diff --git a/mysql-test/r/binary.result-pq b/mysql-test/r/binary.result-pq new file mode 100644 index 000000000000..fe2c7df0938f --- /dev/null +++ b/mysql-test/r/binary.result-pq @@ -0,0 +1,213 @@ +drop table if exists t1,t2; +set names latin1; +create table t1 (name char(20) not null, primary key (name)) charset latin1; +create table t2 (name char(20) binary not null, primary key (name)); +Warnings: +Warning 1287 'BINARY as attribute of a type' is deprecated and will be removed in a future release. Please use a CHARACTER SET clause with _bin collation instead +insert into t1 values ("å"); +insert into t1 values ("ä"); +insert into t1 values ("ö"); +insert into t2 select * from t1; +select * from t1 order by name; +name +å +ä +ö +select concat("*",name,"*") from t1 order by 1; +concat("*",name,"*") +*å* +*ä* +*ö* +select min(name),min(concat("*",name,"*")),max(name),max(concat("*",name,"*")) from t1; +min(name) min(concat("*",name,"*")) max(name) max(concat("*",name,"*")) +å *å* ö *ö* +select * from t2 order by name; +name +ä +å +ö +select concat("*",name,"*") from t2 order by 1; +concat("*",name,"*") +*ä* +*å* +*ö* +select min(name),min(concat("*",name,"*")),max(name),max(concat("*",name,"*")) from t2; +min(name) min(concat("*",name,"*")) max(name) max(concat("*",name,"*")) +ä *ä* ö *ö* +select name from t1 where name between 'Ä' and 'Ö'; +name +ä +ö +select name from t2 where name between 'ä' and 'ö'; +name +ä +å +ö +select name from t2 where name between 'Ä' and 'Ö'; +name +drop table t1,t2; +create table t1 (a char(10) not null, b char(10) binary not null,key (a), key(b)) charset latin1; +Warnings: +Warning 1287 'BINARY as attribute of a type' is deprecated and will be removed in a future release. Please use a CHARACTER SET clause with _bin collation instead +insert into t1 values ("hello ","hello "),("hello2 ","hello2 "); +select concat("-",a,"-",b,"-") from t1 where a="hello"; +concat("-",a,"-",b,"-") +-hello-hello- +select concat("-",a,"-",b,"-") from t1 where a="hello "; +concat("-",a,"-",b,"-") +-hello-hello- +select concat("-",a,"-",b,"-") from t1 ignore index (a) where a="hello "; +concat("-",a,"-",b,"-") +-hello-hello- +select concat("-",a,"-",b,"-") from t1 where b="hello"; +concat("-",a,"-",b,"-") +-hello-hello- +select concat("-",a,"-",b,"-") from t1 where b="hello "; +concat("-",a,"-",b,"-") +-hello-hello- +select concat("-",a,"-",b,"-") from t1 ignore index (b) where b="hello "; +concat("-",a,"-",b,"-") +-hello-hello- +alter table t1 modify b tinytext not null, drop key b, add key (b(100)); +select concat("-",a,"-",b,"-") from t1; +concat("-",a,"-",b,"-") +-hello-hello- +-hello2-hello2- +select concat("-",a,"-",b,"-") from t1 where b="hello "; +concat("-",a,"-",b,"-") +-hello-hello- +select concat("-",a,"-",b,"-") from t1 ignore index (b) where b="hello "; +concat("-",a,"-",b,"-") +-hello-hello- +drop table t1; +create table t1 (b char(8)); +insert into t1 values(NULL); +select b from t1 where binary b like ''; +b +select b from t1 group by binary b like ''; +b +NULL +select b from t1 having binary b like ''; +b +drop table t1; +create table t1 (a char(3) binary, b binary(3)) charset latin1; +Warnings: +Warning 1287 'BINARY as attribute of a type' is deprecated and will be removed in a future release. Please use a CHARACTER SET clause with _bin collation instead +insert into t1 values ('aaa','bbb'),('AAA','BBB'); +select upper(a),upper(b) from t1; +upper(a) upper(b) +AAA bbb +AAA BBB +select lower(a),lower(b) from t1; +lower(a) lower(b) +aaa bbb +aaa BBB +select * from t1 where upper(a)='AAA'; +a b +aaa bbb +AAA BBB +select * from t1 where lower(a)='aaa'; +a b +aaa bbb +AAA BBB +select * from t1 where upper(b)='BBB'; +a b +AAA BBB +select * from t1 where lower(b)='bbb'; +a b +aaa bbb +select charset(a), charset(b), charset(binary 'ccc') from t1 limit 1; +charset(a) charset(b) charset(binary 'ccc') +latin1 binary binary +select collation(a), collation(b), collation(binary 'ccc') from t1 limit 1; +collation(a) collation(b) collation(binary 'ccc') +latin1_bin binary binary +drop table t1; +create table t1( firstname char(20), lastname char(20)); +insert into t1 values ("john","doe"),("John","Doe"); +select * from t1 where firstname='john' and firstname like binary 'john'; +firstname lastname +john doe +select * from t1 where firstname='john' and binary 'john' = firstname; +firstname lastname +john doe +select * from t1 where firstname='john' and firstname = binary 'john'; +firstname lastname +john doe +select * from t1 where firstname='John' and firstname like binary 'john'; +firstname lastname +john doe +select * from t1 where firstname='john' and firstname like binary 'John'; +firstname lastname +John Doe +drop table t1; +create table t1 (a binary) charset utf8mb4; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` binary(1) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +create table t1 (col1 binary(4)); +insert into t1 values ('a'),('a '); +select hex(col1) from t1; +hex(col1) +61000000 +61200000 +alter table t1 modify col1 binary(10); +select hex(col1) from t1; +hex(col1) +61000000000000000000 +61200000000000000000 +insert into t1 values ('b'),('b '); +select hex(col1) from t1; +hex(col1) +61000000000000000000 +61200000000000000000 +62000000000000000000 +62200000000000000000 +drop table t1; +CREATE TABLE t1 ( +a binary(20) NOT NULL DEFAULT '\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0', +index idx(a) +); +INSERT INTO t1 SET a=unhex('1F9480179366F2BF567E1C4B964C1EF029087575'); +INSERT INTO t1 SET a=unhex('1F9480179366F2BF567E1C4B964C1EF029082020'); +INSERT INTO t1 SET a=unhex('1F9480179366F2BF567E1C4B964C1EF029080707'); +SELECT hex(a) FROM t1 order by a; +hex(a) +1F9480179366F2BF567E1C4B964C1EF029080707 +1F9480179366F2BF567E1C4B964C1EF029082020 +1F9480179366F2BF567E1C4B964C1EF029087575 +EXPLAIN SELECT hex(a) FROM t1 order by a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL idx 20 NULL 3 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select hex(`test`.`t1`.`a`) AS `hex(a)` from `test`.`t1` order by `test`.`t1`.`a` +SELECT hex(a) from t1 WHERE a=unhex('1F9480179366F2BF567E1C4B964C1EF029082020'); +hex(a) +1F9480179366F2BF567E1C4B964C1EF029082020 +EXPLAIN +SELECT hex(a) from t1 WHERE a=unhex('1F9480179366F2BF567E1C4B964C1EF029082020'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref idx idx 20 const 1 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select hex(`test`.`t1`.`a`) AS `hex(a)` from `test`.`t1` where (`test`.`t1`.`a` = (unhex('1F9480179366F2BF567E1C4B964C1EF029082020'))) +SELECT hex(a) from t1 WHERE a=unhex('1F9480179366F2BF567E1C4B964C1EF02908'); +hex(a) +DROP TABLE t1; +CREATE TABLE t1 ( +id numeric(20) NOT NULL, +lang varchar(8) NOT NULL, +msg varchar(32) NOT NULL, +PRIMARY KEY (id,lang) +); +INSERT INTO t1 VALUES (33, 'en', 'zzzzzzz'); +INSERT INTO t1 VALUES (31, 'en', 'xxxxxxx'); +INSERT INTO t1 VALUES (32, 'en', 'yyyyyyy'); +SELECT * FROM t1 WHERE id=32; +id lang msg +32 en yyyyyyy +DROP TABLE t1; diff --git a/mysql-test/r/case.result-pq b/mysql-test/r/case.result-pq new file mode 100644 index 000000000000..ee30ab755e9f --- /dev/null +++ b/mysql-test/r/case.result-pq @@ -0,0 +1,481 @@ +drop table if exists t1, t2; +SET sql_mode = 'NO_ENGINE_SUBSTITUTION'; +select CASE "b" when "a" then 1 when "b" then 2 END; +CASE "b" when "a" then 1 when "b" then 2 END +2 +select CASE "c" when "a" then 1 when "b" then 2 END; +CASE "c" when "a" then 1 when "b" then 2 END +NULL +select CASE "c" when "a" then 1 when "b" then 2 ELSE 3 END; +CASE "c" when "a" then 1 when "b" then 2 ELSE 3 END +3 +select CASE BINARY "b" when "a" then 1 when "B" then 2 WHEN "b" then "ok" END; +CASE BINARY "b" when "a" then 1 when "B" then 2 WHEN "b" then "ok" END +ok +select CASE "b" when "a" then 1 when binary "B" then 2 WHEN "b" then "ok" END; +CASE "b" when "a" then 1 when binary "B" then 2 WHEN "b" then "ok" END +ok +select CASE concat("a","b") when concat("ab","") then "a" when "b" then "b" end; +CASE concat("a","b") when concat("ab","") then "a" when "b" then "b" end +a +select CASE when 1=0 then "true" else "false" END; +CASE when 1=0 then "true" else "false" END +false +select CASE 1 when 1 then "one" WHEN 2 then "two" ELSE "more" END; +CASE 1 when 1 then "one" WHEN 2 then "two" ELSE "more" END +one +explain select CASE 1 when 1 then "one" WHEN 2 then "two" ELSE "more" END; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 /* select#1 */ select (case 1 when 1 then 'one' when 2 then 'two' else 'more' end) AS `CASE 1 when 1 then "one" WHEN 2 then "two" ELSE "more" END` +select CASE 2.0 when 1 then "one" WHEN 2.0 then "two" ELSE "more" END; +CASE 2.0 when 1 then "one" WHEN 2.0 then "two" ELSE "more" END +two +select (CASE "two" when "one" then "1" WHEN "two" then "2" END) | 0; +(CASE "two" when "one" then "1" WHEN "two" then "2" END) | 0 +2 +select (CASE "two" when "one" then 1.00 WHEN "two" then 2.00 END) +0.0; +(CASE "two" when "one" then 1.00 WHEN "two" then 2.00 END) +0.0 +2.00 +select case 1/0 when "a" then "true" else "false" END; +case 1/0 when "a" then "true" else "false" END +false +select case 1/0 when "a" then "true" END; +case 1/0 when "a" then "true" END +NULL +select (case 1/0 when "a" then "true" END) | 0; +(case 1/0 when "a" then "true" END) | 0 +NULL +select (case 1/0 when "a" then "true" END) + 0.0; +(case 1/0 when "a" then "true" END) + 0.0 +NULL +select case when 1>0 then "TRUE" else "FALSE" END; +case when 1>0 then "TRUE" else "FALSE" END +TRUE +select case when 1<0 then "TRUE" else "FALSE" END; +case when 1<0 then "TRUE" else "FALSE" END +FALSE +create table t1 (a int); +insert into t1 values(1),(2),(3),(4); +select case a when 1 then 2 when 2 then 3 else 0 end as fcase, count(*) from t1 group by fcase; +fcase count(*) +0 2 +2 1 +3 1 +analyze table t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +explain select case a when 1 then 2 when 2 then 3 else 0 end as fcase, count(*) from t1 group by fcase; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 100.00 Using temporary +Warnings: +Note 1003 /* select#1 */ select (case `test`.`t1`.`a` when 1 then 2 when 2 then 3 else 0 end) AS `fcase`,count(0) AS `count(*)` from `test`.`t1` group by `fcase` +select case a when 1 then "one" when 2 then "two" else "nothing" end as fcase, count(*) from t1 group by fcase; +fcase count(*) +nothing 2 +one 1 +two 1 +drop table t1; +create table t1 (`row` int not null, col int not null, val varchar(255) not null); +insert into t1 values (1,1,'orange'),(1,2,'large'),(2,1,'yellow'),(2,2,'medium'),(3,1,'green'),(3,2,'small'); +select max(case col when 1 then val else null end) as color from t1 group by `row`; +color +orange +yellow +green +drop table t1; +SET NAMES latin1; +CREATE TABLE t1 SELECT +CASE WHEN 1 THEN _latin1'a' COLLATE latin1_danish_ci ELSE _latin1'a' END AS c1, +CASE WHEN 1 THEN _latin1'a' ELSE _latin1'a' COLLATE latin1_danish_ci END AS c2, +CASE WHEN 1 THEN 'a' ELSE 1 END AS c3, +CASE WHEN 1 THEN 1 ELSE 'a' END AS c4, +CASE WHEN 1 THEN 'a' ELSE 1.0 END AS c5, +CASE WHEN 1 THEN 1.0 ELSE 'a' END AS c6, +CASE WHEN 1 THEN 1 ELSE 1.0 END AS c7, +CASE WHEN 1 THEN 1.0 ELSE 1 END AS c8, +CASE WHEN 1 THEN 1.0 END AS c9, +CASE WHEN 1 THEN 0.1e1 else 0.1 END AS c10, +CASE WHEN 1 THEN 0.1e1 else 1 END AS c11, +CASE WHEN 1 THEN 0.1e1 else '1' END AS c12 +; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(1) CHARACTER SET latin1 COLLATE latin1_danish_ci NOT NULL DEFAULT '', + `c2` varchar(1) CHARACTER SET latin1 COLLATE latin1_danish_ci NOT NULL DEFAULT '', + `c3` varchar(1) CHARACTER SET latin1 NOT NULL DEFAULT '', + `c4` varchar(1) CHARACTER SET latin1 NOT NULL DEFAULT '', + `c5` varchar(4) CHARACTER SET latin1 NOT NULL DEFAULT '', + `c6` varchar(4) CHARACTER SET latin1 NOT NULL DEFAULT '', + `c7` decimal(2,1) NOT NULL DEFAULT '0.0', + `c8` decimal(2,1) NOT NULL DEFAULT '0.0', + `c9` decimal(2,1) DEFAULT NULL, + `c10` double NOT NULL DEFAULT '0', + `c11` double NOT NULL DEFAULT '0', + `c12` varchar(22) CHARACTER SET latin1 NOT NULL DEFAULT '' +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +DROP TABLE t1; +SELECT CASE +WHEN 1 +THEN _latin1'a' COLLATE latin1_danish_ci +ELSE _latin1'a' COLLATE latin1_swedish_ci +END; +ERROR HY000: Illegal mix of collations (latin1_danish_ci,EXPLICIT) and (latin1_swedish_ci,EXPLICIT) for operation 'case' +SELECT CASE _latin1'a' COLLATE latin1_general_ci +WHEN _latin1'a' COLLATE latin1_danish_ci THEN 1 +WHEN _latin1'a' COLLATE latin1_swedish_ci THEN 2 +END; +ERROR HY000: Illegal mix of collations (latin1_general_ci,EXPLICIT), (latin1_danish_ci,EXPLICIT), (latin1_swedish_ci,EXPLICIT) for operation 'case' +SELECT +CASE _latin1'a' COLLATE latin1_general_ci WHEN _latin1'A' THEN '1' ELSE 2 END, +CASE _latin1'a' COLLATE latin1_bin WHEN _latin1'A' THEN '1' ELSE 2 END, +CASE _latin1'a' WHEN _latin1'A' COLLATE latin1_swedish_ci THEN '1' ELSE 2 END, +CASE _latin1'a' WHEN _latin1'A' COLLATE latin1_bin THEN '1' ELSE 2 END +; +CASE _latin1'a' COLLATE latin1_general_ci WHEN _latin1'A' THEN '1' ELSE 2 END CASE _latin1'a' COLLATE latin1_bin WHEN _latin1'A' THEN '1' ELSE 2 END CASE _latin1'a' WHEN _latin1'A' COLLATE latin1_swedish_ci THEN '1' ELSE 2 END CASE _latin1'a' WHEN _latin1'A' COLLATE latin1_bin THEN '1' ELSE 2 END +1 2 1 2 +CREATE TABLE t1 SELECT COALESCE(_latin1'a',_latin2'a'); +ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE) and (latin2_general_ci,COERCIBLE) for operation 'coalesce' +CREATE TABLE t1 SELECT COALESCE('a' COLLATE latin1_swedish_ci,'b' COLLATE latin1_bin); +ERROR HY000: Illegal mix of collations (latin1_swedish_ci,EXPLICIT) and (latin1_bin,EXPLICIT) for operation 'coalesce' +CREATE TABLE t1 SELECT +COALESCE(1), COALESCE(1.0),COALESCE('a'), +COALESCE(1,1.0), COALESCE(1,'1'),COALESCE(1.1,'1'), +COALESCE('a' COLLATE latin1_bin,'b'); +explain SELECT +COALESCE(1), COALESCE(1.0),COALESCE('a'), +COALESCE(1,1.0), COALESCE(1,'1'),COALESCE(1.1,'1'), +COALESCE('a' COLLATE latin1_bin,'b'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 /* select#1 */ select coalesce(1) AS `COALESCE(1)`,coalesce(1.0) AS `COALESCE(1.0)`,coalesce('a') AS `COALESCE('a')`,coalesce(1,1.0) AS `COALESCE(1,1.0)`,coalesce(1,'1') AS `COALESCE(1,'1')`,coalesce(1.1,'1') AS `COALESCE(1.1,'1')`,coalesce(('a' collate latin1_bin),'b') AS `COALESCE('a' COLLATE latin1_bin,'b')` +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `COALESCE(1)` int NOT NULL DEFAULT '0', + `COALESCE(1.0)` decimal(2,1) NOT NULL DEFAULT '0.0', + `COALESCE('a')` varchar(1) CHARACTER SET latin1 NOT NULL DEFAULT '', + `COALESCE(1,1.0)` decimal(2,1) NOT NULL DEFAULT '0.0', + `COALESCE(1,'1')` varchar(1) CHARACTER SET latin1 NOT NULL DEFAULT '', + `COALESCE(1.1,'1')` varchar(4) CHARACTER SET latin1 NOT NULL DEFAULT '', + `COALESCE('a' COLLATE latin1_bin,'b')` varchar(1) CHARACTER SET latin1 COLLATE latin1_bin NOT NULL DEFAULT '' +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +DROP TABLE t1; +CREATE TABLE t1 SELECT IFNULL('a' COLLATE latin1_swedish_ci, 'b' COLLATE latin1_bin); +ERROR HY000: Illegal mix of collations (latin1_swedish_ci,EXPLICIT) and (latin1_bin,EXPLICIT) for operation 'ifnull' +SELECT 'case+union+test' +UNION +SELECT CASE LOWER('1') WHEN LOWER('2') THEN 'BUG' ELSE 'nobug' END; +case+union+test +case+union+test +nobug +SELECT CASE LOWER('1') WHEN LOWER('2') THEN 'BUG' ELSE 'nobug' END; +CASE LOWER('1') WHEN LOWER('2') THEN 'BUG' ELSE 'nobug' END +nobug +SELECT 'case+union+test' +UNION +SELECT CASE '1' WHEN '2' THEN 'BUG' ELSE 'nobug' END; +case+union+test +case+union+test +nobug +create table t1(a float, b int default 3); +insert into t1 (a) values (2), (11), (8); +select min(a), min(case when 1=1 then a else NULL end), +min(case when 1!=1 then NULL else a end) +from t1 where b=3 group by b; +min(a) min(case when 1=1 then a else NULL end) min(case when 1!=1 then NULL else a end) +2 2 2 +drop table t1; +CREATE TABLE t1 (EMPNUM INT); +INSERT INTO t1 VALUES (0), (2); +CREATE TABLE t2 (EMPNUM DECIMAL (4, 2)); +INSERT INTO t2 VALUES (0.0), (9.0); +SELECT COALESCE(t2.EMPNUM,t1.EMPNUM) AS CEMPNUM, +t1.EMPNUM AS EMPMUM1, t2.EMPNUM AS EMPNUM2 +FROM t1 LEFT JOIN t2 ON t1.EMPNUM=t2.EMPNUM; +CEMPNUM EMPMUM1 EMPNUM2 +0.00 0 0.00 +2.00 2 NULL +SELECT IFNULL(t2.EMPNUM,t1.EMPNUM) AS CEMPNUM, +t1.EMPNUM AS EMPMUM1, t2.EMPNUM AS EMPNUM2 +FROM t1 LEFT JOIN t2 ON t1.EMPNUM=t2.EMPNUM; +CEMPNUM EMPMUM1 EMPNUM2 +0.00 0 0.00 +2.00 2 NULL +DROP TABLE t1,t2; +End of 4.1 tests +create table t1 (a int, b bigint unsigned); +create table t2 (c int); +insert into t1 (a, b) values (1,4572794622775114594), (2,18196094287899841997), +(3,11120436154190595086); +insert into t2 (c) values (1), (2), (3); +select t1.a, (case t1.a when 0 then 0 else t1.b end) d from t1 +join t2 on t1.a=t2.c order by d; +a d +1 4572794622775114594 +3 11120436154190595086 +2 18196094287899841997 +select t1.a, (case t1.a when 0 then 0 else t1.b end) d from t1 +join t2 on t1.a=t2.c where b=11120436154190595086 order by d; +a d +3 11120436154190595086 +drop table t1, t2; +End of 5.0 tests +CREATE TABLE t1(a YEAR); +SELECT 1 FROM t1 WHERE a=1 AND CASE 1 WHEN a THEN 1 ELSE 1 END; +1 +DROP TABLE t1; +SET sql_mode = default; +# +# Bug#19875294 ASSERTION `SRC' FAILED IN MY_STRNXFRM_UNICODE +# (SIG 6 -STRINGS/CTYPE-UTF8.C:5151) +# +set @@sql_mode=''; +CREATE TABLE t1(c1 SET('','')CHARACTER SET ucs2) engine=innodb; +Warnings: +Note 1291 Column 'c1' has duplicated value '' in SET +INSERT INTO t1 VALUES(990101.102); +Warnings: +Warning 1265 Data truncated for column 'c1' at row 1 +SELECT COALESCE(c1)FROM t1 ORDER BY 1; +COALESCE(c1) + +DROP TABLE t1; +set @@sql_mode=default; +# Bug#24733658: IF and friends give wrong type for signed and unsigned +CREATE TABLE source(bt INTEGER, bf INTEGER, i8u BIGINT UNSIGNED, i8s BIGINT); +INSERT INTO source VALUES +(1,0,0,-9223372036854775808), (1,0,18446744073709551615,9223372036854775807); +CREATE TABLE target +SELECT IF(bt,i8u,i8s) AS u, IF(bf,i8u,i8s) AS s +FROM source; +SHOW CREATE TABLE target; +Table Create Table +target CREATE TABLE `target` ( + `u` decimal(20,0) DEFAULT NULL, + `s` decimal(20,0) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SELECT IF(bt,i8u,i8s) AS u, IF(bf,i8u,i8s) AS s +FROM source; +u s +0 -9223372036854775808 +18446744073709551615 9223372036854775807 +SELECT * FROM target; +u s +0 -9223372036854775808 +18446744073709551615 9223372036854775807 +DROP TABLE target; +CREATE TABLE target +SELECT CASE WHEN bt THEN i8u ELSE i8s END AS u, +CASE WHEN bf THEN i8u ELSE i8s END AS s +FROM source; +SHOW CREATE TABLE target; +Table Create Table +target CREATE TABLE `target` ( + `u` decimal(20,0) DEFAULT NULL, + `s` decimal(20,0) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SELECT CASE WHEN bt THEN i8u ELSE i8s END AS u, +CASE WHEN bf THEN i8u ELSE i8s END AS s +FROM source; +u s +0 -9223372036854775808 +18446744073709551615 9223372036854775807 +SELECT * FROM target; +u s +0 -9223372036854775808 +18446744073709551615 9223372036854775807 +DROP TABLE target; +CREATE TABLE target +SELECT CASE bt WHEN TRUE THEN i8u WHEN FALSE THEN i8s END AS u, +CASE bf WHEN TRUE THEN i8u WHEN FALSE THEN i8s END AS s +FROM source; +SHOW CREATE TABLE target; +Table Create Table +target CREATE TABLE `target` ( + `u` decimal(20,0) DEFAULT NULL, + `s` decimal(20,0) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SELECT CASE bt WHEN TRUE THEN i8u WHEN FALSE THEN i8s END AS u, +CASE bf WHEN TRUE THEN i8u WHEN FALSE THEN i8s END AS s +FROM source; +u s +0 -9223372036854775808 +18446744073709551615 9223372036854775807 +SELECT * FROM target; +u s +0 -9223372036854775808 +18446744073709551615 9223372036854775807 +DROP TABLE target; +CREATE TABLE target +SELECT COALESCE(i8u, i8s) AS u, COALESCE(i8s, i8u) AS s +FROM source; +SHOW CREATE TABLE target; +Table Create Table +target CREATE TABLE `target` ( + `u` decimal(20,0) DEFAULT NULL, + `s` decimal(20,0) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SELECT COALESCE(i8u, i8s) AS u, COALESCE(i8s, i8u) AS s +FROM source; +u s +0 -9223372036854775808 +18446744073709551615 9223372036854775807 +SELECT * FROM target; +u s +0 -9223372036854775808 +18446744073709551615 9223372036854775807 +DROP TABLE source, target; +# Bug#25139420: BIT(n) data type confused when used with IF, IFNULL +CREATE TABLE t (a bit(5)); +INSERT INTO t VALUES +(0),(1),(2),(3),(4),(5),(6),(7),(8),(9), +(10),(11),(12),(19),(20),(21),(29),(30),(31); +SELECT HEX(a), +IFNULL(a,a) AS b, +IFNULL(a,a)+0 AS c, +IFNULL(a+0,a+0) AS d, +IFNULL(a+0,a) AS e, +IFNULL(a,a+0) AS f +FROM t; +HEX(a) b c d e f +0 0 0 0 0 0 +1 1 1 1 1 1 +2 2 2 2 2 2 +3 3 3 3 3 3 +4 4 4 4 4 4 +5 5 5 5 5 5 +6 6 6 6 6 6 +7 7 7 7 7 7 +8 8 8 8 8 8 +9 9 9 9 9 9 +A 10 10 10 10 10 +B 11 11 11 11 11 +C 12 12 12 12 12 +13 19 19 19 19 19 +14 20 20 20 20 20 +15 21 21 21 21 21 +1D 29 29 29 29 29 +1E 30 30 30 30 30 +1F 31 31 31 31 31 +CREATE TABLE u AS SELECT HEX(a), +IFNULL(a,a) AS b, +IFNULL(a,a)+0 AS c, +IFNULL(a+0,a+0) AS d, +IFNULL(a+0,a) AS e, +IFNULL(a,a+0) AS f +FROM t; +SHOW CREATE TABLE u; +Table Create Table +u CREATE TABLE `u` ( + `HEX(a)` varchar(10) CHARACTER SET latin1 DEFAULT NULL, + `b` bit(5) DEFAULT NULL, + `c` int unsigned DEFAULT NULL, + `d` bigint unsigned DEFAULT NULL, + `e` bigint unsigned DEFAULT NULL, + `f` bigint unsigned DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +DROP TABLE t, u; +# Bug#26389402: Outer join optimized away with user-defined functions +CREATE TABLE t00(a INTEGER); +INSERT INTO t00 VALUES (1),(2); +CREATE TABLE t01(a INTEGER); +INSERT INTO t01 VALUES (1); +CREATE VIEW v0 AS +SELECT t00.a, t01.a AS b, IFNULL(t01.a, 666) AS c +FROM t00 LEFT JOIN t01 USING(a); +SELECT * FROM v0 +WHERE c >= 0; +a b c +1 1 1 +2 NULL 666 +CREATE FUNCTION f(a INTEGER) RETURNS INTEGER DETERMINISTIC +RETURN IFNULL(a, 666); +CREATE VIEW v1 AS +SELECT t00.a, t01.a AS b, f(t01.a) AS c +FROM t00 LEFT JOIN t01 USING(a); +SELECT * FROM v1 +WHERE c >= 0; +a b c +1 1 1 +2 NULL 666 +CREATE VIEW v2 AS +SELECT t00.a, t01.a AS b, f(IFNULL(t01.a, NULL)) AS c +FROM t00 LEFT JOIN t01 USING(a); +SELECT * FROM v2 +WHERE c >= 0; +a b c +1 1 1 +2 NULL 666 +SELECT t00.a, t01.a AS b, f(t01.a) AS c +FROM t00 LEFT JOIN t01 USING(a) +WHERE f(t01.a) >= 0; +a b c +1 1 1 +2 NULL 666 +DROP FUNCTION f; +DROP VIEW v0, v1, v2; +DROP TABLE t00, t01; +# +# Bug #25051195 Wrong calculation of decimals after point for IFNULL w/ GROUP BY using +# temporary table. +CREATE TABLE t (i1 INT, +d1 DOUBLE, +e2 DECIMAL(5,2)); +INSERT INTO t VALUES ( 6, 6.0, 10.0/3), +( null, 9.0, 10.0/3), +( 1, null, 10.0/3), +( 2, 2.0, null ); +Warnings: +Note 1265 Data truncated for column 'e2' at row 1 +Note 1265 Data truncated for column 'e2' at row 2 +Note 1265 Data truncated for column 'e2' at row 3 +IFNULL and IF should yield same number for decimals after point here +SELECT IFNULL(e2,i1) nullif_c, +IF(e2 IS NULL,i1,e2) if_c, +SUM(d1) FROM t +GROUP BY e2,i1 ORDER BY nullif_c, SUM(d1); +nullif_c if_c SUM(d1) +2.00 2.00 2 +3.33 3.33 NULL +3.33 3.33 6 +3.33 3.33 9 +DROP TABLE t; +# Bug#29463760 In cases like ifnull(datetime(2), time(3), wrong answer +SET TIMESTAMP=UNIX_TIMESTAMP('2019-03-11 12:00:00'); +CREATE TABLE t1 (dt2 DATETIME(2), t3 TIME(3), d DATE); +INSERT INTO t1 VALUES ('2001-01-01 00:00:00.12', '00:00:00.567', '2002-01-01'); +SELECT CONCAT(IFNULL(t3, d)) AS col1 FROM t1; +col1 +2019-03-11 00:00:00.567 +SELECT CONCAT(IFNULL(t3, d)) AS col1 FROM t1 GROUP BY col1; +col1 +2019-03-11 00:00:00.567 +SET TIMESTAMP=DEFAULT; +DROP TABLE t1; +# +# Test for a memory leak in WL#6570 +# +CREATE TABLE t1 (a VARCHAR(110)); +INSERT INTO t1 VALUES (REPEAT("a",100)); +SELECT (t1.a,t1.a) IN (('a','c'),('a','b')) END FROM t1; +END +0 +SELECT CASE t1.a WHEN 'a' THEN 'c' ELSE 'd' END FROM t1; +CASE t1.a WHEN 'a' THEN 'c' ELSE 'd' END +d +DROP TABLE t1; +# +# Bug#32591239: VAL_JSON(JSON_WRAPPER*):ASSERTION +# `!CURRENT_THD->IS_ERROR() && HAS_VALUE' FAILED +# +CREATE TABLE t1 (col_int int, col_double double, j json); +INSERT INTO t1 VALUES (382218415, -36452.389, '{"key1": 220655528}'); +SELECT col_int FROM t1 +WHERE CASE WHEN POWER(col_double, col_int) THEN j ELSE j END; +ERROR 22003: DOUBLE value is out of range in 'pow(`test`.`t1`.`col_double`,`test`.`t1`.`col_int`)' +DROP TABLE t1; diff --git a/mysql-test/r/condition_filter.result-pq b/mysql-test/r/condition_filter.result-pq new file mode 100644 index 000000000000..eddd059bd7dd --- /dev/null +++ b/mysql-test/r/condition_filter.result-pq @@ -0,0 +1,108 @@ +# +# Bug 20219846: EXPLAIN FOR LIMIT QUERY SHOWS FILESORT BUT EXECUTION +# IS DONE WITH INDEX ONLY +# +CREATE TABLE t0 ( +i0 INTEGER NOT NULL +); +INSERT INTO t0 VALUES (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +CREATE TABLE t1 ( +pk INTEGER PRIMARY KEY, +i1 INTEGER NOT NULL, +i2 INTEGER NOT NULL, +INDEX k1 (i1) +) ENGINE=InnoDB; +INSERT INTO t1 +SELECT a0.i0 + 10*a1.i0 + 100*a2.i0, +(a0.i0 + 10*a1.i0 + 100*a2.i0) % 50, +a0.i0 + 10*a1.i0 + 100*a2.i0 +FROM t0 AS a0, t0 AS a1, t0 AS a2; +CREATE TABLE t2 ( +pk INTEGER PRIMARY KEY, +i1 INTEGER NOT NULL, +i2 INTEGER NOT NULL, +INDEX k1 (i1) +) ENGINE=InnoDB; +INSERT INTO t2 +SELECT a0.i0 + 10*a1.i0 + 100*a2.i0, +(a0.i0 + 10*a1.i0 + 100*a2.i0) % 500, +a0.i0 + 10*a1.i0 + 100*a2.i0 +FROM t0 AS a0, t0 AS a1, t0 AS a2; +ANALYZE TABLE t1,t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +# Explain should show "Using filesort" +EXPLAIN SELECT * +FROM t1 JOIN t2 ON t1.i1=t2.i1 +WHERE t2.i2 > 3 +ORDER BY t1.i1 LIMIT 20; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1000 100.00 Parallel execute (4 workers) +2 SIMPLE t1 NULL ALL k1 NULL NULL NULL 1000 100.00 Using filesort +2 SIMPLE t2 NULL ref k1 k1 4 test.t1.i1 2 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`i1` AS `i1`,`test`.`t1`.`i2` AS `i2`,`test`.`t2`.`pk` AS `pk`,`test`.`t2`.`i1` AS `i1`,`test`.`t2`.`i2` AS `i2` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`i1` = `test`.`t1`.`i1`) and (`test`.`t2`.`i2` > 3)) order by `test`.`t1`.`i1` limit 20 +FLUSH STATUS; +SELECT * +FROM t1 JOIN t2 ON t1.i1=t2.i1 +WHERE t2.i2 > 3 +ORDER BY t1.i1 LIMIT 20; +pk i1 i2 pk i1 i2 +0 0 0 500 0 500 +50 0 50 500 0 500 +100 0 100 500 0 500 +150 0 150 500 0 500 +200 0 200 500 0 500 +250 0 250 500 0 500 +300 0 300 500 0 500 +350 0 350 500 0 500 +400 0 400 500 0 500 +450 0 450 500 0 500 +500 0 500 500 0 500 +550 0 550 500 0 500 +600 0 600 500 0 500 +650 0 650 500 0 500 +700 0 700 500 0 500 +750 0 750 500 0 500 +800 0 800 500 0 500 +850 0 850 500 0 500 +900 0 900 500 0 500 +950 0 950 500 0 500 +# Status from execution should show that filesort was used +SHOW STATUS LIKE 'Sort%'; +Variable_name Value +Sort_merge_passes 0 +Sort_range 0 +Sort_rows 1000 +Sort_scan 4 +DROP TABLE t0, t1, t2; +# +# Bug#30321546: OPTIMIZER TRACE SHOWS DIFFERENT ACTIONS FOR +# A QUERY IF ANOTHER QUERY RUN BEFORE +# +CREATE TABLE t1(a INT); +CREATE TABLE t2(a INT); +INSERT INTO t1 VALUES (1),(2),(3),(4); +INSERT INTO t2 VALUES (1),(2); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +SELECT t1.a, t2.a FROM t1 JOIN t2 +ON t1.a+t2.a = (SELECT COUNT(*) FROM t1); +a a +2 2 +3 1 +SET optimizer_trace="enabled=on"; +SELECT a + (SELECT SUM(a) + (SELECT COUNT(a) FROM t1) FROM t1) AS cnt +FROM t2; +cnt +15 +16 +SELECT TRACE NOT RLIKE '"final_filtering_effect": 1' AS OK +FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +OK +1 +SET optimizer_trace="enabled=off"; +DROP TABLE t1, t2; diff --git a/mysql-test/r/const_folding.result-pq b/mysql-test/r/const_folding.result-pq new file mode 100644 index 000000000000..07470ea82b64 --- /dev/null +++ b/mysql-test/r/const_folding.result-pq @@ -0,0 +1,55815 @@ +# +# Tests with UNSIGNED type TINYINT against int +# +CREATE TABLE tinytbl (colA TINYINT UNSIGNED ); +INSERT INTO tinytbl VALUES (0), (1), +(0),(1),(3), +(254), (255), +(NULL); +ANALYZE TABLE tinytbl; +Table Op Msg_type Msg_text +test.tinytbl analyze status OK +SELECT * FROM tinytbl; +colA +0 +1 +0 +1 +3 +254 +255 +NULL +SELECT * FROM tinytbl WHERE colA < 256; +colA +0 +1 +0 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE colA <= 255; +colA +0 +1 +0 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE colA > 256; +colA +SELECT * FROM tinytbl WHERE colA >= 255; +colA +255 +SELECT * FROM tinytbl WHERE colA > -1; +colA +0 +1 +0 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE colA <= -1; +colA +SELECT * FROM tinytbl WHERE colA <= 0; +colA +0 +0 +SELECT * FROM tinytbl WHERE colA >= 0; +colA +0 +1 +0 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE colA > 0; +colA +1 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE colA = 256; +colA +SELECT * FROM tinytbl WHERE colA <> 256; +colA +0 +1 +0 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE colA = 255; +colA +255 +SELECT * FROM tinytbl WHERE colA <=> 255; +colA +255 +SELECT * FROM tinytbl WHERE NOT(colA <=> 255); +colA +0 +1 +0 +1 +3 +254 +NULL +SELECT * FROM tinytbl WHERE colA <> 255; +colA +0 +1 +0 +1 +3 +254 +SELECT * FROM tinytbl WHERE colA = 0; +colA +0 +0 +SELECT * FROM tinytbl WHERE colA <=> 0; +colA +0 +0 +SELECT * FROM tinytbl WHERE NOT(colA <=> 0); +colA +1 +1 +3 +254 +255 +NULL +SELECT * FROM tinytbl WHERE colA <> 0; +colA +1 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE colA = -1; +colA +SELECT * FROM tinytbl WHERE colA <=> -1; +colA +SELECT * FROM tinytbl WHERE NOT(colA <=> -1); +colA +0 +1 +0 +1 +3 +254 +255 +NULL +SELECT * FROM tinytbl WHERE colA <> -1; +colA +0 +1 +0 +1 +3 +254 +255 +PREPARE p_less FROM 'SELECT * FROM tinytbl WHERE colA < ?'; +PREPARE p_less_eq FROM 'SELECT * FROM tinytbl WHERE colA <= ?'; +PREPARE p_greater FROM 'SELECT * FROM tinytbl WHERE colA > ?'; +PREPARE p_gret_eq FROM 'SELECT * FROM tinytbl WHERE colA >= ?'; +PREPARE p_eq FROM 'SELECT * FROM tinytbl WHERE colA = ?'; +PREPARE p_equal FROM 'SELECT * FROM tinytbl WHERE colA <=> ?'; +PREPARE p_n_equal FROM 'SELECT * FROM tinytbl WHERE NOT(colA <=> ?)'; +PREPARE p_n_eq FROM 'SELECT * FROM tinytbl WHERE colA <> ?'; +SET @maxint_plus_1=256; +SET @maxint=255; +SET @minint_minus_1=-1; +SET @minint=0; +EXECUTE p_less USING @maxint_plus_1; +colA +0 +1 +0 +1 +3 +254 +255 +EXECUTE p_less_eq USING @maxint; +colA +0 +1 +0 +1 +3 +254 +255 +EXECUTE p_greater USING @maxint_plus_1; +colA +EXECUTE p_gret_eq USING @maxint; +colA +255 +EXECUTE p_greater USING @minint_minus_1; +colA +0 +1 +0 +1 +3 +254 +255 +EXECUTE p_less_eq USING @minint_minus_1; +colA +EXECUTE p_less_eq USING @minint; +colA +0 +0 +EXECUTE p_gret_eq USING @minint; +colA +0 +1 +0 +1 +3 +254 +255 +EXECUTE p_greater USING @minint; +colA +1 +1 +3 +254 +255 +EXECUTE p_eq USING @maxint_plus_1; +colA +EXECUTE p_equal USING @maxint_plus_1; +colA +EXECUTE p_n_eq USING @maxint_plus_1; +colA +0 +1 +0 +1 +3 +254 +255 +EXECUTE p_n_equal USING @maxint_plus_1; +colA +0 +1 +0 +1 +3 +254 +255 +NULL +EXECUTE p_eq USING @maxint; +colA +255 +EXECUTE p_equal USING @maxint; +colA +255 +EXECUTE p_n_eq USING @maxint; +colA +0 +1 +0 +1 +3 +254 +EXECUTE p_n_equal USING @maxint; +colA +0 +1 +0 +1 +3 +254 +NULL +EXECUTE p_eq USING @minint; +colA +0 +0 +EXECUTE p_equal USING @minint; +colA +0 +0 +EXECUTE p_n_eq USING @minint; +colA +1 +1 +3 +254 +255 +EXECUTE p_n_equal USING @minint; +colA +1 +1 +3 +254 +255 +NULL +EXECUTE p_eq USING @minint_minus_1; +colA +EXECUTE p_equal USING @minint_minus_1; +colA +EXECUTE p_n_eq USING @minint_minus_1; +colA +0 +1 +0 +1 +3 +254 +255 +EXECUTE p_n_equal USING @minint_minus_1; +colA +0 +1 +0 +1 +3 +254 +255 +NULL +DROP PREPARE p_less; +DROP PREPARE p_less_eq; +DROP PREPARE p_greater; +DROP PREPARE p_gret_eq; +DROP PREPARE p_equal; +DROP PREPARE p_n_eq; +DROP PREPARE p_n_equal; +EXPLAIN SELECT * FROM tinytbl WHERE colA < 256; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (`test`.`tinytbl`.`colA` is not null) +EXPLAIN SELECT * FROM tinytbl WHERE colA <= 255; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (`test`.`tinytbl`.`colA` is not null) +EXPLAIN SELECT * FROM tinytbl WHERE colA > 256; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where false +EXPLAIN SELECT * FROM tinytbl WHERE colA >= 255; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (`test`.`tinytbl`.`colA` = 255) +EXPLAIN SELECT * FROM tinytbl WHERE colA > -1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (`test`.`tinytbl`.`colA` is not null) +EXPLAIN SELECT * FROM tinytbl WHERE colA <= -1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where false +EXPLAIN SELECT * FROM tinytbl WHERE colA <= 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (`test`.`tinytbl`.`colA` = 0) +EXPLAIN SELECT * FROM tinytbl WHERE colA >= 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (`test`.`tinytbl`.`colA` is not null) +EXPLAIN SELECT * FROM tinytbl WHERE colA > 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 33.33 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (`test`.`tinytbl`.`colA` > 0) +EXPLAIN SELECT * FROM tinytbl WHERE colA = 256; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where false +EXPLAIN SELECT * FROM tinytbl WHERE colA <=> 256; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where false +EXPLAIN SELECT * FROM tinytbl WHERE colA <> 256; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (`test`.`tinytbl`.`colA` is not null) +EXPLAIN SELECT * FROM tinytbl WHERE colA = 255; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (`test`.`tinytbl`.`colA` = 255) +EXPLAIN SELECT * FROM tinytbl WHERE colA <=> 255; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (`test`.`tinytbl`.`colA` <=> 255) +EXPLAIN SELECT * FROM tinytbl WHERE colA <> 255; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (`test`.`tinytbl`.`colA` <> 255) +EXPLAIN SELECT * FROM tinytbl WHERE colA = 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (`test`.`tinytbl`.`colA` = 0) +EXPLAIN SELECT * FROM tinytbl WHERE colA <=> 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (`test`.`tinytbl`.`colA` <=> 0) +EXPLAIN SELECT * FROM tinytbl WHERE colA <> 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (`test`.`tinytbl`.`colA` <> 0) +EXPLAIN SELECT * FROM tinytbl WHERE colA = -1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where false +EXPLAIN SELECT * FROM tinytbl WHERE colA <=> -1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where false +EXPLAIN SELECT * FROM tinytbl WHERE colA <> -1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (`test`.`tinytbl`.`colA` is not null) +same queries but constant first +SELECT * FROM tinytbl WHERE 256 > colA; +colA +0 +1 +0 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE 255 >= colA; +colA +0 +1 +0 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE 256 < colA; +colA +SELECT * FROM tinytbl WHERE 255 <= colA; +colA +255 +SELECT * FROM tinytbl WHERE 255 < colA; +colA +SELECT * FROM tinytbl WHERE -1 < colA; +colA +0 +1 +0 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE -1 >= colA; +colA +SELECT * FROM tinytbl WHERE 0 >= colA; +colA +0 +0 +SELECT * FROM tinytbl WHERE 0 <= colA; +colA +0 +1 +0 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE 0 < colA; +colA +1 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE 256 = colA; +colA +SELECT * FROM tinytbl WHERE 256 <=> colA; +colA +SELECT * FROM tinytbl WHERE 256 <> colA; +colA +0 +1 +0 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE 255 = colA; +colA +255 +SELECT * FROM tinytbl WHERE 255 <=> colA; +colA +255 +SELECT * FROM tinytbl WHERE 255 <> colA; +colA +0 +1 +0 +1 +3 +254 +SELECT * FROM tinytbl WHERE 0 = colA; +colA +0 +0 +SELECT * FROM tinytbl WHERE 0 <=> colA; +colA +0 +0 +SELECT * FROM tinytbl WHERE 0 <> colA; +colA +1 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE -1 = colA; +colA +SELECT * FROM tinytbl WHERE -1 <=> colA; +colA +SELECT * FROM tinytbl WHERE -1 <> colA; +colA +0 +1 +0 +1 +3 +254 +255 +PREPARE p_less FROM 'SELECT * FROM tinytbl WHERE ? < colA'; +PREPARE p_less_eq FROM 'SELECT * FROM tinytbl WHERE ? <= colA'; +PREPARE p_greater FROM 'SELECT * FROM tinytbl WHERE ? > colA'; +PREPARE p_gret_eq FROM 'SELECT * FROM tinytbl WHERE ? >= colA'; +PREPARE p_eq FROM 'SELECT * FROM tinytbl WHERE ? = colA'; +PREPARE p_equal FROM 'SELECT * FROM tinytbl WHERE ? <=> colA'; +PREPARE p_n_eq FROM 'SELECT * FROM tinytbl WHERE ? <> colA'; +PREPARE p_n_equal FROM 'SELECT * FROM tinytbl WHERE NOT(? <=> colA)'; +EXECUTE p_greater USING @maxint_plus_1; +colA +0 +1 +0 +1 +3 +254 +255 +EXECUTE p_gret_eq USING @maxint; +colA +0 +1 +0 +1 +3 +254 +255 +EXECUTE p_less USING @maxint_plus_1; +colA +EXECUTE p_less_eq USING @maxint; +colA +255 +EXECUTE p_less USING @minint_minus_1; +colA +0 +1 +0 +1 +3 +254 +255 +EXECUTE p_gret_eq USING @minint_minus_1; +colA +EXECUTE p_gret_eq USING @minint; +colA +0 +0 +EXECUTE p_less_eq USING @minint; +colA +0 +1 +0 +1 +3 +254 +255 +EXECUTE p_less USING @minint; +colA +1 +1 +3 +254 +255 +EXECUTE p_eq USING @maxint_plus_1; +colA +EXECUTE p_equal USING @maxint_plus_1; +colA +EXECUTE p_n_eq USING @maxint_plus_1; +colA +0 +1 +0 +1 +3 +254 +255 +EXECUTE p_n_equal USING @maxint_plus_1; +colA +0 +1 +0 +1 +3 +254 +255 +NULL +EXECUTE p_eq USING @maxint; +colA +255 +EXECUTE p_equal USING @maxint; +colA +255 +EXECUTE p_n_eq USING @maxint; +colA +0 +1 +0 +1 +3 +254 +EXECUTE p_n_equal USING @maxint; +colA +0 +1 +0 +1 +3 +254 +NULL +EXECUTE p_eq USING @minint; +colA +0 +0 +EXECUTE p_equal USING @minint; +colA +0 +0 +EXECUTE p_n_eq USING @minint; +colA +1 +1 +3 +254 +255 +EXECUTE p_n_equal USING @minint; +colA +1 +1 +3 +254 +255 +NULL +EXECUTE p_eq USING @minint_minus_1; +colA +EXECUTE p_equal USING @minint_minus_1; +colA +EXECUTE p_n_eq USING @minint_minus_1; +colA +0 +1 +0 +1 +3 +254 +255 +EXECUTE p_n_equal USING @minint_minus_1; +colA +0 +1 +0 +1 +3 +254 +255 +NULL +DROP PREPARE p_less; +DROP PREPARE p_less_eq; +DROP PREPARE p_greater; +DROP PREPARE p_gret_eq; +DROP PREPARE p_equal; +DROP PREPARE p_n_eq; +DROP PREPARE p_n_equal; +EXPLAIN SELECT * FROM tinytbl WHERE 256 > colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (`test`.`tinytbl`.`colA` is not null) +EXPLAIN SELECT * FROM tinytbl WHERE 255 >= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (`test`.`tinytbl`.`colA` is not null) +EXPLAIN SELECT * FROM tinytbl WHERE 256 < colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where false +EXPLAIN SELECT * FROM tinytbl WHERE 255 <= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (255 = `test`.`tinytbl`.`colA`) +EXPLAIN SELECT * FROM tinytbl WHERE 255 < colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where false +EXPLAIN SELECT * FROM tinytbl WHERE -1 < colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (`test`.`tinytbl`.`colA` is not null) +EXPLAIN SELECT * FROM tinytbl WHERE -1 >= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where false +EXPLAIN SELECT * FROM tinytbl WHERE 0 >= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (0 = `test`.`tinytbl`.`colA`) +EXPLAIN SELECT * FROM tinytbl WHERE 0 <= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (`test`.`tinytbl`.`colA` is not null) +EXPLAIN SELECT * FROM tinytbl WHERE 0 < colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 33.33 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (0 < `test`.`tinytbl`.`colA`) +EXPLAIN SELECT * FROM tinytbl WHERE 256 = colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where false +EXPLAIN SELECT * FROM tinytbl WHERE 256 <=> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where false +EXPLAIN SELECT * FROM tinytbl WHERE 256 <> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (`test`.`tinytbl`.`colA` is not null) +EXPLAIN SELECT * FROM tinytbl WHERE 255 = colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (`test`.`tinytbl`.`colA` = 255) +EXPLAIN SELECT * FROM tinytbl WHERE 255 <=> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (255 <=> `test`.`tinytbl`.`colA`) +EXPLAIN SELECT * FROM tinytbl WHERE 255 <> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (255 <> `test`.`tinytbl`.`colA`) +EXPLAIN SELECT * FROM tinytbl WHERE 0 = colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (`test`.`tinytbl`.`colA` = 0) +EXPLAIN SELECT * FROM tinytbl WHERE 0 <=> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (0 <=> `test`.`tinytbl`.`colA`) +EXPLAIN SELECT * FROM tinytbl WHERE 0 <> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (0 <> `test`.`tinytbl`.`colA`) +EXPLAIN SELECT * FROM tinytbl WHERE -1 = colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where false +EXPLAIN SELECT * FROM tinytbl WHERE -1 <=> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where false +EXPLAIN SELECT * FROM tinytbl WHERE -1 <> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (`test`.`tinytbl`.`colA` is not null) +DROP TABLE tinytbl; +# +# Tests with UNSIGNED type TINYINT against decimal +# +CREATE TABLE tinytbl (colA TINYINT UNSIGNED ); +INSERT INTO tinytbl VALUES (0), (1), +(0),(1),(3), +(254), (255), +(NULL); +ANALYZE TABLE tinytbl; +Table Op Msg_type Msg_text +test.tinytbl analyze status OK +SELECT * FROM tinytbl; +colA +0 +1 +0 +1 +3 +254 +255 +NULL +SELECT * FROM tinytbl WHERE colA < 0.5; +colA +0 +0 +SELECT * FROM tinytbl WHERE colA <= 0.5; +colA +0 +0 +SELECT * FROM tinytbl WHERE colA > 0.5; +colA +1 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE colA >= 0.5; +colA +1 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE colA = 0.5; +colA +SELECT * FROM tinytbl WHERE colA <> 0.5; +colA +0 +1 +0 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE colA < -0.5; +colA +SELECT * FROM tinytbl WHERE colA <= -0.5; +colA +SELECT * FROM tinytbl WHERE colA > -0.5; +colA +0 +1 +0 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE colA >= -0.5; +colA +0 +1 +0 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE colA = -0.5; +colA +SELECT * FROM tinytbl WHERE colA <> -0.5; +colA +0 +1 +0 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE colA < 255.00001; +colA +0 +1 +0 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE colA <= 255.00001; +colA +0 +1 +0 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE colA > 255.00001; +colA +SELECT * FROM tinytbl WHERE colA >= 255.00001; +colA +SELECT * FROM tinytbl WHERE colA = 255.00001; +colA +SELECT * FROM tinytbl WHERE colA <> 255.00001; +colA +0 +1 +0 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE colA < 254.99999; +colA +0 +1 +0 +1 +3 +254 +SELECT * FROM tinytbl WHERE colA <= 254.99999; +colA +0 +1 +0 +1 +3 +254 +SELECT * FROM tinytbl WHERE colA > 254.99999; +colA +255 +SELECT * FROM tinytbl WHERE colA >= 254.99999; +colA +255 +SELECT * FROM tinytbl WHERE colA = 254.99999; +colA +SELECT * FROM tinytbl WHERE colA <> 254.99999; +colA +0 +1 +0 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE colA < 0.00001; +colA +0 +0 +SELECT * FROM tinytbl WHERE colA <= 0.00001; +colA +0 +0 +SELECT * FROM tinytbl WHERE colA > 0.00001; +colA +1 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE colA >= 0.00001; +colA +1 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE colA = 0.00001; +colA +SELECT * FROM tinytbl WHERE colA <> 0.00001; +colA +0 +1 +0 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE colA < -0.99999; +colA +SELECT * FROM tinytbl WHERE colA <= -0.99999; +colA +SELECT * FROM tinytbl WHERE colA > -0.99999; +colA +0 +1 +0 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE colA >= -0.99999; +colA +0 +1 +0 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE colA = -0.99999; +colA +SELECT * FROM tinytbl WHERE colA <> -0.99999; +colA +0 +1 +0 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE colA < 18446744073709551615.00000001; +colA +0 +1 +0 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE colA <= 18446744073709551615.00000001; +colA +0 +1 +0 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE colA > 18446744073709551615.00000001; +colA +SELECT * FROM tinytbl WHERE colA >= 18446744073709551615.00000001; +colA +SELECT * FROM tinytbl WHERE colA = 18446744073709551615.00000001; +colA +SELECT * FROM tinytbl WHERE colA <> 18446744073709551615.00000001; +colA +0 +1 +0 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE colA < -9223372036854775808.00000001; +colA +SELECT * FROM tinytbl WHERE colA <= -9223372036854775808.00000001; +colA +SELECT * FROM tinytbl WHERE colA > -9223372036854775808.00000001; +colA +0 +1 +0 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE colA >= -9223372036854775808.00000001; +colA +0 +1 +0 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE colA = -9223372036854775808.00000001; +colA +SELECT * FROM tinytbl WHERE colA <> -9223372036854775808.00000001; +colA +0 +1 +0 +1 +3 +254 +255 +PREPARE p_less FROM 'SELECT * FROM tinytbl WHERE colA < ?'; +PREPARE p_less_eq FROM 'SELECT * FROM tinytbl WHERE colA <= ?'; +PREPARE p_greater FROM 'SELECT * FROM tinytbl WHERE colA > ?'; +PREPARE p_gret_eq FROM 'SELECT * FROM tinytbl WHERE colA >= ?'; +PREPARE p_equal FROM 'SELECT * FROM tinytbl WHERE colA = ?'; +PREPARE p_n_equal FROM 'SELECT * FROM tinytbl WHERE colA <> ?'; +SET @dec_0_5=0.5; +SET @dec_minus_0_5=-0.5; +SET @dec_max_plus_delta=255.00001; +SET @dec_max_minus_delta=254.99999; +SET @dec_min_plus_delta=0.00001; +SET @dec_min_minus_delta=-0.99999; +SET @dec_too_big_positive_for_any_int=18446744073709551615.00000001; +SET @dec_too_big_negative_for_any_int=-9223372036854775808.00000001; +EXECUTE p_less USING @dec_0_5; +colA +0 +0 +EXECUTE p_less_eq USING @dec_0_5; +colA +0 +0 +EXECUTE p_greater USING @dec_0_5; +colA +1 +1 +3 +254 +255 +EXECUTE p_gret_eq USING @dec_0_5; +colA +1 +1 +3 +254 +255 +EXECUTE p_equal USING @dec_0_5; +colA +EXECUTE p_n_equal USING @dec_0_5; +colA +0 +1 +0 +1 +3 +254 +255 +EXECUTE p_less USING @dec_minus_0_5; +colA +EXECUTE p_less_eq USING @dec_minus_0_5; +colA +EXECUTE p_greater USING @dec_minus_0_5; +colA +0 +1 +0 +1 +3 +254 +255 +EXECUTE p_gret_eq USING @dec_minus_0_5; +colA +0 +1 +0 +1 +3 +254 +255 +EXECUTE p_equal USING @dec_minus_0_5; +colA +EXECUTE p_n_equal USING @dec_minus_0_5; +colA +0 +1 +0 +1 +3 +254 +255 +EXECUTE p_less USING @dec_max_plus_delta; +colA +0 +1 +0 +1 +3 +254 +255 +EXECUTE p_less_eq USING @dec_max_plus_delta; +colA +0 +1 +0 +1 +3 +254 +255 +EXECUTE p_greater USING @dec_max_plus_delta; +colA +EXECUTE p_gret_eq USING @dec_max_plus_delta; +colA +EXECUTE p_equal USING @dec_max_plus_delta; +colA +EXECUTE p_n_equal USING @dec_max_plus_delta; +colA +0 +1 +0 +1 +3 +254 +255 +EXECUTE p_less USING @dec_max_minus_delta; +colA +0 +1 +0 +1 +3 +254 +EXECUTE p_less_eq USING @dec_max_minus_delta; +colA +0 +1 +0 +1 +3 +254 +EXECUTE p_greater USING @dec_max_minus_delta; +colA +255 +EXECUTE p_gret_eq USING @dec_max_minus_delta; +colA +255 +EXECUTE p_equal USING @dec_max_minus_delta; +colA +EXECUTE p_n_equal USING @dec_max_minus_delta; +colA +0 +1 +0 +1 +3 +254 +255 +EXECUTE p_less USING @dec_min_plus_delta; +colA +0 +0 +EXECUTE p_less_eq USING @dec_min_plus_delta; +colA +0 +0 +EXECUTE p_greater USING @dec_min_plus_delta; +colA +1 +1 +3 +254 +255 +EXECUTE p_gret_eq USING @dec_min_plus_delta; +colA +1 +1 +3 +254 +255 +EXECUTE p_equal USING @dec_min_plus_delta; +colA +EXECUTE p_n_equal USING @dec_min_plus_delta; +colA +0 +1 +0 +1 +3 +254 +255 +EXECUTE p_less USING @dec_min_minus_delta; +colA +EXECUTE p_less_eq USING @dec_min_minus_delta; +colA +EXECUTE p_greater USING @dec_min_minus_delta; +colA +0 +1 +0 +1 +3 +254 +255 +EXECUTE p_gret_eq USING @dec_min_minus_delta; +colA +0 +1 +0 +1 +3 +254 +255 +EXECUTE p_equal USING @dec_min_minus_delta; +colA +EXECUTE p_n_equal USING @dec_min_minus_delta; +colA +0 +1 +0 +1 +3 +254 +255 +EXECUTE p_less USING @dec_too_big_positive_for_any_int; +colA +0 +1 +0 +1 +3 +254 +255 +EXECUTE p_less_eq USING @dec_too_big_positive_for_any_int; +colA +0 +1 +0 +1 +3 +254 +255 +EXECUTE p_greater USING @dec_too_big_positive_for_any_int; +colA +EXECUTE p_gret_eq USING @dec_too_big_positive_for_any_int; +colA +EXECUTE p_equal USING @dec_too_big_positive_for_any_int; +colA +EXECUTE p_n_equal USING @dec_too_big_positive_for_any_int; +colA +0 +1 +0 +1 +3 +254 +255 +EXECUTE p_less USING @dec_too_big_negative_for_any_int; +colA +EXECUTE p_less_eq USING @dec_too_big_negative_for_any_int; +colA +EXECUTE p_greater USING @dec_too_big_negative_for_any_int; +colA +0 +1 +0 +1 +3 +254 +255 +EXECUTE p_gret_eq USING @dec_too_big_negative_for_any_int; +colA +0 +1 +0 +1 +3 +254 +255 +EXECUTE p_equal USING @dec_too_big_negative_for_any_int; +colA +EXECUTE p_n_equal USING @dec_too_big_negative_for_any_int; +colA +0 +1 +0 +1 +3 +254 +255 +DROP PREPARE p_less; +DROP PREPARE p_less_eq; +DROP PREPARE p_greater; +DROP PREPARE p_gret_eq; +DROP PREPARE p_equal; +DROP PREPARE p_n_equal; +DROP TABLE tinytbl; +Cruft inside string +CREATE TABLE t(i INT); +INSERT INTO t VALUES (-1), (0), (1); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +SELECT * FROM t WHERE i > 'A'; +i +1 +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'A' +EXPLAIN SELECT * FROM t WHERE i > 'A'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'A' +Note 1003 /* select#1 */ select `test`.`t`.`i` AS `i` from `test`.`t` where (`test`.`t`.`i` > 0) +DROP TABLE t; +Detect decimal inside a string when compared to int +Used to return one row; should be none. +CREATE TABLE t(i BIGINT); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +INSERT INTO t VALUES (1), (2); +SELECT * FROM t WHERE i = '1.1'; +i +EXPLAIN SELECT * FROM t WHERE i = '1.1'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`i` AS `i` from `test`.`t` where false +DROP TABLE t; +Detect out of range real inside a string when compared to int +Used to return one row; should be none. +CREATE TABLE t(i TINYINT); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +INSERT INTO t VALUES (1), (2); +SELECT * FROM t WHERE i > '1E10'; +i +EXPLAIN SELECT * FROM t WHERE i > '1E10'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`i` AS `i` from `test`.`t` where false +DROP TABLE t; +Detect out of range real inside a string when compared to int +Used to return one row; should be none. +CREATE TABLE t(i TINYINT); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +INSERT INTO t VALUES (0); +SELECT * FROM t WHERE i = '1E-308'; +i +EXPLAIN SELECT * FROM t WHERE i = '1E-308'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`i` AS `i` from `test`.`t` where false +Above query should yield the same as this: +SELECT * FROM t WHERE i = 1E-308; +i +EXPLAIN SELECT * FROM t WHERE i = 1E-308; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`i` AS `i` from `test`.`t` where false +DROP TABLE t; +# +# Tests with UNSIGNED type TINYINT against int +# +CREATE TABLE tinytbl (colA TINYINT UNSIGNED ); +INSERT INTO tinytbl VALUES ('0'), ('1'), +(0),(1),(3), +('254'), ('255'), +(NULL); +ANALYZE TABLE tinytbl; +Table Op Msg_type Msg_text +test.tinytbl analyze status OK +SELECT * FROM tinytbl; +colA +0 +1 +0 +1 +3 +254 +255 +NULL +SELECT * FROM tinytbl WHERE colA < '256'; +colA +0 +1 +0 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE colA <= '255'; +colA +0 +1 +0 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE colA > '256'; +colA +SELECT * FROM tinytbl WHERE colA >= '255'; +colA +255 +SELECT * FROM tinytbl WHERE colA > '-1'; +colA +0 +1 +0 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE colA <= '-1'; +colA +SELECT * FROM tinytbl WHERE colA <= '0'; +colA +0 +0 +SELECT * FROM tinytbl WHERE colA >= '0'; +colA +0 +1 +0 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE colA > '0'; +colA +1 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE colA = '256'; +colA +SELECT * FROM tinytbl WHERE colA <> '256'; +colA +0 +1 +0 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE colA = '255'; +colA +255 +SELECT * FROM tinytbl WHERE colA <=> '255'; +colA +255 +SELECT * FROM tinytbl WHERE NOT(colA <=> '255'); +colA +0 +1 +0 +1 +3 +254 +NULL +SELECT * FROM tinytbl WHERE colA <> '255'; +colA +0 +1 +0 +1 +3 +254 +SELECT * FROM tinytbl WHERE colA = '0'; +colA +0 +0 +SELECT * FROM tinytbl WHERE colA <=> '0'; +colA +0 +0 +SELECT * FROM tinytbl WHERE NOT(colA <=> '0'); +colA +1 +1 +3 +254 +255 +NULL +SELECT * FROM tinytbl WHERE colA <> '0'; +colA +1 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE colA = '-1'; +colA +SELECT * FROM tinytbl WHERE colA <=> '-1'; +colA +SELECT * FROM tinytbl WHERE NOT(colA <=> '-1'); +colA +0 +1 +0 +1 +3 +254 +255 +NULL +SELECT * FROM tinytbl WHERE colA <> '-1'; +colA +0 +1 +0 +1 +3 +254 +255 +PREPARE p_less FROM 'SELECT * FROM tinytbl WHERE colA < ?'; +PREPARE p_less_eq FROM 'SELECT * FROM tinytbl WHERE colA <= ?'; +PREPARE p_greater FROM 'SELECT * FROM tinytbl WHERE colA > ?'; +PREPARE p_gret_eq FROM 'SELECT * FROM tinytbl WHERE colA >= ?'; +PREPARE p_eq FROM 'SELECT * FROM tinytbl WHERE colA = ?'; +PREPARE p_equal FROM 'SELECT * FROM tinytbl WHERE colA <=> ?'; +PREPARE p_n_equal FROM 'SELECT * FROM tinytbl WHERE NOT(colA <=> ?)'; +PREPARE p_n_eq FROM 'SELECT * FROM tinytbl WHERE colA <> ?'; +SET @maxint_plus_1='256'; +SET @maxint='255'; +SET @minint_minus_1='-1'; +SET @minint='0'; +EXECUTE p_less USING @maxint_plus_1; +colA +0 +1 +0 +1 +3 +254 +255 +EXECUTE p_less_eq USING @maxint; +colA +0 +1 +0 +1 +3 +254 +255 +EXECUTE p_greater USING @maxint_plus_1; +colA +EXECUTE p_gret_eq USING @maxint; +colA +255 +EXECUTE p_greater USING @minint_minus_1; +colA +0 +1 +0 +1 +3 +254 +255 +EXECUTE p_less_eq USING @minint_minus_1; +colA +EXECUTE p_less_eq USING @minint; +colA +0 +0 +EXECUTE p_gret_eq USING @minint; +colA +0 +1 +0 +1 +3 +254 +255 +EXECUTE p_greater USING @minint; +colA +1 +1 +3 +254 +255 +EXECUTE p_eq USING @maxint_plus_1; +colA +EXECUTE p_equal USING @maxint_plus_1; +colA +EXECUTE p_n_eq USING @maxint_plus_1; +colA +0 +1 +0 +1 +3 +254 +255 +EXECUTE p_n_equal USING @maxint_plus_1; +colA +0 +1 +0 +1 +3 +254 +255 +NULL +EXECUTE p_eq USING @maxint; +colA +255 +EXECUTE p_equal USING @maxint; +colA +255 +EXECUTE p_n_eq USING @maxint; +colA +0 +1 +0 +1 +3 +254 +EXECUTE p_n_equal USING @maxint; +colA +0 +1 +0 +1 +3 +254 +NULL +EXECUTE p_eq USING @minint; +colA +0 +0 +EXECUTE p_equal USING @minint; +colA +0 +0 +EXECUTE p_n_eq USING @minint; +colA +1 +1 +3 +254 +255 +EXECUTE p_n_equal USING @minint; +colA +1 +1 +3 +254 +255 +NULL +EXECUTE p_eq USING @minint_minus_1; +colA +EXECUTE p_equal USING @minint_minus_1; +colA +EXECUTE p_n_eq USING @minint_minus_1; +colA +0 +1 +0 +1 +3 +254 +255 +EXECUTE p_n_equal USING @minint_minus_1; +colA +0 +1 +0 +1 +3 +254 +255 +NULL +DROP PREPARE p_less; +DROP PREPARE p_less_eq; +DROP PREPARE p_greater; +DROP PREPARE p_gret_eq; +DROP PREPARE p_equal; +DROP PREPARE p_n_eq; +DROP PREPARE p_n_equal; +EXPLAIN SELECT * FROM tinytbl WHERE colA < '256'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (`test`.`tinytbl`.`colA` is not null) +EXPLAIN SELECT * FROM tinytbl WHERE colA <= '255'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (`test`.`tinytbl`.`colA` is not null) +EXPLAIN SELECT * FROM tinytbl WHERE colA > '256'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where false +EXPLAIN SELECT * FROM tinytbl WHERE colA >= '255'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (`test`.`tinytbl`.`colA` = 255) +EXPLAIN SELECT * FROM tinytbl WHERE colA > '-1'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (`test`.`tinytbl`.`colA` is not null) +EXPLAIN SELECT * FROM tinytbl WHERE colA <= '-1'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where false +EXPLAIN SELECT * FROM tinytbl WHERE colA <= '0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (`test`.`tinytbl`.`colA` = 0) +EXPLAIN SELECT * FROM tinytbl WHERE colA >= '0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (`test`.`tinytbl`.`colA` is not null) +EXPLAIN SELECT * FROM tinytbl WHERE colA > '0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 33.33 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (`test`.`tinytbl`.`colA` > 0) +EXPLAIN SELECT * FROM tinytbl WHERE colA = '256'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where false +EXPLAIN SELECT * FROM tinytbl WHERE colA <=> '256'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where false +EXPLAIN SELECT * FROM tinytbl WHERE colA <> '256'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (`test`.`tinytbl`.`colA` is not null) +EXPLAIN SELECT * FROM tinytbl WHERE colA = '255'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (`test`.`tinytbl`.`colA` = 255) +EXPLAIN SELECT * FROM tinytbl WHERE colA <=> '255'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (`test`.`tinytbl`.`colA` <=> 255) +EXPLAIN SELECT * FROM tinytbl WHERE colA <> '255'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (`test`.`tinytbl`.`colA` <> 255) +EXPLAIN SELECT * FROM tinytbl WHERE colA = '0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (`test`.`tinytbl`.`colA` = 0) +EXPLAIN SELECT * FROM tinytbl WHERE colA <=> '0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (`test`.`tinytbl`.`colA` <=> 0) +EXPLAIN SELECT * FROM tinytbl WHERE colA <> '0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (`test`.`tinytbl`.`colA` <> 0) +EXPLAIN SELECT * FROM tinytbl WHERE colA = '-1'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where false +EXPLAIN SELECT * FROM tinytbl WHERE colA <=> '-1'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where false +EXPLAIN SELECT * FROM tinytbl WHERE colA <> '-1'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (`test`.`tinytbl`.`colA` is not null) +same queries but constant first +SELECT * FROM tinytbl WHERE '256' > colA; +colA +0 +1 +0 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE '255' >= colA; +colA +0 +1 +0 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE '256' < colA; +colA +SELECT * FROM tinytbl WHERE '255' <= colA; +colA +255 +SELECT * FROM tinytbl WHERE '255' < colA; +colA +SELECT * FROM tinytbl WHERE '-1' < colA; +colA +0 +1 +0 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE '-1' >= colA; +colA +SELECT * FROM tinytbl WHERE '0' >= colA; +colA +0 +0 +SELECT * FROM tinytbl WHERE '0' <= colA; +colA +0 +1 +0 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE '0' < colA; +colA +1 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE '256' = colA; +colA +SELECT * FROM tinytbl WHERE '256' <=> colA; +colA +SELECT * FROM tinytbl WHERE '256' <> colA; +colA +0 +1 +0 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE '255' = colA; +colA +255 +SELECT * FROM tinytbl WHERE '255' <=> colA; +colA +255 +SELECT * FROM tinytbl WHERE '255' <> colA; +colA +0 +1 +0 +1 +3 +254 +SELECT * FROM tinytbl WHERE '0' = colA; +colA +0 +0 +SELECT * FROM tinytbl WHERE '0' <=> colA; +colA +0 +0 +SELECT * FROM tinytbl WHERE '0' <> colA; +colA +1 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE '-1' = colA; +colA +SELECT * FROM tinytbl WHERE '-1' <=> colA; +colA +SELECT * FROM tinytbl WHERE '-1' <> colA; +colA +0 +1 +0 +1 +3 +254 +255 +PREPARE p_less FROM 'SELECT * FROM tinytbl WHERE ? < colA'; +PREPARE p_less_eq FROM 'SELECT * FROM tinytbl WHERE ? <= colA'; +PREPARE p_greater FROM 'SELECT * FROM tinytbl WHERE ? > colA'; +PREPARE p_gret_eq FROM 'SELECT * FROM tinytbl WHERE ? >= colA'; +PREPARE p_eq FROM 'SELECT * FROM tinytbl WHERE ? = colA'; +PREPARE p_equal FROM 'SELECT * FROM tinytbl WHERE ? <=> colA'; +PREPARE p_n_eq FROM 'SELECT * FROM tinytbl WHERE ? <> colA'; +PREPARE p_n_equal FROM 'SELECT * FROM tinytbl WHERE NOT(? <=> colA)'; +EXECUTE p_greater USING @maxint_plus_1; +colA +0 +1 +0 +1 +3 +254 +255 +EXECUTE p_gret_eq USING @maxint; +colA +0 +1 +0 +1 +3 +254 +255 +EXECUTE p_less USING @maxint_plus_1; +colA +EXECUTE p_less_eq USING @maxint; +colA +255 +EXECUTE p_less USING @minint_minus_1; +colA +0 +1 +0 +1 +3 +254 +255 +EXECUTE p_gret_eq USING @minint_minus_1; +colA +EXECUTE p_gret_eq USING @minint; +colA +0 +0 +EXECUTE p_less_eq USING @minint; +colA +0 +1 +0 +1 +3 +254 +255 +EXECUTE p_less USING @minint; +colA +1 +1 +3 +254 +255 +EXECUTE p_eq USING @maxint_plus_1; +colA +EXECUTE p_equal USING @maxint_plus_1; +colA +EXECUTE p_n_eq USING @maxint_plus_1; +colA +0 +1 +0 +1 +3 +254 +255 +EXECUTE p_n_equal USING @maxint_plus_1; +colA +0 +1 +0 +1 +3 +254 +255 +NULL +EXECUTE p_eq USING @maxint; +colA +255 +EXECUTE p_equal USING @maxint; +colA +255 +EXECUTE p_n_eq USING @maxint; +colA +0 +1 +0 +1 +3 +254 +EXECUTE p_n_equal USING @maxint; +colA +0 +1 +0 +1 +3 +254 +NULL +EXECUTE p_eq USING @minint; +colA +0 +0 +EXECUTE p_equal USING @minint; +colA +0 +0 +EXECUTE p_n_eq USING @minint; +colA +1 +1 +3 +254 +255 +EXECUTE p_n_equal USING @minint; +colA +1 +1 +3 +254 +255 +NULL +EXECUTE p_eq USING @minint_minus_1; +colA +EXECUTE p_equal USING @minint_minus_1; +colA +EXECUTE p_n_eq USING @minint_minus_1; +colA +0 +1 +0 +1 +3 +254 +255 +EXECUTE p_n_equal USING @minint_minus_1; +colA +0 +1 +0 +1 +3 +254 +255 +NULL +DROP PREPARE p_less; +DROP PREPARE p_less_eq; +DROP PREPARE p_greater; +DROP PREPARE p_gret_eq; +DROP PREPARE p_equal; +DROP PREPARE p_n_eq; +DROP PREPARE p_n_equal; +EXPLAIN SELECT * FROM tinytbl WHERE '256' > colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (`test`.`tinytbl`.`colA` is not null) +EXPLAIN SELECT * FROM tinytbl WHERE '255' >= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (`test`.`tinytbl`.`colA` is not null) +EXPLAIN SELECT * FROM tinytbl WHERE '256' < colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where false +EXPLAIN SELECT * FROM tinytbl WHERE '255' <= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (255 = `test`.`tinytbl`.`colA`) +EXPLAIN SELECT * FROM tinytbl WHERE '255' < colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where false +EXPLAIN SELECT * FROM tinytbl WHERE '-1' < colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (`test`.`tinytbl`.`colA` is not null) +EXPLAIN SELECT * FROM tinytbl WHERE '-1' >= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where false +EXPLAIN SELECT * FROM tinytbl WHERE '0' >= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (0 = `test`.`tinytbl`.`colA`) +EXPLAIN SELECT * FROM tinytbl WHERE '0' <= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (`test`.`tinytbl`.`colA` is not null) +EXPLAIN SELECT * FROM tinytbl WHERE '0' < colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 33.33 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (0 < `test`.`tinytbl`.`colA`) +EXPLAIN SELECT * FROM tinytbl WHERE '256' = colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where false +EXPLAIN SELECT * FROM tinytbl WHERE '256' <=> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where false +EXPLAIN SELECT * FROM tinytbl WHERE '256' <> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (`test`.`tinytbl`.`colA` is not null) +EXPLAIN SELECT * FROM tinytbl WHERE '255' = colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (255 = `test`.`tinytbl`.`colA`) +EXPLAIN SELECT * FROM tinytbl WHERE '255' <=> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (255 <=> `test`.`tinytbl`.`colA`) +EXPLAIN SELECT * FROM tinytbl WHERE '255' <> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (255 <> `test`.`tinytbl`.`colA`) +EXPLAIN SELECT * FROM tinytbl WHERE '0' = colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (0 = `test`.`tinytbl`.`colA`) +EXPLAIN SELECT * FROM tinytbl WHERE '0' <=> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (0 <=> `test`.`tinytbl`.`colA`) +EXPLAIN SELECT * FROM tinytbl WHERE '0' <> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (0 <> `test`.`tinytbl`.`colA`) +EXPLAIN SELECT * FROM tinytbl WHERE '-1' = colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where false +EXPLAIN SELECT * FROM tinytbl WHERE '-1' <=> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where false +EXPLAIN SELECT * FROM tinytbl WHERE '-1' <> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (`test`.`tinytbl`.`colA` is not null) +DROP TABLE tinytbl; +# +# Tests with UNSIGNED type TINYINT against int +# +CREATE TABLE tinytbl (colA TINYINT UNSIGNED ); +INSERT INTO tinytbl VALUES ('0.0'), ('1.0'), +(0),(1),(3), +('254.0'), ('255.0'), +(NULL); +ANALYZE TABLE tinytbl; +Table Op Msg_type Msg_text +test.tinytbl analyze status OK +SELECT * FROM tinytbl; +colA +0 +1 +0 +1 +3 +254 +255 +NULL +SELECT * FROM tinytbl WHERE colA < '256.1'; +colA +0 +1 +0 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE colA <= '255.0'; +colA +0 +1 +0 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE colA > '256.1'; +colA +SELECT * FROM tinytbl WHERE colA >= '255.0'; +colA +255 +SELECT * FROM tinytbl WHERE colA > '-1.1'; +colA +0 +1 +0 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE colA <= '-1.1'; +colA +SELECT * FROM tinytbl WHERE colA <= '0.0'; +colA +0 +0 +SELECT * FROM tinytbl WHERE colA >= '0.0'; +colA +0 +1 +0 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE colA > '0.0'; +colA +1 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE colA = '256.1'; +colA +SELECT * FROM tinytbl WHERE colA <> '256.1'; +colA +0 +1 +0 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE colA = '255.0'; +colA +255 +SELECT * FROM tinytbl WHERE colA <=> '255.0'; +colA +255 +SELECT * FROM tinytbl WHERE NOT(colA <=> '255.0'); +colA +0 +1 +0 +1 +3 +254 +NULL +SELECT * FROM tinytbl WHERE colA <> '255.0'; +colA +0 +1 +0 +1 +3 +254 +SELECT * FROM tinytbl WHERE colA = '0.0'; +colA +0 +0 +SELECT * FROM tinytbl WHERE colA <=> '0.0'; +colA +0 +0 +SELECT * FROM tinytbl WHERE NOT(colA <=> '0.0'); +colA +1 +1 +3 +254 +255 +NULL +SELECT * FROM tinytbl WHERE colA <> '0.0'; +colA +1 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE colA = '-1.1'; +colA +SELECT * FROM tinytbl WHERE colA <=> '-1.1'; +colA +SELECT * FROM tinytbl WHERE NOT(colA <=> '-1.1'); +colA +0 +1 +0 +1 +3 +254 +255 +NULL +SELECT * FROM tinytbl WHERE colA <> '-1.1'; +colA +0 +1 +0 +1 +3 +254 +255 +PREPARE p_less FROM 'SELECT * FROM tinytbl WHERE colA < ?'; +PREPARE p_less_eq FROM 'SELECT * FROM tinytbl WHERE colA <= ?'; +PREPARE p_greater FROM 'SELECT * FROM tinytbl WHERE colA > ?'; +PREPARE p_gret_eq FROM 'SELECT * FROM tinytbl WHERE colA >= ?'; +PREPARE p_eq FROM 'SELECT * FROM tinytbl WHERE colA = ?'; +PREPARE p_equal FROM 'SELECT * FROM tinytbl WHERE colA <=> ?'; +PREPARE p_n_equal FROM 'SELECT * FROM tinytbl WHERE NOT(colA <=> ?)'; +PREPARE p_n_eq FROM 'SELECT * FROM tinytbl WHERE colA <> ?'; +SET @maxint_plus_1='256.1'; +SET @maxint='255.0'; +SET @minint_minus_1='-1.1'; +SET @minint='0.0'; +EXECUTE p_less USING @maxint_plus_1; +colA +0 +1 +0 +1 +3 +254 +255 +EXECUTE p_less_eq USING @maxint; +colA +0 +1 +0 +1 +3 +254 +255 +EXECUTE p_greater USING @maxint_plus_1; +colA +EXECUTE p_gret_eq USING @maxint; +colA +255 +EXECUTE p_greater USING @minint_minus_1; +colA +0 +1 +0 +1 +3 +254 +255 +EXECUTE p_less_eq USING @minint_minus_1; +colA +EXECUTE p_less_eq USING @minint; +colA +0 +0 +EXECUTE p_gret_eq USING @minint; +colA +0 +1 +0 +1 +3 +254 +255 +EXECUTE p_greater USING @minint; +colA +1 +1 +3 +254 +255 +EXECUTE p_eq USING @maxint_plus_1; +colA +EXECUTE p_equal USING @maxint_plus_1; +colA +EXECUTE p_n_eq USING @maxint_plus_1; +colA +0 +1 +0 +1 +3 +254 +255 +EXECUTE p_n_equal USING @maxint_plus_1; +colA +0 +1 +0 +1 +3 +254 +255 +NULL +EXECUTE p_eq USING @maxint; +colA +255 +EXECUTE p_equal USING @maxint; +colA +255 +EXECUTE p_n_eq USING @maxint; +colA +0 +1 +0 +1 +3 +254 +EXECUTE p_n_equal USING @maxint; +colA +0 +1 +0 +1 +3 +254 +NULL +EXECUTE p_eq USING @minint; +colA +0 +0 +EXECUTE p_equal USING @minint; +colA +0 +0 +EXECUTE p_n_eq USING @minint; +colA +1 +1 +3 +254 +255 +EXECUTE p_n_equal USING @minint; +colA +1 +1 +3 +254 +255 +NULL +EXECUTE p_eq USING @minint_minus_1; +colA +EXECUTE p_equal USING @minint_minus_1; +colA +EXECUTE p_n_eq USING @minint_minus_1; +colA +0 +1 +0 +1 +3 +254 +255 +EXECUTE p_n_equal USING @minint_minus_1; +colA +0 +1 +0 +1 +3 +254 +255 +NULL +DROP PREPARE p_less; +DROP PREPARE p_less_eq; +DROP PREPARE p_greater; +DROP PREPARE p_gret_eq; +DROP PREPARE p_equal; +DROP PREPARE p_n_eq; +DROP PREPARE p_n_equal; +EXPLAIN SELECT * FROM tinytbl WHERE colA < '256.1'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (`test`.`tinytbl`.`colA` is not null) +EXPLAIN SELECT * FROM tinytbl WHERE colA <= '255.0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (`test`.`tinytbl`.`colA` is not null) +EXPLAIN SELECT * FROM tinytbl WHERE colA > '256.1'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where false +EXPLAIN SELECT * FROM tinytbl WHERE colA >= '255.0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (`test`.`tinytbl`.`colA` = 255) +EXPLAIN SELECT * FROM tinytbl WHERE colA > '-1.1'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (`test`.`tinytbl`.`colA` is not null) +EXPLAIN SELECT * FROM tinytbl WHERE colA <= '-1.1'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where false +EXPLAIN SELECT * FROM tinytbl WHERE colA <= '0.0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (`test`.`tinytbl`.`colA` = 0) +EXPLAIN SELECT * FROM tinytbl WHERE colA >= '0.0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (`test`.`tinytbl`.`colA` is not null) +EXPLAIN SELECT * FROM tinytbl WHERE colA > '0.0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 33.33 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (`test`.`tinytbl`.`colA` > 0) +EXPLAIN SELECT * FROM tinytbl WHERE colA = '256.1'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where false +EXPLAIN SELECT * FROM tinytbl WHERE colA <=> '256.1'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where false +EXPLAIN SELECT * FROM tinytbl WHERE colA <> '256.1'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (`test`.`tinytbl`.`colA` is not null) +EXPLAIN SELECT * FROM tinytbl WHERE colA = '255.0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (`test`.`tinytbl`.`colA` = 255) +EXPLAIN SELECT * FROM tinytbl WHERE colA <=> '255.0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (`test`.`tinytbl`.`colA` <=> 255) +EXPLAIN SELECT * FROM tinytbl WHERE colA <> '255.0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (`test`.`tinytbl`.`colA` <> 255) +EXPLAIN SELECT * FROM tinytbl WHERE colA = '0.0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (`test`.`tinytbl`.`colA` = 0) +EXPLAIN SELECT * FROM tinytbl WHERE colA <=> '0.0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (`test`.`tinytbl`.`colA` <=> 0) +EXPLAIN SELECT * FROM tinytbl WHERE colA <> '0.0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (`test`.`tinytbl`.`colA` <> 0) +EXPLAIN SELECT * FROM tinytbl WHERE colA = '-1.1'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where false +EXPLAIN SELECT * FROM tinytbl WHERE colA <=> '-1.1'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where false +EXPLAIN SELECT * FROM tinytbl WHERE colA <> '-1.1'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (`test`.`tinytbl`.`colA` is not null) +same queries but constant first +SELECT * FROM tinytbl WHERE '256.1' > colA; +colA +0 +1 +0 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE '255.0' >= colA; +colA +0 +1 +0 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE '256.1' < colA; +colA +SELECT * FROM tinytbl WHERE '255.0' <= colA; +colA +255 +SELECT * FROM tinytbl WHERE '255.0' < colA; +colA +SELECT * FROM tinytbl WHERE '-1.1' < colA; +colA +0 +1 +0 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE '-1.1' >= colA; +colA +SELECT * FROM tinytbl WHERE '0.0' >= colA; +colA +0 +0 +SELECT * FROM tinytbl WHERE '0.0' <= colA; +colA +0 +1 +0 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE '0.0' < colA; +colA +1 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE '256.1' = colA; +colA +SELECT * FROM tinytbl WHERE '256.1' <=> colA; +colA +SELECT * FROM tinytbl WHERE '256.1' <> colA; +colA +0 +1 +0 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE '255.0' = colA; +colA +255 +SELECT * FROM tinytbl WHERE '255.0' <=> colA; +colA +255 +SELECT * FROM tinytbl WHERE '255.0' <> colA; +colA +0 +1 +0 +1 +3 +254 +SELECT * FROM tinytbl WHERE '0.0' = colA; +colA +0 +0 +SELECT * FROM tinytbl WHERE '0.0' <=> colA; +colA +0 +0 +SELECT * FROM tinytbl WHERE '0.0' <> colA; +colA +1 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE '-1.1' = colA; +colA +SELECT * FROM tinytbl WHERE '-1.1' <=> colA; +colA +SELECT * FROM tinytbl WHERE '-1.1' <> colA; +colA +0 +1 +0 +1 +3 +254 +255 +PREPARE p_less FROM 'SELECT * FROM tinytbl WHERE ? < colA'; +PREPARE p_less_eq FROM 'SELECT * FROM tinytbl WHERE ? <= colA'; +PREPARE p_greater FROM 'SELECT * FROM tinytbl WHERE ? > colA'; +PREPARE p_gret_eq FROM 'SELECT * FROM tinytbl WHERE ? >= colA'; +PREPARE p_eq FROM 'SELECT * FROM tinytbl WHERE ? = colA'; +PREPARE p_equal FROM 'SELECT * FROM tinytbl WHERE ? <=> colA'; +PREPARE p_n_eq FROM 'SELECT * FROM tinytbl WHERE ? <> colA'; +PREPARE p_n_equal FROM 'SELECT * FROM tinytbl WHERE NOT(? <=> colA)'; +EXECUTE p_greater USING @maxint_plus_1; +colA +0 +1 +0 +1 +3 +254 +255 +EXECUTE p_gret_eq USING @maxint; +colA +0 +1 +0 +1 +3 +254 +255 +EXECUTE p_less USING @maxint_plus_1; +colA +EXECUTE p_less_eq USING @maxint; +colA +255 +EXECUTE p_less USING @minint_minus_1; +colA +0 +1 +0 +1 +3 +254 +255 +EXECUTE p_gret_eq USING @minint_minus_1; +colA +EXECUTE p_gret_eq USING @minint; +colA +0 +0 +EXECUTE p_less_eq USING @minint; +colA +0 +1 +0 +1 +3 +254 +255 +EXECUTE p_less USING @minint; +colA +1 +1 +3 +254 +255 +EXECUTE p_eq USING @maxint_plus_1; +colA +EXECUTE p_equal USING @maxint_plus_1; +colA +EXECUTE p_n_eq USING @maxint_plus_1; +colA +0 +1 +0 +1 +3 +254 +255 +EXECUTE p_n_equal USING @maxint_plus_1; +colA +0 +1 +0 +1 +3 +254 +255 +NULL +EXECUTE p_eq USING @maxint; +colA +255 +EXECUTE p_equal USING @maxint; +colA +255 +EXECUTE p_n_eq USING @maxint; +colA +0 +1 +0 +1 +3 +254 +EXECUTE p_n_equal USING @maxint; +colA +0 +1 +0 +1 +3 +254 +NULL +EXECUTE p_eq USING @minint; +colA +0 +0 +EXECUTE p_equal USING @minint; +colA +0 +0 +EXECUTE p_n_eq USING @minint; +colA +1 +1 +3 +254 +255 +EXECUTE p_n_equal USING @minint; +colA +1 +1 +3 +254 +255 +NULL +EXECUTE p_eq USING @minint_minus_1; +colA +EXECUTE p_equal USING @minint_minus_1; +colA +EXECUTE p_n_eq USING @minint_minus_1; +colA +0 +1 +0 +1 +3 +254 +255 +EXECUTE p_n_equal USING @minint_minus_1; +colA +0 +1 +0 +1 +3 +254 +255 +NULL +DROP PREPARE p_less; +DROP PREPARE p_less_eq; +DROP PREPARE p_greater; +DROP PREPARE p_gret_eq; +DROP PREPARE p_equal; +DROP PREPARE p_n_eq; +DROP PREPARE p_n_equal; +EXPLAIN SELECT * FROM tinytbl WHERE '256.1' > colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (`test`.`tinytbl`.`colA` is not null) +EXPLAIN SELECT * FROM tinytbl WHERE '255.0' >= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (`test`.`tinytbl`.`colA` is not null) +EXPLAIN SELECT * FROM tinytbl WHERE '256.1' < colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where false +EXPLAIN SELECT * FROM tinytbl WHERE '255.0' <= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (255 = `test`.`tinytbl`.`colA`) +EXPLAIN SELECT * FROM tinytbl WHERE '255.0' < colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where false +EXPLAIN SELECT * FROM tinytbl WHERE '-1.1' < colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (`test`.`tinytbl`.`colA` is not null) +EXPLAIN SELECT * FROM tinytbl WHERE '-1.1' >= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where false +EXPLAIN SELECT * FROM tinytbl WHERE '0.0' >= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (0 = `test`.`tinytbl`.`colA`) +EXPLAIN SELECT * FROM tinytbl WHERE '0.0' <= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (`test`.`tinytbl`.`colA` is not null) +EXPLAIN SELECT * FROM tinytbl WHERE '0.0' < colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 33.33 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (0 < `test`.`tinytbl`.`colA`) +EXPLAIN SELECT * FROM tinytbl WHERE '256.1' = colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where false +EXPLAIN SELECT * FROM tinytbl WHERE '256.1' <=> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where false +EXPLAIN SELECT * FROM tinytbl WHERE '256.1' <> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (`test`.`tinytbl`.`colA` is not null) +EXPLAIN SELECT * FROM tinytbl WHERE '255.0' = colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (255 = `test`.`tinytbl`.`colA`) +EXPLAIN SELECT * FROM tinytbl WHERE '255.0' <=> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (255 <=> `test`.`tinytbl`.`colA`) +EXPLAIN SELECT * FROM tinytbl WHERE '255.0' <> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (255 <> `test`.`tinytbl`.`colA`) +EXPLAIN SELECT * FROM tinytbl WHERE '0.0' = colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (0 = `test`.`tinytbl`.`colA`) +EXPLAIN SELECT * FROM tinytbl WHERE '0.0' <=> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (0 <=> `test`.`tinytbl`.`colA`) +EXPLAIN SELECT * FROM tinytbl WHERE '0.0' <> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (0 <> `test`.`tinytbl`.`colA`) +EXPLAIN SELECT * FROM tinytbl WHERE '-1.1' = colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where false +EXPLAIN SELECT * FROM tinytbl WHERE '-1.1' <=> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where false +EXPLAIN SELECT * FROM tinytbl WHERE '-1.1' <> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (`test`.`tinytbl`.`colA` is not null) +DROP TABLE tinytbl; +# +# Tests with UNSIGNED type TINYINT against decimal +# +CREATE TABLE tinytbl (colA TINYINT UNSIGNED ); +INSERT INTO tinytbl VALUES ('0.0'), ('1.0'), +(0),(1),(3), +('254.0'), ('255.0'), +(NULL); +ANALYZE TABLE tinytbl; +Table Op Msg_type Msg_text +test.tinytbl analyze status OK +SELECT * FROM tinytbl; +colA +0 +1 +0 +1 +3 +254 +255 +NULL +SELECT * FROM tinytbl WHERE colA < 0.5; +colA +0 +0 +SELECT * FROM tinytbl WHERE colA <= 0.5; +colA +0 +0 +SELECT * FROM tinytbl WHERE colA > 0.5; +colA +1 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE colA >= 0.5; +colA +1 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE colA = 0.5; +colA +SELECT * FROM tinytbl WHERE colA <> 0.5; +colA +0 +1 +0 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE colA < -0.5; +colA +SELECT * FROM tinytbl WHERE colA <= -0.5; +colA +SELECT * FROM tinytbl WHERE colA > -0.5; +colA +0 +1 +0 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE colA >= -0.5; +colA +0 +1 +0 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE colA = -0.5; +colA +SELECT * FROM tinytbl WHERE colA <> -0.5; +colA +0 +1 +0 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE colA < '255.00001'; +colA +0 +1 +0 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE colA <= '255.00001'; +colA +0 +1 +0 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE colA > '255.00001'; +colA +SELECT * FROM tinytbl WHERE colA >= '255.00001'; +colA +SELECT * FROM tinytbl WHERE colA = '255.00001'; +colA +SELECT * FROM tinytbl WHERE colA <> '255.00001'; +colA +0 +1 +0 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE colA < '254.99999'; +colA +0 +1 +0 +1 +3 +254 +SELECT * FROM tinytbl WHERE colA <= '254.99999'; +colA +0 +1 +0 +1 +3 +254 +SELECT * FROM tinytbl WHERE colA > '254.99999'; +colA +255 +SELECT * FROM tinytbl WHERE colA >= '254.99999'; +colA +255 +SELECT * FROM tinytbl WHERE colA = '254.99999'; +colA +SELECT * FROM tinytbl WHERE colA <> '254.99999'; +colA +0 +1 +0 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE colA < '0.00001'; +colA +0 +0 +SELECT * FROM tinytbl WHERE colA <= '0.00001'; +colA +0 +0 +SELECT * FROM tinytbl WHERE colA > '0.00001'; +colA +1 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE colA >= '0.00001'; +colA +1 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE colA = '0.00001'; +colA +SELECT * FROM tinytbl WHERE colA <> '0.00001'; +colA +0 +1 +0 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE colA < '-0.99999'; +colA +SELECT * FROM tinytbl WHERE colA <= '-0.99999'; +colA +SELECT * FROM tinytbl WHERE colA > '-0.99999'; +colA +0 +1 +0 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE colA >= '-0.99999'; +colA +0 +1 +0 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE colA = '-0.99999'; +colA +SELECT * FROM tinytbl WHERE colA <> '-0.99999'; +colA +0 +1 +0 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE colA < 18446744073709551615.00000001; +colA +0 +1 +0 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE colA <= 18446744073709551615.00000001; +colA +0 +1 +0 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE colA > 18446744073709551615.00000001; +colA +SELECT * FROM tinytbl WHERE colA >= 18446744073709551615.00000001; +colA +SELECT * FROM tinytbl WHERE colA = 18446744073709551615.00000001; +colA +SELECT * FROM tinytbl WHERE colA <> 18446744073709551615.00000001; +colA +0 +1 +0 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE colA < -9223372036854775808.00000001; +colA +SELECT * FROM tinytbl WHERE colA <= -9223372036854775808.00000001; +colA +SELECT * FROM tinytbl WHERE colA > -9223372036854775808.00000001; +colA +0 +1 +0 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE colA >= -9223372036854775808.00000001; +colA +0 +1 +0 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE colA = -9223372036854775808.00000001; +colA +SELECT * FROM tinytbl WHERE colA <> -9223372036854775808.00000001; +colA +0 +1 +0 +1 +3 +254 +255 +PREPARE p_less FROM 'SELECT * FROM tinytbl WHERE colA < ?'; +PREPARE p_less_eq FROM 'SELECT * FROM tinytbl WHERE colA <= ?'; +PREPARE p_greater FROM 'SELECT * FROM tinytbl WHERE colA > ?'; +PREPARE p_gret_eq FROM 'SELECT * FROM tinytbl WHERE colA >= ?'; +PREPARE p_equal FROM 'SELECT * FROM tinytbl WHERE colA = ?'; +PREPARE p_n_equal FROM 'SELECT * FROM tinytbl WHERE colA <> ?'; +SET @dec_0_5=0.5; +SET @dec_minus_0_5=-0.5; +SET @dec_max_plus_delta='255.00001'; +SET @dec_max_minus_delta='254.99999'; +SET @dec_min_plus_delta='0.00001'; +SET @dec_min_minus_delta='-0.99999'; +SET @dec_too_big_positive_for_any_int=18446744073709551615.00000001; +SET @dec_too_big_negative_for_any_int=-9223372036854775808.00000001; +EXECUTE p_less USING @dec_0_5; +colA +0 +0 +EXECUTE p_less_eq USING @dec_0_5; +colA +0 +0 +EXECUTE p_greater USING @dec_0_5; +colA +1 +1 +3 +254 +255 +EXECUTE p_gret_eq USING @dec_0_5; +colA +1 +1 +3 +254 +255 +EXECUTE p_equal USING @dec_0_5; +colA +EXECUTE p_n_equal USING @dec_0_5; +colA +0 +1 +0 +1 +3 +254 +255 +EXECUTE p_less USING @dec_minus_0_5; +colA +EXECUTE p_less_eq USING @dec_minus_0_5; +colA +EXECUTE p_greater USING @dec_minus_0_5; +colA +0 +1 +0 +1 +3 +254 +255 +EXECUTE p_gret_eq USING @dec_minus_0_5; +colA +0 +1 +0 +1 +3 +254 +255 +EXECUTE p_equal USING @dec_minus_0_5; +colA +EXECUTE p_n_equal USING @dec_minus_0_5; +colA +0 +1 +0 +1 +3 +254 +255 +EXECUTE p_less USING @dec_max_plus_delta; +colA +0 +1 +0 +1 +3 +254 +255 +EXECUTE p_less_eq USING @dec_max_plus_delta; +colA +0 +1 +0 +1 +3 +254 +255 +EXECUTE p_greater USING @dec_max_plus_delta; +colA +EXECUTE p_gret_eq USING @dec_max_plus_delta; +colA +EXECUTE p_equal USING @dec_max_plus_delta; +colA +EXECUTE p_n_equal USING @dec_max_plus_delta; +colA +0 +1 +0 +1 +3 +254 +255 +EXECUTE p_less USING @dec_max_minus_delta; +colA +0 +1 +0 +1 +3 +254 +EXECUTE p_less_eq USING @dec_max_minus_delta; +colA +0 +1 +0 +1 +3 +254 +EXECUTE p_greater USING @dec_max_minus_delta; +colA +255 +EXECUTE p_gret_eq USING @dec_max_minus_delta; +colA +255 +EXECUTE p_equal USING @dec_max_minus_delta; +colA +EXECUTE p_n_equal USING @dec_max_minus_delta; +colA +0 +1 +0 +1 +3 +254 +255 +EXECUTE p_less USING @dec_min_plus_delta; +colA +0 +0 +EXECUTE p_less_eq USING @dec_min_plus_delta; +colA +0 +0 +EXECUTE p_greater USING @dec_min_plus_delta; +colA +1 +1 +3 +254 +255 +EXECUTE p_gret_eq USING @dec_min_plus_delta; +colA +1 +1 +3 +254 +255 +EXECUTE p_equal USING @dec_min_plus_delta; +colA +EXECUTE p_n_equal USING @dec_min_plus_delta; +colA +0 +1 +0 +1 +3 +254 +255 +EXECUTE p_less USING @dec_min_minus_delta; +colA +EXECUTE p_less_eq USING @dec_min_minus_delta; +colA +EXECUTE p_greater USING @dec_min_minus_delta; +colA +0 +1 +0 +1 +3 +254 +255 +EXECUTE p_gret_eq USING @dec_min_minus_delta; +colA +0 +1 +0 +1 +3 +254 +255 +EXECUTE p_equal USING @dec_min_minus_delta; +colA +EXECUTE p_n_equal USING @dec_min_minus_delta; +colA +0 +1 +0 +1 +3 +254 +255 +EXECUTE p_less USING @dec_too_big_positive_for_any_int; +colA +0 +1 +0 +1 +3 +254 +255 +EXECUTE p_less_eq USING @dec_too_big_positive_for_any_int; +colA +0 +1 +0 +1 +3 +254 +255 +EXECUTE p_greater USING @dec_too_big_positive_for_any_int; +colA +EXECUTE p_gret_eq USING @dec_too_big_positive_for_any_int; +colA +EXECUTE p_equal USING @dec_too_big_positive_for_any_int; +colA +EXECUTE p_n_equal USING @dec_too_big_positive_for_any_int; +colA +0 +1 +0 +1 +3 +254 +255 +EXECUTE p_less USING @dec_too_big_negative_for_any_int; +colA +EXECUTE p_less_eq USING @dec_too_big_negative_for_any_int; +colA +EXECUTE p_greater USING @dec_too_big_negative_for_any_int; +colA +0 +1 +0 +1 +3 +254 +255 +EXECUTE p_gret_eq USING @dec_too_big_negative_for_any_int; +colA +0 +1 +0 +1 +3 +254 +255 +EXECUTE p_equal USING @dec_too_big_negative_for_any_int; +colA +EXECUTE p_n_equal USING @dec_too_big_negative_for_any_int; +colA +0 +1 +0 +1 +3 +254 +255 +DROP PREPARE p_less; +DROP PREPARE p_less_eq; +DROP PREPARE p_greater; +DROP PREPARE p_gret_eq; +DROP PREPARE p_equal; +DROP PREPARE p_n_equal; +DROP TABLE tinytbl; +Cruft inside string +CREATE TABLE t(i INT); +INSERT INTO t VALUES (-1), (0), (1); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +SELECT * FROM t WHERE i > 'A'; +i +1 +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'A' +EXPLAIN SELECT * FROM t WHERE i > 'A'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'A' +Note 1003 /* select#1 */ select `test`.`t`.`i` AS `i` from `test`.`t` where (`test`.`t`.`i` > 0) +DROP TABLE t; +Detect decimal inside a string when compared to int +Used to return one row; should be none. +CREATE TABLE t(i BIGINT); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +INSERT INTO t VALUES (1), (2); +SELECT * FROM t WHERE i = '1.1'; +i +EXPLAIN SELECT * FROM t WHERE i = '1.1'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`i` AS `i` from `test`.`t` where false +DROP TABLE t; +Detect out of range real inside a string when compared to int +Used to return one row; should be none. +CREATE TABLE t(i TINYINT); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +INSERT INTO t VALUES (1), (2); +SELECT * FROM t WHERE i > '1E10'; +i +EXPLAIN SELECT * FROM t WHERE i > '1E10'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`i` AS `i` from `test`.`t` where false +DROP TABLE t; +Detect out of range real inside a string when compared to int +Used to return one row; should be none. +CREATE TABLE t(i TINYINT); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +INSERT INTO t VALUES (0); +SELECT * FROM t WHERE i = '1E-308'; +i +EXPLAIN SELECT * FROM t WHERE i = '1E-308'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`i` AS `i` from `test`.`t` where false +Above query should yield the same as this: +SELECT * FROM t WHERE i = 1E-308; +i +EXPLAIN SELECT * FROM t WHERE i = 1E-308; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`i` AS `i` from `test`.`t` where false +DROP TABLE t; +# +# Tests with UNSIGNED type TINYINT against reals +# +CREATE TABLE tinytbl (colA TINYINT UNSIGNED ); +INSERT INTO tinytbl VALUES (0.0E+00), (1.0E00), +(0),(1),(3), +(2.54E02), (2.55E02), +(NULL); +ANALYZE TABLE tinytbl; +Table Op Msg_type Msg_text +test.tinytbl analyze status OK +SELECT * FROM tinytbl; +colA +0 +1 +0 +1 +3 +254 +255 +NULL +SELECT * FROM tinytbl WHERE colA < 0.5E00; +colA +0 +0 +SELECT * FROM tinytbl WHERE colA <= 0.5E00; +colA +0 +0 +SELECT * FROM tinytbl WHERE colA > 0.5E00; +colA +1 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE colA >= 0.5E00; +colA +1 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE colA = 0.5E00; +colA +SELECT * FROM tinytbl WHERE colA <> 0.5E00; +colA +0 +1 +0 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE colA < -0.5E00; +colA +SELECT * FROM tinytbl WHERE colA <= -0.5E00; +colA +SELECT * FROM tinytbl WHERE colA > -0.5E00; +colA +0 +1 +0 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE colA >= -0.5E00; +colA +0 +1 +0 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE colA = -0.5E00; +colA +SELECT * FROM tinytbl WHERE colA <> -0.5E00; +colA +0 +1 +0 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE colA < 255.00001E+00; +colA +0 +1 +0 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE colA <= 255.00001E+00; +colA +0 +1 +0 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE colA > 255.00001E+00; +colA +SELECT * FROM tinytbl WHERE colA >= 255.00001E+00; +colA +SELECT * FROM tinytbl WHERE colA = 255.00001E+00; +colA +SELECT * FROM tinytbl WHERE colA <> 255.00001E+00; +colA +0 +1 +0 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE colA < 254.99999E+00; +colA +0 +1 +0 +1 +3 +254 +SELECT * FROM tinytbl WHERE colA <= 254.99999E+00; +colA +0 +1 +0 +1 +3 +254 +SELECT * FROM tinytbl WHERE colA > 254.99999E+00; +colA +255 +SELECT * FROM tinytbl WHERE colA >= 254.99999E+00; +colA +255 +SELECT * FROM tinytbl WHERE colA = 254.99999E+00; +colA +SELECT * FROM tinytbl WHERE colA <> 254.99999E+00; +colA +0 +1 +0 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE colA < 0.00001E+00; +colA +0 +0 +SELECT * FROM tinytbl WHERE colA <= 0.00001E+00; +colA +0 +0 +SELECT * FROM tinytbl WHERE colA > 0.00001E+00; +colA +1 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE colA >= 0.00001E+00; +colA +1 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE colA = 0.00001E+00; +colA +SELECT * FROM tinytbl WHERE colA <> 0.00001E+00; +colA +0 +1 +0 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE colA < -0.99999E+00; +colA +SELECT * FROM tinytbl WHERE colA <= -0.99999E+00; +colA +SELECT * FROM tinytbl WHERE colA > -0.99999E+00; +colA +0 +1 +0 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE colA >= -0.99999E+00; +colA +0 +1 +0 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE colA = -0.99999E+00; +colA +SELECT * FROM tinytbl WHERE colA <> -0.99999E+00; +colA +0 +1 +0 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE colA < 18446744073709551615.00000001E+00; +colA +0 +1 +0 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE colA <= 18446744073709551615.00000001E+00; +colA +0 +1 +0 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE colA > 18446744073709551615.00000001E+00; +colA +SELECT * FROM tinytbl WHERE colA >= 18446744073709551615.00000001E+00; +colA +SELECT * FROM tinytbl WHERE colA = 18446744073709551615.00000001E+00; +colA +SELECT * FROM tinytbl WHERE colA <> 18446744073709551615.00000001E+00; +colA +0 +1 +0 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE colA < -9223372036854775808.00000001E+00; +colA +SELECT * FROM tinytbl WHERE colA <= -9223372036854775808.00000001E+00; +colA +SELECT * FROM tinytbl WHERE colA > -9223372036854775808.00000001E+00; +colA +0 +1 +0 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE colA >= -9223372036854775808.00000001E+00; +colA +0 +1 +0 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE colA = -9223372036854775808.00000001E+00; +colA +SELECT * FROM tinytbl WHERE colA <> -9223372036854775808.00000001E+00; +colA +0 +1 +0 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE colA < 1.7976931348623157E+308; +colA +0 +1 +0 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE colA <= 1.7976931348623157E+308; +colA +0 +1 +0 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE colA > 1.7976931348623157E+308; +colA +SELECT * FROM tinytbl WHERE colA >= 1.7976931348623157E+308; +colA +SELECT * FROM tinytbl WHERE colA = 1.7976931348623157E+308; +colA +SELECT * FROM tinytbl WHERE colA <> 1.7976931348623157E+308; +colA +0 +1 +0 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE colA < -1.7976931348623157E+308; +colA +SELECT * FROM tinytbl WHERE colA <= -1.7976931348623157E+308; +colA +SELECT * FROM tinytbl WHERE colA > -1.7976931348623157E+308; +colA +0 +1 +0 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE colA >= -1.7976931348623157E+308; +colA +0 +1 +0 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE colA = -1.7976931348623157E+308; +colA +SELECT * FROM tinytbl WHERE colA <> -1.7976931348623157E+308; +colA +0 +1 +0 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE colA < 1.7976931348623157E-308; +colA +0 +0 +SELECT * FROM tinytbl WHERE colA <= 1.7976931348623157E-308; +colA +0 +0 +SELECT * FROM tinytbl WHERE colA > 1.7976931348623157E-308; +colA +1 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE colA >= 1.7976931348623157E-308; +colA +1 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE colA = 1.7976931348623157E-308; +colA +SELECT * FROM tinytbl WHERE colA <> 1.7976931348623157E-308; +colA +0 +1 +0 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE colA < -1.7976931348623157E-308; +colA +SELECT * FROM tinytbl WHERE colA <= -1.7976931348623157E-308; +colA +SELECT * FROM tinytbl WHERE colA > -1.7976931348623157E-308; +colA +0 +1 +0 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE colA >= -1.7976931348623157E-308; +colA +0 +1 +0 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE colA = -1.7976931348623157E-308; +colA +SELECT * FROM tinytbl WHERE colA <> -1.7976931348623157E-308; +colA +0 +1 +0 +1 +3 +254 +255 +PREPARE p_less FROM 'SELECT * FROM tinytbl WHERE colA < ?'; +PREPARE p_less_eq FROM 'SELECT * FROM tinytbl WHERE colA <= ?'; +PREPARE p_greater FROM 'SELECT * FROM tinytbl WHERE colA > ?'; +PREPARE p_gret_eq FROM 'SELECT * FROM tinytbl WHERE colA >= ?'; +PREPARE p_equal FROM 'SELECT * FROM tinytbl WHERE colA = ?'; +PREPARE p_n_equal FROM 'SELECT * FROM tinytbl WHERE colA <> ?'; +SET @real_0_5=0.5E00; +SET @real_minus_0_5=-0.5E00; +SET @real_max_plus_delta=255.00001E+00; +SET @real_max_minus_delta=254.99999E+00; +SET @real_min_plus_delta=0.00001E+00; +SET @real_min_minus_delta=-0.99999E+00; +SET @real_too_big_positive_for_any_int=18446744073709551615.00000001E+00; +SET @real_dec_too_big_negative_for_any_int=-9223372036854775808.00000001E+00; +SET @real_too_big_positive_for_any_decimal=1.7976931348623157E+308; +SET @real_too_big_negative_for_any_decimal=-1.7976931348623157E+308; +SET @dec_too_small_positive_for_any_int_as_real=1.7976931348623157E-308; +SET @dec_too_small_negative_for_any_int_as_real=-1.7976931348623157E-308; +SET @real_too_small_positive_for_any_decimal=1.7976931348623157E-308; +SET @real_too_small_negative_for_any_decimal=-1.7976931348623157E-308; +EXECUTE p_less USING @real_0_5; +colA +0 +0 +EXECUTE p_less_eq USING @real_0_5; +colA +0 +0 +EXECUTE p_greater USING @real_0_5; +colA +1 +1 +3 +254 +255 +EXECUTE p_gret_eq USING @real_0_5; +colA +1 +1 +3 +254 +255 +EXECUTE p_equal USING @real_0_5; +colA +EXECUTE p_n_equal USING @real_0_5; +colA +0 +1 +0 +1 +3 +254 +255 +EXECUTE p_less USING @real_minus_0_5; +colA +EXECUTE p_less_eq USING @real_minus_0_5; +colA +EXECUTE p_greater USING @real_minus_0_5; +colA +0 +1 +0 +1 +3 +254 +255 +EXECUTE p_gret_eq USING @real_minus_0_5; +colA +0 +1 +0 +1 +3 +254 +255 +EXECUTE p_equal USING @real_minus_0_5; +colA +EXECUTE p_n_equal USING @real_minus_0_5; +colA +0 +1 +0 +1 +3 +254 +255 +EXECUTE p_less USING @real_max_plus_delta; +colA +0 +1 +0 +1 +3 +254 +255 +EXECUTE p_less_eq USING @real_max_plus_delta; +colA +0 +1 +0 +1 +3 +254 +255 +EXECUTE p_greater USING @real_max_plus_delta; +colA +EXECUTE p_gret_eq USING @real_max_plus_delta; +colA +EXECUTE p_equal USING @real_max_plus_delta; +colA +EXECUTE p_n_equal USING @real_max_plus_delta; +colA +0 +1 +0 +1 +3 +254 +255 +EXECUTE p_less USING @real_max_minus_delta; +colA +0 +1 +0 +1 +3 +254 +EXECUTE p_less_eq USING @real_max_minus_delta; +colA +0 +1 +0 +1 +3 +254 +EXECUTE p_greater USING @real_max_minus_delta; +colA +255 +EXECUTE p_gret_eq USING @real_max_minus_delta; +colA +255 +EXECUTE p_equal USING @real_max_minus_delta; +colA +EXECUTE p_n_equal USING @real_max_minus_delta; +colA +0 +1 +0 +1 +3 +254 +255 +EXECUTE p_less USING @real_min_plus_delta; +colA +0 +0 +EXECUTE p_less_eq USING @real_min_plus_delta; +colA +0 +0 +EXECUTE p_greater USING @real_min_plus_delta; +colA +1 +1 +3 +254 +255 +EXECUTE p_gret_eq USING @real_min_plus_delta; +colA +1 +1 +3 +254 +255 +EXECUTE p_equal USING @real_min_plus_delta; +colA +EXECUTE p_n_equal USING @real_min_plus_delta; +colA +0 +1 +0 +1 +3 +254 +255 +EXECUTE p_less USING @real_min_minus_delta; +colA +EXECUTE p_less_eq USING @real_min_minus_delta; +colA +EXECUTE p_greater USING @real_min_minus_delta; +colA +0 +1 +0 +1 +3 +254 +255 +EXECUTE p_gret_eq USING @real_min_minus_delta; +colA +0 +1 +0 +1 +3 +254 +255 +EXECUTE p_equal USING @real_min_minus_delta; +colA +EXECUTE p_n_equal USING @real_min_minus_delta; +colA +0 +1 +0 +1 +3 +254 +255 +EXECUTE p_less USING @real_too_big_positive_for_any_int; +colA +0 +1 +0 +1 +3 +254 +255 +EXECUTE p_less_eq USING @real_too_big_positive_for_any_int; +colA +0 +1 +0 +1 +3 +254 +255 +EXECUTE p_greater USING @real_too_big_positive_for_any_int; +colA +EXECUTE p_gret_eq USING @real_too_big_positive_for_any_int; +colA +EXECUTE p_equal USING @real_too_big_positive_for_any_int; +colA +EXECUTE p_n_equal USING @real_too_big_positive_for_any_int; +colA +0 +1 +0 +1 +3 +254 +255 +EXECUTE p_less USING @real_dec_too_big_negative_for_any_int; +colA +EXECUTE p_less_eq USING @real_dec_too_big_negative_for_any_int; +colA +EXECUTE p_greater USING @real_dec_too_big_negative_for_any_int; +colA +0 +1 +0 +1 +3 +254 +255 +EXECUTE p_gret_eq USING @real_dec_too_big_negative_for_any_int; +colA +0 +1 +0 +1 +3 +254 +255 +EXECUTE p_equal USING @real_dec_too_big_negative_for_any_int; +colA +EXECUTE p_n_equal USING @real_dec_too_big_negative_for_any_int; +colA +0 +1 +0 +1 +3 +254 +255 +EXECUTE p_less USING @real_too_big_positive_for_any_decimal; +colA +0 +1 +0 +1 +3 +254 +255 +EXECUTE p_less_eq USING @real_too_big_positive_for_any_decimal; +colA +0 +1 +0 +1 +3 +254 +255 +EXECUTE p_greater USING @real_too_big_positive_for_any_decimal; +colA +EXECUTE p_gret_eq USING @real_too_big_positive_for_any_decimal; +colA +EXECUTE p_equal USING @real_too_big_positive_for_any_decimal; +colA +EXECUTE p_n_equal USING @real_too_big_positive_for_any_decimal; +colA +0 +1 +0 +1 +3 +254 +255 +EXECUTE p_less USING @real_too_big_negative_for_any_decimal; +colA +EXECUTE p_less_eq USING @real_too_big_negative_for_any_decimal; +colA +EXECUTE p_greater USING @real_too_big_negative_for_any_decimal; +colA +0 +1 +0 +1 +3 +254 +255 +EXECUTE p_gret_eq USING @real_too_big_negative_for_any_decimal; +colA +0 +1 +0 +1 +3 +254 +255 +EXECUTE p_equal USING @real_too_big_negative_for_any_decimal; +colA +EXECUTE p_n_equal USING @real_too_big_negative_for_any_decimal; +colA +0 +1 +0 +1 +3 +254 +255 +EXECUTE p_less USING @real_too_small_positive_for_any_decimal; +colA +0 +0 +EXECUTE p_less_eq USING @real_too_small_positive_for_any_decimal; +colA +0 +0 +EXECUTE p_greater USING @real_too_small_positive_for_any_decimal; +colA +1 +1 +3 +254 +255 +EXECUTE p_gret_eq USING @real_too_small_positive_for_any_decimal; +colA +1 +1 +3 +254 +255 +EXECUTE p_equal USING @real_too_small_positive_for_any_decimal; +colA +EXECUTE p_n_equal USING @real_too_small_positive_for_any_decimal; +colA +0 +1 +0 +1 +3 +254 +255 +EXECUTE p_less USING @real_too_small_negative_for_any_decimal; +colA +EXECUTE p_less_eq USING @real_too_small_negative_for_any_decimal; +colA +EXECUTE p_greater USING @real_too_small_negative_for_any_decimal; +colA +0 +1 +0 +1 +3 +254 +255 +EXECUTE p_gret_eq USING @real_too_small_negative_for_any_decimal; +colA +0 +1 +0 +1 +3 +254 +255 +EXECUTE p_equal USING @real_too_small_negative_for_any_decimal; +colA +EXECUTE p_n_equal USING @real_too_small_negative_for_any_decimal; +colA +0 +1 +0 +1 +3 +254 +255 +DROP PREPARE p_less; +DROP PREPARE p_less_eq; +DROP PREPARE p_greater; +DROP PREPARE p_gret_eq; +DROP PREPARE p_equal; +DROP PREPARE p_n_equal; +DROP TABLE tinytbl; +# +# Tests with UNSIGNED type TINYINT NOT NULL against int +# +CREATE TABLE tinytbl (colA TINYINT UNSIGNED NOT NULL); +INSERT INTO tinytbl VALUES (0.0E+00), (1.0E00), +(0),(1),(3), +(2.54E02), (2.55E02), +(0); +ANALYZE TABLE tinytbl; +Table Op Msg_type Msg_text +test.tinytbl analyze status OK +SELECT * FROM tinytbl; +colA +0 +1 +0 +1 +3 +254 +255 +0 +SELECT * FROM tinytbl WHERE colA < 2.56E02; +colA +0 +1 +0 +1 +3 +254 +255 +0 +SELECT * FROM tinytbl WHERE colA <= 2.55E02; +colA +0 +1 +0 +1 +3 +254 +255 +0 +SELECT * FROM tinytbl WHERE colA > 2.56E02; +colA +SELECT * FROM tinytbl WHERE colA >= 2.55E02; +colA +255 +SELECT * FROM tinytbl WHERE colA > -1.0E00; +colA +0 +1 +0 +1 +3 +254 +255 +0 +SELECT * FROM tinytbl WHERE colA <= -1.0E00; +colA +SELECT * FROM tinytbl WHERE colA <= 0.0E+00; +colA +0 +0 +0 +SELECT * FROM tinytbl WHERE colA >= 0.0E+00; +colA +0 +1 +0 +1 +3 +254 +255 +0 +SELECT * FROM tinytbl WHERE colA > 0.0E+00; +colA +1 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE colA = 2.56E02; +colA +SELECT * FROM tinytbl WHERE colA <> 2.56E02; +colA +0 +1 +0 +1 +3 +254 +255 +0 +SELECT * FROM tinytbl WHERE colA = 2.55E02; +colA +255 +SELECT * FROM tinytbl WHERE colA <=> 2.55E02; +colA +255 +SELECT * FROM tinytbl WHERE NOT(colA <=> 2.55E02); +colA +0 +1 +0 +1 +3 +254 +0 +SELECT * FROM tinytbl WHERE colA <> 2.55E02; +colA +0 +1 +0 +1 +3 +254 +0 +SELECT * FROM tinytbl WHERE colA = 0.0E+00; +colA +0 +0 +0 +SELECT * FROM tinytbl WHERE colA <=> 0.0E+00; +colA +0 +0 +0 +SELECT * FROM tinytbl WHERE NOT(colA <=> 0.0E+00); +colA +1 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE colA <> 0.0E+00; +colA +1 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE colA = -1.0E00; +colA +SELECT * FROM tinytbl WHERE colA <=> -1.0E00; +colA +SELECT * FROM tinytbl WHERE NOT(colA <=> -1.0E00); +colA +0 +1 +0 +1 +3 +254 +255 +0 +SELECT * FROM tinytbl WHERE colA <> -1.0E00; +colA +0 +1 +0 +1 +3 +254 +255 +0 +PREPARE p_less FROM 'SELECT * FROM tinytbl WHERE colA < ?'; +PREPARE p_less_eq FROM 'SELECT * FROM tinytbl WHERE colA <= ?'; +PREPARE p_greater FROM 'SELECT * FROM tinytbl WHERE colA > ?'; +PREPARE p_gret_eq FROM 'SELECT * FROM tinytbl WHERE colA >= ?'; +PREPARE p_eq FROM 'SELECT * FROM tinytbl WHERE colA = ?'; +PREPARE p_equal FROM 'SELECT * FROM tinytbl WHERE colA <=> ?'; +PREPARE p_n_equal FROM 'SELECT * FROM tinytbl WHERE NOT(colA <=> ?)'; +PREPARE p_n_eq FROM 'SELECT * FROM tinytbl WHERE colA <> ?'; +SET @maxint_plus_1=2.56E02; +SET @maxint=2.55E02; +SET @minint_minus_1=-1.0E00; +SET @minint=0.0E+00; +EXECUTE p_less USING @maxint_plus_1; +colA +0 +1 +0 +1 +3 +254 +255 +0 +EXECUTE p_less_eq USING @maxint; +colA +0 +1 +0 +1 +3 +254 +255 +0 +EXECUTE p_greater USING @maxint_plus_1; +colA +EXECUTE p_gret_eq USING @maxint; +colA +255 +EXECUTE p_greater USING @minint_minus_1; +colA +0 +1 +0 +1 +3 +254 +255 +0 +EXECUTE p_less_eq USING @minint_minus_1; +colA +EXECUTE p_less_eq USING @minint; +colA +0 +0 +0 +EXECUTE p_gret_eq USING @minint; +colA +0 +1 +0 +1 +3 +254 +255 +0 +EXECUTE p_greater USING @minint; +colA +1 +1 +3 +254 +255 +EXECUTE p_eq USING @maxint_plus_1; +colA +EXECUTE p_equal USING @maxint_plus_1; +colA +EXECUTE p_n_eq USING @maxint_plus_1; +colA +0 +1 +0 +1 +3 +254 +255 +0 +EXECUTE p_n_equal USING @maxint_plus_1; +colA +0 +1 +0 +1 +3 +254 +255 +0 +EXECUTE p_eq USING @maxint; +colA +255 +EXECUTE p_equal USING @maxint; +colA +255 +EXECUTE p_n_eq USING @maxint; +colA +0 +1 +0 +1 +3 +254 +0 +EXECUTE p_n_equal USING @maxint; +colA +0 +1 +0 +1 +3 +254 +0 +EXECUTE p_eq USING @minint; +colA +0 +0 +0 +EXECUTE p_equal USING @minint; +colA +0 +0 +0 +EXECUTE p_n_eq USING @minint; +colA +1 +1 +3 +254 +255 +EXECUTE p_n_equal USING @minint; +colA +1 +1 +3 +254 +255 +EXECUTE p_eq USING @minint_minus_1; +colA +EXECUTE p_equal USING @minint_minus_1; +colA +EXECUTE p_n_eq USING @minint_minus_1; +colA +0 +1 +0 +1 +3 +254 +255 +0 +EXECUTE p_n_equal USING @minint_minus_1; +colA +0 +1 +0 +1 +3 +254 +255 +0 +DROP PREPARE p_less; +DROP PREPARE p_less_eq; +DROP PREPARE p_greater; +DROP PREPARE p_gret_eq; +DROP PREPARE p_equal; +DROP PREPARE p_n_eq; +DROP PREPARE p_n_equal; +EXPLAIN SELECT * FROM tinytbl WHERE colA < 2.56E02; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where true +EXPLAIN SELECT * FROM tinytbl WHERE colA <= 2.55E02; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where true +EXPLAIN SELECT * FROM tinytbl WHERE colA > 2.56E02; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where false +EXPLAIN SELECT * FROM tinytbl WHERE colA >= 2.55E02; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (`test`.`tinytbl`.`colA` = 255) +EXPLAIN SELECT * FROM tinytbl WHERE colA > -1.0E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where true +EXPLAIN SELECT * FROM tinytbl WHERE colA <= -1.0E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where false +EXPLAIN SELECT * FROM tinytbl WHERE colA <= 0.0E+00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (`test`.`tinytbl`.`colA` = 0) +EXPLAIN SELECT * FROM tinytbl WHERE colA >= 0.0E+00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where true +EXPLAIN SELECT * FROM tinytbl WHERE colA > 0.0E+00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 33.33 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (`test`.`tinytbl`.`colA` > 0) +EXPLAIN SELECT * FROM tinytbl WHERE colA = 2.56E02; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where false +EXPLAIN SELECT * FROM tinytbl WHERE colA <=> 2.56E02; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where false +EXPLAIN SELECT * FROM tinytbl WHERE colA <> 2.56E02; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where true +EXPLAIN SELECT * FROM tinytbl WHERE colA = 2.55E02; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (`test`.`tinytbl`.`colA` = 255) +EXPLAIN SELECT * FROM tinytbl WHERE colA <=> 2.55E02; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (`test`.`tinytbl`.`colA` <=> 255) +EXPLAIN SELECT * FROM tinytbl WHERE colA <> 2.55E02; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (`test`.`tinytbl`.`colA` <> 255) +EXPLAIN SELECT * FROM tinytbl WHERE colA = 0.0E+00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (`test`.`tinytbl`.`colA` = 0) +EXPLAIN SELECT * FROM tinytbl WHERE colA <=> 0.0E+00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (`test`.`tinytbl`.`colA` <=> 0) +EXPLAIN SELECT * FROM tinytbl WHERE colA <> 0.0E+00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (`test`.`tinytbl`.`colA` <> 0) +EXPLAIN SELECT * FROM tinytbl WHERE colA = -1.0E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where false +EXPLAIN SELECT * FROM tinytbl WHERE colA <=> -1.0E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where false +EXPLAIN SELECT * FROM tinytbl WHERE colA <> -1.0E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where true +same queries but constant first +SELECT * FROM tinytbl WHERE 2.56E02 > colA; +colA +0 +1 +0 +1 +3 +254 +255 +0 +SELECT * FROM tinytbl WHERE 2.55E02 >= colA; +colA +0 +1 +0 +1 +3 +254 +255 +0 +SELECT * FROM tinytbl WHERE 2.56E02 < colA; +colA +SELECT * FROM tinytbl WHERE 2.55E02 <= colA; +colA +255 +SELECT * FROM tinytbl WHERE 2.55E02 < colA; +colA +SELECT * FROM tinytbl WHERE -1.0E00 < colA; +colA +0 +1 +0 +1 +3 +254 +255 +0 +SELECT * FROM tinytbl WHERE -1.0E00 >= colA; +colA +SELECT * FROM tinytbl WHERE 0.0E+00 >= colA; +colA +0 +0 +0 +SELECT * FROM tinytbl WHERE 0.0E+00 <= colA; +colA +0 +1 +0 +1 +3 +254 +255 +0 +SELECT * FROM tinytbl WHERE 0.0E+00 < colA; +colA +1 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE 2.56E02 = colA; +colA +SELECT * FROM tinytbl WHERE 2.56E02 <=> colA; +colA +SELECT * FROM tinytbl WHERE 2.56E02 <> colA; +colA +0 +1 +0 +1 +3 +254 +255 +0 +SELECT * FROM tinytbl WHERE 2.55E02 = colA; +colA +255 +SELECT * FROM tinytbl WHERE 2.55E02 <=> colA; +colA +255 +SELECT * FROM tinytbl WHERE 2.55E02 <> colA; +colA +0 +1 +0 +1 +3 +254 +0 +SELECT * FROM tinytbl WHERE 0.0E+00 = colA; +colA +0 +0 +0 +SELECT * FROM tinytbl WHERE 0.0E+00 <=> colA; +colA +0 +0 +0 +SELECT * FROM tinytbl WHERE 0.0E+00 <> colA; +colA +1 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE -1.0E00 = colA; +colA +SELECT * FROM tinytbl WHERE -1.0E00 <=> colA; +colA +SELECT * FROM tinytbl WHERE -1.0E00 <> colA; +colA +0 +1 +0 +1 +3 +254 +255 +0 +PREPARE p_less FROM 'SELECT * FROM tinytbl WHERE ? < colA'; +PREPARE p_less_eq FROM 'SELECT * FROM tinytbl WHERE ? <= colA'; +PREPARE p_greater FROM 'SELECT * FROM tinytbl WHERE ? > colA'; +PREPARE p_gret_eq FROM 'SELECT * FROM tinytbl WHERE ? >= colA'; +PREPARE p_eq FROM 'SELECT * FROM tinytbl WHERE ? = colA'; +PREPARE p_equal FROM 'SELECT * FROM tinytbl WHERE ? <=> colA'; +PREPARE p_n_eq FROM 'SELECT * FROM tinytbl WHERE ? <> colA'; +PREPARE p_n_equal FROM 'SELECT * FROM tinytbl WHERE NOT(? <=> colA)'; +EXECUTE p_greater USING @maxint_plus_1; +colA +0 +1 +0 +1 +3 +254 +255 +0 +EXECUTE p_gret_eq USING @maxint; +colA +0 +1 +0 +1 +3 +254 +255 +0 +EXECUTE p_less USING @maxint_plus_1; +colA +EXECUTE p_less_eq USING @maxint; +colA +255 +EXECUTE p_less USING @minint_minus_1; +colA +0 +1 +0 +1 +3 +254 +255 +0 +EXECUTE p_gret_eq USING @minint_minus_1; +colA +EXECUTE p_gret_eq USING @minint; +colA +0 +0 +0 +EXECUTE p_less_eq USING @minint; +colA +0 +1 +0 +1 +3 +254 +255 +0 +EXECUTE p_less USING @minint; +colA +1 +1 +3 +254 +255 +EXECUTE p_eq USING @maxint_plus_1; +colA +EXECUTE p_equal USING @maxint_plus_1; +colA +EXECUTE p_n_eq USING @maxint_plus_1; +colA +0 +1 +0 +1 +3 +254 +255 +0 +EXECUTE p_n_equal USING @maxint_plus_1; +colA +0 +1 +0 +1 +3 +254 +255 +0 +EXECUTE p_eq USING @maxint; +colA +255 +EXECUTE p_equal USING @maxint; +colA +255 +EXECUTE p_n_eq USING @maxint; +colA +0 +1 +0 +1 +3 +254 +0 +EXECUTE p_n_equal USING @maxint; +colA +0 +1 +0 +1 +3 +254 +0 +EXECUTE p_eq USING @minint; +colA +0 +0 +0 +EXECUTE p_equal USING @minint; +colA +0 +0 +0 +EXECUTE p_n_eq USING @minint; +colA +1 +1 +3 +254 +255 +EXECUTE p_n_equal USING @minint; +colA +1 +1 +3 +254 +255 +EXECUTE p_eq USING @minint_minus_1; +colA +EXECUTE p_equal USING @minint_minus_1; +colA +EXECUTE p_n_eq USING @minint_minus_1; +colA +0 +1 +0 +1 +3 +254 +255 +0 +EXECUTE p_n_equal USING @minint_minus_1; +colA +0 +1 +0 +1 +3 +254 +255 +0 +DROP PREPARE p_less; +DROP PREPARE p_less_eq; +DROP PREPARE p_greater; +DROP PREPARE p_gret_eq; +DROP PREPARE p_equal; +DROP PREPARE p_n_eq; +DROP PREPARE p_n_equal; +EXPLAIN SELECT * FROM tinytbl WHERE 2.56E02 > colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where true +EXPLAIN SELECT * FROM tinytbl WHERE 2.55E02 >= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where true +EXPLAIN SELECT * FROM tinytbl WHERE 2.56E02 < colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where false +EXPLAIN SELECT * FROM tinytbl WHERE 2.55E02 <= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (255 = `test`.`tinytbl`.`colA`) +EXPLAIN SELECT * FROM tinytbl WHERE 2.55E02 < colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where false +EXPLAIN SELECT * FROM tinytbl WHERE -1.0E00 < colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where true +EXPLAIN SELECT * FROM tinytbl WHERE -1.0E00 >= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where false +EXPLAIN SELECT * FROM tinytbl WHERE 0.0E+00 >= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (0 = `test`.`tinytbl`.`colA`) +EXPLAIN SELECT * FROM tinytbl WHERE 0.0E+00 <= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where true +EXPLAIN SELECT * FROM tinytbl WHERE 0.0E+00 < colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 33.33 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (0 < `test`.`tinytbl`.`colA`) +EXPLAIN SELECT * FROM tinytbl WHERE 2.56E02 = colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where false +EXPLAIN SELECT * FROM tinytbl WHERE 2.56E02 <=> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where false +EXPLAIN SELECT * FROM tinytbl WHERE 2.56E02 <> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where true +EXPLAIN SELECT * FROM tinytbl WHERE 2.55E02 = colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (255 = `test`.`tinytbl`.`colA`) +EXPLAIN SELECT * FROM tinytbl WHERE 2.55E02 <=> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (255 <=> `test`.`tinytbl`.`colA`) +EXPLAIN SELECT * FROM tinytbl WHERE 2.55E02 <> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (255 <> `test`.`tinytbl`.`colA`) +EXPLAIN SELECT * FROM tinytbl WHERE 0.0E+00 = colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (0 = `test`.`tinytbl`.`colA`) +EXPLAIN SELECT * FROM tinytbl WHERE 0.0E+00 <=> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (0 <=> `test`.`tinytbl`.`colA`) +EXPLAIN SELECT * FROM tinytbl WHERE 0.0E+00 <> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (0 <> `test`.`tinytbl`.`colA`) +EXPLAIN SELECT * FROM tinytbl WHERE -1.0E00 = colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where false +EXPLAIN SELECT * FROM tinytbl WHERE -1.0E00 <=> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where false +EXPLAIN SELECT * FROM tinytbl WHERE -1.0E00 <> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where true +DROP TABLE tinytbl; +# +# Tests with UNSIGNED type TINYINT NOT NULL against decimal +# +CREATE TABLE tinytbl (colA TINYINT UNSIGNED NOT NULL); +INSERT INTO tinytbl VALUES (0.0E+00), (1.0E00), +(0),(1),(3), +(2.54E02), (2.55E02), +(0); +ANALYZE TABLE tinytbl; +Table Op Msg_type Msg_text +test.tinytbl analyze status OK +SELECT * FROM tinytbl; +colA +0 +1 +0 +1 +3 +254 +255 +0 +SELECT * FROM tinytbl WHERE colA < 0.5; +colA +0 +0 +0 +SELECT * FROM tinytbl WHERE colA <= 0.5; +colA +0 +0 +0 +SELECT * FROM tinytbl WHERE colA > 0.5; +colA +1 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE colA >= 0.5; +colA +1 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE colA = 0.5; +colA +SELECT * FROM tinytbl WHERE colA <> 0.5; +colA +0 +1 +0 +1 +3 +254 +255 +0 +SELECT * FROM tinytbl WHERE colA < -0.5; +colA +SELECT * FROM tinytbl WHERE colA <= -0.5; +colA +SELECT * FROM tinytbl WHERE colA > -0.5; +colA +0 +1 +0 +1 +3 +254 +255 +0 +SELECT * FROM tinytbl WHERE colA >= -0.5; +colA +0 +1 +0 +1 +3 +254 +255 +0 +SELECT * FROM tinytbl WHERE colA = -0.5; +colA +SELECT * FROM tinytbl WHERE colA <> -0.5; +colA +0 +1 +0 +1 +3 +254 +255 +0 +SELECT * FROM tinytbl WHERE colA < '255.00001'; +colA +0 +1 +0 +1 +3 +254 +255 +0 +SELECT * FROM tinytbl WHERE colA <= '255.00001'; +colA +0 +1 +0 +1 +3 +254 +255 +0 +SELECT * FROM tinytbl WHERE colA > '255.00001'; +colA +SELECT * FROM tinytbl WHERE colA >= '255.00001'; +colA +SELECT * FROM tinytbl WHERE colA = '255.00001'; +colA +SELECT * FROM tinytbl WHERE colA <> '255.00001'; +colA +0 +1 +0 +1 +3 +254 +255 +0 +SELECT * FROM tinytbl WHERE colA < '254.99999'; +colA +0 +1 +0 +1 +3 +254 +0 +SELECT * FROM tinytbl WHERE colA <= '254.99999'; +colA +0 +1 +0 +1 +3 +254 +0 +SELECT * FROM tinytbl WHERE colA > '254.99999'; +colA +255 +SELECT * FROM tinytbl WHERE colA >= '254.99999'; +colA +255 +SELECT * FROM tinytbl WHERE colA = '254.99999'; +colA +SELECT * FROM tinytbl WHERE colA <> '254.99999'; +colA +0 +1 +0 +1 +3 +254 +255 +0 +SELECT * FROM tinytbl WHERE colA < '0.00001'; +colA +0 +0 +0 +SELECT * FROM tinytbl WHERE colA <= '0.00001'; +colA +0 +0 +0 +SELECT * FROM tinytbl WHERE colA > '0.00001'; +colA +1 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE colA >= '0.00001'; +colA +1 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE colA = '0.00001'; +colA +SELECT * FROM tinytbl WHERE colA <> '0.00001'; +colA +0 +1 +0 +1 +3 +254 +255 +0 +SELECT * FROM tinytbl WHERE colA < '-0.99999'; +colA +SELECT * FROM tinytbl WHERE colA <= '-0.99999'; +colA +SELECT * FROM tinytbl WHERE colA > '-0.99999'; +colA +0 +1 +0 +1 +3 +254 +255 +0 +SELECT * FROM tinytbl WHERE colA >= '-0.99999'; +colA +0 +1 +0 +1 +3 +254 +255 +0 +SELECT * FROM tinytbl WHERE colA = '-0.99999'; +colA +SELECT * FROM tinytbl WHERE colA <> '-0.99999'; +colA +0 +1 +0 +1 +3 +254 +255 +0 +SELECT * FROM tinytbl WHERE colA < 18446744073709551615.00000001; +colA +0 +1 +0 +1 +3 +254 +255 +0 +SELECT * FROM tinytbl WHERE colA <= 18446744073709551615.00000001; +colA +0 +1 +0 +1 +3 +254 +255 +0 +SELECT * FROM tinytbl WHERE colA > 18446744073709551615.00000001; +colA +SELECT * FROM tinytbl WHERE colA >= 18446744073709551615.00000001; +colA +SELECT * FROM tinytbl WHERE colA = 18446744073709551615.00000001; +colA +SELECT * FROM tinytbl WHERE colA <> 18446744073709551615.00000001; +colA +0 +1 +0 +1 +3 +254 +255 +0 +SELECT * FROM tinytbl WHERE colA < -9223372036854775808.00000001; +colA +SELECT * FROM tinytbl WHERE colA <= -9223372036854775808.00000001; +colA +SELECT * FROM tinytbl WHERE colA > -9223372036854775808.00000001; +colA +0 +1 +0 +1 +3 +254 +255 +0 +SELECT * FROM tinytbl WHERE colA >= -9223372036854775808.00000001; +colA +0 +1 +0 +1 +3 +254 +255 +0 +SELECT * FROM tinytbl WHERE colA = -9223372036854775808.00000001; +colA +SELECT * FROM tinytbl WHERE colA <> -9223372036854775808.00000001; +colA +0 +1 +0 +1 +3 +254 +255 +0 +PREPARE p_less FROM 'SELECT * FROM tinytbl WHERE colA < ?'; +PREPARE p_less_eq FROM 'SELECT * FROM tinytbl WHERE colA <= ?'; +PREPARE p_greater FROM 'SELECT * FROM tinytbl WHERE colA > ?'; +PREPARE p_gret_eq FROM 'SELECT * FROM tinytbl WHERE colA >= ?'; +PREPARE p_equal FROM 'SELECT * FROM tinytbl WHERE colA = ?'; +PREPARE p_n_equal FROM 'SELECT * FROM tinytbl WHERE colA <> ?'; +SET @dec_0_5=0.5; +SET @dec_minus_0_5=-0.5; +SET @dec_max_plus_delta='255.00001'; +SET @dec_max_minus_delta='254.99999'; +SET @dec_min_plus_delta='0.00001'; +SET @dec_min_minus_delta='-0.99999'; +SET @dec_too_big_positive_for_any_int=18446744073709551615.00000001; +SET @dec_too_big_negative_for_any_int=-9223372036854775808.00000001; +EXECUTE p_less USING @dec_0_5; +colA +0 +0 +0 +EXECUTE p_less_eq USING @dec_0_5; +colA +0 +0 +0 +EXECUTE p_greater USING @dec_0_5; +colA +1 +1 +3 +254 +255 +EXECUTE p_gret_eq USING @dec_0_5; +colA +1 +1 +3 +254 +255 +EXECUTE p_equal USING @dec_0_5; +colA +EXECUTE p_n_equal USING @dec_0_5; +colA +0 +1 +0 +1 +3 +254 +255 +0 +EXECUTE p_less USING @dec_minus_0_5; +colA +EXECUTE p_less_eq USING @dec_minus_0_5; +colA +EXECUTE p_greater USING @dec_minus_0_5; +colA +0 +1 +0 +1 +3 +254 +255 +0 +EXECUTE p_gret_eq USING @dec_minus_0_5; +colA +0 +1 +0 +1 +3 +254 +255 +0 +EXECUTE p_equal USING @dec_minus_0_5; +colA +EXECUTE p_n_equal USING @dec_minus_0_5; +colA +0 +1 +0 +1 +3 +254 +255 +0 +EXECUTE p_less USING @dec_max_plus_delta; +colA +0 +1 +0 +1 +3 +254 +255 +0 +EXECUTE p_less_eq USING @dec_max_plus_delta; +colA +0 +1 +0 +1 +3 +254 +255 +0 +EXECUTE p_greater USING @dec_max_plus_delta; +colA +EXECUTE p_gret_eq USING @dec_max_plus_delta; +colA +EXECUTE p_equal USING @dec_max_plus_delta; +colA +EXECUTE p_n_equal USING @dec_max_plus_delta; +colA +0 +1 +0 +1 +3 +254 +255 +0 +EXECUTE p_less USING @dec_max_minus_delta; +colA +0 +1 +0 +1 +3 +254 +0 +EXECUTE p_less_eq USING @dec_max_minus_delta; +colA +0 +1 +0 +1 +3 +254 +0 +EXECUTE p_greater USING @dec_max_minus_delta; +colA +255 +EXECUTE p_gret_eq USING @dec_max_minus_delta; +colA +255 +EXECUTE p_equal USING @dec_max_minus_delta; +colA +EXECUTE p_n_equal USING @dec_max_minus_delta; +colA +0 +1 +0 +1 +3 +254 +255 +0 +EXECUTE p_less USING @dec_min_plus_delta; +colA +0 +0 +0 +EXECUTE p_less_eq USING @dec_min_plus_delta; +colA +0 +0 +0 +EXECUTE p_greater USING @dec_min_plus_delta; +colA +1 +1 +3 +254 +255 +EXECUTE p_gret_eq USING @dec_min_plus_delta; +colA +1 +1 +3 +254 +255 +EXECUTE p_equal USING @dec_min_plus_delta; +colA +EXECUTE p_n_equal USING @dec_min_plus_delta; +colA +0 +1 +0 +1 +3 +254 +255 +0 +EXECUTE p_less USING @dec_min_minus_delta; +colA +EXECUTE p_less_eq USING @dec_min_minus_delta; +colA +EXECUTE p_greater USING @dec_min_minus_delta; +colA +0 +1 +0 +1 +3 +254 +255 +0 +EXECUTE p_gret_eq USING @dec_min_minus_delta; +colA +0 +1 +0 +1 +3 +254 +255 +0 +EXECUTE p_equal USING @dec_min_minus_delta; +colA +EXECUTE p_n_equal USING @dec_min_minus_delta; +colA +0 +1 +0 +1 +3 +254 +255 +0 +EXECUTE p_less USING @dec_too_big_positive_for_any_int; +colA +0 +1 +0 +1 +3 +254 +255 +0 +EXECUTE p_less_eq USING @dec_too_big_positive_for_any_int; +colA +0 +1 +0 +1 +3 +254 +255 +0 +EXECUTE p_greater USING @dec_too_big_positive_for_any_int; +colA +EXECUTE p_gret_eq USING @dec_too_big_positive_for_any_int; +colA +EXECUTE p_equal USING @dec_too_big_positive_for_any_int; +colA +EXECUTE p_n_equal USING @dec_too_big_positive_for_any_int; +colA +0 +1 +0 +1 +3 +254 +255 +0 +EXECUTE p_less USING @dec_too_big_negative_for_any_int; +colA +EXECUTE p_less_eq USING @dec_too_big_negative_for_any_int; +colA +EXECUTE p_greater USING @dec_too_big_negative_for_any_int; +colA +0 +1 +0 +1 +3 +254 +255 +0 +EXECUTE p_gret_eq USING @dec_too_big_negative_for_any_int; +colA +0 +1 +0 +1 +3 +254 +255 +0 +EXECUTE p_equal USING @dec_too_big_negative_for_any_int; +colA +EXECUTE p_n_equal USING @dec_too_big_negative_for_any_int; +colA +0 +1 +0 +1 +3 +254 +255 +0 +DROP PREPARE p_less; +DROP PREPARE p_less_eq; +DROP PREPARE p_greater; +DROP PREPARE p_gret_eq; +DROP PREPARE p_equal; +DROP PREPARE p_n_equal; +DROP TABLE tinytbl; +Cruft inside string +CREATE TABLE t(i INT); +INSERT INTO t VALUES (-1), (0), (1); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +SELECT * FROM t WHERE i > 'A'; +i +1 +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'A' +EXPLAIN SELECT * FROM t WHERE i > 'A'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'A' +Note 1003 /* select#1 */ select `test`.`t`.`i` AS `i` from `test`.`t` where (`test`.`t`.`i` > 0) +DROP TABLE t; +Detect decimal inside a string when compared to int +Used to return one row; should be none. +CREATE TABLE t(i BIGINT); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +INSERT INTO t VALUES (1), (2); +SELECT * FROM t WHERE i = '1.1'; +i +EXPLAIN SELECT * FROM t WHERE i = '1.1'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`i` AS `i` from `test`.`t` where false +DROP TABLE t; +Detect out of range real inside a string when compared to int +Used to return one row; should be none. +CREATE TABLE t(i TINYINT); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +INSERT INTO t VALUES (1), (2); +SELECT * FROM t WHERE i > '1E10'; +i +EXPLAIN SELECT * FROM t WHERE i > '1E10'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`i` AS `i` from `test`.`t` where false +DROP TABLE t; +Detect out of range real inside a string when compared to int +Used to return one row; should be none. +CREATE TABLE t(i TINYINT); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +INSERT INTO t VALUES (0); +SELECT * FROM t WHERE i = '1E-308'; +i +EXPLAIN SELECT * FROM t WHERE i = '1E-308'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`i` AS `i` from `test`.`t` where false +Above query should yield the same as this: +SELECT * FROM t WHERE i = 1E-308; +i +EXPLAIN SELECT * FROM t WHERE i = 1E-308; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`i` AS `i` from `test`.`t` where false +DROP TABLE t; +# +# Tests with type TINYINT against int +# +CREATE TABLE tinytbls (colA TINYINT ); +INSERT INTO tinytbls VALUES (-128), (-127), +(0),(1),(3), +(126), (127), +(NULL); +ANALYZE TABLE tinytbls; +Table Op Msg_type Msg_text +test.tinytbls analyze status OK +SELECT * FROM tinytbls; +colA +-128 +-127 +0 +1 +3 +126 +127 +NULL +SELECT * FROM tinytbls WHERE colA < 128; +colA +-128 +-127 +0 +1 +3 +126 +127 +SELECT * FROM tinytbls WHERE colA <= 127; +colA +-128 +-127 +0 +1 +3 +126 +127 +SELECT * FROM tinytbls WHERE colA > 128; +colA +SELECT * FROM tinytbls WHERE colA >= 127; +colA +127 +SELECT * FROM tinytbls WHERE colA > -129; +colA +-128 +-127 +0 +1 +3 +126 +127 +SELECT * FROM tinytbls WHERE colA <= -129; +colA +SELECT * FROM tinytbls WHERE colA <= -128; +colA +-128 +SELECT * FROM tinytbls WHERE colA >= -128; +colA +-128 +-127 +0 +1 +3 +126 +127 +SELECT * FROM tinytbls WHERE colA > -128; +colA +-127 +0 +1 +3 +126 +127 +SELECT * FROM tinytbls WHERE colA = 128; +colA +SELECT * FROM tinytbls WHERE colA <> 128; +colA +-128 +-127 +0 +1 +3 +126 +127 +SELECT * FROM tinytbls WHERE colA = 127; +colA +127 +SELECT * FROM tinytbls WHERE colA <=> 127; +colA +127 +SELECT * FROM tinytbls WHERE NOT(colA <=> 127); +colA +-128 +-127 +0 +1 +3 +126 +NULL +SELECT * FROM tinytbls WHERE colA <> 127; +colA +-128 +-127 +0 +1 +3 +126 +SELECT * FROM tinytbls WHERE colA = -128; +colA +-128 +SELECT * FROM tinytbls WHERE colA <=> -128; +colA +-128 +SELECT * FROM tinytbls WHERE NOT(colA <=> -128); +colA +-127 +0 +1 +3 +126 +127 +NULL +SELECT * FROM tinytbls WHERE colA <> -128; +colA +-127 +0 +1 +3 +126 +127 +SELECT * FROM tinytbls WHERE colA = -129; +colA +SELECT * FROM tinytbls WHERE colA <=> -129; +colA +SELECT * FROM tinytbls WHERE NOT(colA <=> -129); +colA +-128 +-127 +0 +1 +3 +126 +127 +NULL +SELECT * FROM tinytbls WHERE colA <> -129; +colA +-128 +-127 +0 +1 +3 +126 +127 +PREPARE p_less FROM 'SELECT * FROM tinytbls WHERE colA < ?'; +PREPARE p_less_eq FROM 'SELECT * FROM tinytbls WHERE colA <= ?'; +PREPARE p_greater FROM 'SELECT * FROM tinytbls WHERE colA > ?'; +PREPARE p_gret_eq FROM 'SELECT * FROM tinytbls WHERE colA >= ?'; +PREPARE p_eq FROM 'SELECT * FROM tinytbls WHERE colA = ?'; +PREPARE p_equal FROM 'SELECT * FROM tinytbls WHERE colA <=> ?'; +PREPARE p_n_equal FROM 'SELECT * FROM tinytbls WHERE NOT(colA <=> ?)'; +PREPARE p_n_eq FROM 'SELECT * FROM tinytbls WHERE colA <> ?'; +SET @maxint_plus_1=128; +SET @maxint=127; +SET @minint_minus_1=-129; +SET @minint=-128; +EXECUTE p_less USING @maxint_plus_1; +colA +-128 +-127 +0 +1 +3 +126 +127 +EXECUTE p_less_eq USING @maxint; +colA +-128 +-127 +0 +1 +3 +126 +127 +EXECUTE p_greater USING @maxint_plus_1; +colA +EXECUTE p_gret_eq USING @maxint; +colA +127 +EXECUTE p_greater USING @minint_minus_1; +colA +-128 +-127 +0 +1 +3 +126 +127 +EXECUTE p_less_eq USING @minint_minus_1; +colA +EXECUTE p_less_eq USING @minint; +colA +-128 +EXECUTE p_gret_eq USING @minint; +colA +-128 +-127 +0 +1 +3 +126 +127 +EXECUTE p_greater USING @minint; +colA +-127 +0 +1 +3 +126 +127 +EXECUTE p_eq USING @maxint_plus_1; +colA +EXECUTE p_equal USING @maxint_plus_1; +colA +EXECUTE p_n_eq USING @maxint_plus_1; +colA +-128 +-127 +0 +1 +3 +126 +127 +EXECUTE p_n_equal USING @maxint_plus_1; +colA +-128 +-127 +0 +1 +3 +126 +127 +NULL +EXECUTE p_eq USING @maxint; +colA +127 +EXECUTE p_equal USING @maxint; +colA +127 +EXECUTE p_n_eq USING @maxint; +colA +-128 +-127 +0 +1 +3 +126 +EXECUTE p_n_equal USING @maxint; +colA +-128 +-127 +0 +1 +3 +126 +NULL +EXECUTE p_eq USING @minint; +colA +-128 +EXECUTE p_equal USING @minint; +colA +-128 +EXECUTE p_n_eq USING @minint; +colA +-127 +0 +1 +3 +126 +127 +EXECUTE p_n_equal USING @minint; +colA +-127 +0 +1 +3 +126 +127 +NULL +EXECUTE p_eq USING @minint_minus_1; +colA +EXECUTE p_equal USING @minint_minus_1; +colA +EXECUTE p_n_eq USING @minint_minus_1; +colA +-128 +-127 +0 +1 +3 +126 +127 +EXECUTE p_n_equal USING @minint_minus_1; +colA +-128 +-127 +0 +1 +3 +126 +127 +NULL +DROP PREPARE p_less; +DROP PREPARE p_less_eq; +DROP PREPARE p_greater; +DROP PREPARE p_gret_eq; +DROP PREPARE p_equal; +DROP PREPARE p_n_eq; +DROP PREPARE p_n_equal; +EXPLAIN SELECT * FROM tinytbls WHERE colA < 128; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE tinytbls NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbls`.`colA` AS `colA` from `test`.`tinytbls` where (`test`.`tinytbls`.`colA` is not null) +EXPLAIN SELECT * FROM tinytbls WHERE colA <= 127; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE tinytbls NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbls`.`colA` AS `colA` from `test`.`tinytbls` where (`test`.`tinytbls`.`colA` is not null) +EXPLAIN SELECT * FROM tinytbls WHERE colA > 128; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbls`.`colA` AS `colA` from `test`.`tinytbls` where false +EXPLAIN SELECT * FROM tinytbls WHERE colA >= 127; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE tinytbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbls`.`colA` AS `colA` from `test`.`tinytbls` where (`test`.`tinytbls`.`colA` = 127) +EXPLAIN SELECT * FROM tinytbls WHERE colA > -129; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE tinytbls NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbls`.`colA` AS `colA` from `test`.`tinytbls` where (`test`.`tinytbls`.`colA` is not null) +EXPLAIN SELECT * FROM tinytbls WHERE colA <= -129; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbls`.`colA` AS `colA` from `test`.`tinytbls` where false +EXPLAIN SELECT * FROM tinytbls WHERE colA <= -128; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE tinytbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbls`.`colA` AS `colA` from `test`.`tinytbls` where (`test`.`tinytbls`.`colA` = (-(128))) +EXPLAIN SELECT * FROM tinytbls WHERE colA >= -128; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE tinytbls NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbls`.`colA` AS `colA` from `test`.`tinytbls` where (`test`.`tinytbls`.`colA` is not null) +EXPLAIN SELECT * FROM tinytbls WHERE colA > -128; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 33.33 Parallel execute (1 workers) +2 SIMPLE tinytbls NULL ALL NULL NULL NULL NULL 8 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbls`.`colA` AS `colA` from `test`.`tinytbls` where (`test`.`tinytbls`.`colA` > (-(128))) +EXPLAIN SELECT * FROM tinytbls WHERE colA = 128; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbls`.`colA` AS `colA` from `test`.`tinytbls` where false +EXPLAIN SELECT * FROM tinytbls WHERE colA <=> 128; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbls`.`colA` AS `colA` from `test`.`tinytbls` where false +EXPLAIN SELECT * FROM tinytbls WHERE colA <> 128; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE tinytbls NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbls`.`colA` AS `colA` from `test`.`tinytbls` where (`test`.`tinytbls`.`colA` is not null) +EXPLAIN SELECT * FROM tinytbls WHERE colA = 127; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE tinytbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbls`.`colA` AS `colA` from `test`.`tinytbls` where (`test`.`tinytbls`.`colA` = 127) +EXPLAIN SELECT * FROM tinytbls WHERE colA <=> 127; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE tinytbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbls`.`colA` AS `colA` from `test`.`tinytbls` where (`test`.`tinytbls`.`colA` <=> 127) +EXPLAIN SELECT * FROM tinytbls WHERE colA <> 127; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE tinytbls NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbls`.`colA` AS `colA` from `test`.`tinytbls` where (`test`.`tinytbls`.`colA` <> 127) +EXPLAIN SELECT * FROM tinytbls WHERE colA = -128; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE tinytbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbls`.`colA` AS `colA` from `test`.`tinytbls` where (`test`.`tinytbls`.`colA` = (-(128))) +EXPLAIN SELECT * FROM tinytbls WHERE colA <=> -128; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE tinytbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbls`.`colA` AS `colA` from `test`.`tinytbls` where (`test`.`tinytbls`.`colA` <=> (-(128))) +EXPLAIN SELECT * FROM tinytbls WHERE colA <> -128; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE tinytbls NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbls`.`colA` AS `colA` from `test`.`tinytbls` where (`test`.`tinytbls`.`colA` <> (-(128))) +EXPLAIN SELECT * FROM tinytbls WHERE colA = -129; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbls`.`colA` AS `colA` from `test`.`tinytbls` where false +EXPLAIN SELECT * FROM tinytbls WHERE colA <=> -129; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbls`.`colA` AS `colA` from `test`.`tinytbls` where false +EXPLAIN SELECT * FROM tinytbls WHERE colA <> -129; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE tinytbls NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbls`.`colA` AS `colA` from `test`.`tinytbls` where (`test`.`tinytbls`.`colA` is not null) +same queries but constant first +SELECT * FROM tinytbls WHERE 128 > colA; +colA +-128 +-127 +0 +1 +3 +126 +127 +SELECT * FROM tinytbls WHERE 127 >= colA; +colA +-128 +-127 +0 +1 +3 +126 +127 +SELECT * FROM tinytbls WHERE 128 < colA; +colA +SELECT * FROM tinytbls WHERE 127 <= colA; +colA +127 +SELECT * FROM tinytbls WHERE 127 < colA; +colA +SELECT * FROM tinytbls WHERE -129 < colA; +colA +-128 +-127 +0 +1 +3 +126 +127 +SELECT * FROM tinytbls WHERE -129 >= colA; +colA +SELECT * FROM tinytbls WHERE -128 >= colA; +colA +-128 +SELECT * FROM tinytbls WHERE -128 <= colA; +colA +-128 +-127 +0 +1 +3 +126 +127 +SELECT * FROM tinytbls WHERE -128 < colA; +colA +-127 +0 +1 +3 +126 +127 +SELECT * FROM tinytbls WHERE 128 = colA; +colA +SELECT * FROM tinytbls WHERE 128 <=> colA; +colA +SELECT * FROM tinytbls WHERE 128 <> colA; +colA +-128 +-127 +0 +1 +3 +126 +127 +SELECT * FROM tinytbls WHERE 127 = colA; +colA +127 +SELECT * FROM tinytbls WHERE 127 <=> colA; +colA +127 +SELECT * FROM tinytbls WHERE 127 <> colA; +colA +-128 +-127 +0 +1 +3 +126 +SELECT * FROM tinytbls WHERE -128 = colA; +colA +-128 +SELECT * FROM tinytbls WHERE -128 <=> colA; +colA +-128 +SELECT * FROM tinytbls WHERE -128 <> colA; +colA +-127 +0 +1 +3 +126 +127 +SELECT * FROM tinytbls WHERE -129 = colA; +colA +SELECT * FROM tinytbls WHERE -129 <=> colA; +colA +SELECT * FROM tinytbls WHERE -129 <> colA; +colA +-128 +-127 +0 +1 +3 +126 +127 +PREPARE p_less FROM 'SELECT * FROM tinytbls WHERE ? < colA'; +PREPARE p_less_eq FROM 'SELECT * FROM tinytbls WHERE ? <= colA'; +PREPARE p_greater FROM 'SELECT * FROM tinytbls WHERE ? > colA'; +PREPARE p_gret_eq FROM 'SELECT * FROM tinytbls WHERE ? >= colA'; +PREPARE p_eq FROM 'SELECT * FROM tinytbls WHERE ? = colA'; +PREPARE p_equal FROM 'SELECT * FROM tinytbls WHERE ? <=> colA'; +PREPARE p_n_eq FROM 'SELECT * FROM tinytbls WHERE ? <> colA'; +PREPARE p_n_equal FROM 'SELECT * FROM tinytbls WHERE NOT(? <=> colA)'; +EXECUTE p_greater USING @maxint_plus_1; +colA +-128 +-127 +0 +1 +3 +126 +127 +EXECUTE p_gret_eq USING @maxint; +colA +-128 +-127 +0 +1 +3 +126 +127 +EXECUTE p_less USING @maxint_plus_1; +colA +EXECUTE p_less_eq USING @maxint; +colA +127 +EXECUTE p_less USING @minint_minus_1; +colA +-128 +-127 +0 +1 +3 +126 +127 +EXECUTE p_gret_eq USING @minint_minus_1; +colA +EXECUTE p_gret_eq USING @minint; +colA +-128 +EXECUTE p_less_eq USING @minint; +colA +-128 +-127 +0 +1 +3 +126 +127 +EXECUTE p_less USING @minint; +colA +-127 +0 +1 +3 +126 +127 +EXECUTE p_eq USING @maxint_plus_1; +colA +EXECUTE p_equal USING @maxint_plus_1; +colA +EXECUTE p_n_eq USING @maxint_plus_1; +colA +-128 +-127 +0 +1 +3 +126 +127 +EXECUTE p_n_equal USING @maxint_plus_1; +colA +-128 +-127 +0 +1 +3 +126 +127 +NULL +EXECUTE p_eq USING @maxint; +colA +127 +EXECUTE p_equal USING @maxint; +colA +127 +EXECUTE p_n_eq USING @maxint; +colA +-128 +-127 +0 +1 +3 +126 +EXECUTE p_n_equal USING @maxint; +colA +-128 +-127 +0 +1 +3 +126 +NULL +EXECUTE p_eq USING @minint; +colA +-128 +EXECUTE p_equal USING @minint; +colA +-128 +EXECUTE p_n_eq USING @minint; +colA +-127 +0 +1 +3 +126 +127 +EXECUTE p_n_equal USING @minint; +colA +-127 +0 +1 +3 +126 +127 +NULL +EXECUTE p_eq USING @minint_minus_1; +colA +EXECUTE p_equal USING @minint_minus_1; +colA +EXECUTE p_n_eq USING @minint_minus_1; +colA +-128 +-127 +0 +1 +3 +126 +127 +EXECUTE p_n_equal USING @minint_minus_1; +colA +-128 +-127 +0 +1 +3 +126 +127 +NULL +DROP PREPARE p_less; +DROP PREPARE p_less_eq; +DROP PREPARE p_greater; +DROP PREPARE p_gret_eq; +DROP PREPARE p_equal; +DROP PREPARE p_n_eq; +DROP PREPARE p_n_equal; +EXPLAIN SELECT * FROM tinytbls WHERE 128 > colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE tinytbls NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbls`.`colA` AS `colA` from `test`.`tinytbls` where (`test`.`tinytbls`.`colA` is not null) +EXPLAIN SELECT * FROM tinytbls WHERE 127 >= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE tinytbls NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbls`.`colA` AS `colA` from `test`.`tinytbls` where (`test`.`tinytbls`.`colA` is not null) +EXPLAIN SELECT * FROM tinytbls WHERE 128 < colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbls`.`colA` AS `colA` from `test`.`tinytbls` where false +EXPLAIN SELECT * FROM tinytbls WHERE 127 <= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE tinytbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbls`.`colA` AS `colA` from `test`.`tinytbls` where (127 = `test`.`tinytbls`.`colA`) +EXPLAIN SELECT * FROM tinytbls WHERE 127 < colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbls`.`colA` AS `colA` from `test`.`tinytbls` where false +EXPLAIN SELECT * FROM tinytbls WHERE -129 < colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE tinytbls NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbls`.`colA` AS `colA` from `test`.`tinytbls` where (`test`.`tinytbls`.`colA` is not null) +EXPLAIN SELECT * FROM tinytbls WHERE -129 >= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbls`.`colA` AS `colA` from `test`.`tinytbls` where false +EXPLAIN SELECT * FROM tinytbls WHERE -128 >= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE tinytbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbls`.`colA` AS `colA` from `test`.`tinytbls` where ((-(128)) = `test`.`tinytbls`.`colA`) +EXPLAIN SELECT * FROM tinytbls WHERE -128 <= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE tinytbls NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbls`.`colA` AS `colA` from `test`.`tinytbls` where (`test`.`tinytbls`.`colA` is not null) +EXPLAIN SELECT * FROM tinytbls WHERE -128 < colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 33.33 Parallel execute (1 workers) +2 SIMPLE tinytbls NULL ALL NULL NULL NULL NULL 8 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbls`.`colA` AS `colA` from `test`.`tinytbls` where ((-(128)) < `test`.`tinytbls`.`colA`) +EXPLAIN SELECT * FROM tinytbls WHERE 128 = colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbls`.`colA` AS `colA` from `test`.`tinytbls` where false +EXPLAIN SELECT * FROM tinytbls WHERE 128 <=> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbls`.`colA` AS `colA` from `test`.`tinytbls` where false +EXPLAIN SELECT * FROM tinytbls WHERE 128 <> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE tinytbls NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbls`.`colA` AS `colA` from `test`.`tinytbls` where (`test`.`tinytbls`.`colA` is not null) +EXPLAIN SELECT * FROM tinytbls WHERE 127 = colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE tinytbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbls`.`colA` AS `colA` from `test`.`tinytbls` where (`test`.`tinytbls`.`colA` = 127) +EXPLAIN SELECT * FROM tinytbls WHERE 127 <=> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE tinytbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbls`.`colA` AS `colA` from `test`.`tinytbls` where (127 <=> `test`.`tinytbls`.`colA`) +EXPLAIN SELECT * FROM tinytbls WHERE 127 <> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE tinytbls NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbls`.`colA` AS `colA` from `test`.`tinytbls` where (127 <> `test`.`tinytbls`.`colA`) +EXPLAIN SELECT * FROM tinytbls WHERE -128 = colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE tinytbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbls`.`colA` AS `colA` from `test`.`tinytbls` where (`test`.`tinytbls`.`colA` = (-(128))) +EXPLAIN SELECT * FROM tinytbls WHERE -128 <=> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE tinytbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbls`.`colA` AS `colA` from `test`.`tinytbls` where ((-(128)) <=> `test`.`tinytbls`.`colA`) +EXPLAIN SELECT * FROM tinytbls WHERE -128 <> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE tinytbls NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbls`.`colA` AS `colA` from `test`.`tinytbls` where ((-(128)) <> `test`.`tinytbls`.`colA`) +EXPLAIN SELECT * FROM tinytbls WHERE -129 = colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbls`.`colA` AS `colA` from `test`.`tinytbls` where false +EXPLAIN SELECT * FROM tinytbls WHERE -129 <=> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbls`.`colA` AS `colA` from `test`.`tinytbls` where false +EXPLAIN SELECT * FROM tinytbls WHERE -129 <> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE tinytbls NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbls`.`colA` AS `colA` from `test`.`tinytbls` where (`test`.`tinytbls`.`colA` is not null) +DROP TABLE tinytbls; +# +# Tests with type TINYINT against decimal +# +CREATE TABLE tinytbls (colA TINYINT ); +INSERT INTO tinytbls VALUES (-128), (-127), +(0),(1),(3), +(126), (127), +(NULL); +ANALYZE TABLE tinytbls; +Table Op Msg_type Msg_text +test.tinytbls analyze status OK +SELECT * FROM tinytbls; +colA +-128 +-127 +0 +1 +3 +126 +127 +NULL +SELECT * FROM tinytbls WHERE colA < 0.5; +colA +-128 +-127 +0 +SELECT * FROM tinytbls WHERE colA <= 0.5; +colA +-128 +-127 +0 +SELECT * FROM tinytbls WHERE colA > 0.5; +colA +1 +3 +126 +127 +SELECT * FROM tinytbls WHERE colA >= 0.5; +colA +1 +3 +126 +127 +SELECT * FROM tinytbls WHERE colA = 0.5; +colA +SELECT * FROM tinytbls WHERE colA <> 0.5; +colA +-128 +-127 +0 +1 +3 +126 +127 +SELECT * FROM tinytbls WHERE colA < -0.5; +colA +-128 +-127 +SELECT * FROM tinytbls WHERE colA <= -0.5; +colA +-128 +-127 +SELECT * FROM tinytbls WHERE colA > -0.5; +colA +0 +1 +3 +126 +127 +SELECT * FROM tinytbls WHERE colA >= -0.5; +colA +0 +1 +3 +126 +127 +SELECT * FROM tinytbls WHERE colA = -0.5; +colA +SELECT * FROM tinytbls WHERE colA <> -0.5; +colA +-128 +-127 +0 +1 +3 +126 +127 +SELECT * FROM tinytbls WHERE colA < 127.00001; +colA +-128 +-127 +0 +1 +3 +126 +127 +SELECT * FROM tinytbls WHERE colA <= 127.00001; +colA +-128 +-127 +0 +1 +3 +126 +127 +SELECT * FROM tinytbls WHERE colA > 127.00001; +colA +SELECT * FROM tinytbls WHERE colA >= 127.00001; +colA +SELECT * FROM tinytbls WHERE colA = 127.00001; +colA +SELECT * FROM tinytbls WHERE colA <> 127.00001; +colA +-128 +-127 +0 +1 +3 +126 +127 +SELECT * FROM tinytbls WHERE colA < 126.99999; +colA +-128 +-127 +0 +1 +3 +126 +SELECT * FROM tinytbls WHERE colA <= 126.99999; +colA +-128 +-127 +0 +1 +3 +126 +SELECT * FROM tinytbls WHERE colA > 126.99999; +colA +127 +SELECT * FROM tinytbls WHERE colA >= 126.99999; +colA +127 +SELECT * FROM tinytbls WHERE colA = 126.99999; +colA +SELECT * FROM tinytbls WHERE colA <> 126.99999; +colA +-128 +-127 +0 +1 +3 +126 +127 +SELECT * FROM tinytbls WHERE colA < -127.99999; +colA +-128 +SELECT * FROM tinytbls WHERE colA <= -127.99999; +colA +-128 +SELECT * FROM tinytbls WHERE colA > -127.99999; +colA +-127 +0 +1 +3 +126 +127 +SELECT * FROM tinytbls WHERE colA >= -127.99999; +colA +-127 +0 +1 +3 +126 +127 +SELECT * FROM tinytbls WHERE colA = -127.99999; +colA +SELECT * FROM tinytbls WHERE colA <> -127.99999; +colA +-128 +-127 +0 +1 +3 +126 +127 +SELECT * FROM tinytbls WHERE colA < -128.00001; +colA +SELECT * FROM tinytbls WHERE colA <= -128.00001; +colA +SELECT * FROM tinytbls WHERE colA > -128.00001; +colA +-128 +-127 +0 +1 +3 +126 +127 +SELECT * FROM tinytbls WHERE colA >= -128.00001; +colA +-128 +-127 +0 +1 +3 +126 +127 +SELECT * FROM tinytbls WHERE colA = -128.00001; +colA +SELECT * FROM tinytbls WHERE colA <> -128.00001; +colA +-128 +-127 +0 +1 +3 +126 +127 +SELECT * FROM tinytbls WHERE colA < 18446744073709551615.00000001; +colA +-128 +-127 +0 +1 +3 +126 +127 +SELECT * FROM tinytbls WHERE colA <= 18446744073709551615.00000001; +colA +-128 +-127 +0 +1 +3 +126 +127 +SELECT * FROM tinytbls WHERE colA > 18446744073709551615.00000001; +colA +SELECT * FROM tinytbls WHERE colA >= 18446744073709551615.00000001; +colA +SELECT * FROM tinytbls WHERE colA = 18446744073709551615.00000001; +colA +SELECT * FROM tinytbls WHERE colA <> 18446744073709551615.00000001; +colA +-128 +-127 +0 +1 +3 +126 +127 +SELECT * FROM tinytbls WHERE colA < -9223372036854775808.00000001; +colA +SELECT * FROM tinytbls WHERE colA <= -9223372036854775808.00000001; +colA +SELECT * FROM tinytbls WHERE colA > -9223372036854775808.00000001; +colA +-128 +-127 +0 +1 +3 +126 +127 +SELECT * FROM tinytbls WHERE colA >= -9223372036854775808.00000001; +colA +-128 +-127 +0 +1 +3 +126 +127 +SELECT * FROM tinytbls WHERE colA = -9223372036854775808.00000001; +colA +SELECT * FROM tinytbls WHERE colA <> -9223372036854775808.00000001; +colA +-128 +-127 +0 +1 +3 +126 +127 +PREPARE p_less FROM 'SELECT * FROM tinytbls WHERE colA < ?'; +PREPARE p_less_eq FROM 'SELECT * FROM tinytbls WHERE colA <= ?'; +PREPARE p_greater FROM 'SELECT * FROM tinytbls WHERE colA > ?'; +PREPARE p_gret_eq FROM 'SELECT * FROM tinytbls WHERE colA >= ?'; +PREPARE p_equal FROM 'SELECT * FROM tinytbls WHERE colA = ?'; +PREPARE p_n_equal FROM 'SELECT * FROM tinytbls WHERE colA <> ?'; +SET @dec_0_5=0.5; +SET @dec_minus_0_5=-0.5; +SET @dec_max_plus_delta=127.00001; +SET @dec_max_minus_delta=126.99999; +SET @dec_min_plus_delta=-127.99999; +SET @dec_min_minus_delta=-128.00001; +SET @dec_too_big_positive_for_any_int=18446744073709551615.00000001; +SET @dec_too_big_negative_for_any_int=-9223372036854775808.00000001; +EXECUTE p_less USING @dec_0_5; +colA +-128 +-127 +0 +EXECUTE p_less_eq USING @dec_0_5; +colA +-128 +-127 +0 +EXECUTE p_greater USING @dec_0_5; +colA +1 +3 +126 +127 +EXECUTE p_gret_eq USING @dec_0_5; +colA +1 +3 +126 +127 +EXECUTE p_equal USING @dec_0_5; +colA +EXECUTE p_n_equal USING @dec_0_5; +colA +-128 +-127 +0 +1 +3 +126 +127 +EXECUTE p_less USING @dec_minus_0_5; +colA +-128 +-127 +EXECUTE p_less_eq USING @dec_minus_0_5; +colA +-128 +-127 +EXECUTE p_greater USING @dec_minus_0_5; +colA +0 +1 +3 +126 +127 +EXECUTE p_gret_eq USING @dec_minus_0_5; +colA +0 +1 +3 +126 +127 +EXECUTE p_equal USING @dec_minus_0_5; +colA +EXECUTE p_n_equal USING @dec_minus_0_5; +colA +-128 +-127 +0 +1 +3 +126 +127 +EXECUTE p_less USING @dec_max_plus_delta; +colA +-128 +-127 +0 +1 +3 +126 +127 +EXECUTE p_less_eq USING @dec_max_plus_delta; +colA +-128 +-127 +0 +1 +3 +126 +127 +EXECUTE p_greater USING @dec_max_plus_delta; +colA +EXECUTE p_gret_eq USING @dec_max_plus_delta; +colA +EXECUTE p_equal USING @dec_max_plus_delta; +colA +EXECUTE p_n_equal USING @dec_max_plus_delta; +colA +-128 +-127 +0 +1 +3 +126 +127 +EXECUTE p_less USING @dec_max_minus_delta; +colA +-128 +-127 +0 +1 +3 +126 +EXECUTE p_less_eq USING @dec_max_minus_delta; +colA +-128 +-127 +0 +1 +3 +126 +EXECUTE p_greater USING @dec_max_minus_delta; +colA +127 +EXECUTE p_gret_eq USING @dec_max_minus_delta; +colA +127 +EXECUTE p_equal USING @dec_max_minus_delta; +colA +EXECUTE p_n_equal USING @dec_max_minus_delta; +colA +-128 +-127 +0 +1 +3 +126 +127 +EXECUTE p_less USING @dec_min_plus_delta; +colA +-128 +EXECUTE p_less_eq USING @dec_min_plus_delta; +colA +-128 +EXECUTE p_greater USING @dec_min_plus_delta; +colA +-127 +0 +1 +3 +126 +127 +EXECUTE p_gret_eq USING @dec_min_plus_delta; +colA +-127 +0 +1 +3 +126 +127 +EXECUTE p_equal USING @dec_min_plus_delta; +colA +EXECUTE p_n_equal USING @dec_min_plus_delta; +colA +-128 +-127 +0 +1 +3 +126 +127 +EXECUTE p_less USING @dec_min_minus_delta; +colA +EXECUTE p_less_eq USING @dec_min_minus_delta; +colA +EXECUTE p_greater USING @dec_min_minus_delta; +colA +-128 +-127 +0 +1 +3 +126 +127 +EXECUTE p_gret_eq USING @dec_min_minus_delta; +colA +-128 +-127 +0 +1 +3 +126 +127 +EXECUTE p_equal USING @dec_min_minus_delta; +colA +EXECUTE p_n_equal USING @dec_min_minus_delta; +colA +-128 +-127 +0 +1 +3 +126 +127 +EXECUTE p_less USING @dec_too_big_positive_for_any_int; +colA +-128 +-127 +0 +1 +3 +126 +127 +EXECUTE p_less_eq USING @dec_too_big_positive_for_any_int; +colA +-128 +-127 +0 +1 +3 +126 +127 +EXECUTE p_greater USING @dec_too_big_positive_for_any_int; +colA +EXECUTE p_gret_eq USING @dec_too_big_positive_for_any_int; +colA +EXECUTE p_equal USING @dec_too_big_positive_for_any_int; +colA +EXECUTE p_n_equal USING @dec_too_big_positive_for_any_int; +colA +-128 +-127 +0 +1 +3 +126 +127 +EXECUTE p_less USING @dec_too_big_negative_for_any_int; +colA +EXECUTE p_less_eq USING @dec_too_big_negative_for_any_int; +colA +EXECUTE p_greater USING @dec_too_big_negative_for_any_int; +colA +-128 +-127 +0 +1 +3 +126 +127 +EXECUTE p_gret_eq USING @dec_too_big_negative_for_any_int; +colA +-128 +-127 +0 +1 +3 +126 +127 +EXECUTE p_equal USING @dec_too_big_negative_for_any_int; +colA +EXECUTE p_n_equal USING @dec_too_big_negative_for_any_int; +colA +-128 +-127 +0 +1 +3 +126 +127 +DROP PREPARE p_less; +DROP PREPARE p_less_eq; +DROP PREPARE p_greater; +DROP PREPARE p_gret_eq; +DROP PREPARE p_equal; +DROP PREPARE p_n_equal; +DROP TABLE tinytbls; +Cruft inside string +CREATE TABLE t(i INT); +INSERT INTO t VALUES (-1), (0), (1); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +SELECT * FROM t WHERE i > 'A'; +i +1 +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'A' +EXPLAIN SELECT * FROM t WHERE i > 'A'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'A' +Note 1003 /* select#1 */ select `test`.`t`.`i` AS `i` from `test`.`t` where (`test`.`t`.`i` > 0) +DROP TABLE t; +Detect decimal inside a string when compared to int +Used to return one row; should be none. +CREATE TABLE t(i BIGINT); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +INSERT INTO t VALUES (1), (2); +SELECT * FROM t WHERE i = '1.1'; +i +EXPLAIN SELECT * FROM t WHERE i = '1.1'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`i` AS `i` from `test`.`t` where false +DROP TABLE t; +Detect out of range real inside a string when compared to int +Used to return one row; should be none. +CREATE TABLE t(i TINYINT); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +INSERT INTO t VALUES (1), (2); +SELECT * FROM t WHERE i > '1E10'; +i +EXPLAIN SELECT * FROM t WHERE i > '1E10'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`i` AS `i` from `test`.`t` where false +DROP TABLE t; +Detect out of range real inside a string when compared to int +Used to return one row; should be none. +CREATE TABLE t(i TINYINT); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +INSERT INTO t VALUES (0); +SELECT * FROM t WHERE i = '1E-308'; +i +EXPLAIN SELECT * FROM t WHERE i = '1E-308'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`i` AS `i` from `test`.`t` where false +Above query should yield the same as this: +SELECT * FROM t WHERE i = 1E-308; +i +EXPLAIN SELECT * FROM t WHERE i = 1E-308; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`i` AS `i` from `test`.`t` where false +DROP TABLE t; +# +# Tests with type TINYINT NOT NULL against int +# +CREATE TABLE tinytbls (colA TINYINT NOT NULL); +INSERT INTO tinytbls VALUES (-128), (-127), +(0),(1),(3), +(126), (127), +(0); +ANALYZE TABLE tinytbls; +Table Op Msg_type Msg_text +test.tinytbls analyze status OK +SELECT * FROM tinytbls; +colA +-128 +-127 +0 +1 +3 +126 +127 +0 +SELECT * FROM tinytbls WHERE colA < 128; +colA +-128 +-127 +0 +1 +3 +126 +127 +0 +SELECT * FROM tinytbls WHERE colA <= 127; +colA +-128 +-127 +0 +1 +3 +126 +127 +0 +SELECT * FROM tinytbls WHERE colA > 128; +colA +SELECT * FROM tinytbls WHERE colA >= 127; +colA +127 +SELECT * FROM tinytbls WHERE colA > -129; +colA +-128 +-127 +0 +1 +3 +126 +127 +0 +SELECT * FROM tinytbls WHERE colA <= -129; +colA +SELECT * FROM tinytbls WHERE colA <= -128; +colA +-128 +SELECT * FROM tinytbls WHERE colA >= -128; +colA +-128 +-127 +0 +1 +3 +126 +127 +0 +SELECT * FROM tinytbls WHERE colA > -128; +colA +-127 +0 +1 +3 +126 +127 +0 +SELECT * FROM tinytbls WHERE colA = 128; +colA +SELECT * FROM tinytbls WHERE colA <> 128; +colA +-128 +-127 +0 +1 +3 +126 +127 +0 +SELECT * FROM tinytbls WHERE colA = 127; +colA +127 +SELECT * FROM tinytbls WHERE colA <=> 127; +colA +127 +SELECT * FROM tinytbls WHERE NOT(colA <=> 127); +colA +-128 +-127 +0 +1 +3 +126 +0 +SELECT * FROM tinytbls WHERE colA <> 127; +colA +-128 +-127 +0 +1 +3 +126 +0 +SELECT * FROM tinytbls WHERE colA = -128; +colA +-128 +SELECT * FROM tinytbls WHERE colA <=> -128; +colA +-128 +SELECT * FROM tinytbls WHERE NOT(colA <=> -128); +colA +-127 +0 +1 +3 +126 +127 +0 +SELECT * FROM tinytbls WHERE colA <> -128; +colA +-127 +0 +1 +3 +126 +127 +0 +SELECT * FROM tinytbls WHERE colA = -129; +colA +SELECT * FROM tinytbls WHERE colA <=> -129; +colA +SELECT * FROM tinytbls WHERE NOT(colA <=> -129); +colA +-128 +-127 +0 +1 +3 +126 +127 +0 +SELECT * FROM tinytbls WHERE colA <> -129; +colA +-128 +-127 +0 +1 +3 +126 +127 +0 +PREPARE p_less FROM 'SELECT * FROM tinytbls WHERE colA < ?'; +PREPARE p_less_eq FROM 'SELECT * FROM tinytbls WHERE colA <= ?'; +PREPARE p_greater FROM 'SELECT * FROM tinytbls WHERE colA > ?'; +PREPARE p_gret_eq FROM 'SELECT * FROM tinytbls WHERE colA >= ?'; +PREPARE p_eq FROM 'SELECT * FROM tinytbls WHERE colA = ?'; +PREPARE p_equal FROM 'SELECT * FROM tinytbls WHERE colA <=> ?'; +PREPARE p_n_equal FROM 'SELECT * FROM tinytbls WHERE NOT(colA <=> ?)'; +PREPARE p_n_eq FROM 'SELECT * FROM tinytbls WHERE colA <> ?'; +SET @maxint_plus_1=128; +SET @maxint=127; +SET @minint_minus_1=-129; +SET @minint=-128; +EXECUTE p_less USING @maxint_plus_1; +colA +-128 +-127 +0 +1 +3 +126 +127 +0 +EXECUTE p_less_eq USING @maxint; +colA +-128 +-127 +0 +1 +3 +126 +127 +0 +EXECUTE p_greater USING @maxint_plus_1; +colA +EXECUTE p_gret_eq USING @maxint; +colA +127 +EXECUTE p_greater USING @minint_minus_1; +colA +-128 +-127 +0 +1 +3 +126 +127 +0 +EXECUTE p_less_eq USING @minint_minus_1; +colA +EXECUTE p_less_eq USING @minint; +colA +-128 +EXECUTE p_gret_eq USING @minint; +colA +-128 +-127 +0 +1 +3 +126 +127 +0 +EXECUTE p_greater USING @minint; +colA +-127 +0 +1 +3 +126 +127 +0 +EXECUTE p_eq USING @maxint_plus_1; +colA +EXECUTE p_equal USING @maxint_plus_1; +colA +EXECUTE p_n_eq USING @maxint_plus_1; +colA +-128 +-127 +0 +1 +3 +126 +127 +0 +EXECUTE p_n_equal USING @maxint_plus_1; +colA +-128 +-127 +0 +1 +3 +126 +127 +0 +EXECUTE p_eq USING @maxint; +colA +127 +EXECUTE p_equal USING @maxint; +colA +127 +EXECUTE p_n_eq USING @maxint; +colA +-128 +-127 +0 +1 +3 +126 +0 +EXECUTE p_n_equal USING @maxint; +colA +-128 +-127 +0 +1 +3 +126 +0 +EXECUTE p_eq USING @minint; +colA +-128 +EXECUTE p_equal USING @minint; +colA +-128 +EXECUTE p_n_eq USING @minint; +colA +-127 +0 +1 +3 +126 +127 +0 +EXECUTE p_n_equal USING @minint; +colA +-127 +0 +1 +3 +126 +127 +0 +EXECUTE p_eq USING @minint_minus_1; +colA +EXECUTE p_equal USING @minint_minus_1; +colA +EXECUTE p_n_eq USING @minint_minus_1; +colA +-128 +-127 +0 +1 +3 +126 +127 +0 +EXECUTE p_n_equal USING @minint_minus_1; +colA +-128 +-127 +0 +1 +3 +126 +127 +0 +DROP PREPARE p_less; +DROP PREPARE p_less_eq; +DROP PREPARE p_greater; +DROP PREPARE p_gret_eq; +DROP PREPARE p_equal; +DROP PREPARE p_n_eq; +DROP PREPARE p_n_equal; +EXPLAIN SELECT * FROM tinytbls WHERE colA < 128; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE tinytbls NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbls`.`colA` AS `colA` from `test`.`tinytbls` where true +EXPLAIN SELECT * FROM tinytbls WHERE colA <= 127; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE tinytbls NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbls`.`colA` AS `colA` from `test`.`tinytbls` where true +EXPLAIN SELECT * FROM tinytbls WHERE colA > 128; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbls`.`colA` AS `colA` from `test`.`tinytbls` where false +EXPLAIN SELECT * FROM tinytbls WHERE colA >= 127; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE tinytbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbls`.`colA` AS `colA` from `test`.`tinytbls` where (`test`.`tinytbls`.`colA` = 127) +EXPLAIN SELECT * FROM tinytbls WHERE colA > -129; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE tinytbls NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbls`.`colA` AS `colA` from `test`.`tinytbls` where true +EXPLAIN SELECT * FROM tinytbls WHERE colA <= -129; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbls`.`colA` AS `colA` from `test`.`tinytbls` where false +EXPLAIN SELECT * FROM tinytbls WHERE colA <= -128; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE tinytbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbls`.`colA` AS `colA` from `test`.`tinytbls` where (`test`.`tinytbls`.`colA` = (-(128))) +EXPLAIN SELECT * FROM tinytbls WHERE colA >= -128; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE tinytbls NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbls`.`colA` AS `colA` from `test`.`tinytbls` where true +EXPLAIN SELECT * FROM tinytbls WHERE colA > -128; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 33.33 Parallel execute (1 workers) +2 SIMPLE tinytbls NULL ALL NULL NULL NULL NULL 8 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbls`.`colA` AS `colA` from `test`.`tinytbls` where (`test`.`tinytbls`.`colA` > (-(128))) +EXPLAIN SELECT * FROM tinytbls WHERE colA = 128; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbls`.`colA` AS `colA` from `test`.`tinytbls` where false +EXPLAIN SELECT * FROM tinytbls WHERE colA <=> 128; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbls`.`colA` AS `colA` from `test`.`tinytbls` where false +EXPLAIN SELECT * FROM tinytbls WHERE colA <> 128; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE tinytbls NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbls`.`colA` AS `colA` from `test`.`tinytbls` where true +EXPLAIN SELECT * FROM tinytbls WHERE colA = 127; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE tinytbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbls`.`colA` AS `colA` from `test`.`tinytbls` where (`test`.`tinytbls`.`colA` = 127) +EXPLAIN SELECT * FROM tinytbls WHERE colA <=> 127; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE tinytbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbls`.`colA` AS `colA` from `test`.`tinytbls` where (`test`.`tinytbls`.`colA` <=> 127) +EXPLAIN SELECT * FROM tinytbls WHERE colA <> 127; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE tinytbls NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbls`.`colA` AS `colA` from `test`.`tinytbls` where (`test`.`tinytbls`.`colA` <> 127) +EXPLAIN SELECT * FROM tinytbls WHERE colA = -128; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE tinytbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbls`.`colA` AS `colA` from `test`.`tinytbls` where (`test`.`tinytbls`.`colA` = (-(128))) +EXPLAIN SELECT * FROM tinytbls WHERE colA <=> -128; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE tinytbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbls`.`colA` AS `colA` from `test`.`tinytbls` where (`test`.`tinytbls`.`colA` <=> (-(128))) +EXPLAIN SELECT * FROM tinytbls WHERE colA <> -128; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE tinytbls NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbls`.`colA` AS `colA` from `test`.`tinytbls` where (`test`.`tinytbls`.`colA` <> (-(128))) +EXPLAIN SELECT * FROM tinytbls WHERE colA = -129; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbls`.`colA` AS `colA` from `test`.`tinytbls` where false +EXPLAIN SELECT * FROM tinytbls WHERE colA <=> -129; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbls`.`colA` AS `colA` from `test`.`tinytbls` where false +EXPLAIN SELECT * FROM tinytbls WHERE colA <> -129; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE tinytbls NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbls`.`colA` AS `colA` from `test`.`tinytbls` where true +same queries but constant first +SELECT * FROM tinytbls WHERE 128 > colA; +colA +-128 +-127 +0 +1 +3 +126 +127 +0 +SELECT * FROM tinytbls WHERE 127 >= colA; +colA +-128 +-127 +0 +1 +3 +126 +127 +0 +SELECT * FROM tinytbls WHERE 128 < colA; +colA +SELECT * FROM tinytbls WHERE 127 <= colA; +colA +127 +SELECT * FROM tinytbls WHERE 127 < colA; +colA +SELECT * FROM tinytbls WHERE -129 < colA; +colA +-128 +-127 +0 +1 +3 +126 +127 +0 +SELECT * FROM tinytbls WHERE -129 >= colA; +colA +SELECT * FROM tinytbls WHERE -128 >= colA; +colA +-128 +SELECT * FROM tinytbls WHERE -128 <= colA; +colA +-128 +-127 +0 +1 +3 +126 +127 +0 +SELECT * FROM tinytbls WHERE -128 < colA; +colA +-127 +0 +1 +3 +126 +127 +0 +SELECT * FROM tinytbls WHERE 128 = colA; +colA +SELECT * FROM tinytbls WHERE 128 <=> colA; +colA +SELECT * FROM tinytbls WHERE 128 <> colA; +colA +-128 +-127 +0 +1 +3 +126 +127 +0 +SELECT * FROM tinytbls WHERE 127 = colA; +colA +127 +SELECT * FROM tinytbls WHERE 127 <=> colA; +colA +127 +SELECT * FROM tinytbls WHERE 127 <> colA; +colA +-128 +-127 +0 +1 +3 +126 +0 +SELECT * FROM tinytbls WHERE -128 = colA; +colA +-128 +SELECT * FROM tinytbls WHERE -128 <=> colA; +colA +-128 +SELECT * FROM tinytbls WHERE -128 <> colA; +colA +-127 +0 +1 +3 +126 +127 +0 +SELECT * FROM tinytbls WHERE -129 = colA; +colA +SELECT * FROM tinytbls WHERE -129 <=> colA; +colA +SELECT * FROM tinytbls WHERE -129 <> colA; +colA +-128 +-127 +0 +1 +3 +126 +127 +0 +PREPARE p_less FROM 'SELECT * FROM tinytbls WHERE ? < colA'; +PREPARE p_less_eq FROM 'SELECT * FROM tinytbls WHERE ? <= colA'; +PREPARE p_greater FROM 'SELECT * FROM tinytbls WHERE ? > colA'; +PREPARE p_gret_eq FROM 'SELECT * FROM tinytbls WHERE ? >= colA'; +PREPARE p_eq FROM 'SELECT * FROM tinytbls WHERE ? = colA'; +PREPARE p_equal FROM 'SELECT * FROM tinytbls WHERE ? <=> colA'; +PREPARE p_n_eq FROM 'SELECT * FROM tinytbls WHERE ? <> colA'; +PREPARE p_n_equal FROM 'SELECT * FROM tinytbls WHERE NOT(? <=> colA)'; +EXECUTE p_greater USING @maxint_plus_1; +colA +-128 +-127 +0 +1 +3 +126 +127 +0 +EXECUTE p_gret_eq USING @maxint; +colA +-128 +-127 +0 +1 +3 +126 +127 +0 +EXECUTE p_less USING @maxint_plus_1; +colA +EXECUTE p_less_eq USING @maxint; +colA +127 +EXECUTE p_less USING @minint_minus_1; +colA +-128 +-127 +0 +1 +3 +126 +127 +0 +EXECUTE p_gret_eq USING @minint_minus_1; +colA +EXECUTE p_gret_eq USING @minint; +colA +-128 +EXECUTE p_less_eq USING @minint; +colA +-128 +-127 +0 +1 +3 +126 +127 +0 +EXECUTE p_less USING @minint; +colA +-127 +0 +1 +3 +126 +127 +0 +EXECUTE p_eq USING @maxint_plus_1; +colA +EXECUTE p_equal USING @maxint_plus_1; +colA +EXECUTE p_n_eq USING @maxint_plus_1; +colA +-128 +-127 +0 +1 +3 +126 +127 +0 +EXECUTE p_n_equal USING @maxint_plus_1; +colA +-128 +-127 +0 +1 +3 +126 +127 +0 +EXECUTE p_eq USING @maxint; +colA +127 +EXECUTE p_equal USING @maxint; +colA +127 +EXECUTE p_n_eq USING @maxint; +colA +-128 +-127 +0 +1 +3 +126 +0 +EXECUTE p_n_equal USING @maxint; +colA +-128 +-127 +0 +1 +3 +126 +0 +EXECUTE p_eq USING @minint; +colA +-128 +EXECUTE p_equal USING @minint; +colA +-128 +EXECUTE p_n_eq USING @minint; +colA +-127 +0 +1 +3 +126 +127 +0 +EXECUTE p_n_equal USING @minint; +colA +-127 +0 +1 +3 +126 +127 +0 +EXECUTE p_eq USING @minint_minus_1; +colA +EXECUTE p_equal USING @minint_minus_1; +colA +EXECUTE p_n_eq USING @minint_minus_1; +colA +-128 +-127 +0 +1 +3 +126 +127 +0 +EXECUTE p_n_equal USING @minint_minus_1; +colA +-128 +-127 +0 +1 +3 +126 +127 +0 +DROP PREPARE p_less; +DROP PREPARE p_less_eq; +DROP PREPARE p_greater; +DROP PREPARE p_gret_eq; +DROP PREPARE p_equal; +DROP PREPARE p_n_eq; +DROP PREPARE p_n_equal; +EXPLAIN SELECT * FROM tinytbls WHERE 128 > colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE tinytbls NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbls`.`colA` AS `colA` from `test`.`tinytbls` where true +EXPLAIN SELECT * FROM tinytbls WHERE 127 >= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE tinytbls NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbls`.`colA` AS `colA` from `test`.`tinytbls` where true +EXPLAIN SELECT * FROM tinytbls WHERE 128 < colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbls`.`colA` AS `colA` from `test`.`tinytbls` where false +EXPLAIN SELECT * FROM tinytbls WHERE 127 <= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE tinytbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbls`.`colA` AS `colA` from `test`.`tinytbls` where (127 = `test`.`tinytbls`.`colA`) +EXPLAIN SELECT * FROM tinytbls WHERE 127 < colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbls`.`colA` AS `colA` from `test`.`tinytbls` where false +EXPLAIN SELECT * FROM tinytbls WHERE -129 < colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE tinytbls NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbls`.`colA` AS `colA` from `test`.`tinytbls` where true +EXPLAIN SELECT * FROM tinytbls WHERE -129 >= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbls`.`colA` AS `colA` from `test`.`tinytbls` where false +EXPLAIN SELECT * FROM tinytbls WHERE -128 >= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE tinytbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbls`.`colA` AS `colA` from `test`.`tinytbls` where ((-(128)) = `test`.`tinytbls`.`colA`) +EXPLAIN SELECT * FROM tinytbls WHERE -128 <= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE tinytbls NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbls`.`colA` AS `colA` from `test`.`tinytbls` where true +EXPLAIN SELECT * FROM tinytbls WHERE -128 < colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 33.33 Parallel execute (1 workers) +2 SIMPLE tinytbls NULL ALL NULL NULL NULL NULL 8 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbls`.`colA` AS `colA` from `test`.`tinytbls` where ((-(128)) < `test`.`tinytbls`.`colA`) +EXPLAIN SELECT * FROM tinytbls WHERE 128 = colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbls`.`colA` AS `colA` from `test`.`tinytbls` where false +EXPLAIN SELECT * FROM tinytbls WHERE 128 <=> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbls`.`colA` AS `colA` from `test`.`tinytbls` where false +EXPLAIN SELECT * FROM tinytbls WHERE 128 <> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE tinytbls NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbls`.`colA` AS `colA` from `test`.`tinytbls` where true +EXPLAIN SELECT * FROM tinytbls WHERE 127 = colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE tinytbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbls`.`colA` AS `colA` from `test`.`tinytbls` where (`test`.`tinytbls`.`colA` = 127) +EXPLAIN SELECT * FROM tinytbls WHERE 127 <=> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE tinytbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbls`.`colA` AS `colA` from `test`.`tinytbls` where (127 <=> `test`.`tinytbls`.`colA`) +EXPLAIN SELECT * FROM tinytbls WHERE 127 <> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE tinytbls NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbls`.`colA` AS `colA` from `test`.`tinytbls` where (127 <> `test`.`tinytbls`.`colA`) +EXPLAIN SELECT * FROM tinytbls WHERE -128 = colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE tinytbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbls`.`colA` AS `colA` from `test`.`tinytbls` where (`test`.`tinytbls`.`colA` = (-(128))) +EXPLAIN SELECT * FROM tinytbls WHERE -128 <=> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE tinytbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbls`.`colA` AS `colA` from `test`.`tinytbls` where ((-(128)) <=> `test`.`tinytbls`.`colA`) +EXPLAIN SELECT * FROM tinytbls WHERE -128 <> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE tinytbls NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbls`.`colA` AS `colA` from `test`.`tinytbls` where ((-(128)) <> `test`.`tinytbls`.`colA`) +EXPLAIN SELECT * FROM tinytbls WHERE -129 = colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbls`.`colA` AS `colA` from `test`.`tinytbls` where false +EXPLAIN SELECT * FROM tinytbls WHERE -129 <=> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbls`.`colA` AS `colA` from `test`.`tinytbls` where false +EXPLAIN SELECT * FROM tinytbls WHERE -129 <> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE tinytbls NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbls`.`colA` AS `colA` from `test`.`tinytbls` where true +DROP TABLE tinytbls; +# +# Tests with type TINYINT NOT NULL against decimal +# +CREATE TABLE tinytbls (colA TINYINT NOT NULL); +INSERT INTO tinytbls VALUES (-128), (-127), +(0),(1),(3), +(126), (127), +(0); +ANALYZE TABLE tinytbls; +Table Op Msg_type Msg_text +test.tinytbls analyze status OK +SELECT * FROM tinytbls; +colA +-128 +-127 +0 +1 +3 +126 +127 +0 +SELECT * FROM tinytbls WHERE colA < 0.5; +colA +-128 +-127 +0 +0 +SELECT * FROM tinytbls WHERE colA <= 0.5; +colA +-128 +-127 +0 +0 +SELECT * FROM tinytbls WHERE colA > 0.5; +colA +1 +3 +126 +127 +SELECT * FROM tinytbls WHERE colA >= 0.5; +colA +1 +3 +126 +127 +SELECT * FROM tinytbls WHERE colA = 0.5; +colA +SELECT * FROM tinytbls WHERE colA <> 0.5; +colA +-128 +-127 +0 +1 +3 +126 +127 +0 +SELECT * FROM tinytbls WHERE colA < -0.5; +colA +-128 +-127 +SELECT * FROM tinytbls WHERE colA <= -0.5; +colA +-128 +-127 +SELECT * FROM tinytbls WHERE colA > -0.5; +colA +0 +1 +3 +126 +127 +0 +SELECT * FROM tinytbls WHERE colA >= -0.5; +colA +0 +1 +3 +126 +127 +0 +SELECT * FROM tinytbls WHERE colA = -0.5; +colA +SELECT * FROM tinytbls WHERE colA <> -0.5; +colA +-128 +-127 +0 +1 +3 +126 +127 +0 +SELECT * FROM tinytbls WHERE colA < 127.00001; +colA +-128 +-127 +0 +1 +3 +126 +127 +0 +SELECT * FROM tinytbls WHERE colA <= 127.00001; +colA +-128 +-127 +0 +1 +3 +126 +127 +0 +SELECT * FROM tinytbls WHERE colA > 127.00001; +colA +SELECT * FROM tinytbls WHERE colA >= 127.00001; +colA +SELECT * FROM tinytbls WHERE colA = 127.00001; +colA +SELECT * FROM tinytbls WHERE colA <> 127.00001; +colA +-128 +-127 +0 +1 +3 +126 +127 +0 +SELECT * FROM tinytbls WHERE colA < 126.99999; +colA +-128 +-127 +0 +1 +3 +126 +0 +SELECT * FROM tinytbls WHERE colA <= 126.99999; +colA +-128 +-127 +0 +1 +3 +126 +0 +SELECT * FROM tinytbls WHERE colA > 126.99999; +colA +127 +SELECT * FROM tinytbls WHERE colA >= 126.99999; +colA +127 +SELECT * FROM tinytbls WHERE colA = 126.99999; +colA +SELECT * FROM tinytbls WHERE colA <> 126.99999; +colA +-128 +-127 +0 +1 +3 +126 +127 +0 +SELECT * FROM tinytbls WHERE colA < -127.99999; +colA +-128 +SELECT * FROM tinytbls WHERE colA <= -127.99999; +colA +-128 +SELECT * FROM tinytbls WHERE colA > -127.99999; +colA +-127 +0 +1 +3 +126 +127 +0 +SELECT * FROM tinytbls WHERE colA >= -127.99999; +colA +-127 +0 +1 +3 +126 +127 +0 +SELECT * FROM tinytbls WHERE colA = -127.99999; +colA +SELECT * FROM tinytbls WHERE colA <> -127.99999; +colA +-128 +-127 +0 +1 +3 +126 +127 +0 +SELECT * FROM tinytbls WHERE colA < -128.00001; +colA +SELECT * FROM tinytbls WHERE colA <= -128.00001; +colA +SELECT * FROM tinytbls WHERE colA > -128.00001; +colA +-128 +-127 +0 +1 +3 +126 +127 +0 +SELECT * FROM tinytbls WHERE colA >= -128.00001; +colA +-128 +-127 +0 +1 +3 +126 +127 +0 +SELECT * FROM tinytbls WHERE colA = -128.00001; +colA +SELECT * FROM tinytbls WHERE colA <> -128.00001; +colA +-128 +-127 +0 +1 +3 +126 +127 +0 +SELECT * FROM tinytbls WHERE colA < 18446744073709551615.00000001; +colA +-128 +-127 +0 +1 +3 +126 +127 +0 +SELECT * FROM tinytbls WHERE colA <= 18446744073709551615.00000001; +colA +-128 +-127 +0 +1 +3 +126 +127 +0 +SELECT * FROM tinytbls WHERE colA > 18446744073709551615.00000001; +colA +SELECT * FROM tinytbls WHERE colA >= 18446744073709551615.00000001; +colA +SELECT * FROM tinytbls WHERE colA = 18446744073709551615.00000001; +colA +SELECT * FROM tinytbls WHERE colA <> 18446744073709551615.00000001; +colA +-128 +-127 +0 +1 +3 +126 +127 +0 +SELECT * FROM tinytbls WHERE colA < -9223372036854775808.00000001; +colA +SELECT * FROM tinytbls WHERE colA <= -9223372036854775808.00000001; +colA +SELECT * FROM tinytbls WHERE colA > -9223372036854775808.00000001; +colA +-128 +-127 +0 +1 +3 +126 +127 +0 +SELECT * FROM tinytbls WHERE colA >= -9223372036854775808.00000001; +colA +-128 +-127 +0 +1 +3 +126 +127 +0 +SELECT * FROM tinytbls WHERE colA = -9223372036854775808.00000001; +colA +SELECT * FROM tinytbls WHERE colA <> -9223372036854775808.00000001; +colA +-128 +-127 +0 +1 +3 +126 +127 +0 +PREPARE p_less FROM 'SELECT * FROM tinytbls WHERE colA < ?'; +PREPARE p_less_eq FROM 'SELECT * FROM tinytbls WHERE colA <= ?'; +PREPARE p_greater FROM 'SELECT * FROM tinytbls WHERE colA > ?'; +PREPARE p_gret_eq FROM 'SELECT * FROM tinytbls WHERE colA >= ?'; +PREPARE p_equal FROM 'SELECT * FROM tinytbls WHERE colA = ?'; +PREPARE p_n_equal FROM 'SELECT * FROM tinytbls WHERE colA <> ?'; +SET @dec_0_5=0.5; +SET @dec_minus_0_5=-0.5; +SET @dec_max_plus_delta=127.00001; +SET @dec_max_minus_delta=126.99999; +SET @dec_min_plus_delta=-127.99999; +SET @dec_min_minus_delta=-128.00001; +SET @dec_too_big_positive_for_any_int=18446744073709551615.00000001; +SET @dec_too_big_negative_for_any_int=-9223372036854775808.00000001; +EXECUTE p_less USING @dec_0_5; +colA +-128 +-127 +0 +0 +EXECUTE p_less_eq USING @dec_0_5; +colA +-128 +-127 +0 +0 +EXECUTE p_greater USING @dec_0_5; +colA +1 +3 +126 +127 +EXECUTE p_gret_eq USING @dec_0_5; +colA +1 +3 +126 +127 +EXECUTE p_equal USING @dec_0_5; +colA +EXECUTE p_n_equal USING @dec_0_5; +colA +-128 +-127 +0 +1 +3 +126 +127 +0 +EXECUTE p_less USING @dec_minus_0_5; +colA +-128 +-127 +EXECUTE p_less_eq USING @dec_minus_0_5; +colA +-128 +-127 +EXECUTE p_greater USING @dec_minus_0_5; +colA +0 +1 +3 +126 +127 +0 +EXECUTE p_gret_eq USING @dec_minus_0_5; +colA +0 +1 +3 +126 +127 +0 +EXECUTE p_equal USING @dec_minus_0_5; +colA +EXECUTE p_n_equal USING @dec_minus_0_5; +colA +-128 +-127 +0 +1 +3 +126 +127 +0 +EXECUTE p_less USING @dec_max_plus_delta; +colA +-128 +-127 +0 +1 +3 +126 +127 +0 +EXECUTE p_less_eq USING @dec_max_plus_delta; +colA +-128 +-127 +0 +1 +3 +126 +127 +0 +EXECUTE p_greater USING @dec_max_plus_delta; +colA +EXECUTE p_gret_eq USING @dec_max_plus_delta; +colA +EXECUTE p_equal USING @dec_max_plus_delta; +colA +EXECUTE p_n_equal USING @dec_max_plus_delta; +colA +-128 +-127 +0 +1 +3 +126 +127 +0 +EXECUTE p_less USING @dec_max_minus_delta; +colA +-128 +-127 +0 +1 +3 +126 +0 +EXECUTE p_less_eq USING @dec_max_minus_delta; +colA +-128 +-127 +0 +1 +3 +126 +0 +EXECUTE p_greater USING @dec_max_minus_delta; +colA +127 +EXECUTE p_gret_eq USING @dec_max_minus_delta; +colA +127 +EXECUTE p_equal USING @dec_max_minus_delta; +colA +EXECUTE p_n_equal USING @dec_max_minus_delta; +colA +-128 +-127 +0 +1 +3 +126 +127 +0 +EXECUTE p_less USING @dec_min_plus_delta; +colA +-128 +EXECUTE p_less_eq USING @dec_min_plus_delta; +colA +-128 +EXECUTE p_greater USING @dec_min_plus_delta; +colA +-127 +0 +1 +3 +126 +127 +0 +EXECUTE p_gret_eq USING @dec_min_plus_delta; +colA +-127 +0 +1 +3 +126 +127 +0 +EXECUTE p_equal USING @dec_min_plus_delta; +colA +EXECUTE p_n_equal USING @dec_min_plus_delta; +colA +-128 +-127 +0 +1 +3 +126 +127 +0 +EXECUTE p_less USING @dec_min_minus_delta; +colA +EXECUTE p_less_eq USING @dec_min_minus_delta; +colA +EXECUTE p_greater USING @dec_min_minus_delta; +colA +-128 +-127 +0 +1 +3 +126 +127 +0 +EXECUTE p_gret_eq USING @dec_min_minus_delta; +colA +-128 +-127 +0 +1 +3 +126 +127 +0 +EXECUTE p_equal USING @dec_min_minus_delta; +colA +EXECUTE p_n_equal USING @dec_min_minus_delta; +colA +-128 +-127 +0 +1 +3 +126 +127 +0 +EXECUTE p_less USING @dec_too_big_positive_for_any_int; +colA +-128 +-127 +0 +1 +3 +126 +127 +0 +EXECUTE p_less_eq USING @dec_too_big_positive_for_any_int; +colA +-128 +-127 +0 +1 +3 +126 +127 +0 +EXECUTE p_greater USING @dec_too_big_positive_for_any_int; +colA +EXECUTE p_gret_eq USING @dec_too_big_positive_for_any_int; +colA +EXECUTE p_equal USING @dec_too_big_positive_for_any_int; +colA +EXECUTE p_n_equal USING @dec_too_big_positive_for_any_int; +colA +-128 +-127 +0 +1 +3 +126 +127 +0 +EXECUTE p_less USING @dec_too_big_negative_for_any_int; +colA +EXECUTE p_less_eq USING @dec_too_big_negative_for_any_int; +colA +EXECUTE p_greater USING @dec_too_big_negative_for_any_int; +colA +-128 +-127 +0 +1 +3 +126 +127 +0 +EXECUTE p_gret_eq USING @dec_too_big_negative_for_any_int; +colA +-128 +-127 +0 +1 +3 +126 +127 +0 +EXECUTE p_equal USING @dec_too_big_negative_for_any_int; +colA +EXECUTE p_n_equal USING @dec_too_big_negative_for_any_int; +colA +-128 +-127 +0 +1 +3 +126 +127 +0 +DROP PREPARE p_less; +DROP PREPARE p_less_eq; +DROP PREPARE p_greater; +DROP PREPARE p_gret_eq; +DROP PREPARE p_equal; +DROP PREPARE p_n_equal; +DROP TABLE tinytbls; +Cruft inside string +CREATE TABLE t(i INT); +INSERT INTO t VALUES (-1), (0), (1); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +SELECT * FROM t WHERE i > 'A'; +i +1 +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'A' +EXPLAIN SELECT * FROM t WHERE i > 'A'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'A' +Note 1003 /* select#1 */ select `test`.`t`.`i` AS `i` from `test`.`t` where (`test`.`t`.`i` > 0) +DROP TABLE t; +Detect decimal inside a string when compared to int +Used to return one row; should be none. +CREATE TABLE t(i BIGINT); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +INSERT INTO t VALUES (1), (2); +SELECT * FROM t WHERE i = '1.1'; +i +EXPLAIN SELECT * FROM t WHERE i = '1.1'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`i` AS `i` from `test`.`t` where false +DROP TABLE t; +Detect out of range real inside a string when compared to int +Used to return one row; should be none. +CREATE TABLE t(i TINYINT); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +INSERT INTO t VALUES (1), (2); +SELECT * FROM t WHERE i > '1E10'; +i +EXPLAIN SELECT * FROM t WHERE i > '1E10'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`i` AS `i` from `test`.`t` where false +DROP TABLE t; +Detect out of range real inside a string when compared to int +Used to return one row; should be none. +CREATE TABLE t(i TINYINT); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +INSERT INTO t VALUES (0); +SELECT * FROM t WHERE i = '1E-308'; +i +EXPLAIN SELECT * FROM t WHERE i = '1E-308'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`i` AS `i` from `test`.`t` where false +Above query should yield the same as this: +SELECT * FROM t WHERE i = 1E-308; +i +EXPLAIN SELECT * FROM t WHERE i = 1E-308; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`i` AS `i` from `test`.`t` where false +DROP TABLE t; +# +# Tests with UNSIGNED type SMALLINT against int +# +CREATE TABLE smalltbl (colA SMALLINT UNSIGNED ); +INSERT INTO smalltbl VALUES (0), (1), +(0),(1),(3), +(65534), (65535), +(NULL); +ANALYZE TABLE smalltbl; +Table Op Msg_type Msg_text +test.smalltbl analyze status OK +SELECT * FROM smalltbl; +colA +0 +1 +0 +1 +3 +65534 +65535 +NULL +SELECT * FROM smalltbl WHERE colA < 65536; +colA +0 +1 +0 +1 +3 +65534 +65535 +SELECT * FROM smalltbl WHERE colA <= 65535; +colA +0 +1 +0 +1 +3 +65534 +65535 +SELECT * FROM smalltbl WHERE colA > 65536; +colA +SELECT * FROM smalltbl WHERE colA >= 65535; +colA +65535 +SELECT * FROM smalltbl WHERE colA > -1; +colA +0 +1 +0 +1 +3 +65534 +65535 +SELECT * FROM smalltbl WHERE colA <= -1; +colA +SELECT * FROM smalltbl WHERE colA <= 0; +colA +0 +0 +SELECT * FROM smalltbl WHERE colA >= 0; +colA +0 +1 +0 +1 +3 +65534 +65535 +SELECT * FROM smalltbl WHERE colA > 0; +colA +1 +1 +3 +65534 +65535 +SELECT * FROM smalltbl WHERE colA = 65536; +colA +SELECT * FROM smalltbl WHERE colA <> 65536; +colA +0 +1 +0 +1 +3 +65534 +65535 +SELECT * FROM smalltbl WHERE colA = 65535; +colA +65535 +SELECT * FROM smalltbl WHERE colA <=> 65535; +colA +65535 +SELECT * FROM smalltbl WHERE NOT(colA <=> 65535); +colA +0 +1 +0 +1 +3 +65534 +NULL +SELECT * FROM smalltbl WHERE colA <> 65535; +colA +0 +1 +0 +1 +3 +65534 +SELECT * FROM smalltbl WHERE colA = 0; +colA +0 +0 +SELECT * FROM smalltbl WHERE colA <=> 0; +colA +0 +0 +SELECT * FROM smalltbl WHERE NOT(colA <=> 0); +colA +1 +1 +3 +65534 +65535 +NULL +SELECT * FROM smalltbl WHERE colA <> 0; +colA +1 +1 +3 +65534 +65535 +SELECT * FROM smalltbl WHERE colA = -1; +colA +SELECT * FROM smalltbl WHERE colA <=> -1; +colA +SELECT * FROM smalltbl WHERE NOT(colA <=> -1); +colA +0 +1 +0 +1 +3 +65534 +65535 +NULL +SELECT * FROM smalltbl WHERE colA <> -1; +colA +0 +1 +0 +1 +3 +65534 +65535 +PREPARE p_less FROM 'SELECT * FROM smalltbl WHERE colA < ?'; +PREPARE p_less_eq FROM 'SELECT * FROM smalltbl WHERE colA <= ?'; +PREPARE p_greater FROM 'SELECT * FROM smalltbl WHERE colA > ?'; +PREPARE p_gret_eq FROM 'SELECT * FROM smalltbl WHERE colA >= ?'; +PREPARE p_eq FROM 'SELECT * FROM smalltbl WHERE colA = ?'; +PREPARE p_equal FROM 'SELECT * FROM smalltbl WHERE colA <=> ?'; +PREPARE p_n_equal FROM 'SELECT * FROM smalltbl WHERE NOT(colA <=> ?)'; +PREPARE p_n_eq FROM 'SELECT * FROM smalltbl WHERE colA <> ?'; +SET @maxint_plus_1=65536; +SET @maxint=65535; +SET @minint_minus_1=-1; +SET @minint=0; +EXECUTE p_less USING @maxint_plus_1; +colA +0 +1 +0 +1 +3 +65534 +65535 +EXECUTE p_less_eq USING @maxint; +colA +0 +1 +0 +1 +3 +65534 +65535 +EXECUTE p_greater USING @maxint_plus_1; +colA +EXECUTE p_gret_eq USING @maxint; +colA +65535 +EXECUTE p_greater USING @minint_minus_1; +colA +0 +1 +0 +1 +3 +65534 +65535 +EXECUTE p_less_eq USING @minint_minus_1; +colA +EXECUTE p_less_eq USING @minint; +colA +0 +0 +EXECUTE p_gret_eq USING @minint; +colA +0 +1 +0 +1 +3 +65534 +65535 +EXECUTE p_greater USING @minint; +colA +1 +1 +3 +65534 +65535 +EXECUTE p_eq USING @maxint_plus_1; +colA +EXECUTE p_equal USING @maxint_plus_1; +colA +EXECUTE p_n_eq USING @maxint_plus_1; +colA +0 +1 +0 +1 +3 +65534 +65535 +EXECUTE p_n_equal USING @maxint_plus_1; +colA +0 +1 +0 +1 +3 +65534 +65535 +NULL +EXECUTE p_eq USING @maxint; +colA +65535 +EXECUTE p_equal USING @maxint; +colA +65535 +EXECUTE p_n_eq USING @maxint; +colA +0 +1 +0 +1 +3 +65534 +EXECUTE p_n_equal USING @maxint; +colA +0 +1 +0 +1 +3 +65534 +NULL +EXECUTE p_eq USING @minint; +colA +0 +0 +EXECUTE p_equal USING @minint; +colA +0 +0 +EXECUTE p_n_eq USING @minint; +colA +1 +1 +3 +65534 +65535 +EXECUTE p_n_equal USING @minint; +colA +1 +1 +3 +65534 +65535 +NULL +EXECUTE p_eq USING @minint_minus_1; +colA +EXECUTE p_equal USING @minint_minus_1; +colA +EXECUTE p_n_eq USING @minint_minus_1; +colA +0 +1 +0 +1 +3 +65534 +65535 +EXECUTE p_n_equal USING @minint_minus_1; +colA +0 +1 +0 +1 +3 +65534 +65535 +NULL +DROP PREPARE p_less; +DROP PREPARE p_less_eq; +DROP PREPARE p_greater; +DROP PREPARE p_gret_eq; +DROP PREPARE p_equal; +DROP PREPARE p_n_eq; +DROP PREPARE p_n_equal; +EXPLAIN SELECT * FROM smalltbl WHERE colA < 65536; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE smalltbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbl`.`colA` AS `colA` from `test`.`smalltbl` where (`test`.`smalltbl`.`colA` is not null) +EXPLAIN SELECT * FROM smalltbl WHERE colA <= 65535; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE smalltbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbl`.`colA` AS `colA` from `test`.`smalltbl` where (`test`.`smalltbl`.`colA` is not null) +EXPLAIN SELECT * FROM smalltbl WHERE colA > 65536; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbl`.`colA` AS `colA` from `test`.`smalltbl` where false +EXPLAIN SELECT * FROM smalltbl WHERE colA >= 65535; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE smalltbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbl`.`colA` AS `colA` from `test`.`smalltbl` where (`test`.`smalltbl`.`colA` = 65535) +EXPLAIN SELECT * FROM smalltbl WHERE colA > -1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE smalltbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbl`.`colA` AS `colA` from `test`.`smalltbl` where (`test`.`smalltbl`.`colA` is not null) +EXPLAIN SELECT * FROM smalltbl WHERE colA <= -1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbl`.`colA` AS `colA` from `test`.`smalltbl` where false +EXPLAIN SELECT * FROM smalltbl WHERE colA <= 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE smalltbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbl`.`colA` AS `colA` from `test`.`smalltbl` where (`test`.`smalltbl`.`colA` = 0) +EXPLAIN SELECT * FROM smalltbl WHERE colA >= 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE smalltbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbl`.`colA` AS `colA` from `test`.`smalltbl` where (`test`.`smalltbl`.`colA` is not null) +EXPLAIN SELECT * FROM smalltbl WHERE colA > 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 33.33 Parallel execute (1 workers) +2 SIMPLE smalltbl NULL ALL NULL NULL NULL NULL 8 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbl`.`colA` AS `colA` from `test`.`smalltbl` where (`test`.`smalltbl`.`colA` > 0) +EXPLAIN SELECT * FROM smalltbl WHERE colA = 65536; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbl`.`colA` AS `colA` from `test`.`smalltbl` where false +EXPLAIN SELECT * FROM smalltbl WHERE colA <=> 65536; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbl`.`colA` AS `colA` from `test`.`smalltbl` where false +EXPLAIN SELECT * FROM smalltbl WHERE colA <> 65536; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE smalltbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbl`.`colA` AS `colA` from `test`.`smalltbl` where (`test`.`smalltbl`.`colA` is not null) +EXPLAIN SELECT * FROM smalltbl WHERE colA = 65535; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE smalltbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbl`.`colA` AS `colA` from `test`.`smalltbl` where (`test`.`smalltbl`.`colA` = 65535) +EXPLAIN SELECT * FROM smalltbl WHERE colA <=> 65535; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE smalltbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbl`.`colA` AS `colA` from `test`.`smalltbl` where (`test`.`smalltbl`.`colA` <=> 65535) +EXPLAIN SELECT * FROM smalltbl WHERE colA <> 65535; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE smalltbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbl`.`colA` AS `colA` from `test`.`smalltbl` where (`test`.`smalltbl`.`colA` <> 65535) +EXPLAIN SELECT * FROM smalltbl WHERE colA = 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE smalltbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbl`.`colA` AS `colA` from `test`.`smalltbl` where (`test`.`smalltbl`.`colA` = 0) +EXPLAIN SELECT * FROM smalltbl WHERE colA <=> 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE smalltbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbl`.`colA` AS `colA` from `test`.`smalltbl` where (`test`.`smalltbl`.`colA` <=> 0) +EXPLAIN SELECT * FROM smalltbl WHERE colA <> 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE smalltbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbl`.`colA` AS `colA` from `test`.`smalltbl` where (`test`.`smalltbl`.`colA` <> 0) +EXPLAIN SELECT * FROM smalltbl WHERE colA = -1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbl`.`colA` AS `colA` from `test`.`smalltbl` where false +EXPLAIN SELECT * FROM smalltbl WHERE colA <=> -1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbl`.`colA` AS `colA` from `test`.`smalltbl` where false +EXPLAIN SELECT * FROM smalltbl WHERE colA <> -1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE smalltbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbl`.`colA` AS `colA` from `test`.`smalltbl` where (`test`.`smalltbl`.`colA` is not null) +same queries but constant first +SELECT * FROM smalltbl WHERE 65536 > colA; +colA +0 +1 +0 +1 +3 +65534 +65535 +SELECT * FROM smalltbl WHERE 65535 >= colA; +colA +0 +1 +0 +1 +3 +65534 +65535 +SELECT * FROM smalltbl WHERE 65536 < colA; +colA +SELECT * FROM smalltbl WHERE 65535 <= colA; +colA +65535 +SELECT * FROM smalltbl WHERE 65535 < colA; +colA +SELECT * FROM smalltbl WHERE -1 < colA; +colA +0 +1 +0 +1 +3 +65534 +65535 +SELECT * FROM smalltbl WHERE -1 >= colA; +colA +SELECT * FROM smalltbl WHERE 0 >= colA; +colA +0 +0 +SELECT * FROM smalltbl WHERE 0 <= colA; +colA +0 +1 +0 +1 +3 +65534 +65535 +SELECT * FROM smalltbl WHERE 0 < colA; +colA +1 +1 +3 +65534 +65535 +SELECT * FROM smalltbl WHERE 65536 = colA; +colA +SELECT * FROM smalltbl WHERE 65536 <=> colA; +colA +SELECT * FROM smalltbl WHERE 65536 <> colA; +colA +0 +1 +0 +1 +3 +65534 +65535 +SELECT * FROM smalltbl WHERE 65535 = colA; +colA +65535 +SELECT * FROM smalltbl WHERE 65535 <=> colA; +colA +65535 +SELECT * FROM smalltbl WHERE 65535 <> colA; +colA +0 +1 +0 +1 +3 +65534 +SELECT * FROM smalltbl WHERE 0 = colA; +colA +0 +0 +SELECT * FROM smalltbl WHERE 0 <=> colA; +colA +0 +0 +SELECT * FROM smalltbl WHERE 0 <> colA; +colA +1 +1 +3 +65534 +65535 +SELECT * FROM smalltbl WHERE -1 = colA; +colA +SELECT * FROM smalltbl WHERE -1 <=> colA; +colA +SELECT * FROM smalltbl WHERE -1 <> colA; +colA +0 +1 +0 +1 +3 +65534 +65535 +PREPARE p_less FROM 'SELECT * FROM smalltbl WHERE ? < colA'; +PREPARE p_less_eq FROM 'SELECT * FROM smalltbl WHERE ? <= colA'; +PREPARE p_greater FROM 'SELECT * FROM smalltbl WHERE ? > colA'; +PREPARE p_gret_eq FROM 'SELECT * FROM smalltbl WHERE ? >= colA'; +PREPARE p_eq FROM 'SELECT * FROM smalltbl WHERE ? = colA'; +PREPARE p_equal FROM 'SELECT * FROM smalltbl WHERE ? <=> colA'; +PREPARE p_n_eq FROM 'SELECT * FROM smalltbl WHERE ? <> colA'; +PREPARE p_n_equal FROM 'SELECT * FROM smalltbl WHERE NOT(? <=> colA)'; +EXECUTE p_greater USING @maxint_plus_1; +colA +0 +1 +0 +1 +3 +65534 +65535 +EXECUTE p_gret_eq USING @maxint; +colA +0 +1 +0 +1 +3 +65534 +65535 +EXECUTE p_less USING @maxint_plus_1; +colA +EXECUTE p_less_eq USING @maxint; +colA +65535 +EXECUTE p_less USING @minint_minus_1; +colA +0 +1 +0 +1 +3 +65534 +65535 +EXECUTE p_gret_eq USING @minint_minus_1; +colA +EXECUTE p_gret_eq USING @minint; +colA +0 +0 +EXECUTE p_less_eq USING @minint; +colA +0 +1 +0 +1 +3 +65534 +65535 +EXECUTE p_less USING @minint; +colA +1 +1 +3 +65534 +65535 +EXECUTE p_eq USING @maxint_plus_1; +colA +EXECUTE p_equal USING @maxint_plus_1; +colA +EXECUTE p_n_eq USING @maxint_plus_1; +colA +0 +1 +0 +1 +3 +65534 +65535 +EXECUTE p_n_equal USING @maxint_plus_1; +colA +0 +1 +0 +1 +3 +65534 +65535 +NULL +EXECUTE p_eq USING @maxint; +colA +65535 +EXECUTE p_equal USING @maxint; +colA +65535 +EXECUTE p_n_eq USING @maxint; +colA +0 +1 +0 +1 +3 +65534 +EXECUTE p_n_equal USING @maxint; +colA +0 +1 +0 +1 +3 +65534 +NULL +EXECUTE p_eq USING @minint; +colA +0 +0 +EXECUTE p_equal USING @minint; +colA +0 +0 +EXECUTE p_n_eq USING @minint; +colA +1 +1 +3 +65534 +65535 +EXECUTE p_n_equal USING @minint; +colA +1 +1 +3 +65534 +65535 +NULL +EXECUTE p_eq USING @minint_minus_1; +colA +EXECUTE p_equal USING @minint_minus_1; +colA +EXECUTE p_n_eq USING @minint_minus_1; +colA +0 +1 +0 +1 +3 +65534 +65535 +EXECUTE p_n_equal USING @minint_minus_1; +colA +0 +1 +0 +1 +3 +65534 +65535 +NULL +DROP PREPARE p_less; +DROP PREPARE p_less_eq; +DROP PREPARE p_greater; +DROP PREPARE p_gret_eq; +DROP PREPARE p_equal; +DROP PREPARE p_n_eq; +DROP PREPARE p_n_equal; +EXPLAIN SELECT * FROM smalltbl WHERE 65536 > colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE smalltbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbl`.`colA` AS `colA` from `test`.`smalltbl` where (`test`.`smalltbl`.`colA` is not null) +EXPLAIN SELECT * FROM smalltbl WHERE 65535 >= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE smalltbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbl`.`colA` AS `colA` from `test`.`smalltbl` where (`test`.`smalltbl`.`colA` is not null) +EXPLAIN SELECT * FROM smalltbl WHERE 65536 < colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbl`.`colA` AS `colA` from `test`.`smalltbl` where false +EXPLAIN SELECT * FROM smalltbl WHERE 65535 <= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE smalltbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbl`.`colA` AS `colA` from `test`.`smalltbl` where (65535 = `test`.`smalltbl`.`colA`) +EXPLAIN SELECT * FROM smalltbl WHERE 65535 < colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbl`.`colA` AS `colA` from `test`.`smalltbl` where false +EXPLAIN SELECT * FROM smalltbl WHERE -1 < colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE smalltbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbl`.`colA` AS `colA` from `test`.`smalltbl` where (`test`.`smalltbl`.`colA` is not null) +EXPLAIN SELECT * FROM smalltbl WHERE -1 >= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbl`.`colA` AS `colA` from `test`.`smalltbl` where false +EXPLAIN SELECT * FROM smalltbl WHERE 0 >= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE smalltbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbl`.`colA` AS `colA` from `test`.`smalltbl` where (0 = `test`.`smalltbl`.`colA`) +EXPLAIN SELECT * FROM smalltbl WHERE 0 <= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE smalltbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbl`.`colA` AS `colA` from `test`.`smalltbl` where (`test`.`smalltbl`.`colA` is not null) +EXPLAIN SELECT * FROM smalltbl WHERE 0 < colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 33.33 Parallel execute (1 workers) +2 SIMPLE smalltbl NULL ALL NULL NULL NULL NULL 8 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbl`.`colA` AS `colA` from `test`.`smalltbl` where (0 < `test`.`smalltbl`.`colA`) +EXPLAIN SELECT * FROM smalltbl WHERE 65536 = colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbl`.`colA` AS `colA` from `test`.`smalltbl` where false +EXPLAIN SELECT * FROM smalltbl WHERE 65536 <=> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbl`.`colA` AS `colA` from `test`.`smalltbl` where false +EXPLAIN SELECT * FROM smalltbl WHERE 65536 <> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE smalltbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbl`.`colA` AS `colA` from `test`.`smalltbl` where (`test`.`smalltbl`.`colA` is not null) +EXPLAIN SELECT * FROM smalltbl WHERE 65535 = colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE smalltbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbl`.`colA` AS `colA` from `test`.`smalltbl` where (`test`.`smalltbl`.`colA` = 65535) +EXPLAIN SELECT * FROM smalltbl WHERE 65535 <=> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE smalltbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbl`.`colA` AS `colA` from `test`.`smalltbl` where (65535 <=> `test`.`smalltbl`.`colA`) +EXPLAIN SELECT * FROM smalltbl WHERE 65535 <> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE smalltbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbl`.`colA` AS `colA` from `test`.`smalltbl` where (65535 <> `test`.`smalltbl`.`colA`) +EXPLAIN SELECT * FROM smalltbl WHERE 0 = colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE smalltbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbl`.`colA` AS `colA` from `test`.`smalltbl` where (`test`.`smalltbl`.`colA` = 0) +EXPLAIN SELECT * FROM smalltbl WHERE 0 <=> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE smalltbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbl`.`colA` AS `colA` from `test`.`smalltbl` where (0 <=> `test`.`smalltbl`.`colA`) +EXPLAIN SELECT * FROM smalltbl WHERE 0 <> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE smalltbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbl`.`colA` AS `colA` from `test`.`smalltbl` where (0 <> `test`.`smalltbl`.`colA`) +EXPLAIN SELECT * FROM smalltbl WHERE -1 = colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbl`.`colA` AS `colA` from `test`.`smalltbl` where false +EXPLAIN SELECT * FROM smalltbl WHERE -1 <=> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbl`.`colA` AS `colA` from `test`.`smalltbl` where false +EXPLAIN SELECT * FROM smalltbl WHERE -1 <> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE smalltbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbl`.`colA` AS `colA` from `test`.`smalltbl` where (`test`.`smalltbl`.`colA` is not null) +DROP TABLE smalltbl; +# +# Tests with UNSIGNED type SMALLINT against decimal +# +CREATE TABLE smalltbl (colA SMALLINT UNSIGNED ); +INSERT INTO smalltbl VALUES (0), (1), +(0),(1),(3), +(65534), (65535), +(NULL); +ANALYZE TABLE smalltbl; +Table Op Msg_type Msg_text +test.smalltbl analyze status OK +SELECT * FROM smalltbl; +colA +0 +1 +0 +1 +3 +65534 +65535 +NULL +SELECT * FROM smalltbl WHERE colA < 0.5; +colA +0 +0 +SELECT * FROM smalltbl WHERE colA <= 0.5; +colA +0 +0 +SELECT * FROM smalltbl WHERE colA > 0.5; +colA +1 +1 +3 +65534 +65535 +SELECT * FROM smalltbl WHERE colA >= 0.5; +colA +1 +1 +3 +65534 +65535 +SELECT * FROM smalltbl WHERE colA = 0.5; +colA +SELECT * FROM smalltbl WHERE colA <> 0.5; +colA +0 +1 +0 +1 +3 +65534 +65535 +SELECT * FROM smalltbl WHERE colA < -0.5; +colA +SELECT * FROM smalltbl WHERE colA <= -0.5; +colA +SELECT * FROM smalltbl WHERE colA > -0.5; +colA +0 +1 +0 +1 +3 +65534 +65535 +SELECT * FROM smalltbl WHERE colA >= -0.5; +colA +0 +1 +0 +1 +3 +65534 +65535 +SELECT * FROM smalltbl WHERE colA = -0.5; +colA +SELECT * FROM smalltbl WHERE colA <> -0.5; +colA +0 +1 +0 +1 +3 +65534 +65535 +SELECT * FROM smalltbl WHERE colA < 65535.00001; +colA +0 +1 +0 +1 +3 +65534 +65535 +SELECT * FROM smalltbl WHERE colA <= 65535.00001; +colA +0 +1 +0 +1 +3 +65534 +65535 +SELECT * FROM smalltbl WHERE colA > 65535.00001; +colA +SELECT * FROM smalltbl WHERE colA >= 65535.00001; +colA +SELECT * FROM smalltbl WHERE colA = 65535.00001; +colA +SELECT * FROM smalltbl WHERE colA <> 65535.00001; +colA +0 +1 +0 +1 +3 +65534 +65535 +SELECT * FROM smalltbl WHERE colA < 65534.99999; +colA +0 +1 +0 +1 +3 +65534 +SELECT * FROM smalltbl WHERE colA <= 65534.99999; +colA +0 +1 +0 +1 +3 +65534 +SELECT * FROM smalltbl WHERE colA > 65534.99999; +colA +65535 +SELECT * FROM smalltbl WHERE colA >= 65534.99999; +colA +65535 +SELECT * FROM smalltbl WHERE colA = 65534.99999; +colA +SELECT * FROM smalltbl WHERE colA <> 65534.99999; +colA +0 +1 +0 +1 +3 +65534 +65535 +SELECT * FROM smalltbl WHERE colA < 0.00001; +colA +0 +0 +SELECT * FROM smalltbl WHERE colA <= 0.00001; +colA +0 +0 +SELECT * FROM smalltbl WHERE colA > 0.00001; +colA +1 +1 +3 +65534 +65535 +SELECT * FROM smalltbl WHERE colA >= 0.00001; +colA +1 +1 +3 +65534 +65535 +SELECT * FROM smalltbl WHERE colA = 0.00001; +colA +SELECT * FROM smalltbl WHERE colA <> 0.00001; +colA +0 +1 +0 +1 +3 +65534 +65535 +SELECT * FROM smalltbl WHERE colA < -0.99999; +colA +SELECT * FROM smalltbl WHERE colA <= -0.99999; +colA +SELECT * FROM smalltbl WHERE colA > -0.99999; +colA +0 +1 +0 +1 +3 +65534 +65535 +SELECT * FROM smalltbl WHERE colA >= -0.99999; +colA +0 +1 +0 +1 +3 +65534 +65535 +SELECT * FROM smalltbl WHERE colA = -0.99999; +colA +SELECT * FROM smalltbl WHERE colA <> -0.99999; +colA +0 +1 +0 +1 +3 +65534 +65535 +SELECT * FROM smalltbl WHERE colA < 18446744073709551615.00000001; +colA +0 +1 +0 +1 +3 +65534 +65535 +SELECT * FROM smalltbl WHERE colA <= 18446744073709551615.00000001; +colA +0 +1 +0 +1 +3 +65534 +65535 +SELECT * FROM smalltbl WHERE colA > 18446744073709551615.00000001; +colA +SELECT * FROM smalltbl WHERE colA >= 18446744073709551615.00000001; +colA +SELECT * FROM smalltbl WHERE colA = 18446744073709551615.00000001; +colA +SELECT * FROM smalltbl WHERE colA <> 18446744073709551615.00000001; +colA +0 +1 +0 +1 +3 +65534 +65535 +SELECT * FROM smalltbl WHERE colA < -9223372036854775808.00000001; +colA +SELECT * FROM smalltbl WHERE colA <= -9223372036854775808.00000001; +colA +SELECT * FROM smalltbl WHERE colA > -9223372036854775808.00000001; +colA +0 +1 +0 +1 +3 +65534 +65535 +SELECT * FROM smalltbl WHERE colA >= -9223372036854775808.00000001; +colA +0 +1 +0 +1 +3 +65534 +65535 +SELECT * FROM smalltbl WHERE colA = -9223372036854775808.00000001; +colA +SELECT * FROM smalltbl WHERE colA <> -9223372036854775808.00000001; +colA +0 +1 +0 +1 +3 +65534 +65535 +PREPARE p_less FROM 'SELECT * FROM smalltbl WHERE colA < ?'; +PREPARE p_less_eq FROM 'SELECT * FROM smalltbl WHERE colA <= ?'; +PREPARE p_greater FROM 'SELECT * FROM smalltbl WHERE colA > ?'; +PREPARE p_gret_eq FROM 'SELECT * FROM smalltbl WHERE colA >= ?'; +PREPARE p_equal FROM 'SELECT * FROM smalltbl WHERE colA = ?'; +PREPARE p_n_equal FROM 'SELECT * FROM smalltbl WHERE colA <> ?'; +SET @dec_0_5=0.5; +SET @dec_minus_0_5=-0.5; +SET @dec_max_plus_delta=65535.00001; +SET @dec_max_minus_delta=65534.99999; +SET @dec_min_plus_delta=0.00001; +SET @dec_min_minus_delta=-0.99999; +SET @dec_too_big_positive_for_any_int=18446744073709551615.00000001; +SET @dec_too_big_negative_for_any_int=-9223372036854775808.00000001; +EXECUTE p_less USING @dec_0_5; +colA +0 +0 +EXECUTE p_less_eq USING @dec_0_5; +colA +0 +0 +EXECUTE p_greater USING @dec_0_5; +colA +1 +1 +3 +65534 +65535 +EXECUTE p_gret_eq USING @dec_0_5; +colA +1 +1 +3 +65534 +65535 +EXECUTE p_equal USING @dec_0_5; +colA +EXECUTE p_n_equal USING @dec_0_5; +colA +0 +1 +0 +1 +3 +65534 +65535 +EXECUTE p_less USING @dec_minus_0_5; +colA +EXECUTE p_less_eq USING @dec_minus_0_5; +colA +EXECUTE p_greater USING @dec_minus_0_5; +colA +0 +1 +0 +1 +3 +65534 +65535 +EXECUTE p_gret_eq USING @dec_minus_0_5; +colA +0 +1 +0 +1 +3 +65534 +65535 +EXECUTE p_equal USING @dec_minus_0_5; +colA +EXECUTE p_n_equal USING @dec_minus_0_5; +colA +0 +1 +0 +1 +3 +65534 +65535 +EXECUTE p_less USING @dec_max_plus_delta; +colA +0 +1 +0 +1 +3 +65534 +65535 +EXECUTE p_less_eq USING @dec_max_plus_delta; +colA +0 +1 +0 +1 +3 +65534 +65535 +EXECUTE p_greater USING @dec_max_plus_delta; +colA +EXECUTE p_gret_eq USING @dec_max_plus_delta; +colA +EXECUTE p_equal USING @dec_max_plus_delta; +colA +EXECUTE p_n_equal USING @dec_max_plus_delta; +colA +0 +1 +0 +1 +3 +65534 +65535 +EXECUTE p_less USING @dec_max_minus_delta; +colA +0 +1 +0 +1 +3 +65534 +EXECUTE p_less_eq USING @dec_max_minus_delta; +colA +0 +1 +0 +1 +3 +65534 +EXECUTE p_greater USING @dec_max_minus_delta; +colA +65535 +EXECUTE p_gret_eq USING @dec_max_minus_delta; +colA +65535 +EXECUTE p_equal USING @dec_max_minus_delta; +colA +EXECUTE p_n_equal USING @dec_max_minus_delta; +colA +0 +1 +0 +1 +3 +65534 +65535 +EXECUTE p_less USING @dec_min_plus_delta; +colA +0 +0 +EXECUTE p_less_eq USING @dec_min_plus_delta; +colA +0 +0 +EXECUTE p_greater USING @dec_min_plus_delta; +colA +1 +1 +3 +65534 +65535 +EXECUTE p_gret_eq USING @dec_min_plus_delta; +colA +1 +1 +3 +65534 +65535 +EXECUTE p_equal USING @dec_min_plus_delta; +colA +EXECUTE p_n_equal USING @dec_min_plus_delta; +colA +0 +1 +0 +1 +3 +65534 +65535 +EXECUTE p_less USING @dec_min_minus_delta; +colA +EXECUTE p_less_eq USING @dec_min_minus_delta; +colA +EXECUTE p_greater USING @dec_min_minus_delta; +colA +0 +1 +0 +1 +3 +65534 +65535 +EXECUTE p_gret_eq USING @dec_min_minus_delta; +colA +0 +1 +0 +1 +3 +65534 +65535 +EXECUTE p_equal USING @dec_min_minus_delta; +colA +EXECUTE p_n_equal USING @dec_min_minus_delta; +colA +0 +1 +0 +1 +3 +65534 +65535 +EXECUTE p_less USING @dec_too_big_positive_for_any_int; +colA +0 +1 +0 +1 +3 +65534 +65535 +EXECUTE p_less_eq USING @dec_too_big_positive_for_any_int; +colA +0 +1 +0 +1 +3 +65534 +65535 +EXECUTE p_greater USING @dec_too_big_positive_for_any_int; +colA +EXECUTE p_gret_eq USING @dec_too_big_positive_for_any_int; +colA +EXECUTE p_equal USING @dec_too_big_positive_for_any_int; +colA +EXECUTE p_n_equal USING @dec_too_big_positive_for_any_int; +colA +0 +1 +0 +1 +3 +65534 +65535 +EXECUTE p_less USING @dec_too_big_negative_for_any_int; +colA +EXECUTE p_less_eq USING @dec_too_big_negative_for_any_int; +colA +EXECUTE p_greater USING @dec_too_big_negative_for_any_int; +colA +0 +1 +0 +1 +3 +65534 +65535 +EXECUTE p_gret_eq USING @dec_too_big_negative_for_any_int; +colA +0 +1 +0 +1 +3 +65534 +65535 +EXECUTE p_equal USING @dec_too_big_negative_for_any_int; +colA +EXECUTE p_n_equal USING @dec_too_big_negative_for_any_int; +colA +0 +1 +0 +1 +3 +65534 +65535 +DROP PREPARE p_less; +DROP PREPARE p_less_eq; +DROP PREPARE p_greater; +DROP PREPARE p_gret_eq; +DROP PREPARE p_equal; +DROP PREPARE p_n_equal; +DROP TABLE smalltbl; +Cruft inside string +CREATE TABLE t(i INT); +INSERT INTO t VALUES (-1), (0), (1); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +SELECT * FROM t WHERE i > 'A'; +i +1 +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'A' +EXPLAIN SELECT * FROM t WHERE i > 'A'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'A' +Note 1003 /* select#1 */ select `test`.`t`.`i` AS `i` from `test`.`t` where (`test`.`t`.`i` > 0) +DROP TABLE t; +Detect decimal inside a string when compared to int +Used to return one row; should be none. +CREATE TABLE t(i BIGINT); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +INSERT INTO t VALUES (1), (2); +SELECT * FROM t WHERE i = '1.1'; +i +EXPLAIN SELECT * FROM t WHERE i = '1.1'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`i` AS `i` from `test`.`t` where false +DROP TABLE t; +Detect out of range real inside a string when compared to int +Used to return one row; should be none. +CREATE TABLE t(i TINYINT); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +INSERT INTO t VALUES (1), (2); +SELECT * FROM t WHERE i > '1E10'; +i +EXPLAIN SELECT * FROM t WHERE i > '1E10'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`i` AS `i` from `test`.`t` where false +DROP TABLE t; +Detect out of range real inside a string when compared to int +Used to return one row; should be none. +CREATE TABLE t(i TINYINT); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +INSERT INTO t VALUES (0); +SELECT * FROM t WHERE i = '1E-308'; +i +EXPLAIN SELECT * FROM t WHERE i = '1E-308'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`i` AS `i` from `test`.`t` where false +Above query should yield the same as this: +SELECT * FROM t WHERE i = 1E-308; +i +EXPLAIN SELECT * FROM t WHERE i = 1E-308; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`i` AS `i` from `test`.`t` where false +DROP TABLE t; +# +# Tests with UNSIGNED type SMALLINT NOT NULL against int +# +CREATE TABLE smalltbl (colA SMALLINT UNSIGNED NOT NULL); +INSERT INTO smalltbl VALUES (0), (1), +(0),(1),(3), +(65534), (65535), +(0); +ANALYZE TABLE smalltbl; +Table Op Msg_type Msg_text +test.smalltbl analyze status OK +SELECT * FROM smalltbl; +colA +0 +1 +0 +1 +3 +65534 +65535 +0 +SELECT * FROM smalltbl WHERE colA < 65536; +colA +0 +1 +0 +1 +3 +65534 +65535 +0 +SELECT * FROM smalltbl WHERE colA <= 65535; +colA +0 +1 +0 +1 +3 +65534 +65535 +0 +SELECT * FROM smalltbl WHERE colA > 65536; +colA +SELECT * FROM smalltbl WHERE colA >= 65535; +colA +65535 +SELECT * FROM smalltbl WHERE colA > -1; +colA +0 +1 +0 +1 +3 +65534 +65535 +0 +SELECT * FROM smalltbl WHERE colA <= -1; +colA +SELECT * FROM smalltbl WHERE colA <= 0; +colA +0 +0 +0 +SELECT * FROM smalltbl WHERE colA >= 0; +colA +0 +1 +0 +1 +3 +65534 +65535 +0 +SELECT * FROM smalltbl WHERE colA > 0; +colA +1 +1 +3 +65534 +65535 +SELECT * FROM smalltbl WHERE colA = 65536; +colA +SELECT * FROM smalltbl WHERE colA <> 65536; +colA +0 +1 +0 +1 +3 +65534 +65535 +0 +SELECT * FROM smalltbl WHERE colA = 65535; +colA +65535 +SELECT * FROM smalltbl WHERE colA <=> 65535; +colA +65535 +SELECT * FROM smalltbl WHERE NOT(colA <=> 65535); +colA +0 +1 +0 +1 +3 +65534 +0 +SELECT * FROM smalltbl WHERE colA <> 65535; +colA +0 +1 +0 +1 +3 +65534 +0 +SELECT * FROM smalltbl WHERE colA = 0; +colA +0 +0 +0 +SELECT * FROM smalltbl WHERE colA <=> 0; +colA +0 +0 +0 +SELECT * FROM smalltbl WHERE NOT(colA <=> 0); +colA +1 +1 +3 +65534 +65535 +SELECT * FROM smalltbl WHERE colA <> 0; +colA +1 +1 +3 +65534 +65535 +SELECT * FROM smalltbl WHERE colA = -1; +colA +SELECT * FROM smalltbl WHERE colA <=> -1; +colA +SELECT * FROM smalltbl WHERE NOT(colA <=> -1); +colA +0 +1 +0 +1 +3 +65534 +65535 +0 +SELECT * FROM smalltbl WHERE colA <> -1; +colA +0 +1 +0 +1 +3 +65534 +65535 +0 +PREPARE p_less FROM 'SELECT * FROM smalltbl WHERE colA < ?'; +PREPARE p_less_eq FROM 'SELECT * FROM smalltbl WHERE colA <= ?'; +PREPARE p_greater FROM 'SELECT * FROM smalltbl WHERE colA > ?'; +PREPARE p_gret_eq FROM 'SELECT * FROM smalltbl WHERE colA >= ?'; +PREPARE p_eq FROM 'SELECT * FROM smalltbl WHERE colA = ?'; +PREPARE p_equal FROM 'SELECT * FROM smalltbl WHERE colA <=> ?'; +PREPARE p_n_equal FROM 'SELECT * FROM smalltbl WHERE NOT(colA <=> ?)'; +PREPARE p_n_eq FROM 'SELECT * FROM smalltbl WHERE colA <> ?'; +SET @maxint_plus_1=65536; +SET @maxint=65535; +SET @minint_minus_1=-1; +SET @minint=0; +EXECUTE p_less USING @maxint_plus_1; +colA +0 +1 +0 +1 +3 +65534 +65535 +0 +EXECUTE p_less_eq USING @maxint; +colA +0 +1 +0 +1 +3 +65534 +65535 +0 +EXECUTE p_greater USING @maxint_plus_1; +colA +EXECUTE p_gret_eq USING @maxint; +colA +65535 +EXECUTE p_greater USING @minint_minus_1; +colA +0 +1 +0 +1 +3 +65534 +65535 +0 +EXECUTE p_less_eq USING @minint_minus_1; +colA +EXECUTE p_less_eq USING @minint; +colA +0 +0 +0 +EXECUTE p_gret_eq USING @minint; +colA +0 +1 +0 +1 +3 +65534 +65535 +0 +EXECUTE p_greater USING @minint; +colA +1 +1 +3 +65534 +65535 +EXECUTE p_eq USING @maxint_plus_1; +colA +EXECUTE p_equal USING @maxint_plus_1; +colA +EXECUTE p_n_eq USING @maxint_plus_1; +colA +0 +1 +0 +1 +3 +65534 +65535 +0 +EXECUTE p_n_equal USING @maxint_plus_1; +colA +0 +1 +0 +1 +3 +65534 +65535 +0 +EXECUTE p_eq USING @maxint; +colA +65535 +EXECUTE p_equal USING @maxint; +colA +65535 +EXECUTE p_n_eq USING @maxint; +colA +0 +1 +0 +1 +3 +65534 +0 +EXECUTE p_n_equal USING @maxint; +colA +0 +1 +0 +1 +3 +65534 +0 +EXECUTE p_eq USING @minint; +colA +0 +0 +0 +EXECUTE p_equal USING @minint; +colA +0 +0 +0 +EXECUTE p_n_eq USING @minint; +colA +1 +1 +3 +65534 +65535 +EXECUTE p_n_equal USING @minint; +colA +1 +1 +3 +65534 +65535 +EXECUTE p_eq USING @minint_minus_1; +colA +EXECUTE p_equal USING @minint_minus_1; +colA +EXECUTE p_n_eq USING @minint_minus_1; +colA +0 +1 +0 +1 +3 +65534 +65535 +0 +EXECUTE p_n_equal USING @minint_minus_1; +colA +0 +1 +0 +1 +3 +65534 +65535 +0 +DROP PREPARE p_less; +DROP PREPARE p_less_eq; +DROP PREPARE p_greater; +DROP PREPARE p_gret_eq; +DROP PREPARE p_equal; +DROP PREPARE p_n_eq; +DROP PREPARE p_n_equal; +EXPLAIN SELECT * FROM smalltbl WHERE colA < 65536; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE smalltbl NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbl`.`colA` AS `colA` from `test`.`smalltbl` where true +EXPLAIN SELECT * FROM smalltbl WHERE colA <= 65535; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE smalltbl NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbl`.`colA` AS `colA` from `test`.`smalltbl` where true +EXPLAIN SELECT * FROM smalltbl WHERE colA > 65536; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbl`.`colA` AS `colA` from `test`.`smalltbl` where false +EXPLAIN SELECT * FROM smalltbl WHERE colA >= 65535; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE smalltbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbl`.`colA` AS `colA` from `test`.`smalltbl` where (`test`.`smalltbl`.`colA` = 65535) +EXPLAIN SELECT * FROM smalltbl WHERE colA > -1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE smalltbl NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbl`.`colA` AS `colA` from `test`.`smalltbl` where true +EXPLAIN SELECT * FROM smalltbl WHERE colA <= -1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbl`.`colA` AS `colA` from `test`.`smalltbl` where false +EXPLAIN SELECT * FROM smalltbl WHERE colA <= 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE smalltbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbl`.`colA` AS `colA` from `test`.`smalltbl` where (`test`.`smalltbl`.`colA` = 0) +EXPLAIN SELECT * FROM smalltbl WHERE colA >= 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE smalltbl NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbl`.`colA` AS `colA` from `test`.`smalltbl` where true +EXPLAIN SELECT * FROM smalltbl WHERE colA > 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 33.33 Parallel execute (1 workers) +2 SIMPLE smalltbl NULL ALL NULL NULL NULL NULL 8 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbl`.`colA` AS `colA` from `test`.`smalltbl` where (`test`.`smalltbl`.`colA` > 0) +EXPLAIN SELECT * FROM smalltbl WHERE colA = 65536; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbl`.`colA` AS `colA` from `test`.`smalltbl` where false +EXPLAIN SELECT * FROM smalltbl WHERE colA <=> 65536; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbl`.`colA` AS `colA` from `test`.`smalltbl` where false +EXPLAIN SELECT * FROM smalltbl WHERE colA <> 65536; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE smalltbl NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbl`.`colA` AS `colA` from `test`.`smalltbl` where true +EXPLAIN SELECT * FROM smalltbl WHERE colA = 65535; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE smalltbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbl`.`colA` AS `colA` from `test`.`smalltbl` where (`test`.`smalltbl`.`colA` = 65535) +EXPLAIN SELECT * FROM smalltbl WHERE colA <=> 65535; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE smalltbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbl`.`colA` AS `colA` from `test`.`smalltbl` where (`test`.`smalltbl`.`colA` <=> 65535) +EXPLAIN SELECT * FROM smalltbl WHERE colA <> 65535; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE smalltbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbl`.`colA` AS `colA` from `test`.`smalltbl` where (`test`.`smalltbl`.`colA` <> 65535) +EXPLAIN SELECT * FROM smalltbl WHERE colA = 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE smalltbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbl`.`colA` AS `colA` from `test`.`smalltbl` where (`test`.`smalltbl`.`colA` = 0) +EXPLAIN SELECT * FROM smalltbl WHERE colA <=> 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE smalltbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbl`.`colA` AS `colA` from `test`.`smalltbl` where (`test`.`smalltbl`.`colA` <=> 0) +EXPLAIN SELECT * FROM smalltbl WHERE colA <> 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE smalltbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbl`.`colA` AS `colA` from `test`.`smalltbl` where (`test`.`smalltbl`.`colA` <> 0) +EXPLAIN SELECT * FROM smalltbl WHERE colA = -1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbl`.`colA` AS `colA` from `test`.`smalltbl` where false +EXPLAIN SELECT * FROM smalltbl WHERE colA <=> -1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbl`.`colA` AS `colA` from `test`.`smalltbl` where false +EXPLAIN SELECT * FROM smalltbl WHERE colA <> -1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE smalltbl NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbl`.`colA` AS `colA` from `test`.`smalltbl` where true +same queries but constant first +SELECT * FROM smalltbl WHERE 65536 > colA; +colA +0 +1 +0 +1 +3 +65534 +65535 +0 +SELECT * FROM smalltbl WHERE 65535 >= colA; +colA +0 +1 +0 +1 +3 +65534 +65535 +0 +SELECT * FROM smalltbl WHERE 65536 < colA; +colA +SELECT * FROM smalltbl WHERE 65535 <= colA; +colA +65535 +SELECT * FROM smalltbl WHERE 65535 < colA; +colA +SELECT * FROM smalltbl WHERE -1 < colA; +colA +0 +1 +0 +1 +3 +65534 +65535 +0 +SELECT * FROM smalltbl WHERE -1 >= colA; +colA +SELECT * FROM smalltbl WHERE 0 >= colA; +colA +0 +0 +0 +SELECT * FROM smalltbl WHERE 0 <= colA; +colA +0 +1 +0 +1 +3 +65534 +65535 +0 +SELECT * FROM smalltbl WHERE 0 < colA; +colA +1 +1 +3 +65534 +65535 +SELECT * FROM smalltbl WHERE 65536 = colA; +colA +SELECT * FROM smalltbl WHERE 65536 <=> colA; +colA +SELECT * FROM smalltbl WHERE 65536 <> colA; +colA +0 +1 +0 +1 +3 +65534 +65535 +0 +SELECT * FROM smalltbl WHERE 65535 = colA; +colA +65535 +SELECT * FROM smalltbl WHERE 65535 <=> colA; +colA +65535 +SELECT * FROM smalltbl WHERE 65535 <> colA; +colA +0 +1 +0 +1 +3 +65534 +0 +SELECT * FROM smalltbl WHERE 0 = colA; +colA +0 +0 +0 +SELECT * FROM smalltbl WHERE 0 <=> colA; +colA +0 +0 +0 +SELECT * FROM smalltbl WHERE 0 <> colA; +colA +1 +1 +3 +65534 +65535 +SELECT * FROM smalltbl WHERE -1 = colA; +colA +SELECT * FROM smalltbl WHERE -1 <=> colA; +colA +SELECT * FROM smalltbl WHERE -1 <> colA; +colA +0 +1 +0 +1 +3 +65534 +65535 +0 +PREPARE p_less FROM 'SELECT * FROM smalltbl WHERE ? < colA'; +PREPARE p_less_eq FROM 'SELECT * FROM smalltbl WHERE ? <= colA'; +PREPARE p_greater FROM 'SELECT * FROM smalltbl WHERE ? > colA'; +PREPARE p_gret_eq FROM 'SELECT * FROM smalltbl WHERE ? >= colA'; +PREPARE p_eq FROM 'SELECT * FROM smalltbl WHERE ? = colA'; +PREPARE p_equal FROM 'SELECT * FROM smalltbl WHERE ? <=> colA'; +PREPARE p_n_eq FROM 'SELECT * FROM smalltbl WHERE ? <> colA'; +PREPARE p_n_equal FROM 'SELECT * FROM smalltbl WHERE NOT(? <=> colA)'; +EXECUTE p_greater USING @maxint_plus_1; +colA +0 +1 +0 +1 +3 +65534 +65535 +0 +EXECUTE p_gret_eq USING @maxint; +colA +0 +1 +0 +1 +3 +65534 +65535 +0 +EXECUTE p_less USING @maxint_plus_1; +colA +EXECUTE p_less_eq USING @maxint; +colA +65535 +EXECUTE p_less USING @minint_minus_1; +colA +0 +1 +0 +1 +3 +65534 +65535 +0 +EXECUTE p_gret_eq USING @minint_minus_1; +colA +EXECUTE p_gret_eq USING @minint; +colA +0 +0 +0 +EXECUTE p_less_eq USING @minint; +colA +0 +1 +0 +1 +3 +65534 +65535 +0 +EXECUTE p_less USING @minint; +colA +1 +1 +3 +65534 +65535 +EXECUTE p_eq USING @maxint_plus_1; +colA +EXECUTE p_equal USING @maxint_plus_1; +colA +EXECUTE p_n_eq USING @maxint_plus_1; +colA +0 +1 +0 +1 +3 +65534 +65535 +0 +EXECUTE p_n_equal USING @maxint_plus_1; +colA +0 +1 +0 +1 +3 +65534 +65535 +0 +EXECUTE p_eq USING @maxint; +colA +65535 +EXECUTE p_equal USING @maxint; +colA +65535 +EXECUTE p_n_eq USING @maxint; +colA +0 +1 +0 +1 +3 +65534 +0 +EXECUTE p_n_equal USING @maxint; +colA +0 +1 +0 +1 +3 +65534 +0 +EXECUTE p_eq USING @minint; +colA +0 +0 +0 +EXECUTE p_equal USING @minint; +colA +0 +0 +0 +EXECUTE p_n_eq USING @minint; +colA +1 +1 +3 +65534 +65535 +EXECUTE p_n_equal USING @minint; +colA +1 +1 +3 +65534 +65535 +EXECUTE p_eq USING @minint_minus_1; +colA +EXECUTE p_equal USING @minint_minus_1; +colA +EXECUTE p_n_eq USING @minint_minus_1; +colA +0 +1 +0 +1 +3 +65534 +65535 +0 +EXECUTE p_n_equal USING @minint_minus_1; +colA +0 +1 +0 +1 +3 +65534 +65535 +0 +DROP PREPARE p_less; +DROP PREPARE p_less_eq; +DROP PREPARE p_greater; +DROP PREPARE p_gret_eq; +DROP PREPARE p_equal; +DROP PREPARE p_n_eq; +DROP PREPARE p_n_equal; +EXPLAIN SELECT * FROM smalltbl WHERE 65536 > colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE smalltbl NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbl`.`colA` AS `colA` from `test`.`smalltbl` where true +EXPLAIN SELECT * FROM smalltbl WHERE 65535 >= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE smalltbl NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbl`.`colA` AS `colA` from `test`.`smalltbl` where true +EXPLAIN SELECT * FROM smalltbl WHERE 65536 < colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbl`.`colA` AS `colA` from `test`.`smalltbl` where false +EXPLAIN SELECT * FROM smalltbl WHERE 65535 <= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE smalltbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbl`.`colA` AS `colA` from `test`.`smalltbl` where (65535 = `test`.`smalltbl`.`colA`) +EXPLAIN SELECT * FROM smalltbl WHERE 65535 < colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbl`.`colA` AS `colA` from `test`.`smalltbl` where false +EXPLAIN SELECT * FROM smalltbl WHERE -1 < colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE smalltbl NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbl`.`colA` AS `colA` from `test`.`smalltbl` where true +EXPLAIN SELECT * FROM smalltbl WHERE -1 >= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbl`.`colA` AS `colA` from `test`.`smalltbl` where false +EXPLAIN SELECT * FROM smalltbl WHERE 0 >= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE smalltbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbl`.`colA` AS `colA` from `test`.`smalltbl` where (0 = `test`.`smalltbl`.`colA`) +EXPLAIN SELECT * FROM smalltbl WHERE 0 <= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE smalltbl NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbl`.`colA` AS `colA` from `test`.`smalltbl` where true +EXPLAIN SELECT * FROM smalltbl WHERE 0 < colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 33.33 Parallel execute (1 workers) +2 SIMPLE smalltbl NULL ALL NULL NULL NULL NULL 8 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbl`.`colA` AS `colA` from `test`.`smalltbl` where (0 < `test`.`smalltbl`.`colA`) +EXPLAIN SELECT * FROM smalltbl WHERE 65536 = colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbl`.`colA` AS `colA` from `test`.`smalltbl` where false +EXPLAIN SELECT * FROM smalltbl WHERE 65536 <=> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbl`.`colA` AS `colA` from `test`.`smalltbl` where false +EXPLAIN SELECT * FROM smalltbl WHERE 65536 <> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE smalltbl NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbl`.`colA` AS `colA` from `test`.`smalltbl` where true +EXPLAIN SELECT * FROM smalltbl WHERE 65535 = colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE smalltbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbl`.`colA` AS `colA` from `test`.`smalltbl` where (`test`.`smalltbl`.`colA` = 65535) +EXPLAIN SELECT * FROM smalltbl WHERE 65535 <=> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE smalltbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbl`.`colA` AS `colA` from `test`.`smalltbl` where (65535 <=> `test`.`smalltbl`.`colA`) +EXPLAIN SELECT * FROM smalltbl WHERE 65535 <> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE smalltbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbl`.`colA` AS `colA` from `test`.`smalltbl` where (65535 <> `test`.`smalltbl`.`colA`) +EXPLAIN SELECT * FROM smalltbl WHERE 0 = colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE smalltbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbl`.`colA` AS `colA` from `test`.`smalltbl` where (`test`.`smalltbl`.`colA` = 0) +EXPLAIN SELECT * FROM smalltbl WHERE 0 <=> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE smalltbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbl`.`colA` AS `colA` from `test`.`smalltbl` where (0 <=> `test`.`smalltbl`.`colA`) +EXPLAIN SELECT * FROM smalltbl WHERE 0 <> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE smalltbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbl`.`colA` AS `colA` from `test`.`smalltbl` where (0 <> `test`.`smalltbl`.`colA`) +EXPLAIN SELECT * FROM smalltbl WHERE -1 = colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbl`.`colA` AS `colA` from `test`.`smalltbl` where false +EXPLAIN SELECT * FROM smalltbl WHERE -1 <=> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbl`.`colA` AS `colA` from `test`.`smalltbl` where false +EXPLAIN SELECT * FROM smalltbl WHERE -1 <> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE smalltbl NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbl`.`colA` AS `colA` from `test`.`smalltbl` where true +DROP TABLE smalltbl; +# +# Tests with UNSIGNED type SMALLINT NOT NULL against decimal +# +CREATE TABLE smalltbl (colA SMALLINT UNSIGNED NOT NULL); +INSERT INTO smalltbl VALUES (0), (1), +(0),(1),(3), +(65534), (65535), +(0); +ANALYZE TABLE smalltbl; +Table Op Msg_type Msg_text +test.smalltbl analyze status OK +SELECT * FROM smalltbl; +colA +0 +1 +0 +1 +3 +65534 +65535 +0 +SELECT * FROM smalltbl WHERE colA < 0.5; +colA +0 +0 +0 +SELECT * FROM smalltbl WHERE colA <= 0.5; +colA +0 +0 +0 +SELECT * FROM smalltbl WHERE colA > 0.5; +colA +1 +1 +3 +65534 +65535 +SELECT * FROM smalltbl WHERE colA >= 0.5; +colA +1 +1 +3 +65534 +65535 +SELECT * FROM smalltbl WHERE colA = 0.5; +colA +SELECT * FROM smalltbl WHERE colA <> 0.5; +colA +0 +1 +0 +1 +3 +65534 +65535 +0 +SELECT * FROM smalltbl WHERE colA < -0.5; +colA +SELECT * FROM smalltbl WHERE colA <= -0.5; +colA +SELECT * FROM smalltbl WHERE colA > -0.5; +colA +0 +1 +0 +1 +3 +65534 +65535 +0 +SELECT * FROM smalltbl WHERE colA >= -0.5; +colA +0 +1 +0 +1 +3 +65534 +65535 +0 +SELECT * FROM smalltbl WHERE colA = -0.5; +colA +SELECT * FROM smalltbl WHERE colA <> -0.5; +colA +0 +1 +0 +1 +3 +65534 +65535 +0 +SELECT * FROM smalltbl WHERE colA < 65535.00001; +colA +0 +1 +0 +1 +3 +65534 +65535 +0 +SELECT * FROM smalltbl WHERE colA <= 65535.00001; +colA +0 +1 +0 +1 +3 +65534 +65535 +0 +SELECT * FROM smalltbl WHERE colA > 65535.00001; +colA +SELECT * FROM smalltbl WHERE colA >= 65535.00001; +colA +SELECT * FROM smalltbl WHERE colA = 65535.00001; +colA +SELECT * FROM smalltbl WHERE colA <> 65535.00001; +colA +0 +1 +0 +1 +3 +65534 +65535 +0 +SELECT * FROM smalltbl WHERE colA < 65534.99999; +colA +0 +1 +0 +1 +3 +65534 +0 +SELECT * FROM smalltbl WHERE colA <= 65534.99999; +colA +0 +1 +0 +1 +3 +65534 +0 +SELECT * FROM smalltbl WHERE colA > 65534.99999; +colA +65535 +SELECT * FROM smalltbl WHERE colA >= 65534.99999; +colA +65535 +SELECT * FROM smalltbl WHERE colA = 65534.99999; +colA +SELECT * FROM smalltbl WHERE colA <> 65534.99999; +colA +0 +1 +0 +1 +3 +65534 +65535 +0 +SELECT * FROM smalltbl WHERE colA < 0.00001; +colA +0 +0 +0 +SELECT * FROM smalltbl WHERE colA <= 0.00001; +colA +0 +0 +0 +SELECT * FROM smalltbl WHERE colA > 0.00001; +colA +1 +1 +3 +65534 +65535 +SELECT * FROM smalltbl WHERE colA >= 0.00001; +colA +1 +1 +3 +65534 +65535 +SELECT * FROM smalltbl WHERE colA = 0.00001; +colA +SELECT * FROM smalltbl WHERE colA <> 0.00001; +colA +0 +1 +0 +1 +3 +65534 +65535 +0 +SELECT * FROM smalltbl WHERE colA < -0.99999; +colA +SELECT * FROM smalltbl WHERE colA <= -0.99999; +colA +SELECT * FROM smalltbl WHERE colA > -0.99999; +colA +0 +1 +0 +1 +3 +65534 +65535 +0 +SELECT * FROM smalltbl WHERE colA >= -0.99999; +colA +0 +1 +0 +1 +3 +65534 +65535 +0 +SELECT * FROM smalltbl WHERE colA = -0.99999; +colA +SELECT * FROM smalltbl WHERE colA <> -0.99999; +colA +0 +1 +0 +1 +3 +65534 +65535 +0 +SELECT * FROM smalltbl WHERE colA < 18446744073709551615.00000001; +colA +0 +1 +0 +1 +3 +65534 +65535 +0 +SELECT * FROM smalltbl WHERE colA <= 18446744073709551615.00000001; +colA +0 +1 +0 +1 +3 +65534 +65535 +0 +SELECT * FROM smalltbl WHERE colA > 18446744073709551615.00000001; +colA +SELECT * FROM smalltbl WHERE colA >= 18446744073709551615.00000001; +colA +SELECT * FROM smalltbl WHERE colA = 18446744073709551615.00000001; +colA +SELECT * FROM smalltbl WHERE colA <> 18446744073709551615.00000001; +colA +0 +1 +0 +1 +3 +65534 +65535 +0 +SELECT * FROM smalltbl WHERE colA < -9223372036854775808.00000001; +colA +SELECT * FROM smalltbl WHERE colA <= -9223372036854775808.00000001; +colA +SELECT * FROM smalltbl WHERE colA > -9223372036854775808.00000001; +colA +0 +1 +0 +1 +3 +65534 +65535 +0 +SELECT * FROM smalltbl WHERE colA >= -9223372036854775808.00000001; +colA +0 +1 +0 +1 +3 +65534 +65535 +0 +SELECT * FROM smalltbl WHERE colA = -9223372036854775808.00000001; +colA +SELECT * FROM smalltbl WHERE colA <> -9223372036854775808.00000001; +colA +0 +1 +0 +1 +3 +65534 +65535 +0 +PREPARE p_less FROM 'SELECT * FROM smalltbl WHERE colA < ?'; +PREPARE p_less_eq FROM 'SELECT * FROM smalltbl WHERE colA <= ?'; +PREPARE p_greater FROM 'SELECT * FROM smalltbl WHERE colA > ?'; +PREPARE p_gret_eq FROM 'SELECT * FROM smalltbl WHERE colA >= ?'; +PREPARE p_equal FROM 'SELECT * FROM smalltbl WHERE colA = ?'; +PREPARE p_n_equal FROM 'SELECT * FROM smalltbl WHERE colA <> ?'; +SET @dec_0_5=0.5; +SET @dec_minus_0_5=-0.5; +SET @dec_max_plus_delta=65535.00001; +SET @dec_max_minus_delta=65534.99999; +SET @dec_min_plus_delta=0.00001; +SET @dec_min_minus_delta=-0.99999; +SET @dec_too_big_positive_for_any_int=18446744073709551615.00000001; +SET @dec_too_big_negative_for_any_int=-9223372036854775808.00000001; +EXECUTE p_less USING @dec_0_5; +colA +0 +0 +0 +EXECUTE p_less_eq USING @dec_0_5; +colA +0 +0 +0 +EXECUTE p_greater USING @dec_0_5; +colA +1 +1 +3 +65534 +65535 +EXECUTE p_gret_eq USING @dec_0_5; +colA +1 +1 +3 +65534 +65535 +EXECUTE p_equal USING @dec_0_5; +colA +EXECUTE p_n_equal USING @dec_0_5; +colA +0 +1 +0 +1 +3 +65534 +65535 +0 +EXECUTE p_less USING @dec_minus_0_5; +colA +EXECUTE p_less_eq USING @dec_minus_0_5; +colA +EXECUTE p_greater USING @dec_minus_0_5; +colA +0 +1 +0 +1 +3 +65534 +65535 +0 +EXECUTE p_gret_eq USING @dec_minus_0_5; +colA +0 +1 +0 +1 +3 +65534 +65535 +0 +EXECUTE p_equal USING @dec_minus_0_5; +colA +EXECUTE p_n_equal USING @dec_minus_0_5; +colA +0 +1 +0 +1 +3 +65534 +65535 +0 +EXECUTE p_less USING @dec_max_plus_delta; +colA +0 +1 +0 +1 +3 +65534 +65535 +0 +EXECUTE p_less_eq USING @dec_max_plus_delta; +colA +0 +1 +0 +1 +3 +65534 +65535 +0 +EXECUTE p_greater USING @dec_max_plus_delta; +colA +EXECUTE p_gret_eq USING @dec_max_plus_delta; +colA +EXECUTE p_equal USING @dec_max_plus_delta; +colA +EXECUTE p_n_equal USING @dec_max_plus_delta; +colA +0 +1 +0 +1 +3 +65534 +65535 +0 +EXECUTE p_less USING @dec_max_minus_delta; +colA +0 +1 +0 +1 +3 +65534 +0 +EXECUTE p_less_eq USING @dec_max_minus_delta; +colA +0 +1 +0 +1 +3 +65534 +0 +EXECUTE p_greater USING @dec_max_minus_delta; +colA +65535 +EXECUTE p_gret_eq USING @dec_max_minus_delta; +colA +65535 +EXECUTE p_equal USING @dec_max_minus_delta; +colA +EXECUTE p_n_equal USING @dec_max_minus_delta; +colA +0 +1 +0 +1 +3 +65534 +65535 +0 +EXECUTE p_less USING @dec_min_plus_delta; +colA +0 +0 +0 +EXECUTE p_less_eq USING @dec_min_plus_delta; +colA +0 +0 +0 +EXECUTE p_greater USING @dec_min_plus_delta; +colA +1 +1 +3 +65534 +65535 +EXECUTE p_gret_eq USING @dec_min_plus_delta; +colA +1 +1 +3 +65534 +65535 +EXECUTE p_equal USING @dec_min_plus_delta; +colA +EXECUTE p_n_equal USING @dec_min_plus_delta; +colA +0 +1 +0 +1 +3 +65534 +65535 +0 +EXECUTE p_less USING @dec_min_minus_delta; +colA +EXECUTE p_less_eq USING @dec_min_minus_delta; +colA +EXECUTE p_greater USING @dec_min_minus_delta; +colA +0 +1 +0 +1 +3 +65534 +65535 +0 +EXECUTE p_gret_eq USING @dec_min_minus_delta; +colA +0 +1 +0 +1 +3 +65534 +65535 +0 +EXECUTE p_equal USING @dec_min_minus_delta; +colA +EXECUTE p_n_equal USING @dec_min_minus_delta; +colA +0 +1 +0 +1 +3 +65534 +65535 +0 +EXECUTE p_less USING @dec_too_big_positive_for_any_int; +colA +0 +1 +0 +1 +3 +65534 +65535 +0 +EXECUTE p_less_eq USING @dec_too_big_positive_for_any_int; +colA +0 +1 +0 +1 +3 +65534 +65535 +0 +EXECUTE p_greater USING @dec_too_big_positive_for_any_int; +colA +EXECUTE p_gret_eq USING @dec_too_big_positive_for_any_int; +colA +EXECUTE p_equal USING @dec_too_big_positive_for_any_int; +colA +EXECUTE p_n_equal USING @dec_too_big_positive_for_any_int; +colA +0 +1 +0 +1 +3 +65534 +65535 +0 +EXECUTE p_less USING @dec_too_big_negative_for_any_int; +colA +EXECUTE p_less_eq USING @dec_too_big_negative_for_any_int; +colA +EXECUTE p_greater USING @dec_too_big_negative_for_any_int; +colA +0 +1 +0 +1 +3 +65534 +65535 +0 +EXECUTE p_gret_eq USING @dec_too_big_negative_for_any_int; +colA +0 +1 +0 +1 +3 +65534 +65535 +0 +EXECUTE p_equal USING @dec_too_big_negative_for_any_int; +colA +EXECUTE p_n_equal USING @dec_too_big_negative_for_any_int; +colA +0 +1 +0 +1 +3 +65534 +65535 +0 +DROP PREPARE p_less; +DROP PREPARE p_less_eq; +DROP PREPARE p_greater; +DROP PREPARE p_gret_eq; +DROP PREPARE p_equal; +DROP PREPARE p_n_equal; +DROP TABLE smalltbl; +Cruft inside string +CREATE TABLE t(i INT); +INSERT INTO t VALUES (-1), (0), (1); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +SELECT * FROM t WHERE i > 'A'; +i +1 +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'A' +EXPLAIN SELECT * FROM t WHERE i > 'A'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'A' +Note 1003 /* select#1 */ select `test`.`t`.`i` AS `i` from `test`.`t` where (`test`.`t`.`i` > 0) +DROP TABLE t; +Detect decimal inside a string when compared to int +Used to return one row; should be none. +CREATE TABLE t(i BIGINT); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +INSERT INTO t VALUES (1), (2); +SELECT * FROM t WHERE i = '1.1'; +i +EXPLAIN SELECT * FROM t WHERE i = '1.1'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`i` AS `i` from `test`.`t` where false +DROP TABLE t; +Detect out of range real inside a string when compared to int +Used to return one row; should be none. +CREATE TABLE t(i TINYINT); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +INSERT INTO t VALUES (1), (2); +SELECT * FROM t WHERE i > '1E10'; +i +EXPLAIN SELECT * FROM t WHERE i > '1E10'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`i` AS `i` from `test`.`t` where false +DROP TABLE t; +Detect out of range real inside a string when compared to int +Used to return one row; should be none. +CREATE TABLE t(i TINYINT); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +INSERT INTO t VALUES (0); +SELECT * FROM t WHERE i = '1E-308'; +i +EXPLAIN SELECT * FROM t WHERE i = '1E-308'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`i` AS `i` from `test`.`t` where false +Above query should yield the same as this: +SELECT * FROM t WHERE i = 1E-308; +i +EXPLAIN SELECT * FROM t WHERE i = 1E-308; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`i` AS `i` from `test`.`t` where false +DROP TABLE t; +# +# Tests with type SMALLINT against int +# +CREATE TABLE smalltbls (colA SMALLINT ); +INSERT INTO smalltbls VALUES (-32768), (-32767), +(0),(1),(3), +(32766), (32767), +(NULL); +ANALYZE TABLE smalltbls; +Table Op Msg_type Msg_text +test.smalltbls analyze status OK +SELECT * FROM smalltbls; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +NULL +SELECT * FROM smalltbls WHERE colA < 32768; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +SELECT * FROM smalltbls WHERE colA <= 32767; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +SELECT * FROM smalltbls WHERE colA > 32768; +colA +SELECT * FROM smalltbls WHERE colA >= 32767; +colA +32767 +SELECT * FROM smalltbls WHERE colA > -32769; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +SELECT * FROM smalltbls WHERE colA <= -32769; +colA +SELECT * FROM smalltbls WHERE colA <= -32768; +colA +-32768 +SELECT * FROM smalltbls WHERE colA >= -32768; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +SELECT * FROM smalltbls WHERE colA > -32768; +colA +-32767 +0 +1 +3 +32766 +32767 +SELECT * FROM smalltbls WHERE colA = 32768; +colA +SELECT * FROM smalltbls WHERE colA <> 32768; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +SELECT * FROM smalltbls WHERE colA = 32767; +colA +32767 +SELECT * FROM smalltbls WHERE colA <=> 32767; +colA +32767 +SELECT * FROM smalltbls WHERE NOT(colA <=> 32767); +colA +-32768 +-32767 +0 +1 +3 +32766 +NULL +SELECT * FROM smalltbls WHERE colA <> 32767; +colA +-32768 +-32767 +0 +1 +3 +32766 +SELECT * FROM smalltbls WHERE colA = -32768; +colA +-32768 +SELECT * FROM smalltbls WHERE colA <=> -32768; +colA +-32768 +SELECT * FROM smalltbls WHERE NOT(colA <=> -32768); +colA +-32767 +0 +1 +3 +32766 +32767 +NULL +SELECT * FROM smalltbls WHERE colA <> -32768; +colA +-32767 +0 +1 +3 +32766 +32767 +SELECT * FROM smalltbls WHERE colA = -32769; +colA +SELECT * FROM smalltbls WHERE colA <=> -32769; +colA +SELECT * FROM smalltbls WHERE NOT(colA <=> -32769); +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +NULL +SELECT * FROM smalltbls WHERE colA <> -32769; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +PREPARE p_less FROM 'SELECT * FROM smalltbls WHERE colA < ?'; +PREPARE p_less_eq FROM 'SELECT * FROM smalltbls WHERE colA <= ?'; +PREPARE p_greater FROM 'SELECT * FROM smalltbls WHERE colA > ?'; +PREPARE p_gret_eq FROM 'SELECT * FROM smalltbls WHERE colA >= ?'; +PREPARE p_eq FROM 'SELECT * FROM smalltbls WHERE colA = ?'; +PREPARE p_equal FROM 'SELECT * FROM smalltbls WHERE colA <=> ?'; +PREPARE p_n_equal FROM 'SELECT * FROM smalltbls WHERE NOT(colA <=> ?)'; +PREPARE p_n_eq FROM 'SELECT * FROM smalltbls WHERE colA <> ?'; +SET @maxint_plus_1=32768; +SET @maxint=32767; +SET @minint_minus_1=-32769; +SET @minint=-32768; +EXECUTE p_less USING @maxint_plus_1; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +EXECUTE p_less_eq USING @maxint; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +EXECUTE p_greater USING @maxint_plus_1; +colA +EXECUTE p_gret_eq USING @maxint; +colA +32767 +EXECUTE p_greater USING @minint_minus_1; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +EXECUTE p_less_eq USING @minint_minus_1; +colA +EXECUTE p_less_eq USING @minint; +colA +-32768 +EXECUTE p_gret_eq USING @minint; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +EXECUTE p_greater USING @minint; +colA +-32767 +0 +1 +3 +32766 +32767 +EXECUTE p_eq USING @maxint_plus_1; +colA +EXECUTE p_equal USING @maxint_plus_1; +colA +EXECUTE p_n_eq USING @maxint_plus_1; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +EXECUTE p_n_equal USING @maxint_plus_1; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +NULL +EXECUTE p_eq USING @maxint; +colA +32767 +EXECUTE p_equal USING @maxint; +colA +32767 +EXECUTE p_n_eq USING @maxint; +colA +-32768 +-32767 +0 +1 +3 +32766 +EXECUTE p_n_equal USING @maxint; +colA +-32768 +-32767 +0 +1 +3 +32766 +NULL +EXECUTE p_eq USING @minint; +colA +-32768 +EXECUTE p_equal USING @minint; +colA +-32768 +EXECUTE p_n_eq USING @minint; +colA +-32767 +0 +1 +3 +32766 +32767 +EXECUTE p_n_equal USING @minint; +colA +-32767 +0 +1 +3 +32766 +32767 +NULL +EXECUTE p_eq USING @minint_minus_1; +colA +EXECUTE p_equal USING @minint_minus_1; +colA +EXECUTE p_n_eq USING @minint_minus_1; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +EXECUTE p_n_equal USING @minint_minus_1; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +NULL +DROP PREPARE p_less; +DROP PREPARE p_less_eq; +DROP PREPARE p_greater; +DROP PREPARE p_gret_eq; +DROP PREPARE p_equal; +DROP PREPARE p_n_eq; +DROP PREPARE p_n_equal; +EXPLAIN SELECT * FROM smalltbls WHERE colA < 32768; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE smalltbls NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbls`.`colA` AS `colA` from `test`.`smalltbls` where (`test`.`smalltbls`.`colA` is not null) +EXPLAIN SELECT * FROM smalltbls WHERE colA <= 32767; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE smalltbls NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbls`.`colA` AS `colA` from `test`.`smalltbls` where (`test`.`smalltbls`.`colA` is not null) +EXPLAIN SELECT * FROM smalltbls WHERE colA > 32768; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbls`.`colA` AS `colA` from `test`.`smalltbls` where false +EXPLAIN SELECT * FROM smalltbls WHERE colA >= 32767; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE smalltbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbls`.`colA` AS `colA` from `test`.`smalltbls` where (`test`.`smalltbls`.`colA` = 32767) +EXPLAIN SELECT * FROM smalltbls WHERE colA > -32769; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE smalltbls NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbls`.`colA` AS `colA` from `test`.`smalltbls` where (`test`.`smalltbls`.`colA` is not null) +EXPLAIN SELECT * FROM smalltbls WHERE colA <= -32769; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbls`.`colA` AS `colA` from `test`.`smalltbls` where false +EXPLAIN SELECT * FROM smalltbls WHERE colA <= -32768; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE smalltbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbls`.`colA` AS `colA` from `test`.`smalltbls` where (`test`.`smalltbls`.`colA` = (-(32768))) +EXPLAIN SELECT * FROM smalltbls WHERE colA >= -32768; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE smalltbls NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbls`.`colA` AS `colA` from `test`.`smalltbls` where (`test`.`smalltbls`.`colA` is not null) +EXPLAIN SELECT * FROM smalltbls WHERE colA > -32768; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 33.33 Parallel execute (1 workers) +2 SIMPLE smalltbls NULL ALL NULL NULL NULL NULL 8 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbls`.`colA` AS `colA` from `test`.`smalltbls` where (`test`.`smalltbls`.`colA` > (-(32768))) +EXPLAIN SELECT * FROM smalltbls WHERE colA = 32768; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbls`.`colA` AS `colA` from `test`.`smalltbls` where false +EXPLAIN SELECT * FROM smalltbls WHERE colA <=> 32768; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbls`.`colA` AS `colA` from `test`.`smalltbls` where false +EXPLAIN SELECT * FROM smalltbls WHERE colA <> 32768; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE smalltbls NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbls`.`colA` AS `colA` from `test`.`smalltbls` where (`test`.`smalltbls`.`colA` is not null) +EXPLAIN SELECT * FROM smalltbls WHERE colA = 32767; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE smalltbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbls`.`colA` AS `colA` from `test`.`smalltbls` where (`test`.`smalltbls`.`colA` = 32767) +EXPLAIN SELECT * FROM smalltbls WHERE colA <=> 32767; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE smalltbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbls`.`colA` AS `colA` from `test`.`smalltbls` where (`test`.`smalltbls`.`colA` <=> 32767) +EXPLAIN SELECT * FROM smalltbls WHERE colA <> 32767; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE smalltbls NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbls`.`colA` AS `colA` from `test`.`smalltbls` where (`test`.`smalltbls`.`colA` <> 32767) +EXPLAIN SELECT * FROM smalltbls WHERE colA = -32768; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE smalltbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbls`.`colA` AS `colA` from `test`.`smalltbls` where (`test`.`smalltbls`.`colA` = (-(32768))) +EXPLAIN SELECT * FROM smalltbls WHERE colA <=> -32768; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE smalltbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbls`.`colA` AS `colA` from `test`.`smalltbls` where (`test`.`smalltbls`.`colA` <=> (-(32768))) +EXPLAIN SELECT * FROM smalltbls WHERE colA <> -32768; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE smalltbls NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbls`.`colA` AS `colA` from `test`.`smalltbls` where (`test`.`smalltbls`.`colA` <> (-(32768))) +EXPLAIN SELECT * FROM smalltbls WHERE colA = -32769; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbls`.`colA` AS `colA` from `test`.`smalltbls` where false +EXPLAIN SELECT * FROM smalltbls WHERE colA <=> -32769; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbls`.`colA` AS `colA` from `test`.`smalltbls` where false +EXPLAIN SELECT * FROM smalltbls WHERE colA <> -32769; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE smalltbls NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbls`.`colA` AS `colA` from `test`.`smalltbls` where (`test`.`smalltbls`.`colA` is not null) +same queries but constant first +SELECT * FROM smalltbls WHERE 32768 > colA; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +SELECT * FROM smalltbls WHERE 32767 >= colA; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +SELECT * FROM smalltbls WHERE 32768 < colA; +colA +SELECT * FROM smalltbls WHERE 32767 <= colA; +colA +32767 +SELECT * FROM smalltbls WHERE 32767 < colA; +colA +SELECT * FROM smalltbls WHERE -32769 < colA; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +SELECT * FROM smalltbls WHERE -32769 >= colA; +colA +SELECT * FROM smalltbls WHERE -32768 >= colA; +colA +-32768 +SELECT * FROM smalltbls WHERE -32768 <= colA; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +SELECT * FROM smalltbls WHERE -32768 < colA; +colA +-32767 +0 +1 +3 +32766 +32767 +SELECT * FROM smalltbls WHERE 32768 = colA; +colA +SELECT * FROM smalltbls WHERE 32768 <=> colA; +colA +SELECT * FROM smalltbls WHERE 32768 <> colA; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +SELECT * FROM smalltbls WHERE 32767 = colA; +colA +32767 +SELECT * FROM smalltbls WHERE 32767 <=> colA; +colA +32767 +SELECT * FROM smalltbls WHERE 32767 <> colA; +colA +-32768 +-32767 +0 +1 +3 +32766 +SELECT * FROM smalltbls WHERE -32768 = colA; +colA +-32768 +SELECT * FROM smalltbls WHERE -32768 <=> colA; +colA +-32768 +SELECT * FROM smalltbls WHERE -32768 <> colA; +colA +-32767 +0 +1 +3 +32766 +32767 +SELECT * FROM smalltbls WHERE -32769 = colA; +colA +SELECT * FROM smalltbls WHERE -32769 <=> colA; +colA +SELECT * FROM smalltbls WHERE -32769 <> colA; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +PREPARE p_less FROM 'SELECT * FROM smalltbls WHERE ? < colA'; +PREPARE p_less_eq FROM 'SELECT * FROM smalltbls WHERE ? <= colA'; +PREPARE p_greater FROM 'SELECT * FROM smalltbls WHERE ? > colA'; +PREPARE p_gret_eq FROM 'SELECT * FROM smalltbls WHERE ? >= colA'; +PREPARE p_eq FROM 'SELECT * FROM smalltbls WHERE ? = colA'; +PREPARE p_equal FROM 'SELECT * FROM smalltbls WHERE ? <=> colA'; +PREPARE p_n_eq FROM 'SELECT * FROM smalltbls WHERE ? <> colA'; +PREPARE p_n_equal FROM 'SELECT * FROM smalltbls WHERE NOT(? <=> colA)'; +EXECUTE p_greater USING @maxint_plus_1; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +EXECUTE p_gret_eq USING @maxint; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +EXECUTE p_less USING @maxint_plus_1; +colA +EXECUTE p_less_eq USING @maxint; +colA +32767 +EXECUTE p_less USING @minint_minus_1; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +EXECUTE p_gret_eq USING @minint_minus_1; +colA +EXECUTE p_gret_eq USING @minint; +colA +-32768 +EXECUTE p_less_eq USING @minint; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +EXECUTE p_less USING @minint; +colA +-32767 +0 +1 +3 +32766 +32767 +EXECUTE p_eq USING @maxint_plus_1; +colA +EXECUTE p_equal USING @maxint_plus_1; +colA +EXECUTE p_n_eq USING @maxint_plus_1; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +EXECUTE p_n_equal USING @maxint_plus_1; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +NULL +EXECUTE p_eq USING @maxint; +colA +32767 +EXECUTE p_equal USING @maxint; +colA +32767 +EXECUTE p_n_eq USING @maxint; +colA +-32768 +-32767 +0 +1 +3 +32766 +EXECUTE p_n_equal USING @maxint; +colA +-32768 +-32767 +0 +1 +3 +32766 +NULL +EXECUTE p_eq USING @minint; +colA +-32768 +EXECUTE p_equal USING @minint; +colA +-32768 +EXECUTE p_n_eq USING @minint; +colA +-32767 +0 +1 +3 +32766 +32767 +EXECUTE p_n_equal USING @minint; +colA +-32767 +0 +1 +3 +32766 +32767 +NULL +EXECUTE p_eq USING @minint_minus_1; +colA +EXECUTE p_equal USING @minint_minus_1; +colA +EXECUTE p_n_eq USING @minint_minus_1; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +EXECUTE p_n_equal USING @minint_minus_1; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +NULL +DROP PREPARE p_less; +DROP PREPARE p_less_eq; +DROP PREPARE p_greater; +DROP PREPARE p_gret_eq; +DROP PREPARE p_equal; +DROP PREPARE p_n_eq; +DROP PREPARE p_n_equal; +EXPLAIN SELECT * FROM smalltbls WHERE 32768 > colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE smalltbls NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbls`.`colA` AS `colA` from `test`.`smalltbls` where (`test`.`smalltbls`.`colA` is not null) +EXPLAIN SELECT * FROM smalltbls WHERE 32767 >= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE smalltbls NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbls`.`colA` AS `colA` from `test`.`smalltbls` where (`test`.`smalltbls`.`colA` is not null) +EXPLAIN SELECT * FROM smalltbls WHERE 32768 < colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbls`.`colA` AS `colA` from `test`.`smalltbls` where false +EXPLAIN SELECT * FROM smalltbls WHERE 32767 <= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE smalltbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbls`.`colA` AS `colA` from `test`.`smalltbls` where (32767 = `test`.`smalltbls`.`colA`) +EXPLAIN SELECT * FROM smalltbls WHERE 32767 < colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbls`.`colA` AS `colA` from `test`.`smalltbls` where false +EXPLAIN SELECT * FROM smalltbls WHERE -32769 < colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE smalltbls NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbls`.`colA` AS `colA` from `test`.`smalltbls` where (`test`.`smalltbls`.`colA` is not null) +EXPLAIN SELECT * FROM smalltbls WHERE -32769 >= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbls`.`colA` AS `colA` from `test`.`smalltbls` where false +EXPLAIN SELECT * FROM smalltbls WHERE -32768 >= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE smalltbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbls`.`colA` AS `colA` from `test`.`smalltbls` where ((-(32768)) = `test`.`smalltbls`.`colA`) +EXPLAIN SELECT * FROM smalltbls WHERE -32768 <= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE smalltbls NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbls`.`colA` AS `colA` from `test`.`smalltbls` where (`test`.`smalltbls`.`colA` is not null) +EXPLAIN SELECT * FROM smalltbls WHERE -32768 < colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 33.33 Parallel execute (1 workers) +2 SIMPLE smalltbls NULL ALL NULL NULL NULL NULL 8 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbls`.`colA` AS `colA` from `test`.`smalltbls` where ((-(32768)) < `test`.`smalltbls`.`colA`) +EXPLAIN SELECT * FROM smalltbls WHERE 32768 = colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbls`.`colA` AS `colA` from `test`.`smalltbls` where false +EXPLAIN SELECT * FROM smalltbls WHERE 32768 <=> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbls`.`colA` AS `colA` from `test`.`smalltbls` where false +EXPLAIN SELECT * FROM smalltbls WHERE 32768 <> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE smalltbls NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbls`.`colA` AS `colA` from `test`.`smalltbls` where (`test`.`smalltbls`.`colA` is not null) +EXPLAIN SELECT * FROM smalltbls WHERE 32767 = colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE smalltbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbls`.`colA` AS `colA` from `test`.`smalltbls` where (`test`.`smalltbls`.`colA` = 32767) +EXPLAIN SELECT * FROM smalltbls WHERE 32767 <=> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE smalltbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbls`.`colA` AS `colA` from `test`.`smalltbls` where (32767 <=> `test`.`smalltbls`.`colA`) +EXPLAIN SELECT * FROM smalltbls WHERE 32767 <> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE smalltbls NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbls`.`colA` AS `colA` from `test`.`smalltbls` where (32767 <> `test`.`smalltbls`.`colA`) +EXPLAIN SELECT * FROM smalltbls WHERE -32768 = colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE smalltbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbls`.`colA` AS `colA` from `test`.`smalltbls` where (`test`.`smalltbls`.`colA` = (-(32768))) +EXPLAIN SELECT * FROM smalltbls WHERE -32768 <=> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE smalltbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbls`.`colA` AS `colA` from `test`.`smalltbls` where ((-(32768)) <=> `test`.`smalltbls`.`colA`) +EXPLAIN SELECT * FROM smalltbls WHERE -32768 <> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE smalltbls NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbls`.`colA` AS `colA` from `test`.`smalltbls` where ((-(32768)) <> `test`.`smalltbls`.`colA`) +EXPLAIN SELECT * FROM smalltbls WHERE -32769 = colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbls`.`colA` AS `colA` from `test`.`smalltbls` where false +EXPLAIN SELECT * FROM smalltbls WHERE -32769 <=> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbls`.`colA` AS `colA` from `test`.`smalltbls` where false +EXPLAIN SELECT * FROM smalltbls WHERE -32769 <> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE smalltbls NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbls`.`colA` AS `colA` from `test`.`smalltbls` where (`test`.`smalltbls`.`colA` is not null) +DROP TABLE smalltbls; +# +# Tests with type SMALLINT against decimal +# +CREATE TABLE smalltbls (colA SMALLINT ); +INSERT INTO smalltbls VALUES (-32768), (-32767), +(0),(1),(3), +(32766), (32767), +(NULL); +ANALYZE TABLE smalltbls; +Table Op Msg_type Msg_text +test.smalltbls analyze status OK +SELECT * FROM smalltbls; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +NULL +SELECT * FROM smalltbls WHERE colA < 0.5; +colA +-32768 +-32767 +0 +SELECT * FROM smalltbls WHERE colA <= 0.5; +colA +-32768 +-32767 +0 +SELECT * FROM smalltbls WHERE colA > 0.5; +colA +1 +3 +32766 +32767 +SELECT * FROM smalltbls WHERE colA >= 0.5; +colA +1 +3 +32766 +32767 +SELECT * FROM smalltbls WHERE colA = 0.5; +colA +SELECT * FROM smalltbls WHERE colA <> 0.5; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +SELECT * FROM smalltbls WHERE colA < -0.5; +colA +-32768 +-32767 +SELECT * FROM smalltbls WHERE colA <= -0.5; +colA +-32768 +-32767 +SELECT * FROM smalltbls WHERE colA > -0.5; +colA +0 +1 +3 +32766 +32767 +SELECT * FROM smalltbls WHERE colA >= -0.5; +colA +0 +1 +3 +32766 +32767 +SELECT * FROM smalltbls WHERE colA = -0.5; +colA +SELECT * FROM smalltbls WHERE colA <> -0.5; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +SELECT * FROM smalltbls WHERE colA < 32767.00001; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +SELECT * FROM smalltbls WHERE colA <= 32767.00001; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +SELECT * FROM smalltbls WHERE colA > 32767.00001; +colA +SELECT * FROM smalltbls WHERE colA >= 32767.00001; +colA +SELECT * FROM smalltbls WHERE colA = 32767.00001; +colA +SELECT * FROM smalltbls WHERE colA <> 32767.00001; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +SELECT * FROM smalltbls WHERE colA < 32766.99999; +colA +-32768 +-32767 +0 +1 +3 +32766 +SELECT * FROM smalltbls WHERE colA <= 32766.99999; +colA +-32768 +-32767 +0 +1 +3 +32766 +SELECT * FROM smalltbls WHERE colA > 32766.99999; +colA +32767 +SELECT * FROM smalltbls WHERE colA >= 32766.99999; +colA +32767 +SELECT * FROM smalltbls WHERE colA = 32766.99999; +colA +SELECT * FROM smalltbls WHERE colA <> 32766.99999; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +SELECT * FROM smalltbls WHERE colA < -32767.99999; +colA +-32768 +SELECT * FROM smalltbls WHERE colA <= -32767.99999; +colA +-32768 +SELECT * FROM smalltbls WHERE colA > -32767.99999; +colA +-32767 +0 +1 +3 +32766 +32767 +SELECT * FROM smalltbls WHERE colA >= -32767.99999; +colA +-32767 +0 +1 +3 +32766 +32767 +SELECT * FROM smalltbls WHERE colA = -32767.99999; +colA +SELECT * FROM smalltbls WHERE colA <> -32767.99999; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +SELECT * FROM smalltbls WHERE colA < -32768.00001; +colA +SELECT * FROM smalltbls WHERE colA <= -32768.00001; +colA +SELECT * FROM smalltbls WHERE colA > -32768.00001; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +SELECT * FROM smalltbls WHERE colA >= -32768.00001; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +SELECT * FROM smalltbls WHERE colA = -32768.00001; +colA +SELECT * FROM smalltbls WHERE colA <> -32768.00001; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +SELECT * FROM smalltbls WHERE colA < 18446744073709551615.00000001; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +SELECT * FROM smalltbls WHERE colA <= 18446744073709551615.00000001; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +SELECT * FROM smalltbls WHERE colA > 18446744073709551615.00000001; +colA +SELECT * FROM smalltbls WHERE colA >= 18446744073709551615.00000001; +colA +SELECT * FROM smalltbls WHERE colA = 18446744073709551615.00000001; +colA +SELECT * FROM smalltbls WHERE colA <> 18446744073709551615.00000001; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +SELECT * FROM smalltbls WHERE colA < -9223372036854775808.00000001; +colA +SELECT * FROM smalltbls WHERE colA <= -9223372036854775808.00000001; +colA +SELECT * FROM smalltbls WHERE colA > -9223372036854775808.00000001; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +SELECT * FROM smalltbls WHERE colA >= -9223372036854775808.00000001; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +SELECT * FROM smalltbls WHERE colA = -9223372036854775808.00000001; +colA +SELECT * FROM smalltbls WHERE colA <> -9223372036854775808.00000001; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +PREPARE p_less FROM 'SELECT * FROM smalltbls WHERE colA < ?'; +PREPARE p_less_eq FROM 'SELECT * FROM smalltbls WHERE colA <= ?'; +PREPARE p_greater FROM 'SELECT * FROM smalltbls WHERE colA > ?'; +PREPARE p_gret_eq FROM 'SELECT * FROM smalltbls WHERE colA >= ?'; +PREPARE p_equal FROM 'SELECT * FROM smalltbls WHERE colA = ?'; +PREPARE p_n_equal FROM 'SELECT * FROM smalltbls WHERE colA <> ?'; +SET @dec_0_5=0.5; +SET @dec_minus_0_5=-0.5; +SET @dec_max_plus_delta=32767.00001; +SET @dec_max_minus_delta=32766.99999; +SET @dec_min_plus_delta=-32767.99999; +SET @dec_min_minus_delta=-32768.00001; +SET @dec_too_big_positive_for_any_int=18446744073709551615.00000001; +SET @dec_too_big_negative_for_any_int=-9223372036854775808.00000001; +EXECUTE p_less USING @dec_0_5; +colA +-32768 +-32767 +0 +EXECUTE p_less_eq USING @dec_0_5; +colA +-32768 +-32767 +0 +EXECUTE p_greater USING @dec_0_5; +colA +1 +3 +32766 +32767 +EXECUTE p_gret_eq USING @dec_0_5; +colA +1 +3 +32766 +32767 +EXECUTE p_equal USING @dec_0_5; +colA +EXECUTE p_n_equal USING @dec_0_5; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +EXECUTE p_less USING @dec_minus_0_5; +colA +-32768 +-32767 +EXECUTE p_less_eq USING @dec_minus_0_5; +colA +-32768 +-32767 +EXECUTE p_greater USING @dec_minus_0_5; +colA +0 +1 +3 +32766 +32767 +EXECUTE p_gret_eq USING @dec_minus_0_5; +colA +0 +1 +3 +32766 +32767 +EXECUTE p_equal USING @dec_minus_0_5; +colA +EXECUTE p_n_equal USING @dec_minus_0_5; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +EXECUTE p_less USING @dec_max_plus_delta; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +EXECUTE p_less_eq USING @dec_max_plus_delta; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +EXECUTE p_greater USING @dec_max_plus_delta; +colA +EXECUTE p_gret_eq USING @dec_max_plus_delta; +colA +EXECUTE p_equal USING @dec_max_plus_delta; +colA +EXECUTE p_n_equal USING @dec_max_plus_delta; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +EXECUTE p_less USING @dec_max_minus_delta; +colA +-32768 +-32767 +0 +1 +3 +32766 +EXECUTE p_less_eq USING @dec_max_minus_delta; +colA +-32768 +-32767 +0 +1 +3 +32766 +EXECUTE p_greater USING @dec_max_minus_delta; +colA +32767 +EXECUTE p_gret_eq USING @dec_max_minus_delta; +colA +32767 +EXECUTE p_equal USING @dec_max_minus_delta; +colA +EXECUTE p_n_equal USING @dec_max_minus_delta; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +EXECUTE p_less USING @dec_min_plus_delta; +colA +-32768 +EXECUTE p_less_eq USING @dec_min_plus_delta; +colA +-32768 +EXECUTE p_greater USING @dec_min_plus_delta; +colA +-32767 +0 +1 +3 +32766 +32767 +EXECUTE p_gret_eq USING @dec_min_plus_delta; +colA +-32767 +0 +1 +3 +32766 +32767 +EXECUTE p_equal USING @dec_min_plus_delta; +colA +EXECUTE p_n_equal USING @dec_min_plus_delta; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +EXECUTE p_less USING @dec_min_minus_delta; +colA +EXECUTE p_less_eq USING @dec_min_minus_delta; +colA +EXECUTE p_greater USING @dec_min_minus_delta; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +EXECUTE p_gret_eq USING @dec_min_minus_delta; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +EXECUTE p_equal USING @dec_min_minus_delta; +colA +EXECUTE p_n_equal USING @dec_min_minus_delta; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +EXECUTE p_less USING @dec_too_big_positive_for_any_int; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +EXECUTE p_less_eq USING @dec_too_big_positive_for_any_int; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +EXECUTE p_greater USING @dec_too_big_positive_for_any_int; +colA +EXECUTE p_gret_eq USING @dec_too_big_positive_for_any_int; +colA +EXECUTE p_equal USING @dec_too_big_positive_for_any_int; +colA +EXECUTE p_n_equal USING @dec_too_big_positive_for_any_int; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +EXECUTE p_less USING @dec_too_big_negative_for_any_int; +colA +EXECUTE p_less_eq USING @dec_too_big_negative_for_any_int; +colA +EXECUTE p_greater USING @dec_too_big_negative_for_any_int; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +EXECUTE p_gret_eq USING @dec_too_big_negative_for_any_int; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +EXECUTE p_equal USING @dec_too_big_negative_for_any_int; +colA +EXECUTE p_n_equal USING @dec_too_big_negative_for_any_int; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +DROP PREPARE p_less; +DROP PREPARE p_less_eq; +DROP PREPARE p_greater; +DROP PREPARE p_gret_eq; +DROP PREPARE p_equal; +DROP PREPARE p_n_equal; +DROP TABLE smalltbls; +Cruft inside string +CREATE TABLE t(i INT); +INSERT INTO t VALUES (-1), (0), (1); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +SELECT * FROM t WHERE i > 'A'; +i +1 +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'A' +EXPLAIN SELECT * FROM t WHERE i > 'A'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'A' +Note 1003 /* select#1 */ select `test`.`t`.`i` AS `i` from `test`.`t` where (`test`.`t`.`i` > 0) +DROP TABLE t; +Detect decimal inside a string when compared to int +Used to return one row; should be none. +CREATE TABLE t(i BIGINT); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +INSERT INTO t VALUES (1), (2); +SELECT * FROM t WHERE i = '1.1'; +i +EXPLAIN SELECT * FROM t WHERE i = '1.1'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`i` AS `i` from `test`.`t` where false +DROP TABLE t; +Detect out of range real inside a string when compared to int +Used to return one row; should be none. +CREATE TABLE t(i TINYINT); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +INSERT INTO t VALUES (1), (2); +SELECT * FROM t WHERE i > '1E10'; +i +EXPLAIN SELECT * FROM t WHERE i > '1E10'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`i` AS `i` from `test`.`t` where false +DROP TABLE t; +Detect out of range real inside a string when compared to int +Used to return one row; should be none. +CREATE TABLE t(i TINYINT); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +INSERT INTO t VALUES (0); +SELECT * FROM t WHERE i = '1E-308'; +i +EXPLAIN SELECT * FROM t WHERE i = '1E-308'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`i` AS `i` from `test`.`t` where false +Above query should yield the same as this: +SELECT * FROM t WHERE i = 1E-308; +i +EXPLAIN SELECT * FROM t WHERE i = 1E-308; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`i` AS `i` from `test`.`t` where false +DROP TABLE t; +# +# Tests with type SMALLINT NOT NULL against int +# +CREATE TABLE smalltbls (colA SMALLINT NOT NULL); +INSERT INTO smalltbls VALUES (-32768), (-32767), +(0),(1),(3), +(32766), (32767), +(0); +ANALYZE TABLE smalltbls; +Table Op Msg_type Msg_text +test.smalltbls analyze status OK +SELECT * FROM smalltbls; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +0 +SELECT * FROM smalltbls WHERE colA < 32768; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +0 +SELECT * FROM smalltbls WHERE colA <= 32767; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +0 +SELECT * FROM smalltbls WHERE colA > 32768; +colA +SELECT * FROM smalltbls WHERE colA >= 32767; +colA +32767 +SELECT * FROM smalltbls WHERE colA > -32769; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +0 +SELECT * FROM smalltbls WHERE colA <= -32769; +colA +SELECT * FROM smalltbls WHERE colA <= -32768; +colA +-32768 +SELECT * FROM smalltbls WHERE colA >= -32768; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +0 +SELECT * FROM smalltbls WHERE colA > -32768; +colA +-32767 +0 +1 +3 +32766 +32767 +0 +SELECT * FROM smalltbls WHERE colA = 32768; +colA +SELECT * FROM smalltbls WHERE colA <> 32768; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +0 +SELECT * FROM smalltbls WHERE colA = 32767; +colA +32767 +SELECT * FROM smalltbls WHERE colA <=> 32767; +colA +32767 +SELECT * FROM smalltbls WHERE NOT(colA <=> 32767); +colA +-32768 +-32767 +0 +1 +3 +32766 +0 +SELECT * FROM smalltbls WHERE colA <> 32767; +colA +-32768 +-32767 +0 +1 +3 +32766 +0 +SELECT * FROM smalltbls WHERE colA = -32768; +colA +-32768 +SELECT * FROM smalltbls WHERE colA <=> -32768; +colA +-32768 +SELECT * FROM smalltbls WHERE NOT(colA <=> -32768); +colA +-32767 +0 +1 +3 +32766 +32767 +0 +SELECT * FROM smalltbls WHERE colA <> -32768; +colA +-32767 +0 +1 +3 +32766 +32767 +0 +SELECT * FROM smalltbls WHERE colA = -32769; +colA +SELECT * FROM smalltbls WHERE colA <=> -32769; +colA +SELECT * FROM smalltbls WHERE NOT(colA <=> -32769); +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +0 +SELECT * FROM smalltbls WHERE colA <> -32769; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +0 +PREPARE p_less FROM 'SELECT * FROM smalltbls WHERE colA < ?'; +PREPARE p_less_eq FROM 'SELECT * FROM smalltbls WHERE colA <= ?'; +PREPARE p_greater FROM 'SELECT * FROM smalltbls WHERE colA > ?'; +PREPARE p_gret_eq FROM 'SELECT * FROM smalltbls WHERE colA >= ?'; +PREPARE p_eq FROM 'SELECT * FROM smalltbls WHERE colA = ?'; +PREPARE p_equal FROM 'SELECT * FROM smalltbls WHERE colA <=> ?'; +PREPARE p_n_equal FROM 'SELECT * FROM smalltbls WHERE NOT(colA <=> ?)'; +PREPARE p_n_eq FROM 'SELECT * FROM smalltbls WHERE colA <> ?'; +SET @maxint_plus_1=32768; +SET @maxint=32767; +SET @minint_minus_1=-32769; +SET @minint=-32768; +EXECUTE p_less USING @maxint_plus_1; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +0 +EXECUTE p_less_eq USING @maxint; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +0 +EXECUTE p_greater USING @maxint_plus_1; +colA +EXECUTE p_gret_eq USING @maxint; +colA +32767 +EXECUTE p_greater USING @minint_minus_1; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +0 +EXECUTE p_less_eq USING @minint_minus_1; +colA +EXECUTE p_less_eq USING @minint; +colA +-32768 +EXECUTE p_gret_eq USING @minint; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +0 +EXECUTE p_greater USING @minint; +colA +-32767 +0 +1 +3 +32766 +32767 +0 +EXECUTE p_eq USING @maxint_plus_1; +colA +EXECUTE p_equal USING @maxint_plus_1; +colA +EXECUTE p_n_eq USING @maxint_plus_1; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +0 +EXECUTE p_n_equal USING @maxint_plus_1; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +0 +EXECUTE p_eq USING @maxint; +colA +32767 +EXECUTE p_equal USING @maxint; +colA +32767 +EXECUTE p_n_eq USING @maxint; +colA +-32768 +-32767 +0 +1 +3 +32766 +0 +EXECUTE p_n_equal USING @maxint; +colA +-32768 +-32767 +0 +1 +3 +32766 +0 +EXECUTE p_eq USING @minint; +colA +-32768 +EXECUTE p_equal USING @minint; +colA +-32768 +EXECUTE p_n_eq USING @minint; +colA +-32767 +0 +1 +3 +32766 +32767 +0 +EXECUTE p_n_equal USING @minint; +colA +-32767 +0 +1 +3 +32766 +32767 +0 +EXECUTE p_eq USING @minint_minus_1; +colA +EXECUTE p_equal USING @minint_minus_1; +colA +EXECUTE p_n_eq USING @minint_minus_1; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +0 +EXECUTE p_n_equal USING @minint_minus_1; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +0 +DROP PREPARE p_less; +DROP PREPARE p_less_eq; +DROP PREPARE p_greater; +DROP PREPARE p_gret_eq; +DROP PREPARE p_equal; +DROP PREPARE p_n_eq; +DROP PREPARE p_n_equal; +EXPLAIN SELECT * FROM smalltbls WHERE colA < 32768; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE smalltbls NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbls`.`colA` AS `colA` from `test`.`smalltbls` where true +EXPLAIN SELECT * FROM smalltbls WHERE colA <= 32767; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE smalltbls NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbls`.`colA` AS `colA` from `test`.`smalltbls` where true +EXPLAIN SELECT * FROM smalltbls WHERE colA > 32768; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbls`.`colA` AS `colA` from `test`.`smalltbls` where false +EXPLAIN SELECT * FROM smalltbls WHERE colA >= 32767; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE smalltbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbls`.`colA` AS `colA` from `test`.`smalltbls` where (`test`.`smalltbls`.`colA` = 32767) +EXPLAIN SELECT * FROM smalltbls WHERE colA > -32769; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE smalltbls NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbls`.`colA` AS `colA` from `test`.`smalltbls` where true +EXPLAIN SELECT * FROM smalltbls WHERE colA <= -32769; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbls`.`colA` AS `colA` from `test`.`smalltbls` where false +EXPLAIN SELECT * FROM smalltbls WHERE colA <= -32768; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE smalltbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbls`.`colA` AS `colA` from `test`.`smalltbls` where (`test`.`smalltbls`.`colA` = (-(32768))) +EXPLAIN SELECT * FROM smalltbls WHERE colA >= -32768; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE smalltbls NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbls`.`colA` AS `colA` from `test`.`smalltbls` where true +EXPLAIN SELECT * FROM smalltbls WHERE colA > -32768; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 33.33 Parallel execute (1 workers) +2 SIMPLE smalltbls NULL ALL NULL NULL NULL NULL 8 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbls`.`colA` AS `colA` from `test`.`smalltbls` where (`test`.`smalltbls`.`colA` > (-(32768))) +EXPLAIN SELECT * FROM smalltbls WHERE colA = 32768; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbls`.`colA` AS `colA` from `test`.`smalltbls` where false +EXPLAIN SELECT * FROM smalltbls WHERE colA <=> 32768; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbls`.`colA` AS `colA` from `test`.`smalltbls` where false +EXPLAIN SELECT * FROM smalltbls WHERE colA <> 32768; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE smalltbls NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbls`.`colA` AS `colA` from `test`.`smalltbls` where true +EXPLAIN SELECT * FROM smalltbls WHERE colA = 32767; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE smalltbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbls`.`colA` AS `colA` from `test`.`smalltbls` where (`test`.`smalltbls`.`colA` = 32767) +EXPLAIN SELECT * FROM smalltbls WHERE colA <=> 32767; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE smalltbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbls`.`colA` AS `colA` from `test`.`smalltbls` where (`test`.`smalltbls`.`colA` <=> 32767) +EXPLAIN SELECT * FROM smalltbls WHERE colA <> 32767; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE smalltbls NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbls`.`colA` AS `colA` from `test`.`smalltbls` where (`test`.`smalltbls`.`colA` <> 32767) +EXPLAIN SELECT * FROM smalltbls WHERE colA = -32768; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE smalltbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbls`.`colA` AS `colA` from `test`.`smalltbls` where (`test`.`smalltbls`.`colA` = (-(32768))) +EXPLAIN SELECT * FROM smalltbls WHERE colA <=> -32768; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE smalltbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbls`.`colA` AS `colA` from `test`.`smalltbls` where (`test`.`smalltbls`.`colA` <=> (-(32768))) +EXPLAIN SELECT * FROM smalltbls WHERE colA <> -32768; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE smalltbls NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbls`.`colA` AS `colA` from `test`.`smalltbls` where (`test`.`smalltbls`.`colA` <> (-(32768))) +EXPLAIN SELECT * FROM smalltbls WHERE colA = -32769; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbls`.`colA` AS `colA` from `test`.`smalltbls` where false +EXPLAIN SELECT * FROM smalltbls WHERE colA <=> -32769; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbls`.`colA` AS `colA` from `test`.`smalltbls` where false +EXPLAIN SELECT * FROM smalltbls WHERE colA <> -32769; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE smalltbls NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbls`.`colA` AS `colA` from `test`.`smalltbls` where true +same queries but constant first +SELECT * FROM smalltbls WHERE 32768 > colA; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +0 +SELECT * FROM smalltbls WHERE 32767 >= colA; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +0 +SELECT * FROM smalltbls WHERE 32768 < colA; +colA +SELECT * FROM smalltbls WHERE 32767 <= colA; +colA +32767 +SELECT * FROM smalltbls WHERE 32767 < colA; +colA +SELECT * FROM smalltbls WHERE -32769 < colA; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +0 +SELECT * FROM smalltbls WHERE -32769 >= colA; +colA +SELECT * FROM smalltbls WHERE -32768 >= colA; +colA +-32768 +SELECT * FROM smalltbls WHERE -32768 <= colA; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +0 +SELECT * FROM smalltbls WHERE -32768 < colA; +colA +-32767 +0 +1 +3 +32766 +32767 +0 +SELECT * FROM smalltbls WHERE 32768 = colA; +colA +SELECT * FROM smalltbls WHERE 32768 <=> colA; +colA +SELECT * FROM smalltbls WHERE 32768 <> colA; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +0 +SELECT * FROM smalltbls WHERE 32767 = colA; +colA +32767 +SELECT * FROM smalltbls WHERE 32767 <=> colA; +colA +32767 +SELECT * FROM smalltbls WHERE 32767 <> colA; +colA +-32768 +-32767 +0 +1 +3 +32766 +0 +SELECT * FROM smalltbls WHERE -32768 = colA; +colA +-32768 +SELECT * FROM smalltbls WHERE -32768 <=> colA; +colA +-32768 +SELECT * FROM smalltbls WHERE -32768 <> colA; +colA +-32767 +0 +1 +3 +32766 +32767 +0 +SELECT * FROM smalltbls WHERE -32769 = colA; +colA +SELECT * FROM smalltbls WHERE -32769 <=> colA; +colA +SELECT * FROM smalltbls WHERE -32769 <> colA; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +0 +PREPARE p_less FROM 'SELECT * FROM smalltbls WHERE ? < colA'; +PREPARE p_less_eq FROM 'SELECT * FROM smalltbls WHERE ? <= colA'; +PREPARE p_greater FROM 'SELECT * FROM smalltbls WHERE ? > colA'; +PREPARE p_gret_eq FROM 'SELECT * FROM smalltbls WHERE ? >= colA'; +PREPARE p_eq FROM 'SELECT * FROM smalltbls WHERE ? = colA'; +PREPARE p_equal FROM 'SELECT * FROM smalltbls WHERE ? <=> colA'; +PREPARE p_n_eq FROM 'SELECT * FROM smalltbls WHERE ? <> colA'; +PREPARE p_n_equal FROM 'SELECT * FROM smalltbls WHERE NOT(? <=> colA)'; +EXECUTE p_greater USING @maxint_plus_1; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +0 +EXECUTE p_gret_eq USING @maxint; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +0 +EXECUTE p_less USING @maxint_plus_1; +colA +EXECUTE p_less_eq USING @maxint; +colA +32767 +EXECUTE p_less USING @minint_minus_1; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +0 +EXECUTE p_gret_eq USING @minint_minus_1; +colA +EXECUTE p_gret_eq USING @minint; +colA +-32768 +EXECUTE p_less_eq USING @minint; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +0 +EXECUTE p_less USING @minint; +colA +-32767 +0 +1 +3 +32766 +32767 +0 +EXECUTE p_eq USING @maxint_plus_1; +colA +EXECUTE p_equal USING @maxint_plus_1; +colA +EXECUTE p_n_eq USING @maxint_plus_1; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +0 +EXECUTE p_n_equal USING @maxint_plus_1; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +0 +EXECUTE p_eq USING @maxint; +colA +32767 +EXECUTE p_equal USING @maxint; +colA +32767 +EXECUTE p_n_eq USING @maxint; +colA +-32768 +-32767 +0 +1 +3 +32766 +0 +EXECUTE p_n_equal USING @maxint; +colA +-32768 +-32767 +0 +1 +3 +32766 +0 +EXECUTE p_eq USING @minint; +colA +-32768 +EXECUTE p_equal USING @minint; +colA +-32768 +EXECUTE p_n_eq USING @minint; +colA +-32767 +0 +1 +3 +32766 +32767 +0 +EXECUTE p_n_equal USING @minint; +colA +-32767 +0 +1 +3 +32766 +32767 +0 +EXECUTE p_eq USING @minint_minus_1; +colA +EXECUTE p_equal USING @minint_minus_1; +colA +EXECUTE p_n_eq USING @minint_minus_1; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +0 +EXECUTE p_n_equal USING @minint_minus_1; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +0 +DROP PREPARE p_less; +DROP PREPARE p_less_eq; +DROP PREPARE p_greater; +DROP PREPARE p_gret_eq; +DROP PREPARE p_equal; +DROP PREPARE p_n_eq; +DROP PREPARE p_n_equal; +EXPLAIN SELECT * FROM smalltbls WHERE 32768 > colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE smalltbls NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbls`.`colA` AS `colA` from `test`.`smalltbls` where true +EXPLAIN SELECT * FROM smalltbls WHERE 32767 >= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE smalltbls NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbls`.`colA` AS `colA` from `test`.`smalltbls` where true +EXPLAIN SELECT * FROM smalltbls WHERE 32768 < colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbls`.`colA` AS `colA` from `test`.`smalltbls` where false +EXPLAIN SELECT * FROM smalltbls WHERE 32767 <= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE smalltbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbls`.`colA` AS `colA` from `test`.`smalltbls` where (32767 = `test`.`smalltbls`.`colA`) +EXPLAIN SELECT * FROM smalltbls WHERE 32767 < colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbls`.`colA` AS `colA` from `test`.`smalltbls` where false +EXPLAIN SELECT * FROM smalltbls WHERE -32769 < colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE smalltbls NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbls`.`colA` AS `colA` from `test`.`smalltbls` where true +EXPLAIN SELECT * FROM smalltbls WHERE -32769 >= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbls`.`colA` AS `colA` from `test`.`smalltbls` where false +EXPLAIN SELECT * FROM smalltbls WHERE -32768 >= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE smalltbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbls`.`colA` AS `colA` from `test`.`smalltbls` where ((-(32768)) = `test`.`smalltbls`.`colA`) +EXPLAIN SELECT * FROM smalltbls WHERE -32768 <= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE smalltbls NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbls`.`colA` AS `colA` from `test`.`smalltbls` where true +EXPLAIN SELECT * FROM smalltbls WHERE -32768 < colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 33.33 Parallel execute (1 workers) +2 SIMPLE smalltbls NULL ALL NULL NULL NULL NULL 8 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbls`.`colA` AS `colA` from `test`.`smalltbls` where ((-(32768)) < `test`.`smalltbls`.`colA`) +EXPLAIN SELECT * FROM smalltbls WHERE 32768 = colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbls`.`colA` AS `colA` from `test`.`smalltbls` where false +EXPLAIN SELECT * FROM smalltbls WHERE 32768 <=> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbls`.`colA` AS `colA` from `test`.`smalltbls` where false +EXPLAIN SELECT * FROM smalltbls WHERE 32768 <> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE smalltbls NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbls`.`colA` AS `colA` from `test`.`smalltbls` where true +EXPLAIN SELECT * FROM smalltbls WHERE 32767 = colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE smalltbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbls`.`colA` AS `colA` from `test`.`smalltbls` where (`test`.`smalltbls`.`colA` = 32767) +EXPLAIN SELECT * FROM smalltbls WHERE 32767 <=> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE smalltbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbls`.`colA` AS `colA` from `test`.`smalltbls` where (32767 <=> `test`.`smalltbls`.`colA`) +EXPLAIN SELECT * FROM smalltbls WHERE 32767 <> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE smalltbls NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbls`.`colA` AS `colA` from `test`.`smalltbls` where (32767 <> `test`.`smalltbls`.`colA`) +EXPLAIN SELECT * FROM smalltbls WHERE -32768 = colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE smalltbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbls`.`colA` AS `colA` from `test`.`smalltbls` where (`test`.`smalltbls`.`colA` = (-(32768))) +EXPLAIN SELECT * FROM smalltbls WHERE -32768 <=> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE smalltbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbls`.`colA` AS `colA` from `test`.`smalltbls` where ((-(32768)) <=> `test`.`smalltbls`.`colA`) +EXPLAIN SELECT * FROM smalltbls WHERE -32768 <> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE smalltbls NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbls`.`colA` AS `colA` from `test`.`smalltbls` where ((-(32768)) <> `test`.`smalltbls`.`colA`) +EXPLAIN SELECT * FROM smalltbls WHERE -32769 = colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbls`.`colA` AS `colA` from `test`.`smalltbls` where false +EXPLAIN SELECT * FROM smalltbls WHERE -32769 <=> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbls`.`colA` AS `colA` from `test`.`smalltbls` where false +EXPLAIN SELECT * FROM smalltbls WHERE -32769 <> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE smalltbls NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbls`.`colA` AS `colA` from `test`.`smalltbls` where true +DROP TABLE smalltbls; +# +# Tests with type SMALLINT NOT NULL against decimal +# +CREATE TABLE smalltbls (colA SMALLINT NOT NULL); +INSERT INTO smalltbls VALUES (-32768), (-32767), +(0),(1),(3), +(32766), (32767), +(0); +ANALYZE TABLE smalltbls; +Table Op Msg_type Msg_text +test.smalltbls analyze status OK +SELECT * FROM smalltbls; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +0 +SELECT * FROM smalltbls WHERE colA < 0.5; +colA +-32768 +-32767 +0 +0 +SELECT * FROM smalltbls WHERE colA <= 0.5; +colA +-32768 +-32767 +0 +0 +SELECT * FROM smalltbls WHERE colA > 0.5; +colA +1 +3 +32766 +32767 +SELECT * FROM smalltbls WHERE colA >= 0.5; +colA +1 +3 +32766 +32767 +SELECT * FROM smalltbls WHERE colA = 0.5; +colA +SELECT * FROM smalltbls WHERE colA <> 0.5; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +0 +SELECT * FROM smalltbls WHERE colA < -0.5; +colA +-32768 +-32767 +SELECT * FROM smalltbls WHERE colA <= -0.5; +colA +-32768 +-32767 +SELECT * FROM smalltbls WHERE colA > -0.5; +colA +0 +1 +3 +32766 +32767 +0 +SELECT * FROM smalltbls WHERE colA >= -0.5; +colA +0 +1 +3 +32766 +32767 +0 +SELECT * FROM smalltbls WHERE colA = -0.5; +colA +SELECT * FROM smalltbls WHERE colA <> -0.5; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +0 +SELECT * FROM smalltbls WHERE colA < 32767.00001; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +0 +SELECT * FROM smalltbls WHERE colA <= 32767.00001; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +0 +SELECT * FROM smalltbls WHERE colA > 32767.00001; +colA +SELECT * FROM smalltbls WHERE colA >= 32767.00001; +colA +SELECT * FROM smalltbls WHERE colA = 32767.00001; +colA +SELECT * FROM smalltbls WHERE colA <> 32767.00001; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +0 +SELECT * FROM smalltbls WHERE colA < 32766.99999; +colA +-32768 +-32767 +0 +1 +3 +32766 +0 +SELECT * FROM smalltbls WHERE colA <= 32766.99999; +colA +-32768 +-32767 +0 +1 +3 +32766 +0 +SELECT * FROM smalltbls WHERE colA > 32766.99999; +colA +32767 +SELECT * FROM smalltbls WHERE colA >= 32766.99999; +colA +32767 +SELECT * FROM smalltbls WHERE colA = 32766.99999; +colA +SELECT * FROM smalltbls WHERE colA <> 32766.99999; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +0 +SELECT * FROM smalltbls WHERE colA < -32767.99999; +colA +-32768 +SELECT * FROM smalltbls WHERE colA <= -32767.99999; +colA +-32768 +SELECT * FROM smalltbls WHERE colA > -32767.99999; +colA +-32767 +0 +1 +3 +32766 +32767 +0 +SELECT * FROM smalltbls WHERE colA >= -32767.99999; +colA +-32767 +0 +1 +3 +32766 +32767 +0 +SELECT * FROM smalltbls WHERE colA = -32767.99999; +colA +SELECT * FROM smalltbls WHERE colA <> -32767.99999; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +0 +SELECT * FROM smalltbls WHERE colA < -32768.00001; +colA +SELECT * FROM smalltbls WHERE colA <= -32768.00001; +colA +SELECT * FROM smalltbls WHERE colA > -32768.00001; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +0 +SELECT * FROM smalltbls WHERE colA >= -32768.00001; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +0 +SELECT * FROM smalltbls WHERE colA = -32768.00001; +colA +SELECT * FROM smalltbls WHERE colA <> -32768.00001; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +0 +SELECT * FROM smalltbls WHERE colA < 18446744073709551615.00000001; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +0 +SELECT * FROM smalltbls WHERE colA <= 18446744073709551615.00000001; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +0 +SELECT * FROM smalltbls WHERE colA > 18446744073709551615.00000001; +colA +SELECT * FROM smalltbls WHERE colA >= 18446744073709551615.00000001; +colA +SELECT * FROM smalltbls WHERE colA = 18446744073709551615.00000001; +colA +SELECT * FROM smalltbls WHERE colA <> 18446744073709551615.00000001; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +0 +SELECT * FROM smalltbls WHERE colA < -9223372036854775808.00000001; +colA +SELECT * FROM smalltbls WHERE colA <= -9223372036854775808.00000001; +colA +SELECT * FROM smalltbls WHERE colA > -9223372036854775808.00000001; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +0 +SELECT * FROM smalltbls WHERE colA >= -9223372036854775808.00000001; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +0 +SELECT * FROM smalltbls WHERE colA = -9223372036854775808.00000001; +colA +SELECT * FROM smalltbls WHERE colA <> -9223372036854775808.00000001; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +0 +PREPARE p_less FROM 'SELECT * FROM smalltbls WHERE colA < ?'; +PREPARE p_less_eq FROM 'SELECT * FROM smalltbls WHERE colA <= ?'; +PREPARE p_greater FROM 'SELECT * FROM smalltbls WHERE colA > ?'; +PREPARE p_gret_eq FROM 'SELECT * FROM smalltbls WHERE colA >= ?'; +PREPARE p_equal FROM 'SELECT * FROM smalltbls WHERE colA = ?'; +PREPARE p_n_equal FROM 'SELECT * FROM smalltbls WHERE colA <> ?'; +SET @dec_0_5=0.5; +SET @dec_minus_0_5=-0.5; +SET @dec_max_plus_delta=32767.00001; +SET @dec_max_minus_delta=32766.99999; +SET @dec_min_plus_delta=-32767.99999; +SET @dec_min_minus_delta=-32768.00001; +SET @dec_too_big_positive_for_any_int=18446744073709551615.00000001; +SET @dec_too_big_negative_for_any_int=-9223372036854775808.00000001; +EXECUTE p_less USING @dec_0_5; +colA +-32768 +-32767 +0 +0 +EXECUTE p_less_eq USING @dec_0_5; +colA +-32768 +-32767 +0 +0 +EXECUTE p_greater USING @dec_0_5; +colA +1 +3 +32766 +32767 +EXECUTE p_gret_eq USING @dec_0_5; +colA +1 +3 +32766 +32767 +EXECUTE p_equal USING @dec_0_5; +colA +EXECUTE p_n_equal USING @dec_0_5; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +0 +EXECUTE p_less USING @dec_minus_0_5; +colA +-32768 +-32767 +EXECUTE p_less_eq USING @dec_minus_0_5; +colA +-32768 +-32767 +EXECUTE p_greater USING @dec_minus_0_5; +colA +0 +1 +3 +32766 +32767 +0 +EXECUTE p_gret_eq USING @dec_minus_0_5; +colA +0 +1 +3 +32766 +32767 +0 +EXECUTE p_equal USING @dec_minus_0_5; +colA +EXECUTE p_n_equal USING @dec_minus_0_5; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +0 +EXECUTE p_less USING @dec_max_plus_delta; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +0 +EXECUTE p_less_eq USING @dec_max_plus_delta; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +0 +EXECUTE p_greater USING @dec_max_plus_delta; +colA +EXECUTE p_gret_eq USING @dec_max_plus_delta; +colA +EXECUTE p_equal USING @dec_max_plus_delta; +colA +EXECUTE p_n_equal USING @dec_max_plus_delta; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +0 +EXECUTE p_less USING @dec_max_minus_delta; +colA +-32768 +-32767 +0 +1 +3 +32766 +0 +EXECUTE p_less_eq USING @dec_max_minus_delta; +colA +-32768 +-32767 +0 +1 +3 +32766 +0 +EXECUTE p_greater USING @dec_max_minus_delta; +colA +32767 +EXECUTE p_gret_eq USING @dec_max_minus_delta; +colA +32767 +EXECUTE p_equal USING @dec_max_minus_delta; +colA +EXECUTE p_n_equal USING @dec_max_minus_delta; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +0 +EXECUTE p_less USING @dec_min_plus_delta; +colA +-32768 +EXECUTE p_less_eq USING @dec_min_plus_delta; +colA +-32768 +EXECUTE p_greater USING @dec_min_plus_delta; +colA +-32767 +0 +1 +3 +32766 +32767 +0 +EXECUTE p_gret_eq USING @dec_min_plus_delta; +colA +-32767 +0 +1 +3 +32766 +32767 +0 +EXECUTE p_equal USING @dec_min_plus_delta; +colA +EXECUTE p_n_equal USING @dec_min_plus_delta; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +0 +EXECUTE p_less USING @dec_min_minus_delta; +colA +EXECUTE p_less_eq USING @dec_min_minus_delta; +colA +EXECUTE p_greater USING @dec_min_minus_delta; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +0 +EXECUTE p_gret_eq USING @dec_min_minus_delta; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +0 +EXECUTE p_equal USING @dec_min_minus_delta; +colA +EXECUTE p_n_equal USING @dec_min_minus_delta; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +0 +EXECUTE p_less USING @dec_too_big_positive_for_any_int; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +0 +EXECUTE p_less_eq USING @dec_too_big_positive_for_any_int; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +0 +EXECUTE p_greater USING @dec_too_big_positive_for_any_int; +colA +EXECUTE p_gret_eq USING @dec_too_big_positive_for_any_int; +colA +EXECUTE p_equal USING @dec_too_big_positive_for_any_int; +colA +EXECUTE p_n_equal USING @dec_too_big_positive_for_any_int; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +0 +EXECUTE p_less USING @dec_too_big_negative_for_any_int; +colA +EXECUTE p_less_eq USING @dec_too_big_negative_for_any_int; +colA +EXECUTE p_greater USING @dec_too_big_negative_for_any_int; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +0 +EXECUTE p_gret_eq USING @dec_too_big_negative_for_any_int; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +0 +EXECUTE p_equal USING @dec_too_big_negative_for_any_int; +colA +EXECUTE p_n_equal USING @dec_too_big_negative_for_any_int; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +0 +DROP PREPARE p_less; +DROP PREPARE p_less_eq; +DROP PREPARE p_greater; +DROP PREPARE p_gret_eq; +DROP PREPARE p_equal; +DROP PREPARE p_n_equal; +DROP TABLE smalltbls; +Cruft inside string +CREATE TABLE t(i INT); +INSERT INTO t VALUES (-1), (0), (1); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +SELECT * FROM t WHERE i > 'A'; +i +1 +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'A' +EXPLAIN SELECT * FROM t WHERE i > 'A'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'A' +Note 1003 /* select#1 */ select `test`.`t`.`i` AS `i` from `test`.`t` where (`test`.`t`.`i` > 0) +DROP TABLE t; +Detect decimal inside a string when compared to int +Used to return one row; should be none. +CREATE TABLE t(i BIGINT); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +INSERT INTO t VALUES (1), (2); +SELECT * FROM t WHERE i = '1.1'; +i +EXPLAIN SELECT * FROM t WHERE i = '1.1'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`i` AS `i` from `test`.`t` where false +DROP TABLE t; +Detect out of range real inside a string when compared to int +Used to return one row; should be none. +CREATE TABLE t(i TINYINT); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +INSERT INTO t VALUES (1), (2); +SELECT * FROM t WHERE i > '1E10'; +i +EXPLAIN SELECT * FROM t WHERE i > '1E10'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`i` AS `i` from `test`.`t` where false +DROP TABLE t; +Detect out of range real inside a string when compared to int +Used to return one row; should be none. +CREATE TABLE t(i TINYINT); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +INSERT INTO t VALUES (0); +SELECT * FROM t WHERE i = '1E-308'; +i +EXPLAIN SELECT * FROM t WHERE i = '1E-308'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`i` AS `i` from `test`.`t` where false +Above query should yield the same as this: +SELECT * FROM t WHERE i = 1E-308; +i +EXPLAIN SELECT * FROM t WHERE i = 1E-308; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`i` AS `i` from `test`.`t` where false +DROP TABLE t; +# +# Tests with UNSIGNED type MEDIUMINT against int +# +CREATE TABLE mediumtbl (colA MEDIUMINT UNSIGNED ); +INSERT INTO mediumtbl VALUES (0), (1), +(0),(1),(3), +(16777214), (16777215), +(NULL); +ANALYZE TABLE mediumtbl; +Table Op Msg_type Msg_text +test.mediumtbl analyze status OK +SELECT * FROM mediumtbl; +colA +0 +1 +0 +1 +3 +16777214 +16777215 +NULL +SELECT * FROM mediumtbl WHERE colA < 16777216; +colA +0 +1 +0 +1 +3 +16777214 +16777215 +SELECT * FROM mediumtbl WHERE colA <= 16777215; +colA +0 +1 +0 +1 +3 +16777214 +16777215 +SELECT * FROM mediumtbl WHERE colA > 16777216; +colA +SELECT * FROM mediumtbl WHERE colA >= 16777215; +colA +16777215 +SELECT * FROM mediumtbl WHERE colA > -1; +colA +0 +1 +0 +1 +3 +16777214 +16777215 +SELECT * FROM mediumtbl WHERE colA <= -1; +colA +SELECT * FROM mediumtbl WHERE colA <= 0; +colA +0 +0 +SELECT * FROM mediumtbl WHERE colA >= 0; +colA +0 +1 +0 +1 +3 +16777214 +16777215 +SELECT * FROM mediumtbl WHERE colA > 0; +colA +1 +1 +3 +16777214 +16777215 +SELECT * FROM mediumtbl WHERE colA = 16777216; +colA +SELECT * FROM mediumtbl WHERE colA <> 16777216; +colA +0 +1 +0 +1 +3 +16777214 +16777215 +SELECT * FROM mediumtbl WHERE colA = 16777215; +colA +16777215 +SELECT * FROM mediumtbl WHERE colA <=> 16777215; +colA +16777215 +SELECT * FROM mediumtbl WHERE NOT(colA <=> 16777215); +colA +0 +1 +0 +1 +3 +16777214 +NULL +SELECT * FROM mediumtbl WHERE colA <> 16777215; +colA +0 +1 +0 +1 +3 +16777214 +SELECT * FROM mediumtbl WHERE colA = 0; +colA +0 +0 +SELECT * FROM mediumtbl WHERE colA <=> 0; +colA +0 +0 +SELECT * FROM mediumtbl WHERE NOT(colA <=> 0); +colA +1 +1 +3 +16777214 +16777215 +NULL +SELECT * FROM mediumtbl WHERE colA <> 0; +colA +1 +1 +3 +16777214 +16777215 +SELECT * FROM mediumtbl WHERE colA = -1; +colA +SELECT * FROM mediumtbl WHERE colA <=> -1; +colA +SELECT * FROM mediumtbl WHERE NOT(colA <=> -1); +colA +0 +1 +0 +1 +3 +16777214 +16777215 +NULL +SELECT * FROM mediumtbl WHERE colA <> -1; +colA +0 +1 +0 +1 +3 +16777214 +16777215 +PREPARE p_less FROM 'SELECT * FROM mediumtbl WHERE colA < ?'; +PREPARE p_less_eq FROM 'SELECT * FROM mediumtbl WHERE colA <= ?'; +PREPARE p_greater FROM 'SELECT * FROM mediumtbl WHERE colA > ?'; +PREPARE p_gret_eq FROM 'SELECT * FROM mediumtbl WHERE colA >= ?'; +PREPARE p_eq FROM 'SELECT * FROM mediumtbl WHERE colA = ?'; +PREPARE p_equal FROM 'SELECT * FROM mediumtbl WHERE colA <=> ?'; +PREPARE p_n_equal FROM 'SELECT * FROM mediumtbl WHERE NOT(colA <=> ?)'; +PREPARE p_n_eq FROM 'SELECT * FROM mediumtbl WHERE colA <> ?'; +SET @maxint_plus_1=16777216; +SET @maxint=16777215; +SET @minint_minus_1=-1; +SET @minint=0; +EXECUTE p_less USING @maxint_plus_1; +colA +0 +1 +0 +1 +3 +16777214 +16777215 +EXECUTE p_less_eq USING @maxint; +colA +0 +1 +0 +1 +3 +16777214 +16777215 +EXECUTE p_greater USING @maxint_plus_1; +colA +EXECUTE p_gret_eq USING @maxint; +colA +16777215 +EXECUTE p_greater USING @minint_minus_1; +colA +0 +1 +0 +1 +3 +16777214 +16777215 +EXECUTE p_less_eq USING @minint_minus_1; +colA +EXECUTE p_less_eq USING @minint; +colA +0 +0 +EXECUTE p_gret_eq USING @minint; +colA +0 +1 +0 +1 +3 +16777214 +16777215 +EXECUTE p_greater USING @minint; +colA +1 +1 +3 +16777214 +16777215 +EXECUTE p_eq USING @maxint_plus_1; +colA +EXECUTE p_equal USING @maxint_plus_1; +colA +EXECUTE p_n_eq USING @maxint_plus_1; +colA +0 +1 +0 +1 +3 +16777214 +16777215 +EXECUTE p_n_equal USING @maxint_plus_1; +colA +0 +1 +0 +1 +3 +16777214 +16777215 +NULL +EXECUTE p_eq USING @maxint; +colA +16777215 +EXECUTE p_equal USING @maxint; +colA +16777215 +EXECUTE p_n_eq USING @maxint; +colA +0 +1 +0 +1 +3 +16777214 +EXECUTE p_n_equal USING @maxint; +colA +0 +1 +0 +1 +3 +16777214 +NULL +EXECUTE p_eq USING @minint; +colA +0 +0 +EXECUTE p_equal USING @minint; +colA +0 +0 +EXECUTE p_n_eq USING @minint; +colA +1 +1 +3 +16777214 +16777215 +EXECUTE p_n_equal USING @minint; +colA +1 +1 +3 +16777214 +16777215 +NULL +EXECUTE p_eq USING @minint_minus_1; +colA +EXECUTE p_equal USING @minint_minus_1; +colA +EXECUTE p_n_eq USING @minint_minus_1; +colA +0 +1 +0 +1 +3 +16777214 +16777215 +EXECUTE p_n_equal USING @minint_minus_1; +colA +0 +1 +0 +1 +3 +16777214 +16777215 +NULL +DROP PREPARE p_less; +DROP PREPARE p_less_eq; +DROP PREPARE p_greater; +DROP PREPARE p_gret_eq; +DROP PREPARE p_equal; +DROP PREPARE p_n_eq; +DROP PREPARE p_n_equal; +EXPLAIN SELECT * FROM mediumtbl WHERE colA < 16777216; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE mediumtbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbl`.`colA` AS `colA` from `test`.`mediumtbl` where (`test`.`mediumtbl`.`colA` is not null) +EXPLAIN SELECT * FROM mediumtbl WHERE colA <= 16777215; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE mediumtbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbl`.`colA` AS `colA` from `test`.`mediumtbl` where (`test`.`mediumtbl`.`colA` is not null) +EXPLAIN SELECT * FROM mediumtbl WHERE colA > 16777216; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbl`.`colA` AS `colA` from `test`.`mediumtbl` where false +EXPLAIN SELECT * FROM mediumtbl WHERE colA >= 16777215; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE mediumtbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbl`.`colA` AS `colA` from `test`.`mediumtbl` where (`test`.`mediumtbl`.`colA` = 16777215) +EXPLAIN SELECT * FROM mediumtbl WHERE colA > -1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE mediumtbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbl`.`colA` AS `colA` from `test`.`mediumtbl` where (`test`.`mediumtbl`.`colA` is not null) +EXPLAIN SELECT * FROM mediumtbl WHERE colA <= -1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbl`.`colA` AS `colA` from `test`.`mediumtbl` where false +EXPLAIN SELECT * FROM mediumtbl WHERE colA <= 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE mediumtbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbl`.`colA` AS `colA` from `test`.`mediumtbl` where (`test`.`mediumtbl`.`colA` = 0) +EXPLAIN SELECT * FROM mediumtbl WHERE colA >= 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE mediumtbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbl`.`colA` AS `colA` from `test`.`mediumtbl` where (`test`.`mediumtbl`.`colA` is not null) +EXPLAIN SELECT * FROM mediumtbl WHERE colA > 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 33.33 Parallel execute (1 workers) +2 SIMPLE mediumtbl NULL ALL NULL NULL NULL NULL 8 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbl`.`colA` AS `colA` from `test`.`mediumtbl` where (`test`.`mediumtbl`.`colA` > 0) +EXPLAIN SELECT * FROM mediumtbl WHERE colA = 16777216; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbl`.`colA` AS `colA` from `test`.`mediumtbl` where false +EXPLAIN SELECT * FROM mediumtbl WHERE colA <=> 16777216; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbl`.`colA` AS `colA` from `test`.`mediumtbl` where false +EXPLAIN SELECT * FROM mediumtbl WHERE colA <> 16777216; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE mediumtbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbl`.`colA` AS `colA` from `test`.`mediumtbl` where (`test`.`mediumtbl`.`colA` is not null) +EXPLAIN SELECT * FROM mediumtbl WHERE colA = 16777215; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE mediumtbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbl`.`colA` AS `colA` from `test`.`mediumtbl` where (`test`.`mediumtbl`.`colA` = 16777215) +EXPLAIN SELECT * FROM mediumtbl WHERE colA <=> 16777215; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE mediumtbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbl`.`colA` AS `colA` from `test`.`mediumtbl` where (`test`.`mediumtbl`.`colA` <=> 16777215) +EXPLAIN SELECT * FROM mediumtbl WHERE colA <> 16777215; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE mediumtbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbl`.`colA` AS `colA` from `test`.`mediumtbl` where (`test`.`mediumtbl`.`colA` <> 16777215) +EXPLAIN SELECT * FROM mediumtbl WHERE colA = 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE mediumtbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbl`.`colA` AS `colA` from `test`.`mediumtbl` where (`test`.`mediumtbl`.`colA` = 0) +EXPLAIN SELECT * FROM mediumtbl WHERE colA <=> 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE mediumtbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbl`.`colA` AS `colA` from `test`.`mediumtbl` where (`test`.`mediumtbl`.`colA` <=> 0) +EXPLAIN SELECT * FROM mediumtbl WHERE colA <> 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE mediumtbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbl`.`colA` AS `colA` from `test`.`mediumtbl` where (`test`.`mediumtbl`.`colA` <> 0) +EXPLAIN SELECT * FROM mediumtbl WHERE colA = -1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbl`.`colA` AS `colA` from `test`.`mediumtbl` where false +EXPLAIN SELECT * FROM mediumtbl WHERE colA <=> -1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbl`.`colA` AS `colA` from `test`.`mediumtbl` where false +EXPLAIN SELECT * FROM mediumtbl WHERE colA <> -1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE mediumtbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbl`.`colA` AS `colA` from `test`.`mediumtbl` where (`test`.`mediumtbl`.`colA` is not null) +same queries but constant first +SELECT * FROM mediumtbl WHERE 16777216 > colA; +colA +0 +1 +0 +1 +3 +16777214 +16777215 +SELECT * FROM mediumtbl WHERE 16777215 >= colA; +colA +0 +1 +0 +1 +3 +16777214 +16777215 +SELECT * FROM mediumtbl WHERE 16777216 < colA; +colA +SELECT * FROM mediumtbl WHERE 16777215 <= colA; +colA +16777215 +SELECT * FROM mediumtbl WHERE 16777215 < colA; +colA +SELECT * FROM mediumtbl WHERE -1 < colA; +colA +0 +1 +0 +1 +3 +16777214 +16777215 +SELECT * FROM mediumtbl WHERE -1 >= colA; +colA +SELECT * FROM mediumtbl WHERE 0 >= colA; +colA +0 +0 +SELECT * FROM mediumtbl WHERE 0 <= colA; +colA +0 +1 +0 +1 +3 +16777214 +16777215 +SELECT * FROM mediumtbl WHERE 0 < colA; +colA +1 +1 +3 +16777214 +16777215 +SELECT * FROM mediumtbl WHERE 16777216 = colA; +colA +SELECT * FROM mediumtbl WHERE 16777216 <=> colA; +colA +SELECT * FROM mediumtbl WHERE 16777216 <> colA; +colA +0 +1 +0 +1 +3 +16777214 +16777215 +SELECT * FROM mediumtbl WHERE 16777215 = colA; +colA +16777215 +SELECT * FROM mediumtbl WHERE 16777215 <=> colA; +colA +16777215 +SELECT * FROM mediumtbl WHERE 16777215 <> colA; +colA +0 +1 +0 +1 +3 +16777214 +SELECT * FROM mediumtbl WHERE 0 = colA; +colA +0 +0 +SELECT * FROM mediumtbl WHERE 0 <=> colA; +colA +0 +0 +SELECT * FROM mediumtbl WHERE 0 <> colA; +colA +1 +1 +3 +16777214 +16777215 +SELECT * FROM mediumtbl WHERE -1 = colA; +colA +SELECT * FROM mediumtbl WHERE -1 <=> colA; +colA +SELECT * FROM mediumtbl WHERE -1 <> colA; +colA +0 +1 +0 +1 +3 +16777214 +16777215 +PREPARE p_less FROM 'SELECT * FROM mediumtbl WHERE ? < colA'; +PREPARE p_less_eq FROM 'SELECT * FROM mediumtbl WHERE ? <= colA'; +PREPARE p_greater FROM 'SELECT * FROM mediumtbl WHERE ? > colA'; +PREPARE p_gret_eq FROM 'SELECT * FROM mediumtbl WHERE ? >= colA'; +PREPARE p_eq FROM 'SELECT * FROM mediumtbl WHERE ? = colA'; +PREPARE p_equal FROM 'SELECT * FROM mediumtbl WHERE ? <=> colA'; +PREPARE p_n_eq FROM 'SELECT * FROM mediumtbl WHERE ? <> colA'; +PREPARE p_n_equal FROM 'SELECT * FROM mediumtbl WHERE NOT(? <=> colA)'; +EXECUTE p_greater USING @maxint_plus_1; +colA +0 +1 +0 +1 +3 +16777214 +16777215 +EXECUTE p_gret_eq USING @maxint; +colA +0 +1 +0 +1 +3 +16777214 +16777215 +EXECUTE p_less USING @maxint_plus_1; +colA +EXECUTE p_less_eq USING @maxint; +colA +16777215 +EXECUTE p_less USING @minint_minus_1; +colA +0 +1 +0 +1 +3 +16777214 +16777215 +EXECUTE p_gret_eq USING @minint_minus_1; +colA +EXECUTE p_gret_eq USING @minint; +colA +0 +0 +EXECUTE p_less_eq USING @minint; +colA +0 +1 +0 +1 +3 +16777214 +16777215 +EXECUTE p_less USING @minint; +colA +1 +1 +3 +16777214 +16777215 +EXECUTE p_eq USING @maxint_plus_1; +colA +EXECUTE p_equal USING @maxint_plus_1; +colA +EXECUTE p_n_eq USING @maxint_plus_1; +colA +0 +1 +0 +1 +3 +16777214 +16777215 +EXECUTE p_n_equal USING @maxint_plus_1; +colA +0 +1 +0 +1 +3 +16777214 +16777215 +NULL +EXECUTE p_eq USING @maxint; +colA +16777215 +EXECUTE p_equal USING @maxint; +colA +16777215 +EXECUTE p_n_eq USING @maxint; +colA +0 +1 +0 +1 +3 +16777214 +EXECUTE p_n_equal USING @maxint; +colA +0 +1 +0 +1 +3 +16777214 +NULL +EXECUTE p_eq USING @minint; +colA +0 +0 +EXECUTE p_equal USING @minint; +colA +0 +0 +EXECUTE p_n_eq USING @minint; +colA +1 +1 +3 +16777214 +16777215 +EXECUTE p_n_equal USING @minint; +colA +1 +1 +3 +16777214 +16777215 +NULL +EXECUTE p_eq USING @minint_minus_1; +colA +EXECUTE p_equal USING @minint_minus_1; +colA +EXECUTE p_n_eq USING @minint_minus_1; +colA +0 +1 +0 +1 +3 +16777214 +16777215 +EXECUTE p_n_equal USING @minint_minus_1; +colA +0 +1 +0 +1 +3 +16777214 +16777215 +NULL +DROP PREPARE p_less; +DROP PREPARE p_less_eq; +DROP PREPARE p_greater; +DROP PREPARE p_gret_eq; +DROP PREPARE p_equal; +DROP PREPARE p_n_eq; +DROP PREPARE p_n_equal; +EXPLAIN SELECT * FROM mediumtbl WHERE 16777216 > colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE mediumtbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbl`.`colA` AS `colA` from `test`.`mediumtbl` where (`test`.`mediumtbl`.`colA` is not null) +EXPLAIN SELECT * FROM mediumtbl WHERE 16777215 >= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE mediumtbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbl`.`colA` AS `colA` from `test`.`mediumtbl` where (`test`.`mediumtbl`.`colA` is not null) +EXPLAIN SELECT * FROM mediumtbl WHERE 16777216 < colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbl`.`colA` AS `colA` from `test`.`mediumtbl` where false +EXPLAIN SELECT * FROM mediumtbl WHERE 16777215 <= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE mediumtbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbl`.`colA` AS `colA` from `test`.`mediumtbl` where (16777215 = `test`.`mediumtbl`.`colA`) +EXPLAIN SELECT * FROM mediumtbl WHERE 16777215 < colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbl`.`colA` AS `colA` from `test`.`mediumtbl` where false +EXPLAIN SELECT * FROM mediumtbl WHERE -1 < colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE mediumtbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbl`.`colA` AS `colA` from `test`.`mediumtbl` where (`test`.`mediumtbl`.`colA` is not null) +EXPLAIN SELECT * FROM mediumtbl WHERE -1 >= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbl`.`colA` AS `colA` from `test`.`mediumtbl` where false +EXPLAIN SELECT * FROM mediumtbl WHERE 0 >= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE mediumtbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbl`.`colA` AS `colA` from `test`.`mediumtbl` where (0 = `test`.`mediumtbl`.`colA`) +EXPLAIN SELECT * FROM mediumtbl WHERE 0 <= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE mediumtbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbl`.`colA` AS `colA` from `test`.`mediumtbl` where (`test`.`mediumtbl`.`colA` is not null) +EXPLAIN SELECT * FROM mediumtbl WHERE 0 < colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 33.33 Parallel execute (1 workers) +2 SIMPLE mediumtbl NULL ALL NULL NULL NULL NULL 8 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbl`.`colA` AS `colA` from `test`.`mediumtbl` where (0 < `test`.`mediumtbl`.`colA`) +EXPLAIN SELECT * FROM mediumtbl WHERE 16777216 = colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbl`.`colA` AS `colA` from `test`.`mediumtbl` where false +EXPLAIN SELECT * FROM mediumtbl WHERE 16777216 <=> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbl`.`colA` AS `colA` from `test`.`mediumtbl` where false +EXPLAIN SELECT * FROM mediumtbl WHERE 16777216 <> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE mediumtbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbl`.`colA` AS `colA` from `test`.`mediumtbl` where (`test`.`mediumtbl`.`colA` is not null) +EXPLAIN SELECT * FROM mediumtbl WHERE 16777215 = colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE mediumtbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbl`.`colA` AS `colA` from `test`.`mediumtbl` where (`test`.`mediumtbl`.`colA` = 16777215) +EXPLAIN SELECT * FROM mediumtbl WHERE 16777215 <=> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE mediumtbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbl`.`colA` AS `colA` from `test`.`mediumtbl` where (16777215 <=> `test`.`mediumtbl`.`colA`) +EXPLAIN SELECT * FROM mediumtbl WHERE 16777215 <> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE mediumtbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbl`.`colA` AS `colA` from `test`.`mediumtbl` where (16777215 <> `test`.`mediumtbl`.`colA`) +EXPLAIN SELECT * FROM mediumtbl WHERE 0 = colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE mediumtbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbl`.`colA` AS `colA` from `test`.`mediumtbl` where (`test`.`mediumtbl`.`colA` = 0) +EXPLAIN SELECT * FROM mediumtbl WHERE 0 <=> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE mediumtbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbl`.`colA` AS `colA` from `test`.`mediumtbl` where (0 <=> `test`.`mediumtbl`.`colA`) +EXPLAIN SELECT * FROM mediumtbl WHERE 0 <> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE mediumtbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbl`.`colA` AS `colA` from `test`.`mediumtbl` where (0 <> `test`.`mediumtbl`.`colA`) +EXPLAIN SELECT * FROM mediumtbl WHERE -1 = colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbl`.`colA` AS `colA` from `test`.`mediumtbl` where false +EXPLAIN SELECT * FROM mediumtbl WHERE -1 <=> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbl`.`colA` AS `colA` from `test`.`mediumtbl` where false +EXPLAIN SELECT * FROM mediumtbl WHERE -1 <> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE mediumtbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbl`.`colA` AS `colA` from `test`.`mediumtbl` where (`test`.`mediumtbl`.`colA` is not null) +DROP TABLE mediumtbl; +# +# Tests with UNSIGNED type MEDIUMINT NOT NULL against int +# +CREATE TABLE mediumtbl (colA MEDIUMINT UNSIGNED NOT NULL); +INSERT INTO mediumtbl VALUES (0), (1), +(0),(1),(3), +(16777214), (16777215), +(0); +ANALYZE TABLE mediumtbl; +Table Op Msg_type Msg_text +test.mediumtbl analyze status OK +SELECT * FROM mediumtbl; +colA +0 +1 +0 +1 +3 +16777214 +16777215 +0 +SELECT * FROM mediumtbl WHERE colA < 16777216; +colA +0 +1 +0 +1 +3 +16777214 +16777215 +0 +SELECT * FROM mediumtbl WHERE colA <= 16777215; +colA +0 +1 +0 +1 +3 +16777214 +16777215 +0 +SELECT * FROM mediumtbl WHERE colA > 16777216; +colA +SELECT * FROM mediumtbl WHERE colA >= 16777215; +colA +16777215 +SELECT * FROM mediumtbl WHERE colA > -1; +colA +0 +1 +0 +1 +3 +16777214 +16777215 +0 +SELECT * FROM mediumtbl WHERE colA <= -1; +colA +SELECT * FROM mediumtbl WHERE colA <= 0; +colA +0 +0 +0 +SELECT * FROM mediumtbl WHERE colA >= 0; +colA +0 +1 +0 +1 +3 +16777214 +16777215 +0 +SELECT * FROM mediumtbl WHERE colA > 0; +colA +1 +1 +3 +16777214 +16777215 +SELECT * FROM mediumtbl WHERE colA = 16777216; +colA +SELECT * FROM mediumtbl WHERE colA <> 16777216; +colA +0 +1 +0 +1 +3 +16777214 +16777215 +0 +SELECT * FROM mediumtbl WHERE colA = 16777215; +colA +16777215 +SELECT * FROM mediumtbl WHERE colA <=> 16777215; +colA +16777215 +SELECT * FROM mediumtbl WHERE NOT(colA <=> 16777215); +colA +0 +1 +0 +1 +3 +16777214 +0 +SELECT * FROM mediumtbl WHERE colA <> 16777215; +colA +0 +1 +0 +1 +3 +16777214 +0 +SELECT * FROM mediumtbl WHERE colA = 0; +colA +0 +0 +0 +SELECT * FROM mediumtbl WHERE colA <=> 0; +colA +0 +0 +0 +SELECT * FROM mediumtbl WHERE NOT(colA <=> 0); +colA +1 +1 +3 +16777214 +16777215 +SELECT * FROM mediumtbl WHERE colA <> 0; +colA +1 +1 +3 +16777214 +16777215 +SELECT * FROM mediumtbl WHERE colA = -1; +colA +SELECT * FROM mediumtbl WHERE colA <=> -1; +colA +SELECT * FROM mediumtbl WHERE NOT(colA <=> -1); +colA +0 +1 +0 +1 +3 +16777214 +16777215 +0 +SELECT * FROM mediumtbl WHERE colA <> -1; +colA +0 +1 +0 +1 +3 +16777214 +16777215 +0 +PREPARE p_less FROM 'SELECT * FROM mediumtbl WHERE colA < ?'; +PREPARE p_less_eq FROM 'SELECT * FROM mediumtbl WHERE colA <= ?'; +PREPARE p_greater FROM 'SELECT * FROM mediumtbl WHERE colA > ?'; +PREPARE p_gret_eq FROM 'SELECT * FROM mediumtbl WHERE colA >= ?'; +PREPARE p_eq FROM 'SELECT * FROM mediumtbl WHERE colA = ?'; +PREPARE p_equal FROM 'SELECT * FROM mediumtbl WHERE colA <=> ?'; +PREPARE p_n_equal FROM 'SELECT * FROM mediumtbl WHERE NOT(colA <=> ?)'; +PREPARE p_n_eq FROM 'SELECT * FROM mediumtbl WHERE colA <> ?'; +SET @maxint_plus_1=16777216; +SET @maxint=16777215; +SET @minint_minus_1=-1; +SET @minint=0; +EXECUTE p_less USING @maxint_plus_1; +colA +0 +1 +0 +1 +3 +16777214 +16777215 +0 +EXECUTE p_less_eq USING @maxint; +colA +0 +1 +0 +1 +3 +16777214 +16777215 +0 +EXECUTE p_greater USING @maxint_plus_1; +colA +EXECUTE p_gret_eq USING @maxint; +colA +16777215 +EXECUTE p_greater USING @minint_minus_1; +colA +0 +1 +0 +1 +3 +16777214 +16777215 +0 +EXECUTE p_less_eq USING @minint_minus_1; +colA +EXECUTE p_less_eq USING @minint; +colA +0 +0 +0 +EXECUTE p_gret_eq USING @minint; +colA +0 +1 +0 +1 +3 +16777214 +16777215 +0 +EXECUTE p_greater USING @minint; +colA +1 +1 +3 +16777214 +16777215 +EXECUTE p_eq USING @maxint_plus_1; +colA +EXECUTE p_equal USING @maxint_plus_1; +colA +EXECUTE p_n_eq USING @maxint_plus_1; +colA +0 +1 +0 +1 +3 +16777214 +16777215 +0 +EXECUTE p_n_equal USING @maxint_plus_1; +colA +0 +1 +0 +1 +3 +16777214 +16777215 +0 +EXECUTE p_eq USING @maxint; +colA +16777215 +EXECUTE p_equal USING @maxint; +colA +16777215 +EXECUTE p_n_eq USING @maxint; +colA +0 +1 +0 +1 +3 +16777214 +0 +EXECUTE p_n_equal USING @maxint; +colA +0 +1 +0 +1 +3 +16777214 +0 +EXECUTE p_eq USING @minint; +colA +0 +0 +0 +EXECUTE p_equal USING @minint; +colA +0 +0 +0 +EXECUTE p_n_eq USING @minint; +colA +1 +1 +3 +16777214 +16777215 +EXECUTE p_n_equal USING @minint; +colA +1 +1 +3 +16777214 +16777215 +EXECUTE p_eq USING @minint_minus_1; +colA +EXECUTE p_equal USING @minint_minus_1; +colA +EXECUTE p_n_eq USING @minint_minus_1; +colA +0 +1 +0 +1 +3 +16777214 +16777215 +0 +EXECUTE p_n_equal USING @minint_minus_1; +colA +0 +1 +0 +1 +3 +16777214 +16777215 +0 +DROP PREPARE p_less; +DROP PREPARE p_less_eq; +DROP PREPARE p_greater; +DROP PREPARE p_gret_eq; +DROP PREPARE p_equal; +DROP PREPARE p_n_eq; +DROP PREPARE p_n_equal; +EXPLAIN SELECT * FROM mediumtbl WHERE colA < 16777216; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE mediumtbl NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbl`.`colA` AS `colA` from `test`.`mediumtbl` where true +EXPLAIN SELECT * FROM mediumtbl WHERE colA <= 16777215; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE mediumtbl NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbl`.`colA` AS `colA` from `test`.`mediumtbl` where true +EXPLAIN SELECT * FROM mediumtbl WHERE colA > 16777216; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbl`.`colA` AS `colA` from `test`.`mediumtbl` where false +EXPLAIN SELECT * FROM mediumtbl WHERE colA >= 16777215; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE mediumtbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbl`.`colA` AS `colA` from `test`.`mediumtbl` where (`test`.`mediumtbl`.`colA` = 16777215) +EXPLAIN SELECT * FROM mediumtbl WHERE colA > -1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE mediumtbl NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbl`.`colA` AS `colA` from `test`.`mediumtbl` where true +EXPLAIN SELECT * FROM mediumtbl WHERE colA <= -1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbl`.`colA` AS `colA` from `test`.`mediumtbl` where false +EXPLAIN SELECT * FROM mediumtbl WHERE colA <= 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE mediumtbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbl`.`colA` AS `colA` from `test`.`mediumtbl` where (`test`.`mediumtbl`.`colA` = 0) +EXPLAIN SELECT * FROM mediumtbl WHERE colA >= 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE mediumtbl NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbl`.`colA` AS `colA` from `test`.`mediumtbl` where true +EXPLAIN SELECT * FROM mediumtbl WHERE colA > 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 33.33 Parallel execute (1 workers) +2 SIMPLE mediumtbl NULL ALL NULL NULL NULL NULL 8 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbl`.`colA` AS `colA` from `test`.`mediumtbl` where (`test`.`mediumtbl`.`colA` > 0) +EXPLAIN SELECT * FROM mediumtbl WHERE colA = 16777216; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbl`.`colA` AS `colA` from `test`.`mediumtbl` where false +EXPLAIN SELECT * FROM mediumtbl WHERE colA <=> 16777216; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbl`.`colA` AS `colA` from `test`.`mediumtbl` where false +EXPLAIN SELECT * FROM mediumtbl WHERE colA <> 16777216; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE mediumtbl NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbl`.`colA` AS `colA` from `test`.`mediumtbl` where true +EXPLAIN SELECT * FROM mediumtbl WHERE colA = 16777215; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE mediumtbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbl`.`colA` AS `colA` from `test`.`mediumtbl` where (`test`.`mediumtbl`.`colA` = 16777215) +EXPLAIN SELECT * FROM mediumtbl WHERE colA <=> 16777215; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE mediumtbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbl`.`colA` AS `colA` from `test`.`mediumtbl` where (`test`.`mediumtbl`.`colA` <=> 16777215) +EXPLAIN SELECT * FROM mediumtbl WHERE colA <> 16777215; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE mediumtbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbl`.`colA` AS `colA` from `test`.`mediumtbl` where (`test`.`mediumtbl`.`colA` <> 16777215) +EXPLAIN SELECT * FROM mediumtbl WHERE colA = 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE mediumtbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbl`.`colA` AS `colA` from `test`.`mediumtbl` where (`test`.`mediumtbl`.`colA` = 0) +EXPLAIN SELECT * FROM mediumtbl WHERE colA <=> 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE mediumtbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbl`.`colA` AS `colA` from `test`.`mediumtbl` where (`test`.`mediumtbl`.`colA` <=> 0) +EXPLAIN SELECT * FROM mediumtbl WHERE colA <> 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE mediumtbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbl`.`colA` AS `colA` from `test`.`mediumtbl` where (`test`.`mediumtbl`.`colA` <> 0) +EXPLAIN SELECT * FROM mediumtbl WHERE colA = -1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbl`.`colA` AS `colA` from `test`.`mediumtbl` where false +EXPLAIN SELECT * FROM mediumtbl WHERE colA <=> -1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbl`.`colA` AS `colA` from `test`.`mediumtbl` where false +EXPLAIN SELECT * FROM mediumtbl WHERE colA <> -1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE mediumtbl NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbl`.`colA` AS `colA` from `test`.`mediumtbl` where true +same queries but constant first +SELECT * FROM mediumtbl WHERE 16777216 > colA; +colA +0 +1 +0 +1 +3 +16777214 +16777215 +0 +SELECT * FROM mediumtbl WHERE 16777215 >= colA; +colA +0 +1 +0 +1 +3 +16777214 +16777215 +0 +SELECT * FROM mediumtbl WHERE 16777216 < colA; +colA +SELECT * FROM mediumtbl WHERE 16777215 <= colA; +colA +16777215 +SELECT * FROM mediumtbl WHERE 16777215 < colA; +colA +SELECT * FROM mediumtbl WHERE -1 < colA; +colA +0 +1 +0 +1 +3 +16777214 +16777215 +0 +SELECT * FROM mediumtbl WHERE -1 >= colA; +colA +SELECT * FROM mediumtbl WHERE 0 >= colA; +colA +0 +0 +0 +SELECT * FROM mediumtbl WHERE 0 <= colA; +colA +0 +1 +0 +1 +3 +16777214 +16777215 +0 +SELECT * FROM mediumtbl WHERE 0 < colA; +colA +1 +1 +3 +16777214 +16777215 +SELECT * FROM mediumtbl WHERE 16777216 = colA; +colA +SELECT * FROM mediumtbl WHERE 16777216 <=> colA; +colA +SELECT * FROM mediumtbl WHERE 16777216 <> colA; +colA +0 +1 +0 +1 +3 +16777214 +16777215 +0 +SELECT * FROM mediumtbl WHERE 16777215 = colA; +colA +16777215 +SELECT * FROM mediumtbl WHERE 16777215 <=> colA; +colA +16777215 +SELECT * FROM mediumtbl WHERE 16777215 <> colA; +colA +0 +1 +0 +1 +3 +16777214 +0 +SELECT * FROM mediumtbl WHERE 0 = colA; +colA +0 +0 +0 +SELECT * FROM mediumtbl WHERE 0 <=> colA; +colA +0 +0 +0 +SELECT * FROM mediumtbl WHERE 0 <> colA; +colA +1 +1 +3 +16777214 +16777215 +SELECT * FROM mediumtbl WHERE -1 = colA; +colA +SELECT * FROM mediumtbl WHERE -1 <=> colA; +colA +SELECT * FROM mediumtbl WHERE -1 <> colA; +colA +0 +1 +0 +1 +3 +16777214 +16777215 +0 +PREPARE p_less FROM 'SELECT * FROM mediumtbl WHERE ? < colA'; +PREPARE p_less_eq FROM 'SELECT * FROM mediumtbl WHERE ? <= colA'; +PREPARE p_greater FROM 'SELECT * FROM mediumtbl WHERE ? > colA'; +PREPARE p_gret_eq FROM 'SELECT * FROM mediumtbl WHERE ? >= colA'; +PREPARE p_eq FROM 'SELECT * FROM mediumtbl WHERE ? = colA'; +PREPARE p_equal FROM 'SELECT * FROM mediumtbl WHERE ? <=> colA'; +PREPARE p_n_eq FROM 'SELECT * FROM mediumtbl WHERE ? <> colA'; +PREPARE p_n_equal FROM 'SELECT * FROM mediumtbl WHERE NOT(? <=> colA)'; +EXECUTE p_greater USING @maxint_plus_1; +colA +0 +1 +0 +1 +3 +16777214 +16777215 +0 +EXECUTE p_gret_eq USING @maxint; +colA +0 +1 +0 +1 +3 +16777214 +16777215 +0 +EXECUTE p_less USING @maxint_plus_1; +colA +EXECUTE p_less_eq USING @maxint; +colA +16777215 +EXECUTE p_less USING @minint_minus_1; +colA +0 +1 +0 +1 +3 +16777214 +16777215 +0 +EXECUTE p_gret_eq USING @minint_minus_1; +colA +EXECUTE p_gret_eq USING @minint; +colA +0 +0 +0 +EXECUTE p_less_eq USING @minint; +colA +0 +1 +0 +1 +3 +16777214 +16777215 +0 +EXECUTE p_less USING @minint; +colA +1 +1 +3 +16777214 +16777215 +EXECUTE p_eq USING @maxint_plus_1; +colA +EXECUTE p_equal USING @maxint_plus_1; +colA +EXECUTE p_n_eq USING @maxint_plus_1; +colA +0 +1 +0 +1 +3 +16777214 +16777215 +0 +EXECUTE p_n_equal USING @maxint_plus_1; +colA +0 +1 +0 +1 +3 +16777214 +16777215 +0 +EXECUTE p_eq USING @maxint; +colA +16777215 +EXECUTE p_equal USING @maxint; +colA +16777215 +EXECUTE p_n_eq USING @maxint; +colA +0 +1 +0 +1 +3 +16777214 +0 +EXECUTE p_n_equal USING @maxint; +colA +0 +1 +0 +1 +3 +16777214 +0 +EXECUTE p_eq USING @minint; +colA +0 +0 +0 +EXECUTE p_equal USING @minint; +colA +0 +0 +0 +EXECUTE p_n_eq USING @minint; +colA +1 +1 +3 +16777214 +16777215 +EXECUTE p_n_equal USING @minint; +colA +1 +1 +3 +16777214 +16777215 +EXECUTE p_eq USING @minint_minus_1; +colA +EXECUTE p_equal USING @minint_minus_1; +colA +EXECUTE p_n_eq USING @minint_minus_1; +colA +0 +1 +0 +1 +3 +16777214 +16777215 +0 +EXECUTE p_n_equal USING @minint_minus_1; +colA +0 +1 +0 +1 +3 +16777214 +16777215 +0 +DROP PREPARE p_less; +DROP PREPARE p_less_eq; +DROP PREPARE p_greater; +DROP PREPARE p_gret_eq; +DROP PREPARE p_equal; +DROP PREPARE p_n_eq; +DROP PREPARE p_n_equal; +EXPLAIN SELECT * FROM mediumtbl WHERE 16777216 > colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE mediumtbl NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbl`.`colA` AS `colA` from `test`.`mediumtbl` where true +EXPLAIN SELECT * FROM mediumtbl WHERE 16777215 >= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE mediumtbl NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbl`.`colA` AS `colA` from `test`.`mediumtbl` where true +EXPLAIN SELECT * FROM mediumtbl WHERE 16777216 < colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbl`.`colA` AS `colA` from `test`.`mediumtbl` where false +EXPLAIN SELECT * FROM mediumtbl WHERE 16777215 <= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE mediumtbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbl`.`colA` AS `colA` from `test`.`mediumtbl` where (16777215 = `test`.`mediumtbl`.`colA`) +EXPLAIN SELECT * FROM mediumtbl WHERE 16777215 < colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbl`.`colA` AS `colA` from `test`.`mediumtbl` where false +EXPLAIN SELECT * FROM mediumtbl WHERE -1 < colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE mediumtbl NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbl`.`colA` AS `colA` from `test`.`mediumtbl` where true +EXPLAIN SELECT * FROM mediumtbl WHERE -1 >= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbl`.`colA` AS `colA` from `test`.`mediumtbl` where false +EXPLAIN SELECT * FROM mediumtbl WHERE 0 >= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE mediumtbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbl`.`colA` AS `colA` from `test`.`mediumtbl` where (0 = `test`.`mediumtbl`.`colA`) +EXPLAIN SELECT * FROM mediumtbl WHERE 0 <= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE mediumtbl NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbl`.`colA` AS `colA` from `test`.`mediumtbl` where true +EXPLAIN SELECT * FROM mediumtbl WHERE 0 < colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 33.33 Parallel execute (1 workers) +2 SIMPLE mediumtbl NULL ALL NULL NULL NULL NULL 8 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbl`.`colA` AS `colA` from `test`.`mediumtbl` where (0 < `test`.`mediumtbl`.`colA`) +EXPLAIN SELECT * FROM mediumtbl WHERE 16777216 = colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbl`.`colA` AS `colA` from `test`.`mediumtbl` where false +EXPLAIN SELECT * FROM mediumtbl WHERE 16777216 <=> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbl`.`colA` AS `colA` from `test`.`mediumtbl` where false +EXPLAIN SELECT * FROM mediumtbl WHERE 16777216 <> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE mediumtbl NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbl`.`colA` AS `colA` from `test`.`mediumtbl` where true +EXPLAIN SELECT * FROM mediumtbl WHERE 16777215 = colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE mediumtbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbl`.`colA` AS `colA` from `test`.`mediumtbl` where (`test`.`mediumtbl`.`colA` = 16777215) +EXPLAIN SELECT * FROM mediumtbl WHERE 16777215 <=> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE mediumtbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbl`.`colA` AS `colA` from `test`.`mediumtbl` where (16777215 <=> `test`.`mediumtbl`.`colA`) +EXPLAIN SELECT * FROM mediumtbl WHERE 16777215 <> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE mediumtbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbl`.`colA` AS `colA` from `test`.`mediumtbl` where (16777215 <> `test`.`mediumtbl`.`colA`) +EXPLAIN SELECT * FROM mediumtbl WHERE 0 = colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE mediumtbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbl`.`colA` AS `colA` from `test`.`mediumtbl` where (`test`.`mediumtbl`.`colA` = 0) +EXPLAIN SELECT * FROM mediumtbl WHERE 0 <=> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE mediumtbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbl`.`colA` AS `colA` from `test`.`mediumtbl` where (0 <=> `test`.`mediumtbl`.`colA`) +EXPLAIN SELECT * FROM mediumtbl WHERE 0 <> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE mediumtbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbl`.`colA` AS `colA` from `test`.`mediumtbl` where (0 <> `test`.`mediumtbl`.`colA`) +EXPLAIN SELECT * FROM mediumtbl WHERE -1 = colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbl`.`colA` AS `colA` from `test`.`mediumtbl` where false +EXPLAIN SELECT * FROM mediumtbl WHERE -1 <=> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbl`.`colA` AS `colA` from `test`.`mediumtbl` where false +EXPLAIN SELECT * FROM mediumtbl WHERE -1 <> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE mediumtbl NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbl`.`colA` AS `colA` from `test`.`mediumtbl` where true +DROP TABLE mediumtbl; +# +# Tests with type MEDIUMINT against int +# +CREATE TABLE mediumtbls (colA MEDIUMINT ); +INSERT INTO mediumtbls VALUES (-8388608), (-8388607), +(0),(1),(3), +(8388606), (8388607), +(NULL); +ANALYZE TABLE mediumtbls; +Table Op Msg_type Msg_text +test.mediumtbls analyze status OK +SELECT * FROM mediumtbls; +colA +-8388608 +-8388607 +0 +1 +3 +8388606 +8388607 +NULL +SELECT * FROM mediumtbls WHERE colA < 8388608; +colA +-8388608 +-8388607 +0 +1 +3 +8388606 +8388607 +SELECT * FROM mediumtbls WHERE colA <= 8388607; +colA +-8388608 +-8388607 +0 +1 +3 +8388606 +8388607 +SELECT * FROM mediumtbls WHERE colA > 8388608; +colA +SELECT * FROM mediumtbls WHERE colA >= 8388607; +colA +8388607 +SELECT * FROM mediumtbls WHERE colA > -8388609; +colA +-8388608 +-8388607 +0 +1 +3 +8388606 +8388607 +SELECT * FROM mediumtbls WHERE colA <= -8388609; +colA +SELECT * FROM mediumtbls WHERE colA <= -8388608; +colA +-8388608 +SELECT * FROM mediumtbls WHERE colA >= -8388608; +colA +-8388608 +-8388607 +0 +1 +3 +8388606 +8388607 +SELECT * FROM mediumtbls WHERE colA > -8388608; +colA +-8388607 +0 +1 +3 +8388606 +8388607 +SELECT * FROM mediumtbls WHERE colA = 8388608; +colA +SELECT * FROM mediumtbls WHERE colA <> 8388608; +colA +-8388608 +-8388607 +0 +1 +3 +8388606 +8388607 +SELECT * FROM mediumtbls WHERE colA = 8388607; +colA +8388607 +SELECT * FROM mediumtbls WHERE colA <=> 8388607; +colA +8388607 +SELECT * FROM mediumtbls WHERE NOT(colA <=> 8388607); +colA +-8388608 +-8388607 +0 +1 +3 +8388606 +NULL +SELECT * FROM mediumtbls WHERE colA <> 8388607; +colA +-8388608 +-8388607 +0 +1 +3 +8388606 +SELECT * FROM mediumtbls WHERE colA = -8388608; +colA +-8388608 +SELECT * FROM mediumtbls WHERE colA <=> -8388608; +colA +-8388608 +SELECT * FROM mediumtbls WHERE NOT(colA <=> -8388608); +colA +-8388607 +0 +1 +3 +8388606 +8388607 +NULL +SELECT * FROM mediumtbls WHERE colA <> -8388608; +colA +-8388607 +0 +1 +3 +8388606 +8388607 +SELECT * FROM mediumtbls WHERE colA = -8388609; +colA +SELECT * FROM mediumtbls WHERE colA <=> -8388609; +colA +SELECT * FROM mediumtbls WHERE NOT(colA <=> -8388609); +colA +-8388608 +-8388607 +0 +1 +3 +8388606 +8388607 +NULL +SELECT * FROM mediumtbls WHERE colA <> -8388609; +colA +-8388608 +-8388607 +0 +1 +3 +8388606 +8388607 +PREPARE p_less FROM 'SELECT * FROM mediumtbls WHERE colA < ?'; +PREPARE p_less_eq FROM 'SELECT * FROM mediumtbls WHERE colA <= ?'; +PREPARE p_greater FROM 'SELECT * FROM mediumtbls WHERE colA > ?'; +PREPARE p_gret_eq FROM 'SELECT * FROM mediumtbls WHERE colA >= ?'; +PREPARE p_eq FROM 'SELECT * FROM mediumtbls WHERE colA = ?'; +PREPARE p_equal FROM 'SELECT * FROM mediumtbls WHERE colA <=> ?'; +PREPARE p_n_equal FROM 'SELECT * FROM mediumtbls WHERE NOT(colA <=> ?)'; +PREPARE p_n_eq FROM 'SELECT * FROM mediumtbls WHERE colA <> ?'; +SET @maxint_plus_1=8388608; +SET @maxint=8388607; +SET @minint_minus_1=-8388609; +SET @minint=-8388608; +EXECUTE p_less USING @maxint_plus_1; +colA +-8388608 +-8388607 +0 +1 +3 +8388606 +8388607 +EXECUTE p_less_eq USING @maxint; +colA +-8388608 +-8388607 +0 +1 +3 +8388606 +8388607 +EXECUTE p_greater USING @maxint_plus_1; +colA +EXECUTE p_gret_eq USING @maxint; +colA +8388607 +EXECUTE p_greater USING @minint_minus_1; +colA +-8388608 +-8388607 +0 +1 +3 +8388606 +8388607 +EXECUTE p_less_eq USING @minint_minus_1; +colA +EXECUTE p_less_eq USING @minint; +colA +-8388608 +EXECUTE p_gret_eq USING @minint; +colA +-8388608 +-8388607 +0 +1 +3 +8388606 +8388607 +EXECUTE p_greater USING @minint; +colA +-8388607 +0 +1 +3 +8388606 +8388607 +EXECUTE p_eq USING @maxint_plus_1; +colA +EXECUTE p_equal USING @maxint_plus_1; +colA +EXECUTE p_n_eq USING @maxint_plus_1; +colA +-8388608 +-8388607 +0 +1 +3 +8388606 +8388607 +EXECUTE p_n_equal USING @maxint_plus_1; +colA +-8388608 +-8388607 +0 +1 +3 +8388606 +8388607 +NULL +EXECUTE p_eq USING @maxint; +colA +8388607 +EXECUTE p_equal USING @maxint; +colA +8388607 +EXECUTE p_n_eq USING @maxint; +colA +-8388608 +-8388607 +0 +1 +3 +8388606 +EXECUTE p_n_equal USING @maxint; +colA +-8388608 +-8388607 +0 +1 +3 +8388606 +NULL +EXECUTE p_eq USING @minint; +colA +-8388608 +EXECUTE p_equal USING @minint; +colA +-8388608 +EXECUTE p_n_eq USING @minint; +colA +-8388607 +0 +1 +3 +8388606 +8388607 +EXECUTE p_n_equal USING @minint; +colA +-8388607 +0 +1 +3 +8388606 +8388607 +NULL +EXECUTE p_eq USING @minint_minus_1; +colA +EXECUTE p_equal USING @minint_minus_1; +colA +EXECUTE p_n_eq USING @minint_minus_1; +colA +-8388608 +-8388607 +0 +1 +3 +8388606 +8388607 +EXECUTE p_n_equal USING @minint_minus_1; +colA +-8388608 +-8388607 +0 +1 +3 +8388606 +8388607 +NULL +DROP PREPARE p_less; +DROP PREPARE p_less_eq; +DROP PREPARE p_greater; +DROP PREPARE p_gret_eq; +DROP PREPARE p_equal; +DROP PREPARE p_n_eq; +DROP PREPARE p_n_equal; +EXPLAIN SELECT * FROM mediumtbls WHERE colA < 8388608; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE mediumtbls NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbls`.`colA` AS `colA` from `test`.`mediumtbls` where (`test`.`mediumtbls`.`colA` is not null) +EXPLAIN SELECT * FROM mediumtbls WHERE colA <= 8388607; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE mediumtbls NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbls`.`colA` AS `colA` from `test`.`mediumtbls` where (`test`.`mediumtbls`.`colA` is not null) +EXPLAIN SELECT * FROM mediumtbls WHERE colA > 8388608; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbls`.`colA` AS `colA` from `test`.`mediumtbls` where false +EXPLAIN SELECT * FROM mediumtbls WHERE colA >= 8388607; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE mediumtbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbls`.`colA` AS `colA` from `test`.`mediumtbls` where (`test`.`mediumtbls`.`colA` = 8388607) +EXPLAIN SELECT * FROM mediumtbls WHERE colA > -8388609; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE mediumtbls NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbls`.`colA` AS `colA` from `test`.`mediumtbls` where (`test`.`mediumtbls`.`colA` is not null) +EXPLAIN SELECT * FROM mediumtbls WHERE colA <= -8388609; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbls`.`colA` AS `colA` from `test`.`mediumtbls` where false +EXPLAIN SELECT * FROM mediumtbls WHERE colA <= -8388608; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE mediumtbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbls`.`colA` AS `colA` from `test`.`mediumtbls` where (`test`.`mediumtbls`.`colA` = (-(8388608))) +EXPLAIN SELECT * FROM mediumtbls WHERE colA >= -8388608; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE mediumtbls NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbls`.`colA` AS `colA` from `test`.`mediumtbls` where (`test`.`mediumtbls`.`colA` is not null) +EXPLAIN SELECT * FROM mediumtbls WHERE colA > -8388608; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 33.33 Parallel execute (1 workers) +2 SIMPLE mediumtbls NULL ALL NULL NULL NULL NULL 8 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbls`.`colA` AS `colA` from `test`.`mediumtbls` where (`test`.`mediumtbls`.`colA` > (-(8388608))) +EXPLAIN SELECT * FROM mediumtbls WHERE colA = 8388608; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbls`.`colA` AS `colA` from `test`.`mediumtbls` where false +EXPLAIN SELECT * FROM mediumtbls WHERE colA <=> 8388608; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbls`.`colA` AS `colA` from `test`.`mediumtbls` where false +EXPLAIN SELECT * FROM mediumtbls WHERE colA <> 8388608; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE mediumtbls NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbls`.`colA` AS `colA` from `test`.`mediumtbls` where (`test`.`mediumtbls`.`colA` is not null) +EXPLAIN SELECT * FROM mediumtbls WHERE colA = 8388607; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE mediumtbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbls`.`colA` AS `colA` from `test`.`mediumtbls` where (`test`.`mediumtbls`.`colA` = 8388607) +EXPLAIN SELECT * FROM mediumtbls WHERE colA <=> 8388607; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE mediumtbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbls`.`colA` AS `colA` from `test`.`mediumtbls` where (`test`.`mediumtbls`.`colA` <=> 8388607) +EXPLAIN SELECT * FROM mediumtbls WHERE colA <> 8388607; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE mediumtbls NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbls`.`colA` AS `colA` from `test`.`mediumtbls` where (`test`.`mediumtbls`.`colA` <> 8388607) +EXPLAIN SELECT * FROM mediumtbls WHERE colA = -8388608; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE mediumtbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbls`.`colA` AS `colA` from `test`.`mediumtbls` where (`test`.`mediumtbls`.`colA` = (-(8388608))) +EXPLAIN SELECT * FROM mediumtbls WHERE colA <=> -8388608; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE mediumtbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbls`.`colA` AS `colA` from `test`.`mediumtbls` where (`test`.`mediumtbls`.`colA` <=> (-(8388608))) +EXPLAIN SELECT * FROM mediumtbls WHERE colA <> -8388608; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE mediumtbls NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbls`.`colA` AS `colA` from `test`.`mediumtbls` where (`test`.`mediumtbls`.`colA` <> (-(8388608))) +EXPLAIN SELECT * FROM mediumtbls WHERE colA = -8388609; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbls`.`colA` AS `colA` from `test`.`mediumtbls` where false +EXPLAIN SELECT * FROM mediumtbls WHERE colA <=> -8388609; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbls`.`colA` AS `colA` from `test`.`mediumtbls` where false +EXPLAIN SELECT * FROM mediumtbls WHERE colA <> -8388609; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE mediumtbls NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbls`.`colA` AS `colA` from `test`.`mediumtbls` where (`test`.`mediumtbls`.`colA` is not null) +same queries but constant first +SELECT * FROM mediumtbls WHERE 8388608 > colA; +colA +-8388608 +-8388607 +0 +1 +3 +8388606 +8388607 +SELECT * FROM mediumtbls WHERE 8388607 >= colA; +colA +-8388608 +-8388607 +0 +1 +3 +8388606 +8388607 +SELECT * FROM mediumtbls WHERE 8388608 < colA; +colA +SELECT * FROM mediumtbls WHERE 8388607 <= colA; +colA +8388607 +SELECT * FROM mediumtbls WHERE 8388607 < colA; +colA +SELECT * FROM mediumtbls WHERE -8388609 < colA; +colA +-8388608 +-8388607 +0 +1 +3 +8388606 +8388607 +SELECT * FROM mediumtbls WHERE -8388609 >= colA; +colA +SELECT * FROM mediumtbls WHERE -8388608 >= colA; +colA +-8388608 +SELECT * FROM mediumtbls WHERE -8388608 <= colA; +colA +-8388608 +-8388607 +0 +1 +3 +8388606 +8388607 +SELECT * FROM mediumtbls WHERE -8388608 < colA; +colA +-8388607 +0 +1 +3 +8388606 +8388607 +SELECT * FROM mediumtbls WHERE 8388608 = colA; +colA +SELECT * FROM mediumtbls WHERE 8388608 <=> colA; +colA +SELECT * FROM mediumtbls WHERE 8388608 <> colA; +colA +-8388608 +-8388607 +0 +1 +3 +8388606 +8388607 +SELECT * FROM mediumtbls WHERE 8388607 = colA; +colA +8388607 +SELECT * FROM mediumtbls WHERE 8388607 <=> colA; +colA +8388607 +SELECT * FROM mediumtbls WHERE 8388607 <> colA; +colA +-8388608 +-8388607 +0 +1 +3 +8388606 +SELECT * FROM mediumtbls WHERE -8388608 = colA; +colA +-8388608 +SELECT * FROM mediumtbls WHERE -8388608 <=> colA; +colA +-8388608 +SELECT * FROM mediumtbls WHERE -8388608 <> colA; +colA +-8388607 +0 +1 +3 +8388606 +8388607 +SELECT * FROM mediumtbls WHERE -8388609 = colA; +colA +SELECT * FROM mediumtbls WHERE -8388609 <=> colA; +colA +SELECT * FROM mediumtbls WHERE -8388609 <> colA; +colA +-8388608 +-8388607 +0 +1 +3 +8388606 +8388607 +PREPARE p_less FROM 'SELECT * FROM mediumtbls WHERE ? < colA'; +PREPARE p_less_eq FROM 'SELECT * FROM mediumtbls WHERE ? <= colA'; +PREPARE p_greater FROM 'SELECT * FROM mediumtbls WHERE ? > colA'; +PREPARE p_gret_eq FROM 'SELECT * FROM mediumtbls WHERE ? >= colA'; +PREPARE p_eq FROM 'SELECT * FROM mediumtbls WHERE ? = colA'; +PREPARE p_equal FROM 'SELECT * FROM mediumtbls WHERE ? <=> colA'; +PREPARE p_n_eq FROM 'SELECT * FROM mediumtbls WHERE ? <> colA'; +PREPARE p_n_equal FROM 'SELECT * FROM mediumtbls WHERE NOT(? <=> colA)'; +EXECUTE p_greater USING @maxint_plus_1; +colA +-8388608 +-8388607 +0 +1 +3 +8388606 +8388607 +EXECUTE p_gret_eq USING @maxint; +colA +-8388608 +-8388607 +0 +1 +3 +8388606 +8388607 +EXECUTE p_less USING @maxint_plus_1; +colA +EXECUTE p_less_eq USING @maxint; +colA +8388607 +EXECUTE p_less USING @minint_minus_1; +colA +-8388608 +-8388607 +0 +1 +3 +8388606 +8388607 +EXECUTE p_gret_eq USING @minint_minus_1; +colA +EXECUTE p_gret_eq USING @minint; +colA +-8388608 +EXECUTE p_less_eq USING @minint; +colA +-8388608 +-8388607 +0 +1 +3 +8388606 +8388607 +EXECUTE p_less USING @minint; +colA +-8388607 +0 +1 +3 +8388606 +8388607 +EXECUTE p_eq USING @maxint_plus_1; +colA +EXECUTE p_equal USING @maxint_plus_1; +colA +EXECUTE p_n_eq USING @maxint_plus_1; +colA +-8388608 +-8388607 +0 +1 +3 +8388606 +8388607 +EXECUTE p_n_equal USING @maxint_plus_1; +colA +-8388608 +-8388607 +0 +1 +3 +8388606 +8388607 +NULL +EXECUTE p_eq USING @maxint; +colA +8388607 +EXECUTE p_equal USING @maxint; +colA +8388607 +EXECUTE p_n_eq USING @maxint; +colA +-8388608 +-8388607 +0 +1 +3 +8388606 +EXECUTE p_n_equal USING @maxint; +colA +-8388608 +-8388607 +0 +1 +3 +8388606 +NULL +EXECUTE p_eq USING @minint; +colA +-8388608 +EXECUTE p_equal USING @minint; +colA +-8388608 +EXECUTE p_n_eq USING @minint; +colA +-8388607 +0 +1 +3 +8388606 +8388607 +EXECUTE p_n_equal USING @minint; +colA +-8388607 +0 +1 +3 +8388606 +8388607 +NULL +EXECUTE p_eq USING @minint_minus_1; +colA +EXECUTE p_equal USING @minint_minus_1; +colA +EXECUTE p_n_eq USING @minint_minus_1; +colA +-8388608 +-8388607 +0 +1 +3 +8388606 +8388607 +EXECUTE p_n_equal USING @minint_minus_1; +colA +-8388608 +-8388607 +0 +1 +3 +8388606 +8388607 +NULL +DROP PREPARE p_less; +DROP PREPARE p_less_eq; +DROP PREPARE p_greater; +DROP PREPARE p_gret_eq; +DROP PREPARE p_equal; +DROP PREPARE p_n_eq; +DROP PREPARE p_n_equal; +EXPLAIN SELECT * FROM mediumtbls WHERE 8388608 > colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE mediumtbls NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbls`.`colA` AS `colA` from `test`.`mediumtbls` where (`test`.`mediumtbls`.`colA` is not null) +EXPLAIN SELECT * FROM mediumtbls WHERE 8388607 >= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE mediumtbls NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbls`.`colA` AS `colA` from `test`.`mediumtbls` where (`test`.`mediumtbls`.`colA` is not null) +EXPLAIN SELECT * FROM mediumtbls WHERE 8388608 < colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbls`.`colA` AS `colA` from `test`.`mediumtbls` where false +EXPLAIN SELECT * FROM mediumtbls WHERE 8388607 <= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE mediumtbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbls`.`colA` AS `colA` from `test`.`mediumtbls` where (8388607 = `test`.`mediumtbls`.`colA`) +EXPLAIN SELECT * FROM mediumtbls WHERE 8388607 < colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbls`.`colA` AS `colA` from `test`.`mediumtbls` where false +EXPLAIN SELECT * FROM mediumtbls WHERE -8388609 < colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE mediumtbls NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbls`.`colA` AS `colA` from `test`.`mediumtbls` where (`test`.`mediumtbls`.`colA` is not null) +EXPLAIN SELECT * FROM mediumtbls WHERE -8388609 >= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbls`.`colA` AS `colA` from `test`.`mediumtbls` where false +EXPLAIN SELECT * FROM mediumtbls WHERE -8388608 >= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE mediumtbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbls`.`colA` AS `colA` from `test`.`mediumtbls` where ((-(8388608)) = `test`.`mediumtbls`.`colA`) +EXPLAIN SELECT * FROM mediumtbls WHERE -8388608 <= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE mediumtbls NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbls`.`colA` AS `colA` from `test`.`mediumtbls` where (`test`.`mediumtbls`.`colA` is not null) +EXPLAIN SELECT * FROM mediumtbls WHERE -8388608 < colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 33.33 Parallel execute (1 workers) +2 SIMPLE mediumtbls NULL ALL NULL NULL NULL NULL 8 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbls`.`colA` AS `colA` from `test`.`mediumtbls` where ((-(8388608)) < `test`.`mediumtbls`.`colA`) +EXPLAIN SELECT * FROM mediumtbls WHERE 8388608 = colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbls`.`colA` AS `colA` from `test`.`mediumtbls` where false +EXPLAIN SELECT * FROM mediumtbls WHERE 8388608 <=> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbls`.`colA` AS `colA` from `test`.`mediumtbls` where false +EXPLAIN SELECT * FROM mediumtbls WHERE 8388608 <> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE mediumtbls NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbls`.`colA` AS `colA` from `test`.`mediumtbls` where (`test`.`mediumtbls`.`colA` is not null) +EXPLAIN SELECT * FROM mediumtbls WHERE 8388607 = colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE mediumtbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbls`.`colA` AS `colA` from `test`.`mediumtbls` where (`test`.`mediumtbls`.`colA` = 8388607) +EXPLAIN SELECT * FROM mediumtbls WHERE 8388607 <=> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE mediumtbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbls`.`colA` AS `colA` from `test`.`mediumtbls` where (8388607 <=> `test`.`mediumtbls`.`colA`) +EXPLAIN SELECT * FROM mediumtbls WHERE 8388607 <> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE mediumtbls NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbls`.`colA` AS `colA` from `test`.`mediumtbls` where (8388607 <> `test`.`mediumtbls`.`colA`) +EXPLAIN SELECT * FROM mediumtbls WHERE -8388608 = colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE mediumtbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbls`.`colA` AS `colA` from `test`.`mediumtbls` where (`test`.`mediumtbls`.`colA` = (-(8388608))) +EXPLAIN SELECT * FROM mediumtbls WHERE -8388608 <=> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE mediumtbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbls`.`colA` AS `colA` from `test`.`mediumtbls` where ((-(8388608)) <=> `test`.`mediumtbls`.`colA`) +EXPLAIN SELECT * FROM mediumtbls WHERE -8388608 <> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE mediumtbls NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbls`.`colA` AS `colA` from `test`.`mediumtbls` where ((-(8388608)) <> `test`.`mediumtbls`.`colA`) +EXPLAIN SELECT * FROM mediumtbls WHERE -8388609 = colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbls`.`colA` AS `colA` from `test`.`mediumtbls` where false +EXPLAIN SELECT * FROM mediumtbls WHERE -8388609 <=> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbls`.`colA` AS `colA` from `test`.`mediumtbls` where false +EXPLAIN SELECT * FROM mediumtbls WHERE -8388609 <> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE mediumtbls NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbls`.`colA` AS `colA` from `test`.`mediumtbls` where (`test`.`mediumtbls`.`colA` is not null) +DROP TABLE mediumtbls; +# +# Tests with type MEDIUMINT NOT NULL against int +# +CREATE TABLE mediumtbls (colA MEDIUMINT NOT NULL); +INSERT INTO mediumtbls VALUES (-8388608), (-8388607), +(0),(1),(3), +(8388606), (8388607), +(0); +ANALYZE TABLE mediumtbls; +Table Op Msg_type Msg_text +test.mediumtbls analyze status OK +SELECT * FROM mediumtbls; +colA +-8388608 +-8388607 +0 +1 +3 +8388606 +8388607 +0 +SELECT * FROM mediumtbls WHERE colA < 8388608; +colA +-8388608 +-8388607 +0 +1 +3 +8388606 +8388607 +0 +SELECT * FROM mediumtbls WHERE colA <= 8388607; +colA +-8388608 +-8388607 +0 +1 +3 +8388606 +8388607 +0 +SELECT * FROM mediumtbls WHERE colA > 8388608; +colA +SELECT * FROM mediumtbls WHERE colA >= 8388607; +colA +8388607 +SELECT * FROM mediumtbls WHERE colA > -8388609; +colA +-8388608 +-8388607 +0 +1 +3 +8388606 +8388607 +0 +SELECT * FROM mediumtbls WHERE colA <= -8388609; +colA +SELECT * FROM mediumtbls WHERE colA <= -8388608; +colA +-8388608 +SELECT * FROM mediumtbls WHERE colA >= -8388608; +colA +-8388608 +-8388607 +0 +1 +3 +8388606 +8388607 +0 +SELECT * FROM mediumtbls WHERE colA > -8388608; +colA +-8388607 +0 +1 +3 +8388606 +8388607 +0 +SELECT * FROM mediumtbls WHERE colA = 8388608; +colA +SELECT * FROM mediumtbls WHERE colA <> 8388608; +colA +-8388608 +-8388607 +0 +1 +3 +8388606 +8388607 +0 +SELECT * FROM mediumtbls WHERE colA = 8388607; +colA +8388607 +SELECT * FROM mediumtbls WHERE colA <=> 8388607; +colA +8388607 +SELECT * FROM mediumtbls WHERE NOT(colA <=> 8388607); +colA +-8388608 +-8388607 +0 +1 +3 +8388606 +0 +SELECT * FROM mediumtbls WHERE colA <> 8388607; +colA +-8388608 +-8388607 +0 +1 +3 +8388606 +0 +SELECT * FROM mediumtbls WHERE colA = -8388608; +colA +-8388608 +SELECT * FROM mediumtbls WHERE colA <=> -8388608; +colA +-8388608 +SELECT * FROM mediumtbls WHERE NOT(colA <=> -8388608); +colA +-8388607 +0 +1 +3 +8388606 +8388607 +0 +SELECT * FROM mediumtbls WHERE colA <> -8388608; +colA +-8388607 +0 +1 +3 +8388606 +8388607 +0 +SELECT * FROM mediumtbls WHERE colA = -8388609; +colA +SELECT * FROM mediumtbls WHERE colA <=> -8388609; +colA +SELECT * FROM mediumtbls WHERE NOT(colA <=> -8388609); +colA +-8388608 +-8388607 +0 +1 +3 +8388606 +8388607 +0 +SELECT * FROM mediumtbls WHERE colA <> -8388609; +colA +-8388608 +-8388607 +0 +1 +3 +8388606 +8388607 +0 +PREPARE p_less FROM 'SELECT * FROM mediumtbls WHERE colA < ?'; +PREPARE p_less_eq FROM 'SELECT * FROM mediumtbls WHERE colA <= ?'; +PREPARE p_greater FROM 'SELECT * FROM mediumtbls WHERE colA > ?'; +PREPARE p_gret_eq FROM 'SELECT * FROM mediumtbls WHERE colA >= ?'; +PREPARE p_eq FROM 'SELECT * FROM mediumtbls WHERE colA = ?'; +PREPARE p_equal FROM 'SELECT * FROM mediumtbls WHERE colA <=> ?'; +PREPARE p_n_equal FROM 'SELECT * FROM mediumtbls WHERE NOT(colA <=> ?)'; +PREPARE p_n_eq FROM 'SELECT * FROM mediumtbls WHERE colA <> ?'; +SET @maxint_plus_1=8388608; +SET @maxint=8388607; +SET @minint_minus_1=-8388609; +SET @minint=-8388608; +EXECUTE p_less USING @maxint_plus_1; +colA +-8388608 +-8388607 +0 +1 +3 +8388606 +8388607 +0 +EXECUTE p_less_eq USING @maxint; +colA +-8388608 +-8388607 +0 +1 +3 +8388606 +8388607 +0 +EXECUTE p_greater USING @maxint_plus_1; +colA +EXECUTE p_gret_eq USING @maxint; +colA +8388607 +EXECUTE p_greater USING @minint_minus_1; +colA +-8388608 +-8388607 +0 +1 +3 +8388606 +8388607 +0 +EXECUTE p_less_eq USING @minint_minus_1; +colA +EXECUTE p_less_eq USING @minint; +colA +-8388608 +EXECUTE p_gret_eq USING @minint; +colA +-8388608 +-8388607 +0 +1 +3 +8388606 +8388607 +0 +EXECUTE p_greater USING @minint; +colA +-8388607 +0 +1 +3 +8388606 +8388607 +0 +EXECUTE p_eq USING @maxint_plus_1; +colA +EXECUTE p_equal USING @maxint_plus_1; +colA +EXECUTE p_n_eq USING @maxint_plus_1; +colA +-8388608 +-8388607 +0 +1 +3 +8388606 +8388607 +0 +EXECUTE p_n_equal USING @maxint_plus_1; +colA +-8388608 +-8388607 +0 +1 +3 +8388606 +8388607 +0 +EXECUTE p_eq USING @maxint; +colA +8388607 +EXECUTE p_equal USING @maxint; +colA +8388607 +EXECUTE p_n_eq USING @maxint; +colA +-8388608 +-8388607 +0 +1 +3 +8388606 +0 +EXECUTE p_n_equal USING @maxint; +colA +-8388608 +-8388607 +0 +1 +3 +8388606 +0 +EXECUTE p_eq USING @minint; +colA +-8388608 +EXECUTE p_equal USING @minint; +colA +-8388608 +EXECUTE p_n_eq USING @minint; +colA +-8388607 +0 +1 +3 +8388606 +8388607 +0 +EXECUTE p_n_equal USING @minint; +colA +-8388607 +0 +1 +3 +8388606 +8388607 +0 +EXECUTE p_eq USING @minint_minus_1; +colA +EXECUTE p_equal USING @minint_minus_1; +colA +EXECUTE p_n_eq USING @minint_minus_1; +colA +-8388608 +-8388607 +0 +1 +3 +8388606 +8388607 +0 +EXECUTE p_n_equal USING @minint_minus_1; +colA +-8388608 +-8388607 +0 +1 +3 +8388606 +8388607 +0 +DROP PREPARE p_less; +DROP PREPARE p_less_eq; +DROP PREPARE p_greater; +DROP PREPARE p_gret_eq; +DROP PREPARE p_equal; +DROP PREPARE p_n_eq; +DROP PREPARE p_n_equal; +EXPLAIN SELECT * FROM mediumtbls WHERE colA < 8388608; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE mediumtbls NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbls`.`colA` AS `colA` from `test`.`mediumtbls` where true +EXPLAIN SELECT * FROM mediumtbls WHERE colA <= 8388607; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE mediumtbls NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbls`.`colA` AS `colA` from `test`.`mediumtbls` where true +EXPLAIN SELECT * FROM mediumtbls WHERE colA > 8388608; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbls`.`colA` AS `colA` from `test`.`mediumtbls` where false +EXPLAIN SELECT * FROM mediumtbls WHERE colA >= 8388607; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE mediumtbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbls`.`colA` AS `colA` from `test`.`mediumtbls` where (`test`.`mediumtbls`.`colA` = 8388607) +EXPLAIN SELECT * FROM mediumtbls WHERE colA > -8388609; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE mediumtbls NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbls`.`colA` AS `colA` from `test`.`mediumtbls` where true +EXPLAIN SELECT * FROM mediumtbls WHERE colA <= -8388609; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbls`.`colA` AS `colA` from `test`.`mediumtbls` where false +EXPLAIN SELECT * FROM mediumtbls WHERE colA <= -8388608; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE mediumtbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbls`.`colA` AS `colA` from `test`.`mediumtbls` where (`test`.`mediumtbls`.`colA` = (-(8388608))) +EXPLAIN SELECT * FROM mediumtbls WHERE colA >= -8388608; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE mediumtbls NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbls`.`colA` AS `colA` from `test`.`mediumtbls` where true +EXPLAIN SELECT * FROM mediumtbls WHERE colA > -8388608; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 33.33 Parallel execute (1 workers) +2 SIMPLE mediumtbls NULL ALL NULL NULL NULL NULL 8 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbls`.`colA` AS `colA` from `test`.`mediumtbls` where (`test`.`mediumtbls`.`colA` > (-(8388608))) +EXPLAIN SELECT * FROM mediumtbls WHERE colA = 8388608; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbls`.`colA` AS `colA` from `test`.`mediumtbls` where false +EXPLAIN SELECT * FROM mediumtbls WHERE colA <=> 8388608; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbls`.`colA` AS `colA` from `test`.`mediumtbls` where false +EXPLAIN SELECT * FROM mediumtbls WHERE colA <> 8388608; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE mediumtbls NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbls`.`colA` AS `colA` from `test`.`mediumtbls` where true +EXPLAIN SELECT * FROM mediumtbls WHERE colA = 8388607; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE mediumtbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbls`.`colA` AS `colA` from `test`.`mediumtbls` where (`test`.`mediumtbls`.`colA` = 8388607) +EXPLAIN SELECT * FROM mediumtbls WHERE colA <=> 8388607; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE mediumtbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbls`.`colA` AS `colA` from `test`.`mediumtbls` where (`test`.`mediumtbls`.`colA` <=> 8388607) +EXPLAIN SELECT * FROM mediumtbls WHERE colA <> 8388607; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE mediumtbls NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbls`.`colA` AS `colA` from `test`.`mediumtbls` where (`test`.`mediumtbls`.`colA` <> 8388607) +EXPLAIN SELECT * FROM mediumtbls WHERE colA = -8388608; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE mediumtbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbls`.`colA` AS `colA` from `test`.`mediumtbls` where (`test`.`mediumtbls`.`colA` = (-(8388608))) +EXPLAIN SELECT * FROM mediumtbls WHERE colA <=> -8388608; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE mediumtbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbls`.`colA` AS `colA` from `test`.`mediumtbls` where (`test`.`mediumtbls`.`colA` <=> (-(8388608))) +EXPLAIN SELECT * FROM mediumtbls WHERE colA <> -8388608; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE mediumtbls NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbls`.`colA` AS `colA` from `test`.`mediumtbls` where (`test`.`mediumtbls`.`colA` <> (-(8388608))) +EXPLAIN SELECT * FROM mediumtbls WHERE colA = -8388609; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbls`.`colA` AS `colA` from `test`.`mediumtbls` where false +EXPLAIN SELECT * FROM mediumtbls WHERE colA <=> -8388609; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbls`.`colA` AS `colA` from `test`.`mediumtbls` where false +EXPLAIN SELECT * FROM mediumtbls WHERE colA <> -8388609; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE mediumtbls NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbls`.`colA` AS `colA` from `test`.`mediumtbls` where true +same queries but constant first +SELECT * FROM mediumtbls WHERE 8388608 > colA; +colA +-8388608 +-8388607 +0 +1 +3 +8388606 +8388607 +0 +SELECT * FROM mediumtbls WHERE 8388607 >= colA; +colA +-8388608 +-8388607 +0 +1 +3 +8388606 +8388607 +0 +SELECT * FROM mediumtbls WHERE 8388608 < colA; +colA +SELECT * FROM mediumtbls WHERE 8388607 <= colA; +colA +8388607 +SELECT * FROM mediumtbls WHERE 8388607 < colA; +colA +SELECT * FROM mediumtbls WHERE -8388609 < colA; +colA +-8388608 +-8388607 +0 +1 +3 +8388606 +8388607 +0 +SELECT * FROM mediumtbls WHERE -8388609 >= colA; +colA +SELECT * FROM mediumtbls WHERE -8388608 >= colA; +colA +-8388608 +SELECT * FROM mediumtbls WHERE -8388608 <= colA; +colA +-8388608 +-8388607 +0 +1 +3 +8388606 +8388607 +0 +SELECT * FROM mediumtbls WHERE -8388608 < colA; +colA +-8388607 +0 +1 +3 +8388606 +8388607 +0 +SELECT * FROM mediumtbls WHERE 8388608 = colA; +colA +SELECT * FROM mediumtbls WHERE 8388608 <=> colA; +colA +SELECT * FROM mediumtbls WHERE 8388608 <> colA; +colA +-8388608 +-8388607 +0 +1 +3 +8388606 +8388607 +0 +SELECT * FROM mediumtbls WHERE 8388607 = colA; +colA +8388607 +SELECT * FROM mediumtbls WHERE 8388607 <=> colA; +colA +8388607 +SELECT * FROM mediumtbls WHERE 8388607 <> colA; +colA +-8388608 +-8388607 +0 +1 +3 +8388606 +0 +SELECT * FROM mediumtbls WHERE -8388608 = colA; +colA +-8388608 +SELECT * FROM mediumtbls WHERE -8388608 <=> colA; +colA +-8388608 +SELECT * FROM mediumtbls WHERE -8388608 <> colA; +colA +-8388607 +0 +1 +3 +8388606 +8388607 +0 +SELECT * FROM mediumtbls WHERE -8388609 = colA; +colA +SELECT * FROM mediumtbls WHERE -8388609 <=> colA; +colA +SELECT * FROM mediumtbls WHERE -8388609 <> colA; +colA +-8388608 +-8388607 +0 +1 +3 +8388606 +8388607 +0 +PREPARE p_less FROM 'SELECT * FROM mediumtbls WHERE ? < colA'; +PREPARE p_less_eq FROM 'SELECT * FROM mediumtbls WHERE ? <= colA'; +PREPARE p_greater FROM 'SELECT * FROM mediumtbls WHERE ? > colA'; +PREPARE p_gret_eq FROM 'SELECT * FROM mediumtbls WHERE ? >= colA'; +PREPARE p_eq FROM 'SELECT * FROM mediumtbls WHERE ? = colA'; +PREPARE p_equal FROM 'SELECT * FROM mediumtbls WHERE ? <=> colA'; +PREPARE p_n_eq FROM 'SELECT * FROM mediumtbls WHERE ? <> colA'; +PREPARE p_n_equal FROM 'SELECT * FROM mediumtbls WHERE NOT(? <=> colA)'; +EXECUTE p_greater USING @maxint_plus_1; +colA +-8388608 +-8388607 +0 +1 +3 +8388606 +8388607 +0 +EXECUTE p_gret_eq USING @maxint; +colA +-8388608 +-8388607 +0 +1 +3 +8388606 +8388607 +0 +EXECUTE p_less USING @maxint_plus_1; +colA +EXECUTE p_less_eq USING @maxint; +colA +8388607 +EXECUTE p_less USING @minint_minus_1; +colA +-8388608 +-8388607 +0 +1 +3 +8388606 +8388607 +0 +EXECUTE p_gret_eq USING @minint_minus_1; +colA +EXECUTE p_gret_eq USING @minint; +colA +-8388608 +EXECUTE p_less_eq USING @minint; +colA +-8388608 +-8388607 +0 +1 +3 +8388606 +8388607 +0 +EXECUTE p_less USING @minint; +colA +-8388607 +0 +1 +3 +8388606 +8388607 +0 +EXECUTE p_eq USING @maxint_plus_1; +colA +EXECUTE p_equal USING @maxint_plus_1; +colA +EXECUTE p_n_eq USING @maxint_plus_1; +colA +-8388608 +-8388607 +0 +1 +3 +8388606 +8388607 +0 +EXECUTE p_n_equal USING @maxint_plus_1; +colA +-8388608 +-8388607 +0 +1 +3 +8388606 +8388607 +0 +EXECUTE p_eq USING @maxint; +colA +8388607 +EXECUTE p_equal USING @maxint; +colA +8388607 +EXECUTE p_n_eq USING @maxint; +colA +-8388608 +-8388607 +0 +1 +3 +8388606 +0 +EXECUTE p_n_equal USING @maxint; +colA +-8388608 +-8388607 +0 +1 +3 +8388606 +0 +EXECUTE p_eq USING @minint; +colA +-8388608 +EXECUTE p_equal USING @minint; +colA +-8388608 +EXECUTE p_n_eq USING @minint; +colA +-8388607 +0 +1 +3 +8388606 +8388607 +0 +EXECUTE p_n_equal USING @minint; +colA +-8388607 +0 +1 +3 +8388606 +8388607 +0 +EXECUTE p_eq USING @minint_minus_1; +colA +EXECUTE p_equal USING @minint_minus_1; +colA +EXECUTE p_n_eq USING @minint_minus_1; +colA +-8388608 +-8388607 +0 +1 +3 +8388606 +8388607 +0 +EXECUTE p_n_equal USING @minint_minus_1; +colA +-8388608 +-8388607 +0 +1 +3 +8388606 +8388607 +0 +DROP PREPARE p_less; +DROP PREPARE p_less_eq; +DROP PREPARE p_greater; +DROP PREPARE p_gret_eq; +DROP PREPARE p_equal; +DROP PREPARE p_n_eq; +DROP PREPARE p_n_equal; +EXPLAIN SELECT * FROM mediumtbls WHERE 8388608 > colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE mediumtbls NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbls`.`colA` AS `colA` from `test`.`mediumtbls` where true +EXPLAIN SELECT * FROM mediumtbls WHERE 8388607 >= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE mediumtbls NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbls`.`colA` AS `colA` from `test`.`mediumtbls` where true +EXPLAIN SELECT * FROM mediumtbls WHERE 8388608 < colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbls`.`colA` AS `colA` from `test`.`mediumtbls` where false +EXPLAIN SELECT * FROM mediumtbls WHERE 8388607 <= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE mediumtbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbls`.`colA` AS `colA` from `test`.`mediumtbls` where (8388607 = `test`.`mediumtbls`.`colA`) +EXPLAIN SELECT * FROM mediumtbls WHERE 8388607 < colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbls`.`colA` AS `colA` from `test`.`mediumtbls` where false +EXPLAIN SELECT * FROM mediumtbls WHERE -8388609 < colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE mediumtbls NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbls`.`colA` AS `colA` from `test`.`mediumtbls` where true +EXPLAIN SELECT * FROM mediumtbls WHERE -8388609 >= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbls`.`colA` AS `colA` from `test`.`mediumtbls` where false +EXPLAIN SELECT * FROM mediumtbls WHERE -8388608 >= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE mediumtbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbls`.`colA` AS `colA` from `test`.`mediumtbls` where ((-(8388608)) = `test`.`mediumtbls`.`colA`) +EXPLAIN SELECT * FROM mediumtbls WHERE -8388608 <= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE mediumtbls NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbls`.`colA` AS `colA` from `test`.`mediumtbls` where true +EXPLAIN SELECT * FROM mediumtbls WHERE -8388608 < colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 33.33 Parallel execute (1 workers) +2 SIMPLE mediumtbls NULL ALL NULL NULL NULL NULL 8 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbls`.`colA` AS `colA` from `test`.`mediumtbls` where ((-(8388608)) < `test`.`mediumtbls`.`colA`) +EXPLAIN SELECT * FROM mediumtbls WHERE 8388608 = colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbls`.`colA` AS `colA` from `test`.`mediumtbls` where false +EXPLAIN SELECT * FROM mediumtbls WHERE 8388608 <=> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbls`.`colA` AS `colA` from `test`.`mediumtbls` where false +EXPLAIN SELECT * FROM mediumtbls WHERE 8388608 <> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE mediumtbls NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbls`.`colA` AS `colA` from `test`.`mediumtbls` where true +EXPLAIN SELECT * FROM mediumtbls WHERE 8388607 = colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE mediumtbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbls`.`colA` AS `colA` from `test`.`mediumtbls` where (`test`.`mediumtbls`.`colA` = 8388607) +EXPLAIN SELECT * FROM mediumtbls WHERE 8388607 <=> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE mediumtbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbls`.`colA` AS `colA` from `test`.`mediumtbls` where (8388607 <=> `test`.`mediumtbls`.`colA`) +EXPLAIN SELECT * FROM mediumtbls WHERE 8388607 <> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE mediumtbls NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbls`.`colA` AS `colA` from `test`.`mediumtbls` where (8388607 <> `test`.`mediumtbls`.`colA`) +EXPLAIN SELECT * FROM mediumtbls WHERE -8388608 = colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE mediumtbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbls`.`colA` AS `colA` from `test`.`mediumtbls` where (`test`.`mediumtbls`.`colA` = (-(8388608))) +EXPLAIN SELECT * FROM mediumtbls WHERE -8388608 <=> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE mediumtbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbls`.`colA` AS `colA` from `test`.`mediumtbls` where ((-(8388608)) <=> `test`.`mediumtbls`.`colA`) +EXPLAIN SELECT * FROM mediumtbls WHERE -8388608 <> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE mediumtbls NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbls`.`colA` AS `colA` from `test`.`mediumtbls` where ((-(8388608)) <> `test`.`mediumtbls`.`colA`) +EXPLAIN SELECT * FROM mediumtbls WHERE -8388609 = colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbls`.`colA` AS `colA` from `test`.`mediumtbls` where false +EXPLAIN SELECT * FROM mediumtbls WHERE -8388609 <=> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbls`.`colA` AS `colA` from `test`.`mediumtbls` where false +EXPLAIN SELECT * FROM mediumtbls WHERE -8388609 <> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE mediumtbls NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbls`.`colA` AS `colA` from `test`.`mediumtbls` where true +DROP TABLE mediumtbls; +# +# Tests with UNSIGNED type INT against int +# +CREATE TABLE inttbl (colA INT UNSIGNED ); +INSERT INTO inttbl VALUES (0), (1), +(0),(1),(3), +(4294967294), (4294967295), +(NULL); +ANALYZE TABLE inttbl; +Table Op Msg_type Msg_text +test.inttbl analyze status OK +SELECT * FROM inttbl; +colA +0 +1 +0 +1 +3 +4294967294 +4294967295 +NULL +SELECT * FROM inttbl WHERE colA < 4294967296; +colA +0 +1 +0 +1 +3 +4294967294 +4294967295 +SELECT * FROM inttbl WHERE colA <= 4294967295; +colA +0 +1 +0 +1 +3 +4294967294 +4294967295 +SELECT * FROM inttbl WHERE colA > 4294967296; +colA +SELECT * FROM inttbl WHERE colA >= 4294967295; +colA +4294967295 +SELECT * FROM inttbl WHERE colA > -1; +colA +0 +1 +0 +1 +3 +4294967294 +4294967295 +SELECT * FROM inttbl WHERE colA <= -1; +colA +SELECT * FROM inttbl WHERE colA <= 0; +colA +0 +0 +SELECT * FROM inttbl WHERE colA >= 0; +colA +0 +1 +0 +1 +3 +4294967294 +4294967295 +SELECT * FROM inttbl WHERE colA > 0; +colA +1 +1 +3 +4294967294 +4294967295 +SELECT * FROM inttbl WHERE colA = 4294967296; +colA +SELECT * FROM inttbl WHERE colA <> 4294967296; +colA +0 +1 +0 +1 +3 +4294967294 +4294967295 +SELECT * FROM inttbl WHERE colA = 4294967295; +colA +4294967295 +SELECT * FROM inttbl WHERE colA <=> 4294967295; +colA +4294967295 +SELECT * FROM inttbl WHERE NOT(colA <=> 4294967295); +colA +0 +1 +0 +1 +3 +4294967294 +NULL +SELECT * FROM inttbl WHERE colA <> 4294967295; +colA +0 +1 +0 +1 +3 +4294967294 +SELECT * FROM inttbl WHERE colA = 0; +colA +0 +0 +SELECT * FROM inttbl WHERE colA <=> 0; +colA +0 +0 +SELECT * FROM inttbl WHERE NOT(colA <=> 0); +colA +1 +1 +3 +4294967294 +4294967295 +NULL +SELECT * FROM inttbl WHERE colA <> 0; +colA +1 +1 +3 +4294967294 +4294967295 +SELECT * FROM inttbl WHERE colA = -1; +colA +SELECT * FROM inttbl WHERE colA <=> -1; +colA +SELECT * FROM inttbl WHERE NOT(colA <=> -1); +colA +0 +1 +0 +1 +3 +4294967294 +4294967295 +NULL +SELECT * FROM inttbl WHERE colA <> -1; +colA +0 +1 +0 +1 +3 +4294967294 +4294967295 +PREPARE p_less FROM 'SELECT * FROM inttbl WHERE colA < ?'; +PREPARE p_less_eq FROM 'SELECT * FROM inttbl WHERE colA <= ?'; +PREPARE p_greater FROM 'SELECT * FROM inttbl WHERE colA > ?'; +PREPARE p_gret_eq FROM 'SELECT * FROM inttbl WHERE colA >= ?'; +PREPARE p_eq FROM 'SELECT * FROM inttbl WHERE colA = ?'; +PREPARE p_equal FROM 'SELECT * FROM inttbl WHERE colA <=> ?'; +PREPARE p_n_equal FROM 'SELECT * FROM inttbl WHERE NOT(colA <=> ?)'; +PREPARE p_n_eq FROM 'SELECT * FROM inttbl WHERE colA <> ?'; +SET @maxint_plus_1=4294967296; +SET @maxint=4294967295; +SET @minint_minus_1=-1; +SET @minint=0; +EXECUTE p_less USING @maxint_plus_1; +colA +0 +1 +0 +1 +3 +4294967294 +4294967295 +EXECUTE p_less_eq USING @maxint; +colA +0 +1 +0 +1 +3 +4294967294 +4294967295 +EXECUTE p_greater USING @maxint_plus_1; +colA +EXECUTE p_gret_eq USING @maxint; +colA +4294967295 +EXECUTE p_greater USING @minint_minus_1; +colA +0 +1 +0 +1 +3 +4294967294 +4294967295 +EXECUTE p_less_eq USING @minint_minus_1; +colA +EXECUTE p_less_eq USING @minint; +colA +0 +0 +EXECUTE p_gret_eq USING @minint; +colA +0 +1 +0 +1 +3 +4294967294 +4294967295 +EXECUTE p_greater USING @minint; +colA +1 +1 +3 +4294967294 +4294967295 +EXECUTE p_eq USING @maxint_plus_1; +colA +EXECUTE p_equal USING @maxint_plus_1; +colA +EXECUTE p_n_eq USING @maxint_plus_1; +colA +0 +1 +0 +1 +3 +4294967294 +4294967295 +EXECUTE p_n_equal USING @maxint_plus_1; +colA +0 +1 +0 +1 +3 +4294967294 +4294967295 +NULL +EXECUTE p_eq USING @maxint; +colA +4294967295 +EXECUTE p_equal USING @maxint; +colA +4294967295 +EXECUTE p_n_eq USING @maxint; +colA +0 +1 +0 +1 +3 +4294967294 +EXECUTE p_n_equal USING @maxint; +colA +0 +1 +0 +1 +3 +4294967294 +NULL +EXECUTE p_eq USING @minint; +colA +0 +0 +EXECUTE p_equal USING @minint; +colA +0 +0 +EXECUTE p_n_eq USING @minint; +colA +1 +1 +3 +4294967294 +4294967295 +EXECUTE p_n_equal USING @minint; +colA +1 +1 +3 +4294967294 +4294967295 +NULL +EXECUTE p_eq USING @minint_minus_1; +colA +EXECUTE p_equal USING @minint_minus_1; +colA +EXECUTE p_n_eq USING @minint_minus_1; +colA +0 +1 +0 +1 +3 +4294967294 +4294967295 +EXECUTE p_n_equal USING @minint_minus_1; +colA +0 +1 +0 +1 +3 +4294967294 +4294967295 +NULL +DROP PREPARE p_less; +DROP PREPARE p_less_eq; +DROP PREPARE p_greater; +DROP PREPARE p_gret_eq; +DROP PREPARE p_equal; +DROP PREPARE p_n_eq; +DROP PREPARE p_n_equal; +EXPLAIN SELECT * FROM inttbl WHERE colA < 4294967296; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` is not null) +EXPLAIN SELECT * FROM inttbl WHERE colA <= 4294967295; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` is not null) +EXPLAIN SELECT * FROM inttbl WHERE colA > 4294967296; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where false +EXPLAIN SELECT * FROM inttbl WHERE colA >= 4294967295; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` = 4294967295) +EXPLAIN SELECT * FROM inttbl WHERE colA > -1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` is not null) +EXPLAIN SELECT * FROM inttbl WHERE colA <= -1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where false +EXPLAIN SELECT * FROM inttbl WHERE colA <= 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` = 0) +EXPLAIN SELECT * FROM inttbl WHERE colA >= 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` is not null) +EXPLAIN SELECT * FROM inttbl WHERE colA > 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 33.33 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` > 0) +EXPLAIN SELECT * FROM inttbl WHERE colA = 4294967296; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where false +EXPLAIN SELECT * FROM inttbl WHERE colA <=> 4294967296; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where false +EXPLAIN SELECT * FROM inttbl WHERE colA <> 4294967296; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` is not null) +EXPLAIN SELECT * FROM inttbl WHERE colA = 4294967295; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` = 4294967295) +EXPLAIN SELECT * FROM inttbl WHERE colA <=> 4294967295; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` <=> 4294967295) +EXPLAIN SELECT * FROM inttbl WHERE colA <> 4294967295; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` <> 4294967295) +EXPLAIN SELECT * FROM inttbl WHERE colA = 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` = 0) +EXPLAIN SELECT * FROM inttbl WHERE colA <=> 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` <=> 0) +EXPLAIN SELECT * FROM inttbl WHERE colA <> 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` <> 0) +EXPLAIN SELECT * FROM inttbl WHERE colA = -1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where false +EXPLAIN SELECT * FROM inttbl WHERE colA <=> -1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where false +EXPLAIN SELECT * FROM inttbl WHERE colA <> -1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` is not null) +same queries but constant first +SELECT * FROM inttbl WHERE 4294967296 > colA; +colA +0 +1 +0 +1 +3 +4294967294 +4294967295 +SELECT * FROM inttbl WHERE 4294967295 >= colA; +colA +0 +1 +0 +1 +3 +4294967294 +4294967295 +SELECT * FROM inttbl WHERE 4294967296 < colA; +colA +SELECT * FROM inttbl WHERE 4294967295 <= colA; +colA +4294967295 +SELECT * FROM inttbl WHERE 4294967295 < colA; +colA +SELECT * FROM inttbl WHERE -1 < colA; +colA +0 +1 +0 +1 +3 +4294967294 +4294967295 +SELECT * FROM inttbl WHERE -1 >= colA; +colA +SELECT * FROM inttbl WHERE 0 >= colA; +colA +0 +0 +SELECT * FROM inttbl WHERE 0 <= colA; +colA +0 +1 +0 +1 +3 +4294967294 +4294967295 +SELECT * FROM inttbl WHERE 0 < colA; +colA +1 +1 +3 +4294967294 +4294967295 +SELECT * FROM inttbl WHERE 4294967296 = colA; +colA +SELECT * FROM inttbl WHERE 4294967296 <=> colA; +colA +SELECT * FROM inttbl WHERE 4294967296 <> colA; +colA +0 +1 +0 +1 +3 +4294967294 +4294967295 +SELECT * FROM inttbl WHERE 4294967295 = colA; +colA +4294967295 +SELECT * FROM inttbl WHERE 4294967295 <=> colA; +colA +4294967295 +SELECT * FROM inttbl WHERE 4294967295 <> colA; +colA +0 +1 +0 +1 +3 +4294967294 +SELECT * FROM inttbl WHERE 0 = colA; +colA +0 +0 +SELECT * FROM inttbl WHERE 0 <=> colA; +colA +0 +0 +SELECT * FROM inttbl WHERE 0 <> colA; +colA +1 +1 +3 +4294967294 +4294967295 +SELECT * FROM inttbl WHERE -1 = colA; +colA +SELECT * FROM inttbl WHERE -1 <=> colA; +colA +SELECT * FROM inttbl WHERE -1 <> colA; +colA +0 +1 +0 +1 +3 +4294967294 +4294967295 +PREPARE p_less FROM 'SELECT * FROM inttbl WHERE ? < colA'; +PREPARE p_less_eq FROM 'SELECT * FROM inttbl WHERE ? <= colA'; +PREPARE p_greater FROM 'SELECT * FROM inttbl WHERE ? > colA'; +PREPARE p_gret_eq FROM 'SELECT * FROM inttbl WHERE ? >= colA'; +PREPARE p_eq FROM 'SELECT * FROM inttbl WHERE ? = colA'; +PREPARE p_equal FROM 'SELECT * FROM inttbl WHERE ? <=> colA'; +PREPARE p_n_eq FROM 'SELECT * FROM inttbl WHERE ? <> colA'; +PREPARE p_n_equal FROM 'SELECT * FROM inttbl WHERE NOT(? <=> colA)'; +EXECUTE p_greater USING @maxint_plus_1; +colA +0 +1 +0 +1 +3 +4294967294 +4294967295 +EXECUTE p_gret_eq USING @maxint; +colA +0 +1 +0 +1 +3 +4294967294 +4294967295 +EXECUTE p_less USING @maxint_plus_1; +colA +EXECUTE p_less_eq USING @maxint; +colA +4294967295 +EXECUTE p_less USING @minint_minus_1; +colA +0 +1 +0 +1 +3 +4294967294 +4294967295 +EXECUTE p_gret_eq USING @minint_minus_1; +colA +EXECUTE p_gret_eq USING @minint; +colA +0 +0 +EXECUTE p_less_eq USING @minint; +colA +0 +1 +0 +1 +3 +4294967294 +4294967295 +EXECUTE p_less USING @minint; +colA +1 +1 +3 +4294967294 +4294967295 +EXECUTE p_eq USING @maxint_plus_1; +colA +EXECUTE p_equal USING @maxint_plus_1; +colA +EXECUTE p_n_eq USING @maxint_plus_1; +colA +0 +1 +0 +1 +3 +4294967294 +4294967295 +EXECUTE p_n_equal USING @maxint_plus_1; +colA +0 +1 +0 +1 +3 +4294967294 +4294967295 +NULL +EXECUTE p_eq USING @maxint; +colA +4294967295 +EXECUTE p_equal USING @maxint; +colA +4294967295 +EXECUTE p_n_eq USING @maxint; +colA +0 +1 +0 +1 +3 +4294967294 +EXECUTE p_n_equal USING @maxint; +colA +0 +1 +0 +1 +3 +4294967294 +NULL +EXECUTE p_eq USING @minint; +colA +0 +0 +EXECUTE p_equal USING @minint; +colA +0 +0 +EXECUTE p_n_eq USING @minint; +colA +1 +1 +3 +4294967294 +4294967295 +EXECUTE p_n_equal USING @minint; +colA +1 +1 +3 +4294967294 +4294967295 +NULL +EXECUTE p_eq USING @minint_minus_1; +colA +EXECUTE p_equal USING @minint_minus_1; +colA +EXECUTE p_n_eq USING @minint_minus_1; +colA +0 +1 +0 +1 +3 +4294967294 +4294967295 +EXECUTE p_n_equal USING @minint_minus_1; +colA +0 +1 +0 +1 +3 +4294967294 +4294967295 +NULL +DROP PREPARE p_less; +DROP PREPARE p_less_eq; +DROP PREPARE p_greater; +DROP PREPARE p_gret_eq; +DROP PREPARE p_equal; +DROP PREPARE p_n_eq; +DROP PREPARE p_n_equal; +EXPLAIN SELECT * FROM inttbl WHERE 4294967296 > colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` is not null) +EXPLAIN SELECT * FROM inttbl WHERE 4294967295 >= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` is not null) +EXPLAIN SELECT * FROM inttbl WHERE 4294967296 < colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where false +EXPLAIN SELECT * FROM inttbl WHERE 4294967295 <= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (4294967295 = `test`.`inttbl`.`colA`) +EXPLAIN SELECT * FROM inttbl WHERE 4294967295 < colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where false +EXPLAIN SELECT * FROM inttbl WHERE -1 < colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` is not null) +EXPLAIN SELECT * FROM inttbl WHERE -1 >= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where false +EXPLAIN SELECT * FROM inttbl WHERE 0 >= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (0 = `test`.`inttbl`.`colA`) +EXPLAIN SELECT * FROM inttbl WHERE 0 <= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` is not null) +EXPLAIN SELECT * FROM inttbl WHERE 0 < colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 33.33 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (0 < `test`.`inttbl`.`colA`) +EXPLAIN SELECT * FROM inttbl WHERE 4294967296 = colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where false +EXPLAIN SELECT * FROM inttbl WHERE 4294967296 <=> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where false +EXPLAIN SELECT * FROM inttbl WHERE 4294967296 <> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` is not null) +EXPLAIN SELECT * FROM inttbl WHERE 4294967295 = colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` = 4294967295) +EXPLAIN SELECT * FROM inttbl WHERE 4294967295 <=> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (4294967295 <=> `test`.`inttbl`.`colA`) +EXPLAIN SELECT * FROM inttbl WHERE 4294967295 <> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (4294967295 <> `test`.`inttbl`.`colA`) +EXPLAIN SELECT * FROM inttbl WHERE 0 = colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` = 0) +EXPLAIN SELECT * FROM inttbl WHERE 0 <=> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (0 <=> `test`.`inttbl`.`colA`) +EXPLAIN SELECT * FROM inttbl WHERE 0 <> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (0 <> `test`.`inttbl`.`colA`) +EXPLAIN SELECT * FROM inttbl WHERE -1 = colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where false +EXPLAIN SELECT * FROM inttbl WHERE -1 <=> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where false +EXPLAIN SELECT * FROM inttbl WHERE -1 <> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` is not null) +DROP TABLE inttbl; +# +# Tests with UNSIGNED type INT NOT NULL against int +# +CREATE TABLE inttbl (colA INT UNSIGNED NOT NULL); +INSERT INTO inttbl VALUES (0), (1), +(0),(1),(3), +(4294967294), (4294967295), +(0); +ANALYZE TABLE inttbl; +Table Op Msg_type Msg_text +test.inttbl analyze status OK +SELECT * FROM inttbl; +colA +0 +1 +0 +1 +3 +4294967294 +4294967295 +0 +SELECT * FROM inttbl WHERE colA < 4294967296; +colA +0 +1 +0 +1 +3 +4294967294 +4294967295 +0 +SELECT * FROM inttbl WHERE colA <= 4294967295; +colA +0 +1 +0 +1 +3 +4294967294 +4294967295 +0 +SELECT * FROM inttbl WHERE colA > 4294967296; +colA +SELECT * FROM inttbl WHERE colA >= 4294967295; +colA +4294967295 +SELECT * FROM inttbl WHERE colA > -1; +colA +0 +1 +0 +1 +3 +4294967294 +4294967295 +0 +SELECT * FROM inttbl WHERE colA <= -1; +colA +SELECT * FROM inttbl WHERE colA <= 0; +colA +0 +0 +0 +SELECT * FROM inttbl WHERE colA >= 0; +colA +0 +1 +0 +1 +3 +4294967294 +4294967295 +0 +SELECT * FROM inttbl WHERE colA > 0; +colA +1 +1 +3 +4294967294 +4294967295 +SELECT * FROM inttbl WHERE colA = 4294967296; +colA +SELECT * FROM inttbl WHERE colA <> 4294967296; +colA +0 +1 +0 +1 +3 +4294967294 +4294967295 +0 +SELECT * FROM inttbl WHERE colA = 4294967295; +colA +4294967295 +SELECT * FROM inttbl WHERE colA <=> 4294967295; +colA +4294967295 +SELECT * FROM inttbl WHERE NOT(colA <=> 4294967295); +colA +0 +1 +0 +1 +3 +4294967294 +0 +SELECT * FROM inttbl WHERE colA <> 4294967295; +colA +0 +1 +0 +1 +3 +4294967294 +0 +SELECT * FROM inttbl WHERE colA = 0; +colA +0 +0 +0 +SELECT * FROM inttbl WHERE colA <=> 0; +colA +0 +0 +0 +SELECT * FROM inttbl WHERE NOT(colA <=> 0); +colA +1 +1 +3 +4294967294 +4294967295 +SELECT * FROM inttbl WHERE colA <> 0; +colA +1 +1 +3 +4294967294 +4294967295 +SELECT * FROM inttbl WHERE colA = -1; +colA +SELECT * FROM inttbl WHERE colA <=> -1; +colA +SELECT * FROM inttbl WHERE NOT(colA <=> -1); +colA +0 +1 +0 +1 +3 +4294967294 +4294967295 +0 +SELECT * FROM inttbl WHERE colA <> -1; +colA +0 +1 +0 +1 +3 +4294967294 +4294967295 +0 +PREPARE p_less FROM 'SELECT * FROM inttbl WHERE colA < ?'; +PREPARE p_less_eq FROM 'SELECT * FROM inttbl WHERE colA <= ?'; +PREPARE p_greater FROM 'SELECT * FROM inttbl WHERE colA > ?'; +PREPARE p_gret_eq FROM 'SELECT * FROM inttbl WHERE colA >= ?'; +PREPARE p_eq FROM 'SELECT * FROM inttbl WHERE colA = ?'; +PREPARE p_equal FROM 'SELECT * FROM inttbl WHERE colA <=> ?'; +PREPARE p_n_equal FROM 'SELECT * FROM inttbl WHERE NOT(colA <=> ?)'; +PREPARE p_n_eq FROM 'SELECT * FROM inttbl WHERE colA <> ?'; +SET @maxint_plus_1=4294967296; +SET @maxint=4294967295; +SET @minint_minus_1=-1; +SET @minint=0; +EXECUTE p_less USING @maxint_plus_1; +colA +0 +1 +0 +1 +3 +4294967294 +4294967295 +0 +EXECUTE p_less_eq USING @maxint; +colA +0 +1 +0 +1 +3 +4294967294 +4294967295 +0 +EXECUTE p_greater USING @maxint_plus_1; +colA +EXECUTE p_gret_eq USING @maxint; +colA +4294967295 +EXECUTE p_greater USING @minint_minus_1; +colA +0 +1 +0 +1 +3 +4294967294 +4294967295 +0 +EXECUTE p_less_eq USING @minint_minus_1; +colA +EXECUTE p_less_eq USING @minint; +colA +0 +0 +0 +EXECUTE p_gret_eq USING @minint; +colA +0 +1 +0 +1 +3 +4294967294 +4294967295 +0 +EXECUTE p_greater USING @minint; +colA +1 +1 +3 +4294967294 +4294967295 +EXECUTE p_eq USING @maxint_plus_1; +colA +EXECUTE p_equal USING @maxint_plus_1; +colA +EXECUTE p_n_eq USING @maxint_plus_1; +colA +0 +1 +0 +1 +3 +4294967294 +4294967295 +0 +EXECUTE p_n_equal USING @maxint_plus_1; +colA +0 +1 +0 +1 +3 +4294967294 +4294967295 +0 +EXECUTE p_eq USING @maxint; +colA +4294967295 +EXECUTE p_equal USING @maxint; +colA +4294967295 +EXECUTE p_n_eq USING @maxint; +colA +0 +1 +0 +1 +3 +4294967294 +0 +EXECUTE p_n_equal USING @maxint; +colA +0 +1 +0 +1 +3 +4294967294 +0 +EXECUTE p_eq USING @minint; +colA +0 +0 +0 +EXECUTE p_equal USING @minint; +colA +0 +0 +0 +EXECUTE p_n_eq USING @minint; +colA +1 +1 +3 +4294967294 +4294967295 +EXECUTE p_n_equal USING @minint; +colA +1 +1 +3 +4294967294 +4294967295 +EXECUTE p_eq USING @minint_minus_1; +colA +EXECUTE p_equal USING @minint_minus_1; +colA +EXECUTE p_n_eq USING @minint_minus_1; +colA +0 +1 +0 +1 +3 +4294967294 +4294967295 +0 +EXECUTE p_n_equal USING @minint_minus_1; +colA +0 +1 +0 +1 +3 +4294967294 +4294967295 +0 +DROP PREPARE p_less; +DROP PREPARE p_less_eq; +DROP PREPARE p_greater; +DROP PREPARE p_gret_eq; +DROP PREPARE p_equal; +DROP PREPARE p_n_eq; +DROP PREPARE p_n_equal; +EXPLAIN SELECT * FROM inttbl WHERE colA < 4294967296; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where true +EXPLAIN SELECT * FROM inttbl WHERE colA <= 4294967295; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where true +EXPLAIN SELECT * FROM inttbl WHERE colA > 4294967296; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where false +EXPLAIN SELECT * FROM inttbl WHERE colA >= 4294967295; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` = 4294967295) +EXPLAIN SELECT * FROM inttbl WHERE colA > -1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where true +EXPLAIN SELECT * FROM inttbl WHERE colA <= -1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where false +EXPLAIN SELECT * FROM inttbl WHERE colA <= 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` = 0) +EXPLAIN SELECT * FROM inttbl WHERE colA >= 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where true +EXPLAIN SELECT * FROM inttbl WHERE colA > 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 33.33 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` > 0) +EXPLAIN SELECT * FROM inttbl WHERE colA = 4294967296; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where false +EXPLAIN SELECT * FROM inttbl WHERE colA <=> 4294967296; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where false +EXPLAIN SELECT * FROM inttbl WHERE colA <> 4294967296; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where true +EXPLAIN SELECT * FROM inttbl WHERE colA = 4294967295; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` = 4294967295) +EXPLAIN SELECT * FROM inttbl WHERE colA <=> 4294967295; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` <=> 4294967295) +EXPLAIN SELECT * FROM inttbl WHERE colA <> 4294967295; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` <> 4294967295) +EXPLAIN SELECT * FROM inttbl WHERE colA = 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` = 0) +EXPLAIN SELECT * FROM inttbl WHERE colA <=> 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` <=> 0) +EXPLAIN SELECT * FROM inttbl WHERE colA <> 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` <> 0) +EXPLAIN SELECT * FROM inttbl WHERE colA = -1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where false +EXPLAIN SELECT * FROM inttbl WHERE colA <=> -1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where false +EXPLAIN SELECT * FROM inttbl WHERE colA <> -1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where true +same queries but constant first +SELECT * FROM inttbl WHERE 4294967296 > colA; +colA +0 +1 +0 +1 +3 +4294967294 +4294967295 +0 +SELECT * FROM inttbl WHERE 4294967295 >= colA; +colA +0 +1 +0 +1 +3 +4294967294 +4294967295 +0 +SELECT * FROM inttbl WHERE 4294967296 < colA; +colA +SELECT * FROM inttbl WHERE 4294967295 <= colA; +colA +4294967295 +SELECT * FROM inttbl WHERE 4294967295 < colA; +colA +SELECT * FROM inttbl WHERE -1 < colA; +colA +0 +1 +0 +1 +3 +4294967294 +4294967295 +0 +SELECT * FROM inttbl WHERE -1 >= colA; +colA +SELECT * FROM inttbl WHERE 0 >= colA; +colA +0 +0 +0 +SELECT * FROM inttbl WHERE 0 <= colA; +colA +0 +1 +0 +1 +3 +4294967294 +4294967295 +0 +SELECT * FROM inttbl WHERE 0 < colA; +colA +1 +1 +3 +4294967294 +4294967295 +SELECT * FROM inttbl WHERE 4294967296 = colA; +colA +SELECT * FROM inttbl WHERE 4294967296 <=> colA; +colA +SELECT * FROM inttbl WHERE 4294967296 <> colA; +colA +0 +1 +0 +1 +3 +4294967294 +4294967295 +0 +SELECT * FROM inttbl WHERE 4294967295 = colA; +colA +4294967295 +SELECT * FROM inttbl WHERE 4294967295 <=> colA; +colA +4294967295 +SELECT * FROM inttbl WHERE 4294967295 <> colA; +colA +0 +1 +0 +1 +3 +4294967294 +0 +SELECT * FROM inttbl WHERE 0 = colA; +colA +0 +0 +0 +SELECT * FROM inttbl WHERE 0 <=> colA; +colA +0 +0 +0 +SELECT * FROM inttbl WHERE 0 <> colA; +colA +1 +1 +3 +4294967294 +4294967295 +SELECT * FROM inttbl WHERE -1 = colA; +colA +SELECT * FROM inttbl WHERE -1 <=> colA; +colA +SELECT * FROM inttbl WHERE -1 <> colA; +colA +0 +1 +0 +1 +3 +4294967294 +4294967295 +0 +PREPARE p_less FROM 'SELECT * FROM inttbl WHERE ? < colA'; +PREPARE p_less_eq FROM 'SELECT * FROM inttbl WHERE ? <= colA'; +PREPARE p_greater FROM 'SELECT * FROM inttbl WHERE ? > colA'; +PREPARE p_gret_eq FROM 'SELECT * FROM inttbl WHERE ? >= colA'; +PREPARE p_eq FROM 'SELECT * FROM inttbl WHERE ? = colA'; +PREPARE p_equal FROM 'SELECT * FROM inttbl WHERE ? <=> colA'; +PREPARE p_n_eq FROM 'SELECT * FROM inttbl WHERE ? <> colA'; +PREPARE p_n_equal FROM 'SELECT * FROM inttbl WHERE NOT(? <=> colA)'; +EXECUTE p_greater USING @maxint_plus_1; +colA +0 +1 +0 +1 +3 +4294967294 +4294967295 +0 +EXECUTE p_gret_eq USING @maxint; +colA +0 +1 +0 +1 +3 +4294967294 +4294967295 +0 +EXECUTE p_less USING @maxint_plus_1; +colA +EXECUTE p_less_eq USING @maxint; +colA +4294967295 +EXECUTE p_less USING @minint_minus_1; +colA +0 +1 +0 +1 +3 +4294967294 +4294967295 +0 +EXECUTE p_gret_eq USING @minint_minus_1; +colA +EXECUTE p_gret_eq USING @minint; +colA +0 +0 +0 +EXECUTE p_less_eq USING @minint; +colA +0 +1 +0 +1 +3 +4294967294 +4294967295 +0 +EXECUTE p_less USING @minint; +colA +1 +1 +3 +4294967294 +4294967295 +EXECUTE p_eq USING @maxint_plus_1; +colA +EXECUTE p_equal USING @maxint_plus_1; +colA +EXECUTE p_n_eq USING @maxint_plus_1; +colA +0 +1 +0 +1 +3 +4294967294 +4294967295 +0 +EXECUTE p_n_equal USING @maxint_plus_1; +colA +0 +1 +0 +1 +3 +4294967294 +4294967295 +0 +EXECUTE p_eq USING @maxint; +colA +4294967295 +EXECUTE p_equal USING @maxint; +colA +4294967295 +EXECUTE p_n_eq USING @maxint; +colA +0 +1 +0 +1 +3 +4294967294 +0 +EXECUTE p_n_equal USING @maxint; +colA +0 +1 +0 +1 +3 +4294967294 +0 +EXECUTE p_eq USING @minint; +colA +0 +0 +0 +EXECUTE p_equal USING @minint; +colA +0 +0 +0 +EXECUTE p_n_eq USING @minint; +colA +1 +1 +3 +4294967294 +4294967295 +EXECUTE p_n_equal USING @minint; +colA +1 +1 +3 +4294967294 +4294967295 +EXECUTE p_eq USING @minint_minus_1; +colA +EXECUTE p_equal USING @minint_minus_1; +colA +EXECUTE p_n_eq USING @minint_minus_1; +colA +0 +1 +0 +1 +3 +4294967294 +4294967295 +0 +EXECUTE p_n_equal USING @minint_minus_1; +colA +0 +1 +0 +1 +3 +4294967294 +4294967295 +0 +DROP PREPARE p_less; +DROP PREPARE p_less_eq; +DROP PREPARE p_greater; +DROP PREPARE p_gret_eq; +DROP PREPARE p_equal; +DROP PREPARE p_n_eq; +DROP PREPARE p_n_equal; +EXPLAIN SELECT * FROM inttbl WHERE 4294967296 > colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where true +EXPLAIN SELECT * FROM inttbl WHERE 4294967295 >= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where true +EXPLAIN SELECT * FROM inttbl WHERE 4294967296 < colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where false +EXPLAIN SELECT * FROM inttbl WHERE 4294967295 <= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (4294967295 = `test`.`inttbl`.`colA`) +EXPLAIN SELECT * FROM inttbl WHERE 4294967295 < colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where false +EXPLAIN SELECT * FROM inttbl WHERE -1 < colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where true +EXPLAIN SELECT * FROM inttbl WHERE -1 >= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where false +EXPLAIN SELECT * FROM inttbl WHERE 0 >= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (0 = `test`.`inttbl`.`colA`) +EXPLAIN SELECT * FROM inttbl WHERE 0 <= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where true +EXPLAIN SELECT * FROM inttbl WHERE 0 < colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 33.33 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (0 < `test`.`inttbl`.`colA`) +EXPLAIN SELECT * FROM inttbl WHERE 4294967296 = colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where false +EXPLAIN SELECT * FROM inttbl WHERE 4294967296 <=> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where false +EXPLAIN SELECT * FROM inttbl WHERE 4294967296 <> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where true +EXPLAIN SELECT * FROM inttbl WHERE 4294967295 = colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` = 4294967295) +EXPLAIN SELECT * FROM inttbl WHERE 4294967295 <=> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (4294967295 <=> `test`.`inttbl`.`colA`) +EXPLAIN SELECT * FROM inttbl WHERE 4294967295 <> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (4294967295 <> `test`.`inttbl`.`colA`) +EXPLAIN SELECT * FROM inttbl WHERE 0 = colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` = 0) +EXPLAIN SELECT * FROM inttbl WHERE 0 <=> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (0 <=> `test`.`inttbl`.`colA`) +EXPLAIN SELECT * FROM inttbl WHERE 0 <> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (0 <> `test`.`inttbl`.`colA`) +EXPLAIN SELECT * FROM inttbl WHERE -1 = colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where false +EXPLAIN SELECT * FROM inttbl WHERE -1 <=> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where false +EXPLAIN SELECT * FROM inttbl WHERE -1 <> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where true +DROP TABLE inttbl; +# +# Tests with type INT against int +# +CREATE TABLE inttbls (colA INT ); +INSERT INTO inttbls VALUES (-2147483648), (-2147483647), +(0),(1),(3), +(2147483646), (2147483647), +(NULL); +ANALYZE TABLE inttbls; +Table Op Msg_type Msg_text +test.inttbls analyze status OK +SELECT * FROM inttbls; +colA +-2147483648 +-2147483647 +0 +1 +3 +2147483646 +2147483647 +NULL +SELECT * FROM inttbls WHERE colA < 2147483648; +colA +-2147483648 +-2147483647 +0 +1 +3 +2147483646 +2147483647 +SELECT * FROM inttbls WHERE colA <= 2147483647; +colA +-2147483648 +-2147483647 +0 +1 +3 +2147483646 +2147483647 +SELECT * FROM inttbls WHERE colA > 2147483648; +colA +SELECT * FROM inttbls WHERE colA >= 2147483647; +colA +2147483647 +SELECT * FROM inttbls WHERE colA > -2147483649; +colA +-2147483648 +-2147483647 +0 +1 +3 +2147483646 +2147483647 +SELECT * FROM inttbls WHERE colA <= -2147483649; +colA +SELECT * FROM inttbls WHERE colA <= -2147483648; +colA +-2147483648 +SELECT * FROM inttbls WHERE colA >= -2147483648; +colA +-2147483648 +-2147483647 +0 +1 +3 +2147483646 +2147483647 +SELECT * FROM inttbls WHERE colA > -2147483648; +colA +-2147483647 +0 +1 +3 +2147483646 +2147483647 +SELECT * FROM inttbls WHERE colA = 2147483648; +colA +SELECT * FROM inttbls WHERE colA <> 2147483648; +colA +-2147483648 +-2147483647 +0 +1 +3 +2147483646 +2147483647 +SELECT * FROM inttbls WHERE colA = 2147483647; +colA +2147483647 +SELECT * FROM inttbls WHERE colA <=> 2147483647; +colA +2147483647 +SELECT * FROM inttbls WHERE NOT(colA <=> 2147483647); +colA +-2147483648 +-2147483647 +0 +1 +3 +2147483646 +NULL +SELECT * FROM inttbls WHERE colA <> 2147483647; +colA +-2147483648 +-2147483647 +0 +1 +3 +2147483646 +SELECT * FROM inttbls WHERE colA = -2147483648; +colA +-2147483648 +SELECT * FROM inttbls WHERE colA <=> -2147483648; +colA +-2147483648 +SELECT * FROM inttbls WHERE NOT(colA <=> -2147483648); +colA +-2147483647 +0 +1 +3 +2147483646 +2147483647 +NULL +SELECT * FROM inttbls WHERE colA <> -2147483648; +colA +-2147483647 +0 +1 +3 +2147483646 +2147483647 +SELECT * FROM inttbls WHERE colA = -2147483649; +colA +SELECT * FROM inttbls WHERE colA <=> -2147483649; +colA +SELECT * FROM inttbls WHERE NOT(colA <=> -2147483649); +colA +-2147483648 +-2147483647 +0 +1 +3 +2147483646 +2147483647 +NULL +SELECT * FROM inttbls WHERE colA <> -2147483649; +colA +-2147483648 +-2147483647 +0 +1 +3 +2147483646 +2147483647 +PREPARE p_less FROM 'SELECT * FROM inttbls WHERE colA < ?'; +PREPARE p_less_eq FROM 'SELECT * FROM inttbls WHERE colA <= ?'; +PREPARE p_greater FROM 'SELECT * FROM inttbls WHERE colA > ?'; +PREPARE p_gret_eq FROM 'SELECT * FROM inttbls WHERE colA >= ?'; +PREPARE p_eq FROM 'SELECT * FROM inttbls WHERE colA = ?'; +PREPARE p_equal FROM 'SELECT * FROM inttbls WHERE colA <=> ?'; +PREPARE p_n_equal FROM 'SELECT * FROM inttbls WHERE NOT(colA <=> ?)'; +PREPARE p_n_eq FROM 'SELECT * FROM inttbls WHERE colA <> ?'; +SET @maxint_plus_1=2147483648; +SET @maxint=2147483647; +SET @minint_minus_1=-2147483649; +SET @minint=-2147483648; +EXECUTE p_less USING @maxint_plus_1; +colA +-2147483648 +-2147483647 +0 +1 +3 +2147483646 +2147483647 +EXECUTE p_less_eq USING @maxint; +colA +-2147483648 +-2147483647 +0 +1 +3 +2147483646 +2147483647 +EXECUTE p_greater USING @maxint_plus_1; +colA +EXECUTE p_gret_eq USING @maxint; +colA +2147483647 +EXECUTE p_greater USING @minint_minus_1; +colA +-2147483648 +-2147483647 +0 +1 +3 +2147483646 +2147483647 +EXECUTE p_less_eq USING @minint_minus_1; +colA +EXECUTE p_less_eq USING @minint; +colA +-2147483648 +EXECUTE p_gret_eq USING @minint; +colA +-2147483648 +-2147483647 +0 +1 +3 +2147483646 +2147483647 +EXECUTE p_greater USING @minint; +colA +-2147483647 +0 +1 +3 +2147483646 +2147483647 +EXECUTE p_eq USING @maxint_plus_1; +colA +EXECUTE p_equal USING @maxint_plus_1; +colA +EXECUTE p_n_eq USING @maxint_plus_1; +colA +-2147483648 +-2147483647 +0 +1 +3 +2147483646 +2147483647 +EXECUTE p_n_equal USING @maxint_plus_1; +colA +-2147483648 +-2147483647 +0 +1 +3 +2147483646 +2147483647 +NULL +EXECUTE p_eq USING @maxint; +colA +2147483647 +EXECUTE p_equal USING @maxint; +colA +2147483647 +EXECUTE p_n_eq USING @maxint; +colA +-2147483648 +-2147483647 +0 +1 +3 +2147483646 +EXECUTE p_n_equal USING @maxint; +colA +-2147483648 +-2147483647 +0 +1 +3 +2147483646 +NULL +EXECUTE p_eq USING @minint; +colA +-2147483648 +EXECUTE p_equal USING @minint; +colA +-2147483648 +EXECUTE p_n_eq USING @minint; +colA +-2147483647 +0 +1 +3 +2147483646 +2147483647 +EXECUTE p_n_equal USING @minint; +colA +-2147483647 +0 +1 +3 +2147483646 +2147483647 +NULL +EXECUTE p_eq USING @minint_minus_1; +colA +EXECUTE p_equal USING @minint_minus_1; +colA +EXECUTE p_n_eq USING @minint_minus_1; +colA +-2147483648 +-2147483647 +0 +1 +3 +2147483646 +2147483647 +EXECUTE p_n_equal USING @minint_minus_1; +colA +-2147483648 +-2147483647 +0 +1 +3 +2147483646 +2147483647 +NULL +DROP PREPARE p_less; +DROP PREPARE p_less_eq; +DROP PREPARE p_greater; +DROP PREPARE p_gret_eq; +DROP PREPARE p_equal; +DROP PREPARE p_n_eq; +DROP PREPARE p_n_equal; +EXPLAIN SELECT * FROM inttbls WHERE colA < 2147483648; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where (`test`.`inttbls`.`colA` is not null) +EXPLAIN SELECT * FROM inttbls WHERE colA <= 2147483647; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where (`test`.`inttbls`.`colA` is not null) +EXPLAIN SELECT * FROM inttbls WHERE colA > 2147483648; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where false +EXPLAIN SELECT * FROM inttbls WHERE colA >= 2147483647; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where (`test`.`inttbls`.`colA` = 2147483647) +EXPLAIN SELECT * FROM inttbls WHERE colA > -2147483649; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where (`test`.`inttbls`.`colA` is not null) +EXPLAIN SELECT * FROM inttbls WHERE colA <= -2147483649; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where false +EXPLAIN SELECT * FROM inttbls WHERE colA <= -2147483648; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where (`test`.`inttbls`.`colA` = (-(2147483648))) +EXPLAIN SELECT * FROM inttbls WHERE colA >= -2147483648; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where (`test`.`inttbls`.`colA` is not null) +EXPLAIN SELECT * FROM inttbls WHERE colA > -2147483648; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 33.33 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where (`test`.`inttbls`.`colA` > (-(2147483648))) +EXPLAIN SELECT * FROM inttbls WHERE colA = 2147483648; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where false +EXPLAIN SELECT * FROM inttbls WHERE colA <=> 2147483648; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where false +EXPLAIN SELECT * FROM inttbls WHERE colA <> 2147483648; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where (`test`.`inttbls`.`colA` is not null) +EXPLAIN SELECT * FROM inttbls WHERE colA = 2147483647; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where (`test`.`inttbls`.`colA` = 2147483647) +EXPLAIN SELECT * FROM inttbls WHERE colA <=> 2147483647; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where (`test`.`inttbls`.`colA` <=> 2147483647) +EXPLAIN SELECT * FROM inttbls WHERE colA <> 2147483647; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where (`test`.`inttbls`.`colA` <> 2147483647) +EXPLAIN SELECT * FROM inttbls WHERE colA = -2147483648; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where (`test`.`inttbls`.`colA` = (-(2147483648))) +EXPLAIN SELECT * FROM inttbls WHERE colA <=> -2147483648; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where (`test`.`inttbls`.`colA` <=> (-(2147483648))) +EXPLAIN SELECT * FROM inttbls WHERE colA <> -2147483648; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where (`test`.`inttbls`.`colA` <> (-(2147483648))) +EXPLAIN SELECT * FROM inttbls WHERE colA = -2147483649; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where false +EXPLAIN SELECT * FROM inttbls WHERE colA <=> -2147483649; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where false +EXPLAIN SELECT * FROM inttbls WHERE colA <> -2147483649; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where (`test`.`inttbls`.`colA` is not null) +same queries but constant first +SELECT * FROM inttbls WHERE 2147483648 > colA; +colA +-2147483648 +-2147483647 +0 +1 +3 +2147483646 +2147483647 +SELECT * FROM inttbls WHERE 2147483647 >= colA; +colA +-2147483648 +-2147483647 +0 +1 +3 +2147483646 +2147483647 +SELECT * FROM inttbls WHERE 2147483648 < colA; +colA +SELECT * FROM inttbls WHERE 2147483647 <= colA; +colA +2147483647 +SELECT * FROM inttbls WHERE 2147483647 < colA; +colA +SELECT * FROM inttbls WHERE -2147483649 < colA; +colA +-2147483648 +-2147483647 +0 +1 +3 +2147483646 +2147483647 +SELECT * FROM inttbls WHERE -2147483649 >= colA; +colA +SELECT * FROM inttbls WHERE -2147483648 >= colA; +colA +-2147483648 +SELECT * FROM inttbls WHERE -2147483648 <= colA; +colA +-2147483648 +-2147483647 +0 +1 +3 +2147483646 +2147483647 +SELECT * FROM inttbls WHERE -2147483648 < colA; +colA +-2147483647 +0 +1 +3 +2147483646 +2147483647 +SELECT * FROM inttbls WHERE 2147483648 = colA; +colA +SELECT * FROM inttbls WHERE 2147483648 <=> colA; +colA +SELECT * FROM inttbls WHERE 2147483648 <> colA; +colA +-2147483648 +-2147483647 +0 +1 +3 +2147483646 +2147483647 +SELECT * FROM inttbls WHERE 2147483647 = colA; +colA +2147483647 +SELECT * FROM inttbls WHERE 2147483647 <=> colA; +colA +2147483647 +SELECT * FROM inttbls WHERE 2147483647 <> colA; +colA +-2147483648 +-2147483647 +0 +1 +3 +2147483646 +SELECT * FROM inttbls WHERE -2147483648 = colA; +colA +-2147483648 +SELECT * FROM inttbls WHERE -2147483648 <=> colA; +colA +-2147483648 +SELECT * FROM inttbls WHERE -2147483648 <> colA; +colA +-2147483647 +0 +1 +3 +2147483646 +2147483647 +SELECT * FROM inttbls WHERE -2147483649 = colA; +colA +SELECT * FROM inttbls WHERE -2147483649 <=> colA; +colA +SELECT * FROM inttbls WHERE -2147483649 <> colA; +colA +-2147483648 +-2147483647 +0 +1 +3 +2147483646 +2147483647 +PREPARE p_less FROM 'SELECT * FROM inttbls WHERE ? < colA'; +PREPARE p_less_eq FROM 'SELECT * FROM inttbls WHERE ? <= colA'; +PREPARE p_greater FROM 'SELECT * FROM inttbls WHERE ? > colA'; +PREPARE p_gret_eq FROM 'SELECT * FROM inttbls WHERE ? >= colA'; +PREPARE p_eq FROM 'SELECT * FROM inttbls WHERE ? = colA'; +PREPARE p_equal FROM 'SELECT * FROM inttbls WHERE ? <=> colA'; +PREPARE p_n_eq FROM 'SELECT * FROM inttbls WHERE ? <> colA'; +PREPARE p_n_equal FROM 'SELECT * FROM inttbls WHERE NOT(? <=> colA)'; +EXECUTE p_greater USING @maxint_plus_1; +colA +-2147483648 +-2147483647 +0 +1 +3 +2147483646 +2147483647 +EXECUTE p_gret_eq USING @maxint; +colA +-2147483648 +-2147483647 +0 +1 +3 +2147483646 +2147483647 +EXECUTE p_less USING @maxint_plus_1; +colA +EXECUTE p_less_eq USING @maxint; +colA +2147483647 +EXECUTE p_less USING @minint_minus_1; +colA +-2147483648 +-2147483647 +0 +1 +3 +2147483646 +2147483647 +EXECUTE p_gret_eq USING @minint_minus_1; +colA +EXECUTE p_gret_eq USING @minint; +colA +-2147483648 +EXECUTE p_less_eq USING @minint; +colA +-2147483648 +-2147483647 +0 +1 +3 +2147483646 +2147483647 +EXECUTE p_less USING @minint; +colA +-2147483647 +0 +1 +3 +2147483646 +2147483647 +EXECUTE p_eq USING @maxint_plus_1; +colA +EXECUTE p_equal USING @maxint_plus_1; +colA +EXECUTE p_n_eq USING @maxint_plus_1; +colA +-2147483648 +-2147483647 +0 +1 +3 +2147483646 +2147483647 +EXECUTE p_n_equal USING @maxint_plus_1; +colA +-2147483648 +-2147483647 +0 +1 +3 +2147483646 +2147483647 +NULL +EXECUTE p_eq USING @maxint; +colA +2147483647 +EXECUTE p_equal USING @maxint; +colA +2147483647 +EXECUTE p_n_eq USING @maxint; +colA +-2147483648 +-2147483647 +0 +1 +3 +2147483646 +EXECUTE p_n_equal USING @maxint; +colA +-2147483648 +-2147483647 +0 +1 +3 +2147483646 +NULL +EXECUTE p_eq USING @minint; +colA +-2147483648 +EXECUTE p_equal USING @minint; +colA +-2147483648 +EXECUTE p_n_eq USING @minint; +colA +-2147483647 +0 +1 +3 +2147483646 +2147483647 +EXECUTE p_n_equal USING @minint; +colA +-2147483647 +0 +1 +3 +2147483646 +2147483647 +NULL +EXECUTE p_eq USING @minint_minus_1; +colA +EXECUTE p_equal USING @minint_minus_1; +colA +EXECUTE p_n_eq USING @minint_minus_1; +colA +-2147483648 +-2147483647 +0 +1 +3 +2147483646 +2147483647 +EXECUTE p_n_equal USING @minint_minus_1; +colA +-2147483648 +-2147483647 +0 +1 +3 +2147483646 +2147483647 +NULL +DROP PREPARE p_less; +DROP PREPARE p_less_eq; +DROP PREPARE p_greater; +DROP PREPARE p_gret_eq; +DROP PREPARE p_equal; +DROP PREPARE p_n_eq; +DROP PREPARE p_n_equal; +EXPLAIN SELECT * FROM inttbls WHERE 2147483648 > colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where (`test`.`inttbls`.`colA` is not null) +EXPLAIN SELECT * FROM inttbls WHERE 2147483647 >= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where (`test`.`inttbls`.`colA` is not null) +EXPLAIN SELECT * FROM inttbls WHERE 2147483648 < colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where false +EXPLAIN SELECT * FROM inttbls WHERE 2147483647 <= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where (2147483647 = `test`.`inttbls`.`colA`) +EXPLAIN SELECT * FROM inttbls WHERE 2147483647 < colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where false +EXPLAIN SELECT * FROM inttbls WHERE -2147483649 < colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where (`test`.`inttbls`.`colA` is not null) +EXPLAIN SELECT * FROM inttbls WHERE -2147483649 >= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where false +EXPLAIN SELECT * FROM inttbls WHERE -2147483648 >= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where ((-(2147483648)) = `test`.`inttbls`.`colA`) +EXPLAIN SELECT * FROM inttbls WHERE -2147483648 <= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where (`test`.`inttbls`.`colA` is not null) +EXPLAIN SELECT * FROM inttbls WHERE -2147483648 < colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 33.33 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where ((-(2147483648)) < `test`.`inttbls`.`colA`) +EXPLAIN SELECT * FROM inttbls WHERE 2147483648 = colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where false +EXPLAIN SELECT * FROM inttbls WHERE 2147483648 <=> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where false +EXPLAIN SELECT * FROM inttbls WHERE 2147483648 <> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where (`test`.`inttbls`.`colA` is not null) +EXPLAIN SELECT * FROM inttbls WHERE 2147483647 = colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where (`test`.`inttbls`.`colA` = 2147483647) +EXPLAIN SELECT * FROM inttbls WHERE 2147483647 <=> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where (2147483647 <=> `test`.`inttbls`.`colA`) +EXPLAIN SELECT * FROM inttbls WHERE 2147483647 <> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where (2147483647 <> `test`.`inttbls`.`colA`) +EXPLAIN SELECT * FROM inttbls WHERE -2147483648 = colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where (`test`.`inttbls`.`colA` = (-(2147483648))) +EXPLAIN SELECT * FROM inttbls WHERE -2147483648 <=> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where ((-(2147483648)) <=> `test`.`inttbls`.`colA`) +EXPLAIN SELECT * FROM inttbls WHERE -2147483648 <> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where ((-(2147483648)) <> `test`.`inttbls`.`colA`) +EXPLAIN SELECT * FROM inttbls WHERE -2147483649 = colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where false +EXPLAIN SELECT * FROM inttbls WHERE -2147483649 <=> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where false +EXPLAIN SELECT * FROM inttbls WHERE -2147483649 <> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where (`test`.`inttbls`.`colA` is not null) +DROP TABLE inttbls; +# +# Tests with type INT NOT NULL against int +# +CREATE TABLE inttbls (colA INT NOT NULL); +INSERT INTO inttbls VALUES (-2147483648), (-2147483647), +(0),(1),(3), +(2147483646), (2147483647), +(0); +ANALYZE TABLE inttbls; +Table Op Msg_type Msg_text +test.inttbls analyze status OK +SELECT * FROM inttbls; +colA +-2147483648 +-2147483647 +0 +1 +3 +2147483646 +2147483647 +0 +SELECT * FROM inttbls WHERE colA < 2147483648; +colA +-2147483648 +-2147483647 +0 +1 +3 +2147483646 +2147483647 +0 +SELECT * FROM inttbls WHERE colA <= 2147483647; +colA +-2147483648 +-2147483647 +0 +1 +3 +2147483646 +2147483647 +0 +SELECT * FROM inttbls WHERE colA > 2147483648; +colA +SELECT * FROM inttbls WHERE colA >= 2147483647; +colA +2147483647 +SELECT * FROM inttbls WHERE colA > -2147483649; +colA +-2147483648 +-2147483647 +0 +1 +3 +2147483646 +2147483647 +0 +SELECT * FROM inttbls WHERE colA <= -2147483649; +colA +SELECT * FROM inttbls WHERE colA <= -2147483648; +colA +-2147483648 +SELECT * FROM inttbls WHERE colA >= -2147483648; +colA +-2147483648 +-2147483647 +0 +1 +3 +2147483646 +2147483647 +0 +SELECT * FROM inttbls WHERE colA > -2147483648; +colA +-2147483647 +0 +1 +3 +2147483646 +2147483647 +0 +SELECT * FROM inttbls WHERE colA = 2147483648; +colA +SELECT * FROM inttbls WHERE colA <> 2147483648; +colA +-2147483648 +-2147483647 +0 +1 +3 +2147483646 +2147483647 +0 +SELECT * FROM inttbls WHERE colA = 2147483647; +colA +2147483647 +SELECT * FROM inttbls WHERE colA <=> 2147483647; +colA +2147483647 +SELECT * FROM inttbls WHERE NOT(colA <=> 2147483647); +colA +-2147483648 +-2147483647 +0 +1 +3 +2147483646 +0 +SELECT * FROM inttbls WHERE colA <> 2147483647; +colA +-2147483648 +-2147483647 +0 +1 +3 +2147483646 +0 +SELECT * FROM inttbls WHERE colA = -2147483648; +colA +-2147483648 +SELECT * FROM inttbls WHERE colA <=> -2147483648; +colA +-2147483648 +SELECT * FROM inttbls WHERE NOT(colA <=> -2147483648); +colA +-2147483647 +0 +1 +3 +2147483646 +2147483647 +0 +SELECT * FROM inttbls WHERE colA <> -2147483648; +colA +-2147483647 +0 +1 +3 +2147483646 +2147483647 +0 +SELECT * FROM inttbls WHERE colA = -2147483649; +colA +SELECT * FROM inttbls WHERE colA <=> -2147483649; +colA +SELECT * FROM inttbls WHERE NOT(colA <=> -2147483649); +colA +-2147483648 +-2147483647 +0 +1 +3 +2147483646 +2147483647 +0 +SELECT * FROM inttbls WHERE colA <> -2147483649; +colA +-2147483648 +-2147483647 +0 +1 +3 +2147483646 +2147483647 +0 +PREPARE p_less FROM 'SELECT * FROM inttbls WHERE colA < ?'; +PREPARE p_less_eq FROM 'SELECT * FROM inttbls WHERE colA <= ?'; +PREPARE p_greater FROM 'SELECT * FROM inttbls WHERE colA > ?'; +PREPARE p_gret_eq FROM 'SELECT * FROM inttbls WHERE colA >= ?'; +PREPARE p_eq FROM 'SELECT * FROM inttbls WHERE colA = ?'; +PREPARE p_equal FROM 'SELECT * FROM inttbls WHERE colA <=> ?'; +PREPARE p_n_equal FROM 'SELECT * FROM inttbls WHERE NOT(colA <=> ?)'; +PREPARE p_n_eq FROM 'SELECT * FROM inttbls WHERE colA <> ?'; +SET @maxint_plus_1=2147483648; +SET @maxint=2147483647; +SET @minint_minus_1=-2147483649; +SET @minint=-2147483648; +EXECUTE p_less USING @maxint_plus_1; +colA +-2147483648 +-2147483647 +0 +1 +3 +2147483646 +2147483647 +0 +EXECUTE p_less_eq USING @maxint; +colA +-2147483648 +-2147483647 +0 +1 +3 +2147483646 +2147483647 +0 +EXECUTE p_greater USING @maxint_plus_1; +colA +EXECUTE p_gret_eq USING @maxint; +colA +2147483647 +EXECUTE p_greater USING @minint_minus_1; +colA +-2147483648 +-2147483647 +0 +1 +3 +2147483646 +2147483647 +0 +EXECUTE p_less_eq USING @minint_minus_1; +colA +EXECUTE p_less_eq USING @minint; +colA +-2147483648 +EXECUTE p_gret_eq USING @minint; +colA +-2147483648 +-2147483647 +0 +1 +3 +2147483646 +2147483647 +0 +EXECUTE p_greater USING @minint; +colA +-2147483647 +0 +1 +3 +2147483646 +2147483647 +0 +EXECUTE p_eq USING @maxint_plus_1; +colA +EXECUTE p_equal USING @maxint_plus_1; +colA +EXECUTE p_n_eq USING @maxint_plus_1; +colA +-2147483648 +-2147483647 +0 +1 +3 +2147483646 +2147483647 +0 +EXECUTE p_n_equal USING @maxint_plus_1; +colA +-2147483648 +-2147483647 +0 +1 +3 +2147483646 +2147483647 +0 +EXECUTE p_eq USING @maxint; +colA +2147483647 +EXECUTE p_equal USING @maxint; +colA +2147483647 +EXECUTE p_n_eq USING @maxint; +colA +-2147483648 +-2147483647 +0 +1 +3 +2147483646 +0 +EXECUTE p_n_equal USING @maxint; +colA +-2147483648 +-2147483647 +0 +1 +3 +2147483646 +0 +EXECUTE p_eq USING @minint; +colA +-2147483648 +EXECUTE p_equal USING @minint; +colA +-2147483648 +EXECUTE p_n_eq USING @minint; +colA +-2147483647 +0 +1 +3 +2147483646 +2147483647 +0 +EXECUTE p_n_equal USING @minint; +colA +-2147483647 +0 +1 +3 +2147483646 +2147483647 +0 +EXECUTE p_eq USING @minint_minus_1; +colA +EXECUTE p_equal USING @minint_minus_1; +colA +EXECUTE p_n_eq USING @minint_minus_1; +colA +-2147483648 +-2147483647 +0 +1 +3 +2147483646 +2147483647 +0 +EXECUTE p_n_equal USING @minint_minus_1; +colA +-2147483648 +-2147483647 +0 +1 +3 +2147483646 +2147483647 +0 +DROP PREPARE p_less; +DROP PREPARE p_less_eq; +DROP PREPARE p_greater; +DROP PREPARE p_gret_eq; +DROP PREPARE p_equal; +DROP PREPARE p_n_eq; +DROP PREPARE p_n_equal; +EXPLAIN SELECT * FROM inttbls WHERE colA < 2147483648; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where true +EXPLAIN SELECT * FROM inttbls WHERE colA <= 2147483647; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where true +EXPLAIN SELECT * FROM inttbls WHERE colA > 2147483648; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where false +EXPLAIN SELECT * FROM inttbls WHERE colA >= 2147483647; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where (`test`.`inttbls`.`colA` = 2147483647) +EXPLAIN SELECT * FROM inttbls WHERE colA > -2147483649; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where true +EXPLAIN SELECT * FROM inttbls WHERE colA <= -2147483649; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where false +EXPLAIN SELECT * FROM inttbls WHERE colA <= -2147483648; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where (`test`.`inttbls`.`colA` = (-(2147483648))) +EXPLAIN SELECT * FROM inttbls WHERE colA >= -2147483648; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where true +EXPLAIN SELECT * FROM inttbls WHERE colA > -2147483648; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 33.33 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where (`test`.`inttbls`.`colA` > (-(2147483648))) +EXPLAIN SELECT * FROM inttbls WHERE colA = 2147483648; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where false +EXPLAIN SELECT * FROM inttbls WHERE colA <=> 2147483648; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where false +EXPLAIN SELECT * FROM inttbls WHERE colA <> 2147483648; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where true +EXPLAIN SELECT * FROM inttbls WHERE colA = 2147483647; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where (`test`.`inttbls`.`colA` = 2147483647) +EXPLAIN SELECT * FROM inttbls WHERE colA <=> 2147483647; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where (`test`.`inttbls`.`colA` <=> 2147483647) +EXPLAIN SELECT * FROM inttbls WHERE colA <> 2147483647; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where (`test`.`inttbls`.`colA` <> 2147483647) +EXPLAIN SELECT * FROM inttbls WHERE colA = -2147483648; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where (`test`.`inttbls`.`colA` = (-(2147483648))) +EXPLAIN SELECT * FROM inttbls WHERE colA <=> -2147483648; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where (`test`.`inttbls`.`colA` <=> (-(2147483648))) +EXPLAIN SELECT * FROM inttbls WHERE colA <> -2147483648; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where (`test`.`inttbls`.`colA` <> (-(2147483648))) +EXPLAIN SELECT * FROM inttbls WHERE colA = -2147483649; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where false +EXPLAIN SELECT * FROM inttbls WHERE colA <=> -2147483649; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where false +EXPLAIN SELECT * FROM inttbls WHERE colA <> -2147483649; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where true +same queries but constant first +SELECT * FROM inttbls WHERE 2147483648 > colA; +colA +-2147483648 +-2147483647 +0 +1 +3 +2147483646 +2147483647 +0 +SELECT * FROM inttbls WHERE 2147483647 >= colA; +colA +-2147483648 +-2147483647 +0 +1 +3 +2147483646 +2147483647 +0 +SELECT * FROM inttbls WHERE 2147483648 < colA; +colA +SELECT * FROM inttbls WHERE 2147483647 <= colA; +colA +2147483647 +SELECT * FROM inttbls WHERE 2147483647 < colA; +colA +SELECT * FROM inttbls WHERE -2147483649 < colA; +colA +-2147483648 +-2147483647 +0 +1 +3 +2147483646 +2147483647 +0 +SELECT * FROM inttbls WHERE -2147483649 >= colA; +colA +SELECT * FROM inttbls WHERE -2147483648 >= colA; +colA +-2147483648 +SELECT * FROM inttbls WHERE -2147483648 <= colA; +colA +-2147483648 +-2147483647 +0 +1 +3 +2147483646 +2147483647 +0 +SELECT * FROM inttbls WHERE -2147483648 < colA; +colA +-2147483647 +0 +1 +3 +2147483646 +2147483647 +0 +SELECT * FROM inttbls WHERE 2147483648 = colA; +colA +SELECT * FROM inttbls WHERE 2147483648 <=> colA; +colA +SELECT * FROM inttbls WHERE 2147483648 <> colA; +colA +-2147483648 +-2147483647 +0 +1 +3 +2147483646 +2147483647 +0 +SELECT * FROM inttbls WHERE 2147483647 = colA; +colA +2147483647 +SELECT * FROM inttbls WHERE 2147483647 <=> colA; +colA +2147483647 +SELECT * FROM inttbls WHERE 2147483647 <> colA; +colA +-2147483648 +-2147483647 +0 +1 +3 +2147483646 +0 +SELECT * FROM inttbls WHERE -2147483648 = colA; +colA +-2147483648 +SELECT * FROM inttbls WHERE -2147483648 <=> colA; +colA +-2147483648 +SELECT * FROM inttbls WHERE -2147483648 <> colA; +colA +-2147483647 +0 +1 +3 +2147483646 +2147483647 +0 +SELECT * FROM inttbls WHERE -2147483649 = colA; +colA +SELECT * FROM inttbls WHERE -2147483649 <=> colA; +colA +SELECT * FROM inttbls WHERE -2147483649 <> colA; +colA +-2147483648 +-2147483647 +0 +1 +3 +2147483646 +2147483647 +0 +PREPARE p_less FROM 'SELECT * FROM inttbls WHERE ? < colA'; +PREPARE p_less_eq FROM 'SELECT * FROM inttbls WHERE ? <= colA'; +PREPARE p_greater FROM 'SELECT * FROM inttbls WHERE ? > colA'; +PREPARE p_gret_eq FROM 'SELECT * FROM inttbls WHERE ? >= colA'; +PREPARE p_eq FROM 'SELECT * FROM inttbls WHERE ? = colA'; +PREPARE p_equal FROM 'SELECT * FROM inttbls WHERE ? <=> colA'; +PREPARE p_n_eq FROM 'SELECT * FROM inttbls WHERE ? <> colA'; +PREPARE p_n_equal FROM 'SELECT * FROM inttbls WHERE NOT(? <=> colA)'; +EXECUTE p_greater USING @maxint_plus_1; +colA +-2147483648 +-2147483647 +0 +1 +3 +2147483646 +2147483647 +0 +EXECUTE p_gret_eq USING @maxint; +colA +-2147483648 +-2147483647 +0 +1 +3 +2147483646 +2147483647 +0 +EXECUTE p_less USING @maxint_plus_1; +colA +EXECUTE p_less_eq USING @maxint; +colA +2147483647 +EXECUTE p_less USING @minint_minus_1; +colA +-2147483648 +-2147483647 +0 +1 +3 +2147483646 +2147483647 +0 +EXECUTE p_gret_eq USING @minint_minus_1; +colA +EXECUTE p_gret_eq USING @minint; +colA +-2147483648 +EXECUTE p_less_eq USING @minint; +colA +-2147483648 +-2147483647 +0 +1 +3 +2147483646 +2147483647 +0 +EXECUTE p_less USING @minint; +colA +-2147483647 +0 +1 +3 +2147483646 +2147483647 +0 +EXECUTE p_eq USING @maxint_plus_1; +colA +EXECUTE p_equal USING @maxint_plus_1; +colA +EXECUTE p_n_eq USING @maxint_plus_1; +colA +-2147483648 +-2147483647 +0 +1 +3 +2147483646 +2147483647 +0 +EXECUTE p_n_equal USING @maxint_plus_1; +colA +-2147483648 +-2147483647 +0 +1 +3 +2147483646 +2147483647 +0 +EXECUTE p_eq USING @maxint; +colA +2147483647 +EXECUTE p_equal USING @maxint; +colA +2147483647 +EXECUTE p_n_eq USING @maxint; +colA +-2147483648 +-2147483647 +0 +1 +3 +2147483646 +0 +EXECUTE p_n_equal USING @maxint; +colA +-2147483648 +-2147483647 +0 +1 +3 +2147483646 +0 +EXECUTE p_eq USING @minint; +colA +-2147483648 +EXECUTE p_equal USING @minint; +colA +-2147483648 +EXECUTE p_n_eq USING @minint; +colA +-2147483647 +0 +1 +3 +2147483646 +2147483647 +0 +EXECUTE p_n_equal USING @minint; +colA +-2147483647 +0 +1 +3 +2147483646 +2147483647 +0 +EXECUTE p_eq USING @minint_minus_1; +colA +EXECUTE p_equal USING @minint_minus_1; +colA +EXECUTE p_n_eq USING @minint_minus_1; +colA +-2147483648 +-2147483647 +0 +1 +3 +2147483646 +2147483647 +0 +EXECUTE p_n_equal USING @minint_minus_1; +colA +-2147483648 +-2147483647 +0 +1 +3 +2147483646 +2147483647 +0 +DROP PREPARE p_less; +DROP PREPARE p_less_eq; +DROP PREPARE p_greater; +DROP PREPARE p_gret_eq; +DROP PREPARE p_equal; +DROP PREPARE p_n_eq; +DROP PREPARE p_n_equal; +EXPLAIN SELECT * FROM inttbls WHERE 2147483648 > colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where true +EXPLAIN SELECT * FROM inttbls WHERE 2147483647 >= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where true +EXPLAIN SELECT * FROM inttbls WHERE 2147483648 < colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where false +EXPLAIN SELECT * FROM inttbls WHERE 2147483647 <= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where (2147483647 = `test`.`inttbls`.`colA`) +EXPLAIN SELECT * FROM inttbls WHERE 2147483647 < colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where false +EXPLAIN SELECT * FROM inttbls WHERE -2147483649 < colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where true +EXPLAIN SELECT * FROM inttbls WHERE -2147483649 >= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where false +EXPLAIN SELECT * FROM inttbls WHERE -2147483648 >= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where ((-(2147483648)) = `test`.`inttbls`.`colA`) +EXPLAIN SELECT * FROM inttbls WHERE -2147483648 <= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where true +EXPLAIN SELECT * FROM inttbls WHERE -2147483648 < colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 33.33 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where ((-(2147483648)) < `test`.`inttbls`.`colA`) +EXPLAIN SELECT * FROM inttbls WHERE 2147483648 = colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where false +EXPLAIN SELECT * FROM inttbls WHERE 2147483648 <=> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where false +EXPLAIN SELECT * FROM inttbls WHERE 2147483648 <> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where true +EXPLAIN SELECT * FROM inttbls WHERE 2147483647 = colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where (`test`.`inttbls`.`colA` = 2147483647) +EXPLAIN SELECT * FROM inttbls WHERE 2147483647 <=> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where (2147483647 <=> `test`.`inttbls`.`colA`) +EXPLAIN SELECT * FROM inttbls WHERE 2147483647 <> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where (2147483647 <> `test`.`inttbls`.`colA`) +EXPLAIN SELECT * FROM inttbls WHERE -2147483648 = colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where (`test`.`inttbls`.`colA` = (-(2147483648))) +EXPLAIN SELECT * FROM inttbls WHERE -2147483648 <=> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where ((-(2147483648)) <=> `test`.`inttbls`.`colA`) +EXPLAIN SELECT * FROM inttbls WHERE -2147483648 <> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where ((-(2147483648)) <> `test`.`inttbls`.`colA`) +EXPLAIN SELECT * FROM inttbls WHERE -2147483649 = colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where false +EXPLAIN SELECT * FROM inttbls WHERE -2147483649 <=> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where false +EXPLAIN SELECT * FROM inttbls WHERE -2147483649 <> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where true +DROP TABLE inttbls; +# +# Tests with UNSIGNED type BIGINT against int +# +CREATE TABLE inttbl (colA BIGINT UNSIGNED ); +INSERT INTO inttbl VALUES (0), (1), +(0),(1),(3), +(18446744073709551614), (18446744073709551615), +(NULL); +ANALYZE TABLE inttbl; +Table Op Msg_type Msg_text +test.inttbl analyze status OK +SELECT * FROM inttbl; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +NULL +SELECT * FROM inttbl WHERE colA < 18446744073709551616; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +SELECT * FROM inttbl WHERE colA <= 18446744073709551615; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +SELECT * FROM inttbl WHERE colA > 18446744073709551616; +colA +SELECT * FROM inttbl WHERE colA >= 18446744073709551615; +colA +18446744073709551615 +SELECT * FROM inttbl WHERE colA > -1; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +SELECT * FROM inttbl WHERE colA <= -1; +colA +SELECT * FROM inttbl WHERE colA <= 0; +colA +0 +0 +SELECT * FROM inttbl WHERE colA >= 0; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +SELECT * FROM inttbl WHERE colA > 0; +colA +1 +1 +3 +18446744073709551614 +18446744073709551615 +SELECT * FROM inttbl WHERE colA = 18446744073709551616; +colA +SELECT * FROM inttbl WHERE colA <> 18446744073709551616; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +SELECT * FROM inttbl WHERE colA = 18446744073709551615; +colA +18446744073709551615 +SELECT * FROM inttbl WHERE colA <=> 18446744073709551615; +colA +18446744073709551615 +SELECT * FROM inttbl WHERE NOT(colA <=> 18446744073709551615); +colA +0 +1 +0 +1 +3 +18446744073709551614 +NULL +SELECT * FROM inttbl WHERE colA <> 18446744073709551615; +colA +0 +1 +0 +1 +3 +18446744073709551614 +SELECT * FROM inttbl WHERE colA = 0; +colA +0 +0 +SELECT * FROM inttbl WHERE colA <=> 0; +colA +0 +0 +SELECT * FROM inttbl WHERE NOT(colA <=> 0); +colA +1 +1 +3 +18446744073709551614 +18446744073709551615 +NULL +SELECT * FROM inttbl WHERE colA <> 0; +colA +1 +1 +3 +18446744073709551614 +18446744073709551615 +SELECT * FROM inttbl WHERE colA = -1; +colA +SELECT * FROM inttbl WHERE colA <=> -1; +colA +SELECT * FROM inttbl WHERE NOT(colA <=> -1); +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +NULL +SELECT * FROM inttbl WHERE colA <> -1; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +PREPARE p_less FROM 'SELECT * FROM inttbl WHERE colA < ?'; +PREPARE p_less_eq FROM 'SELECT * FROM inttbl WHERE colA <= ?'; +PREPARE p_greater FROM 'SELECT * FROM inttbl WHERE colA > ?'; +PREPARE p_gret_eq FROM 'SELECT * FROM inttbl WHERE colA >= ?'; +PREPARE p_eq FROM 'SELECT * FROM inttbl WHERE colA = ?'; +PREPARE p_equal FROM 'SELECT * FROM inttbl WHERE colA <=> ?'; +PREPARE p_n_equal FROM 'SELECT * FROM inttbl WHERE NOT(colA <=> ?)'; +PREPARE p_n_eq FROM 'SELECT * FROM inttbl WHERE colA <> ?'; +SET @maxint_plus_1=18446744073709551616; +SET @maxint=18446744073709551615; +SET @minint_minus_1=-1; +SET @minint=0; +EXECUTE p_less USING @maxint_plus_1; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +EXECUTE p_less_eq USING @maxint; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +EXECUTE p_greater USING @maxint_plus_1; +colA +EXECUTE p_gret_eq USING @maxint; +colA +18446744073709551615 +EXECUTE p_greater USING @minint_minus_1; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +EXECUTE p_less_eq USING @minint_minus_1; +colA +EXECUTE p_less_eq USING @minint; +colA +0 +0 +EXECUTE p_gret_eq USING @minint; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +EXECUTE p_greater USING @minint; +colA +1 +1 +3 +18446744073709551614 +18446744073709551615 +EXECUTE p_eq USING @maxint_plus_1; +colA +EXECUTE p_equal USING @maxint_plus_1; +colA +EXECUTE p_n_eq USING @maxint_plus_1; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +EXECUTE p_n_equal USING @maxint_plus_1; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +NULL +EXECUTE p_eq USING @maxint; +colA +18446744073709551615 +EXECUTE p_equal USING @maxint; +colA +18446744073709551615 +EXECUTE p_n_eq USING @maxint; +colA +0 +1 +0 +1 +3 +18446744073709551614 +EXECUTE p_n_equal USING @maxint; +colA +0 +1 +0 +1 +3 +18446744073709551614 +NULL +EXECUTE p_eq USING @minint; +colA +0 +0 +EXECUTE p_equal USING @minint; +colA +0 +0 +EXECUTE p_n_eq USING @minint; +colA +1 +1 +3 +18446744073709551614 +18446744073709551615 +EXECUTE p_n_equal USING @minint; +colA +1 +1 +3 +18446744073709551614 +18446744073709551615 +NULL +EXECUTE p_eq USING @minint_minus_1; +colA +EXECUTE p_equal USING @minint_minus_1; +colA +EXECUTE p_n_eq USING @minint_minus_1; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +EXECUTE p_n_equal USING @minint_minus_1; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +NULL +DROP PREPARE p_less; +DROP PREPARE p_less_eq; +DROP PREPARE p_greater; +DROP PREPARE p_gret_eq; +DROP PREPARE p_equal; +DROP PREPARE p_n_eq; +DROP PREPARE p_n_equal; +EXPLAIN SELECT * FROM inttbl WHERE colA < 18446744073709551616; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` is not null) +EXPLAIN SELECT * FROM inttbl WHERE colA <= 18446744073709551615; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` is not null) +EXPLAIN SELECT * FROM inttbl WHERE colA > 18446744073709551616; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where false +EXPLAIN SELECT * FROM inttbl WHERE colA >= 18446744073709551615; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` = 18446744073709551615) +EXPLAIN SELECT * FROM inttbl WHERE colA > -1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` is not null) +EXPLAIN SELECT * FROM inttbl WHERE colA <= -1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where false +EXPLAIN SELECT * FROM inttbl WHERE colA <= 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` = 0) +EXPLAIN SELECT * FROM inttbl WHERE colA >= 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` is not null) +EXPLAIN SELECT * FROM inttbl WHERE colA > 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 33.33 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` > 0) +EXPLAIN SELECT * FROM inttbl WHERE colA = 18446744073709551616; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where false +EXPLAIN SELECT * FROM inttbl WHERE colA <=> 18446744073709551616; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where false +EXPLAIN SELECT * FROM inttbl WHERE colA <> 18446744073709551616; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` is not null) +EXPLAIN SELECT * FROM inttbl WHERE colA = 18446744073709551615; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` = 18446744073709551615) +EXPLAIN SELECT * FROM inttbl WHERE colA <=> 18446744073709551615; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` <=> 18446744073709551615) +EXPLAIN SELECT * FROM inttbl WHERE colA <> 18446744073709551615; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` <> 18446744073709551615) +EXPLAIN SELECT * FROM inttbl WHERE colA = 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` = 0) +EXPLAIN SELECT * FROM inttbl WHERE colA <=> 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` <=> 0) +EXPLAIN SELECT * FROM inttbl WHERE colA <> 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` <> 0) +EXPLAIN SELECT * FROM inttbl WHERE colA = -1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where false +EXPLAIN SELECT * FROM inttbl WHERE colA <=> -1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where false +EXPLAIN SELECT * FROM inttbl WHERE colA <> -1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` is not null) +same queries but constant first +SELECT * FROM inttbl WHERE 18446744073709551616 > colA; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +SELECT * FROM inttbl WHERE 18446744073709551615 >= colA; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +SELECT * FROM inttbl WHERE 18446744073709551616 < colA; +colA +SELECT * FROM inttbl WHERE 18446744073709551615 <= colA; +colA +18446744073709551615 +SELECT * FROM inttbl WHERE 18446744073709551615 < colA; +colA +SELECT * FROM inttbl WHERE -1 < colA; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +SELECT * FROM inttbl WHERE -1 >= colA; +colA +SELECT * FROM inttbl WHERE 0 >= colA; +colA +0 +0 +SELECT * FROM inttbl WHERE 0 <= colA; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +SELECT * FROM inttbl WHERE 0 < colA; +colA +1 +1 +3 +18446744073709551614 +18446744073709551615 +SELECT * FROM inttbl WHERE 18446744073709551616 = colA; +colA +SELECT * FROM inttbl WHERE 18446744073709551616 <=> colA; +colA +SELECT * FROM inttbl WHERE 18446744073709551616 <> colA; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +SELECT * FROM inttbl WHERE 18446744073709551615 = colA; +colA +18446744073709551615 +SELECT * FROM inttbl WHERE 18446744073709551615 <=> colA; +colA +18446744073709551615 +SELECT * FROM inttbl WHERE 18446744073709551615 <> colA; +colA +0 +1 +0 +1 +3 +18446744073709551614 +SELECT * FROM inttbl WHERE 0 = colA; +colA +0 +0 +SELECT * FROM inttbl WHERE 0 <=> colA; +colA +0 +0 +SELECT * FROM inttbl WHERE 0 <> colA; +colA +1 +1 +3 +18446744073709551614 +18446744073709551615 +SELECT * FROM inttbl WHERE -1 = colA; +colA +SELECT * FROM inttbl WHERE -1 <=> colA; +colA +SELECT * FROM inttbl WHERE -1 <> colA; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +PREPARE p_less FROM 'SELECT * FROM inttbl WHERE ? < colA'; +PREPARE p_less_eq FROM 'SELECT * FROM inttbl WHERE ? <= colA'; +PREPARE p_greater FROM 'SELECT * FROM inttbl WHERE ? > colA'; +PREPARE p_gret_eq FROM 'SELECT * FROM inttbl WHERE ? >= colA'; +PREPARE p_eq FROM 'SELECT * FROM inttbl WHERE ? = colA'; +PREPARE p_equal FROM 'SELECT * FROM inttbl WHERE ? <=> colA'; +PREPARE p_n_eq FROM 'SELECT * FROM inttbl WHERE ? <> colA'; +PREPARE p_n_equal FROM 'SELECT * FROM inttbl WHERE NOT(? <=> colA)'; +EXECUTE p_greater USING @maxint_plus_1; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +EXECUTE p_gret_eq USING @maxint; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +EXECUTE p_less USING @maxint_plus_1; +colA +EXECUTE p_less_eq USING @maxint; +colA +18446744073709551615 +EXECUTE p_less USING @minint_minus_1; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +EXECUTE p_gret_eq USING @minint_minus_1; +colA +EXECUTE p_gret_eq USING @minint; +colA +0 +0 +EXECUTE p_less_eq USING @minint; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +EXECUTE p_less USING @minint; +colA +1 +1 +3 +18446744073709551614 +18446744073709551615 +EXECUTE p_eq USING @maxint_plus_1; +colA +EXECUTE p_equal USING @maxint_plus_1; +colA +EXECUTE p_n_eq USING @maxint_plus_1; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +EXECUTE p_n_equal USING @maxint_plus_1; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +NULL +EXECUTE p_eq USING @maxint; +colA +18446744073709551615 +EXECUTE p_equal USING @maxint; +colA +18446744073709551615 +EXECUTE p_n_eq USING @maxint; +colA +0 +1 +0 +1 +3 +18446744073709551614 +EXECUTE p_n_equal USING @maxint; +colA +0 +1 +0 +1 +3 +18446744073709551614 +NULL +EXECUTE p_eq USING @minint; +colA +0 +0 +EXECUTE p_equal USING @minint; +colA +0 +0 +EXECUTE p_n_eq USING @minint; +colA +1 +1 +3 +18446744073709551614 +18446744073709551615 +EXECUTE p_n_equal USING @minint; +colA +1 +1 +3 +18446744073709551614 +18446744073709551615 +NULL +EXECUTE p_eq USING @minint_minus_1; +colA +EXECUTE p_equal USING @minint_minus_1; +colA +EXECUTE p_n_eq USING @minint_minus_1; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +EXECUTE p_n_equal USING @minint_minus_1; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +NULL +DROP PREPARE p_less; +DROP PREPARE p_less_eq; +DROP PREPARE p_greater; +DROP PREPARE p_gret_eq; +DROP PREPARE p_equal; +DROP PREPARE p_n_eq; +DROP PREPARE p_n_equal; +EXPLAIN SELECT * FROM inttbl WHERE 18446744073709551616 > colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` is not null) +EXPLAIN SELECT * FROM inttbl WHERE 18446744073709551615 >= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` is not null) +EXPLAIN SELECT * FROM inttbl WHERE 18446744073709551616 < colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where false +EXPLAIN SELECT * FROM inttbl WHERE 18446744073709551615 <= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (18446744073709551615 = `test`.`inttbl`.`colA`) +EXPLAIN SELECT * FROM inttbl WHERE 18446744073709551615 < colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where false +EXPLAIN SELECT * FROM inttbl WHERE -1 < colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` is not null) +EXPLAIN SELECT * FROM inttbl WHERE -1 >= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where false +EXPLAIN SELECT * FROM inttbl WHERE 0 >= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (0 = `test`.`inttbl`.`colA`) +EXPLAIN SELECT * FROM inttbl WHERE 0 <= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` is not null) +EXPLAIN SELECT * FROM inttbl WHERE 0 < colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 33.33 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (0 < `test`.`inttbl`.`colA`) +EXPLAIN SELECT * FROM inttbl WHERE 18446744073709551616 = colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where false +EXPLAIN SELECT * FROM inttbl WHERE 18446744073709551616 <=> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where false +EXPLAIN SELECT * FROM inttbl WHERE 18446744073709551616 <> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` is not null) +EXPLAIN SELECT * FROM inttbl WHERE 18446744073709551615 = colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` = 18446744073709551615) +EXPLAIN SELECT * FROM inttbl WHERE 18446744073709551615 <=> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (18446744073709551615 <=> `test`.`inttbl`.`colA`) +EXPLAIN SELECT * FROM inttbl WHERE 18446744073709551615 <> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (18446744073709551615 <> `test`.`inttbl`.`colA`) +EXPLAIN SELECT * FROM inttbl WHERE 0 = colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` = 0) +EXPLAIN SELECT * FROM inttbl WHERE 0 <=> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (0 <=> `test`.`inttbl`.`colA`) +EXPLAIN SELECT * FROM inttbl WHERE 0 <> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (0 <> `test`.`inttbl`.`colA`) +EXPLAIN SELECT * FROM inttbl WHERE -1 = colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where false +EXPLAIN SELECT * FROM inttbl WHERE -1 <=> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where false +EXPLAIN SELECT * FROM inttbl WHERE -1 <> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` is not null) +DROP TABLE inttbl; +# +# Tests with UNSIGNED type BIGINT against decimal +# +CREATE TABLE inttbl (colA BIGINT UNSIGNED ); +INSERT INTO inttbl VALUES (0), (1), +(0),(1),(3), +(18446744073709551614), (18446744073709551615), +(NULL); +ANALYZE TABLE inttbl; +Table Op Msg_type Msg_text +test.inttbl analyze status OK +SELECT * FROM inttbl; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +NULL +SELECT * FROM inttbl WHERE colA < 0.5; +colA +0 +0 +SELECT * FROM inttbl WHERE colA <= 0.5; +colA +0 +0 +SELECT * FROM inttbl WHERE colA > 0.5; +colA +1 +1 +3 +18446744073709551614 +18446744073709551615 +SELECT * FROM inttbl WHERE colA >= 0.5; +colA +1 +1 +3 +18446744073709551614 +18446744073709551615 +SELECT * FROM inttbl WHERE colA = 0.5; +colA +SELECT * FROM inttbl WHERE colA <> 0.5; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +SELECT * FROM inttbl WHERE colA < -0.5; +colA +SELECT * FROM inttbl WHERE colA <= -0.5; +colA +SELECT * FROM inttbl WHERE colA > -0.5; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +SELECT * FROM inttbl WHERE colA >= -0.5; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +SELECT * FROM inttbl WHERE colA = -0.5; +colA +SELECT * FROM inttbl WHERE colA <> -0.5; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +SELECT * FROM inttbl WHERE colA < 18446744073709551615.00001; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +SELECT * FROM inttbl WHERE colA <= 18446744073709551615.00001; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +SELECT * FROM inttbl WHERE colA > 18446744073709551615.00001; +colA +SELECT * FROM inttbl WHERE colA >= 18446744073709551615.00001; +colA +SELECT * FROM inttbl WHERE colA = 18446744073709551615.00001; +colA +SELECT * FROM inttbl WHERE colA <> 18446744073709551615.00001; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +SELECT * FROM inttbl WHERE colA < 18446744073709551614.99999; +colA +0 +1 +0 +1 +3 +18446744073709551614 +SELECT * FROM inttbl WHERE colA <= 18446744073709551614.99999; +colA +0 +1 +0 +1 +3 +18446744073709551614 +SELECT * FROM inttbl WHERE colA > 18446744073709551614.99999; +colA +18446744073709551615 +SELECT * FROM inttbl WHERE colA >= 18446744073709551614.99999; +colA +18446744073709551615 +SELECT * FROM inttbl WHERE colA = 18446744073709551614.99999; +colA +SELECT * FROM inttbl WHERE colA <> 18446744073709551614.99999; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +SELECT * FROM inttbl WHERE colA < 0.00001; +colA +0 +0 +SELECT * FROM inttbl WHERE colA <= 0.00001; +colA +0 +0 +SELECT * FROM inttbl WHERE colA > 0.00001; +colA +1 +1 +3 +18446744073709551614 +18446744073709551615 +SELECT * FROM inttbl WHERE colA >= 0.00001; +colA +1 +1 +3 +18446744073709551614 +18446744073709551615 +SELECT * FROM inttbl WHERE colA = 0.00001; +colA +SELECT * FROM inttbl WHERE colA <> 0.00001; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +SELECT * FROM inttbl WHERE colA < -0.99999; +colA +SELECT * FROM inttbl WHERE colA <= -0.99999; +colA +SELECT * FROM inttbl WHERE colA > -0.99999; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +SELECT * FROM inttbl WHERE colA >= -0.99999; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +SELECT * FROM inttbl WHERE colA = -0.99999; +colA +SELECT * FROM inttbl WHERE colA <> -0.99999; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +SELECT * FROM inttbl WHERE colA < 18446744073709551615.00000001; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +SELECT * FROM inttbl WHERE colA <= 18446744073709551615.00000001; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +SELECT * FROM inttbl WHERE colA > 18446744073709551615.00000001; +colA +SELECT * FROM inttbl WHERE colA >= 18446744073709551615.00000001; +colA +SELECT * FROM inttbl WHERE colA = 18446744073709551615.00000001; +colA +SELECT * FROM inttbl WHERE colA <> 18446744073709551615.00000001; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +SELECT * FROM inttbl WHERE colA < -9223372036854775808.00000001; +colA +SELECT * FROM inttbl WHERE colA <= -9223372036854775808.00000001; +colA +SELECT * FROM inttbl WHERE colA > -9223372036854775808.00000001; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +SELECT * FROM inttbl WHERE colA >= -9223372036854775808.00000001; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +SELECT * FROM inttbl WHERE colA = -9223372036854775808.00000001; +colA +SELECT * FROM inttbl WHERE colA <> -9223372036854775808.00000001; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +PREPARE p_less FROM 'SELECT * FROM inttbl WHERE colA < ?'; +PREPARE p_less_eq FROM 'SELECT * FROM inttbl WHERE colA <= ?'; +PREPARE p_greater FROM 'SELECT * FROM inttbl WHERE colA > ?'; +PREPARE p_gret_eq FROM 'SELECT * FROM inttbl WHERE colA >= ?'; +PREPARE p_equal FROM 'SELECT * FROM inttbl WHERE colA = ?'; +PREPARE p_n_equal FROM 'SELECT * FROM inttbl WHERE colA <> ?'; +SET @dec_0_5=0.5; +SET @dec_minus_0_5=-0.5; +SET @dec_max_plus_delta=18446744073709551615.00001; +SET @dec_max_minus_delta=18446744073709551614.99999; +SET @dec_min_plus_delta=0.00001; +SET @dec_min_minus_delta=-0.99999; +SET @dec_too_big_positive_for_any_int=18446744073709551615.00000001; +SET @dec_too_big_negative_for_any_int=-9223372036854775808.00000001; +EXECUTE p_less USING @dec_0_5; +colA +0 +0 +EXECUTE p_less_eq USING @dec_0_5; +colA +0 +0 +EXECUTE p_greater USING @dec_0_5; +colA +1 +1 +3 +18446744073709551614 +18446744073709551615 +EXECUTE p_gret_eq USING @dec_0_5; +colA +1 +1 +3 +18446744073709551614 +18446744073709551615 +EXECUTE p_equal USING @dec_0_5; +colA +EXECUTE p_n_equal USING @dec_0_5; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +EXECUTE p_less USING @dec_minus_0_5; +colA +EXECUTE p_less_eq USING @dec_minus_0_5; +colA +EXECUTE p_greater USING @dec_minus_0_5; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +EXECUTE p_gret_eq USING @dec_minus_0_5; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +EXECUTE p_equal USING @dec_minus_0_5; +colA +EXECUTE p_n_equal USING @dec_minus_0_5; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +EXECUTE p_less USING @dec_max_plus_delta; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +EXECUTE p_less_eq USING @dec_max_plus_delta; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +EXECUTE p_greater USING @dec_max_plus_delta; +colA +EXECUTE p_gret_eq USING @dec_max_plus_delta; +colA +EXECUTE p_equal USING @dec_max_plus_delta; +colA +EXECUTE p_n_equal USING @dec_max_plus_delta; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +EXECUTE p_less USING @dec_max_minus_delta; +colA +0 +1 +0 +1 +3 +18446744073709551614 +EXECUTE p_less_eq USING @dec_max_minus_delta; +colA +0 +1 +0 +1 +3 +18446744073709551614 +EXECUTE p_greater USING @dec_max_minus_delta; +colA +18446744073709551615 +EXECUTE p_gret_eq USING @dec_max_minus_delta; +colA +18446744073709551615 +EXECUTE p_equal USING @dec_max_minus_delta; +colA +EXECUTE p_n_equal USING @dec_max_minus_delta; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +EXECUTE p_less USING @dec_min_plus_delta; +colA +0 +0 +EXECUTE p_less_eq USING @dec_min_plus_delta; +colA +0 +0 +EXECUTE p_greater USING @dec_min_plus_delta; +colA +1 +1 +3 +18446744073709551614 +18446744073709551615 +EXECUTE p_gret_eq USING @dec_min_plus_delta; +colA +1 +1 +3 +18446744073709551614 +18446744073709551615 +EXECUTE p_equal USING @dec_min_plus_delta; +colA +EXECUTE p_n_equal USING @dec_min_plus_delta; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +EXECUTE p_less USING @dec_min_minus_delta; +colA +EXECUTE p_less_eq USING @dec_min_minus_delta; +colA +EXECUTE p_greater USING @dec_min_minus_delta; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +EXECUTE p_gret_eq USING @dec_min_minus_delta; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +EXECUTE p_equal USING @dec_min_minus_delta; +colA +EXECUTE p_n_equal USING @dec_min_minus_delta; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +EXECUTE p_less USING @dec_too_big_positive_for_any_int; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +EXECUTE p_less_eq USING @dec_too_big_positive_for_any_int; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +EXECUTE p_greater USING @dec_too_big_positive_for_any_int; +colA +EXECUTE p_gret_eq USING @dec_too_big_positive_for_any_int; +colA +EXECUTE p_equal USING @dec_too_big_positive_for_any_int; +colA +EXECUTE p_n_equal USING @dec_too_big_positive_for_any_int; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +EXECUTE p_less USING @dec_too_big_negative_for_any_int; +colA +EXECUTE p_less_eq USING @dec_too_big_negative_for_any_int; +colA +EXECUTE p_greater USING @dec_too_big_negative_for_any_int; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +EXECUTE p_gret_eq USING @dec_too_big_negative_for_any_int; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +EXECUTE p_equal USING @dec_too_big_negative_for_any_int; +colA +EXECUTE p_n_equal USING @dec_too_big_negative_for_any_int; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +DROP PREPARE p_less; +DROP PREPARE p_less_eq; +DROP PREPARE p_greater; +DROP PREPARE p_gret_eq; +DROP PREPARE p_equal; +DROP PREPARE p_n_equal; +DROP TABLE inttbl; +Cruft inside string +CREATE TABLE t(i INT); +INSERT INTO t VALUES (-1), (0), (1); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +SELECT * FROM t WHERE i > 'A'; +i +1 +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'A' +EXPLAIN SELECT * FROM t WHERE i > 'A'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'A' +Note 1003 /* select#1 */ select `test`.`t`.`i` AS `i` from `test`.`t` where (`test`.`t`.`i` > 0) +DROP TABLE t; +Detect decimal inside a string when compared to int +Used to return one row; should be none. +CREATE TABLE t(i BIGINT); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +INSERT INTO t VALUES (1), (2); +SELECT * FROM t WHERE i = '1.1'; +i +EXPLAIN SELECT * FROM t WHERE i = '1.1'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`i` AS `i` from `test`.`t` where false +DROP TABLE t; +Detect out of range real inside a string when compared to int +Used to return one row; should be none. +CREATE TABLE t(i TINYINT); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +INSERT INTO t VALUES (1), (2); +SELECT * FROM t WHERE i > '1E10'; +i +EXPLAIN SELECT * FROM t WHERE i > '1E10'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`i` AS `i` from `test`.`t` where false +DROP TABLE t; +Detect out of range real inside a string when compared to int +Used to return one row; should be none. +CREATE TABLE t(i TINYINT); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +INSERT INTO t VALUES (0); +SELECT * FROM t WHERE i = '1E-308'; +i +EXPLAIN SELECT * FROM t WHERE i = '1E-308'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`i` AS `i` from `test`.`t` where false +Above query should yield the same as this: +SELECT * FROM t WHERE i = 1E-308; +i +EXPLAIN SELECT * FROM t WHERE i = 1E-308; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`i` AS `i` from `test`.`t` where false +DROP TABLE t; +# +# Tests with UNSIGNED type BIGINT against int +# +CREATE TABLE inttbl (colA BIGINT UNSIGNED ); +INSERT INTO inttbl VALUES ('0'), ('1'), +(0),(1),(3), +('18446744073709551614'), ('18446744073709551615'), +(NULL); +ANALYZE TABLE inttbl; +Table Op Msg_type Msg_text +test.inttbl analyze status OK +SELECT * FROM inttbl; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +NULL +SELECT * FROM inttbl WHERE colA < '18446744073709551616'; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +SELECT * FROM inttbl WHERE colA <= '18446744073709551615'; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +SELECT * FROM inttbl WHERE colA > '18446744073709551616'; +colA +SELECT * FROM inttbl WHERE colA >= '18446744073709551615'; +colA +18446744073709551615 +SELECT * FROM inttbl WHERE colA > '-1'; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +SELECT * FROM inttbl WHERE colA <= '-1'; +colA +SELECT * FROM inttbl WHERE colA <= '0'; +colA +0 +0 +SELECT * FROM inttbl WHERE colA >= '0'; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +SELECT * FROM inttbl WHERE colA > '0'; +colA +1 +1 +3 +18446744073709551614 +18446744073709551615 +SELECT * FROM inttbl WHERE colA = '18446744073709551616'; +colA +SELECT * FROM inttbl WHERE colA <> '18446744073709551616'; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +SELECT * FROM inttbl WHERE colA = '18446744073709551615'; +colA +18446744073709551615 +SELECT * FROM inttbl WHERE colA <=> '18446744073709551615'; +colA +18446744073709551615 +SELECT * FROM inttbl WHERE NOT(colA <=> '18446744073709551615'); +colA +0 +1 +0 +1 +3 +18446744073709551614 +NULL +SELECT * FROM inttbl WHERE colA <> '18446744073709551615'; +colA +0 +1 +0 +1 +3 +18446744073709551614 +SELECT * FROM inttbl WHERE colA = '0'; +colA +0 +0 +SELECT * FROM inttbl WHERE colA <=> '0'; +colA +0 +0 +SELECT * FROM inttbl WHERE NOT(colA <=> '0'); +colA +1 +1 +3 +18446744073709551614 +18446744073709551615 +NULL +SELECT * FROM inttbl WHERE colA <> '0'; +colA +1 +1 +3 +18446744073709551614 +18446744073709551615 +SELECT * FROM inttbl WHERE colA = '-1'; +colA +SELECT * FROM inttbl WHERE colA <=> '-1'; +colA +SELECT * FROM inttbl WHERE NOT(colA <=> '-1'); +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +NULL +SELECT * FROM inttbl WHERE colA <> '-1'; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +PREPARE p_less FROM 'SELECT * FROM inttbl WHERE colA < ?'; +PREPARE p_less_eq FROM 'SELECT * FROM inttbl WHERE colA <= ?'; +PREPARE p_greater FROM 'SELECT * FROM inttbl WHERE colA > ?'; +PREPARE p_gret_eq FROM 'SELECT * FROM inttbl WHERE colA >= ?'; +PREPARE p_eq FROM 'SELECT * FROM inttbl WHERE colA = ?'; +PREPARE p_equal FROM 'SELECT * FROM inttbl WHERE colA <=> ?'; +PREPARE p_n_equal FROM 'SELECT * FROM inttbl WHERE NOT(colA <=> ?)'; +PREPARE p_n_eq FROM 'SELECT * FROM inttbl WHERE colA <> ?'; +SET @maxint_plus_1='18446744073709551616'; +SET @maxint='18446744073709551615'; +SET @minint_minus_1='-1'; +SET @minint='0'; +EXECUTE p_less USING @maxint_plus_1; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +EXECUTE p_less_eq USING @maxint; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +EXECUTE p_greater USING @maxint_plus_1; +colA +EXECUTE p_gret_eq USING @maxint; +colA +18446744073709551615 +EXECUTE p_greater USING @minint_minus_1; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +EXECUTE p_less_eq USING @minint_minus_1; +colA +EXECUTE p_less_eq USING @minint; +colA +0 +0 +EXECUTE p_gret_eq USING @minint; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +EXECUTE p_greater USING @minint; +colA +1 +1 +3 +18446744073709551614 +18446744073709551615 +EXECUTE p_eq USING @maxint_plus_1; +colA +EXECUTE p_equal USING @maxint_plus_1; +colA +EXECUTE p_n_eq USING @maxint_plus_1; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +EXECUTE p_n_equal USING @maxint_plus_1; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +NULL +EXECUTE p_eq USING @maxint; +colA +18446744073709551615 +EXECUTE p_equal USING @maxint; +colA +18446744073709551615 +EXECUTE p_n_eq USING @maxint; +colA +0 +1 +0 +1 +3 +18446744073709551614 +EXECUTE p_n_equal USING @maxint; +colA +0 +1 +0 +1 +3 +18446744073709551614 +NULL +EXECUTE p_eq USING @minint; +colA +0 +0 +EXECUTE p_equal USING @minint; +colA +0 +0 +EXECUTE p_n_eq USING @minint; +colA +1 +1 +3 +18446744073709551614 +18446744073709551615 +EXECUTE p_n_equal USING @minint; +colA +1 +1 +3 +18446744073709551614 +18446744073709551615 +NULL +EXECUTE p_eq USING @minint_minus_1; +colA +EXECUTE p_equal USING @minint_minus_1; +colA +EXECUTE p_n_eq USING @minint_minus_1; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +EXECUTE p_n_equal USING @minint_minus_1; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +NULL +DROP PREPARE p_less; +DROP PREPARE p_less_eq; +DROP PREPARE p_greater; +DROP PREPARE p_gret_eq; +DROP PREPARE p_equal; +DROP PREPARE p_n_eq; +DROP PREPARE p_n_equal; +EXPLAIN SELECT * FROM inttbl WHERE colA < '18446744073709551616'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` is not null) +EXPLAIN SELECT * FROM inttbl WHERE colA <= '18446744073709551615'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` is not null) +EXPLAIN SELECT * FROM inttbl WHERE colA > '18446744073709551616'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where false +EXPLAIN SELECT * FROM inttbl WHERE colA >= '18446744073709551615'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` = 18446744073709551615) +EXPLAIN SELECT * FROM inttbl WHERE colA > '-1'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` is not null) +EXPLAIN SELECT * FROM inttbl WHERE colA <= '-1'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where false +EXPLAIN SELECT * FROM inttbl WHERE colA <= '0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` = 0) +EXPLAIN SELECT * FROM inttbl WHERE colA >= '0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` is not null) +EXPLAIN SELECT * FROM inttbl WHERE colA > '0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 33.33 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` > 0) +EXPLAIN SELECT * FROM inttbl WHERE colA = '18446744073709551616'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where false +EXPLAIN SELECT * FROM inttbl WHERE colA <=> '18446744073709551616'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where false +EXPLAIN SELECT * FROM inttbl WHERE colA <> '18446744073709551616'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` is not null) +EXPLAIN SELECT * FROM inttbl WHERE colA = '18446744073709551615'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` = 18446744073709551615) +EXPLAIN SELECT * FROM inttbl WHERE colA <=> '18446744073709551615'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` <=> 18446744073709551615) +EXPLAIN SELECT * FROM inttbl WHERE colA <> '18446744073709551615'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` <> 18446744073709551615) +EXPLAIN SELECT * FROM inttbl WHERE colA = '0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` = 0) +EXPLAIN SELECT * FROM inttbl WHERE colA <=> '0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` <=> 0) +EXPLAIN SELECT * FROM inttbl WHERE colA <> '0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` <> 0) +EXPLAIN SELECT * FROM inttbl WHERE colA = '-1'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where false +EXPLAIN SELECT * FROM inttbl WHERE colA <=> '-1'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where false +EXPLAIN SELECT * FROM inttbl WHERE colA <> '-1'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` is not null) +same queries but constant first +SELECT * FROM inttbl WHERE '18446744073709551616' > colA; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +SELECT * FROM inttbl WHERE '18446744073709551615' >= colA; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +SELECT * FROM inttbl WHERE '18446744073709551616' < colA; +colA +SELECT * FROM inttbl WHERE '18446744073709551615' <= colA; +colA +18446744073709551615 +SELECT * FROM inttbl WHERE '18446744073709551615' < colA; +colA +SELECT * FROM inttbl WHERE '-1' < colA; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +SELECT * FROM inttbl WHERE '-1' >= colA; +colA +SELECT * FROM inttbl WHERE '0' >= colA; +colA +0 +0 +SELECT * FROM inttbl WHERE '0' <= colA; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +SELECT * FROM inttbl WHERE '0' < colA; +colA +1 +1 +3 +18446744073709551614 +18446744073709551615 +SELECT * FROM inttbl WHERE '18446744073709551616' = colA; +colA +SELECT * FROM inttbl WHERE '18446744073709551616' <=> colA; +colA +SELECT * FROM inttbl WHERE '18446744073709551616' <> colA; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +SELECT * FROM inttbl WHERE '18446744073709551615' = colA; +colA +18446744073709551615 +SELECT * FROM inttbl WHERE '18446744073709551615' <=> colA; +colA +18446744073709551615 +SELECT * FROM inttbl WHERE '18446744073709551615' <> colA; +colA +0 +1 +0 +1 +3 +18446744073709551614 +SELECT * FROM inttbl WHERE '0' = colA; +colA +0 +0 +SELECT * FROM inttbl WHERE '0' <=> colA; +colA +0 +0 +SELECT * FROM inttbl WHERE '0' <> colA; +colA +1 +1 +3 +18446744073709551614 +18446744073709551615 +SELECT * FROM inttbl WHERE '-1' = colA; +colA +SELECT * FROM inttbl WHERE '-1' <=> colA; +colA +SELECT * FROM inttbl WHERE '-1' <> colA; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +PREPARE p_less FROM 'SELECT * FROM inttbl WHERE ? < colA'; +PREPARE p_less_eq FROM 'SELECT * FROM inttbl WHERE ? <= colA'; +PREPARE p_greater FROM 'SELECT * FROM inttbl WHERE ? > colA'; +PREPARE p_gret_eq FROM 'SELECT * FROM inttbl WHERE ? >= colA'; +PREPARE p_eq FROM 'SELECT * FROM inttbl WHERE ? = colA'; +PREPARE p_equal FROM 'SELECT * FROM inttbl WHERE ? <=> colA'; +PREPARE p_n_eq FROM 'SELECT * FROM inttbl WHERE ? <> colA'; +PREPARE p_n_equal FROM 'SELECT * FROM inttbl WHERE NOT(? <=> colA)'; +EXECUTE p_greater USING @maxint_plus_1; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +EXECUTE p_gret_eq USING @maxint; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +EXECUTE p_less USING @maxint_plus_1; +colA +EXECUTE p_less_eq USING @maxint; +colA +18446744073709551615 +EXECUTE p_less USING @minint_minus_1; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +EXECUTE p_gret_eq USING @minint_minus_1; +colA +EXECUTE p_gret_eq USING @minint; +colA +0 +0 +EXECUTE p_less_eq USING @minint; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +EXECUTE p_less USING @minint; +colA +1 +1 +3 +18446744073709551614 +18446744073709551615 +EXECUTE p_eq USING @maxint_plus_1; +colA +EXECUTE p_equal USING @maxint_plus_1; +colA +EXECUTE p_n_eq USING @maxint_plus_1; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +EXECUTE p_n_equal USING @maxint_plus_1; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +NULL +EXECUTE p_eq USING @maxint; +colA +18446744073709551615 +EXECUTE p_equal USING @maxint; +colA +18446744073709551615 +EXECUTE p_n_eq USING @maxint; +colA +0 +1 +0 +1 +3 +18446744073709551614 +EXECUTE p_n_equal USING @maxint; +colA +0 +1 +0 +1 +3 +18446744073709551614 +NULL +EXECUTE p_eq USING @minint; +colA +0 +0 +EXECUTE p_equal USING @minint; +colA +0 +0 +EXECUTE p_n_eq USING @minint; +colA +1 +1 +3 +18446744073709551614 +18446744073709551615 +EXECUTE p_n_equal USING @minint; +colA +1 +1 +3 +18446744073709551614 +18446744073709551615 +NULL +EXECUTE p_eq USING @minint_minus_1; +colA +EXECUTE p_equal USING @minint_minus_1; +colA +EXECUTE p_n_eq USING @minint_minus_1; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +EXECUTE p_n_equal USING @minint_minus_1; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +NULL +DROP PREPARE p_less; +DROP PREPARE p_less_eq; +DROP PREPARE p_greater; +DROP PREPARE p_gret_eq; +DROP PREPARE p_equal; +DROP PREPARE p_n_eq; +DROP PREPARE p_n_equal; +EXPLAIN SELECT * FROM inttbl WHERE '18446744073709551616' > colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` is not null) +EXPLAIN SELECT * FROM inttbl WHERE '18446744073709551615' >= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` is not null) +EXPLAIN SELECT * FROM inttbl WHERE '18446744073709551616' < colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where false +EXPLAIN SELECT * FROM inttbl WHERE '18446744073709551615' <= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (18446744073709551615 = `test`.`inttbl`.`colA`) +EXPLAIN SELECT * FROM inttbl WHERE '18446744073709551615' < colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where false +EXPLAIN SELECT * FROM inttbl WHERE '-1' < colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` is not null) +EXPLAIN SELECT * FROM inttbl WHERE '-1' >= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where false +EXPLAIN SELECT * FROM inttbl WHERE '0' >= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (0 = `test`.`inttbl`.`colA`) +EXPLAIN SELECT * FROM inttbl WHERE '0' <= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` is not null) +EXPLAIN SELECT * FROM inttbl WHERE '0' < colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 33.33 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (0 < `test`.`inttbl`.`colA`) +EXPLAIN SELECT * FROM inttbl WHERE '18446744073709551616' = colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where false +EXPLAIN SELECT * FROM inttbl WHERE '18446744073709551616' <=> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where false +EXPLAIN SELECT * FROM inttbl WHERE '18446744073709551616' <> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` is not null) +EXPLAIN SELECT * FROM inttbl WHERE '18446744073709551615' = colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` = 18446744073709551615) +EXPLAIN SELECT * FROM inttbl WHERE '18446744073709551615' <=> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (18446744073709551615 <=> `test`.`inttbl`.`colA`) +EXPLAIN SELECT * FROM inttbl WHERE '18446744073709551615' <> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (18446744073709551615 <> `test`.`inttbl`.`colA`) +EXPLAIN SELECT * FROM inttbl WHERE '0' = colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` = 0) +EXPLAIN SELECT * FROM inttbl WHERE '0' <=> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (0 <=> `test`.`inttbl`.`colA`) +EXPLAIN SELECT * FROM inttbl WHERE '0' <> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (0 <> `test`.`inttbl`.`colA`) +EXPLAIN SELECT * FROM inttbl WHERE '-1' = colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where false +EXPLAIN SELECT * FROM inttbl WHERE '-1' <=> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where false +EXPLAIN SELECT * FROM inttbl WHERE '-1' <> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` is not null) +DROP TABLE inttbl; +# +# Tests with UNSIGNED type BIGINT NOT NULL against int +# +CREATE TABLE inttbl (colA BIGINT UNSIGNED NOT NULL); +INSERT INTO inttbl VALUES ('0'), ('1'), +(0),(1),(3), +('18446744073709551614'), ('18446744073709551615'), +(0); +ANALYZE TABLE inttbl; +Table Op Msg_type Msg_text +test.inttbl analyze status OK +SELECT * FROM inttbl; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +0 +SELECT * FROM inttbl WHERE colA < '18446744073709551616'; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +0 +SELECT * FROM inttbl WHERE colA <= '18446744073709551615'; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +0 +SELECT * FROM inttbl WHERE colA > '18446744073709551616'; +colA +SELECT * FROM inttbl WHERE colA >= '18446744073709551615'; +colA +18446744073709551615 +SELECT * FROM inttbl WHERE colA > '-1'; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +0 +SELECT * FROM inttbl WHERE colA <= '-1'; +colA +SELECT * FROM inttbl WHERE colA <= '0'; +colA +0 +0 +0 +SELECT * FROM inttbl WHERE colA >= '0'; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +0 +SELECT * FROM inttbl WHERE colA > '0'; +colA +1 +1 +3 +18446744073709551614 +18446744073709551615 +SELECT * FROM inttbl WHERE colA = '18446744073709551616'; +colA +SELECT * FROM inttbl WHERE colA <> '18446744073709551616'; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +0 +SELECT * FROM inttbl WHERE colA = '18446744073709551615'; +colA +18446744073709551615 +SELECT * FROM inttbl WHERE colA <=> '18446744073709551615'; +colA +18446744073709551615 +SELECT * FROM inttbl WHERE NOT(colA <=> '18446744073709551615'); +colA +0 +1 +0 +1 +3 +18446744073709551614 +0 +SELECT * FROM inttbl WHERE colA <> '18446744073709551615'; +colA +0 +1 +0 +1 +3 +18446744073709551614 +0 +SELECT * FROM inttbl WHERE colA = '0'; +colA +0 +0 +0 +SELECT * FROM inttbl WHERE colA <=> '0'; +colA +0 +0 +0 +SELECT * FROM inttbl WHERE NOT(colA <=> '0'); +colA +1 +1 +3 +18446744073709551614 +18446744073709551615 +SELECT * FROM inttbl WHERE colA <> '0'; +colA +1 +1 +3 +18446744073709551614 +18446744073709551615 +SELECT * FROM inttbl WHERE colA = '-1'; +colA +SELECT * FROM inttbl WHERE colA <=> '-1'; +colA +SELECT * FROM inttbl WHERE NOT(colA <=> '-1'); +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +0 +SELECT * FROM inttbl WHERE colA <> '-1'; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +0 +PREPARE p_less FROM 'SELECT * FROM inttbl WHERE colA < ?'; +PREPARE p_less_eq FROM 'SELECT * FROM inttbl WHERE colA <= ?'; +PREPARE p_greater FROM 'SELECT * FROM inttbl WHERE colA > ?'; +PREPARE p_gret_eq FROM 'SELECT * FROM inttbl WHERE colA >= ?'; +PREPARE p_eq FROM 'SELECT * FROM inttbl WHERE colA = ?'; +PREPARE p_equal FROM 'SELECT * FROM inttbl WHERE colA <=> ?'; +PREPARE p_n_equal FROM 'SELECT * FROM inttbl WHERE NOT(colA <=> ?)'; +PREPARE p_n_eq FROM 'SELECT * FROM inttbl WHERE colA <> ?'; +SET @maxint_plus_1='18446744073709551616'; +SET @maxint='18446744073709551615'; +SET @minint_minus_1='-1'; +SET @minint='0'; +EXECUTE p_less USING @maxint_plus_1; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +0 +EXECUTE p_less_eq USING @maxint; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +0 +EXECUTE p_greater USING @maxint_plus_1; +colA +EXECUTE p_gret_eq USING @maxint; +colA +18446744073709551615 +EXECUTE p_greater USING @minint_minus_1; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +0 +EXECUTE p_less_eq USING @minint_minus_1; +colA +EXECUTE p_less_eq USING @minint; +colA +0 +0 +0 +EXECUTE p_gret_eq USING @minint; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +0 +EXECUTE p_greater USING @minint; +colA +1 +1 +3 +18446744073709551614 +18446744073709551615 +EXECUTE p_eq USING @maxint_plus_1; +colA +EXECUTE p_equal USING @maxint_plus_1; +colA +EXECUTE p_n_eq USING @maxint_plus_1; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +0 +EXECUTE p_n_equal USING @maxint_plus_1; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +0 +EXECUTE p_eq USING @maxint; +colA +18446744073709551615 +EXECUTE p_equal USING @maxint; +colA +18446744073709551615 +EXECUTE p_n_eq USING @maxint; +colA +0 +1 +0 +1 +3 +18446744073709551614 +0 +EXECUTE p_n_equal USING @maxint; +colA +0 +1 +0 +1 +3 +18446744073709551614 +0 +EXECUTE p_eq USING @minint; +colA +0 +0 +0 +EXECUTE p_equal USING @minint; +colA +0 +0 +0 +EXECUTE p_n_eq USING @minint; +colA +1 +1 +3 +18446744073709551614 +18446744073709551615 +EXECUTE p_n_equal USING @minint; +colA +1 +1 +3 +18446744073709551614 +18446744073709551615 +EXECUTE p_eq USING @minint_minus_1; +colA +EXECUTE p_equal USING @minint_minus_1; +colA +EXECUTE p_n_eq USING @minint_minus_1; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +0 +EXECUTE p_n_equal USING @minint_minus_1; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +0 +DROP PREPARE p_less; +DROP PREPARE p_less_eq; +DROP PREPARE p_greater; +DROP PREPARE p_gret_eq; +DROP PREPARE p_equal; +DROP PREPARE p_n_eq; +DROP PREPARE p_n_equal; +EXPLAIN SELECT * FROM inttbl WHERE colA < '18446744073709551616'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where true +EXPLAIN SELECT * FROM inttbl WHERE colA <= '18446744073709551615'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where true +EXPLAIN SELECT * FROM inttbl WHERE colA > '18446744073709551616'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where false +EXPLAIN SELECT * FROM inttbl WHERE colA >= '18446744073709551615'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` = 18446744073709551615) +EXPLAIN SELECT * FROM inttbl WHERE colA > '-1'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where true +EXPLAIN SELECT * FROM inttbl WHERE colA <= '-1'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where false +EXPLAIN SELECT * FROM inttbl WHERE colA <= '0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` = 0) +EXPLAIN SELECT * FROM inttbl WHERE colA >= '0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where true +EXPLAIN SELECT * FROM inttbl WHERE colA > '0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 33.33 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` > 0) +EXPLAIN SELECT * FROM inttbl WHERE colA = '18446744073709551616'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where false +EXPLAIN SELECT * FROM inttbl WHERE colA <=> '18446744073709551616'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where false +EXPLAIN SELECT * FROM inttbl WHERE colA <> '18446744073709551616'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where true +EXPLAIN SELECT * FROM inttbl WHERE colA = '18446744073709551615'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` = 18446744073709551615) +EXPLAIN SELECT * FROM inttbl WHERE colA <=> '18446744073709551615'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` <=> 18446744073709551615) +EXPLAIN SELECT * FROM inttbl WHERE colA <> '18446744073709551615'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` <> 18446744073709551615) +EXPLAIN SELECT * FROM inttbl WHERE colA = '0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` = 0) +EXPLAIN SELECT * FROM inttbl WHERE colA <=> '0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` <=> 0) +EXPLAIN SELECT * FROM inttbl WHERE colA <> '0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` <> 0) +EXPLAIN SELECT * FROM inttbl WHERE colA = '-1'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where false +EXPLAIN SELECT * FROM inttbl WHERE colA <=> '-1'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where false +EXPLAIN SELECT * FROM inttbl WHERE colA <> '-1'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where true +same queries but constant first +SELECT * FROM inttbl WHERE '18446744073709551616' > colA; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +0 +SELECT * FROM inttbl WHERE '18446744073709551615' >= colA; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +0 +SELECT * FROM inttbl WHERE '18446744073709551616' < colA; +colA +SELECT * FROM inttbl WHERE '18446744073709551615' <= colA; +colA +18446744073709551615 +SELECT * FROM inttbl WHERE '18446744073709551615' < colA; +colA +SELECT * FROM inttbl WHERE '-1' < colA; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +0 +SELECT * FROM inttbl WHERE '-1' >= colA; +colA +SELECT * FROM inttbl WHERE '0' >= colA; +colA +0 +0 +0 +SELECT * FROM inttbl WHERE '0' <= colA; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +0 +SELECT * FROM inttbl WHERE '0' < colA; +colA +1 +1 +3 +18446744073709551614 +18446744073709551615 +SELECT * FROM inttbl WHERE '18446744073709551616' = colA; +colA +SELECT * FROM inttbl WHERE '18446744073709551616' <=> colA; +colA +SELECT * FROM inttbl WHERE '18446744073709551616' <> colA; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +0 +SELECT * FROM inttbl WHERE '18446744073709551615' = colA; +colA +18446744073709551615 +SELECT * FROM inttbl WHERE '18446744073709551615' <=> colA; +colA +18446744073709551615 +SELECT * FROM inttbl WHERE '18446744073709551615' <> colA; +colA +0 +1 +0 +1 +3 +18446744073709551614 +0 +SELECT * FROM inttbl WHERE '0' = colA; +colA +0 +0 +0 +SELECT * FROM inttbl WHERE '0' <=> colA; +colA +0 +0 +0 +SELECT * FROM inttbl WHERE '0' <> colA; +colA +1 +1 +3 +18446744073709551614 +18446744073709551615 +SELECT * FROM inttbl WHERE '-1' = colA; +colA +SELECT * FROM inttbl WHERE '-1' <=> colA; +colA +SELECT * FROM inttbl WHERE '-1' <> colA; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +0 +PREPARE p_less FROM 'SELECT * FROM inttbl WHERE ? < colA'; +PREPARE p_less_eq FROM 'SELECT * FROM inttbl WHERE ? <= colA'; +PREPARE p_greater FROM 'SELECT * FROM inttbl WHERE ? > colA'; +PREPARE p_gret_eq FROM 'SELECT * FROM inttbl WHERE ? >= colA'; +PREPARE p_eq FROM 'SELECT * FROM inttbl WHERE ? = colA'; +PREPARE p_equal FROM 'SELECT * FROM inttbl WHERE ? <=> colA'; +PREPARE p_n_eq FROM 'SELECT * FROM inttbl WHERE ? <> colA'; +PREPARE p_n_equal FROM 'SELECT * FROM inttbl WHERE NOT(? <=> colA)'; +EXECUTE p_greater USING @maxint_plus_1; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +0 +EXECUTE p_gret_eq USING @maxint; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +0 +EXECUTE p_less USING @maxint_plus_1; +colA +EXECUTE p_less_eq USING @maxint; +colA +18446744073709551615 +EXECUTE p_less USING @minint_minus_1; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +0 +EXECUTE p_gret_eq USING @minint_minus_1; +colA +EXECUTE p_gret_eq USING @minint; +colA +0 +0 +0 +EXECUTE p_less_eq USING @minint; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +0 +EXECUTE p_less USING @minint; +colA +1 +1 +3 +18446744073709551614 +18446744073709551615 +EXECUTE p_eq USING @maxint_plus_1; +colA +EXECUTE p_equal USING @maxint_plus_1; +colA +EXECUTE p_n_eq USING @maxint_plus_1; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +0 +EXECUTE p_n_equal USING @maxint_plus_1; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +0 +EXECUTE p_eq USING @maxint; +colA +18446744073709551615 +EXECUTE p_equal USING @maxint; +colA +18446744073709551615 +EXECUTE p_n_eq USING @maxint; +colA +0 +1 +0 +1 +3 +18446744073709551614 +0 +EXECUTE p_n_equal USING @maxint; +colA +0 +1 +0 +1 +3 +18446744073709551614 +0 +EXECUTE p_eq USING @minint; +colA +0 +0 +0 +EXECUTE p_equal USING @minint; +colA +0 +0 +0 +EXECUTE p_n_eq USING @minint; +colA +1 +1 +3 +18446744073709551614 +18446744073709551615 +EXECUTE p_n_equal USING @minint; +colA +1 +1 +3 +18446744073709551614 +18446744073709551615 +EXECUTE p_eq USING @minint_minus_1; +colA +EXECUTE p_equal USING @minint_minus_1; +colA +EXECUTE p_n_eq USING @minint_minus_1; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +0 +EXECUTE p_n_equal USING @minint_minus_1; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +0 +DROP PREPARE p_less; +DROP PREPARE p_less_eq; +DROP PREPARE p_greater; +DROP PREPARE p_gret_eq; +DROP PREPARE p_equal; +DROP PREPARE p_n_eq; +DROP PREPARE p_n_equal; +EXPLAIN SELECT * FROM inttbl WHERE '18446744073709551616' > colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where true +EXPLAIN SELECT * FROM inttbl WHERE '18446744073709551615' >= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where true +EXPLAIN SELECT * FROM inttbl WHERE '18446744073709551616' < colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where false +EXPLAIN SELECT * FROM inttbl WHERE '18446744073709551615' <= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (18446744073709551615 = `test`.`inttbl`.`colA`) +EXPLAIN SELECT * FROM inttbl WHERE '18446744073709551615' < colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where false +EXPLAIN SELECT * FROM inttbl WHERE '-1' < colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where true +EXPLAIN SELECT * FROM inttbl WHERE '-1' >= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where false +EXPLAIN SELECT * FROM inttbl WHERE '0' >= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (0 = `test`.`inttbl`.`colA`) +EXPLAIN SELECT * FROM inttbl WHERE '0' <= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where true +EXPLAIN SELECT * FROM inttbl WHERE '0' < colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 33.33 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (0 < `test`.`inttbl`.`colA`) +EXPLAIN SELECT * FROM inttbl WHERE '18446744073709551616' = colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where false +EXPLAIN SELECT * FROM inttbl WHERE '18446744073709551616' <=> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where false +EXPLAIN SELECT * FROM inttbl WHERE '18446744073709551616' <> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where true +EXPLAIN SELECT * FROM inttbl WHERE '18446744073709551615' = colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` = 18446744073709551615) +EXPLAIN SELECT * FROM inttbl WHERE '18446744073709551615' <=> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (18446744073709551615 <=> `test`.`inttbl`.`colA`) +EXPLAIN SELECT * FROM inttbl WHERE '18446744073709551615' <> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (18446744073709551615 <> `test`.`inttbl`.`colA`) +EXPLAIN SELECT * FROM inttbl WHERE '0' = colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` = 0) +EXPLAIN SELECT * FROM inttbl WHERE '0' <=> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (0 <=> `test`.`inttbl`.`colA`) +EXPLAIN SELECT * FROM inttbl WHERE '0' <> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (0 <> `test`.`inttbl`.`colA`) +EXPLAIN SELECT * FROM inttbl WHERE '-1' = colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where false +EXPLAIN SELECT * FROM inttbl WHERE '-1' <=> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where false +EXPLAIN SELECT * FROM inttbl WHERE '-1' <> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where true +DROP TABLE inttbl; +# +# Tests with UNSIGNED type BIGINT against int +# +CREATE TABLE inttbl (colA BIGINT UNSIGNED ); +INSERT INTO inttbl VALUES ('0.0'), ('1.0'), +(0),(1),(3), +('18446744073709551614.0'), ('18446744073709551615.0'), +(NULL); +ANALYZE TABLE inttbl; +Table Op Msg_type Msg_text +test.inttbl analyze status OK +SELECT * FROM inttbl; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +NULL +SELECT * FROM inttbl WHERE colA < '18446744073709551616.1'; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +SELECT * FROM inttbl WHERE colA <= '18446744073709551615.0'; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +SELECT * FROM inttbl WHERE colA > '18446744073709551616.1'; +colA +SELECT * FROM inttbl WHERE colA >= '18446744073709551615.0'; +colA +18446744073709551615 +SELECT * FROM inttbl WHERE colA > '-1.1'; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +SELECT * FROM inttbl WHERE colA <= '-1.1'; +colA +SELECT * FROM inttbl WHERE colA <= '0.0'; +colA +0 +0 +SELECT * FROM inttbl WHERE colA >= '0.0'; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +SELECT * FROM inttbl WHERE colA > '0.0'; +colA +1 +1 +3 +18446744073709551614 +18446744073709551615 +SELECT * FROM inttbl WHERE colA = '18446744073709551616.1'; +colA +SELECT * FROM inttbl WHERE colA <> '18446744073709551616.1'; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +SELECT * FROM inttbl WHERE colA = '18446744073709551615.0'; +colA +18446744073709551615 +SELECT * FROM inttbl WHERE colA <=> '18446744073709551615.0'; +colA +18446744073709551615 +SELECT * FROM inttbl WHERE NOT(colA <=> '18446744073709551615.0'); +colA +0 +1 +0 +1 +3 +18446744073709551614 +NULL +SELECT * FROM inttbl WHERE colA <> '18446744073709551615.0'; +colA +0 +1 +0 +1 +3 +18446744073709551614 +SELECT * FROM inttbl WHERE colA = '0.0'; +colA +0 +0 +SELECT * FROM inttbl WHERE colA <=> '0.0'; +colA +0 +0 +SELECT * FROM inttbl WHERE NOT(colA <=> '0.0'); +colA +1 +1 +3 +18446744073709551614 +18446744073709551615 +NULL +SELECT * FROM inttbl WHERE colA <> '0.0'; +colA +1 +1 +3 +18446744073709551614 +18446744073709551615 +SELECT * FROM inttbl WHERE colA = '-1.1'; +colA +SELECT * FROM inttbl WHERE colA <=> '-1.1'; +colA +SELECT * FROM inttbl WHERE NOT(colA <=> '-1.1'); +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +NULL +SELECT * FROM inttbl WHERE colA <> '-1.1'; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +PREPARE p_less FROM 'SELECT * FROM inttbl WHERE colA < ?'; +PREPARE p_less_eq FROM 'SELECT * FROM inttbl WHERE colA <= ?'; +PREPARE p_greater FROM 'SELECT * FROM inttbl WHERE colA > ?'; +PREPARE p_gret_eq FROM 'SELECT * FROM inttbl WHERE colA >= ?'; +PREPARE p_eq FROM 'SELECT * FROM inttbl WHERE colA = ?'; +PREPARE p_equal FROM 'SELECT * FROM inttbl WHERE colA <=> ?'; +PREPARE p_n_equal FROM 'SELECT * FROM inttbl WHERE NOT(colA <=> ?)'; +PREPARE p_n_eq FROM 'SELECT * FROM inttbl WHERE colA <> ?'; +SET @maxint_plus_1='18446744073709551616.1'; +SET @maxint='18446744073709551615.0'; +SET @minint_minus_1='-1.1'; +SET @minint='0.0'; +EXECUTE p_less USING @maxint_plus_1; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +EXECUTE p_less_eq USING @maxint; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +EXECUTE p_greater USING @maxint_plus_1; +colA +EXECUTE p_gret_eq USING @maxint; +colA +18446744073709551615 +EXECUTE p_greater USING @minint_minus_1; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +EXECUTE p_less_eq USING @minint_minus_1; +colA +EXECUTE p_less_eq USING @minint; +colA +0 +0 +EXECUTE p_gret_eq USING @minint; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +EXECUTE p_greater USING @minint; +colA +1 +1 +3 +18446744073709551614 +18446744073709551615 +EXECUTE p_eq USING @maxint_plus_1; +colA +EXECUTE p_equal USING @maxint_plus_1; +colA +EXECUTE p_n_eq USING @maxint_plus_1; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +EXECUTE p_n_equal USING @maxint_plus_1; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +NULL +EXECUTE p_eq USING @maxint; +colA +18446744073709551615 +EXECUTE p_equal USING @maxint; +colA +18446744073709551615 +EXECUTE p_n_eq USING @maxint; +colA +0 +1 +0 +1 +3 +18446744073709551614 +EXECUTE p_n_equal USING @maxint; +colA +0 +1 +0 +1 +3 +18446744073709551614 +NULL +EXECUTE p_eq USING @minint; +colA +0 +0 +EXECUTE p_equal USING @minint; +colA +0 +0 +EXECUTE p_n_eq USING @minint; +colA +1 +1 +3 +18446744073709551614 +18446744073709551615 +EXECUTE p_n_equal USING @minint; +colA +1 +1 +3 +18446744073709551614 +18446744073709551615 +NULL +EXECUTE p_eq USING @minint_minus_1; +colA +EXECUTE p_equal USING @minint_minus_1; +colA +EXECUTE p_n_eq USING @minint_minus_1; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +EXECUTE p_n_equal USING @minint_minus_1; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +NULL +DROP PREPARE p_less; +DROP PREPARE p_less_eq; +DROP PREPARE p_greater; +DROP PREPARE p_gret_eq; +DROP PREPARE p_equal; +DROP PREPARE p_n_eq; +DROP PREPARE p_n_equal; +EXPLAIN SELECT * FROM inttbl WHERE colA < '18446744073709551616.1'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` is not null) +EXPLAIN SELECT * FROM inttbl WHERE colA <= '18446744073709551615.0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` is not null) +EXPLAIN SELECT * FROM inttbl WHERE colA > '18446744073709551616.1'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where false +EXPLAIN SELECT * FROM inttbl WHERE colA >= '18446744073709551615.0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` = 18446744073709551615) +EXPLAIN SELECT * FROM inttbl WHERE colA > '-1.1'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` is not null) +EXPLAIN SELECT * FROM inttbl WHERE colA <= '-1.1'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where false +EXPLAIN SELECT * FROM inttbl WHERE colA <= '0.0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` = 0) +EXPLAIN SELECT * FROM inttbl WHERE colA >= '0.0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` is not null) +EXPLAIN SELECT * FROM inttbl WHERE colA > '0.0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 33.33 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` > 0) +EXPLAIN SELECT * FROM inttbl WHERE colA = '18446744073709551616.1'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where false +EXPLAIN SELECT * FROM inttbl WHERE colA <=> '18446744073709551616.1'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where false +EXPLAIN SELECT * FROM inttbl WHERE colA <> '18446744073709551616.1'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` is not null) +EXPLAIN SELECT * FROM inttbl WHERE colA = '18446744073709551615.0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` = 18446744073709551615) +EXPLAIN SELECT * FROM inttbl WHERE colA <=> '18446744073709551615.0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` <=> 18446744073709551615) +EXPLAIN SELECT * FROM inttbl WHERE colA <> '18446744073709551615.0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` <> 18446744073709551615) +EXPLAIN SELECT * FROM inttbl WHERE colA = '0.0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` = 0) +EXPLAIN SELECT * FROM inttbl WHERE colA <=> '0.0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` <=> 0) +EXPLAIN SELECT * FROM inttbl WHERE colA <> '0.0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` <> 0) +EXPLAIN SELECT * FROM inttbl WHERE colA = '-1.1'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where false +EXPLAIN SELECT * FROM inttbl WHERE colA <=> '-1.1'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where false +EXPLAIN SELECT * FROM inttbl WHERE colA <> '-1.1'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` is not null) +same queries but constant first +SELECT * FROM inttbl WHERE '18446744073709551616.1' > colA; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +SELECT * FROM inttbl WHERE '18446744073709551615.0' >= colA; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +SELECT * FROM inttbl WHERE '18446744073709551616.1' < colA; +colA +SELECT * FROM inttbl WHERE '18446744073709551615.0' <= colA; +colA +18446744073709551615 +SELECT * FROM inttbl WHERE '18446744073709551615.0' < colA; +colA +SELECT * FROM inttbl WHERE '-1.1' < colA; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +SELECT * FROM inttbl WHERE '-1.1' >= colA; +colA +SELECT * FROM inttbl WHERE '0.0' >= colA; +colA +0 +0 +SELECT * FROM inttbl WHERE '0.0' <= colA; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +SELECT * FROM inttbl WHERE '0.0' < colA; +colA +1 +1 +3 +18446744073709551614 +18446744073709551615 +SELECT * FROM inttbl WHERE '18446744073709551616.1' = colA; +colA +SELECT * FROM inttbl WHERE '18446744073709551616.1' <=> colA; +colA +SELECT * FROM inttbl WHERE '18446744073709551616.1' <> colA; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +SELECT * FROM inttbl WHERE '18446744073709551615.0' = colA; +colA +18446744073709551615 +SELECT * FROM inttbl WHERE '18446744073709551615.0' <=> colA; +colA +18446744073709551615 +SELECT * FROM inttbl WHERE '18446744073709551615.0' <> colA; +colA +0 +1 +0 +1 +3 +18446744073709551614 +SELECT * FROM inttbl WHERE '0.0' = colA; +colA +0 +0 +SELECT * FROM inttbl WHERE '0.0' <=> colA; +colA +0 +0 +SELECT * FROM inttbl WHERE '0.0' <> colA; +colA +1 +1 +3 +18446744073709551614 +18446744073709551615 +SELECT * FROM inttbl WHERE '-1.1' = colA; +colA +SELECT * FROM inttbl WHERE '-1.1' <=> colA; +colA +SELECT * FROM inttbl WHERE '-1.1' <> colA; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +PREPARE p_less FROM 'SELECT * FROM inttbl WHERE ? < colA'; +PREPARE p_less_eq FROM 'SELECT * FROM inttbl WHERE ? <= colA'; +PREPARE p_greater FROM 'SELECT * FROM inttbl WHERE ? > colA'; +PREPARE p_gret_eq FROM 'SELECT * FROM inttbl WHERE ? >= colA'; +PREPARE p_eq FROM 'SELECT * FROM inttbl WHERE ? = colA'; +PREPARE p_equal FROM 'SELECT * FROM inttbl WHERE ? <=> colA'; +PREPARE p_n_eq FROM 'SELECT * FROM inttbl WHERE ? <> colA'; +PREPARE p_n_equal FROM 'SELECT * FROM inttbl WHERE NOT(? <=> colA)'; +EXECUTE p_greater USING @maxint_plus_1; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +EXECUTE p_gret_eq USING @maxint; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +EXECUTE p_less USING @maxint_plus_1; +colA +EXECUTE p_less_eq USING @maxint; +colA +18446744073709551615 +EXECUTE p_less USING @minint_minus_1; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +EXECUTE p_gret_eq USING @minint_minus_1; +colA +EXECUTE p_gret_eq USING @minint; +colA +0 +0 +EXECUTE p_less_eq USING @minint; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +EXECUTE p_less USING @minint; +colA +1 +1 +3 +18446744073709551614 +18446744073709551615 +EXECUTE p_eq USING @maxint_plus_1; +colA +EXECUTE p_equal USING @maxint_plus_1; +colA +EXECUTE p_n_eq USING @maxint_plus_1; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +EXECUTE p_n_equal USING @maxint_plus_1; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +NULL +EXECUTE p_eq USING @maxint; +colA +18446744073709551615 +EXECUTE p_equal USING @maxint; +colA +18446744073709551615 +EXECUTE p_n_eq USING @maxint; +colA +0 +1 +0 +1 +3 +18446744073709551614 +EXECUTE p_n_equal USING @maxint; +colA +0 +1 +0 +1 +3 +18446744073709551614 +NULL +EXECUTE p_eq USING @minint; +colA +0 +0 +EXECUTE p_equal USING @minint; +colA +0 +0 +EXECUTE p_n_eq USING @minint; +colA +1 +1 +3 +18446744073709551614 +18446744073709551615 +EXECUTE p_n_equal USING @minint; +colA +1 +1 +3 +18446744073709551614 +18446744073709551615 +NULL +EXECUTE p_eq USING @minint_minus_1; +colA +EXECUTE p_equal USING @minint_minus_1; +colA +EXECUTE p_n_eq USING @minint_minus_1; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +EXECUTE p_n_equal USING @minint_minus_1; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +NULL +DROP PREPARE p_less; +DROP PREPARE p_less_eq; +DROP PREPARE p_greater; +DROP PREPARE p_gret_eq; +DROP PREPARE p_equal; +DROP PREPARE p_n_eq; +DROP PREPARE p_n_equal; +EXPLAIN SELECT * FROM inttbl WHERE '18446744073709551616.1' > colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` is not null) +EXPLAIN SELECT * FROM inttbl WHERE '18446744073709551615.0' >= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` is not null) +EXPLAIN SELECT * FROM inttbl WHERE '18446744073709551616.1' < colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where false +EXPLAIN SELECT * FROM inttbl WHERE '18446744073709551615.0' <= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (18446744073709551615 = `test`.`inttbl`.`colA`) +EXPLAIN SELECT * FROM inttbl WHERE '18446744073709551615.0' < colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where false +EXPLAIN SELECT * FROM inttbl WHERE '-1.1' < colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` is not null) +EXPLAIN SELECT * FROM inttbl WHERE '-1.1' >= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where false +EXPLAIN SELECT * FROM inttbl WHERE '0.0' >= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (0 = `test`.`inttbl`.`colA`) +EXPLAIN SELECT * FROM inttbl WHERE '0.0' <= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` is not null) +EXPLAIN SELECT * FROM inttbl WHERE '0.0' < colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 33.33 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (0 < `test`.`inttbl`.`colA`) +EXPLAIN SELECT * FROM inttbl WHERE '18446744073709551616.1' = colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where false +EXPLAIN SELECT * FROM inttbl WHERE '18446744073709551616.1' <=> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where false +EXPLAIN SELECT * FROM inttbl WHERE '18446744073709551616.1' <> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` is not null) +EXPLAIN SELECT * FROM inttbl WHERE '18446744073709551615.0' = colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` = 18446744073709551615) +EXPLAIN SELECT * FROM inttbl WHERE '18446744073709551615.0' <=> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (18446744073709551615 <=> `test`.`inttbl`.`colA`) +EXPLAIN SELECT * FROM inttbl WHERE '18446744073709551615.0' <> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (18446744073709551615 <> `test`.`inttbl`.`colA`) +EXPLAIN SELECT * FROM inttbl WHERE '0.0' = colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` = 0) +EXPLAIN SELECT * FROM inttbl WHERE '0.0' <=> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (0 <=> `test`.`inttbl`.`colA`) +EXPLAIN SELECT * FROM inttbl WHERE '0.0' <> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (0 <> `test`.`inttbl`.`colA`) +EXPLAIN SELECT * FROM inttbl WHERE '-1.1' = colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where false +EXPLAIN SELECT * FROM inttbl WHERE '-1.1' <=> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where false +EXPLAIN SELECT * FROM inttbl WHERE '-1.1' <> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` is not null) +DROP TABLE inttbl; +# +# Tests with UNSIGNED type BIGINT against decimal +# +CREATE TABLE inttbl (colA BIGINT UNSIGNED ); +INSERT INTO inttbl VALUES ('0.0'), ('1.0'), +(0),(1),(3), +('18446744073709551614.0'), ('18446744073709551615.0'), +(NULL); +ANALYZE TABLE inttbl; +Table Op Msg_type Msg_text +test.inttbl analyze status OK +SELECT * FROM inttbl; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +NULL +SELECT * FROM inttbl WHERE colA < 0.5; +colA +0 +0 +SELECT * FROM inttbl WHERE colA <= 0.5; +colA +0 +0 +SELECT * FROM inttbl WHERE colA > 0.5; +colA +1 +1 +3 +18446744073709551614 +18446744073709551615 +SELECT * FROM inttbl WHERE colA >= 0.5; +colA +1 +1 +3 +18446744073709551614 +18446744073709551615 +SELECT * FROM inttbl WHERE colA = 0.5; +colA +SELECT * FROM inttbl WHERE colA <> 0.5; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +SELECT * FROM inttbl WHERE colA < -0.5; +colA +SELECT * FROM inttbl WHERE colA <= -0.5; +colA +SELECT * FROM inttbl WHERE colA > -0.5; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +SELECT * FROM inttbl WHERE colA >= -0.5; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +SELECT * FROM inttbl WHERE colA = -0.5; +colA +SELECT * FROM inttbl WHERE colA <> -0.5; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +SELECT * FROM inttbl WHERE colA < '18446744073709551615.00001'; +colA +0 +1 +0 +1 +3 +18446744073709551614 +SELECT * FROM inttbl WHERE colA <= '18446744073709551615.00001'; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +SELECT * FROM inttbl WHERE colA > '18446744073709551615.00001'; +colA +SELECT * FROM inttbl WHERE colA >= '18446744073709551615.00001'; +colA +18446744073709551615 +SELECT * FROM inttbl WHERE colA = '18446744073709551615.00001'; +colA +18446744073709551615 +SELECT * FROM inttbl WHERE colA <> '18446744073709551615.00001'; +colA +0 +1 +0 +1 +3 +18446744073709551614 +SELECT * FROM inttbl WHERE colA < '18446744073709551614.99999'; +colA +0 +1 +0 +1 +3 +18446744073709551614 +SELECT * FROM inttbl WHERE colA <= '18446744073709551614.99999'; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +SELECT * FROM inttbl WHERE colA > '18446744073709551614.99999'; +colA +SELECT * FROM inttbl WHERE colA >= '18446744073709551614.99999'; +colA +18446744073709551615 +SELECT * FROM inttbl WHERE colA = '18446744073709551614.99999'; +colA +18446744073709551615 +SELECT * FROM inttbl WHERE colA <> '18446744073709551614.99999'; +colA +0 +1 +0 +1 +3 +18446744073709551614 +SELECT * FROM inttbl WHERE colA < '0.00001'; +colA +0 +0 +SELECT * FROM inttbl WHERE colA <= '0.00001'; +colA +0 +0 +SELECT * FROM inttbl WHERE colA > '0.00001'; +colA +1 +1 +3 +18446744073709551614 +18446744073709551615 +SELECT * FROM inttbl WHERE colA >= '0.00001'; +colA +1 +1 +3 +18446744073709551614 +18446744073709551615 +SELECT * FROM inttbl WHERE colA = '0.00001'; +colA +SELECT * FROM inttbl WHERE colA <> '0.00001'; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +SELECT * FROM inttbl WHERE colA < '-0.99999'; +colA +SELECT * FROM inttbl WHERE colA <= '-0.99999'; +colA +SELECT * FROM inttbl WHERE colA > '-0.99999'; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +SELECT * FROM inttbl WHERE colA >= '-0.99999'; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +SELECT * FROM inttbl WHERE colA = '-0.99999'; +colA +SELECT * FROM inttbl WHERE colA <> '-0.99999'; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +SELECT * FROM inttbl WHERE colA < 18446744073709551615.00000001; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +SELECT * FROM inttbl WHERE colA <= 18446744073709551615.00000001; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +SELECT * FROM inttbl WHERE colA > 18446744073709551615.00000001; +colA +SELECT * FROM inttbl WHERE colA >= 18446744073709551615.00000001; +colA +SELECT * FROM inttbl WHERE colA = 18446744073709551615.00000001; +colA +SELECT * FROM inttbl WHERE colA <> 18446744073709551615.00000001; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +SELECT * FROM inttbl WHERE colA < -9223372036854775808.00000001; +colA +SELECT * FROM inttbl WHERE colA <= -9223372036854775808.00000001; +colA +SELECT * FROM inttbl WHERE colA > -9223372036854775808.00000001; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +SELECT * FROM inttbl WHERE colA >= -9223372036854775808.00000001; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +SELECT * FROM inttbl WHERE colA = -9223372036854775808.00000001; +colA +SELECT * FROM inttbl WHERE colA <> -9223372036854775808.00000001; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +PREPARE p_less FROM 'SELECT * FROM inttbl WHERE colA < ?'; +PREPARE p_less_eq FROM 'SELECT * FROM inttbl WHERE colA <= ?'; +PREPARE p_greater FROM 'SELECT * FROM inttbl WHERE colA > ?'; +PREPARE p_gret_eq FROM 'SELECT * FROM inttbl WHERE colA >= ?'; +PREPARE p_equal FROM 'SELECT * FROM inttbl WHERE colA = ?'; +PREPARE p_n_equal FROM 'SELECT * FROM inttbl WHERE colA <> ?'; +SET @dec_0_5=0.5; +SET @dec_minus_0_5=-0.5; +SET @dec_max_plus_delta='18446744073709551615.00001'; +SET @dec_max_minus_delta='18446744073709551614.99999'; +SET @dec_min_plus_delta='0.00001'; +SET @dec_min_minus_delta='-0.99999'; +SET @dec_too_big_positive_for_any_int=18446744073709551615.00000001; +SET @dec_too_big_negative_for_any_int=-9223372036854775808.00000001; +EXECUTE p_less USING @dec_0_5; +colA +0 +0 +EXECUTE p_less_eq USING @dec_0_5; +colA +0 +0 +EXECUTE p_greater USING @dec_0_5; +colA +1 +1 +3 +18446744073709551614 +18446744073709551615 +EXECUTE p_gret_eq USING @dec_0_5; +colA +1 +1 +3 +18446744073709551614 +18446744073709551615 +EXECUTE p_equal USING @dec_0_5; +colA +EXECUTE p_n_equal USING @dec_0_5; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +EXECUTE p_less USING @dec_minus_0_5; +colA +EXECUTE p_less_eq USING @dec_minus_0_5; +colA +EXECUTE p_greater USING @dec_minus_0_5; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +EXECUTE p_gret_eq USING @dec_minus_0_5; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +EXECUTE p_equal USING @dec_minus_0_5; +colA +EXECUTE p_n_equal USING @dec_minus_0_5; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +EXECUTE p_less USING @dec_max_plus_delta; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +EXECUTE p_less_eq USING @dec_max_plus_delta; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +EXECUTE p_greater USING @dec_max_plus_delta; +colA +EXECUTE p_gret_eq USING @dec_max_plus_delta; +colA +EXECUTE p_equal USING @dec_max_plus_delta; +colA +EXECUTE p_n_equal USING @dec_max_plus_delta; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +EXECUTE p_less USING @dec_max_minus_delta; +colA +0 +1 +0 +1 +3 +18446744073709551614 +EXECUTE p_less_eq USING @dec_max_minus_delta; +colA +0 +1 +0 +1 +3 +18446744073709551614 +EXECUTE p_greater USING @dec_max_minus_delta; +colA +18446744073709551615 +EXECUTE p_gret_eq USING @dec_max_minus_delta; +colA +18446744073709551615 +EXECUTE p_equal USING @dec_max_minus_delta; +colA +EXECUTE p_n_equal USING @dec_max_minus_delta; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +EXECUTE p_less USING @dec_min_plus_delta; +colA +0 +0 +EXECUTE p_less_eq USING @dec_min_plus_delta; +colA +0 +0 +EXECUTE p_greater USING @dec_min_plus_delta; +colA +1 +1 +3 +18446744073709551614 +18446744073709551615 +EXECUTE p_gret_eq USING @dec_min_plus_delta; +colA +1 +1 +3 +18446744073709551614 +18446744073709551615 +EXECUTE p_equal USING @dec_min_plus_delta; +colA +EXECUTE p_n_equal USING @dec_min_plus_delta; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +EXECUTE p_less USING @dec_min_minus_delta; +colA +EXECUTE p_less_eq USING @dec_min_minus_delta; +colA +EXECUTE p_greater USING @dec_min_minus_delta; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +EXECUTE p_gret_eq USING @dec_min_minus_delta; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +EXECUTE p_equal USING @dec_min_minus_delta; +colA +EXECUTE p_n_equal USING @dec_min_minus_delta; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +EXECUTE p_less USING @dec_too_big_positive_for_any_int; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +EXECUTE p_less_eq USING @dec_too_big_positive_for_any_int; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +EXECUTE p_greater USING @dec_too_big_positive_for_any_int; +colA +EXECUTE p_gret_eq USING @dec_too_big_positive_for_any_int; +colA +EXECUTE p_equal USING @dec_too_big_positive_for_any_int; +colA +EXECUTE p_n_equal USING @dec_too_big_positive_for_any_int; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +EXECUTE p_less USING @dec_too_big_negative_for_any_int; +colA +EXECUTE p_less_eq USING @dec_too_big_negative_for_any_int; +colA +EXECUTE p_greater USING @dec_too_big_negative_for_any_int; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +EXECUTE p_gret_eq USING @dec_too_big_negative_for_any_int; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +EXECUTE p_equal USING @dec_too_big_negative_for_any_int; +colA +EXECUTE p_n_equal USING @dec_too_big_negative_for_any_int; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +DROP PREPARE p_less; +DROP PREPARE p_less_eq; +DROP PREPARE p_greater; +DROP PREPARE p_gret_eq; +DROP PREPARE p_equal; +DROP PREPARE p_n_equal; +DROP TABLE inttbl; +Cruft inside string +CREATE TABLE t(i INT); +INSERT INTO t VALUES (-1), (0), (1); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +SELECT * FROM t WHERE i > 'A'; +i +1 +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'A' +EXPLAIN SELECT * FROM t WHERE i > 'A'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'A' +Note 1003 /* select#1 */ select `test`.`t`.`i` AS `i` from `test`.`t` where (`test`.`t`.`i` > 0) +DROP TABLE t; +Detect decimal inside a string when compared to int +Used to return one row; should be none. +CREATE TABLE t(i BIGINT); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +INSERT INTO t VALUES (1), (2); +SELECT * FROM t WHERE i = '1.1'; +i +EXPLAIN SELECT * FROM t WHERE i = '1.1'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`i` AS `i` from `test`.`t` where false +DROP TABLE t; +Detect out of range real inside a string when compared to int +Used to return one row; should be none. +CREATE TABLE t(i TINYINT); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +INSERT INTO t VALUES (1), (2); +SELECT * FROM t WHERE i > '1E10'; +i +EXPLAIN SELECT * FROM t WHERE i > '1E10'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`i` AS `i` from `test`.`t` where false +DROP TABLE t; +Detect out of range real inside a string when compared to int +Used to return one row; should be none. +CREATE TABLE t(i TINYINT); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +INSERT INTO t VALUES (0); +SELECT * FROM t WHERE i = '1E-308'; +i +EXPLAIN SELECT * FROM t WHERE i = '1E-308'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`i` AS `i` from `test`.`t` where false +Above query should yield the same as this: +SELECT * FROM t WHERE i = 1E-308; +i +EXPLAIN SELECT * FROM t WHERE i = 1E-308; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`i` AS `i` from `test`.`t` where false +DROP TABLE t; +# +# Tests with type BIGINT against int +# +CREATE TABLE inttbls (colA BIGINT ); +INSERT INTO inttbls VALUES (-9223372036854775808), (-9223372036854775807), +(0),(1),(3), +(9223372036854775806), (9223372036854775807), +(NULL); +ANALYZE TABLE inttbls; +Table Op Msg_type Msg_text +test.inttbls analyze status OK +SELECT * FROM inttbls; +colA +-9223372036854775808 +-9223372036854775807 +0 +1 +3 +9223372036854775806 +9223372036854775807 +NULL +SELECT * FROM inttbls WHERE colA < 9223372036854775808; +colA +-9223372036854775808 +-9223372036854775807 +0 +1 +3 +9223372036854775806 +9223372036854775807 +SELECT * FROM inttbls WHERE colA <= 9223372036854775807; +colA +-9223372036854775808 +-9223372036854775807 +0 +1 +3 +9223372036854775806 +9223372036854775807 +SELECT * FROM inttbls WHERE colA > 9223372036854775808; +colA +SELECT * FROM inttbls WHERE colA >= 9223372036854775807; +colA +9223372036854775807 +SELECT * FROM inttbls WHERE colA > -9223372036854775809; +colA +-9223372036854775808 +-9223372036854775807 +0 +1 +3 +9223372036854775806 +9223372036854775807 +SELECT * FROM inttbls WHERE colA <= -9223372036854775809; +colA +SELECT * FROM inttbls WHERE colA <= -9223372036854775808; +colA +-9223372036854775808 +SELECT * FROM inttbls WHERE colA >= -9223372036854775808; +colA +-9223372036854775808 +-9223372036854775807 +0 +1 +3 +9223372036854775806 +9223372036854775807 +SELECT * FROM inttbls WHERE colA > -9223372036854775808; +colA +-9223372036854775807 +0 +1 +3 +9223372036854775806 +9223372036854775807 +SELECT * FROM inttbls WHERE colA = 9223372036854775808; +colA +SELECT * FROM inttbls WHERE colA <> 9223372036854775808; +colA +-9223372036854775808 +-9223372036854775807 +0 +1 +3 +9223372036854775806 +9223372036854775807 +SELECT * FROM inttbls WHERE colA = 9223372036854775807; +colA +9223372036854775807 +SELECT * FROM inttbls WHERE colA <=> 9223372036854775807; +colA +9223372036854775807 +SELECT * FROM inttbls WHERE NOT(colA <=> 9223372036854775807); +colA +-9223372036854775808 +-9223372036854775807 +0 +1 +3 +9223372036854775806 +NULL +SELECT * FROM inttbls WHERE colA <> 9223372036854775807; +colA +-9223372036854775808 +-9223372036854775807 +0 +1 +3 +9223372036854775806 +SELECT * FROM inttbls WHERE colA = -9223372036854775808; +colA +-9223372036854775808 +SELECT * FROM inttbls WHERE colA <=> -9223372036854775808; +colA +-9223372036854775808 +SELECT * FROM inttbls WHERE NOT(colA <=> -9223372036854775808); +colA +-9223372036854775807 +0 +1 +3 +9223372036854775806 +9223372036854775807 +NULL +SELECT * FROM inttbls WHERE colA <> -9223372036854775808; +colA +-9223372036854775807 +0 +1 +3 +9223372036854775806 +9223372036854775807 +SELECT * FROM inttbls WHERE colA = -9223372036854775809; +colA +SELECT * FROM inttbls WHERE colA <=> -9223372036854775809; +colA +SELECT * FROM inttbls WHERE NOT(colA <=> -9223372036854775809); +colA +-9223372036854775808 +-9223372036854775807 +0 +1 +3 +9223372036854775806 +9223372036854775807 +NULL +SELECT * FROM inttbls WHERE colA <> -9223372036854775809; +colA +-9223372036854775808 +-9223372036854775807 +0 +1 +3 +9223372036854775806 +9223372036854775807 +PREPARE p_less FROM 'SELECT * FROM inttbls WHERE colA < ?'; +PREPARE p_less_eq FROM 'SELECT * FROM inttbls WHERE colA <= ?'; +PREPARE p_greater FROM 'SELECT * FROM inttbls WHERE colA > ?'; +PREPARE p_gret_eq FROM 'SELECT * FROM inttbls WHERE colA >= ?'; +PREPARE p_eq FROM 'SELECT * FROM inttbls WHERE colA = ?'; +PREPARE p_equal FROM 'SELECT * FROM inttbls WHERE colA <=> ?'; +PREPARE p_n_equal FROM 'SELECT * FROM inttbls WHERE NOT(colA <=> ?)'; +PREPARE p_n_eq FROM 'SELECT * FROM inttbls WHERE colA <> ?'; +SET @maxint_plus_1=9223372036854775808; +SET @maxint=9223372036854775807; +SET @minint_minus_1=-9223372036854775809; +SET @minint=-9223372036854775808; +EXECUTE p_less USING @maxint_plus_1; +colA +-9223372036854775808 +-9223372036854775807 +0 +1 +3 +9223372036854775806 +9223372036854775807 +EXECUTE p_less_eq USING @maxint; +colA +-9223372036854775808 +-9223372036854775807 +0 +1 +3 +9223372036854775806 +9223372036854775807 +EXECUTE p_greater USING @maxint_plus_1; +colA +EXECUTE p_gret_eq USING @maxint; +colA +9223372036854775807 +EXECUTE p_greater USING @minint_minus_1; +colA +-9223372036854775808 +-9223372036854775807 +0 +1 +3 +9223372036854775806 +9223372036854775807 +EXECUTE p_less_eq USING @minint_minus_1; +colA +EXECUTE p_less_eq USING @minint; +colA +-9223372036854775808 +EXECUTE p_gret_eq USING @minint; +colA +-9223372036854775808 +-9223372036854775807 +0 +1 +3 +9223372036854775806 +9223372036854775807 +EXECUTE p_greater USING @minint; +colA +-9223372036854775807 +0 +1 +3 +9223372036854775806 +9223372036854775807 +EXECUTE p_eq USING @maxint_plus_1; +colA +EXECUTE p_equal USING @maxint_plus_1; +colA +EXECUTE p_n_eq USING @maxint_plus_1; +colA +-9223372036854775808 +-9223372036854775807 +0 +1 +3 +9223372036854775806 +9223372036854775807 +EXECUTE p_n_equal USING @maxint_plus_1; +colA +-9223372036854775808 +-9223372036854775807 +0 +1 +3 +9223372036854775806 +9223372036854775807 +NULL +EXECUTE p_eq USING @maxint; +colA +9223372036854775807 +EXECUTE p_equal USING @maxint; +colA +9223372036854775807 +EXECUTE p_n_eq USING @maxint; +colA +-9223372036854775808 +-9223372036854775807 +0 +1 +3 +9223372036854775806 +EXECUTE p_n_equal USING @maxint; +colA +-9223372036854775808 +-9223372036854775807 +0 +1 +3 +9223372036854775806 +NULL +EXECUTE p_eq USING @minint; +colA +-9223372036854775808 +EXECUTE p_equal USING @minint; +colA +-9223372036854775808 +EXECUTE p_n_eq USING @minint; +colA +-9223372036854775807 +0 +1 +3 +9223372036854775806 +9223372036854775807 +EXECUTE p_n_equal USING @minint; +colA +-9223372036854775807 +0 +1 +3 +9223372036854775806 +9223372036854775807 +NULL +EXECUTE p_eq USING @minint_minus_1; +colA +EXECUTE p_equal USING @minint_minus_1; +colA +EXECUTE p_n_eq USING @minint_minus_1; +colA +-9223372036854775808 +-9223372036854775807 +0 +1 +3 +9223372036854775806 +9223372036854775807 +EXECUTE p_n_equal USING @minint_minus_1; +colA +-9223372036854775808 +-9223372036854775807 +0 +1 +3 +9223372036854775806 +9223372036854775807 +NULL +DROP PREPARE p_less; +DROP PREPARE p_less_eq; +DROP PREPARE p_greater; +DROP PREPARE p_gret_eq; +DROP PREPARE p_equal; +DROP PREPARE p_n_eq; +DROP PREPARE p_n_equal; +EXPLAIN SELECT * FROM inttbls WHERE colA < 9223372036854775808; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where (`test`.`inttbls`.`colA` is not null) +EXPLAIN SELECT * FROM inttbls WHERE colA <= 9223372036854775807; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where (`test`.`inttbls`.`colA` is not null) +EXPLAIN SELECT * FROM inttbls WHERE colA > 9223372036854775808; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where false +EXPLAIN SELECT * FROM inttbls WHERE colA >= 9223372036854775807; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where (`test`.`inttbls`.`colA` = 9223372036854775807) +EXPLAIN SELECT * FROM inttbls WHERE colA > -9223372036854775809; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where (`test`.`inttbls`.`colA` is not null) +EXPLAIN SELECT * FROM inttbls WHERE colA <= -9223372036854775809; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where false +EXPLAIN SELECT * FROM inttbls WHERE colA <= -9223372036854775808; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where (`test`.`inttbls`.`colA` = -9223372036854775808) +EXPLAIN SELECT * FROM inttbls WHERE colA >= -9223372036854775808; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where (`test`.`inttbls`.`colA` is not null) +EXPLAIN SELECT * FROM inttbls WHERE colA > -9223372036854775808; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 33.33 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where (`test`.`inttbls`.`colA` > -9223372036854775808) +EXPLAIN SELECT * FROM inttbls WHERE colA = 9223372036854775808; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where false +EXPLAIN SELECT * FROM inttbls WHERE colA <=> 9223372036854775808; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where false +EXPLAIN SELECT * FROM inttbls WHERE colA <> 9223372036854775808; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where (`test`.`inttbls`.`colA` is not null) +EXPLAIN SELECT * FROM inttbls WHERE colA = 9223372036854775807; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where (`test`.`inttbls`.`colA` = 9223372036854775807) +EXPLAIN SELECT * FROM inttbls WHERE colA <=> 9223372036854775807; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where (`test`.`inttbls`.`colA` <=> 9223372036854775807) +EXPLAIN SELECT * FROM inttbls WHERE colA <> 9223372036854775807; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where (`test`.`inttbls`.`colA` <> 9223372036854775807) +EXPLAIN SELECT * FROM inttbls WHERE colA = -9223372036854775808; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where (`test`.`inttbls`.`colA` = -9223372036854775808) +EXPLAIN SELECT * FROM inttbls WHERE colA <=> -9223372036854775808; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where (`test`.`inttbls`.`colA` <=> -9223372036854775808) +EXPLAIN SELECT * FROM inttbls WHERE colA <> -9223372036854775808; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where (`test`.`inttbls`.`colA` <> -9223372036854775808) +EXPLAIN SELECT * FROM inttbls WHERE colA = -9223372036854775809; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where false +EXPLAIN SELECT * FROM inttbls WHERE colA <=> -9223372036854775809; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where false +EXPLAIN SELECT * FROM inttbls WHERE colA <> -9223372036854775809; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where (`test`.`inttbls`.`colA` is not null) +same queries but constant first +SELECT * FROM inttbls WHERE 9223372036854775808 > colA; +colA +-9223372036854775808 +-9223372036854775807 +0 +1 +3 +9223372036854775806 +9223372036854775807 +SELECT * FROM inttbls WHERE 9223372036854775807 >= colA; +colA +-9223372036854775808 +-9223372036854775807 +0 +1 +3 +9223372036854775806 +9223372036854775807 +SELECT * FROM inttbls WHERE 9223372036854775808 < colA; +colA +SELECT * FROM inttbls WHERE 9223372036854775807 <= colA; +colA +9223372036854775807 +SELECT * FROM inttbls WHERE 9223372036854775807 < colA; +colA +SELECT * FROM inttbls WHERE -9223372036854775809 < colA; +colA +-9223372036854775808 +-9223372036854775807 +0 +1 +3 +9223372036854775806 +9223372036854775807 +SELECT * FROM inttbls WHERE -9223372036854775809 >= colA; +colA +SELECT * FROM inttbls WHERE -9223372036854775808 >= colA; +colA +-9223372036854775808 +SELECT * FROM inttbls WHERE -9223372036854775808 <= colA; +colA +-9223372036854775808 +-9223372036854775807 +0 +1 +3 +9223372036854775806 +9223372036854775807 +SELECT * FROM inttbls WHERE -9223372036854775808 < colA; +colA +-9223372036854775807 +0 +1 +3 +9223372036854775806 +9223372036854775807 +SELECT * FROM inttbls WHERE 9223372036854775808 = colA; +colA +SELECT * FROM inttbls WHERE 9223372036854775808 <=> colA; +colA +SELECT * FROM inttbls WHERE 9223372036854775808 <> colA; +colA +-9223372036854775808 +-9223372036854775807 +0 +1 +3 +9223372036854775806 +9223372036854775807 +SELECT * FROM inttbls WHERE 9223372036854775807 = colA; +colA +9223372036854775807 +SELECT * FROM inttbls WHERE 9223372036854775807 <=> colA; +colA +9223372036854775807 +SELECT * FROM inttbls WHERE 9223372036854775807 <> colA; +colA +-9223372036854775808 +-9223372036854775807 +0 +1 +3 +9223372036854775806 +SELECT * FROM inttbls WHERE -9223372036854775808 = colA; +colA +-9223372036854775808 +SELECT * FROM inttbls WHERE -9223372036854775808 <=> colA; +colA +-9223372036854775808 +SELECT * FROM inttbls WHERE -9223372036854775808 <> colA; +colA +-9223372036854775807 +0 +1 +3 +9223372036854775806 +9223372036854775807 +SELECT * FROM inttbls WHERE -9223372036854775809 = colA; +colA +SELECT * FROM inttbls WHERE -9223372036854775809 <=> colA; +colA +SELECT * FROM inttbls WHERE -9223372036854775809 <> colA; +colA +-9223372036854775808 +-9223372036854775807 +0 +1 +3 +9223372036854775806 +9223372036854775807 +PREPARE p_less FROM 'SELECT * FROM inttbls WHERE ? < colA'; +PREPARE p_less_eq FROM 'SELECT * FROM inttbls WHERE ? <= colA'; +PREPARE p_greater FROM 'SELECT * FROM inttbls WHERE ? > colA'; +PREPARE p_gret_eq FROM 'SELECT * FROM inttbls WHERE ? >= colA'; +PREPARE p_eq FROM 'SELECT * FROM inttbls WHERE ? = colA'; +PREPARE p_equal FROM 'SELECT * FROM inttbls WHERE ? <=> colA'; +PREPARE p_n_eq FROM 'SELECT * FROM inttbls WHERE ? <> colA'; +PREPARE p_n_equal FROM 'SELECT * FROM inttbls WHERE NOT(? <=> colA)'; +EXECUTE p_greater USING @maxint_plus_1; +colA +-9223372036854775808 +-9223372036854775807 +0 +1 +3 +9223372036854775806 +9223372036854775807 +EXECUTE p_gret_eq USING @maxint; +colA +-9223372036854775808 +-9223372036854775807 +0 +1 +3 +9223372036854775806 +9223372036854775807 +EXECUTE p_less USING @maxint_plus_1; +colA +EXECUTE p_less_eq USING @maxint; +colA +9223372036854775807 +EXECUTE p_less USING @minint_minus_1; +colA +-9223372036854775808 +-9223372036854775807 +0 +1 +3 +9223372036854775806 +9223372036854775807 +EXECUTE p_gret_eq USING @minint_minus_1; +colA +EXECUTE p_gret_eq USING @minint; +colA +-9223372036854775808 +EXECUTE p_less_eq USING @minint; +colA +-9223372036854775808 +-9223372036854775807 +0 +1 +3 +9223372036854775806 +9223372036854775807 +EXECUTE p_less USING @minint; +colA +-9223372036854775807 +0 +1 +3 +9223372036854775806 +9223372036854775807 +EXECUTE p_eq USING @maxint_plus_1; +colA +EXECUTE p_equal USING @maxint_plus_1; +colA +EXECUTE p_n_eq USING @maxint_plus_1; +colA +-9223372036854775808 +-9223372036854775807 +0 +1 +3 +9223372036854775806 +9223372036854775807 +EXECUTE p_n_equal USING @maxint_plus_1; +colA +-9223372036854775808 +-9223372036854775807 +0 +1 +3 +9223372036854775806 +9223372036854775807 +NULL +EXECUTE p_eq USING @maxint; +colA +9223372036854775807 +EXECUTE p_equal USING @maxint; +colA +9223372036854775807 +EXECUTE p_n_eq USING @maxint; +colA +-9223372036854775808 +-9223372036854775807 +0 +1 +3 +9223372036854775806 +EXECUTE p_n_equal USING @maxint; +colA +-9223372036854775808 +-9223372036854775807 +0 +1 +3 +9223372036854775806 +NULL +EXECUTE p_eq USING @minint; +colA +-9223372036854775808 +EXECUTE p_equal USING @minint; +colA +-9223372036854775808 +EXECUTE p_n_eq USING @minint; +colA +-9223372036854775807 +0 +1 +3 +9223372036854775806 +9223372036854775807 +EXECUTE p_n_equal USING @minint; +colA +-9223372036854775807 +0 +1 +3 +9223372036854775806 +9223372036854775807 +NULL +EXECUTE p_eq USING @minint_minus_1; +colA +EXECUTE p_equal USING @minint_minus_1; +colA +EXECUTE p_n_eq USING @minint_minus_1; +colA +-9223372036854775808 +-9223372036854775807 +0 +1 +3 +9223372036854775806 +9223372036854775807 +EXECUTE p_n_equal USING @minint_minus_1; +colA +-9223372036854775808 +-9223372036854775807 +0 +1 +3 +9223372036854775806 +9223372036854775807 +NULL +DROP PREPARE p_less; +DROP PREPARE p_less_eq; +DROP PREPARE p_greater; +DROP PREPARE p_gret_eq; +DROP PREPARE p_equal; +DROP PREPARE p_n_eq; +DROP PREPARE p_n_equal; +EXPLAIN SELECT * FROM inttbls WHERE 9223372036854775808 > colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where (`test`.`inttbls`.`colA` is not null) +EXPLAIN SELECT * FROM inttbls WHERE 9223372036854775807 >= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where (`test`.`inttbls`.`colA` is not null) +EXPLAIN SELECT * FROM inttbls WHERE 9223372036854775808 < colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where false +EXPLAIN SELECT * FROM inttbls WHERE 9223372036854775807 <= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where (9223372036854775807 = `test`.`inttbls`.`colA`) +EXPLAIN SELECT * FROM inttbls WHERE 9223372036854775807 < colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where false +EXPLAIN SELECT * FROM inttbls WHERE -9223372036854775809 < colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where (`test`.`inttbls`.`colA` is not null) +EXPLAIN SELECT * FROM inttbls WHERE -9223372036854775809 >= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where false +EXPLAIN SELECT * FROM inttbls WHERE -9223372036854775808 >= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where (-9223372036854775808 = `test`.`inttbls`.`colA`) +EXPLAIN SELECT * FROM inttbls WHERE -9223372036854775808 <= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where (`test`.`inttbls`.`colA` is not null) +EXPLAIN SELECT * FROM inttbls WHERE -9223372036854775808 < colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 33.33 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where (-9223372036854775808 < `test`.`inttbls`.`colA`) +EXPLAIN SELECT * FROM inttbls WHERE 9223372036854775808 = colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where false +EXPLAIN SELECT * FROM inttbls WHERE 9223372036854775808 <=> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where false +EXPLAIN SELECT * FROM inttbls WHERE 9223372036854775808 <> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where (`test`.`inttbls`.`colA` is not null) +EXPLAIN SELECT * FROM inttbls WHERE 9223372036854775807 = colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where (`test`.`inttbls`.`colA` = 9223372036854775807) +EXPLAIN SELECT * FROM inttbls WHERE 9223372036854775807 <=> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where (9223372036854775807 <=> `test`.`inttbls`.`colA`) +EXPLAIN SELECT * FROM inttbls WHERE 9223372036854775807 <> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where (9223372036854775807 <> `test`.`inttbls`.`colA`) +EXPLAIN SELECT * FROM inttbls WHERE -9223372036854775808 = colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where (`test`.`inttbls`.`colA` = -9223372036854775808) +EXPLAIN SELECT * FROM inttbls WHERE -9223372036854775808 <=> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where (-9223372036854775808 <=> `test`.`inttbls`.`colA`) +EXPLAIN SELECT * FROM inttbls WHERE -9223372036854775808 <> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where (-9223372036854775808 <> `test`.`inttbls`.`colA`) +EXPLAIN SELECT * FROM inttbls WHERE -9223372036854775809 = colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where false +EXPLAIN SELECT * FROM inttbls WHERE -9223372036854775809 <=> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where false +EXPLAIN SELECT * FROM inttbls WHERE -9223372036854775809 <> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where (`test`.`inttbls`.`colA` is not null) +DROP TABLE inttbls; +# +# Tests with type BIGINT NOT NULL against int +# +CREATE TABLE inttbls (colA BIGINT NOT NULL); +INSERT INTO inttbls VALUES (-9223372036854775808), (-9223372036854775807), +(0),(1),(3), +(9223372036854775806), (9223372036854775807), +(0); +ANALYZE TABLE inttbls; +Table Op Msg_type Msg_text +test.inttbls analyze status OK +SELECT * FROM inttbls; +colA +-9223372036854775808 +-9223372036854775807 +0 +1 +3 +9223372036854775806 +9223372036854775807 +0 +SELECT * FROM inttbls WHERE colA < 9223372036854775808; +colA +-9223372036854775808 +-9223372036854775807 +0 +1 +3 +9223372036854775806 +9223372036854775807 +0 +SELECT * FROM inttbls WHERE colA <= 9223372036854775807; +colA +-9223372036854775808 +-9223372036854775807 +0 +1 +3 +9223372036854775806 +9223372036854775807 +0 +SELECT * FROM inttbls WHERE colA > 9223372036854775808; +colA +SELECT * FROM inttbls WHERE colA >= 9223372036854775807; +colA +9223372036854775807 +SELECT * FROM inttbls WHERE colA > -9223372036854775809; +colA +-9223372036854775808 +-9223372036854775807 +0 +1 +3 +9223372036854775806 +9223372036854775807 +0 +SELECT * FROM inttbls WHERE colA <= -9223372036854775809; +colA +SELECT * FROM inttbls WHERE colA <= -9223372036854775808; +colA +-9223372036854775808 +SELECT * FROM inttbls WHERE colA >= -9223372036854775808; +colA +-9223372036854775808 +-9223372036854775807 +0 +1 +3 +9223372036854775806 +9223372036854775807 +0 +SELECT * FROM inttbls WHERE colA > -9223372036854775808; +colA +-9223372036854775807 +0 +1 +3 +9223372036854775806 +9223372036854775807 +0 +SELECT * FROM inttbls WHERE colA = 9223372036854775808; +colA +SELECT * FROM inttbls WHERE colA <> 9223372036854775808; +colA +-9223372036854775808 +-9223372036854775807 +0 +1 +3 +9223372036854775806 +9223372036854775807 +0 +SELECT * FROM inttbls WHERE colA = 9223372036854775807; +colA +9223372036854775807 +SELECT * FROM inttbls WHERE colA <=> 9223372036854775807; +colA +9223372036854775807 +SELECT * FROM inttbls WHERE NOT(colA <=> 9223372036854775807); +colA +-9223372036854775808 +-9223372036854775807 +0 +1 +3 +9223372036854775806 +0 +SELECT * FROM inttbls WHERE colA <> 9223372036854775807; +colA +-9223372036854775808 +-9223372036854775807 +0 +1 +3 +9223372036854775806 +0 +SELECT * FROM inttbls WHERE colA = -9223372036854775808; +colA +-9223372036854775808 +SELECT * FROM inttbls WHERE colA <=> -9223372036854775808; +colA +-9223372036854775808 +SELECT * FROM inttbls WHERE NOT(colA <=> -9223372036854775808); +colA +-9223372036854775807 +0 +1 +3 +9223372036854775806 +9223372036854775807 +0 +SELECT * FROM inttbls WHERE colA <> -9223372036854775808; +colA +-9223372036854775807 +0 +1 +3 +9223372036854775806 +9223372036854775807 +0 +SELECT * FROM inttbls WHERE colA = -9223372036854775809; +colA +SELECT * FROM inttbls WHERE colA <=> -9223372036854775809; +colA +SELECT * FROM inttbls WHERE NOT(colA <=> -9223372036854775809); +colA +-9223372036854775808 +-9223372036854775807 +0 +1 +3 +9223372036854775806 +9223372036854775807 +0 +SELECT * FROM inttbls WHERE colA <> -9223372036854775809; +colA +-9223372036854775808 +-9223372036854775807 +0 +1 +3 +9223372036854775806 +9223372036854775807 +0 +PREPARE p_less FROM 'SELECT * FROM inttbls WHERE colA < ?'; +PREPARE p_less_eq FROM 'SELECT * FROM inttbls WHERE colA <= ?'; +PREPARE p_greater FROM 'SELECT * FROM inttbls WHERE colA > ?'; +PREPARE p_gret_eq FROM 'SELECT * FROM inttbls WHERE colA >= ?'; +PREPARE p_eq FROM 'SELECT * FROM inttbls WHERE colA = ?'; +PREPARE p_equal FROM 'SELECT * FROM inttbls WHERE colA <=> ?'; +PREPARE p_n_equal FROM 'SELECT * FROM inttbls WHERE NOT(colA <=> ?)'; +PREPARE p_n_eq FROM 'SELECT * FROM inttbls WHERE colA <> ?'; +SET @maxint_plus_1=9223372036854775808; +SET @maxint=9223372036854775807; +SET @minint_minus_1=-9223372036854775809; +SET @minint=-9223372036854775808; +EXECUTE p_less USING @maxint_plus_1; +colA +-9223372036854775808 +-9223372036854775807 +0 +1 +3 +9223372036854775806 +9223372036854775807 +0 +EXECUTE p_less_eq USING @maxint; +colA +-9223372036854775808 +-9223372036854775807 +0 +1 +3 +9223372036854775806 +9223372036854775807 +0 +EXECUTE p_greater USING @maxint_plus_1; +colA +EXECUTE p_gret_eq USING @maxint; +colA +9223372036854775807 +EXECUTE p_greater USING @minint_minus_1; +colA +-9223372036854775808 +-9223372036854775807 +0 +1 +3 +9223372036854775806 +9223372036854775807 +0 +EXECUTE p_less_eq USING @minint_minus_1; +colA +EXECUTE p_less_eq USING @minint; +colA +-9223372036854775808 +EXECUTE p_gret_eq USING @minint; +colA +-9223372036854775808 +-9223372036854775807 +0 +1 +3 +9223372036854775806 +9223372036854775807 +0 +EXECUTE p_greater USING @minint; +colA +-9223372036854775807 +0 +1 +3 +9223372036854775806 +9223372036854775807 +0 +EXECUTE p_eq USING @maxint_plus_1; +colA +EXECUTE p_equal USING @maxint_plus_1; +colA +EXECUTE p_n_eq USING @maxint_plus_1; +colA +-9223372036854775808 +-9223372036854775807 +0 +1 +3 +9223372036854775806 +9223372036854775807 +0 +EXECUTE p_n_equal USING @maxint_plus_1; +colA +-9223372036854775808 +-9223372036854775807 +0 +1 +3 +9223372036854775806 +9223372036854775807 +0 +EXECUTE p_eq USING @maxint; +colA +9223372036854775807 +EXECUTE p_equal USING @maxint; +colA +9223372036854775807 +EXECUTE p_n_eq USING @maxint; +colA +-9223372036854775808 +-9223372036854775807 +0 +1 +3 +9223372036854775806 +0 +EXECUTE p_n_equal USING @maxint; +colA +-9223372036854775808 +-9223372036854775807 +0 +1 +3 +9223372036854775806 +0 +EXECUTE p_eq USING @minint; +colA +-9223372036854775808 +EXECUTE p_equal USING @minint; +colA +-9223372036854775808 +EXECUTE p_n_eq USING @minint; +colA +-9223372036854775807 +0 +1 +3 +9223372036854775806 +9223372036854775807 +0 +EXECUTE p_n_equal USING @minint; +colA +-9223372036854775807 +0 +1 +3 +9223372036854775806 +9223372036854775807 +0 +EXECUTE p_eq USING @minint_minus_1; +colA +EXECUTE p_equal USING @minint_minus_1; +colA +EXECUTE p_n_eq USING @minint_minus_1; +colA +-9223372036854775808 +-9223372036854775807 +0 +1 +3 +9223372036854775806 +9223372036854775807 +0 +EXECUTE p_n_equal USING @minint_minus_1; +colA +-9223372036854775808 +-9223372036854775807 +0 +1 +3 +9223372036854775806 +9223372036854775807 +0 +DROP PREPARE p_less; +DROP PREPARE p_less_eq; +DROP PREPARE p_greater; +DROP PREPARE p_gret_eq; +DROP PREPARE p_equal; +DROP PREPARE p_n_eq; +DROP PREPARE p_n_equal; +EXPLAIN SELECT * FROM inttbls WHERE colA < 9223372036854775808; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where true +EXPLAIN SELECT * FROM inttbls WHERE colA <= 9223372036854775807; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where true +EXPLAIN SELECT * FROM inttbls WHERE colA > 9223372036854775808; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where false +EXPLAIN SELECT * FROM inttbls WHERE colA >= 9223372036854775807; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where (`test`.`inttbls`.`colA` = 9223372036854775807) +EXPLAIN SELECT * FROM inttbls WHERE colA > -9223372036854775809; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where true +EXPLAIN SELECT * FROM inttbls WHERE colA <= -9223372036854775809; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where false +EXPLAIN SELECT * FROM inttbls WHERE colA <= -9223372036854775808; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where (`test`.`inttbls`.`colA` = -9223372036854775808) +EXPLAIN SELECT * FROM inttbls WHERE colA >= -9223372036854775808; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where true +EXPLAIN SELECT * FROM inttbls WHERE colA > -9223372036854775808; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 33.33 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where (`test`.`inttbls`.`colA` > -9223372036854775808) +EXPLAIN SELECT * FROM inttbls WHERE colA = 9223372036854775808; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where false +EXPLAIN SELECT * FROM inttbls WHERE colA <=> 9223372036854775808; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where false +EXPLAIN SELECT * FROM inttbls WHERE colA <> 9223372036854775808; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where true +EXPLAIN SELECT * FROM inttbls WHERE colA = 9223372036854775807; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where (`test`.`inttbls`.`colA` = 9223372036854775807) +EXPLAIN SELECT * FROM inttbls WHERE colA <=> 9223372036854775807; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where (`test`.`inttbls`.`colA` <=> 9223372036854775807) +EXPLAIN SELECT * FROM inttbls WHERE colA <> 9223372036854775807; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where (`test`.`inttbls`.`colA` <> 9223372036854775807) +EXPLAIN SELECT * FROM inttbls WHERE colA = -9223372036854775808; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where (`test`.`inttbls`.`colA` = -9223372036854775808) +EXPLAIN SELECT * FROM inttbls WHERE colA <=> -9223372036854775808; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where (`test`.`inttbls`.`colA` <=> -9223372036854775808) +EXPLAIN SELECT * FROM inttbls WHERE colA <> -9223372036854775808; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where (`test`.`inttbls`.`colA` <> -9223372036854775808) +EXPLAIN SELECT * FROM inttbls WHERE colA = -9223372036854775809; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where false +EXPLAIN SELECT * FROM inttbls WHERE colA <=> -9223372036854775809; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where false +EXPLAIN SELECT * FROM inttbls WHERE colA <> -9223372036854775809; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where true +same queries but constant first +SELECT * FROM inttbls WHERE 9223372036854775808 > colA; +colA +-9223372036854775808 +-9223372036854775807 +0 +1 +3 +9223372036854775806 +9223372036854775807 +0 +SELECT * FROM inttbls WHERE 9223372036854775807 >= colA; +colA +-9223372036854775808 +-9223372036854775807 +0 +1 +3 +9223372036854775806 +9223372036854775807 +0 +SELECT * FROM inttbls WHERE 9223372036854775808 < colA; +colA +SELECT * FROM inttbls WHERE 9223372036854775807 <= colA; +colA +9223372036854775807 +SELECT * FROM inttbls WHERE 9223372036854775807 < colA; +colA +SELECT * FROM inttbls WHERE -9223372036854775809 < colA; +colA +-9223372036854775808 +-9223372036854775807 +0 +1 +3 +9223372036854775806 +9223372036854775807 +0 +SELECT * FROM inttbls WHERE -9223372036854775809 >= colA; +colA +SELECT * FROM inttbls WHERE -9223372036854775808 >= colA; +colA +-9223372036854775808 +SELECT * FROM inttbls WHERE -9223372036854775808 <= colA; +colA +-9223372036854775808 +-9223372036854775807 +0 +1 +3 +9223372036854775806 +9223372036854775807 +0 +SELECT * FROM inttbls WHERE -9223372036854775808 < colA; +colA +-9223372036854775807 +0 +1 +3 +9223372036854775806 +9223372036854775807 +0 +SELECT * FROM inttbls WHERE 9223372036854775808 = colA; +colA +SELECT * FROM inttbls WHERE 9223372036854775808 <=> colA; +colA +SELECT * FROM inttbls WHERE 9223372036854775808 <> colA; +colA +-9223372036854775808 +-9223372036854775807 +0 +1 +3 +9223372036854775806 +9223372036854775807 +0 +SELECT * FROM inttbls WHERE 9223372036854775807 = colA; +colA +9223372036854775807 +SELECT * FROM inttbls WHERE 9223372036854775807 <=> colA; +colA +9223372036854775807 +SELECT * FROM inttbls WHERE 9223372036854775807 <> colA; +colA +-9223372036854775808 +-9223372036854775807 +0 +1 +3 +9223372036854775806 +0 +SELECT * FROM inttbls WHERE -9223372036854775808 = colA; +colA +-9223372036854775808 +SELECT * FROM inttbls WHERE -9223372036854775808 <=> colA; +colA +-9223372036854775808 +SELECT * FROM inttbls WHERE -9223372036854775808 <> colA; +colA +-9223372036854775807 +0 +1 +3 +9223372036854775806 +9223372036854775807 +0 +SELECT * FROM inttbls WHERE -9223372036854775809 = colA; +colA +SELECT * FROM inttbls WHERE -9223372036854775809 <=> colA; +colA +SELECT * FROM inttbls WHERE -9223372036854775809 <> colA; +colA +-9223372036854775808 +-9223372036854775807 +0 +1 +3 +9223372036854775806 +9223372036854775807 +0 +PREPARE p_less FROM 'SELECT * FROM inttbls WHERE ? < colA'; +PREPARE p_less_eq FROM 'SELECT * FROM inttbls WHERE ? <= colA'; +PREPARE p_greater FROM 'SELECT * FROM inttbls WHERE ? > colA'; +PREPARE p_gret_eq FROM 'SELECT * FROM inttbls WHERE ? >= colA'; +PREPARE p_eq FROM 'SELECT * FROM inttbls WHERE ? = colA'; +PREPARE p_equal FROM 'SELECT * FROM inttbls WHERE ? <=> colA'; +PREPARE p_n_eq FROM 'SELECT * FROM inttbls WHERE ? <> colA'; +PREPARE p_n_equal FROM 'SELECT * FROM inttbls WHERE NOT(? <=> colA)'; +EXECUTE p_greater USING @maxint_plus_1; +colA +-9223372036854775808 +-9223372036854775807 +0 +1 +3 +9223372036854775806 +9223372036854775807 +0 +EXECUTE p_gret_eq USING @maxint; +colA +-9223372036854775808 +-9223372036854775807 +0 +1 +3 +9223372036854775806 +9223372036854775807 +0 +EXECUTE p_less USING @maxint_plus_1; +colA +EXECUTE p_less_eq USING @maxint; +colA +9223372036854775807 +EXECUTE p_less USING @minint_minus_1; +colA +-9223372036854775808 +-9223372036854775807 +0 +1 +3 +9223372036854775806 +9223372036854775807 +0 +EXECUTE p_gret_eq USING @minint_minus_1; +colA +EXECUTE p_gret_eq USING @minint; +colA +-9223372036854775808 +EXECUTE p_less_eq USING @minint; +colA +-9223372036854775808 +-9223372036854775807 +0 +1 +3 +9223372036854775806 +9223372036854775807 +0 +EXECUTE p_less USING @minint; +colA +-9223372036854775807 +0 +1 +3 +9223372036854775806 +9223372036854775807 +0 +EXECUTE p_eq USING @maxint_plus_1; +colA +EXECUTE p_equal USING @maxint_plus_1; +colA +EXECUTE p_n_eq USING @maxint_plus_1; +colA +-9223372036854775808 +-9223372036854775807 +0 +1 +3 +9223372036854775806 +9223372036854775807 +0 +EXECUTE p_n_equal USING @maxint_plus_1; +colA +-9223372036854775808 +-9223372036854775807 +0 +1 +3 +9223372036854775806 +9223372036854775807 +0 +EXECUTE p_eq USING @maxint; +colA +9223372036854775807 +EXECUTE p_equal USING @maxint; +colA +9223372036854775807 +EXECUTE p_n_eq USING @maxint; +colA +-9223372036854775808 +-9223372036854775807 +0 +1 +3 +9223372036854775806 +0 +EXECUTE p_n_equal USING @maxint; +colA +-9223372036854775808 +-9223372036854775807 +0 +1 +3 +9223372036854775806 +0 +EXECUTE p_eq USING @minint; +colA +-9223372036854775808 +EXECUTE p_equal USING @minint; +colA +-9223372036854775808 +EXECUTE p_n_eq USING @minint; +colA +-9223372036854775807 +0 +1 +3 +9223372036854775806 +9223372036854775807 +0 +EXECUTE p_n_equal USING @minint; +colA +-9223372036854775807 +0 +1 +3 +9223372036854775806 +9223372036854775807 +0 +EXECUTE p_eq USING @minint_minus_1; +colA +EXECUTE p_equal USING @minint_minus_1; +colA +EXECUTE p_n_eq USING @minint_minus_1; +colA +-9223372036854775808 +-9223372036854775807 +0 +1 +3 +9223372036854775806 +9223372036854775807 +0 +EXECUTE p_n_equal USING @minint_minus_1; +colA +-9223372036854775808 +-9223372036854775807 +0 +1 +3 +9223372036854775806 +9223372036854775807 +0 +DROP PREPARE p_less; +DROP PREPARE p_less_eq; +DROP PREPARE p_greater; +DROP PREPARE p_gret_eq; +DROP PREPARE p_equal; +DROP PREPARE p_n_eq; +DROP PREPARE p_n_equal; +EXPLAIN SELECT * FROM inttbls WHERE 9223372036854775808 > colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where true +EXPLAIN SELECT * FROM inttbls WHERE 9223372036854775807 >= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where true +EXPLAIN SELECT * FROM inttbls WHERE 9223372036854775808 < colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where false +EXPLAIN SELECT * FROM inttbls WHERE 9223372036854775807 <= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where (9223372036854775807 = `test`.`inttbls`.`colA`) +EXPLAIN SELECT * FROM inttbls WHERE 9223372036854775807 < colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where false +EXPLAIN SELECT * FROM inttbls WHERE -9223372036854775809 < colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where true +EXPLAIN SELECT * FROM inttbls WHERE -9223372036854775809 >= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where false +EXPLAIN SELECT * FROM inttbls WHERE -9223372036854775808 >= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where (-9223372036854775808 = `test`.`inttbls`.`colA`) +EXPLAIN SELECT * FROM inttbls WHERE -9223372036854775808 <= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where true +EXPLAIN SELECT * FROM inttbls WHERE -9223372036854775808 < colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 33.33 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where (-9223372036854775808 < `test`.`inttbls`.`colA`) +EXPLAIN SELECT * FROM inttbls WHERE 9223372036854775808 = colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where false +EXPLAIN SELECT * FROM inttbls WHERE 9223372036854775808 <=> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where false +EXPLAIN SELECT * FROM inttbls WHERE 9223372036854775808 <> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where true +EXPLAIN SELECT * FROM inttbls WHERE 9223372036854775807 = colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where (`test`.`inttbls`.`colA` = 9223372036854775807) +EXPLAIN SELECT * FROM inttbls WHERE 9223372036854775807 <=> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where (9223372036854775807 <=> `test`.`inttbls`.`colA`) +EXPLAIN SELECT * FROM inttbls WHERE 9223372036854775807 <> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where (9223372036854775807 <> `test`.`inttbls`.`colA`) +EXPLAIN SELECT * FROM inttbls WHERE -9223372036854775808 = colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where (`test`.`inttbls`.`colA` = -9223372036854775808) +EXPLAIN SELECT * FROM inttbls WHERE -9223372036854775808 <=> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where (-9223372036854775808 <=> `test`.`inttbls`.`colA`) +EXPLAIN SELECT * FROM inttbls WHERE -9223372036854775808 <> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where (-9223372036854775808 <> `test`.`inttbls`.`colA`) +EXPLAIN SELECT * FROM inttbls WHERE -9223372036854775809 = colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where false +EXPLAIN SELECT * FROM inttbls WHERE -9223372036854775809 <=> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where false +EXPLAIN SELECT * FROM inttbls WHERE -9223372036854775809 <> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where true +DROP TABLE inttbls; +CREATE TABLE t(u TINYINT UNSIGNED); +INSERT INTO t VALUES (0), (3), (255), (NULL); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +SELECT * FROM t WHERE u=256 IS NOT NULL; +u +0 +3 +255 +SELECT * FROM t WHERE u=256 IS NULL; +u +NULL +SELECT * FROM t WHERE u=256 IS UNKNOWN; +u +NULL +SELECT * FROM t WHERE ABS(u=256)=0; +u +0 +3 +255 +SELECT * FROM t WHERE u=256; +u +EXPLAIN SELECT * FROM t WHERE u=256 IS NOT NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 4 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`u` AS `u` from `test`.`t` where ((`test`.`t`.`u` <> `test`.`t`.`u`) is not null) +EXPLAIN SELECT * FROM t WHERE u=256 IS NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 4 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`u` AS `u` from `test`.`t` where ((`test`.`t`.`u` <> `test`.`t`.`u`) is null) +EXPLAIN SELECT * FROM t WHERE u=256 IS UNKNOWN; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 4 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`u` AS `u` from `test`.`t` where ((`test`.`t`.`u` <> `test`.`t`.`u`) is null) +EXPLAIN SELECT * FROM t WHERE ABS(u=256)=0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 4 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`u` AS `u` from `test`.`t` where (abs((`test`.`t`.`u` <> `test`.`t`.`u`)) = 0) +EXPLAIN SELECT * FROM t WHERE u=256; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`u` AS `u` from `test`.`t` where false +drop table t; +CREATE TABLE t(u TINYINT UNSIGNED NOT NULL); +INSERT INTO t VALUES (0), (3), (255); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +SELECT * FROM t WHERE u=256 IS NOT NULL; +u +0 +3 +255 +SELECT * FROM t WHERE u=256 IS NULL; +u +SELECT * FROM t WHERE u=256 IS UNKNOWN; +u +SELECT * FROM t WHERE ABS(u=256)=0; +u +0 +3 +255 +SELECT * FROM t WHERE u=256; +u +EXPLAIN SELECT * FROM t WHERE u=256 IS NOT NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`u` AS `u` from `test`.`t` where true +EXPLAIN SELECT * FROM t WHERE u=256 IS NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`u` AS `u` from `test`.`t` where false +EXPLAIN SELECT * FROM t WHERE u=256 IS UNKNOWN; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`u` AS `u` from `test`.`t` where false +EXPLAIN SELECT * FROM t WHERE ABS(u=256)=0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`u` AS `u` from `test`.`t` where true +EXPLAIN SELECT * FROM t WHERE u=256; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`u` AS `u` from `test`.`t` where false +DROP TABLE t; + +Constant folding in 3 way join with impossible condition due to +the constant being out of range of one tables' field type. + +CREATE TABLE t1(i TINYINT); +CREATE TABLE t2(i INT); +CREATE TABLE t3(i INT); +INSERT INTO t1 VALUES (127); +INSERT INTO t2 VALUES (128); +INSERT INTO t3 VALUES (128); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +ANALYZE TABLE t2; +Table Op Msg_type Msg_text +test.t2 analyze status OK +ANALYZE TABLE t3; +Table Op Msg_type Msg_text +test.t3 analyze status OK + +EXPLAIN SELECT * FROM t1,t2,t3 WHERE t1.i=t2.i AND t1.i=t3.i AND t1.i=128; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i`,`test`.`t2`.`i` AS `i`,`test`.`t3`.`i` AS `i` from `test`.`t1` join `test`.`t2` join `test`.`t3` where false +EXPLAIN SELECT * FROM t1,t2,t3 WHERE t1.i=t2.i AND t1.i=t3.i AND t2.i=128; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i`,`test`.`t2`.`i` AS `i`,`test`.`t3`.`i` AS `i` from `test`.`t1` join `test`.`t2` join `test`.`t3` where false +EXPLAIN SELECT * FROM t1,t2,t3 WHERE t1.i=t2.i AND t1.i=t3.i AND t3.i=128; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i`,`test`.`t2`.`i` AS `i`,`test`.`t3`.`i` AS `i` from `test`.`t1` join `test`.`t2` join `test`.`t3` where false +EXPLAIN SELECT * FROM t1,t2,t3 WHERE t1.i=128 AND t1.i=t2.i AND t1.i=t3.i; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i`,`test`.`t2`.`i` AS `i`,`test`.`t3`.`i` AS `i` from `test`.`t1` join `test`.`t2` join `test`.`t3` where false +EXPLAIN SELECT * FROM t1,t2,t3 WHERE t2.i=128 AND t1.i=t2.i AND t1.i=t3.i; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i`,`test`.`t2`.`i` AS `i`,`test`.`t3`.`i` AS `i` from `test`.`t1` join `test`.`t2` join `test`.`t3` where false +EXPLAIN SELECT * FROM t1,t2,t3 WHERE t3.i=128 AND t1.i=t2.i AND t1.i=t3.i; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i`,`test`.`t2`.`i` AS `i`,`test`.`t3`.`i` AS `i` from `test`.`t1` join `test`.`t2` join `test`.`t3` where false + +EXPLAIN SELECT * FROM t1,t2,t3 WHERE t2.i=t1.i AND t1.i=t3.i AND t1.i=128; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i`,`test`.`t2`.`i` AS `i`,`test`.`t3`.`i` AS `i` from `test`.`t1` join `test`.`t2` join `test`.`t3` where false +EXPLAIN SELECT * FROM t1,t2,t3 WHERE t2.i=t1.i AND t1.i=t3.i AND t2.i=128; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i`,`test`.`t2`.`i` AS `i`,`test`.`t3`.`i` AS `i` from `test`.`t1` join `test`.`t2` join `test`.`t3` where false +EXPLAIN SELECT * FROM t1,t2,t3 WHERE t2.i=t1.i AND t1.i=t3.i AND t3.i=128; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i`,`test`.`t2`.`i` AS `i`,`test`.`t3`.`i` AS `i` from `test`.`t1` join `test`.`t2` join `test`.`t3` where false +EXPLAIN SELECT * FROM t1,t2,t3 WHERE t1.i=128 AND t2.i=t1.i AND t1.i=t3.i; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i`,`test`.`t2`.`i` AS `i`,`test`.`t3`.`i` AS `i` from `test`.`t1` join `test`.`t2` join `test`.`t3` where false +EXPLAIN SELECT * FROM t1,t2,t3 WHERE t2.i=128 AND t2.i=t1.i AND t1.i=t3.i; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i`,`test`.`t2`.`i` AS `i`,`test`.`t3`.`i` AS `i` from `test`.`t1` join `test`.`t2` join `test`.`t3` where false +EXPLAIN SELECT * FROM t1,t2,t3 WHERE t3.i=128 AND t2.i=t1.i AND t1.i=t3.i; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i`,`test`.`t2`.`i` AS `i`,`test`.`t3`.`i` AS `i` from `test`.`t1` join `test`.`t2` join `test`.`t3` where false + +EXPLAIN SELECT * FROM t1,t2,t3 WHERE t1.i=t2.i AND t3.i=t1.i AND t1.i=128; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i`,`test`.`t2`.`i` AS `i`,`test`.`t3`.`i` AS `i` from `test`.`t1` join `test`.`t2` join `test`.`t3` where false +EXPLAIN SELECT * FROM t1,t2,t3 WHERE t1.i=t2.i AND t3.i=t1.i AND t2.i=128; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i`,`test`.`t2`.`i` AS `i`,`test`.`t3`.`i` AS `i` from `test`.`t1` join `test`.`t2` join `test`.`t3` where false +EXPLAIN SELECT * FROM t1,t2,t3 WHERE t1.i=t2.i AND t3.i=t1.i AND t3.i=128; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i`,`test`.`t2`.`i` AS `i`,`test`.`t3`.`i` AS `i` from `test`.`t1` join `test`.`t2` join `test`.`t3` where false +EXPLAIN SELECT * FROM t1,t2,t3 WHERE t1.i=128 AND t1.i=t2.i AND t3.i=t1.i; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i`,`test`.`t2`.`i` AS `i`,`test`.`t3`.`i` AS `i` from `test`.`t1` join `test`.`t2` join `test`.`t3` where false +EXPLAIN SELECT * FROM t1,t2,t3 WHERE t2.i=128 AND t1.i=t2.i AND t3.i=t1.i; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i`,`test`.`t2`.`i` AS `i`,`test`.`t3`.`i` AS `i` from `test`.`t1` join `test`.`t2` join `test`.`t3` where false +EXPLAIN SELECT * FROM t1,t2,t3 WHERE t3.i=128 AND t1.i=t2.i AND t3.i=t1.i; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i`,`test`.`t2`.`i` AS `i`,`test`.`t3`.`i` AS `i` from `test`.`t1` join `test`.`t2` join `test`.`t3` where false + +EXPLAIN SELECT * FROM t1,t2,t3 WHERE t2.i=t1.i AND t3.i=t1.i AND t1.i=128; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i`,`test`.`t2`.`i` AS `i`,`test`.`t3`.`i` AS `i` from `test`.`t1` join `test`.`t2` join `test`.`t3` where false +EXPLAIN SELECT * FROM t1,t2,t3 WHERE t2.i=t1.i AND t3.i=t1.i AND t2.i=128; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i`,`test`.`t2`.`i` AS `i`,`test`.`t3`.`i` AS `i` from `test`.`t1` join `test`.`t2` join `test`.`t3` where false +EXPLAIN SELECT * FROM t1,t2,t3 WHERE t2.i=t1.i AND t3.i=t1.i AND t3.i=128; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i`,`test`.`t2`.`i` AS `i`,`test`.`t3`.`i` AS `i` from `test`.`t1` join `test`.`t2` join `test`.`t3` where false +EXPLAIN SELECT * FROM t1,t2,t3 WHERE t1.i=128 AND t2.i=t1.i AND t3.i=t1.i; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i`,`test`.`t2`.`i` AS `i`,`test`.`t3`.`i` AS `i` from `test`.`t1` join `test`.`t2` join `test`.`t3` where false +EXPLAIN SELECT * FROM t1,t2,t3 WHERE t2.i=128 AND t2.i=t1.i AND t3.i=t1.i; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i`,`test`.`t2`.`i` AS `i`,`test`.`t3`.`i` AS `i` from `test`.`t1` join `test`.`t2` join `test`.`t3` where false +EXPLAIN SELECT * FROM t1,t2,t3 WHERE t3.i=128 AND t2.i=t1.i AND t3.i=t1.i; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i`,`test`.`t2`.`i` AS `i`,`test`.`t3`.`i` AS `i` from `test`.`t1` join `test`.`t2` join `test`.`t3` where false + +EXPLAIN SELECT * FROM t1,t2,t3 WHERE t1.i=t3.i AND t2.i=t3.i AND t1.i=128; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i`,`test`.`t2`.`i` AS `i`,`test`.`t3`.`i` AS `i` from `test`.`t1` join `test`.`t2` join `test`.`t3` where false +EXPLAIN SELECT * FROM t1,t2,t3 WHERE t1.i=t3.i AND t2.i=t3.i AND t2.i=128; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i`,`test`.`t2`.`i` AS `i`,`test`.`t3`.`i` AS `i` from `test`.`t1` join `test`.`t2` join `test`.`t3` where false +EXPLAIN SELECT * FROM t1,t2,t3 WHERE t1.i=t3.i AND t2.i=t3.i AND t3.i=128; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i`,`test`.`t2`.`i` AS `i`,`test`.`t3`.`i` AS `i` from `test`.`t1` join `test`.`t2` join `test`.`t3` where false +EXPLAIN SELECT * FROM t1,t2,t3 WHERE t1.i=128 AND t1.i=t3.i AND t2.i=t3.i; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i`,`test`.`t2`.`i` AS `i`,`test`.`t3`.`i` AS `i` from `test`.`t1` join `test`.`t2` join `test`.`t3` where false +EXPLAIN SELECT * FROM t1,t2,t3 WHERE t2.i=128 AND t1.i=t3.i AND t2.i=t3.i; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i`,`test`.`t2`.`i` AS `i`,`test`.`t3`.`i` AS `i` from `test`.`t1` join `test`.`t2` join `test`.`t3` where false +EXPLAIN SELECT * FROM t1,t2,t3 WHERE t3.i=128 AND t1.i=t3.i AND t2.i=t3.i; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i`,`test`.`t2`.`i` AS `i`,`test`.`t3`.`i` AS `i` from `test`.`t1` join `test`.`t2` join `test`.`t3` where false + +EXPLAIN SELECT * FROM t1,t2,t3 WHERE t1.i=t3.i AND t3.i=t2.i AND t1.i=128; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i`,`test`.`t2`.`i` AS `i`,`test`.`t3`.`i` AS `i` from `test`.`t1` join `test`.`t2` join `test`.`t3` where false +EXPLAIN SELECT * FROM t1,t2,t3 WHERE t1.i=t3.i AND t3.i=t2.i AND t2.i=128; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i`,`test`.`t2`.`i` AS `i`,`test`.`t3`.`i` AS `i` from `test`.`t1` join `test`.`t2` join `test`.`t3` where false +EXPLAIN SELECT * FROM t1,t2,t3 WHERE t1.i=t3.i AND t3.i=t2.i AND t3.i=128; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i`,`test`.`t2`.`i` AS `i`,`test`.`t3`.`i` AS `i` from `test`.`t1` join `test`.`t2` join `test`.`t3` where false +EXPLAIN SELECT * FROM t1,t2,t3 WHERE t1.i=128 AND t1.i=t3.i AND t3.i=t2.i; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i`,`test`.`t2`.`i` AS `i`,`test`.`t3`.`i` AS `i` from `test`.`t1` join `test`.`t2` join `test`.`t3` where false +EXPLAIN SELECT * FROM t1,t2,t3 WHERE t2.i=128 AND t1.i=t3.i AND t3.i=t2.i; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i`,`test`.`t2`.`i` AS `i`,`test`.`t3`.`i` AS `i` from `test`.`t1` join `test`.`t2` join `test`.`t3` where false +EXPLAIN SELECT * FROM t1,t2,t3 WHERE t3.i=128 AND t1.i=t3.i AND t3.i=t2.i; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i`,`test`.`t2`.`i` AS `i`,`test`.`t3`.`i` AS `i` from `test`.`t1` join `test`.`t2` join `test`.`t3` where false + +EXPLAIN SELECT * FROM t1,t2,t3 WHERE t3.i=t1.i AND t2.i=t3.i AND t1.i=128; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i`,`test`.`t2`.`i` AS `i`,`test`.`t3`.`i` AS `i` from `test`.`t1` join `test`.`t2` join `test`.`t3` where false +EXPLAIN SELECT * FROM t1,t2,t3 WHERE t3.i=t1.i AND t2.i=t3.i AND t2.i=128; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i`,`test`.`t2`.`i` AS `i`,`test`.`t3`.`i` AS `i` from `test`.`t1` join `test`.`t2` join `test`.`t3` where false +EXPLAIN SELECT * FROM t1,t2,t3 WHERE t3.i=t1.i AND t2.i=t3.i AND t3.i=128; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i`,`test`.`t2`.`i` AS `i`,`test`.`t3`.`i` AS `i` from `test`.`t1` join `test`.`t2` join `test`.`t3` where false +EXPLAIN SELECT * FROM t1,t2,t3 WHERE t1.i=128 AND t3.i=t1.i AND t2.i=t3.i; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i`,`test`.`t2`.`i` AS `i`,`test`.`t3`.`i` AS `i` from `test`.`t1` join `test`.`t2` join `test`.`t3` where false +EXPLAIN SELECT * FROM t1,t2,t3 WHERE t2.i=128 AND t3.i=t1.i AND t2.i=t3.i; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i`,`test`.`t2`.`i` AS `i`,`test`.`t3`.`i` AS `i` from `test`.`t1` join `test`.`t2` join `test`.`t3` where false +EXPLAIN SELECT * FROM t1,t2,t3 WHERE t3.i=128 AND t3.i=t1.i AND t2.i=t3.i; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i`,`test`.`t2`.`i` AS `i`,`test`.`t3`.`i` AS `i` from `test`.`t1` join `test`.`t2` join `test`.`t3` where false + +EXPLAIN SELECT * FROM t1,t2,t3 WHERE t3.i=t1.i AND t3.i=t2.i AND t1.i=128; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i`,`test`.`t2`.`i` AS `i`,`test`.`t3`.`i` AS `i` from `test`.`t1` join `test`.`t2` join `test`.`t3` where false +EXPLAIN SELECT * FROM t1,t2,t3 WHERE t3.i=t1.i AND t3.i=t2.i AND t2.i=128; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i`,`test`.`t2`.`i` AS `i`,`test`.`t3`.`i` AS `i` from `test`.`t1` join `test`.`t2` join `test`.`t3` where false +EXPLAIN SELECT * FROM t1,t2,t3 WHERE t3.i=t1.i AND t3.i=t2.i AND t3.i=128; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i`,`test`.`t2`.`i` AS `i`,`test`.`t3`.`i` AS `i` from `test`.`t1` join `test`.`t2` join `test`.`t3` where false +EXPLAIN SELECT * FROM t1,t2,t3 WHERE t1.i=128 AND t3.i=t1.i AND t3.i=t2.i; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i`,`test`.`t2`.`i` AS `i`,`test`.`t3`.`i` AS `i` from `test`.`t1` join `test`.`t2` join `test`.`t3` where false +EXPLAIN SELECT * FROM t1,t2,t3 WHERE t2.i=128 AND t3.i=t1.i AND t3.i=t2.i; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i`,`test`.`t2`.`i` AS `i`,`test`.`t3`.`i` AS `i` from `test`.`t1` join `test`.`t2` join `test`.`t3` where false +EXPLAIN SELECT * FROM t1,t2,t3 WHERE t3.i=128 AND t3.i=t1.i AND t3.i=t2.i; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i`,`test`.`t2`.`i` AS `i`,`test`.`t3`.`i` AS `i` from `test`.`t1` join `test`.`t2` join `test`.`t3` where false + +EXPLAIN SELECT * FROM t1,t2,t3 WHERE t1.i=t2.i AND t3.i=t2.i AND t1.i=128; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i`,`test`.`t2`.`i` AS `i`,`test`.`t3`.`i` AS `i` from `test`.`t1` join `test`.`t2` join `test`.`t3` where false +EXPLAIN SELECT * FROM t1,t2,t3 WHERE t1.i=t2.i AND t3.i=t2.i AND t2.i=128; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i`,`test`.`t2`.`i` AS `i`,`test`.`t3`.`i` AS `i` from `test`.`t1` join `test`.`t2` join `test`.`t3` where false +EXPLAIN SELECT * FROM t1,t2,t3 WHERE t1.i=t2.i AND t3.i=t2.i AND t3.i=128; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i`,`test`.`t2`.`i` AS `i`,`test`.`t3`.`i` AS `i` from `test`.`t1` join `test`.`t2` join `test`.`t3` where false +EXPLAIN SELECT * FROM t1,t2,t3 WHERE t1.i=128 AND t1.i=t2.i AND t3.i=t2.i; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i`,`test`.`t2`.`i` AS `i`,`test`.`t3`.`i` AS `i` from `test`.`t1` join `test`.`t2` join `test`.`t3` where false +EXPLAIN SELECT * FROM t1,t2,t3 WHERE t2.i=128 AND t1.i=t2.i AND t3.i=t2.i; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i`,`test`.`t2`.`i` AS `i`,`test`.`t3`.`i` AS `i` from `test`.`t1` join `test`.`t2` join `test`.`t3` where false +EXPLAIN SELECT * FROM t1,t2,t3 WHERE t3.i=128 AND t1.i=t2.i AND t3.i=t2.i; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i`,`test`.`t2`.`i` AS `i`,`test`.`t3`.`i` AS `i` from `test`.`t1` join `test`.`t2` join `test`.`t3` where false + +EXPLAIN SELECT * FROM t1,t2,t3 WHERE t2.i=t1.i AND t3.i=t2.i AND t1.i=128; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i`,`test`.`t2`.`i` AS `i`,`test`.`t3`.`i` AS `i` from `test`.`t1` join `test`.`t2` join `test`.`t3` where false +EXPLAIN SELECT * FROM t1,t2,t3 WHERE t2.i=t1.i AND t3.i=t2.i AND t2.i=128; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i`,`test`.`t2`.`i` AS `i`,`test`.`t3`.`i` AS `i` from `test`.`t1` join `test`.`t2` join `test`.`t3` where false +EXPLAIN SELECT * FROM t1,t2,t3 WHERE t2.i=t1.i AND t3.i=t2.i AND t3.i=128; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i`,`test`.`t2`.`i` AS `i`,`test`.`t3`.`i` AS `i` from `test`.`t1` join `test`.`t2` join `test`.`t3` where false +EXPLAIN SELECT * FROM t1,t2,t3 WHERE t1.i=128 AND t2.i=t1.i AND t3.i=t2.i; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i`,`test`.`t2`.`i` AS `i`,`test`.`t3`.`i` AS `i` from `test`.`t1` join `test`.`t2` join `test`.`t3` where false +EXPLAIN SELECT * FROM t1,t2,t3 WHERE t2.i=128 AND t2.i=t1.i AND t3.i=t2.i; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i`,`test`.`t2`.`i` AS `i`,`test`.`t3`.`i` AS `i` from `test`.`t1` join `test`.`t2` join `test`.`t3` where false +EXPLAIN SELECT * FROM t1,t2,t3 WHERE t3.i=128 AND t2.i=t1.i AND t3.i=t2.i; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i`,`test`.`t2`.`i` AS `i`,`test`.`t3`.`i` AS `i` from `test`.`t1` join `test`.`t2` join `test`.`t3` where false + +EXPLAIN SELECT * FROM t1,t2,t3 WHERE t2.i=t1.i AND t2.i=t3.i AND t1.i=128; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i`,`test`.`t2`.`i` AS `i`,`test`.`t3`.`i` AS `i` from `test`.`t1` join `test`.`t2` join `test`.`t3` where false +EXPLAIN SELECT * FROM t1,t2,t3 WHERE t2.i=t1.i AND t2.i=t3.i AND t2.i=128; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i`,`test`.`t2`.`i` AS `i`,`test`.`t3`.`i` AS `i` from `test`.`t1` join `test`.`t2` join `test`.`t3` where false +EXPLAIN SELECT * FROM t1,t2,t3 WHERE t2.i=t1.i AND t2.i=t3.i AND t3.i=128; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i`,`test`.`t2`.`i` AS `i`,`test`.`t3`.`i` AS `i` from `test`.`t1` join `test`.`t2` join `test`.`t3` where false +EXPLAIN SELECT * FROM t1,t2,t3 WHERE t1.i=128 AND t2.i=t1.i AND t2.i=t3.i; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i`,`test`.`t2`.`i` AS `i`,`test`.`t3`.`i` AS `i` from `test`.`t1` join `test`.`t2` join `test`.`t3` where false +EXPLAIN SELECT * FROM t1,t2,t3 WHERE t2.i=128 AND t2.i=t1.i AND t2.i=t3.i; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i`,`test`.`t2`.`i` AS `i`,`test`.`t3`.`i` AS `i` from `test`.`t1` join `test`.`t2` join `test`.`t3` where false +EXPLAIN SELECT * FROM t1,t2,t3 WHERE t3.i=128 AND t2.i=t1.i AND t2.i=t3.i; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i`,`test`.`t2`.`i` AS `i`,`test`.`t3`.`i` AS `i` from `test`.`t1` join `test`.`t2` join `test`.`t3` where false + +EXPLAIN SELECT * FROM t1,t2,t3 WHERE t1.i=t2.i AND t2.i=t3.i AND t1.i=128; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i`,`test`.`t2`.`i` AS `i`,`test`.`t3`.`i` AS `i` from `test`.`t1` join `test`.`t2` join `test`.`t3` where false +EXPLAIN SELECT * FROM t1,t2,t3 WHERE t1.i=t2.i AND t2.i=t3.i AND t2.i=128; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i`,`test`.`t2`.`i` AS `i`,`test`.`t3`.`i` AS `i` from `test`.`t1` join `test`.`t2` join `test`.`t3` where false +EXPLAIN SELECT * FROM t1,t2,t3 WHERE t1.i=t2.i AND t2.i=t3.i AND t3.i=128; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i`,`test`.`t2`.`i` AS `i`,`test`.`t3`.`i` AS `i` from `test`.`t1` join `test`.`t2` join `test`.`t3` where false +EXPLAIN SELECT * FROM t1,t2,t3 WHERE t1.i=128 AND t1.i=t2.i AND t2.i=t3.i; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i`,`test`.`t2`.`i` AS `i`,`test`.`t3`.`i` AS `i` from `test`.`t1` join `test`.`t2` join `test`.`t3` where false +EXPLAIN SELECT * FROM t1,t2,t3 WHERE t2.i=128 AND t1.i=t2.i AND t2.i=t3.i; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i`,`test`.`t2`.`i` AS `i`,`test`.`t3`.`i` AS `i` from `test`.`t1` join `test`.`t2` join `test`.`t3` where false +EXPLAIN SELECT * FROM t1,t2,t3 WHERE t3.i=128 AND t1.i=t2.i AND t2.i=t3.i; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i`,`test`.`t2`.`i` AS `i`,`test`.`t3`.`i` AS `i` from `test`.`t1` join `test`.`t2` join `test`.`t3` where false + +Constant folding in 3 way join with always true condition due to +the constant being out of range of one table's field type. + +EXPLAIN SELECT * FROM t1,t2,t3 WHERE t1.i=t2.i AND t1.i=t3.i; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i`,`test`.`t2`.`i` AS `i`,`test`.`t3`.`i` AS `i` from `test`.`t1` join `test`.`t2` join `test`.`t3` where ((`test`.`t1`.`i` = `test`.`t2`.`i`) and (`test`.`t1`.`i` = `test`.`t3`.`i`)) +EXPLAIN SELECT * FROM t1,t2,t3 WHERE t2.i=t1.i AND t2.i=t3.i AND t1.i <> 4294967296; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i`,`test`.`t2`.`i` AS `i`,`test`.`t3`.`i` AS `i` from `test`.`t1` join `test`.`t2` join `test`.`t3` where ((`test`.`t3`.`i` = `test`.`t2`.`i`) and (`test`.`t2`.`i` = `test`.`t1`.`i`) and (`test`.`t1`.`i` is not null)) +EXPLAIN SELECT * FROM t1,t2,t3 WHERE t2.i=t1.i AND t2.i=t3.i AND t2.i <> 4294967296; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i`,`test`.`t2`.`i` AS `i`,`test`.`t3`.`i` AS `i` from `test`.`t1` join `test`.`t2` join `test`.`t3` where ((`test`.`t3`.`i` = `test`.`t2`.`i`) and (`test`.`t2`.`i` = `test`.`t1`.`i`) and (`test`.`t2`.`i` is not null)) +EXPLAIN SELECT * FROM t1,t2,t3 WHERE t2.i=t1.i AND t2.i=t3.i AND t3.i <> 4294967296; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i`,`test`.`t2`.`i` AS `i`,`test`.`t3`.`i` AS `i` from `test`.`t1` join `test`.`t2` join `test`.`t3` where ((`test`.`t3`.`i` = `test`.`t2`.`i`) and (`test`.`t2`.`i` = `test`.`t1`.`i`) and (`test`.`t2`.`i` is not null)) +DROP TABLES t1, t2, t3; +CREATE TABLE t(d DECIMAL (3,1) ); +INSERT INTO t VALUES (-10.5), (-10.4), (-10.3), (NULL), (10.3), (10.4), (10.5); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +SELECT d FROM t; +d +-10.5 +-10.4 +-10.3 +NULL +10.3 +10.4 +10.5 +II.a.1 field cmp constant +Out of range, positive constant +SELECT d FROM t WHERE d > 100; +d +EXPLAIN SELECT d FROM t WHERE d > 100; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where false +SELECT d FROM t WHERE d >= 100; +d +EXPLAIN SELECT d FROM t WHERE d >= 100; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where false +SELECT d FROM t WHERE d < 100; +d +-10.5 +-10.4 +-10.3 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE d < 100; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 85.71 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 85.71 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` is not null) +SELECT d FROM t WHERE d <= 100; +d +-10.5 +-10.4 +-10.3 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE d <= 100; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 85.71 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 85.71 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` is not null) +SELECT d FROM t WHERE d = 100; +d +EXPLAIN SELECT d FROM t WHERE d = 100; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where false +SELECT d FROM t WHERE d <> 100; +d +-10.5 +-10.4 +-10.3 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE d <> 100; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 85.71 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 85.71 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` is not null) +Out of range, negative constant +SELECT d FROM t WHERE d > -100; +d +-10.5 +-10.4 +-10.3 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE d > -100; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 85.71 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 85.71 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` is not null) +SELECT d FROM t WHERE d >= -100; +d +-10.5 +-10.4 +-10.3 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE d >= -100; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 85.71 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 85.71 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` is not null) +SELECT d FROM t WHERE d < -100; +d +EXPLAIN SELECT d FROM t WHERE d < -100; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where false +SELECT d FROM t WHERE d <= -100; +d +EXPLAIN SELECT d FROM t WHERE d <= -100; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where false +SELECT d FROM t WHERE d = -100; +d +EXPLAIN SELECT d FROM t WHERE d = -100; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where false +SELECT d FROM t WHERE d <> -100; +d +-10.5 +-10.4 +-10.3 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE d <> -100; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 85.71 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 85.71 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` is not null) +Positive constant +SELECT d FROM t WHERE d > 10; +d +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE d > 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` > 10.0) +SELECT d FROM t WHERE d >= 10; +d +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE d >= 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` >= 10.0) +SELECT d FROM t WHERE d < 10; +d +-10.5 +-10.4 +-10.3 +EXPLAIN SELECT d FROM t WHERE d < 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` < 10.0) +SELECT d FROM t WHERE d <= 10; +d +-10.5 +-10.4 +-10.3 +EXPLAIN SELECT d FROM t WHERE d <= 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` <= 10.0) +SELECT d FROM t WHERE d = 10; +d +EXPLAIN SELECT d FROM t WHERE d = 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 14.29 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 14.29 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` = 10.0) +SELECT d FROM t WHERE d <> 10; +d +-10.5 +-10.4 +-10.3 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE d <> 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 85.71 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 85.71 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` <> 10.0) +Negative constant +SELECT d FROM t WHERE d > -10; +d +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE d > -10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` > -10.0) +SELECT d FROM t WHERE d >= -10; +d +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE d >= -10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` >= -10.0) +SELECT d FROM t WHERE d < -10; +d +-10.5 +-10.4 +-10.3 +EXPLAIN SELECT d FROM t WHERE d < -10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` < -10.0) +SELECT d FROM t WHERE d <= -10; +d +-10.5 +-10.4 +-10.3 +EXPLAIN SELECT d FROM t WHERE d <= -10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` <= -10.0) +SELECT d FROM t WHERE d = -10; +d +EXPLAIN SELECT d FROM t WHERE d = -10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 14.29 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 14.29 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` = -10.0) +SELECT d FROM t WHERE d <> -10; +d +-10.5 +-10.4 +-10.3 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE d <> -10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 85.71 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 85.71 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` <> -10.0) +II.a.2 constant cmp field +Out of range, positive constant +SELECT d FROM t WHERE 100 < d; +d +EXPLAIN SELECT d FROM t WHERE 100 < d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where false +SELECT d FROM t WHERE 100 <= d; +d +EXPLAIN SELECT d FROM t WHERE 100 <= d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where false +SELECT d FROM t WHERE 100 > d; +d +-10.5 +-10.4 +-10.3 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE 100 > d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 85.71 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 85.71 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` is not null) +SELECT d FROM t WHERE 100 >= d; +d +-10.5 +-10.4 +-10.3 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE 100 >= d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 85.71 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 85.71 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` is not null) +SELECT d FROM t WHERE 100 = d; +d +EXPLAIN SELECT d FROM t WHERE 100 = d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where false +SELECT d FROM t WHERE 100 <> d; +d +-10.5 +-10.4 +-10.3 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE 100 <> d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 85.71 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 85.71 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` is not null) +Out of range, negative constant +SELECT d FROM t WHERE -100 < d; +d +-10.5 +-10.4 +-10.3 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE -100 < d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 85.71 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 85.71 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` is not null) +SELECT d FROM t WHERE -100 <= d; +d +-10.5 +-10.4 +-10.3 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE -100 <= d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 85.71 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 85.71 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` is not null) +SELECT d FROM t WHERE -100 > d; +d +EXPLAIN SELECT d FROM t WHERE -100 > d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where false +SELECT d FROM t WHERE -100 >= d; +d +EXPLAIN SELECT d FROM t WHERE -100 >= d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where false +SELECT d FROM t WHERE -100 = d; +d +EXPLAIN SELECT d FROM t WHERE -100 = d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where false +SELECT d FROM t WHERE -100 <> d; +d +-10.5 +-10.4 +-10.3 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE -100 <> d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 85.71 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 85.71 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` is not null) +Ints inside strings +SELECT d FROM t WHERE d > '10'; +d +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE d > '10'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` > 10.0) +SELECT d FROM t WHERE d > '100'; +d +EXPLAIN SELECT d FROM t WHERE d > '100'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where false +0x notation +SELECT d FROM t WHERE d > 0x100; +d +EXPLAIN SELECT d FROM t WHERE d > 0x100; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where false +DROP TABLE t; +CREATE TABLE t(d DECIMAL(65, 30) ); +INSERT INTO t VALUES (184467440737095516160000); +INSERT INTO t VALUES (18446744073709551.3); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +0x constant too large; gets truncated to 0xFFFFFFFFFFFFFFFF +i.e. 18446744073709551615. +SELECT * FROM t WHERE d <= 0x1FFFFFFFFFFFFFFFF; +d +18446744073709551.300000000000000000000000000000 +Warnings: +Warning 1292 Truncated incorrect BINARY value: 'x'01ffffffffffffffff'' +EXPLAIN SELECT * FROM t WHERE d <= 0x1FFFFFFFFFFFFFFFF; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 50.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Warning 1292 Truncated incorrect BINARY value: 'x'01ffffffffffffffff'' +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` <= 18446744073709551615.000000000000000000000000000000) +0x constant within bounds, expect to warnings +SELECT * FROM t WHERE d > 0x7FFFFFFFFFFFFFFF; +d +184467440737095516160000.000000000000000000000000000000 +EXPLAIN SELECT * FROM t WHERE d > 0x7FFFFFFFFFFFFFFF; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 50.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` > 9223372036854775807.000000000000000000000000000000) +0x constant within bounds, expect to warnings +SELECT * FROM t WHERE d > 0xFFFFFFFFFFFFFFFF; +d +184467440737095516160000.000000000000000000000000000000 +EXPLAIN SELECT * FROM t WHERE d > 0xFFFFFFFFFFFFFFFF; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 50.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` > 18446744073709551615.000000000000000000000000000000) +0x constant within bounds, expect to warnings +SELECT * FROM t WHERE d < 0x7FFFFFFFFFFFFFFF; +d +18446744073709551.300000000000000000000000000000 +EXPLAIN SELECT * FROM t WHERE d < 0x7FFFFFFFFFFFFFFF; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 50.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` < 9223372036854775807.000000000000000000000000000000) +0x constant within bounds, expect to warnings +SELECT * FROM t WHERE d < 0xFFFFFFFFFFFFFFFF; +d +18446744073709551.300000000000000000000000000000 +EXPLAIN SELECT * FROM t WHERE d < 0xFFFFFFFFFFFFFFFF; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 50.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` < 18446744073709551615.000000000000000000000000000000) +DROP TABLE t; +CREATE TABLE t(d DECIMAL (3,1) NOT NULL); +INSERT INTO t VALUES (-10.5), (-10.4), (-10.3), (0), (10.3), (10.4), (10.5); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +SELECT d FROM t; +d +-10.5 +-10.4 +-10.3 +0.0 +10.3 +10.4 +10.5 +II.a.1 field cmp constant +Out of range, positive constant +SELECT d FROM t WHERE d > 100; +d +EXPLAIN SELECT d FROM t WHERE d > 100; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where false +SELECT d FROM t WHERE d >= 100; +d +EXPLAIN SELECT d FROM t WHERE d >= 100; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where false +SELECT d FROM t WHERE d < 100; +d +-10.5 +-10.4 +-10.3 +0.0 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE d < 100; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where true +SELECT d FROM t WHERE d <= 100; +d +-10.5 +-10.4 +-10.3 +0.0 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE d <= 100; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where true +SELECT d FROM t WHERE d = 100; +d +EXPLAIN SELECT d FROM t WHERE d = 100; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where false +SELECT d FROM t WHERE d <> 100; +d +-10.5 +-10.4 +-10.3 +0.0 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE d <> 100; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where true +Out of range, negative constant +SELECT d FROM t WHERE d > -100; +d +-10.5 +-10.4 +-10.3 +0.0 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE d > -100; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where true +SELECT d FROM t WHERE d >= -100; +d +-10.5 +-10.4 +-10.3 +0.0 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE d >= -100; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where true +SELECT d FROM t WHERE d < -100; +d +EXPLAIN SELECT d FROM t WHERE d < -100; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where false +SELECT d FROM t WHERE d <= -100; +d +EXPLAIN SELECT d FROM t WHERE d <= -100; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where false +SELECT d FROM t WHERE d = -100; +d +EXPLAIN SELECT d FROM t WHERE d = -100; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where false +SELECT d FROM t WHERE d <> -100; +d +-10.5 +-10.4 +-10.3 +0.0 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE d <> -100; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where true +Positive constant +SELECT d FROM t WHERE d > 10; +d +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE d > 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` > 10.0) +SELECT d FROM t WHERE d >= 10; +d +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE d >= 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` >= 10.0) +SELECT d FROM t WHERE d < 10; +d +-10.5 +-10.4 +-10.3 +0.0 +EXPLAIN SELECT d FROM t WHERE d < 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` < 10.0) +SELECT d FROM t WHERE d <= 10; +d +-10.5 +-10.4 +-10.3 +0.0 +EXPLAIN SELECT d FROM t WHERE d <= 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` <= 10.0) +SELECT d FROM t WHERE d = 10; +d +EXPLAIN SELECT d FROM t WHERE d = 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 14.29 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 14.29 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` = 10.0) +SELECT d FROM t WHERE d <> 10; +d +-10.5 +-10.4 +-10.3 +0.0 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE d <> 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 85.71 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 85.71 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` <> 10.0) +Negative constant +SELECT d FROM t WHERE d > -10; +d +0.0 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE d > -10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` > -10.0) +SELECT d FROM t WHERE d >= -10; +d +0.0 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE d >= -10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` >= -10.0) +SELECT d FROM t WHERE d < -10; +d +-10.5 +-10.4 +-10.3 +EXPLAIN SELECT d FROM t WHERE d < -10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` < -10.0) +SELECT d FROM t WHERE d <= -10; +d +-10.5 +-10.4 +-10.3 +EXPLAIN SELECT d FROM t WHERE d <= -10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` <= -10.0) +SELECT d FROM t WHERE d = -10; +d +EXPLAIN SELECT d FROM t WHERE d = -10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 14.29 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 14.29 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` = -10.0) +SELECT d FROM t WHERE d <> -10; +d +-10.5 +-10.4 +-10.3 +0.0 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE d <> -10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 85.71 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 85.71 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` <> -10.0) +II.a.2 constant cmp field +Out of range, positive constant +SELECT d FROM t WHERE 100 < d; +d +EXPLAIN SELECT d FROM t WHERE 100 < d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where false +SELECT d FROM t WHERE 100 <= d; +d +EXPLAIN SELECT d FROM t WHERE 100 <= d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where false +SELECT d FROM t WHERE 100 > d; +d +-10.5 +-10.4 +-10.3 +0.0 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE 100 > d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where true +SELECT d FROM t WHERE 100 >= d; +d +-10.5 +-10.4 +-10.3 +0.0 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE 100 >= d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where true +SELECT d FROM t WHERE 100 = d; +d +EXPLAIN SELECT d FROM t WHERE 100 = d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where false +SELECT d FROM t WHERE 100 <> d; +d +-10.5 +-10.4 +-10.3 +0.0 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE 100 <> d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where true +Out of range, negative constant +SELECT d FROM t WHERE -100 < d; +d +-10.5 +-10.4 +-10.3 +0.0 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE -100 < d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where true +SELECT d FROM t WHERE -100 <= d; +d +-10.5 +-10.4 +-10.3 +0.0 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE -100 <= d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where true +SELECT d FROM t WHERE -100 > d; +d +EXPLAIN SELECT d FROM t WHERE -100 > d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where false +SELECT d FROM t WHERE -100 >= d; +d +EXPLAIN SELECT d FROM t WHERE -100 >= d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where false +SELECT d FROM t WHERE -100 = d; +d +EXPLAIN SELECT d FROM t WHERE -100 = d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where false +SELECT d FROM t WHERE -100 <> d; +d +-10.5 +-10.4 +-10.3 +0.0 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE -100 <> d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where true +Ints inside strings +SELECT d FROM t WHERE d > '10'; +d +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE d > '10'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` > 10.0) +SELECT d FROM t WHERE d > '100'; +d +EXPLAIN SELECT d FROM t WHERE d > '100'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where false +0x notation +SELECT d FROM t WHERE d > 0x100; +d +EXPLAIN SELECT d FROM t WHERE d > 0x100; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where false +DROP TABLE t; +CREATE TABLE t(d DECIMAL(65, 30) NOT NULL); +INSERT INTO t VALUES (184467440737095516160000); +INSERT INTO t VALUES (18446744073709551.3); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +0x constant too large; gets truncated to 0xFFFFFFFFFFFFFFFF +i.e. 18446744073709551615. +SELECT * FROM t WHERE d <= 0x1FFFFFFFFFFFFFFFF; +d +18446744073709551.300000000000000000000000000000 +Warnings: +Warning 1292 Truncated incorrect BINARY value: 'x'01ffffffffffffffff'' +EXPLAIN SELECT * FROM t WHERE d <= 0x1FFFFFFFFFFFFFFFF; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 50.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Warning 1292 Truncated incorrect BINARY value: 'x'01ffffffffffffffff'' +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` <= 18446744073709551615.000000000000000000000000000000) +0x constant within bounds, expect to warnings +SELECT * FROM t WHERE d > 0x7FFFFFFFFFFFFFFF; +d +184467440737095516160000.000000000000000000000000000000 +EXPLAIN SELECT * FROM t WHERE d > 0x7FFFFFFFFFFFFFFF; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 50.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` > 9223372036854775807.000000000000000000000000000000) +0x constant within bounds, expect to warnings +SELECT * FROM t WHERE d > 0xFFFFFFFFFFFFFFFF; +d +184467440737095516160000.000000000000000000000000000000 +EXPLAIN SELECT * FROM t WHERE d > 0xFFFFFFFFFFFFFFFF; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 50.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` > 18446744073709551615.000000000000000000000000000000) +0x constant within bounds, expect to warnings +SELECT * FROM t WHERE d < 0x7FFFFFFFFFFFFFFF; +d +18446744073709551.300000000000000000000000000000 +EXPLAIN SELECT * FROM t WHERE d < 0x7FFFFFFFFFFFFFFF; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 50.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` < 9223372036854775807.000000000000000000000000000000) +0x constant within bounds, expect to warnings +SELECT * FROM t WHERE d < 0xFFFFFFFFFFFFFFFF; +d +18446744073709551.300000000000000000000000000000 +EXPLAIN SELECT * FROM t WHERE d < 0xFFFFFFFFFFFFFFFF; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 50.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` < 18446744073709551615.000000000000000000000000000000) +DROP TABLE t; +CREATE TABLE t(d DECIMAL (3,1) ); +INSERT INTO t VALUES (-10.5), (-10.4), (-10.3), (NULL), (10.3), (10.4), (10.5); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +SELECT d FROM t; +d +-10.5 +-10.4 +-10.3 +NULL +10.3 +10.4 +10.5 +II.a.1 field cmp constant +Out of range, positive constant +SELECT d FROM t WHERE d > 100.0; +d +EXPLAIN SELECT d FROM t WHERE d > 100.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where false +SELECT d FROM t WHERE d >= 100.0; +d +EXPLAIN SELECT d FROM t WHERE d >= 100.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where false +SELECT d FROM t WHERE d < 100.0; +d +-10.5 +-10.4 +-10.3 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE d < 100.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 85.71 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 85.71 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` is not null) +SELECT d FROM t WHERE d <= 100.0; +d +-10.5 +-10.4 +-10.3 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE d <= 100.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 85.71 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 85.71 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` is not null) +SELECT d FROM t WHERE d = 100.0; +d +EXPLAIN SELECT d FROM t WHERE d = 100.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where false +SELECT d FROM t WHERE d <> 100.0; +d +-10.5 +-10.4 +-10.3 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE d <> 100.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 85.71 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 85.71 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` is not null) +Out of range, negative constant +SELECT d FROM t WHERE d > -100.0; +d +-10.5 +-10.4 +-10.3 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE d > -100.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 85.71 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 85.71 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` is not null) +SELECT d FROM t WHERE d >= -100.0; +d +-10.5 +-10.4 +-10.3 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE d >= -100.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 85.71 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 85.71 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` is not null) +SELECT d FROM t WHERE d < -100.0; +d +EXPLAIN SELECT d FROM t WHERE d < -100.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where false +SELECT d FROM t WHERE d <= -100.0; +d +EXPLAIN SELECT d FROM t WHERE d <= -100.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where false +SELECT d FROM t WHERE d = -100.0; +d +EXPLAIN SELECT d FROM t WHERE d = -100.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where false +SELECT d FROM t WHERE d <> -100.0; +d +-10.5 +-10.4 +-10.3 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE d <> -100.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 85.71 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 85.71 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` is not null) +Truncated positive constant +SELECT d FROM t WHERE d > 10.31; +d +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE d > 10.31; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` > 10.3) +SELECT d FROM t WHERE d >= 10.31; +d +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE d >= 10.31; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` > 10.3) +SELECT d FROM t WHERE d < 10.31; +d +-10.5 +-10.4 +-10.3 +10.3 +EXPLAIN SELECT d FROM t WHERE d < 10.31; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` <= 10.3) +SELECT d FROM t WHERE d <= 10.31; +d +-10.5 +-10.4 +-10.3 +10.3 +EXPLAIN SELECT d FROM t WHERE d <= 10.31; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` <= 10.3) +SELECT d FROM t WHERE d = 10.31; +d +EXPLAIN SELECT d FROM t WHERE d = 10.31; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where false +SELECT d FROM t WHERE d <> 10.31; +d +-10.5 +-10.4 +-10.3 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE d <> 10.31; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 85.71 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 85.71 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` is not null) +Truncated negative constant +SELECT d FROM t WHERE d > -10.31; +d +-10.3 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE d > -10.31; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` >= -10.3) +SELECT d FROM t WHERE d >= -10.31; +d +-10.3 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE d >= -10.31; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` >= -10.3) +SELECT d FROM t WHERE d < -10.31; +d +-10.5 +-10.4 +EXPLAIN SELECT d FROM t WHERE d < -10.31; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` < -10.3) +SELECT d FROM t WHERE d <= -10.31; +d +-10.5 +-10.4 +EXPLAIN SELECT d FROM t WHERE d <= -10.31; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` < -10.3) +SELECT d FROM t WHERE d = -10.31; +d +EXPLAIN SELECT d FROM t WHERE d = -10.31; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where false +SELECT d FROM t WHERE d <> -10.31; +d +-10.5 +-10.4 +-10.3 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE d <> -10.31; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 85.71 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 85.71 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` is not null) +II.a.2 constant cmp field +Out of range, positive constant +SELECT d FROM t WHERE 100.0 < d; +d +EXPLAIN SELECT d FROM t WHERE 100.0 < d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where false +SELECT d FROM t WHERE 100.0 <= d; +d +EXPLAIN SELECT d FROM t WHERE 100.0 <= d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where false +SELECT d FROM t WHERE 100.0 > d; +d +-10.5 +-10.4 +-10.3 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE 100.0 > d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 85.71 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 85.71 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` is not null) +SELECT d FROM t WHERE 100.0 >= d; +d +-10.5 +-10.4 +-10.3 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE 100.0 >= d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 85.71 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 85.71 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` is not null) +SELECT d FROM t WHERE 100.0 = d; +d +EXPLAIN SELECT d FROM t WHERE 100.0 = d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where false +SELECT d FROM t WHERE 100.0 <> d; +d +-10.5 +-10.4 +-10.3 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE 100.0 <> d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 85.71 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 85.71 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` is not null) +Out of range, negative constant +SELECT d FROM t WHERE -100.0 < d; +d +-10.5 +-10.4 +-10.3 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE -100.0 < d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 85.71 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 85.71 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` is not null) +SELECT d FROM t WHERE -100.0 <= d; +d +-10.5 +-10.4 +-10.3 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE -100.0 <= d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 85.71 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 85.71 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` is not null) +SELECT d FROM t WHERE -100.0 > d; +d +EXPLAIN SELECT d FROM t WHERE -100.0 > d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where false +SELECT d FROM t WHERE -100.0 >= d; +d +EXPLAIN SELECT d FROM t WHERE -100.0 >= d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where false +SELECT d FROM t WHERE -100.0 = d; +d +EXPLAIN SELECT d FROM t WHERE -100.0 = d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where false +SELECT d FROM t WHERE -100.0 <> d; +d +-10.5 +-10.4 +-10.3 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE -100.0 <> d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 85.71 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 85.71 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` is not null) +Truncated positive constant +SELECT d FROM t WHERE 10.31 < d; +d +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE 10.31 < d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (10.3 < `test`.`t`.`d`) +SELECT d FROM t WHERE 10.31 <= d; +d +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE 10.31 <= d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (10.3 < `test`.`t`.`d`) +SELECT d FROM t WHERE 10.31 > d; +d +-10.5 +-10.4 +-10.3 +10.3 +EXPLAIN SELECT d FROM t WHERE 10.31 > d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (10.3 >= `test`.`t`.`d`) +SELECT d FROM t WHERE 10.31 >= d; +d +-10.5 +-10.4 +-10.3 +10.3 +EXPLAIN SELECT d FROM t WHERE 10.31 >= d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (10.3 >= `test`.`t`.`d`) +SELECT d FROM t WHERE 10.31 = d; +d +EXPLAIN SELECT d FROM t WHERE 10.31 = d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where false +SELECT d FROM t WHERE 10.31 <> d; +d +-10.5 +-10.4 +-10.3 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE 10.31 <> d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 85.71 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 85.71 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` is not null) +Truncated negative constant +SELECT d FROM t WHERE -10.31 < d; +d +-10.3 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE -10.31 < d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (-10.3 <= `test`.`t`.`d`) +SELECT d FROM t WHERE -10.31 <= d; +d +-10.3 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE -10.31 <= d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (-10.3 <= `test`.`t`.`d`) +SELECT d FROM t WHERE -10.31 > d; +d +-10.5 +-10.4 +EXPLAIN SELECT d FROM t WHERE -10.31 > d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (-10.3 > `test`.`t`.`d`) +SELECT d FROM t WHERE -10.31 >= d; +d +-10.5 +-10.4 +EXPLAIN SELECT d FROM t WHERE -10.31 >= d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (-10.3 > `test`.`t`.`d`) +SELECT d FROM t WHERE -10.31 = d; +d +EXPLAIN SELECT d FROM t WHERE -10.31 = d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where false +SELECT d FROM t WHERE -10.31 <> d; +d +-10.5 +-10.4 +-10.3 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE -10.31 <> d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 85.71 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 85.71 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` is not null) +Check that leading and trailing zeros are handled +SELECT d FROM t WHERE d > 10.30; +d +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE d > 10.30; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` > 10.3) +SELECT d FROM t WHERE d > 010.3; +d +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE d > 010.3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` > 10.3) +Check decimals hidden inside strings +SELECT d FROM t WHERE d > '-10.31'; +d +-10.3 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE d > '-10.31'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` >= -10.3) +Cruft inside string, MySQL interprets as 0 with warning +SELECT d FROM t WHERE d > 'A'; +d +10.3 +10.4 +10.5 +Warnings: +Warning 1292 Truncated incorrect DECIMAL value: 'A' +EXPLAIN SELECT d FROM t WHERE d > 'A'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Warning 1292 Truncated incorrect DECIMAL value: 'A' +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` > 0.0) +DROP TABLE t; +Check that #digits in constant fraction is widenened as for fields +CREATE TABLE t(d DECIMAL(65,30)); +INSERT INTO t VALUES (10.34999), (10.350001); +SELECT * FROM t WHERE d > 10.35; +d +10.350001000000000000000000000000 +EXPLAIN SELECT * FROM t WHERE d > 10.35; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 50.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` > 10.350000000000000000000000000000) +DROP TABLE t; +CREATE TABLE t(d DECIMAL (3,1) NOT NULL); +INSERT INTO t VALUES (-10.5), (-10.4), (-10.3), (0), (10.3), (10.4), (10.5); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +SELECT d FROM t; +d +-10.5 +-10.4 +-10.3 +0.0 +10.3 +10.4 +10.5 +II.a.1 field cmp constant +Out of range, positive constant +SELECT d FROM t WHERE d > 100.0; +d +EXPLAIN SELECT d FROM t WHERE d > 100.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where false +SELECT d FROM t WHERE d >= 100.0; +d +EXPLAIN SELECT d FROM t WHERE d >= 100.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where false +SELECT d FROM t WHERE d < 100.0; +d +-10.5 +-10.4 +-10.3 +0.0 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE d < 100.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where true +SELECT d FROM t WHERE d <= 100.0; +d +-10.5 +-10.4 +-10.3 +0.0 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE d <= 100.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where true +SELECT d FROM t WHERE d = 100.0; +d +EXPLAIN SELECT d FROM t WHERE d = 100.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where false +SELECT d FROM t WHERE d <> 100.0; +d +-10.5 +-10.4 +-10.3 +0.0 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE d <> 100.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where true +Out of range, negative constant +SELECT d FROM t WHERE d > -100.0; +d +-10.5 +-10.4 +-10.3 +0.0 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE d > -100.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where true +SELECT d FROM t WHERE d >= -100.0; +d +-10.5 +-10.4 +-10.3 +0.0 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE d >= -100.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where true +SELECT d FROM t WHERE d < -100.0; +d +EXPLAIN SELECT d FROM t WHERE d < -100.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where false +SELECT d FROM t WHERE d <= -100.0; +d +EXPLAIN SELECT d FROM t WHERE d <= -100.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where false +SELECT d FROM t WHERE d = -100.0; +d +EXPLAIN SELECT d FROM t WHERE d = -100.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where false +SELECT d FROM t WHERE d <> -100.0; +d +-10.5 +-10.4 +-10.3 +0.0 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE d <> -100.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where true +Truncated positive constant +SELECT d FROM t WHERE d > 10.31; +d +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE d > 10.31; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` > 10.3) +SELECT d FROM t WHERE d >= 10.31; +d +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE d >= 10.31; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` > 10.3) +SELECT d FROM t WHERE d < 10.31; +d +-10.5 +-10.4 +-10.3 +0.0 +10.3 +EXPLAIN SELECT d FROM t WHERE d < 10.31; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` <= 10.3) +SELECT d FROM t WHERE d <= 10.31; +d +-10.5 +-10.4 +-10.3 +0.0 +10.3 +EXPLAIN SELECT d FROM t WHERE d <= 10.31; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` <= 10.3) +SELECT d FROM t WHERE d = 10.31; +d +EXPLAIN SELECT d FROM t WHERE d = 10.31; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where false +SELECT d FROM t WHERE d <> 10.31; +d +-10.5 +-10.4 +-10.3 +0.0 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE d <> 10.31; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where true +Truncated negative constant +SELECT d FROM t WHERE d > -10.31; +d +-10.3 +0.0 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE d > -10.31; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` >= -10.3) +SELECT d FROM t WHERE d >= -10.31; +d +-10.3 +0.0 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE d >= -10.31; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` >= -10.3) +SELECT d FROM t WHERE d < -10.31; +d +-10.5 +-10.4 +EXPLAIN SELECT d FROM t WHERE d < -10.31; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` < -10.3) +SELECT d FROM t WHERE d <= -10.31; +d +-10.5 +-10.4 +EXPLAIN SELECT d FROM t WHERE d <= -10.31; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` < -10.3) +SELECT d FROM t WHERE d = -10.31; +d +EXPLAIN SELECT d FROM t WHERE d = -10.31; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where false +SELECT d FROM t WHERE d <> -10.31; +d +-10.5 +-10.4 +-10.3 +0.0 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE d <> -10.31; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where true +II.a.2 constant cmp field +Out of range, positive constant +SELECT d FROM t WHERE 100.0 < d; +d +EXPLAIN SELECT d FROM t WHERE 100.0 < d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where false +SELECT d FROM t WHERE 100.0 <= d; +d +EXPLAIN SELECT d FROM t WHERE 100.0 <= d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where false +SELECT d FROM t WHERE 100.0 > d; +d +-10.5 +-10.4 +-10.3 +0.0 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE 100.0 > d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where true +SELECT d FROM t WHERE 100.0 >= d; +d +-10.5 +-10.4 +-10.3 +0.0 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE 100.0 >= d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where true +SELECT d FROM t WHERE 100.0 = d; +d +EXPLAIN SELECT d FROM t WHERE 100.0 = d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where false +SELECT d FROM t WHERE 100.0 <> d; +d +-10.5 +-10.4 +-10.3 +0.0 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE 100.0 <> d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where true +Out of range, negative constant +SELECT d FROM t WHERE -100.0 < d; +d +-10.5 +-10.4 +-10.3 +0.0 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE -100.0 < d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where true +SELECT d FROM t WHERE -100.0 <= d; +d +-10.5 +-10.4 +-10.3 +0.0 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE -100.0 <= d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where true +SELECT d FROM t WHERE -100.0 > d; +d +EXPLAIN SELECT d FROM t WHERE -100.0 > d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where false +SELECT d FROM t WHERE -100.0 >= d; +d +EXPLAIN SELECT d FROM t WHERE -100.0 >= d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where false +SELECT d FROM t WHERE -100.0 = d; +d +EXPLAIN SELECT d FROM t WHERE -100.0 = d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where false +SELECT d FROM t WHERE -100.0 <> d; +d +-10.5 +-10.4 +-10.3 +0.0 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE -100.0 <> d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where true +Truncated positive constant +SELECT d FROM t WHERE 10.31 < d; +d +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE 10.31 < d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (10.3 < `test`.`t`.`d`) +SELECT d FROM t WHERE 10.31 <= d; +d +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE 10.31 <= d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (10.3 < `test`.`t`.`d`) +SELECT d FROM t WHERE 10.31 > d; +d +-10.5 +-10.4 +-10.3 +0.0 +10.3 +EXPLAIN SELECT d FROM t WHERE 10.31 > d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (10.3 >= `test`.`t`.`d`) +SELECT d FROM t WHERE 10.31 >= d; +d +-10.5 +-10.4 +-10.3 +0.0 +10.3 +EXPLAIN SELECT d FROM t WHERE 10.31 >= d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (10.3 >= `test`.`t`.`d`) +SELECT d FROM t WHERE 10.31 = d; +d +EXPLAIN SELECT d FROM t WHERE 10.31 = d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where false +SELECT d FROM t WHERE 10.31 <> d; +d +-10.5 +-10.4 +-10.3 +0.0 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE 10.31 <> d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where true +Truncated negative constant +SELECT d FROM t WHERE -10.31 < d; +d +-10.3 +0.0 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE -10.31 < d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (-10.3 <= `test`.`t`.`d`) +SELECT d FROM t WHERE -10.31 <= d; +d +-10.3 +0.0 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE -10.31 <= d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (-10.3 <= `test`.`t`.`d`) +SELECT d FROM t WHERE -10.31 > d; +d +-10.5 +-10.4 +EXPLAIN SELECT d FROM t WHERE -10.31 > d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (-10.3 > `test`.`t`.`d`) +SELECT d FROM t WHERE -10.31 >= d; +d +-10.5 +-10.4 +EXPLAIN SELECT d FROM t WHERE -10.31 >= d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (-10.3 > `test`.`t`.`d`) +SELECT d FROM t WHERE -10.31 = d; +d +EXPLAIN SELECT d FROM t WHERE -10.31 = d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where false +SELECT d FROM t WHERE -10.31 <> d; +d +-10.5 +-10.4 +-10.3 +0.0 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE -10.31 <> d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where true +Check that leading and trailing zeros are handled +SELECT d FROM t WHERE d > 10.30; +d +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE d > 10.30; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` > 10.3) +SELECT d FROM t WHERE d > 010.3; +d +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE d > 010.3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` > 10.3) +Check decimals hidden inside strings +SELECT d FROM t WHERE d > '-10.31'; +d +-10.3 +0.0 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE d > '-10.31'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` >= -10.3) +Cruft inside string, MySQL interprets as 0 with warning +SELECT d FROM t WHERE d > 'A'; +d +10.3 +10.4 +10.5 +Warnings: +Warning 1292 Truncated incorrect DECIMAL value: 'A' +EXPLAIN SELECT d FROM t WHERE d > 'A'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Warning 1292 Truncated incorrect DECIMAL value: 'A' +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` > 0.0) +DROP TABLE t; +Check that #digits in constant fraction is widenened as for fields +CREATE TABLE t(d DECIMAL(65,30)); +INSERT INTO t VALUES (10.34999), (10.350001); +SELECT * FROM t WHERE d > 10.35; +d +10.350001000000000000000000000000 +EXPLAIN SELECT * FROM t WHERE d > 10.35; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 50.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` > 10.350000000000000000000000000000) +DROP TABLE t; +create table t(d decimal (3,1) ); +insert into t values (-10.5), (-10.4), (-10.3), (NULL), (10.3), (10.4), (10.5); +analyze table t; +Table Op Msg_type Msg_text +test.t analyze status OK +SELECT d FROM t; +d +-10.5 +-10.4 +-10.3 +NULL +10.3 +10.4 +10.5 +II.a.1 field cmp constant +Out of range, positive constant +SELECT d FROM t WHERE d > 100.0E00; +d +EXPLAIN SELECT d FROM t WHERE d > 100.0E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where false +SELECT d FROM t WHERE d >= 100.0E00; +d +EXPLAIN SELECT d FROM t WHERE d >= 100.0E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where false +SELECT d FROM t WHERE d < 100.0E00; +d +-10.5 +-10.4 +-10.3 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE d < 100.0E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 85.71 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 85.71 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` is not null) +SELECT d FROM t WHERE d <= 100.0E00; +d +-10.5 +-10.4 +-10.3 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE d <= 100.0E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 85.71 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 85.71 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` is not null) +SELECT d FROM t WHERE d = 100.0E00; +d +EXPLAIN SELECT d FROM t WHERE d = 100.0E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where false +SELECT d FROM t WHERE d <> 100.0E00; +d +-10.5 +-10.4 +-10.3 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE d <> 100.0E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 85.71 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 85.71 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` is not null) +Out of range, negative constant +SELECT d FROM t WHERE d > -100.0E00; +d +-10.5 +-10.4 +-10.3 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE d > -100.0E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 85.71 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 85.71 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` is not null) +SELECT d FROM t WHERE d >= -100.0E00; +d +-10.5 +-10.4 +-10.3 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE d >= -100.0E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 85.71 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 85.71 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` is not null) +SELECT d FROM t WHERE d < -100.0E00; +d +EXPLAIN SELECT d FROM t WHERE d < -100.0E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where false +SELECT d FROM t WHERE d <= -100.0E00; +d +EXPLAIN SELECT d FROM t WHERE d <= -100.0E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where false +SELECT d FROM t WHERE d = -100.0E00; +d +EXPLAIN SELECT d FROM t WHERE d = -100.0E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where false +SELECT d FROM t WHERE d <> -100.0E00; +d +-10.5 +-10.4 +-10.3 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE d <> -100.0E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 85.71 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 85.71 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` is not null) +Truncated positive constant +SELECT d FROM t WHERE d > 10.31E00; +d +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE d > 10.31E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` > 10.3) +SELECT d FROM t WHERE d >= 10.31E00; +d +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE d >= 10.31E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` > 10.3) +SELECT d FROM t WHERE d < 10.31E00; +d +-10.5 +-10.4 +-10.3 +10.3 +EXPLAIN SELECT d FROM t WHERE d < 10.31E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` <= 10.3) +SELECT d FROM t WHERE d <= 10.31E00; +d +-10.5 +-10.4 +-10.3 +10.3 +EXPLAIN SELECT d FROM t WHERE d <= 10.31E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` <= 10.3) +SELECT d FROM t WHERE d = 10.31E00; +d +EXPLAIN SELECT d FROM t WHERE d = 10.31E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where false +SELECT d FROM t WHERE d <> 10.31E00; +d +-10.5 +-10.4 +-10.3 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE d <> 10.31E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 85.71 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 85.71 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` is not null) +Truncated negative constant +SELECT d FROM t WHERE d > -10.31E00; +d +-10.3 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE d > -10.31E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` >= -10.3) +SELECT d FROM t WHERE d >= -10.31E00; +d +-10.3 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE d >= -10.31E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` >= -10.3) +SELECT d FROM t WHERE d < -10.31E00; +d +-10.5 +-10.4 +EXPLAIN SELECT d FROM t WHERE d < -10.31E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` < -10.3) +SELECT d FROM t WHERE d <= -10.31E00; +d +-10.5 +-10.4 +EXPLAIN SELECT d FROM t WHERE d <= -10.31E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` < -10.3) +SELECT d FROM t WHERE d = -10.31E00; +d +EXPLAIN SELECT d FROM t WHERE d = -10.31E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where false +SELECT d FROM t WHERE d <> -10.31E00; +d +-10.5 +-10.4 +-10.3 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE d <> -10.31E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 85.71 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 85.71 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` is not null) +II.a.2 constant cmp field +Out of range, positive constant +SELECT d FROM t WHERE 100.0E00 < d; +d +EXPLAIN SELECT d FROM t WHERE 100.0E00 < d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where false +SELECT d FROM t WHERE 100.0E00 <= d; +d +EXPLAIN SELECT d FROM t WHERE 100.0E00 <= d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where false +SELECT d FROM t WHERE 100.0E00 > d; +d +-10.5 +-10.4 +-10.3 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE 100.0E00 > d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 85.71 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 85.71 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` is not null) +SELECT d FROM t WHERE 100.0E00 >= d; +d +-10.5 +-10.4 +-10.3 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE 100.0E00 >= d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 85.71 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 85.71 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` is not null) +SELECT d FROM t WHERE 100.0E00 = d; +d +EXPLAIN SELECT d FROM t WHERE 100.0E00 = d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where false +SELECT d FROM t WHERE 100.0E00 <> d; +d +-10.5 +-10.4 +-10.3 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE 100.0E00 <> d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 85.71 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 85.71 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` is not null) +Out of range, negative constant +SELECT d FROM t WHERE -100.0E00 < d; +d +-10.5 +-10.4 +-10.3 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE -100.0E00 < d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 85.71 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 85.71 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` is not null) +SELECT d FROM t WHERE -100.0E00 <= d; +d +-10.5 +-10.4 +-10.3 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE -100.0E00 <= d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 85.71 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 85.71 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` is not null) +SELECT d FROM t WHERE -100.0E00 > d; +d +EXPLAIN SELECT d FROM t WHERE -100.0E00 > d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where false +SELECT d FROM t WHERE -100.0E00 >= d; +d +EXPLAIN SELECT d FROM t WHERE -100.0E00 >= d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where false +SELECT d FROM t WHERE -100.0E00 = d; +d +EXPLAIN SELECT d FROM t WHERE -100.0E00 = d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where false +SELECT d FROM t WHERE -100.0E00 <> d; +d +-10.5 +-10.4 +-10.3 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE -100.0E00 <> d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 85.71 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 85.71 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` is not null) +Truncated positive constant +SELECT d FROM t WHERE 10.31E00 < d; +d +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE 10.31E00 < d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (10.3 < `test`.`t`.`d`) +SELECT d FROM t WHERE 10.31E00 <= d; +d +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE 10.31E00 <= d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (10.3 < `test`.`t`.`d`) +SELECT d FROM t WHERE 10.31E00 > d; +d +-10.5 +-10.4 +-10.3 +10.3 +EXPLAIN SELECT d FROM t WHERE 10.31E00 > d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (10.3 >= `test`.`t`.`d`) +SELECT d FROM t WHERE 10.31E00 >= d; +d +-10.5 +-10.4 +-10.3 +10.3 +EXPLAIN SELECT d FROM t WHERE 10.31E00 >= d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (10.3 >= `test`.`t`.`d`) +SELECT d FROM t WHERE 10.31E00 = d; +d +EXPLAIN SELECT d FROM t WHERE 10.31E00 = d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where false +SELECT d FROM t WHERE 10.31E00 <> d; +d +-10.5 +-10.4 +-10.3 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE 10.31E00 <> d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 85.71 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 85.71 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` is not null) +Truncated negative constant +SELECT d FROM t WHERE -10.31E00 < d; +d +-10.3 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE -10.31E00 < d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (-10.3 <= `test`.`t`.`d`) +SELECT d FROM t WHERE -10.31E00 <= d; +d +-10.3 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE -10.31E00 <= d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (-10.3 <= `test`.`t`.`d`) +SELECT d FROM t WHERE -10.31E00 > d; +d +-10.5 +-10.4 +EXPLAIN SELECT d FROM t WHERE -10.31E00 > d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (-10.3 > `test`.`t`.`d`) +SELECT d FROM t WHERE -10.31E00 >= d; +d +-10.5 +-10.4 +EXPLAIN SELECT d FROM t WHERE -10.31E00 >= d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (-10.3 > `test`.`t`.`d`) +SELECT d FROM t WHERE -10.31E00 = d; +d +EXPLAIN SELECT d FROM t WHERE -10.31E00 = d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where false +SELECT d FROM t WHERE -10.31E00 <> d; +d +-10.5 +-10.4 +-10.3 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE -10.31E00 <> d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 85.71 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 85.71 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` is not null) +Check real underflow +SELECT d FROM t WHERE d > 1.0E-100; +d +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE d > 1.0E-100; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` > 0.0) +SELECT d FROM t WHERE d >= 1.0E-100; +d +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE d >= 1.0E-100; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` > 0.0) +SELECT d FROM t WHERE d < 1.0E-100; +d +-10.5 +-10.4 +-10.3 +EXPLAIN SELECT d FROM t WHERE d < 1.0E-100; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` <= 0.0) +SELECT d FROM t WHERE d <= 1.0E-100; +d +-10.5 +-10.4 +-10.3 +EXPLAIN SELECT d FROM t WHERE d <= 1.0E-100; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` <= 0.0) +SELECT d FROM t WHERE d = 1.0E-100; +d +EXPLAIN SELECT d FROM t WHERE d = 1.0E-100; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where false +SELECT d FROM t WHERE d <> 1.0E-100; +d +-10.5 +-10.4 +-10.3 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE d <> 1.0E-100; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 85.71 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 85.71 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` is not null) +SELECT d FROM t WHERE d > -1.0E-100; +d +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE d > -1.0E-100; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` >= 0.0) +SELECT d FROM t WHERE d >= -1.0E-100; +d +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE d >= -1.0E-100; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` >= 0.0) +SELECT d FROM t WHERE d < -1.0E-100; +d +-10.5 +-10.4 +-10.3 +EXPLAIN SELECT d FROM t WHERE d < -1.0E-100; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` < 0.0) +SELECT d FROM t WHERE d <= -1.0E-100; +d +-10.5 +-10.4 +-10.3 +EXPLAIN SELECT d FROM t WHERE d <= -1.0E-100; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` < 0.0) +SELECT d FROM t WHERE d = -1.0E-100; +d +EXPLAIN SELECT d FROM t WHERE d = -1.0E-100; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where false +SELECT d FROM t WHERE d <> -1.0E-100; +d +-10.5 +-10.4 +-10.3 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE d <> -1.0E-100; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 85.71 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 85.71 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` is not null) +Test that reals inside strings are handled ok +SELECT d FROM t WHERE d < '1.0E0'; +d +-10.5 +-10.4 +-10.3 +EXPLAIN SELECT d FROM t WHERE d < '1.0E0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` < 1.0) +DROP TABLE t; +Check that #digits in constant fraction is widenened as for fields +CREATE TABLE t(d DECIMAL(65,30)); +INSERT INTO t VALUES (10.34999), (10.350001); +SELECT * FROM t WHERE d > 0.1035E02; +d +10.350001000000000000000000000000 +EXPLAIN SELECT * FROM t WHERE d > 0.1035E02; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 50.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` > 10.350000000000000000000000000000) +DROP TABLE t; +create table t(d decimal (3,1) NOT NULL); +insert into t values (-10.5), (-10.4), (-10.3), (0), (10.3), (10.4), (10.5); +analyze table t; +Table Op Msg_type Msg_text +test.t analyze status OK +SELECT d FROM t; +d +-10.5 +-10.4 +-10.3 +0.0 +10.3 +10.4 +10.5 +II.a.1 field cmp constant +Out of range, positive constant +SELECT d FROM t WHERE d > 100.0E00; +d +EXPLAIN SELECT d FROM t WHERE d > 100.0E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where false +SELECT d FROM t WHERE d >= 100.0E00; +d +EXPLAIN SELECT d FROM t WHERE d >= 100.0E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where false +SELECT d FROM t WHERE d < 100.0E00; +d +-10.5 +-10.4 +-10.3 +0.0 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE d < 100.0E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where true +SELECT d FROM t WHERE d <= 100.0E00; +d +-10.5 +-10.4 +-10.3 +0.0 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE d <= 100.0E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where true +SELECT d FROM t WHERE d = 100.0E00; +d +EXPLAIN SELECT d FROM t WHERE d = 100.0E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where false +SELECT d FROM t WHERE d <> 100.0E00; +d +-10.5 +-10.4 +-10.3 +0.0 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE d <> 100.0E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where true +Out of range, negative constant +SELECT d FROM t WHERE d > -100.0E00; +d +-10.5 +-10.4 +-10.3 +0.0 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE d > -100.0E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where true +SELECT d FROM t WHERE d >= -100.0E00; +d +-10.5 +-10.4 +-10.3 +0.0 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE d >= -100.0E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where true +SELECT d FROM t WHERE d < -100.0E00; +d +EXPLAIN SELECT d FROM t WHERE d < -100.0E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where false +SELECT d FROM t WHERE d <= -100.0E00; +d +EXPLAIN SELECT d FROM t WHERE d <= -100.0E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where false +SELECT d FROM t WHERE d = -100.0E00; +d +EXPLAIN SELECT d FROM t WHERE d = -100.0E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where false +SELECT d FROM t WHERE d <> -100.0E00; +d +-10.5 +-10.4 +-10.3 +0.0 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE d <> -100.0E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where true +Truncated positive constant +SELECT d FROM t WHERE d > 10.31E00; +d +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE d > 10.31E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` > 10.3) +SELECT d FROM t WHERE d >= 10.31E00; +d +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE d >= 10.31E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` > 10.3) +SELECT d FROM t WHERE d < 10.31E00; +d +-10.5 +-10.4 +-10.3 +0.0 +10.3 +EXPLAIN SELECT d FROM t WHERE d < 10.31E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` <= 10.3) +SELECT d FROM t WHERE d <= 10.31E00; +d +-10.5 +-10.4 +-10.3 +0.0 +10.3 +EXPLAIN SELECT d FROM t WHERE d <= 10.31E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` <= 10.3) +SELECT d FROM t WHERE d = 10.31E00; +d +EXPLAIN SELECT d FROM t WHERE d = 10.31E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where false +SELECT d FROM t WHERE d <> 10.31E00; +d +-10.5 +-10.4 +-10.3 +0.0 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE d <> 10.31E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where true +Truncated negative constant +SELECT d FROM t WHERE d > -10.31E00; +d +-10.3 +0.0 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE d > -10.31E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` >= -10.3) +SELECT d FROM t WHERE d >= -10.31E00; +d +-10.3 +0.0 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE d >= -10.31E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` >= -10.3) +SELECT d FROM t WHERE d < -10.31E00; +d +-10.5 +-10.4 +EXPLAIN SELECT d FROM t WHERE d < -10.31E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` < -10.3) +SELECT d FROM t WHERE d <= -10.31E00; +d +-10.5 +-10.4 +EXPLAIN SELECT d FROM t WHERE d <= -10.31E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` < -10.3) +SELECT d FROM t WHERE d = -10.31E00; +d +EXPLAIN SELECT d FROM t WHERE d = -10.31E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where false +SELECT d FROM t WHERE d <> -10.31E00; +d +-10.5 +-10.4 +-10.3 +0.0 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE d <> -10.31E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where true +II.a.2 constant cmp field +Out of range, positive constant +SELECT d FROM t WHERE 100.0E00 < d; +d +EXPLAIN SELECT d FROM t WHERE 100.0E00 < d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where false +SELECT d FROM t WHERE 100.0E00 <= d; +d +EXPLAIN SELECT d FROM t WHERE 100.0E00 <= d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where false +SELECT d FROM t WHERE 100.0E00 > d; +d +-10.5 +-10.4 +-10.3 +0.0 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE 100.0E00 > d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where true +SELECT d FROM t WHERE 100.0E00 >= d; +d +-10.5 +-10.4 +-10.3 +0.0 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE 100.0E00 >= d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where true +SELECT d FROM t WHERE 100.0E00 = d; +d +EXPLAIN SELECT d FROM t WHERE 100.0E00 = d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where false +SELECT d FROM t WHERE 100.0E00 <> d; +d +-10.5 +-10.4 +-10.3 +0.0 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE 100.0E00 <> d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where true +Out of range, negative constant +SELECT d FROM t WHERE -100.0E00 < d; +d +-10.5 +-10.4 +-10.3 +0.0 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE -100.0E00 < d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where true +SELECT d FROM t WHERE -100.0E00 <= d; +d +-10.5 +-10.4 +-10.3 +0.0 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE -100.0E00 <= d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where true +SELECT d FROM t WHERE -100.0E00 > d; +d +EXPLAIN SELECT d FROM t WHERE -100.0E00 > d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where false +SELECT d FROM t WHERE -100.0E00 >= d; +d +EXPLAIN SELECT d FROM t WHERE -100.0E00 >= d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where false +SELECT d FROM t WHERE -100.0E00 = d; +d +EXPLAIN SELECT d FROM t WHERE -100.0E00 = d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where false +SELECT d FROM t WHERE -100.0E00 <> d; +d +-10.5 +-10.4 +-10.3 +0.0 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE -100.0E00 <> d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where true +Truncated positive constant +SELECT d FROM t WHERE 10.31E00 < d; +d +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE 10.31E00 < d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (10.3 < `test`.`t`.`d`) +SELECT d FROM t WHERE 10.31E00 <= d; +d +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE 10.31E00 <= d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (10.3 < `test`.`t`.`d`) +SELECT d FROM t WHERE 10.31E00 > d; +d +-10.5 +-10.4 +-10.3 +0.0 +10.3 +EXPLAIN SELECT d FROM t WHERE 10.31E00 > d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (10.3 >= `test`.`t`.`d`) +SELECT d FROM t WHERE 10.31E00 >= d; +d +-10.5 +-10.4 +-10.3 +0.0 +10.3 +EXPLAIN SELECT d FROM t WHERE 10.31E00 >= d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (10.3 >= `test`.`t`.`d`) +SELECT d FROM t WHERE 10.31E00 = d; +d +EXPLAIN SELECT d FROM t WHERE 10.31E00 = d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where false +SELECT d FROM t WHERE 10.31E00 <> d; +d +-10.5 +-10.4 +-10.3 +0.0 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE 10.31E00 <> d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where true +Truncated negative constant +SELECT d FROM t WHERE -10.31E00 < d; +d +-10.3 +0.0 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE -10.31E00 < d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (-10.3 <= `test`.`t`.`d`) +SELECT d FROM t WHERE -10.31E00 <= d; +d +-10.3 +0.0 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE -10.31E00 <= d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (-10.3 <= `test`.`t`.`d`) +SELECT d FROM t WHERE -10.31E00 > d; +d +-10.5 +-10.4 +EXPLAIN SELECT d FROM t WHERE -10.31E00 > d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (-10.3 > `test`.`t`.`d`) +SELECT d FROM t WHERE -10.31E00 >= d; +d +-10.5 +-10.4 +EXPLAIN SELECT d FROM t WHERE -10.31E00 >= d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (-10.3 > `test`.`t`.`d`) +SELECT d FROM t WHERE -10.31E00 = d; +d +EXPLAIN SELECT d FROM t WHERE -10.31E00 = d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where false +SELECT d FROM t WHERE -10.31E00 <> d; +d +-10.5 +-10.4 +-10.3 +0.0 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE -10.31E00 <> d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where true +Check real underflow +SELECT d FROM t WHERE d > 1.0E-100; +d +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE d > 1.0E-100; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` > 0.0) +SELECT d FROM t WHERE d >= 1.0E-100; +d +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE d >= 1.0E-100; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` > 0.0) +SELECT d FROM t WHERE d < 1.0E-100; +d +-10.5 +-10.4 +-10.3 +0.0 +EXPLAIN SELECT d FROM t WHERE d < 1.0E-100; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` <= 0.0) +SELECT d FROM t WHERE d <= 1.0E-100; +d +-10.5 +-10.4 +-10.3 +0.0 +EXPLAIN SELECT d FROM t WHERE d <= 1.0E-100; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` <= 0.0) +SELECT d FROM t WHERE d = 1.0E-100; +d +EXPLAIN SELECT d FROM t WHERE d = 1.0E-100; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where false +SELECT d FROM t WHERE d <> 1.0E-100; +d +-10.5 +-10.4 +-10.3 +0.0 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE d <> 1.0E-100; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where true +SELECT d FROM t WHERE d > -1.0E-100; +d +0.0 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE d > -1.0E-100; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` >= 0.0) +SELECT d FROM t WHERE d >= -1.0E-100; +d +0.0 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE d >= -1.0E-100; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` >= 0.0) +SELECT d FROM t WHERE d < -1.0E-100; +d +-10.5 +-10.4 +-10.3 +EXPLAIN SELECT d FROM t WHERE d < -1.0E-100; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` < 0.0) +SELECT d FROM t WHERE d <= -1.0E-100; +d +-10.5 +-10.4 +-10.3 +EXPLAIN SELECT d FROM t WHERE d <= -1.0E-100; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` < 0.0) +SELECT d FROM t WHERE d = -1.0E-100; +d +EXPLAIN SELECT d FROM t WHERE d = -1.0E-100; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where false +SELECT d FROM t WHERE d <> -1.0E-100; +d +-10.5 +-10.4 +-10.3 +0.0 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE d <> -1.0E-100; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where true +Test that reals inside strings are handled ok +SELECT d FROM t WHERE d < '1.0E0'; +d +-10.5 +-10.4 +-10.3 +0.0 +EXPLAIN SELECT d FROM t WHERE d < '1.0E0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` < 1.0) +DROP TABLE t; +Check that #digits in constant fraction is widenened as for fields +CREATE TABLE t(d DECIMAL(65,30)); +INSERT INTO t VALUES (10.34999), (10.350001); +SELECT * FROM t WHERE d > 0.1035E02; +d +10.350001000000000000000000000000 +EXPLAIN SELECT * FROM t WHERE d > 0.1035E02; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 50.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` > 10.350000000000000000000000000000) +DROP TABLE t; + +AD-158 Folding of IS NOT NULL if argument is not nullable. + +CREATE TABLE t(i INT NOT NULL); +EXPLAIN SELECT * FROM t WHERE i IS NOT NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`i` AS `i` from `test`.`t` where true +SELECT * FROM t WHERE i IS NOT NULL; +i +INSERT INTO t VALUES (3), (4); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +SELECT * FROM t WHERE i IS NOT NULL; +i +3 +4 +EXPLAIN SELECT * FROM t WHERE i IS NOT NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`i` AS `i` from `test`.`t` where true +EXPLAIN SELECT * FROM t WHERE ABS(i IS NOT NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`i` AS `i` from `test`.`t` where true +DROP TABLE t; + +Bug in nested condition: expression interior folding didn't +materialize a TRUE in the case of the field being not nullable. +Interior foldings should always materialize. + +CREATE TABLE t(i TINYINT NOT NULL); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +INSERT INTO t VALUES (10),(100),(1),(0); +EXPLAIN SELECT * FROM t WHERE i = (i < 255); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 25.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`i` AS `i` from `test`.`t` where (`test`.`t`.`i` = true) +SELECT * FROM t WHERE i = (i < 255); +i +1 +DROP TABLE t; +CREATE TABLE t(i TINYINT); +INSERT INTO t VALUES (10),(100),(1),(0),(NULL); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +EXPLAIN SELECT * FROM t WHERE i = (i < 255); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 20.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 5 20.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`i` AS `i` from `test`.`t` where (`test`.`t`.`i` = if((`test`.`t`.`i` is null),NULL,1)) +SELECT * FROM t WHERE i = (i < 255); +i +1 + +Bug#29179604 + +EXPLAIN SELECT * FROM t WHERE 1 = (i < 255); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 5 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`i` AS `i` from `test`.`t` where (1 = if((`test`.`t`.`i` is null),NULL,1)) +SELECT * FROM t WHERE 1 = (i < 255); +i +10 +100 +1 +0 +Used to give wrong result: NULL/UNKNOWN was lost in folding +EXPLAIN SELECT * FROM t WHERE 0 = (i < 255); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 5 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`i` AS `i` from `test`.`t` where (0 = if((`test`.`t`.`i` is null),NULL,1)) +SELECT * FROM t WHERE 0 = (i < 255); +i +DROP TABLE t; +CREATE TABLE t(d DECIMAL(65,0)); +EXPLAIN SELECT d FROM t WHERE d < 45.34e306; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` is not null) +EXPLAIN SELECT d FROM t WHERE d = 45.34e306; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where false +EXPLAIN SELECT d FROM t WHERE d != 45.34e306; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` is not null) +EXPLAIN SELECT d FROM t WHERE d > 45.34e306; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where false +EXPLAIN SELECT d FROM t WHERE d < -45.34e306; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where false +EXPLAIN SELECT d FROM t WHERE d = -45.34e306; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where false +EXPLAIN SELECT d FROM t WHERE d != -45.34e306; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` is not null) +EXPLAIN SELECT d FROM t WHERE d > -45.34e306; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` is not null) +EXPLAIN SELECT d FROM t WHERE d < 45.34e-306; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` <= 0) +EXPLAIN SELECT d FROM t WHERE d = 45.34e-306; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where false +EXPLAIN SELECT d FROM t WHERE d != 45.34e-306; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` is not null) +EXPLAIN SELECT d FROM t WHERE d > 45.34e-306; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` > 0) +EXPLAIN SELECT d FROM t WHERE d < -45.34e-306; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` < 0) +EXPLAIN SELECT d FROM t WHERE d = -45.34e-306; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where false +EXPLAIN SELECT d FROM t WHERE d != -45.34e-306; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` is not null) +EXPLAIN SELECT d FROM t WHERE d > -45.34e-306; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` >= 0) +DROP TABLE t; +# +# Tests with type FLOAT(5,2) against real constants +# +CREATE TABLE float_5_2_tbl (colA FLOAT(5,2) ); +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +INSERT INTO float_5_2_tbl VALUES (-999.99), (-999.985), +(-999.984), +( 3.3), (0.0), (3.3), +(999.985), +(999.984), (999.99), +(NULL); +ANALYZE TABLE float_5_2_tbl; +Table Op Msg_type Msg_text +test.float_5_2_tbl analyze status OK +SELECT * FROM float_5_2_tbl; +colA +-999.99 +-999.99 +-999.98 +3.30 +0.00 +3.30 +999.99 +999.98 +999.99 +NULL +SELECT * FROM float_5_2_tbl WHERE colA <= -999.99; +colA +-999.99 +-999.99 +SELECT * FROM float_5_2_tbl WHERE colA < -999.99; +colA +SELECT * FROM float_5_2_tbl WHERE colA >= -999.99; +colA +-999.99 +-999.99 +-999.98 +3.30 +0.00 +3.30 +999.99 +999.98 +999.99 +SELECT * FROM float_5_2_tbl WHERE colA > -999.99; +colA +-999.98 +3.30 +0.00 +3.30 +999.99 +999.98 +999.99 +SELECT * FROM float_5_2_tbl WHERE colA = -999.99; +colA +-999.99 +-999.99 +SELECT * FROM float_5_2_tbl WHERE colA <> -999.99; +colA +-999.98 +3.30 +0.00 +3.30 +999.99 +999.98 +999.99 +SELECT * FROM float_5_2_tbl WHERE colA <= -999.984; +colA +-999.99 +-999.99 +SELECT * FROM float_5_2_tbl WHERE colA < -999.984; +colA +-999.99 +-999.99 +SELECT * FROM float_5_2_tbl WHERE colA >= -999.984; +colA +-999.98 +3.30 +0.00 +3.30 +999.99 +999.98 +999.99 +SELECT * FROM float_5_2_tbl WHERE colA > -999.984; +colA +-999.98 +3.30 +0.00 +3.30 +999.99 +999.98 +999.99 +SELECT * FROM float_5_2_tbl WHERE colA = -999.984; +colA +SELECT * FROM float_5_2_tbl WHERE colA <> -999.984; +colA +-999.99 +-999.99 +-999.98 +3.30 +0.00 +3.30 +999.99 +999.98 +999.99 +SELECT * FROM float_5_2_tbl WHERE colA <= -999.985; +colA +-999.99 +-999.99 +SELECT * FROM float_5_2_tbl WHERE colA < -999.985; +colA +-999.99 +-999.99 +SELECT * FROM float_5_2_tbl WHERE colA >= -999.985; +colA +-999.98 +3.30 +0.00 +3.30 +999.99 +999.98 +999.99 +SELECT * FROM float_5_2_tbl WHERE colA > -999.985; +colA +-999.98 +3.30 +0.00 +3.30 +999.99 +999.98 +999.99 +SELECT * FROM float_5_2_tbl WHERE colA = -999.985; +colA +SELECT * FROM float_5_2_tbl WHERE colA <> -999.985; +colA +-999.99 +-999.99 +-999.98 +3.30 +0.00 +3.30 +999.99 +999.98 +999.99 +SELECT * FROM float_5_2_tbl WHERE colA <= -999.995; +colA +SELECT * FROM float_5_2_tbl WHERE colA < -999.995; +colA +SELECT * FROM float_5_2_tbl WHERE colA >= -999.995; +colA +-999.99 +-999.99 +-999.98 +3.30 +0.00 +3.30 +999.99 +999.98 +999.99 +SELECT * FROM float_5_2_tbl WHERE colA > -999.995; +colA +-999.99 +-999.99 +-999.98 +3.30 +0.00 +3.30 +999.99 +999.98 +999.99 +SELECT * FROM float_5_2_tbl WHERE colA = -999.995; +colA +SELECT * FROM float_5_2_tbl WHERE colA <> -999.995; +colA +-999.99 +-999.99 +-999.98 +3.30 +0.00 +3.30 +999.99 +999.98 +999.99 +SELECT * FROM float_5_2_tbl WHERE colA <= -999.994; +colA +SELECT * FROM float_5_2_tbl WHERE colA < -999.994; +colA +SELECT * FROM float_5_2_tbl WHERE colA >= -999.994; +colA +-999.99 +-999.99 +-999.98 +3.30 +0.00 +3.30 +999.99 +999.98 +999.99 +SELECT * FROM float_5_2_tbl WHERE colA > -999.994; +colA +-999.99 +-999.99 +-999.98 +3.30 +0.00 +3.30 +999.99 +999.98 +999.99 +SELECT * FROM float_5_2_tbl WHERE colA = -999.994; +colA +SELECT * FROM float_5_2_tbl WHERE colA <> -999.994; +colA +-999.99 +-999.99 +-999.98 +3.30 +0.00 +3.30 +999.99 +999.98 +999.99 +SELECT * FROM float_5_2_tbl WHERE colA <= 999.99; +colA +-999.99 +-999.99 +-999.98 +3.30 +0.00 +3.30 +999.99 +999.98 +999.99 +SELECT * FROM float_5_2_tbl WHERE colA < 999.99; +colA +-999.99 +-999.99 +-999.98 +3.30 +0.00 +3.30 +999.98 +SELECT * FROM float_5_2_tbl WHERE colA >= 999.99; +colA +999.99 +999.99 +SELECT * FROM float_5_2_tbl WHERE colA > 999.99; +colA +SELECT * FROM float_5_2_tbl WHERE colA = 999.99; +colA +999.99 +999.99 +SELECT * FROM float_5_2_tbl WHERE colA <> 999.99; +colA +-999.99 +-999.99 +-999.98 +3.30 +0.00 +3.30 +999.98 +SELECT * FROM float_5_2_tbl WHERE colA <= 999.984; +colA +-999.99 +-999.99 +-999.98 +3.30 +0.00 +3.30 +999.98 +SELECT * FROM float_5_2_tbl WHERE colA < 999.984; +colA +-999.99 +-999.99 +-999.98 +3.30 +0.00 +3.30 +999.98 +SELECT * FROM float_5_2_tbl WHERE colA >= 999.984; +colA +999.99 +999.99 +SELECT * FROM float_5_2_tbl WHERE colA > 999.984; +colA +999.99 +999.99 +SELECT * FROM float_5_2_tbl WHERE colA = 999.984; +colA +SELECT * FROM float_5_2_tbl WHERE colA <> 999.984; +colA +-999.99 +-999.99 +-999.98 +3.30 +0.00 +3.30 +999.99 +999.98 +999.99 +SELECT * FROM float_5_2_tbl WHERE colA <= 999.985; +colA +-999.99 +-999.99 +-999.98 +3.30 +0.00 +3.30 +999.98 +SELECT * FROM float_5_2_tbl WHERE colA < 999.985; +colA +-999.99 +-999.99 +-999.98 +3.30 +0.00 +3.30 +999.98 +SELECT * FROM float_5_2_tbl WHERE colA >= 999.985; +colA +999.99 +999.99 +SELECT * FROM float_5_2_tbl WHERE colA > 999.985; +colA +999.99 +999.99 +SELECT * FROM float_5_2_tbl WHERE colA = 999.985; +colA +SELECT * FROM float_5_2_tbl WHERE colA <> 999.985; +colA +-999.99 +-999.99 +-999.98 +3.30 +0.00 +3.30 +999.99 +999.98 +999.99 +SELECT * FROM float_5_2_tbl WHERE colA <= 999.994; +colA +-999.99 +-999.99 +-999.98 +3.30 +0.00 +3.30 +999.99 +999.98 +999.99 +SELECT * FROM float_5_2_tbl WHERE colA < 999.994; +colA +-999.99 +-999.99 +-999.98 +3.30 +0.00 +3.30 +999.99 +999.98 +999.99 +Result here can be empty set, because MySQL performs operation in +double, e.g. colA >= 999.994 for FLOAT(5,2): +executes as nnn.nn0 >= 999.994, i.e. the .994 isn't truncated +to .99 before comparison +SELECT * FROM float_5_2_tbl WHERE colA >= 999.994; +colA +SELECT * FROM float_5_2_tbl WHERE colA > 999.994; +colA +SELECT * FROM float_5_2_tbl WHERE colA = 999.994; +colA +SELECT * FROM float_5_2_tbl WHERE colA <> 999.994; +colA +-999.99 +-999.99 +-999.98 +3.30 +0.00 +3.30 +999.99 +999.98 +999.99 +SELECT * FROM float_5_2_tbl WHERE colA <= 999.995; +colA +-999.99 +-999.99 +-999.98 +3.30 +0.00 +3.30 +999.99 +999.98 +999.99 +SELECT * FROM float_5_2_tbl WHERE colA < 999.995; +colA +-999.99 +-999.99 +-999.98 +3.30 +0.00 +3.30 +999.99 +999.98 +999.99 +SELECT * FROM float_5_2_tbl WHERE colA >= 999.995; +colA +SELECT * FROM float_5_2_tbl WHERE colA > 999.995; +colA +SELECT * FROM float_5_2_tbl WHERE colA = 999.995; +colA +SELECT * FROM float_5_2_tbl WHERE colA <> 999.995; +colA +-999.99 +-999.99 +-999.98 +3.30 +0.00 +3.30 +999.99 +999.98 +999.99 +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA <= -999.99; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` <= -999.989990234375) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA < -999.99; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` < -999.989990234375) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA >= -999.99; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` >= -999.989990234375) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA > -999.99; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` > -999.989990234375) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA = -999.99; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` = -999.989990234375) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA <> -999.99; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 90.00 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 90.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` <> -999.989990234375) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA <= -999.984; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` < -999.97998046875) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA < -999.984; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` < -999.97998046875) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA >= -999.984; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` >= -999.97998046875) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA > -999.984; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` >= -999.97998046875) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA = -999.984; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where false +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA <> -999.984; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 90.00 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 90.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` is not null) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA <= -999.985; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` <= -999.989990234375) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA < -999.985; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` <= -999.989990234375) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA >= -999.985; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` > -999.989990234375) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA > -999.985; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` > -999.989990234375) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA = -999.985; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where false +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA <> -999.985; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 90.00 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 90.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` is not null) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA <= -999.995; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where false +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA < -999.995; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where false +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA >= -999.995; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 90.00 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 90.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` is not null) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA > -999.995; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 90.00 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 90.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` is not null) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA = -999.995; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where false +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA <> -999.995; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 90.00 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 90.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` is not null) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA <= -999.994; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` < -999.989990234375) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA < -999.994; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` < -999.989990234375) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA >= -999.994; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` >= -999.989990234375) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA > -999.994; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` >= -999.989990234375) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA = -999.994; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where false +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA <> -999.994; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 90.00 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 90.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` is not null) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA <= 999.99; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` <= 999.989990234375) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA < 999.99; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` < 999.989990234375) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA >= 999.99; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` >= 999.989990234375) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA > 999.99; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` > 999.989990234375) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA = 999.99; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` = 999.989990234375) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA <> 999.99; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 90.00 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 90.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` <> 999.989990234375) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA <= 999.984; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` <= 999.97998046875) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA < 999.984; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` <= 999.97998046875) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA >= 999.984; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` > 999.97998046875) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA > 999.984; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` > 999.97998046875) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA = 999.984; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where false +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA <> 999.984; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 90.00 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 90.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` is not null) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA <= 999.985; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` < 999.989990234375) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA < 999.985; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` < 999.989990234375) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA >= 999.985; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` >= 999.989990234375) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA > 999.985; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` >= 999.989990234375) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA = 999.985; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where false +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA <> 999.985; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 90.00 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 90.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` is not null) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA <= 999.994; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` <= 999.989990234375) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA < 999.994; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` <= 999.989990234375) +Cf explanation of semantics here under the SELECT above. The operator +is modified here to get the same semantics: we need > instead of >= +since we truncate the constant to the allowed range +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA >= 999.994; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` > 999.989990234375) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA > 999.994; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` > 999.989990234375) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA = 999.994; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where false +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA <> 999.994; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 90.00 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 90.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` is not null) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA <= 999.995; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 90.00 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 90.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` is not null) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA < 999.995; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 90.00 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 90.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` is not null) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA >= 999.995; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where false +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA > 999.995; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where false +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA = 999.995; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where false +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA <> 999.995; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 90.00 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 90.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` is not null) +DROP TABLE float_5_2_tbl; +CREATE TABLE f(f FLOAT); +INSERT INTO f VALUES (-1), (2); +SELECT * FROM f WHERE f >= '2 garbage'; +f +2 +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: '2 garbage' +DROP TABLE f; +# +# Tests with type FLOAT(5,2) against real constants +# +CREATE TABLE float_5_2_tbl (colA FLOAT(5,2) ); +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +INSERT INTO float_5_2_tbl VALUES ('-999.99'), ('-999.985'), +('-999.984'), +( 3.3), (0.0), (3.3), +('999.985'), +('999.984'), ('999.99'), +(NULL); +ANALYZE TABLE float_5_2_tbl; +Table Op Msg_type Msg_text +test.float_5_2_tbl analyze status OK +SELECT * FROM float_5_2_tbl; +colA +-999.99 +-999.99 +-999.98 +3.30 +0.00 +3.30 +999.99 +999.98 +999.99 +NULL +SELECT * FROM float_5_2_tbl WHERE colA <= '-999.99'; +colA +-999.99 +-999.99 +SELECT * FROM float_5_2_tbl WHERE colA < '-999.99'; +colA +SELECT * FROM float_5_2_tbl WHERE colA >= '-999.99'; +colA +-999.99 +-999.99 +-999.98 +3.30 +0.00 +3.30 +999.99 +999.98 +999.99 +SELECT * FROM float_5_2_tbl WHERE colA > '-999.99'; +colA +-999.98 +3.30 +0.00 +3.30 +999.99 +999.98 +999.99 +SELECT * FROM float_5_2_tbl WHERE colA = '-999.99'; +colA +-999.99 +-999.99 +SELECT * FROM float_5_2_tbl WHERE colA <> '-999.99'; +colA +-999.98 +3.30 +0.00 +3.30 +999.99 +999.98 +999.99 +SELECT * FROM float_5_2_tbl WHERE colA <= '-999.984'; +colA +-999.99 +-999.99 +SELECT * FROM float_5_2_tbl WHERE colA < '-999.984'; +colA +-999.99 +-999.99 +SELECT * FROM float_5_2_tbl WHERE colA >= '-999.984'; +colA +-999.98 +3.30 +0.00 +3.30 +999.99 +999.98 +999.99 +SELECT * FROM float_5_2_tbl WHERE colA > '-999.984'; +colA +-999.98 +3.30 +0.00 +3.30 +999.99 +999.98 +999.99 +SELECT * FROM float_5_2_tbl WHERE colA = '-999.984'; +colA +SELECT * FROM float_5_2_tbl WHERE colA <> '-999.984'; +colA +-999.99 +-999.99 +-999.98 +3.30 +0.00 +3.30 +999.99 +999.98 +999.99 +SELECT * FROM float_5_2_tbl WHERE colA <= '-999.985'; +colA +-999.99 +-999.99 +SELECT * FROM float_5_2_tbl WHERE colA < '-999.985'; +colA +-999.99 +-999.99 +SELECT * FROM float_5_2_tbl WHERE colA >= '-999.985'; +colA +-999.98 +3.30 +0.00 +3.30 +999.99 +999.98 +999.99 +SELECT * FROM float_5_2_tbl WHERE colA > '-999.985'; +colA +-999.98 +3.30 +0.00 +3.30 +999.99 +999.98 +999.99 +SELECT * FROM float_5_2_tbl WHERE colA = '-999.985'; +colA +SELECT * FROM float_5_2_tbl WHERE colA <> '-999.985'; +colA +-999.99 +-999.99 +-999.98 +3.30 +0.00 +3.30 +999.99 +999.98 +999.99 +SELECT * FROM float_5_2_tbl WHERE colA <= '-999.995'; +colA +SELECT * FROM float_5_2_tbl WHERE colA < '-999.995'; +colA +SELECT * FROM float_5_2_tbl WHERE colA >= '-999.995'; +colA +-999.99 +-999.99 +-999.98 +3.30 +0.00 +3.30 +999.99 +999.98 +999.99 +SELECT * FROM float_5_2_tbl WHERE colA > '-999.995'; +colA +-999.99 +-999.99 +-999.98 +3.30 +0.00 +3.30 +999.99 +999.98 +999.99 +SELECT * FROM float_5_2_tbl WHERE colA = '-999.995'; +colA +SELECT * FROM float_5_2_tbl WHERE colA <> '-999.995'; +colA +-999.99 +-999.99 +-999.98 +3.30 +0.00 +3.30 +999.99 +999.98 +999.99 +SELECT * FROM float_5_2_tbl WHERE colA <= '-999.994'; +colA +SELECT * FROM float_5_2_tbl WHERE colA < '-999.994'; +colA +SELECT * FROM float_5_2_tbl WHERE colA >= '-999.994'; +colA +-999.99 +-999.99 +-999.98 +3.30 +0.00 +3.30 +999.99 +999.98 +999.99 +SELECT * FROM float_5_2_tbl WHERE colA > '-999.994'; +colA +-999.99 +-999.99 +-999.98 +3.30 +0.00 +3.30 +999.99 +999.98 +999.99 +SELECT * FROM float_5_2_tbl WHERE colA = '-999.994'; +colA +SELECT * FROM float_5_2_tbl WHERE colA <> '-999.994'; +colA +-999.99 +-999.99 +-999.98 +3.30 +0.00 +3.30 +999.99 +999.98 +999.99 +SELECT * FROM float_5_2_tbl WHERE colA <= '999.99'; +colA +-999.99 +-999.99 +-999.98 +3.30 +0.00 +3.30 +999.99 +999.98 +999.99 +SELECT * FROM float_5_2_tbl WHERE colA < '999.99'; +colA +-999.99 +-999.99 +-999.98 +3.30 +0.00 +3.30 +999.98 +SELECT * FROM float_5_2_tbl WHERE colA >= '999.99'; +colA +999.99 +999.99 +SELECT * FROM float_5_2_tbl WHERE colA > '999.99'; +colA +SELECT * FROM float_5_2_tbl WHERE colA = '999.99'; +colA +999.99 +999.99 +SELECT * FROM float_5_2_tbl WHERE colA <> '999.99'; +colA +-999.99 +-999.99 +-999.98 +3.30 +0.00 +3.30 +999.98 +SELECT * FROM float_5_2_tbl WHERE colA <= '999.984'; +colA +-999.99 +-999.99 +-999.98 +3.30 +0.00 +3.30 +999.98 +SELECT * FROM float_5_2_tbl WHERE colA < '999.984'; +colA +-999.99 +-999.99 +-999.98 +3.30 +0.00 +3.30 +999.98 +SELECT * FROM float_5_2_tbl WHERE colA >= '999.984'; +colA +999.99 +999.99 +SELECT * FROM float_5_2_tbl WHERE colA > '999.984'; +colA +999.99 +999.99 +SELECT * FROM float_5_2_tbl WHERE colA = '999.984'; +colA +SELECT * FROM float_5_2_tbl WHERE colA <> '999.984'; +colA +-999.99 +-999.99 +-999.98 +3.30 +0.00 +3.30 +999.99 +999.98 +999.99 +SELECT * FROM float_5_2_tbl WHERE colA <= '999.985'; +colA +-999.99 +-999.99 +-999.98 +3.30 +0.00 +3.30 +999.98 +SELECT * FROM float_5_2_tbl WHERE colA < '999.985'; +colA +-999.99 +-999.99 +-999.98 +3.30 +0.00 +3.30 +999.98 +SELECT * FROM float_5_2_tbl WHERE colA >= '999.985'; +colA +999.99 +999.99 +SELECT * FROM float_5_2_tbl WHERE colA > '999.985'; +colA +999.99 +999.99 +SELECT * FROM float_5_2_tbl WHERE colA = '999.985'; +colA +SELECT * FROM float_5_2_tbl WHERE colA <> '999.985'; +colA +-999.99 +-999.99 +-999.98 +3.30 +0.00 +3.30 +999.99 +999.98 +999.99 +SELECT * FROM float_5_2_tbl WHERE colA <= '999.994'; +colA +-999.99 +-999.99 +-999.98 +3.30 +0.00 +3.30 +999.99 +999.98 +999.99 +SELECT * FROM float_5_2_tbl WHERE colA < '999.994'; +colA +-999.99 +-999.99 +-999.98 +3.30 +0.00 +3.30 +999.99 +999.98 +999.99 +Result here can be empty set, because MySQL performs operation in +double, e.g. colA >= 999.994 for FLOAT(5,2): +executes as nnn.nn0 >= 999.994, i.e. the .994 isn't truncated +to .99 before comparison +SELECT * FROM float_5_2_tbl WHERE colA >= '999.994'; +colA +SELECT * FROM float_5_2_tbl WHERE colA > '999.994'; +colA +SELECT * FROM float_5_2_tbl WHERE colA = '999.994'; +colA +SELECT * FROM float_5_2_tbl WHERE colA <> '999.994'; +colA +-999.99 +-999.99 +-999.98 +3.30 +0.00 +3.30 +999.99 +999.98 +999.99 +SELECT * FROM float_5_2_tbl WHERE colA <= '999.995'; +colA +-999.99 +-999.99 +-999.98 +3.30 +0.00 +3.30 +999.99 +999.98 +999.99 +SELECT * FROM float_5_2_tbl WHERE colA < '999.995'; +colA +-999.99 +-999.99 +-999.98 +3.30 +0.00 +3.30 +999.99 +999.98 +999.99 +SELECT * FROM float_5_2_tbl WHERE colA >= '999.995'; +colA +SELECT * FROM float_5_2_tbl WHERE colA > '999.995'; +colA +SELECT * FROM float_5_2_tbl WHERE colA = '999.995'; +colA +SELECT * FROM float_5_2_tbl WHERE colA <> '999.995'; +colA +-999.99 +-999.99 +-999.98 +3.30 +0.00 +3.30 +999.99 +999.98 +999.99 +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA <= '-999.99'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` <= -999.989990234375) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA < '-999.99'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` < -999.989990234375) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA >= '-999.99'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` >= -999.989990234375) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA > '-999.99'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` > -999.989990234375) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA = '-999.99'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` = -999.989990234375) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA <> '-999.99'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 90.00 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 90.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` <> -999.989990234375) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA <= '-999.984'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` < -999.97998046875) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA < '-999.984'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` < -999.97998046875) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA >= '-999.984'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` >= -999.97998046875) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA > '-999.984'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` >= -999.97998046875) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA = '-999.984'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where false +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA <> '-999.984'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 90.00 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 90.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` is not null) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA <= '-999.985'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` <= -999.989990234375) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA < '-999.985'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` <= -999.989990234375) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA >= '-999.985'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` > -999.989990234375) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA > '-999.985'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` > -999.989990234375) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA = '-999.985'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where false +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA <> '-999.985'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 90.00 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 90.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` is not null) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA <= '-999.995'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where false +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA < '-999.995'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where false +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA >= '-999.995'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 90.00 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 90.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` is not null) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA > '-999.995'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 90.00 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 90.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` is not null) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA = '-999.995'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where false +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA <> '-999.995'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 90.00 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 90.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` is not null) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA <= '-999.994'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` < -999.989990234375) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA < '-999.994'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` < -999.989990234375) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA >= '-999.994'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` >= -999.989990234375) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA > '-999.994'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` >= -999.989990234375) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA = '-999.994'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where false +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA <> '-999.994'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 90.00 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 90.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` is not null) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA <= '999.99'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` <= 999.989990234375) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA < '999.99'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` < 999.989990234375) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA >= '999.99'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` >= 999.989990234375) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA > '999.99'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` > 999.989990234375) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA = '999.99'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` = 999.989990234375) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA <> '999.99'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 90.00 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 90.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` <> 999.989990234375) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA <= '999.984'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` <= 999.97998046875) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA < '999.984'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` <= 999.97998046875) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA >= '999.984'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` > 999.97998046875) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA > '999.984'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` > 999.97998046875) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA = '999.984'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where false +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA <> '999.984'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 90.00 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 90.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` is not null) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA <= '999.985'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` < 999.989990234375) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA < '999.985'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` < 999.989990234375) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA >= '999.985'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` >= 999.989990234375) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA > '999.985'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` >= 999.989990234375) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA = '999.985'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where false +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA <> '999.985'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 90.00 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 90.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` is not null) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA <= '999.994'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` <= 999.989990234375) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA < '999.994'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` <= 999.989990234375) +Cf explanation of semantics here under the SELECT above. The operator +is modified here to get the same semantics: we need > instead of >= +since we truncate the constant to the allowed range +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA >= '999.994'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` > 999.989990234375) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA > '999.994'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` > 999.989990234375) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA = '999.994'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where false +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA <> '999.994'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 90.00 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 90.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` is not null) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA <= '999.995'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 90.00 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 90.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` is not null) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA < '999.995'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 90.00 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 90.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` is not null) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA >= '999.995'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where false +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA > '999.995'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where false +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA = '999.995'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where false +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA <> '999.995'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 90.00 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 90.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` is not null) +DROP TABLE float_5_2_tbl; +CREATE TABLE f(f FLOAT); +INSERT INTO f VALUES (-1), (2); +SELECT * FROM f WHERE f >= '2 garbage'; +f +2 +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: '2 garbage' +DROP TABLE f; +# +# Tests with UNSIGNED type FLOAT(5,2) against real constants +# +CREATE TABLE float_5_2_tbl (colA FLOAT(5,2) UNSIGNED ); +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 UNSIGNED for decimal and floating point data types is deprecated and support for it will be removed in a future release. +INSERT INTO float_5_2_tbl VALUES (0.0), (0.005), +(0.004), +( 3.3), (0.0), (3.3), +('999.985'), +('999.984'), ('999.99'), +(NULL); +ANALYZE TABLE float_5_2_tbl; +Table Op Msg_type Msg_text +test.float_5_2_tbl analyze status OK +SELECT * FROM float_5_2_tbl; +colA +0.00 +0.00 +0.00 +3.30 +0.00 +3.30 +999.99 +999.98 +999.99 +NULL +SELECT * FROM float_5_2_tbl WHERE colA <= 0.0; +colA +0.00 +0.00 +0.00 +0.00 +SELECT * FROM float_5_2_tbl WHERE colA < 0.0; +colA +SELECT * FROM float_5_2_tbl WHERE colA >= 0.0; +colA +0.00 +0.00 +0.00 +3.30 +0.00 +3.30 +999.99 +999.98 +999.99 +SELECT * FROM float_5_2_tbl WHERE colA > 0.0; +colA +3.30 +3.30 +999.99 +999.98 +999.99 +SELECT * FROM float_5_2_tbl WHERE colA = 0.0; +colA +0.00 +0.00 +0.00 +0.00 +SELECT * FROM float_5_2_tbl WHERE colA <> 0.0; +colA +3.30 +3.30 +999.99 +999.98 +999.99 +SELECT * FROM float_5_2_tbl WHERE colA <= 0.004; +colA +0.00 +0.00 +0.00 +0.00 +SELECT * FROM float_5_2_tbl WHERE colA < 0.004; +colA +0.00 +0.00 +0.00 +0.00 +SELECT * FROM float_5_2_tbl WHERE colA >= 0.004; +colA +3.30 +3.30 +999.99 +999.98 +999.99 +SELECT * FROM float_5_2_tbl WHERE colA > 0.004; +colA +3.30 +3.30 +999.99 +999.98 +999.99 +SELECT * FROM float_5_2_tbl WHERE colA = 0.004; +colA +SELECT * FROM float_5_2_tbl WHERE colA <> 0.004; +colA +0.00 +0.00 +0.00 +3.30 +0.00 +3.30 +999.99 +999.98 +999.99 +SELECT * FROM float_5_2_tbl WHERE colA <= 0.005; +colA +0.00 +0.00 +0.00 +0.00 +SELECT * FROM float_5_2_tbl WHERE colA < 0.005; +colA +0.00 +0.00 +0.00 +0.00 +SELECT * FROM float_5_2_tbl WHERE colA >= 0.005; +colA +3.30 +3.30 +999.99 +999.98 +999.99 +SELECT * FROM float_5_2_tbl WHERE colA > 0.005; +colA +3.30 +3.30 +999.99 +999.98 +999.99 +SELECT * FROM float_5_2_tbl WHERE colA = 0.005; +colA +SELECT * FROM float_5_2_tbl WHERE colA <> 0.005; +colA +0.00 +0.00 +0.00 +3.30 +0.00 +3.30 +999.99 +999.98 +999.99 +SELECT * FROM float_5_2_tbl WHERE colA <= 0.0; +colA +0.00 +0.00 +0.00 +0.00 +SELECT * FROM float_5_2_tbl WHERE colA < 0.0; +colA +SELECT * FROM float_5_2_tbl WHERE colA >= 0.0; +colA +0.00 +0.00 +0.00 +3.30 +0.00 +3.30 +999.99 +999.98 +999.99 +SELECT * FROM float_5_2_tbl WHERE colA > 0.0; +colA +3.30 +3.30 +999.99 +999.98 +999.99 +SELECT * FROM float_5_2_tbl WHERE colA = 0.0; +colA +0.00 +0.00 +0.00 +0.00 +SELECT * FROM float_5_2_tbl WHERE colA <> 0.0; +colA +3.30 +3.30 +999.99 +999.98 +999.99 +SELECT * FROM float_5_2_tbl WHERE colA <= 0.0; +colA +0.00 +0.00 +0.00 +0.00 +SELECT * FROM float_5_2_tbl WHERE colA < 0.0; +colA +SELECT * FROM float_5_2_tbl WHERE colA >= 0.0; +colA +0.00 +0.00 +0.00 +3.30 +0.00 +3.30 +999.99 +999.98 +999.99 +SELECT * FROM float_5_2_tbl WHERE colA > 0.0; +colA +3.30 +3.30 +999.99 +999.98 +999.99 +SELECT * FROM float_5_2_tbl WHERE colA = 0.0; +colA +0.00 +0.00 +0.00 +0.00 +SELECT * FROM float_5_2_tbl WHERE colA <> 0.0; +colA +3.30 +3.30 +999.99 +999.98 +999.99 +SELECT * FROM float_5_2_tbl WHERE colA <= '999.99'; +colA +0.00 +0.00 +0.00 +3.30 +0.00 +3.30 +999.99 +999.98 +999.99 +SELECT * FROM float_5_2_tbl WHERE colA < '999.99'; +colA +0.00 +0.00 +0.00 +3.30 +0.00 +3.30 +999.98 +SELECT * FROM float_5_2_tbl WHERE colA >= '999.99'; +colA +999.99 +999.99 +SELECT * FROM float_5_2_tbl WHERE colA > '999.99'; +colA +SELECT * FROM float_5_2_tbl WHERE colA = '999.99'; +colA +999.99 +999.99 +SELECT * FROM float_5_2_tbl WHERE colA <> '999.99'; +colA +0.00 +0.00 +0.00 +3.30 +0.00 +3.30 +999.98 +SELECT * FROM float_5_2_tbl WHERE colA <= '999.984'; +colA +0.00 +0.00 +0.00 +3.30 +0.00 +3.30 +999.98 +SELECT * FROM float_5_2_tbl WHERE colA < '999.984'; +colA +0.00 +0.00 +0.00 +3.30 +0.00 +3.30 +999.98 +SELECT * FROM float_5_2_tbl WHERE colA >= '999.984'; +colA +999.99 +999.99 +SELECT * FROM float_5_2_tbl WHERE colA > '999.984'; +colA +999.99 +999.99 +SELECT * FROM float_5_2_tbl WHERE colA = '999.984'; +colA +SELECT * FROM float_5_2_tbl WHERE colA <> '999.984'; +colA +0.00 +0.00 +0.00 +3.30 +0.00 +3.30 +999.99 +999.98 +999.99 +SELECT * FROM float_5_2_tbl WHERE colA <= '999.985'; +colA +0.00 +0.00 +0.00 +3.30 +0.00 +3.30 +999.98 +SELECT * FROM float_5_2_tbl WHERE colA < '999.985'; +colA +0.00 +0.00 +0.00 +3.30 +0.00 +3.30 +999.98 +SELECT * FROM float_5_2_tbl WHERE colA >= '999.985'; +colA +999.99 +999.99 +SELECT * FROM float_5_2_tbl WHERE colA > '999.985'; +colA +999.99 +999.99 +SELECT * FROM float_5_2_tbl WHERE colA = '999.985'; +colA +SELECT * FROM float_5_2_tbl WHERE colA <> '999.985'; +colA +0.00 +0.00 +0.00 +3.30 +0.00 +3.30 +999.99 +999.98 +999.99 +SELECT * FROM float_5_2_tbl WHERE colA <= '999.994'; +colA +0.00 +0.00 +0.00 +3.30 +0.00 +3.30 +999.99 +999.98 +999.99 +SELECT * FROM float_5_2_tbl WHERE colA < '999.994'; +colA +0.00 +0.00 +0.00 +3.30 +0.00 +3.30 +999.99 +999.98 +999.99 +Result here can be empty set, because MySQL performs operation in +double, e.g. colA >= 999.994 for FLOAT(5,2): +executes as nnn.nn0 >= 999.994, i.e. the .994 isn't truncated +to .99 before comparison +SELECT * FROM float_5_2_tbl WHERE colA >= '999.994'; +colA +SELECT * FROM float_5_2_tbl WHERE colA > '999.994'; +colA +SELECT * FROM float_5_2_tbl WHERE colA = '999.994'; +colA +SELECT * FROM float_5_2_tbl WHERE colA <> '999.994'; +colA +0.00 +0.00 +0.00 +3.30 +0.00 +3.30 +999.99 +999.98 +999.99 +SELECT * FROM float_5_2_tbl WHERE colA <= '999.995'; +colA +0.00 +0.00 +0.00 +3.30 +0.00 +3.30 +999.99 +999.98 +999.99 +SELECT * FROM float_5_2_tbl WHERE colA < '999.995'; +colA +0.00 +0.00 +0.00 +3.30 +0.00 +3.30 +999.99 +999.98 +999.99 +SELECT * FROM float_5_2_tbl WHERE colA >= '999.995'; +colA +SELECT * FROM float_5_2_tbl WHERE colA > '999.995'; +colA +SELECT * FROM float_5_2_tbl WHERE colA = '999.995'; +colA +SELECT * FROM float_5_2_tbl WHERE colA <> '999.995'; +colA +0.00 +0.00 +0.00 +3.30 +0.00 +3.30 +999.99 +999.98 +999.99 +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA <= 0.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` <= 0) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA < 0.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` < 0) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA >= 0.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` >= 0) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA > 0.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` > 0) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA = 0.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` = 0) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA <> 0.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 90.00 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 90.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` <> 0) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA <= 0.004; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` <= 0) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA < 0.004; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` <= 0) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA >= 0.004; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` > 0) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA > 0.004; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` > 0) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA = 0.004; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where false +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA <> 0.004; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 90.00 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 90.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` is not null) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA <= 0.005; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` <= 0) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA < 0.005; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` <= 0) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA >= 0.005; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` > 0) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA > 0.005; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` > 0) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA = 0.005; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where false +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA <> 0.005; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 90.00 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 90.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` is not null) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA <= 0.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` <= 0) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA < 0.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` < 0) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA >= 0.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` >= 0) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA > 0.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` > 0) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA = 0.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` = 0) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA <> 0.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 90.00 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 90.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` <> 0) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA <= 0.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` <= 0) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA < 0.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` < 0) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA >= 0.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` >= 0) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA > 0.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` > 0) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA = 0.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` = 0) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA <> 0.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 90.00 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 90.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` <> 0) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA <= '999.99'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` <= 999.989990234375) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA < '999.99'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` < 999.989990234375) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA >= '999.99'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` >= 999.989990234375) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA > '999.99'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` > 999.989990234375) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA = '999.99'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` = 999.989990234375) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA <> '999.99'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 90.00 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 90.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` <> 999.989990234375) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA <= '999.984'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` <= 999.97998046875) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA < '999.984'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` <= 999.97998046875) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA >= '999.984'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` > 999.97998046875) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA > '999.984'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` > 999.97998046875) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA = '999.984'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where false +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA <> '999.984'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 90.00 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 90.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` is not null) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA <= '999.985'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` < 999.989990234375) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA < '999.985'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` < 999.989990234375) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA >= '999.985'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` >= 999.989990234375) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA > '999.985'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` >= 999.989990234375) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA = '999.985'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where false +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA <> '999.985'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 90.00 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 90.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` is not null) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA <= '999.994'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` <= 999.989990234375) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA < '999.994'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` <= 999.989990234375) +Cf explanation of semantics here under the SELECT above. The operator +is modified here to get the same semantics: we need > instead of >= +since we truncate the constant to the allowed range +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA >= '999.994'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` > 999.989990234375) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA > '999.994'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` > 999.989990234375) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA = '999.994'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where false +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA <> '999.994'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 90.00 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 90.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` is not null) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA <= '999.995'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 90.00 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 90.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` is not null) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA < '999.995'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 90.00 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 90.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` is not null) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA >= '999.995'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where false +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA > '999.995'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where false +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA = '999.995'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where false +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA <> '999.995'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 90.00 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 90.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` is not null) +DROP TABLE float_5_2_tbl; +CREATE TABLE f(f FLOAT); +INSERT INTO f VALUES (-1), (2); +SELECT * FROM f WHERE f >= '2 garbage'; +f +2 +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: '2 garbage' +DROP TABLE f; +# +# Tests with type FLOAT against real constants +# +CREATE TABLE float_tbl (colA FLOAT ); +INSERT INTO float_tbl VALUES (-3.4028234663852886e+38), (-3.4028234663852886e+38), +(-3.4028234663852886e+38), +( 3.3), (0.0), (3.3), +(3.4028234663852886e+38), +(3.4028234663852886e+38), (3.402823466E+38), +(NULL); +ANALYZE TABLE float_tbl; +Table Op Msg_type Msg_text +test.float_tbl analyze status OK +SELECT * FROM float_tbl; +colA +-3.40282e38 +-3.40282e38 +-3.40282e38 +3.3 +0 +3.3 +3.40282e38 +3.40282e38 +3.40282e38 +NULL +SELECT * FROM float_tbl WHERE colA <= -3.4028234663852886e+38; +colA +-3.40282e38 +-3.40282e38 +-3.40282e38 +SELECT * FROM float_tbl WHERE colA < -3.4028234663852886e+38; +colA +SELECT * FROM float_tbl WHERE colA >= -3.4028234663852886e+38; +colA +-3.40282e38 +-3.40282e38 +-3.40282e38 +3.3 +0 +3.3 +3.40282e38 +3.40282e38 +3.40282e38 +SELECT * FROM float_tbl WHERE colA > -3.4028234663852886e+38; +colA +3.3 +0 +3.3 +3.40282e38 +3.40282e38 +3.40282e38 +SELECT * FROM float_tbl WHERE colA = -3.4028234663852886e+38; +colA +-3.40282e38 +-3.40282e38 +-3.40282e38 +SELECT * FROM float_tbl WHERE colA <> -3.4028234663852886e+38; +colA +3.3 +0 +3.3 +3.40282e38 +3.40282e38 +3.40282e38 +SELECT * FROM float_tbl WHERE colA <= -3.4028234663852886e+38; +colA +-3.40282e38 +-3.40282e38 +-3.40282e38 +SELECT * FROM float_tbl WHERE colA < -3.4028234663852886e+38; +colA +SELECT * FROM float_tbl WHERE colA >= -3.4028234663852886e+38; +colA +-3.40282e38 +-3.40282e38 +-3.40282e38 +3.3 +0 +3.3 +3.40282e38 +3.40282e38 +3.40282e38 +SELECT * FROM float_tbl WHERE colA > -3.4028234663852886e+38; +colA +3.3 +0 +3.3 +3.40282e38 +3.40282e38 +3.40282e38 +SELECT * FROM float_tbl WHERE colA = -3.4028234663852886e+38; +colA +-3.40282e38 +-3.40282e38 +-3.40282e38 +SELECT * FROM float_tbl WHERE colA <> -3.4028234663852886e+38; +colA +3.3 +0 +3.3 +3.40282e38 +3.40282e38 +3.40282e38 +SELECT * FROM float_tbl WHERE colA <= -3.4028234663852886e+38; +colA +-3.40282e38 +-3.40282e38 +-3.40282e38 +SELECT * FROM float_tbl WHERE colA < -3.4028234663852886e+38; +colA +SELECT * FROM float_tbl WHERE colA >= -3.4028234663852886e+38; +colA +-3.40282e38 +-3.40282e38 +-3.40282e38 +3.3 +0 +3.3 +3.40282e38 +3.40282e38 +3.40282e38 +SELECT * FROM float_tbl WHERE colA > -3.4028234663852886e+38; +colA +3.3 +0 +3.3 +3.40282e38 +3.40282e38 +3.40282e38 +SELECT * FROM float_tbl WHERE colA = -3.4028234663852886e+38; +colA +-3.40282e38 +-3.40282e38 +-3.40282e38 +SELECT * FROM float_tbl WHERE colA <> -3.4028234663852886e+38; +colA +3.3 +0 +3.3 +3.40282e38 +3.40282e38 +3.40282e38 +SELECT * FROM float_tbl WHERE colA <= -3.402823466385288E+38; +colA +-3.40282e38 +-3.40282e38 +-3.40282e38 +SELECT * FROM float_tbl WHERE colA < -3.402823466385288E+38; +colA +-3.40282e38 +-3.40282e38 +-3.40282e38 +SELECT * FROM float_tbl WHERE colA >= -3.402823466385288E+38; +colA +3.3 +0 +3.3 +3.40282e38 +3.40282e38 +3.40282e38 +SELECT * FROM float_tbl WHERE colA > -3.402823466385288E+38; +colA +3.3 +0 +3.3 +3.40282e38 +3.40282e38 +3.40282e38 +SELECT * FROM float_tbl WHERE colA = -3.402823466385288E+38; +colA +SELECT * FROM float_tbl WHERE colA <> -3.402823466385288E+38; +colA +-3.40282e38 +-3.40282e38 +-3.40282e38 +3.3 +0 +3.3 +3.40282e38 +3.40282e38 +3.40282e38 +SELECT * FROM float_tbl WHERE colA <= -3.402823466385288E+38; +colA +-3.40282e38 +-3.40282e38 +-3.40282e38 +SELECT * FROM float_tbl WHERE colA < -3.402823466385288E+38; +colA +-3.40282e38 +-3.40282e38 +-3.40282e38 +SELECT * FROM float_tbl WHERE colA >= -3.402823466385288E+38; +colA +3.3 +0 +3.3 +3.40282e38 +3.40282e38 +3.40282e38 +SELECT * FROM float_tbl WHERE colA > -3.402823466385288E+38; +colA +3.3 +0 +3.3 +3.40282e38 +3.40282e38 +3.40282e38 +SELECT * FROM float_tbl WHERE colA = -3.402823466385288E+38; +colA +SELECT * FROM float_tbl WHERE colA <> -3.402823466385288E+38; +colA +-3.40282e38 +-3.40282e38 +-3.40282e38 +3.3 +0 +3.3 +3.40282e38 +3.40282e38 +3.40282e38 +SELECT * FROM float_tbl WHERE colA <= 3.402823466E+38; +colA +-3.40282e38 +-3.40282e38 +-3.40282e38 +3.3 +0 +3.3 +SELECT * FROM float_tbl WHERE colA < 3.402823466E+38; +colA +-3.40282e38 +-3.40282e38 +-3.40282e38 +3.3 +0 +3.3 +SELECT * FROM float_tbl WHERE colA >= 3.402823466E+38; +colA +3.40282e38 +3.40282e38 +3.40282e38 +SELECT * FROM float_tbl WHERE colA > 3.402823466E+38; +colA +3.40282e38 +3.40282e38 +3.40282e38 +SELECT * FROM float_tbl WHERE colA = 3.402823466E+38; +colA +SELECT * FROM float_tbl WHERE colA <> 3.402823466E+38; +colA +-3.40282e38 +-3.40282e38 +-3.40282e38 +3.3 +0 +3.3 +3.40282e38 +3.40282e38 +3.40282e38 +SELECT * FROM float_tbl WHERE colA <= 3.4028234663852886e+38; +colA +-3.40282e38 +-3.40282e38 +-3.40282e38 +3.3 +0 +3.3 +3.40282e38 +3.40282e38 +3.40282e38 +SELECT * FROM float_tbl WHERE colA < 3.4028234663852886e+38; +colA +-3.40282e38 +-3.40282e38 +-3.40282e38 +3.3 +0 +3.3 +SELECT * FROM float_tbl WHERE colA >= 3.4028234663852886e+38; +colA +3.40282e38 +3.40282e38 +3.40282e38 +SELECT * FROM float_tbl WHERE colA > 3.4028234663852886e+38; +colA +SELECT * FROM float_tbl WHERE colA = 3.4028234663852886e+38; +colA +3.40282e38 +3.40282e38 +3.40282e38 +SELECT * FROM float_tbl WHERE colA <> 3.4028234663852886e+38; +colA +-3.40282e38 +-3.40282e38 +-3.40282e38 +3.3 +0 +3.3 +SELECT * FROM float_tbl WHERE colA <= 3.4028234663852886e+38; +colA +-3.40282e38 +-3.40282e38 +-3.40282e38 +3.3 +0 +3.3 +3.40282e38 +3.40282e38 +3.40282e38 +SELECT * FROM float_tbl WHERE colA < 3.4028234663852886e+38; +colA +-3.40282e38 +-3.40282e38 +-3.40282e38 +3.3 +0 +3.3 +SELECT * FROM float_tbl WHERE colA >= 3.4028234663852886e+38; +colA +3.40282e38 +3.40282e38 +3.40282e38 +SELECT * FROM float_tbl WHERE colA > 3.4028234663852886e+38; +colA +SELECT * FROM float_tbl WHERE colA = 3.4028234663852886e+38; +colA +3.40282e38 +3.40282e38 +3.40282e38 +SELECT * FROM float_tbl WHERE colA <> 3.4028234663852886e+38; +colA +-3.40282e38 +-3.40282e38 +-3.40282e38 +3.3 +0 +3.3 +SELECT * FROM float_tbl WHERE colA <= 3.402823466385288E+38; +colA +-3.40282e38 +-3.40282e38 +-3.40282e38 +3.3 +0 +3.3 +SELECT * FROM float_tbl WHERE colA < 3.402823466385288E+38; +colA +-3.40282e38 +-3.40282e38 +-3.40282e38 +3.3 +0 +3.3 +Result here can be empty set, because MySQL performs operation in +double, e.g. colA >= 999.994 for FLOAT(5,2): +executes as nnn.nn0 >= 999.994, i.e. the .994 isn't truncated +to .99 before comparison +SELECT * FROM float_tbl WHERE colA >= 3.402823466385288E+38; +colA +3.40282e38 +3.40282e38 +3.40282e38 +SELECT * FROM float_tbl WHERE colA > 3.402823466385288E+38; +colA +3.40282e38 +3.40282e38 +3.40282e38 +SELECT * FROM float_tbl WHERE colA = 3.402823466385288E+38; +colA +SELECT * FROM float_tbl WHERE colA <> 3.402823466385288E+38; +colA +-3.40282e38 +-3.40282e38 +-3.40282e38 +3.3 +0 +3.3 +3.40282e38 +3.40282e38 +3.40282e38 +SELECT * FROM float_tbl WHERE colA <= 3.402823466385288E+38; +colA +-3.40282e38 +-3.40282e38 +-3.40282e38 +3.3 +0 +3.3 +SELECT * FROM float_tbl WHERE colA < 3.402823466385288E+38; +colA +-3.40282e38 +-3.40282e38 +-3.40282e38 +3.3 +0 +3.3 +SELECT * FROM float_tbl WHERE colA >= 3.402823466385288E+38; +colA +3.40282e38 +3.40282e38 +3.40282e38 +SELECT * FROM float_tbl WHERE colA > 3.402823466385288E+38; +colA +3.40282e38 +3.40282e38 +3.40282e38 +SELECT * FROM float_tbl WHERE colA = 3.402823466385288E+38; +colA +SELECT * FROM float_tbl WHERE colA <> 3.402823466385288E+38; +colA +-3.40282e38 +-3.40282e38 +-3.40282e38 +3.3 +0 +3.3 +3.40282e38 +3.40282e38 +3.40282e38 +EXPLAIN SELECT * FROM float_tbl WHERE colA <= -3.4028234663852886e+38; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_tbl`.`colA` AS `colA` from `test`.`float_tbl` where (`test`.`float_tbl`.`colA` <= -3.4028234663852886e38) +EXPLAIN SELECT * FROM float_tbl WHERE colA < -3.4028234663852886e+38; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_tbl`.`colA` AS `colA` from `test`.`float_tbl` where (`test`.`float_tbl`.`colA` < -3.4028234663852886e38) +EXPLAIN SELECT * FROM float_tbl WHERE colA >= -3.4028234663852886e+38; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_tbl`.`colA` AS `colA` from `test`.`float_tbl` where (`test`.`float_tbl`.`colA` >= -3.4028234663852886e38) +EXPLAIN SELECT * FROM float_tbl WHERE colA > -3.4028234663852886e+38; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_tbl`.`colA` AS `colA` from `test`.`float_tbl` where (`test`.`float_tbl`.`colA` > -3.4028234663852886e38) +EXPLAIN SELECT * FROM float_tbl WHERE colA = -3.4028234663852886e+38; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE float_tbl NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_tbl`.`colA` AS `colA` from `test`.`float_tbl` where (`test`.`float_tbl`.`colA` = -3.4028234663852886e38) +EXPLAIN SELECT * FROM float_tbl WHERE colA <> -3.4028234663852886e+38; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 90.00 Parallel execute (1 workers) +2 SIMPLE float_tbl NULL ALL NULL NULL NULL NULL 10 90.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_tbl`.`colA` AS `colA` from `test`.`float_tbl` where (`test`.`float_tbl`.`colA` <> -3.4028234663852886e38) +EXPLAIN SELECT * FROM float_tbl WHERE colA <= -3.4028234663852886e+38; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_tbl`.`colA` AS `colA` from `test`.`float_tbl` where (`test`.`float_tbl`.`colA` <= -3.4028234663852886e38) +EXPLAIN SELECT * FROM float_tbl WHERE colA < -3.4028234663852886e+38; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_tbl`.`colA` AS `colA` from `test`.`float_tbl` where (`test`.`float_tbl`.`colA` < -3.4028234663852886e38) +EXPLAIN SELECT * FROM float_tbl WHERE colA >= -3.4028234663852886e+38; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_tbl`.`colA` AS `colA` from `test`.`float_tbl` where (`test`.`float_tbl`.`colA` >= -3.4028234663852886e38) +EXPLAIN SELECT * FROM float_tbl WHERE colA > -3.4028234663852886e+38; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_tbl`.`colA` AS `colA` from `test`.`float_tbl` where (`test`.`float_tbl`.`colA` > -3.4028234663852886e38) +EXPLAIN SELECT * FROM float_tbl WHERE colA = -3.4028234663852886e+38; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE float_tbl NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_tbl`.`colA` AS `colA` from `test`.`float_tbl` where (`test`.`float_tbl`.`colA` = -3.4028234663852886e38) +EXPLAIN SELECT * FROM float_tbl WHERE colA <> -3.4028234663852886e+38; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 90.00 Parallel execute (1 workers) +2 SIMPLE float_tbl NULL ALL NULL NULL NULL NULL 10 90.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_tbl`.`colA` AS `colA` from `test`.`float_tbl` where (`test`.`float_tbl`.`colA` <> -3.4028234663852886e38) +EXPLAIN SELECT * FROM float_tbl WHERE colA <= -3.4028234663852886e+38; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_tbl`.`colA` AS `colA` from `test`.`float_tbl` where (`test`.`float_tbl`.`colA` <= -3.4028234663852886e38) +EXPLAIN SELECT * FROM float_tbl WHERE colA < -3.4028234663852886e+38; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_tbl`.`colA` AS `colA` from `test`.`float_tbl` where (`test`.`float_tbl`.`colA` < -3.4028234663852886e38) +EXPLAIN SELECT * FROM float_tbl WHERE colA >= -3.4028234663852886e+38; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_tbl`.`colA` AS `colA` from `test`.`float_tbl` where (`test`.`float_tbl`.`colA` >= -3.4028234663852886e38) +EXPLAIN SELECT * FROM float_tbl WHERE colA > -3.4028234663852886e+38; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_tbl`.`colA` AS `colA` from `test`.`float_tbl` where (`test`.`float_tbl`.`colA` > -3.4028234663852886e38) +EXPLAIN SELECT * FROM float_tbl WHERE colA = -3.4028234663852886e+38; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE float_tbl NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_tbl`.`colA` AS `colA` from `test`.`float_tbl` where (`test`.`float_tbl`.`colA` = -3.4028234663852886e38) +EXPLAIN SELECT * FROM float_tbl WHERE colA <> -3.4028234663852886e+38; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 90.00 Parallel execute (1 workers) +2 SIMPLE float_tbl NULL ALL NULL NULL NULL NULL 10 90.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_tbl`.`colA` AS `colA` from `test`.`float_tbl` where (`test`.`float_tbl`.`colA` <> -3.4028234663852886e38) +EXPLAIN SELECT * FROM float_tbl WHERE colA <= -3.402823466385288E+38; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_tbl`.`colA` AS `colA` from `test`.`float_tbl` where (`test`.`float_tbl`.`colA` <= -3.402823466385288e38) +EXPLAIN SELECT * FROM float_tbl WHERE colA < -3.402823466385288E+38; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_tbl`.`colA` AS `colA` from `test`.`float_tbl` where (`test`.`float_tbl`.`colA` < -3.402823466385288e38) +EXPLAIN SELECT * FROM float_tbl WHERE colA >= -3.402823466385288E+38; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_tbl`.`colA` AS `colA` from `test`.`float_tbl` where (`test`.`float_tbl`.`colA` >= -3.402823466385288e38) +EXPLAIN SELECT * FROM float_tbl WHERE colA > -3.402823466385288E+38; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_tbl`.`colA` AS `colA` from `test`.`float_tbl` where (`test`.`float_tbl`.`colA` > -3.402823466385288e38) +EXPLAIN SELECT * FROM float_tbl WHERE colA = -3.402823466385288E+38; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE float_tbl NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_tbl`.`colA` AS `colA` from `test`.`float_tbl` where (`test`.`float_tbl`.`colA` = -3.402823466385288e38) +EXPLAIN SELECT * FROM float_tbl WHERE colA <> -3.402823466385288E+38; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 90.00 Parallel execute (1 workers) +2 SIMPLE float_tbl NULL ALL NULL NULL NULL NULL 10 90.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_tbl`.`colA` AS `colA` from `test`.`float_tbl` where (`test`.`float_tbl`.`colA` <> -3.402823466385288e38) +EXPLAIN SELECT * FROM float_tbl WHERE colA <= -3.402823466385288E+38; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_tbl`.`colA` AS `colA` from `test`.`float_tbl` where (`test`.`float_tbl`.`colA` <= -3.402823466385288e38) +EXPLAIN SELECT * FROM float_tbl WHERE colA < -3.402823466385288E+38; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_tbl`.`colA` AS `colA` from `test`.`float_tbl` where (`test`.`float_tbl`.`colA` < -3.402823466385288e38) +EXPLAIN SELECT * FROM float_tbl WHERE colA >= -3.402823466385288E+38; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_tbl`.`colA` AS `colA` from `test`.`float_tbl` where (`test`.`float_tbl`.`colA` >= -3.402823466385288e38) +EXPLAIN SELECT * FROM float_tbl WHERE colA > -3.402823466385288E+38; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_tbl`.`colA` AS `colA` from `test`.`float_tbl` where (`test`.`float_tbl`.`colA` > -3.402823466385288e38) +EXPLAIN SELECT * FROM float_tbl WHERE colA = -3.402823466385288E+38; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE float_tbl NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_tbl`.`colA` AS `colA` from `test`.`float_tbl` where (`test`.`float_tbl`.`colA` = -3.402823466385288e38) +EXPLAIN SELECT * FROM float_tbl WHERE colA <> -3.402823466385288E+38; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 90.00 Parallel execute (1 workers) +2 SIMPLE float_tbl NULL ALL NULL NULL NULL NULL 10 90.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_tbl`.`colA` AS `colA` from `test`.`float_tbl` where (`test`.`float_tbl`.`colA` <> -3.402823466385288e38) +EXPLAIN SELECT * FROM float_tbl WHERE colA <= 3.402823466E+38; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_tbl`.`colA` AS `colA` from `test`.`float_tbl` where (`test`.`float_tbl`.`colA` <= 3.402823466E+38) +EXPLAIN SELECT * FROM float_tbl WHERE colA < 3.402823466E+38; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_tbl`.`colA` AS `colA` from `test`.`float_tbl` where (`test`.`float_tbl`.`colA` < 3.402823466E+38) +EXPLAIN SELECT * FROM float_tbl WHERE colA >= 3.402823466E+38; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_tbl`.`colA` AS `colA` from `test`.`float_tbl` where (`test`.`float_tbl`.`colA` >= 3.402823466E+38) +EXPLAIN SELECT * FROM float_tbl WHERE colA > 3.402823466E+38; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_tbl`.`colA` AS `colA` from `test`.`float_tbl` where (`test`.`float_tbl`.`colA` > 3.402823466E+38) +EXPLAIN SELECT * FROM float_tbl WHERE colA = 3.402823466E+38; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE float_tbl NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_tbl`.`colA` AS `colA` from `test`.`float_tbl` where (`test`.`float_tbl`.`colA` = 3.402823466E+38) +EXPLAIN SELECT * FROM float_tbl WHERE colA <> 3.402823466E+38; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 90.00 Parallel execute (1 workers) +2 SIMPLE float_tbl NULL ALL NULL NULL NULL NULL 10 90.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_tbl`.`colA` AS `colA` from `test`.`float_tbl` where (`test`.`float_tbl`.`colA` <> 3.402823466E+38) +EXPLAIN SELECT * FROM float_tbl WHERE colA <= 3.4028234663852886e+38; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_tbl`.`colA` AS `colA` from `test`.`float_tbl` where (`test`.`float_tbl`.`colA` <= 3.4028234663852886e+38) +EXPLAIN SELECT * FROM float_tbl WHERE colA < 3.4028234663852886e+38; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_tbl`.`colA` AS `colA` from `test`.`float_tbl` where (`test`.`float_tbl`.`colA` < 3.4028234663852886e+38) +EXPLAIN SELECT * FROM float_tbl WHERE colA >= 3.4028234663852886e+38; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_tbl`.`colA` AS `colA` from `test`.`float_tbl` where (`test`.`float_tbl`.`colA` >= 3.4028234663852886e+38) +EXPLAIN SELECT * FROM float_tbl WHERE colA > 3.4028234663852886e+38; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_tbl`.`colA` AS `colA` from `test`.`float_tbl` where (`test`.`float_tbl`.`colA` > 3.4028234663852886e+38) +EXPLAIN SELECT * FROM float_tbl WHERE colA = 3.4028234663852886e+38; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE float_tbl NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_tbl`.`colA` AS `colA` from `test`.`float_tbl` where (`test`.`float_tbl`.`colA` = 3.4028234663852886e+38) +EXPLAIN SELECT * FROM float_tbl WHERE colA <> 3.4028234663852886e+38; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 90.00 Parallel execute (1 workers) +2 SIMPLE float_tbl NULL ALL NULL NULL NULL NULL 10 90.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_tbl`.`colA` AS `colA` from `test`.`float_tbl` where (`test`.`float_tbl`.`colA` <> 3.4028234663852886e+38) +EXPLAIN SELECT * FROM float_tbl WHERE colA <= 3.4028234663852886e+38; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_tbl`.`colA` AS `colA` from `test`.`float_tbl` where (`test`.`float_tbl`.`colA` <= 3.4028234663852886e+38) +EXPLAIN SELECT * FROM float_tbl WHERE colA < 3.4028234663852886e+38; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_tbl`.`colA` AS `colA` from `test`.`float_tbl` where (`test`.`float_tbl`.`colA` < 3.4028234663852886e+38) +EXPLAIN SELECT * FROM float_tbl WHERE colA >= 3.4028234663852886e+38; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_tbl`.`colA` AS `colA` from `test`.`float_tbl` where (`test`.`float_tbl`.`colA` >= 3.4028234663852886e+38) +EXPLAIN SELECT * FROM float_tbl WHERE colA > 3.4028234663852886e+38; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_tbl`.`colA` AS `colA` from `test`.`float_tbl` where (`test`.`float_tbl`.`colA` > 3.4028234663852886e+38) +EXPLAIN SELECT * FROM float_tbl WHERE colA = 3.4028234663852886e+38; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE float_tbl NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_tbl`.`colA` AS `colA` from `test`.`float_tbl` where (`test`.`float_tbl`.`colA` = 3.4028234663852886e+38) +EXPLAIN SELECT * FROM float_tbl WHERE colA <> 3.4028234663852886e+38; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 90.00 Parallel execute (1 workers) +2 SIMPLE float_tbl NULL ALL NULL NULL NULL NULL 10 90.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_tbl`.`colA` AS `colA` from `test`.`float_tbl` where (`test`.`float_tbl`.`colA` <> 3.4028234663852886e+38) +EXPLAIN SELECT * FROM float_tbl WHERE colA <= 3.402823466385288E+38; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_tbl`.`colA` AS `colA` from `test`.`float_tbl` where (`test`.`float_tbl`.`colA` <= 3.402823466385288E+38) +EXPLAIN SELECT * FROM float_tbl WHERE colA < 3.402823466385288E+38; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_tbl`.`colA` AS `colA` from `test`.`float_tbl` where (`test`.`float_tbl`.`colA` < 3.402823466385288E+38) +Cf explanation of semantics here under the SELECT above. The operator +is modified here to get the same semantics: we need > instead of >= +since we truncate the constant to the allowed range +EXPLAIN SELECT * FROM float_tbl WHERE colA >= 3.402823466385288E+38; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_tbl`.`colA` AS `colA` from `test`.`float_tbl` where (`test`.`float_tbl`.`colA` >= 3.402823466385288E+38) +EXPLAIN SELECT * FROM float_tbl WHERE colA > 3.402823466385288E+38; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_tbl`.`colA` AS `colA` from `test`.`float_tbl` where (`test`.`float_tbl`.`colA` > 3.402823466385288E+38) +EXPLAIN SELECT * FROM float_tbl WHERE colA = 3.402823466385288E+38; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE float_tbl NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_tbl`.`colA` AS `colA` from `test`.`float_tbl` where (`test`.`float_tbl`.`colA` = 3.402823466385288E+38) +EXPLAIN SELECT * FROM float_tbl WHERE colA <> 3.402823466385288E+38; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 90.00 Parallel execute (1 workers) +2 SIMPLE float_tbl NULL ALL NULL NULL NULL NULL 10 90.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_tbl`.`colA` AS `colA` from `test`.`float_tbl` where (`test`.`float_tbl`.`colA` <> 3.402823466385288E+38) +EXPLAIN SELECT * FROM float_tbl WHERE colA <= 3.402823466385288E+38; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_tbl`.`colA` AS `colA` from `test`.`float_tbl` where (`test`.`float_tbl`.`colA` <= 3.402823466385288E+38) +EXPLAIN SELECT * FROM float_tbl WHERE colA < 3.402823466385288E+38; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_tbl`.`colA` AS `colA` from `test`.`float_tbl` where (`test`.`float_tbl`.`colA` < 3.402823466385288E+38) +EXPLAIN SELECT * FROM float_tbl WHERE colA >= 3.402823466385288E+38; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_tbl`.`colA` AS `colA` from `test`.`float_tbl` where (`test`.`float_tbl`.`colA` >= 3.402823466385288E+38) +EXPLAIN SELECT * FROM float_tbl WHERE colA > 3.402823466385288E+38; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_tbl`.`colA` AS `colA` from `test`.`float_tbl` where (`test`.`float_tbl`.`colA` > 3.402823466385288E+38) +EXPLAIN SELECT * FROM float_tbl WHERE colA = 3.402823466385288E+38; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE float_tbl NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_tbl`.`colA` AS `colA` from `test`.`float_tbl` where (`test`.`float_tbl`.`colA` = 3.402823466385288E+38) +EXPLAIN SELECT * FROM float_tbl WHERE colA <> 3.402823466385288E+38; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 90.00 Parallel execute (1 workers) +2 SIMPLE float_tbl NULL ALL NULL NULL NULL NULL 10 90.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_tbl`.`colA` AS `colA` from `test`.`float_tbl` where (`test`.`float_tbl`.`colA` <> 3.402823466385288E+38) +DROP TABLE float_tbl; +CREATE TABLE f(f FLOAT); +INSERT INTO f VALUES (-1), (2); +SELECT * FROM f WHERE f >= '2 garbage'; +f +2 +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: '2 garbage' +DROP TABLE f; +# +# Tests with type DOUBLE(5,2) against real constants +# +CREATE TABLE double_5_2_tbl (colA DOUBLE(5,2) ); +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +INSERT INTO double_5_2_tbl VALUES (-999.99), (-999.985), +(-999.984), +( 3.3), (0.0), (3.3), +(999.985), +(999.984), (999.99), +(NULL); +ANALYZE TABLE double_5_2_tbl; +Table Op Msg_type Msg_text +test.double_5_2_tbl analyze status OK +SELECT * FROM double_5_2_tbl; +colA +-999.99 +-999.99 +-999.98 +3.30 +0.00 +3.30 +999.99 +999.98 +999.99 +NULL +SELECT * FROM double_5_2_tbl WHERE colA <= -999.99; +colA +-999.99 +-999.99 +SELECT * FROM double_5_2_tbl WHERE colA < -999.99; +colA +SELECT * FROM double_5_2_tbl WHERE colA >= -999.99; +colA +-999.99 +-999.99 +-999.98 +3.30 +0.00 +3.30 +999.99 +999.98 +999.99 +SELECT * FROM double_5_2_tbl WHERE colA > -999.99; +colA +-999.98 +3.30 +0.00 +3.30 +999.99 +999.98 +999.99 +SELECT * FROM double_5_2_tbl WHERE colA = -999.99; +colA +-999.99 +-999.99 +SELECT * FROM double_5_2_tbl WHERE colA <> -999.99; +colA +-999.98 +3.30 +0.00 +3.30 +999.99 +999.98 +999.99 +SELECT * FROM double_5_2_tbl WHERE colA <= -999.984; +colA +-999.99 +-999.99 +SELECT * FROM double_5_2_tbl WHERE colA < -999.984; +colA +-999.99 +-999.99 +SELECT * FROM double_5_2_tbl WHERE colA >= -999.984; +colA +-999.98 +3.30 +0.00 +3.30 +999.99 +999.98 +999.99 +SELECT * FROM double_5_2_tbl WHERE colA > -999.984; +colA +-999.98 +3.30 +0.00 +3.30 +999.99 +999.98 +999.99 +SELECT * FROM double_5_2_tbl WHERE colA = -999.984; +colA +SELECT * FROM double_5_2_tbl WHERE colA <> -999.984; +colA +-999.99 +-999.99 +-999.98 +3.30 +0.00 +3.30 +999.99 +999.98 +999.99 +SELECT * FROM double_5_2_tbl WHERE colA <= -999.985; +colA +-999.99 +-999.99 +SELECT * FROM double_5_2_tbl WHERE colA < -999.985; +colA +-999.99 +-999.99 +SELECT * FROM double_5_2_tbl WHERE colA >= -999.985; +colA +-999.98 +3.30 +0.00 +3.30 +999.99 +999.98 +999.99 +SELECT * FROM double_5_2_tbl WHERE colA > -999.985; +colA +-999.98 +3.30 +0.00 +3.30 +999.99 +999.98 +999.99 +SELECT * FROM double_5_2_tbl WHERE colA = -999.985; +colA +SELECT * FROM double_5_2_tbl WHERE colA <> -999.985; +colA +-999.99 +-999.99 +-999.98 +3.30 +0.00 +3.30 +999.99 +999.98 +999.99 +SELECT * FROM double_5_2_tbl WHERE colA <= -999.995; +colA +SELECT * FROM double_5_2_tbl WHERE colA < -999.995; +colA +SELECT * FROM double_5_2_tbl WHERE colA >= -999.995; +colA +-999.99 +-999.99 +-999.98 +3.30 +0.00 +3.30 +999.99 +999.98 +999.99 +SELECT * FROM double_5_2_tbl WHERE colA > -999.995; +colA +-999.99 +-999.99 +-999.98 +3.30 +0.00 +3.30 +999.99 +999.98 +999.99 +SELECT * FROM double_5_2_tbl WHERE colA = -999.995; +colA +SELECT * FROM double_5_2_tbl WHERE colA <> -999.995; +colA +-999.99 +-999.99 +-999.98 +3.30 +0.00 +3.30 +999.99 +999.98 +999.99 +SELECT * FROM double_5_2_tbl WHERE colA <= -999.994; +colA +SELECT * FROM double_5_2_tbl WHERE colA < -999.994; +colA +SELECT * FROM double_5_2_tbl WHERE colA >= -999.994; +colA +-999.99 +-999.99 +-999.98 +3.30 +0.00 +3.30 +999.99 +999.98 +999.99 +SELECT * FROM double_5_2_tbl WHERE colA > -999.994; +colA +-999.99 +-999.99 +-999.98 +3.30 +0.00 +3.30 +999.99 +999.98 +999.99 +SELECT * FROM double_5_2_tbl WHERE colA = -999.994; +colA +SELECT * FROM double_5_2_tbl WHERE colA <> -999.994; +colA +-999.99 +-999.99 +-999.98 +3.30 +0.00 +3.30 +999.99 +999.98 +999.99 +SELECT * FROM double_5_2_tbl WHERE colA <= 999.99; +colA +-999.99 +-999.99 +-999.98 +3.30 +0.00 +3.30 +999.99 +999.98 +999.99 +SELECT * FROM double_5_2_tbl WHERE colA < 999.99; +colA +-999.99 +-999.99 +-999.98 +3.30 +0.00 +3.30 +999.98 +SELECT * FROM double_5_2_tbl WHERE colA >= 999.99; +colA +999.99 +999.99 +SELECT * FROM double_5_2_tbl WHERE colA > 999.99; +colA +SELECT * FROM double_5_2_tbl WHERE colA = 999.99; +colA +999.99 +999.99 +SELECT * FROM double_5_2_tbl WHERE colA <> 999.99; +colA +-999.99 +-999.99 +-999.98 +3.30 +0.00 +3.30 +999.98 +SELECT * FROM double_5_2_tbl WHERE colA <= 999.984; +colA +-999.99 +-999.99 +-999.98 +3.30 +0.00 +3.30 +999.98 +SELECT * FROM double_5_2_tbl WHERE colA < 999.984; +colA +-999.99 +-999.99 +-999.98 +3.30 +0.00 +3.30 +999.98 +SELECT * FROM double_5_2_tbl WHERE colA >= 999.984; +colA +999.99 +999.99 +SELECT * FROM double_5_2_tbl WHERE colA > 999.984; +colA +999.99 +999.99 +SELECT * FROM double_5_2_tbl WHERE colA = 999.984; +colA +SELECT * FROM double_5_2_tbl WHERE colA <> 999.984; +colA +-999.99 +-999.99 +-999.98 +3.30 +0.00 +3.30 +999.99 +999.98 +999.99 +SELECT * FROM double_5_2_tbl WHERE colA <= 999.985; +colA +-999.99 +-999.99 +-999.98 +3.30 +0.00 +3.30 +999.98 +SELECT * FROM double_5_2_tbl WHERE colA < 999.985; +colA +-999.99 +-999.99 +-999.98 +3.30 +0.00 +3.30 +999.98 +SELECT * FROM double_5_2_tbl WHERE colA >= 999.985; +colA +999.99 +999.99 +SELECT * FROM double_5_2_tbl WHERE colA > 999.985; +colA +999.99 +999.99 +SELECT * FROM double_5_2_tbl WHERE colA = 999.985; +colA +SELECT * FROM double_5_2_tbl WHERE colA <> 999.985; +colA +-999.99 +-999.99 +-999.98 +3.30 +0.00 +3.30 +999.99 +999.98 +999.99 +SELECT * FROM double_5_2_tbl WHERE colA <= 999.994; +colA +-999.99 +-999.99 +-999.98 +3.30 +0.00 +3.30 +999.99 +999.98 +999.99 +SELECT * FROM double_5_2_tbl WHERE colA < 999.994; +colA +-999.99 +-999.99 +-999.98 +3.30 +0.00 +3.30 +999.99 +999.98 +999.99 +Result here can be empty set, because MySQL performs operation in +double, e.g. colA >= 999.994 for FLOAT(5,2): +executes as nnn.nn0 >= 999.994, i.e. the .994 isn't truncated +to .99 before comparison +SELECT * FROM double_5_2_tbl WHERE colA >= 999.994; +colA +SELECT * FROM double_5_2_tbl WHERE colA > 999.994; +colA +SELECT * FROM double_5_2_tbl WHERE colA = 999.994; +colA +SELECT * FROM double_5_2_tbl WHERE colA <> 999.994; +colA +-999.99 +-999.99 +-999.98 +3.30 +0.00 +3.30 +999.99 +999.98 +999.99 +SELECT * FROM double_5_2_tbl WHERE colA <= 999.995; +colA +-999.99 +-999.99 +-999.98 +3.30 +0.00 +3.30 +999.99 +999.98 +999.99 +SELECT * FROM double_5_2_tbl WHERE colA < 999.995; +colA +-999.99 +-999.99 +-999.98 +3.30 +0.00 +3.30 +999.99 +999.98 +999.99 +SELECT * FROM double_5_2_tbl WHERE colA >= 999.995; +colA +SELECT * FROM double_5_2_tbl WHERE colA > 999.995; +colA +SELECT * FROM double_5_2_tbl WHERE colA = 999.995; +colA +SELECT * FROM double_5_2_tbl WHERE colA <> 999.995; +colA +-999.99 +-999.99 +-999.98 +3.30 +0.00 +3.30 +999.99 +999.98 +999.99 +EXPLAIN SELECT * FROM double_5_2_tbl WHERE colA <= -999.99; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_5_2_tbl`.`colA` AS `colA` from `test`.`double_5_2_tbl` where (`test`.`double_5_2_tbl`.`colA` <= -999.99) +EXPLAIN SELECT * FROM double_5_2_tbl WHERE colA < -999.99; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_5_2_tbl`.`colA` AS `colA` from `test`.`double_5_2_tbl` where (`test`.`double_5_2_tbl`.`colA` < -999.99) +EXPLAIN SELECT * FROM double_5_2_tbl WHERE colA >= -999.99; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_5_2_tbl`.`colA` AS `colA` from `test`.`double_5_2_tbl` where (`test`.`double_5_2_tbl`.`colA` >= -999.99) +EXPLAIN SELECT * FROM double_5_2_tbl WHERE colA > -999.99; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_5_2_tbl`.`colA` AS `colA` from `test`.`double_5_2_tbl` where (`test`.`double_5_2_tbl`.`colA` > -999.99) +EXPLAIN SELECT * FROM double_5_2_tbl WHERE colA = -999.99; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE double_5_2_tbl NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_5_2_tbl`.`colA` AS `colA` from `test`.`double_5_2_tbl` where (`test`.`double_5_2_tbl`.`colA` = -999.99) +EXPLAIN SELECT * FROM double_5_2_tbl WHERE colA <> -999.99; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 90.00 Parallel execute (1 workers) +2 SIMPLE double_5_2_tbl NULL ALL NULL NULL NULL NULL 10 90.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_5_2_tbl`.`colA` AS `colA` from `test`.`double_5_2_tbl` where (`test`.`double_5_2_tbl`.`colA` <> -999.99) +EXPLAIN SELECT * FROM double_5_2_tbl WHERE colA <= -999.984; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_5_2_tbl`.`colA` AS `colA` from `test`.`double_5_2_tbl` where (`test`.`double_5_2_tbl`.`colA` < -999.98) +EXPLAIN SELECT * FROM double_5_2_tbl WHERE colA < -999.984; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_5_2_tbl`.`colA` AS `colA` from `test`.`double_5_2_tbl` where (`test`.`double_5_2_tbl`.`colA` < -999.98) +EXPLAIN SELECT * FROM double_5_2_tbl WHERE colA >= -999.984; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_5_2_tbl`.`colA` AS `colA` from `test`.`double_5_2_tbl` where (`test`.`double_5_2_tbl`.`colA` >= -999.98) +EXPLAIN SELECT * FROM double_5_2_tbl WHERE colA > -999.984; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_5_2_tbl`.`colA` AS `colA` from `test`.`double_5_2_tbl` where (`test`.`double_5_2_tbl`.`colA` >= -999.98) +EXPLAIN SELECT * FROM double_5_2_tbl WHERE colA = -999.984; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`double_5_2_tbl`.`colA` AS `colA` from `test`.`double_5_2_tbl` where false +EXPLAIN SELECT * FROM double_5_2_tbl WHERE colA <> -999.984; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 90.00 Parallel execute (1 workers) +2 SIMPLE double_5_2_tbl NULL ALL NULL NULL NULL NULL 10 90.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_5_2_tbl`.`colA` AS `colA` from `test`.`double_5_2_tbl` where (`test`.`double_5_2_tbl`.`colA` is not null) +EXPLAIN SELECT * FROM double_5_2_tbl WHERE colA <= -999.985; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_5_2_tbl`.`colA` AS `colA` from `test`.`double_5_2_tbl` where (`test`.`double_5_2_tbl`.`colA` <= -999.99) +EXPLAIN SELECT * FROM double_5_2_tbl WHERE colA < -999.985; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_5_2_tbl`.`colA` AS `colA` from `test`.`double_5_2_tbl` where (`test`.`double_5_2_tbl`.`colA` <= -999.99) +EXPLAIN SELECT * FROM double_5_2_tbl WHERE colA >= -999.985; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_5_2_tbl`.`colA` AS `colA` from `test`.`double_5_2_tbl` where (`test`.`double_5_2_tbl`.`colA` > -999.99) +EXPLAIN SELECT * FROM double_5_2_tbl WHERE colA > -999.985; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_5_2_tbl`.`colA` AS `colA` from `test`.`double_5_2_tbl` where (`test`.`double_5_2_tbl`.`colA` > -999.99) +EXPLAIN SELECT * FROM double_5_2_tbl WHERE colA = -999.985; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`double_5_2_tbl`.`colA` AS `colA` from `test`.`double_5_2_tbl` where false +EXPLAIN SELECT * FROM double_5_2_tbl WHERE colA <> -999.985; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 90.00 Parallel execute (1 workers) +2 SIMPLE double_5_2_tbl NULL ALL NULL NULL NULL NULL 10 90.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_5_2_tbl`.`colA` AS `colA` from `test`.`double_5_2_tbl` where (`test`.`double_5_2_tbl`.`colA` is not null) +EXPLAIN SELECT * FROM double_5_2_tbl WHERE colA <= -999.995; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`double_5_2_tbl`.`colA` AS `colA` from `test`.`double_5_2_tbl` where false +EXPLAIN SELECT * FROM double_5_2_tbl WHERE colA < -999.995; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`double_5_2_tbl`.`colA` AS `colA` from `test`.`double_5_2_tbl` where false +EXPLAIN SELECT * FROM double_5_2_tbl WHERE colA >= -999.995; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 90.00 Parallel execute (1 workers) +2 SIMPLE double_5_2_tbl NULL ALL NULL NULL NULL NULL 10 90.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_5_2_tbl`.`colA` AS `colA` from `test`.`double_5_2_tbl` where (`test`.`double_5_2_tbl`.`colA` is not null) +EXPLAIN SELECT * FROM double_5_2_tbl WHERE colA > -999.995; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 90.00 Parallel execute (1 workers) +2 SIMPLE double_5_2_tbl NULL ALL NULL NULL NULL NULL 10 90.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_5_2_tbl`.`colA` AS `colA` from `test`.`double_5_2_tbl` where (`test`.`double_5_2_tbl`.`colA` is not null) +EXPLAIN SELECT * FROM double_5_2_tbl WHERE colA = -999.995; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`double_5_2_tbl`.`colA` AS `colA` from `test`.`double_5_2_tbl` where false +EXPLAIN SELECT * FROM double_5_2_tbl WHERE colA <> -999.995; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 90.00 Parallel execute (1 workers) +2 SIMPLE double_5_2_tbl NULL ALL NULL NULL NULL NULL 10 90.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_5_2_tbl`.`colA` AS `colA` from `test`.`double_5_2_tbl` where (`test`.`double_5_2_tbl`.`colA` is not null) +EXPLAIN SELECT * FROM double_5_2_tbl WHERE colA <= -999.994; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_5_2_tbl`.`colA` AS `colA` from `test`.`double_5_2_tbl` where (`test`.`double_5_2_tbl`.`colA` < -999.99) +EXPLAIN SELECT * FROM double_5_2_tbl WHERE colA < -999.994; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_5_2_tbl`.`colA` AS `colA` from `test`.`double_5_2_tbl` where (`test`.`double_5_2_tbl`.`colA` < -999.99) +EXPLAIN SELECT * FROM double_5_2_tbl WHERE colA >= -999.994; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_5_2_tbl`.`colA` AS `colA` from `test`.`double_5_2_tbl` where (`test`.`double_5_2_tbl`.`colA` >= -999.99) +EXPLAIN SELECT * FROM double_5_2_tbl WHERE colA > -999.994; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_5_2_tbl`.`colA` AS `colA` from `test`.`double_5_2_tbl` where (`test`.`double_5_2_tbl`.`colA` >= -999.99) +EXPLAIN SELECT * FROM double_5_2_tbl WHERE colA = -999.994; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`double_5_2_tbl`.`colA` AS `colA` from `test`.`double_5_2_tbl` where false +EXPLAIN SELECT * FROM double_5_2_tbl WHERE colA <> -999.994; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 90.00 Parallel execute (1 workers) +2 SIMPLE double_5_2_tbl NULL ALL NULL NULL NULL NULL 10 90.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_5_2_tbl`.`colA` AS `colA` from `test`.`double_5_2_tbl` where (`test`.`double_5_2_tbl`.`colA` is not null) +EXPLAIN SELECT * FROM double_5_2_tbl WHERE colA <= 999.99; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_5_2_tbl`.`colA` AS `colA` from `test`.`double_5_2_tbl` where (`test`.`double_5_2_tbl`.`colA` <= 999.99) +EXPLAIN SELECT * FROM double_5_2_tbl WHERE colA < 999.99; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_5_2_tbl`.`colA` AS `colA` from `test`.`double_5_2_tbl` where (`test`.`double_5_2_tbl`.`colA` < 999.99) +EXPLAIN SELECT * FROM double_5_2_tbl WHERE colA >= 999.99; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_5_2_tbl`.`colA` AS `colA` from `test`.`double_5_2_tbl` where (`test`.`double_5_2_tbl`.`colA` >= 999.99) +EXPLAIN SELECT * FROM double_5_2_tbl WHERE colA > 999.99; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_5_2_tbl`.`colA` AS `colA` from `test`.`double_5_2_tbl` where (`test`.`double_5_2_tbl`.`colA` > 999.99) +EXPLAIN SELECT * FROM double_5_2_tbl WHERE colA = 999.99; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE double_5_2_tbl NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_5_2_tbl`.`colA` AS `colA` from `test`.`double_5_2_tbl` where (`test`.`double_5_2_tbl`.`colA` = 999.99) +EXPLAIN SELECT * FROM double_5_2_tbl WHERE colA <> 999.99; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 90.00 Parallel execute (1 workers) +2 SIMPLE double_5_2_tbl NULL ALL NULL NULL NULL NULL 10 90.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_5_2_tbl`.`colA` AS `colA` from `test`.`double_5_2_tbl` where (`test`.`double_5_2_tbl`.`colA` <> 999.99) +EXPLAIN SELECT * FROM double_5_2_tbl WHERE colA <= 999.984; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_5_2_tbl`.`colA` AS `colA` from `test`.`double_5_2_tbl` where (`test`.`double_5_2_tbl`.`colA` <= 999.98) +EXPLAIN SELECT * FROM double_5_2_tbl WHERE colA < 999.984; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_5_2_tbl`.`colA` AS `colA` from `test`.`double_5_2_tbl` where (`test`.`double_5_2_tbl`.`colA` <= 999.98) +EXPLAIN SELECT * FROM double_5_2_tbl WHERE colA >= 999.984; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_5_2_tbl`.`colA` AS `colA` from `test`.`double_5_2_tbl` where (`test`.`double_5_2_tbl`.`colA` > 999.98) +EXPLAIN SELECT * FROM double_5_2_tbl WHERE colA > 999.984; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_5_2_tbl`.`colA` AS `colA` from `test`.`double_5_2_tbl` where (`test`.`double_5_2_tbl`.`colA` > 999.98) +EXPLAIN SELECT * FROM double_5_2_tbl WHERE colA = 999.984; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`double_5_2_tbl`.`colA` AS `colA` from `test`.`double_5_2_tbl` where false +EXPLAIN SELECT * FROM double_5_2_tbl WHERE colA <> 999.984; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 90.00 Parallel execute (1 workers) +2 SIMPLE double_5_2_tbl NULL ALL NULL NULL NULL NULL 10 90.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_5_2_tbl`.`colA` AS `colA` from `test`.`double_5_2_tbl` where (`test`.`double_5_2_tbl`.`colA` is not null) +EXPLAIN SELECT * FROM double_5_2_tbl WHERE colA <= 999.985; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_5_2_tbl`.`colA` AS `colA` from `test`.`double_5_2_tbl` where (`test`.`double_5_2_tbl`.`colA` < 999.99) +EXPLAIN SELECT * FROM double_5_2_tbl WHERE colA < 999.985; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_5_2_tbl`.`colA` AS `colA` from `test`.`double_5_2_tbl` where (`test`.`double_5_2_tbl`.`colA` < 999.99) +EXPLAIN SELECT * FROM double_5_2_tbl WHERE colA >= 999.985; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_5_2_tbl`.`colA` AS `colA` from `test`.`double_5_2_tbl` where (`test`.`double_5_2_tbl`.`colA` >= 999.99) +EXPLAIN SELECT * FROM double_5_2_tbl WHERE colA > 999.985; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_5_2_tbl`.`colA` AS `colA` from `test`.`double_5_2_tbl` where (`test`.`double_5_2_tbl`.`colA` >= 999.99) +EXPLAIN SELECT * FROM double_5_2_tbl WHERE colA = 999.985; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`double_5_2_tbl`.`colA` AS `colA` from `test`.`double_5_2_tbl` where false +EXPLAIN SELECT * FROM double_5_2_tbl WHERE colA <> 999.985; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 90.00 Parallel execute (1 workers) +2 SIMPLE double_5_2_tbl NULL ALL NULL NULL NULL NULL 10 90.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_5_2_tbl`.`colA` AS `colA` from `test`.`double_5_2_tbl` where (`test`.`double_5_2_tbl`.`colA` is not null) +EXPLAIN SELECT * FROM double_5_2_tbl WHERE colA <= 999.994; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_5_2_tbl`.`colA` AS `colA` from `test`.`double_5_2_tbl` where (`test`.`double_5_2_tbl`.`colA` <= 999.99) +EXPLAIN SELECT * FROM double_5_2_tbl WHERE colA < 999.994; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_5_2_tbl`.`colA` AS `colA` from `test`.`double_5_2_tbl` where (`test`.`double_5_2_tbl`.`colA` <= 999.99) +Cf explanation of semantics here under the SELECT above. The operator +is modified here to get the same semantics: we need > instead of >= +since we truncate the constant to the allowed range +EXPLAIN SELECT * FROM double_5_2_tbl WHERE colA >= 999.994; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_5_2_tbl`.`colA` AS `colA` from `test`.`double_5_2_tbl` where (`test`.`double_5_2_tbl`.`colA` > 999.99) +EXPLAIN SELECT * FROM double_5_2_tbl WHERE colA > 999.994; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_5_2_tbl`.`colA` AS `colA` from `test`.`double_5_2_tbl` where (`test`.`double_5_2_tbl`.`colA` > 999.99) +EXPLAIN SELECT * FROM double_5_2_tbl WHERE colA = 999.994; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`double_5_2_tbl`.`colA` AS `colA` from `test`.`double_5_2_tbl` where false +EXPLAIN SELECT * FROM double_5_2_tbl WHERE colA <> 999.994; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 90.00 Parallel execute (1 workers) +2 SIMPLE double_5_2_tbl NULL ALL NULL NULL NULL NULL 10 90.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_5_2_tbl`.`colA` AS `colA` from `test`.`double_5_2_tbl` where (`test`.`double_5_2_tbl`.`colA` is not null) +EXPLAIN SELECT * FROM double_5_2_tbl WHERE colA <= 999.995; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 90.00 Parallel execute (1 workers) +2 SIMPLE double_5_2_tbl NULL ALL NULL NULL NULL NULL 10 90.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_5_2_tbl`.`colA` AS `colA` from `test`.`double_5_2_tbl` where (`test`.`double_5_2_tbl`.`colA` is not null) +EXPLAIN SELECT * FROM double_5_2_tbl WHERE colA < 999.995; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 90.00 Parallel execute (1 workers) +2 SIMPLE double_5_2_tbl NULL ALL NULL NULL NULL NULL 10 90.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_5_2_tbl`.`colA` AS `colA` from `test`.`double_5_2_tbl` where (`test`.`double_5_2_tbl`.`colA` is not null) +EXPLAIN SELECT * FROM double_5_2_tbl WHERE colA >= 999.995; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`double_5_2_tbl`.`colA` AS `colA` from `test`.`double_5_2_tbl` where false +EXPLAIN SELECT * FROM double_5_2_tbl WHERE colA > 999.995; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`double_5_2_tbl`.`colA` AS `colA` from `test`.`double_5_2_tbl` where false +EXPLAIN SELECT * FROM double_5_2_tbl WHERE colA = 999.995; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`double_5_2_tbl`.`colA` AS `colA` from `test`.`double_5_2_tbl` where false +EXPLAIN SELECT * FROM double_5_2_tbl WHERE colA <> 999.995; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 90.00 Parallel execute (1 workers) +2 SIMPLE double_5_2_tbl NULL ALL NULL NULL NULL NULL 10 90.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_5_2_tbl`.`colA` AS `colA` from `test`.`double_5_2_tbl` where (`test`.`double_5_2_tbl`.`colA` is not null) +DROP TABLE double_5_2_tbl; +CREATE TABLE f(f FLOAT); +INSERT INTO f VALUES (-1), (2); +SELECT * FROM f WHERE f >= '2 garbage'; +f +2 +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: '2 garbage' +DROP TABLE f; +# +# Tests with type DOUBLE against real constants +# +CREATE TABLE double_tbl (colA DOUBLE ); +INSERT INTO double_tbl VALUES (-1.7976931348623157E+308), (-1.7976931348623156E+308), +(-1.7976931348623156E+308), +( 3.3), (0.0), (3.3), +(1.7976931348623156E+308), +(1.7976931348623156E+308), (1.7976931348623157E+308), +(NULL); +ANALYZE TABLE double_tbl; +Table Op Msg_type Msg_text +test.double_tbl analyze status OK +SELECT * FROM double_tbl; +colA +-1.7976931348623157e308 +-1.7976931348623155e308 +-1.7976931348623155e308 +3.3 +0 +3.3 +1.7976931348623155e308 +1.7976931348623155e308 +1.7976931348623157e308 +NULL +SELECT * FROM double_tbl WHERE colA <= -1.7976931348623157E+308; +colA +-1.7976931348623157e308 +SELECT * FROM double_tbl WHERE colA < -1.7976931348623157E+308; +colA +SELECT * FROM double_tbl WHERE colA >= -1.7976931348623157E+308; +colA +-1.7976931348623157e308 +-1.7976931348623155e308 +-1.7976931348623155e308 +3.3 +0 +3.3 +1.7976931348623155e308 +1.7976931348623155e308 +1.7976931348623157e308 +SELECT * FROM double_tbl WHERE colA > -1.7976931348623157E+308; +colA +-1.7976931348623155e308 +-1.7976931348623155e308 +3.3 +0 +3.3 +1.7976931348623155e308 +1.7976931348623155e308 +1.7976931348623157e308 +SELECT * FROM double_tbl WHERE colA = -1.7976931348623157E+308; +colA +-1.7976931348623157e308 +SELECT * FROM double_tbl WHERE colA <> -1.7976931348623157E+308; +colA +-1.7976931348623155e308 +-1.7976931348623155e308 +3.3 +0 +3.3 +1.7976931348623155e308 +1.7976931348623155e308 +1.7976931348623157e308 +SELECT * FROM double_tbl WHERE colA <= -1.7976931348623156E+308; +colA +-1.7976931348623157e308 +-1.7976931348623155e308 +-1.7976931348623155e308 +SELECT * FROM double_tbl WHERE colA < -1.7976931348623156E+308; +colA +-1.7976931348623157e308 +SELECT * FROM double_tbl WHERE colA >= -1.7976931348623156E+308; +colA +-1.7976931348623155e308 +-1.7976931348623155e308 +3.3 +0 +3.3 +1.7976931348623155e308 +1.7976931348623155e308 +1.7976931348623157e308 +SELECT * FROM double_tbl WHERE colA > -1.7976931348623156E+308; +colA +3.3 +0 +3.3 +1.7976931348623155e308 +1.7976931348623155e308 +1.7976931348623157e308 +SELECT * FROM double_tbl WHERE colA = -1.7976931348623156E+308; +colA +-1.7976931348623155e308 +-1.7976931348623155e308 +SELECT * FROM double_tbl WHERE colA <> -1.7976931348623156E+308; +colA +-1.7976931348623157e308 +3.3 +0 +3.3 +1.7976931348623155e308 +1.7976931348623155e308 +1.7976931348623157e308 +SELECT * FROM double_tbl WHERE colA <= -1.7976931348623156E+308; +colA +-1.7976931348623157e308 +-1.7976931348623155e308 +-1.7976931348623155e308 +SELECT * FROM double_tbl WHERE colA < -1.7976931348623156E+308; +colA +-1.7976931348623157e308 +SELECT * FROM double_tbl WHERE colA >= -1.7976931348623156E+308; +colA +-1.7976931348623155e308 +-1.7976931348623155e308 +3.3 +0 +3.3 +1.7976931348623155e308 +1.7976931348623155e308 +1.7976931348623157e308 +SELECT * FROM double_tbl WHERE colA > -1.7976931348623156E+308; +colA +3.3 +0 +3.3 +1.7976931348623155e308 +1.7976931348623155e308 +1.7976931348623157e308 +SELECT * FROM double_tbl WHERE colA = -1.7976931348623156E+308; +colA +-1.7976931348623155e308 +-1.7976931348623155e308 +SELECT * FROM double_tbl WHERE colA <> -1.7976931348623156E+308; +colA +-1.7976931348623157e308 +3.3 +0 +3.3 +1.7976931348623155e308 +1.7976931348623155e308 +1.7976931348623157e308 +SELECT * FROM double_tbl WHERE colA <= -1.7976931348623157E+308; +colA +-1.7976931348623157e308 +SELECT * FROM double_tbl WHERE colA < -1.7976931348623157E+308; +colA +SELECT * FROM double_tbl WHERE colA >= -1.7976931348623157E+308; +colA +-1.7976931348623157e308 +-1.7976931348623155e308 +-1.7976931348623155e308 +3.3 +0 +3.3 +1.7976931348623155e308 +1.7976931348623155e308 +1.7976931348623157e308 +SELECT * FROM double_tbl WHERE colA > -1.7976931348623157E+308; +colA +-1.7976931348623155e308 +-1.7976931348623155e308 +3.3 +0 +3.3 +1.7976931348623155e308 +1.7976931348623155e308 +1.7976931348623157e308 +SELECT * FROM double_tbl WHERE colA = -1.7976931348623157E+308; +colA +-1.7976931348623157e308 +SELECT * FROM double_tbl WHERE colA <> -1.7976931348623157E+308; +colA +-1.7976931348623155e308 +-1.7976931348623155e308 +3.3 +0 +3.3 +1.7976931348623155e308 +1.7976931348623155e308 +1.7976931348623157e308 +SELECT * FROM double_tbl WHERE colA <= -1.7976931348623157E+308; +colA +-1.7976931348623157e308 +SELECT * FROM double_tbl WHERE colA < -1.7976931348623157E+308; +colA +SELECT * FROM double_tbl WHERE colA >= -1.7976931348623157E+308; +colA +-1.7976931348623157e308 +-1.7976931348623155e308 +-1.7976931348623155e308 +3.3 +0 +3.3 +1.7976931348623155e308 +1.7976931348623155e308 +1.7976931348623157e308 +SELECT * FROM double_tbl WHERE colA > -1.7976931348623157E+308; +colA +-1.7976931348623155e308 +-1.7976931348623155e308 +3.3 +0 +3.3 +1.7976931348623155e308 +1.7976931348623155e308 +1.7976931348623157e308 +SELECT * FROM double_tbl WHERE colA = -1.7976931348623157E+308; +colA +-1.7976931348623157e308 +SELECT * FROM double_tbl WHERE colA <> -1.7976931348623157E+308; +colA +-1.7976931348623155e308 +-1.7976931348623155e308 +3.3 +0 +3.3 +1.7976931348623155e308 +1.7976931348623155e308 +1.7976931348623157e308 +SELECT * FROM double_tbl WHERE colA <= 1.7976931348623157E+308; +colA +-1.7976931348623157e308 +-1.7976931348623155e308 +-1.7976931348623155e308 +3.3 +0 +3.3 +1.7976931348623155e308 +1.7976931348623155e308 +1.7976931348623157e308 +SELECT * FROM double_tbl WHERE colA < 1.7976931348623157E+308; +colA +-1.7976931348623157e308 +-1.7976931348623155e308 +-1.7976931348623155e308 +3.3 +0 +3.3 +1.7976931348623155e308 +1.7976931348623155e308 +SELECT * FROM double_tbl WHERE colA >= 1.7976931348623157E+308; +colA +1.7976931348623157e308 +SELECT * FROM double_tbl WHERE colA > 1.7976931348623157E+308; +colA +SELECT * FROM double_tbl WHERE colA = 1.7976931348623157E+308; +colA +1.7976931348623157e308 +SELECT * FROM double_tbl WHERE colA <> 1.7976931348623157E+308; +colA +-1.7976931348623157e308 +-1.7976931348623155e308 +-1.7976931348623155e308 +3.3 +0 +3.3 +1.7976931348623155e308 +1.7976931348623155e308 +SELECT * FROM double_tbl WHERE colA <= 1.7976931348623156E+308; +colA +-1.7976931348623157e308 +-1.7976931348623155e308 +-1.7976931348623155e308 +3.3 +0 +3.3 +1.7976931348623155e308 +1.7976931348623155e308 +SELECT * FROM double_tbl WHERE colA < 1.7976931348623156E+308; +colA +-1.7976931348623157e308 +-1.7976931348623155e308 +-1.7976931348623155e308 +3.3 +0 +3.3 +SELECT * FROM double_tbl WHERE colA >= 1.7976931348623156E+308; +colA +1.7976931348623155e308 +1.7976931348623155e308 +1.7976931348623157e308 +SELECT * FROM double_tbl WHERE colA > 1.7976931348623156E+308; +colA +1.7976931348623157e308 +SELECT * FROM double_tbl WHERE colA = 1.7976931348623156E+308; +colA +1.7976931348623155e308 +1.7976931348623155e308 +SELECT * FROM double_tbl WHERE colA <> 1.7976931348623156E+308; +colA +-1.7976931348623157e308 +-1.7976931348623155e308 +-1.7976931348623155e308 +3.3 +0 +3.3 +1.7976931348623157e308 +SELECT * FROM double_tbl WHERE colA <= 1.7976931348623156E+308; +colA +-1.7976931348623157e308 +-1.7976931348623155e308 +-1.7976931348623155e308 +3.3 +0 +3.3 +1.7976931348623155e308 +1.7976931348623155e308 +SELECT * FROM double_tbl WHERE colA < 1.7976931348623156E+308; +colA +-1.7976931348623157e308 +-1.7976931348623155e308 +-1.7976931348623155e308 +3.3 +0 +3.3 +SELECT * FROM double_tbl WHERE colA >= 1.7976931348623156E+308; +colA +1.7976931348623155e308 +1.7976931348623155e308 +1.7976931348623157e308 +SELECT * FROM double_tbl WHERE colA > 1.7976931348623156E+308; +colA +1.7976931348623157e308 +SELECT * FROM double_tbl WHERE colA = 1.7976931348623156E+308; +colA +1.7976931348623155e308 +1.7976931348623155e308 +SELECT * FROM double_tbl WHERE colA <> 1.7976931348623156E+308; +colA +-1.7976931348623157e308 +-1.7976931348623155e308 +-1.7976931348623155e308 +3.3 +0 +3.3 +1.7976931348623157e308 +SELECT * FROM double_tbl WHERE colA <= 1.7976931348623157E+308; +colA +-1.7976931348623157e308 +-1.7976931348623155e308 +-1.7976931348623155e308 +3.3 +0 +3.3 +1.7976931348623155e308 +1.7976931348623155e308 +1.7976931348623157e308 +SELECT * FROM double_tbl WHERE colA < 1.7976931348623157E+308; +colA +-1.7976931348623157e308 +-1.7976931348623155e308 +-1.7976931348623155e308 +3.3 +0 +3.3 +1.7976931348623155e308 +1.7976931348623155e308 +Result here can be empty set, because MySQL performs operation in +double, e.g. colA >= 999.994 for FLOAT(5,2): +executes as nnn.nn0 >= 999.994, i.e. the .994 isn't truncated +to .99 before comparison +SELECT * FROM double_tbl WHERE colA >= 1.7976931348623157E+308; +colA +1.7976931348623157e308 +SELECT * FROM double_tbl WHERE colA > 1.7976931348623157E+308; +colA +SELECT * FROM double_tbl WHERE colA = 1.7976931348623157E+308; +colA +1.7976931348623157e308 +SELECT * FROM double_tbl WHERE colA <> 1.7976931348623157E+308; +colA +-1.7976931348623157e308 +-1.7976931348623155e308 +-1.7976931348623155e308 +3.3 +0 +3.3 +1.7976931348623155e308 +1.7976931348623155e308 +SELECT * FROM double_tbl WHERE colA <= 1.7976931348623157E+308; +colA +-1.7976931348623157e308 +-1.7976931348623155e308 +-1.7976931348623155e308 +3.3 +0 +3.3 +1.7976931348623155e308 +1.7976931348623155e308 +1.7976931348623157e308 +SELECT * FROM double_tbl WHERE colA < 1.7976931348623157E+308; +colA +-1.7976931348623157e308 +-1.7976931348623155e308 +-1.7976931348623155e308 +3.3 +0 +3.3 +1.7976931348623155e308 +1.7976931348623155e308 +SELECT * FROM double_tbl WHERE colA >= 1.7976931348623157E+308; +colA +1.7976931348623157e308 +SELECT * FROM double_tbl WHERE colA > 1.7976931348623157E+308; +colA +SELECT * FROM double_tbl WHERE colA = 1.7976931348623157E+308; +colA +1.7976931348623157e308 +SELECT * FROM double_tbl WHERE colA <> 1.7976931348623157E+308; +colA +-1.7976931348623157e308 +-1.7976931348623155e308 +-1.7976931348623155e308 +3.3 +0 +3.3 +1.7976931348623155e308 +1.7976931348623155e308 +EXPLAIN SELECT * FROM double_tbl WHERE colA <= -1.7976931348623157E+308; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` <= -1.797693134862316e308) +EXPLAIN SELECT * FROM double_tbl WHERE colA < -1.7976931348623157E+308; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` < -1.797693134862316e308) +EXPLAIN SELECT * FROM double_tbl WHERE colA >= -1.7976931348623157E+308; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` >= -1.797693134862316e308) +EXPLAIN SELECT * FROM double_tbl WHERE colA > -1.7976931348623157E+308; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` > -1.797693134862316e308) +EXPLAIN SELECT * FROM double_tbl WHERE colA = -1.7976931348623157E+308; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` = -1.797693134862316e308) +EXPLAIN SELECT * FROM double_tbl WHERE colA <> -1.7976931348623157E+308; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 90.00 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 90.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` <> -1.797693134862316e308) +EXPLAIN SELECT * FROM double_tbl WHERE colA <= -1.7976931348623156E+308; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` <= -1.797693134862316e308) +EXPLAIN SELECT * FROM double_tbl WHERE colA < -1.7976931348623156E+308; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` < -1.797693134862316e308) +EXPLAIN SELECT * FROM double_tbl WHERE colA >= -1.7976931348623156E+308; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` >= -1.797693134862316e308) +EXPLAIN SELECT * FROM double_tbl WHERE colA > -1.7976931348623156E+308; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` > -1.797693134862316e308) +EXPLAIN SELECT * FROM double_tbl WHERE colA = -1.7976931348623156E+308; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` = -1.797693134862316e308) +EXPLAIN SELECT * FROM double_tbl WHERE colA <> -1.7976931348623156E+308; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 90.00 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 90.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` <> -1.797693134862316e308) +EXPLAIN SELECT * FROM double_tbl WHERE colA <= -1.7976931348623156E+308; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` <= -1.797693134862316e308) +EXPLAIN SELECT * FROM double_tbl WHERE colA < -1.7976931348623156E+308; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` < -1.797693134862316e308) +EXPLAIN SELECT * FROM double_tbl WHERE colA >= -1.7976931348623156E+308; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` >= -1.797693134862316e308) +EXPLAIN SELECT * FROM double_tbl WHERE colA > -1.7976931348623156E+308; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` > -1.797693134862316e308) +EXPLAIN SELECT * FROM double_tbl WHERE colA = -1.7976931348623156E+308; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` = -1.797693134862316e308) +EXPLAIN SELECT * FROM double_tbl WHERE colA <> -1.7976931348623156E+308; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 90.00 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 90.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` <> -1.797693134862316e308) +EXPLAIN SELECT * FROM double_tbl WHERE colA <= -1.7976931348623157E+308; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` <= -1.797693134862316e308) +EXPLAIN SELECT * FROM double_tbl WHERE colA < -1.7976931348623157E+308; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` < -1.797693134862316e308) +EXPLAIN SELECT * FROM double_tbl WHERE colA >= -1.7976931348623157E+308; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` >= -1.797693134862316e308) +EXPLAIN SELECT * FROM double_tbl WHERE colA > -1.7976931348623157E+308; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` > -1.797693134862316e308) +EXPLAIN SELECT * FROM double_tbl WHERE colA = -1.7976931348623157E+308; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` = -1.797693134862316e308) +EXPLAIN SELECT * FROM double_tbl WHERE colA <> -1.7976931348623157E+308; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 90.00 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 90.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` <> -1.797693134862316e308) +EXPLAIN SELECT * FROM double_tbl WHERE colA <= -1.7976931348623157E+308; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` <= -1.797693134862316e308) +EXPLAIN SELECT * FROM double_tbl WHERE colA < -1.7976931348623157E+308; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` < -1.797693134862316e308) +EXPLAIN SELECT * FROM double_tbl WHERE colA >= -1.7976931348623157E+308; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` >= -1.797693134862316e308) +EXPLAIN SELECT * FROM double_tbl WHERE colA > -1.7976931348623157E+308; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` > -1.797693134862316e308) +EXPLAIN SELECT * FROM double_tbl WHERE colA = -1.7976931348623157E+308; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` = -1.797693134862316e308) +EXPLAIN SELECT * FROM double_tbl WHERE colA <> -1.7976931348623157E+308; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 90.00 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 90.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` <> -1.797693134862316e308) +EXPLAIN SELECT * FROM double_tbl WHERE colA <= 1.7976931348623157E+308; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` <= 1.7976931348623157E+308) +EXPLAIN SELECT * FROM double_tbl WHERE colA < 1.7976931348623157E+308; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` < 1.7976931348623157E+308) +EXPLAIN SELECT * FROM double_tbl WHERE colA >= 1.7976931348623157E+308; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` >= 1.7976931348623157E+308) +EXPLAIN SELECT * FROM double_tbl WHERE colA > 1.7976931348623157E+308; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` > 1.7976931348623157E+308) +EXPLAIN SELECT * FROM double_tbl WHERE colA = 1.7976931348623157E+308; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` = 1.7976931348623157E+308) +EXPLAIN SELECT * FROM double_tbl WHERE colA <> 1.7976931348623157E+308; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 90.00 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 90.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` <> 1.7976931348623157E+308) +EXPLAIN SELECT * FROM double_tbl WHERE colA <= 1.7976931348623156E+308; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` <= 1.7976931348623156E+308) +EXPLAIN SELECT * FROM double_tbl WHERE colA < 1.7976931348623156E+308; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` < 1.7976931348623156E+308) +EXPLAIN SELECT * FROM double_tbl WHERE colA >= 1.7976931348623156E+308; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` >= 1.7976931348623156E+308) +EXPLAIN SELECT * FROM double_tbl WHERE colA > 1.7976931348623156E+308; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` > 1.7976931348623156E+308) +EXPLAIN SELECT * FROM double_tbl WHERE colA = 1.7976931348623156E+308; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` = 1.7976931348623156E+308) +EXPLAIN SELECT * FROM double_tbl WHERE colA <> 1.7976931348623156E+308; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 90.00 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 90.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` <> 1.7976931348623156E+308) +EXPLAIN SELECT * FROM double_tbl WHERE colA <= 1.7976931348623156E+308; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` <= 1.7976931348623156E+308) +EXPLAIN SELECT * FROM double_tbl WHERE colA < 1.7976931348623156E+308; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` < 1.7976931348623156E+308) +EXPLAIN SELECT * FROM double_tbl WHERE colA >= 1.7976931348623156E+308; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` >= 1.7976931348623156E+308) +EXPLAIN SELECT * FROM double_tbl WHERE colA > 1.7976931348623156E+308; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` > 1.7976931348623156E+308) +EXPLAIN SELECT * FROM double_tbl WHERE colA = 1.7976931348623156E+308; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` = 1.7976931348623156E+308) +EXPLAIN SELECT * FROM double_tbl WHERE colA <> 1.7976931348623156E+308; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 90.00 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 90.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` <> 1.7976931348623156E+308) +EXPLAIN SELECT * FROM double_tbl WHERE colA <= 1.7976931348623157E+308; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` <= 1.7976931348623157E+308) +EXPLAIN SELECT * FROM double_tbl WHERE colA < 1.7976931348623157E+308; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` < 1.7976931348623157E+308) +Cf explanation of semantics here under the SELECT above. The operator +is modified here to get the same semantics: we need > instead of >= +since we truncate the constant to the allowed range +EXPLAIN SELECT * FROM double_tbl WHERE colA >= 1.7976931348623157E+308; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` >= 1.7976931348623157E+308) +EXPLAIN SELECT * FROM double_tbl WHERE colA > 1.7976931348623157E+308; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` > 1.7976931348623157E+308) +EXPLAIN SELECT * FROM double_tbl WHERE colA = 1.7976931348623157E+308; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` = 1.7976931348623157E+308) +EXPLAIN SELECT * FROM double_tbl WHERE colA <> 1.7976931348623157E+308; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 90.00 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 90.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` <> 1.7976931348623157E+308) +EXPLAIN SELECT * FROM double_tbl WHERE colA <= 1.7976931348623157E+308; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` <= 1.7976931348623157E+308) +EXPLAIN SELECT * FROM double_tbl WHERE colA < 1.7976931348623157E+308; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` < 1.7976931348623157E+308) +EXPLAIN SELECT * FROM double_tbl WHERE colA >= 1.7976931348623157E+308; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` >= 1.7976931348623157E+308) +EXPLAIN SELECT * FROM double_tbl WHERE colA > 1.7976931348623157E+308; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` > 1.7976931348623157E+308) +EXPLAIN SELECT * FROM double_tbl WHERE colA = 1.7976931348623157E+308; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` = 1.7976931348623157E+308) +EXPLAIN SELECT * FROM double_tbl WHERE colA <> 1.7976931348623157E+308; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 90.00 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 90.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` <> 1.7976931348623157E+308) +DROP TABLE double_tbl; +CREATE TABLE f(f FLOAT); +INSERT INTO f VALUES (-1), (2); +SELECT * FROM f WHERE f >= '2 garbage'; +f +2 +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: '2 garbage' +DROP TABLE f; +# +# Tests with type DOUBLE against real constants +# +CREATE TABLE double_tbl (colA DOUBLE ); +INSERT INTO double_tbl VALUES ('-1.7976931348623157E+308'), ('-1.7976931348623156E+308'), +('-1.7976931348623156E+308'), +( 3.3), (0.0), (3.3), +('1.7976931348623156E+308'), +('1.7976931348623156E+308'), ('1.7976931348623157E+308'), +(NULL); +ANALYZE TABLE double_tbl; +Table Op Msg_type Msg_text +test.double_tbl analyze status OK +SELECT * FROM double_tbl; +colA +-1.7976931348623157e308 +-1.7976931348623155e308 +-1.7976931348623155e308 +3.3 +0 +3.3 +1.7976931348623155e308 +1.7976931348623155e308 +1.7976931348623157e308 +NULL +SELECT * FROM double_tbl WHERE colA <= '-1.7976931348623157E+308'; +colA +-1.7976931348623157e308 +SELECT * FROM double_tbl WHERE colA < '-1.7976931348623157E+308'; +colA +SELECT * FROM double_tbl WHERE colA >= '-1.7976931348623157E+308'; +colA +-1.7976931348623157e308 +-1.7976931348623155e308 +-1.7976931348623155e308 +3.3 +0 +3.3 +1.7976931348623155e308 +1.7976931348623155e308 +1.7976931348623157e308 +SELECT * FROM double_tbl WHERE colA > '-1.7976931348623157E+308'; +colA +-1.7976931348623155e308 +-1.7976931348623155e308 +3.3 +0 +3.3 +1.7976931348623155e308 +1.7976931348623155e308 +1.7976931348623157e308 +SELECT * FROM double_tbl WHERE colA = '-1.7976931348623157E+308'; +colA +-1.7976931348623157e308 +SELECT * FROM double_tbl WHERE colA <> '-1.7976931348623157E+308'; +colA +-1.7976931348623155e308 +-1.7976931348623155e308 +3.3 +0 +3.3 +1.7976931348623155e308 +1.7976931348623155e308 +1.7976931348623157e308 +SELECT * FROM double_tbl WHERE colA <= '-1.7976931348623156E+308'; +colA +-1.7976931348623157e308 +-1.7976931348623155e308 +-1.7976931348623155e308 +SELECT * FROM double_tbl WHERE colA < '-1.7976931348623156E+308'; +colA +-1.7976931348623157e308 +SELECT * FROM double_tbl WHERE colA >= '-1.7976931348623156E+308'; +colA +-1.7976931348623155e308 +-1.7976931348623155e308 +3.3 +0 +3.3 +1.7976931348623155e308 +1.7976931348623155e308 +1.7976931348623157e308 +SELECT * FROM double_tbl WHERE colA > '-1.7976931348623156E+308'; +colA +3.3 +0 +3.3 +1.7976931348623155e308 +1.7976931348623155e308 +1.7976931348623157e308 +SELECT * FROM double_tbl WHERE colA = '-1.7976931348623156E+308'; +colA +-1.7976931348623155e308 +-1.7976931348623155e308 +SELECT * FROM double_tbl WHERE colA <> '-1.7976931348623156E+308'; +colA +-1.7976931348623157e308 +3.3 +0 +3.3 +1.7976931348623155e308 +1.7976931348623155e308 +1.7976931348623157e308 +SELECT * FROM double_tbl WHERE colA <= '-1.7976931348623156E+308'; +colA +-1.7976931348623157e308 +-1.7976931348623155e308 +-1.7976931348623155e308 +SELECT * FROM double_tbl WHERE colA < '-1.7976931348623156E+308'; +colA +-1.7976931348623157e308 +SELECT * FROM double_tbl WHERE colA >= '-1.7976931348623156E+308'; +colA +-1.7976931348623155e308 +-1.7976931348623155e308 +3.3 +0 +3.3 +1.7976931348623155e308 +1.7976931348623155e308 +1.7976931348623157e308 +SELECT * FROM double_tbl WHERE colA > '-1.7976931348623156E+308'; +colA +3.3 +0 +3.3 +1.7976931348623155e308 +1.7976931348623155e308 +1.7976931348623157e308 +SELECT * FROM double_tbl WHERE colA = '-1.7976931348623156E+308'; +colA +-1.7976931348623155e308 +-1.7976931348623155e308 +SELECT * FROM double_tbl WHERE colA <> '-1.7976931348623156E+308'; +colA +-1.7976931348623157e308 +3.3 +0 +3.3 +1.7976931348623155e308 +1.7976931348623155e308 +1.7976931348623157e308 +SELECT * FROM double_tbl WHERE colA <= '-1.7976931348623157E+308'; +colA +-1.7976931348623157e308 +SELECT * FROM double_tbl WHERE colA < '-1.7976931348623157E+308'; +colA +SELECT * FROM double_tbl WHERE colA >= '-1.7976931348623157E+308'; +colA +-1.7976931348623157e308 +-1.7976931348623155e308 +-1.7976931348623155e308 +3.3 +0 +3.3 +1.7976931348623155e308 +1.7976931348623155e308 +1.7976931348623157e308 +SELECT * FROM double_tbl WHERE colA > '-1.7976931348623157E+308'; +colA +-1.7976931348623155e308 +-1.7976931348623155e308 +3.3 +0 +3.3 +1.7976931348623155e308 +1.7976931348623155e308 +1.7976931348623157e308 +SELECT * FROM double_tbl WHERE colA = '-1.7976931348623157E+308'; +colA +-1.7976931348623157e308 +SELECT * FROM double_tbl WHERE colA <> '-1.7976931348623157E+308'; +colA +-1.7976931348623155e308 +-1.7976931348623155e308 +3.3 +0 +3.3 +1.7976931348623155e308 +1.7976931348623155e308 +1.7976931348623157e308 +SELECT * FROM double_tbl WHERE colA <= '-1.7976931348623157E+308'; +colA +-1.7976931348623157e308 +SELECT * FROM double_tbl WHERE colA < '-1.7976931348623157E+308'; +colA +SELECT * FROM double_tbl WHERE colA >= '-1.7976931348623157E+308'; +colA +-1.7976931348623157e308 +-1.7976931348623155e308 +-1.7976931348623155e308 +3.3 +0 +3.3 +1.7976931348623155e308 +1.7976931348623155e308 +1.7976931348623157e308 +SELECT * FROM double_tbl WHERE colA > '-1.7976931348623157E+308'; +colA +-1.7976931348623155e308 +-1.7976931348623155e308 +3.3 +0 +3.3 +1.7976931348623155e308 +1.7976931348623155e308 +1.7976931348623157e308 +SELECT * FROM double_tbl WHERE colA = '-1.7976931348623157E+308'; +colA +-1.7976931348623157e308 +SELECT * FROM double_tbl WHERE colA <> '-1.7976931348623157E+308'; +colA +-1.7976931348623155e308 +-1.7976931348623155e308 +3.3 +0 +3.3 +1.7976931348623155e308 +1.7976931348623155e308 +1.7976931348623157e308 +SELECT * FROM double_tbl WHERE colA <= '1.7976931348623157E+308'; +colA +-1.7976931348623157e308 +-1.7976931348623155e308 +-1.7976931348623155e308 +3.3 +0 +3.3 +1.7976931348623155e308 +1.7976931348623155e308 +1.7976931348623157e308 +SELECT * FROM double_tbl WHERE colA < '1.7976931348623157E+308'; +colA +-1.7976931348623157e308 +-1.7976931348623155e308 +-1.7976931348623155e308 +3.3 +0 +3.3 +1.7976931348623155e308 +1.7976931348623155e308 +SELECT * FROM double_tbl WHERE colA >= '1.7976931348623157E+308'; +colA +1.7976931348623157e308 +SELECT * FROM double_tbl WHERE colA > '1.7976931348623157E+308'; +colA +SELECT * FROM double_tbl WHERE colA = '1.7976931348623157E+308'; +colA +1.7976931348623157e308 +SELECT * FROM double_tbl WHERE colA <> '1.7976931348623157E+308'; +colA +-1.7976931348623157e308 +-1.7976931348623155e308 +-1.7976931348623155e308 +3.3 +0 +3.3 +1.7976931348623155e308 +1.7976931348623155e308 +SELECT * FROM double_tbl WHERE colA <= '1.7976931348623156E+308'; +colA +-1.7976931348623157e308 +-1.7976931348623155e308 +-1.7976931348623155e308 +3.3 +0 +3.3 +1.7976931348623155e308 +1.7976931348623155e308 +SELECT * FROM double_tbl WHERE colA < '1.7976931348623156E+308'; +colA +-1.7976931348623157e308 +-1.7976931348623155e308 +-1.7976931348623155e308 +3.3 +0 +3.3 +SELECT * FROM double_tbl WHERE colA >= '1.7976931348623156E+308'; +colA +1.7976931348623155e308 +1.7976931348623155e308 +1.7976931348623157e308 +SELECT * FROM double_tbl WHERE colA > '1.7976931348623156E+308'; +colA +1.7976931348623157e308 +SELECT * FROM double_tbl WHERE colA = '1.7976931348623156E+308'; +colA +1.7976931348623155e308 +1.7976931348623155e308 +SELECT * FROM double_tbl WHERE colA <> '1.7976931348623156E+308'; +colA +-1.7976931348623157e308 +-1.7976931348623155e308 +-1.7976931348623155e308 +3.3 +0 +3.3 +1.7976931348623157e308 +SELECT * FROM double_tbl WHERE colA <= '1.7976931348623156E+308'; +colA +-1.7976931348623157e308 +-1.7976931348623155e308 +-1.7976931348623155e308 +3.3 +0 +3.3 +1.7976931348623155e308 +1.7976931348623155e308 +SELECT * FROM double_tbl WHERE colA < '1.7976931348623156E+308'; +colA +-1.7976931348623157e308 +-1.7976931348623155e308 +-1.7976931348623155e308 +3.3 +0 +3.3 +SELECT * FROM double_tbl WHERE colA >= '1.7976931348623156E+308'; +colA +1.7976931348623155e308 +1.7976931348623155e308 +1.7976931348623157e308 +SELECT * FROM double_tbl WHERE colA > '1.7976931348623156E+308'; +colA +1.7976931348623157e308 +SELECT * FROM double_tbl WHERE colA = '1.7976931348623156E+308'; +colA +1.7976931348623155e308 +1.7976931348623155e308 +SELECT * FROM double_tbl WHERE colA <> '1.7976931348623156E+308'; +colA +-1.7976931348623157e308 +-1.7976931348623155e308 +-1.7976931348623155e308 +3.3 +0 +3.3 +1.7976931348623157e308 +SELECT * FROM double_tbl WHERE colA <= '1.7976931348623157E+308'; +colA +-1.7976931348623157e308 +-1.7976931348623155e308 +-1.7976931348623155e308 +3.3 +0 +3.3 +1.7976931348623155e308 +1.7976931348623155e308 +1.7976931348623157e308 +SELECT * FROM double_tbl WHERE colA < '1.7976931348623157E+308'; +colA +-1.7976931348623157e308 +-1.7976931348623155e308 +-1.7976931348623155e308 +3.3 +0 +3.3 +1.7976931348623155e308 +1.7976931348623155e308 +Result here can be empty set, because MySQL performs operation in +double, e.g. colA >= 999.994 for FLOAT(5,2): +executes as nnn.nn0 >= 999.994, i.e. the .994 isn't truncated +to .99 before comparison +SELECT * FROM double_tbl WHERE colA >= '1.7976931348623157E+308'; +colA +1.7976931348623157e308 +SELECT * FROM double_tbl WHERE colA > '1.7976931348623157E+308'; +colA +SELECT * FROM double_tbl WHERE colA = '1.7976931348623157E+308'; +colA +1.7976931348623157e308 +SELECT * FROM double_tbl WHERE colA <> '1.7976931348623157E+308'; +colA +-1.7976931348623157e308 +-1.7976931348623155e308 +-1.7976931348623155e308 +3.3 +0 +3.3 +1.7976931348623155e308 +1.7976931348623155e308 +SELECT * FROM double_tbl WHERE colA <= '1.7976931348623157E+308'; +colA +-1.7976931348623157e308 +-1.7976931348623155e308 +-1.7976931348623155e308 +3.3 +0 +3.3 +1.7976931348623155e308 +1.7976931348623155e308 +1.7976931348623157e308 +SELECT * FROM double_tbl WHERE colA < '1.7976931348623157E+308'; +colA +-1.7976931348623157e308 +-1.7976931348623155e308 +-1.7976931348623155e308 +3.3 +0 +3.3 +1.7976931348623155e308 +1.7976931348623155e308 +SELECT * FROM double_tbl WHERE colA >= '1.7976931348623157E+308'; +colA +1.7976931348623157e308 +SELECT * FROM double_tbl WHERE colA > '1.7976931348623157E+308'; +colA +SELECT * FROM double_tbl WHERE colA = '1.7976931348623157E+308'; +colA +1.7976931348623157e308 +SELECT * FROM double_tbl WHERE colA <> '1.7976931348623157E+308'; +colA +-1.7976931348623157e308 +-1.7976931348623155e308 +-1.7976931348623155e308 +3.3 +0 +3.3 +1.7976931348623155e308 +1.7976931348623155e308 +EXPLAIN SELECT * FROM double_tbl WHERE colA <= '-1.7976931348623157E+308'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` <= -1.797693134862316e308) +EXPLAIN SELECT * FROM double_tbl WHERE colA < '-1.7976931348623157E+308'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` < -1.797693134862316e308) +EXPLAIN SELECT * FROM double_tbl WHERE colA >= '-1.7976931348623157E+308'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` >= -1.797693134862316e308) +EXPLAIN SELECT * FROM double_tbl WHERE colA > '-1.7976931348623157E+308'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` > -1.797693134862316e308) +EXPLAIN SELECT * FROM double_tbl WHERE colA = '-1.7976931348623157E+308'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` = -1.797693134862316e308) +EXPLAIN SELECT * FROM double_tbl WHERE colA <> '-1.7976931348623157E+308'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 90.00 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 90.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` <> -1.797693134862316e308) +EXPLAIN SELECT * FROM double_tbl WHERE colA <= '-1.7976931348623156E+308'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` <= -1.797693134862316e308) +EXPLAIN SELECT * FROM double_tbl WHERE colA < '-1.7976931348623156E+308'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` < -1.797693134862316e308) +EXPLAIN SELECT * FROM double_tbl WHERE colA >= '-1.7976931348623156E+308'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` >= -1.797693134862316e308) +EXPLAIN SELECT * FROM double_tbl WHERE colA > '-1.7976931348623156E+308'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` > -1.797693134862316e308) +EXPLAIN SELECT * FROM double_tbl WHERE colA = '-1.7976931348623156E+308'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` = -1.797693134862316e308) +EXPLAIN SELECT * FROM double_tbl WHERE colA <> '-1.7976931348623156E+308'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 90.00 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 90.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` <> -1.797693134862316e308) +EXPLAIN SELECT * FROM double_tbl WHERE colA <= '-1.7976931348623156E+308'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` <= -1.797693134862316e308) +EXPLAIN SELECT * FROM double_tbl WHERE colA < '-1.7976931348623156E+308'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` < -1.797693134862316e308) +EXPLAIN SELECT * FROM double_tbl WHERE colA >= '-1.7976931348623156E+308'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` >= -1.797693134862316e308) +EXPLAIN SELECT * FROM double_tbl WHERE colA > '-1.7976931348623156E+308'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` > -1.797693134862316e308) +EXPLAIN SELECT * FROM double_tbl WHERE colA = '-1.7976931348623156E+308'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` = -1.797693134862316e308) +EXPLAIN SELECT * FROM double_tbl WHERE colA <> '-1.7976931348623156E+308'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 90.00 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 90.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` <> -1.797693134862316e308) +EXPLAIN SELECT * FROM double_tbl WHERE colA <= '-1.7976931348623157E+308'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` <= -1.797693134862316e308) +EXPLAIN SELECT * FROM double_tbl WHERE colA < '-1.7976931348623157E+308'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` < -1.797693134862316e308) +EXPLAIN SELECT * FROM double_tbl WHERE colA >= '-1.7976931348623157E+308'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` >= -1.797693134862316e308) +EXPLAIN SELECT * FROM double_tbl WHERE colA > '-1.7976931348623157E+308'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` > -1.797693134862316e308) +EXPLAIN SELECT * FROM double_tbl WHERE colA = '-1.7976931348623157E+308'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` = -1.797693134862316e308) +EXPLAIN SELECT * FROM double_tbl WHERE colA <> '-1.7976931348623157E+308'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 90.00 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 90.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` <> -1.797693134862316e308) +EXPLAIN SELECT * FROM double_tbl WHERE colA <= '-1.7976931348623157E+308'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` <= -1.797693134862316e308) +EXPLAIN SELECT * FROM double_tbl WHERE colA < '-1.7976931348623157E+308'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` < -1.797693134862316e308) +EXPLAIN SELECT * FROM double_tbl WHERE colA >= '-1.7976931348623157E+308'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` >= -1.797693134862316e308) +EXPLAIN SELECT * FROM double_tbl WHERE colA > '-1.7976931348623157E+308'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` > -1.797693134862316e308) +EXPLAIN SELECT * FROM double_tbl WHERE colA = '-1.7976931348623157E+308'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` = -1.797693134862316e308) +EXPLAIN SELECT * FROM double_tbl WHERE colA <> '-1.7976931348623157E+308'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 90.00 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 90.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` <> -1.797693134862316e308) +EXPLAIN SELECT * FROM double_tbl WHERE colA <= '1.7976931348623157E+308'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` <= 1.7976931348623157e308) +EXPLAIN SELECT * FROM double_tbl WHERE colA < '1.7976931348623157E+308'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` < 1.7976931348623157e308) +EXPLAIN SELECT * FROM double_tbl WHERE colA >= '1.7976931348623157E+308'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` >= 1.7976931348623157e308) +EXPLAIN SELECT * FROM double_tbl WHERE colA > '1.7976931348623157E+308'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` > 1.7976931348623157e308) +EXPLAIN SELECT * FROM double_tbl WHERE colA = '1.7976931348623157E+308'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` = 1.7976931348623157e308) +EXPLAIN SELECT * FROM double_tbl WHERE colA <> '1.7976931348623157E+308'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 90.00 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 90.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` <> 1.7976931348623157e308) +EXPLAIN SELECT * FROM double_tbl WHERE colA <= '1.7976931348623156E+308'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` <= 1.7976931348623155e308) +EXPLAIN SELECT * FROM double_tbl WHERE colA < '1.7976931348623156E+308'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` < 1.7976931348623155e308) +EXPLAIN SELECT * FROM double_tbl WHERE colA >= '1.7976931348623156E+308'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` >= 1.7976931348623155e308) +EXPLAIN SELECT * FROM double_tbl WHERE colA > '1.7976931348623156E+308'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` > 1.7976931348623155e308) +EXPLAIN SELECT * FROM double_tbl WHERE colA = '1.7976931348623156E+308'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` = 1.7976931348623155e308) +EXPLAIN SELECT * FROM double_tbl WHERE colA <> '1.7976931348623156E+308'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 90.00 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 90.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` <> 1.7976931348623155e308) +EXPLAIN SELECT * FROM double_tbl WHERE colA <= '1.7976931348623156E+308'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` <= 1.7976931348623155e308) +EXPLAIN SELECT * FROM double_tbl WHERE colA < '1.7976931348623156E+308'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` < 1.7976931348623155e308) +EXPLAIN SELECT * FROM double_tbl WHERE colA >= '1.7976931348623156E+308'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` >= 1.7976931348623155e308) +EXPLAIN SELECT * FROM double_tbl WHERE colA > '1.7976931348623156E+308'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` > 1.7976931348623155e308) +EXPLAIN SELECT * FROM double_tbl WHERE colA = '1.7976931348623156E+308'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` = 1.7976931348623155e308) +EXPLAIN SELECT * FROM double_tbl WHERE colA <> '1.7976931348623156E+308'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 90.00 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 90.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` <> 1.7976931348623155e308) +EXPLAIN SELECT * FROM double_tbl WHERE colA <= '1.7976931348623157E+308'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` <= 1.7976931348623157e308) +EXPLAIN SELECT * FROM double_tbl WHERE colA < '1.7976931348623157E+308'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` < 1.7976931348623157e308) +Cf explanation of semantics here under the SELECT above. The operator +is modified here to get the same semantics: we need > instead of >= +since we truncate the constant to the allowed range +EXPLAIN SELECT * FROM double_tbl WHERE colA >= '1.7976931348623157E+308'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` >= 1.7976931348623157e308) +EXPLAIN SELECT * FROM double_tbl WHERE colA > '1.7976931348623157E+308'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` > 1.7976931348623157e308) +EXPLAIN SELECT * FROM double_tbl WHERE colA = '1.7976931348623157E+308'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` = 1.7976931348623157e308) +EXPLAIN SELECT * FROM double_tbl WHERE colA <> '1.7976931348623157E+308'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 90.00 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 90.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` <> 1.7976931348623157e308) +EXPLAIN SELECT * FROM double_tbl WHERE colA <= '1.7976931348623157E+308'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` <= 1.7976931348623157e308) +EXPLAIN SELECT * FROM double_tbl WHERE colA < '1.7976931348623157E+308'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` < 1.7976931348623157e308) +EXPLAIN SELECT * FROM double_tbl WHERE colA >= '1.7976931348623157E+308'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` >= 1.7976931348623157e308) +EXPLAIN SELECT * FROM double_tbl WHERE colA > '1.7976931348623157E+308'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` > 1.7976931348623157e308) +EXPLAIN SELECT * FROM double_tbl WHERE colA = '1.7976931348623157E+308'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` = 1.7976931348623157e308) +EXPLAIN SELECT * FROM double_tbl WHERE colA <> '1.7976931348623157E+308'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 90.00 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 90.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` <> 1.7976931348623157e308) +DROP TABLE double_tbl; +CREATE TABLE f(f FLOAT); +INSERT INTO f VALUES (-1), (2); +SELECT * FROM f WHERE f >= '2 garbage'; +f +2 +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: '2 garbage' +DROP TABLE f; +CREATE TABLE f(f FLOAT); +CREATE TABLE f_fix(f FLOAT(5,2)); +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +CREATE TABLE d(d DOUBLE); +CREATE TABLE d_fix(d DOUBLE(5,2)); +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +INSERT INTO f VALUES (-3.4028234663852886e+38), (0), (3.4028234663852886e+38); +INSERT INTO f_fix VALUES (-999.00), (0), (999.99); +INSERT INTO d VALUES (-1.7976931348623157E+308), (0), (1.7976931348623157E+308); +INSERT INTO d_fix VALUES (-999.00), (0), (999.99); +ANALYZE TABLE f; +Table Op Msg_type Msg_text +test.f analyze status OK +ANALYZE TABLE f_fix; +Table Op Msg_type Msg_text +test.f_fix analyze status OK +ANALYZE TABLE d; +Table Op Msg_type Msg_text +test.d analyze status OK +ANALYZE TABLE d_fix; +Table Op Msg_type Msg_text +test.d_fix analyze status OK +# With float we should see folding +SELECT * FROM f WHERE f < 99999999999999999999999999999999999999999999999999999999999999999.0; +f +-3.40282e38 +0 +3.40282e38 +EXPLAIN SELECT * FROM f WHERE f < 99999999999999999999999999999999999999999999999999999999999999999.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE f NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`f`.`f` AS `f` from `test`.`f` where (`test`.`f`.`f` is not null) +# With double, only type adjustment +SELECT * FROM d WHERE d < 99999999999999999999999999999999999999999999999999999999999999999.0; +d +-1.7976931348623157e308 +0 +EXPLAIN SELECT * FROM d WHERE d < 99999999999999999999999999999999999999999999999999999999999999999.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE d NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`d`.`d` AS `d` from `test`.`d` where (`test`.`d`.`d` < 1e65) +# Check around max float in decimal +SELECT * FROM f WHERE f < 100000000000000000000000000000000000000.0; +f +-3.40282e38 +0 +EXPLAIN SELECT * FROM f WHERE f < 100000000000000000000000000000000000000.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE f NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`f`.`f` AS `f` from `test`.`f` where (`test`.`f`.`f` < 1e38) +SELECT * FROM f WHERE f > 100000000000000000000000000000000000000.0; +f +3.40282e38 +EXPLAIN SELECT * FROM f WHERE f > 100000000000000000000000000000000000000.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE f NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`f`.`f` AS `f` from `test`.`f` where (`test`.`f`.`f` > 1e38) +SELECT * FROM f WHERE f < 1000000000000000000000000000000000000000.0; +f +-3.40282e38 +0 +3.40282e38 +EXPLAIN SELECT * FROM f WHERE f < 1000000000000000000000000000000000000000.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE f NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`f`.`f` AS `f` from `test`.`f` where (`test`.`f`.`f` is not null) +SELECT * FROM f WHERE f > 1000000000000000000000000000000000000000.0; +f +EXPLAIN SELECT * FROM f WHERE f > 1000000000000000000000000000000000000000.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`f`.`f` AS `f` from `test`.`f` where false +# Then compare with a DOUBLE field +SELECT * FROM d WHERE d < 1000000000000000000000000000000000000000.0; +d +-1.7976931348623157e308 +0 +EXPLAIN SELECT * FROM d WHERE d < 1000000000000000000000000000000000000000.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE d NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`d`.`d` AS `d` from `test`.`d` where (`test`.`d`.`d` < 1e39) +SELECT * FROM d WHERE d > 1000000000000000000000000000000000000000.0; +d +1.7976931348623157e308 +EXPLAIN SELECT * FROM d WHERE d > 1000000000000000000000000000000000000000.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE d NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`d`.`d` AS `d` from `test`.`d` where (`test`.`d`.`d` > 1e39) +Then with the two fixed real type fields, both of which +should be folded +SELECT * FROM f_fix WHERE f < 1000000000000000000000000000000000000000.0; +f +-999.00 +0.00 +999.99 +EXPLAIN SELECT * FROM f_fix WHERE f < 1000000000000000000000000000000000000000.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE f_fix NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`f_fix`.`f` AS `f` from `test`.`f_fix` where (`test`.`f_fix`.`f` is not null) +SELECT * FROM f_fix WHERE f > 1000000000000000000000000000000000000000.0; +f +EXPLAIN SELECT * FROM f_fix WHERE f > 1000000000000000000000000000000000000000.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`f_fix`.`f` AS `f` from `test`.`f_fix` where false +SELECT * FROM d_fix WHERE d < 1000000000000000000000000000000000000000.0; +d +-999.00 +0.00 +999.99 +EXPLAIN SELECT * FROM d_fix WHERE d < 1000000000000000000000000000000000000000.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE d_fix NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`d_fix`.`d` AS `d` from `test`.`d_fix` where (`test`.`d_fix`.`d` is not null) +SELECT * FROM d_fix WHERE d > 1000000000000000000000000000000000000000.0; +d +EXPLAIN SELECT * FROM d_fix WHERE d > 1000000000000000000000000000000000000000.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`d_fix`.`d` AS `d` from `test`.`d_fix` where false +DROP TABLE f, f_fix, d, d_fix; +# I N T constant +CREATE TABLE tbl_year (y YEAR ); +INSERT INTO tbl_year VALUES (0), (1901), (2018), (2155); +ANALYZE TABLE tbl_year; +Table Op Msg_type Msg_text +test.tbl_year analyze status OK +SELECT * FROM tbl_year; +y +0000 +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y < 0; +y +SELECT * FROM tbl_year WHERE y <= 0; +y +0000 +SELECT * FROM tbl_year WHERE y > 0; +y +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y >= 0; +y +0000 +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y = 0; +y +0000 +SELECT * FROM tbl_year WHERE y <> 0; +y +1901 +2018 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y <= 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 25.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` = 0) +EXPLAIN SELECT * FROM tbl_year WHERE y > 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` > 0) +EXPLAIN SELECT * FROM tbl_year WHERE y >= 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +EXPLAIN SELECT * FROM tbl_year WHERE y = 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 25.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` = 0) +EXPLAIN SELECT * FROM tbl_year WHERE y <> 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <> 0) +SELECT * FROM tbl_year WHERE y < -1; +y +SELECT * FROM tbl_year WHERE y <= -1; +y +SELECT * FROM tbl_year WHERE y > -1; +y +0000 +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y >= -1; +y +0000 +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y = -1; +y +SELECT * FROM tbl_year WHERE y <> -1; +y +0000 +1901 +2018 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < -1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y <= -1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y > -1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +EXPLAIN SELECT * FROM tbl_year WHERE y >= -1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +EXPLAIN SELECT * FROM tbl_year WHERE y = -1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y <> -1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +SELECT * FROM tbl_year WHERE y < 1; +y +0000 +1901 +SELECT * FROM tbl_year WHERE y <= 1; +y +0000 +1901 +SELECT * FROM tbl_year WHERE y > 1; +y +2018 +2155 +SELECT * FROM tbl_year WHERE y >= 1; +y +2018 +2155 +SELECT * FROM tbl_year WHERE y = 1; +y +SELECT * FROM tbl_year WHERE y <> 1; +y +0000 +1901 +2018 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` < 2001) +EXPLAIN SELECT * FROM tbl_year WHERE y <= 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <= 2001) +EXPLAIN SELECT * FROM tbl_year WHERE y > 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` > 2001) +EXPLAIN SELECT * FROM tbl_year WHERE y >= 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` >= 2001) +EXPLAIN SELECT * FROM tbl_year WHERE y = 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 25.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` = 2001) +EXPLAIN SELECT * FROM tbl_year WHERE y <> 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <> 2001) +SELECT * FROM tbl_year WHERE y < 300; +y +0000 +SELECT * FROM tbl_year WHERE y <= 300; +y +0000 +SELECT * FROM tbl_year WHERE y > 300; +y +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y >= 300; +y +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y = 300; +y +SELECT * FROM tbl_year WHERE y <> 300; +y +0000 +1901 +2018 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < 300; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` < 300) +EXPLAIN SELECT * FROM tbl_year WHERE y <= 300; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <= 300) +EXPLAIN SELECT * FROM tbl_year WHERE y > 300; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` > 300) +EXPLAIN SELECT * FROM tbl_year WHERE y >= 300; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` >= 300) +EXPLAIN SELECT * FROM tbl_year WHERE y = 300; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y <> 300; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +SELECT * FROM tbl_year WHERE y < 1900; +y +0000 +SELECT * FROM tbl_year WHERE y <= 1900; +y +0000 +SELECT * FROM tbl_year WHERE y > 1900; +y +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y >= 1900; +y +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y = 1900; +y +SELECT * FROM tbl_year WHERE y <> 1900; +y +0000 +1901 +2018 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < 1900; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` < 1900) +EXPLAIN SELECT * FROM tbl_year WHERE y <= 1900; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <= 1900) +EXPLAIN SELECT * FROM tbl_year WHERE y > 1900; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` > 1900) +EXPLAIN SELECT * FROM tbl_year WHERE y >= 1900; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` >= 1900) +EXPLAIN SELECT * FROM tbl_year WHERE y = 1900; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y <> 1900; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +SELECT * FROM tbl_year WHERE y < 1901; +y +0000 +SELECT * FROM tbl_year WHERE y <= 1901; +y +0000 +1901 +SELECT * FROM tbl_year WHERE y > 1901; +y +2018 +2155 +SELECT * FROM tbl_year WHERE y >= 1901; +y +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y = 1901; +y +1901 +SELECT * FROM tbl_year WHERE y <> 1901; +y +0000 +2018 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < 1901; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` < 1901) +EXPLAIN SELECT * FROM tbl_year WHERE y <= 1901; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <= 1901) +EXPLAIN SELECT * FROM tbl_year WHERE y > 1901; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` > 1901) +EXPLAIN SELECT * FROM tbl_year WHERE y >= 1901; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` >= 1901) +EXPLAIN SELECT * FROM tbl_year WHERE y = 1901; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 25.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` = 1901) +EXPLAIN SELECT * FROM tbl_year WHERE y <> 1901; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <> 1901) +SELECT * FROM tbl_year WHERE y < 1902; +y +0000 +1901 +SELECT * FROM tbl_year WHERE y <= 1902; +y +0000 +1901 +SELECT * FROM tbl_year WHERE y > 1902; +y +2018 +2155 +SELECT * FROM tbl_year WHERE y >= 1902; +y +2018 +2155 +SELECT * FROM tbl_year WHERE y = 1902; +y +SELECT * FROM tbl_year WHERE y <> 1902; +y +0000 +1901 +2018 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < 1902; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` < 1902) +EXPLAIN SELECT * FROM tbl_year WHERE y <= 1902; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <= 1902) +EXPLAIN SELECT * FROM tbl_year WHERE y > 1902; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` > 1902) +EXPLAIN SELECT * FROM tbl_year WHERE y >= 1902; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` >= 1902) +EXPLAIN SELECT * FROM tbl_year WHERE y = 1902; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 25.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` = 1902) +EXPLAIN SELECT * FROM tbl_year WHERE y <> 1902; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <> 1902) +SELECT * FROM tbl_year WHERE y < 2018; +y +0000 +1901 +SELECT * FROM tbl_year WHERE y <= 2018; +y +0000 +1901 +2018 +SELECT * FROM tbl_year WHERE y > 2018; +y +2155 +SELECT * FROM tbl_year WHERE y >= 2018; +y +2018 +2155 +SELECT * FROM tbl_year WHERE y = 2018; +y +2018 +SELECT * FROM tbl_year WHERE y <> 2018; +y +0000 +1901 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < 2018; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` < 2018) +EXPLAIN SELECT * FROM tbl_year WHERE y <= 2018; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <= 2018) +EXPLAIN SELECT * FROM tbl_year WHERE y > 2018; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` > 2018) +EXPLAIN SELECT * FROM tbl_year WHERE y >= 2018; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` >= 2018) +EXPLAIN SELECT * FROM tbl_year WHERE y = 2018; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 25.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` = 2018) +EXPLAIN SELECT * FROM tbl_year WHERE y <> 2018; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <> 2018) +SELECT * FROM tbl_year WHERE y < 2154; +y +0000 +1901 +2018 +SELECT * FROM tbl_year WHERE y <= 2154; +y +0000 +1901 +2018 +SELECT * FROM tbl_year WHERE y > 2154; +y +2155 +SELECT * FROM tbl_year WHERE y >= 2154; +y +2155 +SELECT * FROM tbl_year WHERE y = 2154; +y +SELECT * FROM tbl_year WHERE y <> 2154; +y +0000 +1901 +2018 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < 2154; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` < 2154) +EXPLAIN SELECT * FROM tbl_year WHERE y <= 2154; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <= 2154) +EXPLAIN SELECT * FROM tbl_year WHERE y > 2154; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` > 2154) +EXPLAIN SELECT * FROM tbl_year WHERE y >= 2154; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` >= 2154) +EXPLAIN SELECT * FROM tbl_year WHERE y = 2154; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 25.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` = 2154) +EXPLAIN SELECT * FROM tbl_year WHERE y <> 2154; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <> 2154) +SELECT * FROM tbl_year WHERE y < 2155; +y +0000 +1901 +2018 +SELECT * FROM tbl_year WHERE y <= 2155; +y +0000 +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y > 2155; +y +SELECT * FROM tbl_year WHERE y >= 2155; +y +2155 +SELECT * FROM tbl_year WHERE y = 2155; +y +2155 +SELECT * FROM tbl_year WHERE y <> 2155; +y +0000 +1901 +2018 +EXPLAIN SELECT * FROM tbl_year WHERE y < 2155; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` < 2155) +EXPLAIN SELECT * FROM tbl_year WHERE y <= 2155; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +EXPLAIN SELECT * FROM tbl_year WHERE y > 2155; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y >= 2155; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 25.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` = 2155) +EXPLAIN SELECT * FROM tbl_year WHERE y = 2155; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 25.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` = 2155) +EXPLAIN SELECT * FROM tbl_year WHERE y <> 2155; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <> 2155) +SELECT * FROM tbl_year WHERE y < 2156; +y +0000 +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y <= 2156; +y +0000 +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y > 2156; +y +SELECT * FROM tbl_year WHERE y >= 2156; +y +SELECT * FROM tbl_year WHERE y = 2156; +y +SELECT * FROM tbl_year WHERE y <> 2156; +y +0000 +1901 +2018 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < 2156; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +EXPLAIN SELECT * FROM tbl_year WHERE y <= 2156; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +EXPLAIN SELECT * FROM tbl_year WHERE y > 2156; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y >= 2156; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y = 2156; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y <> 2156; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +DROP TABLE tbl_year; +# I N T abbreviated constant +CREATE TABLE tbl_year (y YEAR ); +INSERT INTO tbl_year VALUES (0), (1901), (2018), (2155); +ANALYZE TABLE tbl_year; +Table Op Msg_type Msg_text +test.tbl_year analyze status OK +SELECT * FROM tbl_year; +y +0000 +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y < 0; +y +SELECT * FROM tbl_year WHERE y <= 0; +y +0000 +SELECT * FROM tbl_year WHERE y > 0; +y +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y >= 0; +y +0000 +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y = 0; +y +0000 +SELECT * FROM tbl_year WHERE y <> 0; +y +1901 +2018 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y <= 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 25.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` = 0) +EXPLAIN SELECT * FROM tbl_year WHERE y > 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` > 0) +EXPLAIN SELECT * FROM tbl_year WHERE y >= 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +EXPLAIN SELECT * FROM tbl_year WHERE y = 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 25.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` = 0) +EXPLAIN SELECT * FROM tbl_year WHERE y <> 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <> 0) +SELECT * FROM tbl_year WHERE y < -1; +y +SELECT * FROM tbl_year WHERE y <= -1; +y +SELECT * FROM tbl_year WHERE y > -1; +y +0000 +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y >= -1; +y +0000 +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y = -1; +y +SELECT * FROM tbl_year WHERE y <> -1; +y +0000 +1901 +2018 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < -1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y <= -1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y > -1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +EXPLAIN SELECT * FROM tbl_year WHERE y >= -1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +EXPLAIN SELECT * FROM tbl_year WHERE y = -1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y <> -1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +SELECT * FROM tbl_year WHERE y < 1; +y +0000 +1901 +SELECT * FROM tbl_year WHERE y <= 1; +y +0000 +1901 +SELECT * FROM tbl_year WHERE y > 1; +y +2018 +2155 +SELECT * FROM tbl_year WHERE y >= 1; +y +2018 +2155 +SELECT * FROM tbl_year WHERE y = 1; +y +SELECT * FROM tbl_year WHERE y <> 1; +y +0000 +1901 +2018 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` < 2001) +EXPLAIN SELECT * FROM tbl_year WHERE y <= 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <= 2001) +EXPLAIN SELECT * FROM tbl_year WHERE y > 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` > 2001) +EXPLAIN SELECT * FROM tbl_year WHERE y >= 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` >= 2001) +EXPLAIN SELECT * FROM tbl_year WHERE y = 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 25.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` = 2001) +EXPLAIN SELECT * FROM tbl_year WHERE y <> 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <> 2001) +SELECT * FROM tbl_year WHERE y < 300; +y +0000 +SELECT * FROM tbl_year WHERE y <= 300; +y +0000 +SELECT * FROM tbl_year WHERE y > 300; +y +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y >= 300; +y +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y = 300; +y +SELECT * FROM tbl_year WHERE y <> 300; +y +0000 +1901 +2018 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < 300; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` < 300) +EXPLAIN SELECT * FROM tbl_year WHERE y <= 300; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <= 300) +EXPLAIN SELECT * FROM tbl_year WHERE y > 300; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` > 300) +EXPLAIN SELECT * FROM tbl_year WHERE y >= 300; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` >= 300) +EXPLAIN SELECT * FROM tbl_year WHERE y = 300; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y <> 300; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +SELECT * FROM tbl_year WHERE y < 1900; +y +0000 +SELECT * FROM tbl_year WHERE y <= 1900; +y +0000 +SELECT * FROM tbl_year WHERE y > 1900; +y +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y >= 1900; +y +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y = 1900; +y +SELECT * FROM tbl_year WHERE y <> 1900; +y +0000 +1901 +2018 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < 1900; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` < 1900) +EXPLAIN SELECT * FROM tbl_year WHERE y <= 1900; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <= 1900) +EXPLAIN SELECT * FROM tbl_year WHERE y > 1900; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` > 1900) +EXPLAIN SELECT * FROM tbl_year WHERE y >= 1900; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` >= 1900) +EXPLAIN SELECT * FROM tbl_year WHERE y = 1900; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y <> 1900; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +SELECT * FROM tbl_year WHERE y < 01; +y +0000 +1901 +SELECT * FROM tbl_year WHERE y <= 01; +y +0000 +1901 +SELECT * FROM tbl_year WHERE y > 01; +y +2018 +2155 +SELECT * FROM tbl_year WHERE y >= 01; +y +2018 +2155 +SELECT * FROM tbl_year WHERE y = 01; +y +SELECT * FROM tbl_year WHERE y <> 01; +y +0000 +1901 +2018 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < 01; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` < 2001) +EXPLAIN SELECT * FROM tbl_year WHERE y <= 01; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <= 2001) +EXPLAIN SELECT * FROM tbl_year WHERE y > 01; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` > 2001) +EXPLAIN SELECT * FROM tbl_year WHERE y >= 01; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` >= 2001) +EXPLAIN SELECT * FROM tbl_year WHERE y = 01; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 25.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` = 2001) +EXPLAIN SELECT * FROM tbl_year WHERE y <> 01; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <> 2001) +SELECT * FROM tbl_year WHERE y < 02; +y +0000 +1901 +SELECT * FROM tbl_year WHERE y <= 02; +y +0000 +1901 +SELECT * FROM tbl_year WHERE y > 02; +y +2018 +2155 +SELECT * FROM tbl_year WHERE y >= 02; +y +2018 +2155 +SELECT * FROM tbl_year WHERE y = 02; +y +SELECT * FROM tbl_year WHERE y <> 02; +y +0000 +1901 +2018 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < 02; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` < 2002) +EXPLAIN SELECT * FROM tbl_year WHERE y <= 02; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <= 2002) +EXPLAIN SELECT * FROM tbl_year WHERE y > 02; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` > 2002) +EXPLAIN SELECT * FROM tbl_year WHERE y >= 02; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` >= 2002) +EXPLAIN SELECT * FROM tbl_year WHERE y = 02; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 25.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` = 2002) +EXPLAIN SELECT * FROM tbl_year WHERE y <> 02; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <> 2002) +SELECT * FROM tbl_year WHERE y < 18; +y +0000 +1901 +SELECT * FROM tbl_year WHERE y <= 18; +y +0000 +1901 +2018 +SELECT * FROM tbl_year WHERE y > 18; +y +2155 +SELECT * FROM tbl_year WHERE y >= 18; +y +2018 +2155 +SELECT * FROM tbl_year WHERE y = 18; +y +2018 +SELECT * FROM tbl_year WHERE y <> 18; +y +0000 +1901 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < 18; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` < 2018) +EXPLAIN SELECT * FROM tbl_year WHERE y <= 18; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <= 2018) +EXPLAIN SELECT * FROM tbl_year WHERE y > 18; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` > 2018) +EXPLAIN SELECT * FROM tbl_year WHERE y >= 18; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` >= 2018) +EXPLAIN SELECT * FROM tbl_year WHERE y = 18; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 25.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` = 2018) +EXPLAIN SELECT * FROM tbl_year WHERE y <> 18; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <> 2018) +SELECT * FROM tbl_year WHERE y < 2154; +y +0000 +1901 +2018 +SELECT * FROM tbl_year WHERE y <= 2154; +y +0000 +1901 +2018 +SELECT * FROM tbl_year WHERE y > 2154; +y +2155 +SELECT * FROM tbl_year WHERE y >= 2154; +y +2155 +SELECT * FROM tbl_year WHERE y = 2154; +y +SELECT * FROM tbl_year WHERE y <> 2154; +y +0000 +1901 +2018 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < 2154; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` < 2154) +EXPLAIN SELECT * FROM tbl_year WHERE y <= 2154; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <= 2154) +EXPLAIN SELECT * FROM tbl_year WHERE y > 2154; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` > 2154) +EXPLAIN SELECT * FROM tbl_year WHERE y >= 2154; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` >= 2154) +EXPLAIN SELECT * FROM tbl_year WHERE y = 2154; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 25.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` = 2154) +EXPLAIN SELECT * FROM tbl_year WHERE y <> 2154; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <> 2154) +SELECT * FROM tbl_year WHERE y < 2155; +y +0000 +1901 +2018 +SELECT * FROM tbl_year WHERE y <= 2155; +y +0000 +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y > 2155; +y +SELECT * FROM tbl_year WHERE y >= 2155; +y +2155 +SELECT * FROM tbl_year WHERE y = 2155; +y +2155 +SELECT * FROM tbl_year WHERE y <> 2155; +y +0000 +1901 +2018 +EXPLAIN SELECT * FROM tbl_year WHERE y < 2155; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` < 2155) +EXPLAIN SELECT * FROM tbl_year WHERE y <= 2155; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +EXPLAIN SELECT * FROM tbl_year WHERE y > 2155; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y >= 2155; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 25.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` = 2155) +EXPLAIN SELECT * FROM tbl_year WHERE y = 2155; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 25.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` = 2155) +EXPLAIN SELECT * FROM tbl_year WHERE y <> 2155; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <> 2155) +SELECT * FROM tbl_year WHERE y < 2156; +y +0000 +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y <= 2156; +y +0000 +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y > 2156; +y +SELECT * FROM tbl_year WHERE y >= 2156; +y +SELECT * FROM tbl_year WHERE y = 2156; +y +SELECT * FROM tbl_year WHERE y <> 2156; +y +0000 +1901 +2018 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < 2156; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +EXPLAIN SELECT * FROM tbl_year WHERE y <= 2156; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +EXPLAIN SELECT * FROM tbl_year WHERE y > 2156; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y >= 2156; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y = 2156; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y <> 2156; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +DROP TABLE tbl_year; +# D E C I M A L constant with zero fraction +CREATE TABLE tbl_year (y YEAR ); +INSERT INTO tbl_year VALUES (0), (1901), (2018), (2155); +ANALYZE TABLE tbl_year; +Table Op Msg_type Msg_text +test.tbl_year analyze status OK +SELECT * FROM tbl_year; +y +0000 +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y < 0.0; +y +SELECT * FROM tbl_year WHERE y <= 0.0; +y +0000 +SELECT * FROM tbl_year WHERE y > 0.0; +y +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y >= 0.0; +y +0000 +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y = 0.0; +y +0000 +SELECT * FROM tbl_year WHERE y <> 0.0; +y +1901 +2018 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < 0.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y <= 0.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 25.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` = 0) +EXPLAIN SELECT * FROM tbl_year WHERE y > 0.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` > 0) +EXPLAIN SELECT * FROM tbl_year WHERE y >= 0.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +EXPLAIN SELECT * FROM tbl_year WHERE y = 0.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 25.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` = 0) +EXPLAIN SELECT * FROM tbl_year WHERE y <> 0.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <> 0) +SELECT * FROM tbl_year WHERE y < -1.0; +y +SELECT * FROM tbl_year WHERE y <= -1.0; +y +SELECT * FROM tbl_year WHERE y > -1.0; +y +0000 +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y >= -1.0; +y +0000 +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y = -1.0; +y +SELECT * FROM tbl_year WHERE y <> -1.0; +y +0000 +1901 +2018 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < -1.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y <= -1.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y > -1.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +EXPLAIN SELECT * FROM tbl_year WHERE y >= -1.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +EXPLAIN SELECT * FROM tbl_year WHERE y = -1.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y <> -1.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +SELECT * FROM tbl_year WHERE y < 1.0; +y +0000 +1901 +SELECT * FROM tbl_year WHERE y <= 1.0; +y +0000 +1901 +SELECT * FROM tbl_year WHERE y > 1.0; +y +2018 +2155 +SELECT * FROM tbl_year WHERE y >= 1.0; +y +2018 +2155 +SELECT * FROM tbl_year WHERE y = 1.0; +y +SELECT * FROM tbl_year WHERE y <> 1.0; +y +0000 +1901 +2018 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < 1.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` < 2001) +EXPLAIN SELECT * FROM tbl_year WHERE y <= 1.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <= 2001) +EXPLAIN SELECT * FROM tbl_year WHERE y > 1.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` > 2001) +EXPLAIN SELECT * FROM tbl_year WHERE y >= 1.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` >= 2001) +EXPLAIN SELECT * FROM tbl_year WHERE y = 1.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 25.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` = 2001) +EXPLAIN SELECT * FROM tbl_year WHERE y <> 1.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <> 2001) +SELECT * FROM tbl_year WHERE y < 300.0; +y +0000 +SELECT * FROM tbl_year WHERE y <= 300.0; +y +0000 +SELECT * FROM tbl_year WHERE y > 300.0; +y +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y >= 300.0; +y +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y = 300.0; +y +SELECT * FROM tbl_year WHERE y <> 300.0; +y +0000 +1901 +2018 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < 300.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` < 300) +EXPLAIN SELECT * FROM tbl_year WHERE y <= 300.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <= 300) +EXPLAIN SELECT * FROM tbl_year WHERE y > 300.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` > 300) +EXPLAIN SELECT * FROM tbl_year WHERE y >= 300.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` >= 300) +EXPLAIN SELECT * FROM tbl_year WHERE y = 300.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y <> 300.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +SELECT * FROM tbl_year WHERE y < 1900.0; +y +0000 +SELECT * FROM tbl_year WHERE y <= 1900.0; +y +0000 +SELECT * FROM tbl_year WHERE y > 1900.0; +y +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y >= 1900.0; +y +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y = 1900.0; +y +SELECT * FROM tbl_year WHERE y <> 1900.0; +y +0000 +1901 +2018 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < 1900.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` < 1900) +EXPLAIN SELECT * FROM tbl_year WHERE y <= 1900.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <= 1900) +EXPLAIN SELECT * FROM tbl_year WHERE y > 1900.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` > 1900) +EXPLAIN SELECT * FROM tbl_year WHERE y >= 1900.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` >= 1900) +EXPLAIN SELECT * FROM tbl_year WHERE y = 1900.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y <> 1900.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +SELECT * FROM tbl_year WHERE y < 1901.0; +y +0000 +SELECT * FROM tbl_year WHERE y <= 1901.0; +y +0000 +1901 +SELECT * FROM tbl_year WHERE y > 1901.0; +y +2018 +2155 +SELECT * FROM tbl_year WHERE y >= 1901.0; +y +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y = 1901.0; +y +1901 +SELECT * FROM tbl_year WHERE y <> 1901.0; +y +0000 +2018 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < 1901.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` < 1901) +EXPLAIN SELECT * FROM tbl_year WHERE y <= 1901.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <= 1901) +EXPLAIN SELECT * FROM tbl_year WHERE y > 1901.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` > 1901) +EXPLAIN SELECT * FROM tbl_year WHERE y >= 1901.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` >= 1901) +EXPLAIN SELECT * FROM tbl_year WHERE y = 1901.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 25.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` = 1901) +EXPLAIN SELECT * FROM tbl_year WHERE y <> 1901.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <> 1901) +SELECT * FROM tbl_year WHERE y < 1902.0; +y +0000 +1901 +SELECT * FROM tbl_year WHERE y <= 1902.0; +y +0000 +1901 +SELECT * FROM tbl_year WHERE y > 1902.0; +y +2018 +2155 +SELECT * FROM tbl_year WHERE y >= 1902.0; +y +2018 +2155 +SELECT * FROM tbl_year WHERE y = 1902.0; +y +SELECT * FROM tbl_year WHERE y <> 1902.0; +y +0000 +1901 +2018 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < 1902.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` < 1902) +EXPLAIN SELECT * FROM tbl_year WHERE y <= 1902.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <= 1902) +EXPLAIN SELECT * FROM tbl_year WHERE y > 1902.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` > 1902) +EXPLAIN SELECT * FROM tbl_year WHERE y >= 1902.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` >= 1902) +EXPLAIN SELECT * FROM tbl_year WHERE y = 1902.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 25.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` = 1902) +EXPLAIN SELECT * FROM tbl_year WHERE y <> 1902.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <> 1902) +SELECT * FROM tbl_year WHERE y < 2018.0; +y +0000 +1901 +SELECT * FROM tbl_year WHERE y <= 2018.0; +y +0000 +1901 +2018 +SELECT * FROM tbl_year WHERE y > 2018.0; +y +2155 +SELECT * FROM tbl_year WHERE y >= 2018.0; +y +2018 +2155 +SELECT * FROM tbl_year WHERE y = 2018.0; +y +2018 +SELECT * FROM tbl_year WHERE y <> 2018.0; +y +0000 +1901 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < 2018.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` < 2018) +EXPLAIN SELECT * FROM tbl_year WHERE y <= 2018.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <= 2018) +EXPLAIN SELECT * FROM tbl_year WHERE y > 2018.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` > 2018) +EXPLAIN SELECT * FROM tbl_year WHERE y >= 2018.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` >= 2018) +EXPLAIN SELECT * FROM tbl_year WHERE y = 2018.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 25.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` = 2018) +EXPLAIN SELECT * FROM tbl_year WHERE y <> 2018.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <> 2018) +SELECT * FROM tbl_year WHERE y < 2154.0; +y +0000 +1901 +2018 +SELECT * FROM tbl_year WHERE y <= 2154.0; +y +0000 +1901 +2018 +SELECT * FROM tbl_year WHERE y > 2154.0; +y +2155 +SELECT * FROM tbl_year WHERE y >= 2154.0; +y +2155 +SELECT * FROM tbl_year WHERE y = 2154.0; +y +SELECT * FROM tbl_year WHERE y <> 2154.0; +y +0000 +1901 +2018 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < 2154.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` < 2154) +EXPLAIN SELECT * FROM tbl_year WHERE y <= 2154.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <= 2154) +EXPLAIN SELECT * FROM tbl_year WHERE y > 2154.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` > 2154) +EXPLAIN SELECT * FROM tbl_year WHERE y >= 2154.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` >= 2154) +EXPLAIN SELECT * FROM tbl_year WHERE y = 2154.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 25.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` = 2154) +EXPLAIN SELECT * FROM tbl_year WHERE y <> 2154.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <> 2154) +SELECT * FROM tbl_year WHERE y < 2155.0; +y +0000 +1901 +2018 +SELECT * FROM tbl_year WHERE y <= 2155.0; +y +0000 +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y > 2155.0; +y +SELECT * FROM tbl_year WHERE y >= 2155.0; +y +2155 +SELECT * FROM tbl_year WHERE y = 2155.0; +y +2155 +SELECT * FROM tbl_year WHERE y <> 2155.0; +y +0000 +1901 +2018 +EXPLAIN SELECT * FROM tbl_year WHERE y < 2155.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` < 2155) +EXPLAIN SELECT * FROM tbl_year WHERE y <= 2155.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +EXPLAIN SELECT * FROM tbl_year WHERE y > 2155.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y >= 2155.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 25.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` = 2155) +EXPLAIN SELECT * FROM tbl_year WHERE y = 2155.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 25.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` = 2155) +EXPLAIN SELECT * FROM tbl_year WHERE y <> 2155.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <> 2155) +SELECT * FROM tbl_year WHERE y < 2156.0; +y +0000 +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y <= 2156.0; +y +0000 +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y > 2156.0; +y +SELECT * FROM tbl_year WHERE y >= 2156.0; +y +SELECT * FROM tbl_year WHERE y = 2156.0; +y +SELECT * FROM tbl_year WHERE y <> 2156.0; +y +0000 +1901 +2018 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < 2156.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +EXPLAIN SELECT * FROM tbl_year WHERE y <= 2156.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +EXPLAIN SELECT * FROM tbl_year WHERE y > 2156.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y >= 2156.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y = 2156.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y <> 2156.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +DROP TABLE tbl_year; +# D E C I M A L constant with non-zero fraction +CREATE TABLE tbl_year (y YEAR ); +INSERT INTO tbl_year VALUES (0), (1901), (2018), (2155); +ANALYZE TABLE tbl_year; +Table Op Msg_type Msg_text +test.tbl_year analyze status OK +SELECT * FROM tbl_year; +y +0000 +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y < 0.1; +y +SELECT * FROM tbl_year WHERE y <= 0.1; +y +0000 +SELECT * FROM tbl_year WHERE y > 0.1; +y +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y >= 0.1; +y +0000 +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y = 0.1; +y +0000 +SELECT * FROM tbl_year WHERE y <> 0.1; +y +1901 +2018 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < 0.1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y <= 0.1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 25.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` = 0) +EXPLAIN SELECT * FROM tbl_year WHERE y > 0.1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` > 0) +EXPLAIN SELECT * FROM tbl_year WHERE y >= 0.1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +EXPLAIN SELECT * FROM tbl_year WHERE y = 0.1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 25.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` = 0) +EXPLAIN SELECT * FROM tbl_year WHERE y <> 0.1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <> 0) +SELECT * FROM tbl_year WHERE y < -1.1; +y +SELECT * FROM tbl_year WHERE y <= -1.1; +y +SELECT * FROM tbl_year WHERE y > -1.1; +y +0000 +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y >= -1.1; +y +0000 +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y = -1.1; +y +SELECT * FROM tbl_year WHERE y <> -1.1; +y +0000 +1901 +2018 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < -1.1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y <= -1.1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y > -1.1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +EXPLAIN SELECT * FROM tbl_year WHERE y >= -1.1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +EXPLAIN SELECT * FROM tbl_year WHERE y = -1.1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y <> -1.1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +SELECT * FROM tbl_year WHERE y < 1.1; +y +0000 +1901 +SELECT * FROM tbl_year WHERE y <= 1.1; +y +0000 +1901 +SELECT * FROM tbl_year WHERE y > 1.1; +y +2018 +2155 +SELECT * FROM tbl_year WHERE y >= 1.1; +y +2018 +2155 +SELECT * FROM tbl_year WHERE y = 1.1; +y +SELECT * FROM tbl_year WHERE y <> 1.1; +y +0000 +1901 +2018 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < 1.1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` < 2001) +EXPLAIN SELECT * FROM tbl_year WHERE y <= 1.1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <= 2001) +EXPLAIN SELECT * FROM tbl_year WHERE y > 1.1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` > 2001) +EXPLAIN SELECT * FROM tbl_year WHERE y >= 1.1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` >= 2001) +EXPLAIN SELECT * FROM tbl_year WHERE y = 1.1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 25.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` = 2001) +EXPLAIN SELECT * FROM tbl_year WHERE y <> 1.1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <> 2001) +SELECT * FROM tbl_year WHERE y < 300.1; +y +0000 +SELECT * FROM tbl_year WHERE y <= 300.1; +y +0000 +SELECT * FROM tbl_year WHERE y > 300.1; +y +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y >= 300.1; +y +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y = 300.1; +y +SELECT * FROM tbl_year WHERE y <> 300.1; +y +0000 +1901 +2018 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < 300.1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` < 300) +EXPLAIN SELECT * FROM tbl_year WHERE y <= 300.1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <= 300) +EXPLAIN SELECT * FROM tbl_year WHERE y > 300.1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` > 300) +EXPLAIN SELECT * FROM tbl_year WHERE y >= 300.1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` >= 300) +EXPLAIN SELECT * FROM tbl_year WHERE y = 300.1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y <> 300.1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +SELECT * FROM tbl_year WHERE y < 1900.1; +y +0000 +SELECT * FROM tbl_year WHERE y <= 1900.1; +y +0000 +SELECT * FROM tbl_year WHERE y > 1900.1; +y +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y >= 1900.1; +y +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y = 1900.1; +y +SELECT * FROM tbl_year WHERE y <> 1900.1; +y +0000 +1901 +2018 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < 1900.1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` < 1900) +EXPLAIN SELECT * FROM tbl_year WHERE y <= 1900.1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <= 1900) +EXPLAIN SELECT * FROM tbl_year WHERE y > 1900.1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` > 1900) +EXPLAIN SELECT * FROM tbl_year WHERE y >= 1900.1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` >= 1900) +EXPLAIN SELECT * FROM tbl_year WHERE y = 1900.1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y <> 1900.1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +SELECT * FROM tbl_year WHERE y < 1901.1; +y +0000 +SELECT * FROM tbl_year WHERE y <= 1901.1; +y +0000 +1901 +SELECT * FROM tbl_year WHERE y > 1901.1; +y +2018 +2155 +SELECT * FROM tbl_year WHERE y >= 1901.1; +y +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y = 1901.1; +y +1901 +SELECT * FROM tbl_year WHERE y <> 1901.1; +y +0000 +2018 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < 1901.1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` < 1901) +EXPLAIN SELECT * FROM tbl_year WHERE y <= 1901.1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <= 1901) +EXPLAIN SELECT * FROM tbl_year WHERE y > 1901.1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` > 1901) +EXPLAIN SELECT * FROM tbl_year WHERE y >= 1901.1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` >= 1901) +EXPLAIN SELECT * FROM tbl_year WHERE y = 1901.1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 25.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` = 1901) +EXPLAIN SELECT * FROM tbl_year WHERE y <> 1901.1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <> 1901) +SELECT * FROM tbl_year WHERE y < 1902.1; +y +0000 +1901 +SELECT * FROM tbl_year WHERE y <= 1902.1; +y +0000 +1901 +SELECT * FROM tbl_year WHERE y > 1902.1; +y +2018 +2155 +SELECT * FROM tbl_year WHERE y >= 1902.1; +y +2018 +2155 +SELECT * FROM tbl_year WHERE y = 1902.1; +y +SELECT * FROM tbl_year WHERE y <> 1902.1; +y +0000 +1901 +2018 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < 1902.1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` < 1902) +EXPLAIN SELECT * FROM tbl_year WHERE y <= 1902.1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <= 1902) +EXPLAIN SELECT * FROM tbl_year WHERE y > 1902.1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` > 1902) +EXPLAIN SELECT * FROM tbl_year WHERE y >= 1902.1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` >= 1902) +EXPLAIN SELECT * FROM tbl_year WHERE y = 1902.1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 25.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` = 1902) +EXPLAIN SELECT * FROM tbl_year WHERE y <> 1902.1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <> 1902) +SELECT * FROM tbl_year WHERE y < 2018.1; +y +0000 +1901 +SELECT * FROM tbl_year WHERE y <= 2018.1; +y +0000 +1901 +2018 +SELECT * FROM tbl_year WHERE y > 2018.1; +y +2155 +SELECT * FROM tbl_year WHERE y >= 2018.1; +y +2018 +2155 +SELECT * FROM tbl_year WHERE y = 2018.1; +y +2018 +SELECT * FROM tbl_year WHERE y <> 2018.1; +y +0000 +1901 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < 2018.1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` < 2018) +EXPLAIN SELECT * FROM tbl_year WHERE y <= 2018.1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <= 2018) +EXPLAIN SELECT * FROM tbl_year WHERE y > 2018.1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` > 2018) +EXPLAIN SELECT * FROM tbl_year WHERE y >= 2018.1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` >= 2018) +EXPLAIN SELECT * FROM tbl_year WHERE y = 2018.1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 25.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` = 2018) +EXPLAIN SELECT * FROM tbl_year WHERE y <> 2018.1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <> 2018) +SELECT * FROM tbl_year WHERE y < 2154.1; +y +0000 +1901 +2018 +SELECT * FROM tbl_year WHERE y <= 2154.1; +y +0000 +1901 +2018 +SELECT * FROM tbl_year WHERE y > 2154.1; +y +2155 +SELECT * FROM tbl_year WHERE y >= 2154.1; +y +2155 +SELECT * FROM tbl_year WHERE y = 2154.1; +y +SELECT * FROM tbl_year WHERE y <> 2154.1; +y +0000 +1901 +2018 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < 2154.1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` < 2154) +EXPLAIN SELECT * FROM tbl_year WHERE y <= 2154.1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <= 2154) +EXPLAIN SELECT * FROM tbl_year WHERE y > 2154.1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` > 2154) +EXPLAIN SELECT * FROM tbl_year WHERE y >= 2154.1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` >= 2154) +EXPLAIN SELECT * FROM tbl_year WHERE y = 2154.1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 25.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` = 2154) +EXPLAIN SELECT * FROM tbl_year WHERE y <> 2154.1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <> 2154) +SELECT * FROM tbl_year WHERE y < 2155.1; +y +0000 +1901 +2018 +SELECT * FROM tbl_year WHERE y <= 2155.1; +y +0000 +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y > 2155.1; +y +SELECT * FROM tbl_year WHERE y >= 2155.1; +y +2155 +SELECT * FROM tbl_year WHERE y = 2155.1; +y +2155 +SELECT * FROM tbl_year WHERE y <> 2155.1; +y +0000 +1901 +2018 +EXPLAIN SELECT * FROM tbl_year WHERE y < 2155.1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` < 2155) +EXPLAIN SELECT * FROM tbl_year WHERE y <= 2155.1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +EXPLAIN SELECT * FROM tbl_year WHERE y > 2155.1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y >= 2155.1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 25.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` = 2155) +EXPLAIN SELECT * FROM tbl_year WHERE y = 2155.1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 25.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` = 2155) +EXPLAIN SELECT * FROM tbl_year WHERE y <> 2155.1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <> 2155) +SELECT * FROM tbl_year WHERE y < 2156.1; +y +0000 +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y <= 2156.1; +y +0000 +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y > 2156.1; +y +SELECT * FROM tbl_year WHERE y >= 2156.1; +y +SELECT * FROM tbl_year WHERE y = 2156.1; +y +SELECT * FROM tbl_year WHERE y <> 2156.1; +y +0000 +1901 +2018 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < 2156.1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +EXPLAIN SELECT * FROM tbl_year WHERE y <= 2156.1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +EXPLAIN SELECT * FROM tbl_year WHERE y > 2156.1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y >= 2156.1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y = 2156.1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y <> 2156.1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +DROP TABLE tbl_year; +CREATE TABLE tbl_year (y YEAR ); +INSERT INTO tbl_year VALUES (0), (1901), (2018), (2155); +ANALYZE TABLE tbl_year; +Table Op Msg_type Msg_text +test.tbl_year analyze status OK +SELECT * FROM tbl_year; +y +0000 +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y < 0.9; +y +0000 +1901 +SELECT * FROM tbl_year WHERE y <= 0.9; +y +0000 +1901 +SELECT * FROM tbl_year WHERE y > 0.9; +y +2018 +2155 +SELECT * FROM tbl_year WHERE y >= 0.9; +y +2018 +2155 +SELECT * FROM tbl_year WHERE y = 0.9; +y +SELECT * FROM tbl_year WHERE y <> 0.9; +y +0000 +1901 +2018 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < 0.9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` < 2001) +EXPLAIN SELECT * FROM tbl_year WHERE y <= 0.9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <= 2001) +EXPLAIN SELECT * FROM tbl_year WHERE y > 0.9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` > 2001) +EXPLAIN SELECT * FROM tbl_year WHERE y >= 0.9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` >= 2001) +EXPLAIN SELECT * FROM tbl_year WHERE y = 0.9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 25.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` = 2001) +EXPLAIN SELECT * FROM tbl_year WHERE y <> 0.9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <> 2001) +SELECT * FROM tbl_year WHERE y < -1.9; +y +SELECT * FROM tbl_year WHERE y <= -1.9; +y +SELECT * FROM tbl_year WHERE y > -1.9; +y +0000 +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y >= -1.9; +y +0000 +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y = -1.9; +y +SELECT * FROM tbl_year WHERE y <> -1.9; +y +0000 +1901 +2018 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < -1.9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y <= -1.9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y > -1.9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +EXPLAIN SELECT * FROM tbl_year WHERE y >= -1.9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +EXPLAIN SELECT * FROM tbl_year WHERE y = -1.9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y <> -1.9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +SELECT * FROM tbl_year WHERE y < 1.9; +y +0000 +1901 +SELECT * FROM tbl_year WHERE y <= 1.9; +y +0000 +1901 +SELECT * FROM tbl_year WHERE y > 1.9; +y +2018 +2155 +SELECT * FROM tbl_year WHERE y >= 1.9; +y +2018 +2155 +SELECT * FROM tbl_year WHERE y = 1.9; +y +SELECT * FROM tbl_year WHERE y <> 1.9; +y +0000 +1901 +2018 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < 1.9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` < 2002) +EXPLAIN SELECT * FROM tbl_year WHERE y <= 1.9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <= 2002) +EXPLAIN SELECT * FROM tbl_year WHERE y > 1.9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` > 2002) +EXPLAIN SELECT * FROM tbl_year WHERE y >= 1.9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` >= 2002) +EXPLAIN SELECT * FROM tbl_year WHERE y = 1.9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 25.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` = 2002) +EXPLAIN SELECT * FROM tbl_year WHERE y <> 1.9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <> 2002) +SELECT * FROM tbl_year WHERE y < 300.9; +y +0000 +SELECT * FROM tbl_year WHERE y <= 300.9; +y +0000 +SELECT * FROM tbl_year WHERE y > 300.9; +y +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y >= 300.9; +y +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y = 300.9; +y +SELECT * FROM tbl_year WHERE y <> 300.9; +y +0000 +1901 +2018 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < 300.9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` < 300) +EXPLAIN SELECT * FROM tbl_year WHERE y <= 300.9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <= 300) +EXPLAIN SELECT * FROM tbl_year WHERE y > 300.9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` > 300) +EXPLAIN SELECT * FROM tbl_year WHERE y >= 300.9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` >= 300) +EXPLAIN SELECT * FROM tbl_year WHERE y = 300.9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y <> 300.9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +SELECT * FROM tbl_year WHERE y < 1900.9; +y +0000 +SELECT * FROM tbl_year WHERE y <= 1900.9; +y +0000 +1901 +SELECT * FROM tbl_year WHERE y > 1900.9; +y +2018 +2155 +SELECT * FROM tbl_year WHERE y >= 1900.9; +y +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y = 1900.9; +y +1901 +SELECT * FROM tbl_year WHERE y <> 1900.9; +y +0000 +2018 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < 1900.9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` < 1901) +EXPLAIN SELECT * FROM tbl_year WHERE y <= 1900.9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <= 1901) +EXPLAIN SELECT * FROM tbl_year WHERE y > 1900.9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` > 1901) +EXPLAIN SELECT * FROM tbl_year WHERE y >= 1900.9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` >= 1901) +EXPLAIN SELECT * FROM tbl_year WHERE y = 1900.9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 25.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` = 1901) +EXPLAIN SELECT * FROM tbl_year WHERE y <> 1900.9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <> 1901) +SELECT * FROM tbl_year WHERE y < 1901.9; +y +0000 +1901 +SELECT * FROM tbl_year WHERE y <= 1901.9; +y +0000 +1901 +SELECT * FROM tbl_year WHERE y > 1901.9; +y +2018 +2155 +SELECT * FROM tbl_year WHERE y >= 1901.9; +y +2018 +2155 +SELECT * FROM tbl_year WHERE y = 1901.9; +y +SELECT * FROM tbl_year WHERE y <> 1901.9; +y +0000 +1901 +2018 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < 1901.9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` < 1902) +EXPLAIN SELECT * FROM tbl_year WHERE y <= 1901.9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <= 1902) +EXPLAIN SELECT * FROM tbl_year WHERE y > 1901.9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` > 1902) +EXPLAIN SELECT * FROM tbl_year WHERE y >= 1901.9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` >= 1902) +EXPLAIN SELECT * FROM tbl_year WHERE y = 1901.9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 25.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` = 1902) +EXPLAIN SELECT * FROM tbl_year WHERE y <> 1901.9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <> 1902) +SELECT * FROM tbl_year WHERE y < 1902.9; +y +0000 +1901 +SELECT * FROM tbl_year WHERE y <= 1902.9; +y +0000 +1901 +SELECT * FROM tbl_year WHERE y > 1902.9; +y +2018 +2155 +SELECT * FROM tbl_year WHERE y >= 1902.9; +y +2018 +2155 +SELECT * FROM tbl_year WHERE y = 1902.9; +y +SELECT * FROM tbl_year WHERE y <> 1902.9; +y +0000 +1901 +2018 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < 1902.9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` < 1903) +EXPLAIN SELECT * FROM tbl_year WHERE y <= 1902.9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <= 1903) +EXPLAIN SELECT * FROM tbl_year WHERE y > 1902.9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` > 1903) +EXPLAIN SELECT * FROM tbl_year WHERE y >= 1902.9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` >= 1903) +EXPLAIN SELECT * FROM tbl_year WHERE y = 1902.9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 25.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` = 1903) +EXPLAIN SELECT * FROM tbl_year WHERE y <> 1902.9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <> 1903) +SELECT * FROM tbl_year WHERE y < 2018.9; +y +0000 +1901 +2018 +SELECT * FROM tbl_year WHERE y <= 2018.9; +y +0000 +1901 +2018 +SELECT * FROM tbl_year WHERE y > 2018.9; +y +2155 +SELECT * FROM tbl_year WHERE y >= 2018.9; +y +2155 +SELECT * FROM tbl_year WHERE y = 2018.9; +y +SELECT * FROM tbl_year WHERE y <> 2018.9; +y +0000 +1901 +2018 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < 2018.9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` < 2019) +EXPLAIN SELECT * FROM tbl_year WHERE y <= 2018.9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <= 2019) +EXPLAIN SELECT * FROM tbl_year WHERE y > 2018.9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` > 2019) +EXPLAIN SELECT * FROM tbl_year WHERE y >= 2018.9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` >= 2019) +EXPLAIN SELECT * FROM tbl_year WHERE y = 2018.9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 25.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` = 2019) +EXPLAIN SELECT * FROM tbl_year WHERE y <> 2018.9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <> 2019) +SELECT * FROM tbl_year WHERE y < 2154.9; +y +0000 +1901 +2018 +SELECT * FROM tbl_year WHERE y <= 2154.9; +y +0000 +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y > 2154.9; +y +SELECT * FROM tbl_year WHERE y >= 2154.9; +y +2155 +SELECT * FROM tbl_year WHERE y = 2154.9; +y +2155 +SELECT * FROM tbl_year WHERE y <> 2154.9; +y +0000 +1901 +2018 +EXPLAIN SELECT * FROM tbl_year WHERE y < 2154.9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` < 2155) +EXPLAIN SELECT * FROM tbl_year WHERE y <= 2154.9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +EXPLAIN SELECT * FROM tbl_year WHERE y > 2154.9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y >= 2154.9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 25.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` = 2155) +EXPLAIN SELECT * FROM tbl_year WHERE y = 2154.9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 25.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` = 2155) +EXPLAIN SELECT * FROM tbl_year WHERE y <> 2154.9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <> 2155) +SELECT * FROM tbl_year WHERE y < 2155.9; +y +0000 +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y <= 2155.9; +y +0000 +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y > 2155.9; +y +SELECT * FROM tbl_year WHERE y >= 2155.9; +y +SELECT * FROM tbl_year WHERE y = 2155.9; +y +SELECT * FROM tbl_year WHERE y <> 2155.9; +y +0000 +1901 +2018 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < 2155.9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +EXPLAIN SELECT * FROM tbl_year WHERE y <= 2155.9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +EXPLAIN SELECT * FROM tbl_year WHERE y > 2155.9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y >= 2155.9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y = 2155.9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y <> 2155.9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +SELECT * FROM tbl_year WHERE y < 2156.9; +y +0000 +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y <= 2156.9; +y +0000 +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y > 2156.9; +y +SELECT * FROM tbl_year WHERE y >= 2156.9; +y +SELECT * FROM tbl_year WHERE y = 2156.9; +y +SELECT * FROM tbl_year WHERE y <> 2156.9; +y +0000 +1901 +2018 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < 2156.9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +EXPLAIN SELECT * FROM tbl_year WHERE y <= 2156.9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +EXPLAIN SELECT * FROM tbl_year WHERE y > 2156.9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y >= 2156.9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y = 2156.9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y <> 2156.9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +DROP TABLE tbl_year; +# R E A L constant with zero fraction +CREATE TABLE tbl_year (y YEAR ); +INSERT INTO tbl_year VALUES (0), (1901), (2018), (2155); +ANALYZE TABLE tbl_year; +Table Op Msg_type Msg_text +test.tbl_year analyze status OK +SELECT * FROM tbl_year; +y +0000 +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y < 0.0E00; +y +SELECT * FROM tbl_year WHERE y <= 0.0E00; +y +0000 +SELECT * FROM tbl_year WHERE y > 0.0E00; +y +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y >= 0.0E00; +y +0000 +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y = 0.0E00; +y +0000 +SELECT * FROM tbl_year WHERE y <> 0.0E00; +y +1901 +2018 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < 0.0E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y <= 0.0E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 25.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` = 0) +EXPLAIN SELECT * FROM tbl_year WHERE y > 0.0E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` > 0) +EXPLAIN SELECT * FROM tbl_year WHERE y >= 0.0E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +EXPLAIN SELECT * FROM tbl_year WHERE y = 0.0E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 25.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` = 0) +EXPLAIN SELECT * FROM tbl_year WHERE y <> 0.0E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <> 0) +SELECT * FROM tbl_year WHERE y < -1.0E00; +y +SELECT * FROM tbl_year WHERE y <= -1.0E00; +y +SELECT * FROM tbl_year WHERE y > -1.0E00; +y +0000 +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y >= -1.0E00; +y +0000 +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y = -1.0E00; +y +SELECT * FROM tbl_year WHERE y <> -1.0E00; +y +0000 +1901 +2018 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < -1.0E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y <= -1.0E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y > -1.0E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +EXPLAIN SELECT * FROM tbl_year WHERE y >= -1.0E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +EXPLAIN SELECT * FROM tbl_year WHERE y = -1.0E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y <> -1.0E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +SELECT * FROM tbl_year WHERE y < 1.0E00; +y +0000 +1901 +SELECT * FROM tbl_year WHERE y <= 1.0E00; +y +0000 +1901 +SELECT * FROM tbl_year WHERE y > 1.0E00; +y +2018 +2155 +SELECT * FROM tbl_year WHERE y >= 1.0E00; +y +2018 +2155 +SELECT * FROM tbl_year WHERE y = 1.0E00; +y +SELECT * FROM tbl_year WHERE y <> 1.0E00; +y +0000 +1901 +2018 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < 1.0E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` < 2001) +EXPLAIN SELECT * FROM tbl_year WHERE y <= 1.0E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <= 2001) +EXPLAIN SELECT * FROM tbl_year WHERE y > 1.0E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` > 2001) +EXPLAIN SELECT * FROM tbl_year WHERE y >= 1.0E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` >= 2001) +EXPLAIN SELECT * FROM tbl_year WHERE y = 1.0E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 25.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` = 2001) +EXPLAIN SELECT * FROM tbl_year WHERE y <> 1.0E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <> 2001) +SELECT * FROM tbl_year WHERE y < 300.0E00; +y +0000 +SELECT * FROM tbl_year WHERE y <= 300.0E00; +y +0000 +SELECT * FROM tbl_year WHERE y > 300.0E00; +y +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y >= 300.0E00; +y +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y = 300.0E00; +y +SELECT * FROM tbl_year WHERE y <> 300.0E00; +y +0000 +1901 +2018 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < 300.0E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` < 300) +EXPLAIN SELECT * FROM tbl_year WHERE y <= 300.0E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <= 300) +EXPLAIN SELECT * FROM tbl_year WHERE y > 300.0E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` > 300) +EXPLAIN SELECT * FROM tbl_year WHERE y >= 300.0E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` >= 300) +EXPLAIN SELECT * FROM tbl_year WHERE y = 300.0E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y <> 300.0E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +SELECT * FROM tbl_year WHERE y < 1900.0E00; +y +0000 +SELECT * FROM tbl_year WHERE y <= 1900.0E00; +y +0000 +SELECT * FROM tbl_year WHERE y > 1900.0E00; +y +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y >= 1900.0E00; +y +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y = 1900.0E00; +y +SELECT * FROM tbl_year WHERE y <> 1900.0E00; +y +0000 +1901 +2018 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < 1900.0E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` < 1900) +EXPLAIN SELECT * FROM tbl_year WHERE y <= 1900.0E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <= 1900) +EXPLAIN SELECT * FROM tbl_year WHERE y > 1900.0E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` > 1900) +EXPLAIN SELECT * FROM tbl_year WHERE y >= 1900.0E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` >= 1900) +EXPLAIN SELECT * FROM tbl_year WHERE y = 1900.0E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y <> 1900.0E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +SELECT * FROM tbl_year WHERE y < 1901.0E00; +y +0000 +SELECT * FROM tbl_year WHERE y <= 1901.0E00; +y +0000 +1901 +SELECT * FROM tbl_year WHERE y > 1901.0E00; +y +2018 +2155 +SELECT * FROM tbl_year WHERE y >= 1901.0E00; +y +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y = 1901.0E00; +y +1901 +SELECT * FROM tbl_year WHERE y <> 1901.0E00; +y +0000 +2018 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < 1901.0E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` < 1901) +EXPLAIN SELECT * FROM tbl_year WHERE y <= 1901.0E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <= 1901) +EXPLAIN SELECT * FROM tbl_year WHERE y > 1901.0E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` > 1901) +EXPLAIN SELECT * FROM tbl_year WHERE y >= 1901.0E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` >= 1901) +EXPLAIN SELECT * FROM tbl_year WHERE y = 1901.0E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 25.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` = 1901) +EXPLAIN SELECT * FROM tbl_year WHERE y <> 1901.0E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <> 1901) +SELECT * FROM tbl_year WHERE y < 1902.0E00; +y +0000 +1901 +SELECT * FROM tbl_year WHERE y <= 1902.0E00; +y +0000 +1901 +SELECT * FROM tbl_year WHERE y > 1902.0E00; +y +2018 +2155 +SELECT * FROM tbl_year WHERE y >= 1902.0E00; +y +2018 +2155 +SELECT * FROM tbl_year WHERE y = 1902.0E00; +y +SELECT * FROM tbl_year WHERE y <> 1902.0E00; +y +0000 +1901 +2018 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < 1902.0E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` < 1902) +EXPLAIN SELECT * FROM tbl_year WHERE y <= 1902.0E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <= 1902) +EXPLAIN SELECT * FROM tbl_year WHERE y > 1902.0E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` > 1902) +EXPLAIN SELECT * FROM tbl_year WHERE y >= 1902.0E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` >= 1902) +EXPLAIN SELECT * FROM tbl_year WHERE y = 1902.0E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 25.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` = 1902) +EXPLAIN SELECT * FROM tbl_year WHERE y <> 1902.0E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <> 1902) +SELECT * FROM tbl_year WHERE y < 2018.0E00; +y +0000 +1901 +SELECT * FROM tbl_year WHERE y <= 2018.0E00; +y +0000 +1901 +2018 +SELECT * FROM tbl_year WHERE y > 2018.0E00; +y +2155 +SELECT * FROM tbl_year WHERE y >= 2018.0E00; +y +2018 +2155 +SELECT * FROM tbl_year WHERE y = 2018.0E00; +y +2018 +SELECT * FROM tbl_year WHERE y <> 2018.0E00; +y +0000 +1901 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < 2018.0E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` < 2018) +EXPLAIN SELECT * FROM tbl_year WHERE y <= 2018.0E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <= 2018) +EXPLAIN SELECT * FROM tbl_year WHERE y > 2018.0E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` > 2018) +EXPLAIN SELECT * FROM tbl_year WHERE y >= 2018.0E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` >= 2018) +EXPLAIN SELECT * FROM tbl_year WHERE y = 2018.0E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 25.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` = 2018) +EXPLAIN SELECT * FROM tbl_year WHERE y <> 2018.0E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <> 2018) +SELECT * FROM tbl_year WHERE y < 2154.0E00; +y +0000 +1901 +2018 +SELECT * FROM tbl_year WHERE y <= 2154.0E00; +y +0000 +1901 +2018 +SELECT * FROM tbl_year WHERE y > 2154.0E00; +y +2155 +SELECT * FROM tbl_year WHERE y >= 2154.0E00; +y +2155 +SELECT * FROM tbl_year WHERE y = 2154.0E00; +y +SELECT * FROM tbl_year WHERE y <> 2154.0E00; +y +0000 +1901 +2018 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < 2154.0E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` < 2154) +EXPLAIN SELECT * FROM tbl_year WHERE y <= 2154.0E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <= 2154) +EXPLAIN SELECT * FROM tbl_year WHERE y > 2154.0E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` > 2154) +EXPLAIN SELECT * FROM tbl_year WHERE y >= 2154.0E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` >= 2154) +EXPLAIN SELECT * FROM tbl_year WHERE y = 2154.0E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 25.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` = 2154) +EXPLAIN SELECT * FROM tbl_year WHERE y <> 2154.0E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <> 2154) +SELECT * FROM tbl_year WHERE y < 2155.0E00; +y +0000 +1901 +2018 +SELECT * FROM tbl_year WHERE y <= 2155.0E00; +y +0000 +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y > 2155.0E00; +y +SELECT * FROM tbl_year WHERE y >= 2155.0E00; +y +2155 +SELECT * FROM tbl_year WHERE y = 2155.0E00; +y +2155 +SELECT * FROM tbl_year WHERE y <> 2155.0E00; +y +0000 +1901 +2018 +EXPLAIN SELECT * FROM tbl_year WHERE y < 2155.0E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` < 2155) +EXPLAIN SELECT * FROM tbl_year WHERE y <= 2155.0E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +EXPLAIN SELECT * FROM tbl_year WHERE y > 2155.0E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y >= 2155.0E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 25.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` = 2155) +EXPLAIN SELECT * FROM tbl_year WHERE y = 2155.0E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 25.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` = 2155) +EXPLAIN SELECT * FROM tbl_year WHERE y <> 2155.0E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <> 2155) +SELECT * FROM tbl_year WHERE y < 2156.0E00; +y +0000 +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y <= 2156.0E00; +y +0000 +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y > 2156.0E00; +y +SELECT * FROM tbl_year WHERE y >= 2156.0E00; +y +SELECT * FROM tbl_year WHERE y = 2156.0E00; +y +SELECT * FROM tbl_year WHERE y <> 2156.0E00; +y +0000 +1901 +2018 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < 2156.0E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +EXPLAIN SELECT * FROM tbl_year WHERE y <= 2156.0E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +EXPLAIN SELECT * FROM tbl_year WHERE y > 2156.0E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y >= 2156.0E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y = 2156.0E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y <> 2156.0E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +DROP TABLE tbl_year; +# R E A L constant with non-zero fraction +CREATE TABLE tbl_year (y YEAR ); +INSERT INTO tbl_year VALUES (0), (1901), (2018), (2155); +ANALYZE TABLE tbl_year; +Table Op Msg_type Msg_text +test.tbl_year analyze status OK +SELECT * FROM tbl_year; +y +0000 +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y < 0.1E00; +y +SELECT * FROM tbl_year WHERE y <= 0.1E00; +y +0000 +SELECT * FROM tbl_year WHERE y > 0.1E00; +y +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y >= 0.1E00; +y +0000 +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y = 0.1E00; +y +0000 +SELECT * FROM tbl_year WHERE y <> 0.1E00; +y +1901 +2018 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < 0.1E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y <= 0.1E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 25.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` = 0) +EXPLAIN SELECT * FROM tbl_year WHERE y > 0.1E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` > 0) +EXPLAIN SELECT * FROM tbl_year WHERE y >= 0.1E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +EXPLAIN SELECT * FROM tbl_year WHERE y = 0.1E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 25.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` = 0) +EXPLAIN SELECT * FROM tbl_year WHERE y <> 0.1E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <> 0) +SELECT * FROM tbl_year WHERE y < -1.1E00; +y +SELECT * FROM tbl_year WHERE y <= -1.1E00; +y +SELECT * FROM tbl_year WHERE y > -1.1E00; +y +0000 +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y >= -1.1E00; +y +0000 +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y = -1.1E00; +y +SELECT * FROM tbl_year WHERE y <> -1.1E00; +y +0000 +1901 +2018 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < -1.1E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y <= -1.1E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y > -1.1E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +EXPLAIN SELECT * FROM tbl_year WHERE y >= -1.1E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +EXPLAIN SELECT * FROM tbl_year WHERE y = -1.1E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y <> -1.1E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +SELECT * FROM tbl_year WHERE y < 1.1E00; +y +0000 +1901 +SELECT * FROM tbl_year WHERE y <= 1.1E00; +y +0000 +1901 +SELECT * FROM tbl_year WHERE y > 1.1E00; +y +2018 +2155 +SELECT * FROM tbl_year WHERE y >= 1.1E00; +y +2018 +2155 +SELECT * FROM tbl_year WHERE y = 1.1E00; +y +SELECT * FROM tbl_year WHERE y <> 1.1E00; +y +0000 +1901 +2018 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < 1.1E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` < 2001) +EXPLAIN SELECT * FROM tbl_year WHERE y <= 1.1E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <= 2001) +EXPLAIN SELECT * FROM tbl_year WHERE y > 1.1E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` > 2001) +EXPLAIN SELECT * FROM tbl_year WHERE y >= 1.1E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` >= 2001) +EXPLAIN SELECT * FROM tbl_year WHERE y = 1.1E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 25.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` = 2001) +EXPLAIN SELECT * FROM tbl_year WHERE y <> 1.1E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <> 2001) +SELECT * FROM tbl_year WHERE y < 300.1E00; +y +0000 +SELECT * FROM tbl_year WHERE y <= 300.1E00; +y +0000 +SELECT * FROM tbl_year WHERE y > 300.1E00; +y +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y >= 300.1E00; +y +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y = 300.1E00; +y +SELECT * FROM tbl_year WHERE y <> 300.1E00; +y +0000 +1901 +2018 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < 300.1E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` < 300) +EXPLAIN SELECT * FROM tbl_year WHERE y <= 300.1E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <= 300) +EXPLAIN SELECT * FROM tbl_year WHERE y > 300.1E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` > 300) +EXPLAIN SELECT * FROM tbl_year WHERE y >= 300.1E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` >= 300) +EXPLAIN SELECT * FROM tbl_year WHERE y = 300.1E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y <> 300.1E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +SELECT * FROM tbl_year WHERE y < 1900.1E00; +y +0000 +SELECT * FROM tbl_year WHERE y <= 1900.1E00; +y +0000 +SELECT * FROM tbl_year WHERE y > 1900.1E00; +y +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y >= 1900.1E00; +y +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y = 1900.1E00; +y +SELECT * FROM tbl_year WHERE y <> 1900.1E00; +y +0000 +1901 +2018 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < 1900.1E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` < 1900) +EXPLAIN SELECT * FROM tbl_year WHERE y <= 1900.1E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <= 1900) +EXPLAIN SELECT * FROM tbl_year WHERE y > 1900.1E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` > 1900) +EXPLAIN SELECT * FROM tbl_year WHERE y >= 1900.1E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` >= 1900) +EXPLAIN SELECT * FROM tbl_year WHERE y = 1900.1E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y <> 1900.1E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +SELECT * FROM tbl_year WHERE y < 1901.1E00; +y +0000 +SELECT * FROM tbl_year WHERE y <= 1901.1E00; +y +0000 +1901 +SELECT * FROM tbl_year WHERE y > 1901.1E00; +y +2018 +2155 +SELECT * FROM tbl_year WHERE y >= 1901.1E00; +y +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y = 1901.1E00; +y +1901 +SELECT * FROM tbl_year WHERE y <> 1901.1E00; +y +0000 +2018 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < 1901.1E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` < 1901) +EXPLAIN SELECT * FROM tbl_year WHERE y <= 1901.1E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <= 1901) +EXPLAIN SELECT * FROM tbl_year WHERE y > 1901.1E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` > 1901) +EXPLAIN SELECT * FROM tbl_year WHERE y >= 1901.1E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` >= 1901) +EXPLAIN SELECT * FROM tbl_year WHERE y = 1901.1E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 25.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` = 1901) +EXPLAIN SELECT * FROM tbl_year WHERE y <> 1901.1E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <> 1901) +SELECT * FROM tbl_year WHERE y < 1902.1E00; +y +0000 +1901 +SELECT * FROM tbl_year WHERE y <= 1902.1E00; +y +0000 +1901 +SELECT * FROM tbl_year WHERE y > 1902.1E00; +y +2018 +2155 +SELECT * FROM tbl_year WHERE y >= 1902.1E00; +y +2018 +2155 +SELECT * FROM tbl_year WHERE y = 1902.1E00; +y +SELECT * FROM tbl_year WHERE y <> 1902.1E00; +y +0000 +1901 +2018 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < 1902.1E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` < 1902) +EXPLAIN SELECT * FROM tbl_year WHERE y <= 1902.1E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <= 1902) +EXPLAIN SELECT * FROM tbl_year WHERE y > 1902.1E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` > 1902) +EXPLAIN SELECT * FROM tbl_year WHERE y >= 1902.1E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` >= 1902) +EXPLAIN SELECT * FROM tbl_year WHERE y = 1902.1E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 25.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` = 1902) +EXPLAIN SELECT * FROM tbl_year WHERE y <> 1902.1E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <> 1902) +SELECT * FROM tbl_year WHERE y < 2018.1E00; +y +0000 +1901 +SELECT * FROM tbl_year WHERE y <= 2018.1E00; +y +0000 +1901 +2018 +SELECT * FROM tbl_year WHERE y > 2018.1E00; +y +2155 +SELECT * FROM tbl_year WHERE y >= 2018.1E00; +y +2018 +2155 +SELECT * FROM tbl_year WHERE y = 2018.1E00; +y +2018 +SELECT * FROM tbl_year WHERE y <> 2018.1E00; +y +0000 +1901 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < 2018.1E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` < 2018) +EXPLAIN SELECT * FROM tbl_year WHERE y <= 2018.1E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <= 2018) +EXPLAIN SELECT * FROM tbl_year WHERE y > 2018.1E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` > 2018) +EXPLAIN SELECT * FROM tbl_year WHERE y >= 2018.1E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` >= 2018) +EXPLAIN SELECT * FROM tbl_year WHERE y = 2018.1E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 25.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` = 2018) +EXPLAIN SELECT * FROM tbl_year WHERE y <> 2018.1E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <> 2018) +SELECT * FROM tbl_year WHERE y < 2154.1E00; +y +0000 +1901 +2018 +SELECT * FROM tbl_year WHERE y <= 2154.1E00; +y +0000 +1901 +2018 +SELECT * FROM tbl_year WHERE y > 2154.1E00; +y +2155 +SELECT * FROM tbl_year WHERE y >= 2154.1E00; +y +2155 +SELECT * FROM tbl_year WHERE y = 2154.1E00; +y +SELECT * FROM tbl_year WHERE y <> 2154.1E00; +y +0000 +1901 +2018 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < 2154.1E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` < 2154) +EXPLAIN SELECT * FROM tbl_year WHERE y <= 2154.1E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <= 2154) +EXPLAIN SELECT * FROM tbl_year WHERE y > 2154.1E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` > 2154) +EXPLAIN SELECT * FROM tbl_year WHERE y >= 2154.1E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` >= 2154) +EXPLAIN SELECT * FROM tbl_year WHERE y = 2154.1E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 25.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` = 2154) +EXPLAIN SELECT * FROM tbl_year WHERE y <> 2154.1E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <> 2154) +SELECT * FROM tbl_year WHERE y < 2155.1E00; +y +0000 +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y <= 2155.1E00; +y +0000 +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y > 2155.1E00; +y +SELECT * FROM tbl_year WHERE y >= 2155.1E00; +y +SELECT * FROM tbl_year WHERE y = 2155.1E00; +y +SELECT * FROM tbl_year WHERE y <> 2155.1E00; +y +0000 +1901 +2018 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < 2155.1E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +EXPLAIN SELECT * FROM tbl_year WHERE y <= 2155.1E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +EXPLAIN SELECT * FROM tbl_year WHERE y > 2155.1E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y >= 2155.1E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y = 2155.1E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y <> 2155.1E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +SELECT * FROM tbl_year WHERE y < 2156.1E00; +y +0000 +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y <= 2156.1E00; +y +0000 +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y > 2156.1E00; +y +SELECT * FROM tbl_year WHERE y >= 2156.1E00; +y +SELECT * FROM tbl_year WHERE y = 2156.1E00; +y +SELECT * FROM tbl_year WHERE y <> 2156.1E00; +y +0000 +1901 +2018 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < 2156.1E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +EXPLAIN SELECT * FROM tbl_year WHERE y <= 2156.1E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +EXPLAIN SELECT * FROM tbl_year WHERE y > 2156.1E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y >= 2156.1E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y = 2156.1E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y <> 2156.1E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +DROP TABLE tbl_year; +# S T R I N G constant with I N T inside +CREATE TABLE tbl_year (y YEAR ); +INSERT INTO tbl_year VALUES (0), (1901), (2018), (2155); +ANALYZE TABLE tbl_year; +Table Op Msg_type Msg_text +test.tbl_year analyze status OK +SELECT * FROM tbl_year; +y +0000 +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y < '0'; +y +0000 +1901 +SELECT * FROM tbl_year WHERE y <= '0'; +y +0000 +1901 +SELECT * FROM tbl_year WHERE y > '0'; +y +2018 +2155 +SELECT * FROM tbl_year WHERE y >= '0'; +y +2018 +2155 +SELECT * FROM tbl_year WHERE y = '0'; +y +SELECT * FROM tbl_year WHERE y <> '0'; +y +0000 +1901 +2018 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < '0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` < 2000) +EXPLAIN SELECT * FROM tbl_year WHERE y <= '0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <= 2000) +EXPLAIN SELECT * FROM tbl_year WHERE y > '0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` > 2000) +EXPLAIN SELECT * FROM tbl_year WHERE y >= '0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` >= 2000) +EXPLAIN SELECT * FROM tbl_year WHERE y = '0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 25.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` = 2000) +EXPLAIN SELECT * FROM tbl_year WHERE y <> '0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <> 2000) +SELECT * FROM tbl_year WHERE y < '-1'; +y +SELECT * FROM tbl_year WHERE y <= '-1'; +y +SELECT * FROM tbl_year WHERE y > '-1'; +y +0000 +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y >= '-1'; +y +0000 +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y = '-1'; +y +SELECT * FROM tbl_year WHERE y <> '-1'; +y +0000 +1901 +2018 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < '-1'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y <= '-1'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y > '-1'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +EXPLAIN SELECT * FROM tbl_year WHERE y >= '-1'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +EXPLAIN SELECT * FROM tbl_year WHERE y = '-1'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y <> '-1'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +SELECT * FROM tbl_year WHERE y < '1'; +y +0000 +1901 +SELECT * FROM tbl_year WHERE y <= '1'; +y +0000 +1901 +SELECT * FROM tbl_year WHERE y > '1'; +y +2018 +2155 +SELECT * FROM tbl_year WHERE y >= '1'; +y +2018 +2155 +SELECT * FROM tbl_year WHERE y = '1'; +y +SELECT * FROM tbl_year WHERE y <> '1'; +y +0000 +1901 +2018 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < '1'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` < 2001) +EXPLAIN SELECT * FROM tbl_year WHERE y <= '1'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <= 2001) +EXPLAIN SELECT * FROM tbl_year WHERE y > '1'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` > 2001) +EXPLAIN SELECT * FROM tbl_year WHERE y >= '1'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` >= 2001) +EXPLAIN SELECT * FROM tbl_year WHERE y = '1'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 25.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` = 2001) +EXPLAIN SELECT * FROM tbl_year WHERE y <> '1'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <> 2001) +SELECT * FROM tbl_year WHERE y < '300'; +y +0000 +SELECT * FROM tbl_year WHERE y <= '300'; +y +0000 +SELECT * FROM tbl_year WHERE y > '300'; +y +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y >= '300'; +y +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y = '300'; +y +SELECT * FROM tbl_year WHERE y <> '300'; +y +0000 +1901 +2018 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < '300'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` < 300) +EXPLAIN SELECT * FROM tbl_year WHERE y <= '300'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <= 300) +EXPLAIN SELECT * FROM tbl_year WHERE y > '300'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` > 300) +EXPLAIN SELECT * FROM tbl_year WHERE y >= '300'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` >= 300) +EXPLAIN SELECT * FROM tbl_year WHERE y = '300'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y <> '300'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +SELECT * FROM tbl_year WHERE y < '1900'; +y +0000 +SELECT * FROM tbl_year WHERE y <= '1900'; +y +0000 +SELECT * FROM tbl_year WHERE y > '1900'; +y +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y >= '1900'; +y +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y = '1900'; +y +SELECT * FROM tbl_year WHERE y <> '1900'; +y +0000 +1901 +2018 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < '1900'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` < 1900) +EXPLAIN SELECT * FROM tbl_year WHERE y <= '1900'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <= 1900) +EXPLAIN SELECT * FROM tbl_year WHERE y > '1900'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` > 1900) +EXPLAIN SELECT * FROM tbl_year WHERE y >= '1900'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` >= 1900) +EXPLAIN SELECT * FROM tbl_year WHERE y = '1900'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y <> '1900'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +SELECT * FROM tbl_year WHERE y < '1901'; +y +0000 +SELECT * FROM tbl_year WHERE y <= '1901'; +y +0000 +1901 +SELECT * FROM tbl_year WHERE y > '1901'; +y +2018 +2155 +SELECT * FROM tbl_year WHERE y >= '1901'; +y +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y = '1901'; +y +1901 +SELECT * FROM tbl_year WHERE y <> '1901'; +y +0000 +2018 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < '1901'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` < 1901) +EXPLAIN SELECT * FROM tbl_year WHERE y <= '1901'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <= 1901) +EXPLAIN SELECT * FROM tbl_year WHERE y > '1901'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` > 1901) +EXPLAIN SELECT * FROM tbl_year WHERE y >= '1901'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` >= 1901) +EXPLAIN SELECT * FROM tbl_year WHERE y = '1901'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 25.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` = 1901) +EXPLAIN SELECT * FROM tbl_year WHERE y <> '1901'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <> 1901) +SELECT * FROM tbl_year WHERE y < '1902'; +y +0000 +1901 +SELECT * FROM tbl_year WHERE y <= '1902'; +y +0000 +1901 +SELECT * FROM tbl_year WHERE y > '1902'; +y +2018 +2155 +SELECT * FROM tbl_year WHERE y >= '1902'; +y +2018 +2155 +SELECT * FROM tbl_year WHERE y = '1902'; +y +SELECT * FROM tbl_year WHERE y <> '1902'; +y +0000 +1901 +2018 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < '1902'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` < 1902) +EXPLAIN SELECT * FROM tbl_year WHERE y <= '1902'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <= 1902) +EXPLAIN SELECT * FROM tbl_year WHERE y > '1902'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` > 1902) +EXPLAIN SELECT * FROM tbl_year WHERE y >= '1902'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` >= 1902) +EXPLAIN SELECT * FROM tbl_year WHERE y = '1902'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 25.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` = 1902) +EXPLAIN SELECT * FROM tbl_year WHERE y <> '1902'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <> 1902) +SELECT * FROM tbl_year WHERE y < '2018'; +y +0000 +1901 +SELECT * FROM tbl_year WHERE y <= '2018'; +y +0000 +1901 +2018 +SELECT * FROM tbl_year WHERE y > '2018'; +y +2155 +SELECT * FROM tbl_year WHERE y >= '2018'; +y +2018 +2155 +SELECT * FROM tbl_year WHERE y = '2018'; +y +2018 +SELECT * FROM tbl_year WHERE y <> '2018'; +y +0000 +1901 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < '2018'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` < 2018) +EXPLAIN SELECT * FROM tbl_year WHERE y <= '2018'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <= 2018) +EXPLAIN SELECT * FROM tbl_year WHERE y > '2018'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` > 2018) +EXPLAIN SELECT * FROM tbl_year WHERE y >= '2018'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` >= 2018) +EXPLAIN SELECT * FROM tbl_year WHERE y = '2018'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 25.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` = 2018) +EXPLAIN SELECT * FROM tbl_year WHERE y <> '2018'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <> 2018) +SELECT * FROM tbl_year WHERE y < '2154'; +y +0000 +1901 +2018 +SELECT * FROM tbl_year WHERE y <= '2154'; +y +0000 +1901 +2018 +SELECT * FROM tbl_year WHERE y > '2154'; +y +2155 +SELECT * FROM tbl_year WHERE y >= '2154'; +y +2155 +SELECT * FROM tbl_year WHERE y = '2154'; +y +SELECT * FROM tbl_year WHERE y <> '2154'; +y +0000 +1901 +2018 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < '2154'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` < 2154) +EXPLAIN SELECT * FROM tbl_year WHERE y <= '2154'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <= 2154) +EXPLAIN SELECT * FROM tbl_year WHERE y > '2154'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` > 2154) +EXPLAIN SELECT * FROM tbl_year WHERE y >= '2154'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` >= 2154) +EXPLAIN SELECT * FROM tbl_year WHERE y = '2154'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 25.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` = 2154) +EXPLAIN SELECT * FROM tbl_year WHERE y <> '2154'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <> 2154) +SELECT * FROM tbl_year WHERE y < '2155'; +y +0000 +1901 +2018 +SELECT * FROM tbl_year WHERE y <= '2155'; +y +0000 +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y > '2155'; +y +SELECT * FROM tbl_year WHERE y >= '2155'; +y +2155 +SELECT * FROM tbl_year WHERE y = '2155'; +y +2155 +SELECT * FROM tbl_year WHERE y <> '2155'; +y +0000 +1901 +2018 +EXPLAIN SELECT * FROM tbl_year WHERE y < '2155'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` < 2155) +EXPLAIN SELECT * FROM tbl_year WHERE y <= '2155'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +EXPLAIN SELECT * FROM tbl_year WHERE y > '2155'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y >= '2155'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 25.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` = 2155) +EXPLAIN SELECT * FROM tbl_year WHERE y = '2155'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 25.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` = 2155) +EXPLAIN SELECT * FROM tbl_year WHERE y <> '2155'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <> 2155) +SELECT * FROM tbl_year WHERE y < '2156'; +y +0000 +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y <= '2156'; +y +0000 +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y > '2156'; +y +SELECT * FROM tbl_year WHERE y >= '2156'; +y +SELECT * FROM tbl_year WHERE y = '2156'; +y +SELECT * FROM tbl_year WHERE y <> '2156'; +y +0000 +1901 +2018 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < '2156'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +EXPLAIN SELECT * FROM tbl_year WHERE y <= '2156'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +EXPLAIN SELECT * FROM tbl_year WHERE y > '2156'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y >= '2156'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y = '2156'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y <> '2156'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +DROP TABLE tbl_year; +# S T R I N G constant with abbreviated I N T inside +CREATE TABLE tbl_year (y YEAR ); +INSERT INTO tbl_year VALUES (0), (1901), (2018), (2155); +ANALYZE TABLE tbl_year; +Table Op Msg_type Msg_text +test.tbl_year analyze status OK +SELECT * FROM tbl_year; +y +0000 +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y < '0'; +y +0000 +1901 +SELECT * FROM tbl_year WHERE y <= '0'; +y +0000 +1901 +SELECT * FROM tbl_year WHERE y > '0'; +y +2018 +2155 +SELECT * FROM tbl_year WHERE y >= '0'; +y +2018 +2155 +SELECT * FROM tbl_year WHERE y = '0'; +y +SELECT * FROM tbl_year WHERE y <> '0'; +y +0000 +1901 +2018 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < '0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` < 2000) +EXPLAIN SELECT * FROM tbl_year WHERE y <= '0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <= 2000) +EXPLAIN SELECT * FROM tbl_year WHERE y > '0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` > 2000) +EXPLAIN SELECT * FROM tbl_year WHERE y >= '0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` >= 2000) +EXPLAIN SELECT * FROM tbl_year WHERE y = '0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 25.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` = 2000) +EXPLAIN SELECT * FROM tbl_year WHERE y <> '0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <> 2000) +SELECT * FROM tbl_year WHERE y < '-1'; +y +SELECT * FROM tbl_year WHERE y <= '-1'; +y +SELECT * FROM tbl_year WHERE y > '-1'; +y +0000 +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y >= '-1'; +y +0000 +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y = '-1'; +y +SELECT * FROM tbl_year WHERE y <> '-1'; +y +0000 +1901 +2018 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < '-1'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y <= '-1'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y > '-1'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +EXPLAIN SELECT * FROM tbl_year WHERE y >= '-1'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +EXPLAIN SELECT * FROM tbl_year WHERE y = '-1'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y <> '-1'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +SELECT * FROM tbl_year WHERE y < '1'; +y +0000 +1901 +SELECT * FROM tbl_year WHERE y <= '1'; +y +0000 +1901 +SELECT * FROM tbl_year WHERE y > '1'; +y +2018 +2155 +SELECT * FROM tbl_year WHERE y >= '1'; +y +2018 +2155 +SELECT * FROM tbl_year WHERE y = '1'; +y +SELECT * FROM tbl_year WHERE y <> '1'; +y +0000 +1901 +2018 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < '1'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` < 2001) +EXPLAIN SELECT * FROM tbl_year WHERE y <= '1'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <= 2001) +EXPLAIN SELECT * FROM tbl_year WHERE y > '1'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` > 2001) +EXPLAIN SELECT * FROM tbl_year WHERE y >= '1'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` >= 2001) +EXPLAIN SELECT * FROM tbl_year WHERE y = '1'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 25.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` = 2001) +EXPLAIN SELECT * FROM tbl_year WHERE y <> '1'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <> 2001) +SELECT * FROM tbl_year WHERE y < '300'; +y +0000 +SELECT * FROM tbl_year WHERE y <= '300'; +y +0000 +SELECT * FROM tbl_year WHERE y > '300'; +y +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y >= '300'; +y +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y = '300'; +y +SELECT * FROM tbl_year WHERE y <> '300'; +y +0000 +1901 +2018 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < '300'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` < 300) +EXPLAIN SELECT * FROM tbl_year WHERE y <= '300'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <= 300) +EXPLAIN SELECT * FROM tbl_year WHERE y > '300'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` > 300) +EXPLAIN SELECT * FROM tbl_year WHERE y >= '300'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` >= 300) +EXPLAIN SELECT * FROM tbl_year WHERE y = '300'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y <> '300'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +SELECT * FROM tbl_year WHERE y < '1900'; +y +0000 +SELECT * FROM tbl_year WHERE y <= '1900'; +y +0000 +SELECT * FROM tbl_year WHERE y > '1900'; +y +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y >= '1900'; +y +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y = '1900'; +y +SELECT * FROM tbl_year WHERE y <> '1900'; +y +0000 +1901 +2018 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < '1900'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` < 1900) +EXPLAIN SELECT * FROM tbl_year WHERE y <= '1900'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <= 1900) +EXPLAIN SELECT * FROM tbl_year WHERE y > '1900'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` > 1900) +EXPLAIN SELECT * FROM tbl_year WHERE y >= '1900'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` >= 1900) +EXPLAIN SELECT * FROM tbl_year WHERE y = '1900'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y <> '1900'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +SELECT * FROM tbl_year WHERE y < '01'; +y +0000 +1901 +SELECT * FROM tbl_year WHERE y <= '01'; +y +0000 +1901 +SELECT * FROM tbl_year WHERE y > '01'; +y +2018 +2155 +SELECT * FROM tbl_year WHERE y >= '01'; +y +2018 +2155 +SELECT * FROM tbl_year WHERE y = '01'; +y +SELECT * FROM tbl_year WHERE y <> '01'; +y +0000 +1901 +2018 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < '01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` < 2001) +EXPLAIN SELECT * FROM tbl_year WHERE y <= '01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <= 2001) +EXPLAIN SELECT * FROM tbl_year WHERE y > '01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` > 2001) +EXPLAIN SELECT * FROM tbl_year WHERE y >= '01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` >= 2001) +EXPLAIN SELECT * FROM tbl_year WHERE y = '01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 25.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` = 2001) +EXPLAIN SELECT * FROM tbl_year WHERE y <> '01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <> 2001) +SELECT * FROM tbl_year WHERE y < '02'; +y +0000 +1901 +SELECT * FROM tbl_year WHERE y <= '02'; +y +0000 +1901 +SELECT * FROM tbl_year WHERE y > '02'; +y +2018 +2155 +SELECT * FROM tbl_year WHERE y >= '02'; +y +2018 +2155 +SELECT * FROM tbl_year WHERE y = '02'; +y +SELECT * FROM tbl_year WHERE y <> '02'; +y +0000 +1901 +2018 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < '02'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` < 2002) +EXPLAIN SELECT * FROM tbl_year WHERE y <= '02'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <= 2002) +EXPLAIN SELECT * FROM tbl_year WHERE y > '02'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` > 2002) +EXPLAIN SELECT * FROM tbl_year WHERE y >= '02'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` >= 2002) +EXPLAIN SELECT * FROM tbl_year WHERE y = '02'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 25.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` = 2002) +EXPLAIN SELECT * FROM tbl_year WHERE y <> '02'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <> 2002) +SELECT * FROM tbl_year WHERE y < '18'; +y +0000 +1901 +SELECT * FROM tbl_year WHERE y <= '18'; +y +0000 +1901 +2018 +SELECT * FROM tbl_year WHERE y > '18'; +y +2155 +SELECT * FROM tbl_year WHERE y >= '18'; +y +2018 +2155 +SELECT * FROM tbl_year WHERE y = '18'; +y +2018 +SELECT * FROM tbl_year WHERE y <> '18'; +y +0000 +1901 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < '18'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` < 2018) +EXPLAIN SELECT * FROM tbl_year WHERE y <= '18'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <= 2018) +EXPLAIN SELECT * FROM tbl_year WHERE y > '18'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` > 2018) +EXPLAIN SELECT * FROM tbl_year WHERE y >= '18'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` >= 2018) +EXPLAIN SELECT * FROM tbl_year WHERE y = '18'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 25.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` = 2018) +EXPLAIN SELECT * FROM tbl_year WHERE y <> '18'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <> 2018) +SELECT * FROM tbl_year WHERE y < '2154'; +y +0000 +1901 +2018 +SELECT * FROM tbl_year WHERE y <= '2154'; +y +0000 +1901 +2018 +SELECT * FROM tbl_year WHERE y > '2154'; +y +2155 +SELECT * FROM tbl_year WHERE y >= '2154'; +y +2155 +SELECT * FROM tbl_year WHERE y = '2154'; +y +SELECT * FROM tbl_year WHERE y <> '2154'; +y +0000 +1901 +2018 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < '2154'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` < 2154) +EXPLAIN SELECT * FROM tbl_year WHERE y <= '2154'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <= 2154) +EXPLAIN SELECT * FROM tbl_year WHERE y > '2154'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` > 2154) +EXPLAIN SELECT * FROM tbl_year WHERE y >= '2154'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` >= 2154) +EXPLAIN SELECT * FROM tbl_year WHERE y = '2154'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 25.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` = 2154) +EXPLAIN SELECT * FROM tbl_year WHERE y <> '2154'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <> 2154) +SELECT * FROM tbl_year WHERE y < '2155'; +y +0000 +1901 +2018 +SELECT * FROM tbl_year WHERE y <= '2155'; +y +0000 +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y > '2155'; +y +SELECT * FROM tbl_year WHERE y >= '2155'; +y +2155 +SELECT * FROM tbl_year WHERE y = '2155'; +y +2155 +SELECT * FROM tbl_year WHERE y <> '2155'; +y +0000 +1901 +2018 +EXPLAIN SELECT * FROM tbl_year WHERE y < '2155'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` < 2155) +EXPLAIN SELECT * FROM tbl_year WHERE y <= '2155'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +EXPLAIN SELECT * FROM tbl_year WHERE y > '2155'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y >= '2155'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 25.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` = 2155) +EXPLAIN SELECT * FROM tbl_year WHERE y = '2155'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 25.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` = 2155) +EXPLAIN SELECT * FROM tbl_year WHERE y <> '2155'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <> 2155) +SELECT * FROM tbl_year WHERE y < '2156'; +y +0000 +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y <= '2156'; +y +0000 +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y > '2156'; +y +SELECT * FROM tbl_year WHERE y >= '2156'; +y +SELECT * FROM tbl_year WHERE y = '2156'; +y +SELECT * FROM tbl_year WHERE y <> '2156'; +y +0000 +1901 +2018 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < '2156'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +EXPLAIN SELECT * FROM tbl_year WHERE y <= '2156'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +EXPLAIN SELECT * FROM tbl_year WHERE y > '2156'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y >= '2156'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y = '2156'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y <> '2156'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +DROP TABLE tbl_year; +# S T R I N G constant with D E C I M A L inside +CREATE TABLE tbl_year (y YEAR ); +INSERT INTO tbl_year VALUES (0), (1901), (2018), (2155); +ANALYZE TABLE tbl_year; +Table Op Msg_type Msg_text +test.tbl_year analyze status OK +SELECT * FROM tbl_year; +y +0000 +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y < '0.0'; +y +0000 +1901 +SELECT * FROM tbl_year WHERE y <= '0.0'; +y +0000 +1901 +SELECT * FROM tbl_year WHERE y > '0.0'; +y +2018 +2155 +SELECT * FROM tbl_year WHERE y >= '0.0'; +y +2018 +2155 +SELECT * FROM tbl_year WHERE y = '0.0'; +y +SELECT * FROM tbl_year WHERE y <> '0.0'; +y +0000 +1901 +2018 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < '0.0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` < 2000) +EXPLAIN SELECT * FROM tbl_year WHERE y <= '0.0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <= 2000) +EXPLAIN SELECT * FROM tbl_year WHERE y > '0.0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` > 2000) +EXPLAIN SELECT * FROM tbl_year WHERE y >= '0.0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` >= 2000) +EXPLAIN SELECT * FROM tbl_year WHERE y = '0.0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 25.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` = 2000) +EXPLAIN SELECT * FROM tbl_year WHERE y <> '0.0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <> 2000) +SELECT * FROM tbl_year WHERE y < '-1.0'; +y +SELECT * FROM tbl_year WHERE y <= '-1.0'; +y +SELECT * FROM tbl_year WHERE y > '-1.0'; +y +0000 +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y >= '-1.0'; +y +0000 +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y = '-1.0'; +y +SELECT * FROM tbl_year WHERE y <> '-1.0'; +y +0000 +1901 +2018 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < '-1.0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y <= '-1.0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y > '-1.0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +EXPLAIN SELECT * FROM tbl_year WHERE y >= '-1.0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +EXPLAIN SELECT * FROM tbl_year WHERE y = '-1.0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y <> '-1.0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +SELECT * FROM tbl_year WHERE y < '1.0'; +y +0000 +1901 +SELECT * FROM tbl_year WHERE y <= '1.0'; +y +0000 +1901 +SELECT * FROM tbl_year WHERE y > '1.0'; +y +2018 +2155 +SELECT * FROM tbl_year WHERE y >= '1.0'; +y +2018 +2155 +SELECT * FROM tbl_year WHERE y = '1.0'; +y +SELECT * FROM tbl_year WHERE y <> '1.0'; +y +0000 +1901 +2018 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < '1.0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` < 2001) +EXPLAIN SELECT * FROM tbl_year WHERE y <= '1.0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <= 2001) +EXPLAIN SELECT * FROM tbl_year WHERE y > '1.0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` > 2001) +EXPLAIN SELECT * FROM tbl_year WHERE y >= '1.0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` >= 2001) +EXPLAIN SELECT * FROM tbl_year WHERE y = '1.0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 25.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` = 2001) +EXPLAIN SELECT * FROM tbl_year WHERE y <> '1.0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <> 2001) +SELECT * FROM tbl_year WHERE y < '300.0'; +y +0000 +SELECT * FROM tbl_year WHERE y <= '300.0'; +y +0000 +SELECT * FROM tbl_year WHERE y > '300.0'; +y +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y >= '300.0'; +y +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y = '300.0'; +y +SELECT * FROM tbl_year WHERE y <> '300.0'; +y +0000 +1901 +2018 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < '300.0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` < 300) +EXPLAIN SELECT * FROM tbl_year WHERE y <= '300.0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <= 300) +EXPLAIN SELECT * FROM tbl_year WHERE y > '300.0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` > 300) +EXPLAIN SELECT * FROM tbl_year WHERE y >= '300.0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` >= 300) +EXPLAIN SELECT * FROM tbl_year WHERE y = '300.0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y <> '300.0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +SELECT * FROM tbl_year WHERE y < '1900.0'; +y +0000 +SELECT * FROM tbl_year WHERE y <= '1900.0'; +y +0000 +SELECT * FROM tbl_year WHERE y > '1900.0'; +y +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y >= '1900.0'; +y +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y = '1900.0'; +y +SELECT * FROM tbl_year WHERE y <> '1900.0'; +y +0000 +1901 +2018 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < '1900.0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` < 1900) +EXPLAIN SELECT * FROM tbl_year WHERE y <= '1900.0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <= 1900) +EXPLAIN SELECT * FROM tbl_year WHERE y > '1900.0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` > 1900) +EXPLAIN SELECT * FROM tbl_year WHERE y >= '1900.0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` >= 1900) +EXPLAIN SELECT * FROM tbl_year WHERE y = '1900.0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y <> '1900.0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +SELECT * FROM tbl_year WHERE y < '1901.0'; +y +0000 +SELECT * FROM tbl_year WHERE y <= '1901.0'; +y +0000 +1901 +SELECT * FROM tbl_year WHERE y > '1901.0'; +y +2018 +2155 +SELECT * FROM tbl_year WHERE y >= '1901.0'; +y +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y = '1901.0'; +y +1901 +SELECT * FROM tbl_year WHERE y <> '1901.0'; +y +0000 +2018 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < '1901.0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` < 1901) +EXPLAIN SELECT * FROM tbl_year WHERE y <= '1901.0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <= 1901) +EXPLAIN SELECT * FROM tbl_year WHERE y > '1901.0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` > 1901) +EXPLAIN SELECT * FROM tbl_year WHERE y >= '1901.0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` >= 1901) +EXPLAIN SELECT * FROM tbl_year WHERE y = '1901.0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 25.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` = 1901) +EXPLAIN SELECT * FROM tbl_year WHERE y <> '1901.0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <> 1901) +SELECT * FROM tbl_year WHERE y < '1902.0'; +y +0000 +1901 +SELECT * FROM tbl_year WHERE y <= '1902.0'; +y +0000 +1901 +SELECT * FROM tbl_year WHERE y > '1902.0'; +y +2018 +2155 +SELECT * FROM tbl_year WHERE y >= '1902.0'; +y +2018 +2155 +SELECT * FROM tbl_year WHERE y = '1902.0'; +y +SELECT * FROM tbl_year WHERE y <> '1902.0'; +y +0000 +1901 +2018 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < '1902.0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` < 1902) +EXPLAIN SELECT * FROM tbl_year WHERE y <= '1902.0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <= 1902) +EXPLAIN SELECT * FROM tbl_year WHERE y > '1902.0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` > 1902) +EXPLAIN SELECT * FROM tbl_year WHERE y >= '1902.0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` >= 1902) +EXPLAIN SELECT * FROM tbl_year WHERE y = '1902.0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 25.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` = 1902) +EXPLAIN SELECT * FROM tbl_year WHERE y <> '1902.0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <> 1902) +SELECT * FROM tbl_year WHERE y < '2018.0'; +y +0000 +1901 +SELECT * FROM tbl_year WHERE y <= '2018.0'; +y +0000 +1901 +2018 +SELECT * FROM tbl_year WHERE y > '2018.0'; +y +2155 +SELECT * FROM tbl_year WHERE y >= '2018.0'; +y +2018 +2155 +SELECT * FROM tbl_year WHERE y = '2018.0'; +y +2018 +SELECT * FROM tbl_year WHERE y <> '2018.0'; +y +0000 +1901 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < '2018.0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` < 2018) +EXPLAIN SELECT * FROM tbl_year WHERE y <= '2018.0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <= 2018) +EXPLAIN SELECT * FROM tbl_year WHERE y > '2018.0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` > 2018) +EXPLAIN SELECT * FROM tbl_year WHERE y >= '2018.0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` >= 2018) +EXPLAIN SELECT * FROM tbl_year WHERE y = '2018.0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 25.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` = 2018) +EXPLAIN SELECT * FROM tbl_year WHERE y <> '2018.0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <> 2018) +SELECT * FROM tbl_year WHERE y < '2154.0'; +y +0000 +1901 +2018 +SELECT * FROM tbl_year WHERE y <= '2154.0'; +y +0000 +1901 +2018 +SELECT * FROM tbl_year WHERE y > '2154.0'; +y +2155 +SELECT * FROM tbl_year WHERE y >= '2154.0'; +y +2155 +SELECT * FROM tbl_year WHERE y = '2154.0'; +y +SELECT * FROM tbl_year WHERE y <> '2154.0'; +y +0000 +1901 +2018 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < '2154.0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` < 2154) +EXPLAIN SELECT * FROM tbl_year WHERE y <= '2154.0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <= 2154) +EXPLAIN SELECT * FROM tbl_year WHERE y > '2154.0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` > 2154) +EXPLAIN SELECT * FROM tbl_year WHERE y >= '2154.0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` >= 2154) +EXPLAIN SELECT * FROM tbl_year WHERE y = '2154.0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 25.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` = 2154) +EXPLAIN SELECT * FROM tbl_year WHERE y <> '2154.0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <> 2154) +SELECT * FROM tbl_year WHERE y < '2155.0'; +y +0000 +1901 +2018 +SELECT * FROM tbl_year WHERE y <= '2155.0'; +y +0000 +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y > '2155.0'; +y +SELECT * FROM tbl_year WHERE y >= '2155.0'; +y +2155 +SELECT * FROM tbl_year WHERE y = '2155.0'; +y +2155 +SELECT * FROM tbl_year WHERE y <> '2155.0'; +y +0000 +1901 +2018 +EXPLAIN SELECT * FROM tbl_year WHERE y < '2155.0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` < 2155) +EXPLAIN SELECT * FROM tbl_year WHERE y <= '2155.0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +EXPLAIN SELECT * FROM tbl_year WHERE y > '2155.0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y >= '2155.0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 25.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` = 2155) +EXPLAIN SELECT * FROM tbl_year WHERE y = '2155.0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 25.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` = 2155) +EXPLAIN SELECT * FROM tbl_year WHERE y <> '2155.0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <> 2155) +SELECT * FROM tbl_year WHERE y < '2156.0'; +y +0000 +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y <= '2156.0'; +y +0000 +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y > '2156.0'; +y +SELECT * FROM tbl_year WHERE y >= '2156.0'; +y +SELECT * FROM tbl_year WHERE y = '2156.0'; +y +SELECT * FROM tbl_year WHERE y <> '2156.0'; +y +0000 +1901 +2018 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < '2156.0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +EXPLAIN SELECT * FROM tbl_year WHERE y <= '2156.0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +EXPLAIN SELECT * FROM tbl_year WHERE y > '2156.0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y >= '2156.0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y = '2156.0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y <> '2156.0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +DROP TABLE tbl_year; +# S T R I N G constant with R E A L inside +CREATE TABLE tbl_year (y YEAR ); +INSERT INTO tbl_year VALUES (0), (1901), (2018), (2155); +ANALYZE TABLE tbl_year; +Table Op Msg_type Msg_text +test.tbl_year analyze status OK +SELECT * FROM tbl_year; +y +0000 +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y < '0.0E00'; +y +0000 +1901 +SELECT * FROM tbl_year WHERE y <= '0.0E00'; +y +0000 +1901 +SELECT * FROM tbl_year WHERE y > '0.0E00'; +y +2018 +2155 +SELECT * FROM tbl_year WHERE y >= '0.0E00'; +y +2018 +2155 +SELECT * FROM tbl_year WHERE y = '0.0E00'; +y +SELECT * FROM tbl_year WHERE y <> '0.0E00'; +y +0000 +1901 +2018 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < '0.0E00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` < 2000) +EXPLAIN SELECT * FROM tbl_year WHERE y <= '0.0E00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <= 2000) +EXPLAIN SELECT * FROM tbl_year WHERE y > '0.0E00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` > 2000) +EXPLAIN SELECT * FROM tbl_year WHERE y >= '0.0E00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` >= 2000) +EXPLAIN SELECT * FROM tbl_year WHERE y = '0.0E00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 25.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` = 2000) +EXPLAIN SELECT * FROM tbl_year WHERE y <> '0.0E00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <> 2000) +SELECT * FROM tbl_year WHERE y < '-1.0E00'; +y +SELECT * FROM tbl_year WHERE y <= '-1.0E00'; +y +SELECT * FROM tbl_year WHERE y > '-1.0E00'; +y +0000 +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y >= '-1.0E00'; +y +0000 +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y = '-1.0E00'; +y +SELECT * FROM tbl_year WHERE y <> '-1.0E00'; +y +0000 +1901 +2018 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < '-1.0E00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y <= '-1.0E00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y > '-1.0E00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +EXPLAIN SELECT * FROM tbl_year WHERE y >= '-1.0E00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +EXPLAIN SELECT * FROM tbl_year WHERE y = '-1.0E00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y <> '-1.0E00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +SELECT * FROM tbl_year WHERE y < '1.0E00'; +y +0000 +1901 +SELECT * FROM tbl_year WHERE y <= '1.0E00'; +y +0000 +1901 +SELECT * FROM tbl_year WHERE y > '1.0E00'; +y +2018 +2155 +SELECT * FROM tbl_year WHERE y >= '1.0E00'; +y +2018 +2155 +SELECT * FROM tbl_year WHERE y = '1.0E00'; +y +SELECT * FROM tbl_year WHERE y <> '1.0E00'; +y +0000 +1901 +2018 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < '1.0E00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` < 2001) +EXPLAIN SELECT * FROM tbl_year WHERE y <= '1.0E00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <= 2001) +EXPLAIN SELECT * FROM tbl_year WHERE y > '1.0E00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` > 2001) +EXPLAIN SELECT * FROM tbl_year WHERE y >= '1.0E00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` >= 2001) +EXPLAIN SELECT * FROM tbl_year WHERE y = '1.0E00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 25.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` = 2001) +EXPLAIN SELECT * FROM tbl_year WHERE y <> '1.0E00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <> 2001) +SELECT * FROM tbl_year WHERE y < '300.0E00'; +y +0000 +SELECT * FROM tbl_year WHERE y <= '300.0E00'; +y +0000 +SELECT * FROM tbl_year WHERE y > '300.0E00'; +y +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y >= '300.0E00'; +y +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y = '300.0E00'; +y +SELECT * FROM tbl_year WHERE y <> '300.0E00'; +y +0000 +1901 +2018 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < '300.0E00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` < 300) +EXPLAIN SELECT * FROM tbl_year WHERE y <= '300.0E00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <= 300) +EXPLAIN SELECT * FROM tbl_year WHERE y > '300.0E00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` > 300) +EXPLAIN SELECT * FROM tbl_year WHERE y >= '300.0E00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` >= 300) +EXPLAIN SELECT * FROM tbl_year WHERE y = '300.0E00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y <> '300.0E00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +SELECT * FROM tbl_year WHERE y < '1900.0E00'; +y +0000 +SELECT * FROM tbl_year WHERE y <= '1900.0E00'; +y +0000 +SELECT * FROM tbl_year WHERE y > '1900.0E00'; +y +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y >= '1900.0E00'; +y +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y = '1900.0E00'; +y +SELECT * FROM tbl_year WHERE y <> '1900.0E00'; +y +0000 +1901 +2018 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < '1900.0E00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` < 1900) +EXPLAIN SELECT * FROM tbl_year WHERE y <= '1900.0E00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <= 1900) +EXPLAIN SELECT * FROM tbl_year WHERE y > '1900.0E00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` > 1900) +EXPLAIN SELECT * FROM tbl_year WHERE y >= '1900.0E00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` >= 1900) +EXPLAIN SELECT * FROM tbl_year WHERE y = '1900.0E00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y <> '1900.0E00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +SELECT * FROM tbl_year WHERE y < '1901.0E00'; +y +0000 +SELECT * FROM tbl_year WHERE y <= '1901.0E00'; +y +0000 +1901 +SELECT * FROM tbl_year WHERE y > '1901.0E00'; +y +2018 +2155 +SELECT * FROM tbl_year WHERE y >= '1901.0E00'; +y +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y = '1901.0E00'; +y +1901 +SELECT * FROM tbl_year WHERE y <> '1901.0E00'; +y +0000 +2018 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < '1901.0E00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` < 1901) +EXPLAIN SELECT * FROM tbl_year WHERE y <= '1901.0E00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <= 1901) +EXPLAIN SELECT * FROM tbl_year WHERE y > '1901.0E00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` > 1901) +EXPLAIN SELECT * FROM tbl_year WHERE y >= '1901.0E00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` >= 1901) +EXPLAIN SELECT * FROM tbl_year WHERE y = '1901.0E00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 25.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` = 1901) +EXPLAIN SELECT * FROM tbl_year WHERE y <> '1901.0E00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <> 1901) +SELECT * FROM tbl_year WHERE y < '1902.0E00'; +y +0000 +1901 +SELECT * FROM tbl_year WHERE y <= '1902.0E00'; +y +0000 +1901 +SELECT * FROM tbl_year WHERE y > '1902.0E00'; +y +2018 +2155 +SELECT * FROM tbl_year WHERE y >= '1902.0E00'; +y +2018 +2155 +SELECT * FROM tbl_year WHERE y = '1902.0E00'; +y +SELECT * FROM tbl_year WHERE y <> '1902.0E00'; +y +0000 +1901 +2018 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < '1902.0E00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` < 1902) +EXPLAIN SELECT * FROM tbl_year WHERE y <= '1902.0E00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <= 1902) +EXPLAIN SELECT * FROM tbl_year WHERE y > '1902.0E00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` > 1902) +EXPLAIN SELECT * FROM tbl_year WHERE y >= '1902.0E00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` >= 1902) +EXPLAIN SELECT * FROM tbl_year WHERE y = '1902.0E00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 25.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` = 1902) +EXPLAIN SELECT * FROM tbl_year WHERE y <> '1902.0E00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <> 1902) +SELECT * FROM tbl_year WHERE y < '2018.0E00'; +y +0000 +1901 +SELECT * FROM tbl_year WHERE y <= '2018.0E00'; +y +0000 +1901 +2018 +SELECT * FROM tbl_year WHERE y > '2018.0E00'; +y +2155 +SELECT * FROM tbl_year WHERE y >= '2018.0E00'; +y +2018 +2155 +SELECT * FROM tbl_year WHERE y = '2018.0E00'; +y +2018 +SELECT * FROM tbl_year WHERE y <> '2018.0E00'; +y +0000 +1901 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < '2018.0E00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` < 2018) +EXPLAIN SELECT * FROM tbl_year WHERE y <= '2018.0E00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <= 2018) +EXPLAIN SELECT * FROM tbl_year WHERE y > '2018.0E00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` > 2018) +EXPLAIN SELECT * FROM tbl_year WHERE y >= '2018.0E00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` >= 2018) +EXPLAIN SELECT * FROM tbl_year WHERE y = '2018.0E00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 25.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` = 2018) +EXPLAIN SELECT * FROM tbl_year WHERE y <> '2018.0E00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <> 2018) +SELECT * FROM tbl_year WHERE y < '2154.0E00'; +y +0000 +1901 +2018 +SELECT * FROM tbl_year WHERE y <= '2154.0E00'; +y +0000 +1901 +2018 +SELECT * FROM tbl_year WHERE y > '2154.0E00'; +y +2155 +SELECT * FROM tbl_year WHERE y >= '2154.0E00'; +y +2155 +SELECT * FROM tbl_year WHERE y = '2154.0E00'; +y +SELECT * FROM tbl_year WHERE y <> '2154.0E00'; +y +0000 +1901 +2018 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < '2154.0E00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` < 2154) +EXPLAIN SELECT * FROM tbl_year WHERE y <= '2154.0E00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <= 2154) +EXPLAIN SELECT * FROM tbl_year WHERE y > '2154.0E00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` > 2154) +EXPLAIN SELECT * FROM tbl_year WHERE y >= '2154.0E00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` >= 2154) +EXPLAIN SELECT * FROM tbl_year WHERE y = '2154.0E00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 25.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` = 2154) +EXPLAIN SELECT * FROM tbl_year WHERE y <> '2154.0E00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <> 2154) +SELECT * FROM tbl_year WHERE y < '2155.0E00'; +y +0000 +1901 +2018 +SELECT * FROM tbl_year WHERE y <= '2155.0E00'; +y +0000 +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y > '2155.0E00'; +y +SELECT * FROM tbl_year WHERE y >= '2155.0E00'; +y +2155 +SELECT * FROM tbl_year WHERE y = '2155.0E00'; +y +2155 +SELECT * FROM tbl_year WHERE y <> '2155.0E00'; +y +0000 +1901 +2018 +EXPLAIN SELECT * FROM tbl_year WHERE y < '2155.0E00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` < 2155) +EXPLAIN SELECT * FROM tbl_year WHERE y <= '2155.0E00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +EXPLAIN SELECT * FROM tbl_year WHERE y > '2155.0E00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y >= '2155.0E00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 25.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` = 2155) +EXPLAIN SELECT * FROM tbl_year WHERE y = '2155.0E00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 25.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` = 2155) +EXPLAIN SELECT * FROM tbl_year WHERE y <> '2155.0E00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <> 2155) +SELECT * FROM tbl_year WHERE y < '2156.0E00'; +y +0000 +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y <= '2156.0E00'; +y +0000 +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y > '2156.0E00'; +y +SELECT * FROM tbl_year WHERE y >= '2156.0E00'; +y +SELECT * FROM tbl_year WHERE y = '2156.0E00'; +y +SELECT * FROM tbl_year WHERE y <> '2156.0E00'; +y +0000 +1901 +2018 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < '2156.0E00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +EXPLAIN SELECT * FROM tbl_year WHERE y <= '2156.0E00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +EXPLAIN SELECT * FROM tbl_year WHERE y > '2156.0E00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y >= '2156.0E00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y = '2156.0E00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y <> '2156.0E00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +DROP TABLE tbl_year; +CREATE TABLE tbl_ts (t TIMESTAMP ); +INSERT INTO tbl_ts VALUES ('1970-01-01 03:00:01'), ('2018-06-19 21:00:00'), ('2038-01-19 06:14:07'); +ANALYZE TABLE tbl_ts; +Table Op Msg_type Msg_text +test.tbl_ts analyze status OK +SELECT * FROM tbl_ts; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +SET @OLD_SQL_MODE=@@SQL_MODE, @@SQL_MODE=ALLOW_INVALID_DATES; + +1. String literals + +TIMESTAMP: Some out of range constants (adjusted to TZ +0300 +for MTR) +DATETIME: 1970, 2038 just fine. +SELECT * FROM tbl_ts WHERE t < '0000-00-00 10:20:30'; +t +SELECT * FROM tbl_ts WHERE t <= '0000-00-00 10:20:30'; +t +SELECT * FROM tbl_ts WHERE t > '0000-00-00 10:20:30'; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +SELECT * FROM tbl_ts WHERE t >= '0000-00-00 10:20:30'; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +SELECT * FROM tbl_ts WHERE t = '0000-00-00 10:20:30'; +t +SELECT * FROM tbl_ts WHERE t <> '0000-00-00 10:20:30'; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +EXPLAIN SELECT * FROM tbl_ts WHERE t < '0000-00-00 10:20:30'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` < TIMESTAMP'0000-00-00 10:20:30') +EXPLAIN SELECT * FROM tbl_ts WHERE t <= '0000-00-00 10:20:30'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` <= TIMESTAMP'0000-00-00 10:20:30') +EXPLAIN SELECT * FROM tbl_ts WHERE t > '0000-00-00 10:20:30'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` > TIMESTAMP'0000-00-00 10:20:30') +EXPLAIN SELECT * FROM tbl_ts WHERE t >= '0000-00-00 10:20:30'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` >= TIMESTAMP'0000-00-00 10:20:30') +EXPLAIN SELECT * FROM tbl_ts WHERE t = '0000-00-00 10:20:30'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` = TIMESTAMP'0000-00-00 10:20:30') +EXPLAIN SELECT * FROM tbl_ts WHERE t <> '0000-00-00 10:20:30'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` <> TIMESTAMP'0000-00-00 10:20:30') +SELECT * FROM tbl_ts WHERE t < '2038-01-19 06:14:07.999999'; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +SELECT * FROM tbl_ts WHERE t <= '2038-01-19 06:14:07.999999'; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +SELECT * FROM tbl_ts WHERE t > '2038-01-19 06:14:07.999999'; +t +SELECT * FROM tbl_ts WHERE t >= '2038-01-19 06:14:07.999999'; +t +SELECT * FROM tbl_ts WHERE t = '2038-01-19 06:14:07.999999'; +t +SELECT * FROM tbl_ts WHERE t <> '2038-01-19 06:14:07.999999'; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +EXPLAIN SELECT * FROM tbl_ts WHERE t < '2038-01-19 06:14:07.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` is not null) +EXPLAIN SELECT * FROM tbl_ts WHERE t <= '2038-01-19 06:14:07.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` is not null) +EXPLAIN SELECT * FROM tbl_ts WHERE t > '2038-01-19 06:14:07.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where false +EXPLAIN SELECT * FROM tbl_ts WHERE t >= '2038-01-19 06:14:07.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where false +EXPLAIN SELECT * FROM tbl_ts WHERE t = '2038-01-19 06:14:07.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where false +EXPLAIN SELECT * FROM tbl_ts WHERE t <> '2038-01-19 06:14:07.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` is not null) +SELECT * FROM tbl_ts WHERE t < '2038-01-19 06:14:08.000000'; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +SELECT * FROM tbl_ts WHERE t <= '2038-01-19 06:14:08.000000'; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +SELECT * FROM tbl_ts WHERE t > '2038-01-19 06:14:08.000000'; +t +SELECT * FROM tbl_ts WHERE t >= '2038-01-19 06:14:08.000000'; +t +SELECT * FROM tbl_ts WHERE t = '2038-01-19 06:14:08.000000'; +t +SELECT * FROM tbl_ts WHERE t <> '2038-01-19 06:14:08.000000'; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +EXPLAIN SELECT * FROM tbl_ts WHERE t < '2038-01-19 06:14:08.000000'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` is not null) +EXPLAIN SELECT * FROM tbl_ts WHERE t <= '2038-01-19 06:14:08.000000'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` is not null) +EXPLAIN SELECT * FROM tbl_ts WHERE t > '2038-01-19 06:14:08.000000'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where false +EXPLAIN SELECT * FROM tbl_ts WHERE t >= '2038-01-19 06:14:08.000000'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where false +EXPLAIN SELECT * FROM tbl_ts WHERE t = '2038-01-19 06:14:08.000000'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where false +EXPLAIN SELECT * FROM tbl_ts WHERE t <> '2038-01-19 06:14:08.000000'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` is not null) +SELECT * FROM tbl_ts WHERE t < '1970-01-01 00:00:01'; +t +SELECT * FROM tbl_ts WHERE t <= '1970-01-01 00:00:01'; +t +SELECT * FROM tbl_ts WHERE t > '1970-01-01 00:00:01'; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +SELECT * FROM tbl_ts WHERE t >= '1970-01-01 00:00:01'; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +SELECT * FROM tbl_ts WHERE t = '1970-01-01 00:00:01'; +t +SELECT * FROM tbl_ts WHERE t <> '1970-01-01 00:00:01'; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +EXPLAIN SELECT * FROM tbl_ts WHERE t < '1970-01-01 00:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where false +EXPLAIN SELECT * FROM tbl_ts WHERE t <= '1970-01-01 00:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where false +EXPLAIN SELECT * FROM tbl_ts WHERE t > '1970-01-01 00:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` is not null) +EXPLAIN SELECT * FROM tbl_ts WHERE t >= '1970-01-01 00:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` is not null) +EXPLAIN SELECT * FROM tbl_ts WHERE t = '1970-01-01 00:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where false +EXPLAIN SELECT * FROM tbl_ts WHERE t <> '1970-01-01 00:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` is not null) +SELECT * FROM tbl_ts WHERE t < '1970-01-01 03:00:00.999999'; +t +SELECT * FROM tbl_ts WHERE t <= '1970-01-01 03:00:00.999999'; +t +SELECT * FROM tbl_ts WHERE t > '1970-01-01 03:00:00.999999'; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +SELECT * FROM tbl_ts WHERE t >= '1970-01-01 03:00:00.999999'; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +SELECT * FROM tbl_ts WHERE t = '1970-01-01 03:00:00.999999'; +t +SELECT * FROM tbl_ts WHERE t <> '1970-01-01 03:00:00.999999'; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +EXPLAIN SELECT * FROM tbl_ts WHERE t < '1970-01-01 03:00:00.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where false +EXPLAIN SELECT * FROM tbl_ts WHERE t <= '1970-01-01 03:00:00.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where false +EXPLAIN SELECT * FROM tbl_ts WHERE t > '1970-01-01 03:00:00.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` is not null) +EXPLAIN SELECT * FROM tbl_ts WHERE t >= '1970-01-01 03:00:00.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` is not null) +EXPLAIN SELECT * FROM tbl_ts WHERE t = '1970-01-01 03:00:00.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where false +EXPLAIN SELECT * FROM tbl_ts WHERE t <> '1970-01-01 03:00:00.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` is not null) +Zero date? +SELECT * FROM tbl_ts WHERE t < '0000-00-00 00:00:00'; +t +SELECT * FROM tbl_ts WHERE t <= '0000-00-00 00:00:00'; +t +SELECT * FROM tbl_ts WHERE t > '0000-00-00 00:00:00'; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +SELECT * FROM tbl_ts WHERE t >= '0000-00-00 00:00:00'; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +SELECT * FROM tbl_ts WHERE t = '0000-00-00 00:00:00'; +t +SELECT * FROM tbl_ts WHERE t <> '0000-00-00 00:00:00'; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +EXPLAIN SELECT * FROM tbl_ts WHERE t < '0000-00-00 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` < TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_ts WHERE t <= '0000-00-00 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` <= TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_ts WHERE t > '0000-00-00 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` > TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_ts WHERE t >= '0000-00-00 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` >= TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_ts WHERE t = '0000-00-00 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` = TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_ts WHERE t <> '0000-00-00 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` <> TIMESTAMP'0000-00-00 00:00:00') +Zero in date +SELECT * FROM tbl_ts WHERE t < '2018-00-03 00:00:00'; +t +1970-01-01 03:00:01 +SELECT * FROM tbl_ts WHERE t <= '2018-00-03 00:00:00'; +t +1970-01-01 03:00:01 +SELECT * FROM tbl_ts WHERE t > '2018-00-03 00:00:00'; +t +2018-06-19 21:00:00 +2038-01-19 06:14:07 +SELECT * FROM tbl_ts WHERE t >= '2018-00-03 00:00:00'; +t +2018-06-19 21:00:00 +2038-01-19 06:14:07 +SELECT * FROM tbl_ts WHERE t = '2018-00-03 00:00:00'; +t +SELECT * FROM tbl_ts WHERE t <> '2018-00-03 00:00:00'; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +EXPLAIN SELECT * FROM tbl_ts WHERE t < '2018-00-03 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` < TIMESTAMP'2018-00-03 00:00:00') +EXPLAIN SELECT * FROM tbl_ts WHERE t <= '2018-00-03 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` <= TIMESTAMP'2018-00-03 00:00:00') +EXPLAIN SELECT * FROM tbl_ts WHERE t > '2018-00-03 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` > TIMESTAMP'2018-00-03 00:00:00') +EXPLAIN SELECT * FROM tbl_ts WHERE t >= '2018-00-03 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` >= TIMESTAMP'2018-00-03 00:00:00') +EXPLAIN SELECT * FROM tbl_ts WHERE t = '2018-00-03 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` = TIMESTAMP'2018-00-03 00:00:00') +EXPLAIN SELECT * FROM tbl_ts WHERE t <> '2018-00-03 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` <> TIMESTAMP'2018-00-03 00:00:00') + +Some in range string literals + +SELECT * FROM tbl_ts WHERE t < '2038-01-19 06:14:07'; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +SELECT * FROM tbl_ts WHERE t <= '2038-01-19 06:14:07'; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +SELECT * FROM tbl_ts WHERE t > '2038-01-19 06:14:07'; +t +SELECT * FROM tbl_ts WHERE t >= '2038-01-19 06:14:07'; +t +2038-01-19 06:14:07 +SELECT * FROM tbl_ts WHERE t = '2038-01-19 06:14:07'; +t +2038-01-19 06:14:07 +SELECT * FROM tbl_ts WHERE t <> '2038-01-19 06:14:07'; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +EXPLAIN SELECT * FROM tbl_ts WHERE t < '2038-01-19 06:14:07'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` < TIMESTAMP'2038-01-19 06:14:07') +EXPLAIN SELECT * FROM tbl_ts WHERE t <= '2038-01-19 06:14:07'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` <= TIMESTAMP'2038-01-19 06:14:07') +EXPLAIN SELECT * FROM tbl_ts WHERE t > '2038-01-19 06:14:07'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` > TIMESTAMP'2038-01-19 06:14:07') +EXPLAIN SELECT * FROM tbl_ts WHERE t >= '2038-01-19 06:14:07'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` >= TIMESTAMP'2038-01-19 06:14:07') +EXPLAIN SELECT * FROM tbl_ts WHERE t = '2038-01-19 06:14:07'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` = TIMESTAMP'2038-01-19 06:14:07') +EXPLAIN SELECT * FROM tbl_ts WHERE t <> '2038-01-19 06:14:07'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` <> TIMESTAMP'2038-01-19 06:14:07') +SELECT * FROM tbl_ts WHERE t < '1970-01-01 03:00:01'; +t +SELECT * FROM tbl_ts WHERE t <= '1970-01-01 03:00:01'; +t +1970-01-01 03:00:01 +SELECT * FROM tbl_ts WHERE t > '1970-01-01 03:00:01'; +t +2018-06-19 21:00:00 +2038-01-19 06:14:07 +SELECT * FROM tbl_ts WHERE t >= '1970-01-01 03:00:01'; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +SELECT * FROM tbl_ts WHERE t = '1970-01-01 03:00:01'; +t +1970-01-01 03:00:01 +SELECT * FROM tbl_ts WHERE t <> '1970-01-01 03:00:01'; +t +2018-06-19 21:00:00 +2038-01-19 06:14:07 +EXPLAIN SELECT * FROM tbl_ts WHERE t < '1970-01-01 03:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` < TIMESTAMP'1970-01-01 03:00:01') +EXPLAIN SELECT * FROM tbl_ts WHERE t <= '1970-01-01 03:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` <= TIMESTAMP'1970-01-01 03:00:01') +EXPLAIN SELECT * FROM tbl_ts WHERE t > '1970-01-01 03:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` > TIMESTAMP'1970-01-01 03:00:01') +EXPLAIN SELECT * FROM tbl_ts WHERE t >= '1970-01-01 03:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` >= TIMESTAMP'1970-01-01 03:00:01') +EXPLAIN SELECT * FROM tbl_ts WHERE t = '1970-01-01 03:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` = TIMESTAMP'1970-01-01 03:00:01') +EXPLAIN SELECT * FROM tbl_ts WHERE t <> '1970-01-01 03:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` <> TIMESTAMP'1970-01-01 03:00:01') + +2. TIMESTAMP literals +These are the same as above, but with TIMESTAMP prefix. + +TIMESTAMP field: Some out of range constants (adjusted to TZ ++0300 for MTR) +DATETIME field: in range +SELECT * FROM tbl_ts WHERE t < TIMESTAMP'2038-01-19 06:14:07.999999'; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +SELECT * FROM tbl_ts WHERE t <= TIMESTAMP'2038-01-19 06:14:07.999999'; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +SELECT * FROM tbl_ts WHERE t > TIMESTAMP'2038-01-19 06:14:07.999999'; +t +SELECT * FROM tbl_ts WHERE t >= TIMESTAMP'2038-01-19 06:14:07.999999'; +t +SELECT * FROM tbl_ts WHERE t = TIMESTAMP'2038-01-19 06:14:07.999999'; +t +SELECT * FROM tbl_ts WHERE t <> TIMESTAMP'2038-01-19 06:14:07.999999'; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +EXPLAIN SELECT * FROM tbl_ts WHERE t < TIMESTAMP'2038-01-19 06:14:07.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` is not null) +EXPLAIN SELECT * FROM tbl_ts WHERE t <= TIMESTAMP'2038-01-19 06:14:07.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` is not null) +EXPLAIN SELECT * FROM tbl_ts WHERE t > TIMESTAMP'2038-01-19 06:14:07.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where false +EXPLAIN SELECT * FROM tbl_ts WHERE t >= TIMESTAMP'2038-01-19 06:14:07.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where false +EXPLAIN SELECT * FROM tbl_ts WHERE t = TIMESTAMP'2038-01-19 06:14:07.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where false +EXPLAIN SELECT * FROM tbl_ts WHERE t <> TIMESTAMP'2038-01-19 06:14:07.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` is not null) +SELECT * FROM tbl_ts WHERE t < TIMESTAMP'2038-01-19 06:14:08.000000'; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +SELECT * FROM tbl_ts WHERE t <= TIMESTAMP'2038-01-19 06:14:08.000000'; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +SELECT * FROM tbl_ts WHERE t > TIMESTAMP'2038-01-19 06:14:08.000000'; +t +SELECT * FROM tbl_ts WHERE t >= TIMESTAMP'2038-01-19 06:14:08.000000'; +t +SELECT * FROM tbl_ts WHERE t = TIMESTAMP'2038-01-19 06:14:08.000000'; +t +SELECT * FROM tbl_ts WHERE t <> TIMESTAMP'2038-01-19 06:14:08.000000'; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +EXPLAIN SELECT * FROM tbl_ts WHERE t < TIMESTAMP'2038-01-19 06:14:08.000000'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` is not null) +EXPLAIN SELECT * FROM tbl_ts WHERE t <= TIMESTAMP'2038-01-19 06:14:08.000000'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` is not null) +EXPLAIN SELECT * FROM tbl_ts WHERE t > TIMESTAMP'2038-01-19 06:14:08.000000'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where false +EXPLAIN SELECT * FROM tbl_ts WHERE t >= TIMESTAMP'2038-01-19 06:14:08.000000'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where false +EXPLAIN SELECT * FROM tbl_ts WHERE t = TIMESTAMP'2038-01-19 06:14:08.000000'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where false +EXPLAIN SELECT * FROM tbl_ts WHERE t <> TIMESTAMP'2038-01-19 06:14:08.000000'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` is not null) +SELECT * FROM tbl_ts WHERE t < TIMESTAMP'1970-01-01 00:00:01'; +t +SELECT * FROM tbl_ts WHERE t <= TIMESTAMP'1970-01-01 00:00:01'; +t +SELECT * FROM tbl_ts WHERE t > TIMESTAMP'1970-01-01 00:00:01'; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +SELECT * FROM tbl_ts WHERE t >= TIMESTAMP'1970-01-01 00:00:01'; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +SELECT * FROM tbl_ts WHERE t = TIMESTAMP'1970-01-01 00:00:01'; +t +SELECT * FROM tbl_ts WHERE t <> TIMESTAMP'1970-01-01 00:00:01'; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +EXPLAIN SELECT * FROM tbl_ts WHERE t < TIMESTAMP'1970-01-01 00:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where false +EXPLAIN SELECT * FROM tbl_ts WHERE t <= TIMESTAMP'1970-01-01 00:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where false +EXPLAIN SELECT * FROM tbl_ts WHERE t > TIMESTAMP'1970-01-01 00:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` is not null) +EXPLAIN SELECT * FROM tbl_ts WHERE t >= TIMESTAMP'1970-01-01 00:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` is not null) +EXPLAIN SELECT * FROM tbl_ts WHERE t = TIMESTAMP'1970-01-01 00:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where false +EXPLAIN SELECT * FROM tbl_ts WHERE t <> TIMESTAMP'1970-01-01 00:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` is not null) +SELECT * FROM tbl_ts WHERE t < TIMESTAMP'1970-01-01 03:00:00.999999'; +t +SELECT * FROM tbl_ts WHERE t <= TIMESTAMP'1970-01-01 03:00:00.999999'; +t +SELECT * FROM tbl_ts WHERE t > TIMESTAMP'1970-01-01 03:00:00.999999'; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +SELECT * FROM tbl_ts WHERE t >= TIMESTAMP'1970-01-01 03:00:00.999999'; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +SELECT * FROM tbl_ts WHERE t = TIMESTAMP'1970-01-01 03:00:00.999999'; +t +SELECT * FROM tbl_ts WHERE t <> TIMESTAMP'1970-01-01 03:00:00.999999'; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +EXPLAIN SELECT * FROM tbl_ts WHERE t < TIMESTAMP'1970-01-01 03:00:00.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where false +EXPLAIN SELECT * FROM tbl_ts WHERE t <= TIMESTAMP'1970-01-01 03:00:00.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where false +EXPLAIN SELECT * FROM tbl_ts WHERE t > TIMESTAMP'1970-01-01 03:00:00.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` is not null) +EXPLAIN SELECT * FROM tbl_ts WHERE t >= TIMESTAMP'1970-01-01 03:00:00.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` is not null) +EXPLAIN SELECT * FROM tbl_ts WHERE t = TIMESTAMP'1970-01-01 03:00:00.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where false +EXPLAIN SELECT * FROM tbl_ts WHERE t <> TIMESTAMP'1970-01-01 03:00:00.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` is not null) + +Some in range constants + +SELECT * FROM tbl_ts WHERE t < TIMESTAMP'2038-01-19 06:14:07'; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +SELECT * FROM tbl_ts WHERE t <= TIMESTAMP'2038-01-19 06:14:07'; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +SELECT * FROM tbl_ts WHERE t > TIMESTAMP'2038-01-19 06:14:07'; +t +SELECT * FROM tbl_ts WHERE t >= TIMESTAMP'2038-01-19 06:14:07'; +t +2038-01-19 06:14:07 +SELECT * FROM tbl_ts WHERE t = TIMESTAMP'2038-01-19 06:14:07'; +t +2038-01-19 06:14:07 +SELECT * FROM tbl_ts WHERE t <> TIMESTAMP'2038-01-19 06:14:07'; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +EXPLAIN SELECT * FROM tbl_ts WHERE t < TIMESTAMP'2038-01-19 06:14:07'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` < TIMESTAMP'2038-01-19 06:14:07') +EXPLAIN SELECT * FROM tbl_ts WHERE t <= TIMESTAMP'2038-01-19 06:14:07'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` <= TIMESTAMP'2038-01-19 06:14:07') +EXPLAIN SELECT * FROM tbl_ts WHERE t > TIMESTAMP'2038-01-19 06:14:07'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` > TIMESTAMP'2038-01-19 06:14:07') +EXPLAIN SELECT * FROM tbl_ts WHERE t >= TIMESTAMP'2038-01-19 06:14:07'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` >= TIMESTAMP'2038-01-19 06:14:07') +EXPLAIN SELECT * FROM tbl_ts WHERE t = TIMESTAMP'2038-01-19 06:14:07'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` = TIMESTAMP'2038-01-19 06:14:07') +EXPLAIN SELECT * FROM tbl_ts WHERE t <> TIMESTAMP'2038-01-19 06:14:07'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` <> TIMESTAMP'2038-01-19 06:14:07') +SELECT * FROM tbl_ts WHERE t < TIMESTAMP'1970-01-01 03:00:01'; +t +SELECT * FROM tbl_ts WHERE t <= TIMESTAMP'1970-01-01 03:00:01'; +t +1970-01-01 03:00:01 +SELECT * FROM tbl_ts WHERE t > TIMESTAMP'1970-01-01 03:00:01'; +t +2018-06-19 21:00:00 +2038-01-19 06:14:07 +SELECT * FROM tbl_ts WHERE t >= TIMESTAMP'1970-01-01 03:00:01'; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +SELECT * FROM tbl_ts WHERE t = TIMESTAMP'1970-01-01 03:00:01'; +t +1970-01-01 03:00:01 +SELECT * FROM tbl_ts WHERE t <> TIMESTAMP'1970-01-01 03:00:01'; +t +2018-06-19 21:00:00 +2038-01-19 06:14:07 +EXPLAIN SELECT * FROM tbl_ts WHERE t < TIMESTAMP'1970-01-01 03:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` < TIMESTAMP'1970-01-01 03:00:01') +EXPLAIN SELECT * FROM tbl_ts WHERE t <= TIMESTAMP'1970-01-01 03:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` <= TIMESTAMP'1970-01-01 03:00:01') +EXPLAIN SELECT * FROM tbl_ts WHERE t > TIMESTAMP'1970-01-01 03:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` > TIMESTAMP'1970-01-01 03:00:01') +EXPLAIN SELECT * FROM tbl_ts WHERE t >= TIMESTAMP'1970-01-01 03:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` >= TIMESTAMP'1970-01-01 03:00:01') +EXPLAIN SELECT * FROM tbl_ts WHERE t = TIMESTAMP'1970-01-01 03:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` = TIMESTAMP'1970-01-01 03:00:01') +EXPLAIN SELECT * FROM tbl_ts WHERE t <> TIMESTAMP'1970-01-01 03:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` <> TIMESTAMP'1970-01-01 03:00:01') + +3. Integer literals + +SELECT * FROM tbl_ts WHERE t < 20380119061407; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +SELECT * FROM tbl_ts WHERE t <= 20380119061407; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +SELECT * FROM tbl_ts WHERE t > 20380119061407; +t +SELECT * FROM tbl_ts WHERE t >= 20380119061407; +t +2038-01-19 06:14:07 +SELECT * FROM tbl_ts WHERE t = 20380119061407; +t +2038-01-19 06:14:07 +SELECT * FROM tbl_ts WHERE t <> 20380119061407; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +EXPLAIN SELECT * FROM tbl_ts WHERE t < 20380119061407; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` < TIMESTAMP'2038-01-19 06:14:07') +EXPLAIN SELECT * FROM tbl_ts WHERE t <= 20380119061407; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` <= TIMESTAMP'2038-01-19 06:14:07') +EXPLAIN SELECT * FROM tbl_ts WHERE t > 20380119061407; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` > TIMESTAMP'2038-01-19 06:14:07') +EXPLAIN SELECT * FROM tbl_ts WHERE t >= 20380119061407; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` >= TIMESTAMP'2038-01-19 06:14:07') +EXPLAIN SELECT * FROM tbl_ts WHERE t = 20380119061407; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` = TIMESTAMP'2038-01-19 06:14:07') +EXPLAIN SELECT * FROM tbl_ts WHERE t <> 20380119061407; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` <> TIMESTAMP'2038-01-19 06:14:07') +SELECT * FROM tbl_ts WHERE t < 2018; +t +Warnings: +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +SELECT * FROM tbl_ts WHERE t <= 2018; +t +Warnings: +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +SELECT * FROM tbl_ts WHERE t > 2018; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +Warnings: +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +SELECT * FROM tbl_ts WHERE t >= 2018; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +Warnings: +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +SELECT * FROM tbl_ts WHERE t = 2018; +t +Warnings: +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +SELECT * FROM tbl_ts WHERE t <> 2018; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +Warnings: +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +EXPLAIN SELECT * FROM tbl_ts WHERE t < 2018; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` < 2018) +EXPLAIN SELECT * FROM tbl_ts WHERE t <= 2018; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` <= 2018) +EXPLAIN SELECT * FROM tbl_ts WHERE t > 2018; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` > 2018) +EXPLAIN SELECT * FROM tbl_ts WHERE t >= 2018; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` >= 2018) +EXPLAIN SELECT * FROM tbl_ts WHERE t = 2018; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` = 2018) +EXPLAIN SELECT * FROM tbl_ts WHERE t <> 2018; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` <> 2018) +SELECT * FROM tbl_ts WHERE t < 0; +t +SELECT * FROM tbl_ts WHERE t <= 0; +t +SELECT * FROM tbl_ts WHERE t > 0; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +SELECT * FROM tbl_ts WHERE t >= 0; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +SELECT * FROM tbl_ts WHERE t = 0; +t +SELECT * FROM tbl_ts WHERE t <> 0; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +EXPLAIN SELECT * FROM tbl_ts WHERE t < 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` < TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_ts WHERE t <= 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` <= TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_ts WHERE t > 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` > TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_ts WHERE t >= 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` >= TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_ts WHERE t = 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` = TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_ts WHERE t <> 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` <> TIMESTAMP'0000-00-00 00:00:00') + +3. Decimal literals: rounded up to whole seconds + +SELECT * FROM tbl_ts WHERE t < 20380119061405.55; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +SELECT * FROM tbl_ts WHERE t <= 20380119061405.55; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +SELECT * FROM tbl_ts WHERE t > 20380119061405.55; +t +2038-01-19 06:14:07 +SELECT * FROM tbl_ts WHERE t >= 20380119061405.55; +t +2038-01-19 06:14:07 +SELECT * FROM tbl_ts WHERE t = 20380119061405.55; +t +SELECT * FROM tbl_ts WHERE t <> 20380119061405.55; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +EXPLAIN SELECT * FROM tbl_ts WHERE t < 20380119061405.55; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` < TIMESTAMP'2038-01-19 06:14:06') +EXPLAIN SELECT * FROM tbl_ts WHERE t <= 20380119061405.55; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` <= TIMESTAMP'2038-01-19 06:14:06') +EXPLAIN SELECT * FROM tbl_ts WHERE t > 20380119061405.55; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` > TIMESTAMP'2038-01-19 06:14:06') +EXPLAIN SELECT * FROM tbl_ts WHERE t >= 20380119061405.55; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` >= TIMESTAMP'2038-01-19 06:14:06') +EXPLAIN SELECT * FROM tbl_ts WHERE t = 20380119061405.55; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` = TIMESTAMP'2038-01-19 06:14:06') +EXPLAIN SELECT * FROM tbl_ts WHERE t <> 20380119061405.55; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` <> TIMESTAMP'2038-01-19 06:14:06') +SELECT * FROM tbl_ts WHERE t < 2018.55; +t +Warnings: +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +SELECT * FROM tbl_ts WHERE t <= 2018.55; +t +Warnings: +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +SELECT * FROM tbl_ts WHERE t > 2018.55; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +Warnings: +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +SELECT * FROM tbl_ts WHERE t >= 2018.55; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +Warnings: +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +SELECT * FROM tbl_ts WHERE t = 2018.55; +t +Warnings: +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +SELECT * FROM tbl_ts WHERE t <> 2018.55; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +Warnings: +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +EXPLAIN SELECT * FROM tbl_ts WHERE t < 2018.55; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` < 2018.55) +EXPLAIN SELECT * FROM tbl_ts WHERE t <= 2018.55; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` <= 2018.55) +EXPLAIN SELECT * FROM tbl_ts WHERE t > 2018.55; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` > 2018.55) +EXPLAIN SELECT * FROM tbl_ts WHERE t >= 2018.55; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` >= 2018.55) +EXPLAIN SELECT * FROM tbl_ts WHERE t = 2018.55; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` = 2018.55) +EXPLAIN SELECT * FROM tbl_ts WHERE t <> 2018.55; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` <> 2018.55) +SELECT * FROM tbl_ts WHERE t < 0.00; +t +SELECT * FROM tbl_ts WHERE t <= 0.00; +t +SELECT * FROM tbl_ts WHERE t > 0.00; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +SELECT * FROM tbl_ts WHERE t >= 0.00; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +SELECT * FROM tbl_ts WHERE t = 0.00; +t +SELECT * FROM tbl_ts WHERE t <> 0.00; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +EXPLAIN SELECT * FROM tbl_ts WHERE t < 0.00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` < TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_ts WHERE t <= 0.00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` <= TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_ts WHERE t > 0.00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` > TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_ts WHERE t >= 0.00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` >= TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_ts WHERE t = 0.00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` = TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_ts WHERE t <> 0.00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` <> TIMESTAMP'0000-00-00 00:00:00') + +3. Real literals: rounded up to whole seconds + +SELECT * FROM tbl_ts WHERE t < 20380119061405.55E00; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +SELECT * FROM tbl_ts WHERE t <= 20380119061405.55E00; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +SELECT * FROM tbl_ts WHERE t > 20380119061405.55E00; +t +2038-01-19 06:14:07 +SELECT * FROM tbl_ts WHERE t >= 20380119061405.55E00; +t +2038-01-19 06:14:07 +SELECT * FROM tbl_ts WHERE t = 20380119061405.55E00; +t +SELECT * FROM tbl_ts WHERE t <> 20380119061405.55E00; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +EXPLAIN SELECT * FROM tbl_ts WHERE t < 20380119061405.55E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` < TIMESTAMP'2038-01-19 06:14:06') +EXPLAIN SELECT * FROM tbl_ts WHERE t <= 20380119061405.55E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` <= TIMESTAMP'2038-01-19 06:14:06') +EXPLAIN SELECT * FROM tbl_ts WHERE t > 20380119061405.55E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` > TIMESTAMP'2038-01-19 06:14:06') +EXPLAIN SELECT * FROM tbl_ts WHERE t >= 20380119061405.55E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` >= TIMESTAMP'2038-01-19 06:14:06') +EXPLAIN SELECT * FROM tbl_ts WHERE t = 20380119061405.55E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` = TIMESTAMP'2038-01-19 06:14:06') +EXPLAIN SELECT * FROM tbl_ts WHERE t <> 20380119061405.55E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` <> TIMESTAMP'2038-01-19 06:14:06') +SELECT * FROM tbl_ts WHERE t < 0.00E00; +t +SELECT * FROM tbl_ts WHERE t <= 0.00E00; +t +SELECT * FROM tbl_ts WHERE t > 0.00E00; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +SELECT * FROM tbl_ts WHERE t >= 0.00E00; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +SELECT * FROM tbl_ts WHERE t = 0.00E00; +t +SELECT * FROM tbl_ts WHERE t <> 0.00E00; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +EXPLAIN SELECT * FROM tbl_ts WHERE t < 0.00E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` < TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_ts WHERE t <= 0.00E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` <= TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_ts WHERE t > 0.00E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` > TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_ts WHERE t >= 0.00E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` >= TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_ts WHERE t = 0.00E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` = TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_ts WHERE t <> 0.00E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` <> TIMESTAMP'0000-00-00 00:00:00') +DROP TABLE tbl_ts; +CREATE TABLE tbl_ts (t TIMESTAMP(2) ); +INSERT INTO tbl_ts VALUES ('1970-01-01 03:00:01.00'), ('2018-06-19 21:00:00'), ('2038-01-19 06:14:07.99'); +ANALYZE TABLE tbl_ts; +Table Op Msg_type Msg_text +test.tbl_ts analyze status OK +SELECT * FROM tbl_ts; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +SET @OLD_SQL_MODE=@@SQL_MODE, @@SQL_MODE=ALLOW_INVALID_DATES; + +1. String literals + +TIMESTAMP: Some out of range constants (adjusted to TZ +0300 +for MTR) +DATETIME: 1970, 2038 just fine. +SELECT * FROM tbl_ts WHERE t < '0000-00-00 10:20:30'; +t +SELECT * FROM tbl_ts WHERE t <= '0000-00-00 10:20:30'; +t +SELECT * FROM tbl_ts WHERE t > '0000-00-00 10:20:30'; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +SELECT * FROM tbl_ts WHERE t >= '0000-00-00 10:20:30'; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +SELECT * FROM tbl_ts WHERE t = '0000-00-00 10:20:30'; +t +SELECT * FROM tbl_ts WHERE t <> '0000-00-00 10:20:30'; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +EXPLAIN SELECT * FROM tbl_ts WHERE t < '0000-00-00 10:20:30'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` < TIMESTAMP'0000-00-00 10:20:30') +EXPLAIN SELECT * FROM tbl_ts WHERE t <= '0000-00-00 10:20:30'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` <= TIMESTAMP'0000-00-00 10:20:30') +EXPLAIN SELECT * FROM tbl_ts WHERE t > '0000-00-00 10:20:30'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` > TIMESTAMP'0000-00-00 10:20:30') +EXPLAIN SELECT * FROM tbl_ts WHERE t >= '0000-00-00 10:20:30'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` >= TIMESTAMP'0000-00-00 10:20:30') +EXPLAIN SELECT * FROM tbl_ts WHERE t = '0000-00-00 10:20:30'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` = TIMESTAMP'0000-00-00 10:20:30') +EXPLAIN SELECT * FROM tbl_ts WHERE t <> '0000-00-00 10:20:30'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` <> TIMESTAMP'0000-00-00 10:20:30') +SELECT * FROM tbl_ts WHERE t < '2038-01-19 06:14:07.999999'; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +SELECT * FROM tbl_ts WHERE t <= '2038-01-19 06:14:07.999999'; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +SELECT * FROM tbl_ts WHERE t > '2038-01-19 06:14:07.999999'; +t +SELECT * FROM tbl_ts WHERE t >= '2038-01-19 06:14:07.999999'; +t +SELECT * FROM tbl_ts WHERE t = '2038-01-19 06:14:07.999999'; +t +SELECT * FROM tbl_ts WHERE t <> '2038-01-19 06:14:07.999999'; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +EXPLAIN SELECT * FROM tbl_ts WHERE t < '2038-01-19 06:14:07.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` is not null) +EXPLAIN SELECT * FROM tbl_ts WHERE t <= '2038-01-19 06:14:07.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` is not null) +EXPLAIN SELECT * FROM tbl_ts WHERE t > '2038-01-19 06:14:07.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where false +EXPLAIN SELECT * FROM tbl_ts WHERE t >= '2038-01-19 06:14:07.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where false +EXPLAIN SELECT * FROM tbl_ts WHERE t = '2038-01-19 06:14:07.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where false +EXPLAIN SELECT * FROM tbl_ts WHERE t <> '2038-01-19 06:14:07.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` is not null) +SELECT * FROM tbl_ts WHERE t < '2038-01-19 06:14:08.000000'; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +SELECT * FROM tbl_ts WHERE t <= '2038-01-19 06:14:08.000000'; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +SELECT * FROM tbl_ts WHERE t > '2038-01-19 06:14:08.000000'; +t +SELECT * FROM tbl_ts WHERE t >= '2038-01-19 06:14:08.000000'; +t +SELECT * FROM tbl_ts WHERE t = '2038-01-19 06:14:08.000000'; +t +SELECT * FROM tbl_ts WHERE t <> '2038-01-19 06:14:08.000000'; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +EXPLAIN SELECT * FROM tbl_ts WHERE t < '2038-01-19 06:14:08.000000'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` is not null) +EXPLAIN SELECT * FROM tbl_ts WHERE t <= '2038-01-19 06:14:08.000000'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` is not null) +EXPLAIN SELECT * FROM tbl_ts WHERE t > '2038-01-19 06:14:08.000000'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where false +EXPLAIN SELECT * FROM tbl_ts WHERE t >= '2038-01-19 06:14:08.000000'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where false +EXPLAIN SELECT * FROM tbl_ts WHERE t = '2038-01-19 06:14:08.000000'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where false +EXPLAIN SELECT * FROM tbl_ts WHERE t <> '2038-01-19 06:14:08.000000'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` is not null) +SELECT * FROM tbl_ts WHERE t < '1970-01-01 00:00:01'; +t +SELECT * FROM tbl_ts WHERE t <= '1970-01-01 00:00:01'; +t +SELECT * FROM tbl_ts WHERE t > '1970-01-01 00:00:01'; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +SELECT * FROM tbl_ts WHERE t >= '1970-01-01 00:00:01'; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +SELECT * FROM tbl_ts WHERE t = '1970-01-01 00:00:01'; +t +SELECT * FROM tbl_ts WHERE t <> '1970-01-01 00:00:01'; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +EXPLAIN SELECT * FROM tbl_ts WHERE t < '1970-01-01 00:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where false +EXPLAIN SELECT * FROM tbl_ts WHERE t <= '1970-01-01 00:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where false +EXPLAIN SELECT * FROM tbl_ts WHERE t > '1970-01-01 00:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` is not null) +EXPLAIN SELECT * FROM tbl_ts WHERE t >= '1970-01-01 00:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` is not null) +EXPLAIN SELECT * FROM tbl_ts WHERE t = '1970-01-01 00:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where false +EXPLAIN SELECT * FROM tbl_ts WHERE t <> '1970-01-01 00:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` is not null) +SELECT * FROM tbl_ts WHERE t < '1970-01-01 03:00:00.999999'; +t +SELECT * FROM tbl_ts WHERE t <= '1970-01-01 03:00:00.999999'; +t +SELECT * FROM tbl_ts WHERE t > '1970-01-01 03:00:00.999999'; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +SELECT * FROM tbl_ts WHERE t >= '1970-01-01 03:00:00.999999'; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +SELECT * FROM tbl_ts WHERE t = '1970-01-01 03:00:00.999999'; +t +SELECT * FROM tbl_ts WHERE t <> '1970-01-01 03:00:00.999999'; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +EXPLAIN SELECT * FROM tbl_ts WHERE t < '1970-01-01 03:00:00.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where false +EXPLAIN SELECT * FROM tbl_ts WHERE t <= '1970-01-01 03:00:00.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where false +EXPLAIN SELECT * FROM tbl_ts WHERE t > '1970-01-01 03:00:00.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` is not null) +EXPLAIN SELECT * FROM tbl_ts WHERE t >= '1970-01-01 03:00:00.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` is not null) +EXPLAIN SELECT * FROM tbl_ts WHERE t = '1970-01-01 03:00:00.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where false +EXPLAIN SELECT * FROM tbl_ts WHERE t <> '1970-01-01 03:00:00.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` is not null) +Zero date? +SELECT * FROM tbl_ts WHERE t < '0000-00-00 00:00:00'; +t +SELECT * FROM tbl_ts WHERE t <= '0000-00-00 00:00:00'; +t +SELECT * FROM tbl_ts WHERE t > '0000-00-00 00:00:00'; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +SELECT * FROM tbl_ts WHERE t >= '0000-00-00 00:00:00'; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +SELECT * FROM tbl_ts WHERE t = '0000-00-00 00:00:00'; +t +SELECT * FROM tbl_ts WHERE t <> '0000-00-00 00:00:00'; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +EXPLAIN SELECT * FROM tbl_ts WHERE t < '0000-00-00 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` < TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_ts WHERE t <= '0000-00-00 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` <= TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_ts WHERE t > '0000-00-00 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` > TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_ts WHERE t >= '0000-00-00 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` >= TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_ts WHERE t = '0000-00-00 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` = TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_ts WHERE t <> '0000-00-00 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` <> TIMESTAMP'0000-00-00 00:00:00') +Zero in date +SELECT * FROM tbl_ts WHERE t < '2018-00-03 00:00:00'; +t +1970-01-01 03:00:01.00 +SELECT * FROM tbl_ts WHERE t <= '2018-00-03 00:00:00'; +t +1970-01-01 03:00:01.00 +SELECT * FROM tbl_ts WHERE t > '2018-00-03 00:00:00'; +t +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +SELECT * FROM tbl_ts WHERE t >= '2018-00-03 00:00:00'; +t +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +SELECT * FROM tbl_ts WHERE t = '2018-00-03 00:00:00'; +t +SELECT * FROM tbl_ts WHERE t <> '2018-00-03 00:00:00'; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +EXPLAIN SELECT * FROM tbl_ts WHERE t < '2018-00-03 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` < TIMESTAMP'2018-00-03 00:00:00') +EXPLAIN SELECT * FROM tbl_ts WHERE t <= '2018-00-03 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` <= TIMESTAMP'2018-00-03 00:00:00') +EXPLAIN SELECT * FROM tbl_ts WHERE t > '2018-00-03 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` > TIMESTAMP'2018-00-03 00:00:00') +EXPLAIN SELECT * FROM tbl_ts WHERE t >= '2018-00-03 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` >= TIMESTAMP'2018-00-03 00:00:00') +EXPLAIN SELECT * FROM tbl_ts WHERE t = '2018-00-03 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` = TIMESTAMP'2018-00-03 00:00:00') +EXPLAIN SELECT * FROM tbl_ts WHERE t <> '2018-00-03 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` <> TIMESTAMP'2018-00-03 00:00:00') + +Some in range string literals + +SELECT * FROM tbl_ts WHERE t < '2038-01-19 06:14:07'; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +SELECT * FROM tbl_ts WHERE t <= '2038-01-19 06:14:07'; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +SELECT * FROM tbl_ts WHERE t > '2038-01-19 06:14:07'; +t +2038-01-19 06:14:07.99 +SELECT * FROM tbl_ts WHERE t >= '2038-01-19 06:14:07'; +t +2038-01-19 06:14:07.99 +SELECT * FROM tbl_ts WHERE t = '2038-01-19 06:14:07'; +t +SELECT * FROM tbl_ts WHERE t <> '2038-01-19 06:14:07'; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +EXPLAIN SELECT * FROM tbl_ts WHERE t < '2038-01-19 06:14:07'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` < TIMESTAMP'2038-01-19 06:14:07') +EXPLAIN SELECT * FROM tbl_ts WHERE t <= '2038-01-19 06:14:07'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` <= TIMESTAMP'2038-01-19 06:14:07') +EXPLAIN SELECT * FROM tbl_ts WHERE t > '2038-01-19 06:14:07'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` > TIMESTAMP'2038-01-19 06:14:07') +EXPLAIN SELECT * FROM tbl_ts WHERE t >= '2038-01-19 06:14:07'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` >= TIMESTAMP'2038-01-19 06:14:07') +EXPLAIN SELECT * FROM tbl_ts WHERE t = '2038-01-19 06:14:07'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` = TIMESTAMP'2038-01-19 06:14:07') +EXPLAIN SELECT * FROM tbl_ts WHERE t <> '2038-01-19 06:14:07'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` <> TIMESTAMP'2038-01-19 06:14:07') +SELECT * FROM tbl_ts WHERE t < '1970-01-01 03:00:01'; +t +SELECT * FROM tbl_ts WHERE t <= '1970-01-01 03:00:01'; +t +1970-01-01 03:00:01.00 +SELECT * FROM tbl_ts WHERE t > '1970-01-01 03:00:01'; +t +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +SELECT * FROM tbl_ts WHERE t >= '1970-01-01 03:00:01'; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +SELECT * FROM tbl_ts WHERE t = '1970-01-01 03:00:01'; +t +1970-01-01 03:00:01.00 +SELECT * FROM tbl_ts WHERE t <> '1970-01-01 03:00:01'; +t +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +EXPLAIN SELECT * FROM tbl_ts WHERE t < '1970-01-01 03:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` < TIMESTAMP'1970-01-01 03:00:01') +EXPLAIN SELECT * FROM tbl_ts WHERE t <= '1970-01-01 03:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` <= TIMESTAMP'1970-01-01 03:00:01') +EXPLAIN SELECT * FROM tbl_ts WHERE t > '1970-01-01 03:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` > TIMESTAMP'1970-01-01 03:00:01') +EXPLAIN SELECT * FROM tbl_ts WHERE t >= '1970-01-01 03:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` >= TIMESTAMP'1970-01-01 03:00:01') +EXPLAIN SELECT * FROM tbl_ts WHERE t = '1970-01-01 03:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` = TIMESTAMP'1970-01-01 03:00:01') +EXPLAIN SELECT * FROM tbl_ts WHERE t <> '1970-01-01 03:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` <> TIMESTAMP'1970-01-01 03:00:01') + +2. TIMESTAMP literals +These are the same as above, but with TIMESTAMP prefix. + +TIMESTAMP field: Some out of range constants (adjusted to TZ ++0300 for MTR) +DATETIME field: in range +SELECT * FROM tbl_ts WHERE t < TIMESTAMP'2038-01-19 06:14:07.999999'; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +SELECT * FROM tbl_ts WHERE t <= TIMESTAMP'2038-01-19 06:14:07.999999'; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +SELECT * FROM tbl_ts WHERE t > TIMESTAMP'2038-01-19 06:14:07.999999'; +t +SELECT * FROM tbl_ts WHERE t >= TIMESTAMP'2038-01-19 06:14:07.999999'; +t +SELECT * FROM tbl_ts WHERE t = TIMESTAMP'2038-01-19 06:14:07.999999'; +t +SELECT * FROM tbl_ts WHERE t <> TIMESTAMP'2038-01-19 06:14:07.999999'; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +EXPLAIN SELECT * FROM tbl_ts WHERE t < TIMESTAMP'2038-01-19 06:14:07.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` is not null) +EXPLAIN SELECT * FROM tbl_ts WHERE t <= TIMESTAMP'2038-01-19 06:14:07.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` is not null) +EXPLAIN SELECT * FROM tbl_ts WHERE t > TIMESTAMP'2038-01-19 06:14:07.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where false +EXPLAIN SELECT * FROM tbl_ts WHERE t >= TIMESTAMP'2038-01-19 06:14:07.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where false +EXPLAIN SELECT * FROM tbl_ts WHERE t = TIMESTAMP'2038-01-19 06:14:07.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where false +EXPLAIN SELECT * FROM tbl_ts WHERE t <> TIMESTAMP'2038-01-19 06:14:07.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` is not null) +SELECT * FROM tbl_ts WHERE t < TIMESTAMP'2038-01-19 06:14:08.000000'; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +SELECT * FROM tbl_ts WHERE t <= TIMESTAMP'2038-01-19 06:14:08.000000'; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +SELECT * FROM tbl_ts WHERE t > TIMESTAMP'2038-01-19 06:14:08.000000'; +t +SELECT * FROM tbl_ts WHERE t >= TIMESTAMP'2038-01-19 06:14:08.000000'; +t +SELECT * FROM tbl_ts WHERE t = TIMESTAMP'2038-01-19 06:14:08.000000'; +t +SELECT * FROM tbl_ts WHERE t <> TIMESTAMP'2038-01-19 06:14:08.000000'; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +EXPLAIN SELECT * FROM tbl_ts WHERE t < TIMESTAMP'2038-01-19 06:14:08.000000'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` is not null) +EXPLAIN SELECT * FROM tbl_ts WHERE t <= TIMESTAMP'2038-01-19 06:14:08.000000'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` is not null) +EXPLAIN SELECT * FROM tbl_ts WHERE t > TIMESTAMP'2038-01-19 06:14:08.000000'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where false +EXPLAIN SELECT * FROM tbl_ts WHERE t >= TIMESTAMP'2038-01-19 06:14:08.000000'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where false +EXPLAIN SELECT * FROM tbl_ts WHERE t = TIMESTAMP'2038-01-19 06:14:08.000000'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where false +EXPLAIN SELECT * FROM tbl_ts WHERE t <> TIMESTAMP'2038-01-19 06:14:08.000000'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` is not null) +SELECT * FROM tbl_ts WHERE t < TIMESTAMP'1970-01-01 00:00:01'; +t +SELECT * FROM tbl_ts WHERE t <= TIMESTAMP'1970-01-01 00:00:01'; +t +SELECT * FROM tbl_ts WHERE t > TIMESTAMP'1970-01-01 00:00:01'; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +SELECT * FROM tbl_ts WHERE t >= TIMESTAMP'1970-01-01 00:00:01'; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +SELECT * FROM tbl_ts WHERE t = TIMESTAMP'1970-01-01 00:00:01'; +t +SELECT * FROM tbl_ts WHERE t <> TIMESTAMP'1970-01-01 00:00:01'; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +EXPLAIN SELECT * FROM tbl_ts WHERE t < TIMESTAMP'1970-01-01 00:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where false +EXPLAIN SELECT * FROM tbl_ts WHERE t <= TIMESTAMP'1970-01-01 00:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where false +EXPLAIN SELECT * FROM tbl_ts WHERE t > TIMESTAMP'1970-01-01 00:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` is not null) +EXPLAIN SELECT * FROM tbl_ts WHERE t >= TIMESTAMP'1970-01-01 00:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` is not null) +EXPLAIN SELECT * FROM tbl_ts WHERE t = TIMESTAMP'1970-01-01 00:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where false +EXPLAIN SELECT * FROM tbl_ts WHERE t <> TIMESTAMP'1970-01-01 00:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` is not null) +SELECT * FROM tbl_ts WHERE t < TIMESTAMP'1970-01-01 03:00:00.999999'; +t +SELECT * FROM tbl_ts WHERE t <= TIMESTAMP'1970-01-01 03:00:00.999999'; +t +SELECT * FROM tbl_ts WHERE t > TIMESTAMP'1970-01-01 03:00:00.999999'; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +SELECT * FROM tbl_ts WHERE t >= TIMESTAMP'1970-01-01 03:00:00.999999'; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +SELECT * FROM tbl_ts WHERE t = TIMESTAMP'1970-01-01 03:00:00.999999'; +t +SELECT * FROM tbl_ts WHERE t <> TIMESTAMP'1970-01-01 03:00:00.999999'; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +EXPLAIN SELECT * FROM tbl_ts WHERE t < TIMESTAMP'1970-01-01 03:00:00.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where false +EXPLAIN SELECT * FROM tbl_ts WHERE t <= TIMESTAMP'1970-01-01 03:00:00.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where false +EXPLAIN SELECT * FROM tbl_ts WHERE t > TIMESTAMP'1970-01-01 03:00:00.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` is not null) +EXPLAIN SELECT * FROM tbl_ts WHERE t >= TIMESTAMP'1970-01-01 03:00:00.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` is not null) +EXPLAIN SELECT * FROM tbl_ts WHERE t = TIMESTAMP'1970-01-01 03:00:00.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where false +EXPLAIN SELECT * FROM tbl_ts WHERE t <> TIMESTAMP'1970-01-01 03:00:00.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` is not null) + +Some in range constants + +SELECT * FROM tbl_ts WHERE t < TIMESTAMP'2038-01-19 06:14:07'; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +SELECT * FROM tbl_ts WHERE t <= TIMESTAMP'2038-01-19 06:14:07'; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +SELECT * FROM tbl_ts WHERE t > TIMESTAMP'2038-01-19 06:14:07'; +t +2038-01-19 06:14:07.99 +SELECT * FROM tbl_ts WHERE t >= TIMESTAMP'2038-01-19 06:14:07'; +t +2038-01-19 06:14:07.99 +SELECT * FROM tbl_ts WHERE t = TIMESTAMP'2038-01-19 06:14:07'; +t +SELECT * FROM tbl_ts WHERE t <> TIMESTAMP'2038-01-19 06:14:07'; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +EXPLAIN SELECT * FROM tbl_ts WHERE t < TIMESTAMP'2038-01-19 06:14:07'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` < TIMESTAMP'2038-01-19 06:14:07') +EXPLAIN SELECT * FROM tbl_ts WHERE t <= TIMESTAMP'2038-01-19 06:14:07'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` <= TIMESTAMP'2038-01-19 06:14:07') +EXPLAIN SELECT * FROM tbl_ts WHERE t > TIMESTAMP'2038-01-19 06:14:07'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` > TIMESTAMP'2038-01-19 06:14:07') +EXPLAIN SELECT * FROM tbl_ts WHERE t >= TIMESTAMP'2038-01-19 06:14:07'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` >= TIMESTAMP'2038-01-19 06:14:07') +EXPLAIN SELECT * FROM tbl_ts WHERE t = TIMESTAMP'2038-01-19 06:14:07'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` = TIMESTAMP'2038-01-19 06:14:07') +EXPLAIN SELECT * FROM tbl_ts WHERE t <> TIMESTAMP'2038-01-19 06:14:07'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` <> TIMESTAMP'2038-01-19 06:14:07') +SELECT * FROM tbl_ts WHERE t < TIMESTAMP'1970-01-01 03:00:01'; +t +SELECT * FROM tbl_ts WHERE t <= TIMESTAMP'1970-01-01 03:00:01'; +t +1970-01-01 03:00:01.00 +SELECT * FROM tbl_ts WHERE t > TIMESTAMP'1970-01-01 03:00:01'; +t +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +SELECT * FROM tbl_ts WHERE t >= TIMESTAMP'1970-01-01 03:00:01'; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +SELECT * FROM tbl_ts WHERE t = TIMESTAMP'1970-01-01 03:00:01'; +t +1970-01-01 03:00:01.00 +SELECT * FROM tbl_ts WHERE t <> TIMESTAMP'1970-01-01 03:00:01'; +t +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +EXPLAIN SELECT * FROM tbl_ts WHERE t < TIMESTAMP'1970-01-01 03:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` < TIMESTAMP'1970-01-01 03:00:01') +EXPLAIN SELECT * FROM tbl_ts WHERE t <= TIMESTAMP'1970-01-01 03:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` <= TIMESTAMP'1970-01-01 03:00:01') +EXPLAIN SELECT * FROM tbl_ts WHERE t > TIMESTAMP'1970-01-01 03:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` > TIMESTAMP'1970-01-01 03:00:01') +EXPLAIN SELECT * FROM tbl_ts WHERE t >= TIMESTAMP'1970-01-01 03:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` >= TIMESTAMP'1970-01-01 03:00:01') +EXPLAIN SELECT * FROM tbl_ts WHERE t = TIMESTAMP'1970-01-01 03:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` = TIMESTAMP'1970-01-01 03:00:01') +EXPLAIN SELECT * FROM tbl_ts WHERE t <> TIMESTAMP'1970-01-01 03:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` <> TIMESTAMP'1970-01-01 03:00:01') + +3. Integer literals + +SELECT * FROM tbl_ts WHERE t < 20380119061407; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +SELECT * FROM tbl_ts WHERE t <= 20380119061407; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +SELECT * FROM tbl_ts WHERE t > 20380119061407; +t +2038-01-19 06:14:07.99 +SELECT * FROM tbl_ts WHERE t >= 20380119061407; +t +2038-01-19 06:14:07.99 +SELECT * FROM tbl_ts WHERE t = 20380119061407; +t +SELECT * FROM tbl_ts WHERE t <> 20380119061407; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +EXPLAIN SELECT * FROM tbl_ts WHERE t < 20380119061407; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` < TIMESTAMP'2038-01-19 06:14:07') +EXPLAIN SELECT * FROM tbl_ts WHERE t <= 20380119061407; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` <= TIMESTAMP'2038-01-19 06:14:07') +EXPLAIN SELECT * FROM tbl_ts WHERE t > 20380119061407; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` > TIMESTAMP'2038-01-19 06:14:07') +EXPLAIN SELECT * FROM tbl_ts WHERE t >= 20380119061407; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` >= TIMESTAMP'2038-01-19 06:14:07') +EXPLAIN SELECT * FROM tbl_ts WHERE t = 20380119061407; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` = TIMESTAMP'2038-01-19 06:14:07') +EXPLAIN SELECT * FROM tbl_ts WHERE t <> 20380119061407; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` <> TIMESTAMP'2038-01-19 06:14:07') +SELECT * FROM tbl_ts WHERE t < 2018; +t +Warnings: +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +SELECT * FROM tbl_ts WHERE t <= 2018; +t +Warnings: +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +SELECT * FROM tbl_ts WHERE t > 2018; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +Warnings: +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +SELECT * FROM tbl_ts WHERE t >= 2018; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +Warnings: +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +SELECT * FROM tbl_ts WHERE t = 2018; +t +Warnings: +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +SELECT * FROM tbl_ts WHERE t <> 2018; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +Warnings: +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +EXPLAIN SELECT * FROM tbl_ts WHERE t < 2018; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` < 2018) +EXPLAIN SELECT * FROM tbl_ts WHERE t <= 2018; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` <= 2018) +EXPLAIN SELECT * FROM tbl_ts WHERE t > 2018; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` > 2018) +EXPLAIN SELECT * FROM tbl_ts WHERE t >= 2018; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` >= 2018) +EXPLAIN SELECT * FROM tbl_ts WHERE t = 2018; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` = 2018) +EXPLAIN SELECT * FROM tbl_ts WHERE t <> 2018; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` <> 2018) +SELECT * FROM tbl_ts WHERE t < 0; +t +SELECT * FROM tbl_ts WHERE t <= 0; +t +SELECT * FROM tbl_ts WHERE t > 0; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +SELECT * FROM tbl_ts WHERE t >= 0; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +SELECT * FROM tbl_ts WHERE t = 0; +t +SELECT * FROM tbl_ts WHERE t <> 0; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +EXPLAIN SELECT * FROM tbl_ts WHERE t < 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` < TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_ts WHERE t <= 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` <= TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_ts WHERE t > 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` > TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_ts WHERE t >= 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` >= TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_ts WHERE t = 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` = TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_ts WHERE t <> 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` <> TIMESTAMP'0000-00-00 00:00:00') + +3. Decimal literals: rounded up to whole seconds + +SELECT * FROM tbl_ts WHERE t < 20380119061405.55; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +SELECT * FROM tbl_ts WHERE t <= 20380119061405.55; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +SELECT * FROM tbl_ts WHERE t > 20380119061405.55; +t +2038-01-19 06:14:07.99 +SELECT * FROM tbl_ts WHERE t >= 20380119061405.55; +t +2038-01-19 06:14:07.99 +SELECT * FROM tbl_ts WHERE t = 20380119061405.55; +t +SELECT * FROM tbl_ts WHERE t <> 20380119061405.55; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +EXPLAIN SELECT * FROM tbl_ts WHERE t < 20380119061405.55; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` < TIMESTAMP'2038-01-19 06:14:05.55') +EXPLAIN SELECT * FROM tbl_ts WHERE t <= 20380119061405.55; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` <= TIMESTAMP'2038-01-19 06:14:05.55') +EXPLAIN SELECT * FROM tbl_ts WHERE t > 20380119061405.55; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` > TIMESTAMP'2038-01-19 06:14:05.55') +EXPLAIN SELECT * FROM tbl_ts WHERE t >= 20380119061405.55; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` >= TIMESTAMP'2038-01-19 06:14:05.55') +EXPLAIN SELECT * FROM tbl_ts WHERE t = 20380119061405.55; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` = TIMESTAMP'2038-01-19 06:14:05.55') +EXPLAIN SELECT * FROM tbl_ts WHERE t <> 20380119061405.55; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` <> TIMESTAMP'2038-01-19 06:14:05.55') +SELECT * FROM tbl_ts WHERE t < 2018.55; +t +Warnings: +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +SELECT * FROM tbl_ts WHERE t <= 2018.55; +t +Warnings: +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +SELECT * FROM tbl_ts WHERE t > 2018.55; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +Warnings: +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +SELECT * FROM tbl_ts WHERE t >= 2018.55; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +Warnings: +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +SELECT * FROM tbl_ts WHERE t = 2018.55; +t +Warnings: +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +SELECT * FROM tbl_ts WHERE t <> 2018.55; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +Warnings: +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +EXPLAIN SELECT * FROM tbl_ts WHERE t < 2018.55; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` < 2018.55) +EXPLAIN SELECT * FROM tbl_ts WHERE t <= 2018.55; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` <= 2018.55) +EXPLAIN SELECT * FROM tbl_ts WHERE t > 2018.55; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` > 2018.55) +EXPLAIN SELECT * FROM tbl_ts WHERE t >= 2018.55; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` >= 2018.55) +EXPLAIN SELECT * FROM tbl_ts WHERE t = 2018.55; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` = 2018.55) +EXPLAIN SELECT * FROM tbl_ts WHERE t <> 2018.55; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` <> 2018.55) +SELECT * FROM tbl_ts WHERE t < 0.00; +t +SELECT * FROM tbl_ts WHERE t <= 0.00; +t +SELECT * FROM tbl_ts WHERE t > 0.00; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +SELECT * FROM tbl_ts WHERE t >= 0.00; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +SELECT * FROM tbl_ts WHERE t = 0.00; +t +SELECT * FROM tbl_ts WHERE t <> 0.00; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +EXPLAIN SELECT * FROM tbl_ts WHERE t < 0.00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` < TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_ts WHERE t <= 0.00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` <= TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_ts WHERE t > 0.00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` > TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_ts WHERE t >= 0.00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` >= TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_ts WHERE t = 0.00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` = TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_ts WHERE t <> 0.00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` <> TIMESTAMP'0000-00-00 00:00:00') + +3. Real literals: rounded up to whole seconds + +SELECT * FROM tbl_ts WHERE t < 20380119061405.55E00; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +SELECT * FROM tbl_ts WHERE t <= 20380119061405.55E00; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +SELECT * FROM tbl_ts WHERE t > 20380119061405.55E00; +t +2038-01-19 06:14:07.99 +SELECT * FROM tbl_ts WHERE t >= 20380119061405.55E00; +t +2038-01-19 06:14:07.99 +SELECT * FROM tbl_ts WHERE t = 20380119061405.55E00; +t +SELECT * FROM tbl_ts WHERE t <> 20380119061405.55E00; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +EXPLAIN SELECT * FROM tbl_ts WHERE t < 20380119061405.55E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` < TIMESTAMP'2038-01-19 06:14:05.55') +EXPLAIN SELECT * FROM tbl_ts WHERE t <= 20380119061405.55E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` <= TIMESTAMP'2038-01-19 06:14:05.55') +EXPLAIN SELECT * FROM tbl_ts WHERE t > 20380119061405.55E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` > TIMESTAMP'2038-01-19 06:14:05.55') +EXPLAIN SELECT * FROM tbl_ts WHERE t >= 20380119061405.55E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` >= TIMESTAMP'2038-01-19 06:14:05.55') +EXPLAIN SELECT * FROM tbl_ts WHERE t = 20380119061405.55E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` = TIMESTAMP'2038-01-19 06:14:05.55') +EXPLAIN SELECT * FROM tbl_ts WHERE t <> 20380119061405.55E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` <> TIMESTAMP'2038-01-19 06:14:05.55') +SELECT * FROM tbl_ts WHERE t < 0.00E00; +t +SELECT * FROM tbl_ts WHERE t <= 0.00E00; +t +SELECT * FROM tbl_ts WHERE t > 0.00E00; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +SELECT * FROM tbl_ts WHERE t >= 0.00E00; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +SELECT * FROM tbl_ts WHERE t = 0.00E00; +t +SELECT * FROM tbl_ts WHERE t <> 0.00E00; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +EXPLAIN SELECT * FROM tbl_ts WHERE t < 0.00E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` < TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_ts WHERE t <= 0.00E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` <= TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_ts WHERE t > 0.00E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` > TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_ts WHERE t >= 0.00E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` >= TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_ts WHERE t = 0.00E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` = TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_ts WHERE t <> 0.00E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` <> TIMESTAMP'0000-00-00 00:00:00') +DROP TABLE tbl_ts; +CREATE TABLE tbl_ts (t TIMESTAMP(6) ); +INSERT INTO tbl_ts VALUES ('1970-01-01 03:00:01.000000'), ('2018-06-19 21:00:00'), ('2038-01-19 06:14:07.999999'); +ANALYZE TABLE tbl_ts; +Table Op Msg_type Msg_text +test.tbl_ts analyze status OK +SELECT * FROM tbl_ts; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +SET @OLD_SQL_MODE=@@SQL_MODE, @@SQL_MODE=ALLOW_INVALID_DATES; + +1. String literals + +TIMESTAMP: Some out of range constants (adjusted to TZ +0300 +for MTR) +DATETIME: 1970, 2038 just fine. +SELECT * FROM tbl_ts WHERE t < '0000-00-00 10:20:30'; +t +SELECT * FROM tbl_ts WHERE t <= '0000-00-00 10:20:30'; +t +SELECT * FROM tbl_ts WHERE t > '0000-00-00 10:20:30'; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +SELECT * FROM tbl_ts WHERE t >= '0000-00-00 10:20:30'; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +SELECT * FROM tbl_ts WHERE t = '0000-00-00 10:20:30'; +t +SELECT * FROM tbl_ts WHERE t <> '0000-00-00 10:20:30'; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +EXPLAIN SELECT * FROM tbl_ts WHERE t < '0000-00-00 10:20:30'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` < TIMESTAMP'0000-00-00 10:20:30') +EXPLAIN SELECT * FROM tbl_ts WHERE t <= '0000-00-00 10:20:30'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` <= TIMESTAMP'0000-00-00 10:20:30') +EXPLAIN SELECT * FROM tbl_ts WHERE t > '0000-00-00 10:20:30'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` > TIMESTAMP'0000-00-00 10:20:30') +EXPLAIN SELECT * FROM tbl_ts WHERE t >= '0000-00-00 10:20:30'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` >= TIMESTAMP'0000-00-00 10:20:30') +EXPLAIN SELECT * FROM tbl_ts WHERE t = '0000-00-00 10:20:30'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` = TIMESTAMP'0000-00-00 10:20:30') +EXPLAIN SELECT * FROM tbl_ts WHERE t <> '0000-00-00 10:20:30'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` <> TIMESTAMP'0000-00-00 10:20:30') +SELECT * FROM tbl_ts WHERE t < '2038-01-19 06:14:07.999999'; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +SELECT * FROM tbl_ts WHERE t <= '2038-01-19 06:14:07.999999'; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +SELECT * FROM tbl_ts WHERE t > '2038-01-19 06:14:07.999999'; +t +SELECT * FROM tbl_ts WHERE t >= '2038-01-19 06:14:07.999999'; +t +2038-01-19 06:14:07.999999 +SELECT * FROM tbl_ts WHERE t = '2038-01-19 06:14:07.999999'; +t +2038-01-19 06:14:07.999999 +SELECT * FROM tbl_ts WHERE t <> '2038-01-19 06:14:07.999999'; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +EXPLAIN SELECT * FROM tbl_ts WHERE t < '2038-01-19 06:14:07.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` < TIMESTAMP'2038-01-19 06:14:07.999999') +EXPLAIN SELECT * FROM tbl_ts WHERE t <= '2038-01-19 06:14:07.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` <= TIMESTAMP'2038-01-19 06:14:07.999999') +EXPLAIN SELECT * FROM tbl_ts WHERE t > '2038-01-19 06:14:07.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` > TIMESTAMP'2038-01-19 06:14:07.999999') +EXPLAIN SELECT * FROM tbl_ts WHERE t >= '2038-01-19 06:14:07.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` >= TIMESTAMP'2038-01-19 06:14:07.999999') +EXPLAIN SELECT * FROM tbl_ts WHERE t = '2038-01-19 06:14:07.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` = TIMESTAMP'2038-01-19 06:14:07.999999') +EXPLAIN SELECT * FROM tbl_ts WHERE t <> '2038-01-19 06:14:07.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` <> TIMESTAMP'2038-01-19 06:14:07.999999') +SELECT * FROM tbl_ts WHERE t < '2038-01-19 06:14:08.000000'; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +SELECT * FROM tbl_ts WHERE t <= '2038-01-19 06:14:08.000000'; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +SELECT * FROM tbl_ts WHERE t > '2038-01-19 06:14:08.000000'; +t +SELECT * FROM tbl_ts WHERE t >= '2038-01-19 06:14:08.000000'; +t +SELECT * FROM tbl_ts WHERE t = '2038-01-19 06:14:08.000000'; +t +SELECT * FROM tbl_ts WHERE t <> '2038-01-19 06:14:08.000000'; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +EXPLAIN SELECT * FROM tbl_ts WHERE t < '2038-01-19 06:14:08.000000'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` is not null) +EXPLAIN SELECT * FROM tbl_ts WHERE t <= '2038-01-19 06:14:08.000000'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` is not null) +EXPLAIN SELECT * FROM tbl_ts WHERE t > '2038-01-19 06:14:08.000000'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where false +EXPLAIN SELECT * FROM tbl_ts WHERE t >= '2038-01-19 06:14:08.000000'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where false +EXPLAIN SELECT * FROM tbl_ts WHERE t = '2038-01-19 06:14:08.000000'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where false +EXPLAIN SELECT * FROM tbl_ts WHERE t <> '2038-01-19 06:14:08.000000'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` is not null) +SELECT * FROM tbl_ts WHERE t < '1970-01-01 00:00:01'; +t +SELECT * FROM tbl_ts WHERE t <= '1970-01-01 00:00:01'; +t +SELECT * FROM tbl_ts WHERE t > '1970-01-01 00:00:01'; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +SELECT * FROM tbl_ts WHERE t >= '1970-01-01 00:00:01'; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +SELECT * FROM tbl_ts WHERE t = '1970-01-01 00:00:01'; +t +SELECT * FROM tbl_ts WHERE t <> '1970-01-01 00:00:01'; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +EXPLAIN SELECT * FROM tbl_ts WHERE t < '1970-01-01 00:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where false +EXPLAIN SELECT * FROM tbl_ts WHERE t <= '1970-01-01 00:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where false +EXPLAIN SELECT * FROM tbl_ts WHERE t > '1970-01-01 00:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` is not null) +EXPLAIN SELECT * FROM tbl_ts WHERE t >= '1970-01-01 00:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` is not null) +EXPLAIN SELECT * FROM tbl_ts WHERE t = '1970-01-01 00:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where false +EXPLAIN SELECT * FROM tbl_ts WHERE t <> '1970-01-01 00:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` is not null) +SELECT * FROM tbl_ts WHERE t < '1970-01-01 03:00:00.999999'; +t +SELECT * FROM tbl_ts WHERE t <= '1970-01-01 03:00:00.999999'; +t +SELECT * FROM tbl_ts WHERE t > '1970-01-01 03:00:00.999999'; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +SELECT * FROM tbl_ts WHERE t >= '1970-01-01 03:00:00.999999'; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +SELECT * FROM tbl_ts WHERE t = '1970-01-01 03:00:00.999999'; +t +SELECT * FROM tbl_ts WHERE t <> '1970-01-01 03:00:00.999999'; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +EXPLAIN SELECT * FROM tbl_ts WHERE t < '1970-01-01 03:00:00.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where false +EXPLAIN SELECT * FROM tbl_ts WHERE t <= '1970-01-01 03:00:00.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where false +EXPLAIN SELECT * FROM tbl_ts WHERE t > '1970-01-01 03:00:00.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` is not null) +EXPLAIN SELECT * FROM tbl_ts WHERE t >= '1970-01-01 03:00:00.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` is not null) +EXPLAIN SELECT * FROM tbl_ts WHERE t = '1970-01-01 03:00:00.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where false +EXPLAIN SELECT * FROM tbl_ts WHERE t <> '1970-01-01 03:00:00.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` is not null) +Zero date? +SELECT * FROM tbl_ts WHERE t < '0000-00-00 00:00:00'; +t +SELECT * FROM tbl_ts WHERE t <= '0000-00-00 00:00:00'; +t +SELECT * FROM tbl_ts WHERE t > '0000-00-00 00:00:00'; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +SELECT * FROM tbl_ts WHERE t >= '0000-00-00 00:00:00'; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +SELECT * FROM tbl_ts WHERE t = '0000-00-00 00:00:00'; +t +SELECT * FROM tbl_ts WHERE t <> '0000-00-00 00:00:00'; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +EXPLAIN SELECT * FROM tbl_ts WHERE t < '0000-00-00 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` < TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_ts WHERE t <= '0000-00-00 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` <= TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_ts WHERE t > '0000-00-00 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` > TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_ts WHERE t >= '0000-00-00 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` >= TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_ts WHERE t = '0000-00-00 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` = TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_ts WHERE t <> '0000-00-00 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` <> TIMESTAMP'0000-00-00 00:00:00') +Zero in date +SELECT * FROM tbl_ts WHERE t < '2018-00-03 00:00:00'; +t +1970-01-01 03:00:01.000000 +SELECT * FROM tbl_ts WHERE t <= '2018-00-03 00:00:00'; +t +1970-01-01 03:00:01.000000 +SELECT * FROM tbl_ts WHERE t > '2018-00-03 00:00:00'; +t +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +SELECT * FROM tbl_ts WHERE t >= '2018-00-03 00:00:00'; +t +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +SELECT * FROM tbl_ts WHERE t = '2018-00-03 00:00:00'; +t +SELECT * FROM tbl_ts WHERE t <> '2018-00-03 00:00:00'; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +EXPLAIN SELECT * FROM tbl_ts WHERE t < '2018-00-03 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` < TIMESTAMP'2018-00-03 00:00:00') +EXPLAIN SELECT * FROM tbl_ts WHERE t <= '2018-00-03 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` <= TIMESTAMP'2018-00-03 00:00:00') +EXPLAIN SELECT * FROM tbl_ts WHERE t > '2018-00-03 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` > TIMESTAMP'2018-00-03 00:00:00') +EXPLAIN SELECT * FROM tbl_ts WHERE t >= '2018-00-03 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` >= TIMESTAMP'2018-00-03 00:00:00') +EXPLAIN SELECT * FROM tbl_ts WHERE t = '2018-00-03 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` = TIMESTAMP'2018-00-03 00:00:00') +EXPLAIN SELECT * FROM tbl_ts WHERE t <> '2018-00-03 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` <> TIMESTAMP'2018-00-03 00:00:00') + +Some in range string literals + +SELECT * FROM tbl_ts WHERE t < '2038-01-19 06:14:07'; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +SELECT * FROM tbl_ts WHERE t <= '2038-01-19 06:14:07'; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +SELECT * FROM tbl_ts WHERE t > '2038-01-19 06:14:07'; +t +2038-01-19 06:14:07.999999 +SELECT * FROM tbl_ts WHERE t >= '2038-01-19 06:14:07'; +t +2038-01-19 06:14:07.999999 +SELECT * FROM tbl_ts WHERE t = '2038-01-19 06:14:07'; +t +SELECT * FROM tbl_ts WHERE t <> '2038-01-19 06:14:07'; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +EXPLAIN SELECT * FROM tbl_ts WHERE t < '2038-01-19 06:14:07'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` < TIMESTAMP'2038-01-19 06:14:07') +EXPLAIN SELECT * FROM tbl_ts WHERE t <= '2038-01-19 06:14:07'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` <= TIMESTAMP'2038-01-19 06:14:07') +EXPLAIN SELECT * FROM tbl_ts WHERE t > '2038-01-19 06:14:07'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` > TIMESTAMP'2038-01-19 06:14:07') +EXPLAIN SELECT * FROM tbl_ts WHERE t >= '2038-01-19 06:14:07'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` >= TIMESTAMP'2038-01-19 06:14:07') +EXPLAIN SELECT * FROM tbl_ts WHERE t = '2038-01-19 06:14:07'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` = TIMESTAMP'2038-01-19 06:14:07') +EXPLAIN SELECT * FROM tbl_ts WHERE t <> '2038-01-19 06:14:07'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` <> TIMESTAMP'2038-01-19 06:14:07') +SELECT * FROM tbl_ts WHERE t < '1970-01-01 03:00:01'; +t +SELECT * FROM tbl_ts WHERE t <= '1970-01-01 03:00:01'; +t +1970-01-01 03:00:01.000000 +SELECT * FROM tbl_ts WHERE t > '1970-01-01 03:00:01'; +t +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +SELECT * FROM tbl_ts WHERE t >= '1970-01-01 03:00:01'; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +SELECT * FROM tbl_ts WHERE t = '1970-01-01 03:00:01'; +t +1970-01-01 03:00:01.000000 +SELECT * FROM tbl_ts WHERE t <> '1970-01-01 03:00:01'; +t +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +EXPLAIN SELECT * FROM tbl_ts WHERE t < '1970-01-01 03:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` < TIMESTAMP'1970-01-01 03:00:01') +EXPLAIN SELECT * FROM tbl_ts WHERE t <= '1970-01-01 03:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` <= TIMESTAMP'1970-01-01 03:00:01') +EXPLAIN SELECT * FROM tbl_ts WHERE t > '1970-01-01 03:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` > TIMESTAMP'1970-01-01 03:00:01') +EXPLAIN SELECT * FROM tbl_ts WHERE t >= '1970-01-01 03:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` >= TIMESTAMP'1970-01-01 03:00:01') +EXPLAIN SELECT * FROM tbl_ts WHERE t = '1970-01-01 03:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` = TIMESTAMP'1970-01-01 03:00:01') +EXPLAIN SELECT * FROM tbl_ts WHERE t <> '1970-01-01 03:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` <> TIMESTAMP'1970-01-01 03:00:01') + +2. TIMESTAMP literals +These are the same as above, but with TIMESTAMP prefix. + +TIMESTAMP field: Some out of range constants (adjusted to TZ ++0300 for MTR) +DATETIME field: in range +SELECT * FROM tbl_ts WHERE t < TIMESTAMP'2038-01-19 06:14:07.999999'; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +SELECT * FROM tbl_ts WHERE t <= TIMESTAMP'2038-01-19 06:14:07.999999'; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +SELECT * FROM tbl_ts WHERE t > TIMESTAMP'2038-01-19 06:14:07.999999'; +t +SELECT * FROM tbl_ts WHERE t >= TIMESTAMP'2038-01-19 06:14:07.999999'; +t +2038-01-19 06:14:07.999999 +SELECT * FROM tbl_ts WHERE t = TIMESTAMP'2038-01-19 06:14:07.999999'; +t +2038-01-19 06:14:07.999999 +SELECT * FROM tbl_ts WHERE t <> TIMESTAMP'2038-01-19 06:14:07.999999'; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +EXPLAIN SELECT * FROM tbl_ts WHERE t < TIMESTAMP'2038-01-19 06:14:07.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` < TIMESTAMP'2038-01-19 06:14:07.999999') +EXPLAIN SELECT * FROM tbl_ts WHERE t <= TIMESTAMP'2038-01-19 06:14:07.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` <= TIMESTAMP'2038-01-19 06:14:07.999999') +EXPLAIN SELECT * FROM tbl_ts WHERE t > TIMESTAMP'2038-01-19 06:14:07.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` > TIMESTAMP'2038-01-19 06:14:07.999999') +EXPLAIN SELECT * FROM tbl_ts WHERE t >= TIMESTAMP'2038-01-19 06:14:07.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` >= TIMESTAMP'2038-01-19 06:14:07.999999') +EXPLAIN SELECT * FROM tbl_ts WHERE t = TIMESTAMP'2038-01-19 06:14:07.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` = TIMESTAMP'2038-01-19 06:14:07.999999') +EXPLAIN SELECT * FROM tbl_ts WHERE t <> TIMESTAMP'2038-01-19 06:14:07.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` <> TIMESTAMP'2038-01-19 06:14:07.999999') +SELECT * FROM tbl_ts WHERE t < TIMESTAMP'2038-01-19 06:14:08.000000'; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +SELECT * FROM tbl_ts WHERE t <= TIMESTAMP'2038-01-19 06:14:08.000000'; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +SELECT * FROM tbl_ts WHERE t > TIMESTAMP'2038-01-19 06:14:08.000000'; +t +SELECT * FROM tbl_ts WHERE t >= TIMESTAMP'2038-01-19 06:14:08.000000'; +t +SELECT * FROM tbl_ts WHERE t = TIMESTAMP'2038-01-19 06:14:08.000000'; +t +SELECT * FROM tbl_ts WHERE t <> TIMESTAMP'2038-01-19 06:14:08.000000'; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +EXPLAIN SELECT * FROM tbl_ts WHERE t < TIMESTAMP'2038-01-19 06:14:08.000000'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` is not null) +EXPLAIN SELECT * FROM tbl_ts WHERE t <= TIMESTAMP'2038-01-19 06:14:08.000000'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` is not null) +EXPLAIN SELECT * FROM tbl_ts WHERE t > TIMESTAMP'2038-01-19 06:14:08.000000'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where false +EXPLAIN SELECT * FROM tbl_ts WHERE t >= TIMESTAMP'2038-01-19 06:14:08.000000'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where false +EXPLAIN SELECT * FROM tbl_ts WHERE t = TIMESTAMP'2038-01-19 06:14:08.000000'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where false +EXPLAIN SELECT * FROM tbl_ts WHERE t <> TIMESTAMP'2038-01-19 06:14:08.000000'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` is not null) +SELECT * FROM tbl_ts WHERE t < TIMESTAMP'1970-01-01 00:00:01'; +t +SELECT * FROM tbl_ts WHERE t <= TIMESTAMP'1970-01-01 00:00:01'; +t +SELECT * FROM tbl_ts WHERE t > TIMESTAMP'1970-01-01 00:00:01'; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +SELECT * FROM tbl_ts WHERE t >= TIMESTAMP'1970-01-01 00:00:01'; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +SELECT * FROM tbl_ts WHERE t = TIMESTAMP'1970-01-01 00:00:01'; +t +SELECT * FROM tbl_ts WHERE t <> TIMESTAMP'1970-01-01 00:00:01'; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +EXPLAIN SELECT * FROM tbl_ts WHERE t < TIMESTAMP'1970-01-01 00:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where false +EXPLAIN SELECT * FROM tbl_ts WHERE t <= TIMESTAMP'1970-01-01 00:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where false +EXPLAIN SELECT * FROM tbl_ts WHERE t > TIMESTAMP'1970-01-01 00:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` is not null) +EXPLAIN SELECT * FROM tbl_ts WHERE t >= TIMESTAMP'1970-01-01 00:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` is not null) +EXPLAIN SELECT * FROM tbl_ts WHERE t = TIMESTAMP'1970-01-01 00:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where false +EXPLAIN SELECT * FROM tbl_ts WHERE t <> TIMESTAMP'1970-01-01 00:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` is not null) +SELECT * FROM tbl_ts WHERE t < TIMESTAMP'1970-01-01 03:00:00.999999'; +t +SELECT * FROM tbl_ts WHERE t <= TIMESTAMP'1970-01-01 03:00:00.999999'; +t +SELECT * FROM tbl_ts WHERE t > TIMESTAMP'1970-01-01 03:00:00.999999'; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +SELECT * FROM tbl_ts WHERE t >= TIMESTAMP'1970-01-01 03:00:00.999999'; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +SELECT * FROM tbl_ts WHERE t = TIMESTAMP'1970-01-01 03:00:00.999999'; +t +SELECT * FROM tbl_ts WHERE t <> TIMESTAMP'1970-01-01 03:00:00.999999'; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +EXPLAIN SELECT * FROM tbl_ts WHERE t < TIMESTAMP'1970-01-01 03:00:00.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where false +EXPLAIN SELECT * FROM tbl_ts WHERE t <= TIMESTAMP'1970-01-01 03:00:00.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where false +EXPLAIN SELECT * FROM tbl_ts WHERE t > TIMESTAMP'1970-01-01 03:00:00.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` is not null) +EXPLAIN SELECT * FROM tbl_ts WHERE t >= TIMESTAMP'1970-01-01 03:00:00.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` is not null) +EXPLAIN SELECT * FROM tbl_ts WHERE t = TIMESTAMP'1970-01-01 03:00:00.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where false +EXPLAIN SELECT * FROM tbl_ts WHERE t <> TIMESTAMP'1970-01-01 03:00:00.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` is not null) + +Some in range constants + +SELECT * FROM tbl_ts WHERE t < TIMESTAMP'2038-01-19 06:14:07'; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +SELECT * FROM tbl_ts WHERE t <= TIMESTAMP'2038-01-19 06:14:07'; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +SELECT * FROM tbl_ts WHERE t > TIMESTAMP'2038-01-19 06:14:07'; +t +2038-01-19 06:14:07.999999 +SELECT * FROM tbl_ts WHERE t >= TIMESTAMP'2038-01-19 06:14:07'; +t +2038-01-19 06:14:07.999999 +SELECT * FROM tbl_ts WHERE t = TIMESTAMP'2038-01-19 06:14:07'; +t +SELECT * FROM tbl_ts WHERE t <> TIMESTAMP'2038-01-19 06:14:07'; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +EXPLAIN SELECT * FROM tbl_ts WHERE t < TIMESTAMP'2038-01-19 06:14:07'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` < TIMESTAMP'2038-01-19 06:14:07') +EXPLAIN SELECT * FROM tbl_ts WHERE t <= TIMESTAMP'2038-01-19 06:14:07'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` <= TIMESTAMP'2038-01-19 06:14:07') +EXPLAIN SELECT * FROM tbl_ts WHERE t > TIMESTAMP'2038-01-19 06:14:07'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` > TIMESTAMP'2038-01-19 06:14:07') +EXPLAIN SELECT * FROM tbl_ts WHERE t >= TIMESTAMP'2038-01-19 06:14:07'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` >= TIMESTAMP'2038-01-19 06:14:07') +EXPLAIN SELECT * FROM tbl_ts WHERE t = TIMESTAMP'2038-01-19 06:14:07'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` = TIMESTAMP'2038-01-19 06:14:07') +EXPLAIN SELECT * FROM tbl_ts WHERE t <> TIMESTAMP'2038-01-19 06:14:07'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` <> TIMESTAMP'2038-01-19 06:14:07') +SELECT * FROM tbl_ts WHERE t < TIMESTAMP'1970-01-01 03:00:01'; +t +SELECT * FROM tbl_ts WHERE t <= TIMESTAMP'1970-01-01 03:00:01'; +t +1970-01-01 03:00:01.000000 +SELECT * FROM tbl_ts WHERE t > TIMESTAMP'1970-01-01 03:00:01'; +t +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +SELECT * FROM tbl_ts WHERE t >= TIMESTAMP'1970-01-01 03:00:01'; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +SELECT * FROM tbl_ts WHERE t = TIMESTAMP'1970-01-01 03:00:01'; +t +1970-01-01 03:00:01.000000 +SELECT * FROM tbl_ts WHERE t <> TIMESTAMP'1970-01-01 03:00:01'; +t +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +EXPLAIN SELECT * FROM tbl_ts WHERE t < TIMESTAMP'1970-01-01 03:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` < TIMESTAMP'1970-01-01 03:00:01') +EXPLAIN SELECT * FROM tbl_ts WHERE t <= TIMESTAMP'1970-01-01 03:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` <= TIMESTAMP'1970-01-01 03:00:01') +EXPLAIN SELECT * FROM tbl_ts WHERE t > TIMESTAMP'1970-01-01 03:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` > TIMESTAMP'1970-01-01 03:00:01') +EXPLAIN SELECT * FROM tbl_ts WHERE t >= TIMESTAMP'1970-01-01 03:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` >= TIMESTAMP'1970-01-01 03:00:01') +EXPLAIN SELECT * FROM tbl_ts WHERE t = TIMESTAMP'1970-01-01 03:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` = TIMESTAMP'1970-01-01 03:00:01') +EXPLAIN SELECT * FROM tbl_ts WHERE t <> TIMESTAMP'1970-01-01 03:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` <> TIMESTAMP'1970-01-01 03:00:01') + +3. Integer literals + +SELECT * FROM tbl_ts WHERE t < 20380119061407; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +SELECT * FROM tbl_ts WHERE t <= 20380119061407; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +SELECT * FROM tbl_ts WHERE t > 20380119061407; +t +2038-01-19 06:14:07.999999 +SELECT * FROM tbl_ts WHERE t >= 20380119061407; +t +2038-01-19 06:14:07.999999 +SELECT * FROM tbl_ts WHERE t = 20380119061407; +t +SELECT * FROM tbl_ts WHERE t <> 20380119061407; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +EXPLAIN SELECT * FROM tbl_ts WHERE t < 20380119061407; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` < TIMESTAMP'2038-01-19 06:14:07') +EXPLAIN SELECT * FROM tbl_ts WHERE t <= 20380119061407; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` <= TIMESTAMP'2038-01-19 06:14:07') +EXPLAIN SELECT * FROM tbl_ts WHERE t > 20380119061407; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` > TIMESTAMP'2038-01-19 06:14:07') +EXPLAIN SELECT * FROM tbl_ts WHERE t >= 20380119061407; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` >= TIMESTAMP'2038-01-19 06:14:07') +EXPLAIN SELECT * FROM tbl_ts WHERE t = 20380119061407; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` = TIMESTAMP'2038-01-19 06:14:07') +EXPLAIN SELECT * FROM tbl_ts WHERE t <> 20380119061407; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` <> TIMESTAMP'2038-01-19 06:14:07') +SELECT * FROM tbl_ts WHERE t < 2018; +t +Warnings: +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +SELECT * FROM tbl_ts WHERE t <= 2018; +t +Warnings: +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +SELECT * FROM tbl_ts WHERE t > 2018; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +Warnings: +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +SELECT * FROM tbl_ts WHERE t >= 2018; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +Warnings: +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +SELECT * FROM tbl_ts WHERE t = 2018; +t +Warnings: +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +SELECT * FROM tbl_ts WHERE t <> 2018; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +Warnings: +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +EXPLAIN SELECT * FROM tbl_ts WHERE t < 2018; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` < 2018) +EXPLAIN SELECT * FROM tbl_ts WHERE t <= 2018; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` <= 2018) +EXPLAIN SELECT * FROM tbl_ts WHERE t > 2018; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` > 2018) +EXPLAIN SELECT * FROM tbl_ts WHERE t >= 2018; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` >= 2018) +EXPLAIN SELECT * FROM tbl_ts WHERE t = 2018; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` = 2018) +EXPLAIN SELECT * FROM tbl_ts WHERE t <> 2018; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` <> 2018) +SELECT * FROM tbl_ts WHERE t < 0; +t +SELECT * FROM tbl_ts WHERE t <= 0; +t +SELECT * FROM tbl_ts WHERE t > 0; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +SELECT * FROM tbl_ts WHERE t >= 0; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +SELECT * FROM tbl_ts WHERE t = 0; +t +SELECT * FROM tbl_ts WHERE t <> 0; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +EXPLAIN SELECT * FROM tbl_ts WHERE t < 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` < TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_ts WHERE t <= 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` <= TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_ts WHERE t > 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` > TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_ts WHERE t >= 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` >= TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_ts WHERE t = 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` = TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_ts WHERE t <> 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` <> TIMESTAMP'0000-00-00 00:00:00') + +3. Decimal literals: rounded up to whole seconds + +SELECT * FROM tbl_ts WHERE t < 20380119061405.55; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +SELECT * FROM tbl_ts WHERE t <= 20380119061405.55; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +SELECT * FROM tbl_ts WHERE t > 20380119061405.55; +t +2038-01-19 06:14:07.999999 +SELECT * FROM tbl_ts WHERE t >= 20380119061405.55; +t +2038-01-19 06:14:07.999999 +SELECT * FROM tbl_ts WHERE t = 20380119061405.55; +t +SELECT * FROM tbl_ts WHERE t <> 20380119061405.55; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +EXPLAIN SELECT * FROM tbl_ts WHERE t < 20380119061405.55; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` < TIMESTAMP'2038-01-19 06:14:05.55') +EXPLAIN SELECT * FROM tbl_ts WHERE t <= 20380119061405.55; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` <= TIMESTAMP'2038-01-19 06:14:05.55') +EXPLAIN SELECT * FROM tbl_ts WHERE t > 20380119061405.55; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` > TIMESTAMP'2038-01-19 06:14:05.55') +EXPLAIN SELECT * FROM tbl_ts WHERE t >= 20380119061405.55; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` >= TIMESTAMP'2038-01-19 06:14:05.55') +EXPLAIN SELECT * FROM tbl_ts WHERE t = 20380119061405.55; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` = TIMESTAMP'2038-01-19 06:14:05.55') +EXPLAIN SELECT * FROM tbl_ts WHERE t <> 20380119061405.55; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` <> TIMESTAMP'2038-01-19 06:14:05.55') +SELECT * FROM tbl_ts WHERE t < 2018.55; +t +Warnings: +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +SELECT * FROM tbl_ts WHERE t <= 2018.55; +t +Warnings: +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +SELECT * FROM tbl_ts WHERE t > 2018.55; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +Warnings: +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +SELECT * FROM tbl_ts WHERE t >= 2018.55; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +Warnings: +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +SELECT * FROM tbl_ts WHERE t = 2018.55; +t +Warnings: +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +SELECT * FROM tbl_ts WHERE t <> 2018.55; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +Warnings: +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +EXPLAIN SELECT * FROM tbl_ts WHERE t < 2018.55; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` < 2018.55) +EXPLAIN SELECT * FROM tbl_ts WHERE t <= 2018.55; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` <= 2018.55) +EXPLAIN SELECT * FROM tbl_ts WHERE t > 2018.55; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` > 2018.55) +EXPLAIN SELECT * FROM tbl_ts WHERE t >= 2018.55; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` >= 2018.55) +EXPLAIN SELECT * FROM tbl_ts WHERE t = 2018.55; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` = 2018.55) +EXPLAIN SELECT * FROM tbl_ts WHERE t <> 2018.55; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` <> 2018.55) +SELECT * FROM tbl_ts WHERE t < 0.00; +t +SELECT * FROM tbl_ts WHERE t <= 0.00; +t +SELECT * FROM tbl_ts WHERE t > 0.00; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +SELECT * FROM tbl_ts WHERE t >= 0.00; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +SELECT * FROM tbl_ts WHERE t = 0.00; +t +SELECT * FROM tbl_ts WHERE t <> 0.00; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +EXPLAIN SELECT * FROM tbl_ts WHERE t < 0.00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` < TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_ts WHERE t <= 0.00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` <= TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_ts WHERE t > 0.00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` > TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_ts WHERE t >= 0.00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` >= TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_ts WHERE t = 0.00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` = TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_ts WHERE t <> 0.00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` <> TIMESTAMP'0000-00-00 00:00:00') + +3. Real literals: rounded up to whole seconds + +SELECT * FROM tbl_ts WHERE t < 20380119061405.55E00; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +SELECT * FROM tbl_ts WHERE t <= 20380119061405.55E00; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +SELECT * FROM tbl_ts WHERE t > 20380119061405.55E00; +t +2038-01-19 06:14:07.999999 +SELECT * FROM tbl_ts WHERE t >= 20380119061405.55E00; +t +2038-01-19 06:14:07.999999 +SELECT * FROM tbl_ts WHERE t = 20380119061405.55E00; +t +SELECT * FROM tbl_ts WHERE t <> 20380119061405.55E00; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +EXPLAIN SELECT * FROM tbl_ts WHERE t < 20380119061405.55E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` < TIMESTAMP'2038-01-19 06:14:05.550781') +EXPLAIN SELECT * FROM tbl_ts WHERE t <= 20380119061405.55E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` <= TIMESTAMP'2038-01-19 06:14:05.550781') +EXPLAIN SELECT * FROM tbl_ts WHERE t > 20380119061405.55E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` > TIMESTAMP'2038-01-19 06:14:05.550781') +EXPLAIN SELECT * FROM tbl_ts WHERE t >= 20380119061405.55E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` >= TIMESTAMP'2038-01-19 06:14:05.550781') +EXPLAIN SELECT * FROM tbl_ts WHERE t = 20380119061405.55E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` = TIMESTAMP'2038-01-19 06:14:05.550781') +EXPLAIN SELECT * FROM tbl_ts WHERE t <> 20380119061405.55E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` <> TIMESTAMP'2038-01-19 06:14:05.550781') +SELECT * FROM tbl_ts WHERE t < 0.00E00; +t +SELECT * FROM tbl_ts WHERE t <= 0.00E00; +t +SELECT * FROM tbl_ts WHERE t > 0.00E00; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +SELECT * FROM tbl_ts WHERE t >= 0.00E00; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +SELECT * FROM tbl_ts WHERE t = 0.00E00; +t +SELECT * FROM tbl_ts WHERE t <> 0.00E00; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +EXPLAIN SELECT * FROM tbl_ts WHERE t < 0.00E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` < TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_ts WHERE t <= 0.00E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` <= TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_ts WHERE t > 0.00E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` > TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_ts WHERE t >= 0.00E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` >= TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_ts WHERE t = 0.00E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` = TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_ts WHERE t <> 0.00E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` <> TIMESTAMP'0000-00-00 00:00:00') +DROP TABLE tbl_ts; +CREATE TABLE tbl_datetime (t DATETIME ); +INSERT INTO tbl_datetime VALUES ('1970-01-01 03:00:01'), ('2018-06-19 21:00:00'), ('2038-01-19 06:14:07'); +ANALYZE TABLE tbl_datetime; +Table Op Msg_type Msg_text +test.tbl_datetime analyze status OK +SELECT * FROM tbl_datetime; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +SET @OLD_SQL_MODE=@@SQL_MODE, @@SQL_MODE=ALLOW_INVALID_DATES; + +1. String literals + +TIMESTAMP: Some out of range constants (adjusted to TZ +0300 +for MTR) +DATETIME: 1970, 2038 just fine. +SELECT * FROM tbl_datetime WHERE t < '0000-00-00 10:20:30'; +t +SELECT * FROM tbl_datetime WHERE t <= '0000-00-00 10:20:30'; +t +SELECT * FROM tbl_datetime WHERE t > '0000-00-00 10:20:30'; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +SELECT * FROM tbl_datetime WHERE t >= '0000-00-00 10:20:30'; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +SELECT * FROM tbl_datetime WHERE t = '0000-00-00 10:20:30'; +t +SELECT * FROM tbl_datetime WHERE t <> '0000-00-00 10:20:30'; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +EXPLAIN SELECT * FROM tbl_datetime WHERE t < '0000-00-00 10:20:30'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` < TIMESTAMP'0000-00-00 10:20:30') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <= '0000-00-00 10:20:30'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <= TIMESTAMP'0000-00-00 10:20:30') +EXPLAIN SELECT * FROM tbl_datetime WHERE t > '0000-00-00 10:20:30'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` > TIMESTAMP'0000-00-00 10:20:30') +EXPLAIN SELECT * FROM tbl_datetime WHERE t >= '0000-00-00 10:20:30'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` >= TIMESTAMP'0000-00-00 10:20:30') +EXPLAIN SELECT * FROM tbl_datetime WHERE t = '0000-00-00 10:20:30'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` = TIMESTAMP'0000-00-00 10:20:30') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <> '0000-00-00 10:20:30'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <> TIMESTAMP'0000-00-00 10:20:30') +SELECT * FROM tbl_datetime WHERE t < '2038-01-19 06:14:07.999999'; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +SELECT * FROM tbl_datetime WHERE t <= '2038-01-19 06:14:07.999999'; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +SELECT * FROM tbl_datetime WHERE t > '2038-01-19 06:14:07.999999'; +t +SELECT * FROM tbl_datetime WHERE t >= '2038-01-19 06:14:07.999999'; +t +SELECT * FROM tbl_datetime WHERE t = '2038-01-19 06:14:07.999999'; +t +SELECT * FROM tbl_datetime WHERE t <> '2038-01-19 06:14:07.999999'; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +EXPLAIN SELECT * FROM tbl_datetime WHERE t < '2038-01-19 06:14:07.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` < TIMESTAMP'2038-01-19 06:14:07.999999') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <= '2038-01-19 06:14:07.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <= TIMESTAMP'2038-01-19 06:14:07.999999') +EXPLAIN SELECT * FROM tbl_datetime WHERE t > '2038-01-19 06:14:07.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` > TIMESTAMP'2038-01-19 06:14:07.999999') +EXPLAIN SELECT * FROM tbl_datetime WHERE t >= '2038-01-19 06:14:07.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` >= TIMESTAMP'2038-01-19 06:14:07.999999') +EXPLAIN SELECT * FROM tbl_datetime WHERE t = '2038-01-19 06:14:07.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` = TIMESTAMP'2038-01-19 06:14:07.999999') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <> '2038-01-19 06:14:07.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <> TIMESTAMP'2038-01-19 06:14:07.999999') +SELECT * FROM tbl_datetime WHERE t < '2038-01-19 06:14:08.000000'; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +SELECT * FROM tbl_datetime WHERE t <= '2038-01-19 06:14:08.000000'; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +SELECT * FROM tbl_datetime WHERE t > '2038-01-19 06:14:08.000000'; +t +SELECT * FROM tbl_datetime WHERE t >= '2038-01-19 06:14:08.000000'; +t +SELECT * FROM tbl_datetime WHERE t = '2038-01-19 06:14:08.000000'; +t +SELECT * FROM tbl_datetime WHERE t <> '2038-01-19 06:14:08.000000'; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +EXPLAIN SELECT * FROM tbl_datetime WHERE t < '2038-01-19 06:14:08.000000'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` < TIMESTAMP'2038-01-19 06:14:08') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <= '2038-01-19 06:14:08.000000'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <= TIMESTAMP'2038-01-19 06:14:08') +EXPLAIN SELECT * FROM tbl_datetime WHERE t > '2038-01-19 06:14:08.000000'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` > TIMESTAMP'2038-01-19 06:14:08') +EXPLAIN SELECT * FROM tbl_datetime WHERE t >= '2038-01-19 06:14:08.000000'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` >= TIMESTAMP'2038-01-19 06:14:08') +EXPLAIN SELECT * FROM tbl_datetime WHERE t = '2038-01-19 06:14:08.000000'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` = TIMESTAMP'2038-01-19 06:14:08') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <> '2038-01-19 06:14:08.000000'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <> TIMESTAMP'2038-01-19 06:14:08') +SELECT * FROM tbl_datetime WHERE t < '1970-01-01 00:00:01'; +t +SELECT * FROM tbl_datetime WHERE t <= '1970-01-01 00:00:01'; +t +SELECT * FROM tbl_datetime WHERE t > '1970-01-01 00:00:01'; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +SELECT * FROM tbl_datetime WHERE t >= '1970-01-01 00:00:01'; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +SELECT * FROM tbl_datetime WHERE t = '1970-01-01 00:00:01'; +t +SELECT * FROM tbl_datetime WHERE t <> '1970-01-01 00:00:01'; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +EXPLAIN SELECT * FROM tbl_datetime WHERE t < '1970-01-01 00:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` < TIMESTAMP'1970-01-01 00:00:01') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <= '1970-01-01 00:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <= TIMESTAMP'1970-01-01 00:00:01') +EXPLAIN SELECT * FROM tbl_datetime WHERE t > '1970-01-01 00:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` > TIMESTAMP'1970-01-01 00:00:01') +EXPLAIN SELECT * FROM tbl_datetime WHERE t >= '1970-01-01 00:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` >= TIMESTAMP'1970-01-01 00:00:01') +EXPLAIN SELECT * FROM tbl_datetime WHERE t = '1970-01-01 00:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` = TIMESTAMP'1970-01-01 00:00:01') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <> '1970-01-01 00:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <> TIMESTAMP'1970-01-01 00:00:01') +SELECT * FROM tbl_datetime WHERE t < '1970-01-01 03:00:00.999999'; +t +SELECT * FROM tbl_datetime WHERE t <= '1970-01-01 03:00:00.999999'; +t +SELECT * FROM tbl_datetime WHERE t > '1970-01-01 03:00:00.999999'; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +SELECT * FROM tbl_datetime WHERE t >= '1970-01-01 03:00:00.999999'; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +SELECT * FROM tbl_datetime WHERE t = '1970-01-01 03:00:00.999999'; +t +SELECT * FROM tbl_datetime WHERE t <> '1970-01-01 03:00:00.999999'; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +EXPLAIN SELECT * FROM tbl_datetime WHERE t < '1970-01-01 03:00:00.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` < TIMESTAMP'1970-01-01 03:00:00.999999') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <= '1970-01-01 03:00:00.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <= TIMESTAMP'1970-01-01 03:00:00.999999') +EXPLAIN SELECT * FROM tbl_datetime WHERE t > '1970-01-01 03:00:00.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` > TIMESTAMP'1970-01-01 03:00:00.999999') +EXPLAIN SELECT * FROM tbl_datetime WHERE t >= '1970-01-01 03:00:00.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` >= TIMESTAMP'1970-01-01 03:00:00.999999') +EXPLAIN SELECT * FROM tbl_datetime WHERE t = '1970-01-01 03:00:00.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` = TIMESTAMP'1970-01-01 03:00:00.999999') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <> '1970-01-01 03:00:00.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <> TIMESTAMP'1970-01-01 03:00:00.999999') +Zero date? +SELECT * FROM tbl_datetime WHERE t < '0000-00-00 00:00:00'; +t +SELECT * FROM tbl_datetime WHERE t <= '0000-00-00 00:00:00'; +t +SELECT * FROM tbl_datetime WHERE t > '0000-00-00 00:00:00'; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +SELECT * FROM tbl_datetime WHERE t >= '0000-00-00 00:00:00'; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +SELECT * FROM tbl_datetime WHERE t = '0000-00-00 00:00:00'; +t +SELECT * FROM tbl_datetime WHERE t <> '0000-00-00 00:00:00'; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +EXPLAIN SELECT * FROM tbl_datetime WHERE t < '0000-00-00 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` < TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <= '0000-00-00 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <= TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_datetime WHERE t > '0000-00-00 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` > TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_datetime WHERE t >= '0000-00-00 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` >= TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_datetime WHERE t = '0000-00-00 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` = TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <> '0000-00-00 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <> TIMESTAMP'0000-00-00 00:00:00') +Zero in date +SELECT * FROM tbl_datetime WHERE t < '2018-00-03 00:00:00'; +t +1970-01-01 03:00:01 +SELECT * FROM tbl_datetime WHERE t <= '2018-00-03 00:00:00'; +t +1970-01-01 03:00:01 +SELECT * FROM tbl_datetime WHERE t > '2018-00-03 00:00:00'; +t +2018-06-19 21:00:00 +2038-01-19 06:14:07 +SELECT * FROM tbl_datetime WHERE t >= '2018-00-03 00:00:00'; +t +2018-06-19 21:00:00 +2038-01-19 06:14:07 +SELECT * FROM tbl_datetime WHERE t = '2018-00-03 00:00:00'; +t +SELECT * FROM tbl_datetime WHERE t <> '2018-00-03 00:00:00'; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +EXPLAIN SELECT * FROM tbl_datetime WHERE t < '2018-00-03 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` < TIMESTAMP'2018-00-03 00:00:00') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <= '2018-00-03 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <= TIMESTAMP'2018-00-03 00:00:00') +EXPLAIN SELECT * FROM tbl_datetime WHERE t > '2018-00-03 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` > TIMESTAMP'2018-00-03 00:00:00') +EXPLAIN SELECT * FROM tbl_datetime WHERE t >= '2018-00-03 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` >= TIMESTAMP'2018-00-03 00:00:00') +EXPLAIN SELECT * FROM tbl_datetime WHERE t = '2018-00-03 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` = TIMESTAMP'2018-00-03 00:00:00') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <> '2018-00-03 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <> TIMESTAMP'2018-00-03 00:00:00') + +Some in range string literals + +SELECT * FROM tbl_datetime WHERE t < '2038-01-19 06:14:07'; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +SELECT * FROM tbl_datetime WHERE t <= '2038-01-19 06:14:07'; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +SELECT * FROM tbl_datetime WHERE t > '2038-01-19 06:14:07'; +t +SELECT * FROM tbl_datetime WHERE t >= '2038-01-19 06:14:07'; +t +2038-01-19 06:14:07 +SELECT * FROM tbl_datetime WHERE t = '2038-01-19 06:14:07'; +t +2038-01-19 06:14:07 +SELECT * FROM tbl_datetime WHERE t <> '2038-01-19 06:14:07'; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +EXPLAIN SELECT * FROM tbl_datetime WHERE t < '2038-01-19 06:14:07'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` < TIMESTAMP'2038-01-19 06:14:07') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <= '2038-01-19 06:14:07'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <= TIMESTAMP'2038-01-19 06:14:07') +EXPLAIN SELECT * FROM tbl_datetime WHERE t > '2038-01-19 06:14:07'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` > TIMESTAMP'2038-01-19 06:14:07') +EXPLAIN SELECT * FROM tbl_datetime WHERE t >= '2038-01-19 06:14:07'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` >= TIMESTAMP'2038-01-19 06:14:07') +EXPLAIN SELECT * FROM tbl_datetime WHERE t = '2038-01-19 06:14:07'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` = TIMESTAMP'2038-01-19 06:14:07') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <> '2038-01-19 06:14:07'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <> TIMESTAMP'2038-01-19 06:14:07') +SELECT * FROM tbl_datetime WHERE t < '1970-01-01 03:00:01'; +t +SELECT * FROM tbl_datetime WHERE t <= '1970-01-01 03:00:01'; +t +1970-01-01 03:00:01 +SELECT * FROM tbl_datetime WHERE t > '1970-01-01 03:00:01'; +t +2018-06-19 21:00:00 +2038-01-19 06:14:07 +SELECT * FROM tbl_datetime WHERE t >= '1970-01-01 03:00:01'; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +SELECT * FROM tbl_datetime WHERE t = '1970-01-01 03:00:01'; +t +1970-01-01 03:00:01 +SELECT * FROM tbl_datetime WHERE t <> '1970-01-01 03:00:01'; +t +2018-06-19 21:00:00 +2038-01-19 06:14:07 +EXPLAIN SELECT * FROM tbl_datetime WHERE t < '1970-01-01 03:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` < TIMESTAMP'1970-01-01 03:00:01') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <= '1970-01-01 03:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <= TIMESTAMP'1970-01-01 03:00:01') +EXPLAIN SELECT * FROM tbl_datetime WHERE t > '1970-01-01 03:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` > TIMESTAMP'1970-01-01 03:00:01') +EXPLAIN SELECT * FROM tbl_datetime WHERE t >= '1970-01-01 03:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` >= TIMESTAMP'1970-01-01 03:00:01') +EXPLAIN SELECT * FROM tbl_datetime WHERE t = '1970-01-01 03:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` = TIMESTAMP'1970-01-01 03:00:01') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <> '1970-01-01 03:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <> TIMESTAMP'1970-01-01 03:00:01') + +2. TIMESTAMP literals +These are the same as above, but with TIMESTAMP prefix. + +TIMESTAMP field: Some out of range constants (adjusted to TZ ++0300 for MTR) +DATETIME field: in range +SELECT * FROM tbl_datetime WHERE t < TIMESTAMP'2038-01-19 06:14:07.999999'; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +SELECT * FROM tbl_datetime WHERE t <= TIMESTAMP'2038-01-19 06:14:07.999999'; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +SELECT * FROM tbl_datetime WHERE t > TIMESTAMP'2038-01-19 06:14:07.999999'; +t +SELECT * FROM tbl_datetime WHERE t >= TIMESTAMP'2038-01-19 06:14:07.999999'; +t +SELECT * FROM tbl_datetime WHERE t = TIMESTAMP'2038-01-19 06:14:07.999999'; +t +SELECT * FROM tbl_datetime WHERE t <> TIMESTAMP'2038-01-19 06:14:07.999999'; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +EXPLAIN SELECT * FROM tbl_datetime WHERE t < TIMESTAMP'2038-01-19 06:14:07.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` < TIMESTAMP'2038-01-19 06:14:07.999999') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <= TIMESTAMP'2038-01-19 06:14:07.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <= TIMESTAMP'2038-01-19 06:14:07.999999') +EXPLAIN SELECT * FROM tbl_datetime WHERE t > TIMESTAMP'2038-01-19 06:14:07.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` > TIMESTAMP'2038-01-19 06:14:07.999999') +EXPLAIN SELECT * FROM tbl_datetime WHERE t >= TIMESTAMP'2038-01-19 06:14:07.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` >= TIMESTAMP'2038-01-19 06:14:07.999999') +EXPLAIN SELECT * FROM tbl_datetime WHERE t = TIMESTAMP'2038-01-19 06:14:07.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` = TIMESTAMP'2038-01-19 06:14:07.999999') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <> TIMESTAMP'2038-01-19 06:14:07.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <> TIMESTAMP'2038-01-19 06:14:07.999999') +SELECT * FROM tbl_datetime WHERE t < TIMESTAMP'2038-01-19 06:14:08.000000'; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +SELECT * FROM tbl_datetime WHERE t <= TIMESTAMP'2038-01-19 06:14:08.000000'; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +SELECT * FROM tbl_datetime WHERE t > TIMESTAMP'2038-01-19 06:14:08.000000'; +t +SELECT * FROM tbl_datetime WHERE t >= TIMESTAMP'2038-01-19 06:14:08.000000'; +t +SELECT * FROM tbl_datetime WHERE t = TIMESTAMP'2038-01-19 06:14:08.000000'; +t +SELECT * FROM tbl_datetime WHERE t <> TIMESTAMP'2038-01-19 06:14:08.000000'; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +EXPLAIN SELECT * FROM tbl_datetime WHERE t < TIMESTAMP'2038-01-19 06:14:08.000000'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` < TIMESTAMP'2038-01-19 06:14:08.000000') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <= TIMESTAMP'2038-01-19 06:14:08.000000'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <= TIMESTAMP'2038-01-19 06:14:08.000000') +EXPLAIN SELECT * FROM tbl_datetime WHERE t > TIMESTAMP'2038-01-19 06:14:08.000000'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` > TIMESTAMP'2038-01-19 06:14:08.000000') +EXPLAIN SELECT * FROM tbl_datetime WHERE t >= TIMESTAMP'2038-01-19 06:14:08.000000'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` >= TIMESTAMP'2038-01-19 06:14:08.000000') +EXPLAIN SELECT * FROM tbl_datetime WHERE t = TIMESTAMP'2038-01-19 06:14:08.000000'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` = TIMESTAMP'2038-01-19 06:14:08.000000') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <> TIMESTAMP'2038-01-19 06:14:08.000000'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <> TIMESTAMP'2038-01-19 06:14:08.000000') +SELECT * FROM tbl_datetime WHERE t < TIMESTAMP'1970-01-01 00:00:01'; +t +SELECT * FROM tbl_datetime WHERE t <= TIMESTAMP'1970-01-01 00:00:01'; +t +SELECT * FROM tbl_datetime WHERE t > TIMESTAMP'1970-01-01 00:00:01'; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +SELECT * FROM tbl_datetime WHERE t >= TIMESTAMP'1970-01-01 00:00:01'; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +SELECT * FROM tbl_datetime WHERE t = TIMESTAMP'1970-01-01 00:00:01'; +t +SELECT * FROM tbl_datetime WHERE t <> TIMESTAMP'1970-01-01 00:00:01'; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +EXPLAIN SELECT * FROM tbl_datetime WHERE t < TIMESTAMP'1970-01-01 00:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` < TIMESTAMP'1970-01-01 00:00:01') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <= TIMESTAMP'1970-01-01 00:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <= TIMESTAMP'1970-01-01 00:00:01') +EXPLAIN SELECT * FROM tbl_datetime WHERE t > TIMESTAMP'1970-01-01 00:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` > TIMESTAMP'1970-01-01 00:00:01') +EXPLAIN SELECT * FROM tbl_datetime WHERE t >= TIMESTAMP'1970-01-01 00:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` >= TIMESTAMP'1970-01-01 00:00:01') +EXPLAIN SELECT * FROM tbl_datetime WHERE t = TIMESTAMP'1970-01-01 00:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` = TIMESTAMP'1970-01-01 00:00:01') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <> TIMESTAMP'1970-01-01 00:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <> TIMESTAMP'1970-01-01 00:00:01') +SELECT * FROM tbl_datetime WHERE t < TIMESTAMP'1970-01-01 03:00:00.999999'; +t +SELECT * FROM tbl_datetime WHERE t <= TIMESTAMP'1970-01-01 03:00:00.999999'; +t +SELECT * FROM tbl_datetime WHERE t > TIMESTAMP'1970-01-01 03:00:00.999999'; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +SELECT * FROM tbl_datetime WHERE t >= TIMESTAMP'1970-01-01 03:00:00.999999'; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +SELECT * FROM tbl_datetime WHERE t = TIMESTAMP'1970-01-01 03:00:00.999999'; +t +SELECT * FROM tbl_datetime WHERE t <> TIMESTAMP'1970-01-01 03:00:00.999999'; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +EXPLAIN SELECT * FROM tbl_datetime WHERE t < TIMESTAMP'1970-01-01 03:00:00.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` < TIMESTAMP'1970-01-01 03:00:00.999999') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <= TIMESTAMP'1970-01-01 03:00:00.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <= TIMESTAMP'1970-01-01 03:00:00.999999') +EXPLAIN SELECT * FROM tbl_datetime WHERE t > TIMESTAMP'1970-01-01 03:00:00.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` > TIMESTAMP'1970-01-01 03:00:00.999999') +EXPLAIN SELECT * FROM tbl_datetime WHERE t >= TIMESTAMP'1970-01-01 03:00:00.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` >= TIMESTAMP'1970-01-01 03:00:00.999999') +EXPLAIN SELECT * FROM tbl_datetime WHERE t = TIMESTAMP'1970-01-01 03:00:00.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` = TIMESTAMP'1970-01-01 03:00:00.999999') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <> TIMESTAMP'1970-01-01 03:00:00.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <> TIMESTAMP'1970-01-01 03:00:00.999999') + +Some in range constants + +SELECT * FROM tbl_datetime WHERE t < TIMESTAMP'2038-01-19 06:14:07'; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +SELECT * FROM tbl_datetime WHERE t <= TIMESTAMP'2038-01-19 06:14:07'; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +SELECT * FROM tbl_datetime WHERE t > TIMESTAMP'2038-01-19 06:14:07'; +t +SELECT * FROM tbl_datetime WHERE t >= TIMESTAMP'2038-01-19 06:14:07'; +t +2038-01-19 06:14:07 +SELECT * FROM tbl_datetime WHERE t = TIMESTAMP'2038-01-19 06:14:07'; +t +2038-01-19 06:14:07 +SELECT * FROM tbl_datetime WHERE t <> TIMESTAMP'2038-01-19 06:14:07'; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +EXPLAIN SELECT * FROM tbl_datetime WHERE t < TIMESTAMP'2038-01-19 06:14:07'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` < TIMESTAMP'2038-01-19 06:14:07') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <= TIMESTAMP'2038-01-19 06:14:07'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <= TIMESTAMP'2038-01-19 06:14:07') +EXPLAIN SELECT * FROM tbl_datetime WHERE t > TIMESTAMP'2038-01-19 06:14:07'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` > TIMESTAMP'2038-01-19 06:14:07') +EXPLAIN SELECT * FROM tbl_datetime WHERE t >= TIMESTAMP'2038-01-19 06:14:07'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` >= TIMESTAMP'2038-01-19 06:14:07') +EXPLAIN SELECT * FROM tbl_datetime WHERE t = TIMESTAMP'2038-01-19 06:14:07'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` = TIMESTAMP'2038-01-19 06:14:07') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <> TIMESTAMP'2038-01-19 06:14:07'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <> TIMESTAMP'2038-01-19 06:14:07') +SELECT * FROM tbl_datetime WHERE t < TIMESTAMP'1970-01-01 03:00:01'; +t +SELECT * FROM tbl_datetime WHERE t <= TIMESTAMP'1970-01-01 03:00:01'; +t +1970-01-01 03:00:01 +SELECT * FROM tbl_datetime WHERE t > TIMESTAMP'1970-01-01 03:00:01'; +t +2018-06-19 21:00:00 +2038-01-19 06:14:07 +SELECT * FROM tbl_datetime WHERE t >= TIMESTAMP'1970-01-01 03:00:01'; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +SELECT * FROM tbl_datetime WHERE t = TIMESTAMP'1970-01-01 03:00:01'; +t +1970-01-01 03:00:01 +SELECT * FROM tbl_datetime WHERE t <> TIMESTAMP'1970-01-01 03:00:01'; +t +2018-06-19 21:00:00 +2038-01-19 06:14:07 +EXPLAIN SELECT * FROM tbl_datetime WHERE t < TIMESTAMP'1970-01-01 03:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` < TIMESTAMP'1970-01-01 03:00:01') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <= TIMESTAMP'1970-01-01 03:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <= TIMESTAMP'1970-01-01 03:00:01') +EXPLAIN SELECT * FROM tbl_datetime WHERE t > TIMESTAMP'1970-01-01 03:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` > TIMESTAMP'1970-01-01 03:00:01') +EXPLAIN SELECT * FROM tbl_datetime WHERE t >= TIMESTAMP'1970-01-01 03:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` >= TIMESTAMP'1970-01-01 03:00:01') +EXPLAIN SELECT * FROM tbl_datetime WHERE t = TIMESTAMP'1970-01-01 03:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` = TIMESTAMP'1970-01-01 03:00:01') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <> TIMESTAMP'1970-01-01 03:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <> TIMESTAMP'1970-01-01 03:00:01') + +3. Integer literals + +SELECT * FROM tbl_datetime WHERE t < 20380119061407; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +SELECT * FROM tbl_datetime WHERE t <= 20380119061407; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +SELECT * FROM tbl_datetime WHERE t > 20380119061407; +t +SELECT * FROM tbl_datetime WHERE t >= 20380119061407; +t +2038-01-19 06:14:07 +SELECT * FROM tbl_datetime WHERE t = 20380119061407; +t +2038-01-19 06:14:07 +SELECT * FROM tbl_datetime WHERE t <> 20380119061407; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +EXPLAIN SELECT * FROM tbl_datetime WHERE t < 20380119061407; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` < TIMESTAMP'2038-01-19 06:14:07') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <= 20380119061407; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <= TIMESTAMP'2038-01-19 06:14:07') +EXPLAIN SELECT * FROM tbl_datetime WHERE t > 20380119061407; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` > TIMESTAMP'2038-01-19 06:14:07') +EXPLAIN SELECT * FROM tbl_datetime WHERE t >= 20380119061407; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` >= TIMESTAMP'2038-01-19 06:14:07') +EXPLAIN SELECT * FROM tbl_datetime WHERE t = 20380119061407; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` = TIMESTAMP'2038-01-19 06:14:07') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <> 20380119061407; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <> TIMESTAMP'2038-01-19 06:14:07') +SELECT * FROM tbl_datetime WHERE t < 2018; +t +Warnings: +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +SELECT * FROM tbl_datetime WHERE t <= 2018; +t +Warnings: +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +SELECT * FROM tbl_datetime WHERE t > 2018; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +Warnings: +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +SELECT * FROM tbl_datetime WHERE t >= 2018; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +Warnings: +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +SELECT * FROM tbl_datetime WHERE t = 2018; +t +Warnings: +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +SELECT * FROM tbl_datetime WHERE t <> 2018; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +Warnings: +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +EXPLAIN SELECT * FROM tbl_datetime WHERE t < 2018; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` < 2018) +EXPLAIN SELECT * FROM tbl_datetime WHERE t <= 2018; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <= 2018) +EXPLAIN SELECT * FROM tbl_datetime WHERE t > 2018; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` > 2018) +EXPLAIN SELECT * FROM tbl_datetime WHERE t >= 2018; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` >= 2018) +EXPLAIN SELECT * FROM tbl_datetime WHERE t = 2018; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` = 2018) +EXPLAIN SELECT * FROM tbl_datetime WHERE t <> 2018; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <> 2018) +SELECT * FROM tbl_datetime WHERE t < 0; +t +SELECT * FROM tbl_datetime WHERE t <= 0; +t +SELECT * FROM tbl_datetime WHERE t > 0; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +SELECT * FROM tbl_datetime WHERE t >= 0; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +SELECT * FROM tbl_datetime WHERE t = 0; +t +SELECT * FROM tbl_datetime WHERE t <> 0; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +EXPLAIN SELECT * FROM tbl_datetime WHERE t < 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` < TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <= 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <= TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_datetime WHERE t > 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` > TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_datetime WHERE t >= 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` >= TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_datetime WHERE t = 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` = TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <> 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <> TIMESTAMP'0000-00-00 00:00:00') + +3. Decimal literals: rounded up to whole seconds + +SELECT * FROM tbl_datetime WHERE t < 20380119061405.55; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +SELECT * FROM tbl_datetime WHERE t <= 20380119061405.55; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +SELECT * FROM tbl_datetime WHERE t > 20380119061405.55; +t +2038-01-19 06:14:07 +SELECT * FROM tbl_datetime WHERE t >= 20380119061405.55; +t +2038-01-19 06:14:07 +SELECT * FROM tbl_datetime WHERE t = 20380119061405.55; +t +SELECT * FROM tbl_datetime WHERE t <> 20380119061405.55; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +EXPLAIN SELECT * FROM tbl_datetime WHERE t < 20380119061405.55; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` < TIMESTAMP'2038-01-19 06:14:06') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <= 20380119061405.55; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <= TIMESTAMP'2038-01-19 06:14:06') +EXPLAIN SELECT * FROM tbl_datetime WHERE t > 20380119061405.55; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` > TIMESTAMP'2038-01-19 06:14:06') +EXPLAIN SELECT * FROM tbl_datetime WHERE t >= 20380119061405.55; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` >= TIMESTAMP'2038-01-19 06:14:06') +EXPLAIN SELECT * FROM tbl_datetime WHERE t = 20380119061405.55; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` = TIMESTAMP'2038-01-19 06:14:06') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <> 20380119061405.55; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <> TIMESTAMP'2038-01-19 06:14:06') +SELECT * FROM tbl_datetime WHERE t < 2018.55; +t +Warnings: +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +SELECT * FROM tbl_datetime WHERE t <= 2018.55; +t +Warnings: +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +SELECT * FROM tbl_datetime WHERE t > 2018.55; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +Warnings: +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +SELECT * FROM tbl_datetime WHERE t >= 2018.55; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +Warnings: +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +SELECT * FROM tbl_datetime WHERE t = 2018.55; +t +Warnings: +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +SELECT * FROM tbl_datetime WHERE t <> 2018.55; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +Warnings: +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +EXPLAIN SELECT * FROM tbl_datetime WHERE t < 2018.55; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` < 2018.55) +EXPLAIN SELECT * FROM tbl_datetime WHERE t <= 2018.55; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <= 2018.55) +EXPLAIN SELECT * FROM tbl_datetime WHERE t > 2018.55; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` > 2018.55) +EXPLAIN SELECT * FROM tbl_datetime WHERE t >= 2018.55; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` >= 2018.55) +EXPLAIN SELECT * FROM tbl_datetime WHERE t = 2018.55; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` = 2018.55) +EXPLAIN SELECT * FROM tbl_datetime WHERE t <> 2018.55; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <> 2018.55) +SELECT * FROM tbl_datetime WHERE t < 0.00; +t +SELECT * FROM tbl_datetime WHERE t <= 0.00; +t +SELECT * FROM tbl_datetime WHERE t > 0.00; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +SELECT * FROM tbl_datetime WHERE t >= 0.00; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +SELECT * FROM tbl_datetime WHERE t = 0.00; +t +SELECT * FROM tbl_datetime WHERE t <> 0.00; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +EXPLAIN SELECT * FROM tbl_datetime WHERE t < 0.00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` < TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <= 0.00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <= TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_datetime WHERE t > 0.00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` > TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_datetime WHERE t >= 0.00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` >= TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_datetime WHERE t = 0.00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` = TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <> 0.00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <> TIMESTAMP'0000-00-00 00:00:00') + +3. Real literals: rounded up to whole seconds + +SELECT * FROM tbl_datetime WHERE t < 20380119061405.55E00; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +SELECT * FROM tbl_datetime WHERE t <= 20380119061405.55E00; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +SELECT * FROM tbl_datetime WHERE t > 20380119061405.55E00; +t +2038-01-19 06:14:07 +SELECT * FROM tbl_datetime WHERE t >= 20380119061405.55E00; +t +2038-01-19 06:14:07 +SELECT * FROM tbl_datetime WHERE t = 20380119061405.55E00; +t +SELECT * FROM tbl_datetime WHERE t <> 20380119061405.55E00; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +EXPLAIN SELECT * FROM tbl_datetime WHERE t < 20380119061405.55E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` < TIMESTAMP'2038-01-19 06:14:06') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <= 20380119061405.55E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <= TIMESTAMP'2038-01-19 06:14:06') +EXPLAIN SELECT * FROM tbl_datetime WHERE t > 20380119061405.55E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` > TIMESTAMP'2038-01-19 06:14:06') +EXPLAIN SELECT * FROM tbl_datetime WHERE t >= 20380119061405.55E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` >= TIMESTAMP'2038-01-19 06:14:06') +EXPLAIN SELECT * FROM tbl_datetime WHERE t = 20380119061405.55E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` = TIMESTAMP'2038-01-19 06:14:06') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <> 20380119061405.55E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <> TIMESTAMP'2038-01-19 06:14:06') +SELECT * FROM tbl_datetime WHERE t < 0.00E00; +t +SELECT * FROM tbl_datetime WHERE t <= 0.00E00; +t +SELECT * FROM tbl_datetime WHERE t > 0.00E00; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +SELECT * FROM tbl_datetime WHERE t >= 0.00E00; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +SELECT * FROM tbl_datetime WHERE t = 0.00E00; +t +SELECT * FROM tbl_datetime WHERE t <> 0.00E00; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +EXPLAIN SELECT * FROM tbl_datetime WHERE t < 0.00E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` < TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <= 0.00E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <= TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_datetime WHERE t > 0.00E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` > TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_datetime WHERE t >= 0.00E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` >= TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_datetime WHERE t = 0.00E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` = TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <> 0.00E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <> TIMESTAMP'0000-00-00 00:00:00') +DROP TABLE tbl_datetime; +CREATE TABLE tbl_datetime (t DATETIME(2) ); +INSERT INTO tbl_datetime VALUES ('1970-01-01 03:00:01.00'), ('2018-06-19 21:00:00'), ('2038-01-19 06:14:07.99'); +ANALYZE TABLE tbl_datetime; +Table Op Msg_type Msg_text +test.tbl_datetime analyze status OK +SELECT * FROM tbl_datetime; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +SET @OLD_SQL_MODE=@@SQL_MODE, @@SQL_MODE=ALLOW_INVALID_DATES; + +1. String literals + +TIMESTAMP: Some out of range constants (adjusted to TZ +0300 +for MTR) +DATETIME: 1970, 2038 just fine. +SELECT * FROM tbl_datetime WHERE t < '0000-00-00 10:20:30'; +t +SELECT * FROM tbl_datetime WHERE t <= '0000-00-00 10:20:30'; +t +SELECT * FROM tbl_datetime WHERE t > '0000-00-00 10:20:30'; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +SELECT * FROM tbl_datetime WHERE t >= '0000-00-00 10:20:30'; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +SELECT * FROM tbl_datetime WHERE t = '0000-00-00 10:20:30'; +t +SELECT * FROM tbl_datetime WHERE t <> '0000-00-00 10:20:30'; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +EXPLAIN SELECT * FROM tbl_datetime WHERE t < '0000-00-00 10:20:30'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` < TIMESTAMP'0000-00-00 10:20:30') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <= '0000-00-00 10:20:30'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <= TIMESTAMP'0000-00-00 10:20:30') +EXPLAIN SELECT * FROM tbl_datetime WHERE t > '0000-00-00 10:20:30'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` > TIMESTAMP'0000-00-00 10:20:30') +EXPLAIN SELECT * FROM tbl_datetime WHERE t >= '0000-00-00 10:20:30'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` >= TIMESTAMP'0000-00-00 10:20:30') +EXPLAIN SELECT * FROM tbl_datetime WHERE t = '0000-00-00 10:20:30'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` = TIMESTAMP'0000-00-00 10:20:30') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <> '0000-00-00 10:20:30'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <> TIMESTAMP'0000-00-00 10:20:30') +SELECT * FROM tbl_datetime WHERE t < '2038-01-19 06:14:07.999999'; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +SELECT * FROM tbl_datetime WHERE t <= '2038-01-19 06:14:07.999999'; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +SELECT * FROM tbl_datetime WHERE t > '2038-01-19 06:14:07.999999'; +t +SELECT * FROM tbl_datetime WHERE t >= '2038-01-19 06:14:07.999999'; +t +SELECT * FROM tbl_datetime WHERE t = '2038-01-19 06:14:07.999999'; +t +SELECT * FROM tbl_datetime WHERE t <> '2038-01-19 06:14:07.999999'; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +EXPLAIN SELECT * FROM tbl_datetime WHERE t < '2038-01-19 06:14:07.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` < TIMESTAMP'2038-01-19 06:14:07.999999') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <= '2038-01-19 06:14:07.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <= TIMESTAMP'2038-01-19 06:14:07.999999') +EXPLAIN SELECT * FROM tbl_datetime WHERE t > '2038-01-19 06:14:07.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` > TIMESTAMP'2038-01-19 06:14:07.999999') +EXPLAIN SELECT * FROM tbl_datetime WHERE t >= '2038-01-19 06:14:07.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` >= TIMESTAMP'2038-01-19 06:14:07.999999') +EXPLAIN SELECT * FROM tbl_datetime WHERE t = '2038-01-19 06:14:07.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` = TIMESTAMP'2038-01-19 06:14:07.999999') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <> '2038-01-19 06:14:07.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <> TIMESTAMP'2038-01-19 06:14:07.999999') +SELECT * FROM tbl_datetime WHERE t < '2038-01-19 06:14:08.000000'; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +SELECT * FROM tbl_datetime WHERE t <= '2038-01-19 06:14:08.000000'; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +SELECT * FROM tbl_datetime WHERE t > '2038-01-19 06:14:08.000000'; +t +SELECT * FROM tbl_datetime WHERE t >= '2038-01-19 06:14:08.000000'; +t +SELECT * FROM tbl_datetime WHERE t = '2038-01-19 06:14:08.000000'; +t +SELECT * FROM tbl_datetime WHERE t <> '2038-01-19 06:14:08.000000'; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +EXPLAIN SELECT * FROM tbl_datetime WHERE t < '2038-01-19 06:14:08.000000'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` < TIMESTAMP'2038-01-19 06:14:08') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <= '2038-01-19 06:14:08.000000'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <= TIMESTAMP'2038-01-19 06:14:08') +EXPLAIN SELECT * FROM tbl_datetime WHERE t > '2038-01-19 06:14:08.000000'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` > TIMESTAMP'2038-01-19 06:14:08') +EXPLAIN SELECT * FROM tbl_datetime WHERE t >= '2038-01-19 06:14:08.000000'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` >= TIMESTAMP'2038-01-19 06:14:08') +EXPLAIN SELECT * FROM tbl_datetime WHERE t = '2038-01-19 06:14:08.000000'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` = TIMESTAMP'2038-01-19 06:14:08') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <> '2038-01-19 06:14:08.000000'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <> TIMESTAMP'2038-01-19 06:14:08') +SELECT * FROM tbl_datetime WHERE t < '1970-01-01 00:00:01'; +t +SELECT * FROM tbl_datetime WHERE t <= '1970-01-01 00:00:01'; +t +SELECT * FROM tbl_datetime WHERE t > '1970-01-01 00:00:01'; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +SELECT * FROM tbl_datetime WHERE t >= '1970-01-01 00:00:01'; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +SELECT * FROM tbl_datetime WHERE t = '1970-01-01 00:00:01'; +t +SELECT * FROM tbl_datetime WHERE t <> '1970-01-01 00:00:01'; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +EXPLAIN SELECT * FROM tbl_datetime WHERE t < '1970-01-01 00:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` < TIMESTAMP'1970-01-01 00:00:01') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <= '1970-01-01 00:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <= TIMESTAMP'1970-01-01 00:00:01') +EXPLAIN SELECT * FROM tbl_datetime WHERE t > '1970-01-01 00:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` > TIMESTAMP'1970-01-01 00:00:01') +EXPLAIN SELECT * FROM tbl_datetime WHERE t >= '1970-01-01 00:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` >= TIMESTAMP'1970-01-01 00:00:01') +EXPLAIN SELECT * FROM tbl_datetime WHERE t = '1970-01-01 00:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` = TIMESTAMP'1970-01-01 00:00:01') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <> '1970-01-01 00:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <> TIMESTAMP'1970-01-01 00:00:01') +SELECT * FROM tbl_datetime WHERE t < '1970-01-01 03:00:00.999999'; +t +SELECT * FROM tbl_datetime WHERE t <= '1970-01-01 03:00:00.999999'; +t +SELECT * FROM tbl_datetime WHERE t > '1970-01-01 03:00:00.999999'; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +SELECT * FROM tbl_datetime WHERE t >= '1970-01-01 03:00:00.999999'; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +SELECT * FROM tbl_datetime WHERE t = '1970-01-01 03:00:00.999999'; +t +SELECT * FROM tbl_datetime WHERE t <> '1970-01-01 03:00:00.999999'; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +EXPLAIN SELECT * FROM tbl_datetime WHERE t < '1970-01-01 03:00:00.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` < TIMESTAMP'1970-01-01 03:00:00.999999') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <= '1970-01-01 03:00:00.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <= TIMESTAMP'1970-01-01 03:00:00.999999') +EXPLAIN SELECT * FROM tbl_datetime WHERE t > '1970-01-01 03:00:00.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` > TIMESTAMP'1970-01-01 03:00:00.999999') +EXPLAIN SELECT * FROM tbl_datetime WHERE t >= '1970-01-01 03:00:00.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` >= TIMESTAMP'1970-01-01 03:00:00.999999') +EXPLAIN SELECT * FROM tbl_datetime WHERE t = '1970-01-01 03:00:00.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` = TIMESTAMP'1970-01-01 03:00:00.999999') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <> '1970-01-01 03:00:00.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <> TIMESTAMP'1970-01-01 03:00:00.999999') +Zero date? +SELECT * FROM tbl_datetime WHERE t < '0000-00-00 00:00:00'; +t +SELECT * FROM tbl_datetime WHERE t <= '0000-00-00 00:00:00'; +t +SELECT * FROM tbl_datetime WHERE t > '0000-00-00 00:00:00'; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +SELECT * FROM tbl_datetime WHERE t >= '0000-00-00 00:00:00'; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +SELECT * FROM tbl_datetime WHERE t = '0000-00-00 00:00:00'; +t +SELECT * FROM tbl_datetime WHERE t <> '0000-00-00 00:00:00'; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +EXPLAIN SELECT * FROM tbl_datetime WHERE t < '0000-00-00 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` < TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <= '0000-00-00 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <= TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_datetime WHERE t > '0000-00-00 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` > TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_datetime WHERE t >= '0000-00-00 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` >= TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_datetime WHERE t = '0000-00-00 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` = TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <> '0000-00-00 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <> TIMESTAMP'0000-00-00 00:00:00') +Zero in date +SELECT * FROM tbl_datetime WHERE t < '2018-00-03 00:00:00'; +t +1970-01-01 03:00:01.00 +SELECT * FROM tbl_datetime WHERE t <= '2018-00-03 00:00:00'; +t +1970-01-01 03:00:01.00 +SELECT * FROM tbl_datetime WHERE t > '2018-00-03 00:00:00'; +t +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +SELECT * FROM tbl_datetime WHERE t >= '2018-00-03 00:00:00'; +t +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +SELECT * FROM tbl_datetime WHERE t = '2018-00-03 00:00:00'; +t +SELECT * FROM tbl_datetime WHERE t <> '2018-00-03 00:00:00'; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +EXPLAIN SELECT * FROM tbl_datetime WHERE t < '2018-00-03 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` < TIMESTAMP'2018-00-03 00:00:00') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <= '2018-00-03 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <= TIMESTAMP'2018-00-03 00:00:00') +EXPLAIN SELECT * FROM tbl_datetime WHERE t > '2018-00-03 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` > TIMESTAMP'2018-00-03 00:00:00') +EXPLAIN SELECT * FROM tbl_datetime WHERE t >= '2018-00-03 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` >= TIMESTAMP'2018-00-03 00:00:00') +EXPLAIN SELECT * FROM tbl_datetime WHERE t = '2018-00-03 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` = TIMESTAMP'2018-00-03 00:00:00') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <> '2018-00-03 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <> TIMESTAMP'2018-00-03 00:00:00') + +Some in range string literals + +SELECT * FROM tbl_datetime WHERE t < '2038-01-19 06:14:07'; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +SELECT * FROM tbl_datetime WHERE t <= '2038-01-19 06:14:07'; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +SELECT * FROM tbl_datetime WHERE t > '2038-01-19 06:14:07'; +t +2038-01-19 06:14:07.99 +SELECT * FROM tbl_datetime WHERE t >= '2038-01-19 06:14:07'; +t +2038-01-19 06:14:07.99 +SELECT * FROM tbl_datetime WHERE t = '2038-01-19 06:14:07'; +t +SELECT * FROM tbl_datetime WHERE t <> '2038-01-19 06:14:07'; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +EXPLAIN SELECT * FROM tbl_datetime WHERE t < '2038-01-19 06:14:07'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` < TIMESTAMP'2038-01-19 06:14:07') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <= '2038-01-19 06:14:07'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <= TIMESTAMP'2038-01-19 06:14:07') +EXPLAIN SELECT * FROM tbl_datetime WHERE t > '2038-01-19 06:14:07'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` > TIMESTAMP'2038-01-19 06:14:07') +EXPLAIN SELECT * FROM tbl_datetime WHERE t >= '2038-01-19 06:14:07'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` >= TIMESTAMP'2038-01-19 06:14:07') +EXPLAIN SELECT * FROM tbl_datetime WHERE t = '2038-01-19 06:14:07'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` = TIMESTAMP'2038-01-19 06:14:07') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <> '2038-01-19 06:14:07'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <> TIMESTAMP'2038-01-19 06:14:07') +SELECT * FROM tbl_datetime WHERE t < '1970-01-01 03:00:01'; +t +SELECT * FROM tbl_datetime WHERE t <= '1970-01-01 03:00:01'; +t +1970-01-01 03:00:01.00 +SELECT * FROM tbl_datetime WHERE t > '1970-01-01 03:00:01'; +t +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +SELECT * FROM tbl_datetime WHERE t >= '1970-01-01 03:00:01'; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +SELECT * FROM tbl_datetime WHERE t = '1970-01-01 03:00:01'; +t +1970-01-01 03:00:01.00 +SELECT * FROM tbl_datetime WHERE t <> '1970-01-01 03:00:01'; +t +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +EXPLAIN SELECT * FROM tbl_datetime WHERE t < '1970-01-01 03:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` < TIMESTAMP'1970-01-01 03:00:01') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <= '1970-01-01 03:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <= TIMESTAMP'1970-01-01 03:00:01') +EXPLAIN SELECT * FROM tbl_datetime WHERE t > '1970-01-01 03:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` > TIMESTAMP'1970-01-01 03:00:01') +EXPLAIN SELECT * FROM tbl_datetime WHERE t >= '1970-01-01 03:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` >= TIMESTAMP'1970-01-01 03:00:01') +EXPLAIN SELECT * FROM tbl_datetime WHERE t = '1970-01-01 03:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` = TIMESTAMP'1970-01-01 03:00:01') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <> '1970-01-01 03:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <> TIMESTAMP'1970-01-01 03:00:01') + +2. TIMESTAMP literals +These are the same as above, but with TIMESTAMP prefix. + +TIMESTAMP field: Some out of range constants (adjusted to TZ ++0300 for MTR) +DATETIME field: in range +SELECT * FROM tbl_datetime WHERE t < TIMESTAMP'2038-01-19 06:14:07.999999'; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +SELECT * FROM tbl_datetime WHERE t <= TIMESTAMP'2038-01-19 06:14:07.999999'; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +SELECT * FROM tbl_datetime WHERE t > TIMESTAMP'2038-01-19 06:14:07.999999'; +t +SELECT * FROM tbl_datetime WHERE t >= TIMESTAMP'2038-01-19 06:14:07.999999'; +t +SELECT * FROM tbl_datetime WHERE t = TIMESTAMP'2038-01-19 06:14:07.999999'; +t +SELECT * FROM tbl_datetime WHERE t <> TIMESTAMP'2038-01-19 06:14:07.999999'; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +EXPLAIN SELECT * FROM tbl_datetime WHERE t < TIMESTAMP'2038-01-19 06:14:07.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` < TIMESTAMP'2038-01-19 06:14:07.999999') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <= TIMESTAMP'2038-01-19 06:14:07.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <= TIMESTAMP'2038-01-19 06:14:07.999999') +EXPLAIN SELECT * FROM tbl_datetime WHERE t > TIMESTAMP'2038-01-19 06:14:07.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` > TIMESTAMP'2038-01-19 06:14:07.999999') +EXPLAIN SELECT * FROM tbl_datetime WHERE t >= TIMESTAMP'2038-01-19 06:14:07.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` >= TIMESTAMP'2038-01-19 06:14:07.999999') +EXPLAIN SELECT * FROM tbl_datetime WHERE t = TIMESTAMP'2038-01-19 06:14:07.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` = TIMESTAMP'2038-01-19 06:14:07.999999') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <> TIMESTAMP'2038-01-19 06:14:07.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <> TIMESTAMP'2038-01-19 06:14:07.999999') +SELECT * FROM tbl_datetime WHERE t < TIMESTAMP'2038-01-19 06:14:08.000000'; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +SELECT * FROM tbl_datetime WHERE t <= TIMESTAMP'2038-01-19 06:14:08.000000'; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +SELECT * FROM tbl_datetime WHERE t > TIMESTAMP'2038-01-19 06:14:08.000000'; +t +SELECT * FROM tbl_datetime WHERE t >= TIMESTAMP'2038-01-19 06:14:08.000000'; +t +SELECT * FROM tbl_datetime WHERE t = TIMESTAMP'2038-01-19 06:14:08.000000'; +t +SELECT * FROM tbl_datetime WHERE t <> TIMESTAMP'2038-01-19 06:14:08.000000'; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +EXPLAIN SELECT * FROM tbl_datetime WHERE t < TIMESTAMP'2038-01-19 06:14:08.000000'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` < TIMESTAMP'2038-01-19 06:14:08.000000') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <= TIMESTAMP'2038-01-19 06:14:08.000000'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <= TIMESTAMP'2038-01-19 06:14:08.000000') +EXPLAIN SELECT * FROM tbl_datetime WHERE t > TIMESTAMP'2038-01-19 06:14:08.000000'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` > TIMESTAMP'2038-01-19 06:14:08.000000') +EXPLAIN SELECT * FROM tbl_datetime WHERE t >= TIMESTAMP'2038-01-19 06:14:08.000000'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` >= TIMESTAMP'2038-01-19 06:14:08.000000') +EXPLAIN SELECT * FROM tbl_datetime WHERE t = TIMESTAMP'2038-01-19 06:14:08.000000'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` = TIMESTAMP'2038-01-19 06:14:08.000000') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <> TIMESTAMP'2038-01-19 06:14:08.000000'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <> TIMESTAMP'2038-01-19 06:14:08.000000') +SELECT * FROM tbl_datetime WHERE t < TIMESTAMP'1970-01-01 00:00:01'; +t +SELECT * FROM tbl_datetime WHERE t <= TIMESTAMP'1970-01-01 00:00:01'; +t +SELECT * FROM tbl_datetime WHERE t > TIMESTAMP'1970-01-01 00:00:01'; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +SELECT * FROM tbl_datetime WHERE t >= TIMESTAMP'1970-01-01 00:00:01'; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +SELECT * FROM tbl_datetime WHERE t = TIMESTAMP'1970-01-01 00:00:01'; +t +SELECT * FROM tbl_datetime WHERE t <> TIMESTAMP'1970-01-01 00:00:01'; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +EXPLAIN SELECT * FROM tbl_datetime WHERE t < TIMESTAMP'1970-01-01 00:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` < TIMESTAMP'1970-01-01 00:00:01') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <= TIMESTAMP'1970-01-01 00:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <= TIMESTAMP'1970-01-01 00:00:01') +EXPLAIN SELECT * FROM tbl_datetime WHERE t > TIMESTAMP'1970-01-01 00:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` > TIMESTAMP'1970-01-01 00:00:01') +EXPLAIN SELECT * FROM tbl_datetime WHERE t >= TIMESTAMP'1970-01-01 00:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` >= TIMESTAMP'1970-01-01 00:00:01') +EXPLAIN SELECT * FROM tbl_datetime WHERE t = TIMESTAMP'1970-01-01 00:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` = TIMESTAMP'1970-01-01 00:00:01') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <> TIMESTAMP'1970-01-01 00:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <> TIMESTAMP'1970-01-01 00:00:01') +SELECT * FROM tbl_datetime WHERE t < TIMESTAMP'1970-01-01 03:00:00.999999'; +t +SELECT * FROM tbl_datetime WHERE t <= TIMESTAMP'1970-01-01 03:00:00.999999'; +t +SELECT * FROM tbl_datetime WHERE t > TIMESTAMP'1970-01-01 03:00:00.999999'; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +SELECT * FROM tbl_datetime WHERE t >= TIMESTAMP'1970-01-01 03:00:00.999999'; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +SELECT * FROM tbl_datetime WHERE t = TIMESTAMP'1970-01-01 03:00:00.999999'; +t +SELECT * FROM tbl_datetime WHERE t <> TIMESTAMP'1970-01-01 03:00:00.999999'; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +EXPLAIN SELECT * FROM tbl_datetime WHERE t < TIMESTAMP'1970-01-01 03:00:00.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` < TIMESTAMP'1970-01-01 03:00:00.999999') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <= TIMESTAMP'1970-01-01 03:00:00.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <= TIMESTAMP'1970-01-01 03:00:00.999999') +EXPLAIN SELECT * FROM tbl_datetime WHERE t > TIMESTAMP'1970-01-01 03:00:00.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` > TIMESTAMP'1970-01-01 03:00:00.999999') +EXPLAIN SELECT * FROM tbl_datetime WHERE t >= TIMESTAMP'1970-01-01 03:00:00.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` >= TIMESTAMP'1970-01-01 03:00:00.999999') +EXPLAIN SELECT * FROM tbl_datetime WHERE t = TIMESTAMP'1970-01-01 03:00:00.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` = TIMESTAMP'1970-01-01 03:00:00.999999') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <> TIMESTAMP'1970-01-01 03:00:00.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <> TIMESTAMP'1970-01-01 03:00:00.999999') + +Some in range constants + +SELECT * FROM tbl_datetime WHERE t < TIMESTAMP'2038-01-19 06:14:07'; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +SELECT * FROM tbl_datetime WHERE t <= TIMESTAMP'2038-01-19 06:14:07'; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +SELECT * FROM tbl_datetime WHERE t > TIMESTAMP'2038-01-19 06:14:07'; +t +2038-01-19 06:14:07.99 +SELECT * FROM tbl_datetime WHERE t >= TIMESTAMP'2038-01-19 06:14:07'; +t +2038-01-19 06:14:07.99 +SELECT * FROM tbl_datetime WHERE t = TIMESTAMP'2038-01-19 06:14:07'; +t +SELECT * FROM tbl_datetime WHERE t <> TIMESTAMP'2038-01-19 06:14:07'; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +EXPLAIN SELECT * FROM tbl_datetime WHERE t < TIMESTAMP'2038-01-19 06:14:07'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` < TIMESTAMP'2038-01-19 06:14:07') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <= TIMESTAMP'2038-01-19 06:14:07'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <= TIMESTAMP'2038-01-19 06:14:07') +EXPLAIN SELECT * FROM tbl_datetime WHERE t > TIMESTAMP'2038-01-19 06:14:07'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` > TIMESTAMP'2038-01-19 06:14:07') +EXPLAIN SELECT * FROM tbl_datetime WHERE t >= TIMESTAMP'2038-01-19 06:14:07'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` >= TIMESTAMP'2038-01-19 06:14:07') +EXPLAIN SELECT * FROM tbl_datetime WHERE t = TIMESTAMP'2038-01-19 06:14:07'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` = TIMESTAMP'2038-01-19 06:14:07') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <> TIMESTAMP'2038-01-19 06:14:07'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <> TIMESTAMP'2038-01-19 06:14:07') +SELECT * FROM tbl_datetime WHERE t < TIMESTAMP'1970-01-01 03:00:01'; +t +SELECT * FROM tbl_datetime WHERE t <= TIMESTAMP'1970-01-01 03:00:01'; +t +1970-01-01 03:00:01.00 +SELECT * FROM tbl_datetime WHERE t > TIMESTAMP'1970-01-01 03:00:01'; +t +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +SELECT * FROM tbl_datetime WHERE t >= TIMESTAMP'1970-01-01 03:00:01'; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +SELECT * FROM tbl_datetime WHERE t = TIMESTAMP'1970-01-01 03:00:01'; +t +1970-01-01 03:00:01.00 +SELECT * FROM tbl_datetime WHERE t <> TIMESTAMP'1970-01-01 03:00:01'; +t +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +EXPLAIN SELECT * FROM tbl_datetime WHERE t < TIMESTAMP'1970-01-01 03:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` < TIMESTAMP'1970-01-01 03:00:01') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <= TIMESTAMP'1970-01-01 03:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <= TIMESTAMP'1970-01-01 03:00:01') +EXPLAIN SELECT * FROM tbl_datetime WHERE t > TIMESTAMP'1970-01-01 03:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` > TIMESTAMP'1970-01-01 03:00:01') +EXPLAIN SELECT * FROM tbl_datetime WHERE t >= TIMESTAMP'1970-01-01 03:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` >= TIMESTAMP'1970-01-01 03:00:01') +EXPLAIN SELECT * FROM tbl_datetime WHERE t = TIMESTAMP'1970-01-01 03:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` = TIMESTAMP'1970-01-01 03:00:01') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <> TIMESTAMP'1970-01-01 03:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <> TIMESTAMP'1970-01-01 03:00:01') + +3. Integer literals + +SELECT * FROM tbl_datetime WHERE t < 20380119061407; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +SELECT * FROM tbl_datetime WHERE t <= 20380119061407; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +SELECT * FROM tbl_datetime WHERE t > 20380119061407; +t +2038-01-19 06:14:07.99 +SELECT * FROM tbl_datetime WHERE t >= 20380119061407; +t +2038-01-19 06:14:07.99 +SELECT * FROM tbl_datetime WHERE t = 20380119061407; +t +SELECT * FROM tbl_datetime WHERE t <> 20380119061407; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +EXPLAIN SELECT * FROM tbl_datetime WHERE t < 20380119061407; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` < TIMESTAMP'2038-01-19 06:14:07') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <= 20380119061407; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <= TIMESTAMP'2038-01-19 06:14:07') +EXPLAIN SELECT * FROM tbl_datetime WHERE t > 20380119061407; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` > TIMESTAMP'2038-01-19 06:14:07') +EXPLAIN SELECT * FROM tbl_datetime WHERE t >= 20380119061407; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` >= TIMESTAMP'2038-01-19 06:14:07') +EXPLAIN SELECT * FROM tbl_datetime WHERE t = 20380119061407; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` = TIMESTAMP'2038-01-19 06:14:07') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <> 20380119061407; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <> TIMESTAMP'2038-01-19 06:14:07') +SELECT * FROM tbl_datetime WHERE t < 2018; +t +Warnings: +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +SELECT * FROM tbl_datetime WHERE t <= 2018; +t +Warnings: +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +SELECT * FROM tbl_datetime WHERE t > 2018; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +Warnings: +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +SELECT * FROM tbl_datetime WHERE t >= 2018; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +Warnings: +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +SELECT * FROM tbl_datetime WHERE t = 2018; +t +Warnings: +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +SELECT * FROM tbl_datetime WHERE t <> 2018; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +Warnings: +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +EXPLAIN SELECT * FROM tbl_datetime WHERE t < 2018; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` < 2018) +EXPLAIN SELECT * FROM tbl_datetime WHERE t <= 2018; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <= 2018) +EXPLAIN SELECT * FROM tbl_datetime WHERE t > 2018; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` > 2018) +EXPLAIN SELECT * FROM tbl_datetime WHERE t >= 2018; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` >= 2018) +EXPLAIN SELECT * FROM tbl_datetime WHERE t = 2018; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` = 2018) +EXPLAIN SELECT * FROM tbl_datetime WHERE t <> 2018; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <> 2018) +SELECT * FROM tbl_datetime WHERE t < 0; +t +SELECT * FROM tbl_datetime WHERE t <= 0; +t +SELECT * FROM tbl_datetime WHERE t > 0; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +SELECT * FROM tbl_datetime WHERE t >= 0; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +SELECT * FROM tbl_datetime WHERE t = 0; +t +SELECT * FROM tbl_datetime WHERE t <> 0; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +EXPLAIN SELECT * FROM tbl_datetime WHERE t < 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` < TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <= 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <= TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_datetime WHERE t > 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` > TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_datetime WHERE t >= 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` >= TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_datetime WHERE t = 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` = TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <> 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <> TIMESTAMP'0000-00-00 00:00:00') + +3. Decimal literals: rounded up to whole seconds + +SELECT * FROM tbl_datetime WHERE t < 20380119061405.55; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +SELECT * FROM tbl_datetime WHERE t <= 20380119061405.55; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +SELECT * FROM tbl_datetime WHERE t > 20380119061405.55; +t +2038-01-19 06:14:07.99 +SELECT * FROM tbl_datetime WHERE t >= 20380119061405.55; +t +2038-01-19 06:14:07.99 +SELECT * FROM tbl_datetime WHERE t = 20380119061405.55; +t +SELECT * FROM tbl_datetime WHERE t <> 20380119061405.55; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +EXPLAIN SELECT * FROM tbl_datetime WHERE t < 20380119061405.55; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` < TIMESTAMP'2038-01-19 06:14:05.55') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <= 20380119061405.55; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <= TIMESTAMP'2038-01-19 06:14:05.55') +EXPLAIN SELECT * FROM tbl_datetime WHERE t > 20380119061405.55; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` > TIMESTAMP'2038-01-19 06:14:05.55') +EXPLAIN SELECT * FROM tbl_datetime WHERE t >= 20380119061405.55; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` >= TIMESTAMP'2038-01-19 06:14:05.55') +EXPLAIN SELECT * FROM tbl_datetime WHERE t = 20380119061405.55; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` = TIMESTAMP'2038-01-19 06:14:05.55') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <> 20380119061405.55; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <> TIMESTAMP'2038-01-19 06:14:05.55') +SELECT * FROM tbl_datetime WHERE t < 2018.55; +t +Warnings: +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +SELECT * FROM tbl_datetime WHERE t <= 2018.55; +t +Warnings: +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +SELECT * FROM tbl_datetime WHERE t > 2018.55; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +Warnings: +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +SELECT * FROM tbl_datetime WHERE t >= 2018.55; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +Warnings: +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +SELECT * FROM tbl_datetime WHERE t = 2018.55; +t +Warnings: +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +SELECT * FROM tbl_datetime WHERE t <> 2018.55; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +Warnings: +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +EXPLAIN SELECT * FROM tbl_datetime WHERE t < 2018.55; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` < 2018.55) +EXPLAIN SELECT * FROM tbl_datetime WHERE t <= 2018.55; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <= 2018.55) +EXPLAIN SELECT * FROM tbl_datetime WHERE t > 2018.55; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` > 2018.55) +EXPLAIN SELECT * FROM tbl_datetime WHERE t >= 2018.55; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` >= 2018.55) +EXPLAIN SELECT * FROM tbl_datetime WHERE t = 2018.55; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` = 2018.55) +EXPLAIN SELECT * FROM tbl_datetime WHERE t <> 2018.55; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <> 2018.55) +SELECT * FROM tbl_datetime WHERE t < 0.00; +t +SELECT * FROM tbl_datetime WHERE t <= 0.00; +t +SELECT * FROM tbl_datetime WHERE t > 0.00; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +SELECT * FROM tbl_datetime WHERE t >= 0.00; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +SELECT * FROM tbl_datetime WHERE t = 0.00; +t +SELECT * FROM tbl_datetime WHERE t <> 0.00; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +EXPLAIN SELECT * FROM tbl_datetime WHERE t < 0.00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` < TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <= 0.00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <= TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_datetime WHERE t > 0.00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` > TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_datetime WHERE t >= 0.00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` >= TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_datetime WHERE t = 0.00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` = TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <> 0.00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <> TIMESTAMP'0000-00-00 00:00:00') + +3. Real literals: rounded up to whole seconds + +SELECT * FROM tbl_datetime WHERE t < 20380119061405.55E00; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +SELECT * FROM tbl_datetime WHERE t <= 20380119061405.55E00; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +SELECT * FROM tbl_datetime WHERE t > 20380119061405.55E00; +t +2038-01-19 06:14:07.99 +SELECT * FROM tbl_datetime WHERE t >= 20380119061405.55E00; +t +2038-01-19 06:14:07.99 +SELECT * FROM tbl_datetime WHERE t = 20380119061405.55E00; +t +SELECT * FROM tbl_datetime WHERE t <> 20380119061405.55E00; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +EXPLAIN SELECT * FROM tbl_datetime WHERE t < 20380119061405.55E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` < TIMESTAMP'2038-01-19 06:14:05.55') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <= 20380119061405.55E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <= TIMESTAMP'2038-01-19 06:14:05.55') +EXPLAIN SELECT * FROM tbl_datetime WHERE t > 20380119061405.55E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` > TIMESTAMP'2038-01-19 06:14:05.55') +EXPLAIN SELECT * FROM tbl_datetime WHERE t >= 20380119061405.55E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` >= TIMESTAMP'2038-01-19 06:14:05.55') +EXPLAIN SELECT * FROM tbl_datetime WHERE t = 20380119061405.55E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` = TIMESTAMP'2038-01-19 06:14:05.55') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <> 20380119061405.55E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <> TIMESTAMP'2038-01-19 06:14:05.55') +SELECT * FROM tbl_datetime WHERE t < 0.00E00; +t +SELECT * FROM tbl_datetime WHERE t <= 0.00E00; +t +SELECT * FROM tbl_datetime WHERE t > 0.00E00; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +SELECT * FROM tbl_datetime WHERE t >= 0.00E00; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +SELECT * FROM tbl_datetime WHERE t = 0.00E00; +t +SELECT * FROM tbl_datetime WHERE t <> 0.00E00; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +EXPLAIN SELECT * FROM tbl_datetime WHERE t < 0.00E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` < TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <= 0.00E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <= TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_datetime WHERE t > 0.00E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` > TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_datetime WHERE t >= 0.00E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` >= TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_datetime WHERE t = 0.00E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` = TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <> 0.00E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <> TIMESTAMP'0000-00-00 00:00:00') +DROP TABLE tbl_datetime; +CREATE TABLE tbl_datetime (t DATETIME(6) ); +INSERT INTO tbl_datetime VALUES ('1970-01-01 03:00:01.000000'), ('2018-06-19 21:00:00'), ('2038-01-19 06:14:07.999999'); +ANALYZE TABLE tbl_datetime; +Table Op Msg_type Msg_text +test.tbl_datetime analyze status OK +SELECT * FROM tbl_datetime; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +SET @OLD_SQL_MODE=@@SQL_MODE, @@SQL_MODE=ALLOW_INVALID_DATES; + +1. String literals + +TIMESTAMP: Some out of range constants (adjusted to TZ +0300 +for MTR) +DATETIME: 1970, 2038 just fine. +SELECT * FROM tbl_datetime WHERE t < '0000-00-00 10:20:30'; +t +SELECT * FROM tbl_datetime WHERE t <= '0000-00-00 10:20:30'; +t +SELECT * FROM tbl_datetime WHERE t > '0000-00-00 10:20:30'; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +SELECT * FROM tbl_datetime WHERE t >= '0000-00-00 10:20:30'; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +SELECT * FROM tbl_datetime WHERE t = '0000-00-00 10:20:30'; +t +SELECT * FROM tbl_datetime WHERE t <> '0000-00-00 10:20:30'; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +EXPLAIN SELECT * FROM tbl_datetime WHERE t < '0000-00-00 10:20:30'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` < TIMESTAMP'0000-00-00 10:20:30') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <= '0000-00-00 10:20:30'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <= TIMESTAMP'0000-00-00 10:20:30') +EXPLAIN SELECT * FROM tbl_datetime WHERE t > '0000-00-00 10:20:30'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` > TIMESTAMP'0000-00-00 10:20:30') +EXPLAIN SELECT * FROM tbl_datetime WHERE t >= '0000-00-00 10:20:30'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` >= TIMESTAMP'0000-00-00 10:20:30') +EXPLAIN SELECT * FROM tbl_datetime WHERE t = '0000-00-00 10:20:30'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` = TIMESTAMP'0000-00-00 10:20:30') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <> '0000-00-00 10:20:30'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <> TIMESTAMP'0000-00-00 10:20:30') +SELECT * FROM tbl_datetime WHERE t < '2038-01-19 06:14:07.999999'; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +SELECT * FROM tbl_datetime WHERE t <= '2038-01-19 06:14:07.999999'; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +SELECT * FROM tbl_datetime WHERE t > '2038-01-19 06:14:07.999999'; +t +SELECT * FROM tbl_datetime WHERE t >= '2038-01-19 06:14:07.999999'; +t +2038-01-19 06:14:07.999999 +SELECT * FROM tbl_datetime WHERE t = '2038-01-19 06:14:07.999999'; +t +2038-01-19 06:14:07.999999 +SELECT * FROM tbl_datetime WHERE t <> '2038-01-19 06:14:07.999999'; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +EXPLAIN SELECT * FROM tbl_datetime WHERE t < '2038-01-19 06:14:07.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` < TIMESTAMP'2038-01-19 06:14:07.999999') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <= '2038-01-19 06:14:07.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <= TIMESTAMP'2038-01-19 06:14:07.999999') +EXPLAIN SELECT * FROM tbl_datetime WHERE t > '2038-01-19 06:14:07.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` > TIMESTAMP'2038-01-19 06:14:07.999999') +EXPLAIN SELECT * FROM tbl_datetime WHERE t >= '2038-01-19 06:14:07.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` >= TIMESTAMP'2038-01-19 06:14:07.999999') +EXPLAIN SELECT * FROM tbl_datetime WHERE t = '2038-01-19 06:14:07.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` = TIMESTAMP'2038-01-19 06:14:07.999999') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <> '2038-01-19 06:14:07.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <> TIMESTAMP'2038-01-19 06:14:07.999999') +SELECT * FROM tbl_datetime WHERE t < '2038-01-19 06:14:08.000000'; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +SELECT * FROM tbl_datetime WHERE t <= '2038-01-19 06:14:08.000000'; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +SELECT * FROM tbl_datetime WHERE t > '2038-01-19 06:14:08.000000'; +t +SELECT * FROM tbl_datetime WHERE t >= '2038-01-19 06:14:08.000000'; +t +SELECT * FROM tbl_datetime WHERE t = '2038-01-19 06:14:08.000000'; +t +SELECT * FROM tbl_datetime WHERE t <> '2038-01-19 06:14:08.000000'; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +EXPLAIN SELECT * FROM tbl_datetime WHERE t < '2038-01-19 06:14:08.000000'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` < TIMESTAMP'2038-01-19 06:14:08') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <= '2038-01-19 06:14:08.000000'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <= TIMESTAMP'2038-01-19 06:14:08') +EXPLAIN SELECT * FROM tbl_datetime WHERE t > '2038-01-19 06:14:08.000000'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` > TIMESTAMP'2038-01-19 06:14:08') +EXPLAIN SELECT * FROM tbl_datetime WHERE t >= '2038-01-19 06:14:08.000000'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` >= TIMESTAMP'2038-01-19 06:14:08') +EXPLAIN SELECT * FROM tbl_datetime WHERE t = '2038-01-19 06:14:08.000000'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` = TIMESTAMP'2038-01-19 06:14:08') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <> '2038-01-19 06:14:08.000000'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <> TIMESTAMP'2038-01-19 06:14:08') +SELECT * FROM tbl_datetime WHERE t < '1970-01-01 00:00:01'; +t +SELECT * FROM tbl_datetime WHERE t <= '1970-01-01 00:00:01'; +t +SELECT * FROM tbl_datetime WHERE t > '1970-01-01 00:00:01'; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +SELECT * FROM tbl_datetime WHERE t >= '1970-01-01 00:00:01'; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +SELECT * FROM tbl_datetime WHERE t = '1970-01-01 00:00:01'; +t +SELECT * FROM tbl_datetime WHERE t <> '1970-01-01 00:00:01'; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +EXPLAIN SELECT * FROM tbl_datetime WHERE t < '1970-01-01 00:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` < TIMESTAMP'1970-01-01 00:00:01') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <= '1970-01-01 00:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <= TIMESTAMP'1970-01-01 00:00:01') +EXPLAIN SELECT * FROM tbl_datetime WHERE t > '1970-01-01 00:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` > TIMESTAMP'1970-01-01 00:00:01') +EXPLAIN SELECT * FROM tbl_datetime WHERE t >= '1970-01-01 00:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` >= TIMESTAMP'1970-01-01 00:00:01') +EXPLAIN SELECT * FROM tbl_datetime WHERE t = '1970-01-01 00:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` = TIMESTAMP'1970-01-01 00:00:01') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <> '1970-01-01 00:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <> TIMESTAMP'1970-01-01 00:00:01') +SELECT * FROM tbl_datetime WHERE t < '1970-01-01 03:00:00.999999'; +t +SELECT * FROM tbl_datetime WHERE t <= '1970-01-01 03:00:00.999999'; +t +SELECT * FROM tbl_datetime WHERE t > '1970-01-01 03:00:00.999999'; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +SELECT * FROM tbl_datetime WHERE t >= '1970-01-01 03:00:00.999999'; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +SELECT * FROM tbl_datetime WHERE t = '1970-01-01 03:00:00.999999'; +t +SELECT * FROM tbl_datetime WHERE t <> '1970-01-01 03:00:00.999999'; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +EXPLAIN SELECT * FROM tbl_datetime WHERE t < '1970-01-01 03:00:00.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` < TIMESTAMP'1970-01-01 03:00:00.999999') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <= '1970-01-01 03:00:00.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <= TIMESTAMP'1970-01-01 03:00:00.999999') +EXPLAIN SELECT * FROM tbl_datetime WHERE t > '1970-01-01 03:00:00.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` > TIMESTAMP'1970-01-01 03:00:00.999999') +EXPLAIN SELECT * FROM tbl_datetime WHERE t >= '1970-01-01 03:00:00.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` >= TIMESTAMP'1970-01-01 03:00:00.999999') +EXPLAIN SELECT * FROM tbl_datetime WHERE t = '1970-01-01 03:00:00.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` = TIMESTAMP'1970-01-01 03:00:00.999999') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <> '1970-01-01 03:00:00.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <> TIMESTAMP'1970-01-01 03:00:00.999999') +Zero date? +SELECT * FROM tbl_datetime WHERE t < '0000-00-00 00:00:00'; +t +SELECT * FROM tbl_datetime WHERE t <= '0000-00-00 00:00:00'; +t +SELECT * FROM tbl_datetime WHERE t > '0000-00-00 00:00:00'; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +SELECT * FROM tbl_datetime WHERE t >= '0000-00-00 00:00:00'; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +SELECT * FROM tbl_datetime WHERE t = '0000-00-00 00:00:00'; +t +SELECT * FROM tbl_datetime WHERE t <> '0000-00-00 00:00:00'; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +EXPLAIN SELECT * FROM tbl_datetime WHERE t < '0000-00-00 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` < TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <= '0000-00-00 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <= TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_datetime WHERE t > '0000-00-00 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` > TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_datetime WHERE t >= '0000-00-00 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` >= TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_datetime WHERE t = '0000-00-00 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` = TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <> '0000-00-00 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <> TIMESTAMP'0000-00-00 00:00:00') +Zero in date +SELECT * FROM tbl_datetime WHERE t < '2018-00-03 00:00:00'; +t +1970-01-01 03:00:01.000000 +SELECT * FROM tbl_datetime WHERE t <= '2018-00-03 00:00:00'; +t +1970-01-01 03:00:01.000000 +SELECT * FROM tbl_datetime WHERE t > '2018-00-03 00:00:00'; +t +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +SELECT * FROM tbl_datetime WHERE t >= '2018-00-03 00:00:00'; +t +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +SELECT * FROM tbl_datetime WHERE t = '2018-00-03 00:00:00'; +t +SELECT * FROM tbl_datetime WHERE t <> '2018-00-03 00:00:00'; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +EXPLAIN SELECT * FROM tbl_datetime WHERE t < '2018-00-03 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` < TIMESTAMP'2018-00-03 00:00:00') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <= '2018-00-03 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <= TIMESTAMP'2018-00-03 00:00:00') +EXPLAIN SELECT * FROM tbl_datetime WHERE t > '2018-00-03 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` > TIMESTAMP'2018-00-03 00:00:00') +EXPLAIN SELECT * FROM tbl_datetime WHERE t >= '2018-00-03 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` >= TIMESTAMP'2018-00-03 00:00:00') +EXPLAIN SELECT * FROM tbl_datetime WHERE t = '2018-00-03 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` = TIMESTAMP'2018-00-03 00:00:00') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <> '2018-00-03 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <> TIMESTAMP'2018-00-03 00:00:00') + +Some in range string literals + +SELECT * FROM tbl_datetime WHERE t < '2038-01-19 06:14:07'; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +SELECT * FROM tbl_datetime WHERE t <= '2038-01-19 06:14:07'; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +SELECT * FROM tbl_datetime WHERE t > '2038-01-19 06:14:07'; +t +2038-01-19 06:14:07.999999 +SELECT * FROM tbl_datetime WHERE t >= '2038-01-19 06:14:07'; +t +2038-01-19 06:14:07.999999 +SELECT * FROM tbl_datetime WHERE t = '2038-01-19 06:14:07'; +t +SELECT * FROM tbl_datetime WHERE t <> '2038-01-19 06:14:07'; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +EXPLAIN SELECT * FROM tbl_datetime WHERE t < '2038-01-19 06:14:07'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` < TIMESTAMP'2038-01-19 06:14:07') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <= '2038-01-19 06:14:07'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <= TIMESTAMP'2038-01-19 06:14:07') +EXPLAIN SELECT * FROM tbl_datetime WHERE t > '2038-01-19 06:14:07'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` > TIMESTAMP'2038-01-19 06:14:07') +EXPLAIN SELECT * FROM tbl_datetime WHERE t >= '2038-01-19 06:14:07'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` >= TIMESTAMP'2038-01-19 06:14:07') +EXPLAIN SELECT * FROM tbl_datetime WHERE t = '2038-01-19 06:14:07'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` = TIMESTAMP'2038-01-19 06:14:07') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <> '2038-01-19 06:14:07'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <> TIMESTAMP'2038-01-19 06:14:07') +SELECT * FROM tbl_datetime WHERE t < '1970-01-01 03:00:01'; +t +SELECT * FROM tbl_datetime WHERE t <= '1970-01-01 03:00:01'; +t +1970-01-01 03:00:01.000000 +SELECT * FROM tbl_datetime WHERE t > '1970-01-01 03:00:01'; +t +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +SELECT * FROM tbl_datetime WHERE t >= '1970-01-01 03:00:01'; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +SELECT * FROM tbl_datetime WHERE t = '1970-01-01 03:00:01'; +t +1970-01-01 03:00:01.000000 +SELECT * FROM tbl_datetime WHERE t <> '1970-01-01 03:00:01'; +t +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +EXPLAIN SELECT * FROM tbl_datetime WHERE t < '1970-01-01 03:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` < TIMESTAMP'1970-01-01 03:00:01') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <= '1970-01-01 03:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <= TIMESTAMP'1970-01-01 03:00:01') +EXPLAIN SELECT * FROM tbl_datetime WHERE t > '1970-01-01 03:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` > TIMESTAMP'1970-01-01 03:00:01') +EXPLAIN SELECT * FROM tbl_datetime WHERE t >= '1970-01-01 03:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` >= TIMESTAMP'1970-01-01 03:00:01') +EXPLAIN SELECT * FROM tbl_datetime WHERE t = '1970-01-01 03:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` = TIMESTAMP'1970-01-01 03:00:01') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <> '1970-01-01 03:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <> TIMESTAMP'1970-01-01 03:00:01') + +2. TIMESTAMP literals +These are the same as above, but with TIMESTAMP prefix. + +TIMESTAMP field: Some out of range constants (adjusted to TZ ++0300 for MTR) +DATETIME field: in range +SELECT * FROM tbl_datetime WHERE t < TIMESTAMP'2038-01-19 06:14:07.999999'; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +SELECT * FROM tbl_datetime WHERE t <= TIMESTAMP'2038-01-19 06:14:07.999999'; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +SELECT * FROM tbl_datetime WHERE t > TIMESTAMP'2038-01-19 06:14:07.999999'; +t +SELECT * FROM tbl_datetime WHERE t >= TIMESTAMP'2038-01-19 06:14:07.999999'; +t +2038-01-19 06:14:07.999999 +SELECT * FROM tbl_datetime WHERE t = TIMESTAMP'2038-01-19 06:14:07.999999'; +t +2038-01-19 06:14:07.999999 +SELECT * FROM tbl_datetime WHERE t <> TIMESTAMP'2038-01-19 06:14:07.999999'; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +EXPLAIN SELECT * FROM tbl_datetime WHERE t < TIMESTAMP'2038-01-19 06:14:07.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` < TIMESTAMP'2038-01-19 06:14:07.999999') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <= TIMESTAMP'2038-01-19 06:14:07.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <= TIMESTAMP'2038-01-19 06:14:07.999999') +EXPLAIN SELECT * FROM tbl_datetime WHERE t > TIMESTAMP'2038-01-19 06:14:07.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` > TIMESTAMP'2038-01-19 06:14:07.999999') +EXPLAIN SELECT * FROM tbl_datetime WHERE t >= TIMESTAMP'2038-01-19 06:14:07.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` >= TIMESTAMP'2038-01-19 06:14:07.999999') +EXPLAIN SELECT * FROM tbl_datetime WHERE t = TIMESTAMP'2038-01-19 06:14:07.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` = TIMESTAMP'2038-01-19 06:14:07.999999') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <> TIMESTAMP'2038-01-19 06:14:07.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <> TIMESTAMP'2038-01-19 06:14:07.999999') +SELECT * FROM tbl_datetime WHERE t < TIMESTAMP'2038-01-19 06:14:08.000000'; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +SELECT * FROM tbl_datetime WHERE t <= TIMESTAMP'2038-01-19 06:14:08.000000'; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +SELECT * FROM tbl_datetime WHERE t > TIMESTAMP'2038-01-19 06:14:08.000000'; +t +SELECT * FROM tbl_datetime WHERE t >= TIMESTAMP'2038-01-19 06:14:08.000000'; +t +SELECT * FROM tbl_datetime WHERE t = TIMESTAMP'2038-01-19 06:14:08.000000'; +t +SELECT * FROM tbl_datetime WHERE t <> TIMESTAMP'2038-01-19 06:14:08.000000'; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +EXPLAIN SELECT * FROM tbl_datetime WHERE t < TIMESTAMP'2038-01-19 06:14:08.000000'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` < TIMESTAMP'2038-01-19 06:14:08.000000') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <= TIMESTAMP'2038-01-19 06:14:08.000000'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <= TIMESTAMP'2038-01-19 06:14:08.000000') +EXPLAIN SELECT * FROM tbl_datetime WHERE t > TIMESTAMP'2038-01-19 06:14:08.000000'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` > TIMESTAMP'2038-01-19 06:14:08.000000') +EXPLAIN SELECT * FROM tbl_datetime WHERE t >= TIMESTAMP'2038-01-19 06:14:08.000000'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` >= TIMESTAMP'2038-01-19 06:14:08.000000') +EXPLAIN SELECT * FROM tbl_datetime WHERE t = TIMESTAMP'2038-01-19 06:14:08.000000'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` = TIMESTAMP'2038-01-19 06:14:08.000000') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <> TIMESTAMP'2038-01-19 06:14:08.000000'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <> TIMESTAMP'2038-01-19 06:14:08.000000') +SELECT * FROM tbl_datetime WHERE t < TIMESTAMP'1970-01-01 00:00:01'; +t +SELECT * FROM tbl_datetime WHERE t <= TIMESTAMP'1970-01-01 00:00:01'; +t +SELECT * FROM tbl_datetime WHERE t > TIMESTAMP'1970-01-01 00:00:01'; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +SELECT * FROM tbl_datetime WHERE t >= TIMESTAMP'1970-01-01 00:00:01'; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +SELECT * FROM tbl_datetime WHERE t = TIMESTAMP'1970-01-01 00:00:01'; +t +SELECT * FROM tbl_datetime WHERE t <> TIMESTAMP'1970-01-01 00:00:01'; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +EXPLAIN SELECT * FROM tbl_datetime WHERE t < TIMESTAMP'1970-01-01 00:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` < TIMESTAMP'1970-01-01 00:00:01') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <= TIMESTAMP'1970-01-01 00:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <= TIMESTAMP'1970-01-01 00:00:01') +EXPLAIN SELECT * FROM tbl_datetime WHERE t > TIMESTAMP'1970-01-01 00:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` > TIMESTAMP'1970-01-01 00:00:01') +EXPLAIN SELECT * FROM tbl_datetime WHERE t >= TIMESTAMP'1970-01-01 00:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` >= TIMESTAMP'1970-01-01 00:00:01') +EXPLAIN SELECT * FROM tbl_datetime WHERE t = TIMESTAMP'1970-01-01 00:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` = TIMESTAMP'1970-01-01 00:00:01') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <> TIMESTAMP'1970-01-01 00:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <> TIMESTAMP'1970-01-01 00:00:01') +SELECT * FROM tbl_datetime WHERE t < TIMESTAMP'1970-01-01 03:00:00.999999'; +t +SELECT * FROM tbl_datetime WHERE t <= TIMESTAMP'1970-01-01 03:00:00.999999'; +t +SELECT * FROM tbl_datetime WHERE t > TIMESTAMP'1970-01-01 03:00:00.999999'; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +SELECT * FROM tbl_datetime WHERE t >= TIMESTAMP'1970-01-01 03:00:00.999999'; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +SELECT * FROM tbl_datetime WHERE t = TIMESTAMP'1970-01-01 03:00:00.999999'; +t +SELECT * FROM tbl_datetime WHERE t <> TIMESTAMP'1970-01-01 03:00:00.999999'; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +EXPLAIN SELECT * FROM tbl_datetime WHERE t < TIMESTAMP'1970-01-01 03:00:00.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` < TIMESTAMP'1970-01-01 03:00:00.999999') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <= TIMESTAMP'1970-01-01 03:00:00.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <= TIMESTAMP'1970-01-01 03:00:00.999999') +EXPLAIN SELECT * FROM tbl_datetime WHERE t > TIMESTAMP'1970-01-01 03:00:00.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` > TIMESTAMP'1970-01-01 03:00:00.999999') +EXPLAIN SELECT * FROM tbl_datetime WHERE t >= TIMESTAMP'1970-01-01 03:00:00.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` >= TIMESTAMP'1970-01-01 03:00:00.999999') +EXPLAIN SELECT * FROM tbl_datetime WHERE t = TIMESTAMP'1970-01-01 03:00:00.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` = TIMESTAMP'1970-01-01 03:00:00.999999') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <> TIMESTAMP'1970-01-01 03:00:00.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <> TIMESTAMP'1970-01-01 03:00:00.999999') + +Some in range constants + +SELECT * FROM tbl_datetime WHERE t < TIMESTAMP'2038-01-19 06:14:07'; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +SELECT * FROM tbl_datetime WHERE t <= TIMESTAMP'2038-01-19 06:14:07'; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +SELECT * FROM tbl_datetime WHERE t > TIMESTAMP'2038-01-19 06:14:07'; +t +2038-01-19 06:14:07.999999 +SELECT * FROM tbl_datetime WHERE t >= TIMESTAMP'2038-01-19 06:14:07'; +t +2038-01-19 06:14:07.999999 +SELECT * FROM tbl_datetime WHERE t = TIMESTAMP'2038-01-19 06:14:07'; +t +SELECT * FROM tbl_datetime WHERE t <> TIMESTAMP'2038-01-19 06:14:07'; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +EXPLAIN SELECT * FROM tbl_datetime WHERE t < TIMESTAMP'2038-01-19 06:14:07'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` < TIMESTAMP'2038-01-19 06:14:07') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <= TIMESTAMP'2038-01-19 06:14:07'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <= TIMESTAMP'2038-01-19 06:14:07') +EXPLAIN SELECT * FROM tbl_datetime WHERE t > TIMESTAMP'2038-01-19 06:14:07'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` > TIMESTAMP'2038-01-19 06:14:07') +EXPLAIN SELECT * FROM tbl_datetime WHERE t >= TIMESTAMP'2038-01-19 06:14:07'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` >= TIMESTAMP'2038-01-19 06:14:07') +EXPLAIN SELECT * FROM tbl_datetime WHERE t = TIMESTAMP'2038-01-19 06:14:07'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` = TIMESTAMP'2038-01-19 06:14:07') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <> TIMESTAMP'2038-01-19 06:14:07'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <> TIMESTAMP'2038-01-19 06:14:07') +SELECT * FROM tbl_datetime WHERE t < TIMESTAMP'1970-01-01 03:00:01'; +t +SELECT * FROM tbl_datetime WHERE t <= TIMESTAMP'1970-01-01 03:00:01'; +t +1970-01-01 03:00:01.000000 +SELECT * FROM tbl_datetime WHERE t > TIMESTAMP'1970-01-01 03:00:01'; +t +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +SELECT * FROM tbl_datetime WHERE t >= TIMESTAMP'1970-01-01 03:00:01'; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +SELECT * FROM tbl_datetime WHERE t = TIMESTAMP'1970-01-01 03:00:01'; +t +1970-01-01 03:00:01.000000 +SELECT * FROM tbl_datetime WHERE t <> TIMESTAMP'1970-01-01 03:00:01'; +t +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +EXPLAIN SELECT * FROM tbl_datetime WHERE t < TIMESTAMP'1970-01-01 03:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` < TIMESTAMP'1970-01-01 03:00:01') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <= TIMESTAMP'1970-01-01 03:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <= TIMESTAMP'1970-01-01 03:00:01') +EXPLAIN SELECT * FROM tbl_datetime WHERE t > TIMESTAMP'1970-01-01 03:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` > TIMESTAMP'1970-01-01 03:00:01') +EXPLAIN SELECT * FROM tbl_datetime WHERE t >= TIMESTAMP'1970-01-01 03:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` >= TIMESTAMP'1970-01-01 03:00:01') +EXPLAIN SELECT * FROM tbl_datetime WHERE t = TIMESTAMP'1970-01-01 03:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` = TIMESTAMP'1970-01-01 03:00:01') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <> TIMESTAMP'1970-01-01 03:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <> TIMESTAMP'1970-01-01 03:00:01') + +3. Integer literals + +SELECT * FROM tbl_datetime WHERE t < 20380119061407; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +SELECT * FROM tbl_datetime WHERE t <= 20380119061407; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +SELECT * FROM tbl_datetime WHERE t > 20380119061407; +t +2038-01-19 06:14:07.999999 +SELECT * FROM tbl_datetime WHERE t >= 20380119061407; +t +2038-01-19 06:14:07.999999 +SELECT * FROM tbl_datetime WHERE t = 20380119061407; +t +SELECT * FROM tbl_datetime WHERE t <> 20380119061407; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +EXPLAIN SELECT * FROM tbl_datetime WHERE t < 20380119061407; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` < TIMESTAMP'2038-01-19 06:14:07') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <= 20380119061407; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <= TIMESTAMP'2038-01-19 06:14:07') +EXPLAIN SELECT * FROM tbl_datetime WHERE t > 20380119061407; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` > TIMESTAMP'2038-01-19 06:14:07') +EXPLAIN SELECT * FROM tbl_datetime WHERE t >= 20380119061407; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` >= TIMESTAMP'2038-01-19 06:14:07') +EXPLAIN SELECT * FROM tbl_datetime WHERE t = 20380119061407; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` = TIMESTAMP'2038-01-19 06:14:07') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <> 20380119061407; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <> TIMESTAMP'2038-01-19 06:14:07') +SELECT * FROM tbl_datetime WHERE t < 2018; +t +Warnings: +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +SELECT * FROM tbl_datetime WHERE t <= 2018; +t +Warnings: +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +SELECT * FROM tbl_datetime WHERE t > 2018; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +Warnings: +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +SELECT * FROM tbl_datetime WHERE t >= 2018; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +Warnings: +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +SELECT * FROM tbl_datetime WHERE t = 2018; +t +Warnings: +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +SELECT * FROM tbl_datetime WHERE t <> 2018; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +Warnings: +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +EXPLAIN SELECT * FROM tbl_datetime WHERE t < 2018; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` < 2018) +EXPLAIN SELECT * FROM tbl_datetime WHERE t <= 2018; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <= 2018) +EXPLAIN SELECT * FROM tbl_datetime WHERE t > 2018; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` > 2018) +EXPLAIN SELECT * FROM tbl_datetime WHERE t >= 2018; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` >= 2018) +EXPLAIN SELECT * FROM tbl_datetime WHERE t = 2018; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` = 2018) +EXPLAIN SELECT * FROM tbl_datetime WHERE t <> 2018; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <> 2018) +SELECT * FROM tbl_datetime WHERE t < 0; +t +SELECT * FROM tbl_datetime WHERE t <= 0; +t +SELECT * FROM tbl_datetime WHERE t > 0; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +SELECT * FROM tbl_datetime WHERE t >= 0; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +SELECT * FROM tbl_datetime WHERE t = 0; +t +SELECT * FROM tbl_datetime WHERE t <> 0; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +EXPLAIN SELECT * FROM tbl_datetime WHERE t < 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` < TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <= 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <= TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_datetime WHERE t > 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` > TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_datetime WHERE t >= 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` >= TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_datetime WHERE t = 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` = TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <> 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <> TIMESTAMP'0000-00-00 00:00:00') + +3. Decimal literals: rounded up to whole seconds + +SELECT * FROM tbl_datetime WHERE t < 20380119061405.55; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +SELECT * FROM tbl_datetime WHERE t <= 20380119061405.55; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +SELECT * FROM tbl_datetime WHERE t > 20380119061405.55; +t +2038-01-19 06:14:07.999999 +SELECT * FROM tbl_datetime WHERE t >= 20380119061405.55; +t +2038-01-19 06:14:07.999999 +SELECT * FROM tbl_datetime WHERE t = 20380119061405.55; +t +SELECT * FROM tbl_datetime WHERE t <> 20380119061405.55; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +EXPLAIN SELECT * FROM tbl_datetime WHERE t < 20380119061405.55; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` < TIMESTAMP'2038-01-19 06:14:05.55') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <= 20380119061405.55; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <= TIMESTAMP'2038-01-19 06:14:05.55') +EXPLAIN SELECT * FROM tbl_datetime WHERE t > 20380119061405.55; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` > TIMESTAMP'2038-01-19 06:14:05.55') +EXPLAIN SELECT * FROM tbl_datetime WHERE t >= 20380119061405.55; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` >= TIMESTAMP'2038-01-19 06:14:05.55') +EXPLAIN SELECT * FROM tbl_datetime WHERE t = 20380119061405.55; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` = TIMESTAMP'2038-01-19 06:14:05.55') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <> 20380119061405.55; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <> TIMESTAMP'2038-01-19 06:14:05.55') +SELECT * FROM tbl_datetime WHERE t < 2018.55; +t +Warnings: +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +SELECT * FROM tbl_datetime WHERE t <= 2018.55; +t +Warnings: +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +SELECT * FROM tbl_datetime WHERE t > 2018.55; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +Warnings: +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +SELECT * FROM tbl_datetime WHERE t >= 2018.55; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +Warnings: +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +SELECT * FROM tbl_datetime WHERE t = 2018.55; +t +Warnings: +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +SELECT * FROM tbl_datetime WHERE t <> 2018.55; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +Warnings: +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +EXPLAIN SELECT * FROM tbl_datetime WHERE t < 2018.55; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` < 2018.55) +EXPLAIN SELECT * FROM tbl_datetime WHERE t <= 2018.55; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <= 2018.55) +EXPLAIN SELECT * FROM tbl_datetime WHERE t > 2018.55; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` > 2018.55) +EXPLAIN SELECT * FROM tbl_datetime WHERE t >= 2018.55; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` >= 2018.55) +EXPLAIN SELECT * FROM tbl_datetime WHERE t = 2018.55; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` = 2018.55) +EXPLAIN SELECT * FROM tbl_datetime WHERE t <> 2018.55; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <> 2018.55) +SELECT * FROM tbl_datetime WHERE t < 0.00; +t +SELECT * FROM tbl_datetime WHERE t <= 0.00; +t +SELECT * FROM tbl_datetime WHERE t > 0.00; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +SELECT * FROM tbl_datetime WHERE t >= 0.00; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +SELECT * FROM tbl_datetime WHERE t = 0.00; +t +SELECT * FROM tbl_datetime WHERE t <> 0.00; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +EXPLAIN SELECT * FROM tbl_datetime WHERE t < 0.00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` < TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <= 0.00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <= TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_datetime WHERE t > 0.00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` > TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_datetime WHERE t >= 0.00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` >= TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_datetime WHERE t = 0.00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` = TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <> 0.00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <> TIMESTAMP'0000-00-00 00:00:00') + +3. Real literals: rounded up to whole seconds + +SELECT * FROM tbl_datetime WHERE t < 20380119061405.55E00; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +SELECT * FROM tbl_datetime WHERE t <= 20380119061405.55E00; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +SELECT * FROM tbl_datetime WHERE t > 20380119061405.55E00; +t +2038-01-19 06:14:07.999999 +SELECT * FROM tbl_datetime WHERE t >= 20380119061405.55E00; +t +2038-01-19 06:14:07.999999 +SELECT * FROM tbl_datetime WHERE t = 20380119061405.55E00; +t +SELECT * FROM tbl_datetime WHERE t <> 20380119061405.55E00; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +EXPLAIN SELECT * FROM tbl_datetime WHERE t < 20380119061405.55E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` < TIMESTAMP'2038-01-19 06:14:05.550781') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <= 20380119061405.55E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <= TIMESTAMP'2038-01-19 06:14:05.550781') +EXPLAIN SELECT * FROM tbl_datetime WHERE t > 20380119061405.55E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` > TIMESTAMP'2038-01-19 06:14:05.550781') +EXPLAIN SELECT * FROM tbl_datetime WHERE t >= 20380119061405.55E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` >= TIMESTAMP'2038-01-19 06:14:05.550781') +EXPLAIN SELECT * FROM tbl_datetime WHERE t = 20380119061405.55E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` = TIMESTAMP'2038-01-19 06:14:05.550781') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <> 20380119061405.55E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <> TIMESTAMP'2038-01-19 06:14:05.550781') +SELECT * FROM tbl_datetime WHERE t < 0.00E00; +t +SELECT * FROM tbl_datetime WHERE t <= 0.00E00; +t +SELECT * FROM tbl_datetime WHERE t > 0.00E00; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +SELECT * FROM tbl_datetime WHERE t >= 0.00E00; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +SELECT * FROM tbl_datetime WHERE t = 0.00E00; +t +SELECT * FROM tbl_datetime WHERE t <> 0.00E00; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +EXPLAIN SELECT * FROM tbl_datetime WHERE t < 0.00E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` < TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <= 0.00E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <= TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_datetime WHERE t > 0.00E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` > TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_datetime WHERE t >= 0.00E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` >= TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_datetime WHERE t = 0.00E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` = TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <> 0.00E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <> TIMESTAMP'0000-00-00 00:00:00') +DROP TABLE tbl_datetime; +CREATE TABLE tbl_date(d DATE); +INSERT INTO tbl_date VALUES ('0000-01-01'), ('2038-01-19'), ('9999-12-31'); +ANALYZE TABLE tbl_date; +Table Op Msg_type Msg_text +test.tbl_date analyze status OK +SET @OLD_SQL_MODE=@@SQL_MODE, @@SQL_MODE=ALLOW_INVALID_DATES; + +1. String literals + + +Semi supported +SELECT * FROM tbl_date WHERE d < '0000-01-01'; +d +SELECT * FROM tbl_date WHERE d <= '0000-01-01'; +d +0000-01-01 +SELECT * FROM tbl_date WHERE d > '0000-01-01'; +d +2038-01-19 +9999-12-31 +SELECT * FROM tbl_date WHERE d >= '0000-01-01'; +d +0000-01-01 +2038-01-19 +9999-12-31 +SELECT * FROM tbl_date WHERE d = '0000-01-01'; +d +0000-01-01 +SELECT * FROM tbl_date WHERE d <> '0000-01-01'; +d +2038-01-19 +9999-12-31 +EXPLAIN SELECT * FROM tbl_date WHERE d < '0000-01-01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` < DATE'0000-01-01') +EXPLAIN SELECT * FROM tbl_date WHERE d <= '0000-01-01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` <= DATE'0000-01-01') +EXPLAIN SELECT * FROM tbl_date WHERE d > '0000-01-01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` > DATE'0000-01-01') +EXPLAIN SELECT * FROM tbl_date WHERE d >= '0000-01-01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` >= DATE'0000-01-01') +EXPLAIN SELECT * FROM tbl_date WHERE d = '0000-01-01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` = DATE'0000-01-01') +EXPLAIN SELECT * FROM tbl_date WHERE d <> '0000-01-01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` <> DATE'0000-01-01') +SELECT * FROM tbl_date WHERE d < '2038-01-19'; +d +0000-01-01 +SELECT * FROM tbl_date WHERE d <= '2038-01-19'; +d +0000-01-01 +2038-01-19 +SELECT * FROM tbl_date WHERE d > '2038-01-19'; +d +9999-12-31 +SELECT * FROM tbl_date WHERE d >= '2038-01-19'; +d +2038-01-19 +9999-12-31 +SELECT * FROM tbl_date WHERE d = '2038-01-19'; +d +2038-01-19 +SELECT * FROM tbl_date WHERE d <> '2038-01-19'; +d +0000-01-01 +9999-12-31 +EXPLAIN SELECT * FROM tbl_date WHERE d < '2038-01-19'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` < DATE'2038-01-19') +EXPLAIN SELECT * FROM tbl_date WHERE d <= '2038-01-19'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` <= DATE'2038-01-19') +EXPLAIN SELECT * FROM tbl_date WHERE d > '2038-01-19'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` > DATE'2038-01-19') +EXPLAIN SELECT * FROM tbl_date WHERE d >= '2038-01-19'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` >= DATE'2038-01-19') +EXPLAIN SELECT * FROM tbl_date WHERE d = '2038-01-19'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` = DATE'2038-01-19') +EXPLAIN SELECT * FROM tbl_date WHERE d <> '2038-01-19'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` <> DATE'2038-01-19') +SELECT * FROM tbl_date WHERE d < '1000-01-01'; +d +0000-01-01 +SELECT * FROM tbl_date WHERE d <= '1000-01-01'; +d +0000-01-01 +SELECT * FROM tbl_date WHERE d > '1000-01-01'; +d +2038-01-19 +9999-12-31 +SELECT * FROM tbl_date WHERE d >= '1000-01-01'; +d +2038-01-19 +9999-12-31 +SELECT * FROM tbl_date WHERE d = '1000-01-01'; +d +SELECT * FROM tbl_date WHERE d <> '1000-01-01'; +d +0000-01-01 +2038-01-19 +9999-12-31 +EXPLAIN SELECT * FROM tbl_date WHERE d < '1000-01-01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` < DATE'1000-01-01') +EXPLAIN SELECT * FROM tbl_date WHERE d <= '1000-01-01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` <= DATE'1000-01-01') +EXPLAIN SELECT * FROM tbl_date WHERE d > '1000-01-01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` > DATE'1000-01-01') +EXPLAIN SELECT * FROM tbl_date WHERE d >= '1000-01-01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` >= DATE'1000-01-01') +EXPLAIN SELECT * FROM tbl_date WHERE d = '1000-01-01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` = DATE'1000-01-01') +EXPLAIN SELECT * FROM tbl_date WHERE d <> '1000-01-01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` <> DATE'1000-01-01') +SELECT * FROM tbl_date WHERE d < '9999-12-31'; +d +0000-01-01 +2038-01-19 +SELECT * FROM tbl_date WHERE d <= '9999-12-31'; +d +0000-01-01 +2038-01-19 +9999-12-31 +SELECT * FROM tbl_date WHERE d > '9999-12-31'; +d +SELECT * FROM tbl_date WHERE d >= '9999-12-31'; +d +9999-12-31 +SELECT * FROM tbl_date WHERE d = '9999-12-31'; +d +9999-12-31 +SELECT * FROM tbl_date WHERE d <> '9999-12-31'; +d +0000-01-01 +2038-01-19 +EXPLAIN SELECT * FROM tbl_date WHERE d < '9999-12-31'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` < DATE'9999-12-31') +EXPLAIN SELECT * FROM tbl_date WHERE d <= '9999-12-31'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` <= DATE'9999-12-31') +EXPLAIN SELECT * FROM tbl_date WHERE d > '9999-12-31'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` > DATE'9999-12-31') +EXPLAIN SELECT * FROM tbl_date WHERE d >= '9999-12-31'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` >= DATE'9999-12-31') +EXPLAIN SELECT * FROM tbl_date WHERE d = '9999-12-31'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` = DATE'9999-12-31') +EXPLAIN SELECT * FROM tbl_date WHERE d <> '9999-12-31'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` <> DATE'9999-12-31') +Compare to a full datetime value instead of a date +SELECT * FROM tbl_date WHERE d < '2038-01-19 12:45:00'; +d +0000-01-01 +2038-01-19 +SELECT * FROM tbl_date WHERE d <= '2038-01-19 12:45:00'; +d +0000-01-01 +2038-01-19 +SELECT * FROM tbl_date WHERE d > '2038-01-19 12:45:00'; +d +9999-12-31 +SELECT * FROM tbl_date WHERE d >= '2038-01-19 12:45:00'; +d +9999-12-31 +SELECT * FROM tbl_date WHERE d = '2038-01-19 12:45:00'; +d +SELECT * FROM tbl_date WHERE d <> '2038-01-19 12:45:00'; +d +0000-01-01 +2038-01-19 +9999-12-31 +EXPLAIN SELECT * FROM tbl_date WHERE d < '2038-01-19 12:45:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` <= DATE'2038-01-19') +EXPLAIN SELECT * FROM tbl_date WHERE d <= '2038-01-19 12:45:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` <= DATE'2038-01-19') +EXPLAIN SELECT * FROM tbl_date WHERE d > '2038-01-19 12:45:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` > DATE'2038-01-19') +EXPLAIN SELECT * FROM tbl_date WHERE d >= '2038-01-19 12:45:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` > DATE'2038-01-19') +EXPLAIN SELECT * FROM tbl_date WHERE d = '2038-01-19 12:45:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where false +EXPLAIN SELECT * FROM tbl_date WHERE d <> '2038-01-19 12:45:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` is not null) +Zero date? +SELECT * FROM tbl_date WHERE d < '0000-00-00'; +d +SELECT * FROM tbl_date WHERE d <= '0000-00-00'; +d +SELECT * FROM tbl_date WHERE d > '0000-00-00'; +d +0000-01-01 +2038-01-19 +9999-12-31 +SELECT * FROM tbl_date WHERE d >= '0000-00-00'; +d +0000-01-01 +2038-01-19 +9999-12-31 +SELECT * FROM tbl_date WHERE d = '0000-00-00'; +d +SELECT * FROM tbl_date WHERE d <> '0000-00-00'; +d +0000-01-01 +2038-01-19 +9999-12-31 +EXPLAIN SELECT * FROM tbl_date WHERE d < '0000-00-00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` < DATE'0000-00-00') +EXPLAIN SELECT * FROM tbl_date WHERE d <= '0000-00-00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` <= DATE'0000-00-00') +EXPLAIN SELECT * FROM tbl_date WHERE d > '0000-00-00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` > DATE'0000-00-00') +EXPLAIN SELECT * FROM tbl_date WHERE d >= '0000-00-00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` >= DATE'0000-00-00') +EXPLAIN SELECT * FROM tbl_date WHERE d = '0000-00-00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` = DATE'0000-00-00') +EXPLAIN SELECT * FROM tbl_date WHERE d <> '0000-00-00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` <> DATE'0000-00-00') +Zero in date +SELECT * FROM tbl_date WHERE d < '2018-00-03'; +d +0000-01-01 +SELECT * FROM tbl_date WHERE d <= '2018-00-03'; +d +0000-01-01 +SELECT * FROM tbl_date WHERE d > '2018-00-03'; +d +2038-01-19 +9999-12-31 +SELECT * FROM tbl_date WHERE d >= '2018-00-03'; +d +2038-01-19 +9999-12-31 +SELECT * FROM tbl_date WHERE d = '2018-00-03'; +d +SELECT * FROM tbl_date WHERE d <> '2018-00-03'; +d +0000-01-01 +2038-01-19 +9999-12-31 +EXPLAIN SELECT * FROM tbl_date WHERE d < '2018-00-03'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` < DATE'2018-00-03') +EXPLAIN SELECT * FROM tbl_date WHERE d <= '2018-00-03'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` <= DATE'2018-00-03') +EXPLAIN SELECT * FROM tbl_date WHERE d > '2018-00-03'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` > DATE'2018-00-03') +EXPLAIN SELECT * FROM tbl_date WHERE d >= '2018-00-03'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` >= DATE'2018-00-03') +EXPLAIN SELECT * FROM tbl_date WHERE d = '2018-00-03'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` = DATE'2018-00-03') +EXPLAIN SELECT * FROM tbl_date WHERE d <> '2018-00-03'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` <> DATE'2018-00-03') +Strangely, this does not give an error nor warning, and does +comparison using internal datetime comparison (pre-folding), so +we do the same. +SELECT * FROM tbl_date WHERE d < '2018-02-31'; +d +0000-01-01 +SELECT * FROM tbl_date WHERE d <= '2018-02-31'; +d +0000-01-01 +SELECT * FROM tbl_date WHERE d > '2018-02-31'; +d +2038-01-19 +9999-12-31 +SELECT * FROM tbl_date WHERE d >= '2018-02-31'; +d +2038-01-19 +9999-12-31 +SELECT * FROM tbl_date WHERE d = '2018-02-31'; +d +SELECT * FROM tbl_date WHERE d <> '2018-02-31'; +d +0000-01-01 +2038-01-19 +9999-12-31 +EXPLAIN SELECT * FROM tbl_date WHERE d < '2018-02-31'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` < DATE'2018-02-31') +EXPLAIN SELECT * FROM tbl_date WHERE d <= '2018-02-31'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` <= DATE'2018-02-31') +EXPLAIN SELECT * FROM tbl_date WHERE d > '2018-02-31'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` > DATE'2018-02-31') +EXPLAIN SELECT * FROM tbl_date WHERE d >= '2018-02-31'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` >= DATE'2018-02-31') +EXPLAIN SELECT * FROM tbl_date WHERE d = '2018-02-31'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` = DATE'2018-02-31') +EXPLAIN SELECT * FROM tbl_date WHERE d <> '2018-02-31'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` <> DATE'2018-02-31') + +2. TIMESTAMP literals compared with DATE field + +SELECT * FROM tbl_date WHERE d < TIMESTAMP'2038-01-19 00:00:00'; +d +0000-01-01 +SELECT * FROM tbl_date WHERE d <= TIMESTAMP'2038-01-19 00:00:00'; +d +0000-01-01 +2038-01-19 +SELECT * FROM tbl_date WHERE d > TIMESTAMP'2038-01-19 00:00:00'; +d +9999-12-31 +SELECT * FROM tbl_date WHERE d >= TIMESTAMP'2038-01-19 00:00:00'; +d +2038-01-19 +9999-12-31 +SELECT * FROM tbl_date WHERE d = TIMESTAMP'2038-01-19 00:00:00'; +d +2038-01-19 +SELECT * FROM tbl_date WHERE d <> TIMESTAMP'2038-01-19 00:00:00'; +d +0000-01-01 +9999-12-31 +EXPLAIN SELECT * FROM tbl_date WHERE d < TIMESTAMP'2038-01-19 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` < TIMESTAMP'2038-01-19 00:00:00') +EXPLAIN SELECT * FROM tbl_date WHERE d <= TIMESTAMP'2038-01-19 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` <= TIMESTAMP'2038-01-19 00:00:00') +EXPLAIN SELECT * FROM tbl_date WHERE d > TIMESTAMP'2038-01-19 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` > TIMESTAMP'2038-01-19 00:00:00') +EXPLAIN SELECT * FROM tbl_date WHERE d >= TIMESTAMP'2038-01-19 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` >= TIMESTAMP'2038-01-19 00:00:00') +EXPLAIN SELECT * FROM tbl_date WHERE d = TIMESTAMP'2038-01-19 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` = TIMESTAMP'2038-01-19 00:00:00') +EXPLAIN SELECT * FROM tbl_date WHERE d <> TIMESTAMP'2038-01-19 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` <> TIMESTAMP'2038-01-19 00:00:00') +SELECT * FROM tbl_date WHERE d < TIMESTAMP'2038-01-19 00:00:01'; +d +0000-01-01 +2038-01-19 +SELECT * FROM tbl_date WHERE d <= TIMESTAMP'2038-01-19 00:00:01'; +d +0000-01-01 +2038-01-19 +SELECT * FROM tbl_date WHERE d > TIMESTAMP'2038-01-19 00:00:01'; +d +9999-12-31 +SELECT * FROM tbl_date WHERE d >= TIMESTAMP'2038-01-19 00:00:01'; +d +9999-12-31 +SELECT * FROM tbl_date WHERE d = TIMESTAMP'2038-01-19 00:00:01'; +d +SELECT * FROM tbl_date WHERE d <> TIMESTAMP'2038-01-19 00:00:01'; +d +0000-01-01 +2038-01-19 +9999-12-31 +EXPLAIN SELECT * FROM tbl_date WHERE d < TIMESTAMP'2038-01-19 00:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` < TIMESTAMP'2038-01-19 00:00:01') +EXPLAIN SELECT * FROM tbl_date WHERE d <= TIMESTAMP'2038-01-19 00:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` <= TIMESTAMP'2038-01-19 00:00:01') +EXPLAIN SELECT * FROM tbl_date WHERE d > TIMESTAMP'2038-01-19 00:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` > TIMESTAMP'2038-01-19 00:00:01') +EXPLAIN SELECT * FROM tbl_date WHERE d >= TIMESTAMP'2038-01-19 00:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` >= TIMESTAMP'2038-01-19 00:00:01') +EXPLAIN SELECT * FROM tbl_date WHERE d = TIMESTAMP'2038-01-19 00:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` = TIMESTAMP'2038-01-19 00:00:01') +EXPLAIN SELECT * FROM tbl_date WHERE d <> TIMESTAMP'2038-01-19 00:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` <> TIMESTAMP'2038-01-19 00:00:01') + +3. Integer literals + +in range +SELECT * FROM tbl_date WHERE d < 20380119; +d +0000-01-01 +SELECT * FROM tbl_date WHERE d <= 20380119; +d +0000-01-01 +2038-01-19 +SELECT * FROM tbl_date WHERE d > 20380119; +d +9999-12-31 +SELECT * FROM tbl_date WHERE d >= 20380119; +d +2038-01-19 +9999-12-31 +SELECT * FROM tbl_date WHERE d = 20380119; +d +2038-01-19 +SELECT * FROM tbl_date WHERE d <> 20380119; +d +0000-01-01 +9999-12-31 +EXPLAIN SELECT * FROM tbl_date WHERE d < 20380119; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` < DATE'2038-01-19') +EXPLAIN SELECT * FROM tbl_date WHERE d <= 20380119; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` <= DATE'2038-01-19') +EXPLAIN SELECT * FROM tbl_date WHERE d > 20380119; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` > DATE'2038-01-19') +EXPLAIN SELECT * FROM tbl_date WHERE d >= 20380119; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` >= DATE'2038-01-19') +EXPLAIN SELECT * FROM tbl_date WHERE d = 20380119; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` = DATE'2038-01-19') +EXPLAIN SELECT * FROM tbl_date WHERE d <> 20380119; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` <> DATE'2038-01-19') +incorrect value; removes time part +SELECT * FROM tbl_date WHERE d < 20380119124500; +d +0000-01-01 +SELECT * FROM tbl_date WHERE d <= 20380119124500; +d +0000-01-01 +2038-01-19 +SELECT * FROM tbl_date WHERE d > 20380119124500; +d +9999-12-31 +SELECT * FROM tbl_date WHERE d >= 20380119124500; +d +2038-01-19 +9999-12-31 +SELECT * FROM tbl_date WHERE d = 20380119124500; +d +2038-01-19 +SELECT * FROM tbl_date WHERE d <> 20380119124500; +d +0000-01-01 +9999-12-31 +EXPLAIN SELECT * FROM tbl_date WHERE d < 20380119124500; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` < DATE'2038-01-19') +EXPLAIN SELECT * FROM tbl_date WHERE d <= 20380119124500; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` <= DATE'2038-01-19') +EXPLAIN SELECT * FROM tbl_date WHERE d > 20380119124500; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` > DATE'2038-01-19') +EXPLAIN SELECT * FROM tbl_date WHERE d >= 20380119124500; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` >= DATE'2038-01-19') +EXPLAIN SELECT * FROM tbl_date WHERE d = 20380119124500; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` = DATE'2038-01-19') +EXPLAIN SELECT * FROM tbl_date WHERE d <> 20380119124500; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` <> DATE'2038-01-19') +out of range; interpreted as a value smaller than TIMESTAMP min +SELECT * FROM tbl_date WHERE d < 2018; +d +0000-01-01 +Warnings: +Warning 1292 Incorrect date value: '2018' for column 'd' at row 1 +Warning 1292 Incorrect date value: '2018' for column 'd' at row 1 +Warning 1292 Incorrect date value: '2018' for column 'd' at row 1 +SELECT * FROM tbl_date WHERE d <= 2018; +d +0000-01-01 +Warnings: +Warning 1292 Incorrect date value: '2018' for column 'd' at row 1 +Warning 1292 Incorrect date value: '2018' for column 'd' at row 1 +Warning 1292 Incorrect date value: '2018' for column 'd' at row 1 +SELECT * FROM tbl_date WHERE d > 2018; +d +2038-01-19 +9999-12-31 +Warnings: +Warning 1292 Incorrect date value: '2018' for column 'd' at row 1 +Warning 1292 Incorrect date value: '2018' for column 'd' at row 1 +Warning 1292 Incorrect date value: '2018' for column 'd' at row 1 +SELECT * FROM tbl_date WHERE d >= 2018; +d +2038-01-19 +9999-12-31 +Warnings: +Warning 1292 Incorrect date value: '2018' for column 'd' at row 1 +Warning 1292 Incorrect date value: '2018' for column 'd' at row 1 +Warning 1292 Incorrect date value: '2018' for column 'd' at row 1 +SELECT * FROM tbl_date WHERE d = 2018; +d +Warnings: +Warning 1292 Incorrect date value: '2018' for column 'd' at row 1 +Warning 1292 Incorrect date value: '2018' for column 'd' at row 1 +Warning 1292 Incorrect date value: '2018' for column 'd' at row 1 +SELECT * FROM tbl_date WHERE d <> 2018; +d +0000-01-01 +2038-01-19 +9999-12-31 +Warnings: +Warning 1292 Incorrect date value: '2018' for column 'd' at row 1 +Warning 1292 Incorrect date value: '2018' for column 'd' at row 1 +Warning 1292 Incorrect date value: '2018' for column 'd' at row 1 +EXPLAIN SELECT * FROM tbl_date WHERE d < 2018; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Warning 1292 Incorrect date value: '2018' for column 'd' at row 1 +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` < 2018) +EXPLAIN SELECT * FROM tbl_date WHERE d <= 2018; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Warning 1292 Incorrect date value: '2018' for column 'd' at row 1 +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` <= 2018) +EXPLAIN SELECT * FROM tbl_date WHERE d > 2018; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Warning 1292 Incorrect date value: '2018' for column 'd' at row 1 +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` > 2018) +EXPLAIN SELECT * FROM tbl_date WHERE d >= 2018; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Warning 1292 Incorrect date value: '2018' for column 'd' at row 1 +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` >= 2018) +EXPLAIN SELECT * FROM tbl_date WHERE d = 2018; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Warning 1292 Incorrect date value: '2018' for column 'd' at row 1 +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` = 2018) +EXPLAIN SELECT * FROM tbl_date WHERE d <> 2018; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Warning 1292 Incorrect date value: '2018' for column 'd' at row 1 +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` <> 2018) +SELECT * FROM tbl_date WHERE d < 0; +d +SELECT * FROM tbl_date WHERE d <= 0; +d +SELECT * FROM tbl_date WHERE d > 0; +d +0000-01-01 +2038-01-19 +9999-12-31 +SELECT * FROM tbl_date WHERE d >= 0; +d +0000-01-01 +2038-01-19 +9999-12-31 +SELECT * FROM tbl_date WHERE d = 0; +d +SELECT * FROM tbl_date WHERE d <> 0; +d +0000-01-01 +2038-01-19 +9999-12-31 +EXPLAIN SELECT * FROM tbl_date WHERE d < 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` < DATE'0000-00-00') +EXPLAIN SELECT * FROM tbl_date WHERE d <= 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` <= DATE'0000-00-00') +EXPLAIN SELECT * FROM tbl_date WHERE d > 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` > DATE'0000-00-00') +EXPLAIN SELECT * FROM tbl_date WHERE d >= 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` >= DATE'0000-00-00') +EXPLAIN SELECT * FROM tbl_date WHERE d = 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` = DATE'0000-00-00') +EXPLAIN SELECT * FROM tbl_date WHERE d <> 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` <> DATE'0000-00-00') + +3. Decimal literals + +SELECT * FROM tbl_date WHERE d < 20380119.00; +d +0000-01-01 +SELECT * FROM tbl_date WHERE d <= 20380119.00; +d +0000-01-01 +2038-01-19 +SELECT * FROM tbl_date WHERE d > 20380119.00; +d +9999-12-31 +SELECT * FROM tbl_date WHERE d >= 20380119.00; +d +2038-01-19 +9999-12-31 +SELECT * FROM tbl_date WHERE d = 20380119.00; +d +2038-01-19 +SELECT * FROM tbl_date WHERE d <> 20380119.00; +d +0000-01-01 +9999-12-31 +EXPLAIN SELECT * FROM tbl_date WHERE d < 20380119.00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` < DATE'2038-01-19') +EXPLAIN SELECT * FROM tbl_date WHERE d <= 20380119.00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` <= DATE'2038-01-19') +EXPLAIN SELECT * FROM tbl_date WHERE d > 20380119.00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` > DATE'2038-01-19') +EXPLAIN SELECT * FROM tbl_date WHERE d >= 20380119.00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` >= DATE'2038-01-19') +EXPLAIN SELECT * FROM tbl_date WHERE d = 20380119.00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` = DATE'2038-01-19') +EXPLAIN SELECT * FROM tbl_date WHERE d <> 20380119.00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` <> DATE'2038-01-19') +incorrect value; removes time part +SELECT * FROM tbl_date WHERE d < 20380119061405.00; +d +0000-01-01 +SELECT * FROM tbl_date WHERE d <= 20380119061405.00; +d +0000-01-01 +2038-01-19 +SELECT * FROM tbl_date WHERE d > 20380119061405.00; +d +9999-12-31 +SELECT * FROM tbl_date WHERE d >= 20380119061405.00; +d +2038-01-19 +9999-12-31 +SELECT * FROM tbl_date WHERE d = 20380119061405.00; +d +2038-01-19 +SELECT * FROM tbl_date WHERE d <> 20380119061405.00; +d +0000-01-01 +9999-12-31 +EXPLAIN SELECT * FROM tbl_date WHERE d < 20380119061405.00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` < DATE'2038-01-19') +EXPLAIN SELECT * FROM tbl_date WHERE d <= 20380119061405.00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` <= DATE'2038-01-19') +EXPLAIN SELECT * FROM tbl_date WHERE d > 20380119061405.00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` > DATE'2038-01-19') +EXPLAIN SELECT * FROM tbl_date WHERE d >= 20380119061405.00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` >= DATE'2038-01-19') +EXPLAIN SELECT * FROM tbl_date WHERE d = 20380119061405.00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` = DATE'2038-01-19') +EXPLAIN SELECT * FROM tbl_date WHERE d <> 20380119061405.00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` <> DATE'2038-01-19') +out of range - compare using double +SELECT * FROM tbl_date WHERE d < 2018.55; +d +0000-01-01 +Warnings: +Warning 1292 Incorrect date value: '2018.55' for column 'd' at row 1 +Warning 1292 Incorrect date value: '2018.55' for column 'd' at row 1 +Warning 1292 Incorrect date value: '2018.55' for column 'd' at row 1 +SELECT * FROM tbl_date WHERE d <= 2018.55; +d +0000-01-01 +Warnings: +Warning 1292 Incorrect date value: '2018.55' for column 'd' at row 1 +Warning 1292 Incorrect date value: '2018.55' for column 'd' at row 1 +Warning 1292 Incorrect date value: '2018.55' for column 'd' at row 1 +SELECT * FROM tbl_date WHERE d > 2018.55; +d +2038-01-19 +9999-12-31 +Warnings: +Warning 1292 Incorrect date value: '2018.55' for column 'd' at row 1 +Warning 1292 Incorrect date value: '2018.55' for column 'd' at row 1 +Warning 1292 Incorrect date value: '2018.55' for column 'd' at row 1 +SELECT * FROM tbl_date WHERE d >= 2018.55; +d +2038-01-19 +9999-12-31 +Warnings: +Warning 1292 Incorrect date value: '2018.55' for column 'd' at row 1 +Warning 1292 Incorrect date value: '2018.55' for column 'd' at row 1 +Warning 1292 Incorrect date value: '2018.55' for column 'd' at row 1 +SELECT * FROM tbl_date WHERE d = 2018.55; +d +Warnings: +Warning 1292 Incorrect date value: '2018.55' for column 'd' at row 1 +Warning 1292 Incorrect date value: '2018.55' for column 'd' at row 1 +Warning 1292 Incorrect date value: '2018.55' for column 'd' at row 1 +SELECT * FROM tbl_date WHERE d <> 2018.55; +d +0000-01-01 +2038-01-19 +9999-12-31 +Warnings: +Warning 1292 Incorrect date value: '2018.55' for column 'd' at row 1 +Warning 1292 Incorrect date value: '2018.55' for column 'd' at row 1 +Warning 1292 Incorrect date value: '2018.55' for column 'd' at row 1 +EXPLAIN SELECT * FROM tbl_date WHERE d < 2018.55; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Warning 1292 Incorrect date value: '2018.55' for column 'd' at row 1 +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` < 2018.55) +EXPLAIN SELECT * FROM tbl_date WHERE d <= 2018.55; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Warning 1292 Incorrect date value: '2018.55' for column 'd' at row 1 +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` <= 2018.55) +EXPLAIN SELECT * FROM tbl_date WHERE d > 2018.55; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Warning 1292 Incorrect date value: '2018.55' for column 'd' at row 1 +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` > 2018.55) +EXPLAIN SELECT * FROM tbl_date WHERE d >= 2018.55; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Warning 1292 Incorrect date value: '2018.55' for column 'd' at row 1 +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` >= 2018.55) +EXPLAIN SELECT * FROM tbl_date WHERE d = 2018.55; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Warning 1292 Incorrect date value: '2018.55' for column 'd' at row 1 +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` = 2018.55) +EXPLAIN SELECT * FROM tbl_date WHERE d <> 2018.55; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Warning 1292 Incorrect date value: '2018.55' for column 'd' at row 1 +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` <> 2018.55) +SELECT * FROM tbl_date WHERE d < 0.00; +d +SELECT * FROM tbl_date WHERE d <= 0.00; +d +SELECT * FROM tbl_date WHERE d > 0.00; +d +0000-01-01 +2038-01-19 +9999-12-31 +SELECT * FROM tbl_date WHERE d >= 0.00; +d +0000-01-01 +2038-01-19 +9999-12-31 +SELECT * FROM tbl_date WHERE d = 0.00; +d +SELECT * FROM tbl_date WHERE d <> 0.00; +d +0000-01-01 +2038-01-19 +9999-12-31 +EXPLAIN SELECT * FROM tbl_date WHERE d < 0.00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` < DATE'0000-00-00') +EXPLAIN SELECT * FROM tbl_date WHERE d <= 0.00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` <= DATE'0000-00-00') +EXPLAIN SELECT * FROM tbl_date WHERE d > 0.00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` > DATE'0000-00-00') +EXPLAIN SELECT * FROM tbl_date WHERE d >= 0.00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` >= DATE'0000-00-00') +EXPLAIN SELECT * FROM tbl_date WHERE d = 0.00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` = DATE'0000-00-00') +EXPLAIN SELECT * FROM tbl_date WHERE d <> 0.00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` <> DATE'0000-00-00') + +3. Real literals: rounded up to whole seconds + +in range +SELECT * FROM tbl_date WHERE d < 20380119E00; +d +0000-01-01 +SELECT * FROM tbl_date WHERE d <= 20380119E00; +d +0000-01-01 +2038-01-19 +SELECT * FROM tbl_date WHERE d > 20380119E00; +d +9999-12-31 +SELECT * FROM tbl_date WHERE d >= 20380119E00; +d +2038-01-19 +9999-12-31 +SELECT * FROM tbl_date WHERE d = 20380119E00; +d +2038-01-19 +SELECT * FROM tbl_date WHERE d <> 20380119E00; +d +0000-01-01 +9999-12-31 +EXPLAIN SELECT * FROM tbl_date WHERE d < 20380119E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` < DATE'2038-01-19') +EXPLAIN SELECT * FROM tbl_date WHERE d <= 20380119E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` <= DATE'2038-01-19') +EXPLAIN SELECT * FROM tbl_date WHERE d > 20380119E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` > DATE'2038-01-19') +EXPLAIN SELECT * FROM tbl_date WHERE d >= 20380119E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` >= DATE'2038-01-19') +EXPLAIN SELECT * FROM tbl_date WHERE d = 20380119E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` = DATE'2038-01-19') +EXPLAIN SELECT * FROM tbl_date WHERE d <> 20380119E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` <> DATE'2038-01-19') +incorrect value; removes time part +SELECT * FROM tbl_date WHERE d < 20380119194500E00; +d +0000-01-01 +SELECT * FROM tbl_date WHERE d <= 20380119194500E00; +d +0000-01-01 +2038-01-19 +SELECT * FROM tbl_date WHERE d > 20380119194500E00; +d +9999-12-31 +SELECT * FROM tbl_date WHERE d >= 20380119194500E00; +d +2038-01-19 +9999-12-31 +SELECT * FROM tbl_date WHERE d = 20380119194500E00; +d +2038-01-19 +SELECT * FROM tbl_date WHERE d <> 20380119194500E00; +d +0000-01-01 +9999-12-31 +EXPLAIN SELECT * FROM tbl_date WHERE d < 20380119194500E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` < DATE'2038-01-19') +EXPLAIN SELECT * FROM tbl_date WHERE d <= 20380119194500E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` <= DATE'2038-01-19') +EXPLAIN SELECT * FROM tbl_date WHERE d > 20380119194500E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` > DATE'2038-01-19') +EXPLAIN SELECT * FROM tbl_date WHERE d >= 20380119194500E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` >= DATE'2038-01-19') +EXPLAIN SELECT * FROM tbl_date WHERE d = 20380119194500E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` = DATE'2038-01-19') +EXPLAIN SELECT * FROM tbl_date WHERE d <> 20380119194500E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` <> DATE'2038-01-19') +out of range compare using double +SELECT * FROM tbl_date WHERE d < 0.00E00; +d +SELECT * FROM tbl_date WHERE d <= 0.00E00; +d +SELECT * FROM tbl_date WHERE d > 0.00E00; +d +0000-01-01 +2038-01-19 +9999-12-31 +SELECT * FROM tbl_date WHERE d >= 0.00E00; +d +0000-01-01 +2038-01-19 +9999-12-31 +SELECT * FROM tbl_date WHERE d = 0.00E00; +d +SELECT * FROM tbl_date WHERE d <> 0.00E00; +d +0000-01-01 +2038-01-19 +9999-12-31 +EXPLAIN SELECT * FROM tbl_date WHERE d < 0.00E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` < DATE'0000-00-00') +EXPLAIN SELECT * FROM tbl_date WHERE d <= 0.00E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` <= DATE'0000-00-00') +EXPLAIN SELECT * FROM tbl_date WHERE d > 0.00E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` > DATE'0000-00-00') +EXPLAIN SELECT * FROM tbl_date WHERE d >= 0.00E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` >= DATE'0000-00-00') +EXPLAIN SELECT * FROM tbl_date WHERE d = 0.00E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` = DATE'0000-00-00') +EXPLAIN SELECT * FROM tbl_date WHERE d <> 0.00E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` <> DATE'0000-00-00') +DROP TABLE tbl_date; +SET SESSION sql_mode = DEFAULT; +CREATE TABLE t(t TIME); +INSERT INTO t VALUES ('18:00:00'); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +SELECT * FROM t WHERE t = '18:00:00'; +t +18:00:00 +SELECT * FROM t WHERE t = '18:00:00.001'; +t +18:00:00 +SELECT * FROM t WHERE t = 180000; +t +18:00:00 +SELECT * FROM t WHERE t = 180000.001; +t +18:00:00 +SELECT * FROM t WHERE t = 'abra cadabra'; +t +Warnings: +Warning 1292 Incorrect time value: 'abra cadabra' for column 't' at row 1 +Warning 1292 Incorrect time value: 'abra cadabra' for column 't' at row 1 +Warning 1292 Incorrect time value: 'abra cadabra' for column 't' at row 1 +Note: for explicit TIME literal, the fraction part is not truncated +This is existing behavior, not changed for WL#11935. +SELECT * FROM t WHERE t = TIME'180000.001'; +t +EXPLAIN SELECT * FROM t WHERE t = '18:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`t` AS `t` from `test`.`t` where (`test`.`t`.`t` = TIME'18:00:00') +EXPLAIN SELECT * FROM t WHERE t = '18:00:00.001'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`t` AS `t` from `test`.`t` where (`test`.`t`.`t` = TIME'18:00:00') +EXPLAIN SELECT * FROM t WHERE t = 180000; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`t` AS `t` from `test`.`t` where (`test`.`t`.`t` = TIME'18:00:00') +EXPLAIN SELECT * FROM t WHERE t = 180000.001; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`t` AS `t` from `test`.`t` where (`test`.`t`.`t` = TIME'18:00:00') +EXPLAIN SELECT * FROM t WHERE t = TIME'180000.001'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`t` AS `t` from `test`.`t` where (`test`.`t`.`t` = TIME'18:00:00.001') +EXPLAIN SELECT * FROM t WHERE t = 'abra cadabra'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Warning 1292 Incorrect time value: 'abra cadabra' for column 't' at row 1 +Note 1003 /* select#1 */ select `test`.`t`.`t` AS `t` from `test`.`t` where (`test`.`t`.`t` = 'abra cadabra') +EXPLAIN SELECT * FROM t WHERE t = 3.14E44; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Warning 1292 Incorrect time value: '3.14e44' for column 't' at row 1 +Note 1003 /* select#1 */ select `test`.`t`.`t` AS `t` from `test`.`t` where (`test`.`t`.`t` = 3.14E44) +EXPLAIN SELECT * FROM t WHERE t = 30000000000000000.3567; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Warning 1292 Incorrect time value: '30000000000000000.3567' for column 't' at row 1 +Note 1003 /* select#1 */ select `test`.`t`.`t` AS `t` from `test`.`t` where (`test`.`t`.`t` = 30000000000000000.3567) +DROP TABLE t; +CREATE TABLE t(i TINYINT NOT NULL, j TINYINT NOT NULL); +INSERT INTO t VALUES (1,1), (1,2), (2,1), (2,2); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +Should fold to TRUE +SELECT SUM(i) s, j FROM t WHERE j != 128 GROUP BY j; +s j +3 1 +3 2 +EXPLAIN SELECT SUM(i) s, j FROM t WHERE j != 128 GROUP BY j; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 4 100.00 Using temporary +Warnings: +Note 1003 /* select#1 */ select sum(`test`.`t`.`i`) AS `s`,`test`.`t`.`j` AS `j` from `test`.`t` where true group by `test`.`t`.`j` +SELECT SUM(i) s, j FROM t WHERE j != 128 GROUP BY j WITH ROLLUP; +s j +3 1 +3 2 +6 NULL +EXPLAIN SELECT SUM(i) s, j FROM t WHERE j != 128 GROUP BY j WITH ROLLUP; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL ALL NULL NULL NULL NULL 4 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select rollup_sum_switcher(sum(`test`.`t`.`i`)) AS `s`,rollup_group_item(`test`.`t`.`j`,0) AS `j` from `test`.`t` where true group by `test`.`t`.`j` with rollup +SELECT SUM(i) s, j FROM t GROUP BY j HAVING j != 128; +s j +3 1 +3 2 +EXPLAIN SELECT SUM(i) s, j FROM t GROUP BY j HAVING j != 128; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 4 100.00 Using temporary +Warnings: +Note 1003 /* select#1 */ select sum(`test`.`t`.`i`) AS `s`,`test`.`t`.`j` AS `j` from `test`.`t` group by `test`.`t`.`j` having true +Should fold to IS NOT NULL +SELECT SUM(i) s, j FROM t GROUP BY j WITH ROLLUP HAVING j != 128; +s j +3 1 +3 2 +EXPLAIN SELECT SUM(i) s, j FROM t GROUP BY j WITH ROLLUP HAVING j != 128; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL ALL NULL NULL NULL NULL 4 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select rollup_sum_switcher(sum(`test`.`t`.`i`)) AS `s`,rollup_group_item(`test`.`t`.`j`,0) AS `j` from `test`.`t` group by `test`.`t`.`j` with rollup having (rollup_group_item(rollup_group_item(`test`.`t`.`j`,0),0) <> 128) +SELECT SUM(i) s, j FROM t GROUP BY j WITH ROLLUP HAVING j IS NOT NULL; +s j +3 1 +3 2 +EXPLAIN SELECT SUM(i) s, j FROM t GROUP BY j WITH ROLLUP HAVING j IS NOT NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL ALL NULL NULL NULL NULL 4 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select rollup_sum_switcher(sum(`test`.`t`.`i`)) AS `s`,rollup_group_item(`test`.`t`.`j`,0) AS `j` from `test`.`t` group by `test`.`t`.`j` with rollup having (rollup_group_item(rollup_group_item(`test`.`t`.`j`,0),0) is not null) +DROP TABLE t; +CREATE TABLE a(col_int INT, col_date DATE); +SELECT col_date FROM a WHERE +(NULL, NULL) IN (SELECT col_date, col_date FROM a) OR +(col_int <> 'C') ; +col_date +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'C' +DROP TABLE a; +CREATE TABLE t11 (col_time TIME); +INSERT INTO t11 VALUES('11:00:00'); +An integer value that could not be converted into a TIME literal +should default to old behavior (comparing as double). +EXPLAIN SELECT col_time FROM t11 HAVING col_time > 156970; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t11 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Warning 1292 Incorrect time value: '156970' for column 'col_time' at row 1 +Note 1003 /* select#1 */ select `test`.`t11`.`col_time` AS `col_time` from `test`.`t11` having (`test`.`t11`.`col_time` > 156970) +SELECT col_time FROM t11 HAVING col_time > 156970; +col_time +Warnings: +Warning 1292 Incorrect time value: '156970' for column 'col_time' at row 1 +Warning 1292 Incorrect time value: '156970' for column 'col_time' at row 1 +Warning 1292 Incorrect time value: '156970' for column 'col_time' at row 1 +EXPLAIN SELECT col_time FROM t11 WHERE col_time > 156970; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t11 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Warning 1292 Incorrect time value: '156970' for column 'col_time' at row 1 +Note 1003 /* select#1 */ select `test`.`t11`.`col_time` AS `col_time` from `test`.`t11` where (`test`.`t11`.`col_time` > 156970) +SELECT col_time FROM t11 WHERE col_time > 156970; +col_time +Warnings: +Warning 1292 Incorrect time value: '156970' for column 'col_time' at row 1 +Warning 1292 Incorrect time value: '156970' for column 'col_time' at row 1 +Warning 1292 Incorrect time value: '156970' for column 'col_time' at row 1 +EXPLAIN SELECT col_time FROM t11 WHERE col_time < 156970; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t11 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Warning 1292 Incorrect time value: '156970' for column 'col_time' at row 1 +Note 1003 /* select#1 */ select `test`.`t11`.`col_time` AS `col_time` from `test`.`t11` where (`test`.`t11`.`col_time` < 156970) +SELECT col_time FROM t11 WHERE col_time < 156970; +col_time +11:00:00 +Warnings: +Warning 1292 Incorrect time value: '156970' for column 'col_time' at row 1 +Warning 1292 Incorrect time value: '156970' for column 'col_time' at row 1 +Warning 1292 Incorrect time value: '156970' for column 'col_time' at row 1 +DROP TABLE t11; +CREATE TABLE t1(d DOUBLE); +INSERT INTO t1 VALUES (3.3); +CREATE TABLE t2 (ts TIMESTAMP); +INSERT INTO t2 VALUES ('2018-09-15 11:00:25.00'); +WITH RECURSIVE +cte1 AS ( SELECT ts AS a1 FROM t2 ), +cte2 AS ( SELECT LAST_DAY(18446744073709551615+1) AS a2 FROM t1 ) +SELECT * FROM cte1, cte2 WHERE cte1.a1 <> cte2.a2; +ERROR 22003: BIGINT UNSIGNED value is out of range in '(18446744073709551615 + 1)' +DROP TABLE t1, t2; +CREATE TABLE t(c DECIMAL(9,3)); +SELECT * FROM t WHERE c <=> 8106.000000; +c +EXPLAIN SELECT * from t WHERE c <=> 8106.000000; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`c` AS `c` from `test`.`t` where (`test`.`t`.`c` <=> 8106.000) +DROP TABLE t; +CREATE TABLE t0(c0 TINYINT); +INSERT INTO t0(c0) VALUES(NULL); +SELECT * FROM t0 WHERE NOT(t0.c0 <=> 2035382037); +c0 +NULL +SELECT * FROM t0 WHERE t0.c0 <=> 2035382037; +c0 +DROP TABLE t0; +CREATE TABLE t0(c0 INT); +INSERT INTO t0(c0) VALUES (0); +SELECT * FROM t0 WHERE 0.9 > t0.c0; +c0 +0 +DROP TABLE t0; diff --git a/mysql-test/r/create.result-pq b/mysql-test/r/create.result-pq new file mode 100644 index 000000000000..f9c11d0d2986 --- /dev/null +++ b/mysql-test/r/create.result-pq @@ -0,0 +1,3065 @@ +SET sql_mode = 'NO_ENGINE_SUBSTITUTION'; +drop table if exists t1,t2,t3,t4,t5; +drop database if exists mysqltest; +drop view if exists v1; +create table t1 (b char(0)); +insert into t1 values (""),(null); +select * from t1; +b + +NULL +drop table if exists t1; +create table t1 (b char(0) not null); +create table if not exists t1 (b char(0) not null); +Warnings: +Note 1050 Table 't1' already exists +insert into t1 values (""),(null); +Warnings: +Warning 1048 Column 'b' cannot be null +select * from t1; +b + + +drop table t1; +create table t1 (a int not null auto_increment,primary key (a)) engine=heap; +drop table t1; +create table t2 engine=heap select * from t1; +ERROR 42S02: Table 'test.t1' doesn't exist +create table t2 select auto+1 from t1; +ERROR 42S02: Table 'test.t1' doesn't exist +drop table if exists t1,t2; +Warnings: +Note 1051 Unknown table 'test.t1' +Note 1051 Unknown table 'test.t2' +create table t1 (b char(0) not null, index(b)); +ERROR 42000: The used storage engine can't index column 'b' +create table t1 (a int not null,b text) engine=heap; +ERROR 42000: The used table type doesn't support BLOB/TEXT columns +drop table if exists t1; +Warnings: +Note 1051 Unknown table 'test.t1' +create table t1 (ordid int(8) not null auto_increment, ord varchar(50) not null, primary key (ord,ordid)) engine=heap; +ERROR 42000: Incorrect table definition; there can be only one auto column and it must be defined as a key +create table not_existing_database.test (a int); +ERROR 42000: Unknown database 'not_existing_database' +create temporary table not_existing_database.test (a int); +ERROR 42000: Unknown database 'not_existing_database' +create table `a/a` (a int); +show create table `a/a`; +Table Create Table +a/a CREATE TABLE `a/a` ( + `a` int DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +create table t1 like `a/a`; +drop table `a/a`; +drop table `t1`; +create table `aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa` (aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa int); +ERROR 42000: Identifier name 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' is too long +create table a (`aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa` int); +ERROR 42000: Identifier name 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' is too long +create table t1 (a int default 100 auto_increment); +ERROR 42000: Invalid default value for 'a' +create table t1 (a tinyint default 1000); +ERROR 42000: Invalid default value for 'a' +create table t1 (a varchar(5) default 'abcdef'); +ERROR 42000: Invalid default value for 'a' +create table t1 (a varchar(5) default 'abcde'); +insert into t1 values(); +select * from t1; +a +abcde +alter table t1 alter column a set default 'abcdef'; +ERROR 42000: Invalid default value for 'a' +drop table t1; +create table 1ea10 (1a20 int,1e int); +insert into 1ea10 values(1,1); +select 1ea10.1a20,1e+ 1e+10 from 1ea10; +1a20 1e+ 1e+10 +1 10000000001 +drop table 1ea10; +create table t1 (`index` int); +drop table t1; +drop database if exists mysqltest; +Warnings: +Note 1008 Can't drop database 'mysqltest'; database doesn't exist +create database mysqltest; +create table mysqltest.$test1 (a$1 int, $b int, c$ int); +insert into mysqltest.$test1 values (1,2,3); +select a$1, $b, c$ from mysqltest.$test1; +a$1 $b c$ +1 2 3 +create table mysqltest.test2$ (a int); +drop table mysqltest.test2$; +drop database mysqltest; +create table `` (a int); +ERROR 42000: Incorrect table name '' +drop table if exists ``; +ERROR 42000: Incorrect table name '' +create table t1 (`` int); +ERROR 42000: Incorrect column name '' +create table t1 (i int, index `` (i)); +ERROR 42000: Incorrect index name '' +create table t1 (i int); +lock tables t1 read; +create table t2 (j int); +ERROR HY000: Table 't2' was not locked with LOCK TABLES +create temporary table t2 (j int); +drop temporary table t2; +unlock tables; +drop table t1; +create table t1 (a int auto_increment not null primary key, B CHAR(20)); +insert into t1 (b) values ("hello"),("my"),("world"); +create table t2 (key (b)) select * from t1; +explain select * from t2 where b="world"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ref B B 81 const 1 100.00 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`B` AS `B` from `test`.`t2` where (`test`.`t2`.`B` = 'world') +select * from t2 where b="world"; +a B +3 world +drop table t1,t2; +create table t1(x varchar(50) ); +create table t2 select x from t1 where 1=2; +describe t1; +Field Type Null Key Default Extra +x varchar(50) YES NULL +describe t2; +Field Type Null Key Default Extra +x varchar(50) YES NULL +drop table t2; +create table t2 select now() as a , curtime() as b, curdate() as c , 1+1 as d , 1.0 + 1 as e , 33333333333333333 + 3 as f; +describe t2; +Field Type Null Key Default Extra +a datetime NO 0000-00-00 00:00:00 +b time NO 00:00:00 +c date NO 0000-00-00 +d int NO 0 +e decimal(3,1) NO 0.0 +f bigint NO 0 +drop table t2; +create table t2 select CAST("2001-12-29" AS DATE) as d, CAST("20:45:11" AS TIME) as t, CAST("2001-12-29 20:45:11" AS DATETIME) as dt; +describe t2; +Field Type Null Key Default Extra +d date YES NULL +t time YES NULL +dt datetime YES NULL +drop table t1,t2; +create table t1 (a tinyint); +create table t2 (a int) select * from t1; +describe t1; +Field Type Null Key Default Extra +a tinyint YES NULL +describe t2; +Field Type Null Key Default Extra +a int YES NULL +drop table if exists t2; +create table t2 (a int, a float) select * from t1; +ERROR 42S21: Duplicate column name 'a' +drop table if exists t2; +Warnings: +Note 1051 Unknown table 'test.t2' +create table t2 (a int) select a as b, a+1 as b from t1; +ERROR 42S21: Duplicate column name 'b' +drop table if exists t2; +Warnings: +Note 1051 Unknown table 'test.t2' +create table t2 (b int) select a as b, a+1 as b from t1; +ERROR 42S21: Duplicate column name 'b' +drop table if exists t1,t2; +Warnings: +Note 1051 Unknown table 'test.t2' +CREATE TABLE t1 (a int not null); +INSERT INTO t1 values (1),(2),(1); +CREATE TABLE t2 (primary key(a)) SELECT * FROM t1; +ERROR 23000: Duplicate entry '1' for key 't2.PRIMARY' +SELECT * from t2; +ERROR 42S02: Table 'test.t2' doesn't exist +DROP TABLE t1; +DROP TABLE IF EXISTS t2; +Warnings: +Note 1051 Unknown table 'test.t2' +create table t1 (a int not null, b int, primary key(a), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b)); +Warnings: +Warning 1831 Duplicate index 'b_2' defined on the table 'test.t1'. This is deprecated and will be disallowed in a future release. +Warning 1831 Duplicate index 'b_3' defined on the table 'test.t1'. This is deprecated and will be disallowed in a future release. +Warning 1831 Duplicate index 'b_4' defined on the table 'test.t1'. This is deprecated and will be disallowed in a future release. +Warning 1831 Duplicate index 'b_5' defined on the table 'test.t1'. This is deprecated and will be disallowed in a future release. +Warning 1831 Duplicate index 'b_6' defined on the table 'test.t1'. This is deprecated and will be disallowed in a future release. +Warning 1831 Duplicate index 'b_7' defined on the table 'test.t1'. This is deprecated and will be disallowed in a future release. +Warning 1831 Duplicate index 'b_8' defined on the table 'test.t1'. This is deprecated and will be disallowed in a future release. +Warning 1831 Duplicate index 'b_9' defined on the table 'test.t1'. This is deprecated and will be disallowed in a future release. +Warning 1831 Duplicate index 'b_10' defined on the table 'test.t1'. This is deprecated and will be disallowed in a future release. +Warning 1831 Duplicate index 'b_11' defined on the table 'test.t1'. This is deprecated and will be disallowed in a future release. +Warning 1831 Duplicate index 'b_12' defined on the table 'test.t1'. This is deprecated and will be disallowed in a future release. +Warning 1831 Duplicate index 'b_13' defined on the table 'test.t1'. This is deprecated and will be disallowed in a future release. +Warning 1831 Duplicate index 'b_14' defined on the table 'test.t1'. This is deprecated and will be disallowed in a future release. +Warning 1831 Duplicate index 'b_15' defined on the table 'test.t1'. This is deprecated and will be disallowed in a future release. +Warning 1831 Duplicate index 'b_16' defined on the table 'test.t1'. This is deprecated and will be disallowed in a future release. +Warning 1831 Duplicate index 'b_17' defined on the table 'test.t1'. This is deprecated and will be disallowed in a future release. +Warning 1831 Duplicate index 'b_18' defined on the table 'test.t1'. This is deprecated and will be disallowed in a future release. +Warning 1831 Duplicate index 'b_19' defined on the table 'test.t1'. This is deprecated and will be disallowed in a future release. +Warning 1831 Duplicate index 'b_20' defined on the table 'test.t1'. This is deprecated and will be disallowed in a future release. +Warning 1831 Duplicate index 'b_21' defined on the table 'test.t1'. This is deprecated and will be disallowed in a future release. +Warning 1831 Duplicate index 'b_22' defined on the table 'test.t1'. This is deprecated and will be disallowed in a future release. +Warning 1831 Duplicate index 'b_23' defined on the table 'test.t1'. This is deprecated and will be disallowed in a future release. +Warning 1831 Duplicate index 'b_24' defined on the table 'test.t1'. This is deprecated and will be disallowed in a future release. +Warning 1831 Duplicate index 'b_25' defined on the table 'test.t1'. This is deprecated and will be disallowed in a future release. +Warning 1831 Duplicate index 'b_26' defined on the table 'test.t1'. This is deprecated and will be disallowed in a future release. +Warning 1831 Duplicate index 'b_27' defined on the table 'test.t1'. This is deprecated and will be disallowed in a future release. +Warning 1831 Duplicate index 'b_28' defined on the table 'test.t1'. This is deprecated and will be disallowed in a future release. +Warning 1831 Duplicate index 'b_29' defined on the table 'test.t1'. This is deprecated and will be disallowed in a future release. +Warning 1831 Duplicate index 'b_30' defined on the table 'test.t1'. This is deprecated and will be disallowed in a future release. +Warning 1831 Duplicate index 'b_31' defined on the table 'test.t1'. This is deprecated and will be disallowed in a future release. +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int NOT NULL, + `b` int DEFAULT NULL, + PRIMARY KEY (`a`), + KEY `b` (`b`), + KEY `b_2` (`b`), + KEY `b_3` (`b`), + KEY `b_4` (`b`), + KEY `b_5` (`b`), + KEY `b_6` (`b`), + KEY `b_7` (`b`), + KEY `b_8` (`b`), + KEY `b_9` (`b`), + KEY `b_10` (`b`), + KEY `b_11` (`b`), + KEY `b_12` (`b`), + KEY `b_13` (`b`), + KEY `b_14` (`b`), + KEY `b_15` (`b`), + KEY `b_16` (`b`), + KEY `b_17` (`b`), + KEY `b_18` (`b`), + KEY `b_19` (`b`), + KEY `b_20` (`b`), + KEY `b_21` (`b`), + KEY `b_22` (`b`), + KEY `b_23` (`b`), + KEY `b_24` (`b`), + KEY `b_25` (`b`), + KEY `b_26` (`b`), + KEY `b_27` (`b`), + KEY `b_28` (`b`), + KEY `b_29` (`b`), + KEY `b_30` (`b`), + KEY `b_31` (`b`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +create table t1 select if(1,'1','0'), month("2002-08-02"); +drop table t1; +create table t1 select if('2002'='2002','Y','N'); +select * from t1; +if('2002'='2002','Y','N') +Y +drop table if exists t1; +SET SESSION default_storage_engine="heap"; +SELECT @@default_storage_engine; +@@default_storage_engine +MEMORY +CREATE TABLE t1 (a int not null); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int NOT NULL +) ENGINE=MEMORY DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +SET SESSION default_storage_engine="gemini"; +ERROR 42000: Unknown storage engine 'gemini' +SELECT @@default_storage_engine; +@@default_storage_engine +MEMORY +CREATE TABLE t1 (a int not null); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int NOT NULL +) ENGINE=MEMORY DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SET SESSION default_storage_engine=default; +drop table t1; +create table t1 ( k1 varchar(2), k2 int, primary key(k1,k2)); +insert into t1 values ("a", 1), ("b", 2); +insert into t1 values ("c", NULL); +ERROR 23000: Column 'k2' cannot be null +insert into t1 values (NULL, 3); +ERROR 23000: Column 'k1' cannot be null +insert into t1 values (NULL, NULL); +ERROR 23000: Column 'k1' cannot be null +drop table t1; +create table t1 select x'4132'; +drop table t1; +create table t1 select 1,2,3; +create table if not exists t1 select 1,2; +Warnings: +Note 1050 Table 't1' already exists +create table if not exists t1 select 1,2,3,4; +Warnings: +Note 1050 Table 't1' already exists +create table if not exists t1 select 1; +Warnings: +Note 1050 Table 't1' already exists +select * from t1; +1 2 3 +1 2 3 +drop table t1; +flush status; +create table t1 (a int not null, b int, primary key (a)); +insert into t1 values (1,1); +create table if not exists t1 select 2; +Warnings: +Note 1050 Table 't1' already exists +select * from t1; +a b +1 1 +create table if not exists t1 select 3 as 'a',4 as 'b'; +Warnings: +Note 1050 Table 't1' already exists +show warnings; +Level Code Message +Note 1050 Table 't1' already exists +show status like "Opened_tables"; +Variable_name Value +Opened_tables 1 +select * from t1; +a b +1 1 +drop table t1; +create table `t1 `(a int); +ERROR 42000: Incorrect table name 't1 ' +create database `db1 `; +ERROR 42000: Incorrect database name 'db1 ' +create table t1(`a ` int); +ERROR 42000: Incorrect column name 'a ' +create table t1 (a int,); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')' at line 1 +create table t1 (a int,,b int); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ',b int)' at line 1 +create table t1 (,b int); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ',b int)' at line 1 +create table t1 (a int, key(a)); +create table t2 (b int, foreign key(b) references t1(a), key(b)); +drop table if exists t2,t1; +create table t1(id int not null, name char(20)); +insert into t1 values(10,'mysql'),(20,'monty- the creator'); +create table t2(id int not null); +insert into t2 values(10),(20); +create table t3 like t1; +show create table t3; +Table Create Table +t3 CREATE TABLE `t3` ( + `id` int NOT NULL, + `name` char(20) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +select * from t3; +id name +create table if not exists t3 like t1; +Warnings: +Note 1050 Table 't3' already exists +select @@warning_count; +@@warning_count +1 +create temporary table t3 like t2; +show create table t3; +Table Create Table +t3 CREATE TEMPORARY TABLE `t3` ( + `id` int NOT NULL +) ENGINE=TMP_TABLE_ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +select * from t3; +id +drop table t3; +show create table t3; +Table Create Table +t3 CREATE TABLE `t3` ( + `id` int NOT NULL, + `name` char(20) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +select * from t3; +id name +drop table t2, t3; +create database mysqltest; +create table mysqltest.t3 like t1; +create temporary table t3 like mysqltest.t3; +show create table t3; +Table Create Table +t3 CREATE TEMPORARY TABLE `t3` ( + `id` int NOT NULL, + `name` char(20) DEFAULT NULL +) ENGINE=TMP_TABLE_ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +create table t2 like t3; +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `id` int NOT NULL, + `name` char(20) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +select * from t2; +id name +create table t3 like t1; +create table t3 like mysqltest.t3; +ERROR 42S01: Table 't3' already exists +create table non_existing_database.t1 like t1; +ERROR 42000: Unknown database 'non_existing_database' +create table t3 like non_existing_table; +ERROR 42S02: Table 'test.non_existing_table' doesn't exist +create temporary table t3 like t1; +ERROR 42S01: Table 't3' already exists +drop table t1, t2, t3; +drop table t3; +drop database mysqltest; +create table t1 (i int); +create table t2 (j int); +lock tables t1 read; +create table t3 like t1; +ERROR HY000: Table 't3' was not locked with LOCK TABLES +create temporary table t3 like t1; +drop temporary table t3; +create temporary table t3 like t2; +ERROR HY000: Table 't2' was not locked with LOCK TABLES +unlock tables; +drop tables t1, t2; +SET SESSION default_storage_engine="heap"; +SELECT @@default_storage_engine; +@@default_storage_engine +MEMORY +CREATE TABLE t1 (a int not null); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int NOT NULL +) ENGINE=MEMORY DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +SET SESSION default_storage_engine="gemini"; +ERROR 42000: Unknown storage engine 'gemini' +SELECT @@default_storage_engine; +@@default_storage_engine +MEMORY +CREATE TABLE t1 (a int not null); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int NOT NULL +) ENGINE=MEMORY DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SET SESSION default_storage_engine=default; +drop table t1; +create table t1(a int,b int,c int unsigned,d date,e char,f datetime,g time,h blob); +insert into t1(a)values(1); +insert into t1(a,b,c,d,e,f,g,h) +values(2,-2,2,'1825-12-14','a','2003-1-1 3:2:1','4:3:2','binary data'); +select * from t1; +a b c d e f g h +1 NULL NULL NULL NULL NULL NULL NULL +2 -2 2 1825-12-14 a 2003-01-01 03:02:01 04:03:02 binary data +select a, +ifnull(b,cast(-7 as signed)) as b, +ifnull(c,cast(7 as unsigned)) as c, +ifnull(d,cast('2000-01-01' as date)) as d, +ifnull(e,cast('b' as char)) as e, +ifnull(f,cast('2000-01-01' as datetime)) as f, +ifnull(g,cast('5:4:3' as time)) as g, +ifnull(h,cast('yet another binary data' as binary)) as h, +addtime(cast('1:0:0' as time),cast('1:0:0' as time)) as dd +from t1; +a b c d e f g h dd +1 -7 7 2000-01-01 b 2000-01-01 00:00:00 05:04:03 yet another binary data 02:00:00 +2 -2 2 1825-12-14 a 2003-01-01 03:02:01 04:03:02 binary data 02:00:00 +create table t2 +select +a, +ifnull(b,cast(-7 as signed)) as b, +ifnull(c,cast(7 as unsigned)) as c, +ifnull(d,cast('2000-01-01' as date)) as d, +ifnull(e,cast('b' as char)) as e, +ifnull(f,cast('2000-01-01' as datetime)) as f, +ifnull(g,cast('5:4:3' as time)) as g, +ifnull(h,cast('yet another binary data' as binary)) as h, +addtime(cast('1:0:0' as time),cast('1:0:0' as time)) as dd +from t1; +explain t2; +Field Type Null Key Default Extra +a int YES NULL +b bigint NO 0 +c bigint unsigned NO 0 +d date YES NULL +e varchar(1) NO +f datetime YES NULL +g time YES NULL +h longblob NO NULL +dd time YES NULL +select * from t2; +a b c d e f g h dd +1 -7 7 2000-01-01 b 2000-01-01 00:00:00 05:04:03 yet another binary data 02:00:00 +2 -2 2 1825-12-14 a 2003-01-01 03:02:01 04:03:02 binary data 02:00:00 +drop table t1, t2; +create table t1 (a tinyint, b smallint, c mediumint, d int, e bigint, f float(3,2), g double(4,3), h decimal(5,4), i year, j date, k timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, l datetime, m enum('a','b'), n set('a','b'), o char(10)); +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +create table t2 select ifnull(a,a), ifnull(b,b), ifnull(c,c), ifnull(d,d), ifnull(e,e), ifnull(f,f), ifnull(g,g), ifnull(h,h), ifnull(i,i), ifnull(j,j), ifnull(k,k), ifnull(l,l), ifnull(m,m), ifnull(n,n), ifnull(o,o) from t1; +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `ifnull(a,a)` tinyint DEFAULT NULL, + `ifnull(b,b)` smallint DEFAULT NULL, + `ifnull(c,c)` mediumint DEFAULT NULL, + `ifnull(d,d)` int DEFAULT NULL, + `ifnull(e,e)` bigint DEFAULT NULL, + `ifnull(f,f)` float(3,2) DEFAULT NULL, + `ifnull(g,g)` double(4,3) DEFAULT NULL, + `ifnull(h,h)` decimal(5,4) DEFAULT NULL, + `ifnull(i,i)` year DEFAULT NULL, + `ifnull(j,j)` date DEFAULT NULL, + `ifnull(k,k)` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00', + `ifnull(l,l)` datetime DEFAULT NULL, + `ifnull(m,m)` varchar(1) DEFAULT NULL, + `ifnull(n,n)` varchar(3) DEFAULT NULL, + `ifnull(o,o)` varchar(10) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1,t2; +create table t1(str varchar(10) default 'def',strnull varchar(10),intg int default '10',rel double default '3.14'); +insert into t1 values ('','',0,0.0); +describe t1; +Field Type Null Key Default Extra +str varchar(10) YES def +strnull varchar(10) YES NULL +intg int YES 10 +rel double YES 3.14 +create table t2 select default(str) as str, default(strnull) as strnull, default(intg) as intg, default(rel) as rel from t1; +describe t2; +Field Type Null Key Default Extra +str varchar(10) YES NULL +strnull varchar(10) YES NULL +intg int YES NULL +rel double YES NULL +drop table t1, t2; +create table t1(name varchar(10), age smallint default -1); +describe t1; +Field Type Null Key Default Extra +name varchar(10) YES NULL +age smallint YES -1 +create table t2(name varchar(10), age smallint default - 1); +describe t2; +Field Type Null Key Default Extra +name varchar(10) YES NULL +age smallint YES -1 +drop table t1, t2; +create table t1(cenum enum('a'), cset set('b')); +create table t2(cenum enum('a','a'), cset set('b','b')); +Warnings: +Note 1291 Column 'cenum' has duplicated value 'a' in ENUM +Note 1291 Column 'cset' has duplicated value 'b' in SET +create table t3(cenum enum('a','A','a','c','c'), cset set('b','B','b','d','d')); +Warnings: +Note 1291 Column 'cenum' has duplicated value 'a' in ENUM +Note 1291 Column 'cenum' has duplicated value 'A' in ENUM +Note 1291 Column 'cenum' has duplicated value 'c' in ENUM +Note 1291 Column 'cset' has duplicated value 'b' in SET +Note 1291 Column 'cset' has duplicated value 'B' in SET +Note 1291 Column 'cset' has duplicated value 'd' in SET +drop table t1, t2, t3; +create database mysqltest; +use mysqltest; +select database(); +database() +mysqltest +drop database mysqltest; +select database(); +database() +NULL +create user mysqltest_1; +select database(), user(); +database() user() +NULL mysqltest_1@localhost +drop user mysqltest_1; +use test; +create table t1 (a int, index `primary` (a)); +ERROR 42000: Incorrect index name 'primary' +create table t1 (a int, index `PRIMARY` (a)); +ERROR 42000: Incorrect index name 'PRIMARY' +create table t1 (`primary` int, index(`primary`)); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `primary` int DEFAULT NULL, + KEY `primary_2` (`primary`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +create table t2 (`PRIMARY` int, index(`PRIMARY`)); +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `PRIMARY` int DEFAULT NULL, + KEY `PRIMARY_2` (`PRIMARY`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +create table t3 (a int); +alter table t3 add index `primary` (a); +ERROR 42000: Incorrect index name 'primary' +alter table t3 add index `PRIMARY` (a); +ERROR 42000: Incorrect index name 'PRIMARY' +create table t4 (`primary` int); +alter table t4 add index(`primary`); +show create table t4; +Table Create Table +t4 CREATE TABLE `t4` ( + `primary` int DEFAULT NULL, + KEY `primary_2` (`primary`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +create table t5 (`PRIMARY` int); +alter table t5 add index(`PRIMARY`); +show create table t5; +Table Create Table +t5 CREATE TABLE `t5` ( + `PRIMARY` int DEFAULT NULL, + KEY `PRIMARY_2` (`PRIMARY`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1, t2, t3, t4, t5; +CREATE TABLE t1(id varchar(10) NOT NULL PRIMARY KEY, dsc longtext); +INSERT INTO t1 VALUES ('5000000001', NULL),('5000000003', 'Test'),('5000000004', NULL); +CREATE TABLE t2(id varchar(15) NOT NULL, proc varchar(100) NOT NULL, runID varchar(16) NOT NULL, start datetime NOT NULL, PRIMARY KEY (id,proc,runID,start)); +INSERT INTO t2 VALUES ('5000000001', 'proc01', '20031029090650', '2003-10-29 13:38:40'),('5000000001', 'proc02', '20031029090650', '2003-10-29 13:38:51'),('5000000001', 'proc03', '20031029090650', '2003-10-29 13:38:11'),('5000000002', 'proc09', '20031024013310', '2003-10-24 01:33:11'),('5000000002', 'proc09', '20031024153537', '2003-10-24 15:36:04'),('5000000004', 'proc01', '20031024013641', '2003-10-24 01:37:29'),('5000000004', 'proc02', '20031024013641', '2003-10-24 01:37:39'); +CREATE TABLE t3 SELECT t1.dsc,COUNT(DISTINCT t2.id) AS countOfRuns FROM t1 LEFT JOIN t2 ON (t1.id=t2.id) GROUP BY t1.id; +SELECT * FROM t3; +dsc countOfRuns +NULL 1 +Test 0 +NULL 1 +drop table t1, t2, t3; +create table t1 (b bool not null default false); +create table t2 (b bool not null default true); +insert into t1 values (); +insert into t2 values (); +select * from t1; +b +0 +select * from t2; +b +1 +drop table t1,t2; +create table t1 (a int); +create table t1 select * from t1; +ERROR 42S01: Table 't1' already exists +create table t2 union = (t1) select * from t1; +ERROR HY000: 'test.t2' is not BASE TABLE +flush tables with read lock; +unlock tables; +drop table t1; +create table t1(column.name int); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '.name int)' at line 1 +create table t1(test.column.name int); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '.column.name int)' at line 1 +create table t1(xyz.t1.name int); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '.t1.name int)' at line 1 +create table t1(t1.name int); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '.name int)' at line 1 +create table t2(test.t2.name int); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '.t2.name int)' at line 1 +CREATE TABLE t1 (f1 VARCHAR(255) CHARACTER SET utf8); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +CREATE TABLE t2 AS SELECT LEFT(f1,171) AS f2 FROM t1 UNION SELECT LEFT(f1,171) AS f2 FROM t1; +DESC t2; +Field Type Null Key Default Extra +f2 varchar(171) YES NULL +DROP TABLE t1,t2; +CREATE TABLE t12913 (f1 ENUM ('a','b')) AS SELECT 'a' AS f1; +SELECT * FROM t12913; +f1 +a +DROP TABLE t12913; +create database mysqltest; +use mysqltest; +drop database mysqltest; +create table test.t1 like x; +ERROR 3D000: No database selected +drop table if exists test.t1; +create database mysqltest; +use mysqltest; +create view v1 as select 'foo' from dual; +create table t1 like v1; +ERROR HY000: 'mysqltest.v1' is not BASE TABLE +drop view v1; +drop database mysqltest; +create database mysqltest; +create database if not exists mysqltest character set latin2; +Warnings: +Note 1007 Can't create database 'mysqltest'; database exists +show create database mysqltest; +Database Create Database +mysqltest CREATE DATABASE `mysqltest` /*!40100 DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci */ /*!80016 DEFAULT ENCRYPTION='N' */ +drop database mysqltest; +use test; +create table t1 (a int); +create table if not exists t1 (a int); +Warnings: +Note 1050 Table 't1' already exists +drop table t1; +create table t1 ( +a varchar(112) charset utf8 collate utf8_bin not null, +primary key (a) +) select 'test' as a ; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 3778 'utf8_bin' is a collation of the deprecated character set UTF8MB3. Please consider using UTF8MB4 with an appropriate collation instead. +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(112) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, + PRIMARY KEY (`a`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +CREATE TABLE t2 ( +a int(11) default NULL +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t2 values(111); +create table t1 ( +a varchar(12) charset utf8 collate utf8_bin not null, +b int not null, primary key (a) +) select a, 1 as b from t2 ; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 3778 'utf8_bin' is a collation of the deprecated character set UTF8MB3. Please consider using UTF8MB4 with an appropriate collation instead. +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(12) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, + `b` int NOT NULL, + PRIMARY KEY (`a`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +create table t1 ( +a varchar(12) charset utf8 collate utf8_bin not null, +b int not null, primary key (a) +) select a, 1 as c from t2 ; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 3778 'utf8_bin' is a collation of the deprecated character set UTF8MB3. Please consider using UTF8MB4 with an appropriate collation instead. +Warning 1364 Field 'b' doesn't have a default value +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `b` int NOT NULL, + `a` varchar(12) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, + `c` int NOT NULL DEFAULT '0', + PRIMARY KEY (`a`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +create table t1 ( +a varchar(12) charset utf8 collate utf8_bin not null, +b int null, primary key (a) +) select a, 1 as c from t2 ; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 3778 'utf8_bin' is a collation of the deprecated character set UTF8MB3. Please consider using UTF8MB4 with an appropriate collation instead. +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `b` int DEFAULT NULL, + `a` varchar(12) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, + `c` int NOT NULL DEFAULT '0', + PRIMARY KEY (`a`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +create table t1 ( +a varchar(12) charset utf8 collate utf8_bin not null, +b int not null, primary key (a) +) select 'a' as a , 1 as b from t2 ; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 3778 'utf8_bin' is a collation of the deprecated character set UTF8MB3. Please consider using UTF8MB4 with an appropriate collation instead. +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(12) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, + `b` int NOT NULL, + PRIMARY KEY (`a`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +create table t1 ( +a varchar(12) charset utf8 collate utf8_bin, +b int not null, primary key (a) +) select 'a' as a , 1 as b from t2 ; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 3778 'utf8_bin' is a collation of the deprecated character set UTF8MB3. Please consider using UTF8MB4 with an appropriate collation instead. +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(12) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, + `b` int NOT NULL, + PRIMARY KEY (`a`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1, t2; +create table t1 ( +a1 int not null, +a2 int, a3 int, a4 int, a5 int, a6 int, a7 int, a8 int, a9 int +); +insert into t1 values (1,1,1, 1,1,1, 1,1,1); +create table t2 ( +a1 varchar(12) charset utf8 collate utf8_bin not null, +a2 int, a3 int, a4 int, a5 int, a6 int, a7 int, a8 int, a9 int, +primary key (a1) +) select a1,a2,a3,a4,a5,a6,a7,a8,a9 from t1 ; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 3778 'utf8_bin' is a collation of the deprecated character set UTF8MB3. Please consider using UTF8MB4 with an appropriate collation instead. +drop table t2; +create table t2 ( +a1 varchar(12) charset utf8 collate utf8_bin, +a2 int, a3 int, a4 int, a5 int, a6 int, a7 int, a8 int, a9 int +) select a1,a2,a3,a4,a5,a6,a7,a8,a9 from t1; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 3778 'utf8_bin' is a collation of the deprecated character set UTF8MB3. Please consider using UTF8MB4 with an appropriate collation instead. +drop table t1, t2; +create table t1 ( +a1 int, a2 int, a3 int, a4 int, a5 int, a6 int, a7 int, a8 int, a9 int +); +insert into t1 values (1,1,1, 1,1,1, 1,1,1); +create table t2 ( +a1 varchar(12) charset utf8 collate utf8_bin not null, +a2 int, a3 int, a4 int, a5 int, a6 int, a7 int, a8 int, a9 int, +primary key (a1) +) select a1,a2,a3,a4,a5,a6,a7,a8,a9 from t1 ; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 3778 'utf8_bin' is a collation of the deprecated character set UTF8MB3. Please consider using UTF8MB4 with an appropriate collation instead. +drop table t2; +create table t2 ( a int default 3, b int default 3) +select a1,a2 from t1; +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `a` int DEFAULT '3', + `b` int DEFAULT '3', + `a1` int DEFAULT NULL, + `a2` int DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1, t2; +create table t1(a set("a,b","c,d") not null); +ERROR 22007: Illegal set 'a,b' value found during parsing +create table t1 select * from t2; +ERROR 42S02: Table 'test.t2' doesn't exist +create table t1 select * from t1; +ERROR 42S02: Table 'test.t1' doesn't exist +create table t1 select coalesce(_latin1 'a' collate latin1_swedish_ci,_latin1 'b' collate latin1_bin); +ERROR HY000: Illegal mix of collations (latin1_swedish_ci,EXPLICIT) and (latin1_bin,EXPLICIT) for operation 'coalesce' +create table t1 (primary key(a)) select "b" as b; +ERROR 42000: Key column 'a' doesn't exist in table +create table t1 (a int); +create table if not exists t1 select 1 as a, 2 as b; +Warnings: +Note 1050 Table 't1' already exists +drop table t1; +create table t1 (primary key (a)) (select 1 as a) union all (select 1 as a); +ERROR 23000: Duplicate entry '1' for key 't1.PRIMARY' +create table t1 (i int); +create table t1 select 1 as i; +ERROR 42S01: Table 't1' already exists +create table if not exists t1 select 1 as i; +Warnings: +Note 1050 Table 't1' already exists +select * from t1; +i +create table if not exists t1 select * from t1; +Warnings: +Note 1050 Table 't1' already exists +select * from t1; +i +drop table t1; +create table t1 select coalesce(_latin1 'a' collate latin1_swedish_ci,_latin1 'b' collate latin1_bin); +ERROR HY000: Illegal mix of collations (latin1_swedish_ci,EXPLICIT) and (latin1_bin,EXPLICIT) for operation 'coalesce' +create temporary table t1 (j int); +create table if not exists t1 select 1; +select * from t1; +j +drop temporary table t1; +select * from t1; +1 +1 +drop table t1; +create table t1 (i int); +insert into t1 values (1), (2); +lock tables t1 read; +create table t2 select * from t1; +ERROR HY000: Table 't2' was not locked with LOCK TABLES +create table if not exists t2 select * from t1; +ERROR HY000: Table 't2' was not locked with LOCK TABLES +unlock tables; +create table t2 (j int); +lock tables t1 read; +create table t2 select * from t1; +ERROR HY000: Table 't2' was not locked with LOCK TABLES +create table if not exists t2 select * from t1; +ERROR HY000: Table 't2' was not locked with LOCK TABLES +unlock tables; +lock table t1 read, t2 read; +create table t2 select * from t1; +ERROR 42S01: Table 't2' already exists +create table if not exists t2 select * from t1; +Warnings: +Note 1050 Table 't2' already exists +unlock tables; +lock table t1 read, t2 write; +create table t2 select * from t1; +ERROR 42S01: Table 't2' already exists +create table if not exists t2 select * from t1; +Warnings: +Note 1050 Table 't2' already exists +select * from t1; +i +1 +2 +unlock tables; +drop table t2; +lock tables t1 read; +create temporary table t2 select * from t1; +create temporary table if not exists t2 select * from t1; +Warnings: +Note 1050 Table 't2' already exists +select * from t2; +i +1 +2 +unlock tables; +drop table t1, t2; +create table t1 (upgrade int); +drop table t1; + +Bug #26104 Bug on foreign key class constructor + +Check that ref_columns is initalized correctly in the constructor +and semantic checks in mysql_prepare_table work. + +We do not need a storage engine that supports foreign keys +for this test, as the checks are purely syntax-based, and the +syntax is supported for all engines. + +drop table if exists t1,t2; +create table t1(a int not null, b int not null, primary key (a, b)); +create table t2(a int not null, b int not null, c int not null, primary key (a), +constraint fk_bug26104 foreign key (b,c) references t1(a)); +ERROR 42000: Incorrect foreign key definition for 'fk_bug26104': Key reference and table reference don't match +drop table t1; +create table t1(f1 int,f2 int); +insert into t1 value(1,1),(1,2),(1,3),(2,1),(2,2),(2,3); +flush status; +create table t2 select sql_big_result f1,count(f2) from t1 group by f1; +show status like 'handler_read%'; +Variable_name Value +Handler_read_first 1 +Handler_read_key 23 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 7 +drop table t1,t2; +CREATE TABLE t1(c1 VARCHAR(33), KEY USING BTREE (c1)); +DROP TABLE t1; +CREATE TABLE t1(c1 VARCHAR(33), KEY (c1) USING BTREE); +DROP TABLE t1; +CREATE TABLE t1(c1 VARCHAR(33), KEY USING BTREE (c1) USING HASH) ENGINE=MEMORY; +SHOW INDEX FROM t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible Expression +t1 1 c1 1 c1 NULL 0 NULL NULL YES HASH YES NULL +DROP TABLE t1; +CREATE TABLE t1(c1 VARCHAR(33), KEY USING HASH (c1) USING BTREE) ENGINE=MEMORY; +SHOW INDEX FROM t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible Expression +t1 1 c1 1 c1 A NULL NULL NULL YES BTREE YES NULL +DROP TABLE t1; +create user mysqltest_1@'test@test'; +ERROR HY000: Malformed hostname (illegal symbol: '@') +CREATE TABLE t1 (a INTEGER AUTO_INCREMENT PRIMARY KEY, b INTEGER NOT NULL); +INSERT IGNORE INTO t1 (b) VALUES (5); +CREATE TABLE IF NOT EXISTS t2 (a INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY) +SELECT a FROM t1; +INSERT INTO t2 SELECT a FROM t1; +ERROR 23000: Duplicate entry '1' for key 't2.PRIMARY' +INSERT INTO t2 SELECT a FROM t1; +ERROR 23000: Duplicate entry '1' for key 't2.PRIMARY' +DROP TABLE t1, t2; +# +# BUG#46384 - mysqld segfault when trying to create table with same +# name as existing view +# +CREATE TABLE t1 (a INT); +CREATE TABLE t2 (a INT); +INSERT INTO t1 VALUES (1),(2),(3); +INSERT INTO t2 VALUES (1),(2),(3); +CREATE VIEW v1 AS SELECT t1.a FROM t1, t2; +CREATE TABLE v1 AS SELECT * FROM t1; +ERROR 42S01: Table 'v1' already exists +DROP VIEW v1; +DROP TABLE t1,t2; +End of 5.0 tests +CREATE TABLE t1 (a int, b int); +insert into t1 values (1,1),(1,2); +CREATE TABLE t2 (primary key (a)) select * from t1; +ERROR 23000: Duplicate entry '1' for key 't2.PRIMARY' +drop table if exists t2; +Warnings: +Note 1051 Unknown table 'test.t2' +CREATE TEMPORARY TABLE t2 (primary key (a)) select * from t1; +ERROR 23000: Duplicate entry '1' for key 't2.PRIMARY' +drop table if exists t2; +Warnings: +Note 1051 Unknown table 'test.t2' +CREATE TABLE t2 (a int, b int, primary key (a)); +INSERT INTO t2 select * from t1; +ERROR 23000: Duplicate entry '1' for key 't2.PRIMARY' +SELECT * from t2; +a b +TRUNCATE table t2; +INSERT INTO t2 select * from t1; +ERROR 23000: Duplicate entry '1' for key 't2.PRIMARY' +SELECT * from t2; +a b +drop table t2; +CREATE TEMPORARY TABLE t2 (a int, b int, primary key (a)) ENGINE=InnoDB; +INSERT INTO t2 SELECT * FROM t1; +ERROR 23000: Duplicate entry '1' for key 't2.PRIMARY' +SELECT * from t2; +a b +drop table t1,t2; +CREATE DATABASE aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa; +ERROR 42000: Identifier name 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' is too long +DROP DATABASE aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa; +ERROR 42000: Identifier name 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' is too long +USE aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa; +ERROR 42000: Identifier name 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' is too long +SHOW CREATE DATABASE aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa; +ERROR 42000: Identifier name 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' is too long +set names utf8; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +create database имÑ_базы_в_кодировке_утф8_длиной_больше_чем_45; +use имÑ_базы_в_кодировке_утф8_длиной_больше_чем_45; +select database(); +database() +имÑ_базы_в_кодировке_утф8_длиной_больше_чем_45 +use test; +select SCHEMA_NAME from information_schema.schemata +where schema_name='имÑ_базы_в_кодировке_утф8_длиной_больше_чем_45'; +SCHEMA_NAME +имÑ_базы_в_кодировке_утф8_длиной_больше_чем_45 +drop database имÑ_базы_в_кодировке_утф8_длиной_больше_чем_45; +create table имÑ_таблицы_в_кодировке_утф8_длиной_больше_чем_48 +( +имÑ_полÑ_в_кодировке_утф8_длиной_больше_чем_45 int, +index имÑ_индекÑа_в_кодировке_утф8_длиной_больше_чем_48 (имÑ_полÑ_в_кодировке_утф8_длиной_больше_чем_45) +); +create view имÑ_вью_кодировке_утф8_длиной_больше_чем_42 as +select имÑ_полÑ_в_кодировке_утф8_длиной_больше_чем_45 +from имÑ_таблицы_в_кодировке_утф8_длиной_больше_чем_48; +select * from имÑ_таблицы_в_кодировке_утф8_длиной_больше_чем_48; +имÑ_полÑ_в_кодировке_утф8_длиной_больше_чем_45 +select TABLE_NAME from information_schema.tables where +table_schema='test' order by TABLE_NAME; +TABLE_NAME +имÑ_вью_кодировке_утф8_длиной_больше_чем_42 +имÑ_таблицы_в_кодировке_утф8_длиной_больше_чем_48 +select COLUMN_NAME from information_schema.columns where +table_schema='test' order by COLUMN_NAME; +COLUMN_NAME +имÑ_полÑ_в_кодировке_утф8_длиной_больше_чем_45 +имÑ_полÑ_в_кодировке_утф8_длиной_больше_чем_45 +select INDEX_NAME from information_schema.statistics where +table_schema='test' order by INDEX_NAME; +INDEX_NAME +имÑ_индекÑа_в_кодировке_утф8_длиной_больше_чем_48 +select TABLE_NAME from information_schema.views where +table_schema='test' order by TABLE_NAME; +TABLE_NAME +имÑ_вью_кодировке_утф8_длиной_больше_чем_42 +show create table имÑ_таблицы_в_кодировке_утф8_длиной_больше_чем_48; +Table Create Table +имÑ_таблицы_в_кодировке_утф8_длиной_больше_чем_48 CREATE TABLE `имÑ_таблицы_в_кодировке_утф8_длиной_больше_чем_48` ( + `имÑ_полÑ_в_кодировке_утф8_длиной_больше_чем_45` int DEFAULT NULL, + KEY `имÑ_индекÑа_в_кодировке_утф8_длиной_больше_чем_48` (`имÑ_полÑ_в_кодировке_утф8_длиной_больше_чем_45`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +show create view имÑ_вью_кодировке_утф8_длиной_больше_чем_42; +View Create View character_set_client collation_connection +имÑ_вью_кодировке_утф8_длиной_больше_чем_42 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `имÑ_вью_кодировке_утф8_длиной_больше_чем_42` AS select `имÑ_таблицы_в_кодировке_утф8_длиной_больше_чем_48`.`имÑ_полÑ_в_кодировке_утф8_длиной_больше_чем_45` AS `имÑ_полÑ_в_кодировке_утф8_длиной_больше_чем_45` from `имÑ_таблицы_в_кодировке_утф8_длиной_больше_чем_48` utf8 utf8_general_ci +create trigger имÑ_триггера_в_кодировке_утф8_длиной_больше_чем_49 +before insert on имÑ_таблицы_в_кодировке_утф8_длиной_больше_чем_48 for each row set @a:=1; +select TRIGGER_NAME from information_schema.triggers where +trigger_schema='test'; +TRIGGER_NAME +имÑ_триггера_в_кодировке_утф8_длиной_больше_чем_49 +drop trigger имÑ_триггера_в_кодировке_утф8_длиной_больше_чем_49; +create trigger +очень_очень_очень_очень_очень_очень_очень_очень_длиннаÑ_Ñтрока_66 +before insert on имÑ_таблицы_в_кодировке_утф8_длиной_больше_чем_48 for each row set @a:=1; +ERROR 42000: Identifier name 'очень_очень_очень_очень_очень_очень_очень_очень_длинна' is too long +drop trigger очень_очень_очень_очень_очень_очень_очень_очень_длиннаÑ_Ñтрока_66; +ERROR 42000: Identifier name 'очень_очень_очень_очень_очень_очень_очень_очень_длинна' is too long +create procedure имÑ_процедуры_в_кодировке_утф8_длиной_больше_чем_50() +begin +end; +select ROUTINE_NAME from information_schema.routines where +routine_schema='test'; +ROUTINE_NAME +имÑ_процедуры_в_кодировке_утф8_длиной_больше_чем_50 +drop procedure имÑ_процедуры_в_кодировке_утф8_длиной_больше_чем_50; +create procedure очень_очень_очень_очень_очень_очень_очень_очень_длиннаÑ_Ñтрока_66() +begin +end; +ERROR 42000: Identifier name 'очень_очень_очень_очень_очень_очень_очень_очень_длинна' is too long +create function имÑ_функции_в_кодировке_утф8_длиной_больше_чем_49() +returns int +return 0; +select ROUTINE_NAME from information_schema.routines where +routine_schema='test'; +ROUTINE_NAME +имÑ_функции_в_кодировке_утф8_длиной_больше_чем_49 +drop function имÑ_функции_в_кодировке_утф8_длиной_больше_чем_49; +create function очень_очень_очень_очень_очень_очень_очень_очень_длиннаÑ_Ñтрока_66() +returns int +return 0; +ERROR 42000: Identifier name 'очень_очень_очень_очень_очень_очень_очень_очень_длинна' is too long +drop view имÑ_вью_кодировке_утф8_длиной_больше_чем_42; +drop table имÑ_таблицы_в_кодировке_утф8_длиной_больше_чем_48; +set names default; +drop table if exists t1,t2,t3; +drop function if exists f1; +create function f1() returns int +begin +declare res int; +create temporary table t3 select 1 i; +set res:= (select count(*) from t1); +drop temporary table t3; +return res; +end| +create table t1 as select 1; +create table t2 as select f1() from t1; +drop table t1,t2; +drop function f1; +create table t1 like information_schema.processlist; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `ID` bigint unsigned NOT NULL DEFAULT '0', + `USER` varchar(32) NOT NULL DEFAULT '', + `HOST` varchar(261) NOT NULL DEFAULT '', + `DB` varchar(64) DEFAULT NULL, + `COMMAND` varchar(16) NOT NULL DEFAULT '', + `TIME` int NOT NULL DEFAULT '0', + `STATE` varchar(64) DEFAULT NULL, + `INFO` longtext +) ENGINE=TMP_TABLE_ENGINE DEFAULT CHARSET=utf8mb3 +drop table t1; +create temporary table t1 like information_schema.processlist; +show create table t1; +Table Create Table +t1 CREATE TEMPORARY TABLE `t1` ( + `ID` bigint unsigned NOT NULL DEFAULT '0', + `USER` varchar(32) NOT NULL DEFAULT '', + `HOST` varchar(261) NOT NULL DEFAULT '', + `DB` varchar(64) DEFAULT NULL, + `COMMAND` varchar(16) NOT NULL DEFAULT '', + `TIME` int NOT NULL DEFAULT '0', + `STATE` varchar(64) DEFAULT NULL, + `INFO` longtext +) ENGINE=TMP_TABLE_ENGINE DEFAULT CHARSET=utf8mb3 +drop table t1; +create table t1 as select * from information_schema.character_sets; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `CHARACTER_SET_NAME` varchar(64) CHARACTER SET utf8 NOT NULL, + `DEFAULT_COLLATE_NAME` varchar(64) CHARACTER SET utf8 NOT NULL, + `DESCRIPTION` varchar(2048) CHARACTER SET utf8 NOT NULL, + `MAXLEN` int unsigned NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; + +# -- +# -- Bug#21380: DEFAULT definition not always transfered by CREATE +# -- TABLE/SELECT to the new table. +# -- + +DROP TABLE IF EXISTS t1; +DROP TABLE IF EXISTS t2; + +CREATE TABLE t1( +c1 INT DEFAULT 12 COMMENT 'column1', +c2 INT NULL COMMENT 'column2', +c3 INT NOT NULL COMMENT 'column3', +c4 VARCHAR(255) CHARACTER SET utf8 NOT NULL DEFAULT 'a', +c5 VARCHAR(255) COLLATE utf8_unicode_ci NULL DEFAULT 'b', +c6 VARCHAR(255)) +COLLATE latin1_bin; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 3778 'utf8_unicode_ci' is a collation of the deprecated character set UTF8MB3. Please consider using UTF8MB4 with an appropriate collation instead. + +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` int DEFAULT '12' COMMENT 'column1', + `c2` int DEFAULT NULL COMMENT 'column2', + `c3` int NOT NULL COMMENT 'column3', + `c4` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT 'a', + `c5` varchar(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT 'b', + `c6` varchar(255) COLLATE latin1_bin DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_bin + +CREATE TABLE t2 AS SELECT * FROM t1; + +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `c1` int DEFAULT '12' COMMENT 'column1', + `c2` int DEFAULT NULL COMMENT 'column2', + `c3` int NOT NULL COMMENT 'column3', + `c4` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT 'a', + `c5` varchar(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT 'b', + `c6` varchar(255) CHARACTER SET latin1 COLLATE latin1_bin DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci + +DROP TABLE t2; +DROP TABLE t1; + +# -- End of test case for Bug#21380. + +# -- +# -- Bug#18834: ALTER TABLE ADD INDEX on table with two timestamp fields +# -- + +DROP TABLE IF EXISTS t1; +DROP TABLE IF EXISTS t2; +DROP TABLE IF EXISTS t3; + +CREATE TABLE t1(c1 TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, c2 TIMESTAMP NOT NULL DEFAULT '0000-00-00 00:00:00'); + +SET sql_mode = 'NO_ZERO_DATE'; +Warnings: +Warning 3135 'NO_ZERO_DATE', 'NO_ZERO_IN_DATE' and 'ERROR_FOR_DIVISION_BY_ZERO' sql modes should be used with strict mode. They will be merged with strict mode in a future release. + +CREATE TABLE t2(c1 TIMESTAMP, c2 TIMESTAMP DEFAULT 0); +Warnings: +Warning 1264 Out of range value for column 'c2' at row 1 +DROP TABLE t2; + +# -- Check that NULL column still can be created. +CREATE TABLE t2(c1 TIMESTAMP NULL); + +# -- Check ALTER TABLE. +ALTER TABLE t1 ADD INDEX(c1); +Warnings: +Warning 1264 Out of range value for column 'c2' at row 1 + +# -- Check DATETIME. +SET sql_mode = ''; + +# -- Cleanup. +SET sql_mode = ''; +DROP TABLE t1; +DROP TABLE t2; + +# -- End of Bug#18834. + +# -- +# -- Bug#34274: Invalid handling of 'DEFAULT 0' for YEAR data type. +# -- + +DROP TABLE IF EXISTS t1; + +CREATE TABLE t1(c1 YEAR DEFAULT 2008, c2 YEAR DEFAULT 0); + +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` year DEFAULT '2008', + `c2` year DEFAULT '0000' +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci + +INSERT INTO t1 VALUES(); + +SELECT * FROM t1; +c1 c2 +2008 0000 + +ALTER TABLE t1 MODIFY c1 YEAR DEFAULT 0; + +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` year DEFAULT '0000', + `c2` year DEFAULT '0000' +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci + +INSERT INTO t1 VALUES(); + +SELECT * FROM t1; +c1 c2 +2008 0000 +0000 0000 + +DROP TABLE t1; + +# -- End of Bug#34274 +create table `me:i`(id int); +drop table `me:i`; + +# -- +# -- Bug#45829: CREATE TABLE TRANSACTIONAL PAGE_CHECKSUM ROW_FORMAT=PAGE accepted, does nothing +# -- + +drop table if exists t1,t2,t3; +create table t1 (a int) transactional=0; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'transactional=0' at line 1 +create table t2 (a int) page_checksum=1; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'page_checksum=1' at line 1 +create table t3 (a int) row_format=page; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'page' at line 1 + +# -- End of Bug#45829 + +End of 5.1 tests + +# -- +# -- Bug #43054 Assertion `!table->auto_increment_field_not_null' +# -- failed when redefining trigger + +CREATE TABLE B ( +pk INTEGER AUTO_INCREMENT, +int_key INTEGER NOT NULL, +PRIMARY KEY (pk), +KEY (int_key) +); +INSERT IGNORE INTO B VALUES ('9', '9'); +CREATE TABLE IF NOT EXISTS t1 ( +`pk` INTEGER NOT NULL AUTO_INCREMENT , +`int` INTEGER , +PRIMARY KEY ( `pk` ) +) SELECT `pk` , `int_key` FROM B ; +CREATE TRIGGER f BEFORE INSERT ON t1 FOR EACH ROW +BEGIN +INSERT INTO t1 ( `int` ) VALUES (4 ),( 8 ),( 2 ) ; +END ; | +INSERT INTO t1 (pk, int_key) SELECT `pk` , `int_key` FROM B ; +ERROR HY000: Can't update table 't1' in stored function/trigger because it is already used by statement which invoked this stored function/trigger. +CREATE TRIGGER f BEFORE INSERT ON t1 FOR EACH ROW +BEGIN +UPDATE A SET `pk`=1 WHERE `pk`=0 ; +END ;| +ERROR HY000: Trigger already exists +DROP TABLE t1; +DROP TABLE B; +# +# Bug #47107 assert in notify_shared_lock on incorrect +# CREATE TABLE , HANDLER +# +DROP TABLE IF EXISTS t1; +CREATE TABLE t1(f1 integer); +# The following CREATE TABLEs before gave an assert. +HANDLER t1 OPEN AS A; +CREATE TABLE t1 SELECT 1 AS f2; +ERROR 42S01: Table 't1' already exists +HANDLER t1 OPEN AS A; +CREATE TABLE t1(f1 integer); +ERROR 42S01: Table 't1' already exists +CREATE TABLE t2(f1 integer); +HANDLER t1 OPEN AS A; +CREATE TABLE t1 LIKE t2; +ERROR 42S01: Table 't1' already exists +DROP TABLE t2; +DROP TABLE t1; +# +# Bug #48800 CREATE TABLE t...SELECT fails if t is a +# temporary table +# +CREATE TEMPORARY TABLE t1 (a INT); +CREATE TABLE t1 (a INT); +CREATE TEMPORARY TABLE t2 (a INT); +CREATE VIEW t2 AS SELECT 1; +CREATE TABLE t3 (a INT); +CREATE TEMPORARY TABLE t3 SELECT 1; +CREATE TEMPORARY TABLE t4 (a INT); +CREATE TABLE t4 AS SELECT 1; +DROP TEMPORARY TABLE t1, t2, t3, t4; +DROP TABLE t1, t3, t4; +DROP VIEW t2; +# +# Bug #49193 CREATE TABLE reacts differently depending +# on whether data is selected or not +# +CREATE TEMPORARY TABLE t2 (ID INT); +INSERT INTO t2 VALUES (1),(2),(3); +CREATE TEMPORARY TABLE t1 (ID INT); +CREATE TABLE IF NOT EXISTS t1 (ID INT); +INSERT INTO t1 SELECT * FROM t2; +SELECT * FROM t1; +ID +1 +2 +3 +DROP TEMPORARY TABLE t1; +SELECT * FROM t1; +ID +DROP TABLE t1; +CREATE TEMPORARY TABLE t1 (ID INT); +CREATE TABLE IF NOT EXISTS t1 SELECT * FROM t2; +SELECT * FROM t1; +ID +DROP TEMPORARY TABLE t1; +SELECT * FROM t1; +ID +1 +2 +3 +DROP TABLE t1; +CREATE TEMPORARY TABLE t1 (ID INT); +CREATE TABLE t1 SELECT * FROM t2; +SELECT * FROM t1; +ID +DROP TEMPORARY TABLE t1; +SELECT * FROM t1; +ID +1 +2 +3 +DROP TABLE t1; +DROP TEMPORARY TABLE t2; +# +# Bug #22909 "Using CREATE ... LIKE is possible to create field +# with invalid default value" +# +# Altough original bug report suggests to use older version of MySQL +# for producing .FRM with invalid defaults we use sql_mode to achieve +# the same effect. +drop tables if exists t1, t2; +# Attempt to create table with invalid default should fail in normal mode +create table t1 (dt datetime default '2008-02-31 00:00:00'); +ERROR 42000: Invalid default value for 'dt' +set @old_mode= @@sql_mode; +set @@sql_mode='ALLOW_INVALID_DATES'; +# The same should be possible in relaxed mode +create table t1 (dt datetime default '2008-02-31 00:00:00'); +set @@sql_mode= @old_mode; +# In normal mode attempt to create copy of table with invalid +# default should fail +create table t2 like t1; +ERROR 42000: Invalid default value for 'dt' +set @@sql_mode='ALLOW_INVALID_DATES'; +# But should work in relaxed mode +create table t2 like t1; +# Check that table definitions match +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `dt` datetime DEFAULT '2008-02-31 00:00:00' +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `dt` datetime DEFAULT '2008-02-31 00:00:00' +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +set @@sql_mode= @old_mode; +drop tables t1, t2; +CREATE TABLE t1 (id int); +CREATE TABLE t2 (id int); +INSERT INTO t1 VALUES (1), (1); +INSERT INTO t2 VALUES (2), (2); +CREATE VIEW v1 AS SELECT id FROM t2; +CREATE TABLE IF NOT EXISTS v1(a int, b int) SELECT id, id FROM t1; +Warnings: +Note 1050 Table 'v1' already exists +SHOW CREATE TABLE v1; +View Create View character_set_client collation_connection +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t2`.`id` AS `id` from `t2` utf8mb4 utf8mb4_0900_ai_ci +SELECT * FROM t2; +id +2 +2 +SELECT * FROM v1; +id +2 +2 +DROP VIEW v1; +CREATE TEMPORARY TABLE tt1 AS SELECT id FROM t2; +CREATE TEMPORARY TABLE IF NOT EXISTS tt1(a int, b int) SELECT id, id FROM t1; +Warnings: +Note 1050 Table 'tt1' already exists +SELECT * FROM t2; +id +2 +2 +SELECT * FROM tt1; +id +2 +2 +DROP TEMPORARY TABLE tt1; +DROP TABLE t1, t2; +# +# WL#5370 "Changing 'CREATE TABLE IF NOT EXISTS ... SELECT' +# behaviour. +# +# +# 1. Basic case: a base table. +# +create table if not exists t1 (a int) select 1 as a; +select * from t1; +a +1 +create table t1 (a int) select 2 as a; +ERROR 42S01: Table 't1' already exists +select * from t1; +a +1 +# Produces an essential warning ER_TABLE_EXISTS. +create table if not exists t1 (a int) select 2 as a; +Warnings: +Note 1050 Table 't1' already exists +# No new data in t1. +select * from t1; +a +1 +drop table t1; +# +# 2. A temporary table. +# +create temporary table if not exists t1 (a int) select 1 as a; +select * from t1; +a +1 +create temporary table t1 (a int) select 2 as a; +ERROR 42S01: Table 't1' already exists +select * from t1; +a +1 +# An essential warning. +create temporary table if not exists t1 (a int) select 2 as a; +Warnings: +Note 1050 Table 't1' already exists +# No new data in t1. +select * from t1; +a +1 +drop temporary table t1; +# +# 3. Creating a base table in presence of a temporary table. +# +create table t1 (a int); +# Create a view for convenience of querying t1 shadowed by a temp. +create view v1 as select a from t1; +drop table t1; +create temporary table t1 (a int) select 1 as a; +create table if not exists t1 (a int) select 2 as a; +select * from t1; +a +1 +select * from v1; +a +2 +# Note: an essential warning. +create table if not exists t1 (a int) select 3 as a; +Warnings: +Note 1050 Table 't1' already exists +select * from t1; +a +1 +select * from v1; +a +2 +drop temporary table t1; +select * from t1; +a +2 +drop view v1; +drop table t1; +# +# 4. Creating a temporary table in presence of a base table. +# +create table t1 (a int) select 1 as a; +create temporary table if not exists t1 select 2 as a; +select * from t1; +a +2 +# Note: an essential warning. +create temporary table if not exists t1 select 3 as a; +Warnings: +Note 1050 Table 't1' already exists +select * from t1; +a +2 +drop temporary table t1; +select * from t1; +a +1 +drop table t1; +# +# 5. Creating a base table in presence of an updatable view. +# +create table t2 (a int unique); +create view t1 as select a from t2; +insert into t1 (a) values (1); +create table t1 (a int); +ERROR 42S01: Table 't1' already exists +# Note: an essential warning. +create table if not exists t1 (a int); +Warnings: +Note 1050 Table 't1' already exists +create table t1 (a int) select 2 as a; +ERROR 42S01: Table 't1' already exists +select * from t1; +a +1 +# Note: an essential warning. +create table if not exists t1 (a int) select 2 as a; +Warnings: +Note 1050 Table 't1' already exists +select * from t1; +a +1 +select * from t2; +a +1 +create temporary table if not exists t1 (a int) select 3 as a; +select * from t1; +a +3 +select * from t2; +a +1 +# Note: an essential warning. +create temporary table if not exists t1 (a int) select 4 as a; +Warnings: +Note 1050 Table 't1' already exists +select * from t1; +a +3 +select * from t2; +a +1 +drop temporary table t1; +# +# Repeating the test with a non-updatable view. +# +drop view t1; +create view t1 as select a + 5 as a from t2; +insert into t1 (a) values (1); +ERROR HY000: Column 'a' is not updatable +update t1 set a=3 where a=2; +ERROR HY000: Column 'a' is not updatable +create table t1 (a int); +ERROR 42S01: Table 't1' already exists +# Note: an essential warning. +create table if not exists t1 (a int); +Warnings: +Note 1050 Table 't1' already exists +create table t1 (a int) select 2 as a; +ERROR 42S01: Table 't1' already exists +select * from t1; +a +6 +# Note: an essential warning. +create table if not exists t1 (a int) select 2 as a; +Warnings: +Note 1050 Table 't1' already exists +select * from t1; +a +6 +select * from t2; +a +1 +create temporary table if not exists t1 (a int) select 3 as a; +select * from t1; +a +3 +select * from t2; +a +1 +# Note: an essential warning. +create temporary table if not exists t1 (a int) select 4 as a; +Warnings: +Note 1050 Table 't1' already exists +select * from t1; +a +3 +select * from t2; +a +1 +drop temporary table t1; +drop view t1; +drop table t2; +# +# Repeating the test with a view select a constant number +# +create view t1 as select 1 as a; +insert into t1 (a) values (1); +ERROR HY000: The target table t1 of the INSERT is not insertable-into +update t1 set a=3 where a=2; +ERROR HY000: The target table t1 of the UPDATE is not updatable +create table t1 (a int); +ERROR 42S01: Table 't1' already exists +# Note: an essential warning. +create table if not exists t1 (a int); +Warnings: +Note 1050 Table 't1' already exists +create table t1 (a int) select 2 as a; +ERROR 42S01: Table 't1' already exists +select * from t1; +a +1 +# Note: an essential warning. +create table if not exists t1 (a int) select 2 as a; +Warnings: +Note 1050 Table 't1' already exists +select * from t1; +a +1 +create temporary table if not exists t1 (a int) select 3 as a; +select * from t1; +a +3 +# Note: an essential warning. +create temporary table if not exists t1 (a int) select 4 as a; +Warnings: +Note 1050 Table 't1' already exists +select * from t1; +a +3 +drop temporary table t1; +drop view t1; +# +# 6. Test of unique_table(). +# +create table t1 (a int) select 1 as a; +create temporary table if not exists t1 (a int) select * from t1; +create temporary table if not exists t1 (a int) select * from t1; +ERROR HY000: Can't reopen table: 't1' +select * from t1; +a +1 +drop temporary table t1; +select * from t1; +a +1 +drop table t1; +create temporary table t1 (a int) select 1 as a; +create table if not exists t1 (a int) select * from t1; +create table if not exists t1 (a int) select * from t1; +Warnings: +Note 1050 Table 't1' already exists +select * from t1; +a +1 +drop temporary table t1; +select * from t1; +a +1 +drop table t1; +create table if not exists t1 (a int) select * from t1; +ERROR 42S02: Table 'test.t1' doesn't exist +# +# 7. Test of non-matching columns, REPLACE and IGNORE. +# +create table t1 (a int) select 1 as b, 2 as c; +select * from t1; +a b c +NULL 1 2 +drop table t1; +create table if not exists t1 (a int, b date, c date) select 1 as b, 2 as c; +Warnings: +Warning 1265 Data truncated for column 'b' at row 1 +Warning 1265 Data truncated for column 'c' at row 1 +select * from t1; +a b c +NULL 0000-00-00 0000-00-00 +drop table t1; +set @@session.sql_mode=default; +create table if not exists t1 (a int, b date, c date) select 1 as b, 2 as c; +ERROR 22007: Incorrect date value: '1' for column 'b' at row 1 +select * from t1; +ERROR 42S02: Table 'test.t1' doesn't exist +create table if not exists t1 (a int, b date, c date) +replace select 1 as b, 2 as c; +ERROR 22007: Incorrect date value: '1' for column 'b' at row 1 +select * from t1; +ERROR 42S02: Table 'test.t1' doesn't exist +create table if not exists t1 (a int, b date, c date) +ignore select 1 as b, 2 as c; +Warnings: +Warning 1265 Data truncated for column 'b' at row 1 +Warning 1265 Data truncated for column 'c' at row 1 +select * from t1; +a b c +NULL 0000-00-00 0000-00-00 +drop table t1; +create table if not exists t1 (a int unique, b int) +replace select 1 as a, 1 as b union select 1 as a, 2 as b; +select * from t1; +a b +1 2 +drop table t1; +create table if not exists t1 (a int unique, b int) +ignore select 1 as a, 1 as b union select 1 as a, 2 as b; +Warnings: +Warning 1062 Duplicate entry '1' for key 't1.a' +select * from t1; +a b +1 1 +drop table t1; +# +# +# WL#5576 Prohibit CREATE TABLE ... SELECT to modify other tables +# +create function f() +returns int +begin +insert into t2 values(1); +return 1; +end| +# +# 1. The function updates a base table +# +create table t2(c1 int); +create table t1 select f(); +ERROR HY000: Can't update table 't2' while 't1' is being created. +create temporary table t1 select f(); +ERROR HY000: Can't update table 't2' while 't1' is being created. +drop table t2; +# +# 2. The function updates a view which derives from a base table +# +create table t3(c1 int); +create view t2 as select c1 from t3; +create table t1 select f(); +ERROR HY000: Can't update table 't2' while 't1' is being created. +create temporary table t1 select f(); +ERROR HY000: Can't update table 't2' while 't1' is being created. +drop view t2; +# +# 3. The function updates a view which derives from two base tables +# +create table t4(c1 int); +create view t2 as select t3.c1 as c1 from t3, t4; +create table t1 select f(); +ERROR HY000: Can't update table 't2' while 't1' is being created. +create temporary table t1 select f(); +ERROR HY000: Can't update table 't2' while 't1' is being created. +drop view t2; +drop tables t3, t4; +# +# 4. The function updates a view which selects a constant number +# +create view t2 as select 1; +create table t1 select f(); +ERROR HY000: Can't update table 't2' while 't1' is being created. +create temporary table t1 select f(); +ERROR HY000: Can't update table 't2' while 't1' is being created. +drop view t2; +drop function f; +# +# BUG#11762377 - 54963: ENHANCE THE ERROR MESSAGE TO +# REDUCE USER CONFUSION +# +CREATE TABLE t1 (v varchar(65535) CHARACTER SET latin1); +ERROR 42000: Row size too large. The maximum row size for the used table type, not counting BLOBs, is 65535. This includes storage overhead, check the manual. You have to change some columns to TEXT or BLOBs +# +# Bug#11746295 - 25168: "INCORRECT TABLE NAME" INSTEAD OF "IDENTIFIER TOO +# LONG" IF TABLE NAME > 64 CHARACTERS +# +CREATE TABLE t01234567890123456789012345678901234567890123456789012345678901234567890123456789(a int); +ERROR 42000: Identifier name 't01234567890123456789012345678901234567890123456789012345678901234567890123456789' is too long +CREATE DATABASE t01234567890123456789012345678901234567890123456789012345678901234567890123456789; +ERROR 42000: Identifier name 't01234567890123456789012345678901234567890123456789012345678901234567890123456789' is too long +# +# Bug #20573701 DROP DATABASE ASSERT ON DEBUG WHEN OTHER FILES PRESENT IN +# DB FOLDER. +# +CREATE DATABASE db_with_no_tables_and_an_unrelated_file_in_data_directory; +DROP DATABASE db_with_no_tables_and_an_unrelated_file_in_data_directory; +ERROR HY000: Error dropping database (can't rmdir './db_with_no_tables_and_an_unrelated_file_in_data_directory/', errno: ## - ...) +DROP DATABASE db_with_no_tables_and_an_unrelated_file_in_data_directory; +CREATE DATABASE db_with_tables_and_an_unrelated_file_in_data_directory; +DROP DATABASE db_with_tables_and_an_unrelated_file_in_data_directory; +ERROR HY000: Error dropping database (can't rmdir './db_with_tables_and_an_unrelated_file_in_data_directory/', errno: ## - ...) +DROP DATABASE db_with_tables_and_an_unrelated_file_in_data_directory; +DROP DATABASE db_created_with_mkdir_and_an_unrelated_file_in_data_directory; +ERROR HY000: Schema 'db_created_with_mkdir_and_an_unrelated_file_in_data_directory' does not exist, but schema directory './db_created_with_mkdir_and_an_unrelated_file_in_data_directory/' was found. This must be resolved manually (e.g. by moving the schema directory to another location). +# +# Bug#20857556: IMPROPER ERROR DURING CREATE TABLE +# +# Without the patch ER_WRONG_TABLE_NAME was getting reported. +CREATE TABLE t1 (id INT) INDEX DIRECTORY = 'a#######################################################b#######################################################################################b#####################################################################################b######################################################################################b######################################################################################b#############################################################################################################'; +ERROR HY000: The path specified for INDEX DIRECTORY is too long. +CREATE TABLE t2 (id INT NOT NULL, name VARCHAR(30)) +ENGINE = InnoDB +PARTITION BY RANGE (id) ( +PARTITION p0 VALUES LESS THAN (10) INDEX DIRECTORY = 'a#######################################################b#######################################################################################b#####################################################################################b######################################################################################b######################################################################################b#############################################################################################################' +); +ERROR HY000: The path specified for INDEX DIRECTORY is too long. +CREATE TABLE t3 (id INT) INDEX DIRECTORY = 'test'; +ERROR HY000: Incorrect path value: 'test' +CREATE TABLE t4 (id INT NOT NULL, name VARCHAR(30)) +ENGINE = InnoDB +PARTITION BY RANGE (id) ( +PARTITION p0 VALUES LESS THAN (10) INDEX DIRECTORY = 'test' +); +ERROR HY000: Incorrect path value: 'test' +# +# BUG 27516741 - MYSQL SERVER DOES NOT WRITE INNODB ROW_TYPE +# TO .FRM FILE WHEN DEFAULT USED +# Set up. +SET @saved_innodb_default_row_format= @@global.innodb_default_row_format; +SET @saved_show_create_table_verbosity= @@session.show_create_table_verbosity; +# Current InnoDB default row format and 'show_create_table_verbosity' +# values respectively. +SELECT @@global.innodb_default_row_format; +@@global.innodb_default_row_format +dynamic +SELECT @@session.show_create_table_verbosity; +@@session.show_create_table_verbosity +0 +CREATE TABLE t1(fld1 INT) ENGINE= InnoDB; +CREATE TABLE t2(fld1 INT) ENGINE= InnoDB, ROW_FORMAT= DEFAULT; +SET GLOBAL innodb_default_row_format= 'COMPACT'; +CREATE TABLE t3(fld1 INT) ENGINE= InnoDB; +CREATE TABLE t4(fl1 INT) ENGINE= InnoDB, ROW_FORMAT= COMPRESSED; +# Test without show_create_table_verbosity enabled. +# Row format used is not displayed for all tables +# except t4 where it is explicitly specified. +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `fld1` int DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `fld1` int DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SHOW CREATE TABLE t3; +Table Create Table +t3 CREATE TABLE `t3` ( + `fld1` int DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SHOW CREATE TABLE t4; +Table Create Table +t4 CREATE TABLE `t4` ( + `fl1` int DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=COMPRESSED +# Test with show_create_table_verbosity enabled. +# Row format used is displayed for all tables. +SET SESSION show_create_table_verbosity= ON; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `fld1` int DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=DYNAMIC +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `fld1` int DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=DYNAMIC +SHOW CREATE TABLE t3; +Table Create Table +t3 CREATE TABLE `t3` ( + `fld1` int DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=COMPACT +SHOW CREATE TABLE t4; +Table Create Table +t4 CREATE TABLE `t4` ( + `fl1` int DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=COMPRESSED +SET GLOBAL innodb_default_row_format= 'DYNAMIC'; +SET SESSION show_create_table_verbosity= OFF; +# Test with corresponding temporary tables. +CREATE TEMPORARY TABLE t1(fld1 INT) ENGINE= InnoDB; +CREATE TEMPORARY TABLE t2(fld1 INT) ENGINE= InnoDB, ROW_FORMAT= DEFAULT; +SET GLOBAL innodb_default_row_format= 'COMPACT'; +CREATE TEMPORARY TABLE t3(fld1 INT) ENGINE= InnoDB; +CREATE TEMPORARY TABLE t4(fl1 INT) ENGINE= InnoDB, ROW_FORMAT= REDUNDANT; +# Test without show_create_table_verbosity enabled. +# Row format used is not displayed for all tables +# except t4 where it is explicitly specified. +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TEMPORARY TABLE `t1` ( + `fld1` int DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TEMPORARY TABLE `t2` ( + `fld1` int DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SHOW CREATE TABLE t3; +Table Create Table +t3 CREATE TEMPORARY TABLE `t3` ( + `fld1` int DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SHOW CREATE TABLE t4; +Table Create Table +t4 CREATE TEMPORARY TABLE `t4` ( + `fl1` int DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=REDUNDANT +# Test with show_create_table_verbosity enabled. +# Row format used is displayed for all tables. +SET SESSION show_create_table_verbosity= ON; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TEMPORARY TABLE `t1` ( + `fld1` int DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=DYNAMIC +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TEMPORARY TABLE `t2` ( + `fld1` int DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=DYNAMIC +SHOW CREATE TABLE t3; +Table Create Table +t3 CREATE TEMPORARY TABLE `t3` ( + `fld1` int DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=COMPACT +SHOW CREATE TABLE t4; +Table Create Table +t4 CREATE TEMPORARY TABLE `t4` ( + `fl1` int DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=REDUNDANT +# Clean up. +DROP TABLE t1, t2, t3, t4; +DROP TABLE t1, t2, t3, t4; +SET GLOBAL innodb_default_row_format= @saved_innodb_default_row_format; +SET SESSION show_create_table_verbosity= @saved_show_create_table_verbosity; +# +# Bug#27592803: ASSERTION FAILED: RC == TYPE_OK, +# +# Make sure that it is possible to create enums using binary string +# values that are not valid utf8 +CREATE TABLE t0(a ENUM('aaa', 'bbb', 'ccc') BYTE); +SHOW CREATE TABLE t0; +Table Create Table +t0 CREATE TABLE `t0` ( + `a` enum('aaa','bbb','ccc') CHARACTER SET binary COLLATE binary DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SHOW COLUMNS FROM t0; +Field Type Null Key Default Extra +a enum('aaa','bbb','ccc') YES NULL +# Tables t1 and t2 uses a binary value that is legal as utf8, so they +# would not trigger an assert. +CREATE TABLE t1(a ENUM( b'1001001')); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` enum('I') DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SHOW COLUMNS FROM t1; +Field Type Null Key Default Extra +a enum('I') YES NULL +CREATE TABLE t2(a ENUM( b'1001001') BYTE); +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `a` enum('I') CHARACTER SET binary COLLATE binary DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SHOW COLUMNS FROM t2; +Field Type Null Key Default Extra +a enum('I') YES NULL +# Tables t3 - t6 contains binary values that are not valid utf8 +# which would previously result in assert. With the fix we get the hex +# representation of the binary value instead. +CREATE TABLE t3(a ENUM( b'10010010') BYTE); +SHOW CREATE TABLE t3; +Table Create Table +t3 CREATE TABLE `t3` ( + `a` enum(x'92') CHARACTER SET binary COLLATE binary DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SHOW COLUMNS FROM t3; +Field Type Null Key Default Extra +a enum(x'92') YES NULL +CREATE TABLE t4(a ENUM( b'1001001101101111') BYTE); +SHOW CREATE TABLE t4; +Table Create Table +t4 CREATE TABLE `t4` ( + `a` enum(x'936f') CHARACTER SET binary COLLATE binary DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SHOW COLUMNS FROM t4; +Field Type Null Key Default Extra +a enum(x'936f') YES NULL +CREATE TABLE t5(a ENUM( b'10010011011011111111011000011') BYTE); +SHOW CREATE TABLE t5; +Table Create Table +t5 CREATE TABLE `t5` ( + `a` enum(x'126dfec3') CHARACTER SET binary COLLATE binary DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SHOW COLUMNS FROM t5; +Field Type Null Key Default Extra +a enum(x'126dfec3') YES NULL +CREATE TABLE t6 (a INT); +ALTER TABLE t6 +MODIFY COLUMN a ENUM( b'10010011011011111111011000011') BYTE UNIQUE FIRST; +SHOW CREATE TABLE t6; +Table Create Table +t6 CREATE TABLE `t6` ( + `a` enum(x'126dfec3') CHARACTER SET binary COLLATE binary DEFAULT NULL, + UNIQUE KEY `a` (`a`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SHOW COLUMNS FROM t6; +Field Type Null Key Default Extra +a enum(x'126dfec3') YES UNI NULL +DROP TABLE t6; +DROP TABLE t5; +DROP TABLE t4; +DROP TABLE t3; +DROP TABLE t2; +DROP TABLE t1; +DROP TABLE t0; +# Bug#17468242/Wl#11807: Provide an option to prevent creation of tables +# without a unique/pk +# +SET GLOBAL sql_require_primary_key= ON; +SELECT @@global.sql_require_primary_key; +@@global.sql_require_primary_key +1 +# Checking variable at session level +# Should not affect this session +SELECT @@session.sql_require_primary_key; +@@session.sql_require_primary_key +0 +CREATE TABLE t1(i INT); +CREATE TABLE t2(i INT PRIMARY KEY, j INT); +ALTER TABLE t2 DROP COLUMN i; +DROP TABLE t2; +DROP TABLE t1; +# Create new connection which will inherit global setting +SELECT @@session.sql_require_primary_key; +@@session.sql_require_primary_key +1 +CREATE TABLE t1(i INT); +ERROR HY000: Unable to create or change a table without a primary key, when the system variable 'sql_require_primary_key' is set. Add a primary key to the table or unset this variable to avoid this message. Note that tables without a primary key can cause performance problems in row-based replication, so please consult your DBA before changing this setting. +CREATE TABLE t1(i INT PRIMARY KEY, j INT); +ALTER TABLE t1 DROP COLUMN i; +ERROR HY000: Unable to create or change a table without a primary key, when the system variable 'sql_require_primary_key' is set. Add a primary key to the table or unset this variable to avoid this message. Note that tables without a primary key can cause performance problems in row-based replication, so please consult your DBA before changing this setting. +DROP TABLE t1; +# Overdide inherited global setting locally +SET SESSION sql_require_primary_key= OFF; +SELECT @@session.sql_require_primary_key; +@@session.sql_require_primary_key +0 +CREATE TABLE t1(i INT); +CREATE TABLE t2(i INT PRIMARY KEY, j INT); +ALTER TABLE t2 DROP COLUMN i; +DROP TABLE t2; +DROP TABLE t1; +# Verify CREATE LIKE +CREATE TABLE t1(i INT); +SET SESSION sql_require_primary_key= ON; +CREATE TABLE t2 LIKE t1; +ERROR HY000: Unable to create or change a table without a primary key, when the system variable 'sql_require_primary_key' is set. Add a primary key to the table or unset this variable to avoid this message. Note that tables without a primary key can cause performance problems in row-based replication, so please consult your DBA before changing this setting. +# Verify CREATE AS SELECT ... +CREATE TABLE t3 (I INT PRIMARY KEY); +CREATE TABLE t4 AS SELECT 1; +ERROR HY000: Unable to create or change a table without a primary key, when the system variable 'sql_require_primary_key' is set. Add a primary key to the table or unset this variable to avoid this message. Note that tables without a primary key can cause performance problems in row-based replication, so please consult your DBA before changing this setting. +CREATE TABLE t4 AS SELECT * FROM t1; +ERROR HY000: Unable to create or change a table without a primary key, when the system variable 'sql_require_primary_key' is set. Add a primary key to the table or unset this variable to avoid this message. Note that tables without a primary key can cause performance problems in row-based replication, so please consult your DBA before changing this setting. +# PK attribute is not propagated by CREATE AS +CREATE TABLE t4 AS SELECT * FROM t3; +ERROR HY000: Unable to create or change a table without a primary key, when the system variable 'sql_require_primary_key' is set. Add a primary key to the table or unset this variable to avoid this message. Note that tables without a primary key can cause performance problems in row-based replication, so please consult your DBA before changing this setting. +# PK attribute specified explicitly is ok +CREATE TABLE t4(i INT PRIMARY KEY) AS SELECT * FROM t3; +SHOW CREATE TABLE t4; +Table Create Table +t4 CREATE TABLE `t4` ( + `I` int NOT NULL, + PRIMARY KEY (`I`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +# Drop and add PK in same ALTER statement should be ok +CREATE TABLE t5(i INT PRIMARY KEY, j INT); +ALTER TABLE t5 DROP PRIMARY KEY, ADD CONSTRAINT PRIMARY KEY (j); +# Restriction also applies to temporary tables +CREATE TEMPORARY TABLE t6(i INT); +ERROR HY000: Unable to create or change a table without a primary key, when the system variable 'sql_require_primary_key' is set. Add a primary key to the table or unset this variable to avoid this message. Note that tables without a primary key can cause performance problems in row-based replication, so please consult your DBA before changing this setting. +# Cleanup +DROP TABLE t5; +DROP TABLE t4; +DROP TABLE t3; +DROP TABLE t1; +# Create user without SUPER privilege. +CREATE USER subuser@localhost; +REVOKE SUPER ON *.* FROM subuser@localhost; +Warnings: +Warning 1287 The SUPER privilege identifier is deprecated +# Connect as user subuser@localhost; +SET SESSION sql_require_primary_key= OFF; +ERROR 42000: Access denied; you need (at least one of) the SUPER, SYSTEM_VARIABLES_ADMIN or SESSION_VARIABLES_ADMIN privilege(s) for this operation +SET GLOBAL sql_require_primary_key= OFF; +ERROR 42000: Access denied; you need (at least one of) the SUPER or SYSTEM_VARIABLES_ADMIN privilege(s) for this operation +DROP USER subuser@localhost; +SET GLOBAL sql_require_primary_key= OFF; +# +# Bug#28022129: NOW() DOESN?T HONOR NO_ZERO_DATE SQL_MODE +# +SET @saved_mode= @@sql_mode; +CREATE TABLE t1(fld1 int); +# NO_ZERO_DATE and STRICT SQL mode. +CREATE TABLE t2 SELECT fld1, CURDATE() fld2 FROM t1; +CREATE TABLE t3 AS SELECT now(); +# With patch, zero date is not generated as default. +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `fld1` int DEFAULT NULL, + `fld2` date NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SHOW CREATE TABLE t3; +Table Create Table +t3 CREATE TABLE `t3` ( + `now()` datetime NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +DROP TABLE t2, t3; +SET SQL_MODE= "NO_ZERO_DATE"; +Warnings: +Warning 3135 'NO_ZERO_DATE', 'NO_ZERO_IN_DATE' and 'ERROR_FOR_DIVISION_BY_ZERO' sql modes should be used with strict mode. They will be merged with strict mode in a future release. +# NO_ZERO_DATE SQL mode. +CREATE TABLE t2 SELECT fld1, CURDATE() fld2 FROM t1; +CREATE TABLE t3 AS SELECT now(); +# Zero date is generated as default in non strict mode. +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `fld1` int DEFAULT NULL, + `fld2` date NOT NULL DEFAULT '0000-00-00' +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SHOW CREATE TABLE t3; +Table Create Table +t3 CREATE TABLE `t3` ( + `now()` datetime NOT NULL DEFAULT '0000-00-00 00:00:00' +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +DROP TABLE t1, t2, t3; +SET SQL_MODE= DEFAULT; +# Test cases added for coverage. +CREATE TABLE t1(fld1 DATETIME NOT NULL DEFAULT '1111:11:11'); +# CREATE TABLE..SELECT using fields of another table. +CREATE TABLE t2 AS SELECT * FROM t1; +# Default value is copied from the source table column. +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `fld1` datetime NOT NULL DEFAULT '1111-11-11 00:00:00' +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +DROP TABLE t1, t2; +# CREATE TABLE..SELECT based on trigger fields. +CREATE TABLE t1 (fld1 INT, fld2 DATETIME DEFAULT '1211:1:1'); +CREATE TRIGGER t1_bi BEFORE INSERT ON t1 +FOR EACH ROW +BEGIN +CREATE TEMPORARY TABLE t2 AS SELECT NEW.fld1, NEW.fld2; +END +| +INSERT INTO t1 VALUES (1, '1111:11:11'); +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TEMPORARY TABLE `t2` ( + `fld1` int DEFAULT NULL, + `fld2` datetime DEFAULT '1211-01-01 00:00:00' +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +DROP TABLE t1; +DROP TEMPORARY TABLE t2; +SET SQL_MODE= @saved_mode; +# +# Bug #29283055: CREATE TABLE IF NOT EXISTS .. SHOULD NOT ALWAYS +# FAIL ON SQL_REQUIRE_PRIMARY_KEY +# +# Create table without PK +CREATE TABLE t1(i INT); +SET SESSION sql_require_primary_key=1; +# This must not fail when t1 already exists, even if it does not have +# a pk +CREATE TABLE IF NOT EXISTS t1(i INT); +Warnings: +Note 1050 Table 't1' already exists +# Cleanup +SET SESSION sql_require_primary_key=DEFAULT; +DROP TABLE t1; +# +# WL#13127: Deprecate integer display width and ZEROFILL option +# +CREATE TABLE types(id INT PRIMARY KEY AUTO_INCREMENT, name VARCHAR(100)); +INSERT INTO types(name) VALUES +('TINYINT'), ('SMALLINT'), ('MEDIUMINT'), ('INT'), ('BIGINT'), +('TINYINT(10)'), ('SMALLINT(10)'), ('MEDIUMINT(10)'), ('INT(10)'), ('BIGINT(10)'), +('DOUBLE'), ('FLOAT'), ('DECIMAL(5, 2)'), ('YEAR'); +CREATE TABLE t1(col TINYINT ZEROFILL); +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +CREATE TABLE t2 LIKE t1; +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +CREATE TABLE t3 AS SELECT * FROM t1; +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +ALTER TABLE t1 ADD COLUMN col2 VARCHAR(10); +ALTER TABLE t1 MODIFY COLUMN col2 TINYINT ZEROFILL; +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +ALTER TABLE t1 ADD COLUMN col3 TINYINT ZEROFILL; +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +DROP TABLE t1, t2, t3; +CREATE FUNCTION f1(x TINYINT ZEROFILL) RETURNS INT DETERMINISTIC RETURN 1; +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +CREATE FUNCTION f2(x INT) RETURNS TINYINT ZEROFILL DETERMINISTIC RETURN 1; +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +CREATE FUNCTION f3() RETURNS INT DETERMINISTIC +BEGIN +DECLARE x TINYINT ZEROFILL DEFAULT 1; +RETURN x; +END// +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +DROP FUNCTION f1; +DROP FUNCTION f2; +DROP FUNCTION f3; +CREATE TABLE t1(col SMALLINT ZEROFILL); +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +CREATE TABLE t2 LIKE t1; +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +CREATE TABLE t3 AS SELECT * FROM t1; +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +ALTER TABLE t1 ADD COLUMN col2 VARCHAR(10); +ALTER TABLE t1 MODIFY COLUMN col2 SMALLINT ZEROFILL; +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +ALTER TABLE t1 ADD COLUMN col3 SMALLINT ZEROFILL; +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +DROP TABLE t1, t2, t3; +CREATE FUNCTION f1(x SMALLINT ZEROFILL) RETURNS INT DETERMINISTIC RETURN 1; +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +CREATE FUNCTION f2(x INT) RETURNS SMALLINT ZEROFILL DETERMINISTIC RETURN 1; +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +CREATE FUNCTION f3() RETURNS INT DETERMINISTIC +BEGIN +DECLARE x SMALLINT ZEROFILL DEFAULT 1; +RETURN x; +END// +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +DROP FUNCTION f1; +DROP FUNCTION f2; +DROP FUNCTION f3; +CREATE TABLE t1(col MEDIUMINT ZEROFILL); +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +CREATE TABLE t2 LIKE t1; +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +CREATE TABLE t3 AS SELECT * FROM t1; +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +ALTER TABLE t1 ADD COLUMN col2 VARCHAR(10); +ALTER TABLE t1 MODIFY COLUMN col2 MEDIUMINT ZEROFILL; +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +ALTER TABLE t1 ADD COLUMN col3 MEDIUMINT ZEROFILL; +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +DROP TABLE t1, t2, t3; +CREATE FUNCTION f1(x MEDIUMINT ZEROFILL) RETURNS INT DETERMINISTIC RETURN 1; +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +CREATE FUNCTION f2(x INT) RETURNS MEDIUMINT ZEROFILL DETERMINISTIC RETURN 1; +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +CREATE FUNCTION f3() RETURNS INT DETERMINISTIC +BEGIN +DECLARE x MEDIUMINT ZEROFILL DEFAULT 1; +RETURN x; +END// +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +DROP FUNCTION f1; +DROP FUNCTION f2; +DROP FUNCTION f3; +CREATE TABLE t1(col INT ZEROFILL); +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +CREATE TABLE t2 LIKE t1; +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +CREATE TABLE t3 AS SELECT * FROM t1; +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +ALTER TABLE t1 ADD COLUMN col2 VARCHAR(10); +ALTER TABLE t1 MODIFY COLUMN col2 INT ZEROFILL; +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +ALTER TABLE t1 ADD COLUMN col3 INT ZEROFILL; +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +DROP TABLE t1, t2, t3; +CREATE FUNCTION f1(x INT ZEROFILL) RETURNS INT DETERMINISTIC RETURN 1; +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +CREATE FUNCTION f2(x INT) RETURNS INT ZEROFILL DETERMINISTIC RETURN 1; +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +CREATE FUNCTION f3() RETURNS INT DETERMINISTIC +BEGIN +DECLARE x INT ZEROFILL DEFAULT 1; +RETURN x; +END// +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +DROP FUNCTION f1; +DROP FUNCTION f2; +DROP FUNCTION f3; +CREATE TABLE t1(col BIGINT ZEROFILL); +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +CREATE TABLE t2 LIKE t1; +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +CREATE TABLE t3 AS SELECT * FROM t1; +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +ALTER TABLE t1 ADD COLUMN col2 VARCHAR(10); +ALTER TABLE t1 MODIFY COLUMN col2 BIGINT ZEROFILL; +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +ALTER TABLE t1 ADD COLUMN col3 BIGINT ZEROFILL; +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +DROP TABLE t1, t2, t3; +CREATE FUNCTION f1(x BIGINT ZEROFILL) RETURNS INT DETERMINISTIC RETURN 1; +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +CREATE FUNCTION f2(x INT) RETURNS BIGINT ZEROFILL DETERMINISTIC RETURN 1; +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +CREATE FUNCTION f3() RETURNS INT DETERMINISTIC +BEGIN +DECLARE x BIGINT ZEROFILL DEFAULT 1; +RETURN x; +END// +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +DROP FUNCTION f1; +DROP FUNCTION f2; +DROP FUNCTION f3; +CREATE TABLE t1(col TINYINT(10) ZEROFILL); +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t2 LIKE t1; +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +CREATE TABLE t3 AS SELECT * FROM t1; +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +ALTER TABLE t1 ADD COLUMN col2 VARCHAR(10); +ALTER TABLE t1 MODIFY COLUMN col2 TINYINT(10) ZEROFILL; +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +ALTER TABLE t1 ADD COLUMN col3 TINYINT(10) ZEROFILL; +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +DROP TABLE t1, t2, t3; +CREATE FUNCTION f1(x TINYINT(10) ZEROFILL) RETURNS INT DETERMINISTIC RETURN 1; +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE FUNCTION f2(x INT) RETURNS TINYINT(10) ZEROFILL DETERMINISTIC RETURN 1; +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE FUNCTION f3() RETURNS INT DETERMINISTIC +BEGIN +DECLARE x TINYINT(10) ZEROFILL DEFAULT 1; +RETURN x; +END// +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +DROP FUNCTION f1; +DROP FUNCTION f2; +DROP FUNCTION f3; +CREATE TABLE t1(col SMALLINT(10) ZEROFILL); +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t2 LIKE t1; +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +CREATE TABLE t3 AS SELECT * FROM t1; +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +ALTER TABLE t1 ADD COLUMN col2 VARCHAR(10); +ALTER TABLE t1 MODIFY COLUMN col2 SMALLINT(10) ZEROFILL; +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +ALTER TABLE t1 ADD COLUMN col3 SMALLINT(10) ZEROFILL; +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +DROP TABLE t1, t2, t3; +CREATE FUNCTION f1(x SMALLINT(10) ZEROFILL) RETURNS INT DETERMINISTIC RETURN 1; +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE FUNCTION f2(x INT) RETURNS SMALLINT(10) ZEROFILL DETERMINISTIC RETURN 1; +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE FUNCTION f3() RETURNS INT DETERMINISTIC +BEGIN +DECLARE x SMALLINT(10) ZEROFILL DEFAULT 1; +RETURN x; +END// +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +DROP FUNCTION f1; +DROP FUNCTION f2; +DROP FUNCTION f3; +CREATE TABLE t1(col MEDIUMINT(10) ZEROFILL); +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t2 LIKE t1; +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +CREATE TABLE t3 AS SELECT * FROM t1; +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +ALTER TABLE t1 ADD COLUMN col2 VARCHAR(10); +ALTER TABLE t1 MODIFY COLUMN col2 MEDIUMINT(10) ZEROFILL; +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +ALTER TABLE t1 ADD COLUMN col3 MEDIUMINT(10) ZEROFILL; +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +DROP TABLE t1, t2, t3; +CREATE FUNCTION f1(x MEDIUMINT(10) ZEROFILL) RETURNS INT DETERMINISTIC RETURN 1; +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE FUNCTION f2(x INT) RETURNS MEDIUMINT(10) ZEROFILL DETERMINISTIC RETURN 1; +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE FUNCTION f3() RETURNS INT DETERMINISTIC +BEGIN +DECLARE x MEDIUMINT(10) ZEROFILL DEFAULT 1; +RETURN x; +END// +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +DROP FUNCTION f1; +DROP FUNCTION f2; +DROP FUNCTION f3; +CREATE TABLE t1(col INT(10) ZEROFILL); +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t2 LIKE t1; +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +CREATE TABLE t3 AS SELECT * FROM t1; +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +ALTER TABLE t1 ADD COLUMN col2 VARCHAR(10); +ALTER TABLE t1 MODIFY COLUMN col2 INT(10) ZEROFILL; +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +ALTER TABLE t1 ADD COLUMN col3 INT(10) ZEROFILL; +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +DROP TABLE t1, t2, t3; +CREATE FUNCTION f1(x INT(10) ZEROFILL) RETURNS INT DETERMINISTIC RETURN 1; +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE FUNCTION f2(x INT) RETURNS INT(10) ZEROFILL DETERMINISTIC RETURN 1; +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE FUNCTION f3() RETURNS INT DETERMINISTIC +BEGIN +DECLARE x INT(10) ZEROFILL DEFAULT 1; +RETURN x; +END// +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +DROP FUNCTION f1; +DROP FUNCTION f2; +DROP FUNCTION f3; +CREATE TABLE t1(col BIGINT(10) ZEROFILL); +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t2 LIKE t1; +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +CREATE TABLE t3 AS SELECT * FROM t1; +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +ALTER TABLE t1 ADD COLUMN col2 VARCHAR(10); +ALTER TABLE t1 MODIFY COLUMN col2 BIGINT(10) ZEROFILL; +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +ALTER TABLE t1 ADD COLUMN col3 BIGINT(10) ZEROFILL; +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +DROP TABLE t1, t2, t3; +CREATE FUNCTION f1(x BIGINT(10) ZEROFILL) RETURNS INT DETERMINISTIC RETURN 1; +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE FUNCTION f2(x INT) RETURNS BIGINT(10) ZEROFILL DETERMINISTIC RETURN 1; +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE FUNCTION f3() RETURNS INT DETERMINISTIC +BEGIN +DECLARE x BIGINT(10) ZEROFILL DEFAULT 1; +RETURN x; +END// +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +DROP FUNCTION f1; +DROP FUNCTION f2; +DROP FUNCTION f3; +CREATE TABLE t1(col DOUBLE ZEROFILL); +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +CREATE TABLE t2 LIKE t1; +Warnings: +Warning 1681 UNSIGNED for decimal and floating point data types is deprecated and support for it will be removed in a future release. +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +CREATE TABLE t3 AS SELECT * FROM t1; +Warnings: +Warning 1681 UNSIGNED for decimal and floating point data types is deprecated and support for it will be removed in a future release. +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +ALTER TABLE t1 ADD COLUMN col2 VARCHAR(10); +ALTER TABLE t1 MODIFY COLUMN col2 DOUBLE ZEROFILL; +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +ALTER TABLE t1 ADD COLUMN col3 DOUBLE ZEROFILL; +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +DROP TABLE t1, t2, t3; +CREATE FUNCTION f1(x DOUBLE ZEROFILL) RETURNS INT DETERMINISTIC RETURN 1; +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +CREATE FUNCTION f2(x INT) RETURNS DOUBLE ZEROFILL DETERMINISTIC RETURN 1; +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +CREATE FUNCTION f3() RETURNS INT DETERMINISTIC +BEGIN +DECLARE x DOUBLE ZEROFILL DEFAULT 1; +RETURN x; +END// +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +DROP FUNCTION f1; +DROP FUNCTION f2; +DROP FUNCTION f3; +CREATE TABLE t1(col FLOAT ZEROFILL); +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +CREATE TABLE t2 LIKE t1; +Warnings: +Warning 1681 UNSIGNED for decimal and floating point data types is deprecated and support for it will be removed in a future release. +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +CREATE TABLE t3 AS SELECT * FROM t1; +Warnings: +Warning 1681 UNSIGNED for decimal and floating point data types is deprecated and support for it will be removed in a future release. +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +ALTER TABLE t1 ADD COLUMN col2 VARCHAR(10); +ALTER TABLE t1 MODIFY COLUMN col2 FLOAT ZEROFILL; +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +ALTER TABLE t1 ADD COLUMN col3 FLOAT ZEROFILL; +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +DROP TABLE t1, t2, t3; +CREATE FUNCTION f1(x FLOAT ZEROFILL) RETURNS INT DETERMINISTIC RETURN 1; +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +CREATE FUNCTION f2(x INT) RETURNS FLOAT ZEROFILL DETERMINISTIC RETURN 1; +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +CREATE FUNCTION f3() RETURNS INT DETERMINISTIC +BEGIN +DECLARE x FLOAT ZEROFILL DEFAULT 1; +RETURN x; +END// +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +DROP FUNCTION f1; +DROP FUNCTION f2; +DROP FUNCTION f3; +CREATE TABLE t1(col DECIMAL(5, 2) ZEROFILL); +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +CREATE TABLE t2 LIKE t1; +Warnings: +Warning 1681 UNSIGNED for decimal and floating point data types is deprecated and support for it will be removed in a future release. +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +CREATE TABLE t3 AS SELECT * FROM t1; +Warnings: +Warning 1681 UNSIGNED for decimal and floating point data types is deprecated and support for it will be removed in a future release. +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +ALTER TABLE t1 ADD COLUMN col2 VARCHAR(10); +ALTER TABLE t1 MODIFY COLUMN col2 DECIMAL(5, 2) ZEROFILL; +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +ALTER TABLE t1 ADD COLUMN col3 DECIMAL(5, 2) ZEROFILL; +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +DROP TABLE t1, t2, t3; +CREATE FUNCTION f1(x DECIMAL(5, 2) ZEROFILL) RETURNS INT DETERMINISTIC RETURN 1; +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +CREATE FUNCTION f2(x INT) RETURNS DECIMAL(5, 2) ZEROFILL DETERMINISTIC RETURN 1; +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +CREATE FUNCTION f3() RETURNS INT DETERMINISTIC +BEGIN +DECLARE x DECIMAL(5, 2) ZEROFILL DEFAULT 1; +RETURN x; +END// +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +DROP FUNCTION f1; +DROP FUNCTION f2; +DROP FUNCTION f3; +CREATE TABLE t1(col YEAR ZEROFILL); +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +CREATE TABLE t2 LIKE t1; +CREATE TABLE t3 AS SELECT * FROM t1; +ALTER TABLE t1 ADD COLUMN col2 VARCHAR(10); +ALTER TABLE t1 MODIFY COLUMN col2 YEAR ZEROFILL; +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +ALTER TABLE t1 ADD COLUMN col3 YEAR ZEROFILL; +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +DROP TABLE t1, t2, t3; +CREATE FUNCTION f1(x YEAR ZEROFILL) RETURNS INT DETERMINISTIC RETURN 1; +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +CREATE FUNCTION f2(x INT) RETURNS YEAR ZEROFILL DETERMINISTIC RETURN 1; +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +CREATE FUNCTION f3() RETURNS INT DETERMINISTIC +BEGIN +DECLARE x YEAR ZEROFILL DEFAULT 1; +RETURN x; +END// +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +DROP FUNCTION f1; +DROP FUNCTION f2; +DROP FUNCTION f3; +DROP TABLE types; +# +# WL#13528: Remove integer display width from SHOW CREATE output +# +CREATE TABLE t1( +a TINYINT, +b SMALLINT, +c MEDIUMINT, +d INT, +e BIGINT, +f TINYINT(1), +g SMALLINT(1), +h MEDIUMINT(1), +i INT(1), +j BIGINT(1), +k TINYINT ZEROFILL, +l SMALLINT ZEROFILL, +m MEDIUMINT ZEROFILL, +n INT ZEROFILL, +o BIGINT ZEROFILL +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` tinyint DEFAULT NULL, + `b` smallint DEFAULT NULL, + `c` mediumint DEFAULT NULL, + `d` int DEFAULT NULL, + `e` bigint DEFAULT NULL, + `f` tinyint(1) DEFAULT NULL, + `g` smallint DEFAULT NULL, + `h` mediumint DEFAULT NULL, + `i` int DEFAULT NULL, + `j` bigint DEFAULT NULL, + `k` tinyint(3) unsigned zerofill DEFAULT NULL, + `l` smallint(5) unsigned zerofill DEFAULT NULL, + `m` mediumint(8) unsigned zerofill DEFAULT NULL, + `n` int(10) unsigned zerofill DEFAULT NULL, + `o` bigint(20) unsigned zerofill DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SELECT COLUMN_TYPE FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 't1'; +COLUMN_TYPE +bigint +bigint +bigint(20) unsigned zerofill +int +int +int(10) unsigned zerofill +mediumint +mediumint +mediumint(8) unsigned zerofill +smallint +smallint +smallint(5) unsigned zerofill +tinyint +tinyint(1) +tinyint(3) unsigned zerofill +DESCRIBE t1; +Field Type Null Key Default Extra +a tinyint YES NULL +b smallint YES NULL +c mediumint YES NULL +d int YES NULL +e bigint YES NULL +f tinyint(1) YES NULL +g smallint YES NULL +h mediumint YES NULL +i int YES NULL +j bigint YES NULL +k tinyint(3) unsigned zerofill YES NULL +l smallint(5) unsigned zerofill YES NULL +m mediumint(8) unsigned zerofill YES NULL +n int(10) unsigned zerofill YES NULL +o bigint(20) unsigned zerofill YES NULL +CREATE VIEW v1 AS SELECT * FROM t1; +SELECT COLUMN_TYPE FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'v1'; +COLUMN_TYPE +bigint +bigint +bigint(20) unsigned zerofill +int +int +int(10) unsigned zerofill +mediumint +mediumint +mediumint(8) unsigned zerofill +smallint +smallint +smallint(5) unsigned zerofill +tinyint +tinyint(1) +tinyint(3) unsigned zerofill +DESCRIBE v1; +Field Type Null Key Default Extra +a tinyint YES NULL +b smallint YES NULL +c mediumint YES NULL +d int YES NULL +e bigint YES NULL +f tinyint(1) YES NULL +g smallint YES NULL +h mediumint YES NULL +i int YES NULL +j bigint YES NULL +k tinyint(3) unsigned zerofill YES NULL +l smallint(5) unsigned zerofill YES NULL +m mediumint(8) unsigned zerofill YES NULL +n int(10) unsigned zerofill YES NULL +o bigint(20) unsigned zerofill YES NULL +DROP VIEW v1; +DROP TABLE t1; +CREATE FUNCTION f1(a INT) RETURNS INT RETURN 1; +CREATE FUNCTION f2(a INT ZEROFILL) RETURNS INT ZEROFILL RETURN 1; +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +SHOW CREATE FUNCTION f1; +Function sql_mode Create Function character_set_client collation_connection Database Collation +f1 ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION CREATE DEFINER=`root`@`localhost` FUNCTION `f1`(a INT) RETURNS int +RETURN 1 utf8mb4 utf8mb4_0900_ai_ci utf8mb4_0900_ai_ci +SHOW CREATE FUNCTION f2; +Function sql_mode Create Function character_set_client collation_connection Database Collation +f2 ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION CREATE DEFINER=`root`@`localhost` FUNCTION `f2`(a INT ZEROFILL) RETURNS int(10) unsigned zerofill +RETURN 1 utf8mb4 utf8mb4_0900_ai_ci utf8mb4_0900_ai_ci +SELECT DTD_IDENTIFIER FROM INFORMATION_SCHEMA.ROUTINES WHERE ROUTINE_NAME = 'f1'; +DTD_IDENTIFIER +int +SELECT DTD_IDENTIFIER FROM INFORMATION_SCHEMA.ROUTINES WHERE ROUTINE_NAME = 'f2'; +DTD_IDENTIFIER +int(10) unsigned zerofill +SELECT DTD_IDENTIFIER FROM INFORMATION_SCHEMA.PARAMETERS WHERE SPECIFIC_NAME = 'f1'; +DTD_IDENTIFIER +int +int +SELECT DTD_IDENTIFIER FROM INFORMATION_SCHEMA.PARAMETERS WHERE SPECIFIC_NAME = 'f2'; +DTD_IDENTIFIER +int(10) unsigned zerofill +int(10) unsigned zerofill +DROP FUNCTION f1; +DROP FUNCTION f2; +CREATE PROCEDURE p1(a INT, b INT ZEROFILL) BEGIN END; +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +SHOW CREATE PROCEDURE p1; +Procedure sql_mode Create Procedure character_set_client collation_connection Database Collation +p1 ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION CREATE DEFINER=`root`@`localhost` PROCEDURE `p1`(a INT, b INT ZEROFILL) +BEGIN END utf8mb4 utf8mb4_0900_ai_ci utf8mb4_0900_ai_ci +SELECT DTD_IDENTIFIER FROM INFORMATION_SCHEMA.PARAMETERS WHERE SPECIFIC_NAME = 'p1'; +DTD_IDENTIFIER +int +int(10) unsigned zerofill +DROP PROCEDURE p1; +# +# Bug#30556657: REVERT I_S/SHOW CREATE CHANGES REGARDING TINYINT(1) +# +CREATE TABLE t1(a BOOLEAN, b TINYINT(1), c TINYINT(1) UNSIGNED, d TINYINT(1) ZEROFILL); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` tinyint(1) DEFAULT NULL, + `b` tinyint(1) DEFAULT NULL, + `c` tinyint unsigned DEFAULT NULL, + `d` tinyint(1) unsigned zerofill DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 't1'; +TABLE_CATALOG TABLE_SCHEMA TABLE_NAME COLUMN_NAME ORDINAL_POSITION COLUMN_DEFAULT IS_NULLABLE DATA_TYPE CHARACTER_MAXIMUM_LENGTH CHARACTER_OCTET_LENGTH NUMERIC_PRECISION NUMERIC_SCALE DATETIME_PRECISION CHARACTER_SET_NAME COLLATION_NAME COLUMN_TYPE COLUMN_KEY EXTRA PRIVILEGES COLUMN_COMMENT GENERATION_EXPRESSION SRS_ID +def test t1 a 1 NULL YES tinyint NULL NULL 3 0 NULL NULL NULL tinyint(1) select,insert,update,references NULL +def test t1 b 2 NULL YES tinyint NULL NULL 3 0 NULL NULL NULL tinyint(1) select,insert,update,references NULL +def test t1 c 3 NULL YES tinyint NULL NULL 3 0 NULL NULL NULL tinyint unsigned select,insert,update,references NULL +def test t1 d 4 NULL YES tinyint NULL NULL 3 0 NULL NULL NULL tinyint(1) unsigned zerofill select,insert,update,references NULL +DESCRIBE t1; +Field Type Null Key Default Extra +a tinyint(1) YES NULL +b tinyint(1) YES NULL +c tinyint unsigned YES NULL +d tinyint(1) unsigned zerofill YES NULL +CREATE VIEW v1 AS SELECT * FROM t1; +SELECT COLUMN_TYPE FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'v1'; +COLUMN_TYPE +tinyint unsigned +tinyint(1) +tinyint(1) +tinyint(1) unsigned zerofill +DESCRIBE v1; +Field Type Null Key Default Extra +a tinyint(1) YES NULL +b tinyint(1) YES NULL +c tinyint unsigned YES NULL +d tinyint(1) unsigned zerofill YES NULL +DROP VIEW v1; +DROP TABLE t1; +CREATE FUNCTION f1(a BOOLEAN, b TINYINT(1), c TINYINT(1) UNSIGNED, +d TINYINT(1) ZEROFILL) RETURNS BOOLEAN RETURN 1; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +SHOW CREATE FUNCTION f1; +Function sql_mode Create Function character_set_client collation_connection Database Collation +f1 ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION CREATE DEFINER=`root`@`localhost` FUNCTION `f1`(a BOOLEAN, b TINYINT(1), c TINYINT(1) UNSIGNED, +d TINYINT(1) ZEROFILL) RETURNS tinyint(1) +RETURN 1 utf8mb4 utf8mb4_0900_ai_ci utf8mb4_0900_ai_ci +SELECT DTD_IDENTIFIER FROM INFORMATION_SCHEMA.ROUTINES WHERE ROUTINE_NAME = 'f1'; +DTD_IDENTIFIER +tinyint(1) +SELECT DTD_IDENTIFIER FROM INFORMATION_SCHEMA.PARAMETERS WHERE SPECIFIC_NAME = 'f1'; +DTD_IDENTIFIER +tinyint unsigned +tinyint(1) +tinyint(1) +tinyint(1) +tinyint(1) unsigned zerofill +DROP FUNCTION f1; +CREATE PROCEDURE p1(a BOOLEAN, b TINYINT(1), c TINYINT(1) UNSIGNED, +d TINYINT(1) ZEROFILL) BEGIN END; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +SHOW CREATE PROCEDURE p1; +Procedure sql_mode Create Procedure character_set_client collation_connection Database Collation +p1 ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION CREATE DEFINER=`root`@`localhost` PROCEDURE `p1`(a BOOLEAN, b TINYINT(1), c TINYINT(1) UNSIGNED, +d TINYINT(1) ZEROFILL) +BEGIN END utf8mb4 utf8mb4_0900_ai_ci utf8mb4_0900_ai_ci +SELECT DTD_IDENTIFIER FROM INFORMATION_SCHEMA.PARAMETERS WHERE SPECIFIC_NAME = 'p1'; +DTD_IDENTIFIER +tinyint unsigned +tinyint(1) +tinyint(1) +tinyint(1) unsigned zerofill +DROP PROCEDURE p1; +# +# Bug#32227101: CREATE TABLE PRODUCES CORE +# +# key_block_size = 2^31-1 - rejected by Innodb +CREATE TABLE t1(i INT PRIMARY KEY) KEY_BLOCK_SIZE = 2147483647; +ERROR HY000: Table storage engine for 't1' doesn't have this option +# key_block_size = -(2^31)+1 - rejected by Innodb +CREATE TABLE t1(i INT PRIMARY KEY) KEY_BLOCK_SIZE = -2147483647; +ERROR HY000: Table storage engine for 't1' doesn't have this option +# key_block_size = 2^31 - now rejected by parser +CREATE TABLE t1(i INT PRIMARY KEY) KEY_BLOCK_SIZE = 2147483648; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '2147483648' at line 1 +# key_block_size = -2^31 - now rejected by parser +CREATE TABLE t1(i INT PRIMARY KEY) KEY_BLOCK_SIZE = -2147483648; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '2147483648' at line 1 +# key_block_size = 2^32-1 - now rejected by parser +CREATE TABLE t2(i INT PRIMARY KEY) KEY_BLOCK_SIZE = 4294967295; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '4294967295' at line 1 +# key_block_size = 2^32 - now rejected by parser +CREATE TABLE t3(i INT PRIMARY KEY) KEY_BLOCK_SIZE = 4294967296; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '4294967296' at line 1 +# key_block_size = 3927749503218772669 - now rejected by parser +CREATE TABLE t4( +c0 DECIMAL ZEROFILL UNIQUE KEY STORAGE MEMORY, +c1 DECIMAL ZEROFILL PRIMARY KEY COLUMN_FORMAT DYNAMIC UNIQUE KEY STORAGE MEMORY NOT NULL, +c2 FLOAT ZEROFILL COMMENT 'asdf' COLUMN_FORMAT FIXED NULL STORAGE MEMORY, +c3 TINYINT(120) ZEROFILL STORAGE DISK UNIQUE KEY NULL COMMENT 'asdf' +) CHECKSUM = 1, AUTO_INCREMENT = 1093400439, KEY_BLOCK_SIZE = 3927749503218772669, COMPRESSION = 'NONE'; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '3927749503218772669, COMPRESSION = 'NONE'' at line 6 diff --git a/mysql-test/r/ctype_collate.result-pq b/mysql-test/r/ctype_collate.result-pq new file mode 100644 index 000000000000..6eaad4bf711b --- /dev/null +++ b/mysql-test/r/ctype_collate.result-pq @@ -0,0 +1,868 @@ +DROP TABLE IF EXISTS t1; +DROP TABLE IF EXISTS t2; +CREATE TABLE t1 ( +latin1_f CHAR(32) NOT NULL +) charset latin1; +CREATE TABLE t2 ( +latin1_f CHAR(32) CHARACTER SET latin1 COLLATE koi8r_general_ci NOT NULL +); +ERROR 42000: COLLATION 'koi8r_general_ci' is not valid for CHARACTER SET 'latin1' +CREATE TABLE t2 ( +latin1_f CHAR(32) CHARACTER SET latin1 COLLATE some_non_existing_col NOT NULL +); +ERROR HY000: Unknown collation: 'some_non_existing_col' +INSERT INTO t1 (latin1_f) VALUES (_latin1'A'); +INSERT INTO t1 (latin1_f) VALUES (_latin1'a'); +INSERT INTO t1 (latin1_f) VALUES (_latin1'AD'); +INSERT INTO t1 (latin1_f) VALUES (_latin1'ad'); +INSERT INTO t1 (latin1_f) VALUES (_latin1'AE'); +INSERT INTO t1 (latin1_f) VALUES (_latin1'ae'); +INSERT INTO t1 (latin1_f) VALUES (_latin1'AF'); +INSERT INTO t1 (latin1_f) VALUES (_latin1'af'); +INSERT INTO t1 (latin1_f) VALUES (_latin1'Ä'); +INSERT INTO t1 (latin1_f) VALUES (_latin1'ä'); +INSERT INTO t1 (latin1_f) VALUES (_latin1'Å'); +INSERT INTO t1 (latin1_f) VALUES (_latin1'å'); +INSERT INTO t1 (latin1_f) VALUES (_latin1'B'); +INSERT INTO t1 (latin1_f) VALUES (_latin1'b'); +INSERT INTO t1 (latin1_f) VALUES (_latin1'U'); +INSERT INTO t1 (latin1_f) VALUES (_latin1'u'); +INSERT INTO t1 (latin1_f) VALUES (_latin1'UE'); +INSERT INTO t1 (latin1_f) VALUES (_latin1'ue'); +INSERT INTO t1 (latin1_f) VALUES (_latin1'Ü'); +INSERT INTO t1 (latin1_f) VALUES (_latin1'ü'); +INSERT INTO t1 (latin1_f) VALUES (_latin1'SS'); +INSERT INTO t1 (latin1_f) VALUES (_latin1'ss'); +INSERT INTO t1 (latin1_f) VALUES (_latin1'ß'); +INSERT INTO t1 (latin1_f) VALUES (_latin1'Y'); +INSERT INTO t1 (latin1_f) VALUES (_latin1'y'); +INSERT INTO t1 (latin1_f) VALUES (_latin1'Z'); +INSERT INTO t1 (latin1_f) VALUES (_latin1'z'); +SELECT latin1_f FROM t1 ORDER BY latin1_f, hex(latin1_f); +latin1_f +A +a +AD +ad +AE +ae +AF +af +B +b +SS +ss +U +u +UE +ue +Y +y +Ãœ +ü +Z +z +Ã… +Ã¥ +Ä +ä +ß +SELECT latin1_f FROM t1 ORDER BY latin1_f COLLATE latin1_swedish_ci, hex(latin1_f); +latin1_f +A +a +AD +ad +AE +ae +AF +af +B +b +SS +ss +U +u +UE +ue +Y +y +Ãœ +ü +Z +z +Ã… +Ã¥ +Ä +ä +ß +SELECT latin1_f FROM t1 ORDER BY latin1_f COLLATE latin1_german2_ci, hex(latin1_f); +latin1_f +A +a +Ã… +Ã¥ +AD +ad +AE +ae +Ä +ä +AF +af +B +b +SS +ss +ß +U +u +UE +ue +Ãœ +ü +Y +y +Z +z +SELECT latin1_f FROM t1 ORDER BY latin1_f COLLATE latin1_general_ci, hex(latin1_f); +latin1_f +A +a +AD +ad +AE +ae +AF +af +Ä +ä +Ã… +Ã¥ +B +b +SS +ss +ß +U +u +UE +ue +Ãœ +ü +Y +y +Z +z +SELECT latin1_f FROM t1 ORDER BY latin1_f COLLATE latin1_bin; +latin1_f +A +AD +AE +AF +B +SS +U +UE +Y +Z +a +ad +ae +af +b +ss +u +ue +y +z +Ä +Ã… +Ãœ +ß +ä +Ã¥ +ü +SELECT latin1_f FROM t1 ORDER BY latin1_f COLLATE koi8r_general_ci; +ERROR 42000: COLLATION 'koi8r_general_ci' is not valid for CHARACTER SET 'latin1' +SELECT latin1_f COLLATE latin1_swedish_ci AS latin1_f_as FROM t1 ORDER BY latin1_f_as, hex(latin1_f_as); +latin1_f_as +A +a +AD +ad +AE +ae +AF +af +B +b +SS +ss +U +u +UE +ue +Y +y +Ãœ +ü +Z +z +Ã… +Ã¥ +Ä +ä +ß +SELECT latin1_f COLLATE latin1_german2_ci AS latin1_f_as FROM t1 ORDER BY latin1_f_as, hex(latin1_f_as); +latin1_f_as +A +a +Ã… +Ã¥ +AD +ad +AE +ae +Ä +ä +AF +af +B +b +SS +ss +ß +U +u +UE +ue +Ãœ +ü +Y +y +Z +z +SELECT latin1_f COLLATE latin1_general_ci AS latin1_f_as FROM t1 ORDER BY latin1_f_as, hex(latin1_f_as); +latin1_f_as +A +a +AD +ad +AE +ae +AF +af +Ä +ä +Ã… +Ã¥ +B +b +SS +ss +ß +U +u +UE +ue +Ãœ +ü +Y +y +Z +z +SELECT latin1_f COLLATE latin1_bin AS latin1_f_as FROM t1 ORDER BY latin1_f_as; +latin1_f_as +A +AD +AE +AF +B +SS +U +UE +Y +Z +a +ad +ae +af +b +ss +u +ue +y +z +Ä +Ã… +Ãœ +ß +ä +Ã¥ +ü +SELECT latin1_f COLLATE koi8r_general_ci AS latin1_f_as FROM t1 ORDER BY latin1_f_as; +ERROR 42000: COLLATION 'koi8r_general_ci' is not valid for CHARACTER SET 'latin1' +SELECT latin1_f,count(*) FROM t1 GROUP BY latin1_f ORDER BY latin1_f; +latin1_f count(*) +A 2 +AD 2 +AE 2 +AF 2 +B 2 +SS 2 +U 2 +UE 2 +Ãœ 4 +Z 2 +Ã… 2 +Ä 2 +ß 1 +SELECT latin1_f,count(*) FROM t1 GROUP BY latin1_f COLLATE latin1_swedish_ci ORDER BY latin1_f COLLATE latin1_swedish_ci; +latin1_f count(*) +A 2 +AD 2 +AE 2 +AF 2 +B 2 +SS 2 +U 2 +UE 2 +Ãœ 4 +Z 2 +Ã… 2 +Ä 2 +ß 1 +SELECT latin1_f,count(*) FROM t1 GROUP BY latin1_f COLLATE latin1_german2_ci ORDER BY latin1_f COLLATE latin1_german2_ci; +latin1_f count(*) +A 4 +AD 2 +AE 4 +AF 2 +B 2 +SS 3 +U 2 +UE 4 +Y 2 +Z 2 +SELECT latin1_f,count(*) FROM t1 GROUP BY latin1_f COLLATE latin1_general_ci ORDER BY latin1_f COLLATE latin1_general_ci; +latin1_f count(*) +A 2 +AD 2 +AE 2 +AF 2 +Ä 2 +Ã… 2 +B 2 +SS 2 +ß 1 +U 2 +UE 2 +Ãœ 2 +Y 2 +Z 2 +SELECT latin1_f,count(*) FROM t1 GROUP BY latin1_f COLLATE latin1_bin ORDER BY latin1_f COLLATE latin1_bin; +latin1_f count(*) +A 1 +AD 1 +AE 1 +AF 1 +B 1 +SS 1 +U 1 +UE 1 +Y 1 +Z 1 +a 1 +ad 1 +ae 1 +af 1 +b 1 +ss 1 +u 1 +ue 1 +y 1 +z 1 +Ä 1 +Ã… 1 +Ãœ 1 +ß 1 +ä 1 +Ã¥ 1 +ü 1 +SELECT latin1_f,count(*) FROM t1 GROUP BY latin1_f COLLATE koi8r_general_ci; +ERROR 42000: COLLATION 'koi8r_general_ci' is not valid for CHARACTER SET 'latin1' +SELECT DISTINCT latin1_f FROM t1; +latin1_f +A +AD +AE +AF +B +SS +U +UE +Z +Ä +Ã… +Ãœ +ß +SELECT DISTINCT latin1_f COLLATE latin1_swedish_ci FROM t1; +latin1_f COLLATE latin1_swedish_ci +A +AD +AE +AF +B +SS +U +UE +Z +Ä +Ã… +Ãœ +ß +SELECT DISTINCT latin1_f COLLATE latin1_german2_ci FROM t1; +latin1_f COLLATE latin1_german2_ci +A +AD +AE +AF +B +SS +U +UE +Y +Z +SELECT DISTINCT latin1_f COLLATE latin1_general_ci FROM t1; +latin1_f COLLATE latin1_general_ci +A +AD +AE +AF +B +SS +U +UE +Y +Z +Ä +Ã… +Ãœ +ß +SELECT DISTINCT latin1_f COLLATE latin1_bin FROM t1; +latin1_f COLLATE latin1_bin +A +AD +AE +AF +B +SS +U +UE +Y +Z +a +ad +ae +af +b +ss +u +ue +y +z +Ä +Ã… +Ãœ +ß +ä +Ã¥ +ü +SELECT DISTINCT latin1_f COLLATE koi8r FROM t1; +ERROR HY000: Unknown collation: 'koi8r' +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `latin1_f` char(32) NOT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +SHOW FIELDS FROM t1; +Field Type Null Key Default Extra +latin1_f char(32) NO NULL +ALTER TABLE t1 CHANGE latin1_f +latin1_f CHAR(32) CHARACTER SET latin1 COLLATE latin1_bin; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `latin1_f` char(32) CHARACTER SET latin1 COLLATE latin1_bin DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +SHOW FIELDS FROM t1; +Field Type Null Key Default Extra +latin1_f char(32) YES NULL +ALTER TABLE t1 CHARACTER SET latin1 COLLATE latin1_bin; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `latin1_f` char(32) CHARACTER SET latin1 COLLATE latin1_bin DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_bin +SHOW FIELDS FROM t1; +Field Type Null Key Default Extra +latin1_f char(32) YES NULL +SET CHARACTER SET 'latin1'; +SHOW VARIABLES LIKE 'character_set_client'; +Variable_name Value +character_set_client latin1 +SELECT charset(_latin1 'a'),collation(_latin1 'a'),coercibility('a'),'a'='A'; +charset(_latin1 'a') collation(_latin1 'a') coercibility('a') 'a'='A' +latin1 latin1_swedish_ci 4 1 +explain SELECT charset('a'),collation('a'),coercibility('a'),'a'='A'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 /* select#1 */ select charset('a') AS `charset('a')`,collation('a') AS `collation('a')`,coercibility('a') AS `coercibility('a')`,('a' = 'A') AS `'a'='A'` +SET CHARACTER SET koi8r; +SHOW VARIABLES LIKE 'collation_client'; +Variable_name Value +SELECT charset(_latin1 'a'),collation(_latin1 'a'),coercibility('a'),'a'='A'; +charset(_latin1 'a') collation(_latin1 'a') coercibility('a') 'a'='A' +latin1 latin1_swedish_ci 4 1 +SET CHARACTER SET 'DEFAULT'; +ERROR 42000: Unknown character set: 'DEFAULT' +DROP TABLE t1; +CREATE TABLE t1 +(s1 CHAR(5) COLLATE latin1_german1_ci, +s2 CHAR(5) COLLATE latin1_swedish_ci); +SELECT * FROM t1 WHERE s1 = s2; +ERROR HY000: Illegal mix of collations (latin1_german1_ci,IMPLICIT) and (latin1_swedish_ci,IMPLICIT) for operation '=' +DROP TABLE t1; +CREATE TABLE t1 +(s1 CHAR(5) COLLATE latin1_german1_ci, +s2 CHAR(5) COLLATE latin1_swedish_ci, +s3 CHAR(5) COLLATE latin1_bin); +INSERT INTO t1 VALUES ('a','A','A'); +SELECT * FROM t1 WHERE s1 = s2; +ERROR HY000: Illegal mix of collations (latin1_german1_ci,IMPLICIT) and (latin1_swedish_ci,IMPLICIT) for operation '=' +SELECT * FROM t1 WHERE s1 = s3; +s1 s2 s3 +SELECT * FROM t1 WHERE s2 = s3; +s1 s2 s3 +a A A +DROP TABLE t1; +create table t1 (a varchar(1) character set latin1 collate latin1_general_ci); +insert into t1 values ('A'),('a'),('B'),('b'),('C'),('c'); +select * from t1 where a > _latin1 'B' collate latin1_bin; +a +a +b +C +c +select * from t1 where a <> _latin1 'B' collate latin1_bin; +a +A +a +b +C +c +create index i on t1 (a); +select * from t1 where a > _latin1 'B' collate latin1_bin; +a +a +b +C +c +select * from t1 where a <> _latin1 'B' collate latin1_bin; +a +A +a +b +C +c +drop table t1; +SET NAMES latin1; +CREATE TABLE t1 +(s1 char(10) COLLATE latin1_german1_ci, +s2 char(10) COLLATE latin1_swedish_ci, +KEY(s1), +KEY(s2)); +INSERT INTO t1 VALUES ('a','a'); +INSERT INTO t1 VALUES ('b','b'); +INSERT INTO t1 VALUES ('c','c'); +INSERT INTO t1 VALUES ('d','d'); +INSERT INTO t1 VALUES ('e','e'); +INSERT INTO t1 VALUES ('f','f'); +INSERT INTO t1 VALUES ('g','g'); +INSERT INTO t1 VALUES ('h','h'); +INSERT INTO t1 VALUES ('i','i'); +INSERT INTO t1 VALUES ('j','j'); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT * FROM t1 WHERE s1='a'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref s1 s1 11 const 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`s1` AS `s1`,`test`.`t1`.`s2` AS `s2` from `test`.`t1` where (`test`.`t1`.`s1` = 'a') +EXPLAIN SELECT * FROM t1 WHERE s2='a'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref s2 s2 11 const 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`s1` AS `s1`,`test`.`t1`.`s2` AS `s2` from `test`.`t1` where (`test`.`t1`.`s2` = 'a') +EXPLAIN SELECT * FROM t1 WHERE s1='a' COLLATE latin1_german1_ci; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref s1 s1 11 const 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`s1` AS `s1`,`test`.`t1`.`s2` AS `s2` from `test`.`t1` where (`test`.`t1`.`s1` = ('a' collate latin1_german1_ci)) +EXPLAIN SELECT * FROM t1 WHERE s2='a' COLLATE latin1_german1_ci; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL s2 NULL NULL NULL 10 10.00 Using where +Warnings: +Warning 1739 Cannot use ref access on index 's2' due to type or collation conversion on field 's2' +Warning 1739 Cannot use range access on index 's2' due to type or collation conversion on field 's2' +Note 1003 /* select#1 */ select `test`.`t1`.`s1` AS `s1`,`test`.`t1`.`s2` AS `s2` from `test`.`t1` where (`test`.`t1`.`s2` = (('a' collate latin1_german1_ci))) +EXPLAIN SELECT * FROM t1 WHERE s1 BETWEEN 'a' AND 'b' COLLATE latin1_german1_ci; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range s1 s1 11 NULL 2 100.00 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`s1` AS `s1`,`test`.`t1`.`s2` AS `s2` from `test`.`t1` where (`test`.`t1`.`s1` between 'a' and (('b' collate latin1_german1_ci))) +EXPLAIN SELECT * FROM t1 WHERE s2 BETWEEN 'a' AND 'b' COLLATE latin1_german1_ci; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.10 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL s2 NULL NULL NULL 10 10.10 Using where +Warnings: +Warning 1739 Cannot use range access on index 's2' due to type or collation conversion on field 's2' +Note 1003 /* select#1 */ select `test`.`t1`.`s1` AS `s1`,`test`.`t1`.`s2` AS `s2` from `test`.`t1` where (`test`.`t1`.`s2` between 'a' and (('b' collate latin1_german1_ci))) +EXPLAIN SELECT * FROM t1 WHERE s1 IN ('a','b' COLLATE latin1_german1_ci); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (2 workers) +2 SIMPLE t1 NULL range s1 s1 11 NULL 2 100.00 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`s1` AS `s1`,`test`.`t1`.`s2` AS `s2` from `test`.`t1` where (`test`.`t1`.`s1` in ('a',(('b' collate latin1_german1_ci)))) +EXPLAIN SELECT * FROM t1 WHERE s2 IN ('a','b' COLLATE latin1_german1_ci); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 20.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL s2 NULL NULL NULL 10 20.00 Using where +Warnings: +Warning 1739 Cannot use range access on index 's2' due to type or collation conversion on field 's2' +Note 1003 /* select#1 */ select `test`.`t1`.`s1` AS `s1`,`test`.`t1`.`s2` AS `s2` from `test`.`t1` where (`test`.`t1`.`s2` in ('a',(('b' collate latin1_german1_ci)))) +EXPLAIN SELECT * FROM t1 WHERE s1 LIKE 'a' COLLATE latin1_german1_ci; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range s1 s1 11 NULL 1 100.00 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`s1` AS `s1`,`test`.`t1`.`s2` AS `s2` from `test`.`t1` where (`test`.`t1`.`s1` like (('a' collate latin1_german1_ci))) +EXPLAIN SELECT * FROM t1 WHERE s2 LIKE 'a' COLLATE latin1_german1_ci; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.10 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL s2 NULL NULL NULL 10 10.10 Using where +Warnings: +Warning 1739 Cannot use range access on index 's2' due to type or collation conversion on field 's2' +Note 1003 /* select#1 */ select `test`.`t1`.`s1` AS `s1`,`test`.`t1`.`s2` AS `s2` from `test`.`t1` where (`test`.`t1`.`s2` like (('a' collate latin1_german1_ci))) +DROP TABLE t1; +create table t1(f1 varchar(10) character set latin2 collate latin2_hungarian_ci, key(f1)); +insert into t1 set f1=0x3F3F9DC73F; +insert into t1 set f1=0x3F3F1E563F; +insert into t1 set f1=0x3F3F; +check table t1 extended; +Table Op Msg_type Msg_text +test.t1 check status OK +drop table t1; +create table t1 (a varchar(2) character set latin7 collate latin7_general_ci,key(a)); +insert into t1 set a=0x4c20; +insert into t1 set a=0x6c; +insert into t1 set a=0x4c98; +check table t1 extended; +Table Op Msg_type Msg_text +test.t1 check status OK +drop table t1; +SET sql_mode = 'NO_ENGINE_SUBSTITUTION'; +select least(_latin1'a',_latin2'b',_latin5'c' collate latin5_turkish_ci); +least(_latin1'a',_latin2'b',_latin5'c' collate latin5_turkish_ci) +a +create table t1 charset latin1 +select least(_latin1'a',_latin2'b',_latin5'c' collate latin5_turkish_ci) as f1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `f1` varchar(1) CHARACTER SET latin5 NOT NULL DEFAULT '' +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +drop table t1; +select case _latin1'a' when _latin2'b' then 1 when _latin5'c' collate +latin5_turkish_ci then 2 else 3 end; +case _latin1'a' when _latin2'b' then 1 when _latin5'c' collate +latin5_turkish_ci then 2 else 3 end +3 +select concat(_latin1'a',_latin2'b',_latin5'c' collate latin5_turkish_ci); +concat(_latin1'a',_latin2'b',_latin5'c' collate latin5_turkish_ci) +abc +SET sql_mode = default; +# +# Bug#11765016 57926: ILLEGAL MIX OF COLLATIONS FOR OPERATION 'UNION' .. USING CONCAT/FUNCTION/ +# Not a bug: only adding coverage tests +# +SET NAMES latin1 COLLATE latin1_german2_ci; +CREATE DATABASE test1 DEFAULT CHARACTER SET latin1 COLLATE latin1_german2_ci; +USE test1; +# +# Using "COLLATE latin1_swedish_ci" as the default collation for latin1 +# +CREATE FUNCTION `getText`() RETURNS varchar(20) CHARSET latin1 +BEGIN +RETURN "Testtext"; +END;// +SELECT getText(), CHARSET(getText()), COLLATION(getText()), COERCIBILITY(getText()); +getText() CHARSET(getText()) COLLATION(getText()) COERCIBILITY(getText()) +Testtext latin1 latin1_swedish_ci 4 +CREATE TABLE t1 AS SELECT ' - ' AS a UNION SELECT getText(); +ERROR HY000: Illegal mix of collations for operation 'UNION' +DROP FUNCTION getText; +# +# Using "CHARACTER SET latin1 COLLATE latin1_german2_ci" as the database defaults +# +CREATE FUNCTION `getText`() RETURNS varchar(20) +BEGIN +RETURN "Testtext"; +END;// +SELECT getText(), CHARSET(getText()), COLLATION(getText()), COERCIBILITY(getText()); +getText() CHARSET(getText()) COLLATION(getText()) COERCIBILITY(getText()) +Testtext latin1 latin1_german2_ci 4 +CREATE TABLE t1 AS SELECT ' - ' AS a UNION SELECT getText(); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(20) COLLATE latin1_german2_ci DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_german2_ci +DROP TABLE t1; +DROP FUNCTION getText; +# +# Using explicit "CHARACTER SET latin1 COLLATE latin1_german2_ci" +# +CREATE FUNCTION `getText`() RETURNS varchar(20) CHARACTER SET latin1 COLLATE latin1_german2_ci +BEGIN +RETURN "Testtext"; +END;// +SELECT getText(), CHARSET(getText()), COLLATION(getText()), COERCIBILITY(getText()); +getText() CHARSET(getText()) COLLATION(getText()) COERCIBILITY(getText()) +Testtext latin1 latin1_german2_ci 4 +CREATE TABLE t1 AS SELECT ' - ' AS a UNION SELECT getText(); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(20) COLLATE latin1_german2_ci DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_german2_ci +DROP TABLE t1; +DROP FUNCTION getText; +DROP DATABASE test1; +USE test; +SET NAMES latin1; +# Bug#20425399: CAN'T USE COLLATE +CREATE TABLE t1(a TINYINT, b SMALLINT, c MEDIUMINT, d INT, e BIGINT); +CREATE TABLE t2(a DECIMAL(5,2)); +CREATE TABLE t3(a FLOAT(5,2), b DOUBLE(5,2)); +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES(1, 2, 3, 4, 100); +INSERT INTO t1 VALUES(2, 3, 4, 100, 1); +INSERT INTO t1 VALUES(3, 4, 100, 1, 2); +INSERT INTO t1 VALUES(4, 100, 1, 2, 3); +INSERT INTO t1 VALUES(100, 1, 2, 3, 4); +SELECT * FROM t1 ORDER BY a; +a b c d e +1 2 3 4 100 +2 3 4 100 1 +3 4 100 1 2 +4 100 1 2 3 +100 1 2 3 4 +SELECT * FROM t1 ORDER BY a COLLATE utf8_bin; +a b c d e +1 2 3 4 100 +100 1 2 3 4 +2 3 4 100 1 +3 4 100 1 2 +4 100 1 2 3 +SELECT * FROM t1 ORDER BY b; +a b c d e +100 1 2 3 4 +1 2 3 4 100 +2 3 4 100 1 +3 4 100 1 2 +4 100 1 2 3 +SELECT * FROM t1 ORDER BY b COLLATE latin1_swedish_ci; +a b c d e +100 1 2 3 4 +4 100 1 2 3 +1 2 3 4 100 +2 3 4 100 1 +3 4 100 1 2 +SELECT * FROM t1 ORDER BY c; +a b c d e +4 100 1 2 3 +100 1 2 3 4 +1 2 3 4 100 +2 3 4 100 1 +3 4 100 1 2 +SELECT * FROM t1 ORDER BY c COLLATE gb2312_chinese_ci; +a b c d e +4 100 1 2 3 +3 4 100 1 2 +100 1 2 3 4 +1 2 3 4 100 +2 3 4 100 1 +SELECT * FROM t1 ORDER BY d; +a b c d e +3 4 100 1 2 +4 100 1 2 3 +100 1 2 3 4 +1 2 3 4 100 +2 3 4 100 1 +SELECT * FROM t1 ORDER BY d COLLATE ascii_general_ci; +a b c d e +3 4 100 1 2 +2 3 4 100 1 +4 100 1 2 3 +100 1 2 3 4 +1 2 3 4 100 +INSERT INTO t2 VALUES(1.01); +INSERT INTO t2 VALUES(2.99); +INSERT INTO t2 VALUES(100.49); +SELECT * FROM t2 ORDER BY a; +a +1.01 +2.99 +100.49 +SELECT * FROM t2 ORDER BY a COLLATE latin1_german1_ci; +a +1.01 +100.49 +2.99 +INSERT INTO t3 VALUES(1.01, 2.99); +INSERT INTO t3 VALUES(2.99, 100.49); +INSERT INTO t3 VALUES(100.49, 1.01); +SELECT * FROM t3 ORDER BY a; +a b +1.01 2.99 +2.99 100.49 +100.49 1.01 +SELECT * FROM t3 ORDER BY a COLLATE ascii_bin; +a b +1.01 2.99 +100.49 1.01 +2.99 100.49 +SELECT * FROM t3 ORDER BY b; +a b +100.49 1.01 +1.01 2.99 +2.99 100.49 +SELECT * FROM t3 ORDER BY b COLLATE utf8_general_ci; +a b +100.49 1.01 +2.99 100.49 +1.01 2.99 +DROP TABLE t1; +DROP TABLE t2; +DROP TABLE t3; diff --git a/mysql-test/r/delete.result-pq b/mysql-test/r/delete.result-pq new file mode 100644 index 000000000000..b46cf17a290a --- /dev/null +++ b/mysql-test/r/delete.result-pq @@ -0,0 +1,868 @@ +drop table if exists t1,t2,t3,t11,t12; +CREATE TABLE t1 (a tinyint(3), b tinyint(5)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (1,1); +INSERT LOW_PRIORITY INTO t1 VALUES (1,2); +INSERT INTO t1 VALUES (1,3); +DELETE from t1 where a=1 limit 1; +DELETE LOW_PRIORITY from t1 where a=1; +INSERT INTO t1 VALUES (1,1); +DELETE from t1; +LOCK TABLE t1 write; +INSERT INTO t1 VALUES (1,2); +DELETE from t1; +UNLOCK TABLES; +INSERT INTO t1 VALUES (1,2); +SET AUTOCOMMIT=0; +DELETE from t1; +SET AUTOCOMMIT=1; +drop table t1; +create table t1 ( +a bigint not null, +b bigint not null default 0, +c bigint not null default 0, +d bigint not null default 0, +e bigint not null default 0, +f bigint not null default 0, +g bigint not null default 0, +h bigint not null default 0, +i bigint not null default 0, +j bigint not null default 0, +primary key (a,b,c,d,e,f,g,h,i,j)); +insert into t1 (a) values (2),(4),(6),(8),(10),(12),(14),(16),(18),(20),(22),(24),(26),(23); +delete from t1 where a=26; +drop table t1; +create table t1 ( +a bigint not null, +b bigint not null default 0, +c bigint not null default 0, +d bigint not null default 0, +e bigint not null default 0, +f bigint not null default 0, +g bigint not null default 0, +h bigint not null default 0, +i bigint not null default 0, +j bigint not null default 0, +primary key (a,b,c,d,e,f,g,h,i,j)); +insert into t1 (a) values (2),(4),(6),(8),(10),(12),(14),(16),(18),(20),(22),(24),(26),(23),(27); +delete from t1 where a=27; +drop table t1; +CREATE TABLE `t1` ( +`i` int(10) NOT NULL default '0', +`i2` int(10) NOT NULL default '0', +PRIMARY KEY (`i`) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +DELETE FROM t1 USING t1 WHERE post='1'; +ERROR 42S22: Unknown column 'post' in 'where clause' +drop table t1; +CREATE TABLE t1 ( +bool char(0) default NULL, +not_null varchar(20) binary NOT NULL default '', +misc integer not null, +PRIMARY KEY (not_null) +) ; +Warnings: +Warning 1287 'BINARY as attribute of a type' is deprecated and will be removed in a future release. Please use a CHARACTER SET clause with _bin collation instead +INSERT INTO t1 VALUES (NULL,'a',4), (NULL,'b',5), (NULL,'c',6), (NULL,'d',7); +select * from t1 where misc > 5 and bool is null; +bool not_null misc +NULL c 6 +NULL d 7 +delete from t1 where misc > 5 and bool is null; +select * from t1 where misc > 5 and bool is null; +bool not_null misc +select count(*) from t1; +count(*) +2 +delete from t1 where 1 > 2; +select count(*) from t1; +count(*) +2 +delete from t1 where 3 > 2; +select count(*) from t1; +count(*) +0 +drop table t1; +create table t1 (a int not null auto_increment primary key, b char(32)); +insert into t1 (b) values ('apple'), ('apple'); +select * from t1; +a b +1 apple +2 apple +delete t1 from t1, t1 as t2 where t1.b = t2.b and t1.a > t2.a; +select * from t1; +a b +1 apple +drop table t1; +create table t11 (a int NOT NULL, b int, primary key (a)); +create table t12 (a int NOT NULL, b int, primary key (a)); +create table t2 (a int NOT NULL, b int, primary key (a)); +insert into t11 values (0, 10),(1, 11),(2, 12); +insert into t12 values (33, 10),(0, 11),(2, 12); +insert into t2 values (1, 21),(2, 12),(3, 23); +analyze table t11,t12,t2; +Table Op Msg_type Msg_text +test.t11 analyze status OK +test.t12 analyze status OK +test.t2 analyze status OK +select * from t11; +a b +0 10 +1 11 +2 12 +select * from t12; +a b +0 11 +2 12 +33 10 +select * from t2; +a b +1 21 +2 12 +3 23 +delete t11.*, t12.* from t11,t12 where t11.a = t12.a and t11.b <> (select b from t2 where t11.a < t2.a); +ERROR 21000: Subquery returns more than 1 row +select * from t11; +a b +0 10 +1 11 +2 12 +select * from t12; +a b +0 11 +2 12 +33 10 +delete ignore t11.*, t12.* from t11,t12 where t11.a = t12.a and t11.b <> (select b from t2 where t11.a < t2.a); +Warnings: +Warning 1242 Subquery returns more than 1 row +Warning 1242 Subquery returns more than 1 row +analyze table t11,t12,t2; +Table Op Msg_type Msg_text +test.t11 analyze status OK +test.t12 analyze status OK +test.t2 analyze status OK +select * from t11; +a b +0 10 +1 11 +select * from t12; +a b +0 11 +33 10 +insert into t11 values (2, 12); +analyze table t11,t12,t2; +Table Op Msg_type Msg_text +test.t11 analyze status OK +test.t12 analyze status OK +test.t2 analyze status OK +delete from t11 where t11.b <> (select b from t2 where t11.a < t2.a); +ERROR 21000: Subquery returns more than 1 row +select * from t11; +a b +0 10 +1 11 +2 12 +delete ignore from t11 where t11.b <> (select b from t2 where t11.a < t2.a); +Warnings: +Warning 1242 Subquery returns more than 1 row +Warning 1242 Subquery returns more than 1 row +analyze table t11,t12,t2; +Table Op Msg_type Msg_text +test.t11 analyze status OK +test.t12 analyze status OK +test.t2 analyze status OK +select * from t11; +a b +0 10 +1 11 +drop table t11, t12, t2; +# sql_safe_updates mode with multi-table DELETE +CREATE TABLE t1(a INTEGER PRIMARY KEY); +INSERT INTO t1 VALUES(10),(20); +CREATE TABLE t2(b INTEGER); +INSERT INTO t2 VALUES(10),(20); +SET SESSION sql_safe_updates=1; +EXPLAIN DELETE t2 FROM t1 JOIN t2 WHERE t1.a = 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 Using index +1 DELETE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 delete `test`.`t2` from `test`.`t1` join `test`.`t2` where true +DELETE t2 FROM t1 JOIN t2 WHERE t1.a = 10; +ERROR HY000: You are using safe update mode and you tried to update a table without a WHERE that uses a KEY column. +SET SESSION sql_safe_updates=default; +DROP TABLE t1, t2; +create table t1 (a int, b int, unique key (a), key (b)); +insert into t1 values (3, 3), (7, 7); +delete t1 from t1 where a = 3; +check table t1; +Table Op Msg_type Msg_text +test.t1 check status OK +select * from t1; +a b +7 7 +drop table t1; +CREATE TABLE t1 ( a int PRIMARY KEY ); +DELETE FROM t1 WHERE t1.a > 0 ORDER BY t1.a; +INSERT INTO t1 VALUES (0),(1),(2); +DELETE FROM t1 WHERE t1.a > 0 ORDER BY t1.a LIMIT 1; +SELECT * FROM t1; +a +0 +2 +DROP TABLE t1; +create table t1 (a int); +delete `4.t1` from t1 as `4.t1` where `4.t1`.a = 5; +delete FROM `4.t1` USING t1 as `4.t1` where `4.t1`.a = 5; +drop table t1; +create table t1(f1 int primary key); +insert into t1 values (4),(3),(1),(2); +delete from t1 where (@a:= f1) order by f1 limit 1; +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +select @a; +@a +1 +drop table t1; +CREATE TABLE t1 ( +`date` date , +`time` time , +`seq` int(10) unsigned NOT NULL auto_increment, +PRIMARY KEY (`seq`), +KEY `seq` (`seq`), +KEY `time` (`time`), +KEY `date` (`date`) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +DELETE FROM t1 ORDER BY date ASC, time ASC LIMIT 1; +drop table t1; +End of 4.1 tests +CREATE TABLE t1 (a int not null,b int not null); +CREATE TABLE t2 (a int not null, b int not null, primary key (a,b)); +CREATE TABLE t3 (a int not null, b int not null, primary key (a,b)); +insert into t1 values (1,1),(2,1),(1,3); +insert into t2 values (1,1),(2,2),(3,3); +insert into t3 values (1,1),(2,1),(1,3); +select * from t1,t2,t3 where t1.a=t2.a AND t2.b=t3.a and t1.b=t3.b order by t1.a,t1.b; +a b a b a b +1 1 1 1 1 1 +1 3 1 1 1 3 +2 1 2 2 2 1 +analyze table t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +analyze table t2; +Table Op Msg_type Msg_text +test.t2 analyze status OK +analyze table t3; +Table Op Msg_type Msg_text +test.t3 analyze status OK +explain select * from t1,t2,t3 where t1.a=t2.a AND t2.b=t3.a and t1.b=t3.b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 SIMPLE t2 NULL ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using index +2 SIMPLE t3 NULL eq_ref PRIMARY PRIMARY 8 test.t2.b,test.t1.b 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b` from `test`.`t1` join `test`.`t2` join `test`.`t3` where ((`test`.`t3`.`b` = `test`.`t1`.`b`) and (`test`.`t3`.`a` = `test`.`t2`.`b`) and (`test`.`t2`.`a` = `test`.`t1`.`a`)) +delete t2.*,t3.* from t1,t2,t3 where t1.a=t2.a AND t2.b=t3.a and t1.b=t3.b; +select * from t3; +a b +drop table t1,t2,t3; +create table t1(a date not null); +insert ignore into t1 values (0); +Warnings: +Warning 1264 Out of range value for column 'a' at row 1 +select * from t1 where a is null; +a +0000-00-00 +delete from t1 where a is null; +select count(*) from t1; +count(*) +0 +drop table t1; +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1); +DELETE FROM t1 ORDER BY x; +ERROR 42S22: Unknown column 'x' in 'order clause' +DELETE FROM t1 ORDER BY t2.x; +ERROR 42S22: Unknown column 't2.x' in 'order clause' +DELETE FROM t1 ORDER BY (SELECT x); +ERROR 42S22: Unknown column 'x' in 'field list' +DROP TABLE t1; +CREATE TABLE t1 ( +a INT +); +CREATE TABLE t2 ( +a INT +); +CREATE DATABASE db1; +CREATE TABLE db1.t1 ( +a INT +); +INSERT INTO db1.t1 (a) SELECT * FROM t1; +CREATE DATABASE db2; +CREATE TABLE db2.t1 ( +a INT +); +INSERT INTO db2.t1 (a) SELECT * FROM t2; +DELETE FROM t1 alias USING t1, t2 alias WHERE t1.a = alias.a; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'USING t1, t2 alias WHERE t1.a = alias.a' at line 1 +DELETE FROM alias USING t1, t2 alias WHERE t1.a = alias.a; +DELETE FROM t1, alias USING t1, t2 alias WHERE t1.a = alias.a; +DELETE FROM t1, t2 USING t1, t2 alias WHERE t1.a = alias.a; +ERROR 42S02: Unknown table 't2' in MULTI DELETE +DELETE FROM db1.t1 alias USING db1.t1, db2.t1 alias WHERE db1.t1.a = alias.a; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'USING db1.t1, db2.t1 alias WHERE db1.t1.a = alias.a' at line 1 +DELETE FROM alias USING db1.t1, db2.t1 alias WHERE db1.t1.a = alias.a; +DELETE FROM db2.alias USING db1.t1, db2.t1 alias WHERE db1.t1.a = alias.a; +ERROR 42S02: Unknown table 'alias' in MULTI DELETE +DELETE FROM t1 USING t1 WHERE a = 1; +SELECT * FROM t1; +a +DELETE FROM t1 alias USING t1 alias WHERE a = 2; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'USING t1 alias WHERE a = 2' at line 1 +SELECT * FROM t1; +a +DROP TABLE t1, t2; +DROP DATABASE db1; +DROP DATABASE db2; +CREATE FUNCTION f1() RETURNS INT RETURN 1; +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (0); +DELETE FROM t1 ORDER BY (f1(10)) LIMIT 1; +ERROR 42000: Incorrect number of arguments for FUNCTION test.f1; expected 0, got 1 +DROP TABLE t1; +DROP FUNCTION f1; +# +# Bug #49552 : sql_buffer_result cause crash + not found records +# in multitable delete/subquery +# +CREATE TABLE t1(a INT); +INSERT INTO t1 VALUES (1),(2),(3); +SET SESSION SQL_BUFFER_RESULT=1; +DELETE t1 FROM (SELECT SUM(a) a FROM t1) x,t1; +SET SESSION SQL_BUFFER_RESULT=DEFAULT; +SELECT * FROM t1; +a +DROP TABLE t1; +End of 5.0 tests +DROP DATABASE IF EXISTS db1; +DROP DATABASE IF EXISTS db2; +DROP DATABASE IF EXISTS db3; +DROP DATABASE IF EXISTS db4; +DROP TABLE IF EXISTS t1, t2; +DROP PROCEDURE IF EXISTS count; +USE test; +CREATE DATABASE db1; +CREATE DATABASE db2; +CREATE TABLE db1.t1 (a INT, b INT); +INSERT INTO db1.t1 VALUES (1,1),(2,2),(3,3); +CREATE TABLE db1.t2 AS SELECT * FROM db1.t1; +CREATE TABLE db2.t1 AS SELECT * FROM db1.t2; +CREATE TABLE db2.t2 AS SELECT * FROM db2.t1; +CREATE TABLE t1 AS SELECT * FROM db2.t2; +CREATE TABLE t2 AS SELECT * FROM t1; +CREATE PROCEDURE count_rows() +BEGIN +SELECT COUNT(*) AS "COUNT(db1.t1)" FROM db1.t1; +SELECT COUNT(*) AS "COUNT(db1.t2)" FROM db1.t2; +SELECT COUNT(*) AS "COUNT(db2.t1)" FROM db2.t1; +SELECT COUNT(*) AS "COUNT(db2.t2)" FROM db2.t2; +SELECT COUNT(*) AS "COUNT(test.t1)" FROM test.t1; +SELECT COUNT(*) AS "COUNT(test.t2)" FROM test.t2; +END| +CREATE DATABASE db3; +USE db3; +DROP DATABASE db3; +SELECT * FROM t1; +ERROR 3D000: No database selected +DELETE a1,a2 FROM db1.t1, db2.t2; +ERROR 3D000: No database selected +DELETE a1,a2 FROM db1.t1, db2.t2; +ERROR 3D000: No database selected +DELETE a1,a2 FROM db1.t1 AS a1, db2.t2; +ERROR 3D000: No database selected +DELETE a1,a2 FROM db1.t1, db2.t2 AS a2; +ERROR 3D000: No database selected +DELETE a1,a2 FROM db3.t1 AS a1, db4.t2 AS a2; +ERROR 3D000: No database selected +DELETE a1,a2 FROM db3.t1 AS a1, db4.t2 AS a2; +ERROR 3D000: No database selected +DELETE FROM a1,a2 USING db1.t1, db2.t2; +ERROR 3D000: No database selected +DELETE FROM a1,a2 USING db1.t1, db2.t2; +ERROR 3D000: No database selected +DELETE FROM a1,a2 USING db1.t1 AS a1, db2.t2; +ERROR 3D000: No database selected +DELETE FROM a1,a2 USING db1.t1, db2.t2 AS a2; +ERROR 3D000: No database selected +DELETE FROM a1,a2 USING db3.t1 AS a1, db4.t2 AS a2; +ERROR 3D000: No database selected +DELETE FROM a1,a2 USING db3.t1 AS a1, db4.t2 AS a2; +ERROR 3D000: No database selected +DELETE a1 FROM db1.t1 AS a1, db2.t2 AS a1; +ERROR 3D000: No database selected +DELETE a1 FROM db1.a1, db2.t2 AS a1; +ERROR 3D000: No database selected +DELETE a1 FROM a1, db1.t1 AS a1; +ERROR 3D000: No database selected +DELETE t1 FROM db1.t1, db2.t1 AS a1; +ERROR 3D000: No database selected +DELETE t1 FROM db1.t1 AS a1, db2.t1 AS a2; +ERROR 3D000: No database selected +DELETE t1 FROM db1.t1, db2.t1; +ERROR 3D000: No database selected +USE test; +DELETE a1,a2 FROM db1.t1, db2.t2; +ERROR 42S02: Unknown table 'a1' in MULTI DELETE +DELETE a1,a2 FROM db1.t1, db2.t2; +ERROR 42S02: Unknown table 'a1' in MULTI DELETE +DELETE a1,a2 FROM db1.t1 AS a1, db2.t2; +ERROR 42S02: Unknown table 'a2' in MULTI DELETE +DELETE a1,a2 FROM db1.t1, db2.t2 AS a2; +ERROR 42S02: Unknown table 'a1' in MULTI DELETE +DELETE a1,a2 FROM db3.t1 AS a1, db4.t2 AS a2; +ERROR 42000: Unknown database 'db3' +DELETE a1,a2 FROM db3.t1 AS a1, db4.t2 AS a2; +ERROR 42000: Unknown database 'db3' +DELETE FROM a1,a2 USING db1.t1, db2.t2; +ERROR 42S02: Unknown table 'a1' in MULTI DELETE +DELETE FROM a1,a2 USING db1.t1, db2.t2; +ERROR 42S02: Unknown table 'a1' in MULTI DELETE +DELETE FROM a1,a2 USING db1.t1 AS a1, db2.t2; +ERROR 42S02: Unknown table 'a2' in MULTI DELETE +DELETE FROM a1,a2 USING db1.t1, db2.t2 AS a2; +ERROR 42S02: Unknown table 'a1' in MULTI DELETE +DELETE FROM a1,a2 USING db3.t1 AS a1, db4.t2 AS a2; +ERROR 42000: Unknown database 'db3' +DELETE FROM a1,a2 USING db3.t1 AS a1, db4.t2 AS a2; +ERROR 42000: Unknown database 'db3' +DELETE a1 FROM db1.t1 AS a1, db2.t2 AS a1; +ERROR 42000: Not unique table/alias: 'a1' +DELETE a1 FROM db1.a1, db2.t2 AS a1; +ERROR 42S02: Table 'db1.a1' doesn't exist +DELETE a1 FROM a1, db1.t1 AS a1; +ERROR 42000: Not unique table/alias: 'a1' +DELETE t1 FROM db1.t1, db2.t1 AS a1; +ERROR 42S02: Unknown table 't1' in MULTI DELETE +DELETE t1 FROM db1.t1 AS a1, db2.t1 AS a2; +ERROR 42S02: Unknown table 't1' in MULTI DELETE +DELETE t1 FROM db1.t1, db2.t1; +ERROR 42S02: Unknown table 't1' in MULTI DELETE +DELETE t1 FROM db1.t2 AS t1, db2.t2 AS t2 WHERE t2.a = 1 AND t1.a = t2.a; +SELECT ROW_COUNT(); +ROW_COUNT() +1 +CALL count_rows(); +COUNT(db1.t1) +3 +COUNT(db1.t2) +2 +COUNT(db2.t1) +3 +COUNT(db2.t2) +3 +COUNT(test.t1) +3 +COUNT(test.t2) +3 +DELETE a1, a2 FROM db2.t1 AS a1, t2 AS a2 WHERE a1.a = 2 AND a2.a = 2; +SELECT ROW_COUNT(); +ROW_COUNT() +2 +CALL count_rows(); +COUNT(db1.t1) +3 +COUNT(db1.t2) +2 +COUNT(db2.t1) +2 +COUNT(db2.t2) +3 +COUNT(test.t1) +3 +COUNT(test.t2) +2 +DROP DATABASE db1; +DROP DATABASE db2; +DROP PROCEDURE count_rows; +DROP TABLE t1, t2; +# +# Bug#46958: Assertion in Diagnostics_area::set_ok_status, trigger, +# merge table +# +CREATE TABLE t1 ( a INT ); +CREATE TABLE t2 ( a INT ); +CREATE TABLE t3 ( a INT ); +INSERT INTO t1 VALUES (1), (2); +INSERT INTO t2 VALUES (1), (2); +INSERT INTO t3 VALUES (1), (2); +CREATE TRIGGER tr1 BEFORE DELETE ON t2 +FOR EACH ROW INSERT INTO no_such_table VALUES (1); +DELETE t1, t2, t3 FROM t1, t2, t3; +ERROR 42S02: Table 'test.no_such_table' doesn't exist +SELECT * FROM t1; +a +1 +2 +SELECT * FROM t2; +a +1 +2 +SELECT * FROM t3; +a +1 +2 +DROP TABLE t1, t2, t3; +CREATE TABLE t1 ( a INT ); +CREATE TABLE t2 ( a INT ); +CREATE TABLE t3 ( a INT ); +INSERT INTO t1 VALUES (1), (2); +INSERT INTO t2 VALUES (1), (2); +INSERT INTO t3 VALUES (1), (2); +CREATE TRIGGER tr1 AFTER DELETE ON t2 +FOR EACH ROW INSERT INTO no_such_table VALUES (1); +DELETE t1, t2, t3 FROM t1, t2, t3; +ERROR 42S02: Table 'test.no_such_table' doesn't exist +SELECT * FROM t1; +a +1 +2 +SELECT * FROM t2; +a +1 +2 +SELECT * FROM t3; +a +1 +2 +DROP TABLE t1, t2, t3; +# +# Bug #46425 crash in Diagnostics_area::set_ok_status, +# empty statement, DELETE IGNORE +# +CREATE table t1 (i INTEGER); +INSERT INTO t1 VALUES (1); +CREATE TRIGGER tr1 AFTER DELETE ON t1 FOR EACH ROW +BEGIN +INSERT INTO t1 SELECT * FROM t1 AS A; +END | +DELETE IGNORE FROM t1; +ERROR HY000: Can't update table 't1' in stored function/trigger because it is already used by statement which invoked this stored function/trigger. +DROP TABLE t1; +# +# Bug #53034: Multiple-table DELETE statements not accepting +# "Access compatibility" syntax +# +CREATE TABLE t1 (id INT); +CREATE TABLE t2 LIKE t1; +CREATE TABLE t3 LIKE t1; +DELETE FROM t1.*, test.t2.*, a.* USING t1, t2, t3 AS a; +DROP TABLE t1, t2, t3; +End of 5.1 tests +# +# Bug#51099 Assertion in mysql_multi_delete_prepare() +# +DROP TABLE IF EXISTS t1, t2; +DROP VIEW IF EXISTS v1, v2; +CREATE TABLE t1(a INT); +CREATE TABLE t2(b INT); +CREATE VIEW v1 AS SELECT a, b FROM t1, t2; +CREATE VIEW v2 AS SELECT a FROM v1; +DELETE FROM v2; +ERROR HY000: Can not delete from join view 'test.v2' +DELETE v2 FROM v2; +ERROR HY000: Can not delete from join view 'test.v2' +DROP VIEW v2, v1; +DROP TABLE t1, t2; +# +# Bug#58709 assert in mysql_execute_command +# +DROP TABLE IF EXISTS t2, t1; +DROP PROCEDURE IF EXISTS p1; +CREATE TABLE t1 (i INT PRIMARY KEY) engine=InnoDB; +CREATE TABLE t2 (i INT, FOREIGN KEY (i) REFERENCES t1 (i) ON DELETE NO ACTION) engine=InnoDB; +INSERT INTO t1 VALUES (1); +INSERT INTO t2 VALUES (1); +DELETE IGNORE FROM t1 WHERE i = 1; +Warnings: +Warning 1451 Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`i`) REFERENCES `t1` (`i`)) +CREATE PROCEDURE p1() DELETE IGNORE FROM t1 WHERE i = 1; +CALL p1(); +Warnings: +Warning 1451 Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`i`) REFERENCES `t1` (`i`)) +PREPARE stm FROM 'CALL p1()'; +EXECUTE stm; +Warnings: +Warning 1451 Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`i`) REFERENCES `t1` (`i`)) +DEALLOCATE PREPARE stm; +DROP TABLE t2, t1; +DROP PROCEDURE p1; +# +# Bug#18345346 Assertion failed: table_ref->view && table_ref->table == 0 +# +CREATE TABLE b(a INTEGER); +CREATE VIEW y AS SELECT 1 FROM b, b AS e; +CREATE VIEW x AS SELECT 1 FROM y; +CREATE VIEW z AS SELECT 1 FROM x LIMIT 1; +DELETE z FROM (SELECT 1) AS x, z; +ERROR HY000: The target table z of the DELETE is not updatable +DROP VIEW z, x, y; +DROP TABLE b; +# Bug#11752648 : MULTI-DELETE IGNORE DOES NOT REPORT WARNINGS +# +CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=InnoDB; +INSERT INTO t1 (a) VALUES (1); +CREATE TABLE t2 (a INT PRIMARY KEY) ENGINE=InnoDB; +INSERT INTO t2 (a) VALUES (1); +CREATE TABLE t3 (a INT, b INT, CONSTRAINT c_a FOREIGN KEY (a) +REFERENCES t1 (a), CONSTRAINT c_b FOREIGN KEY (b) REFERENCES t2 (a)) ENGINE=InnoDB; +INSERT INTO t3 (a, b) VALUES (1, 1); +DELETE IGNORE FROM t1; +Warnings: +Warning 1451 Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t3`, CONSTRAINT `c_a` FOREIGN KEY (`a`) REFERENCES `t1` (`a`)) +DELETE IGNORE t1,t2 FROM t1,t2; +Warnings: +Warning 1451 Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t3`, CONSTRAINT `c_a` FOREIGN KEY (`a`) REFERENCES `t1` (`a`)) +Warning 1451 Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t3`, CONSTRAINT `c_b` FOREIGN KEY (`b`) REFERENCES `t2` (`a`)) +SELECT * FROM t1; +a +1 +SELECT * FROM t2; +a +1 +DROP TABLE t3,t2,t1; +# +# Bug#17550423 : DELETE IGNORE GIVES INCORRECT RESULT WITH FOREIGN KEY +# FOR PARENT TABLE +# +CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=InnoDB; +CREATE TABLE t2 (b INT) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1), (2), (5); +INSERT INTO t2 VALUES (1), (5); +ALTER TABLE t2 ADD CONSTRAINT FOREIGN KEY(b) REFERENCES t1(a); +SELECT * FROM t2; +b +1 +5 +DELETE IGNORE FROM t1; +Warnings: +Warning 1451 Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`b`) REFERENCES `t1` (`a`)) +Warning 1451 Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`b`) REFERENCES `t1` (`a`)) +SELECT * FROM t1; +a +1 +5 +DROP TABLE t2,t1; +# +# Bug#20460208: !table || (!table->read_set || bitmap_is_set) +# +CREATE TABLE t1(a INTEGER) engine=innodb; +CREATE TABLE t2(a BLOB) engine=innodb; +INSERT INTO t1 SET z=1; +ERROR 42S22: Unknown column 'z' in 'field list' +INSERT INTO t2 VALUES('a'); +DELETE FROM t2 WHERE 1 = a; +DROP TABLE t1, t2; +# +# Bug#20086791 ASSERT `! IS_SET()` IN DIAGNOSTICS_AREA::SET_OK_STATUS +# ON DELETE (ER_SUBQUERY..) +# +SET sql_mode=''; +CREATE TABLE t1 ( +col_int_key int, +pk integer auto_increment, +col_datetime_key datetime, +/*Indices*/ +key (col_int_key ), +primary key (pk), +key (col_datetime_key ) +) ENGINE=memory; +CREATE TABLE t2 ( +col_varchar_key varchar (1), +col_date_key date, +pk integer auto_increment, +/*Indices*/ +key (col_varchar_key ), +key (col_date_key ), +primary key (pk) +) ENGINE=memory; +INSERT INTO t2 VALUES +('v', '2002-05-01', NULL) , +('d', '2001-01-01', NULL) +; +CREATE TABLE t3 ( +pk integer auto_increment, +col_int_key int, +col_varchar_key varchar (1), +/*Indices*/ +primary key (pk), +key (col_int_key ), +key (col_varchar_key )) +ENGINE=memory; +INSERT INTO t3 VALUES +(NULL, 3, 'n') , +(NULL, 1, 'r') +; +CREATE TABLE t4 ( +pk integer auto_increment, +col_varchar_key varchar (1), +col_int_key int, +/*Indices*/ +primary key (pk), +key (col_varchar_key ), +key (col_int_key ) +) ENGINE=memory; +CREATE TABLE t5 ( +col_datetime_key datetime, +pk integer auto_increment, +col_int_key int, +/*Indices*/ +key (col_datetime_key ), +primary key (pk), +key (col_int_key )) +ENGINE=memory; +INSERT INTO t5 VALUES +('2007-10-01', NULL, 8) , +('2002-10-01', NULL, 3) +; +DELETE OUTR1.* FROM t2 AS OUTR1 +JOIN t3 AS OUTR2 +ON ( OUTR1 . col_varchar_key = OUTR2 . col_varchar_key ) +WHERE OUTR1 . col_varchar_key NOT IN +( SELECT INNR1 . col_varchar_key AS y FROM t5 AS INNR2 +RIGHT JOIN t4 AS INNR1 ON ( INNR2 . pk < INNR1 . col_int_key ) +WHERE INNR1 . col_int_key <= INNR1 . col_int_key +AND OUTR2 . col_int_key >= 3 ); +DELETE QUICK +FROM OUTR1.* USING t2 AS OUTR1 +LEFT OUTER JOIN t1 AS OUTR2 +ON ( OUTR1 . col_date_key = OUTR2 . col_datetime_key ) +WHERE OUTR1 . pk NOT IN ( SELECT 2 UNION SELECT 7 ); +DELETE OUTR1.* +FROM t2 AS OUTR1 +LEFT JOIN t1 AS OUTR2 +ON ( OUTR1 . pk = OUTR2 . col_int_key ) +WHERE OUTR1 . pk <> ( +SELECT DISTINCT INNR1 . col_int_key AS y +FROM t5 AS INNR1 WHERE OUTR1 . pk <= 5 +ORDER BY INNR1 . col_datetime_key +); +ERROR 21000: Subquery returns more than 1 row +DROP TABLE t1, t2, t3, t4, t5; +SET sql_mode=default; +# Bug#20450013 assertion 'select_lex::having_cond() == __null ... +CREATE TABLE t1(a TEXT, FULLTEXT (a)); +CREATE VIEW v1 AS SELECT a FROM t1 ORDER BY a; +explain DELETE FROM t1 USING v1,t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 DELETE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 delete `test`.`t1` from `test`.`t1` join `test`.`t1` +DELETE FROM t1 USING v1,t1; +DROP VIEW v1; +DROP TABLE t1; +# +# Bug#25320909 ASSERTION `THD->LEX->CURRENT_SELECT() == UNIT->FIRST_SELECT()' WITH DELETE +# +CREATE TABLE t1 (a INT, b CHAR(8), pk INT AUTO_INCREMENT PRIMARY KEY); +INSERT INTO t1 (a,b) VALUES +(10000,'foobar'),(1,'a'),(2,'b'),(3,'c'),(4,'d'),(5,'e'); +INSERT INTO t1 (a,b) SELECT a, b FROM t1; +CREATE TABLE t2 (pk INT AUTO_INCREMENT PRIMARY KEY, c CHAR(8), d INT); +INSERT INTO t2 (c,d) SELECT b, a FROM t1; +DELETE IGNORE FROM t1 WHERE b IS NOT NULL ORDER BY a LIMIT 1; +SELECT a,b FROM t1; +a b +1 a +10000 foobar +10000 foobar +2 b +2 b +3 c +3 c +4 d +4 d +5 e +5 e +DELETE IGNORE t1.*, t2.* FROM t1, t2 +WHERE c < b OR +a != ( SELECT 1 UNION SELECT 2 ); +Warnings: +Warning 1242 Subquery returns more than 1 row +DROP TABLE t1, t2; +# +# Bug#29153485: ASSERTION IN JOIN_READ_CONST_TABLE() +# +CREATE TABLE d3 ( +pk int(11) NOT NULL AUTO_INCREMENT, +col_int int(11) DEFAULT NULL, +col_varchar varchar(1) DEFAULT NULL, +PRIMARY KEY (pk) +) ; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO d3 VALUES (96,9,'t'),(97,0,'x'); +CREATE TABLE e3 ( +col_varchar varchar(1) DEFAULT NULL, +pk int(11) NOT NULL AUTO_INCREMENT, +PRIMARY KEY (pk) +) ; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO e3 VALUES ('v',986); +DELETE OUTR1.* FROM e3 AS OUTR1 INNER JOIN d3 AS OUTR2 ON +( OUTR1.col_varchar = OUTR2.col_varchar ) +LEFT JOIN d3 AS OUTR3 ON ( OUTR1. pk = OUTR3.pk ) +WHERE OUTR1.pk = +( SELECT DISTINCT INNR1.col_int FROM d3 AS INNR1 WHERE INNR1.pk <> 8) ; +ERROR 21000: Subquery returns more than 1 row +DROP TABLE d3,e3; +# +# Bug#27455809; DELETE FROM ...WHERE NOT EXISTS WITH TABLE ALIAS CREATES AN ERROR 1064 (42000 +# +CREATE TABLE t1 (c1 INT); +INSERT INTO t1 VALUES (1), (2); +SELECT * FROM t1; +c1 +1 +2 +DELETE FROM t1 AS a1 WHERE a1.c1 = 2; +SELECT * FROM t1; +c1 +1 +CREATE TABLE t2 (c2 INT); +INSERT INTO t2 VALUES (1), (2); +SELECT * FROM t2; +c2 +1 +2 +DELETE FROM t2 a2 WHERE NOT EXISTS (SELECT * FROM t1 WHERE t1.c1 = a2.c2); +SELECT * FROM t2; +c2 +1 +DROP TABLE t1, t2; +# Bug#31640267: Assertion `trans_safe || updated_rows == 0 || thd->get_transaction() +CREATE TABLE t1(pk INTEGER PRIMARY KEY, a INTEGER); +INSERT INTO t1 VALUES(1, 10), (2, 20); +PREPARE s FROM 'DELETE t1 FROM t1, (SELECT 1 FROM DUAL) AS dt'; +EXECUTE s; +SELECT ROW_COUNT(); +ROW_COUNT() +2 +INSERT INTO t1 VALUES(1, 10), (2, 20); +EXECUTE s; +SELECT ROW_COUNT(); +ROW_COUNT() +2 +DEALLOCATE PREPARE s; +DROP TABLE t1; diff --git a/mysql-test/r/derived.result-pq b/mysql-test/r/derived.result-pq new file mode 100644 index 000000000000..63f6fb1f80f3 --- /dev/null +++ b/mysql-test/r/derived.result-pq @@ -0,0 +1,4613 @@ +drop table if exists t1,t2,t3; +select * from (select 2 from DUAL) b; +2 +2 +SELECT 1 as a FROM (SELECT 1 UNION SELECT a) b; +ERROR 42S22: Unknown column 'a' in 'field list' +SELECT 1 as a FROM (SELECT a UNION SELECT 1) b; +ERROR 42S22: Unknown column 'a' in 'field list' +CREATE TABLE t1 (a int not null, b char (10) not null); +insert into t1 values(1,'a'),(2,'b'),(3,'c'),(3,'c'); +CREATE TABLE t2 (a int not null, b char (10) not null); +insert into t2 values (3,'c'),(4,'d'),(5,'f'),(6,'e'); +select t1.a,t3.y from t1,(select a as y from t2 where b='c') as t3 where t1.a = t3.y; +a y +3 3 +3 3 +select t1.a,t3.a from t1,(select * from t2 where b='c') as t3 where t1.a = t3.a; +a a +3 3 +3 3 +CREATE TABLE t3 (a int not null, b char (10) not null); +insert into t3 values (3,'f'),(4,'y'),(5,'z'),(6,'c'); +select t1.a,t4.y from t1,(select t2.a as y from t2,(select t3.b from t3 where t3.a>3) as t5 where t2.b=t5.b) as t4 where t1.a = t4.y; +a y +3 3 +3 3 +SELECT a FROM (SELECT 1 FROM (SELECT 1) a HAVING a=1) b; +ERROR 42S22: Unknown column 'a' in 'having clause' +SELECT a,b as a FROM (SELECT '1' as a,'2' as b) b HAVING a=1; +ERROR 23000: Column 'a' in having clause is ambiguous +SELECT a,2 as a FROM (SELECT '1' as a) b HAVING a=2; +a a +1 2 +SELECT a,2 as a FROM (SELECT '1' as a) b HAVING a=1; +a a +SELECT 1 FROM (SELECT 1) a WHERE a=2; +ERROR 42S22: Unknown column 'a' in 'where clause' +SELECT (SELECT 1) as a FROM (SELECT 1 FROM t1 HAVING a=1) as a; +ERROR 42S22: Unknown column 'a' in 'having clause' +select * from t1 as x1, (select * from t1) as x2; +a b a b +1 a 1 a +1 a 2 b +1 a 3 c +1 a 3 c +2 b 1 a +2 b 2 b +2 b 3 c +2 b 3 c +3 c 1 a +3 c 1 a +3 c 2 b +3 c 2 b +3 c 3 c +3 c 3 c +3 c 3 c +3 c 3 c +explain select * from t1 as x1, (select * from t1) as x2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE x1 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`x1`.`a` AS `a`,`test`.`x1`.`b` AS `b`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` `x1` join `test`.`t1` +drop table if exists t2,t3; +select * from (select 1) as a; +1 +1 +select a from (select 1 as a) as b; +a +1 +select 1 from (select 1) as a; +1 +1 +select * from (select * from t1 union select * from t1) a; +a b +1 a +2 b +3 c +select * from (select * from t1 union all select * from t1) a; +a b +1 a +2 b +3 c +3 c +1 a +2 b +3 c +3 c +select * from (select * from t1 union all select * from t1 limit 2) a; +a b +1 a +2 b +explain select * from (select * from t1 union select * from t1) a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL 8 100.00 NULL +2 DERIVED t1 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +3 UNION t1 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +NULL UNION RESULT NULL ALL NULL NULL NULL NULL NULL NULL Using temporary +Warnings: +Note 1003 /* select#1 */ select `a`.`a` AS `a`,`a`.`b` AS `b` from (/* select#2 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` union /* select#3 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1`) `a` +explain select * from (select * from t1 union all select * from t1) a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL 8 100.00 NULL +2 DERIVED t1 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +3 UNION t1 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `a`.`a` AS `a`,`a`.`b` AS `b` from (/* select#2 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` union all /* select#3 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1`) `a` +CREATE TABLE t2 (a int not null); +insert into t2 values(1); +select * from (select * from t1 where t1.a=(select a from t2 where t2.a=t1.a)) a; +a b +1 a +select * from (select * from t1 where t1.a=(select t2.a from t2 where t2.a=t1.a) union select t1.a, t1.b from t1) a; +a b +1 a +2 b +3 c +explain select * from (select t1.*, t2.a as t2a from t1,t2 where t1.a=t2.a) t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,'1' AS `t2a` from `test`.`t1` where (`test`.`t1`.`a` = '1') +drop table t1, t2; +create table t1(a int not null, t char(8), index(a)); +SELECT * FROM (SELECT * FROM t1) as b ORDER BY a ASC LIMIT 0,20; +a t +1 1 +2 2 +3 3 +4 4 +5 5 +6 6 +7 7 +8 8 +9 9 +10 10 +11 11 +12 12 +13 13 +14 14 +15 15 +16 16 +17 17 +18 18 +19 19 +20 20 +explain select count(*) from t1 as tt1, (select * from t1) as tt2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Select tables optimized away +Warnings: +Note 1003 /* select#1 */ select count(0) AS `count(*)` from `test`.`t1` `tt1` join `test`.`t1` +drop table t1; +SELECT * FROM (SELECT (SELECT * FROM (SELECT 1 as a) as a )) as b; +(SELECT * FROM (SELECT 1 as a) as a ) +1 +select * from (select 1 as a) b left join (select 2 as a) c using(a); +a +1 +SELECT * FROM (SELECT 1 UNION SELECT a) b; +ERROR 42S22: Unknown column 'a' in 'field list' +SELECT 1 as a FROM (SELECT a UNION SELECT 1) b; +ERROR 42S22: Unknown column 'a' in 'field list' +SELECT 1 as a FROM (SELECT 1 UNION SELECT a) b; +ERROR 42S22: Unknown column 'a' in 'field list' +select 1 from (select 2) a order by 0; +ERROR 42S22: Unknown column '0' in 'order clause' +create table t1 (id int); +insert into t1 values (1),(2),(3); +describe select * from (select * from t1 group by id) bar; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 DERIVED t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using temporary +Warnings: +Note 1003 /* select#1 */ select `bar`.`id` AS `id` from (/* select#2 */ select `test`.`t1`.`id` AS `id` from `test`.`t1` group by `test`.`t1`.`id`) `bar` +drop table t1; +create table t1 (mat_id MEDIUMINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, matintnum CHAR(6) NOT NULL, test MEDIUMINT UNSIGNED NULL) charset utf8mb4; +create table t2 (mat_id MEDIUMINT UNSIGNED NOT NULL, pla_id MEDIUMINT UNSIGNED NOT NULL); +insert into t1 values (NULL, 'a', 1), (NULL, 'b', 2), (NULL, 'c', 3), (NULL, 'd', 4), (NULL, 'e', 5), (NULL, 'f', 6), (NULL, 'g', 7), (NULL, 'h', 8), (NULL, 'i', 9); +insert into t2 values (1, 100), (1, 101), (1, 102), (2, 100), (2, 103), (2, 104), (3, 101), (3, 102), (3, 105); +analyze table t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +SELECT STRAIGHT_JOIN d.pla_id, m2.mat_id FROM t1 m2 INNER JOIN (SELECT mp.pla_id, MIN(m1.matintnum) AS matintnum FROM t2 mp INNER JOIN t1 m1 ON mp.mat_id=m1.mat_id GROUP BY mp.pla_id) d ON d.matintnum=m2.matintnum; +pla_id mat_id +100 1 +101 1 +102 1 +103 2 +104 2 +105 3 +SELECT STRAIGHT_JOIN d.pla_id, m2.test FROM t1 m2 INNER JOIN (SELECT mp.pla_id, MIN(m1.matintnum) AS matintnum FROM t2 mp INNER JOIN t1 m1 ON mp.mat_id=m1.mat_id GROUP BY mp.pla_id) d ON d.matintnum=m2.matintnum; +pla_id test +100 1 +101 1 +102 1 +103 2 +104 2 +105 3 +explain SELECT STRAIGHT_JOIN d.pla_id, m2.mat_id FROM t1 m2 INNER JOIN (SELECT mp.pla_id, MIN(m1.matintnum) AS matintnum FROM t2 mp INNER JOIN t1 m1 ON mp.mat_id=m1.mat_id GROUP BY mp.pla_id) d ON d.matintnum=m2.matintnum; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY m2 NULL ALL NULL NULL NULL NULL 9 100.00 NULL +1 PRIMARY NULL ref 25 test.m2.matintnum 2 100.00 NULL +2 DERIVED mp NULL ALL NULL NULL NULL NULL 9 100.00 Using temporary +2 DERIVED m1 NULL eq_ref PRIMARY PRIMARY 3 test.mp.mat_id 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select straight_join `d`.`pla_id` AS `pla_id`,`test`.`m2`.`mat_id` AS `mat_id` from `test`.`t1` `m2` join (/* select#2 */ select `test`.`mp`.`pla_id` AS `pla_id`,min(`test`.`m1`.`matintnum`) AS `matintnum` from `test`.`t2` `mp` join `test`.`t1` `m1` where (`test`.`m1`.`mat_id` = `test`.`mp`.`mat_id`) group by `test`.`mp`.`pla_id`) `d` where (`d`.`matintnum` = `test`.`m2`.`matintnum`) +explain SELECT STRAIGHT_JOIN d.pla_id, m2.test FROM t1 m2 INNER JOIN (SELECT mp.pla_id, MIN(m1.matintnum) AS matintnum FROM t2 mp INNER JOIN t1 m1 ON mp.mat_id=m1.mat_id GROUP BY mp.pla_id) d ON d.matintnum=m2.matintnum; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY m2 NULL ALL NULL NULL NULL NULL 9 100.00 NULL +1 PRIMARY NULL ref 25 test.m2.matintnum 2 100.00 NULL +2 DERIVED mp NULL ALL NULL NULL NULL NULL 9 100.00 Using temporary +2 DERIVED m1 NULL eq_ref PRIMARY PRIMARY 3 test.mp.mat_id 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select straight_join `d`.`pla_id` AS `pla_id`,`test`.`m2`.`test` AS `test` from `test`.`t1` `m2` join (/* select#2 */ select `test`.`mp`.`pla_id` AS `pla_id`,min(`test`.`m1`.`matintnum`) AS `matintnum` from `test`.`t2` `mp` join `test`.`t1` `m1` where (`test`.`m1`.`mat_id` = `test`.`mp`.`mat_id`) group by `test`.`mp`.`pla_id`) `d` where (`d`.`matintnum` = `test`.`m2`.`matintnum`) +drop table t1,t2; +SELECT a.x FROM (SELECT 1 AS x) AS a HAVING a.x = 1; +x +1 +create user mysqltest_1; +create table t1 select 1 as a; +select 2 as a from (select * from t1) b; +ERROR 3D000: No database selected +use test; +select 2 as a from (select * from t1) b; +a +2 +drop table t1; +select mail_id, if(folder.f_description!='', folder.f_description, folder.f_name) as folder_name, date, address_id, phrase, address, subject from folder, (select mail.mail_id as mail_id, date_format(mail.h_date, '%b %e, %Y %h:%i') as date, mail.folder_id, sender.address_id as address_id, sender.phrase as phrase, sender.address as address, mail.h_subject as subject from mail left join mxa as mxa_sender on mail.mail_id=mxa_sender.mail_id and mxa_sender.type='from' left join address as sender on mxa_sender.address_id=sender.address_id mxa as mxa_recipient, address as recipient, where 1 and mail.mail_id=mxa_recipient.mail_id and mxa_recipient.address_id=recipient.address_id and mxa_recipient.type='to' and match(sender.phrase, sender.address, sender.comment) against ('jeremy' in boolean mode) and match(recipient.phrase, recipient.address, recipient.comment) against ('monty' in boolean mode) order by mail.h_date desc limit 0, 25 ) as query where query.folder_id=folder.folder_id; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'mxa as mxa_recipient, address as recipient, where 1 and mail.mail_id=mxa_r' at line 1 +create table t1 (a int); +insert into t1 values (1),(2),(3); +update (select * from t1) as t1 set a = 5; +ERROR HY000: The target table t1 of the UPDATE is not updatable +update (select * from t1) as t1, t1 as t2 set t1.a = 5; +ERROR HY000: The target table t1 of the UPDATE is not updatable +delete from (select * from t1); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '(select * from t1)' at line 1 +delete from (select * from t1) as t1, t1 as t2; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '(select * from t1) as t1, t1 as t2' at line 1 +insert into (select * from t1) values (5); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '(select * from t1) values (5)' at line 1 +drop table t1; +create table t1 (E1 INTEGER UNSIGNED NOT NULL, E2 INTEGER UNSIGNED NOT NULL, E3 INTEGER UNSIGNED NOT NULL, PRIMARY KEY(E1) +); +insert into t1 VALUES(1,1,1), (2,2,1); +select count(*) from t1 INNER JOIN (SELECT A.E1, A.E2, A.E3 FROM t1 AS A WHERE A.E3 = (SELECT MAX(B.E3) FROM t1 AS B WHERE A.E2 = B.E2)) AS themax ON t1.E1 = themax.E2 AND t1.E1 = t1.E2; +count(*) +2 +explain select count(*) from t1 INNER JOIN (SELECT a.E1, a.E2, a.E3 FROM t1 AS a WHERE a.E3 = (SELECT max(b.E3) FROM t1 AS b WHERE a.E2 = b.E2)) AS themax ON t1.E1 = themax.E2 AND t1.E1 = t1.E2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY a NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 PRIMARY t1 NULL eq_ref PRIMARY PRIMARY 4 test.a.E2 1 50.00 Using where +3 DEPENDENT SUBQUERY b NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1276 Field or reference 'test.a.E2' of SELECT #3 was resolved in SELECT #2 +Note 1003 /* select#1 */ select count(0) AS `count(*)` from `test`.`t1` join `test`.`t1` `a` where ((`test`.`t1`.`E1` = `test`.`a`.`E2`) and (`test`.`t1`.`E2` = `test`.`a`.`E2`) and (`test`.`a`.`E3` = (/* select#3 */ select max(`test`.`b`.`E3`) from `test`.`t1` `b` where (`test`.`a`.`E2` = `test`.`b`.`E2`)))) +drop table t1; +create table t1 (a int); +insert into t1 values (1),(2); +select * from ( select * from t1 union select * from t1) a,(select * from t1 union select * from t1) b; +a a +1 1 +1 2 +2 1 +2 2 +explain select * from ( select * from t1 union select * from t1) a,(select * from t1 union select * from t1) b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL 4 100.00 NULL +1 PRIMARY NULL ALL NULL NULL NULL NULL 4 100.00 Using join buffer (hash join) +4 DERIVED t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +5 UNION t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +NULL UNION RESULT NULL ALL NULL NULL NULL NULL NULL NULL Using temporary +2 DERIVED t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +3 UNION t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +NULL UNION RESULT NULL ALL NULL NULL NULL NULL NULL NULL Using temporary +Warnings: +Note 1003 /* select#1 */ select `a`.`a` AS `a`,`b`.`a` AS `a` from (/* select#2 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` union /* select#3 */ select `test`.`t1`.`a` AS `a` from `test`.`t1`) `a` join (/* select#4 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` union /* select#5 */ select `test`.`t1`.`a` AS `a` from `test`.`t1`) `b` +drop table t1; +CREATE TABLE `t1` ( +`N` int(11) unsigned NOT NULL default '0', +`M` tinyint(1) default '0' +) ENGINE=MyISAM DEFAULT CHARSET=latin1; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO `t1` (N, M) VALUES (1, 0),(1, 0),(1, 0),(2, 0),(2, 0),(3, 0); +UPDATE `t1` AS P1 INNER JOIN (SELECT N FROM `t1` GROUP BY N HAVING Count(M) > 1) AS P2 ON P1.N = P2.N SET P1.M = 2; +select * from t1; +N M +1 2 +1 2 +1 2 +2 2 +2 2 +3 0 +UPDATE `t1` AS P1 INNER JOIN (SELECT N FROM `t1` GROUP BY N HAVING Count(M) > 1) AS P2 ON P1.N = P2.N SET P1.M = 2, P2.N = 2; +ERROR HY000: The target table P2 of the UPDATE is not updatable +UPDATE `t1` AS P1 INNER JOIN (SELECT aaaa FROM `t1` GROUP BY N HAVING Count(M) > 1) AS P2 ON P1.N = P2.N SET P1.M = 2; +ERROR 42S22: Unknown column 'aaaa' in 'field list' +delete P1.* from `t1` AS P1 INNER JOIN (SELECT N FROM `t1` GROUP BY N HAVING Count(M) > 1) AS P2 ON P1.N = P2.N; +select * from t1; +N M +3 0 +delete P1.*,p2.* from `t1` AS P1 INNER JOIN (SELECT N FROM `t1` GROUP BY N HAVING Count(M) > 1) AS p2 ON P1.N = p2.N; +ERROR HY000: The target table p2 of the DELETE is not updatable +delete P1.* from `t1` AS P1 INNER JOIN (SELECT aaa FROM `t1` GROUP BY N HAVING Count(M) > 1) AS P2 ON P1.N = P2.N; +ERROR 42S22: Unknown column 'aaa' in 'field list' +drop table t1; +CREATE TABLE t1 ( +OBJECTID int(11) NOT NULL default '0', +SORTORDER int(11) NOT NULL auto_increment, +KEY t1_SortIndex (SORTORDER), +KEY t1_IdIndex (OBJECTID) +) ENGINE=MyISAM DEFAULT CHARSET=latin1; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t2 ( +ID int(11) default NULL, +PARID int(11) default NULL, +UNIQUE KEY t2_ID_IDX (ID), +KEY t2_PARID_IDX (PARID) +) engine=MyISAM DEFAULT CHARSET=latin1; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (1000,0),(1001,0),(1002,0),(1003,0),(1008,1),(1009,1),(1010,1),(1011,1),(1016,2); +CREATE TABLE t3 ( +ID int(11) default NULL, +DATA decimal(10,2) default NULL, +UNIQUE KEY t3_ID_IDX (ID) +) engine=MyISAM DEFAULT CHARSET=latin1; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t3 VALUES (1000,0.00),(1001,0.25),(1002,0.50),(1003,0.75),(1008,1.00),(1009,1.25),(1010,1.50),(1011,1.75); +select 497, TMP.ID, NULL from (select 497 as ID, MAX(t3.DATA) as DATA from t1 join t2 on (t1.ObjectID = t2.ID) join t3 on (t1.ObjectID = t3.ID) group by t2.ParID order by DATA DESC) as TMP; +497 ID NULL +drop table t1, t2, t3; +CREATE TABLE t1 (name char(1) default NULL, val int(5) default NULL); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES ('a',1), ('a',2), ('a',2), ('a',2), ('a',3), ('a',6), ('a',7), ('a',11), ('a',11), ('a',12), ('a',13), ('a',13), ('a',20), ('b',2), ('b',3), ('b',4), ('b',5); +SELECT s.name, AVG(s.val) AS median FROM (SELECT x.name, x.val FROM t1 x, t1 y WHERE x.name=y.name GROUP BY x.name, x.val HAVING SUM(y.val <= x.val) >= COUNT(*)/2 AND SUM(y.val >= x.val) >= COUNT(*)/2) AS s GROUP BY s.name; +name median +a 7.0000 +b 3.5000 +explain SELECT s.name, AVG(s.val) AS median FROM (SELECT x.name, x.val FROM t1 x, t1 y WHERE x.name=y.name GROUP BY x.name, x.val HAVING SUM(y.val <= x.val) >= COUNT(*)/2 AND SUM(y.val >= x.val) >= COUNT(*)/2) AS s GROUP BY s.name; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL 28 100.00 Using temporary +2 DERIVED x NULL ALL NULL NULL NULL NULL 17 100.00 Using temporary +2 DERIVED y NULL ALL NULL NULL NULL NULL 17 10.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `s`.`name` AS `name`,avg(`s`.`val`) AS `median` from (/* select#2 */ select `test`.`x`.`name` AS `name`,`test`.`x`.`val` AS `val` from `test`.`t1` `x` join `test`.`t1` `y` where (`test`.`y`.`name` = `test`.`x`.`name`) group by `test`.`x`.`name`,`test`.`x`.`val` having ((sum((`test`.`y`.`val` <= `test`.`x`.`val`)) >= (count(0) / 2)) and (sum((`test`.`y`.`val` >= `test`.`x`.`val`)) >= (count(0) / 2)))) `s` group by `s`.`name` +drop table t1; +create table t2 (a int, b int, primary key (a)); +insert into t2 values (1,7),(2,7); +explain select a from t2 where a>1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index PRIMARY PRIMARY 4 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` where (`test`.`t2`.`a` > 1) +explain select a from (select a from t2 where a>1) tt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index PRIMARY PRIMARY 4 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` where (`test`.`t2`.`a` > 1) +drop table t2; +SET sql_mode = 'NO_ENGINE_SUBSTITUTION'; +CREATE TABLE `t1` ( `itemid` int(11) NOT NULL default '0', `grpid` varchar(15) NOT NULL default '', `vendor` int(11) NOT NULL default '0', `date_` date NOT NULL default '0000-00-00', `price` decimal(12,2) NOT NULL default '0.00', PRIMARY KEY (`itemid`,`grpid`,`vendor`,`date_`), KEY `itemid` (`itemid`,`vendor`), KEY `itemid_2` (`itemid`,`date_`)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t1 values (128, 'rozn', 2, curdate(), 10), +(128, 'rozn', 1, curdate(), 10); +SELECT MIN(price) min, MAX(price) max, AVG(price) avg FROM (SELECT SUBSTRING( MAX(concat(date_,";",price)), 12) price FROM t1 WHERE itemid=128 AND grpid='rozn' GROUP BY itemid, grpid, vendor) lastprices; +min max avg +10.00 10.00 10 +DROP TABLE t1; +SET sql_mode = default; +create table t1 (a integer, b integer); +insert into t1 values (1,4), (2,2),(2,2), (4,1),(4,1),(4,1),(4,1); +select distinct sum(b) from t1 group by a; +sum(b) +4 +select distinct sum(b) from (select a,b from t1) y group by a; +sum(b) +4 +drop table t1; +CREATE TABLE t1 (a char(10), b char(10)); +INSERT INTO t1 VALUES ('root','localhost'), ('root','%'); +SELECT * FROM (SELECT (SELECT a.a FROM t1 AS a WHERE a.a = b.a) FROM t1 AS b) AS c; +ERROR 21000: Subquery returns more than 1 row +DROP TABLE t1; +create table t1(a int); +create table t2(a int); +create table t3(a int); +insert into t1 values(1),(1); +insert into t2 values(2),(2); +insert into t3 values(3),(3); +select * from t1 union distinct select * from t2 union all select * from t3; +a +1 +2 +3 +3 +select * from (select * from t1 union distinct select * from t2 union all select * from t3) X; +a +1 +2 +3 +3 +drop table t1, t2, t3; +create table t1 (a int); +create table t2 (a int); +select * from (select * from t1,t2) foo; +ERROR 42S21: Duplicate column name 'a' +drop table t1,t2; +create table t1 (ID int unsigned not null auto_increment, +DATA varchar(5) not null, primary key (ID)); +create table t2 (ID int unsigned not null auto_increment, +DATA varchar(5) not null, FID int unsigned not null, +primary key (ID)); +select A.* from (t1 inner join (select * from t2) as A on t1.ID = A.FID); +ID DATA FID +select t2.* from ((select * from t1) as A inner join t2 on A.ID = t2.FID); +ID DATA FID +select t2.* from (select * from t1) as A inner join t2 on A.ID = t2.FID; +ID DATA FID +drop table t1, t2; +drop user mysqltest_1; +# End of 4.1 tests +SELECT 0 FROM +(SELECT 0) t01, (SELECT 0) t02, (SELECT 0) t03, (SELECT 0) t04, (SELECT 0) t05, +(SELECT 0) t06, (SELECT 0) t07, (SELECT 0) t08, (SELECT 0) t09, (SELECT 0) t10, +(SELECT 0) t11, (SELECT 0) t12, (SELECT 0) t13, (SELECT 0) t14, (SELECT 0) t15, +(SELECT 0) t16, (SELECT 0) t17, (SELECT 0) t18, (SELECT 0) t19, (SELECT 0) t20, +(SELECT 0) t21, (SELECT 0) t22, (SELECT 0) t23, (SELECT 0) t24, (SELECT 0) t25, +(SELECT 0) t26, (SELECT 0) t27, (SELECT 0) t28, (SELECT 0) t29, (SELECT 0) t30, +(SELECT 0) t31, (SELECT 0) t32, (SELECT 0) t33, (SELECT 0) t34, (SELECT 0) t35, +(SELECT 0) t36, (SELECT 0) t37, (SELECT 0) t38, (SELECT 0) t39, (SELECT 0) t40, +(SELECT 0) t41, (SELECT 0) t42, (SELECT 0) t43, (SELECT 0) t44, (SELECT 0) t45, +(SELECT 0) t46, (SELECT 0) t47, (SELECT 0) t48, (SELECT 0) t49, (SELECT 0) t50, +(SELECT 0) t51, (SELECT 0) t52, (SELECT 0) t53, (SELECT 0) t54, (SELECT 0) t55, +(SELECT 0) t56, (SELECT 0) t57, (SELECT 0) t58, (SELECT 0) t59, (SELECT 0) t60, +(SELECT 0) t61; +0 +0 +# +# A nested materialized derived table is used before being populated. +# (addon for bug#19077) +# +CREATE TABLE t1 (i INT, j BIGINT); +INSERT INTO t1 VALUES (1, 2), (2, 2), (3, 2); +SELECT * FROM (SELECT MIN(i) FROM t1 +WHERE j = SUBSTRING('12', (SELECT * FROM (SELECT MIN(j) FROM t1) t2))) t3; +MIN(i) +1 +DROP TABLE t1; +# End of 5.0 tests +# +# Bug#55586: Crash JOIN of two subqueries in FROM + ORDER BY and GROUP BY +# +CREATE TABLE C ( +`col_int_key` int(11) DEFAULT NULL, +`col_varchar_key` varchar(1) DEFAULT NULL, +`col_varchar_nokey` varchar(1) DEFAULT NULL, +KEY `col_varchar_key` (`col_varchar_key`,`col_int_key`) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO C VALUES (2,'w','w'); +INSERT INTO C VALUES (2,'d','d'); +SELECT SUM(DISTINCT table2.col_int_key) field1, +table1.col_varchar_key field2 +FROM +(SELECT * FROM C ) table1 +JOIN (SELECT * FROM C ) table2 +ON table2 .`col_varchar_key` = table1 .`col_varchar_nokey` +GROUP BY field2 +ORDER BY field1; +field1 field2 +2 d +2 w +DROP TABLE C; +# End of test for bug#55586 +# +# Bug#55561: Crash on JOIN with 2 FROM subqueries +# +CREATE TABLE C ( +col_int int DEFAULT NULL, +col_varchar varchar(1) DEFAULT NULL +); +INSERT INTO `C` VALUES (0,NULL); +INSERT INTO `C` VALUES (5,'y'); +SELECT table1.col_varchar +FROM +( SELECT * FROM C ) table1 +JOIN ( SELECT * FROM C ) table2 ON table2.col_varchar = table1.col_varchar +WHERE +table2.col_varchar < table2.col_varchar +AND table1.col_varchar != 'k' +LIMIT 1; +col_varchar +DROP TABLE C; +# End on bug#55561 +# +# Bug#56233: Hang during key generation for derived tables +# +CREATE TABLE C ( +col_varchar_10_key varchar(10) DEFAULT NULL, +col_int_key int DEFAULT NULL, +pk int NOT NULL AUTO_INCREMENT, +col_date_key date DEFAULT NULL, +PRIMARY KEY (`pk`), +KEY `col_varchar_10_key` (`col_varchar_10_key`), +KEY `col_int_key` (`col_int_key`), +KEY `col_date_key` (`col_date_key`) +); +INSERT INTO C VALUES ('ok',3,1,'2003-04-02'); +CREATE ALGORITHM=TEMPTABLE VIEW viewC AS SELECT * FROM C; +SELECT table1.col_date_key AS field1 +FROM +C AS table1 +WHERE +(table1.col_int_key <=ANY +( SELECT SUBQUERY1_t1.col_int_key +FROM viewC AS SUBQUERY1_t1 +WHERE SUBQUERY1_t1.col_varchar_10_key <= table1.col_varchar_10_key +) +) +; +field1 +2003-04-02 +DROP TABLE C; +DROP VIEW viewC; +# +# +# Bug#55950: FROM Subquery joined by 2 varchar fields returns empty +# set +# +CREATE TABLE `cc` ( +`i1` varchar(1) DEFAULT NULL, +`i2` varchar(1) DEFAULT NULL +) charset utf8mb4; +INSERT INTO `cc` VALUES ('m','m'); +INSERT INTO `cc` VALUES ('c','c'); +CREATE TABLE `C` ( +`o1` varchar(1) DEFAULT NULL +) charset utf8mb4; +INSERT INTO `C` VALUES ('m'); +SELECT table1 . o1 +FROM C table1 +JOIN ( C table2 +JOIN ( SELECT * FROM cc ) table3 +ON table3 .`i1` = table2 .o1 +) ON table3 .`i2` = table2 .o1 +; +o1 +m +SET @optimizer_switch_saved= @@optimizer_switch; +SET @@optimizer_switch="derived_merge=off"; +# Ref access to the derived table should be used. +EXPLAIN SELECT table1 . o1 +FROM C table1 +JOIN ( C table2 +JOIN ( SELECT * FROM cc ) table3 +ON table3 .`i1` = table2 .o1 +) ON table3 .`i2` = table2 .o1 +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY table1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 PRIMARY table2 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 PRIMARY NULL ref 14 const,const 1 100.00 Using index +2 DERIVED cc NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select 'm' AS `o1` from (/* select#2 */ select `test`.`cc`.`i1` AS `i1`,`test`.`cc`.`i2` AS `i2` from `test`.`cc`) `table3` where ((`table3`.`i2` = 'm') and (`table3`.`i1` = 'm')) +EXPLAIN FORMAT=tree SELECT table1 . o1 +FROM C table1 +JOIN ( C table2 +JOIN ( SELECT * FROM cc ) table3 +ON table3 .`i1` = table2 .o1 +) ON table3 .`i2` = table2 .o1 +; +EXPLAIN +-> Index lookup on table3 using (i1='m', i2='m') + -> Materialize (cost=0.90..0.90 rows=2) + -> Table scan on cc (cost=0.70 rows=2) + +SET @@optimizer_switch=@optimizer_switch_saved; +DROP TABLE cc; +DROP TABLE C; +# End of test for bug#55950 +# +# Bug#56592: Subquery with DISTINCT in FROM clause returns only partial +# result +# +CREATE TABLE `t1` ( +`pk` int(11) NOT NULL, +`col_int_key` int(11) DEFAULT NULL, +`col_datetime_key` datetime DEFAULT NULL +) ENGINE=MyISAM; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (2, 9, NULL), (3, 3, '1900-01-01 00:00:00'), +(8, 8, '1900-01-01 00:00:00'), (15, 0, '2007-12-15 12:39:34'); +SELECT * FROM ( +SELECT DISTINCT tableb.col_datetime_key +FROM t1 tablea LEFT JOIN t1 tableb ON tablea.pk < tableb.col_int_key +) AS from_subquery; +col_datetime_key +1900-01-01 00:00:00 +NULL +EXPLAIN SELECT * FROM ( +SELECT DISTINCT tableb.col_datetime_key +FROM t1 tablea LEFT JOIN t1 tableb ON tablea.pk < tableb.col_int_key +) AS from_subquery; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL 16 100.00 NULL +2 DERIVED tablea NULL ALL NULL NULL NULL NULL 4 100.00 Using temporary +2 DERIVED tableb NULL ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `from_subquery`.`col_datetime_key` AS `col_datetime_key` from (/* select#2 */ select distinct `test`.`tableb`.`col_datetime_key` AS `col_datetime_key` from `test`.`t1` `tablea` left join `test`.`t1` `tableb` on((`test`.`tablea`.`pk` < `test`.`tableb`.`col_int_key`)) where true) `from_subquery` +EXPLAIN SELECT * FROM ( +SELECT DISTINCT tablea.col_datetime_key +FROM t1 tablea LEFT JOIN t1 tableb ON tablea.pk < tableb.col_int_key +) AS from_subquery; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL 16 100.00 NULL +2 DERIVED tablea NULL ALL NULL NULL NULL NULL 4 100.00 Using temporary +2 DERIVED tableb NULL ALL NULL NULL NULL NULL 4 100.00 Using where; Distinct; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `from_subquery`.`col_datetime_key` AS `col_datetime_key` from (/* select#2 */ select distinct `test`.`tablea`.`col_datetime_key` AS `col_datetime_key` from `test`.`t1` `tablea` left join `test`.`t1` `tableb` on((`test`.`tablea`.`pk` < `test`.`tableb`.`col_int_key`)) where true) `from_subquery` +DROP TABLE t1; +# +# Bug#58730 Assertion failed: table->key_read == 0 in close_thread_table, +# temptable views +# +CREATE TABLE t1 (a INT); +CREATE TABLE t2 (b INT, KEY (b)); +INSERT INTO t1 VALUES (1),(1); +INSERT INTO t2 VALUES (1),(1); +CREATE algorithm=temptable VIEW v1 AS +SELECT 1 FROM t1 LEFT JOIN t1 t3 ON 1 > (SELECT 1 FROM t1); +CREATE algorithm=temptable VIEW v2 AS SELECT 1 FROM t2; +EXPLAIN SELECT 1 FROM t1 JOIN v1 ON 1 > (SELECT 1 FROM v2); +ERROR 21000: Subquery returns more than 1 row +DROP TABLE t1, t2; +DROP VIEW v1, v2; +# +# WL#5274: Postpone materialization of views/subqueries in FROM clause. +# Additional tests. +# +CREATE TABLE t1(f1 int, f11 int); +CREATE TABLE t2(f2 int, f22 int); +INSERT INTO t1 VALUES(1,1),(2,2),(3,3),(5,5),(9,9),(7,7); +INSERT INTO t2 VALUES(1,1),(3,3),(2,2),(4,4),(8,8),(6,6); +for merged derived tables +explain for simple derived +EXPLAIN SELECT * FROM (SELECT * FROM t1) tt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 6 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`f1` AS `f1`,`test`.`t1`.`f11` AS `f11` from `test`.`t1` +SELECT * FROM (SELECT * FROM t1) tt; +f1 f11 +1 1 +2 2 +3 3 +5 5 +9 9 +7 7 +explain for multitable derived +EXPLAIN SELECT * FROM (SELECT * FROM t1 JOIN t2 ON f1=f2) tt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 6 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`f1` AS `f1`,`test`.`t1`.`f11` AS `f11`,`test`.`t2`.`f2` AS `f2`,`test`.`t2`.`f22` AS `f22` from `test`.`t1` join `test`.`t2` where (`test`.`t2`.`f2` = `test`.`t1`.`f1`) +SELECT * FROM (SELECT * FROM t1 JOIN t2 ON f1=f2) tt; +f1 f11 f2 f22 +1 1 1 1 +2 2 2 2 +3 3 3 3 +explain for derived with where +FLUSH STATUS; +EXPLAIN +SELECT * FROM (SELECT * FROM t1 WHERE f1 IN (2,3)) tt WHERE f11=2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 6 16.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`f1` AS `f1`,`test`.`t1`.`f11` AS `f11` from `test`.`t1` where ((`test`.`t1`.`f11` = 2) and (`test`.`t1`.`f1` in (2,3))) +SHOW STATUS LIKE 'Handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 0 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +FLUSH STATUS; +SELECT * FROM (SELECT * FROM t1 WHERE f1 IN (2,3)) tt WHERE f11=2; +f1 f11 +2 2 +SHOW STATUS LIKE 'Handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 0 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 7 +join of derived +EXPLAIN +SELECT * FROM (SELECT * FROM t1 WHERE f1 IN (2,3)) tt JOIN +(SELECT * FROM t1 WHERE f1 IN (1,2)) aa ON tt.f1=aa.f1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 6 33.33 Using where +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`f1` AS `f1`,`test`.`t1`.`f11` AS `f11`,`test`.`t1`.`f1` AS `f1`,`test`.`t1`.`f11` AS `f11` from `test`.`t1` join `test`.`t1` where ((`test`.`t1`.`f1` = `test`.`t1`.`f1`) and (`test`.`t1`.`f1` in (1,2)) and (`test`.`t1`.`f1` in (2,3))) +SELECT * FROM (SELECT * FROM t1 WHERE f1 IN (2,3)) tt JOIN +(SELECT * FROM t1 WHERE f1 IN (1,2)) aa ON tt.f1=aa.f1; +f1 f11 f1 f11 +2 2 2 2 +for merged views +CREATE VIEW v1 AS SELECT * FROM t1; +CREATE VIEW v2 AS SELECT * FROM t1 JOIN t2 ON f1=f2; +CREATE VIEW v3 AS SELECT * FROM t1 WHERE f1 IN (2,3); +CREATE VIEW v4 AS SELECT * FROM t2 WHERE f2 IN (2,3); +explain for simple views +EXPLAIN SELECT * FROM v1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 6 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`f1` AS `f1`,`test`.`t1`.`f11` AS `f11` from `test`.`t1` +SELECT * FROM v1; +f1 f11 +1 1 +2 2 +3 3 +5 5 +7 7 +9 9 +explain for multitable views +EXPLAIN SELECT * FROM v2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 6 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`f1` AS `f1`,`test`.`t1`.`f11` AS `f11`,`test`.`t2`.`f2` AS `f2`,`test`.`t2`.`f22` AS `f22` from `test`.`t1` join `test`.`t2` where (`test`.`t2`.`f2` = `test`.`t1`.`f1`) +SELECT * FROM v2; +f1 f11 f2 f22 +1 1 1 1 +2 2 2 2 +3 3 3 3 +explain for views with where +EXPLAIN SELECT * FROM v3 WHERE f11 IN (1,3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 6 16.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`f1` AS `f1`,`test`.`t1`.`f11` AS `f11` from `test`.`t1` where ((`test`.`t1`.`f11` in (1,3)) and (`test`.`t1`.`f1` in (2,3))) +SELECT * FROM v3 WHERE f11 IN (1,3); +f1 f11 +3 3 +explain for joined views +EXPLAIN +SELECT * FROM v3 JOIN v4 ON f1=f2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 6 33.33 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`f1` AS `f1`,`test`.`t1`.`f11` AS `f11`,`test`.`t2`.`f2` AS `f2`,`test`.`t2`.`f22` AS `f22` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`f2` = `test`.`t1`.`f1`) and (`test`.`t1`.`f1` in (2,3)) and (`test`.`t1`.`f1` in (2,3))) +SELECT * FROM v3 JOIN v4 ON f1=f2; +f1 f11 f2 f22 +2 2 2 2 +3 3 3 3 +FLUSH STATUS; +EXPLAIN SELECT * FROM v4 WHERE f2 IN (1,3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`f2` AS `f2`,`test`.`t2`.`f22` AS `f22` from `test`.`t2` where ((`test`.`t2`.`f2` in (1,3)) and (`test`.`t2`.`f2` in (2,3))) +SHOW STATUS LIKE 'Handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 0 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +FLUSH STATUS; +SELECT * FROM v4 WHERE f2 IN (1,3); +f2 f22 +3 3 +SHOW STATUS LIKE 'Handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 0 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 7 +for materialized derived tables +explain for simple derived +EXPLAIN SELECT * FROM (SELECT * FROM t1 GROUP BY f1) tt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL 6 100.00 NULL +2 DERIVED t1 NULL ALL NULL NULL NULL NULL 6 100.00 Using temporary +Warnings: +Note 1003 /* select#1 */ select `tt`.`f1` AS `f1`,`tt`.`f11` AS `f11` from (/* select#2 */ select `test`.`t1`.`f1` AS `f1`,`test`.`t1`.`f11` AS `f11` from `test`.`t1` group by `test`.`t1`.`f1`) `tt` +SELECT * FROM (SELECT * FROM t1 HAVING f1=f1) tt; +f1 f11 +1 1 +2 2 +3 3 +5 5 +9 9 +7 7 +explain showing created indexes and late materialization +FLUSH STATUS; +EXPLAIN +SELECT * FROM t1 JOIN (SELECT * FROM t2 GROUP BY f2) tt ON f1=f2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 6 100.00 Using where +1 PRIMARY NULL ref 5 test.t1.f1 2 100.00 NULL +2 DERIVED t2 NULL ALL NULL NULL NULL NULL 6 100.00 Using temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`f1` AS `f1`,`test`.`t1`.`f11` AS `f11`,`tt`.`f2` AS `f2`,`tt`.`f22` AS `f22` from `test`.`t1` join (/* select#2 */ select `test`.`t2`.`f2` AS `f2`,`test`.`t2`.`f22` AS `f22` from `test`.`t2` group by `test`.`t2`.`f2`) `tt` where (`tt`.`f2` = `test`.`t1`.`f1`) +SHOW STATUS LIKE 'Handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 0 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +FLUSH STATUS; +SELECT * FROM t1 JOIN (SELECT * FROM t2 GROUP BY f2) tt ON f1=f2; +f1 f11 f2 f22 +1 1 1 1 +2 2 2 2 +3 3 3 3 +SHOW STATUS LIKE 'Handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 6 +Handler_read_last 0 +Handler_read_next 3 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 21 +for materialized views +DROP VIEW v1,v2,v3; +CREATE VIEW v1 AS SELECT * FROM t1 GROUP BY f1; +CREATE VIEW v2 AS SELECT * FROM t2 GROUP BY f2; +CREATE VIEW v3 AS SELECT t1.f1,t1.f11 FROM t1 JOIN t1 AS t11 HAVING t1.f1<100; +ensure that view definitions are cached in the data-dictionary cache. +explain for simple derived +EXPLAIN SELECT * FROM v1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL 6 100.00 NULL +2 DERIVED t1 NULL ALL NULL NULL NULL NULL 6 100.00 Using temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`v1`.`f1` AS `f1`,`test`.`v1`.`f11` AS `f11` from `test`.`v1` +SELECT * FROM v1; +f1 f11 +1 1 +2 2 +3 3 +5 5 +7 7 +9 9 +explain showing created indexes and late materialization for views +FLUSH STATUS; +EXPLAIN SELECT * FROM t1 JOIN v2 ON f1=f2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 6 100.00 Using where +1 PRIMARY NULL ref 5 test.t1.f1 2 100.00 NULL +2 DERIVED t2 NULL ALL NULL NULL NULL NULL 6 100.00 Using temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`f1` AS `f1`,`test`.`t1`.`f11` AS `f11`,`test`.`v2`.`f2` AS `f2`,`test`.`v2`.`f22` AS `f22` from `test`.`t1` join `test`.`v2` where (`test`.`v2`.`f2` = `test`.`t1`.`f1`) +SHOW STATUS LIKE 'Handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 0 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +FLUSH STATUS; +SELECT * FROM t1 JOIN v2 ON f1=f2; +f1 f11 f2 f22 +1 1 1 1 +2 2 2 2 +3 3 3 3 +SHOW STATUS LIKE 'Handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 6 +Handler_read_last 0 +Handler_read_next 3 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 21 +EXPLAIN +SELECT * FROM t1,v3 AS v31,v3 WHERE t1.f1=v31.f1 and t1.f1=v3.f1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 6 100.00 Using where +1 PRIMARY NULL ref 5 test.t1.f1 3 100.00 NULL +1 PRIMARY NULL ref 5 test.t1.f1 3 100.00 NULL +3 DERIVED t1 NULL ALL NULL NULL NULL NULL 6 100.00 NULL +3 DERIVED t11 NULL ALL NULL NULL NULL NULL 6 100.00 Using join buffer (hash join) +2 DERIVED t1 NULL ALL NULL NULL NULL NULL 6 100.00 NULL +2 DERIVED t11 NULL ALL NULL NULL NULL NULL 6 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`f1` AS `f1`,`test`.`t1`.`f11` AS `f11`,`test`.`v31`.`f1` AS `f1`,`test`.`v31`.`f11` AS `f11`,`test`.`v3`.`f1` AS `f1`,`test`.`v3`.`f11` AS `f11` from `test`.`t1` join `test`.`v3` `v31` join `test`.`v3` where ((`test`.`v31`.`f1` = `test`.`t1`.`f1`) and (`test`.`v3`.`f1` = `test`.`t1`.`f1`)) +FLUSH STATUS; +SELECT * FROM t1,v3 AS v31,v3 WHERE t1.f1=v31.f1 and t1.f1=v3.f1; +f1 f11 f1 f11 f1 f11 +1 1 1 1 1 1 +1 1 1 1 1 1 +1 1 1 1 1 1 +1 1 1 1 1 1 +1 1 1 1 1 1 +1 1 1 1 1 1 +1 1 1 1 1 1 +1 1 1 1 1 1 +1 1 1 1 1 1 +1 1 1 1 1 1 +1 1 1 1 1 1 +1 1 1 1 1 1 +1 1 1 1 1 1 +1 1 1 1 1 1 +1 1 1 1 1 1 +1 1 1 1 1 1 +1 1 1 1 1 1 +1 1 1 1 1 1 +1 1 1 1 1 1 +1 1 1 1 1 1 +1 1 1 1 1 1 +1 1 1 1 1 1 +1 1 1 1 1 1 +1 1 1 1 1 1 +1 1 1 1 1 1 +1 1 1 1 1 1 +1 1 1 1 1 1 +1 1 1 1 1 1 +1 1 1 1 1 1 +1 1 1 1 1 1 +1 1 1 1 1 1 +1 1 1 1 1 1 +1 1 1 1 1 1 +1 1 1 1 1 1 +1 1 1 1 1 1 +1 1 1 1 1 1 +2 2 2 2 2 2 +2 2 2 2 2 2 +2 2 2 2 2 2 +2 2 2 2 2 2 +2 2 2 2 2 2 +2 2 2 2 2 2 +2 2 2 2 2 2 +2 2 2 2 2 2 +2 2 2 2 2 2 +2 2 2 2 2 2 +2 2 2 2 2 2 +2 2 2 2 2 2 +2 2 2 2 2 2 +2 2 2 2 2 2 +2 2 2 2 2 2 +2 2 2 2 2 2 +2 2 2 2 2 2 +2 2 2 2 2 2 +2 2 2 2 2 2 +2 2 2 2 2 2 +2 2 2 2 2 2 +2 2 2 2 2 2 +2 2 2 2 2 2 +2 2 2 2 2 2 +2 2 2 2 2 2 +2 2 2 2 2 2 +2 2 2 2 2 2 +2 2 2 2 2 2 +2 2 2 2 2 2 +2 2 2 2 2 2 +2 2 2 2 2 2 +2 2 2 2 2 2 +2 2 2 2 2 2 +2 2 2 2 2 2 +2 2 2 2 2 2 +2 2 2 2 2 2 +3 3 3 3 3 3 +3 3 3 3 3 3 +3 3 3 3 3 3 +3 3 3 3 3 3 +3 3 3 3 3 3 +3 3 3 3 3 3 +3 3 3 3 3 3 +3 3 3 3 3 3 +3 3 3 3 3 3 +3 3 3 3 3 3 +3 3 3 3 3 3 +3 3 3 3 3 3 +3 3 3 3 3 3 +3 3 3 3 3 3 +3 3 3 3 3 3 +3 3 3 3 3 3 +3 3 3 3 3 3 +3 3 3 3 3 3 +3 3 3 3 3 3 +3 3 3 3 3 3 +3 3 3 3 3 3 +3 3 3 3 3 3 +3 3 3 3 3 3 +3 3 3 3 3 3 +3 3 3 3 3 3 +3 3 3 3 3 3 +3 3 3 3 3 3 +3 3 3 3 3 3 +3 3 3 3 3 3 +3 3 3 3 3 3 +3 3 3 3 3 3 +3 3 3 3 3 3 +3 3 3 3 3 3 +3 3 3 3 3 3 +3 3 3 3 3 3 +3 3 3 3 3 3 +5 5 5 5 5 5 +5 5 5 5 5 5 +5 5 5 5 5 5 +5 5 5 5 5 5 +5 5 5 5 5 5 +5 5 5 5 5 5 +5 5 5 5 5 5 +5 5 5 5 5 5 +5 5 5 5 5 5 +5 5 5 5 5 5 +5 5 5 5 5 5 +5 5 5 5 5 5 +5 5 5 5 5 5 +5 5 5 5 5 5 +5 5 5 5 5 5 +5 5 5 5 5 5 +5 5 5 5 5 5 +5 5 5 5 5 5 +5 5 5 5 5 5 +5 5 5 5 5 5 +5 5 5 5 5 5 +5 5 5 5 5 5 +5 5 5 5 5 5 +5 5 5 5 5 5 +5 5 5 5 5 5 +5 5 5 5 5 5 +5 5 5 5 5 5 +5 5 5 5 5 5 +5 5 5 5 5 5 +5 5 5 5 5 5 +5 5 5 5 5 5 +5 5 5 5 5 5 +5 5 5 5 5 5 +5 5 5 5 5 5 +5 5 5 5 5 5 +5 5 5 5 5 5 +9 9 9 9 9 9 +9 9 9 9 9 9 +9 9 9 9 9 9 +9 9 9 9 9 9 +9 9 9 9 9 9 +9 9 9 9 9 9 +9 9 9 9 9 9 +9 9 9 9 9 9 +9 9 9 9 9 9 +9 9 9 9 9 9 +9 9 9 9 9 9 +9 9 9 9 9 9 +9 9 9 9 9 9 +9 9 9 9 9 9 +9 9 9 9 9 9 +9 9 9 9 9 9 +9 9 9 9 9 9 +9 9 9 9 9 9 +9 9 9 9 9 9 +9 9 9 9 9 9 +9 9 9 9 9 9 +9 9 9 9 9 9 +9 9 9 9 9 9 +9 9 9 9 9 9 +9 9 9 9 9 9 +9 9 9 9 9 9 +9 9 9 9 9 9 +9 9 9 9 9 9 +9 9 9 9 9 9 +9 9 9 9 9 9 +9 9 9 9 9 9 +9 9 9 9 9 9 +9 9 9 9 9 9 +9 9 9 9 9 9 +9 9 9 9 9 9 +9 9 9 9 9 9 +7 7 7 7 7 7 +7 7 7 7 7 7 +7 7 7 7 7 7 +7 7 7 7 7 7 +7 7 7 7 7 7 +7 7 7 7 7 7 +7 7 7 7 7 7 +7 7 7 7 7 7 +7 7 7 7 7 7 +7 7 7 7 7 7 +7 7 7 7 7 7 +7 7 7 7 7 7 +7 7 7 7 7 7 +7 7 7 7 7 7 +7 7 7 7 7 7 +7 7 7 7 7 7 +7 7 7 7 7 7 +7 7 7 7 7 7 +7 7 7 7 7 7 +7 7 7 7 7 7 +7 7 7 7 7 7 +7 7 7 7 7 7 +7 7 7 7 7 7 +7 7 7 7 7 7 +7 7 7 7 7 7 +7 7 7 7 7 7 +7 7 7 7 7 7 +7 7 7 7 7 7 +7 7 7 7 7 7 +7 7 7 7 7 7 +7 7 7 7 7 7 +7 7 7 7 7 7 +7 7 7 7 7 7 +7 7 7 7 7 7 +7 7 7 7 7 7 +7 7 7 7 7 7 +SHOW STATUS LIKE 'Handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 42 +Handler_read_last 0 +Handler_read_next 252 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 35 +explain showing late materialization for views +EXPLAIN SELECT * FROM v1 JOIN v4 ON f1=f2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 6 33.33 Using where +1 PRIMARY NULL ref 5 test.t2.f2 2 100.00 NULL +2 DERIVED t1 NULL ALL NULL NULL NULL NULL 6 100.00 Using temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`v1`.`f1` AS `f1`,`test`.`v1`.`f11` AS `f11`,`test`.`t2`.`f2` AS `f2`,`test`.`t2`.`f22` AS `f22` from `test`.`v1` join `test`.`t2` where ((`test`.`v1`.`f1` = `test`.`t2`.`f2`) and (`test`.`t2`.`f2` in (2,3))) +SELECT * FROM v1 JOIN v4 ON f1=f2; +f1 f11 f2 f22 +2 2 2 2 +3 3 3 3 +merged derived in merged derived +EXPLAIN SELECT * FROM (SELECT * FROM +(SELECT * FROM t1 WHERE f1 < 7) tt WHERE f1 > 2) zz; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 6 16.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`f1` AS `f1`,`test`.`t1`.`f11` AS `f11` from `test`.`t1` where ((`test`.`t1`.`f1` > 2) and (`test`.`t1`.`f1` < 7)) +SELECT * FROM (SELECT * FROM +(SELECT * FROM t1 WHERE f1 < 7) tt WHERE f1 > 2) zz; +f1 f11 +3 3 +5 5 +materialized derived in merged derived +EXPLAIN SELECT * FROM (SELECT * FROM +(SELECT * FROM t1 WHERE f1 < 7 GROUP BY f1) tt WHERE f1 > 2) zz; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 NULL +3 DERIVED t1 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Using temporary +Warnings: +Note 1003 /* select#1 */ select `tt`.`f1` AS `f1`,`tt`.`f11` AS `f11` from (/* select#3 */ select `test`.`t1`.`f1` AS `f1`,`test`.`t1`.`f11` AS `f11` from `test`.`t1` where ((`test`.`t1`.`f1` < 7) and (`test`.`t1`.`f1` > 2)) group by `test`.`t1`.`f1`) `tt` +SELECT * FROM (SELECT * FROM +(SELECT * FROM t1 WHERE f1 < 7 GROUP BY f1) tt WHERE f1 > 2) zz; +f1 f11 +3 3 +5 5 +merged derived in materialized derived +EXPLAIN SELECT * FROM (SELECT * FROM +(SELECT * FROM t1 WHERE f1 < 7) tt WHERE f1 > 2 GROUP BY f1) zz; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DERIVED t1 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Using temporary +Warnings: +Note 1003 /* select#1 */ select `zz`.`f1` AS `f1`,`zz`.`f11` AS `f11` from (/* select#2 */ select `test`.`t1`.`f1` AS `f1`,`test`.`t1`.`f11` AS `f11` from `test`.`t1` where ((`test`.`t1`.`f1` > 2) and (`test`.`t1`.`f1` < 7)) group by `test`.`t1`.`f1`) `zz` +SELECT * FROM (SELECT * FROM +(SELECT * FROM t1 WHERE f1 < 7) tt WHERE f1 > 2 GROUP BY f1) zz; +f1 f11 +3 3 +5 5 +materialized derived in materialized derived +EXPLAIN SELECT * FROM (SELECT * FROM +(SELECT * FROM t1 WHERE f1 < 7 GROUP BY f1) tt WHERE f1 > 2 GROUP BY f1) zz; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DERIVED NULL ALL NULL NULL NULL NULL 2 100.00 Using temporary +3 DERIVED t1 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Using temporary +Warnings: +Note 1003 /* select#1 */ select `zz`.`f1` AS `f1`,`zz`.`f11` AS `f11` from (/* select#2 */ select `tt`.`f1` AS `f1`,`tt`.`f11` AS `f11` from (/* select#3 */ select `test`.`t1`.`f1` AS `f1`,`test`.`t1`.`f11` AS `f11` from `test`.`t1` where ((`test`.`t1`.`f1` < 7) and (`test`.`t1`.`f1` > 2)) group by `test`.`t1`.`f1`) `tt` group by `tt`.`f1`) `zz` +SELECT * FROM (SELECT * FROM +(SELECT * FROM t1 WHERE f1 < 7 GROUP BY f1) tt WHERE f1 > 2 GROUP BY f1) zz; +f1 f11 +3 3 +5 5 +mat in merged derived join mat in merged derived +EXPLAIN SELECT * FROM +(SELECT * FROM (SELECT * FROM t1 WHERE f1 < 7 GROUP BY f1) tt WHERE f1 > 2) x +JOIN +(SELECT * FROM (SELECT * FROM t1 WHERE f1 < 7 GROUP BY f1) tt WHERE f1 > 2) z +ON x.f1 = z.f1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 PRIMARY NULL ref 5 tt.f1 2 100.00 NULL +5 DERIVED t1 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Using temporary +3 DERIVED t1 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Using temporary +Warnings: +Note 1003 /* select#1 */ select `tt`.`f1` AS `f1`,`tt`.`f11` AS `f11`,`tt`.`f1` AS `f1`,`tt`.`f11` AS `f11` from (/* select#3 */ select `test`.`t1`.`f1` AS `f1`,`test`.`t1`.`f11` AS `f11` from `test`.`t1` where ((`test`.`t1`.`f1` < 7) and (`test`.`t1`.`f1` > 2)) group by `test`.`t1`.`f1`) `tt` join (/* select#5 */ select `t1`.`f1` AS `f1`,`t1`.`f11` AS `f11` from `test`.`t1` where ((`t1`.`f1` < 7) and (`t1`.`f1` > 2)) group by `t1`.`f1`) `tt` where (`tt`.`f1` = `tt`.`f1`) +FLUSH STATUS; +SELECT * FROM +(SELECT * FROM (SELECT * FROM t1 WHERE f1 < 7 GROUP BY f1) tt WHERE f1 > 2) x +JOIN +(SELECT * FROM (SELECT * FROM t1 WHERE f1 < 7 GROUP BY f1) tt WHERE f1 > 2) z +ON x.f1 = z.f1; +f1 f11 f1 f11 +3 3 3 3 +5 5 5 5 +SHOW STATUS LIKE 'Handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 2 +Handler_read_last 0 +Handler_read_next 2 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 23 +FLUSH STATUS; +merged in merged derived join merged in merged derived +EXPLAIN SELECT * FROM +(SELECT * FROM +(SELECT * FROM t1 WHERE f1 < 7 ) tt WHERE f1 > 2 ) x +JOIN +(SELECT * FROM +(SELECT * FROM t1 WHERE f1 < 7 ) tt WHERE f1 > 2 ) z +ON x.f1 = z.f1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 6 16.67 Using where +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`f1` AS `f1`,`test`.`t1`.`f11` AS `f11`,`t1`.`f1` AS `f1`,`t1`.`f11` AS `f11` from `test`.`t1` join `test`.`t1` where ((`t1`.`f1` = `test`.`t1`.`f1`) and (`t1`.`f1` > 2) and (`test`.`t1`.`f1` < 7) and (`test`.`t1`.`f1` > 2) and (`test`.`t1`.`f1` < 7)) +SELECT * FROM +(SELECT * FROM +(SELECT * FROM t1 WHERE f1 < 7 ) tt WHERE f1 > 2 ) x +JOIN +(SELECT * FROM +(SELECT * FROM t1 WHERE f1 < 7 ) tt WHERE f1 > 2 ) z +ON x.f1 = z.f1; +f1 f11 f1 f11 +3 3 3 3 +5 5 5 5 +materialized in materialized derived join +materialized in materialized derived +EXPLAIN SELECT * FROM +(SELECT * FROM +(SELECT * FROM t1 WHERE f1 < 7 GROUP BY f1) tt WHERE f1 > 2 GROUP BY f1) x +JOIN +(SELECT * FROM +(SELECT * FROM t1 WHERE f1 < 7 GROUP BY f1) tt WHERE f1 > 2 GROUP BY f1) z +ON x.f1 = z.f1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 PRIMARY NULL ref 5 x.f1 2 100.00 NULL +4 DERIVED NULL ALL NULL NULL NULL NULL 2 100.00 Using temporary +5 DERIVED t1 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Using temporary +2 DERIVED NULL ALL NULL NULL NULL NULL 2 100.00 Using temporary +3 DERIVED t1 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Using temporary +Warnings: +Note 1003 /* select#1 */ select `x`.`f1` AS `f1`,`x`.`f11` AS `f11`,`z`.`f1` AS `f1`,`z`.`f11` AS `f11` from (/* select#2 */ select `tt`.`f1` AS `f1`,`tt`.`f11` AS `f11` from (/* select#3 */ select `test`.`t1`.`f1` AS `f1`,`test`.`t1`.`f11` AS `f11` from `test`.`t1` where ((`test`.`t1`.`f1` < 7) and (`test`.`t1`.`f1` > 2)) group by `test`.`t1`.`f1`) `tt` group by `tt`.`f1`) `x` join (/* select#4 */ select `tt`.`f1` AS `f1`,`tt`.`f11` AS `f11` from (/* select#5 */ select `t1`.`f1` AS `f1`,`t1`.`f11` AS `f11` from `test`.`t1` where ((`t1`.`f1` < 7) and (`t1`.`f1` > 2)) group by `t1`.`f1`) `tt` group by `tt`.`f1`) `z` where (`z`.`f1` = `x`.`f1`) +SELECT * FROM +(SELECT * FROM +(SELECT * FROM t1 WHERE f1 < 7 GROUP BY f1) tt WHERE f1 > 2 GROUP BY f1) x +JOIN +(SELECT * FROM +(SELECT * FROM t1 WHERE f1 < 7 GROUP BY f1) tt WHERE f1 > 2 GROUP BY f1) z +ON x.f1 = z.f1; +f1 f11 f1 f11 +3 3 3 3 +5 5 5 5 +merged view in materialized derived +EXPLAIN +SELECT * FROM (SELECT * FROM v4 GROUP BY 1) tt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DERIVED t2 NULL ALL NULL NULL NULL NULL 6 33.33 Using where; Using temporary +Warnings: +Note 1003 /* select#1 */ select `tt`.`f2` AS `f2`,`tt`.`f22` AS `f22` from (/* select#2 */ select `test`.`t2`.`f2` AS `f2`,`test`.`t2`.`f22` AS `f22` from `test`.`t2` where (`test`.`t2`.`f2` in (2,3)) group by `test`.`t2`.`f2`) `tt` +SELECT * FROM (SELECT * FROM v4 GROUP BY 1) tt; +f2 f22 +2 2 +3 3 +materialized view in merged derived +EXPLAIN +SELECT * FROM ( SELECT * FROM v1 WHERE f1 < 7) tt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 NULL +3 DERIVED t1 NULL ALL NULL NULL NULL NULL 6 33.33 Using where; Using temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`v1`.`f1` AS `f1`,`test`.`v1`.`f11` AS `f11` from `test`.`v1` +SELECT * FROM ( SELECT * FROM v1 WHERE f1 < 7) tt; +f1 f11 +1 1 +2 2 +3 3 +5 5 +merged view in a merged view in a merged derived +CREATE VIEW v6 AS SELECT * FROM v4 WHERE f2 < 7; +EXPLAIN SELECT * FROM (SELECT * FROM v6) tt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`f2` AS `f2`,`test`.`t2`.`f22` AS `f22` from `test`.`t2` where ((`test`.`t2`.`f2` < 7) and (`test`.`t2`.`f2` in (2,3))) +SELECT * FROM (SELECT * FROM v6) tt; +f2 f22 +3 3 +2 2 +materialized view in a merged view in a materialized derived +CREATE VIEW v7 AS SELECT * FROM v1; +EXPLAIN SELECT * FROM (SELECT * FROM v7 GROUP BY 1) tt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL 6 100.00 NULL +2 DERIVED NULL ALL NULL NULL NULL NULL 6 100.00 Using temporary +4 DERIVED t1 NULL ALL NULL NULL NULL NULL 6 100.00 Using temporary +Warnings: +Note 1003 /* select#1 */ select `tt`.`f1` AS `f1`,`tt`.`f11` AS `f11` from (/* select#2 */ select `test`.`v1`.`f1` AS `f1`,`test`.`v1`.`f11` AS `f11` from `test`.`v1` group by `test`.`v1`.`f1`) `tt` +SELECT * FROM (SELECT * FROM v7 GROUP BY 1) tt; +f1 f11 +1 1 +2 2 +3 3 +5 5 +7 7 +9 9 +JOIN of above two +EXPLAIN SELECT * FROM v6 JOIN v7 ON f2=f1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where +1 PRIMARY NULL ref 5 test.t2.f2 2 100.00 NULL +5 DERIVED t1 NULL ALL NULL NULL NULL NULL 6 100.00 Using temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`f2` AS `f2`,`test`.`t2`.`f22` AS `f22`,`test`.`v1`.`f1` AS `f1`,`test`.`v1`.`f11` AS `f11` from `test`.`t2` join `test`.`v1` where ((`test`.`v1`.`f1` = `test`.`t2`.`f2`) and (`test`.`t2`.`f2` < 7) and (`test`.`t2`.`f2` in (2,3))) +SELECT * FROM v6 JOIN v7 ON f2=f1; +f2 f22 f1 f11 +2 2 2 2 +3 3 3 3 +test two keys +CREATE TABLE t3(f3 INT, f33 INT); +INSERT INTO t1 VALUES(6,6),(8,8); +INSERT INTO t3 VALUES(1,1),(2,2),(3,3),(5,5); +EXPLAIN SELECT * FROM t1 JOIN (SELECT * FROM t2) tt ON t1.f1=tt.f2 +JOIN t3 ON tt.f22=t3.f3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`f1` AS `f1`,`test`.`t1`.`f11` AS `f11`,`test`.`t2`.`f2` AS `f2`,`test`.`t2`.`f22` AS `f22`,`test`.`t3`.`f3` AS `f3`,`test`.`t3`.`f33` AS `f33` from `test`.`t1` join `test`.`t2` join `test`.`t3` where ((`test`.`t1`.`f1` = `test`.`t2`.`f2`) and (`test`.`t2`.`f22` = `test`.`t3`.`f3`)) +SELECT * FROM t1 JOIN (SELECT * FROM t2) tt ON t1.f1=tt.f2 +JOIN t3 ON tt.f22=t3.f3; +f1 f11 f2 f22 f3 f33 +1 1 1 1 1 1 +2 2 2 2 2 2 +3 3 3 3 3 3 +DROP TABLE t1,t2,t3; +DROP VIEW v1,v2,v3,v4,v6,v7; +# +# +# BUG#11783262: CRASH IN ITEM_FIELD::ITEM_FIELD IN ITEM.CC ON SUBQUERY +# IN FROM WITH WL5274 +# +CREATE TABLE t1 ( +col_int_key INT, +col_time_key time, +col_varchar_key VARCHAR(1), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) ENGINE=INNODB; +SELECT alias1.col_time_key AS field1 +FROM ( ( SELECT SQ1_alias1.* FROM t1 AS SQ1_alias1 ) AS alias1 +INNER JOIN t1 AS alias2 +ON (alias2.col_int_key = alias1.col_int_key) +) +WHERE alias1.col_int_key = 207 +ORDER BY alias1.col_varchar_key, field1; +field1 +DROP TABLE t1; +# +# Bug#11807437: VALGRIND WARNING IN MYSQL_DERIVED_OPTIMIZE() LINE 293 +# +CREATE TABLE t1 ( +f1 int(11) DEFAULT NULL +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +SELECT 1 +FROM ( +SELECT 1, 2 FROM DUAL +WHERE EXISTS ( +SELECT f1 +FROM t1 +)) AS tt +; +1 +DROP TABLE t1; +# +# +# Bug#11808582: VALGRIND ON WL#5274: INVALID WRITE IN MC_REPLACE_STRMEM.C:493) +# +CREATE TABLE t1 ( +pk INT NOT NULL AUTO_INCREMENT, +col_int_key INT, +col_time_key time, +col_varchar_key VARCHAR(1), +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) ENGINE=InnoDB; +SELECT tt.col_time_key +FROM ( ( SELECT * FROM t1 ) AS tt +INNER JOIN t1 +ON (t1.col_int_key = tt.col_int_key) +) +WHERE tt.col_int_key = 207 +ORDER BY tt.col_varchar_key, tt.pk ASC, 1; +col_time_key +DROP TABLE t1; +# +# Bug#11791677 - ASSERTION FAILED IN JOIN_MATERIALIZE_TABLE IN +# SQL_SELECT.CC ON NESTED SUBQUERY +# +CREATE TABLE t1 ( +pk int(11) NOT NULL AUTO_INCREMENT, +col_int_key int(11) DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +PRIMARY KEY (pk), +KEY col_varchar_key (col_varchar_key,col_int_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (10,8,'v'), (29,4,'c'); +CREATE TABLE t2 ( +pk int(11) NOT NULL AUTO_INCREMENT, +col_int_nokey int(11) DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +PRIMARY KEY (pk) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (16,1,'c'), (20,4,'d'); +CREATE TABLE t3 ( +`field1` varchar(1) DEFAULT NULL, +`field2` int(11) DEFAULT NULL +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t3 VALUES ('m',6),('c',4); +SELECT * +FROM t3 +WHERE (field1, field2) IN ( +SELECT t1.col_varchar_key AS field1, +t1.col_int_key AS field2 +FROM ( t1 INNER JOIN ( +SELECT t2.* +FROM t2 +WHERE t2.col_int_nokey < t2.pk ) AS alias2 +ON (alias2.col_varchar_key = t1.col_varchar_key ) ) +GROUP BY field1, field2 +ORDER BY t1.col_int_key, t1 .pk DESC ) +; +field1 field2 +c 4 +DROP TABLE t1,t2,t3; +# +# +# Bug#11791705 - CRASH IN JOIN_MATERIALIZE_TABLE OR ASSERTION FAIL: +# !TAB->SAVE_READ_FIRST_RECORD +# +CREATE TABLE t1 (a INTEGER); +INSERT INTO t1 VALUES (NULL),(NULL); +SELECT * FROM t1 +WHERE (a, a) NOT IN +(SELECT * FROM (SELECT 8, 4 UNION SELECT 2, 3) tt) ; +a +DROP TABLE t1; +# +# Bug#11791649 - ASSERT: FIXED == 0, IN ITEM.CC ON EXPLAIN WITH VIEW +# IN SUBQUERY +# +CREATE TABLE t1 (pk int); +INSERT INTO t1 VALUES (1); +CREATE TABLE t2 (col_varchar_nokey varchar(1)); +INSERT INTO t2 VALUES ('m'), ('f'); +EXPLAIN SELECT pk +FROM t1 +WHERE (2) IN +( SELECT * +FROM (SELECT COUNT(col_varchar_nokey) FROM t2) d +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 PRIMARY NULL ALL NULL NULL NULL NULL 1 100.00 FirstMatch(t1) +3 DERIVED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select '1' AS `pk` from semi join ((/* select#3 */ select count(`test`.`t2`.`col_varchar_nokey`) AS `COUNT(col_varchar_nokey)` from `test`.`t2` having (2 = count(`test`.`t2`.`col_varchar_nokey`))) `d`) +DROP TABLE t1,t2; +# +# +# Bug#12735934 - Lost LIMIT clause caused wrong result. +# +CREATE TABLE t1 (f1 VARCHAR(1), key(f1)); +INSERT INTO t1 VALUES ('a'); +CREATE VIEW v1 AS SELECT f1 FROM t1 ORDER BY 1 LIMIT 0; +SELECT * FROM v1; +f1 +DROP VIEW v1; +DROP TABLE t1; +# +# +# Bug#12726927: An outdated assertion caused server failure. +# +CREATE TABLE t1 ( +pk int(11) NOT NULL AUTO_INCREMENT, +col_int_nokey int(11) NOT NULL, +col_varchar_key varchar(1) NOT NULL, +PRIMARY KEY (pk), +KEY col_varchar_key (col_varchar_key) +) ENGINE=MyISAM; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (10,1,'v'), (24,18,'h'); +CREATE TABLE t2 ( +pk int(11) NOT NULL AUTO_INCREMENT, +col_date_key date NOT NULL, +col_date_nokey date NOT NULL, +col_time_nokey time NOT NULL, +col_varchar_key varchar(1) NOT NULL, +col_varchar_nokey varchar(1) NOT NULL, +PRIMARY KEY (pk), +KEY col_date_key (col_date_key), +KEY col_varchar_key (col_varchar_key) +) ENGINE=MyISAM; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (1,'1900-01-01','1900-01-01','00:00:00','k','k'); +SELECT OUTR.col_date_key +FROM t2 AS OUTR2 +LEFT JOIN t2 AS OUTR ON OUTR2.pk < OUTR.pk +WHERE ( OUTR.col_varchar_nokey , OUTR.col_varchar_key ) +IN ( +SELECT DISTINCT col_varchar_key , col_varchar_key +FROM t1 +WHERE col_int_nokey XOR OUTR.col_time_nokey +) +XOR OUTR.col_date_nokey IS NULL +; +col_date_key +NULL +DROP TABLE t1,t2; +# +# +# Bug#12799731 - CRASH IN END_READ_RECORD. +# +create table t1(f1 char(255) charset utf8); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +insert into t1 values('1'),('2'),('3'),('4'),('5'),('6'),('7'),('8'),('9'),('0'); +set @save_internal_tmp_mem_storage_engine= @@internal_tmp_mem_storage_engine; +set session internal_tmp_mem_storage_engine='memory'; +set @save_heap_size= @@max_heap_table_size; +set @@max_heap_table_size= 1; +Warnings: +Warning 1292 Truncated incorrect max_heap_table_size value: '1' +SET @optimizer_switch_saved= @@optimizer_switch; +SET @@optimizer_switch="derived_merge=off"; +flush status; +select count(*) from t1 join ( +select t1.f1 from t1 join t1 as t2 join t1 as t3) tt on t1.f1 = tt.f1; +count(*) +1000 +show status like 'Handler_write'; +Variable_name Value +Handler_write 1021 +set @@max_heap_table_size= @save_heap_size; +set session internal_tmp_mem_storage_engine= @save_internal_tmp_mem_storage_engine; +SET @@optimizer_switch= @optimizer_switch_saved; +drop table t1; +# +# +# Bug#12896124: Crash on rqg_mdl_stability test +# +CREATE TABLE t1(f1 INT); +INSERT INTO t1 VALUES (1),(2),(3); +CREATE FUNCTION func1 (param1 INTEGER) RETURNS INT NOT DETERMINISTIC +return param1; +CREATE FUNCTION func2 (param1 INTEGER) RETURNS INT +return param1; +SET @optimizer_switch_saved= @@optimizer_switch; +SET @@optimizer_switch="derived_merge=off"; +SELECT * FROM (SELECT * FROM t1) tt WHERE f1 = func1(f1); +f1 +1 +2 +3 +EXPLAIN SELECT * FROM (SELECT * FROM t1) tt WHERE f1 = func1(f1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DERIVED t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `tt`.`f1` AS `f1` from (/* select#2 */ select `test`.`t1`.`f1` AS `f1` from `test`.`t1` where (`test`.`t1`.`f1` = `func1`(`test`.`t1`.`f1`))) `tt` +SELECT * FROM (SELECT * FROM t1) tt WHERE f1 = func2(f1); +f1 +1 +2 +3 +EXPLAIN SELECT * FROM (SELECT * FROM t1) tt WHERE f1 = func2(f1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DERIVED t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `tt`.`f1` AS `f1` from (/* select#2 */ select `test`.`t1`.`f1` AS `f1` from `test`.`t1` where (`test`.`t1`.`f1` = `func2`(`test`.`t1`.`f1`))) `tt` +SET @@optimizer_switch= @optimizer_switch_saved; +DROP FUNCTION func1; +DROP FUNCTION func2; +DROP TABLE t1; +# +# +# Bug#12909844: Missing type cast caused false assertion +# +CREATE TABLE t1 ( fk INT) ENGINE=INNODB; +CREATE TABLE t2 ( +f1 INT, f2 INT, f3 INT, f4 INT, f5 INT, f6 INT, +f7 INT, f8 INT, f9 INT, f10 INT, f11 INT, f12 INT, +f13 INT, f14 INT, f15 INT, f16 INT, f17 INT, f18 INT, +f19 INT, f20 INT, f21 INT, f22 INT, f23 INT, f24 INT, +f25 INT, f26 INT, f27 INT, f28 INT, f29 INT, f30 INT, +f31 INT, f32 TEXT, fk INT) ENGINE=INNODB; +SET @optimizer_switch_saved= @@optimizer_switch; +SET @@optimizer_switch="derived_merge=off"; +SELECT alias2.fk AS field1 FROM t1 AS alias1 JOIN +(SELECT * FROM t2 ) AS alias2 ON alias1.fk = alias2.fk; +field1 +EXPLAIN +SELECT alias2.fk AS field1 FROM t1 AS alias1 JOIN +(SELECT * FROM t2 ) AS alias2 ON alias1.fk = alias2.fk; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY alias1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 PRIMARY NULL ref 5 test.alias1.fk 2 100.00 NULL +2 DERIVED t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `alias2`.`fk` AS `field1` from `test`.`t1` `alias1` join (/* select#2 */ select `test`.`t2`.`f1` AS `f1`,`test`.`t2`.`f2` AS `f2`,`test`.`t2`.`f3` AS `f3`,`test`.`t2`.`f4` AS `f4`,`test`.`t2`.`f5` AS `f5`,`test`.`t2`.`f6` AS `f6`,`test`.`t2`.`f7` AS `f7`,`test`.`t2`.`f8` AS `f8`,`test`.`t2`.`f9` AS `f9`,`test`.`t2`.`f10` AS `f10`,`test`.`t2`.`f11` AS `f11`,`test`.`t2`.`f12` AS `f12`,`test`.`t2`.`f13` AS `f13`,`test`.`t2`.`f14` AS `f14`,`test`.`t2`.`f15` AS `f15`,`test`.`t2`.`f16` AS `f16`,`test`.`t2`.`f17` AS `f17`,`test`.`t2`.`f18` AS `f18`,`test`.`t2`.`f19` AS `f19`,`test`.`t2`.`f20` AS `f20`,`test`.`t2`.`f21` AS `f21`,`test`.`t2`.`f22` AS `f22`,`test`.`t2`.`f23` AS `f23`,`test`.`t2`.`f24` AS `f24`,`test`.`t2`.`f25` AS `f25`,`test`.`t2`.`f26` AS `f26`,`test`.`t2`.`f27` AS `f27`,`test`.`t2`.`f28` AS `f28`,`test`.`t2`.`f29` AS `f29`,`test`.`t2`.`f30` AS `f30`,`test`.`t2`.`f31` AS `f31`,`test`.`t2`.`f32` AS `f32`,`test`.`t2`.`fk` AS `fk` from `test`.`t2`) `alias2` where (`alias2`.`fk` = `test`.`alias1`.`fk`) +SET @@optimizer_switch= @optimizer_switch_saved; +DROP TABLE t1, t2; +# +# +# Bug#12910039: Incorrect merge caused segmentation fault. +# +CREATE TABLE t1 (f1 int) ENGINE=myisam; +CREATE TABLE t2 (f1 text) ENGINE=innodb; +SELECT 1 FROM ( +( SELECT * FROM ( SELECT * FROM t2 ) AS alias1 ) AS alias1, +( SELECT * FROM t1 ) AS alias2 ); +1 +DROP TABLE t1,t2; +# +# +# Bug#12910006: MRR initialization on a derived table caused crash. +# +SET @save_switch= @@SESSION.optimizer_switch; +SET @@SESSION.optimizer_switch="batched_key_access=on,derived_merge=off"; +CREATE TABLE t1 ( pk integer auto_increment, +col_blob_key blob, primary key (pk)) ENGINE=innodb; +CREATE TABLE t2 (col_tinytext tinytext null, +pk integer auto_increment, col_text text, +col_blob blob, primary key (pk)) ENGINE=innodb; +SELECT alias1.col_text AS field1 , +alias1.col_tinytext AS field2 +FROM t2 AS alias1 +LEFT OUTER JOIN ( SELECT * FROM t1 ) AS alias2 ON alias1.pk = alias2.pk +WHERE alias2.pk >=1 AND alias2.pk < 3 +ORDER BY field1,field2 ASC; +field1 field2 +SET @@SESSION.optimizer_switch= @save_switch; +DROP TABLE t1, t2; +# +# Bug#13106350: MRR initialization on a derived table caused crash. +# +SET @save_switch= @@optimizer_switch; +SET @@optimizer_switch="materialization=off,derived_merge=off"; +CREATE TABLE t1 (pk INTEGER PRIMARY KEY, vc VARCHAR(20)) charset utf8mb4; +INSERT INTO t1 VALUES(7, 'seven'), (13, 'thirteen'); +CREATE TABLE t2 (pk INTEGER PRIMARY KEY, vc1 VARCHAR(20), vc2 VARCHAR(20)) charset utf8mb4; +INSERT INTO t2 VALUES(7, 'seven', 's'), (14, 'fourteen', 'f'); +CREATE TABLE t3 (pk INTEGER PRIMARY KEY, vc VARCHAR(20)) charset utf8mb4; +INSERT INTO t3 VALUES(5, 'f'), (6, 's'), (7, 's'); +explain SELECT derived.vc +FROM (SELECT * FROM t1) AS derived +WHERE derived.vc IN ( +SELECT t2.vc1 +FROM t2 JOIN t3 ON t2.vc2=t3.vc); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Start temporary +1 PRIMARY t3 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +1 PRIMARY NULL ref 83 test.t2.vc1 2 100.00 End temporary +2 DERIVED t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `derived`.`vc` AS `vc` from (/* select#2 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`vc` AS `vc` from `test`.`t1`) `derived` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`vc` = `test`.`t2`.`vc2`) and (`derived`.`vc` = `test`.`t2`.`vc1`)) +SELECT derived.vc +FROM (SELECT * FROM t1) AS derived +WHERE derived.vc IN ( +SELECT t2.vc1 +FROM t2 JOIN t3 ON t2.vc2=t3.vc); +vc +seven +SET @@optimizer_switch= @save_switch; +DROP TABLE t1, t2, t3; +# +# +# Bug#13107577: Derived table in a semi-join caused failed assertion. +# +SET @save_switch= @@optimizer_switch; +SET @@optimizer_switch="derived_merge=off"; +CREATE TABLE t1 ( +`col_int_key` int(11) NOT NULL, +`col_varchar_nokey` varchar(1) NOT NULL +) ENGINE=MyISAM; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (8,'m'), (4,'b'), (4,'x'), (7,'g'), (4,'p'); +CREATE VIEW v1 AS SELECT * FROM t1; +SELECT col_int_key +FROM t1 +WHERE ( NOT EXISTS ( +SELECT col_varchar_nokey +FROM t1 +WHERE ( 7 ) IN ( +SELECT v1.col_int_key +FROM ( v1 JOIN ( SELECT * FROM t1 ) AS d1 +ON ( d1.col_varchar_nokey = v1.col_varchar_nokey ) ) +) +) ) +; +col_int_key +DROP VIEW v1; +DROP TABLE t1; +SET @@optimizer_switch= @save_switch; +# +# Bug#13105833: Crash when using LooseScan sj-strategy for a view. +# +CREATE TABLE t1 (pk int(11)) ENGINE=InnoDB; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (1); +CREATE TABLE t2 (pk int(11)) ENGINE=InnoDB; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (1), (2), (3); +CREATE VIEW v1 AS SELECT DISTINCT pk FROM t1; +SELECT pk +FROM t2 +WHERE pk IN ( SELECT * FROM v1 ) ; +pk +1 +DROP TABLE t1,t2; +DROP VIEW v1; +# +# +# Bug#13261277: Unchecked key length caused missing records. +# +CREATE TABLE t1 ( +col_varchar varchar(1024) CHARACTER SET utf8 DEFAULT NULL, +stub1 varchar(1024) CHARACTER SET utf8 DEFAULT NULL, +stub2 varchar(1024) CHARACTER SET utf8 DEFAULT NULL, +stub3 varchar(1024) CHARACTER SET utf8 DEFAULT NULL +); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES +('d','d','l','ther'), +(NULL,'s','NJBIQ','trzetuchv'), +(-715390976,'coul','MYWFB','cfhtrzetu'), +(1696792576,'f','i\'s','c'), + (1,'i','ltpemcfhtr','gsltpemcf'), + (-663027712,'mgsltpemcf','sa','amgsltpem'), + (-1686700032,'JPRVK','i','vamgsltpe'), + (NULL,'STUNB','UNVJV','u'), + (5,'oka','qyihvamgsl','AXSMD'), + (NULL,'tqwmqyihva','h','yntqwmqyi'), + (3,'EGMJN','e','e'); +CREATE TABLE t2 ( +col_varchar varchar(10) DEFAULT NULL, +col_int INT DEFAULT NULL +) charset utf8mb4; +INSERT INTO t2 VALUES ('d',9); +SET @save_heap_size= @@max_heap_table_size; +SET @@max_heap_table_size= 16384; +SET @optimizer_switch_saved= @@optimizer_switch; +SET @@optimizer_switch="derived_merge=off"; +SELECT t2.col_int +FROM t2 +RIGHT JOIN ( SELECT * FROM t1 ) AS dt +ON t2.col_varchar = dt.col_varchar +WHERE t2.col_int IS NOT NULL ; +col_int +9 +# Shouldn't use auto_key0 for derived table +EXPLAIN +SELECT t2.col_int +FROM t2 +RIGHT JOIN ( SELECT * FROM t1 ) AS dt +ON t2.col_varchar = dt.col_varchar +WHERE t2.col_int IS NOT NULL ; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t2 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 PRIMARY NULL ALL NULL NULL NULL NULL 11 10.00 Using where +2 DERIVED t1 NULL ALL NULL NULL NULL NULL 11 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select '9' AS `col_int` from (/* select#2 */ select `test`.`t1`.`col_varchar` AS `col_varchar`,`test`.`t1`.`stub1` AS `stub1`,`test`.`t1`.`stub2` AS `stub2`,`test`.`t1`.`stub3` AS `stub3` from `test`.`t1`) `dt` where (('9' is not null) and ('d' = `dt`.`col_varchar`)) +SET @@max_heap_table_size= @save_heap_size; +SET @@optimizer_switch= @optimizer_switch_saved; +DROP TABLE t1,t2; +# +# +# Bug#13383857: Another crash in memcpy from +# join_cache::write_record_data with semijoin +# +CREATE TABLE t1 ( +col_int_key INT DEFAULT NULL, +col_time_nokey TIME DEFAULT NULL, +col_varchar_key VARCHAR(1) DEFAULT NULL, +col_varchar_nokey VARCHAR(1) DEFAULT NULL, +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset latin1; +INSERT INTO t1 VALUES +(8,'22:55:23','x','x'), +(7,'10:19:31','d','d'), +(1,'14:40:36','r','r'), +(7,'04:37:47','f','f'), +(9,'19:34:06','y','y'), +(NULL,'20:35:33','u','u'), +(1,NULL,'m','m'), +(9,'14:43:37',NULL,NULL), +(2,'02:23:09','o','o'), +(9,'01:22:45','w','w'), +(2,'00:00:00','m','m'), +(4,'00:13:25','q','q'), +(0,'03:47:16',NULL,NULL), +(4,'01:41:48','d','d'), +(8,'00:00:00','g','g'), +(NULL,'22:32:04','x','x'), +(NULL,'16:44:14','f','f'), +(0,'17:38:37','p','p'), +(NULL,'08:46:48','j','j'), +(8,'14:11:27','c','c'); +CREATE TABLE t2 ( +col_int_key INT DEFAULT NULL, +col_time_nokey TIME DEFAULT NULL, +col_varchar_key VARCHAR(1) DEFAULT NULL, +col_varchar_nokey VARCHAR(1) DEFAULT NULL, +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset latin1; +INSERT INTO t2 VALUES +(4,'22:34:09','v','v'), +(62,'14:26:02','v','v'), +(7,'14:03:03','c','c'), +(1,'01:46:09',NULL,NULL), +(0,'16:21:18','x','x'), +(7,'18:56:33','i','i'), +(7,NULL,'e','e'), +(1,'09:29:08','p','p'), +(7,'19:11:10','s','s'), +(1,'11:57:26','j','j'), +(5,'00:39:46','z','z'), +(2,'03:28:15','c','c'), +(0,'06:44:18','a','a'), +(1,'14:36:39','q','q'), +(8,'18:42:45','y','y'), +(1,'02:57:29',NULL,NULL), +(1,'16:46:13','r','r'), +(9,'19:39:02','v','v'), +(1,NULL,NULL,NULL), +(5,'20:58:33','r','r'); +CREATE TABLE t3 ( +col_int_key INT DEFAULT NULL, +col_time_nokey TIME DEFAULT NULL, +col_varchar_key VARCHAR(1) DEFAULT NULL, +col_varchar_nokey VARCHAR(1) DEFAULT NULL, +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset latin1; +INSERT INTO t3 VALUES (8,'04:07:22','g','g'); +SET @optimizer_switch_saved= @@optimizer_switch; +SET @@optimizer_switch="derived_merge=off"; +explain SELECT col_time_nokey AS x +FROM (SELECT * FROM t2) AS outr +WHERE col_varchar_nokey IN ( +SELECT innr.col_varchar_key +FROM (SELECT * FROM t3) AS innr2 +LEFT JOIN (SELECT * FROM t1) AS innr +ON innr2.col_varchar_key >= innr.col_varchar_key +WHERE outr.col_varchar_nokey = 'e' + ) +AND outr.col_varchar_key <> 'r' +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +1 PRIMARY NULL ref 4 outr.col_varchar_nokey 2 100.00 End temporary +5 DERIVED t1 NULL ALL NULL NULL NULL NULL 20 100.00 NULL +4 DERIVED t3 NULL system NULL NULL NULL NULL 1 100.00 NULL +2 DERIVED t2 NULL ALL col_varchar_key NULL NULL NULL 20 7.50 Using where +Warnings: +Note 1276 Field or reference 'outr.col_varchar_nokey' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `outr`.`col_time_nokey` AS `x` from (/* select#2 */ select `test`.`t2`.`col_int_key` AS `col_int_key`,`test`.`t2`.`col_time_nokey` AS `col_time_nokey`,`test`.`t2`.`col_varchar_key` AS `col_varchar_key`,`test`.`t2`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t2` where ((`test`.`t2`.`col_varchar_nokey` = 'e') and (`test`.`t2`.`col_varchar_key` <> 'r'))) `outr` semi join ((/* select#4 */ select '8' AS `col_int_key`,'04:07:22' AS `col_time_nokey`,'g' AS `col_varchar_key`,'g' AS `col_varchar_nokey` from dual) `innr2` join (/* select#5 */ select `test`.`t1`.`col_int_key` AS `col_int_key`,`test`.`t1`.`col_time_nokey` AS `col_time_nokey`,`test`.`t1`.`col_varchar_key` AS `col_varchar_key`,`test`.`t1`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t1`) `innr`) where ((`innr`.`col_varchar_key` = `outr`.`col_varchar_nokey`) and (`innr2`.`col_varchar_key` >= `outr`.`col_varchar_nokey`)) +SELECT col_time_nokey AS x +FROM (SELECT * FROM t2) AS outr +WHERE col_varchar_nokey IN ( +SELECT innr.col_varchar_key +FROM (SELECT * FROM t3) AS innr2 +LEFT JOIN (SELECT * FROM t1) AS innr +ON innr2.col_varchar_key >= innr.col_varchar_key +WHERE outr.col_varchar_nokey = 'e' + ) +AND outr.col_varchar_key <> 'r' +; +x +SET @@optimizer_switch= @optimizer_switch_saved; +DROP TABLE t1, t2, t3; +# +# Bug#13354889: Crash on a derived table with more than 64 fields. +# +create table t1 ( +field00 int, field01 int, field02 int, field03 int, +field04 int, field05 int, field06 int, field07 int, +field10 int, field11 int, field12 int, field13 int, +field14 int, field15 int, field16 int, field17 int, +field20 int, field21 int, field22 int, field23 int, +field24 int, field25 int, field26 int, field27 int, +field30 int, field31 int, field32 int, field33 int, +field34 int, field35 int, field36 int, field37 int, +field40 int, field41 int, field42 int, field43 int, +field44 int, field45 int, field46 int, field47 int, +field50 int, field51 int, field52 int, field53 int, +field54 int, field55 int, field56 int, field57 int, +field60 int, field61 int, field62 int, field63 int, +field64 int, field65 int, field66 int, field67 int, +field70 int, field71 int, field72 int, field73 int, +field74 int, field75 int, field76 int, field77 int, +field100 int +); +insert into t1(field100) values (1),(2),(3),(4),(5),(6),(7),(8),(9),(0); +insert into t1 select * from t1; +insert into t1 select * from t1; +insert into t1 select * from t1; +SET @optimizer_switch_saved= @@optimizer_switch; +SET @@optimizer_switch="derived_merge=off"; +select tt.field100 from t1 join (select * from t1) tt where t1.field100=tt.field100 +limit 1; +field100 +1 +Should use auto_key0 and ref access. +explain +select tt.field100 from t1 join (select * from t1) tt where t1.field100=tt.field100 +limit 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 80 100.00 Using where +1 PRIMARY NULL ref 5 test.t1.field100 8 100.00 NULL +2 DERIVED t1 NULL ALL NULL NULL NULL NULL 80 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `tt`.`field100` AS `field100` from `test`.`t1` join (/* select#2 */ select `test`.`t1`.`field00` AS `field00`,`test`.`t1`.`field01` AS `field01`,`test`.`t1`.`field02` AS `field02`,`test`.`t1`.`field03` AS `field03`,`test`.`t1`.`field04` AS `field04`,`test`.`t1`.`field05` AS `field05`,`test`.`t1`.`field06` AS `field06`,`test`.`t1`.`field07` AS `field07`,`test`.`t1`.`field10` AS `field10`,`test`.`t1`.`field11` AS `field11`,`test`.`t1`.`field12` AS `field12`,`test`.`t1`.`field13` AS `field13`,`test`.`t1`.`field14` AS `field14`,`test`.`t1`.`field15` AS `field15`,`test`.`t1`.`field16` AS `field16`,`test`.`t1`.`field17` AS `field17`,`test`.`t1`.`field20` AS `field20`,`test`.`t1`.`field21` AS `field21`,`test`.`t1`.`field22` AS `field22`,`test`.`t1`.`field23` AS `field23`,`test`.`t1`.`field24` AS `field24`,`test`.`t1`.`field25` AS `field25`,`test`.`t1`.`field26` AS `field26`,`test`.`t1`.`field27` AS `field27`,`test`.`t1`.`field30` AS `field30`,`test`.`t1`.`field31` AS `field31`,`test`.`t1`.`field32` AS `field32`,`test`.`t1`.`field33` AS `field33`,`test`.`t1`.`field34` AS `field34`,`test`.`t1`.`field35` AS `field35`,`test`.`t1`.`field36` AS `field36`,`test`.`t1`.`field37` AS `field37`,`test`.`t1`.`field40` AS `field40`,`test`.`t1`.`field41` AS `field41`,`test`.`t1`.`field42` AS `field42`,`test`.`t1`.`field43` AS `field43`,`test`.`t1`.`field44` AS `field44`,`test`.`t1`.`field45` AS `field45`,`test`.`t1`.`field46` AS `field46`,`test`.`t1`.`field47` AS `field47`,`test`.`t1`.`field50` AS `field50`,`test`.`t1`.`field51` AS `field51`,`test`.`t1`.`field52` AS `field52`,`test`.`t1`.`field53` AS `field53`,`test`.`t1`.`field54` AS `field54`,`test`.`t1`.`field55` AS `field55`,`test`.`t1`.`field56` AS `field56`,`test`.`t1`.`field57` AS `field57`,`test`.`t1`.`field60` AS `field60`,`test`.`t1`.`field61` AS `field61`,`test`.`t1`.`field62` AS `field62`,`test`.`t1`.`field63` AS `field63`,`test`.`t1`.`field64` AS `field64`,`test`.`t1`.`field65` AS `field65`,`test`.`t1`.`field66` AS `field66`,`test`.`t1`.`field67` AS `field67`,`test`.`t1`.`field70` AS `field70`,`test`.`t1`.`field71` AS `field71`,`test`.`t1`.`field72` AS `field72`,`test`.`t1`.`field73` AS `field73`,`test`.`t1`.`field74` AS `field74`,`test`.`t1`.`field75` AS `field75`,`test`.`t1`.`field76` AS `field76`,`test`.`t1`.`field77` AS `field77`,`test`.`t1`.`field100` AS `field100` from `test`.`t1`) `tt` where (`tt`.`field100` = `test`.`t1`.`field100`) limit 1 +SET @@optimizer_switch= @optimizer_switch_saved; +drop table t1; +# +# +# Bug#13390138: crash in memcpy from join_cache::write_record_data +# +CREATE TABLE t1 ( +col_varchar_key varchar(1), +col_varchar_nokey varchar(1), +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4 ENGINE=MyISAM; +INSERT INTO t1 VALUES ('r','r'); +CREATE TABLE t2 ( +col_varchar_key varchar(1), +col_varchar_nokey varchar(1), +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4; +INSERT INTO t2 VALUES +(NULL,NULL), +('r','r'); +CREATE TABLE t3 ( +col_int_key int, +col_varchar_key varchar(1), +col_varchar_nokey varchar(1), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key, col_int_key) +) charset utf8mb4; +INSERT INTO t3 VALUES +(9,'f','f'), +(4,'y','y'), +(3,'u','u'), +(2,'m','m'), +(NULL,NULL,NULL), +(2,'o','o'), +(NULL,'r','r'), +(6,'m','m'), +(7,'q','q'), +(6,'c','c'); +SET @optimizer_switch_saved= @@optimizer_switch; +SET @@optimizer_switch="derived_merge=off"; +explain SELECT grandparent.col_varchar_nokey AS g1 +FROM (SELECT * FROM t3) AS grandparent +WHERE grandparent.col_varchar_nokey IN +(SELECT parent.col_varchar_key AS p1 +FROM (SELECT * FROM t2) AS parent +WHERE grandparent.col_varchar_key IN ( +SELECT child1.col_varchar_key AS c1 +FROM (SELECT * FROM t1) AS child1 +LEFT JOIN (SELECT * FROM t2) AS child2 +ON child1.col_varchar_nokey <> child2.col_varchar_key +) +AND grandparent.col_int_key IS UNKNOWN +) +ORDER BY grandparent.col_varchar_nokey; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using temporary; Using filesort; Start temporary +1 PRIMARY NULL ref 7 child1.col_varchar_key 2 100.00 Using where +1 PRIMARY NULL ref 7 grandparent.col_varchar_nokey 2 100.00 NULL +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary; Using join buffer (hash join) +7 DERIVED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +6 DERIVED t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +4 DERIVED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DERIVED t3 NULL ref col_int_key col_int_key 5 const 2 100.00 Using index condition +Warnings: +Note 1276 Field or reference 'grandparent.col_varchar_key' of SELECT #3 was resolved in SELECT #1 +Note 1276 Field or reference 'grandparent.col_int_key' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `grandparent`.`col_varchar_nokey` AS `g1` from (/* select#2 */ select `test`.`t3`.`col_int_key` AS `col_int_key`,`test`.`t3`.`col_varchar_key` AS `col_varchar_key`,`test`.`t3`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t3` where (`test`.`t3`.`col_int_key` is null)) `grandparent` semi join ((/* select#4 */ select `test`.`t2`.`col_varchar_key` AS `col_varchar_key`,`test`.`t2`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t2`) `parent` join (/* select#6 */ select 'r' AS `col_varchar_key`,'r' AS `col_varchar_nokey` from dual) `child1` left join (/* select#7 */ select `test`.`t2`.`col_varchar_key` AS `col_varchar_key`,`test`.`t2`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t2`) `child2` on((`child1`.`col_varchar_nokey` <> `child2`.`col_varchar_key`))) where ((`grandparent`.`col_varchar_key` = `child1`.`col_varchar_key`) and (`parent`.`col_varchar_key` = `grandparent`.`col_varchar_nokey`)) order by `grandparent`.`col_varchar_nokey` +SELECT grandparent.col_varchar_nokey AS g1 +FROM (SELECT * FROM t3) AS grandparent +WHERE grandparent.col_varchar_nokey IN +(SELECT parent.col_varchar_key AS p1 +FROM (SELECT * FROM t2) AS parent +WHERE grandparent.col_varchar_key IN ( +SELECT child1.col_varchar_key AS c1 +FROM (SELECT * FROM t1) AS child1 +LEFT JOIN (SELECT * FROM t2) AS child2 +ON child1.col_varchar_nokey <> child2.col_varchar_key +) +AND grandparent.col_int_key IS UNKNOWN +) +ORDER BY grandparent.col_varchar_nokey; +g1 +r +SET @@optimizer_switch= @optimizer_switch_saved; +DROP TABLE t1, t2, t3; +# +# Bug#13457552: Crash on instantiating a derived table in a query with +# empty result. +# +CREATE TABLE t1 ( pk INT, col_blob BLOB ) ENGINE = MyISAM; +CREATE TABLE t2 ( pk INT, col_blob BLOB ) ENGINE = InnoDB; +SET @optimizer_switch_saved= @@optimizer_switch; +SET @@optimizer_switch="derived_merge=off"; +FLUSH STATUS; +SELECT pk FROM ( SELECT col_blob, pk FROM t2 ) AS A NATURAL JOIN t1; +pk +SHOW STATUS LIKE 'Created_tmp_tables'; +Variable_name Value +Created_tmp_tables 0 +EXPLAIN SELECT pk FROM ( SELECT col_blob, pk FROM t2 ) AS a NATURAL JOIN t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +2 DERIVED t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `a`.`pk` AS `pk` from (/* select#2 */ select `test`.`t2`.`col_blob` AS `col_blob`,`test`.`t2`.`pk` AS `pk` from `test`.`t2`) `a` join `test`.`t1` where (multiple equal(`a`.`col_blob`, NULL) and multiple equal(`a`.`pk`, NULL)) +SET @@optimizer_switch= @optimizer_switch_saved; +DROP TABLE t1,t2; +# +# Bug #13801019 ASSERTION `0' FAILED IN CREATE_MYISAM_TMP_TABLE +# +CREATE TABLE t1 (a INT, b BLOB) ENGINE=InnoDB; +CREATE TABLE t2 (c INT); +CREATE TABLE t3 (d INT); +INSERT INTO t3 VALUES (0); +SET @optimizer_switch_saved= @@optimizer_switch; +SET @@optimizer_switch="derived_merge=off"; +SELECT * FROM (SELECT * FROM t1) AS a1 RIGHT JOIN t3 LEFT JOIN t2 ON d=c ON a=c; +a b d c +NULL NULL 0 NULL +SET @@optimizer_switch= @optimizer_switch_saved; +DROP TABLE t1, t2, t3; +# +# Bug #17814492 - INVALID RESULTS FROM SUBQUERY WITH IN CLAUSE +# +CREATE TABLE t1 ( +a INTEGER NOT NULL, +b VARCHAR(1000) NOT NULL, +c TEXT NOT NULL +)ENGINE=InnoDB; +INSERT INTO t1 VALUES (1, 'xxx', 'abc'); +INSERT INTO t1 VALUES (2, 'yyy', 'abc'); +INSERT INTO t1 SELECT a, b, c FROM t1 WHERE b='yyy'; +INSERT INTO t1 SELECT a, b, c FROM t1 WHERE b='yyy'; +INSERT INTO t1 SELECT a, b, c FROM t1 WHERE b='yyy'; +CREATE TABLE t2 ( +a INTEGER NOT NULL +)ENGINE=InnoDB; +INSERT INTO t2 VALUES (1), (2); +ANALYZE TABLE t1,t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +SET @save_optimizer_switch= @@optimizer_switch; +SET @@SESSION.optimizer_switch="index_condition_pushdown=on"; +EXPLAIN SELECT a1.a, a1.b, a1.c FROM (SELECT a, b, c FROM t1 ) a1 +JOIN t2 ON a1.a=t2.a WHERE a1.b='xxx'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 9 11.11 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`a` = `test`.`t1`.`a`) and (`test`.`t1`.`b` = 'xxx')) +SELECT a1.a, a1.b, a1.c FROM (SELECT a, b, c FROM t1 ) a1 +JOIN t2 ON a1.a=t2.a WHERE a1.b='xxx'; +a b c +1 xxx abc +SET @@SESSION.optimizer_switch= @save_optimizer_switch; +DROP TABLE t2, t1; +# End of test for Bug #17814492 +# +# WL#5275 Process subqueries in FROM clause in the same way as view +# +CREATE TABLE t1(a INTEGER, b INTEGER); +CREATE TABLE t2(a INTEGER, b INTEGER); +INSERT INTO t1 VALUES(1, 10), (2, 20); +INSERT INTO t2 VALUES(1, 100), (2, 200); +SELECT * +FROM t1 JOIN (SELECT * FROM t2) AS dt ON t1.a=dt.a; +a b a b +1 10 1 100 +2 20 2 200 +explain SELECT * +FROM t1 JOIN (SELECT * FROM t2) AS dt ON t1.a=dt.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` join `test`.`t2` where (`test`.`t2`.`a` = `test`.`t1`.`a`) +SELECT * +FROM t1, (SELECT * FROM t2) AS dt WHERE t1.a=dt.a; +a b a b +1 10 1 100 +2 20 2 200 +explain SELECT * +FROM t1, (SELECT * FROM t2) AS dt WHERE t1.a=dt.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` join `test`.`t2` where (`test`.`t2`.`a` = `test`.`t1`.`a`) +SELECT * +FROM (t1 JOIN t2 ON t1.a=t2.a) JOIN (SELECT * FROM t2) AS dt ON t1.a=dt.a; +a b a b a b +1 10 1 100 1 100 +2 20 2 200 2 200 +explain SELECT * +FROM (t1 JOIN t2 ON t1.a=t2.a) JOIN (SELECT * FROM t2) AS dt ON t1.a=dt.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` join `test`.`t2` join `test`.`t2` where ((`test`.`t2`.`a` = `test`.`t1`.`a`) and (`test`.`t2`.`a` = `test`.`t1`.`a`)) +SELECT * +FROM t1 JOIN (SELECT t2.a, t2.b FROM t1 JOIN t2 USING (a)) AS dt ON t1.a=dt.a; +a b a b +1 10 1 100 +2 20 2 200 +explain SELECT * +FROM t1 JOIN (SELECT t2.a, t2.b FROM t1 JOIN t2 USING (a)) AS dt ON t1.a=dt.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` join `test`.`t1` join `test`.`t2` where ((`test`.`t1`.`a` = `test`.`t1`.`a`) and (`test`.`t2`.`a` = `test`.`t1`.`a`)) +SELECT * +FROM (t1 JOIN t2 USING (a)) +JOIN +(SELECT t2.a, t2.b FROM t1 JOIN t2 USING (a)) AS dt +ON t1.a=dt.a; +a b b a b +1 10 100 1 100 +2 20 200 2 200 +explain SELECT * +FROM (t1 JOIN t2 USING (a)) +JOIN +(SELECT t2.a, t2.b FROM t1 JOIN t2 USING (a)) AS dt +ON t1.a=dt.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` join `test`.`t2` join `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`a` = `test`.`t1`.`a`) and (`test`.`t1`.`a` = `test`.`t1`.`a`) and (`test`.`t2`.`a` = `test`.`t1`.`a`)) +SELECT * +FROM (t1 JOIN t2 USING (a)) +JOIN +(SELECT t1.a, t2.b FROM t1 JOIN t2 USING (a)) AS dt1 +ON t1.a=dt1.a AND t2.b=dt1.b +JOIN +(SELECT t2.a, t2.b FROM t1 JOIN t2 USING (a)) AS dt2 +ON dt1.a=dt2.a; +a b b a b a b +1 10 100 1 100 1 100 +2 20 200 2 200 2 200 +explain SELECT * +FROM (t1 JOIN t2 USING (a)) +JOIN +(SELECT t1.a, t2.b FROM t1 JOIN t2 USING (a)) AS dt1 +ON t1.a=dt1.a AND t2.b=dt1.b +JOIN +(SELECT t2.a, t2.b FROM t1 JOIN t2 USING (a)) AS dt2 +ON dt1.a=dt2.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`b` AS `b`,`test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` join `test`.`t2` join `test`.`t1` join `test`.`t2` join `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`b` = `test`.`t2`.`b`) and (`test`.`t2`.`a` = `test`.`t1`.`a`) and (`test`.`t1`.`a` = `test`.`t1`.`a`) and (`test`.`t2`.`a` = `test`.`t1`.`a`) and (`test`.`t1`.`a` = `test`.`t1`.`a`) and (`test`.`t2`.`a` = `test`.`t1`.`a`)) +SELECT * +FROM t1 JOIN (SELECT t2.a, t2.b FROM t1 JOIN t2 USING (a) +WHERE t1.b > 15) AS dt ON t1.a=dt.a; +a b a b +2 20 2 200 +explain SELECT * +FROM t1 JOIN (SELECT t2.a, t2.b FROM t1 JOIN t2 USING (a) +WHERE t1.b > 15) AS dt ON t1.a=dt.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` join `test`.`t1` join `test`.`t2` where ((`test`.`t1`.`a` = `test`.`t1`.`a`) and (`test`.`t2`.`a` = `test`.`t1`.`a`) and (`test`.`t1`.`b` > 15)) +SELECT * +FROM t1 JOIN (SELECT * FROM t2 +WHERE a IN (SELECT a FROM t1)) AS dt ON t1.a=dt.a; +a b a b +1 10 1 100 +2 20 2 200 +explain SELECT * +FROM t1 JOIN (SELECT * FROM t2 +WHERE a IN (SELECT a FROM t1)) AS dt ON t1.a=dt.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t2); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` join `test`.`t2` semi join (`test`.`t1`) where ((`test`.`t2`.`a` = `test`.`t1`.`a`) and (`test`.`t1`.`a` = `test`.`t1`.`a`)) +SELECT * +FROM t1 JOIN (SELECT * FROM t2 UNION SELECT * FROM t2) AS dt ON t1.a=dt.a; +a b a b +1 10 1 100 +2 20 2 200 +explain SELECT * +FROM t1 JOIN (SELECT * FROM t2 UNION SELECT * FROM t2) AS dt ON t1.a=dt.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 PRIMARY NULL ref 5 test.t1.a 2 100.00 NULL +2 DERIVED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +3 UNION t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +NULL UNION RESULT NULL ALL NULL NULL NULL NULL NULL NULL Using temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`dt`.`a` AS `a`,`dt`.`b` AS `b` from `test`.`t1` join (/* select#2 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t2` union /* select#3 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t2`) `dt` where (`dt`.`a` = `test`.`t1`.`a`) +SELECT * +FROM t1 JOIN (SELECT * FROM t2 UNION ALL SELECT * FROM t2) AS dt ON t1.a=dt.a; +a b a b +1 10 1 100 +1 10 1 100 +2 20 2 200 +2 20 2 200 +explain SELECT * +FROM t1 JOIN (SELECT * FROM t2 UNION ALL SELECT * FROM t2) AS dt ON t1.a=dt.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 PRIMARY NULL ref 5 test.t1.a 2 100.00 NULL +2 DERIVED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +3 UNION t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`dt`.`a` AS `a`,`dt`.`b` AS `b` from `test`.`t1` join (/* select#2 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t2` union all /* select#3 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t2`) `dt` where (`dt`.`a` = `test`.`t1`.`a`) +SELECT * +FROM t1 JOIN (SELECT DISTINCT a, b FROM t2) AS dt ON t1.a=dt.a; +a b a b +1 10 1 100 +2 20 2 200 +explain SELECT * +FROM t1 JOIN (SELECT DISTINCT a, b FROM t2) AS dt ON t1.a=dt.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 PRIMARY NULL ref 5 test.t1.a 2 100.00 NULL +2 DERIVED t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`dt`.`a` AS `a`,`dt`.`b` AS `b` from `test`.`t1` join (/* select#2 */ select distinct `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t2`) `dt` where (`dt`.`a` = `test`.`t1`.`a`) +SELECT * +FROM t1 JOIN (SELECT SUM(a) AS a, SUM(b) AS b FROM t2) AS dt ON t1.a=dt.a; +a b a b +explain SELECT * +FROM t1 JOIN (SELECT SUM(a) AS a, SUM(b) AS b FROM t2) AS dt ON t1.a=dt.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL system NULL NULL NULL NULL 1 100.00 NULL +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 DERIVED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,'3' AS `a`,'300' AS `b` from `test`.`t1` where (`test`.`t1`.`a` = '3') +SELECT * +FROM t1 JOIN (SELECT a, SUM(b) AS b FROM t2 GROUP BY a) AS dt ON t1.a=dt.a; +a b a b +1 10 1 100 +2 20 2 200 +explain SELECT * +FROM t1 JOIN (SELECT a, SUM(b) AS b FROM t2 GROUP BY a) AS dt ON t1.a=dt.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 PRIMARY NULL ref 5 test.t1.a 2 100.00 NULL +2 DERIVED t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`dt`.`a` AS `a`,`dt`.`b` AS `b` from `test`.`t1` join (/* select#2 */ select `test`.`t2`.`a` AS `a`,sum(`test`.`t2`.`b`) AS `b` from `test`.`t2` group by `test`.`t2`.`a`) `dt` where (`dt`.`a` = `test`.`t1`.`a`) +SELECT * +FROM t1 JOIN (SELECT 1 AS a FROM t2 HAVING COUNT(*) > 1) AS dt ON t1.a=dt.a; +a b a +1 10 1 +explain SELECT * +FROM t1 JOIN (SELECT 1 AS a FROM t2 HAVING COUNT(*) > 1) AS dt ON t1.a=dt.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +2 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL NULL Select tables optimized away +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,NULL AS `a` from `test`.`t1` join (/* select#2 */ select 1 AS `a` from `test`.`t2` having (count(0) > 1)) `dt` where multiple equal(`test`.`t1`.`a`, NULL) +SELECT * +FROM t1 JOIN (SELECT * FROM t2 LIMIT 1) AS dt ON t1.a=dt.a; +a b a b +1 10 1 100 +explain SELECT * +FROM t1 JOIN (SELECT * FROM t2 LIMIT 1) AS dt ON t1.a=dt.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL system NULL NULL NULL NULL 1 100.00 NULL +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 DERIVED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,'1' AS `a`,'100' AS `b` from `test`.`t1` where (`test`.`t1`.`a` = '1') +SELECT * +FROM t1 JOIN (SELECT * FROM t2 LIMIT 2 OFFSET 1) AS dt ON t1.a=dt.a; +a b a b +2 20 2 200 +explain SELECT * +FROM t1 JOIN (SELECT * FROM t2 LIMIT 2 OFFSET 1) AS dt ON t1.a=dt.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 PRIMARY NULL ref 5 test.t1.a 2 100.00 NULL +2 DERIVED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`dt`.`a` AS `a`,`dt`.`b` AS `b` from `test`.`t1` join (/* select#2 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t2` limit 1,2) `dt` where (`dt`.`a` = `test`.`t1`.`a`) +SELECT * +FROM t1 JOIN (SELECT 1 AS a) AS dt ON t1.a=dt.a; +a b a +1 10 1 +explain SELECT * +FROM t1 JOIN (SELECT 1 AS a) AS dt ON t1.a=dt.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL system NULL NULL NULL NULL 1 100.00 NULL +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,'1' AS `a` from `test`.`t1` where (`test`.`t1`.`a` = '1') +SELECT * +FROM t1 JOIN (SELECT a, b, @c:= a+b FROM t2) AS dt ON t1.a=dt.a; +a b a b @c:= a+b +1 10 1 100 101 +2 20 2 200 202 +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +explain SELECT * +FROM t1 JOIN (SELECT a, b, @c:= a+b FROM t2) AS dt ON t1.a=dt.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 PRIMARY NULL ref 5 test.t1.a 2 100.00 NULL +2 DERIVED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`dt`.`a` AS `a`,`dt`.`b` AS `b`,`dt`.`@c:= a+b` AS `@c:= a+b` from `test`.`t1` join (/* select#2 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,(@c:=(`test`.`t2`.`a` + `test`.`t2`.`b`)) AS `@c:= a+b` from `test`.`t2`) `dt` where (`dt`.`a` = `test`.`t1`.`a`) +SELECT * +FROM (SELECT * FROM t2 ORDER BY t2.a) AS dt; +a b +1 100 +2 200 +explain SELECT * +FROM (SELECT * FROM t2 ORDER BY t2.a) AS dt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t2` order by `test`.`t2`.`a` +SELECT * +FROM (SELECT * FROM t2 ORDER BY t2.a DESC) AS dt; +a b +2 200 +1 100 +explain SELECT * +FROM (SELECT * FROM t2 ORDER BY t2.a DESC) AS dt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t2` order by `test`.`t2`.`a` desc +SELECT * +FROM (SELECT * FROM t2 ORDER BY t2.a) AS dt +WHERE dt.a > 0; +a b +1 100 +2 200 +explain SELECT * +FROM (SELECT * FROM t2 ORDER BY t2.a) AS dt +WHERE dt.a > 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t2` where (`test`.`t2`.`a` > 0) order by `test`.`t2`.`a` +SELECT * +FROM (SELECT * FROM t2 ORDER BY t2.a DESC) AS dt +WHERE dt.a > 0; +a b +2 200 +1 100 +explain SELECT * +FROM (SELECT * FROM t2 ORDER BY t2.a DESC) AS dt +WHERE dt.a > 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t2` where (`test`.`t2`.`a` > 0) order by `test`.`t2`.`a` desc +SELECT * +FROM t1 JOIN (SELECT * FROM t2 ORDER BY t2.a) AS dt ON t1.a=dt.a; +a b a b +1 10 1 100 +2 20 2 200 +explain SELECT * +FROM t1 JOIN (SELECT * FROM t2 ORDER BY t2.a) AS dt ON t1.a=dt.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` join `test`.`t2` where (`test`.`t2`.`a` = `test`.`t1`.`a`) +SELECT * +FROM t1 JOIN (SELECT * FROM t2 ORDER BY t2.a DESC) AS dt ON t1.a=dt.a; +a b a b +1 10 1 100 +2 20 2 200 +explain SELECT * +FROM t1 JOIN (SELECT * FROM t2 ORDER BY t2.a DESC) AS dt ON t1.a=dt.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` join `test`.`t2` where (`test`.`t2`.`a` = `test`.`t1`.`a`) +SELECT dt.a, COUNT(*) +FROM (SELECT * FROM t2 ORDER BY t2.a) AS dt +GROUP BY dt.a; +a COUNT(*) +1 1 +2 1 +explain SELECT dt.a, COUNT(*) +FROM (SELECT * FROM t2 ORDER BY t2.a) AS dt +GROUP BY dt.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,count(0) AS `COUNT(*)` from `test`.`t2` group by `test`.`t2`.`a` +SELECT dt.a, COUNT(*) +FROM (SELECT * FROM t2 ORDER BY t2.a DESC) AS dt +GROUP BY dt.a; +a COUNT(*) +1 1 +2 1 +explain SELECT dt.a, COUNT(*) +FROM (SELECT * FROM t2 ORDER BY t2.a DESC) AS dt +GROUP BY dt.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,count(0) AS `COUNT(*)` from `test`.`t2` group by `test`.`t2`.`a` +SELECT COUNT(*) +FROM (SELECT * FROM t2 ORDER BY t2.a) AS dt; +COUNT(*) +2 +explain SELECT COUNT(*) +FROM (SELECT * FROM t2 ORDER BY t2.a) AS dt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Select tables optimized away +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t2` +SELECT COUNT(*) +FROM (SELECT * FROM t2 ORDER BY t2.a DESC) AS dt; +COUNT(*) +2 +explain SELECT COUNT(*) +FROM (SELECT * FROM t2 ORDER BY t2.a DESC) AS dt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Select tables optimized away +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t2` +SELECT DISTINCT * +FROM (SELECT * FROM t2 ORDER BY t2.a) AS dt; +a b +1 100 +2 200 +explain SELECT DISTINCT * +FROM (SELECT * FROM t2 ORDER BY t2.a) AS dt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using temporary +Warnings: +Note 1003 /* select#1 */ select distinct `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t2` +SELECT DISTINCT * +FROM (SELECT * FROM t2 ORDER BY t2.a DESC) AS dt; +a b +1 100 +2 200 +explain SELECT DISTINCT * +FROM (SELECT * FROM t2 ORDER BY t2.a DESC) AS dt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using temporary +Warnings: +Note 1003 /* select#1 */ select distinct `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t2` +SELECT * +FROM t1 JOIN (SELECT * FROM t2 ORDER BY t2.a) AS dt ON t1.a=dt.a +ORDER BY t1.b; +a b a b +1 10 1 100 +2 20 2 200 +explain SELECT * +FROM t1 JOIN (SELECT * FROM t2 ORDER BY t2.a) AS dt ON t1.a=dt.a +ORDER BY t1.b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using temporary; Using filesort +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` join `test`.`t2` where (`test`.`t2`.`a` = `test`.`t1`.`a`) order by `test`.`t1`.`b` +SELECT * +FROM t1 JOIN (SELECT * FROM t2 ORDER BY t2.a DESC) AS dt ON t1.a=dt.a +ORDER BY t1.b; +a b a b +1 10 1 100 +2 20 2 200 +explain SELECT * +FROM t1 JOIN (SELECT * FROM t2 ORDER BY t2.a DESC) AS dt ON t1.a=dt.a +ORDER BY t1.b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using temporary; Using filesort +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` join `test`.`t2` where (`test`.`t2`.`a` = `test`.`t1`.`a`) order by `test`.`t1`.`b` +SELECT * +FROM t1 JOIN (SELECT a, (SELECT COUNT(*) FROM t1) AS b FROM t2) AS dt +ON t1.a=dt.a; +a b a b +1 10 1 2 +2 20 2 2 +explain SELECT * +FROM t1 JOIN (SELECT a, (SELECT COUNT(*) FROM t1) AS b FROM t2) AS dt +ON t1.a=dt.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +3 SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL NULL Select tables optimized away +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,(/* select#3 */ select count(0) from `test`.`t1`) AS `b` from `test`.`t1` join `test`.`t2` where (`test`.`t2`.`a` = `test`.`t1`.`a`) +SELECT * +FROM t1 JOIN (SELECT a, (SELECT b) AS b FROM t2) AS dt ON t1.a=dt.a; +a b a b +1 10 1 100 +2 20 2 200 +explain SELECT * +FROM t1 JOIN (SELECT a, (SELECT b) AS b FROM t2) AS dt ON t1.a=dt.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t2.b' of SELECT #3 was resolved in SELECT #2 +Note 1249 Select 3 was reduced during optimization +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` join `test`.`t2` where (`test`.`t2`.`a` = `test`.`t1`.`a`) +SET @optimizer_switch_saved= @@optimizer_switch; +SET @@optimizer_switch="derived_merge=off"; +SELECT * +FROM (t1 JOIN t2 USING (a)) +JOIN (SELECT t2.a, t2.b FROM t1 JOIN t2 USING (a)) AS dt +ON t1.a=dt.a; +a b b a b +1 10 100 1 100 +2 20 200 2 200 +explain SELECT * +FROM (t1 JOIN t2 USING (a)) +JOIN (SELECT t2.a, t2.b FROM t1 JOIN t2 USING (a)) AS dt +ON t1.a=dt.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 PRIMARY NULL ref 5 test.t1.a 2 100.00 NULL +2 DERIVED t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DERIVED t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`b` AS `b`,`dt`.`a` AS `a`,`dt`.`b` AS `b` from `test`.`t1` join `test`.`t2` join (/* select#2 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` join `test`.`t2` where (`test`.`t2`.`a` = `test`.`t1`.`a`)) `dt` where ((`test`.`t2`.`a` = `test`.`t1`.`a`) and (`dt`.`a` = `test`.`t1`.`a`)) +SET @@optimizer_switch="derived_merge=on"; +SELECT * +FROM (t1 JOIN t2 USING (a)) +JOIN (SELECT t2.a, t2.b FROM t1 JOIN t2 USING (a)) AS dt +ON t1.a=dt.a; +a b b a b +1 10 100 1 100 +2 20 200 2 200 +explain SELECT * +FROM (t1 JOIN t2 USING (a)) +JOIN (SELECT t2.a, t2.b FROM t1 JOIN t2 USING (a)) AS dt +ON t1.a=dt.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` join `test`.`t2` join `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`a` = `test`.`t1`.`a`) and (`test`.`t1`.`a` = `test`.`t1`.`a`) and (`test`.`t2`.`a` = `test`.`t1`.`a`)) +SET @@optimizer_switch= @optimizer_switch_saved; +INSERT INTO (SELECT * FROM t1) AS dt VALUES(9, 99); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '(SELECT * FROM t1) AS dt VALUES(9, 99)' at line 1 +INSERT INTO (SELECT * FROM t1) AS dt SELECT 9, 99; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '(SELECT * FROM t1) AS dt SELECT 9, 99' at line 1 +UPDATE (SELECT * FROM t1) AS dt SET b=b+1; +ERROR HY000: The target table dt of the UPDATE is not updatable +UPDATE t1 JOIN (SELECT * FROM t2) AS dt ON t1.a=dt.a SET dt.b=dt.b+1; +ERROR HY000: The target table t2 of the UPDATE is not updatable +DELETE FROM (SELECT * FROM t1) AS dt WHERE a=1; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '(SELECT * FROM t1) AS dt WHERE a=1' at line 1 +DELETE dt FROM t1 JOIN (SELECT * FROM t2) AS dt ON t1.a=dt.a WHERE t1.a=1; +ERROR HY000: The target table dt of the DELETE is not updatable +UPDATE t1 JOIN (SELECT * FROM t2) AS dt ON t1.a=dt.a SET t1.b=t1.b+1; +DELETE t1 FROM t1 JOIN (SELECT * FROM t2) AS dt ON t1.a=dt.a WHERE t1.a=1; +SELECT * FROM t1; +a b +2 21 +SELECT * FROM t2; +a b +1 100 +2 200 +DROP TABLE t1, t2; +# Bug#19791944: Assert fail in subselect_hash_sj_engine::exec +CREATE TABLE t1 ( +pk int NOT NULL, +col_int_key int NOT NULL, +col_varchar_key varchar(1) NOT NULL, +PRIMARY KEY (pk), +KEY col_varchar_key (col_varchar_key, col_int_key) +) charset utf8mb4; +INSERT INTO t1 VALUES +(1,4,'j'), (2,6,'v'), (3,3,'c'), (4,5,'m'), (5,3,'d'), (6,246,'d'), (7,2,'y'), (8,9,'t'), +(9,3,'d'), (10,8,'s'), (11,1,'r'), (12,8,'m'), (13,8,'b'), (14,5,'x'), (15,7,'g'), (16,5,'p'), +(17,1,'q'), (18,6,'w'), (19,2,'d'), (20,9,'e'); +CREATE TABLE t2 ( +pk int NOT NULL, +col_int_nokey int NOT NULL, +col_int_key int NOT NULL, +col_date_key date NOT NULL, +col_varchar_nokey varchar(1) NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_date_key (col_date_key) +) charset utf8mb4; +INSERT INTO t2 VALUES (1,1,7,'1900-01-01','k'); +CREATE TABLE t3 ( +pk int NOT NULL , +col_date_nokey date NOT NULL, +col_varchar_nokey varchar(1) NOT NULL, +PRIMARY KEY (pk) +) charset utf8mb4; +INSERT INTO t3 VALUES (10,'1900-01-01','b'); +EXPLAIN SELECT outr.col_date_key AS x +FROM (SELECT * FROM t1) AS outr2 LEFT JOIN (SELECT * FROM t2) AS outr +ON outr2.col_varchar_key = outr.col_varchar_nokey +WHERE (outr.col_int_key, outr.col_int_key) IN +(SELECT innr.pk AS x, innr.pk AS y +FROM (SELECT * FROM t3) AS innr +WHERE innr.col_date_nokey IS NOT NULL XOR +innr.col_varchar_nokey > 'p' + ORDER BY innr.col_date_nokey) XOR +(outr.col_int_nokey < 2 OR +NOT outr.col_int_key IS NULL) +ORDER BY outr.col_int_key, +outr.pk; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL index NULL col_varchar_key 10 NULL 20 100.00 Using index; Using temporary; Using filesort +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +4 DEPENDENT SUBQUERY t3 NULL system PRIMARY NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`col_date_key` AS `x` from `test`.`t1` left join (`test`.`t2`) on((`test`.`t2`.`col_varchar_nokey` = `test`.`t1`.`col_varchar_key`)) where (((`test`.`t2`.`col_int_key`,`test`.`t2`.`col_int_key`),(/* select#4 */ select '10' AS `x`,'10' AS `y` from dual where ((true xor ('b' > 'p')) and (outer_field_is_not_null, (((`test`.`t2`.`col_int_key`) = '10') or ('10' is null)), true) and (outer_field_is_not_null, (((`test`.`t2`.`col_int_key`) = '10') or ('10' is null)), true)) having ((outer_field_is_not_null, ('10'), true) and (outer_field_is_not_null, ('10'), true)))) xor ((`test`.`t2`.`col_int_nokey` < 2) or (`test`.`t2`.`col_int_key` is not null))) order by `test`.`t2`.`col_int_key`,`test`.`t2`.`pk` +SELECT outr.col_date_key AS x +FROM (SELECT * FROM t1) AS outr2 LEFT JOIN (SELECT * FROM t2) AS outr +ON outr2.col_varchar_key = outr.col_varchar_nokey +WHERE (outr.col_int_key, outr.col_int_key) IN +(SELECT innr.pk AS x, innr.pk AS y +FROM (SELECT * FROM t3) AS innr +WHERE innr.col_date_nokey IS NOT NULL XOR +innr.col_varchar_nokey > 'p' + ORDER BY innr.col_date_nokey) XOR +(outr.col_int_nokey < 2 OR +NOT outr.col_int_key IS NULL) +ORDER BY outr.col_int_key, +outr.pk; +x +DROP TABLE t1, t2, t3; +# Bug#20087645: Assert fail in subselect_hash_sj_engine::exec +CREATE TABLE t1 ( +pk int NOT NULL, +col_int_nokey int NOT NULL, +col_varchar_key varchar(1) NOT NULL, +PRIMARY KEY (pk), +KEY col_varchar_key(col_varchar_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t1 VALUES +(10,1,'v'), (11,7,'s'), (12,4,'l'), (13,7,'y'), (14,0,'c'), (15,2,'i'); +CREATE TABLE t2 ( +pk int NOT NULL, +col_varchar_key varchar(1) NOT NULL, +col_varchar_nokey varchar(1) NOT NULL, +PRIMARY KEY (pk), +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t2 VALUES (1,'k','k'); +CREATE TABLE t3 ( +pk int NOT NULL, +col_varchar_nokey varchar(1) NOT NULL, +PRIMARY KEY (pk) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t3 VALUES +(1,'j'), (2,'v'), (3,'c'), (4,'m'), (5,'d'); +ANALYZE TABLE t1, t2, t3; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +EXPLAIN SELECT table1.pk +FROM (SELECT * FROM t1) AS table1 +LEFT JOIN +(SELECT * FROM t1) AS table2 +RIGHT OUTER JOIN +(SELECT * FROM t2) AS table3 +ON table3.col_varchar_nokey = table2.col_varchar_key +ON table3.pk = table2.col_int_nokey +WHERE table3.col_varchar_key <> ALL +(SELECT sq1_t1.col_varchar_nokey AS sq1_field1 +FROM (SELECT * FROM t3) AS sq1_t1 +LEFT OUTER JOIN +(SELECT * FROM t1) AS sq1_t2 +ON sq1_t2.col_varchar_key = sq1_t1.col_varchar_nokey +) OR +table1.pk = 96; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL index PRIMARY col_varchar_key 6 NULL 6 100.00 Using index +1 PRIMARY t2 NULL ALL PRIMARY NULL NULL NULL 1 100.00 Using where +1 PRIMARY t1 NULL ref col_varchar_key col_varchar_key 6 test.t2.col_varchar_nokey 1 100.00 Using where +5 SUBQUERY t3 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +5 SUBQUERY t1 NULL ref col_varchar_key col_varchar_key 6 test.t3.col_varchar_nokey 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` left join (`test`.`t2` join `test`.`t1`) on(((`test`.`t1`.`col_varchar_key` = `test`.`t2`.`col_varchar_nokey`) and (`test`.`t1`.`col_int_nokey` = `test`.`t2`.`pk`))) where ((`test`.`t2`.`col_varchar_key`,`test`.`t2`.`col_varchar_key` in ( (/* select#5 */ select `test`.`t3`.`col_varchar_nokey` AS `sq1_field1` from `test`.`t3` left join (`test`.`t1`) on((`test`.`t1`.`col_varchar_key` = `test`.`t3`.`col_varchar_nokey`)) where true ), (`test`.`t2`.`col_varchar_key` in on where ((`test`.`t2`.`col_varchar_key` = ``.`sq1_field1`)))) is false) or (`test`.`t1`.`pk` = 96)) +SELECT table1.pk +FROM (SELECT * FROM t1) AS table1 +LEFT JOIN +(SELECT * FROM t1) AS table2 +RIGHT OUTER JOIN +(SELECT * FROM t2) AS table3 +ON table3.col_varchar_nokey = table2.col_varchar_key +ON table3.pk = table2.col_int_nokey +WHERE table3.col_varchar_key <> ALL +(SELECT sq1_t1.col_varchar_nokey AS sq1_field1 +FROM (SELECT * FROM t3) AS sq1_t1 +LEFT OUTER JOIN +(SELECT * FROM t1) AS sq1_t2 +ON sq1_t2.col_varchar_key = sq1_t1.col_varchar_nokey +) OR +table1.pk = 96; +pk +DROP TABLE t1, t2, t3; +# Bug#19812352: Assert fail in subselect_hash_sj_engine::setup +CREATE TABLE t1 ( +col_time_nokey time NOT NULL +); +INSERT INTO t1 VALUES ('00:00:00'); +CREATE TABLE t2 ( +pk int NOT NULL, +col_int_nokey int NOT NULL, +col_int_key int NOT NULL, +col_date_nokey date NOT NULL, +col_varchar_key varchar(1) NOT NULL, +col_varchar_nokey varchar(1) NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key(col_int_key), +KEY col_varchar_key(col_varchar_key, col_int_key) +) charset utf8mb4; +INSERT INTO t2 VALUES +(1,4,0,'0001-01-01','j','j'), (2,6,8,'2004-09-18','v','v'), +(3,3,1,'2009-12-01','c','c'), (4,5,8,'2004-12-17','m','m'), +(5,3,9,'2000-03-14','d','d'), (6,246,24,'2000-10-08','d','d'), +(7,2,6,'2006-05-25','y','y'), (8,9,1,'2008-01-23','t','t'), +(9,3,6,'2007-06-18','d','d'), (10,8,2,'2002-10-13','s','s'), +(11,1,4,'1900-01-01','r','r'), (12,8,8,'0001-01-01','m','m'), +(13,8,4,'2006-03-09','b','b'), (14,5,4,'2001-06-05','x','x'), +(15,7,7,'2006-05-28','g','g'), (16,5,4,'2001-04-19','p','p'), +(17,1,1,'1900-01-01','q','q'), (18,6,9,'2004-08-20','w','w'), +(19,2,4,'2004-10-10','d','d'), (20,9,8,'2000-04-02','e','e'); +CREATE TABLE t3 ( +pk int NOT NULL, +col_int_key int NOT NULL, +col_varchar_key varchar(1) NOT NULL, +PRIMARY KEY (pk), +KEY col_varchar_key (col_varchar_key, col_int_key) +) charset utf8mb4; +INSERT INTO t3 VALUES +(10,1,'v'), (11,7,'s'), (12,4,'l'), (13,7,'y'), (14,0,'c'), +(15,2,'i'), (16,9,'h'), (17,4,'q'), (18,0,'a'), (19,9,'v'), +(20,1,'u'), (21,3,'s'), (22,8,'y'), (23,8,'z'), (24,18,'h'), +(25,84,'p'), (26,6,'e'), (27,3,'i'), (28,6,'y'), (29,6,'w'); +CREATE TABLE t4 ( +pk int NOT NULL, +col_int_nokey int NOT NULL, +col_int_key int NOT NULL, +col_varchar_nokey varchar(1) NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +) charset utf8mb4; +INSERT INTO t4 VALUES (10,8,7,'b'); +EXPLAIN SELECT outr.pk AS x +FROM (SELECT * FROM t1) AS outr2 +LEFT JOIN (SELECT * FROM t2) AS outr +ON outr2.col_time_nokey >= outr.col_date_nokey +WHERE (outr.col_int_nokey, outr.col_int_key) IN +(SELECT innr.col_int_key AS x, +innr.col_int_nokey AS y +FROM (SELECT * FROM t3) AS innr2 +LEFT JOIN (SELECT * FROM t4) AS innr +ON innr2.col_varchar_key <> innr.col_varchar_nokey +WHERE innr.col_int_key <> innr.pk OR innr.pk = 9 +) AND +outr.pk < 7 XOR outr.col_varchar_nokey <> 'i' +ORDER BY outr.col_varchar_key, outr.pk; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL system NULL NULL NULL NULL 1 100.00 Using filesort +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 20 21.11 Using where +4 DEPENDENT SUBQUERY t4 NULL system PRIMARY,col_int_key NULL NULL NULL 1 100.00 NULL +4 DEPENDENT SUBQUERY t3 NULL index NULL col_varchar_key 10 NULL 20 90.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`pk` AS `x` from `test`.`t2` where (((((`test`.`t2`.`col_int_nokey`,`test`.`t2`.`col_int_key`),(/* select#4 */ select '7' AS `x`,'8' AS `y` from `test`.`t3` where ((('7' <> '10') or false) and (outer_field_is_not_null, (((`test`.`t2`.`col_int_nokey`) = '7') or ('7' is null)), true) and (outer_field_is_not_null, (((`test`.`t2`.`col_int_key`) = '8') or ('8' is null)), true) and (`test`.`t3`.`col_varchar_key` <> 'b')) having ((outer_field_is_not_null, ('7'), true) and (outer_field_is_not_null, ('8'), true)))) and (`test`.`t2`.`pk` < 7)) xor (`test`.`t2`.`col_varchar_nokey` <> 'i')) and ('00:00:00' >= `test`.`t2`.`col_date_nokey`)) order by `test`.`t2`.`col_varchar_key`,`test`.`t2`.`pk` +SELECT outr.pk AS x +FROM (SELECT * FROM t1) AS outr2 +LEFT JOIN (SELECT * FROM t2) AS outr +ON outr2.col_time_nokey >= outr.col_date_nokey +WHERE (outr.col_int_nokey, outr.col_int_key) IN +(SELECT innr.col_int_key AS x, +innr.col_int_nokey AS y +FROM (SELECT * FROM t3) AS innr2 +LEFT JOIN (SELECT * FROM t4) AS innr +ON innr2.col_varchar_key <> innr.col_varchar_nokey +WHERE innr.col_int_key <> innr.pk OR innr.pk = 9 +) AND +outr.pk < 7 XOR outr.col_varchar_nokey <> 'i' +ORDER BY outr.col_varchar_key, outr.pk; +x +13 +3 +5 +6 +9 +19 +20 +15 +1 +4 +12 +16 +17 +11 +10 +8 +2 +18 +14 +7 +DROP TABLE t1, t2, t3, t4; +# Bug#19811762: Assert fail in JOIN::propagate_dependencies +CREATE TABLE t1 ( +pk int NOT NULL +); +CREATE TABLE t2 ( +pk int NOT NULL, +col_int_key int DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key, col_int_key) +); +CREATE TABLE t3 ( +pk int NOT NULL AUTO_INCREMENT, +col_int_nokey int DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +PRIMARY KEY (pk) +); +EXPLAIN SELECT table1.pk +FROM t1 AS table1 +RIGHT JOIN +t2 AS table2 +LEFT OUTER JOIN +(SELECT sq2_t1.* +FROM t2 AS sq2_t1 INNER JOIN t3 AS sq2_t2 +ON sq2_t2.col_int_nokey = sq2_t1.col_int_key +WHERE sq2_t2.col_varchar_nokey <= sq2_t1.col_varchar_key OR +sq2_t2.col_int_nokey <> 2 +) AS table3 +ON table3.col_int_key = table2.col_int_key +ON table3.pk = table2.col_int_key +WHERE table3.pk >= 6 OR +table1.pk > 68 AND +table1.pk < ( 68 + 76 ); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `pk` from `test`.`t2` `table2` left join (`test`.`t2` `sq2_t1` join `test`.`t3` `sq2_t2`) on((((`test`.`sq2_t2`.`col_varchar_nokey` <= `test`.`sq2_t1`.`col_varchar_key`) or (`test`.`sq2_t2`.`col_int_nokey` <> 2)) and multiple equal(`test`.`sq2_t1`.`col_int_key`, NULL, `test`.`sq2_t2`.`col_int_nokey`))) where ((`test`.`sq2_t1`.`pk` >= 6) or ((NULL > 68) and (NULL < (68 + 76)))) +SELECT table1.pk +FROM t1 AS table1 +RIGHT JOIN +t2 AS table2 +LEFT OUTER JOIN +(SELECT sq2_t1.* +FROM t2 AS sq2_t1 INNER JOIN t3 AS sq2_t2 +ON sq2_t2.col_int_nokey = sq2_t1.col_int_key +WHERE sq2_t2.col_varchar_nokey <= sq2_t1.col_varchar_key OR +sq2_t2.col_int_nokey <> 2 +) AS table3 +ON table3.col_int_key = table2.col_int_key +ON table3.pk = table2.col_int_key +WHERE table3.pk >= 6 OR +table1.pk > 68 AND +table1.pk < ( 68 + 76 ); +pk +DROP TABLE t1, t2, t3; +# +# Bug#19793998 ASSERTION FAILED: ROWS >= 0.0 IN +# HANDLER::INDEX_SCAN_COST() +# +SET @optimizer_switch_saved= @@optimizer_switch; +SET @@optimizer_switch="derived_merge=off"; +CREATE TABLE t1 ( +pk INTEGER PRIMARY KEY +); +INSERT INTO t1 VALUES (0),(1),(2); +CREATE TABLE t2 ( +pk INTEGER PRIMARY KEY +); +INSERT INTO t2 VALUES (0),(1),(2); +explain SELECT SHA(pk) IN (SELECT * FROM (SELECT '' FROM t2) a) FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL index NULL PRIMARY 4 NULL 3 100.00 Using index +2 SUBQUERY NULL ALL NULL NULL NULL NULL 3 100.00 NULL +3 DERIVED t2 NULL index NULL PRIMARY 4 NULL 3 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select (sha(`test`.`t1`.`pk`),sha(`test`.`t1`.`pk`) in ( (/* select#2 */ select `` from (/* select#3 */ select '' AS `` from `test`.`t2`) `a` where true ), (sha(`test`.`t1`.`pk`) in on where ((sha(`test`.`t1`.`pk`) = ``))))) AS `SHA(pk) IN (SELECT * FROM (SELECT '' FROM t2) a)` from `test`.`t1` +SELECT SHA(pk) IN (SELECT * FROM (SELECT '' FROM t2) a) FROM t1; +SHA(pk) IN (SELECT * FROM (SELECT '' FROM t2) a) +0 +0 +0 +DROP TABLE t1, t2; +SET @@optimizer_switch= @optimizer_switch_saved; +# Bug#20073930 Assert fail in store_top_level_join_columns +CREATE TABLE t1 ( +pk int NOT NULL, +col_varchar_key varchar(1) NOT NULL, +PRIMARY KEY (pk) +) engine=innodb; +CREATE TABLE t2 ( +pk int NOT NULL, +col_int_key int NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +) engine=innodb; +CREATE TABLE t3 ( +pk int NOT NULL, +PRIMARY KEY (pk) +) engine=innodb; +CREATE TABLE t4 ( +pk int NOT NULL , +col_varchar_key varchar(1) NOT NULL, +PRIMARY KEY (pk) +) engine=innodb; +explain SELECT table2.pk AS field2 +FROM (SELECT sq1_t2.pk +FROM t1 AS sq1_t1 +JOIN +(t1 AS sq1_t2 RIGHT JOIN t2 AS sq1_t3 +ON sq1_t3.pk = sq1_t2.pk +) +ON sq1_t3.col_int_key = sq1_t2.pk AND +sq1_t1.col_varchar_key IN +(SELECT child_sq1_t2.col_varchar_key AS child_sq1_field1 +FROM t1 AS child_sq1_t2 +) +) AS table1 +LEFT JOIN +t1 AS table2 +JOIN +(SELECT sq2_t1.* FROM t1 AS sq2_t1) AS table3 +ON table3.col_varchar_key = table2.col_varchar_key +ON table3.col_varchar_key = table2.col_varchar_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE sq1_t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE sq1_t3 NULL index PRIMARY,col_int_key col_int_key 4 NULL 1 100.00 Using where; Using index; Using join buffer (hash join) +2 SIMPLE sq1_t2 NULL eq_ref PRIMARY PRIMARY 4 test.sq1_t3.col_int_key 1 100.00 Using index +2 SIMPLE child_sq1_t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(sq1_t2); Using join buffer (hash join) +2 SIMPLE table2 NULL ALL NULL NULL NULL NULL 1 100.00 Using join buffer (hash join) +2 SIMPLE sq2_t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`table2`.`pk` AS `field2` from `test`.`t1` `sq1_t1` join `test`.`t2` `sq1_t3` join `test`.`t1` `sq1_t2` semi join (`test`.`t1` `child_sq1_t2`) left join (`test`.`t1` `table2` join `test`.`t1` `sq2_t1`) on(((`test`.`sq2_t1`.`col_varchar_key` = `test`.`table2`.`col_varchar_key`))) where ((`test`.`child_sq1_t2`.`col_varchar_key` = `test`.`sq1_t1`.`col_varchar_key`) and (`test`.`sq1_t3`.`pk` = `test`.`sq1_t3`.`col_int_key`) and (`test`.`sq1_t2`.`pk` = `test`.`sq1_t3`.`col_int_key`)) +SELECT table2.pk AS field2 +FROM (SELECT sq1_t2.pk +FROM t1 AS sq1_t1 +JOIN +(t1 AS sq1_t2 RIGHT JOIN t2 AS sq1_t3 +ON sq1_t3.pk = sq1_t2.pk +) +ON sq1_t3.col_int_key = sq1_t2.pk AND +sq1_t1.col_varchar_key IN +(SELECT child_sq1_t2.col_varchar_key AS child_sq1_field1 +FROM t1 AS child_sq1_t2 +) +) AS table1 +LEFT JOIN +t1 AS table2 +JOIN +(SELECT sq2_t1.* FROM t1 AS sq2_t1) AS table3 +ON table3.col_varchar_key = table2.col_varchar_key +ON table3.col_varchar_key = table2.col_varchar_key; +field2 +DROP TABLE t1, t2, t3, t4; +# Bug#20118755 Assert fail in JOIN::propagate_dependencies +CREATE TABLE t1 ( +pk int NOT NULL , +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +PRIMARY KEY (pk) +); +CREATE TABLE t2 ( +pk int NOT NULL, +col_int_nokey int DEFAULT NULL, +col_int_key int DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +PRIMARY KEY (pk) +); +explain SELECT table1.pk AS field1, +table2.pk field2 +FROM (SELECT sq1_t1.* +FROM t1 AS sq1_t1 +) AS table1 +RIGHT JOIN +(SELECT sq2_t1.* +FROM t2 AS sq2_t1 +WHERE sq2_t1.col_int_key NOT IN +(SELECT child_sq1_t1.col_int_key AS child_sq2_field1 +FROM t2 AS child_sq1_t1 +) +) AS table2 +RIGHT JOIN t2 AS table3 +ON table3.col_varchar_nokey = table2.col_varchar_key +ON table3.col_varchar_nokey = table2.col_varchar_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +3 SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL NULL Not optimized, outer query is empty +Warnings: +Note 1003 /* select#1 */ select `test`.`sq1_t1`.`pk` AS `field1`,`test`.`sq2_t1`.`pk` AS `field2` from `test`.`t2` `table3` left join (`test`.`t2` `sq2_t1`) on(((`test`.`sq2_t1`.`col_int_key`,(/* select#3 */ select `test`.`child_sq1_t1`.`col_int_key` AS `child_sq2_field1` from `test`.`t2` `child_sq1_t1` where (outer_field_is_not_null, (((`test`.`sq2_t1`.`col_int_key`) = `test`.`child_sq1_t1`.`col_int_key`) or (`test`.`child_sq1_t1`.`col_int_key` is null)), true) having (outer_field_is_not_null, (`test`.`child_sq1_t1`.`col_int_key`), true)) is false) and multiple equal(NULL, `test`.`sq2_t1`.`col_varchar_key`))) left join (`test`.`t1` `sq1_t1`) on(multiple equal(NULL, `test`.`sq2_t1`.`col_varchar_key`)) +SELECT table1.pk AS field1, +table2.pk field2 +FROM (SELECT sq1_t1.* +FROM t1 AS sq1_t1 +) AS table1 +RIGHT JOIN +(SELECT sq2_t1.* +FROM t2 AS sq2_t1 +WHERE sq2_t1.col_int_key NOT IN +(SELECT child_sq1_t1.col_int_key AS child_sq2_field1 +FROM t2 AS child_sq1_t1 +) +) AS table2 +RIGHT JOIN t2 AS table3 +ON table3.col_varchar_nokey = table2.col_varchar_key +ON table3.col_varchar_nokey = table2.col_varchar_key; +field1 field2 +DROP TABLE t1, t2; +# Bug#20073366 Assert fail in +# Optimize_table_order::Optimize_straight_join +CREATE TABLE t1 ( +pk int NOT NULL, +col_int_nokey int DEFAULT NULL, +col_int_key int DEFAULT NULL, +col_date_key date DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_date_key (col_date_key), +KEY col_varchar_key (col_varchar_key, col_int_key) +) charset utf8mb4; +CREATE TABLE t2 ( +pk int NOT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +PRIMARY KEY (pk) +) charset utf8mb4; +CREATE TABLE t3 ( +pk int NOT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +PRIMARY KEY (pk) +) charset utf8mb4; +explain SELECT STRAIGHT_JOIN alias1.col_date_key AS field1 +FROM t1 AS alias1 +INNER JOIN +((SELECT sq1_alias1.col_varchar_key +FROM t1 AS sq1_alias1 RIGHT OUTER JOIN t2 AS sq1_alias2 +ON sq1_alias2.pk = sq1_alias1.col_int_key +WHERE ('n', 'l') IN +(SELECT +c_sq1_alias1.col_varchar_nokey AS c_sq1_field1, +c_sq1_alias1.col_varchar_key AS c_sq1_field2 +FROM t3 AS c_sq1_alias1 +INNER JOIN +(t1 AS c_sq1_alias2 +INNER JOIN t1 AS c_sq1_alias3 +ON c_sq1_alias3.col_varchar_key = c_sq1_alias2.col_varchar_key +) +ON c_sq1_alias3.pk = c_sq1_alias2.pk +WHERE c_sq1_alias3.col_int_nokey <> c_sq1_alias2.col_int_nokey +) AND +sq1_alias2.col_varchar_key = 't' + ) AS alias2 +INNER JOIN t3 AS alias3 +ON alias3.col_varchar_nokey = alias2.col_varchar_key +) +ON alias3.col_varchar_key = alias2.col_varchar_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +2 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select straight_join NULL AS `field1` from `test`.`t1` `alias1` join (/* select#2 */ select NULL AS `col_varchar_key` from `test`.`t2` `sq1_alias2` semi join (`test`.`t3` `c_sq1_alias1` join `test`.`t1` `c_sq1_alias2` join `test`.`t1` `c_sq1_alias3`) where ((`test`.`c_sq1_alias3`.`col_int_nokey` <> `test`.`c_sq1_alias2`.`col_int_nokey`) and multiple equal('t', NULL) and multiple equal('n', `test`.`c_sq1_alias1`.`col_varchar_nokey`) and multiple equal('l', `test`.`c_sq1_alias1`.`col_varchar_key`) and multiple equal(`test`.`c_sq1_alias3`.`pk`, `test`.`c_sq1_alias2`.`pk`) and multiple equal(`test`.`c_sq1_alias3`.`col_varchar_key`, `test`.`c_sq1_alias2`.`col_varchar_key`))) `alias2` join `test`.`t3` `alias3` where multiple equal(`test`.`alias3`.`col_varchar_key`, `alias2`.`col_varchar_key`, `test`.`alias3`.`col_varchar_nokey`) +SELECT STRAIGHT_JOIN alias1.col_date_key AS field1 +FROM t1 AS alias1 +INNER JOIN +((SELECT sq1_alias1.col_varchar_key +FROM t1 AS sq1_alias1 RIGHT OUTER JOIN t2 AS sq1_alias2 +ON sq1_alias2.pk = sq1_alias1.col_int_key +WHERE ('n', 'l') IN +(SELECT +c_sq1_alias1.col_varchar_nokey AS c_sq1_field1, +c_sq1_alias1.col_varchar_key AS c_sq1_field2 +FROM t3 AS c_sq1_alias1 +INNER JOIN +(t1 AS c_sq1_alias2 +INNER JOIN t1 AS c_sq1_alias3 +ON c_sq1_alias3.col_varchar_key = c_sq1_alias2.col_varchar_key +) +ON c_sq1_alias3.pk = c_sq1_alias2.pk +WHERE c_sq1_alias3.col_int_nokey <> c_sq1_alias2.col_int_nokey +) AND +sq1_alias2.col_varchar_key = 't' + ) AS alias2 +INNER JOIN t3 AS alias3 +ON alias3.col_varchar_nokey = alias2.col_varchar_key +) +ON alias3.col_varchar_key = alias2.col_varchar_key; +field1 +DROP TABLE t1, t2, t3; +# Bug#20204415 Assertion failure in TABLE_LIST::set_merged() +CREATE TABLE t(a INTEGER); +CREATE VIEW v AS SELECT * FROM t; +SET optimizer_switch='derived_merge=off'; +PREPARE s1 FROM 'SELECT * FROM v'; +PREPARE s2 FROM 'SELECT * FROM (SELECT * FROM t) AS dt'; +SET optimizer_switch='derived_merge=on'; +EXECUTE s1; +a +EXECUTE s2; +a +DEALLOCATE PREPARE s1; +DEALLOCATE PREPARE s2; +DROP VIEW v; +DROP TABLE t; +# Bug#20487336 Assert length > 0 && keyparts != 0 in calc_length_and_key +CREATE TABLE t1 +(pk INTEGER PRIMARY KEY, +col_int_nokey INTEGER, +col_varchar_nokey VARCHAR(1), +col_varchar_key VARCHAR(1), +KEY col_varchar_key(col_varchar_key) +) charset utf8mb4 engine=innodb; +INSERT INTO t1 (pk) VALUES +(1), (2), (3), (4), (5), (6), (7), (8), (9), (10), +(11), (12), (13), (14), (15), (16), (17), (18), (19), (20); +CREATE TABLE t2 +(pk INTEGER PRIMARY KEY, +col_varchar_key VARCHAR(1), +KEY col_varchar_key(col_varchar_key) +) charset utf8mb4 engine=innodb; +INSERT INTO t2 (pk) VALUES +(1), (2), (3), (4), (5), (6), (7), (8), (9), (10), +(11), (12), (13), (14), (15), (16), (17), (18), (19), (20); +CREATE TABLE t3 +(pk INTEGER PRIMARY KEY, +col_varchar_key VARCHAR(1), +KEY col_varchar_key(col_varchar_key) +) charset utf8mb4 engine=innodb; +INSERT INTO t3 (pk) VALUES +(1), (2); +ANALYZE TABLE t1, t2, t3; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +explain SELECT MIN(alias1.col_varchar_nokey) AS field1 +FROM (SELECT sq1_alias1.* +FROM t1 AS sq1_alias1, t1 AS sq1_alias2 +WHERE sq1_alias1.col_varchar_nokey IN +(SELECT c_sq1_alias2.col_varchar_key AS c_sq1_field1 +FROM t1 AS c_sq1_alias1 INNER JOIN +t1 AS c_sq1_alias2 +ON c_sq1_alias2.col_varchar_nokey = c_sq1_alias1.col_varchar_key +WHERE c_sq1_alias1.col_int_nokey <> c_sq1_alias1.col_int_nokey +) AND +sq1_alias2.pk = sq1_alias1.pk +) AS alias1, +(SELECT sq2_alias1.* +FROM t2 AS sq2_alias1 RIGHT JOIN +t3 AS sq2_alias2 +ON sq2_alias2.col_varchar_key = sq2_alias1.col_varchar_key +) AS alias2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select min(`test`.`sq1_alias1`.`col_varchar_nokey`) AS `field1` from `test`.`t1` `sq1_alias1` join `test`.`t1` `sq1_alias2` semi join (`test`.`t1` `c_sq1_alias1` join `test`.`t1` `c_sq1_alias2`) join `test`.`t3` `sq2_alias2` left join `test`.`t2` `sq2_alias1` on(multiple equal(`test`.`sq2_alias2`.`col_varchar_key`, `test`.`sq2_alias1`.`col_varchar_key`)) where false +SELECT MIN(alias1.col_varchar_nokey) AS field1 +FROM (SELECT sq1_alias1.* +FROM t1 AS sq1_alias1, t1 AS sq1_alias2 +WHERE sq1_alias1.col_varchar_nokey IN +(SELECT c_sq1_alias2.col_varchar_key AS c_sq1_field1 +FROM t1 AS c_sq1_alias1 INNER JOIN +t1 AS c_sq1_alias2 +ON c_sq1_alias2.col_varchar_nokey = c_sq1_alias1.col_varchar_key +WHERE c_sq1_alias1.col_int_nokey <> c_sq1_alias1.col_int_nokey +) AND +sq1_alias2.pk = sq1_alias1.pk +) AS alias1, +(SELECT sq2_alias1.* +FROM t2 AS sq2_alias1 RIGHT JOIN +t3 AS sq2_alias2 +ON sq2_alias2.col_varchar_key = sq2_alias1.col_varchar_key +) AS alias2; +field1 +NULL +DROP TABLE t1, t2, t3; +# +# Bug #18607971 : 5.5 TO 5.6 REGRESSION WITH A SUBQUERY IN THE FROM +# CLAUSE. +# +CREATE TABLE t(id INT PRIMARY KEY, +c1 INT, c2 INT, key(c2)) engine=InnoDB; +INSERT INTO t(id, c1, c2) VALUES(1, 2, 3), (2, 3, 4), (3, 3, 4), (4, 3, 4); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +EXPLAIN SELECT * FROM +(SELECT t1.c1 +FROM t t1 INNER JOIN t t2 ON t1.c1= 3 +GROUP BY t1.c1) a, t b +WHERE b.id BETWEEN 1 AND 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL system NULL NULL NULL NULL 1 100.00 NULL +1 PRIMARY b NULL range PRIMARY PRIMARY 4 NULL 4 100.00 Using where +2 DERIVED t1 NULL ALL NULL NULL NULL NULL 4 25.00 Using where +2 DERIVED t2 NULL index NULL c2 5 NULL 4 100.00 Using index; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '3' AS `c1`,`test`.`b`.`id` AS `id`,`test`.`b`.`c1` AS `c1`,`test`.`b`.`c2` AS `c2` from `test`.`t` `b` where (`test`.`b`.`id` between 1 and 10) +EXPLAIN SELECT * FROM +(SELECT t1.id +FROM t t1 INNER JOIN t t2 ON t1.id=1 AND t1.c1=t2.id +GROUP BY t1.id, t2.c2) a, t b +WHERE b.id BETWEEN 1 AND 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL system NULL NULL NULL NULL 1 100.00 NULL +1 PRIMARY b NULL range PRIMARY PRIMARY 4 NULL 4 100.00 Using where +2 DERIVED t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +2 DERIVED t2 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select '1' AS `id`,`test`.`b`.`id` AS `id`,`test`.`b`.`c1` AS `c1`,`test`.`b`.`c2` AS `c2` from `test`.`t` `b` where (`test`.`b`.`id` between 1 and 10) +EXPLAIN SELECT * FROM +(SELECT t1.c1 +FROM t t1 INNER JOIN t t2 ON t1.c1= 3 AND t2.c2= 3 +GROUP BY t1.c1) a, t b +WHERE b.id BETWEEN 1 AND 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL system NULL NULL NULL NULL 1 100.00 NULL +1 PRIMARY b NULL range PRIMARY PRIMARY 4 NULL 4 100.00 Using where +2 DERIVED t2 NULL ref c2 c2 5 const 1 100.00 Using index +2 DERIVED t1 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '3' AS `c1`,`test`.`b`.`id` AS `id`,`test`.`b`.`c1` AS `c1`,`test`.`b`.`c2` AS `c2` from `test`.`t` `b` where (`test`.`b`.`id` between 1 and 10) +EXPLAIN SELECT * FROM +(SELECT t1.c1 +FROM t t1 INNER JOIN t t2 ON t1.c1= 3 AND t2.c2= 3 +GROUP BY t1.c1, t2.c2) a, t b +WHERE b.id BETWEEN 1 AND 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL system NULL NULL NULL NULL 1 100.00 NULL +1 PRIMARY b NULL range PRIMARY PRIMARY 4 NULL 4 100.00 Using where +2 DERIVED t2 NULL ref c2 c2 5 const 1 100.00 Using index +2 DERIVED t1 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '3' AS `c1`,`test`.`b`.`id` AS `id`,`test`.`b`.`c1` AS `c1`,`test`.`b`.`c2` AS `c2` from `test`.`t` `b` where (`test`.`b`.`id` between 1 and 10) +EXPLAIN SELECT * FROM +(SELECT t1.c1 +FROM t t1 INNER JOIN t t2 ON t1.c1= 3 AND t2.c2= 3 +GROUP BY t1.c1, t1.id) a, t b +WHERE b.id BETWEEN 1 AND 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY b NULL range PRIMARY PRIMARY 4 NULL 4 100.00 Using where +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +2 DERIVED t2 NULL ref c2 c2 5 const 1 100.00 Using index; Using temporary +2 DERIVED t1 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `a`.`c1` AS `c1`,`test`.`b`.`id` AS `id`,`test`.`b`.`c1` AS `c1`,`test`.`b`.`c2` AS `c2` from (/* select#2 */ select `test`.`t1`.`c1` AS `c1` from `test`.`t` `t1` join `test`.`t` `t2` where ((`test`.`t2`.`c2` = 3) and (`test`.`t1`.`c1` = 3)) group by `test`.`t1`.`c1`,`test`.`t1`.`id`) `a` join `test`.`t` `b` where (`test`.`b`.`id` between 1 and 10) +EXPLAIN SELECT * FROM +(SELECT t1.id +FROM t t1 INNER JOIN t t2 ON t1.id=1 AND t1.c1=t2.c1 +GROUP BY t2.c1, t1.id) a, t b +WHERE b.id BETWEEN 1 AND 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL system NULL NULL NULL NULL 1 100.00 NULL +1 PRIMARY b NULL range PRIMARY PRIMARY 4 NULL 4 100.00 Using where +2 DERIVED t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +2 DERIVED t2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select '1' AS `id`,`test`.`b`.`id` AS `id`,`test`.`b`.`c1` AS `c1`,`test`.`b`.`c2` AS `c2` from `test`.`t` `b` where (`test`.`b`.`id` between 1 and 10) +EXPLAIN SELECT * FROM +(SELECT t1.id +FROM t t1 INNER JOIN t t2 ON t1.id=1 AND t1.c1=t2.id +GROUP BY t2.c1, t1.id) a, t b +WHERE b.id BETWEEN 1 AND 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL system NULL NULL NULL NULL 1 100.00 NULL +1 PRIMARY b NULL range PRIMARY PRIMARY 4 NULL 4 100.00 Using where +2 DERIVED t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +2 DERIVED t2 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select '1' AS `id`,`test`.`b`.`id` AS `id`,`test`.`b`.`c1` AS `c1`,`test`.`b`.`c2` AS `c2` from `test`.`t` `b` where (`test`.`b`.`id` between 1 and 10) +EXPLAIN SELECT * FROM +(SELECT t1.id +FROM t t1 INNER JOIN t t2 ON t1.id=1 AND t1.c1=t2.id +GROUP BY t2.c2, t1.id) a, t b +WHERE b.id BETWEEN 1 AND 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL system NULL NULL NULL NULL 1 100.00 NULL +1 PRIMARY b NULL range PRIMARY PRIMARY 4 NULL 4 100.00 Using where +2 DERIVED t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +2 DERIVED t2 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select '1' AS `id`,`test`.`b`.`id` AS `id`,`test`.`b`.`c1` AS `c1`,`test`.`b`.`c2` AS `c2` from `test`.`t` `b` where (`test`.`b`.`id` between 1 and 10) +EXPLAIN SELECT * FROM +(SELECT t1.id +FROM t t1 INNER JOIN t t2 ON t1.id=1 AND t1.c1=t2.id +GROUP BY t1.id, t2.c2) a, t b +WHERE b.id BETWEEN 1 AND 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL system NULL NULL NULL NULL 1 100.00 NULL +1 PRIMARY b NULL range PRIMARY PRIMARY 4 NULL 4 100.00 Using where +2 DERIVED t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +2 DERIVED t2 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select '1' AS `id`,`test`.`b`.`id` AS `id`,`test`.`b`.`c1` AS `c1`,`test`.`b`.`c2` AS `c2` from `test`.`t` `b` where (`test`.`b`.`id` between 1 and 10) +EXPLAIN SELECT * FROM +(SELECT t1.id +FROM t t1 INNER JOIN t t2 INNER JOIN t t3 ON t1.id=1 AND t1.c1=t2.id AND t2.c1=t3.id +GROUP BY t1.id, t2.c2, t3.c2) a, t b +WHERE b.id BETWEEN 1 AND 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL system NULL NULL NULL NULL 1 100.00 NULL +1 PRIMARY b NULL range PRIMARY PRIMARY 4 NULL 4 100.00 Using where +2 DERIVED t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +2 DERIVED t2 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +2 DERIVED t3 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select '1' AS `id`,`test`.`b`.`id` AS `id`,`test`.`b`.`c1` AS `c1`,`test`.`b`.`c2` AS `c2` from `test`.`t` `b` where (`test`.`b`.`id` between 1 and 10) +EXPLAIN SELECT * FROM +(SELECT DISTINCT t1.id +FROM t t1 +WHERE t1.id= 1) a, t b +WHERE b.id BETWEEN 1 AND 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL system NULL NULL NULL NULL 1 100.00 NULL +1 PRIMARY b NULL range PRIMARY PRIMARY 4 NULL 4 100.00 Using where +2 DERIVED t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select '1' AS `id`,`test`.`b`.`id` AS `id`,`test`.`b`.`c1` AS `c1`,`test`.`b`.`c2` AS `c2` from `test`.`t` `b` where (`test`.`b`.`id` between 1 and 10) +EXPLAIN SELECT * FROM +(SELECT t1.id + 1 +FROM t t1 INNER JOIN t t2 ON t1.id= 1 +GROUP BY t1.id + 1) a, t b +WHERE b.id BETWEEN 1 AND 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL system NULL NULL NULL NULL 1 100.00 NULL +1 PRIMARY b NULL range PRIMARY PRIMARY 4 NULL 4 100.00 Using where +2 DERIVED t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 Using index +2 DERIVED t2 NULL index NULL c2 5 NULL 4 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select '2' AS `t1.id + 1`,`test`.`b`.`id` AS `id`,`test`.`b`.`c1` AS `c1`,`test`.`b`.`c2` AS `c2` from `test`.`t` `b` where (`test`.`b`.`id` between 1 and 10) +EXPLAIN SELECT * FROM +(SELECT t1.c1 +FROM t t1 INNER JOIN t t2 ON t1.c1= 3 +GROUP BY 1.5) a, t b +WHERE b.id BETWEEN 1 AND 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL system NULL NULL NULL NULL 1 100.00 NULL +1 PRIMARY b NULL range PRIMARY PRIMARY 4 NULL 4 100.00 Using where +2 DERIVED t1 NULL ALL NULL NULL NULL NULL 4 25.00 Using where +2 DERIVED t2 NULL index NULL c2 5 NULL 4 100.00 Using index; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '3' AS `c1`,`test`.`b`.`id` AS `id`,`test`.`b`.`c1` AS `c1`,`test`.`b`.`c2` AS `c2` from `test`.`t` `b` where (`test`.`b`.`id` between 1 and 10) +EXPLAIN SELECT * FROM +(SELECT t1.id +FROM t t1 INNER JOIN t t2 ON mod(t1.id,1000)= 1 +GROUP BY t1.id) a, t b +WHERE b.id BETWEEN 1 AND 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY b NULL range PRIMARY PRIMARY 4 NULL 4 100.00 Using where +1 PRIMARY NULL ALL NULL NULL NULL NULL 16 100.00 Using join buffer (hash join) +2 DERIVED t1 NULL index PRIMARY,c2 c2 5 NULL 4 100.00 Using where; Using index; Using temporary +2 DERIVED t2 NULL index NULL c2 5 NULL 4 100.00 Using index; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `a`.`id` AS `id`,`test`.`b`.`id` AS `id`,`test`.`b`.`c1` AS `c1`,`test`.`b`.`c2` AS `c2` from (/* select#2 */ select `test`.`t1`.`id` AS `id` from `test`.`t` `t1` join `test`.`t` `t2` where ((`test`.`t1`.`id` % 1000) = 1) group by `test`.`t1`.`id`) `a` join `test`.`t` `b` where (`test`.`b`.`id` between 1 and 10) +EXPLAIN SELECT * FROM +(SELECT t1.id + 1 +FROM t t1 INNER JOIN t t2 ON t1.id + 1= 2 +GROUP BY t1.id + 1) a, t b +WHERE b.id BETWEEN 1 AND 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL system NULL NULL NULL NULL 1 100.00 NULL +1 PRIMARY b NULL range PRIMARY PRIMARY 4 NULL 4 100.00 Using where +2 DERIVED t1 NULL index PRIMARY,c2 c2 5 NULL 4 100.00 Using where; Using index +2 DERIVED t2 NULL index NULL c2 5 NULL 4 100.00 Using index; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `t1.id + 1`,`test`.`b`.`id` AS `id`,`test`.`b`.`c1` AS `c1`,`test`.`b`.`c2` AS `c2` from `test`.`t` `b` where (`test`.`b`.`id` between 1 and 10) +CREATE VIEW v1 AS SELECT c1 a FROM t WHERE c1 = 3; +CREATE VIEW v2 AS SELECT c2 b FROM t WHERE c2 > 3; +EXPLAIN SELECT * FROM (SELECT v1.a +FROM v1 LEFT OUTER JOIN v2 ON v1.a = v2.b +GROUP BY v1.a) p, t q +WHERE q.id BETWEEN 1 AND 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL system NULL NULL NULL NULL 1 100.00 NULL +1 PRIMARY q NULL range PRIMARY PRIMARY 4 NULL 4 100.00 Using where +2 DERIVED t NULL ALL NULL NULL NULL NULL 4 25.00 Using where +2 DERIVED t NULL ref c2 c2 5 const 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select '3' AS `a`,`test`.`q`.`id` AS `id`,`test`.`q`.`c1` AS `c1`,`test`.`q`.`c2` AS `c2` from `test`.`t` `q` where (`test`.`q`.`id` between 1 and 10) +DROP VIEW v1; +CREATE VIEW v1 AS SELECT c1 a FROM t; +EXPLAIN SELECT * FROM (SELECT v1.a +FROM v1 LEFT OUTER JOIN v2 ON v1.a = v2.b AND v1.a = 10 +GROUP BY v1.a) p, t q +WHERE q.id BETWEEN 1 AND 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY q NULL range PRIMARY PRIMARY 4 NULL 4 100.00 Using where +1 PRIMARY NULL ALL NULL NULL NULL NULL 8 100.00 Using join buffer (hash join) +2 DERIVED t NULL ALL NULL NULL NULL NULL 4 100.00 Using temporary +2 DERIVED t NULL ref c2 c2 5 const 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `p`.`a` AS `a`,`test`.`q`.`id` AS `id`,`test`.`q`.`c1` AS `c1`,`test`.`q`.`c2` AS `c2` from (/* select#2 */ select `test`.`t`.`c1` AS `a` from `test`.`t` left join (`test`.`t`) on(((`test`.`t`.`c1` = 10) and (`test`.`t`.`c2` = 10) and (10 > 3))) where true group by `test`.`t`.`c1`) `p` join `test`.`t` `q` where (`test`.`q`.`id` between 1 and 10) +EXPLAIN SELECT * FROM (SELECT v1.a +FROM v1 LEFT OUTER JOIN v2 ON v1.a = v2.b +WHERE v1.a = 3 +GROUP BY v1.a) p, t q +WHERE q.id BETWEEN 1 AND 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL system NULL NULL NULL NULL 1 100.00 NULL +1 PRIMARY q NULL range PRIMARY PRIMARY 4 NULL 4 100.00 Using where +2 DERIVED t NULL ALL NULL NULL NULL NULL 4 25.00 Using where +2 DERIVED t NULL ref c2 c2 5 const 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select '3' AS `a`,`test`.`q`.`id` AS `id`,`test`.`q`.`c1` AS `c1`,`test`.`q`.`c2` AS `c2` from `test`.`t` `q` where (`test`.`q`.`id` between 1 and 10) +DROP VIEW v1, v2; +DROP TABLE t; +# Bug #20443457 : Assert fail in calc_length_and_keyparts +CREATE TABLE t1( +pk INTEGER PRIMARY KEY, +k INTEGER, +KEY k(k), +nk INTEGER); +INSERT INTO t1 VALUES(1, 10, 100), (2, 20, 200); +set @optimizer_switch_saved=@@optimizer_switch; +set @@optimizer_switch='firstmatch=off'; +explain SELECT t1.k +FROM t1 RIGHT JOIN +(SELECT t2.* +FROM t1 AS t2 JOIN t1 AS t3 +ON TRUE +WHERE t3.k IN (SELECT k FROM t1 AS t4 WHERE k>1) +) AS dt +ON t1.pk = dt.pk; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index NULL PRIMARY 4 NULL 2 100.00 Using index +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.pk 1 100.00 NULL +1 SIMPLE t4 NULL index k k 5 NULL 2 100.00 Using where; Using index; LooseScan +1 SIMPLE t3 NULL index k k 5 NULL 2 100.00 Using where; Using index; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`k` AS `k` from `test`.`t1` `t2` join `test`.`t1` `t3` semi join (`test`.`t1` `t4`) left join `test`.`t1` on((`test`.`t1`.`pk` = `test`.`t2`.`pk`)) where ((`test`.`t3`.`k` = `test`.`t4`.`k`) and (`test`.`t4`.`k` > 1)) +SELECT t1.k +FROM t1 RIGHT JOIN +(SELECT t2.* +FROM t1 AS t2 JOIN t1 AS t3 +ON TRUE +WHERE t3.k IN (SELECT k FROM t1 AS t4 WHERE k>1) +) AS dt +ON t1.pk = dt.pk; +k +10 +10 +20 +20 +SET @@optimizer_switch=@optimizer_switch_saved; +DROP TABLE t1; +# Bug#20733540: Assertion failed: !table || (!table->read_set ...) +CREATE TABLE t1(a INTEGER, b VARCHAR(10)); +INSERT INTO t1 VALUES (1,'a'); +CREATE TABLE t2(c INTEGER); +INSERT INTO t2 VALUES(0); +SELECT 1 +FROM (SELECT b FROM t1 WHERE a) AS dt1 +RIGHT JOIN t2 +ON c NOT BETWEEN 1 AND 2 +NATURAL JOIN t1 AS t3; +1 +1 +DROP TABLE t1, t2; +# Bug#21512842: Sig 11 in check_column_grant_in_table_ref +CREATE TABLE t1 ( +pk INTEGER, +col_varchar JSON NOT NULL, +PRIMARY KEY (pk) +); +CREATE TABLE t2 ( +pk INTEGER, +col_date_key DATE NOT NULL, +PRIMARY KEY (pk) +); +set sql_mode=''; +SELECT * +FROM (SELECT alias2.pk AS field1 +FROM t1 AS alias1 +LEFT OUTER JOIN t2 AS alias2 +ON JSON_UNQUOTE(JSON_EXTRACT(alias1.col_varchar,'$.varc')) +COLLATE utf8mb4_general_ci = alias2.col_date_key +GROUP BY JSON_QUOTE(JSON_EXTRACT(field1,'$.intc')) +) AS dt; +field1 +set sql_mode=default; +DROP TABLE t1, t2; +# Bug#21350125: Wrong results when ORDER BY is removed +CREATE TABLE t1 ( +c1n varchar(1) NOT NULL, +c1k varchar(2) DEFAULT NULL, +KEY c1k (c1k) +); +INSERT INTO t1 VALUES ('j','jj'),('r','rr'); +CREATE TABLE t2 ( +c2k varchar(1) NOT NULL, +c2n varchar(2) DEFAULT NULL, +KEY c2k (c2k) +); +INSERT INTO t2 VALUES +('f','ff'),('t','tt'),('c','cc'),('c','cc'),('r','rr'),('k','kk'); +CREATE TABLE `empty` (dummy INTEGER); +CREATE VIEW vr AS +SELECT t2.c2n AS v_field +FROM t1 RIGHT JOIN t2 +ON t2.c2k = t1.c1k; +CREATE VIEW vl AS +SELECT t2.c2n AS v_field +FROM t2 LEFT JOIN t1 +ON t2.c2k = t1.c1k; +SELECT alias1.dt_field AS field1 +FROM (SELECT t2.c2n AS dt_field +FROM t1 RIGHT JOIN t2 +ON t2.c2k = t1.c1k +) AS alias1 +RIGHT JOIN t2 AS alias2 +ON alias2.c2n = alias1.dt_field; +field1 +ff +tt +cc +cc +cc +cc +rr +kk +prepare s from 'SELECT alias1.dt_field AS field1 +FROM (SELECT t2.c2n AS dt_field +FROM t1 RIGHT JOIN t2 +ON t2.c2k = t1.c1k +) AS alias1 +RIGHT JOIN t2 AS alias2 +ON alias2.c2n = alias1.dt_field'; +execute s; +field1 +ff +tt +cc +cc +cc +cc +rr +kk +deallocate prepare s; +SELECT alias1.dt_field AS field1 +FROM (SELECT t2.c2n AS dt_field +FROM t2 LEFT JOIN t1 +ON t2.c2k = t1.c1k +) AS alias1 +RIGHT JOIN t2 AS alias2 +ON alias2.c2n = alias1.dt_field; +field1 +ff +tt +cc +cc +cc +cc +rr +kk +prepare s from 'SELECT alias1.dt_field AS field1 +FROM (SELECT t2.c2n AS dt_field +FROM t2 LEFT JOIN t1 +ON t2.c2k = t1.c1k +) AS alias1 +RIGHT JOIN t2 AS alias2 +ON alias2.c2n = alias1.dt_field'; +execute s; +field1 +ff +tt +cc +cc +cc +cc +rr +kk +deallocate prepare s; +SELECT alias1.v_field AS field1 +FROM vl AS alias1 +RIGHT JOIN t2 AS alias2 +ON alias2.c2n = alias1.v_field; +field1 +ff +tt +cc +cc +cc +cc +rr +kk +SELECT alias1.v_field AS field1 +FROM vr AS alias1 +RIGHT JOIN t2 AS alias2 +ON alias2.c2n = alias1.v_field; +field1 +ff +tt +cc +cc +cc +cc +rr +kk +SELECT alias1.dt_field AS field1 +FROM (SELECT t2.c2n AS dt_field +FROM t1 RIGHT JOIN +(`empty` RIGHT JOIN t2 +ON TRUE) +ON t2.c2k = t1.c1k +) AS alias1 +RIGHT JOIN t2 AS alias2 +ON alias2.c2n = alias1.dt_field; +field1 +ff +tt +cc +cc +cc +cc +rr +kk +SELECT alias1.dt_field AS field1 +FROM (SELECT t2.c2n AS dt_field +FROM t1 RIGHT JOIN +(t2 LEFT JOIN `empty` + ON TRUE) +ON t2.c2k = t1.c1k +) AS alias1 +RIGHT JOIN t2 AS alias2 +ON alias2.c2n = alias1.dt_field; +field1 +ff +tt +cc +cc +cc +cc +rr +kk +DROP VIEW vl, vr; +DROP TABLE t1, t2, `empty`; +# Bug#22239474: Unexpected error 1093 on nested subquery for update +CREATE TABLE t1 (id INTEGER PRIMARY KEY, d INTEGER); +INSERT INTO t1 VALUES(1, 10), (2, 20); +explain DELETE FROM t1 +WHERE id IN (SELECT * FROM (SELECT id FROM t1) AS dt); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL PRIMARY NULL NULL NULL 2 100.00 NULL +1 PRIMARY NULL ref 4 test.t1.id 2 100.00 Using index; FirstMatch(t1) +3 DERIVED t1 NULL index NULL PRIMARY 4 NULL 2 100.00 Using index +Warnings: +Note 1003 delete from `test`.`t1` where (`dt`.`id` = `test`.`t1`.`id`) +DELETE FROM t1 +WHERE id IN (SELECT * FROM (SELECT id FROM t1) AS dt); +INSERT INTO t1 VALUES(1, 10), (2, 20); +explain UPDATE t1 SET d= NULL +WHERE id IN (SELECT * FROM (SELECT id FROM t1) AS dt); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL PRIMARY NULL NULL NULL 2 100.00 NULL +1 PRIMARY NULL ref 4 test.t1.id 2 100.00 Using index; FirstMatch(t1) +3 DERIVED t1 NULL index NULL PRIMARY 4 NULL 2 100.00 Using index +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`d` = NULL where (`dt`.`id` = `test`.`t1`.`id`) +UPDATE t1 SET d= NULL +WHERE id IN (SELECT * FROM (SELECT id FROM t1) AS dt); +explain INSERT INTO t1 SELECT id+10, d FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 INSERT t1 NULL ALL NULL NULL NULL NULL NULL NULL NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using temporary +Warnings: +Note 1003 insert into `test`.`t1` /* select#1 */ select sql_buffer_result (`test`.`t1`.`id` + 10) AS `id+10`,`test`.`t1`.`d` AS `d` from `test`.`t1` +INSERT INTO t1 SELECT id+10, d FROM t1; +explain INSERT INTO t1 SELECT id+20, d FROM (SELECT * FROM t1) AS dt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 INSERT t1 NULL ALL NULL NULL NULL NULL NULL NULL NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 100.00 Using temporary +Warnings: +Note 1003 insert into `test`.`t1` /* select#1 */ select sql_buffer_result (`test`.`t1`.`id` + 20) AS `id+20`,`test`.`t1`.`d` AS `d` from `test`.`t1` +INSERT INTO t1 SELECT id+20, d FROM (SELECT * FROM t1) AS dt; +DROP TABLE t1; +# Bug#22223202: Query with double nested subquery much slower in 5.7 +CREATE TABLE t1 ( +t1_rowid bigint unsigned NOT NULL, +t1_co varchar(1) NOT NULL, +t1_inv_date char(3) NOT NULL, +UNIQUE KEY rowid (t1_rowid), +KEY invdate (t1_co, t1_inv_date) +) charset latin1; +INSERT INTO t1 VALUES (505975,'D','s:1'),(505981,'D','s:1'),(505869,'D','s:3'); +CREATE TABLE t2 ( +t2_rowid bigint unsigned NOT NULL, +t2_end_date char(3) NOT NULL, +UNIQUE KEY rowid (t2_rowid), +KEY end_date (t2_end_date) +) charset latin1; +INSERT INTO t2 VALUES (9,'_:L'), (10,'_<2'), (11,'_= 's:1' + ) AS periods +ON periods.prev_end_date < t1_inv_date AND +periods.end_date >= t1_inv_date; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL index NULL invdate 6 NULL 3 100.00 Using index +1 PRIMARY NULL ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (hash join) +2 DERIVED curr NULL index end_date end_date 3 NULL 3 100.00 Using where; Using index +3 DEPENDENT SUBQUERY prev NULL index end_date end_date 3 NULL 1 33.33 Using where; Backward index scan; Using index +Warnings: +Note 1276 Field or reference 'test.curr.t2_end_date' of SELECT #3 was resolved in SELECT #2 +Note 1003 /* select#1 */ select `test`.`t1`.`t1_inv_date` AS `t1_inv_date` from `test`.`t1` left join (/* select#2 */ select `test`.`curr`.`t2_end_date` AS `end_date`,(/* select#3 */ select `test`.`prev`.`t2_end_date` from `test`.`t2` `prev` where (`test`.`prev`.`t2_end_date` < `test`.`curr`.`t2_end_date`) order by `test`.`prev`.`t2_end_date` desc limit 1) AS `prev_end_date` from `test`.`t2` `curr` where (`test`.`curr`.`t2_end_date` >= 's:1')) `periods` on(((`periods`.`prev_end_date` < `test`.`t1`.`t1_inv_date`) and (`periods`.`end_date` >= `test`.`t1`.`t1_inv_date`))) where true +SELECT t1_inv_date +FROM t1 LEFT JOIN +(SELECT curr.t2_end_date As end_date, +(SELECT prev.t2_end_date +FROM t2 AS prev +WHERE prev.t2_end_date < curr.t2_end_date +ORDER BY prev.t2_end_date DESC LIMIT 1) AS prev_end_date +FROM t2 AS curr +WHERE curr.t2_end_date >= 's:1' + ) AS periods +ON periods.prev_end_date < t1_inv_date AND +periods.end_date >= t1_inv_date; +t1_inv_date +s:1 +s:1 +s:3 +explain SELECT /*+ MERGE(periods) */ t1_inv_date +FROM t1 LEFT JOIN +(SELECT curr.t2_end_date As end_date, +(SELECT prev.t2_end_date +FROM t2 AS prev +WHERE prev.t2_end_date < curr.t2_end_date +ORDER BY prev.t2_end_date DESC LIMIT 1) AS prev_end_date +FROM t2 AS curr +WHERE curr.t2_end_date >= 's:1' + ) AS periods +ON periods.prev_end_date < t1_inv_date AND +periods.end_date >= t1_inv_date; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL index NULL invdate 6 NULL 3 100.00 Using index +1 PRIMARY curr NULL index end_date end_date 3 NULL 3 100.00 Using where; Using index; Using join buffer (hash join) +3 DEPENDENT SUBQUERY prev NULL index end_date end_date 3 NULL 1 33.33 Using where; Backward index scan; Using index +Warnings: +Note 1276 Field or reference 'test.curr.t2_end_date' of SELECT #3 was resolved in SELECT #2 +Note 1003 /* select#1 */ select /*+ MERGE(`periods`@`select#1`) */ `test`.`t1`.`t1_inv_date` AS `t1_inv_date` from `test`.`t1` left join (`test`.`t2` `curr`) on((((/* select#3 */ select `test`.`prev`.`t2_end_date` from `test`.`t2` `prev` where (`test`.`prev`.`t2_end_date` < `test`.`curr`.`t2_end_date`) order by `test`.`prev`.`t2_end_date` desc limit 1) < `test`.`t1`.`t1_inv_date`) and (`test`.`curr`.`t2_end_date` >= `test`.`t1`.`t1_inv_date`) and (`test`.`curr`.`t2_end_date` >= 's:1'))) where true +SELECT /*+ MERGE(periods) */ t1_inv_date +FROM t1 LEFT JOIN +(SELECT curr.t2_end_date As end_date, +(SELECT prev.t2_end_date +FROM t2 AS prev +WHERE prev.t2_end_date < curr.t2_end_date +ORDER BY prev.t2_end_date DESC LIMIT 1) AS prev_end_date +FROM t2 AS curr +WHERE curr.t2_end_date >= 's:1' + ) AS periods +ON periods.prev_end_date < t1_inv_date AND +periods.end_date >= t1_inv_date; +t1_inv_date +s:1 +s:1 +s:3 +DROP TABLE t1, t2; +# Bug#22176604: Wrong result on outer join with uncorrelated subquery +CREATE TABLE t1 (a INT, KEY(a)); +INSERT INTO t1 VALUES (1), (NULL); +CREATE TABLE t2 (b INT, KEY(b)); +INSERT INTO t2 VALUES (7), (NULL), (1), (5), (8), (6), (4), (0), (3), (NULL); +CREATE TABLE t3 (c INT); +INSERT INTO t3 VALUES (NULL), (1), (5); +explain SELECT * FROM t1 LEFT JOIN ( +SELECT t3.* FROM t2 INNER JOIN t3 ON b = c +) AS sq ON a <= sq.c; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index NULL a 5 NULL 2 100.00 Using index +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t2 NULL ref b b 5 test.t3.c 2 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t3`.`c` AS `c` from `test`.`t1` left join (`test`.`t2` join `test`.`t3`) on(((`test`.`t2`.`b` = `test`.`t3`.`c`) and (`test`.`t1`.`a` <= `test`.`t3`.`c`))) where true +SELECT * FROM t1 LEFT JOIN ( +SELECT t3.* FROM t2 INNER JOIN t3 ON b = c +) AS sq ON a <= sq.c; +a c +1 1 +1 5 +NULL NULL +DROP TABLE t1, t2, t3; +# Bug#22343301: Error 1093 (HY000): You can't specify target table'.' +# for update in FROM clause +CREATE TABLE users ( +id int unsigned AUTO_INCREMENT, +name varchar(255), +position int DEFAULT NULL, +PRIMARY KEY (id)); +INSERT INTO users (name, position) VALUES +('user1','1'), ('user2','2'), ('user3','3'), ('user4','4'), ('user5','5'); +# Single-table update with non-mergeable derived table +UPDATE users +SET position = (SELECT COUNT(pos) + 1 +FROM (SELECT DISTINCT position AS pos FROM users) AS t2 +WHERE t2.pos < users.position) +WHERE id = 3; +# Single-table update with mergeable derived table +# (but not merged due to being used in a subquery of an UPDATE statement) +UPDATE users +SET position = (SELECT COUNT(pos) + 1 +FROM (SELECT position AS pos FROM users) AS t2 +WHERE t2.pos < users.position) +WHERE id = 3; +# Multi-table update with non-mergeable derived table +UPDATE users, (SELECT 1) AS dummy +SET position = (SELECT COUNT(pos) + 1 +FROM (SELECT DISTINCT position AS pos FROM users) AS t2 +WHERE t2.pos < users.position) +WHERE id = 3; +# Multi-table update with mergeable derived table +UPDATE users, (SELECT 1) AS dummy +SET position = (SELECT COUNT(pos) + 1 +FROM (SELECT position AS pos FROM users) AS t2 +WHERE t2.pos < users.position) +WHERE id = 3; +UPDATE users +SET position = (SELECT COUNT(t2.position) + 1 +FROM users AS t2 +WHERE t2.position < users.position) +WHERE id = 3; +ERROR HY000: You can't specify target table 'users' for update in FROM clause +UPDATE users, (SELECT 1) AS dummy +SET position = (SELECT COUNT(t2.position) + 1 +FROM users AS t2 +WHERE t2.position < users.position) +WHERE id = 3; +ERROR HY000: You can't specify target table 'users' for update in FROM clause +DROP TABLE users; +# Bug#22783011 assertion failed: base_select != removed_select && +# aggr_select != removed_select +CREATE TABLE t(a INTEGER) engine=innodb; +INSERT INTO t VALUES(1); +# Per MySQL rules, SUM(1) is aggregated in top query +# (can't be in WHERE, in FROM) +SELECT (SELECT 1 FROM (SELECT 1 FROM t WHERE SUM(1)) AS t); +(SELECT 1 FROM (SELECT 1 FROM t WHERE SUM(1)) AS t) +1 +SELECT (SELECT 1 FROM (SELECT 1 FROM t WHERE SUM(0)) AS t); +(SELECT 1 FROM (SELECT 1 FROM t WHERE SUM(0)) AS t) +NULL +DROP TABLE t; +# Bug#23074801: Delete from joined tables with where using derived table +# fails with error 1093 +CREATE TABLE t1 (id INTEGER, d1 INTEGER); +CREATE TABLE t2 (id INTEGER, d2 INTEGER); +DELETE t1, t2 +FROM t1 LEFT JOIN t2 ON t1.id = t2.id +WHERE t1.id IN (SELECT * FROM (SELECT id FROM t1) AS t1sub); +DROP TABLE t1, t2; +# Bug#22967439: Mysql 5.7 vs 5.6 incorrect SELECT statement result +CREATE TABLE t1 +(integer1 INTEGER NULL, +integer2 INTEGER NULL, +varchar1 VARCHAR(255) NULL); +CREATE TABLE t2 +(integer1 INTEGER NULL, +integer2 INTEGER NULL, +varchar1 VARCHAR(255) NULL, +varchar2 VARCHAR(255) NULL); +INSERT INTO t1 VALUES +(11,12,'test1'), (21,22,'test2'), (31,32,'test3'); +INSERT INTO t2 VALUES +(11,12,'test1','test12'), (21,22,'test2','test22'), (31,32,'test3','test32'); +SELECT g_t3.g_f1, g_t3.g_f2, g_t3.g_f3 +FROM (SELECT g_t0.integer1 AS g_f1, +g_t0.integer2 AS g_f2, +g_t0.varchar1 AS g_f3 +FROM t1 g_t0 +) g_t3 +GROUP BY g_t3.g_f1, g_t3.g_f2, g_t3.g_f3 +HAVING g_t3.g_f3 = (select varchar1 +from t2 +where integer1 = g_t3.g_f1 +); +g_f1 g_f2 g_f3 +11 12 test1 +21 22 test2 +31 32 test3 +DROP TABLE t1, t2; +# Bug#24364448: Assert m_opr_handle != null in +# ha_innobase_inmem::keys_to_use_for_scanning +CREATE TABLE K (col_int int(11), col_varchar varchar(255)) charset latin1; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO K VALUES (NULL,'m'), (NULL,'z'); +CREATE TABLE H (col_varchar varchar(255)) charset latin1; +INSERT INTO H VALUES ('m'), ('z'); +SET @optimizer_switch_saved= @@optimizer_switch; +SET @@optimizer_switch="derived_merge=off"; +FLUSH STATUS; +SELECT t1.col_int +FROM (SELECT * FROM K) t1 JOIN (SELECT * FROM H) t2 USING(col_varchar) +WHERE t1.col_int IS NULL +ORDER BY t1.col_int; +col_int +NULL +NULL +SHOW STATUS LIKE 'Created_tmp%'; +Variable_name Value +Created_tmp_disk_tables 0 +Created_tmp_files 0 +Created_tmp_tables 2 +SET @@optimizer_switch=@optimizer_switch_saved; +DROP TABLE K, H; +# +# Bug #25343335: DERIVED TABLE SELECT LIST'S REFERENCE TO ALIAS CAUSES +# INCORRECT BEHAVIOR +# +CREATE TABLE t1 (c11 int); +INSERT INTO t1 VALUES (1); +EXPLAIN SELECT * +FROM (SELECT (1) alias1, +(SELECT alias1) alias2 +FROM t1) X ; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1249 Select 3 was reduced during optimization +Note 1003 /* select#1 */ select 1 AS `alias1`,`alias1` AS `alias2` from dual +SELECT * +FROM (SELECT (1) alias1, +(SELECT alias1) alias2 +FROM t1) X ; +alias1 alias2 +1 1 +PREPARE xx FROM 'SELECT * +FROM (SELECT (1) alias1, +(SELECT alias1) alias2 +FROM t1) X '; +EXECUTE xx; +alias1 alias2 +1 1 +EXECUTE xx; +alias1 alias2 +1 1 +EXECUTE xx; +alias1 alias2 +1 1 +EXPLAIN SELECT alias2 +FROM (SELECT (1) alias1, +(SELECT alias1) alias2 +FROM t1) X ; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1249 Select 3 was reduced during optimization +Note 1003 /* select#1 */ select `alias1` AS `alias2` from dual +SELECT alias2 +FROM (SELECT (1) alias1, +(SELECT alias1) alias2 +FROM t1) X ; +alias2 +1 +PREPARE yy FROM 'SELECT alias2 +FROM (SELECT (1) alias1, +(SELECT alias1) alias2 +FROM t1) X '; +EXECUTE yy; +alias2 +1 +EXECUTE yy; +alias2 +1 +EXECUTE yy; +alias2 +1 +DROP TABLE t1; +# +# Bug#26596977: ASSERT `!(USED_TABS & (~READ_TABLES & ~FILTER_FOR_TABLE))' +# FAILED IN ITEM_FUNC +# +CREATE TABLE t1 ( +col_varchar_key varchar(1) , +pk int(11) NOT NULL AUTO_INCREMENT, +PRIMARY KEY (pk), +KEY col_varchar_key (col_varchar_key) +) ENGINE=MyISAM; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t2 ( +col_int int(11) , +pk int(11) NOT NULL AUTO_INCREMENT, +col_varchar varchar(1) , +col_varchar_key varchar(1) , +PRIMARY KEY (pk) +) ENGINE=MyISAM; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (4,1,'s','r'), (9,19,'p','a'); +CREATE TABLE t3 ( +pk int(11) NOT NULL AUTO_INCREMENT, +col_int int(11) , +col_varchar_key varchar(1) , +col_varchar varchar(1) , +PRIMARY KEY (pk), +KEY col_varchar_key (col_varchar_key) +) ENGINE=MyISAM; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t3 VALUES (100,2,'g',NULL); +EXPLAIN SELECT table1.col_int +FROM t3 AS table1 +LEFT JOIN ( +SELECT subquery1_t1.* +FROM t1 AS subquery1_t1 +RIGHT JOIN t2 AS subquery1_t2 +ON (subquery1_t2.col_varchar_key = subquery1_t1.col_varchar_key) +) AS table3 +ON (table3.col_varchar_key = table1.col_varchar_key) +WHERE table3.col_varchar_key IN ( +SELECT subquery2_t3.col_varchar +FROM t3 AS subquery2_t3 +WHERE subquery2_t3.pk < table3.pk +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'table3.pk' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `col_int` from `test`.`t2` `subquery1_t2` join `test`.`t1` `subquery1_t1` semi join (`test`.`t3` `subquery2_t3`) where ((`test`.`subquery2_t3`.`pk` < NULL) and multiple equal('g', NULL, `test`.`subquery2_t3`.`col_varchar`, `test`.`subquery1_t2`.`col_varchar_key`)) +SELECT table1.col_int +FROM t3 AS table1 +LEFT JOIN ( +SELECT subquery1_t1.* +FROM t1 AS subquery1_t1 +RIGHT JOIN t2 AS subquery1_t2 +ON (subquery1_t2.col_varchar_key = subquery1_t1.col_varchar_key) +) AS table3 +ON (table3.col_varchar_key = table1.col_varchar_key) +WHERE table3.col_varchar_key IN ( +SELECT subquery2_t3.col_varchar +FROM t3 AS subquery2_t3 +WHERE subquery2_t3.pk < table3.pk +); +col_int +DROP TABLE t1, t2, t3; +# +# Bug #26618455: ASSERT 'KEYPARTS > 0' IN CALC_LENGTH_AND_KEYPARTS() +# WITHOUT FIRSTMATCH +# +CREATE TABLE t1 ( +col_int int(11) DEFAULT NULL, +pk int(11) NOT NULL AUTO_INCREMENT, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar varchar(1) DEFAULT NULL, +col_int_key int(11) DEFAULT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +) ENGINE=MyISAM; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (0,1,'i','n',125); +INSERT INTO t1 VALUES (3,20,'b','o',0); +CREATE TABLE t2 ( +col_int_key int(11) DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar varchar(1) DEFAULT NULL, +col_int int(11) DEFAULT NULL, +pk int(11) NOT NULL AUTO_INCREMENT, +PRIMARY KEY (pk), +KEY col_varchar_key (col_varchar_key) +) ENGINE=MyISAM; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (3,'y','p',4,1); +CREATE TABLE t3 ( +col_int int(11) DEFAULT NULL, +col_varchar varchar(1) DEFAULT NULL, +pk int(11) NOT NULL AUTO_INCREMENT, +col_varchar_key varchar(1) DEFAULT NULL, +col_int_key int(11) DEFAULT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +) ENGINE=MyISAM; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t4 ( col_int int(11) DEFAULT NULL, +col_varchar varchar(1) DEFAULT NULL, +col_int_key int(11) DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +pk int(11) NOT NULL AUTO_INCREMENT, +PRIMARY KEY (pk), +KEY col_varchar_key (col_varchar_key) +) ENGINE=MyISAM +; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t4 VALUES (7,'k',9,'z',20); +SET optimizer_switch = 'firstmatch=off'; +EXPLAIN SELECT +table2.col_int_key AS field3 +FROM +( +SELECT subquery2_t2.* +FROM t1 AS subquery2_t1 +INNER JOIN t2 AS subquery2_t2 +ON (subquery2_t2.pk = subquery2_t1.col_int) +) AS table1 +RIGHT OUTER JOIN ( +SELECT subquery3_t1.* +FROM t2 AS subquery3_t1 +) AS table2 +ON (table1.col_varchar_key = table2.col_varchar_key) +WHERE table1.col_varchar_key IN ( +SELECT subquery4_t1.col_varchar AS subquery4_field1 +FROM t3 AS subquery4_t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE subquery3_t1 NULL system col_varchar_key NULL NULL NULL 1 100.00 NULL +1 SIMPLE subquery2_t2 NULL system PRIMARY,col_varchar_key NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL eq_ref 7 const 1 100.00 Using where +1 SIMPLE subquery2_t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +4 MATERIALIZED subquery4_t1 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +Warnings: +Note 1003 /* select#1 */ select '3' AS `field3` from `test`.`t1` `subquery2_t1` semi join (`test`.`t3` `subquery4_t1`) where ((`test`.`subquery2_t1`.`col_int` = '1') and (``.`subquery4_field1` = 'y') and (`test`.`subquery4_t1`.`col_varchar` = 'y')) +SELECT +table2.col_int_key AS field3 +FROM +( +SELECT subquery2_t2.* +FROM t1 AS subquery2_t1 +INNER JOIN t2 AS subquery2_t2 +ON (subquery2_t2.pk = subquery2_t1.col_int) +) AS table1 +RIGHT OUTER JOIN ( +SELECT subquery3_t1.* +FROM t2 AS subquery3_t1 +) AS table2 +ON (table1.col_varchar_key = table2.col_varchar_key) +WHERE table1.col_varchar_key IN ( +SELECT subquery4_t1.col_varchar AS subquery4_field1 +FROM t3 AS subquery4_t1); +field3 +SET optimizer_switch = default; +DROP TABLE t1, t2, t3, t4; +# Bug#26798989: Sig 11 in find_table_in_global_list +CREATE TABLE t1(a INTEGER); +CREATE TABLE t2(a INTEGER); +UPDATE t1 +SET a=5 +WHERE a IN (SELECT a FROM t2 +ORDER BY (SELECT a FROM (SELECT SUM(a) FROM t1) AS dt)); +DROP TABLE t1, t2; +# +# Bug#30381092 WRONG BEHAVIOR OF '=' CONDITION WHEN WORKING WITH COMPLEX SUBQUERIES +# +CREATE TABLE t1 (t1_id INT PRIMARY KEY); +CREATE TABLE t2 (t2_id INT, t1_id INT); +INSERT INTO t1 VALUES (-1), (1); +INSERT INTO t2 SELECT t1_id, t1_id FROM t1; +ANALYZE TABLE t1,t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN SELECT * FROM t2 AS ot +WHERE +( SELECT t1_id AS it1 +FROM ( SELECT * FROM t1 AS it2 +WHERE t1_id = ( SELECT t1_id +FROM ( SELECT * FROM t2 AS it3 +WHERE t2_id=ot.t2_id +) AS dt1 +) +) AS dt2 +) IS NOT NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY ot NULL ALL NULL NULL NULL NULL 2 100.00 Using where +2 DEPENDENT SUBQUERY it2 NULL eq_ref PRIMARY PRIMARY 4 func 1 100.00 Using where; Using index +4 DEPENDENT SUBQUERY it3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1276 Field or reference 'test.ot.t2_id' of SELECT #5 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`ot`.`t2_id` AS `t2_id`,`test`.`ot`.`t1_id` AS `t1_id` from `test`.`t2` `ot` where ((/* select#2 */ select `test`.`it2`.`t1_id` AS `it1` from `test`.`t1` `it2` where (`test`.`it2`.`t1_id` = (/* select#4 */ select `test`.`it3`.`t1_id` from `test`.`t2` `it3` where (`test`.`it3`.`t2_id` = `test`.`ot`.`t2_id`)))) is not null) +SELECT * FROM t2 AS ot +WHERE +( SELECT t1_id AS it1 +FROM ( SELECT * FROM t1 AS it2 +WHERE t1_id = ( SELECT t1_id +FROM ( SELECT * FROM t2 AS it3 +WHERE t2_id=ot.t2_id +) AS dt1 +) +) AS dt2 +) IS NOT NULL; +t2_id t1_id +-1 -1 +1 1 +EXPLAIN SELECT * FROM t2 AS ot +WHERE +( SELECT t1_id AS it1 +FROM ( SELECT * FROM t1 AS it2 +WHERE t1_id = ( SELECT /*+ NO_MERGE() */ t1_id +FROM ( SELECT * FROM t2 AS it3 +WHERE t2_id=ot.t2_id +) AS dt1 +) +) AS dt2 +) IS NOT NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY ot NULL ALL NULL NULL NULL NULL 2 100.00 Using where +2 DEPENDENT SUBQUERY it2 NULL eq_ref PRIMARY PRIMARY 4 func 1 100.00 Using where; Using index +4 DEPENDENT SUBQUERY NULL ALL NULL NULL NULL NULL 2 100.00 NULL +5 DEPENDENT DERIVED it3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1276 Field or reference 'test.ot.t2_id' of SELECT #5 was resolved in SELECT #1 +Note 1003 /* select#1 */ select /*+ NO_MERGE(@`select#4`) */ `test`.`ot`.`t2_id` AS `t2_id`,`test`.`ot`.`t1_id` AS `t1_id` from `test`.`t2` `ot` where ((/* select#2 */ select `test`.`it2`.`t1_id` AS `it1` from `test`.`t1` `it2` where (`test`.`it2`.`t1_id` = (/* select#4 */ select `dt1`.`t1_id` from (/* select#5 */ select `test`.`it3`.`t2_id` AS `t2_id`,`test`.`it3`.`t1_id` AS `t1_id` from `test`.`t2` `it3` where (`test`.`it3`.`t2_id` = `test`.`ot`.`t2_id`)) `dt1`))) is not null) +SELECT * FROM t2 AS ot +WHERE +( SELECT t1_id AS it1 +FROM ( SELECT * FROM t1 AS it2 +WHERE t1_id = ( SELECT /*+ NO_MERGE() */ t1_id +FROM ( SELECT * FROM t2 AS it3 +WHERE t2_id=ot.t2_id +) AS dt1 +) +) AS dt2 +) IS NOT NULL; +t2_id t1_id +-1 -1 +1 1 +DROP TABLE t1,t2; +# Bug#30488700: Mysql chooses different execution plan in 5.7 +CREATE TABLE tbl1 ( +id BIGINT NOT NULL, +rec_id INTEGER NOT NULL, +id_value2 BIGINT DEFAULT NULL, +PRIMARY KEY (id, rec_id) +) ENGINE=INNODB; +CREATE TABLE tbl2 ( +t_id BIGINT NOT NULL, +s_date DATETIME DEFAULT NULL, +PRIMARY KEY (t_id) +) ENGINE=INNODB; +SET @ROWNUM = 0; +SELECT t1.rec_id +FROM tbl1 AS t1 INNER JOIN +(SELECT a.id, a.rec_id,s_date +FROM tbl2 AS b, tbl1 AS a +WHERE a.id_value2 = b.t_id AND a.id = 6889877970355107670 +ORDER BY s_date DESC) t2 +ON t1.id = t2.id AND t1.rec_id = t2.rec_id; +rec_id +UPDATE tbl1 AS t1 INNER JOIN +(SELECT a.id, a.rec_id, b.s_date +FROM tbl2 AS b, tbl1 AS a +WHERE a.id_value2 = b.t_id AND a.id = 6889877970355107670 +ORDER BY s_date DESC) t2 +ON t1.id = t2.id AND t1.rec_id = t2.rec_id +SET t1.rec_id = @ROWNUM:= @ROWNUM+1; +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +explain SELECT t1.rec_id +FROM tbl1 AS t1 INNER JOIN +(SELECT a.id, a.rec_id,s_date +FROM tbl2 AS b, tbl1 AS a +WHERE a.id_value2 = b.t_id AND a.id = 6889877970355107670 +ORDER BY s_date DESC) t2 +ON t1.id = t2.id AND t1.rec_id = t2.rec_id; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref PRIMARY PRIMARY 8 const 1 100.00 Using index +2 SIMPLE a NULL eq_ref PRIMARY PRIMARY 12 const,test.t1.rec_id 1 100.00 Using where +2 SIMPLE b NULL eq_ref PRIMARY PRIMARY 8 test.a.id_value2 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`rec_id` AS `rec_id` from `test`.`tbl1` `t1` join `test`.`tbl2` `b` join `test`.`tbl1` `a` where ((`test`.`b`.`t_id` = `test`.`a`.`id_value2`) and (`test`.`a`.`rec_id` = `test`.`t1`.`rec_id`) and (`test`.`t1`.`id` = 6889877970355107670) and (`test`.`a`.`id` = 6889877970355107670)) +explain UPDATE tbl1 AS t1 INNER JOIN +(SELECT a.id, a.rec_id, b.s_date +FROM tbl2 AS b, tbl1 AS a +WHERE a.id_value2 = b.t_id AND a.id = 6889877970355107670 +ORDER BY s_date DESC) t2 +ON t1.id = t2.id AND t1.rec_id = t2.rec_id +SET t1.rec_id = @ROWNUM:= @ROWNUM+1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL PRIMARY NULL NULL NULL 1 100.00 NULL +1 PRIMARY NULL ref 12 test.t1.id,test.t1.rec_id 2 100.00 NULL +2 DERIVED a NULL ref PRIMARY PRIMARY 8 const 1 100.00 Using where; Using temporary; Using filesort +2 DERIVED b NULL eq_ref PRIMARY PRIMARY 8 test.a.id_value2 1 100.00 NULL +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +Note 1003 update `test`.`tbl1` `t1` join (/* select#2 */ select `test`.`a`.`id` AS `id`,`test`.`a`.`rec_id` AS `rec_id`,`test`.`b`.`s_date` AS `s_date` from `test`.`tbl2` `b` join `test`.`tbl1` `a` where ((`test`.`a`.`id` = 6889877970355107670) and (`test`.`b`.`t_id` = `test`.`a`.`id_value2`)) order by `test`.`b`.`s_date` desc) `t2` set `test`.`t1`.`rec_id` = (@ROWNUM:=((@`ROWNUM`) + 1)) where ((`t2`.`rec_id` = `test`.`t1`.`rec_id`) and (`t2`.`id` = `test`.`t1`.`id`)) +DROP TABLE tbl1, tbl2; +# Bug#26542829: Assertion !(check_datetime_range(ltime)) failed +CREATE TABLE t1 ( +c1 varchar(10) DEFAULT NULL, +c2 datetime DEFAULT NULL, +c3 varchar(255) DEFAULT NULL, +c4 varchar(255) DEFAULT NULL, +pk int NOT NULL, +c5 varchar(255) DEFAULT NULL, +c6 date DEFAULT NULL, +c7 int DEFAULT NULL, +c8 date DEFAULT NULL, +c9 varchar(255) DEFAULT NULL, +c10 int DEFAULT NULL, +c11 varchar(10) DEFAULT NULL, +c12 varchar(10) DEFAULT NULL, +c13 datetime DEFAULT NULL, +PRIMARY KEY (pk), +KEY k5 (c5) +) engine=innodb; +INSERT INTO t1 VALUES +('gjnhugwevl','1000-01-01 00:00:00','m','UJVFB',2,'j','1000-01-01',208797696,'1000-01-01','LRNWI',NULL,'look','ISVAL','2001-03-02 00:00:00'), +('nhugwevltb','1000-01-01 00:00:00','m','h',3,'can\'t','2004-06-07',2052784128,'2000-12-19','r',NULL,'ugwevltbgy','something','1000-01-01 00:00:00'); +CREATE TABLE t2 ( +c1 varchar(255) DEFAULT NULL, +c2 varchar(10) DEFAULT NULL, +c3 int DEFAULT NULL, +c4 datetime DEFAULT NULL, +c5 varchar(10) DEFAULT NULL, +c6 varchar(255) DEFAULT NULL, +c7 varchar(255) DEFAULT NULL, +c8 varchar(255) DEFAULT NULL, +c9 varchar(10) DEFAULT NULL, +c10 datetime DEFAULT NULL, +pk int NOT NULL, +c11 date DEFAULT NULL, +c12 int DEFAULT NULL, +PRIMARY KEY (pk) +) engine=innodb; +INSERT INTO t2 VALUES +('be','njhqcbglns',NULL,'2002-07-20 19:40:02','YHBGN','go','NSPET','j','MKFNT','2007-08-25 14:41:26',1,'2002-04-21',6), +('b','glnspcqnog',2,'1000-01-01 00:00:00','YEJTV','on','z','PPPCH','YRXFT','1000-01-01 00:00:00',4,'2003-07-25',0), +('c','qnogpabsxs',6,'1000-01-01 00:00:00','nogpabsxsr','b','we','og','e','2000-11-01 15:48:07',7,'1000-01-01',3), +('OFZJT','was',6,'2007-01-14 21:01:33','as','was','r','a','but','2009-01-20 17:58:56',9,'2005-02-14',7), +('d','bsxsrumtna',9,'1000-01-01 00:00:00','would','he','o','VESLR','sxsrumtnab','2007-09-25 12:13:37',10,'2005-02-11',772472832); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +SELECT field1 +FROM (SELECT alias1.c5 AS field1, +alias1.c13 AS field2, +alias1.c1 AS field4 +FROM t1 AS alias1 RIGHT JOIN t2 AS alias2 +ON alias1.pk = alias2.c12 +ORDER BY field2 +) as dt; +field1 +NULL +NULL +NULL +NULL +can't +SELECT field1 +FROM (SELECT * +FROM (SELECT alias1.c5 AS field1, +alias1.c13 AS field2, +alias1.c1 AS field4 +FROM t1 AS alias1 RIGHT JOIN t2 AS alias2 +ON alias1.pk = alias2.c12 +ORDER BY field2 +) AS dt_inner +) AS dt_outer; +field1 +NULL +NULL +NULL +NULL +can't +DROP TABLE t1, t2; +# Bug#26808862: Execution of prepared statement with ORDER BY +# in derived table may fail +CREATE TABLE t1 ( +pk INTEGER NOT NULL, +c1 INTEGER DEFAULT NULL, +c2 INTEGER DEFAULT NULL, +PRIMARY KEY (pk) +); +CREATE TABLE t2 ( +c1 integer DEFAULT NULL +); +prepare s from " +SELECT field1 +FROM (SELECT alias1.c1 AS field1, + alias1.c2 AS field2 + FROM t1 AS alias1 RIGHT JOIN t2 AS alias2 + ON alias1.pk = alias2.c1 + ORDER BY field2) as dt"; +execute s; +field1 +execute s; +field1 +DROP TABLE t1, t2; +# Bug#31565009: Simplification of condition when seeing false and +# leaks tmp tables opened +CREATE TABLE t1 (i int); +SELECT t1.i +FROM t1 +WHERE FALSE AND +t1.i > (SELECT MAX(a) +FROM (SELECT 8 AS a UNION SELECT 3) AS tt); +i +DROP TABLE t1; +# Bug#31401637: Asan heap-buffer-overflow Handler::index_only_read_time +CREATE TABLE t( +w INTEGER NOT NULL, +h INTEGER NOT NULL, +u SMALLINT NOT NULL, +PRIMARY KEY (u) +); +INSERT INTO t VALUES(1,2,3),(3,4,5),(6,6,7); +PREPARE s FROM " +SELECT dtaa.c AS c +FROM (SELECT 1 AS c + FROM (SELECT 1 AS c + FROM t AS ta RIGHT JOIN t AS tb ON ta.u <= ? + WHERE 1 OR ? + GROUP BY ta.u + ) AS dta + INNER JOIN t AS tbb + ON dta.c = tbb.h + ) AS dtaa + RIGHT JOIN t AS tbbb + ON dtaa.c or w"; +SET @a:='77777'; +EXECUTE s USING @a,@a; +c +NULL +NULL +NULL +SET @a:='-77777'; +EXECUTE s USING @a,@a; +c +NULL +NULL +NULL +DEALLOCATE PREPARE s; +DROP TABLE t; +# +# Bug #32162862: ORDER BY SUB-SELECT COLUMN SETS ALL VALUES TO NULL +# +CREATE TABLE t1 ( a INTEGER ) Engine=InnoDB; +INSERT INTO t1 VALUES (123); +SELECT * FROM t1 LEFT JOIN ( SELECT 1 FROM t1 ) d1 ON TRUE ORDER BY a; +a 1 +123 1 +DROP TABLE t1; +# +# Bug #32164724: HYPERGRAPH: ASSERTION `PATH->COST >= PATH->INIT_COST' FAILED. +# +CREATE TABLE t1 (a INTEGER); +INSERT INTO t1 VALUES (1); +SET sql_mode=""; +SELECT ( +SELECT 1 FROM ( +SELECT avg(1) FROM t1 +WHERE dayofyear(1) AND max(1) +) d1 +GROUP BY a +) FROM t1; +( +SELECT 1 FROM ( +SELECT avg(1) FROM t1 +WHERE dayofyear(1) AND max(1) +) d1 +GROUP BY a +) +1 +Warnings: +Warning 1292 Incorrect datetime value: '1' +SET sql_mode=DEFAULT; +DROP TABLE t1; +# +# Bug #32169846: HYPERGRAPH: ASSERTION `M_OPENED_TABLE != NULLPTR' FAILED. +# +CREATE TABLE t1 (a LONGTEXT); +INSERT INTO t1 VALUES (''); +CREATE TABLE t2 (b INTEGER); +INSERT INTO t2 VALUES (0); +SELECT 1 FROM t2, ( +SELECT a, rand() FROM t1 GROUP BY a +) d1 +GROUP BY b; +1 +1 +DROP TABLE t1, t2; diff --git a/mysql-test/r/derived_correlated.result-pq b/mysql-test/r/derived_correlated.result-pq new file mode 100644 index 000000000000..fe04c1a0f179 --- /dev/null +++ b/mysql-test/r/derived_correlated.result-pq @@ -0,0 +1,3447 @@ +set optimizer_trace_max_mem_size=10000000,@@session.optimizer_trace="enabled=on"; +# WL#461: allow outer references in derived tables and CTEs +create table t1(a int, b int); +insert into t1 (a) values(1),(2); +create table t2 select * from t1; +analyze table t1,t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +set optimizer_switch='derived_merge=on'; +# Deep nesting: all intermediate subqueries are marked DEPENDENT +explain select * from t1 where +(select count(*) from (select * from (select * from t1 t2 +where 2=(select 2 from (select t1.a) dt1))dt3)dt4); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +5 DEPENDENT SUBQUERY NULL ALL NULL NULL NULL NULL 2 100.00 NULL +6 DEPENDENT DERIVED NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #6 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (0 <> (/* select#2 */ select count(0) from `test`.`t1` `t2` where (2 = (/* select#5 */ select 2 from (/* select#6 */ select `test`.`t1`.`a` AS `a`) `dt1`)))) +select * from t1 where +(select count(*) from (select * from (select * from t1 t2 +where 2=(select 2 from (select t1.a) dt1))dt3)dt4); +a b +1 NULL +2 NULL +# If reference is removed, not DEPENDENT +explain select * from t1 where +(select count(*) from (select * from (select * from t1 t2 +where 2=(select 2 from (select 42) dt1))dt3)dt4); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 SUBQUERY t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +5 SUBQUERY NULL system NULL NULL NULL NULL 1 100.00 NULL +6 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where true +select * from t1 where +(select count(*) from (select * from (select * from t1 t2 +where 2=(select 2 from (select 42) dt1))dt3)dt4); +a b +1 NULL +2 NULL +# Outer ref is in SELECT list of derived table's definition +explain select +(select dt.a from +(select t1.a as a, t2.a as b from t2) dt where dt.b=t1.a) +as subq +from t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #3 was resolved in SELECT #1 +Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select (/* select#2 */ select `test`.`t1`.`a` from `test`.`t2` where (`test`.`t2`.`a` = `test`.`t1`.`a`)) AS `subq` from `test`.`t1` +select +(select dt.a from +(select t1.a as a, t2.a as b from t2) dt where dt.b=t1.a) +as subq +from t1; +subq +1 +2 +# In WHERE +explain select +(select dt.b from +(select t2.a as b from t2 where t1.a=t2.a) dt) +as subq +from t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select (/* select#2 */ select `test`.`t2`.`a` from `test`.`t2` where (`test`.`t1`.`a` = `test`.`t2`.`a`)) AS `subq` from `test`.`t1` +select +(select dt.b from +(select t2.a as b from t2 where t1.a=t2.a) dt) +as subq +from t1; +subq +1 +2 +# In GROUP BY +explain select +(select dt.b from +(select sum(t2.a) as b from t2 group by t1.a) dt) +as subq +from t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DEPENDENT SUBQUERY NULL ALL NULL NULL NULL NULL 2 100.00 NULL +3 DEPENDENT DERIVED t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using temporary +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select (/* select#2 */ select `dt`.`b` from (/* select#3 */ select sum(`test`.`t2`.`a`) AS `b` from `test`.`t2` group by `test`.`t1`.`a`) `dt`) AS `subq` from `test`.`t1` +select +(select dt.b from +(select sum(t2.a) as b from t2 group by t1.a) dt) +as subq +from t1; +subq +3 +3 +# In HAVING +explain select +(select dt.b from +(select sum(t2.a) as b from t2 having t1.a=sum(t2.a)-1) dt) +as subq +from t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DEPENDENT SUBQUERY NULL ALL NULL NULL NULL NULL 2 100.00 NULL +3 DEPENDENT DERIVED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1276 Field or reference 't1.a' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select (/* select#2 */ select `dt`.`b` from (/* select#3 */ select sum(`test`.`t2`.`a`) AS `b` from `test`.`t2` having (`test`.`t1`.`a` = (sum(`test`.`t2`.`a`) - 1))) `dt`) AS `subq` from `test`.`t1` +select +(select dt.b from +(select sum(t2.a) as b from t2 having t1.a=sum(t2.a)-1) dt) +as subq +from t1; +subq +NULL +3 +explain select +(select dt.b from +(select sum(t2.a) as b from t2 having t1.a=sum(t2.a)-2) dt) +as subq +from t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DEPENDENT SUBQUERY NULL ALL NULL NULL NULL NULL 2 100.00 NULL +3 DEPENDENT DERIVED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1276 Field or reference 't1.a' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select (/* select#2 */ select `dt`.`b` from (/* select#3 */ select sum(`test`.`t2`.`a`) AS `b` from `test`.`t2` having (`test`.`t1`.`a` = (sum(`test`.`t2`.`a`) - 2))) `dt`) AS `subq` from `test`.`t1` +select +(select dt.b from +(select sum(t2.a) as b from t2 having t1.a=sum(t2.a)-2) dt) +as subq +from t1; +subq +3 +NULL +# In ORDER BY +explain select +(select dt.b from +(select t2.a as b from t2 order by if(t1.a=1,t2.a,-t2.a) limit 1) dt) +as subq +from t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DEPENDENT SUBQUERY NULL ALL NULL NULL NULL NULL 2 100.00 NULL +3 DEPENDENT DERIVED t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using temporary; Using filesort +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select (/* select#2 */ select `dt`.`b` from (/* select#3 */ select `test`.`t2`.`a` AS `b` from `test`.`t2` order by if((`test`.`t1`.`a` = 1),`test`.`t2`.`a`,-(`test`.`t2`.`a`)) limit 1) `dt`) AS `subq` from `test`.`t1` +select +(select dt.b from +(select t2.a as b from t2 order by if(t1.a=1,t2.a,-t2.a) limit 1) dt) +as subq +from t1; +subq +1 +2 +# In window functions +explain select +(select dt.b from +(select t2.a, sum(t1.a*10+t2.a) over (order by if(t1.a=1,t2.a,-t2.a)) as b +from t2) dt where dt.a=1) +as subq +from t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DEPENDENT SUBQUERY NULL ref 5 const 1 100.00 NULL +3 DEPENDENT DERIVED t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using filesort +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #3 was resolved in SELECT #1 +Note 1276 Field or reference 'test.t1.a' of SELECT #3 was resolved in SELECT #1 +Note 3598 To get information about window functions use EXPLAIN FORMAT=JSON +Note 1003 /* select#1 */ select (/* select#2 */ select `dt`.`b` from (/* select#3 */ select `test`.`t2`.`a` AS `a`,sum(((`test`.`t1`.`a` * 10) + `test`.`t2`.`a`)) OVER (ORDER BY if((`test`.`t1`.`a` = 1),`test`.`t2`.`a`,-(`test`.`t2`.`a`)) ) AS `b` from `test`.`t2`) `dt` where (`dt`.`a` = 1)) AS `subq` from `test`.`t1` +select +(select dt.b from +(select t2.a, sum(t1.a*10+t2.a) over (order by if(t1.a=1,t2.a,-t2.a)) as b +from t2) dt where dt.a=1) +as subq +from t1; +subq +11 +43 +# CTE referenced twice +explain select +(with dt as (select t1.a as a, t2.a as b from t2) +select dt2.a from dt dt1, dt dt2 where dt1.b=t1.a and dt2.b=dt1.b) +as subq +from t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #3 was resolved in SELECT #1 +Note 1276 Field or reference 'test.t1.a' of SELECT #4 was resolved in SELECT #1 +Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select (/* select#2 */ select `test`.`t1`.`a` from `test`.`t2` join `test`.`t2` where ((`test`.`t2`.`a` = `test`.`t2`.`a`) and (`test`.`t2`.`a` = `test`.`t1`.`a`))) AS `subq` from `test`.`t1` +select +(with dt as (select t1.a as a, t2.a as b from t2) +select dt2.a from dt dt1, dt dt2 where dt1.b=t1.a and dt2.b=dt1.b) +as subq +from t1; +subq +1 +2 +Recursive CTE +select +(with recursive dt as +(select t1.a as a union select a+1 from dt where a<10) +select dt1.a from dt dt1 where dt1.a=t1.a +) as subq +from t1; +subq +1 +2 +select +(with recursive dt as +(select t1.a as a union select a+1 from dt where a<10) +select concat(count(*), ' - ', avg(dt.a)) from dt +) as subq +from t1; +subq +10 - 5.5000 +9 - 6.0000 +select +(with recursive dt as +(select t1.a as a union all select a+1 from dt where a<10) +select concat(count(*), ' - ', avg(dt.a)) from dt +) as subq +from t1; +subq +10 - 5.5000 +9 - 6.0000 +select +(with dt as (select t1.a as a, t2.a as b from t2) +select dt2.a from dt dt1, dt dt2 where dt1.b=t1.a and dt2.b=dt1.b) +as subq +from t1; +subq +1 +2 +# Two references to same CTE at different levels of nesting. +explain select (with dt as (select t1.a as a from t2 limit 1) select * from dt dt1 where dt1.a=(select * from dt as dt2)) as subq from t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DEPENDENT SUBQUERY NULL ref 5 func 2 100.00 Using where; Using index +4 DEPENDENT SUBQUERY NULL ALL NULL NULL NULL NULL 2 100.00 NULL +3 DEPENDENT DERIVED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #3 was resolved in SELECT #1 +Note 1276 Field or reference 'test.t1.a' of SELECT #5 was resolved in SELECT #1 +Note 1003 /* select#1 */ select (with `dt` as (/* select#3 */ select `test`.`t1`.`a` AS `a` from `test`.`t2` limit 1) /* select#2 */ select `dt1`.`a` from `dt` `dt1` where (`dt1`.`a` = (/* select#4 */ select `dt2`.`a` from `dt` `dt2`))) AS `subq` from `test`.`t1` +explain format=tree select (with dt as (select t1.a as a from t2 limit 1) select * from dt dt1 where dt1.a=(select * from dt as dt2)) as subq from t1; +EXPLAIN +-> Table scan on t1 (cost=0.45 rows=2) +-> Select #2 (subquery in projection; dependent) + -> Filter: (dt1.a = (select #4)) (cost=0.62..0.70 rows=2) + -> Index lookup on dt1 using (a=(select #4)) + -> Materialize CTE dt if needed (cost=0.55..0.55 rows=1) + -> Limit: 1 row(s) (cost=0.45 rows=1) + -> Table scan on t2 (cost=0.45 rows=2) + -> Select #4 (subquery in condition; dependent) + -> Table scan on dt2 (cost=2.51..2.51 rows=1) + -> Materialize CTE dt if needed (query plan printed elsewhere) (cost=3.06..3.06 rows=1) + +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #3 was resolved in SELECT #1 +Note 1276 Field or reference 'test.t1.a' of SELECT #5 was resolved in SELECT #1 +select (with dt as (select t1.a as a from t2 limit 1) select * from dt dt1 where dt1.a=(select * from dt as dt2)) as subq from t1; +subq +1 +2 +explain select (with dt as (select t2.a as a from t2 having t1.a=t2.a limit 1) select * from dt dt1 where dt1.a=(select * from dt as dt2)) as subq from t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DEPENDENT SUBQUERY NULL ref 5 func 2 100.00 Using where; Using index +4 DEPENDENT SUBQUERY NULL ALL NULL NULL NULL NULL 2 100.00 NULL +3 DEPENDENT DERIVED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1276 Field or reference 't1.a' of SELECT #3 was resolved in SELECT #1 +Note 1276 Field or reference 't1.a' of SELECT #5 was resolved in SELECT #1 +Note 1003 /* select#1 */ select (with `dt` as (/* select#3 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` having (`test`.`t1`.`a` = `test`.`t2`.`a`) limit 1) /* select#2 */ select `dt1`.`a` from `dt` `dt1` where (`dt1`.`a` = (/* select#4 */ select `dt2`.`a` from `dt` `dt2`))) AS `subq` from `test`.`t1` +select (with dt as (select t2.a as a from t2 having t1.a=t2.a limit 1) select * from dt dt1 where dt1.a=(select * from dt as dt2)) as subq from t1; +subq +1 +2 +# Scope of outer ref in CTE +select (select * from (select t1.a) cte) from t1; +(select * from (select t1.a) cte) +1 +2 +select (with cte as (select t1.a) select * from cte) from t1; +(with cte as (select t1.a) select * from cte) +1 +2 +with cte as (select t1.a) select (select * from cte) from t1; +ERROR 42S02: Unknown table 't1' in field list +# NOT IN(subquery using derived), handled with subquery materialization +explain select * from t1 +where a not in (select dt.f+1 from (select t2.a as f from t2) dt); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (`test`.`t1`.`a`,(/* select#2 */ select (`test`.`t2`.`a` + 1) from `test`.`t2` where (outer_field_is_not_null, (((`test`.`t1`.`a`) = (`test`.`t2`.`a` + 1)) or ((`test`.`t2`.`a` + 1) is null)), true) having (outer_field_is_not_null, ((`test`.`t2`.`a` + 1)), true)) is false) +select * from t1 +where a not in (select dt.f+1 from (select t2.a as f from t2) dt); +a b +1 NULL +# Now put an outer reference inside derived table: +# subquery is properly seen as correlated and subquery +# materialization is thus not used. +explain select * from t1 +where a not in (select dt.f+1 from (select 0*t1.a+t2.a as f from t2) dt); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (`test`.`t1`.`a`,(/* select#2 */ select (((0 * `test`.`t1`.`a`) + `test`.`t2`.`a`) + 1) from `test`.`t2` where (outer_field_is_not_null, (((`test`.`t1`.`a`) = (((0 * `test`.`t1`.`a`) + `test`.`t2`.`a`) + 1)) or ((((0 * `test`.`t1`.`a`) + `test`.`t2`.`a`) + 1) is null)), true) having (outer_field_is_not_null, ((((0 * `test`.`t1`.`a`) + `test`.`t2`.`a`) + 1)), true)) is false) +select * from t1 +where a not in (select dt.f+1 from (select 0*t1.a+t2.a as f from t2) dt); +a b +1 NULL +# Verify that a non-lateral derived table with an outer +# reference makes the semijoin be correlated and thus blocks +# semijoin-materialization-scan. +create table t11 (a int); +insert into t11 +with recursive cte as (select 1 as a union all select a+1 from cte where a<124) +select * from cte; +alter table t11 add index(a); +create table t12 like t11; +analyze table t11,t12; +Table Op Msg_type Msg_text +test.t11 analyze status OK +test.t12 analyze status OK +# No outer ref: mat-scan chosen +explain select +/*+ NO_SEMIJOIN(@subq1 FIRSTMATCH, LOOSESCAN, DUPSWEEDOUT) */ +* from t11 where a in (select /*+ QB_NAME(subq1) NO_MERGE(dt) */ * +from (select t12.a from t12) dt); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL NULL 100.00 Using where +1 PRIMARY t11 NULL ref a a 5 .a 1 100.00 Using index +2 MATERIALIZED NULL ALL NULL NULL NULL NULL 2 100.00 NULL +3 DERIVED t12 NULL index NULL a 5 NULL 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select /*+ NO_SEMIJOIN(@`subq1` FIRSTMATCH, LOOSESCAN, DUPSWEEDOUT) NO_MERGE(`dt`@`subq1`) */ `test`.`t11`.`a` AS `a` from `test`.`t11` semi join ((/* select#3 */ select `test`.`t12`.`a` AS `a` from `test`.`t12`) `dt`) where (`test`.`t11`.`a` = ``.`a`) +# outer ref: mat-scan not chosen +explain select +/*+ NO_SEMIJOIN(@subq1 FIRSTMATCH, LOOSESCAN, DUPSWEEDOUT) */ +* from t11 where a in (select /*+ QB_NAME(subq1) NO_MERGE(dt) */ * +from (select t12.a+0*t11.a from t12) dt); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t11 NULL index a a 5 NULL 124 100.00 Using where; Using index; Rematerialize () +1 PRIMARY NULL ref 9 test.t11.a 2 100.00 Using where; Using index; Start temporary; End temporary +3 DEPENDENT DERIVED t12 NULL index NULL a 5 NULL 1 100.00 Using index +Warnings: +Note 1276 Field or reference 'test.t11.a' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select /*+ NO_SEMIJOIN(@`subq1` FIRSTMATCH, LOOSESCAN, DUPSWEEDOUT) NO_MERGE(`dt`@`subq1`) */ `test`.`t11`.`a` AS `a` from `test`.`t11` semi join (lateral (/* select#3 */ select (`test`.`t12`.`a` + (0 * `test`.`t11`.`a`)) AS `t12.a+0*t11.a` from `test`.`t12`) `dt`) where (`test`.`t11`.`a` = `dt`.`t12.a+0*t11.a`) +DROP TABLE t11,t12; +LATERAL +# prevents join buffer if materialized (but not if merged) +explain select dt.a from t1, lateral (select t1.a from t2) dt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` join `test`.`t2` +# no right join +explain select dt.a from t1 right join lateral (select t1.a from t2) dt on 1; +ERROR 42S22: Unknown column 't1.a' in 'field list' +# no bad left join either +explain select dt.a from lateral (select t1.a from t2) dt left join t1 on 1; +ERROR 42S22: Unknown column 't1.a' in 'field list' +# more complex case +explain SELECT * FROM t1 +LEFT JOIN +lateral (select t1.a) as dt ON t1.a=dt.a +RIGHT JOIN +lateral (select dt.a) as dt1 ON dt.a=dt1.a; +ERROR 42S22: Unknown column 'dt.a' in 'field list' +# LATERAL DT depending on LATERAL DT +explain SELECT * FROM t1 +JOIN +lateral (select t1.a) as dt ON t1.a=dt.a +JOIN +lateral (select dt.a) as dt1 ON dt.a=dt1.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Rematerialize () +1 PRIMARY NULL ref 5 test.t1.a 2 100.00 Using index; Rematerialize () +1 PRIMARY NULL ref 5 test.t1.a 2 100.00 Using index +3 DEPENDENT DERIVED NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +2 DEPENDENT DERIVED NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 +Note 1276 Field or reference 'dt.a' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`dt`.`a` AS `a`,`dt1`.`a` AS `a` from `test`.`t1` join lateral (/* select#2 */ select `test`.`t1`.`a` AS `a`) `dt` join lateral (/* select#3 */ select `dt`.`a` AS `a`) `dt1` where ((`dt`.`a` = `test`.`t1`.`a`) and (`dt1`.`a` = `test`.`t1`.`a`)) +# Placing lateral outer ref in SELECT list then HAVING +select t1.a, dt.a from t1, lateral (select t1.a+t2.a as a from t2) dt; +a a +1 2 +1 3 +2 3 +2 4 +select t1.a, dt.a from t1, lateral (select t2.a as a from t2 having t1.a) dt; +a a +1 1 +1 2 +2 1 +2 2 +# Inside view +create view v1 as +select t1.a as f1, dt.a as f2 +from t1, lateral (select t1.a+t2.a as a from t2) dt; +show create view v1; +View Create View character_set_client collation_connection +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`a` AS `f1`,`dt`.`a` AS `f2` from (`t1` join lateral (select (`t1`.`a` + `t2`.`a`) AS `a` from `t2`) `dt`) utf8mb4 utf8mb4_0900_ai_ci +select * from v1; +f1 f2 +1 2 +1 3 +2 3 +2 4 +drop view v1; +# Coverage for various branches in Item_ref::fix_fields +SELECT COUNT(*) FROM t1 GROUP BY t1.a HAVING t1.a IN (SELECT t3.a +FROM t1 AS t3 WHERE t3.b IN (SELECT b FROM t2, lateral (select t1.a) dt)); +COUNT(*) +create view v1 as select a, b from t1; +select vq1.b,dt.b from v1 vq1, lateral (select vq1.b) dt; +b b +NULL NULL +NULL NULL +select b from v1 vq1, lateral (select count(*) from v1 vq2 having vq1.b = 3) dt; +b +drop view v1; +SELECT +/*+ SET_VAR(optimizer_switch = 'materialization=off,semijoin=off') */ +* FROM t1 AS ta, lateral (select 1 WHERE ta.a IN (SELECT b FROM t2 AS tb WHERE tb.b >= SOME(SELECT SUM(tc.a) as sg FROM t1 as tc GROUP BY tc.b HAVING ta.a=tc.b))) dt; +a b 1 +select (select dt.a from (select 1 as a, t2.a as b from t2 having +t1.a) dt where dt.b=t1.a) as subq from t1; +subq +1 +1 +select (select dt.a from (select 1 as a, 3 as b from t2 having t1.a) +dt where dt.b=t1.a) as subq from t1; +subq +NULL +NULL +# Aggregation in outer context +select (select f from (select max(t1.a) as f) as dt) as g from t1; +g +2 +select (select f from lateral (select max(t1.a) as f) as dt) as g from t1; +g +2 +# LATERAL doesn't allow an aggregate to resolve to the +# immediate parent (because reading of FROM tables happens +# before aggregation). So it resolves in the derived table, so +# the outer query doesn't produce a single-row result. +select t1.a, f from t1, lateral (select max(t1.a) as f) as dt; +a f +1 1 +2 2 +# We support CTE inside derived table +select * from t1, +lateral (with qn as (select t1.a) select (select max(a) from qn)) as dt; +a b (select max(a) from qn) +1 NULL 1 +2 NULL 2 +# Coverage for crash in Item_ident::fix_after_pullout: +# when we merge a derived table contained in a derived table, +# and the merged one contains an outer ref to the top query. +select (select * from (select * from (select t1.a from t2) as dt limit 1) dt2) from t1; +(select * from (select * from (select t1.a from t2) as dt limit 1) dt2) +1 +2 +# Semijoin containing a correlated derived table, DT must +# become LATERAL +explain select a from t1 where a in (select a from (select t1.a) dt); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Rematerialize () +1 PRIMARY NULL ref 5 test.t1.a 2 100.00 Using index; FirstMatch(t1) +3 DEPENDENT DERIVED NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (lateral (/* select#3 */ select `test`.`t1`.`a` AS `a`) `dt`) where (`dt`.`a` = `test`.`t1`.`a`) +select a from t1 where a in (select a from (select t1.a) dt); +a +1 +2 +create table t3 as with recursive cte as (select 1 as a union select a+1 from cte where a<20) select * from cte; +analyze table t3; +Table Op Msg_type Msg_text +test.t3 analyze status OK +explain select min(a),max(a) from t3 where a in (select /*+ no_merge() */ a from (select t3.a from t1) dt); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t3 NULL ALL NULL NULL NULL NULL 20 100.00 Using where; Rematerialize () +1 PRIMARY NULL ref 9 test.t3.a 2 100.00 Using index; FirstMatch(t3) +3 DEPENDENT DERIVED t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1276 Field or reference 'test.t3.a' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select /*+ NO_MERGE(@`select#2`) */ min(`test`.`t3`.`a`) AS `min(a)`,max(`test`.`t3`.`a`) AS `max(a)` from `test`.`t3` semi join (lateral (/* select#3 */ select `test`.`t3`.`a` AS `a` from `test`.`t1`) `dt`) where (`dt`.`a` = `test`.`t3`.`a`) +select min(a),max(a) from t3 where a in (select /*+ no_merge() */ a from (select t3.a from t1) dt); +min(a) max(a) +1 20 +drop table t3; +# DT containing a correlated DT which must become LATERAL +explain format=tree select * from t1, lateral (select * from (select * from (select t1.a from t2) as dt limit 1) dt2) dt3; +EXPLAIN +-> Nested loop inner join (cost=6.35 rows=2) + -> Invalidate materialized tables (row from t1) (cost=0.45 rows=2) + -> Table scan on t1 (cost=0.45 rows=2) + -> Table scan on dt2 (cost=2.51..2.51 rows=1) + -> Materialize (invalidate on row from t1) (cost=3.06..3.06 rows=1) + -> Limit: 1 row(s) (cost=0.45 rows=1) + -> Table scan on t2 (cost=0.45 rows=2) + +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #4 was resolved in SELECT #1 +explain select * from t1, lateral (select * from (select * from (select t1.a from t2) as dt limit 1) dt2) dt3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 2 100.00 Rematerialize () +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 NULL +3 DEPENDENT DERIVED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #4 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`dt2`.`a` AS `a` from `test`.`t1` join lateral (/* select#3 */ select `test`.`t1`.`a` AS `a` from `test`.`t2` limit 1) `dt2` +select * from t1, lateral (select * from (select * from (select t1.a from t2) as dt limit 1) dt2) dt3; +a b a +1 NULL 1 +2 NULL 2 +explain select * from t1 as t0, +lateral +(select dt3.* from t1, lateral (select * from (select * from (select t0.a +from t2) as dt limit 1) dt2) dt3) dt4; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t0 NULL ALL NULL NULL NULL NULL 2 100.00 Rematerialize () +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 NULL +4 DEPENDENT DERIVED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1276 Field or reference 'test.t0.a' of SELECT #5 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a`,`test`.`t0`.`b` AS `b`,`dt2`.`a` AS `a` from `test`.`t1` `t0` join `test`.`t1` join lateral (/* select#4 */ select `test`.`t0`.`a` AS `a` from `test`.`t2` limit 1) `dt2` +select * from t1 as t0, +lateral +(select dt3.* from t1, lateral (select * from (select * from (select t0.a +from t2) as dt limit 1) dt2) dt3) dt4; +a b a +1 NULL 1 +1 NULL 1 +2 NULL 2 +2 NULL 2 +explain select /*+ no_merge() */ * from t1 as t0, +lateral +(select dt3.* from t1, lateral (select * from (select * from (select t0.a +from t2) as dt limit 1) dt2) dt3) dt4; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t0 NULL ALL NULL NULL NULL NULL 2 100.00 Rematerialize () +1 PRIMARY NULL ALL NULL NULL NULL NULL 4 100.00 NULL +2 DEPENDENT DERIVED t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DEPENDENT DERIVED NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +4 DEPENDENT DERIVED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1276 Field or reference 'test.t0.a' of SELECT #5 was resolved in SELECT #1 +Note 1003 /* select#1 */ select /*+ NO_MERGE(@`select#1`) */ `test`.`t0`.`a` AS `a`,`test`.`t0`.`b` AS `b`,`dt4`.`a` AS `a` from `test`.`t1` `t0` join lateral (/* select#2 */ select `dt2`.`a` AS `a` from `test`.`t1` join (/* select#4 */ select `test`.`t0`.`a` AS `a` from `test`.`t2` limit 1) `dt2`) `dt4` +select /*+ no_merge() */ * from t1 as t0, +lateral +(select dt3.* from t1, lateral (select * from (select * from (select t0.a +from t2) as dt limit 1) dt2) dt3) dt4; +a b a +1 NULL 1 +1 NULL 1 +2 NULL 2 +2 NULL 2 +explain select * from t1, lateral (select * from (select 42) t1, (select t1.a) dt2) dt3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL system NULL NULL NULL NULL 1 100.00 NULL +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 2 100.00 Rematerialize () +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 NULL +4 DEPENDENT DERIVED NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +3 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #4 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,'42' AS `42`,`dt2`.`a` AS `a` from `test`.`t1` join lateral (/* select#4 */ select `test`.`t1`.`a` AS `a`) `dt2` +select * from t1, lateral (select * from (select 42) t1, (select t1.a) dt2) dt3; +a b 42 a +1 NULL 42 1 +2 NULL 42 2 +without semijoin: index_subquery needs to re-materialize +explain select a from t1 where a in (select /*+ no_semijoin() */ a from (select t1.a) dt); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +2 DEPENDENT SUBQUERY NULL index_subquery 5 func 2 100.00 Using index +3 DEPENDENT DERIVED NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select /*+ NO_SEMIJOIN(@`select#2`) */ `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a`,(((`test`.`t1`.`a`) in dt on ))) +select a from t1 where a in (select /*+ no_semijoin() */ a from (select t1.a) dt); +a +1 +2 +select a from t1 where a in (with cte as (select t1.a) +select /*+ no_semijoin() */ a from cte); +a +1 +2 +# Count rematerializations +# In all three plans, handler_write is 2, showing that we +# rematerialize only when necessary (when row of t1 changes) +explain select straight_join * from t1, t2, lateral (select t1.a) as dt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 2 100.00 Rematerialize () +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DEPENDENT DERIVED NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select straight_join `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`dt`.`a` AS `a` from `test`.`t1` join `test`.`t2` join lateral (/* select#2 */ select `test`.`t1`.`a` AS `a`) `dt` +flush status; +select straight_join * from t1, t2, lateral (select t1.a) as dt; +a b a b a +1 NULL 1 NULL 1 +1 NULL 2 NULL 1 +2 NULL 1 NULL 2 +2 NULL 2 NULL 2 +# when a row of t1 produces two rows of t2 passed to "dt", +# it still makes one materialization. +show status like "handler_write"; +Variable_name Value +Handler_write 2 +explain select straight_join * from t1, lateral (select t1.a) as dt, t2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 2 100.00 Rematerialize () +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +2 DEPENDENT DERIVED NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select straight_join `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`dt`.`a` AS `a`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` join lateral (/* select#2 */ select `test`.`t1`.`a` AS `a`) `dt` join `test`.`t2` +flush status; +select straight_join * from t1, lateral (select t1.a) as dt, t2; +a b a a b +1 NULL 1 1 NULL +1 NULL 1 2 NULL +2 NULL 2 1 NULL +2 NULL 2 2 NULL +show status like "handler_write"; +Variable_name Value +Handler_write 2 +explain select straight_join * from t2, t1, lateral (select t1.a) as dt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 2 100.00 Rematerialize (); Using join buffer (hash join) +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DEPENDENT DERIVED NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select straight_join `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`dt`.`a` AS `a` from `test`.`t2` join `test`.`t1` join lateral (/* select#2 */ select `test`.`t1`.`a` AS `a`) `dt` +flush status; +select straight_join * from t2, t1, lateral (select t1.a) as dt; +a b a b a +1 NULL 1 NULL 1 +1 NULL 2 NULL 2 +2 NULL 1 NULL 1 +2 NULL 2 NULL 2 +# Due to join buffer, order t2-t1 produces rows as a +# non-buffered t1-t2 plan: t1 buffers all rows of t2, then for +# each row of t1 it's joined to all rows of t2 and passed to t2; +# when a row of t1 produces two rows of t2 passed to "dt", +# it still makes one materialization. +show status like "handler_write"; +Variable_name Value +Handler_write 2 +# Let the planner find the best plan. +# It doesn't work so well, because of +# optimizer_prune_level=1 (see bug#28629788): order specified by +# the user is sorted by number of rows, which leaves it +# unchanged (Card(t1)=Card(t2)=Card(dt)); then it is the first +# explored plan so it's explored in full, and later t1-dt is rejected as +# more expensive than t1-t2. Whereas if t1-dt had been explored +# deeper, we'd see t1-dt-t2 is actually the cheapest, because +# it reads dt the least number of times (and dt has a high read +# cost because Temptable::scan_time() is incredibly high but +# that's another issue; see bug#28631100). +# t2 cannot use join buffering as between "dt" and its +# dependency t1: join buffering would interlace rows of t1 +# thus cause more rematerializations. +explain select * from t1, t2, lateral (select t1.a) as dt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 2 100.00 Rematerialize () +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DEPENDENT DERIVED NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`dt`.`a` AS `a` from `test`.`t1` join `test`.`t2` join lateral (/* select#2 */ select `test`.`t1`.`a` AS `a`) `dt` +flush status; +select * from t1, t2, lateral (select t1.a) as dt; +a b a b a +1 NULL 1 NULL 1 +1 NULL 2 NULL 1 +2 NULL 1 NULL 2 +2 NULL 2 NULL 2 +show status like "handler_write"; +Variable_name Value +Handler_write 2 +# This one finds the best plan. Yes we simply swapped tables in the query, +# and it yields a different plan. This is because the order specified by +# the user is sorted by number of rows, which leaves it +# unchanged (Card(t1)=Card(t2)=Card(dt), then it is the first +# explored plan so it's explored in full and so is never pruned by +# prune_level=1, and it is the best plan. Best as: it reads +# "dt" less, and t2 uses join buffering (which is ok as it's +# after "dt"). +# If prune_level=0, all 3 variants here produce this plan. +explain select * from t1, lateral (select t1.a) as dt, t2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 2 100.00 Rematerialize () +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +2 DEPENDENT DERIVED NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`dt`.`a` AS `a`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` join lateral (/* select#2 */ select `test`.`t1`.`a` AS `a`) `dt` join `test`.`t2` +flush status; +select * from t1, lateral (select t1.a) as dt, t2; +a b a a b +1 NULL 1 1 NULL +1 NULL 1 2 NULL +2 NULL 2 1 NULL +2 NULL 2 2 NULL +show status like "handler_write"; +Variable_name Value +Handler_write 2 +# This one is intermediate: t1 uses join buffer (good), but +# "dt" is last (bad, as it has high scan cost). +explain select * from t2, t1, lateral (select t1.a) as dt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 2 100.00 Rematerialize (); Using join buffer (hash join) +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DEPENDENT DERIVED NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`dt`.`a` AS `a` from `test`.`t2` join `test`.`t1` join lateral (/* select#2 */ select `test`.`t1`.`a` AS `a`) `dt` +flush status; +select * from t2, t1, lateral (select t1.a) as dt; +a b a b a +1 NULL 1 NULL 1 +1 NULL 2 NULL 2 +2 NULL 1 NULL 1 +2 NULL 2 NULL 2 +show status like "handler_write"; +Variable_name Value +Handler_write 2 +# Show the trace of planning of lateral derived tables +explain select * from t1, lateral (select t1.a from t2 as t3, t2 as t4) as dt, t2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` join `test`.`t2` `t3` join `test`.`t2` `t4` join `test`.`t2` +select trace from information_schema.optimizer_trace; +trace +{ + "steps": [ + { + "join_preparation": { + "select#": 1, + "steps": [ + { + "join_preparation": { + "select#": 2, + "steps": [ + { + "expanded_query": "/* select#2 */ select `t1`.`a` AS `a` from `t2` `t3` join `t2` `t4`" + } + ] + } + }, + { + "derived": { + "table": "`` `dt`", + "select#": 2, + "merged": true + } + }, + { + "expanded_query": "/* select#1 */ select `t1`.`a` AS `a`,`t1`.`b` AS `b`,`t1`.`a` AS `a`,`t2`.`a` AS `a`,`t2`.`b` AS `b` from `t1` join (`t2` `t3` join `t2` `t4`) join `t2`" + }, + { + "transformations_to_nested_joins": { + "transformations": [ + "parenthesis_removal" + ], + "expanded_query": "/* select#1 */ select `t1`.`a` AS `a`,`t1`.`b` AS `b`,`t1`.`a` AS `a`,`t2`.`a` AS `a`,`t2`.`b` AS `b` from `t1` join `t2` `t3` join `t2` `t4` join `t2`" + } + } + ] + } + }, + { + "join_optimization": { + "select#": 1, + "steps": [ + { + "table_dependencies": [ + { + "table": "`t1`", + "row_may_be_null": false, + "map_bit": 0, + "depends_on_map_bits": [ + ] + }, + { + "table": "`t2` `t3`", + "row_may_be_null": false, + "map_bit": 1, + "depends_on_map_bits": [ + ] + }, + { + "table": "`t2` `t4`", + "row_may_be_null": false, + "map_bit": 2, + "depends_on_map_bits": [ + ] + }, + { + "table": "`t2`", + "row_may_be_null": false, + "map_bit": 3, + "depends_on_map_bits": [ + ] + } + ] + }, + { + "rows_estimation": [ + { + "table": "`t1`", + "table_scan": { + "rows": 2, + "cost": 0.25 + } + }, + { + "table": "`t2` `t3`", + "table_scan": { + "rows": 2, + "cost": 0.25 + } + }, + { + "table": "`t2` `t4`", + "table_scan": { + "rows": 2, + "cost": 0.25 + } + }, + { + "table": "`t2`", + "table_scan": { + "rows": 2, + "cost": 0.25 + } + } + ] + }, + { + "considered_execution_plans": [ + { + "plan_prefix": [ + ], + "table": "`t1`", + "best_access_path": { + "considered_access_paths": [ + { + "rows_to_scan": 2, + "access_type": "scan", + "resulting_rows": 2, + "cost": 0.45, + "chosen": true + } + ] + }, + "condition_filtering_pct": 100, + "rows_for_plan": 2, + "cost_for_plan": 0.45, + "rest_of_plan": [ + { + "plan_prefix": [ + "`t1`" + ], + "table": "`t2` `t3`", + "best_access_path": { + "considered_access_paths": [ + { + "rows_to_scan": 2, + "access_type": "scan", + "using_join_cache": true, + "buffers_needed": 1, + "resulting_rows": 2, + "cost": 0.650017, + "chosen": true + } + ] + }, + "condition_filtering_pct": 100, + "rows_for_plan": 4, + "cost_for_plan": 1.10002, + "rest_of_plan": [ + { + "plan_prefix": [ + "`t1`", + "`t2` `t3`" + ], + "table": "`t2` `t4`", + "best_access_path": { + "considered_access_paths": [ + { + "rows_to_scan": 2, + "access_type": "scan", + "using_join_cache": true, + "buffers_needed": 1, + "resulting_rows": 2, + "cost": 1.05003, + "chosen": true + } + ] + }, + "condition_filtering_pct": 100, + "rows_for_plan": 8, + "cost_for_plan": 2.15005, + "rest_of_plan": [ + { + "plan_prefix": [ + "`t1`", + "`t2` `t3`", + "`t2` `t4`" + ], + "table": "`t2`", + "best_access_path": { + "considered_access_paths": [ + { + "rows_to_scan": 2, + "access_type": "scan", + "using_join_cache": true, + "buffers_needed": 1, + "resulting_rows": 2, + "cost": 1.85007, + "chosen": true + } + ] + }, + "condition_filtering_pct": 100, + "rows_for_plan": 16, + "cost_for_plan": 4.00012, + "chosen": true + } + ] + }, + { + "plan_prefix": [ + "`t1`", + "`t2` `t3`" + ], + "table": "`t2`", + "best_access_path": { + "considered_access_paths": [ + { + "rows_to_scan": 2, + "access_type": "scan", + "using_join_cache": true, + "buffers_needed": 1, + "resulting_rows": 2, + "cost": 1.05003, + "chosen": true + } + ] + }, + "condition_filtering_pct": 100, + "rows_for_plan": 8, + "cost_for_plan": 2.15005, + "pruned_by_heuristic": true + } + ] + }, + { + "plan_prefix": [ + "`t1`" + ], + "table": "`t2` `t4`", + "best_access_path": { + "considered_access_paths": [ + { + "rows_to_scan": 2, + "access_type": "scan", + "using_join_cache": true, + "buffers_needed": 1, + "resulting_rows": 2, + "cost": 0.650017, + "chosen": true + } + ] + }, + "condition_filtering_pct": 100, + "rows_for_plan": 4, + "cost_for_plan": 1.10002, + "pruned_by_heuristic": true + }, + { + "plan_prefix": [ + "`t1`" + ], + "table": "`t2`", + "best_access_path": { + "considered_access_paths": [ + { + "rows_to_scan": 2, + "access_type": "scan", + "using_join_cache": true, + "buffers_needed": 1, + "resulting_rows": 2, + "cost": 0.650017, + "chosen": true + } + ] + }, + "condition_filtering_pct": 100, + "rows_for_plan": 4, + "cost_for_plan": 1.10002, + "pruned_by_heuristic": true + } + ] + }, + { + "plan_prefix": [ + ], + "table": "`t2` `t3`", + "best_access_path": { + "considered_access_paths": [ + { + "rows_to_scan": 2, + "access_type": "scan", + "resulting_rows": 2, + "cost": 0.45, + "chosen": true + } + ] + }, + "condition_filtering_pct": 100, + "rows_for_plan": 2, + "cost_for_plan": 0.45, + "pruned_by_heuristic": true + }, + { + "plan_prefix": [ + ], + "table": "`t2` `t4`", + "best_access_path": { + "considered_access_paths": [ + { + "rows_to_scan": 2, + "access_type": "scan", + "resulting_rows": 2, + "cost": 0.45, + "chosen": true + } + ] + }, + "condition_filtering_pct": 100, + "rows_for_plan": 2, + "cost_for_plan": 0.45, + "pruned_by_heuristic": true + }, + { + "plan_prefix": [ + ], + "table": "`t2`", + "best_access_path": { + "considered_access_paths": [ + { + "rows_to_scan": 2, + "access_type": "scan", + "resulting_rows": 2, + "cost": 0.45, + "chosen": true + } + ] + }, + "condition_filtering_pct": 100, + "rows_for_plan": 2, + "cost_for_plan": 0.45, + "pruned_by_heuristic": true + } + ] + }, + { + "attaching_conditions_to_tables": { + "original_condition": null, + "attached_conditions_computation": [ + ], + "attached_conditions_summary": [ + { + "table": "`t1`", + "attached": null + }, + { + "table": "`t2` `t3`", + "attached": null + }, + { + "table": "`t2` `t4`", + "attached": null + }, + { + "table": "`t2`", + "attached": null + } + ] + } + }, + { + "finalizing_table_conditions": [ + ] + }, + { + "refine_plan": [ + { + "table": "`t1`" + }, + { + "table": "`t2` `t3`" + }, + { + "table": "`t2` `t4`" + }, + { + "table": "`t2`" + } + ] + } + ] + } + }, + { + "make_parallel_query_plan": { + "select#": 1, + "detail": [ + { + "table": "`t1`", + "degree of parallel": 4 + } + ] + } + }, + { + "join_explain": { + "select#": 1, + "steps": [ + ] + } + } + ] +} +# LDT depending on const table only +create table t3(a int) engine=innodb; +insert into t3 values(3); +analyze table t3; +Table Op Msg_type Msg_text +test.t3 analyze status OK +explain select * from t3, lateral (select t3.a+1) as dt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t3 NULL ALL NULL NULL NULL NULL 1 100.00 Rematerialize () +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DEPENDENT DERIVED NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1276 Field or reference 'test.t3.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a`,`dt`.`t3.a+1` AS `t3.a+1` from `test`.`t3` join lateral (/* select#2 */ select (`test`.`t3`.`a` + 1) AS `t3.a+1`) `dt` +select * from t3, lateral (select t3.a+1) as dt; +a t3.a+1 +3 4 +drop table t3; +# Two LDTs depending on different tables +explain select * from t2, t1, lateral (select t1.a) as dt, +lateral (select t2.a) as dt2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 2 100.00 Rematerialize () +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 2 100.00 Rematerialize () +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 NULL +3 DEPENDENT DERIVED NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +2 DEPENDENT DERIVED NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 +Note 1276 Field or reference 'test.t2.a' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`dt`.`a` AS `a`,`dt2`.`a` AS `a` from `test`.`t2` join `test`.`t1` join lateral (/* select#2 */ select `test`.`t1`.`a` AS `a`) `dt` join lateral (/* select#3 */ select `test`.`t2`.`a` AS `a`) `dt2` +select * from t2, t1, lateral (select t1.a) as dt, +lateral (select t2.a) as dt2; +a b a b a a +1 NULL 1 NULL 1 1 +1 NULL 2 NULL 2 1 +2 NULL 1 NULL 1 2 +2 NULL 2 NULL 2 2 +# Two LDTs depending on one same table +explain select * from t2, t1, lateral (select t1.a) as dt, +lateral (select t1.a+1) as dt2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 2 100.00 Rematerialize (,); Using join buffer (hash join) +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 NULL +3 DEPENDENT DERIVED NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +2 DEPENDENT DERIVED NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 +Note 1276 Field or reference 'test.t1.a' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`dt`.`a` AS `a`,`dt2`.`t1.a+1` AS `t1.a+1` from `test`.`t2` join `test`.`t1` join lateral (/* select#2 */ select `test`.`t1`.`a` AS `a`) `dt` join lateral (/* select#3 */ select (`test`.`t1`.`a` + 1) AS `t1.a+1`) `dt2` +explain format=json select * from t2, t1, lateral (select t1.a) as dt, +lateral (select t1.a+1) as dt2; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "34.10" + }, + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 2, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.20", + "prefix_cost": "0.45", + "data_read_per_join": "32" + }, + "used_columns": [ + "a", + "b" + ] + } + }, + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 4, + "filtered": "100.00", + "rematerialize": "dt,dt2", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.40", + "prefix_cost": "1.10", + "data_read_per_join": "64" + }, + "used_columns": [ + "a", + "b" + ] + } + }, + { + "table": { + "table_name": "dt", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 8, + "filtered": "100.00", + "cost_info": { + "read_cost": "10.30", + "eval_cost": "0.80", + "prefix_cost": "12.20", + "data_read_per_join": "128" + }, + "used_columns": [ + "a" + ], + "materialized_from_subquery": { + "using_temporary_table": true, + "dependent": true, + "cacheable": true, + "query_block": { + "select_id": 2, + "message": "No tables used" + } + } + } + }, + { + "table": { + "table_name": "dt2", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 16, + "filtered": "100.00", + "cost_info": { + "read_cost": "20.30", + "eval_cost": "1.60", + "prefix_cost": "34.10", + "data_read_per_join": "256" + }, + "used_columns": [ + "t1.a+1" + ], + "materialized_from_subquery": { + "using_temporary_table": true, + "dependent": true, + "cacheable": true, + "query_block": { + "select_id": 3, + "message": "No tables used" + } + } + } + } + ] + } +} +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 +Note 1276 Field or reference 'test.t1.a' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`dt`.`a` AS `a`,`dt2`.`t1.a+1` AS `t1.a+1` from `test`.`t2` join `test`.`t1` join lateral (/* select#2 */ select `test`.`t1`.`a` AS `a`) `dt` join lateral (/* select#3 */ select (`test`.`t1`.`a` + 1) AS `t1.a+1`) `dt2` +select * from t2, t1, lateral (select t1.a) as dt, +lateral (select t1.a+1) as dt2; +a b a b a t1.a+1 +1 NULL 1 NULL 1 2 +1 NULL 2 NULL 2 3 +2 NULL 1 NULL 1 2 +2 NULL 2 NULL 2 3 +# One LDT depending on two tables. The "rematerialize" tag is +# properly added to the 2nd dependency only. +explain select * from t2, t1, lateral (select t1.a+t2.a) as dt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 2 100.00 Rematerialize () +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DEPENDENT DERIVED NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 +Note 1276 Field or reference 'test.t2.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`dt`.`t1.a+t2.a` AS `t1.a+t2.a` from `test`.`t2` join `test`.`t1` join lateral (/* select#2 */ select (`test`.`t1`.`a` + `test`.`t2`.`a`) AS `t1.a+t2.a`) `dt` +explain format=json select * from t2, t1, lateral (select t1.a+t2.a) as dt; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "12.45" + }, + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 2, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.20", + "prefix_cost": "0.45", + "data_read_per_join": "32" + }, + "used_columns": [ + "a", + "b" + ] + } + }, + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 4, + "filtered": "100.00", + "rematerialize": "dt", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.40", + "prefix_cost": "1.35", + "data_read_per_join": "64" + }, + "used_columns": [ + "a", + "b" + ] + } + }, + { + "table": { + "table_name": "dt", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 8, + "filtered": "100.00", + "cost_info": { + "read_cost": "10.30", + "eval_cost": "0.80", + "prefix_cost": "12.45", + "data_read_per_join": "128" + }, + "used_columns": [ + "t1.a+t2.a" + ], + "materialized_from_subquery": { + "using_temporary_table": true, + "dependent": true, + "cacheable": true, + "query_block": { + "select_id": 2, + "message": "No tables used" + } + } + } + } + ] + } +} +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 +Note 1276 Field or reference 'test.t2.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`dt`.`t1.a+t2.a` AS `t1.a+t2.a` from `test`.`t2` join `test`.`t1` join lateral (/* select#2 */ select (`test`.`t1`.`a` + `test`.`t2`.`a`) AS `t1.a+t2.a`) `dt` +select * from t2, t1, lateral (select t1.a+t2.a) as dt; +a b a b t1.a+t2.a +1 NULL 1 NULL 2 +1 NULL 2 NULL 3 +2 NULL 1 NULL 3 +2 NULL 2 NULL 4 +select json_extract(trace,"$.steps[*].join_optimization.steps[*].refine_plan") from information_schema.optimizer_trace; +json_extract(trace,"$.steps[*].join_optimization.steps[*].refine_plan") +[[{"table": "`t2`"}, {"table": "`t1`"}, {"table": " `dt`", "rematerialized_for_each_row_of": "t1"}]] +# Test when a dependency of LDT uses BKA: BKA code must +# refresh LDT's content when it provides a row. +set @old_opt_switch=@@optimizer_switch; +set @@optimizer_switch="batched_key_access=on,mrr_cost_based=off"; +CREATE TABLE t11 (t11a int, t11b int); +INSERT INTO t11 VALUES (99, NULL),(99, 3),(99,0); +CREATE TABLE t12 (t12a int, t12b int, KEY idx (t12b)); +INSERT INTO t12 VALUES (100,0),(150,200),(999, 0),(999, NULL); +ANALYZE TABLE t11,t12; +Table Op Msg_type Msg_text +test.t11 analyze status OK +test.t12 analyze status OK +explain SELECT * FROM t11 LEFT JOIN t12 force index (idx) ON t12.t12b = t11.t11b +JOIN LATERAL (SELECT t12a) dt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t11 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY t12 NULL ref idx idx 5 test.t11.t11b 1 100.00 Rematerialize (); Using join buffer (Batched Key Access) +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DEPENDENT DERIVED NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1276 Field or reference 'test.t12.t12a' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t11`.`t11a` AS `t11a`,`test`.`t11`.`t11b` AS `t11b`,`test`.`t12`.`t12a` AS `t12a`,`test`.`t12`.`t12b` AS `t12b`,`dt`.`t12a` AS `t12a` from `test`.`t11` left join `test`.`t12` FORCE INDEX (`idx`) on((`test`.`t12`.`t12b` = `test`.`t11`.`t11b`)) join lateral (/* select#2 */ select `test`.`t12`.`t12a` AS `t12a`) `dt` where true +flush status; +SELECT * FROM t11 LEFT JOIN t12 force index (idx) ON t12.t12b = t11.t11b +JOIN LATERAL (SELECT t12a) dt; +t11a t11b t12a t12b t12a +99 0 100 0 100 +99 0 999 0 999 +99 NULL NULL NULL NULL +99 3 NULL NULL NULL +show status like "handler_write"; +Variable_name Value +Handler_write 4 +DROP TABLE t11,t12; +set @@optimizer_switch=@old_opt_switch; +# Test that with an auto_key on the lateral DT, the index is +# properly emptied and re-filled when re-materializing. +# If index weren't emptied, we'd see too many "11" matches for 2nd +# row of t1; and if not re-filled, we'd see no matches for that. +create table t3 (a int, b int); +insert into t3 values(1, 10), (1, 11), (2, 10), (2, 11); +analyze table t3; +Table Op Msg_type Msg_text +test.t3 analyze status OK +# Note the auto_key with "Using index", to test the index as +# much as possible. +explain select * from t1, lateral (select t3.b from t3 where t3.a=t1.a) dt +where dt.b=t1.a+9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t3`.`b` AS `b` from `test`.`t1` join `test`.`t3` where ((`test`.`t3`.`a` = `test`.`t1`.`a`) and (`test`.`t3`.`b` = (`test`.`t1`.`a` + 9))) +select * from t1, lateral (select t3.b from t3 where t3.a=t1.a) dt +where dt.b=t1.a+9; +a b b +1 NULL 10 +2 NULL 11 +drop table t3; +set optimizer_switch='derived_merge=off'; +# Deep nesting: all intermediate subqueries are marked DEPENDENT +explain select * from t1 where +(select count(*) from (select * from (select * from t1 t2 +where 2=(select 2 from (select t1.a) dt1))dt3)dt4); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +2 DEPENDENT SUBQUERY NULL ALL NULL NULL NULL NULL 2 100.00 NULL +3 DEPENDENT DERIVED NULL ALL NULL NULL NULL NULL 2 100.00 NULL +4 DEPENDENT DERIVED t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +5 DEPENDENT SUBQUERY NULL ALL NULL NULL NULL NULL 2 100.00 NULL +6 DEPENDENT DERIVED NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #6 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (0 <> (/* select#2 */ select count(0) from (/* select#3 */ select `dt3`.`a` AS `a`,`dt3`.`b` AS `b` from (/* select#4 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` `t2` where (2 = (/* select#5 */ select 2 from (/* select#6 */ select `test`.`t1`.`a` AS `a`) `dt1`))) `dt3`) `dt4`)) +select * from t1 where +(select count(*) from (select * from (select * from t1 t2 +where 2=(select 2 from (select t1.a) dt1))dt3)dt4); +a b +1 NULL +2 NULL +# If reference is removed, not DEPENDENT +explain select * from t1 where +(select count(*) from (select * from (select * from t1 t2 +where 2=(select 2 from (select 42) dt1))dt3)dt4); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 SUBQUERY NULL ALL NULL NULL NULL NULL 2 100.00 NULL +3 DERIVED NULL ALL NULL NULL NULL NULL 2 100.00 NULL +4 DERIVED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +5 SUBQUERY NULL system NULL NULL NULL NULL 1 100.00 NULL +6 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where true +select * from t1 where +(select count(*) from (select * from (select * from t1 t2 +where 2=(select 2 from (select 42) dt1))dt3)dt4); +a b +1 NULL +2 NULL +# Outer ref is in SELECT list of derived table's definition +explain select +(select dt.a from +(select t1.a as a, t2.a as b from t2) dt where dt.b=t1.a) +as subq +from t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DEPENDENT SUBQUERY NULL ref 5 test.t1.a 2 100.00 NULL +3 DEPENDENT DERIVED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #3 was resolved in SELECT #1 +Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select (/* select#2 */ select `dt`.`a` from (/* select#3 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `b` from `test`.`t2`) `dt` where (`dt`.`b` = `test`.`t1`.`a`)) AS `subq` from `test`.`t1` +select +(select dt.a from +(select t1.a as a, t2.a as b from t2) dt where dt.b=t1.a) +as subq +from t1; +subq +1 +2 +# In WHERE +explain select +(select dt.b from +(select t2.a as b from t2 where t1.a=t2.a) dt) +as subq +from t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DEPENDENT SUBQUERY NULL ALL NULL NULL NULL NULL 2 100.00 NULL +3 DEPENDENT DERIVED t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select (/* select#2 */ select `dt`.`b` from (/* select#3 */ select `test`.`t2`.`a` AS `b` from `test`.`t2` where (`test`.`t1`.`a` = `test`.`t2`.`a`)) `dt`) AS `subq` from `test`.`t1` +select +(select dt.b from +(select t2.a as b from t2 where t1.a=t2.a) dt) +as subq +from t1; +subq +1 +2 +# In GROUP BY +explain select +(select dt.b from +(select sum(t2.a) as b from t2 group by t1.a) dt) +as subq +from t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DEPENDENT SUBQUERY NULL ALL NULL NULL NULL NULL 2 100.00 NULL +3 DEPENDENT DERIVED t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using temporary +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select (/* select#2 */ select `dt`.`b` from (/* select#3 */ select sum(`test`.`t2`.`a`) AS `b` from `test`.`t2` group by `test`.`t1`.`a`) `dt`) AS `subq` from `test`.`t1` +select +(select dt.b from +(select sum(t2.a) as b from t2 group by t1.a) dt) +as subq +from t1; +subq +3 +3 +# In HAVING +explain select +(select dt.b from +(select sum(t2.a) as b from t2 having t1.a=sum(t2.a)-1) dt) +as subq +from t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DEPENDENT SUBQUERY NULL ALL NULL NULL NULL NULL 2 100.00 NULL +3 DEPENDENT DERIVED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1276 Field or reference 't1.a' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select (/* select#2 */ select `dt`.`b` from (/* select#3 */ select sum(`test`.`t2`.`a`) AS `b` from `test`.`t2` having (`test`.`t1`.`a` = (sum(`test`.`t2`.`a`) - 1))) `dt`) AS `subq` from `test`.`t1` +select +(select dt.b from +(select sum(t2.a) as b from t2 having t1.a=sum(t2.a)-1) dt) +as subq +from t1; +subq +NULL +3 +explain select +(select dt.b from +(select sum(t2.a) as b from t2 having t1.a=sum(t2.a)-2) dt) +as subq +from t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DEPENDENT SUBQUERY NULL ALL NULL NULL NULL NULL 2 100.00 NULL +3 DEPENDENT DERIVED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1276 Field or reference 't1.a' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select (/* select#2 */ select `dt`.`b` from (/* select#3 */ select sum(`test`.`t2`.`a`) AS `b` from `test`.`t2` having (`test`.`t1`.`a` = (sum(`test`.`t2`.`a`) - 2))) `dt`) AS `subq` from `test`.`t1` +select +(select dt.b from +(select sum(t2.a) as b from t2 having t1.a=sum(t2.a)-2) dt) +as subq +from t1; +subq +3 +NULL +# In ORDER BY +explain select +(select dt.b from +(select t2.a as b from t2 order by if(t1.a=1,t2.a,-t2.a) limit 1) dt) +as subq +from t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DEPENDENT SUBQUERY NULL ALL NULL NULL NULL NULL 2 100.00 NULL +3 DEPENDENT DERIVED t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using temporary; Using filesort +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select (/* select#2 */ select `dt`.`b` from (/* select#3 */ select `test`.`t2`.`a` AS `b` from `test`.`t2` order by if((`test`.`t1`.`a` = 1),`test`.`t2`.`a`,-(`test`.`t2`.`a`)) limit 1) `dt`) AS `subq` from `test`.`t1` +select +(select dt.b from +(select t2.a as b from t2 order by if(t1.a=1,t2.a,-t2.a) limit 1) dt) +as subq +from t1; +subq +1 +2 +# In window functions +explain select +(select dt.b from +(select t2.a, sum(t1.a*10+t2.a) over (order by if(t1.a=1,t2.a,-t2.a)) as b +from t2) dt where dt.a=1) +as subq +from t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DEPENDENT SUBQUERY NULL ref 5 const 1 100.00 NULL +3 DEPENDENT DERIVED t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using filesort +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #3 was resolved in SELECT #1 +Note 1276 Field or reference 'test.t1.a' of SELECT #3 was resolved in SELECT #1 +Note 3598 To get information about window functions use EXPLAIN FORMAT=JSON +Note 1003 /* select#1 */ select (/* select#2 */ select `dt`.`b` from (/* select#3 */ select `test`.`t2`.`a` AS `a`,sum(((`test`.`t1`.`a` * 10) + `test`.`t2`.`a`)) OVER (ORDER BY if((`test`.`t1`.`a` = 1),`test`.`t2`.`a`,-(`test`.`t2`.`a`)) ) AS `b` from `test`.`t2`) `dt` where (`dt`.`a` = 1)) AS `subq` from `test`.`t1` +select +(select dt.b from +(select t2.a, sum(t1.a*10+t2.a) over (order by if(t1.a=1,t2.a,-t2.a)) as b +from t2) dt where dt.a=1) +as subq +from t1; +subq +11 +43 +# CTE referenced twice +explain select +(with dt as (select t1.a as a, t2.a as b from t2) +select dt2.a from dt dt1, dt dt2 where dt1.b=t1.a and dt2.b=dt1.b) +as subq +from t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DEPENDENT SUBQUERY NULL ref 5 test.t1.a 2 100.00 NULL +2 DEPENDENT SUBQUERY NULL ref 5 test.t1.a 2 100.00 Using where +3 DEPENDENT DERIVED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #3 was resolved in SELECT #1 +Note 1276 Field or reference 'test.t1.a' of SELECT #4 was resolved in SELECT #1 +Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select (with `dt` as (/* select#3 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `b` from `test`.`t2`) /* select#2 */ select `dt2`.`a` from `dt` `dt1` join `dt` `dt2` where ((`dt2`.`b` = `dt1`.`b`) and (`dt1`.`b` = `test`.`t1`.`a`))) AS `subq` from `test`.`t1` +select +(with dt as (select t1.a as a, t2.a as b from t2) +select dt2.a from dt dt1, dt dt2 where dt1.b=t1.a and dt2.b=dt1.b) +as subq +from t1; +subq +1 +2 +Recursive CTE +select +(with recursive dt as +(select t1.a as a union select a+1 from dt where a<10) +select dt1.a from dt dt1 where dt1.a=t1.a +) as subq +from t1; +subq +1 +2 +select +(with recursive dt as +(select t1.a as a union select a+1 from dt where a<10) +select concat(count(*), ' - ', avg(dt.a)) from dt +) as subq +from t1; +subq +10 - 5.5000 +9 - 6.0000 +select +(with recursive dt as +(select t1.a as a union all select a+1 from dt where a<10) +select concat(count(*), ' - ', avg(dt.a)) from dt +) as subq +from t1; +subq +10 - 5.5000 +9 - 6.0000 +select +(with dt as (select t1.a as a, t2.a as b from t2) +select dt2.a from dt dt1, dt dt2 where dt1.b=t1.a and dt2.b=dt1.b) +as subq +from t1; +subq +1 +2 +# Two references to same CTE at different levels of nesting. +explain select (with dt as (select t1.a as a from t2 limit 1) select * from dt dt1 where dt1.a=(select * from dt as dt2)) as subq from t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DEPENDENT SUBQUERY NULL ref 5 func 2 100.00 Using where; Using index +4 DEPENDENT SUBQUERY NULL ALL NULL NULL NULL NULL 2 100.00 NULL +3 DEPENDENT DERIVED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #3 was resolved in SELECT #1 +Note 1276 Field or reference 'test.t1.a' of SELECT #5 was resolved in SELECT #1 +Note 1003 /* select#1 */ select (with `dt` as (/* select#3 */ select `test`.`t1`.`a` AS `a` from `test`.`t2` limit 1) /* select#2 */ select `dt1`.`a` from `dt` `dt1` where (`dt1`.`a` = (/* select#4 */ select `dt2`.`a` from `dt` `dt2`))) AS `subq` from `test`.`t1` +explain format=tree select (with dt as (select t1.a as a from t2 limit 1) select * from dt dt1 where dt1.a=(select * from dt as dt2)) as subq from t1; +EXPLAIN +-> Table scan on t1 (cost=0.45 rows=2) +-> Select #2 (subquery in projection; dependent) + -> Filter: (dt1.a = (select #4)) (cost=0.62..0.70 rows=2) + -> Index lookup on dt1 using (a=(select #4)) + -> Materialize CTE dt if needed (cost=0.55..0.55 rows=1) + -> Limit: 1 row(s) (cost=0.45 rows=1) + -> Table scan on t2 (cost=0.45 rows=2) + -> Select #4 (subquery in condition; dependent) + -> Table scan on dt2 (cost=2.51..2.51 rows=1) + -> Materialize CTE dt if needed (query plan printed elsewhere) (cost=3.06..3.06 rows=1) + +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #3 was resolved in SELECT #1 +Note 1276 Field or reference 'test.t1.a' of SELECT #5 was resolved in SELECT #1 +select (with dt as (select t1.a as a from t2 limit 1) select * from dt dt1 where dt1.a=(select * from dt as dt2)) as subq from t1; +subq +1 +2 +explain select (with dt as (select t2.a as a from t2 having t1.a=t2.a limit 1) select * from dt dt1 where dt1.a=(select * from dt as dt2)) as subq from t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DEPENDENT SUBQUERY NULL ref 5 func 2 100.00 Using where; Using index +4 DEPENDENT SUBQUERY NULL ALL NULL NULL NULL NULL 2 100.00 NULL +3 DEPENDENT DERIVED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1276 Field or reference 't1.a' of SELECT #3 was resolved in SELECT #1 +Note 1276 Field or reference 't1.a' of SELECT #5 was resolved in SELECT #1 +Note 1003 /* select#1 */ select (with `dt` as (/* select#3 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` having (`test`.`t1`.`a` = `test`.`t2`.`a`) limit 1) /* select#2 */ select `dt1`.`a` from `dt` `dt1` where (`dt1`.`a` = (/* select#4 */ select `dt2`.`a` from `dt` `dt2`))) AS `subq` from `test`.`t1` +select (with dt as (select t2.a as a from t2 having t1.a=t2.a limit 1) select * from dt dt1 where dt1.a=(select * from dt as dt2)) as subq from t1; +subq +1 +2 +# Scope of outer ref in CTE +select (select * from (select t1.a) cte) from t1; +(select * from (select t1.a) cte) +1 +2 +select (with cte as (select t1.a) select * from cte) from t1; +(with cte as (select t1.a) select * from cte) +1 +2 +with cte as (select t1.a) select (select * from cte) from t1; +ERROR 42S02: Unknown table 't1' in field list +# NOT IN(subquery using derived), handled with subquery materialization +explain select * from t1 +where a not in (select dt.f+1 from (select t2.a as f from t2) dt); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +2 SUBQUERY NULL ALL NULL NULL NULL NULL 2 100.00 NULL +3 DERIVED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (`test`.`t1`.`a`,`test`.`t1`.`a` in ( (/* select#2 */ select (`dt`.`f` + 1) from (/* select#3 */ select `test`.`t2`.`a` AS `f` from `test`.`t2`) `dt` where true having true ), (`test`.`t1`.`a` in on where ((`test`.`t1`.`a` = ``.`dt.f+1`)))) is false) +select * from t1 +where a not in (select dt.f+1 from (select t2.a as f from t2) dt); +a b +1 NULL +# Now put an outer reference inside derived table: +# subquery is properly seen as correlated and subquery +# materialization is thus not used. +explain select * from t1 +where a not in (select dt.f+1 from (select 0*t1.a+t2.a as f from t2) dt); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +2 DEPENDENT SUBQUERY NULL ALL NULL NULL NULL NULL 2 100.00 Using where +3 DEPENDENT DERIVED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (`test`.`t1`.`a`,(/* select#2 */ select (`dt`.`f` + 1) from (/* select#3 */ select ((0 * `test`.`t1`.`a`) + `test`.`t2`.`a`) AS `f` from `test`.`t2`) `dt` where (outer_field_is_not_null, (((`test`.`t1`.`a`) = (`dt`.`f` + 1)) or ((`dt`.`f` + 1) is null)), true) having (outer_field_is_not_null, ((`dt`.`f` + 1)), true)) is false) +select * from t1 +where a not in (select dt.f+1 from (select 0*t1.a+t2.a as f from t2) dt); +a b +1 NULL +# Verify that a non-lateral derived table with an outer +# reference makes the semijoin be correlated and thus blocks +# semijoin-materialization-scan. +create table t11 (a int); +insert into t11 +with recursive cte as (select 1 as a union all select a+1 from cte where a<124) +select * from cte; +alter table t11 add index(a); +create table t12 like t11; +analyze table t11,t12; +Table Op Msg_type Msg_text +test.t11 analyze status OK +test.t12 analyze status OK +# No outer ref: mat-scan chosen +explain select +/*+ NO_SEMIJOIN(@subq1 FIRSTMATCH, LOOSESCAN, DUPSWEEDOUT) */ +* from t11 where a in (select /*+ QB_NAME(subq1) NO_MERGE(dt) */ * +from (select t12.a from t12) dt); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL NULL 100.00 Using where +1 PRIMARY t11 NULL ref a a 5 .a 1 100.00 Using index +2 MATERIALIZED NULL ALL NULL NULL NULL NULL 2 100.00 NULL +3 DERIVED t12 NULL index NULL a 5 NULL 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select /*+ NO_SEMIJOIN(@`subq1` FIRSTMATCH, LOOSESCAN, DUPSWEEDOUT) NO_MERGE(`dt`@`subq1`) */ `test`.`t11`.`a` AS `a` from `test`.`t11` semi join ((/* select#3 */ select `test`.`t12`.`a` AS `a` from `test`.`t12`) `dt`) where (`test`.`t11`.`a` = ``.`a`) +# outer ref: mat-scan not chosen +explain select +/*+ NO_SEMIJOIN(@subq1 FIRSTMATCH, LOOSESCAN, DUPSWEEDOUT) */ +* from t11 where a in (select /*+ QB_NAME(subq1) NO_MERGE(dt) */ * +from (select t12.a+0*t11.a from t12) dt); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t11 NULL index a a 5 NULL 124 100.00 Using where; Using index; Rematerialize () +1 PRIMARY NULL ref 9 test.t11.a 2 100.00 Using where; Using index; Start temporary; End temporary +3 DEPENDENT DERIVED t12 NULL index NULL a 5 NULL 1 100.00 Using index +Warnings: +Note 1276 Field or reference 'test.t11.a' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select /*+ NO_SEMIJOIN(@`subq1` FIRSTMATCH, LOOSESCAN, DUPSWEEDOUT) NO_MERGE(`dt`@`subq1`) */ `test`.`t11`.`a` AS `a` from `test`.`t11` semi join (lateral (/* select#3 */ select (`test`.`t12`.`a` + (0 * `test`.`t11`.`a`)) AS `t12.a+0*t11.a` from `test`.`t12`) `dt`) where (`test`.`t11`.`a` = `dt`.`t12.a+0*t11.a`) +DROP TABLE t11,t12; +LATERAL +# prevents join buffer if materialized (but not if merged) +explain select dt.a from t1, lateral (select t1.a from t2) dt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 2 100.00 Rematerialize () +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DEPENDENT DERIVED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `dt`.`a` AS `a` from `test`.`t1` join lateral (/* select#2 */ select `test`.`t1`.`a` AS `a` from `test`.`t2`) `dt` +# no right join +explain select dt.a from t1 right join lateral (select t1.a from t2) dt on 1; +ERROR 42S22: Unknown column 't1.a' in 'field list' +# no bad left join either +explain select dt.a from lateral (select t1.a from t2) dt left join t1 on 1; +ERROR 42S22: Unknown column 't1.a' in 'field list' +# more complex case +explain SELECT * FROM t1 +LEFT JOIN +lateral (select t1.a) as dt ON t1.a=dt.a +RIGHT JOIN +lateral (select dt.a) as dt1 ON dt.a=dt1.a; +ERROR 42S22: Unknown column 'dt.a' in 'field list' +# LATERAL DT depending on LATERAL DT +explain SELECT * FROM t1 +JOIN +lateral (select t1.a) as dt ON t1.a=dt.a +JOIN +lateral (select dt.a) as dt1 ON dt.a=dt1.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Rematerialize () +1 PRIMARY NULL ref 5 test.t1.a 2 100.00 Using index; Rematerialize () +1 PRIMARY NULL ref 5 test.t1.a 2 100.00 Using index +3 DEPENDENT DERIVED NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +2 DEPENDENT DERIVED NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 +Note 1276 Field or reference 'dt.a' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`dt`.`a` AS `a`,`dt1`.`a` AS `a` from `test`.`t1` join lateral (/* select#2 */ select `test`.`t1`.`a` AS `a`) `dt` join lateral (/* select#3 */ select `dt`.`a` AS `a`) `dt1` where ((`dt`.`a` = `test`.`t1`.`a`) and (`dt1`.`a` = `test`.`t1`.`a`)) +# Placing lateral outer ref in SELECT list then HAVING +select t1.a, dt.a from t1, lateral (select t1.a+t2.a as a from t2) dt; +a a +1 2 +1 3 +2 3 +2 4 +select t1.a, dt.a from t1, lateral (select t2.a as a from t2 having t1.a) dt; +a a +1 1 +1 2 +2 1 +2 2 +# Inside view +create view v1 as +select t1.a as f1, dt.a as f2 +from t1, lateral (select t1.a+t2.a as a from t2) dt; +show create view v1; +View Create View character_set_client collation_connection +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`a` AS `f1`,`dt`.`a` AS `f2` from (`t1` join lateral (select (`t1`.`a` + `t2`.`a`) AS `a` from `t2`) `dt`) utf8mb4 utf8mb4_0900_ai_ci +select * from v1; +f1 f2 +1 2 +1 3 +2 3 +2 4 +drop view v1; +# Coverage for various branches in Item_ref::fix_fields +SELECT COUNT(*) FROM t1 GROUP BY t1.a HAVING t1.a IN (SELECT t3.a +FROM t1 AS t3 WHERE t3.b IN (SELECT b FROM t2, lateral (select t1.a) dt)); +COUNT(*) +create view v1 as select a, b from t1; +select vq1.b,dt.b from v1 vq1, lateral (select vq1.b) dt; +b b +NULL NULL +NULL NULL +select b from v1 vq1, lateral (select count(*) from v1 vq2 having vq1.b = 3) dt; +b +drop view v1; +SELECT +/*+ SET_VAR(optimizer_switch = 'materialization=off,semijoin=off') */ +* FROM t1 AS ta, lateral (select 1 WHERE ta.a IN (SELECT b FROM t2 AS tb WHERE tb.b >= SOME(SELECT SUM(tc.a) as sg FROM t1 as tc GROUP BY tc.b HAVING ta.a=tc.b))) dt; +a b 1 +select (select dt.a from (select 1 as a, t2.a as b from t2 having +t1.a) dt where dt.b=t1.a) as subq from t1; +subq +1 +1 +select (select dt.a from (select 1 as a, 3 as b from t2 having t1.a) +dt where dt.b=t1.a) as subq from t1; +subq +NULL +NULL +# Aggregation in outer context +select (select f from (select max(t1.a) as f) as dt) as g from t1; +g +2 +select (select f from lateral (select max(t1.a) as f) as dt) as g from t1; +g +2 +# LATERAL doesn't allow an aggregate to resolve to the +# immediate parent (because reading of FROM tables happens +# before aggregation). So it resolves in the derived table, so +# the outer query doesn't produce a single-row result. +select t1.a, f from t1, lateral (select max(t1.a) as f) as dt; +a f +1 1 +2 2 +# We support CTE inside derived table +select * from t1, +lateral (with qn as (select t1.a) select (select max(a) from qn)) as dt; +a b (select max(a) from qn) +1 NULL 1 +2 NULL 2 +# Coverage for crash in Item_ident::fix_after_pullout: +# when we merge a derived table contained in a derived table, +# and the merged one contains an outer ref to the top query. +select (select * from (select * from (select t1.a from t2) as dt limit 1) dt2) from t1; +(select * from (select * from (select t1.a from t2) as dt limit 1) dt2) +1 +2 +# Semijoin containing a correlated derived table, DT must +# become LATERAL +explain select a from t1 where a in (select a from (select t1.a) dt); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Rematerialize () +1 PRIMARY NULL ref 5 test.t1.a 2 100.00 Using index; FirstMatch(t1) +3 DEPENDENT DERIVED NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (lateral (/* select#3 */ select `test`.`t1`.`a` AS `a`) `dt`) where (`dt`.`a` = `test`.`t1`.`a`) +select a from t1 where a in (select a from (select t1.a) dt); +a +1 +2 +create table t3 as with recursive cte as (select 1 as a union select a+1 from cte where a<20) select * from cte; +analyze table t3; +Table Op Msg_type Msg_text +test.t3 analyze status OK +explain select min(a),max(a) from t3 where a in (select /*+ no_merge() */ a from (select t3.a from t1) dt); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t3 NULL ALL NULL NULL NULL NULL 20 100.00 Using where; Rematerialize () +1 PRIMARY NULL ref 9 test.t3.a 2 100.00 Using index; FirstMatch(t3) +3 DEPENDENT DERIVED t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1276 Field or reference 'test.t3.a' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select /*+ NO_MERGE(@`select#2`) */ min(`test`.`t3`.`a`) AS `min(a)`,max(`test`.`t3`.`a`) AS `max(a)` from `test`.`t3` semi join (lateral (/* select#3 */ select `test`.`t3`.`a` AS `a` from `test`.`t1`) `dt`) where (`dt`.`a` = `test`.`t3`.`a`) +select min(a),max(a) from t3 where a in (select /*+ no_merge() */ a from (select t3.a from t1) dt); +min(a) max(a) +1 20 +drop table t3; +# DT containing a correlated DT which must become LATERAL +explain format=tree select * from t1, lateral (select * from (select * from (select t1.a from t2) as dt limit 1) dt2) dt3; +EXPLAIN +-> Nested loop inner join (cost=8.62 rows=2) + -> Invalidate materialized tables (row from t1) (cost=0.45 rows=2) + -> Table scan on t1 (cost=0.45 rows=2) + -> Table scan on dt3 (cost=2.51..2.51 rows=1) + -> Materialize (invalidate on row from t1) (cost=7.14..7.14 rows=1) + -> Table scan on dt2 (cost=2.51..2.51 rows=1) + -> Materialize (cost=4.53..4.53 rows=1) + -> Limit: 1 row(s) (cost=1.91..1.91 rows=1) + -> Table scan on dt (cost=1.26..2.52 rows=2) + -> Materialize (cost=1.91..3.17 rows=2) + -> Table scan on t2 (cost=0.45 rows=2) + +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #4 was resolved in SELECT #1 +explain select * from t1, lateral (select * from (select * from (select t1.a from t2) as dt limit 1) dt2) dt3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 2 100.00 Rematerialize () +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DEPENDENT DERIVED NULL ALL NULL NULL NULL NULL 2 100.00 NULL +3 DEPENDENT DERIVED NULL ALL NULL NULL NULL NULL 2 100.00 NULL +4 DEPENDENT DERIVED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #4 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`dt3`.`a` AS `a` from `test`.`t1` join lateral (/* select#2 */ select `dt2`.`a` AS `a` from (/* select#3 */ select `dt`.`a` AS `a` from (/* select#4 */ select `test`.`t1`.`a` AS `a` from `test`.`t2`) `dt` limit 1) `dt2`) `dt3` +select * from t1, lateral (select * from (select * from (select t1.a from t2) as dt limit 1) dt2) dt3; +a b a +1 NULL 1 +2 NULL 2 +explain select * from t1 as t0, +lateral +(select dt3.* from t1, lateral (select * from (select * from (select t0.a +from t2) as dt limit 1) dt2) dt3) dt4; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t0 NULL ALL NULL NULL NULL NULL 2 100.00 Rematerialize () +1 PRIMARY NULL ALL NULL NULL NULL NULL 4 100.00 NULL +2 DEPENDENT DERIVED t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DEPENDENT DERIVED NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +3 DEPENDENT DERIVED NULL ALL NULL NULL NULL NULL 2 100.00 NULL +4 DEPENDENT DERIVED NULL ALL NULL NULL NULL NULL 2 100.00 NULL +5 DEPENDENT DERIVED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1276 Field or reference 'test.t0.a' of SELECT #5 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a`,`test`.`t0`.`b` AS `b`,`dt4`.`a` AS `a` from `test`.`t1` `t0` join lateral (/* select#2 */ select `dt3`.`a` AS `a` from `test`.`t1` join (/* select#3 */ select `dt2`.`a` AS `a` from (/* select#4 */ select `dt`.`a` AS `a` from (/* select#5 */ select `test`.`t0`.`a` AS `a` from `test`.`t2`) `dt` limit 1) `dt2`) `dt3`) `dt4` +select * from t1 as t0, +lateral +(select dt3.* from t1, lateral (select * from (select * from (select t0.a +from t2) as dt limit 1) dt2) dt3) dt4; +a b a +1 NULL 1 +1 NULL 1 +2 NULL 2 +2 NULL 2 +explain select /*+ no_merge() */ * from t1 as t0, +lateral +(select dt3.* from t1, lateral (select * from (select * from (select t0.a +from t2) as dt limit 1) dt2) dt3) dt4; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t0 NULL ALL NULL NULL NULL NULL 2 100.00 Rematerialize () +1 PRIMARY NULL ALL NULL NULL NULL NULL 4 100.00 NULL +2 DEPENDENT DERIVED t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DEPENDENT DERIVED NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +3 DEPENDENT DERIVED NULL ALL NULL NULL NULL NULL 2 100.00 NULL +4 DEPENDENT DERIVED NULL ALL NULL NULL NULL NULL 2 100.00 NULL +5 DEPENDENT DERIVED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1276 Field or reference 'test.t0.a' of SELECT #5 was resolved in SELECT #1 +Note 1003 /* select#1 */ select /*+ NO_MERGE(@`select#1`) */ `test`.`t0`.`a` AS `a`,`test`.`t0`.`b` AS `b`,`dt4`.`a` AS `a` from `test`.`t1` `t0` join lateral (/* select#2 */ select `dt3`.`a` AS `a` from `test`.`t1` join (/* select#3 */ select `dt2`.`a` AS `a` from (/* select#4 */ select `dt`.`a` AS `a` from (/* select#5 */ select `test`.`t0`.`a` AS `a` from `test`.`t2`) `dt` limit 1) `dt2`) `dt3`) `dt4` +select /*+ no_merge() */ * from t1 as t0, +lateral +(select dt3.* from t1, lateral (select * from (select * from (select t0.a +from t2) as dt limit 1) dt2) dt3) dt4; +a b a +1 NULL 1 +1 NULL 1 +2 NULL 2 +2 NULL 2 +explain select * from t1, lateral (select * from (select 42) t1, (select t1.a) dt2) dt3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 2 100.00 Rematerialize () +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DEPENDENT DERIVED NULL system NULL NULL NULL NULL 1 100.00 NULL +2 DEPENDENT DERIVED NULL ALL NULL NULL NULL NULL 2 100.00 NULL +4 DEPENDENT DERIVED NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +3 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #4 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`dt3`.`42` AS `42`,`dt3`.`a` AS `a` from `test`.`t1` join lateral (/* select#2 */ select '42' AS `42`,`dt2`.`a` AS `a` from (/* select#4 */ select `test`.`t1`.`a` AS `a`) `dt2`) `dt3` +select * from t1, lateral (select * from (select 42) t1, (select t1.a) dt2) dt3; +a b 42 a +1 NULL 42 1 +2 NULL 42 2 +without semijoin: index_subquery needs to re-materialize +explain select a from t1 where a in (select /*+ no_semijoin() */ a from (select t1.a) dt); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +2 DEPENDENT SUBQUERY NULL index_subquery 5 func 2 100.00 Using index +3 DEPENDENT DERIVED NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select /*+ NO_SEMIJOIN(@`select#2`) */ `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a`,(((`test`.`t1`.`a`) in dt on ))) +select a from t1 where a in (select /*+ no_semijoin() */ a from (select t1.a) dt); +a +1 +2 +select a from t1 where a in (with cte as (select t1.a) +select /*+ no_semijoin() */ a from cte); +a +1 +2 +# Count rematerializations +# In all three plans, handler_write is 2, showing that we +# rematerialize only when necessary (when row of t1 changes) +explain select straight_join * from t1, t2, lateral (select t1.a) as dt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 2 100.00 Rematerialize () +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DEPENDENT DERIVED NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select straight_join `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`dt`.`a` AS `a` from `test`.`t1` join `test`.`t2` join lateral (/* select#2 */ select `test`.`t1`.`a` AS `a`) `dt` +flush status; +select straight_join * from t1, t2, lateral (select t1.a) as dt; +a b a b a +1 NULL 1 NULL 1 +1 NULL 2 NULL 1 +2 NULL 1 NULL 2 +2 NULL 2 NULL 2 +# when a row of t1 produces two rows of t2 passed to "dt", +# it still makes one materialization. +show status like "handler_write"; +Variable_name Value +Handler_write 2 +explain select straight_join * from t1, lateral (select t1.a) as dt, t2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 2 100.00 Rematerialize () +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +2 DEPENDENT DERIVED NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select straight_join `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`dt`.`a` AS `a`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` join lateral (/* select#2 */ select `test`.`t1`.`a` AS `a`) `dt` join `test`.`t2` +flush status; +select straight_join * from t1, lateral (select t1.a) as dt, t2; +a b a a b +1 NULL 1 1 NULL +1 NULL 1 2 NULL +2 NULL 2 1 NULL +2 NULL 2 2 NULL +show status like "handler_write"; +Variable_name Value +Handler_write 2 +explain select straight_join * from t2, t1, lateral (select t1.a) as dt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 2 100.00 Rematerialize (); Using join buffer (hash join) +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DEPENDENT DERIVED NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select straight_join `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`dt`.`a` AS `a` from `test`.`t2` join `test`.`t1` join lateral (/* select#2 */ select `test`.`t1`.`a` AS `a`) `dt` +flush status; +select straight_join * from t2, t1, lateral (select t1.a) as dt; +a b a b a +1 NULL 1 NULL 1 +1 NULL 2 NULL 2 +2 NULL 1 NULL 1 +2 NULL 2 NULL 2 +# Due to join buffer, order t2-t1 produces rows as a +# non-buffered t1-t2 plan: t1 buffers all rows of t2, then for +# each row of t1 it's joined to all rows of t2 and passed to t2; +# when a row of t1 produces two rows of t2 passed to "dt", +# it still makes one materialization. +show status like "handler_write"; +Variable_name Value +Handler_write 2 +# Let the planner find the best plan. +# It doesn't work so well, because of +# optimizer_prune_level=1 (see bug#28629788): order specified by +# the user is sorted by number of rows, which leaves it +# unchanged (Card(t1)=Card(t2)=Card(dt)); then it is the first +# explored plan so it's explored in full, and later t1-dt is rejected as +# more expensive than t1-t2. Whereas if t1-dt had been explored +# deeper, we'd see t1-dt-t2 is actually the cheapest, because +# it reads dt the least number of times (and dt has a high read +# cost because Temptable::scan_time() is incredibly high but +# that's another issue; see bug#28631100). +# t2 cannot use join buffering as between "dt" and its +# dependency t1: join buffering would interlace rows of t1 +# thus cause more rematerializations. +explain select * from t1, t2, lateral (select t1.a) as dt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 2 100.00 Rematerialize () +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DEPENDENT DERIVED NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`dt`.`a` AS `a` from `test`.`t1` join `test`.`t2` join lateral (/* select#2 */ select `test`.`t1`.`a` AS `a`) `dt` +flush status; +select * from t1, t2, lateral (select t1.a) as dt; +a b a b a +1 NULL 1 NULL 1 +1 NULL 2 NULL 1 +2 NULL 1 NULL 2 +2 NULL 2 NULL 2 +show status like "handler_write"; +Variable_name Value +Handler_write 2 +# This one finds the best plan. Yes we simply swapped tables in the query, +# and it yields a different plan. This is because the order specified by +# the user is sorted by number of rows, which leaves it +# unchanged (Card(t1)=Card(t2)=Card(dt), then it is the first +# explored plan so it's explored in full and so is never pruned by +# prune_level=1, and it is the best plan. Best as: it reads +# "dt" less, and t2 uses join buffering (which is ok as it's +# after "dt"). +# If prune_level=0, all 3 variants here produce this plan. +explain select * from t1, lateral (select t1.a) as dt, t2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 2 100.00 Rematerialize () +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +2 DEPENDENT DERIVED NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`dt`.`a` AS `a`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` join lateral (/* select#2 */ select `test`.`t1`.`a` AS `a`) `dt` join `test`.`t2` +flush status; +select * from t1, lateral (select t1.a) as dt, t2; +a b a a b +1 NULL 1 1 NULL +1 NULL 1 2 NULL +2 NULL 2 1 NULL +2 NULL 2 2 NULL +show status like "handler_write"; +Variable_name Value +Handler_write 2 +# This one is intermediate: t1 uses join buffer (good), but +# "dt" is last (bad, as it has high scan cost). +explain select * from t2, t1, lateral (select t1.a) as dt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 2 100.00 Rematerialize (); Using join buffer (hash join) +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DEPENDENT DERIVED NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`dt`.`a` AS `a` from `test`.`t2` join `test`.`t1` join lateral (/* select#2 */ select `test`.`t1`.`a` AS `a`) `dt` +flush status; +select * from t2, t1, lateral (select t1.a) as dt; +a b a b a +1 NULL 1 NULL 1 +1 NULL 2 NULL 2 +2 NULL 1 NULL 1 +2 NULL 2 NULL 2 +show status like "handler_write"; +Variable_name Value +Handler_write 2 +# Show the trace of planning of lateral derived tables +explain select * from t1, lateral (select t1.a from t2 as t3, t2 as t4) as dt, t2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 2 100.00 Rematerialize () +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 PRIMARY NULL ALL NULL NULL NULL NULL 4 100.00 NULL +2 DEPENDENT DERIVED t3 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DEPENDENT DERIVED t4 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`dt`.`a` AS `a`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` join lateral (/* select#2 */ select `test`.`t1`.`a` AS `a` from `test`.`t2` `t3` join `test`.`t2` `t4`) `dt` join `test`.`t2` +select trace from information_schema.optimizer_trace; +trace +{ + "steps": [ + { + "join_preparation": { + "select#": 1, + "steps": [ + { + "join_preparation": { + "select#": 2, + "steps": [ + { + "expanded_query": "/* select#2 */ select `t1`.`a` AS `a` from `t2` `t3` join `t2` `t4`" + } + ] + } + }, + { + "derived": { + "table": " `dt`", + "select#": 2, + "materialized": true + } + }, + { + "expanded_query": "/* select#1 */ select `t1`.`a` AS `a`,`t1`.`b` AS `b`,`dt`.`a` AS `a`,`t2`.`a` AS `a`,`t2`.`b` AS `b` from `t1` join lateral (/* select#2 */ select `t1`.`a` AS `a` from `t2` `t3` join `t2` `t4`) `dt` join `t2`" + } + ] + } + }, + { + "join_optimization": { + "select#": 1, + "steps": [ + { + "join_optimization": { + "select#": 2, + "steps": [ + { + "table_dependencies": [ + { + "table": "`t2` `t3`", + "row_may_be_null": false, + "map_bit": 0, + "depends_on_map_bits": [ + ] + }, + { + "table": "`t2` `t4`", + "row_may_be_null": false, + "map_bit": 1, + "depends_on_map_bits": [ + ] + } + ] + }, + { + "rows_estimation": [ + { + "table": "`t2` `t3`", + "table_scan": { + "rows": 2, + "cost": 0.25 + } + }, + { + "table": "`t2` `t4`", + "table_scan": { + "rows": 2, + "cost": 0.25 + } + } + ] + }, + { + "considered_execution_plans": [ + { + "plan_prefix": [ + ], + "table": "`t2` `t3`", + "best_access_path": { + "considered_access_paths": [ + { + "rows_to_scan": 2, + "access_type": "scan", + "resulting_rows": 2, + "cost": 0.45, + "chosen": true + } + ] + }, + "condition_filtering_pct": 100, + "rows_for_plan": 2, + "cost_for_plan": 0.45, + "rest_of_plan": [ + { + "plan_prefix": [ + "`t2` `t3`" + ], + "table": "`t2` `t4`", + "best_access_path": { + "considered_access_paths": [ + { + "rows_to_scan": 2, + "access_type": "scan", + "using_join_cache": true, + "buffers_needed": 1, + "resulting_rows": 2, + "cost": 0.65, + "chosen": true + } + ] + }, + "condition_filtering_pct": 100, + "rows_for_plan": 4, + "cost_for_plan": 1.1, + "chosen": true + } + ] + }, + { + "plan_prefix": [ + ], + "table": "`t2` `t4`", + "best_access_path": { + "considered_access_paths": [ + { + "rows_to_scan": 2, + "access_type": "scan", + "resulting_rows": 2, + "cost": 0.45, + "chosen": true + } + ] + }, + "condition_filtering_pct": 100, + "rows_for_plan": 2, + "cost_for_plan": 0.45, + "pruned_by_heuristic": true + } + ] + }, + { + "attaching_conditions_to_tables": { + "original_condition": null, + "attached_conditions_computation": [ + ], + "attached_conditions_summary": [ + { + "table": "`t2` `t3`", + "attached": null + }, + { + "table": "`t2` `t4`", + "attached": null + } + ] + } + }, + { + "finalizing_table_conditions": [ + ] + }, + { + "refine_plan": [ + { + "table": "`t2` `t3`" + }, + { + "table": "`t2` `t4`" + } + ] + } + ] + } + }, + { + "table_dependencies": [ + { + "table": "`t1`", + "row_may_be_null": false, + "map_bit": 0, + "depends_on_map_bits": [ + ] + }, + { + "table": " `dt`", + "row_may_be_null": false, + "map_bit": 1, + "depends_on_map_bits": [ + 0 + ] + }, + { + "table": "`t2`", + "row_may_be_null": false, + "map_bit": 2, + "depends_on_map_bits": [ + ] + } + ] + }, + { + "rows_estimation": [ + { + "table": "`t1`", + "table_scan": { + "rows": 2, + "cost": 0.25 + } + }, + { + "table": " `dt`", + "table_scan": { + "rows": 4, + "cost": 2.55 + } + }, + { + "table": "`t2`", + "table_scan": { + "rows": 2, + "cost": 0.25 + } + } + ] + }, + { + "considered_execution_plans": [ + { + "plan_prefix": [ + ], + "table": "`t1`", + "best_access_path": { + "considered_access_paths": [ + { + "rows_to_scan": 2, + "access_type": "scan", + "resulting_rows": 2, + "cost": 0.45, + "chosen": true + } + ] + }, + "condition_filtering_pct": 100, + "rows_for_plan": 2, + "cost_for_plan": 0.45, + "rest_of_plan": [ + { + "plan_prefix": [ + "`t1`" + ], + "table": "`t2`", + "best_access_path": { + "considered_access_paths": [ + { + "rows_to_scan": 2, + "access_type": "scan", + "resulting_rows": 2, + "cost": 0.9, + "chosen": true + } + ] + }, + "condition_filtering_pct": 100, + "rows_for_plan": 4, + "cost_for_plan": 1.35, + "rest_of_plan": [ + { + "plan_prefix": [ + "`t1`", + "`t2`" + ], + "table": " `dt`", + "best_access_path": { + "considered_access_paths": [ + { + "lateral_materialization": { + "cost_for_one_run_of_inner_query": 1.099, + "cost_for_writing_to_tmp_table": 0.4, + "count_of_runs": 2, + "total_cost": 2.998, + "cost_per_read": 0.7495 + } + }, + { + "rows_to_scan": 4, + "access_type": "scan", + "resulting_rows": 4, + "cost": 11.8, + "chosen": true + } + ] + }, + "condition_filtering_pct": 100, + "rows_for_plan": 16, + "cost_for_plan": 13.8995, + "chosen": true + } + ] + }, + { + "plan_prefix": [ + "`t1`" + ], + "table": " `dt`", + "best_access_path": { + "considered_access_paths": [ + { + "lateral_materialization": { + "cost_for_one_run_of_inner_query": 1.099, + "cost_for_writing_to_tmp_table": 0.4, + "count_of_runs": 2, + "total_cost": 2.998, + "cost_per_read": 1.499 + } + }, + { + "rows_to_scan": 4, + "access_type": "scan", + "resulting_rows": 4, + "cost": 5.9, + "chosen": true + } + ] + }, + "condition_filtering_pct": 100, + "rows_for_plan": 8, + "cost_for_plan": 7.849, + "pruned_by_heuristic": true + } + ] + }, + { + "plan_prefix": [ + ], + "table": "`t2`", + "best_access_path": { + "considered_access_paths": [ + { + "rows_to_scan": 2, + "access_type": "scan", + "resulting_rows": 2, + "cost": 0.45, + "chosen": true + } + ] + }, + "condition_filtering_pct": 100, + "rows_for_plan": 2, + "cost_for_plan": 0.45, + "pruned_by_heuristic": true + } + ] + }, + { + "attaching_conditions_to_tables": { + "original_condition": null, + "attached_conditions_computation": [ + ], + "attached_conditions_summary": [ + { + "table": "`t1`", + "attached": null + }, + { + "table": "`t2`", + "attached": null + }, + { + "table": " `dt`", + "attached": null + } + ] + } + }, + { + "finalizing_table_conditions": [ + ] + }, + { + "refine_plan": [ + { + "table": "`t1`" + }, + { + "table": "`t2`" + }, + { + "table": " `dt`", + "rematerialized_for_each_row_of": "t1" + } + ] + } + ] + } + }, + { + "join_explain": { + "select#": 1, + "steps": [ + { + "join_explain": { + "select#": 2, + "steps": [ + ] + } + } + ] + } + } + ] +} +# LDT depending on const table only +create table t3(a int) engine=innodb; +insert into t3 values(3); +analyze table t3; +Table Op Msg_type Msg_text +test.t3 analyze status OK +explain select * from t3, lateral (select t3.a+1) as dt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t3 NULL ALL NULL NULL NULL NULL 1 100.00 Rematerialize () +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DEPENDENT DERIVED NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1276 Field or reference 'test.t3.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a`,`dt`.`t3.a+1` AS `t3.a+1` from `test`.`t3` join lateral (/* select#2 */ select (`test`.`t3`.`a` + 1) AS `t3.a+1`) `dt` +select * from t3, lateral (select t3.a+1) as dt; +a t3.a+1 +3 4 +drop table t3; +# Two LDTs depending on different tables +explain select * from t2, t1, lateral (select t1.a) as dt, +lateral (select t2.a) as dt2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 2 100.00 Rematerialize () +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 2 100.00 Rematerialize () +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 NULL +3 DEPENDENT DERIVED NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +2 DEPENDENT DERIVED NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 +Note 1276 Field or reference 'test.t2.a' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`dt`.`a` AS `a`,`dt2`.`a` AS `a` from `test`.`t2` join `test`.`t1` join lateral (/* select#2 */ select `test`.`t1`.`a` AS `a`) `dt` join lateral (/* select#3 */ select `test`.`t2`.`a` AS `a`) `dt2` +select * from t2, t1, lateral (select t1.a) as dt, +lateral (select t2.a) as dt2; +a b a b a a +1 NULL 1 NULL 1 1 +1 NULL 2 NULL 2 1 +2 NULL 1 NULL 1 2 +2 NULL 2 NULL 2 2 +# Two LDTs depending on one same table +explain select * from t2, t1, lateral (select t1.a) as dt, +lateral (select t1.a+1) as dt2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 2 100.00 Rematerialize (,); Using join buffer (hash join) +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 NULL +3 DEPENDENT DERIVED NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +2 DEPENDENT DERIVED NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 +Note 1276 Field or reference 'test.t1.a' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`dt`.`a` AS `a`,`dt2`.`t1.a+1` AS `t1.a+1` from `test`.`t2` join `test`.`t1` join lateral (/* select#2 */ select `test`.`t1`.`a` AS `a`) `dt` join lateral (/* select#3 */ select (`test`.`t1`.`a` + 1) AS `t1.a+1`) `dt2` +explain format=json select * from t2, t1, lateral (select t1.a) as dt, +lateral (select t1.a+1) as dt2; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "34.10" + }, + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 2, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.20", + "prefix_cost": "0.45", + "data_read_per_join": "32" + }, + "used_columns": [ + "a", + "b" + ] + } + }, + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 4, + "filtered": "100.00", + "rematerialize": "dt,dt2", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.40", + "prefix_cost": "1.10", + "data_read_per_join": "64" + }, + "used_columns": [ + "a", + "b" + ] + } + }, + { + "table": { + "table_name": "dt", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 8, + "filtered": "100.00", + "cost_info": { + "read_cost": "10.30", + "eval_cost": "0.80", + "prefix_cost": "12.20", + "data_read_per_join": "128" + }, + "used_columns": [ + "a" + ], + "materialized_from_subquery": { + "using_temporary_table": true, + "dependent": true, + "cacheable": true, + "query_block": { + "select_id": 2, + "message": "No tables used" + } + } + } + }, + { + "table": { + "table_name": "dt2", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 16, + "filtered": "100.00", + "cost_info": { + "read_cost": "20.30", + "eval_cost": "1.60", + "prefix_cost": "34.10", + "data_read_per_join": "256" + }, + "used_columns": [ + "t1.a+1" + ], + "materialized_from_subquery": { + "using_temporary_table": true, + "dependent": true, + "cacheable": true, + "query_block": { + "select_id": 3, + "message": "No tables used" + } + } + } + } + ] + } +} +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 +Note 1276 Field or reference 'test.t1.a' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`dt`.`a` AS `a`,`dt2`.`t1.a+1` AS `t1.a+1` from `test`.`t2` join `test`.`t1` join lateral (/* select#2 */ select `test`.`t1`.`a` AS `a`) `dt` join lateral (/* select#3 */ select (`test`.`t1`.`a` + 1) AS `t1.a+1`) `dt2` +select * from t2, t1, lateral (select t1.a) as dt, +lateral (select t1.a+1) as dt2; +a b a b a t1.a+1 +1 NULL 1 NULL 1 2 +1 NULL 2 NULL 2 3 +2 NULL 1 NULL 1 2 +2 NULL 2 NULL 2 3 +# One LDT depending on two tables. The "rematerialize" tag is +# properly added to the 2nd dependency only. +explain select * from t2, t1, lateral (select t1.a+t2.a) as dt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 2 100.00 Rematerialize () +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DEPENDENT DERIVED NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 +Note 1276 Field or reference 'test.t2.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`dt`.`t1.a+t2.a` AS `t1.a+t2.a` from `test`.`t2` join `test`.`t1` join lateral (/* select#2 */ select (`test`.`t1`.`a` + `test`.`t2`.`a`) AS `t1.a+t2.a`) `dt` +explain format=json select * from t2, t1, lateral (select t1.a+t2.a) as dt; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "12.45" + }, + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 2, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.20", + "prefix_cost": "0.45", + "data_read_per_join": "32" + }, + "used_columns": [ + "a", + "b" + ] + } + }, + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 4, + "filtered": "100.00", + "rematerialize": "dt", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.40", + "prefix_cost": "1.35", + "data_read_per_join": "64" + }, + "used_columns": [ + "a", + "b" + ] + } + }, + { + "table": { + "table_name": "dt", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 8, + "filtered": "100.00", + "cost_info": { + "read_cost": "10.30", + "eval_cost": "0.80", + "prefix_cost": "12.45", + "data_read_per_join": "128" + }, + "used_columns": [ + "t1.a+t2.a" + ], + "materialized_from_subquery": { + "using_temporary_table": true, + "dependent": true, + "cacheable": true, + "query_block": { + "select_id": 2, + "message": "No tables used" + } + } + } + } + ] + } +} +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 +Note 1276 Field or reference 'test.t2.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`dt`.`t1.a+t2.a` AS `t1.a+t2.a` from `test`.`t2` join `test`.`t1` join lateral (/* select#2 */ select (`test`.`t1`.`a` + `test`.`t2`.`a`) AS `t1.a+t2.a`) `dt` +select * from t2, t1, lateral (select t1.a+t2.a) as dt; +a b a b t1.a+t2.a +1 NULL 1 NULL 2 +1 NULL 2 NULL 3 +2 NULL 1 NULL 3 +2 NULL 2 NULL 4 +select json_extract(trace,"$.steps[*].join_optimization.steps[*].refine_plan") from information_schema.optimizer_trace; +json_extract(trace,"$.steps[*].join_optimization.steps[*].refine_plan") +[[{"table": "`t2`"}, {"table": "`t1`"}, {"table": " `dt`", "rematerialized_for_each_row_of": "t1"}]] +# Test when a dependency of LDT uses BKA: BKA code must +# refresh LDT's content when it provides a row. +set @old_opt_switch=@@optimizer_switch; +set @@optimizer_switch="batched_key_access=on,mrr_cost_based=off"; +CREATE TABLE t11 (t11a int, t11b int); +INSERT INTO t11 VALUES (99, NULL),(99, 3),(99,0); +CREATE TABLE t12 (t12a int, t12b int, KEY idx (t12b)); +INSERT INTO t12 VALUES (100,0),(150,200),(999, 0),(999, NULL); +ANALYZE TABLE t11,t12; +Table Op Msg_type Msg_text +test.t11 analyze status OK +test.t12 analyze status OK +explain SELECT * FROM t11 LEFT JOIN t12 force index (idx) ON t12.t12b = t11.t11b +JOIN LATERAL (SELECT t12a) dt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t11 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY t12 NULL ref idx idx 5 test.t11.t11b 1 100.00 Rematerialize (); Using join buffer (Batched Key Access) +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DEPENDENT DERIVED NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1276 Field or reference 'test.t12.t12a' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t11`.`t11a` AS `t11a`,`test`.`t11`.`t11b` AS `t11b`,`test`.`t12`.`t12a` AS `t12a`,`test`.`t12`.`t12b` AS `t12b`,`dt`.`t12a` AS `t12a` from `test`.`t11` left join `test`.`t12` FORCE INDEX (`idx`) on((`test`.`t12`.`t12b` = `test`.`t11`.`t11b`)) join lateral (/* select#2 */ select `test`.`t12`.`t12a` AS `t12a`) `dt` where true +flush status; +SELECT * FROM t11 LEFT JOIN t12 force index (idx) ON t12.t12b = t11.t11b +JOIN LATERAL (SELECT t12a) dt; +t11a t11b t12a t12b t12a +99 0 100 0 100 +99 0 999 0 999 +99 NULL NULL NULL NULL +99 3 NULL NULL NULL +show status like "handler_write"; +Variable_name Value +Handler_write 4 +DROP TABLE t11,t12; +set @@optimizer_switch=@old_opt_switch; +# Test that with an auto_key on the lateral DT, the index is +# properly emptied and re-filled when re-materializing. +# If index weren't emptied, we'd see too many "11" matches for 2nd +# row of t1; and if not re-filled, we'd see no matches for that. +create table t3 (a int, b int); +insert into t3 values(1, 10), (1, 11), (2, 10), (2, 11); +analyze table t3; +Table Op Msg_type Msg_text +test.t3 analyze status OK +# Note the auto_key with "Using index", to test the index as +# much as possible. +explain select * from t1, lateral (select t3.b from t3 where t3.a=t1.a) dt +where dt.b=t1.a+9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 2 100.00 Rematerialize () +1 PRIMARY NULL ref 5 func 2 100.00 Using where; Using index +2 DEPENDENT DERIVED t3 NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`dt`.`b` AS `b` from `test`.`t1` join lateral (/* select#2 */ select `test`.`t3`.`b` AS `b` from `test`.`t3` where (`test`.`t3`.`a` = `test`.`t1`.`a`)) `dt` where (`dt`.`b` = (`test`.`t1`.`a` + 9)) +select * from t1, lateral (select t3.b from t3 where t3.a=t1.a) dt +where dt.b=t1.a+9; +a b b +1 NULL 10 +2 NULL 11 +drop table t3; +set optimizer_switch='derived_merge=off'; +# Reserved word +create table lateral(a int); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'lateral(a int)' at line 1 +drop table t1,t2; +# +# Bug#28723670 RECENT REGRESSION: CRASH/ASSERTION IN FIND_FIELD_IN_TABLE_REF +# +CREATE TABLE t(x INT); +# Don't search for 'y' in top SELECT +SELECT 1 FROM +(SELECT 1 FROM (SELECT (SELECT y FROM t) FROM t) AS a) AS b; +ERROR 42S22: Unknown column 'y' in 'field list' +DROP TABLE t; +# +# Bug#28976533 ASSERTION `JOIN->BEST_READ < DOUBLE(1.79769313486231570814527423731704357E+308L) +# +CREATE TABLE bb ( +pk INTEGER AUTO_INCREMENT, +col_int INTEGER , +col_int_key INTEGER , +col_time_key TIME , +col_time TIME , +col_datetime_key DATETIME , +col_datetime DATETIME , +col_varchar_key VARCHAR(20) , +col_varchar VARCHAR(20) , +PRIMARY KEY (pk DESC), +KEY (col_time_key), +KEY (col_time_key DESC) +); +SET SQL_MODE=''; +EXPLAIN SELECT +grandparent1.col_varchar_key AS g1 FROM bb AS grandparent1 +LEFT JOIN bb AS grandparent2 USING ( col_time ) +WHERE grandparent1.col_int_key IN +( +WITH qn AS ( +SELECT parent1.col_int AS p1 +FROM bb AS parent1 LEFT JOIN bb AS parent2 USING ( col_varchar ) +WHERE parent1.col_varchar_key IN +( +WITH qn1 AS ( +SELECT DISTINCT child1.col_varchar_key AS C1 +FROM bb AS child1 LEFT JOIN bb AS child2 +ON child1.col_varchar_key <= child2.col_varchar +WHERE child1.col_time > grandparent1.col_datetime +) +SELECT * FROM qn1 +) +AND parent1.col_time_key BETWEEN '2008-03-18' AND +'2004-11-14' + ) +SELECT /*+ MERGE(qn) */ * FROM qn +) +GROUP BY grandparent1.col_int; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables +5 DEPENDENT DERIVED child1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using temporary +5 DEPENDENT DERIVED child2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Distinct; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.grandparent1.col_datetime' of SELECT #5 was resolved in SELECT #1 +Warning 1292 Incorrect time value: '2008-03-18' for column 'col_time_key' at row 1 +Warning 1292 Incorrect time value: '2004-11-14' for column 'col_time_key' at row 1 +Warning 1292 Incorrect time value: '2008-03-18' for column 'col_time_key' at row 1 +Warning 1292 Incorrect time value: '2008-03-18' for column 'col_time_key' at row 1 +Warning 1292 Incorrect time value: '2004-11-14' for column 'col_time_key' at row 1 +Warning 1292 Incorrect time value: '2004-11-14' for column 'col_time_key' at row 1 +Note 1003 /* select#1 */ select /*+ MERGE(`qn`@`select#2`) */ `test`.`grandparent1`.`col_varchar_key` AS `g1` from `test`.`bb` `grandparent1` left join `test`.`bb` `grandparent2` on(multiple equal(`test`.`grandparent1`.`col_time`, `test`.`grandparent2`.`col_time`)) semi join (`test`.`bb` `parent1` left join `test`.`bb` `parent2` on((`test`.`parent1`.`col_varchar` = `test`.`parent2`.`col_varchar`)) join `qn1`) where ((`test`.`parent1`.`col_time_key` between '2008-03-18' and '2004-11-14') and multiple equal(`test`.`grandparent1`.`col_int_key`, `test`.`parent1`.`col_int`) and multiple equal(`test`.`parent1`.`col_varchar_key`, `qn1`.`C1`)) group by `test`.`grandparent1`.`col_int` +SELECT +grandparent1.col_varchar_key AS g1 FROM bb AS grandparent1 +LEFT JOIN bb AS grandparent2 USING ( col_time ) +WHERE grandparent1.col_int_key IN +( +WITH qn AS ( +SELECT parent1.col_int AS p1 +FROM bb AS parent1 LEFT JOIN bb AS parent2 USING ( col_varchar ) +WHERE parent1.col_varchar_key IN +( +WITH qn1 AS ( +SELECT DISTINCT child1.col_varchar_key AS C1 +FROM bb AS child1 LEFT JOIN bb AS child2 +ON child1.col_varchar_key <= child2.col_varchar +WHERE child1.col_time > grandparent1.col_datetime +) +SELECT * FROM qn1 +) +AND parent1.col_time_key BETWEEN '2008-03-18' AND +'2004-11-14' + ) +SELECT /*+ MERGE(qn) */ * FROM qn +) +GROUP BY grandparent1.col_int; +g1 +Warnings: +Warning 1292 Incorrect time value: '2008-03-18' for column 'col_time_key' at row 1 +Warning 1292 Incorrect time value: '2004-11-14' for column 'col_time_key' at row 1 +Warning 1292 Incorrect time value: '2008-03-18' for column 'col_time_key' at row 1 +Warning 1292 Incorrect time value: '2008-03-18' for column 'col_time_key' at row 1 +Warning 1292 Incorrect time value: '2004-11-14' for column 'col_time_key' at row 1 +Warning 1292 Incorrect time value: '2004-11-14' for column 'col_time_key' at row 1 +DROP TABLE bb; +SET SQL_MODE=DEFAULT; +# +# Bug #29268512: ASSERTION FAILED: INITED == NONE INTERMITTENTLY +# +CREATE TABLE t1 ( +f1 integer +); +INSERT INTO t1 VALUES (0),(1); +CREATE TABLE t2 ( +f2 integer +); +SELECT * FROM t1, LATERAL ( SELECT MAX(1) FROM t2 GROUP BY t1.f1 ) AS l1; +f1 MAX(1) +DROP TABLE t1, t2; +# +# Bug #29334082: Still crashing in actual_key_parts() / assert inited == INDEX +# +CREATE TABLE t1 ( f1 INTEGER ); +CREATE TABLE t2 ( f2 LONGBLOB ); +INSERT INTO t1 VALUES (1); +INSERT INTO t2 VALUES ('abc'),('def'); +SELECT STD(0) FROM t2, LATERAL ( SELECT f1 FROM t1 GROUP BY f2,f1 ) AS d1; +STD(0) +0 +DROP TABLE t1, t2; +# +# Bug#28954838 ASSERTION `(REMAINING_TABLES_AFTER != 0) || ((CUR_EMBEDDING_MAP == 0) && (JOIN-> +# +CREATE TABLE t1 ( +pk INTEGER, +col_int INT not null, +col_int_key INT not null, +col_time_gckey TIME, +col_varchar VARCHAR(20) not null, +col_varchar_key VARCHAR(15) not null +); +CREATE TABLE t2 ( +pk INTEGER, +col_int INT not null, +col_varchar VARCHAR(20) not null, +col_varchar_key VARCHAR(15) not null +); +SET OPTIMIZER_SWITCH='derived_merge=off'; +SELECT table1.col_varchar_key AS field1, +table2.col_time_gckey AS field2 +FROM t2 AS table1 STRAIGHT_JOIN t1 AS table2 +ON table2.col_varchar_key = table1.col_varchar_key +WHERE table2.col_int_key IN +(WITH qn AS +(SELECT sq1_t1.col_int AS sq1_field1 +FROM t2 AS sq1_t1 +WHERE sq1_t1.col_varchar_key = table2.col_varchar OR +EXISTS (WITH qn1 AS +(SELECT c_sq1_t1.col_int_key AS c_sq1_field1 +FROM t1 AS c_sq1_t1 +WHERE c_sq1_t1.col_varchar_key > sq1_t1.col_varchar OR +c_sq1_t1.col_int <> c_sq1_t1.pk +) +SELECT * FROM qn1 +) +) +SELECT * FROM qn +) AND +EXISTS (WITH qn AS +(SELECT sq2_t1.col_varchar AS sq2_field1 +FROM t1 AS sq2_t1 STRAIGHT_JOIN +t2 AS sq2_t2 INNER JOIN t1 AS sq2_t3 +ON sq2_t3.col_varchar = sq2_t2.col_varchar_key +ON sq2_t3.col_int = sq2_t2.pk +) +SELECT * FROM qn +) AND +table2.col_varchar_key <> 'j'; +field1 field2 +SET OPTIMIZER_SWITCH=DEFAULT; +DROP TABLE t1,t2; +# +# Bug#28955358 VIRTUAL LONGLONG FIELD_NEWDATE::VAL_DATE_TEMPORAL(): ASSERTION `!TABLE || (!TAB +# +CREATE TABLE t1 ( +pk INTEGER, col_int_key INTEGER NOT NULL, +col_date_key DATE NOT NULL, col_datetime DATETIME NOT NULL +); +INSERT INTO t1 VALUES (0, 0, '2006-07-18', '2001-09-06 02:13:59.021506'); +SELECT /*+ no_merge() */ outr.pk AS x +FROM ( SELECT * FROM t1 ) AS outr +WHERE outr.col_int_key IN +( SELECT /*+ no_merge() no_semijoin() */ 2 +FROM (SELECT 1 AS x FROM t1 AS innr WHERE outr.col_date_key ) AS +qn ) +ORDER BY outr.col_datetime; +x +SELECT /*+ no_merge() */ outr.pk AS x +FROM ( SELECT * FROM t1 ) AS outr +WHERE outr.col_int_key IN +( SELECT /*+ no_merge() no_semijoin() */ id +FROM JSON_TABLE( IF(outr.col_date_key<>NOW(), +'[{"a":"3"},{"a":2},{"b":1},{"a":0}]', +'') , +'$[*]' columns (id for ordinality, +jpath varchar(100) path '$.a', +jexst int exists path '$.b') ) AS +qn ) +ORDER BY outr.col_datetime; +x +DROP TABLE t1; +CREATE TABLE t1(pk INT PRIMARY KEY, a INT); +EXPLAIN SELECT pk FROM t1 GROUP BY a; +ERROR 42000: Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'test.t1.pk' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +EXPLAIN SELECT (SELECT pk FROM (SELECT t1.pk) dt) FROM t1 GROUP BY a; +ERROR 42000: Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'test.t1.pk' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +DROP TABLE t1; +# +# Bug#28960857 ASSERTION FAILED: !TR->DERIVED_WHERE_COND || TR->DERIVED_WHERE_COND->FIXED +# Bug#28960789 ASSERTION FAILED: TRANSL->ITEM->FIXED, +# +CREATE TABLE t0007 ( +c0008 date NOT NULL, +c0009 char(234) NOT NULL +); +CREATE TABLE t0008 ( +c0005 tinytext NOT NULL +); +CREATE TABLE t0009 ( +c0000 time NOT NULL +); +SET SQL_MODE=0; +SELECT (SELECT t0007.c0009 FROM (SELECT t0007.c0008 AS c0003 +FROM t0009 ) AS t0005 ) FROM t0007 +GROUP BY -23; +(SELECT t0007.c0009 FROM (SELECT t0007.c0008 AS c0003 +FROM t0009 ) AS t0005 ) +SELECT (SELECT c0009 +FROM (SELECT 1 AS c0003 +FROM t0009 INNER JOIN t0008 +ON t0008.c0005 +WHERE t0007.c0008 +) AS t0005 +GROUP BY c0008 +), +COUNT(c0009) +FROM t0007 +GROUP BY 1, 1; +(SELECT c0009 +FROM (SELECT 1 AS c0003 +FROM t0009 INNER JOIN t0008 +ON t0008.c0005 +WHERE t0007.c0008 +) AS t0005 +GROUP BY c0008 +) COUNT(c0009) +DROP TABLE t0007, t0008, t0009; +SET SQL_MODE=DEFAULT; +# +# Bug #29514504: WRONG RESULT WITH CORRELATED LATERAL JOIN +# +CREATE TABLE t1 (id INTEGER); +CREATE TABLE t2 (id INTEGER); +INSERT INTO t1 VALUES (10), (20), (30); +INSERT INTO t2 VALUES (20), (20); +SELECT * FROM t1 JOIN LATERAL ( +SELECT GROUP_CONCAT(t.id) AS c FROM t2 t WHERE (t.id = t1.id) +) d0 ON (1); +id c +10 NULL +20 20,20 +30 NULL +DROP TABLE t1, t2; +# +# Bug #30110851: SUBQUERY INVOLVES COUNT() AGGREGATE FUNCTION PERFORMANCE REGRESSION +# +CREATE TABLE t1 ( f1 INTEGER NOT NULL, f2 INTEGER NOT NULL ); +CREATE TABLE t2 ( f1 INTEGER NOT NULL, f2 INTEGER NOT NULL ); +CREATE ALGORITHM=TEMPTABLE VIEW v1 AS SELECT * FROM t1; +CREATE ALGORITHM=TEMPTABLE VIEW v2 AS SELECT ( SELECT f2 FROM v1 WHERE v1.f1 = t2.f1 ) AS f3 FROM t2; +EXPLAIN FORMAT=TREE SELECT * FROM v2 WHERE f3 = 3; +EXPLAIN +-> Index lookup on v2 using (f3=3) + -> Materialize (cost=0.45..0.45 rows=1) + -> Table scan on t2 (cost=0.35 rows=1) + -> Select #3 (subquery in projection; dependent) + -> Index lookup on v1 using (f1=t2.f1) + -> Materialize (cost=0.45..0.45 rows=1) + -> Table scan on t1 (cost=0.35 rows=1) + +Warnings: +Note 1276 Field or reference 'test.t2.f1' of SELECT #3 was resolved in SELECT #2 +DROP TABLE t1, t2; +DROP VIEW v1, v2; +# +# Bug#30627575 ASSERT: `INITED == NONE' IN HANDLER::HA_INDEX_INIT() AT SQL/HANDLER.CC +# +CREATE TABLE t1( +a INT, +b INT NOT NULL, +c INT NOT NULL, +d INT, +UNIQUE KEY (c,b) +); +INSERT INTO t1 VALUES (1,1,1,50), (1,2,3,40), (2,1,3,4); +CREATE TABLE t2( +a INT, +b INT, +UNIQUE KEY(a,b) +); +INSERT INTO t2 VALUES (NULL, NULL), (NULL, NULL), (NULL, 1), (1, NULL), (1, 1), (1,2); +ANALYZE TABLE t1,t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN SELECT * FROM t1 JOIN LATERAL (SELECT a+t1.a from t2 GROUP BY a) AS dt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 3 100.00 Rematerialize () +1 PRIMARY NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 DEPENDENT DERIVED t2 NULL range a a 5 NULL 3 100.00 Using index for group-by +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c`,`test`.`t1`.`d` AS `d`,`dt`.`a+t1.a` AS `a+t1.a` from `test`.`t1` join lateral (/* select#2 */ select (`test`.`t2`.`a` + `test`.`t1`.`a`) AS `a+t1.a` from `test`.`t2` group by `test`.`t2`.`a`) `dt` +SELECT * FROM t1 JOIN LATERAL (SELECT a+t1.a from t2 GROUP BY a) AS dt; +a b c d a+t1.a +1 1 1 50 NULL +1 1 1 50 2 +2 1 3 4 NULL +2 1 3 4 3 +1 2 3 40 NULL +1 2 3 40 2 +DROP TABLE t1, t2; +# +# Bug#30887665 ASSERT: `SELECT_LEX->IS_RECURSIVE()' IN JOIN::MAKE_JOIN_PLAN() +# +CREATE TABLE t1 (c1 VARCHAR(1)); +CREATE VIEW v1 AS SELECT * FROM t1; +SELECT 1 FROM +v1 AS table1 RIGHT OUTER JOIN LATERAL +(SELECT 1 FROM v1 AS table2 RIGHT OUTER JOIN LATERAL +( SELECT 1 FROM v1 AS table3 ) AS table4 +ON table1.c1 = 1) AS table5 +ON 1; +ERROR 42S22: Unknown column 'table1.c1' in 'on clause' +DROP VIEW v1; +DROP TABLE t1; +# +# Bug #32113029: WRONG RESULT PRODUCED WHEN LEFT JOINING INFORMATION_SCHEMA TABLES +# +CREATE TABLE t1 ( id INTEGER ); +INSERT INTO t1 VALUES (1); +CREATE TABLE t2 ( table_id integer ); +INSERT INTO t2 VALUES (363); +CREATE TABLE t3 ( id integer ); +INSERT INTO t3 VALUES (362); +INSERT INTO t3 VALUES (363); +ANALYZE TABLE t1, t2, t3; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +set optimizer_switch='derived_merge=off'; +SELECT * +FROM t1 +LEFT JOIN ( +t3, LATERAL ( +SELECT * FROM t2 WHERE table_id = t3.id +) l1 +) ON TRUE; +id id table_id +1 363 363 +SELECT * +FROM t1 +LEFT JOIN ( +t3, LATERAL ( +SELECT * FROM t2 WHERE table_id = t3.id +) l1 +) ON TRUE and t3.id=363; +id id table_id +1 363 363 +set optimizer_switch=DEFAULT; +DROP TABLE t1, t2, t3; diff --git a/mysql-test/r/desc_index_innodb.result-pq b/mysql-test/r/desc_index_innodb.result-pq new file mode 100644 index 000000000000..cce5553cff60 --- /dev/null +++ b/mysql-test/r/desc_index_innodb.result-pq @@ -0,0 +1,1718 @@ +create table t1(f1 int, key f1_idx(f1 desc)) engine=heap; +ERROR 42000: The storage engine for the table doesn't support descending indexes +create table +t1(a int, b int, key a_desc_b_asc (a desc, b), key a_asc_b_desc (a, b desc)) +engine= innodb; +flush tables; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int DEFAULT NULL, + `b` int DEFAULT NULL, + KEY `a_desc_b_asc` (`a` DESC,`b`), + KEY `a_asc_b_desc` (`a`,`b` DESC) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +insert into t1 values(1,6),(1,5),(2,5),(2,4),(3,4),(3,3), +(4,3),(4,2),(5,2),(5,1),(6,1),(NULL,NULL); +analyze table t1; +# Should use index +explain select * from t1 order by a desc; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # # Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL a_desc_b_asc 10 NULL # # Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` order by `test`.`t1`.`a` desc +select * from t1 order by a desc; +a b +6 1 +5 1 +5 2 +4 2 +4 3 +3 3 +3 4 +2 4 +2 5 +1 5 +1 6 +NULL NULL +explain select * from t1 order by a desc, b asc; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # # Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL a_desc_b_asc 10 NULL # # Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` order by `test`.`t1`.`a` desc,`test`.`t1`.`b` +select * from t1 order by a desc, b asc; +a b +6 1 +5 1 +5 2 +4 2 +4 3 +3 3 +3 4 +2 4 +2 5 +1 5 +1 6 +NULL NULL +explain select * from t1 order by a asc; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # # Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL a_asc_b_desc 10 NULL # # Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` order by `test`.`t1`.`a` +select * from t1 order by a asc, b desc; +a b +NULL NULL +1 6 +1 5 +2 5 +2 4 +3 4 +3 3 +4 3 +4 2 +5 2 +5 1 +6 1 +explain select * from t1 order by a asc, b desc; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # # Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL a_asc_b_desc 10 NULL # # Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` order by `test`.`t1`.`a`,`test`.`t1`.`b` desc +select * from t1 order by a asc, b desc; +a b +NULL NULL +1 6 +1 5 +2 5 +2 4 +3 4 +3 3 +4 3 +4 2 +5 2 +5 1 +6 1 +explain select * from t1 group by a,b order by a, b desc; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # # Parallel execute (1 workers) +2 SIMPLE t1 NULL index a_desc_b_asc,a_asc_b_desc a_asc_b_desc 10 NULL # # Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` group by `test`.`t1`.`a`,`test`.`t1`.`b` desc order by `test`.`t1`.`a`,`test`.`t1`.`b` desc +select * from t1 group by a,b order by a, b desc; +a b +NULL NULL +1 6 +1 5 +2 5 +2 4 +3 4 +3 3 +4 3 +4 2 +5 2 +5 1 +6 1 +# For GROUP BY optimizer can pick any order for column, +explain select * from t1 group by a, b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # # Parallel execute (1 workers) +2 SIMPLE t1 NULL index a_desc_b_asc,a_asc_b_desc a_desc_b_asc 10 NULL # # Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` group by `test`.`t1`.`a`,`test`.`t1`.`b` +explain select * from t1 group by a, b order by a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # # Parallel execute (1 workers) +2 SIMPLE t1 NULL index a_desc_b_asc,a_asc_b_desc a_asc_b_desc 10 NULL # # Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` group by `test`.`t1`.`a`,`test`.`t1`.`b` order by `test`.`t1`.`a` +explain select * from t1 group by a , b order by a desc; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # # Parallel execute (1 workers) +2 SIMPLE t1 NULL index a_desc_b_asc,a_asc_b_desc a_desc_b_asc 10 NULL # # Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` group by `test`.`t1`.`a` desc,`test`.`t1`.`b` order by `test`.`t1`.`a` desc +explain select * from t1 group by a, b order by a desc, b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # # Parallel execute (1 workers) +2 SIMPLE t1 NULL index a_desc_b_asc,a_asc_b_desc a_desc_b_asc 10 NULL # # Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` group by `test`.`t1`.`a` desc,`test`.`t1`.`b` order by `test`.`t1`.`a` desc,`test`.`t1`.`b` +explain select * from t1 group by a, b order by a asc, b desc; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # # Parallel execute (1 workers) +2 SIMPLE t1 NULL index a_desc_b_asc,a_asc_b_desc a_asc_b_desc 10 NULL # # Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` group by `test`.`t1`.`a`,`test`.`t1`.`b` desc order by `test`.`t1`.`a`,`test`.`t1`.`b` desc +alter table t1 drop index a_asc_b_desc; +explain select * from t1 group by a, b order by a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # # Backward index scan; Parallel execute (1 workers) +2 SIMPLE t1 NULL index a_desc_b_asc a_desc_b_asc 10 NULL # # Backward index scan; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` group by `test`.`t1`.`a`,`test`.`t1`.`b` order by `test`.`t1`.`a` +explain select distinct a from t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range a_desc_b_asc a_desc_b_asc 5 NULL # # Using index for group-by +Warnings: +Note 1003 /* select#1 */ select distinct `test`.`t1`.`a` AS `a` from `test`.`t1` +select distinct a from t1; +a +1 +2 +3 +4 +5 +6 +NULL +explain select a from t1 group by a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range a_desc_b_asc a_desc_b_asc 5 NULL # # Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` group by `test`.`t1`.`a` +select a from t1 group by a; +a +1 +2 +3 +4 +5 +6 +NULL +# Should use index backward +explain select * from t1 order by a asc; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # # Backward index scan; Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL a_desc_b_asc 10 NULL # # Backward index scan; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` order by `test`.`t1`.`a` +select * from t1 order by a asc, b desc; +a b +NULL NULL +1 6 +1 5 +2 5 +2 4 +3 4 +3 3 +4 3 +4 2 +5 2 +5 1 +6 1 +explain select * from t1 order by a asc, b desc; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # # Backward index scan; Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL a_desc_b_asc 10 NULL # # Backward index scan; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` order by `test`.`t1`.`a`,`test`.`t1`.`b` desc +select * from t1 order by a asc, b desc; +a b +NULL NULL +1 6 +1 5 +2 5 +2 4 +3 4 +3 3 +4 3 +4 2 +5 2 +5 1 +6 1 +# Should use filesort +explain select * from t1 order by a desc, b desc; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # # Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL a_desc_b_asc 10 NULL # # Using index; Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` order by `test`.`t1`.`a` desc,`test`.`t1`.`b` desc +select * from t1 order by a desc, b desc; +a b +6 1 +5 2 +5 1 +4 3 +4 2 +3 4 +3 3 +2 5 +2 4 +1 6 +1 5 +NULL NULL +explain select * from t1 order by a asc, b asc; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # # Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL a_desc_b_asc 10 NULL # # Using index; Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` order by `test`.`t1`.`a`,`test`.`t1`.`b` +select * from t1 order by a asc, b asc; +a b +NULL NULL +1 5 +1 6 +2 4 +2 5 +3 3 +3 4 +4 2 +4 3 +5 1 +5 2 +6 1 +create index i1 on t1 (a desc, a asc); +ERROR 42S21: Duplicate column name 'a' +create index i1 on t1 (a desc, b desc); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int DEFAULT NULL, + `b` int DEFAULT NULL, + KEY `a_desc_b_asc` (`a` DESC,`b`), + KEY `i1` (`a` DESC,`b` DESC) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +create table t2 (a int auto_increment, primary key (a desc)) engine= innodb; +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `a` int NOT NULL AUTO_INCREMENT, + PRIMARY KEY (`a` DESC) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +insert ignore into t2 select a from t1; +Warnings: +Warning 1062 Duplicate entry '5' for key 't2.PRIMARY' +Warning 1062 Duplicate entry '4' for key 't2.PRIMARY' +Warning 1062 Duplicate entry '3' for key 't2.PRIMARY' +Warning 1062 Duplicate entry '2' for key 't2.PRIMARY' +Warning 1062 Duplicate entry '1' for key 't2.PRIMARY' +select * from t2; +a +7 +6 +5 +4 +3 +2 +1 +create table t3 (a varchar(10), key i1(a(5) desc)) engine= innodb; +flush tables; +show create table t3; +Table Create Table +t3 CREATE TABLE `t3` ( + `a` varchar(10) DEFAULT NULL, + KEY `i1` (`a`(5) DESC) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +create index i2 on t3(a(6)); +flush tables; +show create table t3; +Table Create Table +t3 CREATE TABLE `t3` ( + `a` varchar(10) DEFAULT NULL, + KEY `i1` (`a`(5) DESC), + KEY `i2` (`a`(6)) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +alter table t3 add fulltext index fts_idx(a desc); +ERROR HY000: Incorrect usage of spatial/fulltext/hash index and explicit index order +alter table t3 add fulltext index fts_idx(a asc); +ERROR HY000: Incorrect usage of spatial/fulltext/hash index and explicit index order +alter table t3 add column b point not null, add spatial index gis_idx(b desc); +ERROR HY000: Incorrect usage of spatial/fulltext/hash index and explicit index order +alter table t3 add column b point not null, add spatial index gis_idx(b asc); +ERROR HY000: Incorrect usage of spatial/fulltext/hash index and explicit index order +create table t4 (a text, fulltext key fts(a desc)); +ERROR HY000: Incorrect usage of spatial/fulltext/hash index and explicit index order +create table t4 (a point not null, spatial key gis(a desc)); +ERROR HY000: Incorrect usage of spatial/fulltext/hash index and explicit index order +create table t4 (a text, fulltext key fts(a asc)); +ERROR HY000: Incorrect usage of spatial/fulltext/hash index and explicit index order +create table t4 (a point not null, spatial key gis(a asc)); +ERROR HY000: Incorrect usage of spatial/fulltext/hash index and explicit index order +create table t5 (f1 int, key h(f1 asc) using hash) engine= heap; +ERROR HY000: Incorrect usage of spatial/fulltext/hash index and explicit index order +create table t5 (f1 int, key h(f1 desc) using hash) engine= heap; +ERROR HY000: Incorrect usage of spatial/fulltext/hash index and explicit index order +create table t5 (f1 int, key h(f1) using hash) engine= heap; +drop table t1,t2,t3,t5; +CREATE TABLE t0 (i INTEGER); +INSERT INTO t0 VALUES (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +CREATE TABLE t1 (i1 INTEGER NOT NULL, i2 INTEGER NOT NULL, +i3 INTEGER NOT NULL, KEY k1 (i1 desc, i2) +) ENGINE= innodb; +INSERT INTO t1 +SELECT a.i*10 + b.i + 1, a.i*100 + b.i*10 + c.i, a.i +FROM t0 AS a, t0 AS b, t0 AS c; +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT * FROM t1 +WHERE i1 BETWEEN 50 AND 52 AND MOD(i2,2)=1 ORDER BY i1 DESC; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 30 100.00 Parallel execute (2 workers) +2 SIMPLE t1 NULL range k1 k1 4 NULL 30 100.00 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i1` AS `i1`,`test`.`t1`.`i2` AS `i2`,`test`.`t1`.`i3` AS `i3` from `test`.`t1` where ((`test`.`t1`.`i1` between 50 and 52) and ((`test`.`t1`.`i2` % 2) = 1)) order by `test`.`t1`.`i1` desc +SELECT * FROM t1 +WHERE i1 BETWEEN 50 AND 52 AND MOD(i2,2)=1 ORDER BY i1 DESC; +i1 i2 i3 +52 511 5 +52 513 5 +52 515 5 +52 517 5 +52 519 5 +51 501 5 +51 503 5 +51 505 5 +51 507 5 +51 509 5 +50 491 4 +50 493 4 +50 495 4 +50 497 4 +50 499 4 +EXPLAIN SELECT * FROM t1 +WHERE (i1 BETWEEN 50 AND 52 OR i1 BETWEEN 70 AND 72) AND MOD(i2,2)=1 +ORDER BY i1 DESC; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 60 100.00 Parallel execute (3 workers) +2 SIMPLE t1 NULL range k1 k1 4 NULL 60 100.00 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i1` AS `i1`,`test`.`t1`.`i2` AS `i2`,`test`.`t1`.`i3` AS `i3` from `test`.`t1` where (((`test`.`t1`.`i1` between 50 and 52) or (`test`.`t1`.`i1` between 70 and 72)) and ((`test`.`t1`.`i2` % 2) = 1)) order by `test`.`t1`.`i1` desc +SELECT * FROM t1 +WHERE (i1 BETWEEN 50 AND 52 OR i1 BETWEEN 70 AND 72) AND MOD(i2,2)=1 +ORDER BY i1 DESC; +i1 i2 i3 +50 491 4 +50 493 4 +50 495 4 +50 497 4 +50 499 4 +51 501 5 +51 503 5 +51 505 5 +51 507 5 +51 509 5 +52 511 5 +52 513 5 +52 515 5 +52 517 5 +52 519 5 +70 691 6 +70 693 6 +70 695 6 +70 697 6 +70 699 6 +71 701 7 +71 703 7 +71 705 7 +71 707 7 +71 709 7 +72 711 7 +72 713 7 +72 715 7 +72 717 7 +72 719 7 +EXPLAIN SELECT * FROM t1 +WHERE ( (i1=50 AND i2=495) OR i1 BETWEEN 70 AND 72) AND MOD(i2,2)=1 +ORDER BY i1 DESC; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 31 100.00 Parallel execute (2 workers) +2 SIMPLE t1 NULL range k1 k1 8 NULL 31 100.00 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i1` AS `i1`,`test`.`t1`.`i2` AS `i2`,`test`.`t1`.`i3` AS `i3` from `test`.`t1` where ((((`test`.`t1`.`i2` = 495) and (`test`.`t1`.`i1` = 50)) or (`test`.`t1`.`i1` between 70 and 72)) and ((`test`.`t1`.`i2` % 2) = 1)) order by `test`.`t1`.`i1` desc +SELECT * FROM t1 +WHERE ( (i1=50 AND i2=495) OR i1 BETWEEN 70 AND 72) AND MOD(i2,2)=1 +ORDER BY i1 DESC; +i1 i2 i3 +50 495 4 +70 691 6 +70 693 6 +70 695 6 +70 697 6 +70 699 6 +71 701 7 +71 703 7 +71 705 7 +71 707 7 +71 709 7 +72 711 7 +72 713 7 +72 715 7 +72 717 7 +72 719 7 +EXPLAIN SELECT * FROM t1 WHERE i1 >= 50 AND i1 < 52 AND MOD(i2,2)=1 ORDER BY i1 DESC; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 20 100.00 Parallel execute (2 workers) +2 SIMPLE t1 NULL range k1 k1 4 NULL 20 100.00 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i1` AS `i1`,`test`.`t1`.`i2` AS `i2`,`test`.`t1`.`i3` AS `i3` from `test`.`t1` where ((`test`.`t1`.`i1` >= 50) and (`test`.`t1`.`i1` < 52) and ((`test`.`t1`.`i2` % 2) = 1)) order by `test`.`t1`.`i1` desc +SELECT * FROM t1 WHERE i1 >= 50 AND i1 < 52 AND MOD(i2,2)=1 ORDER BY i1 DESC; +i1 i2 i3 +51 501 5 +51 503 5 +51 505 5 +51 507 5 +51 509 5 +50 491 4 +50 493 4 +50 495 4 +50 497 4 +50 499 4 +EXPLAIN SELECT * FROM t1 WHERE i1 > 50 AND i1 <= 52 AND MOD(i2,2)=1 ORDER BY i1 DESC; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 20 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range k1 k1 4 NULL 20 100.00 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i1` AS `i1`,`test`.`t1`.`i2` AS `i2`,`test`.`t1`.`i3` AS `i3` from `test`.`t1` where ((`test`.`t1`.`i1` > 50) and (`test`.`t1`.`i1` <= 52) and ((`test`.`t1`.`i2` % 2) = 1)) order by `test`.`t1`.`i1` desc +SELECT * FROM t1 WHERE i1 > 50 AND i1 <= 52 AND MOD(i2,2)=1 ORDER BY i1 DESC; +i1 i2 i3 +52 511 5 +52 513 5 +52 515 5 +52 517 5 +52 519 5 +51 501 5 +51 503 5 +51 505 5 +51 507 5 +51 509 5 +ALTER TABLE t1 DROP INDEX k1, ADD INDEX k1(i1, i2); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT * FROM t1 +WHERE i1 BETWEEN 50 AND 52 AND MOD(i2,2)=1 ORDER BY i1 DESC; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 30 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range k1 k1 4 NULL 30 100.00 Using index condition; Backward index scan +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i1` AS `i1`,`test`.`t1`.`i2` AS `i2`,`test`.`t1`.`i3` AS `i3` from `test`.`t1` where ((`test`.`t1`.`i1` between 50 and 52) and ((`test`.`t1`.`i2` % 2) = 1)) order by `test`.`t1`.`i1` desc +SELECT * FROM t1 +WHERE i1 BETWEEN 50 AND 52 AND MOD(i2,2)=1 ORDER BY i1 DESC; +i1 i2 i3 +52 511 5 +52 513 5 +52 515 5 +52 517 5 +52 519 5 +51 501 5 +51 503 5 +51 505 5 +51 507 5 +51 509 5 +50 491 4 +50 493 4 +50 495 4 +50 497 4 +50 499 4 +ALTER TABLE t1 DROP INDEX k1, ADD INDEX k1(i1, i2 DESC); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT * FROM t1 +WHERE i1 BETWEEN 50 AND 52 AND i2 BETWEEN 495 AND 515 ORDER BY i1, i2 DESC; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 30 11.11 Parallel execute (1 workers) +2 SIMPLE t1 NULL range k1 k1 8 NULL 30 11.11 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i1` AS `i1`,`test`.`t1`.`i2` AS `i2`,`test`.`t1`.`i3` AS `i3` from `test`.`t1` where ((`test`.`t1`.`i1` between 50 and 52) and (`test`.`t1`.`i2` between 495 and 515)) order by `test`.`t1`.`i1`,`test`.`t1`.`i2` desc +SELECT * FROM t1 +WHERE i1 BETWEEN 50 AND 52 AND i2 BETWEEN 495 AND 515 ORDER BY i1, i2 DESC; +i1 i2 i3 +50 499 4 +50 498 4 +50 497 4 +50 496 4 +50 495 4 +51 509 5 +51 508 5 +51 507 5 +51 506 5 +51 505 5 +51 504 5 +51 503 5 +51 502 5 +51 501 5 +51 500 5 +52 515 5 +52 514 5 +52 513 5 +52 512 5 +52 511 5 +52 510 5 +ALTER TABLE t1 DROP INDEX k1, ADD INDEX k1(i1, i2 DESC, i3); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT * FROM t1 +WHERE i1 BETWEEN 48 AND 62 AND i2 BETWEEN 395 AND 615 AND +i3 BETWEEN 4 AND 5 AND MOD(i1,2)=0 AND MOD(i2,2)=1 +ORDER BY i1, i2 DESC; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 150 1.23 Parallel execute (1 workers) +2 SIMPLE t1 NULL range k1 k1 12 NULL 150 1.23 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i1` AS `i1`,`test`.`t1`.`i2` AS `i2`,`test`.`t1`.`i3` AS `i3` from `test`.`t1` where ((`test`.`t1`.`i1` between 48 and 62) and (`test`.`t1`.`i2` between 395 and 615) and (`test`.`t1`.`i3` between 4 and 5) and ((`test`.`t1`.`i1` % 2) = 0) and ((`test`.`t1`.`i2` % 2) = 1)) order by `test`.`t1`.`i1`,`test`.`t1`.`i2` desc +SELECT * FROM t1 +WHERE i1 BETWEEN 48 AND 62 AND i2 BETWEEN 395 AND 615 AND +i3 BETWEEN 4 AND 5 AND MOD(i1,2)=0 AND MOD(i2,2)=1 +ORDER BY i1, i2 DESC; +i1 i2 i3 +48 479 4 +48 477 4 +48 475 4 +48 473 4 +48 471 4 +50 499 4 +50 497 4 +50 495 4 +50 493 4 +50 491 4 +52 519 5 +52 517 5 +52 515 5 +52 513 5 +52 511 5 +54 539 5 +54 537 5 +54 535 5 +54 533 5 +54 531 5 +56 559 5 +56 557 5 +56 555 5 +56 553 5 +56 551 5 +58 579 5 +58 577 5 +58 575 5 +58 573 5 +58 571 5 +60 599 5 +60 597 5 +60 595 5 +60 593 5 +60 591 5 +ALTER TABLE t1 DROP INDEX k1, ADD INDEX k1(i1, i2 DESC, i3 DESC); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT * FROM t1 +WHERE i1 BETWEEN 48 AND 62 AND i2 BETWEEN 395 AND 615 AND +i3 BETWEEN 4 AND 5 AND MOD(i1,2)=0 AND MOD(i2,2)=1 +ORDER BY i1, i2 DESC; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 150 1.23 Parallel execute (1 workers) +2 SIMPLE t1 NULL range k1 k1 12 NULL 150 1.23 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i1` AS `i1`,`test`.`t1`.`i2` AS `i2`,`test`.`t1`.`i3` AS `i3` from `test`.`t1` where ((`test`.`t1`.`i1` between 48 and 62) and (`test`.`t1`.`i2` between 395 and 615) and (`test`.`t1`.`i3` between 4 and 5) and ((`test`.`t1`.`i1` % 2) = 0) and ((`test`.`t1`.`i2` % 2) = 1)) order by `test`.`t1`.`i1`,`test`.`t1`.`i2` desc +SELECT * FROM t1 +WHERE i1 BETWEEN 48 AND 62 AND i2 BETWEEN 395 AND 615 AND +i3 BETWEEN 4 AND 5 AND MOD(i1,2)=0 AND MOD(i2,2)=1 +ORDER BY i1, i2 DESC; +i1 i2 i3 +48 479 4 +48 477 4 +48 475 4 +48 473 4 +48 471 4 +50 499 4 +50 497 4 +50 495 4 +50 493 4 +50 491 4 +52 519 5 +52 517 5 +52 515 5 +52 513 5 +52 511 5 +54 539 5 +54 537 5 +54 535 5 +54 533 5 +54 531 5 +56 559 5 +56 557 5 +56 555 5 +56 553 5 +56 551 5 +58 579 5 +58 577 5 +58 575 5 +58 573 5 +58 571 5 +60 599 5 +60 597 5 +60 595 5 +60 593 5 +60 591 5 +ALTER TABLE t1 DROP INDEX k1, ADD INDEX k1(i1, i2 DESC, i3); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT * FROM t1 WHERE +((i1 BETWEEN 48 AND 62 AND i2 BETWEEN 395 AND 615 AND +i3 BETWEEN 4 AND 5) or i1 between 70 and 72) AND +MOD(i1,2)=0 AND MOD(i2,2)=1 +ORDER BY i1 desc, i2 ; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 180 100.00 Parallel execute (3 workers) +2 SIMPLE t1 NULL range k1 k1 12 NULL 180 100.00 Using where; Using index; Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i1` AS `i1`,`test`.`t1`.`i2` AS `i2`,`test`.`t1`.`i3` AS `i3` from `test`.`t1` where ((((`test`.`t1`.`i1` between 48 and 62) and (`test`.`t1`.`i2` between 395 and 615) and (`test`.`t1`.`i3` between 4 and 5)) or (`test`.`t1`.`i1` between 70 and 72)) and ((`test`.`t1`.`i1` % 2) = 0) and ((`test`.`t1`.`i2` % 2) = 1)) order by `test`.`t1`.`i1` desc,`test`.`t1`.`i2` +SELECT * FROM t1 WHERE +((i1 BETWEEN 48 AND 62 AND i2 BETWEEN 395 AND 615 AND +i3 BETWEEN 4 AND 5) or i1 between 70 and 72) AND +MOD(i1,2)=0 AND MOD(i2,2)=1 +ORDER BY i1 desc, i2 ; +i1 i2 i3 +72 711 7 +72 713 7 +72 715 7 +72 717 7 +72 719 7 +70 691 6 +70 693 6 +70 695 6 +70 697 6 +70 699 6 +60 591 5 +60 593 5 +60 595 5 +60 597 5 +60 599 5 +58 571 5 +58 573 5 +58 575 5 +58 577 5 +58 579 5 +56 551 5 +56 553 5 +56 555 5 +56 557 5 +56 559 5 +54 531 5 +54 533 5 +54 535 5 +54 537 5 +54 539 5 +52 511 5 +52 513 5 +52 515 5 +52 517 5 +52 519 5 +50 491 4 +50 493 4 +50 495 4 +50 497 4 +50 499 4 +48 471 4 +48 473 4 +48 475 4 +48 477 4 +48 479 4 +ALTER TABLE t1 DROP INDEX k1, ADD INDEX k1(i1 DESC, i2, i3); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT * FROM t1 WHERE +((i1 BETWEEN 48 AND 62 AND i2 BETWEEN 395 AND 615 AND +i3 BETWEEN 4 AND 5) or i1 between 70 and 72) AND +MOD(i1,2)=0 AND MOD(i2,2)=1 +ORDER BY i1 desc, i2 ; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 180 100.00 Parallel execute (2 workers) +2 SIMPLE t1 NULL range k1 k1 12 NULL 180 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i1` AS `i1`,`test`.`t1`.`i2` AS `i2`,`test`.`t1`.`i3` AS `i3` from `test`.`t1` where ((((`test`.`t1`.`i1` between 48 and 62) and (`test`.`t1`.`i2` between 395 and 615) and (`test`.`t1`.`i3` between 4 and 5)) or (`test`.`t1`.`i1` between 70 and 72)) and ((`test`.`t1`.`i1` % 2) = 0) and ((`test`.`t1`.`i2` % 2) = 1)) order by `test`.`t1`.`i1` desc,`test`.`t1`.`i2` +SELECT * FROM t1 WHERE +((i1 BETWEEN 48 AND 62 AND i2 BETWEEN 395 AND 615 AND +i3 BETWEEN 4 AND 5) or i1 between 70 and 72) AND +MOD(i1,2)=0 AND MOD(i2,2)=1 +ORDER BY i1 desc, i2 ; +i1 i2 i3 +72 711 7 +72 713 7 +72 715 7 +72 717 7 +72 719 7 +70 691 6 +70 693 6 +70 695 6 +70 697 6 +70 699 6 +60 591 5 +60 593 5 +60 595 5 +60 597 5 +60 599 5 +58 571 5 +58 573 5 +58 575 5 +58 577 5 +58 579 5 +56 551 5 +56 553 5 +56 555 5 +56 557 5 +56 559 5 +54 531 5 +54 533 5 +54 535 5 +54 537 5 +54 539 5 +52 511 5 +52 513 5 +52 515 5 +52 517 5 +52 519 5 +50 491 4 +50 493 4 +50 495 4 +50 497 4 +50 499 4 +48 471 4 +48 473 4 +48 475 4 +48 477 4 +48 479 4 +ALTER TABLE t1 DROP INDEX k1, ADD INDEX k1(i1 DESC, i2, i3); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT * FROM t1 +WHERE ( (i1=50 AND i2=495 and i3=4) OR i1 BETWEEN 70 AND 72) AND +MOD(i2,2)=1 +ORDER BY i1 DESC; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 31 100.00 Parallel execute (2 workers) +2 SIMPLE t1 NULL range k1 k1 12 NULL 31 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i1` AS `i1`,`test`.`t1`.`i2` AS `i2`,`test`.`t1`.`i3` AS `i3` from `test`.`t1` where ((((`test`.`t1`.`i3` = 4) and (`test`.`t1`.`i2` = 495) and (`test`.`t1`.`i1` = 50)) or (`test`.`t1`.`i1` between 70 and 72)) and ((`test`.`t1`.`i2` % 2) = 1)) order by `test`.`t1`.`i1` desc +SELECT * FROM t1 +WHERE ( (i1=50 AND i2=495 and i3=4) OR i1 BETWEEN 70 AND 72) AND +MOD(i2,2)=1 +ORDER BY i1 DESC; +i1 i2 i3 +72 711 7 +72 713 7 +72 715 7 +72 717 7 +72 719 7 +71 701 7 +71 703 7 +71 705 7 +71 707 7 +71 709 7 +70 691 6 +70 693 6 +70 695 6 +70 697 6 +70 699 6 +50 495 4 +ALTER TABLE t1 ADD COLUMN (i4 INTEGER NOT NULL); +UPDATE t1 SET i4=i3; +ALTER TABLE t1 DROP INDEX k1, ADD INDEX k1(i1 DESC, i2, i3 DESC, i4); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT * FROM t1 WHERE +((i1 BETWEEN 48 AND 62 AND i2 BETWEEN 395 AND 615 AND +i3 BETWEEN 4 AND 5 AND i4 BETWEEN 5 AND 6) OR +i1 between 70 and 72) AND MOD(i1,2)=0 AND MOD(i2,2)=1 +ORDER BY i1 desc, i2 ; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 180 100.00 Parallel execute (2 workers) +2 SIMPLE t1 NULL range k1 k1 16 NULL 180 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i1` AS `i1`,`test`.`t1`.`i2` AS `i2`,`test`.`t1`.`i3` AS `i3`,`test`.`t1`.`i4` AS `i4` from `test`.`t1` where ((((`test`.`t1`.`i1` between 48 and 62) and (`test`.`t1`.`i2` between 395 and 615) and (`test`.`t1`.`i3` between 4 and 5) and (`test`.`t1`.`i4` between 5 and 6)) or (`test`.`t1`.`i1` between 70 and 72)) and ((`test`.`t1`.`i1` % 2) = 0) and ((`test`.`t1`.`i2` % 2) = 1)) order by `test`.`t1`.`i1` desc,`test`.`t1`.`i2` +SELECT * FROM t1 WHERE +((i1 BETWEEN 48 AND 62 AND i2 BETWEEN 395 AND 615 AND +i3 BETWEEN 4 AND 5 AND i4 BETWEEN 5 AND 6) OR +i1 between 70 and 72) AND MOD(i1,2)=0 AND MOD(i2,2)=1 +ORDER BY i1 desc, i2 ; +i1 i2 i3 i4 +72 711 7 7 +72 713 7 7 +72 715 7 7 +72 717 7 7 +72 719 7 7 +70 691 6 6 +70 693 6 6 +70 695 6 6 +70 697 6 6 +70 699 6 6 +60 591 5 5 +60 593 5 5 +60 595 5 5 +60 597 5 5 +60 599 5 5 +58 571 5 5 +58 573 5 5 +58 575 5 5 +58 577 5 5 +58 579 5 5 +56 551 5 5 +56 553 5 5 +56 555 5 5 +56 557 5 5 +56 559 5 5 +54 531 5 5 +54 533 5 5 +54 535 5 5 +54 537 5 5 +54 539 5 5 +52 511 5 5 +52 513 5 5 +52 515 5 5 +52 517 5 5 +52 519 5 5 +DROP TABLE t0, t1; +CREATE TABLE t1 (a INT, b INT, KEY i1 (a DESC, b DESC)); +INSERT INTO t1 (a, b) VALUES (1,1), (1,2), (1,3); +INSERT INTO t1 SELECT a + 1, b FROM t1; +INSERT INTO t1 SELECT a + 2, b FROM t1; +INSERT INTO t1 SELECT a + 4, b FROM t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN +SELECT a, MIN(b), MAX(b) FROM t1 GROUP BY a ORDER BY a DESC; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range i1 i1 10 NULL 9 100.00 Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,min(`test`.`t1`.`b`) AS `MIN(b)`,max(`test`.`t1`.`b`) AS `MAX(b)` from `test`.`t1` group by `test`.`t1`.`a` desc order by `test`.`t1`.`a` desc +SELECT a, MIN(b), MAX(b) FROM t1 GROUP BY a ORDER BY a DESC; +a MIN(b) MAX(b) +8 1 3 +7 1 3 +6 1 3 +5 1 3 +4 1 3 +3 1 3 +2 1 3 +1 1 3 +DROP TABLE t1; +create table t1 (a int not null, b int, c varchar(10), +key (a desc, b desc, c desc)); +insert into t1 values (1, NULL, NULL), (1, NULL, 'b'), (1, 1, NULL), (1, 1, 'b'), (1, 1, 'b'), (2, 1, 'a'), (2, 1, 'b'), (2, 2, 'a'), (2, 2, 'b'), (2, 3, 'c'),(1,3,'b'); +insert into t1 values (0, NULL, NULL), (0, NULL, 'b'), (0, 0, NULL), (0, 0, 'b'), (0, 0, 'b'), (0, 0, 'a'), (0, 0, 'b'), (0, 0, 'a'), (0, 0, 'b'), (0, 0, 'c'),(0,0,'b'); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +explain select * from t1 where a >= 1 and a < 3 and b >0 order by a desc,b desc; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 9 33.33 Parallel execute (1 workers) +2 SIMPLE t1 NULL range a a 9 NULL 9 33.33 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` where ((`test`.`t1`.`a` >= 1) and (`test`.`t1`.`a` < 3) and (`test`.`t1`.`b` > 0)) order by `test`.`t1`.`a` desc,`test`.`t1`.`b` desc +flush status; +select * from t1 where a >= 1 and a < 3 and b >0 order by a desc,b desc; +a b c +2 1 a +2 1 b +2 2 a +2 2 b +2 3 c +1 1 NULL +1 1 b +1 1 b +1 3 b +show status like 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 2 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 10 +drop table t1; +create table t1 (a1 int, a2 char(3), key k1(a1 desc)); +insert into t1 values(10,'aaa'), (10,null), (10,'bbb'), (20,'zzz'); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +# Shouldn't optimize tables away on DESC index +explain select min(a1) from t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # # Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL k1 5 NULL # # Using index +Warnings: +Note 1003 /* select#1 */ select min(`test`.`t1`.`a1`) AS `min(a1)` from `test`.`t1` +select min(a1) from t1; +min(a1) +10 +drop table t1; +CREATE TABLE t1 +(a VARCHAR(10), +b VARCHAR(10), +KEY ab_asc (a ASC, b ASC), +KEY a_asc_b_desc (a ASC, b DESC), +key a_desc_b_asc (a DESC, b ASC)) +ENGINE = InnoDB +PARTITION BY KEY (a, b) PARTITIONS 3; +INSERT INTO t1 VALUES ("0", "0"), ("1", "1"), ("2", "2"), ("3", "3"), +("4", "4"), ("55", "55"), ("54", "54"), ("1", "2"), ("1", "4"), ("1", "3"), +("55", "54"), ("0", "1"), (NULL,NULL),(0, NULL), (1,NULL); +SELECT * FROM t1 ORDER BY a, b DESC; +a b +NULL NULL +0 1 +0 0 +0 NULL +1 4 +1 3 +1 2 +1 1 +1 NULL +2 2 +3 3 +4 4 +54 54 +55 55 +55 54 +DROP TABLE t1; +# +# Bug#23036049: WL1074:ASSERTION `CTX->CUR <= CTX->LAST' FAILED. +# +CREATE TABLE c ( +pk INTEGER AUTO_INCREMENT, +col_int INTEGER NOT NULL, +col_varchar VARCHAR(5) NOT NULL, +unique KEY (pk,col_int DESC) +) ENGINE= innodb; +INSERT IGNORE INTO c (col_int,col_varchar) VALUES +(7, 'm'),(0, 'alukq'),(8, 'lu'),(6, 'uk'), (5, 'kquk'),(9, 'qukko'),(0, 'u'), +(181, 'kkoei'),(3, 'ko'),(86, 'oei'); +CREATE TABLE cc ( +pk INTEGER AUTO_INCREMENT, +col_int INTEGER NOT NULL, +col_varchar VARCHAR(5) NOT NULL, +unique KEY (pk,col_int DESC) +) ENGINE= innodb; +INSERT IGNORE INTO cc (col_int,col_varchar) VALUES +(9, 'gktbk'),(0, 'k'),(4, 'tbkj'),(8, 'bk'),(9, 'kjrk'),(2,'j'),(7, 'r'), +(4, 'kmqmk'),(0, 'm'),(4, 'qmkn'); +SELECT DISTINCT t2.col_int +FROM ( c AS t1 INNER JOIN cc AS t2 ON (t2.col_varchar = t1.col_varchar)) +WHERE ( t1.col_int IN ( 167, 9)) +AND t1.pk = 122; +col_int +DROP TABLE c,cc; +# +CREATE TABLE b ( +pk INTEGER AUTO_INCREMENT, +col_int_key INTEGER /*! NULL */, +col_varchar_key VARCHAR(10) /*! NULL */, +PRIMARY KEY (pk DESC), +KEY (col_varchar_key DESC, col_int_key DESC) +) ENGINE= innodb; +INSERT /*! IGNORE */ INTO b (col_int_key,col_varchar_key) VALUES +(3, 'ceksatef'),(3, 'eks'),(3, 'ksatefqs'),(6, 'sate'),(3, 'a'); +CREATE TABLE cc ( +pk INTEGER , +col_int_key INTEGER /*! NULL */, +col_varchar_key VARCHAR(10) /*! NULL */ +) ENGINE= innodb; +INSERT /*! IGNORE */ INTO cc (col_int_key, col_varchar_key) VALUES +(NULL, 'koeiwsgpmf'),(8, 'oeiwsgpm'),(8, 'eiwsg'),(0,'iwsg'),(5, 'wsgpmfy'), +(1, 'sgpmfyvvu'),(7, 'gpmfyvvu'),(7, 'pmfyvvu'),(147, 'mfyv'),(2, NULL); +# Shouldn't crash +SELECT +DISTINCT OUTR . col_varchar_key +FROM b AS OUTR WHERE ( OUTR . col_int_key , OUTR . pk ) IN +( +SELECT DISTINCT +INNR . pk AS x , +INNR . pk AS y +FROM cc AS INNR WHERE OUTR . col_varchar_key = 'v' +) +AND OUTR . pk >= 3 ; +col_varchar_key +DROP TABLE b; +CREATE TABLE b ( +pk INTEGER AUTO_INCREMENT, +col_int_key INTEGER /*! NULL */, +col_varchar_key VARCHAR(10) /*! NULL */, +PRIMARY KEY (pk DESC), +KEY (col_varchar_key, col_int_key) +) ENGINE= innodb; +INSERT /*! IGNORE */ INTO b (col_int_key,col_varchar_key) +VALUES (3, 'ceksatef'),(3, 'eks'),(3, 'ksatefqs'),(6, 'sate'),(3, 'a'); +# Shouldn't crash +SELECT +DISTINCT OUTR . col_varchar_key +FROM b AS OUTR WHERE ( OUTR . col_int_key , OUTR . pk ) IN +( +SELECT DISTINCT +INNR . pk AS x , +INNR . pk AS y +FROM cc AS INNR WHERE OUTR . col_varchar_key = 'v' +) +AND OUTR . pk >= 3 ; +col_varchar_key +DROP TABLE b,cc; +# +# +# Bug#23212656:JOIN QUERY WITH RANGE PREDICATES GIVES INCORRECT RESULTS +# +CREATE TABLE ee ( +col_int int(11) DEFAULT NULL, +col_int_key int(11) DEFAULT NULL, +pk int(11) NOT NULL AUTO_INCREMENT, +PRIMARY KEY (pk DESC), +KEY 1col_int_key (col_int_key DESC) +) ENGINE=innodb; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO ee VALUES +(NULL,NULL,1), (NULL,NULL,2), (NULL,286720000,3), (NULL,1,4), +(2084831232,8,5), (NULL,0,6), (4,763953152,7), (5,NULL,8), (7,9,9); +SELECT DISTINCT alias1 . col_int_key AS field1 , alias1 . col_int AS field2 +FROM ee AS alias1 JOIN ee AS alias2 ON alias1 . pk = alias2 . col_int_key +WHERE ( alias1 . pk BETWEEN 8 AND ( 8 + 4 ) AND alias2 . pk <> 2 ); +field1 field2 +9 7 +NULL 5 +DROP TABLE ee; +# +# +# Bug#23217803:QUERY USING INDEX_MERGE_SORT_UNION GIVES INCORRECT +# RESULTS WITH DESC KEY +# +CREATE TABLE t ( +pk INTEGER AUTO_INCREMENT, +col_int INTEGER , +col_int_key INTEGER , +col_varchar_key VARCHAR(10) , +col_varchar VARCHAR(10) , +PRIMARY KEY (pk DESC), +KEY (col_varchar_key DESC), +UNIQUE KEY (col_int_key DESC, pk) +) ENGINE=innodb; +INSERT INTO t (col_int_key, col_int, col_varchar_key) +VALUES (1, 2, NULL),(NULL, 3, 'dks'), (7, 0, 'ksjijcsz'),(172, 84, 'sj'); +SELECT col_int FROM t AS table1 WHERE table1 .pk > 166 OR table1 +.col_varchar_key = 'c' OR table1 .col_int_key > 166 LIMIT 1; +col_int +84 +DROP TABLE t; +# +# +# BUG#22973383:INNODB ASSERTION IN ROW_SEL_CONVERT_MYSQL_KEY_TO_INNOBASE +# +CREATE TABLE c ( +col_varchar_10_utf8_key varchar(10) CHARACTER SET utf8 DEFAULT NULL, +unique key k5 (col_varchar_10_utf8_key(7) DESC) +) ENGINE=innodb; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +CREATE TABLE e ( +col_varchar_10_utf8_key varchar(10) CHARACTER SET utf8 DEFAULT NULL, +col_varchar_255_utf8_key varchar(255) CHARACTER SET utf8 DEFAULT NULL, +col_varchar_10_latin1_key varchar(10) DEFAULT NULL, +unique key k5 (col_varchar_10_utf8_key(7) DESC, +col_varchar_10_latin1_key(5) DESC, col_varchar_255_utf8_key(50) DESC) +) ENGINE=innodb; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +EXPLAIN SELECT table2 . col_varchar_10_utf8_key AS field1 +FROM e AS table1 LEFT JOIN c AS table2 +ON table1 . col_varchar_10_utf8_key = table2 . col_varchar_10_utf8_key +WHERE table1 . col_varchar_255_utf8_key != 'LPGIV' +AND table1 . col_varchar_10_latin1_key >= 'w' +AND table1 . col_varchar_10_utf8_key < 'zzzz'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE table1 NULL range k5 k5 24 NULL 1 100.00 Using where +2 SIMPLE table2 NULL eq_ref k5 k5 24 test.table1.col_varchar_10_utf8_key 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`table2`.`col_varchar_10_utf8_key` AS `field1` from `test`.`e` `table1` left join `test`.`c` `table2` on((`test`.`table2`.`col_varchar_10_utf8_key` = `test`.`table1`.`col_varchar_10_utf8_key`)) where ((`test`.`table1`.`col_varchar_255_utf8_key` <> 'LPGIV') and (`test`.`table1`.`col_varchar_10_latin1_key` >= 'w') and (`test`.`table1`.`col_varchar_10_utf8_key` < 'zzzz')) +SELECT table2 . col_varchar_10_utf8_key AS field1 +FROM e AS table1 LEFT JOIN c AS table2 +ON table1 . col_varchar_10_utf8_key = table2 . col_varchar_10_utf8_key +WHERE table1 . col_varchar_255_utf8_key != 'LPGIV' +AND table1 . col_varchar_10_latin1_key >= 'w' +AND table1 . col_varchar_10_utf8_key < 'zzzz'; +field1 +DROP TABLE c,e; +CREATE TABLE t1 ( +i int(11) NOT NULL, +j int(11) DEFAULT NULL, +k int(11) DEFAULT NULL, +l int(11) DEFAULT NULL, +PRIMARY KEY (i), +KEY j (j,k DESC,l), +KEY i (i,j,k,l) +)ENGINE=InnoDB; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES +(11,1,6,3),(4,1,2,3),(8,1,2,3),(10,1,2,3),(1,1,1,1),(2,1,1,1),(3,1,1,1), +(5,3,2,3),(6,4,2,3),(7,6,2,3),(12,7,6,3),(13,7,6,8),(14,7,6,9),(16,8,7,9), +(15,8,6,9); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT * FROM t1 WHERE i < 10 AND j >=1 AND k >=2 AND l <=5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 11.11 Parallel execute (1 workers) +2 SIMPLE t1 NULL range PRIMARY,j,i PRIMARY 4 NULL 8 11.11 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i`,`test`.`t1`.`j` AS `j`,`test`.`t1`.`k` AS `k`,`test`.`t1`.`l` AS `l` from `test`.`t1` where ((`test`.`t1`.`i` < 10) and (`test`.`t1`.`j` >= 1) and (`test`.`t1`.`k` >= 2) and (`test`.`t1`.`l` <= 5)) +SELECT * FROM t1 WHERE i < 10 AND j >=1 AND k >=2 AND l <=5; +i j k l +4 1 2 3 +5 3 2 3 +6 4 2 3 +7 6 2 3 +8 1 2 3 +DROP TABLE t1; +CREATE TABLE t1 ( +pk INTEGER NOT NULL, +col_int_key INTEGER , +col_varchar_key BLOB NOT NULL, +PRIMARY KEY (pk), +KEY (col_int_key, col_varchar_key(25) DESC) +); +CREATE TABLE t2 ( +pk INTEGER NOT NULL, +col_int INTEGER , +col_int_key INTEGER , +col_varchar_key BLOB , +PRIMARY KEY (pk), +KEY (col_int_key, col_varchar_key(25) DESC) +); +EXPLAIN SELECT t1.col_varchar_key +FROM ( t2 INNER JOIN t1 +ON (t1.col_int_key = t2.col_int AND (1,5) IN +( SELECT alias1.col_int_key, alias1. pk +FROM ( t2 AS alias2 RIGHT JOIN t1 AS alias1 +ON (alias1.pk = alias2.col_int_key ) +) WHERE alias1.col_varchar_key >= 'y') ) ); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t1 NULL ref col_int_key col_int_key 5 test.t2.col_int 1 100.00 NULL +1 SIMPLE alias1 NULL const PRIMARY,col_int_key PRIMARY 4 const 1 100.00 Using where +1 SIMPLE alias2 NULL ref col_int_key col_int_key 5 test.alias1.pk 1 100.00 Using index; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col_varchar_key` AS `col_varchar_key` from `test`.`t2` join `test`.`t1` semi join (`test`.`t1` `alias1` left join `test`.`t2` `alias2` on((`test`.`alias1`.`pk` = `test`.`alias2`.`col_int_key`))) where ((`test`.`t1`.`col_int_key` = `test`.`t2`.`col_int`) and (`test`.`alias1`.`pk` = 5) and (`test`.`alias1`.`col_int_key` = 1) and (`test`.`alias1`.`col_varchar_key` >= 'y')) +SELECT t1.col_varchar_key +FROM ( t2 INNER JOIN t1 +ON (t1.col_int_key = t2.col_int AND (1,5) IN +( SELECT alias1.col_int_key, alias1. pk +FROM ( t2 AS alias2 RIGHT JOIN t1 AS alias1 +ON (alias1.pk = alias2.col_int_key ) +) WHERE alias1.col_varchar_key >= 'y') ) ); +col_varchar_key +EXPLAIN SELECT t1.col_varchar_key +FROM ( t2 INNER JOIN t1 +ON (t1.col_int_key = t2.col_int AND (1,5) IN +( SELECT alias1.col_int_key, alias1. pk +FROM ( t2 AS alias2 RIGHT JOIN t1 AS alias1 +ON (alias1.pk = alias2.col_int_key ) +) WHERE alias1.col_varchar_key <= 'y') ) ); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t1 NULL ref col_int_key col_int_key 5 test.t2.col_int 1 100.00 NULL +1 SIMPLE alias1 NULL const PRIMARY,col_int_key PRIMARY 4 const 1 100.00 Using where +1 SIMPLE alias2 NULL ref col_int_key col_int_key 5 test.alias1.pk 1 100.00 Using index; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col_varchar_key` AS `col_varchar_key` from `test`.`t2` join `test`.`t1` semi join (`test`.`t1` `alias1` left join `test`.`t2` `alias2` on((`test`.`alias1`.`pk` = `test`.`alias2`.`col_int_key`))) where ((`test`.`t1`.`col_int_key` = `test`.`t2`.`col_int`) and (`test`.`alias1`.`pk` = 5) and (`test`.`alias1`.`col_int_key` = 1) and (`test`.`alias1`.`col_varchar_key` <= 'y')) +SELECT t1.col_varchar_key +FROM ( t2 INNER JOIN t1 +ON (t1.col_int_key = t2.col_int AND (1,5) IN +( SELECT alias1.col_int_key, alias1. pk +FROM ( t2 AS alias2 RIGHT JOIN t1 AS alias1 +ON (alias1.pk = alias2.col_int_key ) +) WHERE alias1.col_varchar_key <= 'y') ) ); +col_varchar_key +DROP TABLE t1,t2; +#End of test case for Bug#22973383 +# +# Bug #23576305:WL1074:STRAIGHT_JOIN QUERY WITH RANGE +# CHECKED (MYISAM) GIVES WRONG RESULTS +# +CREATE TABLE t1 ( +pk INTEGER NOT NULL , +col_varchar_key varchar(10) DEFAULT NULL, +UNIQUE KEY pk_2 (pk,col_varchar_key DESC) +); +INSERT INTO t1 VALUES (3,'ksatefqs'), +(4,'sate'),(5,'a'); +CREATE TABLE t2 ( +pk INTEGER NOT NULL, +col_int_key INTEGER DEFAULT NULL, +col_varchar_key varchar(10) DEFAULT NULL +); +INSERT INTO t2 VALUES +(10,80,'ukqukkoe'), +(11,2,'kqukkoe'), +(12,5,'qukkoeiws'), +(13,9,'ukko'), +(14,3,'kkoeiwsgp'); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN SELECT t1.pk, t2.col_int_key, +t1.col_varchar_key, t2.col_varchar_key +FROM t2 JOIN t1 ON ( t1.pk >= t2.col_int_key +AND t1.col_varchar_key != t2.col_varchar_key ); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # # Parallel execute (1 workers) +2 SIMPLE t1 NULL index pk_2 pk_2 47 NULL # # Using index +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL # # Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t2`.`col_int_key` AS `col_int_key`,`test`.`t1`.`col_varchar_key` AS `col_varchar_key`,`test`.`t2`.`col_varchar_key` AS `col_varchar_key` from `test`.`t2` join `test`.`t1` where ((`test`.`t1`.`pk` >= `test`.`t2`.`col_int_key`) and (`test`.`t1`.`col_varchar_key` <> `test`.`t2`.`col_varchar_key`)) +SELECT t1.pk, t2.col_int_key, +t1.col_varchar_key, t2.col_varchar_key +FROM t2 JOIN t1 ON ( t1.pk >= t2.col_int_key +AND t1.col_varchar_key != t2.col_varchar_key ); +pk col_int_key col_varchar_key col_varchar_key +3 2 ksatefqs kqukkoe +3 3 ksatefqs kkoeiwsgp +4 2 sate kqukkoe +4 3 sate kkoeiwsgp +5 2 a kqukkoe +5 3 a kkoeiwsgp +5 5 a qukkoeiws +EXPLAIN SELECT STRAIGHT_JOIN t1.pk, t2.col_int_key, +t1.col_varchar_key, t2.col_varchar_key FROM +t2 JOIN t1 ON ( t1.pk >= t2.col_int_key AND +t1.col_varchar_key != t2.col_varchar_key ); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # # Parallel execute (1 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL # # NULL +2 SIMPLE t1 NULL ALL pk_2 NULL NULL NULL # # Range checked for each record (index map: 0x1) +Warnings: +Note 1003 /* select#1 */ select straight_join `test`.`t1`.`pk` AS `pk`,`test`.`t2`.`col_int_key` AS `col_int_key`,`test`.`t1`.`col_varchar_key` AS `col_varchar_key`,`test`.`t2`.`col_varchar_key` AS `col_varchar_key` from `test`.`t2` join `test`.`t1` where ((`test`.`t1`.`pk` >= `test`.`t2`.`col_int_key`) and (`test`.`t1`.`col_varchar_key` <> `test`.`t2`.`col_varchar_key`)) +SELECT STRAIGHT_JOIN t1.pk, t2.col_int_key, +t1.col_varchar_key, t2.col_varchar_key FROM +t2 JOIN t1 ON ( t1.pk >= t2.col_int_key AND +t1.col_varchar_key != t2.col_varchar_key ); +pk col_int_key col_varchar_key col_varchar_key +3 2 ksatefqs kqukkoe +3 3 ksatefqs kkoeiwsgp +4 2 sate kqukkoe +4 3 sate kkoeiwsgp +5 2 a kqukkoe +5 3 a kkoeiwsgp +5 5 a qukkoeiws +DROP TABLE t1,t2; +#End of test for Bug#23576305 +# +# Bug#23730559: ASSERTION `TAB->QUICK() == SAVE_QUICK || +# TAB->QUICK() == __NULL' FAILED. +# +# +CREATE TABLE b ( +col_int INTEGER NOT NULL, +col_int_key INTEGER NOT NULL, +col_varchar_key VARCHAR(20) NOT NULL, +col_varchar VARCHAR(20) NOT NULL, +KEY (col_varchar_key DESC), +KEY (col_varchar_key(5) DESC), +KEY (col_varchar_key, col_int_key) +) ENGINE=InnoDB; +INSERT INTO b ( col_int_key, col_int, col_varchar_key, col_varchar) VALUES +(1, 3, 'xceksatefqsdksjijc', 'xceksatefqsdksjijc'), +(7, 6, 'ce', 'ce'), +(2, 3, 'eksatefqsdksjij', 'eksatefqsdksjij'), +(5, 7, 'satefqsd', 'satefqsd'); +CREATE TABLE bb ( +col_int INTEGER NOT NULL, +col_int_key INTEGER NOT NULL, +col_varchar_key VARCHAR(20) NOT NULL, +col_varchar VARCHAR(20) NOT NULL, +KEY (col_varchar_key(10) DESC, col_int_key DESC) +) ENGINE=InnoDB; +INSERT INTO bb ( col_int_key, col_int, col_varchar_key, col_varchar) VALUES +(181, 88, 'kkoeiwsgpmfyvvuqvtjn', 'kkoeiwsgpmfyvvuqvtjn'), +(3, 4, 'koeiwsgpmfyv', 'koeiwsgpmfyv'), +(86, 113, 'oeiwsgpm', 'oeiwsgpm'), +(6, 1, 'eiwsgpmfyvvuqvtjncds', 'eiwsgpmfyvvuqvtjncds'), +(8, 5, 'iwsgpmfyvvuqv', 'iwsgpmfyvvuqv'); +ANALYZE TABLE b,bb; +Table Op Msg_type Msg_text +test.b analyze status OK +test.bb analyze status OK +EXPLAIN SELECT gp1 . col_varchar AS g1 +FROM b AS gp1 LEFT JOIN bb AS gp2 USING ( col_varchar_key ) +WHERE gp1 . col_int IN ( +SELECT p1 . col_int AS p1 +FROM bb AS p1 LEFT JOIN bb AS p2 +ON ( p1 . col_int >= p2 . col_int_key ) +WHERE ( p1 . col_int , gp1 . col_int ) IN ( +SELECT c1 . col_int AS C1 +, c1 . col_int AS C2 +FROM b AS c1 LEFT JOIN bb AS c2 USING ( col_varchar ) +WHERE ( gp1 . col_varchar_key >= 'n' ) +) +AND ( gp1 . col_varchar < 'e' ) +) +AND ( gp1 . col_varchar_key <> 'y' ) +ORDER BY gp1 . col_varchar_key LIMIT 4; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE gp1 NULL range col_varchar_key,col_varchar_key_2,col_varchar_key_3 col_varchar_key_3 82 NULL 3 33.33 Using index condition; Using where +2 SIMPLE gp2 NULL ref col_varchar_key col_varchar_key 42 test.gp1.col_varchar_key 1 100.00 Using where +2 SIMPLE c1 NULL ALL NULL NULL NULL NULL 4 25.00 Using where +2 SIMPLE p1 NULL ALL NULL NULL NULL NULL 5 20.00 Using where +2 SIMPLE p2 NULL index NULL col_varchar_key 46 NULL 5 100.00 Using where; Using index +2 SIMPLE c2 NULL ALL NULL NULL NULL NULL 5 100.00 Using where; FirstMatch(gp2) +Warnings: +Note 1276 Field or reference 'test.gp1.col_varchar_key' of SELECT #3 was resolved in SELECT #1 +Note 1276 Field or reference 'test.gp1.col_int' of SELECT #2 was resolved in SELECT #1 +Note 1276 Field or reference 'test.gp1.col_varchar' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`gp1`.`col_varchar` AS `g1` from `test`.`b` `gp1` left join `test`.`bb` `gp2` on((`test`.`gp2`.`col_varchar_key` = `test`.`gp1`.`col_varchar_key`)) semi join (`test`.`bb` `p1` left join `test`.`bb` `p2` on((`test`.`p1`.`col_int` >= `test`.`p2`.`col_int_key`)) join `test`.`b` `c1` left join `test`.`bb` `c2` on((`test`.`c1`.`col_varchar` = `test`.`c2`.`col_varchar`))) where ((`test`.`c1`.`col_int` = `test`.`gp1`.`col_int`) and (`test`.`p1`.`col_int` = `test`.`gp1`.`col_int`) and (`test`.`gp1`.`col_varchar_key` <> 'y') and (`test`.`gp1`.`col_varchar` < 'e') and (`test`.`gp1`.`col_varchar_key` >= 'n')) order by `test`.`gp1`.`col_varchar_key` limit 4 +SELECT gp1 . col_varchar AS g1 +FROM b AS gp1 LEFT JOIN bb AS gp2 USING ( col_varchar_key ) +WHERE gp1 . col_int IN ( +SELECT p1 . col_int AS p1 +FROM bb AS p1 LEFT JOIN bb AS p2 +ON ( p1 . col_int >= p2 . col_int_key ) +WHERE ( p1 . col_int , gp1 . col_int ) IN ( +SELECT c1 . col_int AS C1 +, c1 . col_int AS C2 +FROM b AS c1 LEFT JOIN bb AS c2 USING ( col_varchar ) +WHERE ( gp1 . col_varchar_key >= 'n' ) +) +AND ( gp1 . col_varchar < 'e' ) +) +AND ( gp1 . col_varchar_key <> 'y' ) +ORDER BY gp1 . col_varchar_key LIMIT 4; +g1 +DROP TABLE b,bb; +# +# Bug#23759797: DESC INDEX BACKWARD SCAN SHOWS WRONG RESULTS +# +CREATE TABLE t1 ( +col_varchar_255_latin1_key varchar(255) DEFAULT NULL, +pk int(11) NOT NULL AUTO_INCREMENT, +KEY (pk DESC), +KEY k3 (col_varchar_255_latin1_key DESC) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1(col_varchar_255_latin1_key, pk) VALUES +('l',4), ('something',3), ('ycyoybhug',2), ('l',5), ('my',1), +('l',4),('l',4),('l',4),('l',4),('l',4),('l',4), +('l',4),('l',4),('l',4),('l',4),('l',4),('l',4), +('l',4),('l',4),('l',4),('l',4),('l',4),('l',4), +('l',4),('l',4),('l',4),('l',4),('l',4),('l',4); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +SELECT +t1 . pk AS field1, +t1 . pk AS field2 +FROM t1 LEFT JOIN t1 AS t2 +ON t1 . col_varchar_255_latin1_key = t2 . col_varchar_255_latin1_key +WHERE t1 . pk <> 4 +ORDER BY field1, field2 DESC; +field1 field2 +1 1 +2 2 +3 3 +5 5 +5 5 +5 5 +5 5 +5 5 +5 5 +5 5 +5 5 +5 5 +5 5 +5 5 +5 5 +5 5 +5 5 +5 5 +5 5 +5 5 +5 5 +5 5 +5 5 +5 5 +5 5 +5 5 +5 5 +5 5 +5 5 +EXPLAIN SELECT +t1 . pk AS field1, +t1 . pk AS field2 +FROM t1 LEFT JOIN t1 AS t2 +ON t1 . col_varchar_255_latin1_key = t2 . col_varchar_255_latin1_key +WHERE t1 . pk <> 4 +ORDER BY field1, field2 DESC; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # # Parallel execute (2 workers) +2 SIMPLE t1 NULL range pk pk 4 NULL # # Using index condition; Backward index scan +2 SIMPLE t2 NULL ref k3 k3 1023 test.t1.col_varchar_255_latin1_key # # Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `field1`,`test`.`t1`.`pk` AS `field2` from `test`.`t1` left join `test`.`t1` `t2` on((`test`.`t2`.`col_varchar_255_latin1_key` = `test`.`t1`.`col_varchar_255_latin1_key`)) where (`test`.`t1`.`pk` <> 4) order by `field1` +DROP TABLE t1; +CREATE TABLE t1 ( +pk int(11) NOT NULL AUTO_INCREMENT, +col_int_key int(11) DEFAULT NULL, +PRIMARY KEY (pk DESC), +KEY k3 (col_int_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (25,9), (24,1), (23,-74383360), (22,-855900160), +(21,NULL), (20,1596522496), (19,9), (18,1), (17,NULL), (16,NULL), +(15,1808465920), (14,NULL), (13,588644352), (12,3), (11,6), (10,NULL), +(9,NULL), (8,8), (7,NULL), (6,NULL), (5,-1018232832), (4,5), (3,NULL), +(2,NULL), (1,NULL); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +SELECT DISTINCT +t1 . pk AS field1 +FROM t1 LEFT JOIN t1 AS t2 +ON t1 . pk = t2 . pk +WHERE ( t1 . col_int_key IS NULL AND t1 . pk != 4 ) +GROUP BY field1 +HAVING field1 != 6 +ORDER BY field1 ASC; +field1 +1 +2 +3 +7 +9 +10 +14 +16 +17 +21 +EXPLAIN SELECT DISTINCT +t1 . pk AS field1 +FROM t1 LEFT JOIN t1 AS t2 +ON t1 . pk = t2 . pk +WHERE ( t1 . col_int_key IS NULL AND t1 . pk != 4 ) +GROUP BY field1 +HAVING field1 != 6 +ORDER BY field1 ASC; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 100.00 Parallel execute (2 workers) +2 SIMPLE t1 NULL range PRIMARY,k3 k3 9 NULL 11 100.00 Using where; Using index; Using temporary; Using filesort +2 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.pk 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `field1` from `test`.`t1` left join `test`.`t1` `t2` on((`test`.`t2`.`pk` = `test`.`t1`.`pk`)) where ((`test`.`t1`.`col_int_key` is null) and (`test`.`t1`.`pk` <> 4)) group by `field1` having (`field1` <> 6) order by `field1` +EXPLAIN UPDATE t1 +SET t1.pk = pk + 1000 +WHERE ( t1 . col_int_key IS NULL AND t1 . pk != 4 ) +ORDER BY pk ASC LIMIT 3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL range PRIMARY,k3 PRIMARY 4 const 24 100.00 Using where; Backward index scan; Using temporary +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`pk` = (`test`.`t1`.`pk` + 1000) where ((`test`.`t1`.`col_int_key` is null) and (`test`.`t1`.`pk` <> 4)) order by `test`.`t1`.`pk` limit 3 +DROP TABLE t1; +# +# +# Bug #23738137: WL1074:RESULT DIFFERENCE SEEN FOR +# QUERY WITH OR IN JOIN CONDITION +# +CREATE TABLE t1 ( +pk INTEGER NOT NULL, +col_int_key INTEGER DEFAULT NULL, +col_varchar_key varchar(20) DEFAULT NULL, +col_varchar varchar(20) DEFAULT NULL, +PRIMARY KEY (pk DESC), +KEY col_int_key (col_int_key DESC), +KEY col_varchar_key (col_varchar_key DESC) +) charset latin1; +INSERT INTO t1 VALUES (20,8,'eiw','eiw'),(19,8,'oeiws','oeiws'), +(18,NULL,'koeiw','koeiw'),(17,3,'kkoei','kkoei'), +(16,9,'ukkoe','ukkoe'),(15,5,'qukko','qukko'), +(14,2,'kqukk','kqukk'),(13,80,'ukquk','ukquk'), +(12,5,'lukqu','lukqu'),(10,NULL,'alukq','alukq'), +(9,3,'maluk','maluk'),(8,NULL,NULL,NULL), +(7,9,'ymalu','ymalu'),(6,3,'kymal','kymal'), +(5,6,'vkyma','vkyma'),(4,8,'vvkym','vvkym'), +(3,3,'jjvvk','jjvvk'),(1,5,'bjjvv','bjjvv'); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT STRAIGHT_JOIN count(t1.col_varchar) FROM t1 JOIN t1 AS t2 ON +(t2.pk = t1.col_int_key) OR (t2.col_varchar_key = t1.col_varchar_key); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 18 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL col_int_key,col_varchar_key NULL NULL NULL 18 100.00 NULL +2 SIMPLE t2 NULL ALL PRIMARY,col_varchar_key NULL NULL NULL 18 19.00 Range checked for each record (index map: 0x5) +Warnings: +Note 1003 /* select#1 */ select straight_join count(`test`.`t1`.`col_varchar`) AS `count(t1.col_varchar)` from `test`.`t1` join `test`.`t1` `t2` where ((`test`.`t2`.`pk` = `test`.`t1`.`col_int_key`) or (`test`.`t2`.`col_varchar_key` = `test`.`t1`.`col_varchar_key`)) +SELECT STRAIGHT_JOIN count(t1.col_varchar) FROM t1 JOIN t1 AS t2 ON +(t2.pk = t1.col_int_key) OR (t2.col_varchar_key = t1.col_varchar_key); +count(t1.col_varchar) +29 +EXPLAIN SELECT count(t1.col_varchar) FROM t1 JOIN t1 AS t2 ON (t2.pk = t1.col_int_key) +OR (t2.col_varchar_key = t1.col_varchar_key); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 18 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL col_int_key,col_varchar_key NULL NULL NULL 18 100.00 NULL +2 SIMPLE t2 NULL ALL PRIMARY,col_varchar_key NULL NULL NULL 18 19.00 Range checked for each record (index map: 0x5) +Warnings: +Note 1003 /* select#1 */ select count(`test`.`t1`.`col_varchar`) AS `count(t1.col_varchar)` from `test`.`t1` join `test`.`t1` `t2` where ((`test`.`t2`.`pk` = `test`.`t1`.`col_int_key`) or (`test`.`t2`.`col_varchar_key` = `test`.`t1`.`col_varchar_key`)) +SELECT count(t1.col_varchar) FROM t1 JOIN t1 AS t2 ON (t2.pk = t1.col_int_key) +OR (t2.col_varchar_key = t1.col_varchar_key); +count(t1.col_varchar) +29 +DROP TABLE t1; +# End of test for Bug#23738137 +# +# Bug#24294552:MULTI KEY DESC INDEX ON GCOL GIVES INCORRECT RESULTS +# +CREATE TABLE t2 ( +col_int int(11) DEFAULT NULL, +pk int(11) NOT NULL AUTO_INCREMENT, +col_int_key int(11), +PRIMARY KEY (pk DESC), +KEY k2 (col_int_key, col_int DESC) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO +t2(col_int,col_int_key) VALUES (1,2), (2,4), (3,6), (4,8), (5,10), (6,12), +(7,14), (8,16), (9,18); +CREATE TABLE t1 ( +col_int int(11) DEFAULT NULL, +pk int(11) NOT NULL, +col_int_key int(11) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1(pk, col_int, col_int_key) VALUES (4,3,6), (5,4,8), (6,2,4); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +SELECT STRAIGHT_JOIN +t1 . col_int_key AS field1 , +t2 . col_int AS field2 +FROM t1 LEFT JOIN t2 FORCE INDEX(k2) +ON t1 . col_int = t2 . col_int +WHERE ( t2 . col_int_key <= t1 . col_int_key AND t1 . pk >= t2 . pk ) +ORDER BY field1, field2 DESC; +field1 field2 +4 2 +6 3 +8 4 +EXPLAIN SELECT STRAIGHT_JOIN +t1 . col_int_key AS field1 , +t2 . col_int AS field2 +FROM t1 LEFT JOIN t2 force index(k2) +ON t1 . col_int = t2 . col_int +WHERE ( t2 . col_int_key <= t1 . col_int_key AND t1 . pk >= t2 . pk ) +ORDER BY field1, field2 DESC; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # # Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL # # Using temporary; Using filesort +2 SIMPLE t2 NULL ALL k2 NULL NULL NULL # # Range checked for each record (index map: 0x2) +Warnings: +Note 1003 /* select#1 */ select straight_join `test`.`t1`.`col_int_key` AS `field1`,`test`.`t2`.`col_int` AS `field2` from `test`.`t1` join `test`.`t2` FORCE INDEX (`k2`) where ((`test`.`t2`.`col_int` = `test`.`t1`.`col_int`) and (`test`.`t2`.`col_int_key` <= `test`.`t1`.`col_int_key`) and (`test`.`t1`.`pk` >= `test`.`t2`.`pk`)) order by `field1`,`field2` desc +DROP TABLE t1,t2; +# +# +# Bug#24300848:WL1074: INNODB: ASSERTION FAILURE: +# BTR0PCUR.CC:268:CURSOR->OLD_REC +# +CREATE TABLE t1(col1 int , col2 int, PRIMARY KEY (col1 DESC)) +PARTITION BY RANGE (col1) (PARTITION p0 VALUES LESS THAN (5)); +INSERT INTO t1 VALUES(1, 10); +SELECT * FROM t1 WHERE col1 IN (1, 2); +col1 col2 +1 10 +DROP TABLE t1; +# End of test for Bug#24300848 +# +# Bug#24431177: WL1074:LEFT JOIN QUERY USING INDEX SHOWS +# WRONG QEP AND RESULTS ON 2ND EXECUTION +# +CREATE TABLE t1( +pk INTEGER NOT NULL AUTO_INCREMENT, +col_int_key INTEGER DEFAULT NULL, +PRIMARY KEY (pk DESC), +KEY col_int_key (col_int_key DESC) +); +INSERT INTO t1 VALUES (3,15),(6,8),(20,6),(15,6),(18,5),(17,5), +(16,5),(13,5),(12,5),(9,5),(8,5),(7,5),(5,5),(11,4),(4,4), +(19,3),(10,2),(1,2),(14,1),(2,1); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT * FROM t1 WHERE pk IN (6,2) +OR (col_int_key >= 7 AND col_int_key < 13); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 20 28.89 Parallel execute (1 workers) +2 SIMPLE t1 NULL index PRIMARY,col_int_key col_int_key 5 NULL 20 28.89 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`col_int_key` AS `col_int_key` from `test`.`t1` where ((`test`.`t1`.`pk` in (6,2)) or ((`test`.`t1`.`col_int_key` >= 7) and (`test`.`t1`.`col_int_key` < 13))) +SELECT * FROM t1 WHERE pk IN (6,2) +OR (col_int_key >= 7 AND col_int_key < 13); +pk col_int_key +2 1 +6 8 +ALTER TABLE t1 ADD INDEX key1 (pk); +ALTER TABLE t1 ADD INDEX key2 (col_int_key); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT * FROM t1 FORCE INDEX (key1,col_int_key) WHERE pk IN (6,2) +OR (col_int_key >= 7 AND col_int_key < 13); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge col_int_key,key1 key1,col_int_key 4,5 NULL 2 100.00 Using sort_union(key1,col_int_key); Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`col_int_key` AS `col_int_key` from `test`.`t1` FORCE INDEX (`col_int_key`) FORCE INDEX (`key1`) where ((`test`.`t1`.`pk` in (6,2)) or ((`test`.`t1`.`col_int_key` >= 7) and (`test`.`t1`.`col_int_key` < 13))) +SELECT * FROM t1 FORCE INDEX (key1,col_int_key) WHERE pk IN (6,2) +OR (col_int_key >= 7 AND col_int_key < 13); +pk col_int_key +2 1 +6 8 +DROP TABLE t1; +# End of test for Bug#24431777 +CREATE TABLE t1( +a INTEGER NOT NULL, +b INTEGER NOT NULL, +KEY ab (a DESC,b DESC) +); +INSERT INTO t1 VALUES (78,7),(78,6),(70,1),(47,1),(15,4),(15,1), +(10,6),(3,6),(2,56),(2,6),(1,56); +SELECT * FROM t1 WHERE ( +( b =1 AND a BETWEEN 14 AND 21 ) OR +( b =2 AND a BETWEEN 16 AND 18 ) OR +( b =3 AND a BETWEEN 15 AND 19 ) OR +(a BETWEEN 19 AND 47) ); +a b +47 1 +15 1 +DROP TABLE t1; +# +# Bug #25899921: INCORRECT BEHAVIOR WITH DESC INDEX AND +# IMPOSSIBLE CONDITION +# +CREATE TABLE t1 (a INT, b DATE, KEY(b,a DESC)); +SET @g:='1'; +DELETE FROM t1 WHERE b=@g ORDER BY b, a LIMIT 1; +ERROR 22007: Incorrect date value: '1' for column 'b' at row 1 +DROP TABLE t1; +# End of test for Bug#25899921 diff --git a/mysql-test/r/distinct_innodb.result-pq b/mysql-test/r/distinct_innodb.result-pq new file mode 100644 index 000000000000..99e69693500a --- /dev/null +++ b/mysql-test/r/distinct_innodb.result-pq @@ -0,0 +1,965 @@ +# +# Bug#13335170 - ASSERT IN +# PLAN_CHANGE_WATCHDOG::~PLAN_CHANGE_WATCHDOG() ON SELECT DISTINCT +# +CREATE TABLE t1 ( +col_int_key int(11) NOT NULL, +col_time_key time NOT NULL, +col_datetime_key datetime NOT NULL, +KEY col_int_key (col_int_key), +KEY col_time_key (col_time_key), +KEY col_datetime_key (col_datetime_key) +) ENGINE=InnoDB; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (7,'06:17:39','2003-08-21 00:00:00'); +SELECT DISTINCT col_int_key +FROM t1 +WHERE col_int_key IN ( 18, 6, 84, 4, 0, 2, 8, 3, 7, 9, 1 ) +AND col_datetime_key BETWEEN '2001-08-04' AND '2003-06-13' +ORDER BY col_time_key +LIMIT 3; +col_int_key +DROP TABLE t1; + +# BUG#13581713 ONLY_FULL_GROUP_BY DOES NOT BLOCK "SELECT +# DISTINCT A ORDER BY B" + +create table t1(a int, b int, c int) engine=InnoDB; +create table t2(a int, b int, c int) engine=InnoDB; +insert into t2 values(); +analyze table t2; +Table Op Msg_type Msg_text +test.t2 analyze status OK +# Test when selecting from base table +insert into t1 values(100,1,2),(200,1,1),(300,2,1),(400,2,2); +analyze table t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +select distinct b from t1 order by c; +b +2 +1 +select distinct min(b) from t1 group by a order by min(c); +min(b) +1 +2 +explain select distinct min(b) from t1 group by a order by min(c); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL # 4 100.00 Using temporary; Using filesort +Note 1003 /* select#1 */ select distinct min(`test`.`t1`.`b`) AS `min(b)` from `test`.`t1` group by `test`.`t1`.`a` order by min(`test`.`t1`.`c`) +Warnings: +Insert rows in different order: +delete from t1; +insert into t1 values(200,1,1),(100,1,2),(400,2,2),(300,2,1); +analyze table t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +And get a different order. Query is executed like this: +- First, DISTINCT, using a tmp MEMORY table with a unique +index, thus if two rows have the same 'b' but a different 'c', +the second row is rejected, so the first value of 'c' wins +(=> randomness of 'c') +- Second, ORDER BY on the random 'c'. +select distinct b from t1 order by c; +b +1 +2 +Random order too (same reason): +select distinct min(b) from t1 group by a order by min(c); +min(b) +1 +2 +This query gives random order: +select distinct b from t1 order by c; +ERROR HY000: Expression #1 of ORDER BY clause is not in SELECT list, references column 'test.t1.c' which is not in SELECT list; this is incompatible with DISTINCT +and this one too: +select distinct b from t1 order by b-1,b+1,c; +ERROR HY000: Expression #3 of ORDER BY clause is not in SELECT list, references column 'test.t1.c' which is not in SELECT list; this is incompatible with DISTINCT +and this one too: +select distinct min(b) from t1 group by a order by min(c); +ERROR HY000: Expression #1 of ORDER BY clause is not in SELECT list, contains aggregate function; this is incompatible with DISTINCT +Not random (though Standard bans aggregates from ORDER BY): +select distinct min(b) from t1 group by a order by min(b); +min(b) +1 +2 +select distinct min(b) from t1 group by a order by -min(b); +ERROR HY000: Expression #1 of ORDER BY clause is not in SELECT list, contains aggregate function; this is incompatible with DISTINCT +All group exprs are in select list => DISTINCT is removed => no error +select distinct a, min(b) from t1 group by a order by max(b-2)-min(c*5); +a min(b) +100 1 +400 2 +200 1 +300 2 +This one is standard: +select distinct min(b) as z from t1 group by a order by z; +z +1 +2 +Other queries: +select distinct b from t1 where b<0 order by rand(); +b +select distinct b from t1 order by 45.0+3; +b +1 +2 +select (select distinct b from t1 as S2 where b=7 order by S3.a) from t1 as S3; +(select distinct b from t1 as S2 where b=7 order by S3.a) +NULL +NULL +NULL +NULL +select distinct b from t1 order by abs(b); +b +1 +2 +select distinct b as z from t1 order by abs(z); +z +1 +2 +select distinct b from t1 order by abs(b+a); +ERROR HY000: Expression #1 of ORDER BY clause is not in SELECT list, references column 'test.t1.a' which is not in SELECT list; this is incompatible with DISTINCT +select distinct abs(b) as z from t1 order by z; +z +1 +2 +select distinct abs(b) as z from t1 order by abs(b); +z +1 +2 +select distinct abs(b) from t1 order by abs(b); +abs(b) +1 +2 +Not ok: ABS(b)+1 is neither a SELECTed expression nor an alias +to one, and mentions a column of FROM tables. +select distinct abs(b) as z from t1 order by abs(b)+1; +ERROR HY000: Expression #1 of ORDER BY clause is not in SELECT list, references column 'test.t1.b' which is not in SELECT list; this is incompatible with DISTINCT +select distinct abs(b) as z from t1 order by z+1; +z +1 +2 +select distinct abs(b) from t1 order by abs(b)+1; +ERROR HY000: Expression #1 of ORDER BY clause is not in SELECT list, references column 'test.t1.b' which is not in SELECT list; this is incompatible with DISTINCT +select distinct abs(b) as z from t1 order by floor(10*b); +ERROR HY000: Expression #1 of ORDER BY clause is not in SELECT list, references column 'test.t1.b' which is not in SELECT list; this is incompatible with DISTINCT +select distinct abs(b) from t1 order by floor(10*b); +ERROR HY000: Expression #1 of ORDER BY clause is not in SELECT list, references column 'test.t1.b' which is not in SELECT list; this is incompatible with DISTINCT +Two offending columns; error message needs to report only one +select distinct abs(b) from t1 order by floor(10*b),floor(10*a); +ERROR HY000: Expression #1 of ORDER BY clause is not in SELECT list, references column 'test.t1.b' which is not in SELECT list; this is incompatible with DISTINCT +select distinct abs(b) from t1 as S2 order by +(select floor(10*S2.b) from t1 as S3 limit 1); +ERROR HY000: Expression #1 of ORDER BY clause is not in SELECT list, references column 'test.S2.b' which is not in SELECT list; this is incompatible with DISTINCT +Ok as S2.b in SELECT list +select distinct abs(b),b from t1 as S2 order by +(select floor(10*S2.b) from t1 as S3 limit 1); +abs(b) b +1 1 +2 2 +Ok as subq does not use columns of FROM clause of ordered Q. +select distinct abs(b) from t1 as S2 order by +(select floor(10*S3.b) from t1 as S3 limit 1); +abs(b) +1 +2 +Subq as alias => ok +select distinct abs(b), +(select floor(10*S3.b) from t1 as S3 limit 1) as subq +from t1 as S2 order by subq; +abs(b) subq +1 10 +2 10 +Bad field in left or right argument of ALL/ANY(subq): +select distinct abs(b) from t1 as S2 order by +floor(10*S2.b) IN (select floor(10*S3.b) from t1 as S3); +ERROR HY000: Expression #1 of ORDER BY clause is not in SELECT list, references column 'test.S2.b' which is not in SELECT list; this is incompatible with DISTINCT +select distinct abs(b) from t1 as S2 order by +floor(10*S2.b) > ALL(select floor(10*S3.b) from t1 as S3); +ERROR HY000: Expression #1 of ORDER BY clause is not in SELECT list, references column 'test.S2.b' which is not in SELECT list; this is incompatible with DISTINCT +select distinct abs(b) from t1 as S2 order by +floor(10*10) IN (select floor(10*S2.b) from t1 as S3); +ERROR HY000: Expression #1 of ORDER BY clause is not in SELECT list, references column 'test.S2.b' which is not in SELECT list; this is incompatible with DISTINCT +select distinct abs(b) from t1 as S2 order by +floor(10*10) > ALL(select floor(10*S2.b) from t1 as S3); +ERROR HY000: Expression #1 of ORDER BY clause is not in SELECT list, references column 'test.S2.b' which is not in SELECT list; this is incompatible with DISTINCT +Aggregates: +SELECT distinct 1 FROM t1 group by a order by count(*); +ERROR HY000: Expression #1 of ORDER BY clause is not in SELECT list, contains aggregate function; this is incompatible with DISTINCT +SELECT distinct 1 FROM t1 group by a order by count(*)-count(*); +ERROR HY000: Expression #1 of ORDER BY clause is not in SELECT list, contains aggregate function; this is incompatible with DISTINCT +Test ANY_VALUE +SELECT distinct 1 FROM t1 group by a order by any_value(count(*)-count(b)); +1 +1 +SELECT distinct 1 FROM t1 group by a order by any_value(count(*))-any_value(count(b)); +1 +1 +All group exprs are in select list => DISTINCT is removed => no error +SELECT distinct a, min(b) FROM t1 group by a order by count(*)-count(*); +a min(b) +100 1 +200 1 +300 2 +400 2 +SELECT distinct 1 FROM t1 group by a order by count(*)-count(b); +ERROR HY000: Expression #1 of ORDER BY clause is not in SELECT list, contains aggregate function; this is incompatible with DISTINCT +aggregation in outer Q => constant in inner Q +select * from t1 as t2 where t2.a in +(SELECT distinct 1 FROM t1 group by a order by count(t2.a)-max(t2.a)); +a b c +ORDER BY expressions are in SELECT list => ok +SELECT distinct 1, count(*)-count(b) FROM t1 group by a order by count(*)-count(b); +1 count(*)-count(b) +1 0 +Without GROUP BY, aggregates yield a single row, no random order +SELECT distinct sum(a) FROM t1 order by count(*)-count(*); +sum(a) +1000 +SELECT distinct sum(a) FROM t1 order by count(*)-count(b); +sum(a) +1000 +Verify that DISTINCT is optimized away even if the aggregate +function is hidden in a subquery +EXPLAIN SELECT DISTINCT MAX(b) FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select max(`test`.`t1`.`b`) AS `MAX(b)` from `test`.`t1` +EXPLAIN SELECT DISTINCT (SELECT MAX(t1.b) FROM t1 AS t2 LIMIT 1) FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +Warnings: +Note 1276 Field or reference 'test.t1.b' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select (/* select#2 */ select max(`test`.`t1`.`b`) from `test`.`t1` `t2` limit 1) AS `(SELECT MAX(t1.b) FROM t1 AS t2 LIMIT 1)` from `test`.`t1` +but if the subquery is the aggregation query, DISTINCT must stay: +EXPLAIN SELECT DISTINCT (SELECT MAX(t1.b+0*t2.a) FROM t1 AS t2 LIMIT 1) FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 4 100.00 Using temporary +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +Warnings: +Note 1276 Field or reference 'test.t1.b' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select distinct (/* select#2 */ select max((`test`.`t1`.`b` + (0 * `test`.`t2`.`a`))) from `test`.`t1` `t2` limit 1) AS `(SELECT MAX(t1.b+0*t2.a) FROM t1 AS t2 LIMIT 1)` from `test`.`t1` +QA's query is properly rejected: +SELECT DISTINCT GP1.a AS g1 FROM t1 AS GP1 +WHERE GP1.a >= 0 +ORDER BY GP1.b LIMIT 8; +ERROR HY000: Expression #1 of ORDER BY clause is not in SELECT list, references column 'test.GP1.b' which is not in SELECT list; this is incompatible with DISTINCT +result order does change depending on chosen plan. +SELECT DISTINCT GP1.a AS g1 FROM t1 AS GP1 +WHERE GP1.a >= 0 +ORDER BY 2+ANY_VALUE(GP1.b) LIMIT 8; +g1 +100 +200 +300 +400 +DELETE FROM t1; +# Test when selecting from view +create view v1 as select t1.* from t1 left join t2 on 1; +insert into t1 values(100,1,2),(200,1,1),(300,2,1),(400,2,2); +analyze table t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +select distinct b from v1 order by c; +b +2 +1 +select distinct min(b) from v1 group by a order by min(c); +min(b) +1 +2 +explain select distinct min(b) from v1 group by a order by min(c); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL # 4 100.00 Using temporary; Using filesort +1 SIMPLE t2 NULL ALL NULL NULL NULL # 1 100.00 Using where; Using join buffer (hash join) +Note 1003 /* select#1 */ select distinct min(`test`.`t1`.`b`) AS `min(b)` from `test`.`t1` left join `test`.`t2` on(true) where true group by `test`.`t1`.`a` order by min(`test`.`t1`.`c`) +Warnings: +Insert rows in different order: +delete from t1; +insert into t1 values(200,1,1),(100,1,2),(400,2,2),(300,2,1); +analyze table t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +And get a different order. Query is executed like this: +- First, DISTINCT, using a tmp MEMORY table with a unique +index, thus if two rows have the same 'b' but a different 'c', +the second row is rejected, so the first value of 'c' wins +(=> randomness of 'c') +- Second, ORDER BY on the random 'c'. +select distinct b from v1 order by c; +b +1 +2 +Random order too (same reason): +select distinct min(b) from v1 group by a order by min(c); +min(b) +1 +2 +This query gives random order: +select distinct b from v1 order by c; +ERROR HY000: Expression #1 of ORDER BY clause is not in SELECT list, references column 'test.v1.c' which is not in SELECT list; this is incompatible with DISTINCT +and this one too: +select distinct b from v1 order by b-1,b+1,c; +ERROR HY000: Expression #3 of ORDER BY clause is not in SELECT list, references column 'test.v1.c' which is not in SELECT list; this is incompatible with DISTINCT +and this one too: +select distinct min(b) from v1 group by a order by min(c); +ERROR HY000: Expression #1 of ORDER BY clause is not in SELECT list, contains aggregate function; this is incompatible with DISTINCT +Not random (though Standard bans aggregates from ORDER BY): +select distinct min(b) from v1 group by a order by min(b); +min(b) +1 +2 +select distinct min(b) from v1 group by a order by -min(b); +ERROR HY000: Expression #1 of ORDER BY clause is not in SELECT list, contains aggregate function; this is incompatible with DISTINCT +All group exprs are in select list => DISTINCT is removed => no error +select distinct a, min(b) from v1 group by a order by max(b-2)-min(c*5); +a min(b) +100 1 +400 2 +200 1 +300 2 +This one is standard: +select distinct min(b) as z from v1 group by a order by z; +z +1 +2 +Other queries: +select distinct b from v1 where b<0 order by rand(); +b +select distinct b from v1 order by 45.0+3; +b +1 +2 +select (select distinct b from v1 as S2 where b=7 order by S3.a) from v1 as S3; +(select distinct b from v1 as S2 where b=7 order by S3.a) +NULL +NULL +NULL +NULL +select distinct b from v1 order by abs(b); +b +1 +2 +select distinct b as z from v1 order by abs(z); +z +1 +2 +select distinct b from v1 order by abs(b+a); +ERROR HY000: Expression #1 of ORDER BY clause is not in SELECT list, references column 'test.v1.a' which is not in SELECT list; this is incompatible with DISTINCT +select distinct abs(b) as z from v1 order by z; +z +1 +2 +select distinct abs(b) as z from v1 order by abs(b); +z +1 +2 +select distinct abs(b) from v1 order by abs(b); +abs(b) +1 +2 +Not ok: ABS(b)+1 is neither a SELECTed expression nor an alias +to one, and mentions a column of FROM tables. +select distinct abs(b) as z from v1 order by abs(b)+1; +ERROR HY000: Expression #1 of ORDER BY clause is not in SELECT list, references column 'test.v1.b' which is not in SELECT list; this is incompatible with DISTINCT +select distinct abs(b) as z from v1 order by z+1; +z +1 +2 +select distinct abs(b) from v1 order by abs(b)+1; +ERROR HY000: Expression #1 of ORDER BY clause is not in SELECT list, references column 'test.v1.b' which is not in SELECT list; this is incompatible with DISTINCT +select distinct abs(b) as z from v1 order by floor(10*b); +ERROR HY000: Expression #1 of ORDER BY clause is not in SELECT list, references column 'test.v1.b' which is not in SELECT list; this is incompatible with DISTINCT +select distinct abs(b) from v1 order by floor(10*b); +ERROR HY000: Expression #1 of ORDER BY clause is not in SELECT list, references column 'test.v1.b' which is not in SELECT list; this is incompatible with DISTINCT +Two offending columns; error message needs to report only one +select distinct abs(b) from v1 order by floor(10*b),floor(10*a); +ERROR HY000: Expression #1 of ORDER BY clause is not in SELECT list, references column 'test.v1.b' which is not in SELECT list; this is incompatible with DISTINCT +select distinct abs(b) from v1 as S2 order by +(select floor(10*S2.b) from v1 as S3 limit 1); +ERROR HY000: Expression #1 of ORDER BY clause is not in SELECT list, references column 'test.S2.b' which is not in SELECT list; this is incompatible with DISTINCT +Ok as S2.b in SELECT list +select distinct abs(b),b from v1 as S2 order by +(select floor(10*S2.b) from v1 as S3 limit 1); +abs(b) b +1 1 +2 2 +Ok as subq does not use columns of FROM clause of ordered Q. +select distinct abs(b) from v1 as S2 order by +(select floor(10*S3.b) from v1 as S3 limit 1); +abs(b) +1 +2 +Subq as alias => ok +select distinct abs(b), +(select floor(10*S3.b) from v1 as S3 limit 1) as subq +from v1 as S2 order by subq; +abs(b) subq +1 10 +2 10 +Bad field in left or right argument of ALL/ANY(subq): +select distinct abs(b) from v1 as S2 order by +floor(10*S2.b) IN (select floor(10*S3.b) from v1 as S3); +ERROR HY000: Expression #1 of ORDER BY clause is not in SELECT list, references column 'test.S2.b' which is not in SELECT list; this is incompatible with DISTINCT +select distinct abs(b) from v1 as S2 order by +floor(10*S2.b) > ALL(select floor(10*S3.b) from v1 as S3); +ERROR HY000: Expression #1 of ORDER BY clause is not in SELECT list, references column 'test.S2.b' which is not in SELECT list; this is incompatible with DISTINCT +select distinct abs(b) from v1 as S2 order by +floor(10*10) IN (select floor(10*S2.b) from v1 as S3); +ERROR HY000: Expression #1 of ORDER BY clause is not in SELECT list, references column 'test.S2.b' which is not in SELECT list; this is incompatible with DISTINCT +select distinct abs(b) from v1 as S2 order by +floor(10*10) > ALL(select floor(10*S2.b) from v1 as S3); +ERROR HY000: Expression #1 of ORDER BY clause is not in SELECT list, references column 'test.S2.b' which is not in SELECT list; this is incompatible with DISTINCT +Aggregates: +SELECT distinct 1 FROM t1 group by a order by count(*); +ERROR HY000: Expression #1 of ORDER BY clause is not in SELECT list, contains aggregate function; this is incompatible with DISTINCT +SELECT distinct 1 FROM t1 group by a order by count(*)-count(*); +ERROR HY000: Expression #1 of ORDER BY clause is not in SELECT list, contains aggregate function; this is incompatible with DISTINCT +Test ANY_VALUE +SELECT distinct 1 FROM t1 group by a order by any_value(count(*)-count(b)); +1 +1 +SELECT distinct 1 FROM t1 group by a order by any_value(count(*))-any_value(count(b)); +1 +1 +All group exprs are in select list => DISTINCT is removed => no error +SELECT distinct a, min(b) FROM t1 group by a order by count(*)-count(*); +a min(b) +100 1 +200 1 +300 2 +400 2 +SELECT distinct 1 FROM t1 group by a order by count(*)-count(b); +ERROR HY000: Expression #1 of ORDER BY clause is not in SELECT list, contains aggregate function; this is incompatible with DISTINCT +aggregation in outer Q => constant in inner Q +select * from t1 as t2 where t2.a in +(SELECT distinct 1 FROM t1 group by a order by count(t2.a)-max(t2.a)); +a b c +ORDER BY expressions are in SELECT list => ok +SELECT distinct 1, count(*)-count(b) FROM t1 group by a order by count(*)-count(b); +1 count(*)-count(b) +1 0 +Without GROUP BY, aggregates yield a single row, no random order +SELECT distinct sum(a) FROM t1 order by count(*)-count(*); +sum(a) +1000 +SELECT distinct sum(a) FROM t1 order by count(*)-count(b); +sum(a) +1000 +Verify that DISTINCT is optimized away even if the aggregate +function is hidden in a subquery +EXPLAIN SELECT DISTINCT MAX(b) FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select max(`test`.`t1`.`b`) AS `MAX(b)` from `test`.`t1` +EXPLAIN SELECT DISTINCT (SELECT MAX(t1.b) FROM t1 AS t2 LIMIT 1) FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +Warnings: +Note 1276 Field or reference 'test.t1.b' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select (/* select#2 */ select max(`test`.`t1`.`b`) from `test`.`t1` `t2` limit 1) AS `(SELECT MAX(t1.b) FROM t1 AS t2 LIMIT 1)` from `test`.`t1` +but if the subquery is the aggregation query, DISTINCT must stay: +EXPLAIN SELECT DISTINCT (SELECT MAX(t1.b+0*t2.a) FROM t1 AS t2 LIMIT 1) FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 4 100.00 Using temporary +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +Warnings: +Note 1276 Field or reference 'test.t1.b' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select distinct (/* select#2 */ select max((`test`.`t1`.`b` + (0 * `test`.`t2`.`a`))) from `test`.`t1` `t2` limit 1) AS `(SELECT MAX(t1.b+0*t2.a) FROM t1 AS t2 LIMIT 1)` from `test`.`t1` +QA's query is properly rejected: +SELECT DISTINCT GP1.a AS g1 FROM v1 AS GP1 +WHERE GP1.a >= 0 +ORDER BY GP1.b LIMIT 8; +ERROR HY000: Expression #1 of ORDER BY clause is not in SELECT list, references column 'test.GP1.b' which is not in SELECT list; this is incompatible with DISTINCT +result order does change depending on chosen plan. +SELECT DISTINCT GP1.a AS g1 FROM v1 AS GP1 +WHERE GP1.a >= 0 +ORDER BY 2+ANY_VALUE(GP1.b) LIMIT 8; +g1 +100 +200 +300 +400 +DELETE FROM t1; +drop view v1; +# Test when selecting from view, again +create view v1 as select t1.a*2 as a, t1.b*2 as b, t1.c*2 as c from t1; +insert into t1 values(100,1,2),(200,1,1),(300,2,1),(400,2,2); +analyze table t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +select distinct b from v1 order by c; +b +4 +2 +select distinct min(b) from v1 group by a order by min(c); +min(b) +2 +4 +explain select distinct min(b) from v1 group by a order by min(c); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL # 4 100.00 Using temporary; Using filesort +Note 1003 /* select#1 */ select distinct min((`test`.`t1`.`b` * 2)) AS `min(b)` from `test`.`t1` group by (`test`.`t1`.`a` * 2) order by min((`test`.`t1`.`c` * 2)) +Warnings: +Insert rows in different order: +delete from t1; +insert into t1 values(200,1,1),(100,1,2),(400,2,2),(300,2,1); +analyze table t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +And get a different order. Query is executed like this: +- First, DISTINCT, using a tmp MEMORY table with a unique +index, thus if two rows have the same 'b' but a different 'c', +the second row is rejected, so the first value of 'c' wins +(=> randomness of 'c') +- Second, ORDER BY on the random 'c'. +select distinct b from v1 order by c; +b +2 +4 +Random order too (same reason): +select distinct min(b) from v1 group by a order by min(c); +min(b) +2 +4 +This query gives random order: +select distinct b from v1 order by c; +ERROR HY000: Expression #1 of ORDER BY clause is not in SELECT list, references column 'test.v1.c' which is not in SELECT list; this is incompatible with DISTINCT +and this one too: +select distinct b from v1 order by b-1,b+1,c; +ERROR HY000: Expression #3 of ORDER BY clause is not in SELECT list, references column 'test.v1.c' which is not in SELECT list; this is incompatible with DISTINCT +and this one too: +select distinct min(b) from v1 group by a order by min(c); +ERROR HY000: Expression #1 of ORDER BY clause is not in SELECT list, contains aggregate function; this is incompatible with DISTINCT +Not random (though Standard bans aggregates from ORDER BY): +select distinct min(b) from v1 group by a order by min(b); +min(b) +2 +4 +select distinct min(b) from v1 group by a order by -min(b); +ERROR HY000: Expression #1 of ORDER BY clause is not in SELECT list, contains aggregate function; this is incompatible with DISTINCT +All group exprs are in select list => DISTINCT is removed => no error +select distinct a, min(b) from v1 group by a order by max(b-2)-min(c*5); +a min(b) +200 2 +800 4 +400 2 +600 4 +This one is standard: +select distinct min(b) as z from v1 group by a order by z; +z +2 +4 +Other queries: +select distinct b from v1 where b<0 order by rand(); +b +select distinct b from v1 order by 45.0+3; +b +2 +4 +select (select distinct b from v1 as S2 where b=7 order by S3.a) from v1 as S3; +(select distinct b from v1 as S2 where b=7 order by S3.a) +NULL +NULL +NULL +NULL +select distinct b from v1 order by abs(b); +b +2 +4 +select distinct b as z from v1 order by abs(z); +z +2 +4 +select distinct b from v1 order by abs(b+a); +ERROR HY000: Expression #1 of ORDER BY clause is not in SELECT list, references column 'test.v1.a' which is not in SELECT list; this is incompatible with DISTINCT +select distinct abs(b) as z from v1 order by z; +z +2 +4 +select distinct abs(b) as z from v1 order by abs(b); +z +2 +4 +select distinct abs(b) from v1 order by abs(b); +abs(b) +2 +4 +Not ok: ABS(b)+1 is neither a SELECTed expression nor an alias +to one, and mentions a column of FROM tables. +select distinct abs(b) as z from v1 order by abs(b)+1; +ERROR HY000: Expression #1 of ORDER BY clause is not in SELECT list, references column 'test.v1.b' which is not in SELECT list; this is incompatible with DISTINCT +select distinct abs(b) as z from v1 order by z+1; +z +2 +4 +select distinct abs(b) from v1 order by abs(b)+1; +ERROR HY000: Expression #1 of ORDER BY clause is not in SELECT list, references column 'test.v1.b' which is not in SELECT list; this is incompatible with DISTINCT +select distinct abs(b) as z from v1 order by floor(10*b); +ERROR HY000: Expression #1 of ORDER BY clause is not in SELECT list, references column 'test.v1.b' which is not in SELECT list; this is incompatible with DISTINCT +select distinct abs(b) from v1 order by floor(10*b); +ERROR HY000: Expression #1 of ORDER BY clause is not in SELECT list, references column 'test.v1.b' which is not in SELECT list; this is incompatible with DISTINCT +Two offending columns; error message needs to report only one +select distinct abs(b) from v1 order by floor(10*b),floor(10*a); +ERROR HY000: Expression #1 of ORDER BY clause is not in SELECT list, references column 'test.v1.b' which is not in SELECT list; this is incompatible with DISTINCT +select distinct abs(b) from v1 as S2 order by +(select floor(10*S2.b) from v1 as S3 limit 1); +ERROR HY000: Expression #1 of ORDER BY clause is not in SELECT list, references column 'test.S2.b' which is not in SELECT list; this is incompatible with DISTINCT +Ok as S2.b in SELECT list +select distinct abs(b),b from v1 as S2 order by +(select floor(10*S2.b) from v1 as S3 limit 1); +abs(b) b +2 2 +4 4 +Ok as subq does not use columns of FROM clause of ordered Q. +select distinct abs(b) from v1 as S2 order by +(select floor(10*S3.b) from v1 as S3 limit 1); +abs(b) +2 +4 +Subq as alias => ok +select distinct abs(b), +(select floor(10*S3.b) from v1 as S3 limit 1) as subq +from v1 as S2 order by subq; +abs(b) subq +2 20 +4 20 +Bad field in left or right argument of ALL/ANY(subq): +select distinct abs(b) from v1 as S2 order by +floor(10*S2.b) IN (select floor(10*S3.b) from v1 as S3); +ERROR HY000: Expression #1 of ORDER BY clause is not in SELECT list, references column 'test.S2.b' which is not in SELECT list; this is incompatible with DISTINCT +select distinct abs(b) from v1 as S2 order by +floor(10*S2.b) > ALL(select floor(10*S3.b) from v1 as S3); +ERROR HY000: Expression #1 of ORDER BY clause is not in SELECT list, references column 'test.S2.b' which is not in SELECT list; this is incompatible with DISTINCT +select distinct abs(b) from v1 as S2 order by +floor(10*10) IN (select floor(10*S2.b) from v1 as S3); +ERROR HY000: Expression #1 of ORDER BY clause is not in SELECT list, references column 'test.S2.b' which is not in SELECT list; this is incompatible with DISTINCT +select distinct abs(b) from v1 as S2 order by +floor(10*10) > ALL(select floor(10*S2.b) from v1 as S3); +ERROR HY000: Expression #1 of ORDER BY clause is not in SELECT list, references column 'test.S2.b' which is not in SELECT list; this is incompatible with DISTINCT +Aggregates: +SELECT distinct 1 FROM t1 group by a order by count(*); +ERROR HY000: Expression #1 of ORDER BY clause is not in SELECT list, contains aggregate function; this is incompatible with DISTINCT +SELECT distinct 1 FROM t1 group by a order by count(*)-count(*); +ERROR HY000: Expression #1 of ORDER BY clause is not in SELECT list, contains aggregate function; this is incompatible with DISTINCT +Test ANY_VALUE +SELECT distinct 1 FROM t1 group by a order by any_value(count(*)-count(b)); +1 +1 +SELECT distinct 1 FROM t1 group by a order by any_value(count(*))-any_value(count(b)); +1 +1 +All group exprs are in select list => DISTINCT is removed => no error +SELECT distinct a, min(b) FROM t1 group by a order by count(*)-count(*); +a min(b) +100 1 +200 1 +300 2 +400 2 +SELECT distinct 1 FROM t1 group by a order by count(*)-count(b); +ERROR HY000: Expression #1 of ORDER BY clause is not in SELECT list, contains aggregate function; this is incompatible with DISTINCT +aggregation in outer Q => constant in inner Q +select * from t1 as t2 where t2.a in +(SELECT distinct 1 FROM t1 group by a order by count(t2.a)-max(t2.a)); +a b c +ORDER BY expressions are in SELECT list => ok +SELECT distinct 1, count(*)-count(b) FROM t1 group by a order by count(*)-count(b); +1 count(*)-count(b) +1 0 +Without GROUP BY, aggregates yield a single row, no random order +SELECT distinct sum(a) FROM t1 order by count(*)-count(*); +sum(a) +1000 +SELECT distinct sum(a) FROM t1 order by count(*)-count(b); +sum(a) +1000 +Verify that DISTINCT is optimized away even if the aggregate +function is hidden in a subquery +EXPLAIN SELECT DISTINCT MAX(b) FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select max(`test`.`t1`.`b`) AS `MAX(b)` from `test`.`t1` +EXPLAIN SELECT DISTINCT (SELECT MAX(t1.b) FROM t1 AS t2 LIMIT 1) FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +Warnings: +Note 1276 Field or reference 'test.t1.b' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select (/* select#2 */ select max(`test`.`t1`.`b`) from `test`.`t1` `t2` limit 1) AS `(SELECT MAX(t1.b) FROM t1 AS t2 LIMIT 1)` from `test`.`t1` +but if the subquery is the aggregation query, DISTINCT must stay: +EXPLAIN SELECT DISTINCT (SELECT MAX(t1.b+0*t2.a) FROM t1 AS t2 LIMIT 1) FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 4 100.00 Using temporary +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +Warnings: +Note 1276 Field or reference 'test.t1.b' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select distinct (/* select#2 */ select max((`test`.`t1`.`b` + (0 * `test`.`t2`.`a`))) from `test`.`t1` `t2` limit 1) AS `(SELECT MAX(t1.b+0*t2.a) FROM t1 AS t2 LIMIT 1)` from `test`.`t1` +QA's query is properly rejected: +SELECT DISTINCT GP1.a AS g1 FROM v1 AS GP1 +WHERE GP1.a >= 0 +ORDER BY GP1.b LIMIT 8; +ERROR HY000: Expression #1 of ORDER BY clause is not in SELECT list, references column 'test.GP1.b' which is not in SELECT list; this is incompatible with DISTINCT +result order does change depending on chosen plan. +SELECT DISTINCT GP1.a AS g1 FROM v1 AS GP1 +WHERE GP1.a >= 0 +ORDER BY 2+ANY_VALUE(GP1.b) LIMIT 8; +g1 +200 +400 +600 +800 +DELETE FROM t1; +drop view v1; +# Test when selecting from derived table +insert into t1 values(100,1,2),(200,1,1),(300,2,1),(400,2,2); +analyze table t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +select distinct b from (SELECT t1.* FROM t1 left join t2 on 1) AS derived order by c; +b +2 +1 +select distinct min(b) from (SELECT t1.* FROM t1 left join t2 on 1) AS derived group by a order by min(c); +min(b) +1 +2 +explain select distinct min(b) from (SELECT t1.* FROM t1 left join t2 on 1) AS derived group by a order by min(c); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL # 4 100.00 Using temporary; Using filesort +1 SIMPLE t2 NULL ALL NULL NULL NULL # 1 100.00 Using where; Using join buffer (hash join) +Note 1003 /* select#1 */ select distinct min(`test`.`t1`.`b`) AS `min(b)` from `test`.`t1` left join `test`.`t2` on(true) where true group by `test`.`t1`.`a` order by min(`test`.`t1`.`c`) +Warnings: +Insert rows in different order: +delete from t1; +insert into t1 values(200,1,1),(100,1,2),(400,2,2),(300,2,1); +analyze table t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +And get a different order. Query is executed like this: +- First, DISTINCT, using a tmp MEMORY table with a unique +index, thus if two rows have the same 'b' but a different 'c', +the second row is rejected, so the first value of 'c' wins +(=> randomness of 'c') +- Second, ORDER BY on the random 'c'. +select distinct b from (SELECT t1.* FROM t1 left join t2 on 1) AS derived order by c; +b +1 +2 +Random order too (same reason): +select distinct min(b) from (SELECT t1.* FROM t1 left join t2 on 1) AS derived group by a order by min(c); +min(b) +1 +2 +This query gives random order: +select distinct b from (SELECT t1.* FROM t1 left join t2 on 1) AS derived order by c; +ERROR HY000: Expression #1 of ORDER BY clause is not in SELECT list, references column 'derived.c' which is not in SELECT list; this is incompatible with DISTINCT +and this one too: +select distinct b from (SELECT t1.* FROM t1 left join t2 on 1) AS derived order by b-1,b+1,c; +ERROR HY000: Expression #3 of ORDER BY clause is not in SELECT list, references column 'derived.c' which is not in SELECT list; this is incompatible with DISTINCT +and this one too: +select distinct min(b) from (SELECT t1.* FROM t1 left join t2 on 1) AS derived group by a order by min(c); +ERROR HY000: Expression #1 of ORDER BY clause is not in SELECT list, contains aggregate function; this is incompatible with DISTINCT +Not random (though Standard bans aggregates from ORDER BY): +select distinct min(b) from (SELECT t1.* FROM t1 left join t2 on 1) AS derived group by a order by min(b); +min(b) +1 +2 +select distinct min(b) from (SELECT t1.* FROM t1 left join t2 on 1) AS derived group by a order by -min(b); +ERROR HY000: Expression #1 of ORDER BY clause is not in SELECT list, contains aggregate function; this is incompatible with DISTINCT +All group exprs are in select list => DISTINCT is removed => no error +select distinct a, min(b) from (SELECT t1.* FROM t1 left join t2 on 1) AS derived group by a order by max(b-2)-min(c*5); +a min(b) +100 1 +400 2 +200 1 +300 2 +This one is standard: +select distinct min(b) as z from (SELECT t1.* FROM t1 left join t2 on 1) AS derived group by a order by z; +z +1 +2 +Other queries: +select distinct b from (SELECT t1.* FROM t1 left join t2 on 1) AS derived where b<0 order by rand(); +b +select distinct b from (SELECT t1.* FROM t1 left join t2 on 1) AS derived order by 45.0+3; +b +1 +2 +select (select distinct b from (SELECT t1.* FROM t1 left join t2 on 1) as S2 where b=7 order by S3.a) from (SELECT t1.* FROM t1 left join t2 on 1) as S3; +(select distinct b from (SELECT t1.* FROM t1 left join t2 on 1) as S2 where b=7 order by S3.a) +NULL +NULL +NULL +NULL +select distinct b from (SELECT t1.* FROM t1 left join t2 on 1) AS derived order by abs(b); +b +1 +2 +select distinct b as z from (SELECT t1.* FROM t1 left join t2 on 1) AS derived order by abs(z); +z +1 +2 +select distinct b from (SELECT t1.* FROM t1 left join t2 on 1) AS derived order by abs(b+a); +ERROR HY000: Expression #1 of ORDER BY clause is not in SELECT list, references column 'derived.a' which is not in SELECT list; this is incompatible with DISTINCT +select distinct abs(b) as z from (SELECT t1.* FROM t1 left join t2 on 1) AS derived order by z; +z +1 +2 +select distinct abs(b) as z from (SELECT t1.* FROM t1 left join t2 on 1) AS derived order by abs(b); +z +1 +2 +select distinct abs(b) from (SELECT t1.* FROM t1 left join t2 on 1) AS derived order by abs(b); +abs(b) +1 +2 +Not ok: ABS(b)+1 is neither a SELECTed expression nor an alias +to one, and mentions a column of FROM tables. +select distinct abs(b) as z from (SELECT t1.* FROM t1 left join t2 on 1) AS derived order by abs(b)+1; +ERROR HY000: Expression #1 of ORDER BY clause is not in SELECT list, references column 'derived.b' which is not in SELECT list; this is incompatible with DISTINCT +select distinct abs(b) as z from (SELECT t1.* FROM t1 left join t2 on 1) AS derived order by z+1; +z +1 +2 +select distinct abs(b) from (SELECT t1.* FROM t1 left join t2 on 1) AS derived order by abs(b)+1; +ERROR HY000: Expression #1 of ORDER BY clause is not in SELECT list, references column 'derived.b' which is not in SELECT list; this is incompatible with DISTINCT +select distinct abs(b) as z from (SELECT t1.* FROM t1 left join t2 on 1) AS derived order by floor(10*b); +ERROR HY000: Expression #1 of ORDER BY clause is not in SELECT list, references column 'derived.b' which is not in SELECT list; this is incompatible with DISTINCT +select distinct abs(b) from (SELECT t1.* FROM t1 left join t2 on 1) AS derived order by floor(10*b); +ERROR HY000: Expression #1 of ORDER BY clause is not in SELECT list, references column 'derived.b' which is not in SELECT list; this is incompatible with DISTINCT +Two offending columns; error message needs to report only one +select distinct abs(b) from (SELECT t1.* FROM t1 left join t2 on 1) AS derived order by floor(10*b),floor(10*a); +ERROR HY000: Expression #1 of ORDER BY clause is not in SELECT list, references column 'derived.b' which is not in SELECT list; this is incompatible with DISTINCT +select distinct abs(b) from (SELECT t1.* FROM t1 left join t2 on 1) as S2 order by +(select floor(10*S2.b) from (SELECT t1.* FROM t1 left join t2 on 1) as S3 limit 1); +ERROR HY000: Expression #1 of ORDER BY clause is not in SELECT list, references column 'S2.b' which is not in SELECT list; this is incompatible with DISTINCT +Ok as S2.b in SELECT list +select distinct abs(b),b from (SELECT t1.* FROM t1 left join t2 on 1) as S2 order by +(select floor(10*S2.b) from (SELECT t1.* FROM t1 left join t2 on 1) as S3 limit 1); +abs(b) b +1 1 +2 2 +Ok as subq does not use columns of FROM clause of ordered Q. +select distinct abs(b) from (SELECT t1.* FROM t1 left join t2 on 1) as S2 order by +(select floor(10*S3.b) from (SELECT t1.* FROM t1 left join t2 on 1) as S3 limit 1); +abs(b) +1 +2 +Subq as alias => ok +select distinct abs(b), +(select floor(10*S3.b) from (SELECT t1.* FROM t1 left join t2 on 1) as S3 limit 1) as subq +from (SELECT t1.* FROM t1 left join t2 on 1) as S2 order by subq; +abs(b) subq +1 10 +2 10 +Bad field in left or right argument of ALL/ANY(subq): +select distinct abs(b) from (SELECT t1.* FROM t1 left join t2 on 1) as S2 order by +floor(10*S2.b) IN (select floor(10*S3.b) from (SELECT t1.* FROM t1 left join t2 on 1) as S3); +ERROR HY000: Expression #1 of ORDER BY clause is not in SELECT list, references column 'S2.b' which is not in SELECT list; this is incompatible with DISTINCT +select distinct abs(b) from (SELECT t1.* FROM t1 left join t2 on 1) as S2 order by +floor(10*S2.b) > ALL(select floor(10*S3.b) from (SELECT t1.* FROM t1 left join t2 on 1) as S3); +ERROR HY000: Expression #1 of ORDER BY clause is not in SELECT list, references column 'S2.b' which is not in SELECT list; this is incompatible with DISTINCT +select distinct abs(b) from (SELECT t1.* FROM t1 left join t2 on 1) as S2 order by +floor(10*10) IN (select floor(10*S2.b) from (SELECT t1.* FROM t1 left join t2 on 1) as S3); +ERROR HY000: Expression #1 of ORDER BY clause is not in SELECT list, references column 'S2.b' which is not in SELECT list; this is incompatible with DISTINCT +select distinct abs(b) from (SELECT t1.* FROM t1 left join t2 on 1) as S2 order by +floor(10*10) > ALL(select floor(10*S2.b) from (SELECT t1.* FROM t1 left join t2 on 1) as S3); +ERROR HY000: Expression #1 of ORDER BY clause is not in SELECT list, references column 'S2.b' which is not in SELECT list; this is incompatible with DISTINCT +Aggregates: +SELECT distinct 1 FROM t1 group by a order by count(*); +ERROR HY000: Expression #1 of ORDER BY clause is not in SELECT list, contains aggregate function; this is incompatible with DISTINCT +SELECT distinct 1 FROM t1 group by a order by count(*)-count(*); +ERROR HY000: Expression #1 of ORDER BY clause is not in SELECT list, contains aggregate function; this is incompatible with DISTINCT +Test ANY_VALUE +SELECT distinct 1 FROM t1 group by a order by any_value(count(*)-count(b)); +1 +1 +SELECT distinct 1 FROM t1 group by a order by any_value(count(*))-any_value(count(b)); +1 +1 +All group exprs are in select list => DISTINCT is removed => no error +SELECT distinct a, min(b) FROM t1 group by a order by count(*)-count(*); +a min(b) +100 1 +200 1 +300 2 +400 2 +SELECT distinct 1 FROM t1 group by a order by count(*)-count(b); +ERROR HY000: Expression #1 of ORDER BY clause is not in SELECT list, contains aggregate function; this is incompatible with DISTINCT +aggregation in outer Q => constant in inner Q +select * from t1 as t2 where t2.a in +(SELECT distinct 1 FROM t1 group by a order by count(t2.a)-max(t2.a)); +a b c +ORDER BY expressions are in SELECT list => ok +SELECT distinct 1, count(*)-count(b) FROM t1 group by a order by count(*)-count(b); +1 count(*)-count(b) +1 0 +Without GROUP BY, aggregates yield a single row, no random order +SELECT distinct sum(a) FROM t1 order by count(*)-count(*); +sum(a) +1000 +SELECT distinct sum(a) FROM t1 order by count(*)-count(b); +sum(a) +1000 +Verify that DISTINCT is optimized away even if the aggregate +function is hidden in a subquery +EXPLAIN SELECT DISTINCT MAX(b) FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select max(`test`.`t1`.`b`) AS `MAX(b)` from `test`.`t1` +EXPLAIN SELECT DISTINCT (SELECT MAX(t1.b) FROM t1 AS t2 LIMIT 1) FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +Warnings: +Note 1276 Field or reference 'test.t1.b' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select (/* select#2 */ select max(`test`.`t1`.`b`) from `test`.`t1` `t2` limit 1) AS `(SELECT MAX(t1.b) FROM t1 AS t2 LIMIT 1)` from `test`.`t1` +but if the subquery is the aggregation query, DISTINCT must stay: +EXPLAIN SELECT DISTINCT (SELECT MAX(t1.b+0*t2.a) FROM t1 AS t2 LIMIT 1) FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 4 100.00 Using temporary +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +Warnings: +Note 1276 Field or reference 'test.t1.b' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select distinct (/* select#2 */ select max((`test`.`t1`.`b` + (0 * `test`.`t2`.`a`))) from `test`.`t1` `t2` limit 1) AS `(SELECT MAX(t1.b+0*t2.a) FROM t1 AS t2 LIMIT 1)` from `test`.`t1` +QA's query is properly rejected: +SELECT DISTINCT GP1.a AS g1 FROM (SELECT t1.* FROM t1 left join t2 on 1) AS GP1 +WHERE GP1.a >= 0 +ORDER BY GP1.b LIMIT 8; +ERROR HY000: Expression #1 of ORDER BY clause is not in SELECT list, references column 'GP1.b' which is not in SELECT list; this is incompatible with DISTINCT +result order does change depending on chosen plan. +SELECT DISTINCT GP1.a AS g1 FROM (SELECT t1.* FROM t1 left join t2 on 1) AS GP1 +WHERE GP1.a >= 0 +ORDER BY 2+ANY_VALUE(GP1.b) LIMIT 8; +g1 +100 +200 +300 +400 +DELETE FROM t1; +select distinct t1_outer.a from t1 t1_outer +order by t1_outer.b; +ERROR HY000: Expression #1 of ORDER BY clause is not in SELECT list, references column 'test.t1_outer.b' which is not in SELECT list; this is incompatible with DISTINCT +select distinct t1_outer.a from t1 t1_outer +order by (select max(t1_outer.b+t1_inner.b) from t1 t1_inner); +ERROR HY000: Expression #1 of ORDER BY clause is not in SELECT list, references column 'test.t1_outer.b' which is not in SELECT list; this is incompatible with DISTINCT +select +(select distinct 1 from t1 t1_inner +group by t1_inner.a order by max(t1_outer.b)) +from t1 t1_outer; +(select distinct 1 from t1 t1_inner +group by t1_inner.a order by max(t1_outer.b)) +NULL +drop table t1, t2; diff --git a/mysql-test/r/endspace.result-pq b/mysql-test/r/endspace.result-pq new file mode 100644 index 000000000000..ab75a7d4134c --- /dev/null +++ b/mysql-test/r/endspace.result-pq @@ -0,0 +1,243 @@ +drop table if exists t1; +set names utf8mb4 collate utf8mb4_unicode_ci; +select 'a' = 'a', 'a' = 'a ', 'a ' = 'a'; +'a' = 'a' 'a' = 'a ' 'a ' = 'a' +1 1 1 +select 'a\0' = 'a', 'a\0' < 'a', 'a\0' > 'a'; +'a\0' = 'a' 'a\0' < 'a' 'a\0' > 'a' +1 0 0 +select 'a' = 'a\0', 'a' < 'a\0', 'a' > 'a\0'; +'a' = 'a\0' 'a' < 'a\0' 'a' > 'a\0' +1 0 0 +select 'a\0' = 'a ', 'a\0' < 'a ', 'a\0' > 'a '; +'a\0' = 'a ' 'a\0' < 'a ' 'a\0' > 'a ' +1 0 0 +select 'a ' = 'a\0', 'a ' < 'a\0', 'a ' > 'a\0'; +'a ' = 'a\0' 'a ' < 'a\0' 'a ' > 'a\0' +1 0 0 +select 'a a' > 'a', 'a \0' < 'a'; +'a a' > 'a' 'a \0' < 'a' +1 0 +select binary 'a a' > 'a', binary 'a \0' > 'a', binary 'a\0' > 'a'; +binary 'a a' > 'a' binary 'a \0' > 'a' binary 'a\0' > 'a' +1 1 1 +set names default; +create table t1 (text1 varchar(32) not NULL, KEY key1 (text1)) charset latin1; +insert into t1 values ('teststring'), ('nothing'), ('teststring\t'); +analyze table t1; +check table t1; +Table Op Msg_type Msg_text +test.t1 check status OK +select * from t1 ignore key (key1) where text1='teststring' or +text1 like 'teststring_%' ORDER BY text1; +text1 +teststring +teststring +select * from t1 where text1='teststring' or text1 like 'teststring_%'; +text1 +teststring +teststring +select * from t1 where text1='teststring' or text1 > 'teststring\t'; +text1 +teststring +select * from t1 order by text1; +text1 +nothing +teststring +teststring +explain select * from t1 order by text1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL key1 34 NULL 3 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`text1` AS `text1` from `test`.`t1` order by `test`.`t1`.`text1` +alter table t1 modify text1 char(32) binary not null; +Warnings: +Warning 1287 'BINARY as attribute of a type' is deprecated and will be removed in a future release. Please use a CHARACTER SET clause with _bin collation instead +check table t1; +Table Op Msg_type Msg_text +test.t1 check status OK +select * from t1 ignore key (key1) where text1='teststring' or +text1 like 'teststring_%' ORDER BY text1; +text1 +teststring +teststring +select concat('|', text1, '|') as c from t1 where text1='teststring' or text1 like 'teststring_%' order by c; +c +|teststring | +|teststring| +select concat('|', text1, '|') from t1 where text1='teststring' or text1 > 'teststring\t'; +concat('|', text1, '|') +|teststring| +select text1, length(text1) from t1 order by text1; +text1 length(text1) +nothing 7 +teststring 11 +teststring 10 +select text1, length(text1) from t1 order by binary text1; +text1 length(text1) +nothing 7 +teststring 10 +teststring 11 +alter table t1 modify text1 blob not null, drop key key1, add key key1 (text1(20)); +insert into t1 values ('teststring '); +select concat('|', text1, '|') from t1 order by text1; +concat('|', text1, '|') +|nothing| +|teststring| +|teststring | +|teststring | +select concat('|', text1, '|') from t1 where text1='teststring' or text1 > 'teststring\t'; +concat('|', text1, '|') +|teststring | +|teststring| +select concat('|', text1, '|') from t1 where text1='teststring'; +concat('|', text1, '|') +|teststring| +select concat('|', text1, '|') from t1 where text1='teststring '; +concat('|', text1, '|') +|teststring | +alter table t1 modify text1 text not null, pack_keys=1; +analyze table t1; +select concat('|', text1, '|') from t1 where text1='teststring'; +concat('|', text1, '|') +|teststring | +|teststring| +select concat('|', text1, '|') from t1 where text1='teststring '; +concat('|', text1, '|') +|teststring | +|teststring| +explain select concat('|', text1, '|') from t1 where text1='teststring '; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ref key1 key1 22 const 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select concat('|',`test`.`t1`.`text1`,'|') AS `concat('|', text1, '|')` from `test`.`t1` where (`test`.`t1`.`text1` = 'teststring ') +select concat('|', text1, '|') from t1 where text1 like 'teststring_%'; +concat('|', text1, '|') +|teststring | +|teststring | +select concat('|', text1, '|') as c from t1 where text1='teststring' or text1 like 'teststring_%' order by c; +c +|teststring | +|teststring | +|teststring| +select concat('|', text1, '|') from t1 where text1='teststring' or text1 > 'teststring\t'; +concat('|', text1, '|') +|teststring | +|teststring| +select concat('|', text1, '|') from t1 order by text1; +concat('|', text1, '|') +|nothing| +|teststring | +|teststring| +|teststring | +drop table t1; +create table t1 (text1 varchar(32) not NULL, KEY key1 (text1)) charset latin1 pack_keys=0; +insert into t1 values ('teststring'), ('nothing'), ('teststring\t'); +select concat('|', text1, '|') as c from t1 where text1='teststring' or text1 like 'teststring_%' order by c; +c +|teststring | +|teststring| +select concat('|', text1, '|') from t1 where text1='teststring' or text1 >= 'teststring\t'; +concat('|', text1, '|') +|teststring | +|teststring| +drop table t1; +create table t1 (text1 varchar(32) not NULL, KEY key1 using BTREE (text1)) +charset latin1 engine=heap; +insert into t1 values ('teststring'), ('nothing'), ('teststring\t'); +select * from t1 ignore key (key1) where text1='teststring' or +text1 like 'teststring_%' ORDER BY text1; +text1 +teststring +teststring +select * from t1 where text1='teststring' or text1 like 'teststring_%'; +text1 +teststring +teststring +select * from t1 where text1='teststring' or text1 >= 'teststring\t'; +text1 +teststring +teststring +select * from t1 order by text1; +text1 +nothing +teststring +teststring +explain select * from t1 order by text1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`text1` AS `text1` from `test`.`t1` order by `test`.`t1`.`text1` +alter table t1 modify text1 char(32) binary not null; +Warnings: +Warning 1287 'BINARY as attribute of a type' is deprecated and will be removed in a future release. Please use a CHARACTER SET clause with _bin collation instead +select * from t1 order by text1; +text1 +nothing +teststring +teststring +drop table t1; +create table t1 (text1 varchar(32) not NULL, KEY key1 (text1)) +charset latin1 engine=innodb; +insert into t1 values ('teststring'), ('nothing'), ('teststring\t'); +analyze table t1; +check table t1; +Table Op Msg_type Msg_text +test.t1 check status OK +select * from t1 where text1='teststring' or text1 like 'teststring_%'; +text1 +teststring +teststring +select * from t1 where text1='teststring' or text1 > 'teststring\t'; +text1 +teststring +select * from t1 order by text1; +text1 +nothing +teststring +teststring +explain select * from t1 order by text1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL key1 34 NULL 3 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`text1` AS `text1` from `test`.`t1` order by `test`.`t1`.`text1` +alter table t1 modify text1 char(32) binary not null; +Warnings: +Warning 1287 'BINARY as attribute of a type' is deprecated and will be removed in a future release. Please use a CHARACTER SET clause with _bin collation instead +select * from t1 order by text1; +text1 +nothing +teststring +teststring +alter table t1 modify text1 blob not null, drop key key1, add key key1 (text1(20)); +insert into t1 values ('teststring '); +select concat('|', text1, '|') from t1 order by text1; +concat('|', text1, '|') +|nothing| +|teststring | +|teststring | +|teststring| +alter table t1 modify text1 text not null, pack_keys=1; +select * from t1 where text1 like 'teststring_%'; +text1 +teststring +teststring +select text1, length(text1) from t1 where text1='teststring' or text1 like 'teststring_%'; +text1 length(text1) +teststring 11 +teststring 10 +teststring 11 +select text1, length(text1) from t1 where text1='teststring' or text1 >= 'teststring\t'; +text1 length(text1) +teststring 11 +teststring 10 +teststring 11 +select concat('|', text1, '|') from t1 order by text1; +concat('|', text1, '|') +|nothing| +|teststring | +|teststring| +|teststring | +drop table t1; diff --git a/mysql-test/r/explain_tree.result-pq b/mysql-test/r/explain_tree.result-pq new file mode 100644 index 000000000000..8e8f8d6a1fb2 --- /dev/null +++ b/mysql-test/r/explain_tree.result-pq @@ -0,0 +1,861 @@ +set optimizer_switch='batched_key_access=off,block_nested_loop=off,mrr_cost_based=off'; +CREATE TABLE t1 ( f1 INT ); +INSERT INTO t1 VALUES ( 1 ); +INSERT INTO t1 VALUES ( 2 ); +INSERT INTO t1 VALUES ( 3 ); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN FORMAT=tree SELECT * FROM t1; +EXPLAIN +-> Parallel scan on + -> PQblock scan on t1 (cost=0.55 rows=3) + +DROP TABLE t1; +CREATE TABLE t1 ( f1 INT ); +CREATE TABLE t2 ( f1 INT ); +EXPLAIN FORMAT=tree INSERT INTO t2 SELECT * FROM t1; +EXPLAIN +-> Insert into t2 + -> Table scan on t1 (cost=0.35 rows=1) + +DROP TABLE t1, t2; +CREATE TABLE t1 ( f1 INT ); +CREATE TABLE t2 ( f2 INT ); +EXPLAIN FORMAT=tree UPDATE t1, t2 SET f1=f1+2, f2=f2+1 WHERE f1 = f2; +EXPLAIN +-> Update t1 (buffered), t2 (buffered) + -> Nested loop inner join (cost=0.70 rows=1) + -> Table scan on t1 (cost=0.35 rows=1) + -> Filter: (t2.f2 = t1.f1) (cost=0.35 rows=1) + -> Table scan on t2 (cost=0.35 rows=1) + +DROP TABLE t1, t2; +CREATE TABLE t1 ( f1 INT ); +CREATE TABLE t2 ( f2 INT ); +EXPLAIN FORMAT=tree DELETE t1, t2 FROM t1, t2; +EXPLAIN +-> Delete from t1 (immediate), t2 (buffered) + -> Nested loop inner join (cost=0.70 rows=1) + -> Table scan on t1 (cost=0.35 rows=1) + -> Table scan on t2 (cost=0.35 rows=1) + +DROP TABLE t1, t2; +CREATE TABLE t1 ( f1 INT ); +INSERT INTO t1 VALUES ( 1 ); +INSERT INTO t1 VALUES ( 2 ); +INSERT INTO t1 VALUES ( 3 ); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN FORMAT=tree SELECT f1, (SELECT MIN(f1) FROM t1 i WHERE i.f1 > t1.f1) < 3 FROM t1; +EXPLAIN +-> Table scan on t1 (cost=0.55 rows=3) +-> Select #2 (subquery in projection; dependent) + -> Aggregate: min(i.f1) + -> Filter: (i.f1 > t1.f1) (cost=0.35 rows=1) + -> Table scan on i (cost=0.35 rows=3) + +Warnings: +Note 1276 Field or reference 'test.t1.f1' of SELECT #2 was resolved in SELECT #1 +DROP TABLE t1; +CREATE TABLE t1 ( f1 INT PRIMARY KEY ); +INSERT INTO t1 VALUES ( 1 ); +INSERT INTO t1 VALUES ( 2 ); +INSERT INTO t1 VALUES ( 3 ); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN FORMAT=tree SELECT * FROM t1 ORDER BY f1 DESC; +EXPLAIN +-> Parallel scan on + -> PQblock scan on t1 using PRIMARY (reverse) (cost=0.55 rows=3) + +DROP TABLE t1; +CREATE TABLE t1 ( f1 INT, INDEX ( f1 ) ); +INSERT INTO t1 VALUES ( 1 ); +INSERT INTO t1 VALUES ( 2 ); +INSERT INTO t1 VALUES ( 3 ); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN FORMAT=tree SELECT SUM(f1) FROM t1; +EXPLAIN +-> Aggregate: sum(`SUM(f1)`) + -> Parallel scan on + -> Aggregate: + -> PQblock scan on t1 using f1 (cost=0.55 rows=3) + +EXPLAIN FORMAT=tree SELECT f1 FROM t1 GROUP BY f1; +EXPLAIN +-> Group (no aggregates) + -> Parallel scan on + -> Group (no aggregates) + -> PQblock scan on t1 using f1 (cost=0.55 rows=3) + +EXPLAIN FORMAT=tree SELECT f1,COUNT(*) FROM t1 GROUP BY f1; +EXPLAIN +-> Group aggregate: count(`COUNT(*)`) + -> Parallel scan on + -> Group (no aggregates) + -> PQblock scan on t1 using f1 (cost=0.55 rows=3) + +EXPLAIN FORMAT=tree SELECT f1,COUNT(*) FROM t1 GROUP BY f1 WITH ROLLUP; +EXPLAIN +-> Group aggregate with rollup: count(0) + -> Index scan on t1 using f1 (cost=0.55 rows=3) + +DROP TABLE t1; +CREATE TABLE t1 ( f1 INT PRIMARY KEY ); +INSERT INTO t1 VALUES ( 1 ); +INSERT INTO t1 VALUES ( 2 ); +INSERT INTO t1 VALUES ( 3 ); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN FORMAT=tree SELECT * FROM t1 WHERE f1=2; +EXPLAIN +-> Rows fetched before execution (cost=0.00..0.00 rows=1) + +DROP TABLE t1; +CREATE TABLE t1 ( f1 INT PRIMARY KEY ); +INSERT INTO t1 VALUES ( 1 ); +INSERT INTO t1 VALUES ( 2 ); +INSERT INTO t1 VALUES ( 3 ); +CREATE TABLE t2 ( f1 INT PRIMARY KEY ); +INSERT INTO t2 SELECT * FROM t1; +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN FORMAT=tree SELECT * FROM t1 LEFT JOIN t2 ON t1.f1 = t2.f1 + 2 AND t2.f1 = 3; +EXPLAIN +-> Parallel scan on + -> Nested loop left join (cost=1.10 rows=3) + -> PQblock scan on t1 using PRIMARY (cost=0.55 rows=3) + -> Filter: (t1.f1 = ((3 + 2))) (cost=0.12..0.12 rows=1) + -> Constant row from t2 (cost=0.12..0.12 rows=1) + +DROP TABLE t1, t2; +CREATE TABLE t1 ( f1 INT PRIMARY KEY ); +INSERT INTO t1 VALUES ( 1 ); +INSERT INTO t1 VALUES ( 2 ); +INSERT INTO t1 VALUES ( 3 ); +CREATE TABLE t2 AS SELECT * FROM t1; +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN FORMAT=tree SELECT * FROM t1 LEFT JOIN t2 USING (f1) WHERE t1.f1=2; +EXPLAIN +-> Nested loop left join (cost=0.55 rows=3) + -> Rows fetched before execution (cost=0.00..0.00 rows=1) + -> Filter: (t2.f1 = 2) (cost=0.55 rows=3) + -> Table scan on t2 (cost=0.55 rows=3) + +DROP TABLE t1, t2; +CREATE TABLE t1 ( a INT ); +CREATE TABLE t2 ( a INT ); +CREATE TABLE t3 ( a INT, b INT ); +INSERT INTO t1 VALUES ( 1 ); +INSERT INTO t2 VALUES ( 3 ); +INSERT INTO t3 VALUES ( 2, 0 ); +ANALYZE TABLE t1, t2, t3; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +EXPLAIN FORMAT=tree SELECT * FROM t1 LEFT JOIN ( t2 LEFT JOIN t3 USING (a) ) ON t3.b IS NULL; +EXPLAIN +-> Parallel scan on + -> Nested loop left join (cost=0.70 rows=1) + -> PQblock scan on t1 (cost=0.35 rows=1) + -> Filter: (t3.b is null) (cost=0.70 rows=1) + -> Nested loop left join (cost=0.70 rows=1) + -> Table scan on t2 (cost=0.35 rows=1) + -> Filter: (t3.a = t2.a) (cost=0.35 rows=1) + -> Table scan on t3 (cost=0.35 rows=1) + +DROP TABLE t1, t2, t3; +CREATE TABLE t1 ( f1 INT PRIMARY KEY ); +INSERT INTO t1 VALUES ( 1 ); +INSERT INTO t1 VALUES ( 2 ); +INSERT INTO t1 VALUES ( 3 ); +CREATE TABLE t2 AS SELECT * FROM t1; +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN FORMAT=tree SELECT * FROM t1 LEFT JOIN t2 USING (f1) WHERE t2.f1 IS NULL; +EXPLAIN +-> Parallel scan on + -> Filter: (t2.f1 is null) (cost=2.80 rows=3) + -> Nested loop antijoin (cost=2.80 rows=3) + -> PQblock scan on t1 using PRIMARY (cost=0.55 rows=3) + -> Filter: (t2.f1 = t1.f1) (cost=0.48 rows=1) + -> Table scan on t2 (cost=0.48 rows=3) + +DROP TABLE t1, t2; +CREATE TABLE t1 (a INT, b INT); +CREATE TABLE t2 (a INT, c INT, KEY(a)); +INSERT INTO t1 VALUES (1, 1), (2, 2); +INSERT INTO t2 VALUES (1, 1), (1, 2), (1, 3), (1, 4), (1, 5), +(2, 1), (2, 2), (2, 3), (2, 4), (2, 5), +(3, 1), (3, 2), (3, 3), (3, 4), (3, 5), +(4, 1), (4, 2), (4, 3), (4, 4), (4, 5); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +FLUSH STATUS; +EXPLAIN FORMAT=tree SELECT DISTINCT b FROM t1 LEFT JOIN t2 USING(a) WHERE c <= 3; +EXPLAIN +-> Table scan on (cost=1.26..2.51 rows=2) + -> Temporary table with deduplication (cost=3.51..4.76 rows=2) + -> Nested loop inner join (cost=2.05 rows=2) + -> Table scan on t1 (cost=0.45 rows=2) + -> Limit: 1 row(s) (cost=0.58 rows=1) + -> Filter: (t2.c <= 3) (cost=0.58 rows=2) + -> Index lookup on t2 using a (a=t1.a) (cost=0.58 rows=5) + +DROP TABLE t1, t2; +CREATE TABLE t1 ( f1 INT ); +INSERT INTO t1 VALUES ( 1 ); +INSERT INTO t1 VALUES ( 2 ); +INSERT INTO t1 VALUES ( 3 ); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN FORMAT=tree SELECT * FROM t1 ORDER BY f1 DESC; +EXPLAIN +-> Parallel scan on + -> Sort: t1.f1 DESC (cost=0.55 rows=3) + -> PQblock scan on t1 + +DROP TABLE t1; +CREATE TABLE t1 ( a LONGBLOB, b INT ); +INSERT INTO t1 VALUES ('a', 0); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN FORMAT=tree SELECT 0 AS foo FROM t1 WHERE 0 = (SELECT group_concat(b) FROM t1 t GROUP BY t1.a) ; +EXPLAIN +-> Filter: (0 = (select #2)) (cost=0.35 rows=1) + -> Table scan on t1 (cost=0.35 rows=1) + -> Select #2 (subquery in condition; dependent) + -> Group aggregate: group_concat(t1.b separator ',') + -> Sort row IDs: t1.a + -> Table scan on (cost=2.51..2.51 rows=1) + -> Temporary table (cost=2.96..2.96 rows=1) + -> Table scan on t (cost=0.35 rows=1) + +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 +DROP TABLE t1; +CREATE TABLE t1 (a text, b varchar(10)); +INSERT INTO t1 VALUES (repeat('1', 1300),'one'), (repeat('1', 1300),'two'); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN FORMAT=tree SELECT SUBSTRING(a,1,10), LENGTH(a) FROM t1 GROUP BY a; +EXPLAIN +-> Table scan on (cost=1.26..2.52 rows=2) + -> Temporary table with deduplication (cost=1.91..3.17 rows=2) + -> Table scan on t1 (cost=0.45 rows=2) + +DROP TABLE t1; +CREATE TABLE t1 ( f1 VARCHAR(100) ); +INSERT INTO t1 VALUES ('abc'); +INSERT INTO t1 VALUES ('abc'); +INSERT INTO t1 VALUES ('def'); +INSERT INTO t1 VALUES ('def'); +INSERT INTO t1 VALUES ('ghi'); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN FORMAT=tree SELECT DISTINCT f1 FROM t1 LIMIT 2; +EXPLAIN +-> Limit: 2 row(s) (cost=1.76..2.28 rows=2) + -> Table scan on (cost=0.51..2.56 rows=5) + -> Temporary table with deduplication (cost=1.76..3.81 rows=5) + -> Limit table size: 2 unique row(s) + -> Table scan on t1 (cost=0.75 rows=5) + +DROP TABLE t1; +CREATE TABLE t1 (a int PRIMARY KEY); +INSERT INTO t1 values (1), (2); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN FORMAT=tree INSERT INTO t1 SELECT a + 2 FROM t1 LIMIT 1; +EXPLAIN +-> Insert into t1 + -> Limit: 1 row(s) (cost=1.91..1.91 rows=1) + -> Table scan on (cost=1.26..2.52 rows=2) + -> Temporary table (cost=1.91..3.17 rows=2) + -> Limit table size: 1 row(s) + -> Index scan on t1 using PRIMARY (cost=0.45 rows=2) + +DROP TABLE t1; +CREATE TABLE t1 (a INTEGER, b INTEGER); +INSERT INTO t1 VALUES (1,3), (2,4), (1,5), +(1,3), (2,1), (1,5), (1,7), (3,1), +(3,2), (3,1), (2,4); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN FORMAT=tree SELECT DISTINCT (COUNT(DISTINCT b) + 1) AS c FROM t1 GROUP BY a; +EXPLAIN +-> Table scan on (cost=2.50..2.50 rows=0) + -> Temporary table with deduplication (cost=5.00..5.00 rows=0) + -> Table scan on (cost=2.50..2.50 rows=0) + -> Temporary table (cost=2.50..2.50 rows=0) + -> Group aggregate: count(distinct t1.b) + -> Sort: t1.a (cost=1.35 rows=11) + -> Table scan on t1 (cost=1.35 rows=11) + +DROP TABLE t1; +CREATE TABLE t1 ( f1 INT PRIMARY KEY ); +INSERT INTO t1 VALUES ( 1 ); +INSERT INTO t1 VALUES ( 2 ); +INSERT INTO t1 VALUES ( 3 ); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN FORMAT=tree SELECT * FROM t1 WHERE f1 = ( SELECT MIN(f1) FROM t1 AS i WHERE i.f1 > t1.f1 ); +EXPLAIN +-> Filter: (t1.f1 = (select #2)) (cost=0.55 rows=3) + -> Index scan on t1 using PRIMARY (cost=0.55 rows=3) + -> Select #2 (subquery in condition; dependent) + -> Aggregate: min(i.f1) + -> Filter: (i.f1 > t1.f1) (cost=0.35 rows=1) + -> Index range scan on i (re-planned for each iteration) (cost=0.35 rows=3) + +Warnings: +Note 1276 Field or reference 'test.t1.f1' of SELECT #2 was resolved in SELECT #1 +EXPLAIN FORMAT=tree SELECT * FROM t1 WHERE f1 > ( SELECT f1 FROM t1 LIMIT 1 ); +EXPLAIN +-> Filter: (t1.f1 > (select #2)) (cost=0.55 rows=2) + -> Index scan on t1 using PRIMARY (cost=0.55 rows=3) + -> Select #2 (subquery in condition; run only once) + -> Limit: 1 row(s) (cost=0.55 rows=1) + -> Index scan on t1 using PRIMARY (cost=0.55 rows=3) + +DROP TABLE t1; +CREATE TABLE t1 ( f1 INT PRIMARY KEY ); +INSERT INTO t1 VALUES ( 1 ); +INSERT INTO t1 VALUES ( 2 ); +INSERT INTO t1 VALUES ( 3 ); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN FORMAT=tree SELECT * FROM t1 WHERE f1 = ( SELECT ( SELECT MIN(f1) FROM t1 AS ii WHERE ii.f1 > t1.f1 ) > i.f1 FROM t1 AS i ) ; +EXPLAIN +-> Filter: (t1.f1 = (select #2)) (cost=0.55 rows=3) + -> Index scan on t1 using PRIMARY (cost=0.55 rows=3) + -> Select #2 (subquery in condition; dependent) + -> Index scan on i using PRIMARY (cost=0.55 rows=3) + -> Select #3 (subquery in projection; dependent) + -> Aggregate: min(ii.f1) + -> Filter: (ii.f1 > t1.f1) (cost=0.35 rows=1) + -> Index range scan on ii (re-planned for each iteration) (cost=0.35 rows=3) + +Warnings: +Note 1276 Field or reference 'test.t1.f1' of SELECT #3 was resolved in SELECT #1 +DROP TABLE t1; +CREATE TABLE t1 ( f1 INT PRIMARY KEY ); +INSERT INTO t1 VALUES ( 1 ); +INSERT INTO t1 VALUES ( 2 ); +INSERT INTO t1 VALUES ( 3 ); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN FORMAT=tree SELECT ( SELECT ( SELECT ( SELECT MIN(f1) FROM t1 i WHERE i.f1 > t1.f1 ) + 1 ) + 1 ) FROM t1; +EXPLAIN +-> Index scan on t1 using PRIMARY (cost=0.55 rows=3) +-> Select #4 (subquery in projection; dependent) + -> Aggregate: min(i.f1) + -> Filter: (i.f1 > t1.f1) (cost=0.35 rows=1) + -> Index range scan on i (re-planned for each iteration) (cost=0.35 rows=3) + +Warnings: +Note 1276 Field or reference 'test.t1.f1' of SELECT #4 was resolved in SELECT #1 +Note 1249 Select 3 was reduced during optimization +Note 1249 Select 2 was reduced during optimization +DROP TABLE t1; +CREATE TABLE t1 ( f1 INT PRIMARY KEY ); +INSERT INTO t1 VALUES ( 1 ); +INSERT INTO t1 VALUES ( 2 ); +INSERT INTO t1 VALUES ( 3 ); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN FORMAT=tree SELECT ( SELECT f1 FROM t1 AS inner_t1 WHERE inner_t1.f1 > t1.f1 LIMIT 1 ) AS tmp1 FROM t1 ORDER BY tmp1; +EXPLAIN +-> Sort: tmp1 + -> Stream results (cost=0.55 rows=3) + -> Index scan on t1 using PRIMARY (cost=0.55 rows=3) +-> Select #2 (subquery in projection; dependent) + -> Limit: 1 row(s) (cost=0.35 rows=1) + -> Filter: (inner_t1.f1 > t1.f1) (cost=0.35 rows=1) + -> Index range scan on inner_t1 (re-planned for each iteration) (cost=0.35 rows=3) + +Warnings: +Note 1276 Field or reference 'test.t1.f1' of SELECT #2 was resolved in SELECT #1 +DROP TABLE t1; +CREATE TABLE t1 (a INTEGER, b INTEGER); +INSERT INTO t1 VALUES (1,3), (2,4), (1,5), +(1,3), (2,1), (1,5), (1,7), (3,1), +(3,2), (3,1), (2,4); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN FORMAT=tree SELECT * FROM t1 WHERE a > 3 ORDER BY b; +EXPLAIN +-> Parallel scan on + -> Sort: t1.b (cost=1.35 rows=11) + -> Filter: (t1.a > 3) + -> PQblock scan on t1 + +DROP TABLE t1; +CREATE TABLE t1 (i INT); +EXPLAIN INSERT INTO t1 VALUES (10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 INSERT t1 NULL ALL NULL NULL NULL NULL NULL NULL NULL +Warnings: +Note 1003 insert into `test`.`t1` values (10) +EXPLAIN FORMAT=tree INSERT INTO t1 VALUES (10); +EXPLAIN + + +DROP TABLE t1; +CREATE TABLE t1 (a INTEGER, b INTEGER); +INSERT INTO t1 VALUES (1,3), (2,4), (1,5), +(1,3), (2,1), (1,5), (1,7), (3,1), +(3,2), (3,1), (2,4); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN FORMAT=tree SELECT * FROM t1 ORDER BY b LIMIT 3; +EXPLAIN +-> Limit: 3 row(s) + -> Parallel scan on + -> Limit: 3 row(s) (cost=1.35 rows=3) + -> Sort: t1.b, limit input to 3 row(s) per chunk (cost=1.35 rows=11) + -> PQblock scan on t1 + +DROP TABLE t1; +CREATE TABLE t1 ( a INTEGER ); +CREATE TABLE t2 ( a INTEGER ); +CREATE TABLE t3 ( a INTEGER ); +EXPLAIN FORMAT=tree SELECT * FROM t1 LEFT JOIN t2 USING ( a ), +LATERAL ( SELECT * FROM t3 WHERE t3.a = t2.a LIMIT 1 ) t3d, +LATERAL ( SELECT * FROM t3 WHERE t3.a > t1.a LIMIT 1 ) t4d; +EXPLAIN +-> Nested loop inner join (cost=9.30 rows=1) + -> Nested loop inner join (cost=3.87 rows=1) + -> Invalidate materialized tables (row from t2) (cost=0.70 rows=1) + -> Nested loop left join (cost=0.70 rows=1) + -> Invalidate materialized tables (row from t1) (cost=0.35 rows=1) + -> Table scan on t1 (cost=0.35 rows=1) + -> Filter: (t2.a = t1.a) (cost=0.35 rows=1) + -> Table scan on t2 (cost=0.35 rows=1) + -> Table scan on t3d (cost=2.51..2.51 rows=1) + -> Materialize (invalidate on row from t2) (cost=2.96..2.96 rows=1) + -> Limit: 1 row(s) (cost=0.35 rows=1) + -> Filter: (t3.a = t2.a) (cost=0.35 rows=1) + -> Table scan on t3 (cost=0.35 rows=1) + -> Table scan on t4d (cost=2.51..2.51 rows=1) + -> Materialize (invalidate on row from t1) (cost=2.96..2.96 rows=1) + -> Limit: 1 row(s) (cost=0.35 rows=1) + -> Filter: (t3.a > t1.a) (cost=0.35 rows=1) + -> Table scan on t3 (cost=0.35 rows=1) + +Warnings: +Note 1276 Field or reference 'test.t2.a' of SELECT #2 was resolved in SELECT #1 +Note 1276 Field or reference 'test.t1.a' of SELECT #3 was resolved in SELECT #1 +DROP TABLE t1, t2, t3; +CREATE TABLE t1 ( a INTEGER ); +CREATE TABLE t2 ( a INTEGER ); +CREATE TABLE t3 ( a INTEGER ); +CREATE TABLE t4 ( a INTEGER ); +EXPLAIN FORMAT=tree SELECT * FROM t1 LEFT JOIN ( +t2 LEFT JOIN t3 USING ( a ) CROSS JOIN +LATERAL ( SELECT * FROM t4 WHERE t4.a = t3.a LIMIT 1 ) t4d +) ON t1.a = t4d.a; +EXPLAIN +-> Nested loop left join (cost=0.70 rows=1) + -> Table scan on t1 (cost=0.35 rows=1) + -> Nested loop inner join (cost=1.85 rows=1) + -> Invalidate materialized tables (row from t3) (cost=0.70 rows=1) + -> Nested loop left join (cost=0.70 rows=1) + -> Table scan on t2 (cost=0.35 rows=1) + -> Filter: (t3.a = t2.a) (cost=0.35 rows=1) + -> Table scan on t3 (cost=0.35 rows=1) + -> Index lookup on t4d using (a=t1.a) + -> Materialize (invalidate on row from t3) (cost=0.45..0.45 rows=1) + -> Limit: 1 row(s) (cost=0.35 rows=1) + -> Filter: (t4.a = t3.a) (cost=0.35 rows=1) + -> Table scan on t4 (cost=0.35 rows=1) + +Warnings: +Note 1276 Field or reference 'test.t3.a' of SELECT #2 was resolved in SELECT #1 +DROP TABLE t1, t2, t3, t4; +CREATE TABLE t1 ( f1 INTEGER ); +EXPLAIN FORMAT=TREE SELECT * FROM ( SELECT * FROM t1 LIMIT 2 OFFSET 1 ) AS alias1 +WHERE f1 <= ANY ( SELECT f1 FROM t1 ) ORDER BY f1; +EXPLAIN +-> Sort: alias1.f1 + -> Filter: ((alias1.f1 <= (select #3))) (cost=2.62 rows=2) [other sub-iterators not shown] + -> Table scan on alias1 (cost=2.62 rows=2) + -> Materialize (cost=0.35..0.35 rows=0) + -> Limit/Offset: 2/1 row(s) (cost=0.35 rows=0) + -> Table scan on t1 (cost=0.35 rows=1) + +DROP TABLE t1; +CREATE TABLE t1 ( f1 INT ); +CREATE TABLE t2 ( f1 INT ); +EXPLAIN format=tree WITH my_cte AS ( SELECT * FROM t1 LIMIT 3 ) SELECT * FROM my_cte, t2; +EXPLAIN +-> Nested loop inner join (cost=2.98 rows=1) + -> Table scan on t2 (cost=0.35 rows=1) + -> Table scan on my_cte (cost=2.51..2.51 rows=1) + -> Materialize CTE my_cte (cost=2.96..2.96 rows=1) + -> Limit: 3 row(s) (cost=0.35 rows=1) + -> Table scan on t1 (cost=0.35 rows=1) + +DROP TABLE t1; +DROP TABLE t2; +CREATE TABLE t1 (i INTEGER); +CREATE TABLE t2 (i INTEGER); +EXPLAIN FORMAT=tree SELECT * FROM t1 WHERE (t1.i) IN (SELECT t2.i FROM t2); +EXPLAIN +-> Parallel scan on + -> Nested loop semijoin (cost=0.70 rows=1) + -> PQblock scan on t1 (cost=0.35 rows=1) + -> Filter: (t2.i = t1.i) (cost=0.35 rows=1) + -> Table scan on t2 (cost=0.35 rows=1) + +DROP TABLE t1, t2; +CREATE TABLE t1 (pk INTEGER PRIMARY KEY, i INTEGER); +CREATE TABLE t2 (pk INTEGER PRIMARY KEY, i INTEGER); +CREATE TABLE t3 (i INTEGER); +CREATE TABLE t4 (i INTEGER); +INSERT INTO t1 VALUES (2, 3); +INSERT INTO t2 VALUES (4, 5); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN FORMAT=tree SELECT * FROM t1,t2 WHERE (t1.i) IN (SELECT t3.i FROM t3,t4) AND t1.pk = 2 AND t2.pk = 4; +EXPLAIN +-> Limit: 1 row(s) (cost=0.70 rows=1) + -> Nested loop inner join (cost=0.70 rows=1) + -> Filter: (t3.i = '3') (cost=0.35 rows=1) + -> Table scan on t3 (cost=0.35 rows=1) + -> Table scan on t4 (cost=0.35 rows=1) + +DROP TABLE t1, t2, t3, t4; +CREATE TABLE t1 (i INTEGER); +CREATE TABLE t2 (i INTEGER); +CREATE TABLE t3 (i INTEGER, j INTEGER); +EXPLAIN FORMAT=tree SELECT * FROM t1 WHERE t1.i IN ( SELECT i FROM t2 LEFT JOIN t3 USING (i) WHERE t3.j = 1234 OR t3.j IS NULL ); +EXPLAIN +-> Parallel scan on + -> Nested loop semijoin (cost=0.70 rows=1) + -> PQblock scan on t1 (cost=0.35 rows=1) + -> Filter: ((t3.j = 1234) or (t3.j is null)) (cost=0.70 rows=1) + -> Nested loop left join (cost=0.70 rows=1) + -> Filter: (t2.i = t1.i) (cost=0.35 rows=1) + -> Table scan on t2 (cost=0.35 rows=1) + -> Filter: (t2.i = t3.i) (cost=0.35 rows=1) + -> Table scan on t3 (cost=0.35 rows=1) + +DROP TABLE t1, t2, t3; +set @old_opt_switch=@@optimizer_switch; +set optimizer_switch='firstmatch=off'; +CREATE TABLE t1 ( a INTEGER, b INTEGER ); +INSERT INTO t1 VALUES (1,1), (2,2), (3,3); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN FORMAT=tree SELECT a FROM t1 WHERE a = ANY ( SELECT a FROM t1 WHERE b = 2 ); +EXPLAIN +-> Nested loop inner join (cost=3.71 rows=1) + -> Table scan on (cost=2.51..2.51 rows=1) + -> Materialize with deduplication (cost=3.16..3.16 rows=1) + -> Filter: (t1.a is not null) (cost=0.55 rows=1) + -> Filter: (t1.b = 2) (cost=0.55 rows=1) + -> Table scan on t1 (cost=0.55 rows=3) + -> Filter: (t1.a = ``.a) (cost=0.35 rows=1) + -> Table scan on t1 (cost=0.35 rows=3) + +DROP TABLE t1; +set @@optimizer_switch=@old_opt_switch; +set @old_opt_switch=@@optimizer_switch; +set optimizer_switch='firstmatch=off'; +CREATE TABLE t1 ( a INTEGER NOT NULL, b INTEGER NOT NULL ); +INSERT INTO t1 VALUES (1,1), (2,2), (3,3); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN FORMAT=tree SELECT a FROM t1 WHERE a NOT IN ( SELECT b FROM t1 WHERE b > 2 ); +EXPLAIN +-> Nested loop antijoin (cost=1.75 rows=9) + -> Table scan on t1 (cost=0.55 rows=3) + -> Single-row index lookup on using (b=t1.a) + -> Materialize with deduplication (cost=0.85..0.85 rows=3) + -> Filter: (t1.b is not null) (cost=0.55 rows=3) + -> Filter: (t1.b > 2) (cost=0.55 rows=3) + -> Table scan on t1 (cost=0.55 rows=3) + +DROP TABLE t1; +set @@optimizer_switch=@old_opt_switch; +set @old_opt_switch=@@optimizer_switch; +set optimizer_switch='firstmatch=off'; +CREATE TABLE t1 ( a INTEGER, b INTEGER ); +INSERT INTO t1 VALUES (1,1), (2,2), (3,3); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN FORMAT=tree SELECT a FROM t1 WHERE a = ANY ( SELECT MAX(a) FROM t1 WHERE b = 2 ); +EXPLAIN +-> Filter: (t1.a,(select #2)) (cost=0.55 rows=3) + -> Table scan on t1 (cost=0.55 rows=3) + -> Select #2 (subquery in condition; dependent) + -> Limit: 1 row(s) + -> Filter: ((t1.a) = (max(t1.a))) + -> Aggregate: max(t1.a) + -> Filter: (t1.b = 2) (cost=0.55 rows=1) + -> Table scan on t1 (cost=0.55 rows=3) + +DROP TABLE t1; +set @@optimizer_switch=@old_opt_switch; +set @old_opt_switch=@@optimizer_switch; +set optimizer_switch='firstmatch=off,materialization=off,loosescan=off'; +CREATE TABLE t1 ( i INTEGER ); +CREATE TABLE t2 ( i INTEGER ); +INSERT INTO t1 VALUES (1), (2), (3); +INSERT INTO t2 VALUES (2); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN FORMAT=tree SELECT * FROM t1 WHERE (t1.i) IN (SELECT t2.i FROM t2); +EXPLAIN +-> Remove duplicate t1 rows using temporary table (weedout) (cost=0.90 rows=1) + -> Nested loop inner join (cost=0.90 rows=1) + -> Table scan on t2 (cost=0.35 rows=1) + -> Filter: (t1.i = t2.i) (cost=0.35 rows=1) + -> Table scan on t1 (cost=0.35 rows=3) + +DROP TABLE t1; +DROP TABLE t2; +set @@optimizer_switch=@old_opt_switch; +set @old_opt_switch=@@optimizer_switch; +set optimizer_switch='firstmatch=off,materialization=off,loosescan=off'; +CREATE TABLE t1 ( i INTEGER ); +CREATE TABLE t2 ( i INTEGER ); +INSERT INTO t1 VALUES (1), (2), (3); +INSERT INTO t2 VALUES (1), (2), (3), (4); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN FORMAT=tree SELECT * FROM t1 WHERE (t1.i) IN (SELECT t2.i FROM t2); +EXPLAIN +-> Parallel scan on + -> Nested loop inner join (cost=2.50 rows=3) + -> PQblock scan on t1 (cost=0.55 rows=3) + -> Limit: 1 row(s) (cost=0.28 rows=1) + -> Filter: (t2.i = t1.i) (cost=0.28 rows=1) + -> Table scan on t2 (cost=0.28 rows=4) + +DROP TABLE t1; +DROP TABLE t2; +set @@optimizer_switch=@old_opt_switch; +set @old_opt_switch=@@optimizer_switch; +set optimizer_switch='firstmatch=off,materialization=off,duplicateweedout=off,loosescan=on'; +CREATE TABLE t1 ( i INTEGER, PRIMARY KEY (i) ); +CREATE TABLE t2 ( i INTEGER, INDEX i1 (i) ); +INSERT INTO t1 VALUES (2), (3), (4), (5); +INSERT INTO t2 VALUES (1), (2), (3), (4); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN format=tree SELECT * FROM t1 WHERE t1.i IN (SELECT t2.i FROM t2); +EXPLAIN +-> Nested loop inner join (cost=2.05 rows=4) + -> Remove duplicates from input sorted on i1 (cost=0.65 rows=4) + -> Filter: (t2.i is not null) (cost=0.65 rows=4) + -> Index scan on t2 using i1 (cost=0.65 rows=4) + -> Single-row index lookup on t1 using PRIMARY (i=t2.i) (cost=1.10 rows=1) + +DROP TABLE t1; +DROP TABLE t2; +set @@optimizer_switch=@old_opt_switch; +# +# Bug#29904996 EXPLAIN FORMAT=TREE PRINTS OUT HIDDEN COLUMN NAME INSTEAD +# OF INDEXED EXPRESSION +# +CREATE TABLE t1 ( +col_int_key INTEGER, +col_json JSON, +KEY mv_idx ((CAST(col_json->'$[*]' AS CHAR(40) ARRAY))) +); +CREATE TABLE t2 (col_int INTEGER); +# See that we print the indexed expression, and not the hidden column +# name. +EXPLAIN FORMAT=tree SELECT /*+ NO_BNL(t1, t2) */ * FROM t2 +JOIN t1 ON 1 WHERE (CAST("1" AS JSON) MEMBER OF( t1.col_json->'$[*]')); +EXPLAIN +-> Nested loop inner join (cost=0.70 rows=1) + -> Table scan on t2 (cost=0.35 rows=1) + -> Filter: json'"1"' member of (cast(json_extract(col_json,_utf8mb4'$[*]') as char(40) array)) (cost=0.35 rows=1) + -> Index lookup on t1 using mv_idx (cast(json_extract(col_json,_utf8mb4'$[*]') as char(40) array)=json'"1"') (cost=0.35 rows=1) + +DROP TABLE t1, t2; +CREATE TABLE t1 (a INTEGER, b INTEGER, PRIMARY KEY ( a )); +INSERT INTO t1 VALUES (1,3), (2,4), (3,5); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN ANALYZE SELECT * FROM t1 AS a JOIN t1 AS b ON a.a=b.b ORDER BY a.b+b.a LIMIT 3; +EXPLAIN +-> Limit: 3 row(s) (cost=0.00..0.00 rows=0) (actual time=N.NNN..N.NNN rows=0 loops=1) + -> Table scan on (cost=2.50..2.50 rows=0) (never executed) + -> Temporary table (cost=2.50..2.50 rows=0) (actual time=N.NNN..N.NNN rows=0 loops=1) + -> Parallel scan on (actual time=N.NNN..N.NNN rows=1 loops=1) + -> Limit: 3 row(s) (actual time=N.NNN..N.NNN rows=1 loops=1) + -> Sort: `(a.b + b.a)`, limit input to 3 row(s) per chunk (actual time=N.NNN..N.NNN rows=1 loops=1) + -> Stream results (cost=1.60 rows=3) (actual time=N.NNN..N.NNN rows=1 loops=1) + -> Nested loop inner join (cost=1.60 rows=3) (actual time=N.NNN..N.NNN rows=1 loops=1) + -> Filter: (b.b is not null) (cost=0.55 rows=3) (actual time=N.NNN..N.NNN rows=3 loops=1) + -> PQblock scan on b (cost=0.55 rows=3) (actual time=N.NNN..N.NNN rows=3 loops=1) + -> Single-row index lookup on a using PRIMARY (a=b.b) (cost=0.28 rows=1) (actual time=N.NNN..N.NNN rows=0 loops=3) + +EXPLAIN ANALYZE SELECT * FROM t1 AS a, t1 AS b WHERE a.b=500; +EXPLAIN +-> Parallel scan on (actual time=N.NNN..N.NNN rows=0 loops=1) + -> Nested loop inner join (cost=1.10 rows=3) (actual time=N.NNN..N.NNN rows=0 loops=1) + -> Filter: (a.b = 500) (cost=0.55 rows=1) (actual time=N.NNN..N.NNN rows=0 loops=1) + -> PQblock scan on a (cost=0.55 rows=3) (actual time=N.NNN..N.NNN rows=3 loops=1) + -> Table scan on b (cost=0.55 rows=3) (never executed) + +DROP TABLE t1; +EXPLAIN ANALYZE FOR CONNECTION 1; +ERROR 42000: This version of MySQL doesn't yet support 'EXPLAIN ANALYZE FOR CONNECTION' +EXPLAIN ANALYZE FORMAT=TRADITIONAL SELECT 1; +ERROR 42000: This version of MySQL doesn't yet support 'FORMAT=TRADITIONAL with EXPLAIN ANALYZE' +EXPLAIN ANALYZE FORMAT=JSON SELECT 1; +ERROR 42000: This version of MySQL doesn't yet support 'FORMAT=JSON with EXPLAIN ANALYZE' +EXPLAIN ANALYZE FORMAT=TREE SELECT 1; +EXPLAIN +-> Rows fetched before execution (cost=0.00..0.00 rows=1) (actual time=N.NNN..N.NNN rows=1 loops=1) + +EXPLAIN FORMAT=tree SELECT * FROM INFORMATION_SCHEMA.ENGINES; +EXPLAIN +-> Table scan on ENGINES (cost=0.00 rows=0) + -> Fill information schema table ENGINES + +CREATE TABLE t1 ( f1 INT PRIMARY KEY ); +INSERT INTO t1 VALUES (1), (2), (3); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN FORMAT=tree SELECT * FROM t1, ( SELECT f1 FROM t1 UNION SELECT f1 + 10 FROM t1 ) d1; +EXPLAIN +-> Nested loop inner join (cost=10.08 rows=18) + -> Index scan on t1 using PRIMARY (cost=0.55 rows=3) + -> Table scan on d1 (cost=0.43..2.58 rows=6) + -> Union materialize with deduplication (cost=2.13..4.28 rows=6) + -> Index scan on t1 using PRIMARY (cost=0.55 rows=3) + -> Index scan on t1 using PRIMARY (cost=0.55 rows=3) + +EXPLAIN FORMAT=tree SELECT * FROM t1, ( SELECT f1 FROM t1 UNION ALL SELECT f1 + 10 FROM t1 ) d1; +EXPLAIN +-> Nested loop inner join (cost=10.08 rows=18) + -> Index scan on t1 using PRIMARY (cost=0.55 rows=3) + -> Table scan on d1 (cost=0.43..2.58 rows=6) + -> Union materialize (cost=2.13..4.28 rows=6) + -> Index scan on t1 using PRIMARY (cost=0.55 rows=3) + -> Index scan on t1 using PRIMARY (cost=0.55 rows=3) + +DROP TABLE t1; +# +# Bug #30444266: EXPLAIN ANALYZE DOES NOT EXECUTE THE SUBQUERIES IN THE SELECT LIST +# +CREATE TABLE t1 ( f1 INTEGER ); +INSERT INTO t1 VALUES (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN ANALYZE SELECT f1, ( SELECT COUNT(*) FROM t1 AS inner_t1 WHERE inner_t1.f1 < t1.f1 ) FROM t1; +EXPLAIN +-> Table scan on t1 (cost=1.25 rows=10) (actual time=N.NNN..N.NNN rows=10 loops=1) +-> Select #2 (subquery in projection; dependent) + -> Aggregate: count(0) (actual time=N.NNN..N.NNN rows=1 loops=10) + -> Filter: (inner_t1.f1 < t1.f1) (cost=0.58 rows=3) (actual time=N.NNN..N.NNN rows=4 loops=10) + -> Table scan on inner_t1 (cost=0.58 rows=10) (actual time=N.NNN..N.NNN rows=10 loops=10) + +Warnings: +Note 1276 Field or reference 'test.t1.f1' of SELECT #2 was resolved in SELECT #1 +DROP TABLE t1; +# +# Bug#17978975 EXPLAIN FOR MULTI-TABLE UPDATE/DELETE DOES NOT MENTION TEMPORARY TABLE +# +CREATE TABLE t1(a INT, b INT); +CREATE TABLE t2(a INT, b INT); +ANALYZE TABLE t1,t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN FORMAT=TREE UPDATE t1,t2 SET t1.a=1,t2.b=1; +EXPLAIN +-> Update t1 (immediate), t2 (buffered) + -> Nested loop inner join (cost=0.70 rows=1) + -> Table scan on t1 (cost=0.35 rows=1) + -> Table scan on t2 (cost=0.35 rows=1) + +EXPLAIN FORMAT=TREE UPDATE t1,t2 SET t1.a=1,t2.b=1 WHERE t2.a=t1.a; +EXPLAIN +-> Update t1 (buffered), t2 (buffered) + -> Nested loop inner join (cost=0.70 rows=1) + -> Table scan on t1 (cost=0.35 rows=1) + -> Filter: (t2.a = t1.a) (cost=0.35 rows=1) + -> Table scan on t2 (cost=0.35 rows=1) + +EXPLAIN FORMAT=TREE DELETE t1.*,t2.* FROM t1,t2; +EXPLAIN +-> Delete from t1 (immediate), t2 (buffered) + -> Nested loop inner join (cost=0.70 rows=1) + -> Table scan on t1 (cost=0.35 rows=1) + -> Table scan on t2 (cost=0.35 rows=1) + +EXPLAIN FORMAT=TREE DELETE t1.*,t1bis.* FROM t1, t1 AS t1bis; +EXPLAIN +-> Delete from t1 (buffered), t1bis (buffered) + -> Nested loop inner join (cost=0.70 rows=1) + -> Table scan on t1 (cost=0.35 rows=1) + -> Table scan on t1bis (cost=0.35 rows=1) + +DROP TABLE t1,t2; +# +# Bug #30941336: EXPLAIN ANAYLZE SELECT COUNT(*) FROM MYSQL.USER COREDUMP UNDER DEBUG VERSION +# +CREATE TABLE t1 ( a INTEGER ); +EXPLAIN ANALYZE SELECT COUNT(*) FROM t1; +EXPLAIN +-> Count rows in t1 (actual time=N.NNN..N.NNN rows=1 loops=1) + +DROP TABLE t1; +# +# Bug #31559245: REGRESSION: CRASH/ASSERT IN SUBSELECT_HASH_SJ_ENGINE::ROOT_ACCESS_PATH +# +CREATE TABLE t1 (a INTEGER); +EXPLAIN FORMAT=tree SELECT (1 IN (SELECT 1 FROM t1)) WHERE FALSE; +EXPLAIN +-> Zero rows (Impossible WHERE) (cost=0.00..0.00 rows=0) + +DROP TABLE t1; diff --git a/mysql-test/r/filesort.result-pq b/mysql-test/r/filesort.result-pq new file mode 100644 index 000000000000..03e048304790 --- /dev/null +++ b/mysql-test/r/filesort.result-pq @@ -0,0 +1,153 @@ +# +# Bug#24709595 WL#8741: ASSERTION `SORTORDER->NEED_STRXNFRM == 0' FAILED +# +CREATE TABLE t1( +c VARCHAR(10) CHARACTER SET utf8 DEFAULT NULL +); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +CREATE TABLE t2( +c1 VARCHAR(255) CHARACTER SET utf8 DEFAULT NULL, +c2 VARCHAR(10) CHARACTER SET utf8 DEFAULT NULL +); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES('x'); +INSERT INTO t2 VALUES('g','if'), ('not','ojgygqcgqi'); +SELECT * FROM t2 WHERE (c2) <> (SELECT MAX(c) FROM t1 GROUP BY c1); +c1 c2 +g if +not ojgygqcgqi +DROP TABLE t1, t2; +# +# Bug#29660945: SIG 6 AT TEMPTABLE::HANDLER::POSITION | SRC/HANDLER.CC +# +SET optimizer_switch='block_nested_loop=off'; +CREATE TABLE t1 ( +f1 varchar(255), +f2 varchar(255) +); +INSERT INTO t1 VALUES (NULL,'A'); +INSERT INTO t1 VALUES ('A',NULL); +SELECT * FROM t1 AS alias1 JOIN t1 AS alias2 ON alias1.f1=alias2.f2 ORDER BY alias2.f1 LIMIT 50; +f1 f2 f1 f2 +A NULL NULL A +DROP TABLE t1; +SET optimizer_switch=DEFAULT; +SET sort_buffer_size=32768; +CREATE TABLE t1 ( +f1 INTEGER, +f2 LONGBLOB +); +INSERT INTO t1 VALUES ( 2, REPEAT('-', 1048576) ); +INSERT INTO t1 VALUES ( 1, REPEAT('x', 1048576) ); +SELECT * FROM t1 ORDER BY f1; +f1 f2 +1 x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024} +2 -{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024} +DROP TABLE t1; +SET sort_buffer_size=DEFAULT; +# +# Bug #30687020: ORDER BY DOES NOT WORK FOR A COLUMN WITH A STRING FUNCTION AND UTF8MB4_0900_AI_C +# +CREATE TABLE t1 ( f1 VARCHAR(100) ); +INSERT INTO t1 VALUES (''), (NULL), (''), (NULL); +SELECT CONCAT(f1, '') AS dummy FROM t1 ORDER BY dummy; +dummy +NULL +NULL + + +DROP TABLE t1; +# +# Bug #30791074: WEIGHT_STRING: ASSERTION `0' FAILED. IN TIME_ZONE_UTC::TIME_TO_GMT_SEC +# +CREATE TABLE t1 ( f1 INTEGER ); +INSERT INTO t1 VALUES (0), (1), (101); +SELECT * FROM t1 ORDER BY UNIX_TIMESTAMP(f1); +f1 +0 +1 +101 +Warnings: +Warning 1292 Incorrect datetime value: '1' +Warning 1292 Incorrect datetime value: '1' +DROP TABLE t1; +# +# Bug #31397840: Wrong result of SELECT DISTINCT JSON_ARRAYAGG +# +SET sql_mode=''; +CREATE TABLE t1 +( +id INT PRIMARY KEY, +char_field CHAR(10) +); +INSERT INTO t1 VALUES (580801, '580801'); +INSERT INTO t1 VALUES (580901, '580901'); +INSERT INTO t1 VALUES (581001, '581001'); +INSERT INTO t1 VALUES (581101, '581101'); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +SELECT DISTINCT JSON_ARRAYAGG(char_field), JSON_ARRAYAGG(2) FROM t1 GROUP BY id ORDER BY id; +JSON_ARRAYAGG(char_field) JSON_ARRAYAGG(2) +["580801"] [2] +["580901"] [2] +["581001"] [2] +["581101"] [2] +Warnings: +Warning 1235 This version of MySQL doesn't yet support 'sorting of non-scalar JSON values' +EXPLAIN FORMAT=tree SELECT DISTINCT JSON_ARRAYAGG(char_field), JSON_ARRAYAGG(2) FROM t1 GROUP BY id ORDER BY id; +EXPLAIN +-> Sort: t1.id + -> Sort with duplicate removal: `JSON_ARRAYAGG(char_field)`, `JSON_ARRAYAGG(2)` + -> Stream results + -> Group aggregate: json_arrayagg(t1.char_field), json_arrayagg(2) + -> Sort: t1.id + -> Table scan on t1 + +DROP TABLE t1; +SET sql_mode=DEFAULT; +# +# Bug #31588831: ASSERTION FAILURE IN NEWWEEDOUTACCESSPATHFORTABLES() AT SQL/SQL_EXECUTOR.CC +# +CREATE TABLE t1 (pk INTEGER, f2 INTEGER, PRIMARY KEY (pk)); +CREATE TABLE t2 (pk INTEGER, f2 INTEGER, PRIMARY KEY (pk)); +INSERT INTO t1 VALUES (1,1), (2,2); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN FORMAT=tree SELECT * FROM +t1 +LEFT JOIN t1 AS table2 ON 119 IN ( +SELECT SUBQUERY1_t2.pk +FROM t1 AS SUBQUERY1_t1, (t2 AS SUBQUERY1_t2 STRAIGHT_JOIN t1 ON TRUE) +) +ORDER BY t1.f2; +EXPLAIN +-> Parallel scan on + -> Remove duplicate (t1, table2) rows using temporary table (weedout) + -> Nested loop left join + -> Sort row IDs: t1.f2 + -> PQblock scan on t1 + -> Nested loop inner join + -> Nested loop inner join + -> Nested loop inner join + -> Constant row from SUBQUERY1_t2 (cost=0.17..0.17 rows=1) + -> Table scan on table2 + -> Index scan on SUBQUERY1_t1 using PRIMARY + -> Index scan on t1 using PRIMARY + +DROP TABLE t1, t2; +# +# Bug #32169770: HYPERGRAPH: ASSERTION `M_PART_INFO->IS_PARTITION_USED(M_LAST_PART)' FAILED. +# +CREATE TABLE t1 (a LONGTEXT); +INSERT INTO t1 VALUES ('a'); +CREATE TABLE t2 (a INTEGER PRIMARY KEY) PARTITION BY key() PARTITIONS 2; +SELECT 1 AS a FROM t1 LEFT JOIN t2 ON FALSE GROUP BY a; +a +1 +DROP TABLE t1, t2; diff --git a/mysql-test/r/filesort_pack.result-pq b/mysql-test/r/filesort_pack.result-pq new file mode 100644 index 000000000000..13668ef9eba1 --- /dev/null +++ b/mysql-test/r/filesort_pack.result-pq @@ -0,0 +1,31 @@ +CREATE TABLE t1 ( +id int(10) unsigned NOT NULL auto_increment, +k int(10) unsigned NOT NULL default '0', +c char(120) NOT NULL default '', +pad char(60) NOT NULL default '', +PRIMARY KEY (id), +KEY k (k) +) charset latin1 engine=innodb; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +SET @@session.sort_buffer_size=32768; +FLUSH STATUS; +SHOW SESSION STATUS LIKE 'Sort%'; +Variable_name Value +Sort_merge_passes 0 +Sort_range 0 +Sort_rows 0 +Sort_scan 0 +SELECT c FROM t1 WHERE id between 2 and 1002 ORDER BY c; +SHOW SESSION STATUS LIKE 'Sort%'; +Variable_name Value +Sort_merge_passes 0 +Sort_range 0 +Sort_rows 139 +Sort_scan 3 +SET @@session.sort_buffer_size=DEFAULT; +DROP TABLE t1; diff --git a/mysql-test/r/filter_single_col_idx_small.result-pq b/mysql-test/r/filter_single_col_idx_small.result-pq new file mode 100644 index 000000000000..b4ef167bbdb1 --- /dev/null +++ b/mysql-test/r/filter_single_col_idx_small.result-pq @@ -0,0 +1,148 @@ +# +# Test that on a tiny table, the computed filtering effect is not +# less than one row for the basic condition filter constants +# +CREATE TABLE t1( +col1_pk INTEGER PRIMARY KEY, +col2 INTEGER +); +INSERT INTO t1 VALUES (0,0),(1,1),(2,2),(3,3),(4,4),(5,5),(6,6),(7,7); +# Filtered column should be 1 / (size of table) and larger than +# COND_FILTER_EQUALITY +EXPLAIN SELECT * FROM t1 WHERE col2 = 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col1_pk` AS `col1_pk`,`test`.`t1`.`col2` AS `col2` from `test`.`t1` where (`test`.`t1`.`col2` = 2) +# Filtered column should be (size of table - 1) / (size of table) +# and less than COND_FILTER_EQUALITY +EXPLAIN SELECT * FROM t1 WHERE col2 <> 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col1_pk` AS `col1_pk`,`test`.`t1`.`col2` AS `col2` from `test`.`t1` where (`test`.`t1`.`col2` <> 2) +# Filtered column should be 1 / (size of table) and larger than +# COND_FILTER_BETWEEN +EXPLAIN SELECT * FROM t1 WHERE col2 BETWEEN 2 AND 4; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col1_pk` AS `col1_pk`,`test`.`t1`.`col2` AS `col2` from `test`.`t1` where (`test`.`t1`.`col2` between 2 and 4) +# Filtered column should be (size of table - 1) / (size of table) +# and less than COND_FILTER_BETWEEN +EXPLAIN SELECT * FROM t1 WHERE col2 NOT BETWEEN 2 AND 4; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col1_pk` AS `col1_pk`,`test`.`t1`.`col2` AS `col2` from `test`.`t1` where (`test`.`t1`.`col2` not between 2 and 4) +TRUNCATE TABLE t1; +INSERT INTO t1 VALUES (0,0),(1,1); +# Filtered column should be 1 / (size of table) and larger than +# COND_FILTER_INEQUALITY +EXPLAIN SELECT * FROM t1 WHERE col2 > 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 50.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col1_pk` AS `col1_pk`,`test`.`t1`.`col2` AS `col2` from `test`.`t1` where (`test`.`t1`.`col2` > 1) +DROP TABLE t1; +# +# Bug#18438671: MAKE USE OF DATATYPE CONSTRAINTS WHEN CALCULATING +# FILTERING EFFECT +# +CREATE TABLE t1( +day_of_week enum('0','1','2','3','4','5','6'), +bit1 bit(1), +bit3 bit(3) +); +INSERT INTO t1 VALUES (1+RAND()*7, RAND()*2, RAND()*8), +(1+RAND()*7, RAND()*2, RAND()*8); +INSERT INTO t1 SELECT 1+RAND()*7, RAND()*2, RAND()*8 FROM t1; +INSERT INTO t1 SELECT 1+RAND()*7, RAND()*2, RAND()*8 FROM t1; +INSERT INTO t1 SELECT 1+RAND()*7, RAND()*2, RAND()*8 FROM t1; +INSERT INTO t1 SELECT 1+RAND()*7, RAND()*2, RAND()*8 FROM t1; +INSERT INTO t1 SELECT 1+RAND()*7, RAND()*2, RAND()*8 FROM t1; +INSERT INTO t1 SELECT 1+RAND()*7, RAND()*2, RAND()*8 FROM t1; +EXPLAIN SELECT * FROM t1 WHERE bit1 = b'1'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 128 50.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 128 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`day_of_week` AS `day_of_week`,`test`.`t1`.`bit1` AS `bit1`,`test`.`t1`.`bit3` AS `bit3` from `test`.`t1` where (`test`.`t1`.`bit1` = 0x01) +EXPLAIN SELECT * FROM t1 WHERE bit1 <=>b'1'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 128 50.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 128 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`day_of_week` AS `day_of_week`,`test`.`t1`.`bit1` AS `bit1`,`test`.`t1`.`bit3` AS `bit3` from `test`.`t1` where (`test`.`t1`.`bit1` <=> 0x01) +EXPLAIN SELECT * FROM t1 WHERE bit1 > b'0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 128 50.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 128 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`day_of_week` AS `day_of_week`,`test`.`t1`.`bit1` AS `bit1`,`test`.`t1`.`bit3` AS `bit3` from `test`.`t1` where (`test`.`t1`.`bit1` > 0x00) +EXPLAIN SELECT * FROM t1 WHERE bit1 >= b'0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 128 50.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 128 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`day_of_week` AS `day_of_week`,`test`.`t1`.`bit1` AS `bit1`,`test`.`t1`.`bit3` AS `bit3` from `test`.`t1` where (`test`.`t1`.`bit1` >= 0x00) +EXPLAIN SELECT * FROM t1 WHERE bit1 < b'0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 128 50.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 128 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`day_of_week` AS `day_of_week`,`test`.`t1`.`bit1` AS `bit1`,`test`.`t1`.`bit3` AS `bit3` from `test`.`t1` where (`test`.`t1`.`bit1` < 0x00) +EXPLAIN SELECT * FROM t1 WHERE bit1 <= b'0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 128 50.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 128 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`day_of_week` AS `day_of_week`,`test`.`t1`.`bit1` AS `bit1`,`test`.`t1`.`bit3` AS `bit3` from `test`.`t1` where (`test`.`t1`.`bit1` <= 0x00) +EXPLAIN SELECT * FROM t1 WHERE bit3 = b'1'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 128 12.50 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 128 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`day_of_week` AS `day_of_week`,`test`.`t1`.`bit1` AS `bit1`,`test`.`t1`.`bit3` AS `bit3` from `test`.`t1` where (`test`.`t1`.`bit3` = 0x01) +EXPLAIN SELECT * FROM t1 WHERE day_of_week; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 128 85.71 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 128 85.71 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`day_of_week` AS `day_of_week`,`test`.`t1`.`bit1` AS `bit1`,`test`.`t1`.`bit3` AS `bit3` from `test`.`t1` where (0 <> `test`.`t1`.`day_of_week`) +EXPLAIN SELECT * FROM t1 WHERE day_of_week = 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 128 14.29 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 128 14.29 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`day_of_week` AS `day_of_week`,`test`.`t1`.`bit1` AS `bit1`,`test`.`t1`.`bit3` AS `bit3` from `test`.`t1` where (`test`.`t1`.`day_of_week` = 1) +EXPLAIN SELECT * FROM t1 WHERE day_of_week IN (1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 128 14.29 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 128 14.29 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`day_of_week` AS `day_of_week`,`test`.`t1`.`bit1` AS `bit1`,`test`.`t1`.`bit3` AS `bit3` from `test`.`t1` where (`test`.`t1`.`day_of_week` = 1) +EXPLAIN SELECT * FROM t1 WHERE day_of_week IN (1,2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 128 28.57 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 128 28.57 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`day_of_week` AS `day_of_week`,`test`.`t1`.`bit1` AS `bit1`,`test`.`t1`.`bit3` AS `bit3` from `test`.`t1` where (`test`.`t1`.`day_of_week` in (1,2)) +EXPLAIN SELECT * FROM t1 WHERE day_of_week LIKE 'foo'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 128 14.29 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 128 14.29 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`day_of_week` AS `day_of_week`,`test`.`t1`.`bit1` AS `bit1`,`test`.`t1`.`bit3` AS `bit3` from `test`.`t1` where (`test`.`t1`.`day_of_week` like 'foo') +EXPLAIN SELECT * FROM t1 WHERE NOT day_of_week = 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 128 85.71 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 128 85.71 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`day_of_week` AS `day_of_week`,`test`.`t1`.`bit1` AS `bit1`,`test`.`t1`.`bit3` AS `bit3` from `test`.`t1` where (`test`.`t1`.`day_of_week` <> 1) +DROP TABLE t1; diff --git a/mysql-test/r/func_comparison.result-pq b/mysql-test/r/func_comparison.result-pq new file mode 100644 index 000000000000..f33295ab4e2e --- /dev/null +++ b/mysql-test/r/func_comparison.result-pq @@ -0,0 +1,18145 @@ +CREATE TABLE t1 +(pk INTEGER PRIMARY KEY, +i1 TINYINT, +u1 TINYINT UNSIGNED, +i2 SMALLINT, +u2 SMALLINT UNSIGNED, +i3 MEDIUMINT, +u3 MEDIUMINT UNSIGNED, +i4 INTEGER, +u4 INTEGER UNSIGNED, +i8 BIGINT, +u8 BIGINT UNSIGNED); +INSERT INTO t1 VALUES +(0, -128, 0, -32768, 0, -8388608, 0, -2147483648, 0, -9223372036854775808, 0), +(1, -1, 0, -1, 0, -1, 0, -1, 0, -1, 0), +(2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), +(3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1), +(4, 127, 255, 32767, 65535, 8388607, 16777215, 2147483647, 4294967295, +9223372036854775807, 18446744073709551615); +set @iv= -9223372036854775809; +set @dv= -9223372036854775809.0; +set @fv= -9223372036854775809.0e0; +set @sv= "-9223372036854775809"; +SELECT i1 = -9223372036854775809 AS a, +u1 = -9223372036854775809 AS au, +i2 = -9223372036854775809 AS b, +u2 = -9223372036854775809 AS bu, +i3 = -9223372036854775809 AS c, +u3 = -9223372036854775809 AS cu, +i4 = -9223372036854775809 AS d, +u4 = -9223372036854775809 AS du, +i8 = -9223372036854775809 AS e, +u8 = -9223372036854775809 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +execute s1 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +SELECT i1 = -9223372036854775809.0 AS a, +u1 = -9223372036854775809.0 AS au, +i2 = -9223372036854775809.0 AS b, +u2 = -9223372036854775809.0 AS bu, +i3 = -9223372036854775809.0 AS c, +u3 = -9223372036854775809.0 AS cu, +i4 = -9223372036854775809.0 AS d, +u4 = -9223372036854775809.0 AS du, +i8 = -9223372036854775809.0 AS e, +u8 = -9223372036854775809.0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +execute s1 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +SELECT i1 = -9223372036854775809.0e0 AS a, +u1 = -9223372036854775809.0e0 AS au, +i2 = -9223372036854775809.0e0 AS b, +u2 = -9223372036854775809.0e0 AS bu, +i3 = -9223372036854775809.0e0 AS c, +u3 = -9223372036854775809.0e0 AS cu, +i4 = -9223372036854775809.0e0 AS d, +u4 = -9223372036854775809.0e0 AS du, +i8 = -9223372036854775809.0e0 AS e, +u8 = -9223372036854775809.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 1 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +execute s1 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 1 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +SELECT i1 = '-9223372036854775809' AS a, +u1 = '-9223372036854775809' AS au, +i2 = '-9223372036854775809' AS b, +u2 = '-9223372036854775809' AS bu, +i3 = '-9223372036854775809' AS c, +u3 = '-9223372036854775809' AS cu, +i4 = '-9223372036854775809' AS d, +u4 = '-9223372036854775809' AS du, +i8 = '-9223372036854775809' AS e, +u8 = '-9223372036854775809' AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 1 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +execute s1 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 1 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +SELECT i1 <> -9223372036854775809 AS a, +u1 <> -9223372036854775809 AS au, +i2 <> -9223372036854775809 AS b, +u2 <> -9223372036854775809 AS bu, +i3 <> -9223372036854775809 AS c, +u3 <> -9223372036854775809 AS cu, +i4 <> -9223372036854775809 AS d, +u4 <> -9223372036854775809 AS du, +i8 <> -9223372036854775809 AS e, +u8 <> -9223372036854775809 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +execute s2 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +SELECT i1 <> -9223372036854775809.0 AS a, +u1 <> -9223372036854775809.0 AS au, +i2 <> -9223372036854775809.0 AS b, +u2 <> -9223372036854775809.0 AS bu, +i3 <> -9223372036854775809.0 AS c, +u3 <> -9223372036854775809.0 AS cu, +i4 <> -9223372036854775809.0 AS d, +u4 <> -9223372036854775809.0 AS du, +i8 <> -9223372036854775809.0 AS e, +u8 <> -9223372036854775809.0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +execute s2 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +SELECT i1 <> -9223372036854775809.0e0 AS a, +u1 <> -9223372036854775809.0e0 AS au, +i2 <> -9223372036854775809.0e0 AS b, +u2 <> -9223372036854775809.0e0 AS bu, +i3 <> -9223372036854775809.0e0 AS c, +u3 <> -9223372036854775809.0e0 AS cu, +i4 <> -9223372036854775809.0e0 AS d, +u4 <> -9223372036854775809.0e0 AS du, +i8 <> -9223372036854775809.0e0 AS e, +u8 <> -9223372036854775809.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 0 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +execute s2 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 0 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +SELECT i1 <> '-9223372036854775809' AS a, +u1 <> '-9223372036854775809' AS au, +i2 <> '-9223372036854775809' AS b, +u2 <> '-9223372036854775809' AS bu, +i3 <> '-9223372036854775809' AS c, +u3 <> '-9223372036854775809' AS cu, +i4 <> '-9223372036854775809' AS d, +u4 <> '-9223372036854775809' AS du, +i8 <> '-9223372036854775809' AS e, +u8 <> '-9223372036854775809' AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 0 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +execute s2 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 0 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +SELECT i1 < -9223372036854775809 AS a, +u1 < -9223372036854775809 AS au, +i2 < -9223372036854775809 AS b, +u2 < -9223372036854775809 AS bu, +i3 < -9223372036854775809 AS c, +u3 < -9223372036854775809 AS cu, +i4 < -9223372036854775809 AS d, +u4 < -9223372036854775809 AS du, +i8 < -9223372036854775809 AS e, +u8 < -9223372036854775809 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +execute s3 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +SELECT i1 < -9223372036854775809.0 AS a, +u1 < -9223372036854775809.0 AS au, +i2 < -9223372036854775809.0 AS b, +u2 < -9223372036854775809.0 AS bu, +i3 < -9223372036854775809.0 AS c, +u3 < -9223372036854775809.0 AS cu, +i4 < -9223372036854775809.0 AS d, +u4 < -9223372036854775809.0 AS du, +i8 < -9223372036854775809.0 AS e, +u8 < -9223372036854775809.0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +execute s3 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +SELECT i1 < -9223372036854775809.0e0 AS a, +u1 < -9223372036854775809.0e0 AS au, +i2 < -9223372036854775809.0e0 AS b, +u2 < -9223372036854775809.0e0 AS bu, +i3 < -9223372036854775809.0e0 AS c, +u3 < -9223372036854775809.0e0 AS cu, +i4 < -9223372036854775809.0e0 AS d, +u4 < -9223372036854775809.0e0 AS du, +i8 < -9223372036854775809.0e0 AS e, +u8 < -9223372036854775809.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +execute s3 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +SELECT i1 < '-9223372036854775809' AS a, +u1 < '-9223372036854775809' AS au, +i2 < '-9223372036854775809' AS b, +u2 < '-9223372036854775809' AS bu, +i3 < '-9223372036854775809' AS c, +u3 < '-9223372036854775809' AS cu, +i4 < '-9223372036854775809' AS d, +u4 < '-9223372036854775809' AS du, +i8 < '-9223372036854775809' AS e, +u8 < '-9223372036854775809' AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +execute s3 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +SELECT i1 >= -9223372036854775809 AS a, +u1 >= -9223372036854775809 AS au, +i2 >= -9223372036854775809 AS b, +u2 >= -9223372036854775809 AS bu, +i3 >= -9223372036854775809 AS c, +u3 >= -9223372036854775809 AS cu, +i4 >= -9223372036854775809 AS d, +u4 >= -9223372036854775809 AS du, +i8 >= -9223372036854775809 AS e, +u8 >= -9223372036854775809 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +execute s4 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +SELECT i1 >= -9223372036854775809.0 AS a, +u1 >= -9223372036854775809.0 AS au, +i2 >= -9223372036854775809.0 AS b, +u2 >= -9223372036854775809.0 AS bu, +i3 >= -9223372036854775809.0 AS c, +u3 >= -9223372036854775809.0 AS cu, +i4 >= -9223372036854775809.0 AS d, +u4 >= -9223372036854775809.0 AS du, +i8 >= -9223372036854775809.0 AS e, +u8 >= -9223372036854775809.0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +execute s4 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +SELECT i1 >= -9223372036854775809.0e0 AS a, +u1 >= -9223372036854775809.0e0 AS au, +i2 >= -9223372036854775809.0e0 AS b, +u2 >= -9223372036854775809.0e0 AS bu, +i3 >= -9223372036854775809.0e0 AS c, +u3 >= -9223372036854775809.0e0 AS cu, +i4 >= -9223372036854775809.0e0 AS d, +u4 >= -9223372036854775809.0e0 AS du, +i8 >= -9223372036854775809.0e0 AS e, +u8 >= -9223372036854775809.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +execute s4 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +SELECT i1 >= '-9223372036854775809' AS a, +u1 >= '-9223372036854775809' AS au, +i2 >= '-9223372036854775809' AS b, +u2 >= '-9223372036854775809' AS bu, +i3 >= '-9223372036854775809' AS c, +u3 >= '-9223372036854775809' AS cu, +i4 >= '-9223372036854775809' AS d, +u4 >= '-9223372036854775809' AS du, +i8 >= '-9223372036854775809' AS e, +u8 >= '-9223372036854775809' AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +execute s4 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +SELECT i1 <= -9223372036854775809 AS a, +u1 <= -9223372036854775809 AS au, +i2 <= -9223372036854775809 AS b, +u2 <= -9223372036854775809 AS bu, +i3 <= -9223372036854775809 AS c, +u3 <= -9223372036854775809 AS cu, +i4 <= -9223372036854775809 AS d, +u4 <= -9223372036854775809 AS du, +i8 <= -9223372036854775809 AS e, +u8 <= -9223372036854775809 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +execute s5 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +SELECT i1 <= -9223372036854775809.0 AS a, +u1 <= -9223372036854775809.0 AS au, +i2 <= -9223372036854775809.0 AS b, +u2 <= -9223372036854775809.0 AS bu, +i3 <= -9223372036854775809.0 AS c, +u3 <= -9223372036854775809.0 AS cu, +i4 <= -9223372036854775809.0 AS d, +u4 <= -9223372036854775809.0 AS du, +i8 <= -9223372036854775809.0 AS e, +u8 <= -9223372036854775809.0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +execute s5 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +SELECT i1 <= -9223372036854775809.0e0 AS a, +u1 <= -9223372036854775809.0e0 AS au, +i2 <= -9223372036854775809.0e0 AS b, +u2 <= -9223372036854775809.0e0 AS bu, +i3 <= -9223372036854775809.0e0 AS c, +u3 <= -9223372036854775809.0e0 AS cu, +i4 <= -9223372036854775809.0e0 AS d, +u4 <= -9223372036854775809.0e0 AS du, +i8 <= -9223372036854775809.0e0 AS e, +u8 <= -9223372036854775809.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 1 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +execute s5 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 1 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +SELECT i1 <= '-9223372036854775809' AS a, +u1 <= '-9223372036854775809' AS au, +i2 <= '-9223372036854775809' AS b, +u2 <= '-9223372036854775809' AS bu, +i3 <= '-9223372036854775809' AS c, +u3 <= '-9223372036854775809' AS cu, +i4 <= '-9223372036854775809' AS d, +u4 <= '-9223372036854775809' AS du, +i8 <= '-9223372036854775809' AS e, +u8 <= '-9223372036854775809' AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 1 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +execute s5 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 1 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +SELECT i1 > -9223372036854775809 AS a, +u1 > -9223372036854775809 AS au, +i2 > -9223372036854775809 AS b, +u2 > -9223372036854775809 AS bu, +i3 > -9223372036854775809 AS c, +u3 > -9223372036854775809 AS cu, +i4 > -9223372036854775809 AS d, +u4 > -9223372036854775809 AS du, +i8 > -9223372036854775809 AS e, +u8 > -9223372036854775809 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +execute s6 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +SELECT i1 > -9223372036854775809.0 AS a, +u1 > -9223372036854775809.0 AS au, +i2 > -9223372036854775809.0 AS b, +u2 > -9223372036854775809.0 AS bu, +i3 > -9223372036854775809.0 AS c, +u3 > -9223372036854775809.0 AS cu, +i4 > -9223372036854775809.0 AS d, +u4 > -9223372036854775809.0 AS du, +i8 > -9223372036854775809.0 AS e, +u8 > -9223372036854775809.0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +execute s6 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +SELECT i1 > -9223372036854775809.0e0 AS a, +u1 > -9223372036854775809.0e0 AS au, +i2 > -9223372036854775809.0e0 AS b, +u2 > -9223372036854775809.0e0 AS bu, +i3 > -9223372036854775809.0e0 AS c, +u3 > -9223372036854775809.0e0 AS cu, +i4 > -9223372036854775809.0e0 AS d, +u4 > -9223372036854775809.0e0 AS du, +i8 > -9223372036854775809.0e0 AS e, +u8 > -9223372036854775809.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 0 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +execute s6 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 0 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +SELECT i1 > '-9223372036854775809' AS a, +u1 > '-9223372036854775809' AS au, +i2 > '-9223372036854775809' AS b, +u2 > '-9223372036854775809' AS bu, +i3 > '-9223372036854775809' AS c, +u3 > '-9223372036854775809' AS cu, +i4 > '-9223372036854775809' AS d, +u4 > '-9223372036854775809' AS du, +i8 > '-9223372036854775809' AS e, +u8 > '-9223372036854775809' AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 0 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +execute s6 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 0 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +set @iv= -9223372036854775808; +set @dv= -9223372036854775808.0; +set @fv= -9223372036854775808.0e0; +set @sv= "-9223372036854775808"; +SELECT i1 = -9223372036854775808 AS a, +u1 = -9223372036854775808 AS au, +i2 = -9223372036854775808 AS b, +u2 = -9223372036854775808 AS bu, +i3 = -9223372036854775808 AS c, +u3 = -9223372036854775808 AS cu, +i4 = -9223372036854775808 AS d, +u4 = -9223372036854775808 AS du, +i8 = -9223372036854775808 AS e, +u8 = -9223372036854775808 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 1 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +execute s1 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 1 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +SELECT i1 = -9223372036854775808.0 AS a, +u1 = -9223372036854775808.0 AS au, +i2 = -9223372036854775808.0 AS b, +u2 = -9223372036854775808.0 AS bu, +i3 = -9223372036854775808.0 AS c, +u3 = -9223372036854775808.0 AS cu, +i4 = -9223372036854775808.0 AS d, +u4 = -9223372036854775808.0 AS du, +i8 = -9223372036854775808.0 AS e, +u8 = -9223372036854775808.0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 1 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +execute s1 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 1 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +SELECT i1 = -9223372036854775808.0e0 AS a, +u1 = -9223372036854775808.0e0 AS au, +i2 = -9223372036854775808.0e0 AS b, +u2 = -9223372036854775808.0e0 AS bu, +i3 = -9223372036854775808.0e0 AS c, +u3 = -9223372036854775808.0e0 AS cu, +i4 = -9223372036854775808.0e0 AS d, +u4 = -9223372036854775808.0e0 AS du, +i8 = -9223372036854775808.0e0 AS e, +u8 = -9223372036854775808.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 1 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +execute s1 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 1 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +SELECT i1 = '-9223372036854775808' AS a, +u1 = '-9223372036854775808' AS au, +i2 = '-9223372036854775808' AS b, +u2 = '-9223372036854775808' AS bu, +i3 = '-9223372036854775808' AS c, +u3 = '-9223372036854775808' AS cu, +i4 = '-9223372036854775808' AS d, +u4 = '-9223372036854775808' AS du, +i8 = '-9223372036854775808' AS e, +u8 = '-9223372036854775808' AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 1 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +execute s1 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 1 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +SELECT i1 <> -9223372036854775808 AS a, +u1 <> -9223372036854775808 AS au, +i2 <> -9223372036854775808 AS b, +u2 <> -9223372036854775808 AS bu, +i3 <> -9223372036854775808 AS c, +u3 <> -9223372036854775808 AS cu, +i4 <> -9223372036854775808 AS d, +u4 <> -9223372036854775808 AS du, +i8 <> -9223372036854775808 AS e, +u8 <> -9223372036854775808 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 0 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +execute s2 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 0 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +SELECT i1 <> -9223372036854775808.0 AS a, +u1 <> -9223372036854775808.0 AS au, +i2 <> -9223372036854775808.0 AS b, +u2 <> -9223372036854775808.0 AS bu, +i3 <> -9223372036854775808.0 AS c, +u3 <> -9223372036854775808.0 AS cu, +i4 <> -9223372036854775808.0 AS d, +u4 <> -9223372036854775808.0 AS du, +i8 <> -9223372036854775808.0 AS e, +u8 <> -9223372036854775808.0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 0 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +execute s2 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 0 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +SELECT i1 <> -9223372036854775808.0e0 AS a, +u1 <> -9223372036854775808.0e0 AS au, +i2 <> -9223372036854775808.0e0 AS b, +u2 <> -9223372036854775808.0e0 AS bu, +i3 <> -9223372036854775808.0e0 AS c, +u3 <> -9223372036854775808.0e0 AS cu, +i4 <> -9223372036854775808.0e0 AS d, +u4 <> -9223372036854775808.0e0 AS du, +i8 <> -9223372036854775808.0e0 AS e, +u8 <> -9223372036854775808.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 0 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +execute s2 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 0 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +SELECT i1 <> '-9223372036854775808' AS a, +u1 <> '-9223372036854775808' AS au, +i2 <> '-9223372036854775808' AS b, +u2 <> '-9223372036854775808' AS bu, +i3 <> '-9223372036854775808' AS c, +u3 <> '-9223372036854775808' AS cu, +i4 <> '-9223372036854775808' AS d, +u4 <> '-9223372036854775808' AS du, +i8 <> '-9223372036854775808' AS e, +u8 <> '-9223372036854775808' AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 0 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +execute s2 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 0 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +SELECT i1 < -9223372036854775808 AS a, +u1 < -9223372036854775808 AS au, +i2 < -9223372036854775808 AS b, +u2 < -9223372036854775808 AS bu, +i3 < -9223372036854775808 AS c, +u3 < -9223372036854775808 AS cu, +i4 < -9223372036854775808 AS d, +u4 < -9223372036854775808 AS du, +i8 < -9223372036854775808 AS e, +u8 < -9223372036854775808 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +execute s3 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +SELECT i1 < -9223372036854775808.0 AS a, +u1 < -9223372036854775808.0 AS au, +i2 < -9223372036854775808.0 AS b, +u2 < -9223372036854775808.0 AS bu, +i3 < -9223372036854775808.0 AS c, +u3 < -9223372036854775808.0 AS cu, +i4 < -9223372036854775808.0 AS d, +u4 < -9223372036854775808.0 AS du, +i8 < -9223372036854775808.0 AS e, +u8 < -9223372036854775808.0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +execute s3 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +SELECT i1 < -9223372036854775808.0e0 AS a, +u1 < -9223372036854775808.0e0 AS au, +i2 < -9223372036854775808.0e0 AS b, +u2 < -9223372036854775808.0e0 AS bu, +i3 < -9223372036854775808.0e0 AS c, +u3 < -9223372036854775808.0e0 AS cu, +i4 < -9223372036854775808.0e0 AS d, +u4 < -9223372036854775808.0e0 AS du, +i8 < -9223372036854775808.0e0 AS e, +u8 < -9223372036854775808.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +execute s3 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +SELECT i1 < '-9223372036854775808' AS a, +u1 < '-9223372036854775808' AS au, +i2 < '-9223372036854775808' AS b, +u2 < '-9223372036854775808' AS bu, +i3 < '-9223372036854775808' AS c, +u3 < '-9223372036854775808' AS cu, +i4 < '-9223372036854775808' AS d, +u4 < '-9223372036854775808' AS du, +i8 < '-9223372036854775808' AS e, +u8 < '-9223372036854775808' AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +execute s3 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +SELECT i1 >= -9223372036854775808 AS a, +u1 >= -9223372036854775808 AS au, +i2 >= -9223372036854775808 AS b, +u2 >= -9223372036854775808 AS bu, +i3 >= -9223372036854775808 AS c, +u3 >= -9223372036854775808 AS cu, +i4 >= -9223372036854775808 AS d, +u4 >= -9223372036854775808 AS du, +i8 >= -9223372036854775808 AS e, +u8 >= -9223372036854775808 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +execute s4 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +SELECT i1 >= -9223372036854775808.0 AS a, +u1 >= -9223372036854775808.0 AS au, +i2 >= -9223372036854775808.0 AS b, +u2 >= -9223372036854775808.0 AS bu, +i3 >= -9223372036854775808.0 AS c, +u3 >= -9223372036854775808.0 AS cu, +i4 >= -9223372036854775808.0 AS d, +u4 >= -9223372036854775808.0 AS du, +i8 >= -9223372036854775808.0 AS e, +u8 >= -9223372036854775808.0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +execute s4 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +SELECT i1 >= -9223372036854775808.0e0 AS a, +u1 >= -9223372036854775808.0e0 AS au, +i2 >= -9223372036854775808.0e0 AS b, +u2 >= -9223372036854775808.0e0 AS bu, +i3 >= -9223372036854775808.0e0 AS c, +u3 >= -9223372036854775808.0e0 AS cu, +i4 >= -9223372036854775808.0e0 AS d, +u4 >= -9223372036854775808.0e0 AS du, +i8 >= -9223372036854775808.0e0 AS e, +u8 >= -9223372036854775808.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +execute s4 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +SELECT i1 >= '-9223372036854775808' AS a, +u1 >= '-9223372036854775808' AS au, +i2 >= '-9223372036854775808' AS b, +u2 >= '-9223372036854775808' AS bu, +i3 >= '-9223372036854775808' AS c, +u3 >= '-9223372036854775808' AS cu, +i4 >= '-9223372036854775808' AS d, +u4 >= '-9223372036854775808' AS du, +i8 >= '-9223372036854775808' AS e, +u8 >= '-9223372036854775808' AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +execute s4 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +SELECT i1 <= -9223372036854775808 AS a, +u1 <= -9223372036854775808 AS au, +i2 <= -9223372036854775808 AS b, +u2 <= -9223372036854775808 AS bu, +i3 <= -9223372036854775808 AS c, +u3 <= -9223372036854775808 AS cu, +i4 <= -9223372036854775808 AS d, +u4 <= -9223372036854775808 AS du, +i8 <= -9223372036854775808 AS e, +u8 <= -9223372036854775808 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 1 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +execute s5 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 1 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +SELECT i1 <= -9223372036854775808.0 AS a, +u1 <= -9223372036854775808.0 AS au, +i2 <= -9223372036854775808.0 AS b, +u2 <= -9223372036854775808.0 AS bu, +i3 <= -9223372036854775808.0 AS c, +u3 <= -9223372036854775808.0 AS cu, +i4 <= -9223372036854775808.0 AS d, +u4 <= -9223372036854775808.0 AS du, +i8 <= -9223372036854775808.0 AS e, +u8 <= -9223372036854775808.0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 1 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +execute s5 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 1 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +SELECT i1 <= -9223372036854775808.0e0 AS a, +u1 <= -9223372036854775808.0e0 AS au, +i2 <= -9223372036854775808.0e0 AS b, +u2 <= -9223372036854775808.0e0 AS bu, +i3 <= -9223372036854775808.0e0 AS c, +u3 <= -9223372036854775808.0e0 AS cu, +i4 <= -9223372036854775808.0e0 AS d, +u4 <= -9223372036854775808.0e0 AS du, +i8 <= -9223372036854775808.0e0 AS e, +u8 <= -9223372036854775808.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 1 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +execute s5 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 1 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +SELECT i1 <= '-9223372036854775808' AS a, +u1 <= '-9223372036854775808' AS au, +i2 <= '-9223372036854775808' AS b, +u2 <= '-9223372036854775808' AS bu, +i3 <= '-9223372036854775808' AS c, +u3 <= '-9223372036854775808' AS cu, +i4 <= '-9223372036854775808' AS d, +u4 <= '-9223372036854775808' AS du, +i8 <= '-9223372036854775808' AS e, +u8 <= '-9223372036854775808' AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 1 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +execute s5 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 1 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +SELECT i1 > -9223372036854775808 AS a, +u1 > -9223372036854775808 AS au, +i2 > -9223372036854775808 AS b, +u2 > -9223372036854775808 AS bu, +i3 > -9223372036854775808 AS c, +u3 > -9223372036854775808 AS cu, +i4 > -9223372036854775808 AS d, +u4 > -9223372036854775808 AS du, +i8 > -9223372036854775808 AS e, +u8 > -9223372036854775808 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 0 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +execute s6 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 0 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +SELECT i1 > -9223372036854775808.0 AS a, +u1 > -9223372036854775808.0 AS au, +i2 > -9223372036854775808.0 AS b, +u2 > -9223372036854775808.0 AS bu, +i3 > -9223372036854775808.0 AS c, +u3 > -9223372036854775808.0 AS cu, +i4 > -9223372036854775808.0 AS d, +u4 > -9223372036854775808.0 AS du, +i8 > -9223372036854775808.0 AS e, +u8 > -9223372036854775808.0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 0 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +execute s6 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 0 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +SELECT i1 > -9223372036854775808.0e0 AS a, +u1 > -9223372036854775808.0e0 AS au, +i2 > -9223372036854775808.0e0 AS b, +u2 > -9223372036854775808.0e0 AS bu, +i3 > -9223372036854775808.0e0 AS c, +u3 > -9223372036854775808.0e0 AS cu, +i4 > -9223372036854775808.0e0 AS d, +u4 > -9223372036854775808.0e0 AS du, +i8 > -9223372036854775808.0e0 AS e, +u8 > -9223372036854775808.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 0 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +execute s6 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 0 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +SELECT i1 > '-9223372036854775808' AS a, +u1 > '-9223372036854775808' AS au, +i2 > '-9223372036854775808' AS b, +u2 > '-9223372036854775808' AS bu, +i3 > '-9223372036854775808' AS c, +u3 > '-9223372036854775808' AS cu, +i4 > '-9223372036854775808' AS d, +u4 > '-9223372036854775808' AS du, +i8 > '-9223372036854775808' AS e, +u8 > '-9223372036854775808' AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 0 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +execute s6 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 0 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +set @iv= -2147483648; +set @dv= -2147483648.0; +set @fv= -2147483648.0e0; +set @sv= "-2147483648"; +SELECT i1 = -2147483648 AS a, +u1 = -2147483648 AS au, +i2 = -2147483648 AS b, +u2 = -2147483648 AS bu, +i3 = -2147483648 AS c, +u3 = -2147483648 AS cu, +i4 = -2147483648 AS d, +u4 = -2147483648 AS du, +i8 = -2147483648 AS e, +u8 = -2147483648 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 1 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +execute s1 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +0 0 0 0 0 0 1 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +SELECT i1 = -2147483648.0 AS a, +u1 = -2147483648.0 AS au, +i2 = -2147483648.0 AS b, +u2 = -2147483648.0 AS bu, +i3 = -2147483648.0 AS c, +u3 = -2147483648.0 AS cu, +i4 = -2147483648.0 AS d, +u4 = -2147483648.0 AS du, +i8 = -2147483648.0 AS e, +u8 = -2147483648.0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 1 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +execute s1 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +0 0 0 0 0 0 1 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +SELECT i1 = -2147483648.0e0 AS a, +u1 = -2147483648.0e0 AS au, +i2 = -2147483648.0e0 AS b, +u2 = -2147483648.0e0 AS bu, +i3 = -2147483648.0e0 AS c, +u3 = -2147483648.0e0 AS cu, +i4 = -2147483648.0e0 AS d, +u4 = -2147483648.0e0 AS du, +i8 = -2147483648.0e0 AS e, +u8 = -2147483648.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 1 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +execute s1 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +0 0 0 0 0 0 1 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +SELECT i1 = '-2147483648' AS a, +u1 = '-2147483648' AS au, +i2 = '-2147483648' AS b, +u2 = '-2147483648' AS bu, +i3 = '-2147483648' AS c, +u3 = '-2147483648' AS cu, +i4 = '-2147483648' AS d, +u4 = '-2147483648' AS du, +i8 = '-2147483648' AS e, +u8 = '-2147483648' AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 1 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +execute s1 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +0 0 0 0 0 0 1 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +SELECT i1 <> -2147483648 AS a, +u1 <> -2147483648 AS au, +i2 <> -2147483648 AS b, +u2 <> -2147483648 AS bu, +i3 <> -2147483648 AS c, +u3 <> -2147483648 AS cu, +i4 <> -2147483648 AS d, +u4 <> -2147483648 AS du, +i8 <> -2147483648 AS e, +u8 <> -2147483648 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 0 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +execute s2 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +1 1 1 1 1 1 0 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +SELECT i1 <> -2147483648.0 AS a, +u1 <> -2147483648.0 AS au, +i2 <> -2147483648.0 AS b, +u2 <> -2147483648.0 AS bu, +i3 <> -2147483648.0 AS c, +u3 <> -2147483648.0 AS cu, +i4 <> -2147483648.0 AS d, +u4 <> -2147483648.0 AS du, +i8 <> -2147483648.0 AS e, +u8 <> -2147483648.0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 0 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +execute s2 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +1 1 1 1 1 1 0 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +SELECT i1 <> -2147483648.0e0 AS a, +u1 <> -2147483648.0e0 AS au, +i2 <> -2147483648.0e0 AS b, +u2 <> -2147483648.0e0 AS bu, +i3 <> -2147483648.0e0 AS c, +u3 <> -2147483648.0e0 AS cu, +i4 <> -2147483648.0e0 AS d, +u4 <> -2147483648.0e0 AS du, +i8 <> -2147483648.0e0 AS e, +u8 <> -2147483648.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 0 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +execute s2 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +1 1 1 1 1 1 0 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +SELECT i1 <> '-2147483648' AS a, +u1 <> '-2147483648' AS au, +i2 <> '-2147483648' AS b, +u2 <> '-2147483648' AS bu, +i3 <> '-2147483648' AS c, +u3 <> '-2147483648' AS cu, +i4 <> '-2147483648' AS d, +u4 <> '-2147483648' AS du, +i8 <> '-2147483648' AS e, +u8 <> '-2147483648' AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 0 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +execute s2 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +1 1 1 1 1 1 0 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +SELECT i1 < -2147483648 AS a, +u1 < -2147483648 AS au, +i2 < -2147483648 AS b, +u2 < -2147483648 AS bu, +i3 < -2147483648 AS c, +u3 < -2147483648 AS cu, +i4 < -2147483648 AS d, +u4 < -2147483648 AS du, +i8 < -2147483648 AS e, +u8 < -2147483648 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 1 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +execute s3 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 1 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +SELECT i1 < -2147483648.0 AS a, +u1 < -2147483648.0 AS au, +i2 < -2147483648.0 AS b, +u2 < -2147483648.0 AS bu, +i3 < -2147483648.0 AS c, +u3 < -2147483648.0 AS cu, +i4 < -2147483648.0 AS d, +u4 < -2147483648.0 AS du, +i8 < -2147483648.0 AS e, +u8 < -2147483648.0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 1 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +execute s3 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 1 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +SELECT i1 < -2147483648.0e0 AS a, +u1 < -2147483648.0e0 AS au, +i2 < -2147483648.0e0 AS b, +u2 < -2147483648.0e0 AS bu, +i3 < -2147483648.0e0 AS c, +u3 < -2147483648.0e0 AS cu, +i4 < -2147483648.0e0 AS d, +u4 < -2147483648.0e0 AS du, +i8 < -2147483648.0e0 AS e, +u8 < -2147483648.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 1 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +execute s3 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 1 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +SELECT i1 < '-2147483648' AS a, +u1 < '-2147483648' AS au, +i2 < '-2147483648' AS b, +u2 < '-2147483648' AS bu, +i3 < '-2147483648' AS c, +u3 < '-2147483648' AS cu, +i4 < '-2147483648' AS d, +u4 < '-2147483648' AS du, +i8 < '-2147483648' AS e, +u8 < '-2147483648' AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 1 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +execute s3 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 1 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +SELECT i1 >= -2147483648 AS a, +u1 >= -2147483648 AS au, +i2 >= -2147483648 AS b, +u2 >= -2147483648 AS bu, +i3 >= -2147483648 AS c, +u3 >= -2147483648 AS cu, +i4 >= -2147483648 AS d, +u4 >= -2147483648 AS du, +i8 >= -2147483648 AS e, +u8 >= -2147483648 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 0 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +execute s4 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 0 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +SELECT i1 >= -2147483648.0 AS a, +u1 >= -2147483648.0 AS au, +i2 >= -2147483648.0 AS b, +u2 >= -2147483648.0 AS bu, +i3 >= -2147483648.0 AS c, +u3 >= -2147483648.0 AS cu, +i4 >= -2147483648.0 AS d, +u4 >= -2147483648.0 AS du, +i8 >= -2147483648.0 AS e, +u8 >= -2147483648.0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 0 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +execute s4 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 0 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +SELECT i1 >= -2147483648.0e0 AS a, +u1 >= -2147483648.0e0 AS au, +i2 >= -2147483648.0e0 AS b, +u2 >= -2147483648.0e0 AS bu, +i3 >= -2147483648.0e0 AS c, +u3 >= -2147483648.0e0 AS cu, +i4 >= -2147483648.0e0 AS d, +u4 >= -2147483648.0e0 AS du, +i8 >= -2147483648.0e0 AS e, +u8 >= -2147483648.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 0 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +execute s4 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 0 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +SELECT i1 >= '-2147483648' AS a, +u1 >= '-2147483648' AS au, +i2 >= '-2147483648' AS b, +u2 >= '-2147483648' AS bu, +i3 >= '-2147483648' AS c, +u3 >= '-2147483648' AS cu, +i4 >= '-2147483648' AS d, +u4 >= '-2147483648' AS du, +i8 >= '-2147483648' AS e, +u8 >= '-2147483648' AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 0 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +execute s4 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 0 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +SELECT i1 <= -2147483648 AS a, +u1 <= -2147483648 AS au, +i2 <= -2147483648 AS b, +u2 <= -2147483648 AS bu, +i3 <= -2147483648 AS c, +u3 <= -2147483648 AS cu, +i4 <= -2147483648 AS d, +u4 <= -2147483648 AS du, +i8 <= -2147483648 AS e, +u8 <= -2147483648 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 1 0 1 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +execute s5 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +0 0 0 0 0 0 1 0 1 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +SELECT i1 <= -2147483648.0 AS a, +u1 <= -2147483648.0 AS au, +i2 <= -2147483648.0 AS b, +u2 <= -2147483648.0 AS bu, +i3 <= -2147483648.0 AS c, +u3 <= -2147483648.0 AS cu, +i4 <= -2147483648.0 AS d, +u4 <= -2147483648.0 AS du, +i8 <= -2147483648.0 AS e, +u8 <= -2147483648.0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 1 0 1 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +execute s5 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +0 0 0 0 0 0 1 0 1 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +SELECT i1 <= -2147483648.0e0 AS a, +u1 <= -2147483648.0e0 AS au, +i2 <= -2147483648.0e0 AS b, +u2 <= -2147483648.0e0 AS bu, +i3 <= -2147483648.0e0 AS c, +u3 <= -2147483648.0e0 AS cu, +i4 <= -2147483648.0e0 AS d, +u4 <= -2147483648.0e0 AS du, +i8 <= -2147483648.0e0 AS e, +u8 <= -2147483648.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 1 0 1 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +execute s5 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +0 0 0 0 0 0 1 0 1 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +SELECT i1 <= '-2147483648' AS a, +u1 <= '-2147483648' AS au, +i2 <= '-2147483648' AS b, +u2 <= '-2147483648' AS bu, +i3 <= '-2147483648' AS c, +u3 <= '-2147483648' AS cu, +i4 <= '-2147483648' AS d, +u4 <= '-2147483648' AS du, +i8 <= '-2147483648' AS e, +u8 <= '-2147483648' AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 1 0 1 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +execute s5 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +0 0 0 0 0 0 1 0 1 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +SELECT i1 > -2147483648 AS a, +u1 > -2147483648 AS au, +i2 > -2147483648 AS b, +u2 > -2147483648 AS bu, +i3 > -2147483648 AS c, +u3 > -2147483648 AS cu, +i4 > -2147483648 AS d, +u4 > -2147483648 AS du, +i8 > -2147483648 AS e, +u8 > -2147483648 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 0 1 0 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +execute s6 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +1 1 1 1 1 1 0 1 0 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +SELECT i1 > -2147483648.0 AS a, +u1 > -2147483648.0 AS au, +i2 > -2147483648.0 AS b, +u2 > -2147483648.0 AS bu, +i3 > -2147483648.0 AS c, +u3 > -2147483648.0 AS cu, +i4 > -2147483648.0 AS d, +u4 > -2147483648.0 AS du, +i8 > -2147483648.0 AS e, +u8 > -2147483648.0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 0 1 0 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +execute s6 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +1 1 1 1 1 1 0 1 0 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +SELECT i1 > -2147483648.0e0 AS a, +u1 > -2147483648.0e0 AS au, +i2 > -2147483648.0e0 AS b, +u2 > -2147483648.0e0 AS bu, +i3 > -2147483648.0e0 AS c, +u3 > -2147483648.0e0 AS cu, +i4 > -2147483648.0e0 AS d, +u4 > -2147483648.0e0 AS du, +i8 > -2147483648.0e0 AS e, +u8 > -2147483648.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 0 1 0 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +execute s6 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +1 1 1 1 1 1 0 1 0 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +SELECT i1 > '-2147483648' AS a, +u1 > '-2147483648' AS au, +i2 > '-2147483648' AS b, +u2 > '-2147483648' AS bu, +i3 > '-2147483648' AS c, +u3 > '-2147483648' AS cu, +i4 > '-2147483648' AS d, +u4 > '-2147483648' AS du, +i8 > '-2147483648' AS e, +u8 > '-2147483648' AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 0 1 0 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +execute s6 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +1 1 1 1 1 1 0 1 0 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +set @iv= -8388608; +set @dv= -8388608.0; +set @fv= -8388608.0e0; +set @sv= "-8388608"; +SELECT i1 = -8388608 AS a, +u1 = -8388608 AS au, +i2 = -8388608 AS b, +u2 = -8388608 AS bu, +i3 = -8388608 AS c, +u3 = -8388608 AS cu, +i4 = -8388608 AS d, +u4 = -8388608 AS du, +i8 = -8388608 AS e, +u8 = -8388608 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 1 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +execute s1 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +0 0 0 0 1 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +SELECT i1 = -8388608.0 AS a, +u1 = -8388608.0 AS au, +i2 = -8388608.0 AS b, +u2 = -8388608.0 AS bu, +i3 = -8388608.0 AS c, +u3 = -8388608.0 AS cu, +i4 = -8388608.0 AS d, +u4 = -8388608.0 AS du, +i8 = -8388608.0 AS e, +u8 = -8388608.0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 1 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +execute s1 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +0 0 0 0 1 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +SELECT i1 = -8388608.0e0 AS a, +u1 = -8388608.0e0 AS au, +i2 = -8388608.0e0 AS b, +u2 = -8388608.0e0 AS bu, +i3 = -8388608.0e0 AS c, +u3 = -8388608.0e0 AS cu, +i4 = -8388608.0e0 AS d, +u4 = -8388608.0e0 AS du, +i8 = -8388608.0e0 AS e, +u8 = -8388608.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 1 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +execute s1 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +0 0 0 0 1 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +SELECT i1 = '-8388608' AS a, +u1 = '-8388608' AS au, +i2 = '-8388608' AS b, +u2 = '-8388608' AS bu, +i3 = '-8388608' AS c, +u3 = '-8388608' AS cu, +i4 = '-8388608' AS d, +u4 = '-8388608' AS du, +i8 = '-8388608' AS e, +u8 = '-8388608' AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 1 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +execute s1 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +0 0 0 0 1 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +SELECT i1 <> -8388608 AS a, +u1 <> -8388608 AS au, +i2 <> -8388608 AS b, +u2 <> -8388608 AS bu, +i3 <> -8388608 AS c, +u3 <> -8388608 AS cu, +i4 <> -8388608 AS d, +u4 <> -8388608 AS du, +i8 <> -8388608 AS e, +u8 <> -8388608 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 0 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +execute s2 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +1 1 1 1 0 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +SELECT i1 <> -8388608.0 AS a, +u1 <> -8388608.0 AS au, +i2 <> -8388608.0 AS b, +u2 <> -8388608.0 AS bu, +i3 <> -8388608.0 AS c, +u3 <> -8388608.0 AS cu, +i4 <> -8388608.0 AS d, +u4 <> -8388608.0 AS du, +i8 <> -8388608.0 AS e, +u8 <> -8388608.0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 0 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +execute s2 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +1 1 1 1 0 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +SELECT i1 <> -8388608.0e0 AS a, +u1 <> -8388608.0e0 AS au, +i2 <> -8388608.0e0 AS b, +u2 <> -8388608.0e0 AS bu, +i3 <> -8388608.0e0 AS c, +u3 <> -8388608.0e0 AS cu, +i4 <> -8388608.0e0 AS d, +u4 <> -8388608.0e0 AS du, +i8 <> -8388608.0e0 AS e, +u8 <> -8388608.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 0 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +execute s2 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +1 1 1 1 0 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +SELECT i1 <> '-8388608' AS a, +u1 <> '-8388608' AS au, +i2 <> '-8388608' AS b, +u2 <> '-8388608' AS bu, +i3 <> '-8388608' AS c, +u3 <> '-8388608' AS cu, +i4 <> '-8388608' AS d, +u4 <> '-8388608' AS du, +i8 <> '-8388608' AS e, +u8 <> '-8388608' AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 0 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +execute s2 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +1 1 1 1 0 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +SELECT i1 < -8388608 AS a, +u1 < -8388608 AS au, +i2 < -8388608 AS b, +u2 < -8388608 AS bu, +i3 < -8388608 AS c, +u3 < -8388608 AS cu, +i4 < -8388608 AS d, +u4 < -8388608 AS du, +i8 < -8388608 AS e, +u8 < -8388608 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 1 0 1 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +execute s3 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +0 0 0 0 0 0 1 0 1 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +SELECT i1 < -8388608.0 AS a, +u1 < -8388608.0 AS au, +i2 < -8388608.0 AS b, +u2 < -8388608.0 AS bu, +i3 < -8388608.0 AS c, +u3 < -8388608.0 AS cu, +i4 < -8388608.0 AS d, +u4 < -8388608.0 AS du, +i8 < -8388608.0 AS e, +u8 < -8388608.0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 1 0 1 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +execute s3 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +0 0 0 0 0 0 1 0 1 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +SELECT i1 < -8388608.0e0 AS a, +u1 < -8388608.0e0 AS au, +i2 < -8388608.0e0 AS b, +u2 < -8388608.0e0 AS bu, +i3 < -8388608.0e0 AS c, +u3 < -8388608.0e0 AS cu, +i4 < -8388608.0e0 AS d, +u4 < -8388608.0e0 AS du, +i8 < -8388608.0e0 AS e, +u8 < -8388608.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 1 0 1 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +execute s3 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +0 0 0 0 0 0 1 0 1 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +SELECT i1 < '-8388608' AS a, +u1 < '-8388608' AS au, +i2 < '-8388608' AS b, +u2 < '-8388608' AS bu, +i3 < '-8388608' AS c, +u3 < '-8388608' AS cu, +i4 < '-8388608' AS d, +u4 < '-8388608' AS du, +i8 < '-8388608' AS e, +u8 < '-8388608' AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 1 0 1 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +execute s3 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +0 0 0 0 0 0 1 0 1 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +SELECT i1 >= -8388608 AS a, +u1 >= -8388608 AS au, +i2 >= -8388608 AS b, +u2 >= -8388608 AS bu, +i3 >= -8388608 AS c, +u3 >= -8388608 AS cu, +i4 >= -8388608 AS d, +u4 >= -8388608 AS du, +i8 >= -8388608 AS e, +u8 >= -8388608 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 0 1 0 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +execute s4 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +1 1 1 1 1 1 0 1 0 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +SELECT i1 >= -8388608.0 AS a, +u1 >= -8388608.0 AS au, +i2 >= -8388608.0 AS b, +u2 >= -8388608.0 AS bu, +i3 >= -8388608.0 AS c, +u3 >= -8388608.0 AS cu, +i4 >= -8388608.0 AS d, +u4 >= -8388608.0 AS du, +i8 >= -8388608.0 AS e, +u8 >= -8388608.0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 0 1 0 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +execute s4 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +1 1 1 1 1 1 0 1 0 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +SELECT i1 >= -8388608.0e0 AS a, +u1 >= -8388608.0e0 AS au, +i2 >= -8388608.0e0 AS b, +u2 >= -8388608.0e0 AS bu, +i3 >= -8388608.0e0 AS c, +u3 >= -8388608.0e0 AS cu, +i4 >= -8388608.0e0 AS d, +u4 >= -8388608.0e0 AS du, +i8 >= -8388608.0e0 AS e, +u8 >= -8388608.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 0 1 0 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +execute s4 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +1 1 1 1 1 1 0 1 0 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +SELECT i1 >= '-8388608' AS a, +u1 >= '-8388608' AS au, +i2 >= '-8388608' AS b, +u2 >= '-8388608' AS bu, +i3 >= '-8388608' AS c, +u3 >= '-8388608' AS cu, +i4 >= '-8388608' AS d, +u4 >= '-8388608' AS du, +i8 >= '-8388608' AS e, +u8 >= '-8388608' AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 0 1 0 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +execute s4 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +1 1 1 1 1 1 0 1 0 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +SELECT i1 <= -8388608 AS a, +u1 <= -8388608 AS au, +i2 <= -8388608 AS b, +u2 <= -8388608 AS bu, +i3 <= -8388608 AS c, +u3 <= -8388608 AS cu, +i4 <= -8388608 AS d, +u4 <= -8388608 AS du, +i8 <= -8388608 AS e, +u8 <= -8388608 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 1 0 1 0 1 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +execute s5 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +0 0 0 0 1 0 1 0 1 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +SELECT i1 <= -8388608.0 AS a, +u1 <= -8388608.0 AS au, +i2 <= -8388608.0 AS b, +u2 <= -8388608.0 AS bu, +i3 <= -8388608.0 AS c, +u3 <= -8388608.0 AS cu, +i4 <= -8388608.0 AS d, +u4 <= -8388608.0 AS du, +i8 <= -8388608.0 AS e, +u8 <= -8388608.0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 1 0 1 0 1 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +execute s5 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +0 0 0 0 1 0 1 0 1 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +SELECT i1 <= -8388608.0e0 AS a, +u1 <= -8388608.0e0 AS au, +i2 <= -8388608.0e0 AS b, +u2 <= -8388608.0e0 AS bu, +i3 <= -8388608.0e0 AS c, +u3 <= -8388608.0e0 AS cu, +i4 <= -8388608.0e0 AS d, +u4 <= -8388608.0e0 AS du, +i8 <= -8388608.0e0 AS e, +u8 <= -8388608.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 1 0 1 0 1 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +execute s5 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +0 0 0 0 1 0 1 0 1 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +SELECT i1 <= '-8388608' AS a, +u1 <= '-8388608' AS au, +i2 <= '-8388608' AS b, +u2 <= '-8388608' AS bu, +i3 <= '-8388608' AS c, +u3 <= '-8388608' AS cu, +i4 <= '-8388608' AS d, +u4 <= '-8388608' AS du, +i8 <= '-8388608' AS e, +u8 <= '-8388608' AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 1 0 1 0 1 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +execute s5 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +0 0 0 0 1 0 1 0 1 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +SELECT i1 > -8388608 AS a, +u1 > -8388608 AS au, +i2 > -8388608 AS b, +u2 > -8388608 AS bu, +i3 > -8388608 AS c, +u3 > -8388608 AS cu, +i4 > -8388608 AS d, +u4 > -8388608 AS du, +i8 > -8388608 AS e, +u8 > -8388608 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 0 1 0 1 0 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +execute s6 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +1 1 1 1 0 1 0 1 0 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +SELECT i1 > -8388608.0 AS a, +u1 > -8388608.0 AS au, +i2 > -8388608.0 AS b, +u2 > -8388608.0 AS bu, +i3 > -8388608.0 AS c, +u3 > -8388608.0 AS cu, +i4 > -8388608.0 AS d, +u4 > -8388608.0 AS du, +i8 > -8388608.0 AS e, +u8 > -8388608.0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 0 1 0 1 0 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +execute s6 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +1 1 1 1 0 1 0 1 0 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +SELECT i1 > -8388608.0e0 AS a, +u1 > -8388608.0e0 AS au, +i2 > -8388608.0e0 AS b, +u2 > -8388608.0e0 AS bu, +i3 > -8388608.0e0 AS c, +u3 > -8388608.0e0 AS cu, +i4 > -8388608.0e0 AS d, +u4 > -8388608.0e0 AS du, +i8 > -8388608.0e0 AS e, +u8 > -8388608.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 0 1 0 1 0 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +execute s6 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +1 1 1 1 0 1 0 1 0 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +SELECT i1 > '-8388608' AS a, +u1 > '-8388608' AS au, +i2 > '-8388608' AS b, +u2 > '-8388608' AS bu, +i3 > '-8388608' AS c, +u3 > '-8388608' AS cu, +i4 > '-8388608' AS d, +u4 > '-8388608' AS du, +i8 > '-8388608' AS e, +u8 > '-8388608' AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 0 1 0 1 0 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +execute s6 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +1 1 1 1 0 1 0 1 0 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +set @iv= -32768; +set @dv= -32768.0; +set @fv= -32768.0e0; +set @sv= "-32768"; +SELECT i1 = -32768 AS a, +u1 = -32768 AS au, +i2 = -32768 AS b, +u2 = -32768 AS bu, +i3 = -32768 AS c, +u3 = -32768 AS cu, +i4 = -32768 AS d, +u4 = -32768 AS du, +i8 = -32768 AS e, +u8 = -32768 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 1 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +execute s1 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +0 0 1 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +SELECT i1 = -32768.0 AS a, +u1 = -32768.0 AS au, +i2 = -32768.0 AS b, +u2 = -32768.0 AS bu, +i3 = -32768.0 AS c, +u3 = -32768.0 AS cu, +i4 = -32768.0 AS d, +u4 = -32768.0 AS du, +i8 = -32768.0 AS e, +u8 = -32768.0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 1 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +execute s1 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +0 0 1 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +SELECT i1 = -32768.0e0 AS a, +u1 = -32768.0e0 AS au, +i2 = -32768.0e0 AS b, +u2 = -32768.0e0 AS bu, +i3 = -32768.0e0 AS c, +u3 = -32768.0e0 AS cu, +i4 = -32768.0e0 AS d, +u4 = -32768.0e0 AS du, +i8 = -32768.0e0 AS e, +u8 = -32768.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 1 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +execute s1 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +0 0 1 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +SELECT i1 = '-32768' AS a, +u1 = '-32768' AS au, +i2 = '-32768' AS b, +u2 = '-32768' AS bu, +i3 = '-32768' AS c, +u3 = '-32768' AS cu, +i4 = '-32768' AS d, +u4 = '-32768' AS du, +i8 = '-32768' AS e, +u8 = '-32768' AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 1 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +execute s1 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +0 0 1 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +SELECT i1 <> -32768 AS a, +u1 <> -32768 AS au, +i2 <> -32768 AS b, +u2 <> -32768 AS bu, +i3 <> -32768 AS c, +u3 <> -32768 AS cu, +i4 <> -32768 AS d, +u4 <> -32768 AS du, +i8 <> -32768 AS e, +u8 <> -32768 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 0 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +execute s2 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +1 1 0 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +SELECT i1 <> -32768.0 AS a, +u1 <> -32768.0 AS au, +i2 <> -32768.0 AS b, +u2 <> -32768.0 AS bu, +i3 <> -32768.0 AS c, +u3 <> -32768.0 AS cu, +i4 <> -32768.0 AS d, +u4 <> -32768.0 AS du, +i8 <> -32768.0 AS e, +u8 <> -32768.0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 0 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +execute s2 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +1 1 0 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +SELECT i1 <> -32768.0e0 AS a, +u1 <> -32768.0e0 AS au, +i2 <> -32768.0e0 AS b, +u2 <> -32768.0e0 AS bu, +i3 <> -32768.0e0 AS c, +u3 <> -32768.0e0 AS cu, +i4 <> -32768.0e0 AS d, +u4 <> -32768.0e0 AS du, +i8 <> -32768.0e0 AS e, +u8 <> -32768.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 0 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +execute s2 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +1 1 0 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +SELECT i1 <> '-32768' AS a, +u1 <> '-32768' AS au, +i2 <> '-32768' AS b, +u2 <> '-32768' AS bu, +i3 <> '-32768' AS c, +u3 <> '-32768' AS cu, +i4 <> '-32768' AS d, +u4 <> '-32768' AS du, +i8 <> '-32768' AS e, +u8 <> '-32768' AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 0 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +execute s2 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +1 1 0 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +SELECT i1 < -32768 AS a, +u1 < -32768 AS au, +i2 < -32768 AS b, +u2 < -32768 AS bu, +i3 < -32768 AS c, +u3 < -32768 AS cu, +i4 < -32768 AS d, +u4 < -32768 AS du, +i8 < -32768 AS e, +u8 < -32768 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 1 0 1 0 1 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +execute s3 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +0 0 0 0 1 0 1 0 1 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +SELECT i1 < -32768.0 AS a, +u1 < -32768.0 AS au, +i2 < -32768.0 AS b, +u2 < -32768.0 AS bu, +i3 < -32768.0 AS c, +u3 < -32768.0 AS cu, +i4 < -32768.0 AS d, +u4 < -32768.0 AS du, +i8 < -32768.0 AS e, +u8 < -32768.0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 1 0 1 0 1 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +execute s3 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +0 0 0 0 1 0 1 0 1 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +SELECT i1 < -32768.0e0 AS a, +u1 < -32768.0e0 AS au, +i2 < -32768.0e0 AS b, +u2 < -32768.0e0 AS bu, +i3 < -32768.0e0 AS c, +u3 < -32768.0e0 AS cu, +i4 < -32768.0e0 AS d, +u4 < -32768.0e0 AS du, +i8 < -32768.0e0 AS e, +u8 < -32768.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 1 0 1 0 1 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +execute s3 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +0 0 0 0 1 0 1 0 1 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +SELECT i1 < '-32768' AS a, +u1 < '-32768' AS au, +i2 < '-32768' AS b, +u2 < '-32768' AS bu, +i3 < '-32768' AS c, +u3 < '-32768' AS cu, +i4 < '-32768' AS d, +u4 < '-32768' AS du, +i8 < '-32768' AS e, +u8 < '-32768' AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 1 0 1 0 1 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +execute s3 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +0 0 0 0 1 0 1 0 1 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +SELECT i1 >= -32768 AS a, +u1 >= -32768 AS au, +i2 >= -32768 AS b, +u2 >= -32768 AS bu, +i3 >= -32768 AS c, +u3 >= -32768 AS cu, +i4 >= -32768 AS d, +u4 >= -32768 AS du, +i8 >= -32768 AS e, +u8 >= -32768 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 0 1 0 1 0 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +execute s4 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +1 1 1 1 0 1 0 1 0 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +SELECT i1 >= -32768.0 AS a, +u1 >= -32768.0 AS au, +i2 >= -32768.0 AS b, +u2 >= -32768.0 AS bu, +i3 >= -32768.0 AS c, +u3 >= -32768.0 AS cu, +i4 >= -32768.0 AS d, +u4 >= -32768.0 AS du, +i8 >= -32768.0 AS e, +u8 >= -32768.0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 0 1 0 1 0 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +execute s4 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +1 1 1 1 0 1 0 1 0 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +SELECT i1 >= -32768.0e0 AS a, +u1 >= -32768.0e0 AS au, +i2 >= -32768.0e0 AS b, +u2 >= -32768.0e0 AS bu, +i3 >= -32768.0e0 AS c, +u3 >= -32768.0e0 AS cu, +i4 >= -32768.0e0 AS d, +u4 >= -32768.0e0 AS du, +i8 >= -32768.0e0 AS e, +u8 >= -32768.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 0 1 0 1 0 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +execute s4 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +1 1 1 1 0 1 0 1 0 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +SELECT i1 >= '-32768' AS a, +u1 >= '-32768' AS au, +i2 >= '-32768' AS b, +u2 >= '-32768' AS bu, +i3 >= '-32768' AS c, +u3 >= '-32768' AS cu, +i4 >= '-32768' AS d, +u4 >= '-32768' AS du, +i8 >= '-32768' AS e, +u8 >= '-32768' AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 0 1 0 1 0 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +execute s4 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +1 1 1 1 0 1 0 1 0 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +SELECT i1 <= -32768 AS a, +u1 <= -32768 AS au, +i2 <= -32768 AS b, +u2 <= -32768 AS bu, +i3 <= -32768 AS c, +u3 <= -32768 AS cu, +i4 <= -32768 AS d, +u4 <= -32768 AS du, +i8 <= -32768 AS e, +u8 <= -32768 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 1 0 1 0 1 0 1 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +execute s5 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +0 0 1 0 1 0 1 0 1 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +SELECT i1 <= -32768.0 AS a, +u1 <= -32768.0 AS au, +i2 <= -32768.0 AS b, +u2 <= -32768.0 AS bu, +i3 <= -32768.0 AS c, +u3 <= -32768.0 AS cu, +i4 <= -32768.0 AS d, +u4 <= -32768.0 AS du, +i8 <= -32768.0 AS e, +u8 <= -32768.0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 1 0 1 0 1 0 1 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +execute s5 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +0 0 1 0 1 0 1 0 1 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +SELECT i1 <= -32768.0e0 AS a, +u1 <= -32768.0e0 AS au, +i2 <= -32768.0e0 AS b, +u2 <= -32768.0e0 AS bu, +i3 <= -32768.0e0 AS c, +u3 <= -32768.0e0 AS cu, +i4 <= -32768.0e0 AS d, +u4 <= -32768.0e0 AS du, +i8 <= -32768.0e0 AS e, +u8 <= -32768.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 1 0 1 0 1 0 1 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +execute s5 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +0 0 1 0 1 0 1 0 1 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +SELECT i1 <= '-32768' AS a, +u1 <= '-32768' AS au, +i2 <= '-32768' AS b, +u2 <= '-32768' AS bu, +i3 <= '-32768' AS c, +u3 <= '-32768' AS cu, +i4 <= '-32768' AS d, +u4 <= '-32768' AS du, +i8 <= '-32768' AS e, +u8 <= '-32768' AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 1 0 1 0 1 0 1 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +execute s5 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +0 0 1 0 1 0 1 0 1 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +SELECT i1 > -32768 AS a, +u1 > -32768 AS au, +i2 > -32768 AS b, +u2 > -32768 AS bu, +i3 > -32768 AS c, +u3 > -32768 AS cu, +i4 > -32768 AS d, +u4 > -32768 AS du, +i8 > -32768 AS e, +u8 > -32768 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 0 1 0 1 0 1 0 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +execute s6 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +1 1 0 1 0 1 0 1 0 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +SELECT i1 > -32768.0 AS a, +u1 > -32768.0 AS au, +i2 > -32768.0 AS b, +u2 > -32768.0 AS bu, +i3 > -32768.0 AS c, +u3 > -32768.0 AS cu, +i4 > -32768.0 AS d, +u4 > -32768.0 AS du, +i8 > -32768.0 AS e, +u8 > -32768.0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 0 1 0 1 0 1 0 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +execute s6 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +1 1 0 1 0 1 0 1 0 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +SELECT i1 > -32768.0e0 AS a, +u1 > -32768.0e0 AS au, +i2 > -32768.0e0 AS b, +u2 > -32768.0e0 AS bu, +i3 > -32768.0e0 AS c, +u3 > -32768.0e0 AS cu, +i4 > -32768.0e0 AS d, +u4 > -32768.0e0 AS du, +i8 > -32768.0e0 AS e, +u8 > -32768.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 0 1 0 1 0 1 0 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +execute s6 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +1 1 0 1 0 1 0 1 0 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +SELECT i1 > '-32768' AS a, +u1 > '-32768' AS au, +i2 > '-32768' AS b, +u2 > '-32768' AS bu, +i3 > '-32768' AS c, +u3 > '-32768' AS cu, +i4 > '-32768' AS d, +u4 > '-32768' AS du, +i8 > '-32768' AS e, +u8 > '-32768' AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 0 1 0 1 0 1 0 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +execute s6 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +1 1 0 1 0 1 0 1 0 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +set @iv= -128; +set @dv= -128.0; +set @fv= -128.0e0; +set @sv= "-128"; +SELECT i1 = -128 AS a, +u1 = -128 AS au, +i2 = -128 AS b, +u2 = -128 AS bu, +i3 = -128 AS c, +u3 = -128 AS cu, +i4 = -128 AS d, +u4 = -128 AS du, +i8 = -128 AS e, +u8 = -128 AS eu +FROM t1; +a au b bu c cu d du e eu +1 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +execute s1 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +1 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +SELECT i1 = -128.0 AS a, +u1 = -128.0 AS au, +i2 = -128.0 AS b, +u2 = -128.0 AS bu, +i3 = -128.0 AS c, +u3 = -128.0 AS cu, +i4 = -128.0 AS d, +u4 = -128.0 AS du, +i8 = -128.0 AS e, +u8 = -128.0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +execute s1 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +1 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +SELECT i1 = -128.0e0 AS a, +u1 = -128.0e0 AS au, +i2 = -128.0e0 AS b, +u2 = -128.0e0 AS bu, +i3 = -128.0e0 AS c, +u3 = -128.0e0 AS cu, +i4 = -128.0e0 AS d, +u4 = -128.0e0 AS du, +i8 = -128.0e0 AS e, +u8 = -128.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +execute s1 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +1 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +SELECT i1 = '-128' AS a, +u1 = '-128' AS au, +i2 = '-128' AS b, +u2 = '-128' AS bu, +i3 = '-128' AS c, +u3 = '-128' AS cu, +i4 = '-128' AS d, +u4 = '-128' AS du, +i8 = '-128' AS e, +u8 = '-128' AS eu +FROM t1; +a au b bu c cu d du e eu +1 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +execute s1 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +1 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +SELECT i1 <> -128 AS a, +u1 <> -128 AS au, +i2 <> -128 AS b, +u2 <> -128 AS bu, +i3 <> -128 AS c, +u3 <> -128 AS cu, +i4 <> -128 AS d, +u4 <> -128 AS du, +i8 <> -128 AS e, +u8 <> -128 AS eu +FROM t1; +a au b bu c cu d du e eu +0 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +execute s2 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +0 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +SELECT i1 <> -128.0 AS a, +u1 <> -128.0 AS au, +i2 <> -128.0 AS b, +u2 <> -128.0 AS bu, +i3 <> -128.0 AS c, +u3 <> -128.0 AS cu, +i4 <> -128.0 AS d, +u4 <> -128.0 AS du, +i8 <> -128.0 AS e, +u8 <> -128.0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +execute s2 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +0 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +SELECT i1 <> -128.0e0 AS a, +u1 <> -128.0e0 AS au, +i2 <> -128.0e0 AS b, +u2 <> -128.0e0 AS bu, +i3 <> -128.0e0 AS c, +u3 <> -128.0e0 AS cu, +i4 <> -128.0e0 AS d, +u4 <> -128.0e0 AS du, +i8 <> -128.0e0 AS e, +u8 <> -128.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +execute s2 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +0 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +SELECT i1 <> '-128' AS a, +u1 <> '-128' AS au, +i2 <> '-128' AS b, +u2 <> '-128' AS bu, +i3 <> '-128' AS c, +u3 <> '-128' AS cu, +i4 <> '-128' AS d, +u4 <> '-128' AS du, +i8 <> '-128' AS e, +u8 <> '-128' AS eu +FROM t1; +a au b bu c cu d du e eu +0 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +execute s2 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +0 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +SELECT i1 < -128 AS a, +u1 < -128 AS au, +i2 < -128 AS b, +u2 < -128 AS bu, +i3 < -128 AS c, +u3 < -128 AS cu, +i4 < -128 AS d, +u4 < -128 AS du, +i8 < -128 AS e, +u8 < -128 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 1 0 1 0 1 0 1 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +execute s3 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +0 0 1 0 1 0 1 0 1 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +SELECT i1 < -128.0 AS a, +u1 < -128.0 AS au, +i2 < -128.0 AS b, +u2 < -128.0 AS bu, +i3 < -128.0 AS c, +u3 < -128.0 AS cu, +i4 < -128.0 AS d, +u4 < -128.0 AS du, +i8 < -128.0 AS e, +u8 < -128.0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 1 0 1 0 1 0 1 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +execute s3 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +0 0 1 0 1 0 1 0 1 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +SELECT i1 < -128.0e0 AS a, +u1 < -128.0e0 AS au, +i2 < -128.0e0 AS b, +u2 < -128.0e0 AS bu, +i3 < -128.0e0 AS c, +u3 < -128.0e0 AS cu, +i4 < -128.0e0 AS d, +u4 < -128.0e0 AS du, +i8 < -128.0e0 AS e, +u8 < -128.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 1 0 1 0 1 0 1 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +execute s3 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +0 0 1 0 1 0 1 0 1 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +SELECT i1 < '-128' AS a, +u1 < '-128' AS au, +i2 < '-128' AS b, +u2 < '-128' AS bu, +i3 < '-128' AS c, +u3 < '-128' AS cu, +i4 < '-128' AS d, +u4 < '-128' AS du, +i8 < '-128' AS e, +u8 < '-128' AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 1 0 1 0 1 0 1 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +execute s3 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +0 0 1 0 1 0 1 0 1 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +SELECT i1 >= -128 AS a, +u1 >= -128 AS au, +i2 >= -128 AS b, +u2 >= -128 AS bu, +i3 >= -128 AS c, +u3 >= -128 AS cu, +i4 >= -128 AS d, +u4 >= -128 AS du, +i8 >= -128 AS e, +u8 >= -128 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 0 1 0 1 0 1 0 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +execute s4 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +1 1 0 1 0 1 0 1 0 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +SELECT i1 >= -128.0 AS a, +u1 >= -128.0 AS au, +i2 >= -128.0 AS b, +u2 >= -128.0 AS bu, +i3 >= -128.0 AS c, +u3 >= -128.0 AS cu, +i4 >= -128.0 AS d, +u4 >= -128.0 AS du, +i8 >= -128.0 AS e, +u8 >= -128.0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 0 1 0 1 0 1 0 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +execute s4 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +1 1 0 1 0 1 0 1 0 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +SELECT i1 >= -128.0e0 AS a, +u1 >= -128.0e0 AS au, +i2 >= -128.0e0 AS b, +u2 >= -128.0e0 AS bu, +i3 >= -128.0e0 AS c, +u3 >= -128.0e0 AS cu, +i4 >= -128.0e0 AS d, +u4 >= -128.0e0 AS du, +i8 >= -128.0e0 AS e, +u8 >= -128.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 0 1 0 1 0 1 0 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +execute s4 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +1 1 0 1 0 1 0 1 0 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +SELECT i1 >= '-128' AS a, +u1 >= '-128' AS au, +i2 >= '-128' AS b, +u2 >= '-128' AS bu, +i3 >= '-128' AS c, +u3 >= '-128' AS cu, +i4 >= '-128' AS d, +u4 >= '-128' AS du, +i8 >= '-128' AS e, +u8 >= '-128' AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 0 1 0 1 0 1 0 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +execute s4 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +1 1 0 1 0 1 0 1 0 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +SELECT i1 <= -128 AS a, +u1 <= -128 AS au, +i2 <= -128 AS b, +u2 <= -128 AS bu, +i3 <= -128 AS c, +u3 <= -128 AS cu, +i4 <= -128 AS d, +u4 <= -128 AS du, +i8 <= -128 AS e, +u8 <= -128 AS eu +FROM t1; +a au b bu c cu d du e eu +1 0 1 0 1 0 1 0 1 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +execute s5 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +1 0 1 0 1 0 1 0 1 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +SELECT i1 <= -128.0 AS a, +u1 <= -128.0 AS au, +i2 <= -128.0 AS b, +u2 <= -128.0 AS bu, +i3 <= -128.0 AS c, +u3 <= -128.0 AS cu, +i4 <= -128.0 AS d, +u4 <= -128.0 AS du, +i8 <= -128.0 AS e, +u8 <= -128.0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 0 1 0 1 0 1 0 1 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +execute s5 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +1 0 1 0 1 0 1 0 1 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +SELECT i1 <= -128.0e0 AS a, +u1 <= -128.0e0 AS au, +i2 <= -128.0e0 AS b, +u2 <= -128.0e0 AS bu, +i3 <= -128.0e0 AS c, +u3 <= -128.0e0 AS cu, +i4 <= -128.0e0 AS d, +u4 <= -128.0e0 AS du, +i8 <= -128.0e0 AS e, +u8 <= -128.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 0 1 0 1 0 1 0 1 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +execute s5 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +1 0 1 0 1 0 1 0 1 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +SELECT i1 <= '-128' AS a, +u1 <= '-128' AS au, +i2 <= '-128' AS b, +u2 <= '-128' AS bu, +i3 <= '-128' AS c, +u3 <= '-128' AS cu, +i4 <= '-128' AS d, +u4 <= '-128' AS du, +i8 <= '-128' AS e, +u8 <= '-128' AS eu +FROM t1; +a au b bu c cu d du e eu +1 0 1 0 1 0 1 0 1 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +execute s5 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +1 0 1 0 1 0 1 0 1 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +SELECT i1 > -128 AS a, +u1 > -128 AS au, +i2 > -128 AS b, +u2 > -128 AS bu, +i3 > -128 AS c, +u3 > -128 AS cu, +i4 > -128 AS d, +u4 > -128 AS du, +i8 > -128 AS e, +u8 > -128 AS eu +FROM t1; +a au b bu c cu d du e eu +0 1 0 1 0 1 0 1 0 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +execute s6 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +0 1 0 1 0 1 0 1 0 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +SELECT i1 > -128.0 AS a, +u1 > -128.0 AS au, +i2 > -128.0 AS b, +u2 > -128.0 AS bu, +i3 > -128.0 AS c, +u3 > -128.0 AS cu, +i4 > -128.0 AS d, +u4 > -128.0 AS du, +i8 > -128.0 AS e, +u8 > -128.0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 1 0 1 0 1 0 1 0 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +execute s6 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +0 1 0 1 0 1 0 1 0 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +SELECT i1 > -128.0e0 AS a, +u1 > -128.0e0 AS au, +i2 > -128.0e0 AS b, +u2 > -128.0e0 AS bu, +i3 > -128.0e0 AS c, +u3 > -128.0e0 AS cu, +i4 > -128.0e0 AS d, +u4 > -128.0e0 AS du, +i8 > -128.0e0 AS e, +u8 > -128.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 1 0 1 0 1 0 1 0 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +execute s6 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +0 1 0 1 0 1 0 1 0 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +SELECT i1 > '-128' AS a, +u1 > '-128' AS au, +i2 > '-128' AS b, +u2 > '-128' AS bu, +i3 > '-128' AS c, +u3 > '-128' AS cu, +i4 > '-128' AS d, +u4 > '-128' AS du, +i8 > '-128' AS e, +u8 > '-128' AS eu +FROM t1; +a au b bu c cu d du e eu +0 1 0 1 0 1 0 1 0 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +execute s6 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +0 1 0 1 0 1 0 1 0 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +set @iv= 0; +set @dv= 0.0; +set @fv= 0.0e0; +set @sv= "0"; +SELECT i1 = 0 AS a, +u1 = 0 AS au, +i2 = 0 AS b, +u2 = 0 AS bu, +i3 = 0 AS c, +u3 = 0 AS cu, +i4 = 0 AS d, +u4 = 0 AS du, +i8 = 0 AS e, +u8 = 0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 1 0 1 0 1 0 1 0 1 +0 1 0 1 0 1 0 1 0 1 +1 1 1 1 1 1 1 1 1 1 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +execute s1 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +0 1 0 1 0 1 0 1 0 1 +0 1 0 1 0 1 0 1 0 1 +1 1 1 1 1 1 1 1 1 1 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +SELECT i1 = 0.0 AS a, +u1 = 0.0 AS au, +i2 = 0.0 AS b, +u2 = 0.0 AS bu, +i3 = 0.0 AS c, +u3 = 0.0 AS cu, +i4 = 0.0 AS d, +u4 = 0.0 AS du, +i8 = 0.0 AS e, +u8 = 0.0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 1 0 1 0 1 0 1 0 1 +0 1 0 1 0 1 0 1 0 1 +1 1 1 1 1 1 1 1 1 1 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +execute s1 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +0 1 0 1 0 1 0 1 0 1 +0 1 0 1 0 1 0 1 0 1 +1 1 1 1 1 1 1 1 1 1 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +SELECT i1 = 0.0e0 AS a, +u1 = 0.0e0 AS au, +i2 = 0.0e0 AS b, +u2 = 0.0e0 AS bu, +i3 = 0.0e0 AS c, +u3 = 0.0e0 AS cu, +i4 = 0.0e0 AS d, +u4 = 0.0e0 AS du, +i8 = 0.0e0 AS e, +u8 = 0.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 1 0 1 0 1 0 1 0 1 +0 1 0 1 0 1 0 1 0 1 +1 1 1 1 1 1 1 1 1 1 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +execute s1 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +0 1 0 1 0 1 0 1 0 1 +0 1 0 1 0 1 0 1 0 1 +1 1 1 1 1 1 1 1 1 1 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +SELECT i1 = '0' AS a, +u1 = '0' AS au, +i2 = '0' AS b, +u2 = '0' AS bu, +i3 = '0' AS c, +u3 = '0' AS cu, +i4 = '0' AS d, +u4 = '0' AS du, +i8 = '0' AS e, +u8 = '0' AS eu +FROM t1; +a au b bu c cu d du e eu +0 1 0 1 0 1 0 1 0 1 +0 1 0 1 0 1 0 1 0 1 +1 1 1 1 1 1 1 1 1 1 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +execute s1 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +0 1 0 1 0 1 0 1 0 1 +0 1 0 1 0 1 0 1 0 1 +1 1 1 1 1 1 1 1 1 1 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +SELECT i1 <> 0 AS a, +u1 <> 0 AS au, +i2 <> 0 AS b, +u2 <> 0 AS bu, +i3 <> 0 AS c, +u3 <> 0 AS cu, +i4 <> 0 AS d, +u4 <> 0 AS du, +i8 <> 0 AS e, +u8 <> 0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 0 1 0 1 0 1 0 1 0 +1 0 1 0 1 0 1 0 1 0 +0 0 0 0 0 0 0 0 0 0 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +execute s2 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +1 0 1 0 1 0 1 0 1 0 +1 0 1 0 1 0 1 0 1 0 +0 0 0 0 0 0 0 0 0 0 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +SELECT i1 <> 0.0 AS a, +u1 <> 0.0 AS au, +i2 <> 0.0 AS b, +u2 <> 0.0 AS bu, +i3 <> 0.0 AS c, +u3 <> 0.0 AS cu, +i4 <> 0.0 AS d, +u4 <> 0.0 AS du, +i8 <> 0.0 AS e, +u8 <> 0.0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 0 1 0 1 0 1 0 1 0 +1 0 1 0 1 0 1 0 1 0 +0 0 0 0 0 0 0 0 0 0 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +execute s2 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +1 0 1 0 1 0 1 0 1 0 +1 0 1 0 1 0 1 0 1 0 +0 0 0 0 0 0 0 0 0 0 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +SELECT i1 <> 0.0e0 AS a, +u1 <> 0.0e0 AS au, +i2 <> 0.0e0 AS b, +u2 <> 0.0e0 AS bu, +i3 <> 0.0e0 AS c, +u3 <> 0.0e0 AS cu, +i4 <> 0.0e0 AS d, +u4 <> 0.0e0 AS du, +i8 <> 0.0e0 AS e, +u8 <> 0.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 0 1 0 1 0 1 0 1 0 +1 0 1 0 1 0 1 0 1 0 +0 0 0 0 0 0 0 0 0 0 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +execute s2 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +1 0 1 0 1 0 1 0 1 0 +1 0 1 0 1 0 1 0 1 0 +0 0 0 0 0 0 0 0 0 0 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +SELECT i1 <> '0' AS a, +u1 <> '0' AS au, +i2 <> '0' AS b, +u2 <> '0' AS bu, +i3 <> '0' AS c, +u3 <> '0' AS cu, +i4 <> '0' AS d, +u4 <> '0' AS du, +i8 <> '0' AS e, +u8 <> '0' AS eu +FROM t1; +a au b bu c cu d du e eu +1 0 1 0 1 0 1 0 1 0 +1 0 1 0 1 0 1 0 1 0 +0 0 0 0 0 0 0 0 0 0 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +execute s2 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +1 0 1 0 1 0 1 0 1 0 +1 0 1 0 1 0 1 0 1 0 +0 0 0 0 0 0 0 0 0 0 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +SELECT i1 < 0 AS a, +u1 < 0 AS au, +i2 < 0 AS b, +u2 < 0 AS bu, +i3 < 0 AS c, +u3 < 0 AS cu, +i4 < 0 AS d, +u4 < 0 AS du, +i8 < 0 AS e, +u8 < 0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 0 1 0 1 0 1 0 1 0 +1 0 1 0 1 0 1 0 1 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +execute s3 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +1 0 1 0 1 0 1 0 1 0 +1 0 1 0 1 0 1 0 1 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +SELECT i1 < 0.0 AS a, +u1 < 0.0 AS au, +i2 < 0.0 AS b, +u2 < 0.0 AS bu, +i3 < 0.0 AS c, +u3 < 0.0 AS cu, +i4 < 0.0 AS d, +u4 < 0.0 AS du, +i8 < 0.0 AS e, +u8 < 0.0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 0 1 0 1 0 1 0 1 0 +1 0 1 0 1 0 1 0 1 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +execute s3 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +1 0 1 0 1 0 1 0 1 0 +1 0 1 0 1 0 1 0 1 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +SELECT i1 < 0.0e0 AS a, +u1 < 0.0e0 AS au, +i2 < 0.0e0 AS b, +u2 < 0.0e0 AS bu, +i3 < 0.0e0 AS c, +u3 < 0.0e0 AS cu, +i4 < 0.0e0 AS d, +u4 < 0.0e0 AS du, +i8 < 0.0e0 AS e, +u8 < 0.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 0 1 0 1 0 1 0 1 0 +1 0 1 0 1 0 1 0 1 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +execute s3 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +1 0 1 0 1 0 1 0 1 0 +1 0 1 0 1 0 1 0 1 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +SELECT i1 < '0' AS a, +u1 < '0' AS au, +i2 < '0' AS b, +u2 < '0' AS bu, +i3 < '0' AS c, +u3 < '0' AS cu, +i4 < '0' AS d, +u4 < '0' AS du, +i8 < '0' AS e, +u8 < '0' AS eu +FROM t1; +a au b bu c cu d du e eu +1 0 1 0 1 0 1 0 1 0 +1 0 1 0 1 0 1 0 1 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +execute s3 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +1 0 1 0 1 0 1 0 1 0 +1 0 1 0 1 0 1 0 1 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +SELECT i1 >= 0 AS a, +u1 >= 0 AS au, +i2 >= 0 AS b, +u2 >= 0 AS bu, +i3 >= 0 AS c, +u3 >= 0 AS cu, +i4 >= 0 AS d, +u4 >= 0 AS du, +i8 >= 0 AS e, +u8 >= 0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 1 0 1 0 1 0 1 0 1 +0 1 0 1 0 1 0 1 0 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +execute s4 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +0 1 0 1 0 1 0 1 0 1 +0 1 0 1 0 1 0 1 0 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +SELECT i1 >= 0.0 AS a, +u1 >= 0.0 AS au, +i2 >= 0.0 AS b, +u2 >= 0.0 AS bu, +i3 >= 0.0 AS c, +u3 >= 0.0 AS cu, +i4 >= 0.0 AS d, +u4 >= 0.0 AS du, +i8 >= 0.0 AS e, +u8 >= 0.0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 1 0 1 0 1 0 1 0 1 +0 1 0 1 0 1 0 1 0 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +execute s4 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +0 1 0 1 0 1 0 1 0 1 +0 1 0 1 0 1 0 1 0 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +SELECT i1 >= 0.0e0 AS a, +u1 >= 0.0e0 AS au, +i2 >= 0.0e0 AS b, +u2 >= 0.0e0 AS bu, +i3 >= 0.0e0 AS c, +u3 >= 0.0e0 AS cu, +i4 >= 0.0e0 AS d, +u4 >= 0.0e0 AS du, +i8 >= 0.0e0 AS e, +u8 >= 0.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 1 0 1 0 1 0 1 0 1 +0 1 0 1 0 1 0 1 0 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +execute s4 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +0 1 0 1 0 1 0 1 0 1 +0 1 0 1 0 1 0 1 0 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +SELECT i1 >= '0' AS a, +u1 >= '0' AS au, +i2 >= '0' AS b, +u2 >= '0' AS bu, +i3 >= '0' AS c, +u3 >= '0' AS cu, +i4 >= '0' AS d, +u4 >= '0' AS du, +i8 >= '0' AS e, +u8 >= '0' AS eu +FROM t1; +a au b bu c cu d du e eu +0 1 0 1 0 1 0 1 0 1 +0 1 0 1 0 1 0 1 0 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +execute s4 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +0 1 0 1 0 1 0 1 0 1 +0 1 0 1 0 1 0 1 0 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +SELECT i1 <= 0 AS a, +u1 <= 0 AS au, +i2 <= 0 AS b, +u2 <= 0 AS bu, +i3 <= 0 AS c, +u3 <= 0 AS cu, +i4 <= 0 AS d, +u4 <= 0 AS du, +i8 <= 0 AS e, +u8 <= 0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +execute s5 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +SELECT i1 <= 0.0 AS a, +u1 <= 0.0 AS au, +i2 <= 0.0 AS b, +u2 <= 0.0 AS bu, +i3 <= 0.0 AS c, +u3 <= 0.0 AS cu, +i4 <= 0.0 AS d, +u4 <= 0.0 AS du, +i8 <= 0.0 AS e, +u8 <= 0.0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +execute s5 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +SELECT i1 <= 0.0e0 AS a, +u1 <= 0.0e0 AS au, +i2 <= 0.0e0 AS b, +u2 <= 0.0e0 AS bu, +i3 <= 0.0e0 AS c, +u3 <= 0.0e0 AS cu, +i4 <= 0.0e0 AS d, +u4 <= 0.0e0 AS du, +i8 <= 0.0e0 AS e, +u8 <= 0.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +execute s5 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +SELECT i1 <= '0' AS a, +u1 <= '0' AS au, +i2 <= '0' AS b, +u2 <= '0' AS bu, +i3 <= '0' AS c, +u3 <= '0' AS cu, +i4 <= '0' AS d, +u4 <= '0' AS du, +i8 <= '0' AS e, +u8 <= '0' AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +execute s5 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +SELECT i1 > 0 AS a, +u1 > 0 AS au, +i2 > 0 AS b, +u2 > 0 AS bu, +i3 > 0 AS c, +u3 > 0 AS cu, +i4 > 0 AS d, +u4 > 0 AS du, +i8 > 0 AS e, +u8 > 0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +execute s6 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +SELECT i1 > 0.0 AS a, +u1 > 0.0 AS au, +i2 > 0.0 AS b, +u2 > 0.0 AS bu, +i3 > 0.0 AS c, +u3 > 0.0 AS cu, +i4 > 0.0 AS d, +u4 > 0.0 AS du, +i8 > 0.0 AS e, +u8 > 0.0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +execute s6 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +SELECT i1 > 0.0e0 AS a, +u1 > 0.0e0 AS au, +i2 > 0.0e0 AS b, +u2 > 0.0e0 AS bu, +i3 > 0.0e0 AS c, +u3 > 0.0e0 AS cu, +i4 > 0.0e0 AS d, +u4 > 0.0e0 AS du, +i8 > 0.0e0 AS e, +u8 > 0.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +execute s6 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +SELECT i1 > '0' AS a, +u1 > '0' AS au, +i2 > '0' AS b, +u2 > '0' AS bu, +i3 > '0' AS c, +u3 > '0' AS cu, +i4 > '0' AS d, +u4 > '0' AS du, +i8 > '0' AS e, +u8 > '0' AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +execute s6 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +set @iv= 127; +set @dv= 127.0; +set @fv= 127.0e0; +set @sv= "127"; +SELECT i1 = 127 AS a, +u1 = 127 AS au, +i2 = 127 AS b, +u2 = 127 AS bu, +i3 = 127 AS c, +u3 = 127 AS cu, +i4 = 127 AS d, +u4 = 127 AS du, +i8 = 127 AS e, +u8 = 127 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +1 0 0 0 0 0 0 0 0 0 +execute s1 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +1 0 0 0 0 0 0 0 0 0 +SELECT i1 = 127.0 AS a, +u1 = 127.0 AS au, +i2 = 127.0 AS b, +u2 = 127.0 AS bu, +i3 = 127.0 AS c, +u3 = 127.0 AS cu, +i4 = 127.0 AS d, +u4 = 127.0 AS du, +i8 = 127.0 AS e, +u8 = 127.0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +1 0 0 0 0 0 0 0 0 0 +execute s1 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +1 0 0 0 0 0 0 0 0 0 +SELECT i1 = 127.0e0 AS a, +u1 = 127.0e0 AS au, +i2 = 127.0e0 AS b, +u2 = 127.0e0 AS bu, +i3 = 127.0e0 AS c, +u3 = 127.0e0 AS cu, +i4 = 127.0e0 AS d, +u4 = 127.0e0 AS du, +i8 = 127.0e0 AS e, +u8 = 127.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +1 0 0 0 0 0 0 0 0 0 +execute s1 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +1 0 0 0 0 0 0 0 0 0 +SELECT i1 = '127' AS a, +u1 = '127' AS au, +i2 = '127' AS b, +u2 = '127' AS bu, +i3 = '127' AS c, +u3 = '127' AS cu, +i4 = '127' AS d, +u4 = '127' AS du, +i8 = '127' AS e, +u8 = '127' AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +1 0 0 0 0 0 0 0 0 0 +execute s1 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +1 0 0 0 0 0 0 0 0 0 +SELECT i1 <> 127 AS a, +u1 <> 127 AS au, +i2 <> 127 AS b, +u2 <> 127 AS bu, +i3 <> 127 AS c, +u3 <> 127 AS cu, +i4 <> 127 AS d, +u4 <> 127 AS du, +i8 <> 127 AS e, +u8 <> 127 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +0 1 1 1 1 1 1 1 1 1 +execute s2 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +0 1 1 1 1 1 1 1 1 1 +SELECT i1 <> 127.0 AS a, +u1 <> 127.0 AS au, +i2 <> 127.0 AS b, +u2 <> 127.0 AS bu, +i3 <> 127.0 AS c, +u3 <> 127.0 AS cu, +i4 <> 127.0 AS d, +u4 <> 127.0 AS du, +i8 <> 127.0 AS e, +u8 <> 127.0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +0 1 1 1 1 1 1 1 1 1 +execute s2 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +0 1 1 1 1 1 1 1 1 1 +SELECT i1 <> 127.0e0 AS a, +u1 <> 127.0e0 AS au, +i2 <> 127.0e0 AS b, +u2 <> 127.0e0 AS bu, +i3 <> 127.0e0 AS c, +u3 <> 127.0e0 AS cu, +i4 <> 127.0e0 AS d, +u4 <> 127.0e0 AS du, +i8 <> 127.0e0 AS e, +u8 <> 127.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +0 1 1 1 1 1 1 1 1 1 +execute s2 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +0 1 1 1 1 1 1 1 1 1 +SELECT i1 <> '127' AS a, +u1 <> '127' AS au, +i2 <> '127' AS b, +u2 <> '127' AS bu, +i3 <> '127' AS c, +u3 <> '127' AS cu, +i4 <> '127' AS d, +u4 <> '127' AS du, +i8 <> '127' AS e, +u8 <> '127' AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +0 1 1 1 1 1 1 1 1 1 +execute s2 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +0 1 1 1 1 1 1 1 1 1 +SELECT i1 < 127 AS a, +u1 < 127 AS au, +i2 < 127 AS b, +u2 < 127 AS bu, +i3 < 127 AS c, +u3 < 127 AS cu, +i4 < 127 AS d, +u4 < 127 AS du, +i8 < 127 AS e, +u8 < 127 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +0 0 0 0 0 0 0 0 0 0 +execute s3 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +0 0 0 0 0 0 0 0 0 0 +SELECT i1 < 127.0 AS a, +u1 < 127.0 AS au, +i2 < 127.0 AS b, +u2 < 127.0 AS bu, +i3 < 127.0 AS c, +u3 < 127.0 AS cu, +i4 < 127.0 AS d, +u4 < 127.0 AS du, +i8 < 127.0 AS e, +u8 < 127.0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +0 0 0 0 0 0 0 0 0 0 +execute s3 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +0 0 0 0 0 0 0 0 0 0 +SELECT i1 < 127.0e0 AS a, +u1 < 127.0e0 AS au, +i2 < 127.0e0 AS b, +u2 < 127.0e0 AS bu, +i3 < 127.0e0 AS c, +u3 < 127.0e0 AS cu, +i4 < 127.0e0 AS d, +u4 < 127.0e0 AS du, +i8 < 127.0e0 AS e, +u8 < 127.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +0 0 0 0 0 0 0 0 0 0 +execute s3 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +0 0 0 0 0 0 0 0 0 0 +SELECT i1 < '127' AS a, +u1 < '127' AS au, +i2 < '127' AS b, +u2 < '127' AS bu, +i3 < '127' AS c, +u3 < '127' AS cu, +i4 < '127' AS d, +u4 < '127' AS du, +i8 < '127' AS e, +u8 < '127' AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +0 0 0 0 0 0 0 0 0 0 +execute s3 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +0 0 0 0 0 0 0 0 0 0 +SELECT i1 >= 127 AS a, +u1 >= 127 AS au, +i2 >= 127 AS b, +u2 >= 127 AS bu, +i3 >= 127 AS c, +u3 >= 127 AS cu, +i4 >= 127 AS d, +u4 >= 127 AS du, +i8 >= 127 AS e, +u8 >= 127 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +1 1 1 1 1 1 1 1 1 1 +execute s4 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +1 1 1 1 1 1 1 1 1 1 +SELECT i1 >= 127.0 AS a, +u1 >= 127.0 AS au, +i2 >= 127.0 AS b, +u2 >= 127.0 AS bu, +i3 >= 127.0 AS c, +u3 >= 127.0 AS cu, +i4 >= 127.0 AS d, +u4 >= 127.0 AS du, +i8 >= 127.0 AS e, +u8 >= 127.0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +1 1 1 1 1 1 1 1 1 1 +execute s4 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +1 1 1 1 1 1 1 1 1 1 +SELECT i1 >= 127.0e0 AS a, +u1 >= 127.0e0 AS au, +i2 >= 127.0e0 AS b, +u2 >= 127.0e0 AS bu, +i3 >= 127.0e0 AS c, +u3 >= 127.0e0 AS cu, +i4 >= 127.0e0 AS d, +u4 >= 127.0e0 AS du, +i8 >= 127.0e0 AS e, +u8 >= 127.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +1 1 1 1 1 1 1 1 1 1 +execute s4 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +1 1 1 1 1 1 1 1 1 1 +SELECT i1 >= '127' AS a, +u1 >= '127' AS au, +i2 >= '127' AS b, +u2 >= '127' AS bu, +i3 >= '127' AS c, +u3 >= '127' AS cu, +i4 >= '127' AS d, +u4 >= '127' AS du, +i8 >= '127' AS e, +u8 >= '127' AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +1 1 1 1 1 1 1 1 1 1 +execute s4 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +1 1 1 1 1 1 1 1 1 1 +SELECT i1 <= 127 AS a, +u1 <= 127 AS au, +i2 <= 127 AS b, +u2 <= 127 AS bu, +i3 <= 127 AS c, +u3 <= 127 AS cu, +i4 <= 127 AS d, +u4 <= 127 AS du, +i8 <= 127 AS e, +u8 <= 127 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 0 0 0 0 0 0 0 0 0 +execute s5 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 0 0 0 0 0 0 0 0 0 +SELECT i1 <= 127.0 AS a, +u1 <= 127.0 AS au, +i2 <= 127.0 AS b, +u2 <= 127.0 AS bu, +i3 <= 127.0 AS c, +u3 <= 127.0 AS cu, +i4 <= 127.0 AS d, +u4 <= 127.0 AS du, +i8 <= 127.0 AS e, +u8 <= 127.0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 0 0 0 0 0 0 0 0 0 +execute s5 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 0 0 0 0 0 0 0 0 0 +SELECT i1 <= 127.0e0 AS a, +u1 <= 127.0e0 AS au, +i2 <= 127.0e0 AS b, +u2 <= 127.0e0 AS bu, +i3 <= 127.0e0 AS c, +u3 <= 127.0e0 AS cu, +i4 <= 127.0e0 AS d, +u4 <= 127.0e0 AS du, +i8 <= 127.0e0 AS e, +u8 <= 127.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 0 0 0 0 0 0 0 0 0 +execute s5 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 0 0 0 0 0 0 0 0 0 +SELECT i1 <= '127' AS a, +u1 <= '127' AS au, +i2 <= '127' AS b, +u2 <= '127' AS bu, +i3 <= '127' AS c, +u3 <= '127' AS cu, +i4 <= '127' AS d, +u4 <= '127' AS du, +i8 <= '127' AS e, +u8 <= '127' AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 0 0 0 0 0 0 0 0 0 +execute s5 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 0 0 0 0 0 0 0 0 0 +SELECT i1 > 127 AS a, +u1 > 127 AS au, +i2 > 127 AS b, +u2 > 127 AS bu, +i3 > 127 AS c, +u3 > 127 AS cu, +i4 > 127 AS d, +u4 > 127 AS du, +i8 > 127 AS e, +u8 > 127 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 1 1 1 1 1 1 1 1 1 +execute s6 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 1 1 1 1 1 1 1 1 1 +SELECT i1 > 127.0 AS a, +u1 > 127.0 AS au, +i2 > 127.0 AS b, +u2 > 127.0 AS bu, +i3 > 127.0 AS c, +u3 > 127.0 AS cu, +i4 > 127.0 AS d, +u4 > 127.0 AS du, +i8 > 127.0 AS e, +u8 > 127.0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 1 1 1 1 1 1 1 1 1 +execute s6 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 1 1 1 1 1 1 1 1 1 +SELECT i1 > 127.0e0 AS a, +u1 > 127.0e0 AS au, +i2 > 127.0e0 AS b, +u2 > 127.0e0 AS bu, +i3 > 127.0e0 AS c, +u3 > 127.0e0 AS cu, +i4 > 127.0e0 AS d, +u4 > 127.0e0 AS du, +i8 > 127.0e0 AS e, +u8 > 127.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 1 1 1 1 1 1 1 1 1 +execute s6 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 1 1 1 1 1 1 1 1 1 +SELECT i1 > '127' AS a, +u1 > '127' AS au, +i2 > '127' AS b, +u2 > '127' AS bu, +i3 > '127' AS c, +u3 > '127' AS cu, +i4 > '127' AS d, +u4 > '127' AS du, +i8 > '127' AS e, +u8 > '127' AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 1 1 1 1 1 1 1 1 1 +execute s6 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 1 1 1 1 1 1 1 1 1 +set @iv= 255; +set @dv= 255.0; +set @fv= 255.0e0; +set @sv= "255"; +SELECT i1 = 255 AS a, +u1 = 255 AS au, +i2 = 255 AS b, +u2 = 255 AS bu, +i3 = 255 AS c, +u3 = 255 AS cu, +i4 = 255 AS d, +u4 = 255 AS du, +i8 = 255 AS e, +u8 = 255 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 1 0 0 0 0 0 0 0 0 +execute s1 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 1 0 0 0 0 0 0 0 0 +SELECT i1 = 255.0 AS a, +u1 = 255.0 AS au, +i2 = 255.0 AS b, +u2 = 255.0 AS bu, +i3 = 255.0 AS c, +u3 = 255.0 AS cu, +i4 = 255.0 AS d, +u4 = 255.0 AS du, +i8 = 255.0 AS e, +u8 = 255.0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 1 0 0 0 0 0 0 0 0 +execute s1 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 1 0 0 0 0 0 0 0 0 +SELECT i1 = 255.0e0 AS a, +u1 = 255.0e0 AS au, +i2 = 255.0e0 AS b, +u2 = 255.0e0 AS bu, +i3 = 255.0e0 AS c, +u3 = 255.0e0 AS cu, +i4 = 255.0e0 AS d, +u4 = 255.0e0 AS du, +i8 = 255.0e0 AS e, +u8 = 255.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 1 0 0 0 0 0 0 0 0 +execute s1 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 1 0 0 0 0 0 0 0 0 +SELECT i1 = '255' AS a, +u1 = '255' AS au, +i2 = '255' AS b, +u2 = '255' AS bu, +i3 = '255' AS c, +u3 = '255' AS cu, +i4 = '255' AS d, +u4 = '255' AS du, +i8 = '255' AS e, +u8 = '255' AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 1 0 0 0 0 0 0 0 0 +execute s1 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 1 0 0 0 0 0 0 0 0 +SELECT i1 <> 255 AS a, +u1 <> 255 AS au, +i2 <> 255 AS b, +u2 <> 255 AS bu, +i3 <> 255 AS c, +u3 <> 255 AS cu, +i4 <> 255 AS d, +u4 <> 255 AS du, +i8 <> 255 AS e, +u8 <> 255 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 0 1 1 1 1 1 1 1 1 +execute s2 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 0 1 1 1 1 1 1 1 1 +SELECT i1 <> 255.0 AS a, +u1 <> 255.0 AS au, +i2 <> 255.0 AS b, +u2 <> 255.0 AS bu, +i3 <> 255.0 AS c, +u3 <> 255.0 AS cu, +i4 <> 255.0 AS d, +u4 <> 255.0 AS du, +i8 <> 255.0 AS e, +u8 <> 255.0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 0 1 1 1 1 1 1 1 1 +execute s2 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 0 1 1 1 1 1 1 1 1 +SELECT i1 <> 255.0e0 AS a, +u1 <> 255.0e0 AS au, +i2 <> 255.0e0 AS b, +u2 <> 255.0e0 AS bu, +i3 <> 255.0e0 AS c, +u3 <> 255.0e0 AS cu, +i4 <> 255.0e0 AS d, +u4 <> 255.0e0 AS du, +i8 <> 255.0e0 AS e, +u8 <> 255.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 0 1 1 1 1 1 1 1 1 +execute s2 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 0 1 1 1 1 1 1 1 1 +SELECT i1 <> '255' AS a, +u1 <> '255' AS au, +i2 <> '255' AS b, +u2 <> '255' AS bu, +i3 <> '255' AS c, +u3 <> '255' AS cu, +i4 <> '255' AS d, +u4 <> '255' AS du, +i8 <> '255' AS e, +u8 <> '255' AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 0 1 1 1 1 1 1 1 1 +execute s2 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 0 1 1 1 1 1 1 1 1 +SELECT i1 < 255 AS a, +u1 < 255 AS au, +i2 < 255 AS b, +u2 < 255 AS bu, +i3 < 255 AS c, +u3 < 255 AS cu, +i4 < 255 AS d, +u4 < 255 AS du, +i8 < 255 AS e, +u8 < 255 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 0 0 0 0 0 0 0 0 0 +execute s3 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 0 0 0 0 0 0 0 0 0 +SELECT i1 < 255.0 AS a, +u1 < 255.0 AS au, +i2 < 255.0 AS b, +u2 < 255.0 AS bu, +i3 < 255.0 AS c, +u3 < 255.0 AS cu, +i4 < 255.0 AS d, +u4 < 255.0 AS du, +i8 < 255.0 AS e, +u8 < 255.0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 0 0 0 0 0 0 0 0 0 +execute s3 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 0 0 0 0 0 0 0 0 0 +SELECT i1 < 255.0e0 AS a, +u1 < 255.0e0 AS au, +i2 < 255.0e0 AS b, +u2 < 255.0e0 AS bu, +i3 < 255.0e0 AS c, +u3 < 255.0e0 AS cu, +i4 < 255.0e0 AS d, +u4 < 255.0e0 AS du, +i8 < 255.0e0 AS e, +u8 < 255.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 0 0 0 0 0 0 0 0 0 +execute s3 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 0 0 0 0 0 0 0 0 0 +SELECT i1 < '255' AS a, +u1 < '255' AS au, +i2 < '255' AS b, +u2 < '255' AS bu, +i3 < '255' AS c, +u3 < '255' AS cu, +i4 < '255' AS d, +u4 < '255' AS du, +i8 < '255' AS e, +u8 < '255' AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 0 0 0 0 0 0 0 0 0 +execute s3 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 0 0 0 0 0 0 0 0 0 +SELECT i1 >= 255 AS a, +u1 >= 255 AS au, +i2 >= 255 AS b, +u2 >= 255 AS bu, +i3 >= 255 AS c, +u3 >= 255 AS cu, +i4 >= 255 AS d, +u4 >= 255 AS du, +i8 >= 255 AS e, +u8 >= 255 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 1 1 1 1 1 1 1 1 1 +execute s4 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 1 1 1 1 1 1 1 1 1 +SELECT i1 >= 255.0 AS a, +u1 >= 255.0 AS au, +i2 >= 255.0 AS b, +u2 >= 255.0 AS bu, +i3 >= 255.0 AS c, +u3 >= 255.0 AS cu, +i4 >= 255.0 AS d, +u4 >= 255.0 AS du, +i8 >= 255.0 AS e, +u8 >= 255.0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 1 1 1 1 1 1 1 1 1 +execute s4 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 1 1 1 1 1 1 1 1 1 +SELECT i1 >= 255.0e0 AS a, +u1 >= 255.0e0 AS au, +i2 >= 255.0e0 AS b, +u2 >= 255.0e0 AS bu, +i3 >= 255.0e0 AS c, +u3 >= 255.0e0 AS cu, +i4 >= 255.0e0 AS d, +u4 >= 255.0e0 AS du, +i8 >= 255.0e0 AS e, +u8 >= 255.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 1 1 1 1 1 1 1 1 1 +execute s4 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 1 1 1 1 1 1 1 1 1 +SELECT i1 >= '255' AS a, +u1 >= '255' AS au, +i2 >= '255' AS b, +u2 >= '255' AS bu, +i3 >= '255' AS c, +u3 >= '255' AS cu, +i4 >= '255' AS d, +u4 >= '255' AS du, +i8 >= '255' AS e, +u8 >= '255' AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 1 1 1 1 1 1 1 1 1 +execute s4 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 1 1 1 1 1 1 1 1 1 +SELECT i1 <= 255 AS a, +u1 <= 255 AS au, +i2 <= 255 AS b, +u2 <= 255 AS bu, +i3 <= 255 AS c, +u3 <= 255 AS cu, +i4 <= 255 AS d, +u4 <= 255 AS du, +i8 <= 255 AS e, +u8 <= 255 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 0 0 0 0 0 0 0 0 +execute s5 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 0 0 0 0 0 0 0 0 +SELECT i1 <= 255.0 AS a, +u1 <= 255.0 AS au, +i2 <= 255.0 AS b, +u2 <= 255.0 AS bu, +i3 <= 255.0 AS c, +u3 <= 255.0 AS cu, +i4 <= 255.0 AS d, +u4 <= 255.0 AS du, +i8 <= 255.0 AS e, +u8 <= 255.0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 0 0 0 0 0 0 0 0 +execute s5 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 0 0 0 0 0 0 0 0 +SELECT i1 <= 255.0e0 AS a, +u1 <= 255.0e0 AS au, +i2 <= 255.0e0 AS b, +u2 <= 255.0e0 AS bu, +i3 <= 255.0e0 AS c, +u3 <= 255.0e0 AS cu, +i4 <= 255.0e0 AS d, +u4 <= 255.0e0 AS du, +i8 <= 255.0e0 AS e, +u8 <= 255.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 0 0 0 0 0 0 0 0 +execute s5 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 0 0 0 0 0 0 0 0 +SELECT i1 <= '255' AS a, +u1 <= '255' AS au, +i2 <= '255' AS b, +u2 <= '255' AS bu, +i3 <= '255' AS c, +u3 <= '255' AS cu, +i4 <= '255' AS d, +u4 <= '255' AS du, +i8 <= '255' AS e, +u8 <= '255' AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 0 0 0 0 0 0 0 0 +execute s5 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 0 0 0 0 0 0 0 0 +SELECT i1 > 255 AS a, +u1 > 255 AS au, +i2 > 255 AS b, +u2 > 255 AS bu, +i3 > 255 AS c, +u3 > 255 AS cu, +i4 > 255 AS d, +u4 > 255 AS du, +i8 > 255 AS e, +u8 > 255 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 1 1 1 1 1 1 1 1 +execute s6 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 1 1 1 1 1 1 1 1 +SELECT i1 > 255.0 AS a, +u1 > 255.0 AS au, +i2 > 255.0 AS b, +u2 > 255.0 AS bu, +i3 > 255.0 AS c, +u3 > 255.0 AS cu, +i4 > 255.0 AS d, +u4 > 255.0 AS du, +i8 > 255.0 AS e, +u8 > 255.0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 1 1 1 1 1 1 1 1 +execute s6 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 1 1 1 1 1 1 1 1 +SELECT i1 > 255.0e0 AS a, +u1 > 255.0e0 AS au, +i2 > 255.0e0 AS b, +u2 > 255.0e0 AS bu, +i3 > 255.0e0 AS c, +u3 > 255.0e0 AS cu, +i4 > 255.0e0 AS d, +u4 > 255.0e0 AS du, +i8 > 255.0e0 AS e, +u8 > 255.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 1 1 1 1 1 1 1 1 +execute s6 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 1 1 1 1 1 1 1 1 +SELECT i1 > '255' AS a, +u1 > '255' AS au, +i2 > '255' AS b, +u2 > '255' AS bu, +i3 > '255' AS c, +u3 > '255' AS cu, +i4 > '255' AS d, +u4 > '255' AS du, +i8 > '255' AS e, +u8 > '255' AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 1 1 1 1 1 1 1 1 +execute s6 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 1 1 1 1 1 1 1 1 +set @iv= 32767; +set @dv= 32767.0; +set @fv= 32767.0e0; +set @sv= "32767"; +SELECT i1 = 32767 AS a, +u1 = 32767 AS au, +i2 = 32767 AS b, +u2 = 32767 AS bu, +i3 = 32767 AS c, +u3 = 32767 AS cu, +i4 = 32767 AS d, +u4 = 32767 AS du, +i8 = 32767 AS e, +u8 = 32767 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 1 0 0 0 0 0 0 0 +execute s1 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 1 0 0 0 0 0 0 0 +SELECT i1 = 32767.0 AS a, +u1 = 32767.0 AS au, +i2 = 32767.0 AS b, +u2 = 32767.0 AS bu, +i3 = 32767.0 AS c, +u3 = 32767.0 AS cu, +i4 = 32767.0 AS d, +u4 = 32767.0 AS du, +i8 = 32767.0 AS e, +u8 = 32767.0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 1 0 0 0 0 0 0 0 +execute s1 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 1 0 0 0 0 0 0 0 +SELECT i1 = 32767.0e0 AS a, +u1 = 32767.0e0 AS au, +i2 = 32767.0e0 AS b, +u2 = 32767.0e0 AS bu, +i3 = 32767.0e0 AS c, +u3 = 32767.0e0 AS cu, +i4 = 32767.0e0 AS d, +u4 = 32767.0e0 AS du, +i8 = 32767.0e0 AS e, +u8 = 32767.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 1 0 0 0 0 0 0 0 +execute s1 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 1 0 0 0 0 0 0 0 +SELECT i1 = '32767' AS a, +u1 = '32767' AS au, +i2 = '32767' AS b, +u2 = '32767' AS bu, +i3 = '32767' AS c, +u3 = '32767' AS cu, +i4 = '32767' AS d, +u4 = '32767' AS du, +i8 = '32767' AS e, +u8 = '32767' AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 1 0 0 0 0 0 0 0 +execute s1 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 1 0 0 0 0 0 0 0 +SELECT i1 <> 32767 AS a, +u1 <> 32767 AS au, +i2 <> 32767 AS b, +u2 <> 32767 AS bu, +i3 <> 32767 AS c, +u3 <> 32767 AS cu, +i4 <> 32767 AS d, +u4 <> 32767 AS du, +i8 <> 32767 AS e, +u8 <> 32767 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 0 1 1 1 1 1 1 1 +execute s2 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 0 1 1 1 1 1 1 1 +SELECT i1 <> 32767.0 AS a, +u1 <> 32767.0 AS au, +i2 <> 32767.0 AS b, +u2 <> 32767.0 AS bu, +i3 <> 32767.0 AS c, +u3 <> 32767.0 AS cu, +i4 <> 32767.0 AS d, +u4 <> 32767.0 AS du, +i8 <> 32767.0 AS e, +u8 <> 32767.0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 0 1 1 1 1 1 1 1 +execute s2 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 0 1 1 1 1 1 1 1 +SELECT i1 <> 32767.0e0 AS a, +u1 <> 32767.0e0 AS au, +i2 <> 32767.0e0 AS b, +u2 <> 32767.0e0 AS bu, +i3 <> 32767.0e0 AS c, +u3 <> 32767.0e0 AS cu, +i4 <> 32767.0e0 AS d, +u4 <> 32767.0e0 AS du, +i8 <> 32767.0e0 AS e, +u8 <> 32767.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 0 1 1 1 1 1 1 1 +execute s2 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 0 1 1 1 1 1 1 1 +SELECT i1 <> '32767' AS a, +u1 <> '32767' AS au, +i2 <> '32767' AS b, +u2 <> '32767' AS bu, +i3 <> '32767' AS c, +u3 <> '32767' AS cu, +i4 <> '32767' AS d, +u4 <> '32767' AS du, +i8 <> '32767' AS e, +u8 <> '32767' AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 0 1 1 1 1 1 1 1 +execute s2 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 0 1 1 1 1 1 1 1 +SELECT i1 < 32767 AS a, +u1 < 32767 AS au, +i2 < 32767 AS b, +u2 < 32767 AS bu, +i3 < 32767 AS c, +u3 < 32767 AS cu, +i4 < 32767 AS d, +u4 < 32767 AS du, +i8 < 32767 AS e, +u8 < 32767 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 0 0 0 0 0 0 0 0 +execute s3 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 0 0 0 0 0 0 0 0 +SELECT i1 < 32767.0 AS a, +u1 < 32767.0 AS au, +i2 < 32767.0 AS b, +u2 < 32767.0 AS bu, +i3 < 32767.0 AS c, +u3 < 32767.0 AS cu, +i4 < 32767.0 AS d, +u4 < 32767.0 AS du, +i8 < 32767.0 AS e, +u8 < 32767.0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 0 0 0 0 0 0 0 0 +execute s3 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 0 0 0 0 0 0 0 0 +SELECT i1 < 32767.0e0 AS a, +u1 < 32767.0e0 AS au, +i2 < 32767.0e0 AS b, +u2 < 32767.0e0 AS bu, +i3 < 32767.0e0 AS c, +u3 < 32767.0e0 AS cu, +i4 < 32767.0e0 AS d, +u4 < 32767.0e0 AS du, +i8 < 32767.0e0 AS e, +u8 < 32767.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 0 0 0 0 0 0 0 0 +execute s3 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 0 0 0 0 0 0 0 0 +SELECT i1 < '32767' AS a, +u1 < '32767' AS au, +i2 < '32767' AS b, +u2 < '32767' AS bu, +i3 < '32767' AS c, +u3 < '32767' AS cu, +i4 < '32767' AS d, +u4 < '32767' AS du, +i8 < '32767' AS e, +u8 < '32767' AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 0 0 0 0 0 0 0 0 +execute s3 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 0 0 0 0 0 0 0 0 +SELECT i1 >= 32767 AS a, +u1 >= 32767 AS au, +i2 >= 32767 AS b, +u2 >= 32767 AS bu, +i3 >= 32767 AS c, +u3 >= 32767 AS cu, +i4 >= 32767 AS d, +u4 >= 32767 AS du, +i8 >= 32767 AS e, +u8 >= 32767 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 1 1 1 1 1 1 1 1 +execute s4 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 1 1 1 1 1 1 1 1 +SELECT i1 >= 32767.0 AS a, +u1 >= 32767.0 AS au, +i2 >= 32767.0 AS b, +u2 >= 32767.0 AS bu, +i3 >= 32767.0 AS c, +u3 >= 32767.0 AS cu, +i4 >= 32767.0 AS d, +u4 >= 32767.0 AS du, +i8 >= 32767.0 AS e, +u8 >= 32767.0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 1 1 1 1 1 1 1 1 +execute s4 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 1 1 1 1 1 1 1 1 +SELECT i1 >= 32767.0e0 AS a, +u1 >= 32767.0e0 AS au, +i2 >= 32767.0e0 AS b, +u2 >= 32767.0e0 AS bu, +i3 >= 32767.0e0 AS c, +u3 >= 32767.0e0 AS cu, +i4 >= 32767.0e0 AS d, +u4 >= 32767.0e0 AS du, +i8 >= 32767.0e0 AS e, +u8 >= 32767.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 1 1 1 1 1 1 1 1 +execute s4 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 1 1 1 1 1 1 1 1 +SELECT i1 >= '32767' AS a, +u1 >= '32767' AS au, +i2 >= '32767' AS b, +u2 >= '32767' AS bu, +i3 >= '32767' AS c, +u3 >= '32767' AS cu, +i4 >= '32767' AS d, +u4 >= '32767' AS du, +i8 >= '32767' AS e, +u8 >= '32767' AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 1 1 1 1 1 1 1 1 +execute s4 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 1 1 1 1 1 1 1 1 +SELECT i1 <= 32767 AS a, +u1 <= 32767 AS au, +i2 <= 32767 AS b, +u2 <= 32767 AS bu, +i3 <= 32767 AS c, +u3 <= 32767 AS cu, +i4 <= 32767 AS d, +u4 <= 32767 AS du, +i8 <= 32767 AS e, +u8 <= 32767 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 0 0 0 0 0 0 0 +execute s5 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 0 0 0 0 0 0 0 +SELECT i1 <= 32767.0 AS a, +u1 <= 32767.0 AS au, +i2 <= 32767.0 AS b, +u2 <= 32767.0 AS bu, +i3 <= 32767.0 AS c, +u3 <= 32767.0 AS cu, +i4 <= 32767.0 AS d, +u4 <= 32767.0 AS du, +i8 <= 32767.0 AS e, +u8 <= 32767.0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 0 0 0 0 0 0 0 +execute s5 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 0 0 0 0 0 0 0 +SELECT i1 <= 32767.0e0 AS a, +u1 <= 32767.0e0 AS au, +i2 <= 32767.0e0 AS b, +u2 <= 32767.0e0 AS bu, +i3 <= 32767.0e0 AS c, +u3 <= 32767.0e0 AS cu, +i4 <= 32767.0e0 AS d, +u4 <= 32767.0e0 AS du, +i8 <= 32767.0e0 AS e, +u8 <= 32767.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 0 0 0 0 0 0 0 +execute s5 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 0 0 0 0 0 0 0 +SELECT i1 <= '32767' AS a, +u1 <= '32767' AS au, +i2 <= '32767' AS b, +u2 <= '32767' AS bu, +i3 <= '32767' AS c, +u3 <= '32767' AS cu, +i4 <= '32767' AS d, +u4 <= '32767' AS du, +i8 <= '32767' AS e, +u8 <= '32767' AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 0 0 0 0 0 0 0 +execute s5 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 0 0 0 0 0 0 0 +SELECT i1 > 32767 AS a, +u1 > 32767 AS au, +i2 > 32767 AS b, +u2 > 32767 AS bu, +i3 > 32767 AS c, +u3 > 32767 AS cu, +i4 > 32767 AS d, +u4 > 32767 AS du, +i8 > 32767 AS e, +u8 > 32767 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 1 1 1 1 1 1 1 +execute s6 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 1 1 1 1 1 1 1 +SELECT i1 > 32767.0 AS a, +u1 > 32767.0 AS au, +i2 > 32767.0 AS b, +u2 > 32767.0 AS bu, +i3 > 32767.0 AS c, +u3 > 32767.0 AS cu, +i4 > 32767.0 AS d, +u4 > 32767.0 AS du, +i8 > 32767.0 AS e, +u8 > 32767.0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 1 1 1 1 1 1 1 +execute s6 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 1 1 1 1 1 1 1 +SELECT i1 > 32767.0e0 AS a, +u1 > 32767.0e0 AS au, +i2 > 32767.0e0 AS b, +u2 > 32767.0e0 AS bu, +i3 > 32767.0e0 AS c, +u3 > 32767.0e0 AS cu, +i4 > 32767.0e0 AS d, +u4 > 32767.0e0 AS du, +i8 > 32767.0e0 AS e, +u8 > 32767.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 1 1 1 1 1 1 1 +execute s6 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 1 1 1 1 1 1 1 +SELECT i1 > '32767' AS a, +u1 > '32767' AS au, +i2 > '32767' AS b, +u2 > '32767' AS bu, +i3 > '32767' AS c, +u3 > '32767' AS cu, +i4 > '32767' AS d, +u4 > '32767' AS du, +i8 > '32767' AS e, +u8 > '32767' AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 1 1 1 1 1 1 1 +execute s6 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 1 1 1 1 1 1 1 +set @iv= 65535; +set @dv= 65535.0; +set @fv= 65535.0e0; +set @sv= "65535"; +SELECT i1 = 65535 AS a, +u1 = 65535 AS au, +i2 = 65535 AS b, +u2 = 65535 AS bu, +i3 = 65535 AS c, +u3 = 65535 AS cu, +i4 = 65535 AS d, +u4 = 65535 AS du, +i8 = 65535 AS e, +u8 = 65535 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 1 0 0 0 0 0 0 +execute s1 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 1 0 0 0 0 0 0 +SELECT i1 = 65535.0 AS a, +u1 = 65535.0 AS au, +i2 = 65535.0 AS b, +u2 = 65535.0 AS bu, +i3 = 65535.0 AS c, +u3 = 65535.0 AS cu, +i4 = 65535.0 AS d, +u4 = 65535.0 AS du, +i8 = 65535.0 AS e, +u8 = 65535.0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 1 0 0 0 0 0 0 +execute s1 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 1 0 0 0 0 0 0 +SELECT i1 = 65535.0e0 AS a, +u1 = 65535.0e0 AS au, +i2 = 65535.0e0 AS b, +u2 = 65535.0e0 AS bu, +i3 = 65535.0e0 AS c, +u3 = 65535.0e0 AS cu, +i4 = 65535.0e0 AS d, +u4 = 65535.0e0 AS du, +i8 = 65535.0e0 AS e, +u8 = 65535.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 1 0 0 0 0 0 0 +execute s1 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 1 0 0 0 0 0 0 +SELECT i1 = '65535' AS a, +u1 = '65535' AS au, +i2 = '65535' AS b, +u2 = '65535' AS bu, +i3 = '65535' AS c, +u3 = '65535' AS cu, +i4 = '65535' AS d, +u4 = '65535' AS du, +i8 = '65535' AS e, +u8 = '65535' AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 1 0 0 0 0 0 0 +execute s1 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 1 0 0 0 0 0 0 +SELECT i1 <> 65535 AS a, +u1 <> 65535 AS au, +i2 <> 65535 AS b, +u2 <> 65535 AS bu, +i3 <> 65535 AS c, +u3 <> 65535 AS cu, +i4 <> 65535 AS d, +u4 <> 65535 AS du, +i8 <> 65535 AS e, +u8 <> 65535 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 0 1 1 1 1 1 1 +execute s2 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 0 1 1 1 1 1 1 +SELECT i1 <> 65535.0 AS a, +u1 <> 65535.0 AS au, +i2 <> 65535.0 AS b, +u2 <> 65535.0 AS bu, +i3 <> 65535.0 AS c, +u3 <> 65535.0 AS cu, +i4 <> 65535.0 AS d, +u4 <> 65535.0 AS du, +i8 <> 65535.0 AS e, +u8 <> 65535.0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 0 1 1 1 1 1 1 +execute s2 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 0 1 1 1 1 1 1 +SELECT i1 <> 65535.0e0 AS a, +u1 <> 65535.0e0 AS au, +i2 <> 65535.0e0 AS b, +u2 <> 65535.0e0 AS bu, +i3 <> 65535.0e0 AS c, +u3 <> 65535.0e0 AS cu, +i4 <> 65535.0e0 AS d, +u4 <> 65535.0e0 AS du, +i8 <> 65535.0e0 AS e, +u8 <> 65535.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 0 1 1 1 1 1 1 +execute s2 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 0 1 1 1 1 1 1 +SELECT i1 <> '65535' AS a, +u1 <> '65535' AS au, +i2 <> '65535' AS b, +u2 <> '65535' AS bu, +i3 <> '65535' AS c, +u3 <> '65535' AS cu, +i4 <> '65535' AS d, +u4 <> '65535' AS du, +i8 <> '65535' AS e, +u8 <> '65535' AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 0 1 1 1 1 1 1 +execute s2 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 0 1 1 1 1 1 1 +SELECT i1 < 65535 AS a, +u1 < 65535 AS au, +i2 < 65535 AS b, +u2 < 65535 AS bu, +i3 < 65535 AS c, +u3 < 65535 AS cu, +i4 < 65535 AS d, +u4 < 65535 AS du, +i8 < 65535 AS e, +u8 < 65535 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 0 0 0 0 0 0 0 +execute s3 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 0 0 0 0 0 0 0 +SELECT i1 < 65535.0 AS a, +u1 < 65535.0 AS au, +i2 < 65535.0 AS b, +u2 < 65535.0 AS bu, +i3 < 65535.0 AS c, +u3 < 65535.0 AS cu, +i4 < 65535.0 AS d, +u4 < 65535.0 AS du, +i8 < 65535.0 AS e, +u8 < 65535.0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 0 0 0 0 0 0 0 +execute s3 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 0 0 0 0 0 0 0 +SELECT i1 < 65535.0e0 AS a, +u1 < 65535.0e0 AS au, +i2 < 65535.0e0 AS b, +u2 < 65535.0e0 AS bu, +i3 < 65535.0e0 AS c, +u3 < 65535.0e0 AS cu, +i4 < 65535.0e0 AS d, +u4 < 65535.0e0 AS du, +i8 < 65535.0e0 AS e, +u8 < 65535.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 0 0 0 0 0 0 0 +execute s3 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 0 0 0 0 0 0 0 +SELECT i1 < '65535' AS a, +u1 < '65535' AS au, +i2 < '65535' AS b, +u2 < '65535' AS bu, +i3 < '65535' AS c, +u3 < '65535' AS cu, +i4 < '65535' AS d, +u4 < '65535' AS du, +i8 < '65535' AS e, +u8 < '65535' AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 0 0 0 0 0 0 0 +execute s3 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 0 0 0 0 0 0 0 +SELECT i1 >= 65535 AS a, +u1 >= 65535 AS au, +i2 >= 65535 AS b, +u2 >= 65535 AS bu, +i3 >= 65535 AS c, +u3 >= 65535 AS cu, +i4 >= 65535 AS d, +u4 >= 65535 AS du, +i8 >= 65535 AS e, +u8 >= 65535 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 1 1 1 1 1 1 1 +execute s4 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 1 1 1 1 1 1 1 +SELECT i1 >= 65535.0 AS a, +u1 >= 65535.0 AS au, +i2 >= 65535.0 AS b, +u2 >= 65535.0 AS bu, +i3 >= 65535.0 AS c, +u3 >= 65535.0 AS cu, +i4 >= 65535.0 AS d, +u4 >= 65535.0 AS du, +i8 >= 65535.0 AS e, +u8 >= 65535.0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 1 1 1 1 1 1 1 +execute s4 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 1 1 1 1 1 1 1 +SELECT i1 >= 65535.0e0 AS a, +u1 >= 65535.0e0 AS au, +i2 >= 65535.0e0 AS b, +u2 >= 65535.0e0 AS bu, +i3 >= 65535.0e0 AS c, +u3 >= 65535.0e0 AS cu, +i4 >= 65535.0e0 AS d, +u4 >= 65535.0e0 AS du, +i8 >= 65535.0e0 AS e, +u8 >= 65535.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 1 1 1 1 1 1 1 +execute s4 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 1 1 1 1 1 1 1 +SELECT i1 >= '65535' AS a, +u1 >= '65535' AS au, +i2 >= '65535' AS b, +u2 >= '65535' AS bu, +i3 >= '65535' AS c, +u3 >= '65535' AS cu, +i4 >= '65535' AS d, +u4 >= '65535' AS du, +i8 >= '65535' AS e, +u8 >= '65535' AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 1 1 1 1 1 1 1 +execute s4 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 1 1 1 1 1 1 1 +SELECT i1 <= 65535 AS a, +u1 <= 65535 AS au, +i2 <= 65535 AS b, +u2 <= 65535 AS bu, +i3 <= 65535 AS c, +u3 <= 65535 AS cu, +i4 <= 65535 AS d, +u4 <= 65535 AS du, +i8 <= 65535 AS e, +u8 <= 65535 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 0 0 0 0 0 0 +execute s5 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 0 0 0 0 0 0 +SELECT i1 <= 65535.0 AS a, +u1 <= 65535.0 AS au, +i2 <= 65535.0 AS b, +u2 <= 65535.0 AS bu, +i3 <= 65535.0 AS c, +u3 <= 65535.0 AS cu, +i4 <= 65535.0 AS d, +u4 <= 65535.0 AS du, +i8 <= 65535.0 AS e, +u8 <= 65535.0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 0 0 0 0 0 0 +execute s5 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 0 0 0 0 0 0 +SELECT i1 <= 65535.0e0 AS a, +u1 <= 65535.0e0 AS au, +i2 <= 65535.0e0 AS b, +u2 <= 65535.0e0 AS bu, +i3 <= 65535.0e0 AS c, +u3 <= 65535.0e0 AS cu, +i4 <= 65535.0e0 AS d, +u4 <= 65535.0e0 AS du, +i8 <= 65535.0e0 AS e, +u8 <= 65535.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 0 0 0 0 0 0 +execute s5 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 0 0 0 0 0 0 +SELECT i1 <= '65535' AS a, +u1 <= '65535' AS au, +i2 <= '65535' AS b, +u2 <= '65535' AS bu, +i3 <= '65535' AS c, +u3 <= '65535' AS cu, +i4 <= '65535' AS d, +u4 <= '65535' AS du, +i8 <= '65535' AS e, +u8 <= '65535' AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 0 0 0 0 0 0 +execute s5 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 0 0 0 0 0 0 +SELECT i1 > 65535 AS a, +u1 > 65535 AS au, +i2 > 65535 AS b, +u2 > 65535 AS bu, +i3 > 65535 AS c, +u3 > 65535 AS cu, +i4 > 65535 AS d, +u4 > 65535 AS du, +i8 > 65535 AS e, +u8 > 65535 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 1 1 1 1 1 1 +execute s6 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 1 1 1 1 1 1 +SELECT i1 > 65535.0 AS a, +u1 > 65535.0 AS au, +i2 > 65535.0 AS b, +u2 > 65535.0 AS bu, +i3 > 65535.0 AS c, +u3 > 65535.0 AS cu, +i4 > 65535.0 AS d, +u4 > 65535.0 AS du, +i8 > 65535.0 AS e, +u8 > 65535.0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 1 1 1 1 1 1 +execute s6 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 1 1 1 1 1 1 +SELECT i1 > 65535.0e0 AS a, +u1 > 65535.0e0 AS au, +i2 > 65535.0e0 AS b, +u2 > 65535.0e0 AS bu, +i3 > 65535.0e0 AS c, +u3 > 65535.0e0 AS cu, +i4 > 65535.0e0 AS d, +u4 > 65535.0e0 AS du, +i8 > 65535.0e0 AS e, +u8 > 65535.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 1 1 1 1 1 1 +execute s6 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 1 1 1 1 1 1 +SELECT i1 > '65535' AS a, +u1 > '65535' AS au, +i2 > '65535' AS b, +u2 > '65535' AS bu, +i3 > '65535' AS c, +u3 > '65535' AS cu, +i4 > '65535' AS d, +u4 > '65535' AS du, +i8 > '65535' AS e, +u8 > '65535' AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 1 1 1 1 1 1 +execute s6 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 1 1 1 1 1 1 +set @iv= 8388607; +set @dv= 8388607.0; +set @fv= 8388607.0e0; +set @sv= "8388607"; +SELECT i1 = 8388607 AS a, +u1 = 8388607 AS au, +i2 = 8388607 AS b, +u2 = 8388607 AS bu, +i3 = 8388607 AS c, +u3 = 8388607 AS cu, +i4 = 8388607 AS d, +u4 = 8388607 AS du, +i8 = 8388607 AS e, +u8 = 8388607 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 1 0 0 0 0 0 +execute s1 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 1 0 0 0 0 0 +SELECT i1 = 8388607.0 AS a, +u1 = 8388607.0 AS au, +i2 = 8388607.0 AS b, +u2 = 8388607.0 AS bu, +i3 = 8388607.0 AS c, +u3 = 8388607.0 AS cu, +i4 = 8388607.0 AS d, +u4 = 8388607.0 AS du, +i8 = 8388607.0 AS e, +u8 = 8388607.0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 1 0 0 0 0 0 +execute s1 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 1 0 0 0 0 0 +SELECT i1 = 8388607.0e0 AS a, +u1 = 8388607.0e0 AS au, +i2 = 8388607.0e0 AS b, +u2 = 8388607.0e0 AS bu, +i3 = 8388607.0e0 AS c, +u3 = 8388607.0e0 AS cu, +i4 = 8388607.0e0 AS d, +u4 = 8388607.0e0 AS du, +i8 = 8388607.0e0 AS e, +u8 = 8388607.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 1 0 0 0 0 0 +execute s1 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 1 0 0 0 0 0 +SELECT i1 = '8388607' AS a, +u1 = '8388607' AS au, +i2 = '8388607' AS b, +u2 = '8388607' AS bu, +i3 = '8388607' AS c, +u3 = '8388607' AS cu, +i4 = '8388607' AS d, +u4 = '8388607' AS du, +i8 = '8388607' AS e, +u8 = '8388607' AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 1 0 0 0 0 0 +execute s1 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 1 0 0 0 0 0 +SELECT i1 <> 8388607 AS a, +u1 <> 8388607 AS au, +i2 <> 8388607 AS b, +u2 <> 8388607 AS bu, +i3 <> 8388607 AS c, +u3 <> 8388607 AS cu, +i4 <> 8388607 AS d, +u4 <> 8388607 AS du, +i8 <> 8388607 AS e, +u8 <> 8388607 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 0 1 1 1 1 1 +execute s2 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 0 1 1 1 1 1 +SELECT i1 <> 8388607.0 AS a, +u1 <> 8388607.0 AS au, +i2 <> 8388607.0 AS b, +u2 <> 8388607.0 AS bu, +i3 <> 8388607.0 AS c, +u3 <> 8388607.0 AS cu, +i4 <> 8388607.0 AS d, +u4 <> 8388607.0 AS du, +i8 <> 8388607.0 AS e, +u8 <> 8388607.0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 0 1 1 1 1 1 +execute s2 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 0 1 1 1 1 1 +SELECT i1 <> 8388607.0e0 AS a, +u1 <> 8388607.0e0 AS au, +i2 <> 8388607.0e0 AS b, +u2 <> 8388607.0e0 AS bu, +i3 <> 8388607.0e0 AS c, +u3 <> 8388607.0e0 AS cu, +i4 <> 8388607.0e0 AS d, +u4 <> 8388607.0e0 AS du, +i8 <> 8388607.0e0 AS e, +u8 <> 8388607.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 0 1 1 1 1 1 +execute s2 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 0 1 1 1 1 1 +SELECT i1 <> '8388607' AS a, +u1 <> '8388607' AS au, +i2 <> '8388607' AS b, +u2 <> '8388607' AS bu, +i3 <> '8388607' AS c, +u3 <> '8388607' AS cu, +i4 <> '8388607' AS d, +u4 <> '8388607' AS du, +i8 <> '8388607' AS e, +u8 <> '8388607' AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 0 1 1 1 1 1 +execute s2 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 0 1 1 1 1 1 +SELECT i1 < 8388607 AS a, +u1 < 8388607 AS au, +i2 < 8388607 AS b, +u2 < 8388607 AS bu, +i3 < 8388607 AS c, +u3 < 8388607 AS cu, +i4 < 8388607 AS d, +u4 < 8388607 AS du, +i8 < 8388607 AS e, +u8 < 8388607 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 0 0 0 0 0 0 +execute s3 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 0 0 0 0 0 0 +SELECT i1 < 8388607.0 AS a, +u1 < 8388607.0 AS au, +i2 < 8388607.0 AS b, +u2 < 8388607.0 AS bu, +i3 < 8388607.0 AS c, +u3 < 8388607.0 AS cu, +i4 < 8388607.0 AS d, +u4 < 8388607.0 AS du, +i8 < 8388607.0 AS e, +u8 < 8388607.0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 0 0 0 0 0 0 +execute s3 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 0 0 0 0 0 0 +SELECT i1 < 8388607.0e0 AS a, +u1 < 8388607.0e0 AS au, +i2 < 8388607.0e0 AS b, +u2 < 8388607.0e0 AS bu, +i3 < 8388607.0e0 AS c, +u3 < 8388607.0e0 AS cu, +i4 < 8388607.0e0 AS d, +u4 < 8388607.0e0 AS du, +i8 < 8388607.0e0 AS e, +u8 < 8388607.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 0 0 0 0 0 0 +execute s3 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 0 0 0 0 0 0 +SELECT i1 < '8388607' AS a, +u1 < '8388607' AS au, +i2 < '8388607' AS b, +u2 < '8388607' AS bu, +i3 < '8388607' AS c, +u3 < '8388607' AS cu, +i4 < '8388607' AS d, +u4 < '8388607' AS du, +i8 < '8388607' AS e, +u8 < '8388607' AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 0 0 0 0 0 0 +execute s3 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 0 0 0 0 0 0 +SELECT i1 >= 8388607 AS a, +u1 >= 8388607 AS au, +i2 >= 8388607 AS b, +u2 >= 8388607 AS bu, +i3 >= 8388607 AS c, +u3 >= 8388607 AS cu, +i4 >= 8388607 AS d, +u4 >= 8388607 AS du, +i8 >= 8388607 AS e, +u8 >= 8388607 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 1 1 1 1 1 1 +execute s4 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 1 1 1 1 1 1 +SELECT i1 >= 8388607.0 AS a, +u1 >= 8388607.0 AS au, +i2 >= 8388607.0 AS b, +u2 >= 8388607.0 AS bu, +i3 >= 8388607.0 AS c, +u3 >= 8388607.0 AS cu, +i4 >= 8388607.0 AS d, +u4 >= 8388607.0 AS du, +i8 >= 8388607.0 AS e, +u8 >= 8388607.0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 1 1 1 1 1 1 +execute s4 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 1 1 1 1 1 1 +SELECT i1 >= 8388607.0e0 AS a, +u1 >= 8388607.0e0 AS au, +i2 >= 8388607.0e0 AS b, +u2 >= 8388607.0e0 AS bu, +i3 >= 8388607.0e0 AS c, +u3 >= 8388607.0e0 AS cu, +i4 >= 8388607.0e0 AS d, +u4 >= 8388607.0e0 AS du, +i8 >= 8388607.0e0 AS e, +u8 >= 8388607.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 1 1 1 1 1 1 +execute s4 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 1 1 1 1 1 1 +SELECT i1 >= '8388607' AS a, +u1 >= '8388607' AS au, +i2 >= '8388607' AS b, +u2 >= '8388607' AS bu, +i3 >= '8388607' AS c, +u3 >= '8388607' AS cu, +i4 >= '8388607' AS d, +u4 >= '8388607' AS du, +i8 >= '8388607' AS e, +u8 >= '8388607' AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 1 1 1 1 1 1 +execute s4 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 1 1 1 1 1 1 +SELECT i1 <= 8388607 AS a, +u1 <= 8388607 AS au, +i2 <= 8388607 AS b, +u2 <= 8388607 AS bu, +i3 <= 8388607 AS c, +u3 <= 8388607 AS cu, +i4 <= 8388607 AS d, +u4 <= 8388607 AS du, +i8 <= 8388607 AS e, +u8 <= 8388607 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 0 0 0 0 0 +execute s5 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 0 0 0 0 0 +SELECT i1 <= 8388607.0 AS a, +u1 <= 8388607.0 AS au, +i2 <= 8388607.0 AS b, +u2 <= 8388607.0 AS bu, +i3 <= 8388607.0 AS c, +u3 <= 8388607.0 AS cu, +i4 <= 8388607.0 AS d, +u4 <= 8388607.0 AS du, +i8 <= 8388607.0 AS e, +u8 <= 8388607.0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 0 0 0 0 0 +execute s5 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 0 0 0 0 0 +SELECT i1 <= 8388607.0e0 AS a, +u1 <= 8388607.0e0 AS au, +i2 <= 8388607.0e0 AS b, +u2 <= 8388607.0e0 AS bu, +i3 <= 8388607.0e0 AS c, +u3 <= 8388607.0e0 AS cu, +i4 <= 8388607.0e0 AS d, +u4 <= 8388607.0e0 AS du, +i8 <= 8388607.0e0 AS e, +u8 <= 8388607.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 0 0 0 0 0 +execute s5 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 0 0 0 0 0 +SELECT i1 <= '8388607' AS a, +u1 <= '8388607' AS au, +i2 <= '8388607' AS b, +u2 <= '8388607' AS bu, +i3 <= '8388607' AS c, +u3 <= '8388607' AS cu, +i4 <= '8388607' AS d, +u4 <= '8388607' AS du, +i8 <= '8388607' AS e, +u8 <= '8388607' AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 0 0 0 0 0 +execute s5 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 0 0 0 0 0 +SELECT i1 > 8388607 AS a, +u1 > 8388607 AS au, +i2 > 8388607 AS b, +u2 > 8388607 AS bu, +i3 > 8388607 AS c, +u3 > 8388607 AS cu, +i4 > 8388607 AS d, +u4 > 8388607 AS du, +i8 > 8388607 AS e, +u8 > 8388607 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 1 1 1 1 1 +execute s6 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 1 1 1 1 1 +SELECT i1 > 8388607.0 AS a, +u1 > 8388607.0 AS au, +i2 > 8388607.0 AS b, +u2 > 8388607.0 AS bu, +i3 > 8388607.0 AS c, +u3 > 8388607.0 AS cu, +i4 > 8388607.0 AS d, +u4 > 8388607.0 AS du, +i8 > 8388607.0 AS e, +u8 > 8388607.0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 1 1 1 1 1 +execute s6 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 1 1 1 1 1 +SELECT i1 > 8388607.0e0 AS a, +u1 > 8388607.0e0 AS au, +i2 > 8388607.0e0 AS b, +u2 > 8388607.0e0 AS bu, +i3 > 8388607.0e0 AS c, +u3 > 8388607.0e0 AS cu, +i4 > 8388607.0e0 AS d, +u4 > 8388607.0e0 AS du, +i8 > 8388607.0e0 AS e, +u8 > 8388607.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 1 1 1 1 1 +execute s6 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 1 1 1 1 1 +SELECT i1 > '8388607' AS a, +u1 > '8388607' AS au, +i2 > '8388607' AS b, +u2 > '8388607' AS bu, +i3 > '8388607' AS c, +u3 > '8388607' AS cu, +i4 > '8388607' AS d, +u4 > '8388607' AS du, +i8 > '8388607' AS e, +u8 > '8388607' AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 1 1 1 1 1 +execute s6 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 1 1 1 1 1 +set @iv= 16777215; +set @dv= 16777215.0; +set @fv= 16777215.0e0; +set @sv= "16777215"; +SELECT i1 = 16777215 AS a, +u1 = 16777215 AS au, +i2 = 16777215 AS b, +u2 = 16777215 AS bu, +i3 = 16777215 AS c, +u3 = 16777215 AS cu, +i4 = 16777215 AS d, +u4 = 16777215 AS du, +i8 = 16777215 AS e, +u8 = 16777215 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 1 0 0 0 0 +execute s1 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 1 0 0 0 0 +SELECT i1 = 16777215.0 AS a, +u1 = 16777215.0 AS au, +i2 = 16777215.0 AS b, +u2 = 16777215.0 AS bu, +i3 = 16777215.0 AS c, +u3 = 16777215.0 AS cu, +i4 = 16777215.0 AS d, +u4 = 16777215.0 AS du, +i8 = 16777215.0 AS e, +u8 = 16777215.0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 1 0 0 0 0 +execute s1 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 1 0 0 0 0 +SELECT i1 = 16777215.0e0 AS a, +u1 = 16777215.0e0 AS au, +i2 = 16777215.0e0 AS b, +u2 = 16777215.0e0 AS bu, +i3 = 16777215.0e0 AS c, +u3 = 16777215.0e0 AS cu, +i4 = 16777215.0e0 AS d, +u4 = 16777215.0e0 AS du, +i8 = 16777215.0e0 AS e, +u8 = 16777215.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 1 0 0 0 0 +execute s1 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 1 0 0 0 0 +SELECT i1 = '16777215' AS a, +u1 = '16777215' AS au, +i2 = '16777215' AS b, +u2 = '16777215' AS bu, +i3 = '16777215' AS c, +u3 = '16777215' AS cu, +i4 = '16777215' AS d, +u4 = '16777215' AS du, +i8 = '16777215' AS e, +u8 = '16777215' AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 1 0 0 0 0 +execute s1 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 1 0 0 0 0 +SELECT i1 <> 16777215 AS a, +u1 <> 16777215 AS au, +i2 <> 16777215 AS b, +u2 <> 16777215 AS bu, +i3 <> 16777215 AS c, +u3 <> 16777215 AS cu, +i4 <> 16777215 AS d, +u4 <> 16777215 AS du, +i8 <> 16777215 AS e, +u8 <> 16777215 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 0 1 1 1 1 +execute s2 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 0 1 1 1 1 +SELECT i1 <> 16777215.0 AS a, +u1 <> 16777215.0 AS au, +i2 <> 16777215.0 AS b, +u2 <> 16777215.0 AS bu, +i3 <> 16777215.0 AS c, +u3 <> 16777215.0 AS cu, +i4 <> 16777215.0 AS d, +u4 <> 16777215.0 AS du, +i8 <> 16777215.0 AS e, +u8 <> 16777215.0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 0 1 1 1 1 +execute s2 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 0 1 1 1 1 +SELECT i1 <> 16777215.0e0 AS a, +u1 <> 16777215.0e0 AS au, +i2 <> 16777215.0e0 AS b, +u2 <> 16777215.0e0 AS bu, +i3 <> 16777215.0e0 AS c, +u3 <> 16777215.0e0 AS cu, +i4 <> 16777215.0e0 AS d, +u4 <> 16777215.0e0 AS du, +i8 <> 16777215.0e0 AS e, +u8 <> 16777215.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 0 1 1 1 1 +execute s2 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 0 1 1 1 1 +SELECT i1 <> '16777215' AS a, +u1 <> '16777215' AS au, +i2 <> '16777215' AS b, +u2 <> '16777215' AS bu, +i3 <> '16777215' AS c, +u3 <> '16777215' AS cu, +i4 <> '16777215' AS d, +u4 <> '16777215' AS du, +i8 <> '16777215' AS e, +u8 <> '16777215' AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 0 1 1 1 1 +execute s2 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 0 1 1 1 1 +SELECT i1 < 16777215 AS a, +u1 < 16777215 AS au, +i2 < 16777215 AS b, +u2 < 16777215 AS bu, +i3 < 16777215 AS c, +u3 < 16777215 AS cu, +i4 < 16777215 AS d, +u4 < 16777215 AS du, +i8 < 16777215 AS e, +u8 < 16777215 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 0 0 0 0 0 +execute s3 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 0 0 0 0 0 +SELECT i1 < 16777215.0 AS a, +u1 < 16777215.0 AS au, +i2 < 16777215.0 AS b, +u2 < 16777215.0 AS bu, +i3 < 16777215.0 AS c, +u3 < 16777215.0 AS cu, +i4 < 16777215.0 AS d, +u4 < 16777215.0 AS du, +i8 < 16777215.0 AS e, +u8 < 16777215.0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 0 0 0 0 0 +execute s3 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 0 0 0 0 0 +SELECT i1 < 16777215.0e0 AS a, +u1 < 16777215.0e0 AS au, +i2 < 16777215.0e0 AS b, +u2 < 16777215.0e0 AS bu, +i3 < 16777215.0e0 AS c, +u3 < 16777215.0e0 AS cu, +i4 < 16777215.0e0 AS d, +u4 < 16777215.0e0 AS du, +i8 < 16777215.0e0 AS e, +u8 < 16777215.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 0 0 0 0 0 +execute s3 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 0 0 0 0 0 +SELECT i1 < '16777215' AS a, +u1 < '16777215' AS au, +i2 < '16777215' AS b, +u2 < '16777215' AS bu, +i3 < '16777215' AS c, +u3 < '16777215' AS cu, +i4 < '16777215' AS d, +u4 < '16777215' AS du, +i8 < '16777215' AS e, +u8 < '16777215' AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 0 0 0 0 0 +execute s3 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 0 0 0 0 0 +SELECT i1 >= 16777215 AS a, +u1 >= 16777215 AS au, +i2 >= 16777215 AS b, +u2 >= 16777215 AS bu, +i3 >= 16777215 AS c, +u3 >= 16777215 AS cu, +i4 >= 16777215 AS d, +u4 >= 16777215 AS du, +i8 >= 16777215 AS e, +u8 >= 16777215 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 1 1 1 1 1 +execute s4 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 1 1 1 1 1 +SELECT i1 >= 16777215.0 AS a, +u1 >= 16777215.0 AS au, +i2 >= 16777215.0 AS b, +u2 >= 16777215.0 AS bu, +i3 >= 16777215.0 AS c, +u3 >= 16777215.0 AS cu, +i4 >= 16777215.0 AS d, +u4 >= 16777215.0 AS du, +i8 >= 16777215.0 AS e, +u8 >= 16777215.0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 1 1 1 1 1 +execute s4 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 1 1 1 1 1 +SELECT i1 >= 16777215.0e0 AS a, +u1 >= 16777215.0e0 AS au, +i2 >= 16777215.0e0 AS b, +u2 >= 16777215.0e0 AS bu, +i3 >= 16777215.0e0 AS c, +u3 >= 16777215.0e0 AS cu, +i4 >= 16777215.0e0 AS d, +u4 >= 16777215.0e0 AS du, +i8 >= 16777215.0e0 AS e, +u8 >= 16777215.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 1 1 1 1 1 +execute s4 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 1 1 1 1 1 +SELECT i1 >= '16777215' AS a, +u1 >= '16777215' AS au, +i2 >= '16777215' AS b, +u2 >= '16777215' AS bu, +i3 >= '16777215' AS c, +u3 >= '16777215' AS cu, +i4 >= '16777215' AS d, +u4 >= '16777215' AS du, +i8 >= '16777215' AS e, +u8 >= '16777215' AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 1 1 1 1 1 +execute s4 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 1 1 1 1 1 +SELECT i1 <= 16777215 AS a, +u1 <= 16777215 AS au, +i2 <= 16777215 AS b, +u2 <= 16777215 AS bu, +i3 <= 16777215 AS c, +u3 <= 16777215 AS cu, +i4 <= 16777215 AS d, +u4 <= 16777215 AS du, +i8 <= 16777215 AS e, +u8 <= 16777215 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 0 0 0 0 +execute s5 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 0 0 0 0 +SELECT i1 <= 16777215.0 AS a, +u1 <= 16777215.0 AS au, +i2 <= 16777215.0 AS b, +u2 <= 16777215.0 AS bu, +i3 <= 16777215.0 AS c, +u3 <= 16777215.0 AS cu, +i4 <= 16777215.0 AS d, +u4 <= 16777215.0 AS du, +i8 <= 16777215.0 AS e, +u8 <= 16777215.0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 0 0 0 0 +execute s5 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 0 0 0 0 +SELECT i1 <= 16777215.0e0 AS a, +u1 <= 16777215.0e0 AS au, +i2 <= 16777215.0e0 AS b, +u2 <= 16777215.0e0 AS bu, +i3 <= 16777215.0e0 AS c, +u3 <= 16777215.0e0 AS cu, +i4 <= 16777215.0e0 AS d, +u4 <= 16777215.0e0 AS du, +i8 <= 16777215.0e0 AS e, +u8 <= 16777215.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 0 0 0 0 +execute s5 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 0 0 0 0 +SELECT i1 <= '16777215' AS a, +u1 <= '16777215' AS au, +i2 <= '16777215' AS b, +u2 <= '16777215' AS bu, +i3 <= '16777215' AS c, +u3 <= '16777215' AS cu, +i4 <= '16777215' AS d, +u4 <= '16777215' AS du, +i8 <= '16777215' AS e, +u8 <= '16777215' AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 0 0 0 0 +execute s5 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 0 0 0 0 +SELECT i1 > 16777215 AS a, +u1 > 16777215 AS au, +i2 > 16777215 AS b, +u2 > 16777215 AS bu, +i3 > 16777215 AS c, +u3 > 16777215 AS cu, +i4 > 16777215 AS d, +u4 > 16777215 AS du, +i8 > 16777215 AS e, +u8 > 16777215 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 1 1 1 1 +execute s6 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 1 1 1 1 +SELECT i1 > 16777215.0 AS a, +u1 > 16777215.0 AS au, +i2 > 16777215.0 AS b, +u2 > 16777215.0 AS bu, +i3 > 16777215.0 AS c, +u3 > 16777215.0 AS cu, +i4 > 16777215.0 AS d, +u4 > 16777215.0 AS du, +i8 > 16777215.0 AS e, +u8 > 16777215.0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 1 1 1 1 +execute s6 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 1 1 1 1 +SELECT i1 > 16777215.0e0 AS a, +u1 > 16777215.0e0 AS au, +i2 > 16777215.0e0 AS b, +u2 > 16777215.0e0 AS bu, +i3 > 16777215.0e0 AS c, +u3 > 16777215.0e0 AS cu, +i4 > 16777215.0e0 AS d, +u4 > 16777215.0e0 AS du, +i8 > 16777215.0e0 AS e, +u8 > 16777215.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 1 1 1 1 +execute s6 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 1 1 1 1 +SELECT i1 > '16777215' AS a, +u1 > '16777215' AS au, +i2 > '16777215' AS b, +u2 > '16777215' AS bu, +i3 > '16777215' AS c, +u3 > '16777215' AS cu, +i4 > '16777215' AS d, +u4 > '16777215' AS du, +i8 > '16777215' AS e, +u8 > '16777215' AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 1 1 1 1 +execute s6 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 1 1 1 1 +set @iv= 2147483647; +set @dv= 2147483647.0; +set @fv= 2147483647.0e0; +set @sv= "2147483647"; +SELECT i1 = 2147483647 AS a, +u1 = 2147483647 AS au, +i2 = 2147483647 AS b, +u2 = 2147483647 AS bu, +i3 = 2147483647 AS c, +u3 = 2147483647 AS cu, +i4 = 2147483647 AS d, +u4 = 2147483647 AS du, +i8 = 2147483647 AS e, +u8 = 2147483647 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 1 0 0 0 +execute s1 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 1 0 0 0 +SELECT i1 = 2147483647.0 AS a, +u1 = 2147483647.0 AS au, +i2 = 2147483647.0 AS b, +u2 = 2147483647.0 AS bu, +i3 = 2147483647.0 AS c, +u3 = 2147483647.0 AS cu, +i4 = 2147483647.0 AS d, +u4 = 2147483647.0 AS du, +i8 = 2147483647.0 AS e, +u8 = 2147483647.0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 1 0 0 0 +execute s1 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 1 0 0 0 +SELECT i1 = 2147483647.0e0 AS a, +u1 = 2147483647.0e0 AS au, +i2 = 2147483647.0e0 AS b, +u2 = 2147483647.0e0 AS bu, +i3 = 2147483647.0e0 AS c, +u3 = 2147483647.0e0 AS cu, +i4 = 2147483647.0e0 AS d, +u4 = 2147483647.0e0 AS du, +i8 = 2147483647.0e0 AS e, +u8 = 2147483647.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 1 0 0 0 +execute s1 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 1 0 0 0 +SELECT i1 = '2147483647' AS a, +u1 = '2147483647' AS au, +i2 = '2147483647' AS b, +u2 = '2147483647' AS bu, +i3 = '2147483647' AS c, +u3 = '2147483647' AS cu, +i4 = '2147483647' AS d, +u4 = '2147483647' AS du, +i8 = '2147483647' AS e, +u8 = '2147483647' AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 1 0 0 0 +execute s1 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 1 0 0 0 +SELECT i1 <> 2147483647 AS a, +u1 <> 2147483647 AS au, +i2 <> 2147483647 AS b, +u2 <> 2147483647 AS bu, +i3 <> 2147483647 AS c, +u3 <> 2147483647 AS cu, +i4 <> 2147483647 AS d, +u4 <> 2147483647 AS du, +i8 <> 2147483647 AS e, +u8 <> 2147483647 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 0 1 1 1 +execute s2 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 0 1 1 1 +SELECT i1 <> 2147483647.0 AS a, +u1 <> 2147483647.0 AS au, +i2 <> 2147483647.0 AS b, +u2 <> 2147483647.0 AS bu, +i3 <> 2147483647.0 AS c, +u3 <> 2147483647.0 AS cu, +i4 <> 2147483647.0 AS d, +u4 <> 2147483647.0 AS du, +i8 <> 2147483647.0 AS e, +u8 <> 2147483647.0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 0 1 1 1 +execute s2 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 0 1 1 1 +SELECT i1 <> 2147483647.0e0 AS a, +u1 <> 2147483647.0e0 AS au, +i2 <> 2147483647.0e0 AS b, +u2 <> 2147483647.0e0 AS bu, +i3 <> 2147483647.0e0 AS c, +u3 <> 2147483647.0e0 AS cu, +i4 <> 2147483647.0e0 AS d, +u4 <> 2147483647.0e0 AS du, +i8 <> 2147483647.0e0 AS e, +u8 <> 2147483647.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 0 1 1 1 +execute s2 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 0 1 1 1 +SELECT i1 <> '2147483647' AS a, +u1 <> '2147483647' AS au, +i2 <> '2147483647' AS b, +u2 <> '2147483647' AS bu, +i3 <> '2147483647' AS c, +u3 <> '2147483647' AS cu, +i4 <> '2147483647' AS d, +u4 <> '2147483647' AS du, +i8 <> '2147483647' AS e, +u8 <> '2147483647' AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 0 1 1 1 +execute s2 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 0 1 1 1 +SELECT i1 < 2147483647 AS a, +u1 < 2147483647 AS au, +i2 < 2147483647 AS b, +u2 < 2147483647 AS bu, +i3 < 2147483647 AS c, +u3 < 2147483647 AS cu, +i4 < 2147483647 AS d, +u4 < 2147483647 AS du, +i8 < 2147483647 AS e, +u8 < 2147483647 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 0 0 0 0 +execute s3 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 0 0 0 0 +SELECT i1 < 2147483647.0 AS a, +u1 < 2147483647.0 AS au, +i2 < 2147483647.0 AS b, +u2 < 2147483647.0 AS bu, +i3 < 2147483647.0 AS c, +u3 < 2147483647.0 AS cu, +i4 < 2147483647.0 AS d, +u4 < 2147483647.0 AS du, +i8 < 2147483647.0 AS e, +u8 < 2147483647.0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 0 0 0 0 +execute s3 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 0 0 0 0 +SELECT i1 < 2147483647.0e0 AS a, +u1 < 2147483647.0e0 AS au, +i2 < 2147483647.0e0 AS b, +u2 < 2147483647.0e0 AS bu, +i3 < 2147483647.0e0 AS c, +u3 < 2147483647.0e0 AS cu, +i4 < 2147483647.0e0 AS d, +u4 < 2147483647.0e0 AS du, +i8 < 2147483647.0e0 AS e, +u8 < 2147483647.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 0 0 0 0 +execute s3 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 0 0 0 0 +SELECT i1 < '2147483647' AS a, +u1 < '2147483647' AS au, +i2 < '2147483647' AS b, +u2 < '2147483647' AS bu, +i3 < '2147483647' AS c, +u3 < '2147483647' AS cu, +i4 < '2147483647' AS d, +u4 < '2147483647' AS du, +i8 < '2147483647' AS e, +u8 < '2147483647' AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 0 0 0 0 +execute s3 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 0 0 0 0 +SELECT i1 >= 2147483647 AS a, +u1 >= 2147483647 AS au, +i2 >= 2147483647 AS b, +u2 >= 2147483647 AS bu, +i3 >= 2147483647 AS c, +u3 >= 2147483647 AS cu, +i4 >= 2147483647 AS d, +u4 >= 2147483647 AS du, +i8 >= 2147483647 AS e, +u8 >= 2147483647 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 1 1 1 1 +execute s4 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 1 1 1 1 +SELECT i1 >= 2147483647.0 AS a, +u1 >= 2147483647.0 AS au, +i2 >= 2147483647.0 AS b, +u2 >= 2147483647.0 AS bu, +i3 >= 2147483647.0 AS c, +u3 >= 2147483647.0 AS cu, +i4 >= 2147483647.0 AS d, +u4 >= 2147483647.0 AS du, +i8 >= 2147483647.0 AS e, +u8 >= 2147483647.0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 1 1 1 1 +execute s4 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 1 1 1 1 +SELECT i1 >= 2147483647.0e0 AS a, +u1 >= 2147483647.0e0 AS au, +i2 >= 2147483647.0e0 AS b, +u2 >= 2147483647.0e0 AS bu, +i3 >= 2147483647.0e0 AS c, +u3 >= 2147483647.0e0 AS cu, +i4 >= 2147483647.0e0 AS d, +u4 >= 2147483647.0e0 AS du, +i8 >= 2147483647.0e0 AS e, +u8 >= 2147483647.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 1 1 1 1 +execute s4 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 1 1 1 1 +SELECT i1 >= '2147483647' AS a, +u1 >= '2147483647' AS au, +i2 >= '2147483647' AS b, +u2 >= '2147483647' AS bu, +i3 >= '2147483647' AS c, +u3 >= '2147483647' AS cu, +i4 >= '2147483647' AS d, +u4 >= '2147483647' AS du, +i8 >= '2147483647' AS e, +u8 >= '2147483647' AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 1 1 1 1 +execute s4 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 1 1 1 1 +SELECT i1 <= 2147483647 AS a, +u1 <= 2147483647 AS au, +i2 <= 2147483647 AS b, +u2 <= 2147483647 AS bu, +i3 <= 2147483647 AS c, +u3 <= 2147483647 AS cu, +i4 <= 2147483647 AS d, +u4 <= 2147483647 AS du, +i8 <= 2147483647 AS e, +u8 <= 2147483647 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 0 0 0 +execute s5 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 0 0 0 +SELECT i1 <= 2147483647.0 AS a, +u1 <= 2147483647.0 AS au, +i2 <= 2147483647.0 AS b, +u2 <= 2147483647.0 AS bu, +i3 <= 2147483647.0 AS c, +u3 <= 2147483647.0 AS cu, +i4 <= 2147483647.0 AS d, +u4 <= 2147483647.0 AS du, +i8 <= 2147483647.0 AS e, +u8 <= 2147483647.0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 0 0 0 +execute s5 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 0 0 0 +SELECT i1 <= 2147483647.0e0 AS a, +u1 <= 2147483647.0e0 AS au, +i2 <= 2147483647.0e0 AS b, +u2 <= 2147483647.0e0 AS bu, +i3 <= 2147483647.0e0 AS c, +u3 <= 2147483647.0e0 AS cu, +i4 <= 2147483647.0e0 AS d, +u4 <= 2147483647.0e0 AS du, +i8 <= 2147483647.0e0 AS e, +u8 <= 2147483647.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 0 0 0 +execute s5 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 0 0 0 +SELECT i1 <= '2147483647' AS a, +u1 <= '2147483647' AS au, +i2 <= '2147483647' AS b, +u2 <= '2147483647' AS bu, +i3 <= '2147483647' AS c, +u3 <= '2147483647' AS cu, +i4 <= '2147483647' AS d, +u4 <= '2147483647' AS du, +i8 <= '2147483647' AS e, +u8 <= '2147483647' AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 0 0 0 +execute s5 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 0 0 0 +SELECT i1 > 2147483647 AS a, +u1 > 2147483647 AS au, +i2 > 2147483647 AS b, +u2 > 2147483647 AS bu, +i3 > 2147483647 AS c, +u3 > 2147483647 AS cu, +i4 > 2147483647 AS d, +u4 > 2147483647 AS du, +i8 > 2147483647 AS e, +u8 > 2147483647 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 1 1 1 +execute s6 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 1 1 1 +SELECT i1 > 2147483647.0 AS a, +u1 > 2147483647.0 AS au, +i2 > 2147483647.0 AS b, +u2 > 2147483647.0 AS bu, +i3 > 2147483647.0 AS c, +u3 > 2147483647.0 AS cu, +i4 > 2147483647.0 AS d, +u4 > 2147483647.0 AS du, +i8 > 2147483647.0 AS e, +u8 > 2147483647.0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 1 1 1 +execute s6 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 1 1 1 +SELECT i1 > 2147483647.0e0 AS a, +u1 > 2147483647.0e0 AS au, +i2 > 2147483647.0e0 AS b, +u2 > 2147483647.0e0 AS bu, +i3 > 2147483647.0e0 AS c, +u3 > 2147483647.0e0 AS cu, +i4 > 2147483647.0e0 AS d, +u4 > 2147483647.0e0 AS du, +i8 > 2147483647.0e0 AS e, +u8 > 2147483647.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 1 1 1 +execute s6 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 1 1 1 +SELECT i1 > '2147483647' AS a, +u1 > '2147483647' AS au, +i2 > '2147483647' AS b, +u2 > '2147483647' AS bu, +i3 > '2147483647' AS c, +u3 > '2147483647' AS cu, +i4 > '2147483647' AS d, +u4 > '2147483647' AS du, +i8 > '2147483647' AS e, +u8 > '2147483647' AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 1 1 1 +execute s6 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 1 1 1 +set @iv= 4294967295; +set @dv= 4294967295.0; +set @fv= 4294967295.0e0; +set @sv= "4294967295"; +SELECT i1 = 4294967295 AS a, +u1 = 4294967295 AS au, +i2 = 4294967295 AS b, +u2 = 4294967295 AS bu, +i3 = 4294967295 AS c, +u3 = 4294967295 AS cu, +i4 = 4294967295 AS d, +u4 = 4294967295 AS du, +i8 = 4294967295 AS e, +u8 = 4294967295 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 1 0 0 +execute s1 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 1 0 0 +SELECT i1 = 4294967295.0 AS a, +u1 = 4294967295.0 AS au, +i2 = 4294967295.0 AS b, +u2 = 4294967295.0 AS bu, +i3 = 4294967295.0 AS c, +u3 = 4294967295.0 AS cu, +i4 = 4294967295.0 AS d, +u4 = 4294967295.0 AS du, +i8 = 4294967295.0 AS e, +u8 = 4294967295.0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 1 0 0 +execute s1 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 1 0 0 +SELECT i1 = 4294967295.0e0 AS a, +u1 = 4294967295.0e0 AS au, +i2 = 4294967295.0e0 AS b, +u2 = 4294967295.0e0 AS bu, +i3 = 4294967295.0e0 AS c, +u3 = 4294967295.0e0 AS cu, +i4 = 4294967295.0e0 AS d, +u4 = 4294967295.0e0 AS du, +i8 = 4294967295.0e0 AS e, +u8 = 4294967295.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 1 0 0 +execute s1 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 1 0 0 +SELECT i1 = '4294967295' AS a, +u1 = '4294967295' AS au, +i2 = '4294967295' AS b, +u2 = '4294967295' AS bu, +i3 = '4294967295' AS c, +u3 = '4294967295' AS cu, +i4 = '4294967295' AS d, +u4 = '4294967295' AS du, +i8 = '4294967295' AS e, +u8 = '4294967295' AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 1 0 0 +execute s1 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 1 0 0 +SELECT i1 <> 4294967295 AS a, +u1 <> 4294967295 AS au, +i2 <> 4294967295 AS b, +u2 <> 4294967295 AS bu, +i3 <> 4294967295 AS c, +u3 <> 4294967295 AS cu, +i4 <> 4294967295 AS d, +u4 <> 4294967295 AS du, +i8 <> 4294967295 AS e, +u8 <> 4294967295 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 0 1 1 +execute s2 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 0 1 1 +SELECT i1 <> 4294967295.0 AS a, +u1 <> 4294967295.0 AS au, +i2 <> 4294967295.0 AS b, +u2 <> 4294967295.0 AS bu, +i3 <> 4294967295.0 AS c, +u3 <> 4294967295.0 AS cu, +i4 <> 4294967295.0 AS d, +u4 <> 4294967295.0 AS du, +i8 <> 4294967295.0 AS e, +u8 <> 4294967295.0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 0 1 1 +execute s2 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 0 1 1 +SELECT i1 <> 4294967295.0e0 AS a, +u1 <> 4294967295.0e0 AS au, +i2 <> 4294967295.0e0 AS b, +u2 <> 4294967295.0e0 AS bu, +i3 <> 4294967295.0e0 AS c, +u3 <> 4294967295.0e0 AS cu, +i4 <> 4294967295.0e0 AS d, +u4 <> 4294967295.0e0 AS du, +i8 <> 4294967295.0e0 AS e, +u8 <> 4294967295.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 0 1 1 +execute s2 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 0 1 1 +SELECT i1 <> '4294967295' AS a, +u1 <> '4294967295' AS au, +i2 <> '4294967295' AS b, +u2 <> '4294967295' AS bu, +i3 <> '4294967295' AS c, +u3 <> '4294967295' AS cu, +i4 <> '4294967295' AS d, +u4 <> '4294967295' AS du, +i8 <> '4294967295' AS e, +u8 <> '4294967295' AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 0 1 1 +execute s2 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 0 1 1 +SELECT i1 < 4294967295 AS a, +u1 < 4294967295 AS au, +i2 < 4294967295 AS b, +u2 < 4294967295 AS bu, +i3 < 4294967295 AS c, +u3 < 4294967295 AS cu, +i4 < 4294967295 AS d, +u4 < 4294967295 AS du, +i8 < 4294967295 AS e, +u8 < 4294967295 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 0 0 0 +execute s3 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 0 0 0 +SELECT i1 < 4294967295.0 AS a, +u1 < 4294967295.0 AS au, +i2 < 4294967295.0 AS b, +u2 < 4294967295.0 AS bu, +i3 < 4294967295.0 AS c, +u3 < 4294967295.0 AS cu, +i4 < 4294967295.0 AS d, +u4 < 4294967295.0 AS du, +i8 < 4294967295.0 AS e, +u8 < 4294967295.0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 0 0 0 +execute s3 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 0 0 0 +SELECT i1 < 4294967295.0e0 AS a, +u1 < 4294967295.0e0 AS au, +i2 < 4294967295.0e0 AS b, +u2 < 4294967295.0e0 AS bu, +i3 < 4294967295.0e0 AS c, +u3 < 4294967295.0e0 AS cu, +i4 < 4294967295.0e0 AS d, +u4 < 4294967295.0e0 AS du, +i8 < 4294967295.0e0 AS e, +u8 < 4294967295.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 0 0 0 +execute s3 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 0 0 0 +SELECT i1 < '4294967295' AS a, +u1 < '4294967295' AS au, +i2 < '4294967295' AS b, +u2 < '4294967295' AS bu, +i3 < '4294967295' AS c, +u3 < '4294967295' AS cu, +i4 < '4294967295' AS d, +u4 < '4294967295' AS du, +i8 < '4294967295' AS e, +u8 < '4294967295' AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 0 0 0 +execute s3 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 0 0 0 +SELECT i1 >= 4294967295 AS a, +u1 >= 4294967295 AS au, +i2 >= 4294967295 AS b, +u2 >= 4294967295 AS bu, +i3 >= 4294967295 AS c, +u3 >= 4294967295 AS cu, +i4 >= 4294967295 AS d, +u4 >= 4294967295 AS du, +i8 >= 4294967295 AS e, +u8 >= 4294967295 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 1 1 1 +execute s4 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 1 1 1 +SELECT i1 >= 4294967295.0 AS a, +u1 >= 4294967295.0 AS au, +i2 >= 4294967295.0 AS b, +u2 >= 4294967295.0 AS bu, +i3 >= 4294967295.0 AS c, +u3 >= 4294967295.0 AS cu, +i4 >= 4294967295.0 AS d, +u4 >= 4294967295.0 AS du, +i8 >= 4294967295.0 AS e, +u8 >= 4294967295.0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 1 1 1 +execute s4 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 1 1 1 +SELECT i1 >= 4294967295.0e0 AS a, +u1 >= 4294967295.0e0 AS au, +i2 >= 4294967295.0e0 AS b, +u2 >= 4294967295.0e0 AS bu, +i3 >= 4294967295.0e0 AS c, +u3 >= 4294967295.0e0 AS cu, +i4 >= 4294967295.0e0 AS d, +u4 >= 4294967295.0e0 AS du, +i8 >= 4294967295.0e0 AS e, +u8 >= 4294967295.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 1 1 1 +execute s4 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 1 1 1 +SELECT i1 >= '4294967295' AS a, +u1 >= '4294967295' AS au, +i2 >= '4294967295' AS b, +u2 >= '4294967295' AS bu, +i3 >= '4294967295' AS c, +u3 >= '4294967295' AS cu, +i4 >= '4294967295' AS d, +u4 >= '4294967295' AS du, +i8 >= '4294967295' AS e, +u8 >= '4294967295' AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 1 1 1 +execute s4 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 1 1 1 +SELECT i1 <= 4294967295 AS a, +u1 <= 4294967295 AS au, +i2 <= 4294967295 AS b, +u2 <= 4294967295 AS bu, +i3 <= 4294967295 AS c, +u3 <= 4294967295 AS cu, +i4 <= 4294967295 AS d, +u4 <= 4294967295 AS du, +i8 <= 4294967295 AS e, +u8 <= 4294967295 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 0 0 +execute s5 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 0 0 +SELECT i1 <= 4294967295.0 AS a, +u1 <= 4294967295.0 AS au, +i2 <= 4294967295.0 AS b, +u2 <= 4294967295.0 AS bu, +i3 <= 4294967295.0 AS c, +u3 <= 4294967295.0 AS cu, +i4 <= 4294967295.0 AS d, +u4 <= 4294967295.0 AS du, +i8 <= 4294967295.0 AS e, +u8 <= 4294967295.0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 0 0 +execute s5 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 0 0 +SELECT i1 <= 4294967295.0e0 AS a, +u1 <= 4294967295.0e0 AS au, +i2 <= 4294967295.0e0 AS b, +u2 <= 4294967295.0e0 AS bu, +i3 <= 4294967295.0e0 AS c, +u3 <= 4294967295.0e0 AS cu, +i4 <= 4294967295.0e0 AS d, +u4 <= 4294967295.0e0 AS du, +i8 <= 4294967295.0e0 AS e, +u8 <= 4294967295.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 0 0 +execute s5 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 0 0 +SELECT i1 <= '4294967295' AS a, +u1 <= '4294967295' AS au, +i2 <= '4294967295' AS b, +u2 <= '4294967295' AS bu, +i3 <= '4294967295' AS c, +u3 <= '4294967295' AS cu, +i4 <= '4294967295' AS d, +u4 <= '4294967295' AS du, +i8 <= '4294967295' AS e, +u8 <= '4294967295' AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 0 0 +execute s5 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 0 0 +SELECT i1 > 4294967295 AS a, +u1 > 4294967295 AS au, +i2 > 4294967295 AS b, +u2 > 4294967295 AS bu, +i3 > 4294967295 AS c, +u3 > 4294967295 AS cu, +i4 > 4294967295 AS d, +u4 > 4294967295 AS du, +i8 > 4294967295 AS e, +u8 > 4294967295 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 1 1 +execute s6 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 1 1 +SELECT i1 > 4294967295.0 AS a, +u1 > 4294967295.0 AS au, +i2 > 4294967295.0 AS b, +u2 > 4294967295.0 AS bu, +i3 > 4294967295.0 AS c, +u3 > 4294967295.0 AS cu, +i4 > 4294967295.0 AS d, +u4 > 4294967295.0 AS du, +i8 > 4294967295.0 AS e, +u8 > 4294967295.0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 1 1 +execute s6 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 1 1 +SELECT i1 > 4294967295.0e0 AS a, +u1 > 4294967295.0e0 AS au, +i2 > 4294967295.0e0 AS b, +u2 > 4294967295.0e0 AS bu, +i3 > 4294967295.0e0 AS c, +u3 > 4294967295.0e0 AS cu, +i4 > 4294967295.0e0 AS d, +u4 > 4294967295.0e0 AS du, +i8 > 4294967295.0e0 AS e, +u8 > 4294967295.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 1 1 +execute s6 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 1 1 +SELECT i1 > '4294967295' AS a, +u1 > '4294967295' AS au, +i2 > '4294967295' AS b, +u2 > '4294967295' AS bu, +i3 > '4294967295' AS c, +u3 > '4294967295' AS cu, +i4 > '4294967295' AS d, +u4 > '4294967295' AS du, +i8 > '4294967295' AS e, +u8 > '4294967295' AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 1 1 +execute s6 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 1 1 +set @iv= 9223372036854775807; +set @dv= 9223372036854775807.0; +set @fv= 9223372036854775807.0e0; +set @sv= "9223372036854775807"; +SELECT i1 = 9223372036854775807 AS a, +u1 = 9223372036854775807 AS au, +i2 = 9223372036854775807 AS b, +u2 = 9223372036854775807 AS bu, +i3 = 9223372036854775807 AS c, +u3 = 9223372036854775807 AS cu, +i4 = 9223372036854775807 AS d, +u4 = 9223372036854775807 AS du, +i8 = 9223372036854775807 AS e, +u8 = 9223372036854775807 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 1 0 +execute s1 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 1 0 +SELECT i1 = 9223372036854775807.0 AS a, +u1 = 9223372036854775807.0 AS au, +i2 = 9223372036854775807.0 AS b, +u2 = 9223372036854775807.0 AS bu, +i3 = 9223372036854775807.0 AS c, +u3 = 9223372036854775807.0 AS cu, +i4 = 9223372036854775807.0 AS d, +u4 = 9223372036854775807.0 AS du, +i8 = 9223372036854775807.0 AS e, +u8 = 9223372036854775807.0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 1 0 +execute s1 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 1 0 +SELECT i1 = 9223372036854775807.0e0 AS a, +u1 = 9223372036854775807.0e0 AS au, +i2 = 9223372036854775807.0e0 AS b, +u2 = 9223372036854775807.0e0 AS bu, +i3 = 9223372036854775807.0e0 AS c, +u3 = 9223372036854775807.0e0 AS cu, +i4 = 9223372036854775807.0e0 AS d, +u4 = 9223372036854775807.0e0 AS du, +i8 = 9223372036854775807.0e0 AS e, +u8 = 9223372036854775807.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 1 0 +execute s1 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 1 0 +SELECT i1 = '9223372036854775807' AS a, +u1 = '9223372036854775807' AS au, +i2 = '9223372036854775807' AS b, +u2 = '9223372036854775807' AS bu, +i3 = '9223372036854775807' AS c, +u3 = '9223372036854775807' AS cu, +i4 = '9223372036854775807' AS d, +u4 = '9223372036854775807' AS du, +i8 = '9223372036854775807' AS e, +u8 = '9223372036854775807' AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 1 0 +execute s1 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 1 0 +SELECT i1 <> 9223372036854775807 AS a, +u1 <> 9223372036854775807 AS au, +i2 <> 9223372036854775807 AS b, +u2 <> 9223372036854775807 AS bu, +i3 <> 9223372036854775807 AS c, +u3 <> 9223372036854775807 AS cu, +i4 <> 9223372036854775807 AS d, +u4 <> 9223372036854775807 AS du, +i8 <> 9223372036854775807 AS e, +u8 <> 9223372036854775807 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 0 1 +execute s2 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 0 1 +SELECT i1 <> 9223372036854775807.0 AS a, +u1 <> 9223372036854775807.0 AS au, +i2 <> 9223372036854775807.0 AS b, +u2 <> 9223372036854775807.0 AS bu, +i3 <> 9223372036854775807.0 AS c, +u3 <> 9223372036854775807.0 AS cu, +i4 <> 9223372036854775807.0 AS d, +u4 <> 9223372036854775807.0 AS du, +i8 <> 9223372036854775807.0 AS e, +u8 <> 9223372036854775807.0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 0 1 +execute s2 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 0 1 +SELECT i1 <> 9223372036854775807.0e0 AS a, +u1 <> 9223372036854775807.0e0 AS au, +i2 <> 9223372036854775807.0e0 AS b, +u2 <> 9223372036854775807.0e0 AS bu, +i3 <> 9223372036854775807.0e0 AS c, +u3 <> 9223372036854775807.0e0 AS cu, +i4 <> 9223372036854775807.0e0 AS d, +u4 <> 9223372036854775807.0e0 AS du, +i8 <> 9223372036854775807.0e0 AS e, +u8 <> 9223372036854775807.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 0 1 +execute s2 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 0 1 +SELECT i1 <> '9223372036854775807' AS a, +u1 <> '9223372036854775807' AS au, +i2 <> '9223372036854775807' AS b, +u2 <> '9223372036854775807' AS bu, +i3 <> '9223372036854775807' AS c, +u3 <> '9223372036854775807' AS cu, +i4 <> '9223372036854775807' AS d, +u4 <> '9223372036854775807' AS du, +i8 <> '9223372036854775807' AS e, +u8 <> '9223372036854775807' AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 0 1 +execute s2 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 0 1 +SELECT i1 < 9223372036854775807 AS a, +u1 < 9223372036854775807 AS au, +i2 < 9223372036854775807 AS b, +u2 < 9223372036854775807 AS bu, +i3 < 9223372036854775807 AS c, +u3 < 9223372036854775807 AS cu, +i4 < 9223372036854775807 AS d, +u4 < 9223372036854775807 AS du, +i8 < 9223372036854775807 AS e, +u8 < 9223372036854775807 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 0 0 +execute s3 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 0 0 +SELECT i1 < 9223372036854775807.0 AS a, +u1 < 9223372036854775807.0 AS au, +i2 < 9223372036854775807.0 AS b, +u2 < 9223372036854775807.0 AS bu, +i3 < 9223372036854775807.0 AS c, +u3 < 9223372036854775807.0 AS cu, +i4 < 9223372036854775807.0 AS d, +u4 < 9223372036854775807.0 AS du, +i8 < 9223372036854775807.0 AS e, +u8 < 9223372036854775807.0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 0 0 +execute s3 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 0 0 +SELECT i1 < 9223372036854775807.0e0 AS a, +u1 < 9223372036854775807.0e0 AS au, +i2 < 9223372036854775807.0e0 AS b, +u2 < 9223372036854775807.0e0 AS bu, +i3 < 9223372036854775807.0e0 AS c, +u3 < 9223372036854775807.0e0 AS cu, +i4 < 9223372036854775807.0e0 AS d, +u4 < 9223372036854775807.0e0 AS du, +i8 < 9223372036854775807.0e0 AS e, +u8 < 9223372036854775807.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 0 0 +execute s3 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 0 0 +SELECT i1 < '9223372036854775807' AS a, +u1 < '9223372036854775807' AS au, +i2 < '9223372036854775807' AS b, +u2 < '9223372036854775807' AS bu, +i3 < '9223372036854775807' AS c, +u3 < '9223372036854775807' AS cu, +i4 < '9223372036854775807' AS d, +u4 < '9223372036854775807' AS du, +i8 < '9223372036854775807' AS e, +u8 < '9223372036854775807' AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 0 0 +execute s3 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 0 0 +SELECT i1 >= 9223372036854775807 AS a, +u1 >= 9223372036854775807 AS au, +i2 >= 9223372036854775807 AS b, +u2 >= 9223372036854775807 AS bu, +i3 >= 9223372036854775807 AS c, +u3 >= 9223372036854775807 AS cu, +i4 >= 9223372036854775807 AS d, +u4 >= 9223372036854775807 AS du, +i8 >= 9223372036854775807 AS e, +u8 >= 9223372036854775807 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 1 1 +execute s4 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 1 1 +SELECT i1 >= 9223372036854775807.0 AS a, +u1 >= 9223372036854775807.0 AS au, +i2 >= 9223372036854775807.0 AS b, +u2 >= 9223372036854775807.0 AS bu, +i3 >= 9223372036854775807.0 AS c, +u3 >= 9223372036854775807.0 AS cu, +i4 >= 9223372036854775807.0 AS d, +u4 >= 9223372036854775807.0 AS du, +i8 >= 9223372036854775807.0 AS e, +u8 >= 9223372036854775807.0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 1 1 +execute s4 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 1 1 +SELECT i1 >= 9223372036854775807.0e0 AS a, +u1 >= 9223372036854775807.0e0 AS au, +i2 >= 9223372036854775807.0e0 AS b, +u2 >= 9223372036854775807.0e0 AS bu, +i3 >= 9223372036854775807.0e0 AS c, +u3 >= 9223372036854775807.0e0 AS cu, +i4 >= 9223372036854775807.0e0 AS d, +u4 >= 9223372036854775807.0e0 AS du, +i8 >= 9223372036854775807.0e0 AS e, +u8 >= 9223372036854775807.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 1 1 +execute s4 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 1 1 +SELECT i1 >= '9223372036854775807' AS a, +u1 >= '9223372036854775807' AS au, +i2 >= '9223372036854775807' AS b, +u2 >= '9223372036854775807' AS bu, +i3 >= '9223372036854775807' AS c, +u3 >= '9223372036854775807' AS cu, +i4 >= '9223372036854775807' AS d, +u4 >= '9223372036854775807' AS du, +i8 >= '9223372036854775807' AS e, +u8 >= '9223372036854775807' AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 1 1 +execute s4 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 1 1 +SELECT i1 <= 9223372036854775807 AS a, +u1 <= 9223372036854775807 AS au, +i2 <= 9223372036854775807 AS b, +u2 <= 9223372036854775807 AS bu, +i3 <= 9223372036854775807 AS c, +u3 <= 9223372036854775807 AS cu, +i4 <= 9223372036854775807 AS d, +u4 <= 9223372036854775807 AS du, +i8 <= 9223372036854775807 AS e, +u8 <= 9223372036854775807 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 0 +execute s5 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 0 +SELECT i1 <= 9223372036854775807.0 AS a, +u1 <= 9223372036854775807.0 AS au, +i2 <= 9223372036854775807.0 AS b, +u2 <= 9223372036854775807.0 AS bu, +i3 <= 9223372036854775807.0 AS c, +u3 <= 9223372036854775807.0 AS cu, +i4 <= 9223372036854775807.0 AS d, +u4 <= 9223372036854775807.0 AS du, +i8 <= 9223372036854775807.0 AS e, +u8 <= 9223372036854775807.0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 0 +execute s5 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 0 +SELECT i1 <= 9223372036854775807.0e0 AS a, +u1 <= 9223372036854775807.0e0 AS au, +i2 <= 9223372036854775807.0e0 AS b, +u2 <= 9223372036854775807.0e0 AS bu, +i3 <= 9223372036854775807.0e0 AS c, +u3 <= 9223372036854775807.0e0 AS cu, +i4 <= 9223372036854775807.0e0 AS d, +u4 <= 9223372036854775807.0e0 AS du, +i8 <= 9223372036854775807.0e0 AS e, +u8 <= 9223372036854775807.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 0 +execute s5 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 0 +SELECT i1 <= '9223372036854775807' AS a, +u1 <= '9223372036854775807' AS au, +i2 <= '9223372036854775807' AS b, +u2 <= '9223372036854775807' AS bu, +i3 <= '9223372036854775807' AS c, +u3 <= '9223372036854775807' AS cu, +i4 <= '9223372036854775807' AS d, +u4 <= '9223372036854775807' AS du, +i8 <= '9223372036854775807' AS e, +u8 <= '9223372036854775807' AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 0 +execute s5 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 0 +SELECT i1 > 9223372036854775807 AS a, +u1 > 9223372036854775807 AS au, +i2 > 9223372036854775807 AS b, +u2 > 9223372036854775807 AS bu, +i3 > 9223372036854775807 AS c, +u3 > 9223372036854775807 AS cu, +i4 > 9223372036854775807 AS d, +u4 > 9223372036854775807 AS du, +i8 > 9223372036854775807 AS e, +u8 > 9223372036854775807 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 1 +execute s6 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 1 +SELECT i1 > 9223372036854775807.0 AS a, +u1 > 9223372036854775807.0 AS au, +i2 > 9223372036854775807.0 AS b, +u2 > 9223372036854775807.0 AS bu, +i3 > 9223372036854775807.0 AS c, +u3 > 9223372036854775807.0 AS cu, +i4 > 9223372036854775807.0 AS d, +u4 > 9223372036854775807.0 AS du, +i8 > 9223372036854775807.0 AS e, +u8 > 9223372036854775807.0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 1 +execute s6 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 1 +SELECT i1 > 9223372036854775807.0e0 AS a, +u1 > 9223372036854775807.0e0 AS au, +i2 > 9223372036854775807.0e0 AS b, +u2 > 9223372036854775807.0e0 AS bu, +i3 > 9223372036854775807.0e0 AS c, +u3 > 9223372036854775807.0e0 AS cu, +i4 > 9223372036854775807.0e0 AS d, +u4 > 9223372036854775807.0e0 AS du, +i8 > 9223372036854775807.0e0 AS e, +u8 > 9223372036854775807.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 1 +execute s6 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 1 +SELECT i1 > '9223372036854775807' AS a, +u1 > '9223372036854775807' AS au, +i2 > '9223372036854775807' AS b, +u2 > '9223372036854775807' AS bu, +i3 > '9223372036854775807' AS c, +u3 > '9223372036854775807' AS cu, +i4 > '9223372036854775807' AS d, +u4 > '9223372036854775807' AS du, +i8 > '9223372036854775807' AS e, +u8 > '9223372036854775807' AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 1 +execute s6 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 1 +set @iv= 9223372036854775808; +set @dv= 9223372036854775808.0; +set @fv= 9223372036854775808.0e0; +set @sv= "9223372036854775808"; +SELECT i1 = 9223372036854775808 AS a, +u1 = 9223372036854775808 AS au, +i2 = 9223372036854775808 AS b, +u2 = 9223372036854775808 AS bu, +i3 = 9223372036854775808 AS c, +u3 = 9223372036854775808 AS cu, +i4 = 9223372036854775808 AS d, +u4 = 9223372036854775808 AS du, +i8 = 9223372036854775808 AS e, +u8 = 9223372036854775808 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +execute s1 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +SELECT i1 = 9223372036854775808.0 AS a, +u1 = 9223372036854775808.0 AS au, +i2 = 9223372036854775808.0 AS b, +u2 = 9223372036854775808.0 AS bu, +i3 = 9223372036854775808.0 AS c, +u3 = 9223372036854775808.0 AS cu, +i4 = 9223372036854775808.0 AS d, +u4 = 9223372036854775808.0 AS du, +i8 = 9223372036854775808.0 AS e, +u8 = 9223372036854775808.0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +execute s1 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +SELECT i1 = 9223372036854775808.0e0 AS a, +u1 = 9223372036854775808.0e0 AS au, +i2 = 9223372036854775808.0e0 AS b, +u2 = 9223372036854775808.0e0 AS bu, +i3 = 9223372036854775808.0e0 AS c, +u3 = 9223372036854775808.0e0 AS cu, +i4 = 9223372036854775808.0e0 AS d, +u4 = 9223372036854775808.0e0 AS du, +i8 = 9223372036854775808.0e0 AS e, +u8 = 9223372036854775808.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 1 0 +execute s1 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 1 0 +SELECT i1 = '9223372036854775808' AS a, +u1 = '9223372036854775808' AS au, +i2 = '9223372036854775808' AS b, +u2 = '9223372036854775808' AS bu, +i3 = '9223372036854775808' AS c, +u3 = '9223372036854775808' AS cu, +i4 = '9223372036854775808' AS d, +u4 = '9223372036854775808' AS du, +i8 = '9223372036854775808' AS e, +u8 = '9223372036854775808' AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 1 0 +execute s1 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 1 0 +SELECT i1 <> 9223372036854775808 AS a, +u1 <> 9223372036854775808 AS au, +i2 <> 9223372036854775808 AS b, +u2 <> 9223372036854775808 AS bu, +i3 <> 9223372036854775808 AS c, +u3 <> 9223372036854775808 AS cu, +i4 <> 9223372036854775808 AS d, +u4 <> 9223372036854775808 AS du, +i8 <> 9223372036854775808 AS e, +u8 <> 9223372036854775808 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +execute s2 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +SELECT i1 <> 9223372036854775808.0 AS a, +u1 <> 9223372036854775808.0 AS au, +i2 <> 9223372036854775808.0 AS b, +u2 <> 9223372036854775808.0 AS bu, +i3 <> 9223372036854775808.0 AS c, +u3 <> 9223372036854775808.0 AS cu, +i4 <> 9223372036854775808.0 AS d, +u4 <> 9223372036854775808.0 AS du, +i8 <> 9223372036854775808.0 AS e, +u8 <> 9223372036854775808.0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +execute s2 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +SELECT i1 <> 9223372036854775808.0e0 AS a, +u1 <> 9223372036854775808.0e0 AS au, +i2 <> 9223372036854775808.0e0 AS b, +u2 <> 9223372036854775808.0e0 AS bu, +i3 <> 9223372036854775808.0e0 AS c, +u3 <> 9223372036854775808.0e0 AS cu, +i4 <> 9223372036854775808.0e0 AS d, +u4 <> 9223372036854775808.0e0 AS du, +i8 <> 9223372036854775808.0e0 AS e, +u8 <> 9223372036854775808.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 0 1 +execute s2 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 0 1 +SELECT i1 <> '9223372036854775808' AS a, +u1 <> '9223372036854775808' AS au, +i2 <> '9223372036854775808' AS b, +u2 <> '9223372036854775808' AS bu, +i3 <> '9223372036854775808' AS c, +u3 <> '9223372036854775808' AS cu, +i4 <> '9223372036854775808' AS d, +u4 <> '9223372036854775808' AS du, +i8 <> '9223372036854775808' AS e, +u8 <> '9223372036854775808' AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 0 1 +execute s2 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 0 1 +SELECT i1 < 9223372036854775808 AS a, +u1 < 9223372036854775808 AS au, +i2 < 9223372036854775808 AS b, +u2 < 9223372036854775808 AS bu, +i3 < 9223372036854775808 AS c, +u3 < 9223372036854775808 AS cu, +i4 < 9223372036854775808 AS d, +u4 < 9223372036854775808 AS du, +i8 < 9223372036854775808 AS e, +u8 < 9223372036854775808 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 0 +execute s3 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 0 +SELECT i1 < 9223372036854775808.0 AS a, +u1 < 9223372036854775808.0 AS au, +i2 < 9223372036854775808.0 AS b, +u2 < 9223372036854775808.0 AS bu, +i3 < 9223372036854775808.0 AS c, +u3 < 9223372036854775808.0 AS cu, +i4 < 9223372036854775808.0 AS d, +u4 < 9223372036854775808.0 AS du, +i8 < 9223372036854775808.0 AS e, +u8 < 9223372036854775808.0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 0 +execute s3 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 0 +SELECT i1 < 9223372036854775808.0e0 AS a, +u1 < 9223372036854775808.0e0 AS au, +i2 < 9223372036854775808.0e0 AS b, +u2 < 9223372036854775808.0e0 AS bu, +i3 < 9223372036854775808.0e0 AS c, +u3 < 9223372036854775808.0e0 AS cu, +i4 < 9223372036854775808.0e0 AS d, +u4 < 9223372036854775808.0e0 AS du, +i8 < 9223372036854775808.0e0 AS e, +u8 < 9223372036854775808.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 0 0 +execute s3 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 0 0 +SELECT i1 < '9223372036854775808' AS a, +u1 < '9223372036854775808' AS au, +i2 < '9223372036854775808' AS b, +u2 < '9223372036854775808' AS bu, +i3 < '9223372036854775808' AS c, +u3 < '9223372036854775808' AS cu, +i4 < '9223372036854775808' AS d, +u4 < '9223372036854775808' AS du, +i8 < '9223372036854775808' AS e, +u8 < '9223372036854775808' AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 0 0 +execute s3 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 0 0 +SELECT i1 >= 9223372036854775808 AS a, +u1 >= 9223372036854775808 AS au, +i2 >= 9223372036854775808 AS b, +u2 >= 9223372036854775808 AS bu, +i3 >= 9223372036854775808 AS c, +u3 >= 9223372036854775808 AS cu, +i4 >= 9223372036854775808 AS d, +u4 >= 9223372036854775808 AS du, +i8 >= 9223372036854775808 AS e, +u8 >= 9223372036854775808 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 1 +execute s4 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 1 +SELECT i1 >= 9223372036854775808.0 AS a, +u1 >= 9223372036854775808.0 AS au, +i2 >= 9223372036854775808.0 AS b, +u2 >= 9223372036854775808.0 AS bu, +i3 >= 9223372036854775808.0 AS c, +u3 >= 9223372036854775808.0 AS cu, +i4 >= 9223372036854775808.0 AS d, +u4 >= 9223372036854775808.0 AS du, +i8 >= 9223372036854775808.0 AS e, +u8 >= 9223372036854775808.0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 1 +execute s4 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 1 +SELECT i1 >= 9223372036854775808.0e0 AS a, +u1 >= 9223372036854775808.0e0 AS au, +i2 >= 9223372036854775808.0e0 AS b, +u2 >= 9223372036854775808.0e0 AS bu, +i3 >= 9223372036854775808.0e0 AS c, +u3 >= 9223372036854775808.0e0 AS cu, +i4 >= 9223372036854775808.0e0 AS d, +u4 >= 9223372036854775808.0e0 AS du, +i8 >= 9223372036854775808.0e0 AS e, +u8 >= 9223372036854775808.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 1 1 +execute s4 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 1 1 +SELECT i1 >= '9223372036854775808' AS a, +u1 >= '9223372036854775808' AS au, +i2 >= '9223372036854775808' AS b, +u2 >= '9223372036854775808' AS bu, +i3 >= '9223372036854775808' AS c, +u3 >= '9223372036854775808' AS cu, +i4 >= '9223372036854775808' AS d, +u4 >= '9223372036854775808' AS du, +i8 >= '9223372036854775808' AS e, +u8 >= '9223372036854775808' AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 1 1 +execute s4 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 1 1 +SELECT i1 <= 9223372036854775808 AS a, +u1 <= 9223372036854775808 AS au, +i2 <= 9223372036854775808 AS b, +u2 <= 9223372036854775808 AS bu, +i3 <= 9223372036854775808 AS c, +u3 <= 9223372036854775808 AS cu, +i4 <= 9223372036854775808 AS d, +u4 <= 9223372036854775808 AS du, +i8 <= 9223372036854775808 AS e, +u8 <= 9223372036854775808 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 0 +execute s5 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 0 +SELECT i1 <= 9223372036854775808.0 AS a, +u1 <= 9223372036854775808.0 AS au, +i2 <= 9223372036854775808.0 AS b, +u2 <= 9223372036854775808.0 AS bu, +i3 <= 9223372036854775808.0 AS c, +u3 <= 9223372036854775808.0 AS cu, +i4 <= 9223372036854775808.0 AS d, +u4 <= 9223372036854775808.0 AS du, +i8 <= 9223372036854775808.0 AS e, +u8 <= 9223372036854775808.0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 0 +execute s5 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 0 +SELECT i1 <= 9223372036854775808.0e0 AS a, +u1 <= 9223372036854775808.0e0 AS au, +i2 <= 9223372036854775808.0e0 AS b, +u2 <= 9223372036854775808.0e0 AS bu, +i3 <= 9223372036854775808.0e0 AS c, +u3 <= 9223372036854775808.0e0 AS cu, +i4 <= 9223372036854775808.0e0 AS d, +u4 <= 9223372036854775808.0e0 AS du, +i8 <= 9223372036854775808.0e0 AS e, +u8 <= 9223372036854775808.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 0 +execute s5 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 0 +SELECT i1 <= '9223372036854775808' AS a, +u1 <= '9223372036854775808' AS au, +i2 <= '9223372036854775808' AS b, +u2 <= '9223372036854775808' AS bu, +i3 <= '9223372036854775808' AS c, +u3 <= '9223372036854775808' AS cu, +i4 <= '9223372036854775808' AS d, +u4 <= '9223372036854775808' AS du, +i8 <= '9223372036854775808' AS e, +u8 <= '9223372036854775808' AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 0 +execute s5 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 0 +SELECT i1 > 9223372036854775808 AS a, +u1 > 9223372036854775808 AS au, +i2 > 9223372036854775808 AS b, +u2 > 9223372036854775808 AS bu, +i3 > 9223372036854775808 AS c, +u3 > 9223372036854775808 AS cu, +i4 > 9223372036854775808 AS d, +u4 > 9223372036854775808 AS du, +i8 > 9223372036854775808 AS e, +u8 > 9223372036854775808 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 1 +execute s6 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 1 +SELECT i1 > 9223372036854775808.0 AS a, +u1 > 9223372036854775808.0 AS au, +i2 > 9223372036854775808.0 AS b, +u2 > 9223372036854775808.0 AS bu, +i3 > 9223372036854775808.0 AS c, +u3 > 9223372036854775808.0 AS cu, +i4 > 9223372036854775808.0 AS d, +u4 > 9223372036854775808.0 AS du, +i8 > 9223372036854775808.0 AS e, +u8 > 9223372036854775808.0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 1 +execute s6 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 1 +SELECT i1 > 9223372036854775808.0e0 AS a, +u1 > 9223372036854775808.0e0 AS au, +i2 > 9223372036854775808.0e0 AS b, +u2 > 9223372036854775808.0e0 AS bu, +i3 > 9223372036854775808.0e0 AS c, +u3 > 9223372036854775808.0e0 AS cu, +i4 > 9223372036854775808.0e0 AS d, +u4 > 9223372036854775808.0e0 AS du, +i8 > 9223372036854775808.0e0 AS e, +u8 > 9223372036854775808.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 1 +execute s6 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 1 +SELECT i1 > '9223372036854775808' AS a, +u1 > '9223372036854775808' AS au, +i2 > '9223372036854775808' AS b, +u2 > '9223372036854775808' AS bu, +i3 > '9223372036854775808' AS c, +u3 > '9223372036854775808' AS cu, +i4 > '9223372036854775808' AS d, +u4 > '9223372036854775808' AS du, +i8 > '9223372036854775808' AS e, +u8 > '9223372036854775808' AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 1 +execute s6 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 1 +set @iv= 18446744073709551615; +set @dv= 18446744073709551615.0; +set @fv= 18446744073709551615.0e0; +set @sv= "18446744073709551615"; +SELECT i1 = 18446744073709551615 AS a, +u1 = 18446744073709551615 AS au, +i2 = 18446744073709551615 AS b, +u2 = 18446744073709551615 AS bu, +i3 = 18446744073709551615 AS c, +u3 = 18446744073709551615 AS cu, +i4 = 18446744073709551615 AS d, +u4 = 18446744073709551615 AS du, +i8 = 18446744073709551615 AS e, +u8 = 18446744073709551615 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 1 +execute s1 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 1 +SELECT i1 = 18446744073709551615.0 AS a, +u1 = 18446744073709551615.0 AS au, +i2 = 18446744073709551615.0 AS b, +u2 = 18446744073709551615.0 AS bu, +i3 = 18446744073709551615.0 AS c, +u3 = 18446744073709551615.0 AS cu, +i4 = 18446744073709551615.0 AS d, +u4 = 18446744073709551615.0 AS du, +i8 = 18446744073709551615.0 AS e, +u8 = 18446744073709551615.0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 1 +execute s1 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 1 +SELECT i1 = 18446744073709551615.0e0 AS a, +u1 = 18446744073709551615.0e0 AS au, +i2 = 18446744073709551615.0e0 AS b, +u2 = 18446744073709551615.0e0 AS bu, +i3 = 18446744073709551615.0e0 AS c, +u3 = 18446744073709551615.0e0 AS cu, +i4 = 18446744073709551615.0e0 AS d, +u4 = 18446744073709551615.0e0 AS du, +i8 = 18446744073709551615.0e0 AS e, +u8 = 18446744073709551615.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 1 +execute s1 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 1 +SELECT i1 = '18446744073709551615' AS a, +u1 = '18446744073709551615' AS au, +i2 = '18446744073709551615' AS b, +u2 = '18446744073709551615' AS bu, +i3 = '18446744073709551615' AS c, +u3 = '18446744073709551615' AS cu, +i4 = '18446744073709551615' AS d, +u4 = '18446744073709551615' AS du, +i8 = '18446744073709551615' AS e, +u8 = '18446744073709551615' AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 1 +execute s1 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 1 +SELECT i1 <> 18446744073709551615 AS a, +u1 <> 18446744073709551615 AS au, +i2 <> 18446744073709551615 AS b, +u2 <> 18446744073709551615 AS bu, +i3 <> 18446744073709551615 AS c, +u3 <> 18446744073709551615 AS cu, +i4 <> 18446744073709551615 AS d, +u4 <> 18446744073709551615 AS du, +i8 <> 18446744073709551615 AS e, +u8 <> 18446744073709551615 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 0 +execute s2 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 0 +SELECT i1 <> 18446744073709551615.0 AS a, +u1 <> 18446744073709551615.0 AS au, +i2 <> 18446744073709551615.0 AS b, +u2 <> 18446744073709551615.0 AS bu, +i3 <> 18446744073709551615.0 AS c, +u3 <> 18446744073709551615.0 AS cu, +i4 <> 18446744073709551615.0 AS d, +u4 <> 18446744073709551615.0 AS du, +i8 <> 18446744073709551615.0 AS e, +u8 <> 18446744073709551615.0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 0 +execute s2 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 0 +SELECT i1 <> 18446744073709551615.0e0 AS a, +u1 <> 18446744073709551615.0e0 AS au, +i2 <> 18446744073709551615.0e0 AS b, +u2 <> 18446744073709551615.0e0 AS bu, +i3 <> 18446744073709551615.0e0 AS c, +u3 <> 18446744073709551615.0e0 AS cu, +i4 <> 18446744073709551615.0e0 AS d, +u4 <> 18446744073709551615.0e0 AS du, +i8 <> 18446744073709551615.0e0 AS e, +u8 <> 18446744073709551615.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 0 +execute s2 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 0 +SELECT i1 <> '18446744073709551615' AS a, +u1 <> '18446744073709551615' AS au, +i2 <> '18446744073709551615' AS b, +u2 <> '18446744073709551615' AS bu, +i3 <> '18446744073709551615' AS c, +u3 <> '18446744073709551615' AS cu, +i4 <> '18446744073709551615' AS d, +u4 <> '18446744073709551615' AS du, +i8 <> '18446744073709551615' AS e, +u8 <> '18446744073709551615' AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 0 +execute s2 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 0 +SELECT i1 < 18446744073709551615 AS a, +u1 < 18446744073709551615 AS au, +i2 < 18446744073709551615 AS b, +u2 < 18446744073709551615 AS bu, +i3 < 18446744073709551615 AS c, +u3 < 18446744073709551615 AS cu, +i4 < 18446744073709551615 AS d, +u4 < 18446744073709551615 AS du, +i8 < 18446744073709551615 AS e, +u8 < 18446744073709551615 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 0 +execute s3 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 0 +SELECT i1 < 18446744073709551615.0 AS a, +u1 < 18446744073709551615.0 AS au, +i2 < 18446744073709551615.0 AS b, +u2 < 18446744073709551615.0 AS bu, +i3 < 18446744073709551615.0 AS c, +u3 < 18446744073709551615.0 AS cu, +i4 < 18446744073709551615.0 AS d, +u4 < 18446744073709551615.0 AS du, +i8 < 18446744073709551615.0 AS e, +u8 < 18446744073709551615.0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 0 +execute s3 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 0 +SELECT i1 < 18446744073709551615.0e0 AS a, +u1 < 18446744073709551615.0e0 AS au, +i2 < 18446744073709551615.0e0 AS b, +u2 < 18446744073709551615.0e0 AS bu, +i3 < 18446744073709551615.0e0 AS c, +u3 < 18446744073709551615.0e0 AS cu, +i4 < 18446744073709551615.0e0 AS d, +u4 < 18446744073709551615.0e0 AS du, +i8 < 18446744073709551615.0e0 AS e, +u8 < 18446744073709551615.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 0 +execute s3 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 0 +SELECT i1 < '18446744073709551615' AS a, +u1 < '18446744073709551615' AS au, +i2 < '18446744073709551615' AS b, +u2 < '18446744073709551615' AS bu, +i3 < '18446744073709551615' AS c, +u3 < '18446744073709551615' AS cu, +i4 < '18446744073709551615' AS d, +u4 < '18446744073709551615' AS du, +i8 < '18446744073709551615' AS e, +u8 < '18446744073709551615' AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 0 +execute s3 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 0 +SELECT i1 >= 18446744073709551615 AS a, +u1 >= 18446744073709551615 AS au, +i2 >= 18446744073709551615 AS b, +u2 >= 18446744073709551615 AS bu, +i3 >= 18446744073709551615 AS c, +u3 >= 18446744073709551615 AS cu, +i4 >= 18446744073709551615 AS d, +u4 >= 18446744073709551615 AS du, +i8 >= 18446744073709551615 AS e, +u8 >= 18446744073709551615 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 1 +execute s4 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 1 +SELECT i1 >= 18446744073709551615.0 AS a, +u1 >= 18446744073709551615.0 AS au, +i2 >= 18446744073709551615.0 AS b, +u2 >= 18446744073709551615.0 AS bu, +i3 >= 18446744073709551615.0 AS c, +u3 >= 18446744073709551615.0 AS cu, +i4 >= 18446744073709551615.0 AS d, +u4 >= 18446744073709551615.0 AS du, +i8 >= 18446744073709551615.0 AS e, +u8 >= 18446744073709551615.0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 1 +execute s4 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 1 +SELECT i1 >= 18446744073709551615.0e0 AS a, +u1 >= 18446744073709551615.0e0 AS au, +i2 >= 18446744073709551615.0e0 AS b, +u2 >= 18446744073709551615.0e0 AS bu, +i3 >= 18446744073709551615.0e0 AS c, +u3 >= 18446744073709551615.0e0 AS cu, +i4 >= 18446744073709551615.0e0 AS d, +u4 >= 18446744073709551615.0e0 AS du, +i8 >= 18446744073709551615.0e0 AS e, +u8 >= 18446744073709551615.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 1 +execute s4 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 1 +SELECT i1 >= '18446744073709551615' AS a, +u1 >= '18446744073709551615' AS au, +i2 >= '18446744073709551615' AS b, +u2 >= '18446744073709551615' AS bu, +i3 >= '18446744073709551615' AS c, +u3 >= '18446744073709551615' AS cu, +i4 >= '18446744073709551615' AS d, +u4 >= '18446744073709551615' AS du, +i8 >= '18446744073709551615' AS e, +u8 >= '18446744073709551615' AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 1 +execute s4 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 1 +SELECT i1 <= 18446744073709551615 AS a, +u1 <= 18446744073709551615 AS au, +i2 <= 18446744073709551615 AS b, +u2 <= 18446744073709551615 AS bu, +i3 <= 18446744073709551615 AS c, +u3 <= 18446744073709551615 AS cu, +i4 <= 18446744073709551615 AS d, +u4 <= 18446744073709551615 AS du, +i8 <= 18446744073709551615 AS e, +u8 <= 18446744073709551615 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +execute s5 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +SELECT i1 <= 18446744073709551615.0 AS a, +u1 <= 18446744073709551615.0 AS au, +i2 <= 18446744073709551615.0 AS b, +u2 <= 18446744073709551615.0 AS bu, +i3 <= 18446744073709551615.0 AS c, +u3 <= 18446744073709551615.0 AS cu, +i4 <= 18446744073709551615.0 AS d, +u4 <= 18446744073709551615.0 AS du, +i8 <= 18446744073709551615.0 AS e, +u8 <= 18446744073709551615.0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +execute s5 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +SELECT i1 <= 18446744073709551615.0e0 AS a, +u1 <= 18446744073709551615.0e0 AS au, +i2 <= 18446744073709551615.0e0 AS b, +u2 <= 18446744073709551615.0e0 AS bu, +i3 <= 18446744073709551615.0e0 AS c, +u3 <= 18446744073709551615.0e0 AS cu, +i4 <= 18446744073709551615.0e0 AS d, +u4 <= 18446744073709551615.0e0 AS du, +i8 <= 18446744073709551615.0e0 AS e, +u8 <= 18446744073709551615.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +execute s5 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +SELECT i1 <= '18446744073709551615' AS a, +u1 <= '18446744073709551615' AS au, +i2 <= '18446744073709551615' AS b, +u2 <= '18446744073709551615' AS bu, +i3 <= '18446744073709551615' AS c, +u3 <= '18446744073709551615' AS cu, +i4 <= '18446744073709551615' AS d, +u4 <= '18446744073709551615' AS du, +i8 <= '18446744073709551615' AS e, +u8 <= '18446744073709551615' AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +execute s5 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +SELECT i1 > 18446744073709551615 AS a, +u1 > 18446744073709551615 AS au, +i2 > 18446744073709551615 AS b, +u2 > 18446744073709551615 AS bu, +i3 > 18446744073709551615 AS c, +u3 > 18446744073709551615 AS cu, +i4 > 18446744073709551615 AS d, +u4 > 18446744073709551615 AS du, +i8 > 18446744073709551615 AS e, +u8 > 18446744073709551615 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +execute s6 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +SELECT i1 > 18446744073709551615.0 AS a, +u1 > 18446744073709551615.0 AS au, +i2 > 18446744073709551615.0 AS b, +u2 > 18446744073709551615.0 AS bu, +i3 > 18446744073709551615.0 AS c, +u3 > 18446744073709551615.0 AS cu, +i4 > 18446744073709551615.0 AS d, +u4 > 18446744073709551615.0 AS du, +i8 > 18446744073709551615.0 AS e, +u8 > 18446744073709551615.0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +execute s6 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +SELECT i1 > 18446744073709551615.0e0 AS a, +u1 > 18446744073709551615.0e0 AS au, +i2 > 18446744073709551615.0e0 AS b, +u2 > 18446744073709551615.0e0 AS bu, +i3 > 18446744073709551615.0e0 AS c, +u3 > 18446744073709551615.0e0 AS cu, +i4 > 18446744073709551615.0e0 AS d, +u4 > 18446744073709551615.0e0 AS du, +i8 > 18446744073709551615.0e0 AS e, +u8 > 18446744073709551615.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +execute s6 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +SELECT i1 > '18446744073709551615' AS a, +u1 > '18446744073709551615' AS au, +i2 > '18446744073709551615' AS b, +u2 > '18446744073709551615' AS bu, +i3 > '18446744073709551615' AS c, +u3 > '18446744073709551615' AS cu, +i4 > '18446744073709551615' AS d, +u4 > '18446744073709551615' AS du, +i8 > '18446744073709551615' AS e, +u8 > '18446744073709551615' AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +execute s6 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +set @iv= 18446744073709551616; +set @dv= 18446744073709551616.0; +set @fv= 18446744073709551616.0e0; +set @sv= "18446744073709551616"; +SELECT i1 = 18446744073709551616 AS a, +u1 = 18446744073709551616 AS au, +i2 = 18446744073709551616 AS b, +u2 = 18446744073709551616 AS bu, +i3 = 18446744073709551616 AS c, +u3 = 18446744073709551616 AS cu, +i4 = 18446744073709551616 AS d, +u4 = 18446744073709551616 AS du, +i8 = 18446744073709551616 AS e, +u8 = 18446744073709551616 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +execute s1 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +SELECT i1 = 18446744073709551616.0 AS a, +u1 = 18446744073709551616.0 AS au, +i2 = 18446744073709551616.0 AS b, +u2 = 18446744073709551616.0 AS bu, +i3 = 18446744073709551616.0 AS c, +u3 = 18446744073709551616.0 AS cu, +i4 = 18446744073709551616.0 AS d, +u4 = 18446744073709551616.0 AS du, +i8 = 18446744073709551616.0 AS e, +u8 = 18446744073709551616.0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +execute s1 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +SELECT i1 = 18446744073709551616.0e0 AS a, +u1 = 18446744073709551616.0e0 AS au, +i2 = 18446744073709551616.0e0 AS b, +u2 = 18446744073709551616.0e0 AS bu, +i3 = 18446744073709551616.0e0 AS c, +u3 = 18446744073709551616.0e0 AS cu, +i4 = 18446744073709551616.0e0 AS d, +u4 = 18446744073709551616.0e0 AS du, +i8 = 18446744073709551616.0e0 AS e, +u8 = 18446744073709551616.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 1 +execute s1 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 1 +SELECT i1 = '18446744073709551616' AS a, +u1 = '18446744073709551616' AS au, +i2 = '18446744073709551616' AS b, +u2 = '18446744073709551616' AS bu, +i3 = '18446744073709551616' AS c, +u3 = '18446744073709551616' AS cu, +i4 = '18446744073709551616' AS d, +u4 = '18446744073709551616' AS du, +i8 = '18446744073709551616' AS e, +u8 = '18446744073709551616' AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 1 +execute s1 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 1 +SELECT i1 <> 18446744073709551616 AS a, +u1 <> 18446744073709551616 AS au, +i2 <> 18446744073709551616 AS b, +u2 <> 18446744073709551616 AS bu, +i3 <> 18446744073709551616 AS c, +u3 <> 18446744073709551616 AS cu, +i4 <> 18446744073709551616 AS d, +u4 <> 18446744073709551616 AS du, +i8 <> 18446744073709551616 AS e, +u8 <> 18446744073709551616 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +execute s2 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +SELECT i1 <> 18446744073709551616.0 AS a, +u1 <> 18446744073709551616.0 AS au, +i2 <> 18446744073709551616.0 AS b, +u2 <> 18446744073709551616.0 AS bu, +i3 <> 18446744073709551616.0 AS c, +u3 <> 18446744073709551616.0 AS cu, +i4 <> 18446744073709551616.0 AS d, +u4 <> 18446744073709551616.0 AS du, +i8 <> 18446744073709551616.0 AS e, +u8 <> 18446744073709551616.0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +execute s2 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +SELECT i1 <> 18446744073709551616.0e0 AS a, +u1 <> 18446744073709551616.0e0 AS au, +i2 <> 18446744073709551616.0e0 AS b, +u2 <> 18446744073709551616.0e0 AS bu, +i3 <> 18446744073709551616.0e0 AS c, +u3 <> 18446744073709551616.0e0 AS cu, +i4 <> 18446744073709551616.0e0 AS d, +u4 <> 18446744073709551616.0e0 AS du, +i8 <> 18446744073709551616.0e0 AS e, +u8 <> 18446744073709551616.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 0 +execute s2 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 0 +SELECT i1 <> '18446744073709551616' AS a, +u1 <> '18446744073709551616' AS au, +i2 <> '18446744073709551616' AS b, +u2 <> '18446744073709551616' AS bu, +i3 <> '18446744073709551616' AS c, +u3 <> '18446744073709551616' AS cu, +i4 <> '18446744073709551616' AS d, +u4 <> '18446744073709551616' AS du, +i8 <> '18446744073709551616' AS e, +u8 <> '18446744073709551616' AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 0 +execute s2 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 0 +SELECT i1 < 18446744073709551616 AS a, +u1 < 18446744073709551616 AS au, +i2 < 18446744073709551616 AS b, +u2 < 18446744073709551616 AS bu, +i3 < 18446744073709551616 AS c, +u3 < 18446744073709551616 AS cu, +i4 < 18446744073709551616 AS d, +u4 < 18446744073709551616 AS du, +i8 < 18446744073709551616 AS e, +u8 < 18446744073709551616 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +execute s3 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +SELECT i1 < 18446744073709551616.0 AS a, +u1 < 18446744073709551616.0 AS au, +i2 < 18446744073709551616.0 AS b, +u2 < 18446744073709551616.0 AS bu, +i3 < 18446744073709551616.0 AS c, +u3 < 18446744073709551616.0 AS cu, +i4 < 18446744073709551616.0 AS d, +u4 < 18446744073709551616.0 AS du, +i8 < 18446744073709551616.0 AS e, +u8 < 18446744073709551616.0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +execute s3 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +SELECT i1 < 18446744073709551616.0e0 AS a, +u1 < 18446744073709551616.0e0 AS au, +i2 < 18446744073709551616.0e0 AS b, +u2 < 18446744073709551616.0e0 AS bu, +i3 < 18446744073709551616.0e0 AS c, +u3 < 18446744073709551616.0e0 AS cu, +i4 < 18446744073709551616.0e0 AS d, +u4 < 18446744073709551616.0e0 AS du, +i8 < 18446744073709551616.0e0 AS e, +u8 < 18446744073709551616.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 0 +execute s3 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 0 +SELECT i1 < '18446744073709551616' AS a, +u1 < '18446744073709551616' AS au, +i2 < '18446744073709551616' AS b, +u2 < '18446744073709551616' AS bu, +i3 < '18446744073709551616' AS c, +u3 < '18446744073709551616' AS cu, +i4 < '18446744073709551616' AS d, +u4 < '18446744073709551616' AS du, +i8 < '18446744073709551616' AS e, +u8 < '18446744073709551616' AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 0 +execute s3 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 0 +SELECT i1 >= 18446744073709551616 AS a, +u1 >= 18446744073709551616 AS au, +i2 >= 18446744073709551616 AS b, +u2 >= 18446744073709551616 AS bu, +i3 >= 18446744073709551616 AS c, +u3 >= 18446744073709551616 AS cu, +i4 >= 18446744073709551616 AS d, +u4 >= 18446744073709551616 AS du, +i8 >= 18446744073709551616 AS e, +u8 >= 18446744073709551616 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +execute s4 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +SELECT i1 >= 18446744073709551616.0 AS a, +u1 >= 18446744073709551616.0 AS au, +i2 >= 18446744073709551616.0 AS b, +u2 >= 18446744073709551616.0 AS bu, +i3 >= 18446744073709551616.0 AS c, +u3 >= 18446744073709551616.0 AS cu, +i4 >= 18446744073709551616.0 AS d, +u4 >= 18446744073709551616.0 AS du, +i8 >= 18446744073709551616.0 AS e, +u8 >= 18446744073709551616.0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +execute s4 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +SELECT i1 >= 18446744073709551616.0e0 AS a, +u1 >= 18446744073709551616.0e0 AS au, +i2 >= 18446744073709551616.0e0 AS b, +u2 >= 18446744073709551616.0e0 AS bu, +i3 >= 18446744073709551616.0e0 AS c, +u3 >= 18446744073709551616.0e0 AS cu, +i4 >= 18446744073709551616.0e0 AS d, +u4 >= 18446744073709551616.0e0 AS du, +i8 >= 18446744073709551616.0e0 AS e, +u8 >= 18446744073709551616.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 1 +execute s4 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 1 +SELECT i1 >= '18446744073709551616' AS a, +u1 >= '18446744073709551616' AS au, +i2 >= '18446744073709551616' AS b, +u2 >= '18446744073709551616' AS bu, +i3 >= '18446744073709551616' AS c, +u3 >= '18446744073709551616' AS cu, +i4 >= '18446744073709551616' AS d, +u4 >= '18446744073709551616' AS du, +i8 >= '18446744073709551616' AS e, +u8 >= '18446744073709551616' AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 1 +execute s4 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 1 +SELECT i1 <= 18446744073709551616 AS a, +u1 <= 18446744073709551616 AS au, +i2 <= 18446744073709551616 AS b, +u2 <= 18446744073709551616 AS bu, +i3 <= 18446744073709551616 AS c, +u3 <= 18446744073709551616 AS cu, +i4 <= 18446744073709551616 AS d, +u4 <= 18446744073709551616 AS du, +i8 <= 18446744073709551616 AS e, +u8 <= 18446744073709551616 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +execute s5 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +SELECT i1 <= 18446744073709551616.0 AS a, +u1 <= 18446744073709551616.0 AS au, +i2 <= 18446744073709551616.0 AS b, +u2 <= 18446744073709551616.0 AS bu, +i3 <= 18446744073709551616.0 AS c, +u3 <= 18446744073709551616.0 AS cu, +i4 <= 18446744073709551616.0 AS d, +u4 <= 18446744073709551616.0 AS du, +i8 <= 18446744073709551616.0 AS e, +u8 <= 18446744073709551616.0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +execute s5 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +SELECT i1 <= 18446744073709551616.0e0 AS a, +u1 <= 18446744073709551616.0e0 AS au, +i2 <= 18446744073709551616.0e0 AS b, +u2 <= 18446744073709551616.0e0 AS bu, +i3 <= 18446744073709551616.0e0 AS c, +u3 <= 18446744073709551616.0e0 AS cu, +i4 <= 18446744073709551616.0e0 AS d, +u4 <= 18446744073709551616.0e0 AS du, +i8 <= 18446744073709551616.0e0 AS e, +u8 <= 18446744073709551616.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +execute s5 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +SELECT i1 <= '18446744073709551616' AS a, +u1 <= '18446744073709551616' AS au, +i2 <= '18446744073709551616' AS b, +u2 <= '18446744073709551616' AS bu, +i3 <= '18446744073709551616' AS c, +u3 <= '18446744073709551616' AS cu, +i4 <= '18446744073709551616' AS d, +u4 <= '18446744073709551616' AS du, +i8 <= '18446744073709551616' AS e, +u8 <= '18446744073709551616' AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +execute s5 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +SELECT i1 > 18446744073709551616 AS a, +u1 > 18446744073709551616 AS au, +i2 > 18446744073709551616 AS b, +u2 > 18446744073709551616 AS bu, +i3 > 18446744073709551616 AS c, +u3 > 18446744073709551616 AS cu, +i4 > 18446744073709551616 AS d, +u4 > 18446744073709551616 AS du, +i8 > 18446744073709551616 AS e, +u8 > 18446744073709551616 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +execute s6 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +SELECT i1 > 18446744073709551616.0 AS a, +u1 > 18446744073709551616.0 AS au, +i2 > 18446744073709551616.0 AS b, +u2 > 18446744073709551616.0 AS bu, +i3 > 18446744073709551616.0 AS c, +u3 > 18446744073709551616.0 AS cu, +i4 > 18446744073709551616.0 AS d, +u4 > 18446744073709551616.0 AS du, +i8 > 18446744073709551616.0 AS e, +u8 > 18446744073709551616.0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +execute s6 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +SELECT i1 > 18446744073709551616.0e0 AS a, +u1 > 18446744073709551616.0e0 AS au, +i2 > 18446744073709551616.0e0 AS b, +u2 > 18446744073709551616.0e0 AS bu, +i3 > 18446744073709551616.0e0 AS c, +u3 > 18446744073709551616.0e0 AS cu, +i4 > 18446744073709551616.0e0 AS d, +u4 > 18446744073709551616.0e0 AS du, +i8 > 18446744073709551616.0e0 AS e, +u8 > 18446744073709551616.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +execute s6 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +SELECT i1 > '18446744073709551616' AS a, +u1 > '18446744073709551616' AS au, +i2 > '18446744073709551616' AS b, +u2 > '18446744073709551616' AS bu, +i3 > '18446744073709551616' AS c, +u3 > '18446744073709551616' AS cu, +i4 > '18446744073709551616' AS d, +u4 > '18446744073709551616' AS du, +i8 > '18446744073709551616' AS e, +u8 > '18446744073709551616' AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +execute s6 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +DEALLOCATE PREPARE s1; +DEALLOCATE PREPARE s2; +DEALLOCATE PREPARE s3; +DEALLOCATE PREPARE s4; +DEALLOCATE PREPARE s5; +DEALLOCATE PREPARE s6; +DROP TABLE t1; +CREATE TABLE t2 +(pk INTEGER PRIMARY KEY, +f4 REAL, +f8 DOUBLE); +INSERT INTO t2 VALUES +(0, -3.402823e+38, -1.797693134862315708e+308), +(1, -1.175494e-38, -2.225073858507201383e-308), +(2, 0, 0), +(3, 1.175494e-38, 2.225073858507201383e-308), +(4, 3.402823e+38, 1.797693134862315708e+308); +set @fv= -1.797693134862315708e+308; +set @sv= "-1.797693134862315708e+308"; +SELECT f4 = -1.797693134862315708e+308 AS a, +f8 = -1.797693134862315708e+308 AS b +FROM t2; +a b +0 1 +0 0 +0 0 +0 0 +0 0 +execute s1 using @fv, @fv; +a b +0 1 +0 0 +0 0 +0 0 +0 0 +SELECT f4 = '-1.797693134862315708e+308' AS a, +f8 = '-1.797693134862315708e+308' AS b +FROM t2; +a b +0 1 +0 0 +0 0 +0 0 +0 0 +execute s1 using @sv, @sv; +a b +0 1 +0 0 +0 0 +0 0 +0 0 +SELECT f4 <> -1.797693134862315708e+308 AS a, +f8 <> -1.797693134862315708e+308 AS b +FROM t2; +a b +1 0 +1 1 +1 1 +1 1 +1 1 +execute s2 using @fv, @fv; +a b +1 0 +1 1 +1 1 +1 1 +1 1 +SELECT f4 <> '-1.797693134862315708e+308' AS a, +f8 <> '-1.797693134862315708e+308' AS b +FROM t2; +a b +1 0 +1 1 +1 1 +1 1 +1 1 +execute s2 using @sv, @sv; +a b +1 0 +1 1 +1 1 +1 1 +1 1 +SELECT f4 < -1.797693134862315708e+308 AS a, +f8 < -1.797693134862315708e+308 AS b +FROM t2; +a b +0 0 +0 0 +0 0 +0 0 +0 0 +execute s3 using @fv, @fv; +a b +0 0 +0 0 +0 0 +0 0 +0 0 +SELECT f4 < '-1.797693134862315708e+308' AS a, +f8 < '-1.797693134862315708e+308' AS b +FROM t2; +a b +0 0 +0 0 +0 0 +0 0 +0 0 +execute s3 using @sv, @sv; +a b +0 0 +0 0 +0 0 +0 0 +0 0 +SELECT f4 >= -1.797693134862315708e+308 AS a, +f8 >= -1.797693134862315708e+308 AS b +FROM t2; +a b +1 1 +1 1 +1 1 +1 1 +1 1 +execute s4 using @fv, @fv; +a b +1 1 +1 1 +1 1 +1 1 +1 1 +SELECT f4 >= '-1.797693134862315708e+308' AS a, +f8 >= '-1.797693134862315708e+308' AS b +FROM t2; +a b +1 1 +1 1 +1 1 +1 1 +1 1 +execute s4 using @sv, @sv; +a b +1 1 +1 1 +1 1 +1 1 +1 1 +SELECT f4 <= -1.797693134862315708e+308 AS a, +f8 <= -1.797693134862315708e+308 AS b +FROM t2; +a b +0 1 +0 0 +0 0 +0 0 +0 0 +execute s5 using @fv, @fv; +a b +0 1 +0 0 +0 0 +0 0 +0 0 +SELECT f4 <= '-1.797693134862315708e+308' AS a, +f8 <= '-1.797693134862315708e+308' AS b +FROM t2; +a b +0 1 +0 0 +0 0 +0 0 +0 0 +execute s5 using @sv, @sv; +a b +0 1 +0 0 +0 0 +0 0 +0 0 +SELECT f4 > -1.797693134862315708e+308 AS a, +f8 > -1.797693134862315708e+308 AS b +FROM t2; +a b +1 0 +1 1 +1 1 +1 1 +1 1 +execute s6 using @fv, @fv; +a b +1 0 +1 1 +1 1 +1 1 +1 1 +SELECT f4 > '-1.797693134862315708e+308' AS a, +f8 > '-1.797693134862315708e+308' AS b +FROM t2; +a b +1 0 +1 1 +1 1 +1 1 +1 1 +execute s6 using @sv, @sv; +a b +1 0 +1 1 +1 1 +1 1 +1 1 +set @fv= -3.40282347e+38; +set @sv= "-3.40282347e+38"; +SELECT f4 = -3.40282347e+38 AS a, +f8 = -3.40282347e+38 AS b +FROM t2; +a b +0 0 +0 0 +0 0 +0 0 +0 0 +execute s1 using @fv, @fv; +a b +0 0 +0 0 +0 0 +0 0 +0 0 +SELECT f4 = '-3.40282347e+38' AS a, +f8 = '-3.40282347e+38' AS b +FROM t2; +a b +0 0 +0 0 +0 0 +0 0 +0 0 +execute s1 using @sv, @sv; +a b +0 0 +0 0 +0 0 +0 0 +0 0 +SELECT f4 <> -3.40282347e+38 AS a, +f8 <> -3.40282347e+38 AS b +FROM t2; +a b +1 1 +1 1 +1 1 +1 1 +1 1 +execute s2 using @fv, @fv; +a b +1 1 +1 1 +1 1 +1 1 +1 1 +SELECT f4 <> '-3.40282347e+38' AS a, +f8 <> '-3.40282347e+38' AS b +FROM t2; +a b +1 1 +1 1 +1 1 +1 1 +1 1 +execute s2 using @sv, @sv; +a b +1 1 +1 1 +1 1 +1 1 +1 1 +SELECT f4 < -3.40282347e+38 AS a, +f8 < -3.40282347e+38 AS b +FROM t2; +a b +0 1 +0 0 +0 0 +0 0 +0 0 +execute s3 using @fv, @fv; +a b +0 1 +0 0 +0 0 +0 0 +0 0 +SELECT f4 < '-3.40282347e+38' AS a, +f8 < '-3.40282347e+38' AS b +FROM t2; +a b +0 1 +0 0 +0 0 +0 0 +0 0 +execute s3 using @sv, @sv; +a b +0 1 +0 0 +0 0 +0 0 +0 0 +SELECT f4 >= -3.40282347e+38 AS a, +f8 >= -3.40282347e+38 AS b +FROM t2; +a b +1 0 +1 1 +1 1 +1 1 +1 1 +execute s4 using @fv, @fv; +a b +1 0 +1 1 +1 1 +1 1 +1 1 +SELECT f4 >= '-3.40282347e+38' AS a, +f8 >= '-3.40282347e+38' AS b +FROM t2; +a b +1 0 +1 1 +1 1 +1 1 +1 1 +execute s4 using @sv, @sv; +a b +1 0 +1 1 +1 1 +1 1 +1 1 +SELECT f4 <= -3.40282347e+38 AS a, +f8 <= -3.40282347e+38 AS b +FROM t2; +a b +0 1 +0 0 +0 0 +0 0 +0 0 +execute s5 using @fv, @fv; +a b +0 1 +0 0 +0 0 +0 0 +0 0 +SELECT f4 <= '-3.40282347e+38' AS a, +f8 <= '-3.40282347e+38' AS b +FROM t2; +a b +0 1 +0 0 +0 0 +0 0 +0 0 +execute s5 using @sv, @sv; +a b +0 1 +0 0 +0 0 +0 0 +0 0 +SELECT f4 > -3.40282347e+38 AS a, +f8 > -3.40282347e+38 AS b +FROM t2; +a b +1 0 +1 1 +1 1 +1 1 +1 1 +execute s6 using @fv, @fv; +a b +1 0 +1 1 +1 1 +1 1 +1 1 +SELECT f4 > '-3.40282347e+38' AS a, +f8 > '-3.40282347e+38' AS b +FROM t2; +a b +1 0 +1 1 +1 1 +1 1 +1 1 +execute s6 using @sv, @sv; +a b +1 0 +1 1 +1 1 +1 1 +1 1 +set @fv= -1.17549435e-38; +set @sv= "-1.17549435e-38"; +SELECT f4 = -1.17549435e-38 AS a, +f8 = -1.17549435e-38 AS b +FROM t2; +a b +0 0 +0 0 +0 0 +0 0 +0 0 +execute s1 using @fv, @fv; +a b +0 0 +0 0 +0 0 +0 0 +0 0 +SELECT f4 = '-1.17549435e-38' AS a, +f8 = '-1.17549435e-38' AS b +FROM t2; +a b +0 0 +0 0 +0 0 +0 0 +0 0 +execute s1 using @sv, @sv; +a b +0 0 +0 0 +0 0 +0 0 +0 0 +SELECT f4 <> -1.17549435e-38 AS a, +f8 <> -1.17549435e-38 AS b +FROM t2; +a b +1 1 +1 1 +1 1 +1 1 +1 1 +execute s2 using @fv, @fv; +a b +1 1 +1 1 +1 1 +1 1 +1 1 +SELECT f4 <> '-1.17549435e-38' AS a, +f8 <> '-1.17549435e-38' AS b +FROM t2; +a b +1 1 +1 1 +1 1 +1 1 +1 1 +execute s2 using @sv, @sv; +a b +1 1 +1 1 +1 1 +1 1 +1 1 +SELECT f4 < -1.17549435e-38 AS a, +f8 < -1.17549435e-38 AS b +FROM t2; +a b +1 1 +0 0 +0 0 +0 0 +0 0 +execute s3 using @fv, @fv; +a b +1 1 +0 0 +0 0 +0 0 +0 0 +SELECT f4 < '-1.17549435e-38' AS a, +f8 < '-1.17549435e-38' AS b +FROM t2; +a b +1 1 +0 0 +0 0 +0 0 +0 0 +execute s3 using @sv, @sv; +a b +1 1 +0 0 +0 0 +0 0 +0 0 +SELECT f4 >= -1.17549435e-38 AS a, +f8 >= -1.17549435e-38 AS b +FROM t2; +a b +0 0 +1 1 +1 1 +1 1 +1 1 +execute s4 using @fv, @fv; +a b +0 0 +1 1 +1 1 +1 1 +1 1 +SELECT f4 >= '-1.17549435e-38' AS a, +f8 >= '-1.17549435e-38' AS b +FROM t2; +a b +0 0 +1 1 +1 1 +1 1 +1 1 +execute s4 using @sv, @sv; +a b +0 0 +1 1 +1 1 +1 1 +1 1 +SELECT f4 <= -1.17549435e-38 AS a, +f8 <= -1.17549435e-38 AS b +FROM t2; +a b +1 1 +0 0 +0 0 +0 0 +0 0 +execute s5 using @fv, @fv; +a b +1 1 +0 0 +0 0 +0 0 +0 0 +SELECT f4 <= '-1.17549435e-38' AS a, +f8 <= '-1.17549435e-38' AS b +FROM t2; +a b +1 1 +0 0 +0 0 +0 0 +0 0 +execute s5 using @sv, @sv; +a b +1 1 +0 0 +0 0 +0 0 +0 0 +SELECT f4 > -1.17549435e-38 AS a, +f8 > -1.17549435e-38 AS b +FROM t2; +a b +0 0 +1 1 +1 1 +1 1 +1 1 +execute s6 using @fv, @fv; +a b +0 0 +1 1 +1 1 +1 1 +1 1 +SELECT f4 > '-1.17549435e-38' AS a, +f8 > '-1.17549435e-38' AS b +FROM t2; +a b +0 0 +1 1 +1 1 +1 1 +1 1 +execute s6 using @sv, @sv; +a b +0 0 +1 1 +1 1 +1 1 +1 1 +set @fv= -2.225073858507201383e-308; +set @sv= "-2.225073858507201383e-308"; +SELECT f4 = -2.225073858507201383e-308 AS a, +f8 = -2.225073858507201383e-308 AS b +FROM t2; +a b +0 0 +0 1 +0 0 +0 0 +0 0 +execute s1 using @fv, @fv; +a b +0 0 +0 1 +0 0 +0 0 +0 0 +SELECT f4 = '-2.225073858507201383e-308' AS a, +f8 = '-2.225073858507201383e-308' AS b +FROM t2; +a b +0 0 +0 1 +0 0 +0 0 +0 0 +execute s1 using @sv, @sv; +a b +0 0 +0 1 +0 0 +0 0 +0 0 +SELECT f4 <> -2.225073858507201383e-308 AS a, +f8 <> -2.225073858507201383e-308 AS b +FROM t2; +a b +1 1 +1 0 +1 1 +1 1 +1 1 +execute s2 using @fv, @fv; +a b +1 1 +1 0 +1 1 +1 1 +1 1 +SELECT f4 <> '-2.225073858507201383e-308' AS a, +f8 <> '-2.225073858507201383e-308' AS b +FROM t2; +a b +1 1 +1 0 +1 1 +1 1 +1 1 +execute s2 using @sv, @sv; +a b +1 1 +1 0 +1 1 +1 1 +1 1 +SELECT f4 < -2.225073858507201383e-308 AS a, +f8 < -2.225073858507201383e-308 AS b +FROM t2; +a b +1 1 +1 0 +0 0 +0 0 +0 0 +execute s3 using @fv, @fv; +a b +1 1 +1 0 +0 0 +0 0 +0 0 +SELECT f4 < '-2.225073858507201383e-308' AS a, +f8 < '-2.225073858507201383e-308' AS b +FROM t2; +a b +1 1 +1 0 +0 0 +0 0 +0 0 +execute s3 using @sv, @sv; +a b +1 1 +1 0 +0 0 +0 0 +0 0 +SELECT f4 >= -2.225073858507201383e-308 AS a, +f8 >= -2.225073858507201383e-308 AS b +FROM t2; +a b +0 0 +0 1 +1 1 +1 1 +1 1 +execute s4 using @fv, @fv; +a b +0 0 +0 1 +1 1 +1 1 +1 1 +SELECT f4 >= '-2.225073858507201383e-308' AS a, +f8 >= '-2.225073858507201383e-308' AS b +FROM t2; +a b +0 0 +0 1 +1 1 +1 1 +1 1 +execute s4 using @sv, @sv; +a b +0 0 +0 1 +1 1 +1 1 +1 1 +SELECT f4 <= -2.225073858507201383e-308 AS a, +f8 <= -2.225073858507201383e-308 AS b +FROM t2; +a b +1 1 +1 1 +0 0 +0 0 +0 0 +execute s5 using @fv, @fv; +a b +1 1 +1 1 +0 0 +0 0 +0 0 +SELECT f4 <= '-2.225073858507201383e-308' AS a, +f8 <= '-2.225073858507201383e-308' AS b +FROM t2; +a b +1 1 +1 1 +0 0 +0 0 +0 0 +execute s5 using @sv, @sv; +a b +1 1 +1 1 +0 0 +0 0 +0 0 +SELECT f4 > -2.225073858507201383e-308 AS a, +f8 > -2.225073858507201383e-308 AS b +FROM t2; +a b +0 0 +0 0 +1 1 +1 1 +1 1 +execute s6 using @fv, @fv; +a b +0 0 +0 0 +1 1 +1 1 +1 1 +SELECT f4 > '-2.225073858507201383e-308' AS a, +f8 > '-2.225073858507201383e-308' AS b +FROM t2; +a b +0 0 +0 0 +1 1 +1 1 +1 1 +execute s6 using @sv, @sv; +a b +0 0 +0 0 +1 1 +1 1 +1 1 +set @fv= 0; +set @sv= "0"; +SELECT f4 = 0 AS a, +f8 = 0 AS b +FROM t2; +a b +0 0 +0 0 +1 1 +0 0 +0 0 +execute s1 using @fv, @fv; +a b +0 0 +0 0 +1 1 +0 0 +0 0 +SELECT f4 = '0' AS a, +f8 = '0' AS b +FROM t2; +a b +0 0 +0 0 +1 1 +0 0 +0 0 +execute s1 using @sv, @sv; +a b +0 0 +0 0 +1 1 +0 0 +0 0 +SELECT f4 <> 0 AS a, +f8 <> 0 AS b +FROM t2; +a b +1 1 +1 1 +0 0 +1 1 +1 1 +execute s2 using @fv, @fv; +a b +1 1 +1 1 +0 0 +1 1 +1 1 +SELECT f4 <> '0' AS a, +f8 <> '0' AS b +FROM t2; +a b +1 1 +1 1 +0 0 +1 1 +1 1 +execute s2 using @sv, @sv; +a b +1 1 +1 1 +0 0 +1 1 +1 1 +SELECT f4 < 0 AS a, +f8 < 0 AS b +FROM t2; +a b +1 1 +1 1 +0 0 +0 0 +0 0 +execute s3 using @fv, @fv; +a b +1 1 +1 1 +0 0 +0 0 +0 0 +SELECT f4 < '0' AS a, +f8 < '0' AS b +FROM t2; +a b +1 1 +1 1 +0 0 +0 0 +0 0 +execute s3 using @sv, @sv; +a b +1 1 +1 1 +0 0 +0 0 +0 0 +SELECT f4 >= 0 AS a, +f8 >= 0 AS b +FROM t2; +a b +0 0 +0 0 +1 1 +1 1 +1 1 +execute s4 using @fv, @fv; +a b +0 0 +0 0 +1 1 +1 1 +1 1 +SELECT f4 >= '0' AS a, +f8 >= '0' AS b +FROM t2; +a b +0 0 +0 0 +1 1 +1 1 +1 1 +execute s4 using @sv, @sv; +a b +0 0 +0 0 +1 1 +1 1 +1 1 +SELECT f4 <= 0 AS a, +f8 <= 0 AS b +FROM t2; +a b +1 1 +1 1 +1 1 +0 0 +0 0 +execute s5 using @fv, @fv; +a b +1 1 +1 1 +1 1 +0 0 +0 0 +SELECT f4 <= '0' AS a, +f8 <= '0' AS b +FROM t2; +a b +1 1 +1 1 +1 1 +0 0 +0 0 +execute s5 using @sv, @sv; +a b +1 1 +1 1 +1 1 +0 0 +0 0 +SELECT f4 > 0 AS a, +f8 > 0 AS b +FROM t2; +a b +0 0 +0 0 +0 0 +1 1 +1 1 +execute s6 using @fv, @fv; +a b +0 0 +0 0 +0 0 +1 1 +1 1 +SELECT f4 > '0' AS a, +f8 > '0' AS b +FROM t2; +a b +0 0 +0 0 +0 0 +1 1 +1 1 +execute s6 using @sv, @sv; +a b +0 0 +0 0 +0 0 +1 1 +1 1 +set @fv= 2.225073858507201383e-308; +set @sv= "2.225073858507201383e-308"; +SELECT f4 = 2.225073858507201383e-308 AS a, +f8 = 2.225073858507201383e-308 AS b +FROM t2; +a b +0 0 +0 0 +0 0 +0 1 +0 0 +execute s1 using @fv, @fv; +a b +0 0 +0 0 +0 0 +0 1 +0 0 +SELECT f4 = '2.225073858507201383e-308' AS a, +f8 = '2.225073858507201383e-308' AS b +FROM t2; +a b +0 0 +0 0 +0 0 +0 1 +0 0 +execute s1 using @sv, @sv; +a b +0 0 +0 0 +0 0 +0 1 +0 0 +SELECT f4 <> 2.225073858507201383e-308 AS a, +f8 <> 2.225073858507201383e-308 AS b +FROM t2; +a b +1 1 +1 1 +1 1 +1 0 +1 1 +execute s2 using @fv, @fv; +a b +1 1 +1 1 +1 1 +1 0 +1 1 +SELECT f4 <> '2.225073858507201383e-308' AS a, +f8 <> '2.225073858507201383e-308' AS b +FROM t2; +a b +1 1 +1 1 +1 1 +1 0 +1 1 +execute s2 using @sv, @sv; +a b +1 1 +1 1 +1 1 +1 0 +1 1 +SELECT f4 < 2.225073858507201383e-308 AS a, +f8 < 2.225073858507201383e-308 AS b +FROM t2; +a b +1 1 +1 1 +1 1 +0 0 +0 0 +execute s3 using @fv, @fv; +a b +1 1 +1 1 +1 1 +0 0 +0 0 +SELECT f4 < '2.225073858507201383e-308' AS a, +f8 < '2.225073858507201383e-308' AS b +FROM t2; +a b +1 1 +1 1 +1 1 +0 0 +0 0 +execute s3 using @sv, @sv; +a b +1 1 +1 1 +1 1 +0 0 +0 0 +SELECT f4 >= 2.225073858507201383e-308 AS a, +f8 >= 2.225073858507201383e-308 AS b +FROM t2; +a b +0 0 +0 0 +0 0 +1 1 +1 1 +execute s4 using @fv, @fv; +a b +0 0 +0 0 +0 0 +1 1 +1 1 +SELECT f4 >= '2.225073858507201383e-308' AS a, +f8 >= '2.225073858507201383e-308' AS b +FROM t2; +a b +0 0 +0 0 +0 0 +1 1 +1 1 +execute s4 using @sv, @sv; +a b +0 0 +0 0 +0 0 +1 1 +1 1 +SELECT f4 <= 2.225073858507201383e-308 AS a, +f8 <= 2.225073858507201383e-308 AS b +FROM t2; +a b +1 1 +1 1 +1 1 +0 1 +0 0 +execute s5 using @fv, @fv; +a b +1 1 +1 1 +1 1 +0 1 +0 0 +SELECT f4 <= '2.225073858507201383e-308' AS a, +f8 <= '2.225073858507201383e-308' AS b +FROM t2; +a b +1 1 +1 1 +1 1 +0 1 +0 0 +execute s5 using @sv, @sv; +a b +1 1 +1 1 +1 1 +0 1 +0 0 +SELECT f4 > 2.225073858507201383e-308 AS a, +f8 > 2.225073858507201383e-308 AS b +FROM t2; +a b +0 0 +0 0 +0 0 +1 0 +1 1 +execute s6 using @fv, @fv; +a b +0 0 +0 0 +0 0 +1 0 +1 1 +SELECT f4 > '2.225073858507201383e-308' AS a, +f8 > '2.225073858507201383e-308' AS b +FROM t2; +a b +0 0 +0 0 +0 0 +1 0 +1 1 +execute s6 using @sv, @sv; +a b +0 0 +0 0 +0 0 +1 0 +1 1 +set @fv= 1.17549435e-38; +set @sv= "1.17549435e-38"; +SELECT f4 = 1.17549435e-38 AS a, +f8 = 1.17549435e-38 AS b +FROM t2; +a b +0 0 +0 0 +0 0 +0 0 +0 0 +execute s1 using @fv, @fv; +a b +0 0 +0 0 +0 0 +0 0 +0 0 +SELECT f4 = '1.17549435e-38' AS a, +f8 = '1.17549435e-38' AS b +FROM t2; +a b +0 0 +0 0 +0 0 +0 0 +0 0 +execute s1 using @sv, @sv; +a b +0 0 +0 0 +0 0 +0 0 +0 0 +SELECT f4 <> 1.17549435e-38 AS a, +f8 <> 1.17549435e-38 AS b +FROM t2; +a b +1 1 +1 1 +1 1 +1 1 +1 1 +execute s2 using @fv, @fv; +a b +1 1 +1 1 +1 1 +1 1 +1 1 +SELECT f4 <> '1.17549435e-38' AS a, +f8 <> '1.17549435e-38' AS b +FROM t2; +a b +1 1 +1 1 +1 1 +1 1 +1 1 +execute s2 using @sv, @sv; +a b +1 1 +1 1 +1 1 +1 1 +1 1 +SELECT f4 < 1.17549435e-38 AS a, +f8 < 1.17549435e-38 AS b +FROM t2; +a b +1 1 +1 1 +1 1 +1 1 +0 0 +execute s3 using @fv, @fv; +a b +1 1 +1 1 +1 1 +1 1 +0 0 +SELECT f4 < '1.17549435e-38' AS a, +f8 < '1.17549435e-38' AS b +FROM t2; +a b +1 1 +1 1 +1 1 +1 1 +0 0 +execute s3 using @sv, @sv; +a b +1 1 +1 1 +1 1 +1 1 +0 0 +SELECT f4 >= 1.17549435e-38 AS a, +f8 >= 1.17549435e-38 AS b +FROM t2; +a b +0 0 +0 0 +0 0 +0 0 +1 1 +execute s4 using @fv, @fv; +a b +0 0 +0 0 +0 0 +0 0 +1 1 +SELECT f4 >= '1.17549435e-38' AS a, +f8 >= '1.17549435e-38' AS b +FROM t2; +a b +0 0 +0 0 +0 0 +0 0 +1 1 +execute s4 using @sv, @sv; +a b +0 0 +0 0 +0 0 +0 0 +1 1 +SELECT f4 <= 1.17549435e-38 AS a, +f8 <= 1.17549435e-38 AS b +FROM t2; +a b +1 1 +1 1 +1 1 +1 1 +0 0 +execute s5 using @fv, @fv; +a b +1 1 +1 1 +1 1 +1 1 +0 0 +SELECT f4 <= '1.17549435e-38' AS a, +f8 <= '1.17549435e-38' AS b +FROM t2; +a b +1 1 +1 1 +1 1 +1 1 +0 0 +execute s5 using @sv, @sv; +a b +1 1 +1 1 +1 1 +1 1 +0 0 +SELECT f4 > 1.17549435e-38 AS a, +f8 > 1.17549435e-38 AS b +FROM t2; +a b +0 0 +0 0 +0 0 +0 0 +1 1 +execute s6 using @fv, @fv; +a b +0 0 +0 0 +0 0 +0 0 +1 1 +SELECT f4 > '1.17549435e-38' AS a, +f8 > '1.17549435e-38' AS b +FROM t2; +a b +0 0 +0 0 +0 0 +0 0 +1 1 +execute s6 using @sv, @sv; +a b +0 0 +0 0 +0 0 +0 0 +1 1 +set @fv= 3.40282347e+38; +set @sv= "3.40282347e+38"; +SELECT f4 = 3.40282347e+38 AS a, +f8 = 3.40282347e+38 AS b +FROM t2; +a b +0 0 +0 0 +0 0 +0 0 +0 0 +execute s1 using @fv, @fv; +a b +0 0 +0 0 +0 0 +0 0 +0 0 +SELECT f4 = '3.40282347e+38' AS a, +f8 = '3.40282347e+38' AS b +FROM t2; +a b +0 0 +0 0 +0 0 +0 0 +0 0 +execute s1 using @sv, @sv; +a b +0 0 +0 0 +0 0 +0 0 +0 0 +SELECT f4 <> 3.40282347e+38 AS a, +f8 <> 3.40282347e+38 AS b +FROM t2; +a b +1 1 +1 1 +1 1 +1 1 +1 1 +execute s2 using @fv, @fv; +a b +1 1 +1 1 +1 1 +1 1 +1 1 +SELECT f4 <> '3.40282347e+38' AS a, +f8 <> '3.40282347e+38' AS b +FROM t2; +a b +1 1 +1 1 +1 1 +1 1 +1 1 +execute s2 using @sv, @sv; +a b +1 1 +1 1 +1 1 +1 1 +1 1 +SELECT f4 < 3.40282347e+38 AS a, +f8 < 3.40282347e+38 AS b +FROM t2; +a b +1 1 +1 1 +1 1 +1 1 +1 0 +execute s3 using @fv, @fv; +a b +1 1 +1 1 +1 1 +1 1 +1 0 +SELECT f4 < '3.40282347e+38' AS a, +f8 < '3.40282347e+38' AS b +FROM t2; +a b +1 1 +1 1 +1 1 +1 1 +1 0 +execute s3 using @sv, @sv; +a b +1 1 +1 1 +1 1 +1 1 +1 0 +SELECT f4 >= 3.40282347e+38 AS a, +f8 >= 3.40282347e+38 AS b +FROM t2; +a b +0 0 +0 0 +0 0 +0 0 +0 1 +execute s4 using @fv, @fv; +a b +0 0 +0 0 +0 0 +0 0 +0 1 +SELECT f4 >= '3.40282347e+38' AS a, +f8 >= '3.40282347e+38' AS b +FROM t2; +a b +0 0 +0 0 +0 0 +0 0 +0 1 +execute s4 using @sv, @sv; +a b +0 0 +0 0 +0 0 +0 0 +0 1 +SELECT f4 <= 3.40282347e+38 AS a, +f8 <= 3.40282347e+38 AS b +FROM t2; +a b +1 1 +1 1 +1 1 +1 1 +1 0 +execute s5 using @fv, @fv; +a b +1 1 +1 1 +1 1 +1 1 +1 0 +SELECT f4 <= '3.40282347e+38' AS a, +f8 <= '3.40282347e+38' AS b +FROM t2; +a b +1 1 +1 1 +1 1 +1 1 +1 0 +execute s5 using @sv, @sv; +a b +1 1 +1 1 +1 1 +1 1 +1 0 +SELECT f4 > 3.40282347e+38 AS a, +f8 > 3.40282347e+38 AS b +FROM t2; +a b +0 0 +0 0 +0 0 +0 0 +0 1 +execute s6 using @fv, @fv; +a b +0 0 +0 0 +0 0 +0 0 +0 1 +SELECT f4 > '3.40282347e+38' AS a, +f8 > '3.40282347e+38' AS b +FROM t2; +a b +0 0 +0 0 +0 0 +0 0 +0 1 +execute s6 using @sv, @sv; +a b +0 0 +0 0 +0 0 +0 0 +0 1 +set @fv= 1.797693134862315708e+308; +set @sv= "1.797693134862315708e+308"; +SELECT f4 = 1.797693134862315708e+308 AS a, +f8 = 1.797693134862315708e+308 AS b +FROM t2; +a b +0 0 +0 0 +0 0 +0 0 +0 1 +execute s1 using @fv, @fv; +a b +0 0 +0 0 +0 0 +0 0 +0 1 +SELECT f4 = '1.797693134862315708e+308' AS a, +f8 = '1.797693134862315708e+308' AS b +FROM t2; +a b +0 0 +0 0 +0 0 +0 0 +0 1 +execute s1 using @sv, @sv; +a b +0 0 +0 0 +0 0 +0 0 +0 1 +SELECT f4 <> 1.797693134862315708e+308 AS a, +f8 <> 1.797693134862315708e+308 AS b +FROM t2; +a b +1 1 +1 1 +1 1 +1 1 +1 0 +execute s2 using @fv, @fv; +a b +1 1 +1 1 +1 1 +1 1 +1 0 +SELECT f4 <> '1.797693134862315708e+308' AS a, +f8 <> '1.797693134862315708e+308' AS b +FROM t2; +a b +1 1 +1 1 +1 1 +1 1 +1 0 +execute s2 using @sv, @sv; +a b +1 1 +1 1 +1 1 +1 1 +1 0 +SELECT f4 < 1.797693134862315708e+308 AS a, +f8 < 1.797693134862315708e+308 AS b +FROM t2; +a b +1 1 +1 1 +1 1 +1 1 +1 0 +execute s3 using @fv, @fv; +a b +1 1 +1 1 +1 1 +1 1 +1 0 +SELECT f4 < '1.797693134862315708e+308' AS a, +f8 < '1.797693134862315708e+308' AS b +FROM t2; +a b +1 1 +1 1 +1 1 +1 1 +1 0 +execute s3 using @sv, @sv; +a b +1 1 +1 1 +1 1 +1 1 +1 0 +SELECT f4 >= 1.797693134862315708e+308 AS a, +f8 >= 1.797693134862315708e+308 AS b +FROM t2; +a b +0 0 +0 0 +0 0 +0 0 +0 1 +execute s4 using @fv, @fv; +a b +0 0 +0 0 +0 0 +0 0 +0 1 +SELECT f4 >= '1.797693134862315708e+308' AS a, +f8 >= '1.797693134862315708e+308' AS b +FROM t2; +a b +0 0 +0 0 +0 0 +0 0 +0 1 +execute s4 using @sv, @sv; +a b +0 0 +0 0 +0 0 +0 0 +0 1 +SELECT f4 <= 1.797693134862315708e+308 AS a, +f8 <= 1.797693134862315708e+308 AS b +FROM t2; +a b +1 1 +1 1 +1 1 +1 1 +1 1 +execute s5 using @fv, @fv; +a b +1 1 +1 1 +1 1 +1 1 +1 1 +SELECT f4 <= '1.797693134862315708e+308' AS a, +f8 <= '1.797693134862315708e+308' AS b +FROM t2; +a b +1 1 +1 1 +1 1 +1 1 +1 1 +execute s5 using @sv, @sv; +a b +1 1 +1 1 +1 1 +1 1 +1 1 +SELECT f4 > 1.797693134862315708e+308 AS a, +f8 > 1.797693134862315708e+308 AS b +FROM t2; +a b +0 0 +0 0 +0 0 +0 0 +0 0 +execute s6 using @fv, @fv; +a b +0 0 +0 0 +0 0 +0 0 +0 0 +SELECT f4 > '1.797693134862315708e+308' AS a, +f8 > '1.797693134862315708e+308' AS b +FROM t2; +a b +0 0 +0 0 +0 0 +0 0 +0 0 +execute s6 using @sv, @sv; +a b +0 0 +0 0 +0 0 +0 0 +0 0 +DEALLOCATE PREPARE s1; +DEALLOCATE PREPARE s2; +DEALLOCATE PREPARE s3; +DEALLOCATE PREPARE s4; +DEALLOCATE PREPARE s5; +DEALLOCATE PREPARE s6; +DROP TABLE t2; +CREATE TABLE t3 +(pk INTEGER PRIMARY KEY, +dc1 DECIMAL(12, 4), +dc2 DECIMAL(30, 30), +dc3 DECIMAL(65, 0), +dc4 DECIMAL(65, 30)); +INSERT INTO t3 VALUES +(0, -99999999.9999, -.999999999999999999999999999999, +-99999999999999999999999999999999999999999999999999999999999999999, +-99999999999999999999999999999999999.999999999999999999999999999999), +(1, 0, 0, 0, 0), +(2, 99999999.9999, .999999999999999999999999999999, +99999999999999999999999999999999999999999999999999999999999999999, +99999999999999999999999999999999999.999999999999999999999999999999); +set @dv= -100000000000000000000000000000000000000000000000000000000000000000; +set @sv= "-100000000000000000000000000000000000000000000000000000000000000000"; +SELECT dc1 = -100000000000000000000000000000000000000000000000000000000000000000 AS a, +dc2 = -100000000000000000000000000000000000000000000000000000000000000000 AS b, +dc3 = -100000000000000000000000000000000000000000000000000000000000000000 AS c, +dc4 = -100000000000000000000000000000000000000000000000000000000000000000 AS d +FROM t3; +a b c d +0 0 0 0 +0 0 0 0 +0 0 0 0 +execute s1 using @dv, @dv, @dv, @dv; +a b c d +0 0 0 0 +0 0 0 0 +0 0 0 0 +SELECT dc1 = '-100000000000000000000000000000000000000000000000000000000000000000' AS a, +dc2 = '-100000000000000000000000000000000000000000000000000000000000000000' AS b, +dc3 = '-100000000000000000000000000000000000000000000000000000000000000000' AS c, +dc4 = '-100000000000000000000000000000000000000000000000000000000000000000' AS d +FROM t3; +a b c d +0 0 0 0 +0 0 0 0 +0 0 0 0 +execute s1 using @sv, @sv, @sv, @sv; +a b c d +0 0 0 0 +0 0 0 0 +0 0 0 0 +SELECT dc1 <> -100000000000000000000000000000000000000000000000000000000000000000 AS a, +dc2 <> -100000000000000000000000000000000000000000000000000000000000000000 AS b, +dc3 <> -100000000000000000000000000000000000000000000000000000000000000000 AS c, +dc4 <> -100000000000000000000000000000000000000000000000000000000000000000 AS d +FROM t3; +a b c d +1 1 1 1 +1 1 1 1 +1 1 1 1 +execute s2 using @dv, @dv, @dv, @dv; +a b c d +1 1 1 1 +1 1 1 1 +1 1 1 1 +SELECT dc1 <> '-100000000000000000000000000000000000000000000000000000000000000000' AS a, +dc2 <> '-100000000000000000000000000000000000000000000000000000000000000000' AS b, +dc3 <> '-100000000000000000000000000000000000000000000000000000000000000000' AS c, +dc4 <> '-100000000000000000000000000000000000000000000000000000000000000000' AS d +FROM t3; +a b c d +1 1 1 1 +1 1 1 1 +1 1 1 1 +execute s2 using @sv, @sv, @sv, @sv; +a b c d +1 1 1 1 +1 1 1 1 +1 1 1 1 +SELECT dc1 < -100000000000000000000000000000000000000000000000000000000000000000 AS a, +dc2 < -100000000000000000000000000000000000000000000000000000000000000000 AS b, +dc3 < -100000000000000000000000000000000000000000000000000000000000000000 AS c, +dc4 < -100000000000000000000000000000000000000000000000000000000000000000 AS d +FROM t3; +a b c d +0 0 0 0 +0 0 0 0 +0 0 0 0 +execute s3 using @dv, @dv, @dv, @dv; +a b c d +0 0 0 0 +0 0 0 0 +0 0 0 0 +SELECT dc1 < '-100000000000000000000000000000000000000000000000000000000000000000' AS a, +dc2 < '-100000000000000000000000000000000000000000000000000000000000000000' AS b, +dc3 < '-100000000000000000000000000000000000000000000000000000000000000000' AS c, +dc4 < '-100000000000000000000000000000000000000000000000000000000000000000' AS d +FROM t3; +a b c d +0 0 0 0 +0 0 0 0 +0 0 0 0 +execute s3 using @sv, @sv, @sv, @sv; +a b c d +0 0 0 0 +0 0 0 0 +0 0 0 0 +SELECT dc1 >= -100000000000000000000000000000000000000000000000000000000000000000 AS a, +dc2 >= -100000000000000000000000000000000000000000000000000000000000000000 AS b, +dc3 >= -100000000000000000000000000000000000000000000000000000000000000000 AS c, +dc4 >= -100000000000000000000000000000000000000000000000000000000000000000 AS d +FROM t3; +a b c d +1 1 1 1 +1 1 1 1 +1 1 1 1 +execute s4 using @dv, @dv, @dv, @dv; +a b c d +1 1 1 1 +1 1 1 1 +1 1 1 1 +SELECT dc1 >= '-100000000000000000000000000000000000000000000000000000000000000000' AS a, +dc2 >= '-100000000000000000000000000000000000000000000000000000000000000000' AS b, +dc3 >= '-100000000000000000000000000000000000000000000000000000000000000000' AS c, +dc4 >= '-100000000000000000000000000000000000000000000000000000000000000000' AS d +FROM t3; +a b c d +1 1 1 1 +1 1 1 1 +1 1 1 1 +execute s4 using @sv, @sv, @sv, @sv; +a b c d +1 1 1 1 +1 1 1 1 +1 1 1 1 +SELECT dc1 <= -100000000000000000000000000000000000000000000000000000000000000000 AS a, +dc2 <= -100000000000000000000000000000000000000000000000000000000000000000 AS b, +dc3 <= -100000000000000000000000000000000000000000000000000000000000000000 AS c, +dc4 <= -100000000000000000000000000000000000000000000000000000000000000000 AS d +FROM t3; +a b c d +0 0 0 0 +0 0 0 0 +0 0 0 0 +execute s5 using @dv, @dv, @dv, @dv; +a b c d +0 0 0 0 +0 0 0 0 +0 0 0 0 +SELECT dc1 <= '-100000000000000000000000000000000000000000000000000000000000000000' AS a, +dc2 <= '-100000000000000000000000000000000000000000000000000000000000000000' AS b, +dc3 <= '-100000000000000000000000000000000000000000000000000000000000000000' AS c, +dc4 <= '-100000000000000000000000000000000000000000000000000000000000000000' AS d +FROM t3; +a b c d +0 0 0 0 +0 0 0 0 +0 0 0 0 +execute s5 using @sv, @sv, @sv, @sv; +a b c d +0 0 0 0 +0 0 0 0 +0 0 0 0 +SELECT dc1 > -100000000000000000000000000000000000000000000000000000000000000000 AS a, +dc2 > -100000000000000000000000000000000000000000000000000000000000000000 AS b, +dc3 > -100000000000000000000000000000000000000000000000000000000000000000 AS c, +dc4 > -100000000000000000000000000000000000000000000000000000000000000000 AS d +FROM t3; +a b c d +1 1 1 1 +1 1 1 1 +1 1 1 1 +execute s6 using @dv, @dv, @dv, @dv; +a b c d +1 1 1 1 +1 1 1 1 +1 1 1 1 +SELECT dc1 > '-100000000000000000000000000000000000000000000000000000000000000000' AS a, +dc2 > '-100000000000000000000000000000000000000000000000000000000000000000' AS b, +dc3 > '-100000000000000000000000000000000000000000000000000000000000000000' AS c, +dc4 > '-100000000000000000000000000000000000000000000000000000000000000000' AS d +FROM t3; +a b c d +1 1 1 1 +1 1 1 1 +1 1 1 1 +execute s6 using @sv, @sv, @sv, @sv; +a b c d +1 1 1 1 +1 1 1 1 +1 1 1 1 +set @dv= -99999999999999999999999999999999999999999999999999999999999999999; +set @sv= "-99999999999999999999999999999999999999999999999999999999999999999"; +SELECT dc1 = -99999999999999999999999999999999999999999999999999999999999999999 AS a, +dc2 = -99999999999999999999999999999999999999999999999999999999999999999 AS b, +dc3 = -99999999999999999999999999999999999999999999999999999999999999999 AS c, +dc4 = -99999999999999999999999999999999999999999999999999999999999999999 AS d +FROM t3; +a b c d +0 0 1 0 +0 0 0 0 +0 0 0 0 +execute s1 using @dv, @dv, @dv, @dv; +a b c d +0 0 1 0 +0 0 0 0 +0 0 0 0 +SELECT dc1 = '-99999999999999999999999999999999999999999999999999999999999999999' AS a, +dc2 = '-99999999999999999999999999999999999999999999999999999999999999999' AS b, +dc3 = '-99999999999999999999999999999999999999999999999999999999999999999' AS c, +dc4 = '-99999999999999999999999999999999999999999999999999999999999999999' AS d +FROM t3; +a b c d +0 0 1 0 +0 0 0 0 +0 0 0 0 +execute s1 using @sv, @sv, @sv, @sv; +a b c d +0 0 1 0 +0 0 0 0 +0 0 0 0 +SELECT dc1 <> -99999999999999999999999999999999999999999999999999999999999999999 AS a, +dc2 <> -99999999999999999999999999999999999999999999999999999999999999999 AS b, +dc3 <> -99999999999999999999999999999999999999999999999999999999999999999 AS c, +dc4 <> -99999999999999999999999999999999999999999999999999999999999999999 AS d +FROM t3; +a b c d +1 1 0 1 +1 1 1 1 +1 1 1 1 +execute s2 using @dv, @dv, @dv, @dv; +a b c d +1 1 0 1 +1 1 1 1 +1 1 1 1 +SELECT dc1 <> '-99999999999999999999999999999999999999999999999999999999999999999' AS a, +dc2 <> '-99999999999999999999999999999999999999999999999999999999999999999' AS b, +dc3 <> '-99999999999999999999999999999999999999999999999999999999999999999' AS c, +dc4 <> '-99999999999999999999999999999999999999999999999999999999999999999' AS d +FROM t3; +a b c d +1 1 0 1 +1 1 1 1 +1 1 1 1 +execute s2 using @sv, @sv, @sv, @sv; +a b c d +1 1 0 1 +1 1 1 1 +1 1 1 1 +SELECT dc1 < -99999999999999999999999999999999999999999999999999999999999999999 AS a, +dc2 < -99999999999999999999999999999999999999999999999999999999999999999 AS b, +dc3 < -99999999999999999999999999999999999999999999999999999999999999999 AS c, +dc4 < -99999999999999999999999999999999999999999999999999999999999999999 AS d +FROM t3; +a b c d +0 0 0 0 +0 0 0 0 +0 0 0 0 +execute s3 using @dv, @dv, @dv, @dv; +a b c d +0 0 0 0 +0 0 0 0 +0 0 0 0 +SELECT dc1 < '-99999999999999999999999999999999999999999999999999999999999999999' AS a, +dc2 < '-99999999999999999999999999999999999999999999999999999999999999999' AS b, +dc3 < '-99999999999999999999999999999999999999999999999999999999999999999' AS c, +dc4 < '-99999999999999999999999999999999999999999999999999999999999999999' AS d +FROM t3; +a b c d +0 0 0 0 +0 0 0 0 +0 0 0 0 +execute s3 using @sv, @sv, @sv, @sv; +a b c d +0 0 0 0 +0 0 0 0 +0 0 0 0 +SELECT dc1 >= -99999999999999999999999999999999999999999999999999999999999999999 AS a, +dc2 >= -99999999999999999999999999999999999999999999999999999999999999999 AS b, +dc3 >= -99999999999999999999999999999999999999999999999999999999999999999 AS c, +dc4 >= -99999999999999999999999999999999999999999999999999999999999999999 AS d +FROM t3; +a b c d +1 1 1 1 +1 1 1 1 +1 1 1 1 +execute s4 using @dv, @dv, @dv, @dv; +a b c d +1 1 1 1 +1 1 1 1 +1 1 1 1 +SELECT dc1 >= '-99999999999999999999999999999999999999999999999999999999999999999' AS a, +dc2 >= '-99999999999999999999999999999999999999999999999999999999999999999' AS b, +dc3 >= '-99999999999999999999999999999999999999999999999999999999999999999' AS c, +dc4 >= '-99999999999999999999999999999999999999999999999999999999999999999' AS d +FROM t3; +a b c d +1 1 1 1 +1 1 1 1 +1 1 1 1 +execute s4 using @sv, @sv, @sv, @sv; +a b c d +1 1 1 1 +1 1 1 1 +1 1 1 1 +SELECT dc1 <= -99999999999999999999999999999999999999999999999999999999999999999 AS a, +dc2 <= -99999999999999999999999999999999999999999999999999999999999999999 AS b, +dc3 <= -99999999999999999999999999999999999999999999999999999999999999999 AS c, +dc4 <= -99999999999999999999999999999999999999999999999999999999999999999 AS d +FROM t3; +a b c d +0 0 1 0 +0 0 0 0 +0 0 0 0 +execute s5 using @dv, @dv, @dv, @dv; +a b c d +0 0 1 0 +0 0 0 0 +0 0 0 0 +SELECT dc1 <= '-99999999999999999999999999999999999999999999999999999999999999999' AS a, +dc2 <= '-99999999999999999999999999999999999999999999999999999999999999999' AS b, +dc3 <= '-99999999999999999999999999999999999999999999999999999999999999999' AS c, +dc4 <= '-99999999999999999999999999999999999999999999999999999999999999999' AS d +FROM t3; +a b c d +0 0 1 0 +0 0 0 0 +0 0 0 0 +execute s5 using @sv, @sv, @sv, @sv; +a b c d +0 0 1 0 +0 0 0 0 +0 0 0 0 +SELECT dc1 > -99999999999999999999999999999999999999999999999999999999999999999 AS a, +dc2 > -99999999999999999999999999999999999999999999999999999999999999999 AS b, +dc3 > -99999999999999999999999999999999999999999999999999999999999999999 AS c, +dc4 > -99999999999999999999999999999999999999999999999999999999999999999 AS d +FROM t3; +a b c d +1 1 0 1 +1 1 1 1 +1 1 1 1 +execute s6 using @dv, @dv, @dv, @dv; +a b c d +1 1 0 1 +1 1 1 1 +1 1 1 1 +SELECT dc1 > '-99999999999999999999999999999999999999999999999999999999999999999' AS a, +dc2 > '-99999999999999999999999999999999999999999999999999999999999999999' AS b, +dc3 > '-99999999999999999999999999999999999999999999999999999999999999999' AS c, +dc4 > '-99999999999999999999999999999999999999999999999999999999999999999' AS d +FROM t3; +a b c d +1 1 0 1 +1 1 1 1 +1 1 1 1 +execute s6 using @sv, @sv, @sv, @sv; +a b c d +1 1 0 1 +1 1 1 1 +1 1 1 1 +set @dv= -99999999999999999999999999999999999.999999999999999999999999999999; +set @sv= "-99999999999999999999999999999999999.999999999999999999999999999999"; +SELECT dc1 = -99999999999999999999999999999999999.999999999999999999999999999999 AS a, +dc2 = -99999999999999999999999999999999999.999999999999999999999999999999 AS b, +dc3 = -99999999999999999999999999999999999.999999999999999999999999999999 AS c, +dc4 = -99999999999999999999999999999999999.999999999999999999999999999999 AS d +FROM t3; +a b c d +0 0 0 1 +0 0 0 0 +0 0 0 0 +execute s1 using @dv, @dv, @dv, @dv; +a b c d +0 0 0 1 +0 0 0 0 +0 0 0 0 +SELECT dc1 = '-99999999999999999999999999999999999.999999999999999999999999999999' AS a, +dc2 = '-99999999999999999999999999999999999.999999999999999999999999999999' AS b, +dc3 = '-99999999999999999999999999999999999.999999999999999999999999999999' AS c, +dc4 = '-99999999999999999999999999999999999.999999999999999999999999999999' AS d +FROM t3; +a b c d +0 0 0 1 +0 0 0 0 +0 0 0 0 +execute s1 using @sv, @sv, @sv, @sv; +a b c d +0 0 0 1 +0 0 0 0 +0 0 0 0 +SELECT dc1 <> -99999999999999999999999999999999999.999999999999999999999999999999 AS a, +dc2 <> -99999999999999999999999999999999999.999999999999999999999999999999 AS b, +dc3 <> -99999999999999999999999999999999999.999999999999999999999999999999 AS c, +dc4 <> -99999999999999999999999999999999999.999999999999999999999999999999 AS d +FROM t3; +a b c d +1 1 1 0 +1 1 1 1 +1 1 1 1 +execute s2 using @dv, @dv, @dv, @dv; +a b c d +1 1 1 0 +1 1 1 1 +1 1 1 1 +SELECT dc1 <> '-99999999999999999999999999999999999.999999999999999999999999999999' AS a, +dc2 <> '-99999999999999999999999999999999999.999999999999999999999999999999' AS b, +dc3 <> '-99999999999999999999999999999999999.999999999999999999999999999999' AS c, +dc4 <> '-99999999999999999999999999999999999.999999999999999999999999999999' AS d +FROM t3; +a b c d +1 1 1 0 +1 1 1 1 +1 1 1 1 +execute s2 using @sv, @sv, @sv, @sv; +a b c d +1 1 1 0 +1 1 1 1 +1 1 1 1 +SELECT dc1 < -99999999999999999999999999999999999.999999999999999999999999999999 AS a, +dc2 < -99999999999999999999999999999999999.999999999999999999999999999999 AS b, +dc3 < -99999999999999999999999999999999999.999999999999999999999999999999 AS c, +dc4 < -99999999999999999999999999999999999.999999999999999999999999999999 AS d +FROM t3; +a b c d +0 0 1 0 +0 0 0 0 +0 0 0 0 +execute s3 using @dv, @dv, @dv, @dv; +a b c d +0 0 1 0 +0 0 0 0 +0 0 0 0 +SELECT dc1 < '-99999999999999999999999999999999999.999999999999999999999999999999' AS a, +dc2 < '-99999999999999999999999999999999999.999999999999999999999999999999' AS b, +dc3 < '-99999999999999999999999999999999999.999999999999999999999999999999' AS c, +dc4 < '-99999999999999999999999999999999999.999999999999999999999999999999' AS d +FROM t3; +a b c d +0 0 1 0 +0 0 0 0 +0 0 0 0 +execute s3 using @sv, @sv, @sv, @sv; +a b c d +0 0 1 0 +0 0 0 0 +0 0 0 0 +SELECT dc1 >= -99999999999999999999999999999999999.999999999999999999999999999999 AS a, +dc2 >= -99999999999999999999999999999999999.999999999999999999999999999999 AS b, +dc3 >= -99999999999999999999999999999999999.999999999999999999999999999999 AS c, +dc4 >= -99999999999999999999999999999999999.999999999999999999999999999999 AS d +FROM t3; +a b c d +1 1 0 1 +1 1 1 1 +1 1 1 1 +execute s4 using @dv, @dv, @dv, @dv; +a b c d +1 1 0 1 +1 1 1 1 +1 1 1 1 +SELECT dc1 >= '-99999999999999999999999999999999999.999999999999999999999999999999' AS a, +dc2 >= '-99999999999999999999999999999999999.999999999999999999999999999999' AS b, +dc3 >= '-99999999999999999999999999999999999.999999999999999999999999999999' AS c, +dc4 >= '-99999999999999999999999999999999999.999999999999999999999999999999' AS d +FROM t3; +a b c d +1 1 0 1 +1 1 1 1 +1 1 1 1 +execute s4 using @sv, @sv, @sv, @sv; +a b c d +1 1 0 1 +1 1 1 1 +1 1 1 1 +SELECT dc1 <= -99999999999999999999999999999999999.999999999999999999999999999999 AS a, +dc2 <= -99999999999999999999999999999999999.999999999999999999999999999999 AS b, +dc3 <= -99999999999999999999999999999999999.999999999999999999999999999999 AS c, +dc4 <= -99999999999999999999999999999999999.999999999999999999999999999999 AS d +FROM t3; +a b c d +0 0 1 1 +0 0 0 0 +0 0 0 0 +execute s5 using @dv, @dv, @dv, @dv; +a b c d +0 0 1 1 +0 0 0 0 +0 0 0 0 +SELECT dc1 <= '-99999999999999999999999999999999999.999999999999999999999999999999' AS a, +dc2 <= '-99999999999999999999999999999999999.999999999999999999999999999999' AS b, +dc3 <= '-99999999999999999999999999999999999.999999999999999999999999999999' AS c, +dc4 <= '-99999999999999999999999999999999999.999999999999999999999999999999' AS d +FROM t3; +a b c d +0 0 1 1 +0 0 0 0 +0 0 0 0 +execute s5 using @sv, @sv, @sv, @sv; +a b c d +0 0 1 1 +0 0 0 0 +0 0 0 0 +SELECT dc1 > -99999999999999999999999999999999999.999999999999999999999999999999 AS a, +dc2 > -99999999999999999999999999999999999.999999999999999999999999999999 AS b, +dc3 > -99999999999999999999999999999999999.999999999999999999999999999999 AS c, +dc4 > -99999999999999999999999999999999999.999999999999999999999999999999 AS d +FROM t3; +a b c d +1 1 0 0 +1 1 1 1 +1 1 1 1 +execute s6 using @dv, @dv, @dv, @dv; +a b c d +1 1 0 0 +1 1 1 1 +1 1 1 1 +SELECT dc1 > '-99999999999999999999999999999999999.999999999999999999999999999999' AS a, +dc2 > '-99999999999999999999999999999999999.999999999999999999999999999999' AS b, +dc3 > '-99999999999999999999999999999999999.999999999999999999999999999999' AS c, +dc4 > '-99999999999999999999999999999999999.999999999999999999999999999999' AS d +FROM t3; +a b c d +1 1 0 0 +1 1 1 1 +1 1 1 1 +execute s6 using @sv, @sv, @sv, @sv; +a b c d +1 1 0 0 +1 1 1 1 +1 1 1 1 +set @dv= -99999999.9999; +set @sv= "-99999999.9999"; +SELECT dc1 = -99999999.9999 AS a, +dc2 = -99999999.9999 AS b, +dc3 = -99999999.9999 AS c, +dc4 = -99999999.9999 AS d +FROM t3; +a b c d +1 0 0 0 +0 0 0 0 +0 0 0 0 +execute s1 using @dv, @dv, @dv, @dv; +a b c d +1 0 0 0 +0 0 0 0 +0 0 0 0 +SELECT dc1 = '-99999999.9999' AS a, +dc2 = '-99999999.9999' AS b, +dc3 = '-99999999.9999' AS c, +dc4 = '-99999999.9999' AS d +FROM t3; +a b c d +1 0 0 0 +0 0 0 0 +0 0 0 0 +execute s1 using @sv, @sv, @sv, @sv; +a b c d +1 0 0 0 +0 0 0 0 +0 0 0 0 +SELECT dc1 <> -99999999.9999 AS a, +dc2 <> -99999999.9999 AS b, +dc3 <> -99999999.9999 AS c, +dc4 <> -99999999.9999 AS d +FROM t3; +a b c d +0 1 1 1 +1 1 1 1 +1 1 1 1 +execute s2 using @dv, @dv, @dv, @dv; +a b c d +0 1 1 1 +1 1 1 1 +1 1 1 1 +SELECT dc1 <> '-99999999.9999' AS a, +dc2 <> '-99999999.9999' AS b, +dc3 <> '-99999999.9999' AS c, +dc4 <> '-99999999.9999' AS d +FROM t3; +a b c d +0 1 1 1 +1 1 1 1 +1 1 1 1 +execute s2 using @sv, @sv, @sv, @sv; +a b c d +0 1 1 1 +1 1 1 1 +1 1 1 1 +SELECT dc1 < -99999999.9999 AS a, +dc2 < -99999999.9999 AS b, +dc3 < -99999999.9999 AS c, +dc4 < -99999999.9999 AS d +FROM t3; +a b c d +0 0 1 1 +0 0 0 0 +0 0 0 0 +execute s3 using @dv, @dv, @dv, @dv; +a b c d +0 0 1 1 +0 0 0 0 +0 0 0 0 +SELECT dc1 < '-99999999.9999' AS a, +dc2 < '-99999999.9999' AS b, +dc3 < '-99999999.9999' AS c, +dc4 < '-99999999.9999' AS d +FROM t3; +a b c d +0 0 1 1 +0 0 0 0 +0 0 0 0 +execute s3 using @sv, @sv, @sv, @sv; +a b c d +0 0 1 1 +0 0 0 0 +0 0 0 0 +SELECT dc1 >= -99999999.9999 AS a, +dc2 >= -99999999.9999 AS b, +dc3 >= -99999999.9999 AS c, +dc4 >= -99999999.9999 AS d +FROM t3; +a b c d +1 1 0 0 +1 1 1 1 +1 1 1 1 +execute s4 using @dv, @dv, @dv, @dv; +a b c d +1 1 0 0 +1 1 1 1 +1 1 1 1 +SELECT dc1 >= '-99999999.9999' AS a, +dc2 >= '-99999999.9999' AS b, +dc3 >= '-99999999.9999' AS c, +dc4 >= '-99999999.9999' AS d +FROM t3; +a b c d +1 1 0 0 +1 1 1 1 +1 1 1 1 +execute s4 using @sv, @sv, @sv, @sv; +a b c d +1 1 0 0 +1 1 1 1 +1 1 1 1 +SELECT dc1 <= -99999999.9999 AS a, +dc2 <= -99999999.9999 AS b, +dc3 <= -99999999.9999 AS c, +dc4 <= -99999999.9999 AS d +FROM t3; +a b c d +1 0 1 1 +0 0 0 0 +0 0 0 0 +execute s5 using @dv, @dv, @dv, @dv; +a b c d +1 0 1 1 +0 0 0 0 +0 0 0 0 +SELECT dc1 <= '-99999999.9999' AS a, +dc2 <= '-99999999.9999' AS b, +dc3 <= '-99999999.9999' AS c, +dc4 <= '-99999999.9999' AS d +FROM t3; +a b c d +1 0 1 1 +0 0 0 0 +0 0 0 0 +execute s5 using @sv, @sv, @sv, @sv; +a b c d +1 0 1 1 +0 0 0 0 +0 0 0 0 +SELECT dc1 > -99999999.9999 AS a, +dc2 > -99999999.9999 AS b, +dc3 > -99999999.9999 AS c, +dc4 > -99999999.9999 AS d +FROM t3; +a b c d +0 1 0 0 +1 1 1 1 +1 1 1 1 +execute s6 using @dv, @dv, @dv, @dv; +a b c d +0 1 0 0 +1 1 1 1 +1 1 1 1 +SELECT dc1 > '-99999999.9999' AS a, +dc2 > '-99999999.9999' AS b, +dc3 > '-99999999.9999' AS c, +dc4 > '-99999999.9999' AS d +FROM t3; +a b c d +0 1 0 0 +1 1 1 1 +1 1 1 1 +execute s6 using @sv, @sv, @sv, @sv; +a b c d +0 1 0 0 +1 1 1 1 +1 1 1 1 +set @dv= -.999999999999999999999999999999; +set @sv= "-.999999999999999999999999999999"; +SELECT dc1 = -.999999999999999999999999999999 AS a, +dc2 = -.999999999999999999999999999999 AS b, +dc3 = -.999999999999999999999999999999 AS c, +dc4 = -.999999999999999999999999999999 AS d +FROM t3; +a b c d +0 1 0 0 +0 0 0 0 +0 0 0 0 +execute s1 using @dv, @dv, @dv, @dv; +a b c d +0 1 0 0 +0 0 0 0 +0 0 0 0 +SELECT dc1 = '-.999999999999999999999999999999' AS a, +dc2 = '-.999999999999999999999999999999' AS b, +dc3 = '-.999999999999999999999999999999' AS c, +dc4 = '-.999999999999999999999999999999' AS d +FROM t3; +a b c d +0 1 0 0 +0 0 0 0 +0 0 0 0 +execute s1 using @sv, @sv, @sv, @sv; +a b c d +0 1 0 0 +0 0 0 0 +0 0 0 0 +SELECT dc1 <> -.999999999999999999999999999999 AS a, +dc2 <> -.999999999999999999999999999999 AS b, +dc3 <> -.999999999999999999999999999999 AS c, +dc4 <> -.999999999999999999999999999999 AS d +FROM t3; +a b c d +1 0 1 1 +1 1 1 1 +1 1 1 1 +execute s2 using @dv, @dv, @dv, @dv; +a b c d +1 0 1 1 +1 1 1 1 +1 1 1 1 +SELECT dc1 <> '-.999999999999999999999999999999' AS a, +dc2 <> '-.999999999999999999999999999999' AS b, +dc3 <> '-.999999999999999999999999999999' AS c, +dc4 <> '-.999999999999999999999999999999' AS d +FROM t3; +a b c d +1 0 1 1 +1 1 1 1 +1 1 1 1 +execute s2 using @sv, @sv, @sv, @sv; +a b c d +1 0 1 1 +1 1 1 1 +1 1 1 1 +SELECT dc1 < -.999999999999999999999999999999 AS a, +dc2 < -.999999999999999999999999999999 AS b, +dc3 < -.999999999999999999999999999999 AS c, +dc4 < -.999999999999999999999999999999 AS d +FROM t3; +a b c d +1 0 1 1 +0 0 0 0 +0 0 0 0 +execute s3 using @dv, @dv, @dv, @dv; +a b c d +1 0 1 1 +0 0 0 0 +0 0 0 0 +SELECT dc1 < '-.999999999999999999999999999999' AS a, +dc2 < '-.999999999999999999999999999999' AS b, +dc3 < '-.999999999999999999999999999999' AS c, +dc4 < '-.999999999999999999999999999999' AS d +FROM t3; +a b c d +1 0 1 1 +0 0 0 0 +0 0 0 0 +execute s3 using @sv, @sv, @sv, @sv; +a b c d +1 0 1 1 +0 0 0 0 +0 0 0 0 +SELECT dc1 >= -.999999999999999999999999999999 AS a, +dc2 >= -.999999999999999999999999999999 AS b, +dc3 >= -.999999999999999999999999999999 AS c, +dc4 >= -.999999999999999999999999999999 AS d +FROM t3; +a b c d +0 1 0 0 +1 1 1 1 +1 1 1 1 +execute s4 using @dv, @dv, @dv, @dv; +a b c d +0 1 0 0 +1 1 1 1 +1 1 1 1 +SELECT dc1 >= '-.999999999999999999999999999999' AS a, +dc2 >= '-.999999999999999999999999999999' AS b, +dc3 >= '-.999999999999999999999999999999' AS c, +dc4 >= '-.999999999999999999999999999999' AS d +FROM t3; +a b c d +0 1 0 0 +1 1 1 1 +1 1 1 1 +execute s4 using @sv, @sv, @sv, @sv; +a b c d +0 1 0 0 +1 1 1 1 +1 1 1 1 +SELECT dc1 <= -.999999999999999999999999999999 AS a, +dc2 <= -.999999999999999999999999999999 AS b, +dc3 <= -.999999999999999999999999999999 AS c, +dc4 <= -.999999999999999999999999999999 AS d +FROM t3; +a b c d +1 1 1 1 +0 0 0 0 +0 0 0 0 +execute s5 using @dv, @dv, @dv, @dv; +a b c d +1 1 1 1 +0 0 0 0 +0 0 0 0 +SELECT dc1 <= '-.999999999999999999999999999999' AS a, +dc2 <= '-.999999999999999999999999999999' AS b, +dc3 <= '-.999999999999999999999999999999' AS c, +dc4 <= '-.999999999999999999999999999999' AS d +FROM t3; +a b c d +1 1 1 1 +0 0 0 0 +0 0 0 0 +execute s5 using @sv, @sv, @sv, @sv; +a b c d +1 1 1 1 +0 0 0 0 +0 0 0 0 +SELECT dc1 > -.999999999999999999999999999999 AS a, +dc2 > -.999999999999999999999999999999 AS b, +dc3 > -.999999999999999999999999999999 AS c, +dc4 > -.999999999999999999999999999999 AS d +FROM t3; +a b c d +0 0 0 0 +1 1 1 1 +1 1 1 1 +execute s6 using @dv, @dv, @dv, @dv; +a b c d +0 0 0 0 +1 1 1 1 +1 1 1 1 +SELECT dc1 > '-.999999999999999999999999999999' AS a, +dc2 > '-.999999999999999999999999999999' AS b, +dc3 > '-.999999999999999999999999999999' AS c, +dc4 > '-.999999999999999999999999999999' AS d +FROM t3; +a b c d +0 0 0 0 +1 1 1 1 +1 1 1 1 +execute s6 using @sv, @sv, @sv, @sv; +a b c d +0 0 0 0 +1 1 1 1 +1 1 1 1 +set @dv= 0; +set @sv= "0"; +SELECT dc1 = 0 AS a, +dc2 = 0 AS b, +dc3 = 0 AS c, +dc4 = 0 AS d +FROM t3; +a b c d +0 0 0 0 +1 1 1 1 +0 0 0 0 +execute s1 using @dv, @dv, @dv, @dv; +a b c d +0 0 0 0 +1 1 1 1 +0 0 0 0 +SELECT dc1 = '0' AS a, +dc2 = '0' AS b, +dc3 = '0' AS c, +dc4 = '0' AS d +FROM t3; +a b c d +0 0 0 0 +1 1 1 1 +0 0 0 0 +execute s1 using @sv, @sv, @sv, @sv; +a b c d +0 0 0 0 +1 1 1 1 +0 0 0 0 +SELECT dc1 <> 0 AS a, +dc2 <> 0 AS b, +dc3 <> 0 AS c, +dc4 <> 0 AS d +FROM t3; +a b c d +1 1 1 1 +0 0 0 0 +1 1 1 1 +execute s2 using @dv, @dv, @dv, @dv; +a b c d +1 1 1 1 +0 0 0 0 +1 1 1 1 +SELECT dc1 <> '0' AS a, +dc2 <> '0' AS b, +dc3 <> '0' AS c, +dc4 <> '0' AS d +FROM t3; +a b c d +1 1 1 1 +0 0 0 0 +1 1 1 1 +execute s2 using @sv, @sv, @sv, @sv; +a b c d +1 1 1 1 +0 0 0 0 +1 1 1 1 +SELECT dc1 < 0 AS a, +dc2 < 0 AS b, +dc3 < 0 AS c, +dc4 < 0 AS d +FROM t3; +a b c d +1 1 1 1 +0 0 0 0 +0 0 0 0 +execute s3 using @dv, @dv, @dv, @dv; +a b c d +1 1 1 1 +0 0 0 0 +0 0 0 0 +SELECT dc1 < '0' AS a, +dc2 < '0' AS b, +dc3 < '0' AS c, +dc4 < '0' AS d +FROM t3; +a b c d +1 1 1 1 +0 0 0 0 +0 0 0 0 +execute s3 using @sv, @sv, @sv, @sv; +a b c d +1 1 1 1 +0 0 0 0 +0 0 0 0 +SELECT dc1 >= 0 AS a, +dc2 >= 0 AS b, +dc3 >= 0 AS c, +dc4 >= 0 AS d +FROM t3; +a b c d +0 0 0 0 +1 1 1 1 +1 1 1 1 +execute s4 using @dv, @dv, @dv, @dv; +a b c d +0 0 0 0 +1 1 1 1 +1 1 1 1 +SELECT dc1 >= '0' AS a, +dc2 >= '0' AS b, +dc3 >= '0' AS c, +dc4 >= '0' AS d +FROM t3; +a b c d +0 0 0 0 +1 1 1 1 +1 1 1 1 +execute s4 using @sv, @sv, @sv, @sv; +a b c d +0 0 0 0 +1 1 1 1 +1 1 1 1 +SELECT dc1 <= 0 AS a, +dc2 <= 0 AS b, +dc3 <= 0 AS c, +dc4 <= 0 AS d +FROM t3; +a b c d +1 1 1 1 +1 1 1 1 +0 0 0 0 +execute s5 using @dv, @dv, @dv, @dv; +a b c d +1 1 1 1 +1 1 1 1 +0 0 0 0 +SELECT dc1 <= '0' AS a, +dc2 <= '0' AS b, +dc3 <= '0' AS c, +dc4 <= '0' AS d +FROM t3; +a b c d +1 1 1 1 +1 1 1 1 +0 0 0 0 +execute s5 using @sv, @sv, @sv, @sv; +a b c d +1 1 1 1 +1 1 1 1 +0 0 0 0 +SELECT dc1 > 0 AS a, +dc2 > 0 AS b, +dc3 > 0 AS c, +dc4 > 0 AS d +FROM t3; +a b c d +0 0 0 0 +0 0 0 0 +1 1 1 1 +execute s6 using @dv, @dv, @dv, @dv; +a b c d +0 0 0 0 +0 0 0 0 +1 1 1 1 +SELECT dc1 > '0' AS a, +dc2 > '0' AS b, +dc3 > '0' AS c, +dc4 > '0' AS d +FROM t3; +a b c d +0 0 0 0 +0 0 0 0 +1 1 1 1 +execute s6 using @sv, @sv, @sv, @sv; +a b c d +0 0 0 0 +0 0 0 0 +1 1 1 1 +set @dv= .999999999999999999999999999999; +set @sv= ".999999999999999999999999999999"; +SELECT dc1 = .999999999999999999999999999999 AS a, +dc2 = .999999999999999999999999999999 AS b, +dc3 = .999999999999999999999999999999 AS c, +dc4 = .999999999999999999999999999999 AS d +FROM t3; +a b c d +0 0 0 0 +0 0 0 0 +0 1 0 0 +execute s1 using @dv, @dv, @dv, @dv; +a b c d +0 0 0 0 +0 0 0 0 +0 1 0 0 +SELECT dc1 = '.999999999999999999999999999999' AS a, +dc2 = '.999999999999999999999999999999' AS b, +dc3 = '.999999999999999999999999999999' AS c, +dc4 = '.999999999999999999999999999999' AS d +FROM t3; +a b c d +0 0 0 0 +0 0 0 0 +0 1 0 0 +execute s1 using @sv, @sv, @sv, @sv; +a b c d +0 0 0 0 +0 0 0 0 +0 1 0 0 +SELECT dc1 <> .999999999999999999999999999999 AS a, +dc2 <> .999999999999999999999999999999 AS b, +dc3 <> .999999999999999999999999999999 AS c, +dc4 <> .999999999999999999999999999999 AS d +FROM t3; +a b c d +1 1 1 1 +1 1 1 1 +1 0 1 1 +execute s2 using @dv, @dv, @dv, @dv; +a b c d +1 1 1 1 +1 1 1 1 +1 0 1 1 +SELECT dc1 <> '.999999999999999999999999999999' AS a, +dc2 <> '.999999999999999999999999999999' AS b, +dc3 <> '.999999999999999999999999999999' AS c, +dc4 <> '.999999999999999999999999999999' AS d +FROM t3; +a b c d +1 1 1 1 +1 1 1 1 +1 0 1 1 +execute s2 using @sv, @sv, @sv, @sv; +a b c d +1 1 1 1 +1 1 1 1 +1 0 1 1 +SELECT dc1 < .999999999999999999999999999999 AS a, +dc2 < .999999999999999999999999999999 AS b, +dc3 < .999999999999999999999999999999 AS c, +dc4 < .999999999999999999999999999999 AS d +FROM t3; +a b c d +1 1 1 1 +1 1 1 1 +0 0 0 0 +execute s3 using @dv, @dv, @dv, @dv; +a b c d +1 1 1 1 +1 1 1 1 +0 0 0 0 +SELECT dc1 < '.999999999999999999999999999999' AS a, +dc2 < '.999999999999999999999999999999' AS b, +dc3 < '.999999999999999999999999999999' AS c, +dc4 < '.999999999999999999999999999999' AS d +FROM t3; +a b c d +1 1 1 1 +1 1 1 1 +0 0 0 0 +execute s3 using @sv, @sv, @sv, @sv; +a b c d +1 1 1 1 +1 1 1 1 +0 0 0 0 +SELECT dc1 >= .999999999999999999999999999999 AS a, +dc2 >= .999999999999999999999999999999 AS b, +dc3 >= .999999999999999999999999999999 AS c, +dc4 >= .999999999999999999999999999999 AS d +FROM t3; +a b c d +0 0 0 0 +0 0 0 0 +1 1 1 1 +execute s4 using @dv, @dv, @dv, @dv; +a b c d +0 0 0 0 +0 0 0 0 +1 1 1 1 +SELECT dc1 >= '.999999999999999999999999999999' AS a, +dc2 >= '.999999999999999999999999999999' AS b, +dc3 >= '.999999999999999999999999999999' AS c, +dc4 >= '.999999999999999999999999999999' AS d +FROM t3; +a b c d +0 0 0 0 +0 0 0 0 +1 1 1 1 +execute s4 using @sv, @sv, @sv, @sv; +a b c d +0 0 0 0 +0 0 0 0 +1 1 1 1 +SELECT dc1 <= .999999999999999999999999999999 AS a, +dc2 <= .999999999999999999999999999999 AS b, +dc3 <= .999999999999999999999999999999 AS c, +dc4 <= .999999999999999999999999999999 AS d +FROM t3; +a b c d +1 1 1 1 +1 1 1 1 +0 1 0 0 +execute s5 using @dv, @dv, @dv, @dv; +a b c d +1 1 1 1 +1 1 1 1 +0 1 0 0 +SELECT dc1 <= '.999999999999999999999999999999' AS a, +dc2 <= '.999999999999999999999999999999' AS b, +dc3 <= '.999999999999999999999999999999' AS c, +dc4 <= '.999999999999999999999999999999' AS d +FROM t3; +a b c d +1 1 1 1 +1 1 1 1 +0 1 0 0 +execute s5 using @sv, @sv, @sv, @sv; +a b c d +1 1 1 1 +1 1 1 1 +0 1 0 0 +SELECT dc1 > .999999999999999999999999999999 AS a, +dc2 > .999999999999999999999999999999 AS b, +dc3 > .999999999999999999999999999999 AS c, +dc4 > .999999999999999999999999999999 AS d +FROM t3; +a b c d +0 0 0 0 +0 0 0 0 +1 0 1 1 +execute s6 using @dv, @dv, @dv, @dv; +a b c d +0 0 0 0 +0 0 0 0 +1 0 1 1 +SELECT dc1 > '.999999999999999999999999999999' AS a, +dc2 > '.999999999999999999999999999999' AS b, +dc3 > '.999999999999999999999999999999' AS c, +dc4 > '.999999999999999999999999999999' AS d +FROM t3; +a b c d +0 0 0 0 +0 0 0 0 +1 0 1 1 +execute s6 using @sv, @sv, @sv, @sv; +a b c d +0 0 0 0 +0 0 0 0 +1 0 1 1 +set @dv= 99999999.9999; +set @sv= "99999999.9999"; +SELECT dc1 = 99999999.9999 AS a, +dc2 = 99999999.9999 AS b, +dc3 = 99999999.9999 AS c, +dc4 = 99999999.9999 AS d +FROM t3; +a b c d +0 0 0 0 +0 0 0 0 +1 0 0 0 +execute s1 using @dv, @dv, @dv, @dv; +a b c d +0 0 0 0 +0 0 0 0 +1 0 0 0 +SELECT dc1 = '99999999.9999' AS a, +dc2 = '99999999.9999' AS b, +dc3 = '99999999.9999' AS c, +dc4 = '99999999.9999' AS d +FROM t3; +a b c d +0 0 0 0 +0 0 0 0 +1 0 0 0 +execute s1 using @sv, @sv, @sv, @sv; +a b c d +0 0 0 0 +0 0 0 0 +1 0 0 0 +SELECT dc1 <> 99999999.9999 AS a, +dc2 <> 99999999.9999 AS b, +dc3 <> 99999999.9999 AS c, +dc4 <> 99999999.9999 AS d +FROM t3; +a b c d +1 1 1 1 +1 1 1 1 +0 1 1 1 +execute s2 using @dv, @dv, @dv, @dv; +a b c d +1 1 1 1 +1 1 1 1 +0 1 1 1 +SELECT dc1 <> '99999999.9999' AS a, +dc2 <> '99999999.9999' AS b, +dc3 <> '99999999.9999' AS c, +dc4 <> '99999999.9999' AS d +FROM t3; +a b c d +1 1 1 1 +1 1 1 1 +0 1 1 1 +execute s2 using @sv, @sv, @sv, @sv; +a b c d +1 1 1 1 +1 1 1 1 +0 1 1 1 +SELECT dc1 < 99999999.9999 AS a, +dc2 < 99999999.9999 AS b, +dc3 < 99999999.9999 AS c, +dc4 < 99999999.9999 AS d +FROM t3; +a b c d +1 1 1 1 +1 1 1 1 +0 1 0 0 +execute s3 using @dv, @dv, @dv, @dv; +a b c d +1 1 1 1 +1 1 1 1 +0 1 0 0 +SELECT dc1 < '99999999.9999' AS a, +dc2 < '99999999.9999' AS b, +dc3 < '99999999.9999' AS c, +dc4 < '99999999.9999' AS d +FROM t3; +a b c d +1 1 1 1 +1 1 1 1 +0 1 0 0 +execute s3 using @sv, @sv, @sv, @sv; +a b c d +1 1 1 1 +1 1 1 1 +0 1 0 0 +SELECT dc1 >= 99999999.9999 AS a, +dc2 >= 99999999.9999 AS b, +dc3 >= 99999999.9999 AS c, +dc4 >= 99999999.9999 AS d +FROM t3; +a b c d +0 0 0 0 +0 0 0 0 +1 0 1 1 +execute s4 using @dv, @dv, @dv, @dv; +a b c d +0 0 0 0 +0 0 0 0 +1 0 1 1 +SELECT dc1 >= '99999999.9999' AS a, +dc2 >= '99999999.9999' AS b, +dc3 >= '99999999.9999' AS c, +dc4 >= '99999999.9999' AS d +FROM t3; +a b c d +0 0 0 0 +0 0 0 0 +1 0 1 1 +execute s4 using @sv, @sv, @sv, @sv; +a b c d +0 0 0 0 +0 0 0 0 +1 0 1 1 +SELECT dc1 <= 99999999.9999 AS a, +dc2 <= 99999999.9999 AS b, +dc3 <= 99999999.9999 AS c, +dc4 <= 99999999.9999 AS d +FROM t3; +a b c d +1 1 1 1 +1 1 1 1 +1 1 0 0 +execute s5 using @dv, @dv, @dv, @dv; +a b c d +1 1 1 1 +1 1 1 1 +1 1 0 0 +SELECT dc1 <= '99999999.9999' AS a, +dc2 <= '99999999.9999' AS b, +dc3 <= '99999999.9999' AS c, +dc4 <= '99999999.9999' AS d +FROM t3; +a b c d +1 1 1 1 +1 1 1 1 +1 1 0 0 +execute s5 using @sv, @sv, @sv, @sv; +a b c d +1 1 1 1 +1 1 1 1 +1 1 0 0 +SELECT dc1 > 99999999.9999 AS a, +dc2 > 99999999.9999 AS b, +dc3 > 99999999.9999 AS c, +dc4 > 99999999.9999 AS d +FROM t3; +a b c d +0 0 0 0 +0 0 0 0 +0 0 1 1 +execute s6 using @dv, @dv, @dv, @dv; +a b c d +0 0 0 0 +0 0 0 0 +0 0 1 1 +SELECT dc1 > '99999999.9999' AS a, +dc2 > '99999999.9999' AS b, +dc3 > '99999999.9999' AS c, +dc4 > '99999999.9999' AS d +FROM t3; +a b c d +0 0 0 0 +0 0 0 0 +0 0 1 1 +execute s6 using @sv, @sv, @sv, @sv; +a b c d +0 0 0 0 +0 0 0 0 +0 0 1 1 +set @dv= 99999999999999999999999999999999999.999999999999999999999999999999; +set @sv= "99999999999999999999999999999999999.999999999999999999999999999999"; +SELECT dc1 = 99999999999999999999999999999999999.999999999999999999999999999999 AS a, +dc2 = 99999999999999999999999999999999999.999999999999999999999999999999 AS b, +dc3 = 99999999999999999999999999999999999.999999999999999999999999999999 AS c, +dc4 = 99999999999999999999999999999999999.999999999999999999999999999999 AS d +FROM t3; +a b c d +0 0 0 0 +0 0 0 0 +0 0 0 1 +execute s1 using @dv, @dv, @dv, @dv; +a b c d +0 0 0 0 +0 0 0 0 +0 0 0 1 +SELECT dc1 = '99999999999999999999999999999999999.999999999999999999999999999999' AS a, +dc2 = '99999999999999999999999999999999999.999999999999999999999999999999' AS b, +dc3 = '99999999999999999999999999999999999.999999999999999999999999999999' AS c, +dc4 = '99999999999999999999999999999999999.999999999999999999999999999999' AS d +FROM t3; +a b c d +0 0 0 0 +0 0 0 0 +0 0 0 1 +execute s1 using @sv, @sv, @sv, @sv; +a b c d +0 0 0 0 +0 0 0 0 +0 0 0 1 +SELECT dc1 <> 99999999999999999999999999999999999.999999999999999999999999999999 AS a, +dc2 <> 99999999999999999999999999999999999.999999999999999999999999999999 AS b, +dc3 <> 99999999999999999999999999999999999.999999999999999999999999999999 AS c, +dc4 <> 99999999999999999999999999999999999.999999999999999999999999999999 AS d +FROM t3; +a b c d +1 1 1 1 +1 1 1 1 +1 1 1 0 +execute s2 using @dv, @dv, @dv, @dv; +a b c d +1 1 1 1 +1 1 1 1 +1 1 1 0 +SELECT dc1 <> '99999999999999999999999999999999999.999999999999999999999999999999' AS a, +dc2 <> '99999999999999999999999999999999999.999999999999999999999999999999' AS b, +dc3 <> '99999999999999999999999999999999999.999999999999999999999999999999' AS c, +dc4 <> '99999999999999999999999999999999999.999999999999999999999999999999' AS d +FROM t3; +a b c d +1 1 1 1 +1 1 1 1 +1 1 1 0 +execute s2 using @sv, @sv, @sv, @sv; +a b c d +1 1 1 1 +1 1 1 1 +1 1 1 0 +SELECT dc1 < 99999999999999999999999999999999999.999999999999999999999999999999 AS a, +dc2 < 99999999999999999999999999999999999.999999999999999999999999999999 AS b, +dc3 < 99999999999999999999999999999999999.999999999999999999999999999999 AS c, +dc4 < 99999999999999999999999999999999999.999999999999999999999999999999 AS d +FROM t3; +a b c d +1 1 1 1 +1 1 1 1 +1 1 0 0 +execute s3 using @dv, @dv, @dv, @dv; +a b c d +1 1 1 1 +1 1 1 1 +1 1 0 0 +SELECT dc1 < '99999999999999999999999999999999999.999999999999999999999999999999' AS a, +dc2 < '99999999999999999999999999999999999.999999999999999999999999999999' AS b, +dc3 < '99999999999999999999999999999999999.999999999999999999999999999999' AS c, +dc4 < '99999999999999999999999999999999999.999999999999999999999999999999' AS d +FROM t3; +a b c d +1 1 1 1 +1 1 1 1 +1 1 0 0 +execute s3 using @sv, @sv, @sv, @sv; +a b c d +1 1 1 1 +1 1 1 1 +1 1 0 0 +SELECT dc1 >= 99999999999999999999999999999999999.999999999999999999999999999999 AS a, +dc2 >= 99999999999999999999999999999999999.999999999999999999999999999999 AS b, +dc3 >= 99999999999999999999999999999999999.999999999999999999999999999999 AS c, +dc4 >= 99999999999999999999999999999999999.999999999999999999999999999999 AS d +FROM t3; +a b c d +0 0 0 0 +0 0 0 0 +0 0 1 1 +execute s4 using @dv, @dv, @dv, @dv; +a b c d +0 0 0 0 +0 0 0 0 +0 0 1 1 +SELECT dc1 >= '99999999999999999999999999999999999.999999999999999999999999999999' AS a, +dc2 >= '99999999999999999999999999999999999.999999999999999999999999999999' AS b, +dc3 >= '99999999999999999999999999999999999.999999999999999999999999999999' AS c, +dc4 >= '99999999999999999999999999999999999.999999999999999999999999999999' AS d +FROM t3; +a b c d +0 0 0 0 +0 0 0 0 +0 0 1 1 +execute s4 using @sv, @sv, @sv, @sv; +a b c d +0 0 0 0 +0 0 0 0 +0 0 1 1 +SELECT dc1 <= 99999999999999999999999999999999999.999999999999999999999999999999 AS a, +dc2 <= 99999999999999999999999999999999999.999999999999999999999999999999 AS b, +dc3 <= 99999999999999999999999999999999999.999999999999999999999999999999 AS c, +dc4 <= 99999999999999999999999999999999999.999999999999999999999999999999 AS d +FROM t3; +a b c d +1 1 1 1 +1 1 1 1 +1 1 0 1 +execute s5 using @dv, @dv, @dv, @dv; +a b c d +1 1 1 1 +1 1 1 1 +1 1 0 1 +SELECT dc1 <= '99999999999999999999999999999999999.999999999999999999999999999999' AS a, +dc2 <= '99999999999999999999999999999999999.999999999999999999999999999999' AS b, +dc3 <= '99999999999999999999999999999999999.999999999999999999999999999999' AS c, +dc4 <= '99999999999999999999999999999999999.999999999999999999999999999999' AS d +FROM t3; +a b c d +1 1 1 1 +1 1 1 1 +1 1 0 1 +execute s5 using @sv, @sv, @sv, @sv; +a b c d +1 1 1 1 +1 1 1 1 +1 1 0 1 +SELECT dc1 > 99999999999999999999999999999999999.999999999999999999999999999999 AS a, +dc2 > 99999999999999999999999999999999999.999999999999999999999999999999 AS b, +dc3 > 99999999999999999999999999999999999.999999999999999999999999999999 AS c, +dc4 > 99999999999999999999999999999999999.999999999999999999999999999999 AS d +FROM t3; +a b c d +0 0 0 0 +0 0 0 0 +0 0 1 0 +execute s6 using @dv, @dv, @dv, @dv; +a b c d +0 0 0 0 +0 0 0 0 +0 0 1 0 +SELECT dc1 > '99999999999999999999999999999999999.999999999999999999999999999999' AS a, +dc2 > '99999999999999999999999999999999999.999999999999999999999999999999' AS b, +dc3 > '99999999999999999999999999999999999.999999999999999999999999999999' AS c, +dc4 > '99999999999999999999999999999999999.999999999999999999999999999999' AS d +FROM t3; +a b c d +0 0 0 0 +0 0 0 0 +0 0 1 0 +execute s6 using @sv, @sv, @sv, @sv; +a b c d +0 0 0 0 +0 0 0 0 +0 0 1 0 +set @dv= 99999999999999999999999999999999999999999999999999999999999999999; +set @sv= "99999999999999999999999999999999999999999999999999999999999999999"; +SELECT dc1 = 99999999999999999999999999999999999999999999999999999999999999999 AS a, +dc2 = 99999999999999999999999999999999999999999999999999999999999999999 AS b, +dc3 = 99999999999999999999999999999999999999999999999999999999999999999 AS c, +dc4 = 99999999999999999999999999999999999999999999999999999999999999999 AS d +FROM t3; +a b c d +0 0 0 0 +0 0 0 0 +0 0 1 0 +execute s1 using @dv, @dv, @dv, @dv; +a b c d +0 0 0 0 +0 0 0 0 +0 0 1 0 +SELECT dc1 = '99999999999999999999999999999999999999999999999999999999999999999' AS a, +dc2 = '99999999999999999999999999999999999999999999999999999999999999999' AS b, +dc3 = '99999999999999999999999999999999999999999999999999999999999999999' AS c, +dc4 = '99999999999999999999999999999999999999999999999999999999999999999' AS d +FROM t3; +a b c d +0 0 0 0 +0 0 0 0 +0 0 1 0 +execute s1 using @sv, @sv, @sv, @sv; +a b c d +0 0 0 0 +0 0 0 0 +0 0 1 0 +SELECT dc1 <> 99999999999999999999999999999999999999999999999999999999999999999 AS a, +dc2 <> 99999999999999999999999999999999999999999999999999999999999999999 AS b, +dc3 <> 99999999999999999999999999999999999999999999999999999999999999999 AS c, +dc4 <> 99999999999999999999999999999999999999999999999999999999999999999 AS d +FROM t3; +a b c d +1 1 1 1 +1 1 1 1 +1 1 0 1 +execute s2 using @dv, @dv, @dv, @dv; +a b c d +1 1 1 1 +1 1 1 1 +1 1 0 1 +SELECT dc1 <> '99999999999999999999999999999999999999999999999999999999999999999' AS a, +dc2 <> '99999999999999999999999999999999999999999999999999999999999999999' AS b, +dc3 <> '99999999999999999999999999999999999999999999999999999999999999999' AS c, +dc4 <> '99999999999999999999999999999999999999999999999999999999999999999' AS d +FROM t3; +a b c d +1 1 1 1 +1 1 1 1 +1 1 0 1 +execute s2 using @sv, @sv, @sv, @sv; +a b c d +1 1 1 1 +1 1 1 1 +1 1 0 1 +SELECT dc1 < 99999999999999999999999999999999999999999999999999999999999999999 AS a, +dc2 < 99999999999999999999999999999999999999999999999999999999999999999 AS b, +dc3 < 99999999999999999999999999999999999999999999999999999999999999999 AS c, +dc4 < 99999999999999999999999999999999999999999999999999999999999999999 AS d +FROM t3; +a b c d +1 1 1 1 +1 1 1 1 +1 1 0 1 +execute s3 using @dv, @dv, @dv, @dv; +a b c d +1 1 1 1 +1 1 1 1 +1 1 0 1 +SELECT dc1 < '99999999999999999999999999999999999999999999999999999999999999999' AS a, +dc2 < '99999999999999999999999999999999999999999999999999999999999999999' AS b, +dc3 < '99999999999999999999999999999999999999999999999999999999999999999' AS c, +dc4 < '99999999999999999999999999999999999999999999999999999999999999999' AS d +FROM t3; +a b c d +1 1 1 1 +1 1 1 1 +1 1 0 1 +execute s3 using @sv, @sv, @sv, @sv; +a b c d +1 1 1 1 +1 1 1 1 +1 1 0 1 +SELECT dc1 >= 99999999999999999999999999999999999999999999999999999999999999999 AS a, +dc2 >= 99999999999999999999999999999999999999999999999999999999999999999 AS b, +dc3 >= 99999999999999999999999999999999999999999999999999999999999999999 AS c, +dc4 >= 99999999999999999999999999999999999999999999999999999999999999999 AS d +FROM t3; +a b c d +0 0 0 0 +0 0 0 0 +0 0 1 0 +execute s4 using @dv, @dv, @dv, @dv; +a b c d +0 0 0 0 +0 0 0 0 +0 0 1 0 +SELECT dc1 >= '99999999999999999999999999999999999999999999999999999999999999999' AS a, +dc2 >= '99999999999999999999999999999999999999999999999999999999999999999' AS b, +dc3 >= '99999999999999999999999999999999999999999999999999999999999999999' AS c, +dc4 >= '99999999999999999999999999999999999999999999999999999999999999999' AS d +FROM t3; +a b c d +0 0 0 0 +0 0 0 0 +0 0 1 0 +execute s4 using @sv, @sv, @sv, @sv; +a b c d +0 0 0 0 +0 0 0 0 +0 0 1 0 +SELECT dc1 <= 99999999999999999999999999999999999999999999999999999999999999999 AS a, +dc2 <= 99999999999999999999999999999999999999999999999999999999999999999 AS b, +dc3 <= 99999999999999999999999999999999999999999999999999999999999999999 AS c, +dc4 <= 99999999999999999999999999999999999999999999999999999999999999999 AS d +FROM t3; +a b c d +1 1 1 1 +1 1 1 1 +1 1 1 1 +execute s5 using @dv, @dv, @dv, @dv; +a b c d +1 1 1 1 +1 1 1 1 +1 1 1 1 +SELECT dc1 <= '99999999999999999999999999999999999999999999999999999999999999999' AS a, +dc2 <= '99999999999999999999999999999999999999999999999999999999999999999' AS b, +dc3 <= '99999999999999999999999999999999999999999999999999999999999999999' AS c, +dc4 <= '99999999999999999999999999999999999999999999999999999999999999999' AS d +FROM t3; +a b c d +1 1 1 1 +1 1 1 1 +1 1 1 1 +execute s5 using @sv, @sv, @sv, @sv; +a b c d +1 1 1 1 +1 1 1 1 +1 1 1 1 +SELECT dc1 > 99999999999999999999999999999999999999999999999999999999999999999 AS a, +dc2 > 99999999999999999999999999999999999999999999999999999999999999999 AS b, +dc3 > 99999999999999999999999999999999999999999999999999999999999999999 AS c, +dc4 > 99999999999999999999999999999999999999999999999999999999999999999 AS d +FROM t3; +a b c d +0 0 0 0 +0 0 0 0 +0 0 0 0 +execute s6 using @dv, @dv, @dv, @dv; +a b c d +0 0 0 0 +0 0 0 0 +0 0 0 0 +SELECT dc1 > '99999999999999999999999999999999999999999999999999999999999999999' AS a, +dc2 > '99999999999999999999999999999999999999999999999999999999999999999' AS b, +dc3 > '99999999999999999999999999999999999999999999999999999999999999999' AS c, +dc4 > '99999999999999999999999999999999999999999999999999999999999999999' AS d +FROM t3; +a b c d +0 0 0 0 +0 0 0 0 +0 0 0 0 +execute s6 using @sv, @sv, @sv, @sv; +a b c d +0 0 0 0 +0 0 0 0 +0 0 0 0 +set @dv= 100000000000000000000000000000000000000000000000000000000000000000; +set @sv= "100000000000000000000000000000000000000000000000000000000000000000"; +SELECT dc1 = 100000000000000000000000000000000000000000000000000000000000000000 AS a, +dc2 = 100000000000000000000000000000000000000000000000000000000000000000 AS b, +dc3 = 100000000000000000000000000000000000000000000000000000000000000000 AS c, +dc4 = 100000000000000000000000000000000000000000000000000000000000000000 AS d +FROM t3; +a b c d +0 0 0 0 +0 0 0 0 +0 0 0 0 +execute s1 using @dv, @dv, @dv, @dv; +a b c d +0 0 0 0 +0 0 0 0 +0 0 0 0 +SELECT dc1 = '100000000000000000000000000000000000000000000000000000000000000000' AS a, +dc2 = '100000000000000000000000000000000000000000000000000000000000000000' AS b, +dc3 = '100000000000000000000000000000000000000000000000000000000000000000' AS c, +dc4 = '100000000000000000000000000000000000000000000000000000000000000000' AS d +FROM t3; +a b c d +0 0 0 0 +0 0 0 0 +0 0 0 0 +execute s1 using @sv, @sv, @sv, @sv; +a b c d +0 0 0 0 +0 0 0 0 +0 0 0 0 +SELECT dc1 <> 100000000000000000000000000000000000000000000000000000000000000000 AS a, +dc2 <> 100000000000000000000000000000000000000000000000000000000000000000 AS b, +dc3 <> 100000000000000000000000000000000000000000000000000000000000000000 AS c, +dc4 <> 100000000000000000000000000000000000000000000000000000000000000000 AS d +FROM t3; +a b c d +1 1 1 1 +1 1 1 1 +1 1 1 1 +execute s2 using @dv, @dv, @dv, @dv; +a b c d +1 1 1 1 +1 1 1 1 +1 1 1 1 +SELECT dc1 <> '100000000000000000000000000000000000000000000000000000000000000000' AS a, +dc2 <> '100000000000000000000000000000000000000000000000000000000000000000' AS b, +dc3 <> '100000000000000000000000000000000000000000000000000000000000000000' AS c, +dc4 <> '100000000000000000000000000000000000000000000000000000000000000000' AS d +FROM t3; +a b c d +1 1 1 1 +1 1 1 1 +1 1 1 1 +execute s2 using @sv, @sv, @sv, @sv; +a b c d +1 1 1 1 +1 1 1 1 +1 1 1 1 +SELECT dc1 < 100000000000000000000000000000000000000000000000000000000000000000 AS a, +dc2 < 100000000000000000000000000000000000000000000000000000000000000000 AS b, +dc3 < 100000000000000000000000000000000000000000000000000000000000000000 AS c, +dc4 < 100000000000000000000000000000000000000000000000000000000000000000 AS d +FROM t3; +a b c d +1 1 1 1 +1 1 1 1 +1 1 1 1 +execute s3 using @dv, @dv, @dv, @dv; +a b c d +1 1 1 1 +1 1 1 1 +1 1 1 1 +SELECT dc1 < '100000000000000000000000000000000000000000000000000000000000000000' AS a, +dc2 < '100000000000000000000000000000000000000000000000000000000000000000' AS b, +dc3 < '100000000000000000000000000000000000000000000000000000000000000000' AS c, +dc4 < '100000000000000000000000000000000000000000000000000000000000000000' AS d +FROM t3; +a b c d +1 1 1 1 +1 1 1 1 +1 1 1 1 +execute s3 using @sv, @sv, @sv, @sv; +a b c d +1 1 1 1 +1 1 1 1 +1 1 1 1 +SELECT dc1 >= 100000000000000000000000000000000000000000000000000000000000000000 AS a, +dc2 >= 100000000000000000000000000000000000000000000000000000000000000000 AS b, +dc3 >= 100000000000000000000000000000000000000000000000000000000000000000 AS c, +dc4 >= 100000000000000000000000000000000000000000000000000000000000000000 AS d +FROM t3; +a b c d +0 0 0 0 +0 0 0 0 +0 0 0 0 +execute s4 using @dv, @dv, @dv, @dv; +a b c d +0 0 0 0 +0 0 0 0 +0 0 0 0 +SELECT dc1 >= '100000000000000000000000000000000000000000000000000000000000000000' AS a, +dc2 >= '100000000000000000000000000000000000000000000000000000000000000000' AS b, +dc3 >= '100000000000000000000000000000000000000000000000000000000000000000' AS c, +dc4 >= '100000000000000000000000000000000000000000000000000000000000000000' AS d +FROM t3; +a b c d +0 0 0 0 +0 0 0 0 +0 0 0 0 +execute s4 using @sv, @sv, @sv, @sv; +a b c d +0 0 0 0 +0 0 0 0 +0 0 0 0 +SELECT dc1 <= 100000000000000000000000000000000000000000000000000000000000000000 AS a, +dc2 <= 100000000000000000000000000000000000000000000000000000000000000000 AS b, +dc3 <= 100000000000000000000000000000000000000000000000000000000000000000 AS c, +dc4 <= 100000000000000000000000000000000000000000000000000000000000000000 AS d +FROM t3; +a b c d +1 1 1 1 +1 1 1 1 +1 1 1 1 +execute s5 using @dv, @dv, @dv, @dv; +a b c d +1 1 1 1 +1 1 1 1 +1 1 1 1 +SELECT dc1 <= '100000000000000000000000000000000000000000000000000000000000000000' AS a, +dc2 <= '100000000000000000000000000000000000000000000000000000000000000000' AS b, +dc3 <= '100000000000000000000000000000000000000000000000000000000000000000' AS c, +dc4 <= '100000000000000000000000000000000000000000000000000000000000000000' AS d +FROM t3; +a b c d +1 1 1 1 +1 1 1 1 +1 1 1 1 +execute s5 using @sv, @sv, @sv, @sv; +a b c d +1 1 1 1 +1 1 1 1 +1 1 1 1 +SELECT dc1 > 100000000000000000000000000000000000000000000000000000000000000000 AS a, +dc2 > 100000000000000000000000000000000000000000000000000000000000000000 AS b, +dc3 > 100000000000000000000000000000000000000000000000000000000000000000 AS c, +dc4 > 100000000000000000000000000000000000000000000000000000000000000000 AS d +FROM t3; +a b c d +0 0 0 0 +0 0 0 0 +0 0 0 0 +execute s6 using @dv, @dv, @dv, @dv; +a b c d +0 0 0 0 +0 0 0 0 +0 0 0 0 +SELECT dc1 > '100000000000000000000000000000000000000000000000000000000000000000' AS a, +dc2 > '100000000000000000000000000000000000000000000000000000000000000000' AS b, +dc3 > '100000000000000000000000000000000000000000000000000000000000000000' AS c, +dc4 > '100000000000000000000000000000000000000000000000000000000000000000' AS d +FROM t3; +a b c d +0 0 0 0 +0 0 0 0 +0 0 0 0 +execute s6 using @sv, @sv, @sv, @sv; +a b c d +0 0 0 0 +0 0 0 0 +0 0 0 0 +DEALLOCATE PREPARE s1; +DEALLOCATE PREPARE s2; +DEALLOCATE PREPARE s3; +DEALLOCATE PREPARE s4; +DEALLOCATE PREPARE s5; +DEALLOCATE PREPARE s6; +DROP TABLE t3; +CREATE TABLE t4 +(pk INTEGER PRIMARY KEY, +fc CHAR(12), +vc VARCHAR(12)); +INSERT INTO t4 VALUES +(0, "", ""); +set @sv= """"; +SELECT fc = "" AS a, +vc = "" AS b +FROM t4; +a b +1 1 +execute s1 using @sv, @sv; +a b +0 0 +SELECT fc <> "" AS a, +vc <> "" AS b +FROM t4; +a b +0 0 +execute s2 using @sv, @sv; +a b +1 1 +SELECT fc < "" AS a, +vc < "" AS b +FROM t4; +a b +0 0 +execute s3 using @sv, @sv; +a b +1 1 +SELECT fc >= "" AS a, +vc >= "" AS b +FROM t4; +a b +1 1 +execute s4 using @sv, @sv; +a b +0 0 +SELECT fc <= "" AS a, +vc <= "" AS b +FROM t4; +a b +1 1 +execute s5 using @sv, @sv; +a b +1 1 +SELECT fc > "" AS a, +vc > "" AS b +FROM t4; +a b +0 0 +execute s6 using @sv, @sv; +a b +0 0 +DEALLOCATE PREPARE s1; +DEALLOCATE PREPARE s2; +DEALLOCATE PREPARE s3; +DEALLOCATE PREPARE s4; +DEALLOCATE PREPARE s5; +DEALLOCATE PREPARE s6; +DROP TABLE t4; +CREATE TABLE t5 +(pk INTEGER PRIMARY KEY, +d DATE); +INSERT INTO t5 VALUES +(0, '0001-01-01'), (1, '2017-01-01'), (2, '9999-12-31'); +set @sv= "0001-01-01"; +set @iv= 00010101; +set @tsv= "0001-01-01 00:00:00.000000"; +set @tsn= 00010101000000.0; +SELECT d = '0001-01-01' AS a +FROM t5; +a +1 +0 +0 +execute s1 using @sv; +a +1 +0 +0 +SELECT d = 00010101 AS a +FROM t5; +a +0 +0 +0 +execute s1 using @iv; +a +0 +0 +0 +SELECT d = '0001-01-01 00:00:00.000000' AS a +FROM t5; +a +1 +0 +0 +execute s1 using @tsv; +a +1 +0 +0 +SELECT d = 00010101000000.0 AS a +FROM t5; +a +0 +0 +0 +execute s1 using @tsn; +a +0 +0 +0 +SELECT d <> '0001-01-01' AS a +FROM t5; +a +0 +1 +1 +execute s2 using @sv; +a +0 +1 +1 +SELECT d <> 00010101 AS a +FROM t5; +a +1 +1 +1 +execute s2 using @iv; +a +1 +1 +1 +SELECT d <> '0001-01-01 00:00:00.000000' AS a +FROM t5; +a +0 +1 +1 +execute s2 using @tsv; +a +0 +1 +1 +SELECT d <> 00010101000000.0 AS a +FROM t5; +a +1 +1 +1 +execute s2 using @tsn; +a +1 +1 +1 +SELECT d < '0001-01-01' AS a +FROM t5; +a +0 +0 +0 +execute s3 using @sv; +a +0 +0 +0 +SELECT d < 00010101 AS a +FROM t5; +a +1 +0 +0 +execute s3 using @iv; +a +1 +0 +0 +SELECT d < '0001-01-01 00:00:00.000000' AS a +FROM t5; +a +0 +0 +0 +execute s3 using @tsv; +a +0 +0 +0 +SELECT d < 00010101000000.0 AS a +FROM t5; +a +1 +0 +0 +execute s3 using @tsn; +a +1 +0 +0 +SELECT d >= '0001-01-01' AS a +FROM t5; +a +1 +1 +1 +execute s4 using @sv; +a +1 +1 +1 +SELECT d >= 00010101 AS a +FROM t5; +a +0 +1 +1 +execute s4 using @iv; +a +0 +1 +1 +SELECT d >= '0001-01-01 00:00:00.000000' AS a +FROM t5; +a +1 +1 +1 +execute s4 using @tsv; +a +1 +1 +1 +SELECT d >= 00010101000000.0 AS a +FROM t5; +a +0 +1 +1 +execute s4 using @tsn; +a +0 +1 +1 +SELECT d <= '0001-01-01' AS a +FROM t5; +a +1 +0 +0 +execute s5 using @sv; +a +1 +0 +0 +SELECT d <= 00010101 AS a +FROM t5; +a +1 +0 +0 +execute s5 using @iv; +a +1 +0 +0 +SELECT d <= '0001-01-01 00:00:00.000000' AS a +FROM t5; +a +1 +0 +0 +execute s5 using @tsv; +a +1 +0 +0 +SELECT d <= 00010101000000.0 AS a +FROM t5; +a +1 +0 +0 +execute s5 using @tsn; +a +1 +0 +0 +SELECT d > '0001-01-01' AS a +FROM t5; +a +0 +1 +1 +execute s6 using @sv; +a +0 +1 +1 +SELECT d > 00010101 AS a +FROM t5; +a +0 +1 +1 +execute s6 using @iv; +a +0 +1 +1 +SELECT d > '0001-01-01 00:00:00.000000' AS a +FROM t5; +a +0 +1 +1 +execute s6 using @tsv; +a +0 +1 +1 +SELECT d > 00010101000000.0 AS a +FROM t5; +a +0 +1 +1 +execute s6 using @tsn; +a +0 +1 +1 +set @sv= "2017-01-01"; +set @iv= 20170101; +set @tsv= "2017-01-01 00:00:00.000000"; +set @tsn= 20170101000000.0; +SELECT d = '2017-01-01' AS a +FROM t5; +a +0 +1 +0 +execute s1 using @sv; +a +0 +1 +0 +SELECT d = 20170101 AS a +FROM t5; +a +0 +1 +0 +execute s1 using @iv; +a +0 +1 +0 +SELECT d = '2017-01-01 00:00:00.000000' AS a +FROM t5; +a +0 +1 +0 +execute s1 using @tsv; +a +0 +1 +0 +SELECT d = 20170101000000.0 AS a +FROM t5; +a +0 +1 +0 +execute s1 using @tsn; +a +0 +1 +0 +SELECT d <> '2017-01-01' AS a +FROM t5; +a +1 +0 +1 +execute s2 using @sv; +a +1 +0 +1 +SELECT d <> 20170101 AS a +FROM t5; +a +1 +0 +1 +execute s2 using @iv; +a +1 +0 +1 +SELECT d <> '2017-01-01 00:00:00.000000' AS a +FROM t5; +a +1 +0 +1 +execute s2 using @tsv; +a +1 +0 +1 +SELECT d <> 20170101000000.0 AS a +FROM t5; +a +1 +0 +1 +execute s2 using @tsn; +a +1 +0 +1 +SELECT d < '2017-01-01' AS a +FROM t5; +a +1 +0 +0 +execute s3 using @sv; +a +1 +0 +0 +SELECT d < 20170101 AS a +FROM t5; +a +1 +0 +0 +execute s3 using @iv; +a +1 +0 +0 +SELECT d < '2017-01-01 00:00:00.000000' AS a +FROM t5; +a +1 +0 +0 +execute s3 using @tsv; +a +1 +0 +0 +SELECT d < 20170101000000.0 AS a +FROM t5; +a +1 +0 +0 +execute s3 using @tsn; +a +1 +0 +0 +SELECT d >= '2017-01-01' AS a +FROM t5; +a +0 +1 +1 +execute s4 using @sv; +a +0 +1 +1 +SELECT d >= 20170101 AS a +FROM t5; +a +0 +1 +1 +execute s4 using @iv; +a +0 +1 +1 +SELECT d >= '2017-01-01 00:00:00.000000' AS a +FROM t5; +a +0 +1 +1 +execute s4 using @tsv; +a +0 +1 +1 +SELECT d >= 20170101000000.0 AS a +FROM t5; +a +0 +1 +1 +execute s4 using @tsn; +a +0 +1 +1 +SELECT d <= '2017-01-01' AS a +FROM t5; +a +1 +1 +0 +execute s5 using @sv; +a +1 +1 +0 +SELECT d <= 20170101 AS a +FROM t5; +a +1 +1 +0 +execute s5 using @iv; +a +1 +1 +0 +SELECT d <= '2017-01-01 00:00:00.000000' AS a +FROM t5; +a +1 +1 +0 +execute s5 using @tsv; +a +1 +1 +0 +SELECT d <= 20170101000000.0 AS a +FROM t5; +a +1 +1 +0 +execute s5 using @tsn; +a +1 +1 +0 +SELECT d > '2017-01-01' AS a +FROM t5; +a +0 +0 +1 +execute s6 using @sv; +a +0 +0 +1 +SELECT d > 20170101 AS a +FROM t5; +a +0 +0 +1 +execute s6 using @iv; +a +0 +0 +1 +SELECT d > '2017-01-01 00:00:00.000000' AS a +FROM t5; +a +0 +0 +1 +execute s6 using @tsv; +a +0 +0 +1 +SELECT d > 20170101000000.0 AS a +FROM t5; +a +0 +0 +1 +execute s6 using @tsn; +a +0 +0 +1 +set @sv= "9999-12-31"; +set @iv= 99991231; +set @tsv= "9999-12-31 00:00:00.000000"; +set @tsn= 99991231000000.0; +SELECT d = '9999-12-31' AS a +FROM t5; +a +0 +0 +1 +execute s1 using @sv; +a +0 +0 +1 +SELECT d = 99991231 AS a +FROM t5; +a +0 +0 +1 +execute s1 using @iv; +a +0 +0 +1 +SELECT d = '9999-12-31 00:00:00.000000' AS a +FROM t5; +a +0 +0 +1 +execute s1 using @tsv; +a +0 +0 +1 +SELECT d = 99991231000000.0 AS a +FROM t5; +a +0 +0 +1 +execute s1 using @tsn; +a +0 +0 +1 +SELECT d <> '9999-12-31' AS a +FROM t5; +a +1 +1 +0 +execute s2 using @sv; +a +1 +1 +0 +SELECT d <> 99991231 AS a +FROM t5; +a +1 +1 +0 +execute s2 using @iv; +a +1 +1 +0 +SELECT d <> '9999-12-31 00:00:00.000000' AS a +FROM t5; +a +1 +1 +0 +execute s2 using @tsv; +a +1 +1 +0 +SELECT d <> 99991231000000.0 AS a +FROM t5; +a +1 +1 +0 +execute s2 using @tsn; +a +1 +1 +0 +SELECT d < '9999-12-31' AS a +FROM t5; +a +1 +1 +0 +execute s3 using @sv; +a +1 +1 +0 +SELECT d < 99991231 AS a +FROM t5; +a +1 +1 +0 +execute s3 using @iv; +a +1 +1 +0 +SELECT d < '9999-12-31 00:00:00.000000' AS a +FROM t5; +a +1 +1 +0 +execute s3 using @tsv; +a +1 +1 +0 +SELECT d < 99991231000000.0 AS a +FROM t5; +a +1 +1 +0 +execute s3 using @tsn; +a +1 +1 +0 +SELECT d >= '9999-12-31' AS a +FROM t5; +a +0 +0 +1 +execute s4 using @sv; +a +0 +0 +1 +SELECT d >= 99991231 AS a +FROM t5; +a +0 +0 +1 +execute s4 using @iv; +a +0 +0 +1 +SELECT d >= '9999-12-31 00:00:00.000000' AS a +FROM t5; +a +0 +0 +1 +execute s4 using @tsv; +a +0 +0 +1 +SELECT d >= 99991231000000.0 AS a +FROM t5; +a +0 +0 +1 +execute s4 using @tsn; +a +0 +0 +1 +SELECT d <= '9999-12-31' AS a +FROM t5; +a +1 +1 +1 +execute s5 using @sv; +a +1 +1 +1 +SELECT d <= 99991231 AS a +FROM t5; +a +1 +1 +1 +execute s5 using @iv; +a +1 +1 +1 +SELECT d <= '9999-12-31 00:00:00.000000' AS a +FROM t5; +a +1 +1 +1 +execute s5 using @tsv; +a +1 +1 +1 +SELECT d <= 99991231000000.0 AS a +FROM t5; +a +1 +1 +1 +execute s5 using @tsn; +a +1 +1 +1 +SELECT d > '9999-12-31' AS a +FROM t5; +a +0 +0 +0 +execute s6 using @sv; +a +0 +0 +0 +SELECT d > 99991231 AS a +FROM t5; +a +0 +0 +0 +execute s6 using @iv; +a +0 +0 +0 +SELECT d > '9999-12-31 00:00:00.000000' AS a +FROM t5; +a +0 +0 +0 +execute s6 using @tsv; +a +0 +0 +0 +SELECT d > 99991231000000.0 AS a +FROM t5; +a +0 +0 +0 +execute s6 using @tsn; +a +0 +0 +0 +set @iv=-20010101; +select @iv; +@iv +-20010101 +execute s1 using @iv; +a +NULL +NULL +NULL +Warnings: +Warning 1292 Incorrect datetime value: '-20010101' +set @sv="abc"; +execute s1 using @sv; +a +NULL +NULL +NULL +Warnings: +Warning 1292 Incorrect datetime value: 'abc' +Warning 1292 Incorrect datetime value: 'abc' +Warning 1292 Incorrect datetime value: 'abc' +DEALLOCATE PREPARE s1; +DEALLOCATE PREPARE s2; +DEALLOCATE PREPARE s3; +DEALLOCATE PREPARE s4; +DEALLOCATE PREPARE s5; +DEALLOCATE PREPARE s6; +DROP TABLE t5; +CREATE TABLE t6 +(pk INTEGER PRIMARY KEY, +t1 TIME(0), +t2 TIME(6)); +INSERT INTO t6 VALUES +(0, '-838:59:59', '-838:59:59.000000'), +(1, '-23:59:59', '-23:59:59.999999'), +(2, '00:00:00', '00:00:00.000000'), +(3, '23:59:59', '23:59:59.999999'), +(4, '838:59:59', '838:59:59.000000'); +set @tv= "-838:59:59.000000"; +set @dcv= -8385959.000000; +SELECT t1 = '-838:59:59.000000' AS a, +t2 = '-838:59:59.000000' AS b +FROM t6; +a b +1 1 +0 0 +0 0 +0 0 +0 0 +execute s1 using @tv, @tv; +a b +1 1 +0 0 +0 0 +0 0 +0 0 +SELECT t1 = -8385959.000000 AS a, +t2 = -8385959.000000 AS b +FROM t6; +a b +1 1 +0 0 +0 0 +0 0 +0 0 +execute s1 using @dcv, @dcv; +a b +1 1 +0 0 +0 0 +0 0 +0 0 +SELECT t1 <> '-838:59:59.000000' AS a, +t2 <> '-838:59:59.000000' AS b +FROM t6; +a b +0 0 +1 1 +1 1 +1 1 +1 1 +execute s2 using @tv, @tv; +a b +0 0 +1 1 +1 1 +1 1 +1 1 +SELECT t1 <> -8385959.000000 AS a, +t2 <> -8385959.000000 AS b +FROM t6; +a b +0 0 +1 1 +1 1 +1 1 +1 1 +execute s2 using @dcv, @dcv; +a b +0 0 +1 1 +1 1 +1 1 +1 1 +SELECT t1 < '-838:59:59.000000' AS a, +t2 < '-838:59:59.000000' AS b +FROM t6; +a b +0 0 +0 0 +0 0 +0 0 +0 0 +execute s3 using @tv, @tv; +a b +0 0 +0 0 +0 0 +0 0 +0 0 +SELECT t1 < -8385959.000000 AS a, +t2 < -8385959.000000 AS b +FROM t6; +a b +0 0 +0 0 +0 0 +0 0 +0 0 +execute s3 using @dcv, @dcv; +a b +0 0 +0 0 +0 0 +0 0 +0 0 +SELECT t1 >= '-838:59:59.000000' AS a, +t2 >= '-838:59:59.000000' AS b +FROM t6; +a b +1 1 +1 1 +1 1 +1 1 +1 1 +execute s4 using @tv, @tv; +a b +1 1 +1 1 +1 1 +1 1 +1 1 +SELECT t1 >= -8385959.000000 AS a, +t2 >= -8385959.000000 AS b +FROM t6; +a b +1 1 +1 1 +1 1 +1 1 +1 1 +execute s4 using @dcv, @dcv; +a b +1 1 +1 1 +1 1 +1 1 +1 1 +SELECT t1 <= '-838:59:59.000000' AS a, +t2 <= '-838:59:59.000000' AS b +FROM t6; +a b +1 1 +0 0 +0 0 +0 0 +0 0 +execute s5 using @tv, @tv; +a b +1 1 +0 0 +0 0 +0 0 +0 0 +SELECT t1 <= -8385959.000000 AS a, +t2 <= -8385959.000000 AS b +FROM t6; +a b +1 1 +0 0 +0 0 +0 0 +0 0 +execute s5 using @dcv, @dcv; +a b +1 1 +0 0 +0 0 +0 0 +0 0 +SELECT t1 > '-838:59:59.000000' AS a, +t2 > '-838:59:59.000000' AS b +FROM t6; +a b +0 0 +1 1 +1 1 +1 1 +1 1 +execute s6 using @tv, @tv; +a b +0 0 +1 1 +1 1 +1 1 +1 1 +SELECT t1 > -8385959.000000 AS a, +t2 > -8385959.000000 AS b +FROM t6; +a b +0 0 +1 1 +1 1 +1 1 +1 1 +execute s6 using @dcv, @dcv; +a b +0 0 +1 1 +1 1 +1 1 +1 1 +set @tv= "-23:59:59.999999"; +set @dcv= -235959.999999; +SELECT t1 = '-23:59:59.999999' AS a, +t2 = '-23:59:59.999999' AS b +FROM t6; +a b +0 0 +0 1 +0 0 +0 0 +0 0 +execute s1 using @tv, @tv; +a b +0 0 +0 1 +0 0 +0 0 +0 0 +SELECT t1 = -235959.999999 AS a, +t2 = -235959.999999 AS b +FROM t6; +a b +0 0 +0 1 +0 0 +0 0 +0 0 +execute s1 using @dcv, @dcv; +a b +0 0 +0 1 +0 0 +0 0 +0 0 +SELECT t1 <> '-23:59:59.999999' AS a, +t2 <> '-23:59:59.999999' AS b +FROM t6; +a b +1 1 +1 0 +1 1 +1 1 +1 1 +execute s2 using @tv, @tv; +a b +1 1 +1 0 +1 1 +1 1 +1 1 +SELECT t1 <> -235959.999999 AS a, +t2 <> -235959.999999 AS b +FROM t6; +a b +1 1 +1 0 +1 1 +1 1 +1 1 +execute s2 using @dcv, @dcv; +a b +1 1 +1 0 +1 1 +1 1 +1 1 +SELECT t1 < '-23:59:59.999999' AS a, +t2 < '-23:59:59.999999' AS b +FROM t6; +a b +1 1 +0 0 +0 0 +0 0 +0 0 +execute s3 using @tv, @tv; +a b +1 1 +0 0 +0 0 +0 0 +0 0 +SELECT t1 < -235959.999999 AS a, +t2 < -235959.999999 AS b +FROM t6; +a b +1 1 +0 0 +0 0 +0 0 +0 0 +execute s3 using @dcv, @dcv; +a b +1 1 +0 0 +0 0 +0 0 +0 0 +SELECT t1 >= '-23:59:59.999999' AS a, +t2 >= '-23:59:59.999999' AS b +FROM t6; +a b +0 0 +1 1 +1 1 +1 1 +1 1 +execute s4 using @tv, @tv; +a b +0 0 +1 1 +1 1 +1 1 +1 1 +SELECT t1 >= -235959.999999 AS a, +t2 >= -235959.999999 AS b +FROM t6; +a b +0 0 +1 1 +1 1 +1 1 +1 1 +execute s4 using @dcv, @dcv; +a b +0 0 +1 1 +1 1 +1 1 +1 1 +SELECT t1 <= '-23:59:59.999999' AS a, +t2 <= '-23:59:59.999999' AS b +FROM t6; +a b +1 1 +0 1 +0 0 +0 0 +0 0 +execute s5 using @tv, @tv; +a b +1 1 +0 1 +0 0 +0 0 +0 0 +SELECT t1 <= -235959.999999 AS a, +t2 <= -235959.999999 AS b +FROM t6; +a b +1 1 +0 1 +0 0 +0 0 +0 0 +execute s5 using @dcv, @dcv; +a b +1 1 +0 1 +0 0 +0 0 +0 0 +SELECT t1 > '-23:59:59.999999' AS a, +t2 > '-23:59:59.999999' AS b +FROM t6; +a b +0 0 +1 0 +1 1 +1 1 +1 1 +execute s6 using @tv, @tv; +a b +0 0 +1 0 +1 1 +1 1 +1 1 +SELECT t1 > -235959.999999 AS a, +t2 > -235959.999999 AS b +FROM t6; +a b +0 0 +1 0 +1 1 +1 1 +1 1 +execute s6 using @dcv, @dcv; +a b +0 0 +1 0 +1 1 +1 1 +1 1 +set @tv= "00:00:00.000000"; +set @dcv= 000000.000000; +SELECT t1 = '00:00:00.000000' AS a, +t2 = '00:00:00.000000' AS b +FROM t6; +a b +0 0 +0 0 +1 1 +0 0 +0 0 +execute s1 using @tv, @tv; +a b +0 0 +0 0 +1 1 +0 0 +0 0 +SELECT t1 = 000000.000000 AS a, +t2 = 000000.000000 AS b +FROM t6; +a b +0 0 +0 0 +1 1 +0 0 +0 0 +execute s1 using @dcv, @dcv; +a b +0 0 +0 0 +1 1 +0 0 +0 0 +SELECT t1 <> '00:00:00.000000' AS a, +t2 <> '00:00:00.000000' AS b +FROM t6; +a b +1 1 +1 1 +0 0 +1 1 +1 1 +execute s2 using @tv, @tv; +a b +1 1 +1 1 +0 0 +1 1 +1 1 +SELECT t1 <> 000000.000000 AS a, +t2 <> 000000.000000 AS b +FROM t6; +a b +1 1 +1 1 +0 0 +1 1 +1 1 +execute s2 using @dcv, @dcv; +a b +1 1 +1 1 +0 0 +1 1 +1 1 +SELECT t1 < '00:00:00.000000' AS a, +t2 < '00:00:00.000000' AS b +FROM t6; +a b +1 1 +1 1 +0 0 +0 0 +0 0 +execute s3 using @tv, @tv; +a b +1 1 +1 1 +0 0 +0 0 +0 0 +SELECT t1 < 000000.000000 AS a, +t2 < 000000.000000 AS b +FROM t6; +a b +1 1 +1 1 +0 0 +0 0 +0 0 +execute s3 using @dcv, @dcv; +a b +1 1 +1 1 +0 0 +0 0 +0 0 +SELECT t1 >= '00:00:00.000000' AS a, +t2 >= '00:00:00.000000' AS b +FROM t6; +a b +0 0 +0 0 +1 1 +1 1 +1 1 +execute s4 using @tv, @tv; +a b +0 0 +0 0 +1 1 +1 1 +1 1 +SELECT t1 >= 000000.000000 AS a, +t2 >= 000000.000000 AS b +FROM t6; +a b +0 0 +0 0 +1 1 +1 1 +1 1 +execute s4 using @dcv, @dcv; +a b +0 0 +0 0 +1 1 +1 1 +1 1 +SELECT t1 <= '00:00:00.000000' AS a, +t2 <= '00:00:00.000000' AS b +FROM t6; +a b +1 1 +1 1 +1 1 +0 0 +0 0 +execute s5 using @tv, @tv; +a b +1 1 +1 1 +1 1 +0 0 +0 0 +SELECT t1 <= 000000.000000 AS a, +t2 <= 000000.000000 AS b +FROM t6; +a b +1 1 +1 1 +1 1 +0 0 +0 0 +execute s5 using @dcv, @dcv; +a b +1 1 +1 1 +1 1 +0 0 +0 0 +SELECT t1 > '00:00:00.000000' AS a, +t2 > '00:00:00.000000' AS b +FROM t6; +a b +0 0 +0 0 +0 0 +1 1 +1 1 +execute s6 using @tv, @tv; +a b +0 0 +0 0 +0 0 +1 1 +1 1 +SELECT t1 > 000000.000000 AS a, +t2 > 000000.000000 AS b +FROM t6; +a b +0 0 +0 0 +0 0 +1 1 +1 1 +execute s6 using @dcv, @dcv; +a b +0 0 +0 0 +0 0 +1 1 +1 1 +set @tv= "23:59:59.999999"; +set @dcv= 235959.999999; +SELECT t1 = '23:59:59.999999' AS a, +t2 = '23:59:59.999999' AS b +FROM t6; +a b +0 0 +0 0 +0 0 +0 1 +0 0 +execute s1 using @tv, @tv; +a b +0 0 +0 0 +0 0 +0 1 +0 0 +SELECT t1 = 235959.999999 AS a, +t2 = 235959.999999 AS b +FROM t6; +a b +0 0 +0 0 +0 0 +0 1 +0 0 +execute s1 using @dcv, @dcv; +a b +0 0 +0 0 +0 0 +0 1 +0 0 +SELECT t1 <> '23:59:59.999999' AS a, +t2 <> '23:59:59.999999' AS b +FROM t6; +a b +1 1 +1 1 +1 1 +1 0 +1 1 +execute s2 using @tv, @tv; +a b +1 1 +1 1 +1 1 +1 0 +1 1 +SELECT t1 <> 235959.999999 AS a, +t2 <> 235959.999999 AS b +FROM t6; +a b +1 1 +1 1 +1 1 +1 0 +1 1 +execute s2 using @dcv, @dcv; +a b +1 1 +1 1 +1 1 +1 0 +1 1 +SELECT t1 < '23:59:59.999999' AS a, +t2 < '23:59:59.999999' AS b +FROM t6; +a b +1 1 +1 1 +1 1 +1 0 +0 0 +execute s3 using @tv, @tv; +a b +1 1 +1 1 +1 1 +1 0 +0 0 +SELECT t1 < 235959.999999 AS a, +t2 < 235959.999999 AS b +FROM t6; +a b +1 1 +1 1 +1 1 +1 0 +0 0 +execute s3 using @dcv, @dcv; +a b +1 1 +1 1 +1 1 +1 0 +0 0 +SELECT t1 >= '23:59:59.999999' AS a, +t2 >= '23:59:59.999999' AS b +FROM t6; +a b +0 0 +0 0 +0 0 +0 1 +1 1 +execute s4 using @tv, @tv; +a b +0 0 +0 0 +0 0 +0 1 +1 1 +SELECT t1 >= 235959.999999 AS a, +t2 >= 235959.999999 AS b +FROM t6; +a b +0 0 +0 0 +0 0 +0 1 +1 1 +execute s4 using @dcv, @dcv; +a b +0 0 +0 0 +0 0 +0 1 +1 1 +SELECT t1 <= '23:59:59.999999' AS a, +t2 <= '23:59:59.999999' AS b +FROM t6; +a b +1 1 +1 1 +1 1 +1 1 +0 0 +execute s5 using @tv, @tv; +a b +1 1 +1 1 +1 1 +1 1 +0 0 +SELECT t1 <= 235959.999999 AS a, +t2 <= 235959.999999 AS b +FROM t6; +a b +1 1 +1 1 +1 1 +1 1 +0 0 +execute s5 using @dcv, @dcv; +a b +1 1 +1 1 +1 1 +1 1 +0 0 +SELECT t1 > '23:59:59.999999' AS a, +t2 > '23:59:59.999999' AS b +FROM t6; +a b +0 0 +0 0 +0 0 +0 0 +1 1 +execute s6 using @tv, @tv; +a b +0 0 +0 0 +0 0 +0 0 +1 1 +SELECT t1 > 235959.999999 AS a, +t2 > 235959.999999 AS b +FROM t6; +a b +0 0 +0 0 +0 0 +0 0 +1 1 +execute s6 using @dcv, @dcv; +a b +0 0 +0 0 +0 0 +0 0 +1 1 +set @tv= "838:59:59.000000"; +set @dcv= 8385959.000000; +SELECT t1 = '838:59:59.000000' AS a, +t2 = '838:59:59.000000' AS b +FROM t6; +a b +0 0 +0 0 +0 0 +0 0 +1 1 +execute s1 using @tv, @tv; +a b +0 0 +0 0 +0 0 +0 0 +1 1 +SELECT t1 = 8385959.000000 AS a, +t2 = 8385959.000000 AS b +FROM t6; +a b +0 0 +0 0 +0 0 +0 0 +1 1 +execute s1 using @dcv, @dcv; +a b +0 0 +0 0 +0 0 +0 0 +1 1 +SELECT t1 <> '838:59:59.000000' AS a, +t2 <> '838:59:59.000000' AS b +FROM t6; +a b +1 1 +1 1 +1 1 +1 1 +0 0 +execute s2 using @tv, @tv; +a b +1 1 +1 1 +1 1 +1 1 +0 0 +SELECT t1 <> 8385959.000000 AS a, +t2 <> 8385959.000000 AS b +FROM t6; +a b +1 1 +1 1 +1 1 +1 1 +0 0 +execute s2 using @dcv, @dcv; +a b +1 1 +1 1 +1 1 +1 1 +0 0 +SELECT t1 < '838:59:59.000000' AS a, +t2 < '838:59:59.000000' AS b +FROM t6; +a b +1 1 +1 1 +1 1 +1 1 +0 0 +execute s3 using @tv, @tv; +a b +1 1 +1 1 +1 1 +1 1 +0 0 +SELECT t1 < 8385959.000000 AS a, +t2 < 8385959.000000 AS b +FROM t6; +a b +1 1 +1 1 +1 1 +1 1 +0 0 +execute s3 using @dcv, @dcv; +a b +1 1 +1 1 +1 1 +1 1 +0 0 +SELECT t1 >= '838:59:59.000000' AS a, +t2 >= '838:59:59.000000' AS b +FROM t6; +a b +0 0 +0 0 +0 0 +0 0 +1 1 +execute s4 using @tv, @tv; +a b +0 0 +0 0 +0 0 +0 0 +1 1 +SELECT t1 >= 8385959.000000 AS a, +t2 >= 8385959.000000 AS b +FROM t6; +a b +0 0 +0 0 +0 0 +0 0 +1 1 +execute s4 using @dcv, @dcv; +a b +0 0 +0 0 +0 0 +0 0 +1 1 +SELECT t1 <= '838:59:59.000000' AS a, +t2 <= '838:59:59.000000' AS b +FROM t6; +a b +1 1 +1 1 +1 1 +1 1 +1 1 +execute s5 using @tv, @tv; +a b +1 1 +1 1 +1 1 +1 1 +1 1 +SELECT t1 <= 8385959.000000 AS a, +t2 <= 8385959.000000 AS b +FROM t6; +a b +1 1 +1 1 +1 1 +1 1 +1 1 +execute s5 using @dcv, @dcv; +a b +1 1 +1 1 +1 1 +1 1 +1 1 +SELECT t1 > '838:59:59.000000' AS a, +t2 > '838:59:59.000000' AS b +FROM t6; +a b +0 0 +0 0 +0 0 +0 0 +0 0 +execute s6 using @tv, @tv; +a b +0 0 +0 0 +0 0 +0 0 +0 0 +SELECT t1 > 8385959.000000 AS a, +t2 > 8385959.000000 AS b +FROM t6; +a b +0 0 +0 0 +0 0 +0 0 +0 0 +execute s6 using @dcv, @dcv; +a b +0 0 +0 0 +0 0 +0 0 +0 0 +DEALLOCATE PREPARE s1; +DEALLOCATE PREPARE s2; +DEALLOCATE PREPARE s3; +DEALLOCATE PREPARE s4; +DEALLOCATE PREPARE s5; +DEALLOCATE PREPARE s6; +DROP TABLE t6; +CREATE TABLE t7 +(pk INTEGER PRIMARY KEY, +dt1 DATETIME(0), +dt2 DATETIME(6)); +INSERT INTO t7 VALUES +(0, '0001-01-01 00:00:00', '0001-01-01 00:00:00.000000'), +(1, '2017-01-01 11:59.59', '2017-01-01 11:59.59.555555'), +(2, '9999-12-31 23:59.59', '9999-12-31 23:59.59.999999'); +set @dsv= "0001-01-01"; +set @tssv= "0001-01-01 00:00:00.000000"; +set @iv= 00010101; +set @dcv= 00010101000000.000000; +SELECT dt1 = '0001-01-01' AS a, +dt2 = '0001-01-01' AS b +FROM t7; +a b +1 1 +0 0 +0 0 +execute s1 using @dsv, @dsv; +a b +1 1 +0 0 +0 0 +SELECT dt1 = 00010101 AS a, +dt2 = 00010101 AS b +FROM t7; +a b +0 0 +0 0 +0 0 +execute s1 using @iv, @iv; +a b +0 0 +0 0 +0 0 +SELECT dt1 = '0001-01-01 00:00:00.000000' AS a, +dt2 = '0001-01-01 00:00:00.000000' AS b +FROM t7; +a b +1 1 +0 0 +0 0 +execute s1 using @tssv, @tssv; +a b +1 1 +0 0 +0 0 +SELECT dt1 = 00010101000000.000000 AS a, +dt2 = 00010101000000.000000 AS b +FROM t7; +a b +0 0 +0 0 +0 0 +execute s1 using @dcv, @dcv; +a b +0 0 +0 0 +0 0 +SELECT dt1 <> '0001-01-01' AS a, +dt2 <> '0001-01-01' AS b +FROM t7; +a b +0 0 +1 1 +1 1 +execute s2 using @dsv, @dsv; +a b +0 0 +1 1 +1 1 +SELECT dt1 <> 00010101 AS a, +dt2 <> 00010101 AS b +FROM t7; +a b +1 1 +1 1 +1 1 +execute s2 using @iv, @iv; +a b +1 1 +1 1 +1 1 +SELECT dt1 <> '0001-01-01 00:00:00.000000' AS a, +dt2 <> '0001-01-01 00:00:00.000000' AS b +FROM t7; +a b +0 0 +1 1 +1 1 +execute s2 using @tssv, @tssv; +a b +0 0 +1 1 +1 1 +SELECT dt1 <> 00010101000000.000000 AS a, +dt2 <> 00010101000000.000000 AS b +FROM t7; +a b +1 1 +1 1 +1 1 +execute s2 using @dcv, @dcv; +a b +1 1 +1 1 +1 1 +SELECT dt1 < '0001-01-01' AS a, +dt2 < '0001-01-01' AS b +FROM t7; +a b +0 0 +0 0 +0 0 +execute s3 using @dsv, @dsv; +a b +0 0 +0 0 +0 0 +SELECT dt1 < 00010101 AS a, +dt2 < 00010101 AS b +FROM t7; +a b +1 1 +0 0 +0 0 +execute s3 using @iv, @iv; +a b +1 1 +0 0 +0 0 +SELECT dt1 < '0001-01-01 00:00:00.000000' AS a, +dt2 < '0001-01-01 00:00:00.000000' AS b +FROM t7; +a b +0 0 +0 0 +0 0 +execute s3 using @tssv, @tssv; +a b +0 0 +0 0 +0 0 +SELECT dt1 < 00010101000000.000000 AS a, +dt2 < 00010101000000.000000 AS b +FROM t7; +a b +1 1 +0 0 +0 0 +execute s3 using @dcv, @dcv; +a b +1 1 +0 0 +0 0 +SELECT dt1 >= '0001-01-01' AS a, +dt2 >= '0001-01-01' AS b +FROM t7; +a b +1 1 +1 1 +1 1 +execute s4 using @dsv, @dsv; +a b +1 1 +1 1 +1 1 +SELECT dt1 >= 00010101 AS a, +dt2 >= 00010101 AS b +FROM t7; +a b +0 0 +1 1 +1 1 +execute s4 using @iv, @iv; +a b +0 0 +1 1 +1 1 +SELECT dt1 >= '0001-01-01 00:00:00.000000' AS a, +dt2 >= '0001-01-01 00:00:00.000000' AS b +FROM t7; +a b +1 1 +1 1 +1 1 +execute s4 using @tssv, @tssv; +a b +1 1 +1 1 +1 1 +SELECT dt1 >= 00010101000000.000000 AS a, +dt2 >= 00010101000000.000000 AS b +FROM t7; +a b +0 0 +1 1 +1 1 +execute s4 using @dcv, @dcv; +a b +0 0 +1 1 +1 1 +SELECT dt1 <= '0001-01-01' AS a, +dt2 <= '0001-01-01' AS b +FROM t7; +a b +1 1 +0 0 +0 0 +execute s5 using @dsv, @dsv; +a b +1 1 +0 0 +0 0 +SELECT dt1 <= 00010101 AS a, +dt2 <= 00010101 AS b +FROM t7; +a b +1 1 +0 0 +0 0 +execute s5 using @iv, @iv; +a b +1 1 +0 0 +0 0 +SELECT dt1 <= '0001-01-01 00:00:00.000000' AS a, +dt2 <= '0001-01-01 00:00:00.000000' AS b +FROM t7; +a b +1 1 +0 0 +0 0 +execute s5 using @tssv, @tssv; +a b +1 1 +0 0 +0 0 +SELECT dt1 <= 00010101000000.000000 AS a, +dt2 <= 00010101000000.000000 AS b +FROM t7; +a b +1 1 +0 0 +0 0 +execute s5 using @dcv, @dcv; +a b +1 1 +0 0 +0 0 +SELECT dt1 > '0001-01-01' AS a, +dt2 > '0001-01-01' AS b +FROM t7; +a b +0 0 +1 1 +1 1 +execute s6 using @dsv, @dsv; +a b +0 0 +1 1 +1 1 +SELECT dt1 > 00010101 AS a, +dt2 > 00010101 AS b +FROM t7; +a b +0 0 +1 1 +1 1 +execute s6 using @iv, @iv; +a b +0 0 +1 1 +1 1 +SELECT dt1 > '0001-01-01 00:00:00.000000' AS a, +dt2 > '0001-01-01 00:00:00.000000' AS b +FROM t7; +a b +0 0 +1 1 +1 1 +execute s6 using @tssv, @tssv; +a b +0 0 +1 1 +1 1 +SELECT dt1 > 00010101000000.000000 AS a, +dt2 > 00010101000000.000000 AS b +FROM t7; +a b +0 0 +1 1 +1 1 +execute s6 using @dcv, @dcv; +a b +0 0 +1 1 +1 1 +set @dsv= "2017-01-01"; +set @tssv= "2017-01-01 11:59:59"; +set @iv= 20170101; +set @dcv= 20170101115959; +SELECT dt1 = '2017-01-01' AS a, +dt2 = '2017-01-01' AS b +FROM t7; +a b +0 0 +0 0 +0 0 +execute s1 using @dsv, @dsv; +a b +0 0 +0 0 +0 0 +SELECT dt1 = 20170101 AS a, +dt2 = 20170101 AS b +FROM t7; +a b +0 0 +0 0 +0 0 +execute s1 using @iv, @iv; +a b +0 0 +0 0 +0 0 +SELECT dt1 = '2017-01-01 11:59:59' AS a, +dt2 = '2017-01-01 11:59:59' AS b +FROM t7; +a b +0 0 +1 0 +0 0 +execute s1 using @tssv, @tssv; +a b +0 0 +1 0 +0 0 +SELECT dt1 = 20170101115959 AS a, +dt2 = 20170101115959 AS b +FROM t7; +a b +0 0 +1 0 +0 0 +execute s1 using @dcv, @dcv; +a b +0 0 +1 0 +0 0 +SELECT dt1 <> '2017-01-01' AS a, +dt2 <> '2017-01-01' AS b +FROM t7; +a b +1 1 +1 1 +1 1 +execute s2 using @dsv, @dsv; +a b +1 1 +1 1 +1 1 +SELECT dt1 <> 20170101 AS a, +dt2 <> 20170101 AS b +FROM t7; +a b +1 1 +1 1 +1 1 +execute s2 using @iv, @iv; +a b +1 1 +1 1 +1 1 +SELECT dt1 <> '2017-01-01 11:59:59' AS a, +dt2 <> '2017-01-01 11:59:59' AS b +FROM t7; +a b +1 1 +0 1 +1 1 +execute s2 using @tssv, @tssv; +a b +1 1 +0 1 +1 1 +SELECT dt1 <> 20170101115959 AS a, +dt2 <> 20170101115959 AS b +FROM t7; +a b +1 1 +0 1 +1 1 +execute s2 using @dcv, @dcv; +a b +1 1 +0 1 +1 1 +SELECT dt1 < '2017-01-01' AS a, +dt2 < '2017-01-01' AS b +FROM t7; +a b +1 1 +0 0 +0 0 +execute s3 using @dsv, @dsv; +a b +1 1 +0 0 +0 0 +SELECT dt1 < 20170101 AS a, +dt2 < 20170101 AS b +FROM t7; +a b +1 1 +0 0 +0 0 +execute s3 using @iv, @iv; +a b +1 1 +0 0 +0 0 +SELECT dt1 < '2017-01-01 11:59:59' AS a, +dt2 < '2017-01-01 11:59:59' AS b +FROM t7; +a b +1 1 +0 0 +0 0 +execute s3 using @tssv, @tssv; +a b +1 1 +0 0 +0 0 +SELECT dt1 < 20170101115959 AS a, +dt2 < 20170101115959 AS b +FROM t7; +a b +1 1 +0 0 +0 0 +execute s3 using @dcv, @dcv; +a b +1 1 +0 0 +0 0 +SELECT dt1 >= '2017-01-01' AS a, +dt2 >= '2017-01-01' AS b +FROM t7; +a b +0 0 +1 1 +1 1 +execute s4 using @dsv, @dsv; +a b +0 0 +1 1 +1 1 +SELECT dt1 >= 20170101 AS a, +dt2 >= 20170101 AS b +FROM t7; +a b +0 0 +1 1 +1 1 +execute s4 using @iv, @iv; +a b +0 0 +1 1 +1 1 +SELECT dt1 >= '2017-01-01 11:59:59' AS a, +dt2 >= '2017-01-01 11:59:59' AS b +FROM t7; +a b +0 0 +1 1 +1 1 +execute s4 using @tssv, @tssv; +a b +0 0 +1 1 +1 1 +SELECT dt1 >= 20170101115959 AS a, +dt2 >= 20170101115959 AS b +FROM t7; +a b +0 0 +1 1 +1 1 +execute s4 using @dcv, @dcv; +a b +0 0 +1 1 +1 1 +SELECT dt1 <= '2017-01-01' AS a, +dt2 <= '2017-01-01' AS b +FROM t7; +a b +1 1 +0 0 +0 0 +execute s5 using @dsv, @dsv; +a b +1 1 +0 0 +0 0 +SELECT dt1 <= 20170101 AS a, +dt2 <= 20170101 AS b +FROM t7; +a b +1 1 +0 0 +0 0 +execute s5 using @iv, @iv; +a b +1 1 +0 0 +0 0 +SELECT dt1 <= '2017-01-01 11:59:59' AS a, +dt2 <= '2017-01-01 11:59:59' AS b +FROM t7; +a b +1 1 +1 0 +0 0 +execute s5 using @tssv, @tssv; +a b +1 1 +1 0 +0 0 +SELECT dt1 <= 20170101115959 AS a, +dt2 <= 20170101115959 AS b +FROM t7; +a b +1 1 +1 0 +0 0 +execute s5 using @dcv, @dcv; +a b +1 1 +1 0 +0 0 +SELECT dt1 > '2017-01-01' AS a, +dt2 > '2017-01-01' AS b +FROM t7; +a b +0 0 +1 1 +1 1 +execute s6 using @dsv, @dsv; +a b +0 0 +1 1 +1 1 +SELECT dt1 > 20170101 AS a, +dt2 > 20170101 AS b +FROM t7; +a b +0 0 +1 1 +1 1 +execute s6 using @iv, @iv; +a b +0 0 +1 1 +1 1 +SELECT dt1 > '2017-01-01 11:59:59' AS a, +dt2 > '2017-01-01 11:59:59' AS b +FROM t7; +a b +0 0 +0 1 +1 1 +execute s6 using @tssv, @tssv; +a b +0 0 +0 1 +1 1 +SELECT dt1 > 20170101115959 AS a, +dt2 > 20170101115959 AS b +FROM t7; +a b +0 0 +0 1 +1 1 +execute s6 using @dcv, @dcv; +a b +0 0 +0 1 +1 1 +set @dsv= "2017-01-01"; +set @tssv= "2017-01-01 11:59:59.555555"; +set @iv= 20170101; +set @dcv= 20170101115959.555555; +SELECT dt1 = '2017-01-01' AS a, +dt2 = '2017-01-01' AS b +FROM t7; +a b +0 0 +0 0 +0 0 +execute s1 using @dsv, @dsv; +a b +0 0 +0 0 +0 0 +SELECT dt1 = 20170101 AS a, +dt2 = 20170101 AS b +FROM t7; +a b +0 0 +0 0 +0 0 +execute s1 using @iv, @iv; +a b +0 0 +0 0 +0 0 +SELECT dt1 = '2017-01-01 11:59:59.555555' AS a, +dt2 = '2017-01-01 11:59:59.555555' AS b +FROM t7; +a b +0 0 +0 1 +0 0 +execute s1 using @tssv, @tssv; +a b +0 0 +0 1 +0 0 +SELECT dt1 = 20170101115959.555555 AS a, +dt2 = 20170101115959.555555 AS b +FROM t7; +a b +0 0 +0 1 +0 0 +execute s1 using @dcv, @dcv; +a b +0 0 +0 1 +0 0 +SELECT dt1 <> '2017-01-01' AS a, +dt2 <> '2017-01-01' AS b +FROM t7; +a b +1 1 +1 1 +1 1 +execute s2 using @dsv, @dsv; +a b +1 1 +1 1 +1 1 +SELECT dt1 <> 20170101 AS a, +dt2 <> 20170101 AS b +FROM t7; +a b +1 1 +1 1 +1 1 +execute s2 using @iv, @iv; +a b +1 1 +1 1 +1 1 +SELECT dt1 <> '2017-01-01 11:59:59.555555' AS a, +dt2 <> '2017-01-01 11:59:59.555555' AS b +FROM t7; +a b +1 1 +1 0 +1 1 +execute s2 using @tssv, @tssv; +a b +1 1 +1 0 +1 1 +SELECT dt1 <> 20170101115959.555555 AS a, +dt2 <> 20170101115959.555555 AS b +FROM t7; +a b +1 1 +1 0 +1 1 +execute s2 using @dcv, @dcv; +a b +1 1 +1 0 +1 1 +SELECT dt1 < '2017-01-01' AS a, +dt2 < '2017-01-01' AS b +FROM t7; +a b +1 1 +0 0 +0 0 +execute s3 using @dsv, @dsv; +a b +1 1 +0 0 +0 0 +SELECT dt1 < 20170101 AS a, +dt2 < 20170101 AS b +FROM t7; +a b +1 1 +0 0 +0 0 +execute s3 using @iv, @iv; +a b +1 1 +0 0 +0 0 +SELECT dt1 < '2017-01-01 11:59:59.555555' AS a, +dt2 < '2017-01-01 11:59:59.555555' AS b +FROM t7; +a b +1 1 +1 0 +0 0 +execute s3 using @tssv, @tssv; +a b +1 1 +1 0 +0 0 +SELECT dt1 < 20170101115959.555555 AS a, +dt2 < 20170101115959.555555 AS b +FROM t7; +a b +1 1 +1 0 +0 0 +execute s3 using @dcv, @dcv; +a b +1 1 +1 0 +0 0 +SELECT dt1 >= '2017-01-01' AS a, +dt2 >= '2017-01-01' AS b +FROM t7; +a b +0 0 +1 1 +1 1 +execute s4 using @dsv, @dsv; +a b +0 0 +1 1 +1 1 +SELECT dt1 >= 20170101 AS a, +dt2 >= 20170101 AS b +FROM t7; +a b +0 0 +1 1 +1 1 +execute s4 using @iv, @iv; +a b +0 0 +1 1 +1 1 +SELECT dt1 >= '2017-01-01 11:59:59.555555' AS a, +dt2 >= '2017-01-01 11:59:59.555555' AS b +FROM t7; +a b +0 0 +0 1 +1 1 +execute s4 using @tssv, @tssv; +a b +0 0 +0 1 +1 1 +SELECT dt1 >= 20170101115959.555555 AS a, +dt2 >= 20170101115959.555555 AS b +FROM t7; +a b +0 0 +0 1 +1 1 +execute s4 using @dcv, @dcv; +a b +0 0 +0 1 +1 1 +SELECT dt1 <= '2017-01-01' AS a, +dt2 <= '2017-01-01' AS b +FROM t7; +a b +1 1 +0 0 +0 0 +execute s5 using @dsv, @dsv; +a b +1 1 +0 0 +0 0 +SELECT dt1 <= 20170101 AS a, +dt2 <= 20170101 AS b +FROM t7; +a b +1 1 +0 0 +0 0 +execute s5 using @iv, @iv; +a b +1 1 +0 0 +0 0 +SELECT dt1 <= '2017-01-01 11:59:59.555555' AS a, +dt2 <= '2017-01-01 11:59:59.555555' AS b +FROM t7; +a b +1 1 +1 1 +0 0 +execute s5 using @tssv, @tssv; +a b +1 1 +1 1 +0 0 +SELECT dt1 <= 20170101115959.555555 AS a, +dt2 <= 20170101115959.555555 AS b +FROM t7; +a b +1 1 +1 1 +0 0 +execute s5 using @dcv, @dcv; +a b +1 1 +1 1 +0 0 +SELECT dt1 > '2017-01-01' AS a, +dt2 > '2017-01-01' AS b +FROM t7; +a b +0 0 +1 1 +1 1 +execute s6 using @dsv, @dsv; +a b +0 0 +1 1 +1 1 +SELECT dt1 > 20170101 AS a, +dt2 > 20170101 AS b +FROM t7; +a b +0 0 +1 1 +1 1 +execute s6 using @iv, @iv; +a b +0 0 +1 1 +1 1 +SELECT dt1 > '2017-01-01 11:59:59.555555' AS a, +dt2 > '2017-01-01 11:59:59.555555' AS b +FROM t7; +a b +0 0 +0 0 +1 1 +execute s6 using @tssv, @tssv; +a b +0 0 +0 0 +1 1 +SELECT dt1 > 20170101115959.555555 AS a, +dt2 > 20170101115959.555555 AS b +FROM t7; +a b +0 0 +0 0 +1 1 +execute s6 using @dcv, @dcv; +a b +0 0 +0 0 +1 1 +set @dsv= "9999-12-31"; +set @tssv= "9999-12-31 23:59:59.999999"; +set @iv= 99991231; +set @dcv= 99991231235959.999999; +SELECT dt1 = '9999-12-31' AS a, +dt2 = '9999-12-31' AS b +FROM t7; +a b +0 0 +0 0 +0 0 +execute s1 using @dsv, @dsv; +a b +0 0 +0 0 +0 0 +SELECT dt1 = 99991231 AS a, +dt2 = 99991231 AS b +FROM t7; +a b +0 0 +0 0 +0 0 +execute s1 using @iv, @iv; +a b +0 0 +0 0 +0 0 +SELECT dt1 = '9999-12-31 23:59:59.999999' AS a, +dt2 = '9999-12-31 23:59:59.999999' AS b +FROM t7; +a b +0 0 +0 0 +0 1 +execute s1 using @tssv, @tssv; +a b +0 0 +0 0 +0 1 +SELECT dt1 = 99991231235959.999999 AS a, +dt2 = 99991231235959.999999 AS b +FROM t7; +a b +0 0 +0 0 +0 1 +Warnings: +Warning 1441 Datetime function: datetime field overflow +Warning 1292 Incorrect datetime value: '99991231235959.999999' for column 'dt1' at row 1 +Warning 1441 Datetime function: datetime field overflow +Warning 1292 Incorrect datetime value: '99991231235959.999999' for column 'dt1' at row 1 +Warning 1441 Datetime function: datetime field overflow +Warning 1292 Incorrect datetime value: '99991231235959.999999' for column 'dt1' at row 1 +execute s1 using @dcv, @dcv; +a b +0 0 +0 0 +0 1 +SELECT dt1 <> '9999-12-31' AS a, +dt2 <> '9999-12-31' AS b +FROM t7; +a b +1 1 +1 1 +1 1 +execute s2 using @dsv, @dsv; +a b +1 1 +1 1 +1 1 +SELECT dt1 <> 99991231 AS a, +dt2 <> 99991231 AS b +FROM t7; +a b +1 1 +1 1 +1 1 +execute s2 using @iv, @iv; +a b +1 1 +1 1 +1 1 +SELECT dt1 <> '9999-12-31 23:59:59.999999' AS a, +dt2 <> '9999-12-31 23:59:59.999999' AS b +FROM t7; +a b +1 1 +1 1 +1 0 +execute s2 using @tssv, @tssv; +a b +1 1 +1 1 +1 0 +SELECT dt1 <> 99991231235959.999999 AS a, +dt2 <> 99991231235959.999999 AS b +FROM t7; +a b +1 1 +1 1 +1 0 +Warnings: +Warning 1441 Datetime function: datetime field overflow +Warning 1292 Incorrect datetime value: '99991231235959.999999' for column 'dt1' at row 1 +Warning 1441 Datetime function: datetime field overflow +Warning 1292 Incorrect datetime value: '99991231235959.999999' for column 'dt1' at row 1 +Warning 1441 Datetime function: datetime field overflow +Warning 1292 Incorrect datetime value: '99991231235959.999999' for column 'dt1' at row 1 +execute s2 using @dcv, @dcv; +a b +1 1 +1 1 +1 0 +SELECT dt1 < '9999-12-31' AS a, +dt2 < '9999-12-31' AS b +FROM t7; +a b +1 1 +1 1 +0 0 +execute s3 using @dsv, @dsv; +a b +1 1 +1 1 +0 0 +SELECT dt1 < 99991231 AS a, +dt2 < 99991231 AS b +FROM t7; +a b +1 1 +1 1 +0 0 +execute s3 using @iv, @iv; +a b +1 1 +1 1 +0 0 +SELECT dt1 < '9999-12-31 23:59:59.999999' AS a, +dt2 < '9999-12-31 23:59:59.999999' AS b +FROM t7; +a b +1 1 +1 1 +1 0 +execute s3 using @tssv, @tssv; +a b +1 1 +1 1 +1 0 +SELECT dt1 < 99991231235959.999999 AS a, +dt2 < 99991231235959.999999 AS b +FROM t7; +a b +1 1 +1 1 +1 0 +Warnings: +Warning 1441 Datetime function: datetime field overflow +Warning 1292 Incorrect datetime value: '99991231235959.999999' for column 'dt1' at row 1 +Warning 1441 Datetime function: datetime field overflow +Warning 1292 Incorrect datetime value: '99991231235959.999999' for column 'dt1' at row 1 +Warning 1441 Datetime function: datetime field overflow +Warning 1292 Incorrect datetime value: '99991231235959.999999' for column 'dt1' at row 1 +execute s3 using @dcv, @dcv; +a b +1 1 +1 1 +1 0 +SELECT dt1 >= '9999-12-31' AS a, +dt2 >= '9999-12-31' AS b +FROM t7; +a b +0 0 +0 0 +1 1 +execute s4 using @dsv, @dsv; +a b +0 0 +0 0 +1 1 +SELECT dt1 >= 99991231 AS a, +dt2 >= 99991231 AS b +FROM t7; +a b +0 0 +0 0 +1 1 +execute s4 using @iv, @iv; +a b +0 0 +0 0 +1 1 +SELECT dt1 >= '9999-12-31 23:59:59.999999' AS a, +dt2 >= '9999-12-31 23:59:59.999999' AS b +FROM t7; +a b +0 0 +0 0 +0 1 +execute s4 using @tssv, @tssv; +a b +0 0 +0 0 +0 1 +SELECT dt1 >= 99991231235959.999999 AS a, +dt2 >= 99991231235959.999999 AS b +FROM t7; +a b +0 0 +0 0 +0 1 +Warnings: +Warning 1441 Datetime function: datetime field overflow +Warning 1292 Incorrect datetime value: '99991231235959.999999' for column 'dt1' at row 1 +Warning 1441 Datetime function: datetime field overflow +Warning 1292 Incorrect datetime value: '99991231235959.999999' for column 'dt1' at row 1 +Warning 1441 Datetime function: datetime field overflow +Warning 1292 Incorrect datetime value: '99991231235959.999999' for column 'dt1' at row 1 +execute s4 using @dcv, @dcv; +a b +0 0 +0 0 +0 1 +SELECT dt1 <= '9999-12-31' AS a, +dt2 <= '9999-12-31' AS b +FROM t7; +a b +1 1 +1 1 +0 0 +execute s5 using @dsv, @dsv; +a b +1 1 +1 1 +0 0 +SELECT dt1 <= 99991231 AS a, +dt2 <= 99991231 AS b +FROM t7; +a b +1 1 +1 1 +0 0 +execute s5 using @iv, @iv; +a b +1 1 +1 1 +0 0 +SELECT dt1 <= '9999-12-31 23:59:59.999999' AS a, +dt2 <= '9999-12-31 23:59:59.999999' AS b +FROM t7; +a b +1 1 +1 1 +1 1 +execute s5 using @tssv, @tssv; +a b +1 1 +1 1 +1 1 +SELECT dt1 <= 99991231235959.999999 AS a, +dt2 <= 99991231235959.999999 AS b +FROM t7; +a b +1 1 +1 1 +1 1 +Warnings: +Warning 1441 Datetime function: datetime field overflow +Warning 1292 Incorrect datetime value: '99991231235959.999999' for column 'dt1' at row 1 +Warning 1441 Datetime function: datetime field overflow +Warning 1292 Incorrect datetime value: '99991231235959.999999' for column 'dt1' at row 1 +Warning 1441 Datetime function: datetime field overflow +Warning 1292 Incorrect datetime value: '99991231235959.999999' for column 'dt1' at row 1 +execute s5 using @dcv, @dcv; +a b +1 1 +1 1 +1 1 +SELECT dt1 > '9999-12-31' AS a, +dt2 > '9999-12-31' AS b +FROM t7; +a b +0 0 +0 0 +1 1 +execute s6 using @dsv, @dsv; +a b +0 0 +0 0 +1 1 +SELECT dt1 > 99991231 AS a, +dt2 > 99991231 AS b +FROM t7; +a b +0 0 +0 0 +1 1 +execute s6 using @iv, @iv; +a b +0 0 +0 0 +1 1 +SELECT dt1 > '9999-12-31 23:59:59.999999' AS a, +dt2 > '9999-12-31 23:59:59.999999' AS b +FROM t7; +a b +0 0 +0 0 +0 0 +execute s6 using @tssv, @tssv; +a b +0 0 +0 0 +0 0 +SELECT dt1 > 99991231235959.999999 AS a, +dt2 > 99991231235959.999999 AS b +FROM t7; +a b +0 0 +0 0 +0 0 +Warnings: +Warning 1441 Datetime function: datetime field overflow +Warning 1292 Incorrect datetime value: '99991231235959.999999' for column 'dt1' at row 1 +Warning 1441 Datetime function: datetime field overflow +Warning 1292 Incorrect datetime value: '99991231235959.999999' for column 'dt1' at row 1 +Warning 1441 Datetime function: datetime field overflow +Warning 1292 Incorrect datetime value: '99991231235959.999999' for column 'dt1' at row 1 +execute s6 using @dcv, @dcv; +a b +0 0 +0 0 +0 0 +set @dsv= "9999-12-31"; +set @tssv= "9999-12-31 23:59:59.999999"; +set @iv= 99991231; +set @dcv= 99991231235959.999999; +SELECT dt1 = '9999-12-31' AS a, +dt2 = '9999-12-31' AS b +FROM t7; +a b +0 0 +0 0 +0 0 +execute s1 using @dsv, @dsv; +a b +0 0 +0 0 +0 0 +SELECT dt1 = 99991231 AS a, +dt2 = 99991231 AS b +FROM t7; +a b +0 0 +0 0 +0 0 +execute s1 using @iv, @iv; +a b +0 0 +0 0 +0 0 +SELECT dt1 = '9999-12-31 23:59:59.999999' AS a, +dt2 = '9999-12-31 23:59:59.999999' AS b +FROM t7; +a b +0 0 +0 0 +0 1 +execute s1 using @tssv, @tssv; +a b +0 0 +0 0 +0 1 +SELECT dt1 = 99991231235959.999999 AS a, +dt2 = 99991231235959.999999 AS b +FROM t7; +a b +0 0 +0 0 +0 1 +Warnings: +Warning 1441 Datetime function: datetime field overflow +Warning 1292 Incorrect datetime value: '99991231235959.999999' for column 'dt1' at row 1 +Warning 1441 Datetime function: datetime field overflow +Warning 1292 Incorrect datetime value: '99991231235959.999999' for column 'dt1' at row 1 +Warning 1441 Datetime function: datetime field overflow +Warning 1292 Incorrect datetime value: '99991231235959.999999' for column 'dt1' at row 1 +execute s1 using @dcv, @dcv; +a b +0 0 +0 0 +0 1 +SELECT dt1 <> '9999-12-31' AS a, +dt2 <> '9999-12-31' AS b +FROM t7; +a b +1 1 +1 1 +1 1 +execute s2 using @dsv, @dsv; +a b +1 1 +1 1 +1 1 +SELECT dt1 <> 99991231 AS a, +dt2 <> 99991231 AS b +FROM t7; +a b +1 1 +1 1 +1 1 +execute s2 using @iv, @iv; +a b +1 1 +1 1 +1 1 +SELECT dt1 <> '9999-12-31 23:59:59.999999' AS a, +dt2 <> '9999-12-31 23:59:59.999999' AS b +FROM t7; +a b +1 1 +1 1 +1 0 +execute s2 using @tssv, @tssv; +a b +1 1 +1 1 +1 0 +SELECT dt1 <> 99991231235959.999999 AS a, +dt2 <> 99991231235959.999999 AS b +FROM t7; +a b +1 1 +1 1 +1 0 +Warnings: +Warning 1441 Datetime function: datetime field overflow +Warning 1292 Incorrect datetime value: '99991231235959.999999' for column 'dt1' at row 1 +Warning 1441 Datetime function: datetime field overflow +Warning 1292 Incorrect datetime value: '99991231235959.999999' for column 'dt1' at row 1 +Warning 1441 Datetime function: datetime field overflow +Warning 1292 Incorrect datetime value: '99991231235959.999999' for column 'dt1' at row 1 +execute s2 using @dcv, @dcv; +a b +1 1 +1 1 +1 0 +SELECT dt1 < '9999-12-31' AS a, +dt2 < '9999-12-31' AS b +FROM t7; +a b +1 1 +1 1 +0 0 +execute s3 using @dsv, @dsv; +a b +1 1 +1 1 +0 0 +SELECT dt1 < 99991231 AS a, +dt2 < 99991231 AS b +FROM t7; +a b +1 1 +1 1 +0 0 +execute s3 using @iv, @iv; +a b +1 1 +1 1 +0 0 +SELECT dt1 < '9999-12-31 23:59:59.999999' AS a, +dt2 < '9999-12-31 23:59:59.999999' AS b +FROM t7; +a b +1 1 +1 1 +1 0 +execute s3 using @tssv, @tssv; +a b +1 1 +1 1 +1 0 +SELECT dt1 < 99991231235959.999999 AS a, +dt2 < 99991231235959.999999 AS b +FROM t7; +a b +1 1 +1 1 +1 0 +Warnings: +Warning 1441 Datetime function: datetime field overflow +Warning 1292 Incorrect datetime value: '99991231235959.999999' for column 'dt1' at row 1 +Warning 1441 Datetime function: datetime field overflow +Warning 1292 Incorrect datetime value: '99991231235959.999999' for column 'dt1' at row 1 +Warning 1441 Datetime function: datetime field overflow +Warning 1292 Incorrect datetime value: '99991231235959.999999' for column 'dt1' at row 1 +execute s3 using @dcv, @dcv; +a b +1 1 +1 1 +1 0 +SELECT dt1 >= '9999-12-31' AS a, +dt2 >= '9999-12-31' AS b +FROM t7; +a b +0 0 +0 0 +1 1 +execute s4 using @dsv, @dsv; +a b +0 0 +0 0 +1 1 +SELECT dt1 >= 99991231 AS a, +dt2 >= 99991231 AS b +FROM t7; +a b +0 0 +0 0 +1 1 +execute s4 using @iv, @iv; +a b +0 0 +0 0 +1 1 +SELECT dt1 >= '9999-12-31 23:59:59.999999' AS a, +dt2 >= '9999-12-31 23:59:59.999999' AS b +FROM t7; +a b +0 0 +0 0 +0 1 +execute s4 using @tssv, @tssv; +a b +0 0 +0 0 +0 1 +SELECT dt1 >= 99991231235959.999999 AS a, +dt2 >= 99991231235959.999999 AS b +FROM t7; +a b +0 0 +0 0 +0 1 +Warnings: +Warning 1441 Datetime function: datetime field overflow +Warning 1292 Incorrect datetime value: '99991231235959.999999' for column 'dt1' at row 1 +Warning 1441 Datetime function: datetime field overflow +Warning 1292 Incorrect datetime value: '99991231235959.999999' for column 'dt1' at row 1 +Warning 1441 Datetime function: datetime field overflow +Warning 1292 Incorrect datetime value: '99991231235959.999999' for column 'dt1' at row 1 +execute s4 using @dcv, @dcv; +a b +0 0 +0 0 +0 1 +SELECT dt1 <= '9999-12-31' AS a, +dt2 <= '9999-12-31' AS b +FROM t7; +a b +1 1 +1 1 +0 0 +execute s5 using @dsv, @dsv; +a b +1 1 +1 1 +0 0 +SELECT dt1 <= 99991231 AS a, +dt2 <= 99991231 AS b +FROM t7; +a b +1 1 +1 1 +0 0 +execute s5 using @iv, @iv; +a b +1 1 +1 1 +0 0 +SELECT dt1 <= '9999-12-31 23:59:59.999999' AS a, +dt2 <= '9999-12-31 23:59:59.999999' AS b +FROM t7; +a b +1 1 +1 1 +1 1 +execute s5 using @tssv, @tssv; +a b +1 1 +1 1 +1 1 +SELECT dt1 <= 99991231235959.999999 AS a, +dt2 <= 99991231235959.999999 AS b +FROM t7; +a b +1 1 +1 1 +1 1 +Warnings: +Warning 1441 Datetime function: datetime field overflow +Warning 1292 Incorrect datetime value: '99991231235959.999999' for column 'dt1' at row 1 +Warning 1441 Datetime function: datetime field overflow +Warning 1292 Incorrect datetime value: '99991231235959.999999' for column 'dt1' at row 1 +Warning 1441 Datetime function: datetime field overflow +Warning 1292 Incorrect datetime value: '99991231235959.999999' for column 'dt1' at row 1 +execute s5 using @dcv, @dcv; +a b +1 1 +1 1 +1 1 +SELECT dt1 > '9999-12-31' AS a, +dt2 > '9999-12-31' AS b +FROM t7; +a b +0 0 +0 0 +1 1 +execute s6 using @dsv, @dsv; +a b +0 0 +0 0 +1 1 +SELECT dt1 > 99991231 AS a, +dt2 > 99991231 AS b +FROM t7; +a b +0 0 +0 0 +1 1 +execute s6 using @iv, @iv; +a b +0 0 +0 0 +1 1 +SELECT dt1 > '9999-12-31 23:59:59.999999' AS a, +dt2 > '9999-12-31 23:59:59.999999' AS b +FROM t7; +a b +0 0 +0 0 +0 0 +execute s6 using @tssv, @tssv; +a b +0 0 +0 0 +0 0 +SELECT dt1 > 99991231235959.999999 AS a, +dt2 > 99991231235959.999999 AS b +FROM t7; +a b +0 0 +0 0 +0 0 +Warnings: +Warning 1441 Datetime function: datetime field overflow +Warning 1292 Incorrect datetime value: '99991231235959.999999' for column 'dt1' at row 1 +Warning 1441 Datetime function: datetime field overflow +Warning 1292 Incorrect datetime value: '99991231235959.999999' for column 'dt1' at row 1 +Warning 1441 Datetime function: datetime field overflow +Warning 1292 Incorrect datetime value: '99991231235959.999999' for column 'dt1' at row 1 +execute s6 using @dcv, @dcv; +a b +0 0 +0 0 +0 0 +DEALLOCATE PREPARE s1; +DEALLOCATE PREPARE s2; +DEALLOCATE PREPARE s3; +DEALLOCATE PREPARE s4; +DEALLOCATE PREPARE s5; +DEALLOCATE PREPARE s6; +DROP TABLE t7; diff --git a/mysql-test/r/func_default.result-pq b/mysql-test/r/func_default.result-pq new file mode 100644 index 000000000000..e3aa47af2fab --- /dev/null +++ b/mysql-test/r/func_default.result-pq @@ -0,0 +1,32 @@ +drop table if exists t1,t2; +create table t1(str varchar(10) default 'def',strnull varchar(10),intg int default '10',rel double default '3.14'); +insert into t1 values ('','',0,0.0); +analyze table t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +select default(str), default(strnull), default(intg), default(rel) from t1; +default(str) default(strnull) default(intg) default(rel) +def NULL 10 3.14 +explain select default(str), default(strnull), default(intg), default(rel) from t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select default(`test`.`t1`.`str`) AS `default(str)`,default(`test`.`t1`.`strnull`) AS `default(strnull)`,default(`test`.`t1`.`intg`) AS `default(intg)`,default(`test`.`t1`.`rel`) AS `default(rel)` from `test`.`t1` +select * from t1 where str <> default(str); +str strnull intg rel + 0 0 +explain select * from t1 where str <> default(str); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`str` AS `str`,`test`.`t1`.`strnull` AS `strnull`,`test`.`t1`.`intg` AS `intg`,`test`.`t1`.`rel` AS `rel` from `test`.`t1` where (`test`.`t1`.`str` <> (default(`test`.`t1`.`str`))) +drop table t1; +CREATE TABLE t1 (id int(11), s varchar(20)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (1, 'one'), (2, 'two'), (3, 'three'); +SELECT s, 32 AS mi FROM t1 GROUP BY s HAVING DEFAULT(mi) IS NULL; +ERROR HY000: Field 'mi' doesn't have a default value +DROP TABLE t1; diff --git a/mysql-test/r/func_group_innodb.result-pq b/mysql-test/r/func_group_innodb.result-pq new file mode 100644 index 000000000000..dcd5084bda61 --- /dev/null +++ b/mysql-test/r/func_group_innodb.result-pq @@ -0,0 +1,217 @@ +create table t1 (USR_ID integer not null, MAX_REQ integer not null, constraint PK_SEA_USER primary key (USR_ID)) engine=InnoDB; +insert into t1 values (1, 3); +select count(*) + MAX_REQ - MAX_REQ + MAX_REQ - MAX_REQ + MAX_REQ - MAX_REQ + MAX_REQ - MAX_REQ + MAX_REQ - MAX_REQ from t1 group by MAX_REQ; +count(*) + MAX_REQ - MAX_REQ + MAX_REQ - MAX_REQ + MAX_REQ - MAX_REQ + MAX_REQ - MAX_REQ + MAX_REQ - MAX_REQ +1 +select Case When Count(*) < MAX_REQ Then 1 Else 0 End from t1 where t1.USR_ID = 1 group by MAX_REQ; +Case When Count(*) < MAX_REQ Then 1 Else 0 End +1 +drop table t1; +create table t1m (a int) engine=innodb; +create table t1i (a int) engine=innodb; +create table t2m (a int) engine=innodb; +create table t2i (a int) engine=innodb; +insert into t2m values (5); +insert into t2i values (5); +select min(a) from t1m; +min(a) +NULL +select min(7) from t1m; +min(7) +NULL +select min(7) from DUAL; +min(7) +7 +explain select min(7) from t2m join t1m; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t2m NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t1m NULL ALL NULL NULL NULL NULL 1 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select min(7) AS `min(7)` from `test`.`t2m` join `test`.`t1m` +select min(7) from t2m join t1m; +min(7) +NULL +select max(a) from t1m; +max(a) +NULL +select max(7) from t1m; +max(7) +NULL +select max(7) from DUAL; +max(7) +7 +explain select max(7) from t2m join t1m; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t2m NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t1m NULL ALL NULL NULL NULL NULL 1 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select max(7) AS `max(7)` from `test`.`t2m` join `test`.`t1m` +select max(7) from t2m join t1m; +max(7) +NULL +select 1, min(a) from t1m where a=99; +1 min(a) +1 NULL +select 1, min(a) from t1m where 1=99; +1 min(a) +1 NULL +select 1, min(1) from t1m where a=99; +1 min(1) +1 NULL +select 1, min(1) from t1m where 1=99; +1 min(1) +1 NULL +select 1, max(a) from t1m where a=99; +1 max(a) +1 NULL +select 1, max(a) from t1m where 1=99; +1 max(a) +1 NULL +select 1, max(1) from t1m where a=99; +1 max(1) +1 NULL +select 1, max(1) from t1m where 1=99; +1 max(1) +1 NULL +select min(a) from t1i; +min(a) +NULL +select min(7) from t1i; +min(7) +NULL +select min(7) from DUAL; +min(7) +7 +explain select min(7) from t2i join t1i; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t2i NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t1i NULL ALL NULL NULL NULL NULL 1 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select min(7) AS `min(7)` from `test`.`t2i` join `test`.`t1i` +select min(7) from t2i join t1i; +min(7) +NULL +select max(a) from t1i; +max(a) +NULL +select max(7) from t1i; +max(7) +NULL +select max(7) from DUAL; +max(7) +7 +explain select max(7) from t2i join t1i; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t2i NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t1i NULL ALL NULL NULL NULL NULL 1 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select max(7) AS `max(7)` from `test`.`t2i` join `test`.`t1i` +select max(7) from t2i join t1i; +max(7) +NULL +select 1, min(a) from t1i where a=99; +1 min(a) +1 NULL +select 1, min(a) from t1i where 1=99; +1 min(a) +1 NULL +select 1, min(1) from t1i where a=99; +1 min(1) +1 NULL +select 1, min(1) from t1i where 1=99; +1 min(1) +1 NULL +select 1, max(a) from t1i where a=99; +1 max(a) +1 NULL +select 1, max(a) from t1i where 1=99; +1 max(a) +1 NULL +select 1, max(1) from t1i where a=99; +1 max(1) +1 NULL +select 1, max(1) from t1i where 1=99; +1 max(1) +1 NULL +explain select count(*), min(7), max(7) from t1m, t1i; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1m NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t1i NULL ALL NULL NULL NULL NULL 1 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select count(0) AS `count(*)`,min(7) AS `min(7)`,max(7) AS `max(7)` from `test`.`t1m` join `test`.`t1i` +select count(*), min(7), max(7) from t1m, t1i; +count(*) min(7) max(7) +0 NULL NULL +explain select count(*), min(7), max(7) from t1m, t2i; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1m NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t2i NULL ALL NULL NULL NULL NULL 1 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select count(0) AS `count(*)`,min(7) AS `min(7)`,max(7) AS `max(7)` from `test`.`t1m` join `test`.`t2i` +select count(*), min(7), max(7) from t1m, t2i; +count(*) min(7) max(7) +0 NULL NULL +explain select count(*), min(7), max(7) from t2m, t1i; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t2m NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t1i NULL ALL NULL NULL NULL NULL 1 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select count(0) AS `count(*)`,min(7) AS `min(7)`,max(7) AS `max(7)` from `test`.`t2m` join `test`.`t1i` +select count(*), min(7), max(7) from t2m, t1i; +count(*) min(7) max(7) +0 NULL NULL +drop table t1m, t1i, t2m, t2i; +# +# Bug #57954: BIT_AND function returns incorrect results when +# semijoin=on +CREATE TABLE c ( +pk INT, +col_varchar_key VARCHAR(1), +PRIMARY KEY (pk), +KEY col_varchar_key (col_varchar_key) +) ENGINE=InnoDB; +INSERT INTO c VALUES (11,NULL); +INSERT INTO c VALUES (16,'c'); +CREATE TABLE bb ( +pk INT, +col_varchar_key VARCHAR(1), +PRIMARY KEY (pk), +KEY col_varchar_key (col_varchar_key) +) ENGINE=InnoDB; +INSERT INTO bb VALUES (10,NULL); +SELECT straight_join BIT_AND(c.pk) +FROM +bb, c +WHERE c.col_varchar_key='ABC' +ORDER BY c.pk; +BIT_AND(c.pk) +18446744073709551615 +DROP TABLE c,bb; +# +# Bug #58050: BIT_OR and BIT_XOR return incorrect results when +# semijoin=on +# +CREATE TABLE t1 (pk INT PRIMARY KEY, b INT, c INT) ENGINE=InnoDB; +INSERT INTO t1 VALUES(1, 1, 1); +CREATE TABLE t2 (pk INT PRIMARY KEY, b INT, c INT) ENGINE=InnoDB; +INSERT INTO t2 VALUES (1, 1, NULL); +SELECT t1.* FROM t1 JOIN t2 ON t1.c=t2.c WHERE t1.pk=1; +pk b c +SELECT BIT_OR(t1.b) FROM t1 JOIN t2 ON t1.c=t2.c WHERE t1.pk=1; +BIT_OR(t1.b) +0 +SELECT BIT_AND(t1.b) FROM t1 JOIN t2 ON t1.c=t2.c WHERE t1.pk=1; +BIT_AND(t1.b) +18446744073709551615 +SELECT BIT_XOR(t1.b) FROM t1 JOIN t2 ON t1.c=t2.c WHERE t1.pk=1; +BIT_XOR(t1.b) +0 +DROP TABLE t1, t2; +End of 5.5 tests diff --git a/mysql-test/r/func_if.result-pq b/mysql-test/r/func_if.result-pq new file mode 100644 index 000000000000..d883595d4bb9 --- /dev/null +++ b/mysql-test/r/func_if.result-pq @@ -0,0 +1,324 @@ +drop table if exists t1; +select IF(0,"ERROR","this"),IF(1,"is","ERROR"),IF(NULL,"ERROR","a"),IF(1,2,3)|0,IF(1,2.0,3.0)+0 ; +IF(0,"ERROR","this") IF(1,"is","ERROR") IF(NULL,"ERROR","a") IF(1,2,3)|0 IF(1,2.0,3.0)+0 +this is a 2 2.0 +CREATE TABLE t1 (st varchar(255) NOT NULL, u int(11) NOT NULL); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES ('a',1),('A',1),('aa',1),('AA',1),('a',1),('aaa',0),('BBB',0); +select if(1,st,st) s from t1 order by s; +s +a +A +a +aa +AA +aaa +BBB +select if(u=1,st,st) s from t1 order by s; +s +a +A +a +aa +AA +aaa +BBB +select if(u=1,binary st,st) s from t1 order by s; +s +A +AA +BBB +a +a +aa +aaa +select if(u=1,st,binary st) s from t1 where st like "%a%" order by s; +s +A +AA +a +a +aa +aaa +analyze table t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +explain select if(u=1,st,binary st) s from t1 where st like "%a%" order by s; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 7 14.29 Using where; Using filesort +Warnings: +Note 1003 /* select#1 */ select if((`test`.`t1`.`u` = 1),`test`.`t1`.`st`,cast(`test`.`t1`.`st` as char charset binary)) AS `s` from `test`.`t1` where (`test`.`t1`.`st` like '%a%') order by `s` +select nullif(u, 1) from t1; +nullif(u, 1) +NULL +NULL +NULL +NULL +NULL +0 +0 +explain select nullif(u, 1) from t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 7 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select nullif(`test`.`t1`.`u`,1) AS `nullif(u, 1)` from `test`.`t1` +drop table t1; +select nullif(1,'test'); +nullif(1,'test') +1 +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'test' +select NULLIF(NULL,NULL), NULLIF(NULL,1), NULLIF(NULL,1.0), NULLIF(NULL,"test"); +NULLIF(NULL,NULL) NULLIF(NULL,1) NULLIF(NULL,1.0) NULLIF(NULL,"test") +NULL NULL NULL NULL +select NULLIF(1,NULL), NULLIF(1.0, NULL), NULLIF("test", NULL); +NULLIF(1,NULL) NULLIF(1.0, NULL) NULLIF("test", NULL) +1 1.0 test +create table t1 (num double(12,2)); +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +insert into t1 values (144.54); +select sum(if(num is null,0.00,num)) from t1; +sum(if(num is null,0.00,num)) +144.54 +drop table t1; +create table t1 (x int, y int); +insert into t1 values (0,6),(10,16),(20,26),(30,10),(40,46),(50,56); +select min(if(y -x > 5,y,NULL)), max(if(y - x > 5,y,NULL)) from t1; +min(if(y -x > 5,y,NULL)) max(if(y - x > 5,y,NULL)) +6 56 +drop table t1; +create table t1 (a int); +insert t1 values (1),(2); +select if(1>2,a,avg(a)) from t1; +if(1>2,a,avg(a)) +1.5000 +drop table t1; +SELECT NULLIF(5,5) IS NULL, NULLIF(5,5) IS NOT NULL; +NULLIF(5,5) IS NULL NULLIF(5,5) IS NOT NULL +1 0 +CREATE TABLE `t1` ( +`id` int(11) NOT NULL , +`date` int(10) default NULL, +`text` varchar(32) NOT NULL +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (1,1110000000,'Day 1'),(2,1111000000,'Day 2'),(3,1112000000,'Day 3'); +SELECT id, IF(date IS NULL, '-', FROM_UNIXTIME(date, '%d-%m-%Y')) AS date_ord, text FROM t1 ORDER BY date_ord ASC; +id date_ord text +1 05-03-2005 Day 1 +2 16-03-2005 Day 2 +3 28-03-2005 Day 3 +SELECT id, IF(date IS NULL, '-', FROM_UNIXTIME(date, '%d-%m-%Y')) AS date_ord, text FROM t1 ORDER BY date_ord DESC; +id date_ord text +3 28-03-2005 Day 3 +2 16-03-2005 Day 2 +1 05-03-2005 Day 1 +DROP TABLE t1; +CREATE TABLE t1 (a CHAR(10)); +INSERT INTO t1 VALUES ('aaa'), (NULL), (''), ('bbb'); +SELECT a, NULLIF(a,'') FROM t1; +a NULLIF(a,'') +aaa aaa +NULL NULL + NULL +bbb bbb +SELECT a, NULLIF(a,'') FROM t1 WHERE NULLIF(a,'') IS NULL; +a NULLIF(a,'') +NULL NULL + NULL +DROP TABLE t1; +create table t1 (f1 int, f2 int); +insert into t1 values(1,1),(0,0); +select f1, f2, if(f1, 40.0, 5.00) from t1 group by f1 order by f2; +f1 f2 if(f1, 40.0, 5.00) +0 0 5.00 +1 1 40.00 +drop table t1; +select if(0, 18446744073709551610, 18446744073709551610); +if(0, 18446744073709551610, 18446744073709551610) +18446744073709551610 +CREATE TABLE t1(a DECIMAL(10,3)); +SELECT t1.a, +IF((ROUND(t1.a,2)=1), 2, +IF((ROUND(t1.a,2)=1), 2, +IF((ROUND(t1.a,2)=1), 2, +IF((ROUND(t1.a,2)=1), 2, +IF((ROUND(t1.a,2)=1), 2, +IF((ROUND(t1.a,2)=1), 2, +IF((ROUND(t1.a,2)=1), 2, +IF((ROUND(t1.a,2)=1), 2, +IF((ROUND(t1.a,2)=1), 2, +IF((ROUND(t1.a,2)=1), 2, +IF((ROUND(t1.a,2)=1), 2, +IF((ROUND(t1.a,2)=1), 2, +IF((ROUND(t1.a,2)=1), 2, +IF((ROUND(t1.a,2)=1), 2, +IF((ROUND(t1.a,2)=1), 2, +IF((ROUND(t1.a,2)=1), 2, +IF((ROUND(t1.a,2)=1), 2, +IF((ROUND(t1.a,2)=1), 2, +IF((ROUND(t1.a,2)=1), 2, +IF((ROUND(t1.a,2)=1), 2, +IF((ROUND(t1.a,2)=1), 2, +IF((ROUND(t1.a,2)=1), 2, +IF((ROUND(t1.a,2)=1), 2, +IF((ROUND(t1.a,2)=1), 2, +IF((ROUND(t1.a,2)=1), 2, +IF((ROUND(t1.a,2)=1), 2, +IF((ROUND(t1.a,2)=1), 2, +IF((ROUND(t1.a,2)=1), 2, +IF((ROUND(t1.a,2)=1), 2, +IF((ROUND(t1.a,2)=1), 2,0)))))))))))))))))))))))))))))) + 1 +FROM t1; +a IF((ROUND(t1.a,2)=1), 2, +IF((ROUND(t1.a,2)=1), 2, +IF((ROUND(t1.a,2)=1), 2, +IF((ROUND(t1.a,2)=1), 2, +IF((ROUND(t1.a,2)=1), 2, +IF((ROUND(t1.a,2)=1), 2, +IF((ROUND(t1.a,2)=1), 2, +IF((ROUND(t1.a,2)=1), 2, +IF((ROUND(t1.a,2)=1), 2, +IF((ROUND(t1.a,2)=1), 2, +IF((R +DROP TABLE t1; +CREATE TABLE t1 (c LONGTEXT); +INSERT INTO t1 VALUES(1), (2), (3), (4), ('12345678901234567890'); +SELECT * FROM (SELECT MAX(IF(1, CAST(c AS UNSIGNED), 0)) FROM t1) AS te; +MAX(IF(1, CAST(c AS UNSIGNED), 0)) +12345678901234567890 +SELECT * FROM (SELECT MAX(IFNULL(CAST(c AS UNSIGNED), 0)) FROM t1) AS te; +MAX(IFNULL(CAST(c AS UNSIGNED), 0)) +12345678901234567890 +DROP TABLE t1; +End of 5.0 tests +# +# Bug#55077: Assertion failed: width > 0 && to != ((void *)0), file .\dtoa.c +# +CREATE TABLE t1 (a LONGBLOB, b DOUBLE); +INSERT INTO t1 VALUES (NULL, 0), (NULL, 1); +SELECT IF(b, (SELECT a FROM t1 LIMIT 1), b) c FROM t1 GROUP BY c; +c +0 +NULL +DROP TABLE t1; +# +# Bug#12620084 +# ASSERTION WHEN CHECKING FIELD_TYPES[FIELD_POS] AND IT'S MYSQL_TYPE_NULL +# +SELECT if(0, (SELECT min('hello')), NULL); +if(0, (SELECT min('hello')), NULL) +NULL +SELECT if(1, (SELECT min('hello')), NULL); +if(1, (SELECT min('hello')), NULL) +hello +SELECT if(0, NULL, (SELECT min('hello'))); +if(0, NULL, (SELECT min('hello'))) +hello +SELECT if(1, NULL, (SELECT min('hello'))); +if(1, NULL, (SELECT min('hello'))) +NULL +# +# Bug#12532830 +# SIGFPE OR ASSERTION (PRECISION <= ((9 * 9) - 8*2)) && (DEC <= 30) +# +select +sum(distinct(if('a', +(select adddate(elt(convert(9999999999999999999999999999999999999,decimal(64,0)),count(*)), +interval 1 day)) +, .1))) as foo; +foo +0.1 +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'a' +# +# Bug#22148586 IF(BOOL, DATE STR, DATE STR) THROWS ERROR IN UPDATE +# +CREATE TABLE t1(c1 INT); +INSERT INTO t1 VALUES(1); +UPDATE t1 SET c1 = 2 WHERE IF(true, '2015-01-01', '2015-01-01') IS NOT NULL; +DROP TABLE t1; +# +# Bug#24492965 ERROR RESULTS FROM CALCULATION +# +CREATE TABLE test_grids_1 ( +unq_id int(11) NOT NULL DEFAULT '0', +var_fld int(11) DEFAULT '0' +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO test_grids_1 VALUES +(1,4500), +(2,6000); +CREATE TABLE test_grid_dtl_1 ( +dtl_id int(11) NOT NULL DEFAULT '0', +unq_id int(11) DEFAULT '0' +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO test_grid_dtl_1 VALUES +(1,1), +(2,1), +(3,2); +SELECT g.calc_var, g.if_var, g.case_var +FROM +( +SELECT unq_id, +IF ( var_fld > 5000, ( 1 / var_fld ) , 5000 ) calc_var, +IF ( var_fld > 5000, ( 00001 / var_fld ) , 5000 ) if_var, +CASE var_fld > 5000 WHEN TRUE THEN ( 1 / var_fld ) ELSE 5000 END case_var +FROM +test_grids_1 +) g +JOIN +test_grid_dtl_1 d USING (unq_id) +ORDER BY 1 +; +calc_var if_var case_var +0.0002 0.0002 0.0002 +5000.0000 5000.0000 5000.0000 +5000.0000 5000.0000 5000.0000 +DROP TABLE test_grids_1, test_grid_dtl_1; +# Bug#25669606: regression: assertion failed: !is_temporal() +DO NULLIF(CAST(DATABASE() AS TIME), 1); +Warnings: +Warning 1292 Truncated incorrect time value: 'test' +Warning 1292 Truncated incorrect time value: 'test' +DO NULLIF(CAST(DATABASE() AS DATE), 1); +Warnings: +Warning 1292 Incorrect datetime value: 'test' +Warning 1292 Incorrect datetime value: 'test' +DO NULLIF(CAST(DATABASE() AS DATETIME), 1); +Warnings: +Warning 1292 Incorrect datetime value: 'test' +Warning 1292 Incorrect datetime value: 'test' +# +# Bug#28007237 NULLIF returns boolean in context of JSON_ARRAYAGG and JSON_OBJECTAGG's value +# +SELECT NULLIF(1,2); +NULLIF(1,2) +1 +SELECT JSON_ARRAYAGG(NULLIF(1,2)); +JSON_ARRAYAGG(NULLIF(1,2)) +[1] +SELECT JSON_ARRAYAGG(CASE WHEN 1 = 2 THEN NULL ELSE 1 END); +JSON_ARRAYAGG(CASE WHEN 1 = 2 THEN NULL ELSE 1 END) +[1] +SELECT NULLIF(true,false); +NULLIF(true,false) +1 +SELECT JSON_ARRAYAGG(NULLIF(true,false)); +JSON_ARRAYAGG(NULLIF(true,false)) +[1] +SELECT JSON_ARRAYAGG(CASE WHEN true = false THEN NULL ELSE true END); +JSON_ARRAYAGG(CASE WHEN true = false THEN NULL ELSE true END) +[1] +# Bug#32231557: Field_blob::store_to_mem: assertion `field_charset == cs' failed. +DO GROUP_CONCAT(NULLIF(ELT(1, @e), POINT(250,41)) ORDER BY 1); diff --git a/mysql-test/r/func_in_all.result-pq b/mysql-test/r/func_in_all.result-pq new file mode 100644 index 000000000000..c5662c63988a --- /dev/null +++ b/mysql-test/r/func_in_all.result-pq @@ -0,0 +1,998 @@ +set optimizer_switch='semijoin=on,materialization=on,firstmatch=on,loosescan=on,index_condition_pushdown=on,mrr=on,mrr_cost_based=off'; +drop table if exists t1, t2; +select 1 in (1,2,3); +1 in (1,2,3) +1 +select 10 in (1,2,3); +10 in (1,2,3) +0 +select NULL in (1,2,3); +NULL in (1,2,3) +NULL +select 1 in (1,NULL,3); +1 in (1,NULL,3) +1 +select 3 in (1,NULL,3); +3 in (1,NULL,3) +1 +select 10 in (1,NULL,3); +10 in (1,NULL,3) +NULL +select 1.5 in (1.5,2.5,3.5); +1.5 in (1.5,2.5,3.5) +1 +select 10.5 in (1.5,2.5,3.5); +10.5 in (1.5,2.5,3.5) +0 +select NULL in (1.5,2.5,3.5); +NULL in (1.5,2.5,3.5) +NULL +select 1.5 in (1.5,NULL,3.5); +1.5 in (1.5,NULL,3.5) +1 +select 3.5 in (1.5,NULL,3.5); +3.5 in (1.5,NULL,3.5) +1 +select 10.5 in (1.5,NULL,3.5); +10.5 in (1.5,NULL,3.5) +NULL +CREATE TABLE t1 (a int, b int, c int); +insert into t1 values (1,2,3), (1,NULL,3); +select 1 in (a,b,c) from t1; +1 in (a,b,c) +1 +1 +select 3 in (a,b,c) from t1; +3 in (a,b,c) +1 +1 +select 10 in (a,b,c) from t1; +10 in (a,b,c) +0 +NULL +select NULL in (a,b,c) from t1; +NULL in (a,b,c) +NULL +NULL +drop table t1; +CREATE TABLE t1 (a float, b float, c float); +insert into t1 values (1.5,2.5,3.5), (1.5,NULL,3.5); +select 1.5 in (a,b,c) from t1; +1.5 in (a,b,c) +1 +1 +select 3.5 in (a,b,c) from t1; +3.5 in (a,b,c) +1 +1 +select 10.5 in (a,b,c) from t1; +10.5 in (a,b,c) +0 +NULL +drop table t1; +CREATE TABLE t1 (a varchar(10), b varchar(10), c varchar(10)); +insert into t1 values ('A','BC','EFD'), ('A',NULL,'EFD'); +select 'A' in (a,b,c) from t1; +'A' in (a,b,c) +1 +1 +select 'EFD' in (a,b,c) from t1; +'EFD' in (a,b,c) +1 +1 +select 'XSFGGHF' in (a,b,c) from t1; +'XSFGGHF' in (a,b,c) +0 +NULL +drop table t1; +CREATE TABLE t1 (field char(1)); +INSERT INTO t1 VALUES ('A'),(NULL); +SELECT * from t1 WHERE field IN (NULL); +field +SELECT * from t1 WHERE field NOT IN (NULL); +field +SELECT * from t1 where field = field; +field +A +SELECT * from t1 where field <=> field; +field +A +NULL +DELETE FROM t1 WHERE field NOT IN (NULL); +SELECT * FROM t1; +field +A +NULL +drop table t1; +create table t1 (id int(10) primary key); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t1 values (1),(2),(3),(4),(5),(6),(7),(8),(9); +select * from t1 where id in (2,5,9); +id +2 +5 +9 +drop table t1; +create table t1 ( +a char(1) character set latin1 collate latin1_general_ci, +b char(1) character set latin1 collate latin1_swedish_ci, +c char(1) character set latin1 collate latin1_danish_ci +); +insert into t1 values ('A','B','C'); +insert into t1 values ('a','c','c'); +select * from t1 where a in (b); +ERROR HY000: Illegal mix of collations (latin1_general_ci,IMPLICIT) and (latin1_swedish_ci,IMPLICIT) for operation '=' +select * from t1 where a in (b,c); +ERROR HY000: Illegal mix of collations (latin1_general_ci,IMPLICIT), (latin1_swedish_ci,IMPLICIT), (latin1_danish_ci,IMPLICIT) for operation ' IN ' +select * from t1 where 'a' in (a,b,c); +ERROR HY000: Illegal mix of collations for operation ' IN ' +select * from t1 where 'a' in (a); +a b c +A B C +a c c +select * from t1 where a in ('a'); +a b c +A B C +a c c +set names latin1; +select * from t1 where 'a' collate latin1_general_ci in (a,b,c); +a b c +A B C +a c c +select * from t1 where 'a' collate latin1_bin in (a,b,c); +a b c +a c c +select * from t1 where 'a' in (a,b,c collate latin1_bin); +a b c +a c c +explain select * from t1 where 'a' in (a,b,c collate latin1_bin); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` where ('a' in (`test`.`t1`.`a`,`test`.`t1`.`b`,(`test`.`t1`.`c` collate latin1_bin))) +drop table t1; +set names utf8mb4; +set names utf8; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +create table t1 (a char(10) character set utf8 not null); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +insert into t1 values ('bbbb'),(_koi8r x'C3C3C3C3'),(_latin1 x'C4C4C4C4'); +select a from t1 where a in ('bbbb',_koi8r x'C3C3C3C3',_latin1 x'C4C4C4C4') order by a; +a +ÄÄÄÄ +bbbb +цццц +drop table t1; +create table t1 (a char(10) character set latin1 not null); +insert into t1 values ('a'),('b'),('c'); +select a from t1 where a IN ('a','b','c') order by a; +a +a +b +c +drop table t1; +set names latin1; +select '1.0' in (1,2); +'1.0' in (1,2) +1 +select 1 in ('1.0',2); +1 in ('1.0',2) +1 +select 1 in (1,'2.0'); +1 in (1,'2.0') +1 +select 1 in ('1.0',2.0); +1 in ('1.0',2.0) +1 +select 1 in (1.0,'2.0'); +1 in (1.0,'2.0') +1 +select 1 in ('1.1',2); +1 in ('1.1',2) +0 +select 1 in ('1.1',2.0); +1 in ('1.1',2.0) +0 +create table t1 (a char(2) character set binary); +insert into t1 values ('aa'), ('bb'); +select * from t1 where a in (NULL, 'aa'); +a +aa +drop table t1; +create table t1 (id int, key(id)); +insert into t1 values (1),(2),(3); +select count(*) from t1 where id not in (1); +count(*) +2 +select count(*) from t1 where id not in (1,2); +count(*) +1 +drop table t1; +DROP TABLE IF EXISTS t1; +CREATE TABLE t1 SELECT 1 IN (2, NULL); +SELECT should return NULL. +SELECT * FROM t1; +1 IN (2, NULL) +NULL +DROP TABLE t1; +End of 4.1 tests +CREATE TABLE t1 (a int PRIMARY KEY); +INSERT INTO t1 VALUES (44), (45), (46); +SELECT * FROM t1 WHERE a IN (45); +a +45 +SELECT * FROM t1 WHERE a NOT IN (0, 45); +a +44 +46 +SELECT * FROM t1 WHERE a NOT IN (45); +a +44 +46 +CREATE VIEW v1 AS SELECT * FROM t1 WHERE a NOT IN (45); +SHOW CREATE VIEW v1; +View Create View character_set_client collation_connection +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`a` AS `a` from `t1` where (`t1`.`a` <> 45) latin1 latin1_swedish_ci +SELECT * FROM v1; +a +44 +46 +DROP VIEW v1; +DROP TABLE t1; +create table t1 (a int); +insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t2 (a int, filler char(200), key(a)); +insert into t2 select C.a*2, 'no' from t1 A, t1 B, t1 C; +insert into t2 select C.a*2+1, 'yes' from t1 C; +explain +select * from t2 where a NOT IN (0, 2,4,6,8,10,12,14,16,18); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 100.00 Parallel execute (4 workers) +2 SIMPLE t2 NULL range a a 5 NULL 11 100.00 Using index condition; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`filler` AS `filler` from `test`.`t2` where (`test`.`t2`.`a` not in (0,2,4,6,8,10,12,14,16,18)) +select * from t2 where a NOT IN (0, 2,4,6,8,10,12,14,16,18); +a filler +1 yes +3 yes +5 yes +7 yes +9 yes +11 yes +13 yes +15 yes +17 yes +19 yes +explain select * from t2 force index(a) where a NOT IN (2,2,2,2,2,2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 910 100.00 Parallel execute (3 workers) +2 SIMPLE t2 NULL range a a 5 NULL 910 100.00 Using index condition; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`filler` AS `filler` from `test`.`t2` FORCE INDEX (`a`) where (`test`.`t2`.`a` not in (2,2,2,2,2,2)) +explain select * from t2 force index(a) where a <> 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 910 100.00 Parallel execute (3 workers) +2 SIMPLE t2 NULL range a a 5 NULL 910 100.00 Using index condition; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`filler` AS `filler` from `test`.`t2` FORCE INDEX (`a`) where (`test`.`t2`.`a` <> 2) +drop table t2; +create table t2 (a datetime, filler char(200), key(a)); +insert into t2 select '2006-04-25 10:00:00' + interval C.a minute, +'no' from t1 A, t1 B, t1 C where C.a % 2 = 0; +insert into t2 select '2006-04-25 10:00:00' + interval C.a*2+1 minute, +'yes' from t1 C; +explain +select * from t2 where a NOT IN ( +'2006-04-25 10:00:00','2006-04-25 10:02:00','2006-04-25 10:04:00', +'2006-04-25 10:06:00', '2006-04-25 10:08:00'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 100.00 Parallel execute (4 workers) +2 SIMPLE t2 NULL range a a 6 NULL 11 100.00 Using index condition; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`filler` AS `filler` from `test`.`t2` where (`test`.`t2`.`a` not in ('2006-04-25 10:00:00','2006-04-25 10:02:00','2006-04-25 10:04:00','2006-04-25 10:06:00','2006-04-25 10:08:00')) +select * from t2 where a NOT IN ( +'2006-04-25 10:00:00','2006-04-25 10:02:00','2006-04-25 10:04:00', +'2006-04-25 10:06:00', '2006-04-25 10:08:00'); +a filler +2006-04-25 10:01:00 yes +2006-04-25 10:03:00 yes +2006-04-25 10:05:00 yes +2006-04-25 10:07:00 yes +2006-04-25 10:09:00 yes +2006-04-25 10:11:00 yes +2006-04-25 10:13:00 yes +2006-04-25 10:15:00 yes +2006-04-25 10:17:00 yes +2006-04-25 10:19:00 yes +drop table t2; +create table t2 (a varchar(10), filler char(200), key(a)); +insert into t2 select 'foo', 'no' from t1 A, t1 B; +insert into t2 select 'barbar', 'no' from t1 A, t1 B; +insert into t2 select 'bazbazbaz', 'no' from t1 A, t1 B; +insert into t2 values ('fon', '1'), ('fop','1'), ('barbaq','1'), +('barbas','1'), ('bazbazbay', '1'),('zz','1'); +explain select * from t2 where a not in('foo','barbar', 'bazbazbaz'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL 13 NULL 6 100.00 Parallel execute (4 workers) +2 SIMPLE t2 NULL range a a 13 NULL 6 100.00 Using index condition; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`filler` AS `filler` from `test`.`t2` where (`test`.`t2`.`a` not in ('foo','barbar','bazbazbaz')) +drop table t2; +create table t2 (a decimal(10,5), filler char(200), key(a)); +insert into t2 select 345.67890, 'no' from t1 A, t1 B; +insert into t2 select 43245.34, 'no' from t1 A, t1 B; +insert into t2 select 64224.56344, 'no' from t1 A, t1 B; +insert into t2 values (0, '1'), (22334.123,'1'), (33333,'1'), +(55555,'1'), (77777, '1'); +explain +select * from t2 where a not in (345.67890, 43245.34, 64224.56344); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (4 workers) +2 SIMPLE t2 NULL range a a 7 NULL 5 100.00 Using index condition; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`filler` AS `filler` from `test`.`t2` where (`test`.`t2`.`a` not in (345.67890,43245.34,64224.56344)) +select * from t2 where a not in (345.67890, 43245.34, 64224.56344); +a filler +0.00000 1 +22334.12300 1 +33333.00000 1 +55555.00000 1 +77777.00000 1 +drop table t2; +create table t2 (a int, key(a), b int); +insert into t2 values (1,1),(2,2); +set @cnt= 1; +set @str="update t2 set b=1 where a not in ("; +select count(*) from ( +select @str:=concat(@str, @cnt:=@cnt+1, ",") +from t1 A, t1 B, t1 C, t1 D) Z; +count(*) +10000 +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +set @str:=concat(@str, "10000)"); +select substr(@str, 1, 50); +substr(@str, 1, 50) +update t2 set b=1 where a not in (2,3,4,5,6,7,8,9, +prepare s from @str; +execute s; +deallocate prepare s; +set @str=NULL; +drop table t2; +drop table t1; +create table t1 ( +some_id smallint(5) unsigned, +key (some_id) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t1 values (1),(2); +select some_id from t1 where some_id not in(2,-1); +some_id +1 +select some_id from t1 where some_id not in(-4,-1,-4); +some_id +1 +2 +select some_id from t1 where some_id not in(-4,-1,3423534,2342342); +some_id +1 +2 +select some_id from t1 where some_id not in('-1', '0'); +some_id +1 +2 +drop table t1; +# +# BUG#20420: optimizer reports wrong keys on left join with IN +# +CREATE TABLE t1 (a int, b int, PRIMARY KEY (a)); +INSERT INTO t1 VALUES (1,1),(2,1),(3,1),(4,1),(5,1),(6,1); +CREATE TABLE t2 (a int, b int, PRIMARY KEY (a)); +INSERT INTO t2 VALUES (3,2),(4,2),(100,100),(101,201),(102,102); +CREATE TABLE t3 (a int PRIMARY KEY); +INSERT INTO t3 VALUES (1),(2),(3),(4); +CREATE TABLE t4 (a int PRIMARY KEY,b int); +INSERT INTO t4 VALUES (1,1),(2,2),(1000,1000),(1001,1001),(1002,1002), +(1003,1003),(1004,1004); +EXPLAIN SELECT STRAIGHT_JOIN * FROM t3 +JOIN t1 ON t3.a=t1.a +JOIN t2 ON t3.a=t2.a +JOIN t4 WHERE t4.a IN (t1.b, t2.b); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t3 NULL index PRIMARY PRIMARY 4 NULL 4 100.00 Using index +2 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t3.a 1 100.00 NULL +2 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t3.a 1 100.00 NULL +2 SIMPLE t4 NULL ALL PRIMARY NULL NULL NULL 7 28.57 Range checked for each record (index map: 0x1) +Warnings: +Note 1003 /* select#1 */ select straight_join `test`.`t3`.`a` AS `a`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b` from `test`.`t3` join `test`.`t1` join `test`.`t2` join `test`.`t4` where ((`test`.`t1`.`a` = `test`.`t3`.`a`) and (`test`.`t2`.`a` = `test`.`t3`.`a`) and (`test`.`t4`.`a` in (`test`.`t1`.`b`,`test`.`t2`.`b`))) +SELECT STRAIGHT_JOIN * FROM t3 +JOIN t1 ON t3.a=t1.a +JOIN t2 ON t3.a=t2.a +JOIN t4 WHERE t4.a IN (t1.b, t2.b); +a a b a b a b +3 3 1 3 2 1 1 +3 3 1 3 2 2 2 +4 4 1 4 2 1 1 +4 4 1 4 2 2 2 +EXPLAIN SELECT STRAIGHT_JOIN +(SELECT SUM(t4.a) FROM t4 WHERE t4.a IN (t1.b, t2.b)) +FROM t3, t1, t2 +WHERE t3.a=t1.a AND t3.a=t2.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t3 NULL index PRIMARY PRIMARY 4 NULL 4 100.00 Using index +1 PRIMARY t1 NULL eq_ref PRIMARY PRIMARY 4 test.t3.a 1 100.00 NULL +1 PRIMARY t2 NULL eq_ref PRIMARY PRIMARY 4 test.t3.a 1 100.00 NULL +2 DEPENDENT SUBQUERY t4 NULL index NULL PRIMARY 4 NULL 7 28.57 Using where; Using index +Warnings: +Note 1276 Field or reference 'test.t1.b' of SELECT #2 was resolved in SELECT #1 +Note 1276 Field or reference 'test.t2.b' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select straight_join (/* select#2 */ select sum(`test`.`t4`.`a`) from `test`.`t4` where (`test`.`t4`.`a` in (`test`.`t1`.`b`,`test`.`t2`.`b`))) AS `(SELECT SUM(t4.a) FROM t4 WHERE t4.a IN (t1.b, t2.b))` from `test`.`t3` join `test`.`t1` join `test`.`t2` where ((`test`.`t1`.`a` = `test`.`t3`.`a`) and (`test`.`t2`.`a` = `test`.`t3`.`a`)) +SELECT STRAIGHT_JOIN +(SELECT SUM(t4.a) FROM t4 WHERE t4.a IN (t1.b, t2.b)) +FROM t3, t1, t2 +WHERE t3.a=t1.a AND t3.a=t2.a; +(SELECT SUM(t4.a) FROM t4 WHERE t4.a IN (t1.b, t2.b)) +3 +3 +DROP TABLE t1,t2,t3,t4; +CREATE TABLE t1(a BIGINT UNSIGNED); +INSERT INTO t1 VALUES (0xFFFFFFFFFFFFFFFF); +SELECT * FROM t1 WHERE a=-1 OR a=-2 ; +a +SELECT * FROM t1 WHERE a IN (-1, -2); +a +CREATE TABLE t2 (a BIGINT UNSIGNED); +insert into t2 values(13491727406643098568), +(0x7fffffefffffffff), +(0x7ffffffeffffffff), +(0x7fffffffefffffff), +(0x7ffffffffeffffff), +(0x7fffffffffefffff), +(0x7ffffffffffeffff), +(0x7fffffffffffefff), +(0x7ffffffffffffeff), +(0x7fffffffffffffef), +(0x7ffffffffffffffe), +(0x7fffffffffffffff), +(0x8000000000000000), +(0x8000000000000001), +(0x8000000000000002), +(0x8000000000000300), +(0x8000000000000400), +(0x8000000000000401), +(0x8000000000004001), +(0x8000000000040001), +(0x8000000000400001), +(0x8000000004000001), +(0x8000000040000001), +(0x8000000400000001), +(0x8000004000000001), +(0x8000040000000001); +SELECT HEX(a) FROM t2 WHERE a IN +(CAST(0xBB3C3E98175D33C8 AS UNSIGNED), +42); +HEX(a) +BB3C3E98175D33C8 +SELECT HEX(a) FROM t2 WHERE a IN +(CAST(0xBB3C3E98175D33C8 AS UNSIGNED), +CAST(0x7fffffffffffffff AS UNSIGNED), +CAST(0x8000000000000000 AS UNSIGNED), +CAST(0x8000000000000400 AS UNSIGNED), +CAST(0x8000000000000401 AS UNSIGNED), +42); +HEX(a) +BB3C3E98175D33C8 +7FFFFFFFFFFFFFFF +8000000000000000 +8000000000000400 +8000000000000401 +SELECT HEX(a) FROM t2 WHERE a IN +(CAST(0x7fffffffffffffff AS UNSIGNED), +CAST(0x8000000000000001 AS UNSIGNED)); +HEX(a) +7FFFFFFFFFFFFFFF +8000000000000001 +SELECT HEX(a) FROM t2 WHERE a IN +(CAST(0x7ffffffffffffffe AS UNSIGNED), +CAST(0x7fffffffffffffff AS UNSIGNED)); +HEX(a) +7FFFFFFFFFFFFFFE +7FFFFFFFFFFFFFFF +SELECT HEX(a) FROM t2 WHERE a IN +(0x7ffffffffffffffe, +0x7fffffffffffffff, +'abc'); +HEX(a) +7FFFFFFFFFFFFFFE +7FFFFFFFFFFFFFFF +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'abc' +CREATE TABLE t3 (a BIGINT UNSIGNED); +INSERT INTO t3 VALUES (9223372036854775551); +SELECT HEX(a) FROM t3 WHERE a IN (9223372036854775807, 42); +HEX(a) +CREATE TABLE t4 (a DATE); +INSERT INTO t4 VALUES ('1972-02-06'), ('1972-07-29'); +SELECT * FROM t4 WHERE a IN ('1972-02-06','19772-07-29'); +a +1972-02-06 +Warnings: +Warning 1292 Incorrect date value: '19772-07-29' for column 'a' at row 1 +Warning 1292 Incorrect date value: '19772-07-29' for column 'a' at row 1 +Warning 1292 Incorrect date value: '19772-07-29' for column 'a' at row 1 +DROP TABLE t1,t2,t3,t4; +CREATE TABLE t1 (id int not null); +INSERT INTO t1 VALUES (1),(2); +SELECT id FROM t1 WHERE id IN(4564, (SELECT IF(1=0,1,1/0)) ); +id +Warnings: +Warning 1365 Division by 0 +DROP TABLE t1; +End of 5.0 tests +create table t1(f1 char(1)); +insert into t1 values ('a'),('b'),('1'); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +select f1 from t1 where f1 in ('a',1); +f1 +1 +Warning 1292 Truncated incorrect DOUBLE value: 'b' +Warnings: +a +select f1, case f1 when 'a' then '+' when 1 then '-' end from t1; +f1 case f1 when 'a' then '+' when 1 then '-' end +a + +b NULL +1 - +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'b' +create index t1f1_idx on t1(f1); +select f1 from t1 where f1 in ('a',1); +f1 +1 +Warning 1292 Truncated incorrect DOUBLE value: 'b' +Warnings: +a +explain select f1 from t1 where f1 in ('a',1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL 2 NULL 3 50.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index t1f1_idx t1f1_idx 2 NULL 3 50.00 Using where; Using index +Warnings: +Warning 1739 Cannot use range access on index 't1f1_idx' due to type or collation conversion on field 'f1' +Note 1003 /* select#1 */ select `test`.`t1`.`f1` AS `f1` from `test`.`t1` where (`test`.`t1`.`f1` in ('a',1)) +select f1 from t1 where f1 in ('a','b'); +f1 +a +b +explain select f1 from t1 where f1 in ('a','b'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL 2 NULL 2 100.00 Parallel execute (2 workers) +2 SIMPLE t1 NULL range t1f1_idx t1f1_idx 2 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`f1` AS `f1` from `test`.`t1` where (`test`.`t1`.`f1` in ('a','b')) +select f1 from t1 where f1 in (2,1); +f1 +1 +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'a' +Warning 1292 Truncated incorrect DOUBLE value: 'b' +explain select f1 from t1 where f1 in (2,1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL 2 NULL 3 50.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index t1f1_idx t1f1_idx 2 NULL 3 50.00 Using where; Using index +Warnings: +Warning 1739 Cannot use range access on index 't1f1_idx' due to type or collation conversion on field 'f1' +Note 1003 /* select#1 */ select `test`.`t1`.`f1` AS `f1` from `test`.`t1` where (`test`.`t1`.`f1` in (2,1)) +create table t2(f2 int, index t2f2(f2)); +insert into t2 values(0),(1),(2); +select f2 from t2 where f2 in ('a',2); +f2 +0 +2 +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'a' +Warning 1292 Truncated incorrect DOUBLE value: 'a' +explain select f2 from t2 where f2 in ('a',2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (2 workers) +2 SIMPLE t2 NULL range t2f2 t2f2 5 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`f2` AS `f2` from `test`.`t2` where (`test`.`t2`.`f2` in ('a',2)) +select f2 from t2 where f2 in ('a','b'); +f2 +0 +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'a' +Warning 1292 Truncated incorrect DOUBLE value: 'b' +Warning 1292 Truncated incorrect DOUBLE value: 'a' +Warning 1292 Truncated incorrect DOUBLE value: 'b' +Warning 1292 Truncated incorrect DOUBLE value: 'a' +Warning 1292 Truncated incorrect DOUBLE value: 'b' +explain select f2 from t2 where f2 in ('a','b'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL range t2f2 t2f2 5 NULL 1 100.00 Using where; Using index +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'a' +Warning 1292 Truncated incorrect DOUBLE value: 'b' +Note 1003 /* select#1 */ select `test`.`t2`.`f2` AS `f2` from `test`.`t2` where (`test`.`t2`.`f2` in ('a','b')) +select f2 from t2 where f2 in (1,'b'); +f2 +0 +1 +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'b' +explain select f2 from t2 where f2 in (1,'b'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (2 workers) +2 SIMPLE t2 NULL range t2f2 t2f2 5 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`f2` AS `f2` from `test`.`t2` where (`test`.`t2`.`f2` in (1,'b')) +drop table t1, t2; +create table t1 (a time, key(a)); +insert into t1 values (),(),(),(),(),(),(),(),(),(); +select a from t1 where a not in (a,a,a) group by a; +a +drop table t1; +create table t1 (id int); +select * from t1 where NOT id in (select null union all select 1); +id +select * from t1 where NOT id in (null, 1); +id +drop table t1; +CREATE TABLE t1(c0 INTEGER, c1 INTEGER, c2 INTEGER); +INSERT INTO t1 VALUES(1, 1, 1), (1, 1, 1); +SELECT CASE AVG (c0) WHEN c1 * c2 THEN 1 END FROM t1; +CASE AVG (c0) WHEN c1 * c2 THEN 1 END +1 +SELECT CASE c1 * c2 WHEN SUM(c0) THEN 1 WHEN AVG(c0) THEN 2 END FROM t1; +CASE c1 * c2 WHEN SUM(c0) THEN 1 WHEN AVG(c0) THEN 2 END +2 +SELECT CASE c1 WHEN c1 + 1 THEN 1 END, ABS(AVG(c0)) FROM t1; +CASE c1 WHEN c1 + 1 THEN 1 END ABS(AVG(c0)) +NULL 1.0000 +DROP TABLE t1; +CREATE TABLE t1(a TEXT, b INT, c INT UNSIGNED, d DECIMAL(12,2), e REAL); +INSERT INTO t1 VALUES('iynfj', 1, 1, 1, 1); +INSERT INTO t1 VALUES('innfj', 2, 2, 2, 2); +SELECT SUM( DISTINCT a ) FROM t1 GROUP BY a HAVING a IN ( AVG( 1 ), 1 + a); +SUM( DISTINCT a ) +SELECT SUM( DISTINCT b ) FROM t1 GROUP BY b HAVING b IN ( AVG( 1 ), 1 + b); +SUM( DISTINCT b ) +1 +SELECT SUM( DISTINCT c ) FROM t1 GROUP BY c HAVING c IN ( AVG( 1 ), 1 + c); +SUM( DISTINCT c ) +1 +SELECT SUM( DISTINCT d ) FROM t1 GROUP BY d HAVING d IN ( AVG( 1 ), 1 + d); +SUM( DISTINCT d ) +1.00 +SELECT SUM( DISTINCT e ) FROM t1 GROUP BY e HAVING e IN ( AVG( 1 ), 1 + e); +SUM( DISTINCT e ) +1 +SELECT SUM( DISTINCT e ) FROM t1 GROUP BY b,c,d HAVING (b,c,d) IN +((AVG( 1 ), 1 + c, 1 + d), (AVG( 1 ), 2 + c, 2 + d)); +SUM( DISTINCT e ) +DROP TABLE t1; +# +# Bug #44139: Table scan when NULL appears in IN clause +# +CREATE TABLE t1 ( +c_int INT NOT NULL, +c_decimal DECIMAL(5,2) NOT NULL, +c_float FLOAT(5, 2) NOT NULL, +c_bit BIT(10) NOT NULL, +c_date DATE NOT NULL, +c_datetime DATETIME NOT NULL, +c_timestamp TIMESTAMP NOT NULL, +c_time TIME NOT NULL, +c_year YEAR NOT NULL, +c_char CHAR(10) character set utf8mb4 NOT NULL, +INDEX(c_int), INDEX(c_decimal), INDEX(c_float), INDEX(c_bit), INDEX(c_date), +INDEX(c_datetime), INDEX(c_timestamp), INDEX(c_time), INDEX(c_year), +INDEX(c_char)); +INSERT IGNORE INTO t1 (c_int) VALUES (1), (2), (3), (4), (5); +INSERT IGNORE INTO t1 (c_int) SELECT 0 FROM t1; +INSERT IGNORE INTO t1 (c_int) SELECT 0 FROM t1; +EXPLAIN SELECT * FROM t1 WHERE c_int IN (1, 2, 3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (3 workers) +2 SIMPLE t1 NULL range c_int c_int 4 NULL 3 100.00 Using index condition; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_int` in (1,2,3)) +EXPLAIN SELECT * FROM t1 WHERE c_int IN (NULL, 1, 2, 3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (3 workers) +2 SIMPLE t1 NULL range c_int c_int 4 NULL 3 100.00 Using index condition; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_int` in (NULL,1,2,3)) +EXPLAIN SELECT * FROM t1 WHERE c_int IN (1, 2, 3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (3 workers) +2 SIMPLE t1 NULL range c_int c_int 4 NULL 3 100.00 Using index condition; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_int` in (1,2,3)) +EXPLAIN SELECT * FROM t1 WHERE c_int IN (1, NULL, 2, NULL, 3, NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (3 workers) +2 SIMPLE t1 NULL range c_int c_int 4 NULL 3 100.00 Using index condition; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_int` in (1,NULL,2,NULL,3,NULL)) +EXPLAIN SELECT * FROM t1 WHERE c_int IN (NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_int` = NULL) +EXPLAIN SELECT * FROM t1 WHERE c_int IN (NULL, NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_int` in (NULL,NULL)) +EXPLAIN SELECT * FROM t1 WHERE c_decimal IN (1, 2, 3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range c_decimal c_decimal 3 NULL 3 100.00 Using index condition; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_decimal` in (1,2,3)) +EXPLAIN SELECT * FROM t1 WHERE c_decimal IN (NULL, 1, 2, 3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range c_decimal c_decimal 3 NULL 3 100.00 Using index condition; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_decimal` in (NULL,1,2,3)) +EXPLAIN SELECT * FROM t1 WHERE c_decimal IN (NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_decimal` = NULL) +EXPLAIN SELECT * FROM t1 WHERE c_decimal IN (NULL, NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_decimal` in (NULL,NULL)) +EXPLAIN SELECT * FROM t1 WHERE c_float IN (1, 2, 3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range c_float c_float 4 NULL 3 100.00 Using index condition; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_float` in (1,2,3)) +EXPLAIN SELECT * FROM t1 WHERE c_float IN (NULL, 1, 2, 3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range c_float c_float 4 NULL 3 100.00 Using index condition; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_float` in (NULL,1,2,3)) +EXPLAIN SELECT * FROM t1 WHERE c_float IN (NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_float` = NULL) +EXPLAIN SELECT * FROM t1 WHERE c_float IN (NULL, NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_float` in (NULL,NULL)) +EXPLAIN SELECT * FROM t1 WHERE c_bit IN (1, 2, 3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range c_bit c_bit 2 NULL 3 100.00 Using index condition; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_bit` in (1,2,3)) +EXPLAIN SELECT * FROM t1 WHERE c_bit IN (NULL, 1, 2, 3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range c_bit c_bit 2 NULL 3 100.00 Using index condition; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_bit` in (NULL,1,2,3)) +EXPLAIN SELECT * FROM t1 WHERE c_bit IN (NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_bit` = NULL) +EXPLAIN SELECT * FROM t1 WHERE c_bit IN (NULL, NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_bit` in (NULL,NULL)) +EXPLAIN SELECT * FROM t1 WHERE c_date +IN ('2009-09-01', '2009-09-02', '2009-09-03'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range c_date c_date 3 NULL 3 100.00 Using index condition; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_date` in ('2009-09-01','2009-09-02','2009-09-03')) +EXPLAIN SELECT * FROM t1 WHERE c_date +IN (NULL, '2009-09-01', '2009-09-02', '2009-09-03'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range c_date c_date 3 NULL 3 100.00 Using index condition; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_date` in (NULL,'2009-09-01','2009-09-02','2009-09-03')) +EXPLAIN SELECT * FROM t1 WHERE c_date IN (NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where multiple equal(NULL, `test`.`t1`.`c_date`) +EXPLAIN SELECT * FROM t1 WHERE c_date IN (NULL, NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_date` in (NULL,NULL)) +EXPLAIN SELECT * FROM t1 WHERE c_datetime +IN ('2009-09-01 00:00:01', '2009-09-02 00:00:01', '2009-09-03 00:00:01'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range c_datetime c_datetime 5 NULL 3 100.00 Using index condition; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_datetime` in ('2009-09-01 00:00:01','2009-09-02 00:00:01','2009-09-03 00:00:01')) +EXPLAIN SELECT * FROM t1 WHERE c_datetime +IN (NULL, '2009-09-01 00:00:01', '2009-09-02 00:00:01', '2009-09-03 00:00:01'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range c_datetime c_datetime 5 NULL 3 100.00 Using index condition; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_datetime` in (NULL,'2009-09-01 00:00:01','2009-09-02 00:00:01','2009-09-03 00:00:01')) +EXPLAIN SELECT * FROM t1 WHERE c_datetime IN (NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where multiple equal(NULL, `test`.`t1`.`c_datetime`) +EXPLAIN SELECT * FROM t1 WHERE c_datetime IN (NULL, NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_datetime` in (NULL,NULL)) +EXPLAIN SELECT * FROM t1 WHERE c_timestamp +IN ('2009-09-01 00:00:01', '2009-09-01 00:00:02', '2009-09-01 00:00:03'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range c_timestamp c_timestamp 4 NULL 3 100.00 Using index condition; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_timestamp` in ('2009-09-01 00:00:01','2009-09-01 00:00:02','2009-09-01 00:00:03')) +EXPLAIN SELECT * FROM t1 WHERE c_timestamp +IN (NULL, '2009-09-01 00:00:01', '2009-09-01 00:00:02', '2009-09-01 00:00:03'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range c_timestamp c_timestamp 4 NULL 3 100.00 Using index condition; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_timestamp` in (NULL,'2009-09-01 00:00:01','2009-09-01 00:00:02','2009-09-01 00:00:03')) +EXPLAIN SELECT * FROM t1 WHERE c_timestamp IN (NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where multiple equal(NULL, `test`.`t1`.`c_timestamp`) +EXPLAIN SELECT * FROM t1 WHERE c_timestamp IN (NULL, NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_timestamp` in (NULL,NULL)) +EXPLAIN SELECT * FROM t1 WHERE c_year IN (1, 2, 3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range c_year c_year 1 NULL 3 100.00 Using index condition; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_year` in (1,2,3)) +EXPLAIN SELECT * FROM t1 WHERE c_year IN (NULL, 1, 2, 3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range c_year c_year 1 NULL 3 100.00 Using index condition; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_year` in (NULL,1,2,3)) +EXPLAIN SELECT * FROM t1 WHERE c_year IN (NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_year` = NULL) +EXPLAIN SELECT * FROM t1 WHERE c_year IN (NULL, NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_year` in (NULL,NULL)) +EXPLAIN SELECT * FROM t1 WHERE c_char IN ('1', '2', '3'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range c_char c_char 40 NULL 3 100.00 Using index condition; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_char` in ('1','2','3')) +EXPLAIN SELECT * FROM t1 WHERE c_char IN (NULL, '1', '2', '3'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range c_char c_char 40 NULL 3 100.00 Using index condition; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_char` in (NULL,'1','2','3')) +EXPLAIN SELECT * FROM t1 WHERE c_char IN (NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where multiple equal(NULL, `test`.`t1`.`c_char`) +EXPLAIN SELECT * FROM t1 WHERE c_char IN (NULL, NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_char` in (NULL,NULL)) +DROP TABLE t1; +# +# Bug#54477: Crash on IN / CASE with NULL arguments +# +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2); +SELECT 1 IN (NULL, a) FROM t1; +1 IN (NULL, a) +1 +NULL +SELECT a IN (a, a) FROM t1 GROUP BY a WITH ROLLUP; +a IN (a, a) +1 +1 +NULL +SELECT CASE a WHEN a THEN a END FROM t1 GROUP BY a WITH ROLLUP; +CASE a WHEN a THEN a END +1 +2 +NULL +DROP TABLE t1; +# +# Bug#58628: Incorrect result for 'WHERE NULL NOT IN () +# +CREATE TABLE t1 (pk INT NOT NULL, i INT); +INSERT INTO t1 VALUES (0,NULL), (1,NULL), (2,NULL), (3,NULL); +CREATE TABLE subq (pk INT NOT NULL, i INT NOT NULL, PRIMARY KEY(i,pk)); +INSERT INTO subq VALUES (0,0), (1,1), (2,2), (3,3); +SELECT * FROM t1 +WHERE t1.i NOT IN +(SELECT i FROM subq WHERE subq.pk = t1.pk); +pk i +SELECT * FROM t1 +WHERE t1.i IN +(SELECT i FROM subq WHERE subq.pk = t1.pk) IS UNKNOWN; +pk i +0 NULL +1 NULL +2 NULL +3 NULL +SELECT * FROM t1 +WHERE NULL NOT IN +(SELECT i FROM subq WHERE subq.pk = t1.pk); +pk i +SELECT * FROM t1 +WHERE NULL IN +(SELECT i FROM subq WHERE subq.pk = t1.pk) IS UNKNOWN; +pk i +0 NULL +1 NULL +2 NULL +3 NULL +SELECT * FROM t1 +WHERE 1+NULL NOT IN +(SELECT i FROM subq WHERE subq.pk = t1.pk); +pk i +DROP TABLE t1,subq; +# +# Bug #11766270 59343: YEAR(4): INCORRECT RESULT AND VALGRIND WARNINGS WITH MIN/MAX, UNION +# +CREATE TABLE t1(f1 YEAR); +INSERT INTO t1 VALUES (0000),(2001); +(SELECT MAX(f1) FROM t1) UNION (SELECT MAX(f1) FROM t1); +Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr +def MAX(f1) MAX(f1) 13 4 4 Y 32864 0 63 +MAX(f1) +2001 +DROP TABLE t1; +# +# Bug #11764651-57510: IN(string,real,string) causes invalid read in sort function +# +SELECT LEFT(ST_GEOMFROMTEXT("POINT(0 0)"),1) IN (@@global.max_allowed_packet,1,""); +LEFT(ST_GEOMFROMTEXT("POINT(0 0)"),1) IN (@@global.max_allowed_packet,1,"") +0 +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: '\x00' +# End of test BUG#11764651-57510 +End of 5.1 tests +set optimizer_switch=default; diff --git a/mysql-test/r/func_in_icp.result-pq b/mysql-test/r/func_in_icp.result-pq new file mode 100644 index 000000000000..e2c503aa9534 --- /dev/null +++ b/mysql-test/r/func_in_icp.result-pq @@ -0,0 +1,998 @@ +set optimizer_switch='index_condition_pushdown=on'; +drop table if exists t1, t2; +select 1 in (1,2,3); +1 in (1,2,3) +1 +select 10 in (1,2,3); +10 in (1,2,3) +0 +select NULL in (1,2,3); +NULL in (1,2,3) +NULL +select 1 in (1,NULL,3); +1 in (1,NULL,3) +1 +select 3 in (1,NULL,3); +3 in (1,NULL,3) +1 +select 10 in (1,NULL,3); +10 in (1,NULL,3) +NULL +select 1.5 in (1.5,2.5,3.5); +1.5 in (1.5,2.5,3.5) +1 +select 10.5 in (1.5,2.5,3.5); +10.5 in (1.5,2.5,3.5) +0 +select NULL in (1.5,2.5,3.5); +NULL in (1.5,2.5,3.5) +NULL +select 1.5 in (1.5,NULL,3.5); +1.5 in (1.5,NULL,3.5) +1 +select 3.5 in (1.5,NULL,3.5); +3.5 in (1.5,NULL,3.5) +1 +select 10.5 in (1.5,NULL,3.5); +10.5 in (1.5,NULL,3.5) +NULL +CREATE TABLE t1 (a int, b int, c int); +insert into t1 values (1,2,3), (1,NULL,3); +select 1 in (a,b,c) from t1; +1 in (a,b,c) +1 +1 +select 3 in (a,b,c) from t1; +3 in (a,b,c) +1 +1 +select 10 in (a,b,c) from t1; +10 in (a,b,c) +0 +NULL +select NULL in (a,b,c) from t1; +NULL in (a,b,c) +NULL +NULL +drop table t1; +CREATE TABLE t1 (a float, b float, c float); +insert into t1 values (1.5,2.5,3.5), (1.5,NULL,3.5); +select 1.5 in (a,b,c) from t1; +1.5 in (a,b,c) +1 +1 +select 3.5 in (a,b,c) from t1; +3.5 in (a,b,c) +1 +1 +select 10.5 in (a,b,c) from t1; +10.5 in (a,b,c) +0 +NULL +drop table t1; +CREATE TABLE t1 (a varchar(10), b varchar(10), c varchar(10)); +insert into t1 values ('A','BC','EFD'), ('A',NULL,'EFD'); +select 'A' in (a,b,c) from t1; +'A' in (a,b,c) +1 +1 +select 'EFD' in (a,b,c) from t1; +'EFD' in (a,b,c) +1 +1 +select 'XSFGGHF' in (a,b,c) from t1; +'XSFGGHF' in (a,b,c) +0 +NULL +drop table t1; +CREATE TABLE t1 (field char(1)); +INSERT INTO t1 VALUES ('A'),(NULL); +SELECT * from t1 WHERE field IN (NULL); +field +SELECT * from t1 WHERE field NOT IN (NULL); +field +SELECT * from t1 where field = field; +field +A +SELECT * from t1 where field <=> field; +field +A +NULL +DELETE FROM t1 WHERE field NOT IN (NULL); +SELECT * FROM t1; +field +A +NULL +drop table t1; +create table t1 (id int(10) primary key); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t1 values (1),(2),(3),(4),(5),(6),(7),(8),(9); +select * from t1 where id in (2,5,9); +id +2 +5 +9 +drop table t1; +create table t1 ( +a char(1) character set latin1 collate latin1_general_ci, +b char(1) character set latin1 collate latin1_swedish_ci, +c char(1) character set latin1 collate latin1_danish_ci +); +insert into t1 values ('A','B','C'); +insert into t1 values ('a','c','c'); +select * from t1 where a in (b); +ERROR HY000: Illegal mix of collations (latin1_general_ci,IMPLICIT) and (latin1_swedish_ci,IMPLICIT) for operation '=' +select * from t1 where a in (b,c); +ERROR HY000: Illegal mix of collations (latin1_general_ci,IMPLICIT), (latin1_swedish_ci,IMPLICIT), (latin1_danish_ci,IMPLICIT) for operation ' IN ' +select * from t1 where 'a' in (a,b,c); +ERROR HY000: Illegal mix of collations for operation ' IN ' +select * from t1 where 'a' in (a); +a b c +A B C +a c c +select * from t1 where a in ('a'); +a b c +A B C +a c c +set names latin1; +select * from t1 where 'a' collate latin1_general_ci in (a,b,c); +a b c +A B C +a c c +select * from t1 where 'a' collate latin1_bin in (a,b,c); +a b c +a c c +select * from t1 where 'a' in (a,b,c collate latin1_bin); +a b c +a c c +explain select * from t1 where 'a' in (a,b,c collate latin1_bin); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` where ('a' in (`test`.`t1`.`a`,`test`.`t1`.`b`,(`test`.`t1`.`c` collate latin1_bin))) +drop table t1; +set names utf8mb4; +set names utf8; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +create table t1 (a char(10) character set utf8 not null); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +insert into t1 values ('bbbb'),(_koi8r x'C3C3C3C3'),(_latin1 x'C4C4C4C4'); +select a from t1 where a in ('bbbb',_koi8r x'C3C3C3C3',_latin1 x'C4C4C4C4') order by a; +a +ÄÄÄÄ +bbbb +цццц +drop table t1; +create table t1 (a char(10) character set latin1 not null); +insert into t1 values ('a'),('b'),('c'); +select a from t1 where a IN ('a','b','c') order by a; +a +a +b +c +drop table t1; +set names latin1; +select '1.0' in (1,2); +'1.0' in (1,2) +1 +select 1 in ('1.0',2); +1 in ('1.0',2) +1 +select 1 in (1,'2.0'); +1 in (1,'2.0') +1 +select 1 in ('1.0',2.0); +1 in ('1.0',2.0) +1 +select 1 in (1.0,'2.0'); +1 in (1.0,'2.0') +1 +select 1 in ('1.1',2); +1 in ('1.1',2) +0 +select 1 in ('1.1',2.0); +1 in ('1.1',2.0) +0 +create table t1 (a char(2) character set binary); +insert into t1 values ('aa'), ('bb'); +select * from t1 where a in (NULL, 'aa'); +a +aa +drop table t1; +create table t1 (id int, key(id)); +insert into t1 values (1),(2),(3); +select count(*) from t1 where id not in (1); +count(*) +2 +select count(*) from t1 where id not in (1,2); +count(*) +1 +drop table t1; +DROP TABLE IF EXISTS t1; +CREATE TABLE t1 SELECT 1 IN (2, NULL); +SELECT should return NULL. +SELECT * FROM t1; +1 IN (2, NULL) +NULL +DROP TABLE t1; +End of 4.1 tests +CREATE TABLE t1 (a int PRIMARY KEY); +INSERT INTO t1 VALUES (44), (45), (46); +SELECT * FROM t1 WHERE a IN (45); +a +45 +SELECT * FROM t1 WHERE a NOT IN (0, 45); +a +44 +46 +SELECT * FROM t1 WHERE a NOT IN (45); +a +44 +46 +CREATE VIEW v1 AS SELECT * FROM t1 WHERE a NOT IN (45); +SHOW CREATE VIEW v1; +View Create View character_set_client collation_connection +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`a` AS `a` from `t1` where (`t1`.`a` <> 45) latin1 latin1_swedish_ci +SELECT * FROM v1; +a +44 +46 +DROP VIEW v1; +DROP TABLE t1; +create table t1 (a int); +insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t2 (a int, filler char(200), key(a)); +insert into t2 select C.a*2, 'no' from t1 A, t1 B, t1 C; +insert into t2 select C.a*2+1, 'yes' from t1 C; +explain +select * from t2 where a NOT IN (0, 2,4,6,8,10,12,14,16,18); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 100.00 Parallel execute (4 workers) +2 SIMPLE t2 NULL range a a 5 NULL 11 100.00 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`filler` AS `filler` from `test`.`t2` where (`test`.`t2`.`a` not in (0,2,4,6,8,10,12,14,16,18)) +select * from t2 where a NOT IN (0, 2,4,6,8,10,12,14,16,18); +a filler +1 yes +3 yes +5 yes +7 yes +9 yes +11 yes +13 yes +15 yes +17 yes +19 yes +explain select * from t2 force index(a) where a NOT IN (2,2,2,2,2,2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 910 100.00 Parallel execute (3 workers) +2 SIMPLE t2 NULL range a a 5 NULL 910 100.00 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`filler` AS `filler` from `test`.`t2` FORCE INDEX (`a`) where (`test`.`t2`.`a` not in (2,2,2,2,2,2)) +explain select * from t2 force index(a) where a <> 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 910 100.00 Parallel execute (3 workers) +2 SIMPLE t2 NULL range a a 5 NULL 910 100.00 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`filler` AS `filler` from `test`.`t2` FORCE INDEX (`a`) where (`test`.`t2`.`a` <> 2) +drop table t2; +create table t2 (a datetime, filler char(200), key(a)); +insert into t2 select '2006-04-25 10:00:00' + interval C.a minute, +'no' from t1 A, t1 B, t1 C where C.a % 2 = 0; +insert into t2 select '2006-04-25 10:00:00' + interval C.a*2+1 minute, +'yes' from t1 C; +explain +select * from t2 where a NOT IN ( +'2006-04-25 10:00:00','2006-04-25 10:02:00','2006-04-25 10:04:00', +'2006-04-25 10:06:00', '2006-04-25 10:08:00'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 100.00 Parallel execute (4 workers) +2 SIMPLE t2 NULL range a a 6 NULL 11 100.00 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`filler` AS `filler` from `test`.`t2` where (`test`.`t2`.`a` not in ('2006-04-25 10:00:00','2006-04-25 10:02:00','2006-04-25 10:04:00','2006-04-25 10:06:00','2006-04-25 10:08:00')) +select * from t2 where a NOT IN ( +'2006-04-25 10:00:00','2006-04-25 10:02:00','2006-04-25 10:04:00', +'2006-04-25 10:06:00', '2006-04-25 10:08:00'); +a filler +2006-04-25 10:01:00 yes +2006-04-25 10:03:00 yes +2006-04-25 10:05:00 yes +2006-04-25 10:07:00 yes +2006-04-25 10:09:00 yes +2006-04-25 10:11:00 yes +2006-04-25 10:13:00 yes +2006-04-25 10:15:00 yes +2006-04-25 10:17:00 yes +2006-04-25 10:19:00 yes +drop table t2; +create table t2 (a varchar(10), filler char(200), key(a)); +insert into t2 select 'foo', 'no' from t1 A, t1 B; +insert into t2 select 'barbar', 'no' from t1 A, t1 B; +insert into t2 select 'bazbazbaz', 'no' from t1 A, t1 B; +insert into t2 values ('fon', '1'), ('fop','1'), ('barbaq','1'), +('barbas','1'), ('bazbazbay', '1'),('zz','1'); +explain select * from t2 where a not in('foo','barbar', 'bazbazbaz'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL 13 NULL 6 100.00 Parallel execute (4 workers) +2 SIMPLE t2 NULL range a a 13 NULL 6 100.00 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`filler` AS `filler` from `test`.`t2` where (`test`.`t2`.`a` not in ('foo','barbar','bazbazbaz')) +drop table t2; +create table t2 (a decimal(10,5), filler char(200), key(a)); +insert into t2 select 345.67890, 'no' from t1 A, t1 B; +insert into t2 select 43245.34, 'no' from t1 A, t1 B; +insert into t2 select 64224.56344, 'no' from t1 A, t1 B; +insert into t2 values (0, '1'), (22334.123,'1'), (33333,'1'), +(55555,'1'), (77777, '1'); +explain +select * from t2 where a not in (345.67890, 43245.34, 64224.56344); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (4 workers) +2 SIMPLE t2 NULL range a a 7 NULL 5 100.00 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`filler` AS `filler` from `test`.`t2` where (`test`.`t2`.`a` not in (345.67890,43245.34,64224.56344)) +select * from t2 where a not in (345.67890, 43245.34, 64224.56344); +a filler +0.00000 1 +22334.12300 1 +33333.00000 1 +55555.00000 1 +77777.00000 1 +drop table t2; +create table t2 (a int, key(a), b int); +insert into t2 values (1,1),(2,2); +set @cnt= 1; +set @str="update t2 set b=1 where a not in ("; +select count(*) from ( +select @str:=concat(@str, @cnt:=@cnt+1, ",") +from t1 A, t1 B, t1 C, t1 D) Z; +count(*) +10000 +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +set @str:=concat(@str, "10000)"); +select substr(@str, 1, 50); +substr(@str, 1, 50) +update t2 set b=1 where a not in (2,3,4,5,6,7,8,9, +prepare s from @str; +execute s; +deallocate prepare s; +set @str=NULL; +drop table t2; +drop table t1; +create table t1 ( +some_id smallint(5) unsigned, +key (some_id) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t1 values (1),(2); +select some_id from t1 where some_id not in(2,-1); +some_id +1 +select some_id from t1 where some_id not in(-4,-1,-4); +some_id +1 +2 +select some_id from t1 where some_id not in(-4,-1,3423534,2342342); +some_id +1 +2 +select some_id from t1 where some_id not in('-1', '0'); +some_id +1 +2 +drop table t1; +# +# BUG#20420: optimizer reports wrong keys on left join with IN +# +CREATE TABLE t1 (a int, b int, PRIMARY KEY (a)); +INSERT INTO t1 VALUES (1,1),(2,1),(3,1),(4,1),(5,1),(6,1); +CREATE TABLE t2 (a int, b int, PRIMARY KEY (a)); +INSERT INTO t2 VALUES (3,2),(4,2),(100,100),(101,201),(102,102); +CREATE TABLE t3 (a int PRIMARY KEY); +INSERT INTO t3 VALUES (1),(2),(3),(4); +CREATE TABLE t4 (a int PRIMARY KEY,b int); +INSERT INTO t4 VALUES (1,1),(2,2),(1000,1000),(1001,1001),(1002,1002), +(1003,1003),(1004,1004); +EXPLAIN SELECT STRAIGHT_JOIN * FROM t3 +JOIN t1 ON t3.a=t1.a +JOIN t2 ON t3.a=t2.a +JOIN t4 WHERE t4.a IN (t1.b, t2.b); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t3 NULL index PRIMARY PRIMARY 4 NULL 4 100.00 Using index +2 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t3.a 1 100.00 NULL +2 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t3.a 1 100.00 NULL +2 SIMPLE t4 NULL ALL PRIMARY NULL NULL NULL 7 28.57 Range checked for each record (index map: 0x1) +Warnings: +Note 1003 /* select#1 */ select straight_join `test`.`t3`.`a` AS `a`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b` from `test`.`t3` join `test`.`t1` join `test`.`t2` join `test`.`t4` where ((`test`.`t1`.`a` = `test`.`t3`.`a`) and (`test`.`t2`.`a` = `test`.`t3`.`a`) and (`test`.`t4`.`a` in (`test`.`t1`.`b`,`test`.`t2`.`b`))) +SELECT STRAIGHT_JOIN * FROM t3 +JOIN t1 ON t3.a=t1.a +JOIN t2 ON t3.a=t2.a +JOIN t4 WHERE t4.a IN (t1.b, t2.b); +a a b a b a b +3 3 1 3 2 1 1 +3 3 1 3 2 2 2 +4 4 1 4 2 1 1 +4 4 1 4 2 2 2 +EXPLAIN SELECT STRAIGHT_JOIN +(SELECT SUM(t4.a) FROM t4 WHERE t4.a IN (t1.b, t2.b)) +FROM t3, t1, t2 +WHERE t3.a=t1.a AND t3.a=t2.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t3 NULL index PRIMARY PRIMARY 4 NULL 4 100.00 Using index +1 PRIMARY t1 NULL eq_ref PRIMARY PRIMARY 4 test.t3.a 1 100.00 NULL +1 PRIMARY t2 NULL eq_ref PRIMARY PRIMARY 4 test.t3.a 1 100.00 NULL +2 DEPENDENT SUBQUERY t4 NULL index NULL PRIMARY 4 NULL 7 28.57 Using where; Using index +Warnings: +Note 1276 Field or reference 'test.t1.b' of SELECT #2 was resolved in SELECT #1 +Note 1276 Field or reference 'test.t2.b' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select straight_join (/* select#2 */ select sum(`test`.`t4`.`a`) from `test`.`t4` where (`test`.`t4`.`a` in (`test`.`t1`.`b`,`test`.`t2`.`b`))) AS `(SELECT SUM(t4.a) FROM t4 WHERE t4.a IN (t1.b, t2.b))` from `test`.`t3` join `test`.`t1` join `test`.`t2` where ((`test`.`t1`.`a` = `test`.`t3`.`a`) and (`test`.`t2`.`a` = `test`.`t3`.`a`)) +SELECT STRAIGHT_JOIN +(SELECT SUM(t4.a) FROM t4 WHERE t4.a IN (t1.b, t2.b)) +FROM t3, t1, t2 +WHERE t3.a=t1.a AND t3.a=t2.a; +(SELECT SUM(t4.a) FROM t4 WHERE t4.a IN (t1.b, t2.b)) +3 +3 +DROP TABLE t1,t2,t3,t4; +CREATE TABLE t1(a BIGINT UNSIGNED); +INSERT INTO t1 VALUES (0xFFFFFFFFFFFFFFFF); +SELECT * FROM t1 WHERE a=-1 OR a=-2 ; +a +SELECT * FROM t1 WHERE a IN (-1, -2); +a +CREATE TABLE t2 (a BIGINT UNSIGNED); +insert into t2 values(13491727406643098568), +(0x7fffffefffffffff), +(0x7ffffffeffffffff), +(0x7fffffffefffffff), +(0x7ffffffffeffffff), +(0x7fffffffffefffff), +(0x7ffffffffffeffff), +(0x7fffffffffffefff), +(0x7ffffffffffffeff), +(0x7fffffffffffffef), +(0x7ffffffffffffffe), +(0x7fffffffffffffff), +(0x8000000000000000), +(0x8000000000000001), +(0x8000000000000002), +(0x8000000000000300), +(0x8000000000000400), +(0x8000000000000401), +(0x8000000000004001), +(0x8000000000040001), +(0x8000000000400001), +(0x8000000004000001), +(0x8000000040000001), +(0x8000000400000001), +(0x8000004000000001), +(0x8000040000000001); +SELECT HEX(a) FROM t2 WHERE a IN +(CAST(0xBB3C3E98175D33C8 AS UNSIGNED), +42); +HEX(a) +BB3C3E98175D33C8 +SELECT HEX(a) FROM t2 WHERE a IN +(CAST(0xBB3C3E98175D33C8 AS UNSIGNED), +CAST(0x7fffffffffffffff AS UNSIGNED), +CAST(0x8000000000000000 AS UNSIGNED), +CAST(0x8000000000000400 AS UNSIGNED), +CAST(0x8000000000000401 AS UNSIGNED), +42); +HEX(a) +BB3C3E98175D33C8 +7FFFFFFFFFFFFFFF +8000000000000000 +8000000000000400 +8000000000000401 +SELECT HEX(a) FROM t2 WHERE a IN +(CAST(0x7fffffffffffffff AS UNSIGNED), +CAST(0x8000000000000001 AS UNSIGNED)); +HEX(a) +7FFFFFFFFFFFFFFF +8000000000000001 +SELECT HEX(a) FROM t2 WHERE a IN +(CAST(0x7ffffffffffffffe AS UNSIGNED), +CAST(0x7fffffffffffffff AS UNSIGNED)); +HEX(a) +7FFFFFFFFFFFFFFE +7FFFFFFFFFFFFFFF +SELECT HEX(a) FROM t2 WHERE a IN +(0x7ffffffffffffffe, +0x7fffffffffffffff, +'abc'); +HEX(a) +7FFFFFFFFFFFFFFE +7FFFFFFFFFFFFFFF +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'abc' +CREATE TABLE t3 (a BIGINT UNSIGNED); +INSERT INTO t3 VALUES (9223372036854775551); +SELECT HEX(a) FROM t3 WHERE a IN (9223372036854775807, 42); +HEX(a) +CREATE TABLE t4 (a DATE); +INSERT INTO t4 VALUES ('1972-02-06'), ('1972-07-29'); +SELECT * FROM t4 WHERE a IN ('1972-02-06','19772-07-29'); +a +1972-02-06 +Warnings: +Warning 1292 Incorrect date value: '19772-07-29' for column 'a' at row 1 +Warning 1292 Incorrect date value: '19772-07-29' for column 'a' at row 1 +Warning 1292 Incorrect date value: '19772-07-29' for column 'a' at row 1 +DROP TABLE t1,t2,t3,t4; +CREATE TABLE t1 (id int not null); +INSERT INTO t1 VALUES (1),(2); +SELECT id FROM t1 WHERE id IN(4564, (SELECT IF(1=0,1,1/0)) ); +id +Warnings: +Warning 1365 Division by 0 +DROP TABLE t1; +End of 5.0 tests +create table t1(f1 char(1)); +insert into t1 values ('a'),('b'),('1'); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +select f1 from t1 where f1 in ('a',1); +f1 +1 +Warning 1292 Truncated incorrect DOUBLE value: 'b' +Warnings: +a +select f1, case f1 when 'a' then '+' when 1 then '-' end from t1; +f1 case f1 when 'a' then '+' when 1 then '-' end +a + +b NULL +1 - +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'b' +create index t1f1_idx on t1(f1); +select f1 from t1 where f1 in ('a',1); +f1 +1 +Warning 1292 Truncated incorrect DOUBLE value: 'b' +Warnings: +a +explain select f1 from t1 where f1 in ('a',1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL 2 NULL 3 50.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index t1f1_idx t1f1_idx 2 NULL 3 50.00 Using where; Using index +Warnings: +Warning 1739 Cannot use range access on index 't1f1_idx' due to type or collation conversion on field 'f1' +Note 1003 /* select#1 */ select `test`.`t1`.`f1` AS `f1` from `test`.`t1` where (`test`.`t1`.`f1` in ('a',1)) +select f1 from t1 where f1 in ('a','b'); +f1 +a +b +explain select f1 from t1 where f1 in ('a','b'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL 2 NULL 2 100.00 Parallel execute (2 workers) +2 SIMPLE t1 NULL range t1f1_idx t1f1_idx 2 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`f1` AS `f1` from `test`.`t1` where (`test`.`t1`.`f1` in ('a','b')) +select f1 from t1 where f1 in (2,1); +f1 +1 +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'a' +Warning 1292 Truncated incorrect DOUBLE value: 'b' +explain select f1 from t1 where f1 in (2,1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL 2 NULL 3 50.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index t1f1_idx t1f1_idx 2 NULL 3 50.00 Using where; Using index +Warnings: +Warning 1739 Cannot use range access on index 't1f1_idx' due to type or collation conversion on field 'f1' +Note 1003 /* select#1 */ select `test`.`t1`.`f1` AS `f1` from `test`.`t1` where (`test`.`t1`.`f1` in (2,1)) +create table t2(f2 int, index t2f2(f2)); +insert into t2 values(0),(1),(2); +select f2 from t2 where f2 in ('a',2); +f2 +0 +2 +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'a' +Warning 1292 Truncated incorrect DOUBLE value: 'a' +explain select f2 from t2 where f2 in ('a',2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (2 workers) +2 SIMPLE t2 NULL range t2f2 t2f2 5 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`f2` AS `f2` from `test`.`t2` where (`test`.`t2`.`f2` in ('a',2)) +select f2 from t2 where f2 in ('a','b'); +f2 +0 +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'a' +Warning 1292 Truncated incorrect DOUBLE value: 'b' +Warning 1292 Truncated incorrect DOUBLE value: 'a' +Warning 1292 Truncated incorrect DOUBLE value: 'b' +Warning 1292 Truncated incorrect DOUBLE value: 'a' +Warning 1292 Truncated incorrect DOUBLE value: 'b' +explain select f2 from t2 where f2 in ('a','b'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL range t2f2 t2f2 5 NULL 1 100.00 Using where; Using index +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'a' +Warning 1292 Truncated incorrect DOUBLE value: 'b' +Note 1003 /* select#1 */ select `test`.`t2`.`f2` AS `f2` from `test`.`t2` where (`test`.`t2`.`f2` in ('a','b')) +select f2 from t2 where f2 in (1,'b'); +f2 +0 +1 +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'b' +explain select f2 from t2 where f2 in (1,'b'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (2 workers) +2 SIMPLE t2 NULL range t2f2 t2f2 5 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`f2` AS `f2` from `test`.`t2` where (`test`.`t2`.`f2` in (1,'b')) +drop table t1, t2; +create table t1 (a time, key(a)); +insert into t1 values (),(),(),(),(),(),(),(),(),(); +select a from t1 where a not in (a,a,a) group by a; +a +drop table t1; +create table t1 (id int); +select * from t1 where NOT id in (select null union all select 1); +id +select * from t1 where NOT id in (null, 1); +id +drop table t1; +CREATE TABLE t1(c0 INTEGER, c1 INTEGER, c2 INTEGER); +INSERT INTO t1 VALUES(1, 1, 1), (1, 1, 1); +SELECT CASE AVG (c0) WHEN c1 * c2 THEN 1 END FROM t1; +CASE AVG (c0) WHEN c1 * c2 THEN 1 END +1 +SELECT CASE c1 * c2 WHEN SUM(c0) THEN 1 WHEN AVG(c0) THEN 2 END FROM t1; +CASE c1 * c2 WHEN SUM(c0) THEN 1 WHEN AVG(c0) THEN 2 END +2 +SELECT CASE c1 WHEN c1 + 1 THEN 1 END, ABS(AVG(c0)) FROM t1; +CASE c1 WHEN c1 + 1 THEN 1 END ABS(AVG(c0)) +NULL 1.0000 +DROP TABLE t1; +CREATE TABLE t1(a TEXT, b INT, c INT UNSIGNED, d DECIMAL(12,2), e REAL); +INSERT INTO t1 VALUES('iynfj', 1, 1, 1, 1); +INSERT INTO t1 VALUES('innfj', 2, 2, 2, 2); +SELECT SUM( DISTINCT a ) FROM t1 GROUP BY a HAVING a IN ( AVG( 1 ), 1 + a); +SUM( DISTINCT a ) +SELECT SUM( DISTINCT b ) FROM t1 GROUP BY b HAVING b IN ( AVG( 1 ), 1 + b); +SUM( DISTINCT b ) +1 +SELECT SUM( DISTINCT c ) FROM t1 GROUP BY c HAVING c IN ( AVG( 1 ), 1 + c); +SUM( DISTINCT c ) +1 +SELECT SUM( DISTINCT d ) FROM t1 GROUP BY d HAVING d IN ( AVG( 1 ), 1 + d); +SUM( DISTINCT d ) +1.00 +SELECT SUM( DISTINCT e ) FROM t1 GROUP BY e HAVING e IN ( AVG( 1 ), 1 + e); +SUM( DISTINCT e ) +1 +SELECT SUM( DISTINCT e ) FROM t1 GROUP BY b,c,d HAVING (b,c,d) IN +((AVG( 1 ), 1 + c, 1 + d), (AVG( 1 ), 2 + c, 2 + d)); +SUM( DISTINCT e ) +DROP TABLE t1; +# +# Bug #44139: Table scan when NULL appears in IN clause +# +CREATE TABLE t1 ( +c_int INT NOT NULL, +c_decimal DECIMAL(5,2) NOT NULL, +c_float FLOAT(5, 2) NOT NULL, +c_bit BIT(10) NOT NULL, +c_date DATE NOT NULL, +c_datetime DATETIME NOT NULL, +c_timestamp TIMESTAMP NOT NULL, +c_time TIME NOT NULL, +c_year YEAR NOT NULL, +c_char CHAR(10) character set utf8mb4 NOT NULL, +INDEX(c_int), INDEX(c_decimal), INDEX(c_float), INDEX(c_bit), INDEX(c_date), +INDEX(c_datetime), INDEX(c_timestamp), INDEX(c_time), INDEX(c_year), +INDEX(c_char)); +INSERT IGNORE INTO t1 (c_int) VALUES (1), (2), (3), (4), (5); +INSERT IGNORE INTO t1 (c_int) SELECT 0 FROM t1; +INSERT IGNORE INTO t1 (c_int) SELECT 0 FROM t1; +EXPLAIN SELECT * FROM t1 WHERE c_int IN (1, 2, 3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (3 workers) +2 SIMPLE t1 NULL range c_int c_int 4 NULL 3 100.00 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_int` in (1,2,3)) +EXPLAIN SELECT * FROM t1 WHERE c_int IN (NULL, 1, 2, 3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (3 workers) +2 SIMPLE t1 NULL range c_int c_int 4 NULL 3 100.00 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_int` in (NULL,1,2,3)) +EXPLAIN SELECT * FROM t1 WHERE c_int IN (1, 2, 3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (3 workers) +2 SIMPLE t1 NULL range c_int c_int 4 NULL 3 100.00 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_int` in (1,2,3)) +EXPLAIN SELECT * FROM t1 WHERE c_int IN (1, NULL, 2, NULL, 3, NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (3 workers) +2 SIMPLE t1 NULL range c_int c_int 4 NULL 3 100.00 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_int` in (1,NULL,2,NULL,3,NULL)) +EXPLAIN SELECT * FROM t1 WHERE c_int IN (NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_int` = NULL) +EXPLAIN SELECT * FROM t1 WHERE c_int IN (NULL, NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_int` in (NULL,NULL)) +EXPLAIN SELECT * FROM t1 WHERE c_decimal IN (1, 2, 3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range c_decimal c_decimal 3 NULL 3 100.00 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_decimal` in (1,2,3)) +EXPLAIN SELECT * FROM t1 WHERE c_decimal IN (NULL, 1, 2, 3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range c_decimal c_decimal 3 NULL 3 100.00 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_decimal` in (NULL,1,2,3)) +EXPLAIN SELECT * FROM t1 WHERE c_decimal IN (NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_decimal` = NULL) +EXPLAIN SELECT * FROM t1 WHERE c_decimal IN (NULL, NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_decimal` in (NULL,NULL)) +EXPLAIN SELECT * FROM t1 WHERE c_float IN (1, 2, 3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range c_float c_float 4 NULL 3 100.00 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_float` in (1,2,3)) +EXPLAIN SELECT * FROM t1 WHERE c_float IN (NULL, 1, 2, 3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range c_float c_float 4 NULL 3 100.00 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_float` in (NULL,1,2,3)) +EXPLAIN SELECT * FROM t1 WHERE c_float IN (NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_float` = NULL) +EXPLAIN SELECT * FROM t1 WHERE c_float IN (NULL, NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_float` in (NULL,NULL)) +EXPLAIN SELECT * FROM t1 WHERE c_bit IN (1, 2, 3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range c_bit c_bit 2 NULL 3 100.00 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_bit` in (1,2,3)) +EXPLAIN SELECT * FROM t1 WHERE c_bit IN (NULL, 1, 2, 3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range c_bit c_bit 2 NULL 3 100.00 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_bit` in (NULL,1,2,3)) +EXPLAIN SELECT * FROM t1 WHERE c_bit IN (NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_bit` = NULL) +EXPLAIN SELECT * FROM t1 WHERE c_bit IN (NULL, NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_bit` in (NULL,NULL)) +EXPLAIN SELECT * FROM t1 WHERE c_date +IN ('2009-09-01', '2009-09-02', '2009-09-03'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range c_date c_date 3 NULL 3 100.00 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_date` in ('2009-09-01','2009-09-02','2009-09-03')) +EXPLAIN SELECT * FROM t1 WHERE c_date +IN (NULL, '2009-09-01', '2009-09-02', '2009-09-03'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range c_date c_date 3 NULL 3 100.00 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_date` in (NULL,'2009-09-01','2009-09-02','2009-09-03')) +EXPLAIN SELECT * FROM t1 WHERE c_date IN (NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where multiple equal(NULL, `test`.`t1`.`c_date`) +EXPLAIN SELECT * FROM t1 WHERE c_date IN (NULL, NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_date` in (NULL,NULL)) +EXPLAIN SELECT * FROM t1 WHERE c_datetime +IN ('2009-09-01 00:00:01', '2009-09-02 00:00:01', '2009-09-03 00:00:01'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range c_datetime c_datetime 5 NULL 3 100.00 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_datetime` in ('2009-09-01 00:00:01','2009-09-02 00:00:01','2009-09-03 00:00:01')) +EXPLAIN SELECT * FROM t1 WHERE c_datetime +IN (NULL, '2009-09-01 00:00:01', '2009-09-02 00:00:01', '2009-09-03 00:00:01'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range c_datetime c_datetime 5 NULL 3 100.00 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_datetime` in (NULL,'2009-09-01 00:00:01','2009-09-02 00:00:01','2009-09-03 00:00:01')) +EXPLAIN SELECT * FROM t1 WHERE c_datetime IN (NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where multiple equal(NULL, `test`.`t1`.`c_datetime`) +EXPLAIN SELECT * FROM t1 WHERE c_datetime IN (NULL, NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_datetime` in (NULL,NULL)) +EXPLAIN SELECT * FROM t1 WHERE c_timestamp +IN ('2009-09-01 00:00:01', '2009-09-01 00:00:02', '2009-09-01 00:00:03'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range c_timestamp c_timestamp 4 NULL 3 100.00 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_timestamp` in ('2009-09-01 00:00:01','2009-09-01 00:00:02','2009-09-01 00:00:03')) +EXPLAIN SELECT * FROM t1 WHERE c_timestamp +IN (NULL, '2009-09-01 00:00:01', '2009-09-01 00:00:02', '2009-09-01 00:00:03'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range c_timestamp c_timestamp 4 NULL 3 100.00 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_timestamp` in (NULL,'2009-09-01 00:00:01','2009-09-01 00:00:02','2009-09-01 00:00:03')) +EXPLAIN SELECT * FROM t1 WHERE c_timestamp IN (NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where multiple equal(NULL, `test`.`t1`.`c_timestamp`) +EXPLAIN SELECT * FROM t1 WHERE c_timestamp IN (NULL, NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_timestamp` in (NULL,NULL)) +EXPLAIN SELECT * FROM t1 WHERE c_year IN (1, 2, 3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range c_year c_year 1 NULL 3 100.00 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_year` in (1,2,3)) +EXPLAIN SELECT * FROM t1 WHERE c_year IN (NULL, 1, 2, 3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range c_year c_year 1 NULL 3 100.00 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_year` in (NULL,1,2,3)) +EXPLAIN SELECT * FROM t1 WHERE c_year IN (NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_year` = NULL) +EXPLAIN SELECT * FROM t1 WHERE c_year IN (NULL, NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_year` in (NULL,NULL)) +EXPLAIN SELECT * FROM t1 WHERE c_char IN ('1', '2', '3'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range c_char c_char 40 NULL 3 100.00 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_char` in ('1','2','3')) +EXPLAIN SELECT * FROM t1 WHERE c_char IN (NULL, '1', '2', '3'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range c_char c_char 40 NULL 3 100.00 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_char` in (NULL,'1','2','3')) +EXPLAIN SELECT * FROM t1 WHERE c_char IN (NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where multiple equal(NULL, `test`.`t1`.`c_char`) +EXPLAIN SELECT * FROM t1 WHERE c_char IN (NULL, NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_char` in (NULL,NULL)) +DROP TABLE t1; +# +# Bug#54477: Crash on IN / CASE with NULL arguments +# +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2); +SELECT 1 IN (NULL, a) FROM t1; +1 IN (NULL, a) +1 +NULL +SELECT a IN (a, a) FROM t1 GROUP BY a WITH ROLLUP; +a IN (a, a) +1 +1 +NULL +SELECT CASE a WHEN a THEN a END FROM t1 GROUP BY a WITH ROLLUP; +CASE a WHEN a THEN a END +1 +2 +NULL +DROP TABLE t1; +# +# Bug#58628: Incorrect result for 'WHERE NULL NOT IN () +# +CREATE TABLE t1 (pk INT NOT NULL, i INT); +INSERT INTO t1 VALUES (0,NULL), (1,NULL), (2,NULL), (3,NULL); +CREATE TABLE subq (pk INT NOT NULL, i INT NOT NULL, PRIMARY KEY(i,pk)); +INSERT INTO subq VALUES (0,0), (1,1), (2,2), (3,3); +SELECT * FROM t1 +WHERE t1.i NOT IN +(SELECT i FROM subq WHERE subq.pk = t1.pk); +pk i +SELECT * FROM t1 +WHERE t1.i IN +(SELECT i FROM subq WHERE subq.pk = t1.pk) IS UNKNOWN; +pk i +0 NULL +1 NULL +2 NULL +3 NULL +SELECT * FROM t1 +WHERE NULL NOT IN +(SELECT i FROM subq WHERE subq.pk = t1.pk); +pk i +SELECT * FROM t1 +WHERE NULL IN +(SELECT i FROM subq WHERE subq.pk = t1.pk) IS UNKNOWN; +pk i +0 NULL +1 NULL +2 NULL +3 NULL +SELECT * FROM t1 +WHERE 1+NULL NOT IN +(SELECT i FROM subq WHERE subq.pk = t1.pk); +pk i +DROP TABLE t1,subq; +# +# Bug #11766270 59343: YEAR(4): INCORRECT RESULT AND VALGRIND WARNINGS WITH MIN/MAX, UNION +# +CREATE TABLE t1(f1 YEAR); +INSERT INTO t1 VALUES (0000),(2001); +(SELECT MAX(f1) FROM t1) UNION (SELECT MAX(f1) FROM t1); +Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr +def MAX(f1) MAX(f1) 13 4 4 Y 32864 0 63 +MAX(f1) +2001 +DROP TABLE t1; +# +# Bug #11764651-57510: IN(string,real,string) causes invalid read in sort function +# +SELECT LEFT(ST_GEOMFROMTEXT("POINT(0 0)"),1) IN (@@global.max_allowed_packet,1,""); +LEFT(ST_GEOMFROMTEXT("POINT(0 0)"),1) IN (@@global.max_allowed_packet,1,"") +0 +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: '\x00' +# End of test BUG#11764651-57510 +End of 5.1 tests +set optimizer_switch=default; diff --git a/mysql-test/r/func_in_icp_mrr.result-pq b/mysql-test/r/func_in_icp_mrr.result-pq new file mode 100644 index 000000000000..08115d529f2d --- /dev/null +++ b/mysql-test/r/func_in_icp_mrr.result-pq @@ -0,0 +1,998 @@ +set optimizer_switch='index_condition_pushdown=on,mrr=on,mrr_cost_based=off'; +drop table if exists t1, t2; +select 1 in (1,2,3); +1 in (1,2,3) +1 +select 10 in (1,2,3); +10 in (1,2,3) +0 +select NULL in (1,2,3); +NULL in (1,2,3) +NULL +select 1 in (1,NULL,3); +1 in (1,NULL,3) +1 +select 3 in (1,NULL,3); +3 in (1,NULL,3) +1 +select 10 in (1,NULL,3); +10 in (1,NULL,3) +NULL +select 1.5 in (1.5,2.5,3.5); +1.5 in (1.5,2.5,3.5) +1 +select 10.5 in (1.5,2.5,3.5); +10.5 in (1.5,2.5,3.5) +0 +select NULL in (1.5,2.5,3.5); +NULL in (1.5,2.5,3.5) +NULL +select 1.5 in (1.5,NULL,3.5); +1.5 in (1.5,NULL,3.5) +1 +select 3.5 in (1.5,NULL,3.5); +3.5 in (1.5,NULL,3.5) +1 +select 10.5 in (1.5,NULL,3.5); +10.5 in (1.5,NULL,3.5) +NULL +CREATE TABLE t1 (a int, b int, c int); +insert into t1 values (1,2,3), (1,NULL,3); +select 1 in (a,b,c) from t1; +1 in (a,b,c) +1 +1 +select 3 in (a,b,c) from t1; +3 in (a,b,c) +1 +1 +select 10 in (a,b,c) from t1; +10 in (a,b,c) +0 +NULL +select NULL in (a,b,c) from t1; +NULL in (a,b,c) +NULL +NULL +drop table t1; +CREATE TABLE t1 (a float, b float, c float); +insert into t1 values (1.5,2.5,3.5), (1.5,NULL,3.5); +select 1.5 in (a,b,c) from t1; +1.5 in (a,b,c) +1 +1 +select 3.5 in (a,b,c) from t1; +3.5 in (a,b,c) +1 +1 +select 10.5 in (a,b,c) from t1; +10.5 in (a,b,c) +0 +NULL +drop table t1; +CREATE TABLE t1 (a varchar(10), b varchar(10), c varchar(10)); +insert into t1 values ('A','BC','EFD'), ('A',NULL,'EFD'); +select 'A' in (a,b,c) from t1; +'A' in (a,b,c) +1 +1 +select 'EFD' in (a,b,c) from t1; +'EFD' in (a,b,c) +1 +1 +select 'XSFGGHF' in (a,b,c) from t1; +'XSFGGHF' in (a,b,c) +0 +NULL +drop table t1; +CREATE TABLE t1 (field char(1)); +INSERT INTO t1 VALUES ('A'),(NULL); +SELECT * from t1 WHERE field IN (NULL); +field +SELECT * from t1 WHERE field NOT IN (NULL); +field +SELECT * from t1 where field = field; +field +A +SELECT * from t1 where field <=> field; +field +A +NULL +DELETE FROM t1 WHERE field NOT IN (NULL); +SELECT * FROM t1; +field +A +NULL +drop table t1; +create table t1 (id int(10) primary key); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t1 values (1),(2),(3),(4),(5),(6),(7),(8),(9); +select * from t1 where id in (2,5,9); +id +2 +5 +9 +drop table t1; +create table t1 ( +a char(1) character set latin1 collate latin1_general_ci, +b char(1) character set latin1 collate latin1_swedish_ci, +c char(1) character set latin1 collate latin1_danish_ci +); +insert into t1 values ('A','B','C'); +insert into t1 values ('a','c','c'); +select * from t1 where a in (b); +ERROR HY000: Illegal mix of collations (latin1_general_ci,IMPLICIT) and (latin1_swedish_ci,IMPLICIT) for operation '=' +select * from t1 where a in (b,c); +ERROR HY000: Illegal mix of collations (latin1_general_ci,IMPLICIT), (latin1_swedish_ci,IMPLICIT), (latin1_danish_ci,IMPLICIT) for operation ' IN ' +select * from t1 where 'a' in (a,b,c); +ERROR HY000: Illegal mix of collations for operation ' IN ' +select * from t1 where 'a' in (a); +a b c +A B C +a c c +select * from t1 where a in ('a'); +a b c +A B C +a c c +set names latin1; +select * from t1 where 'a' collate latin1_general_ci in (a,b,c); +a b c +A B C +a c c +select * from t1 where 'a' collate latin1_bin in (a,b,c); +a b c +a c c +select * from t1 where 'a' in (a,b,c collate latin1_bin); +a b c +a c c +explain select * from t1 where 'a' in (a,b,c collate latin1_bin); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` where ('a' in (`test`.`t1`.`a`,`test`.`t1`.`b`,(`test`.`t1`.`c` collate latin1_bin))) +drop table t1; +set names utf8mb4; +set names utf8; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +create table t1 (a char(10) character set utf8 not null); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +insert into t1 values ('bbbb'),(_koi8r x'C3C3C3C3'),(_latin1 x'C4C4C4C4'); +select a from t1 where a in ('bbbb',_koi8r x'C3C3C3C3',_latin1 x'C4C4C4C4') order by a; +a +ÄÄÄÄ +bbbb +цццц +drop table t1; +create table t1 (a char(10) character set latin1 not null); +insert into t1 values ('a'),('b'),('c'); +select a from t1 where a IN ('a','b','c') order by a; +a +a +b +c +drop table t1; +set names latin1; +select '1.0' in (1,2); +'1.0' in (1,2) +1 +select 1 in ('1.0',2); +1 in ('1.0',2) +1 +select 1 in (1,'2.0'); +1 in (1,'2.0') +1 +select 1 in ('1.0',2.0); +1 in ('1.0',2.0) +1 +select 1 in (1.0,'2.0'); +1 in (1.0,'2.0') +1 +select 1 in ('1.1',2); +1 in ('1.1',2) +0 +select 1 in ('1.1',2.0); +1 in ('1.1',2.0) +0 +create table t1 (a char(2) character set binary); +insert into t1 values ('aa'), ('bb'); +select * from t1 where a in (NULL, 'aa'); +a +aa +drop table t1; +create table t1 (id int, key(id)); +insert into t1 values (1),(2),(3); +select count(*) from t1 where id not in (1); +count(*) +2 +select count(*) from t1 where id not in (1,2); +count(*) +1 +drop table t1; +DROP TABLE IF EXISTS t1; +CREATE TABLE t1 SELECT 1 IN (2, NULL); +SELECT should return NULL. +SELECT * FROM t1; +1 IN (2, NULL) +NULL +DROP TABLE t1; +End of 4.1 tests +CREATE TABLE t1 (a int PRIMARY KEY); +INSERT INTO t1 VALUES (44), (45), (46); +SELECT * FROM t1 WHERE a IN (45); +a +45 +SELECT * FROM t1 WHERE a NOT IN (0, 45); +a +44 +46 +SELECT * FROM t1 WHERE a NOT IN (45); +a +44 +46 +CREATE VIEW v1 AS SELECT * FROM t1 WHERE a NOT IN (45); +SHOW CREATE VIEW v1; +View Create View character_set_client collation_connection +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`a` AS `a` from `t1` where (`t1`.`a` <> 45) latin1 latin1_swedish_ci +SELECT * FROM v1; +a +44 +46 +DROP VIEW v1; +DROP TABLE t1; +create table t1 (a int); +insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t2 (a int, filler char(200), key(a)); +insert into t2 select C.a*2, 'no' from t1 A, t1 B, t1 C; +insert into t2 select C.a*2+1, 'yes' from t1 C; +explain +select * from t2 where a NOT IN (0, 2,4,6,8,10,12,14,16,18); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 100.00 Parallel execute (4 workers) +2 SIMPLE t2 NULL range a a 5 NULL 11 100.00 Using index condition; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`filler` AS `filler` from `test`.`t2` where (`test`.`t2`.`a` not in (0,2,4,6,8,10,12,14,16,18)) +select * from t2 where a NOT IN (0, 2,4,6,8,10,12,14,16,18); +a filler +1 yes +3 yes +5 yes +7 yes +9 yes +11 yes +13 yes +15 yes +17 yes +19 yes +explain select * from t2 force index(a) where a NOT IN (2,2,2,2,2,2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 910 100.00 Parallel execute (3 workers) +2 SIMPLE t2 NULL range a a 5 NULL 910 100.00 Using index condition; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`filler` AS `filler` from `test`.`t2` FORCE INDEX (`a`) where (`test`.`t2`.`a` not in (2,2,2,2,2,2)) +explain select * from t2 force index(a) where a <> 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 910 100.00 Parallel execute (3 workers) +2 SIMPLE t2 NULL range a a 5 NULL 910 100.00 Using index condition; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`filler` AS `filler` from `test`.`t2` FORCE INDEX (`a`) where (`test`.`t2`.`a` <> 2) +drop table t2; +create table t2 (a datetime, filler char(200), key(a)); +insert into t2 select '2006-04-25 10:00:00' + interval C.a minute, +'no' from t1 A, t1 B, t1 C where C.a % 2 = 0; +insert into t2 select '2006-04-25 10:00:00' + interval C.a*2+1 minute, +'yes' from t1 C; +explain +select * from t2 where a NOT IN ( +'2006-04-25 10:00:00','2006-04-25 10:02:00','2006-04-25 10:04:00', +'2006-04-25 10:06:00', '2006-04-25 10:08:00'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 100.00 Parallel execute (4 workers) +2 SIMPLE t2 NULL range a a 6 NULL 11 100.00 Using index condition; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`filler` AS `filler` from `test`.`t2` where (`test`.`t2`.`a` not in ('2006-04-25 10:00:00','2006-04-25 10:02:00','2006-04-25 10:04:00','2006-04-25 10:06:00','2006-04-25 10:08:00')) +select * from t2 where a NOT IN ( +'2006-04-25 10:00:00','2006-04-25 10:02:00','2006-04-25 10:04:00', +'2006-04-25 10:06:00', '2006-04-25 10:08:00'); +a filler +2006-04-25 10:01:00 yes +2006-04-25 10:03:00 yes +2006-04-25 10:05:00 yes +2006-04-25 10:07:00 yes +2006-04-25 10:09:00 yes +2006-04-25 10:11:00 yes +2006-04-25 10:13:00 yes +2006-04-25 10:15:00 yes +2006-04-25 10:17:00 yes +2006-04-25 10:19:00 yes +drop table t2; +create table t2 (a varchar(10), filler char(200), key(a)); +insert into t2 select 'foo', 'no' from t1 A, t1 B; +insert into t2 select 'barbar', 'no' from t1 A, t1 B; +insert into t2 select 'bazbazbaz', 'no' from t1 A, t1 B; +insert into t2 values ('fon', '1'), ('fop','1'), ('barbaq','1'), +('barbas','1'), ('bazbazbay', '1'),('zz','1'); +explain select * from t2 where a not in('foo','barbar', 'bazbazbaz'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL 13 NULL 6 100.00 Parallel execute (4 workers) +2 SIMPLE t2 NULL range a a 13 NULL 6 100.00 Using index condition; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`filler` AS `filler` from `test`.`t2` where (`test`.`t2`.`a` not in ('foo','barbar','bazbazbaz')) +drop table t2; +create table t2 (a decimal(10,5), filler char(200), key(a)); +insert into t2 select 345.67890, 'no' from t1 A, t1 B; +insert into t2 select 43245.34, 'no' from t1 A, t1 B; +insert into t2 select 64224.56344, 'no' from t1 A, t1 B; +insert into t2 values (0, '1'), (22334.123,'1'), (33333,'1'), +(55555,'1'), (77777, '1'); +explain +select * from t2 where a not in (345.67890, 43245.34, 64224.56344); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (4 workers) +2 SIMPLE t2 NULL range a a 7 NULL 5 100.00 Using index condition; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`filler` AS `filler` from `test`.`t2` where (`test`.`t2`.`a` not in (345.67890,43245.34,64224.56344)) +select * from t2 where a not in (345.67890, 43245.34, 64224.56344); +a filler +0.00000 1 +22334.12300 1 +33333.00000 1 +55555.00000 1 +77777.00000 1 +drop table t2; +create table t2 (a int, key(a), b int); +insert into t2 values (1,1),(2,2); +set @cnt= 1; +set @str="update t2 set b=1 where a not in ("; +select count(*) from ( +select @str:=concat(@str, @cnt:=@cnt+1, ",") +from t1 A, t1 B, t1 C, t1 D) Z; +count(*) +10000 +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +set @str:=concat(@str, "10000)"); +select substr(@str, 1, 50); +substr(@str, 1, 50) +update t2 set b=1 where a not in (2,3,4,5,6,7,8,9, +prepare s from @str; +execute s; +deallocate prepare s; +set @str=NULL; +drop table t2; +drop table t1; +create table t1 ( +some_id smallint(5) unsigned, +key (some_id) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t1 values (1),(2); +select some_id from t1 where some_id not in(2,-1); +some_id +1 +select some_id from t1 where some_id not in(-4,-1,-4); +some_id +1 +2 +select some_id from t1 where some_id not in(-4,-1,3423534,2342342); +some_id +1 +2 +select some_id from t1 where some_id not in('-1', '0'); +some_id +1 +2 +drop table t1; +# +# BUG#20420: optimizer reports wrong keys on left join with IN +# +CREATE TABLE t1 (a int, b int, PRIMARY KEY (a)); +INSERT INTO t1 VALUES (1,1),(2,1),(3,1),(4,1),(5,1),(6,1); +CREATE TABLE t2 (a int, b int, PRIMARY KEY (a)); +INSERT INTO t2 VALUES (3,2),(4,2),(100,100),(101,201),(102,102); +CREATE TABLE t3 (a int PRIMARY KEY); +INSERT INTO t3 VALUES (1),(2),(3),(4); +CREATE TABLE t4 (a int PRIMARY KEY,b int); +INSERT INTO t4 VALUES (1,1),(2,2),(1000,1000),(1001,1001),(1002,1002), +(1003,1003),(1004,1004); +EXPLAIN SELECT STRAIGHT_JOIN * FROM t3 +JOIN t1 ON t3.a=t1.a +JOIN t2 ON t3.a=t2.a +JOIN t4 WHERE t4.a IN (t1.b, t2.b); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t3 NULL index PRIMARY PRIMARY 4 NULL 4 100.00 Using index +2 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t3.a 1 100.00 NULL +2 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t3.a 1 100.00 NULL +2 SIMPLE t4 NULL ALL PRIMARY NULL NULL NULL 7 28.57 Range checked for each record (index map: 0x1) +Warnings: +Note 1003 /* select#1 */ select straight_join `test`.`t3`.`a` AS `a`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b` from `test`.`t3` join `test`.`t1` join `test`.`t2` join `test`.`t4` where ((`test`.`t1`.`a` = `test`.`t3`.`a`) and (`test`.`t2`.`a` = `test`.`t3`.`a`) and (`test`.`t4`.`a` in (`test`.`t1`.`b`,`test`.`t2`.`b`))) +SELECT STRAIGHT_JOIN * FROM t3 +JOIN t1 ON t3.a=t1.a +JOIN t2 ON t3.a=t2.a +JOIN t4 WHERE t4.a IN (t1.b, t2.b); +a a b a b a b +3 3 1 3 2 1 1 +3 3 1 3 2 2 2 +4 4 1 4 2 1 1 +4 4 1 4 2 2 2 +EXPLAIN SELECT STRAIGHT_JOIN +(SELECT SUM(t4.a) FROM t4 WHERE t4.a IN (t1.b, t2.b)) +FROM t3, t1, t2 +WHERE t3.a=t1.a AND t3.a=t2.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t3 NULL index PRIMARY PRIMARY 4 NULL 4 100.00 Using index +1 PRIMARY t1 NULL eq_ref PRIMARY PRIMARY 4 test.t3.a 1 100.00 NULL +1 PRIMARY t2 NULL eq_ref PRIMARY PRIMARY 4 test.t3.a 1 100.00 NULL +2 DEPENDENT SUBQUERY t4 NULL index NULL PRIMARY 4 NULL 7 28.57 Using where; Using index +Warnings: +Note 1276 Field or reference 'test.t1.b' of SELECT #2 was resolved in SELECT #1 +Note 1276 Field or reference 'test.t2.b' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select straight_join (/* select#2 */ select sum(`test`.`t4`.`a`) from `test`.`t4` where (`test`.`t4`.`a` in (`test`.`t1`.`b`,`test`.`t2`.`b`))) AS `(SELECT SUM(t4.a) FROM t4 WHERE t4.a IN (t1.b, t2.b))` from `test`.`t3` join `test`.`t1` join `test`.`t2` where ((`test`.`t1`.`a` = `test`.`t3`.`a`) and (`test`.`t2`.`a` = `test`.`t3`.`a`)) +SELECT STRAIGHT_JOIN +(SELECT SUM(t4.a) FROM t4 WHERE t4.a IN (t1.b, t2.b)) +FROM t3, t1, t2 +WHERE t3.a=t1.a AND t3.a=t2.a; +(SELECT SUM(t4.a) FROM t4 WHERE t4.a IN (t1.b, t2.b)) +3 +3 +DROP TABLE t1,t2,t3,t4; +CREATE TABLE t1(a BIGINT UNSIGNED); +INSERT INTO t1 VALUES (0xFFFFFFFFFFFFFFFF); +SELECT * FROM t1 WHERE a=-1 OR a=-2 ; +a +SELECT * FROM t1 WHERE a IN (-1, -2); +a +CREATE TABLE t2 (a BIGINT UNSIGNED); +insert into t2 values(13491727406643098568), +(0x7fffffefffffffff), +(0x7ffffffeffffffff), +(0x7fffffffefffffff), +(0x7ffffffffeffffff), +(0x7fffffffffefffff), +(0x7ffffffffffeffff), +(0x7fffffffffffefff), +(0x7ffffffffffffeff), +(0x7fffffffffffffef), +(0x7ffffffffffffffe), +(0x7fffffffffffffff), +(0x8000000000000000), +(0x8000000000000001), +(0x8000000000000002), +(0x8000000000000300), +(0x8000000000000400), +(0x8000000000000401), +(0x8000000000004001), +(0x8000000000040001), +(0x8000000000400001), +(0x8000000004000001), +(0x8000000040000001), +(0x8000000400000001), +(0x8000004000000001), +(0x8000040000000001); +SELECT HEX(a) FROM t2 WHERE a IN +(CAST(0xBB3C3E98175D33C8 AS UNSIGNED), +42); +HEX(a) +BB3C3E98175D33C8 +SELECT HEX(a) FROM t2 WHERE a IN +(CAST(0xBB3C3E98175D33C8 AS UNSIGNED), +CAST(0x7fffffffffffffff AS UNSIGNED), +CAST(0x8000000000000000 AS UNSIGNED), +CAST(0x8000000000000400 AS UNSIGNED), +CAST(0x8000000000000401 AS UNSIGNED), +42); +HEX(a) +BB3C3E98175D33C8 +7FFFFFFFFFFFFFFF +8000000000000000 +8000000000000400 +8000000000000401 +SELECT HEX(a) FROM t2 WHERE a IN +(CAST(0x7fffffffffffffff AS UNSIGNED), +CAST(0x8000000000000001 AS UNSIGNED)); +HEX(a) +7FFFFFFFFFFFFFFF +8000000000000001 +SELECT HEX(a) FROM t2 WHERE a IN +(CAST(0x7ffffffffffffffe AS UNSIGNED), +CAST(0x7fffffffffffffff AS UNSIGNED)); +HEX(a) +7FFFFFFFFFFFFFFE +7FFFFFFFFFFFFFFF +SELECT HEX(a) FROM t2 WHERE a IN +(0x7ffffffffffffffe, +0x7fffffffffffffff, +'abc'); +HEX(a) +7FFFFFFFFFFFFFFE +7FFFFFFFFFFFFFFF +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'abc' +CREATE TABLE t3 (a BIGINT UNSIGNED); +INSERT INTO t3 VALUES (9223372036854775551); +SELECT HEX(a) FROM t3 WHERE a IN (9223372036854775807, 42); +HEX(a) +CREATE TABLE t4 (a DATE); +INSERT INTO t4 VALUES ('1972-02-06'), ('1972-07-29'); +SELECT * FROM t4 WHERE a IN ('1972-02-06','19772-07-29'); +a +1972-02-06 +Warnings: +Warning 1292 Incorrect date value: '19772-07-29' for column 'a' at row 1 +Warning 1292 Incorrect date value: '19772-07-29' for column 'a' at row 1 +Warning 1292 Incorrect date value: '19772-07-29' for column 'a' at row 1 +DROP TABLE t1,t2,t3,t4; +CREATE TABLE t1 (id int not null); +INSERT INTO t1 VALUES (1),(2); +SELECT id FROM t1 WHERE id IN(4564, (SELECT IF(1=0,1,1/0)) ); +id +Warnings: +Warning 1365 Division by 0 +DROP TABLE t1; +End of 5.0 tests +create table t1(f1 char(1)); +insert into t1 values ('a'),('b'),('1'); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +select f1 from t1 where f1 in ('a',1); +f1 +1 +Warning 1292 Truncated incorrect DOUBLE value: 'b' +Warnings: +a +select f1, case f1 when 'a' then '+' when 1 then '-' end from t1; +f1 case f1 when 'a' then '+' when 1 then '-' end +a + +b NULL +1 - +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'b' +create index t1f1_idx on t1(f1); +select f1 from t1 where f1 in ('a',1); +f1 +1 +Warning 1292 Truncated incorrect DOUBLE value: 'b' +Warnings: +a +explain select f1 from t1 where f1 in ('a',1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL 2 NULL 3 50.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index t1f1_idx t1f1_idx 2 NULL 3 50.00 Using where; Using index +Warnings: +Warning 1739 Cannot use range access on index 't1f1_idx' due to type or collation conversion on field 'f1' +Note 1003 /* select#1 */ select `test`.`t1`.`f1` AS `f1` from `test`.`t1` where (`test`.`t1`.`f1` in ('a',1)) +select f1 from t1 where f1 in ('a','b'); +f1 +a +b +explain select f1 from t1 where f1 in ('a','b'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL 2 NULL 2 100.00 Parallel execute (2 workers) +2 SIMPLE t1 NULL range t1f1_idx t1f1_idx 2 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`f1` AS `f1` from `test`.`t1` where (`test`.`t1`.`f1` in ('a','b')) +select f1 from t1 where f1 in (2,1); +f1 +1 +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'a' +Warning 1292 Truncated incorrect DOUBLE value: 'b' +explain select f1 from t1 where f1 in (2,1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL 2 NULL 3 50.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index t1f1_idx t1f1_idx 2 NULL 3 50.00 Using where; Using index +Warnings: +Warning 1739 Cannot use range access on index 't1f1_idx' due to type or collation conversion on field 'f1' +Note 1003 /* select#1 */ select `test`.`t1`.`f1` AS `f1` from `test`.`t1` where (`test`.`t1`.`f1` in (2,1)) +create table t2(f2 int, index t2f2(f2)); +insert into t2 values(0),(1),(2); +select f2 from t2 where f2 in ('a',2); +f2 +0 +2 +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'a' +Warning 1292 Truncated incorrect DOUBLE value: 'a' +explain select f2 from t2 where f2 in ('a',2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (2 workers) +2 SIMPLE t2 NULL range t2f2 t2f2 5 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`f2` AS `f2` from `test`.`t2` where (`test`.`t2`.`f2` in ('a',2)) +select f2 from t2 where f2 in ('a','b'); +f2 +0 +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'a' +Warning 1292 Truncated incorrect DOUBLE value: 'b' +Warning 1292 Truncated incorrect DOUBLE value: 'a' +Warning 1292 Truncated incorrect DOUBLE value: 'b' +Warning 1292 Truncated incorrect DOUBLE value: 'a' +Warning 1292 Truncated incorrect DOUBLE value: 'b' +explain select f2 from t2 where f2 in ('a','b'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL range t2f2 t2f2 5 NULL 1 100.00 Using where; Using index +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'a' +Warning 1292 Truncated incorrect DOUBLE value: 'b' +Note 1003 /* select#1 */ select `test`.`t2`.`f2` AS `f2` from `test`.`t2` where (`test`.`t2`.`f2` in ('a','b')) +select f2 from t2 where f2 in (1,'b'); +f2 +0 +1 +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'b' +explain select f2 from t2 where f2 in (1,'b'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (2 workers) +2 SIMPLE t2 NULL range t2f2 t2f2 5 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`f2` AS `f2` from `test`.`t2` where (`test`.`t2`.`f2` in (1,'b')) +drop table t1, t2; +create table t1 (a time, key(a)); +insert into t1 values (),(),(),(),(),(),(),(),(),(); +select a from t1 where a not in (a,a,a) group by a; +a +drop table t1; +create table t1 (id int); +select * from t1 where NOT id in (select null union all select 1); +id +select * from t1 where NOT id in (null, 1); +id +drop table t1; +CREATE TABLE t1(c0 INTEGER, c1 INTEGER, c2 INTEGER); +INSERT INTO t1 VALUES(1, 1, 1), (1, 1, 1); +SELECT CASE AVG (c0) WHEN c1 * c2 THEN 1 END FROM t1; +CASE AVG (c0) WHEN c1 * c2 THEN 1 END +1 +SELECT CASE c1 * c2 WHEN SUM(c0) THEN 1 WHEN AVG(c0) THEN 2 END FROM t1; +CASE c1 * c2 WHEN SUM(c0) THEN 1 WHEN AVG(c0) THEN 2 END +2 +SELECT CASE c1 WHEN c1 + 1 THEN 1 END, ABS(AVG(c0)) FROM t1; +CASE c1 WHEN c1 + 1 THEN 1 END ABS(AVG(c0)) +NULL 1.0000 +DROP TABLE t1; +CREATE TABLE t1(a TEXT, b INT, c INT UNSIGNED, d DECIMAL(12,2), e REAL); +INSERT INTO t1 VALUES('iynfj', 1, 1, 1, 1); +INSERT INTO t1 VALUES('innfj', 2, 2, 2, 2); +SELECT SUM( DISTINCT a ) FROM t1 GROUP BY a HAVING a IN ( AVG( 1 ), 1 + a); +SUM( DISTINCT a ) +SELECT SUM( DISTINCT b ) FROM t1 GROUP BY b HAVING b IN ( AVG( 1 ), 1 + b); +SUM( DISTINCT b ) +1 +SELECT SUM( DISTINCT c ) FROM t1 GROUP BY c HAVING c IN ( AVG( 1 ), 1 + c); +SUM( DISTINCT c ) +1 +SELECT SUM( DISTINCT d ) FROM t1 GROUP BY d HAVING d IN ( AVG( 1 ), 1 + d); +SUM( DISTINCT d ) +1.00 +SELECT SUM( DISTINCT e ) FROM t1 GROUP BY e HAVING e IN ( AVG( 1 ), 1 + e); +SUM( DISTINCT e ) +1 +SELECT SUM( DISTINCT e ) FROM t1 GROUP BY b,c,d HAVING (b,c,d) IN +((AVG( 1 ), 1 + c, 1 + d), (AVG( 1 ), 2 + c, 2 + d)); +SUM( DISTINCT e ) +DROP TABLE t1; +# +# Bug #44139: Table scan when NULL appears in IN clause +# +CREATE TABLE t1 ( +c_int INT NOT NULL, +c_decimal DECIMAL(5,2) NOT NULL, +c_float FLOAT(5, 2) NOT NULL, +c_bit BIT(10) NOT NULL, +c_date DATE NOT NULL, +c_datetime DATETIME NOT NULL, +c_timestamp TIMESTAMP NOT NULL, +c_time TIME NOT NULL, +c_year YEAR NOT NULL, +c_char CHAR(10) character set utf8mb4 NOT NULL, +INDEX(c_int), INDEX(c_decimal), INDEX(c_float), INDEX(c_bit), INDEX(c_date), +INDEX(c_datetime), INDEX(c_timestamp), INDEX(c_time), INDEX(c_year), +INDEX(c_char)); +INSERT IGNORE INTO t1 (c_int) VALUES (1), (2), (3), (4), (5); +INSERT IGNORE INTO t1 (c_int) SELECT 0 FROM t1; +INSERT IGNORE INTO t1 (c_int) SELECT 0 FROM t1; +EXPLAIN SELECT * FROM t1 WHERE c_int IN (1, 2, 3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (3 workers) +2 SIMPLE t1 NULL range c_int c_int 4 NULL 3 100.00 Using index condition; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_int` in (1,2,3)) +EXPLAIN SELECT * FROM t1 WHERE c_int IN (NULL, 1, 2, 3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (3 workers) +2 SIMPLE t1 NULL range c_int c_int 4 NULL 3 100.00 Using index condition; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_int` in (NULL,1,2,3)) +EXPLAIN SELECT * FROM t1 WHERE c_int IN (1, 2, 3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (3 workers) +2 SIMPLE t1 NULL range c_int c_int 4 NULL 3 100.00 Using index condition; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_int` in (1,2,3)) +EXPLAIN SELECT * FROM t1 WHERE c_int IN (1, NULL, 2, NULL, 3, NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (3 workers) +2 SIMPLE t1 NULL range c_int c_int 4 NULL 3 100.00 Using index condition; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_int` in (1,NULL,2,NULL,3,NULL)) +EXPLAIN SELECT * FROM t1 WHERE c_int IN (NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_int` = NULL) +EXPLAIN SELECT * FROM t1 WHERE c_int IN (NULL, NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_int` in (NULL,NULL)) +EXPLAIN SELECT * FROM t1 WHERE c_decimal IN (1, 2, 3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range c_decimal c_decimal 3 NULL 3 100.00 Using index condition; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_decimal` in (1,2,3)) +EXPLAIN SELECT * FROM t1 WHERE c_decimal IN (NULL, 1, 2, 3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range c_decimal c_decimal 3 NULL 3 100.00 Using index condition; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_decimal` in (NULL,1,2,3)) +EXPLAIN SELECT * FROM t1 WHERE c_decimal IN (NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_decimal` = NULL) +EXPLAIN SELECT * FROM t1 WHERE c_decimal IN (NULL, NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_decimal` in (NULL,NULL)) +EXPLAIN SELECT * FROM t1 WHERE c_float IN (1, 2, 3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range c_float c_float 4 NULL 3 100.00 Using index condition; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_float` in (1,2,3)) +EXPLAIN SELECT * FROM t1 WHERE c_float IN (NULL, 1, 2, 3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range c_float c_float 4 NULL 3 100.00 Using index condition; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_float` in (NULL,1,2,3)) +EXPLAIN SELECT * FROM t1 WHERE c_float IN (NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_float` = NULL) +EXPLAIN SELECT * FROM t1 WHERE c_float IN (NULL, NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_float` in (NULL,NULL)) +EXPLAIN SELECT * FROM t1 WHERE c_bit IN (1, 2, 3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range c_bit c_bit 2 NULL 3 100.00 Using index condition; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_bit` in (1,2,3)) +EXPLAIN SELECT * FROM t1 WHERE c_bit IN (NULL, 1, 2, 3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range c_bit c_bit 2 NULL 3 100.00 Using index condition; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_bit` in (NULL,1,2,3)) +EXPLAIN SELECT * FROM t1 WHERE c_bit IN (NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_bit` = NULL) +EXPLAIN SELECT * FROM t1 WHERE c_bit IN (NULL, NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_bit` in (NULL,NULL)) +EXPLAIN SELECT * FROM t1 WHERE c_date +IN ('2009-09-01', '2009-09-02', '2009-09-03'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range c_date c_date 3 NULL 3 100.00 Using index condition; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_date` in ('2009-09-01','2009-09-02','2009-09-03')) +EXPLAIN SELECT * FROM t1 WHERE c_date +IN (NULL, '2009-09-01', '2009-09-02', '2009-09-03'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range c_date c_date 3 NULL 3 100.00 Using index condition; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_date` in (NULL,'2009-09-01','2009-09-02','2009-09-03')) +EXPLAIN SELECT * FROM t1 WHERE c_date IN (NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where multiple equal(NULL, `test`.`t1`.`c_date`) +EXPLAIN SELECT * FROM t1 WHERE c_date IN (NULL, NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_date` in (NULL,NULL)) +EXPLAIN SELECT * FROM t1 WHERE c_datetime +IN ('2009-09-01 00:00:01', '2009-09-02 00:00:01', '2009-09-03 00:00:01'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range c_datetime c_datetime 5 NULL 3 100.00 Using index condition; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_datetime` in ('2009-09-01 00:00:01','2009-09-02 00:00:01','2009-09-03 00:00:01')) +EXPLAIN SELECT * FROM t1 WHERE c_datetime +IN (NULL, '2009-09-01 00:00:01', '2009-09-02 00:00:01', '2009-09-03 00:00:01'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range c_datetime c_datetime 5 NULL 3 100.00 Using index condition; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_datetime` in (NULL,'2009-09-01 00:00:01','2009-09-02 00:00:01','2009-09-03 00:00:01')) +EXPLAIN SELECT * FROM t1 WHERE c_datetime IN (NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where multiple equal(NULL, `test`.`t1`.`c_datetime`) +EXPLAIN SELECT * FROM t1 WHERE c_datetime IN (NULL, NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_datetime` in (NULL,NULL)) +EXPLAIN SELECT * FROM t1 WHERE c_timestamp +IN ('2009-09-01 00:00:01', '2009-09-01 00:00:02', '2009-09-01 00:00:03'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range c_timestamp c_timestamp 4 NULL 3 100.00 Using index condition; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_timestamp` in ('2009-09-01 00:00:01','2009-09-01 00:00:02','2009-09-01 00:00:03')) +EXPLAIN SELECT * FROM t1 WHERE c_timestamp +IN (NULL, '2009-09-01 00:00:01', '2009-09-01 00:00:02', '2009-09-01 00:00:03'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range c_timestamp c_timestamp 4 NULL 3 100.00 Using index condition; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_timestamp` in (NULL,'2009-09-01 00:00:01','2009-09-01 00:00:02','2009-09-01 00:00:03')) +EXPLAIN SELECT * FROM t1 WHERE c_timestamp IN (NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where multiple equal(NULL, `test`.`t1`.`c_timestamp`) +EXPLAIN SELECT * FROM t1 WHERE c_timestamp IN (NULL, NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_timestamp` in (NULL,NULL)) +EXPLAIN SELECT * FROM t1 WHERE c_year IN (1, 2, 3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range c_year c_year 1 NULL 3 100.00 Using index condition; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_year` in (1,2,3)) +EXPLAIN SELECT * FROM t1 WHERE c_year IN (NULL, 1, 2, 3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range c_year c_year 1 NULL 3 100.00 Using index condition; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_year` in (NULL,1,2,3)) +EXPLAIN SELECT * FROM t1 WHERE c_year IN (NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_year` = NULL) +EXPLAIN SELECT * FROM t1 WHERE c_year IN (NULL, NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_year` in (NULL,NULL)) +EXPLAIN SELECT * FROM t1 WHERE c_char IN ('1', '2', '3'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range c_char c_char 40 NULL 3 100.00 Using index condition; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_char` in ('1','2','3')) +EXPLAIN SELECT * FROM t1 WHERE c_char IN (NULL, '1', '2', '3'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range c_char c_char 40 NULL 3 100.00 Using index condition; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_char` in (NULL,'1','2','3')) +EXPLAIN SELECT * FROM t1 WHERE c_char IN (NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where multiple equal(NULL, `test`.`t1`.`c_char`) +EXPLAIN SELECT * FROM t1 WHERE c_char IN (NULL, NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_char` in (NULL,NULL)) +DROP TABLE t1; +# +# Bug#54477: Crash on IN / CASE with NULL arguments +# +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2); +SELECT 1 IN (NULL, a) FROM t1; +1 IN (NULL, a) +1 +NULL +SELECT a IN (a, a) FROM t1 GROUP BY a WITH ROLLUP; +a IN (a, a) +1 +1 +NULL +SELECT CASE a WHEN a THEN a END FROM t1 GROUP BY a WITH ROLLUP; +CASE a WHEN a THEN a END +1 +2 +NULL +DROP TABLE t1; +# +# Bug#58628: Incorrect result for 'WHERE NULL NOT IN () +# +CREATE TABLE t1 (pk INT NOT NULL, i INT); +INSERT INTO t1 VALUES (0,NULL), (1,NULL), (2,NULL), (3,NULL); +CREATE TABLE subq (pk INT NOT NULL, i INT NOT NULL, PRIMARY KEY(i,pk)); +INSERT INTO subq VALUES (0,0), (1,1), (2,2), (3,3); +SELECT * FROM t1 +WHERE t1.i NOT IN +(SELECT i FROM subq WHERE subq.pk = t1.pk); +pk i +SELECT * FROM t1 +WHERE t1.i IN +(SELECT i FROM subq WHERE subq.pk = t1.pk) IS UNKNOWN; +pk i +0 NULL +1 NULL +2 NULL +3 NULL +SELECT * FROM t1 +WHERE NULL NOT IN +(SELECT i FROM subq WHERE subq.pk = t1.pk); +pk i +SELECT * FROM t1 +WHERE NULL IN +(SELECT i FROM subq WHERE subq.pk = t1.pk) IS UNKNOWN; +pk i +0 NULL +1 NULL +2 NULL +3 NULL +SELECT * FROM t1 +WHERE 1+NULL NOT IN +(SELECT i FROM subq WHERE subq.pk = t1.pk); +pk i +DROP TABLE t1,subq; +# +# Bug #11766270 59343: YEAR(4): INCORRECT RESULT AND VALGRIND WARNINGS WITH MIN/MAX, UNION +# +CREATE TABLE t1(f1 YEAR); +INSERT INTO t1 VALUES (0000),(2001); +(SELECT MAX(f1) FROM t1) UNION (SELECT MAX(f1) FROM t1); +Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr +def MAX(f1) MAX(f1) 13 4 4 Y 32864 0 63 +MAX(f1) +2001 +DROP TABLE t1; +# +# Bug #11764651-57510: IN(string,real,string) causes invalid read in sort function +# +SELECT LEFT(ST_GEOMFROMTEXT("POINT(0 0)"),1) IN (@@global.max_allowed_packet,1,""); +LEFT(ST_GEOMFROMTEXT("POINT(0 0)"),1) IN (@@global.max_allowed_packet,1,"") +0 +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: '\x00' +# End of test BUG#11764651-57510 +End of 5.1 tests +set optimizer_switch=default; diff --git a/mysql-test/r/func_in_mrr.result-pq b/mysql-test/r/func_in_mrr.result-pq new file mode 100644 index 000000000000..8d49d3d927a6 --- /dev/null +++ b/mysql-test/r/func_in_mrr.result-pq @@ -0,0 +1,998 @@ +set optimizer_switch='mrr=on,mrr_cost_based=off'; +drop table if exists t1, t2; +select 1 in (1,2,3); +1 in (1,2,3) +1 +select 10 in (1,2,3); +10 in (1,2,3) +0 +select NULL in (1,2,3); +NULL in (1,2,3) +NULL +select 1 in (1,NULL,3); +1 in (1,NULL,3) +1 +select 3 in (1,NULL,3); +3 in (1,NULL,3) +1 +select 10 in (1,NULL,3); +10 in (1,NULL,3) +NULL +select 1.5 in (1.5,2.5,3.5); +1.5 in (1.5,2.5,3.5) +1 +select 10.5 in (1.5,2.5,3.5); +10.5 in (1.5,2.5,3.5) +0 +select NULL in (1.5,2.5,3.5); +NULL in (1.5,2.5,3.5) +NULL +select 1.5 in (1.5,NULL,3.5); +1.5 in (1.5,NULL,3.5) +1 +select 3.5 in (1.5,NULL,3.5); +3.5 in (1.5,NULL,3.5) +1 +select 10.5 in (1.5,NULL,3.5); +10.5 in (1.5,NULL,3.5) +NULL +CREATE TABLE t1 (a int, b int, c int); +insert into t1 values (1,2,3), (1,NULL,3); +select 1 in (a,b,c) from t1; +1 in (a,b,c) +1 +1 +select 3 in (a,b,c) from t1; +3 in (a,b,c) +1 +1 +select 10 in (a,b,c) from t1; +10 in (a,b,c) +0 +NULL +select NULL in (a,b,c) from t1; +NULL in (a,b,c) +NULL +NULL +drop table t1; +CREATE TABLE t1 (a float, b float, c float); +insert into t1 values (1.5,2.5,3.5), (1.5,NULL,3.5); +select 1.5 in (a,b,c) from t1; +1.5 in (a,b,c) +1 +1 +select 3.5 in (a,b,c) from t1; +3.5 in (a,b,c) +1 +1 +select 10.5 in (a,b,c) from t1; +10.5 in (a,b,c) +0 +NULL +drop table t1; +CREATE TABLE t1 (a varchar(10), b varchar(10), c varchar(10)); +insert into t1 values ('A','BC','EFD'), ('A',NULL,'EFD'); +select 'A' in (a,b,c) from t1; +'A' in (a,b,c) +1 +1 +select 'EFD' in (a,b,c) from t1; +'EFD' in (a,b,c) +1 +1 +select 'XSFGGHF' in (a,b,c) from t1; +'XSFGGHF' in (a,b,c) +0 +NULL +drop table t1; +CREATE TABLE t1 (field char(1)); +INSERT INTO t1 VALUES ('A'),(NULL); +SELECT * from t1 WHERE field IN (NULL); +field +SELECT * from t1 WHERE field NOT IN (NULL); +field +SELECT * from t1 where field = field; +field +A +SELECT * from t1 where field <=> field; +field +A +NULL +DELETE FROM t1 WHERE field NOT IN (NULL); +SELECT * FROM t1; +field +A +NULL +drop table t1; +create table t1 (id int(10) primary key); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t1 values (1),(2),(3),(4),(5),(6),(7),(8),(9); +select * from t1 where id in (2,5,9); +id +2 +5 +9 +drop table t1; +create table t1 ( +a char(1) character set latin1 collate latin1_general_ci, +b char(1) character set latin1 collate latin1_swedish_ci, +c char(1) character set latin1 collate latin1_danish_ci +); +insert into t1 values ('A','B','C'); +insert into t1 values ('a','c','c'); +select * from t1 where a in (b); +ERROR HY000: Illegal mix of collations (latin1_general_ci,IMPLICIT) and (latin1_swedish_ci,IMPLICIT) for operation '=' +select * from t1 where a in (b,c); +ERROR HY000: Illegal mix of collations (latin1_general_ci,IMPLICIT), (latin1_swedish_ci,IMPLICIT), (latin1_danish_ci,IMPLICIT) for operation ' IN ' +select * from t1 where 'a' in (a,b,c); +ERROR HY000: Illegal mix of collations for operation ' IN ' +select * from t1 where 'a' in (a); +a b c +A B C +a c c +select * from t1 where a in ('a'); +a b c +A B C +a c c +set names latin1; +select * from t1 where 'a' collate latin1_general_ci in (a,b,c); +a b c +A B C +a c c +select * from t1 where 'a' collate latin1_bin in (a,b,c); +a b c +a c c +select * from t1 where 'a' in (a,b,c collate latin1_bin); +a b c +a c c +explain select * from t1 where 'a' in (a,b,c collate latin1_bin); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` where ('a' in (`test`.`t1`.`a`,`test`.`t1`.`b`,(`test`.`t1`.`c` collate latin1_bin))) +drop table t1; +set names utf8mb4; +set names utf8; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +create table t1 (a char(10) character set utf8 not null); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +insert into t1 values ('bbbb'),(_koi8r x'C3C3C3C3'),(_latin1 x'C4C4C4C4'); +select a from t1 where a in ('bbbb',_koi8r x'C3C3C3C3',_latin1 x'C4C4C4C4') order by a; +a +ÄÄÄÄ +bbbb +цццц +drop table t1; +create table t1 (a char(10) character set latin1 not null); +insert into t1 values ('a'),('b'),('c'); +select a from t1 where a IN ('a','b','c') order by a; +a +a +b +c +drop table t1; +set names latin1; +select '1.0' in (1,2); +'1.0' in (1,2) +1 +select 1 in ('1.0',2); +1 in ('1.0',2) +1 +select 1 in (1,'2.0'); +1 in (1,'2.0') +1 +select 1 in ('1.0',2.0); +1 in ('1.0',2.0) +1 +select 1 in (1.0,'2.0'); +1 in (1.0,'2.0') +1 +select 1 in ('1.1',2); +1 in ('1.1',2) +0 +select 1 in ('1.1',2.0); +1 in ('1.1',2.0) +0 +create table t1 (a char(2) character set binary); +insert into t1 values ('aa'), ('bb'); +select * from t1 where a in (NULL, 'aa'); +a +aa +drop table t1; +create table t1 (id int, key(id)); +insert into t1 values (1),(2),(3); +select count(*) from t1 where id not in (1); +count(*) +2 +select count(*) from t1 where id not in (1,2); +count(*) +1 +drop table t1; +DROP TABLE IF EXISTS t1; +CREATE TABLE t1 SELECT 1 IN (2, NULL); +SELECT should return NULL. +SELECT * FROM t1; +1 IN (2, NULL) +NULL +DROP TABLE t1; +End of 4.1 tests +CREATE TABLE t1 (a int PRIMARY KEY); +INSERT INTO t1 VALUES (44), (45), (46); +SELECT * FROM t1 WHERE a IN (45); +a +45 +SELECT * FROM t1 WHERE a NOT IN (0, 45); +a +44 +46 +SELECT * FROM t1 WHERE a NOT IN (45); +a +44 +46 +CREATE VIEW v1 AS SELECT * FROM t1 WHERE a NOT IN (45); +SHOW CREATE VIEW v1; +View Create View character_set_client collation_connection +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`a` AS `a` from `t1` where (`t1`.`a` <> 45) latin1 latin1_swedish_ci +SELECT * FROM v1; +a +44 +46 +DROP VIEW v1; +DROP TABLE t1; +create table t1 (a int); +insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t2 (a int, filler char(200), key(a)); +insert into t2 select C.a*2, 'no' from t1 A, t1 B, t1 C; +insert into t2 select C.a*2+1, 'yes' from t1 C; +explain +select * from t2 where a NOT IN (0, 2,4,6,8,10,12,14,16,18); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 100.00 Parallel execute (4 workers) +2 SIMPLE t2 NULL range a a 5 NULL 11 100.00 Using where; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`filler` AS `filler` from `test`.`t2` where (`test`.`t2`.`a` not in (0,2,4,6,8,10,12,14,16,18)) +select * from t2 where a NOT IN (0, 2,4,6,8,10,12,14,16,18); +a filler +1 yes +3 yes +5 yes +7 yes +9 yes +11 yes +13 yes +15 yes +17 yes +19 yes +explain select * from t2 force index(a) where a NOT IN (2,2,2,2,2,2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 910 100.00 Parallel execute (3 workers) +2 SIMPLE t2 NULL range a a 5 NULL 910 100.00 Using where; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`filler` AS `filler` from `test`.`t2` FORCE INDEX (`a`) where (`test`.`t2`.`a` not in (2,2,2,2,2,2)) +explain select * from t2 force index(a) where a <> 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 910 100.00 Parallel execute (3 workers) +2 SIMPLE t2 NULL range a a 5 NULL 910 100.00 Using where; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`filler` AS `filler` from `test`.`t2` FORCE INDEX (`a`) where (`test`.`t2`.`a` <> 2) +drop table t2; +create table t2 (a datetime, filler char(200), key(a)); +insert into t2 select '2006-04-25 10:00:00' + interval C.a minute, +'no' from t1 A, t1 B, t1 C where C.a % 2 = 0; +insert into t2 select '2006-04-25 10:00:00' + interval C.a*2+1 minute, +'yes' from t1 C; +explain +select * from t2 where a NOT IN ( +'2006-04-25 10:00:00','2006-04-25 10:02:00','2006-04-25 10:04:00', +'2006-04-25 10:06:00', '2006-04-25 10:08:00'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 100.00 Parallel execute (4 workers) +2 SIMPLE t2 NULL range a a 6 NULL 11 100.00 Using where; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`filler` AS `filler` from `test`.`t2` where (`test`.`t2`.`a` not in ('2006-04-25 10:00:00','2006-04-25 10:02:00','2006-04-25 10:04:00','2006-04-25 10:06:00','2006-04-25 10:08:00')) +select * from t2 where a NOT IN ( +'2006-04-25 10:00:00','2006-04-25 10:02:00','2006-04-25 10:04:00', +'2006-04-25 10:06:00', '2006-04-25 10:08:00'); +a filler +2006-04-25 10:01:00 yes +2006-04-25 10:03:00 yes +2006-04-25 10:05:00 yes +2006-04-25 10:07:00 yes +2006-04-25 10:09:00 yes +2006-04-25 10:11:00 yes +2006-04-25 10:13:00 yes +2006-04-25 10:15:00 yes +2006-04-25 10:17:00 yes +2006-04-25 10:19:00 yes +drop table t2; +create table t2 (a varchar(10), filler char(200), key(a)); +insert into t2 select 'foo', 'no' from t1 A, t1 B; +insert into t2 select 'barbar', 'no' from t1 A, t1 B; +insert into t2 select 'bazbazbaz', 'no' from t1 A, t1 B; +insert into t2 values ('fon', '1'), ('fop','1'), ('barbaq','1'), +('barbas','1'), ('bazbazbay', '1'),('zz','1'); +explain select * from t2 where a not in('foo','barbar', 'bazbazbaz'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL 13 NULL 6 100.00 Parallel execute (4 workers) +2 SIMPLE t2 NULL range a a 13 NULL 6 100.00 Using where; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`filler` AS `filler` from `test`.`t2` where (`test`.`t2`.`a` not in ('foo','barbar','bazbazbaz')) +drop table t2; +create table t2 (a decimal(10,5), filler char(200), key(a)); +insert into t2 select 345.67890, 'no' from t1 A, t1 B; +insert into t2 select 43245.34, 'no' from t1 A, t1 B; +insert into t2 select 64224.56344, 'no' from t1 A, t1 B; +insert into t2 values (0, '1'), (22334.123,'1'), (33333,'1'), +(55555,'1'), (77777, '1'); +explain +select * from t2 where a not in (345.67890, 43245.34, 64224.56344); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (4 workers) +2 SIMPLE t2 NULL range a a 7 NULL 5 100.00 Using where; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`filler` AS `filler` from `test`.`t2` where (`test`.`t2`.`a` not in (345.67890,43245.34,64224.56344)) +select * from t2 where a not in (345.67890, 43245.34, 64224.56344); +a filler +0.00000 1 +22334.12300 1 +33333.00000 1 +55555.00000 1 +77777.00000 1 +drop table t2; +create table t2 (a int, key(a), b int); +insert into t2 values (1,1),(2,2); +set @cnt= 1; +set @str="update t2 set b=1 where a not in ("; +select count(*) from ( +select @str:=concat(@str, @cnt:=@cnt+1, ",") +from t1 A, t1 B, t1 C, t1 D) Z; +count(*) +10000 +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +set @str:=concat(@str, "10000)"); +select substr(@str, 1, 50); +substr(@str, 1, 50) +update t2 set b=1 where a not in (2,3,4,5,6,7,8,9, +prepare s from @str; +execute s; +deallocate prepare s; +set @str=NULL; +drop table t2; +drop table t1; +create table t1 ( +some_id smallint(5) unsigned, +key (some_id) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t1 values (1),(2); +select some_id from t1 where some_id not in(2,-1); +some_id +1 +select some_id from t1 where some_id not in(-4,-1,-4); +some_id +1 +2 +select some_id from t1 where some_id not in(-4,-1,3423534,2342342); +some_id +1 +2 +select some_id from t1 where some_id not in('-1', '0'); +some_id +1 +2 +drop table t1; +# +# BUG#20420: optimizer reports wrong keys on left join with IN +# +CREATE TABLE t1 (a int, b int, PRIMARY KEY (a)); +INSERT INTO t1 VALUES (1,1),(2,1),(3,1),(4,1),(5,1),(6,1); +CREATE TABLE t2 (a int, b int, PRIMARY KEY (a)); +INSERT INTO t2 VALUES (3,2),(4,2),(100,100),(101,201),(102,102); +CREATE TABLE t3 (a int PRIMARY KEY); +INSERT INTO t3 VALUES (1),(2),(3),(4); +CREATE TABLE t4 (a int PRIMARY KEY,b int); +INSERT INTO t4 VALUES (1,1),(2,2),(1000,1000),(1001,1001),(1002,1002), +(1003,1003),(1004,1004); +EXPLAIN SELECT STRAIGHT_JOIN * FROM t3 +JOIN t1 ON t3.a=t1.a +JOIN t2 ON t3.a=t2.a +JOIN t4 WHERE t4.a IN (t1.b, t2.b); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t3 NULL index PRIMARY PRIMARY 4 NULL 4 100.00 Using index +2 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t3.a 1 100.00 NULL +2 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t3.a 1 100.00 NULL +2 SIMPLE t4 NULL ALL PRIMARY NULL NULL NULL 7 28.57 Range checked for each record (index map: 0x1) +Warnings: +Note 1003 /* select#1 */ select straight_join `test`.`t3`.`a` AS `a`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b` from `test`.`t3` join `test`.`t1` join `test`.`t2` join `test`.`t4` where ((`test`.`t1`.`a` = `test`.`t3`.`a`) and (`test`.`t2`.`a` = `test`.`t3`.`a`) and (`test`.`t4`.`a` in (`test`.`t1`.`b`,`test`.`t2`.`b`))) +SELECT STRAIGHT_JOIN * FROM t3 +JOIN t1 ON t3.a=t1.a +JOIN t2 ON t3.a=t2.a +JOIN t4 WHERE t4.a IN (t1.b, t2.b); +a a b a b a b +3 3 1 3 2 1 1 +3 3 1 3 2 2 2 +4 4 1 4 2 1 1 +4 4 1 4 2 2 2 +EXPLAIN SELECT STRAIGHT_JOIN +(SELECT SUM(t4.a) FROM t4 WHERE t4.a IN (t1.b, t2.b)) +FROM t3, t1, t2 +WHERE t3.a=t1.a AND t3.a=t2.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t3 NULL index PRIMARY PRIMARY 4 NULL 4 100.00 Using index +1 PRIMARY t1 NULL eq_ref PRIMARY PRIMARY 4 test.t3.a 1 100.00 NULL +1 PRIMARY t2 NULL eq_ref PRIMARY PRIMARY 4 test.t3.a 1 100.00 NULL +2 DEPENDENT SUBQUERY t4 NULL index NULL PRIMARY 4 NULL 7 28.57 Using where; Using index +Warnings: +Note 1276 Field or reference 'test.t1.b' of SELECT #2 was resolved in SELECT #1 +Note 1276 Field or reference 'test.t2.b' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select straight_join (/* select#2 */ select sum(`test`.`t4`.`a`) from `test`.`t4` where (`test`.`t4`.`a` in (`test`.`t1`.`b`,`test`.`t2`.`b`))) AS `(SELECT SUM(t4.a) FROM t4 WHERE t4.a IN (t1.b, t2.b))` from `test`.`t3` join `test`.`t1` join `test`.`t2` where ((`test`.`t1`.`a` = `test`.`t3`.`a`) and (`test`.`t2`.`a` = `test`.`t3`.`a`)) +SELECT STRAIGHT_JOIN +(SELECT SUM(t4.a) FROM t4 WHERE t4.a IN (t1.b, t2.b)) +FROM t3, t1, t2 +WHERE t3.a=t1.a AND t3.a=t2.a; +(SELECT SUM(t4.a) FROM t4 WHERE t4.a IN (t1.b, t2.b)) +3 +3 +DROP TABLE t1,t2,t3,t4; +CREATE TABLE t1(a BIGINT UNSIGNED); +INSERT INTO t1 VALUES (0xFFFFFFFFFFFFFFFF); +SELECT * FROM t1 WHERE a=-1 OR a=-2 ; +a +SELECT * FROM t1 WHERE a IN (-1, -2); +a +CREATE TABLE t2 (a BIGINT UNSIGNED); +insert into t2 values(13491727406643098568), +(0x7fffffefffffffff), +(0x7ffffffeffffffff), +(0x7fffffffefffffff), +(0x7ffffffffeffffff), +(0x7fffffffffefffff), +(0x7ffffffffffeffff), +(0x7fffffffffffefff), +(0x7ffffffffffffeff), +(0x7fffffffffffffef), +(0x7ffffffffffffffe), +(0x7fffffffffffffff), +(0x8000000000000000), +(0x8000000000000001), +(0x8000000000000002), +(0x8000000000000300), +(0x8000000000000400), +(0x8000000000000401), +(0x8000000000004001), +(0x8000000000040001), +(0x8000000000400001), +(0x8000000004000001), +(0x8000000040000001), +(0x8000000400000001), +(0x8000004000000001), +(0x8000040000000001); +SELECT HEX(a) FROM t2 WHERE a IN +(CAST(0xBB3C3E98175D33C8 AS UNSIGNED), +42); +HEX(a) +BB3C3E98175D33C8 +SELECT HEX(a) FROM t2 WHERE a IN +(CAST(0xBB3C3E98175D33C8 AS UNSIGNED), +CAST(0x7fffffffffffffff AS UNSIGNED), +CAST(0x8000000000000000 AS UNSIGNED), +CAST(0x8000000000000400 AS UNSIGNED), +CAST(0x8000000000000401 AS UNSIGNED), +42); +HEX(a) +BB3C3E98175D33C8 +7FFFFFFFFFFFFFFF +8000000000000000 +8000000000000400 +8000000000000401 +SELECT HEX(a) FROM t2 WHERE a IN +(CAST(0x7fffffffffffffff AS UNSIGNED), +CAST(0x8000000000000001 AS UNSIGNED)); +HEX(a) +7FFFFFFFFFFFFFFF +8000000000000001 +SELECT HEX(a) FROM t2 WHERE a IN +(CAST(0x7ffffffffffffffe AS UNSIGNED), +CAST(0x7fffffffffffffff AS UNSIGNED)); +HEX(a) +7FFFFFFFFFFFFFFE +7FFFFFFFFFFFFFFF +SELECT HEX(a) FROM t2 WHERE a IN +(0x7ffffffffffffffe, +0x7fffffffffffffff, +'abc'); +HEX(a) +7FFFFFFFFFFFFFFE +7FFFFFFFFFFFFFFF +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'abc' +CREATE TABLE t3 (a BIGINT UNSIGNED); +INSERT INTO t3 VALUES (9223372036854775551); +SELECT HEX(a) FROM t3 WHERE a IN (9223372036854775807, 42); +HEX(a) +CREATE TABLE t4 (a DATE); +INSERT INTO t4 VALUES ('1972-02-06'), ('1972-07-29'); +SELECT * FROM t4 WHERE a IN ('1972-02-06','19772-07-29'); +a +1972-02-06 +Warnings: +Warning 1292 Incorrect date value: '19772-07-29' for column 'a' at row 1 +Warning 1292 Incorrect date value: '19772-07-29' for column 'a' at row 1 +Warning 1292 Incorrect date value: '19772-07-29' for column 'a' at row 1 +DROP TABLE t1,t2,t3,t4; +CREATE TABLE t1 (id int not null); +INSERT INTO t1 VALUES (1),(2); +SELECT id FROM t1 WHERE id IN(4564, (SELECT IF(1=0,1,1/0)) ); +id +Warnings: +Warning 1365 Division by 0 +DROP TABLE t1; +End of 5.0 tests +create table t1(f1 char(1)); +insert into t1 values ('a'),('b'),('1'); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +select f1 from t1 where f1 in ('a',1); +f1 +1 +Warning 1292 Truncated incorrect DOUBLE value: 'b' +Warnings: +a +select f1, case f1 when 'a' then '+' when 1 then '-' end from t1; +f1 case f1 when 'a' then '+' when 1 then '-' end +a + +b NULL +1 - +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'b' +create index t1f1_idx on t1(f1); +select f1 from t1 where f1 in ('a',1); +f1 +1 +Warning 1292 Truncated incorrect DOUBLE value: 'b' +Warnings: +a +explain select f1 from t1 where f1 in ('a',1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL 2 NULL 3 50.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index t1f1_idx t1f1_idx 2 NULL 3 50.00 Using where; Using index +Warnings: +Warning 1739 Cannot use range access on index 't1f1_idx' due to type or collation conversion on field 'f1' +Note 1003 /* select#1 */ select `test`.`t1`.`f1` AS `f1` from `test`.`t1` where (`test`.`t1`.`f1` in ('a',1)) +select f1 from t1 where f1 in ('a','b'); +f1 +a +b +explain select f1 from t1 where f1 in ('a','b'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL 2 NULL 2 100.00 Parallel execute (2 workers) +2 SIMPLE t1 NULL range t1f1_idx t1f1_idx 2 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`f1` AS `f1` from `test`.`t1` where (`test`.`t1`.`f1` in ('a','b')) +select f1 from t1 where f1 in (2,1); +f1 +1 +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'a' +Warning 1292 Truncated incorrect DOUBLE value: 'b' +explain select f1 from t1 where f1 in (2,1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL 2 NULL 3 50.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index t1f1_idx t1f1_idx 2 NULL 3 50.00 Using where; Using index +Warnings: +Warning 1739 Cannot use range access on index 't1f1_idx' due to type or collation conversion on field 'f1' +Note 1003 /* select#1 */ select `test`.`t1`.`f1` AS `f1` from `test`.`t1` where (`test`.`t1`.`f1` in (2,1)) +create table t2(f2 int, index t2f2(f2)); +insert into t2 values(0),(1),(2); +select f2 from t2 where f2 in ('a',2); +f2 +0 +2 +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'a' +Warning 1292 Truncated incorrect DOUBLE value: 'a' +explain select f2 from t2 where f2 in ('a',2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (2 workers) +2 SIMPLE t2 NULL range t2f2 t2f2 5 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`f2` AS `f2` from `test`.`t2` where (`test`.`t2`.`f2` in ('a',2)) +select f2 from t2 where f2 in ('a','b'); +f2 +0 +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'a' +Warning 1292 Truncated incorrect DOUBLE value: 'b' +Warning 1292 Truncated incorrect DOUBLE value: 'a' +Warning 1292 Truncated incorrect DOUBLE value: 'b' +Warning 1292 Truncated incorrect DOUBLE value: 'a' +Warning 1292 Truncated incorrect DOUBLE value: 'b' +explain select f2 from t2 where f2 in ('a','b'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL range t2f2 t2f2 5 NULL 1 100.00 Using where; Using index +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'a' +Warning 1292 Truncated incorrect DOUBLE value: 'b' +Note 1003 /* select#1 */ select `test`.`t2`.`f2` AS `f2` from `test`.`t2` where (`test`.`t2`.`f2` in ('a','b')) +select f2 from t2 where f2 in (1,'b'); +f2 +0 +1 +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'b' +explain select f2 from t2 where f2 in (1,'b'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (2 workers) +2 SIMPLE t2 NULL range t2f2 t2f2 5 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`f2` AS `f2` from `test`.`t2` where (`test`.`t2`.`f2` in (1,'b')) +drop table t1, t2; +create table t1 (a time, key(a)); +insert into t1 values (),(),(),(),(),(),(),(),(),(); +select a from t1 where a not in (a,a,a) group by a; +a +drop table t1; +create table t1 (id int); +select * from t1 where NOT id in (select null union all select 1); +id +select * from t1 where NOT id in (null, 1); +id +drop table t1; +CREATE TABLE t1(c0 INTEGER, c1 INTEGER, c2 INTEGER); +INSERT INTO t1 VALUES(1, 1, 1), (1, 1, 1); +SELECT CASE AVG (c0) WHEN c1 * c2 THEN 1 END FROM t1; +CASE AVG (c0) WHEN c1 * c2 THEN 1 END +1 +SELECT CASE c1 * c2 WHEN SUM(c0) THEN 1 WHEN AVG(c0) THEN 2 END FROM t1; +CASE c1 * c2 WHEN SUM(c0) THEN 1 WHEN AVG(c0) THEN 2 END +2 +SELECT CASE c1 WHEN c1 + 1 THEN 1 END, ABS(AVG(c0)) FROM t1; +CASE c1 WHEN c1 + 1 THEN 1 END ABS(AVG(c0)) +NULL 1.0000 +DROP TABLE t1; +CREATE TABLE t1(a TEXT, b INT, c INT UNSIGNED, d DECIMAL(12,2), e REAL); +INSERT INTO t1 VALUES('iynfj', 1, 1, 1, 1); +INSERT INTO t1 VALUES('innfj', 2, 2, 2, 2); +SELECT SUM( DISTINCT a ) FROM t1 GROUP BY a HAVING a IN ( AVG( 1 ), 1 + a); +SUM( DISTINCT a ) +SELECT SUM( DISTINCT b ) FROM t1 GROUP BY b HAVING b IN ( AVG( 1 ), 1 + b); +SUM( DISTINCT b ) +1 +SELECT SUM( DISTINCT c ) FROM t1 GROUP BY c HAVING c IN ( AVG( 1 ), 1 + c); +SUM( DISTINCT c ) +1 +SELECT SUM( DISTINCT d ) FROM t1 GROUP BY d HAVING d IN ( AVG( 1 ), 1 + d); +SUM( DISTINCT d ) +1.00 +SELECT SUM( DISTINCT e ) FROM t1 GROUP BY e HAVING e IN ( AVG( 1 ), 1 + e); +SUM( DISTINCT e ) +1 +SELECT SUM( DISTINCT e ) FROM t1 GROUP BY b,c,d HAVING (b,c,d) IN +((AVG( 1 ), 1 + c, 1 + d), (AVG( 1 ), 2 + c, 2 + d)); +SUM( DISTINCT e ) +DROP TABLE t1; +# +# Bug #44139: Table scan when NULL appears in IN clause +# +CREATE TABLE t1 ( +c_int INT NOT NULL, +c_decimal DECIMAL(5,2) NOT NULL, +c_float FLOAT(5, 2) NOT NULL, +c_bit BIT(10) NOT NULL, +c_date DATE NOT NULL, +c_datetime DATETIME NOT NULL, +c_timestamp TIMESTAMP NOT NULL, +c_time TIME NOT NULL, +c_year YEAR NOT NULL, +c_char CHAR(10) character set utf8mb4 NOT NULL, +INDEX(c_int), INDEX(c_decimal), INDEX(c_float), INDEX(c_bit), INDEX(c_date), +INDEX(c_datetime), INDEX(c_timestamp), INDEX(c_time), INDEX(c_year), +INDEX(c_char)); +INSERT IGNORE INTO t1 (c_int) VALUES (1), (2), (3), (4), (5); +INSERT IGNORE INTO t1 (c_int) SELECT 0 FROM t1; +INSERT IGNORE INTO t1 (c_int) SELECT 0 FROM t1; +EXPLAIN SELECT * FROM t1 WHERE c_int IN (1, 2, 3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (3 workers) +2 SIMPLE t1 NULL range c_int c_int 4 NULL 3 100.00 Using where; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_int` in (1,2,3)) +EXPLAIN SELECT * FROM t1 WHERE c_int IN (NULL, 1, 2, 3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (3 workers) +2 SIMPLE t1 NULL range c_int c_int 4 NULL 3 100.00 Using where; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_int` in (NULL,1,2,3)) +EXPLAIN SELECT * FROM t1 WHERE c_int IN (1, 2, 3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (3 workers) +2 SIMPLE t1 NULL range c_int c_int 4 NULL 3 100.00 Using where; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_int` in (1,2,3)) +EXPLAIN SELECT * FROM t1 WHERE c_int IN (1, NULL, 2, NULL, 3, NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (3 workers) +2 SIMPLE t1 NULL range c_int c_int 4 NULL 3 100.00 Using where; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_int` in (1,NULL,2,NULL,3,NULL)) +EXPLAIN SELECT * FROM t1 WHERE c_int IN (NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_int` = NULL) +EXPLAIN SELECT * FROM t1 WHERE c_int IN (NULL, NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_int` in (NULL,NULL)) +EXPLAIN SELECT * FROM t1 WHERE c_decimal IN (1, 2, 3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range c_decimal c_decimal 3 NULL 3 100.00 Using where; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_decimal` in (1,2,3)) +EXPLAIN SELECT * FROM t1 WHERE c_decimal IN (NULL, 1, 2, 3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range c_decimal c_decimal 3 NULL 3 100.00 Using where; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_decimal` in (NULL,1,2,3)) +EXPLAIN SELECT * FROM t1 WHERE c_decimal IN (NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_decimal` = NULL) +EXPLAIN SELECT * FROM t1 WHERE c_decimal IN (NULL, NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_decimal` in (NULL,NULL)) +EXPLAIN SELECT * FROM t1 WHERE c_float IN (1, 2, 3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range c_float c_float 4 NULL 3 100.00 Using where; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_float` in (1,2,3)) +EXPLAIN SELECT * FROM t1 WHERE c_float IN (NULL, 1, 2, 3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range c_float c_float 4 NULL 3 100.00 Using where; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_float` in (NULL,1,2,3)) +EXPLAIN SELECT * FROM t1 WHERE c_float IN (NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_float` = NULL) +EXPLAIN SELECT * FROM t1 WHERE c_float IN (NULL, NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_float` in (NULL,NULL)) +EXPLAIN SELECT * FROM t1 WHERE c_bit IN (1, 2, 3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range c_bit c_bit 2 NULL 3 100.00 Using where; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_bit` in (1,2,3)) +EXPLAIN SELECT * FROM t1 WHERE c_bit IN (NULL, 1, 2, 3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range c_bit c_bit 2 NULL 3 100.00 Using where; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_bit` in (NULL,1,2,3)) +EXPLAIN SELECT * FROM t1 WHERE c_bit IN (NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_bit` = NULL) +EXPLAIN SELECT * FROM t1 WHERE c_bit IN (NULL, NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_bit` in (NULL,NULL)) +EXPLAIN SELECT * FROM t1 WHERE c_date +IN ('2009-09-01', '2009-09-02', '2009-09-03'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range c_date c_date 3 NULL 3 100.00 Using where; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_date` in ('2009-09-01','2009-09-02','2009-09-03')) +EXPLAIN SELECT * FROM t1 WHERE c_date +IN (NULL, '2009-09-01', '2009-09-02', '2009-09-03'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range c_date c_date 3 NULL 3 100.00 Using where; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_date` in (NULL,'2009-09-01','2009-09-02','2009-09-03')) +EXPLAIN SELECT * FROM t1 WHERE c_date IN (NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where multiple equal(NULL, `test`.`t1`.`c_date`) +EXPLAIN SELECT * FROM t1 WHERE c_date IN (NULL, NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_date` in (NULL,NULL)) +EXPLAIN SELECT * FROM t1 WHERE c_datetime +IN ('2009-09-01 00:00:01', '2009-09-02 00:00:01', '2009-09-03 00:00:01'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range c_datetime c_datetime 5 NULL 3 100.00 Using where; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_datetime` in ('2009-09-01 00:00:01','2009-09-02 00:00:01','2009-09-03 00:00:01')) +EXPLAIN SELECT * FROM t1 WHERE c_datetime +IN (NULL, '2009-09-01 00:00:01', '2009-09-02 00:00:01', '2009-09-03 00:00:01'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range c_datetime c_datetime 5 NULL 3 100.00 Using where; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_datetime` in (NULL,'2009-09-01 00:00:01','2009-09-02 00:00:01','2009-09-03 00:00:01')) +EXPLAIN SELECT * FROM t1 WHERE c_datetime IN (NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where multiple equal(NULL, `test`.`t1`.`c_datetime`) +EXPLAIN SELECT * FROM t1 WHERE c_datetime IN (NULL, NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_datetime` in (NULL,NULL)) +EXPLAIN SELECT * FROM t1 WHERE c_timestamp +IN ('2009-09-01 00:00:01', '2009-09-01 00:00:02', '2009-09-01 00:00:03'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range c_timestamp c_timestamp 4 NULL 3 100.00 Using where; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_timestamp` in ('2009-09-01 00:00:01','2009-09-01 00:00:02','2009-09-01 00:00:03')) +EXPLAIN SELECT * FROM t1 WHERE c_timestamp +IN (NULL, '2009-09-01 00:00:01', '2009-09-01 00:00:02', '2009-09-01 00:00:03'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range c_timestamp c_timestamp 4 NULL 3 100.00 Using where; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_timestamp` in (NULL,'2009-09-01 00:00:01','2009-09-01 00:00:02','2009-09-01 00:00:03')) +EXPLAIN SELECT * FROM t1 WHERE c_timestamp IN (NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where multiple equal(NULL, `test`.`t1`.`c_timestamp`) +EXPLAIN SELECT * FROM t1 WHERE c_timestamp IN (NULL, NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_timestamp` in (NULL,NULL)) +EXPLAIN SELECT * FROM t1 WHERE c_year IN (1, 2, 3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range c_year c_year 1 NULL 3 100.00 Using where; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_year` in (1,2,3)) +EXPLAIN SELECT * FROM t1 WHERE c_year IN (NULL, 1, 2, 3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range c_year c_year 1 NULL 3 100.00 Using where; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_year` in (NULL,1,2,3)) +EXPLAIN SELECT * FROM t1 WHERE c_year IN (NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_year` = NULL) +EXPLAIN SELECT * FROM t1 WHERE c_year IN (NULL, NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_year` in (NULL,NULL)) +EXPLAIN SELECT * FROM t1 WHERE c_char IN ('1', '2', '3'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range c_char c_char 40 NULL 3 100.00 Using where; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_char` in ('1','2','3')) +EXPLAIN SELECT * FROM t1 WHERE c_char IN (NULL, '1', '2', '3'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range c_char c_char 40 NULL 3 100.00 Using where; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_char` in (NULL,'1','2','3')) +EXPLAIN SELECT * FROM t1 WHERE c_char IN (NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where multiple equal(NULL, `test`.`t1`.`c_char`) +EXPLAIN SELECT * FROM t1 WHERE c_char IN (NULL, NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_char` in (NULL,NULL)) +DROP TABLE t1; +# +# Bug#54477: Crash on IN / CASE with NULL arguments +# +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2); +SELECT 1 IN (NULL, a) FROM t1; +1 IN (NULL, a) +1 +NULL +SELECT a IN (a, a) FROM t1 GROUP BY a WITH ROLLUP; +a IN (a, a) +1 +1 +NULL +SELECT CASE a WHEN a THEN a END FROM t1 GROUP BY a WITH ROLLUP; +CASE a WHEN a THEN a END +1 +2 +NULL +DROP TABLE t1; +# +# Bug#58628: Incorrect result for 'WHERE NULL NOT IN () +# +CREATE TABLE t1 (pk INT NOT NULL, i INT); +INSERT INTO t1 VALUES (0,NULL), (1,NULL), (2,NULL), (3,NULL); +CREATE TABLE subq (pk INT NOT NULL, i INT NOT NULL, PRIMARY KEY(i,pk)); +INSERT INTO subq VALUES (0,0), (1,1), (2,2), (3,3); +SELECT * FROM t1 +WHERE t1.i NOT IN +(SELECT i FROM subq WHERE subq.pk = t1.pk); +pk i +SELECT * FROM t1 +WHERE t1.i IN +(SELECT i FROM subq WHERE subq.pk = t1.pk) IS UNKNOWN; +pk i +0 NULL +1 NULL +2 NULL +3 NULL +SELECT * FROM t1 +WHERE NULL NOT IN +(SELECT i FROM subq WHERE subq.pk = t1.pk); +pk i +SELECT * FROM t1 +WHERE NULL IN +(SELECT i FROM subq WHERE subq.pk = t1.pk) IS UNKNOWN; +pk i +0 NULL +1 NULL +2 NULL +3 NULL +SELECT * FROM t1 +WHERE 1+NULL NOT IN +(SELECT i FROM subq WHERE subq.pk = t1.pk); +pk i +DROP TABLE t1,subq; +# +# Bug #11766270 59343: YEAR(4): INCORRECT RESULT AND VALGRIND WARNINGS WITH MIN/MAX, UNION +# +CREATE TABLE t1(f1 YEAR); +INSERT INTO t1 VALUES (0000),(2001); +(SELECT MAX(f1) FROM t1) UNION (SELECT MAX(f1) FROM t1); +Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr +def MAX(f1) MAX(f1) 13 4 4 Y 32864 0 63 +MAX(f1) +2001 +DROP TABLE t1; +# +# Bug #11764651-57510: IN(string,real,string) causes invalid read in sort function +# +SELECT LEFT(ST_GEOMFROMTEXT("POINT(0 0)"),1) IN (@@global.max_allowed_packet,1,""); +LEFT(ST_GEOMFROMTEXT("POINT(0 0)"),1) IN (@@global.max_allowed_packet,1,"") +0 +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: '\x00' +# End of test BUG#11764651-57510 +End of 5.1 tests +set optimizer_switch=default; diff --git a/mysql-test/r/func_in_mrr_cost.result-pq b/mysql-test/r/func_in_mrr_cost.result-pq new file mode 100644 index 000000000000..74227662a57b --- /dev/null +++ b/mysql-test/r/func_in_mrr_cost.result-pq @@ -0,0 +1,998 @@ +set optimizer_switch='mrr=on,mrr_cost_based=on'; +drop table if exists t1, t2; +select 1 in (1,2,3); +1 in (1,2,3) +1 +select 10 in (1,2,3); +10 in (1,2,3) +0 +select NULL in (1,2,3); +NULL in (1,2,3) +NULL +select 1 in (1,NULL,3); +1 in (1,NULL,3) +1 +select 3 in (1,NULL,3); +3 in (1,NULL,3) +1 +select 10 in (1,NULL,3); +10 in (1,NULL,3) +NULL +select 1.5 in (1.5,2.5,3.5); +1.5 in (1.5,2.5,3.5) +1 +select 10.5 in (1.5,2.5,3.5); +10.5 in (1.5,2.5,3.5) +0 +select NULL in (1.5,2.5,3.5); +NULL in (1.5,2.5,3.5) +NULL +select 1.5 in (1.5,NULL,3.5); +1.5 in (1.5,NULL,3.5) +1 +select 3.5 in (1.5,NULL,3.5); +3.5 in (1.5,NULL,3.5) +1 +select 10.5 in (1.5,NULL,3.5); +10.5 in (1.5,NULL,3.5) +NULL +CREATE TABLE t1 (a int, b int, c int); +insert into t1 values (1,2,3), (1,NULL,3); +select 1 in (a,b,c) from t1; +1 in (a,b,c) +1 +1 +select 3 in (a,b,c) from t1; +3 in (a,b,c) +1 +1 +select 10 in (a,b,c) from t1; +10 in (a,b,c) +0 +NULL +select NULL in (a,b,c) from t1; +NULL in (a,b,c) +NULL +NULL +drop table t1; +CREATE TABLE t1 (a float, b float, c float); +insert into t1 values (1.5,2.5,3.5), (1.5,NULL,3.5); +select 1.5 in (a,b,c) from t1; +1.5 in (a,b,c) +1 +1 +select 3.5 in (a,b,c) from t1; +3.5 in (a,b,c) +1 +1 +select 10.5 in (a,b,c) from t1; +10.5 in (a,b,c) +0 +NULL +drop table t1; +CREATE TABLE t1 (a varchar(10), b varchar(10), c varchar(10)); +insert into t1 values ('A','BC','EFD'), ('A',NULL,'EFD'); +select 'A' in (a,b,c) from t1; +'A' in (a,b,c) +1 +1 +select 'EFD' in (a,b,c) from t1; +'EFD' in (a,b,c) +1 +1 +select 'XSFGGHF' in (a,b,c) from t1; +'XSFGGHF' in (a,b,c) +0 +NULL +drop table t1; +CREATE TABLE t1 (field char(1)); +INSERT INTO t1 VALUES ('A'),(NULL); +SELECT * from t1 WHERE field IN (NULL); +field +SELECT * from t1 WHERE field NOT IN (NULL); +field +SELECT * from t1 where field = field; +field +A +SELECT * from t1 where field <=> field; +field +A +NULL +DELETE FROM t1 WHERE field NOT IN (NULL); +SELECT * FROM t1; +field +A +NULL +drop table t1; +create table t1 (id int(10) primary key); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t1 values (1),(2),(3),(4),(5),(6),(7),(8),(9); +select * from t1 where id in (2,5,9); +id +2 +5 +9 +drop table t1; +create table t1 ( +a char(1) character set latin1 collate latin1_general_ci, +b char(1) character set latin1 collate latin1_swedish_ci, +c char(1) character set latin1 collate latin1_danish_ci +); +insert into t1 values ('A','B','C'); +insert into t1 values ('a','c','c'); +select * from t1 where a in (b); +ERROR HY000: Illegal mix of collations (latin1_general_ci,IMPLICIT) and (latin1_swedish_ci,IMPLICIT) for operation '=' +select * from t1 where a in (b,c); +ERROR HY000: Illegal mix of collations (latin1_general_ci,IMPLICIT), (latin1_swedish_ci,IMPLICIT), (latin1_danish_ci,IMPLICIT) for operation ' IN ' +select * from t1 where 'a' in (a,b,c); +ERROR HY000: Illegal mix of collations for operation ' IN ' +select * from t1 where 'a' in (a); +a b c +A B C +a c c +select * from t1 where a in ('a'); +a b c +A B C +a c c +set names latin1; +select * from t1 where 'a' collate latin1_general_ci in (a,b,c); +a b c +A B C +a c c +select * from t1 where 'a' collate latin1_bin in (a,b,c); +a b c +a c c +select * from t1 where 'a' in (a,b,c collate latin1_bin); +a b c +a c c +explain select * from t1 where 'a' in (a,b,c collate latin1_bin); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` where ('a' in (`test`.`t1`.`a`,`test`.`t1`.`b`,(`test`.`t1`.`c` collate latin1_bin))) +drop table t1; +set names utf8mb4; +set names utf8; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +create table t1 (a char(10) character set utf8 not null); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +insert into t1 values ('bbbb'),(_koi8r x'C3C3C3C3'),(_latin1 x'C4C4C4C4'); +select a from t1 where a in ('bbbb',_koi8r x'C3C3C3C3',_latin1 x'C4C4C4C4') order by a; +a +ÄÄÄÄ +bbbb +цццц +drop table t1; +create table t1 (a char(10) character set latin1 not null); +insert into t1 values ('a'),('b'),('c'); +select a from t1 where a IN ('a','b','c') order by a; +a +a +b +c +drop table t1; +set names latin1; +select '1.0' in (1,2); +'1.0' in (1,2) +1 +select 1 in ('1.0',2); +1 in ('1.0',2) +1 +select 1 in (1,'2.0'); +1 in (1,'2.0') +1 +select 1 in ('1.0',2.0); +1 in ('1.0',2.0) +1 +select 1 in (1.0,'2.0'); +1 in (1.0,'2.0') +1 +select 1 in ('1.1',2); +1 in ('1.1',2) +0 +select 1 in ('1.1',2.0); +1 in ('1.1',2.0) +0 +create table t1 (a char(2) character set binary); +insert into t1 values ('aa'), ('bb'); +select * from t1 where a in (NULL, 'aa'); +a +aa +drop table t1; +create table t1 (id int, key(id)); +insert into t1 values (1),(2),(3); +select count(*) from t1 where id not in (1); +count(*) +2 +select count(*) from t1 where id not in (1,2); +count(*) +1 +drop table t1; +DROP TABLE IF EXISTS t1; +CREATE TABLE t1 SELECT 1 IN (2, NULL); +SELECT should return NULL. +SELECT * FROM t1; +1 IN (2, NULL) +NULL +DROP TABLE t1; +End of 4.1 tests +CREATE TABLE t1 (a int PRIMARY KEY); +INSERT INTO t1 VALUES (44), (45), (46); +SELECT * FROM t1 WHERE a IN (45); +a +45 +SELECT * FROM t1 WHERE a NOT IN (0, 45); +a +44 +46 +SELECT * FROM t1 WHERE a NOT IN (45); +a +44 +46 +CREATE VIEW v1 AS SELECT * FROM t1 WHERE a NOT IN (45); +SHOW CREATE VIEW v1; +View Create View character_set_client collation_connection +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`a` AS `a` from `t1` where (`t1`.`a` <> 45) latin1 latin1_swedish_ci +SELECT * FROM v1; +a +44 +46 +DROP VIEW v1; +DROP TABLE t1; +create table t1 (a int); +insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t2 (a int, filler char(200), key(a)); +insert into t2 select C.a*2, 'no' from t1 A, t1 B, t1 C; +insert into t2 select C.a*2+1, 'yes' from t1 C; +explain +select * from t2 where a NOT IN (0, 2,4,6,8,10,12,14,16,18); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 100.00 Parallel execute (4 workers) +2 SIMPLE t2 NULL range a a 5 NULL 11 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`filler` AS `filler` from `test`.`t2` where (`test`.`t2`.`a` not in (0,2,4,6,8,10,12,14,16,18)) +select * from t2 where a NOT IN (0, 2,4,6,8,10,12,14,16,18); +a filler +1 yes +3 yes +5 yes +7 yes +9 yes +11 yes +13 yes +15 yes +17 yes +19 yes +explain select * from t2 force index(a) where a NOT IN (2,2,2,2,2,2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 910 100.00 Parallel execute (3 workers) +2 SIMPLE t2 NULL range a a 5 NULL 910 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`filler` AS `filler` from `test`.`t2` FORCE INDEX (`a`) where (`test`.`t2`.`a` not in (2,2,2,2,2,2)) +explain select * from t2 force index(a) where a <> 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 910 100.00 Parallel execute (3 workers) +2 SIMPLE t2 NULL range a a 5 NULL 910 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`filler` AS `filler` from `test`.`t2` FORCE INDEX (`a`) where (`test`.`t2`.`a` <> 2) +drop table t2; +create table t2 (a datetime, filler char(200), key(a)); +insert into t2 select '2006-04-25 10:00:00' + interval C.a minute, +'no' from t1 A, t1 B, t1 C where C.a % 2 = 0; +insert into t2 select '2006-04-25 10:00:00' + interval C.a*2+1 minute, +'yes' from t1 C; +explain +select * from t2 where a NOT IN ( +'2006-04-25 10:00:00','2006-04-25 10:02:00','2006-04-25 10:04:00', +'2006-04-25 10:06:00', '2006-04-25 10:08:00'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 100.00 Parallel execute (4 workers) +2 SIMPLE t2 NULL range a a 6 NULL 11 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`filler` AS `filler` from `test`.`t2` where (`test`.`t2`.`a` not in ('2006-04-25 10:00:00','2006-04-25 10:02:00','2006-04-25 10:04:00','2006-04-25 10:06:00','2006-04-25 10:08:00')) +select * from t2 where a NOT IN ( +'2006-04-25 10:00:00','2006-04-25 10:02:00','2006-04-25 10:04:00', +'2006-04-25 10:06:00', '2006-04-25 10:08:00'); +a filler +2006-04-25 10:01:00 yes +2006-04-25 10:03:00 yes +2006-04-25 10:05:00 yes +2006-04-25 10:07:00 yes +2006-04-25 10:09:00 yes +2006-04-25 10:11:00 yes +2006-04-25 10:13:00 yes +2006-04-25 10:15:00 yes +2006-04-25 10:17:00 yes +2006-04-25 10:19:00 yes +drop table t2; +create table t2 (a varchar(10), filler char(200), key(a)); +insert into t2 select 'foo', 'no' from t1 A, t1 B; +insert into t2 select 'barbar', 'no' from t1 A, t1 B; +insert into t2 select 'bazbazbaz', 'no' from t1 A, t1 B; +insert into t2 values ('fon', '1'), ('fop','1'), ('barbaq','1'), +('barbas','1'), ('bazbazbay', '1'),('zz','1'); +explain select * from t2 where a not in('foo','barbar', 'bazbazbaz'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL 13 NULL 6 100.00 Parallel execute (4 workers) +2 SIMPLE t2 NULL range a a 13 NULL 6 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`filler` AS `filler` from `test`.`t2` where (`test`.`t2`.`a` not in ('foo','barbar','bazbazbaz')) +drop table t2; +create table t2 (a decimal(10,5), filler char(200), key(a)); +insert into t2 select 345.67890, 'no' from t1 A, t1 B; +insert into t2 select 43245.34, 'no' from t1 A, t1 B; +insert into t2 select 64224.56344, 'no' from t1 A, t1 B; +insert into t2 values (0, '1'), (22334.123,'1'), (33333,'1'), +(55555,'1'), (77777, '1'); +explain +select * from t2 where a not in (345.67890, 43245.34, 64224.56344); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (4 workers) +2 SIMPLE t2 NULL range a a 7 NULL 5 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`filler` AS `filler` from `test`.`t2` where (`test`.`t2`.`a` not in (345.67890,43245.34,64224.56344)) +select * from t2 where a not in (345.67890, 43245.34, 64224.56344); +a filler +0.00000 1 +22334.12300 1 +33333.00000 1 +55555.00000 1 +77777.00000 1 +drop table t2; +create table t2 (a int, key(a), b int); +insert into t2 values (1,1),(2,2); +set @cnt= 1; +set @str="update t2 set b=1 where a not in ("; +select count(*) from ( +select @str:=concat(@str, @cnt:=@cnt+1, ",") +from t1 A, t1 B, t1 C, t1 D) Z; +count(*) +10000 +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +set @str:=concat(@str, "10000)"); +select substr(@str, 1, 50); +substr(@str, 1, 50) +update t2 set b=1 where a not in (2,3,4,5,6,7,8,9, +prepare s from @str; +execute s; +deallocate prepare s; +set @str=NULL; +drop table t2; +drop table t1; +create table t1 ( +some_id smallint(5) unsigned, +key (some_id) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t1 values (1),(2); +select some_id from t1 where some_id not in(2,-1); +some_id +1 +select some_id from t1 where some_id not in(-4,-1,-4); +some_id +1 +2 +select some_id from t1 where some_id not in(-4,-1,3423534,2342342); +some_id +1 +2 +select some_id from t1 where some_id not in('-1', '0'); +some_id +1 +2 +drop table t1; +# +# BUG#20420: optimizer reports wrong keys on left join with IN +# +CREATE TABLE t1 (a int, b int, PRIMARY KEY (a)); +INSERT INTO t1 VALUES (1,1),(2,1),(3,1),(4,1),(5,1),(6,1); +CREATE TABLE t2 (a int, b int, PRIMARY KEY (a)); +INSERT INTO t2 VALUES (3,2),(4,2),(100,100),(101,201),(102,102); +CREATE TABLE t3 (a int PRIMARY KEY); +INSERT INTO t3 VALUES (1),(2),(3),(4); +CREATE TABLE t4 (a int PRIMARY KEY,b int); +INSERT INTO t4 VALUES (1,1),(2,2),(1000,1000),(1001,1001),(1002,1002), +(1003,1003),(1004,1004); +EXPLAIN SELECT STRAIGHT_JOIN * FROM t3 +JOIN t1 ON t3.a=t1.a +JOIN t2 ON t3.a=t2.a +JOIN t4 WHERE t4.a IN (t1.b, t2.b); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t3 NULL index PRIMARY PRIMARY 4 NULL 4 100.00 Using index +2 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t3.a 1 100.00 NULL +2 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t3.a 1 100.00 NULL +2 SIMPLE t4 NULL ALL PRIMARY NULL NULL NULL 7 28.57 Range checked for each record (index map: 0x1) +Warnings: +Note 1003 /* select#1 */ select straight_join `test`.`t3`.`a` AS `a`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b` from `test`.`t3` join `test`.`t1` join `test`.`t2` join `test`.`t4` where ((`test`.`t1`.`a` = `test`.`t3`.`a`) and (`test`.`t2`.`a` = `test`.`t3`.`a`) and (`test`.`t4`.`a` in (`test`.`t1`.`b`,`test`.`t2`.`b`))) +SELECT STRAIGHT_JOIN * FROM t3 +JOIN t1 ON t3.a=t1.a +JOIN t2 ON t3.a=t2.a +JOIN t4 WHERE t4.a IN (t1.b, t2.b); +a a b a b a b +3 3 1 3 2 1 1 +3 3 1 3 2 2 2 +4 4 1 4 2 1 1 +4 4 1 4 2 2 2 +EXPLAIN SELECT STRAIGHT_JOIN +(SELECT SUM(t4.a) FROM t4 WHERE t4.a IN (t1.b, t2.b)) +FROM t3, t1, t2 +WHERE t3.a=t1.a AND t3.a=t2.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t3 NULL index PRIMARY PRIMARY 4 NULL 4 100.00 Using index +1 PRIMARY t1 NULL eq_ref PRIMARY PRIMARY 4 test.t3.a 1 100.00 NULL +1 PRIMARY t2 NULL eq_ref PRIMARY PRIMARY 4 test.t3.a 1 100.00 NULL +2 DEPENDENT SUBQUERY t4 NULL index NULL PRIMARY 4 NULL 7 28.57 Using where; Using index +Warnings: +Note 1276 Field or reference 'test.t1.b' of SELECT #2 was resolved in SELECT #1 +Note 1276 Field or reference 'test.t2.b' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select straight_join (/* select#2 */ select sum(`test`.`t4`.`a`) from `test`.`t4` where (`test`.`t4`.`a` in (`test`.`t1`.`b`,`test`.`t2`.`b`))) AS `(SELECT SUM(t4.a) FROM t4 WHERE t4.a IN (t1.b, t2.b))` from `test`.`t3` join `test`.`t1` join `test`.`t2` where ((`test`.`t1`.`a` = `test`.`t3`.`a`) and (`test`.`t2`.`a` = `test`.`t3`.`a`)) +SELECT STRAIGHT_JOIN +(SELECT SUM(t4.a) FROM t4 WHERE t4.a IN (t1.b, t2.b)) +FROM t3, t1, t2 +WHERE t3.a=t1.a AND t3.a=t2.a; +(SELECT SUM(t4.a) FROM t4 WHERE t4.a IN (t1.b, t2.b)) +3 +3 +DROP TABLE t1,t2,t3,t4; +CREATE TABLE t1(a BIGINT UNSIGNED); +INSERT INTO t1 VALUES (0xFFFFFFFFFFFFFFFF); +SELECT * FROM t1 WHERE a=-1 OR a=-2 ; +a +SELECT * FROM t1 WHERE a IN (-1, -2); +a +CREATE TABLE t2 (a BIGINT UNSIGNED); +insert into t2 values(13491727406643098568), +(0x7fffffefffffffff), +(0x7ffffffeffffffff), +(0x7fffffffefffffff), +(0x7ffffffffeffffff), +(0x7fffffffffefffff), +(0x7ffffffffffeffff), +(0x7fffffffffffefff), +(0x7ffffffffffffeff), +(0x7fffffffffffffef), +(0x7ffffffffffffffe), +(0x7fffffffffffffff), +(0x8000000000000000), +(0x8000000000000001), +(0x8000000000000002), +(0x8000000000000300), +(0x8000000000000400), +(0x8000000000000401), +(0x8000000000004001), +(0x8000000000040001), +(0x8000000000400001), +(0x8000000004000001), +(0x8000000040000001), +(0x8000000400000001), +(0x8000004000000001), +(0x8000040000000001); +SELECT HEX(a) FROM t2 WHERE a IN +(CAST(0xBB3C3E98175D33C8 AS UNSIGNED), +42); +HEX(a) +BB3C3E98175D33C8 +SELECT HEX(a) FROM t2 WHERE a IN +(CAST(0xBB3C3E98175D33C8 AS UNSIGNED), +CAST(0x7fffffffffffffff AS UNSIGNED), +CAST(0x8000000000000000 AS UNSIGNED), +CAST(0x8000000000000400 AS UNSIGNED), +CAST(0x8000000000000401 AS UNSIGNED), +42); +HEX(a) +BB3C3E98175D33C8 +7FFFFFFFFFFFFFFF +8000000000000000 +8000000000000400 +8000000000000401 +SELECT HEX(a) FROM t2 WHERE a IN +(CAST(0x7fffffffffffffff AS UNSIGNED), +CAST(0x8000000000000001 AS UNSIGNED)); +HEX(a) +7FFFFFFFFFFFFFFF +8000000000000001 +SELECT HEX(a) FROM t2 WHERE a IN +(CAST(0x7ffffffffffffffe AS UNSIGNED), +CAST(0x7fffffffffffffff AS UNSIGNED)); +HEX(a) +7FFFFFFFFFFFFFFE +7FFFFFFFFFFFFFFF +SELECT HEX(a) FROM t2 WHERE a IN +(0x7ffffffffffffffe, +0x7fffffffffffffff, +'abc'); +HEX(a) +7FFFFFFFFFFFFFFE +7FFFFFFFFFFFFFFF +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'abc' +CREATE TABLE t3 (a BIGINT UNSIGNED); +INSERT INTO t3 VALUES (9223372036854775551); +SELECT HEX(a) FROM t3 WHERE a IN (9223372036854775807, 42); +HEX(a) +CREATE TABLE t4 (a DATE); +INSERT INTO t4 VALUES ('1972-02-06'), ('1972-07-29'); +SELECT * FROM t4 WHERE a IN ('1972-02-06','19772-07-29'); +a +1972-02-06 +Warnings: +Warning 1292 Incorrect date value: '19772-07-29' for column 'a' at row 1 +Warning 1292 Incorrect date value: '19772-07-29' for column 'a' at row 1 +Warning 1292 Incorrect date value: '19772-07-29' for column 'a' at row 1 +DROP TABLE t1,t2,t3,t4; +CREATE TABLE t1 (id int not null); +INSERT INTO t1 VALUES (1),(2); +SELECT id FROM t1 WHERE id IN(4564, (SELECT IF(1=0,1,1/0)) ); +id +Warnings: +Warning 1365 Division by 0 +DROP TABLE t1; +End of 5.0 tests +create table t1(f1 char(1)); +insert into t1 values ('a'),('b'),('1'); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +select f1 from t1 where f1 in ('a',1); +f1 +1 +Warning 1292 Truncated incorrect DOUBLE value: 'b' +Warnings: +a +select f1, case f1 when 'a' then '+' when 1 then '-' end from t1; +f1 case f1 when 'a' then '+' when 1 then '-' end +a + +b NULL +1 - +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'b' +create index t1f1_idx on t1(f1); +select f1 from t1 where f1 in ('a',1); +f1 +1 +Warning 1292 Truncated incorrect DOUBLE value: 'b' +Warnings: +a +explain select f1 from t1 where f1 in ('a',1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL 2 NULL 3 50.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index t1f1_idx t1f1_idx 2 NULL 3 50.00 Using where; Using index +Warnings: +Warning 1739 Cannot use range access on index 't1f1_idx' due to type or collation conversion on field 'f1' +Note 1003 /* select#1 */ select `test`.`t1`.`f1` AS `f1` from `test`.`t1` where (`test`.`t1`.`f1` in ('a',1)) +select f1 from t1 where f1 in ('a','b'); +f1 +a +b +explain select f1 from t1 where f1 in ('a','b'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL 2 NULL 2 100.00 Parallel execute (2 workers) +2 SIMPLE t1 NULL range t1f1_idx t1f1_idx 2 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`f1` AS `f1` from `test`.`t1` where (`test`.`t1`.`f1` in ('a','b')) +select f1 from t1 where f1 in (2,1); +f1 +1 +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'a' +Warning 1292 Truncated incorrect DOUBLE value: 'b' +explain select f1 from t1 where f1 in (2,1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL 2 NULL 3 50.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index t1f1_idx t1f1_idx 2 NULL 3 50.00 Using where; Using index +Warnings: +Warning 1739 Cannot use range access on index 't1f1_idx' due to type or collation conversion on field 'f1' +Note 1003 /* select#1 */ select `test`.`t1`.`f1` AS `f1` from `test`.`t1` where (`test`.`t1`.`f1` in (2,1)) +create table t2(f2 int, index t2f2(f2)); +insert into t2 values(0),(1),(2); +select f2 from t2 where f2 in ('a',2); +f2 +0 +2 +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'a' +Warning 1292 Truncated incorrect DOUBLE value: 'a' +explain select f2 from t2 where f2 in ('a',2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (2 workers) +2 SIMPLE t2 NULL range t2f2 t2f2 5 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`f2` AS `f2` from `test`.`t2` where (`test`.`t2`.`f2` in ('a',2)) +select f2 from t2 where f2 in ('a','b'); +f2 +0 +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'a' +Warning 1292 Truncated incorrect DOUBLE value: 'b' +Warning 1292 Truncated incorrect DOUBLE value: 'a' +Warning 1292 Truncated incorrect DOUBLE value: 'b' +Warning 1292 Truncated incorrect DOUBLE value: 'a' +Warning 1292 Truncated incorrect DOUBLE value: 'b' +explain select f2 from t2 where f2 in ('a','b'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL range t2f2 t2f2 5 NULL 1 100.00 Using where; Using index +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'a' +Warning 1292 Truncated incorrect DOUBLE value: 'b' +Note 1003 /* select#1 */ select `test`.`t2`.`f2` AS `f2` from `test`.`t2` where (`test`.`t2`.`f2` in ('a','b')) +select f2 from t2 where f2 in (1,'b'); +f2 +0 +1 +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'b' +explain select f2 from t2 where f2 in (1,'b'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (2 workers) +2 SIMPLE t2 NULL range t2f2 t2f2 5 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`f2` AS `f2` from `test`.`t2` where (`test`.`t2`.`f2` in (1,'b')) +drop table t1, t2; +create table t1 (a time, key(a)); +insert into t1 values (),(),(),(),(),(),(),(),(),(); +select a from t1 where a not in (a,a,a) group by a; +a +drop table t1; +create table t1 (id int); +select * from t1 where NOT id in (select null union all select 1); +id +select * from t1 where NOT id in (null, 1); +id +drop table t1; +CREATE TABLE t1(c0 INTEGER, c1 INTEGER, c2 INTEGER); +INSERT INTO t1 VALUES(1, 1, 1), (1, 1, 1); +SELECT CASE AVG (c0) WHEN c1 * c2 THEN 1 END FROM t1; +CASE AVG (c0) WHEN c1 * c2 THEN 1 END +1 +SELECT CASE c1 * c2 WHEN SUM(c0) THEN 1 WHEN AVG(c0) THEN 2 END FROM t1; +CASE c1 * c2 WHEN SUM(c0) THEN 1 WHEN AVG(c0) THEN 2 END +2 +SELECT CASE c1 WHEN c1 + 1 THEN 1 END, ABS(AVG(c0)) FROM t1; +CASE c1 WHEN c1 + 1 THEN 1 END ABS(AVG(c0)) +NULL 1.0000 +DROP TABLE t1; +CREATE TABLE t1(a TEXT, b INT, c INT UNSIGNED, d DECIMAL(12,2), e REAL); +INSERT INTO t1 VALUES('iynfj', 1, 1, 1, 1); +INSERT INTO t1 VALUES('innfj', 2, 2, 2, 2); +SELECT SUM( DISTINCT a ) FROM t1 GROUP BY a HAVING a IN ( AVG( 1 ), 1 + a); +SUM( DISTINCT a ) +SELECT SUM( DISTINCT b ) FROM t1 GROUP BY b HAVING b IN ( AVG( 1 ), 1 + b); +SUM( DISTINCT b ) +1 +SELECT SUM( DISTINCT c ) FROM t1 GROUP BY c HAVING c IN ( AVG( 1 ), 1 + c); +SUM( DISTINCT c ) +1 +SELECT SUM( DISTINCT d ) FROM t1 GROUP BY d HAVING d IN ( AVG( 1 ), 1 + d); +SUM( DISTINCT d ) +1.00 +SELECT SUM( DISTINCT e ) FROM t1 GROUP BY e HAVING e IN ( AVG( 1 ), 1 + e); +SUM( DISTINCT e ) +1 +SELECT SUM( DISTINCT e ) FROM t1 GROUP BY b,c,d HAVING (b,c,d) IN +((AVG( 1 ), 1 + c, 1 + d), (AVG( 1 ), 2 + c, 2 + d)); +SUM( DISTINCT e ) +DROP TABLE t1; +# +# Bug #44139: Table scan when NULL appears in IN clause +# +CREATE TABLE t1 ( +c_int INT NOT NULL, +c_decimal DECIMAL(5,2) NOT NULL, +c_float FLOAT(5, 2) NOT NULL, +c_bit BIT(10) NOT NULL, +c_date DATE NOT NULL, +c_datetime DATETIME NOT NULL, +c_timestamp TIMESTAMP NOT NULL, +c_time TIME NOT NULL, +c_year YEAR NOT NULL, +c_char CHAR(10) character set utf8mb4 NOT NULL, +INDEX(c_int), INDEX(c_decimal), INDEX(c_float), INDEX(c_bit), INDEX(c_date), +INDEX(c_datetime), INDEX(c_timestamp), INDEX(c_time), INDEX(c_year), +INDEX(c_char)); +INSERT IGNORE INTO t1 (c_int) VALUES (1), (2), (3), (4), (5); +INSERT IGNORE INTO t1 (c_int) SELECT 0 FROM t1; +INSERT IGNORE INTO t1 (c_int) SELECT 0 FROM t1; +EXPLAIN SELECT * FROM t1 WHERE c_int IN (1, 2, 3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (3 workers) +2 SIMPLE t1 NULL range c_int c_int 4 NULL 3 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_int` in (1,2,3)) +EXPLAIN SELECT * FROM t1 WHERE c_int IN (NULL, 1, 2, 3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (3 workers) +2 SIMPLE t1 NULL range c_int c_int 4 NULL 3 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_int` in (NULL,1,2,3)) +EXPLAIN SELECT * FROM t1 WHERE c_int IN (1, 2, 3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (3 workers) +2 SIMPLE t1 NULL range c_int c_int 4 NULL 3 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_int` in (1,2,3)) +EXPLAIN SELECT * FROM t1 WHERE c_int IN (1, NULL, 2, NULL, 3, NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (3 workers) +2 SIMPLE t1 NULL range c_int c_int 4 NULL 3 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_int` in (1,NULL,2,NULL,3,NULL)) +EXPLAIN SELECT * FROM t1 WHERE c_int IN (NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_int` = NULL) +EXPLAIN SELECT * FROM t1 WHERE c_int IN (NULL, NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_int` in (NULL,NULL)) +EXPLAIN SELECT * FROM t1 WHERE c_decimal IN (1, 2, 3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range c_decimal c_decimal 3 NULL 3 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_decimal` in (1,2,3)) +EXPLAIN SELECT * FROM t1 WHERE c_decimal IN (NULL, 1, 2, 3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range c_decimal c_decimal 3 NULL 3 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_decimal` in (NULL,1,2,3)) +EXPLAIN SELECT * FROM t1 WHERE c_decimal IN (NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_decimal` = NULL) +EXPLAIN SELECT * FROM t1 WHERE c_decimal IN (NULL, NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_decimal` in (NULL,NULL)) +EXPLAIN SELECT * FROM t1 WHERE c_float IN (1, 2, 3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range c_float c_float 4 NULL 3 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_float` in (1,2,3)) +EXPLAIN SELECT * FROM t1 WHERE c_float IN (NULL, 1, 2, 3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range c_float c_float 4 NULL 3 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_float` in (NULL,1,2,3)) +EXPLAIN SELECT * FROM t1 WHERE c_float IN (NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_float` = NULL) +EXPLAIN SELECT * FROM t1 WHERE c_float IN (NULL, NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_float` in (NULL,NULL)) +EXPLAIN SELECT * FROM t1 WHERE c_bit IN (1, 2, 3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range c_bit c_bit 2 NULL 3 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_bit` in (1,2,3)) +EXPLAIN SELECT * FROM t1 WHERE c_bit IN (NULL, 1, 2, 3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range c_bit c_bit 2 NULL 3 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_bit` in (NULL,1,2,3)) +EXPLAIN SELECT * FROM t1 WHERE c_bit IN (NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_bit` = NULL) +EXPLAIN SELECT * FROM t1 WHERE c_bit IN (NULL, NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_bit` in (NULL,NULL)) +EXPLAIN SELECT * FROM t1 WHERE c_date +IN ('2009-09-01', '2009-09-02', '2009-09-03'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range c_date c_date 3 NULL 3 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_date` in ('2009-09-01','2009-09-02','2009-09-03')) +EXPLAIN SELECT * FROM t1 WHERE c_date +IN (NULL, '2009-09-01', '2009-09-02', '2009-09-03'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range c_date c_date 3 NULL 3 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_date` in (NULL,'2009-09-01','2009-09-02','2009-09-03')) +EXPLAIN SELECT * FROM t1 WHERE c_date IN (NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where multiple equal(NULL, `test`.`t1`.`c_date`) +EXPLAIN SELECT * FROM t1 WHERE c_date IN (NULL, NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_date` in (NULL,NULL)) +EXPLAIN SELECT * FROM t1 WHERE c_datetime +IN ('2009-09-01 00:00:01', '2009-09-02 00:00:01', '2009-09-03 00:00:01'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range c_datetime c_datetime 5 NULL 3 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_datetime` in ('2009-09-01 00:00:01','2009-09-02 00:00:01','2009-09-03 00:00:01')) +EXPLAIN SELECT * FROM t1 WHERE c_datetime +IN (NULL, '2009-09-01 00:00:01', '2009-09-02 00:00:01', '2009-09-03 00:00:01'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range c_datetime c_datetime 5 NULL 3 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_datetime` in (NULL,'2009-09-01 00:00:01','2009-09-02 00:00:01','2009-09-03 00:00:01')) +EXPLAIN SELECT * FROM t1 WHERE c_datetime IN (NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where multiple equal(NULL, `test`.`t1`.`c_datetime`) +EXPLAIN SELECT * FROM t1 WHERE c_datetime IN (NULL, NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_datetime` in (NULL,NULL)) +EXPLAIN SELECT * FROM t1 WHERE c_timestamp +IN ('2009-09-01 00:00:01', '2009-09-01 00:00:02', '2009-09-01 00:00:03'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range c_timestamp c_timestamp 4 NULL 3 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_timestamp` in ('2009-09-01 00:00:01','2009-09-01 00:00:02','2009-09-01 00:00:03')) +EXPLAIN SELECT * FROM t1 WHERE c_timestamp +IN (NULL, '2009-09-01 00:00:01', '2009-09-01 00:00:02', '2009-09-01 00:00:03'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range c_timestamp c_timestamp 4 NULL 3 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_timestamp` in (NULL,'2009-09-01 00:00:01','2009-09-01 00:00:02','2009-09-01 00:00:03')) +EXPLAIN SELECT * FROM t1 WHERE c_timestamp IN (NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where multiple equal(NULL, `test`.`t1`.`c_timestamp`) +EXPLAIN SELECT * FROM t1 WHERE c_timestamp IN (NULL, NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_timestamp` in (NULL,NULL)) +EXPLAIN SELECT * FROM t1 WHERE c_year IN (1, 2, 3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range c_year c_year 1 NULL 3 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_year` in (1,2,3)) +EXPLAIN SELECT * FROM t1 WHERE c_year IN (NULL, 1, 2, 3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range c_year c_year 1 NULL 3 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_year` in (NULL,1,2,3)) +EXPLAIN SELECT * FROM t1 WHERE c_year IN (NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_year` = NULL) +EXPLAIN SELECT * FROM t1 WHERE c_year IN (NULL, NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_year` in (NULL,NULL)) +EXPLAIN SELECT * FROM t1 WHERE c_char IN ('1', '2', '3'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range c_char c_char 40 NULL 3 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_char` in ('1','2','3')) +EXPLAIN SELECT * FROM t1 WHERE c_char IN (NULL, '1', '2', '3'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range c_char c_char 40 NULL 3 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_char` in (NULL,'1','2','3')) +EXPLAIN SELECT * FROM t1 WHERE c_char IN (NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where multiple equal(NULL, `test`.`t1`.`c_char`) +EXPLAIN SELECT * FROM t1 WHERE c_char IN (NULL, NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_char` in (NULL,NULL)) +DROP TABLE t1; +# +# Bug#54477: Crash on IN / CASE with NULL arguments +# +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2); +SELECT 1 IN (NULL, a) FROM t1; +1 IN (NULL, a) +1 +NULL +SELECT a IN (a, a) FROM t1 GROUP BY a WITH ROLLUP; +a IN (a, a) +1 +1 +NULL +SELECT CASE a WHEN a THEN a END FROM t1 GROUP BY a WITH ROLLUP; +CASE a WHEN a THEN a END +1 +2 +NULL +DROP TABLE t1; +# +# Bug#58628: Incorrect result for 'WHERE NULL NOT IN () +# +CREATE TABLE t1 (pk INT NOT NULL, i INT); +INSERT INTO t1 VALUES (0,NULL), (1,NULL), (2,NULL), (3,NULL); +CREATE TABLE subq (pk INT NOT NULL, i INT NOT NULL, PRIMARY KEY(i,pk)); +INSERT INTO subq VALUES (0,0), (1,1), (2,2), (3,3); +SELECT * FROM t1 +WHERE t1.i NOT IN +(SELECT i FROM subq WHERE subq.pk = t1.pk); +pk i +SELECT * FROM t1 +WHERE t1.i IN +(SELECT i FROM subq WHERE subq.pk = t1.pk) IS UNKNOWN; +pk i +0 NULL +1 NULL +2 NULL +3 NULL +SELECT * FROM t1 +WHERE NULL NOT IN +(SELECT i FROM subq WHERE subq.pk = t1.pk); +pk i +SELECT * FROM t1 +WHERE NULL IN +(SELECT i FROM subq WHERE subq.pk = t1.pk) IS UNKNOWN; +pk i +0 NULL +1 NULL +2 NULL +3 NULL +SELECT * FROM t1 +WHERE 1+NULL NOT IN +(SELECT i FROM subq WHERE subq.pk = t1.pk); +pk i +DROP TABLE t1,subq; +# +# Bug #11766270 59343: YEAR(4): INCORRECT RESULT AND VALGRIND WARNINGS WITH MIN/MAX, UNION +# +CREATE TABLE t1(f1 YEAR); +INSERT INTO t1 VALUES (0000),(2001); +(SELECT MAX(f1) FROM t1) UNION (SELECT MAX(f1) FROM t1); +Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr +def MAX(f1) MAX(f1) 13 4 4 Y 32864 0 63 +MAX(f1) +2001 +DROP TABLE t1; +# +# Bug #11764651-57510: IN(string,real,string) causes invalid read in sort function +# +SELECT LEFT(ST_GEOMFROMTEXT("POINT(0 0)"),1) IN (@@global.max_allowed_packet,1,""); +LEFT(ST_GEOMFROMTEXT("POINT(0 0)"),1) IN (@@global.max_allowed_packet,1,"") +0 +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: '\x00' +# End of test BUG#11764651-57510 +End of 5.1 tests +set optimizer_switch=default; diff --git a/mysql-test/r/func_in_none.result-pq b/mysql-test/r/func_in_none.result-pq new file mode 100644 index 000000000000..f4033ac2ab80 --- /dev/null +++ b/mysql-test/r/func_in_none.result-pq @@ -0,0 +1,997 @@ +drop table if exists t1, t2; +select 1 in (1,2,3); +1 in (1,2,3) +1 +select 10 in (1,2,3); +10 in (1,2,3) +0 +select NULL in (1,2,3); +NULL in (1,2,3) +NULL +select 1 in (1,NULL,3); +1 in (1,NULL,3) +1 +select 3 in (1,NULL,3); +3 in (1,NULL,3) +1 +select 10 in (1,NULL,3); +10 in (1,NULL,3) +NULL +select 1.5 in (1.5,2.5,3.5); +1.5 in (1.5,2.5,3.5) +1 +select 10.5 in (1.5,2.5,3.5); +10.5 in (1.5,2.5,3.5) +0 +select NULL in (1.5,2.5,3.5); +NULL in (1.5,2.5,3.5) +NULL +select 1.5 in (1.5,NULL,3.5); +1.5 in (1.5,NULL,3.5) +1 +select 3.5 in (1.5,NULL,3.5); +3.5 in (1.5,NULL,3.5) +1 +select 10.5 in (1.5,NULL,3.5); +10.5 in (1.5,NULL,3.5) +NULL +CREATE TABLE t1 (a int, b int, c int); +insert into t1 values (1,2,3), (1,NULL,3); +select 1 in (a,b,c) from t1; +1 in (a,b,c) +1 +1 +select 3 in (a,b,c) from t1; +3 in (a,b,c) +1 +1 +select 10 in (a,b,c) from t1; +10 in (a,b,c) +0 +NULL +select NULL in (a,b,c) from t1; +NULL in (a,b,c) +NULL +NULL +drop table t1; +CREATE TABLE t1 (a float, b float, c float); +insert into t1 values (1.5,2.5,3.5), (1.5,NULL,3.5); +select 1.5 in (a,b,c) from t1; +1.5 in (a,b,c) +1 +1 +select 3.5 in (a,b,c) from t1; +3.5 in (a,b,c) +1 +1 +select 10.5 in (a,b,c) from t1; +10.5 in (a,b,c) +0 +NULL +drop table t1; +CREATE TABLE t1 (a varchar(10), b varchar(10), c varchar(10)); +insert into t1 values ('A','BC','EFD'), ('A',NULL,'EFD'); +select 'A' in (a,b,c) from t1; +'A' in (a,b,c) +1 +1 +select 'EFD' in (a,b,c) from t1; +'EFD' in (a,b,c) +1 +1 +select 'XSFGGHF' in (a,b,c) from t1; +'XSFGGHF' in (a,b,c) +0 +NULL +drop table t1; +CREATE TABLE t1 (field char(1)); +INSERT INTO t1 VALUES ('A'),(NULL); +SELECT * from t1 WHERE field IN (NULL); +field +SELECT * from t1 WHERE field NOT IN (NULL); +field +SELECT * from t1 where field = field; +field +A +SELECT * from t1 where field <=> field; +field +A +NULL +DELETE FROM t1 WHERE field NOT IN (NULL); +SELECT * FROM t1; +field +A +NULL +drop table t1; +create table t1 (id int(10) primary key); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t1 values (1),(2),(3),(4),(5),(6),(7),(8),(9); +select * from t1 where id in (2,5,9); +id +2 +5 +9 +drop table t1; +create table t1 ( +a char(1) character set latin1 collate latin1_general_ci, +b char(1) character set latin1 collate latin1_swedish_ci, +c char(1) character set latin1 collate latin1_danish_ci +); +insert into t1 values ('A','B','C'); +insert into t1 values ('a','c','c'); +select * from t1 where a in (b); +ERROR HY000: Illegal mix of collations (latin1_general_ci,IMPLICIT) and (latin1_swedish_ci,IMPLICIT) for operation '=' +select * from t1 where a in (b,c); +ERROR HY000: Illegal mix of collations (latin1_general_ci,IMPLICIT), (latin1_swedish_ci,IMPLICIT), (latin1_danish_ci,IMPLICIT) for operation ' IN ' +select * from t1 where 'a' in (a,b,c); +ERROR HY000: Illegal mix of collations for operation ' IN ' +select * from t1 where 'a' in (a); +a b c +A B C +a c c +select * from t1 where a in ('a'); +a b c +A B C +a c c +set names latin1; +select * from t1 where 'a' collate latin1_general_ci in (a,b,c); +a b c +A B C +a c c +select * from t1 where 'a' collate latin1_bin in (a,b,c); +a b c +a c c +select * from t1 where 'a' in (a,b,c collate latin1_bin); +a b c +a c c +explain select * from t1 where 'a' in (a,b,c collate latin1_bin); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` where ('a' in (`test`.`t1`.`a`,`test`.`t1`.`b`,(`test`.`t1`.`c` collate latin1_bin))) +drop table t1; +set names utf8mb4; +set names utf8; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +create table t1 (a char(10) character set utf8 not null); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +insert into t1 values ('bbbb'),(_koi8r x'C3C3C3C3'),(_latin1 x'C4C4C4C4'); +select a from t1 where a in ('bbbb',_koi8r x'C3C3C3C3',_latin1 x'C4C4C4C4') order by a; +a +ÄÄÄÄ +bbbb +цццц +drop table t1; +create table t1 (a char(10) character set latin1 not null); +insert into t1 values ('a'),('b'),('c'); +select a from t1 where a IN ('a','b','c') order by a; +a +a +b +c +drop table t1; +set names latin1; +select '1.0' in (1,2); +'1.0' in (1,2) +1 +select 1 in ('1.0',2); +1 in ('1.0',2) +1 +select 1 in (1,'2.0'); +1 in (1,'2.0') +1 +select 1 in ('1.0',2.0); +1 in ('1.0',2.0) +1 +select 1 in (1.0,'2.0'); +1 in (1.0,'2.0') +1 +select 1 in ('1.1',2); +1 in ('1.1',2) +0 +select 1 in ('1.1',2.0); +1 in ('1.1',2.0) +0 +create table t1 (a char(2) character set binary); +insert into t1 values ('aa'), ('bb'); +select * from t1 where a in (NULL, 'aa'); +a +aa +drop table t1; +create table t1 (id int, key(id)); +insert into t1 values (1),(2),(3); +select count(*) from t1 where id not in (1); +count(*) +2 +select count(*) from t1 where id not in (1,2); +count(*) +1 +drop table t1; +DROP TABLE IF EXISTS t1; +CREATE TABLE t1 SELECT 1 IN (2, NULL); +SELECT should return NULL. +SELECT * FROM t1; +1 IN (2, NULL) +NULL +DROP TABLE t1; +End of 4.1 tests +CREATE TABLE t1 (a int PRIMARY KEY); +INSERT INTO t1 VALUES (44), (45), (46); +SELECT * FROM t1 WHERE a IN (45); +a +45 +SELECT * FROM t1 WHERE a NOT IN (0, 45); +a +44 +46 +SELECT * FROM t1 WHERE a NOT IN (45); +a +44 +46 +CREATE VIEW v1 AS SELECT * FROM t1 WHERE a NOT IN (45); +SHOW CREATE VIEW v1; +View Create View character_set_client collation_connection +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`a` AS `a` from `t1` where (`t1`.`a` <> 45) latin1 latin1_swedish_ci +SELECT * FROM v1; +a +44 +46 +DROP VIEW v1; +DROP TABLE t1; +create table t1 (a int); +insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t2 (a int, filler char(200), key(a)); +insert into t2 select C.a*2, 'no' from t1 A, t1 B, t1 C; +insert into t2 select C.a*2+1, 'yes' from t1 C; +explain +select * from t2 where a NOT IN (0, 2,4,6,8,10,12,14,16,18); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 100.00 Parallel execute (4 workers) +2 SIMPLE t2 NULL range a a 5 NULL 11 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`filler` AS `filler` from `test`.`t2` where (`test`.`t2`.`a` not in (0,2,4,6,8,10,12,14,16,18)) +select * from t2 where a NOT IN (0, 2,4,6,8,10,12,14,16,18); +a filler +1 yes +3 yes +5 yes +7 yes +9 yes +11 yes +13 yes +15 yes +17 yes +19 yes +explain select * from t2 force index(a) where a NOT IN (2,2,2,2,2,2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 910 100.00 Parallel execute (3 workers) +2 SIMPLE t2 NULL range a a 5 NULL 910 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`filler` AS `filler` from `test`.`t2` FORCE INDEX (`a`) where (`test`.`t2`.`a` not in (2,2,2,2,2,2)) +explain select * from t2 force index(a) where a <> 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 910 100.00 Parallel execute (3 workers) +2 SIMPLE t2 NULL range a a 5 NULL 910 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`filler` AS `filler` from `test`.`t2` FORCE INDEX (`a`) where (`test`.`t2`.`a` <> 2) +drop table t2; +create table t2 (a datetime, filler char(200), key(a)); +insert into t2 select '2006-04-25 10:00:00' + interval C.a minute, +'no' from t1 A, t1 B, t1 C where C.a % 2 = 0; +insert into t2 select '2006-04-25 10:00:00' + interval C.a*2+1 minute, +'yes' from t1 C; +explain +select * from t2 where a NOT IN ( +'2006-04-25 10:00:00','2006-04-25 10:02:00','2006-04-25 10:04:00', +'2006-04-25 10:06:00', '2006-04-25 10:08:00'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 100.00 Parallel execute (4 workers) +2 SIMPLE t2 NULL range a a 6 NULL 11 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`filler` AS `filler` from `test`.`t2` where (`test`.`t2`.`a` not in ('2006-04-25 10:00:00','2006-04-25 10:02:00','2006-04-25 10:04:00','2006-04-25 10:06:00','2006-04-25 10:08:00')) +select * from t2 where a NOT IN ( +'2006-04-25 10:00:00','2006-04-25 10:02:00','2006-04-25 10:04:00', +'2006-04-25 10:06:00', '2006-04-25 10:08:00'); +a filler +2006-04-25 10:01:00 yes +2006-04-25 10:03:00 yes +2006-04-25 10:05:00 yes +2006-04-25 10:07:00 yes +2006-04-25 10:09:00 yes +2006-04-25 10:11:00 yes +2006-04-25 10:13:00 yes +2006-04-25 10:15:00 yes +2006-04-25 10:17:00 yes +2006-04-25 10:19:00 yes +drop table t2; +create table t2 (a varchar(10), filler char(200), key(a)); +insert into t2 select 'foo', 'no' from t1 A, t1 B; +insert into t2 select 'barbar', 'no' from t1 A, t1 B; +insert into t2 select 'bazbazbaz', 'no' from t1 A, t1 B; +insert into t2 values ('fon', '1'), ('fop','1'), ('barbaq','1'), +('barbas','1'), ('bazbazbay', '1'),('zz','1'); +explain select * from t2 where a not in('foo','barbar', 'bazbazbaz'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL 13 NULL 6 100.00 Parallel execute (4 workers) +2 SIMPLE t2 NULL range a a 13 NULL 6 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`filler` AS `filler` from `test`.`t2` where (`test`.`t2`.`a` not in ('foo','barbar','bazbazbaz')) +drop table t2; +create table t2 (a decimal(10,5), filler char(200), key(a)); +insert into t2 select 345.67890, 'no' from t1 A, t1 B; +insert into t2 select 43245.34, 'no' from t1 A, t1 B; +insert into t2 select 64224.56344, 'no' from t1 A, t1 B; +insert into t2 values (0, '1'), (22334.123,'1'), (33333,'1'), +(55555,'1'), (77777, '1'); +explain +select * from t2 where a not in (345.67890, 43245.34, 64224.56344); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (4 workers) +2 SIMPLE t2 NULL range a a 7 NULL 5 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`filler` AS `filler` from `test`.`t2` where (`test`.`t2`.`a` not in (345.67890,43245.34,64224.56344)) +select * from t2 where a not in (345.67890, 43245.34, 64224.56344); +a filler +0.00000 1 +22334.12300 1 +33333.00000 1 +55555.00000 1 +77777.00000 1 +drop table t2; +create table t2 (a int, key(a), b int); +insert into t2 values (1,1),(2,2); +set @cnt= 1; +set @str="update t2 set b=1 where a not in ("; +select count(*) from ( +select @str:=concat(@str, @cnt:=@cnt+1, ",") +from t1 A, t1 B, t1 C, t1 D) Z; +count(*) +10000 +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +set @str:=concat(@str, "10000)"); +select substr(@str, 1, 50); +substr(@str, 1, 50) +update t2 set b=1 where a not in (2,3,4,5,6,7,8,9, +prepare s from @str; +execute s; +deallocate prepare s; +set @str=NULL; +drop table t2; +drop table t1; +create table t1 ( +some_id smallint(5) unsigned, +key (some_id) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t1 values (1),(2); +select some_id from t1 where some_id not in(2,-1); +some_id +1 +select some_id from t1 where some_id not in(-4,-1,-4); +some_id +1 +2 +select some_id from t1 where some_id not in(-4,-1,3423534,2342342); +some_id +1 +2 +select some_id from t1 where some_id not in('-1', '0'); +some_id +1 +2 +drop table t1; +# +# BUG#20420: optimizer reports wrong keys on left join with IN +# +CREATE TABLE t1 (a int, b int, PRIMARY KEY (a)); +INSERT INTO t1 VALUES (1,1),(2,1),(3,1),(4,1),(5,1),(6,1); +CREATE TABLE t2 (a int, b int, PRIMARY KEY (a)); +INSERT INTO t2 VALUES (3,2),(4,2),(100,100),(101,201),(102,102); +CREATE TABLE t3 (a int PRIMARY KEY); +INSERT INTO t3 VALUES (1),(2),(3),(4); +CREATE TABLE t4 (a int PRIMARY KEY,b int); +INSERT INTO t4 VALUES (1,1),(2,2),(1000,1000),(1001,1001),(1002,1002), +(1003,1003),(1004,1004); +EXPLAIN SELECT STRAIGHT_JOIN * FROM t3 +JOIN t1 ON t3.a=t1.a +JOIN t2 ON t3.a=t2.a +JOIN t4 WHERE t4.a IN (t1.b, t2.b); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t3 NULL index PRIMARY PRIMARY 4 NULL 4 100.00 Using index +2 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t3.a 1 100.00 NULL +2 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t3.a 1 100.00 NULL +2 SIMPLE t4 NULL ALL PRIMARY NULL NULL NULL 7 28.57 Range checked for each record (index map: 0x1) +Warnings: +Note 1003 /* select#1 */ select straight_join `test`.`t3`.`a` AS `a`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b` from `test`.`t3` join `test`.`t1` join `test`.`t2` join `test`.`t4` where ((`test`.`t1`.`a` = `test`.`t3`.`a`) and (`test`.`t2`.`a` = `test`.`t3`.`a`) and (`test`.`t4`.`a` in (`test`.`t1`.`b`,`test`.`t2`.`b`))) +SELECT STRAIGHT_JOIN * FROM t3 +JOIN t1 ON t3.a=t1.a +JOIN t2 ON t3.a=t2.a +JOIN t4 WHERE t4.a IN (t1.b, t2.b); +a a b a b a b +3 3 1 3 2 1 1 +3 3 1 3 2 2 2 +4 4 1 4 2 1 1 +4 4 1 4 2 2 2 +EXPLAIN SELECT STRAIGHT_JOIN +(SELECT SUM(t4.a) FROM t4 WHERE t4.a IN (t1.b, t2.b)) +FROM t3, t1, t2 +WHERE t3.a=t1.a AND t3.a=t2.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t3 NULL index PRIMARY PRIMARY 4 NULL 4 100.00 Using index +1 PRIMARY t1 NULL eq_ref PRIMARY PRIMARY 4 test.t3.a 1 100.00 NULL +1 PRIMARY t2 NULL eq_ref PRIMARY PRIMARY 4 test.t3.a 1 100.00 NULL +2 DEPENDENT SUBQUERY t4 NULL index NULL PRIMARY 4 NULL 7 28.57 Using where; Using index +Warnings: +Note 1276 Field or reference 'test.t1.b' of SELECT #2 was resolved in SELECT #1 +Note 1276 Field or reference 'test.t2.b' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select straight_join (/* select#2 */ select sum(`test`.`t4`.`a`) from `test`.`t4` where (`test`.`t4`.`a` in (`test`.`t1`.`b`,`test`.`t2`.`b`))) AS `(SELECT SUM(t4.a) FROM t4 WHERE t4.a IN (t1.b, t2.b))` from `test`.`t3` join `test`.`t1` join `test`.`t2` where ((`test`.`t1`.`a` = `test`.`t3`.`a`) and (`test`.`t2`.`a` = `test`.`t3`.`a`)) +SELECT STRAIGHT_JOIN +(SELECT SUM(t4.a) FROM t4 WHERE t4.a IN (t1.b, t2.b)) +FROM t3, t1, t2 +WHERE t3.a=t1.a AND t3.a=t2.a; +(SELECT SUM(t4.a) FROM t4 WHERE t4.a IN (t1.b, t2.b)) +3 +3 +DROP TABLE t1,t2,t3,t4; +CREATE TABLE t1(a BIGINT UNSIGNED); +INSERT INTO t1 VALUES (0xFFFFFFFFFFFFFFFF); +SELECT * FROM t1 WHERE a=-1 OR a=-2 ; +a +SELECT * FROM t1 WHERE a IN (-1, -2); +a +CREATE TABLE t2 (a BIGINT UNSIGNED); +insert into t2 values(13491727406643098568), +(0x7fffffefffffffff), +(0x7ffffffeffffffff), +(0x7fffffffefffffff), +(0x7ffffffffeffffff), +(0x7fffffffffefffff), +(0x7ffffffffffeffff), +(0x7fffffffffffefff), +(0x7ffffffffffffeff), +(0x7fffffffffffffef), +(0x7ffffffffffffffe), +(0x7fffffffffffffff), +(0x8000000000000000), +(0x8000000000000001), +(0x8000000000000002), +(0x8000000000000300), +(0x8000000000000400), +(0x8000000000000401), +(0x8000000000004001), +(0x8000000000040001), +(0x8000000000400001), +(0x8000000004000001), +(0x8000000040000001), +(0x8000000400000001), +(0x8000004000000001), +(0x8000040000000001); +SELECT HEX(a) FROM t2 WHERE a IN +(CAST(0xBB3C3E98175D33C8 AS UNSIGNED), +42); +HEX(a) +BB3C3E98175D33C8 +SELECT HEX(a) FROM t2 WHERE a IN +(CAST(0xBB3C3E98175D33C8 AS UNSIGNED), +CAST(0x7fffffffffffffff AS UNSIGNED), +CAST(0x8000000000000000 AS UNSIGNED), +CAST(0x8000000000000400 AS UNSIGNED), +CAST(0x8000000000000401 AS UNSIGNED), +42); +HEX(a) +BB3C3E98175D33C8 +7FFFFFFFFFFFFFFF +8000000000000000 +8000000000000400 +8000000000000401 +SELECT HEX(a) FROM t2 WHERE a IN +(CAST(0x7fffffffffffffff AS UNSIGNED), +CAST(0x8000000000000001 AS UNSIGNED)); +HEX(a) +7FFFFFFFFFFFFFFF +8000000000000001 +SELECT HEX(a) FROM t2 WHERE a IN +(CAST(0x7ffffffffffffffe AS UNSIGNED), +CAST(0x7fffffffffffffff AS UNSIGNED)); +HEX(a) +7FFFFFFFFFFFFFFE +7FFFFFFFFFFFFFFF +SELECT HEX(a) FROM t2 WHERE a IN +(0x7ffffffffffffffe, +0x7fffffffffffffff, +'abc'); +HEX(a) +7FFFFFFFFFFFFFFE +7FFFFFFFFFFFFFFF +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'abc' +CREATE TABLE t3 (a BIGINT UNSIGNED); +INSERT INTO t3 VALUES (9223372036854775551); +SELECT HEX(a) FROM t3 WHERE a IN (9223372036854775807, 42); +HEX(a) +CREATE TABLE t4 (a DATE); +INSERT INTO t4 VALUES ('1972-02-06'), ('1972-07-29'); +SELECT * FROM t4 WHERE a IN ('1972-02-06','19772-07-29'); +a +1972-02-06 +Warnings: +Warning 1292 Incorrect date value: '19772-07-29' for column 'a' at row 1 +Warning 1292 Incorrect date value: '19772-07-29' for column 'a' at row 1 +Warning 1292 Incorrect date value: '19772-07-29' for column 'a' at row 1 +DROP TABLE t1,t2,t3,t4; +CREATE TABLE t1 (id int not null); +INSERT INTO t1 VALUES (1),(2); +SELECT id FROM t1 WHERE id IN(4564, (SELECT IF(1=0,1,1/0)) ); +id +Warnings: +Warning 1365 Division by 0 +DROP TABLE t1; +End of 5.0 tests +create table t1(f1 char(1)); +insert into t1 values ('a'),('b'),('1'); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +select f1 from t1 where f1 in ('a',1); +f1 +1 +Warning 1292 Truncated incorrect DOUBLE value: 'b' +Warnings: +a +select f1, case f1 when 'a' then '+' when 1 then '-' end from t1; +f1 case f1 when 'a' then '+' when 1 then '-' end +a + +b NULL +1 - +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'b' +create index t1f1_idx on t1(f1); +select f1 from t1 where f1 in ('a',1); +f1 +1 +Warning 1292 Truncated incorrect DOUBLE value: 'b' +Warnings: +a +explain select f1 from t1 where f1 in ('a',1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL 2 NULL 3 50.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index t1f1_idx t1f1_idx 2 NULL 3 50.00 Using where; Using index +Warnings: +Warning 1739 Cannot use range access on index 't1f1_idx' due to type or collation conversion on field 'f1' +Note 1003 /* select#1 */ select `test`.`t1`.`f1` AS `f1` from `test`.`t1` where (`test`.`t1`.`f1` in ('a',1)) +select f1 from t1 where f1 in ('a','b'); +f1 +a +b +explain select f1 from t1 where f1 in ('a','b'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL 2 NULL 2 100.00 Parallel execute (2 workers) +2 SIMPLE t1 NULL range t1f1_idx t1f1_idx 2 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`f1` AS `f1` from `test`.`t1` where (`test`.`t1`.`f1` in ('a','b')) +select f1 from t1 where f1 in (2,1); +f1 +1 +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'a' +Warning 1292 Truncated incorrect DOUBLE value: 'b' +explain select f1 from t1 where f1 in (2,1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL 2 NULL 3 50.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index t1f1_idx t1f1_idx 2 NULL 3 50.00 Using where; Using index +Warnings: +Warning 1739 Cannot use range access on index 't1f1_idx' due to type or collation conversion on field 'f1' +Note 1003 /* select#1 */ select `test`.`t1`.`f1` AS `f1` from `test`.`t1` where (`test`.`t1`.`f1` in (2,1)) +create table t2(f2 int, index t2f2(f2)); +insert into t2 values(0),(1),(2); +select f2 from t2 where f2 in ('a',2); +f2 +0 +2 +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'a' +Warning 1292 Truncated incorrect DOUBLE value: 'a' +explain select f2 from t2 where f2 in ('a',2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (2 workers) +2 SIMPLE t2 NULL range t2f2 t2f2 5 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`f2` AS `f2` from `test`.`t2` where (`test`.`t2`.`f2` in ('a',2)) +select f2 from t2 where f2 in ('a','b'); +f2 +0 +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'a' +Warning 1292 Truncated incorrect DOUBLE value: 'b' +Warning 1292 Truncated incorrect DOUBLE value: 'a' +Warning 1292 Truncated incorrect DOUBLE value: 'b' +Warning 1292 Truncated incorrect DOUBLE value: 'a' +Warning 1292 Truncated incorrect DOUBLE value: 'b' +explain select f2 from t2 where f2 in ('a','b'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL range t2f2 t2f2 5 NULL 1 100.00 Using where; Using index +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'a' +Warning 1292 Truncated incorrect DOUBLE value: 'b' +Note 1003 /* select#1 */ select `test`.`t2`.`f2` AS `f2` from `test`.`t2` where (`test`.`t2`.`f2` in ('a','b')) +select f2 from t2 where f2 in (1,'b'); +f2 +0 +1 +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'b' +explain select f2 from t2 where f2 in (1,'b'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (2 workers) +2 SIMPLE t2 NULL range t2f2 t2f2 5 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`f2` AS `f2` from `test`.`t2` where (`test`.`t2`.`f2` in (1,'b')) +drop table t1, t2; +create table t1 (a time, key(a)); +insert into t1 values (),(),(),(),(),(),(),(),(),(); +select a from t1 where a not in (a,a,a) group by a; +a +drop table t1; +create table t1 (id int); +select * from t1 where NOT id in (select null union all select 1); +id +select * from t1 where NOT id in (null, 1); +id +drop table t1; +CREATE TABLE t1(c0 INTEGER, c1 INTEGER, c2 INTEGER); +INSERT INTO t1 VALUES(1, 1, 1), (1, 1, 1); +SELECT CASE AVG (c0) WHEN c1 * c2 THEN 1 END FROM t1; +CASE AVG (c0) WHEN c1 * c2 THEN 1 END +1 +SELECT CASE c1 * c2 WHEN SUM(c0) THEN 1 WHEN AVG(c0) THEN 2 END FROM t1; +CASE c1 * c2 WHEN SUM(c0) THEN 1 WHEN AVG(c0) THEN 2 END +2 +SELECT CASE c1 WHEN c1 + 1 THEN 1 END, ABS(AVG(c0)) FROM t1; +CASE c1 WHEN c1 + 1 THEN 1 END ABS(AVG(c0)) +NULL 1.0000 +DROP TABLE t1; +CREATE TABLE t1(a TEXT, b INT, c INT UNSIGNED, d DECIMAL(12,2), e REAL); +INSERT INTO t1 VALUES('iynfj', 1, 1, 1, 1); +INSERT INTO t1 VALUES('innfj', 2, 2, 2, 2); +SELECT SUM( DISTINCT a ) FROM t1 GROUP BY a HAVING a IN ( AVG( 1 ), 1 + a); +SUM( DISTINCT a ) +SELECT SUM( DISTINCT b ) FROM t1 GROUP BY b HAVING b IN ( AVG( 1 ), 1 + b); +SUM( DISTINCT b ) +1 +SELECT SUM( DISTINCT c ) FROM t1 GROUP BY c HAVING c IN ( AVG( 1 ), 1 + c); +SUM( DISTINCT c ) +1 +SELECT SUM( DISTINCT d ) FROM t1 GROUP BY d HAVING d IN ( AVG( 1 ), 1 + d); +SUM( DISTINCT d ) +1.00 +SELECT SUM( DISTINCT e ) FROM t1 GROUP BY e HAVING e IN ( AVG( 1 ), 1 + e); +SUM( DISTINCT e ) +1 +SELECT SUM( DISTINCT e ) FROM t1 GROUP BY b,c,d HAVING (b,c,d) IN +((AVG( 1 ), 1 + c, 1 + d), (AVG( 1 ), 2 + c, 2 + d)); +SUM( DISTINCT e ) +DROP TABLE t1; +# +# Bug #44139: Table scan when NULL appears in IN clause +# +CREATE TABLE t1 ( +c_int INT NOT NULL, +c_decimal DECIMAL(5,2) NOT NULL, +c_float FLOAT(5, 2) NOT NULL, +c_bit BIT(10) NOT NULL, +c_date DATE NOT NULL, +c_datetime DATETIME NOT NULL, +c_timestamp TIMESTAMP NOT NULL, +c_time TIME NOT NULL, +c_year YEAR NOT NULL, +c_char CHAR(10) character set utf8mb4 NOT NULL, +INDEX(c_int), INDEX(c_decimal), INDEX(c_float), INDEX(c_bit), INDEX(c_date), +INDEX(c_datetime), INDEX(c_timestamp), INDEX(c_time), INDEX(c_year), +INDEX(c_char)); +INSERT IGNORE INTO t1 (c_int) VALUES (1), (2), (3), (4), (5); +INSERT IGNORE INTO t1 (c_int) SELECT 0 FROM t1; +INSERT IGNORE INTO t1 (c_int) SELECT 0 FROM t1; +EXPLAIN SELECT * FROM t1 WHERE c_int IN (1, 2, 3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (3 workers) +2 SIMPLE t1 NULL range c_int c_int 4 NULL 3 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_int` in (1,2,3)) +EXPLAIN SELECT * FROM t1 WHERE c_int IN (NULL, 1, 2, 3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (3 workers) +2 SIMPLE t1 NULL range c_int c_int 4 NULL 3 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_int` in (NULL,1,2,3)) +EXPLAIN SELECT * FROM t1 WHERE c_int IN (1, 2, 3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (3 workers) +2 SIMPLE t1 NULL range c_int c_int 4 NULL 3 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_int` in (1,2,3)) +EXPLAIN SELECT * FROM t1 WHERE c_int IN (1, NULL, 2, NULL, 3, NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (3 workers) +2 SIMPLE t1 NULL range c_int c_int 4 NULL 3 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_int` in (1,NULL,2,NULL,3,NULL)) +EXPLAIN SELECT * FROM t1 WHERE c_int IN (NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_int` = NULL) +EXPLAIN SELECT * FROM t1 WHERE c_int IN (NULL, NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_int` in (NULL,NULL)) +EXPLAIN SELECT * FROM t1 WHERE c_decimal IN (1, 2, 3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range c_decimal c_decimal 3 NULL 3 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_decimal` in (1,2,3)) +EXPLAIN SELECT * FROM t1 WHERE c_decimal IN (NULL, 1, 2, 3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range c_decimal c_decimal 3 NULL 3 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_decimal` in (NULL,1,2,3)) +EXPLAIN SELECT * FROM t1 WHERE c_decimal IN (NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_decimal` = NULL) +EXPLAIN SELECT * FROM t1 WHERE c_decimal IN (NULL, NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_decimal` in (NULL,NULL)) +EXPLAIN SELECT * FROM t1 WHERE c_float IN (1, 2, 3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range c_float c_float 4 NULL 3 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_float` in (1,2,3)) +EXPLAIN SELECT * FROM t1 WHERE c_float IN (NULL, 1, 2, 3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range c_float c_float 4 NULL 3 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_float` in (NULL,1,2,3)) +EXPLAIN SELECT * FROM t1 WHERE c_float IN (NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_float` = NULL) +EXPLAIN SELECT * FROM t1 WHERE c_float IN (NULL, NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_float` in (NULL,NULL)) +EXPLAIN SELECT * FROM t1 WHERE c_bit IN (1, 2, 3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range c_bit c_bit 2 NULL 3 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_bit` in (1,2,3)) +EXPLAIN SELECT * FROM t1 WHERE c_bit IN (NULL, 1, 2, 3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range c_bit c_bit 2 NULL 3 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_bit` in (NULL,1,2,3)) +EXPLAIN SELECT * FROM t1 WHERE c_bit IN (NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_bit` = NULL) +EXPLAIN SELECT * FROM t1 WHERE c_bit IN (NULL, NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_bit` in (NULL,NULL)) +EXPLAIN SELECT * FROM t1 WHERE c_date +IN ('2009-09-01', '2009-09-02', '2009-09-03'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range c_date c_date 3 NULL 3 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_date` in ('2009-09-01','2009-09-02','2009-09-03')) +EXPLAIN SELECT * FROM t1 WHERE c_date +IN (NULL, '2009-09-01', '2009-09-02', '2009-09-03'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range c_date c_date 3 NULL 3 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_date` in (NULL,'2009-09-01','2009-09-02','2009-09-03')) +EXPLAIN SELECT * FROM t1 WHERE c_date IN (NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where multiple equal(NULL, `test`.`t1`.`c_date`) +EXPLAIN SELECT * FROM t1 WHERE c_date IN (NULL, NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_date` in (NULL,NULL)) +EXPLAIN SELECT * FROM t1 WHERE c_datetime +IN ('2009-09-01 00:00:01', '2009-09-02 00:00:01', '2009-09-03 00:00:01'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range c_datetime c_datetime 5 NULL 3 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_datetime` in ('2009-09-01 00:00:01','2009-09-02 00:00:01','2009-09-03 00:00:01')) +EXPLAIN SELECT * FROM t1 WHERE c_datetime +IN (NULL, '2009-09-01 00:00:01', '2009-09-02 00:00:01', '2009-09-03 00:00:01'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range c_datetime c_datetime 5 NULL 3 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_datetime` in (NULL,'2009-09-01 00:00:01','2009-09-02 00:00:01','2009-09-03 00:00:01')) +EXPLAIN SELECT * FROM t1 WHERE c_datetime IN (NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where multiple equal(NULL, `test`.`t1`.`c_datetime`) +EXPLAIN SELECT * FROM t1 WHERE c_datetime IN (NULL, NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_datetime` in (NULL,NULL)) +EXPLAIN SELECT * FROM t1 WHERE c_timestamp +IN ('2009-09-01 00:00:01', '2009-09-01 00:00:02', '2009-09-01 00:00:03'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range c_timestamp c_timestamp 4 NULL 3 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_timestamp` in ('2009-09-01 00:00:01','2009-09-01 00:00:02','2009-09-01 00:00:03')) +EXPLAIN SELECT * FROM t1 WHERE c_timestamp +IN (NULL, '2009-09-01 00:00:01', '2009-09-01 00:00:02', '2009-09-01 00:00:03'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range c_timestamp c_timestamp 4 NULL 3 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_timestamp` in (NULL,'2009-09-01 00:00:01','2009-09-01 00:00:02','2009-09-01 00:00:03')) +EXPLAIN SELECT * FROM t1 WHERE c_timestamp IN (NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where multiple equal(NULL, `test`.`t1`.`c_timestamp`) +EXPLAIN SELECT * FROM t1 WHERE c_timestamp IN (NULL, NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_timestamp` in (NULL,NULL)) +EXPLAIN SELECT * FROM t1 WHERE c_year IN (1, 2, 3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range c_year c_year 1 NULL 3 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_year` in (1,2,3)) +EXPLAIN SELECT * FROM t1 WHERE c_year IN (NULL, 1, 2, 3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range c_year c_year 1 NULL 3 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_year` in (NULL,1,2,3)) +EXPLAIN SELECT * FROM t1 WHERE c_year IN (NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_year` = NULL) +EXPLAIN SELECT * FROM t1 WHERE c_year IN (NULL, NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_year` in (NULL,NULL)) +EXPLAIN SELECT * FROM t1 WHERE c_char IN ('1', '2', '3'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range c_char c_char 40 NULL 3 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_char` in ('1','2','3')) +EXPLAIN SELECT * FROM t1 WHERE c_char IN (NULL, '1', '2', '3'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range c_char c_char 40 NULL 3 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_char` in (NULL,'1','2','3')) +EXPLAIN SELECT * FROM t1 WHERE c_char IN (NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where multiple equal(NULL, `test`.`t1`.`c_char`) +EXPLAIN SELECT * FROM t1 WHERE c_char IN (NULL, NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_char` in (NULL,NULL)) +DROP TABLE t1; +# +# Bug#54477: Crash on IN / CASE with NULL arguments +# +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2); +SELECT 1 IN (NULL, a) FROM t1; +1 IN (NULL, a) +1 +NULL +SELECT a IN (a, a) FROM t1 GROUP BY a WITH ROLLUP; +a IN (a, a) +1 +1 +NULL +SELECT CASE a WHEN a THEN a END FROM t1 GROUP BY a WITH ROLLUP; +CASE a WHEN a THEN a END +1 +2 +NULL +DROP TABLE t1; +# +# Bug#58628: Incorrect result for 'WHERE NULL NOT IN () +# +CREATE TABLE t1 (pk INT NOT NULL, i INT); +INSERT INTO t1 VALUES (0,NULL), (1,NULL), (2,NULL), (3,NULL); +CREATE TABLE subq (pk INT NOT NULL, i INT NOT NULL, PRIMARY KEY(i,pk)); +INSERT INTO subq VALUES (0,0), (1,1), (2,2), (3,3); +SELECT * FROM t1 +WHERE t1.i NOT IN +(SELECT i FROM subq WHERE subq.pk = t1.pk); +pk i +SELECT * FROM t1 +WHERE t1.i IN +(SELECT i FROM subq WHERE subq.pk = t1.pk) IS UNKNOWN; +pk i +0 NULL +1 NULL +2 NULL +3 NULL +SELECT * FROM t1 +WHERE NULL NOT IN +(SELECT i FROM subq WHERE subq.pk = t1.pk); +pk i +SELECT * FROM t1 +WHERE NULL IN +(SELECT i FROM subq WHERE subq.pk = t1.pk) IS UNKNOWN; +pk i +0 NULL +1 NULL +2 NULL +3 NULL +SELECT * FROM t1 +WHERE 1+NULL NOT IN +(SELECT i FROM subq WHERE subq.pk = t1.pk); +pk i +DROP TABLE t1,subq; +# +# Bug #11766270 59343: YEAR(4): INCORRECT RESULT AND VALGRIND WARNINGS WITH MIN/MAX, UNION +# +CREATE TABLE t1(f1 YEAR); +INSERT INTO t1 VALUES (0000),(2001); +(SELECT MAX(f1) FROM t1) UNION (SELECT MAX(f1) FROM t1); +Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr +def MAX(f1) MAX(f1) 13 4 4 Y 32864 0 63 +MAX(f1) +2001 +DROP TABLE t1; +# +# Bug #11764651-57510: IN(string,real,string) causes invalid read in sort function +# +SELECT LEFT(ST_GEOMFROMTEXT("POINT(0 0)"),1) IN (@@global.max_allowed_packet,1,""); +LEFT(ST_GEOMFROMTEXT("POINT(0 0)"),1) IN (@@global.max_allowed_packet,1,"") +0 +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: '\x00' +# End of test BUG#11764651-57510 +End of 5.1 tests +set optimizer_switch=default; diff --git a/mysql-test/r/func_math.result-pq b/mysql-test/r/func_math.result-pq new file mode 100644 index 000000000000..0d6e60101315 --- /dev/null +++ b/mysql-test/r/func_math.result-pq @@ -0,0 +1,2066 @@ +drop table if exists t1; +select floor(5.5),floor(-5.5); +floor(5.5) floor(-5.5) +5 -6 +explain select floor(5.5),floor(-5.5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 /* select#1 */ select floor(5.5) AS `floor(5.5)`,floor(-(5.5)) AS `floor(-5.5)` +select ceiling(5.5),ceiling(-5.5); +ceiling(5.5) ceiling(-5.5) +6 -5 +explain select ceiling(5.5),ceiling(-5.5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 /* select#1 */ select ceiling(5.5) AS `ceiling(5.5)`,ceiling(-(5.5)) AS `ceiling(-5.5)` +select truncate(52.64,1),truncate(52.64,2),truncate(52.64,-1),truncate(52.64,-2), truncate(-52.64,1),truncate(-52.64,-1); +truncate(52.64,1) truncate(52.64,2) truncate(52.64,-1) truncate(52.64,-2) truncate(-52.64,1) truncate(-52.64,-1) +52.6 52.64 50 0 -52.6 -50 +explain select truncate(52.64,1),truncate(52.64,2),truncate(52.64,-1),truncate(52.64,-2), truncate(-52.64,1),truncate(-52.64,-1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 /* select#1 */ select truncate(52.64,1) AS `truncate(52.64,1)`,truncate(52.64,2) AS `truncate(52.64,2)`,truncate(52.64,-(1)) AS `truncate(52.64,-1)`,truncate(52.64,-(2)) AS `truncate(52.64,-2)`,truncate(-(52.64),1) AS `truncate(-52.64,1)`,truncate(-(52.64),-(1)) AS `truncate(-52.64,-1)` +select round(5.5),round(-5.5); +round(5.5) round(-5.5) +6 -6 +explain select round(5.5),round(-5.5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 /* select#1 */ select round(5.5,0) AS `round(5.5)`,round(-(5.5),0) AS `round(-5.5)` +select round(5.64,1),round(5.64,2),round(5.64,-1),round(5.64,-2); +round(5.64,1) round(5.64,2) round(5.64,-1) round(5.64,-2) +5.6 5.64 10 0 +select abs(-10), sign(-5), sign(5), sign(0); +abs(-10) sign(-5) sign(5) sign(0) +10 -1 1 0 +explain select abs(-10), sign(-5), sign(5), sign(0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 /* select#1 */ select abs(-(10)) AS `abs(-10)`,sign(-(5)) AS `sign(-5)`,sign(5) AS `sign(5)`,sign(0) AS `sign(0)` +select log(exp(10)),exp(log(sqrt(10))*2),log(-1),log(NULL),log(1,1),log(3,9),log(-1,2),log(NULL,2); +log(exp(10)) exp(log(sqrt(10))*2) log(-1) log(NULL) log(1,1) log(3,9) log(-1,2) log(NULL,2) +10 10.000000000000002 NULL NULL NULL 2 NULL NULL +Warnings: +Warning 3020 Invalid argument for logarithm +Warning 3020 Invalid argument for logarithm +Warning 3020 Invalid argument for logarithm +explain select log(exp(10)),exp(log(sqrt(10))*2),log(-1),log(NULL),log(1,1),log(3,9),log(-1,2),log(NULL,2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 /* select#1 */ select log(exp(10)) AS `log(exp(10))`,exp((log(sqrt(10)) * 2)) AS `exp(log(sqrt(10))*2)`,log(-(1)) AS `log(-1)`,log(NULL) AS `log(NULL)`,log(1,1) AS `log(1,1)`,log(3,9) AS `log(3,9)`,log(-(1),2) AS `log(-1,2)`,log(NULL,2) AS `log(NULL,2)` +select ln(exp(10)),exp(ln(sqrt(10))*2),ln(-1),ln(0),ln(NULL); +ln(exp(10)) exp(ln(sqrt(10))*2) ln(-1) ln(0) ln(NULL) +10 10.000000000000002 NULL NULL NULL +Warnings: +Warning 3020 Invalid argument for logarithm +Warning 3020 Invalid argument for logarithm +explain select ln(exp(10)),exp(ln(sqrt(10))*2),ln(-1),ln(0),ln(NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 /* select#1 */ select ln(exp(10)) AS `ln(exp(10))`,exp((ln(sqrt(10)) * 2)) AS `exp(ln(sqrt(10))*2)`,ln(-(1)) AS `ln(-1)`,ln(0) AS `ln(0)`,ln(NULL) AS `ln(NULL)` +select log2(8),log2(15),log2(-2),log2(0),log2(NULL); +log2(8) log2(15) log2(-2) log2(0) log2(NULL) +3 3.9068905956085187 NULL NULL NULL +Warnings: +Warning 3020 Invalid argument for logarithm +Warning 3020 Invalid argument for logarithm +explain select log2(8),log2(15),log2(-2),log2(0),log2(NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 /* select#1 */ select log2(8) AS `log2(8)`,log2(15) AS `log2(15)`,log2(-(2)) AS `log2(-2)`,log2(0) AS `log2(0)`,log2(NULL) AS `log2(NULL)` +select log10(100),log10(18),log10(-4),log10(0),log10(NULL); +log10(100) log10(18) log10(-4) log10(0) log10(NULL) +2 1.255272505103306 NULL NULL NULL +Warnings: +Warning 3020 Invalid argument for logarithm +Warning 3020 Invalid argument for logarithm +explain select log10(100),log10(18),log10(-4),log10(0),log10(NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 /* select#1 */ select log10(100) AS `log10(100)`,log10(18) AS `log10(18)`,log10(-(4)) AS `log10(-4)`,log10(0) AS `log10(0)`,log10(NULL) AS `log10(NULL)` +select pow(10,log10(10)),power(2,4); +pow(10,log10(10)) power(2,4) +10 16 +explain select pow(10,log10(10)),power(2,4); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 /* select#1 */ select pow(10,log10(10)) AS `pow(10,log10(10))`,pow(2,4) AS `power(2,4)` +set @@rand_seed1=10000000,@@rand_seed2=1000000; +select rand(999999),rand(); +rand(999999) rand() +0.014231365187309091 0.028870999839968048 +explain select rand(999999),rand(); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 /* select#1 */ select rand(999999) AS `rand(999999)`,rand() AS `rand()` +select pi(),format(sin(pi()/2),6),format(cos(pi()/2),6),format(abs(tan(pi())),6),format(cot(1),6),format(asin(1),6),format(acos(0),6),format(atan(1),6); +pi() format(sin(pi()/2),6) format(cos(pi()/2),6) format(abs(tan(pi())),6) format(cot(1),6) format(asin(1),6) format(acos(0),6) format(atan(1),6) +3.141593 1.000000 0.000000 0.000000 0.642093 1.570796 1.570796 0.785398 +explain select pi(),format(sin(pi()/2),6),format(cos(pi()/2),6),format(abs(tan(pi())),6),format(cot(1),6),format(asin(1),6),format(acos(0),6),format(atan(1),6); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 /* select#1 */ select pi() AS `pi()`,format(sin((pi() / 2)),6) AS `format(sin(pi()/2),6)`,format(cos((pi() / 2)),6) AS `format(cos(pi()/2),6)`,format(abs(tan(pi())),6) AS `format(abs(tan(pi())),6)`,format(cot(1),6) AS `format(cot(1),6)`,format(asin(1),6) AS `format(asin(1),6)`,format(acos(0),6) AS `format(acos(0),6)`,format(atan(1),6) AS `format(atan(1),6)` +select degrees(pi()),radians(360); +degrees(pi()) radians(360) +180 6.283185307179586 +select format(atan(-2, 2), 6); +format(atan(-2, 2), 6) +-0.785398 +select format(atan(pi(), 0), 6); +format(atan(pi(), 0), 6) +1.570796 +select format(atan2(-2, 2), 6); +format(atan2(-2, 2), 6) +-0.785398 +select format(atan2(pi(), 0), 6); +format(atan2(pi(), 0), 6) +1.570796 +SELECT ACOS(1.0); +ACOS(1.0) +0 +SELECT ASIN(1.0); +ASIN(1.0) +1.5707963267948966 +SELECT ACOS(0.2*5.0); +ACOS(0.2*5.0) +0 +SELECT ACOS(0.5*2.0); +ACOS(0.5*2.0) +0 +SELECT ASIN(0.8+0.2); +ASIN(0.8+0.2) +1.5707963267948966 +SELECT ASIN(1.2-0.2); +ASIN(1.2-0.2) +1.5707963267948966 +select format(4.55, 1), format(4.551, 1); +format(4.55, 1) format(4.551, 1) +4.6 4.6 +explain select degrees(pi()),radians(360); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 /* select#1 */ select degrees(pi()) AS `degrees(pi())`,radians(360) AS `radians(360)` +select rand(rand); +ERROR 42S22: Unknown column 'rand' in 'field list' +create table t1 (col1 int, col2 decimal(60,30)); +insert into t1 values(1,1234567890.12345); +select format(col2,7) from t1; +format(col2,7) +1,234,567,890.1234500 +select format(col2,8) from t1; +format(col2,8) +1,234,567,890.12345000 +insert into t1 values(7,1234567890123456.12345); +select format(col2,6) from t1 where col1=7; +format(col2,6) +1,234,567,890,123,456.123450 +drop table t1; +select ceil(0.09); +ceil(0.09) +1 +select ceil(0.000000000000000009); +ceil(0.000000000000000009) +1 +create table t1 select round(1, 6); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `round(1, 6)` bigint NOT NULL DEFAULT '0' +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +select * from t1; +round(1, 6) +1 +drop table t1; +select abs(-2) * -2; +abs(-2) * -2 +-4 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1),(1),(1),(2); +SELECT CAST(RAND(2) * 1000 AS UNSIGNED), CAST(RAND(a) * 1000 AS UNSIGNED) +FROM t1; +CAST(RAND(2) * 1000 AS UNSIGNED) CAST(RAND(a) * 1000 AS UNSIGNED) +656 405 +122 405 +645 405 +858 656 +SELECT CAST(RAND(2) * 1000 AS UNSIGNED), CAST(RAND(a) * 1000 AS UNSIGNED) +FROM t1 WHERE a = 1; +CAST(RAND(2) * 1000 AS UNSIGNED) CAST(RAND(a) * 1000 AS UNSIGNED) +656 405 +122 405 +645 405 +INSERT INTO t1 VALUES (3); +SELECT CAST(RAND(2) * 1000 AS UNSIGNED), CAST(RAND(a) * 1000 AS UNSIGNED) +FROM t1; +CAST(RAND(2) * 1000 AS UNSIGNED) CAST(RAND(a) * 1000 AS UNSIGNED) +656 405 +122 405 +645 405 +858 656 +354 906 +SELECT CAST(RAND(2) * 1000 AS UNSIGNED), CAST(RAND(a) * 1000 AS UNSIGNED) +FROM t1 WHERE a = 1; +CAST(RAND(2) * 1000 AS UNSIGNED) CAST(RAND(a) * 1000 AS UNSIGNED) +656 405 +122 405 +645 405 +PREPARE stmt FROM +"SELECT CAST(RAND(2) * 1000 AS UNSIGNED), CAST(RAND(?) * 1000 AS UNSIGNED) + FROM t1 WHERE a = 1"; +set @var=2; +EXECUTE stmt USING @var; +CAST(RAND(2) * 1000 AS UNSIGNED) CAST(RAND(?) * 1000 AS UNSIGNED) +656 656 +122 122 +645 645 +DROP TABLE t1; +SET timestamp=UNIX_TIMESTAMP('2001-01-01 00:00:00'); +create table t1 (a varchar(90), ts datetime not null, index (a)) engine=innodb default charset=utf8; +insert into t1 values ('http://www.foo.com/', now()); +select a from t1 where a='http://www.foo.com/' order by abs(timediff(ts, 0)); +a +http://www.foo.com/ +Warnings: +Warning 1292 Truncated incorrect time value: '17540424:00:00' +Warning 1292 Truncated incorrect time value: '17540424:00:00' +drop table t1; +SET timestamp=DEFAULT; +set sql_mode='traditional'; +select ln(-1); +ln(-1) +NULL +Warnings: +Warning 3020 Invalid argument for logarithm +select log10(-1); +log10(-1) +NULL +Warnings: +Warning 3020 Invalid argument for logarithm +select log2(-1); +log2(-1) +NULL +Warnings: +Warning 3020 Invalid argument for logarithm +select log(2,-1); +log(2,-1) +NULL +Warnings: +Warning 3020 Invalid argument for logarithm +select log(-2,1); +log(-2,1) +NULL +Warnings: +Warning 3020 Invalid argument for logarithm +set sql_mode=''; +select round(111,-10); +round(111,-10) +0 +select round(-5000111000111000155,-1); +round(-5000111000111000155,-1) +-5000111000111000160 +select round(15000111000111000155,-1); +round(15000111000111000155,-1) +15000111000111000160 +select truncate(-5000111000111000155,-1); +truncate(-5000111000111000155,-1) +-5000111000111000150 +select truncate(15000111000111000155,-1); +truncate(15000111000111000155,-1) +15000111000111000150 +set names utf8; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +create table t1 +(f1 varchar(32) not null, +f2 smallint(5) unsigned not null, +f3 int(10) unsigned not null default '0') +default charset=utf8; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +insert into t1 values ('zombie',0,0),('gold',1,10000),('silver',2,10000); +create table t2 +(f1 int(10) unsigned not null, +f2 int(10) unsigned not null, +f3 smallint(5) unsigned not null) +default charset=utf8; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +insert into t2 values (16777216,16787215,1),(33554432,33564431,2); +select format(t2.f2-t2.f1+1,0) from t1,t2 +where t1.f2 = t2.f3 order by t1.f1; +format(t2.f2-t2.f1+1,0) +10,000 +10,000 +drop table t1, t2; +set names default; +select cast(-2 as unsigned), 18446744073709551614, -2; +cast(-2 as unsigned) 18446744073709551614 -2 +18446744073709551614 18446744073709551614 -2 +select abs(cast(-2 as unsigned)), abs(18446744073709551614), abs(-2); +abs(cast(-2 as unsigned)) abs(18446744073709551614) abs(-2) +18446744073709551614 18446744073709551614 2 +select ceiling(cast(-2 as unsigned)), ceiling(18446744073709551614), ceiling(-2); +ceiling(cast(-2 as unsigned)) ceiling(18446744073709551614) ceiling(-2) +18446744073709551614 18446744073709551614 -2 +select floor(cast(-2 as unsigned)), floor(18446744073709551614), floor(-2); +floor(cast(-2 as unsigned)) floor(18446744073709551614) floor(-2) +18446744073709551614 18446744073709551614 -2 +select format(cast(-2 as unsigned), 2), format(18446744073709551614, 2), format(-2, 2); +format(cast(-2 as unsigned), 2) format(18446744073709551614, 2) format(-2, 2) +18,446,744,073,709,551,614.00 18,446,744,073,709,551,614.00 -2.00 +select sqrt(cast(-2 as unsigned)), sqrt(18446744073709551614), sqrt(-2); +sqrt(cast(-2 as unsigned)) sqrt(18446744073709551614) sqrt(-2) +4294967296 4294967296 NULL +select round(cast(-2 as unsigned), 1), round(18446744073709551614, 1), round(-2, 1); +round(cast(-2 as unsigned), 1) round(18446744073709551614, 1) round(-2, 1) +18446744073709551614 18446744073709551614 -2 +select round(4, cast(-2 as unsigned)), round(4, 18446744073709551614), round(4, -2); +round(4, cast(-2 as unsigned)) round(4, 18446744073709551614) round(4, -2) +4 4 0 +select truncate(cast(-2 as unsigned), 1), truncate(18446744073709551614, 1), truncate(-2, 1); +truncate(cast(-2 as unsigned), 1) truncate(18446744073709551614, 1) truncate(-2, 1) +18446744073709551614 18446744073709551614 -2 +select truncate(4, cast(-2 as unsigned)), truncate(4, 18446744073709551614), truncate(4, -2); +truncate(4, cast(-2 as unsigned)) truncate(4, 18446744073709551614) truncate(4, -2) +4 4 0 +select round(10000000000000000000, -19), truncate(10000000000000000000, -19); +round(10000000000000000000, -19) truncate(10000000000000000000, -19) +10000000000000000000 10000000000000000000 +select round(1e0, -309), truncate(1e0, -309); +round(1e0, -309) truncate(1e0, -309) +0 0 +select round(1e1,308), truncate(1e1, 308); +round(1e1,308) truncate(1e1, 308) +10 10 +select round(1e1, 2147483648), truncate(1e1, 2147483648); +round(1e1, 2147483648) truncate(1e1, 2147483648) +10 10 +select round(1.1e1, 4294967295), truncate(1.1e1, 4294967295); +round(1.1e1, 4294967295) truncate(1.1e1, 4294967295) +11 11 +select round(1.12e1, 4294967296), truncate(1.12e1, 4294967296); +round(1.12e1, 4294967296) truncate(1.12e1, 4294967296) +11.2 11.2 +select round(1.5, 2147483640), truncate(1.5, 2147483640); +round(1.5, 2147483640) truncate(1.5, 2147483640) +1.5 1.5 +select round(1.5, -2147483649), round(1.5, 2147483648); +round(1.5, -2147483649) round(1.5, 2147483648) +0 1.5 +select truncate(1.5, -2147483649), truncate(1.5, 2147483648); +truncate(1.5, -2147483649) truncate(1.5, 2147483648) +0 1.5 +select round(1.5, -4294967296), round(1.5, 4294967296); +round(1.5, -4294967296) round(1.5, 4294967296) +0 1.5 +select truncate(1.5, -4294967296), truncate(1.5, 4294967296); +truncate(1.5, -4294967296) truncate(1.5, 4294967296) +0 1.5 +select round(1.5, -9223372036854775808), round(1.5, 9223372036854775808); +round(1.5, -9223372036854775808) round(1.5, 9223372036854775808) +0 1.5 +select truncate(1.5, -9223372036854775808), truncate(1.5, 9223372036854775808); +truncate(1.5, -9223372036854775808) truncate(1.5, 9223372036854775808) +0 1.5 +select round(1.5, 18446744073709551615), truncate(1.5, 18446744073709551615); +round(1.5, 18446744073709551615) truncate(1.5, 18446744073709551615) +1.5 1.5 +select round(18446744073709551614, -1), truncate(18446744073709551614, -1); +round(18446744073709551614, -1) truncate(18446744073709551614, -1) +18446744073709551610 18446744073709551610 +select round(4, -4294967200), truncate(4, -4294967200); +round(4, -4294967200) truncate(4, -4294967200) +0 0 +select mod(cast(-2 as unsigned), 3), mod(18446744073709551614, 3), mod(-2, 3); +mod(cast(-2 as unsigned), 3) mod(18446744073709551614, 3) mod(-2, 3) +2 2 -2 +select mod(5, cast(-2 as unsigned)), mod(5, 18446744073709551614), mod(5, -2); +mod(5, cast(-2 as unsigned)) mod(5, 18446744073709551614) mod(5, -2) +5 5 1 +select pow(cast(-2 as unsigned), 5), pow(18446744073709551614, 5), pow(-2, 5); +pow(cast(-2 as unsigned), 5) pow(18446744073709551614, 5) pow(-2, 5) +2.13598703592091e96 2.13598703592091e96 -32 +CREATE TABLE t1 (a timestamp, b varchar(20), c bit(1)); +INSERT INTO t1 VALUES('1998-09-23', 'str1', 1), ('2003-03-25', 'str2', 0); +SELECT a DIV 900 y FROM t1 GROUP BY y; +y +22201025555 +22255916666 +SELECT DISTINCT a DIV 900 y FROM t1; +y +22201025555 +22255916666 +SELECT b DIV 900 y FROM t1 GROUP BY y; +y +0 +Warnings: +Warning 1366 Incorrect DECIMAL value: '0' for column '' at row -1 +Warning 1292 Truncated incorrect DECIMAL value: 'str1' +Warning 1366 Incorrect DECIMAL value: '0' for column '' at row -1 +Warning 1292 Truncated incorrect DECIMAL value: 'str2' +SELECT c DIV 900 y FROM t1 GROUP BY y; +y +0 +DROP TABLE t1; +CREATE TABLE t1(a LONGBLOB); +INSERT INTO t1 VALUES('1'),('2'),('3'); +SELECT DISTINCT (a DIV 254576881) FROM t1; +(a DIV 254576881) +0 +SELECT (a DIV 254576881) FROM t1 UNION ALL +SELECT (a DIV 254576881) FROM t1; +(a DIV 254576881) +0 +0 +0 +0 +0 +0 +DROP TABLE t1; +CREATE TABLE t1(a SET('a','b','c')); +INSERT INTO t1 VALUES ('a'); +SELECT a DIV 2 FROM t1 UNION SELECT a DIV 2 FROM t1; +a DIV 2 +0 +DROP TABLE t1; +CREATE TABLE t1 (a DOUBLE); +INSERT INTO t1 VALUES (-1.1), (1.1), +(-1.5), (1.5), +(-1.9), (1.9), +(-2.1), (2.1), +(-2.5), (2.5), +(-2.9), (2.9), +# Check numbers with absolute values > 2^53 - 1 +# (see comments for MAX_EXACT_INTEGER) +(-1e16 - 0.5), (1e16 + 0.5), +(-1e16 - 1.5), (1e16 + 1.5); +SELECT a, ROUND(a) FROM t1; +a ROUND(a) +-1.1 -1 +1.1 1 +-1.5 -2 +1.5 2 +-1.9 -2 +1.9 2 +-2.1 -2 +2.1 2 +-2.5 -2 +2.5 2 +-2.9 -3 +2.9 3 +-1e16 -1e16 +1e16 1e16 +-1.0000000000000002e16 -1.0000000000000002e16 +1.0000000000000002e16 1.0000000000000002e16 +DROP TABLE t1; +CREATE TABLE t1(f1 LONGTEXT); +INSERT INTO t1 VALUES ('a'); +SELECT 1 FROM (SELECT ROUND(f1) AS a FROM t1) AS s WHERE a LIKE 'a'; +1 +SELECT 1 FROM (SELECT ROUND(f1, f1) AS a FROM t1) AS s WHERE a LIKE 'a'; +1 +DROP TABLE t1; +End of 5.0 tests +SELECT 1e308 + 1e308; +ERROR 22003: DOUBLE value is out of range in '(1e308 + 1e308)' +SELECT -1e308 - 1e308; +ERROR 22003: DOUBLE value is out of range in '(-(1e308) - 1e308)' +SELECT 1e300 * 1e300; +ERROR 22003: DOUBLE value is out of range in '(1e300 * 1e300)' +SELECT 1e300 / 1e-300; +ERROR 22003: DOUBLE value is out of range in '(1e300 / 1e-300)' +SELECT EXP(750); +ERROR 22003: DOUBLE value is out of range in 'exp(750)' +SELECT POW(10, 309); +ERROR 22003: DOUBLE value is out of range in 'pow(10,309)' +# +# Bug #44768: SIGFPE crash when selecting rand from a view +# containing null +# +CREATE OR REPLACE VIEW v1 AS SELECT NULL AS a; +SELECT RAND(a) FROM v1; +RAND(a) +0.15522042769493574 +DROP VIEW v1; +SELECT RAND(a) FROM (SELECT NULL AS a) b; +RAND(a) +0.15522042769493574 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (NULL); +SELECT RAND(i) FROM t1; +RAND(i) +0.15522042769493574 +DROP TABLE t1; +# +# Bug#57477 SIGFPE when dividing a huge number a negative number +# +SELECT -9999999999999999991 DIV -1; +ERROR 22003: BIGINT value is out of range in '(-(9999999999999999991) DIV -(1))' +SELECT -9223372036854775808 DIV -1; +ERROR 22003: BIGINT value is out of range in '(-(9223372036854775808) DIV -(1))' +SELECT -9223372036854775808 MOD -1; +-9223372036854775808 MOD -1 +0 +SELECT -9223372036854775808999 MOD -1; +-9223372036854775808999 MOD -1 +0 +select 123456789012345678901234567890.123456789012345678901234567890 div 1 as x; +ERROR 22003: BIGINT value is out of range in '(123456789012345678901234567890.123456789012345678901234567890 DIV 1)' +select "123456789012345678901234567890.123456789012345678901234567890" div 1 as x; +ERROR 22003: BIGINT value is out of range in '('123456789012345678901234567890.123456789012345678901234567890' DIV 1)' +SHOW WARNINGS; +Level Code Message +Warning 1292 Truncated incorrect DECIMAL value: '123456789012345678901234567890' +Error 1690 BIGINT value is out of range in '('123456789012345678901234567890.123456789012345678901234567890' DIV 1)' +# +# Bug#57810 case/when/then : Assertion failed: length || !scale +# +SELECT CASE(('')) WHEN (CONVERT(1, CHAR(1))) THEN (('' / 1)) END; +CASE(('')) WHEN (CONVERT(1, CHAR(1))) THEN (('' / 1)) END +NULL +CREATE TABLE t1 SELECT CAST((CASE(('')) WHEN (CONVERT(1, CHAR(1))) THEN (('' / 1)) END) AS CHAR) as C; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `C` varchar(22) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +DROP TABLE t1; +# +# Bug#11764994 57900: CREATE TABLE .. SELECT ASSERTS SCALE >= 0 && PRECISION > 0 && SCALE <= PR +# +CREATE TABLE t1 SELECT CEIL(ST_LINESTRINGFROMWKB(1) DIV NULL); +ERROR HY000: Incorrect arguments to DIV +CREATE TABLE t1 SELECT FLOOR(ST_LINESTRINGFROMWKB(1) DIV NULL); +ERROR HY000: Incorrect arguments to DIV +# +# Bug#11765923 58937: MANY VALGRIND ERRORS AFTER GROUPING BY RESULT OF DECIMAL COLUMN FUNCTION +# +CREATE TABLE t1(f1 DECIMAL(22,1)); +INSERT INTO t1 VALUES (0),(1); +SELECT ROUND(f1, f1) FROM t1; +ROUND(f1, f1) +0.0 +1.0 +SELECT ROUND(f1, f1) FROM t1 GROUP BY 1; +ROUND(f1, f1) +0.0 +1.0 +DROP TABLE t1; +# +# Bug#11764671 57533: UNINITIALISED VALUES IN COPY_AND_CONVERT (SQL_STRING.CC) WITH CERTAIN CHA +# +SELECT ROUND(LEAST(15, -4939092, 0.2704), STDDEV('a')); +ROUND(LEAST(15, -4939092, 0.2704), STDDEV('a')) +-4939092.0000 +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'a' +# +# Bug#12392636 ASSERTION FAILED: SCALE >= 0 && PRECISION > 0 && SCALE <= PRECISION +# +SELECT SUM(DISTINCT (TRUNCATE((.1), NULL))); +SUM(DISTINCT (TRUNCATE((.1), NULL))) +NULL +End of 5.1 tests +# +# Bug #8433: Overflow must be an error +# +SELECT 1e308 + 1e308; +ERROR 22003: DOUBLE value is out of range in '(1e308 + 1e308)' +SELECT -1e308 - 1e308; +ERROR 22003: DOUBLE value is out of range in '(-(1e308) - 1e308)' +SELECT 1e300 * 1e300; +ERROR 22003: DOUBLE value is out of range in '(1e300 * 1e300)' +SELECT 1e300 / 1e-300; +ERROR 22003: DOUBLE value is out of range in '(1e300 / 1e-300)' +SELECT EXP(750); +ERROR 22003: DOUBLE value is out of range in 'exp(750)' +SELECT POW(10, 309); +ERROR 22003: DOUBLE value is out of range in 'pow(10,309)' +SELECT COT(0); +ERROR 22003: DOUBLE value is out of range in 'cot(0)' +SELECT DEGREES(1e307); +ERROR 22003: DOUBLE value is out of range in 'degrees(1e307)' +SELECT 9223372036854775808 + 9223372036854775808; +ERROR 22003: BIGINT UNSIGNED value is out of range in '(9223372036854775808 + 9223372036854775808)' +SELECT 18446744073709551615 + 1; +ERROR 22003: BIGINT UNSIGNED value is out of range in '(18446744073709551615 + 1)' +SELECT 1 + 18446744073709551615; +ERROR 22003: BIGINT UNSIGNED value is out of range in '(1 + 18446744073709551615)' +SELECT -2 + CAST(1 AS UNSIGNED); +ERROR 22003: BIGINT UNSIGNED value is out of range in '(-(2) + cast(1 as unsigned))' +SELECT CAST(1 AS UNSIGNED) + -2; +ERROR 22003: BIGINT UNSIGNED value is out of range in '(cast(1 as unsigned) + -(2))' +SELECT -9223372036854775808 + -9223372036854775808; +ERROR 22003: BIGINT value is out of range in '(-(9223372036854775808) + -(9223372036854775808))' +SELECT 9223372036854775807 + 9223372036854775807; +ERROR 22003: BIGINT value is out of range in '(9223372036854775807 + 9223372036854775807)' +SELECT CAST(0 AS UNSIGNED) - 9223372036854775809; +ERROR 22003: BIGINT UNSIGNED value is out of range in '(cast(0 as unsigned) - 9223372036854775809)' +SELECT 9223372036854775808 - 9223372036854775809; +ERROR 22003: BIGINT UNSIGNED value is out of range in '(9223372036854775808 - 9223372036854775809)' +SELECT CAST(1 AS UNSIGNED) - 2; +ERROR 22003: BIGINT UNSIGNED value is out of range in '(cast(1 as unsigned) - 2)' +SELECT 18446744073709551615 - (-1); +ERROR 22003: BIGINT UNSIGNED value is out of range in '(18446744073709551615 - -(1))' +SELECT -1 - 9223372036854775808; +ERROR 22003: BIGINT UNSIGNED value is out of range in '(-(1) - 9223372036854775808)' +SELECT -1 - CAST(1 AS UNSIGNED); +ERROR 22003: BIGINT UNSIGNED value is out of range in '(-(1) - cast(1 as unsigned))' +SELECT -9223372036854775808 - 1; +ERROR 22003: BIGINT value is out of range in '(-(9223372036854775808) - 1)' +SELECT 9223372036854775807 - -9223372036854775808; +ERROR 22003: BIGINT value is out of range in '(9223372036854775807 - -(9223372036854775808))' +set SQL_MODE='NO_UNSIGNED_SUBTRACTION'; +SELECT 18446744073709551615 - 1; +ERROR 22003: BIGINT value is out of range in '(18446744073709551615 - 1)' +SELECT 18446744073709551615 - CAST(1 AS UNSIGNED); +ERROR 22003: BIGINT value is out of range in '(18446744073709551615 - cast(1 as unsigned))' +SELECT 18446744073709551614 - (-1); +ERROR 22003: BIGINT value is out of range in '(18446744073709551614 - -(1))' +SELECT 9223372036854775807 - -1; +ERROR 22003: BIGINT value is out of range in '(9223372036854775807 - -(1))' +set SQL_MODE=default; +SELECT 4294967296 * 4294967296; +ERROR 22003: BIGINT value is out of range in '(4294967296 * 4294967296)' +SELECT 9223372036854775808 * 2; +ERROR 22003: BIGINT UNSIGNED value is out of range in '(9223372036854775808 * 2)' +SELECT 9223372036854775808 * 2; +ERROR 22003: BIGINT UNSIGNED value is out of range in '(9223372036854775808 * 2)' +SELECT 7158278827 * 3221225472; +ERROR 22003: BIGINT value is out of range in '(7158278827 * 3221225472)' +SELECT 9223372036854775807 * (-2); +ERROR 22003: BIGINT value is out of range in '(9223372036854775807 * -(2))' +SELECT CAST(1 as UNSIGNED) * (-1); +ERROR 22003: BIGINT UNSIGNED value is out of range in '(cast(1 as unsigned) * -(1))' +SELECT 9223372036854775807 * 2; +ERROR 22003: BIGINT value is out of range in '(9223372036854775807 * 2)' +SELECT ABS(-9223372036854775808); +ERROR 22003: BIGINT value is out of range in 'abs(-(9223372036854775808))' +SELECT -9223372036854775808 DIV -1; +ERROR 22003: BIGINT value is out of range in '(-(9223372036854775808) DIV -(1))' +SELECT 18446744073709551615 DIV -1; +ERROR 22003: BIGINT UNSIGNED value is out of range in '(18446744073709551615 DIV -(1))' +CREATE TABLE t1(a BIGINT, b BIGINT UNSIGNED); +INSERT INTO t1 VALUES(-9223372036854775808, 9223372036854775809); +SELECT -a FROM t1; +ERROR 22003: BIGINT value is out of range in '-(`test`.`t1`.`a`)' +SELECT -b FROM t1; +ERROR 22003: BIGINT value is out of range in '-(`test`.`t1`.`b`)' +DROP TABLE t1; +SET @a:=999999999999999999999999999999999999999999999999999999999999999999999999999999999; +SELECT @a + @a; +ERROR 22003: DECIMAL value is out of range in '((@`a`) + (@`a`))' +SELECT @a * @a; +ERROR 22003: DECIMAL value is out of range in '((@`a`) * (@`a`))' +SELECT -@a - @a; +ERROR 22003: DECIMAL value is out of range in '(-((@`a`)) - (@`a`))' +SELECT @a / 0.5; +ERROR 22003: DECIMAL value is out of range in '((@`a`) / 0.5)' +SELECT COT(1/0); +COT(1/0) +NULL +Warnings: +Warning 1365 Division by 0 +SELECT -1 + 9223372036854775808; +-1 + 9223372036854775808 +9223372036854775807 +SELECT 2 DIV -2; +2 DIV -2 +-1 +SELECT -(1 DIV 0); +-(1 DIV 0) +NULL +Warnings: +Warning 1365 Division by 0 +Warning 1365 Division by 0 +SELECT -9223372036854775808 MOD -1; +-9223372036854775808 MOD -1 +0 +# +# Bug #57209 valgrind + Assertion failed: dst > buf +# +SELECT floor(log10(format(concat_ws(5445796E25, 5306463, 30837), -358821))) +as foo; +foo +2 +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: '53064635.445796e3130837' +Warning 1292 Truncated incorrect DOUBLE value: '179,769,313,486,231,570,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,' +# +# Bug #58137 char(0) column cause: +# my_gcvt: Assertion `width > 0 && to != ((void *)0)' failed +# +CREATE TABLE t1(a char(0)); +INSERT IGNORE INTO t1 (SELECT -pi()); +Warnings: +Warning 1265 Data truncated for column 'a' at row 1 +DROP TABLE t1; +# +# Bug #59241 invalid memory read +# in do_div_mod with doubly assigned variables +# +SELECT ((@a:=@b:=1.0) div (@b:=@a:=get_format(datetime, 'usa'))); +((@a:=@b:=1.0) div (@b:=@a:=get_format(datetime, 'usa'))) +NULL +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +Warning 1366 Incorrect DECIMAL value: '0' for column '' at row -1 +Warning 1365 Division by 0 +# +# Bug #59498 div function broken in mysql-trunk +# +SELECT 1 div null; +1 div null +NULL +# +# Bug #11792200 - DIVIDING LARGE NUMBERS CAUSES STACK CORRUPTIONS +# +select (1.175494351E-37 div 1.7976931348623157E+308); +(1.175494351E-37 div 1.7976931348623157E+308) +0 +Warnings: +Warning 1292 Truncated incorrect DECIMAL value: '1.7976931348623157' +# +# Bug#12744991 - DECIMAL_ROUND(X,D) GIVES WRONG RESULTS WHEN D == N*(-9) +# +select round(999999999, -9); +round(999999999, -9) +1000000000 +select round(999999999.0, -9); +round(999999999.0, -9) +1000000000 +select round(999999999999999999, -18); +round(999999999999999999, -18) +1000000000000000000 +select round(999999999999999999.0, -18); +round(999999999999999999.0, -18) +1000000000000000000 +# +# Bug#12537160 ASSERTION FAILED: +# STOP0 <= &TO->BUF[TO->LEN] WITH LARGE NUMBER. +# +select 999999999999999999999999999999999999999999999999999999999999999999999999999999999 % 0.1 as foo; +foo +0.0 +select 999999999999999999999999999999999999999999999999999999999999999999999999999999999 % 0.0 as foo; +foo +NULL +Warnings: +Warning 1365 Division by 0 +# +# Bug#12711164 - 61676: +# RESULT OF DIV WITH DECIMAL AND INTEGER DOES NOT MAKE SENSE +# +select 5 div 2; +5 div 2 +2 +select 5.0 div 2.0; +5.0 div 2.0 +2 +select 5.0 div 2; +5.0 div 2 +2 +select 5 div 2.0; +5 div 2.0 +2 +select 5.9 div 2, 1.23456789e3 DIV 2, 1.23456789e9 DIV 2, 1.23456789e19 DIV 2; +5.9 div 2 1.23456789e3 DIV 2 1.23456789e9 DIV 2 1.23456789e19 DIV 2 +2 617 617283945 6172839450000000000 +# +# Bug#11758319 BEHAVIOR OF LOGARITHMIC FUNCTIONS DEPENDS ON +# ERROR_FOR_DIVISION_BY_ZERO +# Bug#50507 Behavior of logarithmic functions depends on +# ERROR_FOR_DIVISION_BY_ZERO +CREATE TABLE t1(a DOUBLE); +SET sql_mode=''; +INSERT INTO t1 VALUES (ln(1)); +INSERT INTO t1 VALUES (ln(0)); +Warnings: +Warning 3020 Invalid argument for logarithm +INSERT INTO t1 VALUES (ln(-1)); +Warnings: +Warning 3020 Invalid argument for logarithm +INSERT INTO t1 VALUES (log(0)); +Warnings: +Warning 3020 Invalid argument for logarithm +INSERT INTO t1 VALUES (log(1,0)); +Warnings: +Warning 3020 Invalid argument for logarithm +INSERT INTO t1 VALUES (log2(0)); +Warnings: +Warning 3020 Invalid argument for logarithm +INSERT INTO t1 VALUES (log10(0)); +Warnings: +Warning 3020 Invalid argument for logarithm +SELECT * FROM t1 ORDER BY a; +a +NULL +NULL +NULL +NULL +NULL +NULL +0 +SET sql_mode=default; +INSERT INTO t1 VALUES (ln(1)); +INSERT INTO t1 VALUES (ln(0)); +ERROR 2201E: Invalid argument for logarithm +INSERT INTO t1 VALUES (ln(-1)); +ERROR 2201E: Invalid argument for logarithm +INSERT INTO t1 VALUES (log(0)); +ERROR 2201E: Invalid argument for logarithm +INSERT INTO t1 VALUES (log(1,0)); +ERROR 2201E: Invalid argument for logarithm +INSERT INTO t1 VALUES (log2(0)); +ERROR 2201E: Invalid argument for logarithm +INSERT INTO t1 VALUES (log10(0)); +ERROR 2201E: Invalid argument for logarithm +SELECT * FROM t1 ORDER BY a; +a +NULL +NULL +NULL +NULL +NULL +NULL +0 +0 +UPDATE t1 SET a = ln(0); +ERROR 2201E: Invalid argument for logarithm +SELECT * FROM t1 ORDER BY a; +a +NULL +NULL +NULL +NULL +NULL +NULL +0 +0 +SET sql_mode=''; +UPDATE t1 SET a = ln(0); +Warnings: +Warning 3020 Invalid argument for logarithm +Warning 3020 Invalid argument for logarithm +Warning 3020 Invalid argument for logarithm +Warning 3020 Invalid argument for logarithm +Warning 3020 Invalid argument for logarithm +Warning 3020 Invalid argument for logarithm +Warning 3020 Invalid argument for logarithm +Warning 3020 Invalid argument for logarithm +SELECT * FROM t1 ORDER BY a; +a +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +SET sql_mode=default; +DELETE FROM t1 WHERE a <=> ln(0); +ERROR 2201E: Invalid argument for logarithm +SELECT * FROM t1 ORDER BY a; +a +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +SET sql_mode=''; +DELETE FROM t1 WHERE a <=> ln(0); +Warnings: +Warning 3020 Invalid argument for logarithm +Warning 3020 Invalid argument for logarithm +Warning 3020 Invalid argument for logarithm +Warning 3020 Invalid argument for logarithm +Warning 3020 Invalid argument for logarithm +Warning 3020 Invalid argument for logarithm +Warning 3020 Invalid argument for logarithm +Warning 3020 Invalid argument for logarithm +SELECT * FROM t1 ORDER BY a; +a +DROP TABLE t1; +SET sql_mode=default; +# +# Bug#19047527 SQRT() : UNINITIALISED VALUE IN MY_STRTOD +# +do sqrt(weight_string(_eucjpms "0E+")); +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: '0E+' +# +# Bug#21279005 - ROUND FUNCTION INCORRECT IN WHERE-CLAUSE +# USING LOCAL VARIABLE +CREATE PROCEDURE test_round_fn() +BEGIN +DECLARE num_digits int; +SET num_digits := 3; +CREATE TEMPORARY TABLE tmp_test ( +number double +); +INSERT INTO tmp_test +VALUES (1),(0); +SELECT +number, +Round(number, num_digits) > 0, +Round(number, 3) > 0 +FROM +tmp_test; +SELECT +number, +Round(number, num_digits) > 0, +Round(number, 3) > 0 +FROM +tmp_test +WHERE +Round(number, 3) >= 0; +SELECT +number, +Round(number, num_digits) > 0, +Round(number, 3) > 0 +FROM +tmp_test +WHERE +Round(number, num_digits) >= 0; +END| +CALL test_round_fn(); +number Round(number, num_digits) > 0 Round(number, 3) > 0 +1 1 1 +0 0 0 +number Round(number, num_digits) > 0 Round(number, 3) > 0 +1 1 1 +0 0 0 +number Round(number, num_digits) > 0 Round(number, 3) > 0 +1 1 1 +0 0 0 +DROP PROCEDURE test_round_fn; +# +# Bug#23013359 FUNCTION FLOOR(CEIL()) TRUNCATES BIGINT UNSIGNED +# +SELECT floor(ceil(12345678901234567890)); +floor(ceil(12345678901234567890)) +12345678901234567890 +SELECT floor(18446744073709551616); +floor(18446744073709551616) +18446744073709551616 +SELECT floor(floor(18446744073709551616)); +floor(floor(18446744073709551616)) +18446744073709551616 +SELECT floor(floor(floor(18446744073709551616))); +floor(floor(floor(18446744073709551616))) +18446744073709551616 +# Bug#25669580: regression: assertion failed: 0 in Item_num_func1::str_op +DO ROUND(0xe9b1, NULL); +# Bug#25688504: regression: scale >= 0 && precision >= 0 && ... +DO COUNT(DISTINCT ROUND(CAST(SLEEP(0) AS DECIMAL), NULL)); +# +# Bug#26495791 - EXPAND TEST SUITE TO INCLUDE CRC32 TESTS +# +SELECT CRC32(NULL), CRC32(''), CRC32('MySQL'), CRC32('mysql'); +CRC32(NULL) CRC32('') CRC32('MySQL') CRC32('mysql') +NULL 0 3259397556 2501908538 +SELECT CRC32('01234567'), CRC32('012345678'); +CRC32('01234567') CRC32('012345678') +763378421 939184570 +SELECT CRC32('~!@$%^*'), CRC32('-0.0001'); +CRC32('~!@$%^*') CRC32('-0.0001') +1533935548 324352530 +SELECT CRC32(99999999999999999999999999999999); +CRC32(99999999999999999999999999999999) +3035957051 +SELECT CRC32(-99999999999999999999999999999999); +CRC32(-99999999999999999999999999999999) +1052326872 +DROP TABLE IF EXISTS t; +Warnings: +Note 1051 Unknown table 'test.t' +CREATE TABLE t(a INT, b VARCHAR(2)); +INSERT INTO t VALUES (1,'a'), (2,'qw'), (1,'t'), (3,'t'); +SELECT crc32(SUM(a)) FROM t; +crc32(SUM(a)) +1790921346 +SELECT crc32(AVG(a)) FROM t GROUP BY b; +crc32(AVG(a)) +768278432 +2875100430 +2875100430 +SELECT crc32(MAX(b)) FROM t GROUP BY a; +crc32(MAX(b)) +2238339752 +3114057431 +2238339752 +SELECT a, b, crc32(a) FROM t GROUP BY a,b HAVING crc32(MAX(a))=450215437; +a b crc32(a) +2 qw 450215437 +SELECT a,b,concat(a,b),crc32(concat(a,b)) FROM t ORDER BY crc32(concat(a,b)); +a b concat(a,b) crc32(concat(a,b)) +2 qw 2qw 552289476 +1 a 1a 3174122627 +1 t 1t 3505168488 +3 t 3t 3805987562 +DROP TABLE t; +SELECT CRC32(4+2); +CRC32(4+2) +498629140 +SELECT CRC32(4/2); +CRC32(4/2) +2875100430 +SELECT CRC32(4-2); +CRC32(4-2) +450215437 +SELECT CRC32(4*2); +CRC32(4*2) +4194326291 +SELECT CRC32(ABS(-6)); +CRC32(ABS(-6)) +498629140 +SELECT CRC32(CEILING(1.23)); +CRC32(CEILING(1.23)) +450215437 +SELECT CRC32(FLOOR(1.23)); +CRC32(FLOOR(1.23)) +2212294583 +SELECT CRC32(LOG(10,100)); +CRC32(LOG(10,100)) +450215437 +SELECT CRC32(PI()); +CRC32(PI()) +2969982827 +SELECT CRC32(POWER(2,2)); +CRC32(POWER(2,2)) +4088798008 +SELECT CRC32(ROUND(1.58)); +CRC32(ROUND(1.58)) +450215437 +SELECT CRC32(SIGN(0)); +CRC32(SIGN(0)) +4108050209 +SELECT CRC32(SQRT(4)); +CRC32(SQRT(4)) +450215437 +SELECT CRC32(2 > 4); +CRC32(2 > 4) +4108050209 +SELECT CRC32(2 < 4); +CRC32(2 < 4) +2212294583 +SELECT CRC32(2 >= 4); +CRC32(2 >= 4) +4108050209 +SELECT CRC32(2 <= 4); +CRC32(2 <= 4) +2212294583 +SELECT CRC32(2 != 4); +CRC32(2 != 4) +2212294583 +SELECT CRC32(NOT 1); +CRC32(NOT 1) +4108050209 +SELECT CRC32(1 AND 1); +CRC32(1 AND 1) +2212294583 +SELECT CRC32(1 OR 1); +CRC32(1 OR 1) +2212294583 +SELECT CRC32(1 XOR 1); +CRC32(1 XOR 1) +4108050209 +SELECT CRC32(ASCII('2')); +CRC32(ASCII('2')) +3308380389 +SELECT CRC32(BIT_LENGTH('text')); +CRC32(BIT_LENGTH('text')) +2103780943 +SELECT CRC32(CHAR('77','121','83','81','76')); +CRC32(CHAR('77','121','83','81','76')) +3259397556 +SELECT CRC32(CONCAT('good','year')); +CRC32(CONCAT('good','year')) +3441724142 +SELECT CRC32(INSERT('foodyear', 1, 4, 'good')); +CRC32(INSERT('foodyear', 1, 4, 'good')) +3441724142 +SELECT CRC32(LEFT('goodyear', 4)); +CRC32(LEFT('goodyear', 4)) +1820610194 +SELECT CRC32(LENGTH('text')); +CRC32(LENGTH('text')) +4088798008 +SELECT CRC32(LOWER('GOODYEAR')); +CRC32(LOWER('GOODYEAR')) +3441724142 +SELECT CRC32(UPPER('goodyear')); +CRC32(UPPER('goodyear')) +186062498 +SELECT CRC32(LTRIM(' goodyear')); +CRC32(LTRIM(' goodyear')) +3441724142 +SELECT CRC32(RTRIM('goodyear ')); +CRC32(RTRIM('goodyear ')) +3441724142 +SELECT CRC32(REPLACE('godyear','o','oo')); +CRC32(REPLACE('godyear','o','oo')) +3441724142 +SELECT CRC32(REVERSE('goodyear')); +CRC32(REVERSE('goodyear')) +3423698264 +SELECT CRC32(true); +CRC32(true) +2212294583 +SELECT CRC32(false); +CRC32(false) +4108050209 +DROP TABLE IF EXISTS t1; +Warnings: +Note 1051 Unknown table 'test.t1' +CREATE TABLE t1 (c1 BIT(5), +c2 TINYINT, +c3 MEDIUMINT, +c4 INTEGER, +c5 BIGINT, +c6 DECIMAL(7,5), +c7 FLOAT(7,5), +c8 DOUBLE(7,5)); +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (B'10101', 127, 8388607, 2147483647, +9223372036854775807, 10.5, 11.5, 12.5); +SELECT CRC32(c1) FROM t1; +CRC32(c1) +3219065702 +SELECT CRC32(c2) FROM t1; +CRC32(c2) +2401609675 +SELECT CRC32(c3) FROM t1; +CRC32(c3) +1742563487 +SELECT CRC32(c4) FROM t1; +CRC32(c4) +365954768 +SELECT CRC32(c5) FROM t1; +CRC32(c5) +1122634462 +SELECT CRC32(c6) FROM t1; +CRC32(c6) +4255015174 +SELECT CRC32(c7) FROM t1; +CRC32(c7) +1542023858 +SELECT CRC32(c8) FROM t1; +CRC32(c8) +1778479151 +DROP TABLE IF EXISTS t1; +CREATE TABLE t1 (c1 DATE, +c2 DATETIME, +c3 TIMESTAMP, +c4 TIME, +c5 YEAR); +INSERT INTO t1 VALUES ('2007-01-01', '2007-01-01 12:00:01', +'2007-01-01 00:00:01.000000', +'12:00:01.000000', '2007'); +SELECT CRC32(c1) FROM t1; +CRC32(c1) +2772295888 +SELECT CRC32(c2) FROM t1; +CRC32(c2) +1449026401 +SELECT CRC32(c3) FROM t1; +CRC32(c3) +225145558 +SELECT CRC32(c4) FROM t1; +CRC32(c4) +1077283474 +SELECT CRC32(c5) FROM t1; +CRC32(c5) +955685210 +DROP TABLE IF EXISTS t1; +CREATE TABLE t1 (c1 CHAR, +c2 VARCHAR(10), +c3 BINARY(1), +c4 VARBINARY(10), +c5 TINYBLOB, +c6 TINYTEXT, +c7 BLOB, +c8 TEXT, +c9 MEDIUMBLOB, +c10 MEDIUMTEXT, +c11 LONGBLOB, +c12 LONGTEXT); +INSERT INTO t1 VALUES ('a', 'a', 0x61, 0x61, 'a', 'a', +'a', 'a', 'a', 'a', 'a', 'a'); +SELECT CRC32(c1) FROM t1; +CRC32(c1) +3904355907 +SELECT CRC32(c2) FROM t1; +CRC32(c2) +3904355907 +SELECT CRC32(c3) FROM t1; +CRC32(c3) +3904355907 +SELECT CRC32(c4) FROM t1; +CRC32(c4) +3904355907 +SELECT CRC32(c5) FROM t1; +CRC32(c5) +3904355907 +SELECT CRC32(c6) FROM t1; +CRC32(c6) +3904355907 +SELECT CRC32(c7) FROM t1; +CRC32(c7) +3904355907 +SELECT CRC32(c8) FROM t1; +CRC32(c8) +3904355907 +SELECT CRC32(c9) FROM t1; +CRC32(c9) +3904355907 +SELECT CRC32(c10) FROM t1; +CRC32(c10) +3904355907 +SELECT CRC32(c11) FROM t1; +CRC32(c11) +3904355907 +SELECT CRC32(c12) FROM t1; +CRC32(c12) +3904355907 +SELECT CRC32(ST_GeomFromText('POINT(1 1)')); +CRC32(ST_GeomFromText('POINT(1 1)')) +1349318989 +CREATE TABLE geom_data(id INT, +pt POINT NOT NULL, +lnstr LINESTRING NOT NULL, +mlnstr MULTILINESTRING NOT NULL, +poly POLYGON NOT NULL, +mpoly MULTIPOLYGON NOT NULL); +INSERT INTO geom_data VALUES (10, +ST_GEOMFROMTEXT('POINT(10 20)'), +ST_GEOMFROMTEXT('LINESTRING(0 0,5 5,6 6)'), +ST_GEOMFROMTEXT('MULTILINESTRING((0 0,2 3,4 5),(6 6,8 8,9 9,10 10))'), +ST_GEOMFROMTEXT('POLYGON((0 0,6 7,8 8,3 9,0 0),(3 6,4 6,4 7,3 6))'), +ST_GEOMFROMTEXT('MULTIPOLYGON(((0 0,0 5,5 5,5 0,0 0)), + ((2 2,4 5,6 2,2 2)))')); +SELECT CRC32(ST_X(pt)) FROM geom_data; +CRC32(ST_X(pt)) +2707236321 +SELECT CRC32(ST_NumPoints((lnstr))) FROM geom_data; +CRC32(ST_NumPoints((lnstr))) +1842515611 +SELECT CRC32(ST_Length((mlnstr))) FROM geom_data; +CRC32(ST_Length((mlnstr))) +2090153432 +SELECT CRC32(ST_Area((poly))) FROM geom_data; +CRC32(ST_Area((poly))) +534598600 +SELECT CRC32(ST_Area((mpoly))) FROM geom_data; +CRC32(ST_Area((mpoly))) +3832313845 +DROP TABLE geom_data; +DROP TABLE IF EXISTS t1; +CREATE TABLE t1 (e1 ENUM ('a','b'), s1 SET('a','b')); +INSERT INTO t1 VALUES(2,'a,b'),('a','b,a'); +SELECT e1, CRC32(e1) FROM t1; +e1 CRC32(e1) +b 1908338681 +a 3904355907 +SELECT s1, CRC32(s1) FROM t1; +s1 CRC32(s1) +a,b 752423903 +a,b 752423903 +DROP TABLE IF EXISTS t1; +CREATE TABLE t1 (a JSON); +INSERT INTO t1 VALUES ('{"name" : "goodyear"}'), +('{"name" : "verygood-year"}'); +SELECT a->>'$.name', CRC32(a) FROM t1; +a->>'$.name' CRC32(a) +goodyear 3664432072 +verygood-year 922278888 +SELECT CRC32(a->>'$.name') FROM t1 WHERE a->>'$.name' = 'goodyear'; +CRC32(a->>'$.name') +3441724142 +SELECT CRC32(REPLACE(JSON_EXTRACT(a, "$.name"),'\"','')) +FROM t1 WHERE JSON_EXTRACT(a, "$.name") = 'goodyear'; +CRC32(REPLACE(JSON_EXTRACT(a, "$.name"),'\"','')) +3441724142 +DROP TABLE t1; +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES(10); +CREATE VIEW v1 AS SELECT CRC32(a) AS my_crc FROM t1; +SELECT * FROM v1; +my_crc +2707236321 +SELECT CRC32(CRC32(my_crc)) FROM v1; +CRC32(CRC32(my_crc)) +3114155452 +DROP VIEW v1; +DROP TABLE t1; +CREATE TABLE t1 (a CHAR); +CREATE TABLE t2 (b BIGINT); +CREATE TRIGGER trg1 +BEFORE INSERT ON t1 +FOR EACH ROW +INSERT INTO t2 VALUES(CRC32(NEW.a)); +INSERT INTO t1 VALUES('a'); +SELECT * FROM t2; +b +3904355907 +DROP TRIGGER trg1; +DROP TABLE t2; +DROP TABLE t1; +CREATE PROCEDURE crc32_proc (IN a CHAR, OUT b BIGINT) +SELECT CRC32(a) INTO b; +CALL crc32_proc('a',@val); +SELECT @val; +@val +3904355907 +DROP PROCEDURE crc32_proc; +CREATE FUNCTION crc32_func(inputvar CHAR) +RETURNS BIGINT +BEGIN +DECLARE crcval BIGINT; +SELECT CRC32(inputvar) INTO crcval; +RETURN crcval; +END| +SELECT crc32_func('a'); +crc32_func('a') +3904355907 +DROP FUNCTION crc32_func; +PREPARE stmt1 FROM 'SELECT CRC32(?)'; +SET @val = 'a'; +EXECUTE stmt1 USING @val; +CRC32(?) +3904355907 +DEALLOCATE PREPARE stmt; +SET NAMES utf8; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +CREATE TABLE t1 (a TEXT) CHARACTER SET = utf8; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +LOAD DATA INFILE '../../std_data/loaddata_utf8.dat' INTO TABLE t1 CHARACTER SET utf8; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +SELECT HEX(a), CRC32(a) from t1; +HEX(a) CRC32(a) +E4B880E4BA8CE4B889 1785250883 +E59B9BE4BA94E585AD 2914501801 +E4B883E585ABE4B99D 2374586519 +E4B880E4BA8CE4B889 1785250883 +E59B9BE4BA94E585AD 2914501801 +E4B883E585ABE4B99D0A 1546750244 +DROP TABLE t1; +SET NAMES default; +# +# Bug#27134168 UBSAN: MY_DOUBLE_ROUND - NEGATION OF BLAH +# +SELECT truncate( +0x123, +-9223372036854775808 +); +truncate( +0x123, +-9223372036854775808 +) +0 +# +# Bug#28401869 ARM BUILD ALLOWS NUMERIC VALUES OUT OF BOUNDS +# +select cast(pow(2,63) as signed) as pp; +ERROR 22003: BIGINT value is out of range in 'pow(2,63)' +select cast(pow(2,63)-1024 as signed) as pp; +pp +9223372036854774784 +select cast(1-pow(2,63) as signed) as qq; +qq +-9223372036854775808 +# +# Bug#17081376 ITEM_FUNC_MUL::INT_OP() MISHANDLES 9223372036854775809*-1 +# +SELECT 9223372036854775809 * -1; +ERROR 22003: BIGINT UNSIGNED value is out of range in '(9223372036854775809 * -(1))' +SELECT -1 * 9223372036854775809; +ERROR 22003: BIGINT UNSIGNED value is out of range in '(-(1) * 9223372036854775809)' +# +# Bug#28505423 UBSAN: SIGNED INTEGER OVERFLOW IN MY_STRNTOULL10RND_8BIT +# +CREATE TABLE t(a int); +INSERT INTO t VALUES(hex(rtrim(1.040739e+308))); +ERROR 22003: Out of range value for column 'a' at row 1 +DROP TABLE t; +# +# Bug#28706832 WINDOWS ALLOWS NUMERIC VALUES OUT OF BOUNDS +# +SELECT 1-CAST(POW(2,100) AS SIGNED); +ERROR 22003: BIGINT value is out of range in 'pow(2,100)' +SELECT 1-CAST(POW(2,1000) AS SIGNED); +ERROR 22003: BIGINT value is out of range in 'pow(2,1000)' +# +# Bug#29581610 UBSAN ERROR IN ITEM_FUNC_MUL::INT_OP() +# +do ((3273059463432352943 )* (-9223372036854775808 )) ; +ERROR 22003: BIGINT value is out of range in '(3273059463432352943 * -(9223372036854775808))' +do ((-9223372036854775808)* ( 3273059463432352943)) ; +ERROR 22003: BIGINT value is out of range in '(-(9223372036854775808) * 3273059463432352943)' +select -9223372036854775808 * 0 as result; +result +0 +select 0 * -9223372036854775808 as result; +result +0 +select -9223372036854775808 * 1 as result; +result +-9223372036854775808 +select 1 * -9223372036854775808 as result; +result +-9223372036854775808 +select -9223372036854775808 * -1 as result; +ERROR 22003: BIGINT value is out of range in '(-(9223372036854775808) * -(1))' +select -1 * -9223372036854775808 as result; +ERROR 22003: BIGINT value is out of range in '(-(1) * -(9223372036854775808))' +select -9223372036854775808 * 2 as result; +ERROR 22003: BIGINT value is out of range in '(-(9223372036854775808) * 2)' +select 2 * -9223372036854775808 as result; +ERROR 22003: BIGINT value is out of range in '(2 * -(9223372036854775808))' +# +# Bug#30139913 CEILING AND FLOOR HAVE INCORRECT RESOLVED TYPES FOR BIGINT +# ARGUMENTS +# +CREATE TABLE t1(a BIGINT UNSIGNED); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` bigint unsigned DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +INSERT INTO t1 VALUES(18446744073709551615); +CREATE TABLE t2 AS +SELECT CEILING(a) AS c, FLOOR(a) AS f FROM t1; +DESCRIBE t2; +Field Type Null Key Default Extra +c bigint unsigned YES NULL +f bigint unsigned YES NULL +SELECT * FROM t2; +c f +18446744073709551615 18446744073709551615 +DROP TABLE t1, t2; +# BIGINT should resolve to BIGINT. +CREATE TABLE t AS +SELECT CEILING(18446744073709551615) AS c, +FLOOR(18446744073709551615) AS f; +DESCRIBE t; +Field Type Null Key Default Extra +c bigint unsigned NO 0 +f bigint unsigned NO 0 +DROP TABLE t; +# DECIMAL should resolve to DECIMAL when too big for BIGINT. +CREATE TABLE t AS +SELECT CEILING(18446744073709551616) AS c, +FLOOR(18446744073709551616) AS f; +DESCRIBE t; +Field Type Null Key Default Extra +c decimal(20,0) NO 0 +f decimal(20,0) NO 0 +DROP TABLE t; +# CEILING/FLOOR has to always assume a signed DECIMAL, making this too +# big for BIGINT. +CREATE TABLE t AS +SELECT CEILING(CAST(1844674407370955161 AS DECIMAL(19, 0))) AS c, +FLOOR(CAST(1844674407370955161 AS DECIMAL(19, 0))) AS f; +DESCRIBE t; +Field Type Null Key Default Extra +c decimal(19,0) NO 0 +f decimal(19,0) NO 0 +SELECT * FROM t; +c f +1844674407370955161 1844674407370955161 +DROP TABLE t; +CREATE TABLE t AS +SELECT CEILING(CAST(-9223372036854775808 AS DECIMAL(19, 0))) AS c, +FLOOR(CAST(-9223372036854775808 AS DECIMAL(19, 0))) AS f; +DESCRIBE t; +Field Type Null Key Default Extra +c decimal(19,0) NO 0 +f decimal(19,0) NO 0 +SELECT * FROM t; +c f +-9223372036854775808 -9223372036854775808 +DROP TABLE t; +# DECIMAL should resolve to BIGINT when it fits. +CREATE TABLE t AS +SELECT CEILING(CAST(184467440737095516 AS DECIMAL(18, 0))) AS c, +FLOOR(CAST(184467440737095516 AS DECIMAL(18, 0))) AS f; +DESCRIBE t; +Field Type Null Key Default Extra +c bigint NO 0 +f bigint NO 0 +SELECT * FROM t; +c f +184467440737095516 184467440737095516 +DROP TABLE t; +CREATE TABLE t AS +SELECT CEILING(CAST(-922337203685477580 AS DECIMAL(18, 0))) AS c, +FLOOR(CAST(-922337203685477580 AS DECIMAL(18, 0))) AS f; +DESCRIBE t; +Field Type Null Key Default Extra +c bigint NO 0 +f bigint NO 0 +SELECT * FROM t; +c f +-922337203685477580 -922337203685477580 +DROP TABLE t; +# Account for possible increase of order of magnitude when rounding. +CREATE TABLE t AS +SELECT CEILING(CAST(99999999999999999.9 AS DECIMAL(18, 1))) AS c, +FLOOR(CAST(-99999999999999999.9 AS DECIMAL(18, 1))) AS f; +DESCRIBE t; +Field Type Null Key Default Extra +c bigint NO 0 +f bigint NO 0 +SELECT * FROM t; +c f +100000000000000000 -100000000000000000 +DROP TABLE t; +CREATE TABLE t AS +SELECT CEILING(CAST(999999999999999999.9 AS DECIMAL(19, 1))) AS c, +FLOOR(CAST(-999999999999999999.9 AS DECIMAL(19, 1))) AS f; +DESCRIBE t; +Field Type Null Key Default Extra +c decimal(19,0) NO 0 +f decimal(19,0) NO 0 +SELECT * FROM t; +c f +1000000000000000000 -1000000000000000000 +DROP TABLE t; +# +# Bug #29952066 CAST OF NEGATIVE FUNCTION RETURN VALUE TO +# UNSIGNED MALFUNCTIONS WITH BIGINT +# +CREATE TABLE t0(c0 BIGINT UNSIGNED); +INSERT INTO t0(c0) VALUES(NULL); +SELECT * FROM t0 WHERE CAST(COALESCE(t0.c0, -1) AS UNSIGNED); +c0 +NULL +SELECT * FROM t0 WHERE CAST(IFNULL(t0.c0, -1) AS UNSIGNED); +c0 +NULL +SELECT CAST(COALESCE(t0.c0, -1) AS UNSIGNED) IS TRUE FROM t0; +CAST(COALESCE(t0.c0, -1) AS UNSIGNED) IS TRUE +1 +SELECT CAST(COALESCE(t0.c0, -1) AS UNSIGNED) FROM t0; +CAST(COALESCE(t0.c0, -1) AS UNSIGNED) +18446744073709551615 +DROP TABLE t0; +SELECT CAST(-1.1 AS UNSIGNED); +CAST(-1.1 AS UNSIGNED) +18446744073709551615 +# +# +# Bug #30680384 UBSAN: RUNTIME ERROR: NEGATION +# OF -9223372036854775808 IN ITEM_FUNC_ROUND::INT_OP() +# +select (round(-9223372036854775808, -4)); +ERROR 22003: BIGINT value is out of range in 'round(-(9223372036854775808),-(4))' +CREATE PROCEDURE test_round(in arg bigint) +BEGIN +DECLARE i int; +SET i = 0; +WHILE (i >= -20) DO +BEGIN +# Ignore SQLSTATE 22003 numeric value out of range +DECLARE CONTINUE HANDLER FOR SQLSTATE '22003' SHOW ERRORS; +SELECT arg, i, round(arg, i); +END; +SET i = i - 1; +END WHILE; +END// +CREATE PROCEDURE test_round_unsigned(in arg bigint unsigned) +BEGIN +DECLARE i int; +SET i = 0; +WHILE (i >= -20) DO +BEGIN +# Ignore SQLSTATE 22003 numeric value out of range +DECLARE CONTINUE HANDLER FOR SQLSTATE '22003' SHOW ERRORS; +SELECT arg, i, round(arg, i); +END; +SET i = i - 1; +END WHILE; +END// +CALL test_round(-123456); +arg i round(arg, i) +-123456 0 -123456 +arg i round(arg, i) +-123456 -1 -123460 +arg i round(arg, i) +-123456 -2 -123500 +arg i round(arg, i) +-123456 -3 -123000 +arg i round(arg, i) +-123456 -4 -120000 +arg i round(arg, i) +-123456 -5 -100000 +arg i round(arg, i) +-123456 -6 0 +arg i round(arg, i) +-123456 -7 0 +arg i round(arg, i) +-123456 -8 0 +arg i round(arg, i) +-123456 -9 0 +arg i round(arg, i) +-123456 -10 0 +arg i round(arg, i) +-123456 -11 0 +arg i round(arg, i) +-123456 -12 0 +arg i round(arg, i) +-123456 -13 0 +arg i round(arg, i) +-123456 -14 0 +arg i round(arg, i) +-123456 -15 0 +arg i round(arg, i) +-123456 -16 0 +arg i round(arg, i) +-123456 -17 0 +arg i round(arg, i) +-123456 -18 0 +arg i round(arg, i) +-123456 -19 0 +arg i round(arg, i) +-123456 -20 0 +CALL test_round(-9223372036854775807); +arg i round(arg, i) +-9223372036854775807 0 -9223372036854775807 +arg i round(arg, i) +Level Code Message +Error 1690 BIGINT value is out of range in 'round(arg@0,i@1)' +arg i round(arg, i) +-9223372036854775807 -2 -9223372036854775800 +arg i round(arg, i) +Level Code Message +Error 1690 BIGINT value is out of range in 'round(arg@0,i@1)' +arg i round(arg, i) +Level Code Message +Error 1690 BIGINT value is out of range in 'round(arg@0,i@1)' +arg i round(arg, i) +Level Code Message +Error 1690 BIGINT value is out of range in 'round(arg@0,i@1)' +arg i round(arg, i) +Level Code Message +Error 1690 BIGINT value is out of range in 'round(arg@0,i@1)' +arg i round(arg, i) +-9223372036854775807 -7 -9223372036850000000 +arg i round(arg, i) +Level Code Message +Error 1690 BIGINT value is out of range in 'round(arg@0,i@1)' +arg i round(arg, i) +Level Code Message +Error 1690 BIGINT value is out of range in 'round(arg@0,i@1)' +arg i round(arg, i) +Level Code Message +Error 1690 BIGINT value is out of range in 'round(arg@0,i@1)' +arg i round(arg, i) +-9223372036854775807 -11 -9223372000000000000 +arg i round(arg, i) +-9223372036854775807 -12 -9223372000000000000 +arg i round(arg, i) +-9223372036854775807 -13 -9223370000000000000 +arg i round(arg, i) +Level Code Message +Error 1690 BIGINT value is out of range in 'round(arg@0,i@1)' +arg i round(arg, i) +-9223372036854775807 -15 -9223000000000000000 +arg i round(arg, i) +-9223372036854775807 -16 -9220000000000000000 +arg i round(arg, i) +-9223372036854775807 -17 -9200000000000000000 +arg i round(arg, i) +-9223372036854775807 -18 -9000000000000000000 +arg i round(arg, i) +Level Code Message +Error 1690 BIGINT value is out of range in 'round(arg@0,i@1)' +arg i round(arg, i) +-9223372036854775807 -20 0 +CALL test_round(-9223372036854775808); +arg i round(arg, i) +-9223372036854775808 0 -9223372036854775808 +arg i round(arg, i) +Level Code Message +Error 1690 BIGINT value is out of range in 'round(arg@0,i@1)' +arg i round(arg, i) +-9223372036854775808 -2 -9223372036854775800 +arg i round(arg, i) +Level Code Message +Error 1690 BIGINT value is out of range in 'round(arg@0,i@1)' +arg i round(arg, i) +Level Code Message +Error 1690 BIGINT value is out of range in 'round(arg@0,i@1)' +arg i round(arg, i) +Level Code Message +Error 1690 BIGINT value is out of range in 'round(arg@0,i@1)' +arg i round(arg, i) +Level Code Message +Error 1690 BIGINT value is out of range in 'round(arg@0,i@1)' +arg i round(arg, i) +-9223372036854775808 -7 -9223372036850000000 +arg i round(arg, i) +Level Code Message +Error 1690 BIGINT value is out of range in 'round(arg@0,i@1)' +arg i round(arg, i) +Level Code Message +Error 1690 BIGINT value is out of range in 'round(arg@0,i@1)' +arg i round(arg, i) +Level Code Message +Error 1690 BIGINT value is out of range in 'round(arg@0,i@1)' +arg i round(arg, i) +-9223372036854775808 -11 -9223372000000000000 +arg i round(arg, i) +-9223372036854775808 -12 -9223372000000000000 +arg i round(arg, i) +-9223372036854775808 -13 -9223370000000000000 +arg i round(arg, i) +Level Code Message +Error 1690 BIGINT value is out of range in 'round(arg@0,i@1)' +arg i round(arg, i) +-9223372036854775808 -15 -9223000000000000000 +arg i round(arg, i) +-9223372036854775808 -16 -9220000000000000000 +arg i round(arg, i) +-9223372036854775808 -17 -9200000000000000000 +arg i round(arg, i) +-9223372036854775808 -18 -9000000000000000000 +arg i round(arg, i) +Level Code Message +Error 1690 BIGINT value is out of range in 'round(arg@0,i@1)' +arg i round(arg, i) +-9223372036854775808 -20 0 +CALL test_round(9223372036854775807); +arg i round(arg, i) +9223372036854775807 0 9223372036854775807 +arg i round(arg, i) +Level Code Message +Error 1690 BIGINT value is out of range in 'round(arg@0,i@1)' +arg i round(arg, i) +9223372036854775807 -2 9223372036854775800 +arg i round(arg, i) +Level Code Message +Error 1690 BIGINT value is out of range in 'round(arg@0,i@1)' +arg i round(arg, i) +Level Code Message +Error 1690 BIGINT value is out of range in 'round(arg@0,i@1)' +arg i round(arg, i) +Level Code Message +Error 1690 BIGINT value is out of range in 'round(arg@0,i@1)' +arg i round(arg, i) +Level Code Message +Error 1690 BIGINT value is out of range in 'round(arg@0,i@1)' +arg i round(arg, i) +9223372036854775807 -7 9223372036850000000 +arg i round(arg, i) +Level Code Message +Error 1690 BIGINT value is out of range in 'round(arg@0,i@1)' +arg i round(arg, i) +Level Code Message +Error 1690 BIGINT value is out of range in 'round(arg@0,i@1)' +arg i round(arg, i) +Level Code Message +Error 1690 BIGINT value is out of range in 'round(arg@0,i@1)' +arg i round(arg, i) +9223372036854775807 -11 9223372000000000000 +arg i round(arg, i) +9223372036854775807 -12 9223372000000000000 +arg i round(arg, i) +9223372036854775807 -13 9223370000000000000 +arg i round(arg, i) +Level Code Message +Error 1690 BIGINT value is out of range in 'round(arg@0,i@1)' +arg i round(arg, i) +9223372036854775807 -15 9223000000000000000 +arg i round(arg, i) +9223372036854775807 -16 9220000000000000000 +arg i round(arg, i) +9223372036854775807 -17 9200000000000000000 +arg i round(arg, i) +9223372036854775807 -18 9000000000000000000 +arg i round(arg, i) +Level Code Message +Error 1690 BIGINT value is out of range in 'round(arg@0,i@1)' +arg i round(arg, i) +9223372036854775807 -20 0 +CALL test_round(9223372036854775808); +ERROR 22003: Out of range value for column 'arg' at row 1 +CALL test_round_unsigned(9223372036854775807); +arg i round(arg, i) +9223372036854775807 0 9223372036854775807 +arg i round(arg, i) +9223372036854775807 -1 9223372036854775810 +arg i round(arg, i) +9223372036854775807 -2 9223372036854775800 +arg i round(arg, i) +9223372036854775807 -3 9223372036854776000 +arg i round(arg, i) +9223372036854775807 -4 9223372036854780000 +arg i round(arg, i) +9223372036854775807 -5 9223372036854800000 +arg i round(arg, i) +9223372036854775807 -6 9223372036855000000 +arg i round(arg, i) +9223372036854775807 -7 9223372036850000000 +arg i round(arg, i) +9223372036854775807 -8 9223372036900000000 +arg i round(arg, i) +9223372036854775807 -9 9223372037000000000 +arg i round(arg, i) +9223372036854775807 -10 9223372040000000000 +arg i round(arg, i) +9223372036854775807 -11 9223372000000000000 +arg i round(arg, i) +9223372036854775807 -12 9223372000000000000 +arg i round(arg, i) +9223372036854775807 -13 9223370000000000000 +arg i round(arg, i) +9223372036854775807 -14 9223400000000000000 +arg i round(arg, i) +9223372036854775807 -15 9223000000000000000 +arg i round(arg, i) +9223372036854775807 -16 9220000000000000000 +arg i round(arg, i) +9223372036854775807 -17 9200000000000000000 +arg i round(arg, i) +9223372036854775807 -18 9000000000000000000 +arg i round(arg, i) +9223372036854775807 -19 10000000000000000000 +arg i round(arg, i) +9223372036854775807 -20 0 +CALL test_round_unsigned(9223372036854775808); +arg i round(arg, i) +9223372036854775808 0 9223372036854775808 +arg i round(arg, i) +9223372036854775808 -1 9223372036854775810 +arg i round(arg, i) +9223372036854775808 -2 9223372036854775800 +arg i round(arg, i) +9223372036854775808 -3 9223372036854776000 +arg i round(arg, i) +9223372036854775808 -4 9223372036854780000 +arg i round(arg, i) +9223372036854775808 -5 9223372036854800000 +arg i round(arg, i) +9223372036854775808 -6 9223372036855000000 +arg i round(arg, i) +9223372036854775808 -7 9223372036850000000 +arg i round(arg, i) +9223372036854775808 -8 9223372036900000000 +arg i round(arg, i) +9223372036854775808 -9 9223372037000000000 +arg i round(arg, i) +9223372036854775808 -10 9223372040000000000 +arg i round(arg, i) +9223372036854775808 -11 9223372000000000000 +arg i round(arg, i) +9223372036854775808 -12 9223372000000000000 +arg i round(arg, i) +9223372036854775808 -13 9223370000000000000 +arg i round(arg, i) +9223372036854775808 -14 9223400000000000000 +arg i round(arg, i) +9223372036854775808 -15 9223000000000000000 +arg i round(arg, i) +9223372036854775808 -16 9220000000000000000 +arg i round(arg, i) +9223372036854775808 -17 9200000000000000000 +arg i round(arg, i) +9223372036854775808 -18 9000000000000000000 +arg i round(arg, i) +9223372036854775808 -19 10000000000000000000 +arg i round(arg, i) +9223372036854775808 -20 0 +CALL test_round_unsigned(18446744073709551614); +arg i round(arg, i) +18446744073709551614 0 18446744073709551614 +arg i round(arg, i) +18446744073709551614 -1 18446744073709551610 +arg i round(arg, i) +18446744073709551614 -2 18446744073709551600 +arg i round(arg, i) +Level Code Message +Error 1690 BIGINT UNSIGNED value is out of range in 'round(arg@0,i@1)' +arg i round(arg, i) +18446744073709551614 -4 18446744073709550000 +arg i round(arg, i) +Level Code Message +Error 1690 BIGINT UNSIGNED value is out of range in 'round(arg@0,i@1)' +arg i round(arg, i) +Level Code Message +Error 1690 BIGINT UNSIGNED value is out of range in 'round(arg@0,i@1)' +arg i round(arg, i) +Level Code Message +Error 1690 BIGINT UNSIGNED value is out of range in 'round(arg@0,i@1)' +arg i round(arg, i) +18446744073709551614 -8 18446744073700000000 +arg i round(arg, i) +Level Code Message +Error 1690 BIGINT UNSIGNED value is out of range in 'round(arg@0,i@1)' +arg i round(arg, i) +18446744073709551614 -10 18446744070000000000 +arg i round(arg, i) +Level Code Message +Error 1690 BIGINT UNSIGNED value is out of range in 'round(arg@0,i@1)' +arg i round(arg, i) +18446744073709551614 -12 18446744000000000000 +arg i round(arg, i) +18446744073709551614 -13 18446740000000000000 +arg i round(arg, i) +18446744073709551614 -14 18446700000000000000 +arg i round(arg, i) +Level Code Message +Error 1690 BIGINT UNSIGNED value is out of range in 'round(arg@0,i@1)' +arg i round(arg, i) +Level Code Message +Error 1690 BIGINT UNSIGNED value is out of range in 'round(arg@0,i@1)' +arg i round(arg, i) +18446744073709551614 -17 18400000000000000000 +arg i round(arg, i) +18446744073709551614 -18 18000000000000000000 +arg i round(arg, i) +Level Code Message +Error 1690 BIGINT UNSIGNED value is out of range in 'round(arg@0,i@1)' +arg i round(arg, i) +18446744073709551614 -20 0 +DROP PROCEDURE test_round; +DROP PROCEDURE test_round_unsigned; +# Bug#31128028 ROUND and TRUNCATE sometimes produce wrong result types +CREATE TABLE t1(a INTEGER, b INTEGER); +INSERT INTO t1 VALUES(11, -1); +CREATE TABLE t2 AS SELECT a, ROUND(a, b) AS c FROM t1; +DESCRIBE t2; +Field Type Null Key Default Extra +a int YES NULL +c bigint YES NULL +DROP TABLE t1, t2; +# Bug#29602947: The behavior between INSERT stmt and "PREPARE stmt and +# EXECUTE stmt" different +CREATE TABLE t (a INTEGER); +INSERT INTO t VALUES (1.0E+01+'a'); +ERROR 22007: Truncated incorrect DOUBLE value: 'a' +PREPARE st1 FROM "INSERT INTO t VALUES (? + ?)"; +SET @a=1.0E+01; +SET @b='a'; +EXECUTE st1 USING @a,@b; +ERROR 22007: Truncated incorrect DOUBLE value: 'a' +DROP TABLE t; +# +# Bug #19186271 MANY, MANY CLASSES OF STRING-TO-INTEGER CONVERSION BUG +# +SET sql_mode = ''; +CREATE TABLE t1 (i INT, iu INT UNSIGNED, +b BIGINT, bu BIGINT UNSIGNED); +DELETE FROM t1; +INSERT INTO t1 (i,iu,b,bu) +# The second '.' and anything after it should be ignored. +VALUES ('1.2.3.4', '1.2.3.4', '1.2.3.4', '1.2.3.4'); +Warnings: +Warning 1265 Data truncated for column 'i' at row 1 +Warning 1265 Data truncated for column 'iu' at row 1 +Warning 1265 Data truncated for column 'b' at row 1 +Warning 1265 Data truncated for column 'bu' at row 1 +SELECT i,iu,b,bu FROM t1; +i iu b bu +1 1 1 1 +DELETE FROM t1; +INSERT INTO t1 (b,bu) VALUES ('92233720368547758000e+', '92233720368547758000e+'); +Warnings: +Warning 1264 Out of range value for column 'b' at row 1 +Warning 1264 Out of range value for column 'bu' at row 1 +SELECT b,bu FROM t1; +b bu +9223372036854775807 18446744073709551615 +DELETE FROM t1; +INSERT INTO t1 (b,bu) VALUES ('92233720368547758000', '92233720368547758000'); +Warnings: +Warning 1264 Out of range value for column 'b' at row 1 +Warning 1264 Out of range value for column 'bu' at row 1 +SELECT b,bu FROM t1; +b bu +9223372036854775807 18446744073709551615 +DELETE FROM t1; +INSERT INTO t1 (i,b) VALUES ('0.9223372036854775807', '0.9223372036854775807'); +INSERT INTO t1 (i,b) VALUES ('0.9223372036854775808', '0.9223372036854775808'); +SELECT i,b FROM t1; +i b +1 1 +1 1 +DELETE FROM t1; +INSERT INTO t1 (iu,bu) VALUES ('-1e19', '-1e19'); +Warnings: +Warning 1264 Out of range value for column 'iu' at row 1 +Warning 1264 Out of range value for column 'bu' at row 1 +INSERT INTO t1 (iu,bu) VALUES ('-2e19', '-2e19'); +Warnings: +Warning 1264 Out of range value for column 'iu' at row 1 +Warning 1264 Out of range value for column 'bu' at row 1 +INSERT INTO t1 (iu,bu) VALUES ('-18446744073709551615','-18446744073709551615'); +Warnings: +Warning 1264 Out of range value for column 'iu' at row 1 +Warning 1264 Out of range value for column 'bu' at row 1 +INSERT INTO t1 (iu,bu) VALUES ('-18446744073709551616','-18446744073709551616'); +Warnings: +Warning 1264 Out of range value for column 'iu' at row 1 +Warning 1264 Out of range value for column 'bu' at row 1 +SELECT iu,bu FROM t1; +iu bu +0 0 +0 0 +0 0 +0 0 +DROP TABLE t1; +SET sql_mode = DEFAULT; +# +# Bug #30156563 TYPE RESOLUTION OF DIV OPERATOR +# PRODUCES ONE LESS PRECISION. +# +SELECT 5.0 + 96 DIV 1; +5.0 + 96 DIV 1 +101.0 +CREATE TABLE t1 SELECT +5.0 + 96 DIV 1, # Dividend is integer +5.0 + 96.1234 DIV 1, # Dividend is decimal +5.0 + '96' DIV 1, # Dividend is string +5.0 + CAST('96' AS SIGNED) DIV 1, # Dividend is function +5.0 + CAST('96' AS UNSIGNED) DIV 1; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `5.0 + 96 DIV 1` decimal(4,1) DEFAULT NULL, + `5.0 + 96.1234 DIV 1` decimal(8,1) DEFAULT NULL, + `5.0 + '96' DIV 1` decimal(4,1) DEFAULT NULL, + `5.0 + CAST('96' AS SIGNED) DIV 1` decimal(22,1) DEFAULT NULL, + `5.0 + CAST('96' AS UNSIGNED) DIV 1` decimal(23,1) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +DROP TABLE t1; diff --git a/mysql-test/r/func_regexp.result-pq b/mysql-test/r/func_regexp.result-pq new file mode 100644 index 000000000000..769eb4046dd2 --- /dev/null +++ b/mysql-test/r/func_regexp.result-pq @@ -0,0 +1,173 @@ +drop table if exists t1; +set names latin1; +drop table if exists t1; +create table t1 as +select repeat(' ', 64) as s1, repeat(' ',64) as s2 +union +select null, null; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `s1` varchar(64) CHARACTER SET latin1 DEFAULT NULL, + `s2` varchar(64) CHARACTER SET latin1 DEFAULT NULL +) ENGINE=default_engine DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +delete from t1; +insert into t1 values('aaa','aaa'); +insert into t1 values('aaa|qqq','qqq'); +insert into t1 values('gheis','^[^a-dXYZ]+$'); +insert into t1 values('aab','^aa?b'); +insert into t1 values('Baaan','^Ba*n'); +insert into t1 values('aaa','qqq|aaa'); +insert into t1 values('qqq','qqq|aaa'); +insert into t1 values('bbb','qqq|aaa'); +insert into t1 values('bbb','qqq'); +insert into t1 values('aaa','aba'); +insert into t1 values(null,'abc'); +insert into t1 values('def',null); +insert into t1 values(null,null); +select HIGH_PRIORITY s1 regexp s2 from t1; +s1 regexp s2 +1 +1 +1 +1 +1 +1 +1 +0 +0 +0 +NULL +NULL +NULL +SELECT 'ghi' REGEXP 'ghi['; +ERROR HY000: The regular expression contains an unclosed bracket expression. +drop table t1; +create table t1 (xxx char(128)); +insert into t1 (xxx) values('this is a test of some long text to see what happens'); +analyze table t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +select * from t1 where xxx regexp('is a test of some long text to'); +xxx +this is a test of some long text to see what happens +explain select * from t1 where xxx regexp('is a test of some long text to'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`xxx` AS `xxx` from `test`.`t1` where regexp_like(`test`.`t1`.`xxx`,'is a test of some long text to') +select * from t1 where xxx regexp('is a test of some long text to '); +xxx +this is a test of some long text to see what happens +select * from t1 where xxx regexp('is a test of some long text to s'); +xxx +this is a test of some long text to see what happens +select * from t1 where xxx regexp('is a test of some long text to se'); +xxx +this is a test of some long text to see what happens +drop table t1; +create table t1 (xxx char(128)); +insert into t1 (xxx) values('this is some text: to test - out.reg exp (22/45)'); +select * from t1 where xxx REGEXP '^this is some text: to test - out\\.reg exp [[(][0-9]+[/\\][0-9]+[])][ ]*$'; +ERROR HY000: The regular expression contains an unclosed bracket expression. +drop table t1; +# The Henry Spencer library used prior to ICU was inonsistent +# here. When the regular expression search is performed in a +# case-insensitive manner, both '[[:lower:]]' and '[[:upper:]]' +# will match. +select _latin1 0xFF regexp _latin1 '[[:lower:]]' COLLATE latin1_bin; +_latin1 0xFF regexp _latin1 '[[:lower:]]' COLLATE latin1_bin +1 +select _koi8r 0xFF regexp _koi8r '[[:lower:]]' COLLATE koi8r_bin; +_koi8r 0xFF regexp _koi8r '[[:lower:]]' COLLATE koi8r_bin +0 +select _latin1 0xFF regexp _latin1 '[[:upper:]]' COLLATE latin1_bin; +_latin1 0xFF regexp _latin1 '[[:upper:]]' COLLATE latin1_bin +0 +select _koi8r 0xFF regexp _koi8r '[[:upper:]]' COLLATE koi8r_bin; +_koi8r 0xFF regexp _koi8r '[[:upper:]]' COLLATE koi8r_bin +1 +select _latin1 0xF7 regexp _latin1 '[[:alpha:]]'; +_latin1 0xF7 regexp _latin1 '[[:alpha:]]' +0 +select _koi8r 0xF7 regexp _koi8r '[[:alpha:]]'; +_koi8r 0xF7 regexp _koi8r '[[:alpha:]]' +1 +select _latin1'a' regexp _latin1'A' collate latin1_general_ci; +_latin1'a' regexp _latin1'A' collate latin1_general_ci +1 +select _latin1'a' regexp _latin1'A' collate latin1_bin; +_latin1'a' regexp _latin1'A' collate latin1_bin +0 +create table t1 (a varchar(40)); +insert into t1 values ('C1'),('C2'),('R1'),('C3'),('R2'),('R3'); +prepare stmt1 from 'select a from t1 where a rlike ? order by a'; +set @a="^C.*"; +execute stmt1 using @a; +a +C1 +C2 +C3 +set @a="^R.*"; +execute stmt1 using @a; +a +R1 +R2 +R3 +deallocate prepare stmt1; +drop table t1; +End of 4.1 tests +SELECT 1 REGEXP NULL; +1 REGEXP NULL +NULL +SELECT '' REGEXP BINARY NULL; +ERROR HY000: Character set 'latin1_swedish_ci' cannot be used in conjunction with 'binary' in call to regexp_like. +SELECT NULL REGEXP BINARY NULL; +NULL REGEXP BINARY NULL +NULL +SELECT 'A' REGEXP BINARY NULL; +ERROR HY000: Character set 'latin1_swedish_ci' cannot be used in conjunction with 'binary' in call to regexp_like. +SELECT "ABC" REGEXP BINARY NULL; +ERROR HY000: Character set 'latin1_swedish_ci' cannot be used in conjunction with 'binary' in call to regexp_like. +End of 5.0 tests +CREATE TABLE t1(a INT, b CHAR(4)); +INSERT INTO t1 VALUES (1, '6.1'), (1, '7.0'), (1, '8.0'); +PREPARE stmt1 FROM "SELECT a FROM t1 WHERE a=1 AND '7.0' REGEXP b LIMIT 1"; +EXECUTE stmt1; +a +1 +EXECUTE stmt1; +a +1 +EXECUTE stmt1; +a +1 +EXECUTE stmt1; +a +1 +DEALLOCATE PREPARE stmt1; +DROP TABLE t1; +End of 5.1 tests +SELECT ' ' REGEXP '[[:blank:]]'; +' ' REGEXP '[[:blank:]]' +1 +SELECT '\t' REGEXP '[[:blank:]]'; +'\t' REGEXP '[[:blank:]]' +1 +SELECT ' ' REGEXP '[[:space:]]'; +' ' REGEXP '[[:space:]]' +1 +SELECT '\t' REGEXP '[[:space:]]'; +'\t' REGEXP '[[:space:]]' +1 +# +# Bug#22836180: REGEXP, ASSERTION FAILED: !THD->IS_ERROR() +# IN SETUP_FIELDS() +# +DO 1 regexp (multilinestring(point(1,1))); +ERROR HY000: Incorrect arguments to multilinestring +# +# Bug#58026: massive recursion and crash in regular expression handling +# +SELECT '1' RLIKE RPAD('1', 10000, '('); diff --git a/mysql-test/r/func_test.result-pq b/mysql-test/r/func_test.result-pq new file mode 100644 index 000000000000..7c8e5e276066 --- /dev/null +++ b/mysql-test/r/func_test.result-pq @@ -0,0 +1,740 @@ +drop table if exists t1,t2; +select 0=0,1>0,1>=1,1<0,1<=0,1!=0,strcmp("abc","abcd"),strcmp("b","a"),strcmp("a","a") ; +0=0 1>0 1>=1 1<0 1<=0 1!=0 strcmp("abc","abcd") strcmp("b","a") strcmp("a","a") +1 1 1 0 0 1 -1 1 0 +select "a"<"b","a"<="b","b">="a","b">"a","a"="A","a"<>"b"; +"a"<"b" "a"<="b" "b">="a" "b">"a" "a"="A" "a"<>"b" +1 1 1 1 1 1 +select "a "="A", "A "="a", "a " <= "A b"; +"a "="A" "A "="a" "a " <= "A b" +0 0 1 +select "abc" like "a%", "abc" not like "%d%", "a%" like "a\%","abc%" like "a%\%","abcd" like "a%b_%d", "a" like "%%a","abcde" like "a%_e","abc" like "abc%"; +"abc" like "a%" "abc" not like "%d%" "a%" like "a\%" "abc%" like "a%\%" "abcd" like "a%b_%d" "a" like "%%a" "abcde" like "a%_e" "abc" like "abc%" +1 1 1 1 1 1 1 1 +select "a" like "%%b","a" like "%%ab","ab" like "a\%", "ab" like "_", "ab" like "ab_", "abc" like "%_d", "abc" like "abc%d"; +"a" like "%%b" "a" like "%%ab" "ab" like "a\%" "ab" like "_" "ab" like "ab_" "abc" like "%_d" "abc" like "abc%d" +0 0 0 0 0 0 0 +select '?' like '|%', '?' like '|%' ESCAPE '|', '%' like '|%', '%' like '|%' ESCAPE '|', '%' like '%'; +'?' like '|%' '?' like '|%' ESCAPE '|' '%' like '|%' '%' like '|%' ESCAPE '|' '%' like '%' +0 0 0 1 1 +select 'abc' like '%c','abcabc' like '%c', "ab" like "", "ab" like "a", "ab" like "ab"; +'abc' like '%c' 'abcabc' like '%c' "ab" like "" "ab" like "a" "ab" like "ab" +1 1 0 0 1 +select "Det här är svenska" regexp "h[[:alpha:]]+r", "aba" regexp "^(a|b)*$"; +"Det här är svenska" regexp "h[[:alpha:]]+r" "aba" regexp "^(a|b)*$" +1 1 +select "aba" regexp concat("^","a"); +"aba" regexp concat("^","a") +1 +select !0,NOT 0=1,!(0=0),1 AND 1,1 && 0,0 OR 1,1 || NULL, 1=1 or 1=1 and 1=0; +!0 NOT 0=1 !(0=0) 1 AND 1 1 && 0 0 OR 1 1 || NULL 1=1 or 1=1 and 1=0 +1 1 0 1 0 1 1 1 +Warnings: +Warning 1287 '!' is deprecated and will be removed in a future release. Please use NOT instead +Warning 1287 '!' is deprecated and will be removed in a future release. Please use NOT instead +Warning 1287 '&&' is deprecated and will be removed in a future release. Please use AND instead +Warning 1287 '|| as a synonym for OR' is deprecated and will be removed in a future release. Please use OR instead +select 2 between 1 and 3, "monty" between "max" and "my",2=2 and "monty" between "max" and "my" and 3=3; +2 between 1 and 3 "monty" between "max" and "my" 2=2 and "monty" between "max" and "my" and 3=3 +1 1 1 +select 'b' between 'a' and 'c', 'B' between 'a' and 'c'; +'b' between 'a' and 'c' 'B' between 'a' and 'c' +1 1 +select 2 in (3,2,5,9,5,1),"monty" in ("david","monty","allan"), 1.2 in (1.4,1.2,1.0); +2 in (3,2,5,9,5,1) "monty" in ("david","monty","allan") 1.2 in (1.4,1.2,1.0) +1 1 1 +select -1.49 or -1.49,0.6 or 0.6; +-1.49 or -1.49 0.6 or 0.6 +1 1 +select 3 ^ 11, 1 ^ 1, 1 ^ 0, 1 ^ NULL, NULL ^ 1; +3 ^ 11 1 ^ 1 1 ^ 0 1 ^ NULL NULL ^ 1 +8 0 1 NULL NULL +explain select 3 ^ 11, 1 ^ 1, 1 ^ 0, 1 ^ NULL, NULL ^ 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 /* select#1 */ select (3 ^ 11) AS `3 ^ 11`,(1 ^ 1) AS `1 ^ 1`,(1 ^ 0) AS `1 ^ 0`,(1 ^ NULL) AS `1 ^ NULL`,(NULL ^ 1) AS `NULL ^ 1` +select 1 XOR 1, 1 XOR 0, 0 XOR 1, 0 XOR 0, NULL XOR 1, 1 XOR NULL, 0 XOR NULL; +1 XOR 1 1 XOR 0 0 XOR 1 0 XOR 0 NULL XOR 1 1 XOR NULL 0 XOR NULL +0 1 1 0 NULL NULL NULL +select 1 like 2 xor 2 like 1; +1 like 2 xor 2 like 1 +0 +select 10 % 7, 10 mod 7, 10 div 3; +10 % 7 10 mod 7 10 div 3 +3 3 3 +explain select 10 % 7, 10 mod 7, 10 div 3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 /* select#1 */ select (10 % 7) AS `10 % 7`,(10 % 7) AS `10 mod 7`,(10 DIV 3) AS `10 div 3` +select 18446744073709551615, 18446744073709551615 DIV 1, 18446744073709551615 DIV 2; +18446744073709551615 18446744073709551615 DIV 1 18446744073709551615 DIV 2 +18446744073709551615 18446744073709551615 9223372036854775807 +explain select (1 << 64)-1, ((1 << 64)-1) DIV 1, ((1 << 64)-1) DIV 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 /* select#1 */ select ((1 << 64) - 1) AS `(1 << 64)-1`,(((1 << 64) - 1) DIV 1) AS `((1 << 64)-1) DIV 1`,(((1 << 64) - 1) DIV 2) AS `((1 << 64)-1) DIV 2` +create table t1 (a int); +insert t1 values (1); +analyze table t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +select * from t1 where 1 xor 1; +a +explain select * from t1 where 1 xor 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where false +select - a from t1; +- a +-1 +explain select - a from t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select -(`test`.`t1`.`a`) AS `- a` from `test`.`t1` +drop table t1; +select 5 between 0 and 10 between 0 and 1,(5 between 0 and 10) between 0 and 1; +5 between 0 and 10 between 0 and 1 (5 between 0 and 10) between 0 and 1 +0 1 +select 1 and 2 between 2 and 10, 2 between 2 and 10 and 1; +1 and 2 between 2 and 10 2 between 2 and 10 and 1 +1 1 +select 1 and 0 or 2, 2 or 1 and 0; +1 and 0 or 2 2 or 1 and 0 +1 1 +select _koi8r'a' = _koi8r'A'; +_koi8r'a' = _koi8r'A' +1 +select _koi8r'a' = _koi8r'A' COLLATE koi8r_general_ci; +_koi8r'a' = _koi8r'A' COLLATE koi8r_general_ci +1 +explain select _koi8r'a' = _koi8r'A' COLLATE koi8r_general_ci; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 /* select#1 */ select (_koi8r'a' = (_koi8r'A' collate koi8r_general_ci)) AS `_koi8r'a' = _koi8r'A' COLLATE koi8r_general_ci` +select _koi8r'a' = _koi8r'A' COLLATE koi8r_bin; +_koi8r'a' = _koi8r'A' COLLATE koi8r_bin +0 +select _koi8r'a' COLLATE koi8r_general_ci = _koi8r'A'; +_koi8r'a' COLLATE koi8r_general_ci = _koi8r'A' +1 +select _koi8r'a' COLLATE koi8r_bin = _koi8r'A'; +_koi8r'a' COLLATE koi8r_bin = _koi8r'A' +0 +select _koi8r'a' COLLATE koi8r_bin = _koi8r'A' COLLATE koi8r_general_ci; +ERROR HY000: Illegal mix of collations (koi8r_bin,EXPLICIT) and (koi8r_general_ci,EXPLICIT) for operation '=' +select _koi8r'a' = _latin1'A'; +ERROR HY000: Illegal mix of collations (koi8r_general_ci,COERCIBLE) and (latin1_swedish_ci,COERCIBLE) for operation '=' +select strcmp(_koi8r'a', _koi8r'A'); +strcmp(_koi8r'a', _koi8r'A') +0 +select strcmp(_koi8r'a', _koi8r'A' COLLATE koi8r_general_ci); +strcmp(_koi8r'a', _koi8r'A' COLLATE koi8r_general_ci) +0 +select strcmp(_koi8r'a', _koi8r'A' COLLATE koi8r_bin); +strcmp(_koi8r'a', _koi8r'A' COLLATE koi8r_bin) +1 +select strcmp(_koi8r'a' COLLATE koi8r_general_ci, _koi8r'A'); +strcmp(_koi8r'a' COLLATE koi8r_general_ci, _koi8r'A') +0 +select strcmp(_koi8r'a' COLLATE koi8r_bin, _koi8r'A'); +strcmp(_koi8r'a' COLLATE koi8r_bin, _koi8r'A') +1 +select strcmp(_koi8r'a' COLLATE koi8r_general_ci, _koi8r'A' COLLATE koi8r_bin); +ERROR HY000: Illegal mix of collations (koi8r_general_ci,EXPLICIT) and (koi8r_bin,EXPLICIT) for operation 'strcmp' +select strcmp(_koi8r'a', _latin1'A'); +ERROR HY000: Illegal mix of collations (koi8r_general_ci,COERCIBLE) and (latin1_swedish_ci,COERCIBLE) for operation 'strcmp' +select _koi8r'a' LIKE _koi8r'A'; +_koi8r'a' LIKE _koi8r'A' +1 +select _koi8r'a' LIKE _koi8r'A' COLLATE koi8r_general_ci; +_koi8r'a' LIKE _koi8r'A' COLLATE koi8r_general_ci +1 +select _koi8r'a' LIKE _koi8r'A' COLLATE koi8r_bin; +_koi8r'a' LIKE _koi8r'A' COLLATE koi8r_bin +0 +select _koi8r'a' COLLATE koi8r_general_ci LIKE _koi8r'A'; +_koi8r'a' COLLATE koi8r_general_ci LIKE _koi8r'A' +1 +select _koi8r'a' COLLATE koi8r_bin LIKE _koi8r'A'; +_koi8r'a' COLLATE koi8r_bin LIKE _koi8r'A' +0 +select _koi8r'a' COLLATE koi8r_general_ci LIKE _koi8r'A' COLLATE koi8r_bin; +ERROR HY000: Illegal mix of collations (koi8r_general_ci,EXPLICIT) and (koi8r_bin,EXPLICIT) for operation 'like' +select _koi8r'a' LIKE _latin1'A'; +ERROR HY000: Illegal mix of collations (koi8r_general_ci,COERCIBLE) and (latin1_swedish_ci,COERCIBLE) for operation 'like' +SET sql_mode = 'NO_ENGINE_SUBSTITUTION'; +CREATE TABLE t1 ( faq_group_id int(11) NOT NULL default '0', faq_id int(11) NOT NULL default '0', title varchar(240) default NULL, keywords text, description longblob, solution longblob, status tinyint(4) NOT NULL default '0', access_id smallint(6) default NULL, lang_id smallint(6) NOT NULL default '0', created datetime NOT NULL default '0000-00-00 00:00:00', updated datetime default NULL, last_access datetime default NULL, last_notify datetime default NULL, solved_count int(11) NOT NULL default '0', static_solved int(11) default NULL, solved_1 int(11) default NULL, solved_2 int(11) default NULL, solved_3 int(11) default NULL, solved_4 int(11) default NULL, solved_5 int(11) default NULL, expires datetime default NULL, notes text, assigned_to smallint(6) default NULL, assigned_group smallint(6) default NULL, last_edited_by smallint(6) default NULL, orig_ref_no varchar(15) binary default NULL, c$fundstate smallint(6) default NULL, c$contributor smallint(6) default NULL, UNIQUE KEY t1$faq_id (faq_id), KEY t1$group_id$faq_id (faq_group_id,faq_id), KEY t1$c$fundstate (c$fundstate) ) ENGINE=InnoDB; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1287 'BINARY as attribute of a type' is deprecated and will be removed in a future release. Please use a CHARACTER SET clause with _bin collation instead +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (82,82,'How to use the DynaVox Usage Counts Feature','usages count, number, corner, white, box, button','\r\n\r\n \r\n \r\n \r\n \r\n
 \r\n

How \r\n To: \r\n Display or Hide the Usage Counts to find out how many times each button is being selected.

\r\n
','\r\n \r\n \r\n \r\n \r\n\r\n \r\n
  \r\n \r\n

1. Select \r\n the On/Setup button to access the DynaVox Setup Menu.
\r\n 2. Select Button Features.
\r\n 3. Below the OK button is the Usage Counts button.
\r\n a. If it says \"Hidden\" then the Usage Counts will not be displayed.
\r\n b. If it says \"Displayed\" then the Usage Counts will be shown.
\r\n c. Select the Usage Counts Option Ring once and it will toggle \r\n to the alternative option.
\r\n 4. Once the correct setting has been chosen, select OK to leave the Button \r\n Features menu.
\r\n 5. Select OK out of the Setup menu and return to the communication \r\n page.

\r\n

For \r\n further information on Usage Counts, see the Button Features \r\n Menu Entry in the DynaVox/DynaMyte Reference Manual.

\r\n
',4,1,1,'2001-11-16 16:43:34','2002-11-25 12:09:43','2003-07-24 01:04:48',NULL,11,NULL,0,0,0,0,0,NULL,NULL,NULL,NULL,11,NULL,NULL,NULL); +CREATE TABLE t2 ( access_id smallint(6) NOT NULL default '0', name varchar(20) binary default NULL, `rank` smallint(6) NOT NULL default '0', KEY t2$access_id (access_id) ) ENGINE=InnoDB; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1287 'BINARY as attribute of a type' is deprecated and will be removed in a future release. Please use a CHARACTER SET clause with _bin collation instead +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (1,'Everyone',2),(2,'Help',3),(3,'Customer Support',1); +SELECT f_acc.`rank`, a1.`rank`, a2.`rank` FROM t1 LEFT JOIN t1 f1 ON (f1.access_id=1 AND f1.faq_group_id = t1.faq_group_id) LEFT JOIN t2 a1 ON (a1.access_id = f1.access_id) LEFT JOIN t1 f2 ON (f2.access_id=3 AND f2.faq_group_id = t1.faq_group_id) LEFT JOIN t2 a2 ON (a2.access_id = f2.access_id), t2 f_acc WHERE LEAST(a1.`rank`,a2.`rank`) = f_acc.`rank`; +rank rank rank +DROP TABLE t1,t2; +SET sql_mode = default; +CREATE TABLE t1 (d varchar(6), k int); +INSERT INTO t1 VALUES (NULL, 2); +SELECT GREATEST(d,d) FROM t1 WHERE k=2; +GREATEST(d,d) +NULL +DROP TABLE t1; +select 1197.90 mod 50; +1197.90 mod 50 +47.90 +select 5.1 mod 3, 5.1 mod -3, -5.1 mod 3, -5.1 mod -3; +5.1 mod 3 5.1 mod -3 -5.1 mod 3 -5.1 mod -3 +2.1 2.1 -2.1 -2.1 +select 5 mod 3, 5 mod -3, -5 mod 3, -5 mod -3; +5 mod 3 5 mod -3 -5 mod 3 -5 mod -3 +2 2 -2 -2 +select (12%0) <=> null as '1'; +1 +1 +Warnings: +Warning 1365 Division by 0 +select (12%0) is null as '1'; +1 +1 +Warnings: +Warning 1365 Division by 0 +select 12%0 as 'NULL'; +NULL +NULL +Warnings: +Warning 1365 Division by 0 +select 12%2 as '0'; +0 +0 +select 12%NULL as 'NULL'; +NULL +NULL +select 12 % null as 'NULL'; +NULL +NULL +select null % 12 as 'NULL'; +NULL +NULL +select null % 0 as 'NULL'; +NULL +NULL +select 0 % null as 'NULL'; +NULL +NULL +select null % null as 'NULL'; +NULL +NULL +select (12 mod 0) <=> null as '1'; +1 +1 +Warnings: +Warning 1365 Division by 0 +select (12 mod 0) is null as '1'; +1 +1 +Warnings: +Warning 1365 Division by 0 +select 12 mod 0 as 'NULL'; +NULL +NULL +Warnings: +Warning 1365 Division by 0 +select 12 mod 2 as '0'; +0 +0 +select 12 mod null as 'NULL'; +NULL +NULL +select null mod 12 as 'NULL'; +NULL +NULL +select null mod 0 as 'NULL'; +NULL +NULL +select 0 mod null as 'NULL'; +NULL +NULL +select null mod null as 'NULL'; +NULL +NULL +select mod(12.0, 0) as 'NULL'; +NULL +NULL +Warnings: +Warning 1365 Division by 0 +select mod(12, 0.0) as 'NULL'; +NULL +NULL +Warnings: +Warning 1365 Division by 0 +select mod(12, NULL) as 'NULL'; +NULL +NULL +select mod(12.0, NULL) as 'NULL'; +NULL +NULL +select mod(NULL, 2) as 'NULL'; +NULL +NULL +select mod(NULL, 2.0) as 'NULL'; +NULL +NULL +create table t1 (a int, b int); +insert into t1 values (1,2), (2,3), (3,4), (4,5); +select * from t1 where a not between 1 and 2; +a b +3 4 +4 5 +select * from t1 where a not between 1 and 2 and b not between 3 and 4; +a b +4 5 +drop table t1; +SELECT GREATEST(1,NULL) FROM DUAL; +GREATEST(1,NULL) +NULL +SELECT LEAST('xxx','aaa',NULL,'yyy') FROM DUAL; +LEAST('xxx','aaa',NULL,'yyy') +NULL +SELECT LEAST(1.1,1.2,NULL,1.0) FROM DUAL; +LEAST(1.1,1.2,NULL,1.0) +NULL +SELECT GREATEST(1.5E+2,1.3E+2,NULL) FROM DUAL; +GREATEST(1.5E+2,1.3E+2,NULL) +NULL +# +# Bug#22523685 FUNCTION GREATEST AND LEAST WORKS INCORRECTLY +# WITH BIGINT UNSIGNED VALUE +# +SELECT greatest( 9223372036854775807 , 9223372036854775808 ) as g; +g +9223372036854775808 +SELECT least ( 9223372036854775807 , 9223372036854775808 ) as l; +l +9223372036854775807 +SELECT greatest (9223372036854775808, -1, 18446744073709551615 ) as g; +g +18446744073709551615 +SELECT least (9223372036854775808, -1, 18446744073709551615 ) as l; +l +-1 +SELECT greatest (9223372036854775808, 18446744073709551615) as g; +g +18446744073709551615 +SELECT least (9223372036854775808, 18446744073709551615) as l; +l +9223372036854775808 +CREATE TABLE t1 AS SELECT greatest(-1, 9223372036854775808); +CREATE TABLE t2 AS SELECT greatest(9223372036854775808, 9223372036854775808); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `greatest(-1, 9223372036854775808)` decimal(19,0) NOT NULL DEFAULT '0' +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `greatest(9223372036854775808, 9223372036854775808)` bigint unsigned NOT NULL DEFAULT '0' +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +DROP TABLE t1, t2; +# +# Bug#22839888 UNINITIALIZED VALUE WHEN CONVERTING +# MULTIBYTE STRINGS TO NUMBERS +# +select greatest(1,_utf16'.',_utf8''); +ERROR HY000: Illegal mix of collations (latin1_swedish_ci,NUMERIC), (utf16_general_ci,COERCIBLE), (utf8_general_ci,COERCIBLE) for operation 'greatest' +# +# Bug#25123839: LEAST AND GREATEST MAKES INCONSISTENT DATA TYPES, +# COMPARED TO UNION AND COALESCE +# +SET sql_mode=''; +CREATE TABLE t1 AS +SELECT 5 AS c1, 5 AS c2, 5 AS c3, 5 AS c4, 20010101 AS c5, 010101 AS c6, +010101 AS c7, 20010101 AS c8, 5.55 AS c11, 5.5 AS c12, 5.5 AS c13, +010101.5 AS c14, 5.5 AS c15, 010101.5 as c16, 5.5e5 as c21, +2004041e1 as c22, 150505.0e5 AS c23, 2004041e1 AS c24, '010101' AS c31, +'5' AS c32, '010101' AS c33, date '2005-05-05' AS c41, +date '2005-05-05' AS c42, time '05:05:05.555555' AS c51, +x'c3a5' AS c61, x'c3a5' AS c62, _utf8mb4 x'c3a5' AS c63, +_utf8mb4 x'c3a5' AS c64, JSON_OBJECT('a', 1) as c71 +UNION +SELECT -5, 5.5, 5.5e5, '5', date '2005-05-05', time '05:05:05.555555', +timestamp '2005-05-05 05:05:05.555555', NOW(0), 88.8, +5.5e5, '5', date '2005-05-05', time '05:05:05.555555', +timestamp '2005-05-05 05:05:05.555555', +'5', date '2005-05-05', time '05:05:05.555555', +timestamp '2005-05-05 05:05:05.555555', +date '2005-05-05', time '05:05:05.555555', +timestamp '2005-05-05 05:05:05.555555', +time '05:05:05.555555', timestamp '2005-05-05 05:05:05.555555', +timestamp '2005-05-05 05:05:05.555555', '1', _binary '1', '1', +_binary '1', NULL; +SET sql_mode=default; +CREATE TABLE t2 AS +SELECT COALESCE(5, -5) AS c1, +COALESCE(5, 5.5) AS c2, +COALESCE(5, 5.5e5) AS c3, +COALESCE(5, '5') AS c4, +COALESCE(20010101, date '2005-05-05') AS c5, +COALESCE(010101, time '05:05:05.555555') AS c6, +COALESCE(010101, timestamp '2005-05-05 05:05:05.555555') AS c7, +COALESCE(20010101, NOW(0)) AS c8, +COALESCE(5.55, 88.8) AS c11, +COALESCE(5.5, 5.5e5) AS c12, +COALESCE(5.5, '5') AS c13, +COALESCE(010101.5, date '2005-05-05') AS c14, +COALESCE(5.5, time '05:05:05.555555') AS c15, +COALESCE(010101.5, timestamp '2005-05-05 05:05:05.555555') AS c16, +COALESCE(5.5e5, '5') AS c21, +COALESCE(2004041e1, date '2005-05-05') AS c22, +COALESCE(150505.0e5, time '05:05:05.555555') AS c23, +COALESCE(2004041e1, timestamp '2005-05-05 05:05:05.555555') AS c24, +COALESCE('010101', date '2005-05-05') AS c31, +COALESCE('5', time '05:05:05.555555') AS c32, +COALESCE('010101', timestamp '2005-05-05 05:05:05.555555') AS c33, +COALESCE(date '2005-05-05', time '05:05:05.555555') AS c41, +COALESCE(date '2005-05-05', timestamp '2005-05-05 05:05:05.555555') AS +c42, +COALESCE(time '05:05:05.555555', timestamp '2005-05-05 +05:05:05.555555') AS c51, +COALESCE(x'c3a5', '1') AS c61, +COALESCE(x'c3a5', _binary '1') AS c62, +COALESCE(_utf8mb4 x'c3a5', '1') AS c63, +COALESCE(_utf8mb4 x'c3a5', _binary '1') AS c64, +COALESCE(JSON_OBJECT('a', 1), NULL) AS c71; +CREATE TABLE t3 AS +SELECT GREATEST(5, -5) AS c1, +GREATEST(5, 5.5) AS c2, +GREATEST(5, 5.5e5) AS c3, +GREATEST(5, '5') AS c4, +GREATEST(20010101, date '2005-05-05') AS c5, +GREATEST(010101, time '05:05:05.555555') AS c6, +GREATEST(010101, timestamp '2005-05-05 05:05:05.555555') AS c7, +GREATEST(20010101, NOW(0)) AS c8, +GREATEST(5.55, 88.8) AS c11, +GREATEST(5.5, 5.5e5) AS c12, +GREATEST(5.5, '5') AS c13, +GREATEST(010101.5, date '2005-05-05') AS c14, +GREATEST(5.5, time '05:05:05.555555') AS c15, +GREATEST(010101.5, timestamp '2005-05-05 05:05:05.555555') AS c16, +GREATEST(5.5e5, '5') AS c21, +GREATEST(2004041e1, date '2005-05-05') AS c22, +GREATEST(150505.0e5, time '05:05:05.555555') AS c23, +GREATEST(2004041e1, timestamp '2005-05-05 05:05:05.555555') AS c24, +GREATEST('010101', date '2005-05-05') AS c31, +GREATEST('5', time '05:05:05.555555') AS c32, +GREATEST('010101', timestamp '2005-05-05 05:05:05.555555') AS c33, +GREATEST(date '2005-05-05', time '05:05:05.555555') AS c41, +GREATEST(date '2005-05-05', timestamp '2005-05-05 05:05:05.555555') AS +c42, +GREATEST(time '05:05:05.555555', timestamp '2005-05-05 +05:05:05.555555') AS c51, +GREATEST(x'c3a5', '1') AS c61, +GREATEST(x'c3a5', _binary '1') AS c62, +GREATEST(_utf8mb4 x'c3a5', '1') AS c63, +GREATEST(_utf8mb4 x'c3a5', _binary '1') AS c64; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` bigint NOT NULL DEFAULT '0', + `c2` decimal(2,1) NOT NULL DEFAULT '0.0', + `c3` double NOT NULL DEFAULT '0', + `c4` varchar(1) NOT NULL DEFAULT '', + `c5` varchar(10) NOT NULL DEFAULT '', + `c6` varchar(17) NOT NULL DEFAULT '', + `c7` varchar(26) NOT NULL DEFAULT '', + `c8` varchar(19) NOT NULL DEFAULT '', + `c11` decimal(4,2) NOT NULL DEFAULT '0.00', + `c12` double NOT NULL DEFAULT '0', + `c13` varchar(4) NOT NULL DEFAULT '', + `c14` varchar(10) NOT NULL DEFAULT '', + `c15` varchar(17) NOT NULL DEFAULT '', + `c16` varchar(26) NOT NULL DEFAULT '', + `c21` varchar(22) NOT NULL DEFAULT '', + `c22` varchar(22) NOT NULL DEFAULT '', + `c23` varchar(22) NOT NULL DEFAULT '', + `c24` varchar(26) NOT NULL DEFAULT '', + `c31` varchar(10) NOT NULL DEFAULT '', + `c32` varchar(17) NOT NULL DEFAULT '', + `c33` varchar(26) NOT NULL DEFAULT '', + `c41` datetime(6) NOT NULL DEFAULT '0000-00-00 00:00:00.000000', + `c42` datetime(6) NOT NULL DEFAULT '0000-00-00 00:00:00.000000', + `c51` datetime(6) NOT NULL DEFAULT '0000-00-00 00:00:00.000000', + `c61` varbinary(4) NOT NULL DEFAULT '', + `c62` varbinary(2) NOT NULL DEFAULT '', + `c63` varchar(1) NOT NULL DEFAULT '', + `c64` varbinary(4) NOT NULL DEFAULT '', + `c71` json DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `c1` int NOT NULL DEFAULT '0', + `c2` decimal(2,1) NOT NULL DEFAULT '0.0', + `c3` double NOT NULL DEFAULT '0', + `c4` varchar(1) NOT NULL DEFAULT '', + `c5` varchar(10) NOT NULL DEFAULT '', + `c6` varchar(17) NOT NULL DEFAULT '', + `c7` varchar(26) NOT NULL DEFAULT '', + `c8` varchar(19) NOT NULL DEFAULT '', + `c11` decimal(4,2) NOT NULL DEFAULT '0.00', + `c12` double NOT NULL DEFAULT '0', + `c13` varchar(4) NOT NULL DEFAULT '', + `c14` varchar(10) NOT NULL DEFAULT '', + `c15` varchar(17) NOT NULL DEFAULT '', + `c16` varchar(26) NOT NULL DEFAULT '', + `c21` varchar(22) NOT NULL DEFAULT '', + `c22` varchar(22) NOT NULL DEFAULT '', + `c23` varchar(22) NOT NULL DEFAULT '', + `c24` varchar(26) NOT NULL DEFAULT '', + `c31` varchar(10) NOT NULL DEFAULT '', + `c32` varchar(17) NOT NULL DEFAULT '', + `c33` varchar(26) NOT NULL DEFAULT '', + `c41` datetime(6) NOT NULL, + `c42` datetime(6) NOT NULL, + `c51` datetime(6) NOT NULL, + `c61` varbinary(4) NOT NULL DEFAULT '', + `c62` varbinary(2) NOT NULL DEFAULT '', + `c63` varchar(1) NOT NULL DEFAULT '', + `c64` varbinary(4) NOT NULL DEFAULT '', + `c71` json DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SHOW CREATE TABLE t3; +Table Create Table +t3 CREATE TABLE `t3` ( + `c1` int NOT NULL DEFAULT '0', + `c2` decimal(2,1) NOT NULL DEFAULT '0.0', + `c3` double NOT NULL DEFAULT '0', + `c4` varchar(1) NOT NULL DEFAULT '', + `c5` varchar(10) NOT NULL DEFAULT '', + `c6` varchar(17) NOT NULL DEFAULT '', + `c7` varchar(26) NOT NULL DEFAULT '', + `c8` varchar(19) NOT NULL DEFAULT '', + `c11` decimal(4,2) NOT NULL DEFAULT '0.00', + `c12` double NOT NULL DEFAULT '0', + `c13` varchar(4) NOT NULL DEFAULT '', + `c14` varchar(10) NOT NULL DEFAULT '', + `c15` varchar(17) NOT NULL DEFAULT '', + `c16` varchar(26) NOT NULL DEFAULT '', + `c21` varchar(22) NOT NULL DEFAULT '', + `c22` varchar(22) NOT NULL DEFAULT '', + `c23` varchar(22) NOT NULL DEFAULT '', + `c24` varchar(26) NOT NULL DEFAULT '', + `c31` varchar(10) NOT NULL DEFAULT '', + `c32` varchar(17) NOT NULL DEFAULT '', + `c33` varchar(26) NOT NULL DEFAULT '', + `c41` datetime(6) NOT NULL, + `c42` datetime(6) NOT NULL, + `c51` datetime(6) NOT NULL, + `c61` varbinary(4) NOT NULL DEFAULT '', + `c62` varbinary(2) NOT NULL DEFAULT '', + `c63` varchar(1) NOT NULL DEFAULT '', + `c64` varbinary(4) NOT NULL DEFAULT '' +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +DROP TABLE t1, t2, t3; +SELECT GREATEST('11', '5', '2'); +GREATEST('11', '5', '2') +5 +SELECT GREATEST('11', 5, 2); +GREATEST('11', 5, 2) +5 +SELECT GREATEST(11, 5, 2); +GREATEST(11, 5, 2) +11 +SELECT LEAST('11', '5', '2'); +LEAST('11', '5', '2') +11 +SELECT LEAST('11', 5, 2); +LEAST('11', 5, 2) +11 +SELECT LEAST(11, 5, 2); +LEAST(11, 5, 2) +2 +SELECT GREATEST(date '2005-05-05', 20010101, 20040404, 20030303); +GREATEST(date '2005-05-05', 20010101, 20040404, 20030303) +2005-05-05 +SELECT LEAST(date '2005-05-05', 20030303, 20010101, 20040404); +LEAST(date '2005-05-05', 20030303, 20010101, 20040404) +2001-01-01 +SELECT GREATEST(date '2005-05-05', '20010101', '20040404', '20030303'); +GREATEST(date '2005-05-05', '20010101', '20040404', '20030303') +2005-05-05 +SELECT LEAST(date '2005-05-05', '20030303', '20010101', '20040404'); +LEAST(date '2005-05-05', '20030303', '20010101', '20040404') +2001-01-01 +SELECT GREATEST(time '00:00:00', 120000); +GREATEST(time '00:00:00', 120000) +120000 +SELECT LEAST(time '00:00:00', 120000); +LEAST(time '00:00:00', 120000) +00:00:00 +SELECT GREATEST(time '20:00:00', 120000); +GREATEST(time '20:00:00', 120000) +20:00:00 +SELECT LEAST(time '20:00:00', 120000); +LEAST(time '20:00:00', 120000) +120000 +SELECT GREATEST('95-05-05', date '10-10-10'); +GREATEST('95-05-05', date '10-10-10') +2010-10-10 +SELECT GREATEST(date '1995-05-05', '10-10-10'); +GREATEST(date '1995-05-05', '10-10-10') +2010-10-10 +SELECT LEAST(date '1995-05-05', '10-10-10'); +LEAST(date '1995-05-05', '10-10-10') +1995-05-05 +SELECT LEAST('95-05-05', date '10-10-10'); +LEAST('95-05-05', date '10-10-10') +1995-05-05 +SELECT GREATEST('11', '5', '2') + 0; +GREATEST('11', '5', '2') + 0 +5 +SELECT GREATEST('11', 5, 2) + 0; +GREATEST('11', 5, 2) + 0 +5 +SELECT GREATEST(11, 5, 2) + 0; +GREATEST(11, 5, 2) + 0 +11 +SELECT GREATEST(date '2005-05-05', 20010101, 20040404, 20030303) + 0; +GREATEST(date '2005-05-05', 20010101, 20040404, 20030303) + 0 +20050505 +SELECT GREATEST(time '00:00:00', 120000) + 0; +GREATEST(time '00:00:00', 120000) + 0 +120000 +SELECT GREATEST(time '20:00:00', 120000) + 0; +GREATEST(time '20:00:00', 120000) + 0 +200000 +SELECT GREATEST('95-05-05', date '10-10-10') + 0; +GREATEST('95-05-05', date '10-10-10') + 0 +20101010 +SELECT GREATEST(date '1995-05-05', '10-10-10') + 0; +GREATEST(date '1995-05-05', '10-10-10') + 0 +20101010 +SELECT GREATEST('11', '5', '2') + 0.00; +GREATEST('11', '5', '2') + 0.00 +5 +SELECT GREATEST('11', 5, 2) + 0.00; +GREATEST('11', 5, 2) + 0.00 +5 +SELECT GREATEST(11, 5, 2) + 0.00; +GREATEST(11, 5, 2) + 0.00 +11.00 +SELECT GREATEST(date '1995-05-05', 19910101, 20050505, 19930303) + 0.00; +GREATEST(date '1995-05-05', 19910101, 20050505, 19930303) + 0.00 +20050505.00 +SELECT GREATEST(time '00:00:00', 120000) + 0.00; +GREATEST(time '00:00:00', 120000) + 0.00 +120000.00 +SELECT GREATEST(time '20:00:00', 120000) + 0.00; +GREATEST(time '20:00:00', 120000) + 0.00 +200000.00 +SELECT GREATEST('95-05-05', date '10-10-10') + 0.00; +GREATEST('95-05-05', date '10-10-10') + 0.00 +20101010.00 +SELECT GREATEST(date '1995-05-05', '10-10-10') + 0.00; +GREATEST(date '1995-05-05', '10-10-10') + 0.00 +20101010.00 +# End of test for Bug#25123839 +# +# Bug#26975864: ASSERTION FAILED: DEC <= 6, MY_DATETIME_TO_STR, LEAST, +# GREATEST, ETC +# +CREATE TABLE t1 (a DATETIME, b BLOB, c TEXT, d CHAR(10), e BINARY(10), +f VARBINARY(10)); +SET @a='2017-01-01'; +INSERT INTO t1 VALUES ('2017-02-02 12:00:00', @a, @a, @a, @a, @a); +SELECT GREATEST(a, b), GREATEST(a, c), GREATEST(a, d), GREATEST(a, e), +GREATEST(a, f) FROM t1; +GREATEST(a, b) GREATEST(a, c) GREATEST(a, d) GREATEST(a, e) GREATEST(a, f) +2017-02-02 12:00:00.000000 2017-02-02 12:00:00.000000 2017-02-02 12:00:00.000000 2017-02-02 12:00:00.000000 2017-02-02 12:00:00.000000 +SET @a=NULL; +DROP TABLE t1; +# +# Bug#13364839: GREATEST() DOES NOT ALWAYS RETURN SAME SIGNNESS OF ARGUMENT TYPES +# +CREATE TABLE t1 (a INT PRIMARY KEY, b BIGINT(20) UNSIGNED); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (1, 13836376518955650385); +INSERT INTO t1 VALUES (1, 13836376518955650385) ON DUPLICATE KEY UPDATE b=GREATEST(b, VALUES(b)); +Warnings: +Warning 1287 'VALUES function' is deprecated and will be removed in a future release. Please use an alias (INSERT INTO ... VALUES (...) AS alias) and replace VALUES(col) in the ON DUPLICATE KEY UPDATE clause with alias.col instead +SELECT * FROM t1; +a b +1 13836376518955650385 +DROP TABLE t1; +# +# Bug#27312703 ASAN: HEAP-USE-AFTER-FREE: GREATEST/LEAST FUNCTIONS +# +SET @a:='11'; +DO GREATEST(RIGHT(@a,1),1); +DO LEAST(RIGHT(@a,1),1); +# +# Bug#29275835 ASSERTION FAILED: +# !UNSIGNED_FLAG || (UNSIGNED_FLAG && ARGS[I]->UNSIGNED_FLAG) +# +SET sql_mode=''; +CREATE TABLE t0017 ( +c0002 bigint(20) NOT NULL +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t0017 (c0002) +VALUES (0); +SELECT greatest(18446744073709551615, NULL) +FROM t0017; +greatest(18446744073709551615, NULL) +NULL +SELECT +count(greatest(18446744073709551615, NULL)) +FROM t0017; +count(greatest(18446744073709551615, NULL)) +0 +DROP TABLE t0017; +SET sql_mode = default; +# +# Bug#29467577 ASSERTION `!UNSIGNED_FLAG || +# (UNSIGNED_FLAG && ARGS[I]->UNSIGNED_FLAG)' FAILED. +# +CREATE TABLE t1 (c1 INT UNSIGNED, c2 INT UNSIGNED); +INSERT INTO t1 VALUES (202, 1); +SELECT * FROM t1 WHERE (GREATEST(c1, c2) = 42) AND (c2 = 1); +c1 c2 +DROP TABLE t1; +# +# Bug#30326848 ASSERTION FAILED: (SLEN % 4) == 0 IN MY_STRNNCOLLSP_UTF32 +# +DO NULLIF((GREATEST(FROM_UNIXTIME(1537024679) , _utf32 "*b!" )), +(FROM_UNIXTIME(1537013301) ) +); +Warnings: +Warning 1300 Invalid utf32 character string: '002A62' +Warning 1292 Incorrect datetime value: '?' for column 'FROM_UNIXTIME(1537024679)' at row 1 +Warning 1292 Incorrect datetime value: '?' for column 'FROM_UNIXTIME(1537024679)' at row 1 diff --git a/mysql-test/r/greedy_search.result-pq b/mysql-test/r/greedy_search.result-pq new file mode 100644 index 000000000000..de716d4bb7c9 --- /dev/null +++ b/mysql-test/r/greedy_search.result-pq @@ -0,0 +1,220 @@ +UPDATE mysql.engine_cost +SET cost_value = 1.0 +WHERE cost_name = 'memory_block_read_cost'; +FLUSH OPTIMIZER_COSTS; +# +# TEST 1 +# Greedy search iteration test for 16-way join: star schema +# +# Creation of 16 tables hidden +# +SET SESSION optimizer_search_depth = 25; +FLUSH STATUS; +# +# 16-way join - all 15 fact tables joined on column with key +# +EXPLAIN SELECT * +FROM vehicles +JOIN models ON vehicles.model_id = models.id_pk +JOIN subtypes ON vehicles.subtype_id = subtypes.id_pk +JOIN colors ON vehicles.color_id = colors.id_pk +JOIN heating ON vehicles.heating_id = heating.id_pk +JOIN windows ON vehicles.window_id = windows.id_pk +JOIN fuels ON vehicles.fuel_id = fuels.id_pk +JOIN transmissions ON vehicles.transmission_id = transmissions.id_pk +JOIN steerings ON vehicles.steering_id = steerings.id_pk +JOIN interiors ON vehicles.interior_id = interiors.id_pk +JOIN drives ON vehicles.drive_id = drives.id_pk +JOIN wheels ON vehicles.wheels_id = wheels.id_pk +JOIN engine ON vehicles.engine_id = engine.id_pk +JOIN price_ranges ON vehicles.price_range_id = price_ranges.id_pk +JOIN countries ON vehicles.assembled_in = countries.id_pk +JOIN brands ON models.brand_id = brands.id_pk; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 100.00 Parallel execute (1 workers) +2 SIMPLE subtypes NULL ALL PRIMARY NULL NULL NULL 10 100.00 NULL +2 SIMPLE vehicles NULL ALL NULL NULL NULL NULL 80 10.00 Using where; Using join buffer (hash join) +2 SIMPLE heating NULL eq_ref PRIMARY PRIMARY 4 test.vehicles.heating_id 1 100.00 NULL +2 SIMPLE windows NULL eq_ref PRIMARY PRIMARY 4 test.vehicles.window_id 1 100.00 NULL +2 SIMPLE fuels NULL eq_ref PRIMARY PRIMARY 4 test.vehicles.fuel_id 1 100.00 NULL +2 SIMPLE transmissions NULL eq_ref PRIMARY PRIMARY 4 test.vehicles.transmission_id 1 100.00 NULL +2 SIMPLE steerings NULL eq_ref PRIMARY PRIMARY 4 test.vehicles.steering_id 1 100.00 NULL +2 SIMPLE drives NULL eq_ref PRIMARY PRIMARY 4 test.vehicles.drive_id 1 100.00 NULL +2 SIMPLE wheels NULL eq_ref PRIMARY PRIMARY 4 test.vehicles.wheels_id 1 100.00 NULL +2 SIMPLE engine NULL eq_ref PRIMARY PRIMARY 4 test.vehicles.engine_id 1 100.00 NULL +2 SIMPLE price_ranges NULL eq_ref PRIMARY PRIMARY 4 test.vehicles.price_range_id 1 100.00 NULL +2 SIMPLE colors NULL eq_ref PRIMARY PRIMARY 4 test.vehicles.color_id 1 100.00 NULL +2 SIMPLE interiors NULL eq_ref PRIMARY PRIMARY 4 test.vehicles.interior_id 1 100.00 NULL +2 SIMPLE countries NULL eq_ref PRIMARY PRIMARY 4 test.vehicles.assembled_in 1 100.00 NULL +2 SIMPLE models NULL eq_ref PRIMARY,brand_id PRIMARY 4 test.vehicles.model_id 1 100.00 Using where +2 SIMPLE brands NULL eq_ref PRIMARY PRIMARY 4 test.models.brand_id 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`vehicles`.`id` AS `id`,`test`.`vehicles`.`model_id` AS `model_id`,`test`.`vehicles`.`subtype_id` AS `subtype_id`,`test`.`vehicles`.`color_id` AS `color_id`,`test`.`vehicles`.`heating_id` AS `heating_id`,`test`.`vehicles`.`window_id` AS `window_id`,`test`.`vehicles`.`fuel_id` AS `fuel_id`,`test`.`vehicles`.`transmission_id` AS `transmission_id`,`test`.`vehicles`.`steering_id` AS `steering_id`,`test`.`vehicles`.`interior_id` AS `interior_id`,`test`.`vehicles`.`drive_id` AS `drive_id`,`test`.`vehicles`.`price_range_id` AS `price_range_id`,`test`.`vehicles`.`assembled_in` AS `assembled_in`,`test`.`vehicles`.`engine_id` AS `engine_id`,`test`.`vehicles`.`wheels_id` AS `wheels_id`,`test`.`models`.`id_pk` AS `id_pk`,`test`.`models`.`id_nokey` AS `id_nokey`,`test`.`models`.`brand_id` AS `brand_id`,`test`.`models`.`name` AS `name`,`test`.`subtypes`.`id_pk` AS `id_pk`,`test`.`subtypes`.`id_nokey` AS `id_nokey`,`test`.`subtypes`.`name` AS `name`,`test`.`colors`.`id_pk` AS `id_pk`,`test`.`colors`.`id_nokey` AS `id_nokey`,`test`.`colors`.`name` AS `name`,`test`.`heating`.`id_pk` AS `id_pk`,`test`.`heating`.`id_nokey` AS `id_nokey`,`test`.`heating`.`name` AS `name`,`test`.`windows`.`id_pk` AS `id_pk`,`test`.`windows`.`id_nokey` AS `id_nokey`,`test`.`windows`.`name` AS `name`,`test`.`fuels`.`id_pk` AS `id_pk`,`test`.`fuels`.`id_nokey` AS `id_nokey`,`test`.`fuels`.`name` AS `name`,`test`.`transmissions`.`id_pk` AS `id_pk`,`test`.`transmissions`.`id_nokey` AS `id_nokey`,`test`.`transmissions`.`name` AS `name`,`test`.`steerings`.`id_pk` AS `id_pk`,`test`.`steerings`.`id_nokey` AS `id_nokey`,`test`.`steerings`.`name` AS `name`,`test`.`interiors`.`id_pk` AS `id_pk`,`test`.`interiors`.`id_nokey` AS `id_nokey`,`test`.`interiors`.`name` AS `name`,`test`.`drives`.`id_pk` AS `id_pk`,`test`.`drives`.`id_nokey` AS `id_nokey`,`test`.`drives`.`name` AS `name`,`test`.`wheels`.`id_pk` AS `id_pk`,`test`.`wheels`.`id_nokey` AS `id_nokey`,`test`.`wheels`.`name` AS `name`,`test`.`engine`.`id_pk` AS `id_pk`,`test`.`engine`.`id_nokey` AS `id_nokey`,`test`.`engine`.`name` AS `name`,`test`.`price_ranges`.`id_pk` AS `id_pk`,`test`.`price_ranges`.`id_nokey` AS `id_nokey`,`test`.`price_ranges`.`name` AS `name`,`test`.`countries`.`id_pk` AS `id_pk`,`test`.`countries`.`id_nokey` AS `id_nokey`,`test`.`countries`.`name` AS `name`,`test`.`brands`.`id_pk` AS `id_pk`,`test`.`brands`.`id_nokey` AS `id_nokey`,`test`.`brands`.`name` AS `name` from `test`.`vehicles` join `test`.`models` join `test`.`subtypes` join `test`.`colors` join `test`.`heating` join `test`.`windows` join `test`.`fuels` join `test`.`transmissions` join `test`.`steerings` join `test`.`interiors` join `test`.`drives` join `test`.`wheels` join `test`.`engine` join `test`.`price_ranges` join `test`.`countries` join `test`.`brands` where ((`test`.`models`.`id_pk` = `test`.`vehicles`.`model_id`) and (`test`.`vehicles`.`subtype_id` = `test`.`subtypes`.`id_pk`) and (`test`.`colors`.`id_pk` = `test`.`vehicles`.`color_id`) and (`test`.`heating`.`id_pk` = `test`.`vehicles`.`heating_id`) and (`test`.`windows`.`id_pk` = `test`.`vehicles`.`window_id`) and (`test`.`fuels`.`id_pk` = `test`.`vehicles`.`fuel_id`) and (`test`.`transmissions`.`id_pk` = `test`.`vehicles`.`transmission_id`) and (`test`.`steerings`.`id_pk` = `test`.`vehicles`.`steering_id`) and (`test`.`interiors`.`id_pk` = `test`.`vehicles`.`interior_id`) and (`test`.`drives`.`id_pk` = `test`.`vehicles`.`drive_id`) and (`test`.`wheels`.`id_pk` = `test`.`vehicles`.`wheels_id`) and (`test`.`engine`.`id_pk` = `test`.`vehicles`.`engine_id`) and (`test`.`price_ranges`.`id_pk` = `test`.`vehicles`.`price_range_id`) and (`test`.`countries`.`id_pk` = `test`.`vehicles`.`assembled_in`) and (`test`.`brands`.`id_pk` = `test`.`models`.`brand_id`)) +### Partial_plans: 338288 +FLUSH STATUS; +# +# 16-way join - 10 fact tables joined on column with key and +# 5 fact tables joined on column without key +# +EXPLAIN SELECT * +FROM vehicles +JOIN models ON vehicles.model_id = models.id_nokey +JOIN subtypes ON vehicles.subtype_id = subtypes.id_pk +JOIN colors ON vehicles.color_id = colors.id_pk +JOIN heating ON vehicles.heating_id = heating.id_nokey +JOIN windows ON vehicles.window_id = windows.id_pk +JOIN fuels ON vehicles.fuel_id = fuels.id_pk +JOIN transmissions ON vehicles.transmission_id = transmissions.id_nokey +JOIN steerings ON vehicles.steering_id = steerings.id_pk +JOIN interiors ON vehicles.interior_id = interiors.id_pk +JOIN drives ON vehicles.drive_id = drives.id_pk +JOIN wheels ON vehicles.wheels_id = wheels.id_nokey +JOIN engine ON vehicles.engine_id = engine.id_pk +JOIN price_ranges ON vehicles.price_range_id = price_ranges.id_pk +JOIN countries ON vehicles.assembled_in = countries.id_pk +JOIN brands ON models.brand_id = brands.id_nokey; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 100.00 Parallel execute (1 workers) +2 SIMPLE brands NULL ALL NULL NULL NULL NULL 7 100.00 Using where +2 SIMPLE models NULL ref brand_id brand_id 5 test.brands.id_nokey 5 100.00 NULL +2 SIMPLE vehicles NULL ALL NULL NULL NULL NULL 80 10.00 Using where; Using join buffer (hash join) +2 SIMPLE heating NULL ALL NULL NULL NULL NULL 10 10.00 Using where; Using join buffer (hash join) +2 SIMPLE windows NULL eq_ref PRIMARY PRIMARY 4 test.vehicles.window_id 1 100.00 NULL +2 SIMPLE fuels NULL eq_ref PRIMARY PRIMARY 4 test.vehicles.fuel_id 1 100.00 NULL +2 SIMPLE steerings NULL eq_ref PRIMARY PRIMARY 4 test.vehicles.steering_id 1 100.00 NULL +2 SIMPLE drives NULL eq_ref PRIMARY PRIMARY 4 test.vehicles.drive_id 1 100.00 NULL +2 SIMPLE engine NULL eq_ref PRIMARY PRIMARY 4 test.vehicles.engine_id 1 100.00 NULL +2 SIMPLE price_ranges NULL eq_ref PRIMARY PRIMARY 4 test.vehicles.price_range_id 1 100.00 NULL +2 SIMPLE interiors NULL eq_ref PRIMARY PRIMARY 4 test.vehicles.interior_id 1 100.00 NULL +2 SIMPLE countries NULL eq_ref PRIMARY PRIMARY 4 test.vehicles.assembled_in 1 100.00 NULL +2 SIMPLE subtypes NULL eq_ref PRIMARY PRIMARY 4 test.vehicles.subtype_id 1 100.00 NULL +2 SIMPLE colors NULL eq_ref PRIMARY PRIMARY 4 test.vehicles.color_id 1 100.00 NULL +2 SIMPLE transmissions NULL ALL NULL NULL NULL NULL 10 10.00 Using where; Using join buffer (hash join) +2 SIMPLE wheels NULL ALL NULL NULL NULL NULL 10 10.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`vehicles`.`id` AS `id`,`test`.`vehicles`.`model_id` AS `model_id`,`test`.`vehicles`.`subtype_id` AS `subtype_id`,`test`.`vehicles`.`color_id` AS `color_id`,`test`.`vehicles`.`heating_id` AS `heating_id`,`test`.`vehicles`.`window_id` AS `window_id`,`test`.`vehicles`.`fuel_id` AS `fuel_id`,`test`.`vehicles`.`transmission_id` AS `transmission_id`,`test`.`vehicles`.`steering_id` AS `steering_id`,`test`.`vehicles`.`interior_id` AS `interior_id`,`test`.`vehicles`.`drive_id` AS `drive_id`,`test`.`vehicles`.`price_range_id` AS `price_range_id`,`test`.`vehicles`.`assembled_in` AS `assembled_in`,`test`.`vehicles`.`engine_id` AS `engine_id`,`test`.`vehicles`.`wheels_id` AS `wheels_id`,`test`.`models`.`id_pk` AS `id_pk`,`test`.`models`.`id_nokey` AS `id_nokey`,`test`.`models`.`brand_id` AS `brand_id`,`test`.`models`.`name` AS `name`,`test`.`subtypes`.`id_pk` AS `id_pk`,`test`.`subtypes`.`id_nokey` AS `id_nokey`,`test`.`subtypes`.`name` AS `name`,`test`.`colors`.`id_pk` AS `id_pk`,`test`.`colors`.`id_nokey` AS `id_nokey`,`test`.`colors`.`name` AS `name`,`test`.`heating`.`id_pk` AS `id_pk`,`test`.`heating`.`id_nokey` AS `id_nokey`,`test`.`heating`.`name` AS `name`,`test`.`windows`.`id_pk` AS `id_pk`,`test`.`windows`.`id_nokey` AS `id_nokey`,`test`.`windows`.`name` AS `name`,`test`.`fuels`.`id_pk` AS `id_pk`,`test`.`fuels`.`id_nokey` AS `id_nokey`,`test`.`fuels`.`name` AS `name`,`test`.`transmissions`.`id_pk` AS `id_pk`,`test`.`transmissions`.`id_nokey` AS `id_nokey`,`test`.`transmissions`.`name` AS `name`,`test`.`steerings`.`id_pk` AS `id_pk`,`test`.`steerings`.`id_nokey` AS `id_nokey`,`test`.`steerings`.`name` AS `name`,`test`.`interiors`.`id_pk` AS `id_pk`,`test`.`interiors`.`id_nokey` AS `id_nokey`,`test`.`interiors`.`name` AS `name`,`test`.`drives`.`id_pk` AS `id_pk`,`test`.`drives`.`id_nokey` AS `id_nokey`,`test`.`drives`.`name` AS `name`,`test`.`wheels`.`id_pk` AS `id_pk`,`test`.`wheels`.`id_nokey` AS `id_nokey`,`test`.`wheels`.`name` AS `name`,`test`.`engine`.`id_pk` AS `id_pk`,`test`.`engine`.`id_nokey` AS `id_nokey`,`test`.`engine`.`name` AS `name`,`test`.`price_ranges`.`id_pk` AS `id_pk`,`test`.`price_ranges`.`id_nokey` AS `id_nokey`,`test`.`price_ranges`.`name` AS `name`,`test`.`countries`.`id_pk` AS `id_pk`,`test`.`countries`.`id_nokey` AS `id_nokey`,`test`.`countries`.`name` AS `name`,`test`.`brands`.`id_pk` AS `id_pk`,`test`.`brands`.`id_nokey` AS `id_nokey`,`test`.`brands`.`name` AS `name` from `test`.`vehicles` join `test`.`models` join `test`.`subtypes` join `test`.`colors` join `test`.`heating` join `test`.`windows` join `test`.`fuels` join `test`.`transmissions` join `test`.`steerings` join `test`.`interiors` join `test`.`drives` join `test`.`wheels` join `test`.`engine` join `test`.`price_ranges` join `test`.`countries` join `test`.`brands` where ((`test`.`vehicles`.`model_id` = `test`.`models`.`id_nokey`) and (`test`.`subtypes`.`id_pk` = `test`.`vehicles`.`subtype_id`) and (`test`.`colors`.`id_pk` = `test`.`vehicles`.`color_id`) and (`test`.`heating`.`id_nokey` = `test`.`vehicles`.`heating_id`) and (`test`.`windows`.`id_pk` = `test`.`vehicles`.`window_id`) and (`test`.`fuels`.`id_pk` = `test`.`vehicles`.`fuel_id`) and (`test`.`transmissions`.`id_nokey` = `test`.`vehicles`.`transmission_id`) and (`test`.`steerings`.`id_pk` = `test`.`vehicles`.`steering_id`) and (`test`.`interiors`.`id_pk` = `test`.`vehicles`.`interior_id`) and (`test`.`drives`.`id_pk` = `test`.`vehicles`.`drive_id`) and (`test`.`wheels`.`id_nokey` = `test`.`vehicles`.`wheels_id`) and (`test`.`engine`.`id_pk` = `test`.`vehicles`.`engine_id`) and (`test`.`price_ranges`.`id_pk` = `test`.`vehicles`.`price_range_id`) and (`test`.`countries`.`id_pk` = `test`.`vehicles`.`assembled_in`) and (`test`.`models`.`brand_id` = `test`.`brands`.`id_nokey`)) +### Partial_plans: 3296 +FLUSH STATUS; +select @@optimizer_search_depth; +@@optimizer_search_depth +25 +select @@optimizer_prune_level; +@@optimizer_prune_level +1 +DROP TABLE vehicles, models, subtypes, colors, heating, windows, +fuels, transmissions, steerings, interiors, drives, +price_ranges, countries, brands, wheels, engine; +# +# TEST 2 +# Greedy search iteration test for chain of tables +# +# +# Chain test a: colidx):(pk,colidx):(pk,colidx) +# +EXPLAIN SELECT * FROM t10_1 JOIN t100_1 ON t10_1.colidx = t100_1.pk JOIN t10_2 ON t100_1.colidx = t10_2.pk JOIN t100_2 ON t10_2.colidx = t100_2.pk JOIN t10_3 ON t100_2.colidx = t10_3.pk JOIN t100_3 ON t10_3.colidx = t100_3.pk JOIN t10_4 ON t100_3.colidx = t10_4.pk JOIN t100_4 ON t10_4.colidx = t100_4.pk JOIN t10_5 ON t100_4.colidx = t10_5.pk JOIN t100_5 ON t10_5.colidx = t100_5.pk JOIN t10_6 ON t100_5.colidx = t10_6.pk JOIN t100_6 ON t10_6.colidx = t100_6.pk JOIN t10_7 ON t100_6.colidx = t10_7.pk JOIN t100_7 ON t10_7.colidx = t100_7.pk JOIN t10_8 ON t100_7.colidx = t10_8.pk; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 100.00 Parallel execute (1 workers) +2 SIMPLE t10_1 NULL ALL colidx NULL NULL NULL 10 100.00 Using where +2 SIMPLE t10_2 NULL ALL PRIMARY,colidx NULL NULL NULL 10 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t100_1 NULL eq_ref PRIMARY,colidx PRIMARY 4 test.t10_1.colidx 1 10.00 Using where +2 SIMPLE t100_2 NULL eq_ref PRIMARY,colidx PRIMARY 4 test.t10_2.colidx 1 100.00 Using where +2 SIMPLE t10_3 NULL eq_ref PRIMARY,colidx PRIMARY 4 test.t100_2.colidx 1 100.00 Using where +2 SIMPLE t100_3 NULL eq_ref PRIMARY,colidx PRIMARY 4 test.t10_3.colidx 1 100.00 Using where +2 SIMPLE t10_4 NULL eq_ref PRIMARY,colidx PRIMARY 4 test.t100_3.colidx 1 100.00 Using where +2 SIMPLE t100_4 NULL eq_ref PRIMARY,colidx PRIMARY 4 test.t10_4.colidx 1 100.00 Using where +2 SIMPLE t10_5 NULL eq_ref PRIMARY,colidx PRIMARY 4 test.t100_4.colidx 1 100.00 Using where +2 SIMPLE t100_5 NULL eq_ref PRIMARY,colidx PRIMARY 4 test.t10_5.colidx 1 100.00 Using where +2 SIMPLE t10_6 NULL eq_ref PRIMARY,colidx PRIMARY 4 test.t100_5.colidx 1 100.00 Using where +2 SIMPLE t100_6 NULL eq_ref PRIMARY,colidx PRIMARY 4 test.t10_6.colidx 1 100.00 Using where +2 SIMPLE t10_7 NULL eq_ref PRIMARY,colidx PRIMARY 4 test.t100_6.colidx 1 100.00 Using where +2 SIMPLE t100_7 NULL eq_ref PRIMARY,colidx PRIMARY 4 test.t10_7.colidx 1 100.00 Using where +2 SIMPLE t10_8 NULL eq_ref PRIMARY PRIMARY 4 test.t100_7.colidx 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t10_1`.`pk` AS `pk`,`test`.`t10_1`.`colidx` AS `colidx`,`test`.`t10_1`.`col` AS `col`,`test`.`t100_1`.`pk` AS `pk`,`test`.`t100_1`.`colidx` AS `colidx`,`test`.`t100_1`.`col` AS `col`,`test`.`t10_2`.`pk` AS `pk`,`test`.`t10_2`.`colidx` AS `colidx`,`test`.`t10_2`.`col` AS `col`,`test`.`t100_2`.`pk` AS `pk`,`test`.`t100_2`.`colidx` AS `colidx`,`test`.`t100_2`.`col` AS `col`,`test`.`t10_3`.`pk` AS `pk`,`test`.`t10_3`.`colidx` AS `colidx`,`test`.`t10_3`.`col` AS `col`,`test`.`t100_3`.`pk` AS `pk`,`test`.`t100_3`.`colidx` AS `colidx`,`test`.`t100_3`.`col` AS `col`,`test`.`t10_4`.`pk` AS `pk`,`test`.`t10_4`.`colidx` AS `colidx`,`test`.`t10_4`.`col` AS `col`,`test`.`t100_4`.`pk` AS `pk`,`test`.`t100_4`.`colidx` AS `colidx`,`test`.`t100_4`.`col` AS `col`,`test`.`t10_5`.`pk` AS `pk`,`test`.`t10_5`.`colidx` AS `colidx`,`test`.`t10_5`.`col` AS `col`,`test`.`t100_5`.`pk` AS `pk`,`test`.`t100_5`.`colidx` AS `colidx`,`test`.`t100_5`.`col` AS `col`,`test`.`t10_6`.`pk` AS `pk`,`test`.`t10_6`.`colidx` AS `colidx`,`test`.`t10_6`.`col` AS `col`,`test`.`t100_6`.`pk` AS `pk`,`test`.`t100_6`.`colidx` AS `colidx`,`test`.`t100_6`.`col` AS `col`,`test`.`t10_7`.`pk` AS `pk`,`test`.`t10_7`.`colidx` AS `colidx`,`test`.`t10_7`.`col` AS `col`,`test`.`t100_7`.`pk` AS `pk`,`test`.`t100_7`.`colidx` AS `colidx`,`test`.`t100_7`.`col` AS `col`,`test`.`t10_8`.`pk` AS `pk`,`test`.`t10_8`.`colidx` AS `colidx`,`test`.`t10_8`.`col` AS `col` from `test`.`t10_1` join `test`.`t100_1` join `test`.`t10_2` join `test`.`t100_2` join `test`.`t10_3` join `test`.`t100_3` join `test`.`t10_4` join `test`.`t100_4` join `test`.`t10_5` join `test`.`t100_5` join `test`.`t10_6` join `test`.`t100_6` join `test`.`t10_7` join `test`.`t100_7` join `test`.`t10_8` where ((`test`.`t100_1`.`pk` = `test`.`t10_1`.`colidx`) and (`test`.`t100_1`.`colidx` = `test`.`t10_2`.`pk`) and (`test`.`t100_2`.`pk` = `test`.`t10_2`.`colidx`) and (`test`.`t10_3`.`pk` = `test`.`t100_2`.`colidx`) and (`test`.`t100_3`.`pk` = `test`.`t10_3`.`colidx`) and (`test`.`t10_4`.`pk` = `test`.`t100_3`.`colidx`) and (`test`.`t100_4`.`pk` = `test`.`t10_4`.`colidx`) and (`test`.`t10_5`.`pk` = `test`.`t100_4`.`colidx`) and (`test`.`t100_5`.`pk` = `test`.`t10_5`.`colidx`) and (`test`.`t10_6`.`pk` = `test`.`t100_5`.`colidx`) and (`test`.`t100_6`.`pk` = `test`.`t10_6`.`colidx`) and (`test`.`t10_7`.`pk` = `test`.`t100_6`.`colidx`) and (`test`.`t100_7`.`pk` = `test`.`t10_7`.`colidx`) and (`test`.`t10_8`.`pk` = `test`.`t100_7`.`colidx`)) +### Partial_plans: 9123 +FLUSH STATUS; +# +# Chain test b: (...,col):(colidx, col):(pk,col):(colidx,col):(pk,...) +# +EXPLAIN SELECT * FROM t10_1 JOIN t100_1 ON t10_1.col = t100_1.colidx JOIN t10_2 ON t100_1.col = t10_2.pk JOIN t100_2 ON t10_2.col = t100_2.colidx JOIN t10_3 ON t100_2.col = t10_3.pk JOIN t100_3 ON t10_3.col = t100_3.colidx JOIN t10_4 ON t100_3.col = t10_4.pk JOIN t100_4 ON t10_4.col = t100_4.colidx JOIN t10_5 ON t100_4.col = t10_5.pk JOIN t100_5 ON t10_5.col = t100_5.colidx JOIN t10_6 ON t100_5.col = t10_6.pk JOIN t100_6 ON t10_6.col = t100_6.colidx JOIN t10_7 ON t100_6.col = t10_7.pk JOIN t100_7 ON t10_7.col = t100_7.colidx JOIN t10_8 ON t100_7.col = t10_8.pk; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 100.00 Parallel execute (1 workers) +2 SIMPLE t10_1 NULL ALL NULL NULL NULL NULL 10 100.00 Using where +2 SIMPLE t100_1 NULL ref colidx colidx 5 test.t10_1.col 10 100.00 NULL +2 SIMPLE t10_2 NULL ALL PRIMARY NULL NULL NULL 10 10.00 Using where; Using join buffer (hash join) +2 SIMPLE t100_2 NULL ref colidx colidx 5 test.t10_2.col 10 100.00 Using where +2 SIMPLE t10_3 NULL eq_ref PRIMARY PRIMARY 4 test.t100_2.col 1 100.00 Using where +2 SIMPLE t10_4 NULL ALL PRIMARY NULL NULL NULL 10 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t100_3 NULL ref colidx colidx 5 test.t10_3.col 10 10.00 Using where +2 SIMPLE t100_4 NULL ref colidx colidx 5 test.t10_4.col 10 100.00 Using where +2 SIMPLE t10_5 NULL eq_ref PRIMARY PRIMARY 4 test.t100_4.col 1 100.00 Using where +2 SIMPLE t100_5 NULL ref colidx colidx 5 test.t10_5.col 10 100.00 Using where +2 SIMPLE t10_6 NULL eq_ref PRIMARY PRIMARY 4 test.t100_5.col 1 100.00 Using where +2 SIMPLE t100_6 NULL ref colidx colidx 5 test.t10_6.col 10 100.00 Using where +2 SIMPLE t10_7 NULL eq_ref PRIMARY PRIMARY 4 test.t100_6.col 1 100.00 Using where +2 SIMPLE t100_7 NULL ref colidx colidx 5 test.t10_7.col 10 100.00 Using where +2 SIMPLE t10_8 NULL eq_ref PRIMARY PRIMARY 4 test.t100_7.col 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t10_1`.`pk` AS `pk`,`test`.`t10_1`.`colidx` AS `colidx`,`test`.`t10_1`.`col` AS `col`,`test`.`t100_1`.`pk` AS `pk`,`test`.`t100_1`.`colidx` AS `colidx`,`test`.`t100_1`.`col` AS `col`,`test`.`t10_2`.`pk` AS `pk`,`test`.`t10_2`.`colidx` AS `colidx`,`test`.`t10_2`.`col` AS `col`,`test`.`t100_2`.`pk` AS `pk`,`test`.`t100_2`.`colidx` AS `colidx`,`test`.`t100_2`.`col` AS `col`,`test`.`t10_3`.`pk` AS `pk`,`test`.`t10_3`.`colidx` AS `colidx`,`test`.`t10_3`.`col` AS `col`,`test`.`t100_3`.`pk` AS `pk`,`test`.`t100_3`.`colidx` AS `colidx`,`test`.`t100_3`.`col` AS `col`,`test`.`t10_4`.`pk` AS `pk`,`test`.`t10_4`.`colidx` AS `colidx`,`test`.`t10_4`.`col` AS `col`,`test`.`t100_4`.`pk` AS `pk`,`test`.`t100_4`.`colidx` AS `colidx`,`test`.`t100_4`.`col` AS `col`,`test`.`t10_5`.`pk` AS `pk`,`test`.`t10_5`.`colidx` AS `colidx`,`test`.`t10_5`.`col` AS `col`,`test`.`t100_5`.`pk` AS `pk`,`test`.`t100_5`.`colidx` AS `colidx`,`test`.`t100_5`.`col` AS `col`,`test`.`t10_6`.`pk` AS `pk`,`test`.`t10_6`.`colidx` AS `colidx`,`test`.`t10_6`.`col` AS `col`,`test`.`t100_6`.`pk` AS `pk`,`test`.`t100_6`.`colidx` AS `colidx`,`test`.`t100_6`.`col` AS `col`,`test`.`t10_7`.`pk` AS `pk`,`test`.`t10_7`.`colidx` AS `colidx`,`test`.`t10_7`.`col` AS `col`,`test`.`t100_7`.`pk` AS `pk`,`test`.`t100_7`.`colidx` AS `colidx`,`test`.`t100_7`.`col` AS `col`,`test`.`t10_8`.`pk` AS `pk`,`test`.`t10_8`.`colidx` AS `colidx`,`test`.`t10_8`.`col` AS `col` from `test`.`t10_1` join `test`.`t100_1` join `test`.`t10_2` join `test`.`t100_2` join `test`.`t10_3` join `test`.`t100_3` join `test`.`t10_4` join `test`.`t100_4` join `test`.`t10_5` join `test`.`t100_5` join `test`.`t10_6` join `test`.`t100_6` join `test`.`t10_7` join `test`.`t100_7` join `test`.`t10_8` where ((`test`.`t100_1`.`colidx` = `test`.`t10_1`.`col`) and (`test`.`t10_2`.`pk` = `test`.`t100_1`.`col`) and (`test`.`t100_2`.`colidx` = `test`.`t10_2`.`col`) and (`test`.`t10_3`.`pk` = `test`.`t100_2`.`col`) and (`test`.`t100_3`.`colidx` = `test`.`t10_3`.`col`) and (`test`.`t100_3`.`col` = `test`.`t10_4`.`pk`) and (`test`.`t100_4`.`colidx` = `test`.`t10_4`.`col`) and (`test`.`t10_5`.`pk` = `test`.`t100_4`.`col`) and (`test`.`t100_5`.`colidx` = `test`.`t10_5`.`col`) and (`test`.`t10_6`.`pk` = `test`.`t100_5`.`col`) and (`test`.`t100_6`.`colidx` = `test`.`t10_6`.`col`) and (`test`.`t10_7`.`pk` = `test`.`t100_6`.`col`) and (`test`.`t100_7`.`colidx` = `test`.`t10_7`.`col`) and (`test`.`t10_8`.`pk` = `test`.`t100_7`.`col`)) +### Partial_plans: 5799059 +FLUSH STATUS; +# +# Chain test c: (...,colidx):(col, pk):(col,colidx):(col,...) +# +EXPLAIN SELECT * FROM t10_1 JOIN t100_1 ON t10_1.colidx = t100_1.col JOIN t10_2 ON t100_1.pk = t10_2.col JOIN t100_2 ON t10_2.colidx = t100_2.col JOIN t10_3 ON t100_2.pk = t10_3.col JOIN t100_3 ON t10_3.colidx = t100_3.col JOIN t10_4 ON t100_3.pk = t10_4.col JOIN t100_4 ON t10_4.colidx = t100_4.col JOIN t10_5 ON t100_4.pk = t10_5.col JOIN t100_5 ON t10_5.colidx = t100_5.col JOIN t10_6 ON t100_5.pk = t10_6.col JOIN t100_6 ON t10_6.colidx = t100_6.col JOIN t10_7 ON t100_6.pk = t10_7.col JOIN t100_7 ON t10_7.colidx = t100_7.col JOIN t10_8 ON t100_7.pk = t10_8.col; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 100.00 Parallel execute (1 workers) +2 SIMPLE t10_7 NULL ALL colidx NULL NULL NULL 10 100.00 Using where +2 SIMPLE t10_8 NULL ALL NULL NULL NULL NULL 10 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t100_6 NULL eq_ref PRIMARY PRIMARY 4 test.t10_7.col 1 100.00 Using where +2 SIMPLE t100_7 NULL eq_ref PRIMARY PRIMARY 4 test.t10_8.col 1 10.00 Using where +2 SIMPLE t10_6 NULL ref colidx colidx 5 test.t100_6.col 1 100.00 Using where +2 SIMPLE t100_5 NULL eq_ref PRIMARY PRIMARY 4 test.t10_6.col 1 100.00 Using where +2 SIMPLE t10_5 NULL ref colidx colidx 5 test.t100_5.col 1 100.00 Using where +2 SIMPLE t100_4 NULL eq_ref PRIMARY PRIMARY 4 test.t10_5.col 1 100.00 Using where +2 SIMPLE t10_4 NULL ref colidx colidx 5 test.t100_4.col 1 100.00 Using where +2 SIMPLE t100_3 NULL eq_ref PRIMARY PRIMARY 4 test.t10_4.col 1 100.00 Using where +2 SIMPLE t10_3 NULL ref colidx colidx 5 test.t100_3.col 1 100.00 Using where +2 SIMPLE t100_2 NULL eq_ref PRIMARY PRIMARY 4 test.t10_3.col 1 100.00 Using where +2 SIMPLE t10_2 NULL ref colidx colidx 5 test.t100_2.col 1 100.00 Using where +2 SIMPLE t100_1 NULL eq_ref PRIMARY PRIMARY 4 test.t10_2.col 1 100.00 Using where +2 SIMPLE t10_1 NULL ref colidx colidx 5 test.t100_1.col 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t10_1`.`pk` AS `pk`,`test`.`t10_1`.`colidx` AS `colidx`,`test`.`t10_1`.`col` AS `col`,`test`.`t100_1`.`pk` AS `pk`,`test`.`t100_1`.`colidx` AS `colidx`,`test`.`t100_1`.`col` AS `col`,`test`.`t10_2`.`pk` AS `pk`,`test`.`t10_2`.`colidx` AS `colidx`,`test`.`t10_2`.`col` AS `col`,`test`.`t100_2`.`pk` AS `pk`,`test`.`t100_2`.`colidx` AS `colidx`,`test`.`t100_2`.`col` AS `col`,`test`.`t10_3`.`pk` AS `pk`,`test`.`t10_3`.`colidx` AS `colidx`,`test`.`t10_3`.`col` AS `col`,`test`.`t100_3`.`pk` AS `pk`,`test`.`t100_3`.`colidx` AS `colidx`,`test`.`t100_3`.`col` AS `col`,`test`.`t10_4`.`pk` AS `pk`,`test`.`t10_4`.`colidx` AS `colidx`,`test`.`t10_4`.`col` AS `col`,`test`.`t100_4`.`pk` AS `pk`,`test`.`t100_4`.`colidx` AS `colidx`,`test`.`t100_4`.`col` AS `col`,`test`.`t10_5`.`pk` AS `pk`,`test`.`t10_5`.`colidx` AS `colidx`,`test`.`t10_5`.`col` AS `col`,`test`.`t100_5`.`pk` AS `pk`,`test`.`t100_5`.`colidx` AS `colidx`,`test`.`t100_5`.`col` AS `col`,`test`.`t10_6`.`pk` AS `pk`,`test`.`t10_6`.`colidx` AS `colidx`,`test`.`t10_6`.`col` AS `col`,`test`.`t100_6`.`pk` AS `pk`,`test`.`t100_6`.`colidx` AS `colidx`,`test`.`t100_6`.`col` AS `col`,`test`.`t10_7`.`pk` AS `pk`,`test`.`t10_7`.`colidx` AS `colidx`,`test`.`t10_7`.`col` AS `col`,`test`.`t100_7`.`pk` AS `pk`,`test`.`t100_7`.`colidx` AS `colidx`,`test`.`t100_7`.`col` AS `col`,`test`.`t10_8`.`pk` AS `pk`,`test`.`t10_8`.`colidx` AS `colidx`,`test`.`t10_8`.`col` AS `col` from `test`.`t10_1` join `test`.`t100_1` join `test`.`t10_2` join `test`.`t100_2` join `test`.`t10_3` join `test`.`t100_3` join `test`.`t10_4` join `test`.`t100_4` join `test`.`t10_5` join `test`.`t100_5` join `test`.`t10_6` join `test`.`t100_6` join `test`.`t10_7` join `test`.`t100_7` join `test`.`t10_8` where ((`test`.`t10_1`.`colidx` = `test`.`t100_1`.`col`) and (`test`.`t100_1`.`pk` = `test`.`t10_2`.`col`) and (`test`.`t10_2`.`colidx` = `test`.`t100_2`.`col`) and (`test`.`t100_2`.`pk` = `test`.`t10_3`.`col`) and (`test`.`t10_3`.`colidx` = `test`.`t100_3`.`col`) and (`test`.`t100_3`.`pk` = `test`.`t10_4`.`col`) and (`test`.`t10_4`.`colidx` = `test`.`t100_4`.`col`) and (`test`.`t100_4`.`pk` = `test`.`t10_5`.`col`) and (`test`.`t10_5`.`colidx` = `test`.`t100_5`.`col`) and (`test`.`t100_5`.`pk` = `test`.`t10_6`.`col`) and (`test`.`t10_6`.`colidx` = `test`.`t100_6`.`col`) and (`test`.`t100_6`.`pk` = `test`.`t10_7`.`col`) and (`test`.`t100_7`.`col` = `test`.`t10_7`.`colidx`) and (`test`.`t100_7`.`pk` = `test`.`t10_8`.`col`)) +### Partial_plans: 13248 +FLUSH STATUS; +# +# Chain test d: (...,colidx):(pk, col):(pk,colidx):(pk,col):(pk,...) +# +EXPLAIN SELECT * FROM t10_1 JOIN t100_1 ON t10_1.colidx = t100_1.pk JOIN t10_2 ON t100_1.col = t10_2.pk JOIN t100_2 ON t10_2.colidx = t100_2.pk JOIN t10_3 ON t100_2.col = t10_3.pk JOIN t100_3 ON t10_3.colidx = t100_3.pk JOIN t10_4 ON t100_3.col = t10_4.pk JOIN t100_4 ON t10_4.colidx = t100_4.pk JOIN t10_5 ON t100_4.col = t10_5.pk JOIN t100_5 ON t10_5.colidx = t100_5.pk JOIN t10_6 ON t100_5.col = t10_6.pk JOIN t100_6 ON t10_6.colidx = t100_6.pk JOIN t10_7 ON t100_6.col = t10_7.pk JOIN t100_7 ON t10_7.colidx = t100_7.pk JOIN t10_8 ON t100_7.col = t10_8.pk; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 100.00 Parallel execute (1 workers) +2 SIMPLE t10_2 NULL ALL PRIMARY,colidx NULL NULL NULL 10 100.00 Using where +2 SIMPLE t10_1 NULL ALL colidx NULL NULL NULL 10 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t100_1 NULL eq_ref PRIMARY PRIMARY 4 test.t10_1.colidx 1 10.00 Using where +2 SIMPLE t100_2 NULL eq_ref PRIMARY PRIMARY 4 test.t10_2.colidx 1 100.00 Using where +2 SIMPLE t10_3 NULL eq_ref PRIMARY,colidx PRIMARY 4 test.t100_2.col 1 100.00 Using where +2 SIMPLE t100_3 NULL eq_ref PRIMARY PRIMARY 4 test.t10_3.colidx 1 100.00 Using where +2 SIMPLE t10_4 NULL eq_ref PRIMARY,colidx PRIMARY 4 test.t100_3.col 1 100.00 Using where +2 SIMPLE t100_4 NULL eq_ref PRIMARY PRIMARY 4 test.t10_4.colidx 1 100.00 Using where +2 SIMPLE t10_5 NULL eq_ref PRIMARY,colidx PRIMARY 4 test.t100_4.col 1 100.00 Using where +2 SIMPLE t100_5 NULL eq_ref PRIMARY PRIMARY 4 test.t10_5.colidx 1 100.00 Using where +2 SIMPLE t10_6 NULL eq_ref PRIMARY,colidx PRIMARY 4 test.t100_5.col 1 100.00 Using where +2 SIMPLE t100_6 NULL eq_ref PRIMARY PRIMARY 4 test.t10_6.colidx 1 100.00 Using where +2 SIMPLE t10_7 NULL eq_ref PRIMARY,colidx PRIMARY 4 test.t100_6.col 1 100.00 Using where +2 SIMPLE t100_7 NULL eq_ref PRIMARY PRIMARY 4 test.t10_7.colidx 1 100.00 Using where +2 SIMPLE t10_8 NULL eq_ref PRIMARY PRIMARY 4 test.t100_7.col 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t10_1`.`pk` AS `pk`,`test`.`t10_1`.`colidx` AS `colidx`,`test`.`t10_1`.`col` AS `col`,`test`.`t100_1`.`pk` AS `pk`,`test`.`t100_1`.`colidx` AS `colidx`,`test`.`t100_1`.`col` AS `col`,`test`.`t10_2`.`pk` AS `pk`,`test`.`t10_2`.`colidx` AS `colidx`,`test`.`t10_2`.`col` AS `col`,`test`.`t100_2`.`pk` AS `pk`,`test`.`t100_2`.`colidx` AS `colidx`,`test`.`t100_2`.`col` AS `col`,`test`.`t10_3`.`pk` AS `pk`,`test`.`t10_3`.`colidx` AS `colidx`,`test`.`t10_3`.`col` AS `col`,`test`.`t100_3`.`pk` AS `pk`,`test`.`t100_3`.`colidx` AS `colidx`,`test`.`t100_3`.`col` AS `col`,`test`.`t10_4`.`pk` AS `pk`,`test`.`t10_4`.`colidx` AS `colidx`,`test`.`t10_4`.`col` AS `col`,`test`.`t100_4`.`pk` AS `pk`,`test`.`t100_4`.`colidx` AS `colidx`,`test`.`t100_4`.`col` AS `col`,`test`.`t10_5`.`pk` AS `pk`,`test`.`t10_5`.`colidx` AS `colidx`,`test`.`t10_5`.`col` AS `col`,`test`.`t100_5`.`pk` AS `pk`,`test`.`t100_5`.`colidx` AS `colidx`,`test`.`t100_5`.`col` AS `col`,`test`.`t10_6`.`pk` AS `pk`,`test`.`t10_6`.`colidx` AS `colidx`,`test`.`t10_6`.`col` AS `col`,`test`.`t100_6`.`pk` AS `pk`,`test`.`t100_6`.`colidx` AS `colidx`,`test`.`t100_6`.`col` AS `col`,`test`.`t10_7`.`pk` AS `pk`,`test`.`t10_7`.`colidx` AS `colidx`,`test`.`t10_7`.`col` AS `col`,`test`.`t100_7`.`pk` AS `pk`,`test`.`t100_7`.`colidx` AS `colidx`,`test`.`t100_7`.`col` AS `col`,`test`.`t10_8`.`pk` AS `pk`,`test`.`t10_8`.`colidx` AS `colidx`,`test`.`t10_8`.`col` AS `col` from `test`.`t10_1` join `test`.`t100_1` join `test`.`t10_2` join `test`.`t100_2` join `test`.`t10_3` join `test`.`t100_3` join `test`.`t10_4` join `test`.`t100_4` join `test`.`t10_5` join `test`.`t100_5` join `test`.`t10_6` join `test`.`t100_6` join `test`.`t10_7` join `test`.`t100_7` join `test`.`t10_8` where ((`test`.`t100_1`.`pk` = `test`.`t10_1`.`colidx`) and (`test`.`t100_1`.`col` = `test`.`t10_2`.`pk`) and (`test`.`t100_2`.`pk` = `test`.`t10_2`.`colidx`) and (`test`.`t10_3`.`pk` = `test`.`t100_2`.`col`) and (`test`.`t100_3`.`pk` = `test`.`t10_3`.`colidx`) and (`test`.`t10_4`.`pk` = `test`.`t100_3`.`col`) and (`test`.`t100_4`.`pk` = `test`.`t10_4`.`colidx`) and (`test`.`t10_5`.`pk` = `test`.`t100_4`.`col`) and (`test`.`t100_5`.`pk` = `test`.`t10_5`.`colidx`) and (`test`.`t10_6`.`pk` = `test`.`t100_5`.`col`) and (`test`.`t100_6`.`pk` = `test`.`t10_6`.`colidx`) and (`test`.`t10_7`.`pk` = `test`.`t100_6`.`col`) and (`test`.`t100_7`.`pk` = `test`.`t10_7`.`colidx`) and (`test`.`t10_8`.`pk` = `test`.`t100_7`.`col`)) +### Partial_plans: 1795 +FLUSH STATUS; +# +# Cleanup after TEST 2 +# +DROP TABLE tbl10, tbl100; +DROP TABLE t10_1,t10_2,t10_3,t10_4,t10_5,t10_6,t10_7,t10_8,t10_9; +DROP TABLE t100_1,t100_2,t100_3,t100_4,t100_5,t100_6,t100_7,t100_8,t100_9; +UPDATE mysql.engine_cost +SET cost_value = DEFAULT +WHERE cost_name = 'memory_block_read_cost'; +FLUSH OPTIMIZER_COSTS; diff --git a/mysql-test/r/group_by.result-pq b/mysql-test/r/group_by.result-pq new file mode 100644 index 000000000000..862a93bf766f --- /dev/null +++ b/mysql-test/r/group_by.result-pq @@ -0,0 +1,4286 @@ +drop table if exists t1,t2,t3; +SET sql_mode = 'NO_ENGINE_SUBSTITUTION'; +SELECT 1 FROM (SELECT 1) as a GROUP BY SUM(1); +ERROR HY000: Invalid use of group function +CREATE TABLE t1 ( +spID int(10) unsigned, +userID int(10) unsigned, +score smallint(5) unsigned, +lsg char(40), +date date +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (1,1,1,'','0000-00-00'); +INSERT INTO t1 VALUES (2,2,2,'','0000-00-00'); +INSERT INTO t1 VALUES (2,1,1,'','0000-00-00'); +INSERT INTO t1 VALUES (3,3,3,'','0000-00-00'); +CREATE TABLE t2 ( +userID int(10) unsigned NOT NULL auto_increment, +niName char(15), +passwd char(8), +mail char(50), +isAukt enum('N','Y') DEFAULT 'N', +vName char(30), +nName char(40), +adr char(60), +plz char(5), +ort char(35), +land char(20), +PRIMARY KEY (userID) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (1,'name','pass','mail','Y','v','n','adr','1','1','1'); +INSERT INTO t2 VALUES (2,'name','pass','mail','Y','v','n','adr','1','1','1'); +INSERT INTO t2 VALUES (3,'name','pass','mail','Y','v','n','adr','1','1','1'); +INSERT INTO t2 VALUES (4,'name','pass','mail','Y','v','n','adr','1','1','1'); +INSERT INTO t2 VALUES (5,'name','pass','mail','Y','v','n','adr','1','1','1'); +ANALYZE TABLE t1,t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN FORMAT=tree SELECT t2.userid, MIN(t1.score) FROM t1, t2 WHERE t1.userID=t2.userID GROUP BY t2.userid; +EXPLAIN +-> Table scan on + -> Aggregate using temporary table + -> Parallel scan on + -> Table scan on + -> Aggregate using temporary table + -> Nested loop inner join (cost=2.05 rows=4) + -> Filter: (t1.userID is not null) (cost=0.65 rows=4) + -> PQblock scan on t1 (cost=0.65 rows=4) + -> Single-row index lookup on t2 using PRIMARY (userID=t1.userID) (cost=0.28 rows=1) + +SELECT t2.userid, MIN(t1.score) FROM t1, t2 WHERE t1.userID=t2.userID GROUP BY t2.userid; +userid MIN(t1.score) +1 1 +2 2 +3 3 +SELECT t2.userid, MIN(t1.score) FROM t1, t2 WHERE t1.userID=t2.userID GROUP BY t2.userid ORDER BY NULL; +userid MIN(t1.score) +1 1 +2 2 +3 3 +SELECT t2.userid, MIN(t1.score) FROM t1, t2 WHERE t1.userID=t2.userID AND t1.spID=2 GROUP BY t2.userid; +userid MIN(t1.score) +1 1 +2 2 +SELECT t2.userid, MIN(t1.score+0.0) FROM t1, t2 WHERE t1.userID=t2.userID AND t1.spID=2 GROUP BY t2.userid; +userid MIN(t1.score+0.0) +1 1.0 +2 2.0 +SELECT t2.userid, MIN(t1.score+0.0) FROM t1, t2 WHERE t1.userID=t2.userID AND t1.spID=2 GROUP BY t2.userid ORDER BY NULL; +userid MIN(t1.score+0.0) +1 1.0 +2 2.0 +EXPLAIN SELECT t2.userid, MIN(t1.score+0.0) FROM t1, t2 WHERE t1.userID=t2.userID AND t1.spID=2 GROUP BY t2.userid ORDER BY NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 25.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; Using temporary +2 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.userID 1 100.00 Using index +Note 1003 /* select#1 */ select `test`.`t2`.`userID` AS `userid`,min((`test`.`t1`.`score` + 0.0)) AS `MIN(t1.score+0.0)` from `test`.`t1` join `test`.`t2` where ((`test`.`t1`.`spID` = 2) and (`test`.`t2`.`userID` = `test`.`t1`.`userID`)) group by `test`.`t2`.`userID` order by NULL +Warnings: +drop table t1,t2; +CREATE TABLE t1 ( +PID int(10) unsigned NOT NULL auto_increment, +payDate date DEFAULT '0000-00-00' NOT NULL, +recDate datetime DEFAULT '0000-00-00 00:00:00' NOT NULL, +URID int(10) unsigned DEFAULT '0' NOT NULL, +CRID int(10) unsigned DEFAULT '0' NOT NULL, +amount int(10) unsigned DEFAULT '0' NOT NULL, +operator int(10) unsigned, +method enum('unknown','cash','dealer','check','card','lazy','delayed','test') DEFAULT 'unknown' NOT NULL, +DIID int(10) unsigned, +reason char(1) binary DEFAULT '' NOT NULL, +code_id int(10) unsigned, +qty mediumint(8) unsigned DEFAULT '0' NOT NULL, +PRIMARY KEY (PID), +KEY URID (URID), +KEY reason (reason), +KEY method (method), +KEY payDate (payDate) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1287 'BINARY as attribute of a type' is deprecated and will be removed in a future release. Please use a CHARACTER SET clause with _bin collation instead +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (1,'1970-01-01','1997-10-17 00:00:00',2529,1,21000,11886,'check',0,'F',16200,6); +SELECT COUNT(P.URID),SUM(P.amount),P.method, MIN(PP.recdate+0) > 19980501000000 AS IsNew FROM t1 AS P JOIN t1 as PP WHERE P.URID = PP.URID GROUP BY method,IsNew; +ERROR 42000: Can't group on 'IsNew' +drop table t1; +CREATE TABLE t1 ( +cid mediumint(9) NOT NULL auto_increment, +firstname varchar(32) DEFAULT '' NOT NULL, +surname varchar(32) DEFAULT '' NOT NULL, +PRIMARY KEY (cid) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (1,'That','Guy'); +INSERT INTO t1 VALUES (2,'Another','Gent'); +CREATE TABLE t2 ( +call_id mediumint(8) NOT NULL auto_increment, +contact_id mediumint(8) DEFAULT '0' NOT NULL, +PRIMARY KEY (call_id), +KEY contact_id (contact_id) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +lock tables t1 read,t2 write; +INSERT INTO t2 VALUES (10,2); +INSERT INTO t2 VALUES (18,2); +INSERT INTO t2 VALUES (62,2); +INSERT INTO t2 VALUES (91,2); +INSERT INTO t2 VALUES (92,2); +SELECT cid, CONCAT(firstname, ' ', surname), COUNT(call_id) FROM t1 LEFT JOIN t2 ON cid=contact_id WHERE firstname like '%foo%' GROUP BY cid; +cid CONCAT(firstname, ' ', surname) COUNT(call_id) +SELECT cid, CONCAT(firstname, ' ', surname), COUNT(call_id) FROM t1 LEFT JOIN t2 ON cid=contact_id WHERE firstname like '%foo%' GROUP BY cid ORDER BY NULL; +cid CONCAT(firstname, ' ', surname) COUNT(call_id) +SELECT HIGH_PRIORITY cid, CONCAT(firstname, ' ', surname), COUNT(call_id) FROM t1 LEFT JOIN t2 ON cid=contact_id WHERE firstname like '%foo%' GROUP BY cid ORDER BY surname, firstname; +cid CONCAT(firstname, ' ', surname) COUNT(call_id) +drop table t2; +unlock tables; +drop table t1; +CREATE TABLE t1 ( +bug_id mediumint(9) NOT NULL auto_increment, +groupset bigint(20) DEFAULT '0' NOT NULL, +assigned_to mediumint(9) DEFAULT '0' NOT NULL, +bug_file_loc text, +bug_severity enum('blocker','critical','major','normal','minor','trivial','enhancement') DEFAULT 'blocker' NOT NULL, +bug_status enum('','NEW','ASSIGNED','REOPENED','RESOLVED','VERIFIED','CLOSED') DEFAULT 'NEW' NOT NULL, +creation_ts datetime DEFAULT '0000-00-00 00:00:00' NOT NULL, +delta_ts timestamp, +short_desc mediumtext, +long_desc mediumtext, +op_sys enum('All','Windows 3.1','Windows 95','Windows 98','Windows NT','Windows 2000','Linux','other') DEFAULT 'All' NOT NULL, +priority enum('P1','P2','P3','P4','P5') DEFAULT 'P1' NOT NULL, +product varchar(64) DEFAULT '' NOT NULL, +rep_platform enum('All','PC','VTD-8','Other'), +reporter mediumint(9) DEFAULT '0' NOT NULL, +version varchar(16) DEFAULT '' NOT NULL, +component varchar(50) DEFAULT '' NOT NULL, +resolution enum('','FIXED','INVALID','WONTFIX','LATER','REMIND','DUPLICATE','WORKSFORME') DEFAULT '' NOT NULL, +target_milestone varchar(20) DEFAULT '' NOT NULL, +qa_contact mediumint(9) DEFAULT '0' NOT NULL, +status_whiteboard mediumtext NOT NULL, +votes mediumint(9) DEFAULT '0' NOT NULL, +PRIMARY KEY (bug_id), +KEY assigned_to (assigned_to), +KEY creation_ts (creation_ts), +KEY delta_ts (delta_ts), +KEY bug_severity (bug_severity), +KEY bug_status (bug_status), +KEY op_sys (op_sys), +KEY priority (priority), +KEY product (product), +KEY reporter (reporter), +KEY version (version), +KEY component (component), +KEY resolution (resolution), +KEY target_milestone (target_milestone), +KEY qa_contact (qa_contact), +KEY votes (votes) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (1,0,0,'','normal','','2000-02-10 09:25:12',20000321114747,'','','Linux','P1','TestProduct','PC',3,'other','TestComponent','','M1',0,'',0); +INSERT INTO t1 VALUES (9,0,0,'','enhancement','','2000-03-10 11:49:36',20000321114747,'','','All','P5','AAAAA','PC',3,'2.00 CD - Pre','BBBBBBBBBBBBB - conversion','','',0,'',0); +INSERT INTO t1 VALUES (10,0,0,'','enhancement','','2000-03-10 18:10:16',20000321114747,'','','All','P4','AAAAA','PC',3,'2.00 CD - Pre','BBBBBBBBBBBBB - conversion','','',0,'',0); +INSERT INTO t1 VALUES (7,0,0,'','critical','','2000-03-09 10:50:21',20000321114747,'','','All','P1','AAAAA','PC',3,'2.00 CD - Pre','BBBBBBBBBBBBB - generic','','',0,'',0); +INSERT INTO t1 VALUES (6,0,0,'','normal','','2000-03-09 10:42:44',20000321114747,'','','All','P2','AAAAA','PC',3,'2.00 CD - Pre','kkkkkkkkkkk lllllllllll','','',0,'',0); +INSERT INTO t1 VALUES (8,0,0,'','major','','2000-03-09 11:32:14',20000321114747,'','','All','P3','AAAAA','PC',3,'2.00 CD - Pre','kkkkkkkkkkk lllllllllll','','',0,'',0); +INSERT INTO t1 VALUES (5,0,0,'','enhancement','','2000-03-09 10:38:59',20000321114747,'','','All','P5','CCC/CCCCCC','PC',5,'7.00','Administration','','',0,'',0); +INSERT INTO t1 VALUES (4,0,0,'','normal','','2000-03-08 18:32:14',20000321114747,'','','other','P2','TestProduct','Other',3,'other','TestComponent2','','',0,'',0); +INSERT INTO t1 VALUES (3,0,0,'','normal','','2000-03-08 18:30:52',20000321114747,'','','other','P2','TestProduct','Other',3,'other','TestComponent','','',0,'',0); +INSERT INTO t1 VALUES (2,0,0,'','enhancement','','2000-03-08 18:24:51',20000321114747,'','','All','P2','TestProduct','Other',4,'other','TestComponent2','','',0,'',0); +INSERT INTO t1 VALUES (11,0,0,'','blocker','','2000-03-13 09:43:41',20000321114747,'','','All','P2','CCC/CCCCCC','PC',5,'7.00','DDDDDDDDD','','',0,'',0); +INSERT INTO t1 VALUES (12,0,0,'','normal','','2000-03-13 16:14:31',20000321114747,'','','All','P2','AAAAA','PC',3,'2.00 CD - Pre','kkkkkkkkkkk lllllllllll','','',0,'',0); +INSERT INTO t1 VALUES (13,0,0,'','normal','','2000-03-15 16:20:44',20000321114747,'','','other','P2','TestProduct','Other',3,'other','TestComponent','','',0,'',0); +INSERT INTO t1 VALUES (14,0,0,'','blocker','','2000-03-15 18:13:47',20000321114747,'','','All','P1','AAAAA','PC',3,'2.00 CD - Pre','BBBBBBBBBBBBB - generic','','',0,'',0); +INSERT INTO t1 VALUES (15,0,0,'','minor','','2000-03-16 18:03:28',20000321114747,'','','All','P2','CCC/CCCCCC','Other',5,'7.00','DDDDDDDDD','','',0,'',0); +INSERT INTO t1 VALUES (16,0,0,'','normal','','2000-03-16 18:33:41',20000321114747,'','','All','P2','CCC/CCCCCC','Other',5,'7.00','Administration','','',0,'',0); +INSERT INTO t1 VALUES (17,0,0,'','normal','','2000-03-16 18:34:18',20000321114747,'','','All','P2','CCC/CCCCCC','Other',5,'7.00','Administration','','',0,'',0); +INSERT INTO t1 VALUES (18,0,0,'','normal','','2000-03-16 18:34:56',20000321114747,'','','All','P2','CCC/CCCCCC','Other',5,'7.00','Administration','','',0,'',0); +INSERT INTO t1 VALUES (19,0,0,'','enhancement','','2000-03-16 18:35:34',20000321114747,'','','All','P2','CCC/CCCCCC','Other',5,'7.00','Administration','','',0,'',0); +INSERT INTO t1 VALUES (20,0,0,'','enhancement','','2000-03-16 18:36:23',20000321114747,'','','All','P2','CCC/CCCCCC','Other',5,'7.00','Administration','','',0,'',0); +INSERT INTO t1 VALUES (21,0,0,'','enhancement','','2000-03-16 18:37:23',20000321114747,'','','All','P2','CCC/CCCCCC','Other',5,'7.00','Administration','','',0,'',0); +INSERT INTO t1 VALUES (22,0,0,'','enhancement','','2000-03-16 18:38:16',20000321114747,'','','All','P2','CCC/CCCCCC','Other',5,'7.00','Administration','','',0,'',0); +INSERT INTO t1 VALUES (23,0,0,'','normal','','2000-03-16 18:58:12',20000321114747,'','','All','P2','CCC/CCCCCC','Other',5,'7.00','DDDDDDDDD','','',0,'',0); +INSERT INTO t1 VALUES (24,0,0,'','normal','','2000-03-17 11:08:10',20000321114747,'','','All','P2','AAAAAAAA-AAA','PC',3,'2.8','Web Interface','','',0,'',0); +INSERT INTO t1 VALUES (25,0,0,'','normal','','2000-03-17 11:10:45',20000321114747,'','','All','P2','AAAAAAAA-AAA','PC',3,'2.8','Web Interface','','',0,'',0); +INSERT INTO t1 VALUES (26,0,0,'','normal','','2000-03-17 11:15:47',20000321114747,'','','All','P2','AAAAAAAA-AAA','PC',3,'2.8','Web Interface','','',0,'',0); +INSERT INTO t1 VALUES (27,0,0,'','normal','','2000-03-17 17:45:41',20000321114747,'','','All','P2','CCC/CCCCCC','PC',5,'7.00','DDDDDDDDD','','',0,'',0); +INSERT INTO t1 VALUES (28,0,0,'','normal','','2000-03-20 09:51:45',20000321114747,'','','Windows NT','P2','TestProduct','PC',8,'other','TestComponent','','',0,'',0); +INSERT INTO t1 VALUES (29,0,0,'','normal','','2000-03-20 11:15:09',20000321114747,'','','All','P5','AAAAAAAA-AAA','PC',3,'2.8','Web Interface','','',0,'',0); +CREATE TABLE t2 ( +value tinytext, +program varchar(64), +initialowner tinytext NOT NULL, +initialqacontact tinytext NOT NULL, +description mediumtext NOT NULL +); +INSERT INTO t2 VALUES ('TestComponent','TestProduct','id0001','',''); +INSERT INTO t2 VALUES ('BBBBBBBBBBBBB - conversion','AAAAA','id0001','',''); +INSERT INTO t2 VALUES ('BBBBBBBBBBBBB - generic','AAAAA','id0001','',''); +INSERT INTO t2 VALUES ('TestComponent2','TestProduct','id0001','',''); +INSERT INTO t2 VALUES ('BBBBBBBBBBBBB - eeeeeeeee','AAAAA','id0001','',''); +INSERT INTO t2 VALUES ('kkkkkkkkkkk lllllllllll','AAAAA','id0001','',''); +INSERT INTO t2 VALUES ('Test Procedures','AAAAA','id0001','',''); +INSERT INTO t2 VALUES ('Documentation','AAAAA','id0003','',''); +INSERT INTO t2 VALUES ('DDDDDDDDD','CCC/CCCCCC','id0002','',''); +INSERT INTO t2 VALUES ('Eeeeeeee Lite','CCC/CCCCCC','id0002','',''); +INSERT INTO t2 VALUES ('Eeeeeeee Full','CCC/CCCCCC','id0002','',''); +INSERT INTO t2 VALUES ('Administration','CCC/CCCCCC','id0002','',''); +INSERT INTO t2 VALUES ('Distribution','CCC/CCCCCC','id0002','',''); +INSERT INTO t2 VALUES ('Setup','CCC/CCCCCC','id0002','',''); +INSERT INTO t2 VALUES ('Unspecified','CCC/CCCCCC','id0002','',''); +INSERT INTO t2 VALUES ('Web Interface','AAAAAAAA-AAA','id0001','',''); +INSERT INTO t2 VALUES ('Host communication','AAAAA','id0001','',''); +select value,description,bug_id from t2 left join t1 on t2.program=t1.product and t2.value=t1.component where program="AAAAA"; +value description bug_id +BBBBBBBBBBBBB - conversion 10 +BBBBBBBBBBBBB - conversion 9 +BBBBBBBBBBBBB - eeeeeeeee NULL +BBBBBBBBBBBBB - generic 14 +BBBBBBBBBBBBB - generic 7 +Documentation NULL +Host communication NULL +Test Procedures NULL +kkkkkkkkkkk lllllllllll 12 +kkkkkkkkkkk lllllllllll 6 +kkkkkkkkkkk lllllllllll 8 +select value,description,COUNT(bug_id) from t2 left join t1 on t2.program=t1.product and t2.value=t1.component where program="AAAAA" group by value; +value description COUNT(bug_id) +BBBBBBBBBBBBB - conversion 2 +BBBBBBBBBBBBB - eeeeeeeee 0 +BBBBBBBBBBBBB - generic 2 +Documentation 0 +Host communication 0 +Test Procedures 0 +kkkkkkkkkkk lllllllllll 3 +select value,description,COUNT(bug_id) from t2 left join t1 on t2.program=t1.product and t2.value=t1.component where program="AAAAA" group by value having COUNT(bug_id) IN (0,2); +value description COUNT(bug_id) +BBBBBBBBBBBBB - conversion 2 +BBBBBBBBBBBBB - eeeeeeeee 0 +BBBBBBBBBBBBB - generic 2 +Documentation 0 +Host communication 0 +Test Procedures 0 +select row_number() over (), value,description,COUNT(bug_id) from t2 left join t1 on t2.program=t1.product and t2.value=t1.component where program="AAAAA" group by value having COUNT(bug_id) IN (0,2); +row_number() over () value description COUNT(bug_id) +1 BBBBBBBBBBBBB - conversion 2 +2 BBBBBBBBBBBBB - generic 2 +3 BBBBBBBBBBBBB - eeeeeeeee 0 +4 Test Procedures 0 +5 Documentation 0 +6 Host communication 0 +drop table t1,t2; +create table t1 (foo int); +insert into t1 values (1); +select 1+1, "a",count(*) from t1 where foo in (2); +1+1 a count(*) +2 a 0 +insert into t1 values (1); +select 1+1,"a",count(*) from t1 where foo in (2); +1+1 a count(*) +2 a 0 +drop table t1; +CREATE TABLE t1 ( +spID int(10) unsigned, +userID int(10) unsigned, +score smallint(5) unsigned, +key (spid), +key (score) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (1,1,1),(2,2,2),(2,1,1),(3,3,3),(4,3,3),(5,3,3),(6,3,3),(7,3,3); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +explain select userid,count(*) from t1 group by userid order by userid desc; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 8 100.00 Using temporary; Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`userID` AS `userid`,count(0) AS `count(*)` from `test`.`t1` group by `test`.`t1`.`userID` desc order by `test`.`t1`.`userID` desc +explain select userid,count(*) from t1 group by userid order by null; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 8 100.00 Using temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`userID` AS `userid`,count(0) AS `count(*)` from `test`.`t1` group by `test`.`t1`.`userID` order by NULL +select userid,count(*) from t1 group by userid order by userid desc; +userid count(*) +3 5 +2 1 +1 2 +select userid,count(*) from t1 group by userid having (count(*)+1) IN (4,3) order by userid desc; +userid count(*) +1 2 +select userid,count(*) from t1 group by userid having 3 IN (1,COUNT(*)) order by userid desc; +userid count(*) +explain select spid,count(*) from t1 where spid between 1 and 2 group by spid order by spid desc; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range spID spID 5 NULL 3 100.00 Using where; Backward index scan; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`spID` AS `spid`,count(0) AS `count(*)` from `test`.`t1` where (`test`.`t1`.`spID` between 1 and 2) group by `test`.`t1`.`spID` desc order by `test`.`t1`.`spID` desc +explain select spid,count(*) from t1 where spid between 1 and 2 group by spid; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range spID spID 5 NULL 3 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`spID` AS `spid`,count(0) AS `count(*)` from `test`.`t1` where (`test`.`t1`.`spID` between 1 and 2) group by `test`.`t1`.`spID` +explain select spid,count(*) from t1 where spid between 1 and 2 group by spid order by null; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range spID spID 5 NULL 3 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`spID` AS `spid`,count(0) AS `count(*)` from `test`.`t1` where (`test`.`t1`.`spID` between 1 and 2) group by `test`.`t1`.`spID` order by NULL +select spid,count(*) from t1 where spid between 1 and 2 group by spid; +spid count(*) +1 1 +2 2 +select spid,count(*) from t1 where spid between 1 and 2 group by spid order by spid desc; +spid count(*) +2 2 +1 1 +explain select sql_big_result spid,sum(userid) from t1 group by spid order by spid desc; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL spID NULL NULL NULL 8 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select sql_big_result `test`.`t1`.`spID` AS `spid`,sum(`test`.`t1`.`userID`) AS `sum(userid)` from `test`.`t1` group by `test`.`t1`.`spID` desc order by `test`.`t1`.`spID` desc +explain select sql_big_result spid,sum(userid) from t1 group by spid order by null; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL spID NULL NULL NULL 8 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select sql_big_result `test`.`t1`.`spID` AS `spid`,sum(`test`.`t1`.`userID`) AS `sum(userid)` from `test`.`t1` group by `test`.`t1`.`spID` order by NULL +select sql_big_result spid,sum(userid) from t1 group by spid order by spid desc; +spid sum(userid) +7 3 +6 3 +5 3 +4 3 +3 3 +2 3 +1 1 +explain select sql_big_result score,count(*) from t1 group by score order by score desc; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index score score 3 NULL 8 100.00 Using index; Using filesort +Warnings: +Note 1003 /* select#1 */ select sql_big_result `test`.`t1`.`score` AS `score`,count(0) AS `count(*)` from `test`.`t1` group by `test`.`t1`.`score` desc order by `test`.`t1`.`score` desc +explain select sql_big_result score,count(*) from t1 group by score order by null; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index score score 3 NULL 8 100.00 Using index; Using filesort +Warnings: +Note 1003 /* select#1 */ select sql_big_result `test`.`t1`.`score` AS `score`,count(0) AS `count(*)` from `test`.`t1` group by `test`.`t1`.`score` order by NULL +select sql_big_result score,count(*) from t1 group by score order by score desc; +score count(*) +3 5 +2 1 +1 2 +drop table t1; +create table t1 (a date default null, b date default null); +insert t1 values ('1999-10-01','2000-01-10'), ('1997-01-01','1998-10-01'); +select a,min(b) c,count(distinct rand()) from t1 group by a having c NULL ALL NULL NULL NULL NULL # # Parallel execute (1 workers) +2 SIMPLE t2 NULL ALL a NULL NULL NULL # # Using temporary +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL # # Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` join `test`.`t2` where (`test`.`t1`.`a` = `test`.`t2`.`a`) group by `test`.`t1`.`a`,`test`.`t2`.`b` +explain select t1.a,t2.b from t1,t2 where t1.a=t2.a group by t1.a,t2.b ORDER BY NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # # Parallel execute (1 workers) +2 SIMPLE t2 NULL ALL a NULL NULL NULL # # Using temporary +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL # # Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` join `test`.`t2` where (`test`.`t1`.`a` = `test`.`t2`.`a`) group by `test`.`t1`.`a`,`test`.`t2`.`b` order by NULL +drop table t1,t2; +create table t1 (a int, b int); +insert into t1 values (1, 4),(10, 40),(1, 4),(10, 43),(1, 4),(10, 41),(1, 4),(10, 43),(1, 4); +select a, MAX(b), INTERVAL (MAX(b), 1,3,10,30,39,40,50,60,100,1000) from t1 group by a; +a MAX(b) INTERVAL (MAX(b), 1,3,10,30,39,40,50,60,100,1000) +1 4 2 +10 43 6 +select a, MAX(b), CASE MAX(b) when 4 then 4 when 43 then 43 else 0 end from t1 group by a; +a MAX(b) CASE MAX(b) when 4 then 4 when 43 then 43 else 0 end +1 4 4 +10 43 43 +select a, MAX(b), FIELD(MAX(b), '43', '4', '5') from t1 group by a; +a MAX(b) FIELD(MAX(b), '43', '4', '5') +1 4 2 +10 43 1 +select a, MAX(b), CONCAT_WS(MAX(b), '43', '4', '5') from t1 group by a; +a MAX(b) CONCAT_WS(MAX(b), '43', '4', '5') +1 4 434445 +10 43 43434435 +select a, MAX(b), ELT(MAX(b), 'a', 'b', 'c', 'd', 'e', 'f') from t1 group by a; +a MAX(b) ELT(MAX(b), 'a', 'b', 'c', 'd', 'e', 'f') +1 4 d +10 43 NULL +select a, MAX(b), MAKE_SET(MAX(b), 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h') from t1 group by a; +a MAX(b) MAKE_SET(MAX(b), 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h') +1 4 c +10 43 a,b,d,f +drop table t1; +create table t1 (id int not null, qty int not null); +insert into t1 values (1,2),(1,3),(2,4),(2,5); +select id, sum(qty) as sqty, count(qty) as cqty from t1 group by id having sum(qty)>2 and cqty>1; +id sqty cqty +1 5 2 +2 9 2 +select id, sum(qty) as sqty from t1 group by id having sqty>2 and count(qty)>1; +id sqty +1 5 +2 9 +select id, sum(qty) as sqty, count(qty) as cqty from t1 group by id having sqty>2 and cqty>1; +id sqty cqty +1 5 2 +2 9 2 +select id, sum(qty) as sqty, count(qty) as cqty from t1 group by id having sum(qty)>2 and count(qty)>1; +id sqty cqty +1 5 2 +2 9 2 +select count(*), case interval(qty,2,3,4,5,6,7,8) when -1 then NULL when 0 then "zero" when 1 then "one" when 2 then "two" end as category from t1 group by category; +count(*) category +2 NULL +1 one +1 two +select count(*), interval(qty,2,3,4,5,6,7,8) as category from t1 group by category; +count(*) category +1 1 +1 2 +1 3 +1 4 +drop table t1; +CREATE TABLE t1 ( +userid int(10) unsigned, +score smallint(5) unsigned, +key (score) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (1,1),(2,2),(1,1),(3,3),(3,3),(3,3),(3,3),(3,3); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +SELECT userid,count(*) FROM t1 GROUP BY userid ORDER BY userid DESC; +userid count(*) +3 5 +2 1 +1 2 +EXPLAIN SELECT userid,count(*) FROM t1 GROUP BY userid ORDER BY userid DESC; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 8 100.00 Using temporary; Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`userid` AS `userid`,count(0) AS `count(*)` from `test`.`t1` group by `test`.`t1`.`userid` desc order by `test`.`t1`.`userid` desc +DROP TABLE t1; +CREATE TABLE t1 ( +i int(11) default NULL, +j int(11) default NULL +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (1,2),(2,3),(4,5),(3,5),(1,5),(23,5); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +SELECT i, COUNT(DISTINCT(i)) FROM t1 GROUP BY j ORDER BY NULL; +i COUNT(DISTINCT(i)) +1 1 +2 1 +4 4 +explain SELECT i, COUNT(DISTINCT(i)) FROM t1 GROUP BY j ORDER BY NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 6 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i`,count(distinct `test`.`t1`.`i`) AS `COUNT(DISTINCT(i))` from `test`.`t1` group by `test`.`t1`.`j` order by NULL +DROP TABLE t1; +create table t1 (a int); +insert into t1 values(null); +select min(a) is null from t1; +min(a) is null +1 +select min(a) is null or null from t1; +min(a) is null or null +1 +select 1 and min(a) is null from t1; +1 and min(a) is null +1 +drop table t1; +create table t1 ( col1 int, col2 int ); +insert into t1 values (1,1),(1,2),(1,3),(2,1),(2,2); +select group_concat( distinct col1 ) as alias from t1 +group by col2 having alias like '%'; +alias +1,2 +1,2 +1 +drop table t1; +CREATE TABLE t1 (a INTEGER, b INTEGER, c INTEGER); +INSERT INTO t1 (a,b) VALUES (1,2),(1,3),(2,5); +SELECT a, 0.1*0+1 r2, SUM(1) r1 FROM t1 WHERE a = 1 GROUP BY a HAVING r1>1 AND r2=1; +a r2 r1 +1 1.0 2 +SELECT a, ROUND(RAND(100)*10) r2, SUM(1) r1 FROM t1 GROUP BY a; +a r2 r1 +1 2 2 +2 7 1 +SELECT a, ROUND(RAND(100)*10) r2, SUM(1) r1 FROM t1 GROUP BY a +HAVING r1>=1 AND r2<=7 AND r2 > 0; +a r2 r1 +1 2 2 +2 7 1 +SELECT a, ROUND(RAND(100)*10) r2, SUM(1) r1 FROM t1 GROUP BY a +HAVING r1>=1 AND (SELECT r2<=7 AND r2 > 0 FROM t1 AS t2 LIMIT 1); +a r2 r1 +1 2 2 +2 7 1 +SELECT a, ROUND(RAND(100)*10) r2, SUM(1) r1 FROM t1 WHERE a = 1 +GROUP BY a HAVING r1>1 AND r2<=2; +a r2 r1 +1 7 2 +SELECT a, ROUND(RAND(100)*10) r2, SUM(1) r1 FROM t1 WHERE a = 1 +GROUP BY a HAVING r1>1 AND r2<=2 ORDER BY a+r2+r1; +a r2 r1 +1 7 2 +SELECT a,SUM(b) FROM t1 WHERE a=1 GROUP BY c; +a SUM(b) +1 5 +SELECT a*SUM(b) FROM t1 WHERE a=1 GROUP BY c; +a*SUM(b) +5 +SELECT SUM(a)*SUM(b) FROM t1 WHERE a=1 GROUP BY c; +SUM(a)*SUM(b) +10 +SELECT a,SUM(b) FROM t1 WHERE a=1 GROUP BY c HAVING a=1; +a SUM(b) +1 5 +SELECT a AS d,SUM(b) FROM t1 WHERE a=1 GROUP BY c HAVING d=1; +d SUM(b) +1 5 +SELECT SUM(a)*SUM(b) AS d FROM t1 WHERE a=1 GROUP BY c HAVING d > 0; +d +10 +SELECT a, ROUND(RAND(100)*10) r2 FROM t1; +a r2 +1 2 +1 7 +2 10 +SELECT ROUND(RAND(100)*10) r2 FROM t1 GROUP BY r2; +r2 +2 +7 +10 +DROP TABLE t1; +CREATE TABLE t1(i INT); +INSERT INTO t1 VALUES (NULL),(1); +SELECT DISTINCT STD(i)+0 as splus0, i+0 as plain FROM t1 GROUP BY i ; +splus0 plain +NULL NULL +0 1 +DROP TABLE t1; +create table t1(a int) engine=myisam; +insert into t1 values (0),(1),(2),(3),(4),(5),(6),(8),(9); +create table t2 ( +a int, +b varchar(200) NOT NULL, +c varchar(50) NOT NULL, +d varchar(100) NOT NULL, +primary key (a,b(132),c,d), +key a (a,b) +) engine=myisam charset=utf8; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +insert into t2 select +x3.a, -- 3 +concat('val-', x3.a + 3*x4.a), -- 12 +concat('val-', @a:=x3.a + 3*x4.a + 12*C.a), -- 120 +concat('val-', @a + 120*D.a) +from t1 x3, t1 x4, t1 C, t1 D where x3.a < 3 and x4.a < 4 and D.a < 4 +order by x3.a, x4.a, C.a, D.a; +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +delete from t2 where a = 2 and b = 'val-2' order by a,b,c,d limit 30; +explain select c from t2 where a = 2 and b = 'val-2' group by c; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ref PRIMARY,a PRIMARY 402 const,const 4 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`c` AS `c` from `test`.`t2` where ((`test`.`t2`.`a` = 2) and (`test`.`t2`.`b` = 'val-2')) group by `test`.`t2`.`c` +select c from t2 where a = 2 and b = 'val-2' group by c; +c +val-74 +val-98 +drop table t1,t2; +create table t1 (b int4 unsigned not null); +insert into t1 values(3000000000); +select * from t1; +b +3000000000 +select min(b) from t1; +min(b) +3000000000 +drop table t1; +CREATE TABLE t1 (id int PRIMARY KEY, user_id int, hostname longtext); +INSERT INTO t1 VALUES +(1, 7, 'cache-dtc-af05.proxy.aol.com'), +(2, 3, 'what.ever.com'), +(3, 7, 'cache-dtc-af05.proxy.aol.com'), +(4, 7, 'cache-dtc-af05.proxy.aol.com'); +SELECT hostname, COUNT(DISTINCT user_id) as no FROM t1 +WHERE hostname LIKE '%aol%' + GROUP BY hostname; +hostname no +cache-dtc-af05.proxy.aol.com 1 +DROP TABLE t1; +CREATE TABLE t1 (a int, b int); +INSERT INTO t1 VALUES (1,2), (1,3); +SELECT a, b FROM t1 GROUP BY 'const'; +a b +1 2 +SELECT DISTINCT a, b FROM t1 GROUP BY 'const'; +a b +1 2 +DROP TABLE t1; +CREATE TABLE t1 (id INT, dt DATETIME); +INSERT INTO t1 VALUES ( 1, '2005-05-01 12:30:00' ); +INSERT INTO t1 VALUES ( 1, '2005-05-01 12:30:00' ); +INSERT INTO t1 VALUES ( 1, '2005-05-01 12:30:00' ); +INSERT INTO t1 VALUES ( 1, '2005-05-01 12:30:00' ); +SELECT dt DIV 1 AS f, id FROM t1 GROUP BY f; +f id +20050501123000 1 +DROP TABLE t1; +CREATE TABLE t1 (id varchar(20) NOT NULL); +INSERT INTO t1 VALUES ('trans1'), ('trans2'); +CREATE TABLE t2 (id varchar(20) NOT NULL, err_comment blob NOT NULL); +INSERT INTO t2 VALUES ('trans1', 'a problem'); +SELECT COUNT(DISTINCT(t1.id)), LEFT(err_comment, 256) AS comment +FROM t1 LEFT JOIN t2 ON t1.id=t2.id GROUP BY comment; +COUNT(DISTINCT(t1.id)) comment +1 NULL +1 a problem +DROP TABLE t1, t2; +create table t1 (f1 date); +insert into t1 values('2005-06-06'); +insert into t1 values('2005-06-06'); +select date(left(f1+0,8)) from t1 group by 1; +date(left(f1+0,8)) +2005-06-06 +drop table t1; +CREATE TABLE t1 (n int); +INSERT INTO t1 VALUES (1); +SELECT n+1 AS n FROM t1 GROUP BY n; +n +2 +Warnings: +Warning 1052 Column 'n' in group statement is ambiguous +DROP TABLE t1; +create table t1(f1 varchar(5) key); +insert into t1 values (1),(2); +select sql_buffer_result max(f1) is null from t1; +max(f1) is null +0 +select sql_buffer_result max(f1)+1 from t1; +max(f1)+1 +3 +drop table t1; +CREATE TABLE t1(a INT); +INSERT INTO t1 VALUES (1),(2); +SELECT a FROM t1 GROUP BY 'a'; +a +1 +SELECT a FROM t1 GROUP BY "a"; +a +1 +SELECT a FROM t1 GROUP BY `a`; +a +1 +2 +set sql_mode=ANSI_QUOTES; +SELECT a FROM t1 GROUP BY "a"; +a +1 +2 +SELECT a FROM t1 GROUP BY 'a'; +a +1 +SELECT a FROM t1 GROUP BY `a`; +a +1 +2 +set sql_mode=DEFAULT; +SELECT a FROM t1 HAVING 'a' > 1; +a +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'a' +SELECT a FROM t1 HAVING "a" > 1; +a +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'a' +SELECT a FROM t1 HAVING `a` > 1; +a +2 +SELECT a FROM t1 ORDER BY 'a' DESC; +a +1 +2 +SELECT a FROM t1 ORDER BY "a" DESC; +a +1 +2 +SELECT a FROM t1 ORDER BY `a` DESC; +a +2 +1 +DROP TABLE t1; +CREATE TABLE t1 ( +f1 int(10) unsigned NOT NULL auto_increment primary key, +f2 varchar(100) NOT NULL default '' +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t2 ( +f1 varchar(10) NOT NULL default '', +f2 char(3) NOT NULL default '', +PRIMARY KEY (`f1`), +KEY `k1` (`f2`,`f1`) +); +INSERT INTO t1 values(NULL, ''); +INSERT INTO `t2` VALUES ('486878','WDT'),('486910','WDT'); +SELECT SQL_BUFFER_RESULT avg(t2.f1) FROM t1, t2 where t2.f2 = 'SIR' GROUP BY t1.f1; +avg(t2.f1) +SELECT avg(t2.f1) FROM t1, t2 where t2.f2 = 'SIR' GROUP BY t1.f1; +avg(t2.f1) +DROP TABLE t1, t2; +create table t1 (c1 char(3), c2 char(3)); +create table t2 (c3 char(3), c4 char(3)); +insert into t1 values ('aaa', 'bb1'), ('aaa', 'bb2'); +insert into t2 values ('aaa', 'bb1'), ('aaa', 'bb2'); +select t1.c1 as c2 from t1, t2 where t1.c2 = t2.c4 +group by c2; +c2 +aaa +aaa +Warnings: +Warning 1052 Column 'c2' in group statement is ambiguous +select t1.c1 as c2 from t1, t2 where t1.c2 = t2.c4 +group by t1.c1; +c2 +aaa +drop table t1, t2; +CREATE TABLE t1 (a tinyint(3), b varchar(255), PRIMARY KEY (a)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (1,'-----'), (6,'Allemagne'), (17,'Autriche'), +(25,'Belgique'), (54,'Danemark'), (62,'Espagne'), (68,'France'); +CREATE TABLE t2 (a tinyint(3), b tinyint(3), PRIMARY KEY (a), KEY b (b)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (1,1), (2,1), (6,6), (18,17), (15,25), (16,25), +(17,25), (10,54), (5,62),(3,68); +CREATE VIEW v1 AS select t1.a, concat(t1.b,'') AS b, t1.b as real_b from t1; +ANALYZE TABLE t1,t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +explain +SELECT straight_join v1.a, v1.b, v1.real_b from t2, v1 +where t2.b=v1.a GROUP BY t2.b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index b b 2 NULL # 100.00 Using where; Using index +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 1 test.t2.b # 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select straight_join `test`.`t1`.`a` AS `a`,concat(`test`.`t1`.`b`,'') AS `b`,`test`.`t1`.`b` AS `real_b` from `test`.`t2` join `test`.`t1` where (`test`.`t1`.`a` = `test`.`t2`.`b`) group by `test`.`t2`.`b` +SELECT straight_join v1.a, v1.b, v1.real_b from t2, v1 +where t2.b=v1.a GROUP BY t2.b; +a b real_b +1 ----- ----- +6 Allemagne Allemagne +17 Autriche Autriche +25 Belgique Belgique +54 Danemark Danemark +62 Espagne Espagne +68 France France +DROP VIEW v1; +DROP TABLE t1,t2; +CREATE TABLE t1 (a INT PRIMARY KEY, b INT, key (b)); +INSERT INTO t1 VALUES (1, 1); +INSERT INTO t1 SELECT a + 1 , MOD(a + 1 , 20) FROM t1; +INSERT INTO t1 SELECT a + 2 , MOD(a + 2 , 20) FROM t1; +INSERT INTO t1 SELECT a + 4 , MOD(a + 4 , 20) FROM t1; +INSERT INTO t1 SELECT a + 8 , MOD(a + 8 , 20) FROM t1; +INSERT INTO t1 SELECT a + 16, MOD(a + 16, 20) FROM t1; +INSERT INTO t1 SELECT a + 32, MOD(a + 32, 20) FROM t1; +INSERT INTO t1 SELECT a + 64, MOD(a + 64, 20) FROM t1; +SELECT MIN(b), MAX(b) from t1; +MIN(b) MAX(b) +0 19 +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT b, sum(1) FROM t1 GROUP BY b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 128 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index b b 5 NULL 128 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`b` AS `b`,sum(1) AS `sum(1)` from `test`.`t1` group by `test`.`t1`.`b` +EXPLAIN SELECT SQL_BIG_RESULT b, sum(1) FROM t1 GROUP BY b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 128 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index b b 5 NULL 128 100.00 Using index; Using filesort +Warnings: +Note 1003 /* select#1 */ select sql_big_result `test`.`t1`.`b` AS `b`,sum(1) AS `sum(1)` from `test`.`t1` group by `test`.`t1`.`b` +SELECT b, sum(1) FROM t1 GROUP BY b; +b sum(1) +0 6 +1 7 +2 7 +3 7 +4 7 +5 7 +6 7 +7 7 +8 7 +9 6 +10 6 +11 6 +12 6 +13 6 +14 6 +15 6 +16 6 +17 6 +18 6 +19 6 +SELECT SQL_BIG_RESULT b, sum(1) FROM t1 GROUP BY b; +b sum(1) +0 6 +1 7 +2 7 +3 7 +4 7 +5 7 +6 7 +7 7 +8 7 +9 6 +10 6 +11 6 +12 6 +13 6 +14 6 +15 6 +16 6 +17 6 +18 6 +19 6 +DROP TABLE t1; +CREATE TABLE t1 (a INT, b INT); +INSERT INTO t1 VALUES (1,1),(2,1),(3,2),(4,2),(5,3),(6,3); +SET SQL_MODE = 'ONLY_FULL_GROUP_BY'; +SELECT MAX(a)-MIN(a) FROM t1 GROUP BY b; +MAX(a)-MIN(a) +1 +1 +1 +SELECT CEILING(MIN(a)) FROM t1 GROUP BY b; +CEILING(MIN(a)) +1 +3 +5 +SELECT CASE WHEN AVG(a)>=0 THEN 'Positive' ELSE 'Negative' END FROM t1 +GROUP BY b; +CASE WHEN AVG(a)>=0 THEN 'Positive' ELSE 'Negative' END +Positive +Positive +Positive +SELECT a + 1 FROM t1 GROUP BY a; +a + 1 +2 +3 +4 +5 +6 +7 +SELECT a + b FROM t1 GROUP BY b; +ERROR 42000: Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'test.t1.a' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +SELECT (SELECT t1_outer.a FROM t1 AS t1_inner GROUP BY b LIMIT 1) +FROM t1 AS t1_outer; +(SELECT t1_outer.a FROM t1 AS t1_inner GROUP BY b LIMIT 1) +1 +2 +3 +4 +5 +6 +SELECT 1 FROM t1 as t1_outer GROUP BY a +HAVING (SELECT t1_outer.a FROM t1 AS t1_inner GROUP BY b LIMIT 1); +1 +1 +1 +1 +1 +1 +1 +SELECT (SELECT t1_outer.a FROM t1 AS t1_inner LIMIT 1) +FROM t1 AS t1_outer GROUP BY t1_outer.b; +ERROR 42000: Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'test.t1_outer.a' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +SELECT 1 FROM t1 as t1_outer GROUP BY a +HAVING (SELECT t1_outer.b FROM t1 AS t1_inner LIMIT 1); +ERROR 42S22: Unknown column 'test.t1_outer.b' in 'field list' +SELECT (SELECT SUM(t1_inner.a) FROM t1 AS t1_inner LIMIT 1) +FROM t1 AS t1_outer GROUP BY t1_outer.b; +(SELECT SUM(t1_inner.a) FROM t1 AS t1_inner LIMIT 1) +21 +21 +21 +SELECT (SELECT SUM(t1_inner.a) FROM t1 AS t1_inner GROUP BY t1_inner.b LIMIT 1) +FROM t1 AS t1_outer; +(SELECT SUM(t1_inner.a) FROM t1 AS t1_inner GROUP BY t1_inner.b LIMIT 1) +3 +3 +3 +3 +3 +3 +SELECT (SELECT SUM(t1_outer.a) FROM t1 AS t1_inner LIMIT 1) +FROM t1 AS t1_outer GROUP BY t1_outer.b; +(SELECT SUM(t1_outer.a) FROM t1 AS t1_inner LIMIT 1) +3 +7 +11 +SET SQL_MODE = ''; +SELECT (SELECT SUM(t1_outer.a) FROM t1 AS t1_inner LIMIT 1) +FROM t1 AS t1_outer GROUP BY t1_outer.b; +(SELECT SUM(t1_outer.a) FROM t1 AS t1_inner LIMIT 1) +3 +7 +11 +SET SQL_MODE = 'ONLY_FULL_GROUP_BY'; +SELECT (SELECT SUM(t1_outer.a+0*t1_inner.a) FROM t1 AS t1_inner LIMIT 1) +FROM t1 AS t1_outer GROUP BY t1_outer.b; +ERROR 42000: Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'test.t1_outer.a' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +SET SQL_MODE = ''; +SELECT (SELECT SUM(t1_outer.a+0*t1_inner.a) FROM t1 AS t1_inner LIMIT 1) +FROM t1 AS t1_outer GROUP BY t1_outer.b; +(SELECT SUM(t1_outer.a+0*t1_inner.a) FROM t1 AS t1_inner LIMIT 1) +6 +18 +30 +SET SQL_MODE = 'ONLY_FULL_GROUP_BY'; +SELECT 1 FROM t1 as t1_outer +WHERE (SELECT t1_outer.b FROM t1 AS t1_inner GROUP BY t1_inner.b LIMIT 1); +1 +1 +1 +1 +1 +1 +1 +SELECT b FROM t1 GROUP BY b HAVING CEILING(b) > 0; +b +1 +2 +3 +SELECT 1 FROM t1 GROUP BY b HAVING b = 2 OR b = 3 OR SUM(a) > 12; +1 +1 +1 +SELECT 1 FROM t1 GROUP BY b HAVING ROW (b,b) = ROW (1,1); +1 +1 +SELECT 1 FROM t1 GROUP BY b HAVING a = 2; +ERROR 42S22: Unknown column 'a' in 'having clause' +SELECT 1 FROM t1 GROUP BY SUM(b); +ERROR HY000: Invalid use of group function +SELECT b FROM t1 AS t1_outer GROUP BY a HAVING t1_outer.a IN +(SELECT SUM(t1_inner.b)+t1_outer.b FROM t1 AS t1_inner GROUP BY t1_inner.a +HAVING SUM(t1_inner.b)+t1_outer.b > 5); +ERROR 42000: Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'test.t1_outer.b' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +DROP TABLE t1; +SET SQL_MODE = ''; +SET SQL_MODE = 'ONLY_FULL_GROUP_BY'; +create table t1(f1 int, f2 int); +select * from t1 group by f1; +ERROR 42000: Expression #2 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'test.t1.f2' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +select * from t1 group by f2; +ERROR 42000: Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'test.t1.f1' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +select * from t1 group by f1, f2; +f1 f2 +select t1.f1,t.* from t1, t1 t group by 1; +ERROR 42000: Expression #2 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'test.t.f1' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +drop table t1; +SET SQL_MODE = DEFAULT; +CREATE TABLE t1( +id INT AUTO_INCREMENT PRIMARY KEY, +c1 INT NOT NULL, +c2 INT NOT NULL, +UNIQUE KEY (c2,c1)); +INSERT INTO t1(c1,c2) VALUES (5,1), (4,1), (3,5), (2,3), (1,3); +SELECT * FROM t1 ORDER BY c1; +id c1 c2 +5 1 3 +4 2 3 +3 3 5 +2 4 1 +1 5 1 +SELECT * FROM t1 GROUP BY id ORDER BY c1; +id c1 c2 +5 1 3 +4 2 3 +3 3 5 +2 4 1 +1 5 1 +SELECT * FROM t1 GROUP BY id ORDER BY id DESC; +id c1 c2 +5 1 3 +4 2 3 +3 3 5 +2 4 1 +1 5 1 +SELECT * FROM t1 GROUP BY c2 ,c1, id ORDER BY c2, c1; +id c1 c2 +2 4 1 +1 5 1 +5 1 3 +4 2 3 +3 3 5 +SELECT * FROM t1 GROUP BY c2, c1, id ORDER BY c2 DESC, c1; +id c1 c2 +3 3 5 +5 1 3 +4 2 3 +2 4 1 +1 5 1 +SELECT * FROM t1 GROUP BY c2, c1, id ORDER BY c2 DESC, c1 DESC; +id c1 c2 +3 3 5 +4 2 3 +5 1 3 +1 5 1 +2 4 1 +SELECT * FROM t1 GROUP BY c2 ORDER BY c2, c1; +id c1 c2 +2 4 1 +5 1 3 +3 3 5 +SELECT * FROM t1 GROUP BY c2 ORDER BY c2 DESC, c1; +id c1 c2 +3 3 5 +5 1 3 +2 4 1 +SELECT * FROM t1 GROUP BY c2 ORDER BY c2 DESC, c1 DESC; +id c1 c2 +3 3 5 +5 1 3 +2 4 1 +DROP TABLE t1; +# +# Bug#27219: Aggregate functions in ORDER BY. +# +SET @save_sql_mode=@@sql_mode; +SET @@sql_mode='ONLY_FULL_GROUP_BY'; +CREATE TABLE t1 (a INT, b INT, c INT DEFAULT 0); +INSERT INTO t1 (a, b) VALUES (3,3), (2,2), (3,3), (2,2), (3,3), (4,4); +CREATE TABLE t2 SELECT * FROM t1; +SELECT COUNT(*) FROM t1 ORDER BY COUNT(*); +COUNT(*) +6 +SELECT COUNT(*) FROM t1 ORDER BY COUNT(*) + 1; +COUNT(*) +6 +SELECT COUNT(*) FROM t1 ORDER BY COUNT(*) + a; +COUNT(*) +6 +SELECT COUNT(*) FROM t1 ORDER BY COUNT(*), 1; +COUNT(*) +6 +SELECT COUNT(*) FROM t1 ORDER BY COUNT(*), a; +COUNT(*) +6 +SELECT COUNT(*) FROM t1 ORDER BY SUM(a); +COUNT(*) +6 +SELECT COUNT(*) FROM t1 ORDER BY SUM(a + 1); +COUNT(*) +6 +SELECT COUNT(*) FROM t1 ORDER BY SUM(a) + 1; +COUNT(*) +6 +SELECT COUNT(*) FROM t1 ORDER BY SUM(a), b; +COUNT(*) +6 +SELECT SUM(a) FROM t1 ORDER BY COUNT(b); +SUM(a) +17 +SELECT t1.a FROM t1 ORDER BY (SELECT SUM(t2.a) FROM t2); +a +3 +2 +3 +2 +3 +4 +SELECT t1.a FROM t1 ORDER BY (SELECT SUM(t2.a), t2.a FROM t2); +ERROR 21000: Operand should contain 1 column(s) +SELECT t1.a FROM t1 ORDER BY (SELECT SUM(t2.a) FROM t2 ORDER BY t2.a); +a +3 +2 +3 +2 +3 +4 +SELECT t1.a FROM t1 ORDER BY (SELECT t2.a FROM t2 ORDER BY SUM(t2.b) LIMIT 1); +ERROR HY000: Expression #1 of ORDER BY contains aggregate function and applies to the result of a non-aggregated query +SELECT t1.a FROM t1 +WHERE t1.a = (SELECT t2.a FROM t2 ORDER BY SUM(t2.b) LIMIT 1); +ERROR HY000: Expression #1 of ORDER BY contains aggregate function and applies to the result of a non-aggregated query +SELECT t1.a FROM t1 GROUP BY t1.a +HAVING t1.a = (SELECT t2.a FROM t2 ORDER BY SUM(t2.a) LIMIT 1); +ERROR HY000: Expression #1 of ORDER BY contains aggregate function and applies to the result of a non-aggregated query +SELECT t1.a FROM t1 GROUP BY t1.a +HAVING t1.a IN (SELECT t2.a FROM t2 ORDER BY SUM(t1.b)); +a +2 +3 +4 +SELECT t1.a FROM t1 GROUP BY t1.a +HAVING t1.a IN (SELECT t2.a FROM t2 ORDER BY t2.a, SUM(t2.b)); +ERROR HY000: Expression #2 of ORDER BY contains aggregate function and applies to the result of a non-aggregated query +SELECT t1.a FROM t1 GROUP BY t1.a +HAVING t1.a > ANY (SELECT t2.a FROM t2 ORDER BY t2.a, SUM(t2.b)); +ERROR HY000: Expression #2 of ORDER BY contains aggregate function and applies to the result of a non-aggregated query +SELECT t1.a FROM t1 +WHERE t1.a = (SELECT t2.a FROM t2 ORDER BY SUM(t1.b)); +ERROR HY000: Expression #1 of ORDER BY contains aggregate function and applies to the result of a non-aggregated query +SELECT 1 FROM t1 GROUP BY t1.a +HAVING (SELECT AVG(SUM(t1.b) + 1) FROM t2 ORDER BY SUM(t2.a) LIMIT 1); +1 +1 +1 +1 +SELECT 1 FROM t1 GROUP BY t1.a +HAVING (SELECT AVG(SUM(t1.b) + t2.b) FROM t2 ORDER BY SUM(t2.a) LIMIT 1); +1 +1 +1 +1 +SELECT 1 FROM t1 GROUP BY t1.a +HAVING (SELECT AVG(t1.b + t2.b) FROM t2 ORDER BY SUM(t2.a) LIMIT 1); +ERROR 42000: Expression #1 of HAVING clause is not in GROUP BY clause and contains nonaggregated column 'test.t1.b' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +SELECT 1 FROM t1 GROUP BY t1.a +HAVING (SELECT AVG(SUM(t1.b) + 1) FROM t2 ORDER BY t2.a LIMIT 1); +1 +1 +1 +1 +SELECT 1 FROM t1 GROUP BY t1.a +HAVING (SELECT AVG(SUM(t1.b) + t2.b) FROM t2 ORDER BY t2.a LIMIT 1); +1 +1 +1 +1 +SELECT 1 FROM t1 GROUP BY t1.a +HAVING (SELECT AVG(t1.b + t2.b) FROM t2 ORDER BY t2.a LIMIT 1); +ERROR 42000: Expression #1 of HAVING clause is not in GROUP BY clause and contains nonaggregated column 'test.t1.b' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +SELECT t1.a FROM t1 +WHERE t1.a = (SELECT t2.a FROM t2 GROUP BY t2.a +ORDER BY SUM(t2.b), SUM(t1.b) LIMIT 1); +a +4 +SELECT t1.a, SUM(t1.b) FROM t1 +WHERE t1.a = (SELECT SUM(t2.b) FROM t2 GROUP BY t2.a +ORDER BY SUM(t2.b), SUM(t1.b) LIMIT 1) +GROUP BY t1.a; +a SUM(t1.b) +4 4 +SELECT t1.a, SUM(t1.b) FROM t1 +WHERE t1.a = (SELECT SUM(t2.b) FROM t2 +ORDER BY SUM(t2.b) + SUM(t1.b) LIMIT 1) +GROUP BY t1.a; +a SUM(t1.b) +SELECT t1.a, SUM(t1.b) FROM t1 +WHERE t1.a = (SELECT SUM(t2.b) FROM t2 +ORDER BY SUM(t2.b + t1.a) LIMIT 1) +GROUP BY t1.a; +a SUM(t1.b) +SELECT t1.a FROM t1 GROUP BY t1.a +HAVING (1, 1) = (SELECT SUM(t1.a), t1.a FROM t2 LIMIT 1); +a +select avg ( +(select +(select sum(outr.a + innr.a) from t1 as innr limit 1) as tt +from t1 as outr order by outr.a limit 1)) +from t1 as most_outer; +avg ( +(select +(select sum(outr.a + innr.a) from t1 as innr limit 1) as tt +from t1 as outr order by outr.a limit 1)) +29.0000 +select avg ( +(select ( +(select sum(outr.a + innr.a) from t1 as innr limit 1)) as tt +from t1 as outr order by count(outr.a) limit 1)) as tt +from t1 as most_outer; +ERROR HY000: Expression #1 of ORDER BY contains aggregate function and applies to the result of a non-aggregated query +select (select sum(outr.a + t1.a) from t1 limit 1) as tt from t1 as outr order by outr.a; +tt +29 +29 +35 +35 +35 +41 +SET sql_mode=@save_sql_mode; +DROP TABLE t1, t2; +# +# BUG#38072: Wrong result: HAVING not observed in a query with aggregate +# +CREATE TABLE t1 ( +pk int(11) NOT NULL AUTO_INCREMENT, +int_nokey int(11) NOT NULL, +int_key int(11) NOT NULL, +varchar_key varchar(1) NOT NULL, +varchar_nokey varchar(1) NOT NULL, +PRIMARY KEY (pk), +KEY int_key (int_key), +KEY varchar_key (varchar_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES +(1,5,5, 'h','h'), +(2,1,1, '{','{'), +(3,1,1, 'z','z'), +(4,8,8, 'x','x'), +(5,7,7, 'o','o'), +(6,3,3, 'p','p'), +(7,9,9, 'c','c'), +(8,0,0, 'k','k'), +(9,6,6, 't','t'), +(10,0,0,'c','c'); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +explain SELECT COUNT(varchar_key) AS x FROM t1 WHERE pk = 8 having 'foo'='bar'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible HAVING +Warnings: +Note 1003 /* select#1 */ select count(`test`.`t1`.`varchar_key`) AS `x` from `test`.`t1` where multiple equal(8, `test`.`t1`.`pk`) having false +SELECT COUNT(varchar_key) AS x FROM t1 WHERE pk = 8 having 'foo'='bar'; +x +drop table t1; +End of 5.0 tests +CREATE TABLE t1 (a INT, b INT, +PRIMARY KEY (a), +KEY i2(a,b)); +INSERT INTO t1 VALUES (1,1),(2,2),(3,3),(4,4),(5,5),(6,6),(7,7),(8,8); +INSERT INTO t1 SELECT a + 8,b FROM t1; +INSERT INTO t1 SELECT a + 16,b FROM t1; +INSERT INTO t1 SELECT a + 32,b FROM t1; +INSERT INTO t1 SELECT a + 64,b FROM t1; +INSERT INTO t1 SELECT a + 128,b FROM t1 limit 16; +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT a FROM t1 WHERE a < 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range PRIMARY,i2 PRIMARY 4 NULL 1 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` < 2) +EXPLAIN SELECT a FROM t1 WHERE a < 2 ORDER BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range PRIMARY,i2 PRIMARY 4 NULL 1 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` < 2) order by `test`.`t1`.`a` +EXPLAIN SELECT a FROM t1 WHERE a < 2 GROUP BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range PRIMARY,i2 PRIMARY 4 NULL 1 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` < 2) group by `test`.`t1`.`a` +EXPLAIN SELECT a FROM t1 IGNORE INDEX (PRIMARY,i2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 144 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 144 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` IGNORE INDEX (`i2`) IGNORE INDEX (PRIMARY) +EXPLAIN SELECT a FROM t1 IGNORE INDEX FOR JOIN (PRIMARY,i2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 144 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 144 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` IGNORE INDEX FOR JOIN (`i2`) IGNORE INDEX FOR JOIN (PRIMARY) +EXPLAIN SELECT a FROM t1 IGNORE INDEX FOR GROUP BY (PRIMARY,i2) GROUP BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 144 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index PRIMARY,i2 PRIMARY 4 NULL 144 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` IGNORE INDEX FOR GROUP BY (`i2`) IGNORE INDEX FOR GROUP BY (PRIMARY) group by `test`.`t1`.`a` +FLUSH STATUS; +SELECT a FROM t1 IGNORE INDEX FOR GROUP BY (PRIMARY,i2) GROUP BY a; +SHOW SESSION STATUS LIKE 'Sort_scan%'; +Variable_name Value +Sort_scan 0 +EXPLAIN SELECT a FROM t1 IGNORE INDEX FOR ORDER BY (PRIMARY,i2) ORDER BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 144 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL PRIMARY 4 NULL 144 100.00 Using index; Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` IGNORE INDEX FOR ORDER BY (`i2`) IGNORE INDEX FOR ORDER BY (PRIMARY) order by `test`.`t1`.`a` +FLUSH STATUS; +SELECT a FROM t1 IGNORE INDEX FOR ORDER BY (PRIMARY,i2) ORDER BY a; +SHOW SESSION STATUS LIKE 'Sort_scan%'; +Variable_name Value +Sort_scan 1 +SELECT a FROM t1 IGNORE INDEX FOR ORDER BY (PRIMARY,i2) ORDER BY a; +a +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +40 +41 +42 +43 +44 +45 +46 +47 +48 +49 +50 +51 +52 +53 +54 +55 +56 +57 +58 +59 +60 +61 +62 +63 +64 +65 +66 +67 +68 +69 +70 +71 +72 +73 +74 +75 +76 +77 +78 +79 +80 +81 +82 +83 +84 +85 +86 +87 +88 +89 +90 +91 +92 +93 +94 +95 +96 +97 +98 +99 +100 +101 +102 +103 +104 +105 +106 +107 +108 +109 +110 +111 +112 +113 +114 +115 +116 +117 +118 +119 +120 +121 +122 +123 +124 +125 +126 +127 +128 +129 +130 +131 +132 +133 +134 +135 +136 +137 +138 +139 +140 +141 +142 +143 +144 +EXPLAIN SELECT a FROM t1 IGNORE INDEX FOR ORDER BY (PRIMARY) +IGNORE INDEX FOR GROUP BY (i2) GROUP BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 144 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index PRIMARY,i2 PRIMARY 4 NULL 144 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` IGNORE INDEX FOR GROUP BY (`i2`) IGNORE INDEX FOR ORDER BY (PRIMARY) group by `test`.`t1`.`a` +EXPLAIN SELECT a FROM t1 IGNORE INDEX (PRIMARY) IGNORE INDEX FOR ORDER BY (i2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 144 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL i2 9 NULL 144 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` IGNORE INDEX FOR ORDER BY (`i2`) IGNORE INDEX (PRIMARY) +EXPLAIN SELECT a FROM t1 FORCE INDEX (i2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 144 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL i2 9 NULL 144 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` FORCE INDEX (`i2`) +EXPLAIN SELECT a FROM t1 USE INDEX (); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 144 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 144 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` USE INDEX () +EXPLAIN SELECT a FROM t1 USE INDEX () USE INDEX (i2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 144 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 144 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` USE INDEX (`i2`) USE INDEX () +EXPLAIN SELECT a FROM t1 +FORCE INDEX (PRIMARY) +IGNORE INDEX FOR GROUP BY (i2) +IGNORE INDEX FOR ORDER BY (i2) +USE INDEX (i2); +ERROR HY000: Incorrect usage of USE INDEX and FORCE INDEX +EXPLAIN SELECT a FROM t1 USE INDEX (i2) USE INDEX (); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 144 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL i2 9 NULL 144 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` USE INDEX () USE INDEX (`i2`) +EXPLAIN SELECT a FROM t1 FORCE INDEX (); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')' at line 1 +EXPLAIN SELECT a FROM t1 IGNORE INDEX (); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')' at line 1 +EXPLAIN SELECT a FROM t1 USE INDEX FOR JOIN (i2) +USE INDEX FOR GROUP BY (i2) GROUP BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index i2 i2 9 NULL # 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` USE INDEX FOR GROUP BY (`i2`) USE INDEX FOR JOIN (`i2`) group by `test`.`t1`.`a` +EXPLAIN SELECT a FROM t1 FORCE INDEX FOR JOIN (i2) +FORCE INDEX FOR GROUP BY (i2) GROUP BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 144 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index i2 i2 9 NULL 144 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` FORCE INDEX FOR GROUP BY (`i2`) FORCE INDEX FOR JOIN (`i2`) group by `test`.`t1`.`a` +EXPLAIN SELECT a FROM t1 USE INDEX () IGNORE INDEX (i2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 144 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 144 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` IGNORE INDEX (`i2`) USE INDEX () +EXPLAIN SELECT a FROM t1 IGNORE INDEX (i2) USE INDEX (); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 144 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 144 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` USE INDEX () IGNORE INDEX (`i2`) +EXPLAIN SELECT a FROM t1 +USE INDEX FOR GROUP BY (i2) +USE INDEX FOR ORDER BY (i2) +USE INDEX FOR JOIN (i2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 144 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL i2 9 NULL 144 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` USE INDEX FOR JOIN (`i2`) USE INDEX FOR ORDER BY (`i2`) USE INDEX FOR GROUP BY (`i2`) +EXPLAIN SELECT a FROM t1 +USE INDEX FOR JOIN (i2) +USE INDEX FOR JOIN (i2) +USE INDEX FOR JOIN (i2,i2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 144 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL i2 9 NULL 144 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` USE INDEX FOR JOIN (`i2`) USE INDEX FOR JOIN (`i2`) USE INDEX FOR JOIN (`i2`) USE INDEX FOR JOIN (`i2`) +EXPLAIN SELECT 1 FROM t1 WHERE a IN +(SELECT a FROM t1 USE INDEX (i2) IGNORE INDEX (i2)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index PRIMARY,i2 PRIMARY 4 NULL 144 100.00 Using index +1 SIMPLE NULL eq_ref 4 test.t1.a 1 100.00 NULL +2 MATERIALIZED t1 NULL ALL NULL NULL NULL NULL 144 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` semi join (`test`.`t1` IGNORE INDEX (`i2`) USE INDEX (`i2`)) where (``.`a` = `test`.`t1`.`a`) +CREATE TABLE t2 (a INT, b INT, KEY(a)); +INSERT INTO t2 VALUES (1, 1), (2, 2), (3,3), (4,4); +EXPLAIN SELECT a, SUM(b) FROM t2 GROUP BY a LIMIT 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL index a a 5 NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,sum(`test`.`t2`.`b`) AS `SUM(b)` from `test`.`t2` group by `test`.`t2`.`a` limit 2 +EXPLAIN SELECT a, SUM(b) FROM t2 IGNORE INDEX (a) GROUP BY a LIMIT 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 4 100.00 Using temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,sum(`test`.`t2`.`b`) AS `SUM(b)` from `test`.`t2` IGNORE INDEX (`a`) group by `test`.`t2`.`a` limit 2 +ANALYZE TABLE t2; +Table Op Msg_type Msg_text +test.t2 analyze status OK +EXPLAIN SELECT 1 FROM t2 WHERE a IN +(SELECT a FROM t1 USE INDEX (i2) IGNORE INDEX (i2)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index a a 5 NULL 4 100.00 Using where; Using index +1 SIMPLE NULL eq_ref 4 test.t2.a 1 100.00 NULL +2 MATERIALIZED t1 NULL ALL NULL NULL NULL NULL 144 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t2` semi join (`test`.`t1` IGNORE INDEX (`i2`) USE INDEX (`i2`)) where (``.`a` = `test`.`t2`.`a`) +SHOW VARIABLES LIKE 'old'; +Variable_name Value +old OFF +SET @@old = off; +ERROR HY000: Variable 'old' is a read only variable +DROP TABLE t1, t2; +CREATE TABLE t1( +a INT, +b INT NOT NULL, +c INT NOT NULL, +d INT, +UNIQUE KEY (c,b) +); +INSERT INTO t1 VALUES (1,1,1,50), (1,2,3,40), (2,1,3,4); +CREATE TABLE t2( +a INT, +b INT, +UNIQUE KEY(a,b) +); +INSERT INTO t2 VALUES (NULL, NULL), (NULL, NULL), (NULL, 1), (1, NULL), (1, 1), (1,2); +ANALYZE TABLE t1,t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN SELECT c,b,d FROM t1 GROUP BY c,b,d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c` AS `c`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`d` AS `d` from `test`.`t1` group by `test`.`t1`.`c`,`test`.`t1`.`b`,`test`.`t1`.`d` +SELECT c,b,d FROM t1 GROUP BY c,b,d; +c b d +1 1 50 +3 1 4 +3 2 40 +EXPLAIN SELECT c,b,d FROM t1 GROUP BY c,b,d ORDER BY NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c` AS `c`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`d` AS `d` from `test`.`t1` group by `test`.`t1`.`c`,`test`.`t1`.`b`,`test`.`t1`.`d` order by NULL +SELECT c,b,d FROM t1 GROUP BY c,b,d ORDER BY NULL; +c b d +1 1 50 +3 1 4 +3 2 40 +EXPLAIN SELECT c,b,d FROM t1 ORDER BY c,b,d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c` AS `c`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`d` AS `d` from `test`.`t1` order by `test`.`t1`.`c`,`test`.`t1`.`b`,`test`.`t1`.`d` +SELECT c,b,d FROM t1 ORDER BY c,b,d; +c b d +1 1 50 +3 1 4 +3 2 40 +EXPLAIN SELECT c,b,d FROM t1 GROUP BY c,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL c NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c` AS `c`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`d` AS `d` from `test`.`t1` group by `test`.`t1`.`c`,`test`.`t1`.`b` +SELECT c,b,d FROM t1 GROUP BY c,b; +c b d +1 1 50 +3 1 4 +3 2 40 +EXPLAIN SELECT c,b FROM t1 GROUP BY c,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index c c 8 NULL 3 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c` AS `c`,`test`.`t1`.`b` AS `b` from `test`.`t1` group by `test`.`t1`.`c`,`test`.`t1`.`b` +SELECT c,b FROM t1 GROUP BY c,b; +c b +1 1 +3 1 +3 2 +EXPLAIN SELECT a,b from t2 ORDER BY a,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 6 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL index NULL a 10 NULL 6 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t2` order by `test`.`t2`.`a`,`test`.`t2`.`b` +SELECT a,b from t2 ORDER BY a,b; +a b +NULL NULL +NULL NULL +NULL 1 +1 NULL +1 1 +1 2 +EXPLAIN SELECT a,b from t2 GROUP BY a,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 6 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL index a a 10 NULL 6 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t2` group by `test`.`t2`.`a`,`test`.`t2`.`b` +SELECT a,b from t2 GROUP BY a,b; +a b +NULL NULL +NULL 1 +1 NULL +1 1 +1 2 +EXPLAIN SELECT a from t2 GROUP BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range a a 5 NULL 3 100.00 Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` group by `test`.`t2`.`a` +SELECT a from t2 GROUP BY a; +a +NULL +1 +EXPLAIN SELECT b from t2 GROUP BY b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 6 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL index a a 10 NULL 6 100.00 Using index; Using temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`b` AS `b` from `test`.`t2` group by `test`.`t2`.`b` +SELECT b from t2 GROUP BY b; +b +NULL +1 +2 +DROP TABLE t1; +DROP TABLE t2; +CREATE TABLE t1 ( a INT, b INT ); +SELECT b c, (SELECT a FROM t1 WHERE b = c) +FROM t1; +c (SELECT a FROM t1 WHERE b = c) +SELECT b c, (SELECT a FROM t1 WHERE b = c) +FROM t1 +HAVING b = 10; +c (SELECT a FROM t1 WHERE b = c) +SELECT MAX(b) c, (SELECT a FROM t1 WHERE b = c) +FROM t1 +HAVING b = 10; +ERROR 42S22: Reference 'c' not supported (reference to group function) +SET @old_sql_mode = @@sql_mode; +SET @@sql_mode='ONLY_FULL_GROUP_BY'; +SELECT b c, (SELECT a FROM t1 WHERE b = c) +FROM t1; +c (SELECT a FROM t1 WHERE b = c) +SELECT b c, (SELECT a FROM t1 WHERE b = c) +FROM t1 +HAVING b = 10; +c (SELECT a FROM t1 WHERE b = c) +SELECT MAX(b) c, (SELECT a FROM t1 WHERE b = c) +FROM t1 +HAVING b = 10; +ERROR 42S22: Reference 'c' not supported (reference to group function) +INSERT INTO t1 VALUES (1, 1); +SELECT b c, (SELECT a FROM t1 WHERE b = c) +FROM t1; +c (SELECT a FROM t1 WHERE b = c) +1 1 +INSERT INTO t1 VALUES (2, 1); +SELECT b c, (SELECT a FROM t1 WHERE b = c) +FROM t1; +ERROR 21000: Subquery returns more than 1 row +DROP TABLE t1; +SET @@sql_mode = @old_sql_mode; +SET @old_sql_mode = @@sql_mode; +SET @@sql_mode='ONLY_FULL_GROUP_BY'; +CREATE TABLE t1(i INT); +INSERT INTO t1 VALUES (1), (10); +SELECT COUNT(i) FROM t1; +COUNT(i) +2 +SELECT COUNT(i) FROM t1 WHERE i > 1; +COUNT(i) +1 +DROP TABLE t1; +SET @@sql_mode = @old_sql_mode; +# +# Bug #45640: optimizer bug produces wrong results +# +CREATE TABLE t1 (a INT, b INT); +INSERT INTO t1 VALUES (4, 40), (1, 10), (2, 20), (2, 20), (3, 30); +# should return 4 ordered records: +SELECT (SELECT t1.a) aa, COUNT(DISTINCT b) FROM t1 GROUP BY aa; +aa COUNT(DISTINCT b) +1 1 +2 1 +3 1 +4 1 +SELECT (SELECT (SELECT t1.a)) aa, COUNT(DISTINCT b) FROM t1 GROUP BY aa; +aa COUNT(DISTINCT b) +1 1 +2 1 +3 1 +4 1 +SELECT (SELECT t1.a) aa, COUNT(DISTINCT b) FROM t1 GROUP BY aa+0; +aa COUNT(DISTINCT b) +1 1 +2 1 +3 1 +4 1 +# should return the same result in a reverse order: +SELECT (SELECT t1.a) aa, COUNT(DISTINCT b) FROM t1 GROUP BY -aa; +aa COUNT(DISTINCT b) +4 1 +3 1 +2 1 +1 1 +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +# execution plan should not use temporary table: +EXPLAIN +SELECT (SELECT t1.a) aa, COUNT(DISTINCT b) FROM t1 GROUP BY aa+0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 100.00 Using temporary; Using filesort +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 +Note 1249 Select 2 was reduced during optimization +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `aa`,count(distinct `test`.`t1`.`b`) AS `COUNT(DISTINCT b)` from `test`.`t1` group by (`a` + 0) +EXPLAIN +SELECT (SELECT t1.a) aa, COUNT(DISTINCT b) FROM t1 GROUP BY -aa; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 100.00 Using temporary; Using filesort +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 +Note 1249 Select 2 was reduced during optimization +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `aa`,count(distinct `test`.`t1`.`b`) AS `COUNT(DISTINCT b)` from `test`.`t1` group by -(`a`) +# should return only one record +SELECT (SELECT tt.a FROM t1 tt LIMIT 1) aa, COUNT(DISTINCT b) FROM t1 +GROUP BY aa; +aa COUNT(DISTINCT b) +4 4 +CREATE TABLE t2 SELECT DISTINCT a FROM t1; +# originally reported queries (1st two columns of next two query +# results should be same): +SELECT (SELECT t2.a FROM t2 WHERE t2.a = t1.a) aa, b, COUNT(DISTINCT b) +FROM t1 GROUP BY aa, b; +aa b COUNT(DISTINCT b) +1 10 1 +2 20 1 +3 30 1 +4 40 1 +SELECT (SELECT t2.a FROM t2 WHERE t2.a = t1.a) aa, b, COUNT( b) +FROM t1 GROUP BY aa, b; +aa b COUNT( b) +1 10 1 +2 20 2 +3 30 1 +4 40 1 +# ORDER BY for sure: +SELECT (SELECT t2.a FROM t2 WHERE t2.a = t1.a) aa, b, COUNT(DISTINCT b) +FROM t1 GROUP BY aa, b ORDER BY -aa, -b; +aa b COUNT(DISTINCT b) +4 40 1 +3 30 1 +2 20 1 +1 10 1 +SELECT (SELECT t2.a FROM t2 WHERE t2.a = t1.a) aa, b, COUNT( b) +FROM t1 GROUP BY aa, b ORDER BY -aa, -b; +aa b COUNT( b) +4 40 1 +3 30 1 +2 20 2 +1 10 1 +DROP TABLE t1, t2; +# +# Bug#52051: Aggregate functions incorrectly returns NULL from outer +# join query +# +CREATE TABLE t1 (a INT PRIMARY KEY); +CREATE TABLE t2 (a INT PRIMARY KEY); +INSERT INTO t2 VALUES (1), (2); +ANALYZE TABLE t1,t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN SELECT MIN(t2.a) FROM t2 LEFT JOIN t1 ON t2.a = t1.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Select tables optimized away +Warnings: +Note 1003 /* select#1 */ select min(`test`.`t2`.`a`) AS `MIN(t2.a)` from `test`.`t2` left join `test`.`t1` on(multiple equal(`test`.`t2`.`a`, `test`.`t1`.`a`)) +SELECT MIN(t2.a) FROM t2 LEFT JOIN t1 ON t2.a = t1.a; +MIN(t2.a) +1 +EXPLAIN SELECT MAX(t2.a) FROM t2 LEFT JOIN t1 ON t2.a = t1.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Select tables optimized away +Warnings: +Note 1003 /* select#1 */ select max(`test`.`t2`.`a`) AS `MAX(t2.a)` from `test`.`t2` left join `test`.`t1` on(multiple equal(`test`.`t2`.`a`, `test`.`t1`.`a`)) +SELECT MAX(t2.a) FROM t2 LEFT JOIN t1 ON t2.a = t1.a; +MAX(t2.a) +2 +DROP TABLE t1, t2; +# +# Bug#55188: GROUP BY, GROUP_CONCAT and TEXT - inconsistent results +# +CREATE TABLE t1 (a text, b varchar(10)); +INSERT INTO t1 VALUES (repeat('1', 1300),'one'), (repeat('1', 1300),'two'); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN +SELECT SUBSTRING(a,1,10), LENGTH(a), GROUP_CONCAT(b) FROM t1 GROUP BY a; +id 1 +select_type SIMPLE +table t1 +partitions NULL +type ALL +possible_keys NULL +key NULL +key_len NULL +ref NULL +rows 2 +filtered 100.00 +Extra Using filesort +Warnings: +Level Note +Code 1003 +Message /* select#1 */ select substr(`test`.`t1`.`a`,1,10) AS `SUBSTRING(a,1,10)`,length(`test`.`t1`.`a`) AS `LENGTH(a)`,group_concat(`test`.`t1`.`b` separator ',') AS `GROUP_CONCAT(b)` from `test`.`t1` group by `test`.`t1`.`a` +SELECT SUBSTRING(a,1,10), LENGTH(a), GROUP_CONCAT(b) FROM t1 GROUP BY a; +SUBSTRING(a,1,10) LENGTH(a) GROUP_CONCAT(b) +1111111111 1300 one,two +EXPLAIN +SELECT SUBSTRING(a,1,10), LENGTH(a) FROM t1 GROUP BY a; +id 1 +select_type SIMPLE +table t1 +partitions NULL +type ALL +possible_keys NULL +key NULL +key_len NULL +ref NULL +rows 2 +filtered 100.00 +Extra Using temporary +Warnings: +Level Note +Code 1003 +Message /* select#1 */ select substr(`test`.`t1`.`a`,1,10) AS `SUBSTRING(a,1,10)`,length(`test`.`t1`.`a`) AS `LENGTH(a)` from `test`.`t1` group by `test`.`t1`.`a` +SELECT SUBSTRING(a,1,10), LENGTH(a) FROM t1 GROUP BY a; +SUBSTRING(a,1,10) LENGTH(a) +1111111111 1300 +DROP TABLE t1; +# +# Bug#57688 Assertion `!table || (!table->write_set || bitmap_is_set(table->write_set, field +# +CREATE TABLE t1(f1 INT NOT NULL); +INSERT INTO t1 VALUES (16777214),(0); +SELECT COUNT(*) FROM t1 LEFT JOIN t1 t2 +ON 1 WHERE t2.f1 > 1 GROUP BY t2.f1; +COUNT(*) +2 +DROP TABLE t1; +# +# Bug#12798270: ASSERTION `!TAB->SORTED' FAILED IN JOIN_READ_KEY2 +# +CREATE TABLE t1 (i int); +INSERT INTO t1 VALUES (1); +CREATE TABLE t2 (pk int PRIMARY KEY); +INSERT INTO t2 VALUES (10); +CREATE VIEW v1 AS SELECT t2.pk FROM t2; +SELECT v1.pk +FROM t1 LEFT JOIN v1 ON t1.i = v1.pk +GROUP BY v1.pk; +pk +NULL +DROP VIEW v1; +DROP TABLE t1,t2; +# End of Bug#12798270 +# +# Bug#59839: Aggregation followed by subquery yields wrong result +# +CREATE TABLE t1 ( +a INT, +b INT, +c INT, +KEY (a, b) +); +INSERT INTO t1 VALUES +( 1, 1, 1 ), +( 1, 2, 2 ), +( 1, 3, 3 ), +( 1, 4, 6 ), +( 1, 5, 5 ), +( 1, 9, 13 ), +( 2, 1, 6 ), +( 2, 2, 7 ), +( 2, 3, 8 ); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN +SELECT a, AVG(t1.b), +(SELECT t11.c FROM t1 t11 WHERE t11.a = t1.a AND t11.b = AVG(t1.b)) AS t11c, +(SELECT t12.c FROM t1 t12 WHERE t12.a = t1.a AND t12.b = AVG(t1.b)) AS t12c +FROM t1 GROUP BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL index a a 10 NULL 9 100.00 Using index +3 DEPENDENT SUBQUERY t12 NULL ref a a 10 func,func 1 100.00 Using where +2 DEPENDENT SUBQUERY t11 NULL ref a a 10 func,func 1 100.00 Using where +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 +Note 1276 Field or reference 'test.t1.b' of SELECT #2 was resolved in SELECT #1 +Note 1276 Field or reference 'test.t1.a' 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#1 */ select `test`.`t1`.`a` AS `a`,avg(`test`.`t1`.`b`) AS `AVG(t1.b)`,(/* select#2 */ select `test`.`t11`.`c` from `test`.`t1` `t11` where ((`test`.`t11`.`a` = `test`.`t1`.`a`) and (`test`.`t11`.`b` = avg(`test`.`t1`.`b`)))) AS `t11c`,(/* select#3 */ select `test`.`t12`.`c` from `test`.`t1` `t12` where ((`test`.`t12`.`a` = `test`.`t1`.`a`) and (`test`.`t12`.`b` = avg(`test`.`t1`.`b`)))) AS `t12c` from `test`.`t1` group by `test`.`t1`.`a` +SELECT a, AVG(t1.b), +(SELECT t11.c FROM t1 t11 WHERE t11.a = t1.a AND t11.b = AVG(t1.b)) AS t11c, +(SELECT t12.c FROM t1 t12 WHERE t12.a = t1.a AND t12.b = AVG(t1.b)) AS t12c +FROM t1 GROUP BY a; +a AVG(t1.b) t11c t12c +1 4.0000 6 6 +2 2.0000 7 7 +DROP TABLE t1; +# +# Bug#11765254 (58200): Assertion failed: param.sort_length when grouping +# by functions +# +SET BIG_TABLES=1; +CREATE TABLE t1(a INT); +INSERT INTO t1 VALUES (0),(0); +SELECT 1 FROM t1 GROUP BY IF(`a`,'',''); +ERROR 42000: The used storage engine can't index column '`if(t1.a,'','')`' +SELECT 1 FROM t1 GROUP BY TRIM(LEADING RAND() FROM ''); +1 +1 +SELECT 1 FROM t1 GROUP BY SUBSTRING('',SLEEP(0),''); +1 +1 +Warnings: +Warning 1292 Truncated incorrect INTEGER value: '' +Warning 1292 Truncated incorrect INTEGER value: '' +Warning 1292 Truncated incorrect INTEGER value: '' +SELECT 1 FROM t1 GROUP BY SUBSTRING(SYSDATE() FROM 'K' FOR 'jxW<'); +1 +1 +Warnings: +Warning 1292 Truncated incorrect INTEGER value: 'K' +Warning 1292 Truncated incorrect INTEGER value: 'jxW<' +Warning 1292 Truncated incorrect INTEGER value: 'K' +Warning 1292 Truncated incorrect INTEGER value: 'jxW<' +Warning 1292 Truncated incorrect INTEGER value: 'K' +Warning 1292 Truncated incorrect INTEGER value: 'jxW<' +Warning 1292 Truncated incorrect INTEGER value: 'K' +Warning 1292 Truncated incorrect INTEGER value: 'jxW<' +Warning 1292 Truncated incorrect INTEGER value: 'K' +Warning 1292 Truncated incorrect INTEGER value: 'jxW<' +DROP TABLE t1; +SET BIG_TABLES=0; +# End of 5.1 tests +# +# Bug#49771: Incorrect MIN (date) when minimum value is 0000-00-00 +# +SET @save_sql_mode=@@sql_mode; +SET @@sql_mode='ONLY_FULL_GROUP_BY'; +CREATE TABLE t1 (f1 int, f2 DATE); +INSERT INTO t1 VALUES (1,'2004-04-19'), (1,'0000-00-00'), (1,'2004-04-18'), +(2,'2004-05-19'), (2,'0001-01-01'), (3,'2004-04-10'); +SELECT MIN(f2),MAX(f2) FROM t1; +MIN(f2) MAX(f2) +0000-00-00 2004-05-19 +SELECT f1,MIN(f2),MAX(f2) FROM t1 GROUP BY 1; +f1 MIN(f2) MAX(f2) +1 0000-00-00 2004-04-19 +2 0001-01-01 2004-05-19 +3 2004-04-10 2004-04-10 +DROP TABLE t1; +CREATE TABLE t1 ( f1 int, f2 time); +INSERT INTO t1 VALUES (1,'01:27:35'), (1,'06:11:01'), (2,'19:53:05'), +(2,'21:44:25'), (3,'10:55:12'), (3,'05:45:11'), (4,'00:25:00'); +SELECT MIN(f2),MAX(f2) FROM t1; +MIN(f2) MAX(f2) +00:25:00 21:44:25 +SELECT f1,MIN(f2),MAX(f2) FROM t1 GROUP BY 1; +f1 MIN(f2) MAX(f2) +1 01:27:35 06:11:01 +2 19:53:05 21:44:25 +3 05:45:11 10:55:12 +4 00:25:00 00:25:00 +DROP TABLE t1; +SET sql_mode=@save_sql_mode; +#End of test#49771 +# +# Bug #58782 +# Missing rows with SELECT .. WHERE .. IN subquery +# with full GROUP BY and no aggr +# +CREATE TABLE t1 ( +pk INT NOT NULL, +col_int_nokey INT, +PRIMARY KEY (pk) +); +INSERT INTO t1 VALUES (10,7); +INSERT INTO t1 VALUES (11,1); +INSERT INTO t1 VALUES (12,5); +INSERT INTO t1 VALUES (13,3); +SELECT pk AS field1, col_int_nokey AS field2 +FROM t1 +WHERE col_int_nokey > 0 +GROUP BY field1, field2; +field1 field2 +10 7 +11 1 +12 5 +13 3 +CREATE TABLE where_subselect +SELECT pk AS field1, col_int_nokey AS field2 +FROM t1 +WHERE col_int_nokey > 0 +GROUP BY field1, field2 +; +SELECT * +FROM where_subselect +WHERE (field1, field2) IN ( +SELECT pk AS field1, col_int_nokey AS field2 +FROM t1 +WHERE col_int_nokey > 0 +GROUP BY field1, field2 +); +field1 field2 +10 7 +11 1 +12 5 +13 3 +DROP TABLE t1; +DROP TABLE where_subselect; +# End of Bug #58782 +# +# Bug #11766429 +# RE-EXECUTE OF PREPARED STATEMENT CRASHES IN ITEM_REF::FIX_FIELDS WITH +# +CREATE TABLE t1(a INT, KEY(a)); +INSERT INTO t1 VALUES (0); +CREATE TABLE t2(b INT, KEY(b)); +INSERT INTO t2 VALUES (0),(0); +PREPARE stmt FROM ' +SELECT 1 FROM t2 +LEFT JOIN t1 ON NULL +GROUP BY t2.b, t1.a +HAVING a <> 2'; +EXECUTE stmt; +1 +EXECUTE stmt; +1 +DEALLOCATE PREPARE stmt; +DROP TABLE t1, t2; +# End of Bug #11766429 +# +# Bug#12699645 SELECT SUM() + STRAIGHT_JOIN QUERY MISSES ROWS +# +CREATE TABLE t1 ( +pk INT, col_int_key INT, +col_varchar_key VARCHAR(1), col_varchar_nokey VARCHAR(1) +); +INSERT INTO t1 VALUES +(10,7,'v','v'),(11,0,'s','s'),(12,9,'l','l'),(13,3,'y','y'),(14,4,'c','c'), +(15,2,'i','i'),(16,5,'h','h'),(17,3,'q','q'),(18,1,'a','a'),(19,3,'v','v'), +(20,6,'u','u'),(21,7,'s','s'),(22,5,'y','y'),(23,1,'z','z'),(24,204,'h','h'), +(25,224,'p','p'),(26,9,'e','e'),(27,5,'i','i'),(28,0,'y','y'),(29,3,'w','w'); +CREATE TABLE t2 ( +pk INT, col_int_key INT, +col_varchar_key VARCHAR(1), col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk) +); +INSERT INTO t2 VALUES +(1,4,'b','b'),(2,8,'y','y'),(3,0,'p','p'),(4,0,'f','f'),(5,0,'p','p'), +(6,7,'d','d'),(7,7,'f','f'),(8,5,'j','j'),(9,3,'e','e'),(10,188,'u','u'), +(11,4,'v','v'),(12,9,'u','u'),(13,6,'i','i'),(14,1,'x','x'),(15,5,'l','l'), +(16,6,'q','q'),(17,2,'n','n'),(18,4,'r','r'),(19,231,'c','c'),(20,4,'h','h'), +(21,3,'k','k'),(22,3,'t','t'),(23,7,'t','t'),(24,6,'k','k'),(25,7,'g','g'), +(26,9,'z','z'),(27,4,'n','n'),(28,4,'j','j'),(29,2,'l','l'),(30,1,'d','d'), +(31,2,'t','t'),(32,194,'y','y'),(33,2,'i','i'),(34,3,'j','j'),(35,8,'r','r'), +(36,4,'b','b'),(37,9,'o','o'),(38,4,'k','k'),(39,5,'a','a'),(40,5,'f','f'), +(41,9,'t','t'),(42,3,'c','c'),(43,8,'c','c'),(44,0,'r','r'),(45,98,'k','k'), +(46,3,'l','l'),(47,1,'o','o'),(48,0,'t','t'),(49,189,'v','v'),(50,8,'x','x'), +(51,3,'j','j'),(52,3,'x','x'),(53,9,'k','k'),(54,6,'o','o'),(55,8,'z','z'), +(56,3,'n','n'),(57,9,'c','c'),(58,5,'d','d'),(59,9,'s','s'),(60,2,'j','j'), +(61,2,'w','w'),(62,5,'f','f'),(63,8,'p','p'),(64,6,'o','o'),(65,9,'f','f'), +(66,0,'x','x'),(67,3,'q','q'),(68,6,'g','g'),(69,5,'x','x'),(70,8,'p','p'), +(71,2,'q','q'),(72,120,'q','q'),(73,25,'v','v'),(74,1,'g','g'),(75,3,'l','l'), +(76,1,'w','w'),(77,3,'h','h'),(78,153,'c','c'),(79,5,'o','o'),(80,9,'o','o'), +(81,1,'v','v'),(82,8,'y','y'),(83,7,'d','d'),(84,6,'p','p'),(85,2,'z','z'), +(86,4,'t','t'),(87,7,'b','b'),(88,3,'y','y'),(89,8,'k','k'),(90,4,'c','c'), +(91,6,'z','z'),(92,1,'t','t'),(93,7,'o','o'),(94,1,'u','u'),(95,0,'t','t'), +(96,2,'k','k'),(97,7,'u','u'),(98,2,'b','b'),(99,1,'m','m'),(100,5,'o','o'); +ANALYZE TABLE t1,t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN SELECT SUM(alias2.col_varchar_nokey) , alias2.pk AS field2 FROM t1 AS alias1 +STRAIGHT_JOIN t2 AS alias2 ON alias2.pk = alias1.col_int_key WHERE alias1.pk +GROUP BY field2 ORDER BY alias1.col_int_key,alias2.pk ; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 90.00 Parallel execute (1 workers) +2 SIMPLE alias1 NULL ALL NULL NULL NULL NULL # 90.00 Using where; Using temporary; Using filesort +2 SIMPLE alias2 NULL eq_ref PRIMARY PRIMARY 4 test.alias1.col_int_key # 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select sum(`test`.`alias2`.`col_varchar_nokey`) AS `SUM(alias2.col_varchar_nokey)`,`test`.`alias2`.`pk` AS `field2` from `test`.`t1` `alias1` straight_join `test`.`t2` `alias2` where ((`test`.`alias2`.`pk` = `test`.`alias1`.`col_int_key`) and (0 <> `test`.`alias1`.`pk`)) group by `field2` order by `test`.`alias1`.`col_int_key` +SELECT SUM(alias2.col_varchar_nokey) , alias2.pk AS field2 FROM t1 AS alias1 +STRAIGHT_JOIN t2 AS alias2 ON alias2.pk = alias1.col_int_key WHERE alias1.pk +GROUP BY field2 ORDER BY alias1.col_int_key,alias2.pk ; +SUM(alias2.col_varchar_nokey) field2 +0 1 +0 2 +0 3 +0 4 +0 5 +0 6 +0 7 +0 9 +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'f' +Warning 1292 Truncated incorrect DOUBLE value: 'e' +Warning 1292 Truncated incorrect DOUBLE value: 'p' +Warning 1292 Truncated incorrect DOUBLE value: 'f' +Warning 1292 Truncated incorrect DOUBLE value: 'y' +Warning 1292 Truncated incorrect DOUBLE value: 'p' +Warning 1292 Truncated incorrect DOUBLE value: 'p' +Warning 1292 Truncated incorrect DOUBLE value: 'b' +Warning 1292 Truncated incorrect DOUBLE value: 'p' +Warning 1292 Truncated incorrect DOUBLE value: 'd' +Warning 1292 Truncated incorrect DOUBLE value: 'f' +Warning 1292 Truncated incorrect DOUBLE value: 'p' +Warning 1292 Truncated incorrect DOUBLE value: 'b' +Warning 1292 Truncated incorrect DOUBLE value: 'e' +Warning 1292 Truncated incorrect DOUBLE value: 'p' +Warning 1292 Truncated incorrect DOUBLE value: 'p' +DROP TABLE t1,t2; +# +# Bug#12798270: ASSERTION `!TAB->SORTED' FAILED IN JOIN_READ_KEY2 +# +CREATE TABLE t1 (i int); +INSERT INTO t1 VALUES (1); +CREATE TABLE t2 (pk int PRIMARY KEY); +INSERT INTO t2 VALUES (10); +CREATE VIEW v1 AS SELECT t2.pk FROM t2; +SELECT v1.pk +FROM t1 LEFT JOIN v1 ON t1.i = v1.pk +GROUP BY v1.pk; +pk +NULL +DROP VIEW v1; +DROP TABLE t1,t2; +# End of Bug#12798270 +# +# Bug#12837714: ADDITIONAL NULL IN 5.6 ON GROUPED SELECT +# +CREATE TABLE t1 (vc varchar(1), INDEX vc_idx (vc)) ; +INSERT INTO t1 VALUES (NULL), ('o'), (NULL), ('p'), ('c'); +FLUSH TABLE t1; +SELECT vc FROM t1 GROUP BY vc; +vc +NULL +c +o +p +DROP TABLE t1; +# End of Bug#12837714 +# +# Bug#12578908: SELECT SQL_BUFFER_RESULT OUTPUTS TOO MANY +# ROWS WHEN GROUP IS OPTIMIZED AWAY +# +CREATE TABLE t1 (col1 int, col2 int) ; +INSERT INTO t1 VALUES (10,1),(11,7); +CREATE TABLE t2 (col1 int, col2 int) ; +INSERT INTO t2 VALUES (10,8); +ANALYZE TABLE t1,t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK + +EXPLAIN SELECT SQL_BUFFER_RESULT t2.col2 FROM t2 JOIN t1 ON t1.col1 GROUP BY t2.col2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using temporary +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select sql_buffer_result `test`.`t2`.`col2` AS `col2` from `test`.`t2` join `test`.`t1` where (0 <> `test`.`t1`.`col1`) group by `test`.`t2`.`col2` +SELECT SQL_BUFFER_RESULT t2.col2 FROM t2 JOIN t1 ON t1.col1 GROUP BY t2.col2; +col2 +8 + +EXPLAIN SELECT t2.col2 FROM t2 JOIN t1 ON t1.col1 GROUP BY t2.col2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using temporary +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`col2` AS `col2` from `test`.`t2` join `test`.`t1` where (0 <> `test`.`t1`.`col1`) group by `test`.`t2`.`col2` +SELECT t2.col2 FROM t2 JOIN t1 ON t1.col1 GROUP BY t2.col2; +col2 +8 + +DROP TABLE t1,t2; +# +# Bug#11761078: 53534: INCORRECT 'SELECT SQL_BIG_RESULT...' +# WITH GROUP BY ON DUPLICATED FIELDS +# +CREATE TABLE t1( +col1 int, +INDEX idx (col1) +); +INSERT INTO t1 VALUES (1),(2),(3),(4),(5),(6),(7),(8),(9),(10), +(11),(12),(13),(14),(15),(16),(17),(18),(19),(20); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT SQL_BIG_RESULT col1 AS field1, col1 AS field2 +FROM t1 GROUP BY field1, field2;; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 20 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index idx idx 5 NULL 20 100.00 Using index; Using filesort +Warnings: +Note 1003 /* select#1 */ select sql_big_result `test`.`t1`.`col1` AS `field1`,`test`.`t1`.`col1` AS `field2` from `test`.`t1` group by `field1` +FLUSH STATUS; +SELECT SQL_BIG_RESULT col1 AS field1, col1 AS field2 +FROM t1 GROUP BY field1, field2;; +field1 field2 +1 1 +2 2 +3 3 +4 4 +5 5 +6 6 +7 7 +8 8 +9 9 +10 10 +11 11 +12 12 +13 13 +14 14 +15 15 +16 16 +17 17 +18 18 +19 19 +20 20 +SHOW SESSION STATUS LIKE 'Sort_scan%'; +Variable_name Value +Sort_scan 1 +CREATE VIEW v1 AS SELECT * FROM t1; +SELECT SQL_BIG_RESULT col1 AS field1, col1 AS field2 +FROM v1 +GROUP BY field1, field2; +field1 field2 +1 1 +2 2 +3 3 +4 4 +5 5 +6 6 +7 7 +8 8 +9 9 +10 10 +11 11 +12 12 +13 13 +14 14 +15 15 +16 16 +17 17 +18 18 +19 19 +20 20 +SELECT SQL_BIG_RESULT tbl1.col1 AS field1, tbl2.col1 AS field2 +FROM t1 as tbl1, t1 as tbl2 +GROUP BY field1, field2 +ORDER BY field1, field2 +LIMIT 3; +field1 field2 +1 1 +1 2 +1 3 +DROP VIEW v1; +DROP TABLE t1; +# +# Bug#13422961: WRONG RESULTS FROM SELECT WITH AGGREGATES AND +# IMPLICIT GROUPING + MYISAM OR MEM +# +CREATE TABLE it ( +pk INT NOT NULL, +col_int_nokey INT NOT NULL, +PRIMARY KEY (pk) +) ENGINE=MyISAM; +CREATE TABLE ot ( +pk int(11) NOT NULL, +col_int_nokey int(11) NOT NULL, +PRIMARY KEY (pk) +) ENGINE=MyISAM; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO ot VALUES (10,8); + +SELECT col_int_nokey, MAX( pk ) +FROM ot +WHERE (8, 1) IN ( SELECT pk, COUNT( col_int_nokey ) FROM it ); +col_int_nokey MAX( pk ) +NULL NULL + +DROP TABLE it,ot; +# +# Bug#13430588: WRONG RESULT FROM IMPLICITLY GROUPED QUERY WITH +# CONST TABLE AND NO MATCHING ROWS +# +CREATE TABLE t1 (i INT) ENGINE=MyISAM; +INSERT INTO t1 VALUES (1); +CREATE TABLE t2 (j INT) ENGINE=MyISAM; +INSERT INTO t2 VALUES (1),(2); + +SELECT i, j, COUNT(i) FROM t1 JOIN t2 WHERE j=3; +i j COUNT(i) +NULL NULL 0 + +DROP TABLE t1,t2; +# +# BUG#13541761: WRONG RESULTS ON CORRELATED SUBQUERY + +# AGGREGATE FUNCTION + MYISAM OR MEMORY +# +CREATE TABLE t1 ( +a varchar(1) +) ENGINE=MyISAM; +INSERT INTO t1 VALUES ('a'), ('b'); +CREATE TABLE t2 ( +a varchar(1), +b int(11) +) ENGINE=MyISAM; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES ('a',1); +ANALYZE TABLE t1,t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK + +EXPLAIN SELECT (SELECT MAX(b) FROM t2 WHERE t2.a != t1.a) as MAX +FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DEPENDENT SUBQUERY t2 NULL system NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select (/* select#2 */ select max('1') from dual where ('a' <> `test`.`t1`.`a`)) AS `MAX` from `test`.`t1` +SELECT (SELECT MAX(b) FROM t2 WHERE t2.a != t1.a) as MAX +FROM t1; +MAX +NULL +1 +DROP TABLE t1,t2; +# Bug 11923239 - ERROR WITH CORRELATED SUBQUERY IN VIEW WITH +# ONLY_FULL_GROUP_BY SQL MODE +SET @old_sql_mode = @@sql_mode; +SET sql_mode=''; +CREATE TABLE t1 ( +pk INT, +col_int_key INT, +col_int_nokey INT, +col_varchar_key VARCHAR(10), +col_varchar_nokey VARCHAR(10), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key) +); +INSERT INTO t1 VALUES (), (); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +# In GROUP BY, aliases are printed as aliases. +EXPLAIN SELECT alias1.col_int_nokey AS field1, +(SELECT alias2.col_int_key +FROM t1 AS alias2 +WHERE alias1.col_varchar_key <= alias1.col_varchar_nokey +) AS field2 +FROM t1 AS alias1 +GROUP BY field1, field2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY alias1 NULL ALL NULL NULL NULL NULL 2 100.00 Using temporary +2 DEPENDENT SUBQUERY alias2 NULL index NULL col_int_key 5 NULL 2 100.00 Using where; Using index +Warnings: +Note 1276 Field or reference 'test.alias1.col_varchar_key' of SELECT #2 was resolved in SELECT #1 +Note 1276 Field or reference 'test.alias1.col_varchar_nokey' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`alias1`.`col_int_nokey` AS `field1`,(/* select#2 */ select `test`.`alias2`.`col_int_key` from `test`.`t1` `alias2` where (`test`.`alias1`.`col_varchar_key` <= `test`.`alias1`.`col_varchar_nokey`)) AS `field2` from `test`.`t1` `alias1` group by `field1`,`field2` +# In GROUP BY, expressions are printed as expressions. +EXPLAIN SELECT alias1.col_int_nokey AS field1, +(SELECT alias2.col_int_key +FROM t1 AS alias2 +WHERE alias1.col_varchar_key <= alias1.col_varchar_nokey +) AS field2 +FROM t1 AS alias1 +GROUP BY field1, +(SELECT alias2.col_int_key +FROM t1 AS alias2 +WHERE alias1.col_varchar_key <= alias1.col_varchar_nokey +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY alias1 NULL ALL NULL NULL NULL NULL 2 100.00 Using temporary +3 DEPENDENT SUBQUERY alias2 NULL index NULL col_int_key 5 NULL 2 100.00 Using where; Using index +2 DEPENDENT SUBQUERY alias2 NULL index NULL col_int_key 5 NULL 2 100.00 Using where; Using index +Warnings: +Note 1276 Field or reference 'test.alias1.col_varchar_key' of SELECT #2 was resolved in SELECT #1 +Note 1276 Field or reference 'test.alias1.col_varchar_nokey' of SELECT #2 was resolved in SELECT #1 +Note 1276 Field or reference 'test.alias1.col_varchar_key' of SELECT #3 was resolved in SELECT #1 +Note 1276 Field or reference 'test.alias1.col_varchar_nokey' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`alias1`.`col_int_nokey` AS `field1`,(/* select#2 */ select `test`.`alias2`.`col_int_key` from `test`.`t1` `alias2` where (`test`.`alias1`.`col_varchar_key` <= `test`.`alias1`.`col_varchar_nokey`)) AS `field2` from `test`.`t1` `alias1` group by `field1`,(/* select#3 */ select `test`.`alias2`.`col_int_key` from `test`.`t1` `alias2` where (`test`.`alias1`.`col_varchar_key` <= `test`.`alias1`.`col_varchar_nokey`)) +# Aliased expression in GROUP BY in a view. +CREATE VIEW v1 AS SELECT alias1.col_int_nokey AS field1, +(SELECT alias2.col_int_key +FROM t1 AS alias2 +WHERE alias1.col_varchar_key <= alias1.col_varchar_nokey +) AS field2 +FROM t1 AS alias1 +GROUP BY field1, field2; +# In GROUP BY, aliases are printed as aliases. +SHOW CREATE VIEW v1; +View Create View character_set_client collation_connection +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `alias1`.`col_int_nokey` AS `field1`,(select `alias2`.`col_int_key` from `t1` `alias2` where (`alias1`.`col_varchar_key` <= `alias1`.`col_varchar_nokey`)) AS `field2` from `t1` `alias1` group by `field1`,`field2` utf8mb4 utf8mb4_0900_ai_ci +SET @@sql_mode='ONLY_FULL_GROUP_BY'; +SELECT alias1.col_int_nokey AS field1, +(SELECT alias2.col_int_key +FROM t1 AS alias2 +WHERE alias1.col_varchar_key <= alias1.col_varchar_nokey +) AS field2 +FROM t1 AS alias1 +GROUP BY field1, field2; +field1 field2 +NULL NULL +# The SELECT above has been accepted, and v1 was created +# using the same SELECT as above, so SELECTing from v1 +# should be accepted. +SELECT * FROM v1; +field1 field2 +NULL NULL +# Here is why in GROUP BY we print aliases of subqueries as +# aliases: below, "GROUP BY (subquery)" confuses +# ONLY_FULL_GROUP_BY, it causes an error though the subquery of +# GROUP BY and of SELECT list are the same. Fixing this would +# require implementing Item_subselect::eq(). It's not worth +# the effort because: +# a) GROUP BY (subquery) is non-SQL-standard so is likely of +# very little interest to users of ONLY_FULL_GROUP_BY +# b) as the user uses ONLY_FULL_GROUP_BY, he wants to have the +# same subquery in GROUP BY and SELECT list, so can give the +# subquery an alias in the SELECT list and use this alias in +# GROUP BY, thus avoiding the problem. +SELECT alias1.col_int_nokey AS field1, +(SELECT alias2.col_int_key +FROM t1 AS alias2 +WHERE alias1.col_varchar_key <= alias1.col_varchar_nokey +) AS field2 +FROM t1 AS alias1 +GROUP BY field1, +(SELECT alias2.col_int_key +FROM t1 AS alias2 +WHERE alias1.col_varchar_key <= alias1.col_varchar_nokey +); +ERROR 42000: Expression #2 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'test.alias1.col_varchar_key' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +DROP VIEW v1; +SET @@sql_mode = @old_sql_mode; +# Verify that if an alias is used in GROUP BY/ORDER BY it +# is printed as an alias, not as the expression. +CREATE TABLE t2(a INT); +INSERT INTO t2 VALUES(3),(4); +ANALYZE TABLE t1,t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN SELECT +pk AS foo, col_int_key AS bar, (SELECT a FROM t2 WHERE a=t1.pk) AS baz +FROM t1 +GROUP BY foo, col_int_key, baz ORDER BY pk, bar, (SELECT a FROM t2 WHERE a=t1.pk); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using temporary; Using filesort +3 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1276 Field or reference 'test.t1.pk' of SELECT #2 was resolved in SELECT #1 +Note 1276 Field or reference 'test.t1.pk' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `foo`,`test`.`t1`.`col_int_key` AS `bar`,(/* select#2 */ select `test`.`t2`.`a` from `test`.`t2` where (`test`.`t2`.`a` = `test`.`t1`.`pk`)) AS `baz` from `test`.`t1` group by `foo`,`test`.`t1`.`col_int_key`,`baz` order by `test`.`t1`.`pk`,`bar`,(/* select#3 */ select `test`.`t2`.`a` from `test`.`t2` where (`test`.`t2`.`a` = `test`.`t1`.`pk`)) +EXPLAIN SELECT +pk AS foo, col_int_key AS foo, (SELECT a FROM t2 WHERE a=t1.pk) AS foo +FROM t1 +GROUP BY pk, col_int_key, (SELECT a FROM t2 WHERE a=t1.pk) +ORDER BY pk, col_int_key, (SELECT a FROM t2 WHERE a=t1.pk); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using temporary; Using filesort +4 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +3 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1276 Field or reference 'test.t1.pk' of SELECT #2 was resolved in SELECT #1 +Note 1276 Field or reference 'test.t1.pk' of SELECT #3 was resolved in SELECT #1 +Note 1276 Field or reference 'test.t1.pk' of SELECT #4 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `foo`,`test`.`t1`.`col_int_key` AS `foo`,(/* select#2 */ select `test`.`t2`.`a` from `test`.`t2` where (`test`.`t2`.`a` = `test`.`t1`.`pk`)) AS `foo` from `test`.`t1` group by `test`.`t1`.`pk`,`test`.`t1`.`col_int_key`,(/* select#3 */ select `test`.`t2`.`a` from `test`.`t2` where (`test`.`t2`.`a` = `test`.`t1`.`pk`)) order by `test`.`t1`.`pk`,`test`.`t1`.`col_int_key`,(/* select#4 */ select `test`.`t2`.`a` from `test`.`t2` where (`test`.`t2`.`a` = `test`.`t1`.`pk`)) +DROP TABLE t1,t2; +# +# Bug#13591138 - ASSERTION NAME && !IS_AUTOGENERATED_NAME IN +# ITEM::PRINT_FOR_ORDER ON EXPLAIN EXT +# +CREATE TABLE t1 ( +pk int(11) NOT NULL AUTO_INCREMENT, +col_datetime_key datetime NOT NULL, +col_varchar_key varchar(1) NOT NULL, +PRIMARY KEY (pk), +KEY col_datetime_key (col_datetime_key), +KEY col_varchar_key (col_varchar_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t2 ( +pk int(11) NOT NULL AUTO_INCREMENT, +PRIMARY KEY (pk) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t3 ( +pk int(11) NOT NULL AUTO_INCREMENT, +col_varchar_key varchar(1) NOT NULL, +PRIMARY KEY (pk), +KEY col_varchar_key (col_varchar_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE VIEW view1 AS SELECT * FROM t1; +ANALYZE TABLE t1,t2,t3; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +EXPLAIN +SELECT +alias1.col_datetime_key AS field1 +FROM ( +view1 AS alias1, +t3 AS alias2 +) +WHERE ( +(SELECT MIN(sq1_alias1.pk) +FROM t2 AS sq1_alias1 +) +) OR (alias1.col_varchar_key = alias2.col_varchar_key +AND alias1.col_varchar_key = 'j' +) AND alias1.pk IS NULL +GROUP BY +field1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL NULL No matching min/max row +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col_datetime_key` AS `field1` from `test`.`t1` join `test`.`t3` `alias2` where false group by `field1` +DROP TABLE t1,t2,t3; +DROP VIEW view1; +CREATE TABLE t1 ( +col_int_key int(11) DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t2 ( +col_int_key int(11) DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE ALGORITHM=MERGE VIEW view1 AS +SELECT CONCAT( table1.col_varchar_nokey , table2.col_varchar_key ) AS +field1 +FROM +t2 AS table1 JOIN t1 AS table2 +ON table2.col_varchar_nokey = table1.col_varchar_key +AND +table2.col_varchar_key >= table1.col_varchar_nokey +ORDER BY field1 +; +ANALYZE TABLE t1,t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN SELECT * FROM view1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE table1 NULL ALL col_varchar_key NULL NULL NULL 1 100.00 Using temporary; Using filesort +1 SIMPLE table2 NULL ALL col_varchar_key NULL NULL NULL 1 100.00 Range checked for each record (index map: 0x2) +Warnings: +Note 1003 /* select#1 */ select concat(`test`.`table1`.`col_varchar_nokey`,`test`.`table2`.`col_varchar_key`) AS `field1` from `test`.`t2` `table1` join `test`.`t1` `table2` where ((`test`.`table2`.`col_varchar_nokey` = `test`.`table1`.`col_varchar_key`) and (`test`.`table2`.`col_varchar_key` >= `test`.`table1`.`col_varchar_nokey`)) order by concat(`test`.`table1`.`col_varchar_nokey`,`test`.`table2`.`col_varchar_key`) +DROP TABLE t1,t2; +DROP VIEW view1; +CREATE TABLE t1 (col_varchar_nokey varchar(1) DEFAULT NULL); +INSERT INTO t1 VALUES ('v'),('c'); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT (SELECT 150) AS field5 +FROM (SELECT * FROM t1) AS alias1 +GROUP BY field5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1249 Select 2 was reduced during optimization +Note 1003 /* select#1 */ select 150 AS `field5` from `test`.`t1` group by `field5` +DROP TABLE t1; +# +# BUG#12626418 "only_full_group_by wrongly allows column in order by" +# +SET @old_sql_mode = @@sql_mode; +SET @@sql_mode='ONLY_FULL_GROUP_BY'; +create table t1(a int, b int); +select a from t1 group by b; +ERROR 42000: Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'test.t1.a' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +select 1 from t1 group by b; +1 +select 1 from t1 group by b order by a; +ERROR 42000: Expression #1 of ORDER BY clause is not in GROUP BY clause and contains nonaggregated column 'test.t1.a' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +select a from t1 group by b order by b; +ERROR 42000: Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'test.t1.a' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +drop table t1; +CREATE TABLE t1 (pk int, i1 int, v1 varchar(1), primary key (pk)); +INSERT INTO t1 VALUES (0,2,'b'),(1,4,'a'),(2,0,'a'),(3,7,'b'),(4,7,'c'); +SELECT a1.v1,a2.v1 FROM t1 AS a1 JOIN t1 AS a2 ON a2.pk = a1.i1 group by +a1.v1,a2.v1 ORDER BY a1.i1,a2.pk,a2.v1 ASC; +ERROR 42000: Expression #1 of ORDER BY clause is not in GROUP BY clause and contains nonaggregated column 'test.a1.i1' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +SELECT a1.v1,a2.v1 FROM t1 AS a1 JOIN t1 AS a2 ON a2.pk = a1.i1 group by +a1.v1,a2.v1 ORDER BY a2.v1 ASC; +v1 v1 +b a +a b +a c +DROP TABLE t1; +CREATE TABLE t1 (pk int(11) NOT NULL AUTO_INCREMENT, col_int_key int(11) NOT +NULL, col_varchar_key varchar(1) NOT NULL, col_varchar_nokey varchar(1) NOT +NULL, PRIMARY KEY (pk), KEY col_int_key (col_int_key), KEY col_varchar_key +(col_varchar_key,col_int_key)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t2 (pk int(11) NOT NULL AUTO_INCREMENT, col_int_key int(11) NOT +NULL, col_varchar_key varchar(1) NOT NULL, col_varchar_nokey varchar(1) NOT +NULL, PRIMARY KEY (pk), KEY col_int_key (col_int_key), KEY col_varchar_key +(col_varchar_key,col_int_key)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +SELECT SUM(alias2.col_varchar_nokey) , alias2.pk AS field2 FROM t1 AS alias1 +STRAIGHT_JOIN t2 AS alias2 ON alias2.pk = alias1.col_int_key WHERE alias1.pk +group by field2 ORDER BY alias1.col_int_key,alias2.pk ; +SUM(alias2.col_varchar_nokey) field2 +DROP TABLE t1,t2; +CREATE TABLE t1 (pk int(11) NOT NULL AUTO_INCREMENT, col_int_key int(11) NOT +NULL, col_datetime_key datetime NOT NULL, col_varchar_key varchar(1) NOT +NULL, col_varchar_nokey varchar(1) NOT NULL, PRIMARY KEY (pk), KEY +col_int_key (col_int_key), KEY col_datetime_key (col_datetime_key), KEY +col_varchar_key (col_varchar_key,col_int_key)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t2 (pk int(11) NOT NULL AUTO_INCREMENT, col_int_key int(11) NOT +NULL, col_datetime_key datetime NOT NULL, col_varchar_key varchar(1) NOT +NULL, col_varchar_nokey varchar(1) NOT NULL, PRIMARY KEY (pk), KEY +col_int_key (col_int_key), KEY col_datetime_key (col_datetime_key), KEY +col_varchar_key (col_varchar_key,col_int_key)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +SELECT alias2.col_varchar_key AS field1 , +COUNT(DISTINCT alias1.col_varchar_nokey), alias2.pk AS field4 +FROM t1 AS alias1 +RIGHT JOIN t2 AS alias2 ON alias2.pk = alias1.col_int_key +GROUP BY field1 , field4 +ORDER BY alias1.col_datetime_key ; +ERROR 42000: Expression #1 of ORDER BY clause is not in GROUP BY clause and contains nonaggregated column 'test.alias1.col_datetime_key' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +DROP TABLE t1,t2; +create table t1 (a int, b int); +select count(*) > 3 from t1 group by a order by b; +ERROR 42000: Expression #1 of ORDER BY clause is not in GROUP BY clause and contains nonaggregated column 'test.t1.b' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +create table t2 (a int, b int); +select a from t2 group by a +order by (select a from t1 order by t2.b limit 1); +ERROR 42000: Expression #1 of ORDER BY clause is not in GROUP BY clause and contains nonaggregated column 'test.t2.b' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +SET @@sql_mode = @old_sql_mode; +DROP TABLE t1,t2; +create table t1 (branch varchar(40), id int); +select count(*) from t1 group by branch having +branch<>'mumbai' order by id desc,branch desc limit 100; +count(*) +select branch, count(*)/max(id) from t1 group by branch +having (branch<>'mumbai' OR count(*)<2) +order by id desc,branch desc limit 100; +branch count(*)/max(id) +SET @@sql_mode='ONLY_FULL_GROUP_BY'; +select count(*) from t1 group by branch having +branch<>'mumbai' order by id desc,branch desc limit 100; +ERROR 42000: Expression #1 of ORDER BY clause is not in GROUP BY clause and contains nonaggregated column 'test.t1.id' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +select branch, count(*)/max(id) from t1 group by branch +having (branch<>'mumbai' OR count(*)<2) +order by id desc,branch desc limit 100; +ERROR 42000: Expression #1 of ORDER BY clause is not in GROUP BY clause and contains nonaggregated column 'test.t1.id' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +DROP TABLE t1; +create table t1 (a int, b int); +insert into t1 values (1, 2), (1, 3), (null, null); +select sum(a), count(*) from t1 group by a; +sum(a) count(*) +2 2 +NULL 1 +select round(sum(a)), count(*) from t1 group by a; +round(sum(a)) count(*) +2 2 +NULL 1 +select ifnull(a, 'xyz') from t1 group by a; +ifnull(a, 'xyz') +1 +xyz +DROP TABLE t1; +SET @@sql_mode = @old_sql_mode; +# +# BUG#12640437: USING SQL_BUFFER_RESULT RESULTS IN A +# DIFFERENT QUERY OUTPUT +# +CREATE TABLE t1 ( +a int, +b varchar(1), +KEY (b,a) +) charset utf8mb4; +INSERT INTO t1 VALUES (1,NULL),(0,'a'),(1,NULL),(0,'a'); +INSERT INTO t1 VALUES (1,'a'),(0,'a'),(1,'a'),(0,'a'); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK + +EXPLAIN SELECT SQL_BUFFER_RESULT MIN(a), b FROM t1 WHERE t1.b = 'a' GROUP BY b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range b b 12 NULL 2 100.00 Using where; Using index for group-by; Using temporary +Warnings: +Note 1003 /* select#1 */ select sql_buffer_result min(`test`.`t1`.`a`) AS `MIN(a)`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (`test`.`t1`.`b` = 'a') group by `test`.`t1`.`b` + +SELECT SQL_BUFFER_RESULT MIN(a), b FROM t1 WHERE t1.b = 'a' GROUP BY b; +MIN(a) b +0 a + +EXPLAIN SELECT MIN(a), b FROM t1 WHERE t1.b = 'a' GROUP BY b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range b b 12 NULL 2 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select min(`test`.`t1`.`a`) AS `MIN(a)`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (`test`.`t1`.`b` = 'a') group by `test`.`t1`.`b` + +SELECT MIN(a), b FROM t1 WHERE t1.b = 'a' GROUP BY b; +MIN(a) b +0 a + +DROP TABLE t1; +# +# Bug #12888306 MISSING ROWS FOR SELECT >ALL (SUBQUERY WITHOUT ROWS) +# +CREATE TABLE t1(a INT); +INSERT INTO t1 VALUES (0); +SELECT 1 FROM t1 WHERE 1 > ALL(SELECT 1 FROM t1 WHERE a); +1 +1 +DROP TABLE t1; +# +# Bug#18035906: TEST_IF_SKIP_SORT_ORDER INCORRECTLY CHOSES NON-COVERING +# INDEX FOR ORDERING +# +CREATE TABLE t1 ( +i INT PRIMARY KEY AUTO_INCREMENT, +kp1 INT, +kp2 INT, +INDEX idx_noncov(kp1), +INDEX idx_cov(kp1,kp2) +) ENGINE=InnoDB; +INSERT INTO t1 VALUES (NULL, 1, 1); +INSERT INTO t1 SELECT NULL, kp1, kp2+1 from t1; +INSERT INTO t1 SELECT NULL, kp1, kp2+2 from t1; +INSERT INTO t1 SELECT NULL, kp1, kp2+4 from t1; +INSERT INTO t1 SELECT NULL, kp1, kp2 from t1; +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT kp1, SUM(kp2) FROM t1 GROUP BY kp1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 16 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index idx_noncov,idx_cov idx_cov 10 NULL 16 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`kp1` AS `kp1`,sum(`test`.`t1`.`kp2`) AS `SUM(kp2)` from `test`.`t1` group by `test`.`t1`.`kp1` +DROP TABLE t1; +# Bug#72512/18694751: Non-aggregated query with set function in +# ORDER BY should be rejected +CREATE TABLE t1(a INTEGER); +INSERT INTO t1 VALUES (1), (2); +# Non-aggregated queries +SELECT a FROM t1 ORDER BY COUNT(*); +ERROR HY000: Expression #1 of ORDER BY contains aggregate function and applies to the result of a non-aggregated query +SELECT a FROM t1 WHERE a > 0 ORDER BY COUNT(*); +ERROR HY000: Expression #1 of ORDER BY contains aggregate function and applies to the result of a non-aggregated query +# Implicitly grouped query +SELECT SUM(a) FROM t1 ORDER BY COUNT(*); +SUM(a) +3 +SELECT COUNT(*) FROM t1 ORDER BY COUNT(*); +COUNT(*) +2 +SELECT COUNT(*) AS c FROM t1 ORDER BY COUNT(*); +c +2 +SELECT COUNT(*) AS c FROM t1 ORDER BY c; +c +2 +# Explicitly grouped query +SELECT a, COUNT(*) FROM t1 GROUP BY a ORDER BY COUNT(*); +a COUNT(*) +1 1 +2 1 +SELECT a, COUNT(*) AS c FROM t1 GROUP BY a ORDER BY COUNT(*); +a c +1 1 +2 1 +SELECT a, COUNT(*) AS c FROM t1 GROUP BY a ORDER BY c; +a c +1 1 +2 1 +SELECT a AS c FROM t1 GROUP BY a ORDER BY COUNT(*); +c +1 +2 +# Query with HAVING, +SELECT 1 FROM t1 HAVING COUNT(*) > 1 ORDER BY COUNT(*); +1 +1 +# Subquery, ORDER BY contains outer reference +SELECT (SELECT 1 AS foo ORDER BY a) AS x +FROM t1; +x +1 +1 +SELECT (SELECT 1 AS foo ORDER BY t1.a) AS x +FROM t1; +x +1 +1 +# Subquery, ORDER BY contains set function with outer reference +SELECT (SELECT 1 AS foo ORDER BY COUNT(a)) AS x +FROM t1; +x +1 +SELECT (SELECT 1 AS foo ORDER BY COUNT(t1.a)) AS x +FROM t1; +x +1 +# Subquery, ORDER BY contains set function with local reference +SELECT (SELECT 1 AS foo ORDER BY COUNT(*)) AS x +FROM t1; +ERROR HY000: Expression #1 of ORDER BY contains aggregate function and applies to the result of a non-aggregated query +# Subquery in ORDER BY with outer reference +SELECT a FROM t1 ORDER BY (SELECT COUNT(t1.a) FROM t1 AS t2); +ERROR HY000: Expression #1 of ORDER BY contains aggregate function and applies to the result of a non-aggregated query +SELECT SUM(a) FROM t1 ORDER BY (SELECT COUNT(t1.a) FROM t1 AS t2); +SUM(a) +3 +# Query with ORDER BY inside UNION +(SELECT a FROM t1 ORDER BY COUNT(*)) +UNION +SELECT a FROM t1; +ERROR HY000: Expression #1 of ORDER BY contains aggregate function and applies to the result of a non-aggregated query +(SELECT a FROM t1 ORDER BY COUNT(*)) +UNION ALL +SELECT a FROM t1; +ERROR HY000: Expression #1 of ORDER BY contains aggregate function and applies to the result of a non-aggregated query +(SELECT a FROM t1 ORDER BY COUNT(*) LIMIT 1) +UNION +SELECT a FROM t1; +ERROR HY000: Expression #1 of ORDER BY contains aggregate function and applies to the result of a non-aggregated query +(SELECT a FROM t1 ORDER BY COUNT(*) LIMIT 1) +UNION ALL +SELECT a FROM t1; +ERROR HY000: Expression #1 of ORDER BY contains aggregate function and applies to the result of a non-aggregated query +SELECT a FROM t1 +UNION +(SELECT a FROM t1 ORDER BY COUNT(*)); +ERROR HY000: Expression #1 of ORDER BY contains aggregate function and applies to the result of a non-aggregated query +SELECT a FROM t1 +UNION ALL +(SELECT a FROM t1 ORDER BY COUNT(*)); +ERROR HY000: Expression #1 of ORDER BY contains aggregate function and applies to the result of a non-aggregated query +SELECT a FROM t1 +UNION +(SELECT a FROM t1 ORDER BY COUNT(*) LIMIT 1 OFFSET 1); +ERROR HY000: Expression #1 of ORDER BY contains aggregate function and applies to the result of a non-aggregated query +SELECT a FROM t1 +UNION ALL +(SELECT a FROM t1 ORDER BY COUNT(*) LIMIT 1 OFFSET 1); +ERROR HY000: Expression #1 of ORDER BY contains aggregate function and applies to the result of a non-aggregated query +(SELECT a FROM t1 ORDER BY COUNT(*)) +UNION +(SELECT a FROM t1 ORDER BY COUNT(*)); +ERROR HY000: Expression #1 of ORDER BY contains aggregate function and applies to the result of a non-aggregated query +(SELECT a FROM t1 ORDER BY COUNT(*)) +UNION ALL +(SELECT a FROM t1 ORDER BY COUNT(*)); +ERROR HY000: Expression #1 of ORDER BY contains aggregate function and applies to the result of a non-aggregated query +(SELECT a FROM t1 ORDER BY COUNT(*) LIMIT 1) +UNION +(SELECT a FROM t1 ORDER BY COUNT(*) LIMIT 1 OFFSET 1); +ERROR HY000: Expression #1 of ORDER BY contains aggregate function and applies to the result of a non-aggregated query +(SELECT a FROM t1 ORDER BY COUNT(*) LIMIT 1) +UNION ALL +(SELECT a FROM t1 ORDER BY COUNT(*) LIMIT 1 OFFSET 1); +ERROR HY000: Expression #1 of ORDER BY contains aggregate function and applies to the result of a non-aggregated query +(SELECT COUNT(*) FROM t1 ORDER BY a) ORDER BY COUNT(*); +ERROR HY000: Expression #1 of ORDER BY contains aggregate function and applies to the result of a non-aggregated query +DROP TABLE t1; +# +# Bug#18487060: ASSERTION FAILED: !TABLE || (!TABLE->READ_SET || +# BITMAP_IS_SET(TABLE->READ_SET, +# +CREATE TABLE r(c BLOB) ENGINE=INNODB; +INSERT INTO r VALUES(''); +SELECT 1 FROM r GROUP BY MAKE_SET(1,c) WITH ROLLUP; +1 +1 +1 +DROP TABLE r; +# +# Bug #18921626 DEBUG CRASH IN PLAN_CHANGE_WATCHDOG::~PLAN_CHANGE_WATCHDOG AT SQL_OPTIMIZER.CC +# +SET @old_sql_mode = @@sql_mode; +set sql_mode=''; +CREATE TABLE AA ( +col_varchar_1024_latin1 varchar(1024) CHARACTER SET latin1, +pk integer auto_increment, +col_varchar_1024_utf8_key varchar(1024) CHARACTER SET utf8, +col_varchar_1024_latin1_key varchar(1024) CHARACTER SET latin1, +col_varchar_10_utf8_key varchar(10) CHARACTER SET utf8, +col_varchar_10_latin1_key varchar(10) CHARACTER SET latin1, +col_int int, +col_varchar_10_latin1 varchar(10) CHARACTER SET latin1, +col_varchar_10_utf8 varchar(10) CHARACTER SET utf8, +col_varchar_1024_utf8 varchar(1024) CHARACTER SET utf8, +col_int_key int, +primary key (pk), +key (col_varchar_1024_utf8_key ), +key (col_varchar_1024_latin1_key ), +key (col_varchar_10_utf8_key ), +key (col_varchar_10_latin1_key ), +key (col_int_key )) ENGINE=innodb ROW_FORMAT=DYNAMIC; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +CREATE OR REPLACE VIEW view_AA AS SELECT * FROM AA; +CREATE TABLE B ( +col_varchar_1024_latin1_key varchar(1024) CHARACTER SET latin1, +col_varchar_10_latin1 varchar(10) CHARACTER SET latin1, +col_varchar_10_utf8_key varchar(10) CHARACTER SET utf8, +col_int_key int, +col_varchar_1024_latin1 varchar(1024) CHARACTER SET latin1, +col_varchar_1024_utf8_key varchar(1024) CHARACTER SET utf8, +col_varchar_10_utf8 varchar(10) CHARACTER SET utf8, +col_int int, +pk integer auto_increment, +col_varchar_10_latin1_key varchar(10) CHARACTER SET latin1, +col_varchar_1024_utf8 varchar(1024) CHARACTER SET utf8, +key (col_varchar_1024_latin1_key ), +key (col_varchar_10_utf8_key ), +key (col_int_key ), +key (col_varchar_1024_utf8_key ), +primary key (pk), +key (col_varchar_10_latin1_key )) ENGINE=myisam; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 1071 Specified key was too long; max key length is 1000 bytes +Warning 1071 Specified key was too long; max key length is 1000 bytes +INSERT INTO B VALUES ('at', repeat('a',1000), 'the', +-1622540288, 'as', repeat('a',1000), 'want', 1810890752, NULL, 'v', 'just'); +Warnings: +Warning 1265 Data truncated for column 'col_varchar_10_latin1' at row 1 +SELECT +DISTINCT table1 . pk AS field1 +FROM view_AA AS table1 LEFT JOIN B AS table2 +ON table1 . col_varchar_10_latin1_key = table2 . +col_varchar_1024_latin1_key +WHERE ( ( table2 . pk > table1 . col_int_key AND table1 . pk NOT +BETWEEN 3 AND ( 3 + 3 ) ) AND table2 . pk <> 6 ) +GROUP BY table1 . pk; +field1 +DROP TABLE AA,B; +DROP VIEW view_AA; +SET @@sql_mode = @old_sql_mode; +SET sql_mode = default; +# +# Bug#20262196 ASSERTION FAILED: !IMPLICIT_GROUPING || TMP_TABLE_PARAM.SUM_FUNC_COUNT +# +CREATE TABLE t1(a INT, b INT) ENGINE=INNODB; +INSERT INTO t1 VALUES (1,2), (3,4); +SELECT +EXISTS +( +SELECT 1 +FROM (SELECT a FROM t1) t_inner +GROUP BY t_inner.a +ORDER BY MIN(t_outer.b) +) +FROM t1 t_outer; +EXISTS +( +SELECT 1 +FROM (SELECT a FROM t1) t_inner +GROUP BY t_inner.a +ORDER BY MIN(t_outer.b) +) +1 +DROP TABLE t1; +# +# Bug#20210742 GROUP BY ON MERGE VIEW WITH ORDER BY DOES NOT WORK WITH ONLY_FULL_GROUP_BY +# +CREATE TABLE t1(cc CHAR(1), n CHAR(1), d CHAR(1)); +CREATE OR REPLACE ALGORITHM = MERGE VIEW v1 AS +SELECT * FROM t1 WHERE cc = 'AUS' ORDER BY n; +SELECT d, COUNT(*) FROM v1 GROUP BY d; +d COUNT(*) +DROP TABLE t1; +DROP VIEW v1; +# +# Bug#20819199 ASSERTION FAILED IN TEST_IF_SKIP_SORT_ORDER +# +CREATE TABLE t0 ( a INT ); +INSERT INTO t0 VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10); +CREATE TABLE t1 ( +pk INT NOT NULL AUTO_INCREMENT, +a INT, +b INT, +PRIMARY KEY (pk), +KEY idx1 (a), +KEY idx2 (b, a), +KEY idx3 (a, b) +) ENGINE = InnoDB; +INSERT INTO t1 (a, b) SELECT t01.a, t02.a FROM t0 t01, t0 t02; +ANALYZE TABLE t0,t1; +Table Op Msg_type Msg_text +test.t0 analyze status OK +test.t1 analyze status OK +EXPLAIN SELECT DISTINCT a, MAX(b) FROM t1 WHERE a >= 0 GROUP BY a,a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 100 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index idx1,idx2,idx3 idx1 5 NULL 100 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,max(`test`.`t1`.`b`) AS `MAX(b)` from `test`.`t1` where (`test`.`t1`.`a` >= 0) group by `test`.`t1`.`a` +SELECT DISTINCT a, MAX(b) FROM t1 WHERE a >= 0 GROUP BY a,a; +a MAX(b) +1 10 +2 10 +3 10 +4 10 +5 10 +6 10 +7 10 +8 10 +9 10 +10 10 +DROP TABLE t0, t1; +# Bug#21753180: handle_fatal_signal (sig=11) in my_strtod_int +CREATE TABLE t1( +a INTEGER, +b BLOB(1), +c BLOB(1), +PRIMARY KEY(a,b(1)), +UNIQUE KEY (a,c(1)) +); +INSERT INTO t1 VALUES(1,2,1),(2,4,1); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +explain SELECT a, (SELECT SUM(a + c) FROM (SELECT b as c FROM t1) AS v1) FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL index NULL a 8 NULL 2 100.00 Using index +2 DEPENDENT SUBQUERY t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,(/* select#2 */ select sum((`test`.`t1`.`a` + `test`.`t1`.`b`)) from `test`.`t1`) AS `(SELECT SUM(a + c) FROM (SELECT b as c FROM t1) AS v1)` from `test`.`t1` +SELECT a, (SELECT SUM(a + c) FROM (SELECT b as c FROM t1) AS v1) FROM t1; +a (SELECT SUM(a + c) FROM (SELECT b as c FROM t1) AS v1) +1 8 +2 10 +DROP TABLE t1; +# +# Bug#21761044 CONDITIONAL JUMP AT TEST_IF_ORDER_BY_KEY IN SQL_OPTIMIZER.CC +# +# Used to give ASAN error on the SELECT: addressing beyond allocated memory +# +CREATE TABLE cc (pk int, i int, c varchar(1), +PRIMARY KEY (pk, i), KEY c_key(c)) ENGINE=InnoDB; +SELECT c, i, pk FROM cc WHERE (cc.pk = 1) GROUP BY c, i, pk; +c i pk +DROP TABLE cc; +# +# Bug#22132822 CRASH IN GROUP_CHECK::IS_FD_ON_SOURCE +# +CREATE TABLE t1 +( +a INT GENERATED ALWAYS AS (1) VIRTUAL, +b INT GENERATED ALWAYS AS (a) VIRTUAL, +c INT GENERATED ALWAYS AS (1) VIRTUAL +); +DROP TABLE t1; +# +# Bug #22186926 CONVERT_CONSTANT_ITEM(THD*, ITEM_FIELD*, ITEM**): ASSERTION `!RESULT' FAILED. +# +CREATE TABLE t1 +( +f1 INTEGER NOT NULL, +f2 DATETIME NOT NULL, +f3 VARCHAR(1) NOT NULL, +KEY (f3) +); +INSERT INTO t1(f1, f2, f3) VALUES +(5, '2001-07-25 08:40:24.058646', 'j'), +(2, '1900-01-01 00:00:00', 's'), +(4, '2001-01-20 12:47:23.022022', 'x'); +CREATE TABLE t2 (f1 VARCHAR(1) NOT NULL); +FLUSH TABLES; +ANALYZE TABLE t1,t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN SELECT MIN(t1.f3 ) FROM t1 +WHERE t1.f3 IN (SELECT t2.f1 FROM t2 WHERE NOT t1.f2 IS NOT NULL) AND t1.f1 IS NULL OR +NOT t1 . f3 < 'q'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL NULL Select tables optimized away +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1276 Field or reference 'test.t1.f2' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select min(`test`.`t1`.`f3`) AS `MIN(t1.f3 )` from `test`.`t1` where (`test`.`t1`.`f3` >= 'q') +DROP TABLE t1,t2; +# +# Bug#22275357 ORDER BY DOES NOT WORK CORRECTLY WITH GROUPED AVG() +# VALUES EXTRACTED FROM JSON +# +CREATE TABLE t(txt TEXT, i INT); +INSERT INTO t VALUES ('a', 2), ('b', 8), ('b', 0), ('c', 2); +SELECT txt, AVG(i) a FROM t GROUP BY txt ORDER BY a, txt; +txt a +a 2.0000 +c 2.0000 +b 4.0000 +SELECT txt, VAR_POP(i) v FROM t GROUP BY txt ORDER BY v, txt; +txt v +a 0 +c 0 +b 16 +SELECT txt, STDDEV_POP(i) s FROM t GROUP BY txt ORDER BY s, txt; +txt s +a 0 +c 0 +b 4 +SELECT SQL_BUFFER_RESULT txt, AVG(i) a FROM t GROUP BY txt ORDER BY a, txt; +txt a +a 2.0000 +c 2.0000 +b 4.0000 +SELECT SQL_BUFFER_RESULT txt, VAR_POP(i) v FROM t GROUP BY txt ORDER BY v, txt; +txt v +a 0 +c 0 +b 16 +SELECT SQL_BUFFER_RESULT txt, STDDEV_POP(i) s FROM t +GROUP BY txt ORDER BY s, txt; +txt s +a 0 +c 0 +b 4 +DROP TABLE t; +# +# Bug#26162009: INCORRECT RESULT WITH EXPRESSION IN HAVING CLAUSE +# +CREATE TABLE t1 (col_varchar VARCHAR(10), col_int_key INT); +INSERT INTO t1 VALUES('r',83); +SELECT col_varchar as field1, MAX(col_int_key) AS field3 FROM t1 +GROUP BY col_varchar HAVING (field1 >= 'i' OR field3 <= 9); +field1 field3 +r 83 +SELECT CONCAT(col_varchar) as field1, MAX(col_int_key) AS field3 +FROM t1 GROUP BY col_varchar HAVING (field1 >= 'i' OR field3 <= 9); +field1 field3 +r 83 +DROP TABLE t1; +# +# Bug#21974346: GROUPING ON AGGREGATED RESULTS NOT ALWAYS REJECTED +# +CREATE TABLE t (a INT); +INSERT INTO t VALUES (0), (1), (1), (2); +# These queries did not raise the expected error before the fix. +SELECT COUNT(*) AS c FROM t GROUP BY (SELECT 1 HAVING c); +ERROR 42S22: Reference 'c' not supported (reference to group function) +SELECT COUNT(*) + 1 AS c FROM t GROUP BY (SELECT 1 HAVING c); +ERROR 42S22: Reference 'c' not supported (reference to group function) +SELECT SUM(a) AS s FROM t GROUP BY (SELECT 1 HAVING s); +ERROR 42S22: Reference 's' not supported (reference to group function) +SELECT SUM(a) + 1 AS s FROM t GROUP BY (SELECT 1 HAVING s); +ERROR 42S22: Reference 's' not supported (reference to group function) +SELECT (SELECT COUNT(*) AS c FROM t GROUP BY (SELECT 1 HAVING c)); +ERROR 42S22: Reference 'c' not supported (reference to group function) +SELECT (SELECT COUNT(*) AS c FROM t GROUP BY (SELECT 1 HAVING c) LIMIT 1); +ERROR 42S22: Reference 'c' not supported (reference to group function) +SELECT (SELECT COUNT(*) + 1 AS c FROM t GROUP BY (SELECT 1 HAVING c)); +ERROR 42S22: Reference 'c' not supported (reference to group function) +SELECT COUNT(*) AS c1, (SELECT 1 HAVING c1) AS c2 +FROM t GROUP BY (SELECT 1 WHERE c2); +ERROR 42S22: Reference 'c2' not supported (reference to group function) +SELECT COUNT(*) + 1 AS c1, (SELECT 1 HAVING c1) + 1 AS c2 +FROM t GROUP BY (SELECT 1 WHERE c2); +ERROR 42S22: Reference 'c2' not supported (reference to group function) +# These queries were accepted before the fix, and they still are. +SELECT COUNT(*) AS c FROM t ORDER BY (SELECT 1 HAVING c); +c +4 +SELECT COUNT(*) AS c FROM t ORDER BY c; +c +4 +SELECT COUNT(*) AS c FROM t ORDER BY c+1; +c +4 +SELECT COUNT(*) AS c FROM t ORDER BY c+c; +c +4 +SELECT COUNT(*) AS c FROM t HAVING (SELECT 1 HAVING c); +c +4 +SELECT COUNT(*) AS c FROM t HAVING c; +c +4 +SELECT a, COUNT(*) AS c FROM t GROUP BY a WITH ROLLUP +HAVING (SELECT 1 HAVING c); +a c +0 1 +1 2 +2 1 +NULL 4 +SELECT a, COUNT(*) AS c FROM t GROUP BY a WITH ROLLUP HAVING c; +a c +0 1 +1 2 +2 1 +NULL 4 +SELECT (SELECT COUNT(*) AS c FROM t HAVING c <> 0); +(SELECT COUNT(*) AS c FROM t HAVING c <> 0) +4 +SELECT (SELECT COUNT(*) FROM t HAVING COUNT(*) <> 0); +(SELECT COUNT(*) FROM t HAVING COUNT(*) <> 0) +4 +SELECT (SELECT COUNT(*) AS c FROM t ORDER BY c); +(SELECT COUNT(*) AS c FROM t ORDER BY c) +4 +SELECT (SELECT COUNT(*) FROM t ORDER BY COUNT(*)); +(SELECT COUNT(*) FROM t ORDER BY COUNT(*)) +4 +SELECT 1 FROM t t1 HAVING (SELECT SUM(t1.a) s FROM t t2 +GROUP BY (SELECT 1 HAVING s > 0)) > 0; +1 +1 +SELECT (SELECT SUM(a)) FROM t; +(SELECT SUM(a)) +4 +SELECT SUM(a) AS s, (SELECT SUM(a)) FROM t; +s (SELECT SUM(a)) +4 4 +SELECT a, (SELECT SUM(a)) s FROM t GROUP BY a; +a s +0 0 +1 2 +2 2 +SELECT 1 FROM t t1 HAVING (SELECT SUM(t1.a) s FROM t t2 HAVING s > 5); +1 +SELECT (SELECT SUM(t1.a) s FROM t t2 WHERE t2.a = 0 HAVING s > 3) FROM t t1; +(SELECT SUM(t1.a) s FROM t t2 WHERE t2.a = 0 HAVING s > 3) +4 +SELECT 1 FROM t HAVING (SELECT SUM(a)) > 0; +1 +1 +SELECT (SELECT SUM(a)) FROM t; +(SELECT SUM(a)) +4 +# Bug #22588319: OUTER REFERENCE TO AGGREGATE INCORRECTLY 0 OR NULL IN SUBQUERY +SELECT SUM(a) AS s, (SELECT 1 HAVING s) FROM t; +s (SELECT 1 HAVING s) +4 1 +SELECT SUM(a) AS s, (SELECT 1 HAVING s IS NULL) FROM t; +s (SELECT 1 HAVING s IS NULL) +4 NULL +SELECT COUNT(a) AS c, (SELECT 1 HAVING c) FROM t; +c (SELECT 1 HAVING c) +4 1 +SELECT COUNT(a) AS c, (SELECT 1 HAVING c = 0) FROM t; +c (SELECT 1 HAVING c = 0) +4 NULL +# Shows that #22588319 isn't fixed for ORDER BY. +# Should have ordered ascending on -a, but comes out in random order +# because the ORDER BY clause always evaluates to NULL. Have to use +# the --sorted_result directive to produce stable test results. +SELECT a, COUNT(*) c FROM t GROUP BY a ORDER BY (SELECT -a HAVING c > 0); +a c +0 1 +1 2 +2 1 +# These queries were accepted in the default sql_mode before the fix, +# and rejected in the ANSI sql_mode. Expect no change after the fix. +SELECT * FROM t t1 WHERE (SELECT SUM(t1.a) s FROM t t2 HAVING s = 0); +a +SELECT 1 FROM t t1 GROUP BY (SELECT SUM(t1.a) s FROM t t2 ORDER BY s); +1 +1 +1 +1 +SELECT 1 FROM t t1 GROUP BY (SELECT SUM(t1.a) s FROM t t2 ORDER BY s + 1); +1 +1 +1 +1 +SELECT 1 FROM t t1 GROUP BY (SELECT SUM(t1.a) s); +1 +1 +1 +1 +SELECT 1 FROM t WHERE (SELECT SUM(a)) > 0; +1 +1 +1 +1 +SELECT 1 FROM t GROUP BY (SELECT SUM(a)); +1 +1 +1 +1 +SET sql_mode = ANSI; +SELECT * FROM t t1 WHERE (SELECT SUM(t1.a) s FROM t t2 HAVING s = 0); +ERROR HY000: Invalid use of group function +SELECT 1 FROM t t1 GROUP BY (SELECT SUM(t1.a) s FROM t t2 ORDER BY s); +ERROR HY000: Invalid use of group function +SELECT 1 FROM t t1 GROUP BY (SELECT SUM(t1.a) s FROM t t2 ORDER BY s + 1); +ERROR HY000: Invalid use of group function +SELECT 1 FROM t t1 GROUP BY (SELECT SUM(t1.a) s); +ERROR HY000: Invalid use of group function +SELECT 1 FROM t WHERE (SELECT SUM(a)) > 0; +ERROR HY000: Invalid use of group function +SELECT 1 FROM t GROUP BY (SELECT SUM(a)); +ERROR HY000: Invalid use of group function +SET sql_mode = DEFAULT; +# These queries were rejected before the fix, and they still are. +SELECT COUNT(*) AS c FROM t GROUP BY (SELECT c); +ERROR 42S22: Reference 'c' not supported (reference to group function) +SELECT COUNT(*) + 1 AS c FROM t GROUP BY (SELECT c); +ERROR 42S22: Reference 'c' not supported (reference to group function) +SELECT COUNT(*) AS c FROM t GROUP BY (SELECT 1 WHERE c); +ERROR 42S22: Reference 'c' not supported (reference to group function) +SELECT COUNT(*) + 1 AS c FROM t GROUP BY (SELECT 1 WHERE c); +ERROR 42S22: Reference 'c' not supported (reference to group function) +SELECT COUNT(*) AS c FROM t GROUP BY (SELECT c HAVING c); +ERROR 42S22: Reference 'c' not supported (reference to group function) +SELECT COUNT(*) + 1 AS c FROM t GROUP BY (SELECT c HAVING c); +ERROR 42S22: Reference 'c' not supported (reference to group function) +SELECT COUNT(*) AS c FROM t GROUP BY (SELECT c WHERE c); +ERROR 42S22: Reference 'c' not supported (reference to group function) +SELECT c FROM (SELECT COUNT(*) AS c FROM t GROUP BY (SELECT 1 ORDER BY c)) tt; +ERROR 42S22: Reference 'c' not supported (reference to group function) +SELECT COUNT(*) AS c FROM t +GROUP BY (SELECT COUNT(*) FROM t HAVING (SELECT c)); +ERROR 42S22: Reference 'c' not supported (reference to group function) +SELECT COUNT(*) AS c FROM t +GROUP BY (SELECT COUNT(*) FROM t ORDER BY (SELECT c)); +ERROR 42S22: Reference 'c' not supported (reference to group function) +SELECT (SELECT COUNT(*) AS c FROM t GROUP BY c); +ERROR 42000: Can't group on 'c' +SELECT (SELECT COUNT(*) FROM t GROUP BY COUNT(*)); +ERROR 42000: Can't group on 'COUNT(*)' +SELECT 1 FROM t t1 WHERE (SELECT SUM(t1.a) s FROM t t2 GROUP BY s); +ERROR 42000: Can't group on 's' +SELECT 1 FROM t t1 WHERE (SELECT SUM(t1.a) s FROM t t2 GROUP BY s+1); +ERROR 42000: Can't group on '???' +SELECT 1 FROM t t1 ORDER BY (SELECT SUM(t1.a) s FROM t t2 GROUP BY s) > 0; +ERROR 42000: Can't group on 's' +SELECT 1 FROM t t1 ORDER BY (SELECT SUM(t1.a) s FROM t t2 GROUP BY s+1) > 0; +ERROR 42000: Can't group on '???' +SELECT 1 FROM t t1 ORDER BY (SELECT SUM(t1.a) s FROM t t2 +GROUP BY (SELECT s)) > 0; +ERROR 42S22: Reference 's' not supported (reference to group function) +SELECT 1 FROM t t1 ORDER BY (SELECT SUM(t1.a) s FROM t t2 +GROUP BY (SELECT s+1)) > 0; +ERROR 42S22: Reference 's' not supported (reference to group function) +SELECT 1 FROM t ORDER BY (SELECT SUM(a)); +ERROR HY000: Expression #1 of ORDER BY contains aggregate function and applies to the result of a non-aggregated query +SELECT 1 FROM t t1 HAVING (SELECT SUM(t1.a) s FROM t t2 WHERE s > 5); +ERROR 42S22: Unknown column 's' in 'where clause' +SELECT a, (SELECT SUM(a)) s FROM t GROUP BY a, s; +ERROR 42000: Can't group on 's' +SELECT EXISTS (SELECT SUM(t1.a) s FROM t t2 GROUP BY s) FROM t t1; +ERROR 42000: Can't group on 's' +SELECT SUM(a) s, s FROM t; +ERROR 42S22: Unknown column 's' in 'field list' +SELECT 1 FROM t t1 HAVING (SELECT SUM(t1.a) s FROM t t2 GROUP BY s) > 0; +ERROR 42000: Can't group on 's' +SELECT 1 FROM t t1 HAVING (SELECT SUM(t1.a) s FROM t t2 GROUP BY s+1) > 0; +ERROR 42000: Can't group on '???' +SELECT 1 FROM t t1 HAVING (SELECT SUM(t1.a) s FROM t t2 +HAVING (SELECT 1 GROUP BY s+1)) > 0; +ERROR 42S22: Reference 's' not supported (reference to group function) +SELECT COUNT(*) AS c FROM t ORDER BY (SELECT c); +ERROR 42S22: Reference 'c' not supported (reference to group function) +SELECT COUNT(*) AS c FROM t ORDER BY (SELECT 1 ORDER BY c); +ERROR 42S22: Reference 'c' not supported (reference to group function) +SELECT COUNT(*) AS c FROM t ORDER BY (SELECT c ORDER BY c); +ERROR 42S22: Reference 'c' not supported (reference to group function) +SELECT COUNT(*) AS c FROM t HAVING (SELECT c); +ERROR 42S22: Reference 'c' not supported (reference to group function) +SELECT COUNT(*) AS c FROM t HAVING (SELECT 1 ORDER BY c); +ERROR 42S22: Reference 'c' not supported (reference to group function) +SELECT COUNT(*) AS c FROM t HAVING (SELECT c ORDER BY c); +ERROR 42S22: Reference 'c' not supported (reference to group function) +SELECT a, COUNT(*) AS c FROM t GROUP BY a WITH ROLLUP +HAVING (SELECT c); +ERROR 42S22: Reference 'c' not supported (reference to group function) +SELECT a, COUNT(*) AS c FROM t GROUP BY a WITH ROLLUP +HAVING (SELECT 1 ORDER BY c); +ERROR 42S22: Reference 'c' not supported (reference to group function) +SELECT a, COUNT(*) AS c FROM t GROUP BY a WITH ROLLUP +HAVING (SELECT c ORDER BY c); +ERROR 42S22: Reference 'c' not supported (reference to group function) +SELECT COUNT(*) AS c FROM t ORDER BY (SELECT COUNT(*) FROM t HAVING (SELECT c)); +ERROR 42S22: Reference 'c' not supported (reference to group function) +SELECT c FROM (SELECT COUNT(*) AS c FROM t ORDER BY (SELECT 1 ORDER BY c)) tt; +ERROR 42S22: Reference 'c' not supported (reference to group function) +SELECT COUNT(*) AS c FROM t +ORDER BY (SELECT COUNT(*) FROM t GROUP BY (SELECT c)); +ERROR 42S22: Reference 'c' not supported (reference to group function) +SELECT COUNT(*) AS c FROM t +HAVING (SELECT COUNT(*) FROM t GROUP BY (SELECT c)); +ERROR 42S22: Reference 'c' not supported (reference to group function) +SELECT SUM(a) AS s, (SELECT s) FROM t; +ERROR 42S22: Reference 's' not supported (reference to group function) +SELECT EXISTS (SELECT SUM(t1.a) s FROM t t2 GROUP BY (SELECT s)) FROM t t1; +ERROR 42S22: Reference 's' not supported (reference to group function) +SELECT (SELECT SUM(t1.a) s FROM t t2 HAVING (SELECT s > 5)) FROM t t1; +ERROR 42S22: Reference 's' not supported (reference to group function) +SELECT 1 FROM t t1 HAVING (SELECT SUM(t1.a) s FROM t t2 HAVING (SELECT s) < 0); +ERROR 42S22: Reference 's' not supported (reference to group function) +SELECT 1 FROM t t1 HAVING (SELECT SUM(t1.a) s FROM t t2 GROUP BY (SELECT s)); +ERROR 42S22: Reference 's' not supported (reference to group function) +SELECT 1 FROM t t1 HAVING (SELECT SUM(t1.a) s FROM t t2 HAVING (SELECT -s) > 0); +ERROR 42S22: Reference 's' not supported (reference to group function) +SELECT 1 FROM t t1 HAVING (SELECT SUM(t1.a) s FROM t t2 GROUP BY (SELECT -s)); +ERROR 42S22: Reference 's' not supported (reference to group function) +DROP TABLE t; +# +# Bug#25407964 GROUP BY DESC GIVES WRONG RESULT WHEN GROUPS ON DECIMAL AND SEES A NULL +# +CREATE TABLE t(d DATE, i INT); +INSERT INTO t VALUES(NULL,1),('2017-01-14',3); +SELECT WEEK(d)/10, GROUP_CONCAT(i) FROM t GROUP BY WEEK(d)/10; +WEEK(d)/10 GROUP_CONCAT(i) +NULL 1 +0.2000 3 +SELECT WEEK(d)/10, GROUP_CONCAT(i) FROM t GROUP BY WEEK(d)/10 ORDER BY WEEK(d)/10 DESC; +WEEK(d)/10 GROUP_CONCAT(i) +0.2000 3 +NULL 1 +DROP TABLE t; +# +# Bug#21974696 WRONG RESULT WHEN GROUPING ON VALUE FROM SUBQUERY +# AND USING COUNT DISTINCT +# +CREATE TABLE t(a TEXT, b INT); +INSERT INTO t VALUES ('1', 10), ('1', 11), ('2', 20), ('2', 20), ('3', 30); +EXPLAIN FORMAT=tree SELECT (SELECT a) AS col1, COUNT(DISTINCT b) FROM t GROUP BY -col1; +EXPLAIN +-> Group aggregate: count(distinct t.b) + -> Sort: `-(a)` + -> Stream results (cost=*** rows=***) + -> Table scan on t (cost=*** rows=***) + +Warnings: +Note 1276 Field or reference 'test.t.a' of SELECT #2 was resolved in SELECT #1 +Note 1249 Select 2 was reduced during optimization +SELECT (SELECT a) AS col1, COUNT(DISTINCT b) FROM t GROUP BY -col1; +col1 COUNT(DISTINCT b) +1 2 +2 1 +3 1 +SELECT (SELECT a) AS col1, COUNT(b) FROM t GROUP BY -col1; +col1 COUNT(b) +1 2 +2 2 +3 1 +SELECT SQL_BIG_RESULT (SELECT a) AS col1, COUNT(b) FROM t GROUP BY -col1; +col1 COUNT(b) +1 2 +2 2 +3 1 +SELECT (SELECT a) AS col1, COUNT(b) FROM t GROUP BY -col1 WITH ROLLUP; +col1 COUNT(b) +1 2 +1 5 +2 2 +3 1 +DROP TABLE t; +CREATE TABLE t(a JSON, b INT); +INSERT INTO t VALUES ('1', 10), ('1', 11), ('2', 20), ('2', 20), ('3', 30); +EXPLAIN FORMAT=tree SELECT (SELECT a) AS col1, COUNT(DISTINCT b) FROM t GROUP BY -col1; +EXPLAIN +-> Group aggregate: count(distinct t.b) + -> Sort: `-(a)` + -> Stream results (cost=*** rows=***) + -> Table scan on t (cost=*** rows=***) + +Warnings: +Note 1276 Field or reference 'test.t.a' of SELECT #2 was resolved in SELECT #1 +Note 1249 Select 2 was reduced during optimization +SELECT (SELECT a) AS col1, COUNT(DISTINCT b) FROM t GROUP BY -col1; +col1 COUNT(DISTINCT b) +1 2 +2 1 +3 1 +SELECT (SELECT a) AS col1, COUNT(b) FROM t GROUP BY -col1; +col1 COUNT(b) +1 2 +2 2 +3 1 +SELECT SQL_BIG_RESULT (SELECT a) AS col1, COUNT(b) FROM t GROUP BY -col1; +col1 COUNT(b) +1 2 +2 2 +3 1 +SELECT (SELECT a) AS col1, COUNT(b) FROM t GROUP BY -col1 WITH ROLLUP; +col1 COUNT(b) +1 2 +1 5 +2 2 +3 1 +DROP TABLE t; +# +# WL#8963: REMOVAL OF NON STANDARD GROUP BY ASC/DESC +# +CREATE TABLE t1 (i INTEGER NOT NULL, j INTEGER NOT NULL, key(i,j)); +INSERT INTO t1 VALUES (1,2),(1,4),(1,3),(2,5),(5,3),(2,6),(6,2); +SELECT i, SUM(j) FROM t1 GROUP BY i ASC; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'ASC' at line 1 +SELECT i, SUM(j) FROM t1 GROUP BY i DESC; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DESC' at line 1 +EXPLAIN SELECT i, SUM(j) FROM t1 GROUP BY i; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # # Parallel execute (1 workers) +2 SIMPLE t1 NULL index i i 8 NULL # # Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i`,sum(`test`.`t1`.`j`) AS `SUM(j)` from `test`.`t1` group by `test`.`t1`.`i` +SELECT i, SUM(j) FROM t1 GROUP BY i; +i SUM(j) +1 9 +2 11 +5 3 +6 2 +EXPLAIN SELECT i, SUM(j) FROM t1 GROUP BY i ORDER BY i; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # # Parallel execute (1 workers) +2 SIMPLE t1 NULL index i i 8 NULL # # Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i`,sum(`test`.`t1`.`j`) AS `SUM(j)` from `test`.`t1` group by `test`.`t1`.`i` order by `test`.`t1`.`i` +SELECT i, SUM(j) FROM t1 GROUP BY i ORDER BY i; +i SUM(j) +1 9 +2 11 +5 3 +6 2 +EXPLAIN SELECT i, SUM(j) FROM t1 GROUP BY i ORDER BY SUM(j); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # # Parallel execute (1 workers) +2 SIMPLE t1 NULL index i i 8 NULL # # Using index; Using temporary; Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i`,sum(`test`.`t1`.`j`) AS `SUM(j)` from `test`.`t1` group by `test`.`t1`.`i` order by sum(`SUM(j)`) +SELECT i, SUM(j) FROM t1 GROUP BY i ORDER BY SUM(j); +i SUM(j) +6 2 +5 3 +1 9 +2 11 +ALTER TABLE t1 ADD UNIQUE INDEX (i,j); +EXPLAIN SELECT i FROM t1 GROUP BY j,i ORDER BY i,j; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index i_2,i i_2 8 NULL 7 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` group by `test`.`t1`.`j`,`test`.`t1`.`i` order by `test`.`t1`.`i`,`test`.`t1`.`j` +SELECT i, SUM(j) FROM t1 GROUP BY j,i ORDER BY i,j; +i SUM(j) +1 2 +1 3 +1 4 +2 5 +2 6 +5 3 +6 2 +DROP TABLE t1; +# End of tests for WL#8693 +# +# Bug #29214970: WRONG RESULTS FOR GROUP EXPRESSIONS WITH THE ITERATOR EXECUTOR +# +CREATE TABLE t1 ( +f1 INTEGER, +f2 INTEGER, +KEY k1 ( f1 ) +); +INSERT INTO t1 VALUES ( 1, 1 ); +INSERT INTO t1 VALUES ( 1, 2 ); +INSERT INTO t1 VALUES ( 1, 3 ); +INSERT INTO t1 VALUES ( 2, 1 ); +INSERT INTO t1 VALUES ( 2, 2 ); +INSERT INTO t1 VALUES ( 3, 5 ); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN FORMAT=tree SELECT f1, f1 + 1, COUNT(DISTINCT f2) AS x FROM t1 GROUP BY f1 ORDER BY x; +EXPLAIN +-> Sort: x + -> Stream results + -> Group aggregate: count(distinct t1.f2) + -> Index scan on t1 using k1 (cost=0.85 rows=6) + +SELECT f1, f1 + 1, COUNT(DISTINCT f2) AS x FROM t1 GROUP BY f1 ORDER BY x; +f1 f1 + 1 x +3 4 1 +2 3 2 +1 2 3 +DROP TABLE t1; +# Bug#29240516: Count on nullable expression may return wrong result +CREATE TABLE t1 ( +vc varchar(255) DEFAULT NULL, +b tinyint DEFAULT NULL +); +INSERT INTO t1 (vc, b) VALUES (1, true), (2, false), (3, true), (4, false); +INSERT INTO t1 (vc) VALUES (5), (6), (7), (8), (9), (10); +SELECT COUNT(b), COUNT(*) +FROM t1; +COUNT(b) COUNT(*) +4 10 +SELECT COUNT(b) +FROM t1 +HAVING COUNT(1) > 0; +COUNT(b) +4 +DROP TABLE t1; +# Bug#28857990: Different result for COUNT with EXISTS subquery +CREATE TABLE d (pk INT PRIMARY KEY); +INSERT INTO d VALUES (1),(2),(3),(4),(5); +CREATE TABLE c (col_varchar VARCHAR(1)); +INSERT INTO c VALUES ('a'),('b'),('c'),('d'),('e'); +SELECT COUNT(pk) FROM d WHERE EXISTS (SELECT col_varchar FROM c); +COUNT(pk) +5 +DROP TABLE c, d; +# +# Bug #29396628: SIG 6 AT LIST::END | SQL_LIST.H +# +CREATE TABLE t1 ( +f1 integer, +f2 integer, +f3 integer +); +SELECT * FROM t1 GROUP BY f3,f2,f1 WITH ROLLUP; +f1 f2 f3 +DROP TABLE t1; +# Bug#23599127 Unexpected unknown column error without ONLY_FULL_GROUP_BY +SET SQL_MODE = ''; +CREATE TABLE t1 ( +id_aams int NOT NULL , +PRIMARY KEY (id_aams) +); +CREATE TABLE t2 ( +id int NOT NULL, +id_game int DEFAULT NULL, +code_id char(11) DEFAULT NULL, +PRIMARY KEY (id), +UNIQUE KEY codeid (code_id,id_game) +); +select count(distinct x.id_aams) +from (select * +from (select t1.id_aams, t2.* +from t1 left join t2 +on t2.code_id='G0000000012' and +t1.id_aams=t2.id_game +where t1.id_aams=1715000360 +order by t2.id desc +) as g +group by g.id_aams +having g.id is null +) as x; +count(distinct x.id_aams) +0 +CREATE FUNCTION f1(vlt_code_id CHAR(11)) RETURNS tinyint DETERMINISTIC +BEGIN +DECLARE not_installed TINYINT DEFAULT 0; +select count(distinct x.id_aams) +into not_installed +from (select * +from (select t1.id_aams, t2.* +from t1 left join t2 +on t2.code_id = vlt_code_id and +t1.id_aams = t2.id_game +where t1.id_aams = 1715000360 +order by t2.id desc +) as g +group by g.id_aams +having g.id is null +) as x; +RETURN TRUE; +END // +SELECT f1('G0000000012'); +f1('G0000000012') +1 +SELECT f1('G0000000012'); +f1('G0000000012') +1 +PREPARE stmt from " +select count(distinct x.id_aams) +from (select g.id_aams, g.id + from (select t1.id_aams, t2.* + from t1 left join t2 + on t2.code_id='G0000000012' and + t1.id_aams=t2.id_game + where t1.id_aams=1715000360 + order by t2.id desc + ) as g + group by g.id_aams + having g.id is null + ) as x"; +EXECUTE stmt; +count(distinct x.id_aams) +0 +EXECUTE stmt; +count(distinct x.id_aams) +0 +DEALLOCATE PREPARE stmt; +DROP FUNCTION f1; +DROP TABLE t1, t2; +SET SQL_MODE = DEFAULT; +# Bug#31562881: Crash in change_to_use_tmp_fields_except_sums +CREATE TABLE w(a INTEGER); +INSERT INTO w VALUES (1),(2),(3),(4); +SELECT MAX(FROM_UNIXTIME(1536999161)), +GROUP_CONCAT(ST_LATFROMGEOHASH(ST_GEOHASH(POINT(115,155),201))) +FROM w RIGHT JOIN w AS e ON TRUE +GROUP BY w.a +LIMIT 39; +ERROR 22003: latitude value is out of range in 'st_geohash' +DROP TABLE w; +# +# Bug #32179240: ADDING ROLLUP BREAKS GROUP LABELS +# +CREATE TABLE t1 (a DOUBLE); +INSERT INTO t1 ( a ) VALUES ( 0.1 ); +SELECT TRUNCATE(a, 1) FROM t1 GROUP BY TRUNCATE(a, 1) WITH ROLLUP; +TRUNCATE(a, 1) +0.1 +NULL +DROP TABLE t1; +# +# Bug#32193123: DIFFERENT RESULTSET WITH HYPERGRAPH_OPTIMIZER SWITCH ENABLED +# +CREATE TABLE t1 (a INTEGER, b VARCHAR(1)); +INSERT INTO t1 VALUES (1, 'x'); +SELECT SUM(t1.a) AS field1, CONCAT(d1.b) AS field2 +FROM (SELECT * FROM t1) AS d1, t1 +GROUP BY field2 HAVING field2 > '' AND field1 < 4; +field1 field2 +1 x +DROP TABLE t1; +# +# Bug #32234709: TEMPTABLEAGGREGATEITERATOR::INIT(): ASSERTION `!THD()->IS_ERROR()' FAILED. +# +CREATE TABLE t1 ( +a INTEGER, +e INTEGER +); +INSERT INTO t1 VALUES (1,0); +INSERT INTO t1 VALUES (1,8388607); +SELECT COUNT(*) FROM +t1 +LEFT JOIN json_table( +'{}','$[0][1]' + COLUMNS(a FOR ORDINALITY) +) AS t2 ON TRUE +GROUP BY e*from_unixtime(0); +ERROR 22003: BIGINT value is out of range in '(`test`.`t1`.`e` * from_unixtime(0))' +DROP TABLE t1; +# +# Bug #32244407: ASSERTION FAILURE IN `!THD()->IS_ERROR()' AT AGGREGATEITERATOR::READ() +# +CREATE TABLE t1 ( +a INTEGER, +b VARCHAR(1) +); +CREATE INDEX i1 ON t1 (b); +INSERT INTO t1 VALUES (1,'0'); +INSERT INTO t1 VALUES (1,'y'); +INSERT INTO t1 VALUES (1,'Q'); +INSERT INTO t1 VALUES (1,'H'); +INSERT INTO t1 VALUES (1,'j'); +INSERT INTO t1 VALUES (1,'a'); +INSERT INTO t1 VALUES (1,'b'); +INSERT INTO t1 VALUES (1,'j'); +INSERT INTO t1 VALUES (1,'q'); +INSERT INTO t1 VALUES (1,'e'); +SELECT AVG(a2.a) +FROM t1 AS a1 +LEFT JOIN t1 AS a2 ON a2.b = ( SELECT a1.b FROM t1 ); +ERROR 21000: Subquery returns more than 1 row +DROP TABLE t1; +# +# Bug #32335256: COUNT(*) RETURNS NULL IN NESTED QUERY +# +CREATE TABLE t1 ( +f1 INTEGER +); +SELECT +( +SELECT COUNT(*) + +( +SELECT COUNT(*) +FROM t1 +WHERE f1 = c.f2 +) +FROM t1 +) +FROM (SELECT 555 AS f2) AS c; +( +SELECT COUNT(*) + +( +SELECT COUNT(*) +FROM t1 +WHERE f1 = c.f2 +) +FROM t1 +) +0 +DROP TABLE t1; +# Bug#32717969: Wrong result of execute prepare on 'smallint' +CREATE TABLE t1( +c1 smallint NOT NULL +); +INSERT INTO t1 VALUES(32767),(14742),(14743); +SELECT COUNT(*), SUM(c1), AVG(c1), MIN(c1), MAX(c1) FROM t1 WHERE c1 > 32767; +COUNT(*) SUM(c1) AVG(c1) MIN(c1) MAX(c1) +0 NULL NULL NULL NULL +PREPARE stmt from +'SELECT COUNT(*), SUM(c1), AVG(c1), MIN(c1), MAX(c1) FROM t1 WHERE c1 > ?'; +SET @a=14742; +EXECUTE stmt USING @a; +COUNT(*) SUM(c1) AVG(c1) MIN(c1) MAX(c1) +2 47510 23755.0000 14743 32767 +set @a=32767; +EXECUTE stmt USING @a; +COUNT(*) SUM(c1) AVG(c1) MIN(c1) MAX(c1) +0 NULL NULL NULL NULL +SELECT BIT_AND(c1), BIT_OR(c1), BIT_XOR(c1) FROM t1 WHERE c1 > 32767; +BIT_AND(c1) BIT_OR(c1) BIT_XOR(c1) +18446744073709551615 0 0 +PREPARE stmt from +'SELECT BIT_AND(c1), BIT_OR(c1), BIT_XOR(c1) FROM t1 WHERE c1 > ?'; +SET @a=14742; +EXECUTE stmt USING @a; +BIT_AND(c1) BIT_OR(c1) BIT_XOR(c1) +14743 32767 18024 +set @a=32767; +EXECUTE stmt USING @a; +BIT_AND(c1) BIT_OR(c1) BIT_XOR(c1) +18446744073709551615 0 0 +SELECT GROUP_CONCAT(c1), JSON_ARRAYAGG(c1), JSON_OBJECTAGG('key', c1) +FROM t1 +WHERE c1 > 32767; +GROUP_CONCAT(c1) JSON_ARRAYAGG(c1) JSON_OBJECTAGG('key', c1) +NULL NULL NULL +PREPARE stmt from +"SELECT GROUP_CONCAT(c1), JSON_ARRAYAGG(c1), JSON_OBJECTAGG('key', c1) + FROM t1 + WHERE c1 > ?"; +SET @a=14742; +EXECUTE stmt USING @a; +GROUP_CONCAT(c1) JSON_ARRAYAGG(c1) JSON_OBJECTAGG('key', c1) +32767,14743 [32767, 14743] {"key": 14743} +set @a=32767; +EXECUTE stmt USING @a; +GROUP_CONCAT(c1) JSON_ARRAYAGG(c1) JSON_OBJECTAGG('key', c1) +NULL NULL NULL +SELECT STDDEV_POP(c1), STDDEV_SAMP(c1), VAR_POP(c1), VAR_SAMP(c1) +FROM t1 +WHERE c1 > 32767; +STDDEV_POP(c1) STDDEV_SAMP(c1) VAR_POP(c1) VAR_SAMP(c1) +NULL NULL NULL NULL +PREPARE stmt from +'SELECT STDDEV_POP(c1), STDDEV_SAMP(c1), VAR_POP(c1), VAR_SAMP(c1) + FROM t1 + WHERE c1 > ?'; +SET @a=14742; +EXECUTE stmt USING @a; +STDDEV_POP(c1) STDDEV_SAMP(c1) VAR_POP(c1) VAR_SAMP(c1) +9012 12744.892624106333 81216144 162432288 +set @a=32767; +EXECUTE stmt USING @a; +STDDEV_POP(c1) STDDEV_SAMP(c1) VAR_POP(c1) VAR_SAMP(c1) +NULL NULL NULL NULL +DROP TABLE t1; diff --git a/mysql-test/r/group_by_fd_no_prot.result-pq b/mysql-test/r/group_by_fd_no_prot.result-pq new file mode 100644 index 000000000000..fd7fedea6897 --- /dev/null +++ b/mysql-test/r/group_by_fd_no_prot.result-pq @@ -0,0 +1,2295 @@ +set optimizer_trace_max_mem_size=1048576; +set end_markers_in_json=on; +set optimizer_trace="enabled=on"; +SET @old_sql_mode = @@sql_mode; +SET @@sql_mode='ONLY_FULL_GROUP_BY'; +# +# Bug#16021396 ONLY_FULL_GROUP_BY REJECTS VALID QUERY USING VIEW +# +create table t1(a int, b int, c int) engine=InnoDB; +create algorithm=merge view v1 as select t1.a*2 as a, t1.b*2 as b, t1.c*2 as c from t1; +show create view v1; +View Create View character_set_client collation_connection +v1 CREATE ALGORITHM=MERGE DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select (`t1`.`a` * 2) AS `a`,(`t1`.`b` * 2) AS `b`,(`t1`.`c` * 2) AS `c` from `t1` utf8mb4 utf8mb4_0900_ai_ci +select sin(b) as z from t1 group by sin(b); +z +select sin(b) as z from v1 group by sin(b); +z +select sin(b) as z from t1 group by b; +z +select sin(b) as z from v1 group by b; +z +select sin(b) as z from v1 group by z; +z +drop view v1; +create algorithm=temptable view v1 as select t1.a*2 as a, t1.b*2 as b, t1.c*2 as c from t1; +show create view v1; +View Create View character_set_client collation_connection +v1 CREATE ALGORITHM=TEMPTABLE DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select (`t1`.`a` * 2) AS `a`,(`t1`.`b` * 2) AS `b`,(`t1`.`c` * 2) AS `c` from `t1` utf8mb4 utf8mb4_0900_ai_ci +select sin(b) as z from t1 group by sin(b); +z +select sin(b) as z from v1 group by sin(b); +z +select sin(b) as z from t1 group by b; +z +select sin(b) as z from v1 group by b; +z +select sin(b) as z from v1 group by z; +z +drop view v1; +drop table t1; +# From testcase of Bug#16903135: +CREATE TABLE group_by_test2 ( +id int unsigned primary key, +cat int unsigned not null, +name varchar(10), +num int unsigned +); +INSERT INTO group_by_test2 (id,cat,name,num) VALUES +(1,10,'foo',2), +(2,11,'foo',1), +(3,22,'bar',3), +(4,23,'bar',7), +(5,34,'test',7); +SELECT +cat, +name, +SUM(num) +FROM +group_by_test2 +GROUP BY +cat; +ERROR 42000: Expression #2 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'test.group_by_test2.name' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +ALTER TABLE group_by_test2 ADD UNIQUE INDEX (cat); +SELECT +cat, +name, +SUM(num) +FROM +group_by_test2 +GROUP BY +cat; +cat name SUM(num) +10 foo 2 +11 foo 1 +22 bar 3 +23 bar 7 +34 test 7 +SELECT +cat, +name, +SUM(num) +FROM +group_by_test2 +GROUP BY +cat WITH ROLLUP; +ERROR 42000: Expression #2 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'test.group_by_test2.name' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +# Expressions of group columns are ok: +SELECT +cat, +length(cat), +SUM(num) +FROM +group_by_test2 +GROUP BY +cat +WITH ROLLUP; +cat length(cat) SUM(num) +10 2 2 +11 2 1 +22 2 3 +23 2 7 +34 2 7 +NULL NULL 20 +DROP TABLE group_by_test2; +# Test from Bug #18993257 SELECT AGGR + NON-AGGR FROM JOIN WITH VIEW IS NOT REJECTED BY ONLY_FULL_GROUP_BY +CREATE TABLE t1 ( +col_int_key INT, +col_varchar_key VARCHAR(1) +); +CREATE TABLE t2 ( +pk INTEGER, +col_int_key INTEGER +); +CREATE VIEW view_b AS SELECT * FROM t2; +SELECT MIN( alias2.col_int_key ), +alias2.col_int_key +FROM t1 AS alias1, t2 AS alias2 +WHERE alias1.col_int_key IS NULL; +ERROR 42000: In aggregated query without GROUP BY, expression #2 of SELECT list contains nonaggregated column 'test.alias2.col_int_key'; this is incompatible with sql_mode=only_full_group_by +# Same with view: +SELECT MIN( alias2.col_int_key ), +alias2.col_int_key +FROM t1 AS alias1, view_b AS alias2 +WHERE alias1.col_int_key IS NULL; +ERROR 42000: In aggregated query without GROUP BY, expression #2 of SELECT list contains nonaggregated column 'test.alias2.col_int_key'; this is incompatible with sql_mode=only_full_group_by +DROP TABLE t1, t2; +DROP VIEW view_b; +# +# WL#2489; Recognizing some functional dependencies +# +create table t1( +a int, +b int not null, +c int not null, +d int, +unique key(b,c), +unique key(b,d) +); +select sin(a) as z from t1 group by b; +ERROR 42000: Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'test.t1.a' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +select sin(a) as z from t1 group by d,b; +ERROR 42000: Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'test.t1.a' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +# {b,c} UNIQUE NOT NULL => {c,b}->a +select sin(a) as z from t1 group by c,b; +z +select sin(a+b*c) as z from t1 group by c,b; +z +# In PS mode, we see nothing below, because only_full_group_by +# checks are done at PREPARE, whereas trace below is from EXECUTE. +SELECT show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +"functional_dependencies_of_GROUP_columns": { + "all_columns_of_table_map_bits": [ + 0 + ] /* all_columns_of_table_map_bits */, + "columns": [ + "test.t1.c", + "test.t1.b" + ] /* columns */ + } +# With outer references: +select (select sin(a)) as z from t1 group by d,b; +ERROR 42000: Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'test.t1.a' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +select (select sin(a)) as z from t1 group by c,b; +z +# If key columns are in function, functional dependency disappears +select sin(a) as z from t1 group by c*2,b*2; +ERROR 42000: Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'test.t1.a' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +# FDs are recognized, like in SQL standard: +# b=2 => c->{b,c} => c->a as (b,c) is unique not null. +select sin(a) as z from t1 where b=2 group by c; +z +SELECT show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +"functional_dependencies_of_GROUP_columns": { + "all_columns_of_table_map_bits": [ + 0 + ] /* all_columns_of_table_map_bits */, + "columns": [ + "test.t1.c", + "test.t1.b" + ] /* columns */ + } +# t2.a=t1.a => {t1.b,t1.c}->t2.a +select sin(t2.a) as z from t1, t1 as t2 +where t2.a=t1.a group by t1.b,t1.c; +z +SELECT show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +"functional_dependencies_of_GROUP_columns": { + "all_columns_of_table_map_bits": [ + 0 + ] /* all_columns_of_table_map_bits */, + "columns": [ + "test.t1.b", + "test.t1.c", + "test.t2.a" + ] /* columns */ + } +# t2.b=t1.b and t2.c=t1.c => {t1.b,t1.c}->{all cols of t2} +select sin(t2.a) as z from t1, t1 as t2 +where t2.b=t1.b and t2.c=t1.c group by t1.b,t1.c; +z +SELECT show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +"functional_dependencies_of_GROUP_columns": { + "all_columns_of_table_map_bits": [ + 0, + 1 + ] /* all_columns_of_table_map_bits */, + "columns": [ + "test.t1.b", + "test.t1.c", + "test.t2.b", + "test.t2.c" + ] /* columns */ + } +# t2.b=t1.b and t2.c=t1.c => {t1.b,t1.c}->{all cols of t2} +# Moreover, {t1.b,t1.c}->{t1.d}. +# So t3.b=t2.b and t3.c=t1.d => {t1.b,t1.c}->{all cols of t3}. +select t3.a from t1, t1 as t2, t1 as t3 +where +t3.b=t2.b and t3.c=t1.d and +t2.b=t1.b and t2.c=t1.c +group by t1.b,t1.c; +a +SELECT show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +"functional_dependencies_of_GROUP_columns": { + "all_columns_of_table_map_bits": [ + 0, + 1, + 2 + ] /* all_columns_of_table_map_bits */, + "columns": [ + "test.t1.b", + "test.t1.c", + "test.t3.c", + "test.t2.b", + "test.t2.c", + "test.t3.b" + ] /* columns */ + } +# 3 tables: +# {t1.b,t1.c}->{t1.*}->{t2.b,t2.c}->{t2.*}->{t3.pk}->{t3.b} +create table t3(pk int primary key, b int); +select t3.b from t1,t1 as t2,t3 +where t3.pk=t2.d and t2.b=t1.b and t2.c=t1.a +group by t1.b,t1.c; +b +drop table t3; +# With subq +select (select t1.b from t1 +where t2.b=t1.b +group by t1.a) from t1 as t2; +(select t1.b from t1 +where t2.b=t1.b +group by t1.a) +# Outer join. +create table t2 like t1; +delete from t1; +insert into t1 (a,b) values(1,10),(2,20); +Warnings: +Warning 1364 Field 'c' doesn't have a default value +insert into t2 (a,b) values(1,-10); +Warnings: +Warning 1364 Field 'c' doesn't have a default value +# In result, t2.a is NULL for both rows, values of t1.a are 1 and 2 +select t1.a,t2.a from t1 left join t2 on t2.a=t1.a and t2.b=t1.b; +a a +1 NULL +2 NULL +# So this query would choose one arbitrary value of t1.a - wrong: +select t1.a from t1 left join t2 on t2.a=t1.a and t2.b=t1.b group by t2.a; +ERROR 42000: Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'test.t1.a' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +# Also problem for FD with constant: +select t1.a,t2.a from t1 left join t2 on 42=t1.a and t2.b=t1.b; +a a +1 NULL +2 NULL +select t1.a from t1 left join t2 on 42=t1.a and t2.b=t1.b group by t2.a; +ERROR 42000: Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'test.t1.a' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +select t1.a from t1 left join t2 on t2.b=t1.a group by t2.b; +ERROR 42000: Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'test.t1.a' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +select t1.a from t1 left join t2 on 42=t1.a group by t2.a; +ERROR 42000: Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'test.t1.a' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +select t1.c from t1 left join t2 on t1.a=t1.c group by t1.a; +ERROR 42000: Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'test.t1.c' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +select t1.b from t1 left join t2 on t1.c=t1.b and t1.a=t1.c group by t1.a; +ERROR 42000: Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'test.t1.b' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +select t1.a,t2.c from t1 left join t2 on t1.a=t2.c +and cos(t2.c+t2.b)>0.5 and sin(t1.a+t2.d)<0.9 group by t1.a; +a c +1 NULL +2 NULL +# with keys: +select t1.a,t2.d from t1 left join t2 on t1.a=t2.c and t1.d=t2.b +and cos(t2.c+t2.b)>0.5 and sin(t1.a+t2.d)<0.9 group by t1.a,t1.d; +a d +1 NULL +2 NULL +# with non-determinism: +select t1.a,t2.c from t1 left join t2 on t1.a=t2.c +and cos(t2.c+rand())>0.5 group by t1.a; +ERROR 42000: Expression #2 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'test.t2.c' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +select t1.a, ANY_VALUE(t2.c) from t1 left join t2 on t1.a=t2.c +and cos(t2.c+rand())>0.5 group by t1.a; +a ANY_VALUE(t2.c) +1 NULL +2 NULL +# with parameter: +prepare s from 'select t1.a,t2.c from t1 left join t2 on t1.a=t2.c +and cos(t2.c+ ? )>0.5 group by t1.a'; +execute s using @dummy; +a c +1 NULL +2 NULL +# No OR +select t1.a,t2.c from t1 left join t2 on t1.a=t2.c +and cos(t2.c+t2.b)>0.5 OR sin(t2.d)<0.9 group by t1.a; +ERROR 42000: Expression #2 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'test.t2.c' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +# With subq +select t2.b from t1 left join t1 as t2 on t1.a=t2.b and t1.b group by t1.a; +ERROR 42000: Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'test.t2.b' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +select t2.b from t1 left join t1 as t2 on t1.a=t2.b and (select t1.b) group by t1.a; +ERROR 42000: Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'test.t2.b' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +# Test ANY_VALUE: +select ANY_VALUE(t1.b) from t1 left join t2 on t1.c=t1.b and t1.a=t1.c group by t1.a; +ANY_VALUE(t1.b) +10 +20 +select 3+(5*t1.b) from t1 left join t2 on t1.c=t1.b and t1.a=t1.c group by t1.a; +ERROR 42000: Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'test.t1.b' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +select 3+(5*ANY_VALUE(t1.b)) from t1 left join t2 on t1.c=t1.b and t1.a=t1.c group by t1.a; +3+(5*ANY_VALUE(t1.b)) +53 +103 +delete from t1; +insert into t1 (a,b) values(1,10),(1,20),(2,30),(2,40); +Warnings: +Warning 1364 Field 'c' doesn't have a default value +select a, sum(b) from t1; +ERROR 42000: In aggregated query without GROUP BY, expression #1 of SELECT list contains nonaggregated column 'test.t1.a'; this is incompatible with sql_mode=only_full_group_by +select any_value(a), sum(b) from t1; +any_value(a) sum(b) +1 100 +# different order of input rows, different "any_value": +select any_value(a), sum(b) from (select * from t1 order by a desc) as d; +any_value(a) sum(b) +1 100 +select a,b,sum(c) from t1 group by a; +ERROR 42000: Expression #2 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'test.t1.b' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +select a,any_value(b),sum(c) from t1 group by a; +a any_value(b) sum(c) +1 10 0 +2 30 0 +select a,any_value(b),sum(c) +from (select * from t1 order by a desc, b desc) as d +group by a; +a any_value(b) sum(c) +1 10 0 +2 30 0 +# With view. +set @optimizer_switch_saved=@@optimizer_switch; +# Merged view +create algorithm=merge view v1 as select t1.a*2 as a, t1.b as b, t1.c as c, t1.d as d, t1.a as e from t1; +show create view v1; +View Create View character_set_client collation_connection +v1 CREATE ALGORITHM=MERGE DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select (`t1`.`a` * 2) AS `a`,`t1`.`b` AS `b`,`t1`.`c` AS `c`,`t1`.`d` AS `d`,`t1`.`a` AS `e` from `t1` utf8mb4 utf8mb4_0900_ai_ci +select sin(a) as z from v1 group by b; +ERROR 42000: Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'test.v1.a' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +select sin(a) as z from v1 group by d,b; +ERROR 42000: Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'test.v1.a' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +select sin(a) as z from v1 group by c,b; +z +0.9092974268256817 +0.9092974268256817 +-0.7568024953079282 +-0.7568024953079282 +select (select sin(a)) as z from v1 group by d,b; +ERROR 42000: Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'test.v1.a' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +select (select sin(a)) as z from v1 group by c,b; +z +0.9092974268256817 +0.9092974268256817 +-0.7568024953079282 +-0.7568024953079282 +select sin(a) as z from t1 group by c*2,b*2; +ERROR 42000: Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'test.t1.a' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +select sin(a+b*c) as z from v1 group by c,b; +z +0.9092974268256817 +0.9092974268256817 +-0.7568024953079282 +-0.7568024953079282 +SELECT show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +"functional_dependencies_of_GROUP_columns": { + "all_columns_of_table_map_bits": [ + 0 + ] /* all_columns_of_table_map_bits */, + "columns": [ + "test.v1.c", + "test.v1.b" + ] /* columns */ + } +select sin(a) as z from v1 where b=2 group by c; +z +# {v1.b,v1.c}->v1.a->t2.a +select sin(t2.a) as z from v1, v1 as t2 +where t2.a=v1.a group by v1.b,v1.c; +z +0.9092974268256817 +0.9092974268256817 +-0.7568024953079282 +-0.7568024953079282 +SELECT show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +"functional_dependencies_of_GROUP_columns": { + "all_columns_of_table_map_bits": [ + 0 + ] /* all_columns_of_table_map_bits */, + "columns": [ + "test.v1.b", + "test.v1.c", + "test.t2.a" + ] /* columns */ + } +select sin(t2.a) as z from v1, v1 as t2 +where t2.b=v1.b and t2.c=v1.c group by v1.b,v1.c; +z +0.9092974268256817 +0.9092974268256817 +-0.7568024953079282 +-0.7568024953079282 +# With materialized view we get more dependencies than needed, due to implementation. +select t3.a from v1, v1 as t2, v1 as t3 +where +t3.b=t2.b and t3.c=v1.d and +t2.b=v1.b and t2.c=v1.c +group by v1.b,v1.c; +a +SELECT show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +"functional_dependencies_of_GROUP_columns": { + "all_columns_of_table_map_bits": [ + 0, + 1, + 2 + ] /* all_columns_of_table_map_bits */, + "columns": [ + "test.v1.b", + "test.v1.c", + "test.t3.c", + "test.t2.b", + "test.t2.c", + "test.t3.b" + ] /* columns */ + } +# If we simply went to real_item(), we would have WHERE 2*a=b, or +# GROUP BY 2*t1.a, so we would not find FDs. The original item +# (direct_view_ref here) must also be considered! +select a from v1 where a=b group by b; +a +SELECT show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +"functional_dependencies_of_GROUP_columns": { + "columns": [ + "test.v1.b", + "test.v1.a" + ] /* columns */ + } +select b from v1 where a=b group by a; +b +SELECT show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +"functional_dependencies_of_GROUP_columns": { + "columns": [ + "test.v1.a", + "test.v1.b" + ] /* columns */ + } +select v1.c from v1 where v1.c=v1.a group by v1.a; +c +SELECT show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +"functional_dependencies_of_GROUP_columns": { + "columns": [ + "test.v1.a", + "test.v1.c" + ] /* columns */ + } +select v1.a from v1 group by v1.e; +a +2 +4 +SELECT show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +"functional_dependencies_of_GROUP_columns": { + "columns": [ + "test.v1.e", + "test.v1.a" + ] /* columns */ + } +select v1.c from v1 where v1.c=v1.a group by v1.e; +c +SELECT show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +"functional_dependencies_of_GROUP_columns": { + "columns": [ + "test.v1.e", + "test.v1.a", + "test.v1.c" + ] /* columns */ + } +# View appears only in WHERE +select t2.d from v1, t1 as t2 where v1.a=t2.d and v1.e=t2.a group by t2.a; +d +SELECT show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +"functional_dependencies_of_GROUP_columns": { + "columns": [ + "test.t2.a", + "test.v1.e", + "test.v1.a", + "test.t2.d" + ] /* columns */ + } +drop view if exists v1; +# FD due to view's WHERE: +create algorithm=merge view v1 as select t1.a*2 as a, t1.b as b from t1; +select a from v1 group by b; +ERROR 42000: Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'test.v1.a' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +drop view if exists v1; +# Merged view +create algorithm=merge view v1 as select t1.a*2 as a, t1.b as b from t1 where t1.a=t1.b; +select a from v1 group by b; +a +SELECT show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +"functional_dependencies_of_GROUP_columns": { + "columns": [ + "test.v1.b", + "test.t1.a", + "test.v1.a" + ] /* columns */ + } +drop view if exists v1; +# Aggregates in view +# Aggregates => skipping Merged view +drop view if exists v1; +Warnings: +Note 1051 Unknown table 'test.v1' +# Aggregates + GROUP BY in view +# We group by b*5, to show that it works with GROUP expressions, not only fields. +# Aggregates => skipping Merged view +drop view if exists v1; +Warnings: +Note 1051 Unknown table 'test.v1' +set optimizer_switch=@optimizer_switch_saved; +set @optimizer_switch_saved=@@optimizer_switch; +# Materialized view +create algorithm=temptable view v1 as select t1.a*2 as a, t1.b as b, t1.c as c, t1.d as d, t1.a as e from t1; +show create view v1; +View Create View character_set_client collation_connection +v1 CREATE ALGORITHM=TEMPTABLE DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select (`t1`.`a` * 2) AS `a`,`t1`.`b` AS `b`,`t1`.`c` AS `c`,`t1`.`d` AS `d`,`t1`.`a` AS `e` from `t1` utf8mb4 utf8mb4_0900_ai_ci +select sin(a) as z from v1 group by b; +ERROR 42000: Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'test.v1.a' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +select sin(a) as z from v1 group by d,b; +ERROR 42000: Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'test.v1.a' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +select sin(a) as z from v1 group by c,b; +z +0.9092974268256817 +0.9092974268256817 +-0.7568024953079282 +-0.7568024953079282 +select (select sin(a)) as z from v1 group by d,b; +ERROR 42000: Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'test.v1.a' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +select (select sin(a)) as z from v1 group by c,b; +z +0.9092974268256817 +0.9092974268256817 +-0.7568024953079282 +-0.7568024953079282 +select sin(a) as z from t1 group by c*2,b*2; +ERROR 42000: Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'test.t1.a' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +select sin(a+b*c) as z from v1 group by c,b; +z +0.9092974268256817 +0.9092974268256817 +-0.7568024953079282 +-0.7568024953079282 +SELECT show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +"functional_dependencies_of_GROUP_columns": { + "columns": [ + "test.v1.c", + "test.v1.b", + "test.v1.a" + ] /* columns */, + "searched_in_materialized_tables": [ + { + "table": "`v1`", + "all_columns_of_table_map_bits": [ + 0 + ] /* all_columns_of_table_map_bits */, + "columns": [ + "test.t1.c", + "test.t1.b" + ] /* columns */ + } + ] /* searched_in_materialized_tables */ + } +select sin(a) as z from v1 where b=2 group by c; +z +# {v1.b,v1.c}->v1.a->t2.a +select sin(t2.a) as z from v1, v1 as t2 +where t2.a=v1.a group by v1.b,v1.c; +z +0.9092974268256817 +0.9092974268256817 +-0.7568024953079282 +-0.7568024953079282 +SELECT show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +"functional_dependencies_of_GROUP_columns": { + "columns": [ + "test.v1.b", + "test.v1.c", + "test.v1.a", + "test.t2.a" + ] /* columns */, + "searched_in_materialized_tables": [ + { + "table": "`v1`", + "all_columns_of_table_map_bits": [ + 0 + ] /* all_columns_of_table_map_bits */, + "columns": [ + "test.t1.b", + "test.t1.c" + ] /* columns */ + }, + { + "table": "`v1` `t2`" + } + ] /* searched_in_materialized_tables */ + } +select sin(t2.a) as z from v1, v1 as t2 +where t2.b=v1.b and t2.c=v1.c group by v1.b,v1.c; +z +0.9092974268256817 +0.9092974268256817 +-0.7568024953079282 +-0.7568024953079282 +# With materialized view we get more dependencies than needed, due to implementation. +select t3.a from v1, v1 as t2, v1 as t3 +where +t3.b=t2.b and t3.c=v1.d and +t2.b=v1.b and t2.c=v1.c +group by v1.b,v1.c; +a +SELECT show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +"functional_dependencies_of_GROUP_columns": { + "columns": [ + "test.v1.b", + "test.v1.c", + "test.t2.b", + "test.t2.c", + "test.t3.b", + "test.v1.d", + "test.t3.c", + "test.t3.a" + ] /* columns */, + "searched_in_materialized_tables": [ + { + "table": "`v1`", + "all_columns_of_table_map_bits": [ + 0 + ] /* all_columns_of_table_map_bits */, + "columns": [ + "test.t1.b", + "test.t1.c" + ] /* columns */ + }, + { + "table": "`v1` `t2`", + "columns": [ + "test.t1.b", + "test.t1.c" + ] /* columns */ + }, + { + "table": "`v1` `t3`", + "all_columns_of_table_map_bits": [ + 0 + ] /* all_columns_of_table_map_bits */, + "columns": [ + "test.t1.b", + "test.t1.c" + ] /* columns */ + } + ] /* searched_in_materialized_tables */ + } +# If we simply went to real_item(), we would have WHERE 2*a=b, or +# GROUP BY 2*t1.a, so we would not find FDs. The original item +# (direct_view_ref here) must also be considered! +select a from v1 where a=b group by b; +a +SELECT show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +"functional_dependencies_of_GROUP_columns": { + "columns": [ + "test.v1.b", + "test.v1.a" + ] /* columns */, + "searched_in_materialized_tables": [ + { + "table": "`v1`", + "columns": [ + "test.t1.b" + ] /* columns */ + } + ] /* searched_in_materialized_tables */ + } +select b from v1 where a=b group by a; +b +SELECT show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +"functional_dependencies_of_GROUP_columns": { + "columns": [ + "test.v1.a", + "test.v1.b" + ] /* columns */, + "searched_in_materialized_tables": [ + { + "table": "`v1`", + "columns": [ + "test.t1.b" + ] /* columns */ + } + ] /* searched_in_materialized_tables */ + } +select v1.c from v1 where v1.c=v1.a group by v1.a; +c +SELECT show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +"functional_dependencies_of_GROUP_columns": { + "columns": [ + "test.v1.a", + "test.v1.c" + ] /* columns */, + "searched_in_materialized_tables": [ + { + "table": "`v1`", + "columns": [ + "test.t1.c" + ] /* columns */ + } + ] /* searched_in_materialized_tables */ + } +select v1.a from v1 group by v1.e; +a +2 +4 +SELECT show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +"functional_dependencies_of_GROUP_columns": { + "columns": [ + "test.v1.e", + "test.v1.a" + ] /* columns */, + "searched_in_materialized_tables": [ + { + "table": "`v1`", + "columns": [ + "test.t1.a" + ] /* columns */ + } + ] /* searched_in_materialized_tables */ + } +select v1.c from v1 where v1.c=v1.a group by v1.e; +c +SELECT show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +"functional_dependencies_of_GROUP_columns": { + "columns": [ + "test.v1.e", + "test.v1.a", + "test.v1.c" + ] /* columns */, + "searched_in_materialized_tables": [ + { + "table": "`v1`", + "columns": [ + "test.t1.a", + "test.t1.c" + ] /* columns */ + } + ] /* searched_in_materialized_tables */ + } +# View appears only in WHERE +select t2.d from v1, t1 as t2 where v1.a=t2.d and v1.e=t2.a group by t2.a; +d +SELECT show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +"functional_dependencies_of_GROUP_columns": { + "columns": [ + "test.t2.a", + "test.v1.e", + "test.v1.a", + "test.t2.d" + ] /* columns */, + "searched_in_materialized_tables": [ + { + "table": "`v1`", + "columns": [ + "test.t1.a" + ] /* columns */ + } + ] /* searched_in_materialized_tables */ + } +drop view if exists v1; +# FD due to view's WHERE: +create algorithm=temptable view v1 as select t1.a*2 as a, t1.b as b from t1; +select a from v1 group by b; +ERROR 42000: Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'test.v1.a' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +drop view if exists v1; +# Materialized view +create algorithm=temptable view v1 as select t1.a*2 as a, t1.b as b from t1 where t1.a=t1.b; +select a from v1 group by b; +a +SELECT show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +"functional_dependencies_of_GROUP_columns": { + "columns": [ + "test.v1.b", + "test.v1.a" + ] /* columns */, + "searched_in_materialized_tables": [ + { + "table": "`v1`", + "columns": [ + "test.t1.b", + "test.t1.a" + ] /* columns */ + } + ] /* searched_in_materialized_tables */ + } +drop view if exists v1; +# Aggregates in view +# Materialized view +create algorithm=temptable view v1 as select sum(t1.a) as a, sum(t1.b) as b from t1; +select a from v1 group by b; +a +6 +SELECT show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +"functional_dependencies_of_GROUP_columns": { + "all_columns_of_table_map_bits": [ + 0 + ] /* all_columns_of_table_map_bits */, + "columns": [ + "test.v1.b" + ] /* columns */, + "searched_in_materialized_tables": [ + { + "table": "`v1`" + } + ] /* searched_in_materialized_tables */ + } +drop view if exists v1; +# Aggregates + GROUP BY in view +# We group by b*5, to show that it works with GROUP expressions, not only fields. +# Materialized view +create algorithm=temptable view v1 as select a, b*5 as b, sum(t1.c) as c, sum(t1.d) as d from t1 group by a,b*5; +select a from v1 group by b; +ERROR 42000: Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'test.v1.a' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +select c from v1 group by b; +ERROR 42000: Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'test.v1.c' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +select c from v1 group by b,d; +ERROR 42000: Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'test.v1.c' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +select a,c from v1 group by a; +ERROR 42000: Expression #2 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'test.v1.c' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +select d,c from v1 group by b,a; +d c +NULL 0 +NULL 0 +NULL 0 +NULL 0 +SELECT show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +"functional_dependencies_of_GROUP_columns": { + "all_columns_of_table_map_bits": [ + 0 + ] /* all_columns_of_table_map_bits */, + "columns": [ + "test.v1.b", + "test.v1.a" + ] /* columns */, + "searched_in_materialized_tables": [ + { + "table": "`v1`", + "columns": [ + "test.t1.a" + ] /* columns */, + "all_group_expressions": true + } + ] /* searched_in_materialized_tables */ + } +drop view if exists v1; +set optimizer_switch=@optimizer_switch_saved; +set @optimizer_switch_saved=@@optimizer_switch; +# Materialized derived table +set optimizer_switch='derived_merge=off'; +select sin(a) as z from (select t1.a*2 as a, t1.b as b, t1.c as c, t1.d as d, t1.a as e from t1) as v1 group by b; +ERROR 42000: Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'v1.a' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +select sin(a) as z from (select t1.a*2 as a, t1.b as b, t1.c as c, t1.d as d, t1.a as e from t1) as v1 group by d,b; +ERROR 42000: Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'v1.a' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +select sin(a) as z from (select t1.a*2 as a, t1.b as b, t1.c as c, t1.d as d, t1.a as e from t1) as v1 group by c,b; +z +0.9092974268256817 +0.9092974268256817 +-0.7568024953079282 +-0.7568024953079282 +select (select sin(a)) as z from (select t1.a*2 as a, t1.b as b, t1.c as c, t1.d as d, t1.a as e from t1) as v1 group by d,b; +ERROR 42000: Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'v1.a' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +select (select sin(a)) as z from (select t1.a*2 as a, t1.b as b, t1.c as c, t1.d as d, t1.a as e from t1) as v1 group by c,b; +z +0.9092974268256817 +0.9092974268256817 +-0.7568024953079282 +-0.7568024953079282 +select sin(a) as z from t1 group by c*2,b*2; +ERROR 42000: Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'test.t1.a' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +select sin(a+b*c) as z from (select t1.a*2 as a, t1.b as b, t1.c as c, t1.d as d, t1.a as e from t1) as v1 group by c,b; +z +0.9092974268256817 +0.9092974268256817 +-0.7568024953079282 +-0.7568024953079282 +SELECT show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +"functional_dependencies_of_GROUP_columns": { + "columns": [ + "v1.c", + "v1.b", + "v1.a" + ] /* columns */, + "searched_in_materialized_tables": [ + { + "table": " `v1`", + "all_columns_of_table_map_bits": [ + 0 + ] /* all_columns_of_table_map_bits */, + "columns": [ + "test.t1.c", + "test.t1.b" + ] /* columns */ + } + ] /* searched_in_materialized_tables */ + } +select sin(a) as z from (select t1.a*2 as a, t1.b as b, t1.c as c, t1.d as d, t1.a as e from t1) as v1 where b=2 group by c; +z +# {v1.b,v1.c}->v1.a->t2.a +select sin(t2.a) as z from (select t1.a*2 as a, t1.b as b, t1.c as c, t1.d as d, t1.a as e from t1) as v1, (select t1.a*2 as a, t1.b as b, t1.c as c, t1.d as d, t1.a as e from t1) as t2 +where t2.a=v1.a group by v1.b,v1.c; +z +0.9092974268256817 +0.9092974268256817 +-0.7568024953079282 +-0.7568024953079282 +SELECT show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +"functional_dependencies_of_GROUP_columns": { + "columns": [ + "v1.b", + "v1.c", + "v1.a", + "t2.a" + ] /* columns */, + "searched_in_materialized_tables": [ + { + "table": " `v1`", + "all_columns_of_table_map_bits": [ + 0 + ] /* all_columns_of_table_map_bits */, + "columns": [ + "test.t1.b", + "test.t1.c" + ] /* columns */ + }, + { + "table": " `t2`" + } + ] /* searched_in_materialized_tables */ + } +select sin(t2.a) as z from (select t1.a*2 as a, t1.b as b, t1.c as c, t1.d as d, t1.a as e from t1) as v1, (select t1.a*2 as a, t1.b as b, t1.c as c, t1.d as d, t1.a as e from t1) as t2 +where t2.b=v1.b and t2.c=v1.c group by v1.b,v1.c; +z +0.9092974268256817 +0.9092974268256817 +-0.7568024953079282 +-0.7568024953079282 +# With materialized view we get more dependencies than needed, due to implementation. +select t3.a from (select t1.a*2 as a, t1.b as b, t1.c as c, t1.d as d, t1.a as e from t1) as v1, (select t1.a*2 as a, t1.b as b, t1.c as c, t1.d as d, t1.a as e from t1) as t2, (select t1.a*2 as a, t1.b as b, t1.c as c, t1.d as d, t1.a as e from t1) as t3 +where +t3.b=t2.b and t3.c=v1.d and +t2.b=v1.b and t2.c=v1.c +group by v1.b,v1.c; +a +SELECT show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +"functional_dependencies_of_GROUP_columns": { + "columns": [ + "v1.b", + "v1.c", + "t2.b", + "t2.c", + "t3.b", + "v1.d", + "t3.c", + "t3.a" + ] /* columns */, + "searched_in_materialized_tables": [ + { + "table": " `v1`", + "all_columns_of_table_map_bits": [ + 0 + ] /* all_columns_of_table_map_bits */, + "columns": [ + "test.t1.b", + "test.t1.c" + ] /* columns */ + }, + { + "table": " `t2`", + "columns": [ + "test.t1.b", + "test.t1.c" + ] /* columns */ + }, + { + "table": " `t3`", + "all_columns_of_table_map_bits": [ + 0 + ] /* all_columns_of_table_map_bits */, + "columns": [ + "test.t1.b", + "test.t1.c" + ] /* columns */ + } + ] /* searched_in_materialized_tables */ + } +# If we simply went to real_item(), we would have WHERE 2*a=b, or +# GROUP BY 2*t1.a, so we would not find FDs. The original item +# (direct_view_ref here) must also be considered! +select a from (select t1.a*2 as a, t1.b as b, t1.c as c, t1.d as d, t1.a as e from t1) as v1 where a=b group by b; +a +SELECT show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +"functional_dependencies_of_GROUP_columns": { + "columns": [ + "v1.b", + "v1.a" + ] /* columns */, + "searched_in_materialized_tables": [ + { + "table": " `v1`", + "columns": [ + "test.t1.b" + ] /* columns */ + } + ] /* searched_in_materialized_tables */ + } +select b from (select t1.a*2 as a, t1.b as b, t1.c as c, t1.d as d, t1.a as e from t1) as v1 where a=b group by a; +b +SELECT show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +"functional_dependencies_of_GROUP_columns": { + "columns": [ + "v1.a", + "v1.b" + ] /* columns */, + "searched_in_materialized_tables": [ + { + "table": " `v1`", + "columns": [ + "test.t1.b" + ] /* columns */ + } + ] /* searched_in_materialized_tables */ + } +select v1.c from (select t1.a*2 as a, t1.b as b, t1.c as c, t1.d as d, t1.a as e from t1) as v1 where v1.c=v1.a group by v1.a; +c +SELECT show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +"functional_dependencies_of_GROUP_columns": { + "columns": [ + "v1.a", + "v1.c" + ] /* columns */, + "searched_in_materialized_tables": [ + { + "table": " `v1`", + "columns": [ + "test.t1.c" + ] /* columns */ + } + ] /* searched_in_materialized_tables */ + } +select v1.a from (select t1.a*2 as a, t1.b as b, t1.c as c, t1.d as d, t1.a as e from t1) as v1 group by v1.e; +a +2 +4 +SELECT show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +"functional_dependencies_of_GROUP_columns": { + "columns": [ + "v1.e", + "v1.a" + ] /* columns */, + "searched_in_materialized_tables": [ + { + "table": " `v1`", + "columns": [ + "test.t1.a" + ] /* columns */ + } + ] /* searched_in_materialized_tables */ + } +select v1.c from (select t1.a*2 as a, t1.b as b, t1.c as c, t1.d as d, t1.a as e from t1) as v1 where v1.c=v1.a group by v1.e; +c +SELECT show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +"functional_dependencies_of_GROUP_columns": { + "columns": [ + "v1.e", + "v1.a", + "v1.c" + ] /* columns */, + "searched_in_materialized_tables": [ + { + "table": " `v1`", + "columns": [ + "test.t1.a", + "test.t1.c" + ] /* columns */ + } + ] /* searched_in_materialized_tables */ + } +# View appears only in WHERE +select t2.d from (select t1.a*2 as a, t1.b as b, t1.c as c, t1.d as d, t1.a as e from t1) as v1, t1 as t2 where v1.a=t2.d and v1.e=t2.a group by t2.a; +d +SELECT show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +"functional_dependencies_of_GROUP_columns": { + "columns": [ + "test.t2.a", + "v1.e", + "v1.a", + "test.t2.d" + ] /* columns */, + "searched_in_materialized_tables": [ + { + "table": " `v1`", + "columns": [ + "test.t1.a" + ] /* columns */ + } + ] /* searched_in_materialized_tables */ + } +drop view if exists v1; +Warnings: +Note 1051 Unknown table 'test.v1' +# FD due to view's WHERE: +select a from (select t1.a*2 as a, t1.b as b from t1) as v1 group by b; +ERROR 42000: Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'v1.a' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +drop view if exists v1; +Warnings: +Note 1051 Unknown table 'test.v1' +# Derived table +select a from (select t1.a*2 as a, t1.b as b from t1 where t1.a=t1.b) as v1 group by b; +a +SELECT show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +"functional_dependencies_of_GROUP_columns": { + "columns": [ + "v1.b", + "v1.a" + ] /* columns */, + "searched_in_materialized_tables": [ + { + "table": " `v1`", + "columns": [ + "test.t1.b", + "test.t1.a" + ] /* columns */ + } + ] /* searched_in_materialized_tables */ + } +drop view if exists v1; +Warnings: +Note 1051 Unknown table 'test.v1' +# Aggregates in view +# Derived table +select a from (select sum(t1.a) as a, sum(t1.b) as b from t1) as v1 group by b; +a +6 +SELECT show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +"functional_dependencies_of_GROUP_columns": { + "all_columns_of_table_map_bits": [ + 0 + ] /* all_columns_of_table_map_bits */, + "columns": [ + "v1.b" + ] /* columns */, + "searched_in_materialized_tables": [ + { + "table": " `v1`" + } + ] /* searched_in_materialized_tables */ + } +drop view if exists v1; +Warnings: +Note 1051 Unknown table 'test.v1' +# Aggregates + GROUP BY in view +# We group by b*5, to show that it works with GROUP expressions, not only fields. +# Derived table +select a from (select a, b*5 as b, sum(t1.c) as c, sum(t1.d) as d from t1 group by a,b*5) as v1 group by b; +ERROR 42000: Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'v1.a' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +select c from (select a, b*5 as b, sum(t1.c) as c, sum(t1.d) as d from t1 group by a,b*5) as v1 group by b; +ERROR 42000: Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'v1.c' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +select c from (select a, b*5 as b, sum(t1.c) as c, sum(t1.d) as d from t1 group by a,b*5) as v1 group by b,d; +ERROR 42000: Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'v1.c' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +select a,c from (select a, b*5 as b, sum(t1.c) as c, sum(t1.d) as d from t1 group by a,b*5) as v1 group by a; +ERROR 42000: Expression #2 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'v1.c' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +select d,c from (select a, b*5 as b, sum(t1.c) as c, sum(t1.d) as d from t1 group by a,b*5) as v1 group by b,a; +d c +NULL 0 +NULL 0 +NULL 0 +NULL 0 +SELECT show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +"functional_dependencies_of_GROUP_columns": { + "all_columns_of_table_map_bits": [ + 0 + ] /* all_columns_of_table_map_bits */, + "columns": [ + "v1.b", + "v1.a" + ] /* columns */, + "searched_in_materialized_tables": [ + { + "table": " `v1`", + "columns": [ + "test.t1.a" + ] /* columns */, + "all_group_expressions": true + } + ] /* searched_in_materialized_tables */ + } +drop view if exists v1; +Warnings: +Note 1051 Unknown table 'test.v1' +set optimizer_switch=@optimizer_switch_saved; +# Derived table in merged view +create algorithm=temptable view v2 +as select a as a, 2*a as b from t1; +create algorithm=merge view v1 +as select v2.a as a, 3*v2.b as b from v2; +select v1.b from v1 group by v1.a; +b +6 +12 +SELECT show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +"functional_dependencies_of_GROUP_columns": { + "columns": [ + "test.v1.a", + "test.v2.b", + "test.v1.b" + ] /* columns */, + "searched_in_materialized_tables": [ + { + "table": "`v2`", + "columns": [ + "test.t1.a" + ] /* columns */ + } + ] /* searched_in_materialized_tables */ + } +select t2.a from t1 as t2, v1 where t2.a=v1.b group by v1.a; +a +SELECT show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +"functional_dependencies_of_GROUP_columns": { + "columns": [ + "test.v1.a", + "test.v2.b", + "test.v1.b", + "test.t2.a" + ] /* columns */, + "searched_in_materialized_tables": [ + { + "table": "`v2`", + "columns": [ + "test.t1.a" + ] /* columns */ + } + ] /* searched_in_materialized_tables */ + } +# FDs in a view are those of the underlying query expression. +# FDs in a query expression: expressions in the SELECT list must be +# deterministic. +drop view v1; +create algorithm=merge view v1 +as select v2.a as a, rand()*v2.b as b from v2; +select v1.b from v1 group by v1.a; +ERROR 42000: Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'test.v1.b' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +drop view v1; +create algorithm=temptable view v1 +as select v2.a as a, rand()*v2.b as b from v2; +select v1.b from v1 group by v1.a; +ERROR 42000: Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'test.v1.b' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +drop view v1,v2; +# Item_direct_view_ref pointing to Item_direct_view_ref pointing to +# Item_field (a rare case!) +create algorithm=merge view v2 as select 2*a as a, 2*b as b from t1; +create algorithm=merge view v1 as select a, 3*b as b from v2 where a=b; +select 1 from (select a,b+0 from v1 group by a) as d; +1 +drop view v1,v2; +# Some fun cases with aggregates in derived table. +# Inner query is valid: t1.a -> t1.b (equality in WHERE). Outer query: +# d.b -> t1.b (underlying column of d.b) -> t1.a (equality) +# -> sum(1) (because t1.a is all group columns so determines +# sum()) -> d.s (because sum() is underlying of d.s) +select d.s from +(select b, sum(1) as s from t1 where a=b group by a) as d +group by d.b; +s +alter table t1 add column pk int primary key auto_increment; +# Inner query: t1.pk -> t1.* (pk). Outer query: +# d.b,d.c -> t1.b,t1.c (their underlying columns) -> t1.pk (because +# t1.b,t1.c is unique) -> sum(1) (because t1.pk is all group columns so +# determines sum()) -> d.s (because sum() is underlying of d.s) +select d.s from +(select b, c, sum(d) as s from t1 group by pk) as d +group by d.b,d.c; +s +NULL +NULL +NULL +NULL +# Outer query: +# d.c -> t1.b*3 (underlying column of d.c) -> sum(a) (because t1.b*3 +# is all group expressions) -> d.s +select d.s from +(select b*3 as c, sum(a) as s from t1 group by b*3) as d +group by d.c; +s +1 +1 +2 +2 +drop table t1,t2; +# Testcase from Reviewers +create table customer1(pk int primary key, a int); +create table customer2(pk int primary key, b int); +CREATE algorithm=merge VIEW customer as SELECT pk,a,b +FROM customer1 JOIN customer2 USING (pk); +select customer.pk, customer.b +from customer +group by customer.pk; +pk b +# View is merged. Show FDs. Note that in --ps-protocol, the trace +# is that of execution, so contains no group-by checks. +SELECT show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +"functional_dependencies_of_GROUP_columns": { + "all_columns_of_table_map_bits": [ + 0, + 1 + ] /* all_columns_of_table_map_bits */, + "columns": [ + "test.customer.pk", + "test.customer2.pk" + ] /* columns */ + } +drop view customer; +CREATE algorithm=temptable VIEW customer as SELECT pk,a,b +FROM customer1 JOIN customer2 USING (pk); +select customer.pk, customer.b +from customer +group by customer.pk; +pk b +SELECT show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +"functional_dependencies_of_GROUP_columns": { + "columns": [ + "test.customer.pk", + "test.customer.b" + ] /* columns */, + "searched_in_materialized_tables": [ + { + "table": "`customer`", + "all_columns_of_table_map_bits": [ + 0, + 1 + ] /* all_columns_of_table_map_bits */, + "columns": [ + "test.customer1.pk", + "test.customer2.pk" + ] /* columns */ + } + ] /* searched_in_materialized_tables */ + } +# Benefit from outer-join-to-inner conversion. +insert into customer1 values(0,10),(1,20); +insert into customer2 values(0,10),(1,20); +# 1) no conversion, no FD from customer2.b to customer1.a. +explain select customer1.a, count(*) +from customer1 left join customer2 on customer1.a=customer2.b +where customer1.pk in (7,9) +group by customer2.b; +ERROR 42000: Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'test.customer1.a' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +# 2) null-complemented row can't pass WHERE => conversion +# => FD from customer2.b to customer1.a. +explain select customer1.a, count(*) +from customer1 left join customer2 on customer1.a=customer2.b +where customer2.pk in (7,9) +group by customer2.b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE customer1 NULL ALL NULL NULL NULL NULL 2 100.00 Using temporary +2 SIMPLE customer2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`customer1`.`a` AS `a`,count(0) AS `count(*)` from `test`.`customer1` join `test`.`customer2` where ((`test`.`customer2`.`b` = `test`.`customer1`.`a`) and (`test`.`customer2`.`pk` in (7,9))) group by `test`.`customer2`.`b` +drop table customer1,customer2; +drop view customer; +# FDs of JOIN...USING and NATURAL JOIN +create table t1(pk int primary key, a int); +create table t2(pk int primary key, b int); +select t1.pk, t1.a from t1 join t2 on t1.pk=t2.pk group by t1.pk; +pk a +select t1.pk, t1.a from t1 join t2 using(pk) group by t1.pk; +pk a +select t1.pk, t1.a from t1 natural join t2 group by t1.pk; +pk a +select t1.pk, t1.a from t1 left join t2 using(pk) group by t1.pk; +pk a +select t1.pk, t1.a from t1 natural left join t2 group by t1.pk; +pk a +select t1.pk, t2.b from t1 join t2 on t1.pk=t2.pk group by t1.pk; +pk b +select t1.pk, t2.b from t1 join t2 using(pk) group by t1.pk; +pk b +select t1.pk, t2.b from t1 natural join t2 group by t1.pk; +pk b +select t1.pk, t2.b from t1 left join t2 using(pk) group by t1.pk; +pk b +SELECT show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +"functional_dependencies_of_GROUP_columns": { + "all_columns_of_table_map_bits": [ + 0, + 1 + ] /* all_columns_of_table_map_bits */, + "columns": [ + "test.t1.pk", + "test.t2.pk" + ] /* columns */ + } +select t1.pk, t2.b from t1 natural left join t2 group by t1.pk; +pk b +# Equivalent queries, with RIGHT JOIN +select t1.pk, t2.b from t2 right join t1 using(pk) group by t1.pk; +pk b +select t1.pk, t2.b from t2 natural right join t1 group by t1.pk; +pk b +select t1.pk, t2.b from t1 left join t2 on t1.pk>t2.pk group by t1.pk; +ERROR 42000: Expression #2 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'test.t2.b' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +# Even in --ps-protocol we see the group-by checks in trace because +# there has been no execution (due to error). +SELECT show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +"functional_dependencies_of_GROUP_columns": { + "all_columns_of_table_map_bits": [ + 0 + ] /* all_columns_of_table_map_bits */, + "columns": [ + "test.t1.pk" + ] /* columns */ + } +select t1.pk, t2.b from t2 right join t1 on t1.pk>t2.pk group by t1.pk; +ERROR 42000: Expression #2 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'test.t2.b' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +drop table t1,t2; +# Cases where FDs from weak side do not propagate +create table t1(a int, b int); +insert into t1 values(null,0),(null,1); +select d.a,d.c +from t1 left join (select a, coalesce(a,3) as c from t1) as d +on t1.b>0; +a c +NULL 3 +NULL 3 +NULL NULL +# Now group it by d.a: +select d.a,d.c +from t1 left join (select a, coalesce(a,3) as c from t1) as d +on t1.b>0 group by d.a; +ERROR 42000: Expression #2 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'd.c' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +SELECT show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +"functional_dependencies_of_GROUP_columns": { + "columns": [ + "d.a" + ] /* columns */ + } +select d.a,d.c +from t1 left join (select a, count(a) as c from t1 group by a) as d +on t1.b+d.c>0; +a c +NULL 0 +NULL NULL +# Now group it by d.a: +select d.a,d.c +from t1 left join (select a, count(a) as c from t1 group by a) as d +on t1.b+d.c>0 group by d.a; +ERROR 42000: Expression #2 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'd.c' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +SELECT show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +"functional_dependencies_of_GROUP_columns": { + "columns": [ + "d.a" + ] /* columns */, + "searched_in_materialized_tables": [ + { + "table": " `d`", + "columns": [ + "test.t1.a" + ] /* columns */, + "all_group_expressions": true + } + ] /* searched_in_materialized_tables */ + } +select d.m,d.c +from t1 left join (select max(a) as m, count(a) as c from t1) as d +on t1.b+d.c>0; +m c +NULL 0 +NULL NULL +# Now group it by d.m: +select d.m,d.c +from t1 left join (select max(a) as m, count(a) as c from t1) as d +on t1.b+d.c>0 group by d.m; +ERROR 42000: Expression #2 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'd.c' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +SELECT show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +"functional_dependencies_of_GROUP_columns": { + "columns": [ + "d.m" + ] /* columns */, + "searched_in_materialized_tables": [ + { + "table": " `d`" + } + ] /* searched_in_materialized_tables */ + } +# Now group it by d.c which is non-nullable: +select d.m,d.c +from t1 left join (select max(a) as m, count(a) as c from t1) as d +on t1.b+d.c>0 group by d.c; +m c +NULL 0 +NULL NULL +SELECT show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +"functional_dependencies_of_GROUP_columns": { + "all_columns_of_table_map_bits": [ + 1 + ] /* all_columns_of_table_map_bits */, + "columns": [ + "d.c" + ] /* columns */, + "searched_in_materialized_tables": [ + { + "table": " `d`" + } + ] /* searched_in_materialized_tables */ + } +drop table t1; +create table t1(pk int primary key, a int); +# Not valid per the standard, because: +# 1) In t3, t3.pk->t3.a holds. +# 2) In R1 the result of "(t2 left join t3 on 1)", t3.pk->t3.a +# holds, by application of: there is a functional dependency in the +# weak side t3, and t3.pk is not nullable in t3. +# 3) In R2 the result of "t1 left join (t2 left join t3 on 1) on 1", +# t3.pk->t3.a doesn't hold anymore, because: it's a dependency in the +# weak side (weak side is R1), and t3.pk is nullable _when +# seen as a column of R1_ (in R1 t3.pk can be NULL, if the row of t3 +# is actually a null-complemented one). +# But for us it is valid, because we have refined the logic: the +# pk-based FD satisfies the requirement that a NULL value of t3.pk +# implies a NULL value of t3.a (indeed, the NULL value of t3.pk can +# only come from null-complementing of the row of t3 in R1, in which +# case t3.a is also NULL). +select t3.a +from t1 left join (t1 as t2 left join t1 as t3 on 1) on 1 +group by t3.pk; +a +SELECT show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +"functional_dependencies_of_GROUP_columns": { + "all_columns_of_table_map_bits": [ + 2 + ] /* all_columns_of_table_map_bits */, + "columns": [ + "test.t3.pk" + ] /* columns */ + } +# Outer reference - why we use resolved_used_tables(): +select (select t1.a from t1 as t2 limit 1) from t1 group by pk; +(select t1.a from t1 as t2 limit 1) +# We don't build the FD list if not needed +select t1.a*3 from t1 group by t1.a; +t1.a*3 +SELECT show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +NOT FOUND +drop table t1; +# Tricky cases with "ON col=literal" propagating. +create table t1(a int, b int); +insert into t1 values(); +insert into t1 values(10,11); +create table t2(c int, d int); +insert into t2 values(2,3); +select t4.d +from t1 left join (t2 as t3 join t2 as t4 on t4.d=3) on t1.a=10; +d +3 +NULL +# Equivalent to T1 LJ (T2, T3) ON T4.D=3 AND T1.A=10 +# (this is what simplify_joins() does). +# For T4.D=3, DJS is {T1.A} which is not group column. +select t4.d +from t1 left join (t2 as t3 join t2 as t4 on t4.d=3) on t1.a=10 group by ""; +ERROR 42000: Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'test.t4.d' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +select t4.d +from t1 left join (t2 as t3 left join t2 as t4 on t4.d=3) on t1.a=10; +d +3 +NULL +# For T4.D=3, DJS={}, not NULL-friendly, and embedding is on weak side +# so FD cannot propagate. +select t4.d +from t1 left join (t2 as t3 left join t2 as t4 on t4.d=3) on t1.a=10 group by ""; +ERROR 42000: Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'test.t4.d' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +select t4.d +from t1 join (t2 as t3 left join t2 as t4 on t4.d=3) on t1.a=10; +d +3 +# For T4.D=3, DJS={}, not NULL-friendly, but embedding is on weak side +# so FD can propagate. +select t4.d +from t1 join (t2 as t3 left join t2 as t4 on t4.d=3) on t1.a=10 group by ""; +d +3 +# With a view +create view v1 as select a as a, 2*a as b, coalesce(a,3) as c from t1; +select v1.b from t1 left join v1 on 1; +b +20 +20 +NULL +NULL +# If v1.a is NULL then v1.b is NULL: a->b is NULL-friendly +select v1.b from t1 left join v1 on 1 group by v1.a; +b +20 +NULL +select v1.c from t1 left join v1 on 1; +c +10 +10 +3 +3 +# If v1.a is NULL then v1.c may not be NULL: a->c is not NULL-friendly +select v1.c from t1 left join v1 on 1 group by v1.a; +ERROR 42000: Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'test.v1.c' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +drop view v1; +# Constant view item +create view v1 as select a as a, 2 as b from t1; +# Because of BUG#17023060, the result is wrong, should be +# [10,2 ; 10,2 ; NULL,NULL], which would show that {}->{v1.b} does not +# hold in the result, even though v1.b is constant (=2) in v1. +select t1.a, v1.b from t1 left join v1 on t1.a is not null; +a b +10 2 +10 2 +NULL NULL +# We correctly reject this: +select t1.a, v1.b from t1 left join v1 on t1.a is not null group by v1.a; +ERROR 42000: Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'test.t1.a' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +drop view v1; +drop table t1,t2; +create table emp(empno int, ename char(1), deptno int); +create table dept(deptno int primary key, dname char(1)); +CREATE algorithm=merge VIEW empdept AS +SELECT emp.empno, emp.ename, dept.deptno, dept.dname +FROM emp LEFT OUTER JOIN dept ON (emp.deptno = dept.deptno); +EXPLAIN SELECT dname, COUNT(*) +FROM empdept +GROUP BY deptno; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE emp NULL ALL NULL NULL NULL NULL 1 100.00 Using temporary +1 SIMPLE dept NULL eq_ref PRIMARY PRIMARY 4 test.emp.deptno 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`dept`.`dname` AS `dname`,count(0) AS `COUNT(*)` from `test`.`emp` left join `test`.`dept` on((`test`.`dept`.`deptno` = `test`.`emp`.`deptno`)) where true group by `test`.`dept`.`deptno` +# There is pk-based FD dept.Depno->dept.dname in dept +# and it propagates in the view-which-became-nest because it is +# NULL-friendly. +SELECT dname, COUNT(*) +FROM empdept +GROUP BY deptno; +dname COUNT(*) +drop view empdept; +CREATE algorithm=temptable VIEW empdept AS +SELECT emp.empno, emp.ename, dept.deptno, dept.dname +FROM emp LEFT OUTER JOIN dept ON (emp.deptno = dept.deptno); +EXPLAIN SELECT dname, COUNT(*) +FROM empdept +GROUP BY deptno; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 Using temporary +2 DERIVED emp NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 DERIVED dept NULL eq_ref PRIMARY PRIMARY 4 test.emp.deptno 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`empdept`.`dname` AS `dname`,count(0) AS `COUNT(*)` from `test`.`empdept` group by `test`.`empdept`.`deptno` +# There is pk-based FD dept.Depno->dept.dname in dept +# and it propagates in the materialized view because it is +# NULL-friendly, and then in the top query because the view is not in +# the weak side of an outer join. +SELECT dname, COUNT(*) +FROM empdept +GROUP BY deptno; +dname COUNT(*) +# More tests, for code coverage. +# UNION in derived table +select emp.ename +from +(select 1 as empno union select 2) deriv, +emp +where emp.empno=deriv.empno +group by emp.empno; +ERROR 42000: Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'test.emp.ename' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +drop view empdept; +# Make the key-searching loop meet view columns which don't wrap a +# column (CONCAT). +CREATE VIEW empdept AS +SELECT emp.empno, emp.ename, dept.deptno, concat("",dept.dname) as dname +FROM emp LEFT JOIN dept ON (emp.deptno = dept.deptno); +SELECT ename, COUNT(*) FROM empdept WHERE empno=dname and empno=deptno GROUP BY empno; +ERROR 42000: Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'test.empdept.ename' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +drop table emp,dept; +drop view empdept; +# +# Bug#19636980 ASSERT `TABLE->OUTER_JOIN' FAILED IN GROUP_CHECK::FIND_FD_IN_JOINED_TABLE +# +CREATE TABLE t1 ( +c1 INT, +c2 INT, +c4 DATE, +c5 VARCHAR(1) +); +CREATE TABLE t2 ( +c1 INT, +c2 INT, +c3 INT, +c5 VARCHAR(1) +); +# alias1.c5 is not FD, the error is detected at SELECT time +CREATE VIEW v1 AS +SELECT alias1.c4 AS field1 +FROM t1 AS alias1 +INNER JOIN t1 AS alias2 +ON 1 +GROUP BY field1 +ORDER BY alias1.c5; +SELECT * FROM v1; +ERROR 42000: Expression #1 of ORDER BY clause is not in GROUP BY clause and contains nonaggregated column 'test.alias1.c5' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +DROP VIEW v1; +# alias1.c5 is FD (WHERE contains: alias1.c5='d') +CREATE VIEW v1 AS +SELECT alias1.c4 AS field1, alias1.c4 AS field2 +FROM t1 AS alias1 +INNER JOIN t1 AS alias2 +ON (alias2.c1 = alias1.c2) +WHERE ( NOT EXISTS ( +SELECT SQ1_alias1.c5 AS SQ1_field1 +FROM t2 AS SQ1_alias1 +WHERE SQ1_alias1.c3 < alias1.c1 +)) +AND (alias1.c5 = alias1.c5 +AND alias1.c5 = 'd' + ) +GROUP BY field1, field2 +ORDER BY alias1.c5, field1, field2 +; +SELECT * FROM v1; +field1 field2 +DROP VIEW v1; +DROP TABLE t1,t2; +# +# Bug#19636409 ASSERT `(MAP_OF_NEW_EQ_FDS...` IN GROUP_CHECK::IS_FD_ON_SOURCE ON SELECT +# +CREATE TABLE t1 ( +pk int NOT NULL, +c1 datetime, +c2 varchar(1), +c3 date, +c4 date, +c5 varchar(1), +PRIMARY KEY (pk) +); +CREATE VIEW v1 AS +SELECT c3 AS subfield11, +pk AS subfield12, +c2 AS subfield13 +FROM t1 +GROUP BY subfield11, subfield12 +; +# This query is valid. Indeed: field3 i.e. t1.c2 is part of GROUP BY, +# so, in a group: +# - all rows have the same value of t1.c2, noted val_c2, +# - so all rows, which necessarily match WHERE, matched with a row of +# v1 having subfield11=val_c2 and subfield12=val_c2 (due to IN +# predicate), +# - thus both grouping columns of v1's query expression are constant +# (to val_c2) +# - thus v1.subfield13 is constant too (grouping columns determine the +# SELECT list) +# - so, due to IN, this determines the value of t1.pk (t1 is the top +# query's table). +# - so t1.pk is constant, so all columns of t1 are constant. +# Which proves that it makes sense to search FDs in semijoin +# equalities. +# In other words: a semijoin is like a join except that it eliminates +# duplicates, but duplicates are irrelevant to the decision whether a +# column is functionally dependent on a set of columns. +SELECT c5 AS field1, +c4 AS field2, +c2 AS field3, +c1 AS field4 +FROM t1 +WHERE ( c2, c2, pk ) IN ( +SELECT * FROM v1 +) +GROUP BY field1, field3, field3; +field1 field2 field3 field4 +# +# Bug#19687724 FUNCTIONAL DEPENDENCIES ARE NOT RECOGNIZED IN EQUALITIES BETWEEN ROWS +# +# Inspired by query above, but with a join: +SELECT c5 AS field1, +c4 AS field2, +c2 AS field3, +c1 AS field4 +FROM t1, v1 +WHERE ( c2, c2, pk ) = (subfield11, subfield12, subfield13) +GROUP BY field1, field3, field3; +field1 field2 field3 field4 +# With constants: +SELECT c5 AS field1, +c4 AS field2, +c2 AS field3, +c1 AS field4 +FROM t1 +WHERE ( c2, c2, pk ) = (1, 2, 3) +GROUP BY field1, field3, field3; +field1 field2 field3 field4 +DROP TABLE t1; +CREATE TABLE t1(a INT, b INT, c INT, d INT); +SELECT a,b,c,d FROM t1 WHERE a=c AND b=d GROUP by a,b; +a b c d +SELECT a,b,c,d FROM t1 WHERE (a,b)=(c,d) GROUP BY a,b; +a b c d +SELECT a,b,c,d FROM t1 WHERE (a,b)=(c,d+1) GROUP BY a,b; +ERROR 42000: Expression #4 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'test.t1.d' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +DROP TABLE t1; +DROP VIEW v1; +# +# Bug #20031708 ASSERT ON GROUP_CHECK::IS_FD_ON_SOURCE +# +CREATE TABLE t1 ( +col_varchar_10_utf8 VARCHAR(10) CHARACTER SET utf8, +col_int_key INT, +pk INT PRIMARY KEY +); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +CREATE TABLE t2 ( +col_varchar_10_utf8 VARCHAR(10) CHARACTER SET utf8 DEFAULT NULL, +col_int_key INT DEFAULT NULL, +pk INT PRIMARY KEY +); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +CREATE VIEW v2 AS SELECT * FROM t2; +# The reporter's testcase: +SELECT COUNT(*), t1.col_int_key +FROM v2 LEFT OUTER JOIN t1 +ON v2.col_varchar_10_utf8 = t1.col_varchar_10_utf8 +WHERE v2.pk = 4; +ERROR 42000: In aggregated query without GROUP BY, expression #2 of SELECT list contains nonaggregated column 'test.t1.col_int_key'; this is incompatible with sql_mode=only_full_group_by +DROP VIEW v2; +# A variant: one column is an expression: +CREATE VIEW v2 AS SELECT +CONCAT(col_varchar_10_utf8,' ') AS col_varchar_10_utf8, +col_int_key, +pk +FROM t2; +SELECT COUNT(*), t1.col_int_key +FROM v2 LEFT OUTER JOIN t1 +ON v2.col_varchar_10_utf8 = t1.col_varchar_10_utf8 +WHERE v2.pk = 4; +ERROR 42000: In aggregated query without GROUP BY, expression #2 of SELECT list contains nonaggregated column 'test.t1.col_int_key'; this is incompatible with sql_mode=only_full_group_by +DROP VIEW v2; +# Query used in the commit comment: view column involving two tables +CREATE VIEW v2 AS +SELECT t1.pk, t2.col_int_key+1 as c, t1.pk+t2.col_int_key as p +FROM t1, t2; +# FDs will be discovered in this order: {}->v2.pk, v2.pk->v2.c, +# v2.c->v2.p +SELECT COUNT(*), v2.p +FROM v2 +WHERE v2.c=v2.p and v2.c=v2.pk AND v2.pk = 4; +COUNT(*) p +0 NULL +DROP VIEW v2; +# If in the query specification defining a view, a base table's pk is +# determined, +# and the view's column is a function of this base table's columns, +# then the view's column is also determined. +# So, in this view's result, {v2.pk}->{v2.coa}: +CREATE ALGORITHM=MERGE VIEW v2 AS +SELECT t2.pk, COALESCE(t2.pk, 3) AS coa +FROM t1 LEFT JOIN t2 ON 0; +# And thus {pk}->{coa} holds in the result of this query using the view; +# if there is NULL-complementing in the LEFT JOIN below then (pk,coa) +# will be (NULL,NULL) and if there is not it will be (non-NULL,3): +# v2.coa is determined by v2.pk. The key fact is that v2.pk is not +# NULLable so this is a NFFD. +SELECT v2.pk, v2.coa +FROM t1 LEFT JOIN v2 AS v2 ON 0 +GROUP BY v2.pk; +pk coa +DROP VIEW v2; +DROP TABLE t1,t2; +# +# Bug#21807579 FUNCTIONAL DEPENDENCIES ARE NOT RECOGNIZED IN GENERATED COLUMNS +# +CREATE TABLE t ( a INT, c INT GENERATED ALWAYS AS (a+2), d INT GENERATED ALWAYS AS (c+2) ); +# {a}->{c}, {c}->{d} and {a}->{d} hold. +SELECT c FROM t GROUP BY a; +c +SELECT d FROM t GROUP BY c; +d +SELECT d FROM t GROUP BY a; +d +SELECT 1+c FROM t GROUP BY a; +1+c +SELECT 1+d FROM t GROUP BY c; +1+d +SELECT 1+d FROM t GROUP BY a; +1+d +# {t2.a}->{t2.d}->{t1.c}->{t1.d} +SELECT t1.d FROM t as t1, t as t2 WHERE t2.d=t1.c GROUP BY t2.a; +d +SELECT t1.d FROM t as t1, t as t2 WHERE t2.d>t1.c GROUP BY t2.a; +ERROR 42000: Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'test.t1.d' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +DROP TABLE t; +# A non-NULL-friendly dependency. +CREATE TABLE t ( a INT, +c INT GENERATED ALWAYS AS (COALESCE(a,3)) ); +INSERT INTO t (a) VALUES(NULL); +CREATE TABLE u ( a INT ); +INSERT INTO u VALUES(0),(1); +# Even though {a}->{c} holds in 't', it doesn't propagate to the left +# join's result +SELECT t.a,t.c FROM u LEFT JOIN t ON u.a>0; +a c +NULL 3 +NULL NULL +SELECT t.a,t.c FROM u LEFT JOIN t ON u.a>0 GROUP BY t.a; +ERROR 42000: Expression #2 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'test.t.c' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +DROP TABLE t,u; +# +# Bug #22924183 GROUP BY ON DERIVED TABLE, EXPRESSION OF AGGREGATE AND GROUP COLUMN: ERROR +# +CREATE TABLE coll ( +doc text +) ENGINE=InnoDB; +SELECT (je+1)+count(*) FROM (SELECT doc+1 AS je FROM coll) AS dt GROUP BY je; +(je+1)+count(*) +SELECT je+(1+count(*)) FROM (SELECT doc+1 AS je FROM coll) AS dt GROUP BY je; +je+(1+count(*)) +DROP TABLE coll; +# +# Bug#27114719 FUNCTIONAL DEPENDENCY CHECK FAILS ON FIRST CALL, SUCCEEDS ON NEXT +# +CREATE TABLE t ( a INT, c INT GENERATED ALWAYS AS (a+2), d INT GENERATED +ALWAYS AS (c+2) ); +SELECT t1.d FROM t as t1, t as t2 WHERE t2.d>t1.c GROUP BY t2.a; +ERROR 42000: Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'test.t1.d' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +SELECT t1.d FROM t as t1, t as t2 WHERE t2.d>t1.c GROUP BY t2.a; +ERROR 42000: Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'test.t1.d' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +FLUSH TABLES; +SELECT (SELECT t1.c FROM t as t1 GROUP BY -3) FROM t as t2; +ERROR 42000: Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'test.t1.c' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +SELECT DISTINCT t1.a FROM t as t1 ORDER BY t1.d LIMIT 1; +ERROR HY000: Expression #1 of ORDER BY clause is not in SELECT list, references column 'test.t1.d' which is not in SELECT list; this is incompatible with DISTINCT +SELECT (SELECT DISTINCT t1.a FROM t as t1 ORDER BY t1.d LIMIT 1) FROM t as t2; +ERROR HY000: Expression #1 of ORDER BY clause is not in SELECT list, references column 'test.t1.d' which is not in SELECT list; this is incompatible with DISTINCT +DROP TABLE t; +# +# Bug#22279903 ISSUE WITH ONLY_FULL_GROUP_BY AND UNIQUE KEY WITH NULL VALUES +# +CREATE TABLE t(a INT NULL, b INT NOT NULL, c INT, UNIQUE(a,b)); +INSERT INTO t VALUES (NULL, 1, 4); +INSERT INTO t VALUES (NULL, 1, 5); +SELECT a,b,c FROM t GROUP BY a,b; +ERROR 42000: Expression #3 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'test.t.c' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +SELECT a,b,c FROM t WHERE a IS NOT NULL GROUP BY a,b; +a b c +SELECT a,b,c FROM t WHERE NOT (a IS NULL) GROUP BY a,b; +a b c +SELECT a,b,c FROM t WHERE a > 3 GROUP BY a,b; +a b c +SELECT a,b,c FROM t WHERE a = 3 GROUP BY b; +a b c +SELECT a,b,c FROM t WHERE a BETWEEN 3 AND 6 GROUP BY a,b; +a b c +SELECT a,b,c FROM t WHERE a <> 3 GROUP BY a,b; +a b c +SELECT a,b,c FROM t WHERE a IN (3,4) GROUP BY a,b; +a b c +SELECT a,b,c FROM t WHERE a IN (SELECT b FROM t) GROUP BY a,b; +a b c +SELECT a,b,c FROM t WHERE a IS TRUE GROUP BY a,b; +a b c +SELECT a,b,c FROM t WHERE (a <> 3) IS TRUE GROUP BY a,b; +a b c +SELECT a,b,c FROM t WHERE a IS FALSE GROUP BY a,b; +a b c +SELECT a,b,c FROM t WHERE (a <> 3) IS FALSE GROUP BY a,b; +a b c +SELECT a,b,c FROM t WHERE NOT(a IN (3,4)) GROUP BY a,b; +a b c +SELECT a,b,c FROM t WHERE a NOT IN (3,4) GROUP BY a,b; +a b c +SELECT a,b,c FROM t WHERE a LIKE "%abc%" GROUP BY a,b; +a b c +SELECT a,b,c FROM t WHERE a NOT LIKE "%abc%" GROUP BY a,b; +a b c +SELECT a,b,c FROM t WHERE a IS TRUE GROUP BY b; +ERROR 42000: Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'test.t.a' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +SELECT a,b,c FROM t WHERE a<=>NULL GROUP BY b; +ERROR 42000: Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'test.t.a' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +SELECT a,b,c FROM t WHERE a IS NOT TRUE GROUP BY a,b; +ERROR 42000: Expression #3 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'test.t.c' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +SELECT a,b,c FROM +(SELECT * FROM t WHERE a IS NOT NULL) AS dt GROUP BY a,b; +a b c +SELECT /*+ NO_MERGE() */ a,b,c FROM +(SELECT * FROM t WHERE a IS NOT NULL) AS dt GROUP BY a,b; +a b c +SELECT show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +"functional_dependencies_of_GROUP_columns": { + "columns": [ + "dt.a", + "dt.b", + "dt.c" + ] /* columns */, + "searched_in_materialized_tables": [ + { + "table": " `dt`", + "all_columns_of_table_map_bits": [ + 0 + ] /* all_columns_of_table_map_bits */, + "columns": [ + "test.t.a", + "test.t.b" + ] /* columns */ + } + ] /* searched_in_materialized_tables */ + } +SELECT a,b,c FROM t WHERE a IS NULL GROUP BY a,b; +ERROR 42000: Expression #3 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'test.t.c' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +SELECT a,b,c FROM t WHERE NOT(a IS NOT NULL) GROUP BY a,b; +ERROR 42000: Expression #3 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'test.t.c' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +SELECT t.* FROM t LEFT JOIN t AS t1 ON t.a IS NOT NULL +GROUP BY t.a,t.b; +ERROR 42000: Expression #3 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'test.t.c' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +SELECT t.* FROM t RIGHT JOIN t AS t1 ON t.a IS NOT NULL +GROUP BY t.a,t.b; +a b c +NULL NULL NULL +DROP TABLE t; +CREATE TABLE t1 (a INT, b INT); +CREATE TABLE t2 (b INT); +CREATE TABLE t3 ( +b INT NULL, +c INT NULL, +d INT NULL, +e INT NULL, +UNIQUE KEY (b,d,e)); +SELECT * FROM t1, t2, t3 +WHERE t2.b = t1.b AND t2.b = t3.b +AND t3.d = 1 AND t3.e = 1 AND t3.d IS NOT NULL AND t1.a = 2 +GROUP BY t1.b; +a b b b c d e +SELECT * FROM t1, t2, t3 +WHERE t2.b = t1.b AND t2.b = t3.b +AND t3.d = 1 AND t3.e = 1 AND t1.a = 2 +GROUP BY t1.b; +a b b b c d e +SELECT show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +"functional_dependencies_of_GROUP_columns": { + "all_columns_of_table_map_bits": [ + 2 + ] /* all_columns_of_table_map_bits */, + "columns": [ + "test.t1.b", + "test.t2.b", + "test.t3.b", + "test.t3.d", + "test.t3.e", + "test.t1.a" + ] /* columns */ + } +SELECT * FROM t1, t2, t3 +WHERE t2.b = t1.b AND t2.b = t3.b +AND t3.e = 1 AND t3.d IS NOT NULL AND t1.a = 2 +GROUP BY t1.b; +ERROR 42000: Expression #5 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'test.t3.c' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +# Verify that for semijoin and antijoin we catch the FD issues. +explain select (select 2 from t2 where 1=(select t1.b from t3)) as col from t1 group by t1.a; +ERROR 42000: Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'test.t1.b' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +explain select (select 2 from t2 where exists(select t1.b from t3)) as col from t1 group by t1.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using temporary +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 DEPENDENT SUBQUERY t3 NULL index NULL b 15 NULL 1 100.00 Using index; FirstMatch(t2); Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.b' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select (/* select#2 */ select 2 from `test`.`t2` semi join (`test`.`t3`) where true) AS `col` from `test`.`t1` group by `test`.`t1`.`a` +explain select (select 2 from t2 where not exists(select t1.b from t3)) as col from t1 group by t1.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using temporary +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 DEPENDENT SUBQUERY t3 NULL index NULL b 15 NULL 1 100.00 Using where; Not exists; Using index; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.b' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select (/* select#2 */ select 2 from `test`.`t2` anti join (`test`.`t3`) on((1 = 1)) where true) AS `col` from `test`.`t1` group by `test`.`t1`.`a` +explain select (select 2 from t2 where exists(select 1 from t3 where t1.b)) as col from t1 group by t1.a; +ERROR 42000: Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'test.t1.b' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +explain select (select 2 from t2 where not exists(select 1 from t3 where t1.b)) as col from t1 group by t1.a; +ERROR 42000: Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'test.t1.b' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +explain select (select 2 from t2 where 1 in(select t1.b from t3)) as col from t1 group by t1.a; +ERROR 42000: Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'test.t1.b' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +alter table t1 modify b int not null; +explain select (select 2 from t2 where 1 not in(select t1.b from t3)) as col from t1 group by t1.a; +ERROR 42000: Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'test.t1.b' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +explain select (select 2 from t2 where 1 in(select 1 from t3 where t1.b)) as col from t1 group by t1.a; +ERROR 42000: Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'test.t1.b' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +explain select (select 2 from t2 where 1 not in(select 1 from t3 where t1.b)) as col from t1 group by t1.a; +ERROR 42000: Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'test.t1.b' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +DROP TABLE t1, t2, t3; +DROP FUNCTION show_json_object; +# +# Bug#29006668 UNEXPECTED ERROR: "ORDER BY CLAUSE IS NOT IN GROUP BY CLAUSE" WITH ROLLUP +# +CREATE TABLE t(i INT); +INSERT INTO t VALUES (-1),(2),(1); +SELECT ABS(i) AS a FROM t GROUP BY abs(i) ORDER BY a + 1; +a +1 +2 +SELECT ABS(i) AS a FROM t GROUP BY abs(i) WITH ROLLUP ORDER BY a + 1; +a +NULL +1 +2 +SELECT ABS(i) AS a FROM t GROUP BY a ORDER BY a + 1; +a +1 +2 +SELECT ABS(i) AS a FROM t GROUP BY a WITH ROLLUP ORDER BY a + 1; +a +NULL +1 +2 +DROP TABLE t; +# +# Bug#30753524 DBUG_ASSERT((MAP_OF_NEW_FDS & PSEUDO_TABLE_BITS) == 0) +# +CREATE TABLE t (a INT,b INT); +SELECT 1 FROM t AS ot +WHERE 1 <= +( +SELECT it2.a +FROM +( +SELECT ot.b FROM t AS it1 +) AS dt +JOIN t AS it2 ON dt.b=it2.b +GROUP BY it2.b +) +; +ERROR 42000: Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'test.it2.a' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +SELECT 1 FROM t AS ot +WHERE 1 <= +( +SELECT dt.b +FROM +( +SELECT ot.b FROM t AS it1 +) AS dt +JOIN t AS it2 ON dt.b=it2.b +GROUP BY it2.b +) +; +1 +DROP TABLE t; diff --git a/mysql-test/r/group_min_max.result-pq b/mysql-test/r/group_min_max.result-pq new file mode 100644 index 000000000000..e927c86ec8fe --- /dev/null +++ b/mysql-test/r/group_min_max.result-pq @@ -0,0 +1,4501 @@ +drop table if exists t1; +create table t1 ( +a1 char(64), a2 char(64), b char(16), c char(16) not null, d char(16), dummy char(248) default ' ' +) charset latin1; +insert into t1 (a1, a2, b, c, d) values +('a','a','a','a111','xy1'),('a','a','a','b111','xy2'),('a','a','a','c111','xy3'),('a','a','a','d111','xy4'), +('a','a','b','e112','xy1'),('a','a','b','f112','xy2'),('a','a','b','g112','xy3'),('a','a','b','h112','xy4'), +('a','b','a','i121','xy1'),('a','b','a','j121','xy2'),('a','b','a','k121','xy3'),('a','b','a','l121','xy4'), +('a','b','b','m122','xy1'),('a','b','b','n122','xy2'),('a','b','b','o122','xy3'),('a','b','b','p122','xy4'), +('b','a','a','a211','xy1'),('b','a','a','b211','xy2'),('b','a','a','c211','xy3'),('b','a','a','d211','xy4'), +('b','a','b','e212','xy1'),('b','a','b','f212','xy2'),('b','a','b','g212','xy3'),('b','a','b','h212','xy4'), +('b','b','a','i221','xy1'),('b','b','a','j221','xy2'),('b','b','a','k221','xy3'),('b','b','a','l221','xy4'), +('b','b','b','m222','xy1'),('b','b','b','n222','xy2'),('b','b','b','o222','xy3'),('b','b','b','p222','xy4'), +('c','a','a','a311','xy1'),('c','a','a','b311','xy2'),('c','a','a','c311','xy3'),('c','a','a','d311','xy4'), +('c','a','b','e312','xy1'),('c','a','b','f312','xy2'),('c','a','b','g312','xy3'),('c','a','b','h312','xy4'), +('c','b','a','i321','xy1'),('c','b','a','j321','xy2'),('c','b','a','k321','xy3'),('c','b','a','l321','xy4'), +('c','b','b','m322','xy1'),('c','b','b','n322','xy2'),('c','b','b','o322','xy3'),('c','b','b','p322','xy4'), +('d','a','a','a411','xy1'),('d','a','a','b411','xy2'),('d','a','a','c411','xy3'),('d','a','a','d411','xy4'), +('d','a','b','e412','xy1'),('d','a','b','f412','xy2'),('d','a','b','g412','xy3'),('d','a','b','h412','xy4'), +('d','b','a','i421','xy1'),('d','b','a','j421','xy2'),('d','b','a','k421','xy3'),('d','b','a','l421','xy4'), +('d','b','b','m422','xy1'),('d','b','b','n422','xy2'),('d','b','b','o422','xy3'),('d','b','b','p422','xy4'), +('a','a','a','a111','xy1'),('a','a','a','b111','xy2'),('a','a','a','c111','xy3'),('a','a','a','d111','xy4'), +('a','a','b','e112','xy1'),('a','a','b','f112','xy2'),('a','a','b','g112','xy3'),('a','a','b','h112','xy4'), +('a','b','a','i121','xy1'),('a','b','a','j121','xy2'),('a','b','a','k121','xy3'),('a','b','a','l121','xy4'), +('a','b','b','m122','xy1'),('a','b','b','n122','xy2'),('a','b','b','o122','xy3'),('a','b','b','p122','xy4'), +('b','a','a','a211','xy1'),('b','a','a','b211','xy2'),('b','a','a','c211','xy3'),('b','a','a','d211','xy4'), +('b','a','b','e212','xy1'),('b','a','b','f212','xy2'),('b','a','b','g212','xy3'),('b','a','b','h212','xy4'), +('b','b','a','i221','xy1'),('b','b','a','j221','xy2'),('b','b','a','k221','xy3'),('b','b','a','l221','xy4'), +('b','b','b','m222','xy1'),('b','b','b','n222','xy2'),('b','b','b','o222','xy3'),('b','b','b','p222','xy4'), +('c','a','a','a311','xy1'),('c','a','a','b311','xy2'),('c','a','a','c311','xy3'),('c','a','a','d311','xy4'), +('c','a','b','e312','xy1'),('c','a','b','f312','xy2'),('c','a','b','g312','xy3'),('c','a','b','h312','xy4'), +('c','b','a','i321','xy1'),('c','b','a','j321','xy2'),('c','b','a','k321','xy3'),('c','b','a','l321','xy4'), +('c','b','b','m322','xy1'),('c','b','b','n322','xy2'),('c','b','b','o322','xy3'),('c','b','b','p322','xy4'), +('d','a','a','a411','xy1'),('d','a','a','b411','xy2'),('d','a','a','c411','xy3'),('d','a','a','d411','xy4'), +('d','a','b','e412','xy1'),('d','a','b','f412','xy2'),('d','a','b','g412','xy3'),('d','a','b','h412','xy4'), +('d','b','a','i421','xy1'),('d','b','a','j421','xy2'),('d','b','a','k421','xy3'),('d','b','a','l421','xy4'), +('d','b','b','m422','xy1'),('d','b','b','n422','xy2'),('d','b','b','o422','xy3'),('d','b','b','p422','xy4'); +create index idx_t1_0 on t1 (a1); +create index idx_t1_1 on t1 (a1,a2,b,c); +create index idx_t1_2 on t1 (a1,a2,b); +analyze table t1; +Table Op Msg_type Msg_text +test.t1 analyze status Table is already up to date +drop table if exists t2; +create table t2 ( +a1 char(64), a2 char(64) not null, b char(16), c char(16), d char(16), dummy char(248) default ' ' +) charset latin1; +insert into t2 select * from t1; +insert into t2 (a1, a2, b, c, d) values +('a','a',NULL,'a777','xyz'),('a','a',NULL,'a888','xyz'),('a','a',NULL,'a999','xyz'), +('a','a','a',NULL,'xyz'), +('a','a','b',NULL,'xyz'), +('a','b','a',NULL,'xyz'), +('c','a',NULL,'c777','xyz'),('c','a',NULL,'c888','xyz'),('c','a',NULL,'c999','xyz'), +('d','b','b',NULL,'xyz'), +('e','a','a',NULL,'xyz'),('e','a','a',NULL,'xyz'),('e','a','a',NULL,'xyz'),('e','a','a',NULL,'xyz'), +('e','a','b',NULL,'xyz'),('e','a','b',NULL,'xyz'),('e','a','b',NULL,'xyz'),('e','a','b',NULL,'xyz'), +('a','a',NULL,'a777','xyz'),('a','a',NULL,'a888','xyz'),('a','a',NULL,'a999','xyz'), +('a','a','a',NULL,'xyz'), +('a','a','b',NULL,'xyz'), +('a','b','a',NULL,'xyz'), +('c','a',NULL,'c777','xyz'),('c','a',NULL,'c888','xyz'),('c','a',NULL,'c999','xyz'), +('d','b','b',NULL,'xyz'), +('e','a','a',NULL,'xyz'),('e','a','a',NULL,'xyz'),('e','a','a',NULL,'xyz'),('e','a','a',NULL,'xyz'), +('e','a','b',NULL,'xyz'),('e','a','b',NULL,'xyz'),('e','a','b',NULL,'xyz'),('e','a','b',NULL,'xyz'); +create index idx_t2_0 on t2 (a1); +create index idx_t2_1 on t2 (a1,a2,b,c); +create index idx_t2_2 on t2 (a1,a2,b); +analyze table t2; +Table Op Msg_type Msg_text +test.t2 analyze status Table is already up to date +drop table if exists t3; +create table t3 ( +a1 char(1), a2 char(1), b char(1), c char(4) not null, d char(3), dummy char(1) default ' ' +) charset latin1; +insert into t3 (a1, a2, b, c, d) values +('a','a','a','a111','xy1'),('a','a','a','b111','xy2'),('a','a','a','c111','xy3'),('a','a','a','d111','xy4'), +('a','a','b','e112','xy1'),('a','a','b','f112','xy2'),('a','a','b','g112','xy3'),('a','a','b','h112','xy4'), +('a','b','a','i121','xy1'),('a','b','a','j121','xy2'),('a','b','a','k121','xy3'),('a','b','a','l121','xy4'), +('a','b','b','m122','xy1'),('a','b','b','n122','xy2'),('a','b','b','o122','xy3'),('a','b','b','p122','xy4'), +('b','a','a','a211','xy1'),('b','a','a','b211','xy2'),('b','a','a','c211','xy3'),('b','a','a','d211','xy4'), +('b','a','b','e212','xy1'),('b','a','b','f212','xy2'),('b','a','b','g212','xy3'),('b','a','b','h212','xy4'), +('b','b','a','i221','xy1'),('b','b','a','j221','xy2'),('b','b','a','k221','xy3'),('b','b','a','l221','xy4'), +('b','b','b','m222','xy1'),('b','b','b','n222','xy2'),('b','b','b','o222','xy3'),('b','b','b','p222','xy4'), +('c','a','a','a311','xy1'),('c','a','a','b311','xy2'),('c','a','a','c311','xy3'),('c','a','a','d311','xy4'), +('c','a','b','e312','xy1'),('c','a','b','f312','xy2'),('c','a','b','g312','xy3'),('c','a','b','h312','xy4'), +('c','b','a','i321','xy1'),('c','b','a','j321','xy2'),('c','b','a','k321','xy3'),('c','b','a','l321','xy4'), +('c','b','b','m322','xy1'),('c','b','b','n322','xy2'),('c','b','b','o322','xy3'),('c','b','b','p322','xy4'); +insert into t3 (a1, a2, b, c, d) values +('a','a','a','a111','xy1'),('a','a','a','b111','xy2'),('a','a','a','c111','xy3'),('a','a','a','d111','xy4'), +('a','a','b','e112','xy1'),('a','a','b','f112','xy2'),('a','a','b','g112','xy3'),('a','a','b','h112','xy4'), +('a','b','a','i121','xy1'),('a','b','a','j121','xy2'),('a','b','a','k121','xy3'),('a','b','a','l121','xy4'), +('a','b','b','m122','xy1'),('a','b','b','n122','xy2'),('a','b','b','o122','xy3'),('a','b','b','p122','xy4'), +('b','a','a','a211','xy1'),('b','a','a','b211','xy2'),('b','a','a','c211','xy3'),('b','a','a','d211','xy4'), +('b','a','b','e212','xy1'),('b','a','b','f212','xy2'),('b','a','b','g212','xy3'),('b','a','b','h212','xy4'), +('b','b','a','i221','xy1'),('b','b','a','j221','xy2'),('b','b','a','k221','xy3'),('b','b','a','l221','xy4'), +('b','b','b','m222','xy1'),('b','b','b','n222','xy2'),('b','b','b','o222','xy3'),('b','b','b','p222','xy4'), +('c','a','a','a311','xy1'),('c','a','a','b311','xy2'),('c','a','a','c311','xy3'),('c','a','a','d311','xy4'), +('c','a','b','e312','xy1'),('c','a','b','f312','xy2'),('c','a','b','g312','xy3'),('c','a','b','h312','xy4'), +('c','b','a','i321','xy1'),('c','b','a','j321','xy2'),('c','b','a','k321','xy3'),('c','b','a','l321','xy4'), +('c','b','b','m322','xy1'),('c','b','b','n322','xy2'),('c','b','b','o322','xy3'),('c','b','b','p322','xy4'); +insert into t3 (a1, a2, b, c, d) values +('a','a','a','a111','xy1'),('a','a','a','b111','xy2'),('a','a','a','c111','xy3'),('a','a','a','d111','xy4'), +('a','a','b','e112','xy1'),('a','a','b','f112','xy2'),('a','a','b','g112','xy3'),('a','a','b','h112','xy4'), +('a','b','a','i121','xy1'),('a','b','a','j121','xy2'),('a','b','a','k121','xy3'),('a','b','a','l121','xy4'), +('a','b','b','m122','xy1'),('a','b','b','n122','xy2'),('a','b','b','o122','xy3'),('a','b','b','p122','xy4'), +('b','a','a','a211','xy1'),('b','a','a','b211','xy2'),('b','a','a','c211','xy3'),('b','a','a','d211','xy4'), +('b','a','b','e212','xy1'),('b','a','b','f212','xy2'),('b','a','b','g212','xy3'),('b','a','b','h212','xy4'), +('b','b','a','i221','xy1'),('b','b','a','j221','xy2'),('b','b','a','k221','xy3'),('b','b','a','l221','xy4'), +('b','b','b','m222','xy1'),('b','b','b','n222','xy2'),('b','b','b','o222','xy3'),('b','b','b','p222','xy4'), +('c','a','a','a311','xy1'),('c','a','a','b311','xy2'),('c','a','a','c311','xy3'),('c','a','a','d311','xy4'), +('c','a','b','e312','xy1'),('c','a','b','f312','xy2'),('c','a','b','g312','xy3'),('c','a','b','h312','xy4'), +('c','b','a','i321','xy1'),('c','b','a','j321','xy2'),('c','b','a','k321','xy3'),('c','b','a','l321','xy4'), +('c','b','b','m322','xy1'),('c','b','b','n322','xy2'),('c','b','b','o322','xy3'),('c','b','b','p322','xy4'); +insert into t3 (a1, a2, b, c, d) values +('a','a','a','a111','xy1'),('a','a','a','b111','xy2'),('a','a','a','c111','xy3'),('a','a','a','d111','xy4'), +('a','a','b','e112','xy1'),('a','a','b','f112','xy2'),('a','a','b','g112','xy3'),('a','a','b','h112','xy4'), +('a','b','a','i121','xy1'),('a','b','a','j121','xy2'),('a','b','a','k121','xy3'),('a','b','a','l121','xy4'), +('a','b','b','m122','xy1'),('a','b','b','n122','xy2'),('a','b','b','o122','xy3'),('a','b','b','p122','xy4'), +('b','a','a','a211','xy1'),('b','a','a','b211','xy2'),('b','a','a','c211','xy3'),('b','a','a','d211','xy4'), +('b','a','b','e212','xy1'),('b','a','b','f212','xy2'),('b','a','b','g212','xy3'),('b','a','b','h212','xy4'), +('b','b','a','i221','xy1'),('b','b','a','j221','xy2'),('b','b','a','k221','xy3'),('b','b','a','l221','xy4'), +('b','b','b','m222','xy1'),('b','b','b','n222','xy2'),('b','b','b','o222','xy3'),('b','b','b','p222','xy4'), +('c','a','a','a311','xy1'),('c','a','a','b311','xy2'),('c','a','a','c311','xy3'),('c','a','a','d311','xy4'), +('c','a','b','e312','xy1'),('c','a','b','f312','xy2'),('c','a','b','g312','xy3'),('c','a','b','h312','xy4'), +('c','b','a','i321','xy1'),('c','b','a','j321','xy2'),('c','b','a','k321','xy3'),('c','b','a','l321','xy4'), +('c','b','b','m322','xy1'),('c','b','b','n322','xy2'),('c','b','b','o322','xy3'),('c','b','b','p322','xy4'); +create index idx_t3_0 on t3 (a1); +create index idx_t3_1 on t3 (a1,a2,b,c); +create index idx_t3_2 on t3 (a1,a2,b); +analyze table t3; +Table Op Msg_type Msg_text +test.t3 analyze status Table is already up to date +explain select a1, min(a2) from t1 group by a1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 130 NULL 5 100.00 Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,min(`test`.`t1`.`a2`) AS `min(a2)` from `test`.`t1` group by `test`.`t1`.`a1` +explain format=tree select a1, min(a2) from t1 group by a1; +EXPLAIN +-> Index range scan on t1 using index_for_group_by(idx_t1_1) (cost=3.25 rows=5) + +explain select a1, max(a2) from t1 group by a1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 65 NULL 5 100.00 Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,max(`test`.`t1`.`a2`) AS `max(a2)` from `test`.`t1` group by `test`.`t1`.`a1` +explain select a1, min(a2), max(a2) from t1 group by a1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 130 NULL 5 100.00 Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,min(`test`.`t1`.`a2`) AS `min(a2)`,max(`test`.`t1`.`a2`) AS `max(a2)` from `test`.`t1` group by `test`.`t1`.`a1` +explain select a1, a2, b, min(c), max(c) from t1 group by a1,a2,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 17 100.00 Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,`test`.`t1`.`b` AS `b`,min(`test`.`t1`.`c`) AS `min(c)`,max(`test`.`t1`.`c`) AS `max(c)` from `test`.`t1` group by `test`.`t1`.`a1`,`test`.`t1`.`a2`,`test`.`t1`.`b` +explain select a1,a2,b,max(c),min(c) from t1 group by a1,a2,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 17 100.00 Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,`test`.`t1`.`b` AS `b`,max(`test`.`t1`.`c`) AS `max(c)`,min(`test`.`t1`.`c`) AS `min(c)` from `test`.`t1` group by `test`.`t1`.`a1`,`test`.`t1`.`a2`,`test`.`t1`.`b` +explain select a1,a2,b,max(c),min(c) from t2 group by a1,a2,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range idx_t2_1,idx_t2_2 idx_t2_1 # NULL # 100.00 Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a1` AS `a1`,`test`.`t2`.`a2` AS `a2`,`test`.`t2`.`b` AS `b`,max(`test`.`t2`.`c`) AS `max(c)`,min(`test`.`t2`.`c`) AS `min(c)` from `test`.`t2` group by `test`.`t2`.`a1`,`test`.`t2`.`a2`,`test`.`t2`.`b` +explain select min(a2), a1, max(a2), min(a2), a1 from t1 group by a1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 130 NULL 5 100.00 Using index for group-by +Warnings: +Note 1003 /* select#1 */ select min(`test`.`t1`.`a2`) AS `min(a2)`,`test`.`t1`.`a1` AS `a1`,max(`test`.`t1`.`a2`) AS `max(a2)`,min(`test`.`t1`.`a2`) AS `min(a2)`,`test`.`t1`.`a1` AS `a1` from `test`.`t1` group by `test`.`t1`.`a1` +explain select a1, b, min(c), a1, max(c), b, a2, max(c), max(c) from t1 group by a1, a2, b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 17 100.00 Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`b` AS `b`,min(`test`.`t1`.`c`) AS `min(c)`,`test`.`t1`.`a1` AS `a1`,max(`test`.`t1`.`c`) AS `max(c)`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`a2` AS `a2`,max(`test`.`t1`.`c`) AS `max(c)`,max(`test`.`t1`.`c`) AS `max(c)` from `test`.`t1` group by `test`.`t1`.`a1`,`test`.`t1`.`a2`,`test`.`t1`.`b` +explain select min(a2) from t1 group by a1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 130 NULL 5 100.00 Using index for group-by +Warnings: +Note 1003 /* select#1 */ select min(`test`.`t1`.`a2`) AS `min(a2)` from `test`.`t1` group by `test`.`t1`.`a1` +explain select a2, min(c), max(c) from t1 group by a1,a2,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 17 100.00 Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a2` AS `a2`,min(`test`.`t1`.`c`) AS `min(c)`,max(`test`.`t1`.`c`) AS `max(c)` from `test`.`t1` group by `test`.`t1`.`a1`,`test`.`t1`.`a2`,`test`.`t1`.`b` +select a1, min(a2) from t1 group by a1; +a1 min(a2) +a a +b a +c a +d a +select a1, max(a2) from t1 group by a1; +a1 max(a2) +a b +b b +c b +d b +select a1, min(a2), max(a2) from t1 group by a1; +a1 min(a2) max(a2) +a a b +b a b +c a b +d a b +select a1, a2, b, min(c), max(c) from t1 group by a1,a2,b; +a1 a2 b min(c) max(c) +a a a a111 d111 +a a b e112 h112 +a b a i121 l121 +a b b m122 p122 +b a a a211 d211 +b a b e212 h212 +b b a i221 l221 +b b b m222 p222 +c a a a311 d311 +c a b e312 h312 +c b a i321 l321 +c b b m322 p322 +d a a a411 d411 +d a b e412 h412 +d b a i421 l421 +d b b m422 p422 +select a1,a2,b,max(c),min(c) from t1 group by a1,a2,b; +a1 a2 b max(c) min(c) +a a a d111 a111 +a a b h112 e112 +a b a l121 i121 +a b b p122 m122 +b a a d211 a211 +b a b h212 e212 +b b a l221 i221 +b b b p222 m222 +c a a d311 a311 +c a b h312 e312 +c b a l321 i321 +c b b p322 m322 +d a a d411 a411 +d a b h412 e412 +d b a l421 i421 +d b b p422 m422 +select a1,a2,b,max(c),min(c) from t2 group by a1,a2,b; +a1 a2 b max(c) min(c) +a a NULL a999 a777 +a a a d111 a111 +a a b h112 e112 +a b a l121 i121 +a b b p122 m122 +b a a d211 a211 +b a b h212 e212 +b b a l221 i221 +b b b p222 m222 +c a NULL c999 c777 +c a a d311 a311 +c a b h312 e312 +c b a l321 i321 +c b b p322 m322 +d a a d411 a411 +d a b h412 e412 +d b a l421 i421 +d b b p422 m422 +e a a NULL NULL +e a b NULL NULL +select min(a2), a1, max(a2), min(a2), a1 from t1 group by a1; +min(a2) a1 max(a2) min(a2) a1 +a a b a a +a b b a b +a c b a c +a d b a d +select a1, b, min(c), a1, max(c), b, a2, max(c), max(c) from t1 group by a1, a2, b; +a1 b min(c) a1 max(c) b a2 max(c) max(c) +a a a111 a d111 a a d111 d111 +a b e112 a h112 b a h112 h112 +a a i121 a l121 a b l121 l121 +a b m122 a p122 b b p122 p122 +b a a211 b d211 a a d211 d211 +b b e212 b h212 b a h212 h212 +b a i221 b l221 a b l221 l221 +b b m222 b p222 b b p222 p222 +c a a311 c d311 a a d311 d311 +c b e312 c h312 b a h312 h312 +c a i321 c l321 a b l321 l321 +c b m322 c p322 b b p322 p322 +d a a411 d d411 a a d411 d411 +d b e412 d h412 b a h412 h412 +d a i421 d l421 a b l421 l421 +d b m422 d p422 b b p422 p422 +select min(a2) from t1 group by a1; +min(a2) +a +a +a +a +select a2, min(c), max(c) from t1 group by a1,a2,b; +a2 min(c) max(c) +a a111 d111 +a e112 h112 +b i121 l121 +b m122 p122 +a a211 d211 +a e212 h212 +b i221 l221 +b m222 p222 +a a311 d311 +a e312 h312 +b i321 l321 +b m322 p322 +a a411 d411 +a e412 h412 +b i421 l421 +b m422 p422 +explain select a1,a2,b,min(c),max(c) from t1 where a1 < 'd' group by a1,a2,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 10 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,`test`.`t1`.`b` AS `b`,min(`test`.`t1`.`c`) AS `min(c)`,max(`test`.`t1`.`c`) AS `max(c)` from `test`.`t1` where (`test`.`t1`.`a1` < 'd') group by `test`.`t1`.`a1`,`test`.`t1`.`a2`,`test`.`t1`.`b` +explain select a1,a2,b,min(c),max(c) from t1 where a1 >= 'b' group by a1,a2,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 14 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,`test`.`t1`.`b` AS `b`,min(`test`.`t1`.`c`) AS `min(c)`,max(`test`.`t1`.`c`) AS `max(c)` from `test`.`t1` where (`test`.`t1`.`a1` >= 'b') group by `test`.`t1`.`a1`,`test`.`t1`.`a2`,`test`.`t1`.`b` +explain select a1,a2,b, max(c) from t1 where a1 >= 'c' or a1 < 'b' group by a1,a2,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 14 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,`test`.`t1`.`b` AS `b`,max(`test`.`t1`.`c`) AS `max(c)` from `test`.`t1` where ((`test`.`t1`.`a1` >= 'c') or (`test`.`t1`.`a1` < 'b')) group by `test`.`t1`.`a1`,`test`.`t1`.`a2`,`test`.`t1`.`b` +explain select a1, max(c) from t1 where a1 >= 'c' or a1 < 'b' group by a1,a2,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 14 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,max(`test`.`t1`.`c`) AS `max(c)` from `test`.`t1` where ((`test`.`t1`.`a1` >= 'c') or (`test`.`t1`.`a1` < 'b')) group by `test`.`t1`.`a1`,`test`.`t1`.`a2`,`test`.`t1`.`b` +explain select a1,a2,b,min(c),max(c) from t1 where a1 >= 'c' or a2 < 'b' group by a1,a2,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 17 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,`test`.`t1`.`b` AS `b`,min(`test`.`t1`.`c`) AS `min(c)`,max(`test`.`t1`.`c`) AS `max(c)` from `test`.`t1` where ((`test`.`t1`.`a1` >= 'c') or (`test`.`t1`.`a2` < 'b')) group by `test`.`t1`.`a1`,`test`.`t1`.`a2`,`test`.`t1`.`b` +explain select a1,a2,b, max(c) from t1 where a1 = 'z' or a1 = 'b' or a1 = 'd' group by a1,a2,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 10 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,`test`.`t1`.`b` AS `b`,max(`test`.`t1`.`c`) AS `max(c)` from `test`.`t1` where ((`test`.`t1`.`a1` = 'z') or (`test`.`t1`.`a1` = 'b') or (`test`.`t1`.`a1` = 'd')) group by `test`.`t1`.`a1`,`test`.`t1`.`a2`,`test`.`t1`.`b` +explain select a1,a2,b,min(c),max(c) from t1 where a1 = 'z' or a1 = 'b' or a1 = 'd' group by a1,a2,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 10 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,`test`.`t1`.`b` AS `b`,min(`test`.`t1`.`c`) AS `min(c)`,max(`test`.`t1`.`c`) AS `max(c)` from `test`.`t1` where ((`test`.`t1`.`a1` = 'z') or (`test`.`t1`.`a1` = 'b') or (`test`.`t1`.`a1` = 'd')) group by `test`.`t1`.`a1`,`test`.`t1`.`a2`,`test`.`t1`.`b` +explain select a1,a2,b, max(c) from t1 where (a1 = 'b' or a1 = 'd' or a1 = 'a' or a1 = 'c') and (a2 > 'a') group by a1,a2,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 10 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,`test`.`t1`.`b` AS `b`,max(`test`.`t1`.`c`) AS `max(c)` from `test`.`t1` where (((`test`.`t1`.`a1` = 'b') or (`test`.`t1`.`a1` = 'd') or (`test`.`t1`.`a1` = 'a') or (`test`.`t1`.`a1` = 'c')) and (`test`.`t1`.`a2` > 'a')) group by `test`.`t1`.`a1`,`test`.`t1`.`a2`,`test`.`t1`.`b` +explain select a1,a2,b,min(c),max(c) from t1 where (a1 = 'b' or a1 = 'd' or a1 = 'a' or a1 = 'c') and (a2 > 'a') group by a1,a2,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 10 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,`test`.`t1`.`b` AS `b`,min(`test`.`t1`.`c`) AS `min(c)`,max(`test`.`t1`.`c`) AS `max(c)` from `test`.`t1` where (((`test`.`t1`.`a1` = 'b') or (`test`.`t1`.`a1` = 'd') or (`test`.`t1`.`a1` = 'a') or (`test`.`t1`.`a1` = 'c')) and (`test`.`t1`.`a2` > 'a')) group by `test`.`t1`.`a1`,`test`.`t1`.`a2`,`test`.`t1`.`b` +explain select a1,min(c),max(c) from t1 where a1 >= 'b' group by a1,a2,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 14 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,min(`test`.`t1`.`c`) AS `min(c)`,max(`test`.`t1`.`c`) AS `max(c)` from `test`.`t1` where (`test`.`t1`.`a1` >= 'b') group by `test`.`t1`.`a1`,`test`.`t1`.`a2`,`test`.`t1`.`b` +explain select a1, max(c) from t1 where a1 in ('a','b','d') group by a1,a2,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 14 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,max(`test`.`t1`.`c`) AS `max(c)` from `test`.`t1` where (`test`.`t1`.`a1` in ('a','b','d')) group by `test`.`t1`.`a1`,`test`.`t1`.`a2`,`test`.`t1`.`b` +explain select a1,a2,b, max(c) from t2 where a1 < 'd' group by a1,a2,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range idx_t2_0,idx_t2_1,idx_t2_2 idx_t2_1 146 NULL # 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a1` AS `a1`,`test`.`t2`.`a2` AS `a2`,`test`.`t2`.`b` AS `b`,max(`test`.`t2`.`c`) AS `max(c)` from `test`.`t2` where (`test`.`t2`.`a1` < 'd') group by `test`.`t2`.`a1`,`test`.`t2`.`a2`,`test`.`t2`.`b` +explain select a1,a2,b,min(c),max(c) from t2 where a1 < 'd' group by a1,a2,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range idx_t2_0,idx_t2_1,idx_t2_2 idx_t2_1 163 NULL # 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a1` AS `a1`,`test`.`t2`.`a2` AS `a2`,`test`.`t2`.`b` AS `b`,min(`test`.`t2`.`c`) AS `min(c)`,max(`test`.`t2`.`c`) AS `max(c)` from `test`.`t2` where (`test`.`t2`.`a1` < 'd') group by `test`.`t2`.`a1`,`test`.`t2`.`a2`,`test`.`t2`.`b` +explain select a1,a2,b,min(c),max(c) from t2 where a1 >= 'b' group by a1,a2,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range idx_t2_0,idx_t2_1,idx_t2_2 idx_t2_1 163 NULL # 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a1` AS `a1`,`test`.`t2`.`a2` AS `a2`,`test`.`t2`.`b` AS `b`,min(`test`.`t2`.`c`) AS `min(c)`,max(`test`.`t2`.`c`) AS `max(c)` from `test`.`t2` where (`test`.`t2`.`a1` >= 'b') group by `test`.`t2`.`a1`,`test`.`t2`.`a2`,`test`.`t2`.`b` +explain select a1,a2,b, max(c) from t2 where a1 >= 'c' or a1 < 'b' group by a1,a2,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range idx_t2_0,idx_t2_1,idx_t2_2 idx_t2_1 146 NULL # 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a1` AS `a1`,`test`.`t2`.`a2` AS `a2`,`test`.`t2`.`b` AS `b`,max(`test`.`t2`.`c`) AS `max(c)` from `test`.`t2` where ((`test`.`t2`.`a1` >= 'c') or (`test`.`t2`.`a1` < 'b')) group by `test`.`t2`.`a1`,`test`.`t2`.`a2`,`test`.`t2`.`b` +explain select a1, max(c) from t2 where a1 >= 'c' or a1 < 'b' group by a1,a2,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range idx_t2_0,idx_t2_1,idx_t2_2 idx_t2_1 146 NULL # 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a1` AS `a1`,max(`test`.`t2`.`c`) AS `max(c)` from `test`.`t2` where ((`test`.`t2`.`a1` >= 'c') or (`test`.`t2`.`a1` < 'b')) group by `test`.`t2`.`a1`,`test`.`t2`.`a2`,`test`.`t2`.`b` +explain select a1,a2,b,min(c),max(c) from t2 where a1 >= 'c' or a2 < 'b' group by a1,a2,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range idx_t2_0,idx_t2_1,idx_t2_2 idx_t2_1 163 NULL # 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a1` AS `a1`,`test`.`t2`.`a2` AS `a2`,`test`.`t2`.`b` AS `b`,min(`test`.`t2`.`c`) AS `min(c)`,max(`test`.`t2`.`c`) AS `max(c)` from `test`.`t2` where ((`test`.`t2`.`a1` >= 'c') or (`test`.`t2`.`a2` < 'b')) group by `test`.`t2`.`a1`,`test`.`t2`.`a2`,`test`.`t2`.`b` +explain select a1,a2,b, max(c) from t2 where a1 = 'z' or a1 = 'b' or a1 = 'd' group by a1,a2,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range idx_t2_0,idx_t2_1,idx_t2_2 idx_t2_1 146 NULL # 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a1` AS `a1`,`test`.`t2`.`a2` AS `a2`,`test`.`t2`.`b` AS `b`,max(`test`.`t2`.`c`) AS `max(c)` from `test`.`t2` where ((`test`.`t2`.`a1` = 'z') or (`test`.`t2`.`a1` = 'b') or (`test`.`t2`.`a1` = 'd')) group by `test`.`t2`.`a1`,`test`.`t2`.`a2`,`test`.`t2`.`b` +explain select a1,a2,b,min(c),max(c) from t2 where a1 = 'z' or a1 = 'b' or a1 = 'd' group by a1,a2,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range idx_t2_0,idx_t2_1,idx_t2_2 idx_t2_1 163 NULL # 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a1` AS `a1`,`test`.`t2`.`a2` AS `a2`,`test`.`t2`.`b` AS `b`,min(`test`.`t2`.`c`) AS `min(c)`,max(`test`.`t2`.`c`) AS `max(c)` from `test`.`t2` where ((`test`.`t2`.`a1` = 'z') or (`test`.`t2`.`a1` = 'b') or (`test`.`t2`.`a1` = 'd')) group by `test`.`t2`.`a1`,`test`.`t2`.`a2`,`test`.`t2`.`b` +explain select a1,a2,b, max(c) from t2 where (a1 = 'b' or a1 = 'd' or a1 = 'a' or a1 = 'c') and (a2 > 'a') group by a1,a2,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range idx_t2_0,idx_t2_1,idx_t2_2 idx_t2_1 146 NULL # 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a1` AS `a1`,`test`.`t2`.`a2` AS `a2`,`test`.`t2`.`b` AS `b`,max(`test`.`t2`.`c`) AS `max(c)` from `test`.`t2` where (((`test`.`t2`.`a1` = 'b') or (`test`.`t2`.`a1` = 'd') or (`test`.`t2`.`a1` = 'a') or (`test`.`t2`.`a1` = 'c')) and (`test`.`t2`.`a2` > 'a')) group by `test`.`t2`.`a1`,`test`.`t2`.`a2`,`test`.`t2`.`b` +explain select a1,a2,b,min(c),max(c) from t2 where (a1 = 'b' or a1 = 'd' or a1 = 'a' or a1 = 'c') and (a2 > 'a') group by a1,a2,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range idx_t2_0,idx_t2_1,idx_t2_2 idx_t2_1 163 NULL # 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a1` AS `a1`,`test`.`t2`.`a2` AS `a2`,`test`.`t2`.`b` AS `b`,min(`test`.`t2`.`c`) AS `min(c)`,max(`test`.`t2`.`c`) AS `max(c)` from `test`.`t2` where (((`test`.`t2`.`a1` = 'b') or (`test`.`t2`.`a1` = 'd') or (`test`.`t2`.`a1` = 'a') or (`test`.`t2`.`a1` = 'c')) and (`test`.`t2`.`a2` > 'a')) group by `test`.`t2`.`a1`,`test`.`t2`.`a2`,`test`.`t2`.`b` +explain select a1,min(c),max(c) from t2 where a1 >= 'b' group by a1,a2,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range idx_t2_0,idx_t2_1,idx_t2_2 idx_t2_1 163 NULL # 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a1` AS `a1`,min(`test`.`t2`.`c`) AS `min(c)`,max(`test`.`t2`.`c`) AS `max(c)` from `test`.`t2` where (`test`.`t2`.`a1` >= 'b') group by `test`.`t2`.`a1`,`test`.`t2`.`a2`,`test`.`t2`.`b` +explain select a1, max(c) from t2 where a1 in ('a','b','d') group by a1,a2,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range idx_t2_0,idx_t2_1,idx_t2_2 idx_t2_1 146 NULL # 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a1` AS `a1`,max(`test`.`t2`.`c`) AS `max(c)` from `test`.`t2` where (`test`.`t2`.`a1` in ('a','b','d')) group by `test`.`t2`.`a1`,`test`.`t2`.`a2`,`test`.`t2`.`b` +select a1,a2,b,min(c),max(c) from t1 where a1 < 'd' group by a1,a2,b; +a1 a2 b min(c) max(c) +a a a a111 d111 +a a b e112 h112 +a b a i121 l121 +a b b m122 p122 +b a a a211 d211 +b a b e212 h212 +b b a i221 l221 +b b b m222 p222 +c a a a311 d311 +c a b e312 h312 +c b a i321 l321 +c b b m322 p322 +select a1,a2,b,min(c),max(c) from t1 where a1 >= 'b' group by a1,a2,b; +a1 a2 b min(c) max(c) +b a a a211 d211 +b a b e212 h212 +b b a i221 l221 +b b b m222 p222 +c a a a311 d311 +c a b e312 h312 +c b a i321 l321 +c b b m322 p322 +d a a a411 d411 +d a b e412 h412 +d b a i421 l421 +d b b m422 p422 +select a1,a2,b, max(c) from t1 where a1 >= 'c' or a1 < 'b' group by a1,a2,b; +a1 a2 b max(c) +a a a d111 +a a b h112 +a b a l121 +a b b p122 +c a a d311 +c a b h312 +c b a l321 +c b b p322 +d a a d411 +d a b h412 +d b a l421 +d b b p422 +select a1, max(c) from t1 where a1 >= 'c' or a1 < 'b' group by a1,a2,b; +a1 max(c) +a d111 +a h112 +a l121 +a p122 +c d311 +c h312 +c l321 +c p322 +d d411 +d h412 +d l421 +d p422 +select a1,a2,b,min(c),max(c) from t1 where a1 >= 'c' or a2 < 'b' group by a1,a2,b; +a1 a2 b min(c) max(c) +a a a a111 d111 +a a b e112 h112 +b a a a211 d211 +b a b e212 h212 +c a a a311 d311 +c a b e312 h312 +c b a i321 l321 +c b b m322 p322 +d a a a411 d411 +d a b e412 h412 +d b a i421 l421 +d b b m422 p422 +select a1,a2,b, max(c) from t1 where a1 = 'z' or a1 = 'b' or a1 = 'd' group by a1,a2,b; +a1 a2 b max(c) +b a a d211 +b a b h212 +b b a l221 +b b b p222 +d a a d411 +d a b h412 +d b a l421 +d b b p422 +select a1,a2,b,min(c),max(c) from t1 where a1 = 'z' or a1 = 'b' or a1 = 'd' group by a1,a2,b; +a1 a2 b min(c) max(c) +b a a a211 d211 +b a b e212 h212 +b b a i221 l221 +b b b m222 p222 +d a a a411 d411 +d a b e412 h412 +d b a i421 l421 +d b b m422 p422 +select a1,a2,b, max(c) from t1 where (a1 = 'b' or a1 = 'd' or a1 = 'a' or a1 = 'c') and (a2 > 'a') group by a1,a2,b; +a1 a2 b max(c) +a b a l121 +a b b p122 +b b a l221 +b b b p222 +c b a l321 +c b b p322 +d b a l421 +d b b p422 +select a1,a2,b,min(c),max(c) from t1 where (a1 = 'b' or a1 = 'd' or a1 = 'a' or a1 = 'c') and (a2 > 'a') group by a1,a2,b; +a1 a2 b min(c) max(c) +a b a i121 l121 +a b b m122 p122 +b b a i221 l221 +b b b m222 p222 +c b a i321 l321 +c b b m322 p322 +d b a i421 l421 +d b b m422 p422 +select a1,min(c),max(c) from t1 where a1 >= 'b' group by a1,a2,b; +a1 min(c) max(c) +b a211 d211 +b e212 h212 +b i221 l221 +b m222 p222 +c a311 d311 +c e312 h312 +c i321 l321 +c m322 p322 +d a411 d411 +d e412 h412 +d i421 l421 +d m422 p422 +select a1, max(c) from t1 where a1 in ('a','b','d') group by a1,a2,b; +a1 max(c) +a d111 +a h112 +a l121 +a p122 +b d211 +b h212 +b l221 +b p222 +d d411 +d h412 +d l421 +d p422 +select a1,a2,b, max(c) from t2 where a1 < 'd' group by a1,a2,b; +a1 a2 b max(c) +a a NULL a999 +a a a d111 +a a b h112 +a b a l121 +a b b p122 +b a a d211 +b a b h212 +b b a l221 +b b b p222 +c a NULL c999 +c a a d311 +c a b h312 +c b a l321 +c b b p322 +select a1,a2,b,min(c),max(c) from t2 where a1 < 'd' group by a1,a2,b; +a1 a2 b min(c) max(c) +a a NULL a777 a999 +a a a a111 d111 +a a b e112 h112 +a b a i121 l121 +a b b m122 p122 +b a a a211 d211 +b a b e212 h212 +b b a i221 l221 +b b b m222 p222 +c a NULL c777 c999 +c a a a311 d311 +c a b e312 h312 +c b a i321 l321 +c b b m322 p322 +select a1,a2,b,min(c),max(c) from t2 where a1 >= 'b' group by a1,a2,b; +a1 a2 b min(c) max(c) +b a a a211 d211 +b a b e212 h212 +b b a i221 l221 +b b b m222 p222 +c a NULL c777 c999 +c a a a311 d311 +c a b e312 h312 +c b a i321 l321 +c b b m322 p322 +d a a a411 d411 +d a b e412 h412 +d b a i421 l421 +d b b m422 p422 +e a a NULL NULL +e a b NULL NULL +select a1,a2,b, max(c) from t2 where a1 >= 'c' or a1 < 'b' group by a1,a2,b; +a1 a2 b max(c) +a a NULL a999 +a a a d111 +a a b h112 +a b a l121 +a b b p122 +c a NULL c999 +c a a d311 +c a b h312 +c b a l321 +c b b p322 +d a a d411 +d a b h412 +d b a l421 +d b b p422 +e a a NULL +e a b NULL +select a1, max(c) from t2 where a1 >= 'c' or a1 < 'b' group by a1,a2,b; +a1 max(c) +a a999 +a d111 +a h112 +a l121 +a p122 +c c999 +c d311 +c h312 +c l321 +c p322 +d d411 +d h412 +d l421 +d p422 +e NULL +e NULL +select a1,a2,b,min(c),max(c) from t2 where a1 >= 'c' or a2 < 'b' group by a1,a2,b; +a1 a2 b min(c) max(c) +a a NULL a777 a999 +a a a a111 d111 +a a b e112 h112 +b a a a211 d211 +b a b e212 h212 +c a NULL c777 c999 +c a a a311 d311 +c a b e312 h312 +c b a i321 l321 +c b b m322 p322 +d a a a411 d411 +d a b e412 h412 +d b a i421 l421 +d b b m422 p422 +e a a NULL NULL +e a b NULL NULL +select a1,a2,b, max(c) from t2 where a1 = 'z' or a1 = 'b' or a1 = 'd' group by a1,a2,b; +a1 a2 b max(c) +b a a d211 +b a b h212 +b b a l221 +b b b p222 +d a a d411 +d a b h412 +d b a l421 +d b b p422 +select a1,a2,b,min(c),max(c) from t2 where a1 = 'z' or a1 = 'b' or a1 = 'd' group by a1,a2,b; +a1 a2 b min(c) max(c) +b a a a211 d211 +b a b e212 h212 +b b a i221 l221 +b b b m222 p222 +d a a a411 d411 +d a b e412 h412 +d b a i421 l421 +d b b m422 p422 +select a1,a2,b, max(c) from t2 where (a1 = 'b' or a1 = 'd' or a1 = 'a' or a1 = 'c') and (a2 > 'a') group by a1,a2,b; +a1 a2 b max(c) +a b a l121 +a b b p122 +b b a l221 +b b b p222 +c b a l321 +c b b p322 +d b a l421 +d b b p422 +select a1,a2,b,min(c),max(c) from t2 where (a1 = 'b' or a1 = 'd' or a1 = 'a' or a1 = 'c') and (a2 > 'a') group by a1,a2,b; +a1 a2 b min(c) max(c) +a b a i121 l121 +a b b m122 p122 +b b a i221 l221 +b b b m222 p222 +c b a i321 l321 +c b b m322 p322 +d b a i421 l421 +d b b m422 p422 +select a1,min(c),max(c) from t2 where a1 >= 'b' group by a1,a2,b; +a1 min(c) max(c) +b a211 d211 +b e212 h212 +b i221 l221 +b m222 p222 +c c777 c999 +c a311 d311 +c e312 h312 +c i321 l321 +c m322 p322 +d a411 d411 +d e412 h412 +d i421 l421 +d m422 p422 +e NULL NULL +e NULL NULL +select a1, max(c) from t2 where a1 in ('a','b','d') group by a1,a2,b; +a1 max(c) +a a999 +a d111 +a h112 +a l121 +a p122 +b d211 +b h212 +b l221 +b p222 +d d411 +d h412 +d l421 +d p422 +explain select a1,a2,b,max(c),min(c) from t1 where (a2 = 'a') and (b = 'b') group by a1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 5 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,`test`.`t1`.`b` AS `b`,max(`test`.`t1`.`c`) AS `max(c)`,min(`test`.`t1`.`c`) AS `min(c)` from `test`.`t1` where ((`test`.`t1`.`b` = 'b') and (`test`.`t1`.`a2` = 'a')) group by `test`.`t1`.`a1` +explain select a1,max(c),min(c) from t1 where (a2 = 'a') and (b = 'b') group by a1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 5 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,max(`test`.`t1`.`c`) AS `max(c)`,min(`test`.`t1`.`c`) AS `min(c)` from `test`.`t1` where ((`test`.`t1`.`b` = 'b') and (`test`.`t1`.`a2` = 'a')) group by `test`.`t1`.`a1` +explain select a1,a2,b, max(c) from t1 where (b = 'b') group by a1,a2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 9 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,`test`.`t1`.`b` AS `b`,max(`test`.`t1`.`c`) AS `max(c)` from `test`.`t1` where (`test`.`t1`.`b` = 'b') group by `test`.`t1`.`a1`,`test`.`t1`.`a2` +explain select a1,a2,b,min(c),max(c) from t1 where (b = 'b') group by a1,a2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 9 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,`test`.`t1`.`b` AS `b`,min(`test`.`t1`.`c`) AS `min(c)`,max(`test`.`t1`.`c`) AS `max(c)` from `test`.`t1` where (`test`.`t1`.`b` = 'b') group by `test`.`t1`.`a1`,`test`.`t1`.`a2` +explain select a1,a2, max(c) from t1 where (b = 'b') group by a1,a2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 9 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,max(`test`.`t1`.`c`) AS `max(c)` from `test`.`t1` where (`test`.`t1`.`b` = 'b') group by `test`.`t1`.`a1`,`test`.`t1`.`a2` +explain select a1,a2,b,max(c),min(c) from t2 where (a2 = 'a') and (b = 'b') group by a1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range idx_t2_0,idx_t2_1,idx_t2_2 idx_t2_1 163 NULL 5 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a1` AS `a1`,`test`.`t2`.`a2` AS `a2`,`test`.`t2`.`b` AS `b`,max(`test`.`t2`.`c`) AS `max(c)`,min(`test`.`t2`.`c`) AS `min(c)` from `test`.`t2` where ((`test`.`t2`.`b` = 'b') and (`test`.`t2`.`a2` = 'a')) group by `test`.`t2`.`a1` +explain select a1,max(c),min(c) from t2 where (a2 = 'a') and (b = 'b') group by a1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range idx_t2_0,idx_t2_1,idx_t2_2 idx_t2_1 163 NULL 5 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a1` AS `a1`,max(`test`.`t2`.`c`) AS `max(c)`,min(`test`.`t2`.`c`) AS `min(c)` from `test`.`t2` where ((`test`.`t2`.`b` = 'b') and (`test`.`t2`.`a2` = 'a')) group by `test`.`t2`.`a1` +explain select a1,a2,b, max(c) from t2 where (b = 'b') group by a1,a2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range idx_t2_1,idx_t2_2 idx_t2_1 146 NULL 10 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a1` AS `a1`,`test`.`t2`.`a2` AS `a2`,`test`.`t2`.`b` AS `b`,max(`test`.`t2`.`c`) AS `max(c)` from `test`.`t2` where (`test`.`t2`.`b` = 'b') group by `test`.`t2`.`a1`,`test`.`t2`.`a2` +explain select a1,a2,b,min(c),max(c) from t2 where (b = 'b') group by a1,a2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range idx_t2_1,idx_t2_2 idx_t2_1 163 NULL 10 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a1` AS `a1`,`test`.`t2`.`a2` AS `a2`,`test`.`t2`.`b` AS `b`,min(`test`.`t2`.`c`) AS `min(c)`,max(`test`.`t2`.`c`) AS `max(c)` from `test`.`t2` where (`test`.`t2`.`b` = 'b') group by `test`.`t2`.`a1`,`test`.`t2`.`a2` +explain select a1,a2, max(c) from t2 where (b = 'b') group by a1,a2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range idx_t2_1,idx_t2_2 idx_t2_1 146 NULL 10 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a1` AS `a1`,`test`.`t2`.`a2` AS `a2`,max(`test`.`t2`.`c`) AS `max(c)` from `test`.`t2` where (`test`.`t2`.`b` = 'b') group by `test`.`t2`.`a1`,`test`.`t2`.`a2` +explain select a1,a2,b,max(c),min(c) from t3 where (a2 = 'a') and (b = 'b') group by a1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL range idx_t3_0,idx_t3_1,idx_t3_2 idx_t3_1 6 NULL 4 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a1` AS `a1`,`test`.`t3`.`a2` AS `a2`,`test`.`t3`.`b` AS `b`,max(`test`.`t3`.`c`) AS `max(c)`,min(`test`.`t3`.`c`) AS `min(c)` from `test`.`t3` where ((`test`.`t3`.`b` = 'b') and (`test`.`t3`.`a2` = 'a')) group by `test`.`t3`.`a1` +explain select a1,max(c),min(c) from t3 where (a2 = 'a') and (b = 'b') group by a1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL range idx_t3_0,idx_t3_1,idx_t3_2 idx_t3_1 6 NULL 4 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a1` AS `a1`,max(`test`.`t3`.`c`) AS `max(c)`,min(`test`.`t3`.`c`) AS `min(c)` from `test`.`t3` where ((`test`.`t3`.`b` = 'b') and (`test`.`t3`.`a2` = 'a')) group by `test`.`t3`.`a1` +select a1,a2,b,max(c),min(c) from t1 where (a2 = 'a') and (b = 'b') group by a1; +a1 a2 b max(c) min(c) +a a b h112 e112 +b a b h212 e212 +c a b h312 e312 +d a b h412 e412 +select a1,max(c),min(c) from t1 where (a2 = 'a') and (b = 'b') group by a1; +a1 max(c) min(c) +a h112 e112 +b h212 e212 +c h312 e312 +d h412 e412 +select a1,a2,b, max(c) from t1 where (b = 'b') group by a1,a2; +a1 a2 b max(c) +a a b h112 +a b b p122 +b a b h212 +b b b p222 +c a b h312 +c b b p322 +d a b h412 +d b b p422 +select a1,a2,b,min(c),max(c) from t1 where (b = 'b') group by a1,a2; +a1 a2 b min(c) max(c) +a a b e112 h112 +a b b m122 p122 +b a b e212 h212 +b b b m222 p222 +c a b e312 h312 +c b b m322 p322 +d a b e412 h412 +d b b m422 p422 +select a1,a2, max(c) from t1 where (b = 'b') group by a1,a2; +a1 a2 max(c) +a a h112 +a b p122 +b a h212 +b b p222 +c a h312 +c b p322 +d a h412 +d b p422 +select a1,a2,b,max(c),min(c) from t2 where (a2 = 'a') and (b = 'b') group by a1; +a1 a2 b max(c) min(c) +a a b h112 e112 +b a b h212 e212 +c a b h312 e312 +d a b h412 e412 +e a b NULL NULL +select a1,max(c),min(c) from t2 where (a2 = 'a') and (b = 'b') group by a1; +a1 max(c) min(c) +a h112 e112 +b h212 e212 +c h312 e312 +d h412 e412 +e NULL NULL +select a1,a2,b, max(c) from t2 where (b = 'b') group by a1,a2; +a1 a2 b max(c) +a a b h112 +a b b p122 +b a b h212 +b b b p222 +c a b h312 +c b b p322 +d a b h412 +d b b p422 +e a b NULL +select a1,a2,b,min(c),max(c) from t2 where (b = 'b') group by a1,a2; +a1 a2 b min(c) max(c) +a a b e112 h112 +a b b m122 p122 +b a b e212 h212 +b b b m222 p222 +c a b e312 h312 +c b b m322 p322 +d a b e412 h412 +d b b m422 p422 +e a b NULL NULL +select a1,a2, max(c) from t2 where (b = 'b') group by a1,a2; +a1 a2 max(c) +a a h112 +a b p122 +b a h212 +b b p222 +c a h312 +c b p322 +d a h412 +d b p422 +e a NULL +select a1,a2,b,max(c),min(c) from t3 where (a2 = 'a') and (b = 'b') group by a1; +a1 a2 b max(c) min(c) +a a b h112 e112 +b a b h212 e212 +c a b h312 e312 +select a1,max(c),min(c) from t3 where (a2 = 'a') and (b = 'b') group by a1; +a1 max(c) min(c) +a h112 e112 +b h212 e212 +c h312 e312 +explain select a1,a2,b,min(c) from t2 where (a2 = 'a') and b is NULL group by a1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range idx_t2_0,idx_t2_1,idx_t2_2 idx_t2_1 163 NULL 5 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a1` AS `a1`,`test`.`t2`.`a2` AS `a2`,`test`.`t2`.`b` AS `b`,min(`test`.`t2`.`c`) AS `min(c)` from `test`.`t2` where ((`test`.`t2`.`a2` = 'a') and (`test`.`t2`.`b` is null)) group by `test`.`t2`.`a1` +explain select a1,a2,b,max(c) from t2 where (a2 = 'a') and b is NULL group by a1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range idx_t2_0,idx_t2_1,idx_t2_2 idx_t2_1 146 NULL 5 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a1` AS `a1`,`test`.`t2`.`a2` AS `a2`,`test`.`t2`.`b` AS `b`,max(`test`.`t2`.`c`) AS `max(c)` from `test`.`t2` where ((`test`.`t2`.`a2` = 'a') and (`test`.`t2`.`b` is null)) group by `test`.`t2`.`a1` +explain select a1,a2,b,min(c) from t2 where b is NULL group by a1,a2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range idx_t2_1,idx_t2_2 idx_t2_1 163 NULL 10 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a1` AS `a1`,`test`.`t2`.`a2` AS `a2`,`test`.`t2`.`b` AS `b`,min(`test`.`t2`.`c`) AS `min(c)` from `test`.`t2` where (`test`.`t2`.`b` is null) group by `test`.`t2`.`a1`,`test`.`t2`.`a2` +explain select a1,a2,b,max(c) from t2 where b is NULL group by a1,a2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range idx_t2_1,idx_t2_2 idx_t2_1 146 NULL 10 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a1` AS `a1`,`test`.`t2`.`a2` AS `a2`,`test`.`t2`.`b` AS `b`,max(`test`.`t2`.`c`) AS `max(c)` from `test`.`t2` where (`test`.`t2`.`b` is null) group by `test`.`t2`.`a1`,`test`.`t2`.`a2` +explain select a1,a2,b,min(c),max(c) from t2 where b is NULL group by a1,a2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range idx_t2_1,idx_t2_2 idx_t2_1 163 NULL 10 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a1` AS `a1`,`test`.`t2`.`a2` AS `a2`,`test`.`t2`.`b` AS `b`,min(`test`.`t2`.`c`) AS `min(c)`,max(`test`.`t2`.`c`) AS `max(c)` from `test`.`t2` where (`test`.`t2`.`b` is null) group by `test`.`t2`.`a1`,`test`.`t2`.`a2` +explain select a1,a2,b,min(c),max(c) from t2 where b is NULL group by a1,a2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range idx_t2_1,idx_t2_2 idx_t2_1 163 NULL 10 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a1` AS `a1`,`test`.`t2`.`a2` AS `a2`,`test`.`t2`.`b` AS `b`,min(`test`.`t2`.`c`) AS `min(c)`,max(`test`.`t2`.`c`) AS `max(c)` from `test`.`t2` where (`test`.`t2`.`b` is null) group by `test`.`t2`.`a1`,`test`.`t2`.`a2` +select a1,a2,b,min(c) from t2 where (a2 = 'a') and b is NULL group by a1; +a1 a2 b min(c) +a a NULL a777 +c a NULL c777 +select a1,a2,b,max(c) from t2 where (a2 = 'a') and b is NULL group by a1; +a1 a2 b max(c) +a a NULL a999 +c a NULL c999 +select a1,a2,b,min(c) from t2 where b is NULL group by a1,a2; +a1 a2 b min(c) +a a NULL a777 +c a NULL c777 +select a1,a2,b,max(c) from t2 where b is NULL group by a1,a2; +a1 a2 b max(c) +a a NULL a999 +c a NULL c999 +select a1,a2,b,min(c),max(c) from t2 where b is NULL group by a1,a2; +a1 a2 b min(c) max(c) +a a NULL a777 a999 +c a NULL c777 c999 +select a1,a2,b,min(c),max(c) from t2 where b is NULL group by a1,a2; +a1 a2 b min(c) max(c) +a a NULL a777 a999 +c a NULL c777 c999 +explain select a1,a2,b, max(c) from t1 where (c > 'b1') group by a1,a2,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range idx_t1_1,idx_t1_2 idx_t1_1 147 NULL # 33.33 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,`test`.`t1`.`b` AS `b`,max(`test`.`t1`.`c`) AS `max(c)` from `test`.`t1` where (`test`.`t1`.`c` > 'b1') group by `test`.`t1`.`a1`,`test`.`t1`.`a2`,`test`.`t1`.`b` +explain select a1,a2,b,min(c),max(c) from t1 where (c > 'b1') group by a1,a2,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range idx_t1_1,idx_t1_2 idx_t1_1 163 NULL 17 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,`test`.`t1`.`b` AS `b`,min(`test`.`t1`.`c`) AS `min(c)`,max(`test`.`t1`.`c`) AS `max(c)` from `test`.`t1` where (`test`.`t1`.`c` > 'b1') group by `test`.`t1`.`a1`,`test`.`t1`.`a2`,`test`.`t1`.`b` +explain select a1,a2,b, max(c) from t1 where (c > 'f123') group by a1,a2,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 17 33.33 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,`test`.`t1`.`b` AS `b`,max(`test`.`t1`.`c`) AS `max(c)` from `test`.`t1` where (`test`.`t1`.`c` > 'f123') group by `test`.`t1`.`a1`,`test`.`t1`.`a2`,`test`.`t1`.`b` +explain select a1,a2,b,min(c),max(c) from t1 where (c > 'f123') group by a1,a2,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range idx_t1_1,idx_t1_2 idx_t1_1 163 NULL 17 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,`test`.`t1`.`b` AS `b`,min(`test`.`t1`.`c`) AS `min(c)`,max(`test`.`t1`.`c`) AS `max(c)` from `test`.`t1` where (`test`.`t1`.`c` > 'f123') group by `test`.`t1`.`a1`,`test`.`t1`.`a2`,`test`.`t1`.`b` +explain select a1,a2,b, max(c) from t1 where (c < 'a0') group by a1,a2,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range idx_t1_1,idx_t1_2 idx_t1_1 163 NULL 17 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,`test`.`t1`.`b` AS `b`,max(`test`.`t1`.`c`) AS `max(c)` from `test`.`t1` where (`test`.`t1`.`c` < 'a0') group by `test`.`t1`.`a1`,`test`.`t1`.`a2`,`test`.`t1`.`b` +explain select a1,a2,b,min(c),max(c) from t1 where (c < 'a0') group by a1,a2,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range idx_t1_1,idx_t1_2 idx_t1_1 163 NULL 17 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,`test`.`t1`.`b` AS `b`,min(`test`.`t1`.`c`) AS `min(c)`,max(`test`.`t1`.`c`) AS `max(c)` from `test`.`t1` where (`test`.`t1`.`c` < 'a0') group by `test`.`t1`.`a1`,`test`.`t1`.`a2`,`test`.`t1`.`b` +explain select a1,a2,b, max(c) from t1 where (c < 'k321') group by a1,a2,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range idx_t1_1,idx_t1_2 idx_t1_1 163 NULL 17 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,`test`.`t1`.`b` AS `b`,max(`test`.`t1`.`c`) AS `max(c)` from `test`.`t1` where (`test`.`t1`.`c` < 'k321') group by `test`.`t1`.`a1`,`test`.`t1`.`a2`,`test`.`t1`.`b` +explain select a1,a2,b,min(c),max(c) from t1 where (c < 'k321') group by a1,a2,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range idx_t1_1,idx_t1_2 idx_t1_1 163 NULL 17 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,`test`.`t1`.`b` AS `b`,min(`test`.`t1`.`c`) AS `min(c)`,max(`test`.`t1`.`c`) AS `max(c)` from `test`.`t1` where (`test`.`t1`.`c` < 'k321') group by `test`.`t1`.`a1`,`test`.`t1`.`a2`,`test`.`t1`.`b` +explain select a1,a2,b, max(c) from t1 where (c < 'a0') or (c > 'b1') group by a1,a2,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range idx_t1_1,idx_t1_2 idx_t1_1 163 NULL 17 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,`test`.`t1`.`b` AS `b`,max(`test`.`t1`.`c`) AS `max(c)` from `test`.`t1` where ((`test`.`t1`.`c` < 'a0') or (`test`.`t1`.`c` > 'b1')) group by `test`.`t1`.`a1`,`test`.`t1`.`a2`,`test`.`t1`.`b` +explain select a1,a2,b,min(c),max(c) from t1 where (c < 'a0') or (c > 'b1') group by a1,a2,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range idx_t1_1,idx_t1_2 idx_t1_1 163 NULL 17 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,`test`.`t1`.`b` AS `b`,min(`test`.`t1`.`c`) AS `min(c)`,max(`test`.`t1`.`c`) AS `max(c)` from `test`.`t1` where ((`test`.`t1`.`c` < 'a0') or (`test`.`t1`.`c` > 'b1')) group by `test`.`t1`.`a1`,`test`.`t1`.`a2`,`test`.`t1`.`b` +explain select a1,a2,b, max(c) from t1 where (c > 'b1') or (c <= 'g1') group by a1,a2,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 17 55.55 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,`test`.`t1`.`b` AS `b`,max(`test`.`t1`.`c`) AS `max(c)` from `test`.`t1` where ((`test`.`t1`.`c` > 'b1') or (`test`.`t1`.`c` <= 'g1')) group by `test`.`t1`.`a1`,`test`.`t1`.`a2`,`test`.`t1`.`b` +explain select a1,a2,b,min(c),max(c) from t1 where (c > 'b1') or (c <= 'g1') group by a1,a2,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 17 55.55 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,`test`.`t1`.`b` AS `b`,min(`test`.`t1`.`c`) AS `min(c)`,max(`test`.`t1`.`c`) AS `max(c)` from `test`.`t1` where ((`test`.`t1`.`c` > 'b1') or (`test`.`t1`.`c` <= 'g1')) group by `test`.`t1`.`a1`,`test`.`t1`.`a2`,`test`.`t1`.`b` +explain select a1,a2,b,min(c),max(c) from t1 where (c > 'b111') and (c <= 'g112') group by a1,a2,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range idx_t1_1,idx_t1_2 idx_t1_1 163 NULL 17 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,`test`.`t1`.`b` AS `b`,min(`test`.`t1`.`c`) AS `min(c)`,max(`test`.`t1`.`c`) AS `max(c)` from `test`.`t1` where ((`test`.`t1`.`c` > 'b111') and (`test`.`t1`.`c` <= 'g112')) group by `test`.`t1`.`a1`,`test`.`t1`.`a2`,`test`.`t1`.`b` +explain select a1,a2,b,min(c),max(c) from t1 where (c < 'c5') or (c = 'g412') or (c = 'k421') group by a1,a2,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range idx_t1_1,idx_t1_2 idx_t1_1 163 NULL 17 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,`test`.`t1`.`b` AS `b`,min(`test`.`t1`.`c`) AS `min(c)`,max(`test`.`t1`.`c`) AS `max(c)` from `test`.`t1` where ((`test`.`t1`.`c` < 'c5') or (`test`.`t1`.`c` = 'g412') or (`test`.`t1`.`c` = 'k421')) group by `test`.`t1`.`a1`,`test`.`t1`.`a2`,`test`.`t1`.`b` +explain select a1,a2,b,min(c),max(c) from t1 where ((c > 'b111') and (c <= 'g112')) or ((c > 'd000') and (c <= 'i110')) group by a1,a2,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range idx_t1_1,idx_t1_2 idx_t1_1 163 NULL 17 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,`test`.`t1`.`b` AS `b`,min(`test`.`t1`.`c`) AS `min(c)`,max(`test`.`t1`.`c`) AS `max(c)` from `test`.`t1` where (((`test`.`t1`.`c` > 'b111') and (`test`.`t1`.`c` <= 'g112')) or ((`test`.`t1`.`c` > 'd000') and (`test`.`t1`.`c` <= 'i110'))) group by `test`.`t1`.`a1`,`test`.`t1`.`a2`,`test`.`t1`.`b` +explain select a1,a2,b,min(c),max(c) from t1 where (c between 'b111' and 'g112') or (c between 'd000' and 'i110') group by a1,a2,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range idx_t1_1,idx_t1_2 idx_t1_1 163 NULL 17 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,`test`.`t1`.`b` AS `b`,min(`test`.`t1`.`c`) AS `min(c)`,max(`test`.`t1`.`c`) AS `max(c)` from `test`.`t1` where ((`test`.`t1`.`c` between 'b111' and 'g112') or (`test`.`t1`.`c` between 'd000' and 'i110')) group by `test`.`t1`.`a1`,`test`.`t1`.`a2`,`test`.`t1`.`b` +explain select a1,a2,b, max(c) from t2 where (c > 'b1') group by a1,a2,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range idx_t2_1,idx_t2_2 idx_t2_1 146 NULL # 33.33 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a1` AS `a1`,`test`.`t2`.`a2` AS `a2`,`test`.`t2`.`b` AS `b`,max(`test`.`t2`.`c`) AS `max(c)` from `test`.`t2` where (`test`.`t2`.`c` > 'b1') group by `test`.`t2`.`a1`,`test`.`t2`.`a2`,`test`.`t2`.`b` +explain select a1,a2,b,min(c),max(c) from t2 where (c > 'b1') group by a1,a2,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range idx_t2_1,idx_t2_2 idx_t2_1 163 NULL # 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a1` AS `a1`,`test`.`t2`.`a2` AS `a2`,`test`.`t2`.`b` AS `b`,min(`test`.`t2`.`c`) AS `min(c)`,max(`test`.`t2`.`c`) AS `max(c)` from `test`.`t2` where (`test`.`t2`.`c` > 'b1') group by `test`.`t2`.`a1`,`test`.`t2`.`a2`,`test`.`t2`.`b` +explain select a1,a2,b, max(c) from t2 where (c > 'f123') group by a1,a2,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range idx_t2_1,idx_t2_2 idx_t2_1 146 NULL # 33.33 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a1` AS `a1`,`test`.`t2`.`a2` AS `a2`,`test`.`t2`.`b` AS `b`,max(`test`.`t2`.`c`) AS `max(c)` from `test`.`t2` where (`test`.`t2`.`c` > 'f123') group by `test`.`t2`.`a1`,`test`.`t2`.`a2`,`test`.`t2`.`b` +explain select a1,a2,b,min(c),max(c) from t2 where (c > 'f123') group by a1,a2,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range idx_t2_1,idx_t2_2 idx_t2_1 163 NULL # 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a1` AS `a1`,`test`.`t2`.`a2` AS `a2`,`test`.`t2`.`b` AS `b`,min(`test`.`t2`.`c`) AS `min(c)`,max(`test`.`t2`.`c`) AS `max(c)` from `test`.`t2` where (`test`.`t2`.`c` > 'f123') group by `test`.`t2`.`a1`,`test`.`t2`.`a2`,`test`.`t2`.`b` +explain select a1,a2,b, max(c) from t2 where (c < 'a0') group by a1,a2,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range idx_t2_1,idx_t2_2 idx_t2_1 163 NULL # 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a1` AS `a1`,`test`.`t2`.`a2` AS `a2`,`test`.`t2`.`b` AS `b`,max(`test`.`t2`.`c`) AS `max(c)` from `test`.`t2` where (`test`.`t2`.`c` < 'a0') group by `test`.`t2`.`a1`,`test`.`t2`.`a2`,`test`.`t2`.`b` +explain select a1,a2,b,min(c),max(c) from t2 where (c < 'a0') group by a1,a2,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range idx_t2_1,idx_t2_2 idx_t2_1 163 NULL # 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a1` AS `a1`,`test`.`t2`.`a2` AS `a2`,`test`.`t2`.`b` AS `b`,min(`test`.`t2`.`c`) AS `min(c)`,max(`test`.`t2`.`c`) AS `max(c)` from `test`.`t2` where (`test`.`t2`.`c` < 'a0') group by `test`.`t2`.`a1`,`test`.`t2`.`a2`,`test`.`t2`.`b` +explain select a1,a2,b, max(c) from t2 where (c < 'k321') group by a1,a2,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range idx_t2_1,idx_t2_2 idx_t2_1 163 NULL # 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a1` AS `a1`,`test`.`t2`.`a2` AS `a2`,`test`.`t2`.`b` AS `b`,max(`test`.`t2`.`c`) AS `max(c)` from `test`.`t2` where (`test`.`t2`.`c` < 'k321') group by `test`.`t2`.`a1`,`test`.`t2`.`a2`,`test`.`t2`.`b` +explain select a1,a2,b,min(c),max(c) from t2 where (c < 'k321') group by a1,a2,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range idx_t2_1,idx_t2_2 idx_t2_1 163 NULL # 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a1` AS `a1`,`test`.`t2`.`a2` AS `a2`,`test`.`t2`.`b` AS `b`,min(`test`.`t2`.`c`) AS `min(c)`,max(`test`.`t2`.`c`) AS `max(c)` from `test`.`t2` where (`test`.`t2`.`c` < 'k321') group by `test`.`t2`.`a1`,`test`.`t2`.`a2`,`test`.`t2`.`b` +explain select a1,a2,b, max(c) from t2 where (c < 'a0') or (c > 'b1') group by a1,a2,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range idx_t2_1,idx_t2_2 idx_t2_1 163 NULL # 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a1` AS `a1`,`test`.`t2`.`a2` AS `a2`,`test`.`t2`.`b` AS `b`,max(`test`.`t2`.`c`) AS `max(c)` from `test`.`t2` where ((`test`.`t2`.`c` < 'a0') or (`test`.`t2`.`c` > 'b1')) group by `test`.`t2`.`a1`,`test`.`t2`.`a2`,`test`.`t2`.`b` +explain select a1,a2,b,min(c),max(c) from t2 where (c < 'a0') or (c > 'b1') group by a1,a2,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range idx_t2_1,idx_t2_2 idx_t2_1 163 NULL # 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a1` AS `a1`,`test`.`t2`.`a2` AS `a2`,`test`.`t2`.`b` AS `b`,min(`test`.`t2`.`c`) AS `min(c)`,max(`test`.`t2`.`c`) AS `max(c)` from `test`.`t2` where ((`test`.`t2`.`c` < 'a0') or (`test`.`t2`.`c` > 'b1')) group by `test`.`t2`.`a1`,`test`.`t2`.`a2`,`test`.`t2`.`b` +explain select a1,a2,b, max(c) from t2 where (c > 'b1') or (c <= 'g1') group by a1,a2,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range idx_t2_1,idx_t2_2 idx_t2_1 146 NULL # 55.55 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a1` AS `a1`,`test`.`t2`.`a2` AS `a2`,`test`.`t2`.`b` AS `b`,max(`test`.`t2`.`c`) AS `max(c)` from `test`.`t2` where ((`test`.`t2`.`c` > 'b1') or (`test`.`t2`.`c` <= 'g1')) group by `test`.`t2`.`a1`,`test`.`t2`.`a2`,`test`.`t2`.`b` +explain select a1,a2,b,min(c),max(c) from t2 where (c > 'b1') or (c <= 'g1') group by a1,a2,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range idx_t2_1,idx_t2_2 idx_t2_1 163 NULL # 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a1` AS `a1`,`test`.`t2`.`a2` AS `a2`,`test`.`t2`.`b` AS `b`,min(`test`.`t2`.`c`) AS `min(c)`,max(`test`.`t2`.`c`) AS `max(c)` from `test`.`t2` where ((`test`.`t2`.`c` > 'b1') or (`test`.`t2`.`c` <= 'g1')) group by `test`.`t2`.`a1`,`test`.`t2`.`a2`,`test`.`t2`.`b` +explain select a1,a2,b,min(c),max(c) from t2 where (c > 'b111') and (c <= 'g112') group by a1,a2,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range idx_t2_1,idx_t2_2 idx_t2_1 163 NULL # 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a1` AS `a1`,`test`.`t2`.`a2` AS `a2`,`test`.`t2`.`b` AS `b`,min(`test`.`t2`.`c`) AS `min(c)`,max(`test`.`t2`.`c`) AS `max(c)` from `test`.`t2` where ((`test`.`t2`.`c` > 'b111') and (`test`.`t2`.`c` <= 'g112')) group by `test`.`t2`.`a1`,`test`.`t2`.`a2`,`test`.`t2`.`b` +explain select a1,a2,b,min(c),max(c) from t2 where (c < 'c5') or (c = 'g412') or (c = 'k421') group by a1,a2,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range idx_t2_1,idx_t2_2 idx_t2_1 163 NULL # 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a1` AS `a1`,`test`.`t2`.`a2` AS `a2`,`test`.`t2`.`b` AS `b`,min(`test`.`t2`.`c`) AS `min(c)`,max(`test`.`t2`.`c`) AS `max(c)` from `test`.`t2` where ((`test`.`t2`.`c` < 'c5') or (`test`.`t2`.`c` = 'g412') or (`test`.`t2`.`c` = 'k421')) group by `test`.`t2`.`a1`,`test`.`t2`.`a2`,`test`.`t2`.`b` +explain select a1,a2,b,min(c),max(c) from t2 where ((c > 'b111') and (c <= 'g112')) or ((c > 'd000') and (c <= 'i110')) group by a1,a2,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range idx_t2_1,idx_t2_2 idx_t2_1 163 NULL # 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a1` AS `a1`,`test`.`t2`.`a2` AS `a2`,`test`.`t2`.`b` AS `b`,min(`test`.`t2`.`c`) AS `min(c)`,max(`test`.`t2`.`c`) AS `max(c)` from `test`.`t2` where (((`test`.`t2`.`c` > 'b111') and (`test`.`t2`.`c` <= 'g112')) or ((`test`.`t2`.`c` > 'd000') and (`test`.`t2`.`c` <= 'i110'))) group by `test`.`t2`.`a1`,`test`.`t2`.`a2`,`test`.`t2`.`b` +select a1,a2,b, max(c) from t1 where (c > 'b1') group by a1,a2,b; +a1 a2 b max(c) +a a a d111 +a a b h112 +a b a l121 +a b b p122 +b a a d211 +b a b h212 +b b a l221 +b b b p222 +c a a d311 +c a b h312 +c b a l321 +c b b p322 +d a a d411 +d a b h412 +d b a l421 +d b b p422 +select a1,a2,b,min(c),max(c) from t1 where (c > 'b1') group by a1,a2,b; +a1 a2 b min(c) max(c) +a a a b111 d111 +a a b e112 h112 +a b a i121 l121 +a b b m122 p122 +b a a b211 d211 +b a b e212 h212 +b b a i221 l221 +b b b m222 p222 +c a a b311 d311 +c a b e312 h312 +c b a i321 l321 +c b b m322 p322 +d a a b411 d411 +d a b e412 h412 +d b a i421 l421 +d b b m422 p422 +select a1,a2,b, max(c) from t1 where (c > 'f123') group by a1,a2,b; +a1 a2 b max(c) +a a b h112 +a b a l121 +a b b p122 +b a b h212 +b b a l221 +b b b p222 +c a b h312 +c b a l321 +c b b p322 +d a b h412 +d b a l421 +d b b p422 +select a1,a2,b,min(c),max(c) from t1 where (c > 'f123') group by a1,a2,b; +a1 a2 b min(c) max(c) +a a b g112 h112 +a b a i121 l121 +a b b m122 p122 +b a b f212 h212 +b b a i221 l221 +b b b m222 p222 +c a b f312 h312 +c b a i321 l321 +c b b m322 p322 +d a b f412 h412 +d b a i421 l421 +d b b m422 p422 +select a1,a2,b, max(c) from t1 where (c < 'a0') group by a1,a2,b; +a1 a2 b max(c) +select a1,a2,b,min(c),max(c) from t1 where (c < 'a0') group by a1,a2,b; +a1 a2 b min(c) max(c) +select a1,a2,b, max(c) from t1 where (c < 'k321') group by a1,a2,b; +a1 a2 b max(c) +a a a d111 +a a b h112 +a b a k121 +b a a d211 +b a b h212 +b b a k221 +c a a d311 +c a b h312 +c b a j321 +d a a d411 +d a b h412 +d b a j421 +select a1,a2,b,min(c),max(c) from t1 where (c < 'k321') group by a1,a2,b; +a1 a2 b min(c) max(c) +a a a a111 d111 +a a b e112 h112 +a b a i121 k121 +b a a a211 d211 +b a b e212 h212 +b b a i221 k221 +c a a a311 d311 +c a b e312 h312 +c b a i321 j321 +d a a a411 d411 +d a b e412 h412 +d b a i421 j421 +select a1,a2,b, max(c) from t1 where (c < 'a0') or (c > 'b1') group by a1,a2,b; +a1 a2 b max(c) +a a a d111 +a a b h112 +a b a l121 +a b b p122 +b a a d211 +b a b h212 +b b a l221 +b b b p222 +c a a d311 +c a b h312 +c b a l321 +c b b p322 +d a a d411 +d a b h412 +d b a l421 +d b b p422 +select a1,a2,b,min(c),max(c) from t1 where (c < 'a0') or (c > 'b1') group by a1,a2,b; +a1 a2 b min(c) max(c) +a a a b111 d111 +a a b e112 h112 +a b a i121 l121 +a b b m122 p122 +b a a b211 d211 +b a b e212 h212 +b b a i221 l221 +b b b m222 p222 +c a a b311 d311 +c a b e312 h312 +c b a i321 l321 +c b b m322 p322 +d a a b411 d411 +d a b e412 h412 +d b a i421 l421 +d b b m422 p422 +select a1,a2,b, max(c) from t1 where (c > 'b1') or (c <= 'g1') group by a1,a2,b; +a1 a2 b max(c) +a a a d111 +a a b h112 +a b a l121 +a b b p122 +b a a d211 +b a b h212 +b b a l221 +b b b p222 +c a a d311 +c a b h312 +c b a l321 +c b b p322 +d a a d411 +d a b h412 +d b a l421 +d b b p422 +select a1,a2,b,min(c),max(c) from t1 where (c > 'b1') or (c <= 'g1') group by a1,a2,b; +a1 a2 b min(c) max(c) +a a a a111 d111 +a a b e112 h112 +a b a i121 l121 +a b b m122 p122 +b a a a211 d211 +b a b e212 h212 +b b a i221 l221 +b b b m222 p222 +c a a a311 d311 +c a b e312 h312 +c b a i321 l321 +c b b m322 p322 +d a a a411 d411 +d a b e412 h412 +d b a i421 l421 +d b b m422 p422 +select a1,a2,b,min(c),max(c) from t1 where (c > 'b111') and (c <= 'g112') group by a1,a2,b; +a1 a2 b min(c) max(c) +a a a c111 d111 +a a b e112 g112 +b a a b211 d211 +b a b e212 f212 +c a a b311 d311 +c a b e312 f312 +d a a b411 d411 +d a b e412 f412 +select a1,a2,b,min(c),max(c) from t1 where (c < 'c5') or (c = 'g412') or (c = 'k421') group by a1,a2,b; +a1 a2 b min(c) max(c) +a a a a111 c111 +b a a a211 c211 +c a a a311 c311 +d a a a411 c411 +d a b g412 g412 +d b a k421 k421 +select a1,a2,b,min(c),max(c) from t1 where ((c > 'b111') and (c <= 'g112')) or ((c > 'd000') and (c <= 'i110')) group by a1,a2,b; +a1 a2 b min(c) max(c) +a a a c111 d111 +a a b e112 h112 +b a a b211 d211 +b a b e212 h212 +c a a b311 d311 +c a b e312 h312 +d a a b411 d411 +d a b e412 h412 +select a1,a2,b,min(c),max(c) from t1 where (c between 'b111' and 'g112') or (c between 'd000' and 'i110') group by a1,a2,b; +a1 a2 b min(c) max(c) +a a a b111 d111 +a a b e112 h112 +b a a b211 d211 +b a b e212 h212 +c a a b311 d311 +c a b e312 h312 +d a a b411 d411 +d a b e412 h412 +select a1,a2,b, max(c) from t2 where (c > 'b1') group by a1,a2,b; +a1 a2 b max(c) +a a a d111 +a a b h112 +a b a l121 +a b b p122 +b a a d211 +b a b h212 +b b a l221 +b b b p222 +c a NULL c999 +c a a d311 +c a b h312 +c b a l321 +c b b p322 +d a a d411 +d a b h412 +d b a l421 +d b b p422 +select a1,a2,b,min(c),max(c) from t2 where (c > 'b1') group by a1,a2,b; +a1 a2 b min(c) max(c) +a a a b111 d111 +a a b e112 h112 +a b a i121 l121 +a b b m122 p122 +b a a b211 d211 +b a b e212 h212 +b b a i221 l221 +b b b m222 p222 +c a NULL c777 c999 +c a a b311 d311 +c a b e312 h312 +c b a i321 l321 +c b b m322 p322 +d a a b411 d411 +d a b e412 h412 +d b a i421 l421 +d b b m422 p422 +select a1,a2,b, max(c) from t2 where (c > 'f123') group by a1,a2,b; +a1 a2 b max(c) +a a b h112 +a b a l121 +a b b p122 +b a b h212 +b b a l221 +b b b p222 +c a b h312 +c b a l321 +c b b p322 +d a b h412 +d b a l421 +d b b p422 +select a1,a2,b,min(c),max(c) from t2 where (c > 'f123') group by a1,a2,b; +a1 a2 b min(c) max(c) +a a b g112 h112 +a b a i121 l121 +a b b m122 p122 +b a b f212 h212 +b b a i221 l221 +b b b m222 p222 +c a b f312 h312 +c b a i321 l321 +c b b m322 p322 +d a b f412 h412 +d b a i421 l421 +d b b m422 p422 +select a1,a2,b, max(c) from t2 where (c < 'a0') group by a1,a2,b; +a1 a2 b max(c) +select a1,a2,b,min(c),max(c) from t2 where (c < 'a0') group by a1,a2,b; +a1 a2 b min(c) max(c) +select a1,a2,b, max(c) from t2 where (c < 'k321') group by a1,a2,b; +a1 a2 b max(c) +a a NULL a999 +a a a d111 +a a b h112 +a b a k121 +b a a d211 +b a b h212 +b b a k221 +c a NULL c999 +c a a d311 +c a b h312 +c b a j321 +d a a d411 +d a b h412 +d b a j421 +select a1,a2,b,min(c),max(c) from t2 where (c < 'k321') group by a1,a2,b; +a1 a2 b min(c) max(c) +a a NULL a777 a999 +a a a a111 d111 +a a b e112 h112 +a b a i121 k121 +b a a a211 d211 +b a b e212 h212 +b b a i221 k221 +c a NULL c777 c999 +c a a a311 d311 +c a b e312 h312 +c b a i321 j321 +d a a a411 d411 +d a b e412 h412 +d b a i421 j421 +select a1,a2,b, max(c) from t2 where (c < 'a0') or (c > 'b1') group by a1,a2,b; +a1 a2 b max(c) +a a a d111 +a a b h112 +a b a l121 +a b b p122 +b a a d211 +b a b h212 +b b a l221 +b b b p222 +c a NULL c999 +c a a d311 +c a b h312 +c b a l321 +c b b p322 +d a a d411 +d a b h412 +d b a l421 +d b b p422 +select a1,a2,b,min(c),max(c) from t2 where (c < 'a0') or (c > 'b1') group by a1,a2,b; +a1 a2 b min(c) max(c) +a a a b111 d111 +a a b e112 h112 +a b a i121 l121 +a b b m122 p122 +b a a b211 d211 +b a b e212 h212 +b b a i221 l221 +b b b m222 p222 +c a NULL c777 c999 +c a a b311 d311 +c a b e312 h312 +c b a i321 l321 +c b b m322 p322 +d a a b411 d411 +d a b e412 h412 +d b a i421 l421 +d b b m422 p422 +select a1,a2,b, max(c) from t2 where (c > 'b1') or (c <= 'g1') group by a1,a2,b; +a1 a2 b max(c) +a a NULL a999 +a a a d111 +a a b h112 +a b a l121 +a b b p122 +b a a d211 +b a b h212 +b b a l221 +b b b p222 +c a NULL c999 +c a a d311 +c a b h312 +c b a l321 +c b b p322 +d a a d411 +d a b h412 +d b a l421 +d b b p422 +select a1,a2,b,min(c),max(c) from t2 where (c > 'b1') or (c <= 'g1') group by a1,a2,b; +a1 a2 b min(c) max(c) +a a NULL a777 a999 +a a a a111 d111 +a a b e112 h112 +a b a i121 l121 +a b b m122 p122 +b a a a211 d211 +b a b e212 h212 +b b a i221 l221 +b b b m222 p222 +c a NULL c777 c999 +c a a a311 d311 +c a b e312 h312 +c b a i321 l321 +c b b m322 p322 +d a a a411 d411 +d a b e412 h412 +d b a i421 l421 +d b b m422 p422 +select a1,a2,b,min(c),max(c) from t2 where (c > 'b111') and (c <= 'g112') group by a1,a2,b; +a1 a2 b min(c) max(c) +a a a c111 d111 +a a b e112 g112 +b a a b211 d211 +b a b e212 f212 +c a NULL c777 c999 +c a a b311 d311 +c a b e312 f312 +d a a b411 d411 +d a b e412 f412 +select a1,a2,b,min(c),max(c) from t2 where (c < 'c5') or (c = 'g412') or (c = 'k421') group by a1,a2,b; +a1 a2 b min(c) max(c) +a a NULL a777 a999 +a a a a111 c111 +b a a a211 c211 +c a a a311 c311 +d a a a411 c411 +d a b g412 g412 +d b a k421 k421 +select a1,a2,b,min(c),max(c) from t2 where ((c > 'b111') and (c <= 'g112')) or ((c > 'd000') and (c <= 'i110')) group by a1,a2,b; +a1 a2 b min(c) max(c) +a a a c111 d111 +a a b e112 h112 +b a a b211 d211 +b a b e212 h212 +c a NULL c777 c999 +c a a b311 d311 +c a b e312 h312 +d a a b411 d411 +d a b e412 h412 +explain select a1,a2,b,min(c),max(c) from t1 +where exists ( select * from t2 where t2.c = t1.c ) +group by a1,a2,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index idx_t1_1,idx_t1_2 idx_t1_1 163 NULL 128 100.00 Using index +1 SIMPLE NULL eq_ref 17 test.t1.c 1 100.00 NULL +2 MATERIALIZED t2 NULL index NULL idx_t2_1 163 NULL 164 100.00 Using index +Warnings: +Note 1276 Field or reference 'test.t1.c' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,`test`.`t1`.`b` AS `b`,min(`test`.`t1`.`c`) AS `min(c)`,max(`test`.`t1`.`c`) AS `max(c)` from `test`.`t1` semi join (`test`.`t2`) where (``.`c` = `test`.`t1`.`c`) group by `test`.`t1`.`a1`,`test`.`t1`.`a2`,`test`.`t1`.`b` +explain select a1,a2,b,min(c),max(c) from t1 +where exists ( select * from t2 where t2.c > 'b1' ) +group by a1,a2,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index NULL idx_t2_1 163 NULL 164 33.33 Using where; Using index; Using temporary; FirstMatch +1 SIMPLE t1 NULL index idx_t1_1,idx_t1_2 idx_t1_1 163 NULL 128 100.00 Using index; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,`test`.`t1`.`b` AS `b`,min(`test`.`t1`.`c`) AS `min(c)`,max(`test`.`t1`.`c`) AS `max(c)` from `test`.`t1` semi join (`test`.`t2`) where (`test`.`t2`.`c` > 'b1') group by `test`.`t1`.`a1`,`test`.`t1`.`a2`,`test`.`t1`.`b` +explain select a1,a2,b,min(c),max(c) from t1 where (a1 >= 'c' or a2 < 'b') and (b > 'a') group by a1,a2,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 17 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,`test`.`t1`.`b` AS `b`,min(`test`.`t1`.`c`) AS `min(c)`,max(`test`.`t1`.`c`) AS `max(c)` from `test`.`t1` where (((`test`.`t1`.`a1` >= 'c') or (`test`.`t1`.`a2` < 'b')) and (`test`.`t1`.`b` > 'a')) group by `test`.`t1`.`a1`,`test`.`t1`.`a2`,`test`.`t1`.`b` +explain select a1,a2,b,min(c),max(c) from t1 where (a1 >= 'c' or a2 < 'b') and (c > 'b111') group by a1,a2,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 163 NULL 17 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,`test`.`t1`.`b` AS `b`,min(`test`.`t1`.`c`) AS `min(c)`,max(`test`.`t1`.`c`) AS `max(c)` from `test`.`t1` where (((`test`.`t1`.`a1` >= 'c') or (`test`.`t1`.`a2` < 'b')) and (`test`.`t1`.`c` > 'b111')) group by `test`.`t1`.`a1`,`test`.`t1`.`a2`,`test`.`t1`.`b` +explain select a1,a2,b,min(c),max(c) from t1 where (a2 >= 'b') and (b = 'a') and (c > 'b111') group by a1,a2,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range idx_t1_1,idx_t1_2 idx_t1_1 163 NULL 17 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,`test`.`t1`.`b` AS `b`,min(`test`.`t1`.`c`) AS `min(c)`,max(`test`.`t1`.`c`) AS `max(c)` from `test`.`t1` where ((`test`.`t1`.`b` = 'a') and (`test`.`t1`.`a2` >= 'b') and (`test`.`t1`.`c` > 'b111')) group by `test`.`t1`.`a1`,`test`.`t1`.`a2` +explain select a1,a2,b,min(c) from t1 where ((a1 > 'a') or (a1 < '9')) and ((a2 >= 'b') and (a2 < 'z')) and (b = 'a') and ((c < 'h112') or (c = 'j121') or (c > 'k121' and c < 'm122') or (c > 'o122')) group by a1,a2,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 163 NULL 14 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,`test`.`t1`.`b` AS `b`,min(`test`.`t1`.`c`) AS `min(c)` from `test`.`t1` where ((`test`.`t1`.`b` = 'a') and ((`test`.`t1`.`a1` > 'a') or (`test`.`t1`.`a1` < '9')) and (`test`.`t1`.`a2` >= 'b') and (`test`.`t1`.`a2` < 'z') and ((`test`.`t1`.`c` < 'h112') or (`test`.`t1`.`c` = 'j121') or ((`test`.`t1`.`c` > 'k121') and (`test`.`t1`.`c` < 'm122')) or (`test`.`t1`.`c` > 'o122'))) group by `test`.`t1`.`a1`,`test`.`t1`.`a2` +explain select a1,a2,b,min(c) from t1 where ((a1 > 'a') or (a1 < '9')) and ((a2 >= 'b') and (a2 < 'z')) and (b = 'a') and ((c = 'j121') or (c > 'k121' and c < 'm122') or (c > 'o122') or (c < 'h112') or (c = 'c111')) group by a1,a2,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 163 NULL 14 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,`test`.`t1`.`b` AS `b`,min(`test`.`t1`.`c`) AS `min(c)` from `test`.`t1` where ((`test`.`t1`.`b` = 'a') and ((`test`.`t1`.`a1` > 'a') or (`test`.`t1`.`a1` < '9')) and (`test`.`t1`.`a2` >= 'b') and (`test`.`t1`.`a2` < 'z') and ((`test`.`t1`.`c` = 'j121') or ((`test`.`t1`.`c` > 'k121') and (`test`.`t1`.`c` < 'm122')) or (`test`.`t1`.`c` > 'o122') or (`test`.`t1`.`c` < 'h112') or (`test`.`t1`.`c` = 'c111'))) group by `test`.`t1`.`a1`,`test`.`t1`.`a2` +explain select a1,a2,b,min(c) from t1 where (a1 > 'a') and (a2 > 'a') and (b = 'c') group by a1,a2,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 14 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,`test`.`t1`.`b` AS `b`,min(`test`.`t1`.`c`) AS `min(c)` from `test`.`t1` where ((`test`.`t1`.`b` = 'c') and (`test`.`t1`.`a1` > 'a') and (`test`.`t1`.`a2` > 'a')) group by `test`.`t1`.`a1`,`test`.`t1`.`a2` +explain select a1,a2,b,min(c) from t1 where (ord(a1) > 97) and (ord(a2) + ord(a1) > 194) and (b = 'c') group by a1,a2,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 17 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,`test`.`t1`.`b` AS `b`,min(`test`.`t1`.`c`) AS `min(c)` from `test`.`t1` where ((`test`.`t1`.`b` = 'c') and (ord(`test`.`t1`.`a1`) > 97) and ((ord(`test`.`t1`.`a2`) + ord(`test`.`t1`.`a1`)) > 194)) group by `test`.`t1`.`a1`,`test`.`t1`.`a2` +explain select a1,a2,b,min(c),max(c) from t2 where (a1 >= 'c' or a2 < 'b') and (b > 'a') group by a1,a2,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range idx_t2_0,idx_t2_1,idx_t2_2 idx_t2_1 163 NULL # 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a1` AS `a1`,`test`.`t2`.`a2` AS `a2`,`test`.`t2`.`b` AS `b`,min(`test`.`t2`.`c`) AS `min(c)`,max(`test`.`t2`.`c`) AS `max(c)` from `test`.`t2` where (((`test`.`t2`.`a1` >= 'c') or (`test`.`t2`.`a2` < 'b')) and (`test`.`t2`.`b` > 'a')) group by `test`.`t2`.`a1`,`test`.`t2`.`a2`,`test`.`t2`.`b` +explain select a1,a2,b,min(c),max(c) from t2 where (a1 >= 'c' or a2 < 'b') and (c > 'b111') group by a1,a2,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range idx_t2_0,idx_t2_1,idx_t2_2 idx_t2_1 163 NULL # 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a1` AS `a1`,`test`.`t2`.`a2` AS `a2`,`test`.`t2`.`b` AS `b`,min(`test`.`t2`.`c`) AS `min(c)`,max(`test`.`t2`.`c`) AS `max(c)` from `test`.`t2` where (((`test`.`t2`.`a1` >= 'c') or (`test`.`t2`.`a2` < 'b')) and (`test`.`t2`.`c` > 'b111')) group by `test`.`t2`.`a1`,`test`.`t2`.`a2`,`test`.`t2`.`b` +explain select a1,a2,b,min(c),max(c) from t2 where (a2 >= 'b') and (b = 'a') and (c > 'b111') group by a1,a2,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range idx_t2_1,idx_t2_2 idx_t2_1 163 NULL # 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a1` AS `a1`,`test`.`t2`.`a2` AS `a2`,`test`.`t2`.`b` AS `b`,min(`test`.`t2`.`c`) AS `min(c)`,max(`test`.`t2`.`c`) AS `max(c)` from `test`.`t2` where ((`test`.`t2`.`b` = 'a') and (`test`.`t2`.`a2` >= 'b') and (`test`.`t2`.`c` > 'b111')) group by `test`.`t2`.`a1`,`test`.`t2`.`a2` +explain select a1,a2,b,min(c) from t2 where ((a1 > 'a') or (a1 < '9')) and ((a2 >= 'b') and (a2 < 'z')) and (b = 'a') and ((c < 'h112') or (c = 'j121') or (c > 'k121' and c < 'm122') or (c > 'o122')) group by a1,a2,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range idx_t2_0,idx_t2_1,idx_t2_2 idx_t2_1 163 NULL # 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a1` AS `a1`,`test`.`t2`.`a2` AS `a2`,`test`.`t2`.`b` AS `b`,min(`test`.`t2`.`c`) AS `min(c)` from `test`.`t2` where ((`test`.`t2`.`b` = 'a') and ((`test`.`t2`.`a1` > 'a') or (`test`.`t2`.`a1` < '9')) and (`test`.`t2`.`a2` >= 'b') and (`test`.`t2`.`a2` < 'z') and ((`test`.`t2`.`c` < 'h112') or (`test`.`t2`.`c` = 'j121') or ((`test`.`t2`.`c` > 'k121') and (`test`.`t2`.`c` < 'm122')) or (`test`.`t2`.`c` > 'o122'))) group by `test`.`t2`.`a1`,`test`.`t2`.`a2` +explain select a1,a2,b,min(c) from t2 where ((a1 > 'a') or (a1 < '9')) and ((a2 >= 'b') and (a2 < 'z')) and (b = 'a') and ((c = 'j121') or (c > 'k121' and c < 'm122') or (c > 'o122') or (c < 'h112') or (c = 'c111')) group by a1,a2,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range idx_t2_0,idx_t2_1,idx_t2_2 idx_t2_1 163 NULL # 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a1` AS `a1`,`test`.`t2`.`a2` AS `a2`,`test`.`t2`.`b` AS `b`,min(`test`.`t2`.`c`) AS `min(c)` from `test`.`t2` where ((`test`.`t2`.`b` = 'a') and ((`test`.`t2`.`a1` > 'a') or (`test`.`t2`.`a1` < '9')) and (`test`.`t2`.`a2` >= 'b') and (`test`.`t2`.`a2` < 'z') and ((`test`.`t2`.`c` = 'j121') or ((`test`.`t2`.`c` > 'k121') and (`test`.`t2`.`c` < 'm122')) or (`test`.`t2`.`c` > 'o122') or (`test`.`t2`.`c` < 'h112') or (`test`.`t2`.`c` = 'c111'))) group by `test`.`t2`.`a1`,`test`.`t2`.`a2` +explain select a1,a2,b,min(c) from t2 where (a1 > 'a') and (a2 > 'a') and (b = 'c') group by a1,a2,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range idx_t2_0,idx_t2_1,idx_t2_2 idx_t2_1 163 NULL # 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a1` AS `a1`,`test`.`t2`.`a2` AS `a2`,`test`.`t2`.`b` AS `b`,min(`test`.`t2`.`c`) AS `min(c)` from `test`.`t2` where ((`test`.`t2`.`b` = 'c') and (`test`.`t2`.`a1` > 'a') and (`test`.`t2`.`a2` > 'a')) group by `test`.`t2`.`a1`,`test`.`t2`.`a2` +select a1,a2,b,min(c),max(c) from t1 where (a1 >= 'c' or a2 < 'b') and (b > 'a') group by a1,a2,b; +a1 a2 b min(c) max(c) +a a b e112 h112 +b a b e212 h212 +c a b e312 h312 +c b b m322 p322 +d a b e412 h412 +d b b m422 p422 +select a1,a2,b,min(c),max(c) from t1 where (a1 >= 'c' or a2 < 'b') and (c > 'b111') group by a1,a2,b; +a1 a2 b min(c) max(c) +a a a c111 d111 +a a b e112 h112 +b a a b211 d211 +b a b e212 h212 +c a a b311 d311 +c a b e312 h312 +c b a i321 l321 +c b b m322 p322 +d a a b411 d411 +d a b e412 h412 +d b a i421 l421 +d b b m422 p422 +select a1,a2,b,min(c),max(c) from t1 where (a2 >= 'b') and (b = 'a') and (c > 'b111') group by a1,a2,b; +a1 a2 b min(c) max(c) +a b a i121 l121 +b b a i221 l221 +c b a i321 l321 +d b a i421 l421 +select a1,a2,b,min(c) from t1 where ((a1 > 'a') or (a1 < '9')) and ((a2 >= 'b') and (a2 < 'z')) and (b = 'a') and ((c < 'h112') or (c = 'j121') or (c > 'k121' and c < 'm122') or (c > 'o122')) group by a1,a2,b; +a1 a2 b min(c) +b b a k221 +c b a k321 +d b a k421 +select a1,a2,b,min(c) from t1 where ((a1 > 'a') or (a1 < '9')) and ((a2 >= 'b') and (a2 < 'z')) and (b = 'a') and ((c = 'j121') or (c > 'k121' and c < 'm122') or (c > 'o122') or (c < 'h112') or (c = 'c111')) group by a1,a2,b; +a1 a2 b min(c) +b b a k221 +c b a k321 +d b a k421 +select a1,a2,b,min(c) from t1 where (a1 > 'a') and (a2 > 'a') and (b = 'c') group by a1,a2,b; +a1 a2 b min(c) +select a1,a2,b,min(c) from t1 where (ord(a1) > 97) and (ord(a2) + ord(a1) > 194) and (b = 'c') group by a1,a2,b; +a1 a2 b min(c) +select a1,a2,b,min(c),max(c) from t2 where (a1 >= 'c' or a2 < 'b') and (b > 'a') group by a1,a2,b; +a1 a2 b min(c) max(c) +a a b e112 h112 +b a b e212 h212 +c a b e312 h312 +c b b m322 p322 +d a b e412 h412 +d b b m422 p422 +e a b NULL NULL +select a1,a2,b,min(c),max(c) from t2 where (a1 >= 'c' or a2 < 'b') and (c > 'b111') group by a1,a2,b; +a1 a2 b min(c) max(c) +a a a c111 d111 +a a b e112 h112 +b a a b211 d211 +b a b e212 h212 +c a NULL c777 c999 +c a a b311 d311 +c a b e312 h312 +c b a i321 l321 +c b b m322 p322 +d a a b411 d411 +d a b e412 h412 +d b a i421 l421 +d b b m422 p422 +select a1,a2,b,min(c),max(c) from t2 where (a2 >= 'b') and (b = 'a') and (c > 'b111') group by a1,a2,b; +a1 a2 b min(c) max(c) +a b a i121 l121 +b b a i221 l221 +c b a i321 l321 +d b a i421 l421 +select a1,a2,b,min(c) from t2 where ((a1 > 'a') or (a1 < '9')) and ((a2 >= 'b') and (a2 < 'z')) and (b = 'a') and ((c < 'h112') or (c = 'j121') or (c > 'k121' and c < 'm122') or (c > 'o122')) group by a1,a2,b; +a1 a2 b min(c) +b b a k221 +c b a k321 +d b a k421 +select a1,a2,b,min(c) from t2 where ((a1 > 'a') or (a1 < '9')) and ((a2 >= 'b') and (a2 < 'z')) and (b = 'a') and ((c = 'j121') or (c > 'k121' and c < 'm122') or (c > 'o122') or (c < 'h112') or (c = 'c111')) group by a1,a2,b; +a1 a2 b min(c) +b b a k221 +c b a k321 +d b a k421 +select a1,a2,b,min(c) from t2 where (a1 > 'a') and (a2 > 'a') and (b = 'c') group by a1,a2,b; +a1 a2 b min(c) +explain select a1,a2,b from t1 where (a1 >= 'c' or a2 < 'b') and (b > 'a') group by a1,a2,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 17 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (((`test`.`t1`.`a1` >= 'c') or (`test`.`t1`.`a2` < 'b')) and (`test`.`t1`.`b` > 'a')) group by `test`.`t1`.`a1`,`test`.`t1`.`a2`,`test`.`t1`.`b` +explain format=tree select a1,a2,b from t1 where (a1 >= 'c' or a2 < 'b') and (b > 'a') group by a1,a2,b; +EXPLAIN +-> Filter: (((t1.a1 >= 'c') or (t1.a2 < 'b')) and (t1.b > 'a')) (cost=11.05 rows=17) + -> Index range scan on t1 using index_for_group_by(idx_t1_1) (cost=11.05 rows=17) + +explain select a1,a2,b from t1 where (a2 >= 'b') and (b = 'a') group by a1,a2,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 17 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`b` = 'a') and (`test`.`t1`.`a2` >= 'b')) group by `test`.`t1`.`a1`,`test`.`t1`.`a2` +explain select a1,a2,b,c from t1 where (a2 >= 'b') and (b = 'a') and (c = 'i121') group by a1,a2,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range idx_t1_1,idx_t1_2 idx_t1_1 163 NULL 17 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` where ((`test`.`t1`.`c` = 'i121') and (`test`.`t1`.`b` = 'a') and (`test`.`t1`.`a2` >= 'b')) group by `test`.`t1`.`a1`,`test`.`t1`.`a2` +explain select a1,a2,b from t1 where (a1 > 'a') and (a2 > 'a') and (b = 'c') group by a1,a2,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 14 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`b` = 'c') and (`test`.`t1`.`a1` > 'a') and (`test`.`t1`.`a2` > 'a')) group by `test`.`t1`.`a1`,`test`.`t1`.`a2` +explain select a1,a2,b from t2 where (a1 >= 'c' or a2 < 'b') and (b > 'a') group by a1,a2,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range idx_t2_0,idx_t2_1,idx_t2_2 idx_t2_1 146 NULL # 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a1` AS `a1`,`test`.`t2`.`a2` AS `a2`,`test`.`t2`.`b` AS `b` from `test`.`t2` where (((`test`.`t2`.`a1` >= 'c') or (`test`.`t2`.`a2` < 'b')) and (`test`.`t2`.`b` > 'a')) group by `test`.`t2`.`a1`,`test`.`t2`.`a2`,`test`.`t2`.`b` +explain select a1,a2,b from t2 where (a2 >= 'b') and (b = 'a') group by a1,a2,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range idx_t2_1,idx_t2_2 idx_t2_1 146 NULL # 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a1` AS `a1`,`test`.`t2`.`a2` AS `a2`,`test`.`t2`.`b` AS `b` from `test`.`t2` where ((`test`.`t2`.`b` = 'a') and (`test`.`t2`.`a2` >= 'b')) group by `test`.`t2`.`a1`,`test`.`t2`.`a2` +explain select a1,a2,b,c from t2 where (a2 >= 'b') and (b = 'a') and (c = 'i121') group by a1,a2,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range idx_t2_1,idx_t2_2 idx_t2_1 163 NULL # 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a1` AS `a1`,`test`.`t2`.`a2` AS `a2`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c` from `test`.`t2` where ((`test`.`t2`.`c` = 'i121') and (`test`.`t2`.`b` = 'a') and (`test`.`t2`.`a2` >= 'b')) group by `test`.`t2`.`a1`,`test`.`t2`.`a2` +explain select a1,a2,b from t2 where (a1 > 'a') and (a2 > 'a') and (b = 'c') group by a1,a2,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range idx_t2_0,idx_t2_1,idx_t2_2 idx_t2_1 146 NULL # 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a1` AS `a1`,`test`.`t2`.`a2` AS `a2`,`test`.`t2`.`b` AS `b` from `test`.`t2` where ((`test`.`t2`.`b` = 'c') and (`test`.`t2`.`a1` > 'a') and (`test`.`t2`.`a2` > 'a')) group by `test`.`t2`.`a1`,`test`.`t2`.`a2` +select a1,a2,b from t1 where (a1 >= 'c' or a2 < 'b') and (b > 'a') group by a1,a2,b; +a1 a2 b +a a b +b a b +c a b +c b b +d a b +d b b +select a1,a2,b from t1 where (a2 >= 'b') and (b = 'a') group by a1,a2,b; +a1 a2 b +a b a +b b a +c b a +d b a +select a1,a2,b,c from t1 where (a2 >= 'b') and (b = 'a') and (c = 'i121') group by a1,a2,b; +a1 a2 b c +a b a i121 +select a1,a2,b from t1 where (a1 > 'a') and (a2 > 'a') and (b = 'c') group by a1,a2,b; +a1 a2 b +select a1,a2,b from t2 where (a1 >= 'c' or a2 < 'b') and (b > 'a') group by a1,a2,b; +a1 a2 b +a a b +b a b +c a b +c b b +d a b +d b b +e a b +select a1,a2,b from t2 where (a2 >= 'b') and (b = 'a') group by a1,a2,b; +a1 a2 b +a b a +b b a +c b a +d b a +select a1,a2,b,c from t2 where (a2 >= 'b') and (b = 'a') and (c = 'i121') group by a1,a2,b; +a1 a2 b c +a b a i121 +select a1,a2,b from t2 where (a1 > 'a') and (a2 > 'a') and (b = 'c') group by a1,a2,b; +a1 a2 b +explain select distinct a1,a2,b from t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 17 100.00 Using index for group-by +Warnings: +Note 1003 /* select#1 */ select distinct `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,`test`.`t1`.`b` AS `b` from `test`.`t1` +explain select distinct a1,a2,b from t1 where (a2 >= 'b') and (b = 'a'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 17 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select distinct `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`b` = 'a') and (`test`.`t1`.`a2` >= 'b')) +explain select distinct a1,a2,b,c from t1 where (a2 >= 'b') and (b = 'a') and (c = 'i121'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index idx_t1_1 idx_t1_1 163 NULL 128 0.78 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select distinct `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` where ((`test`.`t1`.`c` = 'i121') and (`test`.`t1`.`b` = 'a') and (`test`.`t1`.`a2` >= 'b')) +explain select distinct a1,a2,b from t1 where (a1 > 'a') and (a2 > 'a') and (b = 'c'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 14 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select distinct `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`b` = 'c') and (`test`.`t1`.`a1` > 'a') and (`test`.`t1`.`a2` > 'a')) +explain select distinct b from t1 where (a2 >= 'b') and (b = 'a'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index idx_t1_1,idx_t1_2 idx_t1_2 147 NULL 128 3.33 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select distinct `test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`b` = 'a') and (`test`.`t1`.`a2` >= 'b')) +explain select distinct a1,a2,b from t2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range idx_t2_1,idx_t2_2 idx_t2_1 146 NULL # 100.00 Using index for group-by +Warnings: +Note 1003 /* select#1 */ select distinct `test`.`t2`.`a1` AS `a1`,`test`.`t2`.`a2` AS `a2`,`test`.`t2`.`b` AS `b` from `test`.`t2` +explain select distinct a1,a2,b from t2 where (a2 >= 'b') and (b = 'a'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range idx_t2_1,idx_t2_2 idx_t2_1 146 NULL # 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select distinct `test`.`t2`.`a1` AS `a1`,`test`.`t2`.`a2` AS `a2`,`test`.`t2`.`b` AS `b` from `test`.`t2` where ((`test`.`t2`.`b` = 'a') and (`test`.`t2`.`a2` >= 'b')) +explain select distinct a1,a2,b,c from t2 where (a2 >= 'b') and (b = 'a') and (c = 'i121'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index idx_t2_1 idx_t2_1 163 NULL 164 0.61 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select distinct `test`.`t2`.`a1` AS `a1`,`test`.`t2`.`a2` AS `a2`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c` from `test`.`t2` where ((`test`.`t2`.`c` = 'i121') and (`test`.`t2`.`b` = 'a') and (`test`.`t2`.`a2` >= 'b')) +explain select distinct a1,a2,b from t2 where (a1 > 'a') and (a2 > 'a') and (b = 'c'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range idx_t2_0,idx_t2_1,idx_t2_2 idx_t2_1 146 NULL # 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select distinct `test`.`t2`.`a1` AS `a1`,`test`.`t2`.`a2` AS `a2`,`test`.`t2`.`b` AS `b` from `test`.`t2` where ((`test`.`t2`.`b` = 'c') and (`test`.`t2`.`a1` > 'a') and (`test`.`t2`.`a2` > 'a')) +explain select distinct b from t2 where (a2 >= 'b') and (b = 'a'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index idx_t2_1,idx_t2_2 idx_t2_2 146 NULL 164 3.33 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select distinct `test`.`t2`.`b` AS `b` from `test`.`t2` where ((`test`.`t2`.`b` = 'a') and (`test`.`t2`.`a2` >= 'b')) +select distinct a1,a2,b from t1; +a1 a2 b +a a a +a a b +a b a +a b b +b a a +b a b +b b a +b b b +c a a +c a b +c b a +c b b +d a a +d a b +d b a +d b b +select distinct a1,a2,b from t1 where (a2 >= 'b') and (b = 'a'); +a1 a2 b +a b a +b b a +c b a +d b a +select distinct a1,a2,b,c from t1 where (a2 >= 'b') and (b = 'a') and (c = 'i121'); +a1 a2 b c +a b a i121 +select distinct a1,a2,b from t1 where (a1 > 'a') and (a2 > 'a') and (b = 'c'); +a1 a2 b +select distinct b from t1 where (a2 >= 'b') and (b = 'a'); +b +a +select distinct a1,a2,b from t2; +a1 a2 b +a a NULL +a a a +a a b +a b a +a b b +b a a +b a b +b b a +b b b +c a NULL +c a a +c a b +c b a +c b b +d a a +d a b +d b a +d b b +e a a +e a b +select distinct a1,a2,b from t2 where (a2 >= 'b') and (b = 'a'); +a1 a2 b +a b a +b b a +c b a +d b a +select distinct a1,a2,b,c from t2 where (a2 >= 'b') and (b = 'a') and (c = 'i121'); +a1 a2 b c +a b a i121 +select distinct a1,a2,b from t2 where (a1 > 'a') and (a2 > 'a') and (b = 'c'); +a1 a2 b +select distinct b from t2 where (a2 >= 'b') and (b = 'a'); +b +a +select distinct t_00.a1 +from t1 t_00 +where exists ( select * from t2 where a1 = t_00.a1 ); +a1 +a +b +c +d +select distinct a1,a1 from t1; +a1 a1 +a a +b b +c c +d d +select distinct a2,a1,a2,a1 from t1; +a2 a1 a2 a1 +a a a a +a b a b +a c a c +a d a d +b a b a +b b b b +b c b c +b d b d +select distinct t1.a1,t2.a1 from t1,t2; +a1 a1 +a a +a b +a c +a d +a e +b a +b b +b c +b d +b e +c a +c b +c c +c d +c e +d a +d b +d c +d d +d e +explain select distinct a1,a2,b from t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 17 100.00 Using index for group-by +Warnings: +Note 1003 /* select#1 */ select distinct `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,`test`.`t1`.`b` AS `b` from `test`.`t1` +explain select distinct a1,a2,b from t1 where (a2 >= 'b') and (b = 'a') group by a1,a2,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 17 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`b` = 'a') and (`test`.`t1`.`a2` >= 'b')) group by `test`.`t1`.`a1`,`test`.`t1`.`a2` +explain select distinct a1,a2,b,c from t1 where (a2 >= 'b') and (b = 'a') and (c = 'i121') group by a1,a2,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range idx_t1_1,idx_t1_2 idx_t1_1 163 NULL 17 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` where ((`test`.`t1`.`c` = 'i121') and (`test`.`t1`.`b` = 'a') and (`test`.`t1`.`a2` >= 'b')) group by `test`.`t1`.`a1`,`test`.`t1`.`a2` +explain select distinct a1,a2,b from t1 where (a1 > 'a') and (a2 > 'a') and (b = 'c') group by a1,a2,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 14 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`b` = 'c') and (`test`.`t1`.`a1` > 'a') and (`test`.`t1`.`a2` > 'a')) group by `test`.`t1`.`a1`,`test`.`t1`.`a2` +explain select distinct b from t1 where (a2 >= 'b') and (b = 'a') group by a1,a2,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 17 100.00 Using where; Using index for group-by; Using temporary +Warnings: +Note 1003 /* select#1 */ select distinct `test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`b` = 'a') and (`test`.`t1`.`a2` >= 'b')) group by `test`.`t1`.`a1`,`test`.`t1`.`a2` +explain select distinct a1,a2,b from t2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range idx_t2_1,idx_t2_2 idx_t2_1 146 NULL # 100.00 Using index for group-by +Warnings: +Note 1003 /* select#1 */ select distinct `test`.`t2`.`a1` AS `a1`,`test`.`t2`.`a2` AS `a2`,`test`.`t2`.`b` AS `b` from `test`.`t2` +explain select distinct a1,a2,b from t2 where (a2 >= 'b') and (b = 'a') group by a1,a2,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range idx_t2_1,idx_t2_2 idx_t2_1 146 NULL # 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a1` AS `a1`,`test`.`t2`.`a2` AS `a2`,`test`.`t2`.`b` AS `b` from `test`.`t2` where ((`test`.`t2`.`b` = 'a') and (`test`.`t2`.`a2` >= 'b')) group by `test`.`t2`.`a1`,`test`.`t2`.`a2` +explain select distinct a1,a2,b,c from t2 where (a2 >= 'b') and (b = 'a') and (c = 'i121') group by a1,a2,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range idx_t2_1,idx_t2_2 idx_t2_1 163 NULL # 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a1` AS `a1`,`test`.`t2`.`a2` AS `a2`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c` from `test`.`t2` where ((`test`.`t2`.`c` = 'i121') and (`test`.`t2`.`b` = 'a') and (`test`.`t2`.`a2` >= 'b')) group by `test`.`t2`.`a1`,`test`.`t2`.`a2` +explain select distinct a1,a2,b from t2 where (a1 > 'a') and (a2 > 'a') and (b = 'c') group by a1,a2,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range idx_t2_0,idx_t2_1,idx_t2_2 idx_t2_1 146 NULL # 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a1` AS `a1`,`test`.`t2`.`a2` AS `a2`,`test`.`t2`.`b` AS `b` from `test`.`t2` where ((`test`.`t2`.`b` = 'c') and (`test`.`t2`.`a1` > 'a') and (`test`.`t2`.`a2` > 'a')) group by `test`.`t2`.`a1`,`test`.`t2`.`a2` +explain select distinct b from t2 where (a2 >= 'b') and (b = 'a') group by a1,a2,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range idx_t2_1,idx_t2_2 idx_t2_1 146 NULL # 100.00 Using where; Using index for group-by; Using temporary +Warnings: +Note 1003 /* select#1 */ select distinct `test`.`t2`.`b` AS `b` from `test`.`t2` where ((`test`.`t2`.`b` = 'a') and (`test`.`t2`.`a2` >= 'b')) group by `test`.`t2`.`a1`,`test`.`t2`.`a2` +select distinct a1,a2,b from t1; +a1 a2 b +a a a +a a b +a b a +a b b +b a a +b a b +b b a +b b b +c a a +c a b +c b a +c b b +d a a +d a b +d b a +d b b +select distinct a1,a2,b from t1 where (a2 >= 'b') and (b = 'a') group by a1,a2,b; +a1 a2 b +a b a +b b a +c b a +d b a +select distinct a1,a2,b,c from t1 where (a2 >= 'b') and (b = 'a') and (c = 'i121') group by a1,a2,b; +a1 a2 b c +a b a i121 +select distinct a1,a2,b from t1 where (a1 > 'a') and (a2 > 'a') and (b = 'c') group by a1,a2,b; +a1 a2 b +select distinct b from t1 where (a2 >= 'b') and (b = 'a') group by a1,a2,b; +b +a +select distinct a1,a2,b from t2; +a1 a2 b +a a NULL +a a a +a a b +a b a +a b b +b a a +b a b +b b a +b b b +c a NULL +c a a +c a b +c b a +c b b +d a a +d a b +d b a +d b b +e a a +e a b +select distinct a1,a2,b from t2 where (a2 >= 'b') and (b = 'a') group by a1,a2,b; +a1 a2 b +a b a +b b a +c b a +d b a +select distinct a1,a2,b,c from t2 where (a2 >= 'b') and (b = 'a') and (c = 'i121') group by a1,a2,b; +a1 a2 b c +a b a i121 +select distinct a1,a2,b from t2 where (a1 > 'a') and (a2 > 'a') and (b = 'c') group by a1,a2,b; +a1 a2 b +select distinct b from t2 where (a2 >= 'b') and (b = 'a') group by a1,a2,b; +b +a +explain select count(distinct a1,a2,b) from t1 where (a2 >= 'b') and (b = 'a'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 17 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select count(distinct `test`.`t1`.`a1`,`test`.`t1`.`a2`,`test`.`t1`.`b`) AS `count(distinct a1,a2,b)` from `test`.`t1` where ((`test`.`t1`.`b` = 'a') and (`test`.`t1`.`a2` >= 'b')) +explain select count(distinct a1,a2,b,c) from t1 where (a2 >= 'b') and (b = 'a') and (c = 'i121'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range idx_t1_1 idx_t1_1 163 NULL 65 100.00 Using where; Using index for group-by (scanning) +Warnings: +Note 1003 /* select#1 */ select count(distinct `test`.`t1`.`a1`,`test`.`t1`.`a2`,`test`.`t1`.`b`,`test`.`t1`.`c`) AS `count(distinct a1,a2,b,c)` from `test`.`t1` where ((`test`.`t1`.`c` = 'i121') and (`test`.`t1`.`b` = 'a') and (`test`.`t1`.`a2` >= 'b')) +explain select count(distinct a1,a2,b) from t1 where (a1 > 'a') and (a2 > 'a') and (b = 'c'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 14 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select count(distinct `test`.`t1`.`a1`,`test`.`t1`.`a2`,`test`.`t1`.`b`) AS `count(distinct a1,a2,b)` from `test`.`t1` where ((`test`.`t1`.`b` = 'c') and (`test`.`t1`.`a1` > 'a') and (`test`.`t1`.`a2` > 'a')) +explain select count(distinct b) from t1 where (a2 >= 'b') and (b = 'a'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index idx_t1_1,idx_t1_2 idx_t1_2 147 NULL 128 3.33 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select count(distinct `test`.`t1`.`b`) AS `count(distinct b)` from `test`.`t1` where ((`test`.`t1`.`b` = 'a') and (`test`.`t1`.`a2` >= 'b')) +explain select 98 + count(distinct a1,a2,b) from t1 where (a1 > 'a') and (a2 > 'a'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 14 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select (98 + count(distinct `test`.`t1`.`a1`,`test`.`t1`.`a2`,`test`.`t1`.`b`)) AS `98 + count(distinct a1,a2,b)` from `test`.`t1` where ((`test`.`t1`.`a1` > 'a') and (`test`.`t1`.`a2` > 'a')) +select count(distinct a1,a2,b) from t1 where (a2 >= 'b') and (b = 'a'); +count(distinct a1,a2,b) +4 +select count(distinct a1,a2,b,c) from t1 where (a2 >= 'b') and (b = 'a') and (c = 'i121'); +count(distinct a1,a2,b,c) +1 +select count(distinct a1,a2,b) from t1 where (a1 > 'a') and (a2 > 'a') and (b = 'c'); +count(distinct a1,a2,b) +0 +select count(distinct b) from t1 where (a2 >= 'b') and (b = 'a'); +count(distinct b) +1 +select 98 + count(distinct a1,a2,b) from t1 where (a1 > 'a') and (a2 > 'a'); +98 + count(distinct a1,a2,b) +104 +explain select a1,a2,b, concat(min(c), max(c)) from t1 where a1 < 'd' group by a1,a2,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 10 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,`test`.`t1`.`b` AS `b`,concat(min(`test`.`t1`.`c`),max(`test`.`t1`.`c`)) AS `concat(min(c), max(c))` from `test`.`t1` where (`test`.`t1`.`a1` < 'd') group by `test`.`t1`.`a1`,`test`.`t1`.`a2`,`test`.`t1`.`b` +explain select concat(a1,min(c)),b from t1 where a1 < 'd' group by a1,a2,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 10 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select concat(`test`.`t1`.`a1`,min(`test`.`t1`.`c`)) AS `concat(a1,min(c))`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (`test`.`t1`.`a1` < 'd') group by `test`.`t1`.`a1`,`test`.`t1`.`a2`,`test`.`t1`.`b` +explain select concat(a1,min(c)),b,max(c) from t1 where a1 < 'd' group by a1,a2,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 10 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select concat(`test`.`t1`.`a1`,min(`test`.`t1`.`c`)) AS `concat(a1,min(c))`,`test`.`t1`.`b` AS `b`,max(`test`.`t1`.`c`) AS `max(c)` from `test`.`t1` where (`test`.`t1`.`a1` < 'd') group by `test`.`t1`.`a1`,`test`.`t1`.`a2`,`test`.`t1`.`b` +explain select concat(a1,a2),b,min(c),max(c) from t1 where a1 < 'd' group by a1,a2,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 10 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select concat(`test`.`t1`.`a1`,`test`.`t1`.`a2`) AS `concat(a1,a2)`,`test`.`t1`.`b` AS `b`,min(`test`.`t1`.`c`) AS `min(c)`,max(`test`.`t1`.`c`) AS `max(c)` from `test`.`t1` where (`test`.`t1`.`a1` < 'd') group by `test`.`t1`.`a1`,`test`.`t1`.`a2`,`test`.`t1`.`b` +explain select concat(ord(min(b)),ord(max(b))),min(b),max(b) from t1 group by a1,a2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 9 100.00 Using index for group-by +Warnings: +Note 1003 /* select#1 */ select concat(ord(min(`test`.`t1`.`b`)),ord(max(`test`.`t1`.`b`))) AS `concat(ord(min(b)),ord(max(b)))`,min(`test`.`t1`.`b`) AS `min(b)`,max(`test`.`t1`.`b`) AS `max(b)` from `test`.`t1` group by `test`.`t1`.`a1`,`test`.`t1`.`a2` +select a1,a2,b, concat(min(c), max(c)) from t1 where a1 < 'd' group by a1,a2,b; +a1 a2 b concat(min(c), max(c)) +a a a a111d111 +a a b e112h112 +a b a i121l121 +a b b m122p122 +b a a a211d211 +b a b e212h212 +b b a i221l221 +b b b m222p222 +c a a a311d311 +c a b e312h312 +c b a i321l321 +c b b m322p322 +select concat(a1,min(c)),b from t1 where a1 < 'd' group by a1,a2,b; +concat(a1,min(c)) b +aa111 a +ae112 b +ai121 a +am122 b +ba211 a +be212 b +bi221 a +bm222 b +ca311 a +ce312 b +ci321 a +cm322 b +select concat(a1,min(c)),b,max(c) from t1 where a1 < 'd' group by a1,a2,b; +concat(a1,min(c)) b max(c) +aa111 a d111 +ae112 b h112 +ai121 a l121 +am122 b p122 +ba211 a d211 +be212 b h212 +bi221 a l221 +bm222 b p222 +ca311 a d311 +ce312 b h312 +ci321 a l321 +cm322 b p322 +select concat(a1,a2),b,min(c),max(c) from t1 where a1 < 'd' group by a1,a2,b; +concat(a1,a2) b min(c) max(c) +aa a a111 d111 +aa b e112 h112 +ab a i121 l121 +ab b m122 p122 +ba a a211 d211 +ba b e212 h212 +bb a i221 l221 +bb b m222 p222 +ca a a311 d311 +ca b e312 h312 +cb a i321 l321 +cb b m322 p322 +select concat(ord(min(b)),ord(max(b))),min(b),max(b) from t1 group by a1,a2; +concat(ord(min(b)),ord(max(b))) min(b) max(b) +9798 a b +9798 a b +9798 a b +9798 a b +9798 a b +9798 a b +9798 a b +9798 a b +explain select a1,a2,b,d,min(c),max(c) from t1 group by a1,a2,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index idx_t1_1,idx_t1_2 idx_t1_2 147 NULL 128 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`d` AS `d`,min(`test`.`t1`.`c`) AS `min(c)`,max(`test`.`t1`.`c`) AS `max(c)` from `test`.`t1` group by `test`.`t1`.`a1`,`test`.`t1`.`a2`,`test`.`t1`.`b` +explain select a1,a2,b,d from t1 group by a1,a2,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index idx_t1_1,idx_t1_2 idx_t1_2 147 NULL 128 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`d` AS `d` from `test`.`t1` group by `test`.`t1`.`a1`,`test`.`t1`.`a2`,`test`.`t1`.`b` +explain select a1,a2,min(b),max(b) from t1 +where (a1 = 'b' or a1 = 'd' or a1 = 'a' or a1 = 'c') and (a2 > 'a') and (c > 'a111') group by a1,a2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 130 NULL 76 33.33 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,min(`test`.`t1`.`b`) AS `min(b)`,max(`test`.`t1`.`b`) AS `max(b)` from `test`.`t1` where (((`test`.`t1`.`a1` = 'b') or (`test`.`t1`.`a1` = 'd') or (`test`.`t1`.`a1` = 'a') or (`test`.`t1`.`a1` = 'c')) and (`test`.`t1`.`a2` > 'a') and (`test`.`t1`.`c` > 'a111')) group by `test`.`t1`.`a1`,`test`.`t1`.`a2` +explain select a1,a2,b,min(c),max(c) from t1 +where (a1 = 'b' or a1 = 'd' or a1 = 'a' or a1 = 'c') and (a2 > 'a') and (d > 'xy2') group by a1,a2,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_2 147 NULL 128 11.02 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,`test`.`t1`.`b` AS `b`,min(`test`.`t1`.`c`) AS `min(c)`,max(`test`.`t1`.`c`) AS `max(c)` from `test`.`t1` where (((`test`.`t1`.`a1` = 'b') or (`test`.`t1`.`a1` = 'd') or (`test`.`t1`.`a1` = 'a') or (`test`.`t1`.`a1` = 'c')) and (`test`.`t1`.`a2` > 'a') and (`test`.`t1`.`d` > 'xy2')) group by `test`.`t1`.`a1`,`test`.`t1`.`a2`,`test`.`t1`.`b` +explain select a1,a2,b,c from t1 +where (a1 = 'b' or a1 = 'd' or a1 = 'a' or a1 = 'c') and (a2 > 'a') and (d > 'xy2') group by a1,a2,b,c; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 163 NULL 128 11.02 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` where (((`test`.`t1`.`a1` = 'b') or (`test`.`t1`.`a1` = 'd') or (`test`.`t1`.`a1` = 'a') or (`test`.`t1`.`a1` = 'c')) and (`test`.`t1`.`a2` > 'a') and (`test`.`t1`.`d` > 'xy2')) group by `test`.`t1`.`a1`,`test`.`t1`.`a2`,`test`.`t1`.`b`,`test`.`t1`.`c` +explain select a1,a2,b,max(c),min(c) from t2 where (a2 = 'a') and (b = 'b') or (b < 'b') group by a1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index idx_t2_0,idx_t2_1,idx_t2_2 idx_t2_1 163 NULL 164 34.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a1` AS `a1`,`test`.`t2`.`a2` AS `a2`,`test`.`t2`.`b` AS `b`,max(`test`.`t2`.`c`) AS `max(c)`,min(`test`.`t2`.`c`) AS `min(c)` from `test`.`t2` where (((`test`.`t2`.`b` = 'b') and (`test`.`t2`.`a2` = 'a')) or (`test`.`t2`.`b` < 'b')) group by `test`.`t2`.`a1` +explain select a1,a2,b from t1 where (a1 = 'b' or a1 = 'd' or a1 = 'a' or a1 = 'c') and (a2 > 'a') and (c > 'a111') group by a1,a2,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 130 NULL 76 33.33 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (((`test`.`t1`.`a1` = 'b') or (`test`.`t1`.`a1` = 'd') or (`test`.`t1`.`a1` = 'a') or (`test`.`t1`.`a1` = 'c')) and (`test`.`t1`.`a2` > 'a') and (`test`.`t1`.`c` > 'a111')) group by `test`.`t1`.`a1`,`test`.`t1`.`a2`,`test`.`t1`.`b` +explain select a1,a2,min(b),c from t2 where (a2 = 'a') and (c = 'a111') group by a1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index idx_t2_0,idx_t2_1,idx_t2_2 idx_t2_1 163 NULL 164 1.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a1` AS `a1`,`test`.`t2`.`a2` AS `a2`,min(`test`.`t2`.`b`) AS `min(b)`,`test`.`t2`.`c` AS `c` from `test`.`t2` where ((`test`.`t2`.`c` = 'a111') and (`test`.`t2`.`a2` = 'a')) group by `test`.`t2`.`a1` +select a1,a2,min(b),c from t2 where (a2 = 'a') and (c = 'a111') group by a1; +a1 a2 min(b) c +a a a a111 +explain select a1,a2,b,max(c),min(c) from t2 where (a2 = 'a') and (b = 'b') or (b = 'a') group by a1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index idx_t2_0,idx_t2_1,idx_t2_2 idx_t2_1 163 NULL 164 10.90 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a1` AS `a1`,`test`.`t2`.`a2` AS `a2`,`test`.`t2`.`b` AS `b`,max(`test`.`t2`.`c`) AS `max(c)`,min(`test`.`t2`.`c`) AS `min(c)` from `test`.`t2` where (((`test`.`t2`.`b` = 'b') and (`test`.`t2`.`a2` = 'a')) or (`test`.`t2`.`b` = 'a')) group by `test`.`t2`.`a1` +explain select a1,a2,b,min(c),max(c) from t2 +where (c > 'a000') and (c <= 'd999') and (c like '_8__') group by a1,a2,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index idx_t2_1,idx_t2_2 idx_t2_1 163 NULL 164 1.23 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a1` AS `a1`,`test`.`t2`.`a2` AS `a2`,`test`.`t2`.`b` AS `b`,min(`test`.`t2`.`c`) AS `min(c)`,max(`test`.`t2`.`c`) AS `max(c)` from `test`.`t2` where ((`test`.`t2`.`c` > 'a000') and (`test`.`t2`.`c` <= 'd999') and (`test`.`t2`.`c` like '_8__')) group by `test`.`t2`.`a1`,`test`.`t2`.`a2`,`test`.`t2`.`b` +explain select a1, a2, b, c, min(d), max(d) from t1 group by a1,a2,b,c; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index idx_t1_1 idx_t1_1 163 NULL 128 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c`,min(`test`.`t1`.`d`) AS `min(d)`,max(`test`.`t1`.`d`) AS `max(d)` from `test`.`t1` group by `test`.`t1`.`a1`,`test`.`t1`.`a2`,`test`.`t1`.`b`,`test`.`t1`.`c` +explain select a1,a2,count(a2) from t1 group by a1,a2,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index idx_t1_1,idx_t1_2 idx_t1_2 147 NULL 128 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,count(`test`.`t1`.`a2`) AS `count(a2)` from `test`.`t1` group by `test`.`t1`.`a1`,`test`.`t1`.`a2`,`test`.`t1`.`b` +explain select a1,a2,count(a2) from t1 where (a1 > 'a') group by a1,a2,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_2 65 NULL 102 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,count(`test`.`t1`.`a2`) AS `count(a2)` from `test`.`t1` where (`test`.`t1`.`a1` > 'a') group by `test`.`t1`.`a1`,`test`.`t1`.`a2`,`test`.`t1`.`b` +explain select sum(ord(a1)) from t1 where (a1 > 'a') group by a1,a2,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_2 65 NULL 102 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select sum(ord(`test`.`t1`.`a1`)) AS `sum(ord(a1))` from `test`.`t1` where (`test`.`t1`.`a1` > 'a') group by `test`.`t1`.`a1`,`test`.`t1`.`a2`,`test`.`t1`.`b` +explain select distinct(a1) from t1 where ord(a2) = 98; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_2 147 NULL 128 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select distinct `test`.`t1`.`a1` AS `a1` from `test`.`t1` where (ord(`test`.`t1`.`a2`) = 98) +select distinct(a1) from t1 where ord(a2) = 98; +a1 +a +b +c +d +explain select a1 from t1 where a2 = 'b' group by a1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 130 NULL 5 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1` from `test`.`t1` where (`test`.`t1`.`a2` = 'b') group by `test`.`t1`.`a1` +select a1 from t1 where a2 = 'b' group by a1; +a1 +a +b +c +d +explain select distinct a1 from t1 where a2 = 'b'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 130 NULL 5 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select distinct `test`.`t1`.`a1` AS `a1` from `test`.`t1` where (`test`.`t1`.`a2` = 'b') +select distinct a1 from t1 where a2 = 'b'; +a1 +a +b +c +d +drop table t1,t2,t3; +create table t1 (c1 int not null,c2 int not null, primary key(c1,c2)); +insert into t1 (c1,c2) values +(10,1),(10,2),(10,3),(20,4),(20,5),(20,6),(30,7),(30,8),(30,9); +select distinct c1, c2 from t1 order by c2; +c1 c2 +10 1 +10 2 +10 3 +20 4 +20 5 +20 6 +30 7 +30 8 +30 9 +select c1,min(c2) as c2 from t1 group by c1 order by c2; +c1 c2 +10 1 +20 4 +30 7 +select c1,c2 from t1 group by c1,c2 order by c2; +c1 c2 +10 1 +10 2 +10 3 +20 4 +20 5 +20 6 +30 7 +30 8 +30 9 +drop table t1; +CREATE TABLE t1 (a varchar(5), b int(11), PRIMARY KEY (a,b)) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES ('AA',1), ('AA',2), ('AA',3), ('BB',1), ('AA',4); +OPTIMIZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 optimize status OK +SELECT a FROM t1 WHERE a='AA' GROUP BY a; +a +AA +SELECT a FROM t1 WHERE a='BB' GROUP BY a; +a +BB +EXPLAIN SELECT a FROM t1 WHERE a='AA' GROUP BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range PRIMARY PRIMARY 22 NULL 1 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` = 'AA') group by `test`.`t1`.`a` +EXPLAIN SELECT a FROM t1 WHERE a='BB' GROUP BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ref PRIMARY PRIMARY 22 const 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` = 'BB') group by `test`.`t1`.`a` +SELECT DISTINCT a FROM t1 WHERE a='BB'; +a +BB +SELECT DISTINCT a FROM t1 WHERE a LIKE 'B%'; +a +BB +SELECT a FROM t1 WHERE a LIKE 'B%' GROUP BY a; +a +BB +DROP TABLE t1; +CREATE TABLE t1 ( +a int(11) NOT NULL DEFAULT '0', +b varchar(16) COLLATE latin1_general_ci NOT NULL DEFAULT '', +PRIMARY KEY (a,b) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE PROCEDURE a(x INT) +BEGIN +DECLARE rnd INT; +DECLARE cnt INT; +WHILE x > 0 DO +SET rnd= x % 100; +SET cnt = (SELECT COUNT(*) FROM t1 WHERE a = rnd); +INSERT INTO t1(a,b) VALUES (rnd, CAST(cnt AS CHAR)); +SET x= x - 1; +END WHILE; +END| +CALL a(1000); +SELECT a FROM t1 WHERE a=0; +a +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +SELECT DISTINCT a FROM t1 WHERE a=0; +a +0 +SELECT COUNT(DISTINCT a) FROM t1 WHERE a=0; +COUNT(DISTINCT a) +1 +DROP TABLE t1; +DROP PROCEDURE a; +CREATE TABLE t1 (a varchar(64) NOT NULL default '', PRIMARY KEY(a)) charset utf8mb4; +INSERT INTO t1 (a) VALUES +(''), ('CENTRAL'), ('EASTERN'), ('GREATER LONDON'), +('NORTH CENTRAL'), ('NORTH EAST'), ('NORTH WEST'), ('SCOTLAND'), +('SOUTH EAST'), ('SOUTH WEST'), ('WESTERN'); +EXPLAIN SELECT DISTINCT a,a FROM t1 ORDER BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index PRIMARY PRIMARY 258 NULL 11 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select distinct `test`.`t1`.`a` AS `a`,`test`.`t1`.`a` AS `a` from `test`.`t1` order by `test`.`t1`.`a` +SELECT DISTINCT a,a FROM t1 ORDER BY a; +a a + +CENTRAL CENTRAL +EASTERN EASTERN +GREATER LONDON GREATER LONDON +NORTH CENTRAL NORTH CENTRAL +NORTH EAST NORTH EAST +NORTH WEST NORTH WEST +SCOTLAND SCOTLAND +SOUTH EAST SOUTH EAST +SOUTH WEST SOUTH WEST +WESTERN WESTERN +DROP TABLE t1; +CREATE TABLE t1 (id1 INT, id2 INT); +CREATE TABLE t2 (id2 INT, id3 INT, id5 INT); +CREATE TABLE t3 (id3 INT, id4 INT); +CREATE TABLE t4 (id4 INT); +CREATE TABLE t5 (id5 INT, id6 INT); +CREATE TABLE t6 (id6 INT); +INSERT INTO t1 VALUES(1,1); +INSERT INTO t2 VALUES(1,1,1); +INSERT INTO t3 VALUES(1,1); +INSERT INTO t4 VALUES(1); +INSERT INTO t5 VALUES(1,1); +INSERT INTO t6 VALUES(1); +SELECT * FROM +t1 +NATURAL JOIN +(t2 JOIN (t3 NATURAL JOIN t4, t5 NATURAL JOIN t6) +ON (t3.id3 = t2.id3 AND t5.id5 = t2.id5)); +id2 id1 id3 id5 id4 id3 id6 id5 +1 1 1 1 1 1 1 1 +SELECT * FROM +t1 +NATURAL JOIN +(((t3 NATURAL JOIN t4) join (t5 NATURAL JOIN t6) on t3.id4 = t5.id5) JOIN t2 +ON (t3.id3 = t2.id3 AND t5.id5 = t2.id5)); +id2 id1 id4 id3 id6 id5 id3 id5 +1 1 1 1 1 1 1 1 +SELECT * FROM t1 NATURAL JOIN ((t3 join (t5 NATURAL JOIN t6)) JOIN t2); +id2 id1 id3 id4 id6 id5 id3 id5 +1 1 1 1 1 1 1 1 +SELECT * FROM +(t2 JOIN (t3 NATURAL JOIN t4, t5 NATURAL JOIN t6) +ON (t3.id3 = t2.id3 AND t5.id5 = t2.id5)) +NATURAL JOIN +t1; +id2 id3 id5 id4 id3 id6 id5 id1 +1 1 1 1 1 1 1 1 +SELECT * FROM +(t2 JOIN ((t3 NATURAL JOIN t4) join (t5 NATURAL JOIN t6))) +NATURAL JOIN +t1; +id2 id3 id5 id4 id3 id6 id5 id1 +1 1 1 1 1 1 1 1 +DROP TABLE t1,t2,t3,t4,t5,t6; +CREATE TABLE t1 (a int, b int, PRIMARY KEY (a,b), KEY b (b)); +INSERT INTO t1 VALUES (1,1),(1,2),(1,0),(1,3); +INSERT INTO t1 VALUES (2,1),(2,2),(2,0),(2,3); +INSERT INTO t1 VALUES (3,1),(3,2),(3,0),(3,3); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +explain SELECT MAX(b), a FROM t1 WHERE b < 2 AND a = 1 GROUP BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range PRIMARY,b PRIMARY 8 NULL 1 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select max(`test`.`t1`.`b`) AS `MAX(b)`,`test`.`t1`.`a` AS `a` from `test`.`t1` where ((`test`.`t1`.`a` = 1) and (`test`.`t1`.`b` < 2)) group by `test`.`t1`.`a` +SELECT MAX(b), a FROM t1 WHERE b < 2 AND a = 1 GROUP BY a; +MAX(b) a +1 1 +SELECT MIN(b), a FROM t1 WHERE b > 1 AND a = 1 GROUP BY a; +MIN(b) a +2 1 +CREATE TABLE t2 (a int, b int, c int, PRIMARY KEY (a,b,c)); +INSERT INTO t2 SELECT a,b,b FROM t1; +ANALYZE TABLE t2; +Table Op Msg_type Msg_text +test.t2 analyze status OK +explain SELECT MIN(c) FROM t2 WHERE b = 2 and a = 1 and c > 1 GROUP BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range PRIMARY PRIMARY 12 NULL 1 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select min(`test`.`t2`.`c`) AS `MIN(c)` from `test`.`t2` where ((`test`.`t2`.`a` = 1) and (`test`.`t2`.`b` = 2) and (`test`.`t2`.`c` > 1)) group by `test`.`t2`.`a` +SELECT MIN(c) FROM t2 WHERE b = 2 and a = 1 and c > 1 GROUP BY a; +MIN(c) +2 +DROP TABLE t1,t2; +CREATE TABLE t1 (a INT, b INT, INDEX (a,b)); +INSERT INTO t1 (a, b) VALUES (1,1), (1,2), (1,3), (1,4), (1,5), +(2,2), (2,3), (2,1), (3,1), (4,1), (4,2), (4,3), (4,4), (4,5), (4,6), +(5,1), (5,2), (5,3), (5,4), (5,5); +EXPLAIN SELECT max(b), a FROM t1 GROUP BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range a a 5 NULL 11 100.00 Using index for group-by +Warnings: +Note 1003 /* select#1 */ select max(`test`.`t1`.`b`) AS `max(b)`,`test`.`t1`.`a` AS `a` from `test`.`t1` group by `test`.`t1`.`a` +FLUSH STATUS; +SELECT max(b), a FROM t1 GROUP BY a; +max(b) a +5 1 +3 2 +1 3 +6 4 +5 5 +SHOW STATUS LIKE 'handler_read__e%'; +Variable_name Value +Handler_read_key 10 +Handler_read_next 0 +EXPLAIN SELECT max(b), a FROM t1 GROUP BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range a a 5 NULL 11 100.00 Using index for group-by +Warnings: +Note 1003 /* select#1 */ select max(`test`.`t1`.`b`) AS `max(b)`,`test`.`t1`.`a` AS `a` from `test`.`t1` group by `test`.`t1`.`a` +FLUSH STATUS; +CREATE TABLE t2 SELECT max(b), a FROM t1 GROUP BY a; +SHOW STATUS LIKE 'handler_read__e%'; +Variable_name Value +Handler_read_key 24 +Handler_read_next 2 +FLUSH STATUS; +SELECT * FROM (SELECT max(b), a FROM t1 GROUP BY a) b; +max(b) a +5 1 +3 2 +1 3 +6 4 +5 5 +SHOW STATUS LIKE 'handler_read__e%'; +Variable_name Value +Handler_read_key 10 +Handler_read_next 0 +FLUSH STATUS; +(SELECT max(b), a FROM t1 GROUP BY a) UNION +(SELECT max(b), a FROM t1 GROUP BY a); +max(b) a +5 1 +3 2 +1 3 +6 4 +5 5 +SHOW STATUS LIKE 'handler_read__e%'; +Variable_name Value +Handler_read_key 20 +Handler_read_next 0 +EXPLAIN (SELECT max(b), a FROM t1 GROUP BY a) UNION +(SELECT max(b), a FROM t1 GROUP BY a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL range a a 5 NULL 11 100.00 Using index for group-by +2 UNION t1 NULL range a a 5 NULL 11 100.00 Using index for group-by +NULL UNION RESULT NULL ALL NULL NULL NULL NULL NULL NULL Using temporary +Warnings: +Note 1003 /* select#1 */ select max(`test`.`t1`.`b`) AS `max(b)`,`test`.`t1`.`a` AS `a` from `test`.`t1` group by `test`.`t1`.`a` union /* select#2 */ select max(`test`.`t1`.`b`) AS `max(b)`,`test`.`t1`.`a` AS `a` from `test`.`t1` group by `test`.`t1`.`a` +EXPLAIN SELECT (SELECT max(b) FROM t1 GROUP BY a HAVING a < 2) x +FROM t1 AS t1_outer; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_outer NULL index NULL a 10 NULL 20 100.00 Using index +2 SUBQUERY t1 NULL range a a 5 NULL 11 100.00 Using index for group-by +Warnings: +Note 1003 /* select#1 */ select (/* select#2 */ select max(`test`.`t1`.`b`) from `test`.`t1` group by `test`.`t1`.`a` having (`test`.`t1`.`a` < 2)) AS `x` from `test`.`t1` `t1_outer` +EXPLAIN SELECT 1 FROM t1 AS t1_outer WHERE EXISTS +(SELECT max(b) FROM t1 GROUP BY a HAVING a < 2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_outer NULL index NULL a 10 NULL 20 100.00 Using index +2 SUBQUERY t1 NULL range a a 5 NULL 11 100.00 Using index for group-by +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` `t1_outer` where true +EXPLAIN SELECT 1 FROM t1 AS t1_outer WHERE +(SELECT max(b) FROM t1 GROUP BY a HAVING a < 2) > 12; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +2 SUBQUERY t1 NULL range a a 5 NULL 11 100.00 Using index for group-by +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` `t1_outer` where false +EXPLAIN SELECT 1 FROM t1 AS t1_outer WHERE +a IN (SELECT max(b) FROM t1 GROUP BY a HAVING a < 2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_outer NULL index NULL a 10 NULL 20 100.00 Using where; Using index +2 SUBQUERY t1 NULL range a a 5 NULL 11 100.00 Using index for group-by +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` `t1_outer` where (`test`.`t1_outer`.`a`,`test`.`t1_outer`.`a` in ( (/* select#2 */ select max(`test`.`t1`.`b`) from `test`.`t1` group by `test`.`t1`.`a` having (`test`.`t1`.`a` < 2) ), (`test`.`t1_outer`.`a` in on where ((`test`.`t1_outer`.`a` = ``.`max(b)`))))) +EXPLAIN SELECT 1 FROM t1 AS t1_outer GROUP BY a HAVING +a > (SELECT max(b) FROM t1 GROUP BY a HAVING a < 2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_outer NULL range a a 5 NULL 11 100.00 Using index for group-by +2 SUBQUERY t1 NULL range a a 5 NULL 11 100.00 Using index for group-by +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` `t1_outer` group by `test`.`t1_outer`.`a` having (`test`.`t1_outer`.`a` > (/* select#2 */ select max(`test`.`t1`.`b`) from `test`.`t1` group by `test`.`t1`.`a` having (`test`.`t1`.`a` < 2))) +EXPLAIN SELECT 1 FROM t1 AS t1_outer1 JOIN t1 AS t1_outer2 +ON t1_outer1.a = (SELECT max(b) FROM t1 GROUP BY a HAVING a < 2) +AND t1_outer1.b = t1_outer2.b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_outer1 NULL ref a a 5 const 5 100.00 Using where; Using index +1 PRIMARY t1_outer2 NULL index NULL a 10 NULL 20 10.00 Using where; Using index; Using join buffer (hash join) +2 SUBQUERY t1 NULL range a a 5 NULL 11 100.00 Using index for group-by +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` `t1_outer1` join `test`.`t1` `t1_outer2` where ((`test`.`t1_outer2`.`b` = `test`.`t1_outer1`.`b`) and (`test`.`t1_outer1`.`a` = (/* select#2 */ select max(`test`.`t1`.`b`) from `test`.`t1` group by `test`.`t1`.`a` having (`test`.`t1`.`a` < 2)))) +EXPLAIN SELECT (SELECT (SELECT max(b) FROM t1 GROUP BY a HAVING a < 2) x +FROM t1 AS t1_outer) x2 FROM t1 AS t1_outer2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_outer2 NULL index NULL a 10 NULL 20 100.00 Using index +2 SUBQUERY t1_outer NULL index NULL a 10 NULL 20 100.00 Using index +3 SUBQUERY t1 NULL range a a 5 NULL 11 100.00 Using index for group-by +Warnings: +Note 1003 /* select#1 */ select (/* select#2 */ select (/* select#3 */ select max(`test`.`t1`.`b`) from `test`.`t1` group by `test`.`t1`.`a` having (`test`.`t1`.`a` < 2)) AS `x` from `test`.`t1` `t1_outer`) AS `x2` from `test`.`t1` `t1_outer2` +CREATE TABLE t3 LIKE t1; +# Warm-up data-dictionary cache. +FLUSH STATUS; +INSERT INTO t3 SELECT a,MAX(b) FROM t1 GROUP BY a; +SHOW STATUS LIKE 'handler_read__e%'; +Variable_name Value +Handler_read_key 10 +Handler_read_next 0 +DELETE FROM t3; +FLUSH STATUS; +INSERT INTO t3 SELECT 1, (SELECT MAX(b) FROM t1 GROUP BY a HAVING a < 2) +FROM t1 LIMIT 1; +SHOW STATUS LIKE 'handler_read__e%'; +Variable_name Value +Handler_read_key 10 +Handler_read_next 0 +FLUSH STATUS; +DELETE FROM t3 WHERE (SELECT MAX(b) FROM t1 GROUP BY a HAVING a < 2) > 10000; +SHOW STATUS LIKE 'handler_read__e%'; +Variable_name Value +Handler_read_key 10 +Handler_read_next 0 +FLUSH STATUS; +DELETE FROM t3 WHERE (SELECT (SELECT MAX(b) FROM t1 GROUP BY a HAVING a < 2) x +FROM t1) > 10000; +ERROR 21000: Subquery returns more than 1 row +SHOW STATUS LIKE 'handler_read__e%'; +Variable_name Value +Handler_read_key 10 +Handler_read_next 1 +DROP TABLE t1,t2,t3; +CREATE TABLE t1 (a int, INDEX idx(a)); +INSERT INTO t1 VALUES +(4), (2), (1), (2), (4), (2), (1), (4), +(4), (2), (1), (2), (2), (4), (1), (4), +(4), (2), (1), (2), (2), (4), (1), (4); +EXPLAIN SELECT DISTINCT(a) FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range idx idx 5 NULL 10 100.00 Using index for group-by +Warnings: +Note 1003 /* select#1 */ select distinct `test`.`t1`.`a` AS `a` from `test`.`t1` +SELECT DISTINCT(a) FROM t1; +a +1 +2 +4 +EXPLAIN SELECT SQL_BIG_RESULT DISTINCT(a) FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range idx idx 5 NULL 10 100.00 Using index for group-by +Warnings: +Note 1003 /* select#1 */ select distinct sql_big_result `test`.`t1`.`a` AS `a` from `test`.`t1` +SELECT SQL_BIG_RESULT DISTINCT(a) FROM t1; +a +1 +2 +4 +DROP TABLE t1; +CREATE TABLE t1 (a INT, b INT); +INSERT INTO t1 (a, b) VALUES (1,1), (1,2), (1,3); +INSERT INTO t1 SELECT a + 1, b FROM t1; +INSERT INTO t1 SELECT a + 2, b FROM t1; +INSERT INTO t1 SELECT a + 4, b FROM t1; +EXPLAIN +SELECT a, MIN(b), MAX(b) FROM t1 GROUP BY a ORDER BY a DESC; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 24 100.00 Using temporary; Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,min(`test`.`t1`.`b`) AS `MIN(b)`,max(`test`.`t1`.`b`) AS `MAX(b)` from `test`.`t1` group by `test`.`t1`.`a` desc order by `test`.`t1`.`a` desc +SELECT a, MIN(b), MAX(b) FROM t1 GROUP BY a ORDER BY a DESC; +a MIN(b) MAX(b) +8 1 3 +7 1 3 +6 1 3 +5 1 3 +4 1 3 +3 1 3 +2 1 3 +1 1 3 +CREATE INDEX break_it ON t1 (a, b); +EXPLAIN +SELECT a, MIN(b), MAX(b) FROM t1 GROUP BY a ORDER BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range break_it break_it 10 NULL 10 100.00 Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,min(`test`.`t1`.`b`) AS `MIN(b)`,max(`test`.`t1`.`b`) AS `MAX(b)` from `test`.`t1` group by `test`.`t1`.`a` order by `test`.`t1`.`a` +SELECT a, MIN(b), MAX(b) FROM t1 GROUP BY a ORDER BY a; +a MIN(b) MAX(b) +1 1 3 +2 1 3 +3 1 3 +4 1 3 +5 1 3 +6 1 3 +7 1 3 +8 1 3 +EXPLAIN +SELECT a, MIN(b), MAX(b) FROM t1 GROUP BY a ORDER BY a DESC; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range break_it break_it 10 NULL 10 100.00 Using index for group-by; Using temporary; Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,min(`test`.`t1`.`b`) AS `MIN(b)`,max(`test`.`t1`.`b`) AS `MAX(b)` from `test`.`t1` group by `test`.`t1`.`a` desc order by `test`.`t1`.`a` desc +SELECT a, MIN(b), MAX(b) FROM t1 GROUP BY a ORDER BY a DESC; +a MIN(b) MAX(b) +8 1 3 +7 1 3 +6 1 3 +5 1 3 +4 1 3 +3 1 3 +2 1 3 +1 1 3 +EXPLAIN +SELECT a, MIN(b), MAX(b), AVG(b) FROM t1 GROUP BY a ORDER BY a DESC; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index break_it break_it 10 NULL 24 100.00 Backward index scan; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,min(`test`.`t1`.`b`) AS `MIN(b)`,max(`test`.`t1`.`b`) AS `MAX(b)`,avg(`test`.`t1`.`b`) AS `AVG(b)` from `test`.`t1` group by `test`.`t1`.`a` desc order by `test`.`t1`.`a` desc +SELECT a, MIN(b), MAX(b), AVG(b) FROM t1 GROUP BY a ORDER BY a DESC; +a MIN(b) MAX(b) AVG(b) +8 1 3 2.0000 +7 1 3 2.0000 +6 1 3 2.0000 +5 1 3 2.0000 +4 1 3 2.0000 +3 1 3 2.0000 +2 1 3 2.0000 +1 1 3 2.0000 +DROP TABLE t1; +create table t1 (a int, b int, primary key (a,b), key `index` (a,b)) engine=MyISAM; +insert into t1 (a,b) values +(0,0),(0,1),(0,2),(0,3),(0,4),(0,5),(0,6), +(0,7),(0,8),(0,9),(0,10),(0,11),(0,12),(0,13), +(1,0),(1,1),(1,2),(1,3),(1,4),(1,5),(1,6), +(1,7),(1,8),(1,9),(1,10),(1,11),(1,12),(1,13), +(2,0),(2,1),(2,2),(2,3),(2,4),(2,5),(2,6), +(2,7),(2,8),(2,9),(2,10),(2,11),(2,12),(2,13), +(3,0),(3,1),(3,2),(3,3),(3,4),(3,5),(3,6), +(3,7),(3,8),(3,9),(3,10),(3,11),(3,12),(3,13); +insert into t1 (a,b) select a, max(b)+1 from t1 where a = 0 group by a; +select * from t1; +a b +0 0 +0 1 +0 10 +0 11 +0 12 +0 13 +0 14 +0 2 +0 3 +0 4 +0 5 +0 6 +0 7 +0 8 +0 9 +1 0 +1 1 +1 10 +1 11 +1 12 +1 13 +1 2 +1 3 +1 4 +1 5 +1 6 +1 7 +1 8 +1 9 +2 0 +2 1 +2 10 +2 11 +2 12 +2 13 +2 2 +2 3 +2 4 +2 5 +2 6 +2 7 +2 8 +2 9 +3 0 +3 1 +3 10 +3 11 +3 12 +3 13 +3 2 +3 3 +3 4 +3 5 +3 6 +3 7 +3 8 +3 9 +explain select sql_buffer_result a, max(b)+1 from t1 where a = 0 group by a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range PRIMARY,index index 4 NULL 3 100.00 Using where; Using index for group-by; Using temporary +Warnings: +Note 1003 /* select#1 */ select sql_buffer_result `test`.`t1`.`a` AS `a`,(max(`test`.`t1`.`b`) + 1) AS `max(b)+1` from `test`.`t1` where (`test`.`t1`.`a` = 0) group by `test`.`t1`.`a` +drop table t1; +CREATE TABLE t1 (a int, b int, c int, d int, +KEY foo (c,d,a,b), KEY bar (c,a,b,d)); +INSERT INTO t1 VALUES (1, 1, 1, 1), (1, 1, 1, 2), (1, 1, 1, 3), (1, 1, 1, 4); +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT a,b,c+1,d FROM t1; +EXPLAIN SELECT DISTINCT c FROM t1 WHERE d=4; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range foo,bar foo 10 NULL 10 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select distinct `test`.`t1`.`c` AS `c` from `test`.`t1` where (`test`.`t1`.`d` = 4) +SELECT DISTINCT c FROM t1 WHERE d=4; +c +1 +2 +DROP TABLE t1; +# +# Bug #45386: Wrong query result with MIN function in field list, +# WHERE and GROUP BY clause +# +CREATE TABLE t (a INT, b INT, INDEX (a,b)); +INSERT INTO t VALUES (2,0), (2,0), (2,1), (2,1); +INSERT INTO t SELECT * FROM t; +INSERT INTO t SELECT * FROM t; +INSERT INTO t SELECT * FROM t; +# test MIN +#should use range with index for group by +EXPLAIN +SELECT a, MIN(b) FROM t WHERE b <> 0 GROUP BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range a a 10 NULL 10 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,min(`test`.`t`.`b`) AS `MIN(b)` from `test`.`t` where (`test`.`t`.`b` <> 0) group by `test`.`t`.`a` +#should return 1 row +SELECT a, MIN(b) FROM t WHERE b <> 0 GROUP BY a; +a MIN(b) +2 1 +# test MAX +#should use range with index for group by +EXPLAIN +SELECT a, MAX(b) FROM t WHERE b <> 1 GROUP BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range a a 10 NULL 10 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,max(`test`.`t`.`b`) AS `MAX(b)` from `test`.`t` where (`test`.`t`.`b` <> 1) group by `test`.`t`.`a` +#should return 1 row +SELECT a, MAX(b) FROM t WHERE b <> 1 GROUP BY a; +a MAX(b) +2 0 +# test 3 ranges and use the middle one +INSERT INTO t SELECT a, 2 FROM t; +#should use range with index for group by +EXPLAIN +SELECT a, MAX(b) FROM t WHERE b > 0 AND b < 2 GROUP BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range a a 10 NULL 10 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,max(`test`.`t`.`b`) AS `MAX(b)` from `test`.`t` where ((`test`.`t`.`b` > 0) and (`test`.`t`.`b` < 2)) group by `test`.`t`.`a` +#should return 1 row +SELECT a, MAX(b) FROM t WHERE b > 0 AND b < 2 GROUP BY a; +a MAX(b) +2 1 +DROP TABLE t; +# +# Bug #48472: Loose index scan inappropriately chosen for some WHERE +# conditions +# +CREATE TABLE t (a INT, b INT, INDEX (a,b)); +INSERT INTO t VALUES (2,0), (2,0), (2,1), (2,1); +INSERT INTO t SELECT * FROM t; +SELECT a, MAX(b) FROM t WHERE 0=b+0 GROUP BY a; +a MAX(b) +2 0 +DROP TABLE t; +End of 5.0 tests +# +# Bug #46607: Assertion failed: (cond_type == Item::FUNC_ITEM) results in +# server crash +# +CREATE TABLE t (a INT, b INT, INDEX (a,b)); +INSERT INTO t VALUES (2,0), (2,0), (2,1), (2,1); +INSERT INTO t SELECT * FROM t; +SELECT a, MAX(b) FROM t WHERE b GROUP BY a; +a MAX(b) +2 1 +DROP TABLE t; +CREATE TABLE t1(a INT NOT NULL, b INT NOT NULL, KEY (b)); +INSERT INTO t1 VALUES(1,1),(2,1); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +SELECT 1 AS c, b FROM t1 WHERE b IN (1,2) GROUP BY c, b; +c b +1 1 +SELECT a FROM t1 WHERE b=1; +a +1 +2 +DROP TABLE t1; +# +# Bug#47762: Incorrect result from MIN() when WHERE tests NOT NULL column +# for NULL +# +## Test for NULLs allowed +CREATE TABLE t1 ( a INT, KEY (a) ); +INSERT INTO t1 VALUES (1), (2), (3); +EXPLAIN +SELECT MIN( a ) FROM t1 WHERE a = NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +x x x NULL x x x x x x NULL no matching row in const table +Warnings: +x x x +SELECT MIN( a ) FROM t1 WHERE a = NULL; +MIN( a ) +NULL +EXPLAIN +SELECT MIN( a ) FROM t1 WHERE a <> NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +x x x NULL x x x x x x NULL no matching row in const table +Warnings: +x x x +SELECT MIN( a ) FROM t1 WHERE a <> NULL; +MIN( a ) +NULL +EXPLAIN +SELECT MIN( a ) FROM t1 WHERE a > NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +x x x NULL x x x x x x NULL no matching row in const table +Warnings: +x x x +SELECT MIN( a ) FROM t1 WHERE a > NULL; +MIN( a ) +NULL +EXPLAIN +SELECT MIN( a ) FROM t1 WHERE a < NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +x x x NULL x x x x x x NULL no matching row in const table +Warnings: +x x x +SELECT MIN( a ) FROM t1 WHERE a < NULL; +MIN( a ) +NULL +EXPLAIN +SELECT MIN( a ) FROM t1 WHERE a <=> NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +x x x NULL x x x x x x NULL No matching min/max row +Warnings: +x x x +SELECT MIN( a ) FROM t1 WHERE a <=> NULL; +MIN( a ) +NULL +EXPLAIN +SELECT MIN( a ) FROM t1 WHERE a BETWEEN NULL AND 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +x x x NULL x x x x x x NULL no matching row in const table +Warnings: +x x x +SELECT MIN( a ) FROM t1 WHERE a BETWEEN NULL AND 10; +MIN( a ) +NULL +EXPLAIN +SELECT MIN( a ) FROM t1 WHERE a BETWEEN NULL AND NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +x x x NULL x x x x x x NULL no matching row in const table +Warnings: +x x x +SELECT MIN( a ) FROM t1 WHERE a BETWEEN NULL AND NULL; +MIN( a ) +NULL +EXPLAIN +SELECT MIN( a ) FROM t1 WHERE a BETWEEN 10 AND NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +x x x NULL x x x x x x NULL no matching row in const table +Warnings: +x x x +SELECT MIN( a ) FROM t1 WHERE a BETWEEN 10 AND NULL; +MIN( a ) +NULL +EXPLAIN +SELECT MIN( a ) FROM t1 WHERE a = (SELECT a FROM t1 WHERE a < 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +x x x NULL x x x x x x NULL no matching row in const table +x x x NULL x x x x x x 100.00 Using where; Using index +Warnings: +x x x +SELECT MIN( a ) FROM t1 WHERE a = (SELECT a FROM t1 WHERE a < 0); +MIN( a ) +NULL +EXPLAIN +SELECT MIN( a ) FROM t1 WHERE a IS NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +x x x NULL x x x x x x NULL No matching min/max row +Warnings: +x x x +SELECT MIN( a ) FROM t1 WHERE a IS NULL; +MIN( a ) +NULL +INSERT INTO t1 VALUES (NULL), (NULL); +EXPLAIN +SELECT MIN( a ) FROM t1 WHERE a = NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +x x x NULL x x x x x x NULL no matching row in const table +Warnings: +x x x +SELECT MIN( a ) FROM t1 WHERE a = NULL; +MIN( a ) +NULL +EXPLAIN +SELECT MIN( a ) FROM t1 WHERE a <> NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +x x x NULL x x x x x x NULL no matching row in const table +Warnings: +x x x +SELECT MIN( a ) FROM t1 WHERE a <> NULL; +MIN( a ) +NULL +EXPLAIN +SELECT MIN( a ) FROM t1 WHERE a > NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +x x x NULL x x x x x x NULL no matching row in const table +Warnings: +x x x +SELECT MIN( a ) FROM t1 WHERE a > NULL; +MIN( a ) +NULL +EXPLAIN +SELECT MIN( a ) FROM t1 WHERE a < NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +x x x NULL x x x x x x NULL no matching row in const table +Warnings: +x x x +SELECT MIN( a ) FROM t1 WHERE a < NULL; +MIN( a ) +NULL +EXPLAIN +SELECT MIN( a ) FROM t1 WHERE a <=> NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +x x x NULL x x x x x x NULL Select tables optimized away +Warnings: +x x x +SELECT MIN( a ) FROM t1 WHERE a <=> NULL; +MIN( a ) +NULL +EXPLAIN +SELECT MIN( a ) FROM t1 WHERE a BETWEEN NULL AND 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +x x x NULL x x x x x x NULL no matching row in const table +Warnings: +x x x +SELECT MIN( a ) FROM t1 WHERE a BETWEEN NULL AND 10; +MIN( a ) +NULL +EXPLAIN +SELECT MIN( a ) FROM t1 WHERE a BETWEEN NULL AND NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +x x x NULL x x x x x x NULL no matching row in const table +Warnings: +x x x +SELECT MIN( a ) FROM t1 WHERE a BETWEEN NULL AND NULL; +MIN( a ) +NULL +EXPLAIN +SELECT MIN( a ) FROM t1 WHERE a BETWEEN 10 AND NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +x x x NULL x x x x x x NULL no matching row in const table +Warnings: +x x x +SELECT MIN( a ) FROM t1 WHERE a BETWEEN 10 AND NULL; +MIN( a ) +NULL +EXPLAIN +SELECT MIN( a ) FROM t1 WHERE a = (SELECT a FROM t1 WHERE a < 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +x x x NULL x x x x x x NULL no matching row in const table +x x x NULL x x x x x x 100.00 Using where; Using index +Warnings: +x x x +SELECT MIN( a ) FROM t1 WHERE a = (SELECT a FROM t1 WHERE a < 0); +MIN( a ) +NULL +EXPLAIN +SELECT MIN( a ) FROM t1 WHERE a IS NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +x x x NULL x x x x x x NULL Select tables optimized away +Warnings: +x x x +SELECT MIN( a ) FROM t1 WHERE a IS NULL; +MIN( a ) +NULL +DROP TABLE t1; +## Test for NOT NULLs +CREATE TABLE t1 ( a INT NOT NULL PRIMARY KEY); +INSERT INTO t1 VALUES (1), (2), (3); +# +# NULL-safe operator test disabled for non-NULL indexed columns. +# +# See bugs +# +# - Bug#52174: Sometimes wrong plan when reading a MAX value from +# non-NULL index +# +EXPLAIN +SELECT MIN( a ) FROM t1 WHERE a = NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +x x x NULL x x x x x x NULL no matching row in const table +Warnings: +x x x +SELECT MIN( a ) FROM t1 WHERE a = NULL; +MIN( a ) +NULL +EXPLAIN +SELECT MIN( a ) FROM t1 WHERE a <> NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +x x x NULL x x x x x x NULL no matching row in const table +Warnings: +x x x +SELECT MIN( a ) FROM t1 WHERE a <> NULL; +MIN( a ) +NULL +EXPLAIN +SELECT MIN( a ) FROM t1 WHERE a > NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +x x x NULL x x x x x x NULL no matching row in const table +Warnings: +x x x +SELECT MIN( a ) FROM t1 WHERE a > NULL; +MIN( a ) +NULL +EXPLAIN +SELECT MIN( a ) FROM t1 WHERE a < NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +x x x NULL x x x x x x NULL no matching row in const table +Warnings: +x x x +SELECT MIN( a ) FROM t1 WHERE a < NULL; +MIN( a ) +NULL +EXPLAIN +SELECT MIN( a ) FROM t1 WHERE a BETWEEN NULL AND 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +x x x NULL x x x x x x NULL no matching row in const table +Warnings: +x x x +SELECT MIN( a ) FROM t1 WHERE a BETWEEN NULL AND 10; +MIN( a ) +NULL +EXPLAIN +SELECT MIN( a ) FROM t1 WHERE a BETWEEN NULL AND NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +x x x NULL x x x x x x NULL no matching row in const table +Warnings: +x x x +SELECT MIN( a ) FROM t1 WHERE a BETWEEN NULL AND NULL; +MIN( a ) +NULL +EXPLAIN +SELECT MIN( a ) FROM t1 WHERE a BETWEEN 10 AND NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +x x x NULL x x x x x x NULL no matching row in const table +Warnings: +x x x +SELECT MIN( a ) FROM t1 WHERE a BETWEEN 10 AND NULL; +MIN( a ) +NULL +EXPLAIN +SELECT MIN( a ) FROM t1 WHERE a = (SELECT a FROM t1 WHERE a < 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +x x x NULL x x x x x x NULL no matching row in const table +x x x NULL x x x x x x 100.00 Using where; Using index +Warnings: +x x x +SELECT MIN( a ) FROM t1 WHERE a = (SELECT a FROM t1 WHERE a < 0); +MIN( a ) +NULL +EXPLAIN +SELECT MIN( a ) FROM t1 WHERE a IS NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +x x x NULL x x x x x x NULL Impossible WHERE +Warnings: +x x x +SELECT MIN( a ) FROM t1 WHERE a IS NULL; +MIN( a ) +NULL +DROP TABLE t1; +# +# Bug#53859: Valgrind: opt_sum_query(TABLE_LIST*, List&, Item*) at +# opt_sum.cc:305 +# +CREATE TABLE t1 ( a INT, KEY (a) ); +INSERT INTO t1 VALUES (1), (2), (3); +SELECT MIN( a ) AS min_a +FROM t1 +WHERE a > 1 AND a IS NULL +ORDER BY min_a; +min_a +NULL +DROP TABLE t1; +End of 5.1 tests +# +# WL#3220 (Loose index scan for COUNT DISTINCT) +# +CREATE TABLE t1 (a INT, b INT, c INT, KEY (a,b)); +INSERT INTO t1 VALUES (1,1,1), (1,2,1), (1,3,1), (1,4,1); +INSERT INTO t1 SELECT a, b + 4, 1 FROM t1; +INSERT INTO t1 SELECT a + 1, b, 1 FROM t1; +INSERT INTO t1 SELECT a + 2, b + 8, 1 FROM t1; +CREATE TABLE t2 (a INT, b INT, c INT, d INT, e INT, f INT, KEY (a,b,c)); +INSERT INTO t2 VALUES (1,1,1,1,1,1), (1,2,1,1,1,1), (1,3,1,1,1,1), +(1,4,1,1,1,1); +INSERT INTO t2 SELECT a, b + 4, c,d,e,f FROM t2; +INSERT INTO t2 SELECT a + 1, b, c,d,e,f FROM t2; +INSERT INTO t2 SELECT a + 2, b + 8, c,d,e,f FROM t2; +EXPLAIN SELECT COUNT(DISTINCT a) FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range a a 5 NULL 10 100.00 Using index for group-by +Warnings: +Note 1003 /* select#1 */ select count(distinct `test`.`t1`.`a`) AS `COUNT(DISTINCT a)` from `test`.`t1` +SELECT COUNT(DISTINCT a) FROM t1; +COUNT(DISTINCT a) +4 +EXPLAIN SELECT COUNT(DISTINCT a,b) FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range a a 10 NULL 10 100.00 Using index for group-by +Warnings: +Note 1003 /* select#1 */ select count(distinct `test`.`t1`.`a`,`test`.`t1`.`b`) AS `COUNT(DISTINCT a,b)` from `test`.`t1` +SELECT COUNT(DISTINCT a,b) FROM t1; +COUNT(DISTINCT a,b) +32 +EXPLAIN SELECT COUNT(DISTINCT b,a) FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range a a 10 NULL 10 100.00 Using index for group-by +Warnings: +Note 1003 /* select#1 */ select count(distinct `test`.`t1`.`b`,`test`.`t1`.`a`) AS `COUNT(DISTINCT b,a)` from `test`.`t1` +SELECT COUNT(DISTINCT b,a) FROM t1; +COUNT(DISTINCT b,a) +32 +EXPLAIN SELECT COUNT(DISTINCT b) FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index a a 10 NULL 32 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select count(distinct `test`.`t1`.`b`) AS `COUNT(DISTINCT b)` from `test`.`t1` +SELECT COUNT(DISTINCT b) FROM t1; +COUNT(DISTINCT b) +16 +EXPLAIN SELECT COUNT(DISTINCT a) FROM t1 GROUP BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range a a 5 NULL 10 100.00 Using index for group-by +Warnings: +Note 1003 /* select#1 */ select count(distinct `test`.`t1`.`a`) AS `COUNT(DISTINCT a)` from `test`.`t1` group by `test`.`t1`.`a` +SELECT COUNT(DISTINCT a) FROM t1 GROUP BY a; +COUNT(DISTINCT a) +1 +1 +1 +1 +EXPLAIN SELECT COUNT(DISTINCT b) FROM t1 GROUP BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range a a 10 NULL 10 100.00 Using index for group-by +Warnings: +Note 1003 /* select#1 */ select count(distinct `test`.`t1`.`b`) AS `COUNT(DISTINCT b)` from `test`.`t1` group by `test`.`t1`.`a` +SELECT COUNT(DISTINCT b) FROM t1 GROUP BY a; +COUNT(DISTINCT b) +8 +8 +8 +8 +EXPLAIN SELECT COUNT(DISTINCT a) FROM t1 GROUP BY b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index a a 10 NULL 32 100.00 Using index; Using filesort +Warnings: +Note 1003 /* select#1 */ select count(distinct `test`.`t1`.`a`) AS `COUNT(DISTINCT a)` from `test`.`t1` group by `test`.`t1`.`b` +SELECT COUNT(DISTINCT a) FROM t1 GROUP BY b; +COUNT(DISTINCT a) +2 +2 +2 +2 +2 +2 +2 +2 +2 +2 +2 +2 +2 +2 +2 +2 +EXPLAIN SELECT DISTINCT COUNT(DISTINCT a) FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range a a 5 NULL 10 100.00 Using index for group-by +Warnings: +Note 1003 /* select#1 */ select count(distinct `test`.`t1`.`a`) AS `COUNT(DISTINCT a)` from `test`.`t1` +SELECT DISTINCT COUNT(DISTINCT a) FROM t1; +COUNT(DISTINCT a) +4 +EXPLAIN SELECT COUNT(DISTINCT a, b + 0) FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index NULL a 10 NULL 32 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select count(distinct `test`.`t1`.`a`,(`test`.`t1`.`b` + 0)) AS `COUNT(DISTINCT a, b + 0)` from `test`.`t1` +SELECT COUNT(DISTINCT a, b + 0) FROM t1; +COUNT(DISTINCT a, b + 0) +32 +EXPLAIN SELECT COUNT(DISTINCT a) FROM t1 HAVING COUNT(DISTINCT b) < 20; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index NULL a 10 NULL 32 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select count(distinct `test`.`t1`.`a`) AS `COUNT(DISTINCT a)` from `test`.`t1` having (count(distinct `test`.`t1`.`b`) < 20) +SELECT COUNT(DISTINCT a) FROM t1 HAVING COUNT(DISTINCT b) < 20; +COUNT(DISTINCT a) +4 +EXPLAIN SELECT COUNT(DISTINCT a) FROM t1 HAVING COUNT(DISTINCT c) < 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 32 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select count(distinct `test`.`t1`.`a`) AS `COUNT(DISTINCT a)` from `test`.`t1` having (count(distinct `test`.`t1`.`c`) < 10) +SELECT COUNT(DISTINCT a) FROM t1 HAVING COUNT(DISTINCT c) < 10; +COUNT(DISTINCT a) +4 +EXPLAIN SELECT 1 FROM t1 HAVING COUNT(DISTINCT a) < 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range a a 5 NULL 10 100.00 Using index for group-by +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` having (count(distinct `test`.`t1`.`a`) < 10) +SELECT 1 FROM t1 HAVING COUNT(DISTINCT a) < 10; +1 +1 +EXPLAIN SELECT 1 FROM t1 GROUP BY a HAVING COUNT(DISTINCT b) > 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range a a 10 NULL 10 100.00 Using index for group-by +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` group by `test`.`t1`.`a` having (count(distinct `test`.`t1`.`b`) > 1) +SELECT 1 FROM t1 GROUP BY a HAVING COUNT(DISTINCT b) > 1; +1 +1 +1 +1 +1 +EXPLAIN SELECT COUNT(DISTINCT t1_1.a) FROM t1 t1_1, t1 t1_2 GROUP BY t1_1.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1_1 NULL index a a 10 NULL 32 100.00 Using index; Using temporary; Using filesort +1 SIMPLE t1_2 NULL index NULL a 10 NULL 32 100.00 Using index; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select count(distinct `test`.`t1`.`a`) AS `COUNT(DISTINCT t1_1.a)` from `test`.`t1` `t1_1` join `test`.`t1` `t1_2` group by `test`.`t1_1`.`a` +SELECT COUNT(DISTINCT t1_1.a) FROM t1 t1_1, t1 t1_2 GROUP BY t1_1.a; +COUNT(DISTINCT t1_1.a) +1 +1 +1 +1 +EXPLAIN SELECT COUNT(DISTINCT a), 12 FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range a a 5 NULL 10 100.00 Using index for group-by +Warnings: +Note 1003 /* select#1 */ select count(distinct `test`.`t1`.`a`) AS `COUNT(DISTINCT a)`,12 AS `12` from `test`.`t1` +SELECT COUNT(DISTINCT a), 12 FROM t1; +COUNT(DISTINCT a) 12 +4 12 +EXPLAIN SELECT COUNT(DISTINCT a, b, c) FROM t2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range a a 15 NULL 10 100.00 Using index for group-by +Warnings: +Note 1003 /* select#1 */ select count(distinct `test`.`t2`.`a`,`test`.`t2`.`b`,`test`.`t2`.`c`) AS `COUNT(DISTINCT a, b, c)` from `test`.`t2` +SELECT COUNT(DISTINCT a, b, c) FROM t2; +COUNT(DISTINCT a, b, c) +32 +EXPLAIN SELECT COUNT(DISTINCT a), SUM(DISTINCT a), AVG(DISTINCT a) FROM t2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range a a 5 NULL 10 100.00 Using index for group-by +Warnings: +Note 1003 /* select#1 */ select count(distinct `test`.`t2`.`a`) AS `COUNT(DISTINCT a)`,sum(distinct `test`.`t2`.`a`) AS `SUM(DISTINCT a)`,avg(distinct `test`.`t2`.`a`) AS `AVG(DISTINCT a)` from `test`.`t2` +SELECT COUNT(DISTINCT a), SUM(DISTINCT a), AVG(DISTINCT a) FROM t2; +COUNT(DISTINCT a) SUM(DISTINCT a) AVG(DISTINCT a) +4 10 2.5000 +EXPLAIN SELECT COUNT(DISTINCT a), SUM(DISTINCT a), AVG(DISTINCT f) FROM t2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 32 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select count(distinct `test`.`t2`.`a`) AS `COUNT(DISTINCT a)`,sum(distinct `test`.`t2`.`a`) AS `SUM(DISTINCT a)`,avg(distinct `test`.`t2`.`f`) AS `AVG(DISTINCT f)` from `test`.`t2` +SELECT COUNT(DISTINCT a), SUM(DISTINCT a), AVG(DISTINCT f) FROM t2; +COUNT(DISTINCT a) SUM(DISTINCT a) AVG(DISTINCT f) +4 10 1.0000 +EXPLAIN SELECT COUNT(DISTINCT a, b), COUNT(DISTINCT b, a) FROM t2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range a a 10 NULL 10 100.00 Using index for group-by +Warnings: +Note 1003 /* select#1 */ select count(distinct `test`.`t2`.`a`,`test`.`t2`.`b`) AS `COUNT(DISTINCT a, b)`,count(distinct `test`.`t2`.`b`,`test`.`t2`.`a`) AS `COUNT(DISTINCT b, a)` from `test`.`t2` +SELECT COUNT(DISTINCT a, b), COUNT(DISTINCT b, a) FROM t2; +COUNT(DISTINCT a, b) COUNT(DISTINCT b, a) +32 32 +EXPLAIN SELECT COUNT(DISTINCT a, b), COUNT(DISTINCT b, f) FROM t2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 32 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select count(distinct `test`.`t2`.`a`,`test`.`t2`.`b`) AS `COUNT(DISTINCT a, b)`,count(distinct `test`.`t2`.`b`,`test`.`t2`.`f`) AS `COUNT(DISTINCT b, f)` from `test`.`t2` +SELECT COUNT(DISTINCT a, b), COUNT(DISTINCT b, f) FROM t2; +COUNT(DISTINCT a, b) COUNT(DISTINCT b, f) +32 16 +EXPLAIN SELECT COUNT(DISTINCT a, b), COUNT(DISTINCT b, d) FROM t2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 32 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select count(distinct `test`.`t2`.`a`,`test`.`t2`.`b`) AS `COUNT(DISTINCT a, b)`,count(distinct `test`.`t2`.`b`,`test`.`t2`.`d`) AS `COUNT(DISTINCT b, d)` from `test`.`t2` +SELECT COUNT(DISTINCT a, b), COUNT(DISTINCT b, d) FROM t2; +COUNT(DISTINCT a, b) COUNT(DISTINCT b, d) +32 16 +EXPLAIN SELECT a, c, COUNT(DISTINCT c, a, b) FROM t2 GROUP BY a, b, c; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range a a 15 NULL 10 100.00 Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`c` AS `c`,count(distinct `test`.`t2`.`c`,`test`.`t2`.`a`,`test`.`t2`.`b`) AS `COUNT(DISTINCT c, a, b)` from `test`.`t2` group by `test`.`t2`.`a`,`test`.`t2`.`b`,`test`.`t2`.`c` +SELECT a, c, COUNT(DISTINCT c, a, b) FROM t2 GROUP BY a, b, c; +a c COUNT(DISTINCT c, a, b) +1 1 1 +1 1 1 +1 1 1 +1 1 1 +1 1 1 +1 1 1 +1 1 1 +1 1 1 +2 1 1 +2 1 1 +2 1 1 +2 1 1 +2 1 1 +2 1 1 +2 1 1 +2 1 1 +3 1 1 +3 1 1 +3 1 1 +3 1 1 +3 1 1 +3 1 1 +3 1 1 +3 1 1 +4 1 1 +4 1 1 +4 1 1 +4 1 1 +4 1 1 +4 1 1 +4 1 1 +4 1 1 +EXPLAIN SELECT COUNT(DISTINCT c, a, b) FROM t2 +WHERE a > 5 AND b BETWEEN 10 AND 20 GROUP BY a, b, c; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range a a 5 NULL 1 11.11 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select count(distinct `test`.`t2`.`c`,`test`.`t2`.`a`,`test`.`t2`.`b`) AS `COUNT(DISTINCT c, a, b)` from `test`.`t2` where ((`test`.`t2`.`a` > 5) and (`test`.`t2`.`b` between 10 and 20)) group by `test`.`t2`.`a`,`test`.`t2`.`b`,`test`.`t2`.`c` +SELECT COUNT(DISTINCT c, a, b) FROM t2 +WHERE a > 5 AND b BETWEEN 10 AND 20 GROUP BY a, b, c; +COUNT(DISTINCT c, a, b) +EXPLAIN SELECT COUNT(DISTINCT b), SUM(DISTINCT b) FROM t2 WHERE a = 5 +GROUP BY b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ref a a 5 const 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select count(distinct `test`.`t2`.`b`) AS `COUNT(DISTINCT b)`,sum(distinct `test`.`t2`.`b`) AS `SUM(DISTINCT b)` from `test`.`t2` where (`test`.`t2`.`a` = 5) group by `test`.`t2`.`b` +SELECT COUNT(DISTINCT b), SUM(DISTINCT b) FROM t2 WHERE a = 5 +GROUP BY b; +COUNT(DISTINCT b) SUM(DISTINCT b) +EXPLAIN SELECT a, COUNT(DISTINCT b), SUM(DISTINCT b) FROM t2 GROUP BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range a a 10 NULL 10 100.00 Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,count(distinct `test`.`t2`.`b`) AS `COUNT(DISTINCT b)`,sum(distinct `test`.`t2`.`b`) AS `SUM(DISTINCT b)` from `test`.`t2` group by `test`.`t2`.`a` +SELECT a, COUNT(DISTINCT b), SUM(DISTINCT b) FROM t2 GROUP BY a; +a COUNT(DISTINCT b) SUM(DISTINCT b) +1 8 36 +2 8 36 +3 8 100 +4 8 100 +EXPLAIN SELECT COUNT(DISTINCT b), SUM(DISTINCT b) FROM t2 GROUP BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range a a 10 NULL 10 100.00 Using index for group-by +Warnings: +Note 1003 /* select#1 */ select count(distinct `test`.`t2`.`b`) AS `COUNT(DISTINCT b)`,sum(distinct `test`.`t2`.`b`) AS `SUM(DISTINCT b)` from `test`.`t2` group by `test`.`t2`.`a` +SELECT COUNT(DISTINCT b), SUM(DISTINCT b) FROM t2 GROUP BY a; +COUNT(DISTINCT b) SUM(DISTINCT b) +8 36 +8 36 +8 100 +8 100 +EXPLAIN SELECT COUNT(DISTINCT a, b) FROM t2 WHERE c = 13 AND d = 42; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL a NULL NULL NULL 32 3.12 Using where +Warnings: +Note 1003 /* select#1 */ select count(distinct `test`.`t2`.`a`,`test`.`t2`.`b`) AS `COUNT(DISTINCT a, b)` from `test`.`t2` where ((`test`.`t2`.`d` = 42) and (`test`.`t2`.`c` = 13)) +SELECT COUNT(DISTINCT a, b) FROM t2 WHERE c = 13 AND d = 42; +COUNT(DISTINCT a, b) +0 +EXPLAIN SELECT a, COUNT(DISTINCT a), SUM(DISTINCT a) FROM t2 +WHERE b = 13 AND c = 42 GROUP BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range a a 15 NULL 10 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,count(distinct `test`.`t2`.`a`) AS `COUNT(DISTINCT a)`,sum(distinct `test`.`t2`.`a`) AS `SUM(DISTINCT a)` from `test`.`t2` where ((`test`.`t2`.`c` = 42) and (`test`.`t2`.`b` = 13)) group by `test`.`t2`.`a` +SELECT a, COUNT(DISTINCT a), SUM(DISTINCT a) FROM t2 +WHERE b = 13 AND c = 42 GROUP BY a; +a COUNT(DISTINCT a) SUM(DISTINCT a) +# This query could have been resolved using loose index scan since +# the second part of count(..) is defined by a constant predicate +EXPLAIN SELECT COUNT(DISTINCT a, b), SUM(DISTINCT a) FROM t2 WHERE b = 42; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index NULL a 15 NULL 32 10.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select count(distinct `test`.`t2`.`a`,`test`.`t2`.`b`) AS `COUNT(DISTINCT a, b)`,sum(distinct `test`.`t2`.`a`) AS `SUM(DISTINCT a)` from `test`.`t2` where (`test`.`t2`.`b` = 42) +SELECT COUNT(DISTINCT a, b), SUM(DISTINCT a) FROM t2 WHERE b = 42; +COUNT(DISTINCT a, b) SUM(DISTINCT a) +0 NULL +EXPLAIN SELECT SUM(DISTINCT a), MAX(b) FROM t2 GROUP BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index a a 15 NULL 32 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select sum(distinct `test`.`t2`.`a`) AS `SUM(DISTINCT a)`,max(`test`.`t2`.`b`) AS `MAX(b)` from `test`.`t2` group by `test`.`t2`.`a` +SELECT SUM(DISTINCT a), MAX(b) FROM t2 GROUP BY a; +SUM(DISTINCT a) MAX(b) +1 8 +2 8 +3 16 +4 16 +EXPLAIN SELECT 42 * (a + c + COUNT(DISTINCT c, a, b)) FROM t2 GROUP BY a, b, c; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range a a 15 NULL 10 100.00 Using index for group-by +Warnings: +Note 1003 /* select#1 */ select (42 * ((`test`.`t2`.`a` + `test`.`t2`.`c`) + count(distinct `test`.`t2`.`c`,`test`.`t2`.`a`,`test`.`t2`.`b`))) AS `42 * (a + c + COUNT(DISTINCT c, a, b))` from `test`.`t2` group by `test`.`t2`.`a`,`test`.`t2`.`b`,`test`.`t2`.`c` +SELECT 42 * (a + c + COUNT(DISTINCT c, a, b)) FROM t2 GROUP BY a, b, c; +42 * (a + c + COUNT(DISTINCT c, a, b)) +126 +126 +126 +126 +126 +126 +126 +126 +168 +168 +168 +168 +168 +168 +168 +168 +210 +210 +210 +210 +210 +210 +210 +210 +252 +252 +252 +252 +252 +252 +252 +252 +EXPLAIN SELECT (SUM(DISTINCT a) + MAX(b)) FROM t2 GROUP BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index a a 15 NULL 32 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select (sum(distinct `test`.`t2`.`a`) + max(`test`.`t2`.`b`)) AS `(SUM(DISTINCT a) + MAX(b))` from `test`.`t2` group by `test`.`t2`.`a` +SELECT (SUM(DISTINCT a) + MAX(b)) FROM t2 GROUP BY a; +(SUM(DISTINCT a) + MAX(b)) +9 +10 +19 +20 +DROP TABLE t1,t2; +# end of WL#3220 tests +# +# Bug#50539: Wrong result when loose index scan is used for an aggregate +# function with distinct +# +CREATE TABLE t1 ( +f1 int(11) NOT NULL DEFAULT '0', +f2 char(1) NOT NULL DEFAULT '', +PRIMARY KEY (f1,f2) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t1 values(1,'A'),(1 , 'B'), (1, 'C'), (2, 'A'), +(3, 'A'), (3, 'B'), (3, 'C'), (3, 'D'); +SELECT f1, COUNT(DISTINCT f2) FROM t1 GROUP BY f1; +f1 COUNT(DISTINCT f2) +1 3 +2 1 +3 4 +explain SELECT f1, COUNT(DISTINCT f2) FROM t1 GROUP BY f1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range PRIMARY PRIMARY 8 NULL 9 100.00 Using index for group-by (scanning) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`f1` AS `f1`,count(distinct `test`.`t1`.`f2`) AS `COUNT(DISTINCT f2)` from `test`.`t1` group by `test`.`t1`.`f1` +drop table t1; +# End of test#50539. +# +# Bug#18497308 WRONG COST ESTIMATE FOR LOOSE INDEX SCAN WHEN +# INDEX STATISTICS IS MISSING +# +CREATE TABLE t1 ( +a INTEGER, +b INTEGER, +c INTEGER, +d INTEGER, +KEY foo (a,b,c,d) +) ENGINE=MyISAM; +INSERT INTO t1 VALUES (1, 1, 1, 1), (1, 2, 1, 2), (1, 3, 1, 3), (1, 4, 1, 4); +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +EXPLAIN SELECT DISTINCT a FROM t1 WHERE b=4; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range foo foo 10 NULL 101 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select distinct `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`b` = 4) +SELECT DISTINCT a FROM t1 WHERE b=4; +a +1 +DROP TABLE t1; +# +# Bug#17217128 - BAD INTERACTION BETWEEN MIN/MAX AND +# "HAVING SUM(DISTINCT)": WRONG RESULTS. +# +CREATE TABLE t (a INT, b INT, KEY(a,b)); +INSERT INTO t VALUES (1,1), (2,2), (3,3), (4,4), (1,0), (3,2), (4,5); +set optimizer_trace_max_mem_size=1048576; +set @@session.optimizer_trace='enabled=on'; +set end_markers_in_json=on; +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +SELECT a, SUM(DISTINCT a), MIN(b) FROM t GROUP BY a; +a SUM(DISTINCT a) MIN(b) +1 1 0 +2 2 2 +3 3 2 +4 4 4 +EXPLAIN SELECT a, SUM(DISTINCT a), MIN(b) FROM t GROUP BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL index a a 10 NULL 7 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,sum(distinct `test`.`t`.`a`) AS `SUM(DISTINCT a)`,min(`test`.`t`.`b`) AS `MIN(b)` from `test`.`t` group by `test`.`t`.`a` +SELECT TRACE RLIKE 'have_both_agg_distinct_and_min_max' AS OK +FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +OK +1 +SELECT a, SUM(DISTINCT a), MAX(b) FROM t GROUP BY a; +a SUM(DISTINCT a) MAX(b) +1 1 1 +2 2 2 +3 3 3 +4 4 5 +EXPLAIN SELECT a, SUM(DISTINCT a), MAX(b) FROM t GROUP BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL index a a 10 NULL 7 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,sum(distinct `test`.`t`.`a`) AS `SUM(DISTINCT a)`,max(`test`.`t`.`b`) AS `MAX(b)` from `test`.`t` group by `test`.`t`.`a` +SELECT TRACE RLIKE 'have_both_agg_distinct_and_min_max' AS OK +FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +OK +1 +SELECT a, MAX(b) FROM t GROUP BY a HAVING SUM(DISTINCT a); +a MAX(b) +1 1 +2 2 +3 3 +4 5 +EXPLAIN SELECT a, MAX(b) FROM t GROUP BY a HAVING SUM(DISTINCT a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL index a a 10 NULL 7 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,max(`test`.`t`.`b`) AS `MAX(b)` from `test`.`t` group by `test`.`t`.`a` having (0 <> sum(distinct `test`.`t`.`a`)) +SELECT TRACE RLIKE 'have_both_agg_distinct_and_min_max' AS OK +FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +OK +1 +SELECT SUM(DISTINCT a), MIN(b), MAX(b) FROM t; +SUM(DISTINCT a) MIN(b) MAX(b) +10 0 5 +EXPLAIN SELECT SUM(DISTINCT a), MIN(b), MAX(b) FROM t; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL index a a 10 NULL 7 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select sum(distinct `test`.`t`.`a`) AS `SUM(DISTINCT a)`,min(`test`.`t`.`b`) AS `MIN(b)`,max(`test`.`t`.`b`) AS `MAX(b)` from `test`.`t` +SELECT TRACE RLIKE 'have_both_agg_distinct_and_min_max' AS OK +FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +OK +1 +SELECT a, SUM(DISTINCT a), MIN(b), MAX(b) FROM t GROUP BY a; +a SUM(DISTINCT a) MIN(b) MAX(b) +1 1 0 1 +2 2 2 2 +3 3 2 3 +4 4 4 5 +EXPLAIN SELECT a, SUM(DISTINCT a), MIN(b), MAX(b) FROM t GROUP BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL index a a 10 NULL 7 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,sum(distinct `test`.`t`.`a`) AS `SUM(DISTINCT a)`,min(`test`.`t`.`b`) AS `MIN(b)`,max(`test`.`t`.`b`) AS `MAX(b)` from `test`.`t` group by `test`.`t`.`a` +SELECT TRACE RLIKE 'have_both_agg_distinct_and_min_max' AS OK +FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +OK +1 +SET optimizer_trace_max_mem_size=DEFAULT; +SET optimizer_trace=DEFAULT; +SET end_markers_in_json=DEFAULT; +DROP TABLE t; +# +# Bug #18066518: THE COST VALUE IS A NEGATIVE NUMBER FOR MERGE ENGINE +# TABLE +# +CREATE TABLE t(a INT PRIMARY KEY) +ENGINE = MERGE; +EXPLAIN SELECT DISTINCT(a) FROM t; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL index PRIMARY PRIMARY 4 NULL 0 0.00 Using index +Warnings: +Note 1003 /* select#1 */ select distinct `test`.`t`.`a` AS `a` from `test`.`t` +SELECT DISTINCT(a) FROM t; +a +DROP TABLE t; +# End of test#18066518. +# +# Bug #18486293: ASSERTION FAILED: KEYS >= 0.0 IN +# COST_MODEL_TABLE::KEY_COMPARE_COST +# +CREATE TABLE t (b INT, KEY b_key (b)) ENGINE=INNODB +PARTITION BY RANGE COLUMNS(b) (PARTITION p_part VALUES LESS THAN (0)); +SELECT 1 FROM t WHERE b IN ('') GROUP BY b ; +1 +DROP TABLE t; +# End of test#18486293. +# +# Bug#18109609: LOOSE INDEX SCAN IS NOT USED WHEN IT SHOULD +# +CREATE TABLE t1 ( +id INT AUTO_INCREMENT PRIMARY KEY, +c1 INT, +c2 INT, +KEY(c1,c2)); +INSERT INTO t1(c1,c2) VALUES +(1, 1), (1,2), (2,1), (2,2), (3,1), (3,2), (3,3), (4,1), (4,2), (4,3), +(4,4), (4,5), (4,6), (4,7), (4,8), (4,9), (4,10), (4,11), (4,12), (4,13), +(4,14), (4,15), (4,16), (4,17), (4,18), (4,19), (4,20),(5,5); +EXPLAIN SELECT MAX(c2), c1 FROM t1 WHERE c1 = 4 GROUP BY c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range c1 c1 5 NULL 7 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select max(`test`.`t1`.`c2`) AS `MAX(c2)`,`test`.`t1`.`c1` AS `c1` from `test`.`t1` where (`test`.`t1`.`c1` = 4) group by `test`.`t1`.`c1` +FLUSH STATUS; +SELECT MAX(c2), c1 FROM t1 WHERE c1 = 4 GROUP BY c1; +MAX(c2) c1 +20 4 +SHOW SESSION STATUS LIKE 'Handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 3 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +DROP TABLE t1; +# End of test for Bug#18109609 +# +# Bug#22661012 - "USING INDEX FOR GROUP-BY" QUERIES CAN RETURN +# NO DATA WITH LE/LEQ AND ROUNDING +# +CREATE TABLE t1 (a INT, b INT, KEY(a,b)); +INSERT INTO t1 VALUES (1,1000), (1,1001), (1,2000), +(1,2001), (1,3000), (1,3002); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT a, MAX(b) FROM t1 WHERE a = 1 AND b < 1999.5 GROUP BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range a a 10 NULL 1 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,max(`test`.`t1`.`b`) AS `MAX(b)` from `test`.`t1` where ((`test`.`t1`.`a` = 1) and (`test`.`t1`.`b` < 2000)) group by `test`.`t1`.`a` +SELECT a, MAX(b) FROM t1 WHERE a = 1 AND b < 1999.5 GROUP BY a; +a MAX(b) +1 1001 +EXPLAIN SELECT a, MAX(b) FROM t1 WHERE a = 1 AND b <= 1999.5 GROUP BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range a a 10 NULL 1 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,max(`test`.`t1`.`b`) AS `MAX(b)` from `test`.`t1` where ((`test`.`t1`.`a` = 1) and (`test`.`t1`.`b` < 2000)) group by `test`.`t1`.`a` +SELECT a, MAX(b) FROM t1 WHERE a = 1 AND b <= 1999.5 GROUP BY a; +a MAX(b) +1 1001 +EXPLAIN SELECT a, MAX(b) FROM t1 WHERE a = 1 AND b between 0 and 1999.5 +GROUP BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range a a 10 NULL 1 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,max(`test`.`t1`.`b`) AS `MAX(b)` from `test`.`t1` where ((`test`.`t1`.`a` = 1) and (`test`.`t1`.`b` between 0 and 1999.5)) group by `test`.`t1`.`a` +SELECT a, MAX(b) FROM t1 WHERE a = 1 AND b between 0 and 1999.5 +GROUP BY a; +a MAX(b) +1 1001 +EXPLAIN SELECT a, MIN(b) FROM t1 WHERE a = 1 AND b > 2000.1 GROUP BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range a a 10 NULL 1 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,min(`test`.`t1`.`b`) AS `MIN(b)` from `test`.`t1` where ((`test`.`t1`.`a` = 1) and (`test`.`t1`.`b` > 2000)) group by `test`.`t1`.`a` +SELECT a, MIN(b) FROM t1 WHERE a = 1 AND b > 2000.1 GROUP BY a; +a MIN(b) +1 2001 +EXPLAIN SELECT a, MIN(b) FROM t1 WHERE a = 1 AND b >= 2000.1 GROUP BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range a a 10 NULL 1 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,min(`test`.`t1`.`b`) AS `MIN(b)` from `test`.`t1` where ((`test`.`t1`.`a` = 1) and (`test`.`t1`.`b` > 2000)) group by `test`.`t1`.`a` +SELECT a, MIN(b) FROM t1 WHERE a = 1 AND b >= 2000.1 GROUP BY a; +a MIN(b) +1 2001 +DROP TABLE t1; +# End of test for Bug#22661012 +# +# Bug#24484060 INCORRECT EVALUATION OF MIN/MAX REFERRING +# TO AN OUTER QUERY BLOCK +# +CREATE TABLE t1 (pk INT PRIMARY KEY, nk INT, k INT UNIQUE); +INSERT INTO t1 VALUES (1,1,1),(2,2,2),(4,4,4); +CREATE TABLE t2 (k INT); +INSERT INTO t2 VALUES (1),(2),(4); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +explain SELECT t2.k FROM t1 out1, t2 WHERE t2.k = out1.k +AND out1.pk<>3 AND out1.nk = (SELECT MAX(out1.k) FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 PRIMARY out1 NULL eq_ref PRIMARY,k k 5 test.t2.k 1 100.00 Using where +2 DEPENDENT SUBQUERY t1 NULL index NULL PRIMARY 4 NULL 3 100.00 Using index +Warnings: +Note 1276 Field or reference 'test.out1.k' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t2`.`k` AS `k` from `test`.`t1` `out1` join `test`.`t2` where ((`test`.`out1`.`k` = `test`.`t2`.`k`) and (`test`.`out1`.`pk` <> 3) and (`test`.`out1`.`nk` = (/* select#2 */ select max(`test`.`out1`.`k`) from `test`.`t1`))) +SELECT t2.k FROM t1 out1, t2 WHERE t2.k = out1.k +AND out1.pk<>3 AND out1.nk = (SELECT MAX(out1.k) FROM t1); +k +1 +2 +4 +# Repeat the test with PRIMARY KEY instead of the non-indexed column. +ALTER TABLE t1 DROP COLUMN nk; +explain SELECT t2.k FROM t1 out1, t2 WHERE t2.k = out1.k +AND out1.pk = (SELECT MAX(out1.k) FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 PRIMARY out1 NULL eq_ref k k 5 test.t2.k 1 100.00 Using where +2 DEPENDENT SUBQUERY t1 NULL index NULL PRIMARY 4 NULL 3 100.00 Using index +Warnings: +Note 1276 Field or reference 'test.out1.k' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t2`.`k` AS `k` from `test`.`t1` `out1` join `test`.`t2` where ((`test`.`out1`.`k` = `test`.`t2`.`k`) and (`test`.`out1`.`pk` = (/* select#2 */ select max(`test`.`out1`.`k`) from `test`.`t1`))) +SELECT t2.k FROM t1 out1, t2 WHERE t2.k = out1.k +AND out1.pk = (SELECT MAX(out1.k) FROM t1); +k +1 +2 +4 +# Inner reference should be optimized. +explain SELECT t2.k FROM t1 out1, t2 WHERE t2.k = out1.k +AND out1.pk = (SELECT MAX(k) FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY out1 NULL const PRIMARY,k PRIMARY 4 const 1 100.00 NULL +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL NULL Select tables optimized away +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`k` AS `k` from `test`.`t1` `out1` join `test`.`t2` where ((`test`.`t2`.`k` = '4')) +SELECT t2.k FROM t1 out1, t2 WHERE t2.k = out1.k +AND out1.pk = (SELECT MAX(k) FROM t1); +k +4 +explain SELECT t2.k FROM t1 out1, t2 WHERE t2.k = out1.k +AND out1.pk = (SELECT 2*MIN(k) FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY out1 NULL const PRIMARY,k PRIMARY 4 const 1 100.00 NULL +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL NULL Select tables optimized away +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`k` AS `k` from `test`.`t1` `out1` join `test`.`t2` where ((`test`.`t2`.`k` = '2')) +SELECT t2.k FROM t1 out1, t2 WHERE t2.k = out1.k +AND out1.pk = (SELECT 2*MIN(k) FROM t1); +k +2 +explain SELECT t2.k FROM t1 out1, t2 WHERE t2.k = out1.k +AND out1.pk = (SELECT SUM(k) - COUNT(k) FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY out1 NULL const PRIMARY,k PRIMARY 4 const 1 100.00 NULL +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +2 SUBQUERY t1 NULL index NULL k 5 NULL 3 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`k` AS `k` from `test`.`t1` `out1` join `test`.`t2` where ((`test`.`t2`.`k` = '4') and ('4' = (/* select#2 */ select (sum(`test`.`t1`.`k`) - count(`test`.`t1`.`k`)) from `test`.`t1`))) +SELECT t2.k FROM t1 out1, t2 WHERE t2.k = out1.k +AND out1.pk = (SELECT SUM(k) - COUNT(k) FROM t1); +k +4 +# Combinations of outer and inner references should not be optimized. +explain SELECT t2.k FROM t1 out1, t2 WHERE t2.k = out1.k +AND out1.pk = (SELECT MIN(out1.k + k) - 1 FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 PRIMARY out1 NULL eq_ref k k 5 test.t2.k 1 100.00 Using where +2 DEPENDENT SUBQUERY t1 NULL index NULL k 5 NULL 3 100.00 Using index +Warnings: +Note 1276 Field or reference 'test.out1.k' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t2`.`k` AS `k` from `test`.`t1` `out1` join `test`.`t2` where ((`test`.`out1`.`k` = `test`.`t2`.`k`) and (`test`.`out1`.`pk` = (/* select#2 */ select (min((`test`.`out1`.`k` + `test`.`t1`.`k`)) - 1) from `test`.`t1`))) +SELECT t2.k FROM t1 out1, t2 WHERE t2.k = out1.k +AND out1.pk = (SELECT MIN(out1.k + k) - 1 FROM t1); +k +1 +2 +4 +explain SELECT t2.k FROM t1 out1, t2 WHERE t2.k = out1.k +AND out1.pk = (SELECT out1.k + MIN(k) - 1 FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 PRIMARY out1 NULL eq_ref k k 5 test.t2.k 1 100.00 Using where +2 DEPENDENT SUBQUERY t1 NULL index NULL k 5 NULL 3 100.00 Using index +Warnings: +Note 1276 Field or reference 'test.out1.k' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t2`.`k` AS `k` from `test`.`t1` `out1` join `test`.`t2` where ((`test`.`out1`.`k` = `test`.`t2`.`k`) and (`test`.`out1`.`pk` = (/* select#2 */ select ((`test`.`out1`.`k` + min(`test`.`t1`.`k`)) - 1) from `test`.`t1`))) +SELECT t2.k FROM t1 out1, t2 WHERE t2.k = out1.k +AND out1.pk = (SELECT out1.k + MIN(k) - 1 FROM t1); +k +1 +2 +4 +explain SELECT t2.k FROM t1 out1, t2 WHERE t2.k = out1.k +AND out1.pk = (SELECT MIN(out1.k) + MIN(k) - 1 FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 PRIMARY out1 NULL eq_ref k k 5 test.t2.k 1 100.00 Using where +2 DEPENDENT SUBQUERY t1 NULL index NULL k 5 NULL 3 100.00 Using index +Warnings: +Note 1276 Field or reference 'test.out1.k' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t2`.`k` AS `k` from `test`.`t1` `out1` join `test`.`t2` where ((`test`.`out1`.`k` = `test`.`t2`.`k`) and (`test`.`out1`.`pk` = (/* select#2 */ select ((min(`test`.`out1`.`k`) + min(`test`.`t1`.`k`)) - 1) from `test`.`t1`))) +SELECT t2.k FROM t1 out1, t2 WHERE t2.k = out1.k +AND out1.pk = (SELECT MIN(out1.k) + MIN(k) - 1 FROM t1); +k +1 +2 +4 +explain SELECT t2.k FROM t1 out1, t2 WHERE t2.k = out1.k +AND out1.pk = (SELECT SUM(out1.k) / COUNT(k) FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 PRIMARY out1 NULL eq_ref k k 5 test.t2.k 1 100.00 Using where +2 DEPENDENT SUBQUERY t1 NULL index NULL k 5 NULL 3 100.00 Using index +Warnings: +Note 1276 Field or reference 'test.out1.k' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t2`.`k` AS `k` from `test`.`t1` `out1` join `test`.`t2` where ((`test`.`out1`.`k` = `test`.`t2`.`k`) and (`test`.`out1`.`pk` = (/* select#2 */ select (sum(`test`.`out1`.`k`) / count(`test`.`t1`.`k`)) from `test`.`t1`))) +SELECT t2.k FROM t1 out1, t2 WHERE t2.k = out1.k +AND out1.pk = (SELECT SUM(out1.k) / COUNT(k) FROM t1); +k +1 +2 +4 +explain SELECT t2.k FROM t1 out1, t2 WHERE t2.k = out1.k +AND out1.pk = (SELECT SUM(out1.k) / COUNT(*) FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 PRIMARY out1 NULL eq_ref k k 5 test.t2.k 1 100.00 Using where +2 DEPENDENT SUBQUERY t1 NULL index NULL PRIMARY 4 NULL 3 100.00 Using index +Warnings: +Note 1276 Field or reference 'test.out1.k' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t2`.`k` AS `k` from `test`.`t1` `out1` join `test`.`t2` where ((`test`.`out1`.`k` = `test`.`t2`.`k`) and (`test`.`out1`.`pk` = (/* select#2 */ select (sum(`test`.`out1`.`k`) / count(0)) from `test`.`t1`))) +SELECT t2.k FROM t1 out1, t2 WHERE t2.k = out1.k +AND out1.pk = (SELECT SUM(out1.k) / COUNT(*) FROM t1); +k +1 +2 +4 +explain SELECT t2.k FROM t1 out1, t2 WHERE t2.k = out1.k +AND out1.pk = (SELECT AVG(out1.k) FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 PRIMARY out1 NULL eq_ref k k 5 test.t2.k 1 100.00 Using where +2 DEPENDENT SUBQUERY t1 NULL index NULL PRIMARY 4 NULL 3 100.00 Using index +Warnings: +Note 1276 Field or reference 'test.out1.k' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t2`.`k` AS `k` from `test`.`t1` `out1` join `test`.`t2` where ((`test`.`out1`.`k` = `test`.`t2`.`k`) and (`test`.`out1`.`pk` = (/* select#2 */ select avg(`test`.`out1`.`k`) from `test`.`t1`))) +SELECT t2.k FROM t1 out1, t2 WHERE t2.k = out1.k +AND out1.pk = (SELECT AVG(out1.k) FROM t1); +k +1 +2 +4 +DROP TABLE t1, t2; +# End of test for Bug#24484060 +# +# Bug#24657798 HANDLER::HA_INDEX_INIT() TRIES TO USE +# AN UNLOCKED CONST TABLE IN OPT_SUM_QUERY() +# +CREATE TABLE t1 (k INT, KEY(k)) ENGINE=MyISAM; +INSERT INTO t1 VALUES (1); +CREATE TABLE t2 (h INT) ENGINE=MyISAM; +INSERT INTO t2 VALUES (3); +explain SELECT * FROM t1 WHERE (SELECT MIN(t1.k) FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +2 DEPENDENT SUBQUERY t2 NULL system NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1276 Field or reference 'test.t1.k' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '1' AS `k` from dual where true +SELECT * FROM t1 WHERE (SELECT MIN(t1.k) FROM t2); +k +1 +explain SELECT * FROM t1 WHERE EXISTS (SELECT MIN(t1.k) FROM t1 s1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +2 DEPENDENT SUBQUERY s1 NULL system NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1276 Field or reference 'test.t1.k' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '1' AS `k` from dual where true +SELECT * FROM t1 WHERE EXISTS (SELECT MIN(t1.k) FROM t1 s1); +k +1 +explain SELECT * FROM t1 WHERE EXISTS (SELECT MIN(t1.k) FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +2 DEPENDENT SUBQUERY t2 NULL system NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1276 Field or reference 'test.t1.k' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '1' AS `k` from dual where true +SELECT * FROM t1 WHERE EXISTS (SELECT MIN(t1.k) FROM t2); +k +1 +UPDATE t1 SET k=0; +explain SELECT * FROM t1 WHERE (SELECT MIN(t1.k) FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables +2 DEPENDENT SUBQUERY t2 NULL system NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1276 Field or reference 'test.t1.k' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '0' AS `k` from dual where (0 <> (/* select#2 */ select min('0') from dual)) +SELECT * FROM t1 WHERE (SELECT MIN(t1.k) FROM t2); +k +explain SELECT * FROM t1 WHERE EXISTS (SELECT MIN(t1.k) FROM t1 s1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +2 DEPENDENT SUBQUERY s1 NULL system NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1276 Field or reference 'test.t1.k' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '0' AS `k` from dual where true +SELECT * FROM t1 WHERE EXISTS (SELECT MIN(t1.k) FROM t1 s1); +k +0 +explain SELECT * FROM t1 WHERE EXISTS (SELECT MIN(t1.k) FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +2 DEPENDENT SUBQUERY t2 NULL system NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1276 Field or reference 'test.t1.k' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '0' AS `k` from dual where true +SELECT * FROM t1 WHERE EXISTS (SELECT MIN(t1.k) FROM t2); +k +0 +DROP TABLE t1; +CREATE TABLE t1 (nk INT, k INT, KEY(k)) ENGINE=MyISAM; +INSERT INTO t1 VALUES (1,1); +explain SELECT * FROM t1 WHERE nk = (SELECT MIN(t1.k) FROM t1 s1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +2 DEPENDENT SUBQUERY s1 NULL system NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1276 Field or reference 'test.t1.k' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '1' AS `nk`,'1' AS `k` from dual where true +SELECT * FROM t1 WHERE nk = (SELECT MIN(t1.k) FROM t1 s1); +nk k +1 1 +explain SELECT * FROM t1 WHERE nk = (SELECT MIN(t1.k) FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +2 DEPENDENT SUBQUERY t2 NULL system NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1276 Field or reference 'test.t1.k' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '1' AS `nk`,'1' AS `k` from dual where true +SELECT * FROM t1 WHERE nk = (SELECT MIN(t1.k) FROM t2); +nk k +1 1 +UPDATE t1 SET nk=0, k=0; +explain SELECT * FROM t1 WHERE nk = (SELECT MIN(t1.k) FROM t1 s1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +2 DEPENDENT SUBQUERY s1 NULL system NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1276 Field or reference 'test.t1.k' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '0' AS `nk`,'0' AS `k` from dual where true +SELECT * FROM t1 WHERE nk = (SELECT MIN(t1.k) FROM t1 s1); +nk k +0 0 +explain SELECT * FROM t1 WHERE nk = (SELECT MIN(t1.k) FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +2 DEPENDENT SUBQUERY t2 NULL system NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1276 Field or reference 'test.t1.k' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '0' AS `nk`,'0' AS `k` from dual where true +SELECT * FROM t1 WHERE nk = (SELECT MIN(t1.k) FROM t2); +nk k +0 0 +DROP TABLE t1; +DROP TABLE t2; +# End of test for Bug#24657798 +# +# Bug#24423143 - WRONG RESULTS FOR AGGREGATE QUERY +# +# Test index merge tree scenario +CREATE TABLE a ( +aggr_col int, +group_by_col int, +KEY aggr_col_key (aggr_col), +KEY group_by_col_key (group_by_col, aggr_col) +) ENGINE=InnoDB; +set optimizer_trace_max_mem_size=1048576; +set @@session.optimizer_trace='enabled=on'; +set end_markers_in_json=on; +INSERT INTO a VALUES (2,3),(5,6),(6,3),(7,NULL),(9,NULL),(10,6); +ANALYZE TABLE a; +Table Op Msg_type Msg_text +test.a analyze status OK +SELECT group_by_col, MIN(aggr_col) FROM a +WHERE (group_by_col IN (70, 9)) OR (aggr_col > 2) GROUP BY group_by_col; +group_by_col MIN(aggr_col) +NULL 7 +3 6 +6 5 +EXPLAIN SELECT group_by_col, MIN(aggr_col) FROM a +WHERE (group_by_col IN (70 ,9)) OR (aggr_col > 2) GROUP BY group_by_col; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 6 55.55 Parallel execute (1 workers) +2 SIMPLE a NULL index aggr_col_key,group_by_col_key group_by_col_key 10 NULL 6 55.55 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`a`.`group_by_col` AS `group_by_col`,min(`test`.`a`.`aggr_col`) AS `MIN(aggr_col)` from `test`.`a` where ((`test`.`a`.`group_by_col` in (70,9)) or (`test`.`a`.`aggr_col` > 2)) group by `test`.`a`.`group_by_col` +SELECT TRACE RLIKE 'disjuntive_predicate_present' AS OK +FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +OK +1 +SELECT group_by_col, MAX(aggr_col) FROM a +WHERE (group_by_col IN (70, 9)) OR (aggr_col < 9) GROUP BY group_by_col; +group_by_col MAX(aggr_col) +NULL 7 +3 6 +6 5 +EXPLAIN SELECT group_by_col, MAX(aggr_col) FROM a +WHERE (group_by_col IN (70 , 9)) OR (aggr_col < 9) GROUP BY group_by_col; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 6 55.55 Parallel execute (1 workers) +2 SIMPLE a NULL index aggr_col_key,group_by_col_key group_by_col_key 10 NULL 6 55.55 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`a`.`group_by_col` AS `group_by_col`,max(`test`.`a`.`aggr_col`) AS `MAX(aggr_col)` from `test`.`a` where ((`test`.`a`.`group_by_col` in (70,9)) or (`test`.`a`.`aggr_col` < 9)) group by `test`.`a`.`group_by_col` +SELECT TRACE RLIKE 'disjuntive_predicate_present' AS OK +FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +OK +1 +# Test IMPOSSIBLE TREE scenario +ALTER TABLE a DROP KEY aggr_col_key; +SELECT group_by_col, MIN(aggr_col) FROM a +WHERE (group_by_col IN (70 ,9)) OR (aggr_col > 2) GROUP BY group_by_col; +group_by_col MIN(aggr_col) +NULL 7 +3 6 +6 5 +EXPLAIN SELECT group_by_col, MIN(aggr_col) FROM a +WHERE (group_by_col IN (70, 9)) OR (aggr_col > 2) GROUP BY group_by_col; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 6 55.55 Parallel execute (1 workers) +2 SIMPLE a NULL index group_by_col_key group_by_col_key 10 NULL 6 55.55 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`a`.`group_by_col` AS `group_by_col`,min(`test`.`a`.`aggr_col`) AS `MIN(aggr_col)` from `test`.`a` where ((`test`.`a`.`group_by_col` in (70,9)) or (`test`.`a`.`aggr_col` > 2)) group by `test`.`a`.`group_by_col` +SELECT TRACE RLIKE 'minmax_keypart_in_disjunctive_query' AS OK +FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +OK +1 +SELECT group_by_col, MAX(aggr_col) FROM a +WHERE (group_by_col IN (70, 9)) OR (aggr_col < 9) GROUP BY group_by_col; +group_by_col MAX(aggr_col) +NULL 7 +3 6 +6 5 +EXPLAIN SELECT group_by_col, MAX(aggr_col) FROM a +WHERE (group_by_col IN (70, 9)) OR (aggr_col < 9) GROUP BY group_by_col; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 6 55.55 Parallel execute (1 workers) +2 SIMPLE a NULL index group_by_col_key group_by_col_key 10 NULL 6 55.55 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`a`.`group_by_col` AS `group_by_col`,max(`test`.`a`.`aggr_col`) AS `MAX(aggr_col)` from `test`.`a` where ((`test`.`a`.`group_by_col` in (70,9)) or (`test`.`a`.`aggr_col` < 9)) group by `test`.`a`.`group_by_col` +SELECT TRACE RLIKE 'minmax_keypart_in_disjunctive_query' AS OK +FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +OK +1 +# Scenario 3: aggregate field used as equal expression. +SELECT group_by_col, MIN(aggr_col), MAX(aggr_col) FROM a +WHERE (group_by_col IN (3, 9)) OR (aggr_col = 9) GROUP BY group_by_col; +group_by_col MIN(aggr_col) MAX(aggr_col) +NULL 9 9 +3 2 6 +EXPLAIN SELECT group_by_col, MIN(aggr_col), MAX(aggr_col) FROM a +WHERE (group_by_col IN (3, 9)) OR (aggr_col = 9) GROUP BY group_by_col; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 6 44.44 Parallel execute (1 workers) +2 SIMPLE a NULL index group_by_col_key group_by_col_key 10 NULL 6 44.44 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`a`.`group_by_col` AS `group_by_col`,min(`test`.`a`.`aggr_col`) AS `MIN(aggr_col)`,max(`test`.`a`.`aggr_col`) AS `MAX(aggr_col)` from `test`.`a` where ((`test`.`a`.`group_by_col` in (3,9)) or (`test`.`a`.`aggr_col` = 9)) group by `test`.`a`.`group_by_col` +SELECT TRACE RLIKE 'minmax_keypart_in_disjunctive_query' AS OK +FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +OK +1 +# Scenario 4: non aggregate field used as equal expression. +SELECT group_by_col, MIN(aggr_col), MAX(aggr_col) FROM a +WHERE (group_by_col = 3) OR (aggr_col > 8) GROUP BY group_by_col; +group_by_col MIN(aggr_col) MAX(aggr_col) +NULL 9 9 +3 2 6 +6 10 10 +EXPLAIN SELECT group_by_col, MIN(aggr_col), MAX(aggr_col) FROM a +WHERE (group_by_col = 3) OR (aggr_col > 8) GROUP BY group_by_col; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 6 55.55 Parallel execute (1 workers) +2 SIMPLE a NULL index group_by_col_key group_by_col_key 10 NULL 6 55.55 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`a`.`group_by_col` AS `group_by_col`,min(`test`.`a`.`aggr_col`) AS `MIN(aggr_col)`,max(`test`.`a`.`aggr_col`) AS `MAX(aggr_col)` from `test`.`a` where ((`test`.`a`.`group_by_col` = 3) or (`test`.`a`.`aggr_col` > 8)) group by `test`.`a`.`group_by_col` +SELECT TRACE RLIKE 'minmax_keypart_in_disjunctive_query' AS OK +FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +OK +1 +# Scenario 5: aggregate field used as non-zero expression. +INSERT INTO a VALUES(0, 3); +INSERT INTO a VALUES(0, 9); +INSERT INTO a VALUES(8, 0); +ANALYZE TABLE a; +Table Op Msg_type Msg_text +test.a analyze status OK +SELECT group_by_col, MIN(aggr_col), MAX(aggr_col) FROM a +WHERE (group_by_col = 9) OR aggr_col GROUP BY group_by_col; +group_by_col MIN(aggr_col) MAX(aggr_col) +NULL 7 9 +0 8 8 +3 2 6 +6 5 10 +9 0 0 +EXPLAIN SELECT group_by_col, MIN(aggr_col), MAX(aggr_col) FROM a +WHERE group_by_col = 9 OR aggr_col GROUP BY group_by_col; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 9 91.11 Parallel execute (1 workers) +2 SIMPLE a NULL index group_by_col_key group_by_col_key 10 NULL 9 91.11 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`a`.`group_by_col` AS `group_by_col`,min(`test`.`a`.`aggr_col`) AS `MIN(aggr_col)`,max(`test`.`a`.`aggr_col`) AS `MAX(aggr_col)` from `test`.`a` where ((`test`.`a`.`group_by_col` = 9) or (0 <> `test`.`a`.`aggr_col`)) group by `test`.`a`.`group_by_col` +SELECT TRACE RLIKE 'minmax_keypart_in_disjunctive_query' AS OK +FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +OK +1 +# Scenario 6: non aggregate field used as non-zero expression. +SELECT group_by_col, MIN(aggr_col), MAX(aggr_col) FROM a +WHERE group_by_col OR (aggr_col < 9) GROUP BY group_by_col; +group_by_col MIN(aggr_col) MAX(aggr_col) +NULL 7 7 +0 8 8 +3 0 6 +6 5 10 +9 0 0 +EXPLAIN SELECT group_by_col, MIN(aggr_col), MAX(aggr_col) FROM a +WHERE group_by_col OR (aggr_col < 9) GROUP BY group_by_col; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 9 92.59 Parallel execute (1 workers) +2 SIMPLE a NULL index group_by_col_key group_by_col_key 10 NULL 9 92.59 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`a`.`group_by_col` AS `group_by_col`,min(`test`.`a`.`aggr_col`) AS `MIN(aggr_col)`,max(`test`.`a`.`aggr_col`) AS `MAX(aggr_col)` from `test`.`a` where ((0 <> `test`.`a`.`group_by_col`) or (`test`.`a`.`aggr_col` < 9)) group by `test`.`a`.`group_by_col` +SELECT TRACE RLIKE 'minmax_keypart_in_disjunctive_query' AS OK +FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +OK +1 +# Scenario 7: aggregate field used in equal exp without a CONST +INSERT INTO a VALUES(1,1),(1,2),(2,1); +SELECT group_by_col, MIN(aggr_col), MAX(aggr_col) FROM a +WHERE aggr_col = group_by_col GROUP BY group_by_col; +group_by_col MIN(aggr_col) MAX(aggr_col) +1 1 1 +EXPLAIN SELECT group_by_col, MIN(aggr_col), MAX(aggr_col) FROM a +WHERE aggr_col = group_by_col GROUP BY group_by_col; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 12 100.00 Parallel execute (1 workers) +2 SIMPLE a NULL index group_by_col_key group_by_col_key 10 NULL 12 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`a`.`group_by_col` AS `group_by_col`,min(`test`.`a`.`aggr_col`) AS `MIN(aggr_col)`,max(`test`.`a`.`aggr_col`) AS `MAX(aggr_col)` from `test`.`a` where (`test`.`a`.`group_by_col` = `test`.`a`.`aggr_col`) group by `test`.`a`.`group_by_col` +SELECT TRACE RLIKE 'minmax_keypart_in_disjunctive_query' AS OK +FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +OK +1 +# Scenario 8: aggregate field used in a non-eq exp without a CONST +SELECT group_by_col, MIN(aggr_col), MAX(aggr_col) FROM a +WHERE aggr_col < group_by_col GROUP BY group_by_col; +group_by_col MIN(aggr_col) MAX(aggr_col) +2 1 1 +3 0 2 +6 5 5 +9 0 0 +EXPLAIN SELECT group_by_col, MIN(aggr_col), MAX(aggr_col) FROM a +WHERE aggr_col < group_by_col GROUP BY group_by_col; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 12 33.33 Parallel execute (1 workers) +2 SIMPLE a NULL index group_by_col_key group_by_col_key 10 NULL 12 33.33 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`a`.`group_by_col` AS `group_by_col`,min(`test`.`a`.`aggr_col`) AS `MIN(aggr_col)`,max(`test`.`a`.`aggr_col`) AS `MAX(aggr_col)` from `test`.`a` where (`test`.`a`.`aggr_col` < `test`.`a`.`group_by_col`) group by `test`.`a`.`group_by_col` +SELECT TRACE RLIKE 'minmax_keypart_in_disjunctive_query' AS OK +FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +OK +1 +# Scenario 8 +INSERT INTO a VALUES(0,1),(1,0),(0,0); +SELECT group_by_col, MIN(aggr_col), MAX(aggr_col) FROM a +WHERE aggr_col OR group_by_col GROUP BY group_by_col; +group_by_col MIN(aggr_col) MAX(aggr_col) +NULL 7 9 +0 1 8 +1 0 2 +2 1 1 +3 0 6 +6 5 10 +9 0 0 +EXPLAIN SELECT group_by_col, MIN(aggr_col), MAX(aggr_col) FROM a +WHERE aggr_col OR group_by_col GROUP BY group_by_col; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 15 99.00 Parallel execute (1 workers) +2 SIMPLE a NULL index group_by_col_key group_by_col_key 10 NULL 15 99.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`a`.`group_by_col` AS `group_by_col`,min(`test`.`a`.`aggr_col`) AS `MIN(aggr_col)`,max(`test`.`a`.`aggr_col`) AS `MAX(aggr_col)` from `test`.`a` where ((0 <> `test`.`a`.`aggr_col`) or (0 <> `test`.`a`.`group_by_col`)) group by `test`.`a`.`group_by_col` +SELECT TRACE RLIKE 'minmax_keypart_in_disjunctive_query' AS OK +FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +OK +1 +# Scenario 9 +SELECT group_by_col, MIN(aggr_col), MAX(aggr_col) FROM a +WHERE aggr_col AND group_by_col GROUP BY group_by_col; +group_by_col MIN(aggr_col) MAX(aggr_col) +1 1 2 +2 1 1 +3 2 6 +6 5 10 +EXPLAIN SELECT group_by_col, MIN(aggr_col), MAX(aggr_col) FROM a +WHERE aggr_col AND group_by_col GROUP BY group_by_col; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE a NULL range group_by_col_key group_by_col_key 10 NULL 4 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`a`.`group_by_col` AS `group_by_col`,min(`test`.`a`.`aggr_col`) AS `MIN(aggr_col)`,max(`test`.`a`.`aggr_col`) AS `MAX(aggr_col)` from `test`.`a` where ((0 <> `test`.`a`.`aggr_col`) and (0 <> `test`.`a`.`group_by_col`)) group by `test`.`a`.`group_by_col` +SELECT TRACE RLIKE 'minmax_keypart_in_disjunctive_query' AS OK +FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +OK +0 +# Scenario 10: Added for completion. This fix does not have an impact. +SELECT group_by_col, MIN(aggr_col), MAX(aggr_col) FROM a +WHERE aggr_col<>0 AND group_by_col<>0 GROUP BY group_by_col; +group_by_col MIN(aggr_col) MAX(aggr_col) +1 1 2 +2 1 1 +3 2 6 +6 5 10 +EXPLAIN SELECT group_by_col, MIN(aggr_col), MAX(aggr_col) FROM a +WHERE aggr_col<>0 AND group_by_col<>0 GROUP BY group_by_col; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE a NULL range group_by_col_key group_by_col_key 10 NULL 4 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`a`.`group_by_col` AS `group_by_col`,min(`test`.`a`.`aggr_col`) AS `MIN(aggr_col)`,max(`test`.`a`.`aggr_col`) AS `MAX(aggr_col)` from `test`.`a` where ((`test`.`a`.`aggr_col` <> 0) and (`test`.`a`.`group_by_col` <> 0)) group by `test`.`a`.`group_by_col` +SELECT TRACE RLIKE 'minmax_keypart_in_disjunctive_query' AS OK +FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +OK +0 +# Scenario 11: ITEM_FUNC as an argument of ITEM_FUNC +SELECT group_by_col, MIN(aggr_col), MAX(aggr_col) FROM a +WHERE group_by_col OR (group_by_col < (aggr_col = 1)) GROUP BY group_by_col; +group_by_col MIN(aggr_col) MAX(aggr_col) +0 1 1 +1 0 2 +2 1 1 +3 0 6 +6 5 10 +9 0 0 +EXPLAIN SELECT group_by_col, MIN(aggr_col), MAX(aggr_col) FROM a +WHERE group_by_col OR (group_by_col < (aggr_col = 1)) GROUP BY group_by_col; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 15 93.33 Parallel execute (1 workers) +2 SIMPLE a NULL index group_by_col_key group_by_col_key 10 NULL 15 93.33 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`a`.`group_by_col` AS `group_by_col`,min(`test`.`a`.`aggr_col`) AS `MIN(aggr_col)`,max(`test`.`a`.`aggr_col`) AS `MAX(aggr_col)` from `test`.`a` where ((0 <> `test`.`a`.`group_by_col`) or (`test`.`a`.`group_by_col` < (`test`.`a`.`aggr_col` = 1))) group by `test`.`a`.`group_by_col` +SELECT TRACE RLIKE 'minmax_keypart_in_disjunctive_query' AS OK +FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +OK +1 +SET optimizer_trace_max_mem_size=DEFAULT; +SET optimizer_trace=DEFAULT; +SET end_markers_in_json=DEFAULT; +DROP TABLE a; +# End of test for Bug#24423143 +# +# Bug #31475700 REGRESSION: MEMORY LEAK AFTER +# ITEM_SUM_HYBRID::MIN_MAX_UPDATE_STR_FIELD +# +CREATE TABLE t(a TEXT); +INSERT t VALUES('a'),('a'); +SELECT a, MAX(TRIM('1' FROM ~1)) FROM t GROUP BY a; +a MAX(TRIM('1' FROM ~1)) +a 8446744073709551614 +DROP TABLE t; +# +# Bug#30242457 ASSERTION "!TABLE->CONST_TABLE" +# +CREATE TABLE t2(id1 INT, id2 CHAR (1), id3 INT, value INT, +KEY (id1,id2,id3)) COLLATE LATIN1_BIN; +CREATE TABLE t1(a INT,b INT, PRIMARY KEY(a)) ENGINE=MEMORY; +# One row in an in-memory table: row will be read before +# optimizing MAX in subquery. No result set, either when t2 is +# empty or not, since t1.a <> t1.b +INSERT INTO t1 VALUES(1,0); +SELECT * FROM t1 WHERE t1.a IN (SELECT MAX(t1.b) FROM t2); +a b +INSERT INTO t2 VALUES (0, 'a', 3, 4); +SELECT * FROM t1 WHERE t1.a IN (SELECT MAX(t1.b) FROM t2); +a b +EXPLAIN FORMAT=TREE SELECT * FROM t1 WHERE t1.a IN (SELECT MAX(t1.b) FROM t2); +EXPLAIN +-> Zero rows (Impossible WHERE noticed after reading const tables) (cost=0.00..0.00 rows=0) + +Warnings: +Note 1276 Field or reference 'test.t1.b' of SELECT #2 was resolved in SELECT #1 +DELETE FROM t1; +DELETE FROM t2; +# Now t1.a = t1.b, still not result if t2 is empty +INSERT INTO t1 VALUES(1,1); +SELECT * FROM t1 WHERE t1.a IN (SELECT MAX(t1.b) FROM t2); +a b +# If t2 has at least one row, we will get a result row +INSERT INTO t2 VALUES (0, 'a', 3, 4); +SELECT * FROM t1 WHERE t1.a IN (SELECT MAX(t1.b) FROM t2); +a b +1 1 +EXPLAIN FORMAT=TREE SELECT * FROM t1 WHERE t1.a IN (SELECT MAX(t1.b) FROM t2); +EXPLAIN +-> Rows fetched before execution (cost=0.00..0.00 rows=1) + +Warnings: +Note 1276 Field or reference 'test.t1.b' of SELECT #2 was resolved in SELECT #1 +# If we have two rows in t1, t1 will not be read before +# optimization of the subquery, so this didn't use to fail +# before this patch. +INSERT INTO t1 VALUES(0,0); +SELECT * FROM t1 WHERE t1.a IN (SELECT MAX(t1.b) FROM t2); +a b +1 1 +0 0 +EXPLAIN FORMAT=TREE SELECT * FROM t1 WHERE t1.a IN (SELECT MAX(t1.b) FROM t2); +EXPLAIN +-> Filter: (t1.a,(select #2)) (cost=2.73 rows=2) + -> Table scan on t1 (cost=2.73 rows=2) + -> Select #2 (subquery in condition; dependent) + -> Limit: 1 row(s) + -> Filter: ((t1.a) = (max(t1.b))) + -> Aggregate: max(t1.b) + -> Rows fetched before execution (cost=0.00..0.00 rows=1) + +Warnings: +Note 1276 Field or reference 'test.t1.b' of SELECT #2 was resolved in SELECT #1 +DROP TABLE t1, t2; +# End of test for Bug#30242457 diff --git a/mysql-test/r/group_min_max_ext.result-pq b/mysql-test/r/group_min_max_ext.result-pq new file mode 100644 index 000000000000..0a758e998d15 --- /dev/null +++ b/mysql-test/r/group_min_max_ext.result-pq @@ -0,0 +1,4112 @@ +CREATE TABLE t (a INT, b INT, c INT, d INT, KEY k1(a, b, c, d)) ENGINE=innodb; +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +EXPLAIN SELECT a, MAX(d), MIN(d) FROM t WHERE (b = 2 OR b = 15 OR b = 3) AND (c = 3 OR c = 40) GROUP BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 20 NULL 78 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,max(`test`.`t`.`d`) AS `MAX(d)`,min(`test`.`t`.`d`) AS `MIN(d)` from `test`.`t` where (((`test`.`t`.`b` = 2) or (`test`.`t`.`b` = 15) or (`test`.`t`.`b` = 3)) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40))) group by `test`.`t`.`a` +FLUSH STATUS; +SELECT a, MAX(d), MIN(d) FROM t WHERE (b = 2 OR b = 15 OR b = 3) AND (c = 3 OR c = 40) GROUP BY a; +a MAX(d) MIN(d) +1 10 1 +10 10 1 +11 20 -10 +12 -15 -23 +2 10 1 +3 10 1 +4 10 1 +5 10 1 +6 10 1 +7 10 1 +8 10 1 +9 10 1 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 1 +Handler_read_key 113 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT a, MAX(d), MIN(d) FROM t WHERE (b = 2 OR b = 15) AND (c = 3 OR c = 40) GROUP BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 20 NULL 52 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,max(`test`.`t`.`d`) AS `MAX(d)`,min(`test`.`t`.`d`) AS `MIN(d)` from `test`.`t` where (((`test`.`t`.`b` = 2) or (`test`.`t`.`b` = 15)) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40))) group by `test`.`t`.`a` +FLUSH STATUS; +SELECT a, MAX(d), MIN(d) FROM t WHERE (b = 2 OR b = 15) AND (c = 3 OR c = 40) GROUP BY a; +a MAX(d) MIN(d) +1 10 1 +10 10 1 +11 -10 -10 +12 -15 -23 +2 10 1 +3 10 1 +4 10 1 +5 10 1 +6 10 1 +7 10 1 +8 10 1 +9 10 1 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 1 +Handler_read_key 78 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT a, MAX(d), MIN(d) FROM t WHERE (b = 2 OR b = 15) AND (c = 3 OR c IS NULL) GROUP BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 20 NULL 52 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,max(`test`.`t`.`d`) AS `MAX(d)`,min(`test`.`t`.`d`) AS `MIN(d)` from `test`.`t` where (((`test`.`t`.`b` = 2) or (`test`.`t`.`b` = 15)) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` is null))) group by `test`.`t`.`a` +FLUSH STATUS; +SELECT a, MAX(d), MIN(d) FROM t WHERE (b = 2 OR b = 15) AND (c = 3 OR c IS NULL) GROUP BY a; +a MAX(d) MIN(d) +1 10 1 +10 10 1 +11 -10 -20 +12 -15 -15 +2 10 1 +3 10 1 +4 10 1 +5 10 1 +6 10 1 +7 10 1 +8 10 1 +9 10 1 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 1 +Handler_read_key 77 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT a, MAX(d), MIN(d) FROM t WHERE (b IS NULL OR b = 15) AND (c = 3 OR c = 40) GROUP BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 20 NULL 52 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,max(`test`.`t`.`d`) AS `MAX(d)`,min(`test`.`t`.`d`) AS `MIN(d)` from `test`.`t` where (((`test`.`t`.`b` is null) or (`test`.`t`.`b` = 15)) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40))) group by `test`.`t`.`a` +FLUSH STATUS; +SELECT a, MAX(d), MIN(d) FROM t WHERE (b IS NULL OR b = 15) AND (c = 3 OR c = 40) GROUP BY a; +a MAX(d) MIN(d) +11 30 30 +12 -15 -20 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 1 +Handler_read_key 65 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT a, MAX(d), MIN(d) FROM t WHERE (b IS NULL OR b = 2) AND (c = 3 OR c = 40) GROUP BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 20 NULL 52 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,max(`test`.`t`.`d`) AS `MAX(d)`,min(`test`.`t`.`d`) AS `MIN(d)` from `test`.`t` where (((`test`.`t`.`b` is null) or (`test`.`t`.`b` = 2)) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40))) group by `test`.`t`.`a` +FLUSH STATUS; +SELECT a, MAX(d), MIN(d) FROM t WHERE (b IS NULL OR b = 2) AND (c = 3 OR c = 40) GROUP BY a; +a MAX(d) MIN(d) +1 10 1 +10 10 1 +11 30 -10 +12 -23 -23 +2 10 1 +3 10 1 +4 10 1 +5 10 1 +6 10 1 +7 10 1 +8 10 1 +9 10 1 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 1 +Handler_read_key 77 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT a FROM t WHERE (b = 2 OR b = 15 OR b = 3) AND (c = 3 OR c = 40) GROUP BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 15 NULL 78 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a` from `test`.`t` where (((`test`.`t`.`b` = 2) or (`test`.`t`.`b` = 15) or (`test`.`t`.`b` = 3)) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40))) group by `test`.`t`.`a` +FLUSH STATUS; +SELECT a FROM t WHERE (b = 2 OR b = 15 OR b = 3) AND (c = 3 OR c = 40) GROUP BY a; +a +1 +10 +11 +12 +2 +3 +4 +5 +6 +7 +8 +9 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 1 +Handler_read_key 26 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT a, b, MAX(d), MIN(d) FROM t WHERE (b = 2 OR b = 15) AND (c = 3 OR c = 40) GROUP BY a, b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 20 NULL 114 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,max(`test`.`t`.`d`) AS `MAX(d)`,min(`test`.`t`.`d`) AS `MIN(d)` from `test`.`t` where (((`test`.`t`.`b` = 2) or (`test`.`t`.`b` = 15)) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40))) group by `test`.`t`.`a`,`test`.`t`.`b` +FLUSH STATUS; +SELECT a, b, MAX(d), MIN(d) FROM t WHERE (b = 2 OR b = 15) AND (c = 3 OR c = 40) GROUP BY a, b; +a b MAX(d) MIN(d) +1 2 10 1 +10 2 10 1 +11 2 -10 -10 +12 15 -15 -20 +12 2 -23 -23 +2 2 10 1 +3 2 10 1 +4 2 10 1 +5 2 10 1 +6 2 10 1 +7 2 10 1 +8 2 10 1 +9 2 10 1 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 1 +Handler_read_key 228 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT a, b, MAX(d), MIN(d) FROM t WHERE (b = 2 OR b = 15 OR b = 3) AND (c = 3 OR c = 40) +GROUP BY a, b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 20 NULL 114 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,max(`test`.`t`.`d`) AS `MAX(d)`,min(`test`.`t`.`d`) AS `MIN(d)` from `test`.`t` where (((`test`.`t`.`b` = 2) or (`test`.`t`.`b` = 15) or (`test`.`t`.`b` = 3)) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40))) group by `test`.`t`.`a`,`test`.`t`.`b` +FLUSH STATUS; +SELECT a, b, MAX(d), MIN(d) FROM t WHERE (b = 2 OR b = 15 OR b = 3) AND (c = 3 OR c = 40) +GROUP BY a, b; +a b MAX(d) MIN(d) +1 2 10 1 +1 3 10 1 +10 2 10 1 +10 3 10 1 +11 2 -10 -10 +11 3 20 20 +12 15 -15 -20 +12 2 -23 -23 +2 2 10 1 +2 3 10 1 +3 2 10 1 +3 3 10 1 +4 2 10 1 +4 3 10 1 +5 2 10 1 +5 3 10 1 +6 2 10 1 +6 3 10 1 +7 2 10 1 +7 3 10 1 +8 2 10 1 +8 3 10 1 +9 2 10 1 +9 3 10 1 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 1 +Handler_read_key 228 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT DISTINCT a FROM t WHERE a = 1 AND (b = 2 OR b = 15); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 10 NULL 2 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select distinct `test`.`t`.`a` AS `a` from `test`.`t` where ((`test`.`t`.`a` = 1) and ((`test`.`t`.`b` = 2) or (`test`.`t`.`b` = 15))) +FLUSH STATUS; +SELECT DISTINCT a FROM t WHERE a = 1 AND (b = 2 OR b = 15); +a +1 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 4 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT a, MAX(d), MIN(d) FROM t WHERE a = 1 AND (c = 3 OR c = 40) AND (d = 1 OR d = 9) +GROUP BY a, b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 20 NULL 12 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,max(`test`.`t`.`d`) AS `MAX(d)`,min(`test`.`t`.`d`) AS `MIN(d)` from `test`.`t` where ((`test`.`t`.`a` = 1) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40)) and ((`test`.`t`.`d` = 1) or (`test`.`t`.`d` = 9))) group by `test`.`t`.`a`,`test`.`t`.`b` +FLUSH STATUS; +SELECT a, MAX(d), MIN(d) FROM t WHERE a = 1 AND (c = 3 OR c = 40) AND (d = 1 OR d = 9) +GROUP BY a, b; +a MAX(d) MIN(d) +1 9 1 +1 9 1 +1 9 1 +1 9 1 +1 9 1 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 27 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT a, b, MAX(d), MIN(d) FROM t WHERE (a = 1 OR a = 12) AND (b = 2 OR b = 15) AND (c = 3 OR c = 40) +GROUP BY a, b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 20 NULL 2 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,max(`test`.`t`.`d`) AS `MAX(d)`,min(`test`.`t`.`d`) AS `MIN(d)` from `test`.`t` where (((`test`.`t`.`a` = 1) or (`test`.`t`.`a` = 12)) and ((`test`.`t`.`b` = 2) or (`test`.`t`.`b` = 15)) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40))) group by `test`.`t`.`a`,`test`.`t`.`b` +FLUSH STATUS; +SELECT a, b, MAX(d), MIN(d) FROM t WHERE (a = 1 OR a = 12) AND (b = 2 OR b = 15) AND (c = 3 OR c = 40) +GROUP BY a, b; +a b MAX(d) MIN(d) +1 2 10 1 +12 15 -15 -20 +12 2 -23 -23 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 20 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT a, b, MAX(d), MIN(d) FROM t WHERE (a < 2 OR a > 11) AND (b = 2 OR b = 15) AND (c = 3 OR c = 40) +GROUP BY a, b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 20 NULL 12 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,max(`test`.`t`.`d`) AS `MAX(d)`,min(`test`.`t`.`d`) AS `MIN(d)` from `test`.`t` where (((`test`.`t`.`a` < 2) or (`test`.`t`.`a` > 11)) and ((`test`.`t`.`b` = 2) or (`test`.`t`.`b` = 15)) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40))) group by `test`.`t`.`a`,`test`.`t`.`b` +FLUSH STATUS; +SELECT a, b, MAX(d), MIN(d) FROM t WHERE (a < 2 OR a > 11) AND (b = 2 OR b = 15) AND (c = 3 OR c = 40) +GROUP BY a, b; +a b MAX(d) MIN(d) +1 2 10 1 +12 15 -15 -20 +12 2 -23 -23 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 34 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT DISTINCT a, b FROM t WHERE (a = 1 OR a = 12) AND (b = 2 OR b = 15) AND (c = 3 OR c = 40); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 15 NULL 2 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select distinct `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b` from `test`.`t` where (((`test`.`t`.`a` = 1) or (`test`.`t`.`a` = 12)) and ((`test`.`t`.`b` = 2) or (`test`.`t`.`b` = 15)) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40))) +FLUSH STATUS; +SELECT DISTINCT a, b FROM t WHERE (a = 1 OR a = 12) AND (b = 2 OR b = 15) AND (c = 3 OR c = 40); +a b +1 2 +12 15 +12 2 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 11 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT DISTINCT a FROM t WHERE (a = 1 OR a = 12) AND (b = 2 OR b = 15); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 10 NULL 2 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select distinct `test`.`t`.`a` AS `a` from `test`.`t` where (((`test`.`t`.`a` = 1) or (`test`.`t`.`a` = 12)) and ((`test`.`t`.`b` = 2) or (`test`.`t`.`b` = 15))) +FLUSH STATUS; +SELECT DISTINCT a FROM t WHERE (a = 1 OR a = 12) AND (b = 2 OR b = 15); +a +1 +12 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 7 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT a, b, MAX(d), MIN(d) FROM t WHERE (a = 1 OR a = 12) AND (b < 4 OR b > 10) AND (c = 3 OR c = 40) +GROUP BY a, b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 20 NULL 8 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,max(`test`.`t`.`d`) AS `MAX(d)`,min(`test`.`t`.`d`) AS `MIN(d)` from `test`.`t` where (((`test`.`t`.`a` = 1) or (`test`.`t`.`a` = 12)) and ((`test`.`t`.`b` < 4) or (`test`.`t`.`b` > 10)) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40))) group by `test`.`t`.`a`,`test`.`t`.`b` +FLUSH STATUS; +SELECT a, b, MAX(d), MIN(d) FROM t WHERE (a = 1 OR a = 12) AND (b < 4 OR b > 10) AND (c = 3 OR c = 40) +GROUP BY a, b; +a b MAX(d) MIN(d) +1 1 10 1 +1 2 10 1 +1 3 10 1 +12 15 -15 -20 +12 2 -23 -23 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 28 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT a, MAX(d), MIN(d) FROM t WHERE (a = 1 OR a > 9) AND (b = 2 OR b = 15) AND (c = 3 OR c = 40) +GROUP BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 20 NULL 4 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,max(`test`.`t`.`d`) AS `MAX(d)`,min(`test`.`t`.`d`) AS `MIN(d)` from `test`.`t` where (((`test`.`t`.`a` = 1) or (`test`.`t`.`a` > 9)) and ((`test`.`t`.`b` = 2) or (`test`.`t`.`b` = 15)) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40))) group by `test`.`t`.`a` +FLUSH STATUS; +SELECT a, MAX(d), MIN(d) FROM t WHERE (a = 1 OR a > 9) AND (b = 2 OR b = 15) AND (c = 3 OR c = 40) +GROUP BY a; +a MAX(d) MIN(d) +1 10 1 +10 10 1 +11 -10 -10 +12 -15 -23 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 31 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT COUNT(DISTINCT a, b) FROM t WHERE (a = 1 OR a = 12) AND (b = 2 OR b = 15) AND (c = 3 OR c = 40); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 15 NULL 2 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select count(distinct `test`.`t`.`a`,`test`.`t`.`b`) AS `COUNT(DISTINCT a, b)` from `test`.`t` where (((`test`.`t`.`a` = 1) or (`test`.`t`.`a` = 12)) and ((`test`.`t`.`b` = 2) or (`test`.`t`.`b` = 15)) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40))) +FLUSH STATUS; +SELECT COUNT(DISTINCT a, b) FROM t WHERE (a = 1 OR a = 12) AND (b = 2 OR b = 15) AND (c = 3 OR c = 40); +COUNT(DISTINCT a, b) +3 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 11 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT SUM(DISTINCT a), AVG(DISTINCT a) FROM t WHERE (b = 2 OR b = 15) AND (c = 3 OR c = 40); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 15 NULL 52 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select sum(distinct `test`.`t`.`a`) AS `SUM(DISTINCT a)`,avg(distinct `test`.`t`.`a`) AS `AVG(DISTINCT a)` from `test`.`t` where (((`test`.`t`.`b` = 2) or (`test`.`t`.`b` = 15)) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40))) +FLUSH STATUS; +SELECT SUM(DISTINCT a), AVG(DISTINCT a) FROM t WHERE (b = 2 OR b = 15) AND (c = 3 OR c = 40); +SUM(DISTINCT a) AVG(DISTINCT a) +78 6.5000 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 1 +Handler_read_key 26 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT SUM(DISTINCT a), AVG(DISTINCT a), COUNT(DISTINCT a) FROM t WHERE (b = 2 OR b = 15) AND (c = 3 OR c = 40); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 15 NULL 52 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select sum(distinct `test`.`t`.`a`) AS `SUM(DISTINCT a)`,avg(distinct `test`.`t`.`a`) AS `AVG(DISTINCT a)`,count(distinct `test`.`t`.`a`) AS `COUNT(DISTINCT a)` from `test`.`t` where (((`test`.`t`.`b` = 2) or (`test`.`t`.`b` = 15)) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40))) +FLUSH STATUS; +SELECT SUM(DISTINCT a), AVG(DISTINCT a), COUNT(DISTINCT a) FROM t WHERE (b = 2 OR b = 15) AND (c = 3 OR c = 40); +SUM(DISTINCT a) AVG(DISTINCT a) COUNT(DISTINCT a) +78 6.5000 12 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 1 +Handler_read_key 26 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT a, MAX(d), MIN(d) FROM t WHERE (a > 11) AND (b = 2 OR b = 15) AND +(c = 3 OR c = 1 OR c = 2 OR c = 4) +GROUP BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 6.53 Parallel execute (1 workers) +2 SIMPLE t NULL range k1 k1 5 NULL 4 6.53 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,max(`test`.`t`.`d`) AS `MAX(d)`,min(`test`.`t`.`d`) AS `MIN(d)` from `test`.`t` where ((`test`.`t`.`a` > 11) and ((`test`.`t`.`b` = 2) or (`test`.`t`.`b` = 15)) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 1) or (`test`.`t`.`c` = 2) or (`test`.`t`.`c` = 4))) group by `test`.`t`.`a` +FLUSH STATUS; +SELECT a, MAX(d), MIN(d) FROM t WHERE (a > 11) AND (b = 2 OR b = 15) AND +(c = 3 OR c = 1 OR c = 2 OR c = 4) +GROUP BY a; +a MAX(d) MIN(d) +12 -15 -15 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 2 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 5 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT a, b, MAX(d), MIN(d) FROM t WHERE (c = 3 OR c = 40) AND (d > 7 OR d =2) GROUP BY a, b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 20 NULL 114 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,max(`test`.`t`.`d`) AS `MAX(d)`,min(`test`.`t`.`d`) AS `MIN(d)` from `test`.`t` where (((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40)) and ((`test`.`t`.`d` > 7) or (`test`.`t`.`d` = 2))) group by `test`.`t`.`a`,`test`.`t`.`b` +FLUSH STATUS; +SELECT a, b, MAX(d), MIN(d) FROM t WHERE (c = 3 OR c = 40) AND (d > 7 OR d =2) GROUP BY a, b; +a b MAX(d) MIN(d) +1 1 10 2 +1 2 10 2 +1 3 10 2 +1 4 10 2 +1 5 10 2 +10 1 10 2 +10 2 10 2 +10 3 10 2 +10 4 10 2 +10 5 10 2 +11 3 20 20 +11 NULL 30 30 +2 1 10 2 +2 2 10 2 +2 3 10 2 +2 4 10 2 +2 5 10 2 +3 1 10 2 +3 2 10 2 +3 3 10 2 +3 4 10 2 +3 5 10 2 +4 1 10 2 +4 2 10 2 +4 3 10 2 +4 4 10 2 +4 5 10 2 +5 1 10 2 +5 2 10 2 +5 3 10 2 +5 4 10 2 +5 5 10 2 +6 1 10 2 +6 2 10 2 +6 3 10 2 +6 4 10 2 +6 5 10 2 +7 1 10 2 +7 2 10 2 +7 3 10 2 +7 4 10 2 +7 5 10 2 +8 1 10 2 +8 2 10 2 +8 3 10 2 +8 4 10 2 +8 5 10 2 +9 1 10 2 +9 2 10 2 +9 3 10 2 +9 4 10 2 +9 5 10 2 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 1 +Handler_read_key 283 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT a, b, MAX(d), MIN(d) FROM t WHERE (c = 3 OR c = 40) AND (d > 7 OR d =2 OR d IS NULL) +GROUP BY a, b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 20 NULL 114 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,max(`test`.`t`.`d`) AS `MAX(d)`,min(`test`.`t`.`d`) AS `MIN(d)` from `test`.`t` where (((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40)) and ((`test`.`t`.`d` > 7) or (`test`.`t`.`d` = 2) or (`test`.`t`.`d` is null))) group by `test`.`t`.`a`,`test`.`t`.`b` +FLUSH STATUS; +SELECT a, b, MAX(d), MIN(d) FROM t WHERE (c = 3 OR c = 40) AND (d > 7 OR d =2 OR d IS NULL) +GROUP BY a, b; +a b MAX(d) MIN(d) +1 1 10 2 +1 2 10 2 +1 3 10 2 +1 4 10 2 +1 5 10 2 +10 1 10 2 +10 2 10 2 +10 3 10 2 +10 4 10 2 +10 5 10 2 +11 3 20 20 +11 NULL 30 30 +12 2 NULL NULL +2 1 10 2 +2 2 10 2 +2 3 10 2 +2 4 10 2 +2 5 10 2 +3 1 10 2 +3 2 10 2 +3 3 10 2 +3 4 10 2 +3 5 10 2 +4 1 10 2 +4 2 10 2 +4 3 10 2 +4 4 10 2 +4 5 10 2 +5 1 10 2 +5 2 10 2 +5 3 10 2 +5 4 10 2 +5 5 10 2 +6 1 10 2 +6 2 10 2 +6 3 10 2 +6 4 10 2 +6 5 10 2 +7 1 10 2 +7 2 10 2 +7 3 10 2 +7 4 10 2 +7 5 10 2 +8 1 10 2 +8 2 10 2 +8 3 10 2 +8 4 10 2 +8 5 10 2 +9 1 10 2 +9 2 10 2 +9 3 10 2 +9 4 10 2 +9 5 10 2 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 1 +Handler_read_key 398 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT a, b, MIN(d) FROM t WHERE (a > 5) AND (c = 3 OR c = 40) AND +(d < -24 OR d = 3 OR d IS NULL) +GROUP BY a, b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 20 NULL 58 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,min(`test`.`t`.`d`) AS `MIN(d)` from `test`.`t` where ((`test`.`t`.`a` > 5) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40)) and ((`test`.`t`.`d` < (-(24))) or (`test`.`t`.`d` = 3) or (`test`.`t`.`d` is null))) group by `test`.`t`.`a`,`test`.`t`.`b` +FLUSH STATUS; +SELECT a, b, MIN(d) FROM t WHERE (a > 5) AND (c = 3 OR c = 40) AND +(d < -24 OR d = 3 OR d IS NULL) +GROUP BY a, b; +a b MIN(d) +10 1 3 +10 2 3 +10 3 3 +10 4 3 +10 5 3 +12 2 NULL +6 1 3 +6 2 3 +6 3 3 +6 4 3 +6 5 3 +7 1 3 +7 2 3 +7 3 3 +7 4 3 +7 5 3 +8 1 3 +8 2 3 +8 3 3 +8 4 3 +8 5 3 +9 1 3 +9 2 3 +9 3 3 +9 4 3 +9 5 3 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 155 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT a, b, MAX(d), MIN(d) FROM t WHERE (a > 5) AND (c = 3 OR c = 40) AND (d < 1 OR d = 9) +GROUP BY a, b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 20 NULL 58 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,max(`test`.`t`.`d`) AS `MAX(d)`,min(`test`.`t`.`d`) AS `MIN(d)` from `test`.`t` where ((`test`.`t`.`a` > 5) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40)) and ((`test`.`t`.`d` < 1) or (`test`.`t`.`d` = 9))) group by `test`.`t`.`a`,`test`.`t`.`b` +FLUSH STATUS; +SELECT a, b, MAX(d), MIN(d) FROM t WHERE (a > 5) AND (c = 3 OR c = 40) AND (d < 1 OR d = 9) +GROUP BY a, b; +a b MAX(d) MIN(d) +10 1 9 9 +10 2 9 9 +10 3 9 9 +10 4 9 9 +10 5 9 9 +11 2 -10 -10 +12 15 -15 -20 +12 2 -23 -23 +6 1 9 9 +6 2 9 9 +6 3 9 9 +6 4 9 9 +6 5 9 9 +7 1 9 9 +7 2 9 9 +7 3 9 9 +7 4 9 9 +7 5 9 9 +8 1 9 9 +8 2 9 9 +8 3 9 9 +8 4 9 9 +8 5 9 9 +9 1 9 9 +9 2 9 9 +9 3 9 9 +9 4 9 9 +9 5 9 9 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 186 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT a, b, MAX(d), MIN(d) FROM t WHERE (a > 9) AND (c = 3 OR c = 40) AND +(d = 1 OR d = 9 OR d IS NULL) +GROUP BY a, b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 20 NULL 12 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,max(`test`.`t`.`d`) AS `MAX(d)`,min(`test`.`t`.`d`) AS `MIN(d)` from `test`.`t` where ((`test`.`t`.`a` > 9) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40)) and ((`test`.`t`.`d` = 1) or (`test`.`t`.`d` = 9) or (`test`.`t`.`d` is null))) group by `test`.`t`.`a`,`test`.`t`.`b` +FLUSH STATUS; +SELECT a, b, MAX(d), MIN(d) FROM t WHERE (a > 9) AND (c = 3 OR c = 40) AND +(d = 1 OR d = 9 OR d IS NULL) +GROUP BY a, b; +a b MAX(d) MIN(d) +10 1 9 1 +10 2 9 1 +10 3 9 1 +10 4 9 1 +10 5 9 1 +12 2 NULL NULL + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 81 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT a, b, MIN(d), MAX(d) FROM t WHERE (a > 9) AND (c = 3 OR c = 40) AND +(d = 0 OR d = 9 OR d IS NULL) +GROUP BY a, b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 20 NULL 12 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,min(`test`.`t`.`d`) AS `MIN(d)`,max(`test`.`t`.`d`) AS `MAX(d)` from `test`.`t` where ((`test`.`t`.`a` > 9) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40)) and ((`test`.`t`.`d` = 0) or (`test`.`t`.`d` = 9) or (`test`.`t`.`d` is null))) group by `test`.`t`.`a`,`test`.`t`.`b` +FLUSH STATUS; +SELECT a, b, MIN(d), MAX(d) FROM t WHERE (a > 9) AND (c = 3 OR c = 40) AND +(d = 0 OR d = 9 OR d IS NULL) +GROUP BY a, b; +a b MIN(d) MAX(d) +10 1 9 9 +10 2 9 9 +10 3 9 9 +10 4 9 9 +10 5 9 9 +12 2 NULL NULL + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 86 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT a, b, MIN(d), MAX(d) FROM t WHERE (a > 9) AND (c = 3 OR c = 40) AND +(d > 0 AND d < 2 OR d > 3 AND d < 5 OR d IS NULL) +GROUP BY a, b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 20 NULL 12 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,min(`test`.`t`.`d`) AS `MIN(d)`,max(`test`.`t`.`d`) AS `MAX(d)` from `test`.`t` where ((`test`.`t`.`a` > 9) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40)) and (((`test`.`t`.`d` > 0) and (`test`.`t`.`d` < 2)) or ((`test`.`t`.`d` > 3) and (`test`.`t`.`d` < 5)) or (`test`.`t`.`d` is null))) group by `test`.`t`.`a`,`test`.`t`.`b` +FLUSH STATUS; +SELECT a, b, MIN(d), MAX(d) FROM t WHERE (a > 9) AND (c = 3 OR c = 40) AND +(d > 0 AND d < 2 OR d > 3 AND d < 5 OR d IS NULL) +GROUP BY a, b; +a b MIN(d) MAX(d) +10 1 1 4 +10 2 1 4 +10 3 1 4 +10 4 1 4 +10 5 1 4 +12 2 NULL NULL + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 80 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT a, b, MIN(d) FROM t WHERE (a > 9) AND (c = 3 OR c = 40) AND +(d < 2 OR d > 5 OR d IS NULL) +GROUP BY a, b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 20 NULL 12 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,min(`test`.`t`.`d`) AS `MIN(d)` from `test`.`t` where ((`test`.`t`.`a` > 9) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40)) and ((`test`.`t`.`d` < 2) or (`test`.`t`.`d` > 5) or (`test`.`t`.`d` is null))) group by `test`.`t`.`a`,`test`.`t`.`b` +FLUSH STATUS; +SELECT a, b, MIN(d) FROM t WHERE (a > 9) AND (c = 3 OR c = 40) AND +(d < 2 OR d > 5 OR d IS NULL) +GROUP BY a, b; +a b MIN(d) +10 1 1 +10 2 1 +10 3 1 +10 4 1 +10 5 1 +11 2 -10 +11 3 20 +11 NULL 30 +12 15 -20 +12 2 -23 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 47 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT a, b , max(d) FROM t WHERE (a >= 10) AND (c = 3 or c=40) AND +(d is NULL or d = -10 or d = -23) +GROUP BY a, b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 20 NULL 12 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,max(`test`.`t`.`d`) AS `max(d)` from `test`.`t` where ((`test`.`t`.`a` >= 10) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40)) and ((`test`.`t`.`d` is null) or (`test`.`t`.`d` = (-(10))) or (`test`.`t`.`d` = (-(23))))) group by `test`.`t`.`a`,`test`.`t`.`b` +FLUSH STATUS; +SELECT a, b , max(d) FROM t WHERE (a >= 10) AND (c = 3 or c=40) AND +(d is NULL or d = -10 or d = -23) +GROUP BY a, b; +a b max(d) +11 2 -10 +12 2 -23 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 75 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT a, b , min(d) FROM t WHERE (a >= 10) AND (c = 3 or c=40) AND +(d is NULL or d = -10 or d = -23) +GROUP BY a, b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 20 NULL 12 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,min(`test`.`t`.`d`) AS `min(d)` from `test`.`t` where ((`test`.`t`.`a` >= 10) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40)) and ((`test`.`t`.`d` is null) or (`test`.`t`.`d` = (-(10))) or (`test`.`t`.`d` = (-(23))))) group by `test`.`t`.`a`,`test`.`t`.`b` +FLUSH STATUS; +SELECT a, b , min(d) FROM t WHERE (a >= 10) AND (c = 3 or c=40) AND +(d is NULL or d = -10 or d = -23) +GROUP BY a, b; +a b min(d) +11 2 -10 +12 2 -23 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 77 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT a, MIN(b), MAX(b) FROM t WHERE a > 9 GROUP BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 10 NULL 1 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,min(`test`.`t`.`b`) AS `MIN(b)`,max(`test`.`t`.`b`) AS `MAX(b)` from `test`.`t` where (`test`.`t`.`a` > 9) group by `test`.`t`.`a` +FLUSH STATUS; +SELECT a, MIN(b), MAX(b) FROM t WHERE a > 9 GROUP BY a; +a MIN(b) MAX(b) +10 1 5 +11 2 15 +12 2 15 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 9 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +ALTER TABLE t ADD KEY k2(a DESC, b, c DESC, d); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +SELECT a, b, MIN(d) FROM t +WHERE (a > 4) AND (c = 3 or c = 40) AND (d > 7) GROUP BY a, b; +a b MIN(d) +10 1 8 +10 2 8 +10 3 8 +10 4 8 +10 5 8 +11 3 20 +11 NULL 30 +5 1 8 +5 2 8 +5 3 8 +5 4 8 +5 5 8 +6 1 8 +6 2 8 +6 3 8 +6 4 8 +6 5 8 +7 1 8 +7 2 8 +7 3 8 +7 4 8 +7 5 8 +8 1 8 +8 2 8 +8 3 8 +8 4 8 +8 5 8 +9 1 8 +9 2 8 +9 3 8 +9 4 8 +9 5 8 +SELECT a, b, MIN(d) FROM t +WHERE (a > 4) AND (c = 3 or c = 40) AND (d > 7) GROUP BY a, b; +a b MIN(d) +10 1 8 +10 2 8 +10 3 8 +10 4 8 +10 5 8 +11 3 20 +11 NULL 30 +5 1 8 +5 2 8 +5 3 8 +5 4 8 +5 5 8 +6 1 8 +6 2 8 +6 3 8 +6 4 8 +6 5 8 +7 1 8 +7 2 8 +7 3 8 +7 4 8 +7 5 8 +8 1 8 +8 2 8 +8 3 8 +8 4 8 +8 5 8 +9 1 8 +9 2 8 +9 3 8 +9 4 8 +9 5 8 +ALTER TABLE t DROP KEY k2; +EXPLAIN SELECT a, b FROM t WHERE (a > 4) AND (c = 3 OR c > 6) GROUP BY a, b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1508 40.00 Parallel execute (4 workers) +2 SIMPLE t NULL range k1 k1 5 NULL 1508 40.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b` from `test`.`t` where ((`test`.`t`.`a` > 4) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` > 6))) group by `test`.`t`.`a`,`test`.`t`.`b` +EXPLAIN SELECT a, b FROM t WHERE (a > 4) AND (c = 3 OR c = 40) AND +(d = -1 OR d = -2 OR d > 7) GROUP BY a, b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1508 8.74 Parallel execute (4 workers) +2 SIMPLE t NULL range k1 k1 5 NULL 1508 8.74 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b` from `test`.`t` where ((`test`.`t`.`a` > 4) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40)) and ((`test`.`t`.`d` = (-(1))) or (`test`.`t`.`d` = (-(2))) or (`test`.`t`.`d` > 7))) group by `test`.`t`.`a`,`test`.`t`.`b` +ALTER TABLE t DROP KEY k1; +ALTER TABLE t ADD KEY k1(a, b, c, d DESC); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +EXPLAIN SELECT a, b, MIN(d) FROM t WHERE (a > 9) AND (c = 3) GROUP BY a, b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 20 NULL 6 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,min(`test`.`t`.`d`) AS `MIN(d)` from `test`.`t` where ((`test`.`t`.`c` = 3) and (`test`.`t`.`a` > 9)) group by `test`.`t`.`a`,`test`.`t`.`b` +SELECT a, b, MIN(d) FROM t WHERE (a > 9) AND (c = 3) GROUP BY a, b; +a b MIN(d) +10 1 1 +10 2 1 +10 3 1 +10 4 1 +10 5 1 +11 2 -10 +11 3 20 +12 2 NULL +12 15 -15 +EXPLAIN SELECT a, b, MIN(d), MAX(d) FROM t WHERE (a > 9) AND (c = 3) GROUP BY a, b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 20 NULL 6 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,min(`test`.`t`.`d`) AS `MIN(d)`,max(`test`.`t`.`d`) AS `MAX(d)` from `test`.`t` where ((`test`.`t`.`c` = 3) and (`test`.`t`.`a` > 9)) group by `test`.`t`.`a`,`test`.`t`.`b` +SELECT a, b, MIN(d), MAX(d) FROM t WHERE (a > 9) AND (c = 3) GROUP BY a, b; +a b MIN(d) MAX(d) +10 1 1 10 +10 2 1 10 +10 3 1 10 +10 4 1 10 +10 5 1 10 +11 2 -10 -10 +11 3 20 20 +12 2 NULL NULL +12 15 -15 -15 +ALTER TABLE t DROP KEY k1; +ALTER TABLE t ADD KEY k1(a DESC, b, c DESC, d); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +EXPLAIN SELECT a, MAX(d), MIN(d) FROM t WHERE (b = 2 OR b = 15 OR b = 3) AND (c = 3 OR c = 40) GROUP BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 20 NULL 78 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,max(`test`.`t`.`d`) AS `MAX(d)`,min(`test`.`t`.`d`) AS `MIN(d)` from `test`.`t` where (((`test`.`t`.`b` = 2) or (`test`.`t`.`b` = 15) or (`test`.`t`.`b` = 3)) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40))) group by `test`.`t`.`a` +FLUSH STATUS; +SELECT a, MAX(d), MIN(d) FROM t WHERE (b = 2 OR b = 15 OR b = 3) AND (c = 3 OR c = 40) GROUP BY a; +a MAX(d) MIN(d) +1 10 1 +10 10 1 +11 20 -10 +12 -15 -23 +2 10 1 +3 10 1 +4 10 1 +5 10 1 +6 10 1 +7 10 1 +8 10 1 +9 10 1 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 1 +Handler_read_key 113 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT a, MAX(d), MIN(d) FROM t WHERE (b = 2 OR b = 15) AND (c = 3 OR c = 40) GROUP BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 20 NULL 52 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,max(`test`.`t`.`d`) AS `MAX(d)`,min(`test`.`t`.`d`) AS `MIN(d)` from `test`.`t` where (((`test`.`t`.`b` = 2) or (`test`.`t`.`b` = 15)) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40))) group by `test`.`t`.`a` +FLUSH STATUS; +SELECT a, MAX(d), MIN(d) FROM t WHERE (b = 2 OR b = 15) AND (c = 3 OR c = 40) GROUP BY a; +a MAX(d) MIN(d) +1 10 1 +10 10 1 +11 -10 -10 +12 -15 -23 +2 10 1 +3 10 1 +4 10 1 +5 10 1 +6 10 1 +7 10 1 +8 10 1 +9 10 1 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 1 +Handler_read_key 78 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT a, MAX(d), MIN(d) FROM t WHERE (b = 2 OR b = 15) AND (c = 3 OR c IS NULL) GROUP BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 20 NULL 52 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,max(`test`.`t`.`d`) AS `MAX(d)`,min(`test`.`t`.`d`) AS `MIN(d)` from `test`.`t` where (((`test`.`t`.`b` = 2) or (`test`.`t`.`b` = 15)) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` is null))) group by `test`.`t`.`a` +FLUSH STATUS; +SELECT a, MAX(d), MIN(d) FROM t WHERE (b = 2 OR b = 15) AND (c = 3 OR c IS NULL) GROUP BY a; +a MAX(d) MIN(d) +1 10 1 +10 10 1 +11 -10 -20 +12 -15 -15 +2 10 1 +3 10 1 +4 10 1 +5 10 1 +6 10 1 +7 10 1 +8 10 1 +9 10 1 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 1 +Handler_read_key 77 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT a, MAX(d), MIN(d) FROM t WHERE (b IS NULL OR b = 15) AND (c = 3 OR c = 40) GROUP BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 20 NULL 52 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,max(`test`.`t`.`d`) AS `MAX(d)`,min(`test`.`t`.`d`) AS `MIN(d)` from `test`.`t` where (((`test`.`t`.`b` is null) or (`test`.`t`.`b` = 15)) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40))) group by `test`.`t`.`a` +FLUSH STATUS; +SELECT a, MAX(d), MIN(d) FROM t WHERE (b IS NULL OR b = 15) AND (c = 3 OR c = 40) GROUP BY a; +a MAX(d) MIN(d) +11 30 30 +12 -15 -20 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 1 +Handler_read_key 64 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT a, MAX(d), MIN(d) FROM t WHERE (b IS NULL OR b = 2) AND (c = 3 OR c = 40) GROUP BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 20 NULL 52 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,max(`test`.`t`.`d`) AS `MAX(d)`,min(`test`.`t`.`d`) AS `MIN(d)` from `test`.`t` where (((`test`.`t`.`b` is null) or (`test`.`t`.`b` = 2)) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40))) group by `test`.`t`.`a` +FLUSH STATUS; +SELECT a, MAX(d), MIN(d) FROM t WHERE (b IS NULL OR b = 2) AND (c = 3 OR c = 40) GROUP BY a; +a MAX(d) MIN(d) +1 10 1 +10 10 1 +11 30 -10 +12 -23 -23 +2 10 1 +3 10 1 +4 10 1 +5 10 1 +6 10 1 +7 10 1 +8 10 1 +9 10 1 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 1 +Handler_read_key 77 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT a FROM t WHERE (b = 2 OR b = 15 OR b = 3) AND (c = 3 OR c = 40) GROUP BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 15 NULL 78 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a` from `test`.`t` where (((`test`.`t`.`b` = 2) or (`test`.`t`.`b` = 15) or (`test`.`t`.`b` = 3)) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40))) group by `test`.`t`.`a` +FLUSH STATUS; +SELECT a FROM t WHERE (b = 2 OR b = 15 OR b = 3) AND (c = 3 OR c = 40) GROUP BY a; +a +1 +10 +11 +12 +2 +3 +4 +5 +6 +7 +8 +9 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 1 +Handler_read_key 37 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT a, b, MAX(d), MIN(d) FROM t WHERE (b = 2 OR b = 15) AND (c = 3 OR c = 40) GROUP BY a, b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 20 NULL 114 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,max(`test`.`t`.`d`) AS `MAX(d)`,min(`test`.`t`.`d`) AS `MIN(d)` from `test`.`t` where (((`test`.`t`.`b` = 2) or (`test`.`t`.`b` = 15)) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40))) group by `test`.`t`.`a`,`test`.`t`.`b` +FLUSH STATUS; +SELECT a, b, MAX(d), MIN(d) FROM t WHERE (b = 2 OR b = 15) AND (c = 3 OR c = 40) GROUP BY a, b; +a b MAX(d) MIN(d) +1 2 10 1 +10 2 10 1 +11 2 -10 -10 +12 15 -15 -20 +12 2 -23 -23 +2 2 10 1 +3 2 10 1 +4 2 10 1 +5 2 10 1 +6 2 10 1 +7 2 10 1 +8 2 10 1 +9 2 10 1 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 1 +Handler_read_key 228 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT a, b, MAX(d), MIN(d) FROM t WHERE (b = 2 OR b = 15 OR b = 3) AND (c = 3 OR c = 40) +GROUP BY a, b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 20 NULL 114 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,max(`test`.`t`.`d`) AS `MAX(d)`,min(`test`.`t`.`d`) AS `MIN(d)` from `test`.`t` where (((`test`.`t`.`b` = 2) or (`test`.`t`.`b` = 15) or (`test`.`t`.`b` = 3)) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40))) group by `test`.`t`.`a`,`test`.`t`.`b` +FLUSH STATUS; +SELECT a, b, MAX(d), MIN(d) FROM t WHERE (b = 2 OR b = 15 OR b = 3) AND (c = 3 OR c = 40) +GROUP BY a, b; +a b MAX(d) MIN(d) +1 2 10 1 +1 3 10 1 +10 2 10 1 +10 3 10 1 +11 2 -10 -10 +11 3 20 20 +12 15 -15 -20 +12 2 -23 -23 +2 2 10 1 +2 3 10 1 +3 2 10 1 +3 3 10 1 +4 2 10 1 +4 3 10 1 +5 2 10 1 +5 3 10 1 +6 2 10 1 +6 3 10 1 +7 2 10 1 +7 3 10 1 +8 2 10 1 +8 3 10 1 +9 2 10 1 +9 3 10 1 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 1 +Handler_read_key 228 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT DISTINCT a FROM t WHERE a = 1 AND (b = 2 OR b = 15); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 10 NULL 2 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select distinct `test`.`t`.`a` AS `a` from `test`.`t` where ((`test`.`t`.`a` = 1) and ((`test`.`t`.`b` = 2) or (`test`.`t`.`b` = 15))) +FLUSH STATUS; +SELECT DISTINCT a FROM t WHERE a = 1 AND (b = 2 OR b = 15); +a +1 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 4 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT a, MAX(d), MIN(d) FROM t WHERE a = 1 AND (c = 3 OR c = 40) AND (d = 1 OR d = 9) +GROUP BY a, b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 20 NULL 12 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,max(`test`.`t`.`d`) AS `MAX(d)`,min(`test`.`t`.`d`) AS `MIN(d)` from `test`.`t` where ((`test`.`t`.`a` = 1) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40)) and ((`test`.`t`.`d` = 1) or (`test`.`t`.`d` = 9))) group by `test`.`t`.`a`,`test`.`t`.`b` +FLUSH STATUS; +SELECT a, MAX(d), MIN(d) FROM t WHERE a = 1 AND (c = 3 OR c = 40) AND (d = 1 OR d = 9) +GROUP BY a, b; +a MAX(d) MIN(d) +1 9 1 +1 9 1 +1 9 1 +1 9 1 +1 9 1 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 27 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT a, b, MAX(d), MIN(d) FROM t WHERE (a = 1 OR a = 12) AND (b = 2 OR b = 15) AND (c = 3 OR c = 40) +GROUP BY a, b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 20 NULL 2 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,max(`test`.`t`.`d`) AS `MAX(d)`,min(`test`.`t`.`d`) AS `MIN(d)` from `test`.`t` where (((`test`.`t`.`a` = 1) or (`test`.`t`.`a` = 12)) and ((`test`.`t`.`b` = 2) or (`test`.`t`.`b` = 15)) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40))) group by `test`.`t`.`a`,`test`.`t`.`b` +FLUSH STATUS; +SELECT a, b, MAX(d), MIN(d) FROM t WHERE (a = 1 OR a = 12) AND (b = 2 OR b = 15) AND (c = 3 OR c = 40) +GROUP BY a, b; +a b MAX(d) MIN(d) +1 2 10 1 +12 15 -15 -20 +12 2 -23 -23 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 20 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT a, b, MAX(d), MIN(d) FROM t WHERE (a < 2 OR a > 11) AND (b = 2 OR b = 15) AND (c = 3 OR c = 40) +GROUP BY a, b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 20 NULL 12 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,max(`test`.`t`.`d`) AS `MAX(d)`,min(`test`.`t`.`d`) AS `MIN(d)` from `test`.`t` where (((`test`.`t`.`a` < 2) or (`test`.`t`.`a` > 11)) and ((`test`.`t`.`b` = 2) or (`test`.`t`.`b` = 15)) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40))) group by `test`.`t`.`a`,`test`.`t`.`b` +FLUSH STATUS; +SELECT a, b, MAX(d), MIN(d) FROM t WHERE (a < 2 OR a > 11) AND (b = 2 OR b = 15) AND (c = 3 OR c = 40) +GROUP BY a, b; +a b MAX(d) MIN(d) +1 2 10 1 +12 15 -15 -20 +12 2 -23 -23 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 1 +Handler_read_key 34 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT DISTINCT a, b FROM t WHERE (a = 1 OR a = 12) AND (b = 2 OR b = 15) AND (c = 3 OR c = 40); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 15 NULL 2 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select distinct `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b` from `test`.`t` where (((`test`.`t`.`a` = 1) or (`test`.`t`.`a` = 12)) and ((`test`.`t`.`b` = 2) or (`test`.`t`.`b` = 15)) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40))) +FLUSH STATUS; +SELECT DISTINCT a, b FROM t WHERE (a = 1 OR a = 12) AND (b = 2 OR b = 15) AND (c = 3 OR c = 40); +a b +1 2 +12 15 +12 2 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 12 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT DISTINCT a FROM t WHERE (a = 1 OR a = 12) AND (b = 2 OR b = 15); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 10 NULL 2 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select distinct `test`.`t`.`a` AS `a` from `test`.`t` where (((`test`.`t`.`a` = 1) or (`test`.`t`.`a` = 12)) and ((`test`.`t`.`b` = 2) or (`test`.`t`.`b` = 15))) +FLUSH STATUS; +SELECT DISTINCT a FROM t WHERE (a = 1 OR a = 12) AND (b = 2 OR b = 15); +a +1 +12 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 7 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT a, b, MAX(d), MIN(d) FROM t WHERE (a = 1 OR a = 12) AND (b < 4 OR b > 10) AND (c = 3 OR c = 40) +GROUP BY a, b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 20 NULL 8 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,max(`test`.`t`.`d`) AS `MAX(d)`,min(`test`.`t`.`d`) AS `MIN(d)` from `test`.`t` where (((`test`.`t`.`a` = 1) or (`test`.`t`.`a` = 12)) and ((`test`.`t`.`b` < 4) or (`test`.`t`.`b` > 10)) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40))) group by `test`.`t`.`a`,`test`.`t`.`b` +FLUSH STATUS; +SELECT a, b, MAX(d), MIN(d) FROM t WHERE (a = 1 OR a = 12) AND (b < 4 OR b > 10) AND (c = 3 OR c = 40) +GROUP BY a, b; +a b MAX(d) MIN(d) +1 1 10 1 +1 2 10 1 +1 3 10 1 +12 15 -15 -20 +12 2 -23 -23 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 28 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT a, MAX(d), MIN(d) FROM t WHERE (a = 1 OR a > 9) AND (b = 2 OR b = 15) AND (c = 3 OR c = 40) +GROUP BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 20 NULL 4 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,max(`test`.`t`.`d`) AS `MAX(d)`,min(`test`.`t`.`d`) AS `MIN(d)` from `test`.`t` where (((`test`.`t`.`a` = 1) or (`test`.`t`.`a` > 9)) and ((`test`.`t`.`b` = 2) or (`test`.`t`.`b` = 15)) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40))) group by `test`.`t`.`a` +FLUSH STATUS; +SELECT a, MAX(d), MIN(d) FROM t WHERE (a = 1 OR a > 9) AND (b = 2 OR b = 15) AND (c = 3 OR c = 40) +GROUP BY a; +a MAX(d) MIN(d) +1 10 1 +10 10 1 +11 -10 -10 +12 -15 -23 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 1 +Handler_read_key 31 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT COUNT(DISTINCT a, b) FROM t WHERE (a = 1 OR a = 12) AND (b = 2 OR b = 15) AND (c = 3 OR c = 40); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 15 NULL 2 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select count(distinct `test`.`t`.`a`,`test`.`t`.`b`) AS `COUNT(DISTINCT a, b)` from `test`.`t` where (((`test`.`t`.`a` = 1) or (`test`.`t`.`a` = 12)) and ((`test`.`t`.`b` = 2) or (`test`.`t`.`b` = 15)) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40))) +FLUSH STATUS; +SELECT COUNT(DISTINCT a, b) FROM t WHERE (a = 1 OR a = 12) AND (b = 2 OR b = 15) AND (c = 3 OR c = 40); +COUNT(DISTINCT a, b) +3 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 12 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT SUM(DISTINCT a), AVG(DISTINCT a) FROM t WHERE (b = 2 OR b = 15) AND (c = 3 OR c = 40); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 15 NULL 52 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select sum(distinct `test`.`t`.`a`) AS `SUM(DISTINCT a)`,avg(distinct `test`.`t`.`a`) AS `AVG(DISTINCT a)` from `test`.`t` where (((`test`.`t`.`b` = 2) or (`test`.`t`.`b` = 15)) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40))) +FLUSH STATUS; +SELECT SUM(DISTINCT a), AVG(DISTINCT a) FROM t WHERE (b = 2 OR b = 15) AND (c = 3 OR c = 40); +SUM(DISTINCT a) AVG(DISTINCT a) +78 6.5000 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 1 +Handler_read_key 37 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT SUM(DISTINCT a), AVG(DISTINCT a), COUNT(DISTINCT a) FROM t WHERE (b = 2 OR b = 15) AND (c = 3 OR c = 40); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 15 NULL 52 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select sum(distinct `test`.`t`.`a`) AS `SUM(DISTINCT a)`,avg(distinct `test`.`t`.`a`) AS `AVG(DISTINCT a)`,count(distinct `test`.`t`.`a`) AS `COUNT(DISTINCT a)` from `test`.`t` where (((`test`.`t`.`b` = 2) or (`test`.`t`.`b` = 15)) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40))) +FLUSH STATUS; +SELECT SUM(DISTINCT a), AVG(DISTINCT a), COUNT(DISTINCT a) FROM t WHERE (b = 2 OR b = 15) AND (c = 3 OR c = 40); +SUM(DISTINCT a) AVG(DISTINCT a) COUNT(DISTINCT a) +78 6.5000 12 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 1 +Handler_read_key 37 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT a, MAX(d), MIN(d) FROM t WHERE (a > 11) AND (b = 2 OR b = 15) AND +(c = 3 OR c = 1 OR c = 2 OR c = 4) +GROUP BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 6.53 Parallel execute (1 workers) +2 SIMPLE t NULL range k1 k1 5 NULL 4 6.53 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,max(`test`.`t`.`d`) AS `MAX(d)`,min(`test`.`t`.`d`) AS `MIN(d)` from `test`.`t` where ((`test`.`t`.`a` > 11) and ((`test`.`t`.`b` = 2) or (`test`.`t`.`b` = 15)) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 1) or (`test`.`t`.`c` = 2) or (`test`.`t`.`c` = 4))) group by `test`.`t`.`a` +FLUSH STATUS; +SELECT a, MAX(d), MIN(d) FROM t WHERE (a > 11) AND (b = 2 OR b = 15) AND +(c = 3 OR c = 1 OR c = 2 OR c = 4) +GROUP BY a; +a MAX(d) MIN(d) +12 -15 -15 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 1 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 5 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT a, b, MAX(d), MIN(d) FROM t WHERE (c = 3 OR c = 40) AND (d > 7 OR d =2) GROUP BY a, b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 20 NULL 114 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,max(`test`.`t`.`d`) AS `MAX(d)`,min(`test`.`t`.`d`) AS `MIN(d)` from `test`.`t` where (((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40)) and ((`test`.`t`.`d` > 7) or (`test`.`t`.`d` = 2))) group by `test`.`t`.`a`,`test`.`t`.`b` +FLUSH STATUS; +SELECT a, b, MAX(d), MIN(d) FROM t WHERE (c = 3 OR c = 40) AND (d > 7 OR d =2) GROUP BY a, b; +a b MAX(d) MIN(d) +1 1 10 2 +1 2 10 2 +1 3 10 2 +1 4 10 2 +1 5 10 2 +10 1 10 2 +10 2 10 2 +10 3 10 2 +10 4 10 2 +10 5 10 2 +11 3 20 20 +11 NULL 30 30 +2 1 10 2 +2 2 10 2 +2 3 10 2 +2 4 10 2 +2 5 10 2 +3 1 10 2 +3 2 10 2 +3 3 10 2 +3 4 10 2 +3 5 10 2 +4 1 10 2 +4 2 10 2 +4 3 10 2 +4 4 10 2 +4 5 10 2 +5 1 10 2 +5 2 10 2 +5 3 10 2 +5 4 10 2 +5 5 10 2 +6 1 10 2 +6 2 10 2 +6 3 10 2 +6 4 10 2 +6 5 10 2 +7 1 10 2 +7 2 10 2 +7 3 10 2 +7 4 10 2 +7 5 10 2 +8 1 10 2 +8 2 10 2 +8 3 10 2 +8 4 10 2 +8 5 10 2 +9 1 10 2 +9 2 10 2 +9 3 10 2 +9 4 10 2 +9 5 10 2 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 1 +Handler_read_key 284 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT a, b, MAX(d), MIN(d) FROM t WHERE (c = 3 OR c = 40) AND (d > 7 OR d =2 OR d IS NULL) +GROUP BY a, b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 20 NULL 114 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,max(`test`.`t`.`d`) AS `MAX(d)`,min(`test`.`t`.`d`) AS `MIN(d)` from `test`.`t` where (((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40)) and ((`test`.`t`.`d` > 7) or (`test`.`t`.`d` = 2) or (`test`.`t`.`d` is null))) group by `test`.`t`.`a`,`test`.`t`.`b` +FLUSH STATUS; +SELECT a, b, MAX(d), MIN(d) FROM t WHERE (c = 3 OR c = 40) AND (d > 7 OR d =2 OR d IS NULL) +GROUP BY a, b; +a b MAX(d) MIN(d) +1 1 10 2 +1 2 10 2 +1 3 10 2 +1 4 10 2 +1 5 10 2 +10 1 10 2 +10 2 10 2 +10 3 10 2 +10 4 10 2 +10 5 10 2 +11 3 20 20 +11 NULL 30 30 +12 2 NULL NULL +2 1 10 2 +2 2 10 2 +2 3 10 2 +2 4 10 2 +2 5 10 2 +3 1 10 2 +3 2 10 2 +3 3 10 2 +3 4 10 2 +3 5 10 2 +4 1 10 2 +4 2 10 2 +4 3 10 2 +4 4 10 2 +4 5 10 2 +5 1 10 2 +5 2 10 2 +5 3 10 2 +5 4 10 2 +5 5 10 2 +6 1 10 2 +6 2 10 2 +6 3 10 2 +6 4 10 2 +6 5 10 2 +7 1 10 2 +7 2 10 2 +7 3 10 2 +7 4 10 2 +7 5 10 2 +8 1 10 2 +8 2 10 2 +8 3 10 2 +8 4 10 2 +8 5 10 2 +9 1 10 2 +9 2 10 2 +9 3 10 2 +9 4 10 2 +9 5 10 2 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 1 +Handler_read_key 399 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT a, b, MIN(d) FROM t WHERE (a > 5) AND (c = 3 OR c = 40) AND +(d < -24 OR d = 3 OR d IS NULL) +GROUP BY a, b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 20 NULL 58 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,min(`test`.`t`.`d`) AS `MIN(d)` from `test`.`t` where ((`test`.`t`.`a` > 5) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40)) and ((`test`.`t`.`d` < (-(24))) or (`test`.`t`.`d` = 3) or (`test`.`t`.`d` is null))) group by `test`.`t`.`a`,`test`.`t`.`b` +FLUSH STATUS; +SELECT a, b, MIN(d) FROM t WHERE (a > 5) AND (c = 3 OR c = 40) AND +(d < -24 OR d = 3 OR d IS NULL) +GROUP BY a, b; +a b MIN(d) +10 1 3 +10 2 3 +10 3 3 +10 4 3 +10 5 3 +12 2 NULL +6 1 3 +6 2 3 +6 3 3 +6 4 3 +6 5 3 +7 1 3 +7 2 3 +7 3 3 +7 4 3 +7 5 3 +8 1 3 +8 2 3 +8 3 3 +8 4 3 +8 5 3 +9 1 3 +9 2 3 +9 3 3 +9 4 3 +9 5 3 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 1 +Handler_read_key 156 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT a, b, MAX(d), MIN(d) FROM t WHERE (a > 5) AND (c = 3 OR c = 40) AND (d < 1 OR d = 9) +GROUP BY a, b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 20 NULL 58 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,max(`test`.`t`.`d`) AS `MAX(d)`,min(`test`.`t`.`d`) AS `MIN(d)` from `test`.`t` where ((`test`.`t`.`a` > 5) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40)) and ((`test`.`t`.`d` < 1) or (`test`.`t`.`d` = 9))) group by `test`.`t`.`a`,`test`.`t`.`b` +FLUSH STATUS; +SELECT a, b, MAX(d), MIN(d) FROM t WHERE (a > 5) AND (c = 3 OR c = 40) AND (d < 1 OR d = 9) +GROUP BY a, b; +a b MAX(d) MIN(d) +10 1 9 9 +10 2 9 9 +10 3 9 9 +10 4 9 9 +10 5 9 9 +11 2 -10 -10 +12 15 -15 -20 +12 2 -23 -23 +6 1 9 9 +6 2 9 9 +6 3 9 9 +6 4 9 9 +6 5 9 9 +7 1 9 9 +7 2 9 9 +7 3 9 9 +7 4 9 9 +7 5 9 9 +8 1 9 9 +8 2 9 9 +8 3 9 9 +8 4 9 9 +8 5 9 9 +9 1 9 9 +9 2 9 9 +9 3 9 9 +9 4 9 9 +9 5 9 9 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 1 +Handler_read_key 186 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT a, b, MAX(d), MIN(d) FROM t WHERE (a > 9) AND (c = 3 OR c = 40) AND +(d = 1 OR d = 9 OR d IS NULL) +GROUP BY a, b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 20 NULL 12 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,max(`test`.`t`.`d`) AS `MAX(d)`,min(`test`.`t`.`d`) AS `MIN(d)` from `test`.`t` where ((`test`.`t`.`a` > 9) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40)) and ((`test`.`t`.`d` = 1) or (`test`.`t`.`d` = 9) or (`test`.`t`.`d` is null))) group by `test`.`t`.`a`,`test`.`t`.`b` +FLUSH STATUS; +SELECT a, b, MAX(d), MIN(d) FROM t WHERE (a > 9) AND (c = 3 OR c = 40) AND +(d = 1 OR d = 9 OR d IS NULL) +GROUP BY a, b; +a b MAX(d) MIN(d) +10 1 9 1 +10 2 9 1 +10 3 9 1 +10 4 9 1 +10 5 9 1 +12 2 NULL NULL + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 1 +Handler_read_key 82 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT a, b, MIN(d), MAX(d) FROM t WHERE (a > 9) AND (c = 3 OR c = 40) AND +(d = 0 OR d = 9 OR d IS NULL) +GROUP BY a, b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 20 NULL 12 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,min(`test`.`t`.`d`) AS `MIN(d)`,max(`test`.`t`.`d`) AS `MAX(d)` from `test`.`t` where ((`test`.`t`.`a` > 9) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40)) and ((`test`.`t`.`d` = 0) or (`test`.`t`.`d` = 9) or (`test`.`t`.`d` is null))) group by `test`.`t`.`a`,`test`.`t`.`b` +FLUSH STATUS; +SELECT a, b, MIN(d), MAX(d) FROM t WHERE (a > 9) AND (c = 3 OR c = 40) AND +(d = 0 OR d = 9 OR d IS NULL) +GROUP BY a, b; +a b MIN(d) MAX(d) +10 1 9 9 +10 2 9 9 +10 3 9 9 +10 4 9 9 +10 5 9 9 +12 2 NULL NULL + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 1 +Handler_read_key 87 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT a, b, MIN(d), MAX(d) FROM t WHERE (a > 9) AND (c = 3 OR c = 40) AND +(d > 0 AND d < 2 OR d > 3 AND d < 5 OR d IS NULL) +GROUP BY a, b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 20 NULL 12 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,min(`test`.`t`.`d`) AS `MIN(d)`,max(`test`.`t`.`d`) AS `MAX(d)` from `test`.`t` where ((`test`.`t`.`a` > 9) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40)) and (((`test`.`t`.`d` > 0) and (`test`.`t`.`d` < 2)) or ((`test`.`t`.`d` > 3) and (`test`.`t`.`d` < 5)) or (`test`.`t`.`d` is null))) group by `test`.`t`.`a`,`test`.`t`.`b` +FLUSH STATUS; +SELECT a, b, MIN(d), MAX(d) FROM t WHERE (a > 9) AND (c = 3 OR c = 40) AND +(d > 0 AND d < 2 OR d > 3 AND d < 5 OR d IS NULL) +GROUP BY a, b; +a b MIN(d) MAX(d) +10 1 1 4 +10 2 1 4 +10 3 1 4 +10 4 1 4 +10 5 1 4 +12 2 NULL NULL + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 1 +Handler_read_key 82 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT a, b, MIN(d) FROM t WHERE (a > 9) AND (c = 3 OR c = 40) AND +(d < 2 OR d > 5 OR d IS NULL) +GROUP BY a, b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 20 NULL 12 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,min(`test`.`t`.`d`) AS `MIN(d)` from `test`.`t` where ((`test`.`t`.`a` > 9) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40)) and ((`test`.`t`.`d` < 2) or (`test`.`t`.`d` > 5) or (`test`.`t`.`d` is null))) group by `test`.`t`.`a`,`test`.`t`.`b` +FLUSH STATUS; +SELECT a, b, MIN(d) FROM t WHERE (a > 9) AND (c = 3 OR c = 40) AND +(d < 2 OR d > 5 OR d IS NULL) +GROUP BY a, b; +a b MIN(d) +10 1 1 +10 2 1 +10 3 1 +10 4 1 +10 5 1 +11 2 -10 +11 3 20 +11 NULL 30 +12 15 -20 +12 2 -23 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 1 +Handler_read_key 47 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT a, b , max(d) FROM t WHERE (a >= 10) AND (c = 3 or c=40) AND +(d is NULL or d = -10 or d = -23) +GROUP BY a, b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 20 NULL 12 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,max(`test`.`t`.`d`) AS `max(d)` from `test`.`t` where ((`test`.`t`.`a` >= 10) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40)) and ((`test`.`t`.`d` is null) or (`test`.`t`.`d` = (-(10))) or (`test`.`t`.`d` = (-(23))))) group by `test`.`t`.`a`,`test`.`t`.`b` +FLUSH STATUS; +SELECT a, b , max(d) FROM t WHERE (a >= 10) AND (c = 3 or c=40) AND +(d is NULL or d = -10 or d = -23) +GROUP BY a, b; +a b max(d) +11 2 -10 +12 2 -23 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 1 +Handler_read_key 76 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT a, b , min(d) FROM t WHERE (a >= 10) AND (c = 3 or c=40) AND +(d is NULL or d = -10 or d = -23) +GROUP BY a, b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 20 NULL 12 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,min(`test`.`t`.`d`) AS `min(d)` from `test`.`t` where ((`test`.`t`.`a` >= 10) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40)) and ((`test`.`t`.`d` is null) or (`test`.`t`.`d` = (-(10))) or (`test`.`t`.`d` = (-(23))))) group by `test`.`t`.`a`,`test`.`t`.`b` +FLUSH STATUS; +SELECT a, b , min(d) FROM t WHERE (a >= 10) AND (c = 3 or c=40) AND +(d is NULL or d = -10 or d = -23) +GROUP BY a, b; +a b min(d) +11 2 -10 +12 2 -23 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 1 +Handler_read_key 78 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT a, MIN(b), MAX(b) FROM t WHERE a > 9 GROUP BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 10 NULL 1 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,min(`test`.`t`.`b`) AS `MIN(b)`,max(`test`.`t`.`b`) AS `MAX(b)` from `test`.`t` where (`test`.`t`.`a` > 9) group by `test`.`t`.`a` +FLUSH STATUS; +SELECT a, MIN(b), MAX(b) FROM t WHERE a > 9 GROUP BY a; +a MIN(b) MAX(b) +10 1 5 +11 2 15 +12 2 15 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 1 +Handler_read_key 9 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +ALTER TABLE t DROP KEY k1; +ALTER TABLE t ADD KEY k1(a, b DESC, c, d DESC); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +EXPLAIN SELECT a, MAX(d), MIN(d) FROM t WHERE (b = 2 OR b = 15 OR b = 3) AND (c = 3 OR c = 40) GROUP BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 20 NULL 78 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,max(`test`.`t`.`d`) AS `MAX(d)`,min(`test`.`t`.`d`) AS `MIN(d)` from `test`.`t` where (((`test`.`t`.`b` = 2) or (`test`.`t`.`b` = 15) or (`test`.`t`.`b` = 3)) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40))) group by `test`.`t`.`a` +FLUSH STATUS; +SELECT a, MAX(d), MIN(d) FROM t WHERE (b = 2 OR b = 15 OR b = 3) AND (c = 3 OR c = 40) GROUP BY a; +a MAX(d) MIN(d) +1 10 1 +10 10 1 +11 20 -10 +12 -15 -23 +2 10 1 +3 10 1 +4 10 1 +5 10 1 +6 10 1 +7 10 1 +8 10 1 +9 10 1 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 1 +Handler_read_key 113 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT a, MAX(d), MIN(d) FROM t WHERE (b = 2 OR b = 15) AND (c = 3 OR c = 40) GROUP BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 20 NULL 52 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,max(`test`.`t`.`d`) AS `MAX(d)`,min(`test`.`t`.`d`) AS `MIN(d)` from `test`.`t` where (((`test`.`t`.`b` = 2) or (`test`.`t`.`b` = 15)) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40))) group by `test`.`t`.`a` +FLUSH STATUS; +SELECT a, MAX(d), MIN(d) FROM t WHERE (b = 2 OR b = 15) AND (c = 3 OR c = 40) GROUP BY a; +a MAX(d) MIN(d) +1 10 1 +10 10 1 +11 -10 -10 +12 -15 -23 +2 10 1 +3 10 1 +4 10 1 +5 10 1 +6 10 1 +7 10 1 +8 10 1 +9 10 1 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 1 +Handler_read_key 78 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT a, MAX(d), MIN(d) FROM t WHERE (b = 2 OR b = 15) AND (c = 3 OR c IS NULL) GROUP BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 20 NULL 52 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,max(`test`.`t`.`d`) AS `MAX(d)`,min(`test`.`t`.`d`) AS `MIN(d)` from `test`.`t` where (((`test`.`t`.`b` = 2) or (`test`.`t`.`b` = 15)) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` is null))) group by `test`.`t`.`a` +FLUSH STATUS; +SELECT a, MAX(d), MIN(d) FROM t WHERE (b = 2 OR b = 15) AND (c = 3 OR c IS NULL) GROUP BY a; +a MAX(d) MIN(d) +1 10 1 +10 10 1 +11 -10 -20 +12 -15 -15 +2 10 1 +3 10 1 +4 10 1 +5 10 1 +6 10 1 +7 10 1 +8 10 1 +9 10 1 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 1 +Handler_read_key 77 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT a, MAX(d), MIN(d) FROM t WHERE (b IS NULL OR b = 15) AND (c = 3 OR c = 40) GROUP BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 20 NULL 52 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,max(`test`.`t`.`d`) AS `MAX(d)`,min(`test`.`t`.`d`) AS `MIN(d)` from `test`.`t` where (((`test`.`t`.`b` is null) or (`test`.`t`.`b` = 15)) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40))) group by `test`.`t`.`a` +FLUSH STATUS; +SELECT a, MAX(d), MIN(d) FROM t WHERE (b IS NULL OR b = 15) AND (c = 3 OR c = 40) GROUP BY a; +a MAX(d) MIN(d) +11 30 30 +12 -15 -20 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 1 +Handler_read_key 65 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT a, MAX(d), MIN(d) FROM t WHERE (b IS NULL OR b = 2) AND (c = 3 OR c = 40) GROUP BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 20 NULL 52 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,max(`test`.`t`.`d`) AS `MAX(d)`,min(`test`.`t`.`d`) AS `MIN(d)` from `test`.`t` where (((`test`.`t`.`b` is null) or (`test`.`t`.`b` = 2)) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40))) group by `test`.`t`.`a` +FLUSH STATUS; +SELECT a, MAX(d), MIN(d) FROM t WHERE (b IS NULL OR b = 2) AND (c = 3 OR c = 40) GROUP BY a; +a MAX(d) MIN(d) +1 10 1 +10 10 1 +11 30 -10 +12 -23 -23 +2 10 1 +3 10 1 +4 10 1 +5 10 1 +6 10 1 +7 10 1 +8 10 1 +9 10 1 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 1 +Handler_read_key 77 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT a FROM t WHERE (b = 2 OR b = 15 OR b = 3) AND (c = 3 OR c = 40) GROUP BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 15 NULL 78 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a` from `test`.`t` where (((`test`.`t`.`b` = 2) or (`test`.`t`.`b` = 15) or (`test`.`t`.`b` = 3)) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40))) group by `test`.`t`.`a` +FLUSH STATUS; +SELECT a FROM t WHERE (b = 2 OR b = 15 OR b = 3) AND (c = 3 OR c = 40) GROUP BY a; +a +1 +10 +11 +12 +2 +3 +4 +5 +6 +7 +8 +9 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 1 +Handler_read_key 48 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT a, b, MAX(d), MIN(d) FROM t WHERE (b = 2 OR b = 15) AND (c = 3 OR c = 40) GROUP BY a, b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 20 NULL 114 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,max(`test`.`t`.`d`) AS `MAX(d)`,min(`test`.`t`.`d`) AS `MIN(d)` from `test`.`t` where (((`test`.`t`.`b` = 2) or (`test`.`t`.`b` = 15)) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40))) group by `test`.`t`.`a`,`test`.`t`.`b` +FLUSH STATUS; +SELECT a, b, MAX(d), MIN(d) FROM t WHERE (b = 2 OR b = 15) AND (c = 3 OR c = 40) GROUP BY a, b; +a b MAX(d) MIN(d) +1 2 10 1 +10 2 10 1 +11 2 -10 -10 +12 15 -15 -20 +12 2 -23 -23 +2 2 10 1 +3 2 10 1 +4 2 10 1 +5 2 10 1 +6 2 10 1 +7 2 10 1 +8 2 10 1 +9 2 10 1 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 1 +Handler_read_key 228 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT a, b, MAX(d), MIN(d) FROM t WHERE (b = 2 OR b = 15 OR b = 3) AND (c = 3 OR c = 40) +GROUP BY a, b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 20 NULL 114 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,max(`test`.`t`.`d`) AS `MAX(d)`,min(`test`.`t`.`d`) AS `MIN(d)` from `test`.`t` where (((`test`.`t`.`b` = 2) or (`test`.`t`.`b` = 15) or (`test`.`t`.`b` = 3)) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40))) group by `test`.`t`.`a`,`test`.`t`.`b` +FLUSH STATUS; +SELECT a, b, MAX(d), MIN(d) FROM t WHERE (b = 2 OR b = 15 OR b = 3) AND (c = 3 OR c = 40) +GROUP BY a, b; +a b MAX(d) MIN(d) +1 2 10 1 +1 3 10 1 +10 2 10 1 +10 3 10 1 +11 2 -10 -10 +11 3 20 20 +12 15 -15 -20 +12 2 -23 -23 +2 2 10 1 +2 3 10 1 +3 2 10 1 +3 3 10 1 +4 2 10 1 +4 3 10 1 +5 2 10 1 +5 3 10 1 +6 2 10 1 +6 3 10 1 +7 2 10 1 +7 3 10 1 +8 2 10 1 +8 3 10 1 +9 2 10 1 +9 3 10 1 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 1 +Handler_read_key 228 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT DISTINCT a FROM t WHERE a = 1 AND (b = 2 OR b = 15); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 10 NULL 2 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select distinct `test`.`t`.`a` AS `a` from `test`.`t` where ((`test`.`t`.`a` = 1) and ((`test`.`t`.`b` = 2) or (`test`.`t`.`b` = 15))) +FLUSH STATUS; +SELECT DISTINCT a FROM t WHERE a = 1 AND (b = 2 OR b = 15); +a +1 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 5 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT a, MAX(d), MIN(d) FROM t WHERE a = 1 AND (c = 3 OR c = 40) AND (d = 1 OR d = 9) +GROUP BY a, b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 20 NULL 12 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,max(`test`.`t`.`d`) AS `MAX(d)`,min(`test`.`t`.`d`) AS `MIN(d)` from `test`.`t` where ((`test`.`t`.`a` = 1) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40)) and ((`test`.`t`.`d` = 1) or (`test`.`t`.`d` = 9))) group by `test`.`t`.`a`,`test`.`t`.`b` +FLUSH STATUS; +SELECT a, MAX(d), MIN(d) FROM t WHERE a = 1 AND (c = 3 OR c = 40) AND (d = 1 OR d = 9) +GROUP BY a, b; +a MAX(d) MIN(d) +1 9 1 +1 9 1 +1 9 1 +1 9 1 +1 9 1 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 27 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT a, b, MAX(d), MIN(d) FROM t WHERE (a = 1 OR a = 12) AND (b = 2 OR b = 15) AND (c = 3 OR c = 40) +GROUP BY a, b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 20 NULL 2 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,max(`test`.`t`.`d`) AS `MAX(d)`,min(`test`.`t`.`d`) AS `MIN(d)` from `test`.`t` where (((`test`.`t`.`a` = 1) or (`test`.`t`.`a` = 12)) and ((`test`.`t`.`b` = 2) or (`test`.`t`.`b` = 15)) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40))) group by `test`.`t`.`a`,`test`.`t`.`b` +FLUSH STATUS; +SELECT a, b, MAX(d), MIN(d) FROM t WHERE (a = 1 OR a = 12) AND (b = 2 OR b = 15) AND (c = 3 OR c = 40) +GROUP BY a, b; +a b MAX(d) MIN(d) +1 2 10 1 +12 15 -15 -20 +12 2 -23 -23 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 20 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT a, b, MAX(d), MIN(d) FROM t WHERE (a < 2 OR a > 11) AND (b = 2 OR b = 15) AND (c = 3 OR c = 40) +GROUP BY a, b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 20 NULL 12 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,max(`test`.`t`.`d`) AS `MAX(d)`,min(`test`.`t`.`d`) AS `MIN(d)` from `test`.`t` where (((`test`.`t`.`a` < 2) or (`test`.`t`.`a` > 11)) and ((`test`.`t`.`b` = 2) or (`test`.`t`.`b` = 15)) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40))) group by `test`.`t`.`a`,`test`.`t`.`b` +FLUSH STATUS; +SELECT a, b, MAX(d), MIN(d) FROM t WHERE (a < 2 OR a > 11) AND (b = 2 OR b = 15) AND (c = 3 OR c = 40) +GROUP BY a, b; +a b MAX(d) MIN(d) +1 2 10 1 +12 15 -15 -20 +12 2 -23 -23 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 34 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT DISTINCT a, b FROM t WHERE (a = 1 OR a = 12) AND (b = 2 OR b = 15) AND (c = 3 OR c = 40); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 15 NULL 2 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select distinct `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b` from `test`.`t` where (((`test`.`t`.`a` = 1) or (`test`.`t`.`a` = 12)) and ((`test`.`t`.`b` = 2) or (`test`.`t`.`b` = 15)) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40))) +FLUSH STATUS; +SELECT DISTINCT a, b FROM t WHERE (a = 1 OR a = 12) AND (b = 2 OR b = 15) AND (c = 3 OR c = 40); +a b +1 2 +12 15 +12 2 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 11 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT DISTINCT a FROM t WHERE (a = 1 OR a = 12) AND (b = 2 OR b = 15); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 10 NULL 2 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select distinct `test`.`t`.`a` AS `a` from `test`.`t` where (((`test`.`t`.`a` = 1) or (`test`.`t`.`a` = 12)) and ((`test`.`t`.`b` = 2) or (`test`.`t`.`b` = 15))) +FLUSH STATUS; +SELECT DISTINCT a FROM t WHERE (a = 1 OR a = 12) AND (b = 2 OR b = 15); +a +1 +12 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 8 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT a, b, MAX(d), MIN(d) FROM t WHERE (a = 1 OR a = 12) AND (b < 4 OR b > 10) AND (c = 3 OR c = 40) +GROUP BY a, b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 20 NULL 8 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,max(`test`.`t`.`d`) AS `MAX(d)`,min(`test`.`t`.`d`) AS `MIN(d)` from `test`.`t` where (((`test`.`t`.`a` = 1) or (`test`.`t`.`a` = 12)) and ((`test`.`t`.`b` < 4) or (`test`.`t`.`b` > 10)) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40))) group by `test`.`t`.`a`,`test`.`t`.`b` +FLUSH STATUS; +SELECT a, b, MAX(d), MIN(d) FROM t WHERE (a = 1 OR a = 12) AND (b < 4 OR b > 10) AND (c = 3 OR c = 40) +GROUP BY a, b; +a b MAX(d) MIN(d) +1 1 10 1 +1 2 10 1 +1 3 10 1 +12 15 -15 -20 +12 2 -23 -23 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 28 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT a, MAX(d), MIN(d) FROM t WHERE (a = 1 OR a > 9) AND (b = 2 OR b = 15) AND (c = 3 OR c = 40) +GROUP BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 20 NULL 4 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,max(`test`.`t`.`d`) AS `MAX(d)`,min(`test`.`t`.`d`) AS `MIN(d)` from `test`.`t` where (((`test`.`t`.`a` = 1) or (`test`.`t`.`a` > 9)) and ((`test`.`t`.`b` = 2) or (`test`.`t`.`b` = 15)) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40))) group by `test`.`t`.`a` +FLUSH STATUS; +SELECT a, MAX(d), MIN(d) FROM t WHERE (a = 1 OR a > 9) AND (b = 2 OR b = 15) AND (c = 3 OR c = 40) +GROUP BY a; +a MAX(d) MIN(d) +1 10 1 +10 10 1 +11 -10 -10 +12 -15 -23 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 31 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT COUNT(DISTINCT a, b) FROM t WHERE (a = 1 OR a = 12) AND (b = 2 OR b = 15) AND (c = 3 OR c = 40); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 15 NULL 2 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select count(distinct `test`.`t`.`a`,`test`.`t`.`b`) AS `COUNT(DISTINCT a, b)` from `test`.`t` where (((`test`.`t`.`a` = 1) or (`test`.`t`.`a` = 12)) and ((`test`.`t`.`b` = 2) or (`test`.`t`.`b` = 15)) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40))) +FLUSH STATUS; +SELECT COUNT(DISTINCT a, b) FROM t WHERE (a = 1 OR a = 12) AND (b = 2 OR b = 15) AND (c = 3 OR c = 40); +COUNT(DISTINCT a, b) +3 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 11 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT SUM(DISTINCT a), AVG(DISTINCT a) FROM t WHERE (b = 2 OR b = 15) AND (c = 3 OR c = 40); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 15 NULL 52 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select sum(distinct `test`.`t`.`a`) AS `SUM(DISTINCT a)`,avg(distinct `test`.`t`.`a`) AS `AVG(DISTINCT a)` from `test`.`t` where (((`test`.`t`.`b` = 2) or (`test`.`t`.`b` = 15)) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40))) +FLUSH STATUS; +SELECT SUM(DISTINCT a), AVG(DISTINCT a) FROM t WHERE (b = 2 OR b = 15) AND (c = 3 OR c = 40); +SUM(DISTINCT a) AVG(DISTINCT a) +78 6.5000 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 1 +Handler_read_key 48 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT SUM(DISTINCT a), AVG(DISTINCT a), COUNT(DISTINCT a) FROM t WHERE (b = 2 OR b = 15) AND (c = 3 OR c = 40); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 15 NULL 52 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select sum(distinct `test`.`t`.`a`) AS `SUM(DISTINCT a)`,avg(distinct `test`.`t`.`a`) AS `AVG(DISTINCT a)`,count(distinct `test`.`t`.`a`) AS `COUNT(DISTINCT a)` from `test`.`t` where (((`test`.`t`.`b` = 2) or (`test`.`t`.`b` = 15)) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40))) +FLUSH STATUS; +SELECT SUM(DISTINCT a), AVG(DISTINCT a), COUNT(DISTINCT a) FROM t WHERE (b = 2 OR b = 15) AND (c = 3 OR c = 40); +SUM(DISTINCT a) AVG(DISTINCT a) COUNT(DISTINCT a) +78 6.5000 12 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 1 +Handler_read_key 48 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT a, MAX(d), MIN(d) FROM t WHERE (a > 11) AND (b = 2 OR b = 15) AND +(c = 3 OR c = 1 OR c = 2 OR c = 4) +GROUP BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 6.53 Parallel execute (1 workers) +2 SIMPLE t NULL range k1 k1 5 NULL 4 6.53 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,max(`test`.`t`.`d`) AS `MAX(d)`,min(`test`.`t`.`d`) AS `MIN(d)` from `test`.`t` where ((`test`.`t`.`a` > 11) and ((`test`.`t`.`b` = 2) or (`test`.`t`.`b` = 15)) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 1) or (`test`.`t`.`c` = 2) or (`test`.`t`.`c` = 4))) group by `test`.`t`.`a` +FLUSH STATUS; +SELECT a, MAX(d), MIN(d) FROM t WHERE (a > 11) AND (b = 2 OR b = 15) AND +(c = 3 OR c = 1 OR c = 2 OR c = 4) +GROUP BY a; +a MAX(d) MIN(d) +12 -15 -15 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 2 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 5 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT a, b, MAX(d), MIN(d) FROM t WHERE (c = 3 OR c = 40) AND (d > 7 OR d =2) GROUP BY a, b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 20 NULL 114 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,max(`test`.`t`.`d`) AS `MAX(d)`,min(`test`.`t`.`d`) AS `MIN(d)` from `test`.`t` where (((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40)) and ((`test`.`t`.`d` > 7) or (`test`.`t`.`d` = 2))) group by `test`.`t`.`a`,`test`.`t`.`b` +FLUSH STATUS; +SELECT a, b, MAX(d), MIN(d) FROM t WHERE (c = 3 OR c = 40) AND (d > 7 OR d =2) GROUP BY a, b; +a b MAX(d) MIN(d) +1 1 10 2 +1 2 10 2 +1 3 10 2 +1 4 10 2 +1 5 10 2 +10 1 10 2 +10 2 10 2 +10 3 10 2 +10 4 10 2 +10 5 10 2 +11 3 20 20 +11 NULL 30 30 +2 1 10 2 +2 2 10 2 +2 3 10 2 +2 4 10 2 +2 5 10 2 +3 1 10 2 +3 2 10 2 +3 3 10 2 +3 4 10 2 +3 5 10 2 +4 1 10 2 +4 2 10 2 +4 3 10 2 +4 4 10 2 +4 5 10 2 +5 1 10 2 +5 2 10 2 +5 3 10 2 +5 4 10 2 +5 5 10 2 +6 1 10 2 +6 2 10 2 +6 3 10 2 +6 4 10 2 +6 5 10 2 +7 1 10 2 +7 2 10 2 +7 3 10 2 +7 4 10 2 +7 5 10 2 +8 1 10 2 +8 2 10 2 +8 3 10 2 +8 4 10 2 +8 5 10 2 +9 1 10 2 +9 2 10 2 +9 3 10 2 +9 4 10 2 +9 5 10 2 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 1 +Handler_read_key 228 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT a, b, MAX(d), MIN(d) FROM t WHERE (c = 3 OR c = 40) AND (d > 7 OR d =2 OR d IS NULL) +GROUP BY a, b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 20 NULL 114 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,max(`test`.`t`.`d`) AS `MAX(d)`,min(`test`.`t`.`d`) AS `MIN(d)` from `test`.`t` where (((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40)) and ((`test`.`t`.`d` > 7) or (`test`.`t`.`d` = 2) or (`test`.`t`.`d` is null))) group by `test`.`t`.`a`,`test`.`t`.`b` +FLUSH STATUS; +SELECT a, b, MAX(d), MIN(d) FROM t WHERE (c = 3 OR c = 40) AND (d > 7 OR d =2 OR d IS NULL) +GROUP BY a, b; +a b MAX(d) MIN(d) +1 1 10 2 +1 2 10 2 +1 3 10 2 +1 4 10 2 +1 5 10 2 +10 1 10 2 +10 2 10 2 +10 3 10 2 +10 4 10 2 +10 5 10 2 +11 3 20 20 +11 NULL 30 30 +12 2 NULL NULL +2 1 10 2 +2 2 10 2 +2 3 10 2 +2 4 10 2 +2 5 10 2 +3 1 10 2 +3 2 10 2 +3 3 10 2 +3 4 10 2 +3 5 10 2 +4 1 10 2 +4 2 10 2 +4 3 10 2 +4 4 10 2 +4 5 10 2 +5 1 10 2 +5 2 10 2 +5 3 10 2 +5 4 10 2 +5 5 10 2 +6 1 10 2 +6 2 10 2 +6 3 10 2 +6 4 10 2 +6 5 10 2 +7 1 10 2 +7 2 10 2 +7 3 10 2 +7 4 10 2 +7 5 10 2 +8 1 10 2 +8 2 10 2 +8 3 10 2 +8 4 10 2 +8 5 10 2 +9 1 10 2 +9 2 10 2 +9 3 10 2 +9 4 10 2 +9 5 10 2 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 1 +Handler_read_key 287 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT a, b, MIN(d) FROM t WHERE (a > 5) AND (c = 3 OR c = 40) AND +(d < -24 OR d = 3 OR d IS NULL) +GROUP BY a, b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 20 NULL 58 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,min(`test`.`t`.`d`) AS `MIN(d)` from `test`.`t` where ((`test`.`t`.`a` > 5) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40)) and ((`test`.`t`.`d` < (-(24))) or (`test`.`t`.`d` = 3) or (`test`.`t`.`d` is null))) group by `test`.`t`.`a`,`test`.`t`.`b` +FLUSH STATUS; +SELECT a, b, MIN(d) FROM t WHERE (a > 5) AND (c = 3 OR c = 40) AND +(d < -24 OR d = 3 OR d IS NULL) +GROUP BY a, b; +a b MIN(d) +10 1 3 +10 2 3 +10 3 3 +10 4 3 +10 5 3 +12 2 NULL +6 1 3 +6 2 3 +6 3 3 +6 4 3 +6 5 3 +7 1 3 +7 2 3 +7 3 3 +7 4 3 +7 5 3 +8 1 3 +8 2 3 +8 3 3 +8 4 3 +8 5 3 +9 1 3 +9 2 3 +9 3 3 +9 4 3 +9 5 3 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 156 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT a, b, MAX(d), MIN(d) FROM t WHERE (a > 5) AND (c = 3 OR c = 40) AND (d < 1 OR d = 9) +GROUP BY a, b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 20 NULL 58 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,max(`test`.`t`.`d`) AS `MAX(d)`,min(`test`.`t`.`d`) AS `MIN(d)` from `test`.`t` where ((`test`.`t`.`a` > 5) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40)) and ((`test`.`t`.`d` < 1) or (`test`.`t`.`d` = 9))) group by `test`.`t`.`a`,`test`.`t`.`b` +FLUSH STATUS; +SELECT a, b, MAX(d), MIN(d) FROM t WHERE (a > 5) AND (c = 3 OR c = 40) AND (d < 1 OR d = 9) +GROUP BY a, b; +a b MAX(d) MIN(d) +10 1 9 9 +10 2 9 9 +10 3 9 9 +10 4 9 9 +10 5 9 9 +11 2 -10 -10 +12 15 -15 -20 +12 2 -23 -23 +6 1 9 9 +6 2 9 9 +6 3 9 9 +6 4 9 9 +6 5 9 9 +7 1 9 9 +7 2 9 9 +7 3 9 9 +7 4 9 9 +7 5 9 9 +8 1 9 9 +8 2 9 9 +8 3 9 9 +8 4 9 9 +8 5 9 9 +9 1 9 9 +9 2 9 9 +9 3 9 9 +9 4 9 9 +9 5 9 9 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 186 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT a, b, MAX(d), MIN(d) FROM t WHERE (a > 9) AND (c = 3 OR c = 40) AND +(d = 1 OR d = 9 OR d IS NULL) +GROUP BY a, b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 20 NULL 12 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,max(`test`.`t`.`d`) AS `MAX(d)`,min(`test`.`t`.`d`) AS `MIN(d)` from `test`.`t` where ((`test`.`t`.`a` > 9) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40)) and ((`test`.`t`.`d` = 1) or (`test`.`t`.`d` = 9) or (`test`.`t`.`d` is null))) group by `test`.`t`.`a`,`test`.`t`.`b` +FLUSH STATUS; +SELECT a, b, MAX(d), MIN(d) FROM t WHERE (a > 9) AND (c = 3 OR c = 40) AND +(d = 1 OR d = 9 OR d IS NULL) +GROUP BY a, b; +a b MAX(d) MIN(d) +10 1 9 1 +10 2 9 1 +10 3 9 1 +10 4 9 1 +10 5 9 1 +12 2 NULL NULL + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 80 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT a, b, MIN(d), MAX(d) FROM t WHERE (a > 9) AND (c = 3 OR c = 40) AND +(d = 0 OR d = 9 OR d IS NULL) +GROUP BY a, b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 20 NULL 12 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,min(`test`.`t`.`d`) AS `MIN(d)`,max(`test`.`t`.`d`) AS `MAX(d)` from `test`.`t` where ((`test`.`t`.`a` > 9) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40)) and ((`test`.`t`.`d` = 0) or (`test`.`t`.`d` = 9) or (`test`.`t`.`d` is null))) group by `test`.`t`.`a`,`test`.`t`.`b` +FLUSH STATUS; +SELECT a, b, MIN(d), MAX(d) FROM t WHERE (a > 9) AND (c = 3 OR c = 40) AND +(d = 0 OR d = 9 OR d IS NULL) +GROUP BY a, b; +a b MIN(d) MAX(d) +10 1 9 9 +10 2 9 9 +10 3 9 9 +10 4 9 9 +10 5 9 9 +12 2 NULL NULL + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 85 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT a, b, MIN(d), MAX(d) FROM t WHERE (a > 9) AND (c = 3 OR c = 40) AND +(d > 0 AND d < 2 OR d > 3 AND d < 5 OR d IS NULL) +GROUP BY a, b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 20 NULL 12 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,min(`test`.`t`.`d`) AS `MIN(d)`,max(`test`.`t`.`d`) AS `MAX(d)` from `test`.`t` where ((`test`.`t`.`a` > 9) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40)) and (((`test`.`t`.`d` > 0) and (`test`.`t`.`d` < 2)) or ((`test`.`t`.`d` > 3) and (`test`.`t`.`d` < 5)) or (`test`.`t`.`d` is null))) group by `test`.`t`.`a`,`test`.`t`.`b` +FLUSH STATUS; +SELECT a, b, MIN(d), MAX(d) FROM t WHERE (a > 9) AND (c = 3 OR c = 40) AND +(d > 0 AND d < 2 OR d > 3 AND d < 5 OR d IS NULL) +GROUP BY a, b; +a b MIN(d) MAX(d) +10 1 1 4 +10 2 1 4 +10 3 1 4 +10 4 1 4 +10 5 1 4 +12 2 NULL NULL + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 80 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT a, b, MIN(d) FROM t WHERE (a > 9) AND (c = 3 OR c = 40) AND +(d < 2 OR d > 5 OR d IS NULL) +GROUP BY a, b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 20 NULL 12 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,min(`test`.`t`.`d`) AS `MIN(d)` from `test`.`t` where ((`test`.`t`.`a` > 9) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40)) and ((`test`.`t`.`d` < 2) or (`test`.`t`.`d` > 5) or (`test`.`t`.`d` is null))) group by `test`.`t`.`a`,`test`.`t`.`b` +FLUSH STATUS; +SELECT a, b, MIN(d) FROM t WHERE (a > 9) AND (c = 3 OR c = 40) AND +(d < 2 OR d > 5 OR d IS NULL) +GROUP BY a, b; +a b MIN(d) +10 1 1 +10 2 1 +10 3 1 +10 4 1 +10 5 1 +11 2 -10 +11 3 20 +11 NULL 30 +12 15 -20 +12 2 -23 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 47 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT a, b , max(d) FROM t WHERE (a >= 10) AND (c = 3 or c=40) AND +(d is NULL or d = -10 or d = -23) +GROUP BY a, b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 20 NULL 12 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,max(`test`.`t`.`d`) AS `max(d)` from `test`.`t` where ((`test`.`t`.`a` >= 10) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40)) and ((`test`.`t`.`d` is null) or (`test`.`t`.`d` = (-(10))) or (`test`.`t`.`d` = (-(23))))) group by `test`.`t`.`a`,`test`.`t`.`b` +FLUSH STATUS; +SELECT a, b , max(d) FROM t WHERE (a >= 10) AND (c = 3 or c=40) AND +(d is NULL or d = -10 or d = -23) +GROUP BY a, b; +a b max(d) +11 2 -10 +12 2 -23 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 76 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT a, b , min(d) FROM t WHERE (a >= 10) AND (c = 3 or c=40) AND +(d is NULL or d = -10 or d = -23) +GROUP BY a, b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 20 NULL 12 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,min(`test`.`t`.`d`) AS `min(d)` from `test`.`t` where ((`test`.`t`.`a` >= 10) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40)) and ((`test`.`t`.`d` is null) or (`test`.`t`.`d` = (-(10))) or (`test`.`t`.`d` = (-(23))))) group by `test`.`t`.`a`,`test`.`t`.`b` +FLUSH STATUS; +SELECT a, b , min(d) FROM t WHERE (a >= 10) AND (c = 3 or c=40) AND +(d is NULL or d = -10 or d = -23) +GROUP BY a, b; +a b min(d) +11 2 -10 +12 2 -23 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 76 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT a, MIN(b), MAX(b) FROM t WHERE a > 9 GROUP BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 10 NULL 1 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,min(`test`.`t`.`b`) AS `MIN(b)`,max(`test`.`t`.`b`) AS `MAX(b)` from `test`.`t` where (`test`.`t`.`a` > 9) group by `test`.`t`.`a` +FLUSH STATUS; +SELECT a, MIN(b), MAX(b) FROM t WHERE a > 9 GROUP BY a; +a MIN(b) MAX(b) +10 1 5 +11 2 15 +12 2 15 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 9 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +DROP TABLE t; +CREATE TABLE t (a INT, b INT, c INT, d INT, KEY k1(a, b, c, d)) ENGINE=myisam; +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +EXPLAIN SELECT a, MAX(d), MIN(d) FROM t WHERE (b = 2 OR b = 15 OR b = 3) AND (c = 3 OR c = 40) GROUP BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 20 NULL 78 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,max(`test`.`t`.`d`) AS `MAX(d)`,min(`test`.`t`.`d`) AS `MIN(d)` from `test`.`t` where (((`test`.`t`.`b` = 2) or (`test`.`t`.`b` = 15) or (`test`.`t`.`b` = 3)) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40))) group by `test`.`t`.`a` +FLUSH STATUS; +SELECT a, MAX(d), MIN(d) FROM t WHERE (b = 2 OR b = 15 OR b = 3) AND (c = 3 OR c = 40) GROUP BY a; +a MAX(d) MIN(d) +1 10 1 +10 10 1 +11 20 -10 +12 -15 -23 +2 10 1 +3 10 1 +4 10 1 +5 10 1 +6 10 1 +7 10 1 +8 10 1 +9 10 1 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 1 +Handler_read_key 111 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT a, MAX(d), MIN(d) FROM t WHERE (b = 2 OR b = 15) AND (c = 3 OR c = 40) GROUP BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 20 NULL 52 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,max(`test`.`t`.`d`) AS `MAX(d)`,min(`test`.`t`.`d`) AS `MIN(d)` from `test`.`t` where (((`test`.`t`.`b` = 2) or (`test`.`t`.`b` = 15)) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40))) group by `test`.`t`.`a` +FLUSH STATUS; +SELECT a, MAX(d), MIN(d) FROM t WHERE (b = 2 OR b = 15) AND (c = 3 OR c = 40) GROUP BY a; +a MAX(d) MIN(d) +1 10 1 +10 10 1 +11 -10 -10 +12 -15 -23 +2 10 1 +3 10 1 +4 10 1 +5 10 1 +6 10 1 +7 10 1 +8 10 1 +9 10 1 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 1 +Handler_read_key 76 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT a, MAX(d), MIN(d) FROM t WHERE (b = 2 OR b = 15) AND (c = 3 OR c IS NULL) GROUP BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 20 NULL 52 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,max(`test`.`t`.`d`) AS `MAX(d)`,min(`test`.`t`.`d`) AS `MIN(d)` from `test`.`t` where (((`test`.`t`.`b` = 2) or (`test`.`t`.`b` = 15)) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` is null))) group by `test`.`t`.`a` +FLUSH STATUS; +SELECT a, MAX(d), MIN(d) FROM t WHERE (b = 2 OR b = 15) AND (c = 3 OR c IS NULL) GROUP BY a; +a MAX(d) MIN(d) +1 10 1 +10 10 1 +11 -10 -20 +12 -15 -15 +2 10 1 +3 10 1 +4 10 1 +5 10 1 +6 10 1 +7 10 1 +8 10 1 +9 10 1 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 1 +Handler_read_key 75 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT a, MAX(d), MIN(d) FROM t WHERE (b IS NULL OR b = 15) AND (c = 3 OR c = 40) GROUP BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 20 NULL 52 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,max(`test`.`t`.`d`) AS `MAX(d)`,min(`test`.`t`.`d`) AS `MIN(d)` from `test`.`t` where (((`test`.`t`.`b` is null) or (`test`.`t`.`b` = 15)) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40))) group by `test`.`t`.`a` +FLUSH STATUS; +SELECT a, MAX(d), MIN(d) FROM t WHERE (b IS NULL OR b = 15) AND (c = 3 OR c = 40) GROUP BY a; +a MAX(d) MIN(d) +11 30 30 +12 -15 -20 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 1 +Handler_read_key 63 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT a, MAX(d), MIN(d) FROM t WHERE (b IS NULL OR b = 2) AND (c = 3 OR c = 40) GROUP BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 20 NULL 52 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,max(`test`.`t`.`d`) AS `MAX(d)`,min(`test`.`t`.`d`) AS `MIN(d)` from `test`.`t` where (((`test`.`t`.`b` is null) or (`test`.`t`.`b` = 2)) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40))) group by `test`.`t`.`a` +FLUSH STATUS; +SELECT a, MAX(d), MIN(d) FROM t WHERE (b IS NULL OR b = 2) AND (c = 3 OR c = 40) GROUP BY a; +a MAX(d) MIN(d) +1 10 1 +10 10 1 +11 30 -10 +12 -23 -23 +2 10 1 +3 10 1 +4 10 1 +5 10 1 +6 10 1 +7 10 1 +8 10 1 +9 10 1 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 1 +Handler_read_key 75 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT a FROM t WHERE (b = 2 OR b = 15 OR b = 3) AND (c = 3 OR c = 40) GROUP BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 15 NULL 78 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a` from `test`.`t` where (((`test`.`t`.`b` = 2) or (`test`.`t`.`b` = 15) or (`test`.`t`.`b` = 3)) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40))) group by `test`.`t`.`a` +FLUSH STATUS; +SELECT a FROM t WHERE (b = 2 OR b = 15 OR b = 3) AND (c = 3 OR c = 40) GROUP BY a; +a +1 +10 +11 +12 +2 +3 +4 +5 +6 +7 +8 +9 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 1 +Handler_read_key 24 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT a, b, MAX(d), MIN(d) FROM t WHERE (b = 2 OR b = 15) AND (c = 3 OR c = 40) GROUP BY a, b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 20 NULL 112 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,max(`test`.`t`.`d`) AS `MAX(d)`,min(`test`.`t`.`d`) AS `MIN(d)` from `test`.`t` where (((`test`.`t`.`b` = 2) or (`test`.`t`.`b` = 15)) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40))) group by `test`.`t`.`a`,`test`.`t`.`b` +FLUSH STATUS; +SELECT a, b, MAX(d), MIN(d) FROM t WHERE (b = 2 OR b = 15) AND (c = 3 OR c = 40) GROUP BY a, b; +a b MAX(d) MIN(d) +1 2 10 1 +10 2 10 1 +11 2 -10 -10 +12 15 -15 -20 +12 2 -23 -23 +2 2 10 1 +3 2 10 1 +4 2 10 1 +5 2 10 1 +6 2 10 1 +7 2 10 1 +8 2 10 1 +9 2 10 1 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 1 +Handler_read_key 226 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT a, b, MAX(d), MIN(d) FROM t WHERE (b = 2 OR b = 15 OR b = 3) AND (c = 3 OR c = 40) +GROUP BY a, b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 20 NULL 112 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,max(`test`.`t`.`d`) AS `MAX(d)`,min(`test`.`t`.`d`) AS `MIN(d)` from `test`.`t` where (((`test`.`t`.`b` = 2) or (`test`.`t`.`b` = 15) or (`test`.`t`.`b` = 3)) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40))) group by `test`.`t`.`a`,`test`.`t`.`b` +FLUSH STATUS; +SELECT a, b, MAX(d), MIN(d) FROM t WHERE (b = 2 OR b = 15 OR b = 3) AND (c = 3 OR c = 40) +GROUP BY a, b; +a b MAX(d) MIN(d) +1 2 10 1 +1 3 10 1 +10 2 10 1 +10 3 10 1 +11 2 -10 -10 +11 3 20 20 +12 15 -15 -20 +12 2 -23 -23 +2 2 10 1 +2 3 10 1 +3 2 10 1 +3 3 10 1 +4 2 10 1 +4 3 10 1 +5 2 10 1 +5 3 10 1 +6 2 10 1 +6 3 10 1 +7 2 10 1 +7 3 10 1 +8 2 10 1 +8 3 10 1 +9 2 10 1 +9 3 10 1 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 1 +Handler_read_key 226 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT DISTINCT a FROM t WHERE a = 1 AND (b = 2 OR b = 15); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 10 NULL 2 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select distinct `test`.`t`.`a` AS `a` from `test`.`t` where ((`test`.`t`.`a` = 1) and ((`test`.`t`.`b` = 2) or (`test`.`t`.`b` = 15))) +FLUSH STATUS; +SELECT DISTINCT a FROM t WHERE a = 1 AND (b = 2 OR b = 15); +a +1 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 3 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT a, MAX(d), MIN(d) FROM t WHERE a = 1 AND (c = 3 OR c = 40) AND (d = 1 OR d = 9) +GROUP BY a, b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 20 NULL 12 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,max(`test`.`t`.`d`) AS `MAX(d)`,min(`test`.`t`.`d`) AS `MIN(d)` from `test`.`t` where ((`test`.`t`.`a` = 1) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40)) and ((`test`.`t`.`d` = 1) or (`test`.`t`.`d` = 9))) group by `test`.`t`.`a`,`test`.`t`.`b` +FLUSH STATUS; +SELECT a, MAX(d), MIN(d) FROM t WHERE a = 1 AND (c = 3 OR c = 40) AND (d = 1 OR d = 9) +GROUP BY a, b; +a MAX(d) MIN(d) +1 9 1 +1 9 1 +1 9 1 +1 9 1 +1 9 1 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 26 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT a, b, MAX(d), MIN(d) FROM t WHERE (a = 1 OR a = 12) AND (b = 2 OR b = 15) AND (c = 3 OR c = 40) +GROUP BY a, b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 20 NULL 2 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,max(`test`.`t`.`d`) AS `MAX(d)`,min(`test`.`t`.`d`) AS `MIN(d)` from `test`.`t` where (((`test`.`t`.`a` = 1) or (`test`.`t`.`a` = 12)) and ((`test`.`t`.`b` = 2) or (`test`.`t`.`b` = 15)) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40))) group by `test`.`t`.`a`,`test`.`t`.`b` +FLUSH STATUS; +SELECT a, b, MAX(d), MIN(d) FROM t WHERE (a = 1 OR a = 12) AND (b = 2 OR b = 15) AND (c = 3 OR c = 40) +GROUP BY a, b; +a b MAX(d) MIN(d) +1 2 10 1 +12 15 -15 -20 +12 2 -23 -23 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 19 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT a, b, MAX(d), MIN(d) FROM t WHERE (a < 2 OR a > 11) AND (b = 2 OR b = 15) AND (c = 3 OR c = 40) +GROUP BY a, b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 20 NULL 12 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,max(`test`.`t`.`d`) AS `MAX(d)`,min(`test`.`t`.`d`) AS `MIN(d)` from `test`.`t` where (((`test`.`t`.`a` < 2) or (`test`.`t`.`a` > 11)) and ((`test`.`t`.`b` = 2) or (`test`.`t`.`b` = 15)) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40))) group by `test`.`t`.`a`,`test`.`t`.`b` +FLUSH STATUS; +SELECT a, b, MAX(d), MIN(d) FROM t WHERE (a < 2 OR a > 11) AND (b = 2 OR b = 15) AND (c = 3 OR c = 40) +GROUP BY a, b; +a b MAX(d) MIN(d) +1 2 10 1 +12 15 -15 -20 +12 2 -23 -23 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 33 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT DISTINCT a, b FROM t WHERE (a = 1 OR a = 12) AND (b = 2 OR b = 15) AND (c = 3 OR c = 40); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 15 NULL 2 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select distinct `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b` from `test`.`t` where (((`test`.`t`.`a` = 1) or (`test`.`t`.`a` = 12)) and ((`test`.`t`.`b` = 2) or (`test`.`t`.`b` = 15)) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40))) +FLUSH STATUS; +SELECT DISTINCT a, b FROM t WHERE (a = 1 OR a = 12) AND (b = 2 OR b = 15) AND (c = 3 OR c = 40); +a b +1 2 +12 15 +12 2 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 10 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT DISTINCT a FROM t WHERE (a = 1 OR a = 12) AND (b = 2 OR b = 15); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 10 NULL 2 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select distinct `test`.`t`.`a` AS `a` from `test`.`t` where (((`test`.`t`.`a` = 1) or (`test`.`t`.`a` = 12)) and ((`test`.`t`.`b` = 2) or (`test`.`t`.`b` = 15))) +FLUSH STATUS; +SELECT DISTINCT a FROM t WHERE (a = 1 OR a = 12) AND (b = 2 OR b = 15); +a +1 +12 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 6 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT a, b, MAX(d), MIN(d) FROM t WHERE (a = 1 OR a = 12) AND (b < 4 OR b > 10) AND (c = 3 OR c = 40) +GROUP BY a, b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 20 NULL 8 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,max(`test`.`t`.`d`) AS `MAX(d)`,min(`test`.`t`.`d`) AS `MIN(d)` from `test`.`t` where (((`test`.`t`.`a` = 1) or (`test`.`t`.`a` = 12)) and ((`test`.`t`.`b` < 4) or (`test`.`t`.`b` > 10)) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40))) group by `test`.`t`.`a`,`test`.`t`.`b` +FLUSH STATUS; +SELECT a, b, MAX(d), MIN(d) FROM t WHERE (a = 1 OR a = 12) AND (b < 4 OR b > 10) AND (c = 3 OR c = 40) +GROUP BY a, b; +a b MAX(d) MIN(d) +1 1 10 1 +1 2 10 1 +1 3 10 1 +12 15 -15 -20 +12 2 -23 -23 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 27 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT a, MAX(d), MIN(d) FROM t WHERE (a = 1 OR a > 9) AND (b = 2 OR b = 15) AND (c = 3 OR c = 40) +GROUP BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 20 NULL 8 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,max(`test`.`t`.`d`) AS `MAX(d)`,min(`test`.`t`.`d`) AS `MIN(d)` from `test`.`t` where (((`test`.`t`.`a` = 1) or (`test`.`t`.`a` > 9)) and ((`test`.`t`.`b` = 2) or (`test`.`t`.`b` = 15)) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40))) group by `test`.`t`.`a` +FLUSH STATUS; +SELECT a, MAX(d), MIN(d) FROM t WHERE (a = 1 OR a > 9) AND (b = 2 OR b = 15) AND (c = 3 OR c = 40) +GROUP BY a; +a MAX(d) MIN(d) +1 10 1 +10 10 1 +11 -10 -10 +12 -15 -23 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 30 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT COUNT(DISTINCT a, b) FROM t WHERE (a = 1 OR a = 12) AND (b = 2 OR b = 15) AND (c = 3 OR c = 40); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 15 NULL 2 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select count(distinct `test`.`t`.`a`,`test`.`t`.`b`) AS `COUNT(DISTINCT a, b)` from `test`.`t` where (((`test`.`t`.`a` = 1) or (`test`.`t`.`a` = 12)) and ((`test`.`t`.`b` = 2) or (`test`.`t`.`b` = 15)) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40))) +FLUSH STATUS; +SELECT COUNT(DISTINCT a, b) FROM t WHERE (a = 1 OR a = 12) AND (b = 2 OR b = 15) AND (c = 3 OR c = 40); +COUNT(DISTINCT a, b) +3 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 10 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT SUM(DISTINCT a), AVG(DISTINCT a) FROM t WHERE (b = 2 OR b = 15) AND (c = 3 OR c = 40); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 15 NULL 52 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select sum(distinct `test`.`t`.`a`) AS `SUM(DISTINCT a)`,avg(distinct `test`.`t`.`a`) AS `AVG(DISTINCT a)` from `test`.`t` where (((`test`.`t`.`b` = 2) or (`test`.`t`.`b` = 15)) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40))) +FLUSH STATUS; +SELECT SUM(DISTINCT a), AVG(DISTINCT a) FROM t WHERE (b = 2 OR b = 15) AND (c = 3 OR c = 40); +SUM(DISTINCT a) AVG(DISTINCT a) +78 6.5000 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 1 +Handler_read_key 24 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT SUM(DISTINCT a), AVG(DISTINCT a), COUNT(DISTINCT a) FROM t WHERE (b = 2 OR b = 15) AND (c = 3 OR c = 40); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 15 NULL 52 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select sum(distinct `test`.`t`.`a`) AS `SUM(DISTINCT a)`,avg(distinct `test`.`t`.`a`) AS `AVG(DISTINCT a)`,count(distinct `test`.`t`.`a`) AS `COUNT(DISTINCT a)` from `test`.`t` where (((`test`.`t`.`b` = 2) or (`test`.`t`.`b` = 15)) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40))) +FLUSH STATUS; +SELECT SUM(DISTINCT a), AVG(DISTINCT a), COUNT(DISTINCT a) FROM t WHERE (b = 2 OR b = 15) AND (c = 3 OR c = 40); +SUM(DISTINCT a) AVG(DISTINCT a) COUNT(DISTINCT a) +78 6.5000 12 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 1 +Handler_read_key 24 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT a, MAX(d), MIN(d) FROM t WHERE (a > 11) AND (b = 2 OR b = 15) AND +(c = 3 OR c = 1 OR c = 2 OR c = 4) +GROUP BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 5 NULL 13 6.53 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,max(`test`.`t`.`d`) AS `MAX(d)`,min(`test`.`t`.`d`) AS `MIN(d)` from `test`.`t` where ((`test`.`t`.`a` > 11) and ((`test`.`t`.`b` = 2) or (`test`.`t`.`b` = 15)) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 1) or (`test`.`t`.`c` = 2) or (`test`.`t`.`c` = 4))) group by `test`.`t`.`a` +FLUSH STATUS; +SELECT a, MAX(d), MIN(d) FROM t WHERE (a > 11) AND (b = 2 OR b = 15) AND +(c = 3 OR c = 1 OR c = 2 OR c = 4) +GROUP BY a; +a MAX(d) MIN(d) +12 -15 -15 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 1 +Handler_read_last 0 +Handler_read_next 4 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT a, b, MAX(d), MIN(d) FROM t WHERE (c = 3 OR c = 40) AND (d > 7 OR d =2) GROUP BY a, b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 20 NULL 112 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,max(`test`.`t`.`d`) AS `MAX(d)`,min(`test`.`t`.`d`) AS `MIN(d)` from `test`.`t` where (((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40)) and ((`test`.`t`.`d` > 7) or (`test`.`t`.`d` = 2))) group by `test`.`t`.`a`,`test`.`t`.`b` +FLUSH STATUS; +SELECT a, b, MAX(d), MIN(d) FROM t WHERE (c = 3 OR c = 40) AND (d > 7 OR d =2) GROUP BY a, b; +a b MAX(d) MIN(d) +1 1 10 2 +1 2 10 2 +1 3 10 2 +1 4 10 2 +1 5 10 2 +10 1 10 2 +10 2 10 2 +10 3 10 2 +10 4 10 2 +10 5 10 2 +11 3 20 20 +11 NULL 30 30 +2 1 10 2 +2 2 10 2 +2 3 10 2 +2 4 10 2 +2 5 10 2 +3 1 10 2 +3 2 10 2 +3 3 10 2 +3 4 10 2 +3 5 10 2 +4 1 10 2 +4 2 10 2 +4 3 10 2 +4 4 10 2 +4 5 10 2 +5 1 10 2 +5 2 10 2 +5 3 10 2 +5 4 10 2 +5 5 10 2 +6 1 10 2 +6 2 10 2 +6 3 10 2 +6 4 10 2 +6 5 10 2 +7 1 10 2 +7 2 10 2 +7 3 10 2 +7 4 10 2 +7 5 10 2 +8 1 10 2 +8 2 10 2 +8 3 10 2 +8 4 10 2 +8 5 10 2 +9 1 10 2 +9 2 10 2 +9 3 10 2 +9 4 10 2 +9 5 10 2 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 1 +Handler_read_key 281 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT a, b, MAX(d), MIN(d) FROM t WHERE (c = 3 OR c = 40) AND (d > 7 OR d =2 OR d IS NULL) +GROUP BY a, b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 20 NULL 112 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,max(`test`.`t`.`d`) AS `MAX(d)`,min(`test`.`t`.`d`) AS `MIN(d)` from `test`.`t` where (((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40)) and ((`test`.`t`.`d` > 7) or (`test`.`t`.`d` = 2) or (`test`.`t`.`d` is null))) group by `test`.`t`.`a`,`test`.`t`.`b` +FLUSH STATUS; +SELECT a, b, MAX(d), MIN(d) FROM t WHERE (c = 3 OR c = 40) AND (d > 7 OR d =2 OR d IS NULL) +GROUP BY a, b; +a b MAX(d) MIN(d) +1 1 10 2 +1 2 10 2 +1 3 10 2 +1 4 10 2 +1 5 10 2 +10 1 10 2 +10 2 10 2 +10 3 10 2 +10 4 10 2 +10 5 10 2 +11 3 20 20 +11 NULL 30 30 +12 2 NULL NULL +2 1 10 2 +2 2 10 2 +2 3 10 2 +2 4 10 2 +2 5 10 2 +3 1 10 2 +3 2 10 2 +3 3 10 2 +3 4 10 2 +3 5 10 2 +4 1 10 2 +4 2 10 2 +4 3 10 2 +4 4 10 2 +4 5 10 2 +5 1 10 2 +5 2 10 2 +5 3 10 2 +5 4 10 2 +5 5 10 2 +6 1 10 2 +6 2 10 2 +6 3 10 2 +6 4 10 2 +6 5 10 2 +7 1 10 2 +7 2 10 2 +7 3 10 2 +7 4 10 2 +7 5 10 2 +8 1 10 2 +8 2 10 2 +8 3 10 2 +8 4 10 2 +8 5 10 2 +9 1 10 2 +9 2 10 2 +9 3 10 2 +9 4 10 2 +9 5 10 2 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 1 +Handler_read_key 396 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT a, b, MIN(d) FROM t WHERE (a > 5) AND (c = 3 OR c = 40) AND +(d < -24 OR d = 3 OR d IS NULL) +GROUP BY a, b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 20 NULL 56 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,min(`test`.`t`.`d`) AS `MIN(d)` from `test`.`t` where ((`test`.`t`.`a` > 5) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40)) and ((`test`.`t`.`d` < (-(24))) or (`test`.`t`.`d` = 3) or (`test`.`t`.`d` is null))) group by `test`.`t`.`a`,`test`.`t`.`b` +FLUSH STATUS; +SELECT a, b, MIN(d) FROM t WHERE (a > 5) AND (c = 3 OR c = 40) AND +(d < -24 OR d = 3 OR d IS NULL) +GROUP BY a, b; +a b MIN(d) +10 1 3 +10 2 3 +10 3 3 +10 4 3 +10 5 3 +12 2 NULL +6 1 3 +6 2 3 +6 3 3 +6 4 3 +6 5 3 +7 1 3 +7 2 3 +7 3 3 +7 4 3 +7 5 3 +8 1 3 +8 2 3 +8 3 3 +8 4 3 +8 5 3 +9 1 3 +9 2 3 +9 3 3 +9 4 3 +9 5 3 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 154 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT a, b, MAX(d), MIN(d) FROM t WHERE (a > 5) AND (c = 3 OR c = 40) AND (d < 1 OR d = 9) +GROUP BY a, b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 20 NULL 56 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,max(`test`.`t`.`d`) AS `MAX(d)`,min(`test`.`t`.`d`) AS `MIN(d)` from `test`.`t` where ((`test`.`t`.`a` > 5) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40)) and ((`test`.`t`.`d` < 1) or (`test`.`t`.`d` = 9))) group by `test`.`t`.`a`,`test`.`t`.`b` +FLUSH STATUS; +SELECT a, b, MAX(d), MIN(d) FROM t WHERE (a > 5) AND (c = 3 OR c = 40) AND (d < 1 OR d = 9) +GROUP BY a, b; +a b MAX(d) MIN(d) +10 1 9 9 +10 2 9 9 +10 3 9 9 +10 4 9 9 +10 5 9 9 +11 2 -10 -10 +12 15 -15 -20 +12 2 -23 -23 +6 1 9 9 +6 2 9 9 +6 3 9 9 +6 4 9 9 +6 5 9 9 +7 1 9 9 +7 2 9 9 +7 3 9 9 +7 4 9 9 +7 5 9 9 +8 1 9 9 +8 2 9 9 +8 3 9 9 +8 4 9 9 +8 5 9 9 +9 1 9 9 +9 2 9 9 +9 3 9 9 +9 4 9 9 +9 5 9 9 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 185 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT a, b, MAX(d), MIN(d) FROM t WHERE (a > 9) AND (c = 3 OR c = 40) AND +(d = 1 OR d = 9 OR d IS NULL) +GROUP BY a, b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 20 NULL 12 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,max(`test`.`t`.`d`) AS `MAX(d)`,min(`test`.`t`.`d`) AS `MIN(d)` from `test`.`t` where ((`test`.`t`.`a` > 9) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40)) and ((`test`.`t`.`d` = 1) or (`test`.`t`.`d` = 9) or (`test`.`t`.`d` is null))) group by `test`.`t`.`a`,`test`.`t`.`b` +FLUSH STATUS; +SELECT a, b, MAX(d), MIN(d) FROM t WHERE (a > 9) AND (c = 3 OR c = 40) AND +(d = 1 OR d = 9 OR d IS NULL) +GROUP BY a, b; +a b MAX(d) MIN(d) +10 1 9 1 +10 2 9 1 +10 3 9 1 +10 4 9 1 +10 5 9 1 +12 2 NULL NULL + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 80 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT a, b, MIN(d), MAX(d) FROM t WHERE (a > 9) AND (c = 3 OR c = 40) AND +(d = 0 OR d = 9 OR d IS NULL) +GROUP BY a, b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 20 NULL 12 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,min(`test`.`t`.`d`) AS `MIN(d)`,max(`test`.`t`.`d`) AS `MAX(d)` from `test`.`t` where ((`test`.`t`.`a` > 9) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40)) and ((`test`.`t`.`d` = 0) or (`test`.`t`.`d` = 9) or (`test`.`t`.`d` is null))) group by `test`.`t`.`a`,`test`.`t`.`b` +FLUSH STATUS; +SELECT a, b, MIN(d), MAX(d) FROM t WHERE (a > 9) AND (c = 3 OR c = 40) AND +(d = 0 OR d = 9 OR d IS NULL) +GROUP BY a, b; +a b MIN(d) MAX(d) +10 1 9 9 +10 2 9 9 +10 3 9 9 +10 4 9 9 +10 5 9 9 +12 2 NULL NULL + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 85 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT a, b, MIN(d), MAX(d) FROM t WHERE (a > 9) AND (c = 3 OR c = 40) AND +(d > 0 AND d < 2 OR d > 3 AND d < 5 OR d IS NULL) +GROUP BY a, b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 20 NULL 12 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,min(`test`.`t`.`d`) AS `MIN(d)`,max(`test`.`t`.`d`) AS `MAX(d)` from `test`.`t` where ((`test`.`t`.`a` > 9) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40)) and (((`test`.`t`.`d` > 0) and (`test`.`t`.`d` < 2)) or ((`test`.`t`.`d` > 3) and (`test`.`t`.`d` < 5)) or (`test`.`t`.`d` is null))) group by `test`.`t`.`a`,`test`.`t`.`b` +FLUSH STATUS; +SELECT a, b, MIN(d), MAX(d) FROM t WHERE (a > 9) AND (c = 3 OR c = 40) AND +(d > 0 AND d < 2 OR d > 3 AND d < 5 OR d IS NULL) +GROUP BY a, b; +a b MIN(d) MAX(d) +10 1 1 4 +10 2 1 4 +10 3 1 4 +10 4 1 4 +10 5 1 4 +12 2 NULL NULL + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 79 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT a, b, MIN(d) FROM t WHERE (a > 9) AND (c = 3 OR c = 40) AND +(d < 2 OR d > 5 OR d IS NULL) +GROUP BY a, b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 20 NULL 12 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,min(`test`.`t`.`d`) AS `MIN(d)` from `test`.`t` where ((`test`.`t`.`a` > 9) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40)) and ((`test`.`t`.`d` < 2) or (`test`.`t`.`d` > 5) or (`test`.`t`.`d` is null))) group by `test`.`t`.`a`,`test`.`t`.`b` +FLUSH STATUS; +SELECT a, b, MIN(d) FROM t WHERE (a > 9) AND (c = 3 OR c = 40) AND +(d < 2 OR d > 5 OR d IS NULL) +GROUP BY a, b; +a b MIN(d) +10 1 1 +10 2 1 +10 3 1 +10 4 1 +10 5 1 +11 2 -10 +11 3 20 +11 NULL 30 +12 15 -20 +12 2 -23 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 46 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT a, b , max(d) FROM t WHERE (a >= 10) AND (c = 3 or c=40) AND +(d is NULL or d = -10 or d = -23) +GROUP BY a, b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 20 NULL 12 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,max(`test`.`t`.`d`) AS `max(d)` from `test`.`t` where ((`test`.`t`.`a` >= 10) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40)) and ((`test`.`t`.`d` is null) or (`test`.`t`.`d` = (-(10))) or (`test`.`t`.`d` = (-(23))))) group by `test`.`t`.`a`,`test`.`t`.`b` +FLUSH STATUS; +SELECT a, b , max(d) FROM t WHERE (a >= 10) AND (c = 3 or c=40) AND +(d is NULL or d = -10 or d = -23) +GROUP BY a, b; +a b max(d) +11 2 -10 +12 2 -23 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 74 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT a, b , min(d) FROM t WHERE (a >= 10) AND (c = 3 or c=40) AND +(d is NULL or d = -10 or d = -23) +GROUP BY a, b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 20 NULL 12 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,min(`test`.`t`.`d`) AS `min(d)` from `test`.`t` where ((`test`.`t`.`a` >= 10) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40)) and ((`test`.`t`.`d` is null) or (`test`.`t`.`d` = (-(10))) or (`test`.`t`.`d` = (-(23))))) group by `test`.`t`.`a`,`test`.`t`.`b` +FLUSH STATUS; +SELECT a, b , min(d) FROM t WHERE (a >= 10) AND (c = 3 or c=40) AND +(d is NULL or d = -10 or d = -23) +GROUP BY a, b; +a b min(d) +11 2 -10 +12 2 -23 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 76 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT a, MIN(b), MAX(b) FROM t WHERE a > 9 GROUP BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 10 NULL 1 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,min(`test`.`t`.`b`) AS `MIN(b)`,max(`test`.`t`.`b`) AS `MAX(b)` from `test`.`t` where (`test`.`t`.`a` > 9) group by `test`.`t`.`a` +FLUSH STATUS; +SELECT a, MIN(b), MAX(b) FROM t WHERE a > 9 GROUP BY a; +a MIN(b) MAX(b) +10 1 5 +11 2 15 +12 2 15 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 8 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +DROP TABLE t; diff --git a/mysql-test/r/group_min_max_innodb.result-pq b/mysql-test/r/group_min_max_innodb.result-pq new file mode 100644 index 000000000000..0ffbe6c7e3e5 --- /dev/null +++ b/mysql-test/r/group_min_max_innodb.result-pq @@ -0,0 +1,693 @@ +drop view if exists v1; +drop table if exists t1,t4; +create table t4 ( +pk_col int auto_increment primary key, a1 char(64), a2 char(64), b char(16), c char(16) not null, d char(16), dummy char(64) default ' ' +) engine=innodb; +insert into t4 (a1, a2, b, c, d) values +('a','a','a','a111','xy1'),('a','a','a','b111','xy2'),('a','a','a','c111','xy3'),('a','a','a','d111','xy4'), +('a','a','b','e112','xy1'),('a','a','b','f112','xy2'),('a','a','b','g112','xy3'),('a','a','b','h112','xy4'), +('a','b','a','i121','xy1'),('a','b','a','j121','xy2'),('a','b','a','k121','xy3'),('a','b','a','l121','xy4'), +('a','b','b','m122','xy1'),('a','b','b','n122','xy2'),('a','b','b','o122','xy3'),('a','b','b','p122','xy4'), +('b','a','a','a211','xy1'),('b','a','a','b211','xy2'),('b','a','a','c211','xy3'),('b','a','a','d211','xy4'), +('b','a','b','e212','xy1'),('b','a','b','f212','xy2'),('b','a','b','g212','xy3'),('b','a','b','h212','xy4'), +('b','b','a','i221','xy1'),('b','b','a','j221','xy2'),('b','b','a','k221','xy3'),('b','b','a','l221','xy4'), +('b','b','b','m222','xy1'),('b','b','b','n222','xy2'),('b','b','b','o222','xy3'),('b','b','b','p222','xy4'), +('c','a','a','a311','xy1'),('c','a','a','b311','xy2'),('c','a','a','c311','xy3'),('c','a','a','d311','xy4'), +('c','a','b','e312','xy1'),('c','a','b','f312','xy2'),('c','a','b','g312','xy3'),('c','a','b','h312','xy4'), +('c','b','a','i321','xy1'),('c','b','a','j321','xy2'),('c','b','a','k321','xy3'),('c','b','a','l321','xy4'), +('c','b','b','m322','xy1'),('c','b','b','n322','xy2'),('c','b','b','o322','xy3'),('c','b','b','p322','xy4'), +('d','a','a','a411','xy1'),('d','a','a','b411','xy2'),('d','a','a','c411','xy3'),('d','a','a','d411','xy4'), +('d','a','b','e412','xy1'),('d','a','b','f412','xy2'),('d','a','b','g412','xy3'),('d','a','b','h412','xy4'), +('d','b','a','i421','xy1'),('d','b','a','j421','xy2'),('d','b','a','k421','xy3'),('d','b','a','l421','xy4'), +('d','b','b','m422','xy1'),('d','b','b','n422','xy2'),('d','b','b','o422','xy3'),('d','b','b','p422','xy4'), +('a','a','a','a111','xy1'),('a','a','a','b111','xy2'),('a','a','a','c111','xy3'),('a','a','a','d111','xy4'), +('a','a','b','e112','xy1'),('a','a','b','f112','xy2'),('a','a','b','g112','xy3'),('a','a','b','h112','xy4'), +('a','b','a','i121','xy1'),('a','b','a','j121','xy2'),('a','b','a','k121','xy3'),('a','b','a','l121','xy4'), +('a','b','b','m122','xy1'),('a','b','b','n122','xy2'),('a','b','b','o122','xy3'),('a','b','b','p122','xy4'), +('b','a','a','a211','xy1'),('b','a','a','b211','xy2'),('b','a','a','c211','xy3'),('b','a','a','d211','xy4'), +('b','a','b','e212','xy1'),('b','a','b','f212','xy2'),('b','a','b','g212','xy3'),('b','a','b','h212','xy4'), +('b','b','a','i221','xy1'),('b','b','a','j221','xy2'),('b','b','a','k221','xy3'),('b','b','a','l221','xy4'), +('b','b','b','m222','xy1'),('b','b','b','n222','xy2'),('b','b','b','o222','xy3'),('b','b','b','p222','xy4'), +('c','a','a','a311','xy1'),('c','a','a','b311','xy2'),('c','a','a','c311','xy3'),('c','a','a','d311','xy4'), +('c','a','b','e312','xy1'),('c','a','b','f312','xy2'),('c','a','b','g312','xy3'),('c','a','b','h312','xy4'), +('c','b','a','i321','xy1'),('c','b','a','j321','xy2'),('c','b','a','k321','xy3'),('c','b','a','l321','xy4'), +('c','b','b','m322','xy1'),('c','b','b','n322','xy2'),('c','b','b','o322','xy3'),('c','b','b','p322','xy4'), +('d','a','a','a411','xy1'),('d','a','a','b411','xy2'),('d','a','a','c411','xy3'),('d','a','a','d411','xy4'), +('d','a','b','e412','xy1'),('d','a','b','f412','xy2'),('d','a','b','g412','xy3'),('d','a','b','h412','xy4'), +('d','b','a','i421','xy1'),('d','b','a','j421','xy2'),('d','b','a','k421','xy3'),('d','b','a','l421','xy4'), +('d','b','b','m422','xy1'),('d','b','b','n422','xy2'),('d','b','b','o422','xy3'),('d','b','b','p422','xy4'); +create index idx12672_0 on t4 (a1); +create index idx12672_1 on t4 (a1,a2,b,c); +create index idx12672_2 on t4 (a1,a2,b); +analyze table t4; +Table Op Msg_type Msg_text +test.t4 analyze status OK +select distinct a1 from t4 where pk_col not in (1,2,3,4); +a1 +a +b +c +d +drop table t4; +create table t1 ( +a varchar(30), b varchar(30), primary key(a), key(b) +) engine=innodb; +select distinct a from t1; +a +drop table t1; +create table t1(a int, key(a)) engine=innodb; +insert into t1 values(1); +select a, count(a) from t1 group by a with rollup; +a count(a) +1 1 +NULL 1 +drop table t1; +create table t1 (f1 int, f2 char(1), primary key(f1,f2)) charset utf8mb4 engine=innodb +stats_persistent=0; +insert into t1 values ( 1,"e"),(2,"a"),( 3,"c"),(4,"d"); +alter table t1 drop primary key, add primary key (f2, f1); +explain select distinct f1 a, f1 b from t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index PRIMARY PRIMARY 8 NULL 4 100.00 Using index; Using temporary +Warnings: +Note 1003 /* select#1 */ select distinct `test`.`t1`.`f1` AS `a`,`test`.`t1`.`f1` AS `b` from `test`.`t1` +explain select distinct f1, f2 from t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index PRIMARY PRIMARY 8 NULL 4 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select distinct `test`.`t1`.`f1` AS `f1`,`test`.`t1`.`f2` AS `f2` from `test`.`t1` +drop table t1; +create table t1(pk int primary key) engine=innodb; +create view v1 as select pk from t1 where pk < 20; +insert into t1 values (1), (2), (3), (4); +select distinct pk from v1; +pk +1 +2 +3 +4 +insert into t1 values (5), (6), (7); +select distinct pk from v1; +pk +1 +2 +3 +4 +5 +6 +7 +drop view v1; +drop table t1; +End of 5.1 tests +# +# Bug#12540545 61101: ASSERTION FAILURE IN THREAD 1256741184 IN +# FILE /BUILDDIR/BUILD/BUILD/MYSQ +# +CREATE TABLE t1 (a CHAR(1), b CHAR(1), PRIMARY KEY (a,b)) +charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t1 VALUES ('a', 'b'), ('c', 'd'); +EXPLAIN SELECT COUNT(DISTINCT a) FROM t1 WHERE b = 'b'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index PRIMARY PRIMARY 8 NULL 2 50.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select count(distinct `test`.`t1`.`a`) AS `COUNT(DISTINCT a)` from `test`.`t1` where (`test`.`t1`.`b` = 'b') +SELECT COUNT(DISTINCT a) FROM t1 WHERE b = 'b'; +COUNT(DISTINCT a) +1 +DROP TABLE t1; +CREATE TABLE t1 (a CHAR(1) NOT NULL, b CHAR(1) NOT NULL, UNIQUE KEY (a,b)) +charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t1 VALUES ('a', 'b'), ('c', 'd'); +EXPLAIN SELECT COUNT(DISTINCT a) FROM t1 WHERE b = 'b'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index a a 8 NULL 2 50.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select count(distinct `test`.`t1`.`a`) AS `COUNT(DISTINCT a)` from `test`.`t1` where (`test`.`t1`.`b` = 'b') +SELECT COUNT(DISTINCT a) FROM t1 WHERE b = 'b'; +COUNT(DISTINCT a) +1 +DROP TABLE t1; +End of 5.5 tests +# +# Bug#17909656 - WRONG RESULTS FOR A SIMPLE QUERY WITH GROUP BY +# +CREATE TABLE t0 ( +i1 INTEGER NOT NULL +); +INSERT INTO t0 VALUES (1),(2),(3),(4),(5),(6),(7),(8),(9),(10), +(11),(12),(13),(14),(15),(16),(17),(18),(19),(20), +(21),(22),(23),(24),(25),(26),(27),(28),(29),(30); +CREATE TABLE t1 ( +c1 CHAR(1) NOT NULL, +i1 INTEGER NOT NULL, +i2 INTEGER NOT NULL, +UNIQUE KEY k1 (c1,i2) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t1 SELECT 'A',i1,i1 FROM t0; +INSERT INTO t1 SELECT 'B',i1,i1 FROM t0; +INSERT INTO t1 SELECT 'C',i1,i1 FROM t0; +INSERT INTO t1 SELECT 'D',i1,i1 FROM t0; +INSERT INTO t1 SELECT 'E',i1,i1 FROM t0; +INSERT INTO t1 SELECT 'F',i1,i1 FROM t0; +CREATE TABLE t2 ( +c1 CHAR(1) NOT NULL, +i1 INTEGER NOT NULL, +i2 INTEGER NOT NULL, +UNIQUE KEY k2 (c1,i1,i2) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t2 SELECT 'A',i1,i1 FROM t0; +INSERT INTO t2 SELECT 'B',i1,i1 FROM t0; +INSERT INTO t2 SELECT 'C',i1,i1 FROM t0; +INSERT INTO t2 SELECT 'D',i1,i1 FROM t0; +INSERT INTO t2 SELECT 'E',i1,i1 FROM t0; +INSERT INTO t2 SELECT 'F',i1,i1 FROM t0; +ANALYZE TABLE t1; +ANALYZE TABLE t2; +set optimizer_trace_max_mem_size=1048576; +set @@session.optimizer_trace='enabled=on'; +set end_markers_in_json=on; +EXPLAIN SELECT c1, max(i2) FROM t1 WHERE (c1 = 'C' AND i2 = 17) OR ( c1 = 'F') +GROUP BY c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL ROWS 100.00 Parallel execute (2 workers) +2 SIMPLE t1 NULL range k1 k1 8 NULL ROWS 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c1` AS `c1`,max(`test`.`t1`.`i2`) AS `max(i2)` from `test`.`t1` where (((`test`.`t1`.`i2` = 17) and (`test`.`t1`.`c1` = 'C')) or (`test`.`t1`.`c1` = 'F')) group by `test`.`t1`.`c1` +SELECT c1, max(i2) FROM t1 WHERE (c1 = 'C' AND i2 = 17) OR ( c1 = 'F') +GROUP BY c1; +c1 max(i2) +C 17 +F 30 +SELECT TRACE RLIKE 'minmax_keypart_in_disjunctive_query' +AS OK FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +OK +1 +EXPLAIN SELECT c1, max(i2) FROM t1 WHERE (c1 = 'C' OR ( c1 = 'F' AND i2 = 17)) +GROUP BY c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL ROWS 100.00 Parallel execute (2 workers) +2 SIMPLE t1 NULL range k1 k1 8 NULL ROWS 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c1` AS `c1`,max(`test`.`t1`.`i2`) AS `max(i2)` from `test`.`t1` where ((`test`.`t1`.`c1` = 'C') or ((`test`.`t1`.`i2` = 17) and (`test`.`t1`.`c1` = 'F'))) group by `test`.`t1`.`c1` +SELECT c1, max(i2) FROM t1 WHERE (c1 = 'C' OR ( c1 = 'F' AND i2 = 17)) +GROUP BY c1; +c1 max(i2) +C 30 +F 17 +SELECT TRACE RLIKE 'minmax_keypart_in_disjunctive_query' +AS OK FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +OK +1 +EXPLAIN SELECT c1, max(i2) FROM t1 WHERE (c1 = 'C' OR c1 = 'F' ) AND ( i2 = 17 ) +GROUP BY c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range k1 k1 8 NULL ROWS 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c1` AS `c1`,max(`test`.`t1`.`i2`) AS `max(i2)` from `test`.`t1` where ((`test`.`t1`.`i2` = 17) and ((`test`.`t1`.`c1` = 'C') or (`test`.`t1`.`c1` = 'F'))) group by `test`.`t1`.`c1` +SELECT c1, max(i2) FROM t1 WHERE (c1 = 'C' OR c1 = 'F' ) AND ( i2 = 17 ) +GROUP BY c1; +c1 max(i2) +C 17 +F 17 +SELECT TRACE RLIKE 'minmax_keypart_in_disjunctive_query' +AS OK FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +OK +0 +EXPLAIN SELECT c1, max(i2) FROM t1 +WHERE ((c1 = 'C' AND (i2 = 40 OR i2 = 30)) OR ( c1 = 'F' AND (i2 = 40 ))) +GROUP BY c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL ROWS 100.00 Parallel execute (2 workers) +2 SIMPLE t1 NULL range k1 k1 8 NULL ROWS 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c1` AS `c1`,max(`test`.`t1`.`i2`) AS `max(i2)` from `test`.`t1` where (((`test`.`t1`.`c1` = 'C') and ((`test`.`t1`.`i2` = 40) or (`test`.`t1`.`i2` = 30))) or ((`test`.`t1`.`i2` = 40) and (`test`.`t1`.`c1` = 'F'))) group by `test`.`t1`.`c1` +SELECT c1, max(i2) FROM t1 +WHERE ((c1 = 'C' AND (i2 = 40 OR i2 = 30)) OR ( c1 = 'F' AND (i2 = 40 ))) +GROUP BY c1; +c1 max(i2) +C 30 +SELECT TRACE RLIKE 'minmax_keypart_in_disjunctive_query' +AS OK FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +OK +1 +EXPLAIN SELECT c1, i1, max(i2) FROM t2 +WHERE (c1 = 'C' OR ( c1 = 'F' AND i1 < 35)) AND ( i2 = 17 ) +GROUP BY c1,i1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL ROWS 10.00 Parallel execute (2 workers) +2 SIMPLE t2 NULL range k2 k2 8 NULL ROWS 10.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`c1` AS `c1`,`test`.`t2`.`i1` AS `i1`,max(`test`.`t2`.`i2`) AS `max(i2)` from `test`.`t2` where ((`test`.`t2`.`i2` = 17) and ((`test`.`t2`.`c1` = 'C') or ((`test`.`t2`.`c1` = 'F') and (`test`.`t2`.`i1` < 35)))) group by `test`.`t2`.`c1`,`test`.`t2`.`i1` +SELECT c1, i1, max(i2) FROM t2 +WHERE (c1 = 'C' OR ( c1 = 'F' AND i1 < 35)) AND ( i2 = 17 ) +GROUP BY c1,i1; +c1 i1 max(i2) +C 17 17 +F 17 17 +SELECT TRACE RLIKE 'minmax_keypart_in_disjunctive_query' +AS OK FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +OK +0 +EXPLAIN SELECT c1, i1, max(i2) FROM t2 +WHERE (((c1 = 'C' AND i1 < 40) OR ( c1 = 'F' AND i1 < 35)) AND ( i2 = 17 )) +GROUP BY c1,i1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL ROWS 10.00 Parallel execute (2 workers) +2 SIMPLE t2 NULL range k2 k2 8 NULL ROWS 10.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`c1` AS `c1`,`test`.`t2`.`i1` AS `i1`,max(`test`.`t2`.`i2`) AS `max(i2)` from `test`.`t2` where ((`test`.`t2`.`i2` = 17) and (((`test`.`t2`.`c1` = 'C') and (`test`.`t2`.`i1` < 40)) or ((`test`.`t2`.`c1` = 'F') and (`test`.`t2`.`i1` < 35)))) group by `test`.`t2`.`c1`,`test`.`t2`.`i1` +SELECT c1, i1, max(i2) FROM t2 +WHERE (((c1 = 'C' AND i1 < 40) OR ( c1 = 'F' AND i1 < 35)) AND ( i2 = 17 )) +GROUP BY c1,i1; +c1 i1 max(i2) +C 17 17 +F 17 17 +SELECT TRACE RLIKE 'minmax_keypart_in_disjunctive_query' +AS OK FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +OK +0 +EXPLAIN SELECT c1, i1, max(i2) FROM t2 +WHERE ((c1 = 'C' AND i1 < 40) OR ( c1 = 'F' AND i1 < 35) OR ( i2 = 17 )) +GROUP BY c1,i1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL ROWS 19.72 Parallel execute (1 workers) +2 SIMPLE t2 NULL index k2 k2 12 NULL ROWS 19.72 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`c1` AS `c1`,`test`.`t2`.`i1` AS `i1`,max(`test`.`t2`.`i2`) AS `max(i2)` from `test`.`t2` where (((`test`.`t2`.`c1` = 'C') and (`test`.`t2`.`i1` < 40)) or ((`test`.`t2`.`c1` = 'F') and (`test`.`t2`.`i1` < 35)) or (`test`.`t2`.`i2` = 17)) group by `test`.`t2`.`c1`,`test`.`t2`.`i1` +SELECT c1, i1, max(i2) FROM t2 +WHERE ((c1 = 'C' AND i1 < 40) OR ( c1 = 'F' AND i1 < 35) OR ( i2 = 17 )) +GROUP BY c1,i1; +c1 i1 max(i2) +A 17 17 +B 17 17 +C 1 1 +C 2 2 +C 3 3 +C 4 4 +C 5 5 +C 6 6 +C 7 7 +C 8 8 +C 9 9 +C 10 10 +C 11 11 +C 12 12 +C 13 13 +C 14 14 +C 15 15 +C 16 16 +C 17 17 +C 18 18 +C 19 19 +C 20 20 +C 21 21 +C 22 22 +C 23 23 +C 24 24 +C 25 25 +C 26 26 +C 27 27 +C 28 28 +C 29 29 +C 30 30 +D 17 17 +E 17 17 +F 1 1 +F 2 2 +F 3 3 +F 4 4 +F 5 5 +F 6 6 +F 7 7 +F 8 8 +F 9 9 +F 10 10 +F 11 11 +F 12 12 +F 13 13 +F 14 14 +F 15 15 +F 16 16 +F 17 17 +F 18 18 +F 19 19 +F 20 20 +F 21 21 +F 22 22 +F 23 23 +F 24 24 +F 25 25 +F 26 26 +F 27 27 +F 28 28 +F 29 29 +F 30 30 +SELECT TRACE RLIKE 'minmax_keypart_in_disjunctive_query' +AS OK FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +OK +1 +SET optimizer_trace_max_mem_size=DEFAULT; +SET optimizer_trace=DEFAULT; +SET end_markers_in_json=DEFAULT; +DROP TABLE t0,t1,t2; +# +# Bug #21749123: SELECT DISTINCT, WRONG RESULTS COMBINED WITH +# USE_INDEX_EXTENSIONS=OFF +# +CREATE TABLE t1 ( +pk_col INT AUTO_INCREMENT PRIMARY KEY, +a1 CHAR(64), +KEY a1_idx (a1) +) charset utf8mb4 ENGINE=INNODB; +INSERT INTO t1 (a1) VALUES ('a'),('a'),('a'),('a'), ('a'); +CREATE TABLE t2 ( +pk_col1 INT NOT NULL, +pk_col2 INT NOT NULL, +a1 CHAR(64), +a2 CHAR(64), +PRIMARY KEY(pk_col1, pk_col2), +KEY a1_idx (a1), +KEY a1_a2_idx (a1, a2) +) charset utf8mb4 ENGINE=INNODB; +INSERT INTO t2 (pk_col1, pk_col2, a1, a2) VALUES (1,1,'a','b'),(1,2,'a','b'), +(1,3,'a','c'),(1,4,'a','c'), +(2,1,'a','d'); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +ANALYZE TABLE t2; +Table Op Msg_type Msg_text +test.t2 analyze status OK +EXPLAIN SELECT DISTINCT a1 +FROM t1 +WHERE (pk_col = 2 OR pk_col = 22) AND a1 = 'a'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range PRIMARY,a1_idx a1_idx 261 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select distinct `test`.`t1`.`a1` AS `a1` from `test`.`t1` where ((`test`.`t1`.`a1` = 'a') and ((`test`.`t1`.`pk_col` = 2) or (`test`.`t1`.`pk_col` = 22))) +SELECT DISTINCT a1 +FROM t1 +WHERE (pk_col = 2 OR pk_col = 22) AND a1 = 'a'; +a1 +a +EXPLAIN SELECT COUNT(DISTINCT a1) +FROM t1 +GROUP BY a1,pk_col; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range a1_idx a1_idx 261 NULL 6 100.00 Using index for group-by (scanning) +Warnings: +Note 1003 /* select#1 */ select count(distinct `test`.`t1`.`a1`) AS `COUNT(DISTINCT a1)` from `test`.`t1` group by `test`.`t1`.`a1`,`test`.`t1`.`pk_col` +SELECT COUNT(DISTINCT a1) +FROM t1 +GROUP BY a1,pk_col; +COUNT(DISTINCT a1) +1 +1 +1 +1 +1 +EXPLAIN SELECT COUNT(DISTINCT a1) +FROM t2 +GROUP BY a1,pk_col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range a1_idx,a1_a2_idx a1_idx 261 NULL 3 100.00 Using index for group-by +Warnings: +Note 1003 /* select#1 */ select count(distinct `test`.`t2`.`a1`) AS `COUNT(DISTINCT a1)` from `test`.`t2` group by `test`.`t2`.`a1`,`test`.`t2`.`pk_col1` +SELECT COUNT(DISTINCT a1) +FROM t2 +GROUP BY a1,pk_col1; +COUNT(DISTINCT a1) +1 +1 +EXPLAIN SELECT COUNT(DISTINCT a1) +FROM t2 +GROUP BY a1,a2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range a1_a2_idx a1_a2_idx 514 NULL 4 100.00 Using index for group-by (scanning) +Warnings: +Note 1003 /* select#1 */ select count(distinct `test`.`t2`.`a1`) AS `COUNT(DISTINCT a1)` from `test`.`t2` group by `test`.`t2`.`a1`,`test`.`t2`.`a2` +SELECT COUNT(DISTINCT a1) +FROM t2 +GROUP BY a1,a2; +COUNT(DISTINCT a1) +1 +1 +1 +SET @optimizer_switch_save=@@optimizer_switch; +SET @@optimizer_switch= "use_index_extensions=off"; +EXPLAIN SELECT DISTINCT a1 +FROM t1 +WHERE (pk_col = 2 OR pk_col = 22) AND a1 = 'a'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ref PRIMARY,a1_idx a1_idx 257 const 5 40.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select distinct `test`.`t1`.`a1` AS `a1` from `test`.`t1` where ((`test`.`t1`.`a1` = 'a') and ((`test`.`t1`.`pk_col` = 2) or (`test`.`t1`.`pk_col` = 22))) +SELECT DISTINCT a1 +FROM t1 +WHERE (pk_col = 2 OR pk_col = 22) AND a1 = 'a'; +a1 +a +EXPLAIN SELECT COUNT(DISTINCT a1) +FROM t1 +GROUP BY a1,pk_col; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index a1_idx a1_idx 257 NULL 5 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select count(distinct `test`.`t1`.`a1`) AS `COUNT(DISTINCT a1)` from `test`.`t1` group by `test`.`t1`.`a1`,`test`.`t1`.`pk_col` +SELECT COUNT(DISTINCT a1) +FROM t1 +GROUP BY a1,pk_col; +COUNT(DISTINCT a1) +1 +1 +1 +1 +1 +EXPLAIN SELECT COUNT(DISTINCT a1) +FROM t2 +GROUP BY a1,pk_col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index a1_idx,a1_a2_idx a1_idx 257 NULL 5 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select count(distinct `test`.`t2`.`a1`) AS `COUNT(DISTINCT a1)` from `test`.`t2` group by `test`.`t2`.`a1`,`test`.`t2`.`pk_col1` +SELECT COUNT(DISTINCT a1) +FROM t2 +GROUP BY a1,pk_col1; +COUNT(DISTINCT a1) +1 +1 +EXPLAIN SELECT COUNT(DISTINCT a1) +FROM t2 +GROUP BY a1,a2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range a1_a2_idx a1_a2_idx 514 NULL 4 100.00 Using index for group-by (scanning) +Warnings: +Note 1003 /* select#1 */ select count(distinct `test`.`t2`.`a1`) AS `COUNT(DISTINCT a1)` from `test`.`t2` group by `test`.`t2`.`a1`,`test`.`t2`.`a2` +SELECT COUNT(DISTINCT a1) +FROM t2 +GROUP BY a1,a2; +COUNT(DISTINCT a1) +1 +1 +1 +SET @@optimizer_switch= @optimizer_switch_save; +DROP TABLE t1, t2; +# +# Bug #24671968: WHEN THE OPTIMISER IS USING INDEX FOR GROUP-BY IT OFTEN +# OFTEN GIVES WRONG RESULTS +# +CREATE TABLE t1 ( +id int NOT NULL, +c1 int NOT NULL, +c2 int, +PRIMARY KEY(id), +INDEX c1_c2_idx(c1, c2)); +INSERT INTO t1 (id, c1, c2) VALUES (1,1,1), (2,2,2), (10,10,1), (11,10,8), +(12,10,1), (13,10,2); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT DISTINCT c1 +FROM t1 +WHERE EXISTS (SELECT * +FROM DUAL +WHERE (c2 = 2)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL index c1_c2_idx c1_c2_idx 9 NULL 6 100.00 Using where; Using index +2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1276 Field or reference 'test.t1.c2' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select distinct `test`.`t1`.`c1` AS `c1` from `test`.`t1` where exists(/* select#2 */ select 1 from DUAL where (`test`.`t1`.`c2` = 2)) +EXPLAIN SELECT DISTINCT c1 +FROM t1 +WHERE 1 IN (2, +(SELECT 1 +FROM DUAL +WHERE (c2 = 2)), +3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL index c1_c2_idx c1_c2_idx 9 NULL 6 100.00 Using where; Using index +2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1276 Field or reference 'test.t1.c2' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select distinct `test`.`t1`.`c1` AS `c1` from `test`.`t1` where (1 in (2,(/* select#2 */ select 1 from DUAL where (`test`.`t1`.`c2` = 2)),3)) +EXPLAIN SELECT DISTINCT c1 +FROM t1 +WHERE c2 = 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range c1_c2_idx c1_c2_idx 9 NULL 4 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select distinct `test`.`t1`.`c1` AS `c1` from `test`.`t1` where (`test`.`t1`.`c2` = 2) +EXPLAIN SELECT DISTINCT c1 +FROM t1 IGNORE INDEX (c1_c2_idx) +WHERE EXISTS (SELECT * +FROM DUAL +WHERE (c2 = 2)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 6 100.00 Using where; Using temporary +2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1276 Field or reference 'test.t1.c2' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select distinct `test`.`t1`.`c1` AS `c1` from `test`.`t1` IGNORE INDEX (`c1_c2_idx`) where exists(/* select#2 */ select 1 from DUAL where (`test`.`t1`.`c2` = 2)) +EXPLAIN SELECT DISTINCT c1 +FROM t1 IGNORE INDEX (c1_c2_idx) +WHERE 1 IN (2, +(SELECT 1 +FROM DUAL +WHERE (c2 = 2)), +3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 6 100.00 Using where; Using temporary +2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1276 Field or reference 'test.t1.c2' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select distinct `test`.`t1`.`c1` AS `c1` from `test`.`t1` IGNORE INDEX (`c1_c2_idx`) where (1 in (2,(/* select#2 */ select 1 from DUAL where (`test`.`t1`.`c2` = 2)),3)) +SET optimizer_trace="enabled=on"; +SELECT DISTINCT c1 +FROM t1 +WHERE EXISTS (SELECT * +FROM DUAL +WHERE (c2 = 2)); +c1 +2 +10 +SELECT TRACE INTO @trace FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +SELECT @trace RLIKE "keypart_reference_from_where_clause"; +@trace RLIKE "keypart_reference_from_where_clause" +1 +SET optimizer_trace="enabled=off"; +SELECT DISTINCT c1 +FROM t1 +WHERE 1 IN (2, +(SELECT 1 +FROM DUAL +WHERE (c2 = 2)), +3); +c1 +2 +10 +SELECT DISTINCT c1 +FROM t1 +WHERE c2 = 2; +c1 +2 +10 +SELECT DISTINCT c1 +FROM t1 IGNORE INDEX (c1_c2_idx) +WHERE EXISTS (SELECT * +FROM DUAL +WHERE (c2 = 2)); +c1 +2 +10 +SELECT DISTINCT c1 +FROM t1 IGNORE INDEX (c1_c2_idx) +WHERE 1 IN (2, +(SELECT 1 +FROM DUAL +WHERE (c2 = 2)), +3); +c1 +2 +10 +DROP TABLE t1; +# +# Bug #26532061: SELECT DISTINCT WITH SECONDARY KEY FOR +# 'USING INDEX FOR GROUP-BY' BAD RESULTS +# +CREATE TABLE t1( +pk INT NOT NULL, +c1 CHAR(2), +c2 INT, +PRIMARY KEY(pk), +UNIQUE KEY ukey(c1, c2) +); +INSERT INTO t1(pk, c1, c2) VALUES (1,1,1),(2,2,2),(3,3,3),(4,5,4); +SET @a:=5; +INSERT IGNORE INTo t1(pk, c1, c2) +SELECT (@a:=@a+1),@a,@a FROM t1, t1 t2,t1 t3, t1 t4; +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +SELECT * FROM t1 WHERE pk = 1 OR pk = 231; +pk c1 c2 +1 1 1 +231 23 231 +EXPLAIN SELECT DISTINCT c1 +FROM t1 FORCE INDEX(ukey) +WHERE pk IN (1,231) and c1 IS NOT NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index ukey ukey 14 NULL 260 20.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select distinct `test`.`t1`.`c1` AS `c1` from `test`.`t1` FORCE INDEX (`ukey`) where ((`test`.`t1`.`pk` in (1,231)) and (`test`.`t1`.`c1` is not null)) +EXPLAIN SELECT DISTINCT c1 +FROM t1 IGNORE INDEX(ukey) +WHERE pk IN (1,231) and c1 IS NOT NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range PRIMARY PRIMARY 4 NULL 2 90.00 Using where; Using temporary +Warnings: +Note 1003 /* select#1 */ select distinct `test`.`t1`.`c1` AS `c1` from `test`.`t1` IGNORE INDEX (`ukey`) where ((`test`.`t1`.`pk` in (1,231)) and (`test`.`t1`.`c1` is not null)) +SELECT DISTINCT c1 +FROM t1 FORCE INDEX(ukey) +WHERE pk IN (1,231) and c1 IS NOT NULL; +c1 +1 +23 +SELECT DISTINCT c1 +FROM t1 IGNORE INDEX(ukey) +WHERE pk IN (1,231) and c1 IS NOT NULL; +c1 +1 +23 +DROP TABLE t1; +# +# Bug #25989915: LOOSE INDEX SCANS RETURNING WRONG RESULT +# +CREATE TABLE t1 ( +pk INT NOT NULL AUTO_INCREMENT, +c1 varchar(100) DEFAULT NULL, +c2 INT NOT NULL, +PRIMARY KEY (pk), +UNIQUE KEY ukey (c2,c1) +); +INSERT INTO t1(pk, c2) VALUES (100, 0), (101, 0), (102, 0), (103, 0); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT COUNT(DISTINCT(c2)) FROM t1 WHERE pk IN (102, 101); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index PRIMARY,ukey ukey 407 NULL 4 50.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select count(distinct `test`.`t1`.`c2`) AS `COUNT(DISTINCT(c2))` from `test`.`t1` where (`test`.`t1`.`pk` in (102,101)) +EXPLAIN SELECT COUNT(DISTINCT(c2)) FROM t1 WHERE pk IN (102, 100); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index PRIMARY,ukey ukey 407 NULL 4 50.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select count(distinct `test`.`t1`.`c2`) AS `COUNT(DISTINCT(c2))` from `test`.`t1` where (`test`.`t1`.`pk` in (102,100)) +SELECT COUNT(DISTINCT(c2)) FROM t1 WHERE pk IN (102, 101); +COUNT(DISTINCT(c2)) +1 +SELECT COUNT(DISTINCT(c2)) FROM t1 WHERE pk IN (102, 100); +COUNT(DISTINCT(c2)) +1 +DROP TABLE t1; diff --git a/mysql-test/r/handler_read_last.result-pq b/mysql-test/r/handler_read_last.result-pq new file mode 100644 index 000000000000..e46af11dc9c7 --- /dev/null +++ b/mysql-test/r/handler_read_last.result-pq @@ -0,0 +1,60 @@ +DROP TABLE IF EXISTS t1; +CREATE TABLE t1 (a INT, INDEX (a)); +INSERT INTO t1 VALUES (),(),(),(),(),(),(),(),(),(); +FLUSH STATUS; +SELECT a FROM t1 ORDER BY a LIMIT 1; +a +NULL +SHOW STATUS LIKE 'HANDLER_READ%'; +Variable_name Value +Handler_read_first 1 +Handler_read_key 1 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 1 +FLUSH STATUS; +SELECT a FROM t1 ORDER BY a DESC LIMIT 1; +a +NULL +SHOW STATUS LIKE 'HANDLER_READ%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 1 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 1 +FLUSH STATUS; +SELECT a FROM t1 ORDER BY a LIMIT 3; +a +NULL +NULL +NULL +SHOW STATUS LIKE 'HANDLER_READ%'; +Variable_name Value +Handler_read_first 1 +Handler_read_key 1 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 3 +FLUSH STATUS; +SELECT a FROM t1 ORDER BY a DESC LIMIT 3; +a +NULL +NULL +NULL +SHOW STATUS LIKE 'HANDLER_READ%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 1 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 3 +DROP TABLE t1; diff --git a/mysql-test/r/hash_join.result-pq b/mysql-test/r/hash_join.result-pq new file mode 100644 index 000000000000..eb629ba1ceac --- /dev/null +++ b/mysql-test/r/hash_join.result-pq @@ -0,0 +1,4022 @@ +# +# Start out by testing some simple in-memory inner hash joins. +# +# Join on two integer columns. +CREATE TABLE t1 (col1 INTEGER); +CREATE TABLE t2 (col1 INTEGER); +INSERT INTO t1 VALUES (1), (3), (5), (7); +INSERT INTO t2 VALUES (1), (2), (5), (6); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN FORMAT=tree +SELECT t1.col1, t2.col1 FROM t1 JOIN t2 ON t1.col1 = t2.col1 ORDER BY t1.col1; +EXPLAIN +-> Sort: t1.col1 + -> Stream results + -> Parallel scan on + -> Sort: t1.col1 + -> Stream results (cost=2.50 rows=4) + -> Inner hash join (t2.col1 = t1.col1) (cost=2.50 rows=4) + -> Table scan on t2 (cost=0.09 rows=4) + -> Hash + -> PQblock scan on t1 (cost=0.65 rows=4) + +SELECT t1.col1, t2.col1 FROM t1 JOIN t2 ON t1.col1 = t2.col1 ORDER BY t1.col1; +col1 col1 +1 1 +5 5 +DROP TABLE t1, t2; +# Join on a integer column and a string column. +CREATE TABLE t1 (col1 INTEGER); +CREATE TABLE t2 (col1 VARCHAR(255)); +INSERT INTO t1 VALUES (1), (3), (5), (7); +INSERT INTO t2 VALUES (1), (2), (5), (6); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN FORMAT=tree +SELECT t1.col1, t2.col1 FROM t1 JOIN t2 ON t1.col1 = t2.col1 ORDER BY t1.col1; +EXPLAIN +-> Sort: t1.col1 + -> Stream results + -> Parallel scan on + -> Sort: t1.col1 + -> Stream results (cost=2.50 rows=4) + -> Inner hash join (cast(t1.col1 as double) = cast(t2.col1 as double)) (cost=2.50 rows=4) + -> Table scan on t2 (cost=0.09 rows=4) + -> Hash + -> PQblock scan on t1 (cost=0.65 rows=4) + +SELECT t1.col1, t2.col1 FROM t1 JOIN t2 ON t1.col1 = t2.col1 ORDER BY t1.col1; +col1 col1 +1 1 +5 5 +DROP TABLE t1, t2; +# Join on two datetime columns. +CREATE TABLE t1 (col1 DATETIME(6)); +CREATE TABLE t2 (col1 DATETIME(6)); +INSERT INTO t1 VALUES ('2018-01-01 00:00:00.000000'), +('2018-01-01 00:00:00.000001'), +('2018-01-02 00:00:00.000000'), +('2018-01-02 00:00:00.000001'); +INSERT INTO t2 VALUES ('2018-01-01 00:00:00.000000'), +('2018-01-01 00:00:00.000002'), +('2018-01-02 00:00:00.000001'), +('2019-01-02 00:00:00.000001'); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN FORMAT=tree +SELECT t1.col1, t2.col1 FROM t1 JOIN t2 ON t1.col1 = t2.col1; +EXPLAIN +-> Parallel scan on + -> Inner hash join (t2.col1 = t1.col1) (cost=2.50 rows=4) + -> Table scan on t2 (cost=0.09 rows=4) + -> Hash + -> PQblock scan on t1 (cost=0.65 rows=4) + +SELECT t1.col1, t2.col1 FROM t1 JOIN t2 ON t1.col1 = t2.col1 ORDER BY t1.col1; +col1 col1 +2018-01-01 00:00:00.000000 2018-01-01 00:00:00.000000 +2018-01-02 00:00:00.000001 2018-01-02 00:00:00.000001 +DROP TABLE t1, t2; +# Join on a string and datetime column, where datetime comparison is +# picked. +CREATE TABLE t1 (a DATETIME); +INSERT INTO t1 VALUES ('2001-01-01 00:00:00'); +CREATE TABLE t2 (b VARCHAR(64)); +INSERT INTO t2 VALUES ('2001#01#01'); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN FORMAT=tree SELECT * FROM t1, t2 WHERE a=b; +EXPLAIN +-> Parallel scan on + -> Inner hash join (t1.a = t2.b) (cost=0.70 rows=1) + -> Table scan on t2 (cost=0.35 rows=1) + -> Hash + -> PQblock scan on t1 (cost=0.35 rows=1) + +SELECT * FROM t1, t2 WHERE a=b; +a b +2001-01-01 00:00:00 2001#01#01 +DROP TABLE t1, t2; +# Join on two double columns. +CREATE TABLE t1 (col1 DOUBLE); +CREATE TABLE t2 (col1 DOUBLE); +INSERT INTO t1 VALUES (1.1), (3.3), (5.5), (7.7); +INSERT INTO t2 VALUES (1.1), (1.11), (5.5), (6.6); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN FORMAT=tree +SELECT t1.col1, t2.col1 FROM t1 JOIN t2 ON t1.col1 = t2.col1; +EXPLAIN +-> Parallel scan on + -> Inner hash join (t2.col1 = t1.col1) (cost=2.50 rows=4) + -> Table scan on t2 (cost=0.09 rows=4) + -> Hash + -> PQblock scan on t1 (cost=0.65 rows=4) + +SELECT t1.col1, t2.col1 FROM t1 JOIN t2 ON t1.col1 = t2.col1 ORDER BY t1.col1; +col1 col1 +1.1 1.1 +5.5 5.5 +DROP TABLE t1, t2; +# Join on two decimal columns. +CREATE TABLE t1 (col1 DECIMAL(6, 2)); +CREATE TABLE t2 (col1 DECIMAL(6, 2)); +INSERT INTO t1 VALUES (1.1), (3.3), (5.5), (7.7); +INSERT INTO t2 VALUES (1.1), (1.10), (5.5), (6.6); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN FORMAT=tree +SELECT t1.col1, t2.col1 FROM t1 JOIN t2 ON t1.col1 = t2.col1; +EXPLAIN +-> Parallel scan on + -> Inner hash join (t2.col1 = t1.col1) (cost=2.50 rows=4) + -> Table scan on t2 (cost=0.09 rows=4) + -> Hash + -> PQblock scan on t1 (cost=0.65 rows=4) + +SELECT t1.col1, t2.col1 FROM t1 JOIN t2 ON t1.col1 = t2.col1 ORDER BY t1.col1; +col1 col1 +1.10 1.10 +1.10 1.10 +5.50 5.50 +DROP TABLE t1, t2; +# See that comparison between decimal and bigint works well. The main +# challenge is that decimals with different amount of leading/trailing +# zeroes should compare equally. +CREATE TABLE t1 (col1 BIGINT); +CREATE TABLE t2 (col1 DECIMAL(64,30)); +INSERT INTO t1 VALUES (5); +INSERT INTO t2 VALUES (5.000000000000000000000000000000); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN FORMAT=tree SELECT * FROM t1,t2 WHERE t1.col1 = t2.col1; +EXPLAIN +-> Parallel scan on + -> Inner hash join (t1.col1 = t2.col1) (cost=0.70 rows=1) + -> Table scan on t2 (cost=0.35 rows=1) + -> Hash + -> PQblock scan on t1 (cost=0.35 rows=1) + +SELECT * FROM t1,t2 WHERE t1.col1 = t2.col1; +col1 col1 +5 5.000000000000000000000000000000 +DROP TABLE t1, t2; +CREATE TABLE t1 (col1 DECIMAL(5)); +CREATE TABLE t2 (col1 BIGINT); +INSERT INTO t1 VALUES (1); +INSERT INTO t2 VALUES (1); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN FORMAT=tree SELECT * FROM t1,t2 where t1.col1=t2.col1; +EXPLAIN +-> Parallel scan on + -> Inner hash join (t1.col1 = t2.col1) (cost=0.70 rows=1) + -> Table scan on t2 (cost=0.35 rows=1) + -> Hash + -> PQblock scan on t1 (cost=0.35 rows=1) + +SELECT * FROM t1,t2 where t1.col1=t2.col1; +col1 col1 +1 1 +DROP TABLE t1, t2; +# Bit fields, which is a bit different depending on the storage engine. +create table t1 (id1 int, b1 bit(1)) engine = myisam; +create table t2 (id2 int, b2 bit(1)) engine = myisam; +insert into t1 values (2, 0), (3, 1); +insert into t2 values (2, 1), (3, 0); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN FORMAT=tree SELECT * FROM t1, t2 WHERE id1 = id2; +EXPLAIN +-> Inner hash join (t2.id2 = t1.id1) (cost=1.60 rows=2) + -> Table scan on t2 (cost=0.30 rows=2) + -> Hash + -> Table scan on t1 (cost=0.70 rows=2) + +SELECT id1, HEX(b1), id2, HEX(b2) FROM t1, t2 WHERE id1 = id2; +id1 HEX(b1) id2 HEX(b2) +2 0 2 1 +3 1 3 0 +DROP TABLE t1, t2; +create table t1 (id1 int, b1 bit(64)) engine = innodb; +create table t2 (id2 int, b2 bit(64)) engine = innodb; +insert into t1 values (2, 0), (3, 2); +insert into t2 values (2, 2), (3, 0); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN FORMAT=tree SELECT * FROM t1, t2 WHERE id1 = id2; +EXPLAIN +-> Parallel scan on + -> Inner hash join (t2.id2 = t1.id1) (cost=1.10 rows=2) + -> Table scan on t2 (cost=0.18 rows=2) + -> Hash + -> PQblock scan on t1 (cost=0.45 rows=2) + +SELECT id1, HEX(b1), id2, HEX(b2) FROM t1, t2 WHERE id1 = id2; +id1 HEX(b1) id2 HEX(b2) +2 0 2 2 +3 2 3 0 +DROP TABLE t1, t2; +# See that we handle NULL values properly. +CREATE TABLE t1 (col1 VARCHAR(255)); +CREATE TABLE t2 (col1 VARCHAR(255)); +INSERT INTO t1 VALUES (NULL); +INSERT INTO t2 VALUES (""); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN FORMAT=tree SELECT * FROM t1, t2 WHERE t1.col1 = t2.col1; +EXPLAIN +-> Parallel scan on + -> Filter: (t2.col1 = t1.col1) (cost=0.70 rows=1) + -> Inner hash join ((t2.col1)=(t1.col1)) (cost=0.70 rows=1) + -> Table scan on t2 (cost=0.35 rows=1) + -> Hash + -> PQblock scan on t1 (cost=0.35 rows=1) + +SELECT * FROM t1, t2 WHERE t1.col1 = t2.col1; +col1 col1 +DROP TABLE t1,t2; +# +# Now, do some queries where we end up with a GRACE hash join. That is, +# the right table of the join is bigger than the join_buffer_size. +# +CREATE TABLE t1 (col1 BIGINT); +CREATE TABLE t2 (col1 BIGINT); +INSERT INTO t1 SELECT 1; +INSERT INTO t1 SELECT col1 + 1 FROM t1; +INSERT INTO t1 SELECT col1 + 2 FROM t1; +INSERT INTO t1 SELECT col1 + 4 FROM t1; +INSERT INTO t1 SELECT col1 + 8 FROM t1; +INSERT INTO t1 SELECT col1 + 16 FROM t1; +INSERT INTO t1 SELECT col1 + 32 FROM t1; +INSERT INTO t1 SELECT col1 + 64 FROM t1; +INSERT INTO t1 SELECT col1 + 128 FROM t1; +INSERT INTO t1 SELECT col1 + 256 FROM t1; +INSERT INTO t1 SELECT col1 + 512 FROM t1; +INSERT INTO t2 SELECT col1 FROM t1; +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +SET join_buffer_size = 2048; +EXPLAIN FORMAT=tree +SELECT SUM(t1.col1), SUM(t2.col1) FROM t1, t2 WHERE t1.col1 = t2.col1; +EXPLAIN +-> Aggregate: sum(`SUM(t1.col1)`), sum(`SUM(t2.col1)`) + -> Parallel scan on + -> Aggregate: + -> Inner hash join (t2.col1 = t1.col1) (cost=*** rows=104858) + -> Table scan on t2 (cost=*** rows=1024) + -> Hash + -> PQblock scan on t1 (cost=*** rows=1024) + +TRUNCATE performance_schema.file_summary_by_event_name; +SELECT COUNT_STAR > 0 FROM performance_schema.file_summary_by_event_name +WHERE event_name LIKE '%hash_join%'; +COUNT_STAR > 0 +0 +SELECT SUM(t1.col1), SUM(t2.col1) FROM t1, t2 WHERE t1.col1 = t2.col1; +SUM(t1.col1) SUM(t2.col1) +524800 524800 +SELECT COUNT_STAR > 0 FROM performance_schema.file_summary_by_event_name +WHERE event_name LIKE '%hash_join%'; +COUNT_STAR > 0 +1 +SET join_buffer_size = DEFAULT; +DROP TABLE t1,t2; +# See that spill to disk (GRACE hash join) works with all kind of +# data types. +CREATE TABLE t1 ( +str_col VARCHAR(255), +blob_col LONGBLOB, +text_col LONGTEXT, +bit_col BIT(64), +tinyint_col TINYINT, +smallint_col SMALLINT, +mediumint_col MEDIUMINT, +int_col INTEGER, +bigint_col BIGINT, +float_col FLOAT, +double_col DOUBLE, +decimal_col DECIMAL(65, 30), +year_col YEAR, +date_col DATE, +time_col TIME(6), +datetime_col DATETIME(6), +timestamp_col TIMESTAMP(6), +json_col JSON, +geometry_col GEOMETRY +); +SET time_zone = '+00:00'; +INSERT INTO t1 VALUES ( +'', +'', +'', +b'0000000000000000000000000000000000000000000000000000000000000000', +-128, +-32768, +-8388608, +-2147483648, +-9223372036854775808, +-3.402823466E+38, +-1.7976931348623157E+308, +'-99999999999999999999999999999999999.999999999999999999999999999999', +1901, +'1000-01-01', +'-838:59:59.000000', +'1000-01-01 00:00:00.000000', +'1970-01-01 00:00:01.000000', +'{}', +ST_GeomFromText('GEOMETRYCOLLECTION()') +); +INSERT INTO t1 VALUES ( +'a very long and interesting string', +'a very long and interesting blob', +'a very long and interesting text', +b'1111111111111111111111111111111111111111111111111111111111111111', +127, +32767, +8388607, +2147483647, +9223372036854775807, +3.402823466E+38, +1.7976931348623157E+308, +'99999999999999999999999999999999999.999999999999999999999999999999', +2155, +'9999-12-31', +'838:59:59.000000', +'9999-12-31 23:59:59.999999', +'2038-01-19 03:14:07.999999', +'{"key": [1, 2, 3]}', +ST_GeomFromText('GEOMETRYCOLLECTION(POINT(1 2), POINT(3 4))') +); +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +SET join_buffer_size = 99968; +# Just do a few aggregations for sanity checking. We don't want to +# pollute the result log with thousands of lines with binary data. +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN FORMAT=tree SELECT +COUNT(*), +SUM(LENGTH(t1.text_col)), +SUM(t2.bigint_col) +FROM +t1, +t1 AS t2 +WHERE +t1.int_col = t2.int_col +ORDER BY +t1.int_col; +EXPLAIN +-> Aggregate: count(0), sum(length(t1.text_col)), sum(t2.bigint_col) + -> Inner hash join (t2.int_col = t1.int_col) (cost=*** rows=1638) + -> Table scan on t2 (cost=*** rows=128) + -> Hash + -> Table scan on t1 (cost=*** rows=128) + +SELECT +COUNT(*), +SUM(LENGTH(t1.text_col)), +SUM(t2.bigint_col) +FROM +t1, +t1 AS t2 +WHERE +t1.int_col = t2.int_col +ORDER BY +t1.int_col; +COUNT(*) SUM(LENGTH(t1.text_col)) SUM(t2.bigint_col) +8192 131072 -4096 +DROP TABLE t1; +SET join_buffer_size = DEFAULT; +SET time_zone = DEFAULT; +# +# A query where we end up with a weedout + hash join. This forces hash +# join to keep the row ID for each row, so that the duplicate removal +# works. +# +SET optimizer_switch="materialization=off,firstmatch=off"; +CREATE TABLE t1 (i BIGINT); +CREATE TABLE t2 (i BIGINT); +INSERT INTO t1 VALUES (1), (2), (3); +INSERT INTO t2 VALUES (2), (3); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN FORMAT=tree SELECT * FROM t2 WHERE (t2.i) IN (SELECT t1.i FROM t1); +EXPLAIN +-> Parallel scan on + -> Remove duplicate t2 rows using temporary table (weedout) (cost=1.30 rows=2) + -> Inner hash join (t1.i = t2.i) (cost=1.30 rows=2) + -> Table scan on t1 (cost=0.18 rows=3) + -> Hash + -> PQblock scan on t2 (cost=0.45 rows=2) + +SELECT * FROM t2 WHERE (t2.i) IN (SELECT t1.i FROM t1); +i +2 +3 +# Increase the data volume, and reduce the join_buffer_size, in order to +# test that we can keep the row ID in case of GRACE hash join as well. +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t2 SELECT * FROM t2; +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t2 SELECT * FROM t2; +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t2 SELECT * FROM t2; +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t2 SELECT * FROM t2; +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t2 SELECT * FROM t2; +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t2 SELECT * FROM t2; +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t2 SELECT * FROM t2; +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t2 SELECT * FROM t2; +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t2 SELECT * FROM t2; +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +SET join_buffer_size = 2048; +EXPLAIN FORMAT=tree +SELECT COUNT(*) FROM t2 WHERE (t2.i) IN (SELECT t1.i FROM t1); +EXPLAIN +-> Aggregate: count(`COUNT(*)`) + -> Parallel scan on + -> Aggregate: + -> Remove duplicate t2 rows using temporary table (weedout) (cost=*** rows=157286) + -> Inner hash join (t1.i = t2.i) (cost=*** rows=157286) + -> Table scan on t1 (cost=*** rows=1536) + -> Hash + -> PQblock scan on t2 (cost=*** rows=1024) + +TRUNCATE performance_schema.file_summary_by_event_name; +SELECT COUNT_STAR > 0 FROM performance_schema.file_summary_by_event_name +WHERE event_name LIKE '%hash_join%'; +COUNT_STAR > 0 +0 +SELECT COUNT(*) FROM t2 WHERE (t2.i) IN (SELECT t1.i FROM t1); +COUNT(*) +1024 +SELECT COUNT_STAR > 0 FROM performance_schema.file_summary_by_event_name +WHERE event_name LIKE '%hash_join%'; +COUNT_STAR > 0 +0 +DROP TABLE t1, t2; +SET join_buffer_size = DEFAULT; +SET optimizer_switch = DEFAULT; +# Test a case where the RAND() function is pushed as late as possible in +# the join. The optimizer ends up rewriting t1.col1 = FLOOR(...) to +# t2.col1 = FLOOR(...), so this test case ensures that the executor is +# able to put the condition after the join. FLOOR and division/addition +# make this query deterministic. +CREATE TABLE t1 (col1 INTEGER); +CREATE TABLE t2 (col1 INTEGER); +INSERT INTO t1 VALUES (1), (2); +INSERT INTO t2 VALUES (1), (2); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN FORMAT=tree SELECT +t1.col1, +t2.col1 +FROM +t1, +t2 +WHERE +t1.col1 = t2.col1 +AND t1.col1 = FLOOR(RAND() / 2 + 2); +EXPLAIN +-> Parallel scan on + -> Filter: (t1.col1 = floor(((rand() / 2) + 2))) (cost=1.00 rows=2) + -> Inner hash join (t2.col1 = t1.col1) (cost=1.00 rows=2) + -> Table scan on t2 (cost=0.35 rows=2) + -> Hash + -> PQblock scan on t1 (cost=0.35 rows=2) + +SELECT +t1.col1, +t2.col1 +FROM +t1, +t2 +WHERE +t1.col1 = t2.col1 +AND t1.col1 = FLOOR(RAND() / 2 + 2); +col1 col1 +2 2 +DROP TABLE t1, t2; +# Ensure that the hash join picks the correct fields and tables when both +# sides of the join condition are from the same source table. +CREATE TABLE c ( +col1 varchar(1) +) ENGINE = myisam; +INSERT INTO c VALUES ('w'); +INSERT INTO c VALUES ('d'); +ANALYZE TABLE c; +Table Op Msg_type Msg_text +test.c analyze status OK +EXPLAIN format=tree SELECT * +FROM +(SELECT * FROM c) AS table1 +JOIN (SELECT * FROM c) AS table2 +ON table2.col1 = table1.col1; +EXPLAIN +-> Inner hash join (c.col1 = c.col1) (cost=1.60 rows=2) + -> Table scan on c (cost=0.30 rows=2) + -> Hash + -> Table scan on c (cost=0.70 rows=2) + +SELECT * +FROM +(SELECT * FROM c) AS table1 +JOIN (SELECT * FROM c) AS table2 +ON table2.col1 = table1.col1; +col1 col1 +w w +d d +DROP TABLE c; +# This query ends up with a BNL between t3 and t2. Ensure that we don't +# end up with a hash join like: +# +# -> Constant row from +# -> Materialize with deduplication +# -> HashJoin inner join (t3.i = '2') +# -> Table scan on t2 +# -> Table scan on t3 +# +# We don't want a join condition on a constant, so it should be pushed as +# a filter. +SET optimizer_switch='firstmatch=off'; +CREATE TABLE t1 (i INTEGER) ENGINE = MyISAM; +CREATE TABLE t2 (i INTEGER) ENGINE = MyISAM; +CREATE TABLE t3 (i INTEGER) ENGINE = MyISAM; +INSERT INTO t1 VALUES (2); +INSERT INTO t2 VALUES (2); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN FORMAT=tree +SELECT * FROM t1 WHERE (t1.i) IN (SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +EXPLAIN +-> Constant row from (cost=0.00..0.00 rows=1) + -> Materialize with deduplication (cost=1.10..1.10 rows=0) + -> Filter: (t3.i is not null) (cost=1.10 rows=0) + -> Inner hash join (no condition) (cost=1.10 rows=0) + -> Filter: (t3.i = '2') (cost=0.50 rows=0) + -> Table scan on t3 (cost=0.50 rows=0) + -> Hash + -> Table scan on t2 (cost=0.60 rows=1) + +SELECT * FROM t1 WHERE (t1.i) IN (SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +DROP TABLE t1,t2,t3; +SET optimizer_switch=DEFAULT; +# A bit more complicated join condition where we have multiple join +# conditions, and one of them is an expression. +CREATE TABLE t1 (a INTEGER, b INTEGER); +INSERT INTO t1 (a) VALUES (1),(2); +CREATE TABLE t3 (a INTEGER, b INTEGER); +INSERT INTO t3 VALUES (1, 10), (1, 11), (2, 10), (2, 11); +ANALYZE TABLE t1, t3; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t3 analyze status OK +EXPLAIN FORMAT=tree SELECT * FROM t1, t3 WHERE t3.b = t1.a + 9 AND t3.a = t1.a; +EXPLAIN +-> Parallel scan on + -> Inner hash join (t3.a = t1.a), (t3.b = (t1.a + 9)) (cost=1.50 rows=2) + -> Table scan on t3 (cost=0.18 rows=4) + -> Hash + -> PQblock scan on t1 (cost=0.45 rows=2) + +SELECT * FROM t1, t3 WHERE t3.b = t1.a + 9 AND t3.a = t1.a; +a b a b +1 NULL 1 10 +2 NULL 2 11 +DROP TABLE t1,t3; +# Ensure that outer joins doesn't degrade into a nested loop, +# but still uses join buffering. +CREATE TABLE t1 (col1 INTEGER); +CREATE TABLE t2 (col1 INTEGER); +INSERT INTO t1 VALUES (1), (2); +INSERT INTO t2 VALUES (2); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN FORMAT=tree SELECT * FROM t1 LEFT JOIN t2 ON t1.col1 = t2.col1; +EXPLAIN +-> Parallel scan on + -> Left hash join (t2.col1 = t1.col1) (cost=0.63 rows=2) + -> PQblock scan on t1 (cost=0.45 rows=2) + -> Hash + -> Table scan on t2 (cost=0.18 rows=1) + +EXPLAIN SELECT * FROM t1 LEFT JOIN t2 ON t1.col1 = t2.col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col1` AS `col1`,`test`.`t2`.`col1` AS `col1` from `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`col1` = `test`.`t1`.`col1`)) where true +DROP TABLE t1, t2; +# See that we can replace a BNL with hash join, even if we have extra +# join conditions that are not equi-join conditions. The result should be +# that the non-equi-join conditions should be attached as a filter after +# the join. +CREATE TABLE t1 (col1 INTEGER, col2 INTEGER); +CREATE TABLE t2 (col1 INTEGER, col2 INTEGER); +INSERT INTO t1 VALUES (1, 1), (2, 2), (3, 3); +INSERT INTO t2 VALUES (1, 1), (2, 4), (3, 6); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN FORMAT=tree +SELECT * FROM t1 JOIN t2 ON t1.col1 = t2.col1 AND t1.col2 < t2.col2; +EXPLAIN +-> Parallel scan on + -> Filter: (t1.col2 < t2.col2) (cost=1.70 rows=3) + -> Inner hash join (t2.col1 = t1.col1) (cost=1.70 rows=3) + -> Table scan on t2 (cost=0.12 rows=3) + -> Hash + -> PQblock scan on t1 (cost=0.55 rows=3) + +SELECT * FROM t1 JOIN t2 ON t1.col1 = t2.col1 AND t1.col2 < t2.col2; +col1 col2 col1 col2 +2 2 2 4 +3 3 3 6 +DROP TABLE t1, t2; +CREATE TABLE t1 (col1 BIGINT); +INSERT INTO t1 VALUES (1), (1), (1), (1), (1), (1), (1), (1), (1), (1); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN FORMAT=tree SELECT SUM(t1.col1) +FROM t1, t1 t2, t1 t3, t1 t4, t1 t5, t1 t6; +EXPLAIN +-> Aggregate: sum(`SUM(t1.col1)`) + -> Parallel scan on + -> Aggregate: + -> Inner hash join (no condition) (cost=111113.45 rows=1000000) + -> Table scan on t6 (cost=0.00 rows=10) + -> Hash + -> Inner hash join (no condition) (cost=11112.35 rows=100000) + -> Table scan on t5 (cost=0.00 rows=10) + -> Hash + -> Inner hash join (no condition) (cost=1112.01 rows=10000) + -> Table scan on t4 (cost=0.00 rows=10) + -> Hash + -> Inner hash join (no condition) (cost=111.75 rows=1000) + -> Table scan on t3 (cost=0.01 rows=10) + -> Hash + -> Inner hash join (no condition) (cost=11.50 rows=100) + -> Table scan on t2 (cost=0.13 rows=10) + -> Hash + -> PQblock scan on t1 (cost=1.25 rows=10) + +SELECT SUM(t1.col1) FROM t1, t1 t2, t1 t3, t1 t4, t1 t5, t1 t6; +SUM(t1.col1) +1000000 +DROP TABLE t1; +# Test that comparison between FLOAT and DOUBLE works as expected if +# given an explicit number of decimals. +CREATE TABLE t1 (col1 FLOAT(5,2), col2 DOUBLE(15,2)); +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (1.01, 1.01); +SELECT * FROM t1 a, t1 b WHERE a.col1 = b.col2; +col1 col2 col1 col2 +1.01 1.01 1.01 1.01 +DROP TABLE t1; +# The point of the following test is to see that if the innermost hash +# join returns zero rows, the outermost hash join should not scan the +# probe table. +CREATE TABLE t1 (col1 INT); +CREATE TABLE t2 (col1 INT); +CREATE TABLE t3 (col1 INT); +INSERT INTO t1 VALUES (1), (2), (3); +INSERT INTO t2 VALUES (1), (2), (3); +INSERT INTO t3 VALUES (1), (2), (3); +ANALYZE TABLE t1, t2, t3; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +EXPLAIN FORMAT=tree SELECT STRAIGHT_JOIN * FROM t1 +JOIN t2 ON t1.col1 + 10 = t2.col1 +JOIN t3 ON t2.col1 = t3.col1; +EXPLAIN +-> Parallel scan on + -> Inner hash join (t3.col1 = t2.col1) (cost=2.85 rows=3) + -> Table scan on t3 (cost=0.12 rows=3) + -> Hash + -> Inner hash join ((t1.col1 + 10) = t2.col1) (cost=1.70 rows=3) + -> Table scan on t2 (cost=0.12 rows=3) + -> Hash + -> PQblock scan on t1 (cost=0.55 rows=3) + +SELECT SUM(variable_value) AS Total_handler_reads +FROM performance_schema.session_status +WHERE variable_name LIKE 'Handler_read%'; +Total_handler_reads +12 +DROP TABLE t1, t2, t3; +# +# Bug#29898802 WL#2241: SIG6 IN HASH_JOIN_BUFFER::LOADINTOTABLEBUFFERS() +# AT HASH_JOIN_BUFFER.CC +# +CREATE TABLE t1 ( +pk int NOT NULL AUTO_INCREMENT, +col_varchar varchar(1), +col_varchar_key varchar(1), +PRIMARY KEY (pk), +KEY idx_CC_col_varchar_key (col_varchar_key) +); +INSERT INTO t1 VALUES (1,'n','X'),(2,'Y','8'),(3,'R','l'); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN FORMAT=tree SELECT +t1.col_varchar_key AS field1 +FROM +(t1, t1 as alias1) +WHERE +NOT +EXISTS( +SELECT +alias2.col_varchar_key +FROM +t1 AS alias2 +WHERE +alias2.col_varchar_key >= t1.col_varchar +) +GROUP BY +field1; +EXPLAIN +-> Table scan on (cost=2.50..2.50 rows=0) + -> Temporary table with deduplication (cost=2.50..2.50 rows=0) + -> Parallel scan on + -> Table scan on (cost=0.11..2.84 rows=27) + -> Temporary table with deduplication (cost=7.46..10.19 rows=27) + -> Inner hash join (no condition) (cost=4.65 rows=27) + -> Index scan on alias1 using idx_CC_col_varchar_key (cost=0.18 rows=3) + -> Hash + -> Nested loop antijoin (cost=1.70 rows=9) + -> PQblock scan on t1 (cost=0.55 rows=3) + -> Filter: (alias2.col_varchar_key >= t1.col_varchar) (cost=0.55 rows=3) + -> Index range scan on alias2 (re-planned for each iteration) (cost=0.55 rows=3) + +Warnings: +Note 1276 Field or reference 'test.t1.col_varchar' of SELECT #2 was resolved in SELECT #1 +SELECT +t1.col_varchar_key AS field1 +FROM +(t1, t1 as alias1) +WHERE +NOT +EXISTS( +SELECT +alias2.col_varchar_key +FROM +t1 AS alias2 +WHERE +alias2.col_varchar_key >= t1.col_varchar +) +GROUP BY +field1; +field1 +8 +DROP TABLE t1; +# See that typed arrays are handled as blobs. That is, we do not try to +# allocate 4GB of memory during the hash join. +CREATE TABLE t1 ( +col_int_key INTEGER, +col_json JSON, +KEY mv_idx ((CAST(col_json->'$[*]' AS CHAR(40) ARRAY))) +); +INSERT INTO t1 VALUES (NULL, '[1]'), (4, '[1]'), (1, '[2]'); +CREATE TABLE t2(col_int INTEGER); +INSERT INTO t2 VALUES (1), (2), (3), (11), (12); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN FORMAT=tree SELECT t1.col_int_key AS field1, t2.col_int AS field2 FROM t2 +JOIN t1 ON 1 WHERE (CAST("1" AS JSON) MEMBER OF( t1.col_json->'$[*]')); +EXPLAIN +-> Inner hash join (no condition) (cost=*** rows=5) + -> Table scan on t2 (cost=*** rows=5) + -> Hash + -> Filter: json'"1"' member of (cast(json_extract(col_json,_utf8mb4'$[*]') as char(40) array)) (cost=*** rows=1) + -> Index lookup on t1 using mv_idx (cast(json_extract(col_json,_utf8mb4'$[*]') as char(40) array)=json'"1"') (cost=*** rows=1) + +SELECT t1.col_int_key AS field1, t2.col_int AS field2 FROM t2 +JOIN t1 ON 1 WHERE (CAST("1" AS JSON) MEMBER OF( t1.col_json->'$[*]')); +DROP TABLE t1,t2; +# +# Bug#29906372 WL#2241: SIG6 IN HASH_JOIN_BUFFER::STOREFROMTABLEBUFFERS +# AT HASH_JOIN_BUFFER.CC +# +CREATE TABLE a ( +pk INTEGER NOT NULL AUTO_INCREMENT, +col_varchar VARCHAR(1), +col_varchar_key VARCHAR(1), +PRIMARY KEY (pk), +KEY varchar_key (col_varchar_key) +); +CREATE TABLE b ( +pk INTEGER NOT NULL AUTO_INCREMENT, +col_varchar VARCHAR(1), +col_varchar_key VARCHAR(1), +PRIMARY KEY (pk), +KEY varchar_key (col_varchar_key) +); +INSERT INTO a VALUES (1, 'N', '0'); +INSERT INTO b VALUES (1, '8', 'r'), (2, 'v', 'C'), (3, 'b', 'p'), (4, '7', 'W'); +ANALYZE TABLE a, b; +Table Op Msg_type Msg_text +test.a analyze status OK +test.b analyze status OK +EXPLAIN FORMAT=tree SELECT 1 FROM (b AS table1 +INNER JOIN a AS table2 ON table2.pk = table1.pk OR table1.col_varchar < 'D') +WHERE (NOT EXISTS +(SELECT 1 FROM (b AS alias3 STRAIGHT_JOIN a AS alias4 +ON alias4.col_varchar = alias3.col_varchar_key) +WHERE alias3.pk >= table1.pk)); +EXPLAIN +-> Parallel scan on + -> Nested loop antijoin (cost=2.30 rows=8) + -> Filter: ((table1.pk = table2.pk) or (table1.col_varchar < 'D')) (cost=1.00 rows=2) + -> Inner hash join (no condition) (cost=1.00 rows=2) + -> Table scan on table1 (cost=0.45 rows=4) + -> Hash + -> PQblock scan on table2 using varchar_key (cost=0.35 rows=1) + -> Nested loop inner join (cost=2.85 rows=4) + -> Filter: (alias3.pk >= table1.pk) (cost=0.45 rows=4) + -> Index range scan on alias3 (re-planned for each iteration) (cost=0.45 rows=4) + -> Filter: (alias4.col_varchar = alias3.col_varchar_key) (cost=1.05 rows=1) + -> Table scan on alias4 (cost=1.05 rows=1) + +Warnings: +Note 1276 Field or reference 'test.table1.pk' of SELECT #2 was resolved in SELECT #1 +SELECT 1 FROM (b AS table1 +INNER JOIN a AS table2 ON table2.pk = table1.pk OR table1.col_varchar < 'D') +WHERE (NOT EXISTS +(SELECT 1 FROM (b AS alias3 STRAIGHT_JOIN a AS alias4 +ON alias4.col_varchar = alias3.col_varchar_key) +WHERE alias3.pk >= table1.pk)); +DROP TABLE a, b; +# +# Bug#29947439 WL#2241: FLOATING POINT EXCEPTION: INITIALIZECHUNKFILES AT +# HASH_JOIN_ITERATOR.CC +# +CREATE TABLE t1 (col1 TEXT); +INSERT INTO t1 VALUES (REPEAT('A', 50000)), (REPEAT('A', 50000)); +EXPLAIN FORMAT=tree SELECT a.col1 FROM t1 AS a, t1 AS b; +EXPLAIN +-> Inner hash join (no condition) (cost=*** rows=4) + -> Table scan on b (cost=*** rows=2) + -> Hash + -> Table scan on a (cost=*** rows=2) + +SET join_buffer_size = 128; +SELECT a.col1 FROM t1 AS a, t1 AS b; +DROP TABLE t1; +# Set up a case where we have very skewed data in the probe input, and we +# degrade into an on-disk hash join. We want to trigger a code path where +# we have empty chunk files from the probe input. +CREATE TABLE t1 (col1 VARCHAR(255)); +CREATE TABLE t2 (col1 VARCHAR(255)); +INSERT INTO t1 VALUES (SHA2(UUID(), 512)); +INSERT INTO t1 SELECT SHA2(UUID(), 512) FROM t1; +INSERT INTO t1 SELECT SHA2(UUID(), 512) FROM t1; +INSERT INTO t1 SELECT SHA2(UUID(), 512) FROM t1; +INSERT INTO t1 SELECT SHA2(UUID(), 512) FROM t1; +INSERT INTO t1 SELECT SHA2(UUID(), 512) FROM t1; +INSERT INTO t1 SELECT SHA2(UUID(), 512) FROM t1; +INSERT INTO t1 SELECT SHA2(UUID(), 512) FROM t1; +INSERT INTO t1 SELECT SHA2(UUID(), 512) FROM t1; +INSERT INTO t1 SELECT SHA2(UUID(), 512) FROM t1; +INSERT INTO t2 SELECT REPEAT("a", 255) FROM t1; +SET GLOBAL innodb_stats_persistent_sample_pages = 2000; +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +SET GLOBAL innodb_stats_persistent_sample_pages = DEFAULT; +EXPLAIN FORMAT=tree SELECT STRAIGHT_JOIN COUNT(*) FROM t1 JOIN t2 ON t1.col1 = t2.col1; +EXPLAIN +-> Aggregate: count(`COUNT(*)`) + -> Parallel scan on + -> Aggregate: + -> Filter: (t2.col1 = t1.col1) (cost=*** rows=26214) + -> Inner hash join ((t2.col1)=(t1.col1)) (cost=*** rows=26214) + -> Table scan on t2 (cost=*** rows=512) + -> Hash + -> PQblock scan on t1 (cost=*** rows=512) + +SET join_buffer_size = 1024; +SELECT STRAIGHT_JOIN COUNT(*) FROM t1 JOIN t2 ON t1.col1 = t2.col1; +DROP TABLE t1, t2; +SET join_buffer_size = DEFAULT; +# +# Bug#29964536 WL#2241: ASSERTION FAILURE IN +# TEMPTABLE::HANDLER::POSITION() AT SRC/HANDLER.CC +# +CREATE TABLE tc ( +col_int INTEGER, +col_varchar VARCHAR(1) +); +INSERT INTO tc VALUES (0,'x'); +CREATE TABLE tcc ( +col_varchar VARCHAR(1) +); +INSERT INTO tcc VALUES ('r'), ('f'), ('y'), ('u'), ('m'), (NULL); +CREATE TABLE t1 (field1 INTEGER); +INSERT INTO t1 VALUES (0); +SET optimizer_switch="firstmatch=off"; +UPDATE t1 SET field1 = 9999 WHERE field1 NOT IN ( SELECT alias1.col_int AS +field1 FROM ( tcc, ( SELECT * FROM tc WHERE col_int < 1 ) AS alias1 ) WHERE ( +alias1.col_varchar IN ( SELECT col_varchar FROM tcc ) ) GROUP BY field1 +HAVING field1 <> 1 ); +SET optimizer_switch="firstmatch=on"; +DROP TABLE tc,tcc,t1; +# Do a join between DECIMAL and INTEGER to verify that we get a match +# between these two types. +CREATE TABLE t1 (col1 DECIMAL(4, 2)); +INSERT INTO t1 VALUES (0); +CREATE TABLE t2 (col1 INTEGER); +INSERT INTO t2 VALUES (0); +EXPLAIN FORMAT=tree SELECT * FROM t1 JOIN t2 ON t1.col1 = t2.col1; +EXPLAIN +-> Parallel scan on + -> Inner hash join (t1.col1 = t2.col1) (cost=0.70 rows=1) + -> Table scan on t2 (cost=0.35 rows=1) + -> Hash + -> PQblock scan on t1 (cost=0.35 rows=1) + +SELECT * FROM t1 JOIN t2 ON t1.col1 = t2.col1; +col1 col1 +0.00 0 +DROP TABLE t1, t2; +# See that we get the correct results with a PAD SPACE collation and +# PAD_CHAR_TO_FULL_LENGTH. Note that the latter is deprecated, so this +# test should go away once the SQL mode is removed. +CREATE TABLE t1 ( +col1 CHAR(4) +) DEFAULT CHARSET=latin1 COLLATE=latin1_general_cs; +INSERT INTO t1 VALUES ("foo"); +CREATE TABLE t2 ( +col1 CHAR(40) +) DEFAULT CHARSET=latin1 COLLATE=latin1_general_cs; +INSERT INTO t2 VALUES ("foo"); +SET sql_mode="PAD_CHAR_TO_FULL_LENGTH"; +Warnings: +Warning 3090 Changing sql mode 'PAD_CHAR_TO_FULL_LENGTH' is deprecated. It will be removed in a future release. +EXPLAIN FORMAT=tree SELECT * FROM t1 JOIN t2 ON t1.col1 = t2.col1; +EXPLAIN +-> Parallel scan on + -> Inner hash join (t1.col1 = t2.col1) (cost=0.70 rows=1) + -> Table scan on t2 (cost=0.35 rows=1) + -> Hash + -> PQblock scan on t1 (cost=0.35 rows=1) + +SELECT * FROM t1 JOIN t2 ON t1.col1 = t2.col1; +col1 col1 +foo foo +SET sql_mode=DEFAULT; +DROP TABLE t1, t2; +# Set up a case where the join planner will set up a BNL with linked +# join buffers, and where the row ID should be kept due to duplicate +# removal. rowid_status will be set on several QEP_TABs to indicate that +# a row ID is needed, even though we should not request the row ID on all +# of them. +CREATE TABLE b1 (col_int INTEGER); +INSERT INTO b1 VALUES (1); +CREATE TABLE c1 ( +col_int INTEGER, +col_timestamp TIMESTAMP NULL, +col_decimal DECIMAL(10, 4) +); +INSERT INTO c1 VALUES +(1741569678,'2004-01-07 20:47:51',-4.7563), +(-1533615975,'2037-10-27 16:40:24',7.7785); +CREATE TABLE cc1 ( +col_int INTEGER, +col_decimal DECIMAL(10, 4), +col_timestamp TIMESTAMP NULL +); +INSERT INTO cc1 VALUES +(-190646953,6.4052,'2007-11-21 09:45:29'), +(-423321712,6.9636,'1988-01-04 13:34:47'); +SELECT +1 +FROM +b1 +LEFT JOIN ( +c1 +RIGHT JOIN (SELECT DISTINCT * FROM cc1) AS alias3 ON +alias3.col_timestamp = c1.col_timestamp +) ON b1.col_int = c1.col_int AND 1 +WHERE +EXISTS( +SELECT +1 +FROM +cc1 JOIN c1 ON c1.col_decimal = cc1.col_decimal AND 1 +WHERE +cc1.col_int <= b1.col_int OR cc1.col_int = c1.col_int +); +1 +DROP TABLE b1, c1, cc1; +# Yet another problematic case involing duplicate weedout. +CREATE TABLE t1 ( +col_int_key int(11) DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (4,'v','v'); +INSERT INTO t1 VALUES (62,'v','v'); +INSERT INTO t1 VALUES (7,'c','c'); +INSERT INTO t1 VALUES (1,NULL,NULL); +set optimizer_switch='firstmatch=off'; +set optimizer_switch='materialization=off'; +SELECT +alias1.col_varchar_nokey AS a1_nokey, +alias1.col_varchar_key AS a1_key, +alias2.col_varchar_nokey AS a2_nokey +FROM +t1 AS alias1, t1 AS alias2 +WHERE +(alias1.col_varchar_nokey,alias2.col_varchar_nokey) +IN +( +SELECT +sq2_alias2.col_varchar_nokey, sq2_alias1.col_varchar_key +FROM +t1 AS sq2_alias1, t1 AS sq2_alias2 +) +; +a1_nokey a1_key a2_nokey +c c c +c c v +c c v +v v c +v v c +v v v +v v v +v v v +v v v +set optimizer_switch=DEFAULT; +DROP TABLE t1; +# A case where we have a hash join iterator both above and below a +# WeedoutIterator. +CREATE TABLE t1(f1 INT(11) NOT NULL); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (10); +CREATE TABLE t2 +( +f1 INT(11) NOT NULL AUTO_INCREMENT, +f2 INT(11) DEFAULT NULL, +PRIMARY KEY (f1), +KEY (f2) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (1, 7), (2, 1), (4, 7); +CREATE TABLE t4(f1 INT DEFAULT NULL); +INSERT INTO t4 VALUES (2); +ANALYZE TABLE t1, t2, t4; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t4 analyze status OK +EXPLAIN FORMAT=tree SELECT /*+ JOIN_PREFIX(t2@qb2, t4@qb1, ta3, ta4) */ +COUNT(*) FROM t1 JOIN t2 AS ta3 JOIN t2 AS ta4 +WHERE ta4.f1 IN (SELECT /*+ QB_NAME(qb1) */ f1 FROM t4) AND +ta3.f2 IN (SELECT /*+ QB_NAME(qb2) */ f2 FROM t2); +EXPLAIN +-> Aggregate: count(0) + -> Inner hash join (no condition) (cost=3.70 rows=4) + -> Table scan on t1 (cost=0.08 rows=1) + -> Hash + -> Remove duplicate (ta3, ta4) rows using temporary table (weedout) (cost=3.00 rows=4) + -> Nested loop inner join (cost=3.00 rows=4) + -> Nested loop inner join (cost=2.30 rows=4) + -> Inner hash join (no condition) (cost=1.10 rows=3) + -> Filter: (t4.f1 is not null) (cost=0.12 rows=1) + -> Table scan on t4 (cost=0.12 rows=1) + -> Hash + -> Filter: (t2.f2 is not null) (cost=0.55 rows=3) + -> Index scan on t2 using f2 (cost=0.55 rows=3) + -> Index lookup on ta3 using f2 (f2=t2.f2) (cost=0.30 rows=2) + -> Single-row index lookup on ta4 using PRIMARY (f1=t4.f1) (cost=0.08 rows=1) + +SELECT /*+ JOIN_PREFIX(t2@qb2, t4@qb1, ta3, ta4) */ +COUNT(*) FROM t1 JOIN t2 AS ta3 JOIN t2 AS ta4 +WHERE ta4.f1 IN (SELECT /*+ QB_NAME(qb1) */ f1 FROM t4) AND +ta3.f2 IN (SELECT /*+ QB_NAME(qb2) */ f2 FROM t2); +COUNT(*) +3 +SELECT /*+ JOIN_PREFIX(t2@qb2, t4@qb1, ta3, ta4) */ +COUNT(*) FROM t1 JOIN t2 AS ta3 JOIN t2 AS ta4 +WHERE ta4.f1 IN (SELECT /*+ QB_NAME(qb1) */ f1 FROM t4) AND +ta3.f2 IN (SELECT /*+ QB_NAME(qb2) */ f2 FROM t2); +COUNT(*) +3 +DROP TABLE t1, t2, t4; +# +# Bug#30035890 SIG 11 IN HASHJOINITERATOR::READJOINEDROW AT +# SQL/HASH_JOIN_ITERATOR.CC +# +# Note that this test case needs ASAN to reproduce. +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (7), (7); +CREATE TABLE t2 (b INT, c DATETIME); +INSERT IGNORE INTO t2 VALUES (7, NULL), (7, '2006'), (7, '2002'); +Warnings: +Warning 1265 Data truncated for column 'c' at row 2 +Warning 1265 Data truncated for column 'c' at row 3 +# Set up a case where the hash join row buffer will be re-inited. +UPDATE t1 +SET a = 42 +WHERE a NOT IN ( +SELECT alias2.b FROM t2 AS alias2 JOIN t2 AS alias1 ON (alias2.c = alias1.c) +); +DROP TABLE t1, t2; +# +# Bug#30060691 ASSERTION `M_INDEX_CURSOR.IS_POSITIONED()' IN +# TEMPTABLE::HANDLER::POSITION() +# +CREATE TABLE c ( +col_int INTEGER, +col_varchar VARCHAR(1) , +col_varchar_key VARCHAR(1)); +CREATE TABLE bb ( +pk INTEGER auto_increment, +col_int_key INTEGER, +col_varchar VARCHAR(1), +col_varchar_key VARCHAR(1), +PRIMARY KEY (pk)); +CREATE TABLE cc ( +col_varchar_key VARCHAR(1), +INDEX idx (col_varchar_key)); +INSERT INTO bb VALUES (DEFAULT, 41509313, 'S', 'W'); +INSERT INTO c VALUES +(-792274908, 'P', 'r'), +(281391051, 'w', 'x'), +(-1381986093, 'l', '2'), +(-78303180, 'f', 'Q'), +(1027797776, 'w', 'G'), +(-1361294690, 'm', 'L'), +(65604698, '7', 'Y'), +(-964881813, 'j', 'F'), +(1831120981, 'q', 'q'), +(-573388832, 'F', 'M'), +(571640392, '1', 'R'), +(857813414, 'y', 'l'), +(555892383, 'x', 'P'), +(601556555, 'z', 'k'), +(-578249624, 'N', 'e'), +(-843749952, '4', 'J'), +(2058477272, '4', 'R'), +(-1732353317, 'C', 'Z'), +(-1639317818, '9', 'f'), +(19700948, 'K', 'V'); +INSERT INTO cc VALUES +('b'), ('E'), ('v'), ('4'), ('L'), ('g'), ('i'), ('D'), ('S'), ('s'), ('4'), +('5'), ('4'), ('y'), ('v'), ('Z'), ('O'), ('2'), ('v'), ('5'); +ANALYZE TABLE c, bb, cc; +Table Op Msg_type Msg_text +test.c analyze status OK +test.bb analyze status OK +test.cc analyze status OK +EXPLAIN FORMAT=tree SELECT * +FROM +cc AS alias1 +LEFT JOIN ( +( +bb AS alias2 +INNER JOIN (SELECT DISTINCT sq1_alias1.* FROM bb AS sq1_alias1) +AS alias3 ON alias3.col_int_key = alias2.col_int_key +) +) ON alias3.col_varchar_key = alias2.col_varchar_key +WHERE +alias1.col_varchar_key +IN ( +SELECT +sq2_alias1.col_varchar AS sq2_field1 +FROM +c AS sq2_alias1 +WHERE +sq2_alias1.col_varchar_key != alias2.col_varchar +AND sq2_alias1.col_int > alias2.pk +); +EXPLAIN +-> Remove duplicate (alias2, alias3, alias1) rows using temporary table (weedout) (cost=5.06 rows=3) + -> Nested loop inner join (cost=5.06 rows=3) + -> Filter: ((sq2_alias1.col_varchar_key <> alias2.col_varchar) and (sq2_alias1.col_int > alias2.pk)) (cost=1.80 rows=2) + -> Inner hash join (no condition) (cost=1.80 rows=2) + -> Filter: (sq2_alias1.col_varchar is not null) (cost=0.43 rows=6) + -> Table scan on sq2_alias1 (cost=0.43 rows=20) + -> Hash + -> Nested loop inner join (cost=0.95 rows=1) + -> Table scan on alias2 (cost=0.35 rows=1) + -> Index lookup on alias3 using (col_int_key=alias2.col_int_key, col_varchar_key=alias2.col_varchar_key) + -> Materialize (cost=0.45..0.45 rows=1) + -> Table scan on sq1_alias1 (cost=0.35 rows=1) + -> Index lookup on alias1 using idx (col_varchar_key=sq2_alias1.col_varchar) (cost=0.26 rows=1) + +Warnings: +Note 1276 Field or reference 'test.alias2.col_varchar' of SELECT #3 was resolved in SELECT #1 +Note 1276 Field or reference 'test.alias2.pk' of SELECT #3 was resolved in SELECT #1 +# We only want to see that the query does not hit an assertion, so ignore +# the results. +SELECT * +FROM +cc AS alias1 +LEFT JOIN ( +( +bb AS alias2 +INNER JOIN (SELECT DISTINCT sq1_alias1.* FROM bb AS sq1_alias1) +AS alias3 ON alias3.col_int_key = alias2.col_int_key +) +) ON alias3.col_varchar_key = alias2.col_varchar_key +WHERE +alias1.col_varchar_key +IN ( +SELECT +sq2_alias1.col_varchar AS sq2_field1 +FROM +c AS sq2_alias1 +WHERE +sq2_alias1.col_varchar_key != alias2.col_varchar +AND sq2_alias1.col_int > alias2.pk +); +DROP TABLE bb, c, cc; +# +# Bug#30049217 ASSERTION FAILURE AT +# TEMPTABLE::HANDLER::POSITION|SRC/HANDLER.CC +# +CREATE TABLE t1 (c1 INT); +INSERT INTO t1 VALUES +(6),(7),(8),(9),(10),(11),(12),(13),(14),(15),(16),(17),(18),(19),(20); +CREATE TABLE t2 (c2 INT, c3 INT, KEY (c3)); +INSERT INTO t2 VALUES +(1,-823867270), +(19,1130654803), +(20,1299270309); +CREATE TABLE t3 (c4 INT); +INSERT INTO t3 VALUES (1); +ANALYZE TABLE t1, t2, t3; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +SELECT * +FROM ((SELECT DISTINCT * FROM t2) AS alias2 JOIN t3 ON (t3.c4 = alias2.c2)) +WHERE (EXISTS (SELECT * FROM (t1 LEFT JOIN (t3 JOIN t2 ON (t2.c3 = t3.c4)) ON +(1)))) +AND alias2.c3 < 19; +c2 c3 c4 +1 -823867270 1 +DROP TABLE t1, t2, t3; +# +# Bug#30153695 ASSERTION SIG6 TEMPTABLE::HANDLER::POSITION +# SRC/HANDLER.CC:715 +# +CREATE TABLE c ( +col_date date, +col_datetime_key datetime, +col_varchar_key varchar (1), +col_varchar varchar (1), +col_date_key date, +col_int_key int, +col_time time, +col_time_key time, +col_int int, +pk integer auto_increment, +col_datetime datetime, +key (col_datetime_key ), +key (col_varchar_key ), +key (col_date_key ), +key (col_int_key ), +key (col_time_key ), +primary key (pk)) ENGINE=innodb; +INSERT IGNORE INTO c VALUES +('2001-07-23', '2004-12-11', 'k', 's', NULL, 7, '2004-11-12', '2000-03-18', 3, +NULL, NULL), +(NULL, NULL, 's', 'j', NULL, 6, NULL, '2005', 1, NULL, NULL), +('2006-07-02', NULL, 'w', 'y', NULL, 2, '04:35:59.017853', '2002', 7, NULL, +'2004-09-04 21:23:05.023144'), +(NULL, '2009-02-16 21:37:23.010045', 'w', 'o', '2005-05-25', NULL, NULL, +'04:32:06.000870', 9, NULL, '2004'), +(NULL, NULL, 'y', 'k', '2002-12-15', 81, NULL, '2009-03-14', 3, NULL, NULL), +(NULL, '2005', 'x', 's', '2004-07-12', 9, NULL, NULL, 7, NULL, '2009'), +('2003', '2000-11-08', 'd', 'h', '2002-09-25', 8, NULL, '2002', NULL, NULL, +'2004'), +('2000', '2008-01-08 20:49:13.011386', 't', 'w', '2000-12-11', 6, +'18:31:35.007025', '19:28:20.040544', 4, NULL, '2005-03-13'), +('2006-10-04', '2000-12-16', 'i', 'f', NULL, 3, '2008', NULL, 5, NULL, +'2003-12-03 13:55:06.040156'), +('2009-07-26', '2009-11-22 07:59:12.037926', 'o', 'n', '2004-07-23', 4, +'2005', '12:00:51.020344', 5, NULL, '2006'), +('2009-02-25', NULL, 'm', NULL, '2003', NULL, '2000', '2002-07-28', 1, NULL, +'2004-06-26'), +('2008-01-11', '2001-05-27', 'c', 'w', '2001-11-21', 4, '2004-07-23', +'2005-07-19', 3, NULL, '2001'), +('2009', NULL, 'x', NULL, NULL, 6, '2006-10-03', NULL, 1, NULL, '2009-12-03'), +('2008-09-22', '2008-08-09 11:16:52.037869', 'r', 'c', '2008-01-23', 3, NULL, +NULL, 6, NULL, '2008'), +('2007-01-21', NULL, 'u', 'u', '2008', 5, '2003-07-15', '07:04:43.054922', +NULL, NULL, NULL), +('2009-06-15', '2004-01-25', 'x', NULL, NULL, 189, '2008', '2000-06-14', 1, +NULL, NULL), +('2005', '2008-03-22', NULL, 'g', '2008', 1, '20:53:08.022885', '2006', 3, +NULL, '2009-04-06 15:24:52.051014'), +('2002', '2003-07-10 12:29:23.023649', 'g', 'u', '2000-10-16', 9, '2003', +'2006', 9, NULL, NULL), +('2005-10-23', NULL, 's', 'x', '2005', 9, '2008-07-09', '2001-08-12', 8, NULL, +NULL), +('2005', NULL, 'g', 'm', '2000-01-03', 9, '2008', NULL, 1, NULL, +'2001-01-21'); +Warnings: +Warning 1265 Data truncated for column 'col_time' at row 1 +Warning 1265 Data truncated for column 'col_time_key' at row 1 +Warning 1265 Data truncated for column 'col_datetime' at row 4 +Warning 1265 Data truncated for column 'col_time_key' at row 5 +Warning 1265 Data truncated for column 'col_datetime_key' at row 6 +Warning 1265 Data truncated for column 'col_datetime' at row 6 +Warning 1265 Data truncated for column 'col_date' at row 7 +Warning 1265 Data truncated for column 'col_datetime' at row 7 +Warning 1265 Data truncated for column 'col_date' at row 8 +Warning 1265 Data truncated for column 'col_datetime' at row 10 +Warning 1265 Data truncated for column 'col_date_key' at row 11 +Warning 1265 Data truncated for column 'col_time_key' at row 11 +Warning 1265 Data truncated for column 'col_time' at row 12 +Warning 1265 Data truncated for column 'col_time_key' at row 12 +Warning 1265 Data truncated for column 'col_datetime' at row 12 +Warning 1265 Data truncated for column 'col_date' at row 13 +Warning 1265 Data truncated for column 'col_time' at row 13 +Warning 1265 Data truncated for column 'col_datetime' at row 14 +Warning 1265 Data truncated for column 'col_date_key' at row 15 +Warning 1265 Data truncated for column 'col_time' at row 15 +Warning 1265 Data truncated for column 'col_time_key' at row 16 +Warning 1265 Data truncated for column 'col_date' at row 17 +Warning 1265 Data truncated for column 'col_date_key' at row 17 +Warning 1265 Data truncated for column 'col_date' at row 18 +Warning 1265 Data truncated for column 'col_date_key' at row 19 +Warning 1265 Data truncated for column 'col_time' at row 19 +Warning 1265 Data truncated for column 'col_time_key' at row 19 +Warning 1265 Data truncated for column 'col_date' at row 20 +CREATE TABLE cc ( +col_date date, +col_int int, +col_int_key int, +col_varchar_key varchar (1), +col_datetime_key datetime, +col_datetime datetime, +pk integer auto_increment, +col_varchar varchar (1), +col_time_key time, +col_time time, +col_date_key date, +key (col_int_key ), +key (col_varchar_key ), +key (col_datetime_key ), +primary key (pk), +key (col_time_key ), +key (col_date_key )) ENGINE=innodb; +ALTER TABLE cc DISABLE KEYS; +Warnings: +Note 1031 Table storage engine for 'cc' doesn't have this option +INSERT IGNORE INTO cc VALUES +('2006-06-04', 3, 0, 'y', '2006-04-12 00:44:48.055959', NULL, NULL, 'l', +'2005-01-10', '2004', '2004-07-14'), +('2008', 6, 8, NULL, '2006-10-23', NULL, NULL, 'a', NULL, NULL, '2000-04-26'), +('2009-06-11', NULL, 9, 'w', '2008', '2005', NULL, 'q', '04:42:05.061538', +'2004-08-18', NULL), +('2007-03-01', 4, 7, 'f', NULL, '2000-10-06 15:26:40.040137', NULL, 'd', +'2008', '2006-11-17', '2006'), +('2001-02-08', 4, 210, 'j', '2003-11-14 04:26:34.047333', NULL, NULL, 'h', +'06:13:13.012974', '02:20:21.050151', '2006-08-20'), +('2000', 9, 5, 'b', '2006-12-16', NULL, NULL, 'z', '2000-09-09', '2007-06-15', +'2008'), +(NULL, 1, 6, 'z', '2007-12-10 00:57:04.007939', NULL, NULL, 'i', '2002-02-11', +'2004', '2006-08-08'), +('2007', NULL, 1, 'w', '2007-09-03 21:11:14.028959', '2009', NULL, 'n', +'2009-05-03', '2005-06-23', NULL), +(NULL, 4, NULL, 'f', '2007-04-12', NULL, NULL, 'f', '2007-12-01', '2006', +'2000-05-11'), +('2008', 7, 1, 's', NULL, NULL, NULL, 'o', '2002', '2003', '2009-12-03'), +(NULL, 5, 62, 'i', '2009-10-06 12:22:10.055548', '2003', NULL, 'p', NULL, +NULL, '2006-02-03'), +('2006-02-10', 4, 9, 'g', NULL, '2000-07-26 23:20:24.031805', NULL, 'c', +'2007-12-12', '2002', '2003'), +('2000', 5, 0, 'j', '2000-02-23', '2000', NULL, 'a', '2005', '2000-04-15', +'2000-09-19'), +(NULL, 2, 9, 'q', '2003-12-24', NULL, NULL, NULL, NULL, '2000', '2008-05-23'), +(NULL, 9, NULL, 'i', '2003-10-22 02:03:47.003490', '2006-01-03', NULL, 'b', +NULL, '2003', '2008-01-21'), +('2008-06-09', 9, 0, 'a', '2000', NULL, NULL, 'c', '21:15:46.049912', '2001', +NULL), +('2000', 2, 8, NULL, '2009-11-27', NULL, NULL, NULL, '2004-05-08', +'12:30:30.041709', '2005-12-01'), +('2009-03-27', 3, 0, 'l', '2009', '2009', NULL, 'a', NULL, '04:16:53.049190', +NULL), +('2008-08-26', 114, 3, 'o', '2008-03-06', NULL, NULL, 'k', '07:26:47.018798', +'2002-08-17', '2004-09-07'), +(NULL, 8, 7, 'm', '2007-12-28 23:49:04.022501', '2005-04-08', NULL, 't', +'2000-11-12', '22:19:29.060590', '2005-09-20'); +Warnings: +Warning 1265 Data truncated for column 'col_time_key' at row 1 +Warning 1265 Data truncated for column 'col_date' at row 2 +Warning 1265 Data truncated for column 'col_datetime_key' at row 3 +Warning 1265 Data truncated for column 'col_datetime' at row 3 +Warning 1265 Data truncated for column 'col_time' at row 3 +Warning 1265 Data truncated for column 'col_time' at row 4 +Warning 1265 Data truncated for column 'col_date_key' at row 4 +Warning 1265 Data truncated for column 'col_date' at row 6 +Warning 1265 Data truncated for column 'col_time_key' at row 6 +Warning 1265 Data truncated for column 'col_time' at row 6 +Warning 1265 Data truncated for column 'col_date_key' at row 6 +Warning 1265 Data truncated for column 'col_time_key' at row 7 +Warning 1265 Data truncated for column 'col_date' at row 8 +Warning 1265 Data truncated for column 'col_datetime' at row 8 +Warning 1265 Data truncated for column 'col_time_key' at row 8 +Warning 1265 Data truncated for column 'col_time' at row 8 +Warning 1265 Data truncated for column 'col_time_key' at row 9 +Warning 1265 Data truncated for column 'col_date' at row 10 +Warning 1265 Data truncated for column 'col_datetime' at row 11 +Warning 1265 Data truncated for column 'col_time_key' at row 12 +Warning 1265 Data truncated for column 'col_date_key' at row 12 +Warning 1265 Data truncated for column 'col_date' at row 13 +Warning 1265 Data truncated for column 'col_datetime' at row 13 +Warning 1265 Data truncated for column 'col_time' at row 13 +Warning 1265 Data truncated for column 'col_datetime_key' at row 16 +Warning 1265 Data truncated for column 'col_date' at row 17 +Warning 1265 Data truncated for column 'col_time_key' at row 17 +Warning 1265 Data truncated for column 'col_datetime_key' at row 18 +Warning 1265 Data truncated for column 'col_datetime' at row 18 +Warning 1265 Data truncated for column 'col_time' at row 19 +Warning 1265 Data truncated for column 'col_time_key' at row 20 +ALTER TABLE cc ENABLE KEYS; +Warnings: +Note 1031 Table storage engine for 'cc' doesn't have this option +ANALYZE TABLE c, cc; +Table Op Msg_type Msg_text +test.c analyze status OK +test.cc analyze status OK +EXPLAIN FORMAT=tree SELECT +alias1.pk AS field1 +FROM +( +SELECT +sq1_alias2.* +FROM +cc AS sq1_alias1 +RIGHT JOIN cc AS sq1_alias2 ON +sq1_alias2.col_varchar_key = sq1_alias1.col_varchar_key +LIMIT +100 +) +AS alias1 +WHERE +alias1.col_varchar_key +IN ( +SELECT +sq2_alias1.col_varchar_key AS sq2_field1 +FROM +(cc AS sq2_alias1, c AS sq2_alias2) +WHERE +sq2_alias1.col_varchar_key != alias1.col_varchar +) +GROUP BY +field1 +HAVING +field1 != 'pg' +ORDER BY +alias1.col_int_key DESC, field1 +LIMIT 2 OFFSET 2; +EXPLAIN +-> Limit/Offset: 2/2 row(s) + -> Sort: alias1.col_int_key DESC, alias1.pk + -> Filter: (field1 <> 0) + -> Table scan on (cost=0.02..14.19 rows=936) + -> Temporary table with deduplication (cost=207.92..222.09 rows=936) + -> Remove duplicate alias1 rows using temporary table (weedout) (cost=114.30 rows=936) + -> Inner hash join (no condition) (cost=114.30 rows=936) + -> Index scan on sq2_alias2 using col_date_key (cost=1.93 rows=20) + -> Hash + -> Nested loop inner join (cost=20.45 rows=47) + -> Filter: (sq2_alias1.col_varchar_key is not null) (cost=2.25 rows=20) + -> Index scan on sq2_alias1 using col_varchar_key (cost=2.25 rows=20) + -> Filter: (sq2_alias1.col_varchar_key <> alias1.col_varchar) (cost=7.49..0.66 rows=2) + -> Index lookup on alias1 using (col_varchar_key=sq2_alias1.col_varchar_key) + -> Materialize (cost=12.59..12.59 rows=27) + -> Limit: 100 row(s) (cost=9.92 rows=27) + -> Nested loop left join (cost=9.92 rows=27) + -> Table scan on sq1_alias2 (cost=2.25 rows=20) + -> Index lookup on sq1_alias1 using col_varchar_key (col_varchar_key=sq1_alias2.col_varchar_key) (cost=0.26 rows=1) + +Warnings: +Note 1276 Field or reference 'alias1.col_varchar' of SELECT #3 was resolved in SELECT #1 +Warning 1292 Truncated incorrect DOUBLE value: 'pg' +SELECT +alias1.pk AS field1 +FROM +( +SELECT +sq1_alias2.* +FROM +cc AS sq1_alias1 +RIGHT JOIN cc AS sq1_alias2 ON +sq1_alias2.col_varchar_key = sq1_alias1.col_varchar_key +LIMIT +100 +) +AS alias1 +WHERE +alias1.col_varchar_key +IN ( +SELECT +sq2_alias1.col_varchar_key AS sq2_field1 +FROM +(cc AS sq2_alias1, c AS sq2_alias2) +WHERE +sq2_alias1.col_varchar_key != alias1.col_varchar +) +GROUP BY +field1 +HAVING +field1 != 'pg' +ORDER BY +alias1.col_int_key DESC, field1 +LIMIT 2 OFFSET 2; +field1 +3 +12 +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'pg' +Warning 1292 Incorrect date value: '0000-00-00' for column 'col_date' at row 1 +Warning 1292 Incorrect datetime value: '0000-00-00 00:00:00' for column 'col_datetime_key' at row 1 +Warning 1292 Incorrect datetime value: '0000-00-00 00:00:00' for column 'col_datetime' at row 1 +Warning 1292 Incorrect datetime value: '0000-00-00 00:00:00' for column 'col_datetime_key' at row 1 +Warning 1292 Incorrect datetime value: '0000-00-00 00:00:00' for column 'col_datetime' at row 1 +Warning 1292 Incorrect date value: '0000-00-00' for column 'col_date_key' at row 1 +Warning 1292 Incorrect date value: '0000-00-00' for column 'col_date_key' at row 1 +Warning 1292 Incorrect date value: '0000-00-00' for column 'col_date' at row 1 +Warning 1292 Incorrect date value: '0000-00-00' for column 'col_date_key' at row 1 +Warning 1292 Incorrect date value: '0000-00-00' for column 'col_date' at row 1 +Warning 1292 Incorrect datetime value: '0000-00-00 00:00:00' for column 'col_datetime' at row 1 +Warning 1292 Incorrect date value: '0000-00-00' for column 'col_date' at row 1 +Warning 1292 Incorrect datetime value: '0000-00-00 00:00:00' for column 'col_datetime' at row 1 +Warning 1292 Incorrect date value: '0000-00-00' for column 'col_date' at row 1 +Warning 1292 Incorrect datetime value: '0000-00-00 00:00:00' for column 'col_datetime' at row 1 +Warning 1292 Incorrect datetime value: '0000-00-00 00:00:00' for column 'col_datetime' at row 1 +Warning 1292 Incorrect date value: '0000-00-00' for column 'col_date_key' at row 1 +Warning 1292 Incorrect date value: '0000-00-00' for column 'col_date' at row 1 +Warning 1292 Incorrect datetime value: '0000-00-00 00:00:00' for column 'col_datetime' at row 1 +Warning 1292 Incorrect date value: '0000-00-00' for column 'col_date' at row 1 +Warning 1292 Incorrect datetime value: '0000-00-00 00:00:00' for column 'col_datetime' at row 1 +Warning 1292 Incorrect datetime value: '0000-00-00 00:00:00' for column 'col_datetime_key' at row 1 +Warning 1292 Incorrect date value: '0000-00-00' for column 'col_date' at row 1 +Warning 1292 Incorrect datetime value: '0000-00-00 00:00:00' for column 'col_datetime_key' at row 1 +Warning 1292 Incorrect datetime value: '0000-00-00 00:00:00' for column 'col_datetime' at row 1 +DROP TABLE c, cc; +# +# Bug#30119783 SIG11 IN +# HASH_JOIN_BUFFER::STOREFROMTABLEBUFFERS|SQL/HASH_JOIN_BUFFER.CC +# +CREATE TABLE b(pk INT PRIMARY KEY, col_varchar VARCHAR(1)); +CREATE TABLE cc(pk INT PRIMARY KEY, col_varchar VARCHAR(1)); +INSERT INTO b VALUES (1, '4'); +INSERT INTO cc VALUES (1, 'c'), (2, 'c'); +EXPLAIN FORMAT=tree SELECT +table1.col_varchar +FROM +( +SELECT +subquery1_t1.* +FROM +b AS subquery1_t1 +INNER JOIN cc AS subquery1_t2 ON +subquery1_t1.col_varchar = subquery1_t2.col_varchar +) +AS table1 +LEFT JOIN ( +SELECT +col_varchar +FROM +cc AS subquery2_t1 +GROUP BY +subquery2_t1.col_varchar +) +AS table2 ON +table2.col_varchar = table1.col_varchar +AND table1.col_varchar +IN ( +SELECT +lower(subquery3_t1.pk) AS subquery3_field1 +FROM +b AS subquery3_t1 +); +EXPLAIN +-> Nested loop left join (cost=1.50 rows=2) + -> Inner hash join (subquery1_t2.col_varchar = subquery1_t1.col_varchar) (cost=0.80 rows=1) + -> Table scan on subquery1_t2 (cost=0.35 rows=2) + -> Hash + -> Table scan on subquery1_t1 (cost=0.35 rows=1) + -> Nested loop semijoin (cost=3.83 rows=2) + -> Index lookup on table2 using (col_varchar=subquery1_t1.col_varchar) + -> Materialize (cost=3.38..3.38 rows=2) + -> Table scan on (cost=1.26..2.52 rows=2) + -> Temporary table with deduplication (cost=1.91..3.17 rows=2) + -> Table scan on subquery2_t1 (cost=0.45 rows=2) + -> Filter: (subquery1_t1.col_varchar = lower(subquery3_t1.pk)) (cost=0.18 rows=1) + -> Index scan on subquery3_t1 using PRIMARY (cost=0.18 rows=1) + +SELECT +table1.col_varchar +FROM +( +SELECT +subquery1_t1.* +FROM +b AS subquery1_t1 +INNER JOIN cc AS subquery1_t2 ON +subquery1_t1.col_varchar = subquery1_t2.col_varchar +) +AS table1 +LEFT JOIN ( +SELECT +col_varchar +FROM +cc AS subquery2_t1 +GROUP BY +subquery2_t1.col_varchar +) +AS table2 ON +table2.col_varchar = table1.col_varchar +AND table1.col_varchar +IN ( +SELECT +lower(subquery3_t1.pk) AS subquery3_field1 +FROM +b AS subquery3_t1 +); +col_varchar +DROP TABLE b, cc; +# +# Bug#30049083 [REGRESSION]REPLACE/INSERT WITH LIMIT TAKING MORE TIME AND +# SPACE +# +# If the query has a LIMIT, the hash join should not spill to disk. Note +# that if the query contains either grouping or sorting, we allow spill +# to disk even if the query contains a LIMIT. +CREATE TABLE t1 (col1 BIGINT); +INSERT INTO t1 SELECT 1; +INSERT INTO t1 SELECT col1 + 1 FROM t1; +INSERT INTO t1 SELECT col1 + 2 FROM t1; +INSERT INTO t1 SELECT col1 + 4 FROM t1; +INSERT INTO t1 SELECT col1 + 8 FROM t1; +INSERT INTO t1 SELECT col1 + 16 FROM t1; +INSERT INTO t1 SELECT col1 + 32 FROM t1; +INSERT INTO t1 SELECT col1 + 64 FROM t1; +INSERT INTO t1 SELECT col1 + 128 FROM t1; +INSERT INTO t1 SELECT col1 + 256 FROM t1; +INSERT INTO t1 SELECT col1 + 512 FROM t1; +CREATE TABLE t2 SELECT col1 FROM t1; +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +SET join_buffer_size = 2048; +# This should spill to disk since we do not have any LIMIT. +TRUNCATE performance_schema.file_summary_by_event_name; +SELECT * FROM t1, t2 WHERE t1.col1 = t2.col1; +SELECT COUNT_STAR > 0 FROM performance_schema.file_summary_by_event_name +WHERE event_name LIKE '%hash_join%'; +COUNT_STAR > 0 +1 +# This should NOT spill to disk since we have a LIMIT. +TRUNCATE performance_schema.file_summary_by_event_name; +SELECT * FROM t1, t2 WHERE t1.col1 = t2.col1 LIMIT 1; +SELECT COUNT_STAR > 0 FROM performance_schema.file_summary_by_event_name +WHERE event_name LIKE '%hash_join%'; +COUNT_STAR > 0 +0 +# This should spill to disk since we have sorting. +TRUNCATE performance_schema.file_summary_by_event_name; +SELECT * FROM t1, t2 WHERE t1.col1 = t2.col1 ORDER BY t1.col1 LIMIT 1; +col1 col1 +1 1 +SELECT COUNT_STAR > 0 FROM performance_schema.file_summary_by_event_name +WHERE event_name LIKE '%hash_join%'; +COUNT_STAR > 0 +1 +# This should spill to disk since we have (implicit) grouping. +TRUNCATE performance_schema.file_summary_by_event_name; +SELECT SUM(t1.col1) FROM t1, t2 WHERE t1.col1 = t2.col1 LIMIT 10; +SUM(t1.col1) +524800 +SELECT COUNT_STAR > 0 FROM performance_schema.file_summary_by_event_name +WHERE event_name LIKE '%hash_join%'; +COUNT_STAR > 0 +1 +SET join_buffer_size = DEFAULT; +DROP TABLE t1,t2; +# +# Bug#30214767 SIG11 AT QUICK_INDEX_MERGE_SELECT::GET_NEXT | +# SQL/OPT_RANGE.CC +# +# Set up a query with hash join, where the build input uses an index +# range scan with index merge sort-union. Also, a LIMIT greater than +# the number of rows satisfying the join condition is needed to +# reproduce the bug. What we want to achieve is to get the hash join +# to call Read() on the build input after it has returned EOF. This can +# be triggered by using LIMIT, as this causes the hash join to go back +# and read from the build input after the probe iterator has returned +# EOF (see comment on HashJoinIterator regarding spill to disk and LIMIT +# for more details around this). +CREATE TABLE t1 (col1 INTEGER); +CREATE TABLE t2 ( +col1 INTEGER, +col2 INTEGER, +col3 INTEGER, +INDEX idx_a (col2), +INDEX idx_b (col3)); +INSERT INTO t1 VALUES (1); +INSERT INTO t2 VALUES (1, 1, 1); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN FORMAT=tree SELECT /*+ JOIN_ORDER(t2, t1) INDEX_MERGE(t2) */ t1.col1 +FROM t1 +JOIN t2 ON t1.col1 = t2.col1 +WHERE t2.col2 > 0 OR t2.col3 > 0 LIMIT 10; +EXPLAIN +-> Limit: 10 row(s) (cost=1.86 rows=1) + -> Inner hash join (t1.col1 = t2.col1) (cost=1.86 rows=1) + -> Table scan on t1 (cost=0.35 rows=1) + -> Hash + -> Filter: ((t2.col2 > 0) or (t2.col3 > 0)) (cost=1.51 rows=1) + -> Index range scan on t2 using sort_union(idx_a,idx_b) (cost=1.51 rows=1) + +SELECT /*+ JOIN_ORDER(t2, t1) INDEX_MERGE(t2) */ t1.col1 +FROM t1 +JOIN t2 ON t1.col1 = t2.col1 +WHERE t2.col2 > 0 OR t2.col3 > 0 LIMIT 10; +col1 +1 +DROP TABLE t1, t2; +# +# Bug#30224582 ASSERTION `M_INDEX_CURSOR.IS_POSITIONED()' FAILED +# +# Set up a query where the hash join build input consists of a +# materialized table, where we do an index lookup on the materialized +# table. The LIMIT is also needed in order to trigger a second build +# phase in the hash join. +CREATE TABLE t1 (col1 INTEGER); +CREATE TABLE t2 (col1 INTEGER); +INSERT INTO t1 VALUES (1); +INSERT INTO t2 VALUES (1); +EXPLAIN FORMAT=tree SELECT /*+ JOIN_ORDER(table1, t2) */ +* +FROM +( +SELECT +DISTINCT t1.* +FROM +t1 +) AS table1 JOIN t2 +WHERE table1.col1 = 1 +LIMIT 50; +EXPLAIN +-> Limit: 50 row(s) (cost=0.35 rows=1) + -> Table scan on t2 (cost=0.35 rows=1) + +SELECT /*+ JOIN_ORDER(table1, t2) */ +* +FROM +( +SELECT +DISTINCT t1.* +FROM +t1 +) AS table1 JOIN t2 +WHERE table1.col1 = 1 +LIMIT 50; +col1 col1 +1 1 +DROP TABLE t1, t2; +# +# Bug#30306279 ASAN: MEMCPY-PARAM-OVERLAP NEAR +# EXTRACT_VALUE_FOR_HASH_JOIN +# +# Set up a test where geometry data is written to chunk files on disk. +# Note that the test only fails with ASAN. +CREATE TABLE t1 (col1 GEOMETRY); +INSERT INTO t1 SELECT ST_GeomFromText(CONCAT('GEOMETRYCOLLECTION(POINT(1 1)', +REPEAT(',POINT(1 1)', 100), ')')); +INSERT INTO t1 SELECT ST_GeomFromText(CONCAT('GEOMETRYCOLLECTION(POINT(1 1)', +REPEAT(',POINT(1 1)', 100), ')')) FROM t1; +INSERT INTO t1 SELECT ST_GeomFromText(CONCAT('GEOMETRYCOLLECTION(POINT(1 1)', +REPEAT(',POINT(1 1)', 100), ')')) FROM t1; +SET join_buffer_size = 128; +SELECT * FROM t1 a JOIN t1 b ON a.col1 = b.col1; +SET join_buffer_size = DEFAULT; +DROP TABLE t1; +# +# Bug#30535541 HASH JOIN DOES NOT HANDLE PAD SPACE COLLATIONS CORRECTLY +# +# Test that hash join compares strings that only differs in end spaces +# equally in PAD SPACE collations. +CREATE TABLE t1 (c VARCHAR(255) COLLATE utf8mb4_bin); +CREATE TABLE t2 (c VARCHAR(255) COLLATE utf8mb4_bin); +INSERT INTO t1 VALUES ('foo'); +INSERT INTO t2 VALUES ('foo '); +EXPLAIN FORMAT=tree SELECT * FROM t1 JOIN t2 ON t1.c = t2.c; +EXPLAIN +-> Parallel scan on + -> Inner hash join (t2.c = t1.c) (cost=0.70 rows=1) + -> Table scan on t2 (cost=0.35 rows=1) + -> Hash + -> PQblock scan on t1 (cost=0.35 rows=1) + +SELECT * FROM t1 JOIN t2 ON t1.c = t2.c; +c c +foo foo +DROP TABLE t1, t2; +# +# Bug#30579922 INCORRECT RESULT IF HASH-JOIN ALGORITHM EXHAUST ITS +# JOIN_BUFFER +# +# Set up a query where the build input is a nested loop, where the inner +# side of the nested loop also has a filter. We want to see that if the +# hash join is not allowed to spill to disk, it will restore the last row +# read from the build iterator before doing a re-fill of the hash table. +CREATE TABLE t1 (i BIGINT); +INSERT INTO t1 SELECT 1; +INSERT INTO t1 SELECT i + POW(2, 0) FROM t1; +INSERT INTO t1 SELECT i + POW(2, 1) FROM t1; +INSERT INTO t1 SELECT i + POW(2, 2) FROM t1; +INSERT INTO t1 SELECT i + POW(2, 3) FROM t1; +INSERT INTO t1 SELECT i + POW(2, 4) FROM t1; +INSERT INTO t1 SELECT i + POW(2, 5) FROM t1; +CREATE TABLE t2 AS SELECT i FROM t1; +CREATE TABLE t3 AS SELECT i + 60 AS i FROM t1; +ANALYZE TABLE t1, t2, t3; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +SET join_buffer_size = 128; +EXPLAIN FORMAT=tree SELECT /*+ NO_BNL(t2) JOIN_ORDER(t1, t2, t3) */ * FROM t1 +JOIN t2 ON t1.i > t2.i +JOIN t3 ON t2.i = t3.i; +EXPLAIN +-> Parallel scan on + -> Inner hash join (t3.i = t2.i) (cost=9217.75 rows=8737) + -> Table scan on t3 (cost=0.04 rows=64) + -> Hash + -> Nested loop inner join (cost=432.25 rows=1365) + -> PQblock scan on t1 (cost=6.65 rows=64) + -> Filter: (t1.i > t2.i) (cost=0.28 rows=21) + -> Table scan on t2 (cost=0.28 rows=64) + +SELECT /*+ NO_BNL(t2) JOIN_ORDER(t1, t2, t3) */ * FROM t1 +JOIN t2 ON t1.i > t2.i +JOIN t3 ON t2.i = t3.i; +i i i +62 61 61 +63 61 61 +63 62 62 +64 61 61 +64 62 62 +64 63 63 +SELECT /*+ NO_BNL(t2) JOIN_ORDER(t1, t2, t3) */ * FROM t1 +JOIN t2 ON t1.i > t2.i +JOIN t3 ON t2.i = t3.i LIMIT 1000; +i i i +62 61 61 +63 61 61 +63 62 62 +64 61 61 +64 62 62 +64 63 63 +SET join_buffer_size = DEFAULT; +DROP TABLE t1, t2, t3; +# +# Bug#30282693 SIG6 IN TEMPTABLE::HANDLER::POSITION() AT SRC/HANDLER.CC +# +# Create a query where we get a confluent weedout as the right side of an +# antijoin. Since a confluent weedout returns at most one row, the +# iterator executor will replace it with a LIMIT 1. Note that the test +# case is not easy to understand, but it is the smallest test case I +# could make that reproduces the bug. +CREATE TABLE t1 ( +col1 INTEGER, +KEY idx (col1) +); +CREATE TABLE t2 ( +col1 INTEGER, +KEY idx (col1) +); +INSERT INTO t2 VALUES +(1),(2),(3),(4),(5),(6),(7),(8),(9),(10),(11),(12),(13),(14),(15),(16),(17); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN FORMAT=tree SELECT /*+ JOIN_ORDER(const_table, t2, t1, t1_2) */ 1 FROM t2 +RIGHT OUTER JOIN (VALUES ROW(4), ROW(5)) AS const_table ON TRUE +WHERE NOT EXISTS ( +SELECT t1.col1 FROM t1 +INNER JOIN t1 AS t1_2 ON t1_2.col1 = t1.col1 +WHERE t1.col1 <> t2.col1 +) AND t2.col1 < 49; +EXPLAIN +-> Nested loop antijoin (cost=10.03 rows=34) + -> Inner hash join (no condition) (cost=6.38 rows=34) + -> Filter: (t2.col1 < 49) (cost=0.98 rows=17) + -> Index scan on t2 using idx (cost=0.98 rows=17) + -> Hash + -> Table scan on const_table (cost=1.26..2.52 rows=2) + -> Materialize (cost=1.46..2.73 rows=2) + -> Rows fetched before execution (cost=0.00 rows=2) + -> Limit: 1 row(s) (cost=8.61 rows=1) + -> Nested loop inner join (cost=8.61 rows=1) + -> Filter: (t1.col1 <> t2.col1) (cost=0.01 rows=1) + -> Index scan on t1 using idx (cost=0.01 rows=1) + -> Index lookup on t1_2 using idx (col1=t1.col1) (cost=0.25 rows=1) + +Warnings: +Note 1276 Field or reference 'test.t2.col1' of SELECT #3 was resolved in SELECT #1 +SELECT /*+ JOIN_ORDER(const_table, t2, t1, t1_2) */ 1 FROM t2 +RIGHT OUTER JOIN (VALUES ROW(4), ROW(5)) AS const_table ON TRUE +WHERE NOT EXISTS ( +SELECT t1.col1 FROM t1 +INNER JOIN t1 AS t1_2 ON t1_2.col1 = t1.col1 +WHERE t1.col1 <> t2.col1 +) AND t2.col1 < 49; +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +DROP TABLE t1, t2; +# +# Bug#30626264 ASSERTS IN BASIC_ROW_ITERATORS.H:345: +# FAKESINGLEROWITERATOR::SETNULLROWFLAG +# +CREATE TABLE t1 ( +pk INTEGER +); +INSERT INTO t1 VALUES (1), (2); +CREATE TABLE t2 ( +pk INTEGER NOT NULL, +PRIMARY KEY (pk) +); +INSERT INTO t2 VALUES (9); +CREATE TABLE t3 ( +pk INTEGER +); +ANALYZE TABLE t1, t2, t3; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +explain format=tree SELECT ( +SELECT t1.pk +FROM t2 +LEFT JOIN t3 USING (pk) +JOIN t3 AS t4 USING (pk) +WHERE t2.pk = 9 +) FROM t1; +EXPLAIN +-> Table scan on t1 (cost=0.45 rows=2) +-> Select #2 (subquery in projection; dependent) + -> Inner hash join (no condition) (cost=0.70 rows=1) + -> Filter: (t4.pk = 9) (cost=0.35 rows=1) + -> Table scan on t4 (cost=0.35 rows=1) + -> Hash + -> Nested loop left join (cost=0.35 rows=1) + -> Rows fetched before execution (cost=0.00..0.00 rows=1) + -> Filter: (t3.pk = 9) (cost=0.35 rows=1) + -> Table scan on t3 (cost=0.35 rows=1) + +Warnings: +Note 1276 Field or reference 'test.t1.pk' of SELECT #2 was resolved in SELECT #1 +SELECT ( +SELECT t1.pk +FROM t2 +LEFT JOIN t3 USING (pk) +JOIN t3 AS t4 USING (pk) +WHERE t2.pk = 9 +) FROM t1; +( +SELECT t1.pk +FROM t2 +LEFT JOIN t3 USING (pk) +JOIN t3 AS t4 USING (pk) +WHERE t2.pk = 9 +) +NULL +NULL +DROP TABLE t1, t2, t3; +# See that non equi-join BNL are executed using hash join. +CREATE TABLE t1 (col1 INT); +CREATE TABLE t2 (col1 INT); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN FORMAT=tree SELECT * FROM t1 JOIN t2 ON t1.col1 < t2.col1; +EXPLAIN +-> Parallel scan on + -> Filter: (t1.col1 < t2.col1) (cost=0.70 rows=1) + -> Inner hash join (no condition) (cost=0.70 rows=1) + -> Table scan on t2 (cost=0.35 rows=1) + -> Hash + -> PQblock scan on t1 (cost=0.35 rows=1) + +DROP TABLE t1, t2; +# Semijoin. +CREATE TABLE t1 (i INTEGER); +CREATE TABLE t2 (i INTEGER); +INSERT INTO t1 VALUES (1), (2); +INSERT INTO t2 VALUES (1), (1); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN FORMAT=tree SELECT * FROM t1 WHERE (t1.i) IN (SELECT t2.i FROM t2); +EXPLAIN +-> Parallel scan on + -> Hash semijoin (t2.i = t1.i) (cost=0.83 rows=2) + -> PQblock scan on t1 (cost=0.45 rows=2) + -> Hash + -> Table scan on t2 (cost=0.18 rows=2) + +SELECT * FROM t1 WHERE (t1.i) IN (SELECT t2.i FROM t2); +i +1 +DROP TABLE t1, t2; +CREATE TABLE t1 (col1 INTEGER, col2 INTEGER); +CREATE TABLE t2 (col1 INTEGER, col2 INTEGER); +INSERT INTO t1 VALUES (1, 1), (2, 2); +INSERT INTO t2 VALUES (1, 1), (1, 2); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN FORMAT=tree +SELECT * FROM t1 WHERE (t1.col1) IN +(SELECT t2.col1 FROM t2 WHERE t2.col2 < 3); +EXPLAIN +-> Parallel scan on + -> Hash semijoin (t2.col1 = t1.col1) (cost=0.78 rows=1) + -> PQblock scan on t1 (cost=0.45 rows=2) + -> Hash + -> Filter: (t2.col2 < 3) (cost=0.23 rows=1) + -> Table scan on t2 (cost=0.23 rows=2) + +DROP TABLE t1, t2; +# Test a query where the optimizer will create a semijoin condition that +# is not an equi-join condition. These kind of conditions must be +# attached as "extra" conditions in the hash join iterator in order to +# produce correct results. +CREATE TABLE t1 (col1 INTEGER); +CREATE TABLE t2 (col1 INTEGER); +INSERT INTO t1 VALUES (1), (3), (4), (5); +INSERT INTO t2 VALUES (2), (3), (4), (6); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN FORMAT=tree SELECT * FROM t1 WHERE 1 IN (SELECT t1.col1 = t2.col1 FROM t2); +EXPLAIN +-> Parallel scan on + -> Hash semijoin (no condition), extra conditions: (1 = (t1.col1 = t2.col1)) (cost=2.50 rows=16) + -> PQblock scan on t1 (cost=0.65 rows=4) + -> Hash + -> Table scan on t2 (cost=0.65 rows=4) + +Warnings: +Note 1276 Field or reference 'test.t1.col1' of SELECT #2 was resolved in SELECT #1 +SELECT * FROM t1 WHERE 1 IN (SELECT t1.col1 = t2.col1 FROM t2); +col1 +3 +4 +DROP TABLE t1, t2; +# Exercise a test where we get multiple tables in the probe input. +CREATE TABLE t1(a INTEGER); +CREATE TABLE t2(a INTEGER); +CREATE TABLE t3(a INTEGER); +INSERT INTO t1 VALUES (0); +INSERT INTO t2 VALUES (0); +INSERT INTO t3 VALUES (0); +ANALYZE TABLE t1, t2, t3; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +SET optimizer_switch="materialization=off,duplicateweedout=off"; +EXPLAIN FORMAT=tree SELECT * FROM t1 LEFT JOIN t2 ON t1.a=t2.a +WHERE (t1.a,t2.a) IN (SELECT a, a FROM t3); +EXPLAIN +-> Parallel scan on + -> Hash semijoin (t3.a = t1.a) (cost=0.70 rows=1) + -> Inner hash join (t2.a = t1.a) (cost=0.70 rows=1) + -> Table scan on t2 (cost=0.35 rows=1) + -> Hash + -> PQblock scan on t1 (cost=0.35 rows=1) + -> Hash + -> Table scan on t3 (cost=0.35 rows=1) + +SELECT * FROM t1 LEFT JOIN t2 ON t1.a=t2.a +WHERE (t1.a,t2.a) IN (SELECT a, a FROM t3); +a a +0 0 +SET optimizer_switch=DEFAULT; +DROP TABLE t1, t2, t3; +# See that semijoin with spill to disk works as expected. +CREATE TABLE t1 (col1 BIGINT, col2 BIGINT); +INSERT INTO t1 SELECT POW(2, 0), POW(2, 0); +INSERT INTO t1 +SELECT col1 + POW(2, 0), col2 + POW(2, 0) FROM t1; +INSERT INTO t1 +SELECT col1 + POW(2, 1), col2 + POW(2, 1) FROM t1; +INSERT INTO t1 +SELECT col1 + POW(2, 2), col2 + POW(2, 2) FROM t1; +INSERT INTO t1 +SELECT col1 + POW(2, 3), col2 + POW(2, 3) FROM t1; +INSERT INTO t1 +SELECT col1 + POW(2, 4), col2 + POW(2, 4) FROM t1; +INSERT INTO t1 +SELECT col1 + POW(2, 5), col2 + POW(2, 5) FROM t1; +INSERT INTO t1 +SELECT col1 + POW(2, 6), col2 + POW(2, 6) FROM t1; +INSERT INTO t1 +SELECT col1 + POW(2, 7), col2 + POW(2, 7) FROM t1; +INSERT INTO t1 +SELECT col1 + POW(2, 8), col2 + POW(2, 8) FROM t1; +INSERT INTO t1 +SELECT col1 + POW(2, 9), col2 + POW(2, 9) FROM t1; +CREATE TABLE t2 AS SELECT * FROM t1; +UPDATE t1 SET col2 = col1 + 1 WHERE MOD(col1, 2) = 0; +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +SET join_buffer_size = 1024; +SET optimizer_switch = "materialization=off"; +EXPLAIN FORMAT=tree SELECT SUM(t1.col1), SUM(t1.col2) FROM t1 WHERE t1.col1 IN +(SELECT t2.col1 FROM t2); +EXPLAIN +-> Aggregate: sum(`SUM(t1.col1)`), sum(`SUM(t1.col2)`) + -> Parallel scan on + -> Aggregate: + -> Hash semijoin (t2.col1 = t1.col1) (cost=104883.37 rows=104858) + -> PQblock scan on t1 (cost=103.65 rows=1024) + -> Hash + -> Table scan on t2 (cost=3.27 rows=1024) + +SELECT SUM(t1.col1), SUM(t1.col2) FROM t1 WHERE t1.col1 IN +(SELECT t2.col1 FROM t2); +SUM(t1.col1) SUM(t1.col2) +524800 525312 +EXPLAIN FORMAT=tree SELECT SUM(t1.col1), SUM(t1.col2) FROM t1 WHERE t1.col1 IN +(SELECT t2.col1 FROM t2 WHERE t1.col2 <> t2.col2); +EXPLAIN +-> Aggregate: sum(`SUM(t1.col1)`), sum(`SUM(t1.col2)`) + -> Parallel scan on + -> Aggregate: + -> Hash semijoin (t2.col1 = t1.col1), extra conditions: (t1.col2 <> t2.col2) (cost=104882.95 rows=94372) + -> PQblock scan on t1 (cost=103.65 rows=1024) + -> Hash + -> Table scan on t2 (cost=2.85 rows=1024) + +Warnings: +Note 1276 Field or reference 'test.t1.col2' of SELECT #2 was resolved in SELECT #1 +SELECT SUM(t1.col1), SUM(t1.col2) FROM t1 WHERE t1.col1 IN +(SELECT t2.col1 FROM t2 WHERE t1.col2 <> t2.col2); +SUM(t1.col1) SUM(t1.col2) +262656 263168 +SET optimizer_switch = DEFAULT; +SET join_buffer_size = DEFAULT; +DROP TABLE t1, t2; +# Set up a test case where hash join spills to disk, and the chunk files +# for the build input is too big to fit into memory. This causes the +# probe chunk file to be read multiple times. What we want to see is that +# if a row from the probe chunk file finds a match in the first part of +# the build chunk file, the row must not be sent to the client the second +# time the row is read from the probe chunk. Note that it is not trivial +# to set up a test case that is guaranteed to hit this case. +CREATE TABLE build (col1 BIGINT); +CREATE TABLE probe (col1 BIGINT); +INSERT INTO probe SELECT 1; +INSERT INTO probe SELECT col1 + POW(2, 0) FROM probe; +INSERT INTO probe SELECT col1 + POW(2, 1) FROM probe; +INSERT INTO probe SELECT col1 + POW(2, 2) FROM probe; +INSERT INTO probe SELECT col1 + POW(2, 3) FROM probe; +INSERT INTO probe SELECT col1 + POW(2, 4) FROM probe; +INSERT INTO probe SELECT col1 + POW(2, 5) FROM probe; +INSERT INTO probe SELECT col1 + POW(2, 6) FROM probe; +INSERT INTO probe SELECT col1 + POW(2, 7) FROM probe; +INSERT INTO build SELECT col1 FROM probe; +INSERT INTO build SELECT col1 * 2 FROM probe; +INSERT INTO build SELECT col1 * 3 FROM probe; +SELECT COUNT(*) AS expected_num_rows FROM probe; +expected_num_rows +256 +SET join_buffer_size = 128; +SET optimizer_switch="materialization=off"; +EXPLAIN FORMAT=tree SELECT COUNT(*) FROM probe WHERE col1 IN (SELECT col1 FROM build); +EXPLAIN +-> Aggregate: count(`COUNT(*)`) + -> Parallel scan on + -> Aggregate: + -> Hash semijoin (build.col1 = probe.col1) (cost=19669.28 rows=19661) + -> PQblock scan on probe (cost=25.85 rows=256) + -> Hash + -> Table scan on build (cost=3.73 rows=768) + +SELECT COUNT(*) FROM probe WHERE col1 IN (SELECT col1 FROM build); +COUNT(*) +256 +SET join_buffer_size = DEFAULT; +SET optimizer_switch = DEFAULT; +DROP TABLE build, probe; +# Using LIMIT in the query rejects hash join from spilling to disk, +# causing the probe input to be read multiple times if the build input +# does not fit in memory. This test case is somewhat similar to the +# above; see that we do not output rows from the probe input multiple +# times even if the probe input is read multiple times. +CREATE TABLE build (col1 BIGINT); +CREATE TABLE probe (col1 BIGINT); +INSERT INTO probe SELECT 1; +INSERT INTO probe SELECT col1 + POW(2, 0) FROM probe; +INSERT INTO probe SELECT col1 + POW(2, 1) FROM probe; +INSERT INTO probe SELECT col1 + POW(2, 2) FROM probe; +INSERT INTO probe SELECT col1 + POW(2, 3) FROM probe; +INSERT INTO probe SELECT col1 + POW(2, 4) FROM probe; +INSERT INTO probe SELECT col1 + POW(2, 5) FROM probe; +INSERT INTO probe SELECT col1 + POW(2, 6) FROM probe; +INSERT INTO probe SELECT col1 + POW(2, 7) FROM probe; +INSERT INTO build SELECT col1 FROM probe; +INSERT INTO build SELECT col1 FROM probe ORDER BY col1 DESC; +SET optimizer_switch = "materialization=off"; +SET join_buffer_size = 1024; +EXPLAIN FORMAT=tree SELECT * FROM probe WHERE col1 IN (SELECT * FROM build); +EXPLAIN +-> Parallel scan on + -> Hash semijoin (build.col1 = probe.col1) (cost=13109.20 rows=13107) + -> PQblock scan on probe (cost=25.85 rows=256) + -> Hash + -> Table scan on build (cost=1.19 rows=512) + +SELECT * FROM probe WHERE col1 IN (SELECT * FROM build); +col1 +1 +10 +100 +101 +102 +103 +104 +105 +106 +107 +108 +109 +11 +110 +111 +112 +113 +114 +115 +116 +117 +118 +119 +12 +120 +121 +122 +123 +124 +125 +126 +127 +128 +129 +13 +130 +131 +132 +133 +134 +135 +136 +137 +138 +139 +14 +140 +141 +142 +143 +144 +145 +146 +147 +148 +149 +15 +150 +151 +152 +153 +154 +155 +156 +157 +158 +159 +16 +160 +161 +162 +163 +164 +165 +166 +167 +168 +169 +17 +170 +171 +172 +173 +174 +175 +176 +177 +178 +179 +18 +180 +181 +182 +183 +184 +185 +186 +187 +188 +189 +19 +190 +191 +192 +193 +194 +195 +196 +197 +198 +199 +2 +20 +200 +201 +202 +203 +204 +205 +206 +207 +208 +209 +21 +210 +211 +212 +213 +214 +215 +216 +217 +218 +219 +22 +220 +221 +222 +223 +224 +225 +226 +227 +228 +229 +23 +230 +231 +232 +233 +234 +235 +236 +237 +238 +239 +24 +240 +241 +242 +243 +244 +245 +246 +247 +248 +249 +25 +250 +251 +252 +253 +254 +255 +256 +26 +27 +28 +29 +3 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +4 +40 +41 +42 +43 +44 +45 +46 +47 +48 +49 +5 +50 +51 +52 +53 +54 +55 +56 +57 +58 +59 +6 +60 +61 +62 +63 +64 +65 +66 +67 +68 +69 +7 +70 +71 +72 +73 +74 +75 +76 +77 +78 +79 +8 +80 +81 +82 +83 +84 +85 +86 +87 +88 +89 +9 +90 +91 +92 +93 +94 +95 +96 +97 +98 +99 +SELECT * FROM probe WHERE col1 IN (SELECT * FROM build) LIMIT 1000; +col1 +1 +10 +100 +101 +102 +103 +104 +105 +106 +107 +108 +109 +11 +110 +111 +112 +113 +114 +115 +116 +117 +118 +119 +12 +120 +121 +122 +123 +124 +125 +126 +127 +128 +129 +13 +130 +131 +132 +133 +134 +135 +136 +137 +138 +139 +14 +140 +141 +142 +143 +144 +145 +146 +147 +148 +149 +15 +150 +151 +152 +153 +154 +155 +156 +157 +158 +159 +16 +160 +161 +162 +163 +164 +165 +166 +167 +168 +169 +17 +170 +171 +172 +173 +174 +175 +176 +177 +178 +179 +18 +180 +181 +182 +183 +184 +185 +186 +187 +188 +189 +19 +190 +191 +192 +193 +194 +195 +196 +197 +198 +199 +2 +20 +200 +201 +202 +203 +204 +205 +206 +207 +208 +209 +21 +210 +211 +212 +213 +214 +215 +216 +217 +218 +219 +22 +220 +221 +222 +223 +224 +225 +226 +227 +228 +229 +23 +230 +231 +232 +233 +234 +235 +236 +237 +238 +239 +24 +240 +241 +242 +243 +244 +245 +246 +247 +248 +249 +25 +250 +251 +252 +253 +254 +255 +256 +26 +27 +28 +29 +3 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +4 +40 +41 +42 +43 +44 +45 +46 +47 +48 +49 +5 +50 +51 +52 +53 +54 +55 +56 +57 +58 +59 +6 +60 +61 +62 +63 +64 +65 +66 +67 +68 +69 +7 +70 +71 +72 +73 +74 +75 +76 +77 +78 +79 +8 +80 +81 +82 +83 +84 +85 +86 +87 +88 +89 +9 +90 +91 +92 +93 +94 +95 +96 +97 +98 +99 +SET optimizer_switch = DEFAULT; +SET join_buffer_size = DEFAULT; +DROP TABLE build, probe; +# +# Bug#30512118 WL#13476: ASSERTION FAILURE AT +# HASHJOINITERATOR::INITPROBEITERATOR() +# +# Execute a query that causes the hash join to do everything in memory +# with multiple refills of the hash table. This can be triggered when the +# build input does not fit in memory, and the iterator is not allowed to +# spill to disk due to LIMIT in the query. +CREATE TABLE t1 (col1 VARCHAR(255)); +INSERT INTO t1 SELECT UUID(); +INSERT INTO t1 SELECT UUID() FROM t1; +INSERT INTO t1 SELECT UUID() FROM t1; +INSERT INTO t1 SELECT UUID() FROM t1; +INSERT INTO t1 SELECT UUID() FROM t1; +INSERT INTO t1 SELECT UUID() FROM t1; +INSERT INTO t1 SELECT UUID() FROM t1; +INSERT INTO t1 SELECT UUID() FROM t1; +CREATE TABLE t2 AS SELECT UUID() AS col1 FROM t1; +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +SET join_buffer_size = 128; +EXPLAIN FORMAT=tree SELECT * FROM t1 JOIN t2 ON t1.col1 = t2.col1 LIMIT 1000; +EXPLAIN +-> Limit: 1000 row(s) + -> Parallel scan on + -> Limit: 1000 row(s) (cost=1907.45 rows=1000) + -> Filter: (t1.col1 = t2.col1) (cost=1907.45 rows=1638) + -> Inner hash join ((t1.col1)=(t2.col1)) (cost=1907.45 rows=1638) + -> Table scan on t2 (cost=2.01 rows=128) + -> Hash + -> PQblock scan on t1 (cost=13.05 rows=128) + +SELECT * FROM t1 JOIN t2 ON t1.col1 = t2.col1 LIMIT 1000; +SET join_buffer_size = DEFAULT; +DROP TABLE t1, t2; +# Antijoin. +CREATE TABLE t1 (f1 INTEGER PRIMARY KEY); +INSERT INTO t1 VALUES (1), (2), (3); +CREATE TABLE t2 (f1 INTEGER NOT NULL); +INSERT INTO t2 VALUES (1), (2), (3), (4); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN FORMAT=tree SELECT * FROM t1 LEFT JOIN t2 USING (f1) WHERE t2.f1 IS NULL; +EXPLAIN +-> Parallel scan on + -> Filter: (t2.f1 is null) (cost=1.97 rows=3) + -> Hash antijoin (t2.f1 = t1.f1) (cost=1.97 rows=3) + -> PQblock scan on t1 using PRIMARY (cost=0.55 rows=3) + -> Hash + -> Table scan on t2 (cost=0.22 rows=4) + +SELECT * FROM t1 LEFT JOIN t2 USING (f1) WHERE t2.f1 IS NULL; +f1 +DROP TABLE t1,t2; +# Set up a case where we get multiple antijoin conditions AND'ed together +# inside a is_not_null_compl. We want to see that the server is able to +# split these conditions and attach them as antijoin conditions to the +# hash join. +CREATE TABLE t1 ( +aid INTEGER NOT NULL, +bid INTEGER NOT NULL); +CREATE TABLE t2 LIKE t1; +INSERT INTO t1 VALUES (1,1),(1,2),(2,1),(2,2); +INSERT INTO t2 VALUES (1,2),(2,2); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN FORMAT=tree SELECT * FROM t1 +WHERE t1.aid NOT IN (SELECT aid FROM t2 WHERE bid = t1.bid); +EXPLAIN +-> Parallel scan on + -> Hash antijoin (t2.bid = t1.bid), (t2.aid = t1.aid) (cost=1.28 rows=8) + -> PQblock scan on t1 (cost=0.65 rows=4) + -> Hash + -> Table scan on t2 (cost=0.23 rows=2) + +Warnings: +Note 1276 Field or reference 'test.t1.bid' of SELECT #2 was resolved in SELECT #1 +SELECT * FROM t1 +WHERE t1.aid NOT IN (SELECT aid FROM t2 WHERE bid = t1.bid); +aid bid +1 1 +2 1 +DROP TABLE t1, t2; +# Check that hash antijoin can handle NULL values correctly. +CREATE TABLE t1 (col1 INTEGER); +CREATE TABLE t2 (col1 INTEGER); +INSERT INTO t1 VALUES (NULL); +EXPLAIN FORMAT=tree SELECT * FROM t1 +WHERE 1 IN (SELECT 1 FROM t2 WHERE t1.col1 = t2.col1) IS FALSE; +EXPLAIN +-> Parallel scan on + -> Hash antijoin (t2.col1 = t1.col1) (cost=0.70 rows=1) + -> PQblock scan on t1 (cost=0.35 rows=1) + -> Hash + -> Table scan on t2 (cost=0.35 rows=1) + +Warnings: +Note 1276 Field or reference 'test.t1.col1' of SELECT #2 was resolved in SELECT #1 +SELECT * FROM t1 +WHERE 1 IN (SELECT 1 FROM t2 WHERE t1.col1 = t2.col1) IS FALSE; +col1 +NULL +DROP TABLE t1, t2; +# See that antijoin with spill to disk works. +CREATE TABLE t1 (col1 BIGINT NOT NULL, col2 BIGINT NOT NULL); +INSERT INTO t1 SELECT POW(2, 0), POW(2, 0); +INSERT INTO t1 +SELECT col1 + POW(2, 0), col2 + POW(2, 0) FROM t1; +INSERT INTO t1 +SELECT col1 + POW(2, 1), col2 + POW(2, 1) FROM t1; +INSERT INTO t1 +SELECT col1 + POW(2, 2), col2 + POW(2, 2) FROM t1; +INSERT INTO t1 +SELECT col1 + POW(2, 3), col2 + POW(2, 3) FROM t1; +INSERT INTO t1 +SELECT col1 + POW(2, 4), col2 + POW(2, 4) FROM t1; +INSERT INTO t1 +SELECT col1 + POW(2, 5), col2 + POW(2, 5) FROM t1; +INSERT INTO t1 +SELECT col1 + POW(2, 6), col2 + POW(2, 6) FROM t1; +INSERT INTO t1 +SELECT col1 + POW(2, 7), col2 + POW(2, 7) FROM t1; +INSERT INTO t1 +SELECT col1 + POW(2, 8), col2 + POW(2, 8) FROM t1; +INSERT INTO t1 +SELECT col1 + POW(2, 9), col2 + POW(2, 9) FROM t1; +CREATE TABLE t2 AS SELECT * FROM t1; +UPDATE t1 SET col2 = col1 + 1 WHERE MOD(col1, 2) = 0; +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +SET join_buffer_size = 1024; +SET optimizer_switch = "materialization=off"; +EXPLAIN FORMAT=tree SELECT SUM(t1.col1), SUM(t1.col2) FROM t1 WHERE t1.col1 NOT IN +(SELECT t2.col1 FROM t2); +EXPLAIN +-> Aggregate: sum(`SUM(t1.col1)`), sum(`SUM(t1.col2)`) + -> Parallel scan on + -> Aggregate: + -> Hash antijoin (t2.col1 = t1.col1) (cost=105002.50 rows=1048576) + -> PQblock scan on t1 (cost=103.65 rows=1024) + -> Hash + -> Table scan on t2 (cost=123.65 rows=1024) + +SELECT SUM(t1.col1), SUM(t1.col2) FROM t1 WHERE t1.col1 NOT IN +(SELECT t2.col1 FROM t2); +SUM(t1.col1) SUM(t1.col2) +NULL NULL +EXPLAIN FORMAT=tree SELECT SUM(t1.col1), SUM(t1.col2) FROM t1 WHERE t1.col1 NOT IN +(SELECT t2.col1 FROM t2 WHERE t1.col2 < t2.col2); +EXPLAIN +-> Aggregate: sum(`SUM(t1.col1)`), sum(`SUM(t1.col2)`) + -> Parallel scan on + -> Aggregate: + -> Hash antijoin (t2.col1 = t1.col1), extra conditions: (t1.col2 < t2.col2) (cost=105002.50 rows=1048576) + -> PQblock scan on t1 (cost=103.65 rows=1024) + -> Hash + -> Table scan on t2 (cost=123.65 rows=1024) + +Warnings: +Note 1276 Field or reference 'test.t1.col2' of SELECT #2 was resolved in SELECT #1 +SELECT SUM(t1.col1), SUM(t1.col2) FROM t1 WHERE t1.col1 NOT IN +(SELECT t2.col1 FROM t2 WHERE t1.col2 < t2.col2); +SUM(t1.col1) SUM(t1.col2) +524800 525312 +SET optimizer_switch = DEFAULT; +SET join_buffer_size = DEFAULT; +DROP TABLE t1, t2; +# Set up an antijoin that spills to disk, and the probe chunk files are +# too big to fit in memory. This causes the hash join to read the probe +# chunk files in several smaller chunks, which in turn enables probe row +# saving. So this test tries to verify that on-disk antijoin with probe +# row saving works correctly. This is not the easiest scenario to set up +# correctly, and it is difficult to show that on-disk antijoin with probe +# row saving actually is triggered... +CREATE TABLE build (col1 BIGINT NOT NULL); +CREATE TABLE probe (col1 BIGINT NOT NULL); +INSERT INTO probe SELECT 1; +INSERT INTO probe SELECT col1 + POW(2, 0) FROM probe; +INSERT INTO probe SELECT col1 + POW(2, 1) FROM probe; +INSERT INTO probe SELECT col1 + POW(2, 2) FROM probe; +INSERT INTO probe SELECT col1 + POW(2, 3) FROM probe; +INSERT INTO probe SELECT col1 + POW(2, 4) FROM probe; +INSERT INTO probe SELECT col1 + POW(2, 5) FROM probe; +INSERT INTO probe SELECT col1 + POW(2, 6) FROM probe; +INSERT INTO probe SELECT col1 + POW(2, 7) FROM probe; +INSERT INTO build SELECT col1 FROM probe; +INSERT INTO build SELECT col1 * 2 FROM probe; +INSERT INTO build SELECT col1 * 3 FROM probe; +DELETE FROM build WHERE col1 = 254; +SET join_buffer_size = 128; +SET optimizer_switch="materialization=off"; +EXPLAIN FORMAT=tree SELECT * FROM probe WHERE col1 NOT IN (SELECT col1 FROM build); +EXPLAIN +-> Parallel scan on + -> Hash antijoin (build.col1 = probe.col1) (cost=*** rows=196096) + -> PQblock scan on probe (cost=*** rows=256) + -> Hash + -> Table scan on build (cost=*** rows=766) + +SELECT * FROM probe WHERE col1 NOT IN (SELECT col1 FROM build); +col1 +254 +SET join_buffer_size = DEFAULT; +SET optimizer_switch = DEFAULT; +DROP TABLE build, probe; +# Outer join. +CREATE TABLE t1 (col1 INTEGER); +CREATE TABLE t2 (col1 INTEGER); +INSERT INTO t1 VALUES (1), (2); +INSERT INTO t2 VALUES (1); +EXPLAIN FORMAT=tree SELECT * FROM t1 LEFT JOIN t2 ON t1.col1 = t2.col1; +EXPLAIN +-> Parallel scan on + -> Left hash join (t2.col1 = t1.col1) (cost=0.63 rows=2) + -> PQblock scan on t1 (cost=0.45 rows=2) + -> Hash + -> Table scan on t2 (cost=0.18 rows=1) + +SELECT * FROM t1 LEFT JOIN t2 ON t1.col1 = t2.col1; +col1 col1 +1 1 +2 NULL +DROP TABLE t1,t2; +CREATE TABLE t1 (col1 INTEGER); +CREATE TABLE t2 (col1 INTEGER); +CREATE TABLE t3 (col1 INTEGER); +INSERT INTO t1 VALUES (1), (2), (3); +INSERT INTO t2 VALUES (1), (2); +INSERT INTO t3 VALUES (1); +ANALYZE TABLE t1, t2, t3; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +EXPLAIN FORMAT=tree SELECT t1.col1, t2.col1, t3.col1 FROM t1 +LEFT JOIN ( +t2 LEFT JOIN t3 ON t2.col1 = t3.col1) +ON t2.col1 = t1.col1 +ORDER BY t1.col1, t2.col1, t3.col1; +EXPLAIN +-> Sort: t1.col1, t2.col1, t3.col1 + -> Stream results + -> Parallel scan on + -> Sort: t1.col1, t2.col1, t3.col1 + -> Stream results (cost=1.36 rows=6) + -> Left hash join (t2.col1 = t1.col1) (cost=1.36 rows=6) + -> PQblock scan on t1 (cost=0.55 rows=3) + -> Hash + -> Left hash join (t3.col1 = t2.col1) (cost=0.51 rows=2) + -> Table scan on t2 (cost=0.15 rows=2) + -> Hash + -> Table scan on t3 (cost=0.06 rows=1) + +SELECT t1.col1, t2.col1, t3.col1 FROM t1 +LEFT JOIN ( +t2 LEFT JOIN t3 ON t2.col1 = t3.col1) +ON t2.col1 = t1.col1 +ORDER BY t1.col1, t2.col1, t3.col1; +col1 col1 col1 +1 1 1 +2 2 NULL +3 NULL NULL +DROP TABLE t1, t2, t3; +CREATE TABLE t1 (i INTEGER NOT NULL); +INSERT INTO t1 VALUES (0), (2), (3),(4); +CREATE TABLE t2 (i INTEGER NOT NULL); +INSERT INTO t2 VALUES (0), (1), (3),(4); +CREATE TABLE t3 (i INTEGER NOT NULL); +INSERT INTO t3 VALUES (0), (1), (2), (4); +CREATE TABLE t4 (i INTEGER NOT NULL); +INSERT INTO t4 VALUES (0), (1), (2), (3); +ANALYZE TABLE t1, t2, t3, t4; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +test.t4 analyze status OK +EXPLAIN FORMAT=tree SELECT * FROM +t1 LEFT JOIN +( t2 LEFT JOIN +( t3 LEFT JOIN +t4 +ON t4.i = t3.i +) +ON t3.i = t2.i +) +ON t2.i = t1.i; +EXPLAIN +-> Parallel scan on + -> Left hash join (t2.i = t1.i) (cost=34.36 rows=256) + -> PQblock scan on t1 (cost=0.65 rows=4) + -> Hash + -> Left hash join (t2.i = t3.i), (t3.i = t2.i) (cost=8.51 rows=64) + -> Table scan on t2 (cost=0.16 rows=4) + -> Hash + -> Left hash join (t4.i = t3.i) (cost=1.86 rows=16) + -> Table scan on t3 (cost=0.04 rows=4) + -> Hash + -> Table scan on t4 (cost=0.01 rows=4) + +SELECT * FROM +t1 LEFT JOIN +( t2 LEFT JOIN +( t3 LEFT JOIN +t4 +ON t4.i = t3.i +) +ON t3.i = t2.i +) +ON t2.i = t1.i; +i i i i +0 0 0 0 +2 NULL NULL NULL +3 3 NULL NULL +4 4 4 NULL +DROP TABLE t1, t2, t3, t4; +CREATE TABLE t1 (col1 INTEGER); +CREATE TABLE t2 (col1 INTEGER); +CREATE TABLE t3 (col1 INTEGER); +EXPLAIN FORMAT=tree SELECT * FROM t1 LEFT JOIN (t2 INNER JOIN t3 ON t2.col1 = t3.col1) +ON t1.col1 = t2.col1; +EXPLAIN +-> Parallel scan on + -> Left hash join (t2.col1 = t1.col1), (t3.col1 = t1.col1) (cost=1.05 rows=1) + -> PQblock scan on t1 (cost=0.35 rows=1) + -> Hash + -> Inner hash join (no condition) (cost=0.70 rows=1) + -> Table scan on t3 (cost=0.35 rows=1) + -> Hash + -> Table scan on t2 (cost=0.35 rows=1) + +DROP TABLE t1, t2, t3; +# Set up a case where the join condition in a left join does not refer +# to any of the tables (degenerate join predicate). It will be attached +# as an "extra" condition on the hash join iterator. +CREATE TABLE t1 (col1 INTEGER); +CREATE TABLE t2 (col1 INTEGER); +INSERT INTO t1 VALUES (1); +INSERT INTO t2 VALUES (1); +EXPLAIN FORMAT=tree SELECT * FROM t1 LEFT JOIN t2 ON RAND() < -1; +EXPLAIN +-> Parallel scan on + -> Left hash join (no condition), extra conditions: (rand() < (-(1))) (cost=0.70 rows=1) + -> PQblock scan on t1 (cost=0.35 rows=1) + -> Hash + -> Table scan on t2 (cost=0.35 rows=1) + +SELECT * FROM t1 LEFT JOIN t2 ON RAND() < -1; +col1 col1 +1 NULL +DROP TABLE t1, t2; +CREATE TABLE t1 (col1 INTEGER); +CREATE TABLE t2 (col1 INTEGER, col2 INTEGER); +INSERT INTO t1 VALUES (1); +INSERT INTO t2 VALUES (1, 1), (1, 2), (1, 3), (1, 4), (1, 5); +SELECT * FROM t1 LEFT JOIN t2 ON t1.col1 = t2.col1 AND t2.col2 = 1; +col1 col1 col2 +1 1 1 +SELECT * FROM t1 LEFT JOIN t2 ON t1.col1 = t2.col1 AND t2.col2 = 2; +col1 col1 col2 +1 1 2 +SELECT * FROM t1 LEFT JOIN t2 ON t1.col1 = t2.col1 AND t2.col2 = 3; +col1 col1 col2 +1 1 3 +SELECT * FROM t1 LEFT JOIN t2 ON t1.col1 = t2.col1 AND t2.col2 = 4; +col1 col1 col2 +1 1 4 +SELECT * FROM t1 LEFT JOIN t2 ON t1.col1 = t2.col1 AND t2.col2 = 5; +col1 col1 col2 +1 1 5 +SELECT * FROM t1 LEFT JOIN t2 ON t1.col1 = t2.col1 AND t2.col2 = 6; +col1 col1 col2 +1 NULL NULL +DROP TABLE t1, t2; +# Run a query where we get a cached outer join condition (i.e. comparison +# between two constant values. The condition is evaluated once and then +# cached.). This condition must be placed as a condition below the +# hash join iterator, and not as a filter after it. +CREATE TABLE t1 (f1 INTEGER, f2 INTEGER); +INSERT INTO t1 VALUES (1,1), (2,2); +EXPLAIN FORMAT=tree SELECT +tt.t +FROM +(SELECT 'crash1' AS t, f2 FROM t1) AS tt +LEFT JOIN t1 ON tt.t = 'crash2' AND tt.f2 = t1.f2 +WHERE +tt.t = 'crash1'; +EXPLAIN +-> Parallel scan on + -> Left hash join (no condition) (cost=0.25 rows=0) + -> PQblock scan on t1 (cost=0.45 rows=2) + -> Hash + -> Zero rows (Impossible filter) (cost=0.00..0.00 rows=0) + +SELECT +tt.t +FROM +(SELECT 'crash1' AS t, f2 FROM t1) AS tt +LEFT JOIN t1 ON tt.t = 'crash2' AND tt.f2 = t1.f2 +WHERE +tt.t = 'crash1'; +t +crash1 +crash1 +DROP TABLE t1; +# Set up a query where the optimizer will attach an AND condition to ot3, +# where the AND condition is inside a trigger condition guard. +# Additionally, one of the conditions inside the AND condition is a join +# condition while the other is not. What we should see in EXPLAIN is that +# the hash join iterator uses one of these conditions as a join +# condition, while the other condition should be attached as an "extra" +# condition. +CREATE TABLE t1 (col1 INTEGER); +CREATE TABLE t2 (col1 INTEGER); +EXPLAIN FORMAT=tree +SELECT * FROM t1 LEFT JOIN t2 ON t1.col1 = t2.col1 AND RAND() < RAND(); +EXPLAIN +-> Parallel scan on + -> Left hash join (t2.col1 = t1.col1), extra conditions: (rand() < rand()) (cost=0.70 rows=1) + -> PQblock scan on t1 (cost=0.35 rows=1) + -> Hash + -> Table scan on t2 (cost=0.35 rows=1) + +DROP TABLE t1, t2; +# See that outer join with spill to disk works. +CREATE TABLE t1 (col1 BIGINT NOT NULL, col2 BIGINT NOT NULL); +INSERT INTO t1 SELECT POW(2, 0), POW(2, 0); +INSERT INTO t1 +SELECT col1 + POW(2, 0), col2 + POW(2, 0) FROM t1; +INSERT INTO t1 +SELECT col1 + POW(2, 1), col2 + POW(2, 1) FROM t1; +INSERT INTO t1 +SELECT col1 + POW(2, 2), col2 + POW(2, 2) FROM t1; +INSERT INTO t1 +SELECT col1 + POW(2, 3), col2 + POW(2, 3) FROM t1; +INSERT INTO t1 +SELECT col1 + POW(2, 4), col2 + POW(2, 4) FROM t1; +INSERT INTO t1 +SELECT col1 + POW(2, 5), col2 + POW(2, 5) FROM t1; +INSERT INTO t1 +SELECT col1 + POW(2, 6), col2 + POW(2, 6) FROM t1; +INSERT INTO t1 +SELECT col1 + POW(2, 7), col2 + POW(2, 7) FROM t1; +INSERT INTO t1 +SELECT col1 + POW(2, 8), col2 + POW(2, 8) FROM t1; +INSERT INTO t1 +SELECT col1 + POW(2, 9), col2 + POW(2, 9) FROM t1; +CREATE TABLE t2 AS SELECT * FROM t1; +UPDATE t1 SET col2 = col1 + 1 WHERE MOD(col1, 2) = 0; +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +SET join_buffer_size = 1024; +EXPLAIN FORMAT=tree SELECT SUM(t1.col1), SUM(t1.col2) FROM t1 LEFT JOIN t2 ON t1.col1 = t2.col1; +EXPLAIN +-> Aggregate: sum(`SUM(t1.col1)`), sum(`SUM(t1.col2)`) + -> Parallel scan on + -> Aggregate: + -> Left hash join (t2.col1 = t1.col1) (cost=104878.97 rows=1048576) + -> PQblock scan on t1 (cost=103.65 rows=1024) + -> Hash + -> Table scan on t2 (cost=0.12 rows=1024) + +SELECT SUM(t1.col1), SUM(t1.col2) FROM t1 LEFT JOIN t2 ON t1.col1 = t2.col1; +SUM(t1.col1) SUM(t1.col2) +524800 525312 +EXPLAIN FORMAT=tree SELECT SUM(t1.col1), SUM(t1.col2) FROM t1 +LEFT JOIN t2 ON t1.col1 = t2.col1 AND t1.col2 < t2.col2; +EXPLAIN +-> Aggregate: sum(`SUM(t1.col1)`), sum(`SUM(t1.col2)`) + -> Parallel scan on + -> Aggregate: + -> Left hash join (t2.col1 = t1.col1), extra conditions: (t1.col2 < t2.col2) (cost=104878.97 rows=1048576) + -> PQblock scan on t1 (cost=103.65 rows=1024) + -> Hash + -> Table scan on t2 (cost=0.12 rows=1024) + +SELECT SUM(t1.col1), SUM(t1.col2) FROM t1 +LEFT JOIN t2 ON t1.col1 = t2.col1 AND t1.col2 < t2.col2; +SUM(t1.col1) SUM(t1.col2) +524800 525312 +SET optimizer_switch = DEFAULT; +SET join_buffer_size = DEFAULT; +DROP TABLE t1, t2; +CREATE TABLE t1 (i INTEGER); +CREATE TABLE t2 (i INTEGER); +CREATE TABLE t3 (i INTEGER); +EXPLAIN FORMAT=tree +SELECT * FROM t1 LEFT JOIN +(t2 LEFT JOIN t3 ON ABS(t2.i) = t3.i) +ON t2.i = t1.i; +EXPLAIN +-> Parallel scan on + -> Left hash join (t2.i = t1.i) (cost=1.05 rows=1) + -> PQblock scan on t1 (cost=0.35 rows=1) + -> Hash + -> Left hash join (abs(t2.i) = t3.i) (cost=0.70 rows=1) + -> Table scan on t2 (cost=0.35 rows=1) + -> Hash + -> Table scan on t3 (cost=0.35 rows=1) + +DROP TABLE t1, t2, t3; +# See that we do not attach conditions that are always 'true' to the hash +# join iterator. +CREATE TABLE t1 (i INTEGER); +CREATE TABLE t2 (i INTEGER); +EXPLAIN FORMAT=tree SELECT * FROM t1 LEFT JOIN t2 ON 1=1; +EXPLAIN +-> Parallel scan on + -> Left hash join (no condition) (cost=0.70 rows=1) + -> PQblock scan on t1 (cost=0.35 rows=1) + -> Hash + -> Table scan on t2 (cost=0.35 rows=1) + +DROP TABLE t1, t2; +# Set up a query where the join condition is an equi-join condition, +# but it refers to only one side of the hash join (degenerate join +# predicate). This condition must be attached as an 'extra' condition +# (proper join conditions must refer to both sides of the join). +CREATE TABLE t1 (i INTEGER); +CREATE TABLE t2 (i INTEGER); +CREATE TABLE t3 (i INTEGER); +EXPLAIN FORMAT=tree +SELECT * FROM t1 LEFT JOIN (t2 LEFT JOIN t3 ON TRUE) ON t3.i = t2.i; +EXPLAIN +-> Parallel scan on + -> Left hash join (no condition) (cost=1.05 rows=1) + -> PQblock scan on t1 (cost=0.35 rows=1) + -> Hash + -> Filter: (t3.i = t2.i) (cost=0.70 rows=1) + -> Inner hash join (no condition) (cost=0.70 rows=1) + -> Table scan on t3 (cost=0.35 rows=1) + -> Hash + -> Table scan on t2 (cost=0.35 rows=1) + +DROP TABLE t1, t2, t3; +# Execute a query that causes the hash join to do everything in memory +# with multiple refills of the hash table. This can be triggered when the +# build input does not fit in memory, and the iterator is not allowed to +# spill to disk due to LIMIT in the query. +CREATE TABLE t1 (col1 VARCHAR(255)); +INSERT INTO t1 SELECT UUID(); +INSERT INTO t1 SELECT UUID() FROM t1; +INSERT INTO t1 SELECT UUID() FROM t1; +INSERT INTO t1 SELECT UUID() FROM t1; +INSERT INTO t1 SELECT UUID() FROM t1; +INSERT INTO t1 SELECT UUID() FROM t1; +INSERT INTO t1 SELECT UUID() FROM t1; +INSERT INTO t1 SELECT UUID() FROM t1; +CREATE TABLE t2 AS SELECT UUID() AS col1 FROM t1; +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +SET join_buffer_size = 128; +EXPLAIN FORMAT=tree SELECT * FROM t1 LEFT JOIN t2 ON t1.col1 = t2.col1 LIMIT 1000; +EXPLAIN +-> Limit: 1000 row(s) + -> Parallel scan on + -> Limit: 1000 row(s) (cost=1896.50 rows=1000) + -> Left hash join ((t1.col1)=(t2.col1)), extra conditions: (t1.col1 = t2.col1) (cost=1896.50 rows=16384) + -> PQblock scan on t1 (cost=13.05 rows=128) + -> Hash + -> Table scan on t2 (cost=2.10 rows=128) + +SELECT * FROM t1 LEFT JOIN t2 ON t1.col1 = t2.col1 LIMIT 1000; +SET join_buffer_size = DEFAULT; +DROP TABLE t1, t2; +# +# Bug #30631730: WL#13377: RESULT DIFF WITH LEFT HASH JOIN +# +CREATE TABLE t1 (pk INTEGER PRIMARY KEY); +INSERT INTO t1 VALUES +(1),(2),(3),(4),(5),(6),(7),(8),(9),(10),(11),(12),(13),(14),(15),(16),(17),(18),(19),(20); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN FORMAT=tree SELECT * FROM t1 AS alias1 LEFT JOIN t1 AS alias2 ON NOT EXISTS ( +SELECT * FROM t1 WHERE alias1.pk NOT IN ( 20 ) ); +EXPLAIN +-> Parallel scan on + -> Nested loop left join (cost=42.50 rows=400) + -> PQblock scan on alias1 using PRIMARY (cost=2.25 rows=20) + -> Hash antijoin (no condition) (cost=2.37 rows=20) + -> Index scan on alias2 using PRIMARY (cost=0.11 rows=20) + -> Hash + -> Limit: 1 row(s) (cost=0.11 rows=1) + -> Filter: (alias1.pk <> 20) (cost=0.11 rows=20) + -> Index scan on t1 using PRIMARY (cost=0.11 rows=20) + +Warnings: +Note 1276 Field or reference 'test.alias1.pk' of SELECT #2 was resolved in SELECT #1 +SELECT * FROM t1 AS alias1 LEFT JOIN t1 AS alias2 ON NOT EXISTS ( +SELECT * FROM t1 WHERE alias1.pk NOT IN ( 20 ) ); +pk pk +1 NULL +10 NULL +11 NULL +12 NULL +13 NULL +14 NULL +15 NULL +16 NULL +17 NULL +18 NULL +19 NULL +2 NULL +20 1 +20 10 +20 11 +20 12 +20 13 +20 14 +20 15 +20 16 +20 17 +20 18 +20 19 +20 2 +20 20 +20 3 +20 4 +20 5 +20 6 +20 7 +20 8 +20 9 +3 NULL +4 NULL +5 NULL +6 NULL +7 NULL +8 NULL +9 NULL +DROP TABLE t1; +# +# Bug #30642968: WL#13377: RESULTSET DIFFERENCE WITH HASH ANTIJOIN +# +CREATE TABLE t1 (f1 INTEGER); +INSERT INTO t1 VALUES ( 100 ), ( 200 ); +EXPLAIN FORMAT=tree SELECT * FROM t1 AS alias1 LEFT JOIN t1 AS alias2 ON alias2.f1 = alias1.f1 +AND NOT EXISTS ( SELECT * FROM t1 AS alias3 WHERE alias1.f1 <= 1 ); +EXPLAIN +-> Parallel scan on + -> Nested loop left join (cost=1.10 rows=4) + -> PQblock scan on alias1 (cost=0.45 rows=2) + -> Filter: (alias2.f1 = alias1.f1) (cost=0.68 rows=2) + -> Hash antijoin (no condition) (cost=0.68 rows=2) + -> Table scan on alias2 (cost=0.23 rows=2) + -> Hash + -> Limit: 1 row(s) (cost=0.23 rows=1) + -> Filter: (alias1.f1 <= 1) (cost=0.23 rows=2) + -> Table scan on alias3 (cost=0.23 rows=2) + +Warnings: +Note 1276 Field or reference 'test.alias1.f1' of SELECT #2 was resolved in SELECT #1 +SELECT * FROM t1 AS alias1 LEFT JOIN t1 AS alias2 ON alias2.f1 = alias1.f1 +AND NOT EXISTS ( SELECT * FROM t1 AS alias3 WHERE alias1.f1 <= 1 ); +f1 f1 +100 100 +200 200 +DROP TABLE t1; +# +# Bug #30650725: WL13476: RESULTSET DIFFERENCE WITH BKA +# +CREATE TABLE t1 ( +pk int NOT NULL, +col_datetime datetime +); +INSERT INTO t1 VALUES (9,'1988-02-06 01:32:15'); +CREATE TABLE t2 ( +col_int_key int, +col_datetime datetime, +KEY idx_N_col_int_key (col_int_key) +); +INSERT INTO t2 VALUES (9,'2025-01-07 03:12:24'); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +SET optimizer_switch='mrr=on,mrr_cost_based=off,batched_key_access=on'; +EXPLAIN FORMAT=tree SELECT * FROM +t1 AS table3 LEFT JOIN (t1 AS table1, t2 AS table2) ON table2.col_int_key=table3.pk; +EXPLAIN +-> Parallel scan on + -> Nested loop left join + -> PQblock scan on table3 (cost=0.35 rows=1) + -> Batched key access inner join + -> Batch input rows + -> Table scan on table1 (cost=0.35 rows=1) + -> Multi-range index lookup on table2 using idx_N_col_int_key (col_int_key=table3.pk) + +SELECT * FROM +t1 AS table3 LEFT JOIN (t1 AS table1, t2 AS table2) ON table2.col_int_key=table3.pk; +pk col_datetime pk col_datetime col_int_key col_datetime +9 1988-02-06 01:32:15 9 1988-02-06 01:32:15 9 2025-01-07 03:12:24 +SET optimizer_switch=DEFAULT; +DROP TABLE t1, t2; +# +# Bug #30665042: WL#13476: RESULTSET DIFFERENT NUMBER OF ROWS +# +CREATE TABLE t1 ( +pk INTEGER, +f1 varchar(1), +KEY i1 (pk) +); +INSERT INTO t1 VALUES (2,'x'); +INSERT INTO t1 VALUES (3,'x'); +INSERT INTO t1 VALUES (4,'x'); +INSERT INTO t1 VALUES (5,'x'); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +SET optimizer_switch='mrr=on,mrr_cost_based=off,batched_key_access=on'; +EXPLAIN FORMAT=tree SELECT * +FROM t1 AS table1 +LEFT JOIN ( +SELECT inner_t3.* FROM +t1 AS inner_t1 +JOIN t1 AS inner_t2 ON inner_t1.pk = inner_t2.pk +JOIN t1 AS inner_t3 ON inner_t1.f1 = inner_t2.f1 +) AS table2 ON NOT EXISTS ( +SELECT * FROM t1 WHERE table2.pk >= 1 OR table1.f1 = 'G' + ); +EXPLAIN +-> Parallel scan on + -> Nested loop left join + -> PQblock scan on table1 (cost=0.65 rows=4) + -> Batched key access inner join + -> Batch input rows + -> Inner hash join (no condition) (cost=8.66 rows=64) + -> Table scan on inner_t1 (cost=0.04 rows=4) + -> Hash + -> Hash antijoin (no condition), extra conditions: ((inner_t3.pk >= 1) or (table1.f1 = 'G')) (cost=2.01 rows=16) + -> Table scan on inner_t3 (cost=0.16 rows=4) + -> Hash + -> Index scan on t1 using i1 (cost=0.16 rows=4) + -> Filter: (inner_t2.f1 = inner_t1.f1) + -> Multi-range index lookup on inner_t2 using i1 (pk=inner_t1.pk) + +Warnings: +Note 1276 Field or reference 'table2.pk' of SELECT #3 was resolved in SELECT #1 +Note 1276 Field or reference 'test.table1.f1' of SELECT #3 was resolved in SELECT #1 +SELECT * +FROM t1 AS table1 +LEFT JOIN ( +SELECT inner_t3.* FROM +t1 AS inner_t1 +JOIN t1 AS inner_t2 ON inner_t1.pk = inner_t2.pk +JOIN t1 AS inner_t3 ON inner_t1.f1 = inner_t2.f1 +) AS table2 ON NOT EXISTS ( +SELECT * FROM t1 WHERE table2.pk >= 1 OR table1.f1 = 'G' + ); +pk f1 pk f1 +2 x NULL NULL +3 x NULL NULL +4 x NULL NULL +5 x NULL NULL +SET optimizer_switch=DEFAULT; +DROP TABLE t1; +# +# Bug#30520749 - REGRESSION: LEFT JOIN WITH IMPOSSIBLE ON CONDITION PERFORMS SLOWLY +# +CREATE TABLE t1 ( f1 INTEGER ); +INSERT INTO t1 VALUES (1), (2), (3), (4), (5); +CREATE TABLE t2 AS SELECT * FROM t1; +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN FORMAT=tree SELECT * FROM t1 LEFT JOIN t2 ON 1=2; +EXPLAIN +-> Parallel scan on + -> Left hash join (no condition) (cost=0.25 rows=0) + -> PQblock scan on t1 (cost=0.75 rows=5) + -> Hash + -> Zero rows (Impossible filter) (cost=0.00..0.00 rows=0) + +EXPLAIN FORMAT=tree SELECT * FROM t1 LEFT JOIN t2 ON t2.f1 > 3; +EXPLAIN +-> Parallel scan on + -> Left hash join (no condition) (cost=2.90 rows=25) + -> PQblock scan on t1 (cost=0.75 rows=5) + -> Hash + -> Filter: (t2.f1 > 3) (cost=0.15 rows=5) + -> Table scan on t2 (cost=0.15 rows=5) + +EXPLAIN FORMAT=tree SELECT * FROM t1 LEFT JOIN t2 ON t1.f1 > 3; +EXPLAIN +-> Parallel scan on + -> Left hash join (no condition), extra conditions: (t1.f1 > 3) (cost=2.90 rows=25) + -> PQblock scan on t1 (cost=0.75 rows=5) + -> Hash + -> Table scan on t2 (cost=0.15 rows=5) + +DROP TABLE t1, t2; +# +# Bug #30664671: HASH JOINS : CRASH WITH COMPARING DIFFERENT CHARSET +# Bug #30664831: SEVERE PERFORMANCE REGRESSION JOINING ON MEDIUMTEXT COLUMNS! +# +CREATE TABLE t1 ( +a LONGTEXT COLLATE utf32_sinhala_ci +); +INSERT INTO t1 (a) VALUES ('abc'); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN FORMAT=tree SELECT 1 FROM t1 JOIN t1 AS t2 ON t1.a=t2.a; +EXPLAIN +-> Filter: (t2.a = t1.a) (cost=0.72 rows=1) + -> Inner hash join ((t2.a)=(t1.a)) (cost=0.72 rows=1) + -> Table scan on t2 (cost=0.37 rows=1) + -> Hash + -> Table scan on t1 (cost=0.35 rows=1) + +SELECT 1 FROM t1 JOIN t1 AS t2 ON t1.a=t2.a; +1 +1 +EXPLAIN FORMAT=tree SELECT 1 FROM t1 LEFT JOIN t1 AS t2 ON t1.a=t2.a; +EXPLAIN +-> Parallel scan on + -> Left hash join ((t2.a)=(t1.a)), extra conditions: (t2.a = t1.a) (cost=0.73 rows=1) + -> PQblock scan on t1 (cost=0.35 rows=1) + -> Hash + -> Table scan on t2 (cost=0.37 rows=1) + +SELECT 1 FROM t1 LEFT JOIN t1 AS t2 ON t1.a=t2.a; +1 +1 +DROP TABLE t1; +# +# Bug#30716607 SIG11 IN WELL_FORMED_COPY_NCHARS() AT +# SQL-COMMON/SQL_STRING.CC +# Bug#30648809 HASH_JOIN_BUFFER::LOADINTOTABLEBUFFERS() HITS AN ASSERT +# AND CRASH +CREATE TABLE t1 ( +str_col VARCHAR(1) +); +CREATE TABLE t2 ( +i INTEGER, +str_col VARCHAR(1), +PRIMARY KEY (i), +KEY idx (str_col) +); +CREATE TABLE t3 (i INTEGER); +INSERT INTO t1 VALUES ('r'), ('s'); +INSERT INTO t2 VALUES (9,'s'), (11,'o'); +ANALYZE TABLE t1, t2, t3; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +SET sql_mode = ''; +EXPLAIN FORMAT=tree SELECT 1 FROM t1 RIGHT JOIN t2 ON t2.str_col = t1.str_col +WHERE (t1.str_col, t1.str_col) NOT IN ( +SELECT c1_1.str_col, MIN(c1_2.str_col) +FROM t2 AS c1_1 INNER JOIN t2 AS c1_2 STRAIGHT_JOIN t3 ON t3.i = c1_2.i +); +EXPLAIN +-> Filter: ((t1.str_col,t1.str_col),(select #2) is false) (cost=0.88 rows=4) + -> Left hash join (t1.str_col = t2.str_col) (cost=0.88 rows=4) + -> Index scan on t2 using idx (cost=0.45 rows=2) + -> Hash + -> Table scan on t1 (cost=0.23 rows=2) + -> Select #2 (subquery in condition; dependent) + -> Limit: 1 row(s) + -> Filter: ((outer_field_is_not_null, (((t1.str_col) = c1_1.str_col) or (c1_1.str_col is null)), true) and (outer_field_is_not_null, (((t1.str_col) = min(c1_2.str_col)) or (min(c1_2.str_col) is null)), true) and (outer_field_is_not_null, (c1_1.str_col), true) and (outer_field_is_not_null, (min(c1_2.str_col)), true)) + -> Aggregate: min(c1_2.str_col) + -> Inner hash join (t3.i = c1_2.i) (cost=1.75 rows=4) + -> Table scan on t3 (cost=0.09 rows=1) + -> Hash + -> Inner hash join (no condition) (cost=1.10 rows=4) + -> Index scan on c1_2 using idx (cost=0.23 rows=2) + -> Hash + -> Index scan on c1_1 using idx (cost=0.45 rows=2) + +SELECT 1 FROM t1 RIGHT JOIN t2 ON t2.str_col = t1.str_col +WHERE (t1.str_col, t1.str_col) NOT IN ( +SELECT c1_1.str_col, MIN(c1_2.str_col) +FROM t2 AS c1_1 INNER JOIN t2 AS c1_2 STRAIGHT_JOIN t3 ON t3.i = c1_2.i +); +SET sql_mode = DEFAULT; +DROP TABLE t1, t2, t3; +# +# Bug#30738687 CRASH IN HASHJOINCONDITION::HASHJOINCONDITION +# +CREATE TABLE t ( +c TEXT +); +EXPLAIN FORMAT=tree SELECT c FROM +( +SELECT 1 AS c FROM t AS a +RIGHT JOIN t AS b ON 1 +RIGHT JOIN t AS c ON 1 +RIGHT JOIN t AS d ON 1 +) AS z +NATURAL RIGHT JOIN t; +EXPLAIN +-> Left hash join (t.c = 1) (cost=1.83 rows=1) + -> Table scan on t (cost=0.35 rows=1) + -> Hash + -> Left hash join (no condition) (cost=1.46 rows=1) + -> Table scan on d (cost=0.37 rows=1) + -> Hash + -> Left hash join (no condition) (cost=1.10 rows=1) + -> Table scan on c (cost=0.37 rows=1) + -> Hash + -> Left hash join (no condition) (cost=0.73 rows=1) + -> Table scan on b (cost=0.37 rows=1) + -> Hash + -> Table scan on a (cost=0.37 rows=1) + +DROP TABLE t; +# +# Bug#30741679 ASSERTION `FALSE' IN EXTRACT_VALUE_FOR_HASH_JOIN +# Bug#30769883 HIT ASSERT IN +# ITEM_FUNC_EQ::APPEND_JOIN_KEY_FOR_HASH_JOIN() +# +CREATE TABLE t1 ( +a INTEGER, +b INTEGER +); +INSERT INTO t1 VALUES (1, 1); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN FORMAT=tree SELECT * FROM t1 as table1 +WHERE (SELECT a, b FROM t1 WHERE table1.a <> 6) IN (SELECT a, b FROM t1); +EXPLAIN +-> Hash semijoin (no condition), extra conditions: ((select #2) = (t1.a,t1.b)) (cost=0.70 rows=1) + -> Table scan on table1 (cost=0.35 rows=1) + -> Hash + -> Table scan on t1 (cost=0.35 rows=1) + +Warnings: +Note 1276 Field or reference 'test.table1.a' of SELECT #2 was resolved in SELECT #1 +SELECT * FROM t1 as table1 +WHERE (SELECT a, b FROM t1 WHERE table1.a <> 6) IN (SELECT a, b FROM t1); +a b +1 1 +EXPLAIN FORMAT=tree SELECT * FROM t1 as table1 +WHERE (SELECT a FROM t1 WHERE table1.a <> 6) IN (SELECT a FROM t1); +EXPLAIN +-> Hash semijoin ((select #2) = (t1.a)) (cost=0.70 rows=1) + -> Table scan on table1 (cost=0.35 rows=1) + -> Hash + -> Table scan on t1 (cost=0.35 rows=1) + +Warnings: +Note 1276 Field or reference 'test.table1.a' of SELECT #2 was resolved in SELECT #1 +SELECT * FROM t1 as table1 +WHERE (SELECT a FROM t1 WHERE table1.a <> 6) IN (SELECT a FROM t1); +a b +1 1 +DROP TABLE t1; +# +# Bug#30792727 ERRORS WHEN BUILDING HASH TABLE FOR HASH JOIN NOT +# PROPAGATED +# +CREATE TABLE t (i INTEGER); +INSERT INTO t VALUES (1), (2); +EXPLAIN FORMAT=tree SELECT * FROM t t1, t t2 WHERE JSON_EXTRACT(t1.i, t1.i) = t2.i; +EXPLAIN +-> Inner hash join (json_extract(t1.i,t1.i) = t2.i) (cost=1.10 rows=2) + -> Table scan on t2 (cost=0.18 rows=2) + -> Hash + -> Table scan on t1 (cost=0.45 rows=2) + +SELECT * FROM t t1, t t2 WHERE JSON_EXTRACT(t1.i, t1.i) = t2.i; +ERROR 22032: Invalid data type for JSON data in argument 1 to function json_extract; a JSON string or JSON type is required. +SHOW ERRORS; +Level Code Message +Error 3146 Invalid data type for JSON data in argument 1 to function json_extract; a JSON string or JSON type is required. +DROP TABLE t; +# +# Bug #31102789 A PREDICATE THAT COMPARES 0 WITH -0 +# YIELDS AN INCORRECT RESULT +# +CREATE TABLE t0(c0 INT); +CREATE TABLE t1(c0 DOUBLE); +CREATE TABLE t2(c0 DOUBLE); +INSERT INTO t0 VALUES(0); +INSERT INTO t1 VALUES('-0'); +INSERT INTO t2 VALUES('+0'); +SELECT * FROM t0, t1 WHERE t0.c0 = t1.c0; +c0 c0 +0 -0 +SELECT * FROM t1, t2 WHERE t1.c0 = t2.c0; +c0 c0 +-0 0 +SELECT * FROM t0, t2 WHERE t0.c0 = t2.c0; +c0 c0 +0 0 +DROP TABLE t0, t1, t2; +# +# Bug #31376809: PERFORMANCE REGRESSION FROM 5.7->8.0, DUE TO ANTIJOIN OF NOT EXISTS SUBQUERY +# +CREATE TABLE t1 (a INTEGER NOT NULL, b INTEGER); +INSERT INTO t1 VALUES (1,1),(2,2),(3,3),(4,4),(5,5); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN ANALYZE SELECT t1.a FROM t1 LEFT JOIN t1 AS t2 ON TRUE WHERE t2.a IS NULL; +EXPLAIN +-> Parallel scan on (actual time=N.NNN..N.NNN rows=0 loops=1) + -> Filter: (t2.a is null) (cost=1.30 rows=1) (actual time=N.NNN..N.NNN rows=0 loops=1) + -> Hash antijoin (no condition) (cost=1.30 rows=1) (actual time=N.NNN..N.NNN rows=0 loops=1) + -> PQblock scan on t1 (cost=0.75 rows=5) (never executed) + -> Hash + -> Limit: 1 row(s) (cost=0.15 rows=1) (actual time=N.NNN..N.NNN rows=1 loops=1) + -> Table scan on t2 (cost=0.15 rows=5) (actual time=N.NNN..N.NNN rows=1 loops=1) + +DROP TABLE t1; +# +# Bug #31563414: REGRESSION: ITEM_FUNC_EQ::APPEND_JOIN_KEY_FOR_HASH_JOIN CONST: ASSERTION `FALSE' FAILED. +# +CREATE TABLE t1 (a INTEGER NOT NULL); +INSERT INTO t1 VALUES (1),(2),(3),(4); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN FORMAT=tree SELECT * +FROM t1 AS a +LEFT JOIN t1 AS b ON FALSE +LEFT JOIN t1 AS c ON b.a=c.a; +EXPLAIN +-> Parallel scan on + -> Left hash join (no condition) (cost=0.25 rows=0) + -> Left hash join (no condition) (cost=0.25 rows=0) + -> PQblock scan on a (cost=0.65 rows=4) + -> Hash + -> Zero rows (Impossible filter) (cost=0.00..0.00 rows=0) + -> Hash + -> Zero rows (Join condition (c.a = b.a) requires pruned table) (cost=0.00..0.00 rows=0) + +SELECT * +FROM t1 AS a +LEFT JOIN t1 AS b ON FALSE +LEFT JOIN t1 AS c ON b.a=c.a; +a a a +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +DROP TABLE t1; +# +# Bug #31940549: NEW MEMORY LEAK ON TRUNK RELATING TO HASHJOINITERATOR::BUILDHASHTABLE , OPEN_CACHED_FILE +# +SET join_buffer_size=32768; +CREATE TABLE t(a DOUBLE NOT NULL, b VARCHAR(15873) NOT NULL); +INSERT INTO t VALUES(1, REPEAT('abs',1000)); +INSERT INTO t VALUES(2, REPEAT('ajs',1000)); +INSERT INTO t VALUES(3, REPEAT('ajj',1000)); +INSERT INTO t VALUES(4, REPEAT('jjs',1000)); +INSERT INTO t SELECT * FROM t; +INSERT INTO t SELECT * FROM t; +SELECT +( +SELECT 1 FROM (SELECT t_outer.a) Z LEFT JOIN t +ON t.a > t.b LIMIT 1 +) FROM t AS t_outer; +( +SELECT 1 FROM (SELECT t_outer.a) Z LEFT JOIN t +ON t.a > t.b LIMIT 1 +) +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +DROP TABLE t; +SET join_buffer_size=DEFAULT; +# +# Bug #31832001 HASH JOIN MISMATCHES SIGNED AND UNSIGNED +# +CREATE TABLE t2 (c1 BIGINT NOT NULL); +CREATE TABLE t13 (c1 BIGINT UNSIGNED NOT NULL); +INSERT INTO t2 VALUES (-1),(1); +INSERT INTO t13 VALUES (18446744073709551615),(1); +SELECT * FROM t2 JOIN t13 WHERE t2.c1=t13.c1; +c1 c1 +1 1 +SELECT /*+ NO_BNL(t2,t13) */ * FROM t2 JOIN t13 WHERE t2.c1=t13.c1; +c1 c1 +1 1 +DROP TABLE t2, t13; +# +# Bug #32244974: SIG 6 IN HASHJOINITERATOR::READROWFROMPROBEITERATOR() AT HASH_JOIN_ITERATOR.CC +# +CREATE TABLE t1 ( +pk INTEGER, +col_int INTEGER, +PRIMARY KEY (pk) +); +CREATE TABLE t2 ( +pk INTEGER, +col_int INTEGER +); +INSERT INTO t1 VALUES (2,6); +INSERT INTO t1 VALUES (3,NULL); +INSERT INTO t2 VALUES (1,6); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +SELECT 1 +FROM +t1 AS alias1 +JOIN t2 AS alias2 ON alias1.col_int = alias2.col_int +JOIN t1 AS alias3 ON 1 +WHERE +( SELECT 1 UNION SELECT MAX(alias1.pk) ) = alias3.pk; +ERROR 21000: Subquery returns more than 1 row +DROP TABLE t1, t2; +# Bug#32579184: Hash join: my_lengthsp_utf32: assertion (length % 4) +CREATE TABLE t ( +a TEXT CHARACTER SET ucs2 COLLATE ucs2_sinhala_ci, +b TEXT CHARACTER SET utf32 COLLATE utf32_german2_ci +); +INSERT INTO t(a, b) VALUES('h','k'), ('w','e'); +explain SELECT 1 FROM t AS a INNER JOIN t AS b ON a.a=b.b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE a NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE b NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t` `a` join `test`.`t` `b` where (`test`.`a`.`a` = `test`.`b`.`b`) +SELECT 1 FROM t AS a INNER JOIN t AS b ON a.a=b.b; +1 +DROP TABLE t; diff --git a/mysql-test/r/having.result-pq b/mysql-test/r/having.result-pq new file mode 100644 index 000000000000..3faefb8c032b --- /dev/null +++ b/mysql-test/r/having.result-pq @@ -0,0 +1,936 @@ +drop table if exists t1,t2,t3; +create table t1 (a int); +select count(a) as b from t1 where a=0 having b > 0; +b +insert into t1 values (null); +select count(a) as b from t1 where a=0 having b > 0; +b +select count(a) as b from t1 where a=0 having b >=0; +b +0 +analyze table t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +explain select count(a) as b from t1 where a=0 having b >=0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select count(`test`.`t1`.`a`) AS `b` from `test`.`t1` where (`test`.`t1`.`a` = 0) having (`b` >= 0) +drop table t1; +CREATE TABLE t1 ( +raw_id int(10) NOT NULL default '0', +chr_start int(10) NOT NULL default '0', +chr_end int(10) NOT NULL default '0', +raw_start int(10) NOT NULL default '0', +raw_end int(10) NOT NULL default '0', +raw_ori int(2) NOT NULL default '0' +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (469713,1,164123,1,164123,1),(317330,164124,317193,101,153170,1),(469434,317194,375620,101,58527,1),(591816,375621,484273,1,108653,1),(591807,484274,534671,91,50488,1),(318885,534672,649362,101,114791,1),(318728,649363,775520,102,126259,1),(336829,775521,813997,101,38577,1),(317740,813998,953227,101,139330,1),(1,813998,953227,101,139330,1); +CREATE TABLE t2 ( +id int(10) unsigned NOT NULL default '0', +contig_id int(10) unsigned NOT NULL default '0', +seq_start int(10) NOT NULL default '0', +seq_end int(10) NOT NULL default '0', +strand tinyint(2) NOT NULL default '0', +KEY id (id) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (133195,469713,61327,61384,1),(133196,469713,64113,64387,1),(133197,1,1,1,0),(133197,1,1,1,-2); +SELECT e.id, +MIN( IF(sgp.raw_ori=1, +(e.seq_start+sgp.chr_start-sgp.raw_start), +(sgp.chr_start+sgp.raw_end-e.seq_end))) as start, +MAX( IF(sgp.raw_ori=1, +(e.seq_end+sgp.chr_start-sgp.raw_start), +(sgp.chr_start+sgp.raw_end-e.seq_start))) as end, +AVG(IF (sgp.raw_ori=1,e.strand,(-e.strand))) as chr_strand +FROM t1 sgp, +t2 e +WHERE sgp.raw_id=e.contig_id +GROUP BY e.id +HAVING chr_strand= -1 and end >= 0 +AND start <= 999660; +id start end chr_strand +133197 813898 813898 -1.0000 +drop table t1,t2; +CREATE TABLE t1 (Fld1 int(11) default NULL,Fld2 int(11) default NULL); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (1,10),(1,20),(2,NULL),(2,NULL),(3,50); +select Fld1, max(Fld2) as q from t1 group by Fld1 having q is not null; +Fld1 q +1 20 +3 50 +select Fld1, max(Fld2) from t1 group by Fld1 having max(Fld2) is not null; +Fld1 max(Fld2) +1 20 +3 50 +select Fld1, max(Fld2) from t1 group by Fld1 having avg(Fld2) is not null; +Fld1 max(Fld2) +1 20 +3 50 +select Fld1, max(Fld2) from t1 group by Fld1 having std(Fld2) is not null; +Fld1 max(Fld2) +1 20 +3 50 +select Fld1, max(Fld2) from t1 group by Fld1 having variance(Fld2) is not null; +Fld1 max(Fld2) +1 20 +3 50 +drop table t1; +create table t1 (id int not null, qty int not null); +insert into t1 values (1,2),(1,3),(2,4),(2,5); +select id, sum(qty) as sqty from t1 group by id having sqty>2; +id sqty +1 5 +2 9 +select sum(qty) as sqty from t1 group by id having count(id) > 0; +sqty +5 +9 +select sum(qty) as sqty from t1 group by id having count(distinct id) > 0; +sqty +5 +9 +drop table t1; +CREATE TABLE t1 ( +`id` bigint(20) NOT NULL default '0', +`description` text +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t2 ( +`id` bigint(20) NOT NULL default '0', +`description` varchar(20) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (1, 'test'); +INSERT INTO t2 VALUES (1, 'test'); +CREATE TABLE t3 ( +`id` bigint(20) NOT NULL default '0', +`order_id` bigint(20) NOT NULL default '0' +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +select +a.id, a.description, +count(b.id) as c +from t1 a left join t3 b on a.id=b.order_id +group by a.id, a.description +having (a.description is not null) and (c=0); +id description c +1 test 0 +select +a.*, +count(b.id) as c +from t2 a left join t3 b on a.id=b.order_id +group by a.id, a.description +having (a.description is not null) and (c=0); +id description c +1 test 0 +INSERT INTO t1 VALUES (2, 'test2'); +select +a.id, a.description, +count(b.id) as c +from t1 a left join t3 b on a.id=b.order_id +group by a.id, a.description +having (a.description is not null) and (c=0); +id description c +1 test 0 +2 test2 0 +drop table t1,t2,t3; +CREATE TABLE t1 (a int); +INSERT INTO t1 VALUES (3), (4), (1), (3), (1); +SELECT SUM(a) FROM t1 GROUP BY a HAVING SUM(a)>0; +SUM(a) +2 +4 +6 +SELECT SUM(a) FROM t1 GROUP BY a HAVING SUM(a); +SUM(a) +2 +4 +6 +DROP TABLE t1; +CREATE TABLE t1 (a int); +INSERT INTO t1 VALUES (1), (2), (1), (3), (2), (1); +SELECT a FROM t1 GROUP BY a HAVING a > 1; +a +2 +3 +SELECT a FROM t1 GROUP BY a HAVING 1 != 1 AND a > 1; +a +SELECT 0 AS x, a FROM t1 GROUP BY x,a HAVING x=1 AND a > 1; +x a +analyze table t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT a FROM t1 GROUP BY a HAVING 1 != 1 AND a > 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible HAVING +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` group by `test`.`t1`.`a` having false +EXPLAIN SELECT 0 AS x, a FROM t1 GROUP BY x,a HAVING x=1 AND a > 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible HAVING +Warnings: +Note 1003 /* select#1 */ select 0 AS `x`,`test`.`t1`.`a` AS `a` from `test`.`t1` group by `x`,`test`.`t1`.`a` having false +DROP table t1; +CREATE TABLE t1 (a int PRIMARY KEY); +CREATE TABLE t2 (b int PRIMARY KEY, a int); +CREATE TABLE t3 (b int, flag int); +INSERT INTO t1 VALUES (1); +INSERT INTO t2 VALUES (1,1), (2,1), (3,1); +INSERT INTO t3(b,flag) VALUES (2, 1); +SELECT t1.a +FROM t1 INNER JOIN t2 ON t1.a=t2.a LEFT JOIN t3 ON t2.b=t3.b +GROUP BY t1.a, t2.b HAVING MAX(t3.flag)=0; +a +SELECT DISTINCT t1.a, MAX(t3.flag) +FROM t1 INNER JOIN t2 ON t1.a=t2.a LEFT JOIN t3 ON t2.b=t3.b +GROUP BY t1.a, t2.b HAVING MAX(t3.flag)=0; +a MAX(t3.flag) +SELECT DISTINCT t1.a +FROM t1 INNER JOIN t2 ON t1.a=t2.a LEFT JOIN t3 ON t2.b=t3.b +GROUP BY t1.a, t2.b HAVING MAX(t3.flag)=0; +a +DROP TABLE t1,t2,t3; +create table t1 (col1 int, col2 varchar(5), col_t1 int); +create table t2 (col1 int, col2 varchar(5), col_t2 int); +create table t3 (col1 int, col2 varchar(5), col_t3 int); +insert into t1 values(10,'hello',10); +insert into t1 values(20,'hello',20); +insert into t1 values(30,'hello',30); +insert into t1 values(10,'bye',10); +insert into t1 values(10,'sam',10); +insert into t1 values(10,'bob',10); +insert into t2 select * from t1; +insert into t3 select * from t1; +select count(*) from t1 group by col1 having col1 = 10; +count(*) +4 +select count(*) as count_col1 from t1 group by col1 having col1 = 10; +count_col1 +4 +select count(*) as count_col1 from t1 as tmp1 group by col1 having col1 = 10; +count_col1 +4 +select count(*) from t1 group by col2 having col2 = 'hello'; +count(*) +3 +select count(*) from t1 group by col2 having col1 = 10; +ERROR 42S22: Unknown column 'col1' in 'having clause' +select col1 as count_col1 from t1 as tmp1 group by col1 having col1 = 10; +count_col1 +10 +select col1 as count_col1 from t1 as tmp1 group by col1 having count_col1 = 10; +count_col1 +10 +select col1 as count_col1 from t1 as tmp1 group by count_col1 having col1 = 10; +count_col1 +10 +select col1 as count_col1 from t1 as tmp1 group by count_col1 having count_col1 = 10; +count_col1 +10 +select col1 as count_col1,col2 from t1 as tmp1 group by col1,col2 having col1 = 10; +count_col1 col2 +10 bob +10 bye +10 hello +10 sam +select col1 as count_col1,col2 from t1 as tmp1 group by col1,col2 having count_col1 = 10; +count_col1 col2 +10 bob +10 bye +10 hello +10 sam +select col1 as count_col1,col2 from t1 as tmp1 group by col1,col2 having col2 = 'hello'; +count_col1 col2 +10 hello +20 hello +30 hello +select col1 as count_col1,col2 as group_col2 from t1 as tmp1 group by col1,col2 having group_col2 = 'hello'; +count_col1 group_col2 +10 hello +20 hello +30 hello +select sum(col1) as co12 from t1 group by col2 having col2 10; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '10' at line 1 +select sum(col1) as co2, count(col2) as cc from t1 group by col1 having col1 =10; +co2 cc +40 4 +select t2.col2 from t2 group by t2.col1, t2.col2 having t1.col1 <= 10; +ERROR 42S22: Unknown column 't1.col1' in 'having clause' +select t1.col1 from t1 +where t1.col2 in +(select t2.col2 from t2 +group by t2.col1, t2.col2 having t2.col1 <= 10); +col1 +10 +20 +30 +10 +10 +10 +select t1.col1 from t1 +where t1.col2 in +(select t2.col2 from t2 +group by t2.col1, t2.col2 +having t2.col1 <= +(select min(t3.col1) from t3)); +col1 +10 +20 +30 +10 +10 +10 +select t1.col1 from t1 +where t1.col2 in +(select t2.col2 from t2 +group by t2.col1, t2.col2 having t1.col1 <= 10); +col1 +10 +10 +10 +10 +select t1.col1 from t1 +where t1.col2 in +(select t2.col2 from t2 +group by t2.col1, t2.col2 having col_t1 <= 10); +col1 +10 +10 +10 +10 +select sum(col1) from t1 +group by col_t1 +having (select col_t1 from t2 where col_t1 = col_t2 order by col_t2 limit 1); +sum(col1) +40 +20 +30 +select t1.col1 from t1 +where t1.col2 in +(select t2.col2 from t2 +group by t2.col1, t2.col2 having col_t1 <= 10) +having col_t1 <= 20; +ERROR 42S22: Unknown column 'col_t1' in 'having clause' +select t1.col1 from t1 +where t1.col2 in +(select t2.col2 from t2 +group by t2.col1, t2.col2 having col_t1 <= 10) +group by col_t1 +having col_t1 <= 20; +col1 +10 +select col_t1, sum(col1) from t1 +group by col_t1 +having col_t1 > 10 and +exists (select sum(t2.col1) from t2 +group by t2.col2 having t2.col2 > 'b'); +col_t1 sum(col1) +20 20 +30 30 +select sum(col1) from t1 +group by col_t1 +having col_t1 in (select sum(t2.col1) from t2 +group by t2.col2, t2.col1 having t2.col1 = t1.col1); +ERROR 42S22: Unknown column 't1.col1' in 'having clause' +select sum(col1) from t1 +group by col_t1 +having col_t1 in (select sum(t2.col1) from t2 +group by t2.col2, t2.col1 having t2.col1 = col_t1); +sum(col1) +40 +20 +30 +select t1.col1, t2.col1 from t1, t2 where t1.col1 = t2.col1 +group by t1.col1, t2.col1 having col1 = 2; +ERROR 23000: Column 'col1' in having clause is ambiguous +select t1.col1*10+t2.col1 from t1,t2 where t1.col1=t2.col1 +group by t1.col1, t2.col1 having col1 = 2; +ERROR 23000: Column 'col1' in having clause is ambiguous +drop table t1, t2, t3; +create table t1 (s1 int); +insert into t1 values (1),(2),(3); +select count(*) from t1 group by s1 having s1 is null; +count(*) +select s1*0 as s1 from t1 group by s1 having s1 <> 0; +s1 +0 +0 +0 +Warnings: +Warning 1052 Column 's1' in group statement is ambiguous +Warning 1052 Column 's1' in having clause is ambiguous +Warning 1052 Column 's1' in having clause is ambiguous +Warning 1052 Column 's1' in having clause is ambiguous +select s1*0 from t1 group by s1 having s1 = 0; +s1*0 +select s1 from t1 group by 1 having 1 = 0; +s1 +select count(s1) from t1 group by s1 having count(1+1)=2; +count(s1) +select count(s1) from t1 group by s1 having s1*0=0; +count(s1) +1 +1 +1 +select * from t1 a, t1 b group by a.s1 having s1 is null; +ERROR 23000: Column 's1' in having clause is ambiguous +drop table t1; +set names latin1; +create table t1 (s1 char character set latin1 collate latin1_german1_ci); +insert ignore into t1 values ('ü'),('y'); +Warnings: +Warning 1265 Data truncated for column 's1' at row 1 +select s1,count(s1) from t1 +group by s1 collate latin1_swedish_ci having s1 = 'y'; +s1 count(s1) +y 1 +set names utf8mb4; +drop table t1; +DROP SCHEMA IF EXISTS HU; +CREATE SCHEMA HU ; +USE HU ; +CREATE TABLE STAFF +(EMPNUM CHAR(3) NOT NULL UNIQUE, +EMPNAME CHAR(20), +GRADE DECIMAL(4), +CITY CHAR(15)); +CREATE TABLE PROJ +(PNUM CHAR(3) NOT NULL UNIQUE, +PNAME CHAR(20), +PTYPE CHAR(6), +BUDGET DECIMAL(9), +CITY CHAR(15)); +INSERT INTO STAFF VALUES ('E1','Alice',12,'Deale'); +INSERT INTO STAFF VALUES ('E2','Betty',10,'Vienna'); +INSERT INTO STAFF VALUES ('E3','Carmen',13,'Vienna'); +INSERT INTO STAFF VALUES ('E4','Don',12,'Deale'); +INSERT INTO STAFF VALUES ('E5','Ed',13,'Akron'); +INSERT INTO PROJ VALUES ('P1','MXSS','Design',10000,'Deale'); +INSERT INTO PROJ VALUES ('P2','CALM','Code',30000,'Vienna'); +INSERT INTO PROJ VALUES ('P3','SDP','Test',30000,'Tampa'); +INSERT INTO PROJ VALUES ('P4','SDP','Design',20000,'Deale'); +INSERT INTO PROJ VALUES ('P5','IRM','Test',10000,'Vienna'); +INSERT INTO PROJ VALUES ('P6','PAYR','Design',50000,'Deale'); +SELECT EMPNUM, GRADE*1000 +FROM HU.STAFF WHERE GRADE * 1000 > +ANY (SELECT SUM(BUDGET) FROM HU.PROJ +GROUP BY CITY, PTYPE +HAVING HU.PROJ.CITY = HU.STAFF.CITY); +EMPNUM GRADE*1000 +E3 13000 +DROP SCHEMA HU; +USE test; +create table t1(f1 int); +select f1 from t1 having max(f1)=f1; +f1 +select f1 from t1 group by f1 having max(f1)=f1; +f1 +set session sql_mode='ONLY_FULL_GROUP_BY'; +select f1 from t1 having max(f1)=f1; +ERROR 42000: In aggregated query without GROUP BY, expression #1 of SELECT list contains nonaggregated column 'test.t1.f1'; this is incompatible with sql_mode=only_full_group_by +select f1 from t1 group by f1 having max(f1)=f1; +f1 +set session sql_mode=''; +drop table t1; +CREATE TABLE t1 ( a INT, b INT); +INSERT INTO t1 VALUES (1, 1), (2,2), (3, NULL); +SELECT b, COUNT(DISTINCT a) FROM t1 GROUP BY b HAVING b is NULL; +b COUNT(DISTINCT a) +NULL 1 +DROP TABLE t1; +# +# Bug#50995 Having clause on subquery result produces incorrect results. +# +CREATE TABLE t1 +( +id1 INT, +id2 INT NOT NULL, +INDEX id1(id2) +); +INSERT INTO t1 SET id1=1, id2=1; +INSERT INTO t1 SET id1=2, id2=1; +INSERT INTO t1 SET id1=3, id2=1; +SELECT t1.id1, +(SELECT 0 FROM DUAL +WHERE t1.id1=t1.id1) AS amount FROM t1 +WHERE t1.id2 = 1 +HAVING amount > 0 +ORDER BY t1.id1; +id1 amount +DROP TABLE t1; +# +# Bug#48916 Server incorrectly processing HAVING clauses with an ORDER BY clause +# +CREATE TABLE t1 (f1 INT PRIMARY KEY, f2 INT, f3 INT); +INSERT INTO t1 VALUES (2,7,9), (4,7,9), (6,2,9), (17,0,9); +SELECT table1.f1, table2.f2 +FROM t1 AS table1 +JOIN t1 AS table2 ON table1.f3 = table2.f3 +WHERE table2.f1 = 2 +GROUP BY table1.f1, table2.f2 +HAVING (table2.f2 = 8 AND table1.f1 >= 6); +f1 f2 +EXPLAIN +SELECT table1.f1, table2.f2 +FROM t1 AS table1 +JOIN t1 AS table2 ON table1.f3 = table2.f3 +WHERE table2.f1 = 2 +GROUP BY table1.f1, table2.f2 +HAVING (table2.f2 = 8 AND table1.f1 >= 6); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible HAVING noticed after reading const tables +Warnings: +Note 1003 /* select#1 */ select `test`.`table1`.`f1` AS `f1`,'7' AS `f2` from `test`.`t1` `table1` join `test`.`t1` `table2` where ((`test`.`table1`.`f3` = '9')) group by `test`.`table1`.`f1`,'7' having false +EXPLAIN +SELECT table1.f1, table2.f2 +FROM t1 AS table1 +JOIN t1 AS table2 ON table1.f3 = table2.f3 +WHERE table2.f1 = 2 +GROUP BY table1.f1, table2.f2 +HAVING (table2.f2 = 8); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible HAVING noticed after reading const tables +Warnings: +Note 1003 /* select#1 */ select `test`.`table1`.`f1` AS `f1`,'7' AS `f2` from `test`.`t1` `table1` join `test`.`t1` `table2` where ((`test`.`table1`.`f3` = '9')) group by `test`.`table1`.`f1`,'7' having false +DROP TABLE t1; +# +# Bug#52336 Segfault / crash in 5.1 copy_fields (param=0x9872980) at sql_select.cc:15355 +# +CREATE TABLE t1(f1 INT, f2 INT); +INSERT INTO t1 VALUES (10,8); +CREATE TABLE t2 (f1 INT); +INSERT INTO t2 VALUES (5); +SELECT COUNT(f1) FROM t2 +HAVING (7, 9) IN (SELECT f1, MIN(f2) FROM t1); +COUNT(f1) +DROP TABLE t1, t2; +CREATE TABLE t1 (f1 INT, f2 VARCHAR(1)); +INSERT INTO t1 VALUES (16,'f'); +INSERT INTO t1 VALUES (16,'f'); +CREATE TABLE t2 (f1 INT, f2 VARCHAR(1)); +INSERT INTO t2 VALUES (13,'f'); +INSERT INTO t2 VALUES (20,'f'); +CREATE TABLE t3 (f1 INT, f2 VARCHAR(1)); +INSERT INTO t3 VALUES (7,'f'); +SELECT t1.f2 FROM t1 +STRAIGHT_JOIN (t2 JOIN t3 ON t3.f2 = t2.f2 ) ON t3 .f2 = t2 .f2 +HAVING ('v', 'i') NOT IN (SELECT f2, MIN(f2) FROM t1) +ORDER BY f2; +f2 +f +f +f +f +DROP TABLES t1,t2,t3; +# +# Bug#52340 Segfault: read_cached_record (tab=0x94a2634) at sql_select.cc:14411 +# +CREATE TABLE t1 (f1 INT, f2 VARCHAR(1)); +INSERT INTO t1 VALUES (16,'d'); +CREATE TABLE t2 (f1 INT, f2 VARCHAR(1)); +INSERT INTO t2 VALUES (13,'e'); +INSERT INTO t2 VALUES (20,'d'); +SELECT MAX(t2.f2) FROM t2 JOIN t1 ON t1.f2 +HAVING ('e' , 'd') IN +(SELECT ts1.f2, ts2.f2 FROM t2 ts1 JOIN t2 ts2 ON ts1.f1) +ORDER BY t1.f2; +MAX(t2.f2) +NULL +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'd' +DROP TABLE t1,t2; +End of 5.0 tests +# +# Bug#54416 MAX from JOIN with HAVING returning NULL with 5.1 and Empty set +# +CREATE TABLE t1 (f1 INT(11), f2 VARCHAR(1), PRIMARY KEY (f1)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (1,'f'); +CREATE TABLE t2 (f1 INT(11), f2 VARCHAR(1)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (2,'m'); +INSERT INTO t2 VALUES (3,'m'); +INSERT INTO t2 VALUES (11,NULL); +INSERT INTO t2 VALUES (12,'k'); +SELECT MAX(t1.f1) field1 +FROM t1 JOIN t2 ON t2.f2 LIKE 'x' +HAVING field1 < 7; +field1 +DROP TABLE t1,t2; +# +# Bug#48916 Server incorrectly processing HAVING clauses with an ORDER BY clause +# +CREATE TABLE t1 (f1 INT, f2 INT); +INSERT INTO t1 VALUES (1, 0), (2, 1), (3, 2); +CREATE TABLE t2 (f1 INT, f2 INT); +SELECT t1.f1 +FROM t1 +HAVING (3, 2) IN (SELECT f1, f2 FROM t2) AND t1.f1 >= 0 +ORDER BY t1.f1; +f1 +SELECT t1.f1 +FROM t1 +HAVING (3, 2) IN (SELECT 4, 2) AND t1.f1 >= 0 +ORDER BY t1.f1; +f1 +SELECT t1.f1 +FROM t1 +HAVING 2 IN (SELECT f2 FROM t2) AND t1.f1 >= 0 +ORDER BY t1.f1; +f1 +DROP TABLE t1,t2; +End of 5.1 tests +# +# Bug#12402590 ASSERT AT PROTOCOL::END_STATEMENT ON MYSQL-TRUNK +# RUNNING RQG_OPT_SUBQUERY TEST +# +CREATE TABLE t2 ( +f1 INT, +PRIMARY KEY (f1) +); +INSERT INTO t2 VALUES (1), (2); +CREATE TABLE t1 ( +f1 INT, +f2 VARCHAR(1), +f3 VARCHAR(1), +PRIMARY KEY (f1), +KEY (f2, f1) +); +INSERT INTO t1 VALUES (8, 'g', 'g'), (11, 'a', 'a'); +SELECT t1.f1 FROM t1 JOIN t2 ON t2.f1 = t1.f1 +WHERE t1.f3 AND t1.f2 IN ('f') +HAVING (1 ,6) IN (SELECT 3, 6) +ORDER BY t1.f1; +f1 +DROP TABLE t1, t2; +# +# Bug#11760517: MIN/MAX FAILS TO EVALUATE HAVING CONDITION, +# RETURNS INCORRECT NULL RESULT +# +CREATE TABLE t1 (pk INT PRIMARY KEY, i4 INT); +INSERT INTO t1 VALUES (2,7), (4,7), (6,2), (17,0); + +SELECT MIN(table1.i4), MIN(table2.pk) as min_pk +FROM t1 as table1, t1 as table2 +WHERE table1.pk = 1; +MIN(table1.i4) min_pk +NULL NULL + +SELECT MIN(table1.i4), MIN(table2.pk) as min_pk +FROM t1 as table1, t1 as table2 +WHERE table1.pk = 1 +HAVING min_pk <= 10; +MIN(table1.i4) min_pk + +DROP TABLE t1; +End of 5.6 tests + +ONLY_FULL_GROUP_BY now allows using an alias in HAVING +SET @old_sql_mode = @@sql_mode; +SET @@sql_mode='ONLY_FULL_GROUP_BY'; +CREATE TABLE t1 (a INT, b INT); +insert into t1 values(1,10),(2,20),(3,30); +select a from t1 having a=3; +a +3 +select a as x from t1 having x=3; +x +3 +select avg(a) as x from t1 having x=2; +x +2.0000 +select a as foo, sum(b) as bar from t1 group by a having foo<10; +foo bar +1 10 +2 20 +3 30 +select a as foo, sum(b) as bar from t1 +group by a +having bar>10 +order by foo+10; +foo bar +2 20 +3 30 +select a as foo, +(select t1_inner.b from t1 as t1_inner where +t1_inner.a=t1_outer.a+1) +as bar from t1 as t1_outer +group by a +having bar<30 +order by bar+5; +foo bar +1 20 +select a as foo, +(select t1_inner.b from t1 as t1_inner where +t1_inner.a=t1_outer.a+1) +as bar from t1 as t1_outer +group by foo +having bar<30 +order by bar+5; +foo bar +1 20 +DROP TABLE t1; +set sql_mode=''; +CREATE TABLE t1 (a INT) ENGINE=INNODB; +SELECT a FROM (SELECT 1 FROM t1 AS From1) AS From2 +NATURAL RIGHT OUTER JOIN t1 AS Outjoin3 +GROUP BY 1 HAVING ( +SELECT 1 FROM t1 AS Grouphaving4 GROUP BY 1 HAVING a); +a +SELECT a FROM (SELECT 1 FROM t1 AS From1) AS From2 +NATURAL RIGHT OUTER JOIN t1 AS Outjoin3 +GROUP BY 1 HAVING +sin((SELECT 1 FROM t1 AS Grouphaving4 GROUP BY 1 HAVING a)); +a +CREATE TABLE t2 (a INT) ENGINE=INNODB; +SELECT Outjoin3.a FROM (SELECT 1 FROM t1 AS From1) AS From2 +NATURAL RIGHT OUTER JOIN t2 AS Outjoin3 +GROUP BY 1 HAVING ( +SELECT 1 FROM t1 AS GroupHaving4 GROUP BY 1 HAVING a); +a +DROP TABLE t1, t2; +SET @@sql_mode = @old_sql_mode; +# +# Bug#17055185: WRONG RESULTS WHEN RUNNING A SELECT THAT INCLUDE +# A HAVING BASED ON A FUNCTION. +# +CREATE TABLE series ( +val INT(10) UNSIGNED NOT NULL +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO series VALUES(1); +CREATE TABLE seq_calls ( +c INT +); +INSERT INTO seq_calls VALUES(0); +CREATE FUNCTION next_seq_value() RETURNS INT +BEGIN +DECLARE next_val INT; +SELECT val INTO next_val FROM series; +UPDATE series SET val=mod(val + 1, 2); +UPDATE seq_calls SET c=c+1; +RETURN next_val; +END; +| +CREATE TABLE t1 (t INT, u INT, KEY(t)); +INSERT INTO t1 VALUES(10, 10), (11, 11), (12, 12), (12, 13),(14, 15), (15, 16), +(16, 17), (17, 18); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +SELECT * FROM series, seq_calls; +val c +1 0 +SELECT t, next_seq_value() r FROM t1 FORCE INDEX(t) +GROUP BY t HAVING r = 1 ORDER BY t1.u; +t r +10 1 +12 1 +15 1 +17 1 +SELECT * FROM series, seq_calls; +val c +0 7 +UPDATE series set val=0; +SELECT DISTINCT t1.t, next_seq_value() r FROM t1, t1 P +WHERE P.t = t1.t HAVING r = 1 ORDER BY t1.u; +t r +11 0 +12 0 +14 0 +15 0 +16 0 +17 0 +PREPARE STMT FROM 'SELECT t, next_seq_value() r FROM t1 FORCE INDEX(t) + GROUP BY t HAVING (SELECT 1 FROM t1 WHERE r = 1 LIMIT 1) + ORDER BY t1.u'; +SELECT * FROM series, seq_calls; +val c +1 22 +UPDATE series set val=0; +EXECUTE stmt; +t r +11 1 +14 1 +16 1 +SELECT * FROM series, seq_calls; +val c +1 29 +UPDATE series set val=1; +EXECUTE stmt; +t r +10 1 +12 1 +15 1 +17 1 +DEALLOCATE PREPARE stmt; +INSERT INTO t1 SELECT * FROM t1; +ALTER TABLE t1 ADD KEY(t, u); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +SELECT * FROM series, seq_calls; +val c +0 36 +UPDATE series set val=0; +SELECT next_seq_value() r, MIN(u) FROM t1 GROUP BY t HAVING r = 1; +r MIN(u) +0 11 +0 12 +0 15 +0 16 +0 17 +0 18 +DROP TABLE t1; +DROP FUNCTION next_seq_value; +DROP TABLE series, seq_calls; +# +# Bug#21243772: NOT IN SUBQUERY RETURNS INCORRECT RESULTS WHEN INNER +# QUERY HAS COUNT DISTINCT. +# +CREATE TABLE t1 (t TEXT NOT NULL, u TEXT); +INSERT INTO t1 VALUES('2', '1'), ('3', '1'), ('4', '1'); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +SELECT * FROM t1 WHERE (t, u) in (SELECT a.t, COUNT(DISTINCT a.u) +FROM t1 a, t1 b +GROUP BY a.t); +t u +2 1 +3 1 +4 1 +SELECT * FROM t1 WHERE (t, u) not in (SELECT a.t, COUNT(DISTINCT a.u) +FROM t1 a, t1 b +GROUP BY a.t); +t u +DROP TABLE t1; +# +# Bug#21507072: SIG 11 IN TABLE_LIST::MAP AT SQL/TABLE.H:2463. +# +CREATE TABLE t1 (col_varchar_key varchar(1) DEFAULT NULL, +KEY col_varchar_key (col_varchar_key)); +INSERT INTO t1 VALUES ('a'), ('b'), ('c'), ('h'), ('i'), ('i'), ('j'); +SELECT SQL_BUFFER_RESULT col_varchar_key AS field1 +FROM t1 AS table1 +GROUP BY field1 +HAVING field1 = 'a'; +field1 +a +DROP TABLE t1; +# Bug#21613422: Assertion failed: !thd->is_error() in ::prepare() +CREATE TABLE a(f INTEGER, g INTEGER) engine=innodb; +SELECT (SELECT 1 FROM a HAVING g) +FROM (SELECT 1) AS e +JOIN a AS t on TRUE +JOIN a USING (f) +JOIN a AS h on TRUE; +ERROR 23000: Column 'g' in having clause is ambiguous +DROP TABLE a; +# +# Bug #22655856: COLUMN NAME IN HAVING, WHICH IS CONTAINED IN SELECT +# LIST '*', PRODUCES ERROR +# +CREATE TABLE t1(c1 INT) ENGINE=INNODB; +CREATE TABLE t2(c2 INT) ENGINE=INNODB; +EXPLAIN SELECT c1 FROM t1 WHERE EXISTS(SELECT * FROM t2 HAVING c2>0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +2 SUBQUERY t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c1` AS `c1` from `test`.`t1` where false +SELECT c1 FROM t1 WHERE EXISTS(SELECT * FROM t2 HAVING c2>0); +c1 +INSERT INTO t1 VALUES(1); +INSERT INTO t2 VALUES(2); +SELECT c1 FROM t1 WHERE EXISTS(SELECT * FROM t2 HAVING c2>0); +c1 +1 +DROP TABLE t1, t2; +# +# BUG#26781725 INCORRECT RESULTS FOR QUERY(MAX FUNC+HAVING CLAUSE) WHEN USED INSIDE VIEW +# +CREATE TABLE CC ( +pk int(11) NOT NULL AUTO_INCREMENT, +col_varchar_key varchar(1) NOT NULL, +col_varchar varchar(1) NOT NULL, +PRIMARY KEY (pk), +KEY col_varchar_key (col_varchar_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO CC VALUES +(10,'v','v'),(18,'a','a'),(19,'v','v'),(20,'u','u'),(21,'s','s'),(22,'y','y'), +(23,'z','z'),(28,'y','y'); +SELECT MAX(col_varchar_key) AS field1 FROM CC AS alias1 +HAVING field1 <> 5; +field1 +z +CREATE OR REPLACE VIEW v1 AS SELECT MAX(col_varchar_key) AS field1 FROM CC AS alias1 +HAVING field1 <> 5; +SELECT * FROM v1; +field1 +z +DROP TABLE CC; +DROP VIEW v1; +# Bug#28934388: LIMIT is applied before HAVING when you have a subquery +CREATE TABLE t (id INT PRIMARY KEY, value INT); +INSERT INTO t VALUES (1, 99), (2,98), (3, 97); +CREATE TABLE o(c INTEGER); +INSERT INTO o(c) VALUES(1), (2); +SELECT t1.id, (SELECT t2.value FROM t t2 WHERE t1.id = t2.id) AS sub_value +FROM t t1 +HAVING sub_value = 99 +ORDER BY value +LIMIT 1; +id sub_value +1 99 +SELECT t1.id, (SELECT t2.value FROM t t2 WHERE t1.id = t2.id) AS sub_value +FROM t t1 +HAVING sub_value = 99 AND RAND() >= 0.0E0 +ORDER BY value +LIMIT 1; +id sub_value +1 99 +SELECT (SELECT (SELECT t2.value+o.c FROM t t2 WHERE t1.id = t2.id) AS sub_value +FROM t t1 +HAVING sub_value = 99 +ORDER BY value +LIMIT 1) AS sub_value +FROM o; +sub_value +99 +99 +DROP TABLE t, o; +# Bug#31429865: Assertion `table_share->tmp_table != NO_TMP_TABLE || +# m_lock_type == 1' failed. +CREATE TABLE t(a INTEGER); +INSERT INTO t VALUES(1),(2); +CREATE VIEW v AS SELECT a FROM t HAVING 0<>1; +DELETE FROM v LIMIT 1; +ERROR HY000: The target table v of the DELETE is not updatable +DROP VIEW v; +DROP TABLE t; diff --git a/mysql-test/r/heap.result-pq b/mysql-test/r/heap.result-pq new file mode 100644 index 000000000000..875e524fdf16 --- /dev/null +++ b/mysql-test/r/heap.result-pq @@ -0,0 +1,850 @@ +drop table if exists t1,t2,t3; +create table t1 (a int not null,b int not null, primary key (a)) engine=heap comment="testing heaps" avg_row_length=100 min_rows=1 max_rows=100; +insert into t1 values(1,1),(2,2),(3,3),(4,4); +delete from t1 where a=1 or a=0; +analyze table t1; +Table Op Msg_type Msg_text +test.t1 analyze note The storage engine for the table doesn't support analyze +show keys from t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible Expression +t1 0 PRIMARY 1 a NULL 3 NULL NULL HASH YES NULL +select * from t1; +a b +2 2 +3 3 +4 4 +select * from t1 where a=4; +a b +4 4 +update t1 set b=5 where a=4; +update t1 set b=b+1 where a>=3; +replace t1 values (3,3); +select * from t1; +a b +2 2 +3 3 +4 6 +alter table t1 add c int not null, add key (c,a); +drop table t1; +create table t1 (a int not null,b int not null, primary key (a)) engine=memory comment="testing heaps"; +insert into t1 values(1,1),(2,2),(3,3),(4,4); +delete from t1 where a > 0; +select * from t1; +a b +drop table t1; +create table t1 (a int not null,b int not null, primary key (a)) engine=heap comment="testing heaps"; +insert into t1 values(1,1),(2,2),(3,3),(4,4); +alter table t1 modify a int not null auto_increment, engine=innodb, comment="new innodb table"; +select * from t1; +a b +1 1 +2 2 +3 3 +4 4 +drop table t1; +create table t1 (a int not null) engine=heap; +insert into t1 values (869751),(736494),(226312),(802616),(728912); +select * from t1 where a > 736494; +a +869751 +802616 +alter table t1 add unique uniq_id(a); +select * from t1 where a > 736494; +a +869751 +802616 +select * from t1 where a = 736494; +a +736494 +select * from t1 where a=869751 or a=736494; +a +736494 +869751 +select * from t1 where a in (869751,736494,226312,802616); +a +226312 +736494 +802616 +869751 +alter table t1 engine=innodb; +explain select * from t1 where a in (869751,736494,226312,802616); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # # Parallel execute (1 workers) +2 SIMPLE t1 NULL index uniq_id uniq_id 4 NULL # # Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` in (869751,736494,226312,802616)) +drop table t1; +create table t1 (x int not null, y int not null, key x (x), unique y (y)) +engine=heap; +insert into t1 values (1,1),(2,2),(1,3),(2,4),(2,5),(2,6); +select * from t1 where x=1; +x y +1 1 +1 3 +select * from t1,t1 as t2 where t1.x=t2.y; +x y x y +1 1 1 1 +2 2 2 2 +1 3 1 1 +2 4 2 2 +2 5 2 2 +2 6 2 2 +explain select * from t1,t1 as t2 where t1.x=t2.y; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL x NULL NULL NULL 6 100.00 NULL +1 SIMPLE t2 NULL eq_ref y y 4 test.t1.x 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`x` AS `x`,`test`.`t1`.`y` AS `y`,`test`.`t2`.`x` AS `x`,`test`.`t2`.`y` AS `y` from `test`.`t1` join `test`.`t1` `t2` where (`test`.`t2`.`y` = `test`.`t1`.`x`) +drop table t1; +create table t1 (a int) engine=heap; +insert into t1 values(1); +select max(a) from t1; +max(a) +1 +drop table t1; +CREATE TABLE t1 ( a int not null default 0, b int not null default 0, key(a), key(b) ) ENGINE=HEAP; +insert into t1 values(1,1),(1,2),(2,3),(1,3),(1,4),(1,5),(1,6); +select * from t1 where a=1; +a b +1 1 +1 2 +1 3 +1 4 +1 5 +1 6 +insert into t1 values(1,1),(1,2),(2,3),(1,3),(1,4),(1,5),(1,6); +select * from t1 where a=1; +a b +1 1 +1 1 +1 2 +1 2 +1 3 +1 3 +1 4 +1 4 +1 5 +1 5 +1 6 +1 6 +drop table t1; +create table t1 (id int unsigned not null, primary key (id)) engine=HEAP; +insert into t1 values(1); +select max(id) from t1; +max(id) +1 +insert into t1 values(2); +select max(id) from t1; +max(id) +2 +replace into t1 values(1); +drop table t1; +create table t1 (n int) engine=heap; +drop table t1; +create table t1 (n int) engine=heap; +drop table if exists t1; +CREATE table t1(f1 int not null,f2 char(20) not +null,index(f2)) engine=heap; +INSERT into t1 set f1=12,f2="bill"; +INSERT into t1 set f1=13,f2="bill"; +INSERT into t1 set f1=14,f2="bill"; +INSERT into t1 set f1=15,f2="bill"; +INSERT into t1 set f1=16,f2="ted"; +INSERT into t1 set f1=12,f2="ted"; +INSERT into t1 set f1=12,f2="ted"; +INSERT into t1 set f1=12,f2="ted"; +INSERT into t1 set f1=12,f2="ted"; +delete from t1 where f2="bill"; +select * from t1; +f1 f2 +16 ted +12 ted +12 ted +12 ted +12 ted +drop table t1; +create table t1 (btn char(10) not null, key(btn)) charset utf8mb4 engine=heap; +insert into t1 values ("hello"),("hello"),("hello"),("hello"),("hello"),("a"),("b"),("c"),("d"),("e"),("f"),("g"),("h"),("i"); +explain select * from t1 where btn like "q%"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL btn NULL NULL NULL 14 11.11 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`btn` AS `btn` from `test`.`t1` where (`test`.`t1`.`btn` like 'q%') +select * from t1 where btn like "q%"; +btn +alter table t1 add column new_col char(1) not null, add key (btn,new_col), drop key btn; +update t1 set new_col=left(btn,1); +explain select * from t1 where btn="a"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL btn NULL NULL NULL 14 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`btn` AS `btn`,`test`.`t1`.`new_col` AS `new_col` from `test`.`t1` where (`test`.`t1`.`btn` = 'a') +explain select * from t1 where btn="a" and new_col="a"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ref btn btn 44 const,const 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`btn` AS `btn`,`test`.`t1`.`new_col` AS `new_col` from `test`.`t1` where ((`test`.`t1`.`new_col` = 'a') and (`test`.`t1`.`btn` = 'a')) +drop table t1; +CREATE TABLE t1 ( +a int default NULL, +b int default NULL, +KEY a (a), +UNIQUE b (b) +) engine=heap; +INSERT INTO t1 VALUES (NULL,99),(99,NULL),(1,1),(2,2),(1,3); +SELECT * FROM t1 WHERE a=NULL; +a b +explain SELECT * FROM t1 WHERE a IS NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ref a a 5 const 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (`test`.`t1`.`a` is null) +SELECT * FROM t1 WHERE a<=>NULL; +a b +NULL 99 +SELECT * FROM t1 WHERE b=NULL; +a b +explain SELECT * FROM t1 WHERE b IS NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ref b b 5 const 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (`test`.`t1`.`b` is null) +SELECT * FROM t1 WHERE b<=>NULL; +a b +99 NULL +INSERT INTO t1 VALUES (1,3); +ERROR 23000: Duplicate entry '3' for key 't1.b' +DROP TABLE t1; +CREATE TABLE t1 ( +a int default NULL, +key a (a) +) ENGINE=HEAP; +INSERT INTO t1 VALUES (10), (10), (10); +EXPLAIN SELECT * FROM t1 WHERE a=10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ref a a 5 const 3 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` = 10) +SELECT * FROM t1 WHERE a=10; +a +10 +10 +10 +DROP TABLE t1; +CREATE TABLE t1 (a int not null, primary key(a)) engine=heap; +INSERT into t1 values (1),(2),(3),(4),(5),(6),(7),(8),(9),(10),(11); +DELETE from t1 where a < 100; +SELECT * from t1; +a +DROP TABLE t1; +CREATE TABLE `job_titles` ( +`job_title_id` int(6) unsigned NOT NULL default '0', +`job_title` char(18) NOT NULL default '', +PRIMARY KEY (`job_title_id`), +UNIQUE KEY `job_title_id` (`job_title_id`,`job_title`) +) ENGINE=HEAP; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +SELECT MAX(job_title_id) FROM job_titles; +MAX(job_title_id) +NULL +DROP TABLE job_titles; +CREATE TABLE t1 (a INT NOT NULL, B INT, KEY(B)) ENGINE=HEAP; +INSERT INTO t1 VALUES(1,1), (1,NULL); +SELECT * FROM t1 WHERE B is not null; +a B +1 1 +DROP TABLE t1; +CREATE TABLE t1 (pseudo char(35) PRIMARY KEY, date int(10) unsigned NOT NULL) ENGINE=HEAP; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES ('massecot',1101106491),('altec',1101106492),('stitch+',1101106304),('Seb Corgan',1101106305),('beerfilou',1101106263),('flaker',1101106529),('joce8',5),('M4vrick',1101106418),('gabay008',1101106525),('Vamp irX',1101106291),('ZoomZip',1101106546),('rip666',1101106502),('CBP ',1101106397),('guezpard',1101106496); +DELETE FROM t1 WHERE date<1101106546; +SELECT * FROM t1; +pseudo date +ZoomZip 1101106546 +DROP TABLE t1; +create table t1(a char(2)) engine=memory; +insert into t1 values (NULL), (NULL); +delete from t1 where a is null; +insert into t1 values ('2'), ('3'); +select * from t1; +a +3 +2 +drop table t1; +set default_storage_engine=HEAP; +create table t1 (v varchar(10), c char(10), t varchar(50)) charset utf8mb4; +insert into t1 values('+ ', '+ ', '+ '); +set @a=repeat(' ',20); +insert into t1 values (concat('+',@a),concat('+',@a),concat('+',@a)); +Warnings: +Note 1265 Data truncated for column 'v' at row 1 +select concat('*',v,'*',c,'*',t,'*') from t1; +concat('*',v,'*',c,'*',t,'*') +*+ *+*+ * +*+ *+*+ * +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `v` varchar(10) DEFAULT NULL, + `c` char(10) DEFAULT NULL, + `t` varchar(50) DEFAULT NULL +) ENGINE=MEMORY DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +create table t2 like t1; +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `v` varchar(10) DEFAULT NULL, + `c` char(10) DEFAULT NULL, + `t` varchar(50) DEFAULT NULL +) ENGINE=MEMORY DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +create table t3 charset utf8mb4 select * from t1; +show create table t3; +Table Create Table +t3 CREATE TABLE `t3` ( + `v` varchar(10) DEFAULT NULL, + `c` char(10) DEFAULT NULL, + `t` varchar(50) DEFAULT NULL +) ENGINE=MEMORY DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +alter table t1 modify c varchar(10); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `v` varchar(10) DEFAULT NULL, + `c` varchar(10) DEFAULT NULL, + `t` varchar(50) DEFAULT NULL +) ENGINE=MEMORY DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +alter table t1 modify v char(10); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `v` char(10) DEFAULT NULL, + `c` varchar(10) DEFAULT NULL, + `t` varchar(50) DEFAULT NULL +) ENGINE=MEMORY DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SET sql_mode = 'NO_ENGINE_SUBSTITUTION'; +alter table t1 modify t varchar(10); +Warnings: +Warning 1265 Data truncated for column 't' at row 2 +SET sql_mode = default; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `v` char(10) DEFAULT NULL, + `c` varchar(10) DEFAULT NULL, + `t` varchar(10) DEFAULT NULL +) ENGINE=MEMORY DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +select concat('*',v,'*',c,'*',t,'*') from t1; +concat('*',v,'*',c,'*',t,'*') +*+*+*+ * +*+*+*+ * +drop table t1,t2,t3; +create table t1 (v varchar(10), c char(10), t varchar(50), key(v), key(c), key(t(10))) charset latin1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `v` varchar(10) DEFAULT NULL, + `c` char(10) DEFAULT NULL, + `t` varchar(50) DEFAULT NULL, + KEY `v` (`v`), + KEY `c` (`c`), + KEY `t` (`t`(10)) +) ENGINE=MEMORY DEFAULT CHARSET=latin1 +select count(*) from t1; +count(*) +270 +insert into t1 values(concat('a',char(1)),concat('a',char(1)),concat('a',char(1))); +select count(*) from t1 where v='a'; +count(*) +10 +select count(*) from t1 where c='a'; +count(*) +10 +select count(*) from t1 where t='a'; +count(*) +10 +select count(*) from t1 where v='a '; +count(*) +10 +select count(*) from t1 where c='a '; +count(*) +10 +select count(*) from t1 where t='a '; +count(*) +10 +select count(*) from t1 where v between 'a' and 'a '; +count(*) +10 +select count(*) from t1 where v between 'a' and 'a ' and v between 'a ' and 'b\n'; +count(*) +10 +select count(*) from t1 where v like 'a%'; +count(*) +11 +select count(*) from t1 where c like 'a%'; +count(*) +11 +select count(*) from t1 where t like 'a%'; +count(*) +11 +select count(*) from t1 where v like 'a %'; +count(*) +9 +explain select count(*) from t1 where v='a '; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ref v v 13 const 10 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select count(0) AS `count(*)` from `test`.`t1` where (`test`.`t1`.`v` = 'a ') +explain select count(*) from t1 where c='a '; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ref c c 11 const 10 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select count(0) AS `count(*)` from `test`.`t1` where (`test`.`t1`.`c` = 'a ') +explain select count(*) from t1 where t='a '; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ref t t 13 const 10 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select count(0) AS `count(*)` from `test`.`t1` where (`test`.`t1`.`t` = 'a ') +explain select count(*) from t1 where v like 'a%'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL v NULL NULL NULL 271 11.11 Using where +Warnings: +Note 1003 /* select#1 */ select count(0) AS `count(*)` from `test`.`t1` where (`test`.`t1`.`v` like 'a%') +explain select count(*) from t1 where v between 'a' and 'a '; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ref v v 13 const 10 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select count(0) AS `count(*)` from `test`.`t1` where (`test`.`t1`.`v` between 'a' and 'a ') +explain select count(*) from t1 where v between 'a' and 'a ' and v between 'a ' and 'b\n'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ref v v 13 const 10 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select count(0) AS `count(*)` from `test`.`t1` where ((`test`.`t1`.`v` between 'a' and 'a ') and (`test`.`t1`.`v` between 'a ' and 'b\n')) +alter table t1 add unique(v); +ERROR 23000: Duplicate entry '{ ' for key 't1.v_2' +select concat('*',v,'*',c,'*',t,'*') as qq from t1 where v='a' order by length(concat('*',v,'*',c,'*',t,'*')); +qq +*a*a*a* +*a *a*a * +*a *a*a * +*a *a*a * +*a *a*a * +*a *a*a * +*a *a*a * +*a *a*a * +*a *a*a * +*a *a*a * +explain select * from t1 where v='a'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ref v v 13 const 10 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`v` AS `v`,`test`.`t1`.`c` AS `c`,`test`.`t1`.`t` AS `t` from `test`.`t1` where (`test`.`t1`.`v` = 'a') +select v,count(*) from t1 group by v order by v limit 9; +v count(*) +a 1 +a 10 +b 10 +c 10 +d 10 +e 10 +f 10 +g 10 +h 10 +select v,count(t) from t1 group by v order by v limit 10; +v count(t) +a 1 +a 10 +b 10 +c 10 +d 10 +e 10 +f 10 +g 10 +h 10 +i 10 +select v,count(c) from t1 group by v order by v limit 10; +v count(c) +a 1 +a 10 +b 10 +c 10 +d 10 +e 10 +f 10 +g 10 +h 10 +i 10 +select sql_big_result trim(v),count(t) from t1 group by v order by v limit 10; +trim(v) count(t) +a 1 +a 10 +b 10 +c 10 +d 10 +e 10 +f 10 +g 10 +h 10 +i 10 +select sql_big_result trim(v),count(c) from t1 group by v order by v limit 10; +trim(v) count(c) +a 1 +a 10 +b 10 +c 10 +d 10 +e 10 +f 10 +g 10 +h 10 +i 10 +select c,count(*) from t1 group by c order by c limit 10; +c count(*) +a 1 +a 10 +b 10 +c 10 +d 10 +e 10 +f 10 +g 10 +h 10 +i 10 +select c,count(t) from t1 group by c order by c limit 10; +c count(t) +a 1 +a 10 +b 10 +c 10 +d 10 +e 10 +f 10 +g 10 +h 10 +i 10 +select sql_big_result c,count(t) from t1 group by c order by c limit 10; +c count(t) +a 1 +a 10 +b 10 +c 10 +d 10 +e 10 +f 10 +g 10 +h 10 +i 10 +select t,count(*) from t1 group by t order by t limit 10; +t count(*) +a 1 +a 10 +b 10 +c 10 +d 10 +e 10 +f 10 +g 10 +h 10 +i 10 +select t,count(t) from t1 group by t order by t limit 10; +t count(t) +a 1 +a 10 +b 10 +c 10 +d 10 +e 10 +f 10 +g 10 +h 10 +i 10 +select sql_big_result trim(t),count(t) from t1 group by t order by t limit 10; +trim(t) count(t) +a 1 +a 10 +b 10 +c 10 +d 10 +e 10 +f 10 +g 10 +h 10 +i 10 +drop table t1; +create table t1 (a char(10), unique (a)) charset latin1; +insert into t1 values ('a'); +insert into t1 values ('a '); +ERROR 23000: Duplicate entry 'a' for key 't1.a' +alter table t1 modify a varchar(10); +insert into t1 values ('a '),('a '),('a '),('a '); +ERROR 23000: Duplicate entry 'a ' for key 't1.a' +insert into t1 values ('a '); +ERROR 23000: Duplicate entry 'a ' for key 't1.a' +insert into t1 values ('a '); +ERROR 23000: Duplicate entry 'a ' for key 't1.a' +insert into t1 values ('a '); +ERROR 23000: Duplicate entry 'a ' for key 't1.a' +update t1 set a='a ' where a like 'a '; +update t1 set a='a ' where a like 'a '; +drop table t1; +create table t1 (v varchar(10), c char(10), t varchar(50), key using btree (v), key using btree (c), key using btree (t(10))) charset latin1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `v` varchar(10) DEFAULT NULL, + `c` char(10) DEFAULT NULL, + `t` varchar(50) DEFAULT NULL, + KEY `v` (`v`) USING BTREE, + KEY `c` (`c`) USING BTREE, + KEY `t` (`t`(10)) USING BTREE +) ENGINE=MEMORY DEFAULT CHARSET=latin1 +select count(*) from t1; +count(*) +270 +insert into t1 values(concat('a',char(1)),concat('a',char(1)),concat('a',char(1))); +select count(*) from t1 where v='a'; +count(*) +10 +select count(*) from t1 where c='a'; +count(*) +10 +select count(*) from t1 where t='a'; +count(*) +10 +select count(*) from t1 where v='a '; +count(*) +10 +select count(*) from t1 where c='a '; +count(*) +10 +select count(*) from t1 where t='a '; +count(*) +10 +select count(*) from t1 where v between 'a' and 'a '; +count(*) +10 +select count(*) from t1 where v between 'a' and 'a ' and v between 'a ' and 'b\n'; +count(*) +10 +explain select count(*) from t1 where v='a '; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ref v v 13 const # 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select count(0) AS `count(*)` from `test`.`t1` where (`test`.`t1`.`v` = 'a ') +explain select count(*) from t1 where c='a '; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ref c c 11 const # 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select count(0) AS `count(*)` from `test`.`t1` where (`test`.`t1`.`c` = 'a ') +explain select count(*) from t1 where t='a '; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ref t t 13 const # 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select count(0) AS `count(*)` from `test`.`t1` where (`test`.`t1`.`t` = 'a ') +explain select count(*) from t1 where v like 'a%'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range v v 13 NULL # 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select count(0) AS `count(*)` from `test`.`t1` where (`test`.`t1`.`v` like 'a%') +explain select count(*) from t1 where v between 'a' and 'a '; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ref v v 13 const # 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select count(0) AS `count(*)` from `test`.`t1` where (`test`.`t1`.`v` between 'a' and 'a ') +explain select count(*) from t1 where v between 'a' and 'a ' and v between 'a ' and 'b\n'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ref v v 13 const # 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select count(0) AS `count(*)` from `test`.`t1` where ((`test`.`t1`.`v` between 'a' and 'a ') and (`test`.`t1`.`v` between 'a ' and 'b\n')) +alter table t1 add unique(v); +ERROR 23000: Duplicate entry '{ ' for key 't1.v_2' +select concat('*',v,'*',c,'*',t,'*') as qq from t1 where v='a' order by length(concat('*',v,'*',c,'*',t,'*')); +qq +*a*a*a* +*a *a*a * +*a *a*a * +*a *a*a * +*a *a*a * +*a *a*a * +*a *a*a * +*a *a*a * +*a *a*a * +*a *a*a * +explain select * from t1 where v='a'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ref v v 13 const # 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`v` AS `v`,`test`.`t1`.`c` AS `c`,`test`.`t1`.`t` AS `t` from `test`.`t1` where (`test`.`t1`.`v` = 'a') +drop table t1; +create table t1 (a char(10), unique using btree (a)) charset latin1 engine=heap; +insert into t1 values ('a'); +insert into t1 values ('a '); +ERROR 23000: Duplicate entry 'a' for key 't1.a' +alter table t1 modify a varchar(10); +insert into t1 values ('a '),('a '),('a '),('a '); +ERROR 23000: Duplicate entry 'a ' for key 't1.a' +insert into t1 values ('a '); +ERROR 23000: Duplicate entry 'a ' for key 't1.a' +insert into t1 values ('a '); +ERROR 23000: Duplicate entry 'a ' for key 't1.a' +insert into t1 values ('a '); +ERROR 23000: Duplicate entry 'a ' for key 't1.a' +update t1 set a='a ' where a like 'a '; +update t1 set a='a ' where a like 'a '; +drop table t1; +create table t1 (v varchar(10), c char(10), t varchar(50), key(v(5)), key(c(5)), key(t(5))) charset utf8mb4; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `v` varchar(10) DEFAULT NULL, + `c` char(10) DEFAULT NULL, + `t` varchar(50) DEFAULT NULL, + KEY `v` (`v`(5)), + KEY `c` (`c`(5)), + KEY `t` (`t`(5)) +) ENGINE=MEMORY DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +create table t1 (v varchar(65530), key(v(10))) charset latin1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `v` varchar(65530) DEFAULT NULL, + KEY `v` (`v`(10)) +) ENGINE=MEMORY DEFAULT CHARSET=latin1 +insert into t1 values(repeat('a',65530)); +select length(v) from t1 where v=repeat('a',65530); +length(v) +65530 +drop table t1; +set default_storage_engine=InnoDB; +create table t1 (a bigint unsigned auto_increment primary key, b int, +key (b, a)) engine=heap; +insert t1 (b) values (1),(1),(1),(1),(1),(1),(1),(1); +select * from t1; +a b +1 1 +2 1 +3 1 +4 1 +5 1 +6 1 +7 1 +8 1 +drop table t1; +create table t1 (a int not null, b int not null auto_increment, +primary key(a, b), key(b)) engine=heap; +insert t1 (a) values (1),(1),(1),(1),(1),(1),(1),(1); +select * from t1; +a b +1 1 +1 2 +1 3 +1 4 +1 5 +1 6 +1 7 +1 8 +drop table t1; +create table t1 (a int not null, b int not null auto_increment, +primary key(a, b)) engine=heap; +ERROR 42000: Incorrect table definition; there can be only one auto column and it must be defined as a key +create table t1 (c char(255), primary key(c(90))); +insert into t1 values ("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz"); +insert into t1 values ("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz"); +ERROR 23000: Duplicate entry 'abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijkl' for key 't1.PRIMARY' +drop table t1; +# +# Bug 12796: Record doesn't show when selecting through index +# +CREATE TABLE t1 (a int, key(a)) engine=heap; +insert into t1 values (0); +delete from t1; +select * from t1; +a +insert into t1 values (0), (1); +select * from t1 where a = 0; +a +0 +drop table t1; +create table t1 (c char(10)) charset utf8mb4 engine=memory; +create table t2 (c varchar(10)) charset utf8mb4 engine=memory; +analyze table t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze note The storage engine for the table doesn't support analyze +test.t2 analyze note The storage engine for the table doesn't support analyze +show table status like 't_'; +Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment +t1 MEMORY 10 Fixed 0 41 0 # 0 0 NULL # NULL NULL utf8mb4_0900_ai_ci NULL +t2 MEMORY 10 Fixed 0 42 0 # 0 0 NULL # NULL NULL utf8mb4_0900_ai_ci NULL +drop table t1, t2; +CREATE TABLE t1(a VARCHAR(1), b VARCHAR(2), c VARCHAR(256), +KEY(a), KEY(b), KEY(c)) ENGINE=MEMORY; +INSERT INTO t1 VALUES('a','aa',REPEAT('a', 256)),('a','aa',REPEAT('a',256)); +SELECT COUNT(*) FROM t1 WHERE a='a'; +COUNT(*) +2 +SELECT COUNT(*) FROM t1 WHERE b='aa'; +COUNT(*) +2 +SELECT COUNT(*) FROM t1 WHERE c=REPEAT('a',256); +COUNT(*) +2 +DROP TABLE t1; +CREATE TABLE t1(c1 VARCHAR(100), c2 INT) ENGINE=MEMORY; +INSERT INTO t1 VALUES('', 0); +ALTER TABLE t1 MODIFY c1 VARCHAR(101); +SELECT c2 FROM t1; +c2 +0 +DROP TABLE t1; +# +# BUG#11825482: Broken key length calculation for btree index +# +CREATE TABLE h1 (f1 VARCHAR(1), f2 INT NOT NULL, +UNIQUE KEY h1i (f1,f2) USING BTREE ) ENGINE=HEAP; +INSERT INTO h1 VALUES(NULL,0),(NULL,1); +SELECT 'wrong' as 'result' FROM dual WHERE ('h', 0) NOT IN (SELECT * FROM h1); +result +CREATE TABLE t1 ( +pk int NOT NULL, +col_int_nokey INT, +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk) +); +INSERT INTO t1 VALUES (19,5,'h'),(20,5,'h'); +CREATE TABLE t2 (col_int_nokey INT); +INSERT INTO t2 VALUES (1),(2); +CREATE VIEW v1 AS +SELECT col_varchar_nokey, COUNT( col_varchar_nokey ) +FROM t1 +WHERE col_int_nokey <= 141 AND pk <= 4 +; +SELECT col_int_nokey FROM t2 +WHERE ('h', 0) NOT IN ( SELECT * FROM v1); +col_int_nokey +# shouldn't crash +EXPLAIN SELECT col_int_nokey FROM t2 +WHERE ('h', 0) NOT IN ( SELECT * FROM v1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +2 SUBQUERY NULL system NULL NULL NULL NULL 1 100.00 NULL +3 DERIVED t1 NULL range PRIMARY PRIMARY 4 NULL 1 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`col_int_nokey` AS `col_int_nokey` from `test`.`t2` where false +DROP TABLE t1,t2,h1; +DROP VIEW v1; +CREATE TABLE t1 ( +c1 VARCHAR(10) NOT NULL, +KEY i1 (c1(3)) +) ENGINE=MEMORY DEFAULT CHARSET=latin1; +INSERT INTO t1 VALUES ('foo1'), ('bar2'), ('baz3'); +SELECT * FROM t1 WHERE c1='bar2'; +c1 +bar2 +#should show one tuple! +SELECT * FROM t1 IGNORE INDEX (i1) WHERE c1='bar2'; +c1 +bar2 +#should show one tuple! +DROP TABLE t1; diff --git a/mysql-test/r/histogram_equi_height.result-pq b/mysql-test/r/histogram_equi_height.result-pq new file mode 100644 index 000000000000..deb356c69b3b --- /dev/null +++ b/mysql-test/r/histogram_equi_height.result-pq @@ -0,0 +1,1718 @@ +# +# Integer column, equi-height histogram +# +CREATE TABLE tbl_int (col1 INT); +INSERT INTO tbl_int VALUES (1), (2), (3), (4), (5), (6), (7), (8), (NULL), (NULL); +ANALYZE TABLE tbl_int; +Table Op Msg_type Msg_text +test.tbl_int analyze status OK +ANALYZE TABLE tbl_int UPDATE HISTOGRAM ON col1 WITH 2 BUCKETS; +Table Op Msg_type Msg_text +test.tbl_int histogram status Histogram statistics created for column 'col1'. +# Expect "80.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_int WHERE col1 > 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` > 0) +EXPLAIN SELECT * FROM tbl_int WHERE 0 < col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (0 < `test`.`tbl_int`.`col1`) +# Expect "10.0" in column "filtered" (we never estimate 0%) +EXPLAIN SELECT * FROM tbl_int WHERE col1 > 8; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` > 8) +EXPLAIN SELECT * FROM tbl_int WHERE 8 < col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (8 < `test`.`tbl_int`.`col1`) +# Expect "80.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_int WHERE col1 < 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` < 10) +EXPLAIN SELECT * FROM tbl_int WHERE 10 > col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (10 > `test`.`tbl_int`.`col1`) +# Expect "36.67" in column "filtered" +EXPLAIN SELECT * FROM tbl_int WHERE col1 >= 6; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 30.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 30.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` >= 6) +EXPLAIN SELECT * FROM tbl_int WHERE 6 <= col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 30.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 30.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (6 <= `test`.`tbl_int`.`col1`) +# Expect "80.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_int WHERE col1 >= -100; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` >= (-(100))) +EXPLAIN SELECT * FROM tbl_int WHERE -100 <= col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where ((-(100)) <= `test`.`tbl_int`.`col1`) +# Expect "70.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_int WHERE col1 != 8; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 70.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 70.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` <> 8) +EXPLAIN SELECT * FROM tbl_int WHERE 8 != col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 70.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 70.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (8 <> `test`.`tbl_int`.`col1`) +EXPLAIN SELECT * FROM tbl_int WHERE col1 <> 8; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 70.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 70.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` <> 8) +EXPLAIN SELECT * FROM tbl_int WHERE 8 <> col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 70.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 70.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (8 <> `test`.`tbl_int`.`col1`) +# Expect "10.0" in column "filtered", due to the fact that the optimizer +# always assumes that at least one row will match. +EXPLAIN SELECT * FROM tbl_int WHERE col1 = 100; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` = 100) +EXPLAIN SELECT * FROM tbl_int WHERE 100 = col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` = 100) +# Expect "20.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_int WHERE col1 IS NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 20.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 20.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` is null) +# Expect "80.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_int WHERE col1 IS NOT NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` is not null) +# Expect "36.67" in column "filtered" +EXPLAIN SELECT * FROM tbl_int WHERE col1 BETWEEN 1 AND 3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 30.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 30.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` between 1 and 3) +# Expect "43.33" in column "filtered" +EXPLAIN SELECT * FROM tbl_int WHERE col1 NOT BETWEEN 1 AND 3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 50.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` not between 1 and 3) +# Expect "60.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_int WHERE col1 IN (1, 3, 4, 5, 6, 7); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 60.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 60.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` in (1,3,4,5,6,7)) +# Expect "20.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_int WHERE col1 NOT IN (1, 3, 4, 5, 6, 7); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 20.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 20.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` not in (1,3,4,5,6,7)) +DROP TABLE tbl_int; +# +# String column, equi-height histogram +# +CREATE TABLE tbl_varchar (col1 VARCHAR(255)); +INSERT INTO tbl_varchar VALUES +("abcd"), ("ðŸ£"), ("ðŸº"), ("eeeeeeeeee"), ("ef"), ("AG"), +("a very long string that is longer than 42 characters"), +("lorem ipsum"), (NULL), (NULL); +ANALYZE TABLE tbl_varchar UPDATE HISTOGRAM ON col1 WITH 2 BUCKETS; +Table Op Msg_type Msg_text +test.tbl_varchar histogram status Histogram statistics created for column 'col1'. +ANALYZE TABLE tbl_varchar; +Table Op Msg_type Msg_text +test.tbl_varchar analyze status OK +# Expect "36.73" in column "filtered" +EXPLAIN SELECT * FROM tbl_varchar WHERE col1 > "b"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 36.73 Parallel execute (1 workers) +2 SIMPLE tbl_varchar NULL ALL NULL NULL NULL NULL 10 36.73 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_varchar`.`col1` AS `col1` from `test`.`tbl_varchar` where (`test`.`tbl_varchar`.`col1` > 'b') +EXPLAIN SELECT * FROM tbl_varchar WHERE "b" < col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 36.73 Parallel execute (1 workers) +2 SIMPLE tbl_varchar NULL ALL NULL NULL NULL NULL 10 36.73 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_varchar`.`col1` AS `col1` from `test`.`tbl_varchar` where ('b' < `test`.`tbl_varchar`.`col1`) +# Expect "10.0" in column "filtered" (we never estimate 0%) +EXPLAIN SELECT * FROM tbl_varchar WHERE col1 > "lp"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_varchar NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_varchar`.`col1` AS `col1` from `test`.`tbl_varchar` where (`test`.`tbl_varchar`.`col1` > 'lp') +EXPLAIN SELECT * FROM tbl_varchar WHERE "lp" < col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_varchar NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_varchar`.`col1` AS `col1` from `test`.`tbl_varchar` where ('lp' < `test`.`tbl_varchar`.`col1`) +# Expect "80.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_varchar WHERE col1 < "sierra"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_varchar NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_varchar`.`col1` AS `col1` from `test`.`tbl_varchar` where (`test`.`tbl_varchar`.`col1` < 'sierra') +EXPLAIN SELECT * FROM tbl_varchar WHERE "sierra" > col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_varchar NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_varchar`.`col1` AS `col1` from `test`.`tbl_varchar` where ('sierra' > `test`.`tbl_varchar`.`col1`) +# Expect "40.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_varchar WHERE col1 >= "abcd"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 40.00 Parallel execute (1 workers) +2 SIMPLE tbl_varchar NULL ALL NULL NULL NULL NULL 10 40.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_varchar`.`col1` AS `col1` from `test`.`tbl_varchar` where (`test`.`tbl_varchar`.`col1` >= 'abcd') +EXPLAIN SELECT * FROM tbl_varchar WHERE "abcd" <= col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 40.00 Parallel execute (1 workers) +2 SIMPLE tbl_varchar NULL ALL NULL NULL NULL NULL 10 40.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_varchar`.`col1` AS `col1` from `test`.`tbl_varchar` where ('abcd' <= `test`.`tbl_varchar`.`col1`) +# Expect "80.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_varchar WHERE col1 >= ""; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_varchar NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_varchar`.`col1` AS `col1` from `test`.`tbl_varchar` where (`test`.`tbl_varchar`.`col1` >= '') +EXPLAIN SELECT * FROM tbl_varchar WHERE "" <= col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_varchar NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_varchar`.`col1` AS `col1` from `test`.`tbl_varchar` where ('' <= `test`.`tbl_varchar`.`col1`) +# Expect "80.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_varchar WHERE col1 != "lorem ipsum"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_varchar NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_varchar`.`col1` AS `col1` from `test`.`tbl_varchar` where (`test`.`tbl_varchar`.`col1` <> 'lorem ipsum') +EXPLAIN SELECT * FROM tbl_varchar WHERE "lorem ipsum" != col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_varchar NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_varchar`.`col1` AS `col1` from `test`.`tbl_varchar` where ('lorem ipsum' <> `test`.`tbl_varchar`.`col1`) +EXPLAIN SELECT * FROM tbl_varchar WHERE col1 <> "lorem ipsum"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_varchar NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_varchar`.`col1` AS `col1` from `test`.`tbl_varchar` where (`test`.`tbl_varchar`.`col1` <> 'lorem ipsum') +EXPLAIN SELECT * FROM tbl_varchar WHERE "lorem ipsum" <> col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_varchar NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_varchar`.`col1` AS `col1` from `test`.`tbl_varchar` where ('lorem ipsum' <> `test`.`tbl_varchar`.`col1`) +# Expect "10.0" in column "filtered", due to the fact that the optimizer +# always assumes that at least one row will match. +EXPLAIN SELECT * FROM tbl_varchar WHERE col1 = "sierra"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_varchar NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_varchar`.`col1` AS `col1` from `test`.`tbl_varchar` where (`test`.`tbl_varchar`.`col1` = 'sierra') +EXPLAIN SELECT * FROM tbl_varchar WHERE "sierra" = col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_varchar NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_varchar`.`col1` AS `col1` from `test`.`tbl_varchar` where (`test`.`tbl_varchar`.`col1` = 'sierra') +# Expect "20.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_varchar WHERE col1 IS NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 20.00 Parallel execute (1 workers) +2 SIMPLE tbl_varchar NULL ALL NULL NULL NULL NULL 10 20.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_varchar`.`col1` AS `col1` from `test`.`tbl_varchar` where (`test`.`tbl_varchar`.`col1` is null) +# Expect "80.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_varchar WHERE col1 IS NOT NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_varchar NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_varchar`.`col1` AS `col1` from `test`.`tbl_varchar` where (`test`.`tbl_varchar`.`col1` is not null) +# Expect "10.00" in column "filtered" +EXPLAIN SELECT * FROM tbl_varchar WHERE col1 BETWEEN "a" AND "b"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_varchar NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_varchar`.`col1` AS `col1` from `test`.`tbl_varchar` where (`test`.`tbl_varchar`.`col1` between 'a' and 'b') +# Expect "76.72" in column "filtered" +EXPLAIN SELECT * FROM tbl_varchar WHERE col1 NOT BETWEEN "a" AND "b"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 76.72 Parallel execute (1 workers) +2 SIMPLE tbl_varchar NULL ALL NULL NULL NULL NULL 10 76.72 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_varchar`.`col1` AS `col1` from `test`.`tbl_varchar` where (`test`.`tbl_varchar`.`col1` not between 'a' and 'b') +# Expect "10.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_varchar WHERE col1 IN ("ag", "ef", "ðŸ£"); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_varchar NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Warning 1300 Cannot convert string '\xF0\x9F\x8D\xA3' from utf8mb4 to utf8 +Note 1003 /* select#1 */ select `test`.`tbl_varchar`.`col1` AS `col1` from `test`.`tbl_varchar` where (`test`.`tbl_varchar`.`col1` in ('ag','ef','?')) +# Expect "80.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_varchar WHERE col1 NOT IN ("ag", "ef", "ðŸ£"); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_varchar NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Warning 1300 Cannot convert string '\xF0\x9F\x8D\xA3' from utf8mb4 to utf8 +Note 1003 /* select#1 */ select `test`.`tbl_varchar`.`col1` AS `col1` from `test`.`tbl_varchar` where (`test`.`tbl_varchar`.`col1` not in ('ag','ef','?')) +DROP TABLE tbl_varchar; +CREATE TABLE tbl_varchar (col1 VARCHAR(255)); +INSERT INTO tbl_varchar VALUES +# |------------ 42 characters -------------| +("abcdefghijklmnopqrstuvwxyzabcdefghijklmnop"), +("abcdefghijklmnopqrstuvwxyzabcdefghijklmnoq"), +("abcdefghijklmnopqrstuvwxyzabcdefghijklmnor"), +("abcdefghijklmnopqrstuvwxyzabcdefghijklmnos"), +("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopp"), +("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopq"), +("abcdefghijklmnopqrstuvwxyzabcdefghijklmnoss"), +("abcdefghijklmnopqrstuvwxyzabcdefghijklmnost"); +ANALYZE TABLE tbl_varchar UPDATE HISTOGRAM ON col1 WITH 2 BUCKETS; +Table Op Msg_type Msg_text +test.tbl_varchar histogram status Histogram statistics created for column 'col1'. +ANALYZE TABLE tbl_varchar; +Table Op Msg_type Msg_text +test.tbl_varchar analyze status OK +# Expect "100.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_varchar WHERE col1 < "abcdefghijklmnopqrstuvwxyzabcdefghijklmnos"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE tbl_varchar NULL ALL NULL NULL NULL NULL 8 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_varchar`.`col1` AS `col1` from `test`.`tbl_varchar` where (`test`.`tbl_varchar`.`col1` < 'abcdefghijklmnopqrstuvwxyzabcdefghijklmnos') +# Expect "12.50" in column "filtered" +EXPLAIN SELECT * FROM tbl_varchar WHERE col1 < "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopr"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE tbl_varchar NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_varchar`.`col1` AS `col1` from `test`.`tbl_varchar` where (`test`.`tbl_varchar`.`col1` < 'abcdefghijklmnopqrstuvwxyzabcdefghijklmnopr') +DROP TABLE tbl_varchar; +# +# Double column, equi-height histogram +# +CREATE TABLE tbl_double (col1 DOUBLE); +INSERT INTO tbl_double VALUES (-1.1), (0.0), (1.1), (2.2), (3.3), (4.4), (5.5), (6.6), (NULL), (NULL); +ANALYZE TABLE tbl_double UPDATE HISTOGRAM ON col1 WITH 2 BUCKETS; +Table Op Msg_type Msg_text +test.tbl_double histogram status Histogram statistics created for column 'col1'. +ANALYZE TABLE tbl_double; +Table Op Msg_type Msg_text +test.tbl_double analyze status OK +# Expect "66.67" in column "filtered" +EXPLAIN SELECT * FROM tbl_double WHERE col1 > 0.0e0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_double NULL ALL NULL NULL NULL NULL 10 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_double`.`col1` AS `col1` from `test`.`tbl_double` where (`test`.`tbl_double`.`col1` > 0.0e0) +EXPLAIN SELECT * FROM tbl_double WHERE 0.0e0 < col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_double NULL ALL NULL NULL NULL NULL 10 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_double`.`col1` AS `col1` from `test`.`tbl_double` where (0.0e0 < `test`.`tbl_double`.`col1`) +# Expect "10.0" in column "filtered" (we never estimate 0%) +EXPLAIN SELECT * FROM tbl_double WHERE col1 > 6.6e0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_double NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_double`.`col1` AS `col1` from `test`.`tbl_double` where (`test`.`tbl_double`.`col1` > 6.6e0) +EXPLAIN SELECT * FROM tbl_double WHERE 6.6e0 < col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_double NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_double`.`col1` AS `col1` from `test`.`tbl_double` where (6.6e0 < `test`.`tbl_double`.`col1`) +# Expect "80.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_double WHERE col1 < 100.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_double NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_double`.`col1` AS `col1` from `test`.`tbl_double` where (`test`.`tbl_double`.`col1` < 100) +EXPLAIN SELECT * FROM tbl_double WHERE 100.0 > col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_double NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_double`.`col1` AS `col1` from `test`.`tbl_double` where (100 > `test`.`tbl_double`.`col1`) +# Expect "40.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_double WHERE col1 >= 3.3e0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 40.00 Parallel execute (1 workers) +2 SIMPLE tbl_double NULL ALL NULL NULL NULL NULL 10 40.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_double`.`col1` AS `col1` from `test`.`tbl_double` where (`test`.`tbl_double`.`col1` >= 3.3e0) +EXPLAIN SELECT * FROM tbl_double WHERE 3.3e0 <= col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 40.00 Parallel execute (1 workers) +2 SIMPLE tbl_double NULL ALL NULL NULL NULL NULL 10 40.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_double`.`col1` AS `col1` from `test`.`tbl_double` where (3.3e0 <= `test`.`tbl_double`.`col1`) +# Expect "80.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_double WHERE col1 >= -2.0e0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_double NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_double`.`col1` AS `col1` from `test`.`tbl_double` where (`test`.`tbl_double`.`col1` >= -2) +EXPLAIN SELECT * FROM tbl_double WHERE -2.0e0 <= col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_double NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_double`.`col1` AS `col1` from `test`.`tbl_double` where (-2 <= `test`.`tbl_double`.`col1`) +# Expect "80.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_double WHERE col1 != 0.0e0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_double NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_double`.`col1` AS `col1` from `test`.`tbl_double` where (`test`.`tbl_double`.`col1` <> 0.0e0) +EXPLAIN SELECT * FROM tbl_double WHERE 0.0e0 != col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_double NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_double`.`col1` AS `col1` from `test`.`tbl_double` where (0.0e0 <> `test`.`tbl_double`.`col1`) +EXPLAIN SELECT * FROM tbl_double WHERE col1 <> 0.0e0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_double NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_double`.`col1` AS `col1` from `test`.`tbl_double` where (`test`.`tbl_double`.`col1` <> 0.0e0) +EXPLAIN SELECT * FROM tbl_double WHERE 0.0e0 <> col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_double NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_double`.`col1` AS `col1` from `test`.`tbl_double` where (0.0e0 <> `test`.`tbl_double`.`col1`) +# Expect "10.0" in column "filtered", due to the fact that the optimizer +# always assumes that at least one row will match. +EXPLAIN SELECT * FROM tbl_double WHERE col1 = 100.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_double NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_double`.`col1` AS `col1` from `test`.`tbl_double` where (`test`.`tbl_double`.`col1` = 100) +EXPLAIN SELECT * FROM tbl_double WHERE 100.0 = col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_double NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_double`.`col1` AS `col1` from `test`.`tbl_double` where (100 = `test`.`tbl_double`.`col1`) +# Expect "20.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_double WHERE col1 IS NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 20.00 Parallel execute (1 workers) +2 SIMPLE tbl_double NULL ALL NULL NULL NULL NULL 10 20.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_double`.`col1` AS `col1` from `test`.`tbl_double` where (`test`.`tbl_double`.`col1` is null) +# Expect "80.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_double WHERE col1 IS NOT NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_double NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_double`.`col1` AS `col1` from `test`.`tbl_double` where (`test`.`tbl_double`.`col1` is not null) +# Expect "13.33" in column "filtered" +EXPLAIN SELECT * FROM tbl_double WHERE col1 BETWEEN 1.1e0 AND 3.3e0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 13.33 Parallel execute (1 workers) +2 SIMPLE tbl_double NULL ALL NULL NULL NULL NULL 10 13.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_double`.`col1` AS `col1` from `test`.`tbl_double` where (`test`.`tbl_double`.`col1` between 1.1e0 and 3.3e0) +# Expect "66.67" in column "filtered" +EXPLAIN SELECT * FROM tbl_double WHERE col1 NOT BETWEEN 1.1e0 AND 3.3e0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_double NULL ALL NULL NULL NULL NULL 10 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_double`.`col1` AS `col1` from `test`.`tbl_double` where (`test`.`tbl_double`.`col1` not between 1.1e0 and 3.3e0) +# Expect "10.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_double WHERE col1 IN (-1.1e0, 0.0e0, 1.1e0, 2.2e0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_double NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_double`.`col1` AS `col1` from `test`.`tbl_double` where (`test`.`tbl_double`.`col1` in ((-(1.1e0)),0.0e0,1.1e0,2.2e0)) +# Expect "80.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_double WHERE col1 NOT IN (-1.1e0, 0.0e0, 1.1e0, 2.2e0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_double NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_double`.`col1` AS `col1` from `test`.`tbl_double` where (`test`.`tbl_double`.`col1` not in ((-(1.1e0)),0.0e0,1.1e0,2.2e0)) +DROP TABLE tbl_double; +# +# Time column, equi-height histogram +# +CREATE TABLE tbl_time (col1 TIME); +INSERT INTO tbl_time VALUES +("-01:00:00"), ("00:00:00"), ("00:00:01"), ("00:01:00"), ("01:00:00"), +("01:01:00"), ("02:00:00"), ("03:00:00"), (NULL), (NULL); +ANALYZE TABLE tbl_time UPDATE HISTOGRAM ON col1 WITH 2 BUCKETS; +Table Op Msg_type Msg_text +test.tbl_time histogram status Histogram statistics created for column 'col1'. +ANALYZE TABLE tbl_time; +Table Op Msg_type Msg_text +test.tbl_time analyze status OK +# Expect "40.66" in column "filtered" +EXPLAIN SELECT * FROM tbl_time WHERE col1 > "00:00:00"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 40.66 Parallel execute (1 workers) +2 SIMPLE tbl_time NULL ALL NULL NULL NULL NULL 10 40.66 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_time`.`col1` AS `col1` from `test`.`tbl_time` where (`test`.`tbl_time`.`col1` > TIME'00:00:00') +EXPLAIN SELECT * FROM tbl_time WHERE "00:00:00" < col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 40.66 Parallel execute (1 workers) +2 SIMPLE tbl_time NULL ALL NULL NULL NULL NULL 10 40.66 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_time`.`col1` AS `col1` from `test`.`tbl_time` where (TIME'00:00:00' < `test`.`tbl_time`.`col1`) +# Expect "10.0" in column "filtered" (we never estimate 0%) +EXPLAIN SELECT * FROM tbl_time WHERE col1 > "03:00:00"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_time NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_time`.`col1` AS `col1` from `test`.`tbl_time` where (`test`.`tbl_time`.`col1` > TIME'03:00:00') +EXPLAIN SELECT * FROM tbl_time WHERE "03:00:00" < col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_time NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_time`.`col1` AS `col1` from `test`.`tbl_time` where (TIME'03:00:00' < `test`.`tbl_time`.`col1`) +# Expect "80.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_time WHERE col1 < "10:00:00"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_time NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_time`.`col1` AS `col1` from `test`.`tbl_time` where (`test`.`tbl_time`.`col1` < TIME'10:00:00') +EXPLAIN SELECT * FROM tbl_time WHERE "10:00:00" > col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_time NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_time`.`col1` AS `col1` from `test`.`tbl_time` where (TIME'10:00:00' > `test`.`tbl_time`.`col1`) +# Expect "40.64" in column "filtered" +EXPLAIN SELECT * FROM tbl_time WHERE col1 >= "00:00:01"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 40.64 Parallel execute (1 workers) +2 SIMPLE tbl_time NULL ALL NULL NULL NULL NULL 10 40.64 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_time`.`col1` AS `col1` from `test`.`tbl_time` where (`test`.`tbl_time`.`col1` >= TIME'00:00:01') +EXPLAIN SELECT * FROM tbl_time WHERE "00:00:01" <= col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 40.64 Parallel execute (1 workers) +2 SIMPLE tbl_time NULL ALL NULL NULL NULL NULL 10 40.64 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_time`.`col1` AS `col1` from `test`.`tbl_time` where (TIME'00:00:01' <= `test`.`tbl_time`.`col1`) +# Expect "80.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_time WHERE col1 >= "-01:00:00"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_time NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_time`.`col1` AS `col1` from `test`.`tbl_time` where (`test`.`tbl_time`.`col1` >= TIME'-01:00:00') +EXPLAIN SELECT * FROM tbl_time WHERE "-01:00:00" <= col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_time NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_time`.`col1` AS `col1` from `test`.`tbl_time` where (TIME'-01:00:00' <= `test`.`tbl_time`.`col1`) +# Expect "80.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_time WHERE col1 != "01:01:00"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_time NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_time`.`col1` AS `col1` from `test`.`tbl_time` where (`test`.`tbl_time`.`col1` <> TIME'01:01:00') +EXPLAIN SELECT * FROM tbl_time WHERE "01:01:00" != col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_time NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_time`.`col1` AS `col1` from `test`.`tbl_time` where (TIME'01:01:00' <> `test`.`tbl_time`.`col1`) +EXPLAIN SELECT * FROM tbl_time WHERE col1 <> "01:01:00"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_time NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_time`.`col1` AS `col1` from `test`.`tbl_time` where (`test`.`tbl_time`.`col1` <> TIME'01:01:00') +EXPLAIN SELECT * FROM tbl_time WHERE "01:01:00" <> col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_time NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_time`.`col1` AS `col1` from `test`.`tbl_time` where (TIME'01:01:00' <> `test`.`tbl_time`.`col1`) +# Expect "10.0" in column "filtered", due to the fact that the optimizer +# always assumes that at least one row will match. +EXPLAIN SELECT * FROM tbl_time WHERE col1 = "10:00:00"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_time NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_time`.`col1` AS `col1` from `test`.`tbl_time` where (`test`.`tbl_time`.`col1` = TIME'10:00:00') +EXPLAIN SELECT * FROM tbl_time WHERE "10:00:00" = col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_time NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_time`.`col1` AS `col1` from `test`.`tbl_time` where (TIME'10:00:00' = `test`.`tbl_time`.`col1`) +# Expect "20.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_time WHERE col1 IS NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 20.00 Parallel execute (1 workers) +2 SIMPLE tbl_time NULL ALL NULL NULL NULL NULL 10 20.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_time`.`col1` AS `col1` from `test`.`tbl_time` where (`test`.`tbl_time`.`col1` is null) +# Expect "80.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_time WHERE col1 IS NOT NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_time NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_time`.`col1` AS `col1` from `test`.`tbl_time` where (`test`.`tbl_time`.`col1` is not null) +# Expect "20.64" in column "filtered" +# This might seem low, but given the uniform distribution assuption in +# each bucket this is actually correct. +EXPLAIN SELECT * FROM tbl_time WHERE col1 BETWEEN "00:00:01" AND "02:00:00"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 20.64 Parallel execute (1 workers) +2 SIMPLE tbl_time NULL ALL NULL NULL NULL NULL 10 20.64 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_time`.`col1` AS `col1` from `test`.`tbl_time` where (`test`.`tbl_time`.`col1` between '00:00:01' and '02:00:00') +# Expect "59.36" in column "filtered" +# This might seem high, but given the uniform distribution assuption in +# each bucket this is actually correct. +EXPLAIN SELECT * FROM tbl_time WHERE col1 NOT BETWEEN "00:00:01" AND "02:00:00"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 59.36 Parallel execute (1 workers) +2 SIMPLE tbl_time NULL ALL NULL NULL NULL NULL 10 59.36 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_time`.`col1` AS `col1` from `test`.`tbl_time` where (`test`.`tbl_time`.`col1` not between '00:00:01' and '02:00:00') +# Expect "10.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_time WHERE col1 IN ("-01:00:00", "00:00:00", "03:00:00"); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_time NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_time`.`col1` AS `col1` from `test`.`tbl_time` where (`test`.`tbl_time`.`col1` in ('-01:00:00','00:00:00','03:00:00')) +# Expect "80.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_time WHERE col1 NOT IN ("-01:00:00", "00:00:00", "03:00:00"); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_time NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_time`.`col1` AS `col1` from `test`.`tbl_time` where (`test`.`tbl_time`.`col1` not in ('-01:00:00','00:00:00','03:00:00')) +DROP TABLE tbl_time; +CREATE TABLE tbl_time (col1 TIME(6)); +INSERT INTO tbl_time VALUES +("00:00:00.000000"), ("00:00:00.000001"), ("00:00:00.000002"), +("00:00:00.000003"), ("00:00:00.000004"), ("00:00:00.000005"); +ANALYZE TABLE tbl_time UPDATE HISTOGRAM ON col1 WITH 2 BUCKETS; +Table Op Msg_type Msg_text +test.tbl_time histogram status Histogram statistics created for column 'col1'. +ANALYZE TABLE tbl_time; +Table Op Msg_type Msg_text +test.tbl_time analyze status OK +EXPLAIN SELECT * FROM tbl_time WHERE col1 < "00:00:00.000004"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 6 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_time NULL ALL NULL NULL NULL NULL 6 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_time`.`col1` AS `col1` from `test`.`tbl_time` where (`test`.`tbl_time`.`col1` < TIME'00:00:00.000004') +DROP TABLE tbl_time; +# +# Date column, equi-height histogram +# +CREATE TABLE tbl_date (col1 DATE); +INSERT INTO tbl_date VALUES +("1000-01-01"), ("9999-12-30"), ("2017-01-01"), ("2017-01-02"), ("2017-02-01"), +("2018-01-01"), ("2019-01-01"), ("3019-01-01"), (NULL), (NULL); +ANALYZE TABLE tbl_date UPDATE HISTOGRAM ON col1 WITH 2 BUCKETS; +Table Op Msg_type Msg_text +test.tbl_date histogram status Histogram statistics created for column 'col1'. +ANALYZE TABLE tbl_date; +Table Op Msg_type Msg_text +test.tbl_date analyze status OK +# Expect "40.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_date WHERE col1 > "2017-01-02"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 40.00 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 10 40.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`col1` AS `col1` from `test`.`tbl_date` where (`test`.`tbl_date`.`col1` > DATE'2017-01-02') +EXPLAIN SELECT * FROM tbl_date WHERE "2017-01-02" < col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 40.00 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 10 40.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`col1` AS `col1` from `test`.`tbl_date` where (DATE'2017-01-02' < `test`.`tbl_date`.`col1`) +# Expect "10.0" in column "filtered" (we never estimate 0%) +EXPLAIN SELECT * FROM tbl_date WHERE col1 > "9999-12-31"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`col1` AS `col1` from `test`.`tbl_date` where (`test`.`tbl_date`.`col1` > DATE'9999-12-31') +EXPLAIN SELECT * FROM tbl_date WHERE "9999-12-31" < col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`col1` AS `col1` from `test`.`tbl_date` where (DATE'9999-12-31' < `test`.`tbl_date`.`col1`) +# Expect "80.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_date WHERE col1 < "9999-12-31"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`col1` AS `col1` from `test`.`tbl_date` where (`test`.`tbl_date`.`col1` < DATE'9999-12-31') +EXPLAIN SELECT * FROM tbl_date WHERE "9999-12-31" > col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`col1` AS `col1` from `test`.`tbl_date` where (DATE'9999-12-31' > `test`.`tbl_date`.`col1`) +# Expect "40.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_date WHERE col1 >= "2018-01-01"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 40.00 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 10 40.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`col1` AS `col1` from `test`.`tbl_date` where (`test`.`tbl_date`.`col1` >= DATE'2018-01-01') +EXPLAIN SELECT * FROM tbl_date WHERE "2018-01-01" <= col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 40.00 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 10 40.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`col1` AS `col1` from `test`.`tbl_date` where (DATE'2018-01-01' <= `test`.`tbl_date`.`col1`) +# Expect "80.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_date WHERE col1 >= "1000-01-01"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`col1` AS `col1` from `test`.`tbl_date` where (`test`.`tbl_date`.`col1` >= DATE'1000-01-01') +EXPLAIN SELECT * FROM tbl_date WHERE "1000-01-01" <= col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`col1` AS `col1` from `test`.`tbl_date` where (DATE'1000-01-01' <= `test`.`tbl_date`.`col1`) +# Expect "80.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_date WHERE col1 != "2017-01-02"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`col1` AS `col1` from `test`.`tbl_date` where (`test`.`tbl_date`.`col1` <> DATE'2017-01-02') +EXPLAIN SELECT * FROM tbl_date WHERE "2017-01-02" != col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`col1` AS `col1` from `test`.`tbl_date` where (DATE'2017-01-02' <> `test`.`tbl_date`.`col1`) +EXPLAIN SELECT * FROM tbl_date WHERE col1 <> "2017-01-02"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`col1` AS `col1` from `test`.`tbl_date` where (`test`.`tbl_date`.`col1` <> DATE'2017-01-02') +EXPLAIN SELECT * FROM tbl_date WHERE "2017-01-02" <> col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`col1` AS `col1` from `test`.`tbl_date` where (DATE'2017-01-02' <> `test`.`tbl_date`.`col1`) +# Expect "10.0" in column "filtered", due to the fact that the optimizer +# always assumes that at least one row will match. +EXPLAIN SELECT * FROM tbl_date WHERE col1 = "9999-12-31"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`col1` AS `col1` from `test`.`tbl_date` where (`test`.`tbl_date`.`col1` = DATE'9999-12-31') +EXPLAIN SELECT * FROM tbl_date WHERE "9999-12-31" = col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`col1` AS `col1` from `test`.`tbl_date` where (`test`.`tbl_date`.`col1` = DATE'9999-12-31') +# Expect "20.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_date WHERE col1 IS NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 20.00 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 10 20.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`col1` AS `col1` from `test`.`tbl_date` where (`test`.`tbl_date`.`col1` is null) +# Expect "80.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_date WHERE col1 IS NOT NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`col1` AS `col1` from `test`.`tbl_date` where (`test`.`tbl_date`.`col1` is not null) +# Expect "10.00" in column "filtered" +# This might seem low, but given the uniform distribution assuption in +# each bucket this is actually correct. +EXPLAIN SELECT * FROM tbl_date WHERE col1 BETWEEN "2017-01-01" AND "3019-01-01"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`col1` AS `col1` from `test`.`tbl_date` where (`test`.`tbl_date`.`col1` between '2017-01-01' and '3019-01-01') +# Expect "74.98" in column "filtered" +# This might seem high, but given the uniform distribution assuption in +# each bucket this is actually correct. +EXPLAIN SELECT * FROM tbl_date WHERE col1 NOT BETWEEN "2017-01-01" AND "3019-01-01"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 74.98 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 10 74.98 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`col1` AS `col1` from `test`.`tbl_date` where (`test`.`tbl_date`.`col1` not between '2017-01-01' and '3019-01-01') +# Expect "10.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_date WHERE col1 IN ("1000-01-01", "2017-01-02", "2018-01-01"); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`col1` AS `col1` from `test`.`tbl_date` where (`test`.`tbl_date`.`col1` in ('1000-01-01','2017-01-02','2018-01-01')) +# Expect "80.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_date WHERE col1 NOT IN ("1000-01-01", "2017-01-02", "2018-01-01"); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`col1` AS `col1` from `test`.`tbl_date` where (`test`.`tbl_date`.`col1` not in ('1000-01-01','2017-01-02','2018-01-01')) +DROP TABLE tbl_date; +# +# Datetime column, equi-height histogram +# +CREATE TABLE tbl_datetime (col1 DATETIME(6)); +INSERT INTO tbl_datetime VALUES +("1000-01-01 00:00:00"), ("9999-12-31 23:59:59.999998"), +("2017-01-01 00:00:00"), ("2017-01-01 00:00:00.000001"), +("2017-02-01 00:00:00"), ("2018-01-01 00:00:00.999999"), +("2018-01-01 00:00:01"), ("3019-01-01 10:10:10.101010"), (NULL), (NULL); +ANALYZE TABLE tbl_datetime UPDATE HISTOGRAM ON col1 WITH 2 BUCKETS; +Table Op Msg_type Msg_text +test.tbl_datetime histogram status Histogram statistics created for column 'col1'. +ANALYZE TABLE tbl_datetime; +Table Op Msg_type Msg_text +test.tbl_datetime analyze status OK +# Expect "40.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_datetime WHERE col1 > "2018-01-01 00:00:00"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 40.00 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 10 40.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`col1` AS `col1` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`col1` > TIMESTAMP'2018-01-01 00:00:00') +EXPLAIN SELECT * FROM tbl_datetime WHERE "2018-01-01 00:00:00" < col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 40.00 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 10 40.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`col1` AS `col1` from `test`.`tbl_datetime` where (TIMESTAMP'2018-01-01 00:00:00' < `test`.`tbl_datetime`.`col1`) +# Expect "10.0" in column "filtered" (we never estimate 0%) +EXPLAIN SELECT * FROM tbl_datetime WHERE col1 > "9999-12-31 23:59:59.999999"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`col1` AS `col1` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`col1` > TIMESTAMP'9999-12-31 23:59:59.999999') +EXPLAIN SELECT * FROM tbl_datetime WHERE "9999-12-31 23:59:59.999999" < col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`col1` AS `col1` from `test`.`tbl_datetime` where (TIMESTAMP'9999-12-31 23:59:59.999999' < `test`.`tbl_datetime`.`col1`) +# Expect "80.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_datetime WHERE col1 < "9999-12-31 23:59:59.999999"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`col1` AS `col1` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`col1` < TIMESTAMP'9999-12-31 23:59:59.999999') +EXPLAIN SELECT * FROM tbl_datetime WHERE "9999-12-31 23:59:59.999999" > col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`col1` AS `col1` from `test`.`tbl_datetime` where (TIMESTAMP'9999-12-31 23:59:59.999999' > `test`.`tbl_datetime`.`col1`) +# Expect "40.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_datetime WHERE col1 >= "2018-01-01 00:00:00.999999"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 40.00 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 10 40.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`col1` AS `col1` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`col1` >= TIMESTAMP'2018-01-01 00:00:00.999999') +EXPLAIN SELECT * FROM tbl_datetime WHERE "2018-01-01 00:00:00.999999" <= col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 40.00 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 10 40.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`col1` AS `col1` from `test`.`tbl_datetime` where (TIMESTAMP'2018-01-01 00:00:00.999999' <= `test`.`tbl_datetime`.`col1`) +# Expect "80.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_datetime WHERE col1 >= "1000-01-01 00:00:00.000000"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`col1` AS `col1` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`col1` >= TIMESTAMP'1000-01-01 00:00:00') +EXPLAIN SELECT * FROM tbl_datetime WHERE "1000-01-01 00:00:00.000000" <= col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`col1` AS `col1` from `test`.`tbl_datetime` where (TIMESTAMP'1000-01-01 00:00:00' <= `test`.`tbl_datetime`.`col1`) +# Expect "80.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_datetime WHERE col1 != "3019-01-01 10:10:10.101010"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`col1` AS `col1` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`col1` <> TIMESTAMP'3019-01-01 10:10:10.10101') +EXPLAIN SELECT * FROM tbl_datetime WHERE "3019-01-01 10:10:10.101010" != col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`col1` AS `col1` from `test`.`tbl_datetime` where (TIMESTAMP'3019-01-01 10:10:10.10101' <> `test`.`tbl_datetime`.`col1`) +EXPLAIN SELECT * FROM tbl_datetime WHERE col1 <> "3019-01-01 10:10:10.101010"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`col1` AS `col1` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`col1` <> TIMESTAMP'3019-01-01 10:10:10.10101') +EXPLAIN SELECT * FROM tbl_datetime WHERE "3019-01-01 10:10:10.101010" <> col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`col1` AS `col1` from `test`.`tbl_datetime` where (TIMESTAMP'3019-01-01 10:10:10.10101' <> `test`.`tbl_datetime`.`col1`) +# Expect "10.0" in column "filtered", due to the fact that the optimizer +# always assumes that at least one row will match. +EXPLAIN SELECT * FROM tbl_datetime WHERE col1 = "9999-12-31 23:59:59.999999"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`col1` AS `col1` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`col1` = TIMESTAMP'9999-12-31 23:59:59.999999') +EXPLAIN SELECT * FROM tbl_datetime WHERE "9999-12-31 23:59:59.999999" = col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`col1` AS `col1` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`col1` = TIMESTAMP'9999-12-31 23:59:59.999999') +# Expect "20.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_datetime WHERE col1 IS NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 20.00 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 10 20.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`col1` AS `col1` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`col1` is null) +# Expect "80.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_datetime WHERE col1 IS NOT NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`col1` AS `col1` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`col1` is not null) +# Expect "10.00" in column "filtered" +# This might seem low, but given the uniform distribution assuption in +# each bucket this is actually correct. +EXPLAIN SELECT * FROM tbl_datetime WHERE col1 BETWEEN "2017-01-01 00:00:00.000001" AND "3019-01-01 10:10:10.101010"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`col1` AS `col1` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`col1` between '2017-01-01 00:00:00.000001' and '3019-01-01 10:10:10.101010') +# Expect "74.98" in column "filtered" +# This might seem high, but given the uniform distribution assuption in +# each bucket this is actually correct. +EXPLAIN SELECT * FROM tbl_datetime WHERE col1 NOT BETWEEN "2017-01-01 00:00:00.000001" AND "3019-01-01 10:10:10.101010"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 74.98 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 10 74.98 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`col1` AS `col1` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`col1` not between '2017-01-01 00:00:00.000001' and '3019-01-01 10:10:10.101010') +# Expect "10.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_datetime WHERE col1 IN ("1000-01-01 00:00:00.000000", "2018-01-01 00:00:00.999999", "9999-12-31 23:59:59.999998"); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`col1` AS `col1` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`col1` in ('1000-01-01 00:00:00.000000','2018-01-01 00:00:00.999999','9999-12-31 23:59:59.999998')) +# Expect "80.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_datetime WHERE col1 NOT IN ("1000-01-01 00:00:00.000000", "2018-01-01 00:00:00.999999", "9999-12-31 23:59:59.999998"); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`col1` AS `col1` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`col1` not in ('1000-01-01 00:00:00.000000','2018-01-01 00:00:00.999999','9999-12-31 23:59:59.999998')) +DROP TABLE tbl_datetime; +# +# Decimal column, equi-height histogram +# +CREATE TABLE tbl_decimal (col1 DECIMAL(65, 30)); +INSERT INTO tbl_decimal VALUES +(00000000000000000000000000000000000.000000000000000000000000000000), +(99999999999999999999999999999999999.999999999999999999999999999998), +(-99999999999999999999999999999999999.999999999999999999999999999999), +(1), (2), (3), (4), (-1), (NULL), (NULL); +ANALYZE TABLE tbl_decimal UPDATE HISTOGRAM ON col1 WITH 2 BUCKETS; +Table Op Msg_type Msg_text +test.tbl_decimal histogram status Histogram statistics created for column 'col1'. +ANALYZE TABLE tbl_decimal; +Table Op Msg_type Msg_text +test.tbl_decimal analyze status OK +# Expect "40.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_decimal WHERE col1 > 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 40.00 Parallel execute (1 workers) +2 SIMPLE tbl_decimal NULL ALL NULL NULL NULL NULL 10 40.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_decimal`.`col1` AS `col1` from `test`.`tbl_decimal` where (`test`.`tbl_decimal`.`col1` > 1.000000000000000000000000000000) +EXPLAIN SELECT * FROM tbl_decimal WHERE 1 < col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 40.00 Parallel execute (1 workers) +2 SIMPLE tbl_decimal NULL ALL NULL NULL NULL NULL 10 40.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_decimal`.`col1` AS `col1` from `test`.`tbl_decimal` where (1.000000000000000000000000000000 < `test`.`tbl_decimal`.`col1`) +# Expect "10.0" in column "filtered" (we never estimate 0%) +EXPLAIN SELECT * FROM tbl_decimal WHERE col1 > 100000000000000000000000000000000000; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_decimal`.`col1` AS `col1` from `test`.`tbl_decimal` where false +EXPLAIN SELECT * FROM tbl_decimal WHERE 100000000000000000000000000000000000 < col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_decimal`.`col1` AS `col1` from `test`.`tbl_decimal` where false +# Expect "80.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_decimal WHERE col1 < 99999999999999999999999999999999999.999999999999999999999999999999; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_decimal NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_decimal`.`col1` AS `col1` from `test`.`tbl_decimal` where (`test`.`tbl_decimal`.`col1` < 99999999999999999999999999999999999.999999999999999999999999999999) +EXPLAIN SELECT * FROM tbl_decimal WHERE 99999999999999999999999999999999999.999999999999999999999999999999 > col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_decimal NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_decimal`.`col1` AS `col1` from `test`.`tbl_decimal` where (99999999999999999999999999999999999.999999999999999999999999999999 > `test`.`tbl_decimal`.`col1`) +# Expect "40.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_decimal WHERE col1 >= 4; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 40.00 Parallel execute (1 workers) +2 SIMPLE tbl_decimal NULL ALL NULL NULL NULL NULL 10 40.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_decimal`.`col1` AS `col1` from `test`.`tbl_decimal` where (`test`.`tbl_decimal`.`col1` >= 4.000000000000000000000000000000) +EXPLAIN SELECT * FROM tbl_decimal WHERE 4 <= col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 40.00 Parallel execute (1 workers) +2 SIMPLE tbl_decimal NULL ALL NULL NULL NULL NULL 10 40.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_decimal`.`col1` AS `col1` from `test`.`tbl_decimal` where (4.000000000000000000000000000000 <= `test`.`tbl_decimal`.`col1`) +# Expect "40.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_decimal WHERE col1 >= -1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 40.00 Parallel execute (1 workers) +2 SIMPLE tbl_decimal NULL ALL NULL NULL NULL NULL 10 40.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_decimal`.`col1` AS `col1` from `test`.`tbl_decimal` where (`test`.`tbl_decimal`.`col1` >= -1.000000000000000000000000000000) +EXPLAIN SELECT * FROM tbl_decimal WHERE -1 <= col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 40.00 Parallel execute (1 workers) +2 SIMPLE tbl_decimal NULL ALL NULL NULL NULL NULL 10 40.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_decimal`.`col1` AS `col1` from `test`.`tbl_decimal` where (-1.000000000000000000000000000000 <= `test`.`tbl_decimal`.`col1`) +# Expect "80.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_decimal WHERE col1 != 2.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_decimal NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_decimal`.`col1` AS `col1` from `test`.`tbl_decimal` where (`test`.`tbl_decimal`.`col1` <> 2.000000000000000000000000000000) +EXPLAIN SELECT * FROM tbl_decimal WHERE 2.0 != col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_decimal NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_decimal`.`col1` AS `col1` from `test`.`tbl_decimal` where (2.000000000000000000000000000000 <> `test`.`tbl_decimal`.`col1`) +EXPLAIN SELECT * FROM tbl_decimal WHERE col1 <> 2.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_decimal NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_decimal`.`col1` AS `col1` from `test`.`tbl_decimal` where (`test`.`tbl_decimal`.`col1` <> 2.000000000000000000000000000000) +EXPLAIN SELECT * FROM tbl_decimal WHERE 2.0 <> col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_decimal NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_decimal`.`col1` AS `col1` from `test`.`tbl_decimal` where (2.000000000000000000000000000000 <> `test`.`tbl_decimal`.`col1`) +# Expect "10.0" in column "filtered", due to the fact that the optimizer +# always assumes that at least one row will match. +EXPLAIN SELECT * FROM tbl_decimal WHERE col1 = "99999999999999999999999999999999999.999999999999999999999999999999"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_decimal NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_decimal`.`col1` AS `col1` from `test`.`tbl_decimal` where (`test`.`tbl_decimal`.`col1` = 99999999999999999999999999999999999.999999999999999999999999999999) +EXPLAIN SELECT * FROM tbl_decimal WHERE "99999999999999999999999999999999999.999999999999999999999999999999" = col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_decimal NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_decimal`.`col1` AS `col1` from `test`.`tbl_decimal` where (99999999999999999999999999999999999.999999999999999999999999999999 = `test`.`tbl_decimal`.`col1`) +# Expect "20.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_decimal WHERE col1 IS NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 20.00 Parallel execute (1 workers) +2 SIMPLE tbl_decimal NULL ALL NULL NULL NULL NULL 10 20.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_decimal`.`col1` AS `col1` from `test`.`tbl_decimal` where (`test`.`tbl_decimal`.`col1` is null) +# Expect "80.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_decimal WHERE col1 IS NOT NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_decimal NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_decimal`.`col1` AS `col1` from `test`.`tbl_decimal` where (`test`.`tbl_decimal`.`col1` is not null) +# This might seem low, but given the uniform distribution assuption in +# each bucket this is actually correct. +# Expect "10.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_decimal WHERE col1 BETWEEN -1.0 AND 4.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_decimal NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_decimal`.`col1` AS `col1` from `test`.`tbl_decimal` where (`test`.`tbl_decimal`.`col1` between (-(1.0)) and 4.0) +# This might seem high, but given the uniform distribution assuption in +# each bucket this is actually correct. +# Expect "80.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_decimal WHERE col1 NOT BETWEEN -1.0 AND 4.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_decimal NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_decimal`.`col1` AS `col1` from `test`.`tbl_decimal` where (`test`.`tbl_decimal`.`col1` not between (-(1.0)) and 4.0) +# Expect "10.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_decimal WHERE col1 IN +(-99999999999999999999999999999999999.999999999999999999999999999999, 1.0, 2.0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_decimal NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_decimal`.`col1` AS `col1` from `test`.`tbl_decimal` where (`test`.`tbl_decimal`.`col1` in ((-(99999999999999999999999999999999999.999999999999999999999999999999)),1.0,2.0)) +# Expect "80.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_decimal WHERE col1 NOT IN +(-99999999999999999999999999999999999.999999999999999999999999999999, 1.0, 2.0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_decimal NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_decimal`.`col1` AS `col1` from `test`.`tbl_decimal` where (`test`.`tbl_decimal`.`col1` not in ((-(99999999999999999999999999999999999.999999999999999999999999999999)),1.0,2.0)) +DROP TABLE tbl_decimal; +# +# ENUM column, equi-height histogram +# Note that we only support equality/inequality operators for ENUM +# columns. +# +CREATE TABLE tbl_enum (col1 ENUM('red', 'black', 'blue', 'green')); +INSERT INTO tbl_enum VALUES ('red'), ('red'), ('black'), ('blue'), ('green'), +('green'), (NULL), (NULL), (NULL); +ANALYZE TABLE tbl_enum UPDATE HISTOGRAM ON col1 WITH 2 BUCKETS; +Table Op Msg_type Msg_text +test.tbl_enum histogram status Histogram statistics created for column 'col1'. +ANALYZE TABLE tbl_enum; +Table Op Msg_type Msg_text +test.tbl_enum analyze status OK +# Expect "16.67" in column "filtered" +EXPLAIN SELECT * FROM tbl_enum WHERE col1 = 'red'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 9 16.67 Parallel execute (1 workers) +2 SIMPLE tbl_enum NULL ALL NULL NULL NULL NULL 9 16.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_enum`.`col1` AS `col1` from `test`.`tbl_enum` where (`test`.`tbl_enum`.`col1` = 'red') +EXPLAIN SELECT * FROM tbl_enum WHERE 'red' = col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 9 16.67 Parallel execute (1 workers) +2 SIMPLE tbl_enum NULL ALL NULL NULL NULL NULL 9 16.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_enum`.`col1` AS `col1` from `test`.`tbl_enum` where (`test`.`tbl_enum`.`col1` = 'red') +# Expect "50.00" in column "filtered" +EXPLAIN SELECT * FROM tbl_enum WHERE col1 != 'black'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 9 50.00 Parallel execute (1 workers) +2 SIMPLE tbl_enum NULL ALL NULL NULL NULL NULL 9 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_enum`.`col1` AS `col1` from `test`.`tbl_enum` where (`test`.`tbl_enum`.`col1` <> 'black') +EXPLAIN SELECT * FROM tbl_enum WHERE 'black' != col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 9 50.00 Parallel execute (1 workers) +2 SIMPLE tbl_enum NULL ALL NULL NULL NULL NULL 9 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_enum`.`col1` AS `col1` from `test`.`tbl_enum` where ('black' <> `test`.`tbl_enum`.`col1`) +EXPLAIN SELECT * FROM tbl_enum WHERE col1 <> 'black'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 9 50.00 Parallel execute (1 workers) +2 SIMPLE tbl_enum NULL ALL NULL NULL NULL NULL 9 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_enum`.`col1` AS `col1` from `test`.`tbl_enum` where (`test`.`tbl_enum`.`col1` <> 'black') +EXPLAIN SELECT * FROM tbl_enum WHERE 'black' <> col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 9 50.00 Parallel execute (1 workers) +2 SIMPLE tbl_enum NULL ALL NULL NULL NULL NULL 9 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_enum`.`col1` AS `col1` from `test`.`tbl_enum` where ('black' <> `test`.`tbl_enum`.`col1`) +# Expect "66.67" in column "filtered" +EXPLAIN SELECT * FROM tbl_enum WHERE col1 != ''; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 9 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_enum NULL ALL NULL NULL NULL NULL 9 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_enum`.`col1` AS `col1` from `test`.`tbl_enum` where (`test`.`tbl_enum`.`col1` <> '') +EXPLAIN SELECT * FROM tbl_enum WHERE col1 != 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 9 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_enum NULL ALL NULL NULL NULL NULL 9 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_enum`.`col1` AS `col1` from `test`.`tbl_enum` where (`test`.`tbl_enum`.`col1` <> 0) +EXPLAIN SELECT * FROM tbl_enum WHERE col1 <> ''; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 9 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_enum NULL ALL NULL NULL NULL NULL 9 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_enum`.`col1` AS `col1` from `test`.`tbl_enum` where (`test`.`tbl_enum`.`col1` <> '') +EXPLAIN SELECT * FROM tbl_enum WHERE col1 <> 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 9 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_enum NULL ALL NULL NULL NULL NULL 9 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_enum`.`col1` AS `col1` from `test`.`tbl_enum` where (`test`.`tbl_enum`.`col1` <> 0) +# Expect "50.00" in column "filtered" +EXPLAIN SELECT * FROM tbl_enum WHERE col1 IN ('black', 'blue', 'green'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 9 50.00 Parallel execute (1 workers) +2 SIMPLE tbl_enum NULL ALL NULL NULL NULL NULL 9 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_enum`.`col1` AS `col1` from `test`.`tbl_enum` where (`test`.`tbl_enum`.`col1` in ('black','blue','green')) +# Expect "33.33" in column "filtered" +EXPLAIN SELECT * FROM tbl_enum WHERE col1 NOT IN ('green', 'blue'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 9 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_enum NULL ALL NULL NULL NULL NULL 9 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_enum`.`col1` AS `col1` from `test`.`tbl_enum` where (`test`.`tbl_enum`.`col1` not in ('green','blue')) +# Expect "33.33" in column "filtered" +EXPLAIN SELECT * FROM tbl_enum WHERE col1 IS NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 9 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_enum NULL ALL NULL NULL NULL NULL 9 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_enum`.`col1` AS `col1` from `test`.`tbl_enum` where (`test`.`tbl_enum`.`col1` is null) +# Expect "66.67" in column "filtered" +EXPLAIN SELECT * FROM tbl_enum WHERE col1 IS NOT NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 9 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_enum NULL ALL NULL NULL NULL NULL 9 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_enum`.`col1` AS `col1` from `test`.`tbl_enum` where (`test`.`tbl_enum`.`col1` is not null) +# Test that the numerical representation of enum values also gives the +# correct result. +# Expect "16.67" in column "filtered" +EXPLAIN SELECT * FROM tbl_enum WHERE col1 = 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 9 16.67 Parallel execute (1 workers) +2 SIMPLE tbl_enum NULL ALL NULL NULL NULL NULL 9 16.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_enum`.`col1` AS `col1` from `test`.`tbl_enum` where (`test`.`tbl_enum`.`col1` = 1) +EXPLAIN SELECT * FROM tbl_enum WHERE 1 = col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 9 16.67 Parallel execute (1 workers) +2 SIMPLE tbl_enum NULL ALL NULL NULL NULL NULL 9 16.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_enum`.`col1` AS `col1` from `test`.`tbl_enum` where (1 = `test`.`tbl_enum`.`col1`) +# Expect "50.00" in column "filtered" +EXPLAIN SELECT * FROM tbl_enum WHERE col1 != 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 9 50.00 Parallel execute (1 workers) +2 SIMPLE tbl_enum NULL ALL NULL NULL NULL NULL 9 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_enum`.`col1` AS `col1` from `test`.`tbl_enum` where (`test`.`tbl_enum`.`col1` <> 2) +EXPLAIN SELECT * FROM tbl_enum WHERE 2 != col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 9 50.00 Parallel execute (1 workers) +2 SIMPLE tbl_enum NULL ALL NULL NULL NULL NULL 9 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_enum`.`col1` AS `col1` from `test`.`tbl_enum` where (2 <> `test`.`tbl_enum`.`col1`) +EXPLAIN SELECT * FROM tbl_enum WHERE col1 <> 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 9 50.00 Parallel execute (1 workers) +2 SIMPLE tbl_enum NULL ALL NULL NULL NULL NULL 9 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_enum`.`col1` AS `col1` from `test`.`tbl_enum` where (`test`.`tbl_enum`.`col1` <> 2) +EXPLAIN SELECT * FROM tbl_enum WHERE 2 <> col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 9 50.00 Parallel execute (1 workers) +2 SIMPLE tbl_enum NULL ALL NULL NULL NULL NULL 9 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_enum`.`col1` AS `col1` from `test`.`tbl_enum` where (2 <> `test`.`tbl_enum`.`col1`) +# Expect "11.11" in column "filtered", due to the fact that the optimizer +# always assumes that at least one row will match. +EXPLAIN SELECT * FROM tbl_enum WHERE col1 = 100; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 9 11.11 Parallel execute (1 workers) +2 SIMPLE tbl_enum NULL ALL NULL NULL NULL NULL 9 11.11 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_enum`.`col1` AS `col1` from `test`.`tbl_enum` where (`test`.`tbl_enum`.`col1` = 100) +EXPLAIN SELECT * FROM tbl_enum WHERE 100 = col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 9 11.11 Parallel execute (1 workers) +2 SIMPLE tbl_enum NULL ALL NULL NULL NULL NULL 9 11.11 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_enum`.`col1` AS `col1` from `test`.`tbl_enum` where (100 = `test`.`tbl_enum`.`col1`) +# Expect "50.00" in column "filtered" +EXPLAIN SELECT * FROM tbl_enum WHERE col1 IN (2, 3, 4); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 9 50.00 Parallel execute (1 workers) +2 SIMPLE tbl_enum NULL ALL NULL NULL NULL NULL 9 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_enum`.`col1` AS `col1` from `test`.`tbl_enum` where (`test`.`tbl_enum`.`col1` in (2,3,4)) +# Expect "33.33" in column "filtered" +EXPLAIN SELECT * FROM tbl_enum WHERE col1 NOT IN (4, 3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 9 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_enum NULL ALL NULL NULL NULL NULL 9 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_enum`.`col1` AS `col1` from `test`.`tbl_enum` where (`test`.`tbl_enum`.`col1` not in (4,3)) +DROP TABLE tbl_enum; +# +# SET column, equi-height histogram +# Note that we only support equality/inequality operators for SET +# columns. +# +CREATE TABLE tbl_set (col1 SET('red', 'black', 'blue', 'green')); +INSERT INTO tbl_set VALUES ('red'), ('red,black'), ('black,green,blue'), +('black,green,blue'), ('black,green,blue'), +('green'), ('green,red'), ('red,green'), (NULL), +(NULL), (NULL); +ANALYZE TABLE tbl_set UPDATE HISTOGRAM ON col1 WITH 2 BUCKETS; +Table Op Msg_type Msg_text +test.tbl_set histogram status Histogram statistics created for column 'col1'. +ANALYZE TABLE tbl_set; +Table Op Msg_type Msg_text +test.tbl_set analyze status OK +# Expect "9.09" in column "filtered" +EXPLAIN SELECT * FROM tbl_set WHERE col1 = 'red,green'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 9.09 Parallel execute (1 workers) +2 SIMPLE tbl_set NULL ALL NULL NULL NULL NULL 11 9.09 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_set`.`col1` AS `col1` from `test`.`tbl_set` where (`test`.`tbl_set`.`col1` = 'red,green') +EXPLAIN SELECT * FROM tbl_set WHERE 'red,green' = col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 9.09 Parallel execute (1 workers) +2 SIMPLE tbl_set NULL ALL NULL NULL NULL NULL 11 9.09 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_set`.`col1` AS `col1` from `test`.`tbl_set` where (`test`.`tbl_set`.`col1` = 'red,green') +# Expect "67.68" in column "filtered" +EXPLAIN SELECT * FROM tbl_set WHERE col1 != 'red'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 67.68 Parallel execute (1 workers) +2 SIMPLE tbl_set NULL ALL NULL NULL NULL NULL 11 67.68 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_set`.`col1` AS `col1` from `test`.`tbl_set` where (`test`.`tbl_set`.`col1` <> 'red') +EXPLAIN SELECT * FROM tbl_set WHERE 'red' != col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 67.68 Parallel execute (1 workers) +2 SIMPLE tbl_set NULL ALL NULL NULL NULL NULL 11 67.68 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_set`.`col1` AS `col1` from `test`.`tbl_set` where ('red' <> `test`.`tbl_set`.`col1`) +EXPLAIN SELECT * FROM tbl_set WHERE col1 <> 'red'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 67.68 Parallel execute (1 workers) +2 SIMPLE tbl_set NULL ALL NULL NULL NULL NULL 11 67.68 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_set`.`col1` AS `col1` from `test`.`tbl_set` where (`test`.`tbl_set`.`col1` <> 'red') +EXPLAIN SELECT * FROM tbl_set WHERE 'red' <> col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 67.68 Parallel execute (1 workers) +2 SIMPLE tbl_set NULL ALL NULL NULL NULL NULL 11 67.68 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_set`.`col1` AS `col1` from `test`.`tbl_set` where ('red' <> `test`.`tbl_set`.`col1`) +# Expect "72.73" in column "filtered" +EXPLAIN SELECT * FROM tbl_set WHERE col1 != ''; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 72.73 Parallel execute (1 workers) +2 SIMPLE tbl_set NULL ALL NULL NULL NULL NULL 11 72.73 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_set`.`col1` AS `col1` from `test`.`tbl_set` where (`test`.`tbl_set`.`col1` <> '') +EXPLAIN SELECT * FROM tbl_set WHERE col1 != 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 72.73 Parallel execute (1 workers) +2 SIMPLE tbl_set NULL ALL NULL NULL NULL NULL 11 72.73 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_set`.`col1` AS `col1` from `test`.`tbl_set` where (`test`.`tbl_set`.`col1` <> 0) +EXPLAIN SELECT * FROM tbl_set WHERE col1 <> ''; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 72.73 Parallel execute (1 workers) +2 SIMPLE tbl_set NULL ALL NULL NULL NULL NULL 11 72.73 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_set`.`col1` AS `col1` from `test`.`tbl_set` where (`test`.`tbl_set`.`col1` <> '') +EXPLAIN SELECT * FROM tbl_set WHERE col1 <> 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 72.73 Parallel execute (1 workers) +2 SIMPLE tbl_set NULL ALL NULL NULL NULL NULL 11 72.73 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_set`.`col1` AS `col1` from `test`.`tbl_set` where (`test`.`tbl_set`.`col1` <> 0) +# Expect "32.32" in column "filtered" +EXPLAIN SELECT * FROM tbl_set WHERE col1 IN ('green', 'black,blue,green'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 32.32 Parallel execute (1 workers) +2 SIMPLE tbl_set NULL ALL NULL NULL NULL NULL 11 32.32 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_set`.`col1` AS `col1` from `test`.`tbl_set` where (`test`.`tbl_set`.`col1` in ('green','black,blue,green')) +# Expect "40.40" in column "filtered" +EXPLAIN SELECT * FROM tbl_set WHERE col1 NOT IN ('green', 'black,blue,green'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 40.40 Parallel execute (1 workers) +2 SIMPLE tbl_set NULL ALL NULL NULL NULL NULL 11 40.40 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_set`.`col1` AS `col1` from `test`.`tbl_set` where (`test`.`tbl_set`.`col1` not in ('green','black,blue,green')) +# Expect "27.27" in column "filtered" +EXPLAIN SELECT * FROM tbl_set WHERE col1 IS NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 27.27 Parallel execute (1 workers) +2 SIMPLE tbl_set NULL ALL NULL NULL NULL NULL 11 27.27 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_set`.`col1` AS `col1` from `test`.`tbl_set` where (`test`.`tbl_set`.`col1` is null) +# Expect "72.73" in column "filtered" +EXPLAIN SELECT * FROM tbl_set WHERE col1 IS NOT NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 72.73 Parallel execute (1 workers) +2 SIMPLE tbl_set NULL ALL NULL NULL NULL NULL 11 72.73 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_set`.`col1` AS `col1` from `test`.`tbl_set` where (`test`.`tbl_set`.`col1` is not null) +# Test that the numerical representation of set values also gives the +# correct result. +# Expect "9.09" in column "filtered" +EXPLAIN SELECT * FROM tbl_set WHERE col1 = 9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 9.09 Parallel execute (1 workers) +2 SIMPLE tbl_set NULL ALL NULL NULL NULL NULL 11 9.09 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_set`.`col1` AS `col1` from `test`.`tbl_set` where (`test`.`tbl_set`.`col1` = 9) +EXPLAIN SELECT * FROM tbl_set WHERE 9 = col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 9.09 Parallel execute (1 workers) +2 SIMPLE tbl_set NULL ALL NULL NULL NULL NULL 11 9.09 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_set`.`col1` AS `col1` from `test`.`tbl_set` where (9 = `test`.`tbl_set`.`col1`) +# Expect "67.68" in column "filtered" +EXPLAIN SELECT * FROM tbl_set WHERE col1 != 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 67.68 Parallel execute (1 workers) +2 SIMPLE tbl_set NULL ALL NULL NULL NULL NULL 11 67.68 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_set`.`col1` AS `col1` from `test`.`tbl_set` where (`test`.`tbl_set`.`col1` <> 1) +EXPLAIN SELECT * FROM tbl_set WHERE 1 != col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 67.68 Parallel execute (1 workers) +2 SIMPLE tbl_set NULL ALL NULL NULL NULL NULL 11 67.68 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_set`.`col1` AS `col1` from `test`.`tbl_set` where (1 <> `test`.`tbl_set`.`col1`) +EXPLAIN SELECT * FROM tbl_set WHERE col1 <> 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 67.68 Parallel execute (1 workers) +2 SIMPLE tbl_set NULL ALL NULL NULL NULL NULL 11 67.68 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_set`.`col1` AS `col1` from `test`.`tbl_set` where (`test`.`tbl_set`.`col1` <> 1) +EXPLAIN SELECT * FROM tbl_set WHERE 1 <> col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 67.68 Parallel execute (1 workers) +2 SIMPLE tbl_set NULL ALL NULL NULL NULL NULL 11 67.68 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_set`.`col1` AS `col1` from `test`.`tbl_set` where (1 <> `test`.`tbl_set`.`col1`) +# Expect "72.73" in column "filtered" +EXPLAIN SELECT * FROM tbl_set WHERE col1 != ''; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 72.73 Parallel execute (1 workers) +2 SIMPLE tbl_set NULL ALL NULL NULL NULL NULL 11 72.73 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_set`.`col1` AS `col1` from `test`.`tbl_set` where (`test`.`tbl_set`.`col1` <> '') +EXPLAIN SELECT * FROM tbl_set WHERE col1 != 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 72.73 Parallel execute (1 workers) +2 SIMPLE tbl_set NULL ALL NULL NULL NULL NULL 11 72.73 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_set`.`col1` AS `col1` from `test`.`tbl_set` where (`test`.`tbl_set`.`col1` <> 0) +EXPLAIN SELECT * FROM tbl_set WHERE col1 <> ''; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 72.73 Parallel execute (1 workers) +2 SIMPLE tbl_set NULL ALL NULL NULL NULL NULL 11 72.73 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_set`.`col1` AS `col1` from `test`.`tbl_set` where (`test`.`tbl_set`.`col1` <> '') +EXPLAIN SELECT * FROM tbl_set WHERE col1 <> 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 72.73 Parallel execute (1 workers) +2 SIMPLE tbl_set NULL ALL NULL NULL NULL NULL 11 72.73 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_set`.`col1` AS `col1` from `test`.`tbl_set` where (`test`.`tbl_set`.`col1` <> 0) +# Expect "9.09" in column "filtered", due to the fact that the optimizer +# always assumes that at least one row will match. +EXPLAIN SELECT * FROM tbl_set WHERE col1 = 100; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 9.09 Parallel execute (1 workers) +2 SIMPLE tbl_set NULL ALL NULL NULL NULL NULL 11 9.09 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_set`.`col1` AS `col1` from `test`.`tbl_set` where (`test`.`tbl_set`.`col1` = 100) +EXPLAIN SELECT * FROM tbl_set WHERE 100 = col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 9.09 Parallel execute (1 workers) +2 SIMPLE tbl_set NULL ALL NULL NULL NULL NULL 11 9.09 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_set`.`col1` AS `col1` from `test`.`tbl_set` where (100 = `test`.`tbl_set`.`col1`) +# Expect "32.32" in column "filtered" +EXPLAIN SELECT * FROM tbl_set WHERE col1 IN (8, 14); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 32.32 Parallel execute (1 workers) +2 SIMPLE tbl_set NULL ALL NULL NULL NULL NULL 11 32.32 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_set`.`col1` AS `col1` from `test`.`tbl_set` where (`test`.`tbl_set`.`col1` in (8,14)) +# Expect "40.40" in column "filtered" +EXPLAIN SELECT * FROM tbl_set WHERE col1 NOT IN (8, 14); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 40.40 Parallel execute (1 workers) +2 SIMPLE tbl_set NULL ALL NULL NULL NULL NULL 11 40.40 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_set`.`col1` AS `col1` from `test`.`tbl_set` where (`test`.`tbl_set`.`col1` not in (8,14)) +DROP TABLE tbl_set; +# +# Tests for covering various corner cases that hasn't already been +# covered. +# +CREATE TABLE t1 (col1 VARCHAR(255)); +INSERT INTO t1 VALUES ("a"), ("a"), ("a"), ("a"), ("a"), ("a"), ("a"), ("b"), +("c"), ("d"); +ANALYZE TABLE t1 UPDATE HISTOGRAM ON col1 WITH 2 BUCKETS; +Table Op Msg_type Msg_text +test.t1 histogram status Histogram statistics created for column 'col1'. +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT * FROM t1 WHERE col1 < "a"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col1` AS `col1` from `test`.`t1` where (`test`.`t1`.`col1` < 'a') +DROP TABLE t1; +CREATE TABLE t1 (col1 DECIMAL); +INSERT INTO t1 VALUES (1.0), (1.0), (1.0), (1.0), (1.0), (1.0), (1.0), (2.0), +(3.0), (4.0); +ANALYZE TABLE t1 UPDATE HISTOGRAM ON col1 WITH 2 BUCKETS; +Table Op Msg_type Msg_text +test.t1 histogram status Histogram statistics created for column 'col1'. +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT * FROM t1 WHERE col1 < 0.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col1` AS `col1` from `test`.`t1` where (`test`.`t1`.`col1` < 0) +EXPLAIN SELECT * FROM t1 WHERE col1 < 1.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col1` AS `col1` from `test`.`t1` where (`test`.`t1`.`col1` < 1) +DROP TABLE t1; +CREATE TABLE t1 (col1 BIGINT UNSIGNED); +INSERT INTO t1 VALUES (100), (100), (100), (100), (100), (100), (100), (200), +(300), (400); +ANALYZE TABLE t1 UPDATE HISTOGRAM ON col1 WITH 2 BUCKETS; +Table Op Msg_type Msg_text +test.t1 histogram status Histogram statistics created for column 'col1'. +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT * FROM t1 WHERE col1 <= 100; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 70.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 70.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col1` AS `col1` from `test`.`t1` where (`test`.`t1`.`col1` <= 100) +EXPLAIN SELECT * FROM t1 WHERE col1 <= 150; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 70.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 70.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col1` AS `col1` from `test`.`t1` where (`test`.`t1`.`col1` <= 150) +EXPLAIN SELECT * FROM t1 WHERE 150 >= col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 70.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 70.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col1` AS `col1` from `test`.`t1` where (150 >= `test`.`t1`.`col1`) +EXPLAIN SELECT * FROM t1 WHERE col1 BETWEEN 0 AND RAND(); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 11.11 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 11.11 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col1` AS `col1` from `test`.`t1` where (`test`.`t1`.`col1` between 0 and rand()) +EXPLAIN SELECT * FROM t1 WHERE col1 BETWEEN 1 AND NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 11.11 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 11.11 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col1` AS `col1` from `test`.`t1` where (`test`.`t1`.`col1` between 1 and NULL) +EXPLAIN SELECT * FROM t1 WHERE col1 IN (1, RAND()); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 20.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 20.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col1` AS `col1` from `test`.`t1` where (`test`.`t1`.`col1` in (1,rand())) +EXPLAIN SELECT * FROM t1 WHERE col1 IN (1, NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 20.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 20.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col1` AS `col1` from `test`.`t1` where (`test`.`t1`.`col1` in (1,NULL)) +EXPLAIN SELECT * FROM t1 WHERE col1 IN (100, 100, 100, 100, 100, 100); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col1` AS `col1` from `test`.`t1` where (`test`.`t1`.`col1` in (100,100,100,100,100,100)) +EXPLAIN SELECT * FROM t1 WHERE col1 NOT IN (1, NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col1` AS `col1` from `test`.`t1` where (`test`.`t1`.`col1` not in (1,NULL)) +EXPLAIN SELECT * FROM t1 WHERE col1 NOT IN (100, 100, 100, 100, 100, 100); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col1` AS `col1` from `test`.`t1` where (`test`.`t1`.`col1` not in (100,100,100,100,100,100)) +EXPLAIN SELECT * FROM t1 WHERE col1 <= NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col1` AS `col1` from `test`.`t1` where (`test`.`t1`.`col1` <= NULL) +EXPLAIN SELECT * FROM t1 WHERE col1 >= NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col1` AS `col1` from `test`.`t1` where (`test`.`t1`.`col1` >= NULL) +EXPLAIN SELECT * FROM t1 WHERE col1 != NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 90.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 90.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col1` AS `col1` from `test`.`t1` where (`test`.`t1`.`col1` <> NULL) +DROP TABLE t1; +CREATE TABLE t1 (col1 TIME); +INSERT INTO t1 VALUES ("00:00:00"), ("00:00:00"), ("00:00:00"), ("00:00:00"), +("00:00:00"), ("00:00:00"), ("00:00:00"), ("00:01:00"), +("00:02:00"), ("00:03:00"); +ANALYZE TABLE t1 UPDATE HISTOGRAM ON col1 WITH 2 BUCKETS; +Table Op Msg_type Msg_text +test.t1 histogram status Histogram statistics created for column 'col1'. +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT * FROM t1 WHERE col1 < "00:00:00"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col1` AS `col1` from `test`.`t1` where (`test`.`t1`.`col1` < TIME'00:00:00') +EXPLAIN SELECT * FROM t1 WHERE col1 NOT BETWEEN "00:00:00" AND ""; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 88.89 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 88.89 Using where +Warnings: +Warning 1292 Truncated incorrect time value: '' +Warning 1292 Truncated incorrect time value: '' +Note 1003 /* select#1 */ select `test`.`t1`.`col1` AS `col1` from `test`.`t1` where (`test`.`t1`.`col1` not between '00:00:00' and '') +DROP TABLE t1; diff --git a/mysql-test/r/histogram_singleton.result-pq b/mysql-test/r/histogram_singleton.result-pq new file mode 100644 index 000000000000..d30afae19e62 --- /dev/null +++ b/mysql-test/r/histogram_singleton.result-pq @@ -0,0 +1,1591 @@ +# +# Integer column, singleton histogram +# +CREATE TABLE tbl_int (col1 INT); +INSERT INTO tbl_int VALUES (1), (2), (3), (4), (5), (6), (7), (8), (NULL), (NULL); +ANALYZE TABLE tbl_int; +Table Op Msg_type Msg_text +test.tbl_int analyze status OK +ANALYZE TABLE tbl_int UPDATE HISTOGRAM ON col1 WITH 10 BUCKETS; +Table Op Msg_type Msg_text +test.tbl_int histogram status Histogram statistics created for column 'col1'. +# Expect "80.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_int WHERE col1 > 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` > 0) +EXPLAIN SELECT * FROM tbl_int WHERE 0 < col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (0 < `test`.`tbl_int`.`col1`) +# Expect "10.0" in column "filtered" (we never estimate 0%) +EXPLAIN SELECT * FROM tbl_int WHERE col1 > 8; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` > 8) +EXPLAIN SELECT * FROM tbl_int WHERE 8 < col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (8 < `test`.`tbl_int`.`col1`) +# Expect "10.0" in column "filtered" (we never estimate 0%) +EXPLAIN SELECT * FROM tbl_int WHERE col1 < 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` < 0) +EXPLAIN SELECT * FROM tbl_int WHERE 0 > col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (0 > `test`.`tbl_int`.`col1`) +# Expect "80.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_int WHERE col1 < 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` < 10) +EXPLAIN SELECT * FROM tbl_int WHERE 10 > col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (10 > `test`.`tbl_int`.`col1`) +# Expect "30.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_int WHERE col1 >= 6; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 30.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 30.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` >= 6) +EXPLAIN SELECT * FROM tbl_int WHERE 6 <= col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 30.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 30.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (6 <= `test`.`tbl_int`.`col1`) +# Expect "80.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_int WHERE col1 >= -100; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` >= (-(100))) +EXPLAIN SELECT * FROM tbl_int WHERE -100 <= col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where ((-(100)) <= `test`.`tbl_int`.`col1`) +# Expect "70.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_int WHERE col1 != 8; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 70.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 70.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` <> 8) +EXPLAIN SELECT * FROM tbl_int WHERE 8 != col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 70.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 70.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (8 <> `test`.`tbl_int`.`col1`) +EXPLAIN SELECT * FROM tbl_int WHERE col1 <> 8; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 70.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 70.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` <> 8) +EXPLAIN SELECT * FROM tbl_int WHERE 8 <> col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 70.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 70.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (8 <> `test`.`tbl_int`.`col1`) +# Expect "10.0" in column "filtered", due to the fact that the optimizer +# always assumes that at least one row will match. +EXPLAIN SELECT * FROM tbl_int WHERE col1 = 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` = 10) +EXPLAIN SELECT * FROM tbl_int WHERE 10 = col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` = 10) +# Expect "20.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_int WHERE col1 IS NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 20.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 20.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` is null) +# Expect "80.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_int WHERE col1 IS NOT NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` is not null) +# Expect "30.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_int WHERE col1 BETWEEN 1 AND 3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 30.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 30.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` between 1 and 3) +# Expect "50.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_int WHERE col1 NOT BETWEEN 1 AND 3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 50.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` not between 1 and 3) +# Expect "60.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_int WHERE col1 IN (1, 3, 4, 5, 6, 7); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 60.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 60.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` in (1,3,4,5,6,7)) +# Expect "20.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_int WHERE col1 NOT IN (1, 3, 4, 5, 6, 7); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 20.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 20.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` not in (1,3,4,5,6,7)) +DROP TABLE tbl_int; +# +# String column, singleton histogram +# +CREATE TABLE tbl_varchar (col1 VARCHAR(255)); +INSERT INTO tbl_varchar VALUES +("abcd"), ("ðŸ£"), ("ðŸº"), ("eeeeeeeeee"), ("ef"), ("AG"), +("a very long string that is longer than 42 characters"), +("lorem ipsum"), (NULL), (NULL); +ANALYZE TABLE tbl_varchar UPDATE HISTOGRAM ON col1 WITH 10 BUCKETS; +Table Op Msg_type Msg_text +test.tbl_varchar histogram status Histogram statistics created for column 'col1'. +ANALYZE TABLE tbl_varchar; +Table Op Msg_type Msg_text +test.tbl_varchar analyze status OK +# Expect "30.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_varchar WHERE col1 > "b"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 30.00 Parallel execute (1 workers) +2 SIMPLE tbl_varchar NULL ALL NULL NULL NULL NULL 10 30.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_varchar`.`col1` AS `col1` from `test`.`tbl_varchar` where (`test`.`tbl_varchar`.`col1` > 'b') +EXPLAIN SELECT * FROM tbl_varchar WHERE "b" < col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 30.00 Parallel execute (1 workers) +2 SIMPLE tbl_varchar NULL ALL NULL NULL NULL NULL 10 30.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_varchar`.`col1` AS `col1` from `test`.`tbl_varchar` where ('b' < `test`.`tbl_varchar`.`col1`) +# Expect "10.0" in column "filtered" (we never estimate 0%) +EXPLAIN SELECT * FROM tbl_varchar WHERE col1 > "lp"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_varchar NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_varchar`.`col1` AS `col1` from `test`.`tbl_varchar` where (`test`.`tbl_varchar`.`col1` > 'lp') +EXPLAIN SELECT * FROM tbl_varchar WHERE "lp" < col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_varchar NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_varchar`.`col1` AS `col1` from `test`.`tbl_varchar` where ('lp' < `test`.`tbl_varchar`.`col1`) +# Expect "10.0" in column "filtered" (we never estimate 0%) +EXPLAIN SELECT * FROM tbl_varchar WHERE col1 < "ðŸ¡"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_varchar NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Warning 1300 Cannot convert string '\xF0\x9F\x8D\xA1' from utf8mb4 to utf8 +Note 1003 /* select#1 */ select `test`.`tbl_varchar`.`col1` AS `col1` from `test`.`tbl_varchar` where (`test`.`tbl_varchar`.`col1` < '?') +EXPLAIN SELECT * FROM tbl_varchar WHERE "ðŸ¡" > col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_varchar NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Warning 1300 Cannot convert string '\xF0\x9F\x8D\xA1' from utf8mb4 to utf8 +Note 1003 /* select#1 */ select `test`.`tbl_varchar`.`col1` AS `col1` from `test`.`tbl_varchar` where ('?' > `test`.`tbl_varchar`.`col1`) +# Expect "80.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_varchar WHERE col1 < "sierra"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_varchar NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_varchar`.`col1` AS `col1` from `test`.`tbl_varchar` where (`test`.`tbl_varchar`.`col1` < 'sierra') +EXPLAIN SELECT * FROM tbl_varchar WHERE "sierra" > col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_varchar NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_varchar`.`col1` AS `col1` from `test`.`tbl_varchar` where ('sierra' > `test`.`tbl_varchar`.`col1`) +# Expect "50.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_varchar WHERE col1 >= "abcd"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 50.00 Parallel execute (1 workers) +2 SIMPLE tbl_varchar NULL ALL NULL NULL NULL NULL 10 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_varchar`.`col1` AS `col1` from `test`.`tbl_varchar` where (`test`.`tbl_varchar`.`col1` >= 'abcd') +EXPLAIN SELECT * FROM tbl_varchar WHERE "abcd" <= col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 50.00 Parallel execute (1 workers) +2 SIMPLE tbl_varchar NULL ALL NULL NULL NULL NULL 10 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_varchar`.`col1` AS `col1` from `test`.`tbl_varchar` where ('abcd' <= `test`.`tbl_varchar`.`col1`) +# Expect "80.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_varchar WHERE col1 >= ""; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_varchar NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_varchar`.`col1` AS `col1` from `test`.`tbl_varchar` where (`test`.`tbl_varchar`.`col1` >= '') +EXPLAIN SELECT * FROM tbl_varchar WHERE "" <= col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_varchar NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_varchar`.`col1` AS `col1` from `test`.`tbl_varchar` where ('' <= `test`.`tbl_varchar`.`col1`) +# Expect "70.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_varchar WHERE col1 != "lorem ipsum"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 70.00 Parallel execute (1 workers) +2 SIMPLE tbl_varchar NULL ALL NULL NULL NULL NULL 10 70.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_varchar`.`col1` AS `col1` from `test`.`tbl_varchar` where (`test`.`tbl_varchar`.`col1` <> 'lorem ipsum') +EXPLAIN SELECT * FROM tbl_varchar WHERE "lorem ipsum" != col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 70.00 Parallel execute (1 workers) +2 SIMPLE tbl_varchar NULL ALL NULL NULL NULL NULL 10 70.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_varchar`.`col1` AS `col1` from `test`.`tbl_varchar` where ('lorem ipsum' <> `test`.`tbl_varchar`.`col1`) +EXPLAIN SELECT * FROM tbl_varchar WHERE col1 <> "lorem ipsum"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 70.00 Parallel execute (1 workers) +2 SIMPLE tbl_varchar NULL ALL NULL NULL NULL NULL 10 70.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_varchar`.`col1` AS `col1` from `test`.`tbl_varchar` where (`test`.`tbl_varchar`.`col1` <> 'lorem ipsum') +EXPLAIN SELECT * FROM tbl_varchar WHERE "lorem ipsum" <> col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 70.00 Parallel execute (1 workers) +2 SIMPLE tbl_varchar NULL ALL NULL NULL NULL NULL 10 70.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_varchar`.`col1` AS `col1` from `test`.`tbl_varchar` where ('lorem ipsum' <> `test`.`tbl_varchar`.`col1`) +# Expect "10.0" in column "filtered", due to the fact that the optimizer +# always assumes that at least one row will match. +EXPLAIN SELECT * FROM tbl_varchar WHERE col1 = "sierra"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_varchar NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_varchar`.`col1` AS `col1` from `test`.`tbl_varchar` where (`test`.`tbl_varchar`.`col1` = 'sierra') +EXPLAIN SELECT * FROM tbl_varchar WHERE "sierra" = col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_varchar NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_varchar`.`col1` AS `col1` from `test`.`tbl_varchar` where (`test`.`tbl_varchar`.`col1` = 'sierra') +# Expect "20.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_varchar WHERE col1 IS NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 20.00 Parallel execute (1 workers) +2 SIMPLE tbl_varchar NULL ALL NULL NULL NULL NULL 10 20.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_varchar`.`col1` AS `col1` from `test`.`tbl_varchar` where (`test`.`tbl_varchar`.`col1` is null) +# Expect "80.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_varchar WHERE col1 IS NOT NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_varchar NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_varchar`.`col1` AS `col1` from `test`.`tbl_varchar` where (`test`.`tbl_varchar`.`col1` is not null) +# Expect "30.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_varchar WHERE col1 BETWEEN "a" AND "b"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 30.00 Parallel execute (1 workers) +2 SIMPLE tbl_varchar NULL ALL NULL NULL NULL NULL 10 30.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_varchar`.`col1` AS `col1` from `test`.`tbl_varchar` where (`test`.`tbl_varchar`.`col1` between 'a' and 'b') +# Expect "50.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_varchar WHERE col1 NOT BETWEEN "a" AND "b"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 50.00 Parallel execute (1 workers) +2 SIMPLE tbl_varchar NULL ALL NULL NULL NULL NULL 10 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_varchar`.`col1` AS `col1` from `test`.`tbl_varchar` where (`test`.`tbl_varchar`.`col1` not between 'a' and 'b') +# Expect "30.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_varchar WHERE col1 IN ("ag", "ef", "ðŸ£"); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 30.00 Parallel execute (1 workers) +2 SIMPLE tbl_varchar NULL ALL NULL NULL NULL NULL 10 30.00 Using where +Warnings: +Warning 1300 Cannot convert string '\xF0\x9F\x8D\xA3' from utf8mb4 to utf8 +Note 1003 /* select#1 */ select `test`.`tbl_varchar`.`col1` AS `col1` from `test`.`tbl_varchar` where (`test`.`tbl_varchar`.`col1` in ('ag','ef','?')) +# Expect "50.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_varchar WHERE col1 NOT IN ("ag", "ef", "ðŸ£"); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 50.00 Parallel execute (1 workers) +2 SIMPLE tbl_varchar NULL ALL NULL NULL NULL NULL 10 50.00 Using where +Warnings: +Warning 1300 Cannot convert string '\xF0\x9F\x8D\xA3' from utf8mb4 to utf8 +Note 1003 /* select#1 */ select `test`.`tbl_varchar`.`col1` AS `col1` from `test`.`tbl_varchar` where (`test`.`tbl_varchar`.`col1` not in ('ag','ef','?')) +DROP TABLE tbl_varchar; +# +# Double column, singleton histogram +# +CREATE TABLE tbl_double (col1 DOUBLE); +INSERT INTO tbl_double VALUES (-1.1), (0.0), (1.1), (2.2), (3.3), (4.4), (5.5), (6.6), (NULL), (NULL); +ANALYZE TABLE tbl_double UPDATE HISTOGRAM ON col1 WITH 10 BUCKETS; +Table Op Msg_type Msg_text +test.tbl_double histogram status Histogram statistics created for column 'col1'. +ANALYZE TABLE tbl_double; +Table Op Msg_type Msg_text +test.tbl_double analyze status OK +# Expect "60.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_double WHERE col1 > 0.0e0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 60.00 Parallel execute (1 workers) +2 SIMPLE tbl_double NULL ALL NULL NULL NULL NULL 10 60.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_double`.`col1` AS `col1` from `test`.`tbl_double` where (`test`.`tbl_double`.`col1` > 0.0e0) +EXPLAIN SELECT * FROM tbl_double WHERE 0.0e0 < col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 60.00 Parallel execute (1 workers) +2 SIMPLE tbl_double NULL ALL NULL NULL NULL NULL 10 60.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_double`.`col1` AS `col1` from `test`.`tbl_double` where (0.0e0 < `test`.`tbl_double`.`col1`) +# Expect "10.0" in column "filtered" (we never estimate 0%) +EXPLAIN SELECT * FROM tbl_double WHERE col1 > 6.6e0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_double NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_double`.`col1` AS `col1` from `test`.`tbl_double` where (`test`.`tbl_double`.`col1` > 6.6e0) +EXPLAIN SELECT * FROM tbl_double WHERE 6.6e0 < col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_double NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_double`.`col1` AS `col1` from `test`.`tbl_double` where (6.6e0 < `test`.`tbl_double`.`col1`) +# Expect "10.0" in column "filtered" (we never estimate 0%) +EXPLAIN SELECT * FROM tbl_double WHERE col1 < -2.2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_double NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_double`.`col1` AS `col1` from `test`.`tbl_double` where (`test`.`tbl_double`.`col1` < -2.2) +EXPLAIN SELECT * FROM tbl_double WHERE -2.2 > col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_double NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_double`.`col1` AS `col1` from `test`.`tbl_double` where (-2.2 > `test`.`tbl_double`.`col1`) +# Expect "80.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_double WHERE col1 < 10.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_double NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_double`.`col1` AS `col1` from `test`.`tbl_double` where (`test`.`tbl_double`.`col1` < 10) +EXPLAIN SELECT * FROM tbl_double WHERE 10.0 > col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_double NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_double`.`col1` AS `col1` from `test`.`tbl_double` where (10 > `test`.`tbl_double`.`col1`) +# Expect "40.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_double WHERE col1 >= 3.3e0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 40.00 Parallel execute (1 workers) +2 SIMPLE tbl_double NULL ALL NULL NULL NULL NULL 10 40.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_double`.`col1` AS `col1` from `test`.`tbl_double` where (`test`.`tbl_double`.`col1` >= 3.3e0) +EXPLAIN SELECT * FROM tbl_double WHERE 3.3e0 <= col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 40.00 Parallel execute (1 workers) +2 SIMPLE tbl_double NULL ALL NULL NULL NULL NULL 10 40.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_double`.`col1` AS `col1` from `test`.`tbl_double` where (3.3e0 <= `test`.`tbl_double`.`col1`) +# Expect "80.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_double WHERE col1 >= -2.0e0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_double NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_double`.`col1` AS `col1` from `test`.`tbl_double` where (`test`.`tbl_double`.`col1` >= -2) +EXPLAIN SELECT * FROM tbl_double WHERE -2.0e0 <= col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_double NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_double`.`col1` AS `col1` from `test`.`tbl_double` where (-2 <= `test`.`tbl_double`.`col1`) +# Expect "70.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_double WHERE col1 != 0.0e0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 70.00 Parallel execute (1 workers) +2 SIMPLE tbl_double NULL ALL NULL NULL NULL NULL 10 70.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_double`.`col1` AS `col1` from `test`.`tbl_double` where (`test`.`tbl_double`.`col1` <> 0.0e0) +EXPLAIN SELECT * FROM tbl_double WHERE 0.0e0 != col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 70.00 Parallel execute (1 workers) +2 SIMPLE tbl_double NULL ALL NULL NULL NULL NULL 10 70.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_double`.`col1` AS `col1` from `test`.`tbl_double` where (0.0e0 <> `test`.`tbl_double`.`col1`) +EXPLAIN SELECT * FROM tbl_double WHERE col1 <> 0.0e0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 70.00 Parallel execute (1 workers) +2 SIMPLE tbl_double NULL ALL NULL NULL NULL NULL 10 70.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_double`.`col1` AS `col1` from `test`.`tbl_double` where (`test`.`tbl_double`.`col1` <> 0.0e0) +EXPLAIN SELECT * FROM tbl_double WHERE 0.0e0 <> col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 70.00 Parallel execute (1 workers) +2 SIMPLE tbl_double NULL ALL NULL NULL NULL NULL 10 70.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_double`.`col1` AS `col1` from `test`.`tbl_double` where (0.0e0 <> `test`.`tbl_double`.`col1`) +# Expect "10.0" in column "filtered", due to the fact that the optimizer +# always assumes that at least one row will match. +EXPLAIN SELECT * FROM tbl_double WHERE col1 = 100.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_double NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_double`.`col1` AS `col1` from `test`.`tbl_double` where (`test`.`tbl_double`.`col1` = 100) +EXPLAIN SELECT * FROM tbl_double WHERE 100.0 = col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_double NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_double`.`col1` AS `col1` from `test`.`tbl_double` where (100 = `test`.`tbl_double`.`col1`) +# Expect "20.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_double WHERE col1 IS NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 20.00 Parallel execute (1 workers) +2 SIMPLE tbl_double NULL ALL NULL NULL NULL NULL 10 20.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_double`.`col1` AS `col1` from `test`.`tbl_double` where (`test`.`tbl_double`.`col1` is null) +# Expect "80.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_double WHERE col1 IS NOT NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_double NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_double`.`col1` AS `col1` from `test`.`tbl_double` where (`test`.`tbl_double`.`col1` is not null) +# Expect "30.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_double WHERE col1 BETWEEN 1.1e0 AND 3.3e0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 30.00 Parallel execute (1 workers) +2 SIMPLE tbl_double NULL ALL NULL NULL NULL NULL 10 30.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_double`.`col1` AS `col1` from `test`.`tbl_double` where (`test`.`tbl_double`.`col1` between 1.1e0 and 3.3e0) +# Expect "50.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_double WHERE col1 NOT BETWEEN 1.1e0 AND 3.3e0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 50.00 Parallel execute (1 workers) +2 SIMPLE tbl_double NULL ALL NULL NULL NULL NULL 10 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_double`.`col1` AS `col1` from `test`.`tbl_double` where (`test`.`tbl_double`.`col1` not between 1.1e0 and 3.3e0) +# Expect "40.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_double WHERE col1 IN (-1.1e0, 0.0e0, 1.1e0, 2.2e0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 40.00 Parallel execute (1 workers) +2 SIMPLE tbl_double NULL ALL NULL NULL NULL NULL 10 40.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_double`.`col1` AS `col1` from `test`.`tbl_double` where (`test`.`tbl_double`.`col1` in ((-(1.1e0)),0.0e0,1.1e0,2.2e0)) +# Expect "40.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_double WHERE col1 NOT IN (-1.1e0, 0.0e0, 1.1e0, 2.2e0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 40.00 Parallel execute (1 workers) +2 SIMPLE tbl_double NULL ALL NULL NULL NULL NULL 10 40.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_double`.`col1` AS `col1` from `test`.`tbl_double` where (`test`.`tbl_double`.`col1` not in ((-(1.1e0)),0.0e0,1.1e0,2.2e0)) +DROP TABLE tbl_double; +# +# Time column, singleton histogram +# +CREATE TABLE tbl_time (col1 TIME); +INSERT INTO tbl_time VALUES +("-01:00:00"), ("00:00:00"), ("00:00:01"), ("00:01:00"), ("01:00:00"), +("01:01:00"), ("02:00:00"), ("03:00:00"), (NULL), (NULL); +ANALYZE TABLE tbl_time UPDATE HISTOGRAM ON col1 WITH 10 BUCKETS; +Table Op Msg_type Msg_text +test.tbl_time histogram status Histogram statistics created for column 'col1'. +ANALYZE TABLE tbl_time; +Table Op Msg_type Msg_text +test.tbl_time analyze status OK +# Expect "60.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_time WHERE col1 > "00:00:00"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 60.00 Parallel execute (1 workers) +2 SIMPLE tbl_time NULL ALL NULL NULL NULL NULL 10 60.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_time`.`col1` AS `col1` from `test`.`tbl_time` where (`test`.`tbl_time`.`col1` > TIME'00:00:00') +EXPLAIN SELECT * FROM tbl_time WHERE "00:00:00" < col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 60.00 Parallel execute (1 workers) +2 SIMPLE tbl_time NULL ALL NULL NULL NULL NULL 10 60.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_time`.`col1` AS `col1` from `test`.`tbl_time` where (TIME'00:00:00' < `test`.`tbl_time`.`col1`) +# Expect "10.0" in column "filtered" (we never estimate 0%) +EXPLAIN SELECT * FROM tbl_time WHERE col1 > "03:00:00"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_time NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_time`.`col1` AS `col1` from `test`.`tbl_time` where (`test`.`tbl_time`.`col1` > TIME'03:00:00') +EXPLAIN SELECT * FROM tbl_time WHERE "03:00:00" < col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_time NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_time`.`col1` AS `col1` from `test`.`tbl_time` where (TIME'03:00:00' < `test`.`tbl_time`.`col1`) +# Expect "10.0" in column "filtered" (we never estimate 0%) +EXPLAIN SELECT * FROM tbl_time WHERE col1 < "-02:00:00"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_time NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_time`.`col1` AS `col1` from `test`.`tbl_time` where (`test`.`tbl_time`.`col1` < TIME'-02:00:00') +EXPLAIN SELECT * FROM tbl_time WHERE "-02:00:00" > col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_time NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_time`.`col1` AS `col1` from `test`.`tbl_time` where (TIME'-02:00:00' > `test`.`tbl_time`.`col1`) +# Expect "80.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_time WHERE col1 < "10:00:00"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_time NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_time`.`col1` AS `col1` from `test`.`tbl_time` where (`test`.`tbl_time`.`col1` < TIME'10:00:00') +EXPLAIN SELECT * FROM tbl_time WHERE "10:00:00" > col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_time NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_time`.`col1` AS `col1` from `test`.`tbl_time` where (TIME'10:00:00' > `test`.`tbl_time`.`col1`) +# Expect "60.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_time WHERE col1 >= "00:00:01"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 60.00 Parallel execute (1 workers) +2 SIMPLE tbl_time NULL ALL NULL NULL NULL NULL 10 60.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_time`.`col1` AS `col1` from `test`.`tbl_time` where (`test`.`tbl_time`.`col1` >= TIME'00:00:01') +EXPLAIN SELECT * FROM tbl_time WHERE "00:00:01" <= col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 60.00 Parallel execute (1 workers) +2 SIMPLE tbl_time NULL ALL NULL NULL NULL NULL 10 60.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_time`.`col1` AS `col1` from `test`.`tbl_time` where (TIME'00:00:01' <= `test`.`tbl_time`.`col1`) +# Expect "80.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_time WHERE col1 >= "-01:00:00"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_time NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_time`.`col1` AS `col1` from `test`.`tbl_time` where (`test`.`tbl_time`.`col1` >= TIME'-01:00:00') +EXPLAIN SELECT * FROM tbl_time WHERE "-01:00:00" <= col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_time NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_time`.`col1` AS `col1` from `test`.`tbl_time` where (TIME'-01:00:00' <= `test`.`tbl_time`.`col1`) +# Expect "70.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_time WHERE col1 != "01:01:00"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 70.00 Parallel execute (1 workers) +2 SIMPLE tbl_time NULL ALL NULL NULL NULL NULL 10 70.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_time`.`col1` AS `col1` from `test`.`tbl_time` where (`test`.`tbl_time`.`col1` <> TIME'01:01:00') +EXPLAIN SELECT * FROM tbl_time WHERE "01:01:00" != col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 70.00 Parallel execute (1 workers) +2 SIMPLE tbl_time NULL ALL NULL NULL NULL NULL 10 70.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_time`.`col1` AS `col1` from `test`.`tbl_time` where (TIME'01:01:00' <> `test`.`tbl_time`.`col1`) +EXPLAIN SELECT * FROM tbl_time WHERE col1 <> "01:01:00"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 70.00 Parallel execute (1 workers) +2 SIMPLE tbl_time NULL ALL NULL NULL NULL NULL 10 70.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_time`.`col1` AS `col1` from `test`.`tbl_time` where (`test`.`tbl_time`.`col1` <> TIME'01:01:00') +EXPLAIN SELECT * FROM tbl_time WHERE "01:01:00" <> col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 70.00 Parallel execute (1 workers) +2 SIMPLE tbl_time NULL ALL NULL NULL NULL NULL 10 70.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_time`.`col1` AS `col1` from `test`.`tbl_time` where (TIME'01:01:00' <> `test`.`tbl_time`.`col1`) +# Expect "10.0" in column "filtered", due to the fact that the optimizer +# always assumes that at least one row will match. +EXPLAIN SELECT * FROM tbl_time WHERE col1 = "10:00:00"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_time NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_time`.`col1` AS `col1` from `test`.`tbl_time` where (`test`.`tbl_time`.`col1` = TIME'10:00:00') +EXPLAIN SELECT * FROM tbl_time WHERE "10:00:00" = col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_time NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_time`.`col1` AS `col1` from `test`.`tbl_time` where (TIME'10:00:00' = `test`.`tbl_time`.`col1`) +# Expect "20.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_time WHERE col1 IS NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 20.00 Parallel execute (1 workers) +2 SIMPLE tbl_time NULL ALL NULL NULL NULL NULL 10 20.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_time`.`col1` AS `col1` from `test`.`tbl_time` where (`test`.`tbl_time`.`col1` is null) +# Expect "80.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_time WHERE col1 IS NOT NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_time NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_time`.`col1` AS `col1` from `test`.`tbl_time` where (`test`.`tbl_time`.`col1` is not null) +# Expect "50.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_time WHERE col1 BETWEEN "00:00:01" AND "02:00:00"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 50.00 Parallel execute (1 workers) +2 SIMPLE tbl_time NULL ALL NULL NULL NULL NULL 10 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_time`.`col1` AS `col1` from `test`.`tbl_time` where (`test`.`tbl_time`.`col1` between '00:00:01' and '02:00:00') +# Expect "30.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_time WHERE col1 NOT BETWEEN "00:00:01" AND "02:00:00"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 30.00 Parallel execute (1 workers) +2 SIMPLE tbl_time NULL ALL NULL NULL NULL NULL 10 30.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_time`.`col1` AS `col1` from `test`.`tbl_time` where (`test`.`tbl_time`.`col1` not between '00:00:01' and '02:00:00') +# Expect "30.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_time WHERE col1 IN ("-01:00:00", "00:00:00", "03:00:00"); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 30.00 Parallel execute (1 workers) +2 SIMPLE tbl_time NULL ALL NULL NULL NULL NULL 10 30.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_time`.`col1` AS `col1` from `test`.`tbl_time` where (`test`.`tbl_time`.`col1` in ('-01:00:00','00:00:00','03:00:00')) +# Expect "50.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_time WHERE col1 NOT IN ("-01:00:00", "00:00:00", "03:00:00"); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 50.00 Parallel execute (1 workers) +2 SIMPLE tbl_time NULL ALL NULL NULL NULL NULL 10 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_time`.`col1` AS `col1` from `test`.`tbl_time` where (`test`.`tbl_time`.`col1` not in ('-01:00:00','00:00:00','03:00:00')) +DROP TABLE tbl_time; +# +# Date column, singleton histogram +# +CREATE TABLE tbl_date (col1 DATE); +INSERT INTO tbl_date VALUES +("1000-01-02"), ("9999-12-30"), ("2017-01-01"), ("2017-01-02"), ("2017-02-01"), +("2018-01-01"), ("2019-01-01"), ("3019-01-01"), (NULL), (NULL); +ANALYZE TABLE tbl_date UPDATE HISTOGRAM ON col1 WITH 10 BUCKETS; +Table Op Msg_type Msg_text +test.tbl_date histogram status Histogram statistics created for column 'col1'. +ANALYZE TABLE tbl_date; +Table Op Msg_type Msg_text +test.tbl_date analyze status OK +# Expect "50.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_date WHERE col1 > "2017-01-02"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 50.00 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 10 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`col1` AS `col1` from `test`.`tbl_date` where (`test`.`tbl_date`.`col1` > DATE'2017-01-02') +EXPLAIN SELECT * FROM tbl_date WHERE "2017-01-02" < col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 50.00 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 10 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`col1` AS `col1` from `test`.`tbl_date` where (DATE'2017-01-02' < `test`.`tbl_date`.`col1`) +# Expect "10.0" in column "filtered" (we never estimate 0%) +EXPLAIN SELECT * FROM tbl_date WHERE col1 > "9999-12-31"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`col1` AS `col1` from `test`.`tbl_date` where (`test`.`tbl_date`.`col1` > DATE'9999-12-31') +EXPLAIN SELECT * FROM tbl_date WHERE "9999-12-31" < col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`col1` AS `col1` from `test`.`tbl_date` where (DATE'9999-12-31' < `test`.`tbl_date`.`col1`) +# Expect "10.0" in column "filtered" (we never estimate 0%) +EXPLAIN SELECT * FROM tbl_date WHERE col1 < "1000-01-01"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`col1` AS `col1` from `test`.`tbl_date` where (`test`.`tbl_date`.`col1` < DATE'1000-01-01') +EXPLAIN SELECT * FROM tbl_date WHERE "1000-01-01" > col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`col1` AS `col1` from `test`.`tbl_date` where (DATE'1000-01-01' > `test`.`tbl_date`.`col1`) +# Expect "80.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_date WHERE col1 < "9999-12-31"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`col1` AS `col1` from `test`.`tbl_date` where (`test`.`tbl_date`.`col1` < DATE'9999-12-31') +EXPLAIN SELECT * FROM tbl_date WHERE "9999-12-31" > col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`col1` AS `col1` from `test`.`tbl_date` where (DATE'9999-12-31' > `test`.`tbl_date`.`col1`) +# Expect "40.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_date WHERE col1 >= "2018-01-01"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 40.00 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 10 40.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`col1` AS `col1` from `test`.`tbl_date` where (`test`.`tbl_date`.`col1` >= DATE'2018-01-01') +EXPLAIN SELECT * FROM tbl_date WHERE "2018-01-01" <= col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 40.00 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 10 40.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`col1` AS `col1` from `test`.`tbl_date` where (DATE'2018-01-01' <= `test`.`tbl_date`.`col1`) +# Expect "80.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_date WHERE col1 >= "1000-01-02"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`col1` AS `col1` from `test`.`tbl_date` where (`test`.`tbl_date`.`col1` >= DATE'1000-01-02') +EXPLAIN SELECT * FROM tbl_date WHERE "1000-01-02" <= col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`col1` AS `col1` from `test`.`tbl_date` where (DATE'1000-01-02' <= `test`.`tbl_date`.`col1`) +# Expect "70.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_date WHERE col1 != "2017-01-02"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 70.00 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 10 70.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`col1` AS `col1` from `test`.`tbl_date` where (`test`.`tbl_date`.`col1` <> DATE'2017-01-02') +EXPLAIN SELECT * FROM tbl_date WHERE "2017-01-02" != col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 70.00 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 10 70.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`col1` AS `col1` from `test`.`tbl_date` where (DATE'2017-01-02' <> `test`.`tbl_date`.`col1`) +EXPLAIN SELECT * FROM tbl_date WHERE col1 <> "2017-01-02"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 70.00 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 10 70.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`col1` AS `col1` from `test`.`tbl_date` where (`test`.`tbl_date`.`col1` <> DATE'2017-01-02') +EXPLAIN SELECT * FROM tbl_date WHERE "2017-01-02" <> col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 70.00 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 10 70.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`col1` AS `col1` from `test`.`tbl_date` where (DATE'2017-01-02' <> `test`.`tbl_date`.`col1`) +# Expect "10.0" in column "filtered", due to the fact that the optimizer +# always assumes that at least one row will match. +EXPLAIN SELECT * FROM tbl_date WHERE col1 = "9999-12-31"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`col1` AS `col1` from `test`.`tbl_date` where (`test`.`tbl_date`.`col1` = DATE'9999-12-31') +EXPLAIN SELECT * FROM tbl_date WHERE "9999-12-31" = col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`col1` AS `col1` from `test`.`tbl_date` where (`test`.`tbl_date`.`col1` = DATE'9999-12-31') +# Expect "20.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_date WHERE col1 IS NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 20.00 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 10 20.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`col1` AS `col1` from `test`.`tbl_date` where (`test`.`tbl_date`.`col1` is null) +# Expect "80.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_date WHERE col1 IS NOT NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`col1` AS `col1` from `test`.`tbl_date` where (`test`.`tbl_date`.`col1` is not null) +# Expect "60.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_date WHERE col1 BETWEEN "2017-01-01" AND "3019-01-01"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 60.00 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 10 60.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`col1` AS `col1` from `test`.`tbl_date` where (`test`.`tbl_date`.`col1` between '2017-01-01' and '3019-01-01') +# Expect "20.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_date WHERE col1 NOT BETWEEN "2017-01-01" AND "3019-01-01"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 20.00 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 10 20.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`col1` AS `col1` from `test`.`tbl_date` where (`test`.`tbl_date`.`col1` not between '2017-01-01' and '3019-01-01') +# Expect "30.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_date WHERE col1 IN ("1000-01-02", "2017-01-02", "2018-01-01"); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 30.00 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 10 30.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`col1` AS `col1` from `test`.`tbl_date` where (`test`.`tbl_date`.`col1` in ('1000-01-02','2017-01-02','2018-01-01')) +# Expect "50.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_date WHERE col1 NOT IN ("1000-01-02", "2017-01-02", "2018-01-01"); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 50.00 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 10 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`col1` AS `col1` from `test`.`tbl_date` where (`test`.`tbl_date`.`col1` not in ('1000-01-02','2017-01-02','2018-01-01')) +DROP TABLE tbl_date; +# +# Datetime column, singleton histogram +# +CREATE TABLE tbl_datetime (col1 DATETIME(6)); +INSERT INTO tbl_datetime VALUES +("1000-01-01 00:00:01"), ("9999-12-31 23:59:59.999998"), +("2017-01-01 00:00:00"), ("2017-01-01 00:00:00.000001"), +("2017-02-01 00:00:00"), ("2018-01-01 00:00:00.999999"), +("2018-01-01 00:00:01"), ("3019-01-01 10:10:10.101010"), (NULL), (NULL); +ANALYZE TABLE tbl_datetime UPDATE HISTOGRAM ON col1 WITH 10 BUCKETS; +Table Op Msg_type Msg_text +test.tbl_datetime histogram status Histogram statistics created for column 'col1'. +ANALYZE TABLE tbl_datetime; +Table Op Msg_type Msg_text +test.tbl_datetime analyze status OK +# Expect "40.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_datetime WHERE col1 > "2018-01-01 00:00:00"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 40.00 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 10 40.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`col1` AS `col1` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`col1` > TIMESTAMP'2018-01-01 00:00:00') +EXPLAIN SELECT * FROM tbl_datetime WHERE "2018-01-01 00:00:00" < col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 40.00 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 10 40.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`col1` AS `col1` from `test`.`tbl_datetime` where (TIMESTAMP'2018-01-01 00:00:00' < `test`.`tbl_datetime`.`col1`) +# Expect "10.0" in column "filtered" (we never estimate 0%) +EXPLAIN SELECT * FROM tbl_datetime WHERE col1 > "9999-12-31 23:59:59.999998"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`col1` AS `col1` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`col1` > TIMESTAMP'9999-12-31 23:59:59.999998') +EXPLAIN SELECT * FROM tbl_datetime WHERE "9999-12-31 23:59:59.999998" < col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`col1` AS `col1` from `test`.`tbl_datetime` where (TIMESTAMP'9999-12-31 23:59:59.999998' < `test`.`tbl_datetime`.`col1`) +# Expect "10.0" in column "filtered" (we never estimate 0%) +EXPLAIN SELECT * FROM tbl_datetime WHERE col1 < "1000-01-01 00:00:00"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`col1` AS `col1` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`col1` < TIMESTAMP'1000-01-01 00:00:00') +EXPLAIN SELECT * FROM tbl_datetime WHERE "1000-01-01 00:00:00" > col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`col1` AS `col1` from `test`.`tbl_datetime` where (TIMESTAMP'1000-01-01 00:00:00' > `test`.`tbl_datetime`.`col1`) +# Expect "80.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_datetime WHERE col1 < "9999-12-31 23:59:59.999999"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`col1` AS `col1` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`col1` < TIMESTAMP'9999-12-31 23:59:59.999999') +EXPLAIN SELECT * FROM tbl_datetime WHERE "9999-12-31 23:59:59.999999" > col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`col1` AS `col1` from `test`.`tbl_datetime` where (TIMESTAMP'9999-12-31 23:59:59.999999' > `test`.`tbl_datetime`.`col1`) +# Expect "40.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_datetime WHERE col1 >= "2018-01-01 00:00:00.999999"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 40.00 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 10 40.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`col1` AS `col1` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`col1` >= TIMESTAMP'2018-01-01 00:00:00.999999') +EXPLAIN SELECT * FROM tbl_datetime WHERE "2018-01-01 00:00:00.999999" <= col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 40.00 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 10 40.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`col1` AS `col1` from `test`.`tbl_datetime` where (TIMESTAMP'2018-01-01 00:00:00.999999' <= `test`.`tbl_datetime`.`col1`) +# Expect "80.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_datetime WHERE col1 >= "1000-01-01 00:00:01.000000"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`col1` AS `col1` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`col1` >= TIMESTAMP'1000-01-01 00:00:01') +EXPLAIN SELECT * FROM tbl_datetime WHERE "1000-01-01 00:00:01.000000" <= col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`col1` AS `col1` from `test`.`tbl_datetime` where (TIMESTAMP'1000-01-01 00:00:01' <= `test`.`tbl_datetime`.`col1`) +# Expect "70.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_datetime WHERE col1 != "3019-01-01 10:10:10.101010"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 70.00 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 10 70.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`col1` AS `col1` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`col1` <> TIMESTAMP'3019-01-01 10:10:10.10101') +EXPLAIN SELECT * FROM tbl_datetime WHERE "3019-01-01 10:10:10.101010" != col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 70.00 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 10 70.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`col1` AS `col1` from `test`.`tbl_datetime` where (TIMESTAMP'3019-01-01 10:10:10.10101' <> `test`.`tbl_datetime`.`col1`) +EXPLAIN SELECT * FROM tbl_datetime WHERE col1 <> "3019-01-01 10:10:10.101010"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 70.00 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 10 70.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`col1` AS `col1` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`col1` <> TIMESTAMP'3019-01-01 10:10:10.10101') +EXPLAIN SELECT * FROM tbl_datetime WHERE "3019-01-01 10:10:10.101010" <> col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 70.00 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 10 70.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`col1` AS `col1` from `test`.`tbl_datetime` where (TIMESTAMP'3019-01-01 10:10:10.10101' <> `test`.`tbl_datetime`.`col1`) +# Expect "10.0" in column "filtered", due to the fact that the optimizer +# always assumes that at least one row will match. +EXPLAIN SELECT * FROM tbl_datetime WHERE col1 = "9999-12-31 23:59:59.999999"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`col1` AS `col1` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`col1` = TIMESTAMP'9999-12-31 23:59:59.999999') +EXPLAIN SELECT * FROM tbl_datetime WHERE "9999-12-31 23:59:59.999999" = col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`col1` AS `col1` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`col1` = TIMESTAMP'9999-12-31 23:59:59.999999') +# Expect "20.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_datetime WHERE col1 IS NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 20.00 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 10 20.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`col1` AS `col1` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`col1` is null) +# Expect "80.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_datetime WHERE col1 IS NOT NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`col1` AS `col1` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`col1` is not null) +# Expect "50.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_datetime WHERE col1 BETWEEN "2017-01-01 00:00:00.000001" AND "3019-01-01 10:10:10.101010"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 50.00 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 10 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`col1` AS `col1` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`col1` between '2017-01-01 00:00:00.000001' and '3019-01-01 10:10:10.101010') +# Expect "30.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_datetime WHERE col1 NOT BETWEEN "2017-01-01 00:00:00.000001" AND "3019-01-01 10:10:10.101010"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 30.00 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 10 30.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`col1` AS `col1` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`col1` not between '2017-01-01 00:00:00.000001' and '3019-01-01 10:10:10.101010') +# Expect "30.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_datetime WHERE col1 IN ("1000-01-01 00:00:01.000000", "2018-01-01 00:00:00.999999", "9999-12-31 23:59:59.999998"); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 30.00 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 10 30.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`col1` AS `col1` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`col1` in ('1000-01-01 00:00:01.000000','2018-01-01 00:00:00.999999','9999-12-31 23:59:59.999998')) +# Expect "50.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_datetime WHERE col1 NOT IN ("1000-01-01 00:00:01.000000", "2018-01-01 00:00:00.999999", "9999-12-31 23:59:59.999998"); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 50.00 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 10 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`col1` AS `col1` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`col1` not in ('1000-01-01 00:00:01.000000','2018-01-01 00:00:00.999999','9999-12-31 23:59:59.999998')) +DROP TABLE tbl_datetime; +# +# Decimal column, singleton histogram +# +CREATE TABLE tbl_decimal (col1 DECIMAL(65, 30)); +INSERT INTO tbl_decimal VALUES +(00000000000000000000000000000000000.000000000000000000000000000000), +(99999999999999999999999999999999999.999999999999999999999999999998), +(-99999999999999999999999999999999999.999999999999999999999999999998), +(1), (2), (3), (4), (-1), (NULL), (NULL); +ANALYZE TABLE tbl_decimal UPDATE HISTOGRAM ON col1 WITH 10 BUCKETS; +Table Op Msg_type Msg_text +test.tbl_decimal histogram status Histogram statistics created for column 'col1'. +ANALYZE TABLE tbl_decimal; +Table Op Msg_type Msg_text +test.tbl_decimal analyze status OK +# Expect "40.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_decimal WHERE col1 > 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 40.00 Parallel execute (1 workers) +2 SIMPLE tbl_decimal NULL ALL NULL NULL NULL NULL 10 40.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_decimal`.`col1` AS `col1` from `test`.`tbl_decimal` where (`test`.`tbl_decimal`.`col1` > 1.000000000000000000000000000000) +EXPLAIN SELECT * FROM tbl_decimal WHERE 1 < col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 40.00 Parallel execute (1 workers) +2 SIMPLE tbl_decimal NULL ALL NULL NULL NULL NULL 10 40.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_decimal`.`col1` AS `col1` from `test`.`tbl_decimal` where (1.000000000000000000000000000000 < `test`.`tbl_decimal`.`col1`) +# Expect "10.0" in column "filtered" (we never estimate 0%) +EXPLAIN SELECT * FROM tbl_decimal WHERE col1 > 100000000000000000000000000000000000; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_decimal`.`col1` AS `col1` from `test`.`tbl_decimal` where false +EXPLAIN SELECT * FROM tbl_decimal WHERE 100000000000000000000000000000000000 < col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_decimal`.`col1` AS `col1` from `test`.`tbl_decimal` where false +# Expect "10.0" in column "filtered" (we never estimate 0%) +EXPLAIN SELECT * FROM tbl_decimal WHERE col1 < -99999999999999999999999999999999999.999999999999999999999999999999; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_decimal NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_decimal`.`col1` AS `col1` from `test`.`tbl_decimal` where (`test`.`tbl_decimal`.`col1` < (-(99999999999999999999999999999999999.999999999999999999999999999999))) +EXPLAIN SELECT * FROM tbl_decimal WHERE -99999999999999999999999999999999999.999999999999999999999999999999 > col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_decimal NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_decimal`.`col1` AS `col1` from `test`.`tbl_decimal` where ((-(99999999999999999999999999999999999.999999999999999999999999999999)) > `test`.`tbl_decimal`.`col1`) +# Expect "80.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_decimal WHERE col1 < 99999999999999999999999999999999999.999999999999999999999999999999; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_decimal NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_decimal`.`col1` AS `col1` from `test`.`tbl_decimal` where (`test`.`tbl_decimal`.`col1` < 99999999999999999999999999999999999.999999999999999999999999999999) +EXPLAIN SELECT * FROM tbl_decimal WHERE 99999999999999999999999999999999999.999999999999999999999999999999 > col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_decimal NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_decimal`.`col1` AS `col1` from `test`.`tbl_decimal` where (99999999999999999999999999999999999.999999999999999999999999999999 > `test`.`tbl_decimal`.`col1`) +# Expect "40.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_decimal WHERE col1 >= 4; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 20.00 Parallel execute (1 workers) +2 SIMPLE tbl_decimal NULL ALL NULL NULL NULL NULL 10 20.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_decimal`.`col1` AS `col1` from `test`.`tbl_decimal` where (`test`.`tbl_decimal`.`col1` >= 4.000000000000000000000000000000) +EXPLAIN SELECT * FROM tbl_decimal WHERE 4 <= col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 20.00 Parallel execute (1 workers) +2 SIMPLE tbl_decimal NULL ALL NULL NULL NULL NULL 10 20.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_decimal`.`col1` AS `col1` from `test`.`tbl_decimal` where (4.000000000000000000000000000000 <= `test`.`tbl_decimal`.`col1`) +# Expect "70.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_decimal WHERE col1 >= -1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 70.00 Parallel execute (1 workers) +2 SIMPLE tbl_decimal NULL ALL NULL NULL NULL NULL 10 70.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_decimal`.`col1` AS `col1` from `test`.`tbl_decimal` where (`test`.`tbl_decimal`.`col1` >= -1.000000000000000000000000000000) +EXPLAIN SELECT * FROM tbl_decimal WHERE -1 <= col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 70.00 Parallel execute (1 workers) +2 SIMPLE tbl_decimal NULL ALL NULL NULL NULL NULL 10 70.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_decimal`.`col1` AS `col1` from `test`.`tbl_decimal` where (-1.000000000000000000000000000000 <= `test`.`tbl_decimal`.`col1`) +# Expect "70.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_decimal WHERE col1 != 2.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 70.00 Parallel execute (1 workers) +2 SIMPLE tbl_decimal NULL ALL NULL NULL NULL NULL 10 70.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_decimal`.`col1` AS `col1` from `test`.`tbl_decimal` where (`test`.`tbl_decimal`.`col1` <> 2.000000000000000000000000000000) +EXPLAIN SELECT * FROM tbl_decimal WHERE 2.0 != col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 70.00 Parallel execute (1 workers) +2 SIMPLE tbl_decimal NULL ALL NULL NULL NULL NULL 10 70.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_decimal`.`col1` AS `col1` from `test`.`tbl_decimal` where (2.000000000000000000000000000000 <> `test`.`tbl_decimal`.`col1`) +EXPLAIN SELECT * FROM tbl_decimal WHERE col1 <> 2.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 70.00 Parallel execute (1 workers) +2 SIMPLE tbl_decimal NULL ALL NULL NULL NULL NULL 10 70.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_decimal`.`col1` AS `col1` from `test`.`tbl_decimal` where (`test`.`tbl_decimal`.`col1` <> 2.000000000000000000000000000000) +EXPLAIN SELECT * FROM tbl_decimal WHERE 2.0 <> col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 70.00 Parallel execute (1 workers) +2 SIMPLE tbl_decimal NULL ALL NULL NULL NULL NULL 10 70.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_decimal`.`col1` AS `col1` from `test`.`tbl_decimal` where (2.000000000000000000000000000000 <> `test`.`tbl_decimal`.`col1`) +# Expect "10.0" in column "filtered", due to the fact that the optimizer +# always assumes that at least one row will match. +EXPLAIN SELECT * FROM tbl_decimal WHERE col1 = "99999999999999999999999999999999999.999999999999999999999999999999"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_decimal NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_decimal`.`col1` AS `col1` from `test`.`tbl_decimal` where (`test`.`tbl_decimal`.`col1` = 99999999999999999999999999999999999.999999999999999999999999999999) +EXPLAIN SELECT * FROM tbl_decimal WHERE "99999999999999999999999999999999999.999999999999999999999999999999" = col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_decimal NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_decimal`.`col1` AS `col1` from `test`.`tbl_decimal` where (99999999999999999999999999999999999.999999999999999999999999999999 = `test`.`tbl_decimal`.`col1`) +# Expect "20.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_decimal WHERE col1 IS NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 20.00 Parallel execute (1 workers) +2 SIMPLE tbl_decimal NULL ALL NULL NULL NULL NULL 10 20.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_decimal`.`col1` AS `col1` from `test`.`tbl_decimal` where (`test`.`tbl_decimal`.`col1` is null) +# Expect "80.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_decimal WHERE col1 IS NOT NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_decimal NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_decimal`.`col1` AS `col1` from `test`.`tbl_decimal` where (`test`.`tbl_decimal`.`col1` is not null) +# Expect "60.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_decimal WHERE col1 BETWEEN -1.0 AND 4.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 60.00 Parallel execute (1 workers) +2 SIMPLE tbl_decimal NULL ALL NULL NULL NULL NULL 10 60.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_decimal`.`col1` AS `col1` from `test`.`tbl_decimal` where (`test`.`tbl_decimal`.`col1` between (-(1.0)) and 4.0) +# Expect "20.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_decimal WHERE col1 NOT BETWEEN -1.0 AND 4.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 20.00 Parallel execute (1 workers) +2 SIMPLE tbl_decimal NULL ALL NULL NULL NULL NULL 10 20.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_decimal`.`col1` AS `col1` from `test`.`tbl_decimal` where (`test`.`tbl_decimal`.`col1` not between (-(1.0)) and 4.0) +# Expect "30.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_decimal WHERE col1 IN +(-99999999999999999999999999999999999.999999999999999999999999999998, 1.0, 2.0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 30.00 Parallel execute (1 workers) +2 SIMPLE tbl_decimal NULL ALL NULL NULL NULL NULL 10 30.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_decimal`.`col1` AS `col1` from `test`.`tbl_decimal` where (`test`.`tbl_decimal`.`col1` in ((-(99999999999999999999999999999999999.999999999999999999999999999998)),1.0,2.0)) +# Expect "50.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_decimal WHERE col1 NOT IN +(-99999999999999999999999999999999999.999999999999999999999999999998, 1.0, 2.0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 50.00 Parallel execute (1 workers) +2 SIMPLE tbl_decimal NULL ALL NULL NULL NULL NULL 10 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_decimal`.`col1` AS `col1` from `test`.`tbl_decimal` where (`test`.`tbl_decimal`.`col1` not in ((-(99999999999999999999999999999999999.999999999999999999999999999998)),1.0,2.0)) +DROP TABLE tbl_decimal; +# +# ENUM column, singleton histogram +# Note that we only support equality/inequality operators for ENUM +# columns. +# +CREATE TABLE tbl_enum (col1 ENUM('red', 'black', 'blue', 'green')); +INSERT INTO tbl_enum VALUES ('red'), ('red'), ('black'), ('blue'), ('green'), +('green'), (NULL), (NULL), (NULL); +ANALYZE TABLE tbl_enum UPDATE HISTOGRAM ON col1 WITH 10 BUCKETS; +Table Op Msg_type Msg_text +test.tbl_enum histogram status Histogram statistics created for column 'col1'. +ANALYZE TABLE tbl_enum; +Table Op Msg_type Msg_text +test.tbl_enum analyze status OK +# Expect "22.22" in column "filtered" +EXPLAIN SELECT * FROM tbl_enum WHERE col1 = 'red'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 9 22.22 Parallel execute (1 workers) +2 SIMPLE tbl_enum NULL ALL NULL NULL NULL NULL 9 22.22 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_enum`.`col1` AS `col1` from `test`.`tbl_enum` where (`test`.`tbl_enum`.`col1` = 'red') +EXPLAIN SELECT * FROM tbl_enum WHERE 'red' = col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 9 22.22 Parallel execute (1 workers) +2 SIMPLE tbl_enum NULL ALL NULL NULL NULL NULL 9 22.22 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_enum`.`col1` AS `col1` from `test`.`tbl_enum` where (`test`.`tbl_enum`.`col1` = 'red') +# Expect "55.56" in column "filtered" +EXPLAIN SELECT * FROM tbl_enum WHERE col1 != 'black'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 9 55.56 Parallel execute (1 workers) +2 SIMPLE tbl_enum NULL ALL NULL NULL NULL NULL 9 55.56 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_enum`.`col1` AS `col1` from `test`.`tbl_enum` where (`test`.`tbl_enum`.`col1` <> 'black') +EXPLAIN SELECT * FROM tbl_enum WHERE 'black' != col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 9 55.56 Parallel execute (1 workers) +2 SIMPLE tbl_enum NULL ALL NULL NULL NULL NULL 9 55.56 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_enum`.`col1` AS `col1` from `test`.`tbl_enum` where ('black' <> `test`.`tbl_enum`.`col1`) +EXPLAIN SELECT * FROM tbl_enum WHERE col1 <> 'black'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 9 55.56 Parallel execute (1 workers) +2 SIMPLE tbl_enum NULL ALL NULL NULL NULL NULL 9 55.56 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_enum`.`col1` AS `col1` from `test`.`tbl_enum` where (`test`.`tbl_enum`.`col1` <> 'black') +EXPLAIN SELECT * FROM tbl_enum WHERE 'black' <> col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 9 55.56 Parallel execute (1 workers) +2 SIMPLE tbl_enum NULL ALL NULL NULL NULL NULL 9 55.56 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_enum`.`col1` AS `col1` from `test`.`tbl_enum` where ('black' <> `test`.`tbl_enum`.`col1`) +# Expect "66.67" in column "filtered" +EXPLAIN SELECT * FROM tbl_enum WHERE col1 != ''; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 9 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_enum NULL ALL NULL NULL NULL NULL 9 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_enum`.`col1` AS `col1` from `test`.`tbl_enum` where (`test`.`tbl_enum`.`col1` <> '') +EXPLAIN SELECT * FROM tbl_enum WHERE col1 != 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 9 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_enum NULL ALL NULL NULL NULL NULL 9 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_enum`.`col1` AS `col1` from `test`.`tbl_enum` where (`test`.`tbl_enum`.`col1` <> 0) +EXPLAIN SELECT * FROM tbl_enum WHERE col1 <> ''; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 9 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_enum NULL ALL NULL NULL NULL NULL 9 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_enum`.`col1` AS `col1` from `test`.`tbl_enum` where (`test`.`tbl_enum`.`col1` <> '') +EXPLAIN SELECT * FROM tbl_enum WHERE col1 <> 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 9 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_enum NULL ALL NULL NULL NULL NULL 9 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_enum`.`col1` AS `col1` from `test`.`tbl_enum` where (`test`.`tbl_enum`.`col1` <> 0) +# Expect "44.44" in column "filtered" +EXPLAIN SELECT * FROM tbl_enum WHERE col1 IN ('black', 'blue', 'green'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 9 44.44 Parallel execute (1 workers) +2 SIMPLE tbl_enum NULL ALL NULL NULL NULL NULL 9 44.44 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_enum`.`col1` AS `col1` from `test`.`tbl_enum` where (`test`.`tbl_enum`.`col1` in ('black','blue','green')) +# Expect "33.33" in column "filtered" +EXPLAIN SELECT * FROM tbl_enum WHERE col1 NOT IN ('green', 'blue'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 9 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_enum NULL ALL NULL NULL NULL NULL 9 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_enum`.`col1` AS `col1` from `test`.`tbl_enum` where (`test`.`tbl_enum`.`col1` not in ('green','blue')) +# Expect "33.33" in column "filtered" +EXPLAIN SELECT * FROM tbl_enum WHERE col1 IS NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 9 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_enum NULL ALL NULL NULL NULL NULL 9 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_enum`.`col1` AS `col1` from `test`.`tbl_enum` where (`test`.`tbl_enum`.`col1` is null) +# Expect "66.67" in column "filtered" +EXPLAIN SELECT * FROM tbl_enum WHERE col1 IS NOT NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 9 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_enum NULL ALL NULL NULL NULL NULL 9 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_enum`.`col1` AS `col1` from `test`.`tbl_enum` where (`test`.`tbl_enum`.`col1` is not null) +# Test that the numerical representation of enum values also gives the +# correct result. +# Expect "22.22" in column "filtered" +EXPLAIN SELECT * FROM tbl_enum WHERE col1 = 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 9 22.22 Parallel execute (1 workers) +2 SIMPLE tbl_enum NULL ALL NULL NULL NULL NULL 9 22.22 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_enum`.`col1` AS `col1` from `test`.`tbl_enum` where (`test`.`tbl_enum`.`col1` = 1) +EXPLAIN SELECT * FROM tbl_enum WHERE 1 = col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 9 22.22 Parallel execute (1 workers) +2 SIMPLE tbl_enum NULL ALL NULL NULL NULL NULL 9 22.22 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_enum`.`col1` AS `col1` from `test`.`tbl_enum` where (1 = `test`.`tbl_enum`.`col1`) +# Expect "55.56" in column "filtered" +EXPLAIN SELECT * FROM tbl_enum WHERE col1 != 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 9 55.56 Parallel execute (1 workers) +2 SIMPLE tbl_enum NULL ALL NULL NULL NULL NULL 9 55.56 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_enum`.`col1` AS `col1` from `test`.`tbl_enum` where (`test`.`tbl_enum`.`col1` <> 2) +EXPLAIN SELECT * FROM tbl_enum WHERE 2 != col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 9 55.56 Parallel execute (1 workers) +2 SIMPLE tbl_enum NULL ALL NULL NULL NULL NULL 9 55.56 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_enum`.`col1` AS `col1` from `test`.`tbl_enum` where (2 <> `test`.`tbl_enum`.`col1`) +EXPLAIN SELECT * FROM tbl_enum WHERE col1 <> 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 9 55.56 Parallel execute (1 workers) +2 SIMPLE tbl_enum NULL ALL NULL NULL NULL NULL 9 55.56 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_enum`.`col1` AS `col1` from `test`.`tbl_enum` where (`test`.`tbl_enum`.`col1` <> 2) +EXPLAIN SELECT * FROM tbl_enum WHERE 2 <> col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 9 55.56 Parallel execute (1 workers) +2 SIMPLE tbl_enum NULL ALL NULL NULL NULL NULL 9 55.56 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_enum`.`col1` AS `col1` from `test`.`tbl_enum` where (2 <> `test`.`tbl_enum`.`col1`) +# Expect "11.11" in column "filtered", due to the fact that the optimizer +# always assumes that at least one row will match. +EXPLAIN SELECT * FROM tbl_enum WHERE col1 = 100; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 9 11.11 Parallel execute (1 workers) +2 SIMPLE tbl_enum NULL ALL NULL NULL NULL NULL 9 11.11 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_enum`.`col1` AS `col1` from `test`.`tbl_enum` where (`test`.`tbl_enum`.`col1` = 100) +EXPLAIN SELECT * FROM tbl_enum WHERE 100 = col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 9 11.11 Parallel execute (1 workers) +2 SIMPLE tbl_enum NULL ALL NULL NULL NULL NULL 9 11.11 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_enum`.`col1` AS `col1` from `test`.`tbl_enum` where (100 = `test`.`tbl_enum`.`col1`) +# Expect "44.44" in column "filtered" +EXPLAIN SELECT * FROM tbl_enum WHERE col1 IN (2, 3, 4); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 9 44.44 Parallel execute (1 workers) +2 SIMPLE tbl_enum NULL ALL NULL NULL NULL NULL 9 44.44 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_enum`.`col1` AS `col1` from `test`.`tbl_enum` where (`test`.`tbl_enum`.`col1` in (2,3,4)) +# Expect "33.33" in column "filtered" +EXPLAIN SELECT * FROM tbl_enum WHERE col1 NOT IN (4, 3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 9 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_enum NULL ALL NULL NULL NULL NULL 9 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_enum`.`col1` AS `col1` from `test`.`tbl_enum` where (`test`.`tbl_enum`.`col1` not in (4,3)) +DROP TABLE tbl_enum; +# +# SET column, singleton histogram +# Note that we only support equality/inequality operators for SET +# columns. +# +CREATE TABLE tbl_set (col1 SET('red', 'black', 'blue', 'green')); +INSERT INTO tbl_set VALUES ('red'), ('red,black'), ('black,green,blue'), +('black,green,blue'), ('black,green,blue'), +('green'), ('green,red'), ('red,green'), (NULL), +(NULL), (NULL); +ANALYZE TABLE tbl_set UPDATE HISTOGRAM ON col1 WITH 10 BUCKETS; +Table Op Msg_type Msg_text +test.tbl_set histogram status Histogram statistics created for column 'col1'. +ANALYZE TABLE tbl_set; +Table Op Msg_type Msg_text +test.tbl_set analyze status OK +# Expect "18.18" in column "filtered" +EXPLAIN SELECT * FROM tbl_set WHERE col1 = 'red,green'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 18.18 Parallel execute (1 workers) +2 SIMPLE tbl_set NULL ALL NULL NULL NULL NULL 11 18.18 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_set`.`col1` AS `col1` from `test`.`tbl_set` where (`test`.`tbl_set`.`col1` = 'red,green') +EXPLAIN SELECT * FROM tbl_set WHERE 'red,green' = col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 18.18 Parallel execute (1 workers) +2 SIMPLE tbl_set NULL ALL NULL NULL NULL NULL 11 18.18 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_set`.`col1` AS `col1` from `test`.`tbl_set` where (`test`.`tbl_set`.`col1` = 'red,green') +# Expect "63.64" in column "filtered" +EXPLAIN SELECT * FROM tbl_set WHERE col1 != 'red'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 63.64 Parallel execute (1 workers) +2 SIMPLE tbl_set NULL ALL NULL NULL NULL NULL 11 63.64 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_set`.`col1` AS `col1` from `test`.`tbl_set` where (`test`.`tbl_set`.`col1` <> 'red') +EXPLAIN SELECT * FROM tbl_set WHERE 'red' != col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 63.64 Parallel execute (1 workers) +2 SIMPLE tbl_set NULL ALL NULL NULL NULL NULL 11 63.64 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_set`.`col1` AS `col1` from `test`.`tbl_set` where ('red' <> `test`.`tbl_set`.`col1`) +EXPLAIN SELECT * FROM tbl_set WHERE col1 <> 'red'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 63.64 Parallel execute (1 workers) +2 SIMPLE tbl_set NULL ALL NULL NULL NULL NULL 11 63.64 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_set`.`col1` AS `col1` from `test`.`tbl_set` where (`test`.`tbl_set`.`col1` <> 'red') +EXPLAIN SELECT * FROM tbl_set WHERE 'red' <> col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 63.64 Parallel execute (1 workers) +2 SIMPLE tbl_set NULL ALL NULL NULL NULL NULL 11 63.64 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_set`.`col1` AS `col1` from `test`.`tbl_set` where ('red' <> `test`.`tbl_set`.`col1`) +# Expect "72.73" in column "filtered" +EXPLAIN SELECT * FROM tbl_set WHERE col1 != ''; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 72.73 Parallel execute (1 workers) +2 SIMPLE tbl_set NULL ALL NULL NULL NULL NULL 11 72.73 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_set`.`col1` AS `col1` from `test`.`tbl_set` where (`test`.`tbl_set`.`col1` <> '') +EXPLAIN SELECT * FROM tbl_set WHERE col1 != 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 72.73 Parallel execute (1 workers) +2 SIMPLE tbl_set NULL ALL NULL NULL NULL NULL 11 72.73 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_set`.`col1` AS `col1` from `test`.`tbl_set` where (`test`.`tbl_set`.`col1` <> 0) +EXPLAIN SELECT * FROM tbl_set WHERE col1 <> ''; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 72.73 Parallel execute (1 workers) +2 SIMPLE tbl_set NULL ALL NULL NULL NULL NULL 11 72.73 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_set`.`col1` AS `col1` from `test`.`tbl_set` where (`test`.`tbl_set`.`col1` <> '') +EXPLAIN SELECT * FROM tbl_set WHERE col1 <> 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 72.73 Parallel execute (1 workers) +2 SIMPLE tbl_set NULL ALL NULL NULL NULL NULL 11 72.73 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_set`.`col1` AS `col1` from `test`.`tbl_set` where (`test`.`tbl_set`.`col1` <> 0) +# Expect "36.36" in column "filtered" +EXPLAIN SELECT * FROM tbl_set WHERE col1 IN ('green', 'black,blue,green'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 36.36 Parallel execute (1 workers) +2 SIMPLE tbl_set NULL ALL NULL NULL NULL NULL 11 36.36 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_set`.`col1` AS `col1` from `test`.`tbl_set` where (`test`.`tbl_set`.`col1` in ('green','black,blue,green')) +# Expect "36.36" in column "filtered" +EXPLAIN SELECT * FROM tbl_set WHERE col1 NOT IN ('green', 'black,blue,green'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 36.36 Parallel execute (1 workers) +2 SIMPLE tbl_set NULL ALL NULL NULL NULL NULL 11 36.36 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_set`.`col1` AS `col1` from `test`.`tbl_set` where (`test`.`tbl_set`.`col1` not in ('green','black,blue,green')) +# Expect "27.27" in column "filtered" +EXPLAIN SELECT * FROM tbl_set WHERE col1 IS NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 27.27 Parallel execute (1 workers) +2 SIMPLE tbl_set NULL ALL NULL NULL NULL NULL 11 27.27 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_set`.`col1` AS `col1` from `test`.`tbl_set` where (`test`.`tbl_set`.`col1` is null) +# Expect "72.73" in column "filtered" +EXPLAIN SELECT * FROM tbl_set WHERE col1 IS NOT NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 72.73 Parallel execute (1 workers) +2 SIMPLE tbl_set NULL ALL NULL NULL NULL NULL 11 72.73 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_set`.`col1` AS `col1` from `test`.`tbl_set` where (`test`.`tbl_set`.`col1` is not null) +# Test that the numerical representation of enum values also gives the +# correct result. +# Expect "18.18" in column "filtered" +EXPLAIN SELECT * FROM tbl_set WHERE col1 = 9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 18.18 Parallel execute (1 workers) +2 SIMPLE tbl_set NULL ALL NULL NULL NULL NULL 11 18.18 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_set`.`col1` AS `col1` from `test`.`tbl_set` where (`test`.`tbl_set`.`col1` = 9) +EXPLAIN SELECT * FROM tbl_set WHERE 9 = col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 18.18 Parallel execute (1 workers) +2 SIMPLE tbl_set NULL ALL NULL NULL NULL NULL 11 18.18 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_set`.`col1` AS `col1` from `test`.`tbl_set` where (9 = `test`.`tbl_set`.`col1`) +# Expect "63.64" in column "filtered" +EXPLAIN SELECT * FROM tbl_set WHERE col1 != 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 63.64 Parallel execute (1 workers) +2 SIMPLE tbl_set NULL ALL NULL NULL NULL NULL 11 63.64 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_set`.`col1` AS `col1` from `test`.`tbl_set` where (`test`.`tbl_set`.`col1` <> 1) +EXPLAIN SELECT * FROM tbl_set WHERE 1 != col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 63.64 Parallel execute (1 workers) +2 SIMPLE tbl_set NULL ALL NULL NULL NULL NULL 11 63.64 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_set`.`col1` AS `col1` from `test`.`tbl_set` where (1 <> `test`.`tbl_set`.`col1`) +EXPLAIN SELECT * FROM tbl_set WHERE col1 <> 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 63.64 Parallel execute (1 workers) +2 SIMPLE tbl_set NULL ALL NULL NULL NULL NULL 11 63.64 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_set`.`col1` AS `col1` from `test`.`tbl_set` where (`test`.`tbl_set`.`col1` <> 1) +EXPLAIN SELECT * FROM tbl_set WHERE 1 <> col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 63.64 Parallel execute (1 workers) +2 SIMPLE tbl_set NULL ALL NULL NULL NULL NULL 11 63.64 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_set`.`col1` AS `col1` from `test`.`tbl_set` where (1 <> `test`.`tbl_set`.`col1`) +# Expect "72.73" in column "filtered" +EXPLAIN SELECT * FROM tbl_set WHERE col1 != ''; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 72.73 Parallel execute (1 workers) +2 SIMPLE tbl_set NULL ALL NULL NULL NULL NULL 11 72.73 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_set`.`col1` AS `col1` from `test`.`tbl_set` where (`test`.`tbl_set`.`col1` <> '') +EXPLAIN SELECT * FROM tbl_set WHERE col1 != 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 72.73 Parallel execute (1 workers) +2 SIMPLE tbl_set NULL ALL NULL NULL NULL NULL 11 72.73 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_set`.`col1` AS `col1` from `test`.`tbl_set` where (`test`.`tbl_set`.`col1` <> 0) +EXPLAIN SELECT * FROM tbl_set WHERE col1 <> ''; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 72.73 Parallel execute (1 workers) +2 SIMPLE tbl_set NULL ALL NULL NULL NULL NULL 11 72.73 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_set`.`col1` AS `col1` from `test`.`tbl_set` where (`test`.`tbl_set`.`col1` <> '') +EXPLAIN SELECT * FROM tbl_set WHERE col1 <> 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 72.73 Parallel execute (1 workers) +2 SIMPLE tbl_set NULL ALL NULL NULL NULL NULL 11 72.73 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_set`.`col1` AS `col1` from `test`.`tbl_set` where (`test`.`tbl_set`.`col1` <> 0) +# Expect "9.09" in column "filtered", due to the fact that the optimizer +# always assumes that at least one row will match. +EXPLAIN SELECT * FROM tbl_set WHERE col1 = 100; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 9.09 Parallel execute (1 workers) +2 SIMPLE tbl_set NULL ALL NULL NULL NULL NULL 11 9.09 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_set`.`col1` AS `col1` from `test`.`tbl_set` where (`test`.`tbl_set`.`col1` = 100) +EXPLAIN SELECT * FROM tbl_set WHERE 100 = col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 9.09 Parallel execute (1 workers) +2 SIMPLE tbl_set NULL ALL NULL NULL NULL NULL 11 9.09 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_set`.`col1` AS `col1` from `test`.`tbl_set` where (100 = `test`.`tbl_set`.`col1`) +# Expect "36.36" in column "filtered" +EXPLAIN SELECT * FROM tbl_set WHERE col1 IN (8, 14); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 36.36 Parallel execute (1 workers) +2 SIMPLE tbl_set NULL ALL NULL NULL NULL NULL 11 36.36 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_set`.`col1` AS `col1` from `test`.`tbl_set` where (`test`.`tbl_set`.`col1` in (8,14)) +# Expect "36.36" in column "filtered" +EXPLAIN SELECT * FROM tbl_set WHERE col1 NOT IN (8, 14); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 36.36 Parallel execute (1 workers) +2 SIMPLE tbl_set NULL ALL NULL NULL NULL NULL 11 36.36 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_set`.`col1` AS `col1` from `test`.`tbl_set` where (`test`.`tbl_set`.`col1` not in (8,14)) +DROP TABLE tbl_set; diff --git a/mysql-test/r/histograms.result-pq b/mysql-test/r/histograms.result-pq new file mode 100644 index 000000000000..ec805e737f0c --- /dev/null +++ b/mysql-test/r/histograms.result-pq @@ -0,0 +1,3391 @@ +################## +# UPDATE HISTOGRAM +################## +# +# Verify that we can build and store a histogram for all valid data types. +# +CREATE TABLE all_types ( +col_bool BOOLEAN, +col_bit BIT(64), +col_tinyint TINYINT, +col_smallint SMALLINT, +col_mediumint MEDIUMINT, +col_integer INTEGER, +col_bigint BIGINT, +col_tinyint_unsigned TINYINT UNSIGNED, +col_smallint_unsigned SMALLINT UNSIGNED, +col_mediumint_unsigned MEDIUMINT UNSIGNED, +col_integer_unsigned INTEGER UNSIGNED, +col_bigint_unsigned BIGINT UNSIGNED, +col_float FLOAT, +col_double DOUBLE, +col_decimal DECIMAL(65, 2), +col_date DATE, +col_time TIME, +col_year YEAR, +col_datetime DATETIME, +col_timestamp TIMESTAMP NULL, +col_char CHAR(255), +col_varchar VARCHAR(255), +col_tinytext TINYTEXT, +col_text TEXT, +col_mediumtext MEDIUMTEXT, +col_longtext LONGTEXT, +col_binary BINARY(255), +col_varbinary VARBINARY(255), +col_tinyblob TINYBLOB, +col_blob BLOB, +col_mediumblob MEDIUMBLOB, +col_longblob LONGBLOB, +col_enum ENUM('red', 'black', 'pink', 'white', 'purple'), +col_set SET('one', 'two', 'three')); +INSERT INTO all_types VALUES ( +NULL, # BOOLEAN +NULL, # BIT +NULL, # TINYINT +NULL, # SMALLINT +NULL, # MEDIUMINT +NULL, # INTEGER +NULL, # BIGINT +NULL, # TINYINT_UNSIGNED +NULL, # SMALLINT_UNSIGNED +NULL, # MEDIUMINT_UNSIGNED +NULL, # INTEGER_UNSIGNED +NULL, # BIGINT_UNSIGNED +NULL, # FLOAT +NULL, # DOUBLE +NULL, # DECIMAL(65, 2) +NULL, # DATE +NULL, # TIME +NULL, # YEAR +NULL, # DATETIME +NULL, # TIMESTAMP +NULL, # CHAR +NULL, # VARCHAR +NULL, # TINYTEXT +NULL, # TEXT +NULL, # MEDIUMTEXT +NULL, # LONGTEXT +NULL, # BINARY +NULL, # VARBINARY +NULL, # TINYBLOB +NULL, # BLOB +NULL, # MEDIUMBLOB +NULL, # LONGBLOB +NULL, # ENUM +NULL); +INSERT INTO all_types VALUES ( +FALSE, # BOOLEAN +b'0000000000000000000000000000000000000000000000000000000000000000', # BIT +-128, # TINYINT +-32768, # SMALLINT +-8388608, # MEDIUMINT +-2147483648, # INTEGER +-9223372036854775808, # BIGINT +0, # TINYINT_UNSIGNED +0, # SMALLINT_UNSIGNED +0, # MEDIUMINT_UNSIGNED +0, # INTEGER_UNSIGNED +0, # BIGINT_UNSIGNED +-3.402823466E+38, # FLOAT +-1.7976931348623157E+308, # DOUBLE +-999999999999999999999999999999999999999999999999999999999999999.99, # DECIMAL(65, 2) +'1000-01-01', # DATE +'-838:59:59.000000', # TIME +1901, # YEAR +'1000-01-01 00:00:00', # DATETIME +'1970-01-02 00:00:01', # TIMESTAMP +'', # CHAR +'', # VARCHAR +'', # TINYTEXT +'', # TEXT +'', # MEDIUMTEXT +'', # LONGTEXT +'', # BINARY +'', # VARBINARY +'', # TINYBLOB +'', # BLOB +'', # MEDIUMBLOB +'', # LONGBLOB +'red', # ENUM +''); +INSERT INTO all_types VALUES ( +TRUE, # BOOLEAN +b'1111111111111111111111111111111111111111111111111111111111111111', # BIT +127, # TINYINT +32767, # SMALLINT +8388607, # MEDIUMINT +2147483647, # INTEGER +9223372036854775807, # BIGINT +255, # TINYINT_UNSIGNED +65535, # SMALLINT_UNSIGNED +16777215, # MEDIUMINT_UNSIGNED +4294967295, # INTEGER_UNSIGNED +18446744073709551615, # BIGINT_UNSIGNED +3.402823466E+38, # FLOAT +1.7976931348623157E+308, # DOUBLE +999999999999999999999999999999999999999999999999999999999999999.99, # DECIMAL(65, 2) +'9999-12-31', # DATE +'838:59:59.000000', # TIME +2155, # YEAR +'9999-12-31 23:59:59', # DATETIME +'2038-01-19 03:14:07', # TIMESTAMP +'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', # CHAR +'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', # VARCHAR +'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', # TINYTEXT +'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', # TEXT +'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', # MEDIUMTEXT +'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', # LONGTEXT +'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', # BINARY +'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', # VARBINARY +'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', # TINYBLOB +'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', # BLOB +'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', # MEDIUMBLOB +'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', # LONGBLOB +'purple', # ENUM +'three'); +SELECT COUNT(*) AS should_be_0 FROM information_schema.COLUMN_STATISTICS; +should_be_0 +0 +# Check that ANALZYE TABLE without the "UPDATE HISTOGRAM"-clause doesn't +# have any effect on histogram statistics. +ANALYZE TABLE all_types; +Table Op Msg_type Msg_text +test.all_types analyze status OK +SELECT COUNT(*) AS should_be_0 FROM information_schema.COLUMN_STATISTICS; +should_be_0 +0 +ANALYZE TABLE all_types UPDATE HISTOGRAM ON col_bool, +col_bit, +col_tinyint, +col_smallint, +col_mediumint, +col_integer, +col_bigint, +col_tinyint_unsigned, +col_smallint_unsigned, +col_mediumint_unsigned, +col_integer_unsigned, +col_bigint_unsigned, +col_float, +col_double, +col_decimal, +col_date, +col_time, +col_year, +col_datetime, +col_timestamp, +col_char, +col_varchar, +col_tinytext, +col_text, +col_mediumtext, +col_longtext, +col_binary, +col_varbinary, +col_tinyblob, +col_blob, +col_mediumblob, +col_longblob, +col_enum, +col_set WITH 1024 BUCKETS; +Table Op Msg_type Msg_text +test.all_types histogram status Histogram statistics created for column 'col_bigint'. +test.all_types histogram status Histogram statistics created for column 'col_bigint_unsigned'. +test.all_types histogram status Histogram statistics created for column 'col_binary'. +test.all_types histogram status Histogram statistics created for column 'col_bit'. +test.all_types histogram status Histogram statistics created for column 'col_blob'. +test.all_types histogram status Histogram statistics created for column 'col_bool'. +test.all_types histogram status Histogram statistics created for column 'col_char'. +test.all_types histogram status Histogram statistics created for column 'col_date'. +test.all_types histogram status Histogram statistics created for column 'col_datetime'. +test.all_types histogram status Histogram statistics created for column 'col_decimal'. +test.all_types histogram status Histogram statistics created for column 'col_double'. +test.all_types histogram status Histogram statistics created for column 'col_enum'. +test.all_types histogram status Histogram statistics created for column 'col_float'. +test.all_types histogram status Histogram statistics created for column 'col_integer'. +test.all_types histogram status Histogram statistics created for column 'col_integer_unsigned'. +test.all_types histogram status Histogram statistics created for column 'col_longblob'. +test.all_types histogram status Histogram statistics created for column 'col_longtext'. +test.all_types histogram status Histogram statistics created for column 'col_mediumblob'. +test.all_types histogram status Histogram statistics created for column 'col_mediumint'. +test.all_types histogram status Histogram statistics created for column 'col_mediumint_unsigned'. +test.all_types histogram status Histogram statistics created for column 'col_mediumtext'. +test.all_types histogram status Histogram statistics created for column 'col_set'. +test.all_types histogram status Histogram statistics created for column 'col_smallint'. +test.all_types histogram status Histogram statistics created for column 'col_smallint_unsigned'. +test.all_types histogram status Histogram statistics created for column 'col_text'. +test.all_types histogram status Histogram statistics created for column 'col_time'. +test.all_types histogram status Histogram statistics created for column 'col_timestamp'. +test.all_types histogram status Histogram statistics created for column 'col_tinyblob'. +test.all_types histogram status Histogram statistics created for column 'col_tinyint'. +test.all_types histogram status Histogram statistics created for column 'col_tinyint_unsigned'. +test.all_types histogram status Histogram statistics created for column 'col_tinytext'. +test.all_types histogram status Histogram statistics created for column 'col_varbinary'. +test.all_types histogram status Histogram statistics created for column 'col_varchar'. +test.all_types histogram status Histogram statistics created for column 'col_year'. +# Remove 'last-updated' from the histogram, since it will change on every +# run. +SELECT schema_name, table_name, column_name, +JSON_REMOVE(histogram, '$."last-updated"') +FROM information_schema.COLUMN_STATISTICS; +SCHEMA_NAME TABLE_NAME COLUMN_NAME JSON_REMOVE(histogram, '$."last-updated"') +test all_types col_bigint {"buckets": [[-9223372036854775808, 0.3333333333333333], [9223372036854775807, 0.6666666666666666]], "data-type": "int", "null-values": 0.3333333333333333, "collation-id": 8, "sampling-rate": 1.0, "histogram-type": "singleton", "number-of-buckets-specified": 1024} +test all_types col_bigint_unsigned {"buckets": [[0, 0.3333333333333333], [18446744073709551615, 0.6666666666666666]], "data-type": "uint", "null-values": 0.3333333333333333, "collation-id": 8, "sampling-rate": 1.0, "histogram-type": "singleton", "number-of-buckets-specified": 1024} +test all_types col_binary {"buckets": [["base64:type254:AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", 0.3333333333333333], ["base64:type254:YWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFh", 0.6666666666666666]], "data-type": "string", "null-values": 0.3333333333333333, "collation-id": 63, "sampling-rate": 1.0, "histogram-type": "singleton", "number-of-buckets-specified": 1024} +test all_types col_bit {"buckets": [[-1, 0.3333333333333333], [0, 0.6666666666666666]], "data-type": "int", "null-values": 0.3333333333333333, "collation-id": 63, "sampling-rate": 1.0, "histogram-type": "singleton", "number-of-buckets-specified": 1024} +test all_types col_blob {"buckets": [["base64:type254:", 0.3333333333333333], ["base64:type254:YWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFh", 0.6666666666666666]], "data-type": "string", "null-values": 0.3333333333333333, "collation-id": 63, "sampling-rate": 1.0, "histogram-type": "singleton", "number-of-buckets-specified": 1024} +test all_types col_bool {"buckets": [[0, 0.3333333333333333], [1, 0.6666666666666666]], "data-type": "int", "null-values": 0.3333333333333333, "collation-id": 8, "sampling-rate": 1.0, "histogram-type": "singleton", "number-of-buckets-specified": 1024} +test all_types col_char {"buckets": [["base64:type254:", 0.3333333333333333], ["base64:type254:YWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFh", 0.6666666666666666]], "data-type": "string", "null-values": 0.3333333333333333, "collation-id": 255, "sampling-rate": 1.0, "histogram-type": "singleton", "number-of-buckets-specified": 1024} +test all_types col_date {"buckets": [["1000-01-01", 0.3333333333333333], ["9999-12-31", 0.6666666666666666]], "data-type": "date", "null-values": 0.3333333333333333, "collation-id": 8, "sampling-rate": 1.0, "histogram-type": "singleton", "number-of-buckets-specified": 1024} +test all_types col_datetime {"buckets": [["1000-01-01 00:00:00.000000", 0.3333333333333333], ["9999-12-31 23:59:59.000000", 0.6666666666666666]], "data-type": "datetime", "null-values": 0.3333333333333333, "collation-id": 8, "sampling-rate": 1.0, "histogram-type": "singleton", "number-of-buckets-specified": 1024} +test all_types col_decimal {"buckets": [[-999999999999999999999999999999999999999999999999999999999999999.99, 0.3333333333333333], [999999999999999999999999999999999999999999999999999999999999999.99, 0.6666666666666666]], "data-type": "decimal", "null-values": 0.3333333333333333, "collation-id": 8, "sampling-rate": 1.0, "histogram-type": "singleton", "number-of-buckets-specified": 1024} +test all_types col_double {"buckets": [[-1.7976931348623157e308, 0.3333333333333333], [1.7976931348623157e308, 0.6666666666666666]], "data-type": "double", "null-values": 0.3333333333333333, "collation-id": 8, "sampling-rate": 1.0, "histogram-type": "singleton", "number-of-buckets-specified": 1024} +test all_types col_enum {"buckets": [[1, 0.3333333333333333], [5, 0.6666666666666666]], "data-type": "enum", "null-values": 0.3333333333333333, "collation-id": 255, "sampling-rate": 1.0, "histogram-type": "singleton", "number-of-buckets-specified": 1024} +test all_types col_float {"buckets": [[-3.4028234663852886e38, 0.3333333333333333], [3.4028234663852886e38, 0.6666666666666666]], "data-type": "double", "null-values": 0.3333333333333333, "collation-id": 8, "sampling-rate": 1.0, "histogram-type": "singleton", "number-of-buckets-specified": 1024} +test all_types col_integer {"buckets": [[-2147483648, 0.3333333333333333], [2147483647, 0.6666666666666666]], "data-type": "int", "null-values": 0.3333333333333333, "collation-id": 8, "sampling-rate": 1.0, "histogram-type": "singleton", "number-of-buckets-specified": 1024} +test all_types col_integer_unsigned {"buckets": [[0, 0.3333333333333333], [4294967295, 0.6666666666666666]], "data-type": "int", "null-values": 0.3333333333333333, "collation-id": 8, "sampling-rate": 1.0, "histogram-type": "singleton", "number-of-buckets-specified": 1024} +test all_types col_longblob {"buckets": [["base64:type254:", 0.3333333333333333], ["base64:type254:YWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFh", 0.6666666666666666]], "data-type": "string", "null-values": 0.3333333333333333, "collation-id": 63, "sampling-rate": 1.0, "histogram-type": "singleton", "number-of-buckets-specified": 1024} +test all_types col_longtext {"buckets": [["base64:type254:", 0.3333333333333333], ["base64:type254:YWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFh", 0.6666666666666666]], "data-type": "string", "null-values": 0.3333333333333333, "collation-id": 255, "sampling-rate": 1.0, "histogram-type": "singleton", "number-of-buckets-specified": 1024} +test all_types col_mediumblob {"buckets": [["base64:type254:", 0.3333333333333333], ["base64:type254:YWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFh", 0.6666666666666666]], "data-type": "string", "null-values": 0.3333333333333333, "collation-id": 63, "sampling-rate": 1.0, "histogram-type": "singleton", "number-of-buckets-specified": 1024} +test all_types col_mediumint {"buckets": [[-8388608, 0.3333333333333333], [8388607, 0.6666666666666666]], "data-type": "int", "null-values": 0.3333333333333333, "collation-id": 8, "sampling-rate": 1.0, "histogram-type": "singleton", "number-of-buckets-specified": 1024} +test all_types col_mediumint_unsigned {"buckets": [[0, 0.3333333333333333], [16777215, 0.6666666666666666]], "data-type": "int", "null-values": 0.3333333333333333, "collation-id": 8, "sampling-rate": 1.0, "histogram-type": "singleton", "number-of-buckets-specified": 1024} +test all_types col_mediumtext {"buckets": [["base64:type254:", 0.3333333333333333], ["base64:type254:YWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFh", 0.6666666666666666]], "data-type": "string", "null-values": 0.3333333333333333, "collation-id": 255, "sampling-rate": 1.0, "histogram-type": "singleton", "number-of-buckets-specified": 1024} +test all_types col_set {"buckets": [[0, 0.3333333333333333], [4, 0.6666666666666666]], "data-type": "set", "null-values": 0.3333333333333333, "collation-id": 255, "sampling-rate": 1.0, "histogram-type": "singleton", "number-of-buckets-specified": 1024} +test all_types col_smallint {"buckets": [[-32768, 0.3333333333333333], [32767, 0.6666666666666666]], "data-type": "int", "null-values": 0.3333333333333333, "collation-id": 8, "sampling-rate": 1.0, "histogram-type": "singleton", "number-of-buckets-specified": 1024} +test all_types col_smallint_unsigned {"buckets": [[0, 0.3333333333333333], [65535, 0.6666666666666666]], "data-type": "int", "null-values": 0.3333333333333333, "collation-id": 8, "sampling-rate": 1.0, "histogram-type": "singleton", "number-of-buckets-specified": 1024} +test all_types col_text {"buckets": [["base64:type254:", 0.3333333333333333], ["base64:type254:YWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFh", 0.6666666666666666]], "data-type": "string", "null-values": 0.3333333333333333, "collation-id": 255, "sampling-rate": 1.0, "histogram-type": "singleton", "number-of-buckets-specified": 1024} +test all_types col_time {"buckets": [["-838:59:59.000000", 0.3333333333333333], ["838:59:59.000000", 0.6666666666666666]], "data-type": "time", "null-values": 0.3333333333333333, "collation-id": 8, "sampling-rate": 1.0, "histogram-type": "singleton", "number-of-buckets-specified": 1024} +test all_types col_timestamp {"buckets": [["1970-01-02 00:00:01.000000", 0.3333333333333333], ["2038-01-19 03:14:07.000000", 0.6666666666666666]], "data-type": "datetime", "null-values": 0.3333333333333333, "collation-id": 8, "sampling-rate": 1.0, "histogram-type": "singleton", "number-of-buckets-specified": 1024} +test all_types col_tinyblob {"buckets": [["base64:type254:", 0.3333333333333333], ["base64:type254:YWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFh", 0.6666666666666666]], "data-type": "string", "null-values": 0.3333333333333333, "collation-id": 63, "sampling-rate": 1.0, "histogram-type": "singleton", "number-of-buckets-specified": 1024} +test all_types col_tinyint {"buckets": [[-128, 0.3333333333333333], [127, 0.6666666666666666]], "data-type": "int", "null-values": 0.3333333333333333, "collation-id": 8, "sampling-rate": 1.0, "histogram-type": "singleton", "number-of-buckets-specified": 1024} +test all_types col_tinyint_unsigned {"buckets": [[0, 0.3333333333333333], [255, 0.6666666666666666]], "data-type": "int", "null-values": 0.3333333333333333, "collation-id": 8, "sampling-rate": 1.0, "histogram-type": "singleton", "number-of-buckets-specified": 1024} +test all_types col_tinytext {"buckets": [["base64:type254:", 0.3333333333333333], ["base64:type254:YWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFh", 0.6666666666666666]], "data-type": "string", "null-values": 0.3333333333333333, "collation-id": 255, "sampling-rate": 1.0, "histogram-type": "singleton", "number-of-buckets-specified": 1024} +test all_types col_varbinary {"buckets": [["base64:type254:", 0.3333333333333333], ["base64:type254:YWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFh", 0.6666666666666666]], "data-type": "string", "null-values": 0.3333333333333333, "collation-id": 63, "sampling-rate": 1.0, "histogram-type": "singleton", "number-of-buckets-specified": 1024} +test all_types col_varchar {"buckets": [["base64:type254:", 0.3333333333333333], ["base64:type254:YWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFh", 0.6666666666666666]], "data-type": "string", "null-values": 0.3333333333333333, "collation-id": 255, "sampling-rate": 1.0, "histogram-type": "singleton", "number-of-buckets-specified": 1024} +test all_types col_year {"buckets": [[1901, 0.3333333333333333], [2155, 0.6666666666666666]], "data-type": "int", "null-values": 0.3333333333333333, "collation-id": 8, "sampling-rate": 1.0, "histogram-type": "singleton", "number-of-buckets-specified": 1024} +# When we remove the table, all histograms that belong to this table +# should also dissapear. +DROP TABLE all_types; +SELECT COUNT(*) AS should_be_0 FROM information_schema.COLUMN_STATISTICS; +should_be_0 +0 +# +# Check that we don't try to build and/or store histogram statistics for +# unsupported data types. +# +CREATE TABLE unsupported_types (col_geometry GEOMETRY, +col_point POINT, +col_linestring LINESTRING, +col_polygon POLYGON, +col_multipoint MULTIPOINT, +col_multilinestring MULTILINESTRING, +col_multipolygon MULTIPOLYGON, +col_geometrycollection GEOMETRYCOLLECTION, +col_json JSON); +ANALYZE TABLE unsupported_types UPDATE HISTOGRAM ON col_geometry, +col_point, +col_linestring, +col_polygon, +col_multipoint, +col_multilinestring, +col_multipolygon, +col_geometrycollection, +col_json WITH 100 BUCKETS; +Table Op Msg_type Msg_text +test.unsupported_types histogram Error The column 'col_geometry' has an unsupported data type. +test.unsupported_types histogram Error The column 'col_geometrycollection' has an unsupported data type. +test.unsupported_types histogram Error The column 'col_json' has an unsupported data type. +test.unsupported_types histogram Error The column 'col_linestring' has an unsupported data type. +test.unsupported_types histogram Error The column 'col_multilinestring' has an unsupported data type. +test.unsupported_types histogram Error The column 'col_multipoint' has an unsupported data type. +test.unsupported_types histogram Error The column 'col_multipolygon' has an unsupported data type. +test.unsupported_types histogram Error The column 'col_point' has an unsupported data type. +test.unsupported_types histogram Error The column 'col_polygon' has an unsupported data type. +SELECT COUNT(*) AS should_be_0 FROM information_schema.COLUMN_STATISTICS; +should_be_0 +0 +DROP TABLE unsupported_types; +CREATE TABLE t1 (col_integer INT); +# +# Non-existing column +# +ANALYZE TABLE t1 UPDATE HISTOGRAM ON foobar WITH 100 BUCKETS; +Table Op Msg_type Msg_text +test.t1 histogram Error The column 'foobar' does not exist. +SELECT COUNT(*) AS should_be_0 FROM information_schema.COLUMN_STATISTICS; +should_be_0 +0 +# +# Non-existing table +# +ANALYZE TABLE foobar UPDATE HISTOGRAM ON foobar WITH 100 BUCKETS; +Table Op Msg_type Msg_text +test.foobar histogram Error Table 'test.foobar' doesn't exist +SELECT COUNT(*) AS should_be_0 FROM information_schema.COLUMN_STATISTICS; +should_be_0 +0 +# +# Temporary table +# +CREATE TEMPORARY TABLE temp_table (col1 INT); +ANALYZE TABLE temp_table UPDATE HISTOGRAM ON col1 WITH 100 BUCKETS; +Table Op Msg_type Msg_text +test.temp_table histogram Error Cannot create histogram statistics for a temporary table. +SELECT COUNT(*) AS should_be_0 FROM information_schema.COLUMN_STATISTICS; +should_be_0 +0 +DROP TABLE temp_table; +# +# View +# +CREATE VIEW my_view AS SELECT * FROM t1; +ANALYZE TABLE my_view UPDATE HISTOGRAM ON col_integer WITH 100 BUCKETS; +Table Op Msg_type Msg_text +test.my_view histogram Error Cannot create histogram statistics for a view. +SELECT COUNT(*) AS should_be_0 FROM information_schema.COLUMN_STATISTICS; +should_be_0 +0 +DROP VIEW my_view; +# +# Generated column +# +ALTER TABLE t1 ADD COLUMN virtual_generated INT AS (col_integer + 10) VIRTUAL, +ADD COLUMN stored_generated INT AS (col_integer + 20) STORED; +INSERT INTO t1 (col_integer) VALUES (10), (20), (30); +ANALYZE TABLE t1 UPDATE HISTOGRAM ON col_integer, +virtual_generated, +stored_generated +WITH 100 BUCKETS; +Table Op Msg_type Msg_text +test.t1 histogram status Histogram statistics created for column 'col_integer'. +test.t1 histogram status Histogram statistics created for column 'stored_generated'. +test.t1 histogram status Histogram statistics created for column 'virtual_generated'. +SELECT schema_name, table_name, column_name, +JSON_REMOVE(histogram, '$."last-updated"') +FROM information_schema.COLUMN_STATISTICS; +SCHEMA_NAME TABLE_NAME COLUMN_NAME JSON_REMOVE(histogram, '$."last-updated"') +test t1 col_integer {"buckets": [[10, 0.3333333333333333], [20, 0.6666666666666666], [30, 1.0]], "data-type": "int", "null-values": 0.0, "collation-id": 8, "sampling-rate": 1.0, "histogram-type": "singleton", "number-of-buckets-specified": 100} +test t1 stored_generated {"buckets": [[30, 0.3333333333333333], [40, 0.6666666666666666], [50, 1.0]], "data-type": "int", "null-values": 0.0, "collation-id": 8, "sampling-rate": 1.0, "histogram-type": "singleton", "number-of-buckets-specified": 100} +test t1 virtual_generated {"buckets": [[20, 0.3333333333333333], [30, 0.6666666666666666], [40, 1.0]], "data-type": "int", "null-values": 0.0, "collation-id": 8, "sampling-rate": 1.0, "histogram-type": "singleton", "number-of-buckets-specified": 100} +ALTER TABLE t1 DROP COLUMN virtual_generated, DROP COLUMN stored_generated; +# The histogram for 'virtual_generated' and 'stored_generated' should now +# be gone +SELECT schema_name, table_name, column_name +FROM information_schema.COLUMN_STATISTICS; +SCHEMA_NAME TABLE_NAME COLUMN_NAME +test t1 col_integer +DELETE FROM t1; +# +# Check that the server switches between singleton and equi-height when +# it should. +# +INSERT INTO t1 VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10); +ANALYZE TABLE t1 UPDATE HISTOGRAM ON col_integer WITH 10 BUCKETS; +Table Op Msg_type Msg_text +test.t1 histogram status Histogram statistics created for column 'col_integer'. +SELECT schema_name, table_name, column_name, +JSON_EXTRACT(histogram, '$."histogram-type"') AS should_be_singleton +FROM information_schema.COLUMN_STATISTICS; +SCHEMA_NAME TABLE_NAME COLUMN_NAME should_be_singleton +test t1 col_integer "singleton" +ANALYZE TABLE t1 UPDATE HISTOGRAM ON col_integer WITH 9 BUCKETS; +Table Op Msg_type Msg_text +test.t1 histogram status Histogram statistics created for column 'col_integer'. +SELECT schema_name, table_name, column_name, +JSON_EXTRACT(histogram, '$."histogram-type"') AS should_be_equiheight +FROM information_schema.COLUMN_STATISTICS; +SCHEMA_NAME TABLE_NAME COLUMN_NAME should_be_equiheight +test t1 col_integer "equi-height" +DROP TABLE t1; +# +# Check that invalid range for the number of buckets is rejected +# (should be in the range [1, 1024]). +# +ANALYZE TABLE foo UPDATE HISTOGRAM ON foo WITH 0 BUCKETS; +ERROR 22003: Number of buckets value is out of range in 'ANALYZE TABLE' +ANALYZE TABLE foo UPDATE HISTOGRAM ON foo WITH 1025 BUCKETS; +ERROR 22003: Number of buckets value is out of range in 'ANALYZE TABLE' +ANALYZE TABLE foo UPDATE HISTOGRAM ON foo WITH -1 BUCKETS; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '-1 BUCKETS' at line 1 +# +# Check that 'tbl.col' and 'db.tbl.col' isn't allowed. +# +ANALYZE TABLE foo UPDATE HISTOGRAM ON tbl.col WITH 100 BUCKETS; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '.col WITH 100 BUCKETS' at line 1 +ANALYZE TABLE foo UPDATE HISTOGRAM ON db.tbl.col WITH 100 BUCKETS; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '.tbl.col WITH 100 BUCKETS' at line 1 +# +# Multiple tables in ANALYZE TABLE .. UPDATE HISTOGRAM +# +ANALYZE TABLE foo, foo2 UPDATE HISTOGRAM ON bar WITH 100 BUCKETS; +Table Op Msg_type Msg_text + histogram Error Only one table can be specified while modifying histogram statistics. +# +# Histogram statistics should not be created for columns covered by a +# single-part unique index +# +CREATE TABLE t1 (col1 INT PRIMARY KEY, +col2 INT, +col3 INT, +UNIQUE INDEX index_1 (col2), +UNIQUE INDEX index_2 (col3, col2)); +ANALYZE TABLE t1 UPDATE HISTOGRAM ON col1, col2, col3 WITH 100 BUCKETS; +Table Op Msg_type Msg_text +test.t1 histogram Error The column 'col1' is covered by a single-part unique index. +test.t1 histogram Error The column 'col2' is covered by a single-part unique index. +test.t1 histogram status Histogram statistics created for column 'col3'. +# We should end up with histogram statistics for 'col3' +SELECT schema_name, table_name, column_name +FROM information_schema.COLUMN_STATISTICS; +SCHEMA_NAME TABLE_NAME COLUMN_NAME +test t1 col3 +# If we hide the index however, we should be able to create a histogram +# for 'col2' +ALTER TABLE t1 ALTER INDEX index_1 INVISIBLE; +ANALYZE TABLE t1 UPDATE HISTOGRAM ON col2 WITH 100 BUCKETS; +Table Op Msg_type Msg_text +test.t1 histogram status Histogram statistics created for column 'col2'. +SELECT schema_name, table_name, column_name +FROM information_schema.COLUMN_STATISTICS; +SCHEMA_NAME TABLE_NAME COLUMN_NAME +test t1 col2 +test t1 col3 +DROP TABLE t1; +# +# The server should not create a histogram with more buckets than +# specified +# +CREATE TABLE t1 (col1 INT); +INSERT INTO t1 SELECT 1; +INSERT INTO t1 SELECT col1 + 1 FROM t1; +INSERT INTO t1 SELECT col1 + 2 FROM t1; +INSERT INTO t1 SELECT col1 + 4 FROM t1; +INSERT INTO t1 SELECT col1 + 8 FROM t1; +INSERT INTO t1 SELECT col1 + 16 FROM t1; +INSERT INTO t1 SELECT col1 + 32 FROM t1; +INSERT INTO t1 SELECT col1 + 64 FROM t1; +INSERT INTO t1 SELECT col1 + 128 FROM t1; +ANALYZE TABLE t1 UPDATE HISTOGRAM ON col1 WITH 10 BUCKETS; +Table Op Msg_type Msg_text +test.t1 histogram status Histogram statistics created for column 'col1'. +SELECT JSON_LENGTH(histogram->'$.buckets') <= 10 +FROM information_schema.COLUMN_STATISTICS +WHERE schema_name = 'test' AND table_name = 't1' AND column_name = 'col1'; +JSON_LENGTH(histogram->'$.buckets') <= 10 +1 +ANALYZE TABLE t1 UPDATE HISTOGRAM ON col1 WITH 57 BUCKETS; +Table Op Msg_type Msg_text +test.t1 histogram status Histogram statistics created for column 'col1'. +SELECT JSON_LENGTH(histogram->'$.buckets') <= 57 +FROM information_schema.COLUMN_STATISTICS +WHERE schema_name = 'test' AND table_name = 't1' AND column_name = 'col1'; +JSON_LENGTH(histogram->'$.buckets') <= 57 +1 +ANALYZE TABLE t1 UPDATE HISTOGRAM ON col1 WITH 255 BUCKETS; +Table Op Msg_type Msg_text +test.t1 histogram status Histogram statistics created for column 'col1'. +SELECT JSON_LENGTH(histogram->'$.buckets') <= 255 +FROM information_schema.COLUMN_STATISTICS +WHERE schema_name = 'test' AND table_name = 't1' AND column_name = 'col1'; +JSON_LENGTH(histogram->'$.buckets') <= 255 +1 +# +# If the same column is specified more than once, the server should raise +# the error ER_DUP_FIELDNAME +# +ANALYZE TABLE t1 UPDATE HISTOGRAM ON col1, col2, col1 WITH 10 BUCKETS; +ERROR 42S21: Duplicate column name 'col1' +DROP TABLE t1; +################ +# DROP HISTOGRAM +################ +# Check that we don't have any histograms here +SELECT COUNT(*) AS should_be_0 FROM information_schema.COLUMN_STATISTICS; +should_be_0 +0 +CREATE TABLE t1 (col1 INT, col2 VARCHAR(255)); +INSERT INTO t1 VALUES (1, "1"), (2, "2"), (3, "3"), (4, "4"), (5, "5"), +(6, "6"), (7, "7"), (8, "8"), (9, "9"), (10, "10"); +ANALYZE TABLE t1 UPDATE HISTOGRAM ON col1, col2 WITH 10 BUCKETS; +Table Op Msg_type Msg_text +test.t1 histogram status Histogram statistics created for column 'col1'. +test.t1 histogram status Histogram statistics created for column 'col2'. +# We should now have two histograms. +SELECT schema_name, table_name, column_name +FROM information_schema.COLUMN_STATISTICS; +SCHEMA_NAME TABLE_NAME COLUMN_NAME +test t1 col1 +test t1 col2 +ANALYZE TABLE t1 DROP HISTOGRAM ON col2; +Table Op Msg_type Msg_text +test.t1 histogram status Histogram statistics removed for column 'col2'. +# We should now have one histogram. +SELECT schema_name, table_name, column_name +FROM information_schema.COLUMN_STATISTICS; +SCHEMA_NAME TABLE_NAME COLUMN_NAME +test t1 col1 +ANALYZE TABLE t1 DROP HISTOGRAM ON col1; +Table Op Msg_type Msg_text +test.t1 histogram status Histogram statistics removed for column 'col1'. +# All histograms should have been removed. +SELECT schema_name, table_name, column_name +FROM information_schema.COLUMN_STATISTICS; +SCHEMA_NAME TABLE_NAME COLUMN_NAME +ANALYZE TABLE t1 UPDATE HISTOGRAM ON col1, col2 WITH 10 BUCKETS; +Table Op Msg_type Msg_text +test.t1 histogram status Histogram statistics created for column 'col1'. +test.t1 histogram status Histogram statistics created for column 'col2'. +# We should now have two histograms. +SELECT schema_name, table_name, column_name +FROM information_schema.COLUMN_STATISTICS; +SCHEMA_NAME TABLE_NAME COLUMN_NAME +test t1 col1 +test t1 col2 +ANALYZE TABLE t1 DROP HISTOGRAM ON col2, col1; +Table Op Msg_type Msg_text +test.t1 histogram status Histogram statistics removed for column 'col1'. +test.t1 histogram status Histogram statistics removed for column 'col2'. +# All histograms should have been removed. +SELECT schema_name, table_name, column_name +FROM information_schema.COLUMN_STATISTICS; +SCHEMA_NAME TABLE_NAME COLUMN_NAME +# Try to drop histogram statistics for a column that does not have any +# histogram +ANALYZE TABLE t1 DROP HISTOGRAM ON col1; +Table Op Msg_type Msg_text +test.t1 histogram Error No histogram statistics found for column 'col1'. +ANALYZE TABLE t1 UPDATE HISTOGRAM ON col2 WITH 10 BUCKETS; +Table Op Msg_type Msg_text +test.t1 histogram status Histogram statistics created for column 'col2'. +ANALYZE TABLE t1 DROP HISTOGRAM ON col1, col2; +Table Op Msg_type Msg_text +test.t1 histogram Error No histogram statistics found for column 'col1'. +test.t1 histogram status Histogram statistics removed for column 'col2'. +# +# Non-existing column +# +ANALYZE TABLE t1 DROP HISTOGRAM ON foobar; +Table Op Msg_type Msg_text +test.t1 histogram Error No histogram statistics found for column 'foobar'. +# +# Non-existing table +# +ANALYZE TABLE foo DROP HISTOGRAM ON foobar; +Table Op Msg_type Msg_text +test.foo histogram Error No histogram statistics found for column 'foobar'. +# +# The same column specified multiple times +# +ANALYZE TABLE foo DROP HISTOGRAM ON foobar, foobar; +ERROR 42S21: Duplicate column name 'foobar' +# +# Multiple tables specified in ANALYZE TABLE .. DROP HISTOGRAM should not +# be allowed. +# +CREATE TABLE t2 (col1 INT); +ANALYZE TABLE t1, t2 DROP HISTOGRAM ON col1; +Table Op Msg_type Msg_text + histogram Error Only one table can be specified while modifying histogram statistics. +DROP TABLE t1, t2; +##################################### +# HISTOGRAM REMOVAL ON DDL STATEMENTS +##################################### +# Check that we don't have any histograms here +SELECT COUNT(*) AS should_be_0 FROM information_schema.COLUMN_STATISTICS; +should_be_0 +0 +# +# DROP TABLE +# +CREATE TABLE t1 (col1 INT); +ANALYZE TABLE t1 UPDATE HISTOGRAM ON col1 WITH 10 BUCKETS; +Table Op Msg_type Msg_text +test.t1 histogram status Histogram statistics created for column 'col1'. +SELECT schema_name, table_name, column_name +FROM information_schema.COLUMN_STATISTICS; +SCHEMA_NAME TABLE_NAME COLUMN_NAME +test t1 col1 +DROP TABLE t1; +SELECT COUNT(*) AS should_be_0 FROM information_schema.COLUMN_STATISTICS; +should_be_0 +0 +# +# Rename column +# +CREATE TABLE t1 (col1 INT, col2 INT); +ANALYZE TABLE t1 UPDATE HISTOGRAM ON col1, col2 WITH 10 BUCKETS; +Table Op Msg_type Msg_text +test.t1 histogram status Histogram statistics created for column 'col1'. +test.t1 histogram status Histogram statistics created for column 'col2'. +SELECT schema_name, table_name, column_name +FROM information_schema.COLUMN_STATISTICS; +SCHEMA_NAME TABLE_NAME COLUMN_NAME +test t1 col1 +test t1 col2 +ALTER TABLE t1 CHANGE COLUMN col1 col1_renamed INT; +SELECT schema_name, table_name, column_name +FROM information_schema.COLUMN_STATISTICS; +SCHEMA_NAME TABLE_NAME COLUMN_NAME +test t1 col2 +# +# Change column definition +# +ALTER TABLE t1 CHANGE COLUMN col2 col2 VARCHAR(255); +SELECT schema_name, table_name, column_name +FROM information_schema.COLUMN_STATISTICS; +SCHEMA_NAME TABLE_NAME COLUMN_NAME +# +# Drop column +# +ANALYZE TABLE t1 UPDATE HISTOGRAM ON col2 WITH 10 BUCKETS; +Table Op Msg_type Msg_text +test.t1 histogram status Histogram statistics created for column 'col2'. +SELECT schema_name, table_name, column_name +FROM information_schema.COLUMN_STATISTICS; +SCHEMA_NAME TABLE_NAME COLUMN_NAME +test t1 col2 +ALTER TABLE t1 DROP COLUMN col2; +SELECT schema_name, table_name, column_name +FROM information_schema.COLUMN_STATISTICS; +SCHEMA_NAME TABLE_NAME COLUMN_NAME +# +# Rename table +# +INSERT INTO t1 VALUES (1), (2); +ANALYZE TABLE t1 UPDATE HISTOGRAM ON col1_renamed WITH 10 BUCKETS; +Table Op Msg_type Msg_text +test.t1 histogram status Histogram statistics created for column 'col1_renamed'. +SELECT schema_name, table_name, column_name, +JSON_REMOVE(histogram, '$."last-updated"') +FROM information_schema.COLUMN_STATISTICS; +SCHEMA_NAME TABLE_NAME COLUMN_NAME JSON_REMOVE(histogram, '$."last-updated"') +test t1 col1_renamed {"buckets": [[1, 0.5], [2, 1.0]], "data-type": "int", "null-values": 0.0, "collation-id": 8, "sampling-rate": 1.0, "histogram-type": "singleton", "number-of-buckets-specified": 10} +RENAME TABLE t1 TO t1_renamed; +SELECT schema_name, table_name, column_name, +JSON_REMOVE(histogram, '$."last-updated"') +FROM information_schema.COLUMN_STATISTICS; +SCHEMA_NAME TABLE_NAME COLUMN_NAME JSON_REMOVE(histogram, '$."last-updated"') +test t1_renamed col1_renamed {"buckets": [[1, 0.5], [2, 1.0]], "data-type": "int", "null-values": 0.0, "collation-id": 8, "sampling-rate": 1.0, "histogram-type": "singleton", "number-of-buckets-specified": 10} +ALTER TABLE t1_renamed RENAME TO t1; +SELECT schema_name, table_name, column_name, +JSON_REMOVE(histogram, '$."last-updated"') +FROM information_schema.COLUMN_STATISTICS; +SCHEMA_NAME TABLE_NAME COLUMN_NAME JSON_REMOVE(histogram, '$."last-updated"') +test t1 col1_renamed {"buckets": [[1, 0.5], [2, 1.0]], "data-type": "int", "null-values": 0.0, "collation-id": 8, "sampling-rate": 1.0, "histogram-type": "singleton", "number-of-buckets-specified": 10} +ALTER TABLE t1 RENAME TO t1_renamed, ALGORITHM = INPLACE; +SELECT schema_name, table_name, column_name, +JSON_REMOVE(histogram, '$."last-updated"') +FROM information_schema.COLUMN_STATISTICS; +SCHEMA_NAME TABLE_NAME COLUMN_NAME JSON_REMOVE(histogram, '$."last-updated"') +test t1_renamed col1_renamed {"buckets": [[1, 0.5], [2, 1.0]], "data-type": "int", "null-values": 0.0, "collation-id": 8, "sampling-rate": 1.0, "histogram-type": "singleton", "number-of-buckets-specified": 10} +ALTER TABLE t1_renamed RENAME TO t1, ALGORITHM = COPY; +SELECT schema_name, table_name, column_name, +JSON_REMOVE(histogram, '$."last-updated"') +FROM information_schema.COLUMN_STATISTICS; +SCHEMA_NAME TABLE_NAME COLUMN_NAME JSON_REMOVE(histogram, '$."last-updated"') +test t1 col1_renamed {"buckets": [[1, 0.5], [2, 1.0]], "data-type": "int", "null-values": 0.0, "collation-id": 8, "sampling-rate": 1.0, "histogram-type": "singleton", "number-of-buckets-specified": 10} +DROP TABLE t1; +# +# Do RENAME TABLE on a table with string contents, since they have a more +# complicated memory handling. Test both singleton and equi-height +# +CREATE TABLE t1 (col1 VARCHAR(255), col2 VARCHAR(255)); +INSERT INTO t1 VALUES ('foo', 'foo'), ('bar', 'bar'), ('fo', 'fo'), +('yay', 'yay'); +ANALYZE TABLE t1 UPDATE HISTOGRAM ON col1 WITH 10 BUCKETS; +Table Op Msg_type Msg_text +test.t1 histogram status Histogram statistics created for column 'col1'. +ANALYZE TABLE t1 UPDATE HISTOGRAM ON col2 WITH 2 BUCKETS; +Table Op Msg_type Msg_text +test.t1 histogram status Histogram statistics created for column 'col2'. +SELECT schema_name, table_name, column_name, +JSON_REMOVE(histogram, '$."last-updated"') +FROM information_schema.COLUMN_STATISTICS; +SCHEMA_NAME TABLE_NAME COLUMN_NAME JSON_REMOVE(histogram, '$."last-updated"') +test t1 col1 {"buckets": [["base64:type254:YmFy", 0.25], ["base64:type254:Zm8=", 0.5], ["base64:type254:Zm9v", 0.75], ["base64:type254:eWF5", 1.0]], "data-type": "string", "null-values": 0.0, "collation-id": 255, "sampling-rate": 1.0, "histogram-type": "singleton", "number-of-buckets-specified": 10} +test t1 col2 {"buckets": [["base64:type254:YmFy", "base64:type254:Zm8=", 0.5, 2], ["base64:type254:Zm9v", "base64:type254:eWF5", 1.0, 2]], "data-type": "string", "null-values": 0.0, "collation-id": 255, "sampling-rate": 1.0, "histogram-type": "equi-height", "number-of-buckets-specified": 2} +RENAME TABLE t1 TO t1_renamed; +SELECT schema_name, table_name, column_name, +JSON_REMOVE(histogram, '$."last-updated"') +FROM information_schema.COLUMN_STATISTICS; +SCHEMA_NAME TABLE_NAME COLUMN_NAME JSON_REMOVE(histogram, '$."last-updated"') +test t1_renamed col1 {"buckets": [["base64:type254:YmFy", 0.25], ["base64:type254:Zm8=", 0.5], ["base64:type254:Zm9v", 0.75], ["base64:type254:eWF5", 1.0]], "data-type": "string", "null-values": 0.0, "collation-id": 255, "sampling-rate": 1.0, "histogram-type": "singleton", "number-of-buckets-specified": 10} +test t1_renamed col2 {"buckets": [["base64:type254:YmFy", "base64:type254:Zm8=", 0.5, 2], ["base64:type254:Zm9v", "base64:type254:eWF5", 1.0, 2]], "data-type": "string", "null-values": 0.0, "collation-id": 255, "sampling-rate": 1.0, "histogram-type": "equi-height", "number-of-buckets-specified": 2} +DROP TABLE t1_renamed; +# +# Drop database +# +CREATE DATABASE histogram_db; +CREATE TABLE histogram_db.t1 (col1 INT); +ANALYZE TABLE histogram_db.t1 UPDATE HISTOGRAM ON col1 WITH 10 BUCKETS; +Table Op Msg_type Msg_text +histogram_db.t1 histogram status Histogram statistics created for column 'col1'. +SELECT schema_name, table_name, column_name +FROM information_schema.COLUMN_STATISTICS; +SCHEMA_NAME TABLE_NAME COLUMN_NAME +histogram_db t1 col1 +DROP DATABASE histogram_db; +SELECT schema_name, table_name, column_name +FROM information_schema.COLUMN_STATISTICS; +SCHEMA_NAME TABLE_NAME COLUMN_NAME +# +# Change character set +# +CREATE TABLE t1 (col1 VARCHAR(255), col2 CHAR(10), col3 TEXT, col4 INT, +col5 BLOB) CHARACTER SET latin1; +ANALYZE TABLE t1 UPDATE HISTOGRAM ON col1, col2, col3, col4, col5 +WITH 10 BUCKETS; +Table Op Msg_type Msg_text +test.t1 histogram status Histogram statistics created for column 'col1'. +test.t1 histogram status Histogram statistics created for column 'col2'. +test.t1 histogram status Histogram statistics created for column 'col3'. +test.t1 histogram status Histogram statistics created for column 'col4'. +test.t1 histogram status Histogram statistics created for column 'col5'. +SELECT schema_name, table_name, column_name +FROM information_schema.COLUMN_STATISTICS; +SCHEMA_NAME TABLE_NAME COLUMN_NAME +test t1 col1 +test t1 col2 +test t1 col3 +test t1 col4 +test t1 col5 +ALTER TABLE t1 CONVERT TO CHARACTER SET utf8mb4; +# Only col4 and col5 should remain +SELECT schema_name, table_name, column_name +FROM information_schema.COLUMN_STATISTICS; +SCHEMA_NAME TABLE_NAME COLUMN_NAME +test t1 col4 +test t1 col5 +ANALYZE TABLE t1 UPDATE HISTOGRAM ON col1, col2, col3, col4, col5 +WITH 10 BUCKETS; +Table Op Msg_type Msg_text +test.t1 histogram status Histogram statistics created for column 'col1'. +test.t1 histogram status Histogram statistics created for column 'col2'. +test.t1 histogram status Histogram statistics created for column 'col3'. +test.t1 histogram status Histogram statistics created for column 'col4'. +test.t1 histogram status Histogram statistics created for column 'col5'. +ALTER TABLE t1 MODIFY COLUMN col1 VARCHAR(255) CHARACTER SET latin1; +# col2, col3, col4 and col5 should remain +SELECT schema_name, table_name, column_name +FROM information_schema.COLUMN_STATISTICS; +SCHEMA_NAME TABLE_NAME COLUMN_NAME +test t1 col2 +test t1 col3 +test t1 col4 +test t1 col5 +DROP TABLE t1; +# +# Adding a column should not affect existing histograms +# +CREATE TABLE t1 (col1 INT); +ANALYZE TABLE t1 UPDATE HISTOGRAM ON col1 WITH 10 BUCKETS; +Table Op Msg_type Msg_text +test.t1 histogram status Histogram statistics created for column 'col1'. +SELECT schema_name, table_name, column_name +FROM information_schema.COLUMN_STATISTICS; +SCHEMA_NAME TABLE_NAME COLUMN_NAME +test t1 col1 +ALTER TABLE t1 ADD COLUMN col2 INT; +SELECT schema_name, table_name, column_name +FROM information_schema.COLUMN_STATISTICS; +SCHEMA_NAME TABLE_NAME COLUMN_NAME +test t1 col1 +# +# Dropping a column without histogram should not affect existing +# histograms +# +ALTER TABLE t1 DROP COLUMN col2; +SELECT schema_name, table_name, column_name +FROM information_schema.COLUMN_STATISTICS; +SCHEMA_NAME TABLE_NAME COLUMN_NAME +test t1 col1 +DROP TABLE t1; +# +# Column names are always case insensitive, so verify that histogram +# statistics respect this. +# +CREATE TABLE t1 (col1 INT, col2 INT); +ANALYZE TABLE t1 UPDATE HISTOGRAM ON COL1, col2 WITH 10 BUCKETS; +Table Op Msg_type Msg_text +test.t1 histogram status Histogram statistics created for column 'col1'. +test.t1 histogram status Histogram statistics created for column 'col2'. +SELECT schema_name, table_name, column_name +FROM information_schema.COLUMN_STATISTICS; +SCHEMA_NAME TABLE_NAME COLUMN_NAME +test t1 col1 +test t1 col2 +ALTER TABLE t1 DROP COLUMN COL1; +SELECT schema_name, table_name, column_name +FROM information_schema.COLUMN_STATISTICS; +SCHEMA_NAME TABLE_NAME COLUMN_NAME +test t1 col2 +DROP TABLE t1; +# +# Using ANALYZE TABLE in a prepared statement +# +CREATE TABLE t(x INT); +PREPARE ps FROM 'ANALYZE TABLE t UPDATE HISTOGRAM ON x WITH 10 BUCKETS'; +EXECUTE ps; +Table Op Msg_type Msg_text +test.t histogram status Histogram statistics created for column 'x'. +EXECUTE ps; +Table Op Msg_type Msg_text +test.t histogram status Histogram statistics created for column 'x'. +DROP TABLE t; +# +# Check that any existing histogram is removed if we add a single-part +# unique index to a column +# +CREATE TABLE t1 (col1 INT, col2 INT, col3 INT, col4 INT, col5 INT, col6 INT); +ANALYZE TABLE t1 UPDATE HISTOGRAM ON col1, col2, col3, col4, col5, col6 +WITH 4 BUCKETS; +Table Op Msg_type Msg_text +test.t1 histogram status Histogram statistics created for column 'col1'. +test.t1 histogram status Histogram statistics created for column 'col2'. +test.t1 histogram status Histogram statistics created for column 'col3'. +test.t1 histogram status Histogram statistics created for column 'col4'. +test.t1 histogram status Histogram statistics created for column 'col5'. +test.t1 histogram status Histogram statistics created for column 'col6'. +SELECT schema_name, table_name, column_name +FROM information_schema.COLUMN_STATISTICS; +SCHEMA_NAME TABLE_NAME COLUMN_NAME +test t1 col1 +test t1 col2 +test t1 col3 +test t1 col4 +test t1 col5 +test t1 col6 +ALTER TABLE t1 ADD UNIQUE INDEX (col1); +SELECT schema_name, table_name, column_name +FROM information_schema.COLUMN_STATISTICS; +SCHEMA_NAME TABLE_NAME COLUMN_NAME +test t1 col2 +test t1 col3 +test t1 col4 +test t1 col5 +test t1 col6 +ALTER TABLE t1 ADD UNIQUE INDEX (col2), ALGORITHM = INPLACE; +SELECT schema_name, table_name, column_name +FROM information_schema.COLUMN_STATISTICS; +SCHEMA_NAME TABLE_NAME COLUMN_NAME +test t1 col3 +test t1 col4 +test t1 col5 +test t1 col6 +ALTER TABLE t1 ADD UNIQUE INDEX (col3), ALGORITHM = COPY; +SELECT schema_name, table_name, column_name +FROM information_schema.COLUMN_STATISTICS; +SCHEMA_NAME TABLE_NAME COLUMN_NAME +test t1 col4 +test t1 col5 +test t1 col6 +ALTER TABLE t1 ADD PRIMARY KEY (col4); +SELECT schema_name, table_name, column_name +FROM information_schema.COLUMN_STATISTICS; +SCHEMA_NAME TABLE_NAME COLUMN_NAME +test t1 col5 +test t1 col6 +# Adding a multi-part unique index should NOT remove histograms +ALTER TABLE t1 ADD UNIQUE INDEX (col5, col6); +SELECT schema_name, table_name, column_name +FROM information_schema.COLUMN_STATISTICS; +SCHEMA_NAME TABLE_NAME COLUMN_NAME +test t1 col5 +test t1 col6 +CREATE UNIQUE INDEX index_col5 ON t1 (col5); +SELECT schema_name, table_name, column_name +FROM information_schema.COLUMN_STATISTICS; +SCHEMA_NAME TABLE_NAME COLUMN_NAME +test t1 col6 +# Adding a non-unique single part index should NOT remove histograms +CREATE INDEX index_col6 ON t1 (col6); +SELECT schema_name, table_name, column_name +FROM information_schema.COLUMN_STATISTICS; +SCHEMA_NAME TABLE_NAME COLUMN_NAME +test t1 col6 +ALTER TABLE t1 MODIFY COLUMN col6 INT UNIQUE; +SELECT schema_name, table_name, column_name +FROM information_schema.COLUMN_STATISTICS; +SCHEMA_NAME TABLE_NAME COLUMN_NAME +# Set the server in read-only mode, and verify that a histogram cannot +# be created. +SET GLOBAL read_only = 1; +ANALYZE TABLE t1 UPDATE HISTOGRAM ON col1 WITH 1024 BUCKETS; +Table Op Msg_type Msg_text + histogram Error The server is in read-only mode. +SET GLOBAL read_only = 0; +DROP TABLE t1; +# +# Bug#25841057 WL8943: ASSERTION `!TABLE || (!TABLE->READ_SET || +# BITMAP_IS_SET(TABLE->READ_SET, +# +CREATE TABLE t1 ( +c1 int(11) DEFAULT NULL, +c2 int(11) GENERATED ALWAYS AS ((c1 * 2)) VIRTUAL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +ANALYZE TABLE t1 UPDATE HISTOGRAM ON c2 WITH 2 BUCKETS; +Table Op Msg_type Msg_text +test.t1 histogram status Histogram statistics created for column 'c2'. +INSERT into t1(c1) VALUES (1); +ALTER TABLE t1 ADD UNIQUE INDEX i (c2); +ANALYZE TABLE t1 UPDATE HISTOGRAM ON c2 WITH 2 BUCKETS; +Table Op Msg_type Msg_text +test.t1 histogram Error The column 'c2' is covered by a single-part unique index. +ALTER TABLE t1 DROP KEY i; +ANALYZE TABLE t1 UPDATE HISTOGRAM ON c2 WITH 2 BUCKETS; +Table Op Msg_type Msg_text +test.t1 histogram status Histogram statistics created for column 'c2'. +DROP TABLE t1; +# +# Bug#25929588 WL8943:ASSERTION `STORED_OBJECT == NULLPTR' FAILED. +# +CREATE TABLE t1 (col1 INT); +ANALYZE TABLE t1 UPDATE HISTOGRAM ON col1 WITH 2 BUCKETS; +Table Op Msg_type Msg_text +test.t1 histogram status Histogram statistics created for column 'col1'. +ALTER TABLE t1 DROP COLUMN foobar, CHANGE COLUMN col1 col2 INT; +ERROR 42000: Can't DROP 'foobar'; check that column/key exists +SELECT schema_name, table_name, column_name +FROM information_schema.COLUMN_STATISTICS; +SCHEMA_NAME TABLE_NAME COLUMN_NAME +test t1 col1 +DROP TABLE t1; +# +# Bug#25950613 WL8943:ASSERTION `!TABLE || (!TABLE->WRITE_SET || +# BITMAP_IS_SET(TABLE->WRITE_SET +# +CREATE TABLE foo (col1 INT, +col2 INT AS (col1 + 1) VIRTUAL, +col3 INT AS (col2 + 1) VIRTUAL); +INSERT INTO foo (col1) VALUES (1); +ANALYZE TABLE foo UPDATE HISTOGRAM ON col3 WITH 10 BUCKETS; +Table Op Msg_type Msg_text +test.foo histogram status Histogram statistics created for column 'col3'. +SELECT schema_name, table_name, column_name +FROM information_schema.COLUMN_STATISTICS; +SCHEMA_NAME TABLE_NAME COLUMN_NAME +test foo col3 +DROP TABLE foo; +# +# Bug#25985106 WL8943:ASSERTION `FLOAT_COMPARE::ALMOST_EQUAL( +# CUMULATIVE_FREQUENCY + GET_NULL_V +# +CREATE TABLE t1 (col1 INT); +INSERT INTO t1 SELECT 1; +INSERT INTO t1 SELECT col1 + 1 FROM t1; +INSERT INTO t1 SELECT col1 + 2 FROM t1; +INSERT INTO t1 SELECT col1 + 4 FROM t1; +INSERT INTO t1 SELECT col1 + 8 FROM t1; +INSERT INTO t1 SELECT col1 + 16 FROM t1; +INSERT INTO t1 SELECT col1 + 32 FROM t1; +INSERT INTO t1 SELECT col1 + 64 FROM t1; +INSERT INTO t1 SELECT col1 + 128 FROM t1; +INSERT INTO t1 SELECT col1 + 256 FROM t1 LIMIT 38; +INSERT INTO t1 SELECT NULL; +ANALYZE TABLE t1 UPDATE HISTOGRAM ON col1 WITH 1024 BUCKETS; +Table Op Msg_type Msg_text +test.t1 histogram status Histogram statistics created for column 'col1'. +DROP TABLE t1; +# +# Bug#26021907 WL8943:ASSERTION `M_SCAN_VALUE == 1' FAILED. +# +CREATE TABLE p (col1 INT PRIMARY KEY, col2 INT, col3 INT) +PARTITION BY KEY (col1) PARTITIONS 4; +INSERT INTO p VALUES (1, 1, 1), (2, 2, 2), (3, 3, 3); +ANALYZE TABLE p UPDATE HISTOGRAM ON col2, col3 WITH 10 BUCKETS; +Table Op Msg_type Msg_text +test.p histogram status Histogram statistics created for column 'col2'. +test.p histogram status Histogram statistics created for column 'col3'. +SELECT schema_name, table_name, column_name, +JSON_REMOVE(histogram, '$."last-updated"') +FROM information_schema.COLUMN_STATISTICS; +SCHEMA_NAME TABLE_NAME COLUMN_NAME JSON_REMOVE(histogram, '$."last-updated"') +test p col2 {"buckets": [[1, 0.3333333333333333], [2, 0.6666666666666666], [3, 1.0]], "data-type": "int", "null-values": 0.0, "collation-id": 8, "sampling-rate": 1.0, "histogram-type": "singleton", "number-of-buckets-specified": 10} +test p col3 {"buckets": [[1, 0.3333333333333333], [2, 0.6666666666666666], [3, 1.0]], "data-type": "int", "null-values": 0.0, "collation-id": 8, "sampling-rate": 1.0, "histogram-type": "singleton", "number-of-buckets-specified": 10} +ALTER TABLE p PARTITION BY HASH (col1) PARTITIONS 2; +# Histogram statistics should still be present after a re-partitioning. +SELECT schema_name, table_name, column_name +FROM information_schema.COLUMN_STATISTICS; +SCHEMA_NAME TABLE_NAME COLUMN_NAME +test p col2 +test p col3 +# Histogram statistics should remain the same now, even though the +# partitions specification is different. +ANALYZE TABLE p UPDATE HISTOGRAM ON col2, col3 WITH 10 BUCKETS; +Table Op Msg_type Msg_text +test.p histogram status Histogram statistics created for column 'col2'. +test.p histogram status Histogram statistics created for column 'col3'. +SELECT schema_name, table_name, column_name, +JSON_REMOVE(histogram, '$."last-updated"') +FROM information_schema.COLUMN_STATISTICS; +SCHEMA_NAME TABLE_NAME COLUMN_NAME JSON_REMOVE(histogram, '$."last-updated"') +test p col2 {"buckets": [[1, 0.3333333333333333], [2, 0.6666666666666666], [3, 1.0]], "data-type": "int", "null-values": 0.0, "collation-id": 8, "sampling-rate": 1.0, "histogram-type": "singleton", "number-of-buckets-specified": 10} +test p col3 {"buckets": [[1, 0.3333333333333333], [2, 0.6666666666666666], [3, 1.0]], "data-type": "int", "null-values": 0.0, "collation-id": 8, "sampling-rate": 1.0, "histogram-type": "singleton", "number-of-buckets-specified": 10} +DROP TABLE p; +# +# Bug#26026996 WL8943:ASSERTION `MDL_CHECKER::IS_WRITE_LOCKED(M_THD, +# NEW_OBJECT)' FAILED. +# +CREATE SCHEMA foo; +CREATE SCHEMA bar; +CREATE TABLE foo.tbl (col1 INT); +ANALYZE TABLE foo.tbl UPDATE HISTOGRAM ON col1 WITH 10 BUCKETS; +Table Op Msg_type Msg_text +foo.tbl histogram status Histogram statistics created for column 'col1'. +SELECT schema_name, table_name, column_name +FROM information_schema.COLUMN_STATISTICS; +SCHEMA_NAME TABLE_NAME COLUMN_NAME +foo tbl col1 +RENAME TABLE foo.tbl TO bar.tbl2; +SELECT schema_name, table_name, column_name +FROM information_schema.COLUMN_STATISTICS; +SCHEMA_NAME TABLE_NAME COLUMN_NAME +bar tbl2 col1 +DROP SCHEMA foo; +DROP SCHEMA bar; +# +# Bug#26035995 WL8943:HISTOGRAM NOT CREATED FOR TABLE CREATED WITH +# ENCRYPTION='N' +# +# Restart the server with keyring enabled +CREATE TABLE not_encrypted1 (col1 INT) ENCRYPTION='n'; +CREATE TABLE not_encrypted2 (col1 INT) ENCRYPTION='N'; +CREATE TABLE encrypted1 (col1 INT) ENCRYPTION='y'; +CREATE TABLE encrypted2 (col1 INT) ENCRYPTION='Y'; +INSERT INTO not_encrypted1 VALUES (1); +INSERT INTO not_encrypted2 VALUES (1); +INSERT INTO encrypted1 VALUES (1); +INSERT INTO encrypted2 VALUES (1); +ANALYZE TABLE not_encrypted1 UPDATE HISTOGRAM ON col1 WITH 2 BUCKETS; +Table Op Msg_type Msg_text +test.not_encrypted1 histogram status Histogram statistics created for column 'col1'. +ANALYZE TABLE not_encrypted2 UPDATE HISTOGRAM ON col1 WITH 2 BUCKETS; +Table Op Msg_type Msg_text +test.not_encrypted2 histogram status Histogram statistics created for column 'col1'. +ANALYZE TABLE encrypted1 UPDATE HISTOGRAM ON col1 WITH 2 BUCKETS; +Table Op Msg_type Msg_text +test.encrypted1 histogram Error Cannot create histogram statistics for an encrypted table. +ANALYZE TABLE encrypted2 UPDATE HISTOGRAM ON col1 WITH 2 BUCKETS; +Table Op Msg_type Msg_text +test.encrypted2 histogram Error Cannot create histogram statistics for an encrypted table. +SELECT schema_name, table_name, column_name +FROM information_schema.COLUMN_STATISTICS; +SCHEMA_NAME TABLE_NAME COLUMN_NAME +test not_encrypted1 col1 +test not_encrypted2 col1 +# Ensure that histogram statistics are removed if we enable encryption +ALTER TABLE not_encrypted1 ENCRYPTION='y'; +ALTER TABLE not_encrypted2 ENCRYPTION='Y'; +SELECT schema_name, table_name, column_name +FROM information_schema.COLUMN_STATISTICS; +SCHEMA_NAME TABLE_NAME COLUMN_NAME +DROP TABLE encrypted1; +DROP TABLE not_encrypted1; +DROP TABLE encrypted2; +DROP TABLE not_encrypted2; +# +# Bug#26114424 WL8943:SIG11 IN DROP_HISTOGRAMS AT SQL/SQL_TABLE.CC +# +# Create a non-transactional table with a trigger. +CREATE TABLE t1 (i INT, at INT, k INT) ENGINE=InnoDB; +CREATE TRIGGER ai AFTER INSERT ON t1 FOR EACH ROW SET @a:= NEW.at; +ALTER TABLE t1 ADD PRIMARY KEY (i); +DROP TABLE t1; +# +# Bug#26303972 HISTOGRAM.CC:1169: BOOL HISTOGRAMS::DROP_ALL_HISTOGRAMS +# +CREATE TABLE ftidx_encrypted (a VARCHAR(255), FULLTEXT ftidx(a)) +ENGINE=InnoDB ENCRYPTION='N'; +ALTER TABLE ftidx_encrypted RENAME TO ftidx_encrypted_renamed, KEY_BLOCK_SIZE=0; +DROP TABLE ftidx_encrypted_renamed; +# +# Bug#26388098 WL9223: ASSERTION `DISTANCE >= 0.0' FAILED. +# +CREATE TABLE t1 ( +ten int(11) DEFAULT NULL, +twenty int(11) DEFAULT NULL, +forty int(11) DEFAULT NULL, +eighty int(11) DEFAULT NULL, +KEY idx3 (twenty,ten), +KEY idx (ten) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES +(6,16,36,76), (5,15,35,35), (9,19,39,79), (1,1,1,41), (7,17,17,17), +(3,13,33,73), (7,17,37,37), (1,1,1,1), (9,9,9,9), (0,0,20,60), (5,15,35,75), +(0,10,10,10), (3,3,3,3), (8,8,8,48), (8,18,38,38), (8,8,28,28), (3,13,33,33), +(7,7,7,7), (2,2,22,62), (0,0,0,40), (0,0,0,0), (2,12,12,52), (6,6,6,6), +(9,19,19,19), (5,15,15,15), (5,5,5,5), (5,5,25,65), (4,14,14,14), (3,3,23,23), +(4,4,4,44), (4,14,34,74), (6,6,26,26), (7,17,17,57), (7,17,17,17), (8,18,18,18), +(1,11,11,11), (4,4,4,4), (4,4,24,24), (8,18,18,18), (1,11,11,51), (7,7,27,27), +(8,8,8,8), (9,9,29,29), (7,7,7,47), (1,1,1,1), (5,5,25,25), (4,4,24,64), +(9,9,29,69), (0,10,10,10), (9,9,9,49); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +ANALYZE TABLE t1 UPDATE HISTOGRAM ON eighty WITH 40 BUCKETS; +Table Op Msg_type Msg_text +test.t1 histogram status Histogram statistics created for column 'eighty'. +EXPLAIN SELECT a.forty, b.twenty FROM t1 AS a, t1 AS b +WHERE a.twenty = b.ten AND b.eighty >= (3 + 20); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 50 60.00 Parallel execute (1 workers) +2 SIMPLE b NULL ALL idx NULL NULL NULL 50 60.00 Using where +2 SIMPLE a NULL ref idx3 idx3 5 test.b.ten 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`a`.`forty` AS `forty`,`test`.`b`.`twenty` AS `twenty` from `test`.`t1` `a` join `test`.`t1` `b` where ((`test`.`a`.`twenty` = `test`.`b`.`ten`) and (`test`.`b`.`eighty` >= ((3 + 20)))) +DROP TABLE t1; +# +# Bug#26389682 WL9223: ASSERTION `VALUE_CONVERTED <= UPPER_CONVERTED' +# FAILED. +# +CREATE TABLE `t1` ( +`two` blob, +`ten` blob, +`sixty` text, +`eighty` blob, +`tenPercent` text +) DEFAULT CHARSET=utf8mb4; +INSERT INTO `t1` VALUES +('0','6','16','76','6'), ('1','5','35','35','5'), ('1','9','19','79','9'), +('1','1','41','41','1'), ('1','7','37','17','7'), ('1','3','13','73','3'), +('1','7','37','37','7'), ('1','1','1','1','1'), ('1','9','29','9','9'), +('0','0','0','60','0'), ('1','5','15','75','5'), ('0','0','10','10','0'), +('1','3','3','3','3'), ('0','8','48','48','8'), ('0','8','38','38','8'), +('0','8','28','28','8'), ('1','3','33','33','3'), ('1','7','7','7','7'), +('0','2','2','62','2'), ('0','0','40','40','0'), ('0','0','20','0','0'), +('0','2','52','52','2'), ('0','6','26','6','6'), ('1','9','19','19','9'), +('1','5','15','15','5'), ('1','5','25','5','5'), ('1','5','5','65','5'), +('0','4','14','14','4'), ('1','3','23','23','3'), ('0','4','44','44','4'), +('0','4','14','74','4'), ('0','6','26','26','6'), ('1','7','57','57','7'), +('1','7','17','17','7'), ('0','8','18','18','8'), ('1','1','11','11','1'), +('0','4','24','4','4'), ('0','4','24','24','4'), ('0','8','38','18','8'), +('1','1','51','51','1'), ('1','7','27','27','7'), ('0','8','8','8','8'), +('1','9','29','29','9'), ('1','7','47','47','7'), ('1','1','21','1','1'), +('1','5','25','25','5'), ('0','4','4','64','4'), ('1','9','9','69','9'), +('0','0','30','10','0'), ('1','9','49','49','9'), ('0','6','36','36','6'), +('0','0','20','20','0'), ('0','2','2','2','2'), ('1','1','1','61','1'), +('0','8','28','8','8'), ('0','2','42','42','2'), ('0','2','12','72','2'), +('0','6','6','66','6'), ('1','7','7','67','7'), ('0','8','8','68','8'), +('0','4','34','14','4'), ('0','4','4','4','4'), ('0','6','6','6','6'), +('0','6','16','16','6'), ('1','7','17','77','7'), ('0','8','18','78','8'), +('0','2','22','22','2'), ('0','0','0','0','0'), ('1','9','9','9','9'), +('1','9','39','39','9'), ('1','7','27','7','7'), ('0','2','32','32','2'), +('1','1','31','11','1'), ('0','2','12','12','2'), ('0','4','54','54','4'), +('0','4','34','34','4'), ('1','1','21','21','1'), ('1','3','33','13','3'), +('0','6','56','56','6'), ('1','1','11','71','1'), ('1','3','53','53','3'), +('0','0','10','70','0'), ('0','6','36','16','6'), ('1','5','55','55','5'), +('0','2','22','2','2'), ('1','5','45','45','5'), ('1','3','43','43','3'), +('0','2','32','12','2'), ('1','1','31','31','1'), ('0','0','50','50','0'), +('1','3','13','13','3'), ('1','5','35','15','5'), ('1','9','59','59','9'), +('1','5','5','5','5'), ('0','6','46','46','6'), ('0','0','30','30','0'), +('0','8','58','58','8'), ('1','3','23','3','3'), ('1','3','3','63','3'), +('1','9','39','19','9'), ('1','3','44',NULL,'5'), ('1','7','38',NULL,'6'), +('1','1','52','64','6'), ('1','6','39',NULL,'0'), ('1','7','44','48','6'), +('0','8','42',NULL,'6'), ('0','0','7',NULL,'9'), ('1','0','45',NULL,'1'), +('1','5','40','32','0'), ('0','3','52',NULL,'3'), ('1','1','8','48','2'), +('0','3','20','16','2'), ('0','2','15',NULL,'6'), ('1','6','48','48','8'), +('0','5','31',NULL,'7'), ('0','6','20','0','4'), ('0','2','12','16','6'), +('0','4','20','64','4'), ('0','6','56','48','8'), ('0','2','40','16','4'), +('0','2','52','48','6'), ('1','9','25',NULL,'0'), ('0','0','12',NULL,'1'), +('0','1','0','64','8'), ('1','4','48','32','6'), ('1','2','0','0','4'), +('0','5','52','64','8'), ('0','8','44','48','2'), ('0','8','40','0','2'), +('0','6','8',NULL,'6'), ('1','1','24','16','6'), ('0','6','44','0','4'), +('1','1','36','0','2'), ('1','0','39',NULL,'7'), ('0','0','8','32','8'), +('0','2','16','32','0'), ('0','5','8','64','4'), ('0','9','38',NULL,'9'), +('1','7','32','48','4'), ('0','3','8','48','4'), ('1','8','32',NULL,'5'), +('1','3','12','32','0'), ('0','3','24','16','6'), ('0','3','53',NULL,'3'), +('1','6','44','32','8'), ('1','0','4','32','2'), ('1','4','4','48','8'), +('1','8','8',NULL,'5'), ('1','6','16',NULL,'2'), ('0','7','20','64','8'), +('0','2','55',NULL,'6'), ('0','8','5',NULL,'1'), ('1','9','36','48','8'), +('1','3','20','32','2'), ('0','0','56','0','6'), ('1','4','25',NULL,'2'), +('0','3','0',NULL,'9'), ('1','1','32',NULL,'5'), ('0','4','32',NULL,'0'), +('0','9','4','0','2'), ('1','9','36','64','8'), ('0','3','48','16','4'), +('0','9','12','0','0'), ('1','4','39',NULL,'6'), ('0','5','16','16','6'), +('0','2','17',NULL,'3'), ('1','9','52','0','8'), ('1','2','28',NULL,'3'), +('1','5','28','32','8'), ('1','4','0','48','8'), ('1','4','39',NULL,'7'), +('1','3','16',NULL,'6'), ('0','3','17',NULL,'4'), ('1','2','18',NULL,'9'), +('0','6','52','16','2'), ('1','1','15',NULL,'7'), ('0','5','4','64','6'), +('0','6','48','64','8'), ('0','7','56',NULL,'0'), ('1','0','28',NULL,'9'), +('0','4','40','32','8'), ('1','9','52','0','6'), ('1','4','30',NULL,'3'), +('0','8','8',NULL,'0'), ('0','6','0','64','8'), ('0','6','38',NULL,'9'), +('0','0','52','64','0'), ('0','5','39',NULL,'3'), ('0','0','52','16','0'), +('0','5','8','64','0'), ('1','1','44','16','0'), ('0','4','52',NULL,'2'), +('0','9','0',NULL,'3'), ('0','3','36','64','2'), ('0','3','52','16','8'), +('1','5','4','16','2'), ('0','9','58',NULL,'9'); +UPDATE mysql.innodb_table_stats SET n_rows = 197 +WHERE database_name = "test" AND table_name = "t1"; +ANALYZE TABLE t1 UPDATE HISTOGRAM ON tenPercent WITH 4 BUCKETS; +Table Op Msg_type Msg_text +test.t1 histogram status Histogram statistics created for column 'tenPercent'. +EXPLAIN SELECT a.two, b.eighty FROM t1 AS a,t1 AS b +WHERE a.ten = b.sixty AND b.tenPercent < (9 + (5*10)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE b NULL ALL NULL NULL NULL NULL 197 33.33 Using where +1 SIMPLE a NULL ALL NULL NULL NULL NULL 197 10.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`a`.`two` AS `two`,`test`.`b`.`eighty` AS `eighty` from `test`.`t1` `a` join `test`.`t1` `b` where ((`test`.`a`.`ten` = `test`.`b`.`sixty`) and (`test`.`b`.`tenPercent` < ((9 + (5 * 10))))) +DROP TABLE t1; +# +# Bug#26388066 WL9223:ASSERTION `FILTER >= 0.0F && FILTER <= 1.0F' FAILED +# +CREATE TABLE t1 ( +tenPercent int(11) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (6),(5),(9),(1),(7); +UPDATE mysql.innodb_table_stats SET n_rows = 5 +WHERE database_name = "test" AND table_name = "t1"; +ANALYZE TABLE t1 UPDATE HISTOGRAM ON tenPercent WITH 2 BUCKETS; +Table Op Msg_type Msg_text +test.t1 histogram status Histogram statistics created for column 'tenPercent'. +EXPLAIN SELECT b.tenPercent FROM t1 AS b WHERE b.tenPercent NOT BETWEEN 3 AND 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE b NULL ALL NULL NULL NULL NULL 5 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`b`.`tenPercent` AS `tenPercent` from `test`.`t1` `b` where (`test`.`b`.`tenPercent` not between 3 and 0) +EXPLAIN SELECT b.tenPercent FROM t1 AS b WHERE b.tenPercent BETWEEN 3 AND 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 20.00 Parallel execute (1 workers) +2 SIMPLE b NULL ALL NULL NULL NULL NULL 5 20.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`b`.`tenPercent` AS `tenPercent` from `test`.`t1` `b` where (`test`.`b`.`tenPercent` between 3 and 0) +DROP TABLE t1; +# +# Bug#26388217 WL9223: SIG 11 IN STRING::NUMCHARS | +# /SQL-COMMON/SQL_STRING.CC:680 +# +CREATE TABLE k ( +pk int(11) NOT NULL AUTO_INCREMENT, +col_varchar_255_utf8 varchar(255) CHARACTER SET utf8 DEFAULT NULL, +col_varchar_10_utf8_key varchar(10) CHARACTER SET utf8 DEFAULT NULL, +col_varchar_10_latin1 varchar(10) CHARACTER SET latin1 DEFAULT NULL, +col_varchar_255_utf8_key varchar(255) CHARACTER SET utf8 DEFAULT NULL, +col_int_key int(11) DEFAULT NULL, +col_varchar_255_latin1 varchar(255) CHARACTER SET latin1 DEFAULT NULL, +col_datetime_key datetime DEFAULT NULL, +col_date_key date DEFAULT NULL, +col_varchar_255_latin1_key varchar(255) CHARACTER SET latin1 DEFAULT NULL, +col_varchar_10_latin1_key varchar(10) CHARACTER SET latin1 DEFAULT NULL, +col_date date DEFAULT NULL, +col_int int(11) DEFAULT NULL, +col_varchar_10_utf8 varchar(10) CHARACTER SET utf8 DEFAULT NULL, +col_datetime datetime DEFAULT NULL, +PRIMARY KEY (pk), +KEY col_varchar_10_utf8_key (col_varchar_10_utf8_key), +KEY col_varchar_255_utf8_key (col_varchar_255_utf8_key), +KEY col_int_key (col_int_key), +KEY col_datetime_key (col_datetime_key), +KEY col_date_key (col_date_key), +KEY col_varchar_255_latin1_key (col_varchar_255_latin1_key), +KEY col_varchar_10_latin1_key (col_varchar_10_latin1_key) +) ENGINE=InnoDB AUTO_INCREMENT=51 DEFAULT CHARSET=utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO k VALUES (1, +'wrhhsy', +'rhgpwcrafs', +'hgpwcrafsb', +'i', +NULL, +'gpwcrafsbt', +'1000-01-01 00:00:00', +'1000-01-01', +'n', +'LUWOS', +'1000-01-01', +NULL, +'pwcrafsbtn', +'2002-08-22 03:35:28'); +CREATE TABLE a ( +col_datetime_key datetime DEFAULT NULL, +col_datetime datetime DEFAULT NULL, +col_varchar_10_utf8_key varchar(10) CHARACTER SET utf8 DEFAULT NULL, +col_varchar_255_latin1 varchar(255) CHARACTER SET latin1 DEFAULT NULL, +col_varchar_10_latin1_key varchar(10) CHARACTER SET latin1 DEFAULT NULL, +col_varchar_10_latin1 varchar(10) CHARACTER SET latin1 DEFAULT NULL, +col_varchar_10_utf8 varchar(10) CHARACTER SET utf8 DEFAULT NULL, +pk int(11) NOT NULL AUTO_INCREMENT, +col_varchar_255_utf8_key varchar(255) CHARACTER SET utf8 DEFAULT NULL, +col_date date DEFAULT NULL, +col_int_key int(11) DEFAULT NULL, +col_date_key date DEFAULT NULL, +col_int int(11) DEFAULT NULL, +col_varchar_255_utf8 varchar(255) CHARACTER SET utf8 DEFAULT NULL, +col_varchar_255_latin1_key varchar(255) CHARACTER SET latin1 DEFAULT NULL, +PRIMARY KEY (pk), +KEY col_datetime_key (col_datetime_key), +KEY col_varchar_10_utf8_key (col_varchar_10_utf8_key), +KEY col_varchar_10_latin1_key (col_varchar_10_latin1_key), +KEY col_varchar_255_utf8_key (col_varchar_255_utf8_key), +KEY col_int_key (col_int_key), +KEY col_date_key (col_date_key), +KEY col_varchar_255_latin1_key (col_varchar_255_latin1_key) +) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO a VALUES (NULL, +'2008-10-25 07:07:49', +'BXLIC', +'GSDDY', +'w', +'crbhsozfbh', +'s', +1, +'the', +'2005-04-01', +104529920, +'1000-01-01', +NULL, +'like', +'CGLFP'); +CREATE TABLE g ( +col_varchar_10_latin1 varchar(10) CHARACTER SET latin1 DEFAULT NULL, +col_datetime datetime DEFAULT NULL, +col_varchar_255_latin1_key varchar(255) CHARACTER SET latin1 DEFAULT NULL, +col_varchar_10_utf8 varchar(10) CHARACTER SET utf8 DEFAULT NULL, +col_varchar_255_latin1 varchar(255) CHARACTER SET latin1 DEFAULT NULL, +col_varchar_255_utf8 varchar(255) CHARACTER SET utf8 DEFAULT NULL, +col_date_key date DEFAULT NULL, +col_date date DEFAULT NULL, +col_int_key int(11) DEFAULT NULL, +col_int int(11) DEFAULT NULL, +col_varchar_10_utf8_key varchar(10) CHARACTER SET utf8 DEFAULT NULL, +col_varchar_10_latin1_key varchar(10) CHARACTER SET latin1 DEFAULT NULL, +pk int(11) NOT NULL AUTO_INCREMENT, +col_varchar_255_utf8_key varchar(255) CHARACTER SET utf8 DEFAULT NULL, +col_datetime_key datetime DEFAULT NULL, +PRIMARY KEY (pk), +KEY col_varchar_255_latin1_key (col_varchar_255_latin1_key), +KEY col_date_key (col_date_key), +KEY col_int_key (col_int_key), +KEY col_varchar_10_utf8_key (col_varchar_10_utf8_key), +KEY col_varchar_10_latin1_key (col_varchar_10_latin1_key), +KEY col_varchar_255_utf8_key (col_varchar_255_utf8_key), +KEY col_datetime_key (col_datetime_key) +) ENGINE=InnoDB AUTO_INCREMENT=21 DEFAULT CHARSET=utf8mb4; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO g VALUES ('o', +'2009-05-15 00:00:00', +'PFJGE', +'ASUNU', +'yj', +'if', +'1000-01-01', +'2001-04-06', +4, +-1442512896, +'m', +'his', +1, +'I', +'2007-05-11 00:00:00'); +ANALYZE TABLE g UPDATE HISTOGRAM ON col_varchar_10_utf8 WITH 250 BUCKETS; +Table Op Msg_type Msg_text +test.g histogram status Histogram statistics created for column 'col_varchar_10_utf8'. +EXPLAIN SELECT alias1 . col_date_key AS field1 FROM k AS alias1 +LEFT OUTER JOIN a AS alias2 +RIGHT OUTER JOIN g AS alias3 ON alias2 . col_varchar_255_utf8_key = alias3 . col_varchar_10_utf8 +ON alias1 . col_varchar_10_latin1 = alias3 . col_varchar_255_latin1 +LEFT OUTER JOIN g AS alias4 ON alias1 . col_varchar_255_utf8_key = alias4 . col_varchar_255_utf8_key +WHERE alias2 . pk = 3 ORDER BY field1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`alias1`.`col_date_key` AS `field1` from `test`.`k` `alias1` join `test`.`g` `alias3` join `test`.`a` `alias2` left join `test`.`g` `alias4` on(multiple equal(`test`.`alias1`.`col_varchar_255_utf8_key`, `test`.`alias4`.`col_varchar_255_utf8_key`)) where ((NULL = `test`.`alias3`.`col_varchar_10_utf8`) and (`test`.`alias1`.`col_varchar_10_latin1` = `test`.`alias3`.`col_varchar_255_latin1`) and multiple equal(3, NULL)) order by `field1` +DROP TABLE a, k, g; +# +# Bug#26495045 WL9223:ASSERTION `FILTER >= 0.0F && FILTER <= 1.0F' FAILED. +# +CREATE TABLE t1 (col1 INT); +INSERT INTO t1 VALUES (1), (2), (3); +ANALYZE TABLE t1 UPDATE HISTOGRAM ON col1 WITH 1 BUCKETS; +Table Op Msg_type Msg_text +test.t1 histogram status Histogram statistics created for column 'col1'. +UPDATE mysql.innodb_table_stats SET n_rows = 3 +WHERE database_name = "test" AND table_name = "t1"; +EXPLAIN SELECT * FROM t1 WHERE col1 <= 3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col1` AS `col1` from `test`.`t1` where (`test`.`t1`.`col1` <= 3) +DROP TABLE t1; +# +# Bug#26542689 WL9223: VIRTUAL LONGLONG +# ITEM_TIME_WITH_REF::VAL_DATE_TEMPORAL(): ASSERTION `0' +# +CREATE TABLE table1 ( +col_datetime_key datetime DEFAULT NULL, +col_datetime datetime DEFAULT NULL, +pk int(11) NOT NULL AUTO_INCREMENT, +col_date date DEFAULT NULL, +col_time time DEFAULT NULL, +col_varchar varchar(1) DEFAULT NULL, +col_int_key int(11) DEFAULT NULL, +col_blob_key blob, +col_time_key time DEFAULT NULL, +col_int int(11) DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_date_key date DEFAULT NULL, +col_blob blob, +PRIMARY KEY (pk), +KEY col_datetime_key (col_datetime_key), +KEY col_int_key (col_int_key), +KEY col_blob_key (col_blob_key(255)), +KEY col_time_key (col_time_key), +KEY col_varchar_key (col_varchar_key), +KEY col_date_key (col_date_key), +KEY test_idx (col_int_key,col_int) +) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO table1 VALUES ('2000-09-05 00:00:00', +'2003-11-25 11:17:04', +1, +'2006-02-27', +'00:20:06', +'l', +1, +'uajnlnsnzyo', +'23:18:41', +7, +'a', +'2001-02-18', +'jn'); +ANALYZE TABLE table1 UPDATE HISTOGRAM ON col_varchar WITH 1 BUCKETS; +Table Op Msg_type Msg_text +test.table1 histogram status Histogram statistics created for column 'col_varchar'. +ANALYZE TABLE table1 UPDATE HISTOGRAM ON col_datetime WITH 20 BUCKETS; +Table Op Msg_type Msg_text +test.table1 histogram status Histogram statistics created for column 'col_datetime'. +ANALYZE TABLE table1 UPDATE HISTOGRAM ON col_time WITH 2 BUCKETS; +Table Op Msg_type Msg_text +test.table1 histogram status Histogram statistics created for column 'col_time'. +ANALYZE TABLE table1 UPDATE HISTOGRAM ON col_datetime_key WITH 20 BUCKETS; +Table Op Msg_type Msg_text +test.table1 histogram status Histogram statistics created for column 'col_datetime_key'. +ANALYZE TABLE table1 UPDATE HISTOGRAM ON col_date_key WITH 60 BUCKETS; +Table Op Msg_type Msg_text +test.table1 histogram status Histogram statistics created for column 'col_date_key'. +ANALYZE TABLE table1 UPDATE HISTOGRAM ON col_blob WITH 1023 BUCKETS; +Table Op Msg_type Msg_text +test.table1 histogram status Histogram statistics created for column 'col_blob'. +ANALYZE TABLE table1 UPDATE HISTOGRAM ON col_int_key WITH 1023 BUCKETS; +Table Op Msg_type Msg_text +test.table1 histogram status Histogram statistics created for column 'col_int_key'. +ANALYZE TABLE table1 UPDATE HISTOGRAM ON col_date WITH 2 BUCKETS; +Table Op Msg_type Msg_text +test.table1 histogram status Histogram statistics created for column 'col_date'. +ANALYZE TABLE table1 UPDATE HISTOGRAM ON col_int WITH 1000 BUCKETS; +Table Op Msg_type Msg_text +test.table1 histogram status Histogram statistics created for column 'col_int'. +ANALYZE TABLE table1 UPDATE HISTOGRAM ON col_blob_key WITH 60 BUCKETS; +Table Op Msg_type Msg_text +test.table1 histogram status Histogram statistics created for column 'col_blob_key'. +CREATE TABLE table2 ( +col_time_key time DEFAULT NULL, +col_blob_key blob, +col_int int(11) DEFAULT NULL, +col_datetime_key datetime DEFAULT NULL, +col_varchar varchar(1) DEFAULT NULL, +col_date date DEFAULT NULL, +col_time time DEFAULT NULL, +col_blob blob, +col_date_key date DEFAULT NULL, +col_int_key int(11) DEFAULT NULL, +pk int(11) NOT NULL AUTO_INCREMENT, +col_varchar_key varchar(1) DEFAULT NULL, +col_datetime datetime DEFAULT NULL, +PRIMARY KEY (pk), +KEY col_time_key (col_time_key), +KEY col_blob_key (col_blob_key(255)), +KEY col_datetime_key (col_datetime_key), +KEY col_date_key (col_date_key), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key), +KEY test_idx (col_int_key,pk) +) ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO table2 VALUES ('10:39:59', +'tymjpskqjjap', +9, +'2006-07-17 08:29:28', +'y', +'2002-10-02', +'00:20:00', +'mjpskqjjapldefot', +'2008-11-12', +3, +1, +NULL, +'2009-03-19 00:00:00'); +ANALYZE TABLE table2 UPDATE HISTOGRAM ON col_blob_key WITH 4 BUCKETS; +Table Op Msg_type Msg_text +test.table2 histogram status Histogram statistics created for column 'col_blob_key'. +ANALYZE TABLE table2 UPDATE HISTOGRAM ON col_date WITH 40 BUCKETS; +Table Op Msg_type Msg_text +test.table2 histogram status Histogram statistics created for column 'col_date'. +ANALYZE TABLE table2 UPDATE HISTOGRAM ON col_blob WITH 20 BUCKETS; +Table Op Msg_type Msg_text +test.table2 histogram status Histogram statistics created for column 'col_blob'. +ANALYZE TABLE table2 UPDATE HISTOGRAM ON col_int WITH 1 BUCKETS; +Table Op Msg_type Msg_text +test.table2 histogram status Histogram statistics created for column 'col_int'. +ANALYZE TABLE table2 UPDATE HISTOGRAM ON col_datetime_key WITH 20 BUCKETS; +Table Op Msg_type Msg_text +test.table2 histogram status Histogram statistics created for column 'col_datetime_key'. +ANALYZE TABLE table2 UPDATE HISTOGRAM ON col_int_key WITH 2 BUCKETS; +Table Op Msg_type Msg_text +test.table2 histogram status Histogram statistics created for column 'col_int_key'. +ANALYZE TABLE table2 UPDATE HISTOGRAM ON col_time WITH 60 BUCKETS; +Table Op Msg_type Msg_text +test.table2 histogram status Histogram statistics created for column 'col_time'. +ANALYZE TABLE table2 UPDATE HISTOGRAM ON col_varchar WITH 60 BUCKETS; +Table Op Msg_type Msg_text +test.table2 histogram status Histogram statistics created for column 'col_varchar'. +CREATE TABLE table3 ( +col_int_key int(11) DEFAULT NULL, +col_datetime datetime DEFAULT NULL, +pk int(11) NOT NULL AUTO_INCREMENT, +col_datetime_key datetime DEFAULT NULL, +col_blob blob, +col_blob_key blob, +col_int int(11) DEFAULT NULL, +col_time time DEFAULT NULL, +col_varchar varchar(1) DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_time_key time DEFAULT NULL, +col_date_key date DEFAULT NULL, +col_date date DEFAULT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_datetime_key (col_datetime_key), +KEY col_blob_key (col_blob_key(255)), +KEY col_varchar_key (col_varchar_key), +KEY col_time_key (col_time_key), +KEY col_date_key (col_date_key) +) ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO table3 VALUES (6, +'2003-08-27 00:00:00', +1, +'2002-07-10 12:41:35', +NULL, +'xgtmzjkhjqplanraxafy', +5, +'05:20:53', +'q', +'g', +'00:30:27', +'2008-11-18', +'2008-05-26'); +ANALYZE TABLE table3 UPDATE HISTOGRAM ON col_date_key WITH 2 BUCKETS; +Table Op Msg_type Msg_text +test.table3 histogram status Histogram statistics created for column 'col_date_key'. +ANALYZE TABLE table3 UPDATE HISTOGRAM ON col_time_key WITH 1024 BUCKETS; +Table Op Msg_type Msg_text +test.table3 histogram status Histogram statistics created for column 'col_time_key'. +ANALYZE TABLE table3 UPDATE HISTOGRAM ON col_date WITH 10 BUCKETS; +Table Op Msg_type Msg_text +test.table3 histogram status Histogram statistics created for column 'col_date'. +ANALYZE TABLE table3 UPDATE HISTOGRAM ON col_datetime_key WITH 1024 BUCKETS; +Table Op Msg_type Msg_text +test.table3 histogram status Histogram statistics created for column 'col_datetime_key'. +ANALYZE TABLE table3 UPDATE HISTOGRAM ON col_blob_key WITH 20 BUCKETS; +Table Op Msg_type Msg_text +test.table3 histogram status Histogram statistics created for column 'col_blob_key'. +ANALYZE TABLE table3 UPDATE HISTOGRAM ON col_blob WITH 10 BUCKETS; +Table Op Msg_type Msg_text +test.table3 histogram status Histogram statistics created for column 'col_blob'. +ANALYZE TABLE table3 UPDATE HISTOGRAM ON col_time WITH 10 BUCKETS; +Table Op Msg_type Msg_text +test.table3 histogram status Histogram statistics created for column 'col_time'. +ANALYZE TABLE table3 UPDATE HISTOGRAM ON col_int WITH 1000 BUCKETS; +Table Op Msg_type Msg_text +test.table3 histogram status Histogram statistics created for column 'col_int'. +ANALYZE TABLE table3 UPDATE HISTOGRAM ON col_varchar WITH 2 BUCKETS; +Table Op Msg_type Msg_text +test.table3 histogram status Histogram statistics created for column 'col_varchar'. +ANALYZE TABLE table3 UPDATE HISTOGRAM ON col_varchar_key WITH 4 BUCKETS; +Table Op Msg_type Msg_text +test.table3 histogram status Histogram statistics created for column 'col_varchar_key'. +ANALYZE TABLE table3 UPDATE HISTOGRAM ON col_datetime WITH 2 BUCKETS; +Table Op Msg_type Msg_text +test.table3 histogram status Histogram statistics created for column 'col_datetime'. +CREATE TABLE table4 ( +col_datetime datetime DEFAULT NULL, +col_time time DEFAULT NULL, +col_time_key time DEFAULT NULL, +col_varchar varchar(1) DEFAULT NULL, +col_int_key int(11) DEFAULT NULL, +col_date date DEFAULT NULL, +col_int int(11) DEFAULT NULL, +col_blob blob, +col_blob_key blob, +col_varchar_key varchar(1) DEFAULT NULL, +col_date_key date DEFAULT NULL, +pk int(11) NOT NULL AUTO_INCREMENT, +col_datetime_key datetime DEFAULT NULL, +PRIMARY KEY (pk), +KEY col_time_key (col_time_key), +KEY col_int_key (col_int_key), +KEY col_blob_key (col_blob_key(255)), +KEY col_varchar_key (col_varchar_key), +KEY col_date_key (col_date_key), +KEY col_datetime_key (col_datetime_key), +KEY test_idx (pk,col_int_key) +) ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO table4 VALUES ('2009-05-17 00:00:00', +'00:20:03', +'00:20:04', +'u', +6, +'2008-02-12', +0, +'orecqsomotqciisj', +'recqsomotqciisjzx', +'e', +'2005-03-21', +1, +'2009-11-16 02:30:22'); +ANALYZE TABLE table4 UPDATE HISTOGRAM ON col_time_key WITH 100 BUCKETS; +Table Op Msg_type Msg_text +test.table4 histogram status Histogram statistics created for column 'col_time_key'. +ANALYZE TABLE table4 UPDATE HISTOGRAM ON col_date WITH 4 BUCKETS; +Table Op Msg_type Msg_text +test.table4 histogram status Histogram statistics created for column 'col_date'. +ANALYZE TABLE table4 UPDATE HISTOGRAM ON col_datetime_key WITH 4 BUCKETS; +Table Op Msg_type Msg_text +test.table4 histogram status Histogram statistics created for column 'col_datetime_key'. +ANALYZE TABLE table4 UPDATE HISTOGRAM ON col_int_key WITH 1024 BUCKETS; +Table Op Msg_type Msg_text +test.table4 histogram status Histogram statistics created for column 'col_int_key'. +ANALYZE TABLE table4 UPDATE HISTOGRAM ON col_blob WITH 60 BUCKETS; +Table Op Msg_type Msg_text +test.table4 histogram status Histogram statistics created for column 'col_blob'. +ANALYZE TABLE table4 UPDATE HISTOGRAM ON col_time WITH 100 BUCKETS; +Table Op Msg_type Msg_text +test.table4 histogram status Histogram statistics created for column 'col_time'. +ANALYZE TABLE table4 UPDATE HISTOGRAM ON col_varchar_key WITH 1024 BUCKETS; +Table Op Msg_type Msg_text +test.table4 histogram status Histogram statistics created for column 'col_varchar_key'. +ANALYZE TABLE table4 UPDATE HISTOGRAM ON col_int WITH 4 BUCKETS; +Table Op Msg_type Msg_text +test.table4 histogram status Histogram statistics created for column 'col_int'. +ANALYZE TABLE table4 UPDATE HISTOGRAM ON col_blob_key WITH 80 BUCKETS; +Table Op Msg_type Msg_text +test.table4 histogram status Histogram statistics created for column 'col_blob_key'. +ANALYZE TABLE table4 UPDATE HISTOGRAM ON col_varchar WITH 1024 BUCKETS; +Table Op Msg_type Msg_text +test.table4 histogram status Histogram statistics created for column 'col_varchar'. +ANALYZE TABLE table4 UPDATE HISTOGRAM ON col_date_key WITH 4 BUCKETS; +Table Op Msg_type Msg_text +test.table4 histogram status Histogram statistics created for column 'col_date_key'. +CREATE VIEW view_BB AS SELECT * FROM table2; +CREATE VIEW view_A AS SELECT * FROM table1; +WITH cte AS ( +SELECT alias2 . col_time AS field1 +FROM view_BB AS alias1 LEFT JOIN view_A AS alias2 +ON alias1 . col_varchar = alias2 . col_varchar_key +WHERE alias2 . col_int_key > 2 AND alias2 . col_int_key < ( 5 + 1 ) +ORDER BY field1 +LIMIT 1000 OFFSET 35) +UPDATE table3 AS OUTR1, table4 AS OUTR2, cte AS OUTRcte, cte AS OUTRcte1 +SET OUTR1.col_varchar_key = 'hey' +WHERE OUTRcte . field1 <> 3; +DROP VIEW view_BB, view_A; +DROP TABLE table1, table2, table3, table4; +# Inverted BETWEEN predicate (lower bound is higher/greater than the +# upper bound) +CREATE TABLE t1 (col1 INT); +INSERT INTO t1 VALUES (1), (2), (3), (4), (5); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +ANALYZE TABLE t1 UPDATE HISTOGRAM ON col1 WITH 64 BUCKETS; +Table Op Msg_type Msg_text +test.t1 histogram status Histogram statistics created for column 'col1'. +EXPLAIN SELECT * FROM t1 WHERE col1 BETWEEN 4 AND 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 20.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 20.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col1` AS `col1` from `test`.`t1` where (`test`.`t1`.`col1` between 4 and 2) +EXPLAIN SELECT * FROM t1 WHERE col1 NOT BETWEEN 4 AND 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col1` AS `col1` from `test`.`t1` where (`test`.`t1`.`col1` not between 4 and 2) +DROP TABLE t1; +# +# Bug#26555815 WL9223: ASSERTION `DISTANCE >= 0.0' FAILED. +# +CREATE TABLE t1 (col1 BIGINT); +INSERT INTO t1 VALUES (-8454100925504552960), (-3300857051885862912), (0), (0), +(0), (0), (0), (2), (2), (2), (6), (16), (56), (86), (142), (191), (7294), +(16729), (22243), (23035), (23731), (23807), (39158), (51338), +(762515711909167104), (1976517286462226432), (5793317970658721792), +(6453095316068499456), (7648519542158655488), (8601593813300936704); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +ANALYZE TABLE t1 UPDATE HISTOGRAM ON col1 WITH 1 BUCKETS; +Table Op Msg_type Msg_text +test.t1 histogram status Histogram statistics created for column 'col1'. +EXPLAIN SELECT * FROM t1 WHERE col1 <= 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 30 49.57 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 30 49.57 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col1` AS `col1` from `test`.`t1` where (`test`.`t1`.`col1` <= 0) +DROP TABLE t1; +# +# Bug#26570230 WL9223: ASSERTION `FILTER >= 0.0F && FILTER <= 1.0F' +# FAILED. +# +CREATE TABLE t1 (col1 VARCHAR(255)); +INSERT INTO t1 VALUES ("c"), ("f"), ("get"), ("going"), ("look"), ("MOZVN"), +("n"), ("NJAOC"), ("o"), ("on"), ("qnqzklkafp"), ("say"), ("sckaeiqnqz"), +("the"), ("there"), ("VXPRU"), ("w"), ("WBQDQ"), ("your"), ("ZHZXW"); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +ANALYZE TABLE t1 UPDATE HISTOGRAM ON col1 WITH 4 BUCKETS; +Table Op Msg_type Msg_text +test.t1 histogram status Histogram statistics created for column 'col1'. +EXPLAIN SELECT * FROM t1 WHERE col1 BETWEEN 'b' AND 'z'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 20 99.95 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 20 99.95 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col1` AS `col1` from `test`.`t1` where (`test`.`t1`.`col1` between 'b' and 'z') +DROP TABLE t1; +# Test that histogram data is updated in a multi-connection setup +CREATE TABLE t1 (col1 INT); +INSERT INTO t1 VALUES (1), (2), (3); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +ANALYZE TABLE t1 UPDATE HISTOGRAM ON col1 WITH 128 BUCKETS; +Table Op Msg_type Msg_text +test.t1 histogram status Histogram statistics created for column 'col1'. +# This should give a very low estimate, since no rows matches this +# condition +EXPLAIN SELECT * FROM t1 WHERE col1 > 3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col1` AS `col1` from `test`.`t1` where (`test`.`t1`.`col1` > 3) +DELETE FROM t1; +INSERT INTO t1 VALUES (4), (5), (6); +# This should give the same estimate as earlier, since we haven't updated +# the histogram statistics. +EXPLAIN SELECT * FROM t1 WHERE col1 > 3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col1` AS `col1` from `test`.`t1` where (`test`.`t1`.`col1` > 3) +ANALYZE TABLE t1 UPDATE HISTOGRAM ON col1 WITH 128 BUCKETS; +Table Op Msg_type Msg_text +test.t1 histogram status Histogram statistics created for column 'col1'. +# Now we should see a very high estimate, since all rows matches this +# condition. +EXPLAIN SELECT * FROM t1 WHERE col1 > 3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col1` AS `col1` from `test`.`t1` where (`test`.`t1`.`col1` > 3) +DROP TABLE t1; +# +# Bug#26621664 WL9223:ASSERTION `DISTANCE <= 1.0' FAILED. +# +SET @@SESSION.sql_mode=''; +CREATE TABLE t1 ( +pk int(11) NOT NULL AUTO_INCREMENT, +col_int int(11) NOT NULL, +col_int_key int(11) GENERATED ALWAYS AS ((col_int + col_int)) VIRTUAL, +col_date date NOT NULL, +col_date_key date GENERATED ALWAYS AS ((col_date + interval 30 day)) +VIRTUAL, +col_datetime datetime NOT NULL, +col_time time NOT NULL, +col_datetime_key datetime GENERATED ALWAYS AS +(addtime(col_datetime,col_time)) VIRTUAL, +col_time_key time GENERATED ALWAYS AS (addtime(col_datetime,col_time)) +VIRTUAL, +col_varchar varchar(1) NOT NULL, +col_varchar_key varchar(2) GENERATED ALWAYS AS +(concat(col_varchar,col_varchar)) VIRTUAL, +PRIMARY KEY (pk), +KEY col_date_key (col_date_key) +) ENGINE=InnoDB AUTO_INCREMENT=30 DEFAULT CHARSET=utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 (pk, col_int, col_date, col_datetime, col_time, col_varchar) +VALUES (10,8,'2006-08-19','2001-07-04 +14:30:59','23:33:39','v'),(11,8,'2006-08-13','2006-12-15 +06:22:01','11:50:10','j'),(12,9,'2008-05-12','2002-06-19 +14:43:00','07:14:03','h'),(13,0,'2003-07-05','2005-08-19 +04:46:53','18:13:22','q'),(14,1,'2003-10-21','2007-05-14 +06:19:04','00:00:00','g'),(29,1,'2008-12-24','2004-04-02 +07:16:01','16:30:10','e'); +ANALYZE TABLE t1 UPDATE HISTOGRAM ON col_time WITH 4 BUCKETS; +Table Op Msg_type Msg_text +test.t1 histogram status Histogram statistics created for column 'col_time'. +ANALYZE TABLE t1 UPDATE HISTOGRAM ON col_time_key WITH 1024 BUCKETS; +Table Op Msg_type Msg_text +test.t1 histogram status Histogram statistics created for column 'col_time_key'. +ANALYZE TABLE t1 UPDATE HISTOGRAM ON col_varchar_key WITH 1023 BUCKETS; +Table Op Msg_type Msg_text +test.t1 histogram status Histogram statistics created for column 'col_varchar_key'. +ANALYZE TABLE t1 UPDATE HISTOGRAM ON col_datetime_key WITH 2 BUCKETS; +Table Op Msg_type Msg_text +test.t1 histogram status Histogram statistics created for column 'col_datetime_key'. +ANALYZE TABLE t1 UPDATE HISTOGRAM ON col_int WITH 40 BUCKETS; +Table Op Msg_type Msg_text +test.t1 histogram status Histogram statistics created for column 'col_int'. +ANALYZE TABLE t1 UPDATE HISTOGRAM ON col_date_key WITH 80 BUCKETS; +Table Op Msg_type Msg_text +test.t1 histogram status Histogram statistics created for column 'col_date_key'. +ANALYZE TABLE t1 UPDATE HISTOGRAM ON col_datetime WITH 40 BUCKETS; +Table Op Msg_type Msg_text +test.t1 histogram status Histogram statistics created for column 'col_datetime'. +CREATE TABLE t2 ( +pk int(11) NOT NULL AUTO_INCREMENT, +col_int int(11) NOT NULL, +col_int_key int(11) GENERATED ALWAYS AS ((col_int + col_int)) VIRTUAL, +col_date date NOT NULL, +col_date_key date GENERATED ALWAYS AS ((col_date + interval 30 day)) +VIRTUAL, +col_datetime datetime NOT NULL, +col_time time NOT NULL, +col_datetime_key datetime GENERATED ALWAYS AS +(addtime(col_datetime,col_time)) VIRTUAL, +col_time_key time GENERATED ALWAYS AS (addtime(col_datetime,col_time)) +VIRTUAL, +col_varchar varchar(1) NOT NULL, +col_varchar_key varchar(2) GENERATED ALWAYS AS +(concat(col_varchar,col_varchar)) VIRTUAL, +PRIMARY KEY (pk), +KEY col_date_key (col_date_key) +) ENGINE=InnoDB AUTO_INCREMENT=21 DEFAULT CHARSET=utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 (pk, col_int, col_date, col_datetime, col_time, col_varchar) +VALUES (1,2,'2002-10-13','1900-01-01 +00:00:00','00:00:00','s'),(2,4,'1900-01-01','2005-08-15 +00:00:00','15:57:25','r'),(3,8,'0000-00-00','1900-01-01 +00:00:00','07:05:51','m'),(4,4,'2006-03-09','2008-05-16 +08:09:06','19:22:21','b'),(5,4,'2001-06-05','2001-01-20 +12:47:23','03:53:16','x'),(6,7,'2006-05-28','2008-07-02 +00:00:00','09:16:38','g'),(7,4,'2001-04-19','1900-01-01 +00:00:00','15:37:26','p'),(8,1,'1900-01-01','2002-12-08 +11:34:58','00:00:00','q'),(9,9,'2004-08-20','1900-01-01 +00:00:00','05:03:03','w'),(10,4,'2004-10-10','1900-01-01 +00:00:00','02:59:24','d'),(11,8,'2000-04-02','2002-08-25 +20:35:06','00:01:58','e'),(12,4,'2006-11-02','2001-10-22 +11:13:24','00:00:00','b'),(13,8,'2009-01-28','2003-03-12 +02:00:34','02:20:16','y'),(14,0,'2005-04-19','2007-04-10 +12:16:04','04:59:50','p'),(15,0,'2006-08-12','2009-11-07 +00:00:00','21:14:04','f'),(16,0,'2005-03-12','2003-12-04 +11:14:26','00:00:00','p'),(17,7,'1900-01-01','2006-09-11 +18:25:21','12:59:27','d'),(18,7,'1900-01-01','1900-01-01 +00:00:00','16:39:36','f'),(19,5,'0000-00-00','2001-07-25 +08:40:24','00:00:00','j'),(20,3,'2007-09-09','2009-06-07 +13:48:58','00:00:00','e'); +ANALYZE TABLE t2 UPDATE HISTOGRAM ON col_int WITH 4 BUCKETS; +Table Op Msg_type Msg_text +test.t2 histogram status Histogram statistics created for column 'col_int'. +ANALYZE TABLE t2 UPDATE HISTOGRAM ON col_time_key WITH 1 BUCKETS; +Table Op Msg_type Msg_text +test.t2 histogram status Histogram statistics created for column 'col_time_key'. +ANALYZE TABLE t2 UPDATE HISTOGRAM ON col_datetime_key WITH 10 BUCKETS; +Table Op Msg_type Msg_text +test.t2 histogram status Histogram statistics created for column 'col_datetime_key'. +ANALYZE TABLE t2 UPDATE HISTOGRAM ON col_datetime WITH 100 BUCKETS; +Table Op Msg_type Msg_text +test.t2 histogram status Histogram statistics created for column 'col_datetime'. +ANALYZE TABLE t2 UPDATE HISTOGRAM ON col_date_key WITH 2 BUCKETS; +Table Op Msg_type Msg_text +test.t2 histogram status Histogram statistics created for column 'col_date_key'. +ANALYZE TABLE t2 UPDATE HISTOGRAM ON col_varchar WITH 1023 BUCKETS; +Table Op Msg_type Msg_text +test.t2 histogram status Histogram statistics created for column 'col_varchar'. +ANALYZE TABLE t2 UPDATE HISTOGRAM ON col_int_key WITH 4 BUCKETS; +Table Op Msg_type Msg_text +test.t2 histogram status Histogram statistics created for column 'col_int_key'. +ANALYZE TABLE t2 UPDATE HISTOGRAM ON col_time WITH 4 BUCKETS; +Table Op Msg_type Msg_text +test.t2 histogram status Histogram statistics created for column 'col_time'. +SELECT STD( OUTR . pk ) AS x +FROM t2 AS OUTR2 LEFT JOIN t2 AS OUTR +ON ( OUTR2 . col_datetime_key >= OUTR . col_datetime_key ) +WHERE OUTR . col_int IN ( +SELECT DISTINCT INNR . col_int_key AS y +FROM t1 AS INNR2 LEFT JOIN t1 AS INNR +ON ( INNR2 . col_varchar_key > INNR . col_varchar_key ) +WHERE INNR . col_varchar_key IS NOT NULL +AND NOT OUTR . pk <> 7 ) +AND OUTR . col_varchar_key IS NULL +HAVING x <= 3 +ORDER BY OUTR . pk , OUTR . pk; +x +DROP TABLE t1, t2; +SET @@SESSION.sql_mode=DEFAULT; +# +# Bug#26634098 WL9223:ASSERTION `(*REF)->IS_TEMPORAL()' FAILED. +# +CREATE TABLE t1 ( +pk int(11) NOT NULL AUTO_INCREMENT, +col_int int(11) DEFAULT NULL, +col_int_key int(11) GENERATED ALWAYS AS ((col_int + col_int)) VIRTUAL, +col_date date DEFAULT NULL, +col_date_key date GENERATED ALWAYS AS ((col_date + interval 30 day)) VIRTUAL, +col_datetime datetime DEFAULT NULL, +col_time time DEFAULT NULL, +col_datetime_key datetime GENERATED ALWAYS AS (addtime(col_datetime,col_time)) VIRTUAL, +col_time_key time GENERATED ALWAYS AS (addtime(col_datetime,col_time)) VIRTUAL, +col_varchar varchar(1) DEFAULT NULL, +col_varchar_key varchar(2) GENERATED ALWAYS AS (concat(col_varchar,col_varchar)) VIRTUAL, +PRIMARY KEY (pk), +KEY col_date_key (col_date_key) /*!80000 INVISIBLE */ +) ENGINE=InnoDB AUTO_INCREMENT=20 DEFAULT CHARSET=utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 (pk, col_int, col_date, col_datetime, col_time, col_varchar) VALUES +(10,3,'2007-02-04','2006-02-10 18:41:38',NULL,'t'), +(11,48,'1900-01-01','2009-02-16 14:58:58',NULL,'d'), +(12,8,'2001-03-14','2007-08-14 00:00:00','23:28:51','h'), +(13,9,NULL,'1900-01-01 00:00:00',NULL,NULL), +(14,2,'2008-10-05',NULL,'20:31:20','f'), +(15,0,'2001-11-25','2008-12-03 06:59:23','21:39:14','l'), +(16,205,'2003-01-27','2008-10-04 00:00:00','02:10:00','g'), +(17,NULL,'2008-08-08','2009-07-07 07:00:21','02:03:54','v'), +(18,3,'2006-07-03','2001-04-15 00:00:00','22:37:33',NULL), +(19,3,'2002-11-21','2007-07-08 04:01:58','12:17:48','m'); +ANALYZE TABLE t1 UPDATE HISTOGRAM ON col_datetime_key WITH 1023 BUCKETS; +Table Op Msg_type Msg_text +test.t1 histogram status Histogram statistics created for column 'col_datetime_key'. +ANALYZE TABLE t1 UPDATE HISTOGRAM ON col_int WITH 1000 BUCKETS; +Table Op Msg_type Msg_text +test.t1 histogram status Histogram statistics created for column 'col_int'. +ANALYZE TABLE t1 UPDATE HISTOGRAM ON col_time_key WITH 2 BUCKETS; +Table Op Msg_type Msg_text +test.t1 histogram status Histogram statistics created for column 'col_time_key'. +ANALYZE TABLE t1 UPDATE HISTOGRAM ON col_datetime WITH 1023 BUCKETS; +Table Op Msg_type Msg_text +test.t1 histogram status Histogram statistics created for column 'col_datetime'. +ANALYZE TABLE t1 UPDATE HISTOGRAM ON col_time WITH 80 BUCKETS; +Table Op Msg_type Msg_text +test.t1 histogram status Histogram statistics created for column 'col_time'. +ANALYZE TABLE t1 UPDATE HISTOGRAM ON col_int_key WITH 80 BUCKETS; +Table Op Msg_type Msg_text +test.t1 histogram status Histogram statistics created for column 'col_int_key'. +CREATE TABLE t2 ( +pk int(11) NOT NULL AUTO_INCREMENT, +col_int int(11) DEFAULT NULL, +col_int_key int(11) GENERATED ALWAYS AS ((col_int + col_int)) VIRTUAL, +col_date date DEFAULT NULL, +col_date_key date GENERATED ALWAYS AS ((col_date + interval 30 day)) VIRTUAL, +col_datetime datetime DEFAULT NULL, +col_time time DEFAULT NULL, +col_datetime_key datetime GENERATED ALWAYS AS (addtime(col_datetime,col_time)) VIRTUAL, +col_time_key time GENERATED ALWAYS AS (addtime(col_datetime,col_time)) VIRTUAL, +col_varchar varchar(1) DEFAULT NULL, +col_varchar_key varchar(2) GENERATED ALWAYS AS (concat(col_varchar,col_varchar)) VIRTUAL, +PRIMARY KEY (pk), +KEY col_date_key (col_date_key) +) ENGINE=InnoDB AUTO_INCREMENT=50 DEFAULT CHARSET=utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 (pk, col_int, col_date, col_datetime, col_time, col_varchar) VALUES +(10,7,'2006-03-07','2008-03-04 06:14:13','13:08:22','b'), +(11,8,'2001-10-15','2001-03-17 00:00:00','12:54:48','m'), +(12,NULL,'1900-01-01','2009-02-21 11:35:50','00:00:00','i'), +(13,0,NULL,'1900-01-01 00:00:00','20:56:23','w'), +(14,1,'2009-04-05','1900-01-01 00:00:00','04:25:03','m'), +(15,NULL,'2001-03-19','2001-04-12 00:00:00','00:00:00','q'), +(16,9,'2009-12-08','2001-12-04 20:21:01','00:00:00','k'), +(17,9,'2005-02-09','2001-05-27 08:41:01','00:58:58','l'), +(18,1,'2004-05-25','2004-09-18 00:00:00','18:39:28','c'), +(19,1,'2005-01-17','2002-09-12 11:18:48','19:47:45','d'), +(20,3,'2003-08-28','1900-01-01 00:00:00','05:20:00','k'), +(21,7,'2006-10-11','2003-10-28 03:31:02','11:43:03','a'), +(22,4,'1900-01-01','2001-08-22 10:20:09','02:38:39','p'), +(23,NULL,'1900-01-01','2008-04-24 00:00:00','05:34:27','o'), +(24,4,'2005-08-18','2006-11-10 10:08:49','11:13:16','e'), +(25,1,'2007-03-12','2007-10-16 00:00:00','00:00:00','n'), +(26,6,'2000-11-18','2009-05-27 12:25:07','08:56:42','t'), +(27,5,'2001-03-03',NULL,'03:20:29','u'), +(28,4,'2003-09-11','2001-09-10 18:10:10',NULL,'f'), +(29,1,'2007-06-17','1900-01-01 00:00:00',NULL,'t'), +(30,5,'2008-09-11','2004-06-07 23:17:09','10:39:48','k'), +(31,NULL,'2008-05-03','2007-06-09 02:05:46','00:00:00','m'), +(32,4,'2009-09-07','2000-07-03 00:00:00','10:52:33','y'), +(33,4,'2005-12-15','2001-04-15 14:12:38','21:41:45','m'), +(34,203,'2005-05-10','2007-04-12 13:29:59',NULL,'x'), +(35,9,'2008-01-22','2002-03-24 01:35:46','08:33:38',NULL), +(36,7,'2005-10-23','2001-12-27 07:56:29','19:27:01','q'), +(37,NULL,'2005-11-01','2002-06-08 09:04:13','09:31:22','f'), +(38,NULL,NULL,'2002-02-05 12:54:23','17:16:58','t'), +(39,0,'2005-06-25','2009-09-19 00:00:00','16:44:24','x'), +(40,1,'2005-12-09','2006-12-18 02:43:37','05:22:56','s'), +(41,5,'2006-06-28','2002-10-18 00:00:00','13:32:21','i'), +(42,NULL,'2002-03-16','2004-08-03 22:46:02','15:59:32','l'), +(43,6,'2006-07-20','1900-01-01 00:00:00','07:19:58','t'), +(44,7,'1900-01-01','2006-11-15 05:00:37','12:50:41','b'), +(45,NULL,'2002-09-13','2005-01-21 07:18:44','04:38:11','h'), +(46,6,'2002-08-17','1900-01-01 00:00:00','20:25:46',NULL), +(47,9,NULL,'2002-09-22 01:36:27','00:00:00',NULL), +(48,5,'2007-12-08','2003-04-22 16:42:22','10:53:24',NULL), +(49,1,'2008-07-05','2000-10-18 08:28:55','06:16:28','x'); +ANALYZE TABLE t2 UPDATE HISTOGRAM ON col_datetime_key WITH 100 BUCKETS; +Table Op Msg_type Msg_text +test.t2 histogram status Histogram statistics created for column 'col_datetime_key'. +ANALYZE TABLE t2 UPDATE HISTOGRAM ON col_varchar WITH 60 BUCKETS; +Table Op Msg_type Msg_text +test.t2 histogram status Histogram statistics created for column 'col_varchar'. +ANALYZE TABLE t2 UPDATE HISTOGRAM ON col_date_key WITH 2 BUCKETS; +Table Op Msg_type Msg_text +test.t2 histogram status Histogram statistics created for column 'col_date_key'. +ANALYZE TABLE t2 UPDATE HISTOGRAM ON col_datetime WITH 4 BUCKETS; +Table Op Msg_type Msg_text +test.t2 histogram status Histogram statistics created for column 'col_datetime'. +ANALYZE TABLE t2 UPDATE HISTOGRAM ON col_varchar_key WITH 2 BUCKETS; +Table Op Msg_type Msg_text +test.t2 histogram status Histogram statistics created for column 'col_varchar_key'. +ANALYZE TABLE t2 UPDATE HISTOGRAM ON col_int_key WITH 4 BUCKETS; +Table Op Msg_type Msg_text +test.t2 histogram status Histogram statistics created for column 'col_int_key'. +ANALYZE TABLE t2 UPDATE HISTOGRAM ON col_time WITH 10 BUCKETS; +Table Op Msg_type Msg_text +test.t2 histogram status Histogram statistics created for column 'col_time'. +ANALYZE TABLE t2 UPDATE HISTOGRAM ON col_date WITH 2 BUCKETS; +Table Op Msg_type Msg_text +test.t2 histogram status Histogram statistics created for column 'col_date'. +ANALYZE TABLE t2 UPDATE HISTOGRAM ON col_time_key WITH 10 BUCKETS; +Table Op Msg_type Msg_text +test.t2 histogram status Histogram statistics created for column 'col_time_key'. +CREATE OR REPLACE VIEW view_AA AS SELECT * FROM t1; +CREATE OR REPLACE VIEW view_CC AS SELECT * FROM t2; +SELECT LEFT(col_varchar_key, 1) AS field1 FROM view_AA WHERE ( pk, NULL ) IN +( SELECT col_int AS subfield11, pk AS subfield12 FROM view_CC WHERE ( col_datetime, col_date_key, col_varchar_key ) IN +( SELECT col_time_key AS subfield21, pk AS subfield22, col_time_key AS subfield23 FROM t1 WHERE col_varchar != col_varchar_key ) +ORDER BY subfield12 ) OR col_int IS NOT NULL ORDER BY field1 LIMIT 10 OFFSET 25; +field1 +DROP VIEW view_AA, view_CC; +DROP TABLE t1, t2; +# +# Bug#26641404 WL9223:ASSERTION `DELSUM+(INT) Y/4-TEMP >= 0' FAILED. +# +CREATE TABLE t1 (col1 TIME, col2 DATE); +INSERT INTO t1 VALUES ("00:00:00", "2017-01-01"); +ANALYZE TABLE t1 UPDATE HISTOGRAM ON col1, col2 WITH 8 BUCKETS; +Table Op Msg_type Msg_text +test.t1 histogram status Histogram statistics created for column 'col1'. +test.t1 histogram status Histogram statistics created for column 'col2'. +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT * FROM t1 WHERE col1 < ""; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Warning 1292 Truncated incorrect time value: '' +Warning 1292 Truncated incorrect time value: '' +Note 1003 /* select#1 */ select `test`.`t1`.`col1` AS `col1`,`test`.`t1`.`col2` AS `col2` from `test`.`t1` where (`test`.`t1`.`col1` < '') +EXPLAIN SELECT * FROM t1 WHERE col2 < ""; +ERROR HY000: Incorrect DATE value: '' +DROP TABLE t1; +CREATE TABLE tbl_int (col1 INT); +INSERT INTO tbl_int VALUES (1), (2), (2), (2), (3), (6), (8), (8), (NULL), (NULL); +ANALYZE TABLE tbl_int; +Table Op Msg_type Msg_text +test.tbl_int analyze status OK +ANALYZE TABLE tbl_int UPDATE HISTOGRAM ON col1 WITH 2 BUCKETS; +Table Op Msg_type Msg_text +test.tbl_int histogram status Histogram statistics created for column 'col1'. +SELECT schema_name, table_name, column_name, +JSON_REMOVE(histogram, '$."last-updated"') +FROM information_schema.COLUMN_STATISTICS; +SCHEMA_NAME TABLE_NAME COLUMN_NAME JSON_REMOVE(histogram, '$."last-updated"') +test tbl_int col1 {"buckets": [[1, 2, 0.4, 2], [3, 8, 0.8, 3]], "data-type": "int", "null-values": 0.2, "collation-id": 8, "sampling-rate": 1.0, "histogram-type": "equi-height", "number-of-buckets-specified": 2} +EXPLAIN SELECT * FROM tbl_int WHERE col1 > 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` > 0) +EXPLAIN SELECT * FROM tbl_int WHERE col1 > 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 60.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 60.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` > 1) +EXPLAIN SELECT * FROM tbl_int WHERE col1 > 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 40.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 40.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` > 2) +EXPLAIN SELECT * FROM tbl_int WHERE col1 > 3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` > 3) +EXPLAIN SELECT * FROM tbl_int WHERE col1 > 4; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 26.67 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 26.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` > 4) +EXPLAIN SELECT * FROM tbl_int WHERE col1 > 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 20.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 20.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` > 5) +EXPLAIN SELECT * FROM tbl_int WHERE col1 > 6; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 13.33 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 13.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` > 6) +EXPLAIN SELECT * FROM tbl_int WHERE col1 > 7; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` > 7) +EXPLAIN SELECT * FROM tbl_int WHERE col1 > 8; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` > 8) +EXPLAIN SELECT * FROM tbl_int WHERE col1 > 9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` > 9) +EXPLAIN SELECT * FROM tbl_int WHERE col1 >= 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` >= 0) +EXPLAIN SELECT * FROM tbl_int WHERE col1 >= 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` >= 1) +EXPLAIN SELECT * FROM tbl_int WHERE col1 >= 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 60.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 60.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` >= 2) +EXPLAIN SELECT * FROM tbl_int WHERE col1 >= 3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 40.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 40.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` >= 3) +EXPLAIN SELECT * FROM tbl_int WHERE col1 >= 4; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` >= 4) +EXPLAIN SELECT * FROM tbl_int WHERE col1 >= 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 26.67 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 26.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` >= 5) +EXPLAIN SELECT * FROM tbl_int WHERE col1 >= 6; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 20.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 20.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` >= 6) +EXPLAIN SELECT * FROM tbl_int WHERE col1 >= 7; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 13.33 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 13.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` >= 7) +EXPLAIN SELECT * FROM tbl_int WHERE col1 >= 8; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` >= 8) +EXPLAIN SELECT * FROM tbl_int WHERE col1 >= 9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` >= 9) +EXPLAIN SELECT * FROM tbl_int WHERE col1 = 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` = 0) +EXPLAIN SELECT * FROM tbl_int WHERE col1 = 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 20.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 20.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` = 1) +EXPLAIN SELECT * FROM tbl_int WHERE col1 = 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 20.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 20.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` = 2) +EXPLAIN SELECT * FROM tbl_int WHERE col1 = 3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` = 3) +EXPLAIN SELECT * FROM tbl_int WHERE col1 = 4; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` = 4) +EXPLAIN SELECT * FROM tbl_int WHERE col1 = 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` = 5) +EXPLAIN SELECT * FROM tbl_int WHERE col1 = 6; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` = 6) +EXPLAIN SELECT * FROM tbl_int WHERE col1 = 7; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` = 7) +EXPLAIN SELECT * FROM tbl_int WHERE col1 = 8; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` = 8) +EXPLAIN SELECT * FROM tbl_int WHERE col1 = 9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` = 9) +EXPLAIN SELECT * FROM tbl_int WHERE col1 <= 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` <= 0) +EXPLAIN SELECT * FROM tbl_int WHERE col1 <= 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 20.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 20.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` <= 1) +EXPLAIN SELECT * FROM tbl_int WHERE col1 <= 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 40.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 40.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` <= 2) +EXPLAIN SELECT * FROM tbl_int WHERE col1 <= 3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 46.67 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 46.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` <= 3) +EXPLAIN SELECT * FROM tbl_int WHERE col1 <= 4; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 53.33 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 53.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` <= 4) +EXPLAIN SELECT * FROM tbl_int WHERE col1 <= 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 60.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 60.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` <= 5) +EXPLAIN SELECT * FROM tbl_int WHERE col1 <= 6; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` <= 6) +EXPLAIN SELECT * FROM tbl_int WHERE col1 <= 7; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 73.33 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 73.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` <= 7) +EXPLAIN SELECT * FROM tbl_int WHERE col1 <= 8; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` <= 8) +EXPLAIN SELECT * FROM tbl_int WHERE col1 <= 9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` <= 9) +EXPLAIN SELECT * FROM tbl_int WHERE col1 < 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` < 0) +EXPLAIN SELECT * FROM tbl_int WHERE col1 < 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` < 1) +EXPLAIN SELECT * FROM tbl_int WHERE col1 < 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 20.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 20.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` < 2) +EXPLAIN SELECT * FROM tbl_int WHERE col1 < 3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 40.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 40.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` < 3) +EXPLAIN SELECT * FROM tbl_int WHERE col1 < 4; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 46.67 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 46.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` < 4) +EXPLAIN SELECT * FROM tbl_int WHERE col1 < 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 53.33 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 53.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` < 5) +EXPLAIN SELECT * FROM tbl_int WHERE col1 < 6; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 60.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 60.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` < 6) +EXPLAIN SELECT * FROM tbl_int WHERE col1 < 7; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` < 7) +EXPLAIN SELECT * FROM tbl_int WHERE col1 < 8; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 73.33 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 73.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` < 8) +EXPLAIN SELECT * FROM tbl_int WHERE col1 < 9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` < 9) +EXPLAIN SELECT * FROM tbl_int WHERE col1 <> 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` <> 0) +EXPLAIN SELECT * FROM tbl_int WHERE col1 <> 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 60.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 60.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` <> 1) +EXPLAIN SELECT * FROM tbl_int WHERE col1 <> 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 60.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 60.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` <> 2) +EXPLAIN SELECT * FROM tbl_int WHERE col1 <> 3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 73.33 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 73.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` <> 3) +EXPLAIN SELECT * FROM tbl_int WHERE col1 <> 4; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 73.33 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 73.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` <> 4) +EXPLAIN SELECT * FROM tbl_int WHERE col1 <> 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 73.33 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 73.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` <> 5) +EXPLAIN SELECT * FROM tbl_int WHERE col1 <> 6; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 73.33 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 73.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` <> 6) +EXPLAIN SELECT * FROM tbl_int WHERE col1 <> 7; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 73.33 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 73.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` <> 7) +EXPLAIN SELECT * FROM tbl_int WHERE col1 <> 8; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 73.33 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 73.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` <> 8) +EXPLAIN SELECT * FROM tbl_int WHERE col1 <> 9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` <> 9) +EXPLAIN SELECT * FROM tbl_int WHERE col1 BETWEEN 0 AND 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` between 0 and 0) +EXPLAIN SELECT * FROM tbl_int WHERE col1 BETWEEN 0 AND 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 20.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 20.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` between 0 and 1) +EXPLAIN SELECT * FROM tbl_int WHERE col1 BETWEEN 0 AND 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 40.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 40.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` between 0 and 2) +EXPLAIN SELECT * FROM tbl_int WHERE col1 BETWEEN 0 AND 3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 46.67 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 46.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` between 0 and 3) +EXPLAIN SELECT * FROM tbl_int WHERE col1 BETWEEN 0 AND 4; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 53.33 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 53.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` between 0 and 4) +EXPLAIN SELECT * FROM tbl_int WHERE col1 BETWEEN 0 AND 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 60.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 60.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` between 0 and 5) +EXPLAIN SELECT * FROM tbl_int WHERE col1 BETWEEN 0 AND 6; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` between 0 and 6) +EXPLAIN SELECT * FROM tbl_int WHERE col1 BETWEEN 0 AND 7; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 73.33 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 73.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` between 0 and 7) +EXPLAIN SELECT * FROM tbl_int WHERE col1 BETWEEN 0 AND 8; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` between 0 and 8) +EXPLAIN SELECT * FROM tbl_int WHERE col1 BETWEEN 0 AND 9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` between 0 and 9) +EXPLAIN SELECT * FROM tbl_int WHERE col1 BETWEEN 0 AND 9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` between 0 and 9) +EXPLAIN SELECT * FROM tbl_int WHERE col1 BETWEEN 1 AND 9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` between 1 and 9) +EXPLAIN SELECT * FROM tbl_int WHERE col1 BETWEEN 2 AND 9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 60.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 60.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` between 2 and 9) +EXPLAIN SELECT * FROM tbl_int WHERE col1 BETWEEN 3 AND 9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 40.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 40.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` between 3 and 9) +EXPLAIN SELECT * FROM tbl_int WHERE col1 BETWEEN 4 AND 9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` between 4 and 9) +EXPLAIN SELECT * FROM tbl_int WHERE col1 BETWEEN 5 AND 9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 26.67 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 26.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` between 5 and 9) +EXPLAIN SELECT * FROM tbl_int WHERE col1 BETWEEN 6 AND 9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 20.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 20.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` between 6 and 9) +EXPLAIN SELECT * FROM tbl_int WHERE col1 BETWEEN 7 AND 9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 13.33 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 13.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` between 7 and 9) +EXPLAIN SELECT * FROM tbl_int WHERE col1 BETWEEN 8 AND 9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` between 8 and 9) +EXPLAIN SELECT * FROM tbl_int WHERE col1 BETWEEN 9 AND 9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` between 9 and 9) +EXPLAIN SELECT * FROM tbl_int WHERE col1 IN (0,1,2,3,4,5,6,7,8,9); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` in (0,1,2,3,4,5,6,7,8,9)) +EXPLAIN SELECT * FROM tbl_int WHERE col1 IN (2,3,4,5,6,7,8,9); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 60.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 60.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` in (2,3,4,5,6,7,8,9)) +EXPLAIN SELECT * FROM tbl_int WHERE col1 IN (3,4,5,6,7,8,9); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 40.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 40.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` in (3,4,5,6,7,8,9)) +EXPLAIN SELECT * FROM tbl_int WHERE col1 IN (4,5,6,7,8,9); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` in (4,5,6,7,8,9)) +EXPLAIN SELECT * FROM tbl_int WHERE col1 IN (5,6,7,8,9); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 26.67 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 26.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` in (5,6,7,8,9)) +EXPLAIN SELECT * FROM tbl_int WHERE col1 IN (6,7,8,9); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 20.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 20.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` in (6,7,8,9)) +EXPLAIN SELECT * FROM tbl_int WHERE col1 IN (7,8,9); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 13.33 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 13.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` in (7,8,9)) +EXPLAIN SELECT * FROM tbl_int WHERE col1 IN (8,9); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` in (8,9)) +EXPLAIN SELECT * FROM tbl_int WHERE col1 IN (9); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` = 9) +EXPLAIN SELECT * FROM tbl_int WHERE col1 IN (1,3,5,7); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 40.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 40.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` in (1,3,5,7)) +EXPLAIN SELECT * FROM tbl_int WHERE col1 IN (2,4,6,8); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 40.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 40.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` in (2,4,6,8)) +EXPLAIN SELECT * FROM tbl_int WHERE col1 IN (2,5,6); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` in (2,5,6)) +EXPLAIN SELECT * FROM tbl_int WHERE col1 IN (9,10,11,12,13); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` in (9,10,11,12,13)) +DROP TABLE tbl_int; +CREATE TABLE tbl_float (col double); +INSERT INTO tbl_float VALUES (0.1), (0.2), (0.3), (0.3), (0.4), (0.5), (0.5), +(0.8), (NULL), (NULL); +ANALYZE TABLE tbl_float; +Table Op Msg_type Msg_text +test.tbl_float analyze status OK +ANALYZE TABLE tbl_float UPDATE HISTOGRAM ON col WITH 4 BUCKETS; +Table Op Msg_type Msg_text +test.tbl_float histogram status Histogram statistics created for column 'col'. +SELECT schema_name, table_name, column_name, +JSON_REMOVE(histogram, '$."last-updated"') +FROM information_schema.COLUMN_STATISTICS; +SCHEMA_NAME TABLE_NAME COLUMN_NAME JSON_REMOVE(histogram, '$."last-updated"') +test tbl_float col {"buckets": [[0.1, 0.2, 0.2, 2], [0.3, 0.3, 0.4, 1], [0.4, 0.5, 0.7, 2], [0.8, 0.8, 0.8, 1]], "data-type": "double", "null-values": 0.2, "collation-id": 8, "sampling-rate": 1.0, "histogram-type": "equi-height", "number-of-buckets-specified": 4} +EXPLAIN SELECT * FROM tbl_float WHERE col > 0.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_float NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_float`.`col` AS `col` from `test`.`tbl_float` where (`test`.`tbl_float`.`col` > 0) +EXPLAIN SELECT * FROM tbl_float WHERE col > 0.1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_float NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_float`.`col` AS `col` from `test`.`tbl_float` where (`test`.`tbl_float`.`col` > 0.1) +EXPLAIN SELECT * FROM tbl_float WHERE col > 0.2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 60.00 Parallel execute (1 workers) +2 SIMPLE tbl_float NULL ALL NULL NULL NULL NULL 10 60.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_float`.`col` AS `col` from `test`.`tbl_float` where (`test`.`tbl_float`.`col` > 0.2) +EXPLAIN SELECT * FROM tbl_float WHERE col > 0.3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 40.00 Parallel execute (1 workers) +2 SIMPLE tbl_float NULL ALL NULL NULL NULL NULL 10 40.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_float`.`col` AS `col` from `test`.`tbl_float` where (`test`.`tbl_float`.`col` > 0.3) +EXPLAIN SELECT * FROM tbl_float WHERE col > 0.4; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 40.00 Parallel execute (1 workers) +2 SIMPLE tbl_float NULL ALL NULL NULL NULL NULL 10 40.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_float`.`col` AS `col` from `test`.`tbl_float` where (`test`.`tbl_float`.`col` > 0.4) +EXPLAIN SELECT * FROM tbl_float WHERE col > 0.5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_float NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_float`.`col` AS `col` from `test`.`tbl_float` where (`test`.`tbl_float`.`col` > 0.5) +EXPLAIN SELECT * FROM tbl_float WHERE col > 0.6; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_float NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_float`.`col` AS `col` from `test`.`tbl_float` where (`test`.`tbl_float`.`col` > 0.6) +EXPLAIN SELECT * FROM tbl_float WHERE col > 0.7; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_float NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_float`.`col` AS `col` from `test`.`tbl_float` where (`test`.`tbl_float`.`col` > 0.7) +EXPLAIN SELECT * FROM tbl_float WHERE col > 0.8; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_float NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_float`.`col` AS `col` from `test`.`tbl_float` where (`test`.`tbl_float`.`col` > 0.8) +EXPLAIN SELECT * FROM tbl_float WHERE col > 0.9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_float NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_float`.`col` AS `col` from `test`.`tbl_float` where (`test`.`tbl_float`.`col` > 0.9) +EXPLAIN SELECT * FROM tbl_float WHERE col >= 0.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_float NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_float`.`col` AS `col` from `test`.`tbl_float` where (`test`.`tbl_float`.`col` >= 0) +EXPLAIN SELECT * FROM tbl_float WHERE col >= 0.1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_float NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_float`.`col` AS `col` from `test`.`tbl_float` where (`test`.`tbl_float`.`col` >= 0.1) +EXPLAIN SELECT * FROM tbl_float WHERE col >= 0.2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 60.00 Parallel execute (1 workers) +2 SIMPLE tbl_float NULL ALL NULL NULL NULL NULL 10 60.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_float`.`col` AS `col` from `test`.`tbl_float` where (`test`.`tbl_float`.`col` >= 0.2) +EXPLAIN SELECT * FROM tbl_float WHERE col >= 0.3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 60.00 Parallel execute (1 workers) +2 SIMPLE tbl_float NULL ALL NULL NULL NULL NULL 10 60.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_float`.`col` AS `col` from `test`.`tbl_float` where (`test`.`tbl_float`.`col` >= 0.3) +EXPLAIN SELECT * FROM tbl_float WHERE col >= 0.4; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 40.00 Parallel execute (1 workers) +2 SIMPLE tbl_float NULL ALL NULL NULL NULL NULL 10 40.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_float`.`col` AS `col` from `test`.`tbl_float` where (`test`.`tbl_float`.`col` >= 0.4) +EXPLAIN SELECT * FROM tbl_float WHERE col >= 0.5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_float NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_float`.`col` AS `col` from `test`.`tbl_float` where (`test`.`tbl_float`.`col` >= 0.5) +EXPLAIN SELECT * FROM tbl_float WHERE col >= 0.6; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_float NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_float`.`col` AS `col` from `test`.`tbl_float` where (`test`.`tbl_float`.`col` >= 0.6) +EXPLAIN SELECT * FROM tbl_float WHERE col >= 0.7; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_float NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_float`.`col` AS `col` from `test`.`tbl_float` where (`test`.`tbl_float`.`col` >= 0.7) +EXPLAIN SELECT * FROM tbl_float WHERE col >= 0.8; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_float NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_float`.`col` AS `col` from `test`.`tbl_float` where (`test`.`tbl_float`.`col` >= 0.8) +EXPLAIN SELECT * FROM tbl_float WHERE col >= 0.9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_float NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_float`.`col` AS `col` from `test`.`tbl_float` where (`test`.`tbl_float`.`col` >= 0.9) +EXPLAIN SELECT * FROM tbl_float WHERE col = 0.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_float NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_float`.`col` AS `col` from `test`.`tbl_float` where (`test`.`tbl_float`.`col` = 0) +EXPLAIN SELECT * FROM tbl_float WHERE col = 0.1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_float NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_float`.`col` AS `col` from `test`.`tbl_float` where (`test`.`tbl_float`.`col` = 0.1) +EXPLAIN SELECT * FROM tbl_float WHERE col = 0.2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_float NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_float`.`col` AS `col` from `test`.`tbl_float` where (`test`.`tbl_float`.`col` = 0.2) +EXPLAIN SELECT * FROM tbl_float WHERE col = 0.3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 20.00 Parallel execute (1 workers) +2 SIMPLE tbl_float NULL ALL NULL NULL NULL NULL 10 20.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_float`.`col` AS `col` from `test`.`tbl_float` where (`test`.`tbl_float`.`col` = 0.3) +EXPLAIN SELECT * FROM tbl_float WHERE col = 0.4; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_float NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_float`.`col` AS `col` from `test`.`tbl_float` where (`test`.`tbl_float`.`col` = 0.4) +EXPLAIN SELECT * FROM tbl_float WHERE col = 0.5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_float NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_float`.`col` AS `col` from `test`.`tbl_float` where (`test`.`tbl_float`.`col` = 0.5) +EXPLAIN SELECT * FROM tbl_float WHERE col = 0.6; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_float NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_float`.`col` AS `col` from `test`.`tbl_float` where (`test`.`tbl_float`.`col` = 0.6) +EXPLAIN SELECT * FROM tbl_float WHERE col = 0.7; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_float NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_float`.`col` AS `col` from `test`.`tbl_float` where (`test`.`tbl_float`.`col` = 0.7) +EXPLAIN SELECT * FROM tbl_float WHERE col = 0.8; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_float NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_float`.`col` AS `col` from `test`.`tbl_float` where (`test`.`tbl_float`.`col` = 0.8) +EXPLAIN SELECT * FROM tbl_float WHERE col = 0.9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_float NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_float`.`col` AS `col` from `test`.`tbl_float` where (`test`.`tbl_float`.`col` = 0.9) +EXPLAIN SELECT * FROM tbl_float WHERE col <= 0.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_float NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_float`.`col` AS `col` from `test`.`tbl_float` where (`test`.`tbl_float`.`col` <= 0) +EXPLAIN SELECT * FROM tbl_float WHERE col <= 0.1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_float NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_float`.`col` AS `col` from `test`.`tbl_float` where (`test`.`tbl_float`.`col` <= 0.1) +EXPLAIN SELECT * FROM tbl_float WHERE col <= 0.2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 20.00 Parallel execute (1 workers) +2 SIMPLE tbl_float NULL ALL NULL NULL NULL NULL 10 20.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_float`.`col` AS `col` from `test`.`tbl_float` where (`test`.`tbl_float`.`col` <= 0.2) +EXPLAIN SELECT * FROM tbl_float WHERE col <= 0.3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 40.00 Parallel execute (1 workers) +2 SIMPLE tbl_float NULL ALL NULL NULL NULL NULL 10 40.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_float`.`col` AS `col` from `test`.`tbl_float` where (`test`.`tbl_float`.`col` <= 0.3) +EXPLAIN SELECT * FROM tbl_float WHERE col <= 0.4; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 40.00 Parallel execute (1 workers) +2 SIMPLE tbl_float NULL ALL NULL NULL NULL NULL 10 40.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_float`.`col` AS `col` from `test`.`tbl_float` where (`test`.`tbl_float`.`col` <= 0.4) +EXPLAIN SELECT * FROM tbl_float WHERE col <= 0.5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 70.00 Parallel execute (1 workers) +2 SIMPLE tbl_float NULL ALL NULL NULL NULL NULL 10 70.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_float`.`col` AS `col` from `test`.`tbl_float` where (`test`.`tbl_float`.`col` <= 0.5) +EXPLAIN SELECT * FROM tbl_float WHERE col <= 0.6; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 70.00 Parallel execute (1 workers) +2 SIMPLE tbl_float NULL ALL NULL NULL NULL NULL 10 70.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_float`.`col` AS `col` from `test`.`tbl_float` where (`test`.`tbl_float`.`col` <= 0.6) +EXPLAIN SELECT * FROM tbl_float WHERE col <= 0.7; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 70.00 Parallel execute (1 workers) +2 SIMPLE tbl_float NULL ALL NULL NULL NULL NULL 10 70.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_float`.`col` AS `col` from `test`.`tbl_float` where (`test`.`tbl_float`.`col` <= 0.7) +EXPLAIN SELECT * FROM tbl_float WHERE col <= 0.8; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_float NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_float`.`col` AS `col` from `test`.`tbl_float` where (`test`.`tbl_float`.`col` <= 0.8) +EXPLAIN SELECT * FROM tbl_float WHERE col <= 0.9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_float NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_float`.`col` AS `col` from `test`.`tbl_float` where (`test`.`tbl_float`.`col` <= 0.9) +EXPLAIN SELECT * FROM tbl_float WHERE col < 0.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_float NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_float`.`col` AS `col` from `test`.`tbl_float` where (`test`.`tbl_float`.`col` < 0) +EXPLAIN SELECT * FROM tbl_float WHERE col < 0.1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_float NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_float`.`col` AS `col` from `test`.`tbl_float` where (`test`.`tbl_float`.`col` < 0.1) +EXPLAIN SELECT * FROM tbl_float WHERE col < 0.2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 20.00 Parallel execute (1 workers) +2 SIMPLE tbl_float NULL ALL NULL NULL NULL NULL 10 20.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_float`.`col` AS `col` from `test`.`tbl_float` where (`test`.`tbl_float`.`col` < 0.2) +EXPLAIN SELECT * FROM tbl_float WHERE col < 0.3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 20.00 Parallel execute (1 workers) +2 SIMPLE tbl_float NULL ALL NULL NULL NULL NULL 10 20.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_float`.`col` AS `col` from `test`.`tbl_float` where (`test`.`tbl_float`.`col` < 0.3) +EXPLAIN SELECT * FROM tbl_float WHERE col < 0.4; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 40.00 Parallel execute (1 workers) +2 SIMPLE tbl_float NULL ALL NULL NULL NULL NULL 10 40.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_float`.`col` AS `col` from `test`.`tbl_float` where (`test`.`tbl_float`.`col` < 0.4) +EXPLAIN SELECT * FROM tbl_float WHERE col < 0.5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 70.00 Parallel execute (1 workers) +2 SIMPLE tbl_float NULL ALL NULL NULL NULL NULL 10 70.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_float`.`col` AS `col` from `test`.`tbl_float` where (`test`.`tbl_float`.`col` < 0.5) +EXPLAIN SELECT * FROM tbl_float WHERE col < 0.6; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 70.00 Parallel execute (1 workers) +2 SIMPLE tbl_float NULL ALL NULL NULL NULL NULL 10 70.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_float`.`col` AS `col` from `test`.`tbl_float` where (`test`.`tbl_float`.`col` < 0.6) +EXPLAIN SELECT * FROM tbl_float WHERE col < 0.7; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 70.00 Parallel execute (1 workers) +2 SIMPLE tbl_float NULL ALL NULL NULL NULL NULL 10 70.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_float`.`col` AS `col` from `test`.`tbl_float` where (`test`.`tbl_float`.`col` < 0.7) +EXPLAIN SELECT * FROM tbl_float WHERE col < 0.8; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 70.00 Parallel execute (1 workers) +2 SIMPLE tbl_float NULL ALL NULL NULL NULL NULL 10 70.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_float`.`col` AS `col` from `test`.`tbl_float` where (`test`.`tbl_float`.`col` < 0.8) +EXPLAIN SELECT * FROM tbl_float WHERE col < 0.9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_float NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_float`.`col` AS `col` from `test`.`tbl_float` where (`test`.`tbl_float`.`col` < 0.9) +EXPLAIN SELECT * FROM tbl_float WHERE col <> 0.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_float NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_float`.`col` AS `col` from `test`.`tbl_float` where (`test`.`tbl_float`.`col` <> 0) +EXPLAIN SELECT * FROM tbl_float WHERE col <> 0.1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_float NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_float`.`col` AS `col` from `test`.`tbl_float` where (`test`.`tbl_float`.`col` <> 0.1) +EXPLAIN SELECT * FROM tbl_float WHERE col <> 0.2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_float NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_float`.`col` AS `col` from `test`.`tbl_float` where (`test`.`tbl_float`.`col` <> 0.2) +EXPLAIN SELECT * FROM tbl_float WHERE col <> 0.3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 60.00 Parallel execute (1 workers) +2 SIMPLE tbl_float NULL ALL NULL NULL NULL NULL 10 60.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_float`.`col` AS `col` from `test`.`tbl_float` where (`test`.`tbl_float`.`col` <> 0.3) +EXPLAIN SELECT * FROM tbl_float WHERE col <> 0.4; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_float NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_float`.`col` AS `col` from `test`.`tbl_float` where (`test`.`tbl_float`.`col` <> 0.4) +EXPLAIN SELECT * FROM tbl_float WHERE col <> 0.5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_float NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_float`.`col` AS `col` from `test`.`tbl_float` where (`test`.`tbl_float`.`col` <> 0.5) +EXPLAIN SELECT * FROM tbl_float WHERE col <> 0.6; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_float NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_float`.`col` AS `col` from `test`.`tbl_float` where (`test`.`tbl_float`.`col` <> 0.6) +EXPLAIN SELECT * FROM tbl_float WHERE col <> 0.7; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_float NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_float`.`col` AS `col` from `test`.`tbl_float` where (`test`.`tbl_float`.`col` <> 0.7) +EXPLAIN SELECT * FROM tbl_float WHERE col <> 0.8; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 70.00 Parallel execute (1 workers) +2 SIMPLE tbl_float NULL ALL NULL NULL NULL NULL 10 70.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_float`.`col` AS `col` from `test`.`tbl_float` where (`test`.`tbl_float`.`col` <> 0.8) +EXPLAIN SELECT * FROM tbl_float WHERE col <> 0.9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_float NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_float`.`col` AS `col` from `test`.`tbl_float` where (`test`.`tbl_float`.`col` <> 0.9) +EXPLAIN SELECT * FROM tbl_float WHERE col BETWEEN 0.0 AND 0.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_float NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_float`.`col` AS `col` from `test`.`tbl_float` where (`test`.`tbl_float`.`col` between 0.0 and 0.0) +EXPLAIN SELECT * FROM tbl_float WHERE col BETWEEN 0.0 AND 0.1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_float NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_float`.`col` AS `col` from `test`.`tbl_float` where (`test`.`tbl_float`.`col` between 0.0 and 0.1) +EXPLAIN SELECT * FROM tbl_float WHERE col BETWEEN 0.0 AND 0.2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 20.00 Parallel execute (1 workers) +2 SIMPLE tbl_float NULL ALL NULL NULL NULL NULL 10 20.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_float`.`col` AS `col` from `test`.`tbl_float` where (`test`.`tbl_float`.`col` between 0.0 and 0.2) +EXPLAIN SELECT * FROM tbl_float WHERE col BETWEEN 0.0 AND 0.3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 40.00 Parallel execute (1 workers) +2 SIMPLE tbl_float NULL ALL NULL NULL NULL NULL 10 40.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_float`.`col` AS `col` from `test`.`tbl_float` where (`test`.`tbl_float`.`col` between 0.0 and 0.3) +EXPLAIN SELECT * FROM tbl_float WHERE col BETWEEN 0.0 AND 0.4; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 40.00 Parallel execute (1 workers) +2 SIMPLE tbl_float NULL ALL NULL NULL NULL NULL 10 40.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_float`.`col` AS `col` from `test`.`tbl_float` where (`test`.`tbl_float`.`col` between 0.0 and 0.4) +EXPLAIN SELECT * FROM tbl_float WHERE col BETWEEN 0.0 AND 0.5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 70.00 Parallel execute (1 workers) +2 SIMPLE tbl_float NULL ALL NULL NULL NULL NULL 10 70.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_float`.`col` AS `col` from `test`.`tbl_float` where (`test`.`tbl_float`.`col` between 0.0 and 0.5) +EXPLAIN SELECT * FROM tbl_float WHERE col BETWEEN 0.0 AND 0.6; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 70.00 Parallel execute (1 workers) +2 SIMPLE tbl_float NULL ALL NULL NULL NULL NULL 10 70.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_float`.`col` AS `col` from `test`.`tbl_float` where (`test`.`tbl_float`.`col` between 0.0 and 0.6) +EXPLAIN SELECT * FROM tbl_float WHERE col BETWEEN 0.0 AND 0.7; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 70.00 Parallel execute (1 workers) +2 SIMPLE tbl_float NULL ALL NULL NULL NULL NULL 10 70.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_float`.`col` AS `col` from `test`.`tbl_float` where (`test`.`tbl_float`.`col` between 0.0 and 0.7) +EXPLAIN SELECT * FROM tbl_float WHERE col BETWEEN 0.0 AND 0.8; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_float NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_float`.`col` AS `col` from `test`.`tbl_float` where (`test`.`tbl_float`.`col` between 0.0 and 0.8) +EXPLAIN SELECT * FROM tbl_float WHERE col BETWEEN 0.0 AND 0.9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_float NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_float`.`col` AS `col` from `test`.`tbl_float` where (`test`.`tbl_float`.`col` between 0.0 and 0.9) +EXPLAIN SELECT * FROM tbl_float WHERE col BETWEEN 0.0 AND 0.9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_float NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_float`.`col` AS `col` from `test`.`tbl_float` where (`test`.`tbl_float`.`col` between 0.0 and 0.9) +EXPLAIN SELECT * FROM tbl_float WHERE col BETWEEN 0.1 AND 0.9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_float NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_float`.`col` AS `col` from `test`.`tbl_float` where (`test`.`tbl_float`.`col` between 0.1 and 0.9) +EXPLAIN SELECT * FROM tbl_float WHERE col BETWEEN 0.2 AND 0.9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 60.00 Parallel execute (1 workers) +2 SIMPLE tbl_float NULL ALL NULL NULL NULL NULL 10 60.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_float`.`col` AS `col` from `test`.`tbl_float` where (`test`.`tbl_float`.`col` between 0.2 and 0.9) +EXPLAIN SELECT * FROM tbl_float WHERE col BETWEEN 0.3 AND 0.9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 60.00 Parallel execute (1 workers) +2 SIMPLE tbl_float NULL ALL NULL NULL NULL NULL 10 60.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_float`.`col` AS `col` from `test`.`tbl_float` where (`test`.`tbl_float`.`col` between 0.3 and 0.9) +EXPLAIN SELECT * FROM tbl_float WHERE col BETWEEN 0.4 AND 0.9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 40.00 Parallel execute (1 workers) +2 SIMPLE tbl_float NULL ALL NULL NULL NULL NULL 10 40.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_float`.`col` AS `col` from `test`.`tbl_float` where (`test`.`tbl_float`.`col` between 0.4 and 0.9) +EXPLAIN SELECT * FROM tbl_float WHERE col BETWEEN 0.5 AND 0.9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_float NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_float`.`col` AS `col` from `test`.`tbl_float` where (`test`.`tbl_float`.`col` between 0.5 and 0.9) +EXPLAIN SELECT * FROM tbl_float WHERE col BETWEEN 0.6 AND 0.9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_float NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_float`.`col` AS `col` from `test`.`tbl_float` where (`test`.`tbl_float`.`col` between 0.6 and 0.9) +EXPLAIN SELECT * FROM tbl_float WHERE col BETWEEN 0.7 AND 0.9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_float NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_float`.`col` AS `col` from `test`.`tbl_float` where (`test`.`tbl_float`.`col` between 0.7 and 0.9) +EXPLAIN SELECT * FROM tbl_float WHERE col BETWEEN 0.8 AND 0.9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_float NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_float`.`col` AS `col` from `test`.`tbl_float` where (`test`.`tbl_float`.`col` between 0.8 and 0.9) +EXPLAIN SELECT * FROM tbl_float WHERE col BETWEEN 0.9 AND 0.9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_float NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_float`.`col` AS `col` from `test`.`tbl_float` where (`test`.`tbl_float`.`col` between 0.9 and 0.9) +EXPLAIN SELECT * FROM tbl_float WHERE col IN (0.0,0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 30.00 Parallel execute (1 workers) +2 SIMPLE tbl_float NULL ALL NULL NULL NULL NULL 10 30.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_float`.`col` AS `col` from `test`.`tbl_float` where (`test`.`tbl_float`.`col` in (0.0,0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9)) +EXPLAIN SELECT * FROM tbl_float WHERE col IN (0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 30.00 Parallel execute (1 workers) +2 SIMPLE tbl_float NULL ALL NULL NULL NULL NULL 10 30.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_float`.`col` AS `col` from `test`.`tbl_float` where (`test`.`tbl_float`.`col` in (0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9)) +EXPLAIN SELECT * FROM tbl_float WHERE col IN (0.3,0.4,0.5,0.6,0.7,0.8,0.9); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 30.00 Parallel execute (1 workers) +2 SIMPLE tbl_float NULL ALL NULL NULL NULL NULL 10 30.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_float`.`col` AS `col` from `test`.`tbl_float` where (`test`.`tbl_float`.`col` in (0.3,0.4,0.5,0.6,0.7,0.8,0.9)) +EXPLAIN SELECT * FROM tbl_float WHERE col IN (0.4,0.5,0.6,0.7,0.8,0.9); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_float NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_float`.`col` AS `col` from `test`.`tbl_float` where (`test`.`tbl_float`.`col` in (0.4,0.5,0.6,0.7,0.8,0.9)) +EXPLAIN SELECT * FROM tbl_float WHERE col IN (0.5,0.6,0.7,0.8,0.9); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_float NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_float`.`col` AS `col` from `test`.`tbl_float` where (`test`.`tbl_float`.`col` in (0.5,0.6,0.7,0.8,0.9)) +EXPLAIN SELECT * FROM tbl_float WHERE col IN (0.6,0.7,0.8,0.9); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_float NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_float`.`col` AS `col` from `test`.`tbl_float` where (`test`.`tbl_float`.`col` in (0.6,0.7,0.8,0.9)) +EXPLAIN SELECT * FROM tbl_float WHERE col IN (0.7,0.8,0.9); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_float NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_float`.`col` AS `col` from `test`.`tbl_float` where (`test`.`tbl_float`.`col` in (0.7,0.8,0.9)) +EXPLAIN SELECT * FROM tbl_float WHERE col IN (0.8,0.9); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_float NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_float`.`col` AS `col` from `test`.`tbl_float` where (`test`.`tbl_float`.`col` in (0.8,0.9)) +EXPLAIN SELECT * FROM tbl_float WHERE col IN (0.9); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_float NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_float`.`col` AS `col` from `test`.`tbl_float` where (`test`.`tbl_float`.`col` = 0.9) +EXPLAIN SELECT * FROM tbl_float WHERE col IN (0.1,0.3,0.5,0.7); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 20.00 Parallel execute (1 workers) +2 SIMPLE tbl_float NULL ALL NULL NULL NULL NULL 10 20.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_float`.`col` AS `col` from `test`.`tbl_float` where (`test`.`tbl_float`.`col` in (0.1,0.3,0.5,0.7)) +EXPLAIN SELECT * FROM tbl_float WHERE col IN (0.2,0.4,0.6,0.8); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_float NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_float`.`col` AS `col` from `test`.`tbl_float` where (`test`.`tbl_float`.`col` in (0.2,0.4,0.6,0.8)) +EXPLAIN SELECT * FROM tbl_float WHERE col IN (0.2,0.5,0.6); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_float NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_float`.`col` AS `col` from `test`.`tbl_float` where (`test`.`tbl_float`.`col` in (0.2,0.5,0.6)) +EXPLAIN SELECT * FROM tbl_float WHERE col IN (0.9,1.0,1.1,1.2,1.3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_float NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_float`.`col` AS `col` from `test`.`tbl_float` where (`test`.`tbl_float`.`col` in (0.9,1.0,1.1,1.2,1.3)) +DROP TABLE tbl_float; +CREATE TABLE t1 (col1 BIGINT, col2 BIGINT UNSIGNED, col3 DOUBLE); +INSERT INTO t1 VALUES +(-9223372036854775808, 0, -1.7976931348623157E+308), +(9223372036854775806, 18446744073709551614, 1.7976931348623155e+308), +(9223372036854775807, 18446744073709551615, 1.7976931348623157e+308); +ANALYZE TABLE t1 UPDATE HISTOGRAM ON col1, col2, col3 WITH 2 BUCKETS; +Table Op Msg_type Msg_text +test.t1 histogram status Histogram statistics created for column 'col1'. +test.t1 histogram status Histogram statistics created for column 'col2'. +test.t1 histogram status Histogram statistics created for column 'col3'. +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT * FROM t1 WHERE col1 < 100; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col1` AS `col1`,`test`.`t1`.`col2` AS `col2`,`test`.`t1`.`col3` AS `col3` from `test`.`t1` where (`test`.`t1`.`col1` < 100) +EXPLAIN SELECT * FROM t1 WHERE col2 < 100; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col1` AS `col1`,`test`.`t1`.`col2` AS `col2`,`test`.`t1`.`col3` AS `col3` from `test`.`t1` where (`test`.`t1`.`col2` < 100) +EXPLAIN SELECT * FROM t1 WHERE col3 < 100; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col1` AS `col1`,`test`.`t1`.`col2` AS `col2`,`test`.`t1`.`col3` AS `col3` from `test`.`t1` where (`test`.`t1`.`col3` < 100) +DROP TABLE t1; +# +# Bug#27197709 TABLE ROWS ESTIMATE DURING HISTOGRAM CREATION MAY BE WAY +# OFF +# +CREATE TABLE t1 (col1 VARCHAR(255)); +# Insert 10000 rows into the table t1 with random string data +SET cte_max_recursion_depth = 10000; +INSERT INTO t1 (col1) +WITH RECURSIVE cte (n, val) AS +( +SELECT 1, CONCAT(MD5(RAND()), MD5(RAND())) +UNION ALL +SELECT n + 1, CONCAT(MD5(RAND()), MD5(RAND())) FROM cte WHERE n < 10000 +) +SELECT val FROM cte; +# Set the amount of available memory as low as possible, so we are sure +# that sampling will be used. +SET histogram_generation_max_mem_size = 1000000; +ANALYZE TABLE t1 UPDATE HISTOGRAM ON col1 WITH 2 BUCKETS; +Table Op Msg_type Msg_text +test.t1 histogram status Histogram statistics created for column 'col1'. +SELECT +histogram->>'$."sampling-rate"' < 1.0 AS should_be_true +FROM +INFORMATION_SCHEMA.COLUMN_STATISTICS; +should_be_true +1 +SET cte_max_recursion_depth = DEFAULT; +SET histogram_generation_max_mem_size = DEFAULT; +DROP TABLE t1; +# +# Bug#27637968 PROVIDE A DEFAULT NUMBER OF BUCKETS FOR HISTOGRAM +# STATISTICS +# +CREATE TABLE t1 (col1 INT); +INSERT INTO t1 VALUES (10), (20), (30); +ANALYZE TABLE t1 UPDATE HISTOGRAM ON col1; +Table Op Msg_type Msg_text +test.t1 histogram status Histogram statistics created for column 'col1'. +SELECT JSON_EXTRACT(histogram, '$."number-of-buckets-specified"') +FROM INFORMATION_SCHEMA.column_statistics +WHERE table_name = "t1" AND column_name = "col1"; +JSON_EXTRACT(histogram, '$."number-of-buckets-specified"') +100 +DROP TABLE t1; +# +# Bug#27574375 ANALYZA TABLE DOESN'T RETURN ERROR IN CASE +# LOCK_WAIT_TIMEOUT HAPPENED +# +CREATE TABLE t1 (a INT); +SET lock_wait_timeout= 1; +LOCK INSTANCE FOR BACKUP; +# The error ER_LOCK_WAIT_TIMEOUT is expected here, and when using ANALYZE +# TABLE errors are printed out in the result set from the query. +ANALYZE TABLE t1 UPDATE HISTOGRAM ON a WITH 5 BUCKETS; +Table Op Msg_type Msg_text +test.t1 histogram Error Lock wait timeout exceeded; try restarting transaction +UNLOCK INSTANCE; +DROP TABLE t1; +# restart: diff --git a/mysql-test/r/index_merge_innodb.result-pq b/mysql-test/r/index_merge_innodb.result-pq new file mode 100644 index 000000000000..8a1cbda247c8 --- /dev/null +++ b/mysql-test/r/index_merge_innodb.result-pq @@ -0,0 +1,2116 @@ +#---------------- Index merge test 1 ------------------------------------------- +# (Start of test file: index_merge1.inc) +SET SESSION DEFAULT_STORAGE_ENGINE = InnoDB; +drop table if exists t0, t1, t2, t3, t4; +# Create and fill a table with simple keys +create table t0 +( +key1 int not null, +key2 int not null, +key3 int not null, +key4 int not null, +key5 int not null, +key6 int not null, +key7 int not null, +key8 int not null, +INDEX i1(key1), +INDEX i2(key2), +INDEX i3(key3), +INDEX i4(key4), +INDEX i5(key5), +INDEX i6(key6), +INDEX i7(key7), +INDEX i8(key8) +); +analyze table t0; +Table Op Msg_type Msg_text +test.t0 analyze status OK +# 1. One index +explain select * from t0 where key1 < 3 or key1 > 1020; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 6 100.00 Parallel execute (2 workers) +2 SIMPLE t0 NULL range i1 i1 4 NULL 6 100.00 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`key1` AS `key1`,`test`.`t0`.`key2` AS `key2`,`test`.`t0`.`key3` AS `key3`,`test`.`t0`.`key4` AS `key4`,`test`.`t0`.`key5` AS `key5`,`test`.`t0`.`key6` AS `key6`,`test`.`t0`.`key7` AS `key7`,`test`.`t0`.`key8` AS `key8` from `test`.`t0` where ((`test`.`t0`.`key1` < 3) or (`test`.`t0`.`key1` > 1020)) +# 2. Simple cases +explain +select * from t0 where key1 < 3 or key2 > 1020; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL index_merge i1,i2 i1,i2 4,4 NULL 6 100.00 Using sort_union(i1,i2); Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`key1` AS `key1`,`test`.`t0`.`key2` AS `key2`,`test`.`t0`.`key3` AS `key3`,`test`.`t0`.`key4` AS `key4`,`test`.`t0`.`key5` AS `key5`,`test`.`t0`.`key6` AS `key6`,`test`.`t0`.`key7` AS `key7`,`test`.`t0`.`key8` AS `key8` from `test`.`t0` where ((`test`.`t0`.`key1` < 3) or (`test`.`t0`.`key2` > 1020)) +select * from t0 where key1 < 3 or key2 > 1020; +key1 key2 key3 key4 key5 key6 key7 key8 +1 1 1 1 1 1 1 1023 +2 2 2 2 2 2 2 1022 +1021 1021 1021 1021 1021 1021 1021 3 +1022 1022 1022 1022 1022 1022 1022 2 +1023 1023 1023 1023 1023 1023 1023 1 +1024 1024 1024 1024 1024 1024 1024 0 +explain select * from t0 where key1 < 2 or key2 <3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL index_merge i1,i2 i1,i2 4,4 NULL # 100.00 Using sort_union(i1,i2); Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`key1` AS `key1`,`test`.`t0`.`key2` AS `key2`,`test`.`t0`.`key3` AS `key3`,`test`.`t0`.`key4` AS `key4`,`test`.`t0`.`key5` AS `key5`,`test`.`t0`.`key6` AS `key6`,`test`.`t0`.`key7` AS `key7`,`test`.`t0`.`key8` AS `key8` from `test`.`t0` where ((`test`.`t0`.`key1` < 2) or (`test`.`t0`.`key2` < 3)) +explain +select * from t0 where (key1 > 30 and key1<35) or (key2 >32 and key2 < 40); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL index_merge i1,i2 i1,i2 4,4 NULL # 100.00 Using sort_union(i1,i2); Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`key1` AS `key1`,`test`.`t0`.`key2` AS `key2`,`test`.`t0`.`key3` AS `key3`,`test`.`t0`.`key4` AS `key4`,`test`.`t0`.`key5` AS `key5`,`test`.`t0`.`key6` AS `key6`,`test`.`t0`.`key7` AS `key7`,`test`.`t0`.`key8` AS `key8` from `test`.`t0` where (((`test`.`t0`.`key1` > 30) and (`test`.`t0`.`key1` < 35)) or ((`test`.`t0`.`key2` > 32) and (`test`.`t0`.`key2` < 40))) +# Bug#21277: InnoDB, wrong result set, index_merge strategy, +# second index not evaluated +select * from t0 where (key1 > 30 and key1<35) or (key2 >32 and key2 < 40); +key1 key2 key3 key4 key5 key6 key7 key8 +31 31 31 31 31 31 31 993 +32 32 32 32 32 32 32 992 +33 33 33 33 33 33 33 991 +34 34 34 34 34 34 34 990 +35 35 35 35 35 35 35 989 +36 36 36 36 36 36 36 988 +37 37 37 37 37 37 37 987 +38 38 38 38 38 38 38 986 +39 39 39 39 39 39 39 985 +# 3. Check that index_merge doesn't break "ignore/force/use index" +explain select * from t0 ignore index (i2) where key1 < 3 or key2 <4; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 55.55 Parallel execute (4 workers) +2 SIMPLE t0 NULL ALL i1 NULL NULL NULL # 55.55 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`key1` AS `key1`,`test`.`t0`.`key2` AS `key2`,`test`.`t0`.`key3` AS `key3`,`test`.`t0`.`key4` AS `key4`,`test`.`t0`.`key5` AS `key5`,`test`.`t0`.`key6` AS `key6`,`test`.`t0`.`key7` AS `key7`,`test`.`t0`.`key8` AS `key8` from `test`.`t0` IGNORE INDEX (`i2`) where ((`test`.`t0`.`key1` < 3) or (`test`.`t0`.`key2` < 4)) +explain select * from t0 where (key1 < 3 or key2 <4) and key3 = 50; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 55.55 Parallel execute (1 workers) +2 SIMPLE t0 NULL ref i1,i2,i3 i3 4 const # 55.55 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`key1` AS `key1`,`test`.`t0`.`key2` AS `key2`,`test`.`t0`.`key3` AS `key3`,`test`.`t0`.`key4` AS `key4`,`test`.`t0`.`key5` AS `key5`,`test`.`t0`.`key6` AS `key6`,`test`.`t0`.`key7` AS `key7`,`test`.`t0`.`key8` AS `key8` from `test`.`t0` where ((`test`.`t0`.`key3` = 50) and ((`test`.`t0`.`key1` < 3) or (`test`.`t0`.`key2` < 4))) +explain select * from t0 use index (i1,i2) where (key1 < 2 or key2 <3) and key3 = 50; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL index_merge i1,i2 i1,i2 4,4 NULL # 1.67 Using sort_union(i1,i2); Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`key1` AS `key1`,`test`.`t0`.`key2` AS `key2`,`test`.`t0`.`key3` AS `key3`,`test`.`t0`.`key4` AS `key4`,`test`.`t0`.`key5` AS `key5`,`test`.`t0`.`key6` AS `key6`,`test`.`t0`.`key7` AS `key7`,`test`.`t0`.`key8` AS `key8` from `test`.`t0` USE INDEX (`i2`) USE INDEX (`i1`) where ((`test`.`t0`.`key3` = 50) and ((`test`.`t0`.`key1` < 2) or (`test`.`t0`.`key2` < 3))) +explain select * from t0 where (key1 > 1 or key2 > 2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 55.55 Parallel execute (4 workers) +2 SIMPLE t0 NULL ALL i1,i2 NULL NULL NULL # 55.55 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`key1` AS `key1`,`test`.`t0`.`key2` AS `key2`,`test`.`t0`.`key3` AS `key3`,`test`.`t0`.`key4` AS `key4`,`test`.`t0`.`key5` AS `key5`,`test`.`t0`.`key6` AS `key6`,`test`.`t0`.`key7` AS `key7`,`test`.`t0`.`key8` AS `key8` from `test`.`t0` where ((`test`.`t0`.`key1` > 1) or (`test`.`t0`.`key2` > 2)) +explain select * from t0 force index (i1,i2) where (key1 > 1 or key2 > 2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL index_merge i1,i2 i1,i2 4,4 NULL # 100.00 Using sort_union(i1,i2); Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`key1` AS `key1`,`test`.`t0`.`key2` AS `key2`,`test`.`t0`.`key3` AS `key3`,`test`.`t0`.`key4` AS `key4`,`test`.`t0`.`key5` AS `key5`,`test`.`t0`.`key6` AS `key6`,`test`.`t0`.`key7` AS `key7`,`test`.`t0`.`key8` AS `key8` from `test`.`t0` FORCE INDEX (`i2`) FORCE INDEX (`i1`) where ((`test`.`t0`.`key1` > 1) or (`test`.`t0`.`key2` > 2)) +# 4. Check if conjuncts are grouped by keyuse +explain +select * from t0 where key1<2 or key2<3 or (key1>5 and key1<7) or +(key1>10 and key1<12) or (key2>100 and key2<102); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL index_merge i1,i2 i1,i2 4,4 NULL # 100.00 Using sort_union(i1,i2); Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`key1` AS `key1`,`test`.`t0`.`key2` AS `key2`,`test`.`t0`.`key3` AS `key3`,`test`.`t0`.`key4` AS `key4`,`test`.`t0`.`key5` AS `key5`,`test`.`t0`.`key6` AS `key6`,`test`.`t0`.`key7` AS `key7`,`test`.`t0`.`key8` AS `key8` from `test`.`t0` where ((`test`.`t0`.`key1` < 2) or (`test`.`t0`.`key2` < 3) or ((`test`.`t0`.`key1` > 5) and (`test`.`t0`.`key1` < 7)) or ((`test`.`t0`.`key1` > 10) and (`test`.`t0`.`key1` < 12)) or ((`test`.`t0`.`key2` > 100) and (`test`.`t0`.`key2` < 102))) +# 5. Check index_merge with conjuncts that are always true/false +# verify fallback to "range" if there is only one non-confluent condition +explain select * from t0 where key2 = 45 or key1 <=> null; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (1 workers) +2 SIMPLE t0 NULL range i1,i2 i2 4 NULL # 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`key1` AS `key1`,`test`.`t0`.`key2` AS `key2`,`test`.`t0`.`key3` AS `key3`,`test`.`t0`.`key4` AS `key4`,`test`.`t0`.`key5` AS `key5`,`test`.`t0`.`key6` AS `key6`,`test`.`t0`.`key7` AS `key7`,`test`.`t0`.`key8` AS `key8` from `test`.`t0` where ((`test`.`t0`.`key2` = 45) or (`test`.`t0`.`key1` <=> NULL)) +explain select * from t0 where key2 = 45 or key1 is not null; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (4 workers) +2 SIMPLE t0 NULL ALL NULL NULL NULL NULL # 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`key1` AS `key1`,`test`.`t0`.`key2` AS `key2`,`test`.`t0`.`key3` AS `key3`,`test`.`t0`.`key4` AS `key4`,`test`.`t0`.`key5` AS `key5`,`test`.`t0`.`key6` AS `key6`,`test`.`t0`.`key7` AS `key7`,`test`.`t0`.`key8` AS `key8` from `test`.`t0` where true +explain select * from t0 where key2 = 45 or key1 is null; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (1 workers) +2 SIMPLE t0 NULL ref i2 i2 4 const # 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`key1` AS `key1`,`test`.`t0`.`key2` AS `key2`,`test`.`t0`.`key3` AS `key3`,`test`.`t0`.`key4` AS `key4`,`test`.`t0`.`key5` AS `key5`,`test`.`t0`.`key6` AS `key6`,`test`.`t0`.`key7` AS `key7`,`test`.`t0`.`key8` AS `key8` from `test`.`t0` where (`test`.`t0`.`key2` = 45) +# the last conj. is always false and will be discarded +explain select * from t0 where key2=10 or key3=3 or key4 <=> null; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL index_merge i2,i3,i4 i2,i3 4,4 NULL # 100.00 Using union(i2,i3); Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`key1` AS `key1`,`test`.`t0`.`key2` AS `key2`,`test`.`t0`.`key3` AS `key3`,`test`.`t0`.`key4` AS `key4`,`test`.`t0`.`key5` AS `key5`,`test`.`t0`.`key6` AS `key6`,`test`.`t0`.`key7` AS `key7`,`test`.`t0`.`key8` AS `key8` from `test`.`t0` where ((`test`.`t0`.`key2` = 10) or (`test`.`t0`.`key3` = 3) or (`test`.`t0`.`key4` <=> NULL)) +# the last conj. is always true and will cause 'all' scan +explain select * from t0 where key2=10 or key3=3 or key4 is null; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL index_merge i2,i3 i2,i3 4,4 NULL # 100.00 Using union(i2,i3); Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`key1` AS `key1`,`test`.`t0`.`key2` AS `key2`,`test`.`t0`.`key3` AS `key3`,`test`.`t0`.`key4` AS `key4`,`test`.`t0`.`key5` AS `key5`,`test`.`t0`.`key6` AS `key6`,`test`.`t0`.`key7` AS `key7`,`test`.`t0`.`key8` AS `key8` from `test`.`t0` where ((`test`.`t0`.`key2` = 10) or (`test`.`t0`.`key3` = 3)) +# some more complicated cases +explain select key1 from t0 where (key1 <=> null) or (key2 < 2) or +(key3=10) or (key4 <=> null); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL index_merge i1,i2,i3,i4 i2,i3 4,4 NULL # 100.00 Using sort_union(i2,i3); Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`key1` AS `key1` from `test`.`t0` where ((`test`.`t0`.`key1` <=> NULL) or (`test`.`t0`.`key2` < 2) or (`test`.`t0`.`key3` = 10) or (`test`.`t0`.`key4` <=> NULL)) +explain select key1 from t0 where (key1 <=> null) or (key1 < 5) or +(key3=10) or (key4 <=> null); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL index_merge i1,i3,i4 i1,i3 4,4 NULL # 100.00 Using sort_union(i1,i3); Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`key1` AS `key1` from `test`.`t0` where ((`test`.`t0`.`key1` <=> NULL) or (`test`.`t0`.`key1` < 5) or (`test`.`t0`.`key3` = 10) or (`test`.`t0`.`key4` <=> NULL)) +# 6.Several ways to do index_merge, (ignored) index_merge vs. range +explain select * from t0 where +(key1 < 2 or key2 < 2) and (key3 < 3 or key4 < 3) and (key5 < 5 or key6 < 5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL index_merge i1,i2,i3,i4,i5,i6 i1,i2 4,4 NULL # 30.86 Using sort_union(i1,i2); Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`key1` AS `key1`,`test`.`t0`.`key2` AS `key2`,`test`.`t0`.`key3` AS `key3`,`test`.`t0`.`key4` AS `key4`,`test`.`t0`.`key5` AS `key5`,`test`.`t0`.`key6` AS `key6`,`test`.`t0`.`key7` AS `key7`,`test`.`t0`.`key8` AS `key8` from `test`.`t0` where (((`test`.`t0`.`key1` < 2) or (`test`.`t0`.`key2` < 2)) and ((`test`.`t0`.`key3` < 3) or (`test`.`t0`.`key4` < 3)) and ((`test`.`t0`.`key5` < 5) or (`test`.`t0`.`key6` < 5))) +explain +select * from t0 where (key1 < 2 or key2 < 4) and (key1 < 5 or key3 < 3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL index_merge i1,i2,i3 i1,i2 4,4 NULL # 100.00 Using sort_union(i1,i2); Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`key1` AS `key1`,`test`.`t0`.`key2` AS `key2`,`test`.`t0`.`key3` AS `key3`,`test`.`t0`.`key4` AS `key4`,`test`.`t0`.`key5` AS `key5`,`test`.`t0`.`key6` AS `key6`,`test`.`t0`.`key7` AS `key7`,`test`.`t0`.`key8` AS `key8` from `test`.`t0` where (((`test`.`t0`.`key1` < 2) or (`test`.`t0`.`key2` < 4)) and ((`test`.`t0`.`key1` < 5) or (`test`.`t0`.`key3` < 3))) +select * from t0 where (key1 < 2 or key2 < 4) and (key1 < 5 or key3 < 3); +key1 key2 key3 key4 key5 key6 key7 key8 +1 1 1 1 1 1 1 1023 +2 2 2 2 2 2 2 1022 +3 3 3 3 3 3 3 1021 +explain select * from t0 where +(key1 < 3 or key2 < 2) and (key3 < 3 or key4 < 3) and (key5 < 2 or key6 < 2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL index_merge i1,i2,i3,i4,i5,i6 i5,i6 4,4 NULL # 30.86 Using sort_union(i5,i6); Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`key1` AS `key1`,`test`.`t0`.`key2` AS `key2`,`test`.`t0`.`key3` AS `key3`,`test`.`t0`.`key4` AS `key4`,`test`.`t0`.`key5` AS `key5`,`test`.`t0`.`key6` AS `key6`,`test`.`t0`.`key7` AS `key7`,`test`.`t0`.`key8` AS `key8` from `test`.`t0` where (((`test`.`t0`.`key1` < 3) or (`test`.`t0`.`key2` < 2)) and ((`test`.`t0`.`key3` < 3) or (`test`.`t0`.`key4` < 3)) and ((`test`.`t0`.`key5` < 2) or (`test`.`t0`.`key6` < 2))) +explain select * from t0 where +(key1 < 3 or key2 < 3) and (key3 < 70); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL index_merge i1,i2,i3 i1,i2 4,4 NULL # 6.74 Using sort_union(i1,i2); Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`key1` AS `key1`,`test`.`t0`.`key2` AS `key2`,`test`.`t0`.`key3` AS `key3`,`test`.`t0`.`key4` AS `key4`,`test`.`t0`.`key5` AS `key5`,`test`.`t0`.`key6` AS `key6`,`test`.`t0`.`key7` AS `key7`,`test`.`t0`.`key8` AS `key8` from `test`.`t0` where (((`test`.`t0`.`key1` < 3) or (`test`.`t0`.`key2` < 3)) and (`test`.`t0`.`key3` < 70)) +explain select * from t0 where +(key1 < 3 or key2 < 3) and (key3 < 1000); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL index_merge i1,i2,i3 i1,i2 4,4 NULL # 97.56 Using sort_union(i1,i2); Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`key1` AS `key1`,`test`.`t0`.`key2` AS `key2`,`test`.`t0`.`key3` AS `key3`,`test`.`t0`.`key4` AS `key4`,`test`.`t0`.`key5` AS `key5`,`test`.`t0`.`key6` AS `key6`,`test`.`t0`.`key7` AS `key7`,`test`.`t0`.`key8` AS `key8` from `test`.`t0` where (((`test`.`t0`.`key1` < 3) or (`test`.`t0`.`key2` < 3)) and (`test`.`t0`.`key3` < 1000)) +# 7. Complex cases +# tree_or(List, range SEL_TREE). +explain select * from t0 where +((key1 < 3 or key2 < 3) and (key2 <4 or key3 < 3)) +or +key2 > 4; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 53.90 Parallel execute (4 workers) +2 SIMPLE t0 NULL ALL i1,i2,i3 NULL NULL NULL # 53.90 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`key1` AS `key1`,`test`.`t0`.`key2` AS `key2`,`test`.`t0`.`key3` AS `key3`,`test`.`t0`.`key4` AS `key4`,`test`.`t0`.`key5` AS `key5`,`test`.`t0`.`key6` AS `key6`,`test`.`t0`.`key7` AS `key7`,`test`.`t0`.`key8` AS `key8` from `test`.`t0` where ((((`test`.`t0`.`key1` < 3) or (`test`.`t0`.`key2` < 3)) and ((`test`.`t0`.`key2` < 4) or (`test`.`t0`.`key3` < 3))) or (`test`.`t0`.`key2` > 4)) +explain select * from t0 where +((key1 < 4 or key2 < 4) and (key2 <4 or key3 < 3)) +or +key1 < 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL index_merge i1,i2,i3 i1,i2 4,4 NULL # 100.00 Using sort_union(i1,i2); Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`key1` AS `key1`,`test`.`t0`.`key2` AS `key2`,`test`.`t0`.`key3` AS `key3`,`test`.`t0`.`key4` AS `key4`,`test`.`t0`.`key5` AS `key5`,`test`.`t0`.`key6` AS `key6`,`test`.`t0`.`key7` AS `key7`,`test`.`t0`.`key8` AS `key8` from `test`.`t0` where ((((`test`.`t0`.`key1` < 4) or (`test`.`t0`.`key2` < 4)) and ((`test`.`t0`.`key2` < 4) or (`test`.`t0`.`key3` < 3))) or (`test`.`t0`.`key1` < 5)) +select * from t0 where +((key1 < 4 or key2 < 4) and (key2 <4 or key3 < 3)) +or +key1 < 5; +key1 key2 key3 key4 key5 key6 key7 key8 +1 1 1 1 1 1 1 1023 +2 2 2 2 2 2 2 1022 +3 3 3 3 3 3 3 1021 +4 4 4 4 4 4 4 1020 +# tree_or(List, List). +explain select * from t0 where +((key1 < 2 or key2 < 2) and (key3 <4 or key5 < 3)) +or +((key5 < 3 or key6 < 3) and (key7 <3 or key8 < 3)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL index_merge i1,i2,i3,i5,i6,i7,i8 i1,i2,i5,i6 4,4,4,4 NULL # 100.00 Using sort_union(i1,i2,i5,i6); Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`key1` AS `key1`,`test`.`t0`.`key2` AS `key2`,`test`.`t0`.`key3` AS `key3`,`test`.`t0`.`key4` AS `key4`,`test`.`t0`.`key5` AS `key5`,`test`.`t0`.`key6` AS `key6`,`test`.`t0`.`key7` AS `key7`,`test`.`t0`.`key8` AS `key8` from `test`.`t0` where ((((`test`.`t0`.`key1` < 2) or (`test`.`t0`.`key2` < 2)) and ((`test`.`t0`.`key3` < 4) or (`test`.`t0`.`key5` < 3))) or (((`test`.`t0`.`key5` < 3) or (`test`.`t0`.`key6` < 3)) and ((`test`.`t0`.`key7` < 3) or (`test`.`t0`.`key8` < 3)))) +explain select * from t0 where +((key3 <3 or key5 < 4) and (key1 < 3 or key2 < 3)) +or +((key7 <5 or key8 < 3) and (key5 < 4 or key6 < 4)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL index_merge i1,i2,i3,i5,i6,i7,i8 i3,i5,i7,i8 4,4,4,4 NULL # 100.00 Using sort_union(i3,i5,i7,i8); Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`key1` AS `key1`,`test`.`t0`.`key2` AS `key2`,`test`.`t0`.`key3` AS `key3`,`test`.`t0`.`key4` AS `key4`,`test`.`t0`.`key5` AS `key5`,`test`.`t0`.`key6` AS `key6`,`test`.`t0`.`key7` AS `key7`,`test`.`t0`.`key8` AS `key8` from `test`.`t0` where ((((`test`.`t0`.`key3` < 3) or (`test`.`t0`.`key5` < 4)) and ((`test`.`t0`.`key1` < 3) or (`test`.`t0`.`key2` < 3))) or (((`test`.`t0`.`key7` < 5) or (`test`.`t0`.`key8` < 3)) and ((`test`.`t0`.`key5` < 4) or (`test`.`t0`.`key6` < 4)))) +explain select * from t0 where +((key3 <3 or key5 < 4) and (key1 < 3 or key2 < 4)) +or +((key3 <4 or key5 < 2) and (key5 < 5 or key6 < 3)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL index_merge i1,i2,i3,i5,i6 i3,i5 4,4 NULL # 100.00 Using sort_union(i3,i5); Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`key1` AS `key1`,`test`.`t0`.`key2` AS `key2`,`test`.`t0`.`key3` AS `key3`,`test`.`t0`.`key4` AS `key4`,`test`.`t0`.`key5` AS `key5`,`test`.`t0`.`key6` AS `key6`,`test`.`t0`.`key7` AS `key7`,`test`.`t0`.`key8` AS `key8` from `test`.`t0` where ((((`test`.`t0`.`key3` < 3) or (`test`.`t0`.`key5` < 4)) and ((`test`.`t0`.`key1` < 3) or (`test`.`t0`.`key2` < 4))) or (((`test`.`t0`.`key3` < 4) or (`test`.`t0`.`key5` < 2)) and ((`test`.`t0`.`key5` < 5) or (`test`.`t0`.`key6` < 3)))) +explain select * from t0 where +((key3 <4 or key5 < 3) and (key1 < 3 or key2 < 3)) +or +(((key3 <5 and key7 < 5) or key5 < 2) and (key5 < 4 or key6 < 4)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL index_merge i1,i2,i3,i5,i6,i7 i3,i5 4,4 NULL # 100.00 Using sort_union(i3,i5); Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`key1` AS `key1`,`test`.`t0`.`key2` AS `key2`,`test`.`t0`.`key3` AS `key3`,`test`.`t0`.`key4` AS `key4`,`test`.`t0`.`key5` AS `key5`,`test`.`t0`.`key6` AS `key6`,`test`.`t0`.`key7` AS `key7`,`test`.`t0`.`key8` AS `key8` from `test`.`t0` where ((((`test`.`t0`.`key3` < 4) or (`test`.`t0`.`key5` < 3)) and ((`test`.`t0`.`key1` < 3) or (`test`.`t0`.`key2` < 3))) or ((((`test`.`t0`.`key3` < 5) and (`test`.`t0`.`key7` < 5)) or (`test`.`t0`.`key5` < 2)) and ((`test`.`t0`.`key5` < 4) or (`test`.`t0`.`key6` < 4)))) +explain select * from t0 where +((key3 <5 or key5 < 4) and (key1 < 4 or key2 < 4)) +or +((key3 >5 or key5 < 2) and (key5 < 5 or key6 < 6)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 52.20 Parallel execute (4 workers) +2 SIMPLE t0 NULL ALL i1,i2,i3,i5,i6 NULL NULL NULL # 52.20 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`key1` AS `key1`,`test`.`t0`.`key2` AS `key2`,`test`.`t0`.`key3` AS `key3`,`test`.`t0`.`key4` AS `key4`,`test`.`t0`.`key5` AS `key5`,`test`.`t0`.`key6` AS `key6`,`test`.`t0`.`key7` AS `key7`,`test`.`t0`.`key8` AS `key8` from `test`.`t0` where ((((`test`.`t0`.`key3` < 5) or (`test`.`t0`.`key5` < 4)) and ((`test`.`t0`.`key1` < 4) or (`test`.`t0`.`key2` < 4))) or (((`test`.`t0`.`key3` > 5) or (`test`.`t0`.`key5` < 2)) and ((`test`.`t0`.`key5` < 5) or (`test`.`t0`.`key6` < 6)))) +explain select * from t0 force index(i1, i2, i3, i4, i5, i6 ) where +((key3 <3 or key5 < 4) and (key1 < 3 or key2 < 3)) +or +((key3 >4 or key5 < 2) and (key5 < 5 or key6 < 4)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL index_merge i1,i2,i3,i5,i6 i3,i5 4,4 NULL # 100.00 Using sort_union(i3,i5); Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`key1` AS `key1`,`test`.`t0`.`key2` AS `key2`,`test`.`t0`.`key3` AS `key3`,`test`.`t0`.`key4` AS `key4`,`test`.`t0`.`key5` AS `key5`,`test`.`t0`.`key6` AS `key6`,`test`.`t0`.`key7` AS `key7`,`test`.`t0`.`key8` AS `key8` from `test`.`t0` FORCE INDEX (`i6`) FORCE INDEX (`i5`) FORCE INDEX (`i4`) FORCE INDEX (`i3`) FORCE INDEX (`i2`) FORCE INDEX (`i1`) where ((((`test`.`t0`.`key3` < 3) or (`test`.`t0`.`key5` < 4)) and ((`test`.`t0`.`key1` < 3) or (`test`.`t0`.`key2` < 3))) or (((`test`.`t0`.`key3` > 4) or (`test`.`t0`.`key5` < 2)) and ((`test`.`t0`.`key5` < 5) or (`test`.`t0`.`key6` < 4)))) +# Can't merge any indexes here (predicate on key3 is always true) +explain select * from t0 force index(i1, i2, i3, i4, i5, i6 ) where +((key3 <5 or key5 < 4) and (key1 < 4 or key2 < 4)) +or +((key3 >=5 or key5 < 2) and (key5 < 5 or key6 < 6)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 52.20 Parallel execute (4 workers) +2 SIMPLE t0 NULL ALL i1,i2,i3,i5,i6 NULL NULL NULL # 52.20 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`key1` AS `key1`,`test`.`t0`.`key2` AS `key2`,`test`.`t0`.`key3` AS `key3`,`test`.`t0`.`key4` AS `key4`,`test`.`t0`.`key5` AS `key5`,`test`.`t0`.`key6` AS `key6`,`test`.`t0`.`key7` AS `key7`,`test`.`t0`.`key8` AS `key8` from `test`.`t0` FORCE INDEX (`i6`) FORCE INDEX (`i5`) FORCE INDEX (`i4`) FORCE INDEX (`i3`) FORCE INDEX (`i2`) FORCE INDEX (`i1`) where ((((`test`.`t0`.`key3` < 5) or (`test`.`t0`.`key5` < 4)) and ((`test`.`t0`.`key1` < 4) or (`test`.`t0`.`key2` < 4))) or (((`test`.`t0`.`key3` >= 5) or (`test`.`t0`.`key5` < 2)) and ((`test`.`t0`.`key5` < 5) or (`test`.`t0`.`key6` < 6)))) +# 8. Verify that "order by" after index merge uses filesort +select * from t0 where key1 < 3 or key8 < 2 order by key1; +key1 key2 key3 key4 key5 key6 key7 key8 +1 1 1 1 1 1 1 1023 +2 2 2 2 2 2 2 1022 +1023 1023 1023 1023 1023 1023 1023 1 +1024 1024 1024 1024 1024 1024 1024 0 +explain +select * from t0 where key1 < 3 or key8 < 2 order by key1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL index_merge i1,i8 i1,i8 4,4 NULL # 100.00 Using sort_union(i1,i8); Using where; Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`key1` AS `key1`,`test`.`t0`.`key2` AS `key2`,`test`.`t0`.`key3` AS `key3`,`test`.`t0`.`key4` AS `key4`,`test`.`t0`.`key5` AS `key5`,`test`.`t0`.`key6` AS `key6`,`test`.`t0`.`key7` AS `key7`,`test`.`t0`.`key8` AS `key8` from `test`.`t0` where ((`test`.`t0`.`key1` < 3) or (`test`.`t0`.`key8` < 2)) order by `test`.`t0`.`key1` +# 9. Check that index_merge cost is compared to 'index' where possible +create table t2 like t0; +insert into t2 select * from t0; +alter table t2 add index i1_3(key1, key3); +alter table t2 add index i2_3(key2, key3); +alter table t2 drop index i1; +alter table t2 drop index i2; +alter table t2 add index i321(key3, key2, key1); +# index_merge vs 'index', index_merge is better. +explain select key3 from t2 where key1 = 100 or key2 = 100; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index_merge i1_3,i2_3 i1_3,i2_3 4,4 NULL # 100.00 Using sort_union(i1_3,i2_3); Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`key3` AS `key3` from `test`.`t2` where ((`test`.`t2`.`key1` = 100) or (`test`.`t2`.`key2` = 100)) +# index_merge vs 'index', 'index' is better. +explain select key3 from t2 where key1 <100 or key2 < 100; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 55.55 Parallel execute (2 workers) +2 SIMPLE t2 NULL index i1_3,i2_3 i321 12 NULL # 55.55 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`key3` AS `key3` from `test`.`t2` where ((`test`.`t2`.`key1` < 100) or (`test`.`t2`.`key2` < 100)) +# index_merge vs 'all', index_merge is better. +explain select key7 from t2 where key1 <100 or key2 < 100; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 55.55 Parallel execute (4 workers) +2 SIMPLE t2 NULL ALL i1_3,i2_3 NULL NULL NULL # 55.55 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`key7` AS `key7` from `test`.`t2` where ((`test`.`t2`.`key1` < 100) or (`test`.`t2`.`key2` < 100)) +# 10. Multipart keys. +create table t4 ( +key1a int not null, +key1b int not null, +key2 int not null, +key2_1 int not null, +key2_2 int not null, +key3 int not null, +index i1a (key1a, key1b), +index i1b (key1b, key1a), +index i2_1(key2, key2_1), +index i2_2(key2, key2_1) +); +Warnings: +Warning 1831 Duplicate index 'i2_2' defined on the table 'test.t4'. This is deprecated and will be disallowed in a future release. +insert into t4 select key1,key1,key1 div 10, key1 % 10, key1 % 10, key1 from t0; +# the following will be handled by index_merge: +select * from t4 where key1a = 3 or key1b = 4; +key1a key1b key2 key2_1 key2_2 key3 +3 3 0 3 3 3 +4 4 0 4 4 4 +explain select * from t4 where key1a = 3 or key1b = 4; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t4 NULL index_merge i1a,i1b i1a,i1b 4,4 NULL 2 100.00 Using sort_union(i1a,i1b); Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`key1a` AS `key1a`,`test`.`t4`.`key1b` AS `key1b`,`test`.`t4`.`key2` AS `key2`,`test`.`t4`.`key2_1` AS `key2_1`,`test`.`t4`.`key2_2` AS `key2_2`,`test`.`t4`.`key3` AS `key3` from `test`.`t4` where ((`test`.`t4`.`key1a` = 3) or (`test`.`t4`.`key1b` = 4)) +# and the following will not +explain select * from t4 where key2 = 1 and (key2_1 = 1 or key3 = 5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 19.00 Parallel execute (1 workers) +2 SIMPLE t4 NULL ref i2_1,i2_2 i2_1 4 const 10 19.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`key1a` AS `key1a`,`test`.`t4`.`key1b` AS `key1b`,`test`.`t4`.`key2` AS `key2`,`test`.`t4`.`key2_1` AS `key2_1`,`test`.`t4`.`key2_2` AS `key2_2`,`test`.`t4`.`key3` AS `key3` from `test`.`t4` where ((`test`.`t4`.`key2` = 1) and ((`test`.`t4`.`key2_1` = 1) or (`test`.`t4`.`key3` = 5))) +explain select * from t4 where key2 = 1 and (key2_1 = 1 or key2_2 = 5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 19.00 Parallel execute (1 workers) +2 SIMPLE t4 NULL ref i2_1,i2_2 i2_1 4 const 10 19.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`key1a` AS `key1a`,`test`.`t4`.`key1b` AS `key1b`,`test`.`t4`.`key2` AS `key2`,`test`.`t4`.`key2_1` AS `key2_1`,`test`.`t4`.`key2_2` AS `key2_2`,`test`.`t4`.`key3` AS `key3` from `test`.`t4` where ((`test`.`t4`.`key2` = 1) and ((`test`.`t4`.`key2_1` = 1) or (`test`.`t4`.`key2_2` = 5))) +explain select * from t4 where key2_1 = 1 or key2_2 = 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 19.00 Parallel execute (4 workers) +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL # 19.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`key1a` AS `key1a`,`test`.`t4`.`key1b` AS `key1b`,`test`.`t4`.`key2` AS `key2`,`test`.`t4`.`key2_1` AS `key2_1`,`test`.`t4`.`key2_2` AS `key2_2`,`test`.`t4`.`key3` AS `key3` from `test`.`t4` where ((`test`.`t4`.`key2_1` = 1) or (`test`.`t4`.`key2_2` = 5)) +# 11. Multitable selects +create table t1 like t0; +insert into t1 select * from t0; +# index_merge on first table in join +explain select * from t0 left join t1 on (t0.key1=t1.key1) +where t0.key1=3 or t0.key2=4; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL index_merge i1,i2 i1,i2 4,4 NULL 2 100.00 Using union(i1,i2); Using where +1 SIMPLE t1 NULL ref i1 i1 4 test.t0.key1 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`key1` AS `key1`,`test`.`t0`.`key2` AS `key2`,`test`.`t0`.`key3` AS `key3`,`test`.`t0`.`key4` AS `key4`,`test`.`t0`.`key5` AS `key5`,`test`.`t0`.`key6` AS `key6`,`test`.`t0`.`key7` AS `key7`,`test`.`t0`.`key8` AS `key8`,`test`.`t1`.`key1` AS `key1`,`test`.`t1`.`key2` AS `key2`,`test`.`t1`.`key3` AS `key3`,`test`.`t1`.`key4` AS `key4`,`test`.`t1`.`key5` AS `key5`,`test`.`t1`.`key6` AS `key6`,`test`.`t1`.`key7` AS `key7`,`test`.`t1`.`key8` AS `key8` from `test`.`t0` left join `test`.`t1` on((`test`.`t1`.`key1` = `test`.`t0`.`key1`)) where ((`test`.`t0`.`key1` = 3) or (`test`.`t0`.`key2` = 4)) +select * from t0 left join t1 on (t0.key1=t1.key1) +where t0.key1=3 or t0.key2=4; +key1 key2 key3 key4 key5 key6 key7 key8 key1 key2 key3 key4 key5 key6 key7 key8 +3 3 3 3 3 3 3 1021 3 3 3 3 3 3 3 1021 +4 4 4 4 4 4 4 1020 4 4 4 4 4 4 4 1020 +explain +select * from t0,t1 where (t0.key1=t1.key1) and ( t0.key1=3 or t0.key2=4); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL index_merge i1,i2 i1,i2 4,4 NULL 2 100.00 Using union(i1,i2); Using where +1 SIMPLE t1 NULL ref i1 i1 4 test.t0.key1 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`key1` AS `key1`,`test`.`t0`.`key2` AS `key2`,`test`.`t0`.`key3` AS `key3`,`test`.`t0`.`key4` AS `key4`,`test`.`t0`.`key5` AS `key5`,`test`.`t0`.`key6` AS `key6`,`test`.`t0`.`key7` AS `key7`,`test`.`t0`.`key8` AS `key8`,`test`.`t1`.`key1` AS `key1`,`test`.`t1`.`key2` AS `key2`,`test`.`t1`.`key3` AS `key3`,`test`.`t1`.`key4` AS `key4`,`test`.`t1`.`key5` AS `key5`,`test`.`t1`.`key6` AS `key6`,`test`.`t1`.`key7` AS `key7`,`test`.`t1`.`key8` AS `key8` from `test`.`t0` join `test`.`t1` where ((`test`.`t1`.`key1` = `test`.`t0`.`key1`) and ((`test`.`t0`.`key1` = 3) or (`test`.`t0`.`key2` = 4))) +# index_merge vs. ref +# index_merge vs. ref +explain +select * from t0,t1 where (t0.key1=t1.key1) and +(t0.key1=3 or t0.key2<4) and t1.key1=2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 5.00 Parallel execute (1 workers) +2 SIMPLE t0 NULL ref i1,i2 i1 4 const 1 5.00 Using where +2 SIMPLE t1 NULL ref i1 i1 4 const 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`key1` AS `key1`,`test`.`t0`.`key2` AS `key2`,`test`.`t0`.`key3` AS `key3`,`test`.`t0`.`key4` AS `key4`,`test`.`t0`.`key5` AS `key5`,`test`.`t0`.`key6` AS `key6`,`test`.`t0`.`key7` AS `key7`,`test`.`t0`.`key8` AS `key8`,`test`.`t1`.`key1` AS `key1`,`test`.`t1`.`key2` AS `key2`,`test`.`t1`.`key3` AS `key3`,`test`.`t1`.`key4` AS `key4`,`test`.`t1`.`key5` AS `key5`,`test`.`t1`.`key6` AS `key6`,`test`.`t1`.`key7` AS `key7`,`test`.`t1`.`key8` AS `key8` from `test`.`t0` join `test`.`t1` where ((`test`.`t0`.`key1` = 2) and (`test`.`t1`.`key1` = 2) and (`test`.`t0`.`key2` < 4)) +# index_merge on second table in join +explain select * from t0,t1 where t0.key1 = 5 and +(t1.key1 = t0.key1 or t1.key8 = t0.key1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t0 NULL ref i1 i1 4 const 1 100.00 NULL +2 SIMPLE t1 NULL index_merge i1,i8 i1,i8 4,4 NULL 2 100.00 Using union(i1,i8); Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`key1` AS `key1`,`test`.`t0`.`key2` AS `key2`,`test`.`t0`.`key3` AS `key3`,`test`.`t0`.`key4` AS `key4`,`test`.`t0`.`key5` AS `key5`,`test`.`t0`.`key6` AS `key6`,`test`.`t0`.`key7` AS `key7`,`test`.`t0`.`key8` AS `key8`,`test`.`t1`.`key1` AS `key1`,`test`.`t1`.`key2` AS `key2`,`test`.`t1`.`key3` AS `key3`,`test`.`t1`.`key4` AS `key4`,`test`.`t1`.`key5` AS `key5`,`test`.`t1`.`key6` AS `key6`,`test`.`t1`.`key7` AS `key7`,`test`.`t1`.`key8` AS `key8` from `test`.`t0` join `test`.`t1` where ((`test`.`t0`.`key1` = 5) and ((`test`.`t1`.`key1` = 5) or (`test`.`t1`.`key8` = 5))) +# Fix for bug#1974 +explain select * from t0,t1 where t0.key1 < 3 and +(t1.key1 = t0.key1 or t1.key8 = t0.key1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (1 workers) +2 SIMPLE t0 NULL range i1 i1 4 NULL # 100.00 Using index condition +2 SIMPLE t1 NULL ALL i1,i8 NULL NULL NULL # 0.20 Range checked for each record (index map: 0x81) +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`key1` AS `key1`,`test`.`t0`.`key2` AS `key2`,`test`.`t0`.`key3` AS `key3`,`test`.`t0`.`key4` AS `key4`,`test`.`t0`.`key5` AS `key5`,`test`.`t0`.`key6` AS `key6`,`test`.`t0`.`key7` AS `key7`,`test`.`t0`.`key8` AS `key8`,`test`.`t1`.`key1` AS `key1`,`test`.`t1`.`key2` AS `key2`,`test`.`t1`.`key3` AS `key3`,`test`.`t1`.`key4` AS `key4`,`test`.`t1`.`key5` AS `key5`,`test`.`t1`.`key6` AS `key6`,`test`.`t1`.`key7` AS `key7`,`test`.`t1`.`key8` AS `key8` from `test`.`t0` join `test`.`t1` where ((`test`.`t0`.`key1` < 3) and ((`test`.`t1`.`key1` = `test`.`t0`.`key1`) or (`test`.`t1`.`key8` = `test`.`t0`.`key1`))) +# index_merge inside union +explain select * from t1 where key1=3 or key2=4 +union select * from t1 where key1<4 or key3=5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL index_merge i1,i2 i1,i2 4,4 NULL 2 100.00 Using union(i1,i2); Using where +2 UNION t1 NULL index_merge i1,i3 i1,i3 4,4 NULL 4 100.00 Using sort_union(i1,i3); Using where +NULL UNION RESULT NULL ALL NULL NULL NULL NULL NULL NULL Using temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`key1` AS `key1`,`test`.`t1`.`key2` AS `key2`,`test`.`t1`.`key3` AS `key3`,`test`.`t1`.`key4` AS `key4`,`test`.`t1`.`key5` AS `key5`,`test`.`t1`.`key6` AS `key6`,`test`.`t1`.`key7` AS `key7`,`test`.`t1`.`key8` AS `key8` from `test`.`t1` where ((`test`.`t1`.`key1` = 3) or (`test`.`t1`.`key2` = 4)) union /* select#2 */ select `test`.`t1`.`key1` AS `key1`,`test`.`t1`.`key2` AS `key2`,`test`.`t1`.`key3` AS `key3`,`test`.`t1`.`key4` AS `key4`,`test`.`t1`.`key5` AS `key5`,`test`.`t1`.`key6` AS `key6`,`test`.`t1`.`key7` AS `key7`,`test`.`t1`.`key8` AS `key8` from `test`.`t1` where ((`test`.`t1`.`key1` < 4) or (`test`.`t1`.`key3` = 5)) +# index merge in subselect +explain select * from (select * from t1 where key1 = 3 or key2 =3) as z where key8 >5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge i1,i2,i8 i1,i2 4,4 NULL 2 99.41 Using union(i1,i2); Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`key1` AS `key1`,`test`.`t1`.`key2` AS `key2`,`test`.`t1`.`key3` AS `key3`,`test`.`t1`.`key4` AS `key4`,`test`.`t1`.`key5` AS `key5`,`test`.`t1`.`key6` AS `key6`,`test`.`t1`.`key7` AS `key7`,`test`.`t1`.`key8` AS `key8` from `test`.`t1` where ((`test`.`t1`.`key8` > 5) and ((`test`.`t1`.`key1` = 3) or (`test`.`t1`.`key2` = 3))) +# 12. check for long index_merges. +create table t3 like t0; +insert into t3 select * from t0; +alter table t3 add key9 int not null, add index i9(key9); +alter table t3 add keyA int not null, add index iA(keyA); +alter table t3 add keyB int not null, add index iB(keyB); +alter table t3 add keyC int not null, add index iC(keyC); +update t3 set key9=key1,keyA=key1,keyB=key1,keyC=key1; +explain select * from t3 where +key1=1 or key2=2 or key3=3 or key4=4 or +key5=5 or key6=6 or key7=7 or key8=8 or +key9=9 or keyA=10 or keyB=11 or keyC=12; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL index_merge i1,i2,i3,i4,i5,i6,i7,i8,i9,iA,iB,iC i1,i2,i3,i4,i5,i6,i7,i8,i9,iA,iB,iC 4,4,4,4,4,4,4,4,4,4,4,4 NULL 12 100.00 Using union(i1,i2,i3,i4,i5,i6,i7,i8,i9,iA,iB,iC); Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`key1` AS `key1`,`test`.`t3`.`key2` AS `key2`,`test`.`t3`.`key3` AS `key3`,`test`.`t3`.`key4` AS `key4`,`test`.`t3`.`key5` AS `key5`,`test`.`t3`.`key6` AS `key6`,`test`.`t3`.`key7` AS `key7`,`test`.`t3`.`key8` AS `key8`,`test`.`t3`.`key9` AS `key9`,`test`.`t3`.`keyA` AS `keyA`,`test`.`t3`.`keyB` AS `keyB`,`test`.`t3`.`keyC` AS `keyC` from `test`.`t3` where ((`test`.`t3`.`key1` = 1) or (`test`.`t3`.`key2` = 2) or (`test`.`t3`.`key3` = 3) or (`test`.`t3`.`key4` = 4) or (`test`.`t3`.`key5` = 5) or (`test`.`t3`.`key6` = 6) or (`test`.`t3`.`key7` = 7) or (`test`.`t3`.`key8` = 8) or (`test`.`t3`.`key9` = 9) or (`test`.`t3`.`keyA` = 10) or (`test`.`t3`.`keyB` = 11) or (`test`.`t3`.`keyC` = 12)) +select * from t3 where +key1=1 or key2=2 or key3=3 or key4=4 or +key5=5 or key6=6 or key7=7 or key8=8 or +key9=9 or keyA=10 or keyB=11 or keyC=12; +key1 key2 key3 key4 key5 key6 key7 key8 key9 keyA keyB keyC +1 1 1 1 1 1 1 1023 1 1 1 1 +2 2 2 2 2 2 2 1022 2 2 2 2 +3 3 3 3 3 3 3 1021 3 3 3 3 +4 4 4 4 4 4 4 1020 4 4 4 4 +5 5 5 5 5 5 5 1019 5 5 5 5 +6 6 6 6 6 6 6 1018 6 6 6 6 +7 7 7 7 7 7 7 1017 7 7 7 7 +9 9 9 9 9 9 9 1015 9 9 9 9 +10 10 10 10 10 10 10 1014 10 10 10 10 +11 11 11 11 11 11 11 1013 11 11 11 11 +12 12 12 12 12 12 12 1012 12 12 12 12 +1016 1016 1016 1016 1016 1016 1016 8 1016 1016 1016 1016 +# Test for Bug#3183 +explain select * from t0 where key1 < 3 or key2 < 4; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL index_merge i1,i2 i1,i2 4,4 NULL 5 100.00 Using sort_union(i1,i2); Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`key1` AS `key1`,`test`.`t0`.`key2` AS `key2`,`test`.`t0`.`key3` AS `key3`,`test`.`t0`.`key4` AS `key4`,`test`.`t0`.`key5` AS `key5`,`test`.`t0`.`key6` AS `key6`,`test`.`t0`.`key7` AS `key7`,`test`.`t0`.`key8` AS `key8` from `test`.`t0` where ((`test`.`t0`.`key1` < 3) or (`test`.`t0`.`key2` < 4)) +# Bug#21277: InnoDB, wrong result set, index_merge strategy, +# second index not evaluated +select * from t0 where key1 < 3 or key2 < 4; +key1 key2 key3 key4 key5 key6 key7 key8 +1 1 1 1 1 1 1 1023 +2 2 2 2 2 2 2 1022 +3 3 3 3 3 3 3 1021 +update t0 set key8=123 where key1 < 3 or key2 < 4; +# Bug#21277: InnoDB, wrong result set, index_merge strategy, +# second index not evaluated +select * from t0 where key1 < 3 or key2 < 4; +key1 key2 key3 key4 key5 key6 key7 key8 +1 1 1 1 1 1 1 123 +2 2 2 2 2 2 2 123 +3 3 3 3 3 3 3 123 +delete from t0 where key1 < 3 or key2 < 4; +select * from t0 where key1 < 3 or key2 < 4; +key1 key2 key3 key4 key5 key6 key7 key8 +select count(*) from t0; +count(*) +1021 +# Test for BUG#4177 +drop table t4; +create table t4 (a int); +insert into t4 values (1),(4),(3); +set @save_join_buffer_size=@@join_buffer_size; +set join_buffer_size= 4096; +explain select max(a.key1 + b.key1 + a.key2 + b.key2 + a.key3 + b.key3 + a.key4 + b.key4 + a.key5 + b.key5) +from t0 as a force index(i1,i2), t0 as b force index (i1,i2) +where (a.key1 < 500000 or a.key2 < 3) +and (b.key1 < 500000 or b.key2 < 3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE a NULL index_merge i1,i2 i1,i2 4,4 NULL # 100.00 Using sort_union(i1,i2); Using where +1 SIMPLE b NULL index_merge i1,i2 i1,i2 4,4 NULL # 100.00 Using sort_union(i1,i2); Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select max((((((((((`test`.`a`.`key1` + `test`.`b`.`key1`) + `test`.`a`.`key2`) + `test`.`b`.`key2`) + `test`.`a`.`key3`) + `test`.`b`.`key3`) + `test`.`a`.`key4`) + `test`.`b`.`key4`) + `test`.`a`.`key5`) + `test`.`b`.`key5`)) AS `max(a.key1 + b.key1 + a.key2 + b.key2 + a.key3 + b.key3 + a.key4 + b.key4 + a.key5 + b.key5)` from `test`.`t0` `a` FORCE INDEX (`i2`) FORCE INDEX (`i1`) join `test`.`t0` `b` FORCE INDEX (`i2`) FORCE INDEX (`i1`) where (((`test`.`a`.`key1` < 500000) or (`test`.`a`.`key2` < 3)) and ((`test`.`b`.`key1` < 500000) or (`test`.`b`.`key2` < 3))) +select max(a.key1 + b.key1 + a.key2 + b.key2 + a.key3 + b.key3 + a.key4 + b.key4 + a.key5 + b.key5) +from t0 as a force index(i1,i2), t0 as b force index (i1,i2) +where (a.key1 < 500000 or a.key2 < 3) +and (b.key1 < 500000 or b.key2 < 3); +max(a.key1 + b.key1 + a.key2 + b.key2 + a.key3 + b.key3 + a.key4 + b.key4 + a.key5 + b.key5) +10240 +update t0 set key1=1; +explain select max(a.key1 + b.key1 + a.key2 + b.key2 + a.key3 + b.key3 + a.key4 + b.key4 + a.key5 + b.key5) +from t0 as a force index(i1,i2), t0 as b force index (i1,i2) +where (a.key1 = 1 or a.key2 = 1) +and (b.key1 = 1 or b.key2 = 1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE a NULL index_merge i1,i2 i1,i2 4,4 NULL # # Using union(i1,i2); Using where +1 SIMPLE b NULL index_merge i1,i2 i1,i2 4,4 NULL # # Using union(i1,i2); Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select max((((((((((`test`.`a`.`key1` + `test`.`b`.`key1`) + `test`.`a`.`key2`) + `test`.`b`.`key2`) + `test`.`a`.`key3`) + `test`.`b`.`key3`) + `test`.`a`.`key4`) + `test`.`b`.`key4`) + `test`.`a`.`key5`) + `test`.`b`.`key5`)) AS `max(a.key1 + b.key1 + a.key2 + b.key2 + a.key3 + b.key3 + a.key4 + b.key4 + a.key5 + b.key5)` from `test`.`t0` `a` FORCE INDEX (`i2`) FORCE INDEX (`i1`) join `test`.`t0` `b` FORCE INDEX (`i2`) FORCE INDEX (`i1`) where (((`test`.`a`.`key1` = 1) or (`test`.`a`.`key2` = 1)) and ((`test`.`b`.`key1` = 1) or (`test`.`b`.`key2` = 1))) +select max(a.key1 + b.key1 + a.key2 + b.key2 + a.key3 + b.key3 + a.key4 + b.key4 + a.key5 + b.key5) +from t0 as a force index(i1,i2), t0 as b force index (i1,i2) +where (a.key1 = 1 or a.key2 = 1) +and (b.key1 = 1 or b.key2 = 1); +max(a.key1 + b.key1 + a.key2 + b.key2 + a.key3 + b.key3 + a.key4 + b.key4 + a.key5 + b.key5) +8194 +alter table t0 add filler1 char(200), add filler2 char(200), add filler3 char(200); +update t0 set key2=1, key3=1, key4=1, key5=1,key6=1,key7=1 where key7 < 500; +# The next query will not use index i7 in intersection if the OS doesn't +# support file sizes > 2GB. (ha_myisam::ref_length depends on this and index +# scan cost estimates depend on ha_myisam::ref_length) +select max(a.key1 + b.key1 + a.key2 + b.key2 + a.key3 + b.key3 + a.key4 + b.key4 + a.key5 + b.key5) +from t0 as a, t0 as b +where (a.key1 = 1 and a.key2 = 1 and a.key3 = 1 and a.key4=1 and a.key5=1 and a.key6=1 and a.key7 = 1 or a.key8=1) +and (b.key1 = 1 and b.key2 = 1 and b.key3 = 1 and b.key4=1 and b.key5=1 and b.key6=1 and b.key7 = 1 or b.key8=1); +max(a.key1 + b.key1 + a.key2 + b.key2 + a.key3 + b.key3 + a.key4 + b.key4 + a.key5 + b.key5) +8186 +set join_buffer_size= @save_join_buffer_size; +# Test for BUG#4177 ends +drop table t0, t1, t2, t3, t4; +# BUG#16166 +CREATE TABLE t1 ( +cola char(3) not null, colb char(3) not null, filler char(200), +key(cola), key(colb) +); +INSERT INTO t1 VALUES ('foo','bar', 'ZZ'),('fuz','baz', 'ZZ'); +OPTIMIZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 optimize note Table does not support optimize, doing recreate + analyze instead +test.t1 optimize status OK +select count(*) from t1; +count(*) +8704 +explain select * from t1 WHERE cola = 'foo' AND colb = 'bar'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge cola,colb cola,colb 12,12 NULL # # Using intersect(cola,colb); Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`cola` AS `cola`,`test`.`t1`.`colb` AS `colb`,`test`.`t1`.`filler` AS `filler` from `test`.`t1` where ((`test`.`t1`.`colb` = 'bar') and (`test`.`t1`.`cola` = 'foo')) +explain select * from t1 force index(cola,colb) WHERE cola = 'foo' AND colb = 'bar'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge cola,colb cola,colb 12,12 NULL # # Using intersect(cola,colb); Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`cola` AS `cola`,`test`.`t1`.`colb` AS `colb`,`test`.`t1`.`filler` AS `filler` from `test`.`t1` FORCE INDEX (`colb`) FORCE INDEX (`cola`) where ((`test`.`t1`.`colb` = 'bar') and (`test`.`t1`.`cola` = 'foo')) +drop table t1; +# +# BUG#20256 - LOCK WRITE - MyISAM +# +CREATE TABLE t1(a INT); +INSERT INTO t1 VALUES(1); +CREATE TABLE t2(a INT, b INT, dummy CHAR(16) DEFAULT '', KEY(a), KEY(b)); +INSERT INTO t2(a,b) VALUES +(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0), +(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0), +(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0), +(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0), +(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0), +(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0), +(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0), +(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0), +(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0), +(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0), +(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0), +(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0), +(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0), +(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0), +(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0), +(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0), +(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0), +(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0), +(1,2); +LOCK TABLES t1 WRITE, t2 WRITE; +INSERT INTO t2(a,b) VALUES(1,2); +SELECT t2.a FROM t1,t2 WHERE t2.b=2 AND t2.a=1; +a +1 +1 +UNLOCK TABLES; +DROP TABLE t1, t2; +# +# BUG#29740: HA_KEY_SCAN_NOT_ROR wasn't set for HEAP engine +# +CREATE TABLE `t1` ( +`a` int(11) DEFAULT NULL, +`filler` char(200) DEFAULT NULL, +`b` int(11) DEFAULT NULL, +KEY `a` (`a`), +KEY `b` (`b`) +) ENGINE=MEMORY DEFAULT CHARSET=latin1; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t1 values +(0, 'filler', 0), (1, 'filler', 1), (2, 'filler', 2), (3, 'filler', 3), +(4, 'filler', 4), (5, 'filler', 5), (6, 'filler', 6), (7, 'filler', 7), +(8, 'filler', 8), (9, 'filler', 9), (0, 'filler', 0), (1, 'filler', 1), +(2, 'filler', 2), (3, 'filler', 3), (4, 'filler', 4), (5, 'filler', 5), +(6, 'filler', 6), (7, 'filler', 7), (8, 'filler', 8), (9, 'filler', 9), +(10, 'filler', 10), (11, 'filler', 11), (12, 'filler', 12), (13, 'filler', 13), +(14, 'filler', 14), (15, 'filler', 15), (16, 'filler', 16), (17, 'filler', 17), +(18, 'filler', 18), (19, 'filler', 19), (4, '5 ', 0), (5, '4 ', 0), +(4, '4 ', 0), (4, 'qq ', 5), (5, 'qq ', 4), (4, 'zz ', 4); +create table t2( +`a` int(11) DEFAULT NULL, +`filler` char(200) DEFAULT NULL, +`b` int(11) DEFAULT NULL, +KEY USING BTREE (`a`), +KEY USING BTREE (`b`) +) ENGINE=MEMORY DEFAULT CHARSET=latin1; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t2 select * from t1; +must use sort-union rather than union: +explain select * from t1 where a=4 or b=4; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge a,b a,b 5,5 NULL # 100.00 Using sort_union(a,b); Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`filler` AS `filler`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`a` = 4) or (`test`.`t1`.`b` = 4)) +select * from t1 where a=4 or b=4; +a filler b +4 4 0 +4 5 0 +4 filler 4 +4 filler 4 +4 qq 5 +4 zz 4 +5 qq 4 +select * from t1 ignore index(a,b) where a=4 or b=4; +a filler b +4 4 0 +4 5 0 +4 filler 4 +4 filler 4 +4 qq 5 +4 zz 4 +5 qq 4 +must use union, not sort-union: +explain select * from t2 where a=4 or b=4; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index_merge a,b a,b 5,5 NULL # 100.00 Using union(a,b); Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`filler` AS `filler`,`test`.`t2`.`b` AS `b` from `test`.`t2` where ((`test`.`t2`.`a` = 4) or (`test`.`t2`.`b` = 4)) +select * from t2 where a=4 or b=4; +a filler b +4 4 0 +4 5 0 +4 filler 4 +4 filler 4 +4 qq 5 +4 zz 4 +5 qq 4 +drop table t1, t2; +# +# Bug #37943: Reproducible mysqld crash/sigsegv in sel_trees_can_be_ored +# +CREATE TABLE t1 (a varchar(8), b set('a','b','c','d','e','f','g','h'), +KEY b(b), KEY a(a)); +INSERT INTO t1 VALUES ('y',''), ('z',''); +SELECT b,a from t1 WHERE (b!='c' AND b!='f' && b!='h') OR +(a='pure-S') OR (a='DE80337a') OR (a='DE80799'); +b a + y + z +Warnings: +Warning 1287 '&&' is deprecated and will be removed in a future release. Please use AND instead +DROP TABLE t1; +# +# BUG#40974: Incorrect query results when using clause +# evaluated using range check +# +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (a int); +insert into t1 values (1),(2); +create table t2(a int, b int); +insert into t2 values (1,1), (2, 1000); +create table t3 (a int, b int, filler char(100), key(a), key(b)); +insert into t3 select 1000, 1000,'filler' from t0 A, t0 B, t0 C; +insert into t3 values (1,1,'data'); +insert into t3 values (1,1,'data'); +The plan should be ALL/ALL/ALL(Range checked for each record (index map: 0x3) +explain select * from t1 +where exists (select 1 from t2, t3 +where t2.a=t1.a and (t3.a=t2.b or t3.b=t2.b or t3.b=t2.b+1)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # # Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL # # NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL # # Using where +2 SIMPLE t3 NULL ALL a,b NULL NULL NULL # # Range checked for each record (index map: 0x3); FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`a` = `test`.`t1`.`a`) and ((`test`.`t3`.`a` = `test`.`t2`.`b`) or (`test`.`t3`.`b` = `test`.`t2`.`b`) or (`test`.`t3`.`b` = (`test`.`t2`.`b` + 1)))) +select * from t1 +where exists (select 1 from t2, t3 +where t2.a=t1.a and (t3.a=t2.b or t3.b=t2.b or t3.b=t2.b+1)); +a +1 +2 +drop table t0, t1, t2, t3; +# +# BUG#44810: index merge and order by with low sort_buffer_size +# crashes server! +# +CREATE TABLE t1(a VARCHAR(128),b VARCHAR(128),KEY(A),KEY(B)) charset latin1; +INSERT INTO t1 VALUES (REPEAT('a',128),REPEAT('b',128)); +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +SET SESSION sort_buffer_size=1; +Warnings: +Warning 1292 Truncated incorrect sort_buffer_size value: '1' +EXPLAIN +SELECT * FROM t1 FORCE INDEX(a,b) WHERE a LIKE 'a%' OR b LIKE 'b%' +ORDER BY a,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge a,b a,b 131,131 NULL # 100.00 Using sort_union(a,b); Using where; Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` FORCE INDEX (`b`) FORCE INDEX (`a`) where ((`test`.`t1`.`a` like 'a%') or (`test`.`t1`.`b` like 'b%')) order by `test`.`t1`.`a`,`test`.`t1`.`b` +# we don't actually care about the result : we're checking if it crashes +SELECT * FROM t1 FORCE INDEX(a,b) WHERE a LIKE 'a%' OR b LIKE 'b%' +ORDER BY a,b; +SET SESSION sort_buffer_size=DEFAULT; +DROP TABLE t1; +End of 5.0 tests +#---------------- ROR-index_merge tests ----------------------- +# (Start of test file: index_merge_ror.inc) +SET SESSION DEFAULT_STORAGE_ENGINE = InnoDB; +drop table if exists t0,t1,t2; +create table t1 +( +/* Field names reflect value(rowid) distribution, st=STairs, swt= SaWTooth */ +st_a int not null default 0, +swt1a int not null default 0, +swt2a int not null default 0, +st_b int not null default 0, +swt1b int not null default 0, +swt2b int not null default 0, +/* fields/keys for row retrieval tests */ +key1 int, +key2 int, +key3 int, +key4 int, +/* make rows much bigger then keys */ +filler1 char (200), +filler2 char (200), +filler3 char (200), +filler4 char (200), +filler5 char (200), +filler6 char (200), +/* order of keys is important */ +key sta_swt12a(st_a,swt1a,swt2a), +key sta_swt1a(st_a,swt1a), +key sta_swt2a(st_a,swt2a), +key sta_swt21a(st_a,swt2a,swt1a), +key st_a(st_a), +key stb_swt1a_2b(st_b,swt1b,swt2a), +key stb_swt1b(st_b,swt1b), +key st_b(st_b), +key(key1), +key(key2), +key(key3), +key(key4) +) ; +create table t0 as select * from t1; +# Printing of many insert into t0 values (....) disabled. +alter table t1 disable keys; +Warnings: +Note 1031 Table storage engine for 't1' doesn't have this option +# Printing of many insert into t1 select .... from t0 disabled. +# Printing of many insert into t1 (...) values (....) disabled. +alter table t1 enable keys; +Warnings: +Note 1031 Table storage engine for 't1' doesn't have this option +select count(*) from t1; +count(*) +64801 +# One row results tests for cases where a single row matches all conditions +explain select key1,key2 from t1 where key1=100 and key2=100; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge key1,key2 key1,key2 5,5 NULL 2 100.00 Using intersect(key1,key2); Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`key1` AS `key1`,`test`.`t1`.`key2` AS `key2` from `test`.`t1` where ((`test`.`t1`.`key2` = 100) and (`test`.`t1`.`key1` = 100)) +select key1,key2 from t1 where key1=100 and key2=100; +key1 key2 +100 100 +explain select key1,key2,key3,key4,filler1 from t1 where key1=100 and key2=100 or key3=100 and key4=100; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge key1,key2,key3,key4 key1,key2,key3,key4 5,5,5,5 NULL 4 100.00 Using union(intersect(key1,key2),intersect(key3,key4)); Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`key1` AS `key1`,`test`.`t1`.`key2` AS `key2`,`test`.`t1`.`key3` AS `key3`,`test`.`t1`.`key4` AS `key4`,`test`.`t1`.`filler1` AS `filler1` from `test`.`t1` where (((`test`.`t1`.`key2` = 100) and (`test`.`t1`.`key1` = 100)) or ((`test`.`t1`.`key4` = 100) and (`test`.`t1`.`key3` = 100))) +explain format=json select key1,key2,key3,key4,filler1 from t1 where key1=100 and key2=100 or key3=100 and key4=100; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "#" + }, + "table": { + "table_name": "t1", + "access_type": "index_merge", + "possible_keys": [ + "key1", + "key2", + "key3", + "key4" + ], + "key": "union(intersect(key1,key2),intersect(key3,key4))", + "key_length": "5,5,5,5", + "rows_examined_per_scan": 4, + "rows_produced_per_join": 4, + "filtered": "100.00", + "cost_info": { + "read_cost": "#", + "eval_cost": "#", + "prefix_cost": "#", + "data_read_per_join": "18K" + }, + "used_columns": [ + "key1", + "key2", + "key3", + "key4", + "filler1" + ], + "attached_condition": "(((`test`.`t1`.`key2` = 100) and (`test`.`t1`.`key1` = 100)) or ((`test`.`t1`.`key4` = 100) and (`test`.`t1`.`key3` = 100)))" + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`key1` AS `key1`,`test`.`t1`.`key2` AS `key2`,`test`.`t1`.`key3` AS `key3`,`test`.`t1`.`key4` AS `key4`,`test`.`t1`.`filler1` AS `filler1` from `test`.`t1` where (((`test`.`t1`.`key2` = 100) and (`test`.`t1`.`key1` = 100)) or ((`test`.`t1`.`key4` = 100) and (`test`.`t1`.`key3` = 100))) +select key1,key2,key3,key4,filler1 from t1 where key1=100 and key2=100 or key3=100 and key4=100; +key1 key2 key3 key4 filler1 +100 100 100 100 key1-key2-key3-key4 +# Several-rows results +insert into t1 (key1, key2, key3, key4, filler1) values (100, 100, -1, -1, 'key1-key2'); +insert into t1 (key1, key2, key3, key4, filler1) values (-1, -1, 100, 100, 'key4-key3'); +# ROR-intersection, not covering +explain select key1,key2,filler1 from t1 where key1=100 and key2=100; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge key1,key2 key1,key2 5,5 NULL 2 100.00 Using intersect(key1,key2); Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`key1` AS `key1`,`test`.`t1`.`key2` AS `key2`,`test`.`t1`.`filler1` AS `filler1` from `test`.`t1` where ((`test`.`t1`.`key2` = 100) and (`test`.`t1`.`key1` = 100)) +select key1,key2,filler1 from t1 where key1=100 and key2=100; +key1 key2 filler1 +100 100 key1-key2-key3-key4 +100 100 key1-key2 +# ROR-intersection, covering +explain select key1,key2 from t1 where key1=100 and key2=100; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge key1,key2 key1,key2 5,5 NULL 2 100.00 Using intersect(key1,key2); Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`key1` AS `key1`,`test`.`t1`.`key2` AS `key2` from `test`.`t1` where ((`test`.`t1`.`key2` = 100) and (`test`.`t1`.`key1` = 100)) +select key1,key2 from t1 where key1=100 and key2=100; +key1 key2 +100 100 +100 100 +# ROR-union of ROR-intersections +explain select key1,key2,key3,key4 from t1 where key1=100 and key2=100 or key3=100 and key4=100; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge key1,key2,key3,key4 key1,key2,key3,key4 5,5,5,5 NULL 4 100.00 Using union(intersect(key1,key2),intersect(key3,key4)); Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`key1` AS `key1`,`test`.`t1`.`key2` AS `key2`,`test`.`t1`.`key3` AS `key3`,`test`.`t1`.`key4` AS `key4` from `test`.`t1` where (((`test`.`t1`.`key2` = 100) and (`test`.`t1`.`key1` = 100)) or ((`test`.`t1`.`key4` = 100) and (`test`.`t1`.`key3` = 100))) +select key1,key2,key3,key4 from t1 where key1=100 and key2=100 or key3=100 and key4=100; +key1 key2 key3 key4 +100 100 100 100 +100 100 -1 -1 +-1 -1 100 100 +explain select key1,key2,key3,key4,filler1 from t1 where key1=100 and key2=100 or key3=100 and key4=100; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge key1,key2,key3,key4 key1,key2,key3,key4 5,5,5,5 NULL 4 100.00 Using union(intersect(key1,key2),intersect(key3,key4)); Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`key1` AS `key1`,`test`.`t1`.`key2` AS `key2`,`test`.`t1`.`key3` AS `key3`,`test`.`t1`.`key4` AS `key4`,`test`.`t1`.`filler1` AS `filler1` from `test`.`t1` where (((`test`.`t1`.`key2` = 100) and (`test`.`t1`.`key1` = 100)) or ((`test`.`t1`.`key4` = 100) and (`test`.`t1`.`key3` = 100))) +select key1,key2,key3,key4,filler1 from t1 where key1=100 and key2=100 or key3=100 and key4=100; +key1 key2 key3 key4 filler1 +100 100 100 100 key1-key2-key3-key4 +100 100 -1 -1 key1-key2 +-1 -1 100 100 key4-key3 +# 3-way ROR-intersection +explain select key1,key2,key3 from t1 where key1=100 and key2=100 and key3=100; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge key1,key2,key3 key1,key2,key3 5,5,5 NULL 1 100.00 Using intersect(key1,key2,key3); Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`key1` AS `key1`,`test`.`t1`.`key2` AS `key2`,`test`.`t1`.`key3` AS `key3` from `test`.`t1` where ((`test`.`t1`.`key3` = 100) and (`test`.`t1`.`key2` = 100) and (`test`.`t1`.`key1` = 100)) +select key1,key2,key3 from t1 where key1=100 and key2=100 and key3=100; +key1 key2 key3 +100 100 100 +# ROR-union(ROR-intersection, ROR-range) +insert into t1 (key1,key2,key3,key4,filler1) values (101,101,101,101, 'key1234-101'); +explain select key1,key2,key3,key4,filler1 from t1 where key1=100 and key2=100 or key3=101; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge key1,key2,key3 key1,key2,key3 5,5,5 NULL 3 100.00 Using union(intersect(key1,key2),key3); Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`key1` AS `key1`,`test`.`t1`.`key2` AS `key2`,`test`.`t1`.`key3` AS `key3`,`test`.`t1`.`key4` AS `key4`,`test`.`t1`.`filler1` AS `filler1` from `test`.`t1` where (((`test`.`t1`.`key2` = 100) and (`test`.`t1`.`key1` = 100)) or (`test`.`t1`.`key3` = 101)) +select key1,key2,key3,key4,filler1 from t1 where key1=100 and key2=100 or key3=101; +key1 key2 key3 key4 filler1 +100 100 100 100 key1-key2-key3-key4 +100 100 -1 -1 key1-key2 +101 101 101 101 key1234-101 +# Run some ROR updates/deletes +select key1,key2, filler1 from t1 where key1=100 and key2=100; +key1 key2 filler1 +100 100 key1-key2-key3-key4 +100 100 key1-key2 +update t1 set filler1='to be deleted' where key1=100 and key2=100; +update t1 set key1=200,key2=200 where key1=100 and key2=100; +delete from t1 where key1=200 and key2=200; +select key1,key2,filler1 from t1 where key2=100 and key2=200; +key1 key2 filler1 +# ROR-union(ROR-intersection) with one of ROR-intersection giving empty +# results +explain select key1,key2,key3,key4,filler1 from t1 where key1=100 and key2=100 or key3=100 and key4=100; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge key1,key2,key3,key4 key1,key2,key3,key4 5,5,5,5 NULL 4 100.00 Using union(intersect(key1,key2),intersect(key3,key4)); Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`key1` AS `key1`,`test`.`t1`.`key2` AS `key2`,`test`.`t1`.`key3` AS `key3`,`test`.`t1`.`key4` AS `key4`,`test`.`t1`.`filler1` AS `filler1` from `test`.`t1` where (((`test`.`t1`.`key2` = 100) and (`test`.`t1`.`key1` = 100)) or ((`test`.`t1`.`key4` = 100) and (`test`.`t1`.`key3` = 100))) +select key1,key2,key3,key4,filler1 from t1 where key1=100 and key2=100 or key3=100 and key4=100; +key1 key2 key3 key4 filler1 +-1 -1 100 100 key4-key3 +delete from t1 where key3=100 and key4=100; +# ROR-union with all ROR-intersections giving empty results +explain select key1,key2,key3,key4,filler1 from t1 where key1=100 and key2=100 or key3=100 and key4=100; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge key1,key2,key3,key4 key1,key2,key3,key4 5,5,5,5 NULL 4 100.00 Using union(intersect(key1,key2),intersect(key3,key4)); Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`key1` AS `key1`,`test`.`t1`.`key2` AS `key2`,`test`.`t1`.`key3` AS `key3`,`test`.`t1`.`key4` AS `key4`,`test`.`t1`.`filler1` AS `filler1` from `test`.`t1` where (((`test`.`t1`.`key2` = 100) and (`test`.`t1`.`key1` = 100)) or ((`test`.`t1`.`key4` = 100) and (`test`.`t1`.`key3` = 100))) +select key1,key2,key3,key4,filler1 from t1 where key1=100 and key2=100 or key3=100 and key4=100; +key1 key2 key3 key4 filler1 +# ROR-intersection with empty result +explain select key1,key2 from t1 where key1=100 and key2=100; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge key1,key2 key1,key2 5,5 NULL 2 100.00 Using intersect(key1,key2); Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`key1` AS `key1`,`test`.`t1`.`key2` AS `key2` from `test`.`t1` where ((`test`.`t1`.`key2` = 100) and (`test`.`t1`.`key1` = 100)) +select key1,key2 from t1 where key1=100 and key2=100; +key1 key2 +# ROR-union tests with various cases. +# All scans returning duplicate rows: +insert into t1 (key1, key2, key3, key4, filler1) values (100, 100, 200, 200,'key1-key2-key3-key4-1'); +insert into t1 (key1, key2, key3, key4, filler1) values (100, 100, 200, 200,'key1-key2-key3-key4-2'); +insert into t1 (key1, key2, key3, key4, filler1) values (100, 100, 200, 200,'key1-key2-key3-key4-3'); +explain select key1,key2,key3,key4,filler1 from t1 where key3=200 or (key1=100 and key2=100) or key4=200; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge key1,key2,key3,key4 key3,key1,key2,key4 5,5,5,5 NULL 8 100.00 Using union(key3,intersect(key1,key2),key4); Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`key1` AS `key1`,`test`.`t1`.`key2` AS `key2`,`test`.`t1`.`key3` AS `key3`,`test`.`t1`.`key4` AS `key4`,`test`.`t1`.`filler1` AS `filler1` from `test`.`t1` where ((`test`.`t1`.`key3` = 200) or ((`test`.`t1`.`key2` = 100) and (`test`.`t1`.`key1` = 100)) or (`test`.`t1`.`key4` = 200)) +select key1,key2,key3,key4,filler1 from t1 where key3=200 or (key1=100 and key2=100) or key4=200; +key1 key2 key3 key4 filler1 +100 100 200 200 key1-key2-key3-key4-1 +100 100 200 200 key1-key2-key3-key4-2 +100 100 200 200 key1-key2-key3-key4-3 +insert into t1 (key1, key2, key3, key4, filler1) values (-1, -1, -1, 200,'key4'); +explain select key1,key2,key3,key4,filler1 from t1 where key3=200 or (key1=100 and key2=100) or key4=200; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge key1,key2,key3,key4 key3,key1,key2,key4 5,5,5,5 NULL 9 100.00 Using union(key3,intersect(key1,key2),key4); Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`key1` AS `key1`,`test`.`t1`.`key2` AS `key2`,`test`.`t1`.`key3` AS `key3`,`test`.`t1`.`key4` AS `key4`,`test`.`t1`.`filler1` AS `filler1` from `test`.`t1` where ((`test`.`t1`.`key3` = 200) or ((`test`.`t1`.`key2` = 100) and (`test`.`t1`.`key1` = 100)) or (`test`.`t1`.`key4` = 200)) +select key1,key2,key3,key4,filler1 from t1 where key3=200 or (key1=100 and key2=100) or key4=200; +key1 key2 key3 key4 filler1 +100 100 200 200 key1-key2-key3-key4-1 +100 100 200 200 key1-key2-key3-key4-2 +100 100 200 200 key1-key2-key3-key4-3 +-1 -1 -1 200 key4 +insert into t1 (key1, key2, key3, key4, filler1) values (-1, -1, 200, -1,'key3'); +explain select key1,key2,key3,key4,filler1 from t1 where key3=200 or (key1=100 and key2=100) or key4=200; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge key1,key2,key3,key4 key3,key1,key2,key4 5,5,5,5 NULL 10 100.00 Using union(key3,intersect(key1,key2),key4); Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`key1` AS `key1`,`test`.`t1`.`key2` AS `key2`,`test`.`t1`.`key3` AS `key3`,`test`.`t1`.`key4` AS `key4`,`test`.`t1`.`filler1` AS `filler1` from `test`.`t1` where ((`test`.`t1`.`key3` = 200) or ((`test`.`t1`.`key2` = 100) and (`test`.`t1`.`key1` = 100)) or (`test`.`t1`.`key4` = 200)) +select key1,key2,key3,key4,filler1 from t1 where key3=200 or (key1=100 and key2=100) or key4=200; +key1 key2 key3 key4 filler1 +100 100 200 200 key1-key2-key3-key4-1 +100 100 200 200 key1-key2-key3-key4-2 +100 100 200 200 key1-key2-key3-key4-3 +-1 -1 -1 200 key4 +-1 -1 200 -1 key3 +## +## Optimizer tests +## +# Check that the shortest key is used for ROR-intersection, covering and non-covering. +# Do many tests +# Check that keys that don't improve selectivity are skipped. +explain select * from t1 where st_a=1 and swt1a=1 and swt2a=1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1000 100.00 Parallel execute (3 workers) +2 SIMPLE t1 NULL ref sta_swt12a,sta_swt1a,sta_swt2a,sta_swt21a,st_a sta_swt21a 12 const,const,const 1000 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`st_a` AS `st_a`,`test`.`t1`.`swt1a` AS `swt1a`,`test`.`t1`.`swt2a` AS `swt2a`,`test`.`t1`.`st_b` AS `st_b`,`test`.`t1`.`swt1b` AS `swt1b`,`test`.`t1`.`swt2b` AS `swt2b`,`test`.`t1`.`key1` AS `key1`,`test`.`t1`.`key2` AS `key2`,`test`.`t1`.`key3` AS `key3`,`test`.`t1`.`key4` AS `key4`,`test`.`t1`.`filler1` AS `filler1`,`test`.`t1`.`filler2` AS `filler2`,`test`.`t1`.`filler3` AS `filler3`,`test`.`t1`.`filler4` AS `filler4`,`test`.`t1`.`filler5` AS `filler5`,`test`.`t1`.`filler6` AS `filler6` from `test`.`t1` where ((`test`.`t1`.`swt2a` = 1) and (`test`.`t1`.`swt1a` = 1) and (`test`.`t1`.`st_a` = 1)) +explain select * from t1 where st_b=1 and swt1b=1 and swt2b=1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4000 10.00 Parallel execute (4 workers) +2 SIMPLE t1 NULL range stb_swt1a_2b,stb_swt1b,st_b stb_swt1b 8 NULL 4000 10.00 Using index condition; Using where; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`st_a` AS `st_a`,`test`.`t1`.`swt1a` AS `swt1a`,`test`.`t1`.`swt2a` AS `swt2a`,`test`.`t1`.`st_b` AS `st_b`,`test`.`t1`.`swt1b` AS `swt1b`,`test`.`t1`.`swt2b` AS `swt2b`,`test`.`t1`.`key1` AS `key1`,`test`.`t1`.`key2` AS `key2`,`test`.`t1`.`key3` AS `key3`,`test`.`t1`.`key4` AS `key4`,`test`.`t1`.`filler1` AS `filler1`,`test`.`t1`.`filler2` AS `filler2`,`test`.`t1`.`filler3` AS `filler3`,`test`.`t1`.`filler4` AS `filler4`,`test`.`t1`.`filler5` AS `filler5`,`test`.`t1`.`filler6` AS `filler6` from `test`.`t1` where ((`test`.`t1`.`swt2b` = 1) and (`test`.`t1`.`swt1b` = 1) and (`test`.`t1`.`st_b` = 1)) +explain select * from t1 where st_a=1 and swt1a=1 and swt2a=1 and st_b=1 and swt1b=1 and swt2b=1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge sta_swt12a,sta_swt1a,sta_swt2a,sta_swt21a,st_a,stb_swt1a_2b,stb_swt1b,st_b sta_swt12a,stb_swt1a_2b 12,12 NULL # # Using intersect(sta_swt12a,stb_swt1a_2b); Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`st_a` AS `st_a`,`test`.`t1`.`swt1a` AS `swt1a`,`test`.`t1`.`swt2a` AS `swt2a`,`test`.`t1`.`st_b` AS `st_b`,`test`.`t1`.`swt1b` AS `swt1b`,`test`.`t1`.`swt2b` AS `swt2b`,`test`.`t1`.`key1` AS `key1`,`test`.`t1`.`key2` AS `key2`,`test`.`t1`.`key3` AS `key3`,`test`.`t1`.`key4` AS `key4`,`test`.`t1`.`filler1` AS `filler1`,`test`.`t1`.`filler2` AS `filler2`,`test`.`t1`.`filler3` AS `filler3`,`test`.`t1`.`filler4` AS `filler4`,`test`.`t1`.`filler5` AS `filler5`,`test`.`t1`.`filler6` AS `filler6` from `test`.`t1` where ((`test`.`t1`.`swt2b` = 1) and (`test`.`t1`.`swt1b` = 1) and (`test`.`t1`.`st_b` = 1) and (`test`.`t1`.`swt2a` = 1) and (`test`.`t1`.`swt1a` = 1) and (`test`.`t1`.`st_a` = 1)) +explain select * from t1 ignore index (sta_swt21a, stb_swt1a_2b) +where st_a=1 and swt1a=1 and swt2a=1 and st_b=1 and swt1b=1 and swt2b=1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge sta_swt12a,sta_swt1a,sta_swt2a,st_a,stb_swt1b,st_b sta_swt12a,stb_swt1b 12,8 NULL # # Using intersect(sta_swt12a,stb_swt1b); Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`st_a` AS `st_a`,`test`.`t1`.`swt1a` AS `swt1a`,`test`.`t1`.`swt2a` AS `swt2a`,`test`.`t1`.`st_b` AS `st_b`,`test`.`t1`.`swt1b` AS `swt1b`,`test`.`t1`.`swt2b` AS `swt2b`,`test`.`t1`.`key1` AS `key1`,`test`.`t1`.`key2` AS `key2`,`test`.`t1`.`key3` AS `key3`,`test`.`t1`.`key4` AS `key4`,`test`.`t1`.`filler1` AS `filler1`,`test`.`t1`.`filler2` AS `filler2`,`test`.`t1`.`filler3` AS `filler3`,`test`.`t1`.`filler4` AS `filler4`,`test`.`t1`.`filler5` AS `filler5`,`test`.`t1`.`filler6` AS `filler6` from `test`.`t1` IGNORE INDEX (`stb_swt1a_2b`) IGNORE INDEX (`sta_swt21a`) where ((`test`.`t1`.`swt2b` = 1) and (`test`.`t1`.`swt1b` = 1) and (`test`.`t1`.`st_b` = 1) and (`test`.`t1`.`swt2a` = 1) and (`test`.`t1`.`swt1a` = 1) and (`test`.`t1`.`st_a` = 1)) +explain select * from t1 ignore index (sta_swt21a, sta_swt12a, stb_swt1a_2b) +where st_a=1 and swt1a=1 and swt2a=1 and st_b=1 and swt1b=1 and swt2b=1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge sta_swt1a,sta_swt2a,st_a,stb_swt1b,st_b sta_swt1a,stb_swt1b,sta_swt2a 8,8,8 NULL # # Using intersect(sta_swt1a,stb_swt1b,sta_swt2a); Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`st_a` AS `st_a`,`test`.`t1`.`swt1a` AS `swt1a`,`test`.`t1`.`swt2a` AS `swt2a`,`test`.`t1`.`st_b` AS `st_b`,`test`.`t1`.`swt1b` AS `swt1b`,`test`.`t1`.`swt2b` AS `swt2b`,`test`.`t1`.`key1` AS `key1`,`test`.`t1`.`key2` AS `key2`,`test`.`t1`.`key3` AS `key3`,`test`.`t1`.`key4` AS `key4`,`test`.`t1`.`filler1` AS `filler1`,`test`.`t1`.`filler2` AS `filler2`,`test`.`t1`.`filler3` AS `filler3`,`test`.`t1`.`filler4` AS `filler4`,`test`.`t1`.`filler5` AS `filler5`,`test`.`t1`.`filler6` AS `filler6` from `test`.`t1` IGNORE INDEX (`stb_swt1a_2b`) IGNORE INDEX (`sta_swt12a`) IGNORE INDEX (`sta_swt21a`) where ((`test`.`t1`.`swt2b` = 1) and (`test`.`t1`.`swt1b` = 1) and (`test`.`t1`.`st_b` = 1) and (`test`.`t1`.`swt2a` = 1) and (`test`.`t1`.`swt1a` = 1) and (`test`.`t1`.`st_a` = 1)) +explain select * from t1 ignore index (sta_swt21a, sta_swt12a, stb_swt1a_2b, stb_swt1b) +where st_a=1 and swt1a=1 and swt2a=1 and st_b=1 and swt1b=1 and swt2b=1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge sta_swt1a,sta_swt2a,st_a,st_b sta_swt1a,sta_swt2a,st_b 8,8,4 NULL # # Using intersect(sta_swt1a,sta_swt2a,st_b); Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`st_a` AS `st_a`,`test`.`t1`.`swt1a` AS `swt1a`,`test`.`t1`.`swt2a` AS `swt2a`,`test`.`t1`.`st_b` AS `st_b`,`test`.`t1`.`swt1b` AS `swt1b`,`test`.`t1`.`swt2b` AS `swt2b`,`test`.`t1`.`key1` AS `key1`,`test`.`t1`.`key2` AS `key2`,`test`.`t1`.`key3` AS `key3`,`test`.`t1`.`key4` AS `key4`,`test`.`t1`.`filler1` AS `filler1`,`test`.`t1`.`filler2` AS `filler2`,`test`.`t1`.`filler3` AS `filler3`,`test`.`t1`.`filler4` AS `filler4`,`test`.`t1`.`filler5` AS `filler5`,`test`.`t1`.`filler6` AS `filler6` from `test`.`t1` IGNORE INDEX (`stb_swt1b`) IGNORE INDEX (`stb_swt1a_2b`) IGNORE INDEX (`sta_swt12a`) IGNORE INDEX (`sta_swt21a`) where ((`test`.`t1`.`swt2b` = 1) and (`test`.`t1`.`swt1b` = 1) and (`test`.`t1`.`st_b` = 1) and (`test`.`t1`.`swt2a` = 1) and (`test`.`t1`.`swt1a` = 1) and (`test`.`t1`.`st_a` = 1)) +explain select * from t1 +where st_a=1 and swt1a=1 and swt2a=1 and st_b=1 and swt1b=1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge sta_swt12a,sta_swt1a,sta_swt2a,sta_swt21a,st_a,stb_swt1a_2b,stb_swt1b,st_b sta_swt12a,stb_swt1a_2b 12,12 NULL # # Using intersect(sta_swt12a,stb_swt1a_2b); Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`st_a` AS `st_a`,`test`.`t1`.`swt1a` AS `swt1a`,`test`.`t1`.`swt2a` AS `swt2a`,`test`.`t1`.`st_b` AS `st_b`,`test`.`t1`.`swt1b` AS `swt1b`,`test`.`t1`.`swt2b` AS `swt2b`,`test`.`t1`.`key1` AS `key1`,`test`.`t1`.`key2` AS `key2`,`test`.`t1`.`key3` AS `key3`,`test`.`t1`.`key4` AS `key4`,`test`.`t1`.`filler1` AS `filler1`,`test`.`t1`.`filler2` AS `filler2`,`test`.`t1`.`filler3` AS `filler3`,`test`.`t1`.`filler4` AS `filler4`,`test`.`t1`.`filler5` AS `filler5`,`test`.`t1`.`filler6` AS `filler6` from `test`.`t1` where ((`test`.`t1`.`swt1b` = 1) and (`test`.`t1`.`st_b` = 1) and (`test`.`t1`.`swt2a` = 1) and (`test`.`t1`.`swt1a` = 1) and (`test`.`t1`.`st_a` = 1)) +explain select * from t1 +where st_a=1 and swt1a=1 and st_b=1 and swt1b=1 and swt1b=1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge sta_swt12a,sta_swt1a,sta_swt2a,sta_swt21a,st_a,stb_swt1a_2b,stb_swt1b,st_b sta_swt1a,stb_swt1b 8,8 NULL # # Using intersect(sta_swt1a,stb_swt1b); Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`st_a` AS `st_a`,`test`.`t1`.`swt1a` AS `swt1a`,`test`.`t1`.`swt2a` AS `swt2a`,`test`.`t1`.`st_b` AS `st_b`,`test`.`t1`.`swt1b` AS `swt1b`,`test`.`t1`.`swt2b` AS `swt2b`,`test`.`t1`.`key1` AS `key1`,`test`.`t1`.`key2` AS `key2`,`test`.`t1`.`key3` AS `key3`,`test`.`t1`.`key4` AS `key4`,`test`.`t1`.`filler1` AS `filler1`,`test`.`t1`.`filler2` AS `filler2`,`test`.`t1`.`filler3` AS `filler3`,`test`.`t1`.`filler4` AS `filler4`,`test`.`t1`.`filler5` AS `filler5`,`test`.`t1`.`filler6` AS `filler6` from `test`.`t1` where ((`test`.`t1`.`swt1b` = 1) and (`test`.`t1`.`st_b` = 1) and (`test`.`t1`.`swt1a` = 1) and (`test`.`t1`.`st_a` = 1)) +explain select st_a from t1 +where st_a=1 and swt1a=1 and st_b=1 and swt1b=1 and swt1b=1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge sta_swt12a,sta_swt1a,sta_swt2a,sta_swt21a,st_a,stb_swt1a_2b,stb_swt1b,st_b sta_swt1a,stb_swt1b 8,8 NULL # # Using intersect(sta_swt1a,stb_swt1b); Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`st_a` AS `st_a` from `test`.`t1` where ((`test`.`t1`.`swt1b` = 1) and (`test`.`t1`.`st_b` = 1) and (`test`.`t1`.`swt1a` = 1) and (`test`.`t1`.`st_a` = 1)) +explain select st_a from t1 +where st_a=1 and swt1a=1 and st_b=1 and swt1b=1 and swt1b=1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge sta_swt12a,sta_swt1a,sta_swt2a,sta_swt21a,st_a,stb_swt1a_2b,stb_swt1b,st_b sta_swt1a,stb_swt1b 8,8 NULL # # Using intersect(sta_swt1a,stb_swt1b); Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`st_a` AS `st_a` from `test`.`t1` where ((`test`.`t1`.`swt1b` = 1) and (`test`.`t1`.`st_b` = 1) and (`test`.`t1`.`swt1a` = 1) and (`test`.`t1`.`st_a` = 1)) +drop table t0,t1; +# 'Partially' covered fields test +create table t2 ( +a char(10), +b char(10), +filler1 char(255), +filler2 char(255), +key(a(5)), +key(b(5)) +); +select count(a) from t2 where a='BBBBBBBB'; +count(a) +4 +select count(a) from t2 where b='BBBBBBBB'; +count(a) +4 +# BUG#1: +expla_or_bin select count(a_or_b) from t2 where a_or_b='AAAAAAAA' a_or_bnd a_or_b='AAAAAAAA'; +id select_type ta_or_ba_or_ble pa_or_brtitions type possia_or_ble_keys key key_len ref rows filtered Extra_or_b +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 12.50 Pa_or_bra_or_bllel execute (1 workers) +2 SIMPLE t2 NULL ref a_or_b,a_or_b a_or_b 21 const 4 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select count(`test`.`t2`.`a_or_b`) AS `count(a_or_b)` from `test`.`t2` where ((`test`.`t2`.`a_or_b` = 'AAAAAAAA') a_or_bnd (`test`.`t2`.`a_or_b` = 'AAAAAAAA')) +select count(a) from t2 where a='AAAAAAAA' and b='AAAAAAAA'; +count(a) +4 +select count(a) from t2 ignore index(a,b) where a='AAAAAAAA' and b='AAAAAAAA'; +count(a) +4 +insert into t2 values ('ab', 'ab', 'uh', 'oh'); +explain select a from t2 where a='ab'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ref a a 21 const 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` where (`test`.`t2`.`a` = 'ab') +drop table t2; +# +# BUG#25048 - ERROR 126 : Incorrect key file for table '.XXXX.MYI'; +# try to repair it +# +CREATE TABLE t1(c1 INT, c2 INT DEFAULT 0, c3 CHAR(255) DEFAULT '', +KEY(c1), KEY(c2), KEY(c3)) charset latin1; +INSERT INTO t1(c1) VALUES(0),(0),(0),(0),(0),(0),(0),(0),(0),(0),(0),(0),(0), +(0),(0),(0),(0),(0),(0),(0),(0),(0),(0),(0),(0),(0),(0),(0),(0); +INSERT INTO t1 VALUES(0,0,0); +CREATE TABLE t2(c1 int); +INSERT INTO t2 VALUES(1); +DELETE t1 FROM t1,t2 WHERE t1.c1=0 AND t1.c2=0; +SELECT * FROM t1; +c1 c2 c3 +DROP TABLE t1,t2; +#---------------- Index merge test 2 ------------------------------------------- +# (Start of test file: index_merge2.inc) +SET SESSION DEFAULT_STORAGE_ENGINE = InnoDB; +drop table if exists t1,t2; +create table t1 +( +key1 int not null, +key2 int not null, +INDEX i1(key1), +INDEX i2(key2) +) charset latin1; +# No primary key +explain select * from t1 where key1 < 5 or key2 > 197; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge i1,i2 i1,i2 4,4 NULL 8 100.00 Using sort_union(i1,i2); Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`key1` AS `key1`,`test`.`t1`.`key2` AS `key2` from `test`.`t1` where ((`test`.`t1`.`key1` < 5) or (`test`.`t1`.`key2` > 197)) +select * from t1 where key1 < 5 or key2 > 197; +key1 key2 +0 200 +1 199 +2 198 +3 197 +4 196 +explain select * from t1 where key1 < 3 or key2 > 195; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge i1,i2 i1,i2 4,4 NULL 8 100.00 Using sort_union(i1,i2); Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`key1` AS `key1`,`test`.`t1`.`key2` AS `key2` from `test`.`t1` where ((`test`.`t1`.`key1` < 3) or (`test`.`t1`.`key2` > 195)) +select * from t1 where key1 < 3 or key2 > 195; +key1 key2 +0 200 +1 199 +2 198 +3 197 +4 196 +# Primary key as case-sensitive string with \0s. +# also make primary key be longer then max. index length of MyISAM. +alter table t1 add str1 char (255) not null, +add zeroval int not null default 0, +add str2 char (255) not null, +add str3 char (255) not null; +update t1 set str1='aaa', str2='bbb', str3=concat(key2, '-', key1 div 2, '_' ,if(key1 mod 2 = 0, 'a', 'A')); +alter table t1 add primary key (str1, zeroval, str2, str3); +explain select * from t1 where key1 < 5 or key2 > 197; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge i1,i2 i1,i2 4,4 NULL 8 100.00 Using sort_union(i1,i2); Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`key1` AS `key1`,`test`.`t1`.`key2` AS `key2`,`test`.`t1`.`str1` AS `str1`,`test`.`t1`.`zeroval` AS `zeroval`,`test`.`t1`.`str2` AS `str2`,`test`.`t1`.`str3` AS `str3` from `test`.`t1` where ((`test`.`t1`.`key1` < 5) or (`test`.`t1`.`key2` > 197)) +select * from t1 where key1 < 5 or key2 > 197; +key1 key2 str1 zeroval str2 str3 +4 196 aaa 0 bbb 196-2_a +3 197 aaa 0 bbb 197-1_A +2 198 aaa 0 bbb 198-1_a +1 199 aaa 0 bbb 199-0_A +0 200 aaa 0 bbb 200-0_a +explain select * from t1 where key1 < 3 or key2 > 195; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge i1,i2 i1,i2 4,4 NULL 8 100.00 Using sort_union(i1,i2); Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`key1` AS `key1`,`test`.`t1`.`key2` AS `key2`,`test`.`t1`.`str1` AS `str1`,`test`.`t1`.`zeroval` AS `zeroval`,`test`.`t1`.`str2` AS `str2`,`test`.`t1`.`str3` AS `str3` from `test`.`t1` where ((`test`.`t1`.`key1` < 3) or (`test`.`t1`.`key2` > 195)) +select * from t1 where key1 < 3 or key2 > 195; +key1 key2 str1 zeroval str2 str3 +4 196 aaa 0 bbb 196-2_a +3 197 aaa 0 bbb 197-1_A +2 198 aaa 0 bbb 198-1_a +1 199 aaa 0 bbb 199-0_A +0 200 aaa 0 bbb 200-0_a +# Test for BUG#5401 +drop table t1; +create table t1 ( +pk integer not null auto_increment primary key, +key1 integer, +key2 integer not null, +filler char (200), +index (key1), +index (key2) +) charset latin1; +show warnings; +Level Code Message +explain select pk from t1 where key1 = 1 and key2 = 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge key1,key2 key1,key2 5,4 NULL 1 100.00 Using intersect(key1,key2); Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` where ((`test`.`t1`.`key2` = 1) and (`test`.`t1`.`key1` = 1)) +select pk from t1 where key2 = 1 and key1 = 1; +pk +26 +27 +select pk from t1 ignore index(key1,key2) where key2 = 1 and key1 = 1; +pk +26 +27 +# More tests for BUG#5401. +drop table t1; +create table t1 ( +pk int primary key auto_increment, +key1a int, +key2a int, +key1b int, +key2b int, +dummy1 int, +dummy2 int, +dummy3 int, +dummy4 int, +key3a int, +key3b int, +filler1 char (200), +index i1(key1a, key1b), +index i2(key2a, key2b), +index i3(key3a, key3b) +); +create table t2 (a int); +insert into t2 values (0),(1),(2),(3),(4),(NULL); +insert into t1 (key1a, key1b, key2a, key2b, key3a, key3b) +select A.a, B.a, C.a, D.a, C.a, D.a from t2 A,t2 B,t2 C, t2 D; +insert into t1 (key1a, key1b, key2a, key2b, key3a, key3b) +select key1a, key1b, key2a, key2b, key3a, key3b from t1; +insert into t1 (key1a, key1b, key2a, key2b, key3a, key3b) +select key1a, key1b, key2a, key2b, key3a, key3b from t1; +analyze table t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +select count(*) from t1; +count(*) +5184 +explain select count(*) from t1 where +key1a = 2 and key1b is null and key2a = 2 and key2b is null; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge i1,i2 i1,i2 10,10 NULL # 100.00 Using intersect(i1,i2); Using where; Using index +Warnings: +Note 1003 /* select#1 */ select count(0) AS `count(*)` from `test`.`t1` where ((`test`.`t1`.`key2a` = 2) and (`test`.`t1`.`key1a` = 2) and (`test`.`t1`.`key1b` is null) and (`test`.`t1`.`key2b` is null)) +select count(*) from t1 where +key1a = 2 and key1b is null and key2a = 2 and key2b is null; +count(*) +4 +explain select count(*) from t1 where +key1a = 2 and key1b is null and key3a = 2 and key3b is null; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge i1,i3 i1,i3 10,10 NULL # 100.00 Using intersect(i1,i3); Using where; Using index +Warnings: +Note 1003 /* select#1 */ select count(0) AS `count(*)` from `test`.`t1` where ((`test`.`t1`.`key3a` = 2) and (`test`.`t1`.`key1a` = 2) and (`test`.`t1`.`key1b` is null) and (`test`.`t1`.`key3b` is null)) +select count(*) from t1 where +key1a = 2 and key1b is null and key3a = 2 and key3b is null; +count(*) +4 +drop table t1,t2; +# Test for BUG#8441 +create table t1 ( +id1 int, +id2 date , +index idx2 (id1,id2), +index idx1 (id2) +); +insert into t1 values(1,'20040101'), (2,'20040102'); +select * from t1 where id1 = 1 and id2= '20040101'; +id1 id2 +1 2004-01-01 +drop table t1; +# Test for BUG#12720 +drop view if exists v1; +CREATE TABLE t1 ( +`oid` int(11) unsigned NOT NULL auto_increment, +`fk_bbk_niederlassung` int(11) unsigned NOT NULL, +`fk_wochentag` int(11) unsigned NOT NULL, +`uhrzeit_von` time NOT NULL COMMENT 'HH:MM', +`uhrzeit_bis` time NOT NULL COMMENT 'HH:MM', +`geloescht` tinyint(4) NOT NULL, +`version` int(5) NOT NULL, +PRIMARY KEY (`oid`), +KEY `fk_bbk_niederlassung` (`fk_bbk_niederlassung`), +KEY `fk_wochentag` (`fk_wochentag`), +KEY `ix_version` (`version`) +) DEFAULT CHARSET=latin1; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t1 values +(1, 38, 1, '08:00:00', '13:00:00', 0, 1), +(2, 38, 2, '08:00:00', '13:00:00', 0, 1), +(3, 38, 3, '08:00:00', '13:00:00', 0, 1), +(4, 38, 4, '08:00:00', '13:00:00', 0, 1), +(5, 38, 5, '08:00:00', '13:00:00', 0, 1), +(6, 38, 5, '08:00:00', '13:00:00', 1, 2), +(7, 38, 3, '08:00:00', '13:00:00', 1, 2), +(8, 38, 1, '08:00:00', '13:00:00', 1, 2), +(9, 38, 2, '08:00:00', '13:00:00', 1, 2), +(10, 38, 4, '08:00:00', '13:00:00', 1, 2), +(11, 38, 1, '08:00:00', '13:00:00', 0, 3), +(12, 38, 2, '08:00:00', '13:00:00', 0, 3), +(13, 38, 3, '08:00:00', '13:00:00', 0, 3), +(14, 38, 4, '08:00:00', '13:00:00', 0, 3), +(15, 38, 5, '08:00:00', '13:00:00', 0, 3), +(16, 38, 4, '08:00:00', '13:00:00', 0, 4), +(17, 38, 5, '08:00:00', '13:00:00', 0, 4), +(18, 38, 1, '08:00:00', '13:00:00', 0, 4), +(19, 38, 2, '08:00:00', '13:00:00', 0, 4), +(20, 38, 3, '08:00:00', '13:00:00', 0, 4), +(21, 7, 1, '08:00:00', '13:00:00', 0, 1), +(22, 7, 2, '08:00:00', '13:00:00', 0, 1), +(23, 7, 3, '08:00:00', '13:00:00', 0, 1), +(24, 7, 4, '08:00:00', '13:00:00', 0, 1), +(25, 7, 5, '08:00:00', '13:00:00', 0, 1); +create view v1 as +select +zeit1.oid AS oid, +zeit1.fk_bbk_niederlassung AS fk_bbk_niederlassung, +zeit1.fk_wochentag AS fk_wochentag, +zeit1.uhrzeit_von AS uhrzeit_von, +zeit1.uhrzeit_bis AS uhrzeit_bis, +zeit1.geloescht AS geloescht, +zeit1.version AS version +from +t1 zeit1 +where +(zeit1.version = +(select max(zeit2.version) AS `max(version)` + from t1 zeit2 +where +((zeit1.fk_bbk_niederlassung = zeit2.fk_bbk_niederlassung) and +(zeit1.fk_wochentag = zeit2.fk_wochentag) and +(zeit1.uhrzeit_von = zeit2.uhrzeit_von) and +(zeit1.uhrzeit_bis = zeit2.uhrzeit_bis) +) +) +) +and (zeit1.geloescht = 0); +select * from v1 where oid = 21; +oid fk_bbk_niederlassung fk_wochentag uhrzeit_von uhrzeit_bis geloescht version +21 7 1 08:00:00 13:00:00 0 1 +drop view v1; +drop table t1; +CREATE TABLE t1( +t_cpac varchar(2) NOT NULL, +t_vers varchar(4) NOT NULL, +t_rele varchar(2) NOT NULL, +t_cust varchar(4) NOT NULL, +filler1 char(250) default NULL, +filler2 char(250) default NULL, +PRIMARY KEY (t_cpac,t_vers,t_rele,t_cust), +UNIQUE KEY IX_4 (t_cust,t_cpac,t_vers,t_rele), +KEY IX_5 (t_vers,t_rele,t_cust) +) charset latin1; +insert into t1 values +('tm','2.5 ','a ',' ','',''), ('tm','2.5U','a ','stnd','',''), +('da','3.3 ','b ',' ','',''), ('da','3.3U','b ','stnd','',''), +('tl','7.6 ','a ',' ','',''), ('tt','7.6 ','a ',' ','',''), +('bc','B61 ','a ',' ','',''), ('bp','B61 ','a ',' ','',''), +('ca','B61 ','a ',' ','',''), ('ci','B61 ','a ',' ','',''), +('cp','B61 ','a ',' ','',''), ('dm','B61 ','a ',' ','',''), +('ec','B61 ','a ',' ','',''), ('ed','B61 ','a ',' ','',''), +('fm','B61 ','a ',' ','',''), ('nt','B61 ','a ',' ','',''), +('qm','B61 ','a ',' ','',''), ('tc','B61 ','a ',' ','',''), +('td','B61 ','a ',' ','',''), ('tf','B61 ','a ',' ','',''), +('tg','B61 ','a ',' ','',''), ('ti','B61 ','a ',' ','',''), +('tp','B61 ','a ',' ','',''), ('ts','B61 ','a ',' ','',''), +('wh','B61 ','a ',' ','',''), ('bc','B61U','a ','stnd','',''), +('bp','B61U','a ','stnd','',''), ('ca','B61U','a ','stnd','',''), +('ci','B61U','a ','stnd','',''), ('cp','B61U','a ','stnd','',''), +('dm','B61U','a ','stnd','',''), ('ec','B61U','a ','stnd','',''), +('fm','B61U','a ','stnd','',''), ('nt','B61U','a ','stnd','',''), +('qm','B61U','a ','stnd','',''), ('tc','B61U','a ','stnd','',''), +('td','B61U','a ','stnd','',''), ('tf','B61U','a ','stnd','',''), +('tg','B61U','a ','stnd','',''), ('ti','B61U','a ','stnd','',''), +('tp','B61U','a ','stnd','',''), ('ts','B61U','a ','stnd','',''), +('wh','B61U','a ','stnd','',''); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `t_cpac` varchar(2) NOT NULL, + `t_vers` varchar(4) NOT NULL, + `t_rele` varchar(2) NOT NULL, + `t_cust` varchar(4) NOT NULL, + `filler1` char(250) DEFAULT NULL, + `filler2` char(250) DEFAULT NULL, + PRIMARY KEY (`t_cpac`,`t_vers`,`t_rele`,`t_cust`), + UNIQUE KEY `IX_4` (`t_cust`,`t_cpac`,`t_vers`,`t_rele`), + KEY `IX_5` (`t_vers`,`t_rele`,`t_cust`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +select t_vers,t_rele,t_cust,filler1 from t1 where t_vers = '7.6'; +t_vers t_rele t_cust filler1 +7.6 a +7.6 a +select t_vers,t_rele,t_cust,filler1 from t1 where t_vers = '7.6' + and t_rele='a' and t_cust = ' '; +t_vers t_rele t_cust filler1 +7.6 a +7.6 a +drop table t1; +# BUG#19021: Crash in index_merge/ROR-intersection optimizer under +# specific circumstances. +create table t1 ( +pk int(11) not null auto_increment, +a int(11) not null default '0', +b int(11) not null default '0', +c int(11) not null default '0', +filler1 datetime, filler2 varchar(15), +filler3 longtext, +kp1 varchar(4), kp2 varchar(7), +kp3 varchar(2), kp4 varchar(4), +kp5 varchar(7), +filler4 char(1), +primary key (pk), +key idx1(a,b,c), +key idx2(c), +key idx3(kp1,kp2,kp3,kp4,kp5) +) default charset=latin1; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +set @fill=NULL; +SELECT COUNT(*) FROM t1 WHERE b = 0 AND a = 0 AND c = 13286427 AND +kp1='279' AND kp2='ELM0678' AND kp3='6' AND kp4='10' AND kp5 = 'R '; +COUNT(*) +1 +drop table t1; +# BUG#21277: Index Merge/sort_union: wrong query results +create table t1 +( +key1 int not null, +key2 int not null default 0, +key3 int not null default 0 +); +insert into t1(key1) values (1),(2),(3),(4),(5),(6),(7),(8); +set @d=8; +insert into t1 (key1) select key1+@d from t1; +set @d=@d*2; +insert into t1 (key1) select key1+@d from t1; +set @d=@d*2; +insert into t1 (key1) select key1+@d from t1; +set @d=@d*2; +insert into t1 (key1) select key1+@d from t1; +set @d=@d*2; +insert into t1 (key1) select key1+@d from t1; +set @d=@d*2; +insert into t1 (key1) select key1+@d from t1; +set @d=@d*2; +insert into t1 (key1) select key1+@d from t1; +set @d=@d*2; +alter table t1 add index i2(key2); +alter table t1 add index i3(key3); +update t1 set key2=key1,key3=key1; +explain select * from t1 where (key3 > 30 and key3<35) or (key2 >32 and key2 < 40); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge i2,i3 i3,i2 4,4 NULL # 100.00 Using sort_union(i3,i2); Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`key1` AS `key1`,`test`.`t1`.`key2` AS `key2`,`test`.`t1`.`key3` AS `key3` from `test`.`t1` where (((`test`.`t1`.`key3` > 30) and (`test`.`t1`.`key3` < 35)) or ((`test`.`t1`.`key2` > 32) and (`test`.`t1`.`key2` < 40))) +select * from t1 where (key3 > 30 and key3<35) or (key2 >32 and key2 < 40); +key1 key2 key3 +31 31 31 +32 32 32 +33 33 33 +34 34 34 +35 35 35 +36 36 36 +37 37 37 +38 38 38 +39 39 39 +drop table t1; +# +# Bug#56423: Different count with SELECT and CREATE SELECT queries +# +CREATE TABLE t1 ( +a INT, +b INT, +c INT, +d INT, +PRIMARY KEY (a), +KEY (c), +KEY bd (b,d) +); +INSERT INTO t1 VALUES +(1, 0, 1, 0), +(2, 1, 1, 1), +(3, 1, 1, 1), +(4, 0, 1, 1); +EXPLAIN +SELECT a +FROM t1 +WHERE c = 1 AND b = 1 AND d = 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref c,bd bd 10 const,const 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where ((`test`.`t1`.`d` = 1) and (`test`.`t1`.`b` = 1) and (`test`.`t1`.`c` = 1)) +CREATE TABLE t2 ( a INT ) +SELECT a +FROM t1 +WHERE c = 1 AND b = 1 AND d = 1; +SELECT * FROM t2; +a +2 +3 +DROP TABLE t1, t2; +CREATE TABLE t1( a INT, b INT, KEY(a), KEY(b) ); +INSERT INTO t1 VALUES (1, 2), (1, 2), (1, 2), (1, 2); +SELECT * FROM t1 FORCE INDEX(a, b) WHERE a = 1 AND b = 2; +a b +1 2 +1 2 +1 2 +1 2 +DROP TABLE t1; +# Code coverage of fix. +CREATE TABLE t1 ( a INT NOT NULL AUTO_INCREMENT PRIMARY KEY, b INT); +INSERT INTO t1 (b) VALUES (1); +UPDATE t1 SET b = 2 WHERE a = 1; +SELECT * FROM t1; +a b +1 2 +CREATE TABLE t2 ( a INT NOT NULL AUTO_INCREMENT PRIMARY KEY, b VARCHAR(1) ); +INSERT INTO t2 (b) VALUES ('a'); +UPDATE t2 SET b = 'b' WHERE a = 1; +SELECT * FROM t2; +a b +1 b +DROP TABLE t1, t2; +# +# BUG#13970015: ASSERT `MIN_ENDP || MAX_ENDP' FAILED IN +# HANDLER::MULTI_RANGE_READ_INFO_CONST +# +CREATE TABLE t1 ( +pk INT NOT NULL, +col_int_key INT NOT NULL, +col_varchar_key VARCHAR(1) NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +); +INSERT INTO t1 VALUES (1,1,'a'), (2,2,'b'); +EXPLAIN +SELECT col_int_key +FROM t1 +WHERE col_varchar_key >= 'l' OR +(((pk BETWEEN 141 AND 141) OR col_varchar_key <> 'l') +AND ((pk BETWEEN 141 AND 141) OR (col_int_key > 141))); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 78.12 Parallel execute (1 workers) +2 SIMPLE t1 NULL index PRIMARY,col_int_key,col_varchar_key col_varchar_key 10 NULL 2 78.12 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col_int_key` AS `col_int_key` from `test`.`t1` where ((`test`.`t1`.`col_varchar_key` >= 'l') or (((`test`.`t1`.`pk` between 141 and 141) or (`test`.`t1`.`col_varchar_key` <> 'l')) and ((`test`.`t1`.`pk` between 141 and 141) or (`test`.`t1`.`col_int_key` > 141)))) +SELECT col_int_key +FROM t1 +WHERE col_varchar_key >= 'l' OR +(((pk BETWEEN 141 AND 141) OR col_varchar_key <> 'l') +AND ((pk BETWEEN 141 AND 141) OR (col_int_key > 141))); +col_int_key +DROP TABLE t1; +#---------------- 2-sweeps read Index merge test 2 ------------------------------- +# (Start of test file: index_merge_2sweeps.inc) +SET SESSION DEFAULT_STORAGE_ENGINE = InnoDB; +drop table if exists t1; +create table t1 ( +pk int primary key, +key1 int, +key2 int, +filler char(200), +filler2 char(200), +index(key1), +index(key2) +); +select * from t1 where (key1 >= 2 and key1 <= 10) or (pk >= 4 and pk <=8 ); +pk key1 key2 filler filler2 +10 10 10 filler-data filler-data-2 +2 2 2 filler-data filler-data-2 +3 3 3 filler-data filler-data-2 +4 4 4 filler-data filler-data-2 +5 5 5 filler-data filler-data-2 +6 6 6 filler-data filler-data-2 +7 7 7 filler-data filler-data-2 +8 8 8 filler-data filler-data-2 +9 9 9 filler-data filler-data-2 +set @maxv=1000; +select * from t1 where +(pk < 5) or (pk > 10 and pk < 15) or (pk >= 50 and pk < 55 ) or (pk > @maxv-10) +or key1=18 or key1=60; +pk key1 key2 filler filler2 +1 1 1 filler-data filler-data-2 +1000 1000 1000 filler-data filler-data-2 +11 11 11 filler-data filler-data-2 +12 12 12 filler-data filler-data-2 +13 13 13 filler-data filler-data-2 +14 14 14 filler-data filler-data-2 +18 18 18 filler-data filler-data-2 +2 2 2 filler-data filler-data-2 +3 3 3 filler-data filler-data-2 +4 4 4 filler-data filler-data-2 +50 50 50 filler-data filler-data-2 +51 51 51 filler-data filler-data-2 +52 52 52 filler-data filler-data-2 +53 53 53 filler-data filler-data-2 +54 54 54 filler-data filler-data-2 +60 60 60 filler-data filler-data-2 +991 991 991 filler-data filler-data-2 +992 992 992 filler-data filler-data-2 +993 993 993 filler-data filler-data-2 +994 994 994 filler-data filler-data-2 +995 995 995 filler-data filler-data-2 +996 996 996 filler-data filler-data-2 +997 997 997 filler-data filler-data-2 +998 998 998 filler-data filler-data-2 +999 999 999 filler-data filler-data-2 +select * from t1 where +(pk < 5) or (pk > 10 and pk < 15) or (pk >= 50 and pk < 55 ) or (pk > @maxv-10) +or key1 < 3 or key1 > @maxv-11; +pk key1 key2 filler filler2 +1 1 1 filler-data filler-data-2 +1000 1000 1000 filler-data filler-data-2 +11 11 11 filler-data filler-data-2 +12 12 12 filler-data filler-data-2 +13 13 13 filler-data filler-data-2 +14 14 14 filler-data filler-data-2 +2 2 2 filler-data filler-data-2 +3 3 3 filler-data filler-data-2 +4 4 4 filler-data filler-data-2 +50 50 50 filler-data filler-data-2 +51 51 51 filler-data filler-data-2 +52 52 52 filler-data filler-data-2 +53 53 53 filler-data filler-data-2 +54 54 54 filler-data filler-data-2 +990 990 990 filler-data filler-data-2 +991 991 991 filler-data filler-data-2 +992 992 992 filler-data filler-data-2 +993 993 993 filler-data filler-data-2 +994 994 994 filler-data filler-data-2 +995 995 995 filler-data filler-data-2 +996 996 996 filler-data filler-data-2 +997 997 997 filler-data filler-data-2 +998 998 998 filler-data filler-data-2 +999 999 999 filler-data filler-data-2 +select * from t1 where +(pk < 5) or (pk > 10 and pk < 15) or (pk >= 50 and pk < 55 ) or (pk > @maxv-10) +or +(key1 < 5) or (key1 > 10 and key1 < 15) or (key1 >= 50 and key1 < 55 ) or (key1 > @maxv-10); +pk key1 key2 filler filler2 +1 1 1 filler-data filler-data-2 +1000 1000 1000 filler-data filler-data-2 +11 11 11 filler-data filler-data-2 +12 12 12 filler-data filler-data-2 +13 13 13 filler-data filler-data-2 +14 14 14 filler-data filler-data-2 +2 2 2 filler-data filler-data-2 +3 3 3 filler-data filler-data-2 +4 4 4 filler-data filler-data-2 +50 50 50 filler-data filler-data-2 +51 51 51 filler-data filler-data-2 +52 52 52 filler-data filler-data-2 +53 53 53 filler-data filler-data-2 +54 54 54 filler-data filler-data-2 +991 991 991 filler-data filler-data-2 +992 992 992 filler-data filler-data-2 +993 993 993 filler-data filler-data-2 +994 994 994 filler-data filler-data-2 +995 995 995 filler-data filler-data-2 +996 996 996 filler-data filler-data-2 +997 997 997 filler-data filler-data-2 +998 998 998 filler-data filler-data-2 +999 999 999 filler-data filler-data-2 +select * from t1 where +(pk > 10 and pk < 15) or (pk >= 50 and pk < 55 ) +or +(key1 < 5) or (key1 > @maxv-10); +pk key1 key2 filler filler2 +1 1 1 filler-data filler-data-2 +1000 1000 1000 filler-data filler-data-2 +11 11 11 filler-data filler-data-2 +12 12 12 filler-data filler-data-2 +13 13 13 filler-data filler-data-2 +14 14 14 filler-data filler-data-2 +2 2 2 filler-data filler-data-2 +3 3 3 filler-data filler-data-2 +4 4 4 filler-data filler-data-2 +50 50 50 filler-data filler-data-2 +51 51 51 filler-data filler-data-2 +52 52 52 filler-data filler-data-2 +53 53 53 filler-data filler-data-2 +54 54 54 filler-data filler-data-2 +991 991 991 filler-data filler-data-2 +992 992 992 filler-data filler-data-2 +993 993 993 filler-data filler-data-2 +994 994 994 filler-data filler-data-2 +995 995 995 filler-data filler-data-2 +996 996 996 filler-data filler-data-2 +997 997 997 filler-data filler-data-2 +998 998 998 filler-data filler-data-2 +999 999 999 filler-data filler-data-2 +drop table t1; +#---------------- Clustered PK ROR-index_merge tests ----------------------------- +# (Start of test file: index_merge_ror_cpk.inc) +SET SESSION DEFAULT_STORAGE_ENGINE = InnoDB; +drop table if exists t1; +create table t1 +( +pk1 int not null, +pk2 int not null, +key1 int not null, +key2 int not null, +pktail1ok int not null, +pktail2ok int not null, +pktail3bad int not null, +pktail4bad int not null, +pktail5bad int not null, +pk2copy int not null, +badkey int not null, +filler1 char (200), +filler2 char (200), +key (key1), +key (key2), +/* keys with tails from CPK members */ +key (pktail1ok, pk1), +key (pktail2ok, pk1, pk2), +key (pktail3bad, pk2, pk1), +key (pktail4bad, pk1, pk2copy), +key (pktail5bad, pk1, pk2, pk2copy), +primary key (pk1, pk2) +); +# Verify that range scan on CPK is ROR +# (use index_intersection because it is impossible to check that for index union) +# Column 9, rows, can change depending on innodb-page-size. +explain select * from t1 where pk1 = 1 and pk2 < 80 and key1=0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL ROWS # Parallel execute (1 workers) +2 SIMPLE t1 NULL range PRIMARY,key1 PRIMARY 8 NULL ROWS # Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk1` AS `pk1`,`test`.`t1`.`pk2` AS `pk2`,`test`.`t1`.`key1` AS `key1`,`test`.`t1`.`key2` AS `key2`,`test`.`t1`.`pktail1ok` AS `pktail1ok`,`test`.`t1`.`pktail2ok` AS `pktail2ok`,`test`.`t1`.`pktail3bad` AS `pktail3bad`,`test`.`t1`.`pktail4bad` AS `pktail4bad`,`test`.`t1`.`pktail5bad` AS `pktail5bad`,`test`.`t1`.`pk2copy` AS `pk2copy`,`test`.`t1`.`badkey` AS `badkey`,`test`.`t1`.`filler1` AS `filler1`,`test`.`t1`.`filler2` AS `filler2` from `test`.`t1` where ((`test`.`t1`.`key1` = 0) and (`test`.`t1`.`pk1` = 1) and (`test`.`t1`.`pk2` < 80)) +# CPK scan + 1 ROR range scan is a special case +select * from t1 where pk1 = 1 and pk2 < 80 and key1=0; +pk1 pk2 key1 key2 pktail1ok pktail2ok pktail3bad pktail4bad pktail5bad pk2copy badkey filler1 filler2 +1 10 0 0 0 0 0 0 0 10 0 filler-data-10 filler2 +1 11 0 0 0 0 0 0 0 11 0 filler-data-11 filler2 +1 12 0 0 0 0 0 0 0 12 0 filler-data-12 filler2 +1 13 0 0 0 0 0 0 0 13 0 filler-data-13 filler2 +1 14 0 0 0 0 0 0 0 14 0 filler-data-14 filler2 +1 15 0 0 0 0 0 0 0 15 0 filler-data-15 filler2 +1 16 0 0 0 0 0 0 0 16 0 filler-data-16 filler2 +1 17 0 0 0 0 0 0 0 17 0 filler-data-17 filler2 +1 18 0 0 0 0 0 0 0 18 0 filler-data-18 filler2 +1 19 0 0 0 0 0 0 0 19 0 filler-data-19 filler2 +# Verify that CPK fields are considered to be covered by index scans +explain select pk1,pk2 from t1 where key1 = 10 and key2=10 and 2*pk1+1 < 2*96+1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge key1,key2 key1,key2 4,4 NULL 1 100.00 Using intersect(key1,key2); Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk1` AS `pk1`,`test`.`t1`.`pk2` AS `pk2` from `test`.`t1` where ((`test`.`t1`.`key2` = 10) and (`test`.`t1`.`key1` = 10) and (((2 * `test`.`t1`.`pk1`) + 1) < (((2 * 96) + 1)))) +select pk1,pk2 from t1 where key1 = 10 and key2=10 and 2*pk1+1 < 2*96+1; +pk1 pk2 +95 50 +95 51 +95 52 +95 53 +95 54 +95 55 +95 56 +95 57 +95 58 +95 59 +# Verify that CPK is always used for index intersection scans +# (this is because it is used as a filter, not for retrieval) +# The expected number of rows can vary depending on page size +explain select * from t1 where badkey=1 and key1=10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL ROWS 10.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref key1 key1 4 const ROWS 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk1` AS `pk1`,`test`.`t1`.`pk2` AS `pk2`,`test`.`t1`.`key1` AS `key1`,`test`.`t1`.`key2` AS `key2`,`test`.`t1`.`pktail1ok` AS `pktail1ok`,`test`.`t1`.`pktail2ok` AS `pktail2ok`,`test`.`t1`.`pktail3bad` AS `pktail3bad`,`test`.`t1`.`pktail4bad` AS `pktail4bad`,`test`.`t1`.`pktail5bad` AS `pktail5bad`,`test`.`t1`.`pk2copy` AS `pk2copy`,`test`.`t1`.`badkey` AS `badkey`,`test`.`t1`.`filler1` AS `filler1`,`test`.`t1`.`filler2` AS `filler2` from `test`.`t1` where ((`test`.`t1`.`key1` = 10) and (`test`.`t1`.`badkey` = 1)) +# The expected number of rows can vary depending on page size +explain select * from t1 where pk1 < 7500 and key1 = 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge PRIMARY,key1 key1,PRIMARY 8,4 NULL ROWS 100.00 Using intersect(key1,PRIMARY); Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk1` AS `pk1`,`test`.`t1`.`pk2` AS `pk2`,`test`.`t1`.`key1` AS `key1`,`test`.`t1`.`key2` AS `key2`,`test`.`t1`.`pktail1ok` AS `pktail1ok`,`test`.`t1`.`pktail2ok` AS `pktail2ok`,`test`.`t1`.`pktail3bad` AS `pktail3bad`,`test`.`t1`.`pktail4bad` AS `pktail4bad`,`test`.`t1`.`pktail5bad` AS `pktail5bad`,`test`.`t1`.`pk2copy` AS `pk2copy`,`test`.`t1`.`badkey` AS `badkey`,`test`.`t1`.`filler1` AS `filler1`,`test`.`t1`.`filler2` AS `filler2` from `test`.`t1` where ((`test`.`t1`.`key1` = 10) and (`test`.`t1`.`pk1` < 7500)) +# Verify that keys with 'tails' of PK members are ok. +explain select * from t1 where pktail1ok=1 and key1=10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge key1,pktail1ok key1,pktail1ok 4,4 NULL 1 100.00 Using intersect(key1,pktail1ok); Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk1` AS `pk1`,`test`.`t1`.`pk2` AS `pk2`,`test`.`t1`.`key1` AS `key1`,`test`.`t1`.`key2` AS `key2`,`test`.`t1`.`pktail1ok` AS `pktail1ok`,`test`.`t1`.`pktail2ok` AS `pktail2ok`,`test`.`t1`.`pktail3bad` AS `pktail3bad`,`test`.`t1`.`pktail4bad` AS `pktail4bad`,`test`.`t1`.`pktail5bad` AS `pktail5bad`,`test`.`t1`.`pk2copy` AS `pk2copy`,`test`.`t1`.`badkey` AS `badkey`,`test`.`t1`.`filler1` AS `filler1`,`test`.`t1`.`filler2` AS `filler2` from `test`.`t1` where ((`test`.`t1`.`key1` = 10) and (`test`.`t1`.`pktail1ok` = 1)) +explain select * from t1 where pktail2ok=1 and key1=10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge key1,pktail2ok key1,pktail2ok 4,4 NULL 1 100.00 Using intersect(key1,pktail2ok); Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk1` AS `pk1`,`test`.`t1`.`pk2` AS `pk2`,`test`.`t1`.`key1` AS `key1`,`test`.`t1`.`key2` AS `key2`,`test`.`t1`.`pktail1ok` AS `pktail1ok`,`test`.`t1`.`pktail2ok` AS `pktail2ok`,`test`.`t1`.`pktail3bad` AS `pktail3bad`,`test`.`t1`.`pktail4bad` AS `pktail4bad`,`test`.`t1`.`pktail5bad` AS `pktail5bad`,`test`.`t1`.`pk2copy` AS `pk2copy`,`test`.`t1`.`badkey` AS `badkey`,`test`.`t1`.`filler1` AS `filler1`,`test`.`t1`.`filler2` AS `filler2` from `test`.`t1` where ((`test`.`t1`.`key1` = 10) and (`test`.`t1`.`pktail2ok` = 1)) +# Note: The following is actually a deficiency, it uses sort_union currently. +# This comment refers to InnoDB and is probably not valid for other engines. +explain select * from t1 where (pktail2ok=1 and pk1< 50000) or key1=10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge PRIMARY,key1,pktail2ok pktail2ok,key1 8,4 NULL ROWS 100.00 Using sort_union(pktail2ok,key1); Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk1` AS `pk1`,`test`.`t1`.`pk2` AS `pk2`,`test`.`t1`.`key1` AS `key1`,`test`.`t1`.`key2` AS `key2`,`test`.`t1`.`pktail1ok` AS `pktail1ok`,`test`.`t1`.`pktail2ok` AS `pktail2ok`,`test`.`t1`.`pktail3bad` AS `pktail3bad`,`test`.`t1`.`pktail4bad` AS `pktail4bad`,`test`.`t1`.`pktail5bad` AS `pktail5bad`,`test`.`t1`.`pk2copy` AS `pk2copy`,`test`.`t1`.`badkey` AS `badkey`,`test`.`t1`.`filler1` AS `filler1`,`test`.`t1`.`filler2` AS `filler2` from `test`.`t1` where (((`test`.`t1`.`pktail2ok` = 1) and (`test`.`t1`.`pk1` < 50000)) or (`test`.`t1`.`key1` = 10)) +explain select * from t1 where pktail3bad=1 and key1=10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL EITHER_KEY NULL NULL ROWS 1.03 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref key1,pktail3bad EITHER_KEY 4 const ROWS 1.03 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk1` AS `pk1`,`test`.`t1`.`pk2` AS `pk2`,`test`.`t1`.`key1` AS `key1`,`test`.`t1`.`key2` AS `key2`,`test`.`t1`.`pktail1ok` AS `pktail1ok`,`test`.`t1`.`pktail2ok` AS `pktail2ok`,`test`.`t1`.`pktail3bad` AS `pktail3bad`,`test`.`t1`.`pktail4bad` AS `pktail4bad`,`test`.`t1`.`pktail5bad` AS `pktail5bad`,`test`.`t1`.`pk2copy` AS `pk2copy`,`test`.`t1`.`badkey` AS `badkey`,`test`.`t1`.`filler1` AS `filler1`,`test`.`t1`.`filler2` AS `filler2` from `test`.`t1` where ((`test`.`t1`.`key1` = 10) and (`test`.`t1`.`pktail3bad` = 1)) +explain select * from t1 where pktail4bad=1 and key1=10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL ROWS 1.03 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref key1,pktail4bad key1 4 const ROWS 1.03 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk1` AS `pk1`,`test`.`t1`.`pk2` AS `pk2`,`test`.`t1`.`key1` AS `key1`,`test`.`t1`.`key2` AS `key2`,`test`.`t1`.`pktail1ok` AS `pktail1ok`,`test`.`t1`.`pktail2ok` AS `pktail2ok`,`test`.`t1`.`pktail3bad` AS `pktail3bad`,`test`.`t1`.`pktail4bad` AS `pktail4bad`,`test`.`t1`.`pktail5bad` AS `pktail5bad`,`test`.`t1`.`pk2copy` AS `pk2copy`,`test`.`t1`.`badkey` AS `badkey`,`test`.`t1`.`filler1` AS `filler1`,`test`.`t1`.`filler2` AS `filler2` from `test`.`t1` where ((`test`.`t1`.`key1` = 10) and (`test`.`t1`.`pktail4bad` = 1)) +explain select * from t1 where pktail5bad=1 and key1=10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL ROWS 1.03 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref key1,pktail5bad key1 4 const ROWS 1.03 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk1` AS `pk1`,`test`.`t1`.`pk2` AS `pk2`,`test`.`t1`.`key1` AS `key1`,`test`.`t1`.`key2` AS `key2`,`test`.`t1`.`pktail1ok` AS `pktail1ok`,`test`.`t1`.`pktail2ok` AS `pktail2ok`,`test`.`t1`.`pktail3bad` AS `pktail3bad`,`test`.`t1`.`pktail4bad` AS `pktail4bad`,`test`.`t1`.`pktail5bad` AS `pktail5bad`,`test`.`t1`.`pk2copy` AS `pk2copy`,`test`.`t1`.`badkey` AS `badkey`,`test`.`t1`.`filler1` AS `filler1`,`test`.`t1`.`filler2` AS `filler2` from `test`.`t1` where ((`test`.`t1`.`key1` = 10) and (`test`.`t1`.`pktail5bad` = 1)) +# Test for problem with innodb key values prefetch buffer: +explain select pk1,pk2,key1,key2 from t1 where key1 = 10 and key2=10 limit 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge key1,key2 key1,key2 4,4 NULL 1 100.00 Using intersect(key1,key2); Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk1` AS `pk1`,`test`.`t1`.`pk2` AS `pk2`,`test`.`t1`.`key1` AS `key1`,`test`.`t1`.`key2` AS `key2` from `test`.`t1` where ((`test`.`t1`.`key2` = 10) and (`test`.`t1`.`key1` = 10)) limit 10 +select pk1,pk2,key1,key2 from t1 where key1 = 10 and key2=10 limit 10; +pk1 pk2 key1 key2 +95 50 10 10 +95 51 10 10 +95 52 10 10 +95 53 10 10 +95 54 10 10 +95 55 10 10 +95 56 10 10 +95 57 10 10 +95 58 10 10 +95 59 10 10 +drop table t1; +# Testcase for BUG#4984 +create table t1 +( +RUNID varchar(22), +SUBMITNR varchar(5), +ORDERNR char(1), +PROGRAMM varchar(8), +TESTID varchar(4), +UCCHECK char(1), +ETEXT varchar(80), +ETEXT_TYPE char(1), +INFO char(1), +SEVERITY tinyint(3), +TADIRFLAG char(1), +PRIMARY KEY (RUNID,SUBMITNR,ORDERNR,PROGRAMM,TESTID,UCCHECK), +KEY `TVERM~KEY` (PROGRAMM,TESTID,UCCHECK) +) DEFAULT CHARSET=latin1; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +update t1 set `ETEXT` = '', `ETEXT_TYPE`='', `INFO`='', `SEVERITY`='', `TADIRFLAG`='' +WHERE +`RUNID`= '' AND `SUBMITNR`= '' AND `ORDERNR`='' AND `PROGRAMM`='' AND +`TESTID`='' AND `UCCHECK`=''; +drop table t1; +# +# Bug#50402 Optimizer producing wrong results when using Index Merge on InnoDB +# +CREATE TABLE t1 (f1 INT, PRIMARY KEY (f1)); +INSERT INTO t1 VALUES (2); +CREATE TABLE t2 (f1 INT, f2 INT, f3 char(1), +PRIMARY KEY (f1), KEY (f2), KEY (f3) ); +INSERT INTO t2 VALUES (1, 1, 'h'), (2, 3, 'h'), (3, 2, ''), (4, 2, ''); +SELECT t1.f1 FROM t1 +WHERE (SELECT COUNT(*) FROM t2 WHERE t2.f3 = 'h' AND t2.f2 = t1.f1) = 0 AND t1.f1 = 2; +f1 +2 +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; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 Using index +2 DEPENDENT SUBQUERY t2 NULL index_merge f2,f3 f2,f3 5,5 NULL 1 100.00 Using intersect(f2,f3); Using where; Using index +Warnings: +Note 1276 Field or reference 'test.t1.f1' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `f1` from `test`.`t1` where true +DROP TABLE t1,t2; +# +# Bug#19055268 ASSERT `!TABLE || (!TABLE->READ_SET || BITMAP_IS_SET(TABLE->READ_SET,...) FAILED +# +SET sql_mode = ''; +CREATE TABLE t1 ( +pk int(11) NOT NULL AUTO_INCREMENT, +col_int_nokey int(11) NOT NULL, +col_int_key int(11) NOT NULL, +col_date_key date NOT NULL, +col_date_nokey date NOT NULL, +col_time_key time NOT NULL, +col_time_nokey time NOT NULL, +col_datetime_key datetime NOT NULL, +col_datetime_nokey datetime NOT NULL, +col_varchar_key varchar(1) NOT NULL, +col_varchar_nokey varchar(1) NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_date_key (col_date_key), +KEY col_time_key (col_time_key), +KEY col_datetime_key (col_datetime_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES +(1,2,1,'0000-00-00','0000-00-00','00:00:07','00:00:25','0000-00-00 00:00:00','0000-00-00 00:00:00','2','2'), +(109,25,1,'0000-00-00','0000-00-00','00:00:07','00:00:25','0000-00-00 00:00:00','0000-00-00 00:00:00','1','7'); +CREATE TABLE t2 ( +pk int(11) NOT NULL AUTO_INCREMENT, +col_int_nokey int(11) NOT NULL, +col_int_key int(11) NOT NULL, +col_date_key date NOT NULL, +col_date_nokey date NOT NULL, +col_time_key time NOT NULL, +col_time_nokey time NOT NULL, +col_datetime_key datetime NOT NULL, +col_datetime_nokey datetime NOT NULL, +col_varchar_key varchar(1) NOT NULL, +col_varchar_nokey varchar(1) NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_date_key (col_date_key), +KEY col_time_key (col_time_key), +KEY col_datetime_key (col_datetime_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES +(10,2,4,'2000-04-16','2000-04-16','17:02:34','17:02:34','2009-08-04 02:49:10','2009-08-04 02:49:10','u','u'), +(11,6,5,'1900-01-01','1900-01-01','12:31:32','12:31:32','2004-05-24 22:22:06','2004-05-24 22:22:06','b','b'), +(12,6,0,'2005-05-14','2005-05-14','16:49:31','16:49:31','1900-01-01 00:00:00','1900-01-01 00:00:00','c','c'), +(13,94,140,'2001-05-23','2001-05-23','00:00:00','00:00:00','2003-07-28 07:31:49','2003-07-28 07:31:49','f','f'), +(14,10,230,'2000-06-04','2000-06-04','20:23:27','20:23:27','2000-02-04 21:03:36','2000-02-04 21:03:36','g','g'), +(15,8,2,'1900-01-01','1900-01-01','10:31:09','10:31:09','2005-05-22 11:48:12','2005-05-22 11:48:12','q','q'), +(16,43,110,'2008-03-18','2008-03-18','09:58:35','09:58:35','1900-01-01 00:00:00','1900-01-01 00:00:00','n','n'), +(17,1,8,'2007-02-25','2007-02-25','05:39:28','05:39:28','2005-05-06 00:53:37','2005-05-06 00:53:37','c','c'), +(18,6,5,'2001-11-22','2001-11-22','00:00:00','00:00:00','2002-08-08 23:43:46','2002-08-08 23:43:46','x','x'), +(19,5,8,'0000-00-00','0000-00-00','00:00:00','00:00:00','2009-10-26 04:07:22','2009-10-26 04:07:22','n','n'), +(20,1,5,'2001-08-07','2001-08-07','14:06:09','14:06:09','2005-03-12 22:55:23','2005-03-12 22:55:23','r','r'), +(21,195,70,'2000-08-03','2000-08-03','00:00:00','00:00:00','2008-05-03 22:34:19','2008-05-03 22:34:19','j','j'), +(22,1,0,'2007-04-21','2007-04-21','17:43:27','17:43:27','2001-10-12 13:30:14','2001-10-12 13:30:14','l','l'), +(23,0,9,'2000-06-13','2000-06-13','12:23:15','12:23:15','2007-10-07 03:53:06','2007-10-07 03:53:06','h','h'), +(24,7,3,'0000-00-00','0000-00-00','19:35:06','19:35:06','2005-12-27 20:58:56','2005-12-27 20:58:56','z','z'), +(25,1,9,'2004-07-08','2004-07-08','10:16:08','10:16:08','2009-05-16 18:44:21','2009-05-16 18:44:21','z','z'), +(26,4,3,'2003-06-01','2003-06-01','00:00:00','00:00:00','2008-10-02 00:00:00','2008-10-02 00:00:00','d','d'), +(27,76,22,'0000-00-00','0000-00-00','16:51:15','16:51:15','2001-03-20 00:00:00','2001-03-20 00:00:00','l','l'), +(28,6,1,'1900-01-01','1900-01-01','00:00:00','00:00:00','1900-01-01 00:00:00','1900-01-01 00:00:00','s','s'), +(29,7,3,'2007-01-22','2007-01-22','00:00:00','00:00:00','2000-01-10 23:19:37','2000-01-10 23:19:37','k','k'), +(30,6,3,'2006-10-19','2006-10-19','21:46:20','21:46:20','2008-06-21 16:56:37','2008-06-21 16:56:37','l','l'), +(31,6,8,'2005-02-27','2005-02-27','00:00:00','00:00:00','2002-03-01 00:34:37','2002-03-01 00:34:37','t','t'), +(32,1,4,'2001-09-10','2001-09-10','03:34:16','03:34:16','2003-02-05 18:41:00','2003-02-05 18:41:00','n','n'), +(33,5,1,'2002-09-06','2002-09-06','11:25:31','11:25:31','2004-01-18 13:28:24','2004-01-18 13:28:24','z','z'), +(34,2,3,'2005-01-15','2005-01-15','17:00:53','17:00:53','2002-12-03 01:06:27','2002-12-03 01:06:27','f','f'), +(35,1,3,'1900-01-01','1900-01-01','23:32:47','23:32:47','2006-03-03 02:58:59','2006-03-03 02:58:59','q','q'), +(36,185,63,'2006-12-20','2006-12-20','00:00:00','00:00:00','2002-07-01 10:13:39','2002-07-01 10:13:39','l','l'), +(37,3,4,'2002-04-17','2002-04-17','12:15:05','12:15:05','2009-01-13 20:47:01','2009-01-13 20:47:01','a','a'), +(38,7,8,'2004-01-10','2004-01-10','22:26:38','22:26:38','2008-07-18 13:35:29','2008-07-18 13:35:29','c','c'), +(39,8,6,'2008-03-24','2008-03-24','00:00:00','00:00:00','2001-03-15 02:44:57','2001-03-15 02:44:57','c','c'), +(40,1,4,'2007-08-18','2007-08-18','00:00:00','00:00:00','2000-06-25 14:03:55','2000-06-25 14:03:55','i','i'), +(41,3,9,'2005-07-22','2005-07-22','00:00:00','00:00:00','2005-12-13 21:32:03','2005-12-13 21:32:03','r','r'), +(42,8,2,'2008-07-12','2008-07-12','08:59:37','08:59:37','2009-03-18 19:27:29','2009-03-18 19:27:29','g','g'), +(43,159,118,'2003-08-18','2003-08-18','07:19:50','07:19:50','2004-04-10 02:50:59','2004-04-10 02:50:59','l','l'), +(44,112,10,'2002-02-26','2002-02-26','03:51:46','03:51:46','2008-09-27 06:49:19','2008-09-27 06:49:19','w','w'), +(45,0,9,'2007-07-26','2007-07-26','15:57:32','15:57:32','2006-02-04 15:10:41','2006-02-04 15:10:41','b','b'), +(46,2,9,'1900-01-01','1900-01-01','02:57:08','02:57:08','2004-01-04 18:45:14','2004-01-04 18:45:14','i','i'), +(47,1,1,'2000-07-26','2000-07-26','00:21:15','00:21:15','2009-04-04 02:52:09','2009-04-04 02:52:09','o','o'), +(48,7,6,'2005-03-06','2005-03-06','23:35:02','23:35:02','2001-03-20 12:50:17','2001-03-20 12:50:17','f','f'), +(49,5,2,'2005-04-16','2005-04-16','09:21:51','09:21:51','2001-11-15 10:51:46','2001-11-15 10:51:46','a','a'), +(50,2,2,'2004-04-09','2004-04-09','19:21:02','19:21:02','2007-08-13 00:00:00','2007-08-13 00:00:00','j','j'), +(51,5,3,'2003-05-13','2003-05-13','03:16:22','03:16:22','1900-01-01 00:00:00','1900-01-01 00:00:00','k','k'), +(52,5,0,'0000-00-00','0000-00-00','00:00:00','00:00:00','2008-01-24 08:37:15','2008-01-24 08:37:15','x','x'), +(53,2,8,'2000-05-27','2000-05-27','18:19:51','18:19:51','2003-03-02 10:18:02','2003-03-02 10:18:02','r','r'), +(54,2,5,'2004-07-04','2004-07-04','01:42:17','01:42:17','2003-04-25 07:35:13','2003-04-25 07:35:13','t','t'), +(55,9,0,'2006-03-07','2006-03-07','00:00:00','00:00:00','2006-07-11 23:31:13','2006-07-11 23:31:13','p','p'), +(56,3,1,'2002-08-17','2002-08-17','20:32:51','20:32:51','2009-08-08 16:55:59','2009-08-08 16:55:59','g','g'), +(57,2,9,'2003-06-08','2003-06-08','10:04:19','10:04:19','1900-01-01 00:00:00','1900-01-01 00:00:00','q','q'), +(58,7,4,'1900-01-01','1900-01-01','06:39:26','06:39:26','2000-12-22 10:27:41','2000-12-22 10:27:41','m','m'), +(59,4,7,'2003-10-09','2003-10-09','15:48:26','15:48:26','2002-07-20 00:00:00','2002-07-20 00:00:00','l','l'), +(60,5,6,'2007-08-12','2007-08-12','02:17:23','02:17:23','2007-09-24 00:12:11','2007-09-24 00:12:11','d','d'), +(61,3,3,'2008-12-13','2008-12-13','07:48:47','07:48:47','2009-01-05 06:13:21','2009-01-05 06:13:21','n','n'), +(62,0,8,'0000-00-00','0000-00-00','09:09:14','09:09:14','2008-11-23 18:13:35','2008-11-23 18:13:35','l','l'), +(63,1,2,'2003-07-27','2003-07-27','22:46:23','22:46:23','2002-12-19 00:00:00','2002-12-19 00:00:00','c','c'), +(64,5,5,'2003-04-13','2003-04-13','19:42:42','19:42:42','2003-04-03 16:16:35','2003-04-03 16:16:35','v','v'), +(65,0,3,'2007-04-25','2007-04-25','15:15:32','15:15:32','2009-04-13 13:44:41','2009-04-13 13:44:41','z','z'), +(66,4,4,'2000-03-04','2000-03-04','02:50:26','02:50:26','2007-04-19 20:49:24','2007-04-19 20:49:24','h','h'), +(67,0,9,'2001-08-03','2001-08-03','14:44:31','14:44:31','2002-11-15 23:36:04','2002-11-15 23:36:04','y','y'), +(68,2,0,'2006-04-13','2006-04-13','00:00:00','00:00:00','2000-05-16 00:00:00','2000-05-16 00:00:00','o','o'), +(69,2,1,'2006-04-22','2006-04-22','07:31:27','07:31:27','2002-06-08 06:51:27','2002-06-08 06:51:27','h','h'), +(70,8,5,'2004-08-26','2004-08-26','10:48:57','10:48:57','2006-12-07 01:49:26','2006-12-07 01:49:26','h','h'), +(71,8,6,'2002-11-26','2002-11-26','00:00:00','00:00:00','1900-01-01 00:00:00','1900-01-01 00:00:00','c','c'), +(72,5,2,'2002-01-07','2002-01-07','23:06:00','23:06:00','2000-09-27 16:26:23','2000-09-27 16:26:23','m','m'), +(73,1,0,'2005-05-07','2005-05-07','05:56:02','05:56:02','1900-01-01 00:00:00','1900-01-01 00:00:00','s','s'), +(74,0,0,'2001-04-21','2001-04-21','10:44:22','10:44:22','2008-02-13 04:28:14','2008-02-13 04:28:14','t','t'), +(75,7,9,'2000-09-01','2000-09-01','00:00:00','00:00:00','2000-03-10 06:17:52','2000-03-10 06:17:52','r','r'), +(76,6,8,'2004-07-06','2004-07-06','01:44:26','01:44:26','2003-05-23 00:00:00','2003-05-23 00:00:00','u','u'), +(77,0,6,'0000-00-00','0000-00-00','00:00:00','00:00:00','1900-01-01 00:00:00','1900-01-01 00:00:00','h','h'), +(78,6,0,'2001-02-21','2001-02-21','17:01:49','17:01:49','2003-10-27 12:45:52','2003-10-27 12:45:52','p','p'), +(79,9,0,'2004-01-28','2004-01-28','16:27:14','16:27:14','2004-08-06 00:00:00','2004-08-06 00:00:00','z','z'), +(80,5,3,'2008-10-07','2008-10-07','00:00:00','00:00:00','2001-10-05 05:13:39','2001-10-05 05:13:39','h','h'), +(81,5,5,'0000-00-00','0000-00-00','10:34:22','10:34:22','2001-03-25 04:24:51','2001-03-25 04:24:51','q','q'), +(82,6,0,'2008-03-04','2008-03-04','10:48:51','10:48:51','2006-08-20 11:54:04','2006-08-20 11:54:04','l','l'), +(83,1,0,'2009-05-08','2009-05-08','16:55:06','16:55:06','2003-05-16 18:14:52','2003-05-16 18:14:52','p','p'), +(84,1,1,'2005-03-19','2005-03-19','14:46:32','14:46:32','2009-10-24 13:39:35','2009-10-24 13:39:35','t','t'), +(85,9,8,'2007-09-14','2007-09-14','16:26:50','16:26:50','2001-08-10 00:00:00','2001-08-10 00:00:00','o','o'), +(86,249,190,'2007-02-10','2007-02-10','06:35:32','06:35:32','2001-09-06 10:15:08','2001-09-06 10:15:08','o','o'), +(87,3,0,'2000-06-12','2000-06-12','02:28:38','02:28:38','2006-09-27 00:00:00','2006-09-27 00:00:00','p','p'), +(88,6,4,'2002-07-06','2002-07-06','00:00:00','00:00:00','2002-02-27 20:12:29','2002-02-27 20:12:29','e','e'), +(89,7,2,'2001-02-25','2001-02-25','04:52:29','04:52:29','1900-01-01 00:00:00','1900-01-01 00:00:00','u','u'), +(90,5,8,'2000-04-27','2000-04-27','00:00:00','00:00:00','2005-08-18 00:00:00','2005-08-18 00:00:00','z','z'), +(91,4,0,'2005-08-23','2005-08-23','09:11:04','09:11:04','2000-10-15 15:52:54','2000-10-15 15:52:54','j','j'), +(92,24,137,'2006-01-07','2006-01-07','22:38:18','22:38:18','2007-11-22 13:52:22','2007-11-22 13:52:22','e','e'), +(93,3,7,'2007-07-08','2007-07-08','13:23:13','13:23:13','2005-09-20 09:09:48','2005-09-20 09:09:48','k','k'), +(94,179,153,'2000-01-06','2000-01-06','15:33:10','15:33:10','2008-01-11 17:35:34','2008-01-11 17:35:34','d','d'), +(95,5,7,'0000-00-00','0000-00-00','09:20:10','09:20:10','2002-11-01 00:00:00','2002-11-01 00:00:00','q','q'), +(96,7,9,'2002-02-22','2002-02-22','11:19:10','11:19:10','2009-06-27 00:00:00','2009-06-27 00:00:00','j','j'), +(97,7,2,'2001-04-17','2001-04-17','08:08:41','08:08:41','2000-09-25 14:11:58','2000-09-25 14:11:58','j','j'), +(98,1,0,'2005-06-26','2005-06-26','10:17:36','10:17:36','2004-01-05 04:49:39','2004-01-05 04:49:39','e','e'), +(99,5,6,'2008-09-14','2008-09-14','00:00:00','00:00:00','1900-01-01 00:00:00','1900-01-01 00:00:00','f','f'), +(100,7,6,'0000-00-00','0000-00-00','01:05:02','01:05:02','2001-01-17 23:16:24','2001-01-17 23:16:24','a','a'), +(101,9,2,'2001-12-20','2001-12-20','00:00:00','00:00:00','1900-01-01 00:00:00','1900-01-01 00:00:00','o','o'), +(102,5,9,'2001-11-05','2001-11-05','00:00:00','00:00:00','2008-07-15 00:00:00','2008-07-15 00:00:00','y','y'), +(103,4,4,'1900-01-01','1900-01-01','15:32:04','15:32:04','2001-03-06 10:00:37','2001-03-06 10:00:37','d','d'), +(104,8,7,'2009-02-13','2009-02-13','20:25:36','20:25:36','2004-08-15 00:00:00','2004-08-15 00:00:00','z','z'), +(105,8,6,'2008-03-25','2008-03-25','21:33:53','21:33:53','2006-10-12 06:13:06','2006-10-12 06:13:06','s','s'); +analyze table t1; +analyze table t2; +EXPLAIN UPDATE t1 SET col_time_nokey = 25 +WHERE (col_varchar_key, col_varchar_nokey) IN ( +SELECT col_int_key, col_int_key +FROM t2 +WHERE (col_time_key, col_int_key, col_int_key) IN ( +(0, 'a', 'm'), (0, 'n', 7) +) +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL col_varchar_key NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL index_merge col_int_key,col_time_key col_int_key,col_time_key 4,3 NULL 3 100.00 Using intersect(col_int_key,col_time_key); Using where; Using index; FirstMatch(t1) +UPDATE t1 SET col_time_nokey = 25 +WHERE (col_varchar_key, col_varchar_nokey) IN ( +SELECT col_int_key, col_int_key +FROM t2 +WHERE (col_time_key, col_int_key, col_int_key) IN ( +(0, 'a', 'm'), (0, 'n', 7) +) +); +DROP TABLE t1, t2; +SET sql_mode = default; +# +# Bug#11747423 32254: INDEX MERGE USED UNNECESSARILY +# +CREATE TABLE t1 ( +id INT NOT NULL PRIMARY KEY, +id2 INT NOT NULL, +id3 INT NOT NULL, +KEY (id2), +KEY (id3), +KEY covering_index (id2,id3) +) ENGINE=InnoDB; +INSERT INTO t1 VALUES (0, 0, 0), (1, 1, 1), (2, 2, 2), (3, 3, 3), (4, 4, 4), (5, 5, 5), (6, 6, 6), (7, 7, 7); +INSERT INTO t1 SELECT id + 8, id2 + 8, id3 +8 FROM t1; +INSERT INTO t1 SELECT id + 16, 7, 0 FROM t1; +EXPLAIN SELECT count(*) FROM t1 WHERE id2=7 AND id3=0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 16 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref id2,id3,covering_index covering_index 8 const,const 16 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select count(0) AS `count(*)` from `test`.`t1` where ((`test`.`t1`.`id3` = 0) and (`test`.`t1`.`id2` = 7)) +DROP TABLE t1; +# +# Bug#21697002 ASSERTION `KEYS >= 0.0' FAILED +# +CREATE TABLE t1 ( +c1 VARCHAR(2), +d1 DATETIME NOT NULL +); +CREATE TABLE t2 ( +pk INTEGER NOT NULL, +c1 VARCHAR(2), +c2 VARCHAR(2), +PRIMARY KEY (pk), +KEY (c1), +KEY (c2) +) PARTITION BY KEY(pk) PARTITIONS 2; +SELECT c1 +FROM t1 +WHERE c1 IN +( +SELECT t2.c1 +FROM t2 +WHERE t2.c1 = 'f' + OR t2.c2 < 'y' +) +AND t1.d1 IS NULL; +c1 +DROP TABLE t1, t2; diff --git a/mysql-test/r/innodb_explain_json_non_select_all.result-pq b/mysql-test/r/innodb_explain_json_non_select_all.result-pq new file mode 100644 index 000000000000..99294737a19e --- /dev/null +++ b/mysql-test/r/innodb_explain_json_non_select_all.result-pq @@ -0,0 +1,9486 @@ +set optimizer_switch='semijoin=on,materialization=on,firstmatch=on,loosescan=on,index_condition_pushdown=on,mrr=on,mrr_cost_based=off'; +set @save_storage_engine= @@session.default_storage_engine; +set session default_storage_engine = InnoDB; +set end_markers_in_json=on; +#1 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +# +# query: UPDATE t1 SET a = 10 WHERE a < 10 +# select: SELECT * FROM t1 WHERE a < 10 +# +EXPLAIN UPDATE t1 SET a = 10 WHERE a < 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`a` = 10 where (`test`.`t1`.`a` < 10) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t1 SET a = 10 WHERE a < 10;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "table": { + "update": true, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "filtered": "100.00", + "attached_condition": "(`test`.`t1`.`a` < 10)" + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`a` = 10 where (`test`.`t1`.`a` < 10) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 WHERE a < 10;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.55" + } /* cost_info */, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 1, + "filtered": "33.33", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.45", + "eval_cost": "0.10", + "prefix_cost": "0.55", + "data_read_per_join": "16" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "query_block": { + "cost_info": { + "query_cost": "0.55" + } /* cost_info */, + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 1, + "filtered": "33.33", + "cost_info": { + "read_cost": "0.45", + "eval_cost": "0.10", + "prefix_cost": "0.55", + "data_read_per_join": "8" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`a` < 10)" + } /* table */ + } /* query_block */ + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` < 10) +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 2 +Handler_read_rnd_next 4 +# Status of testing query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 2 +Handler_read_rnd_next 4 +Handler_update 3 + +DROP TABLE t1; +#2 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +# +# query: DELETE FROM t1 WHERE a < 10 +# select: SELECT * FROM t1 WHERE a < 10 +# +EXPLAIN DELETE FROM t1 WHERE a < 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 delete from `test`.`t1` where (`test`.`t1`.`a` < 10) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t1 WHERE a < 10;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "table": { + "delete": true, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "filtered": "100.00", + "attached_condition": "(`test`.`t1`.`a` < 10)" + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 delete from `test`.`t1` where (`test`.`t1`.`a` < 10) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 WHERE a < 10;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.55" + } /* cost_info */, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 1, + "filtered": "33.33", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.45", + "eval_cost": "0.10", + "prefix_cost": "0.55", + "data_read_per_join": "16" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "query_block": { + "cost_info": { + "query_cost": "0.55" + } /* cost_info */, + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 1, + "filtered": "33.33", + "cost_info": { + "read_cost": "0.45", + "eval_cost": "0.10", + "prefix_cost": "0.55", + "data_read_per_join": "8" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`a` < 10)" + } /* table */ + } /* query_block */ + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` < 10) +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 2 +Handler_read_rnd_next 4 +# Status of testing query execution: +Variable_name Value +Handler_delete 3 +Handler_read_first 1 +Handler_read_key 2 +Handler_read_rnd_next 4 + +DROP TABLE t1; +#3 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +# +# query: DELETE FROM t1 USING t1 WHERE a = 1 +# select: SELECT * FROM t1 WHERE a = 1 +# +EXPLAIN DELETE FROM t1 USING t1 WHERE a = 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 delete `test`.`t1` from `test`.`t1` where (`test`.`t1`.`a` = 1) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t1 USING t1 WHERE a = 1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.55" + } /* cost_info */, + "table": { + "delete": true, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 1, + "filtered": "33.33", + "cost_info": { + "read_cost": "0.45", + "eval_cost": "0.10", + "prefix_cost": "0.55", + "data_read_per_join": "8" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`a` = 1)" + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 delete `test`.`t1` from `test`.`t1` where (`test`.`t1`.`a` = 1) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 WHERE a = 1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.55" + } /* cost_info */, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 1, + "filtered": "33.33", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.45", + "eval_cost": "0.10", + "prefix_cost": "0.55", + "data_read_per_join": "16" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "query_block": { + "cost_info": { + "query_cost": "0.55" + } /* cost_info */, + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 1, + "filtered": "33.33", + "cost_info": { + "read_cost": "0.45", + "eval_cost": "0.10", + "prefix_cost": "0.55", + "data_read_per_join": "8" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`a` = 1)" + } /* table */ + } /* query_block */ + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` = 1) +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 2 +Handler_read_rnd_next 4 +# Status of testing query execution: +Variable_name Value +Handler_delete 1 +Handler_read_first 1 +Handler_read_key 2 +Handler_read_rnd_next 4 + +DROP TABLE t1; +#4 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +CREATE TABLE t2 (b INT); +INSERT INTO t2 VALUES (1), (2), (3); +# +# query: UPDATE t1, t2 SET t1.a = 10 WHERE t1.a = 1 +# select: SELECT * FROM t1, t2 WHERE t1.a = 1 +# +EXPLAIN UPDATE t1, t2 SET t1.a = 10 WHERE t1.a = 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 update `test`.`t1` join `test`.`t2` set `test`.`t1`.`a` = 10 where (`test`.`t1`.`a` = 1) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t1, t2 SET t1.a = 10 WHERE t1.a = 1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.10" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "update": true, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 1, + "filtered": "33.33", + "cost_info": { + "read_cost": "0.45", + "eval_cost": "0.10", + "prefix_cost": "0.55", + "data_read_per_join": "8" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`a` = 1)" + } /* table */ + }, + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.30", + "prefix_cost": "1.10", + "data_read_per_join": "24" + } /* cost_info */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t1` join `test`.`t2` set `test`.`t1`.`a` = 10 where (`test`.`t1`.`a` = 1) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1, t2 WHERE t1.a = 1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.10" + } /* cost_info */, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 1, + "filtered": "33.33", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.45", + "eval_cost": "0.10", + "prefix_cost": "0.55", + "data_read_per_join": "16" + } /* cost_info */, + "used_columns": [ + "a", + "b" + ] /* used_columns */, + "query_block": { + "cost_info": { + "query_cost": "1.10" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 1, + "filtered": "33.33", + "cost_info": { + "read_cost": "0.45", + "eval_cost": "0.10", + "prefix_cost": "0.55", + "data_read_per_join": "8" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`a` = 1)" + } /* table */ + }, + { + "table": { + "select_id": 2, + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.30", + "prefix_cost": "1.10", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "b" + ] /* used_columns */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` join `test`.`t2` where (`test`.`t1`.`a` = 1) +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 2 +Handler_read_key 4 +Handler_read_rnd_next 8 +# Status of testing query execution: +Variable_name Value +Handler_read_first 2 +Handler_read_key 4 +Handler_read_rnd_next 8 +Handler_update 1 + +DROP TABLE t1, t2; +#5 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +CREATE TABLE t2 (b INT); +INSERT INTO t2 VALUES (1), (2), (3); +# +# query: UPDATE t1 t11, (SELECT * FROM t2) t12 SET t11.a = 10 WHERE t11.a = 1 +# select: SELECT * FROM t1 t11, (SELECT * FROM t2) t12 WHERE t11.a = 1 +# +EXPLAIN UPDATE t1 t11, (SELECT * FROM t2) t12 SET t11.a = 10 WHERE t11.a = 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t11 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 update `test`.`t1` `t11` join `test`.`t2` set `test`.`t11`.`a` = 10 where (`test`.`t11`.`a` = 1) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t1 t11, (SELECT * FROM t2) t12 SET t11.a = 10 WHERE t11.a = 1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.10" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "update": true, + "table_name": "t11", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 1, + "filtered": "33.33", + "cost_info": { + "read_cost": "0.45", + "eval_cost": "0.10", + "prefix_cost": "0.55", + "data_read_per_join": "8" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t11`.`a` = 1)" + } /* table */ + }, + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.30", + "prefix_cost": "1.10", + "data_read_per_join": "24" + } /* cost_info */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t1` `t11` join `test`.`t2` set `test`.`t11`.`a` = 10 where (`test`.`t11`.`a` = 1) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 t11, (SELECT * FROM t2) t12 WHERE t11.a = 1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.10" + } /* cost_info */, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 1, + "filtered": "33.33", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.45", + "eval_cost": "0.10", + "prefix_cost": "0.55", + "data_read_per_join": "16" + } /* cost_info */, + "used_columns": [ + "a", + "b" + ] /* used_columns */, + "query_block": { + "cost_info": { + "query_cost": "1.10" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "select_id": 2, + "table_name": "t11", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 1, + "filtered": "33.33", + "cost_info": { + "read_cost": "0.45", + "eval_cost": "0.10", + "prefix_cost": "0.55", + "data_read_per_join": "8" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t11`.`a` = 1)" + } /* table */ + }, + { + "table": { + "select_id": 2, + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.30", + "prefix_cost": "1.10", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "b" + ] /* used_columns */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t11`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` `t11` join `test`.`t2` where (`test`.`t11`.`a` = 1) +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 2 +Handler_read_key 4 +Handler_read_rnd_next 8 +# Status of testing query execution: +Variable_name Value +Handler_read_first 2 +Handler_read_key 4 +Handler_read_rnd_next 8 +Handler_update 1 + +DROP TABLE t1, t2; +#6 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +CREATE TABLE t2 (b INT); +INSERT INTO t2 VALUES (1), (2), (3); +# +# query: UPDATE t1 SET a = 10 WHERE 1 IN (SELECT 1 FROM t2 WHERE t2.b < 3) +# select: SELECT * FROM t1 WHERE 1 IN (SELECT 1 FROM t2 WHERE t2.b < 3) +# +EXPLAIN UPDATE t1 SET a = 10 WHERE 1 IN (SELECT 1 FROM t2 WHERE t2.b < 3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`a` = 10 where (`test`.`t2`.`b` < 3) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t1 SET a = 10 WHERE 1 IN (SELECT 1 FROM t2 WHERE t2.b < 3);; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.10" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 1, + "filtered": "33.33", + "first_match": true, + "cost_info": { + "read_cost": "0.45", + "eval_cost": "0.10", + "prefix_cost": "0.55", + "data_read_per_join": "8" + } /* cost_info */, + "used_columns": [ + "b" + ] /* used_columns */, + "attached_condition": "(`test`.`t2`.`b` < 3)" + } /* table */ + }, + { + "table": { + "update": true, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.30", + "prefix_cost": "1.10", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`a` = 10 where (`test`.`t2`.`b` < 3) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 WHERE 1 IN (SELECT 1 FROM t2 WHERE t2.b < 3);; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.10" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 1, + "filtered": "33.33", + "first_match": true, + "cost_info": { + "read_cost": "0.45", + "eval_cost": "0.10", + "prefix_cost": "0.55", + "data_read_per_join": "8" + } /* cost_info */, + "used_columns": [ + "b" + ] /* used_columns */, + "attached_condition": "(`test`.`t2`.`b` < 3)" + } /* table */ + }, + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.30", + "prefix_cost": "1.10", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t2`) where (`test`.`t2`.`b` < 3) +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 2 +Handler_read_key 4 +Handler_read_rnd_next 5 +# Status of testing query execution: +Variable_name Value +Handler_read_first 2 +Handler_read_key 7 +Handler_read_rnd 3 +Handler_read_rnd_next 9 +Handler_update 3 +Handler_write 3 + +DROP TABLE t1, t2; +#7 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +CREATE TABLE t2 (b INT); +INSERT INTO t2 VALUES (1), (2), (3); +# +# query: UPDATE t1 SET a = 10 WHERE a IN (SELECT b FROM t2 WHERE t1.a < 3) +# select: SELECT * FROM t1 WHERE a IN (SELECT b FROM t2 WHERE t1.a < 3) +# +EXPLAIN UPDATE t1 SET a = 10 WHERE a IN (SELECT b FROM t2 WHERE t1.a < 3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 update `test`.`t1` set `test`.`t1`.`a` = 10 where ((`test`.`t2`.`b` = `test`.`t1`.`a`) and (`test`.`t1`.`a` < 3)) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t1 SET a = 10 WHERE a IN (SELECT b FROM t2 WHERE t1.a < 3);; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.10" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "update": true, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 1, + "filtered": "33.33", + "cost_info": { + "read_cost": "0.45", + "eval_cost": "0.10", + "prefix_cost": "0.55", + "data_read_per_join": "8" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`a` < 3)" + } /* table */ + }, + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 1, + "filtered": "33.33", + "first_match": "t1", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.10", + "prefix_cost": "1.10", + "data_read_per_join": "8" + } /* cost_info */, + "used_columns": [ + "b" + ] /* used_columns */, + "attached_condition": "(`test`.`t2`.`b` = `test`.`t1`.`a`)" + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 update `test`.`t1` set `test`.`t1`.`a` = 10 where ((`test`.`t2`.`b` = `test`.`t1`.`a`) and (`test`.`t1`.`a` < 3)) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 WHERE a IN (SELECT b FROM t2 WHERE t1.a < 3);; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.10" + } /* cost_info */, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 1, + "filtered": "33.33", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.45", + "eval_cost": "0.10", + "prefix_cost": "0.55", + "data_read_per_join": "16" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "query_block": { + "cost_info": { + "query_cost": "1.10" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 1, + "filtered": "33.33", + "cost_info": { + "read_cost": "0.45", + "eval_cost": "0.10", + "prefix_cost": "0.55", + "data_read_per_join": "8" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`a` < 3)" + } /* table */ + }, + { + "table": { + "select_id": 2, + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 1, + "filtered": "33.33", + "first_match": "t1", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.10", + "prefix_cost": "1.10", + "data_read_per_join": "8" + } /* cost_info */, + "used_columns": [ + "b" + ] /* used_columns */, + "attached_condition": "(`test`.`t2`.`b` = `test`.`t1`.`a`)" + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ + } /* table */ + } /* query_block */ +} +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`b` = `test`.`t1`.`a`) and (`test`.`t1`.`a` < 3)) +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 2 +Handler_read_key 4 +Handler_read_rnd_next 8 +# Status of testing query execution: +Variable_name Value +Handler_read_first 3 +Handler_read_key 5 +Handler_read_rnd_next 7 +Handler_update 2 + +DROP TABLE t1, t2; +#7 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +CREATE TABLE t2 (b INT); +INSERT INTO t2 VALUES (1), (2), (3); +# +# query: UPDATE t1, t2 SET a = 10 WHERE a IN (SELECT b FROM t2 WHERE t2.b < 3) +# select: SELECT * FROM t1, t2 WHERE a IN (SELECT b FROM t2 WHERE t2.b < 3) +# +EXPLAIN UPDATE t1, t2 SET a = 10 WHERE a IN (SELECT b FROM t2 WHERE t2.b < 3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(t1) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 update `test`.`t1` join `test`.`t2` semi join (`test`.`t2`) set `test`.`t1`.`a` = 10 where ((`test`.`t2`.`b` = `test`.`t1`.`a`) and (`test`.`t1`.`a` < 3)) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t1, t2 SET a = 10 WHERE a IN (SELECT b FROM t2 WHERE t2.b < 3);; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "2.45" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "update": true, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.30", + "prefix_cost": "0.55", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`a` < 3)" + } /* table */ + }, + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "33.33", + "first_match": "t1", + "cost_info": { + "read_cost": "0.45", + "eval_cost": "0.30", + "prefix_cost": "1.30", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "b" + ] /* used_columns */, + "attached_condition": "(`test`.`t2`.`b` = `test`.`t1`.`a`)" + } /* table */ + }, + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 9, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.90", + "prefix_cost": "2.45", + "data_read_per_join": "72" + } /* cost_info */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t1` join `test`.`t2` semi join (`test`.`t2`) set `test`.`t1`.`a` = 10 where ((`test`.`t2`.`b` = `test`.`t1`.`a`) and (`test`.`t1`.`a` < 3)) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1, t2 WHERE a IN (SELECT b FROM t2 WHERE t2.b < 3);; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "2.45" + } /* cost_info */, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.30", + "prefix_cost": "0.55", + "data_read_per_join": "48" + } /* cost_info */, + "used_columns": [ + "a", + "b" + ] /* used_columns */, + "query_block": { + "cost_info": { + "query_cost": "2.45" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.30", + "prefix_cost": "0.55", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`a` < 3)" + } /* table */ + }, + { + "table": { + "select_id": 2, + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "33.33", + "first_match": "t1", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.45", + "eval_cost": "0.30", + "prefix_cost": "1.30", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "b" + ] /* used_columns */, + "attached_condition": "(`test`.`t2`.`b` = `test`.`t1`.`a`)" + } /* table */ + }, + { + "table": { + "select_id": 2, + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 9, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.90", + "prefix_cost": "2.45", + "data_read_per_join": "72" + } /* cost_info */, + "used_columns": [ + "b" + ] /* used_columns */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` join `test`.`t2` semi join (`test`.`t2`) where ((`test`.`t2`.`b` = `test`.`t1`.`a`) and (`test`.`t1`.`a` < 3)) +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 3 +Handler_read_key 5 +Handler_read_rnd_next 12 +# Status of testing query execution: +Variable_name Value +Handler_read_first 5 +Handler_read_key 7 +Handler_read_rnd_next 15 +Handler_update 2 + +DROP TABLE t1, t2; +#8 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +CREATE TABLE t2 (b INT); +INSERT INTO t2 VALUES (1), (2), (3); +# +# query: UPDATE t1 t11, (SELECT * FROM t2) t12 SET t11.a = t11.a + 10 +# select: SELECT * FROM t1 t11, (SELECT * FROM t2) t12 +# +EXPLAIN UPDATE t1 t11, (SELECT * FROM t2) t12 SET t11.a = t11.a + 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t11 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 update `test`.`t1` `t11` join `test`.`t2` set `test`.`t11`.`a` = (`test`.`t11`.`a` + 10) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t1 t11, (SELECT * FROM t2) t12 SET t11.a = t11.a + 10;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.70" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "update": true, + "table_name": "t11", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.30", + "prefix_cost": "0.55", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */ + } /* table */ + }, + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 9, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.90", + "prefix_cost": "1.70", + "data_read_per_join": "72" + } /* cost_info */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t1` `t11` join `test`.`t2` set `test`.`t11`.`a` = (`test`.`t11`.`a` + 10) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 t11, (SELECT * FROM t2) t12;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.70" + } /* cost_info */, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.30", + "prefix_cost": "0.55", + "data_read_per_join": "48" + } /* cost_info */, + "used_columns": [ + "a", + "b" + ] /* used_columns */, + "query_block": { + "cost_info": { + "query_cost": "1.70" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "select_id": 2, + "table_name": "t11", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.30", + "prefix_cost": "0.55", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */ + } /* table */ + }, + { + "table": { + "select_id": 2, + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 9, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.90", + "prefix_cost": "1.70", + "data_read_per_join": "72" + } /* cost_info */, + "used_columns": [ + "b" + ] /* used_columns */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t11`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` `t11` join `test`.`t2` +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 2 +Handler_read_key 4 +Handler_read_rnd_next 8 +# Status of testing query execution: +Variable_name Value +Handler_read_first 4 +Handler_read_key 6 +Handler_read_rnd_next 16 +Handler_update 3 + +DROP TABLE t1, t2; +#9 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +CREATE TABLE t2 (b INT); +INSERT INTO t2 VALUES (1), (2), (3); +# +# query: UPDATE t1 t11, (SELECT 1 FROM DUAL) t12 SET t11.a = t11.a + 10 +# select: SELECT * FROM t1 t11, (SELECT 1 FROM DUAL) t12 +# +EXPLAIN UPDATE t1 t11, (SELECT 1 FROM DUAL) t12 SET t11.a = t11.a + 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL system NULL NULL NULL NULL 1 100.00 NULL +1 UPDATE t11 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 update `test`.`t1` `t11` join (/* select#2 */ select 1 AS `1`) `t12` set `test`.`t11`.`a` = (`test`.`t11`.`a` + 10) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t1 t11, (SELECT 1 FROM DUAL) t12 SET t11.a = t11.a + 10;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.55" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "table_name": "t12", + "access_type": "system", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.00", + "eval_cost": "0.10", + "prefix_cost": "0.00", + "data_read_per_join": "16" + } /* cost_info */, + "used_columns": [ + "1" + ] /* used_columns */, + "materialized_from_subquery": { + "using_temporary_table": true, + "dependent": false, + "cacheable": true, + "query_block": { + "select_id": 2, + "message": "No tables used" + } /* query_block */ + } /* materialized_from_subquery */ + } /* table */ + }, + { + "table": { + "update": true, + "table_name": "t11", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.30", + "prefix_cost": "0.55", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t1` `t11` join (/* select#2 */ select 1 AS `1`) `t12` set `test`.`t11`.`a` = (`test`.`t11`.`a` + 10) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 t11, (SELECT 1 FROM DUAL) t12;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.55" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "table_name": "t12", + "access_type": "system", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.00", + "eval_cost": "0.10", + "prefix_cost": "0.00", + "data_read_per_join": "16" + } /* cost_info */, + "used_columns": [ + "1" + ] /* used_columns */, + "materialized_from_subquery": { + "using_temporary_table": true, + "dependent": false, + "cacheable": true, + "query_block": { + "select_id": 2, + "message": "No tables used" + } /* query_block */ + } /* materialized_from_subquery */ + } /* table */ + }, + { + "table": { + "table_name": "t11", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.30", + "prefix_cost": "0.55", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t11`.`a` AS `a`,'1' AS `1` from `test`.`t1` `t11` +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 2 +Handler_read_rnd_next 5 +Handler_write 1 +# Status of testing query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 5 +Handler_read_rnd 3 +Handler_read_rnd_next 9 +Handler_update 3 +Handler_write 4 + +DROP TABLE t1, t2; +#10 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +CREATE TABLE t2 (b INT); +INSERT INTO t2 VALUES (1), (2), (3); +# +# query: UPDATE t1 t11, (SELECT * FROM t2) t12 SET t11.a = 10 WHERE t11.a > 1 +# select: SELECT * FROM t1 t11, (SELECT * FROM t2) t12 WHERE t11.a > 1 +# +EXPLAIN UPDATE t1 t11, (SELECT * FROM t2) t12 SET t11.a = 10 WHERE t11.a > 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t11 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 update `test`.`t1` `t11` join `test`.`t2` set `test`.`t11`.`a` = 10 where (`test`.`t11`.`a` > 1) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t1 t11, (SELECT * FROM t2) t12 SET t11.a = 10 WHERE t11.a > 1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.10" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "update": true, + "table_name": "t11", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 1, + "filtered": "33.33", + "cost_info": { + "read_cost": "0.45", + "eval_cost": "0.10", + "prefix_cost": "0.55", + "data_read_per_join": "8" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t11`.`a` > 1)" + } /* table */ + }, + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.30", + "prefix_cost": "1.10", + "data_read_per_join": "24" + } /* cost_info */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t1` `t11` join `test`.`t2` set `test`.`t11`.`a` = 10 where (`test`.`t11`.`a` > 1) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 t11, (SELECT * FROM t2) t12 WHERE t11.a > 1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.10" + } /* cost_info */, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 1, + "filtered": "33.33", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.45", + "eval_cost": "0.10", + "prefix_cost": "0.55", + "data_read_per_join": "16" + } /* cost_info */, + "used_columns": [ + "a", + "b" + ] /* used_columns */, + "query_block": { + "cost_info": { + "query_cost": "1.10" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "select_id": 2, + "table_name": "t11", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 1, + "filtered": "33.33", + "cost_info": { + "read_cost": "0.45", + "eval_cost": "0.10", + "prefix_cost": "0.55", + "data_read_per_join": "8" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t11`.`a` > 1)" + } /* table */ + }, + { + "table": { + "select_id": 2, + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.30", + "prefix_cost": "1.10", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "b" + ] /* used_columns */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t11`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` `t11` join `test`.`t2` where (`test`.`t11`.`a` > 1) +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 2 +Handler_read_key 4 +Handler_read_rnd_next 8 +# Status of testing query execution: +Variable_name Value +Handler_read_first 3 +Handler_read_key 5 +Handler_read_rnd_next 12 +Handler_update 2 + +DROP TABLE t1, t2; +#11 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +# +# query: DELETE FROM t1 WHERE a > 1 LIMIT 1 +# select: SELECT * FROM t1 WHERE a > 1 LIMIT 1 +# +EXPLAIN DELETE FROM t1 WHERE a > 1 LIMIT 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 delete from `test`.`t1` where (`test`.`t1`.`a` > 1) limit 1 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t1 WHERE a > 1 LIMIT 1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "table": { + "delete": true, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "filtered": "100.00", + "attached_condition": "(`test`.`t1`.`a` > 1)" + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 delete from `test`.`t1` where (`test`.`t1`.`a` > 1) limit 1 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 WHERE a > 1 LIMIT 1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.55" + } /* cost_info */, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 1, + "filtered": "33.33", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.45", + "eval_cost": "0.10", + "prefix_cost": "0.55", + "data_read_per_join": "16" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "query_block": { + "cost_info": { + "query_cost": "0.55" + } /* cost_info */, + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 1, + "filtered": "33.33", + "cost_info": { + "read_cost": "0.45", + "eval_cost": "0.10", + "prefix_cost": "0.55", + "data_read_per_join": "8" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`a` > 1)" + } /* table */ + } /* query_block */ + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` > 1) limit 1 +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 2 +Handler_read_rnd_next 2 +# Status of testing query execution: +Variable_name Value +Handler_delete 1 +Handler_read_first 1 +Handler_read_key 2 +Handler_read_rnd_next 2 + +DROP TABLE t1; +#12 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +# +# query: DELETE FROM t1 WHERE 0 +# select: SELECT * FROM t1 WHERE 0 +# +EXPLAIN DELETE FROM t1 WHERE 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 delete from `test`.`t1` where false +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t1 WHERE 0;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "message": "Impossible WHERE" + } /* query_block */ +} +Warnings: +Note 1003 delete from `test`.`t1` where false +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 WHERE 0;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "message": "Impossible WHERE" + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where false +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 1 + +DROP TABLE t1; +#13 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +# +# query: DELETE FROM t1 USING t1 WHERE 0 +# select: SELECT * FROM t1 WHERE 0 +# +EXPLAIN DELETE FROM t1 USING t1 WHERE 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 delete `test`.`t1` from `test`.`t1` where false +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t1 USING t1 WHERE 0;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "message": "Impossible WHERE" + } /* query_block */ +} +Warnings: +Note 1003 delete `test`.`t1` from `test`.`t1` where false +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 WHERE 0;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "message": "Impossible WHERE" + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where false +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 1 + +DROP TABLE t1; +#14 +CREATE TABLE t1 (a INT, b INT, UNIQUE KEY (a), KEY (b)); +INSERT INTO t1 VALUES (3, 3), (7, 7); +# +# query: DELETE FROM t1 WHERE a = 3 +# select: SELECT * FROM t1 WHERE a = 3 +# +EXPLAIN DELETE FROM t1 WHERE a = 3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL range a a 5 const 1 100.00 Using where +Warnings: +Note 1003 delete from `test`.`t1` where (`test`.`t1`.`a` = 3) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t1 WHERE a = 3;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "table": { + "delete": true, + "table_name": "t1", + "access_type": "range", + "possible_keys": [ + "a" + ] /* possible_keys */, + "key": "a", + "used_key_parts": [ + "a" + ] /* used_key_parts */, + "key_length": "5", + "ref": [ + "const" + ] /* ref */, + "rows_examined_per_scan": 1, + "filtered": "100.00", + "attached_condition": "(`test`.`t1`.`a` = 3)" + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 delete from `test`.`t1` where (`test`.`t1`.`a` = 3) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 WHERE a = 3;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.00" + } /* cost_info */, + "table": { + "table_name": "t1", + "access_type": "const", + "possible_keys": [ + "a" + ] /* possible_keys */, + "key": "a", + "used_key_parts": [ + "a" + ] /* used_key_parts */, + "key_length": "5", + "ref": [ + "const" + ] /* ref */, + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.00", + "eval_cost": "0.10", + "prefix_cost": "0.00", + "data_read_per_join": "16" + } /* cost_info */, + "used_columns": [ + "a", + "b" + ] /* used_columns */ + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select '3' AS `a`,'3' AS `b` from `test`.`t1` where true +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 3 +# Status of testing query execution: +Variable_name Value +Handler_delete 1 +Handler_read_key 3 + +DROP TABLE t1; +#15 +CREATE TABLE t1 (a INT, b INT, UNIQUE KEY (a), KEY (b)); +INSERT INTO t1 VALUES (3, 3), (7, 7); +# +# query: DELETE FROM t1 WHERE a < 3 +# select: SELECT * FROM t1 WHERE a < 3 +# +EXPLAIN DELETE FROM t1 WHERE a < 3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL range a a 5 const 1 100.00 Using where +Warnings: +Note 1003 delete from `test`.`t1` where (`test`.`t1`.`a` < 3) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t1 WHERE a < 3;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "table": { + "delete": true, + "table_name": "t1", + "access_type": "range", + "possible_keys": [ + "a" + ] /* possible_keys */, + "key": "a", + "used_key_parts": [ + "a" + ] /* used_key_parts */, + "key_length": "5", + "ref": [ + "const" + ] /* ref */, + "rows_examined_per_scan": 1, + "filtered": "100.00", + "attached_condition": "(`test`.`t1`.`a` < 3)" + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 delete from `test`.`t1` where (`test`.`t1`.`a` < 3) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 WHERE a < 3;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.70" + } /* cost_info */, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.60", + "eval_cost": "0.10", + "prefix_cost": "0.70", + "data_read_per_join": "16" + } /* cost_info */, + "used_columns": [ + "a", + "b" + ] /* used_columns */, + "query_block": { + "cost_info": { + "query_cost": "0.70" + } /* cost_info */, + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "range", + "possible_keys": [ + "a" + ] /* possible_keys */, + "key": "a", + "used_key_parts": [ + "a" + ] /* used_key_parts */, + "key_length": "5", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "index_condition": "(`test`.`t1`.`a` < 3)", + "using_MRR": true, + "cost_info": { + "read_cost": "0.60", + "eval_cost": "0.10", + "prefix_cost": "0.70", + "data_read_per_join": "16" + } /* cost_info */, + "used_columns": [ + "a", + "b" + ] /* used_columns */ + } /* table */ + } /* query_block */ + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (`test`.`t1`.`a` < 3) +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 4 +Handler_read_rnd_next 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 3 + +DROP TABLE t1; +#16 +CREATE TABLE t1 ( a int PRIMARY KEY ); +# +# query: DELETE FROM t1 WHERE t1.a > 0 ORDER BY t1.a +# select: SELECT * FROM t1 WHERE t1.a > 0 ORDER BY t1.a +# +EXPLAIN DELETE FROM t1 WHERE t1.a > 0 ORDER BY t1.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL range PRIMARY PRIMARY 4 const 1 100.00 Using where +Warnings: +Note 1003 delete from `test`.`t1` where (`test`.`t1`.`a` > 0) order by `test`.`t1`.`a` +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t1 WHERE t1.a > 0 ORDER BY t1.a;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_filesort": false, + "table": { + "delete": true, + "table_name": "t1", + "access_type": "range", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "a" + ] /* used_key_parts */, + "key_length": "4", + "ref": [ + "const" + ] /* ref */, + "rows_examined_per_scan": 1, + "filtered": "100.00", + "attached_condition": "(`test`.`t1`.`a` > 0)" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 delete from `test`.`t1` where (`test`.`t1`.`a` > 0) order by `test`.`t1`.`a` +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 WHERE t1.a > 0 ORDER BY t1.a;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.35" + } /* cost_info */, + "ordering_operation": { + "using_filesort": false, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.10", + "prefix_cost": "0.35", + "data_read_per_join": "16" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "ordering_operation": { + "using_filesort": false, + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "index", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "a" + ] /* used_key_parts */, + "key_length": "4", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "using_index": true, + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.10", + "prefix_cost": "0.35", + "data_read_per_join": "8" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`a` > 0)" + } /* table */ + } /* ordering_operation */ + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` > 0) order by `test`.`t1`.`a` +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 2 +Handler_read_rnd_next 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 2 + +INSERT INTO t1 VALUES (1), (2), (3); +# +# query: DELETE FROM t1 WHERE t1.a > 0 ORDER BY t1.a +# select: SELECT * FROM t1 WHERE t1.a > 0 ORDER BY t1.a +# +EXPLAIN DELETE FROM t1 WHERE t1.a > 0 ORDER BY t1.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL range PRIMARY PRIMARY 4 const 3 100.00 Using where +Warnings: +Note 1003 delete from `test`.`t1` where (`test`.`t1`.`a` > 0) order by `test`.`t1`.`a` +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t1 WHERE t1.a > 0 ORDER BY t1.a;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_filesort": false, + "table": { + "delete": true, + "table_name": "t1", + "access_type": "range", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "a" + ] /* used_key_parts */, + "key_length": "4", + "ref": [ + "const" + ] /* ref */, + "rows_examined_per_scan": 3, + "filtered": "100.00", + "attached_condition": "(`test`.`t1`.`a` > 0)" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 delete from `test`.`t1` where (`test`.`t1`.`a` > 0) order by `test`.`t1`.`a` +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 WHERE t1.a > 0 ORDER BY t1.a;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.55" + } /* cost_info */, + "ordering_operation": { + "using_filesort": false, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.30", + "prefix_cost": "0.55", + "data_read_per_join": "48" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "ordering_operation": { + "using_filesort": false, + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "index", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "a" + ] /* used_key_parts */, + "key_length": "4", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "using_index": true, + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.30", + "prefix_cost": "0.55", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`a` > 0)" + } /* table */ + } /* ordering_operation */ + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` > 0) order by `test`.`t1`.`a` +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 2 +Handler_read_rnd_next 4 +# Status of testing query execution: +Variable_name Value +Handler_delete 3 +Handler_read_key 2 +Handler_read_next 3 + +DROP TABLE t1; +#17 +CREATE TABLE t1(a INT PRIMARY KEY); +INSERT INTO t1 VALUES (4),(3),(1),(2); +# +# query: DELETE FROM t1 WHERE (@a:= a) ORDER BY a LIMIT 1 +# select: SELECT * FROM t1 WHERE (@a:= a) ORDER BY a LIMIT 1 +# +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +EXPLAIN DELETE FROM t1 WHERE (@a:= a) ORDER BY a LIMIT 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL index NULL PRIMARY 4 NULL 4 100.00 Using where +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +Note 1003 delete from `test`.`t1` where (0 <> (@a:=`test`.`t1`.`a`)) order by `test`.`t1`.`a` limit 1 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t1 WHERE (@a:= a) ORDER BY a LIMIT 1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_filesort": false, + "table": { + "delete": true, + "table_name": "t1", + "access_type": "index", + "key": "PRIMARY", + "used_key_parts": [ + "a" + ] /* used_key_parts */, + "key_length": "4", + "rows_examined_per_scan": 4, + "filtered": "100.00", + "attached_condition": "(0 <> (@a:=`test`.`t1`.`a`))" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +Note 1003 delete from `test`.`t1` where (0 <> (@a:=`test`.`t1`.`a`)) order by `test`.`t1`.`a` limit 1 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 WHERE (@a:= a) ORDER BY a LIMIT 1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.65" + } /* cost_info */, + "ordering_operation": { + "using_filesort": false, + "table": { + "table_name": "t1", + "access_type": "index", + "key": "PRIMARY", + "used_key_parts": [ + "a" + ] /* used_key_parts */, + "key_length": "4", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 4, + "filtered": "100.00", + "using_index": true, + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.40", + "prefix_cost": "0.65", + "data_read_per_join": "32" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(0 <> (@a:=`test`.`t1`.`a`))" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (0 <> (@a:=`test`.`t1`.`a`)) order by `test`.`t1`.`a` limit 1 +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 2 +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +# Status of testing query execution: +Variable_name Value +Handler_delete 1 +Handler_read_first 1 +Handler_read_key 2 + +DROP TABLE t1; +#18 +CREATE TABLE t1 (a DATE, b TIME, c INT, KEY c(c), KEY b(b), KEY a(a)); +INSERT INTO t1 VALUES (), (), (), (), (), (), (), (), (), (); +UPDATE t1 SET a = c, b = c; +# +# query: DELETE FROM t1 ORDER BY a ASC, b ASC LIMIT 1 +# select: SELECT * FROM t1 ORDER BY a ASC, b ASC LIMIT 1 +# +EXPLAIN DELETE FROM t1 ORDER BY a ASC, b ASC LIMIT 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 10 100.00 Using filesort +Warnings: +Note 1003 delete from `test`.`t1` order by `test`.`t1`.`a`,`test`.`t1`.`b` limit 1 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t1 ORDER BY a ASC, b ASC LIMIT 1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_filesort": true, + "table": { + "delete": true, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 10, + "filtered": "100.00" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 delete from `test`.`t1` order by `test`.`t1`.`a`,`test`.`t1`.`b` limit 1 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 ORDER BY a ASC, b ASC LIMIT 1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.25" + } /* cost_info */, + "ordering_operation": { + "using_filesort": true, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 10, + "rows_produced_per_join": 10, + "filtered": "100.00", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "1.00", + "prefix_cost": "1.25", + "data_read_per_join": "160" + } /* cost_info */, + "used_columns": [ + "a", + "b", + "c" + ] /* used_columns */, + "ordering_operation": { + "using_filesort": true, + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 10, + "rows_produced_per_join": 10, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "1.00", + "prefix_cost": "1.25", + "data_read_per_join": "160" + } /* cost_info */, + "used_columns": [ + "a", + "b", + "c" + ] /* used_columns */ + } /* table */ + } /* ordering_operation */ + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` order by `test`.`t1`.`a`,`test`.`t1`.`b` limit 1 +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 4 +Handler_read_rnd_next 11 +Sort_rows 1 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_delete 1 +Handler_read_first 1 +Handler_read_key 5 +Handler_read_rnd 1 +Handler_read_rnd_next 11 +Sort_rows 10 +Sort_scan 1 + +DROP TABLE t1; +#19 +CREATE TABLE t1 (a1 INT NOT NULL, b1 INT NOT NULL); +CREATE TABLE t2 (a2 INT NOT NULL, b2 INT NOT NULL, PRIMARY KEY (a2,b2)); +CREATE TABLE t3 (a3 INT NOT NULL, b3 INT NOT NULL, PRIMARY KEY (a3,b3)); +INSERT INTO t1 VALUES (1,1), (2,1), (1,3); +INSERT INTO t2 VALUES (1,1), (2,2), (3,3); +INSERT INTO t3 VALUES (1,1), (2,1), (1,3); +# +# query: DELETE t1,t2,t3 FROM t1,t2,t3 WHERE a1=a2 AND b2=a3 AND b1=b3 +# select: SELECT * FROM t1,t2,t3 WHERE a1=a2 AND b2=a3 AND b1=b3 +# +EXPLAIN DELETE t1,t2,t3 FROM t1,t2,t3 WHERE a1=a2 AND b2=a3 AND b1=b3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 DELETE t2 NULL ref PRIMARY PRIMARY 4 test.t1.a1 1 100.00 NULL +1 DELETE t3 NULL eq_ref PRIMARY PRIMARY 8 test.t2.b2,test.t1.b1 1 100.00 NULL +Warnings: +Note 1003 delete `test`.`t1`, `test`.`t2`, `test`.`t3` from `test`.`t1` join `test`.`t2` join `test`.`t3` where ((`test`.`t3`.`b3` = `test`.`t1`.`b1`) and (`test`.`t3`.`a3` = `test`.`t2`.`b2`) and (`test`.`t2`.`a2` = `test`.`t1`.`a1`)) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE t1,t2,t3 FROM t1,t2,t3 WHERE a1=a2 AND b2=a3 AND b1=b3;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "2.65" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "delete": true, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.30", + "prefix_cost": "0.55", + "data_read_per_join": "48" + } /* cost_info */, + "used_columns": [ + "a1", + "b1" + ] /* used_columns */ + } /* table */ + }, + { + "table": { + "delete": true, + "table_name": "t2", + "access_type": "ref", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "a2" + ] /* used_key_parts */, + "key_length": "4", + "ref": [ + "test.t1.a1" + ] /* ref */, + "rows_examined_per_scan": 1, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.75", + "eval_cost": "0.30", + "prefix_cost": "1.60", + "data_read_per_join": "48" + } /* cost_info */, + "used_columns": [ + "a2", + "b2" + ] /* used_columns */ + } /* table */ + }, + { + "table": { + "delete": true, + "table_name": "t3", + "access_type": "eq_ref", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "a3", + "b3" + ] /* used_key_parts */, + "key_length": "8", + "ref": [ + "test.t2.b2", + "test.t1.b1" + ] /* ref */, + "rows_examined_per_scan": 1, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.75", + "eval_cost": "0.30", + "prefix_cost": "2.65", + "data_read_per_join": "48" + } /* cost_info */, + "used_columns": [ + "a3", + "b3" + ] /* used_columns */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 delete `test`.`t1`, `test`.`t2`, `test`.`t3` from `test`.`t1` join `test`.`t2` join `test`.`t3` where ((`test`.`t3`.`b3` = `test`.`t1`.`b1`) and (`test`.`t3`.`a3` = `test`.`t2`.`b2`) and (`test`.`t2`.`a2` = `test`.`t1`.`a1`)) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1,t2,t3 WHERE a1=a2 AND b2=a3 AND b1=b3;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "2.65" + } /* cost_info */, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.30", + "prefix_cost": "0.55", + "data_read_per_join": "96" + } /* cost_info */, + "used_columns": [ + "a1", + "b1", + "a2", + "b2", + "a3", + "b3" + ] /* used_columns */, + "query_block": { + "cost_info": { + "query_cost": "2.65" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.30", + "prefix_cost": "0.55", + "data_read_per_join": "48" + } /* cost_info */, + "used_columns": [ + "a1", + "b1" + ] /* used_columns */ + } /* table */ + }, + { + "table": { + "select_id": 2, + "table_name": "t2", + "access_type": "ref", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "a2" + ] /* used_key_parts */, + "key_length": "4", + "ref": [ + "test.t1.a1" + ] /* ref */, + "rows_examined_per_scan": 1, + "rows_produced_per_join": 3, + "filtered": "100.00", + "using_index": true, + "cost_info": { + "read_cost": "0.75", + "eval_cost": "0.30", + "prefix_cost": "1.60", + "data_read_per_join": "48" + } /* cost_info */, + "used_columns": [ + "a2", + "b2" + ] /* used_columns */ + } /* table */ + }, + { + "table": { + "select_id": 2, + "table_name": "t3", + "access_type": "eq_ref", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "a3", + "b3" + ] /* used_key_parts */, + "key_length": "8", + "ref": [ + "test.t2.b2", + "test.t1.b1" + ] /* ref */, + "rows_examined_per_scan": 1, + "rows_produced_per_join": 3, + "filtered": "100.00", + "using_index": true, + "cost_info": { + "read_cost": "0.75", + "eval_cost": "0.30", + "prefix_cost": "2.65", + "data_read_per_join": "48" + } /* cost_info */, + "used_columns": [ + "a3", + "b3" + ] /* used_columns */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`b1` AS `b1`,`test`.`t2`.`a2` AS `a2`,`test`.`t2`.`b2` AS `b2`,`test`.`t3`.`a3` AS `a3`,`test`.`t3`.`b3` AS `b3` from `test`.`t1` join `test`.`t2` join `test`.`t3` where ((`test`.`t3`.`b3` = `test`.`t1`.`b1`) and (`test`.`t3`.`a3` = `test`.`t2`.`b2`) and (`test`.`t2`.`a2` = `test`.`t1`.`a1`)) +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 13 +Handler_read_next 3 +Handler_read_rnd_next 4 +# Status of testing query execution: +Variable_name Value +Handler_delete 8 +Handler_read_first 1 +Handler_read_key 18 +Handler_read_next 3 +Handler_read_rnd 5 +Handler_read_rnd_next 4 + +DROP TABLE t1, t2, t3; +#20 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +CREATE TABLE t2 (a INT); +INSERT INTO t2 VALUES (1), (2), (3); +# +# query: UPDATE t1 SET a = 10 WHERE a IN (SELECT a FROM t2) +# select: SELECT * FROM t1 WHERE a IN (SELECT a FROM t2) +# +EXPLAIN UPDATE t1 SET a = 10 WHERE a IN (SELECT a FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(t1) +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`a` = 10 where (`test`.`t2`.`a` = `test`.`t1`.`a`) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t1 SET a = 10 WHERE a IN (SELECT a FROM t2);; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.70" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "update": true, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.30", + "prefix_cost": "0.55", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */ + } /* table */ + }, + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "33.33", + "first_match": "t1", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.30", + "prefix_cost": "1.70", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t2`.`a` = `test`.`t1`.`a`)" + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`a` = 10 where (`test`.`t2`.`a` = `test`.`t1`.`a`) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 WHERE a IN (SELECT a FROM t2);; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.70" + } /* cost_info */, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.30", + "prefix_cost": "0.55", + "data_read_per_join": "48" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "query_block": { + "cost_info": { + "query_cost": "1.70" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.30", + "prefix_cost": "0.55", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */ + } /* table */ + }, + { + "table": { + "select_id": 2, + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "33.33", + "first_match": "t1", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.30", + "prefix_cost": "1.70", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t2`.`a` = `test`.`t1`.`a`)" + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t2`) where (`test`.`t2`.`a` = `test`.`t1`.`a`) +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 2 +Handler_read_key 4 +Handler_read_rnd_next 8 +# Status of testing query execution: +Variable_name Value +Handler_read_first 4 +Handler_read_key 6 +Handler_read_rnd_next 10 +Handler_update 3 + +DROP TABLE t1, t2; +#21 +CREATE TABLE t1 (a1 INT); +INSERT INTO t1 VALUES (1), (2), (3), (4), (5); +CREATE TABLE t2 (a2 VARCHAR(10)) charset utf8mb4; +INSERT INTO t2 VALUES (1), (2), (3), (4), (5); +SET @save_optimizer_switch= @@optimizer_switch; +# +# query: DELETE FROM t1 WHERE a1 IN (SELECT a2 FROM t2 WHERE a2 > 2) +# select: SELECT * FROM t1 WHERE a1 IN (SELECT a2 FROM t2 WHERE a2 > 2) +# +EXPLAIN DELETE FROM t1 WHERE a1 IN (SELECT a2 FROM t2 WHERE a2 > 2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 5 100.00 Using where +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 5 20.00 Using where +Warnings: +Note 1003 delete from `test`.`t1` where (`test`.`t1`.`a1`,(/* select#2 */ select `test`.`t2`.`a2` from `test`.`t2` where ((`test`.`t2`.`a2` > 2) and ((`test`.`t1`.`a1`) = `test`.`t2`.`a2`)))) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t1 WHERE a1 IN (SELECT a2 FROM t2 WHERE a2 > 2);; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.75" + } /* cost_info */, + "table": { + "delete": true, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "40" + } /* cost_info */, + "used_columns": [ + "a1" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`a1`,(/* select#2 */ select `test`.`t2`.`a2` from `test`.`t2` where ((`test`.`t2`.`a2` > 2) and ((`test`.`t1`.`a1`) = `test`.`t2`.`a2`))))", + "attached_subqueries": [ + { + "dependent": true, + "cacheable": false, + "query_block": { + "select_id": 2, + "cost_info": { + "query_cost": "0.75" + } /* cost_info */, + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 1, + "filtered": "20.00", + "cost_info": { + "read_cost": "0.58", + "eval_cost": "0.10", + "prefix_cost": "0.75", + "data_read_per_join": "48" + } /* cost_info */, + "used_columns": [ + "a2" + ] /* used_columns */, + "attached_condition": "((`test`.`t2`.`a2` > 2) and ((`test`.`t1`.`a1`) = `test`.`t2`.`a2`))" + } /* table */ + } /* query_block */ + } + ] /* attached_subqueries */ + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 delete from `test`.`t1` where (`test`.`t1`.`a1`,(/* select#2 */ select `test`.`t2`.`a2` from `test`.`t2` where ((`test`.`t2`.`a2` > 2) and ((`test`.`t1`.`a1`) = `test`.`t2`.`a2`)))) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 WHERE a1 IN (SELECT a2 FROM t2 WHERE a2 > 2);; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.75" + } /* cost_info */, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "40" + } /* cost_info */, + "used_columns": [ + "a1" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`a1`,(/* select#2 */ select `test`.`t2`.`a2` from `test`.`t2` where ((`test`.`t2`.`a2` > 2) and ((`test`.`t1`.`a1`) = `test`.`t2`.`a2`))))", + "attached_subqueries": [ + { + "dependent": true, + "cacheable": false, + "query_block": { + "select_id": 2, + "cost_info": { + "query_cost": "0.75" + } /* cost_info */, + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 1, + "filtered": "20.00", + "cost_info": { + "read_cost": "0.58", + "eval_cost": "0.10", + "prefix_cost": "0.75", + "data_read_per_join": "48" + } /* cost_info */, + "used_columns": [ + "a2" + ] /* used_columns */, + "attached_condition": "((`test`.`t2`.`a2` > 2) and ((`test`.`t1`.`a1`) = `test`.`t2`.`a2`))" + } /* table */ + } /* query_block */ + } + ] /* attached_subqueries */ + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1` from `test`.`t1` where (`test`.`t1`.`a1`,(/* select#2 */ select `test`.`t2`.`a2` from `test`.`t2` where ((`test`.`t2`.`a2` > 2) and ((`test`.`t1`.`a1`) = `test`.`t2`.`a2`)))) +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 6 +Handler_read_key 8 +Handler_read_rnd_next 30 +# Status of testing query execution: +Variable_name Value +Handler_delete 3 +Handler_read_first 6 +Handler_read_key 8 +Handler_read_rnd_next 30 + +SET @@optimizer_switch= @save_optimizer_switch; +TRUNCATE t1; +INSERT INTO t1 VALUES (1), (2), (3), (4), (5); +# +# query: DELETE FROM t1 WHERE a1 IN (SELECT a2 FROM t2 WHERE a2 > 2) +# select: SELECT * FROM t1 WHERE a1 IN (SELECT a2 FROM t2 WHERE a2 > 2) +# +EXPLAIN DELETE FROM t1 WHERE a1 IN (SELECT a2 FROM t2 WHERE a2 > 2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 5 20.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 delete from `test`.`t1` where ((`test`.`t2`.`a2` > 2) and (cast(`test`.`t1`.`a1` as double) = cast(`test`.`t2`.`a2` as double))) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t1 WHERE a1 IN (SELECT a2 FROM t2 WHERE a2 > 2);; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "2.17" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "delete": true, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "40" + } /* cost_info */, + "used_columns": [ + "a1" + ] /* used_columns */ + } /* table */ + }, + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "20.00", + "first_match": "t1", + "cost_info": { + "read_cost": "0.58", + "eval_cost": "0.50", + "prefix_cost": "2.17", + "data_read_per_join": "240" + } /* cost_info */, + "used_columns": [ + "a2" + ] /* used_columns */, + "attached_condition": "((`test`.`t2`.`a2` > 2) and (cast(`test`.`t1`.`a1` as double) = cast(`test`.`t2`.`a2` as double)))" + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 delete from `test`.`t1` where ((`test`.`t2`.`a2` > 2) and (cast(`test`.`t1`.`a1` as double) = cast(`test`.`t2`.`a2` as double))) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 WHERE a1 IN (SELECT a2 FROM t2 WHERE a2 > 2);; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "2.17" + } /* cost_info */, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "80" + } /* cost_info */, + "used_columns": [ + "a1" + ] /* used_columns */, + "query_block": { + "cost_info": { + "query_cost": "2.17" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "40" + } /* cost_info */, + "used_columns": [ + "a1" + ] /* used_columns */ + } /* table */ + }, + { + "table": { + "select_id": 2, + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "20.00", + "first_match": "t1", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.58", + "eval_cost": "0.50", + "prefix_cost": "2.17", + "data_read_per_join": "240" + } /* cost_info */, + "used_columns": [ + "a2" + ] /* used_columns */, + "attached_condition": "((`test`.`t2`.`a2` > 2) and (cast(`test`.`t1`.`a1` as double) = cast(`test`.`t2`.`a2` as double)))" + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`a2` > 2) and (cast(`test`.`t1`.`a1` as double) = cast(`test`.`t2`.`a2` as double))) +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 2 +Handler_read_key 4 +Handler_read_rnd_next 12 +# Status of testing query execution: +Variable_name Value +Handler_delete 3 +Handler_read_first 6 +Handler_read_key 8 +Handler_read_rnd_next 30 + +DROP TABLE t1, t2; +#22 +CREATE TABLE t1 (i INT, j INT); +INSERT INTO t1 VALUES (1, 1), (2, 2), (3, 3), (4, 4), (5, 5); +# +# query: UPDATE t1 SET i = 10 +# select: SELECT * FROM t1 +# +EXPLAIN UPDATE t1 SET i = 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`i` = 10 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t1 SET i = 10;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "table": { + "update": true, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "filtered": "100.00" + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`i` = 10 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.75" + } /* cost_info */, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "80" + } /* cost_info */, + "used_columns": [ + "i", + "j" + ] /* used_columns */, + "query_block": { + "cost_info": { + "query_cost": "0.75" + } /* cost_info */, + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "80" + } /* cost_info */, + "used_columns": [ + "i", + "j" + ] /* used_columns */ + } /* table */ + } /* query_block */ + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i`,`test`.`t1`.`j` AS `j` from `test`.`t1` +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 3 +Handler_read_rnd_next 6 +# Status of testing query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 3 +Handler_read_rnd_next 6 +Handler_update 5 + +DROP TABLE t1; +#23 +CREATE TABLE t1 (i INT, j INT); +INSERT INTO t1 VALUES (1, 1), (2, 2), (3, 3), (4, 4), (5, 5); +# +# query: DELETE FROM t1 +# select: SELECT * FROM t1 +# +EXPLAIN DELETE FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 5 100.00 Deleting all rows +Warnings: +Note 1003 delete from `test`.`t1` +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "table": { + "delete": true, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "filtered": "100.00", + "message": "Deleting all rows" + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 delete from `test`.`t1` +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.75" + } /* cost_info */, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "80" + } /* cost_info */, + "used_columns": [ + "i", + "j" + ] /* used_columns */, + "query_block": { + "cost_info": { + "query_cost": "0.75" + } /* cost_info */, + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "80" + } /* cost_info */, + "used_columns": [ + "i", + "j" + ] /* used_columns */ + } /* table */ + } /* query_block */ + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i`,`test`.`t1`.`j` AS `j` from `test`.`t1` +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 3 +Handler_read_rnd_next 6 +# Status of testing query execution: +Variable_name Value +Handler_delete 5 +Handler_read_first 1 +Handler_read_key 3 +Handler_read_rnd_next 6 + +DROP TABLE t1; +#24 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2(a INT, b INT, c INT, d INT, INDEX(a, b, c)); +INSERT INTO t2 (a, b, c) SELECT i, i, i FROM t1; +INSERT INTO t2 (a, b, c) SELECT t1.i, t1.i, t1.i FROM t1, t1 x1, t1 x2; +# +# query: DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# select: SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# +EXPLAIN DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t2 NULL index NULL a 15 NULL X 100.00 Using where +Warnings: +Note 1003 delete from `test`.`t2` where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_filesort": false, + "table": { + "delete": true, + "table_name": "t2", + "access_type": "index", + "key": "a", + "used_key_parts": [ + "a", + "b", + "c" + ] /* used_key_parts */, + "key_length": "15", + "rows_examined_per_scan": "X", + "filtered": "X", + "attached_condition": "(`test`.`t2`.`b` = 10)" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 delete from `test`.`t2` where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "X" + } /* cost_info */, + "ordering_operation": { + "using_filesort": false, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": "X", + "rows_produced_per_join": "X", + "filtered": "X", + "parallel_execute": "4 workers", + "cost_info": { + "read_cost": "X", + "eval_cost": "X", + "prefix_cost": "X", + "data_read_per_join": "X" + } /* cost_info */, + "used_columns": [ + "a", + "b", + "c", + "d" + ] /* used_columns */, + "ordering_operation": { + "using_filesort": false, + "table": { + "select_id": 2, + "table_name": "t2", + "access_type": "index", + "key": "a", + "used_key_parts": [ + "a", + "b", + "c" + ] /* used_key_parts */, + "key_length": "15", + "rows_examined_per_scan": "X", + "rows_produced_per_join": "X", + "filtered": "X", + "cost_info": { + "read_cost": "X", + "eval_cost": "X", + "prefix_cost": "X", + "data_read_per_join": "X" + } /* cost_info */, + "used_columns": [ + "a", + "b", + "c", + "d" + ] /* used_columns */, + "attached_condition": "(`test`.`t2`.`b` = 10)" + } /* table */ + } /* ordering_operation */ + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c`,`test`.`t2`.`d` AS `d` from `test`.`t2` where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 5 +Handler_read_rnd_next 16936 +# Status of testing query execution: +Variable_name Value +Handler_delete 5 +Handler_read_first 1 +Handler_read_key 5 +Handler_read_next 4 + +DROP TABLE t1, t2; +#25 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (1), (2), (3); +CREATE TABLE t2 (i INT); +# +# query: INSERT INTO t2 SELECT * FROM t1 +# select: SELECT * FROM t1 +# +EXPLAIN INSERT INTO t2 SELECT * FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 INSERT t2 NULL ALL NULL NULL NULL NULL NULL NULL NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 insert into `test`.`t2` /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON INSERT INTO t2 SELECT * FROM t1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.55" + } /* cost_info */, + "table": { + "insert": true, + "table_name": "t2", + "access_type": "ALL" + } /* table */, + "insert_from": { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.30", + "prefix_cost": "0.55", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "i" + ] /* used_columns */ + } /* table */ + } /* insert_from */ + } /* query_block */ +} +Warnings: +Note 1003 insert into `test`.`t2` /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.55" + } /* cost_info */, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.30", + "prefix_cost": "0.55", + "data_read_per_join": "48" + } /* cost_info */, + "used_columns": [ + "i" + ] /* used_columns */, + "query_block": { + "cost_info": { + "query_cost": "0.55" + } /* cost_info */, + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.30", + "prefix_cost": "0.55", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "i" + ] /* used_columns */ + } /* table */ + } /* query_block */ + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 2 +Handler_read_rnd_next 4 +# Status of testing query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 3 +Handler_read_rnd_next 4 +Handler_write 3 + +# +# query: INSERT INTO t2 SELECT * FROM t1 JOIN t1 AS tt USING(i) +# select: SELECT * FROM t1 JOIN t1 AS tt USING(i) +# +EXPLAIN INSERT INTO t2 SELECT * FROM t1 JOIN t1 AS tt USING(i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 INSERT t2 NULL ALL NULL NULL NULL NULL NULL NULL NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE tt NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +Warnings: +Note 1003 insert into `test`.`t2` /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` join `test`.`t1` `tt` where (`test`.`tt`.`i` = `test`.`t1`.`i`) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON INSERT INTO t2 SELECT * FROM t1 JOIN t1 AS tt USING(i);; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.70" + } /* cost_info */, + "table": { + "insert": true, + "table_name": "t2", + "access_type": "ALL" + } /* table */, + "insert_from": { + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.30", + "prefix_cost": "0.55", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "i" + ] /* used_columns */ + } /* table */ + }, + { + "table": { + "table_name": "tt", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "33.33", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.30", + "prefix_cost": "1.70", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "i" + ] /* used_columns */, + "attached_condition": "(`test`.`tt`.`i` = `test`.`t1`.`i`)" + } /* table */ + } + ] /* nested_loop */ + } /* insert_from */ + } /* query_block */ +} +Warnings: +Note 1003 insert into `test`.`t2` /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` join `test`.`t1` `tt` where (`test`.`tt`.`i` = `test`.`t1`.`i`) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 JOIN t1 AS tt USING(i);; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.70" + } /* cost_info */, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.30", + "prefix_cost": "0.55", + "data_read_per_join": "48" + } /* cost_info */, + "used_columns": [ + "i" + ] /* used_columns */, + "query_block": { + "cost_info": { + "query_cost": "1.70" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.30", + "prefix_cost": "0.55", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "i" + ] /* used_columns */ + } /* table */ + }, + { + "table": { + "select_id": 2, + "table_name": "tt", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "33.33", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.30", + "prefix_cost": "1.70", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "i" + ] /* used_columns */, + "attached_condition": "(`test`.`tt`.`i` = `test`.`t1`.`i`)" + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` join `test`.`t1` `tt` where (`test`.`tt`.`i` = `test`.`t1`.`i`) +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 2 +Handler_read_key 3 +Handler_read_rnd_next 8 +# Status of testing query execution: +Variable_name Value +Handler_read_first 2 +Handler_read_key 4 +Handler_read_rnd_next 8 +Handler_write 3 + +DROP TABLE t1, t2; +#26 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (1), (2), (3); +CREATE TABLE t2 (i INT); +# +# query: REPLACE INTO t2 SELECT * FROM t1 +# select: SELECT * FROM t1 +# +EXPLAIN REPLACE INTO t2 SELECT * FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 REPLACE t2 NULL ALL NULL NULL NULL NULL NULL NULL NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 replace into `test`.`t2` /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON REPLACE INTO t2 SELECT * FROM t1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.55" + } /* cost_info */, + "table": { + "replace": true, + "table_name": "t2", + "access_type": "ALL" + } /* table */, + "insert_from": { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.30", + "prefix_cost": "0.55", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "i" + ] /* used_columns */ + } /* table */ + } /* insert_from */ + } /* query_block */ +} +Warnings: +Note 1003 replace into `test`.`t2` /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.55" + } /* cost_info */, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.30", + "prefix_cost": "0.55", + "data_read_per_join": "48" + } /* cost_info */, + "used_columns": [ + "i" + ] /* used_columns */, + "query_block": { + "cost_info": { + "query_cost": "0.55" + } /* cost_info */, + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.30", + "prefix_cost": "0.55", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "i" + ] /* used_columns */ + } /* table */ + } /* query_block */ + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 2 +Handler_read_rnd_next 4 +# Status of testing query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 3 +Handler_read_rnd_next 4 +Handler_write 3 + +DROP TABLE t1, t2; +#27 +CREATE TABLE t1 (i INT); +# +# query: INSERT INTO t1 SET i = 10 +# select: +# +EXPLAIN INSERT INTO t1 SET i = 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 INSERT t1 NULL ALL NULL NULL NULL NULL NULL NULL NULL +Warnings: +Note 1003 insert into `test`.`t1` (`test`.`t1`.`i`) values (10) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON INSERT INTO t1 SET i = 10;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "table": { + "insert": true, + "table_name": "t1", + "access_type": "ALL" + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 insert into `test`.`t1` (`test`.`t1`.`i`) values (10) +# Status of testing query execution: +Variable_name Value +Handler_read_key 1 +Handler_write 1 + +DROP TABLE t1; +#28 +CREATE TABLE t1 (i INT); +# +# query: REPLACE INTO t1 SET i = 10 +# select: +# +EXPLAIN REPLACE INTO t1 SET i = 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 REPLACE t1 NULL ALL NULL NULL NULL NULL NULL NULL NULL +Warnings: +Note 1003 replace into `test`.`t1` (`test`.`t1`.`i`) values (10) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON REPLACE INTO t1 SET i = 10;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "table": { + "replace": true, + "table_name": "t1", + "access_type": "ALL" + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 replace into `test`.`t1` (`test`.`t1`.`i`) values (10) +# Status of testing query execution: +Variable_name Value +Handler_read_key 1 +Handler_write 1 + +DROP TABLE t1; +#29 +CREATE TABLE t1 (a INT, i INT PRIMARY KEY); +INSERT INTO t1 (i) VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +# +# query: DELETE FROM t1 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 1 +# select: SELECT * FROM t1 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 1 +# +EXPLAIN DELETE FROM t1 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL range PRIMARY PRIMARY 4 const X 100.00 Using where +Warnings: +Note 1003 delete from `test`.`t1` where ((`test`.`t1`.`i` > 10) and (`test`.`t1`.`i` <= 18)) order by `test`.`t1`.`i` limit 1 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t1 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_filesort": false, + "table": { + "delete": true, + "table_name": "t1", + "access_type": "range", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "i" + ] /* used_key_parts */, + "key_length": "4", + "ref": [ + "const" + ] /* ref */, + "rows_examined_per_scan": "X", + "filtered": "X", + "attached_condition": "((`test`.`t1`.`i` > 10) and (`test`.`t1`.`i` <= 18))" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 delete from `test`.`t1` where ((`test`.`t1`.`i` > 10) and (`test`.`t1`.`i` <= 18)) order by `test`.`t1`.`i` limit 1 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "X" + } /* cost_info */, + "ordering_operation": { + "using_filesort": false, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": "X", + "rows_produced_per_join": "X", + "filtered": "X", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "X", + "eval_cost": "X", + "prefix_cost": "X", + "data_read_per_join": "X" + } /* cost_info */, + "used_columns": [ + "a", + "i" + ] /* used_columns */, + "ordering_operation": { + "using_filesort": false, + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "range", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "i" + ] /* used_key_parts */, + "key_length": "4", + "rows_examined_per_scan": "X", + "rows_produced_per_join": "X", + "filtered": "X", + "cost_info": { + "read_cost": "X", + "eval_cost": "X", + "prefix_cost": "X", + "data_read_per_join": "X" + } /* cost_info */, + "used_columns": [ + "a", + "i" + ] /* used_columns */, + "attached_condition": "((`test`.`t1`.`i` > 10) and (`test`.`t1`.`i` <= 18))" + } /* table */ + } /* ordering_operation */ + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`i` AS `i` from `test`.`t1` where ((`test`.`t1`.`i` > 10) and (`test`.`t1`.`i` <= 18)) order by `test`.`t1`.`i` limit 1 +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 4 +Handler_read_rnd_next 1 +# Status of testing query execution: +Variable_name Value +Handler_delete 1 +Handler_read_key 3 + +DROP TABLE t1; +#30 +CREATE TABLE t1(a INT, i CHAR(2), INDEX(i(1))) charset utf8mb4; +INSERT INTO t1 (i) VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +# +# query: DELETE FROM t1 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 5 +# select: SELECT * FROM t1 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 5 +# +EXPLAIN DELETE FROM t1 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 26 100.00 Using where; Using filesort +Warnings: +Warning 1739 Cannot use range access on index 'i' due to type or collation conversion on field 'i' +Warning 1739 Cannot use range access on index 'i' due to type or collation conversion on field 'i' +Note 1003 delete from `test`.`t1` where ((`test`.`t1`.`i` > 10) and (`test`.`t1`.`i` <= 18)) order by `test`.`t1`.`i` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t1 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_filesort": true, + "table": { + "delete": true, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 26, + "filtered": "100.00", + "attached_condition": "((`test`.`t1`.`i` > 10) and (`test`.`t1`.`i` <= 18))" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Warning 1739 Cannot use range access on index 'i' due to type or collation conversion on field 'i' +Warning 1739 Cannot use range access on index 'i' due to type or collation conversion on field 'i' +Note 1003 delete from `test`.`t1` where ((`test`.`t1`.`i` > 10) and (`test`.`t1`.`i` <= 18)) order by `test`.`t1`.`i` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "5.74" + } /* cost_info */, + "ordering_operation": { + "using_filesort": true, + "cost_info": { + "sort_cost": "2.89" + } /* cost_info */, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 26, + "rows_produced_per_join": 2, + "filtered": "11.11", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "2.56", + "eval_cost": "0.29", + "prefix_cost": "2.85", + "data_read_per_join": "69" + } /* cost_info */, + "used_columns": [ + "a", + "i" + ] /* used_columns */, + "ordering_operation": { + "using_filesort": true, + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "ALL", + "possible_keys": [ + "i" + ] /* possible_keys */, + "rows_examined_per_scan": 26, + "rows_produced_per_join": 2, + "filtered": "11.11", + "cost_info": { + "read_cost": "2.56", + "eval_cost": "0.29", + "prefix_cost": "2.85", + "data_read_per_join": "46" + } /* cost_info */, + "used_columns": [ + "a", + "i" + ] /* used_columns */, + "attached_condition": "((`test`.`t1`.`i` > 10) and (`test`.`t1`.`i` <= 18))" + } /* table */ + } /* ordering_operation */ + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Warning 1739 Cannot use range access on index 'i' due to type or collation conversion on field 'i' +Warning 1739 Cannot use range access on index 'i' due to type or collation conversion on field 'i' +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`i` AS `i` from `test`.`t1` where ((`test`.`t1`.`i` > 10) and (`test`.`t1`.`i` <= 18)) order by `test`.`t1`.`i` limit 5 +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 3 +Handler_read_rnd_next 27 +Sort_rows 5 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_delete 5 +Handler_read_first 1 +Handler_read_key 8 +Handler_read_rnd 5 +Handler_read_rnd_next 27 +Sort_rows 8 +Sort_scan 1 + +DROP TABLE t1; +#31 +CREATE TABLE t1 (i INT); +INSERT INTO t1 (i) VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2(a INT, b INT, c INT, d INT, INDEX(a, b, c)); +INSERT INTO t2 (a, b, c) SELECT i, i, i FROM t1; +# +# query: DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# select: SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# +EXPLAIN DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t2 NULL ALL NULL NULL NULL NULL 26 100.00 Using where; Using filesort +Warnings: +Note 1003 delete from `test`.`t2` where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_filesort": true, + "table": { + "delete": true, + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 26, + "filtered": "100.00", + "attached_condition": "(`test`.`t2`.`b` = 10)" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 delete from `test`.`t2` where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "2.85" + } /* cost_info */, + "ordering_operation": { + "using_filesort": false, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 2, + "filtered": "10.00", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "2.59", + "eval_cost": "0.26", + "prefix_cost": "2.85", + "data_read_per_join": "62" + } /* cost_info */, + "used_columns": [ + "a", + "b", + "c", + "d" + ] /* used_columns */, + "ordering_operation": { + "using_filesort": false, + "table": { + "select_id": 2, + "table_name": "t2", + "access_type": "index", + "key": "a", + "used_key_parts": [ + "a", + "b", + "c" + ] /* used_key_parts */, + "key_length": "15", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 2, + "filtered": "10.00", + "cost_info": { + "read_cost": "2.59", + "eval_cost": "0.26", + "prefix_cost": "2.85", + "data_read_per_join": "62" + } /* cost_info */, + "used_columns": [ + "a", + "b", + "c", + "d" + ] /* used_columns */, + "attached_condition": "(`test`.`t2`.`b` = 10)" + } /* table */ + } /* ordering_operation */ + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c`,`test`.`t2`.`d` AS `d` from `test`.`t2` where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 5 +Handler_read_rnd_next 27 +# Status of testing query execution: +Variable_name Value +Handler_delete 1 +Handler_read_first 1 +Handler_read_key 6 +Handler_read_rnd 1 +Handler_read_rnd_next 27 +Sort_rows 1 +Sort_scan 1 + +DROP TABLE t1, t2; +#32 +CREATE TABLE t1 (i INT); +INSERT INTO t1 (i) VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2(a INT, b INT, c INT, d INT, INDEX(a, b, c)); +INSERT INTO t2 (a, b, c) SELECT i, i, i FROM t1; +INSERT INTO t2 (a, b, c) SELECT t1.i, t1.i, t1.i FROM t1, t1 x1, t1 x2; +# +# query: DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# select: SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# +EXPLAIN DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t2 NULL index NULL a 15 NULL X 100.00 Using where +Warnings: +Note 1003 delete from `test`.`t2` where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_filesort": false, + "table": { + "delete": true, + "table_name": "t2", + "access_type": "index", + "key": "a", + "used_key_parts": [ + "a", + "b", + "c" + ] /* used_key_parts */, + "key_length": "15", + "rows_examined_per_scan": "X", + "filtered": "X", + "attached_condition": "(`test`.`t2`.`b` = 10)" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 delete from `test`.`t2` where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "X" + } /* cost_info */, + "ordering_operation": { + "using_filesort": false, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": "X", + "rows_produced_per_join": "X", + "filtered": "X", + "parallel_execute": "4 workers", + "cost_info": { + "read_cost": "X", + "eval_cost": "X", + "prefix_cost": "X", + "data_read_per_join": "X" + } /* cost_info */, + "used_columns": [ + "a", + "b", + "c", + "d" + ] /* used_columns */, + "ordering_operation": { + "using_filesort": false, + "table": { + "select_id": 2, + "table_name": "t2", + "access_type": "index", + "key": "a", + "used_key_parts": [ + "a", + "b", + "c" + ] /* used_key_parts */, + "key_length": "15", + "rows_examined_per_scan": "X", + "rows_produced_per_join": "X", + "filtered": "X", + "cost_info": { + "read_cost": "X", + "eval_cost": "X", + "prefix_cost": "X", + "data_read_per_join": "X" + } /* cost_info */, + "used_columns": [ + "a", + "b", + "c", + "d" + ] /* used_columns */, + "attached_condition": "(`test`.`t2`.`b` = 10)" + } /* table */ + } /* ordering_operation */ + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c`,`test`.`t2`.`d` AS `d` from `test`.`t2` where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 5 +Handler_read_rnd_next 16936 +# Status of testing query execution: +Variable_name Value +Handler_delete 5 +Handler_read_first 1 +Handler_read_key 5 +Handler_read_next 4 + +DROP TABLE t1, t2; +#33 +CREATE TABLE t1 (i INT); +INSERT INTO t1 (i) VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2 (a CHAR(2), b CHAR(2), c CHAR(2), d CHAR(2), INDEX (a,b(1),c)) +charset utf8mb4; +INSERT INTO t2 SELECT i, i, i, i FROM t1; +# +# query: DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# select: SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# +EXPLAIN DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t2 NULL ALL NULL NULL NULL NULL 26 100.00 Using where; Using filesort +Warnings: +Warning 1739 Cannot use range access on index 'a' due to type or collation conversion on field 'b' +Note 1003 delete from `test`.`t2` where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_filesort": true, + "table": { + "delete": true, + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 26, + "filtered": "100.00", + "attached_condition": "(`test`.`t2`.`b` = 10)" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Warning 1739 Cannot use range access on index 'a' due to type or collation conversion on field 'b' +Note 1003 delete from `test`.`t2` where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "5.45" + } /* cost_info */, + "ordering_operation": { + "using_filesort": true, + "cost_info": { + "sort_cost": "2.60" + } /* cost_info */, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 26, + "rows_produced_per_join": 2, + "filtered": "10.00", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "2.59", + "eval_cost": "0.26", + "prefix_cost": "2.85", + "data_read_per_join": "104" + } /* cost_info */, + "used_columns": [ + "a", + "b", + "c", + "d" + ] /* used_columns */, + "ordering_operation": { + "using_filesort": true, + "table": { + "select_id": 2, + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 26, + "rows_produced_per_join": 2, + "filtered": "10.00", + "cost_info": { + "read_cost": "2.59", + "eval_cost": "0.26", + "prefix_cost": "2.85", + "data_read_per_join": "104" + } /* cost_info */, + "used_columns": [ + "a", + "b", + "c", + "d" + ] /* used_columns */, + "attached_condition": "(`test`.`t2`.`b` = 10)" + } /* table */ + } /* ordering_operation */ + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c`,`test`.`t2`.`d` AS `d` from `test`.`t2` where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 5 +Handler_read_rnd_next 27 +Sort_rows 1 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_delete 1 +Handler_read_first 1 +Handler_read_key 6 +Handler_read_rnd 1 +Handler_read_rnd_next 27 +Sort_rows 1 +Sort_scan 1 + +DROP TABLE t1, t2; +#34 +CREATE TABLE t1 (i INT); +INSERT INTO t1 (i) VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2 (a CHAR(2), b CHAR(2), c CHAR(2), d CHAR(2), INDEX (a,b,c)) +charset utf8mb4 ENGINE=HEAP; +INSERT INTO t2 SELECT i, i, i, i FROM t1; +# +# query: DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# select: SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# +EXPLAIN DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t2 NULL ALL NULL NULL NULL NULL 26 100.00 Using where; Using filesort +Warnings: +Warning 1739 Cannot use range access on index 'a' due to type or collation conversion on field 'b' +Note 1003 delete from `test`.`t2` where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_filesort": true, + "table": { + "delete": true, + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 26, + "filtered": "100.00", + "attached_condition": "(`test`.`t2`.`b` = 10)" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Warning 1739 Cannot use range access on index 'a' due to type or collation conversion on field 'b' +Note 1003 delete from `test`.`t2` where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "8.02" + } /* cost_info */, + "ordering_operation": { + "using_filesort": true, + "cost_info": { + "sort_cost": "2.60" + } /* cost_info */, + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 26, + "rows_produced_per_join": 2, + "filtered": "10.00", + "cost_info": { + "read_cost": "5.16", + "eval_cost": "0.26", + "prefix_cost": "5.42", + "data_read_per_join": "104" + } /* cost_info */, + "used_columns": [ + "a", + "b", + "c", + "d" + ] /* used_columns */, + "attached_condition": "(`test`.`t2`.`b` = 10)" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Warning 1739 Cannot use range access on index 'a' due to type or collation conversion on field 'b' +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c`,`test`.`t2`.`d` AS `d` from `test`.`t2` where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 4 +Handler_read_rnd_next 27 +Sort_rows 1 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_delete 1 +Handler_read_key 4 +Handler_read_rnd 1 +Handler_read_rnd_next 27 +Sort_rows 1 +Sort_scan 1 + +DROP TABLE t1, t2; +#35 +CREATE TABLE t1 (i INT); +INSERT INTO t1 (i) VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35),(36),(37),(38),(39), +(40),(41),(42),(43),(44); +CREATE TABLE t2 (i INT, key1 INT, key2 INT, INDEX (key1), INDEX (key2)); +INSERT INTO t2 (key1, key2) SELECT i, i FROM t1; +# +# query: DELETE FROM t2 WHERE key1 < 13 or key2 < 14 ORDER BY key1 +# select: SELECT * FROM t2 WHERE key1 < 13 or key2 < 14 ORDER BY key1 +# +EXPLAIN DELETE FROM t2 WHERE key1 < 13 or key2 < 14 ORDER BY key1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t2 NULL index_merge key1,key2 key1,key2 5,5 NULL X 100.00 Using sort_union(key1,key2); Using where; Using filesort +Warnings: +Note 1003 delete from `test`.`t2` where ((`test`.`t2`.`key1` < 13) or (`test`.`t2`.`key2` < 14)) order by `test`.`t2`.`key1` +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t2 WHERE key1 < 13 or key2 < 14 ORDER BY key1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_filesort": true, + "table": { + "delete": true, + "table_name": "t2", + "access_type": "index_merge", + "possible_keys": [ + "key1", + "key2" + ] /* possible_keys */, + "key": "sort_union(key1,key2)", + "key_length": "5,5", + "rows_examined_per_scan": "X", + "filtered": "X", + "attached_condition": "((`test`.`t2`.`key1` < 13) or (`test`.`t2`.`key2` < 14))" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 delete from `test`.`t2` where ((`test`.`t2`.`key1` < 13) or (`test`.`t2`.`key2` < 14)) order by `test`.`t2`.`key1` +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t2 WHERE key1 < 13 or key2 < 14 ORDER BY key1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "X" + } /* cost_info */, + "ordering_operation": { + "using_filesort": true, + "cost_info": { + "sort_cost": "X" + } /* cost_info */, + "table": { + "table_name": "t2", + "access_type": "index_merge", + "possible_keys": [ + "key1", + "key2" + ] /* possible_keys */, + "key": "sort_union(key1,key2)", + "key_length": "5,5", + "rows_examined_per_scan": "X", + "rows_produced_per_join": "X", + "filtered": "X", + "cost_info": { + "read_cost": "X", + "eval_cost": "X", + "prefix_cost": "X", + "data_read_per_join": "X" + } /* cost_info */, + "used_columns": [ + "i", + "key1", + "key2" + ] /* used_columns */, + "attached_condition": "((`test`.`t2`.`key1` < 13) or (`test`.`t2`.`key2` < 14))" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`i` AS `i`,`test`.`t2`.`key1` AS `key1`,`test`.`t2`.`key2` AS `key2` from `test`.`t2` where ((`test`.`t2`.`key1` < 13) or (`test`.`t2`.`key2` < 14)) order by `test`.`t2`.`key1` +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 9 +Handler_read_next 7 +Handler_read_rnd 4 +Sort_rows 4 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_delete 4 +Handler_read_key 13 +Handler_read_next 7 +Handler_read_rnd 8 +Sort_rows 4 +Sort_scan 1 + +DROP TABLE t1, t2; +#36 +CREATE TABLE t1 (i INT); +INSERT INTO t1 (i) VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2(a INT, i INT PRIMARY KEY); +INSERT INTO t2 (i) SELECT i FROM t1; +# +# query: DELETE FROM t2 WHERE i > 10 AND i <= 18 ORDER BY i DESC LIMIT 1 +# select: SELECT * FROM t2 WHERE i > 10 AND i <= 18 ORDER BY i DESC LIMIT 1 +# +EXPLAIN DELETE FROM t2 WHERE i > 10 AND i <= 18 ORDER BY i DESC LIMIT 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t2 NULL range PRIMARY PRIMARY 4 const X 100.00 Using where; Backward index scan +Warnings: +Note 1003 delete from `test`.`t2` where ((`test`.`t2`.`i` > 10) and (`test`.`t2`.`i` <= 18)) order by `test`.`t2`.`i` desc limit 1 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t2 WHERE i > 10 AND i <= 18 ORDER BY i DESC LIMIT 1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_filesort": false, + "table": { + "delete": true, + "table_name": "t2", + "access_type": "range", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "i" + ] /* used_key_parts */, + "key_length": "4", + "ref": [ + "const" + ] /* ref */, + "rows_examined_per_scan": "X", + "filtered": "X", + "backward_index_scan": true, + "attached_condition": "((`test`.`t2`.`i` > 10) and (`test`.`t2`.`i` <= 18))" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 delete from `test`.`t2` where ((`test`.`t2`.`i` > 10) and (`test`.`t2`.`i` <= 18)) order by `test`.`t2`.`i` desc limit 1 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t2 WHERE i > 10 AND i <= 18 ORDER BY i DESC LIMIT 1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "X" + } /* cost_info */, + "ordering_operation": { + "using_filesort": false, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": "X", + "rows_produced_per_join": "X", + "filtered": "X", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "X", + "eval_cost": "X", + "prefix_cost": "X", + "data_read_per_join": "X" + } /* cost_info */, + "used_columns": [ + "a", + "i" + ] /* used_columns */, + "ordering_operation": { + "using_filesort": false, + "table": { + "select_id": 2, + "table_name": "t2", + "access_type": "range", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "i" + ] /* used_key_parts */, + "key_length": "4", + "rows_examined_per_scan": "X", + "rows_produced_per_join": "X", + "filtered": "X", + "backward_index_scan": true, + "cost_info": { + "read_cost": "X", + "eval_cost": "X", + "prefix_cost": "X", + "data_read_per_join": "X" + } /* cost_info */, + "used_columns": [ + "a", + "i" + ] /* used_columns */, + "attached_condition": "((`test`.`t2`.`i` > 10) and (`test`.`t2`.`i` <= 18))" + } /* table */ + } /* ordering_operation */ + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`i` AS `i` from `test`.`t2` where ((`test`.`t2`.`i` > 10) and (`test`.`t2`.`i` <= 18)) order by `test`.`t2`.`i` desc limit 1 +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 4 +Handler_read_rnd_next 1 +# Status of testing query execution: +Variable_name Value +Handler_delete 1 +Handler_read_key 3 + +DROP TABLE t1, t2; +#37 +CREATE TABLE t1 (i INT); +INSERT INTO t1 (i) VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2 (a CHAR(2), b CHAR(2), c CHAR(2), INDEX (a, b)) charset utf8mb4; +INSERT INTO t2 SELECT i, i, i FROM t1; +# +# query: DELETE FROM t2 ORDER BY a, b DESC LIMIT 5 +# select: SELECT * FROM t2 ORDER BY a, b DESC LIMIT 5 +# +EXPLAIN DELETE FROM t2 ORDER BY a, b DESC LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t2 NULL ALL NULL NULL NULL NULL 26 100.00 Using filesort +Warnings: +Note 1003 delete from `test`.`t2` order by `test`.`t2`.`a`,`test`.`t2`.`b` desc limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t2 ORDER BY a, b DESC LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_filesort": true, + "table": { + "delete": true, + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 26, + "filtered": "100.00" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 delete from `test`.`t2` order by `test`.`t2`.`a`,`test`.`t2`.`b` desc limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t2 ORDER BY a, b DESC LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "2.85" + } /* cost_info */, + "ordering_operation": { + "using_filesort": true, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 26, + "rows_produced_per_join": 26, + "filtered": "100.00", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "2.60", + "prefix_cost": "2.85", + "data_read_per_join": "832" + } /* cost_info */, + "used_columns": [ + "a", + "b", + "c" + ] /* used_columns */, + "ordering_operation": { + "using_filesort": true, + "table": { + "select_id": 2, + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 26, + "rows_produced_per_join": 26, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "2.60", + "prefix_cost": "2.85", + "data_read_per_join": "832" + } /* cost_info */, + "used_columns": [ + "a", + "b", + "c" + ] /* used_columns */ + } /* table */ + } /* ordering_operation */ + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c` from `test`.`t2` order by `test`.`t2`.`a`,`test`.`t2`.`b` desc limit 5 +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 4 +Handler_read_rnd_next 27 +Sort_rows 5 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_delete 5 +Handler_read_first 1 +Handler_read_key 9 +Handler_read_rnd 5 +Handler_read_rnd_next 27 +Sort_rows 26 +Sort_scan 1 + +DROP TABLE t1, t2; +#38 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2 (a CHAR(2), b CHAR(2), c INT, INDEX (a, b)) charset utf8mb4; +INSERT INTO t2 (a, b) SELECT i, i FROM t1; +INSERT INTO t2 (a, b) SELECT t1.i, t1.i FROM t1, t1 x1, t1 x2; +# +# query: DELETE FROM t2 ORDER BY a DESC, b DESC LIMIT 5 +# select: SELECT * FROM t2 ORDER BY a DESC, b DESC LIMIT 5 +# +EXPLAIN DELETE FROM t2 ORDER BY a DESC, b DESC LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t2 NULL index NULL a 18 NULL X 100.00 NULL +Warnings: +Note 1003 delete from `test`.`t2` order by `test`.`t2`.`a` desc,`test`.`t2`.`b` desc limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t2 ORDER BY a DESC, b DESC LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_filesort": false, + "table": { + "delete": true, + "table_name": "t2", + "access_type": "index", + "key": "a", + "used_key_parts": [ + "a", + "b" + ] /* used_key_parts */, + "key_length": "18", + "rows_examined_per_scan": "X", + "filtered": "X" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 delete from `test`.`t2` order by `test`.`t2`.`a` desc,`test`.`t2`.`b` desc limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t2 ORDER BY a DESC, b DESC LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "X" + } /* cost_info */, + "ordering_operation": { + "using_filesort": false, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": "X", + "rows_produced_per_join": "X", + "filtered": "X", + "backward_index_scan": true, + "parallel_execute": "4 workers", + "cost_info": { + "read_cost": "X", + "eval_cost": "X", + "prefix_cost": "X", + "data_read_per_join": "X" + } /* cost_info */, + "used_columns": [ + "a", + "b", + "c" + ] /* used_columns */, + "ordering_operation": { + "using_filesort": false, + "table": { + "select_id": 2, + "table_name": "t2", + "access_type": "index", + "key": "a", + "used_key_parts": [ + "a", + "b" + ] /* used_key_parts */, + "key_length": "18", + "rows_examined_per_scan": "X", + "rows_produced_per_join": "X", + "filtered": "X", + "backward_index_scan": true, + "cost_info": { + "read_cost": "X", + "eval_cost": "X", + "prefix_cost": "X", + "data_read_per_join": "X" + } /* cost_info */, + "used_columns": [ + "a", + "b", + "c" + ] /* used_columns */ + } /* table */ + } /* ordering_operation */ + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c` from `test`.`t2` order by `test`.`t2`.`a` desc,`test`.`t2`.`b` desc limit 5 +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 4 +Handler_read_last 1 +Handler_read_rnd_next 20 +# Status of testing query execution: +Variable_name Value +Handler_delete 5 +Handler_read_key 4 +Handler_read_last 1 +Handler_read_prev 4 + +DROP TABLE t1, t2; +#39 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2(a INT, i INT PRIMARY KEY); +INSERT INTO t2 (i) SELECT i FROM t1; +# +# query: UPDATE t2 SET a = 10 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 1 +# select: SELECT * FROM t2 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 1 +# +EXPLAIN UPDATE t2 SET a = 10 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t2 NULL range PRIMARY PRIMARY 4 const X 100.00 Using where; Using temporary +Warnings: +Note 1003 update `test`.`t2` set `test`.`t2`.`a` = 10 where ((`test`.`t2`.`i` > 10) and (`test`.`t2`.`i` <= 18)) order by `test`.`t2`.`i` limit 1 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t2 SET a = 10 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_temporary_table": true, + "using_filesort": false, + "table": { + "update": true, + "table_name": "t2", + "access_type": "range", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "i" + ] /* used_key_parts */, + "key_length": "4", + "ref": [ + "const" + ] /* ref */, + "rows_examined_per_scan": "X", + "filtered": "X", + "attached_condition": "((`test`.`t2`.`i` > 10) and (`test`.`t2`.`i` <= 18))" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t2` set `test`.`t2`.`a` = 10 where ((`test`.`t2`.`i` > 10) and (`test`.`t2`.`i` <= 18)) order by `test`.`t2`.`i` limit 1 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t2 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "X" + } /* cost_info */, + "ordering_operation": { + "using_filesort": false, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": "X", + "rows_produced_per_join": "X", + "filtered": "X", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "X", + "eval_cost": "X", + "prefix_cost": "X", + "data_read_per_join": "X" + } /* cost_info */, + "used_columns": [ + "a", + "i" + ] /* used_columns */, + "ordering_operation": { + "using_filesort": false, + "table": { + "select_id": 2, + "table_name": "t2", + "access_type": "range", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "i" + ] /* used_key_parts */, + "key_length": "4", + "rows_examined_per_scan": "X", + "rows_produced_per_join": "X", + "filtered": "X", + "cost_info": { + "read_cost": "X", + "eval_cost": "X", + "prefix_cost": "X", + "data_read_per_join": "X" + } /* cost_info */, + "used_columns": [ + "a", + "i" + ] /* used_columns */, + "attached_condition": "((`test`.`t2`.`i` > 10) and (`test`.`t2`.`i` <= 18))" + } /* table */ + } /* ordering_operation */ + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`i` AS `i` from `test`.`t2` where ((`test`.`t2`.`i` > 10) and (`test`.`t2`.`i` <= 18)) order by `test`.`t2`.`i` limit 1 +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 4 +Handler_read_rnd_next 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 4 +Handler_read_rnd 1 +Handler_update 1 + +DROP TABLE t1, t2; +#40 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2(a INT, i CHAR(2), INDEX(i(1))) charset utf8mb4; +INSERT INTO t2 (i) SELECT i FROM t1; +# +# query: UPDATE t2 SET a = 10 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 5 +# select: SELECT * FROM t2 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 5 +# +EXPLAIN UPDATE t2 SET a = 10 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t2 NULL ALL NULL NULL NULL NULL 26 100.00 Using where; Using filesort +Warnings: +Warning 1739 Cannot use range access on index 'i' due to type or collation conversion on field 'i' +Warning 1739 Cannot use range access on index 'i' due to type or collation conversion on field 'i' +Note 1003 update `test`.`t2` set `test`.`t2`.`a` = 10 where ((`test`.`t2`.`i` > 10) and (`test`.`t2`.`i` <= 18)) order by `test`.`t2`.`i` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t2 SET a = 10 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_filesort": true, + "table": { + "update": true, + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 26, + "filtered": "100.00", + "attached_condition": "((`test`.`t2`.`i` > 10) and (`test`.`t2`.`i` <= 18))" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Warning 1739 Cannot use range access on index 'i' due to type or collation conversion on field 'i' +Warning 1739 Cannot use range access on index 'i' due to type or collation conversion on field 'i' +Note 1003 update `test`.`t2` set `test`.`t2`.`a` = 10 where ((`test`.`t2`.`i` > 10) and (`test`.`t2`.`i` <= 18)) order by `test`.`t2`.`i` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t2 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "5.74" + } /* cost_info */, + "ordering_operation": { + "using_filesort": true, + "cost_info": { + "sort_cost": "2.89" + } /* cost_info */, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 26, + "rows_produced_per_join": 2, + "filtered": "11.11", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "2.56", + "eval_cost": "0.29", + "prefix_cost": "2.85", + "data_read_per_join": "69" + } /* cost_info */, + "used_columns": [ + "a", + "i" + ] /* used_columns */, + "ordering_operation": { + "using_filesort": true, + "table": { + "select_id": 2, + "table_name": "t2", + "access_type": "ALL", + "possible_keys": [ + "i" + ] /* possible_keys */, + "rows_examined_per_scan": 26, + "rows_produced_per_join": 2, + "filtered": "11.11", + "cost_info": { + "read_cost": "2.56", + "eval_cost": "0.29", + "prefix_cost": "2.85", + "data_read_per_join": "46" + } /* cost_info */, + "used_columns": [ + "a", + "i" + ] /* used_columns */, + "attached_condition": "((`test`.`t2`.`i` > 10) and (`test`.`t2`.`i` <= 18))" + } /* table */ + } /* ordering_operation */ + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Warning 1739 Cannot use range access on index 'i' due to type or collation conversion on field 'i' +Warning 1739 Cannot use range access on index 'i' due to type or collation conversion on field 'i' +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`i` AS `i` from `test`.`t2` where ((`test`.`t2`.`i` > 10) and (`test`.`t2`.`i` <= 18)) order by `test`.`t2`.`i` limit 5 +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 3 +Handler_read_rnd_next 27 +Sort_rows 5 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 8 +Handler_read_rnd 5 +Handler_read_rnd_next 27 +Handler_update 5 +Sort_rows 5 +Sort_scan 1 + +DROP TABLE t1, t2; +#41 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2(a INT, b INT, c INT, d INT, INDEX(a, b, c)); +INSERT INTO t2 (a, b, c) SELECT i, i, i FROM t1; +# +# query: UPDATE t2 SET d = 10 WHERE b = 10 ORDER BY a, c LIMIT 5 +# select: SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# +EXPLAIN UPDATE t2 SET d = 10 WHERE b = 10 ORDER BY a, c LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t2 NULL ALL NULL NULL NULL NULL 26 100.00 Using where; Using filesort +Warnings: +Note 1003 update `test`.`t2` set `test`.`t2`.`d` = 10 where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t2 SET d = 10 WHERE b = 10 ORDER BY a, c LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_filesort": true, + "table": { + "update": true, + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 26, + "filtered": "100.00", + "attached_condition": "(`test`.`t2`.`b` = 10)" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t2` set `test`.`t2`.`d` = 10 where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "2.85" + } /* cost_info */, + "ordering_operation": { + "using_filesort": false, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 2, + "filtered": "10.00", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "2.59", + "eval_cost": "0.26", + "prefix_cost": "2.85", + "data_read_per_join": "62" + } /* cost_info */, + "used_columns": [ + "a", + "b", + "c", + "d" + ] /* used_columns */, + "ordering_operation": { + "using_filesort": false, + "table": { + "select_id": 2, + "table_name": "t2", + "access_type": "index", + "key": "a", + "used_key_parts": [ + "a", + "b", + "c" + ] /* used_key_parts */, + "key_length": "15", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 2, + "filtered": "10.00", + "cost_info": { + "read_cost": "2.59", + "eval_cost": "0.26", + "prefix_cost": "2.85", + "data_read_per_join": "62" + } /* cost_info */, + "used_columns": [ + "a", + "b", + "c", + "d" + ] /* used_columns */, + "attached_condition": "(`test`.`t2`.`b` = 10)" + } /* table */ + } /* ordering_operation */ + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c`,`test`.`t2`.`d` AS `d` from `test`.`t2` where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 5 +Handler_read_rnd_next 27 +# Status of testing query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 6 +Handler_read_rnd 1 +Handler_read_rnd_next 27 +Handler_update 1 +Sort_rows 1 +Sort_scan 1 + +DROP TABLE t1, t2; +#42 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2(a INT, b INT, c INT, d INT, INDEX(a, b, c)); +INSERT INTO t2 (a, b, c) SELECT i, i, i FROM t1; +INSERT INTO t2 (a, b, c) SELECT t1.i, t1.i, t1.i FROM t1, t1 x1, t1 x2; +# +# query: UPDATE t2 SET d = 10 WHERE b = 10 ORDER BY a, c LIMIT 5 +# select: SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# +EXPLAIN UPDATE t2 SET d = 10 WHERE b = 10 ORDER BY a, c LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t2 NULL index NULL a 15 NULL X 100.00 Using where; Using temporary +Warnings: +Note 1003 update `test`.`t2` set `test`.`t2`.`d` = 10 where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t2 SET d = 10 WHERE b = 10 ORDER BY a, c LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_temporary_table": true, + "using_filesort": false, + "table": { + "update": true, + "table_name": "t2", + "access_type": "index", + "key": "a", + "used_key_parts": [ + "a", + "b", + "c" + ] /* used_key_parts */, + "key_length": "15", + "rows_examined_per_scan": "X", + "filtered": "X", + "attached_condition": "(`test`.`t2`.`b` = 10)" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t2` set `test`.`t2`.`d` = 10 where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "X" + } /* cost_info */, + "ordering_operation": { + "using_filesort": false, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": "X", + "rows_produced_per_join": "X", + "filtered": "X", + "parallel_execute": "4 workers", + "cost_info": { + "read_cost": "X", + "eval_cost": "X", + "prefix_cost": "X", + "data_read_per_join": "X" + } /* cost_info */, + "used_columns": [ + "a", + "b", + "c", + "d" + ] /* used_columns */, + "ordering_operation": { + "using_filesort": false, + "table": { + "select_id": 2, + "table_name": "t2", + "access_type": "index", + "key": "a", + "used_key_parts": [ + "a", + "b", + "c" + ] /* used_key_parts */, + "key_length": "15", + "rows_examined_per_scan": "X", + "rows_produced_per_join": "X", + "filtered": "X", + "cost_info": { + "read_cost": "X", + "eval_cost": "X", + "prefix_cost": "X", + "data_read_per_join": "X" + } /* cost_info */, + "used_columns": [ + "a", + "b", + "c", + "d" + ] /* used_columns */, + "attached_condition": "(`test`.`t2`.`b` = 10)" + } /* table */ + } /* ordering_operation */ + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c`,`test`.`t2`.`d` AS `d` from `test`.`t2` where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 5 +Handler_read_rnd_next 16936 +# Status of testing query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 10 +Handler_read_next 4 +Handler_read_rnd 5 +Handler_update 5 + +DROP TABLE t1, t2; +#43 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2 (a CHAR(2), b CHAR(2), c CHAR(2), d CHAR(2), INDEX (a,b(1),c)) +charset utf8mb4; +INSERT INTO t2 SELECT i, i, i, i FROM t1; +# +# query: UPDATE t2 SET d = 10 WHERE b = 10 ORDER BY a, c LIMIT 5 +# select: SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# +EXPLAIN UPDATE t2 SET d = 10 WHERE b = 10 ORDER BY a, c LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t2 NULL ALL NULL NULL NULL NULL 26 100.00 Using where; Using filesort +Warnings: +Warning 1739 Cannot use range access on index 'a' due to type or collation conversion on field 'b' +Note 1003 update `test`.`t2` set `test`.`t2`.`d` = 10 where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t2 SET d = 10 WHERE b = 10 ORDER BY a, c LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_filesort": true, + "table": { + "update": true, + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 26, + "filtered": "100.00", + "attached_condition": "(`test`.`t2`.`b` = 10)" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Warning 1739 Cannot use range access on index 'a' due to type or collation conversion on field 'b' +Note 1003 update `test`.`t2` set `test`.`t2`.`d` = 10 where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "5.45" + } /* cost_info */, + "ordering_operation": { + "using_filesort": true, + "cost_info": { + "sort_cost": "2.60" + } /* cost_info */, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 26, + "rows_produced_per_join": 2, + "filtered": "10.00", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "2.59", + "eval_cost": "0.26", + "prefix_cost": "2.85", + "data_read_per_join": "104" + } /* cost_info */, + "used_columns": [ + "a", + "b", + "c", + "d" + ] /* used_columns */, + "ordering_operation": { + "using_filesort": true, + "table": { + "select_id": 2, + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 26, + "rows_produced_per_join": 2, + "filtered": "10.00", + "cost_info": { + "read_cost": "2.59", + "eval_cost": "0.26", + "prefix_cost": "2.85", + "data_read_per_join": "104" + } /* cost_info */, + "used_columns": [ + "a", + "b", + "c", + "d" + ] /* used_columns */, + "attached_condition": "(`test`.`t2`.`b` = 10)" + } /* table */ + } /* ordering_operation */ + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c`,`test`.`t2`.`d` AS `d` from `test`.`t2` where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 5 +Handler_read_rnd_next 27 +Sort_rows 1 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 6 +Handler_read_rnd 1 +Handler_read_rnd_next 27 +Sort_rows 1 +Sort_scan 1 + +DROP TABLE t1, t2; +#44 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2 (a CHAR(2), b CHAR(2), c CHAR(2), d CHAR(2), INDEX (a,b,c)) +charset utf8mb4 ENGINE=HEAP; +INSERT INTO t2 SELECT i, i, i, i FROM t1; +# +# query: UPDATE t2 SET d = 10 WHERE b = 10 ORDER BY a, c LIMIT 5 +# select: SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# +EXPLAIN UPDATE t2 SET d = 10 WHERE b = 10 ORDER BY a, c LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t2 NULL ALL NULL NULL NULL NULL 26 100.00 Using where; Using filesort +Warnings: +Warning 1739 Cannot use range access on index 'a' due to type or collation conversion on field 'b' +Note 1003 update `test`.`t2` set `test`.`t2`.`d` = 10 where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t2 SET d = 10 WHERE b = 10 ORDER BY a, c LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_filesort": true, + "table": { + "update": true, + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 26, + "filtered": "100.00", + "attached_condition": "(`test`.`t2`.`b` = 10)" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Warning 1739 Cannot use range access on index 'a' due to type or collation conversion on field 'b' +Note 1003 update `test`.`t2` set `test`.`t2`.`d` = 10 where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "8.02" + } /* cost_info */, + "ordering_operation": { + "using_filesort": true, + "cost_info": { + "sort_cost": "2.60" + } /* cost_info */, + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 26, + "rows_produced_per_join": 2, + "filtered": "10.00", + "cost_info": { + "read_cost": "5.16", + "eval_cost": "0.26", + "prefix_cost": "5.42", + "data_read_per_join": "104" + } /* cost_info */, + "used_columns": [ + "a", + "b", + "c", + "d" + ] /* used_columns */, + "attached_condition": "(`test`.`t2`.`b` = 10)" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Warning 1739 Cannot use range access on index 'a' due to type or collation conversion on field 'b' +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c`,`test`.`t2`.`d` AS `d` from `test`.`t2` where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 4 +Handler_read_rnd_next 27 +Sort_rows 1 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 4 +Handler_read_rnd 1 +Handler_read_rnd_next 27 +Sort_rows 1 +Sort_scan 1 + +DROP TABLE t1, t2; +#45 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35),(36),(37),(38),(39), +(40),(41),(42),(43),(44); +CREATE TABLE t2 (i INT, key1 INT, key2 INT, INDEX (key1), INDEX (key2)); +INSERT INTO t2 (key1, key2) SELECT i, i FROM t1; +# +# query: UPDATE t2 SET i = 123 WHERE key1 < 13 or key2 < 14 ORDER BY key1 +# select: SELECT * FROM t2 WHERE key1 < 13 or key2 < 14 ORDER BY key1 +# +EXPLAIN UPDATE t2 SET i = 123 WHERE key1 < 13 or key2 < 14 ORDER BY key1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t2 NULL index_merge key1,key2 key1,key2 5,5 NULL X 100.00 Using sort_union(key1,key2); Using where; Using filesort +Warnings: +Note 1003 update `test`.`t2` set `test`.`t2`.`i` = 123 where ((`test`.`t2`.`key1` < 13) or (`test`.`t2`.`key2` < 14)) order by `test`.`t2`.`key1` +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t2 SET i = 123 WHERE key1 < 13 or key2 < 14 ORDER BY key1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_filesort": true, + "table": { + "update": true, + "table_name": "t2", + "access_type": "index_merge", + "possible_keys": [ + "key1", + "key2" + ] /* possible_keys */, + "key": "sort_union(key1,key2)", + "key_length": "5,5", + "rows_examined_per_scan": "X", + "filtered": "X", + "attached_condition": "((`test`.`t2`.`key1` < 13) or (`test`.`t2`.`key2` < 14))" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t2` set `test`.`t2`.`i` = 123 where ((`test`.`t2`.`key1` < 13) or (`test`.`t2`.`key2` < 14)) order by `test`.`t2`.`key1` +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t2 WHERE key1 < 13 or key2 < 14 ORDER BY key1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "X" + } /* cost_info */, + "ordering_operation": { + "using_filesort": true, + "cost_info": { + "sort_cost": "X" + } /* cost_info */, + "table": { + "table_name": "t2", + "access_type": "index_merge", + "possible_keys": [ + "key1", + "key2" + ] /* possible_keys */, + "key": "sort_union(key1,key2)", + "key_length": "5,5", + "rows_examined_per_scan": "X", + "rows_produced_per_join": "X", + "filtered": "X", + "cost_info": { + "read_cost": "X", + "eval_cost": "X", + "prefix_cost": "X", + "data_read_per_join": "X" + } /* cost_info */, + "used_columns": [ + "i", + "key1", + "key2" + ] /* used_columns */, + "attached_condition": "((`test`.`t2`.`key1` < 13) or (`test`.`t2`.`key2` < 14))" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`i` AS `i`,`test`.`t2`.`key1` AS `key1`,`test`.`t2`.`key2` AS `key2` from `test`.`t2` where ((`test`.`t2`.`key1` < 13) or (`test`.`t2`.`key2` < 14)) order by `test`.`t2`.`key1` +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 9 +Handler_read_next 7 +Handler_read_rnd 4 +Sort_rows 4 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 13 +Handler_read_next 7 +Handler_read_rnd 8 +Handler_update 4 +Sort_rows 4 +Sort_scan 1 + +DROP TABLE t1, t2; +#46 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2(a INT, i INT PRIMARY KEY); +INSERT INTO t2 (i) SELECT i FROM t1; +# +# query: UPDATE t2 SET a = 10 WHERE i > 10 AND i <= 18 ORDER BY i DESC LIMIT 1 +# select: SELECT * FROM t2 WHERE i > 10 AND i <= 18 ORDER BY i DESC LIMIT 1 +# +EXPLAIN UPDATE t2 SET a = 10 WHERE i > 10 AND i <= 18 ORDER BY i DESC LIMIT 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t2 NULL range PRIMARY PRIMARY 4 const X 100.00 Using where; Backward index scan; Using temporary +Warnings: +Note 1003 update `test`.`t2` set `test`.`t2`.`a` = 10 where ((`test`.`t2`.`i` > 10) and (`test`.`t2`.`i` <= 18)) order by `test`.`t2`.`i` desc limit 1 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t2 SET a = 10 WHERE i > 10 AND i <= 18 ORDER BY i DESC LIMIT 1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_temporary_table": true, + "using_filesort": false, + "table": { + "update": true, + "table_name": "t2", + "access_type": "range", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "i" + ] /* used_key_parts */, + "key_length": "4", + "ref": [ + "const" + ] /* ref */, + "rows_examined_per_scan": "X", + "filtered": "X", + "backward_index_scan": true, + "attached_condition": "((`test`.`t2`.`i` > 10) and (`test`.`t2`.`i` <= 18))" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t2` set `test`.`t2`.`a` = 10 where ((`test`.`t2`.`i` > 10) and (`test`.`t2`.`i` <= 18)) order by `test`.`t2`.`i` desc limit 1 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t2 WHERE i > 10 AND i <= 18 ORDER BY i DESC LIMIT 1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "X" + } /* cost_info */, + "ordering_operation": { + "using_filesort": false, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": "X", + "rows_produced_per_join": "X", + "filtered": "X", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "X", + "eval_cost": "X", + "prefix_cost": "X", + "data_read_per_join": "X" + } /* cost_info */, + "used_columns": [ + "a", + "i" + ] /* used_columns */, + "ordering_operation": { + "using_filesort": false, + "table": { + "select_id": 2, + "table_name": "t2", + "access_type": "range", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "i" + ] /* used_key_parts */, + "key_length": "4", + "rows_examined_per_scan": "X", + "rows_produced_per_join": "X", + "filtered": "X", + "backward_index_scan": true, + "cost_info": { + "read_cost": "X", + "eval_cost": "X", + "prefix_cost": "X", + "data_read_per_join": "X" + } /* cost_info */, + "used_columns": [ + "a", + "i" + ] /* used_columns */, + "attached_condition": "((`test`.`t2`.`i` > 10) and (`test`.`t2`.`i` <= 18))" + } /* table */ + } /* ordering_operation */ + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`i` AS `i` from `test`.`t2` where ((`test`.`t2`.`i` > 10) and (`test`.`t2`.`i` <= 18)) order by `test`.`t2`.`i` desc limit 1 +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 4 +Handler_read_rnd_next 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 4 +Handler_read_rnd 1 +Handler_update 1 + +DROP TABLE t1, t2; +#47 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2 (a CHAR(2), b CHAR(2), c CHAR(2), INDEX (a, b)) charset utf8mb4; +INSERT INTO t2 SELECT i, i, i FROM t1; +# +# query: UPDATE t2 SET c = 10 ORDER BY a, b DESC LIMIT 5 +# select: SELECT * FROM t2 ORDER BY a, b DESC LIMIT 5 +# +EXPLAIN UPDATE t2 SET c = 10 ORDER BY a, b DESC LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t2 NULL ALL NULL NULL NULL NULL 26 100.00 Using filesort +Warnings: +Note 1003 update `test`.`t2` set `test`.`t2`.`c` = 10 order by `test`.`t2`.`a`,`test`.`t2`.`b` desc limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t2 SET c = 10 ORDER BY a, b DESC LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_filesort": true, + "table": { + "update": true, + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 26, + "filtered": "100.00" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t2` set `test`.`t2`.`c` = 10 order by `test`.`t2`.`a`,`test`.`t2`.`b` desc limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t2 ORDER BY a, b DESC LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "2.85" + } /* cost_info */, + "ordering_operation": { + "using_filesort": true, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 26, + "rows_produced_per_join": 26, + "filtered": "100.00", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "2.60", + "prefix_cost": "2.85", + "data_read_per_join": "832" + } /* cost_info */, + "used_columns": [ + "a", + "b", + "c" + ] /* used_columns */, + "ordering_operation": { + "using_filesort": true, + "table": { + "select_id": 2, + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 26, + "rows_produced_per_join": 26, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "2.60", + "prefix_cost": "2.85", + "data_read_per_join": "832" + } /* cost_info */, + "used_columns": [ + "a", + "b", + "c" + ] /* used_columns */ + } /* table */ + } /* ordering_operation */ + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c` from `test`.`t2` order by `test`.`t2`.`a`,`test`.`t2`.`b` desc limit 5 +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 4 +Handler_read_rnd_next 27 +Sort_rows 5 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 9 +Handler_read_rnd 5 +Handler_read_rnd_next 27 +Handler_update 4 +Sort_rows 5 +Sort_scan 1 + +DROP TABLE t1, t2; +#48 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2 (a CHAR(2), b CHAR(2), c INT, INDEX (a, b)) charset utf8mb4; +INSERT INTO t2 (a, b) SELECT i, i FROM t1; +INSERT INTO t2 (a, b) SELECT t1.i, t1.i FROM t1, t1 x1, t1 x2; +# +# query: UPDATE t2 SET c = 10 ORDER BY a DESC, b DESC LIMIT 5 +# select: SELECT * FROM t2 ORDER BY a DESC, b DESC LIMIT 5 +# +EXPLAIN UPDATE t2 SET c = 10 ORDER BY a DESC, b DESC LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t2 NULL index NULL a 18 NULL X 100.00 Using temporary +Warnings: +Note 1003 update `test`.`t2` set `test`.`t2`.`c` = 10 order by `test`.`t2`.`a` desc,`test`.`t2`.`b` desc limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t2 SET c = 10 ORDER BY a DESC, b DESC LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_temporary_table": true, + "using_filesort": false, + "table": { + "update": true, + "table_name": "t2", + "access_type": "index", + "key": "a", + "used_key_parts": [ + "a", + "b" + ] /* used_key_parts */, + "key_length": "18", + "rows_examined_per_scan": "X", + "filtered": "X" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t2` set `test`.`t2`.`c` = 10 order by `test`.`t2`.`a` desc,`test`.`t2`.`b` desc limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t2 ORDER BY a DESC, b DESC LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "X" + } /* cost_info */, + "ordering_operation": { + "using_filesort": false, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": "X", + "rows_produced_per_join": "X", + "filtered": "X", + "backward_index_scan": true, + "parallel_execute": "4 workers", + "cost_info": { + "read_cost": "X", + "eval_cost": "X", + "prefix_cost": "X", + "data_read_per_join": "X" + } /* cost_info */, + "used_columns": [ + "a", + "b", + "c" + ] /* used_columns */, + "ordering_operation": { + "using_filesort": false, + "table": { + "select_id": 2, + "table_name": "t2", + "access_type": "index", + "key": "a", + "used_key_parts": [ + "a", + "b" + ] /* used_key_parts */, + "key_length": "18", + "rows_examined_per_scan": "X", + "rows_produced_per_join": "X", + "filtered": "X", + "backward_index_scan": true, + "cost_info": { + "read_cost": "X", + "eval_cost": "X", + "prefix_cost": "X", + "data_read_per_join": "X" + } /* cost_info */, + "used_columns": [ + "a", + "b", + "c" + ] /* used_columns */ + } /* table */ + } /* ordering_operation */ + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c` from `test`.`t2` order by `test`.`t2`.`a` desc,`test`.`t2`.`b` desc limit 5 +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 4 +Handler_read_last 1 +Handler_read_rnd_next 20 +# Status of testing query execution: +Variable_name Value +Handler_read_key 9 +Handler_read_last 1 +Handler_read_prev 4 +Handler_read_rnd 5 +Handler_update 5 + +DROP TABLE t1, t2; +#49 +CREATE TABLE t1 ( +pk INT NOT NULL AUTO_INCREMENT, +c1_idx CHAR(1) DEFAULT 'y', +c2 INT, +PRIMARY KEY (pk), +INDEX c1_idx (c1_idx) +) charset utf8mb4; +INSERT INTO t1 VALUES (1,'y',1), (2,'n',2), (3,'y',3), (4,'n',4); +# +# query: UPDATE t1 SET c2 = 0 WHERE c1_idx = 'y' ORDER BY pk DESC LIMIT 2 +# select: SELECT * FROM t1 WHERE c1_idx = 'y' ORDER BY pk DESC LIMIT 2 +# +EXPLAIN UPDATE t1 SET c2 = 0 WHERE c1_idx = 'y' ORDER BY pk DESC LIMIT 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL range c1_idx c1_idx 5 const 2 100.00 Using where; Backward index scan; Using temporary +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`c2` = 0 where (`test`.`t1`.`c1_idx` = 'y') order by `test`.`t1`.`pk` desc limit 2 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t1 SET c2 = 0 WHERE c1_idx = 'y' ORDER BY pk DESC LIMIT 2;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_temporary_table": true, + "using_filesort": false, + "table": { + "update": true, + "table_name": "t1", + "access_type": "range", + "possible_keys": [ + "c1_idx" + ] /* possible_keys */, + "key": "c1_idx", + "used_key_parts": [ + "c1_idx" + ] /* used_key_parts */, + "key_length": "5", + "ref": [ + "const" + ] /* ref */, + "rows_examined_per_scan": 2, + "filtered": "100.00", + "backward_index_scan": true, + "attached_condition": "(`test`.`t1`.`c1_idx` = 'y')" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`c2` = 0 where (`test`.`t1`.`c1_idx` = 'y') order by `test`.`t1`.`pk` desc limit 2 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 WHERE c1_idx = 'y' ORDER BY pk DESC LIMIT 2;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.70" + } /* cost_info */, + "ordering_operation": { + "using_filesort": false, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 2, + "filtered": "100.00", + "backward_index_scan": true, + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.20", + "prefix_cost": "0.70", + "data_read_per_join": "48" + } /* cost_info */, + "used_columns": [ + "pk", + "c1_idx", + "c2" + ] /* used_columns */, + "ordering_operation": { + "using_filesort": false, + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "ref", + "possible_keys": [ + "c1_idx" + ] /* possible_keys */, + "key": "c1_idx", + "used_key_parts": [ + "c1_idx" + ] /* used_key_parts */, + "key_length": "5", + "ref": [ + "const" + ] /* ref */, + "rows_examined_per_scan": 2, + "rows_produced_per_join": 2, + "filtered": "100.00", + "backward_index_scan": true, + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.20", + "prefix_cost": "0.70", + "data_read_per_join": "32" + } /* cost_info */, + "used_columns": [ + "pk", + "c1_idx", + "c2" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`c1_idx` = 'y')" + } /* table */ + } /* ordering_operation */ + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`c1_idx` AS `c1_idx`,`test`.`t1`.`c2` AS `c2` from `test`.`t1` where (`test`.`t1`.`c1_idx` = 'y') order by `test`.`t1`.`pk` desc limit 2 +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 6 +Handler_read_rnd_next 2 +# Status of testing query execution: +Variable_name Value +Handler_read_key 6 +Handler_read_prev 1 +Handler_read_rnd 2 +Handler_update 2 + +# +# query: DELETE FROM t1 WHERE c1_idx = 'y' ORDER BY pk DESC LIMIT 2 +# select: SELECT * FROM t1 WHERE c1_idx = 'y' ORDER BY pk DESC LIMIT 2 +# +EXPLAIN DELETE FROM t1 WHERE c1_idx = 'y' ORDER BY pk DESC LIMIT 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL range c1_idx c1_idx 5 const 2 100.00 Using where; Backward index scan +Warnings: +Note 1003 delete from `test`.`t1` where (`test`.`t1`.`c1_idx` = 'y') order by `test`.`t1`.`pk` desc limit 2 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t1 WHERE c1_idx = 'y' ORDER BY pk DESC LIMIT 2;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_filesort": false, + "table": { + "delete": true, + "table_name": "t1", + "access_type": "range", + "possible_keys": [ + "c1_idx" + ] /* possible_keys */, + "key": "c1_idx", + "used_key_parts": [ + "c1_idx" + ] /* used_key_parts */, + "key_length": "5", + "ref": [ + "const" + ] /* ref */, + "rows_examined_per_scan": 2, + "filtered": "100.00", + "backward_index_scan": true, + "attached_condition": "(`test`.`t1`.`c1_idx` = 'y')" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 delete from `test`.`t1` where (`test`.`t1`.`c1_idx` = 'y') order by `test`.`t1`.`pk` desc limit 2 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 WHERE c1_idx = 'y' ORDER BY pk DESC LIMIT 2;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.70" + } /* cost_info */, + "ordering_operation": { + "using_filesort": false, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 2, + "filtered": "100.00", + "backward_index_scan": true, + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.20", + "prefix_cost": "0.70", + "data_read_per_join": "48" + } /* cost_info */, + "used_columns": [ + "pk", + "c1_idx", + "c2" + ] /* used_columns */, + "ordering_operation": { + "using_filesort": false, + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "ref", + "possible_keys": [ + "c1_idx" + ] /* possible_keys */, + "key": "c1_idx", + "used_key_parts": [ + "c1_idx" + ] /* used_key_parts */, + "key_length": "5", + "ref": [ + "const" + ] /* ref */, + "rows_examined_per_scan": 2, + "rows_produced_per_join": 2, + "filtered": "100.00", + "backward_index_scan": true, + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.20", + "prefix_cost": "0.70", + "data_read_per_join": "32" + } /* cost_info */, + "used_columns": [ + "pk", + "c1_idx", + "c2" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`c1_idx` = 'y')" + } /* table */ + } /* ordering_operation */ + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`c1_idx` AS `c1_idx`,`test`.`t1`.`c2` AS `c2` from `test`.`t1` where (`test`.`t1`.`c1_idx` = 'y') order by `test`.`t1`.`pk` desc limit 2 +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 6 +Handler_read_rnd_next 2 +# Status of testing query execution: +Variable_name Value +Handler_delete 2 +Handler_read_key 4 +Handler_read_prev 1 + +DROP TABLE t1; +#50 +CREATE TABLE t1 (a INT AUTO_INCREMENT PRIMARY KEY); +INSERT INTO t1 VALUES (),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(); +# +# query: UPDATE t1 SET a=a+10 WHERE a > 34 +# select: SELECT * FROM t1 WHERE a > 34 +# +EXPLAIN UPDATE t1 SET a=a+10 WHERE a > 34; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL range PRIMARY PRIMARY 4 const 2 100.00 Using where; Using temporary +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`a` = (`test`.`t1`.`a` + 10) where (`test`.`t1`.`a` > 34) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t1 SET a=a+10 WHERE a > 34;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "table": { + "update": true, + "table_name": "t1", + "access_type": "range", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "a" + ] /* used_key_parts */, + "key_length": "4", + "ref": [ + "const" + ] /* ref */, + "rows_examined_per_scan": 2, + "filtered": "100.00", + "using_temporary_table": "for update", + "attached_condition": "(`test`.`t1`.`a` > 34)" + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`a` = (`test`.`t1`.`a` + 10) where (`test`.`t1`.`a` > 34) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 WHERE a > 34;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.91" + } /* cost_info */, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 2, + "filtered": "100.00", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.71", + "eval_cost": "0.20", + "prefix_cost": "0.91", + "data_read_per_join": "32" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "query_block": { + "cost_info": { + "query_cost": "0.91" + } /* cost_info */, + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "range", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "a" + ] /* used_key_parts */, + "key_length": "4", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 2, + "filtered": "100.00", + "using_index": true, + "cost_info": { + "read_cost": "0.71", + "eval_cost": "0.20", + "prefix_cost": "0.91", + "data_read_per_join": "16" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`a` > 34)" + } /* table */ + } /* query_block */ + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` > 34) +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 3 +Handler_read_last 1 +Handler_read_rnd_next 3 +# Status of testing query execution: +Variable_name Value +Handler_read_key 4 +Handler_read_next 2 +Handler_read_rnd 2 +Handler_update 2 + +DROP TABLE t1; +#51 +CREATE TABLE t1 (c1 INT, c2 INT, c3 INT); +CREATE TABLE t2 (c1 INT, c2 INT); +INSERT INTO t1 VALUES (1, 1, 10), (2, 2, 20); +# +# query: UPDATE t1 LEFT JOIN t2 ON t1.c1 = t2.c1 SET t2.c2 = 10 +# select: SELECT * FROM t1 LEFT JOIN t2 ON t1.c1 = t2.c1 +# +EXPLAIN UPDATE t1 LEFT JOIN t2 ON t1.c1 = t2.c1 SET t2.c2 = 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 UPDATE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 update `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`c1` = `test`.`t1`.`c1`)) set `test`.`t2`.`c2` = 10 where true +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t1 LEFT JOIN t2 ON t1.c1 = t2.c1 SET t2.c2 = 10;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.90" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 2, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.20", + "prefix_cost": "0.45", + "data_read_per_join": "32" + } /* cost_info */, + "used_columns": [ + "c1" + ] /* used_columns */ + } /* table */ + }, + { + "table": { + "update": true, + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 2, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.20", + "prefix_cost": "0.90", + "data_read_per_join": "32" + } /* cost_info */, + "used_columns": [ + "c1", + "c2" + ] /* used_columns */, + "attached_condition": "(is_not_null_compl(t2), (`test`.`t2`.`c1` = `test`.`t1`.`c1`), true)" + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`c1` = `test`.`t1`.`c1`)) set `test`.`t2`.`c2` = 10 where true +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 LEFT JOIN t2 ON t1.c1 = t2.c1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.90" + } /* cost_info */, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 2, + "filtered": "100.00", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.20", + "prefix_cost": "0.45", + "data_read_per_join": "64" + } /* cost_info */, + "used_columns": [ + "c1", + "c2", + "c3", + "c1", + "c2" + ] /* used_columns */, + "query_block": { + "cost_info": { + "query_cost": "0.90" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 2, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.20", + "prefix_cost": "0.45", + "data_read_per_join": "32" + } /* cost_info */, + "used_columns": [ + "c1", + "c2", + "c3" + ] /* used_columns */ + } /* table */ + }, + { + "table": { + "select_id": 2, + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 2, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.20", + "prefix_cost": "0.90", + "data_read_per_join": "32" + } /* cost_info */, + "used_columns": [ + "c1", + "c2" + ] /* used_columns */, + "attached_condition": "(is_not_null_compl(t2), (`test`.`t2`.`c1` = `test`.`t1`.`c1`), true)" + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c1` AS `c1`,`test`.`t1`.`c2` AS `c2`,`test`.`t1`.`c3` AS `c3`,`test`.`t2`.`c1` AS `c1`,`test`.`t2`.`c2` AS `c2` from `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`c1` = `test`.`t1`.`c1`)) where true +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 2 +Handler_read_key 7 +Handler_read_rnd_next 4 +# Status of testing query execution: +Variable_name Value +Handler_read_first 3 +Handler_read_key 8 +Handler_read_rnd_next 5 + +# +# query: UPDATE t1 LEFT JOIN t2 ON t1.c1 = t2.c1 SET t2.c2 = 10 WHERE t1.c3 = 10 +# select: SELECT * FROM t1 LEFT JOIN t2 ON t1.c1 = t2.c1 WHERE t1.c3 = 10 +# +EXPLAIN UPDATE t1 LEFT JOIN t2 ON t1.c1 = t2.c1 SET t2.c2 = 10 WHERE t1.c3 = 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 UPDATE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 update `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`c1` = `test`.`t1`.`c1`)) set `test`.`t2`.`c2` = 10 where (`test`.`t1`.`c3` = 10) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t1 LEFT JOIN t2 ON t1.c1 = t2.c1 SET t2.c2 = 10 WHERE t1.c3 = 10;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.80" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 1, + "filtered": "50.00", + "cost_info": { + "read_cost": "0.35", + "eval_cost": "0.10", + "prefix_cost": "0.45", + "data_read_per_join": "16" + } /* cost_info */, + "used_columns": [ + "c1", + "c3" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`c3` = 10)" + } /* table */ + }, + { + "table": { + "update": true, + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.10", + "prefix_cost": "0.80", + "data_read_per_join": "16" + } /* cost_info */, + "used_columns": [ + "c1", + "c2" + ] /* used_columns */, + "attached_condition": "(is_not_null_compl(t2), (`test`.`t2`.`c1` = `test`.`t1`.`c1`), true)" + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`c1` = `test`.`t1`.`c1`)) set `test`.`t2`.`c2` = 10 where (`test`.`t1`.`c3` = 10) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 LEFT JOIN t2 ON t1.c1 = t2.c1 WHERE t1.c3 = 10;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.80" + } /* cost_info */, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 1, + "filtered": "50.00", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.35", + "eval_cost": "0.10", + "prefix_cost": "0.45", + "data_read_per_join": "32" + } /* cost_info */, + "used_columns": [ + "c1", + "c2", + "c3", + "c1", + "c2" + ] /* used_columns */, + "query_block": { + "cost_info": { + "query_cost": "0.80" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 1, + "filtered": "50.00", + "cost_info": { + "read_cost": "0.35", + "eval_cost": "0.10", + "prefix_cost": "0.45", + "data_read_per_join": "16" + } /* cost_info */, + "used_columns": [ + "c1", + "c2", + "c3" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`c3` = 10)" + } /* table */ + }, + { + "table": { + "select_id": 2, + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.10", + "prefix_cost": "0.80", + "data_read_per_join": "16" + } /* cost_info */, + "used_columns": [ + "c1", + "c2" + ] /* used_columns */, + "attached_condition": "(is_not_null_compl(t2), (`test`.`t2`.`c1` = `test`.`t1`.`c1`), true)" + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c1` AS `c1`,`test`.`t1`.`c2` AS `c2`,`test`.`t1`.`c3` AS `c3`,`test`.`t2`.`c1` AS `c1`,`test`.`t2`.`c2` AS `c2` from `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`c1` = `test`.`t1`.`c1`)) where (`test`.`t1`.`c3` = 10) +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 2 +Handler_read_key 7 +Handler_read_rnd_next 4 +# Status of testing query execution: +Variable_name Value +Handler_read_first 2 +Handler_read_key 7 +Handler_read_rnd_next 4 + +DROP TABLE t1, t2; +#52 +CREATE TABLE t1(f1 INT, f2 INT); +CREATE TABLE t2(f3 INT, f4 INT); +CREATE INDEX IDX ON t2(f3); +INSERT INTO t1 VALUES(1,0),(2,0); +INSERT INTO t2 VALUES(1,1),(2,2); +# +# query: UPDATE t1 SET t1.f2=(SELECT MAX(t2.f4) FROM t2 WHERE t2.f3=t1.f1) +# select: SELECT (SELECT MAX(t2.f4) FROM t2 WHERE t2.f3=t1.f1) FROM t1 +# +EXPLAIN UPDATE t1 SET t1.f2=(SELECT MAX(t2.f4) FROM t2 WHERE t2.f3=t1.f1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DEPENDENT SUBQUERY t2 NULL ref IDX IDX 5 test.t1.f1 1 100.00 NULL +Warnings: +Note 1276 Field or reference 'test.t1.f1' of SELECT #2 was resolved in SELECT #1 +Note 1003 update `test`.`t1` set `test`.`t1`.`f2` = (/* select#2 */ select max(`test`.`t2`.`f4`) from `test`.`t2` where (`test`.`t2`.`f3` = `test`.`t1`.`f1`)) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t1 SET t1.f2=(SELECT MAX(t2.f4) FROM t2 WHERE t2.f3=t1.f1);; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "table": { + "update": true, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "filtered": "100.00" + } /* table */, + "update_value_subqueries": [ + { + "dependent": true, + "cacheable": false, + "query_block": { + "select_id": 2, + "cost_info": { + "query_cost": "0.35" + } /* cost_info */, + "table": { + "table_name": "t2", + "access_type": "ref", + "possible_keys": [ + "IDX" + ] /* possible_keys */, + "key": "IDX", + "used_key_parts": [ + "f3" + ] /* used_key_parts */, + "key_length": "5", + "ref": [ + "test.t1.f1" + ] /* ref */, + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.10", + "prefix_cost": "0.35", + "data_read_per_join": "16" + } /* cost_info */, + "used_columns": [ + "f3", + "f4" + ] /* used_columns */ + } /* table */ + } /* query_block */ + } + ] /* update_value_subqueries */ + } /* query_block */ +} +Warnings: +Note 1276 Field or reference 'test.t1.f1' of SELECT #2 was resolved in SELECT #1 +Note 1003 update `test`.`t1` set `test`.`t1`.`f2` = (/* select#2 */ select max(`test`.`t2`.`f4`) from `test`.`t2` where (`test`.`t2`.`f3` = `test`.`t1`.`f1`)) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT (SELECT MAX(t2.f4) FROM t2 WHERE t2.f3=t1.f1) FROM t1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.45" + } /* cost_info */, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 2, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.20", + "prefix_cost": "0.45", + "data_read_per_join": "32" + } /* cost_info */, + "used_columns": [ + "f1" + ] /* used_columns */ + } /* table */, + "select_list_subqueries": [ + { + "dependent": true, + "cacheable": false, + "query_block": { + "select_id": 2, + "cost_info": { + "query_cost": "0.35" + } /* cost_info */, + "table": { + "table_name": "t2", + "access_type": "ref", + "possible_keys": [ + "IDX" + ] /* possible_keys */, + "key": "IDX", + "used_key_parts": [ + "f3" + ] /* used_key_parts */, + "key_length": "5", + "ref": [ + "test.t1.f1" + ] /* ref */, + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.10", + "prefix_cost": "0.35", + "data_read_per_join": "16" + } /* cost_info */, + "used_columns": [ + "f3", + "f4" + ] /* used_columns */ + } /* table */ + } /* query_block */ + } + ] /* select_list_subqueries */ + } /* query_block */ +} +Warnings: +Note 1276 Field or reference 'test.t1.f1' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select (/* select#2 */ select max(`test`.`t2`.`f4`) from `test`.`t2` where (`test`.`t2`.`f3` = `test`.`t1`.`f1`)) AS `(SELECT MAX(t2.f4) FROM t2 WHERE t2.f3=t1.f1)` from `test`.`t1` +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 7 +Handler_read_next 2 +Handler_read_rnd_next 3 +# Status of testing query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 7 +Handler_read_next 2 +Handler_read_rnd_next 3 +Handler_update 2 + +DROP TABLE t1, t2; +#55 +CREATE TABLE t1(a INT); +INSERT INTO t1 VALUES (1); +SET @a = NULL; +EXPLAIN DELETE FROM t1 WHERE (@a:= a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +Note 1003 delete from `test`.`t1` where (0 <> (@a:=`test`.`t1`.`a`)) +DROP TABLE t1; +#56 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +DELETE FROM t1 USING t1 WHERE uknown_column = 12345; +ERROR 42S22: Unknown column 'uknown_column' in 'where clause' +EXPLAIN DELETE FROM t1 USING t1 WHERE uknown_column = 12345; +ERROR 42S22: Unknown column 'uknown_column' in 'where clause' +DROP TABLE t1; +#57 +CREATE TABLE t1(f1 INT); +EXPLAIN UPDATE t1 SET f2=1 ORDER BY f2; +ERROR 42S22: Unknown column 'f2' in 'field list' +UPDATE t1 SET f2=1 ORDER BY f2; +ERROR 42S22: Unknown column 'f2' in 'field list' +DROP TABLE t1; +#59 +CREATE TABLE t1 ( a INT, KEY( a ) ); +INSERT INTO t1 VALUES (0), (1); +CREATE VIEW v1 AS SELECT t11.a, t12.a AS b FROM t1 t11, t1 t12; +SET SESSION sql_safe_updates = 1; +EXPLAIN UPDATE IGNORE v1 SET a = 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t11 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t12 NULL index NULL a 5 NULL 2 100.00 Using index +Warnings: +Note 1003 update ignore (`test`.`t1` `t11` join `test`.`t1` `t12`) set `t11`.`a` = 1 +UPDATE IGNORE v1 SET a = 1; +ERROR HY000: You are using safe update mode and you tried to update a table without a WHERE that uses a KEY column. +SET SESSION sql_safe_updates = DEFAULT; +DROP TABLE t1; +DROP VIEW v1; +#62 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (0), (1); +CREATE VIEW v1 AS SELECT t11.a, t12.a AS b FROM t1 t11, t1 t12; +# +# query: UPDATE v1 SET a = 1 WHERE a > 0 +# select: SELECT * FROM v1 WHERE a > 0 +# +EXPLAIN UPDATE v1 SET a = 1 WHERE a > 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t11 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t12 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 update (`test`.`t1` `t11` join `test`.`t1` `t12`) set `t11`.`a` = 1 where (`t11`.`a` > 0) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE v1 SET a = 1 WHERE a > 0;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.90" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "update": true, + "table_name": "t11", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 1, + "filtered": "50.00", + "cost_info": { + "read_cost": "0.35", + "eval_cost": "0.10", + "prefix_cost": "0.45", + "data_read_per_join": "8" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t11`.`a` > 0)" + } /* table */ + }, + { + "table": { + "table_name": "t12", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 2, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.20", + "prefix_cost": "0.90", + "data_read_per_join": "16" + } /* cost_info */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 update (`test`.`t1` `t11` join `test`.`t1` `t12`) set `test`.`t11`.`a` = 1 where (`test`.`t11`.`a` > 0) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM v1 WHERE a > 0;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.90" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "table_name": "t11", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 1, + "filtered": "50.00", + "cost_info": { + "read_cost": "0.35", + "eval_cost": "0.10", + "prefix_cost": "0.45", + "data_read_per_join": "8" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t11`.`a` > 0)" + } /* table */ + }, + { + "table": { + "table_name": "t12", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 2, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.20", + "prefix_cost": "0.90", + "data_read_per_join": "16" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t11`.`a` AS `a`,`test`.`t12`.`a` AS `b` from `test`.`t1` `t11` join `test`.`t1` `t12` where (`test`.`t11`.`a` > 0) +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 2 +Handler_read_key 3 +Handler_read_rnd_next 6 +# Status of testing query execution: +Variable_name Value +Handler_read_first 2 +Handler_read_key 4 +Handler_read_rnd 1 +Handler_read_rnd_next 8 +Handler_write 2 + +# +# query: UPDATE t1, v1 SET v1.a = 1 WHERE t1.a = v1.a +# select: SELECT * FROM t1, v1 WHERE t1.a = v1.a +# +EXPLAIN UPDATE t1, v1 SET v1.a = 1 WHERE t1.a = v1.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 UPDATE t11 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t12 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 update `test`.`t1` join `test`.`t1` `t11` join `test`.`t1` `t12` set `test`.`t11`.`a` = 1 where (`test`.`t11`.`a` = `test`.`t1`.`a`) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t1, v1 SET v1.a = 1 WHERE t1.a = v1.a;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.75" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 2, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.20", + "prefix_cost": "0.45", + "data_read_per_join": "16" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */ + } /* table */ + }, + { + "table": { + "update": true, + "table_name": "t11", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 2, + "filtered": "50.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.20", + "prefix_cost": "1.10", + "data_read_per_join": "16" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t11`.`a` = `test`.`t1`.`a`)" + } /* table */ + }, + { + "table": { + "table_name": "t12", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 4, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.40", + "prefix_cost": "1.75", + "data_read_per_join": "32" + } /* cost_info */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t1` join `test`.`t1` `t11` join `test`.`t1` `t12` set `test`.`t11`.`a` = 1 where (`test`.`t11`.`a` = `test`.`t1`.`a`) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1, v1 WHERE t1.a = v1.a;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.75" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 2, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.20", + "prefix_cost": "0.45", + "data_read_per_join": "16" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */ + } /* table */ + }, + { + "table": { + "table_name": "t11", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 2, + "filtered": "50.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.20", + "prefix_cost": "1.10", + "data_read_per_join": "16" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t11`.`a` = `test`.`t1`.`a`)" + } /* table */ + }, + { + "table": { + "table_name": "t12", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 4, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.40", + "prefix_cost": "1.75", + "data_read_per_join": "32" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t11`.`a` AS `a`,`test`.`t12`.`a` AS `b` from `test`.`t1` join `test`.`t1` `t11` join `test`.`t1` `t12` where (`test`.`t11`.`a` = `test`.`t1`.`a`) +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 3 +Handler_read_key 4 +Handler_read_rnd_next 9 +# Status of testing query execution: +Variable_name Value +Handler_read_first 5 +Handler_read_key 8 +Handler_read_rnd 2 +Handler_read_rnd_next 18 +Handler_update 1 +Handler_write 4 + +DROP TABLE t1; +DROP VIEW v1; +#63 +CREATE TABLE t1 (a INT, PRIMARY KEY(a)); +INSERT INTO t1 VALUES (1), (2), (3), (4), (5); +CREATE VIEW v1 (a) AS SELECT a FROM t1; +# +# query: DELETE FROM v1 WHERE a < 4 +# select: SELECT * FROM v1 WHERE a < 4 +# +EXPLAIN DELETE FROM v1 WHERE a < 4; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL range PRIMARY PRIMARY 4 const X 100.00 Using where +Warnings: +Note 1003 delete from (`test`.`t1`) where (`test`.`t1`.`a` < 4) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM v1 WHERE a < 4;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "table": { + "delete": true, + "table_name": "t1", + "access_type": "range", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "a" + ] /* used_key_parts */, + "key_length": "4", + "ref": [ + "const" + ] /* ref */, + "rows_examined_per_scan": "X", + "filtered": "X", + "attached_condition": "(`test`.`t1`.`a` < 4)" + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 delete from (`test`.`t1`) where (`test`.`t1`.`a` < 4) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM v1 WHERE a < 4;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "X" + } /* cost_info */, + "table": { + "table_name": "t1", + "access_type": "range", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "a" + ] /* used_key_parts */, + "key_length": "4", + "rows_examined_per_scan": "X", + "rows_produced_per_join": "X", + "filtered": "X", + "using_index": true, + "cost_info": { + "read_cost": "X", + "eval_cost": "X", + "prefix_cost": "X", + "data_read_per_join": "X" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`a` < 4)" + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` < 4) +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 2 +Handler_read_next 3 +# Status of testing query execution: +Variable_name Value +Handler_delete 3 +Handler_read_first 1 +Handler_read_key 2 +Handler_read_next 3 + +DROP TABLE t1; +DROP VIEW v1; +#64 +CREATE TABLE t1 (a INT, b INT, PRIMARY KEY(a)); +INSERT INTO t1 VALUES (1,2), (2,3), (3,4), (4,5), (5,10); +CREATE TABLE t2 (x INT); +INSERT INTO t2 VALUES (1), (2), (3), (4); +CREATE VIEW v1 (a,c) AS SELECT a, b+1 FROM t1; +# +# query: DELETE v1 FROM t2, v1 WHERE t2.x = v1.a +# select: SELECT * FROM t2, v1 WHERE t2.x = v1.a +# +EXPLAIN DELETE v1 FROM t2, v1 WHERE t2.x = v1.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +1 DELETE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.x 1 100.00 NULL +Warnings: +Note 1003 delete `test`.`t1` from `test`.`t2` join `test`.`t1` where (`test`.`t1`.`a` = `test`.`t2`.`x`) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE v1 FROM t2, v1 WHERE t2.x = v1.a;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "2.05" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 4, + "rows_produced_per_join": 4, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.40", + "prefix_cost": "0.65", + "data_read_per_join": "32" + } /* cost_info */, + "used_columns": [ + "x" + ] /* used_columns */, + "attached_condition": "(`test`.`t2`.`x` is not null)" + } /* table */ + }, + { + "table": { + "delete": true, + "table_name": "t1", + "access_type": "eq_ref", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "a" + ] /* used_key_parts */, + "key_length": "4", + "ref": [ + "test.t2.x" + ] /* ref */, + "rows_examined_per_scan": 1, + "rows_produced_per_join": 4, + "filtered": "100.00", + "cost_info": { + "read_cost": "1.00", + "eval_cost": "0.40", + "prefix_cost": "2.05", + "data_read_per_join": "64" + } /* cost_info */, + "used_columns": [ + "a", + "b" + ] /* used_columns */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 delete `test`.`t1` from `test`.`t2` join `test`.`t1` where (`test`.`t1`.`a` = `test`.`t2`.`x`) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t2, v1 WHERE t2.x = v1.a;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "2.05" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 4, + "rows_produced_per_join": 4, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.40", + "prefix_cost": "0.65", + "data_read_per_join": "32" + } /* cost_info */, + "used_columns": [ + "x" + ] /* used_columns */, + "attached_condition": "(`test`.`t2`.`x` is not null)" + } /* table */ + }, + { + "table": { + "table_name": "t1", + "access_type": "eq_ref", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "a" + ] /* used_key_parts */, + "key_length": "4", + "ref": [ + "test.t2.x" + ] /* ref */, + "rows_examined_per_scan": 1, + "rows_produced_per_join": 4, + "filtered": "100.00", + "cost_info": { + "read_cost": "1.00", + "eval_cost": "0.40", + "prefix_cost": "2.05", + "data_read_per_join": "64" + } /* cost_info */, + "used_columns": [ + "a", + "b" + ] /* used_columns */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`x` AS `x`,`test`.`t1`.`a` AS `a`,(`test`.`t1`.`b` + 1) AS `c` from `test`.`t2` join `test`.`t1` where (`test`.`t1`.`a` = `test`.`t2`.`x`) +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 8 +Handler_read_rnd_next 5 +# Status of testing query execution: +Variable_name Value +Handler_delete 4 +Handler_read_first 1 +Handler_read_key 12 +Handler_read_rnd 4 +Handler_read_rnd_next 5 + +DROP TABLE t1,t2; +DROP VIEW v1; +#65 +CREATE TABLE t1 (a INT, b INT, PRIMARY KEY(a)); +INSERT INTO t1 VALUES (1,2), (2,3), (3,4), (4,5), (5,10); +CREATE TABLE t2 (x INT); +INSERT INTO t2 VALUES (1), (2), (3), (4); +CREATE VIEW v1 (a,c) AS SELECT a, b+1 FROM t1; +# +# query: DELETE v1 FROM t2, v1 WHERE t2.x = v1.a +# select: SELECT * FROM t2, v1 WHERE t2.x = v1.a +# +EXPLAIN DELETE v1 FROM t2, v1 WHERE t2.x = v1.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +1 DELETE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.x 1 100.00 NULL +Warnings: +Note 1003 delete `test`.`t1` from `test`.`t2` join `test`.`t1` where (`test`.`t1`.`a` = `test`.`t2`.`x`) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE v1 FROM t2, v1 WHERE t2.x = v1.a;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "2.05" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 4, + "rows_produced_per_join": 4, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.40", + "prefix_cost": "0.65", + "data_read_per_join": "32" + } /* cost_info */, + "used_columns": [ + "x" + ] /* used_columns */, + "attached_condition": "(`test`.`t2`.`x` is not null)" + } /* table */ + }, + { + "table": { + "delete": true, + "table_name": "t1", + "access_type": "eq_ref", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "a" + ] /* used_key_parts */, + "key_length": "4", + "ref": [ + "test.t2.x" + ] /* ref */, + "rows_examined_per_scan": 1, + "rows_produced_per_join": 4, + "filtered": "100.00", + "cost_info": { + "read_cost": "1.00", + "eval_cost": "0.40", + "prefix_cost": "2.05", + "data_read_per_join": "64" + } /* cost_info */, + "used_columns": [ + "a", + "b" + ] /* used_columns */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 delete `test`.`t1` from `test`.`t2` join `test`.`t1` where (`test`.`t1`.`a` = `test`.`t2`.`x`) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t2, v1 WHERE t2.x = v1.a;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "2.05" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 4, + "rows_produced_per_join": 4, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.40", + "prefix_cost": "0.65", + "data_read_per_join": "32" + } /* cost_info */, + "used_columns": [ + "x" + ] /* used_columns */, + "attached_condition": "(`test`.`t2`.`x` is not null)" + } /* table */ + }, + { + "table": { + "table_name": "t1", + "access_type": "eq_ref", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "a" + ] /* used_key_parts */, + "key_length": "4", + "ref": [ + "test.t2.x" + ] /* ref */, + "rows_examined_per_scan": 1, + "rows_produced_per_join": 4, + "filtered": "100.00", + "cost_info": { + "read_cost": "1.00", + "eval_cost": "0.40", + "prefix_cost": "2.05", + "data_read_per_join": "64" + } /* cost_info */, + "used_columns": [ + "a", + "b" + ] /* used_columns */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`x` AS `x`,`test`.`t1`.`a` AS `a`,(`test`.`t1`.`b` + 1) AS `c` from `test`.`t2` join `test`.`t1` where (`test`.`t1`.`a` = `test`.`t2`.`x`) +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 8 +Handler_read_rnd_next 5 +# Status of testing query execution: +Variable_name Value +Handler_delete 4 +Handler_read_first 1 +Handler_read_key 12 +Handler_read_rnd 4 +Handler_read_rnd_next 5 + +DROP TABLE t1,t2; +DROP VIEW v1; +#66 +CREATE TABLE t1 (a INT); +CREATE VIEW v1 (x) AS SELECT a FROM t1; +# +# query: INSERT INTO v1 VALUES (10) +# select: SELECT NULL +# +EXPLAIN INSERT INTO v1 VALUES (10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 INSERT t1 NULL ALL NULL NULL NULL NULL NULL NULL NULL +Warnings: +Note 1003 insert into `test`.`t1` values (10) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON INSERT INTO v1 VALUES (10);; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "table": { + "insert": true, + "table_name": "t1", + "access_type": "ALL" + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 insert into `test`.`t1` values (10) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT NULL;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "message": "No tables used" + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select NULL AS `NULL` +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +# Status of testing query execution: +Variable_name Value +Handler_read_key 1 +Handler_write 1 + +DROP TABLE t1; +DROP VIEW v1; +#67 +CREATE TABLE t1 (a INT); +CREATE TABLE t2 (b INT); +INSERT INTO t2 VALUES (1), (2), (3); +CREATE VIEW v1 (x) AS SELECT b FROM t2; +# +# query: INSERT INTO v1 SELECT * FROM t1 +# select: SELECT * FROM t1 +# +EXPLAIN INSERT INTO v1 SELECT * FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 INSERT t2 NULL ALL NULL NULL NULL NULL NULL NULL NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 insert into `test`.`t2` /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON INSERT INTO v1 SELECT * FROM t1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.35" + } /* cost_info */, + "table": { + "insert": true, + "table_name": "t2", + "access_type": "ALL" + } /* table */, + "insert_from": { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.10", + "prefix_cost": "0.35", + "data_read_per_join": "8" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */ + } /* table */ + } /* insert_from */ + } /* query_block */ +} +Warnings: +Note 1003 insert into `test`.`t2` /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.35" + } /* cost_info */, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.10", + "prefix_cost": "0.35", + "data_read_per_join": "16" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "query_block": { + "cost_info": { + "query_cost": "0.35" + } /* cost_info */, + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.10", + "prefix_cost": "0.35", + "data_read_per_join": "8" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */ + } /* table */ + } /* query_block */ + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 2 +Handler_read_rnd_next 1 +# Status of testing query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 3 +Handler_read_rnd_next 1 + +DROP TABLE t1, t2; +DROP VIEW v1; +#69 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +CREATE TABLE t2 (b INT); +INSERT INTO t2 VALUES (1), (2), (3); +# +# query: UPDATE t1 SET a = 10 WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x) +# select: SELECT * FROM t1 WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x) +# +EXPLAIN UPDATE t1 SET a = 10 WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 PRIMARY NULL ref 5 test.t1.a 2 100.00 Using index; FirstMatch(t1) +3 DERIVED t2 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`a` = 10 where (`x`.`b` = `test`.`t1`.`a`) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t1 SET a = 10 WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x);; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "2.65" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "update": true, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.30", + "prefix_cost": "0.55", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`a` is not null)" + } /* table */ + }, + { + "table": { + "table_name": "x", + "access_type": "ref", + "possible_keys": [ + "" + ] /* possible_keys */, + "key": "", + "used_key_parts": [ + "b" + ] /* used_key_parts */, + "key_length": "5", + "ref": [ + "test.t1.a" + ] /* ref */, + "rows_examined_per_scan": 2, + "rows_produced_per_join": 3, + "filtered": "100.00", + "using_index": true, + "first_match": "t1", + "cost_info": { + "read_cost": "1.50", + "eval_cost": "0.30", + "prefix_cost": "2.65", + "data_read_per_join": "48" + } /* cost_info */, + "used_columns": [ + "b" + ] /* used_columns */, + "materialized_from_subquery": { + "using_temporary_table": true, + "dependent": false, + "cacheable": true, + "query_block": { + "select_id": 3, + "cost_info": { + "query_cost": "3.55" + } /* cost_info */, + "ordering_operation": { + "using_filesort": true, + "cost_info": { + "sort_cost": "3.00" + } /* cost_info */, + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.30", + "prefix_cost": "0.55", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "b" + ] /* used_columns */ + } /* table */ + } /* ordering_operation */ + } /* query_block */ + } /* materialized_from_subquery */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`a` = 10 where (`x`.`b` = `test`.`t1`.`a`) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x);; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "2.65" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.30", + "prefix_cost": "0.55", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`a` is not null)" + } /* table */ + }, + { + "table": { + "table_name": "x", + "access_type": "ref", + "possible_keys": [ + "" + ] /* possible_keys */, + "key": "", + "used_key_parts": [ + "b" + ] /* used_key_parts */, + "key_length": "5", + "ref": [ + "test.t1.a" + ] /* ref */, + "rows_examined_per_scan": 2, + "rows_produced_per_join": 3, + "filtered": "100.00", + "using_index": true, + "first_match": "t1", + "cost_info": { + "read_cost": "1.50", + "eval_cost": "0.30", + "prefix_cost": "2.65", + "data_read_per_join": "48" + } /* cost_info */, + "used_columns": [ + "b" + ] /* used_columns */, + "materialized_from_subquery": { + "using_temporary_table": true, + "dependent": false, + "cacheable": true, + "query_block": { + "select_id": 3, + "cost_info": { + "query_cost": "3.55" + } /* cost_info */, + "ordering_operation": { + "using_filesort": true, + "cost_info": { + "sort_cost": "3.00" + } /* cost_info */, + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.30", + "prefix_cost": "0.55", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "b" + ] /* used_columns */ + } /* table */ + } /* ordering_operation */ + } /* query_block */ + } /* materialized_from_subquery */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join ((/* select#3 */ select `test`.`t2`.`b` AS `b` from `test`.`t2` order by `test`.`t2`.`b` limit 2,2) `x`) where (`x`.`b` = `test`.`t1`.`a`) +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 2 +Handler_read_key 7 +Handler_read_rnd_next 8 +Handler_write 1 +Sort_rows 3 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_read_first 2 +Handler_read_key 7 +Handler_read_rnd_next 8 +Handler_update 1 +Handler_write 1 +Sort_rows 3 +Sort_scan 1 + +# +# query: UPDATE t1, t2 SET a = 10 WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x) +# select: SELECT * FROM t1, t2 WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x) +# +EXPLAIN UPDATE t1, t2 SET a = 10 WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 PRIMARY NULL ref 5 test.t1.a 2 100.00 Using index; FirstMatch(t1) +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +3 DERIVED t2 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 update `test`.`t1` join `test`.`t2` semi join ((/* select#3 */ select `test`.`t2`.`b` AS `b` from `test`.`t2` order by `test`.`t2`.`b` limit 2,2) `x`) set `test`.`t1`.`a` = 10 where (`x`.`b` = `test`.`t1`.`a`) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t1, t2 SET a = 10 WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x);; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "3.80" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "update": true, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.30", + "prefix_cost": "0.55", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`a` is not null)" + } /* table */ + }, + { + "table": { + "table_name": "x", + "access_type": "ref", + "possible_keys": [ + "" + ] /* possible_keys */, + "key": "", + "used_key_parts": [ + "b" + ] /* used_key_parts */, + "key_length": "5", + "ref": [ + "test.t1.a" + ] /* ref */, + "rows_examined_per_scan": 2, + "rows_produced_per_join": 3, + "filtered": "100.00", + "using_index": true, + "first_match": "t1", + "cost_info": { + "read_cost": "1.50", + "eval_cost": "0.30", + "prefix_cost": "2.65", + "data_read_per_join": "48" + } /* cost_info */, + "used_columns": [ + "b" + ] /* used_columns */, + "materialized_from_subquery": { + "using_temporary_table": true, + "dependent": false, + "cacheable": true, + "query_block": { + "select_id": 3, + "cost_info": { + "query_cost": "3.55" + } /* cost_info */, + "ordering_operation": { + "using_filesort": true, + "cost_info": { + "sort_cost": "3.00" + } /* cost_info */, + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.30", + "prefix_cost": "0.55", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "b" + ] /* used_columns */ + } /* table */ + } /* ordering_operation */ + } /* query_block */ + } /* materialized_from_subquery */ + } /* table */ + }, + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 9, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.90", + "prefix_cost": "3.80", + "data_read_per_join": "72" + } /* cost_info */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t1` join `test`.`t2` semi join ((/* select#3 */ select `test`.`t2`.`b` AS `b` from `test`.`t2` order by `test`.`t2`.`b` limit 2,2) `x`) set `test`.`t1`.`a` = 10 where (`x`.`b` = `test`.`t1`.`a`) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1, t2 WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x);; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "3.80" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.30", + "prefix_cost": "0.55", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`a` is not null)" + } /* table */ + }, + { + "table": { + "table_name": "x", + "access_type": "ref", + "possible_keys": [ + "" + ] /* possible_keys */, + "key": "", + "used_key_parts": [ + "b" + ] /* used_key_parts */, + "key_length": "5", + "ref": [ + "test.t1.a" + ] /* ref */, + "rows_examined_per_scan": 2, + "rows_produced_per_join": 3, + "filtered": "100.00", + "using_index": true, + "first_match": "t1", + "cost_info": { + "read_cost": "1.50", + "eval_cost": "0.30", + "prefix_cost": "2.65", + "data_read_per_join": "48" + } /* cost_info */, + "used_columns": [ + "b" + ] /* used_columns */, + "materialized_from_subquery": { + "using_temporary_table": true, + "dependent": false, + "cacheable": true, + "query_block": { + "select_id": 3, + "cost_info": { + "query_cost": "3.55" + } /* cost_info */, + "ordering_operation": { + "using_filesort": true, + "cost_info": { + "sort_cost": "3.00" + } /* cost_info */, + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.30", + "prefix_cost": "0.55", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "b" + ] /* used_columns */ + } /* table */ + } /* ordering_operation */ + } /* query_block */ + } /* materialized_from_subquery */ + } /* table */ + }, + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 9, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.90", + "prefix_cost": "3.80", + "data_read_per_join": "72" + } /* cost_info */, + "used_columns": [ + "b" + ] /* used_columns */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` join `test`.`t2` semi join ((/* select#3 */ select `test`.`t2`.`b` AS `b` from `test`.`t2` order by `test`.`t2`.`b` limit 2,2) `x`) where (`x`.`b` = `test`.`t1`.`a`) +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 2 +Handler_read_key 7 +Handler_read_rnd_next 8 +Handler_write 1 +Sort_rows 3 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_read_first 2 +Handler_read_key 7 +Handler_read_rnd_next 8 +Handler_write 1 +Sort_rows 3 +Sort_scan 1 + +# +# query: UPDATE t1, (SELECT * FROM t2) y SET a = 10 WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x) +# select: SELECT * FROM t1, (SELECT * FROM t2) y WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x) +# +EXPLAIN UPDATE t1, (SELECT * FROM t2) y SET a = 10 WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 PRIMARY NULL ref 5 test.t1.a 2 100.00 Using index; FirstMatch(t1) +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +4 DERIVED t2 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 update `test`.`t1` join `test`.`t2` semi join ((/* select#4 */ select `test`.`t2`.`b` AS `b` from `test`.`t2` order by `test`.`t2`.`b` limit 2,2) `x`) set `test`.`t1`.`a` = 10 where (`x`.`b` = `test`.`t1`.`a`) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t1, (SELECT * FROM t2) y SET a = 10 WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x);; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "3.80" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "update": true, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.30", + "prefix_cost": "0.55", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`a` is not null)" + } /* table */ + }, + { + "table": { + "table_name": "x", + "access_type": "ref", + "possible_keys": [ + "" + ] /* possible_keys */, + "key": "", + "used_key_parts": [ + "b" + ] /* used_key_parts */, + "key_length": "5", + "ref": [ + "test.t1.a" + ] /* ref */, + "rows_examined_per_scan": 2, + "rows_produced_per_join": 3, + "filtered": "100.00", + "using_index": true, + "first_match": "t1", + "cost_info": { + "read_cost": "1.50", + "eval_cost": "0.30", + "prefix_cost": "2.65", + "data_read_per_join": "48" + } /* cost_info */, + "used_columns": [ + "b" + ] /* used_columns */, + "materialized_from_subquery": { + "using_temporary_table": true, + "dependent": false, + "cacheable": true, + "query_block": { + "select_id": 4, + "cost_info": { + "query_cost": "3.55" + } /* cost_info */, + "ordering_operation": { + "using_filesort": true, + "cost_info": { + "sort_cost": "3.00" + } /* cost_info */, + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.30", + "prefix_cost": "0.55", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "b" + ] /* used_columns */ + } /* table */ + } /* ordering_operation */ + } /* query_block */ + } /* materialized_from_subquery */ + } /* table */ + }, + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 9, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.90", + "prefix_cost": "3.80", + "data_read_per_join": "72" + } /* cost_info */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t1` join `test`.`t2` semi join ((/* select#4 */ select `test`.`t2`.`b` AS `b` from `test`.`t2` order by `test`.`t2`.`b` limit 2,2) `x`) set `test`.`t1`.`a` = 10 where (`x`.`b` = `test`.`t1`.`a`) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1, (SELECT * FROM t2) y WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x);; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "3.80" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.30", + "prefix_cost": "0.55", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`a` is not null)" + } /* table */ + }, + { + "table": { + "table_name": "x", + "access_type": "ref", + "possible_keys": [ + "" + ] /* possible_keys */, + "key": "", + "used_key_parts": [ + "b" + ] /* used_key_parts */, + "key_length": "5", + "ref": [ + "test.t1.a" + ] /* ref */, + "rows_examined_per_scan": 2, + "rows_produced_per_join": 3, + "filtered": "100.00", + "using_index": true, + "first_match": "t1", + "cost_info": { + "read_cost": "1.50", + "eval_cost": "0.30", + "prefix_cost": "2.65", + "data_read_per_join": "48" + } /* cost_info */, + "used_columns": [ + "b" + ] /* used_columns */, + "materialized_from_subquery": { + "using_temporary_table": true, + "dependent": false, + "cacheable": true, + "query_block": { + "select_id": 4, + "cost_info": { + "query_cost": "3.55" + } /* cost_info */, + "ordering_operation": { + "using_filesort": true, + "cost_info": { + "sort_cost": "3.00" + } /* cost_info */, + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.30", + "prefix_cost": "0.55", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "b" + ] /* used_columns */ + } /* table */ + } /* ordering_operation */ + } /* query_block */ + } /* materialized_from_subquery */ + } /* table */ + }, + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 9, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.90", + "prefix_cost": "3.80", + "data_read_per_join": "72" + } /* cost_info */, + "used_columns": [ + "b" + ] /* used_columns */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` join `test`.`t2` semi join ((/* select#4 */ select `test`.`t2`.`b` AS `b` from `test`.`t2` order by `test`.`t2`.`b` limit 2,2) `x`) where (`x`.`b` = `test`.`t1`.`a`) +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 2 +Handler_read_key 7 +Handler_read_rnd_next 8 +Handler_write 1 +Sort_rows 3 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_read_first 2 +Handler_read_key 7 +Handler_read_rnd_next 8 +Handler_write 1 +Sort_rows 3 +Sort_scan 1 + +DROP TABLE t1,t2; +#70 +CREATE TABLE t1 (c1 INT KEY); +CREATE TABLE t2 (c2 INT); +CREATE TABLE t3 (c3 INT); +EXPLAIN UPDATE t3 SET c3 = ( +SELECT COUNT(d1.c1) +FROM ( +SELECT a11.c1 FROM t1 AS a11 +STRAIGHT_JOIN t2 AS a21 ON a21.c2 = a11.c1 +JOIN t1 AS a12 ON a12.c1 = a11.c1 +) d1 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t3 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SUBQUERY NULL ALL NULL NULL NULL NULL 2 100.00 NULL +3 DERIVED a11 NULL index PRIMARY PRIMARY 4 NULL 1 100.00 Using index +3 DERIVED a21 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +3 DERIVED a12 NULL eq_ref PRIMARY PRIMARY 4 test.a11.c1 1 100.00 Using index +Warnings: +Note 1003 update `test`.`t3` set `test`.`t3`.`c3` = (/* select#2 */ select count(`d1`.`c1`) from (/* select#3 */ select `test`.`a11`.`c1` AS `c1` from `test`.`t1` `a11` straight_join `test`.`t2` `a21` join `test`.`t1` `a12` where ((`test`.`a21`.`c2` = `test`.`a11`.`c1`) and (`test`.`a12`.`c1` = `test`.`a11`.`c1`))) `d1`) +DROP TABLE t1, t2, t3; +#71 +CREATE TABLE t1 (c1 INT NOT NULL, c2 INT NOT NULL, INDEX i1(c1)); +INSERT INTO t1 VALUES (1,0),(2,0),(3,0),(4,0),(5,0),(6,0),(7,0),(8,0); +CREATE TABLE t2 LIKE t1; +EXPLAIN INSERT INTO t2 SELECT * FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 INSERT t2 NULL ALL NULL NULL NULL NULL X NULL NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL X 100.00 NULL +Warnings: +Note 1003 insert into `test`.`t2` /* select#1 */ select `test`.`t1`.`c1` AS `c1`,`test`.`t1`.`c2` AS `c2` from `test`.`t1` +INSERT INTO t2 SELECT * FROM t1; +SELECT * FROM t1 LEFT JOIN t2 ON t1.c1 = t2.c1; +DROP TABLE t1, t2; +#73 +CREATE TABLE t1 (id INT); +CREATE TABLE t2 (id INT); +INSERT INTO t1 VALUES (1), (2); +EXPLAIN SELECT * FROM t1 LEFT JOIN t2 USING(id) GROUP BY t1.id; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using temporary +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id` from `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`id` = `test`.`t1`.`id`)) where true group by `test`.`t1`.`id` +DROP TABLE t1,t2; +#74 +CREATE TABLE t1(a INT PRIMARY KEY) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1), (2), (3), (4), (5); +# used key is modified & Using temporary +# +# query: UPDATE t1 SET a=a+1 WHERE a>10 +# select: SELECT a t1 FROM t1 WHERE a>10 +# +EXPLAIN UPDATE t1 SET a=a+1 WHERE a>10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL range PRIMARY PRIMARY 4 const 1 100.00 Using where; Using temporary +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`a` = (`test`.`t1`.`a` + 1) where (`test`.`t1`.`a` > 10) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t1 SET a=a+1 WHERE a>10;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "table": { + "update": true, + "table_name": "t1", + "access_type": "range", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "a" + ] /* used_key_parts */, + "key_length": "4", + "ref": [ + "const" + ] /* ref */, + "rows_examined_per_scan": 1, + "filtered": "100.00", + "using_temporary_table": "for update", + "attached_condition": "(`test`.`t1`.`a` > 10)" + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`a` = (`test`.`t1`.`a` + 1) where (`test`.`t1`.`a` > 10) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT a t1 FROM t1 WHERE a>10;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.46" + } /* cost_info */, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.36", + "eval_cost": "0.10", + "prefix_cost": "0.46", + "data_read_per_join": "16" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "query_block": { + "cost_info": { + "query_cost": "0.46" + } /* cost_info */, + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "range", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "a" + ] /* used_key_parts */, + "key_length": "4", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "using_index": true, + "cost_info": { + "read_cost": "0.36", + "eval_cost": "0.10", + "prefix_cost": "0.46", + "data_read_per_join": "8" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`a` > 10)" + } /* table */ + } /* query_block */ + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `t1` from `test`.`t1` where (`test`.`t1`.`a` > 10) +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 2 + +# used key is modified & Using filesort +# +# query: UPDATE t1 SET a=a+1 WHERE a>10 ORDER BY a+20 +# select: SELECT a t1 FROM t1 WHERE a>10 ORDER BY a+20 +# +EXPLAIN UPDATE t1 SET a=a+1 WHERE a>10 ORDER BY a+20; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL range PRIMARY PRIMARY 4 const 1 100.00 Using where; Using filesort +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`a` = (`test`.`t1`.`a` + 1) where (`test`.`t1`.`a` > 10) order by (`test`.`t1`.`a` + 20) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t1 SET a=a+1 WHERE a>10 ORDER BY a+20;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_filesort": true, + "table": { + "update": true, + "table_name": "t1", + "access_type": "range", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "a" + ] /* used_key_parts */, + "key_length": "4", + "ref": [ + "const" + ] /* ref */, + "rows_examined_per_scan": 1, + "filtered": "100.00", + "attached_condition": "(`test`.`t1`.`a` > 10)" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`a` = (`test`.`t1`.`a` + 1) where (`test`.`t1`.`a` > 10) order by (`test`.`t1`.`a` + 20) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT a t1 FROM t1 WHERE a>10 ORDER BY a+20;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.46" + } /* cost_info */, + "ordering_operation": { + "using_filesort": true, + "cost_info": { + "sort_cost": "1.00" + } /* cost_info */, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.36", + "eval_cost": "0.10", + "prefix_cost": "0.46", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "(t1.a + 20)", + "a" + ] /* used_columns */, + "ordering_operation": { + "using_filesort": true, + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "range", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "a" + ] /* used_key_parts */, + "key_length": "4", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "using_index": true, + "cost_info": { + "read_cost": "0.36", + "eval_cost": "0.10", + "prefix_cost": "0.46", + "data_read_per_join": "8" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`a` > 10)" + } /* table */ + } /* ordering_operation */ + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `t1` from `test`.`t1` where (`test`.`t1`.`a` > 10) order by `(t1.a + 20)` +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 1 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 2 +Sort_scan 1 + +DROP TABLE t1; +# +# Bug #12949629: CLIENT LOSES CONNECTION AFTER EXECUTING A PROCEDURE WITH +# EXPLAIN UPDATE/DEL/INS +# +CREATE TABLE t1 (i INT); +CREATE TABLE t2 (i INT); +CREATE PROCEDURE p1() BEGIN EXPLAIN INSERT INTO t1 VALUES (1);END| +CREATE PROCEDURE p2() BEGIN INSERT INTO t1 VALUES (1);END| +CREATE PROCEDURE p3() BEGIN EXPLAIN INSERT INTO t1 SELECT 1;END| +CREATE PROCEDURE p4() BEGIN INSERT INTO t1 SELECT 1;END| +CREATE PROCEDURE p5() BEGIN EXPLAIN REPLACE INTO t1 VALUES (1);END| +CREATE PROCEDURE p6() BEGIN REPLACE INTO t1 VALUES (1);END| +CREATE PROCEDURE p7() BEGIN EXPLAIN REPLACE INTO t1 SELECT 1;END| +CREATE PROCEDURE p8() BEGIN REPLACE INTO t1 SELECT 1;END| +CREATE PROCEDURE p9() BEGIN EXPLAIN UPDATE t1 SET i = 10;END| +CREATE PROCEDURE p10() BEGIN UPDATE t1 SET i = 10;END| +CREATE PROCEDURE p11() BEGIN EXPLAIN UPDATE t1,t2 SET t1.i = 10 WHERE t1.i = t2.i ;END| +CREATE PROCEDURE p12() BEGIN UPDATE t1,t2 SET t1.i = 10 WHERE t1.i = t2.i ;END| +CREATE PROCEDURE p13() BEGIN +# Disabling binary logging temporarily as optimized delete is not used when log-bin is enabled in row mode +SET @save_log_bin= @@sql_log_bin;SET SQL_LOG_BIN=0; +EXPLAIN DELETE FROM t1; +SET SQL_LOG_BIN=@save_log_bin; END| +CREATE PROCEDURE p14() BEGIN DELETE FROM t1;END| +CREATE PROCEDURE p15() BEGIN EXPLAIN DELETE FROM t1 USING t1;END| +CREATE PROCEDURE p16() BEGIN DELETE FROM t1 USING t1;END| +CALL p16(); +DROP PROCEDURE p16; +CALL p15(); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 delete `test`.`t1` from `test`.`t1` +DROP PROCEDURE p15; +CALL p14(); +DROP PROCEDURE p14; +CALL p13(); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Deleting all rows +DROP PROCEDURE p13; +CALL p12(); +DROP PROCEDURE p12; +CALL p11(); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 update `test`.`t1` join `test`.`t2` set `test`.`t1`.`i` = 10 where (`test`.`t2`.`i` = `test`.`t1`.`i`) +DROP PROCEDURE p11; +CALL p10(); +DROP PROCEDURE p10; +CALL p9(); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`i` = 10 +DROP PROCEDURE p9; +CALL p8(); +DROP PROCEDURE p8; +CALL p7(); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 REPLACE t1 NULL ALL NULL NULL NULL NULL NULL NULL NULL +Warnings: +Note 1003 replace into `test`.`t1` /* select#1 */ select 1 AS `1` from dual +DROP PROCEDURE p7; +CALL p6(); +DROP PROCEDURE p6; +CALL p5(); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 REPLACE t1 NULL ALL NULL NULL NULL NULL NULL NULL NULL +Warnings: +Note 1003 replace into `test`.`t1` values (1) +DROP PROCEDURE p5; +CALL p4(); +DROP PROCEDURE p4; +CALL p3(); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 INSERT t1 NULL ALL NULL NULL NULL NULL NULL NULL NULL +Warnings: +Note 1003 insert into `test`.`t1` /* select#1 */ select 1 AS `1` from dual +DROP PROCEDURE p3; +CALL p2(); +DROP PROCEDURE p2; +CALL p1(); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 INSERT t1 NULL ALL NULL NULL NULL NULL NULL NULL NULL +Warnings: +Note 1003 insert into `test`.`t1` values (1) +DROP PROCEDURE p1; +DROP TABLE t1, t2; +# +set default_storage_engine= @save_storage_engine; +set optimizer_switch=default; diff --git a/mysql-test/r/innodb_explain_json_non_select_none.result-pq b/mysql-test/r/innodb_explain_json_non_select_none.result-pq new file mode 100644 index 000000000000..0f4a3613f5c2 --- /dev/null +++ b/mysql-test/r/innodb_explain_json_non_select_none.result-pq @@ -0,0 +1,9409 @@ +set @save_storage_engine= @@session.default_storage_engine; +set session default_storage_engine = InnoDB; +set end_markers_in_json=on; +#1 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +# +# query: UPDATE t1 SET a = 10 WHERE a < 10 +# select: SELECT * FROM t1 WHERE a < 10 +# +EXPLAIN UPDATE t1 SET a = 10 WHERE a < 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`a` = 10 where (`test`.`t1`.`a` < 10) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t1 SET a = 10 WHERE a < 10;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "table": { + "update": true, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "filtered": "100.00", + "attached_condition": "(`test`.`t1`.`a` < 10)" + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`a` = 10 where (`test`.`t1`.`a` < 10) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 WHERE a < 10;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.55" + } /* cost_info */, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 1, + "filtered": "33.33", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.45", + "eval_cost": "0.10", + "prefix_cost": "0.55", + "data_read_per_join": "16" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "query_block": { + "cost_info": { + "query_cost": "0.55" + } /* cost_info */, + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 1, + "filtered": "33.33", + "cost_info": { + "read_cost": "0.45", + "eval_cost": "0.10", + "prefix_cost": "0.55", + "data_read_per_join": "8" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`a` < 10)" + } /* table */ + } /* query_block */ + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` < 10) +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 2 +Handler_read_rnd_next 4 +# Status of testing query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 2 +Handler_read_rnd_next 4 +Handler_update 3 + +DROP TABLE t1; +#2 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +# +# query: DELETE FROM t1 WHERE a < 10 +# select: SELECT * FROM t1 WHERE a < 10 +# +EXPLAIN DELETE FROM t1 WHERE a < 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 delete from `test`.`t1` where (`test`.`t1`.`a` < 10) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t1 WHERE a < 10;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "table": { + "delete": true, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "filtered": "100.00", + "attached_condition": "(`test`.`t1`.`a` < 10)" + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 delete from `test`.`t1` where (`test`.`t1`.`a` < 10) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 WHERE a < 10;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.55" + } /* cost_info */, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 1, + "filtered": "33.33", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.45", + "eval_cost": "0.10", + "prefix_cost": "0.55", + "data_read_per_join": "16" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "query_block": { + "cost_info": { + "query_cost": "0.55" + } /* cost_info */, + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 1, + "filtered": "33.33", + "cost_info": { + "read_cost": "0.45", + "eval_cost": "0.10", + "prefix_cost": "0.55", + "data_read_per_join": "8" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`a` < 10)" + } /* table */ + } /* query_block */ + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` < 10) +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 2 +Handler_read_rnd_next 4 +# Status of testing query execution: +Variable_name Value +Handler_delete 3 +Handler_read_first 1 +Handler_read_key 2 +Handler_read_rnd_next 4 + +DROP TABLE t1; +#3 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +# +# query: DELETE FROM t1 USING t1 WHERE a = 1 +# select: SELECT * FROM t1 WHERE a = 1 +# +EXPLAIN DELETE FROM t1 USING t1 WHERE a = 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 delete `test`.`t1` from `test`.`t1` where (`test`.`t1`.`a` = 1) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t1 USING t1 WHERE a = 1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.55" + } /* cost_info */, + "table": { + "delete": true, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 1, + "filtered": "33.33", + "cost_info": { + "read_cost": "0.45", + "eval_cost": "0.10", + "prefix_cost": "0.55", + "data_read_per_join": "8" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`a` = 1)" + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 delete `test`.`t1` from `test`.`t1` where (`test`.`t1`.`a` = 1) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 WHERE a = 1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.55" + } /* cost_info */, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 1, + "filtered": "33.33", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.45", + "eval_cost": "0.10", + "prefix_cost": "0.55", + "data_read_per_join": "16" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "query_block": { + "cost_info": { + "query_cost": "0.55" + } /* cost_info */, + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 1, + "filtered": "33.33", + "cost_info": { + "read_cost": "0.45", + "eval_cost": "0.10", + "prefix_cost": "0.55", + "data_read_per_join": "8" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`a` = 1)" + } /* table */ + } /* query_block */ + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` = 1) +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 2 +Handler_read_rnd_next 4 +# Status of testing query execution: +Variable_name Value +Handler_delete 1 +Handler_read_first 1 +Handler_read_key 2 +Handler_read_rnd_next 4 + +DROP TABLE t1; +#4 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +CREATE TABLE t2 (b INT); +INSERT INTO t2 VALUES (1), (2), (3); +# +# query: UPDATE t1, t2 SET t1.a = 10 WHERE t1.a = 1 +# select: SELECT * FROM t1, t2 WHERE t1.a = 1 +# +EXPLAIN UPDATE t1, t2 SET t1.a = 10 WHERE t1.a = 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 update `test`.`t1` join `test`.`t2` set `test`.`t1`.`a` = 10 where (`test`.`t1`.`a` = 1) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t1, t2 SET t1.a = 10 WHERE t1.a = 1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.10" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "update": true, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 1, + "filtered": "33.33", + "cost_info": { + "read_cost": "0.45", + "eval_cost": "0.10", + "prefix_cost": "0.55", + "data_read_per_join": "8" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`a` = 1)" + } /* table */ + }, + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.30", + "prefix_cost": "1.10", + "data_read_per_join": "24" + } /* cost_info */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t1` join `test`.`t2` set `test`.`t1`.`a` = 10 where (`test`.`t1`.`a` = 1) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1, t2 WHERE t1.a = 1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.10" + } /* cost_info */, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 1, + "filtered": "33.33", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.45", + "eval_cost": "0.10", + "prefix_cost": "0.55", + "data_read_per_join": "16" + } /* cost_info */, + "used_columns": [ + "a", + "b" + ] /* used_columns */, + "query_block": { + "cost_info": { + "query_cost": "1.10" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 1, + "filtered": "33.33", + "cost_info": { + "read_cost": "0.45", + "eval_cost": "0.10", + "prefix_cost": "0.55", + "data_read_per_join": "8" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`a` = 1)" + } /* table */ + }, + { + "table": { + "select_id": 2, + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.30", + "prefix_cost": "1.10", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "b" + ] /* used_columns */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` join `test`.`t2` where (`test`.`t1`.`a` = 1) +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 2 +Handler_read_key 4 +Handler_read_rnd_next 8 +# Status of testing query execution: +Variable_name Value +Handler_read_first 2 +Handler_read_key 4 +Handler_read_rnd_next 8 +Handler_update 1 + +DROP TABLE t1, t2; +#5 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +CREATE TABLE t2 (b INT); +INSERT INTO t2 VALUES (1), (2), (3); +# +# query: UPDATE t1 t11, (SELECT * FROM t2) t12 SET t11.a = 10 WHERE t11.a = 1 +# select: SELECT * FROM t1 t11, (SELECT * FROM t2) t12 WHERE t11.a = 1 +# +EXPLAIN UPDATE t1 t11, (SELECT * FROM t2) t12 SET t11.a = 10 WHERE t11.a = 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t11 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 update `test`.`t1` `t11` join `test`.`t2` set `test`.`t11`.`a` = 10 where (`test`.`t11`.`a` = 1) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t1 t11, (SELECT * FROM t2) t12 SET t11.a = 10 WHERE t11.a = 1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.10" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "update": true, + "table_name": "t11", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 1, + "filtered": "33.33", + "cost_info": { + "read_cost": "0.45", + "eval_cost": "0.10", + "prefix_cost": "0.55", + "data_read_per_join": "8" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t11`.`a` = 1)" + } /* table */ + }, + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.30", + "prefix_cost": "1.10", + "data_read_per_join": "24" + } /* cost_info */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t1` `t11` join `test`.`t2` set `test`.`t11`.`a` = 10 where (`test`.`t11`.`a` = 1) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 t11, (SELECT * FROM t2) t12 WHERE t11.a = 1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.10" + } /* cost_info */, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 1, + "filtered": "33.33", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.45", + "eval_cost": "0.10", + "prefix_cost": "0.55", + "data_read_per_join": "16" + } /* cost_info */, + "used_columns": [ + "a", + "b" + ] /* used_columns */, + "query_block": { + "cost_info": { + "query_cost": "1.10" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "select_id": 2, + "table_name": "t11", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 1, + "filtered": "33.33", + "cost_info": { + "read_cost": "0.45", + "eval_cost": "0.10", + "prefix_cost": "0.55", + "data_read_per_join": "8" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t11`.`a` = 1)" + } /* table */ + }, + { + "table": { + "select_id": 2, + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.30", + "prefix_cost": "1.10", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "b" + ] /* used_columns */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t11`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` `t11` join `test`.`t2` where (`test`.`t11`.`a` = 1) +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 2 +Handler_read_key 4 +Handler_read_rnd_next 8 +# Status of testing query execution: +Variable_name Value +Handler_read_first 2 +Handler_read_key 4 +Handler_read_rnd_next 8 +Handler_update 1 + +DROP TABLE t1, t2; +#6 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +CREATE TABLE t2 (b INT); +INSERT INTO t2 VALUES (1), (2), (3); +# +# query: UPDATE t1 SET a = 10 WHERE 1 IN (SELECT 1 FROM t2 WHERE t2.b < 3) +# select: SELECT * FROM t1 WHERE 1 IN (SELECT 1 FROM t2 WHERE t2.b < 3) +# +EXPLAIN UPDATE t1 SET a = 10 WHERE 1 IN (SELECT 1 FROM t2 WHERE t2.b < 3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 SUBQUERY t2 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`a` = 10 where (1,(/* select#2 */ select 1 from `test`.`t2` where (`test`.`t2`.`b` < 3))) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t1 SET a = 10 WHERE 1 IN (SELECT 1 FROM t2 WHERE t2.b < 3);; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "table": { + "update": true, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "filtered": "100.00", + "attached_subqueries": [ + { + "dependent": false, + "cacheable": true, + "query_block": { + "select_id": 2, + "cost_info": { + "query_cost": "0.55" + } /* cost_info */, + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 1, + "filtered": "33.33", + "cost_info": { + "read_cost": "0.45", + "eval_cost": "0.10", + "prefix_cost": "0.55", + "data_read_per_join": "8" + } /* cost_info */, + "used_columns": [ + "b" + ] /* used_columns */, + "attached_condition": "(`test`.`t2`.`b` < 3)" + } /* table */ + } /* query_block */ + } + ] /* attached_subqueries */ + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`a` = 10 where (1,(/* select#2 */ select 1 from `test`.`t2` where (`test`.`t2`.`b` < 3))) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 WHERE 1 IN (SELECT 1 FROM t2 WHERE t2.b < 3);; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.55" + } /* cost_info */, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.30", + "prefix_cost": "0.55", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */ + } /* table */, + "optimized_away_subqueries": [ + { + "dependent": false, + "cacheable": true, + "query_block": { + "select_id": 2, + "cost_info": { + "query_cost": "0.55" + } /* cost_info */, + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 1, + "filtered": "33.33", + "cost_info": { + "read_cost": "0.45", + "eval_cost": "0.10", + "prefix_cost": "0.55", + "data_read_per_join": "8" + } /* cost_info */, + "used_columns": [ + "b" + ] /* used_columns */, + "attached_condition": "(`test`.`t2`.`b` < 3)" + } /* table */ + } /* query_block */ + } + ] /* optimized_away_subqueries */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where true +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 2 +Handler_read_key 4 +Handler_read_rnd_next 5 +# Status of testing query execution: +Variable_name Value +Handler_read_first 2 +Handler_read_key 4 +Handler_read_rnd_next 5 +Handler_update 3 + +DROP TABLE t1, t2; +#7 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +CREATE TABLE t2 (b INT); +INSERT INTO t2 VALUES (1), (2), (3); +# +# query: UPDATE t1 SET a = 10 WHERE a IN (SELECT b FROM t2 WHERE t1.a < 3) +# select: SELECT * FROM t1 WHERE a IN (SELECT b FROM t2 WHERE t1.a < 3) +# +EXPLAIN UPDATE t1 SET a = 10 WHERE a IN (SELECT b FROM t2 WHERE t1.a < 3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 update `test`.`t1` set `test`.`t1`.`a` = 10 where (`test`.`t1`.`a`,(/* select#2 */ select `test`.`t2`.`b` from `test`.`t2` where ((`test`.`t1`.`a` < 3) and ((`test`.`t1`.`a`) = `test`.`t2`.`b`)))) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t1 SET a = 10 WHERE a IN (SELECT b FROM t2 WHERE t1.a < 3);; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "table": { + "update": true, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "filtered": "100.00", + "attached_condition": "(`test`.`t1`.`a`,(/* select#2 */ select `test`.`t2`.`b` from `test`.`t2` where ((`test`.`t1`.`a` < 3) and ((`test`.`t1`.`a`) = `test`.`t2`.`b`))))", + "attached_subqueries": [ + { + "dependent": true, + "cacheable": false, + "query_block": { + "select_id": 2, + "cost_info": { + "query_cost": "0.55" + } /* cost_info */, + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 1, + "filtered": "33.33", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.10", + "prefix_cost": "0.55", + "data_read_per_join": "8" + } /* cost_info */, + "used_columns": [ + "b" + ] /* used_columns */, + "attached_condition": "((`test`.`t1`.`a` < 3) and ((`test`.`t1`.`a`) = `test`.`t2`.`b`))" + } /* table */ + } /* query_block */ + } + ] /* attached_subqueries */ + } /* table */ + } /* query_block */ +} +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 update `test`.`t1` set `test`.`t1`.`a` = 10 where (`test`.`t1`.`a`,(/* select#2 */ select `test`.`t2`.`b` from `test`.`t2` where ((`test`.`t1`.`a` < 3) and ((`test`.`t1`.`a`) = `test`.`t2`.`b`)))) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 WHERE a IN (SELECT b FROM t2 WHERE t1.a < 3);; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.55" + } /* cost_info */, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.30", + "prefix_cost": "0.55", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`a`,(/* select#2 */ select `test`.`t2`.`b` from `test`.`t2` where ((`test`.`t1`.`a` < 3) and ((`test`.`t1`.`a`) = `test`.`t2`.`b`))))", + "attached_subqueries": [ + { + "dependent": true, + "cacheable": false, + "query_block": { + "select_id": 2, + "cost_info": { + "query_cost": "0.55" + } /* cost_info */, + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 1, + "filtered": "33.33", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.10", + "prefix_cost": "0.55", + "data_read_per_join": "8" + } /* cost_info */, + "used_columns": [ + "b" + ] /* used_columns */, + "attached_condition": "((`test`.`t1`.`a` < 3) and ((`test`.`t1`.`a`) = `test`.`t2`.`b`))" + } /* table */ + } /* query_block */ + } + ] /* attached_subqueries */ + } /* table */ + } /* query_block */ +} +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a`,(/* select#2 */ select `test`.`t2`.`b` from `test`.`t2` where ((`test`.`t1`.`a` < 3) and ((`test`.`t1`.`a`) = `test`.`t2`.`b`)))) +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 4 +Handler_read_key 6 +Handler_read_rnd_next 11 +# Status of testing query execution: +Variable_name Value +Handler_read_first 4 +Handler_read_key 6 +Handler_read_rnd_next 11 +Handler_update 2 + +DROP TABLE t1, t2; +#7 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +CREATE TABLE t2 (b INT); +INSERT INTO t2 VALUES (1), (2), (3); +# +# query: UPDATE t1, t2 SET a = 10 WHERE a IN (SELECT b FROM t2 WHERE t2.b < 3) +# select: SELECT * FROM t1, t2 WHERE a IN (SELECT b FROM t2 WHERE t2.b < 3) +# +EXPLAIN UPDATE t1, t2 SET a = 10 WHERE a IN (SELECT b FROM t2 WHERE t2.b < 3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 update `test`.`t1` join `test`.`t2` set `test`.`t1`.`a` = 10 where (`test`.`t1`.`a`,(/* select#2 */ select `test`.`t2`.`b` from `test`.`t2` where ((`test`.`t2`.`b` < 3) and ((`test`.`t1`.`a`) = `test`.`t2`.`b`)))) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t1, t2 SET a = 10 WHERE a IN (SELECT b FROM t2 WHERE t2.b < 3);; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.70" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "update": true, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.30", + "prefix_cost": "0.55", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`a`,(/* select#2 */ select `test`.`t2`.`b` from `test`.`t2` where ((`test`.`t2`.`b` < 3) and ((`test`.`t1`.`a`) = `test`.`t2`.`b`))))", + "attached_subqueries": [ + { + "dependent": true, + "cacheable": false, + "query_block": { + "select_id": 2, + "cost_info": { + "query_cost": "0.55" + } /* cost_info */, + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 1, + "filtered": "33.33", + "cost_info": { + "read_cost": "0.45", + "eval_cost": "0.10", + "prefix_cost": "0.55", + "data_read_per_join": "8" + } /* cost_info */, + "used_columns": [ + "b" + ] /* used_columns */, + "attached_condition": "((`test`.`t2`.`b` < 3) and ((`test`.`t1`.`a`) = `test`.`t2`.`b`))" + } /* table */ + } /* query_block */ + } + ] /* attached_subqueries */ + } /* table */ + }, + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 9, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.90", + "prefix_cost": "1.70", + "data_read_per_join": "72" + } /* cost_info */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t1` join `test`.`t2` set `test`.`t1`.`a` = 10 where (`test`.`t1`.`a`,(/* select#2 */ select `test`.`t2`.`b` from `test`.`t2` where ((`test`.`t2`.`b` < 3) and ((`test`.`t1`.`a`) = `test`.`t2`.`b`)))) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1, t2 WHERE a IN (SELECT b FROM t2 WHERE t2.b < 3);; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.70" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.30", + "prefix_cost": "0.55", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`a`,(/* select#2 */ select `test`.`t2`.`b` from `test`.`t2` where ((`test`.`t2`.`b` < 3) and ((`test`.`t1`.`a`) = `test`.`t2`.`b`))))", + "attached_subqueries": [ + { + "dependent": true, + "cacheable": false, + "query_block": { + "select_id": 2, + "cost_info": { + "query_cost": "0.55" + } /* cost_info */, + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 1, + "filtered": "33.33", + "cost_info": { + "read_cost": "0.45", + "eval_cost": "0.10", + "prefix_cost": "0.55", + "data_read_per_join": "8" + } /* cost_info */, + "used_columns": [ + "b" + ] /* used_columns */, + "attached_condition": "((`test`.`t2`.`b` < 3) and ((`test`.`t1`.`a`) = `test`.`t2`.`b`))" + } /* table */ + } /* query_block */ + } + ] /* attached_subqueries */ + } /* table */ + }, + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 9, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.90", + "prefix_cost": "1.70", + "data_read_per_join": "72" + } /* cost_info */, + "used_columns": [ + "b" + ] /* used_columns */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` join `test`.`t2` where (`test`.`t1`.`a`,(/* select#2 */ select `test`.`t2`.`b` from `test`.`t2` where ((`test`.`t2`.`b` < 3) and ((`test`.`t1`.`a`) = `test`.`t2`.`b`)))) +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 5 +Handler_read_key 7 +Handler_read_rnd_next 15 +# Status of testing query execution: +Variable_name Value +Handler_read_first 6 +Handler_read_key 8 +Handler_read_rnd_next 19 +Handler_update 2 + +DROP TABLE t1, t2; +#8 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +CREATE TABLE t2 (b INT); +INSERT INTO t2 VALUES (1), (2), (3); +# +# query: UPDATE t1 t11, (SELECT * FROM t2) t12 SET t11.a = t11.a + 10 +# select: SELECT * FROM t1 t11, (SELECT * FROM t2) t12 +# +EXPLAIN UPDATE t1 t11, (SELECT * FROM t2) t12 SET t11.a = t11.a + 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t11 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 update `test`.`t1` `t11` join `test`.`t2` set `test`.`t11`.`a` = (`test`.`t11`.`a` + 10) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t1 t11, (SELECT * FROM t2) t12 SET t11.a = t11.a + 10;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.70" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "update": true, + "table_name": "t11", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.30", + "prefix_cost": "0.55", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */ + } /* table */ + }, + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 9, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.90", + "prefix_cost": "1.70", + "data_read_per_join": "72" + } /* cost_info */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t1` `t11` join `test`.`t2` set `test`.`t11`.`a` = (`test`.`t11`.`a` + 10) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 t11, (SELECT * FROM t2) t12;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.70" + } /* cost_info */, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.30", + "prefix_cost": "0.55", + "data_read_per_join": "48" + } /* cost_info */, + "used_columns": [ + "a", + "b" + ] /* used_columns */, + "query_block": { + "cost_info": { + "query_cost": "1.70" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "select_id": 2, + "table_name": "t11", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.30", + "prefix_cost": "0.55", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */ + } /* table */ + }, + { + "table": { + "select_id": 2, + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 9, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.90", + "prefix_cost": "1.70", + "data_read_per_join": "72" + } /* cost_info */, + "used_columns": [ + "b" + ] /* used_columns */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t11`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` `t11` join `test`.`t2` +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 2 +Handler_read_key 4 +Handler_read_rnd_next 8 +# Status of testing query execution: +Variable_name Value +Handler_read_first 4 +Handler_read_key 6 +Handler_read_rnd_next 16 +Handler_update 3 + +DROP TABLE t1, t2; +#9 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +CREATE TABLE t2 (b INT); +INSERT INTO t2 VALUES (1), (2), (3); +# +# query: UPDATE t1 t11, (SELECT 1 FROM DUAL) t12 SET t11.a = t11.a + 10 +# select: SELECT * FROM t1 t11, (SELECT 1 FROM DUAL) t12 +# +EXPLAIN UPDATE t1 t11, (SELECT 1 FROM DUAL) t12 SET t11.a = t11.a + 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL system NULL NULL NULL NULL 1 100.00 NULL +1 UPDATE t11 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 update `test`.`t1` `t11` join (/* select#2 */ select 1 AS `1`) `t12` set `test`.`t11`.`a` = (`test`.`t11`.`a` + 10) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t1 t11, (SELECT 1 FROM DUAL) t12 SET t11.a = t11.a + 10;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.55" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "table_name": "t12", + "access_type": "system", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.00", + "eval_cost": "0.10", + "prefix_cost": "0.00", + "data_read_per_join": "16" + } /* cost_info */, + "used_columns": [ + "1" + ] /* used_columns */, + "materialized_from_subquery": { + "using_temporary_table": true, + "dependent": false, + "cacheable": true, + "query_block": { + "select_id": 2, + "message": "No tables used" + } /* query_block */ + } /* materialized_from_subquery */ + } /* table */ + }, + { + "table": { + "update": true, + "table_name": "t11", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.30", + "prefix_cost": "0.55", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t1` `t11` join (/* select#2 */ select 1 AS `1`) `t12` set `test`.`t11`.`a` = (`test`.`t11`.`a` + 10) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 t11, (SELECT 1 FROM DUAL) t12;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.55" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "table_name": "t12", + "access_type": "system", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.00", + "eval_cost": "0.10", + "prefix_cost": "0.00", + "data_read_per_join": "16" + } /* cost_info */, + "used_columns": [ + "1" + ] /* used_columns */, + "materialized_from_subquery": { + "using_temporary_table": true, + "dependent": false, + "cacheable": true, + "query_block": { + "select_id": 2, + "message": "No tables used" + } /* query_block */ + } /* materialized_from_subquery */ + } /* table */ + }, + { + "table": { + "table_name": "t11", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.30", + "prefix_cost": "0.55", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t11`.`a` AS `a`,'1' AS `1` from `test`.`t1` `t11` +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 2 +Handler_read_rnd_next 5 +Handler_write 1 +# Status of testing query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 5 +Handler_read_rnd 3 +Handler_read_rnd_next 9 +Handler_update 3 +Handler_write 4 + +DROP TABLE t1, t2; +#10 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +CREATE TABLE t2 (b INT); +INSERT INTO t2 VALUES (1), (2), (3); +# +# query: UPDATE t1 t11, (SELECT * FROM t2) t12 SET t11.a = 10 WHERE t11.a > 1 +# select: SELECT * FROM t1 t11, (SELECT * FROM t2) t12 WHERE t11.a > 1 +# +EXPLAIN UPDATE t1 t11, (SELECT * FROM t2) t12 SET t11.a = 10 WHERE t11.a > 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t11 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 update `test`.`t1` `t11` join `test`.`t2` set `test`.`t11`.`a` = 10 where (`test`.`t11`.`a` > 1) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t1 t11, (SELECT * FROM t2) t12 SET t11.a = 10 WHERE t11.a > 1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.10" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "update": true, + "table_name": "t11", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 1, + "filtered": "33.33", + "cost_info": { + "read_cost": "0.45", + "eval_cost": "0.10", + "prefix_cost": "0.55", + "data_read_per_join": "8" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t11`.`a` > 1)" + } /* table */ + }, + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.30", + "prefix_cost": "1.10", + "data_read_per_join": "24" + } /* cost_info */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t1` `t11` join `test`.`t2` set `test`.`t11`.`a` = 10 where (`test`.`t11`.`a` > 1) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 t11, (SELECT * FROM t2) t12 WHERE t11.a > 1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.10" + } /* cost_info */, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 1, + "filtered": "33.33", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.45", + "eval_cost": "0.10", + "prefix_cost": "0.55", + "data_read_per_join": "16" + } /* cost_info */, + "used_columns": [ + "a", + "b" + ] /* used_columns */, + "query_block": { + "cost_info": { + "query_cost": "1.10" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "select_id": 2, + "table_name": "t11", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 1, + "filtered": "33.33", + "cost_info": { + "read_cost": "0.45", + "eval_cost": "0.10", + "prefix_cost": "0.55", + "data_read_per_join": "8" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t11`.`a` > 1)" + } /* table */ + }, + { + "table": { + "select_id": 2, + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.30", + "prefix_cost": "1.10", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "b" + ] /* used_columns */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t11`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` `t11` join `test`.`t2` where (`test`.`t11`.`a` > 1) +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 2 +Handler_read_key 4 +Handler_read_rnd_next 8 +# Status of testing query execution: +Variable_name Value +Handler_read_first 3 +Handler_read_key 5 +Handler_read_rnd_next 12 +Handler_update 2 + +DROP TABLE t1, t2; +#11 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +# +# query: DELETE FROM t1 WHERE a > 1 LIMIT 1 +# select: SELECT * FROM t1 WHERE a > 1 LIMIT 1 +# +EXPLAIN DELETE FROM t1 WHERE a > 1 LIMIT 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 delete from `test`.`t1` where (`test`.`t1`.`a` > 1) limit 1 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t1 WHERE a > 1 LIMIT 1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "table": { + "delete": true, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "filtered": "100.00", + "attached_condition": "(`test`.`t1`.`a` > 1)" + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 delete from `test`.`t1` where (`test`.`t1`.`a` > 1) limit 1 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 WHERE a > 1 LIMIT 1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.55" + } /* cost_info */, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 1, + "filtered": "33.33", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.45", + "eval_cost": "0.10", + "prefix_cost": "0.55", + "data_read_per_join": "16" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "query_block": { + "cost_info": { + "query_cost": "0.55" + } /* cost_info */, + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 1, + "filtered": "33.33", + "cost_info": { + "read_cost": "0.45", + "eval_cost": "0.10", + "prefix_cost": "0.55", + "data_read_per_join": "8" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`a` > 1)" + } /* table */ + } /* query_block */ + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` > 1) limit 1 +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 2 +Handler_read_rnd_next 2 +# Status of testing query execution: +Variable_name Value +Handler_delete 1 +Handler_read_first 1 +Handler_read_key 2 +Handler_read_rnd_next 2 + +DROP TABLE t1; +#12 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +# +# query: DELETE FROM t1 WHERE 0 +# select: SELECT * FROM t1 WHERE 0 +# +EXPLAIN DELETE FROM t1 WHERE 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 delete from `test`.`t1` where false +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t1 WHERE 0;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "message": "Impossible WHERE" + } /* query_block */ +} +Warnings: +Note 1003 delete from `test`.`t1` where false +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 WHERE 0;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "message": "Impossible WHERE" + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where false +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 1 + +DROP TABLE t1; +#13 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +# +# query: DELETE FROM t1 USING t1 WHERE 0 +# select: SELECT * FROM t1 WHERE 0 +# +EXPLAIN DELETE FROM t1 USING t1 WHERE 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 delete `test`.`t1` from `test`.`t1` where false +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t1 USING t1 WHERE 0;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "message": "Impossible WHERE" + } /* query_block */ +} +Warnings: +Note 1003 delete `test`.`t1` from `test`.`t1` where false +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 WHERE 0;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "message": "Impossible WHERE" + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where false +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 1 + +DROP TABLE t1; +#14 +CREATE TABLE t1 (a INT, b INT, UNIQUE KEY (a), KEY (b)); +INSERT INTO t1 VALUES (3, 3), (7, 7); +# +# query: DELETE FROM t1 WHERE a = 3 +# select: SELECT * FROM t1 WHERE a = 3 +# +EXPLAIN DELETE FROM t1 WHERE a = 3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL range a a 5 const 1 100.00 Using where +Warnings: +Note 1003 delete from `test`.`t1` where (`test`.`t1`.`a` = 3) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t1 WHERE a = 3;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "table": { + "delete": true, + "table_name": "t1", + "access_type": "range", + "possible_keys": [ + "a" + ] /* possible_keys */, + "key": "a", + "used_key_parts": [ + "a" + ] /* used_key_parts */, + "key_length": "5", + "ref": [ + "const" + ] /* ref */, + "rows_examined_per_scan": 1, + "filtered": "100.00", + "attached_condition": "(`test`.`t1`.`a` = 3)" + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 delete from `test`.`t1` where (`test`.`t1`.`a` = 3) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 WHERE a = 3;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.00" + } /* cost_info */, + "table": { + "table_name": "t1", + "access_type": "const", + "possible_keys": [ + "a" + ] /* possible_keys */, + "key": "a", + "used_key_parts": [ + "a" + ] /* used_key_parts */, + "key_length": "5", + "ref": [ + "const" + ] /* ref */, + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.00", + "eval_cost": "0.10", + "prefix_cost": "0.00", + "data_read_per_join": "16" + } /* cost_info */, + "used_columns": [ + "a", + "b" + ] /* used_columns */ + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select '3' AS `a`,'3' AS `b` from `test`.`t1` where true +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 3 +# Status of testing query execution: +Variable_name Value +Handler_delete 1 +Handler_read_key 3 + +DROP TABLE t1; +#15 +CREATE TABLE t1 (a INT, b INT, UNIQUE KEY (a), KEY (b)); +INSERT INTO t1 VALUES (3, 3), (7, 7); +# +# query: DELETE FROM t1 WHERE a < 3 +# select: SELECT * FROM t1 WHERE a < 3 +# +EXPLAIN DELETE FROM t1 WHERE a < 3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL range a a 5 const 1 100.00 Using where +Warnings: +Note 1003 delete from `test`.`t1` where (`test`.`t1`.`a` < 3) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t1 WHERE a < 3;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "table": { + "delete": true, + "table_name": "t1", + "access_type": "range", + "possible_keys": [ + "a" + ] /* possible_keys */, + "key": "a", + "used_key_parts": [ + "a" + ] /* used_key_parts */, + "key_length": "5", + "ref": [ + "const" + ] /* ref */, + "rows_examined_per_scan": 1, + "filtered": "100.00", + "attached_condition": "(`test`.`t1`.`a` < 3)" + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 delete from `test`.`t1` where (`test`.`t1`.`a` < 3) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 WHERE a < 3;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.71" + } /* cost_info */, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.61", + "eval_cost": "0.10", + "prefix_cost": "0.71", + "data_read_per_join": "16" + } /* cost_info */, + "used_columns": [ + "a", + "b" + ] /* used_columns */, + "query_block": { + "cost_info": { + "query_cost": "0.71" + } /* cost_info */, + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "range", + "possible_keys": [ + "a" + ] /* possible_keys */, + "key": "a", + "used_key_parts": [ + "a" + ] /* used_key_parts */, + "key_length": "5", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.61", + "eval_cost": "0.10", + "prefix_cost": "0.71", + "data_read_per_join": "16" + } /* cost_info */, + "used_columns": [ + "a", + "b" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`a` < 3)" + } /* table */ + } /* query_block */ + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (`test`.`t1`.`a` < 3) +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 4 +Handler_read_rnd_next 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 3 + +DROP TABLE t1; +#16 +CREATE TABLE t1 ( a int PRIMARY KEY ); +# +# query: DELETE FROM t1 WHERE t1.a > 0 ORDER BY t1.a +# select: SELECT * FROM t1 WHERE t1.a > 0 ORDER BY t1.a +# +EXPLAIN DELETE FROM t1 WHERE t1.a > 0 ORDER BY t1.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL range PRIMARY PRIMARY 4 const 1 100.00 Using where +Warnings: +Note 1003 delete from `test`.`t1` where (`test`.`t1`.`a` > 0) order by `test`.`t1`.`a` +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t1 WHERE t1.a > 0 ORDER BY t1.a;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_filesort": false, + "table": { + "delete": true, + "table_name": "t1", + "access_type": "range", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "a" + ] /* used_key_parts */, + "key_length": "4", + "ref": [ + "const" + ] /* ref */, + "rows_examined_per_scan": 1, + "filtered": "100.00", + "attached_condition": "(`test`.`t1`.`a` > 0)" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 delete from `test`.`t1` where (`test`.`t1`.`a` > 0) order by `test`.`t1`.`a` +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 WHERE t1.a > 0 ORDER BY t1.a;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.35" + } /* cost_info */, + "ordering_operation": { + "using_filesort": false, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.10", + "prefix_cost": "0.35", + "data_read_per_join": "16" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "ordering_operation": { + "using_filesort": false, + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "index", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "a" + ] /* used_key_parts */, + "key_length": "4", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "using_index": true, + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.10", + "prefix_cost": "0.35", + "data_read_per_join": "8" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`a` > 0)" + } /* table */ + } /* ordering_operation */ + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` > 0) order by `test`.`t1`.`a` +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 2 +Handler_read_rnd_next 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 2 + +INSERT INTO t1 VALUES (1), (2), (3); +# +# query: DELETE FROM t1 WHERE t1.a > 0 ORDER BY t1.a +# select: SELECT * FROM t1 WHERE t1.a > 0 ORDER BY t1.a +# +EXPLAIN DELETE FROM t1 WHERE t1.a > 0 ORDER BY t1.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL range PRIMARY PRIMARY 4 const 3 100.00 Using where +Warnings: +Note 1003 delete from `test`.`t1` where (`test`.`t1`.`a` > 0) order by `test`.`t1`.`a` +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t1 WHERE t1.a > 0 ORDER BY t1.a;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_filesort": false, + "table": { + "delete": true, + "table_name": "t1", + "access_type": "range", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "a" + ] /* used_key_parts */, + "key_length": "4", + "ref": [ + "const" + ] /* ref */, + "rows_examined_per_scan": 3, + "filtered": "100.00", + "attached_condition": "(`test`.`t1`.`a` > 0)" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 delete from `test`.`t1` where (`test`.`t1`.`a` > 0) order by `test`.`t1`.`a` +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 WHERE t1.a > 0 ORDER BY t1.a;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.55" + } /* cost_info */, + "ordering_operation": { + "using_filesort": false, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.30", + "prefix_cost": "0.55", + "data_read_per_join": "48" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "ordering_operation": { + "using_filesort": false, + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "index", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "a" + ] /* used_key_parts */, + "key_length": "4", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "using_index": true, + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.30", + "prefix_cost": "0.55", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`a` > 0)" + } /* table */ + } /* ordering_operation */ + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` > 0) order by `test`.`t1`.`a` +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 2 +Handler_read_rnd_next 4 +# Status of testing query execution: +Variable_name Value +Handler_delete 3 +Handler_read_key 2 +Handler_read_next 3 + +DROP TABLE t1; +#17 +CREATE TABLE t1(a INT PRIMARY KEY); +INSERT INTO t1 VALUES (4),(3),(1),(2); +# +# query: DELETE FROM t1 WHERE (@a:= a) ORDER BY a LIMIT 1 +# select: SELECT * FROM t1 WHERE (@a:= a) ORDER BY a LIMIT 1 +# +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +EXPLAIN DELETE FROM t1 WHERE (@a:= a) ORDER BY a LIMIT 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL index NULL PRIMARY 4 NULL 4 100.00 Using where +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +Note 1003 delete from `test`.`t1` where (0 <> (@a:=`test`.`t1`.`a`)) order by `test`.`t1`.`a` limit 1 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t1 WHERE (@a:= a) ORDER BY a LIMIT 1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_filesort": false, + "table": { + "delete": true, + "table_name": "t1", + "access_type": "index", + "key": "PRIMARY", + "used_key_parts": [ + "a" + ] /* used_key_parts */, + "key_length": "4", + "rows_examined_per_scan": 4, + "filtered": "100.00", + "attached_condition": "(0 <> (@a:=`test`.`t1`.`a`))" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +Note 1003 delete from `test`.`t1` where (0 <> (@a:=`test`.`t1`.`a`)) order by `test`.`t1`.`a` limit 1 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 WHERE (@a:= a) ORDER BY a LIMIT 1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.65" + } /* cost_info */, + "ordering_operation": { + "using_filesort": false, + "table": { + "table_name": "t1", + "access_type": "index", + "key": "PRIMARY", + "used_key_parts": [ + "a" + ] /* used_key_parts */, + "key_length": "4", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 4, + "filtered": "100.00", + "using_index": true, + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.40", + "prefix_cost": "0.65", + "data_read_per_join": "32" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(0 <> (@a:=`test`.`t1`.`a`))" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (0 <> (@a:=`test`.`t1`.`a`)) order by `test`.`t1`.`a` limit 1 +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 2 +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +# Status of testing query execution: +Variable_name Value +Handler_delete 1 +Handler_read_first 1 +Handler_read_key 2 + +DROP TABLE t1; +#18 +CREATE TABLE t1 (a DATE, b TIME, c INT, KEY c(c), KEY b(b), KEY a(a)); +INSERT INTO t1 VALUES (), (), (), (), (), (), (), (), (), (); +UPDATE t1 SET a = c, b = c; +# +# query: DELETE FROM t1 ORDER BY a ASC, b ASC LIMIT 1 +# select: SELECT * FROM t1 ORDER BY a ASC, b ASC LIMIT 1 +# +EXPLAIN DELETE FROM t1 ORDER BY a ASC, b ASC LIMIT 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 10 100.00 Using filesort +Warnings: +Note 1003 delete from `test`.`t1` order by `test`.`t1`.`a`,`test`.`t1`.`b` limit 1 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t1 ORDER BY a ASC, b ASC LIMIT 1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_filesort": true, + "table": { + "delete": true, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 10, + "filtered": "100.00" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 delete from `test`.`t1` order by `test`.`t1`.`a`,`test`.`t1`.`b` limit 1 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 ORDER BY a ASC, b ASC LIMIT 1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.25" + } /* cost_info */, + "ordering_operation": { + "using_filesort": true, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 10, + "rows_produced_per_join": 10, + "filtered": "100.00", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "1.00", + "prefix_cost": "1.25", + "data_read_per_join": "160" + } /* cost_info */, + "used_columns": [ + "a", + "b", + "c" + ] /* used_columns */, + "ordering_operation": { + "using_filesort": true, + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 10, + "rows_produced_per_join": 10, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "1.00", + "prefix_cost": "1.25", + "data_read_per_join": "160" + } /* cost_info */, + "used_columns": [ + "a", + "b", + "c" + ] /* used_columns */ + } /* table */ + } /* ordering_operation */ + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` order by `test`.`t1`.`a`,`test`.`t1`.`b` limit 1 +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 4 +Handler_read_rnd_next 11 +Sort_rows 1 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_delete 1 +Handler_read_first 1 +Handler_read_key 5 +Handler_read_rnd 1 +Handler_read_rnd_next 11 +Sort_rows 10 +Sort_scan 1 + +DROP TABLE t1; +#19 +CREATE TABLE t1 (a1 INT NOT NULL, b1 INT NOT NULL); +CREATE TABLE t2 (a2 INT NOT NULL, b2 INT NOT NULL, PRIMARY KEY (a2,b2)); +CREATE TABLE t3 (a3 INT NOT NULL, b3 INT NOT NULL, PRIMARY KEY (a3,b3)); +INSERT INTO t1 VALUES (1,1), (2,1), (1,3); +INSERT INTO t2 VALUES (1,1), (2,2), (3,3); +INSERT INTO t3 VALUES (1,1), (2,1), (1,3); +# +# query: DELETE t1,t2,t3 FROM t1,t2,t3 WHERE a1=a2 AND b2=a3 AND b1=b3 +# select: SELECT * FROM t1,t2,t3 WHERE a1=a2 AND b2=a3 AND b1=b3 +# +EXPLAIN DELETE t1,t2,t3 FROM t1,t2,t3 WHERE a1=a2 AND b2=a3 AND b1=b3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 DELETE t2 NULL ref PRIMARY PRIMARY 4 test.t1.a1 1 100.00 NULL +1 DELETE t3 NULL eq_ref PRIMARY PRIMARY 8 test.t2.b2,test.t1.b1 1 100.00 NULL +Warnings: +Note 1003 delete `test`.`t1`, `test`.`t2`, `test`.`t3` from `test`.`t1` join `test`.`t2` join `test`.`t3` where ((`test`.`t3`.`b3` = `test`.`t1`.`b1`) and (`test`.`t3`.`a3` = `test`.`t2`.`b2`) and (`test`.`t2`.`a2` = `test`.`t1`.`a1`)) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE t1,t2,t3 FROM t1,t2,t3 WHERE a1=a2 AND b2=a3 AND b1=b3;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "2.65" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "delete": true, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.30", + "prefix_cost": "0.55", + "data_read_per_join": "48" + } /* cost_info */, + "used_columns": [ + "a1", + "b1" + ] /* used_columns */ + } /* table */ + }, + { + "table": { + "delete": true, + "table_name": "t2", + "access_type": "ref", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "a2" + ] /* used_key_parts */, + "key_length": "4", + "ref": [ + "test.t1.a1" + ] /* ref */, + "rows_examined_per_scan": 1, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.75", + "eval_cost": "0.30", + "prefix_cost": "1.60", + "data_read_per_join": "48" + } /* cost_info */, + "used_columns": [ + "a2", + "b2" + ] /* used_columns */ + } /* table */ + }, + { + "table": { + "delete": true, + "table_name": "t3", + "access_type": "eq_ref", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "a3", + "b3" + ] /* used_key_parts */, + "key_length": "8", + "ref": [ + "test.t2.b2", + "test.t1.b1" + ] /* ref */, + "rows_examined_per_scan": 1, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.75", + "eval_cost": "0.30", + "prefix_cost": "2.65", + "data_read_per_join": "48" + } /* cost_info */, + "used_columns": [ + "a3", + "b3" + ] /* used_columns */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 delete `test`.`t1`, `test`.`t2`, `test`.`t3` from `test`.`t1` join `test`.`t2` join `test`.`t3` where ((`test`.`t3`.`b3` = `test`.`t1`.`b1`) and (`test`.`t3`.`a3` = `test`.`t2`.`b2`) and (`test`.`t2`.`a2` = `test`.`t1`.`a1`)) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1,t2,t3 WHERE a1=a2 AND b2=a3 AND b1=b3;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "2.65" + } /* cost_info */, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.30", + "prefix_cost": "0.55", + "data_read_per_join": "96" + } /* cost_info */, + "used_columns": [ + "a1", + "b1", + "a2", + "b2", + "a3", + "b3" + ] /* used_columns */, + "query_block": { + "cost_info": { + "query_cost": "2.65" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.30", + "prefix_cost": "0.55", + "data_read_per_join": "48" + } /* cost_info */, + "used_columns": [ + "a1", + "b1" + ] /* used_columns */ + } /* table */ + }, + { + "table": { + "select_id": 2, + "table_name": "t2", + "access_type": "ref", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "a2" + ] /* used_key_parts */, + "key_length": "4", + "ref": [ + "test.t1.a1" + ] /* ref */, + "rows_examined_per_scan": 1, + "rows_produced_per_join": 3, + "filtered": "100.00", + "using_index": true, + "cost_info": { + "read_cost": "0.75", + "eval_cost": "0.30", + "prefix_cost": "1.60", + "data_read_per_join": "48" + } /* cost_info */, + "used_columns": [ + "a2", + "b2" + ] /* used_columns */ + } /* table */ + }, + { + "table": { + "select_id": 2, + "table_name": "t3", + "access_type": "eq_ref", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "a3", + "b3" + ] /* used_key_parts */, + "key_length": "8", + "ref": [ + "test.t2.b2", + "test.t1.b1" + ] /* ref */, + "rows_examined_per_scan": 1, + "rows_produced_per_join": 3, + "filtered": "100.00", + "using_index": true, + "cost_info": { + "read_cost": "0.75", + "eval_cost": "0.30", + "prefix_cost": "2.65", + "data_read_per_join": "48" + } /* cost_info */, + "used_columns": [ + "a3", + "b3" + ] /* used_columns */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`b1` AS `b1`,`test`.`t2`.`a2` AS `a2`,`test`.`t2`.`b2` AS `b2`,`test`.`t3`.`a3` AS `a3`,`test`.`t3`.`b3` AS `b3` from `test`.`t1` join `test`.`t2` join `test`.`t3` where ((`test`.`t3`.`b3` = `test`.`t1`.`b1`) and (`test`.`t3`.`a3` = `test`.`t2`.`b2`) and (`test`.`t2`.`a2` = `test`.`t1`.`a1`)) +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 13 +Handler_read_next 3 +Handler_read_rnd_next 4 +# Status of testing query execution: +Variable_name Value +Handler_delete 8 +Handler_read_first 1 +Handler_read_key 18 +Handler_read_next 3 +Handler_read_rnd 5 +Handler_read_rnd_next 4 + +DROP TABLE t1, t2, t3; +#20 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +CREATE TABLE t2 (a INT); +INSERT INTO t2 VALUES (1), (2), (3); +# +# query: UPDATE t1 SET a = 10 WHERE a IN (SELECT a FROM t2) +# select: SELECT * FROM t1 WHERE a IN (SELECT a FROM t2) +# +EXPLAIN UPDATE t1 SET a = 10 WHERE a IN (SELECT a FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`a` = 10 where (`test`.`t1`.`a`,(/* select#2 */ select `test`.`t2`.`a` from `test`.`t2` where ((`test`.`t1`.`a`) = `test`.`t2`.`a`))) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t1 SET a = 10 WHERE a IN (SELECT a FROM t2);; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "table": { + "update": true, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "filtered": "100.00", + "attached_condition": "(`test`.`t1`.`a`,(/* select#2 */ select `test`.`t2`.`a` from `test`.`t2` where ((`test`.`t1`.`a`) = `test`.`t2`.`a`)))", + "attached_subqueries": [ + { + "dependent": true, + "cacheable": false, + "query_block": { + "select_id": 2, + "cost_info": { + "query_cost": "0.55" + } /* cost_info */, + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 1, + "filtered": "33.33", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.10", + "prefix_cost": "0.55", + "data_read_per_join": "8" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "((`test`.`t1`.`a`) = `test`.`t2`.`a`)" + } /* table */ + } /* query_block */ + } + ] /* attached_subqueries */ + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`a` = 10 where (`test`.`t1`.`a`,(/* select#2 */ select `test`.`t2`.`a` from `test`.`t2` where ((`test`.`t1`.`a`) = `test`.`t2`.`a`))) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 WHERE a IN (SELECT a FROM t2);; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.55" + } /* cost_info */, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.30", + "prefix_cost": "0.55", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`a`,(/* select#2 */ select `test`.`t2`.`a` from `test`.`t2` where ((`test`.`t1`.`a`) = `test`.`t2`.`a`)))", + "attached_subqueries": [ + { + "dependent": true, + "cacheable": false, + "query_block": { + "select_id": 2, + "cost_info": { + "query_cost": "0.55" + } /* cost_info */, + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 1, + "filtered": "33.33", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.10", + "prefix_cost": "0.55", + "data_read_per_join": "8" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "((`test`.`t1`.`a`) = `test`.`t2`.`a`)" + } /* table */ + } /* query_block */ + } + ] /* attached_subqueries */ + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a`,(/* select#2 */ select `test`.`t2`.`a` from `test`.`t2` where ((`test`.`t1`.`a`) = `test`.`t2`.`a`))) +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 4 +Handler_read_key 6 +Handler_read_rnd_next 10 +# Status of testing query execution: +Variable_name Value +Handler_read_first 4 +Handler_read_key 6 +Handler_read_rnd_next 10 +Handler_update 3 + +DROP TABLE t1, t2; +#21 +CREATE TABLE t1 (a1 INT); +INSERT INTO t1 VALUES (1), (2), (3), (4), (5); +CREATE TABLE t2 (a2 VARCHAR(10)) charset utf8mb4; +INSERT INTO t2 VALUES (1), (2), (3), (4), (5); +SET @save_optimizer_switch= @@optimizer_switch; +# +# query: DELETE FROM t1 WHERE a1 IN (SELECT a2 FROM t2 WHERE a2 > 2) +# select: SELECT * FROM t1 WHERE a1 IN (SELECT a2 FROM t2 WHERE a2 > 2) +# +EXPLAIN DELETE FROM t1 WHERE a1 IN (SELECT a2 FROM t2 WHERE a2 > 2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 5 100.00 Using where +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 5 20.00 Using where +Warnings: +Note 1003 delete from `test`.`t1` where (`test`.`t1`.`a1`,(/* select#2 */ select `test`.`t2`.`a2` from `test`.`t2` where ((`test`.`t2`.`a2` > 2) and ((`test`.`t1`.`a1`) = `test`.`t2`.`a2`)))) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t1 WHERE a1 IN (SELECT a2 FROM t2 WHERE a2 > 2);; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "table": { + "delete": true, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "filtered": "100.00", + "attached_condition": "(`test`.`t1`.`a1`,(/* select#2 */ select `test`.`t2`.`a2` from `test`.`t2` where ((`test`.`t2`.`a2` > 2) and ((`test`.`t1`.`a1`) = `test`.`t2`.`a2`))))", + "attached_subqueries": [ + { + "dependent": true, + "cacheable": false, + "query_block": { + "select_id": 2, + "cost_info": { + "query_cost": "0.75" + } /* cost_info */, + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 1, + "filtered": "20.00", + "cost_info": { + "read_cost": "0.58", + "eval_cost": "0.10", + "prefix_cost": "0.75", + "data_read_per_join": "48" + } /* cost_info */, + "used_columns": [ + "a2" + ] /* used_columns */, + "attached_condition": "((`test`.`t2`.`a2` > 2) and ((`test`.`t1`.`a1`) = `test`.`t2`.`a2`))" + } /* table */ + } /* query_block */ + } + ] /* attached_subqueries */ + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 delete from `test`.`t1` where (`test`.`t1`.`a1`,(/* select#2 */ select `test`.`t2`.`a2` from `test`.`t2` where ((`test`.`t2`.`a2` > 2) and ((`test`.`t1`.`a1`) = `test`.`t2`.`a2`)))) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 WHERE a1 IN (SELECT a2 FROM t2 WHERE a2 > 2);; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.75" + } /* cost_info */, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "40" + } /* cost_info */, + "used_columns": [ + "a1" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`a1`,(/* select#2 */ select `test`.`t2`.`a2` from `test`.`t2` where ((`test`.`t2`.`a2` > 2) and ((`test`.`t1`.`a1`) = `test`.`t2`.`a2`))))", + "attached_subqueries": [ + { + "dependent": true, + "cacheable": false, + "query_block": { + "select_id": 2, + "cost_info": { + "query_cost": "0.75" + } /* cost_info */, + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 1, + "filtered": "20.00", + "cost_info": { + "read_cost": "0.58", + "eval_cost": "0.10", + "prefix_cost": "0.75", + "data_read_per_join": "48" + } /* cost_info */, + "used_columns": [ + "a2" + ] /* used_columns */, + "attached_condition": "((`test`.`t2`.`a2` > 2) and ((`test`.`t1`.`a1`) = `test`.`t2`.`a2`))" + } /* table */ + } /* query_block */ + } + ] /* attached_subqueries */ + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1` from `test`.`t1` where (`test`.`t1`.`a1`,(/* select#2 */ select `test`.`t2`.`a2` from `test`.`t2` where ((`test`.`t2`.`a2` > 2) and ((`test`.`t1`.`a1`) = `test`.`t2`.`a2`)))) +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 6 +Handler_read_key 8 +Handler_read_rnd_next 30 +# Status of testing query execution: +Variable_name Value +Handler_delete 3 +Handler_read_first 6 +Handler_read_key 8 +Handler_read_rnd_next 30 + +SET @@optimizer_switch= @save_optimizer_switch; +TRUNCATE t1; +INSERT INTO t1 VALUES (1), (2), (3), (4), (5); +# +# query: DELETE FROM t1 WHERE a1 IN (SELECT a2 FROM t2 WHERE a2 > 2) +# select: SELECT * FROM t1 WHERE a1 IN (SELECT a2 FROM t2 WHERE a2 > 2) +# +EXPLAIN DELETE FROM t1 WHERE a1 IN (SELECT a2 FROM t2 WHERE a2 > 2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 5 100.00 Using where +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 5 20.00 Using where +Warnings: +Note 1003 delete from `test`.`t1` where (`test`.`t1`.`a1`,(/* select#2 */ select `test`.`t2`.`a2` from `test`.`t2` where ((`test`.`t2`.`a2` > 2) and ((`test`.`t1`.`a1`) = `test`.`t2`.`a2`)))) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t1 WHERE a1 IN (SELECT a2 FROM t2 WHERE a2 > 2);; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "table": { + "delete": true, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "filtered": "100.00", + "attached_condition": "(`test`.`t1`.`a1`,(/* select#2 */ select `test`.`t2`.`a2` from `test`.`t2` where ((`test`.`t2`.`a2` > 2) and ((`test`.`t1`.`a1`) = `test`.`t2`.`a2`))))", + "attached_subqueries": [ + { + "dependent": true, + "cacheable": false, + "query_block": { + "select_id": 2, + "cost_info": { + "query_cost": "0.75" + } /* cost_info */, + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 1, + "filtered": "20.00", + "cost_info": { + "read_cost": "0.58", + "eval_cost": "0.10", + "prefix_cost": "0.75", + "data_read_per_join": "48" + } /* cost_info */, + "used_columns": [ + "a2" + ] /* used_columns */, + "attached_condition": "((`test`.`t2`.`a2` > 2) and ((`test`.`t1`.`a1`) = `test`.`t2`.`a2`))" + } /* table */ + } /* query_block */ + } + ] /* attached_subqueries */ + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 delete from `test`.`t1` where (`test`.`t1`.`a1`,(/* select#2 */ select `test`.`t2`.`a2` from `test`.`t2` where ((`test`.`t2`.`a2` > 2) and ((`test`.`t1`.`a1`) = `test`.`t2`.`a2`)))) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 WHERE a1 IN (SELECT a2 FROM t2 WHERE a2 > 2);; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.75" + } /* cost_info */, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "40" + } /* cost_info */, + "used_columns": [ + "a1" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`a1`,(/* select#2 */ select `test`.`t2`.`a2` from `test`.`t2` where ((`test`.`t2`.`a2` > 2) and ((`test`.`t1`.`a1`) = `test`.`t2`.`a2`))))", + "attached_subqueries": [ + { + "dependent": true, + "cacheable": false, + "query_block": { + "select_id": 2, + "cost_info": { + "query_cost": "0.75" + } /* cost_info */, + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 1, + "filtered": "20.00", + "cost_info": { + "read_cost": "0.58", + "eval_cost": "0.10", + "prefix_cost": "0.75", + "data_read_per_join": "48" + } /* cost_info */, + "used_columns": [ + "a2" + ] /* used_columns */, + "attached_condition": "((`test`.`t2`.`a2` > 2) and ((`test`.`t1`.`a1`) = `test`.`t2`.`a2`))" + } /* table */ + } /* query_block */ + } + ] /* attached_subqueries */ + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1` from `test`.`t1` where (`test`.`t1`.`a1`,(/* select#2 */ select `test`.`t2`.`a2` from `test`.`t2` where ((`test`.`t2`.`a2` > 2) and ((`test`.`t1`.`a1`) = `test`.`t2`.`a2`)))) +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 6 +Handler_read_key 8 +Handler_read_rnd_next 30 +# Status of testing query execution: +Variable_name Value +Handler_delete 3 +Handler_read_first 6 +Handler_read_key 8 +Handler_read_rnd_next 30 + +DROP TABLE t1, t2; +#22 +CREATE TABLE t1 (i INT, j INT); +INSERT INTO t1 VALUES (1, 1), (2, 2), (3, 3), (4, 4), (5, 5); +# +# query: UPDATE t1 SET i = 10 +# select: SELECT * FROM t1 +# +EXPLAIN UPDATE t1 SET i = 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`i` = 10 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t1 SET i = 10;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "table": { + "update": true, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "filtered": "100.00" + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`i` = 10 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.75" + } /* cost_info */, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "80" + } /* cost_info */, + "used_columns": [ + "i", + "j" + ] /* used_columns */, + "query_block": { + "cost_info": { + "query_cost": "0.75" + } /* cost_info */, + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "80" + } /* cost_info */, + "used_columns": [ + "i", + "j" + ] /* used_columns */ + } /* table */ + } /* query_block */ + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i`,`test`.`t1`.`j` AS `j` from `test`.`t1` +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 3 +Handler_read_rnd_next 6 +# Status of testing query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 3 +Handler_read_rnd_next 6 +Handler_update 5 + +DROP TABLE t1; +#23 +CREATE TABLE t1 (i INT, j INT); +INSERT INTO t1 VALUES (1, 1), (2, 2), (3, 3), (4, 4), (5, 5); +# +# query: DELETE FROM t1 +# select: SELECT * FROM t1 +# +EXPLAIN DELETE FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 5 100.00 Deleting all rows +Warnings: +Note 1003 delete from `test`.`t1` +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "table": { + "delete": true, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "filtered": "100.00", + "message": "Deleting all rows" + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 delete from `test`.`t1` +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.75" + } /* cost_info */, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "80" + } /* cost_info */, + "used_columns": [ + "i", + "j" + ] /* used_columns */, + "query_block": { + "cost_info": { + "query_cost": "0.75" + } /* cost_info */, + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "80" + } /* cost_info */, + "used_columns": [ + "i", + "j" + ] /* used_columns */ + } /* table */ + } /* query_block */ + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i`,`test`.`t1`.`j` AS `j` from `test`.`t1` +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 3 +Handler_read_rnd_next 6 +# Status of testing query execution: +Variable_name Value +Handler_delete 5 +Handler_read_first 1 +Handler_read_key 3 +Handler_read_rnd_next 6 + +DROP TABLE t1; +#24 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2(a INT, b INT, c INT, d INT, INDEX(a, b, c)); +INSERT INTO t2 (a, b, c) SELECT i, i, i FROM t1; +INSERT INTO t2 (a, b, c) SELECT t1.i, t1.i, t1.i FROM t1, t1 x1, t1 x2; +# +# query: DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# select: SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# +EXPLAIN DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t2 NULL index NULL a 15 NULL X 100.00 Using where +Warnings: +Note 1003 delete from `test`.`t2` where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_filesort": false, + "table": { + "delete": true, + "table_name": "t2", + "access_type": "index", + "key": "a", + "used_key_parts": [ + "a", + "b", + "c" + ] /* used_key_parts */, + "key_length": "15", + "rows_examined_per_scan": "X", + "filtered": "X", + "attached_condition": "(`test`.`t2`.`b` = 10)" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 delete from `test`.`t2` where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "X" + } /* cost_info */, + "ordering_operation": { + "using_filesort": false, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": "X", + "rows_produced_per_join": "X", + "filtered": "X", + "parallel_execute": "4 workers", + "cost_info": { + "read_cost": "X", + "eval_cost": "X", + "prefix_cost": "X", + "data_read_per_join": "X" + } /* cost_info */, + "used_columns": [ + "a", + "b", + "c", + "d" + ] /* used_columns */, + "ordering_operation": { + "using_filesort": false, + "table": { + "select_id": 2, + "table_name": "t2", + "access_type": "index", + "key": "a", + "used_key_parts": [ + "a", + "b", + "c" + ] /* used_key_parts */, + "key_length": "15", + "rows_examined_per_scan": "X", + "rows_produced_per_join": "X", + "filtered": "X", + "cost_info": { + "read_cost": "X", + "eval_cost": "X", + "prefix_cost": "X", + "data_read_per_join": "X" + } /* cost_info */, + "used_columns": [ + "a", + "b", + "c", + "d" + ] /* used_columns */, + "attached_condition": "(`test`.`t2`.`b` = 10)" + } /* table */ + } /* ordering_operation */ + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c`,`test`.`t2`.`d` AS `d` from `test`.`t2` where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 5 +Handler_read_rnd_next 16936 +# Status of testing query execution: +Variable_name Value +Handler_delete 5 +Handler_read_first 1 +Handler_read_key 5 +Handler_read_next 4 + +DROP TABLE t1, t2; +#25 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (1), (2), (3); +CREATE TABLE t2 (i INT); +# +# query: INSERT INTO t2 SELECT * FROM t1 +# select: SELECT * FROM t1 +# +EXPLAIN INSERT INTO t2 SELECT * FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 INSERT t2 NULL ALL NULL NULL NULL NULL NULL NULL NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 insert into `test`.`t2` /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON INSERT INTO t2 SELECT * FROM t1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.55" + } /* cost_info */, + "table": { + "insert": true, + "table_name": "t2", + "access_type": "ALL" + } /* table */, + "insert_from": { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.30", + "prefix_cost": "0.55", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "i" + ] /* used_columns */ + } /* table */ + } /* insert_from */ + } /* query_block */ +} +Warnings: +Note 1003 insert into `test`.`t2` /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.55" + } /* cost_info */, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.30", + "prefix_cost": "0.55", + "data_read_per_join": "48" + } /* cost_info */, + "used_columns": [ + "i" + ] /* used_columns */, + "query_block": { + "cost_info": { + "query_cost": "0.55" + } /* cost_info */, + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.30", + "prefix_cost": "0.55", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "i" + ] /* used_columns */ + } /* table */ + } /* query_block */ + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 2 +Handler_read_rnd_next 4 +# Status of testing query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 3 +Handler_read_rnd_next 4 +Handler_write 3 + +# +# query: INSERT INTO t2 SELECT * FROM t1 JOIN t1 AS tt USING(i) +# select: SELECT * FROM t1 JOIN t1 AS tt USING(i) +# +EXPLAIN INSERT INTO t2 SELECT * FROM t1 JOIN t1 AS tt USING(i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 INSERT t2 NULL ALL NULL NULL NULL NULL NULL NULL NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE tt NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +Warnings: +Note 1003 insert into `test`.`t2` /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` join `test`.`t1` `tt` where (`test`.`tt`.`i` = `test`.`t1`.`i`) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON INSERT INTO t2 SELECT * FROM t1 JOIN t1 AS tt USING(i);; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.70" + } /* cost_info */, + "table": { + "insert": true, + "table_name": "t2", + "access_type": "ALL" + } /* table */, + "insert_from": { + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.30", + "prefix_cost": "0.55", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "i" + ] /* used_columns */ + } /* table */ + }, + { + "table": { + "table_name": "tt", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "33.33", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.30", + "prefix_cost": "1.70", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "i" + ] /* used_columns */, + "attached_condition": "(`test`.`tt`.`i` = `test`.`t1`.`i`)" + } /* table */ + } + ] /* nested_loop */ + } /* insert_from */ + } /* query_block */ +} +Warnings: +Note 1003 insert into `test`.`t2` /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` join `test`.`t1` `tt` where (`test`.`tt`.`i` = `test`.`t1`.`i`) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 JOIN t1 AS tt USING(i);; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.70" + } /* cost_info */, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.30", + "prefix_cost": "0.55", + "data_read_per_join": "48" + } /* cost_info */, + "used_columns": [ + "i" + ] /* used_columns */, + "query_block": { + "cost_info": { + "query_cost": "1.70" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.30", + "prefix_cost": "0.55", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "i" + ] /* used_columns */ + } /* table */ + }, + { + "table": { + "select_id": 2, + "table_name": "tt", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "33.33", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.30", + "prefix_cost": "1.70", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "i" + ] /* used_columns */, + "attached_condition": "(`test`.`tt`.`i` = `test`.`t1`.`i`)" + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` join `test`.`t1` `tt` where (`test`.`tt`.`i` = `test`.`t1`.`i`) +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 2 +Handler_read_key 3 +Handler_read_rnd_next 8 +# Status of testing query execution: +Variable_name Value +Handler_read_first 2 +Handler_read_key 4 +Handler_read_rnd_next 8 +Handler_write 3 + +DROP TABLE t1, t2; +#26 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (1), (2), (3); +CREATE TABLE t2 (i INT); +# +# query: REPLACE INTO t2 SELECT * FROM t1 +# select: SELECT * FROM t1 +# +EXPLAIN REPLACE INTO t2 SELECT * FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 REPLACE t2 NULL ALL NULL NULL NULL NULL NULL NULL NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 replace into `test`.`t2` /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON REPLACE INTO t2 SELECT * FROM t1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.55" + } /* cost_info */, + "table": { + "replace": true, + "table_name": "t2", + "access_type": "ALL" + } /* table */, + "insert_from": { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.30", + "prefix_cost": "0.55", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "i" + ] /* used_columns */ + } /* table */ + } /* insert_from */ + } /* query_block */ +} +Warnings: +Note 1003 replace into `test`.`t2` /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.55" + } /* cost_info */, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.30", + "prefix_cost": "0.55", + "data_read_per_join": "48" + } /* cost_info */, + "used_columns": [ + "i" + ] /* used_columns */, + "query_block": { + "cost_info": { + "query_cost": "0.55" + } /* cost_info */, + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.30", + "prefix_cost": "0.55", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "i" + ] /* used_columns */ + } /* table */ + } /* query_block */ + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 2 +Handler_read_rnd_next 4 +# Status of testing query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 3 +Handler_read_rnd_next 4 +Handler_write 3 + +DROP TABLE t1, t2; +#27 +CREATE TABLE t1 (i INT); +# +# query: INSERT INTO t1 SET i = 10 +# select: +# +EXPLAIN INSERT INTO t1 SET i = 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 INSERT t1 NULL ALL NULL NULL NULL NULL NULL NULL NULL +Warnings: +Note 1003 insert into `test`.`t1` (`test`.`t1`.`i`) values (10) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON INSERT INTO t1 SET i = 10;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "table": { + "insert": true, + "table_name": "t1", + "access_type": "ALL" + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 insert into `test`.`t1` (`test`.`t1`.`i`) values (10) +# Status of testing query execution: +Variable_name Value +Handler_read_key 1 +Handler_write 1 + +DROP TABLE t1; +#28 +CREATE TABLE t1 (i INT); +# +# query: REPLACE INTO t1 SET i = 10 +# select: +# +EXPLAIN REPLACE INTO t1 SET i = 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 REPLACE t1 NULL ALL NULL NULL NULL NULL NULL NULL NULL +Warnings: +Note 1003 replace into `test`.`t1` (`test`.`t1`.`i`) values (10) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON REPLACE INTO t1 SET i = 10;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "table": { + "replace": true, + "table_name": "t1", + "access_type": "ALL" + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 replace into `test`.`t1` (`test`.`t1`.`i`) values (10) +# Status of testing query execution: +Variable_name Value +Handler_read_key 1 +Handler_write 1 + +DROP TABLE t1; +#29 +CREATE TABLE t1 (a INT, i INT PRIMARY KEY); +INSERT INTO t1 (i) VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +# +# query: DELETE FROM t1 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 1 +# select: SELECT * FROM t1 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 1 +# +EXPLAIN DELETE FROM t1 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL range PRIMARY PRIMARY 4 const X 100.00 Using where +Warnings: +Note 1003 delete from `test`.`t1` where ((`test`.`t1`.`i` > 10) and (`test`.`t1`.`i` <= 18)) order by `test`.`t1`.`i` limit 1 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t1 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_filesort": false, + "table": { + "delete": true, + "table_name": "t1", + "access_type": "range", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "i" + ] /* used_key_parts */, + "key_length": "4", + "ref": [ + "const" + ] /* ref */, + "rows_examined_per_scan": "X", + "filtered": "X", + "attached_condition": "((`test`.`t1`.`i` > 10) and (`test`.`t1`.`i` <= 18))" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 delete from `test`.`t1` where ((`test`.`t1`.`i` > 10) and (`test`.`t1`.`i` <= 18)) order by `test`.`t1`.`i` limit 1 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "X" + } /* cost_info */, + "ordering_operation": { + "using_filesort": false, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": "X", + "rows_produced_per_join": "X", + "filtered": "X", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "X", + "eval_cost": "X", + "prefix_cost": "X", + "data_read_per_join": "X" + } /* cost_info */, + "used_columns": [ + "a", + "i" + ] /* used_columns */, + "ordering_operation": { + "using_filesort": false, + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "range", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "i" + ] /* used_key_parts */, + "key_length": "4", + "rows_examined_per_scan": "X", + "rows_produced_per_join": "X", + "filtered": "X", + "cost_info": { + "read_cost": "X", + "eval_cost": "X", + "prefix_cost": "X", + "data_read_per_join": "X" + } /* cost_info */, + "used_columns": [ + "a", + "i" + ] /* used_columns */, + "attached_condition": "((`test`.`t1`.`i` > 10) and (`test`.`t1`.`i` <= 18))" + } /* table */ + } /* ordering_operation */ + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`i` AS `i` from `test`.`t1` where ((`test`.`t1`.`i` > 10) and (`test`.`t1`.`i` <= 18)) order by `test`.`t1`.`i` limit 1 +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 4 +Handler_read_rnd_next 1 +# Status of testing query execution: +Variable_name Value +Handler_delete 1 +Handler_read_key 3 + +DROP TABLE t1; +#30 +CREATE TABLE t1(a INT, i CHAR(2), INDEX(i(1))) charset utf8mb4; +INSERT INTO t1 (i) VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +# +# query: DELETE FROM t1 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 5 +# select: SELECT * FROM t1 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 5 +# +EXPLAIN DELETE FROM t1 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 26 100.00 Using where; Using filesort +Warnings: +Warning 1739 Cannot use range access on index 'i' due to type or collation conversion on field 'i' +Warning 1739 Cannot use range access on index 'i' due to type or collation conversion on field 'i' +Note 1003 delete from `test`.`t1` where ((`test`.`t1`.`i` > 10) and (`test`.`t1`.`i` <= 18)) order by `test`.`t1`.`i` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t1 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_filesort": true, + "table": { + "delete": true, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 26, + "filtered": "100.00", + "attached_condition": "((`test`.`t1`.`i` > 10) and (`test`.`t1`.`i` <= 18))" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Warning 1739 Cannot use range access on index 'i' due to type or collation conversion on field 'i' +Warning 1739 Cannot use range access on index 'i' due to type or collation conversion on field 'i' +Note 1003 delete from `test`.`t1` where ((`test`.`t1`.`i` > 10) and (`test`.`t1`.`i` <= 18)) order by `test`.`t1`.`i` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "5.74" + } /* cost_info */, + "ordering_operation": { + "using_filesort": true, + "cost_info": { + "sort_cost": "2.89" + } /* cost_info */, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 26, + "rows_produced_per_join": 2, + "filtered": "11.11", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "2.56", + "eval_cost": "0.29", + "prefix_cost": "2.85", + "data_read_per_join": "69" + } /* cost_info */, + "used_columns": [ + "a", + "i" + ] /* used_columns */, + "ordering_operation": { + "using_filesort": true, + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "ALL", + "possible_keys": [ + "i" + ] /* possible_keys */, + "rows_examined_per_scan": 26, + "rows_produced_per_join": 2, + "filtered": "11.11", + "cost_info": { + "read_cost": "2.56", + "eval_cost": "0.29", + "prefix_cost": "2.85", + "data_read_per_join": "46" + } /* cost_info */, + "used_columns": [ + "a", + "i" + ] /* used_columns */, + "attached_condition": "((`test`.`t1`.`i` > 10) and (`test`.`t1`.`i` <= 18))" + } /* table */ + } /* ordering_operation */ + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Warning 1739 Cannot use range access on index 'i' due to type or collation conversion on field 'i' +Warning 1739 Cannot use range access on index 'i' due to type or collation conversion on field 'i' +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`i` AS `i` from `test`.`t1` where ((`test`.`t1`.`i` > 10) and (`test`.`t1`.`i` <= 18)) order by `test`.`t1`.`i` limit 5 +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 3 +Handler_read_rnd_next 27 +Sort_rows 5 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_delete 5 +Handler_read_first 1 +Handler_read_key 8 +Handler_read_rnd 5 +Handler_read_rnd_next 27 +Sort_rows 8 +Sort_scan 1 + +DROP TABLE t1; +#31 +CREATE TABLE t1 (i INT); +INSERT INTO t1 (i) VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2(a INT, b INT, c INT, d INT, INDEX(a, b, c)); +INSERT INTO t2 (a, b, c) SELECT i, i, i FROM t1; +# +# query: DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# select: SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# +EXPLAIN DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t2 NULL ALL NULL NULL NULL NULL 26 100.00 Using where; Using filesort +Warnings: +Note 1003 delete from `test`.`t2` where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_filesort": true, + "table": { + "delete": true, + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 26, + "filtered": "100.00", + "attached_condition": "(`test`.`t2`.`b` = 10)" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 delete from `test`.`t2` where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "2.85" + } /* cost_info */, + "ordering_operation": { + "using_filesort": false, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 2, + "filtered": "10.00", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "2.59", + "eval_cost": "0.26", + "prefix_cost": "2.85", + "data_read_per_join": "62" + } /* cost_info */, + "used_columns": [ + "a", + "b", + "c", + "d" + ] /* used_columns */, + "ordering_operation": { + "using_filesort": false, + "table": { + "select_id": 2, + "table_name": "t2", + "access_type": "index", + "key": "a", + "used_key_parts": [ + "a", + "b", + "c" + ] /* used_key_parts */, + "key_length": "15", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 2, + "filtered": "10.00", + "cost_info": { + "read_cost": "2.59", + "eval_cost": "0.26", + "prefix_cost": "2.85", + "data_read_per_join": "62" + } /* cost_info */, + "used_columns": [ + "a", + "b", + "c", + "d" + ] /* used_columns */, + "attached_condition": "(`test`.`t2`.`b` = 10)" + } /* table */ + } /* ordering_operation */ + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c`,`test`.`t2`.`d` AS `d` from `test`.`t2` where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 5 +Handler_read_rnd_next 27 +# Status of testing query execution: +Variable_name Value +Handler_delete 1 +Handler_read_first 1 +Handler_read_key 6 +Handler_read_rnd 1 +Handler_read_rnd_next 27 +Sort_rows 1 +Sort_scan 1 + +DROP TABLE t1, t2; +#32 +CREATE TABLE t1 (i INT); +INSERT INTO t1 (i) VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2(a INT, b INT, c INT, d INT, INDEX(a, b, c)); +INSERT INTO t2 (a, b, c) SELECT i, i, i FROM t1; +INSERT INTO t2 (a, b, c) SELECT t1.i, t1.i, t1.i FROM t1, t1 x1, t1 x2; +# +# query: DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# select: SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# +EXPLAIN DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t2 NULL index NULL a 15 NULL X 100.00 Using where +Warnings: +Note 1003 delete from `test`.`t2` where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_filesort": false, + "table": { + "delete": true, + "table_name": "t2", + "access_type": "index", + "key": "a", + "used_key_parts": [ + "a", + "b", + "c" + ] /* used_key_parts */, + "key_length": "15", + "rows_examined_per_scan": "X", + "filtered": "X", + "attached_condition": "(`test`.`t2`.`b` = 10)" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 delete from `test`.`t2` where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "X" + } /* cost_info */, + "ordering_operation": { + "using_filesort": false, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": "X", + "rows_produced_per_join": "X", + "filtered": "X", + "parallel_execute": "4 workers", + "cost_info": { + "read_cost": "X", + "eval_cost": "X", + "prefix_cost": "X", + "data_read_per_join": "X" + } /* cost_info */, + "used_columns": [ + "a", + "b", + "c", + "d" + ] /* used_columns */, + "ordering_operation": { + "using_filesort": false, + "table": { + "select_id": 2, + "table_name": "t2", + "access_type": "index", + "key": "a", + "used_key_parts": [ + "a", + "b", + "c" + ] /* used_key_parts */, + "key_length": "15", + "rows_examined_per_scan": "X", + "rows_produced_per_join": "X", + "filtered": "X", + "cost_info": { + "read_cost": "X", + "eval_cost": "X", + "prefix_cost": "X", + "data_read_per_join": "X" + } /* cost_info */, + "used_columns": [ + "a", + "b", + "c", + "d" + ] /* used_columns */, + "attached_condition": "(`test`.`t2`.`b` = 10)" + } /* table */ + } /* ordering_operation */ + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c`,`test`.`t2`.`d` AS `d` from `test`.`t2` where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 5 +Handler_read_rnd_next 16936 +# Status of testing query execution: +Variable_name Value +Handler_delete 5 +Handler_read_first 1 +Handler_read_key 5 +Handler_read_next 4 + +DROP TABLE t1, t2; +#33 +CREATE TABLE t1 (i INT); +INSERT INTO t1 (i) VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2 (a CHAR(2), b CHAR(2), c CHAR(2), d CHAR(2), INDEX (a,b(1),c)) +charset utf8mb4; +INSERT INTO t2 SELECT i, i, i, i FROM t1; +# +# query: DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# select: SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# +EXPLAIN DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t2 NULL ALL NULL NULL NULL NULL 26 100.00 Using where; Using filesort +Warnings: +Warning 1739 Cannot use range access on index 'a' due to type or collation conversion on field 'b' +Note 1003 delete from `test`.`t2` where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_filesort": true, + "table": { + "delete": true, + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 26, + "filtered": "100.00", + "attached_condition": "(`test`.`t2`.`b` = 10)" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Warning 1739 Cannot use range access on index 'a' due to type or collation conversion on field 'b' +Note 1003 delete from `test`.`t2` where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "5.45" + } /* cost_info */, + "ordering_operation": { + "using_filesort": true, + "cost_info": { + "sort_cost": "2.60" + } /* cost_info */, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 26, + "rows_produced_per_join": 2, + "filtered": "10.00", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "2.59", + "eval_cost": "0.26", + "prefix_cost": "2.85", + "data_read_per_join": "104" + } /* cost_info */, + "used_columns": [ + "a", + "b", + "c", + "d" + ] /* used_columns */, + "ordering_operation": { + "using_filesort": true, + "table": { + "select_id": 2, + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 26, + "rows_produced_per_join": 2, + "filtered": "10.00", + "cost_info": { + "read_cost": "2.59", + "eval_cost": "0.26", + "prefix_cost": "2.85", + "data_read_per_join": "104" + } /* cost_info */, + "used_columns": [ + "a", + "b", + "c", + "d" + ] /* used_columns */, + "attached_condition": "(`test`.`t2`.`b` = 10)" + } /* table */ + } /* ordering_operation */ + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c`,`test`.`t2`.`d` AS `d` from `test`.`t2` where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 5 +Handler_read_rnd_next 27 +Sort_rows 1 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_delete 1 +Handler_read_first 1 +Handler_read_key 6 +Handler_read_rnd 1 +Handler_read_rnd_next 27 +Sort_rows 1 +Sort_scan 1 + +DROP TABLE t1, t2; +#34 +CREATE TABLE t1 (i INT); +INSERT INTO t1 (i) VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2 (a CHAR(2), b CHAR(2), c CHAR(2), d CHAR(2), INDEX (a,b,c)) +charset utf8mb4 ENGINE=HEAP; +INSERT INTO t2 SELECT i, i, i, i FROM t1; +# +# query: DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# select: SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# +EXPLAIN DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t2 NULL ALL NULL NULL NULL NULL 26 100.00 Using where; Using filesort +Warnings: +Warning 1739 Cannot use range access on index 'a' due to type or collation conversion on field 'b' +Note 1003 delete from `test`.`t2` where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_filesort": true, + "table": { + "delete": true, + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 26, + "filtered": "100.00", + "attached_condition": "(`test`.`t2`.`b` = 10)" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Warning 1739 Cannot use range access on index 'a' due to type or collation conversion on field 'b' +Note 1003 delete from `test`.`t2` where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "8.02" + } /* cost_info */, + "ordering_operation": { + "using_filesort": true, + "cost_info": { + "sort_cost": "2.60" + } /* cost_info */, + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 26, + "rows_produced_per_join": 2, + "filtered": "10.00", + "cost_info": { + "read_cost": "5.16", + "eval_cost": "0.26", + "prefix_cost": "5.42", + "data_read_per_join": "104" + } /* cost_info */, + "used_columns": [ + "a", + "b", + "c", + "d" + ] /* used_columns */, + "attached_condition": "(`test`.`t2`.`b` = 10)" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Warning 1739 Cannot use range access on index 'a' due to type or collation conversion on field 'b' +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c`,`test`.`t2`.`d` AS `d` from `test`.`t2` where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 4 +Handler_read_rnd_next 27 +Sort_rows 1 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_delete 1 +Handler_read_key 4 +Handler_read_rnd 1 +Handler_read_rnd_next 27 +Sort_rows 1 +Sort_scan 1 + +DROP TABLE t1, t2; +#35 +CREATE TABLE t1 (i INT); +INSERT INTO t1 (i) VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35),(36),(37),(38),(39), +(40),(41),(42),(43),(44); +CREATE TABLE t2 (i INT, key1 INT, key2 INT, INDEX (key1), INDEX (key2)); +INSERT INTO t2 (key1, key2) SELECT i, i FROM t1; +# +# query: DELETE FROM t2 WHERE key1 < 13 or key2 < 14 ORDER BY key1 +# select: SELECT * FROM t2 WHERE key1 < 13 or key2 < 14 ORDER BY key1 +# +EXPLAIN DELETE FROM t2 WHERE key1 < 13 or key2 < 14 ORDER BY key1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t2 NULL index_merge key1,key2 key1,key2 5,5 NULL X 100.00 Using sort_union(key1,key2); Using where; Using filesort +Warnings: +Note 1003 delete from `test`.`t2` where ((`test`.`t2`.`key1` < 13) or (`test`.`t2`.`key2` < 14)) order by `test`.`t2`.`key1` +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t2 WHERE key1 < 13 or key2 < 14 ORDER BY key1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_filesort": true, + "table": { + "delete": true, + "table_name": "t2", + "access_type": "index_merge", + "possible_keys": [ + "key1", + "key2" + ] /* possible_keys */, + "key": "sort_union(key1,key2)", + "key_length": "5,5", + "rows_examined_per_scan": "X", + "filtered": "X", + "attached_condition": "((`test`.`t2`.`key1` < 13) or (`test`.`t2`.`key2` < 14))" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 delete from `test`.`t2` where ((`test`.`t2`.`key1` < 13) or (`test`.`t2`.`key2` < 14)) order by `test`.`t2`.`key1` +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t2 WHERE key1 < 13 or key2 < 14 ORDER BY key1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "X" + } /* cost_info */, + "ordering_operation": { + "using_filesort": true, + "cost_info": { + "sort_cost": "X" + } /* cost_info */, + "table": { + "table_name": "t2", + "access_type": "index_merge", + "possible_keys": [ + "key1", + "key2" + ] /* possible_keys */, + "key": "sort_union(key1,key2)", + "key_length": "5,5", + "rows_examined_per_scan": "X", + "rows_produced_per_join": "X", + "filtered": "X", + "cost_info": { + "read_cost": "X", + "eval_cost": "X", + "prefix_cost": "X", + "data_read_per_join": "X" + } /* cost_info */, + "used_columns": [ + "i", + "key1", + "key2" + ] /* used_columns */, + "attached_condition": "((`test`.`t2`.`key1` < 13) or (`test`.`t2`.`key2` < 14))" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`i` AS `i`,`test`.`t2`.`key1` AS `key1`,`test`.`t2`.`key2` AS `key2` from `test`.`t2` where ((`test`.`t2`.`key1` < 13) or (`test`.`t2`.`key2` < 14)) order by `test`.`t2`.`key1` +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 9 +Handler_read_next 7 +Handler_read_rnd 4 +Sort_rows 4 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_delete 4 +Handler_read_key 13 +Handler_read_next 7 +Handler_read_rnd 8 +Sort_rows 4 +Sort_scan 1 + +DROP TABLE t1, t2; +#36 +CREATE TABLE t1 (i INT); +INSERT INTO t1 (i) VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2(a INT, i INT PRIMARY KEY); +INSERT INTO t2 (i) SELECT i FROM t1; +# +# query: DELETE FROM t2 WHERE i > 10 AND i <= 18 ORDER BY i DESC LIMIT 1 +# select: SELECT * FROM t2 WHERE i > 10 AND i <= 18 ORDER BY i DESC LIMIT 1 +# +EXPLAIN DELETE FROM t2 WHERE i > 10 AND i <= 18 ORDER BY i DESC LIMIT 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t2 NULL range PRIMARY PRIMARY 4 const X 100.00 Using where; Backward index scan +Warnings: +Note 1003 delete from `test`.`t2` where ((`test`.`t2`.`i` > 10) and (`test`.`t2`.`i` <= 18)) order by `test`.`t2`.`i` desc limit 1 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t2 WHERE i > 10 AND i <= 18 ORDER BY i DESC LIMIT 1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_filesort": false, + "table": { + "delete": true, + "table_name": "t2", + "access_type": "range", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "i" + ] /* used_key_parts */, + "key_length": "4", + "ref": [ + "const" + ] /* ref */, + "rows_examined_per_scan": "X", + "filtered": "X", + "backward_index_scan": true, + "attached_condition": "((`test`.`t2`.`i` > 10) and (`test`.`t2`.`i` <= 18))" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 delete from `test`.`t2` where ((`test`.`t2`.`i` > 10) and (`test`.`t2`.`i` <= 18)) order by `test`.`t2`.`i` desc limit 1 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t2 WHERE i > 10 AND i <= 18 ORDER BY i DESC LIMIT 1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "X" + } /* cost_info */, + "ordering_operation": { + "using_filesort": false, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": "X", + "rows_produced_per_join": "X", + "filtered": "X", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "X", + "eval_cost": "X", + "prefix_cost": "X", + "data_read_per_join": "X" + } /* cost_info */, + "used_columns": [ + "a", + "i" + ] /* used_columns */, + "ordering_operation": { + "using_filesort": false, + "table": { + "select_id": 2, + "table_name": "t2", + "access_type": "range", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "i" + ] /* used_key_parts */, + "key_length": "4", + "rows_examined_per_scan": "X", + "rows_produced_per_join": "X", + "filtered": "X", + "backward_index_scan": true, + "cost_info": { + "read_cost": "X", + "eval_cost": "X", + "prefix_cost": "X", + "data_read_per_join": "X" + } /* cost_info */, + "used_columns": [ + "a", + "i" + ] /* used_columns */, + "attached_condition": "((`test`.`t2`.`i` > 10) and (`test`.`t2`.`i` <= 18))" + } /* table */ + } /* ordering_operation */ + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`i` AS `i` from `test`.`t2` where ((`test`.`t2`.`i` > 10) and (`test`.`t2`.`i` <= 18)) order by `test`.`t2`.`i` desc limit 1 +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 4 +Handler_read_rnd_next 1 +# Status of testing query execution: +Variable_name Value +Handler_delete 1 +Handler_read_key 3 + +DROP TABLE t1, t2; +#37 +CREATE TABLE t1 (i INT); +INSERT INTO t1 (i) VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2 (a CHAR(2), b CHAR(2), c CHAR(2), INDEX (a, b)) charset utf8mb4; +INSERT INTO t2 SELECT i, i, i FROM t1; +# +# query: DELETE FROM t2 ORDER BY a, b DESC LIMIT 5 +# select: SELECT * FROM t2 ORDER BY a, b DESC LIMIT 5 +# +EXPLAIN DELETE FROM t2 ORDER BY a, b DESC LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t2 NULL ALL NULL NULL NULL NULL 26 100.00 Using filesort +Warnings: +Note 1003 delete from `test`.`t2` order by `test`.`t2`.`a`,`test`.`t2`.`b` desc limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t2 ORDER BY a, b DESC LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_filesort": true, + "table": { + "delete": true, + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 26, + "filtered": "100.00" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 delete from `test`.`t2` order by `test`.`t2`.`a`,`test`.`t2`.`b` desc limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t2 ORDER BY a, b DESC LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "2.85" + } /* cost_info */, + "ordering_operation": { + "using_filesort": true, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 26, + "rows_produced_per_join": 26, + "filtered": "100.00", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "2.60", + "prefix_cost": "2.85", + "data_read_per_join": "832" + } /* cost_info */, + "used_columns": [ + "a", + "b", + "c" + ] /* used_columns */, + "ordering_operation": { + "using_filesort": true, + "table": { + "select_id": 2, + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 26, + "rows_produced_per_join": 26, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "2.60", + "prefix_cost": "2.85", + "data_read_per_join": "832" + } /* cost_info */, + "used_columns": [ + "a", + "b", + "c" + ] /* used_columns */ + } /* table */ + } /* ordering_operation */ + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c` from `test`.`t2` order by `test`.`t2`.`a`,`test`.`t2`.`b` desc limit 5 +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 4 +Handler_read_rnd_next 27 +Sort_rows 5 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_delete 5 +Handler_read_first 1 +Handler_read_key 9 +Handler_read_rnd 5 +Handler_read_rnd_next 27 +Sort_rows 26 +Sort_scan 1 + +DROP TABLE t1, t2; +#38 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2 (a CHAR(2), b CHAR(2), c INT, INDEX (a, b)) charset utf8mb4; +INSERT INTO t2 (a, b) SELECT i, i FROM t1; +INSERT INTO t2 (a, b) SELECT t1.i, t1.i FROM t1, t1 x1, t1 x2; +# +# query: DELETE FROM t2 ORDER BY a DESC, b DESC LIMIT 5 +# select: SELECT * FROM t2 ORDER BY a DESC, b DESC LIMIT 5 +# +EXPLAIN DELETE FROM t2 ORDER BY a DESC, b DESC LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t2 NULL index NULL a 18 NULL X 100.00 NULL +Warnings: +Note 1003 delete from `test`.`t2` order by `test`.`t2`.`a` desc,`test`.`t2`.`b` desc limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t2 ORDER BY a DESC, b DESC LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_filesort": false, + "table": { + "delete": true, + "table_name": "t2", + "access_type": "index", + "key": "a", + "used_key_parts": [ + "a", + "b" + ] /* used_key_parts */, + "key_length": "18", + "rows_examined_per_scan": "X", + "filtered": "X" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 delete from `test`.`t2` order by `test`.`t2`.`a` desc,`test`.`t2`.`b` desc limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t2 ORDER BY a DESC, b DESC LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "X" + } /* cost_info */, + "ordering_operation": { + "using_filesort": false, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": "X", + "rows_produced_per_join": "X", + "filtered": "X", + "backward_index_scan": true, + "parallel_execute": "4 workers", + "cost_info": { + "read_cost": "X", + "eval_cost": "X", + "prefix_cost": "X", + "data_read_per_join": "X" + } /* cost_info */, + "used_columns": [ + "a", + "b", + "c" + ] /* used_columns */, + "ordering_operation": { + "using_filesort": false, + "table": { + "select_id": 2, + "table_name": "t2", + "access_type": "index", + "key": "a", + "used_key_parts": [ + "a", + "b" + ] /* used_key_parts */, + "key_length": "18", + "rows_examined_per_scan": "X", + "rows_produced_per_join": "X", + "filtered": "X", + "backward_index_scan": true, + "cost_info": { + "read_cost": "X", + "eval_cost": "X", + "prefix_cost": "X", + "data_read_per_join": "X" + } /* cost_info */, + "used_columns": [ + "a", + "b", + "c" + ] /* used_columns */ + } /* table */ + } /* ordering_operation */ + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c` from `test`.`t2` order by `test`.`t2`.`a` desc,`test`.`t2`.`b` desc limit 5 +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 4 +Handler_read_last 1 +Handler_read_rnd_next 20 +# Status of testing query execution: +Variable_name Value +Handler_delete 5 +Handler_read_key 4 +Handler_read_last 1 +Handler_read_prev 4 + +DROP TABLE t1, t2; +#39 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2(a INT, i INT PRIMARY KEY); +INSERT INTO t2 (i) SELECT i FROM t1; +# +# query: UPDATE t2 SET a = 10 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 1 +# select: SELECT * FROM t2 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 1 +# +EXPLAIN UPDATE t2 SET a = 10 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t2 NULL range PRIMARY PRIMARY 4 const X 100.00 Using where; Using temporary +Warnings: +Note 1003 update `test`.`t2` set `test`.`t2`.`a` = 10 where ((`test`.`t2`.`i` > 10) and (`test`.`t2`.`i` <= 18)) order by `test`.`t2`.`i` limit 1 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t2 SET a = 10 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_temporary_table": true, + "using_filesort": false, + "table": { + "update": true, + "table_name": "t2", + "access_type": "range", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "i" + ] /* used_key_parts */, + "key_length": "4", + "ref": [ + "const" + ] /* ref */, + "rows_examined_per_scan": "X", + "filtered": "X", + "attached_condition": "((`test`.`t2`.`i` > 10) and (`test`.`t2`.`i` <= 18))" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t2` set `test`.`t2`.`a` = 10 where ((`test`.`t2`.`i` > 10) and (`test`.`t2`.`i` <= 18)) order by `test`.`t2`.`i` limit 1 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t2 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "X" + } /* cost_info */, + "ordering_operation": { + "using_filesort": false, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": "X", + "rows_produced_per_join": "X", + "filtered": "X", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "X", + "eval_cost": "X", + "prefix_cost": "X", + "data_read_per_join": "X" + } /* cost_info */, + "used_columns": [ + "a", + "i" + ] /* used_columns */, + "ordering_operation": { + "using_filesort": false, + "table": { + "select_id": 2, + "table_name": "t2", + "access_type": "range", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "i" + ] /* used_key_parts */, + "key_length": "4", + "rows_examined_per_scan": "X", + "rows_produced_per_join": "X", + "filtered": "X", + "cost_info": { + "read_cost": "X", + "eval_cost": "X", + "prefix_cost": "X", + "data_read_per_join": "X" + } /* cost_info */, + "used_columns": [ + "a", + "i" + ] /* used_columns */, + "attached_condition": "((`test`.`t2`.`i` > 10) and (`test`.`t2`.`i` <= 18))" + } /* table */ + } /* ordering_operation */ + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`i` AS `i` from `test`.`t2` where ((`test`.`t2`.`i` > 10) and (`test`.`t2`.`i` <= 18)) order by `test`.`t2`.`i` limit 1 +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 4 +Handler_read_rnd_next 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 4 +Handler_read_rnd 1 +Handler_update 1 + +DROP TABLE t1, t2; +#40 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2(a INT, i CHAR(2), INDEX(i(1))) charset utf8mb4; +INSERT INTO t2 (i) SELECT i FROM t1; +# +# query: UPDATE t2 SET a = 10 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 5 +# select: SELECT * FROM t2 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 5 +# +EXPLAIN UPDATE t2 SET a = 10 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t2 NULL ALL NULL NULL NULL NULL 26 100.00 Using where; Using filesort +Warnings: +Warning 1739 Cannot use range access on index 'i' due to type or collation conversion on field 'i' +Warning 1739 Cannot use range access on index 'i' due to type or collation conversion on field 'i' +Note 1003 update `test`.`t2` set `test`.`t2`.`a` = 10 where ((`test`.`t2`.`i` > 10) and (`test`.`t2`.`i` <= 18)) order by `test`.`t2`.`i` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t2 SET a = 10 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_filesort": true, + "table": { + "update": true, + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 26, + "filtered": "100.00", + "attached_condition": "((`test`.`t2`.`i` > 10) and (`test`.`t2`.`i` <= 18))" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Warning 1739 Cannot use range access on index 'i' due to type or collation conversion on field 'i' +Warning 1739 Cannot use range access on index 'i' due to type or collation conversion on field 'i' +Note 1003 update `test`.`t2` set `test`.`t2`.`a` = 10 where ((`test`.`t2`.`i` > 10) and (`test`.`t2`.`i` <= 18)) order by `test`.`t2`.`i` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t2 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "5.74" + } /* cost_info */, + "ordering_operation": { + "using_filesort": true, + "cost_info": { + "sort_cost": "2.89" + } /* cost_info */, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 26, + "rows_produced_per_join": 2, + "filtered": "11.11", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "2.56", + "eval_cost": "0.29", + "prefix_cost": "2.85", + "data_read_per_join": "69" + } /* cost_info */, + "used_columns": [ + "a", + "i" + ] /* used_columns */, + "ordering_operation": { + "using_filesort": true, + "table": { + "select_id": 2, + "table_name": "t2", + "access_type": "ALL", + "possible_keys": [ + "i" + ] /* possible_keys */, + "rows_examined_per_scan": 26, + "rows_produced_per_join": 2, + "filtered": "11.11", + "cost_info": { + "read_cost": "2.56", + "eval_cost": "0.29", + "prefix_cost": "2.85", + "data_read_per_join": "46" + } /* cost_info */, + "used_columns": [ + "a", + "i" + ] /* used_columns */, + "attached_condition": "((`test`.`t2`.`i` > 10) and (`test`.`t2`.`i` <= 18))" + } /* table */ + } /* ordering_operation */ + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Warning 1739 Cannot use range access on index 'i' due to type or collation conversion on field 'i' +Warning 1739 Cannot use range access on index 'i' due to type or collation conversion on field 'i' +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`i` AS `i` from `test`.`t2` where ((`test`.`t2`.`i` > 10) and (`test`.`t2`.`i` <= 18)) order by `test`.`t2`.`i` limit 5 +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 3 +Handler_read_rnd_next 27 +Sort_rows 5 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 8 +Handler_read_rnd 5 +Handler_read_rnd_next 27 +Handler_update 5 +Sort_rows 5 +Sort_scan 1 + +DROP TABLE t1, t2; +#41 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2(a INT, b INT, c INT, d INT, INDEX(a, b, c)); +INSERT INTO t2 (a, b, c) SELECT i, i, i FROM t1; +# +# query: UPDATE t2 SET d = 10 WHERE b = 10 ORDER BY a, c LIMIT 5 +# select: SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# +EXPLAIN UPDATE t2 SET d = 10 WHERE b = 10 ORDER BY a, c LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t2 NULL ALL NULL NULL NULL NULL 26 100.00 Using where; Using filesort +Warnings: +Note 1003 update `test`.`t2` set `test`.`t2`.`d` = 10 where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t2 SET d = 10 WHERE b = 10 ORDER BY a, c LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_filesort": true, + "table": { + "update": true, + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 26, + "filtered": "100.00", + "attached_condition": "(`test`.`t2`.`b` = 10)" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t2` set `test`.`t2`.`d` = 10 where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "2.85" + } /* cost_info */, + "ordering_operation": { + "using_filesort": false, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 2, + "filtered": "10.00", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "2.59", + "eval_cost": "0.26", + "prefix_cost": "2.85", + "data_read_per_join": "62" + } /* cost_info */, + "used_columns": [ + "a", + "b", + "c", + "d" + ] /* used_columns */, + "ordering_operation": { + "using_filesort": false, + "table": { + "select_id": 2, + "table_name": "t2", + "access_type": "index", + "key": "a", + "used_key_parts": [ + "a", + "b", + "c" + ] /* used_key_parts */, + "key_length": "15", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 2, + "filtered": "10.00", + "cost_info": { + "read_cost": "2.59", + "eval_cost": "0.26", + "prefix_cost": "2.85", + "data_read_per_join": "62" + } /* cost_info */, + "used_columns": [ + "a", + "b", + "c", + "d" + ] /* used_columns */, + "attached_condition": "(`test`.`t2`.`b` = 10)" + } /* table */ + } /* ordering_operation */ + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c`,`test`.`t2`.`d` AS `d` from `test`.`t2` where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 5 +Handler_read_rnd_next 27 +# Status of testing query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 6 +Handler_read_rnd 1 +Handler_read_rnd_next 27 +Handler_update 1 +Sort_rows 1 +Sort_scan 1 + +DROP TABLE t1, t2; +#42 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2(a INT, b INT, c INT, d INT, INDEX(a, b, c)); +INSERT INTO t2 (a, b, c) SELECT i, i, i FROM t1; +INSERT INTO t2 (a, b, c) SELECT t1.i, t1.i, t1.i FROM t1, t1 x1, t1 x2; +# +# query: UPDATE t2 SET d = 10 WHERE b = 10 ORDER BY a, c LIMIT 5 +# select: SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# +EXPLAIN UPDATE t2 SET d = 10 WHERE b = 10 ORDER BY a, c LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t2 NULL index NULL a 15 NULL X 100.00 Using where; Using temporary +Warnings: +Note 1003 update `test`.`t2` set `test`.`t2`.`d` = 10 where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t2 SET d = 10 WHERE b = 10 ORDER BY a, c LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_temporary_table": true, + "using_filesort": false, + "table": { + "update": true, + "table_name": "t2", + "access_type": "index", + "key": "a", + "used_key_parts": [ + "a", + "b", + "c" + ] /* used_key_parts */, + "key_length": "15", + "rows_examined_per_scan": "X", + "filtered": "X", + "attached_condition": "(`test`.`t2`.`b` = 10)" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t2` set `test`.`t2`.`d` = 10 where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "X" + } /* cost_info */, + "ordering_operation": { + "using_filesort": false, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": "X", + "rows_produced_per_join": "X", + "filtered": "X", + "parallel_execute": "4 workers", + "cost_info": { + "read_cost": "X", + "eval_cost": "X", + "prefix_cost": "X", + "data_read_per_join": "X" + } /* cost_info */, + "used_columns": [ + "a", + "b", + "c", + "d" + ] /* used_columns */, + "ordering_operation": { + "using_filesort": false, + "table": { + "select_id": 2, + "table_name": "t2", + "access_type": "index", + "key": "a", + "used_key_parts": [ + "a", + "b", + "c" + ] /* used_key_parts */, + "key_length": "15", + "rows_examined_per_scan": "X", + "rows_produced_per_join": "X", + "filtered": "X", + "cost_info": { + "read_cost": "X", + "eval_cost": "X", + "prefix_cost": "X", + "data_read_per_join": "X" + } /* cost_info */, + "used_columns": [ + "a", + "b", + "c", + "d" + ] /* used_columns */, + "attached_condition": "(`test`.`t2`.`b` = 10)" + } /* table */ + } /* ordering_operation */ + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c`,`test`.`t2`.`d` AS `d` from `test`.`t2` where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 5 +Handler_read_rnd_next 16936 +# Status of testing query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 10 +Handler_read_next 4 +Handler_read_rnd 5 +Handler_update 5 + +DROP TABLE t1, t2; +#43 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2 (a CHAR(2), b CHAR(2), c CHAR(2), d CHAR(2), INDEX (a,b(1),c)) +charset utf8mb4; +INSERT INTO t2 SELECT i, i, i, i FROM t1; +# +# query: UPDATE t2 SET d = 10 WHERE b = 10 ORDER BY a, c LIMIT 5 +# select: SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# +EXPLAIN UPDATE t2 SET d = 10 WHERE b = 10 ORDER BY a, c LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t2 NULL ALL NULL NULL NULL NULL 26 100.00 Using where; Using filesort +Warnings: +Warning 1739 Cannot use range access on index 'a' due to type or collation conversion on field 'b' +Note 1003 update `test`.`t2` set `test`.`t2`.`d` = 10 where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t2 SET d = 10 WHERE b = 10 ORDER BY a, c LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_filesort": true, + "table": { + "update": true, + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 26, + "filtered": "100.00", + "attached_condition": "(`test`.`t2`.`b` = 10)" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Warning 1739 Cannot use range access on index 'a' due to type or collation conversion on field 'b' +Note 1003 update `test`.`t2` set `test`.`t2`.`d` = 10 where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "5.45" + } /* cost_info */, + "ordering_operation": { + "using_filesort": true, + "cost_info": { + "sort_cost": "2.60" + } /* cost_info */, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 26, + "rows_produced_per_join": 2, + "filtered": "10.00", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "2.59", + "eval_cost": "0.26", + "prefix_cost": "2.85", + "data_read_per_join": "104" + } /* cost_info */, + "used_columns": [ + "a", + "b", + "c", + "d" + ] /* used_columns */, + "ordering_operation": { + "using_filesort": true, + "table": { + "select_id": 2, + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 26, + "rows_produced_per_join": 2, + "filtered": "10.00", + "cost_info": { + "read_cost": "2.59", + "eval_cost": "0.26", + "prefix_cost": "2.85", + "data_read_per_join": "104" + } /* cost_info */, + "used_columns": [ + "a", + "b", + "c", + "d" + ] /* used_columns */, + "attached_condition": "(`test`.`t2`.`b` = 10)" + } /* table */ + } /* ordering_operation */ + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c`,`test`.`t2`.`d` AS `d` from `test`.`t2` where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 5 +Handler_read_rnd_next 27 +Sort_rows 1 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 6 +Handler_read_rnd 1 +Handler_read_rnd_next 27 +Sort_rows 1 +Sort_scan 1 + +DROP TABLE t1, t2; +#44 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2 (a CHAR(2), b CHAR(2), c CHAR(2), d CHAR(2), INDEX (a,b,c)) +charset utf8mb4 ENGINE=HEAP; +INSERT INTO t2 SELECT i, i, i, i FROM t1; +# +# query: UPDATE t2 SET d = 10 WHERE b = 10 ORDER BY a, c LIMIT 5 +# select: SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# +EXPLAIN UPDATE t2 SET d = 10 WHERE b = 10 ORDER BY a, c LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t2 NULL ALL NULL NULL NULL NULL 26 100.00 Using where; Using filesort +Warnings: +Warning 1739 Cannot use range access on index 'a' due to type or collation conversion on field 'b' +Note 1003 update `test`.`t2` set `test`.`t2`.`d` = 10 where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t2 SET d = 10 WHERE b = 10 ORDER BY a, c LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_filesort": true, + "table": { + "update": true, + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 26, + "filtered": "100.00", + "attached_condition": "(`test`.`t2`.`b` = 10)" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Warning 1739 Cannot use range access on index 'a' due to type or collation conversion on field 'b' +Note 1003 update `test`.`t2` set `test`.`t2`.`d` = 10 where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "8.02" + } /* cost_info */, + "ordering_operation": { + "using_filesort": true, + "cost_info": { + "sort_cost": "2.60" + } /* cost_info */, + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 26, + "rows_produced_per_join": 2, + "filtered": "10.00", + "cost_info": { + "read_cost": "5.16", + "eval_cost": "0.26", + "prefix_cost": "5.42", + "data_read_per_join": "104" + } /* cost_info */, + "used_columns": [ + "a", + "b", + "c", + "d" + ] /* used_columns */, + "attached_condition": "(`test`.`t2`.`b` = 10)" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Warning 1739 Cannot use range access on index 'a' due to type or collation conversion on field 'b' +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c`,`test`.`t2`.`d` AS `d` from `test`.`t2` where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 4 +Handler_read_rnd_next 27 +Sort_rows 1 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 4 +Handler_read_rnd 1 +Handler_read_rnd_next 27 +Sort_rows 1 +Sort_scan 1 + +DROP TABLE t1, t2; +#45 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35),(36),(37),(38),(39), +(40),(41),(42),(43),(44); +CREATE TABLE t2 (i INT, key1 INT, key2 INT, INDEX (key1), INDEX (key2)); +INSERT INTO t2 (key1, key2) SELECT i, i FROM t1; +# +# query: UPDATE t2 SET i = 123 WHERE key1 < 13 or key2 < 14 ORDER BY key1 +# select: SELECT * FROM t2 WHERE key1 < 13 or key2 < 14 ORDER BY key1 +# +EXPLAIN UPDATE t2 SET i = 123 WHERE key1 < 13 or key2 < 14 ORDER BY key1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t2 NULL index_merge key1,key2 key1,key2 5,5 NULL X 100.00 Using sort_union(key1,key2); Using where; Using filesort +Warnings: +Note 1003 update `test`.`t2` set `test`.`t2`.`i` = 123 where ((`test`.`t2`.`key1` < 13) or (`test`.`t2`.`key2` < 14)) order by `test`.`t2`.`key1` +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t2 SET i = 123 WHERE key1 < 13 or key2 < 14 ORDER BY key1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_filesort": true, + "table": { + "update": true, + "table_name": "t2", + "access_type": "index_merge", + "possible_keys": [ + "key1", + "key2" + ] /* possible_keys */, + "key": "sort_union(key1,key2)", + "key_length": "5,5", + "rows_examined_per_scan": "X", + "filtered": "X", + "attached_condition": "((`test`.`t2`.`key1` < 13) or (`test`.`t2`.`key2` < 14))" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t2` set `test`.`t2`.`i` = 123 where ((`test`.`t2`.`key1` < 13) or (`test`.`t2`.`key2` < 14)) order by `test`.`t2`.`key1` +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t2 WHERE key1 < 13 or key2 < 14 ORDER BY key1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "X" + } /* cost_info */, + "ordering_operation": { + "using_filesort": true, + "cost_info": { + "sort_cost": "X" + } /* cost_info */, + "table": { + "table_name": "t2", + "access_type": "index_merge", + "possible_keys": [ + "key1", + "key2" + ] /* possible_keys */, + "key": "sort_union(key1,key2)", + "key_length": "5,5", + "rows_examined_per_scan": "X", + "rows_produced_per_join": "X", + "filtered": "X", + "cost_info": { + "read_cost": "X", + "eval_cost": "X", + "prefix_cost": "X", + "data_read_per_join": "X" + } /* cost_info */, + "used_columns": [ + "i", + "key1", + "key2" + ] /* used_columns */, + "attached_condition": "((`test`.`t2`.`key1` < 13) or (`test`.`t2`.`key2` < 14))" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`i` AS `i`,`test`.`t2`.`key1` AS `key1`,`test`.`t2`.`key2` AS `key2` from `test`.`t2` where ((`test`.`t2`.`key1` < 13) or (`test`.`t2`.`key2` < 14)) order by `test`.`t2`.`key1` +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 9 +Handler_read_next 7 +Handler_read_rnd 4 +Sort_rows 4 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 13 +Handler_read_next 7 +Handler_read_rnd 8 +Handler_update 4 +Sort_rows 4 +Sort_scan 1 + +DROP TABLE t1, t2; +#46 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2(a INT, i INT PRIMARY KEY); +INSERT INTO t2 (i) SELECT i FROM t1; +# +# query: UPDATE t2 SET a = 10 WHERE i > 10 AND i <= 18 ORDER BY i DESC LIMIT 1 +# select: SELECT * FROM t2 WHERE i > 10 AND i <= 18 ORDER BY i DESC LIMIT 1 +# +EXPLAIN UPDATE t2 SET a = 10 WHERE i > 10 AND i <= 18 ORDER BY i DESC LIMIT 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t2 NULL range PRIMARY PRIMARY 4 const X 100.00 Using where; Backward index scan; Using temporary +Warnings: +Note 1003 update `test`.`t2` set `test`.`t2`.`a` = 10 where ((`test`.`t2`.`i` > 10) and (`test`.`t2`.`i` <= 18)) order by `test`.`t2`.`i` desc limit 1 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t2 SET a = 10 WHERE i > 10 AND i <= 18 ORDER BY i DESC LIMIT 1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_temporary_table": true, + "using_filesort": false, + "table": { + "update": true, + "table_name": "t2", + "access_type": "range", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "i" + ] /* used_key_parts */, + "key_length": "4", + "ref": [ + "const" + ] /* ref */, + "rows_examined_per_scan": "X", + "filtered": "X", + "backward_index_scan": true, + "attached_condition": "((`test`.`t2`.`i` > 10) and (`test`.`t2`.`i` <= 18))" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t2` set `test`.`t2`.`a` = 10 where ((`test`.`t2`.`i` > 10) and (`test`.`t2`.`i` <= 18)) order by `test`.`t2`.`i` desc limit 1 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t2 WHERE i > 10 AND i <= 18 ORDER BY i DESC LIMIT 1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "X" + } /* cost_info */, + "ordering_operation": { + "using_filesort": false, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": "X", + "rows_produced_per_join": "X", + "filtered": "X", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "X", + "eval_cost": "X", + "prefix_cost": "X", + "data_read_per_join": "X" + } /* cost_info */, + "used_columns": [ + "a", + "i" + ] /* used_columns */, + "ordering_operation": { + "using_filesort": false, + "table": { + "select_id": 2, + "table_name": "t2", + "access_type": "range", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "i" + ] /* used_key_parts */, + "key_length": "4", + "rows_examined_per_scan": "X", + "rows_produced_per_join": "X", + "filtered": "X", + "backward_index_scan": true, + "cost_info": { + "read_cost": "X", + "eval_cost": "X", + "prefix_cost": "X", + "data_read_per_join": "X" + } /* cost_info */, + "used_columns": [ + "a", + "i" + ] /* used_columns */, + "attached_condition": "((`test`.`t2`.`i` > 10) and (`test`.`t2`.`i` <= 18))" + } /* table */ + } /* ordering_operation */ + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`i` AS `i` from `test`.`t2` where ((`test`.`t2`.`i` > 10) and (`test`.`t2`.`i` <= 18)) order by `test`.`t2`.`i` desc limit 1 +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 4 +Handler_read_rnd_next 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 4 +Handler_read_rnd 1 +Handler_update 1 + +DROP TABLE t1, t2; +#47 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2 (a CHAR(2), b CHAR(2), c CHAR(2), INDEX (a, b)) charset utf8mb4; +INSERT INTO t2 SELECT i, i, i FROM t1; +# +# query: UPDATE t2 SET c = 10 ORDER BY a, b DESC LIMIT 5 +# select: SELECT * FROM t2 ORDER BY a, b DESC LIMIT 5 +# +EXPLAIN UPDATE t2 SET c = 10 ORDER BY a, b DESC LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t2 NULL ALL NULL NULL NULL NULL 26 100.00 Using filesort +Warnings: +Note 1003 update `test`.`t2` set `test`.`t2`.`c` = 10 order by `test`.`t2`.`a`,`test`.`t2`.`b` desc limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t2 SET c = 10 ORDER BY a, b DESC LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_filesort": true, + "table": { + "update": true, + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 26, + "filtered": "100.00" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t2` set `test`.`t2`.`c` = 10 order by `test`.`t2`.`a`,`test`.`t2`.`b` desc limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t2 ORDER BY a, b DESC LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "2.85" + } /* cost_info */, + "ordering_operation": { + "using_filesort": true, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 26, + "rows_produced_per_join": 26, + "filtered": "100.00", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "2.60", + "prefix_cost": "2.85", + "data_read_per_join": "832" + } /* cost_info */, + "used_columns": [ + "a", + "b", + "c" + ] /* used_columns */, + "ordering_operation": { + "using_filesort": true, + "table": { + "select_id": 2, + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 26, + "rows_produced_per_join": 26, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "2.60", + "prefix_cost": "2.85", + "data_read_per_join": "832" + } /* cost_info */, + "used_columns": [ + "a", + "b", + "c" + ] /* used_columns */ + } /* table */ + } /* ordering_operation */ + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c` from `test`.`t2` order by `test`.`t2`.`a`,`test`.`t2`.`b` desc limit 5 +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 4 +Handler_read_rnd_next 27 +Sort_rows 5 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 9 +Handler_read_rnd 5 +Handler_read_rnd_next 27 +Handler_update 4 +Sort_rows 5 +Sort_scan 1 + +DROP TABLE t1, t2; +#48 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2 (a CHAR(2), b CHAR(2), c INT, INDEX (a, b)) charset utf8mb4; +INSERT INTO t2 (a, b) SELECT i, i FROM t1; +INSERT INTO t2 (a, b) SELECT t1.i, t1.i FROM t1, t1 x1, t1 x2; +# +# query: UPDATE t2 SET c = 10 ORDER BY a DESC, b DESC LIMIT 5 +# select: SELECT * FROM t2 ORDER BY a DESC, b DESC LIMIT 5 +# +EXPLAIN UPDATE t2 SET c = 10 ORDER BY a DESC, b DESC LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t2 NULL index NULL a 18 NULL X 100.00 Using temporary +Warnings: +Note 1003 update `test`.`t2` set `test`.`t2`.`c` = 10 order by `test`.`t2`.`a` desc,`test`.`t2`.`b` desc limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t2 SET c = 10 ORDER BY a DESC, b DESC LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_temporary_table": true, + "using_filesort": false, + "table": { + "update": true, + "table_name": "t2", + "access_type": "index", + "key": "a", + "used_key_parts": [ + "a", + "b" + ] /* used_key_parts */, + "key_length": "18", + "rows_examined_per_scan": "X", + "filtered": "X" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t2` set `test`.`t2`.`c` = 10 order by `test`.`t2`.`a` desc,`test`.`t2`.`b` desc limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t2 ORDER BY a DESC, b DESC LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "X" + } /* cost_info */, + "ordering_operation": { + "using_filesort": false, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": "X", + "rows_produced_per_join": "X", + "filtered": "X", + "backward_index_scan": true, + "parallel_execute": "4 workers", + "cost_info": { + "read_cost": "X", + "eval_cost": "X", + "prefix_cost": "X", + "data_read_per_join": "X" + } /* cost_info */, + "used_columns": [ + "a", + "b", + "c" + ] /* used_columns */, + "ordering_operation": { + "using_filesort": false, + "table": { + "select_id": 2, + "table_name": "t2", + "access_type": "index", + "key": "a", + "used_key_parts": [ + "a", + "b" + ] /* used_key_parts */, + "key_length": "18", + "rows_examined_per_scan": "X", + "rows_produced_per_join": "X", + "filtered": "X", + "backward_index_scan": true, + "cost_info": { + "read_cost": "X", + "eval_cost": "X", + "prefix_cost": "X", + "data_read_per_join": "X" + } /* cost_info */, + "used_columns": [ + "a", + "b", + "c" + ] /* used_columns */ + } /* table */ + } /* ordering_operation */ + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c` from `test`.`t2` order by `test`.`t2`.`a` desc,`test`.`t2`.`b` desc limit 5 +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 4 +Handler_read_last 1 +Handler_read_rnd_next 20 +# Status of testing query execution: +Variable_name Value +Handler_read_key 9 +Handler_read_last 1 +Handler_read_prev 4 +Handler_read_rnd 5 +Handler_update 5 + +DROP TABLE t1, t2; +#49 +CREATE TABLE t1 ( +pk INT NOT NULL AUTO_INCREMENT, +c1_idx CHAR(1) DEFAULT 'y', +c2 INT, +PRIMARY KEY (pk), +INDEX c1_idx (c1_idx) +) charset utf8mb4; +INSERT INTO t1 VALUES (1,'y',1), (2,'n',2), (3,'y',3), (4,'n',4); +# +# query: UPDATE t1 SET c2 = 0 WHERE c1_idx = 'y' ORDER BY pk DESC LIMIT 2 +# select: SELECT * FROM t1 WHERE c1_idx = 'y' ORDER BY pk DESC LIMIT 2 +# +EXPLAIN UPDATE t1 SET c2 = 0 WHERE c1_idx = 'y' ORDER BY pk DESC LIMIT 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL range c1_idx c1_idx 5 const 2 100.00 Using where; Backward index scan; Using temporary +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`c2` = 0 where (`test`.`t1`.`c1_idx` = 'y') order by `test`.`t1`.`pk` desc limit 2 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t1 SET c2 = 0 WHERE c1_idx = 'y' ORDER BY pk DESC LIMIT 2;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_temporary_table": true, + "using_filesort": false, + "table": { + "update": true, + "table_name": "t1", + "access_type": "range", + "possible_keys": [ + "c1_idx" + ] /* possible_keys */, + "key": "c1_idx", + "used_key_parts": [ + "c1_idx" + ] /* used_key_parts */, + "key_length": "5", + "ref": [ + "const" + ] /* ref */, + "rows_examined_per_scan": 2, + "filtered": "100.00", + "backward_index_scan": true, + "attached_condition": "(`test`.`t1`.`c1_idx` = 'y')" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`c2` = 0 where (`test`.`t1`.`c1_idx` = 'y') order by `test`.`t1`.`pk` desc limit 2 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 WHERE c1_idx = 'y' ORDER BY pk DESC LIMIT 2;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.70" + } /* cost_info */, + "ordering_operation": { + "using_filesort": false, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 2, + "filtered": "100.00", + "backward_index_scan": true, + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.20", + "prefix_cost": "0.70", + "data_read_per_join": "48" + } /* cost_info */, + "used_columns": [ + "pk", + "c1_idx", + "c2" + ] /* used_columns */, + "ordering_operation": { + "using_filesort": false, + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "ref", + "possible_keys": [ + "c1_idx" + ] /* possible_keys */, + "key": "c1_idx", + "used_key_parts": [ + "c1_idx" + ] /* used_key_parts */, + "key_length": "5", + "ref": [ + "const" + ] /* ref */, + "rows_examined_per_scan": 2, + "rows_produced_per_join": 2, + "filtered": "100.00", + "backward_index_scan": true, + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.20", + "prefix_cost": "0.70", + "data_read_per_join": "32" + } /* cost_info */, + "used_columns": [ + "pk", + "c1_idx", + "c2" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`c1_idx` = 'y')" + } /* table */ + } /* ordering_operation */ + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`c1_idx` AS `c1_idx`,`test`.`t1`.`c2` AS `c2` from `test`.`t1` where (`test`.`t1`.`c1_idx` = 'y') order by `test`.`t1`.`pk` desc limit 2 +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 6 +Handler_read_rnd_next 2 +# Status of testing query execution: +Variable_name Value +Handler_read_key 6 +Handler_read_prev 1 +Handler_read_rnd 2 +Handler_update 2 + +# +# query: DELETE FROM t1 WHERE c1_idx = 'y' ORDER BY pk DESC LIMIT 2 +# select: SELECT * FROM t1 WHERE c1_idx = 'y' ORDER BY pk DESC LIMIT 2 +# +EXPLAIN DELETE FROM t1 WHERE c1_idx = 'y' ORDER BY pk DESC LIMIT 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL range c1_idx c1_idx 5 const 2 100.00 Using where; Backward index scan +Warnings: +Note 1003 delete from `test`.`t1` where (`test`.`t1`.`c1_idx` = 'y') order by `test`.`t1`.`pk` desc limit 2 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t1 WHERE c1_idx = 'y' ORDER BY pk DESC LIMIT 2;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_filesort": false, + "table": { + "delete": true, + "table_name": "t1", + "access_type": "range", + "possible_keys": [ + "c1_idx" + ] /* possible_keys */, + "key": "c1_idx", + "used_key_parts": [ + "c1_idx" + ] /* used_key_parts */, + "key_length": "5", + "ref": [ + "const" + ] /* ref */, + "rows_examined_per_scan": 2, + "filtered": "100.00", + "backward_index_scan": true, + "attached_condition": "(`test`.`t1`.`c1_idx` = 'y')" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 delete from `test`.`t1` where (`test`.`t1`.`c1_idx` = 'y') order by `test`.`t1`.`pk` desc limit 2 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 WHERE c1_idx = 'y' ORDER BY pk DESC LIMIT 2;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.70" + } /* cost_info */, + "ordering_operation": { + "using_filesort": false, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 2, + "filtered": "100.00", + "backward_index_scan": true, + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.20", + "prefix_cost": "0.70", + "data_read_per_join": "48" + } /* cost_info */, + "used_columns": [ + "pk", + "c1_idx", + "c2" + ] /* used_columns */, + "ordering_operation": { + "using_filesort": false, + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "ref", + "possible_keys": [ + "c1_idx" + ] /* possible_keys */, + "key": "c1_idx", + "used_key_parts": [ + "c1_idx" + ] /* used_key_parts */, + "key_length": "5", + "ref": [ + "const" + ] /* ref */, + "rows_examined_per_scan": 2, + "rows_produced_per_join": 2, + "filtered": "100.00", + "backward_index_scan": true, + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.20", + "prefix_cost": "0.70", + "data_read_per_join": "32" + } /* cost_info */, + "used_columns": [ + "pk", + "c1_idx", + "c2" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`c1_idx` = 'y')" + } /* table */ + } /* ordering_operation */ + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`c1_idx` AS `c1_idx`,`test`.`t1`.`c2` AS `c2` from `test`.`t1` where (`test`.`t1`.`c1_idx` = 'y') order by `test`.`t1`.`pk` desc limit 2 +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 6 +Handler_read_rnd_next 2 +# Status of testing query execution: +Variable_name Value +Handler_delete 2 +Handler_read_key 4 +Handler_read_prev 1 + +DROP TABLE t1; +#50 +CREATE TABLE t1 (a INT AUTO_INCREMENT PRIMARY KEY); +INSERT INTO t1 VALUES (),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(); +# +# query: UPDATE t1 SET a=a+10 WHERE a > 34 +# select: SELECT * FROM t1 WHERE a > 34 +# +EXPLAIN UPDATE t1 SET a=a+10 WHERE a > 34; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL range PRIMARY PRIMARY 4 const 2 100.00 Using where; Using temporary +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`a` = (`test`.`t1`.`a` + 10) where (`test`.`t1`.`a` > 34) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t1 SET a=a+10 WHERE a > 34;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "table": { + "update": true, + "table_name": "t1", + "access_type": "range", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "a" + ] /* used_key_parts */, + "key_length": "4", + "ref": [ + "const" + ] /* ref */, + "rows_examined_per_scan": 2, + "filtered": "100.00", + "using_temporary_table": "for update", + "attached_condition": "(`test`.`t1`.`a` > 34)" + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`a` = (`test`.`t1`.`a` + 10) where (`test`.`t1`.`a` > 34) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 WHERE a > 34;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.91" + } /* cost_info */, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 2, + "filtered": "100.00", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.71", + "eval_cost": "0.20", + "prefix_cost": "0.91", + "data_read_per_join": "32" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "query_block": { + "cost_info": { + "query_cost": "0.91" + } /* cost_info */, + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "range", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "a" + ] /* used_key_parts */, + "key_length": "4", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 2, + "filtered": "100.00", + "using_index": true, + "cost_info": { + "read_cost": "0.71", + "eval_cost": "0.20", + "prefix_cost": "0.91", + "data_read_per_join": "16" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`a` > 34)" + } /* table */ + } /* query_block */ + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` > 34) +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 3 +Handler_read_last 1 +Handler_read_rnd_next 3 +# Status of testing query execution: +Variable_name Value +Handler_read_key 4 +Handler_read_next 2 +Handler_read_rnd 2 +Handler_update 2 + +DROP TABLE t1; +#51 +CREATE TABLE t1 (c1 INT, c2 INT, c3 INT); +CREATE TABLE t2 (c1 INT, c2 INT); +INSERT INTO t1 VALUES (1, 1, 10), (2, 2, 20); +# +# query: UPDATE t1 LEFT JOIN t2 ON t1.c1 = t2.c1 SET t2.c2 = 10 +# select: SELECT * FROM t1 LEFT JOIN t2 ON t1.c1 = t2.c1 +# +EXPLAIN UPDATE t1 LEFT JOIN t2 ON t1.c1 = t2.c1 SET t2.c2 = 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 UPDATE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 update `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`c1` = `test`.`t1`.`c1`)) set `test`.`t2`.`c2` = 10 where true +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t1 LEFT JOIN t2 ON t1.c1 = t2.c1 SET t2.c2 = 10;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.90" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 2, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.20", + "prefix_cost": "0.45", + "data_read_per_join": "32" + } /* cost_info */, + "used_columns": [ + "c1" + ] /* used_columns */ + } /* table */ + }, + { + "table": { + "update": true, + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 2, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.20", + "prefix_cost": "0.90", + "data_read_per_join": "32" + } /* cost_info */, + "used_columns": [ + "c1", + "c2" + ] /* used_columns */, + "attached_condition": "(is_not_null_compl(t2), (`test`.`t2`.`c1` = `test`.`t1`.`c1`), true)" + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`c1` = `test`.`t1`.`c1`)) set `test`.`t2`.`c2` = 10 where true +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 LEFT JOIN t2 ON t1.c1 = t2.c1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.90" + } /* cost_info */, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 2, + "filtered": "100.00", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.20", + "prefix_cost": "0.45", + "data_read_per_join": "64" + } /* cost_info */, + "used_columns": [ + "c1", + "c2", + "c3", + "c1", + "c2" + ] /* used_columns */, + "query_block": { + "cost_info": { + "query_cost": "0.90" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 2, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.20", + "prefix_cost": "0.45", + "data_read_per_join": "32" + } /* cost_info */, + "used_columns": [ + "c1", + "c2", + "c3" + ] /* used_columns */ + } /* table */ + }, + { + "table": { + "select_id": 2, + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 2, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.20", + "prefix_cost": "0.90", + "data_read_per_join": "32" + } /* cost_info */, + "used_columns": [ + "c1", + "c2" + ] /* used_columns */, + "attached_condition": "(is_not_null_compl(t2), (`test`.`t2`.`c1` = `test`.`t1`.`c1`), true)" + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c1` AS `c1`,`test`.`t1`.`c2` AS `c2`,`test`.`t1`.`c3` AS `c3`,`test`.`t2`.`c1` AS `c1`,`test`.`t2`.`c2` AS `c2` from `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`c1` = `test`.`t1`.`c1`)) where true +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 2 +Handler_read_key 7 +Handler_read_rnd_next 4 +# Status of testing query execution: +Variable_name Value +Handler_read_first 3 +Handler_read_key 8 +Handler_read_rnd_next 5 + +# +# query: UPDATE t1 LEFT JOIN t2 ON t1.c1 = t2.c1 SET t2.c2 = 10 WHERE t1.c3 = 10 +# select: SELECT * FROM t1 LEFT JOIN t2 ON t1.c1 = t2.c1 WHERE t1.c3 = 10 +# +EXPLAIN UPDATE t1 LEFT JOIN t2 ON t1.c1 = t2.c1 SET t2.c2 = 10 WHERE t1.c3 = 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 UPDATE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 update `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`c1` = `test`.`t1`.`c1`)) set `test`.`t2`.`c2` = 10 where (`test`.`t1`.`c3` = 10) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t1 LEFT JOIN t2 ON t1.c1 = t2.c1 SET t2.c2 = 10 WHERE t1.c3 = 10;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.80" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 1, + "filtered": "50.00", + "cost_info": { + "read_cost": "0.35", + "eval_cost": "0.10", + "prefix_cost": "0.45", + "data_read_per_join": "16" + } /* cost_info */, + "used_columns": [ + "c1", + "c3" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`c3` = 10)" + } /* table */ + }, + { + "table": { + "update": true, + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.10", + "prefix_cost": "0.80", + "data_read_per_join": "16" + } /* cost_info */, + "used_columns": [ + "c1", + "c2" + ] /* used_columns */, + "attached_condition": "(is_not_null_compl(t2), (`test`.`t2`.`c1` = `test`.`t1`.`c1`), true)" + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`c1` = `test`.`t1`.`c1`)) set `test`.`t2`.`c2` = 10 where (`test`.`t1`.`c3` = 10) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 LEFT JOIN t2 ON t1.c1 = t2.c1 WHERE t1.c3 = 10;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.80" + } /* cost_info */, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 1, + "filtered": "50.00", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.35", + "eval_cost": "0.10", + "prefix_cost": "0.45", + "data_read_per_join": "32" + } /* cost_info */, + "used_columns": [ + "c1", + "c2", + "c3", + "c1", + "c2" + ] /* used_columns */, + "query_block": { + "cost_info": { + "query_cost": "0.80" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 1, + "filtered": "50.00", + "cost_info": { + "read_cost": "0.35", + "eval_cost": "0.10", + "prefix_cost": "0.45", + "data_read_per_join": "16" + } /* cost_info */, + "used_columns": [ + "c1", + "c2", + "c3" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`c3` = 10)" + } /* table */ + }, + { + "table": { + "select_id": 2, + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.10", + "prefix_cost": "0.80", + "data_read_per_join": "16" + } /* cost_info */, + "used_columns": [ + "c1", + "c2" + ] /* used_columns */, + "attached_condition": "(is_not_null_compl(t2), (`test`.`t2`.`c1` = `test`.`t1`.`c1`), true)" + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c1` AS `c1`,`test`.`t1`.`c2` AS `c2`,`test`.`t1`.`c3` AS `c3`,`test`.`t2`.`c1` AS `c1`,`test`.`t2`.`c2` AS `c2` from `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`c1` = `test`.`t1`.`c1`)) where (`test`.`t1`.`c3` = 10) +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 2 +Handler_read_key 7 +Handler_read_rnd_next 4 +# Status of testing query execution: +Variable_name Value +Handler_read_first 2 +Handler_read_key 7 +Handler_read_rnd_next 4 + +DROP TABLE t1, t2; +#52 +CREATE TABLE t1(f1 INT, f2 INT); +CREATE TABLE t2(f3 INT, f4 INT); +CREATE INDEX IDX ON t2(f3); +INSERT INTO t1 VALUES(1,0),(2,0); +INSERT INTO t2 VALUES(1,1),(2,2); +# +# query: UPDATE t1 SET t1.f2=(SELECT MAX(t2.f4) FROM t2 WHERE t2.f3=t1.f1) +# select: SELECT (SELECT MAX(t2.f4) FROM t2 WHERE t2.f3=t1.f1) FROM t1 +# +EXPLAIN UPDATE t1 SET t1.f2=(SELECT MAX(t2.f4) FROM t2 WHERE t2.f3=t1.f1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DEPENDENT SUBQUERY t2 NULL ref IDX IDX 5 test.t1.f1 1 100.00 NULL +Warnings: +Note 1276 Field or reference 'test.t1.f1' of SELECT #2 was resolved in SELECT #1 +Note 1003 update `test`.`t1` set `test`.`t1`.`f2` = (/* select#2 */ select max(`test`.`t2`.`f4`) from `test`.`t2` where (`test`.`t2`.`f3` = `test`.`t1`.`f1`)) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t1 SET t1.f2=(SELECT MAX(t2.f4) FROM t2 WHERE t2.f3=t1.f1);; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "table": { + "update": true, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "filtered": "100.00" + } /* table */, + "update_value_subqueries": [ + { + "dependent": true, + "cacheable": false, + "query_block": { + "select_id": 2, + "cost_info": { + "query_cost": "0.35" + } /* cost_info */, + "table": { + "table_name": "t2", + "access_type": "ref", + "possible_keys": [ + "IDX" + ] /* possible_keys */, + "key": "IDX", + "used_key_parts": [ + "f3" + ] /* used_key_parts */, + "key_length": "5", + "ref": [ + "test.t1.f1" + ] /* ref */, + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.10", + "prefix_cost": "0.35", + "data_read_per_join": "16" + } /* cost_info */, + "used_columns": [ + "f3", + "f4" + ] /* used_columns */ + } /* table */ + } /* query_block */ + } + ] /* update_value_subqueries */ + } /* query_block */ +} +Warnings: +Note 1276 Field or reference 'test.t1.f1' of SELECT #2 was resolved in SELECT #1 +Note 1003 update `test`.`t1` set `test`.`t1`.`f2` = (/* select#2 */ select max(`test`.`t2`.`f4`) from `test`.`t2` where (`test`.`t2`.`f3` = `test`.`t1`.`f1`)) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT (SELECT MAX(t2.f4) FROM t2 WHERE t2.f3=t1.f1) FROM t1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.45" + } /* cost_info */, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 2, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.20", + "prefix_cost": "0.45", + "data_read_per_join": "32" + } /* cost_info */, + "used_columns": [ + "f1" + ] /* used_columns */ + } /* table */, + "select_list_subqueries": [ + { + "dependent": true, + "cacheable": false, + "query_block": { + "select_id": 2, + "cost_info": { + "query_cost": "0.35" + } /* cost_info */, + "table": { + "table_name": "t2", + "access_type": "ref", + "possible_keys": [ + "IDX" + ] /* possible_keys */, + "key": "IDX", + "used_key_parts": [ + "f3" + ] /* used_key_parts */, + "key_length": "5", + "ref": [ + "test.t1.f1" + ] /* ref */, + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.10", + "prefix_cost": "0.35", + "data_read_per_join": "16" + } /* cost_info */, + "used_columns": [ + "f3", + "f4" + ] /* used_columns */ + } /* table */ + } /* query_block */ + } + ] /* select_list_subqueries */ + } /* query_block */ +} +Warnings: +Note 1276 Field or reference 'test.t1.f1' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select (/* select#2 */ select max(`test`.`t2`.`f4`) from `test`.`t2` where (`test`.`t2`.`f3` = `test`.`t1`.`f1`)) AS `(SELECT MAX(t2.f4) FROM t2 WHERE t2.f3=t1.f1)` from `test`.`t1` +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 7 +Handler_read_next 2 +Handler_read_rnd_next 3 +# Status of testing query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 7 +Handler_read_next 2 +Handler_read_rnd_next 3 +Handler_update 2 + +DROP TABLE t1, t2; +#55 +CREATE TABLE t1(a INT); +INSERT INTO t1 VALUES (1); +SET @a = NULL; +EXPLAIN DELETE FROM t1 WHERE (@a:= a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +Note 1003 delete from `test`.`t1` where (0 <> (@a:=`test`.`t1`.`a`)) +DROP TABLE t1; +#56 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +DELETE FROM t1 USING t1 WHERE uknown_column = 12345; +ERROR 42S22: Unknown column 'uknown_column' in 'where clause' +EXPLAIN DELETE FROM t1 USING t1 WHERE uknown_column = 12345; +ERROR 42S22: Unknown column 'uknown_column' in 'where clause' +DROP TABLE t1; +#57 +CREATE TABLE t1(f1 INT); +EXPLAIN UPDATE t1 SET f2=1 ORDER BY f2; +ERROR 42S22: Unknown column 'f2' in 'field list' +UPDATE t1 SET f2=1 ORDER BY f2; +ERROR 42S22: Unknown column 'f2' in 'field list' +DROP TABLE t1; +#59 +CREATE TABLE t1 ( a INT, KEY( a ) ); +INSERT INTO t1 VALUES (0), (1); +CREATE VIEW v1 AS SELECT t11.a, t12.a AS b FROM t1 t11, t1 t12; +SET SESSION sql_safe_updates = 1; +EXPLAIN UPDATE IGNORE v1 SET a = 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t11 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t12 NULL index NULL a 5 NULL 2 100.00 Using index +Warnings: +Note 1003 update ignore (`test`.`t1` `t11` join `test`.`t1` `t12`) set `t11`.`a` = 1 +UPDATE IGNORE v1 SET a = 1; +ERROR HY000: You are using safe update mode and you tried to update a table without a WHERE that uses a KEY column. +SET SESSION sql_safe_updates = DEFAULT; +DROP TABLE t1; +DROP VIEW v1; +#62 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (0), (1); +CREATE VIEW v1 AS SELECT t11.a, t12.a AS b FROM t1 t11, t1 t12; +# +# query: UPDATE v1 SET a = 1 WHERE a > 0 +# select: SELECT * FROM v1 WHERE a > 0 +# +EXPLAIN UPDATE v1 SET a = 1 WHERE a > 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t11 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t12 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 update (`test`.`t1` `t11` join `test`.`t1` `t12`) set `t11`.`a` = 1 where (`t11`.`a` > 0) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE v1 SET a = 1 WHERE a > 0;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.90" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "update": true, + "table_name": "t11", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 1, + "filtered": "50.00", + "cost_info": { + "read_cost": "0.35", + "eval_cost": "0.10", + "prefix_cost": "0.45", + "data_read_per_join": "8" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t11`.`a` > 0)" + } /* table */ + }, + { + "table": { + "table_name": "t12", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 2, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.20", + "prefix_cost": "0.90", + "data_read_per_join": "16" + } /* cost_info */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 update (`test`.`t1` `t11` join `test`.`t1` `t12`) set `test`.`t11`.`a` = 1 where (`test`.`t11`.`a` > 0) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM v1 WHERE a > 0;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.90" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "table_name": "t11", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 1, + "filtered": "50.00", + "cost_info": { + "read_cost": "0.35", + "eval_cost": "0.10", + "prefix_cost": "0.45", + "data_read_per_join": "8" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t11`.`a` > 0)" + } /* table */ + }, + { + "table": { + "table_name": "t12", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 2, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.20", + "prefix_cost": "0.90", + "data_read_per_join": "16" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t11`.`a` AS `a`,`test`.`t12`.`a` AS `b` from `test`.`t1` `t11` join `test`.`t1` `t12` where (`test`.`t11`.`a` > 0) +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 2 +Handler_read_key 3 +Handler_read_rnd_next 6 +# Status of testing query execution: +Variable_name Value +Handler_read_first 2 +Handler_read_key 4 +Handler_read_rnd 1 +Handler_read_rnd_next 8 +Handler_write 2 + +# +# query: UPDATE t1, v1 SET v1.a = 1 WHERE t1.a = v1.a +# select: SELECT * FROM t1, v1 WHERE t1.a = v1.a +# +EXPLAIN UPDATE t1, v1 SET v1.a = 1 WHERE t1.a = v1.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 UPDATE t11 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t12 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 update `test`.`t1` join `test`.`t1` `t11` join `test`.`t1` `t12` set `test`.`t11`.`a` = 1 where (`test`.`t11`.`a` = `test`.`t1`.`a`) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t1, v1 SET v1.a = 1 WHERE t1.a = v1.a;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.75" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 2, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.20", + "prefix_cost": "0.45", + "data_read_per_join": "16" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */ + } /* table */ + }, + { + "table": { + "update": true, + "table_name": "t11", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 2, + "filtered": "50.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.20", + "prefix_cost": "1.10", + "data_read_per_join": "16" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t11`.`a` = `test`.`t1`.`a`)" + } /* table */ + }, + { + "table": { + "table_name": "t12", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 4, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.40", + "prefix_cost": "1.75", + "data_read_per_join": "32" + } /* cost_info */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t1` join `test`.`t1` `t11` join `test`.`t1` `t12` set `test`.`t11`.`a` = 1 where (`test`.`t11`.`a` = `test`.`t1`.`a`) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1, v1 WHERE t1.a = v1.a;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.75" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 2, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.20", + "prefix_cost": "0.45", + "data_read_per_join": "16" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */ + } /* table */ + }, + { + "table": { + "table_name": "t11", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 2, + "filtered": "50.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.20", + "prefix_cost": "1.10", + "data_read_per_join": "16" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t11`.`a` = `test`.`t1`.`a`)" + } /* table */ + }, + { + "table": { + "table_name": "t12", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 4, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.40", + "prefix_cost": "1.75", + "data_read_per_join": "32" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t11`.`a` AS `a`,`test`.`t12`.`a` AS `b` from `test`.`t1` join `test`.`t1` `t11` join `test`.`t1` `t12` where (`test`.`t11`.`a` = `test`.`t1`.`a`) +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 3 +Handler_read_key 4 +Handler_read_rnd_next 9 +# Status of testing query execution: +Variable_name Value +Handler_read_first 5 +Handler_read_key 8 +Handler_read_rnd 2 +Handler_read_rnd_next 18 +Handler_update 1 +Handler_write 4 + +DROP TABLE t1; +DROP VIEW v1; +#63 +CREATE TABLE t1 (a INT, PRIMARY KEY(a)); +INSERT INTO t1 VALUES (1), (2), (3), (4), (5); +CREATE VIEW v1 (a) AS SELECT a FROM t1; +# +# query: DELETE FROM v1 WHERE a < 4 +# select: SELECT * FROM v1 WHERE a < 4 +# +EXPLAIN DELETE FROM v1 WHERE a < 4; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL range PRIMARY PRIMARY 4 const X 100.00 Using where +Warnings: +Note 1003 delete from (`test`.`t1`) where (`test`.`t1`.`a` < 4) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM v1 WHERE a < 4;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "table": { + "delete": true, + "table_name": "t1", + "access_type": "range", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "a" + ] /* used_key_parts */, + "key_length": "4", + "ref": [ + "const" + ] /* ref */, + "rows_examined_per_scan": "X", + "filtered": "X", + "attached_condition": "(`test`.`t1`.`a` < 4)" + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 delete from (`test`.`t1`) where (`test`.`t1`.`a` < 4) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM v1 WHERE a < 4;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "X" + } /* cost_info */, + "table": { + "table_name": "t1", + "access_type": "range", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "a" + ] /* used_key_parts */, + "key_length": "4", + "rows_examined_per_scan": "X", + "rows_produced_per_join": "X", + "filtered": "X", + "using_index": true, + "cost_info": { + "read_cost": "X", + "eval_cost": "X", + "prefix_cost": "X", + "data_read_per_join": "X" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`a` < 4)" + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` < 4) +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 2 +Handler_read_next 3 +# Status of testing query execution: +Variable_name Value +Handler_delete 3 +Handler_read_first 1 +Handler_read_key 2 +Handler_read_next 3 + +DROP TABLE t1; +DROP VIEW v1; +#64 +CREATE TABLE t1 (a INT, b INT, PRIMARY KEY(a)); +INSERT INTO t1 VALUES (1,2), (2,3), (3,4), (4,5), (5,10); +CREATE TABLE t2 (x INT); +INSERT INTO t2 VALUES (1), (2), (3), (4); +CREATE VIEW v1 (a,c) AS SELECT a, b+1 FROM t1; +# +# query: DELETE v1 FROM t2, v1 WHERE t2.x = v1.a +# select: SELECT * FROM t2, v1 WHERE t2.x = v1.a +# +EXPLAIN DELETE v1 FROM t2, v1 WHERE t2.x = v1.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +1 DELETE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.x 1 100.00 NULL +Warnings: +Note 1003 delete `test`.`t1` from `test`.`t2` join `test`.`t1` where (`test`.`t1`.`a` = `test`.`t2`.`x`) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE v1 FROM t2, v1 WHERE t2.x = v1.a;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "2.05" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 4, + "rows_produced_per_join": 4, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.40", + "prefix_cost": "0.65", + "data_read_per_join": "32" + } /* cost_info */, + "used_columns": [ + "x" + ] /* used_columns */, + "attached_condition": "(`test`.`t2`.`x` is not null)" + } /* table */ + }, + { + "table": { + "delete": true, + "table_name": "t1", + "access_type": "eq_ref", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "a" + ] /* used_key_parts */, + "key_length": "4", + "ref": [ + "test.t2.x" + ] /* ref */, + "rows_examined_per_scan": 1, + "rows_produced_per_join": 4, + "filtered": "100.00", + "cost_info": { + "read_cost": "1.00", + "eval_cost": "0.40", + "prefix_cost": "2.05", + "data_read_per_join": "64" + } /* cost_info */, + "used_columns": [ + "a", + "b" + ] /* used_columns */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 delete `test`.`t1` from `test`.`t2` join `test`.`t1` where (`test`.`t1`.`a` = `test`.`t2`.`x`) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t2, v1 WHERE t2.x = v1.a;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "2.05" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 4, + "rows_produced_per_join": 4, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.40", + "prefix_cost": "0.65", + "data_read_per_join": "32" + } /* cost_info */, + "used_columns": [ + "x" + ] /* used_columns */, + "attached_condition": "(`test`.`t2`.`x` is not null)" + } /* table */ + }, + { + "table": { + "table_name": "t1", + "access_type": "eq_ref", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "a" + ] /* used_key_parts */, + "key_length": "4", + "ref": [ + "test.t2.x" + ] /* ref */, + "rows_examined_per_scan": 1, + "rows_produced_per_join": 4, + "filtered": "100.00", + "cost_info": { + "read_cost": "1.00", + "eval_cost": "0.40", + "prefix_cost": "2.05", + "data_read_per_join": "64" + } /* cost_info */, + "used_columns": [ + "a", + "b" + ] /* used_columns */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`x` AS `x`,`test`.`t1`.`a` AS `a`,(`test`.`t1`.`b` + 1) AS `c` from `test`.`t2` join `test`.`t1` where (`test`.`t1`.`a` = `test`.`t2`.`x`) +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 8 +Handler_read_rnd_next 5 +# Status of testing query execution: +Variable_name Value +Handler_delete 4 +Handler_read_first 1 +Handler_read_key 12 +Handler_read_rnd 4 +Handler_read_rnd_next 5 + +DROP TABLE t1,t2; +DROP VIEW v1; +#65 +CREATE TABLE t1 (a INT, b INT, PRIMARY KEY(a)); +INSERT INTO t1 VALUES (1,2), (2,3), (3,4), (4,5), (5,10); +CREATE TABLE t2 (x INT); +INSERT INTO t2 VALUES (1), (2), (3), (4); +CREATE VIEW v1 (a,c) AS SELECT a, b+1 FROM t1; +# +# query: DELETE v1 FROM t2, v1 WHERE t2.x = v1.a +# select: SELECT * FROM t2, v1 WHERE t2.x = v1.a +# +EXPLAIN DELETE v1 FROM t2, v1 WHERE t2.x = v1.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +1 DELETE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.x 1 100.00 NULL +Warnings: +Note 1003 delete `test`.`t1` from `test`.`t2` join `test`.`t1` where (`test`.`t1`.`a` = `test`.`t2`.`x`) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE v1 FROM t2, v1 WHERE t2.x = v1.a;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "2.05" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 4, + "rows_produced_per_join": 4, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.40", + "prefix_cost": "0.65", + "data_read_per_join": "32" + } /* cost_info */, + "used_columns": [ + "x" + ] /* used_columns */, + "attached_condition": "(`test`.`t2`.`x` is not null)" + } /* table */ + }, + { + "table": { + "delete": true, + "table_name": "t1", + "access_type": "eq_ref", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "a" + ] /* used_key_parts */, + "key_length": "4", + "ref": [ + "test.t2.x" + ] /* ref */, + "rows_examined_per_scan": 1, + "rows_produced_per_join": 4, + "filtered": "100.00", + "cost_info": { + "read_cost": "1.00", + "eval_cost": "0.40", + "prefix_cost": "2.05", + "data_read_per_join": "64" + } /* cost_info */, + "used_columns": [ + "a", + "b" + ] /* used_columns */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 delete `test`.`t1` from `test`.`t2` join `test`.`t1` where (`test`.`t1`.`a` = `test`.`t2`.`x`) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t2, v1 WHERE t2.x = v1.a;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "2.05" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 4, + "rows_produced_per_join": 4, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.40", + "prefix_cost": "0.65", + "data_read_per_join": "32" + } /* cost_info */, + "used_columns": [ + "x" + ] /* used_columns */, + "attached_condition": "(`test`.`t2`.`x` is not null)" + } /* table */ + }, + { + "table": { + "table_name": "t1", + "access_type": "eq_ref", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "a" + ] /* used_key_parts */, + "key_length": "4", + "ref": [ + "test.t2.x" + ] /* ref */, + "rows_examined_per_scan": 1, + "rows_produced_per_join": 4, + "filtered": "100.00", + "cost_info": { + "read_cost": "1.00", + "eval_cost": "0.40", + "prefix_cost": "2.05", + "data_read_per_join": "64" + } /* cost_info */, + "used_columns": [ + "a", + "b" + ] /* used_columns */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`x` AS `x`,`test`.`t1`.`a` AS `a`,(`test`.`t1`.`b` + 1) AS `c` from `test`.`t2` join `test`.`t1` where (`test`.`t1`.`a` = `test`.`t2`.`x`) +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 8 +Handler_read_rnd_next 5 +# Status of testing query execution: +Variable_name Value +Handler_delete 4 +Handler_read_first 1 +Handler_read_key 12 +Handler_read_rnd 4 +Handler_read_rnd_next 5 + +DROP TABLE t1,t2; +DROP VIEW v1; +#66 +CREATE TABLE t1 (a INT); +CREATE VIEW v1 (x) AS SELECT a FROM t1; +# +# query: INSERT INTO v1 VALUES (10) +# select: SELECT NULL +# +EXPLAIN INSERT INTO v1 VALUES (10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 INSERT t1 NULL ALL NULL NULL NULL NULL NULL NULL NULL +Warnings: +Note 1003 insert into `test`.`t1` values (10) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON INSERT INTO v1 VALUES (10);; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "table": { + "insert": true, + "table_name": "t1", + "access_type": "ALL" + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 insert into `test`.`t1` values (10) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT NULL;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "message": "No tables used" + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select NULL AS `NULL` +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +# Status of testing query execution: +Variable_name Value +Handler_read_key 1 +Handler_write 1 + +DROP TABLE t1; +DROP VIEW v1; +#67 +CREATE TABLE t1 (a INT); +CREATE TABLE t2 (b INT); +INSERT INTO t2 VALUES (1), (2), (3); +CREATE VIEW v1 (x) AS SELECT b FROM t2; +# +# query: INSERT INTO v1 SELECT * FROM t1 +# select: SELECT * FROM t1 +# +EXPLAIN INSERT INTO v1 SELECT * FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 INSERT t2 NULL ALL NULL NULL NULL NULL NULL NULL NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 insert into `test`.`t2` /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON INSERT INTO v1 SELECT * FROM t1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.35" + } /* cost_info */, + "table": { + "insert": true, + "table_name": "t2", + "access_type": "ALL" + } /* table */, + "insert_from": { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.10", + "prefix_cost": "0.35", + "data_read_per_join": "8" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */ + } /* table */ + } /* insert_from */ + } /* query_block */ +} +Warnings: +Note 1003 insert into `test`.`t2` /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.35" + } /* cost_info */, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.10", + "prefix_cost": "0.35", + "data_read_per_join": "16" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "query_block": { + "cost_info": { + "query_cost": "0.35" + } /* cost_info */, + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.10", + "prefix_cost": "0.35", + "data_read_per_join": "8" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */ + } /* table */ + } /* query_block */ + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 2 +Handler_read_rnd_next 1 +# Status of testing query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 3 +Handler_read_rnd_next 1 + +DROP TABLE t1, t2; +DROP VIEW v1; +#69 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +CREATE TABLE t2 (b INT); +INSERT INTO t2 VALUES (1), (2), (3); +# +# query: UPDATE t1 SET a = 10 WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x) +# select: SELECT * FROM t1 WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x) +# +EXPLAIN UPDATE t1 SET a = 10 WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY NULL index_subquery 5 func 2 100.00 Using index +3 DERIVED t2 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`a` = 10 where (`test`.`t1`.`a`,(((`test`.`t1`.`a`) in x on ))) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t1 SET a = 10 WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x);; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "table": { + "update": true, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "filtered": "100.00", + "attached_condition": "(`test`.`t1`.`a`,(((`test`.`t1`.`a`) in x on )))", + "attached_subqueries": [ + { + "dependent": true, + "cacheable": false, + "query_block": { + "select_id": 2, + "cost_info": { + "query_cost": "0.70" + } /* cost_info */, + "table": { + "table_name": "x", + "access_type": "index_subquery", + "possible_keys": [ + "" + ] /* possible_keys */, + "key": "", + "used_key_parts": [ + "b" + ] /* used_key_parts */, + "key_length": "5", + "ref": [ + "func" + ] /* ref */, + "rows_examined_per_scan": 2, + "rows_produced_per_join": 2, + "filtered": "100.00", + "using_index": true, + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.20", + "prefix_cost": "0.70", + "data_read_per_join": "32" + } /* cost_info */, + "used_columns": [ + "b" + ] /* used_columns */, + "materialized_from_subquery": { + "using_temporary_table": true, + "dependent": false, + "cacheable": true, + "query_block": { + "select_id": 3, + "cost_info": { + "query_cost": "3.55" + } /* cost_info */, + "ordering_operation": { + "using_filesort": true, + "cost_info": { + "sort_cost": "3.00" + } /* cost_info */, + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.30", + "prefix_cost": "0.55", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "b" + ] /* used_columns */ + } /* table */ + } /* ordering_operation */ + } /* query_block */ + } /* materialized_from_subquery */ + } /* table */ + } /* query_block */ + } + ] /* attached_subqueries */ + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`a` = 10 where (`test`.`t1`.`a`,(((`test`.`t1`.`a`) in x on ))) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x);; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.55" + } /* cost_info */, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.30", + "prefix_cost": "0.55", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`a`,(((`test`.`t1`.`a`) in x on )))", + "attached_subqueries": [ + { + "dependent": true, + "cacheable": false, + "query_block": { + "select_id": 2, + "cost_info": { + "query_cost": "0.70" + } /* cost_info */, + "table": { + "table_name": "x", + "access_type": "index_subquery", + "possible_keys": [ + "" + ] /* possible_keys */, + "key": "", + "used_key_parts": [ + "b" + ] /* used_key_parts */, + "key_length": "5", + "ref": [ + "func" + ] /* ref */, + "rows_examined_per_scan": 2, + "rows_produced_per_join": 2, + "filtered": "100.00", + "using_index": true, + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.20", + "prefix_cost": "0.70", + "data_read_per_join": "32" + } /* cost_info */, + "used_columns": [ + "b" + ] /* used_columns */, + "materialized_from_subquery": { + "using_temporary_table": true, + "dependent": false, + "cacheable": true, + "query_block": { + "select_id": 3, + "cost_info": { + "query_cost": "3.55" + } /* cost_info */, + "ordering_operation": { + "using_filesort": true, + "cost_info": { + "sort_cost": "3.00" + } /* cost_info */, + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.30", + "prefix_cost": "0.55", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "b" + ] /* used_columns */ + } /* table */ + } /* ordering_operation */ + } /* query_block */ + } /* materialized_from_subquery */ + } /* table */ + } /* query_block */ + } + ] /* attached_subqueries */ + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a`,(((`test`.`t1`.`a`) in x on ))) +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 2 +Handler_read_key 7 +Handler_read_rnd_next 8 +Handler_write 1 +Sort_rows 3 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_read_first 2 +Handler_read_key 7 +Handler_read_rnd_next 8 +Handler_update 1 +Handler_write 1 +Sort_rows 3 +Sort_scan 1 + +# +# query: UPDATE t1, t2 SET a = 10 WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x) +# select: SELECT * FROM t1, t2 WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x) +# +EXPLAIN UPDATE t1, t2 SET a = 10 WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 DEPENDENT SUBQUERY NULL index_subquery 5 func 2 100.00 Using index +3 DERIVED t2 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 update `test`.`t1` join `test`.`t2` set `test`.`t1`.`a` = 10 where (`test`.`t1`.`a`,(((`test`.`t1`.`a`) in x on ))) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t1, t2 SET a = 10 WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x);; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.70" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "update": true, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.30", + "prefix_cost": "0.55", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`a`,(((`test`.`t1`.`a`) in x on )))", + "attached_subqueries": [ + { + "dependent": true, + "cacheable": false, + "query_block": { + "select_id": 2, + "cost_info": { + "query_cost": "0.70" + } /* cost_info */, + "table": { + "table_name": "x", + "access_type": "index_subquery", + "possible_keys": [ + "" + ] /* possible_keys */, + "key": "", + "used_key_parts": [ + "b" + ] /* used_key_parts */, + "key_length": "5", + "ref": [ + "func" + ] /* ref */, + "rows_examined_per_scan": 2, + "rows_produced_per_join": 2, + "filtered": "100.00", + "using_index": true, + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.20", + "prefix_cost": "0.70", + "data_read_per_join": "32" + } /* cost_info */, + "used_columns": [ + "b" + ] /* used_columns */, + "materialized_from_subquery": { + "using_temporary_table": true, + "dependent": false, + "cacheable": true, + "query_block": { + "select_id": 3, + "cost_info": { + "query_cost": "3.55" + } /* cost_info */, + "ordering_operation": { + "using_filesort": true, + "cost_info": { + "sort_cost": "3.00" + } /* cost_info */, + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.30", + "prefix_cost": "0.55", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "b" + ] /* used_columns */ + } /* table */ + } /* ordering_operation */ + } /* query_block */ + } /* materialized_from_subquery */ + } /* table */ + } /* query_block */ + } + ] /* attached_subqueries */ + } /* table */ + }, + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 9, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.90", + "prefix_cost": "1.70", + "data_read_per_join": "72" + } /* cost_info */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t1` join `test`.`t2` set `test`.`t1`.`a` = 10 where (`test`.`t1`.`a`,(((`test`.`t1`.`a`) in x on ))) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1, t2 WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x);; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.70" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.30", + "prefix_cost": "0.55", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`a`,(((`test`.`t1`.`a`) in x on )))", + "attached_subqueries": [ + { + "dependent": true, + "cacheable": false, + "query_block": { + "select_id": 2, + "cost_info": { + "query_cost": "0.70" + } /* cost_info */, + "table": { + "table_name": "x", + "access_type": "index_subquery", + "possible_keys": [ + "" + ] /* possible_keys */, + "key": "", + "used_key_parts": [ + "b" + ] /* used_key_parts */, + "key_length": "5", + "ref": [ + "func" + ] /* ref */, + "rows_examined_per_scan": 2, + "rows_produced_per_join": 2, + "filtered": "100.00", + "using_index": true, + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.20", + "prefix_cost": "0.70", + "data_read_per_join": "32" + } /* cost_info */, + "used_columns": [ + "b" + ] /* used_columns */, + "materialized_from_subquery": { + "using_temporary_table": true, + "dependent": false, + "cacheable": true, + "query_block": { + "select_id": 3, + "cost_info": { + "query_cost": "3.55" + } /* cost_info */, + "ordering_operation": { + "using_filesort": true, + "cost_info": { + "sort_cost": "3.00" + } /* cost_info */, + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.30", + "prefix_cost": "0.55", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "b" + ] /* used_columns */ + } /* table */ + } /* ordering_operation */ + } /* query_block */ + } /* materialized_from_subquery */ + } /* table */ + } /* query_block */ + } + ] /* attached_subqueries */ + } /* table */ + }, + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 9, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.90", + "prefix_cost": "1.70", + "data_read_per_join": "72" + } /* cost_info */, + "used_columns": [ + "b" + ] /* used_columns */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` join `test`.`t2` where (`test`.`t1`.`a`,(((`test`.`t1`.`a`) in x on ))) +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 2 +Handler_read_key 7 +Handler_read_rnd_next 8 +Handler_write 1 +Sort_rows 3 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_read_first 2 +Handler_read_key 7 +Handler_read_rnd_next 8 +Handler_write 1 +Sort_rows 3 +Sort_scan 1 + +# +# query: UPDATE t1, (SELECT * FROM t2) y SET a = 10 WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x) +# select: SELECT * FROM t1, (SELECT * FROM t2) y WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x) +# +EXPLAIN UPDATE t1, (SELECT * FROM t2) y SET a = 10 WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +3 DEPENDENT SUBQUERY NULL index_subquery 5 func 2 100.00 Using index +4 DERIVED t2 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 update `test`.`t1` join `test`.`t2` set `test`.`t1`.`a` = 10 where (`test`.`t1`.`a`,(((`test`.`t1`.`a`) in x on ))) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t1, (SELECT * FROM t2) y SET a = 10 WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x);; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.70" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "update": true, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.30", + "prefix_cost": "0.55", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`a`,(((`test`.`t1`.`a`) in x on )))", + "attached_subqueries": [ + { + "dependent": true, + "cacheable": false, + "query_block": { + "select_id": 3, + "cost_info": { + "query_cost": "0.70" + } /* cost_info */, + "table": { + "table_name": "x", + "access_type": "index_subquery", + "possible_keys": [ + "" + ] /* possible_keys */, + "key": "", + "used_key_parts": [ + "b" + ] /* used_key_parts */, + "key_length": "5", + "ref": [ + "func" + ] /* ref */, + "rows_examined_per_scan": 2, + "rows_produced_per_join": 2, + "filtered": "100.00", + "using_index": true, + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.20", + "prefix_cost": "0.70", + "data_read_per_join": "32" + } /* cost_info */, + "used_columns": [ + "b" + ] /* used_columns */, + "materialized_from_subquery": { + "using_temporary_table": true, + "dependent": false, + "cacheable": true, + "query_block": { + "select_id": 4, + "cost_info": { + "query_cost": "3.55" + } /* cost_info */, + "ordering_operation": { + "using_filesort": true, + "cost_info": { + "sort_cost": "3.00" + } /* cost_info */, + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.30", + "prefix_cost": "0.55", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "b" + ] /* used_columns */ + } /* table */ + } /* ordering_operation */ + } /* query_block */ + } /* materialized_from_subquery */ + } /* table */ + } /* query_block */ + } + ] /* attached_subqueries */ + } /* table */ + }, + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 9, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.90", + "prefix_cost": "1.70", + "data_read_per_join": "72" + } /* cost_info */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t1` join `test`.`t2` set `test`.`t1`.`a` = 10 where (`test`.`t1`.`a`,(((`test`.`t1`.`a`) in x on ))) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1, (SELECT * FROM t2) y WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x);; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.70" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.30", + "prefix_cost": "0.55", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`a`,(((`test`.`t1`.`a`) in x on )))", + "attached_subqueries": [ + { + "dependent": true, + "cacheable": false, + "query_block": { + "select_id": 3, + "cost_info": { + "query_cost": "0.70" + } /* cost_info */, + "table": { + "table_name": "x", + "access_type": "index_subquery", + "possible_keys": [ + "" + ] /* possible_keys */, + "key": "", + "used_key_parts": [ + "b" + ] /* used_key_parts */, + "key_length": "5", + "ref": [ + "func" + ] /* ref */, + "rows_examined_per_scan": 2, + "rows_produced_per_join": 2, + "filtered": "100.00", + "using_index": true, + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.20", + "prefix_cost": "0.70", + "data_read_per_join": "32" + } /* cost_info */, + "used_columns": [ + "b" + ] /* used_columns */, + "materialized_from_subquery": { + "using_temporary_table": true, + "dependent": false, + "cacheable": true, + "query_block": { + "select_id": 4, + "cost_info": { + "query_cost": "3.55" + } /* cost_info */, + "ordering_operation": { + "using_filesort": true, + "cost_info": { + "sort_cost": "3.00" + } /* cost_info */, + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.30", + "prefix_cost": "0.55", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "b" + ] /* used_columns */ + } /* table */ + } /* ordering_operation */ + } /* query_block */ + } /* materialized_from_subquery */ + } /* table */ + } /* query_block */ + } + ] /* attached_subqueries */ + } /* table */ + }, + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 9, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.90", + "prefix_cost": "1.70", + "data_read_per_join": "72" + } /* cost_info */, + "used_columns": [ + "b" + ] /* used_columns */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` join `test`.`t2` where (`test`.`t1`.`a`,(((`test`.`t1`.`a`) in x on ))) +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 2 +Handler_read_key 7 +Handler_read_rnd_next 8 +Handler_write 1 +Sort_rows 3 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_read_first 2 +Handler_read_key 7 +Handler_read_rnd_next 8 +Handler_write 1 +Sort_rows 3 +Sort_scan 1 + +DROP TABLE t1,t2; +#70 +CREATE TABLE t1 (c1 INT KEY); +CREATE TABLE t2 (c2 INT); +CREATE TABLE t3 (c3 INT); +EXPLAIN UPDATE t3 SET c3 = ( +SELECT COUNT(d1.c1) +FROM ( +SELECT a11.c1 FROM t1 AS a11 +STRAIGHT_JOIN t2 AS a21 ON a21.c2 = a11.c1 +JOIN t1 AS a12 ON a12.c1 = a11.c1 +) d1 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t3 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SUBQUERY NULL ALL NULL NULL NULL NULL 2 100.00 NULL +3 DERIVED a11 NULL index PRIMARY PRIMARY 4 NULL 1 100.00 Using index +3 DERIVED a21 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +3 DERIVED a12 NULL eq_ref PRIMARY PRIMARY 4 test.a11.c1 1 100.00 Using index +Warnings: +Note 1003 update `test`.`t3` set `test`.`t3`.`c3` = (/* select#2 */ select count(`d1`.`c1`) from (/* select#3 */ select `test`.`a11`.`c1` AS `c1` from `test`.`t1` `a11` straight_join `test`.`t2` `a21` join `test`.`t1` `a12` where ((`test`.`a21`.`c2` = `test`.`a11`.`c1`) and (`test`.`a12`.`c1` = `test`.`a11`.`c1`))) `d1`) +DROP TABLE t1, t2, t3; +#71 +CREATE TABLE t1 (c1 INT NOT NULL, c2 INT NOT NULL, INDEX i1(c1)); +INSERT INTO t1 VALUES (1,0),(2,0),(3,0),(4,0),(5,0),(6,0),(7,0),(8,0); +CREATE TABLE t2 LIKE t1; +EXPLAIN INSERT INTO t2 SELECT * FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 INSERT t2 NULL ALL NULL NULL NULL NULL X NULL NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL X 100.00 NULL +Warnings: +Note 1003 insert into `test`.`t2` /* select#1 */ select `test`.`t1`.`c1` AS `c1`,`test`.`t1`.`c2` AS `c2` from `test`.`t1` +INSERT INTO t2 SELECT * FROM t1; +SELECT * FROM t1 LEFT JOIN t2 ON t1.c1 = t2.c1; +DROP TABLE t1, t2; +#73 +CREATE TABLE t1 (id INT); +CREATE TABLE t2 (id INT); +INSERT INTO t1 VALUES (1), (2); +EXPLAIN SELECT * FROM t1 LEFT JOIN t2 USING(id) GROUP BY t1.id; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using temporary +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id` from `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`id` = `test`.`t1`.`id`)) where true group by `test`.`t1`.`id` +DROP TABLE t1,t2; +#74 +CREATE TABLE t1(a INT PRIMARY KEY) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1), (2), (3), (4), (5); +# used key is modified & Using temporary +# +# query: UPDATE t1 SET a=a+1 WHERE a>10 +# select: SELECT a t1 FROM t1 WHERE a>10 +# +EXPLAIN UPDATE t1 SET a=a+1 WHERE a>10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL range PRIMARY PRIMARY 4 const 1 100.00 Using where; Using temporary +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`a` = (`test`.`t1`.`a` + 1) where (`test`.`t1`.`a` > 10) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t1 SET a=a+1 WHERE a>10;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "table": { + "update": true, + "table_name": "t1", + "access_type": "range", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "a" + ] /* used_key_parts */, + "key_length": "4", + "ref": [ + "const" + ] /* ref */, + "rows_examined_per_scan": 1, + "filtered": "100.00", + "using_temporary_table": "for update", + "attached_condition": "(`test`.`t1`.`a` > 10)" + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`a` = (`test`.`t1`.`a` + 1) where (`test`.`t1`.`a` > 10) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT a t1 FROM t1 WHERE a>10;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.46" + } /* cost_info */, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.36", + "eval_cost": "0.10", + "prefix_cost": "0.46", + "data_read_per_join": "16" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "query_block": { + "cost_info": { + "query_cost": "0.46" + } /* cost_info */, + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "range", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "a" + ] /* used_key_parts */, + "key_length": "4", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "using_index": true, + "cost_info": { + "read_cost": "0.36", + "eval_cost": "0.10", + "prefix_cost": "0.46", + "data_read_per_join": "8" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`a` > 10)" + } /* table */ + } /* query_block */ + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `t1` from `test`.`t1` where (`test`.`t1`.`a` > 10) +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 2 + +# used key is modified & Using filesort +# +# query: UPDATE t1 SET a=a+1 WHERE a>10 ORDER BY a+20 +# select: SELECT a t1 FROM t1 WHERE a>10 ORDER BY a+20 +# +EXPLAIN UPDATE t1 SET a=a+1 WHERE a>10 ORDER BY a+20; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL range PRIMARY PRIMARY 4 const 1 100.00 Using where; Using filesort +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`a` = (`test`.`t1`.`a` + 1) where (`test`.`t1`.`a` > 10) order by (`test`.`t1`.`a` + 20) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t1 SET a=a+1 WHERE a>10 ORDER BY a+20;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_filesort": true, + "table": { + "update": true, + "table_name": "t1", + "access_type": "range", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "a" + ] /* used_key_parts */, + "key_length": "4", + "ref": [ + "const" + ] /* ref */, + "rows_examined_per_scan": 1, + "filtered": "100.00", + "attached_condition": "(`test`.`t1`.`a` > 10)" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`a` = (`test`.`t1`.`a` + 1) where (`test`.`t1`.`a` > 10) order by (`test`.`t1`.`a` + 20) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT a t1 FROM t1 WHERE a>10 ORDER BY a+20;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.46" + } /* cost_info */, + "ordering_operation": { + "using_filesort": true, + "cost_info": { + "sort_cost": "1.00" + } /* cost_info */, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.36", + "eval_cost": "0.10", + "prefix_cost": "0.46", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "(t1.a + 20)", + "a" + ] /* used_columns */, + "ordering_operation": { + "using_filesort": true, + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "range", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "a" + ] /* used_key_parts */, + "key_length": "4", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "using_index": true, + "cost_info": { + "read_cost": "0.36", + "eval_cost": "0.10", + "prefix_cost": "0.46", + "data_read_per_join": "8" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`a` > 10)" + } /* table */ + } /* ordering_operation */ + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `t1` from `test`.`t1` where (`test`.`t1`.`a` > 10) order by `(t1.a + 20)` +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 1 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 2 +Sort_scan 1 + +DROP TABLE t1; +# +# Bug #12949629: CLIENT LOSES CONNECTION AFTER EXECUTING A PROCEDURE WITH +# EXPLAIN UPDATE/DEL/INS +# +CREATE TABLE t1 (i INT); +CREATE TABLE t2 (i INT); +CREATE PROCEDURE p1() BEGIN EXPLAIN INSERT INTO t1 VALUES (1);END| +CREATE PROCEDURE p2() BEGIN INSERT INTO t1 VALUES (1);END| +CREATE PROCEDURE p3() BEGIN EXPLAIN INSERT INTO t1 SELECT 1;END| +CREATE PROCEDURE p4() BEGIN INSERT INTO t1 SELECT 1;END| +CREATE PROCEDURE p5() BEGIN EXPLAIN REPLACE INTO t1 VALUES (1);END| +CREATE PROCEDURE p6() BEGIN REPLACE INTO t1 VALUES (1);END| +CREATE PROCEDURE p7() BEGIN EXPLAIN REPLACE INTO t1 SELECT 1;END| +CREATE PROCEDURE p8() BEGIN REPLACE INTO t1 SELECT 1;END| +CREATE PROCEDURE p9() BEGIN EXPLAIN UPDATE t1 SET i = 10;END| +CREATE PROCEDURE p10() BEGIN UPDATE t1 SET i = 10;END| +CREATE PROCEDURE p11() BEGIN EXPLAIN UPDATE t1,t2 SET t1.i = 10 WHERE t1.i = t2.i ;END| +CREATE PROCEDURE p12() BEGIN UPDATE t1,t2 SET t1.i = 10 WHERE t1.i = t2.i ;END| +CREATE PROCEDURE p13() BEGIN +# Disabling binary logging temporarily as optimized delete is not used when log-bin is enabled in row mode +SET @save_log_bin= @@sql_log_bin;SET SQL_LOG_BIN=0; +EXPLAIN DELETE FROM t1; +SET SQL_LOG_BIN=@save_log_bin; END| +CREATE PROCEDURE p14() BEGIN DELETE FROM t1;END| +CREATE PROCEDURE p15() BEGIN EXPLAIN DELETE FROM t1 USING t1;END| +CREATE PROCEDURE p16() BEGIN DELETE FROM t1 USING t1;END| +CALL p16(); +DROP PROCEDURE p16; +CALL p15(); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 delete `test`.`t1` from `test`.`t1` +DROP PROCEDURE p15; +CALL p14(); +DROP PROCEDURE p14; +CALL p13(); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Deleting all rows +DROP PROCEDURE p13; +CALL p12(); +DROP PROCEDURE p12; +CALL p11(); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 update `test`.`t1` join `test`.`t2` set `test`.`t1`.`i` = 10 where (`test`.`t2`.`i` = `test`.`t1`.`i`) +DROP PROCEDURE p11; +CALL p10(); +DROP PROCEDURE p10; +CALL p9(); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`i` = 10 +DROP PROCEDURE p9; +CALL p8(); +DROP PROCEDURE p8; +CALL p7(); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 REPLACE t1 NULL ALL NULL NULL NULL NULL NULL NULL NULL +Warnings: +Note 1003 replace into `test`.`t1` /* select#1 */ select 1 AS `1` from dual +DROP PROCEDURE p7; +CALL p6(); +DROP PROCEDURE p6; +CALL p5(); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 REPLACE t1 NULL ALL NULL NULL NULL NULL NULL NULL NULL +Warnings: +Note 1003 replace into `test`.`t1` values (1) +DROP PROCEDURE p5; +CALL p4(); +DROP PROCEDURE p4; +CALL p3(); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 INSERT t1 NULL ALL NULL NULL NULL NULL NULL NULL NULL +Warnings: +Note 1003 insert into `test`.`t1` /* select#1 */ select 1 AS `1` from dual +DROP PROCEDURE p3; +CALL p2(); +DROP PROCEDURE p2; +CALL p1(); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 INSERT t1 NULL ALL NULL NULL NULL NULL NULL NULL NULL +Warnings: +Note 1003 insert into `test`.`t1` values (1) +DROP PROCEDURE p1; +DROP TABLE t1, t2; +# +set default_storage_engine= @save_storage_engine; +set optimizer_switch=default; diff --git a/mysql-test/r/innodb_explain_non_select_all.result-pq b/mysql-test/r/innodb_explain_non_select_all.result-pq new file mode 100644 index 000000000000..8575f1a6d014 --- /dev/null +++ b/mysql-test/r/innodb_explain_non_select_all.result-pq @@ -0,0 +1,2605 @@ +set optimizer_switch='semijoin=on,materialization=on,firstmatch=on,loosescan=on,index_condition_pushdown=on,mrr=on,mrr_cost_based=off'; +set @save_storage_engine= @@session.default_storage_engine; +set session default_storage_engine = InnoDB; +set end_markers_in_json=on; +#1 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +# +# query: UPDATE t1 SET a = 10 WHERE a < 10 +# select: SELECT * FROM t1 WHERE a < 10 +# +EXPLAIN UPDATE t1 SET a = 10 WHERE a < 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`a` = 10 where (`test`.`t1`.`a` < 10) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 2 +Handler_read_rnd_next 4 +# Status of testing query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 2 +Handler_read_rnd_next 4 +Handler_update 3 + +DROP TABLE t1; +#2 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +# +# query: DELETE FROM t1 WHERE a < 10 +# select: SELECT * FROM t1 WHERE a < 10 +# +EXPLAIN DELETE FROM t1 WHERE a < 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 delete from `test`.`t1` where (`test`.`t1`.`a` < 10) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 2 +Handler_read_rnd_next 4 +# Status of testing query execution: +Variable_name Value +Handler_delete 3 +Handler_read_first 1 +Handler_read_key 2 +Handler_read_rnd_next 4 + +DROP TABLE t1; +#3 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +# +# query: DELETE FROM t1 USING t1 WHERE a = 1 +# select: SELECT * FROM t1 WHERE a = 1 +# +EXPLAIN DELETE FROM t1 USING t1 WHERE a = 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 delete `test`.`t1` from `test`.`t1` where (`test`.`t1`.`a` = 1) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 2 +Handler_read_rnd_next 4 +# Status of testing query execution: +Variable_name Value +Handler_delete 1 +Handler_read_first 1 +Handler_read_key 2 +Handler_read_rnd_next 4 + +DROP TABLE t1; +#4 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +CREATE TABLE t2 (b INT); +INSERT INTO t2 VALUES (1), (2), (3); +# +# query: UPDATE t1, t2 SET t1.a = 10 WHERE t1.a = 1 +# select: SELECT * FROM t1, t2 WHERE t1.a = 1 +# +EXPLAIN UPDATE t1, t2 SET t1.a = 10 WHERE t1.a = 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 update `test`.`t1` join `test`.`t2` set `test`.`t1`.`a` = 10 where (`test`.`t1`.`a` = 1) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 2 +Handler_read_key 4 +Handler_read_rnd_next 8 +# Status of testing query execution: +Variable_name Value +Handler_read_first 2 +Handler_read_key 4 +Handler_read_rnd_next 8 +Handler_update 1 + +DROP TABLE t1, t2; +#5 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +CREATE TABLE t2 (b INT); +INSERT INTO t2 VALUES (1), (2), (3); +# +# query: UPDATE t1 t11, (SELECT * FROM t2) t12 SET t11.a = 10 WHERE t11.a = 1 +# select: SELECT * FROM t1 t11, (SELECT * FROM t2) t12 WHERE t11.a = 1 +# +EXPLAIN UPDATE t1 t11, (SELECT * FROM t2) t12 SET t11.a = 10 WHERE t11.a = 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t11 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 update `test`.`t1` `t11` join `test`.`t2` set `test`.`t11`.`a` = 10 where (`test`.`t11`.`a` = 1) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 2 +Handler_read_key 4 +Handler_read_rnd_next 8 +# Status of testing query execution: +Variable_name Value +Handler_read_first 2 +Handler_read_key 4 +Handler_read_rnd_next 8 +Handler_update 1 + +DROP TABLE t1, t2; +#6 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +CREATE TABLE t2 (b INT); +INSERT INTO t2 VALUES (1), (2), (3); +# +# query: UPDATE t1 SET a = 10 WHERE 1 IN (SELECT 1 FROM t2 WHERE t2.b < 3) +# select: SELECT * FROM t1 WHERE 1 IN (SELECT 1 FROM t2 WHERE t2.b < 3) +# +EXPLAIN UPDATE t1 SET a = 10 WHERE 1 IN (SELECT 1 FROM t2 WHERE t2.b < 3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`a` = 10 where (`test`.`t2`.`b` < 3) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 2 +Handler_read_key 4 +Handler_read_rnd_next 5 +# Status of testing query execution: +Variable_name Value +Handler_read_first 2 +Handler_read_key 7 +Handler_read_rnd 3 +Handler_read_rnd_next 9 +Handler_update 3 +Handler_write 3 + +DROP TABLE t1, t2; +#7 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +CREATE TABLE t2 (b INT); +INSERT INTO t2 VALUES (1), (2), (3); +# +# query: UPDATE t1 SET a = 10 WHERE a IN (SELECT b FROM t2 WHERE t1.a < 3) +# select: SELECT * FROM t1 WHERE a IN (SELECT b FROM t2 WHERE t1.a < 3) +# +EXPLAIN UPDATE t1 SET a = 10 WHERE a IN (SELECT b FROM t2 WHERE t1.a < 3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 update `test`.`t1` set `test`.`t1`.`a` = 10 where ((`test`.`t2`.`b` = `test`.`t1`.`a`) and (`test`.`t1`.`a` < 3)) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 2 +Handler_read_key 4 +Handler_read_rnd_next 8 +# Status of testing query execution: +Variable_name Value +Handler_read_first 3 +Handler_read_key 5 +Handler_read_rnd_next 7 +Handler_update 2 + +DROP TABLE t1, t2; +#7 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +CREATE TABLE t2 (b INT); +INSERT INTO t2 VALUES (1), (2), (3); +# +# query: UPDATE t1, t2 SET a = 10 WHERE a IN (SELECT b FROM t2 WHERE t2.b < 3) +# select: SELECT * FROM t1, t2 WHERE a IN (SELECT b FROM t2 WHERE t2.b < 3) +# +EXPLAIN UPDATE t1, t2 SET a = 10 WHERE a IN (SELECT b FROM t2 WHERE t2.b < 3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(t1) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 update `test`.`t1` join `test`.`t2` semi join (`test`.`t2`) set `test`.`t1`.`a` = 10 where ((`test`.`t2`.`b` = `test`.`t1`.`a`) and (`test`.`t1`.`a` < 3)) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 3 +Handler_read_key 5 +Handler_read_rnd_next 12 +# Status of testing query execution: +Variable_name Value +Handler_read_first 5 +Handler_read_key 7 +Handler_read_rnd_next 15 +Handler_update 2 + +DROP TABLE t1, t2; +#8 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +CREATE TABLE t2 (b INT); +INSERT INTO t2 VALUES (1), (2), (3); +# +# query: UPDATE t1 t11, (SELECT * FROM t2) t12 SET t11.a = t11.a + 10 +# select: SELECT * FROM t1 t11, (SELECT * FROM t2) t12 +# +EXPLAIN UPDATE t1 t11, (SELECT * FROM t2) t12 SET t11.a = t11.a + 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t11 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 update `test`.`t1` `t11` join `test`.`t2` set `test`.`t11`.`a` = (`test`.`t11`.`a` + 10) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 2 +Handler_read_key 4 +Handler_read_rnd_next 8 +# Status of testing query execution: +Variable_name Value +Handler_read_first 4 +Handler_read_key 6 +Handler_read_rnd_next 16 +Handler_update 3 + +DROP TABLE t1, t2; +#9 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +CREATE TABLE t2 (b INT); +INSERT INTO t2 VALUES (1), (2), (3); +# +# query: UPDATE t1 t11, (SELECT 1 FROM DUAL) t12 SET t11.a = t11.a + 10 +# select: SELECT * FROM t1 t11, (SELECT 1 FROM DUAL) t12 +# +EXPLAIN UPDATE t1 t11, (SELECT 1 FROM DUAL) t12 SET t11.a = t11.a + 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL system NULL NULL NULL NULL 1 100.00 NULL +1 UPDATE t11 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 update `test`.`t1` `t11` join (/* select#2 */ select 1 AS `1`) `t12` set `test`.`t11`.`a` = (`test`.`t11`.`a` + 10) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 2 +Handler_read_rnd_next 5 +Handler_write 1 +# Status of testing query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 5 +Handler_read_rnd 3 +Handler_read_rnd_next 9 +Handler_update 3 +Handler_write 4 + +DROP TABLE t1, t2; +#10 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +CREATE TABLE t2 (b INT); +INSERT INTO t2 VALUES (1), (2), (3); +# +# query: UPDATE t1 t11, (SELECT * FROM t2) t12 SET t11.a = 10 WHERE t11.a > 1 +# select: SELECT * FROM t1 t11, (SELECT * FROM t2) t12 WHERE t11.a > 1 +# +EXPLAIN UPDATE t1 t11, (SELECT * FROM t2) t12 SET t11.a = 10 WHERE t11.a > 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t11 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 update `test`.`t1` `t11` join `test`.`t2` set `test`.`t11`.`a` = 10 where (`test`.`t11`.`a` > 1) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 2 +Handler_read_key 4 +Handler_read_rnd_next 8 +# Status of testing query execution: +Variable_name Value +Handler_read_first 3 +Handler_read_key 5 +Handler_read_rnd_next 12 +Handler_update 2 + +DROP TABLE t1, t2; +#11 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +# +# query: DELETE FROM t1 WHERE a > 1 LIMIT 1 +# select: SELECT * FROM t1 WHERE a > 1 LIMIT 1 +# +EXPLAIN DELETE FROM t1 WHERE a > 1 LIMIT 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 delete from `test`.`t1` where (`test`.`t1`.`a` > 1) limit 1 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 2 +Handler_read_rnd_next 2 +# Status of testing query execution: +Variable_name Value +Handler_delete 1 +Handler_read_first 1 +Handler_read_key 2 +Handler_read_rnd_next 2 + +DROP TABLE t1; +#12 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +# +# query: DELETE FROM t1 WHERE 0 +# select: SELECT * FROM t1 WHERE 0 +# +EXPLAIN DELETE FROM t1 WHERE 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 delete from `test`.`t1` where false +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 1 + +DROP TABLE t1; +#13 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +# +# query: DELETE FROM t1 USING t1 WHERE 0 +# select: SELECT * FROM t1 WHERE 0 +# +EXPLAIN DELETE FROM t1 USING t1 WHERE 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 delete `test`.`t1` from `test`.`t1` where false +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 1 + +DROP TABLE t1; +#14 +CREATE TABLE t1 (a INT, b INT, UNIQUE KEY (a), KEY (b)); +INSERT INTO t1 VALUES (3, 3), (7, 7); +# +# query: DELETE FROM t1 WHERE a = 3 +# select: SELECT * FROM t1 WHERE a = 3 +# +EXPLAIN DELETE FROM t1 WHERE a = 3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL range a a 5 const 1 100.00 Using where +Warnings: +Note 1003 delete from `test`.`t1` where (`test`.`t1`.`a` = 3) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 3 +# Status of testing query execution: +Variable_name Value +Handler_delete 1 +Handler_read_key 3 + +DROP TABLE t1; +#15 +CREATE TABLE t1 (a INT, b INT, UNIQUE KEY (a), KEY (b)); +INSERT INTO t1 VALUES (3, 3), (7, 7); +# +# query: DELETE FROM t1 WHERE a < 3 +# select: SELECT * FROM t1 WHERE a < 3 +# +EXPLAIN DELETE FROM t1 WHERE a < 3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL range a a 5 const 1 100.00 Using where +Warnings: +Note 1003 delete from `test`.`t1` where (`test`.`t1`.`a` < 3) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 4 +Handler_read_rnd_next 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 3 + +DROP TABLE t1; +#16 +CREATE TABLE t1 ( a int PRIMARY KEY ); +# +# query: DELETE FROM t1 WHERE t1.a > 0 ORDER BY t1.a +# select: SELECT * FROM t1 WHERE t1.a > 0 ORDER BY t1.a +# +EXPLAIN DELETE FROM t1 WHERE t1.a > 0 ORDER BY t1.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL range PRIMARY PRIMARY 4 const 1 100.00 Using where +Warnings: +Note 1003 delete from `test`.`t1` where (`test`.`t1`.`a` > 0) order by `test`.`t1`.`a` +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 2 +Handler_read_rnd_next 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 2 + +INSERT INTO t1 VALUES (1), (2), (3); +# +# query: DELETE FROM t1 WHERE t1.a > 0 ORDER BY t1.a +# select: SELECT * FROM t1 WHERE t1.a > 0 ORDER BY t1.a +# +EXPLAIN DELETE FROM t1 WHERE t1.a > 0 ORDER BY t1.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL range PRIMARY PRIMARY 4 const 3 100.00 Using where +Warnings: +Note 1003 delete from `test`.`t1` where (`test`.`t1`.`a` > 0) order by `test`.`t1`.`a` +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 2 +Handler_read_rnd_next 4 +# Status of testing query execution: +Variable_name Value +Handler_delete 3 +Handler_read_key 2 +Handler_read_next 3 + +DROP TABLE t1; +#17 +CREATE TABLE t1(a INT PRIMARY KEY); +INSERT INTO t1 VALUES (4),(3),(1),(2); +# +# query: DELETE FROM t1 WHERE (@a:= a) ORDER BY a LIMIT 1 +# select: SELECT * FROM t1 WHERE (@a:= a) ORDER BY a LIMIT 1 +# +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +EXPLAIN DELETE FROM t1 WHERE (@a:= a) ORDER BY a LIMIT 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL index NULL PRIMARY 4 NULL 4 100.00 Using where +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +Note 1003 delete from `test`.`t1` where (0 <> (@a:=`test`.`t1`.`a`)) order by `test`.`t1`.`a` limit 1 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 2 +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +# Status of testing query execution: +Variable_name Value +Handler_delete 1 +Handler_read_first 1 +Handler_read_key 2 + +DROP TABLE t1; +#18 +CREATE TABLE t1 (a DATE, b TIME, c INT, KEY c(c), KEY b(b), KEY a(a)); +INSERT INTO t1 VALUES (), (), (), (), (), (), (), (), (), (); +UPDATE t1 SET a = c, b = c; +# +# query: DELETE FROM t1 ORDER BY a ASC, b ASC LIMIT 1 +# select: SELECT * FROM t1 ORDER BY a ASC, b ASC LIMIT 1 +# +EXPLAIN DELETE FROM t1 ORDER BY a ASC, b ASC LIMIT 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 10 100.00 Using filesort +Warnings: +Note 1003 delete from `test`.`t1` order by `test`.`t1`.`a`,`test`.`t1`.`b` limit 1 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 4 +Handler_read_rnd_next 11 +Sort_rows 1 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_delete 1 +Handler_read_first 1 +Handler_read_key 5 +Handler_read_rnd 1 +Handler_read_rnd_next 11 +Sort_rows 10 +Sort_scan 1 + +DROP TABLE t1; +#19 +CREATE TABLE t1 (a1 INT NOT NULL, b1 INT NOT NULL); +CREATE TABLE t2 (a2 INT NOT NULL, b2 INT NOT NULL, PRIMARY KEY (a2,b2)); +CREATE TABLE t3 (a3 INT NOT NULL, b3 INT NOT NULL, PRIMARY KEY (a3,b3)); +INSERT INTO t1 VALUES (1,1), (2,1), (1,3); +INSERT INTO t2 VALUES (1,1), (2,2), (3,3); +INSERT INTO t3 VALUES (1,1), (2,1), (1,3); +# +# query: DELETE t1,t2,t3 FROM t1,t2,t3 WHERE a1=a2 AND b2=a3 AND b1=b3 +# select: SELECT * FROM t1,t2,t3 WHERE a1=a2 AND b2=a3 AND b1=b3 +# +EXPLAIN DELETE t1,t2,t3 FROM t1,t2,t3 WHERE a1=a2 AND b2=a3 AND b1=b3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 DELETE t2 NULL ref PRIMARY PRIMARY 4 test.t1.a1 1 100.00 NULL +1 DELETE t3 NULL eq_ref PRIMARY PRIMARY 8 test.t2.b2,test.t1.b1 1 100.00 NULL +Warnings: +Note 1003 delete `test`.`t1`, `test`.`t2`, `test`.`t3` from `test`.`t1` join `test`.`t2` join `test`.`t3` where ((`test`.`t3`.`b3` = `test`.`t1`.`b1`) and (`test`.`t3`.`a3` = `test`.`t2`.`b2`) and (`test`.`t2`.`a2` = `test`.`t1`.`a1`)) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 13 +Handler_read_next 3 +Handler_read_rnd_next 4 +# Status of testing query execution: +Variable_name Value +Handler_delete 8 +Handler_read_first 1 +Handler_read_key 18 +Handler_read_next 3 +Handler_read_rnd 5 +Handler_read_rnd_next 4 + +DROP TABLE t1, t2, t3; +#20 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +CREATE TABLE t2 (a INT); +INSERT INTO t2 VALUES (1), (2), (3); +# +# query: UPDATE t1 SET a = 10 WHERE a IN (SELECT a FROM t2) +# select: SELECT * FROM t1 WHERE a IN (SELECT a FROM t2) +# +EXPLAIN UPDATE t1 SET a = 10 WHERE a IN (SELECT a FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(t1) +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`a` = 10 where (`test`.`t2`.`a` = `test`.`t1`.`a`) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 2 +Handler_read_key 4 +Handler_read_rnd_next 8 +# Status of testing query execution: +Variable_name Value +Handler_read_first 4 +Handler_read_key 6 +Handler_read_rnd_next 10 +Handler_update 3 + +DROP TABLE t1, t2; +#21 +CREATE TABLE t1 (a1 INT); +INSERT INTO t1 VALUES (1), (2), (3), (4), (5); +CREATE TABLE t2 (a2 VARCHAR(10)) charset utf8mb4; +INSERT INTO t2 VALUES (1), (2), (3), (4), (5); +SET @save_optimizer_switch= @@optimizer_switch; +# +# query: DELETE FROM t1 WHERE a1 IN (SELECT a2 FROM t2 WHERE a2 > 2) +# select: SELECT * FROM t1 WHERE a1 IN (SELECT a2 FROM t2 WHERE a2 > 2) +# +EXPLAIN DELETE FROM t1 WHERE a1 IN (SELECT a2 FROM t2 WHERE a2 > 2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 5 100.00 Using where +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 5 20.00 Using where +Warnings: +Note 1003 delete from `test`.`t1` where (`test`.`t1`.`a1`,(/* select#2 */ select `test`.`t2`.`a2` from `test`.`t2` where ((`test`.`t2`.`a2` > 2) and ((`test`.`t1`.`a1`) = `test`.`t2`.`a2`)))) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 6 +Handler_read_key 8 +Handler_read_rnd_next 30 +# Status of testing query execution: +Variable_name Value +Handler_delete 3 +Handler_read_first 6 +Handler_read_key 8 +Handler_read_rnd_next 30 + +SET @@optimizer_switch= @save_optimizer_switch; +TRUNCATE t1; +INSERT INTO t1 VALUES (1), (2), (3), (4), (5); +# +# query: DELETE FROM t1 WHERE a1 IN (SELECT a2 FROM t2 WHERE a2 > 2) +# select: SELECT * FROM t1 WHERE a1 IN (SELECT a2 FROM t2 WHERE a2 > 2) +# +EXPLAIN DELETE FROM t1 WHERE a1 IN (SELECT a2 FROM t2 WHERE a2 > 2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 5 20.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 delete from `test`.`t1` where ((`test`.`t2`.`a2` > 2) and (cast(`test`.`t1`.`a1` as double) = cast(`test`.`t2`.`a2` as double))) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 2 +Handler_read_key 4 +Handler_read_rnd_next 12 +# Status of testing query execution: +Variable_name Value +Handler_delete 3 +Handler_read_first 6 +Handler_read_key 8 +Handler_read_rnd_next 30 + +DROP TABLE t1, t2; +#22 +CREATE TABLE t1 (i INT, j INT); +INSERT INTO t1 VALUES (1, 1), (2, 2), (3, 3), (4, 4), (5, 5); +# +# query: UPDATE t1 SET i = 10 +# select: SELECT * FROM t1 +# +EXPLAIN UPDATE t1 SET i = 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`i` = 10 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 3 +Handler_read_rnd_next 6 +# Status of testing query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 3 +Handler_read_rnd_next 6 +Handler_update 5 + +DROP TABLE t1; +#23 +CREATE TABLE t1 (i INT, j INT); +INSERT INTO t1 VALUES (1, 1), (2, 2), (3, 3), (4, 4), (5, 5); +# +# query: DELETE FROM t1 +# select: SELECT * FROM t1 +# +EXPLAIN DELETE FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 5 100.00 Deleting all rows +Warnings: +Note 1003 delete from `test`.`t1` +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 3 +Handler_read_rnd_next 6 +# Status of testing query execution: +Variable_name Value +Handler_delete 5 +Handler_read_first 1 +Handler_read_key 3 +Handler_read_rnd_next 6 + +DROP TABLE t1; +#24 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2(a INT, b INT, c INT, d INT, INDEX(a, b, c)); +INSERT INTO t2 (a, b, c) SELECT i, i, i FROM t1; +INSERT INTO t2 (a, b, c) SELECT t1.i, t1.i, t1.i FROM t1, t1 x1, t1 x2; +# +# query: DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# select: SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# +EXPLAIN DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t2 NULL index NULL a 15 NULL X 100.00 Using where +Warnings: +Note 1003 delete from `test`.`t2` where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 5 +Handler_read_rnd_next 16936 +# Status of testing query execution: +Variable_name Value +Handler_delete 5 +Handler_read_first 1 +Handler_read_key 5 +Handler_read_next 4 + +DROP TABLE t1, t2; +#25 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (1), (2), (3); +CREATE TABLE t2 (i INT); +# +# query: INSERT INTO t2 SELECT * FROM t1 +# select: SELECT * FROM t1 +# +EXPLAIN INSERT INTO t2 SELECT * FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 INSERT t2 NULL ALL NULL NULL NULL NULL NULL NULL NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 insert into `test`.`t2` /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 2 +Handler_read_rnd_next 4 +# Status of testing query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 3 +Handler_read_rnd_next 4 +Handler_write 3 + +# +# query: INSERT INTO t2 SELECT * FROM t1 JOIN t1 AS tt USING(i) +# select: SELECT * FROM t1 JOIN t1 AS tt USING(i) +# +EXPLAIN INSERT INTO t2 SELECT * FROM t1 JOIN t1 AS tt USING(i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 INSERT t2 NULL ALL NULL NULL NULL NULL NULL NULL NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE tt NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +Warnings: +Note 1003 insert into `test`.`t2` /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` join `test`.`t1` `tt` where (`test`.`tt`.`i` = `test`.`t1`.`i`) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 2 +Handler_read_key 3 +Handler_read_rnd_next 8 +# Status of testing query execution: +Variable_name Value +Handler_read_first 2 +Handler_read_key 4 +Handler_read_rnd_next 8 +Handler_write 3 + +DROP TABLE t1, t2; +#26 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (1), (2), (3); +CREATE TABLE t2 (i INT); +# +# query: REPLACE INTO t2 SELECT * FROM t1 +# select: SELECT * FROM t1 +# +EXPLAIN REPLACE INTO t2 SELECT * FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 REPLACE t2 NULL ALL NULL NULL NULL NULL NULL NULL NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 replace into `test`.`t2` /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 2 +Handler_read_rnd_next 4 +# Status of testing query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 3 +Handler_read_rnd_next 4 +Handler_write 3 + +DROP TABLE t1, t2; +#27 +CREATE TABLE t1 (i INT); +# +# query: INSERT INTO t1 SET i = 10 +# select: +# +EXPLAIN INSERT INTO t1 SET i = 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 INSERT t1 NULL ALL NULL NULL NULL NULL NULL NULL NULL +Warnings: +Note 1003 insert into `test`.`t1` (`test`.`t1`.`i`) values (10) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# Status of testing query execution: +Variable_name Value +Handler_read_key 1 +Handler_write 1 + +DROP TABLE t1; +#28 +CREATE TABLE t1 (i INT); +# +# query: REPLACE INTO t1 SET i = 10 +# select: +# +EXPLAIN REPLACE INTO t1 SET i = 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 REPLACE t1 NULL ALL NULL NULL NULL NULL NULL NULL NULL +Warnings: +Note 1003 replace into `test`.`t1` (`test`.`t1`.`i`) values (10) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# Status of testing query execution: +Variable_name Value +Handler_read_key 1 +Handler_write 1 + +DROP TABLE t1; +#29 +CREATE TABLE t1 (a INT, i INT PRIMARY KEY); +INSERT INTO t1 (i) VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +# +# query: DELETE FROM t1 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 1 +# select: SELECT * FROM t1 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 1 +# +EXPLAIN DELETE FROM t1 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL range PRIMARY PRIMARY 4 const X 100.00 Using where +Warnings: +Note 1003 delete from `test`.`t1` where ((`test`.`t1`.`i` > 10) and (`test`.`t1`.`i` <= 18)) order by `test`.`t1`.`i` limit 1 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 4 +Handler_read_rnd_next 1 +# Status of testing query execution: +Variable_name Value +Handler_delete 1 +Handler_read_key 3 + +DROP TABLE t1; +#30 +CREATE TABLE t1(a INT, i CHAR(2), INDEX(i(1))) charset utf8mb4; +INSERT INTO t1 (i) VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +# +# query: DELETE FROM t1 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 5 +# select: SELECT * FROM t1 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 5 +# +EXPLAIN DELETE FROM t1 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 26 100.00 Using where; Using filesort +Warnings: +Warning 1739 Cannot use range access on index 'i' due to type or collation conversion on field 'i' +Warning 1739 Cannot use range access on index 'i' due to type or collation conversion on field 'i' +Note 1003 delete from `test`.`t1` where ((`test`.`t1`.`i` > 10) and (`test`.`t1`.`i` <= 18)) order by `test`.`t1`.`i` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 3 +Handler_read_rnd_next 27 +Sort_rows 5 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_delete 5 +Handler_read_first 1 +Handler_read_key 8 +Handler_read_rnd 5 +Handler_read_rnd_next 27 +Sort_rows 8 +Sort_scan 1 + +DROP TABLE t1; +#31 +CREATE TABLE t1 (i INT); +INSERT INTO t1 (i) VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2(a INT, b INT, c INT, d INT, INDEX(a, b, c)); +INSERT INTO t2 (a, b, c) SELECT i, i, i FROM t1; +# +# query: DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# select: SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# +EXPLAIN DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t2 NULL ALL NULL NULL NULL NULL 26 100.00 Using where; Using filesort +Warnings: +Note 1003 delete from `test`.`t2` where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 5 +Handler_read_rnd_next 27 +# Status of testing query execution: +Variable_name Value +Handler_delete 1 +Handler_read_first 1 +Handler_read_key 6 +Handler_read_rnd 1 +Handler_read_rnd_next 27 +Sort_rows 1 +Sort_scan 1 + +DROP TABLE t1, t2; +#32 +CREATE TABLE t1 (i INT); +INSERT INTO t1 (i) VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2(a INT, b INT, c INT, d INT, INDEX(a, b, c)); +INSERT INTO t2 (a, b, c) SELECT i, i, i FROM t1; +INSERT INTO t2 (a, b, c) SELECT t1.i, t1.i, t1.i FROM t1, t1 x1, t1 x2; +# +# query: DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# select: SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# +EXPLAIN DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t2 NULL index NULL a 15 NULL X 100.00 Using where +Warnings: +Note 1003 delete from `test`.`t2` where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 5 +Handler_read_rnd_next 16936 +# Status of testing query execution: +Variable_name Value +Handler_delete 5 +Handler_read_first 1 +Handler_read_key 5 +Handler_read_next 4 + +DROP TABLE t1, t2; +#33 +CREATE TABLE t1 (i INT); +INSERT INTO t1 (i) VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2 (a CHAR(2), b CHAR(2), c CHAR(2), d CHAR(2), INDEX (a,b(1),c)) +charset utf8mb4; +INSERT INTO t2 SELECT i, i, i, i FROM t1; +# +# query: DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# select: SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# +EXPLAIN DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t2 NULL ALL NULL NULL NULL NULL 26 100.00 Using where; Using filesort +Warnings: +Warning 1739 Cannot use range access on index 'a' due to type or collation conversion on field 'b' +Note 1003 delete from `test`.`t2` where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 5 +Handler_read_rnd_next 27 +Sort_rows 1 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_delete 1 +Handler_read_first 1 +Handler_read_key 6 +Handler_read_rnd 1 +Handler_read_rnd_next 27 +Sort_rows 1 +Sort_scan 1 + +DROP TABLE t1, t2; +#34 +CREATE TABLE t1 (i INT); +INSERT INTO t1 (i) VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2 (a CHAR(2), b CHAR(2), c CHAR(2), d CHAR(2), INDEX (a,b,c)) +charset utf8mb4 ENGINE=HEAP; +INSERT INTO t2 SELECT i, i, i, i FROM t1; +# +# query: DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# select: SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# +EXPLAIN DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t2 NULL ALL NULL NULL NULL NULL 26 100.00 Using where; Using filesort +Warnings: +Warning 1739 Cannot use range access on index 'a' due to type or collation conversion on field 'b' +Note 1003 delete from `test`.`t2` where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 4 +Handler_read_rnd_next 27 +Sort_rows 1 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_delete 1 +Handler_read_key 4 +Handler_read_rnd 1 +Handler_read_rnd_next 27 +Sort_rows 1 +Sort_scan 1 + +DROP TABLE t1, t2; +#35 +CREATE TABLE t1 (i INT); +INSERT INTO t1 (i) VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35),(36),(37),(38),(39), +(40),(41),(42),(43),(44); +CREATE TABLE t2 (i INT, key1 INT, key2 INT, INDEX (key1), INDEX (key2)); +INSERT INTO t2 (key1, key2) SELECT i, i FROM t1; +# +# query: DELETE FROM t2 WHERE key1 < 13 or key2 < 14 ORDER BY key1 +# select: SELECT * FROM t2 WHERE key1 < 13 or key2 < 14 ORDER BY key1 +# +EXPLAIN DELETE FROM t2 WHERE key1 < 13 or key2 < 14 ORDER BY key1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t2 NULL index_merge key1,key2 key1,key2 5,5 NULL X 100.00 Using sort_union(key1,key2); Using where; Using filesort +Warnings: +Note 1003 delete from `test`.`t2` where ((`test`.`t2`.`key1` < 13) or (`test`.`t2`.`key2` < 14)) order by `test`.`t2`.`key1` +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 9 +Handler_read_next 7 +Handler_read_rnd 4 +Sort_rows 4 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_delete 4 +Handler_read_key 13 +Handler_read_next 7 +Handler_read_rnd 8 +Sort_rows 4 +Sort_scan 1 + +DROP TABLE t1, t2; +#36 +CREATE TABLE t1 (i INT); +INSERT INTO t1 (i) VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2(a INT, i INT PRIMARY KEY); +INSERT INTO t2 (i) SELECT i FROM t1; +# +# query: DELETE FROM t2 WHERE i > 10 AND i <= 18 ORDER BY i DESC LIMIT 1 +# select: SELECT * FROM t2 WHERE i > 10 AND i <= 18 ORDER BY i DESC LIMIT 1 +# +EXPLAIN DELETE FROM t2 WHERE i > 10 AND i <= 18 ORDER BY i DESC LIMIT 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t2 NULL range PRIMARY PRIMARY 4 const X 100.00 Using where; Backward index scan +Warnings: +Note 1003 delete from `test`.`t2` where ((`test`.`t2`.`i` > 10) and (`test`.`t2`.`i` <= 18)) order by `test`.`t2`.`i` desc limit 1 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 4 +Handler_read_rnd_next 1 +# Status of testing query execution: +Variable_name Value +Handler_delete 1 +Handler_read_key 3 + +DROP TABLE t1, t2; +#37 +CREATE TABLE t1 (i INT); +INSERT INTO t1 (i) VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2 (a CHAR(2), b CHAR(2), c CHAR(2), INDEX (a, b)) charset utf8mb4; +INSERT INTO t2 SELECT i, i, i FROM t1; +# +# query: DELETE FROM t2 ORDER BY a, b DESC LIMIT 5 +# select: SELECT * FROM t2 ORDER BY a, b DESC LIMIT 5 +# +EXPLAIN DELETE FROM t2 ORDER BY a, b DESC LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t2 NULL ALL NULL NULL NULL NULL 26 100.00 Using filesort +Warnings: +Note 1003 delete from `test`.`t2` order by `test`.`t2`.`a`,`test`.`t2`.`b` desc limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 4 +Handler_read_rnd_next 27 +Sort_rows 5 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_delete 5 +Handler_read_first 1 +Handler_read_key 9 +Handler_read_rnd 5 +Handler_read_rnd_next 27 +Sort_rows 26 +Sort_scan 1 + +DROP TABLE t1, t2; +#38 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2 (a CHAR(2), b CHAR(2), c INT, INDEX (a, b)) charset utf8mb4; +INSERT INTO t2 (a, b) SELECT i, i FROM t1; +INSERT INTO t2 (a, b) SELECT t1.i, t1.i FROM t1, t1 x1, t1 x2; +# +# query: DELETE FROM t2 ORDER BY a DESC, b DESC LIMIT 5 +# select: SELECT * FROM t2 ORDER BY a DESC, b DESC LIMIT 5 +# +EXPLAIN DELETE FROM t2 ORDER BY a DESC, b DESC LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t2 NULL index NULL a 18 NULL X 100.00 NULL +Warnings: +Note 1003 delete from `test`.`t2` order by `test`.`t2`.`a` desc,`test`.`t2`.`b` desc limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 4 +Handler_read_last 1 +Handler_read_rnd_next 20 +# Status of testing query execution: +Variable_name Value +Handler_delete 5 +Handler_read_key 4 +Handler_read_last 1 +Handler_read_prev 4 + +DROP TABLE t1, t2; +#39 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2(a INT, i INT PRIMARY KEY); +INSERT INTO t2 (i) SELECT i FROM t1; +# +# query: UPDATE t2 SET a = 10 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 1 +# select: SELECT * FROM t2 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 1 +# +EXPLAIN UPDATE t2 SET a = 10 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t2 NULL range PRIMARY PRIMARY 4 const X 100.00 Using where; Using temporary +Warnings: +Note 1003 update `test`.`t2` set `test`.`t2`.`a` = 10 where ((`test`.`t2`.`i` > 10) and (`test`.`t2`.`i` <= 18)) order by `test`.`t2`.`i` limit 1 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 4 +Handler_read_rnd_next 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 4 +Handler_read_rnd 1 +Handler_update 1 + +DROP TABLE t1, t2; +#40 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2(a INT, i CHAR(2), INDEX(i(1))) charset utf8mb4; +INSERT INTO t2 (i) SELECT i FROM t1; +# +# query: UPDATE t2 SET a = 10 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 5 +# select: SELECT * FROM t2 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 5 +# +EXPLAIN UPDATE t2 SET a = 10 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t2 NULL ALL NULL NULL NULL NULL 26 100.00 Using where; Using filesort +Warnings: +Warning 1739 Cannot use range access on index 'i' due to type or collation conversion on field 'i' +Warning 1739 Cannot use range access on index 'i' due to type or collation conversion on field 'i' +Note 1003 update `test`.`t2` set `test`.`t2`.`a` = 10 where ((`test`.`t2`.`i` > 10) and (`test`.`t2`.`i` <= 18)) order by `test`.`t2`.`i` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 3 +Handler_read_rnd_next 27 +Sort_rows 5 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 8 +Handler_read_rnd 5 +Handler_read_rnd_next 27 +Handler_update 5 +Sort_rows 5 +Sort_scan 1 + +DROP TABLE t1, t2; +#41 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2(a INT, b INT, c INT, d INT, INDEX(a, b, c)); +INSERT INTO t2 (a, b, c) SELECT i, i, i FROM t1; +# +# query: UPDATE t2 SET d = 10 WHERE b = 10 ORDER BY a, c LIMIT 5 +# select: SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# +EXPLAIN UPDATE t2 SET d = 10 WHERE b = 10 ORDER BY a, c LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t2 NULL ALL NULL NULL NULL NULL 26 100.00 Using where; Using filesort +Warnings: +Note 1003 update `test`.`t2` set `test`.`t2`.`d` = 10 where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 5 +Handler_read_rnd_next 27 +# Status of testing query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 6 +Handler_read_rnd 1 +Handler_read_rnd_next 27 +Handler_update 1 +Sort_rows 1 +Sort_scan 1 + +DROP TABLE t1, t2; +#42 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2(a INT, b INT, c INT, d INT, INDEX(a, b, c)); +INSERT INTO t2 (a, b, c) SELECT i, i, i FROM t1; +INSERT INTO t2 (a, b, c) SELECT t1.i, t1.i, t1.i FROM t1, t1 x1, t1 x2; +# +# query: UPDATE t2 SET d = 10 WHERE b = 10 ORDER BY a, c LIMIT 5 +# select: SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# +EXPLAIN UPDATE t2 SET d = 10 WHERE b = 10 ORDER BY a, c LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t2 NULL index NULL a 15 NULL X 100.00 Using where; Using temporary +Warnings: +Note 1003 update `test`.`t2` set `test`.`t2`.`d` = 10 where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 5 +Handler_read_rnd_next 16936 +# Status of testing query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 10 +Handler_read_next 4 +Handler_read_rnd 5 +Handler_update 5 + +DROP TABLE t1, t2; +#43 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2 (a CHAR(2), b CHAR(2), c CHAR(2), d CHAR(2), INDEX (a,b(1),c)) +charset utf8mb4; +INSERT INTO t2 SELECT i, i, i, i FROM t1; +# +# query: UPDATE t2 SET d = 10 WHERE b = 10 ORDER BY a, c LIMIT 5 +# select: SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# +EXPLAIN UPDATE t2 SET d = 10 WHERE b = 10 ORDER BY a, c LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t2 NULL ALL NULL NULL NULL NULL 26 100.00 Using where; Using filesort +Warnings: +Warning 1739 Cannot use range access on index 'a' due to type or collation conversion on field 'b' +Note 1003 update `test`.`t2` set `test`.`t2`.`d` = 10 where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 5 +Handler_read_rnd_next 27 +Sort_rows 1 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 6 +Handler_read_rnd 1 +Handler_read_rnd_next 27 +Sort_rows 1 +Sort_scan 1 + +DROP TABLE t1, t2; +#44 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2 (a CHAR(2), b CHAR(2), c CHAR(2), d CHAR(2), INDEX (a,b,c)) +charset utf8mb4 ENGINE=HEAP; +INSERT INTO t2 SELECT i, i, i, i FROM t1; +# +# query: UPDATE t2 SET d = 10 WHERE b = 10 ORDER BY a, c LIMIT 5 +# select: SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# +EXPLAIN UPDATE t2 SET d = 10 WHERE b = 10 ORDER BY a, c LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t2 NULL ALL NULL NULL NULL NULL 26 100.00 Using where; Using filesort +Warnings: +Warning 1739 Cannot use range access on index 'a' due to type or collation conversion on field 'b' +Note 1003 update `test`.`t2` set `test`.`t2`.`d` = 10 where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 4 +Handler_read_rnd_next 27 +Sort_rows 1 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 4 +Handler_read_rnd 1 +Handler_read_rnd_next 27 +Sort_rows 1 +Sort_scan 1 + +DROP TABLE t1, t2; +#45 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35),(36),(37),(38),(39), +(40),(41),(42),(43),(44); +CREATE TABLE t2 (i INT, key1 INT, key2 INT, INDEX (key1), INDEX (key2)); +INSERT INTO t2 (key1, key2) SELECT i, i FROM t1; +# +# query: UPDATE t2 SET i = 123 WHERE key1 < 13 or key2 < 14 ORDER BY key1 +# select: SELECT * FROM t2 WHERE key1 < 13 or key2 < 14 ORDER BY key1 +# +EXPLAIN UPDATE t2 SET i = 123 WHERE key1 < 13 or key2 < 14 ORDER BY key1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t2 NULL index_merge key1,key2 key1,key2 5,5 NULL X 100.00 Using sort_union(key1,key2); Using where; Using filesort +Warnings: +Note 1003 update `test`.`t2` set `test`.`t2`.`i` = 123 where ((`test`.`t2`.`key1` < 13) or (`test`.`t2`.`key2` < 14)) order by `test`.`t2`.`key1` +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 9 +Handler_read_next 7 +Handler_read_rnd 4 +Sort_rows 4 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 13 +Handler_read_next 7 +Handler_read_rnd 8 +Handler_update 4 +Sort_rows 4 +Sort_scan 1 + +DROP TABLE t1, t2; +#46 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2(a INT, i INT PRIMARY KEY); +INSERT INTO t2 (i) SELECT i FROM t1; +# +# query: UPDATE t2 SET a = 10 WHERE i > 10 AND i <= 18 ORDER BY i DESC LIMIT 1 +# select: SELECT * FROM t2 WHERE i > 10 AND i <= 18 ORDER BY i DESC LIMIT 1 +# +EXPLAIN UPDATE t2 SET a = 10 WHERE i > 10 AND i <= 18 ORDER BY i DESC LIMIT 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t2 NULL range PRIMARY PRIMARY 4 const X 100.00 Using where; Backward index scan; Using temporary +Warnings: +Note 1003 update `test`.`t2` set `test`.`t2`.`a` = 10 where ((`test`.`t2`.`i` > 10) and (`test`.`t2`.`i` <= 18)) order by `test`.`t2`.`i` desc limit 1 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 4 +Handler_read_rnd_next 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 4 +Handler_read_rnd 1 +Handler_update 1 + +DROP TABLE t1, t2; +#47 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2 (a CHAR(2), b CHAR(2), c CHAR(2), INDEX (a, b)) charset utf8mb4; +INSERT INTO t2 SELECT i, i, i FROM t1; +# +# query: UPDATE t2 SET c = 10 ORDER BY a, b DESC LIMIT 5 +# select: SELECT * FROM t2 ORDER BY a, b DESC LIMIT 5 +# +EXPLAIN UPDATE t2 SET c = 10 ORDER BY a, b DESC LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t2 NULL ALL NULL NULL NULL NULL 26 100.00 Using filesort +Warnings: +Note 1003 update `test`.`t2` set `test`.`t2`.`c` = 10 order by `test`.`t2`.`a`,`test`.`t2`.`b` desc limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 4 +Handler_read_rnd_next 27 +Sort_rows 5 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 9 +Handler_read_rnd 5 +Handler_read_rnd_next 27 +Handler_update 4 +Sort_rows 5 +Sort_scan 1 + +DROP TABLE t1, t2; +#48 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2 (a CHAR(2), b CHAR(2), c INT, INDEX (a, b)) charset utf8mb4; +INSERT INTO t2 (a, b) SELECT i, i FROM t1; +INSERT INTO t2 (a, b) SELECT t1.i, t1.i FROM t1, t1 x1, t1 x2; +# +# query: UPDATE t2 SET c = 10 ORDER BY a DESC, b DESC LIMIT 5 +# select: SELECT * FROM t2 ORDER BY a DESC, b DESC LIMIT 5 +# +EXPLAIN UPDATE t2 SET c = 10 ORDER BY a DESC, b DESC LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t2 NULL index NULL a 18 NULL X 100.00 Using temporary +Warnings: +Note 1003 update `test`.`t2` set `test`.`t2`.`c` = 10 order by `test`.`t2`.`a` desc,`test`.`t2`.`b` desc limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 4 +Handler_read_last 1 +Handler_read_rnd_next 20 +# Status of testing query execution: +Variable_name Value +Handler_read_key 9 +Handler_read_last 1 +Handler_read_prev 4 +Handler_read_rnd 5 +Handler_update 5 + +DROP TABLE t1, t2; +#49 +CREATE TABLE t1 ( +pk INT NOT NULL AUTO_INCREMENT, +c1_idx CHAR(1) DEFAULT 'y', +c2 INT, +PRIMARY KEY (pk), +INDEX c1_idx (c1_idx) +) charset utf8mb4; +INSERT INTO t1 VALUES (1,'y',1), (2,'n',2), (3,'y',3), (4,'n',4); +# +# query: UPDATE t1 SET c2 = 0 WHERE c1_idx = 'y' ORDER BY pk DESC LIMIT 2 +# select: SELECT * FROM t1 WHERE c1_idx = 'y' ORDER BY pk DESC LIMIT 2 +# +EXPLAIN UPDATE t1 SET c2 = 0 WHERE c1_idx = 'y' ORDER BY pk DESC LIMIT 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL range c1_idx c1_idx 5 const 2 100.00 Using where; Backward index scan; Using temporary +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`c2` = 0 where (`test`.`t1`.`c1_idx` = 'y') order by `test`.`t1`.`pk` desc limit 2 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 6 +Handler_read_rnd_next 2 +# Status of testing query execution: +Variable_name Value +Handler_read_key 6 +Handler_read_prev 1 +Handler_read_rnd 2 +Handler_update 2 + +# +# query: DELETE FROM t1 WHERE c1_idx = 'y' ORDER BY pk DESC LIMIT 2 +# select: SELECT * FROM t1 WHERE c1_idx = 'y' ORDER BY pk DESC LIMIT 2 +# +EXPLAIN DELETE FROM t1 WHERE c1_idx = 'y' ORDER BY pk DESC LIMIT 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL range c1_idx c1_idx 5 const 2 100.00 Using where; Backward index scan +Warnings: +Note 1003 delete from `test`.`t1` where (`test`.`t1`.`c1_idx` = 'y') order by `test`.`t1`.`pk` desc limit 2 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 6 +Handler_read_rnd_next 2 +# Status of testing query execution: +Variable_name Value +Handler_delete 2 +Handler_read_key 4 +Handler_read_prev 1 + +DROP TABLE t1; +#50 +CREATE TABLE t1 (a INT AUTO_INCREMENT PRIMARY KEY); +INSERT INTO t1 VALUES (),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(); +# +# query: UPDATE t1 SET a=a+10 WHERE a > 34 +# select: SELECT * FROM t1 WHERE a > 34 +# +EXPLAIN UPDATE t1 SET a=a+10 WHERE a > 34; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL range PRIMARY PRIMARY 4 const 2 100.00 Using where; Using temporary +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`a` = (`test`.`t1`.`a` + 10) where (`test`.`t1`.`a` > 34) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 3 +Handler_read_last 1 +Handler_read_rnd_next 3 +# Status of testing query execution: +Variable_name Value +Handler_read_key 4 +Handler_read_next 2 +Handler_read_rnd 2 +Handler_update 2 + +DROP TABLE t1; +#51 +CREATE TABLE t1 (c1 INT, c2 INT, c3 INT); +CREATE TABLE t2 (c1 INT, c2 INT); +INSERT INTO t1 VALUES (1, 1, 10), (2, 2, 20); +# +# query: UPDATE t1 LEFT JOIN t2 ON t1.c1 = t2.c1 SET t2.c2 = 10 +# select: SELECT * FROM t1 LEFT JOIN t2 ON t1.c1 = t2.c1 +# +EXPLAIN UPDATE t1 LEFT JOIN t2 ON t1.c1 = t2.c1 SET t2.c2 = 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 UPDATE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 update `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`c1` = `test`.`t1`.`c1`)) set `test`.`t2`.`c2` = 10 where true +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 2 +Handler_read_key 7 +Handler_read_rnd_next 4 +# Status of testing query execution: +Variable_name Value +Handler_read_first 3 +Handler_read_key 8 +Handler_read_rnd_next 5 + +# +# query: UPDATE t1 LEFT JOIN t2 ON t1.c1 = t2.c1 SET t2.c2 = 10 WHERE t1.c3 = 10 +# select: SELECT * FROM t1 LEFT JOIN t2 ON t1.c1 = t2.c1 WHERE t1.c3 = 10 +# +EXPLAIN UPDATE t1 LEFT JOIN t2 ON t1.c1 = t2.c1 SET t2.c2 = 10 WHERE t1.c3 = 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 UPDATE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 update `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`c1` = `test`.`t1`.`c1`)) set `test`.`t2`.`c2` = 10 where (`test`.`t1`.`c3` = 10) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 2 +Handler_read_key 7 +Handler_read_rnd_next 4 +# Status of testing query execution: +Variable_name Value +Handler_read_first 2 +Handler_read_key 7 +Handler_read_rnd_next 4 + +DROP TABLE t1, t2; +#52 +CREATE TABLE t1(f1 INT, f2 INT); +CREATE TABLE t2(f3 INT, f4 INT); +CREATE INDEX IDX ON t2(f3); +INSERT INTO t1 VALUES(1,0),(2,0); +INSERT INTO t2 VALUES(1,1),(2,2); +# +# query: UPDATE t1 SET t1.f2=(SELECT MAX(t2.f4) FROM t2 WHERE t2.f3=t1.f1) +# select: SELECT (SELECT MAX(t2.f4) FROM t2 WHERE t2.f3=t1.f1) FROM t1 +# +EXPLAIN UPDATE t1 SET t1.f2=(SELECT MAX(t2.f4) FROM t2 WHERE t2.f3=t1.f1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DEPENDENT SUBQUERY t2 NULL ref IDX IDX 5 test.t1.f1 1 100.00 NULL +Warnings: +Note 1276 Field or reference 'test.t1.f1' of SELECT #2 was resolved in SELECT #1 +Note 1003 update `test`.`t1` set `test`.`t1`.`f2` = (/* select#2 */ select max(`test`.`t2`.`f4`) from `test`.`t2` where (`test`.`t2`.`f3` = `test`.`t1`.`f1`)) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 7 +Handler_read_next 2 +Handler_read_rnd_next 3 +# Status of testing query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 7 +Handler_read_next 2 +Handler_read_rnd_next 3 +Handler_update 2 + +DROP TABLE t1, t2; +#55 +CREATE TABLE t1(a INT); +INSERT INTO t1 VALUES (1); +SET @a = NULL; +EXPLAIN DELETE FROM t1 WHERE (@a:= a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +Note 1003 delete from `test`.`t1` where (0 <> (@a:=`test`.`t1`.`a`)) +DROP TABLE t1; +#56 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +DELETE FROM t1 USING t1 WHERE uknown_column = 12345; +ERROR 42S22: Unknown column 'uknown_column' in 'where clause' +EXPLAIN DELETE FROM t1 USING t1 WHERE uknown_column = 12345; +ERROR 42S22: Unknown column 'uknown_column' in 'where clause' +DROP TABLE t1; +#57 +CREATE TABLE t1(f1 INT); +EXPLAIN UPDATE t1 SET f2=1 ORDER BY f2; +ERROR 42S22: Unknown column 'f2' in 'field list' +UPDATE t1 SET f2=1 ORDER BY f2; +ERROR 42S22: Unknown column 'f2' in 'field list' +DROP TABLE t1; +#59 +CREATE TABLE t1 ( a INT, KEY( a ) ); +INSERT INTO t1 VALUES (0), (1); +CREATE VIEW v1 AS SELECT t11.a, t12.a AS b FROM t1 t11, t1 t12; +SET SESSION sql_safe_updates = 1; +EXPLAIN UPDATE IGNORE v1 SET a = 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t11 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t12 NULL index NULL a 5 NULL 2 100.00 Using index +Warnings: +Note 1003 update ignore (`test`.`t1` `t11` join `test`.`t1` `t12`) set `t11`.`a` = 1 +UPDATE IGNORE v1 SET a = 1; +ERROR HY000: You are using safe update mode and you tried to update a table without a WHERE that uses a KEY column. +SET SESSION sql_safe_updates = DEFAULT; +DROP TABLE t1; +DROP VIEW v1; +#62 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (0), (1); +CREATE VIEW v1 AS SELECT t11.a, t12.a AS b FROM t1 t11, t1 t12; +# +# query: UPDATE v1 SET a = 1 WHERE a > 0 +# select: SELECT * FROM v1 WHERE a > 0 +# +EXPLAIN UPDATE v1 SET a = 1 WHERE a > 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t11 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t12 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 update (`test`.`t1` `t11` join `test`.`t1` `t12`) set `t11`.`a` = 1 where (`t11`.`a` > 0) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 2 +Handler_read_key 3 +Handler_read_rnd_next 6 +# Status of testing query execution: +Variable_name Value +Handler_read_first 2 +Handler_read_key 4 +Handler_read_rnd 1 +Handler_read_rnd_next 8 +Handler_write 2 + +# +# query: UPDATE t1, v1 SET v1.a = 1 WHERE t1.a = v1.a +# select: SELECT * FROM t1, v1 WHERE t1.a = v1.a +# +EXPLAIN UPDATE t1, v1 SET v1.a = 1 WHERE t1.a = v1.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 UPDATE t11 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t12 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 update `test`.`t1` join `test`.`t1` `t11` join `test`.`t1` `t12` set `test`.`t11`.`a` = 1 where (`test`.`t11`.`a` = `test`.`t1`.`a`) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 3 +Handler_read_key 4 +Handler_read_rnd_next 9 +# Status of testing query execution: +Variable_name Value +Handler_read_first 5 +Handler_read_key 8 +Handler_read_rnd 2 +Handler_read_rnd_next 18 +Handler_update 1 +Handler_write 4 + +DROP TABLE t1; +DROP VIEW v1; +#63 +CREATE TABLE t1 (a INT, PRIMARY KEY(a)); +INSERT INTO t1 VALUES (1), (2), (3), (4), (5); +CREATE VIEW v1 (a) AS SELECT a FROM t1; +# +# query: DELETE FROM v1 WHERE a < 4 +# select: SELECT * FROM v1 WHERE a < 4 +# +EXPLAIN DELETE FROM v1 WHERE a < 4; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL range PRIMARY PRIMARY 4 const X 100.00 Using where +Warnings: +Note 1003 delete from (`test`.`t1`) where (`test`.`t1`.`a` < 4) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 2 +Handler_read_next 3 +# Status of testing query execution: +Variable_name Value +Handler_delete 3 +Handler_read_first 1 +Handler_read_key 2 +Handler_read_next 3 + +DROP TABLE t1; +DROP VIEW v1; +#64 +CREATE TABLE t1 (a INT, b INT, PRIMARY KEY(a)); +INSERT INTO t1 VALUES (1,2), (2,3), (3,4), (4,5), (5,10); +CREATE TABLE t2 (x INT); +INSERT INTO t2 VALUES (1), (2), (3), (4); +CREATE VIEW v1 (a,c) AS SELECT a, b+1 FROM t1; +# +# query: DELETE v1 FROM t2, v1 WHERE t2.x = v1.a +# select: SELECT * FROM t2, v1 WHERE t2.x = v1.a +# +EXPLAIN DELETE v1 FROM t2, v1 WHERE t2.x = v1.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +1 DELETE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.x 1 100.00 NULL +Warnings: +Note 1003 delete `test`.`t1` from `test`.`t2` join `test`.`t1` where (`test`.`t1`.`a` = `test`.`t2`.`x`) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 8 +Handler_read_rnd_next 5 +# Status of testing query execution: +Variable_name Value +Handler_delete 4 +Handler_read_first 1 +Handler_read_key 12 +Handler_read_rnd 4 +Handler_read_rnd_next 5 + +DROP TABLE t1,t2; +DROP VIEW v1; +#65 +CREATE TABLE t1 (a INT, b INT, PRIMARY KEY(a)); +INSERT INTO t1 VALUES (1,2), (2,3), (3,4), (4,5), (5,10); +CREATE TABLE t2 (x INT); +INSERT INTO t2 VALUES (1), (2), (3), (4); +CREATE VIEW v1 (a,c) AS SELECT a, b+1 FROM t1; +# +# query: DELETE v1 FROM t2, v1 WHERE t2.x = v1.a +# select: SELECT * FROM t2, v1 WHERE t2.x = v1.a +# +EXPLAIN DELETE v1 FROM t2, v1 WHERE t2.x = v1.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +1 DELETE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.x 1 100.00 NULL +Warnings: +Note 1003 delete `test`.`t1` from `test`.`t2` join `test`.`t1` where (`test`.`t1`.`a` = `test`.`t2`.`x`) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 8 +Handler_read_rnd_next 5 +# Status of testing query execution: +Variable_name Value +Handler_delete 4 +Handler_read_first 1 +Handler_read_key 12 +Handler_read_rnd 4 +Handler_read_rnd_next 5 + +DROP TABLE t1,t2; +DROP VIEW v1; +#66 +CREATE TABLE t1 (a INT); +CREATE VIEW v1 (x) AS SELECT a FROM t1; +# +# query: INSERT INTO v1 VALUES (10) +# select: SELECT NULL +# +EXPLAIN INSERT INTO v1 VALUES (10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 INSERT t1 NULL ALL NULL NULL NULL NULL NULL NULL NULL +Warnings: +Note 1003 insert into `test`.`t1` values (10) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +# Status of testing query execution: +Variable_name Value +Handler_read_key 1 +Handler_write 1 + +DROP TABLE t1; +DROP VIEW v1; +#67 +CREATE TABLE t1 (a INT); +CREATE TABLE t2 (b INT); +INSERT INTO t2 VALUES (1), (2), (3); +CREATE VIEW v1 (x) AS SELECT b FROM t2; +# +# query: INSERT INTO v1 SELECT * FROM t1 +# select: SELECT * FROM t1 +# +EXPLAIN INSERT INTO v1 SELECT * FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 INSERT t2 NULL ALL NULL NULL NULL NULL NULL NULL NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 insert into `test`.`t2` /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 2 +Handler_read_rnd_next 1 +# Status of testing query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 3 +Handler_read_rnd_next 1 + +DROP TABLE t1, t2; +DROP VIEW v1; +#69 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +CREATE TABLE t2 (b INT); +INSERT INTO t2 VALUES (1), (2), (3); +# +# query: UPDATE t1 SET a = 10 WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x) +# select: SELECT * FROM t1 WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x) +# +EXPLAIN UPDATE t1 SET a = 10 WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 PRIMARY NULL ref 5 test.t1.a 2 100.00 Using index; FirstMatch(t1) +3 DERIVED t2 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`a` = 10 where (`x`.`b` = `test`.`t1`.`a`) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 2 +Handler_read_key 7 +Handler_read_rnd_next 8 +Handler_write 1 +Sort_rows 3 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_read_first 2 +Handler_read_key 7 +Handler_read_rnd_next 8 +Handler_update 1 +Handler_write 1 +Sort_rows 3 +Sort_scan 1 + +# +# query: UPDATE t1, t2 SET a = 10 WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x) +# select: SELECT * FROM t1, t2 WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x) +# +EXPLAIN UPDATE t1, t2 SET a = 10 WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 PRIMARY NULL ref 5 test.t1.a 2 100.00 Using index; FirstMatch(t1) +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +3 DERIVED t2 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 update `test`.`t1` join `test`.`t2` semi join ((/* select#3 */ select `test`.`t2`.`b` AS `b` from `test`.`t2` order by `test`.`t2`.`b` limit 2,2) `x`) set `test`.`t1`.`a` = 10 where (`x`.`b` = `test`.`t1`.`a`) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 2 +Handler_read_key 7 +Handler_read_rnd_next 8 +Handler_write 1 +Sort_rows 3 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_read_first 2 +Handler_read_key 7 +Handler_read_rnd_next 8 +Handler_write 1 +Sort_rows 3 +Sort_scan 1 + +# +# query: UPDATE t1, (SELECT * FROM t2) y SET a = 10 WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x) +# select: SELECT * FROM t1, (SELECT * FROM t2) y WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x) +# +EXPLAIN UPDATE t1, (SELECT * FROM t2) y SET a = 10 WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 PRIMARY NULL ref 5 test.t1.a 2 100.00 Using index; FirstMatch(t1) +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +4 DERIVED t2 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 update `test`.`t1` join `test`.`t2` semi join ((/* select#4 */ select `test`.`t2`.`b` AS `b` from `test`.`t2` order by `test`.`t2`.`b` limit 2,2) `x`) set `test`.`t1`.`a` = 10 where (`x`.`b` = `test`.`t1`.`a`) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 2 +Handler_read_key 7 +Handler_read_rnd_next 8 +Handler_write 1 +Sort_rows 3 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_read_first 2 +Handler_read_key 7 +Handler_read_rnd_next 8 +Handler_write 1 +Sort_rows 3 +Sort_scan 1 + +DROP TABLE t1,t2; +#70 +CREATE TABLE t1 (c1 INT KEY); +CREATE TABLE t2 (c2 INT); +CREATE TABLE t3 (c3 INT); +EXPLAIN UPDATE t3 SET c3 = ( +SELECT COUNT(d1.c1) +FROM ( +SELECT a11.c1 FROM t1 AS a11 +STRAIGHT_JOIN t2 AS a21 ON a21.c2 = a11.c1 +JOIN t1 AS a12 ON a12.c1 = a11.c1 +) d1 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t3 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SUBQUERY NULL ALL NULL NULL NULL NULL 2 100.00 NULL +3 DERIVED a11 NULL index PRIMARY PRIMARY 4 NULL 1 100.00 Using index +3 DERIVED a21 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +3 DERIVED a12 NULL eq_ref PRIMARY PRIMARY 4 test.a11.c1 1 100.00 Using index +Warnings: +Note 1003 update `test`.`t3` set `test`.`t3`.`c3` = (/* select#2 */ select count(`d1`.`c1`) from (/* select#3 */ select `test`.`a11`.`c1` AS `c1` from `test`.`t1` `a11` straight_join `test`.`t2` `a21` join `test`.`t1` `a12` where ((`test`.`a21`.`c2` = `test`.`a11`.`c1`) and (`test`.`a12`.`c1` = `test`.`a11`.`c1`))) `d1`) +DROP TABLE t1, t2, t3; +#71 +CREATE TABLE t1 (c1 INT NOT NULL, c2 INT NOT NULL, INDEX i1(c1)); +INSERT INTO t1 VALUES (1,0),(2,0),(3,0),(4,0),(5,0),(6,0),(7,0),(8,0); +CREATE TABLE t2 LIKE t1; +EXPLAIN INSERT INTO t2 SELECT * FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 INSERT t2 NULL ALL NULL NULL NULL NULL X NULL NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL X 100.00 NULL +Warnings: +Note 1003 insert into `test`.`t2` /* select#1 */ select `test`.`t1`.`c1` AS `c1`,`test`.`t1`.`c2` AS `c2` from `test`.`t1` +INSERT INTO t2 SELECT * FROM t1; +SELECT * FROM t1 LEFT JOIN t2 ON t1.c1 = t2.c1; +DROP TABLE t1, t2; +#73 +CREATE TABLE t1 (id INT); +CREATE TABLE t2 (id INT); +INSERT INTO t1 VALUES (1), (2); +EXPLAIN SELECT * FROM t1 LEFT JOIN t2 USING(id) GROUP BY t1.id; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using temporary +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id` from `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`id` = `test`.`t1`.`id`)) where true group by `test`.`t1`.`id` +DROP TABLE t1,t2; +#74 +CREATE TABLE t1(a INT PRIMARY KEY) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1), (2), (3), (4), (5); +# used key is modified & Using temporary +# +# query: UPDATE t1 SET a=a+1 WHERE a>10 +# select: SELECT a t1 FROM t1 WHERE a>10 +# +EXPLAIN UPDATE t1 SET a=a+1 WHERE a>10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL range PRIMARY PRIMARY 4 const 1 100.00 Using where; Using temporary +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`a` = (`test`.`t1`.`a` + 1) where (`test`.`t1`.`a` > 10) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 2 + +# used key is modified & Using filesort +# +# query: UPDATE t1 SET a=a+1 WHERE a>10 ORDER BY a+20 +# select: SELECT a t1 FROM t1 WHERE a>10 ORDER BY a+20 +# +EXPLAIN UPDATE t1 SET a=a+1 WHERE a>10 ORDER BY a+20; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL range PRIMARY PRIMARY 4 const 1 100.00 Using where; Using filesort +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`a` = (`test`.`t1`.`a` + 1) where (`test`.`t1`.`a` > 10) order by (`test`.`t1`.`a` + 20) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 1 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 2 +Sort_scan 1 + +DROP TABLE t1; +# +# Bug #12949629: CLIENT LOSES CONNECTION AFTER EXECUTING A PROCEDURE WITH +# EXPLAIN UPDATE/DEL/INS +# +CREATE TABLE t1 (i INT); +CREATE TABLE t2 (i INT); +CREATE PROCEDURE p1() BEGIN EXPLAIN INSERT INTO t1 VALUES (1);END| +CREATE PROCEDURE p2() BEGIN INSERT INTO t1 VALUES (1);END| +CREATE PROCEDURE p3() BEGIN EXPLAIN INSERT INTO t1 SELECT 1;END| +CREATE PROCEDURE p4() BEGIN INSERT INTO t1 SELECT 1;END| +CREATE PROCEDURE p5() BEGIN EXPLAIN REPLACE INTO t1 VALUES (1);END| +CREATE PROCEDURE p6() BEGIN REPLACE INTO t1 VALUES (1);END| +CREATE PROCEDURE p7() BEGIN EXPLAIN REPLACE INTO t1 SELECT 1;END| +CREATE PROCEDURE p8() BEGIN REPLACE INTO t1 SELECT 1;END| +CREATE PROCEDURE p9() BEGIN EXPLAIN UPDATE t1 SET i = 10;END| +CREATE PROCEDURE p10() BEGIN UPDATE t1 SET i = 10;END| +CREATE PROCEDURE p11() BEGIN EXPLAIN UPDATE t1,t2 SET t1.i = 10 WHERE t1.i = t2.i ;END| +CREATE PROCEDURE p12() BEGIN UPDATE t1,t2 SET t1.i = 10 WHERE t1.i = t2.i ;END| +CREATE PROCEDURE p13() BEGIN +# Disabling binary logging temporarily as optimized delete is not used when log-bin is enabled in row mode +SET @save_log_bin= @@sql_log_bin;SET SQL_LOG_BIN=0; +EXPLAIN DELETE FROM t1; +SET SQL_LOG_BIN=@save_log_bin; END| +CREATE PROCEDURE p14() BEGIN DELETE FROM t1;END| +CREATE PROCEDURE p15() BEGIN EXPLAIN DELETE FROM t1 USING t1;END| +CREATE PROCEDURE p16() BEGIN DELETE FROM t1 USING t1;END| +CALL p16(); +DROP PROCEDURE p16; +CALL p15(); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 delete `test`.`t1` from `test`.`t1` +DROP PROCEDURE p15; +CALL p14(); +DROP PROCEDURE p14; +CALL p13(); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Deleting all rows +DROP PROCEDURE p13; +CALL p12(); +DROP PROCEDURE p12; +CALL p11(); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 update `test`.`t1` join `test`.`t2` set `test`.`t1`.`i` = 10 where (`test`.`t2`.`i` = `test`.`t1`.`i`) +DROP PROCEDURE p11; +CALL p10(); +DROP PROCEDURE p10; +CALL p9(); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`i` = 10 +DROP PROCEDURE p9; +CALL p8(); +DROP PROCEDURE p8; +CALL p7(); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 REPLACE t1 NULL ALL NULL NULL NULL NULL NULL NULL NULL +Warnings: +Note 1003 replace into `test`.`t1` /* select#1 */ select 1 AS `1` from dual +DROP PROCEDURE p7; +CALL p6(); +DROP PROCEDURE p6; +CALL p5(); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 REPLACE t1 NULL ALL NULL NULL NULL NULL NULL NULL NULL +Warnings: +Note 1003 replace into `test`.`t1` values (1) +DROP PROCEDURE p5; +CALL p4(); +DROP PROCEDURE p4; +CALL p3(); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 INSERT t1 NULL ALL NULL NULL NULL NULL NULL NULL NULL +Warnings: +Note 1003 insert into `test`.`t1` /* select#1 */ select 1 AS `1` from dual +DROP PROCEDURE p3; +CALL p2(); +DROP PROCEDURE p2; +CALL p1(); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 INSERT t1 NULL ALL NULL NULL NULL NULL NULL NULL NULL +Warnings: +Note 1003 insert into `test`.`t1` values (1) +DROP PROCEDURE p1; +DROP TABLE t1, t2; +# +set default_storage_engine= @save_storage_engine; +set optimizer_switch=default; diff --git a/mysql-test/r/innodb_explain_non_select_none.result-pq b/mysql-test/r/innodb_explain_non_select_none.result-pq new file mode 100644 index 000000000000..da4617818fbe --- /dev/null +++ b/mysql-test/r/innodb_explain_non_select_none.result-pq @@ -0,0 +1,2602 @@ +set @save_storage_engine= @@session.default_storage_engine; +set session default_storage_engine = InnoDB; +set end_markers_in_json=on; +#1 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +# +# query: UPDATE t1 SET a = 10 WHERE a < 10 +# select: SELECT * FROM t1 WHERE a < 10 +# +EXPLAIN UPDATE t1 SET a = 10 WHERE a < 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`a` = 10 where (`test`.`t1`.`a` < 10) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 2 +Handler_read_rnd_next 4 +# Status of testing query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 2 +Handler_read_rnd_next 4 +Handler_update 3 + +DROP TABLE t1; +#2 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +# +# query: DELETE FROM t1 WHERE a < 10 +# select: SELECT * FROM t1 WHERE a < 10 +# +EXPLAIN DELETE FROM t1 WHERE a < 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 delete from `test`.`t1` where (`test`.`t1`.`a` < 10) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 2 +Handler_read_rnd_next 4 +# Status of testing query execution: +Variable_name Value +Handler_delete 3 +Handler_read_first 1 +Handler_read_key 2 +Handler_read_rnd_next 4 + +DROP TABLE t1; +#3 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +# +# query: DELETE FROM t1 USING t1 WHERE a = 1 +# select: SELECT * FROM t1 WHERE a = 1 +# +EXPLAIN DELETE FROM t1 USING t1 WHERE a = 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 delete `test`.`t1` from `test`.`t1` where (`test`.`t1`.`a` = 1) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 2 +Handler_read_rnd_next 4 +# Status of testing query execution: +Variable_name Value +Handler_delete 1 +Handler_read_first 1 +Handler_read_key 2 +Handler_read_rnd_next 4 + +DROP TABLE t1; +#4 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +CREATE TABLE t2 (b INT); +INSERT INTO t2 VALUES (1), (2), (3); +# +# query: UPDATE t1, t2 SET t1.a = 10 WHERE t1.a = 1 +# select: SELECT * FROM t1, t2 WHERE t1.a = 1 +# +EXPLAIN UPDATE t1, t2 SET t1.a = 10 WHERE t1.a = 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 update `test`.`t1` join `test`.`t2` set `test`.`t1`.`a` = 10 where (`test`.`t1`.`a` = 1) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 2 +Handler_read_key 4 +Handler_read_rnd_next 8 +# Status of testing query execution: +Variable_name Value +Handler_read_first 2 +Handler_read_key 4 +Handler_read_rnd_next 8 +Handler_update 1 + +DROP TABLE t1, t2; +#5 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +CREATE TABLE t2 (b INT); +INSERT INTO t2 VALUES (1), (2), (3); +# +# query: UPDATE t1 t11, (SELECT * FROM t2) t12 SET t11.a = 10 WHERE t11.a = 1 +# select: SELECT * FROM t1 t11, (SELECT * FROM t2) t12 WHERE t11.a = 1 +# +EXPLAIN UPDATE t1 t11, (SELECT * FROM t2) t12 SET t11.a = 10 WHERE t11.a = 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t11 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 update `test`.`t1` `t11` join `test`.`t2` set `test`.`t11`.`a` = 10 where (`test`.`t11`.`a` = 1) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 2 +Handler_read_key 4 +Handler_read_rnd_next 8 +# Status of testing query execution: +Variable_name Value +Handler_read_first 2 +Handler_read_key 4 +Handler_read_rnd_next 8 +Handler_update 1 + +DROP TABLE t1, t2; +#6 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +CREATE TABLE t2 (b INT); +INSERT INTO t2 VALUES (1), (2), (3); +# +# query: UPDATE t1 SET a = 10 WHERE 1 IN (SELECT 1 FROM t2 WHERE t2.b < 3) +# select: SELECT * FROM t1 WHERE 1 IN (SELECT 1 FROM t2 WHERE t2.b < 3) +# +EXPLAIN UPDATE t1 SET a = 10 WHERE 1 IN (SELECT 1 FROM t2 WHERE t2.b < 3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 SUBQUERY t2 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`a` = 10 where (1,(/* select#2 */ select 1 from `test`.`t2` where (`test`.`t2`.`b` < 3))) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 2 +Handler_read_key 4 +Handler_read_rnd_next 5 +# Status of testing query execution: +Variable_name Value +Handler_read_first 2 +Handler_read_key 4 +Handler_read_rnd_next 5 +Handler_update 3 + +DROP TABLE t1, t2; +#7 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +CREATE TABLE t2 (b INT); +INSERT INTO t2 VALUES (1), (2), (3); +# +# query: UPDATE t1 SET a = 10 WHERE a IN (SELECT b FROM t2 WHERE t1.a < 3) +# select: SELECT * FROM t1 WHERE a IN (SELECT b FROM t2 WHERE t1.a < 3) +# +EXPLAIN UPDATE t1 SET a = 10 WHERE a IN (SELECT b FROM t2 WHERE t1.a < 3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 update `test`.`t1` set `test`.`t1`.`a` = 10 where (`test`.`t1`.`a`,(/* select#2 */ select `test`.`t2`.`b` from `test`.`t2` where ((`test`.`t1`.`a` < 3) and ((`test`.`t1`.`a`) = `test`.`t2`.`b`)))) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 4 +Handler_read_key 6 +Handler_read_rnd_next 11 +# Status of testing query execution: +Variable_name Value +Handler_read_first 4 +Handler_read_key 6 +Handler_read_rnd_next 11 +Handler_update 2 + +DROP TABLE t1, t2; +#7 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +CREATE TABLE t2 (b INT); +INSERT INTO t2 VALUES (1), (2), (3); +# +# query: UPDATE t1, t2 SET a = 10 WHERE a IN (SELECT b FROM t2 WHERE t2.b < 3) +# select: SELECT * FROM t1, t2 WHERE a IN (SELECT b FROM t2 WHERE t2.b < 3) +# +EXPLAIN UPDATE t1, t2 SET a = 10 WHERE a IN (SELECT b FROM t2 WHERE t2.b < 3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 update `test`.`t1` join `test`.`t2` set `test`.`t1`.`a` = 10 where (`test`.`t1`.`a`,(/* select#2 */ select `test`.`t2`.`b` from `test`.`t2` where ((`test`.`t2`.`b` < 3) and ((`test`.`t1`.`a`) = `test`.`t2`.`b`)))) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 5 +Handler_read_key 7 +Handler_read_rnd_next 15 +# Status of testing query execution: +Variable_name Value +Handler_read_first 6 +Handler_read_key 8 +Handler_read_rnd_next 19 +Handler_update 2 + +DROP TABLE t1, t2; +#8 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +CREATE TABLE t2 (b INT); +INSERT INTO t2 VALUES (1), (2), (3); +# +# query: UPDATE t1 t11, (SELECT * FROM t2) t12 SET t11.a = t11.a + 10 +# select: SELECT * FROM t1 t11, (SELECT * FROM t2) t12 +# +EXPLAIN UPDATE t1 t11, (SELECT * FROM t2) t12 SET t11.a = t11.a + 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t11 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 update `test`.`t1` `t11` join `test`.`t2` set `test`.`t11`.`a` = (`test`.`t11`.`a` + 10) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 2 +Handler_read_key 4 +Handler_read_rnd_next 8 +# Status of testing query execution: +Variable_name Value +Handler_read_first 4 +Handler_read_key 6 +Handler_read_rnd_next 16 +Handler_update 3 + +DROP TABLE t1, t2; +#9 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +CREATE TABLE t2 (b INT); +INSERT INTO t2 VALUES (1), (2), (3); +# +# query: UPDATE t1 t11, (SELECT 1 FROM DUAL) t12 SET t11.a = t11.a + 10 +# select: SELECT * FROM t1 t11, (SELECT 1 FROM DUAL) t12 +# +EXPLAIN UPDATE t1 t11, (SELECT 1 FROM DUAL) t12 SET t11.a = t11.a + 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL system NULL NULL NULL NULL 1 100.00 NULL +1 UPDATE t11 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 update `test`.`t1` `t11` join (/* select#2 */ select 1 AS `1`) `t12` set `test`.`t11`.`a` = (`test`.`t11`.`a` + 10) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 2 +Handler_read_rnd_next 5 +Handler_write 1 +# Status of testing query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 5 +Handler_read_rnd 3 +Handler_read_rnd_next 9 +Handler_update 3 +Handler_write 4 + +DROP TABLE t1, t2; +#10 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +CREATE TABLE t2 (b INT); +INSERT INTO t2 VALUES (1), (2), (3); +# +# query: UPDATE t1 t11, (SELECT * FROM t2) t12 SET t11.a = 10 WHERE t11.a > 1 +# select: SELECT * FROM t1 t11, (SELECT * FROM t2) t12 WHERE t11.a > 1 +# +EXPLAIN UPDATE t1 t11, (SELECT * FROM t2) t12 SET t11.a = 10 WHERE t11.a > 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t11 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 update `test`.`t1` `t11` join `test`.`t2` set `test`.`t11`.`a` = 10 where (`test`.`t11`.`a` > 1) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 2 +Handler_read_key 4 +Handler_read_rnd_next 8 +# Status of testing query execution: +Variable_name Value +Handler_read_first 3 +Handler_read_key 5 +Handler_read_rnd_next 12 +Handler_update 2 + +DROP TABLE t1, t2; +#11 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +# +# query: DELETE FROM t1 WHERE a > 1 LIMIT 1 +# select: SELECT * FROM t1 WHERE a > 1 LIMIT 1 +# +EXPLAIN DELETE FROM t1 WHERE a > 1 LIMIT 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 delete from `test`.`t1` where (`test`.`t1`.`a` > 1) limit 1 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 2 +Handler_read_rnd_next 2 +# Status of testing query execution: +Variable_name Value +Handler_delete 1 +Handler_read_first 1 +Handler_read_key 2 +Handler_read_rnd_next 2 + +DROP TABLE t1; +#12 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +# +# query: DELETE FROM t1 WHERE 0 +# select: SELECT * FROM t1 WHERE 0 +# +EXPLAIN DELETE FROM t1 WHERE 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 delete from `test`.`t1` where false +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 1 + +DROP TABLE t1; +#13 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +# +# query: DELETE FROM t1 USING t1 WHERE 0 +# select: SELECT * FROM t1 WHERE 0 +# +EXPLAIN DELETE FROM t1 USING t1 WHERE 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 delete `test`.`t1` from `test`.`t1` where false +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 1 + +DROP TABLE t1; +#14 +CREATE TABLE t1 (a INT, b INT, UNIQUE KEY (a), KEY (b)); +INSERT INTO t1 VALUES (3, 3), (7, 7); +# +# query: DELETE FROM t1 WHERE a = 3 +# select: SELECT * FROM t1 WHERE a = 3 +# +EXPLAIN DELETE FROM t1 WHERE a = 3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL range a a 5 const 1 100.00 Using where +Warnings: +Note 1003 delete from `test`.`t1` where (`test`.`t1`.`a` = 3) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 3 +# Status of testing query execution: +Variable_name Value +Handler_delete 1 +Handler_read_key 3 + +DROP TABLE t1; +#15 +CREATE TABLE t1 (a INT, b INT, UNIQUE KEY (a), KEY (b)); +INSERT INTO t1 VALUES (3, 3), (7, 7); +# +# query: DELETE FROM t1 WHERE a < 3 +# select: SELECT * FROM t1 WHERE a < 3 +# +EXPLAIN DELETE FROM t1 WHERE a < 3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL range a a 5 const 1 100.00 Using where +Warnings: +Note 1003 delete from `test`.`t1` where (`test`.`t1`.`a` < 3) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 4 +Handler_read_rnd_next 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 3 + +DROP TABLE t1; +#16 +CREATE TABLE t1 ( a int PRIMARY KEY ); +# +# query: DELETE FROM t1 WHERE t1.a > 0 ORDER BY t1.a +# select: SELECT * FROM t1 WHERE t1.a > 0 ORDER BY t1.a +# +EXPLAIN DELETE FROM t1 WHERE t1.a > 0 ORDER BY t1.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL range PRIMARY PRIMARY 4 const 1 100.00 Using where +Warnings: +Note 1003 delete from `test`.`t1` where (`test`.`t1`.`a` > 0) order by `test`.`t1`.`a` +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 2 +Handler_read_rnd_next 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 2 + +INSERT INTO t1 VALUES (1), (2), (3); +# +# query: DELETE FROM t1 WHERE t1.a > 0 ORDER BY t1.a +# select: SELECT * FROM t1 WHERE t1.a > 0 ORDER BY t1.a +# +EXPLAIN DELETE FROM t1 WHERE t1.a > 0 ORDER BY t1.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL range PRIMARY PRIMARY 4 const 3 100.00 Using where +Warnings: +Note 1003 delete from `test`.`t1` where (`test`.`t1`.`a` > 0) order by `test`.`t1`.`a` +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 2 +Handler_read_rnd_next 4 +# Status of testing query execution: +Variable_name Value +Handler_delete 3 +Handler_read_key 2 +Handler_read_next 3 + +DROP TABLE t1; +#17 +CREATE TABLE t1(a INT PRIMARY KEY); +INSERT INTO t1 VALUES (4),(3),(1),(2); +# +# query: DELETE FROM t1 WHERE (@a:= a) ORDER BY a LIMIT 1 +# select: SELECT * FROM t1 WHERE (@a:= a) ORDER BY a LIMIT 1 +# +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +EXPLAIN DELETE FROM t1 WHERE (@a:= a) ORDER BY a LIMIT 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL index NULL PRIMARY 4 NULL 4 100.00 Using where +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +Note 1003 delete from `test`.`t1` where (0 <> (@a:=`test`.`t1`.`a`)) order by `test`.`t1`.`a` limit 1 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 2 +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +# Status of testing query execution: +Variable_name Value +Handler_delete 1 +Handler_read_first 1 +Handler_read_key 2 + +DROP TABLE t1; +#18 +CREATE TABLE t1 (a DATE, b TIME, c INT, KEY c(c), KEY b(b), KEY a(a)); +INSERT INTO t1 VALUES (), (), (), (), (), (), (), (), (), (); +UPDATE t1 SET a = c, b = c; +# +# query: DELETE FROM t1 ORDER BY a ASC, b ASC LIMIT 1 +# select: SELECT * FROM t1 ORDER BY a ASC, b ASC LIMIT 1 +# +EXPLAIN DELETE FROM t1 ORDER BY a ASC, b ASC LIMIT 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 10 100.00 Using filesort +Warnings: +Note 1003 delete from `test`.`t1` order by `test`.`t1`.`a`,`test`.`t1`.`b` limit 1 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 4 +Handler_read_rnd_next 11 +Sort_rows 1 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_delete 1 +Handler_read_first 1 +Handler_read_key 5 +Handler_read_rnd 1 +Handler_read_rnd_next 11 +Sort_rows 10 +Sort_scan 1 + +DROP TABLE t1; +#19 +CREATE TABLE t1 (a1 INT NOT NULL, b1 INT NOT NULL); +CREATE TABLE t2 (a2 INT NOT NULL, b2 INT NOT NULL, PRIMARY KEY (a2,b2)); +CREATE TABLE t3 (a3 INT NOT NULL, b3 INT NOT NULL, PRIMARY KEY (a3,b3)); +INSERT INTO t1 VALUES (1,1), (2,1), (1,3); +INSERT INTO t2 VALUES (1,1), (2,2), (3,3); +INSERT INTO t3 VALUES (1,1), (2,1), (1,3); +# +# query: DELETE t1,t2,t3 FROM t1,t2,t3 WHERE a1=a2 AND b2=a3 AND b1=b3 +# select: SELECT * FROM t1,t2,t3 WHERE a1=a2 AND b2=a3 AND b1=b3 +# +EXPLAIN DELETE t1,t2,t3 FROM t1,t2,t3 WHERE a1=a2 AND b2=a3 AND b1=b3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 DELETE t2 NULL ref PRIMARY PRIMARY 4 test.t1.a1 1 100.00 NULL +1 DELETE t3 NULL eq_ref PRIMARY PRIMARY 8 test.t2.b2,test.t1.b1 1 100.00 NULL +Warnings: +Note 1003 delete `test`.`t1`, `test`.`t2`, `test`.`t3` from `test`.`t1` join `test`.`t2` join `test`.`t3` where ((`test`.`t3`.`b3` = `test`.`t1`.`b1`) and (`test`.`t3`.`a3` = `test`.`t2`.`b2`) and (`test`.`t2`.`a2` = `test`.`t1`.`a1`)) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 13 +Handler_read_next 3 +Handler_read_rnd_next 4 +# Status of testing query execution: +Variable_name Value +Handler_delete 8 +Handler_read_first 1 +Handler_read_key 18 +Handler_read_next 3 +Handler_read_rnd 5 +Handler_read_rnd_next 4 + +DROP TABLE t1, t2, t3; +#20 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +CREATE TABLE t2 (a INT); +INSERT INTO t2 VALUES (1), (2), (3); +# +# query: UPDATE t1 SET a = 10 WHERE a IN (SELECT a FROM t2) +# select: SELECT * FROM t1 WHERE a IN (SELECT a FROM t2) +# +EXPLAIN UPDATE t1 SET a = 10 WHERE a IN (SELECT a FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`a` = 10 where (`test`.`t1`.`a`,(/* select#2 */ select `test`.`t2`.`a` from `test`.`t2` where ((`test`.`t1`.`a`) = `test`.`t2`.`a`))) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 4 +Handler_read_key 6 +Handler_read_rnd_next 10 +# Status of testing query execution: +Variable_name Value +Handler_read_first 4 +Handler_read_key 6 +Handler_read_rnd_next 10 +Handler_update 3 + +DROP TABLE t1, t2; +#21 +CREATE TABLE t1 (a1 INT); +INSERT INTO t1 VALUES (1), (2), (3), (4), (5); +CREATE TABLE t2 (a2 VARCHAR(10)) charset utf8mb4; +INSERT INTO t2 VALUES (1), (2), (3), (4), (5); +SET @save_optimizer_switch= @@optimizer_switch; +# +# query: DELETE FROM t1 WHERE a1 IN (SELECT a2 FROM t2 WHERE a2 > 2) +# select: SELECT * FROM t1 WHERE a1 IN (SELECT a2 FROM t2 WHERE a2 > 2) +# +EXPLAIN DELETE FROM t1 WHERE a1 IN (SELECT a2 FROM t2 WHERE a2 > 2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 5 100.00 Using where +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 5 20.00 Using where +Warnings: +Note 1003 delete from `test`.`t1` where (`test`.`t1`.`a1`,(/* select#2 */ select `test`.`t2`.`a2` from `test`.`t2` where ((`test`.`t2`.`a2` > 2) and ((`test`.`t1`.`a1`) = `test`.`t2`.`a2`)))) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 6 +Handler_read_key 8 +Handler_read_rnd_next 30 +# Status of testing query execution: +Variable_name Value +Handler_delete 3 +Handler_read_first 6 +Handler_read_key 8 +Handler_read_rnd_next 30 + +SET @@optimizer_switch= @save_optimizer_switch; +TRUNCATE t1; +INSERT INTO t1 VALUES (1), (2), (3), (4), (5); +# +# query: DELETE FROM t1 WHERE a1 IN (SELECT a2 FROM t2 WHERE a2 > 2) +# select: SELECT * FROM t1 WHERE a1 IN (SELECT a2 FROM t2 WHERE a2 > 2) +# +EXPLAIN DELETE FROM t1 WHERE a1 IN (SELECT a2 FROM t2 WHERE a2 > 2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 5 100.00 Using where +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 5 20.00 Using where +Warnings: +Note 1003 delete from `test`.`t1` where (`test`.`t1`.`a1`,(/* select#2 */ select `test`.`t2`.`a2` from `test`.`t2` where ((`test`.`t2`.`a2` > 2) and ((`test`.`t1`.`a1`) = `test`.`t2`.`a2`)))) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 6 +Handler_read_key 8 +Handler_read_rnd_next 30 +# Status of testing query execution: +Variable_name Value +Handler_delete 3 +Handler_read_first 6 +Handler_read_key 8 +Handler_read_rnd_next 30 + +DROP TABLE t1, t2; +#22 +CREATE TABLE t1 (i INT, j INT); +INSERT INTO t1 VALUES (1, 1), (2, 2), (3, 3), (4, 4), (5, 5); +# +# query: UPDATE t1 SET i = 10 +# select: SELECT * FROM t1 +# +EXPLAIN UPDATE t1 SET i = 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`i` = 10 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 3 +Handler_read_rnd_next 6 +# Status of testing query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 3 +Handler_read_rnd_next 6 +Handler_update 5 + +DROP TABLE t1; +#23 +CREATE TABLE t1 (i INT, j INT); +INSERT INTO t1 VALUES (1, 1), (2, 2), (3, 3), (4, 4), (5, 5); +# +# query: DELETE FROM t1 +# select: SELECT * FROM t1 +# +EXPLAIN DELETE FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 5 100.00 Deleting all rows +Warnings: +Note 1003 delete from `test`.`t1` +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 3 +Handler_read_rnd_next 6 +# Status of testing query execution: +Variable_name Value +Handler_delete 5 +Handler_read_first 1 +Handler_read_key 3 +Handler_read_rnd_next 6 + +DROP TABLE t1; +#24 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2(a INT, b INT, c INT, d INT, INDEX(a, b, c)); +INSERT INTO t2 (a, b, c) SELECT i, i, i FROM t1; +INSERT INTO t2 (a, b, c) SELECT t1.i, t1.i, t1.i FROM t1, t1 x1, t1 x2; +# +# query: DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# select: SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# +EXPLAIN DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t2 NULL index NULL a 15 NULL X 100.00 Using where +Warnings: +Note 1003 delete from `test`.`t2` where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 5 +Handler_read_rnd_next 16936 +# Status of testing query execution: +Variable_name Value +Handler_delete 5 +Handler_read_first 1 +Handler_read_key 5 +Handler_read_next 4 + +DROP TABLE t1, t2; +#25 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (1), (2), (3); +CREATE TABLE t2 (i INT); +# +# query: INSERT INTO t2 SELECT * FROM t1 +# select: SELECT * FROM t1 +# +EXPLAIN INSERT INTO t2 SELECT * FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 INSERT t2 NULL ALL NULL NULL NULL NULL NULL NULL NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 insert into `test`.`t2` /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 2 +Handler_read_rnd_next 4 +# Status of testing query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 3 +Handler_read_rnd_next 4 +Handler_write 3 + +# +# query: INSERT INTO t2 SELECT * FROM t1 JOIN t1 AS tt USING(i) +# select: SELECT * FROM t1 JOIN t1 AS tt USING(i) +# +EXPLAIN INSERT INTO t2 SELECT * FROM t1 JOIN t1 AS tt USING(i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 INSERT t2 NULL ALL NULL NULL NULL NULL NULL NULL NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE tt NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +Warnings: +Note 1003 insert into `test`.`t2` /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` join `test`.`t1` `tt` where (`test`.`tt`.`i` = `test`.`t1`.`i`) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 2 +Handler_read_key 3 +Handler_read_rnd_next 8 +# Status of testing query execution: +Variable_name Value +Handler_read_first 2 +Handler_read_key 4 +Handler_read_rnd_next 8 +Handler_write 3 + +DROP TABLE t1, t2; +#26 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (1), (2), (3); +CREATE TABLE t2 (i INT); +# +# query: REPLACE INTO t2 SELECT * FROM t1 +# select: SELECT * FROM t1 +# +EXPLAIN REPLACE INTO t2 SELECT * FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 REPLACE t2 NULL ALL NULL NULL NULL NULL NULL NULL NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 replace into `test`.`t2` /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 2 +Handler_read_rnd_next 4 +# Status of testing query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 3 +Handler_read_rnd_next 4 +Handler_write 3 + +DROP TABLE t1, t2; +#27 +CREATE TABLE t1 (i INT); +# +# query: INSERT INTO t1 SET i = 10 +# select: +# +EXPLAIN INSERT INTO t1 SET i = 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 INSERT t1 NULL ALL NULL NULL NULL NULL NULL NULL NULL +Warnings: +Note 1003 insert into `test`.`t1` (`test`.`t1`.`i`) values (10) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# Status of testing query execution: +Variable_name Value +Handler_read_key 1 +Handler_write 1 + +DROP TABLE t1; +#28 +CREATE TABLE t1 (i INT); +# +# query: REPLACE INTO t1 SET i = 10 +# select: +# +EXPLAIN REPLACE INTO t1 SET i = 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 REPLACE t1 NULL ALL NULL NULL NULL NULL NULL NULL NULL +Warnings: +Note 1003 replace into `test`.`t1` (`test`.`t1`.`i`) values (10) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# Status of testing query execution: +Variable_name Value +Handler_read_key 1 +Handler_write 1 + +DROP TABLE t1; +#29 +CREATE TABLE t1 (a INT, i INT PRIMARY KEY); +INSERT INTO t1 (i) VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +# +# query: DELETE FROM t1 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 1 +# select: SELECT * FROM t1 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 1 +# +EXPLAIN DELETE FROM t1 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL range PRIMARY PRIMARY 4 const X 100.00 Using where +Warnings: +Note 1003 delete from `test`.`t1` where ((`test`.`t1`.`i` > 10) and (`test`.`t1`.`i` <= 18)) order by `test`.`t1`.`i` limit 1 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 4 +Handler_read_rnd_next 1 +# Status of testing query execution: +Variable_name Value +Handler_delete 1 +Handler_read_key 3 + +DROP TABLE t1; +#30 +CREATE TABLE t1(a INT, i CHAR(2), INDEX(i(1))) charset utf8mb4; +INSERT INTO t1 (i) VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +# +# query: DELETE FROM t1 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 5 +# select: SELECT * FROM t1 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 5 +# +EXPLAIN DELETE FROM t1 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 26 100.00 Using where; Using filesort +Warnings: +Warning 1739 Cannot use range access on index 'i' due to type or collation conversion on field 'i' +Warning 1739 Cannot use range access on index 'i' due to type or collation conversion on field 'i' +Note 1003 delete from `test`.`t1` where ((`test`.`t1`.`i` > 10) and (`test`.`t1`.`i` <= 18)) order by `test`.`t1`.`i` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 3 +Handler_read_rnd_next 27 +Sort_rows 5 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_delete 5 +Handler_read_first 1 +Handler_read_key 8 +Handler_read_rnd 5 +Handler_read_rnd_next 27 +Sort_rows 8 +Sort_scan 1 + +DROP TABLE t1; +#31 +CREATE TABLE t1 (i INT); +INSERT INTO t1 (i) VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2(a INT, b INT, c INT, d INT, INDEX(a, b, c)); +INSERT INTO t2 (a, b, c) SELECT i, i, i FROM t1; +# +# query: DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# select: SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# +EXPLAIN DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t2 NULL ALL NULL NULL NULL NULL 26 100.00 Using where; Using filesort +Warnings: +Note 1003 delete from `test`.`t2` where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 5 +Handler_read_rnd_next 27 +# Status of testing query execution: +Variable_name Value +Handler_delete 1 +Handler_read_first 1 +Handler_read_key 6 +Handler_read_rnd 1 +Handler_read_rnd_next 27 +Sort_rows 1 +Sort_scan 1 + +DROP TABLE t1, t2; +#32 +CREATE TABLE t1 (i INT); +INSERT INTO t1 (i) VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2(a INT, b INT, c INT, d INT, INDEX(a, b, c)); +INSERT INTO t2 (a, b, c) SELECT i, i, i FROM t1; +INSERT INTO t2 (a, b, c) SELECT t1.i, t1.i, t1.i FROM t1, t1 x1, t1 x2; +# +# query: DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# select: SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# +EXPLAIN DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t2 NULL index NULL a 15 NULL X 100.00 Using where +Warnings: +Note 1003 delete from `test`.`t2` where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 5 +Handler_read_rnd_next 16936 +# Status of testing query execution: +Variable_name Value +Handler_delete 5 +Handler_read_first 1 +Handler_read_key 5 +Handler_read_next 4 + +DROP TABLE t1, t2; +#33 +CREATE TABLE t1 (i INT); +INSERT INTO t1 (i) VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2 (a CHAR(2), b CHAR(2), c CHAR(2), d CHAR(2), INDEX (a,b(1),c)) +charset utf8mb4; +INSERT INTO t2 SELECT i, i, i, i FROM t1; +# +# query: DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# select: SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# +EXPLAIN DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t2 NULL ALL NULL NULL NULL NULL 26 100.00 Using where; Using filesort +Warnings: +Warning 1739 Cannot use range access on index 'a' due to type or collation conversion on field 'b' +Note 1003 delete from `test`.`t2` where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 5 +Handler_read_rnd_next 27 +Sort_rows 1 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_delete 1 +Handler_read_first 1 +Handler_read_key 6 +Handler_read_rnd 1 +Handler_read_rnd_next 27 +Sort_rows 1 +Sort_scan 1 + +DROP TABLE t1, t2; +#34 +CREATE TABLE t1 (i INT); +INSERT INTO t1 (i) VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2 (a CHAR(2), b CHAR(2), c CHAR(2), d CHAR(2), INDEX (a,b,c)) +charset utf8mb4 ENGINE=HEAP; +INSERT INTO t2 SELECT i, i, i, i FROM t1; +# +# query: DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# select: SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# +EXPLAIN DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t2 NULL ALL NULL NULL NULL NULL 26 100.00 Using where; Using filesort +Warnings: +Warning 1739 Cannot use range access on index 'a' due to type or collation conversion on field 'b' +Note 1003 delete from `test`.`t2` where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 4 +Handler_read_rnd_next 27 +Sort_rows 1 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_delete 1 +Handler_read_key 4 +Handler_read_rnd 1 +Handler_read_rnd_next 27 +Sort_rows 1 +Sort_scan 1 + +DROP TABLE t1, t2; +#35 +CREATE TABLE t1 (i INT); +INSERT INTO t1 (i) VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35),(36),(37),(38),(39), +(40),(41),(42),(43),(44); +CREATE TABLE t2 (i INT, key1 INT, key2 INT, INDEX (key1), INDEX (key2)); +INSERT INTO t2 (key1, key2) SELECT i, i FROM t1; +# +# query: DELETE FROM t2 WHERE key1 < 13 or key2 < 14 ORDER BY key1 +# select: SELECT * FROM t2 WHERE key1 < 13 or key2 < 14 ORDER BY key1 +# +EXPLAIN DELETE FROM t2 WHERE key1 < 13 or key2 < 14 ORDER BY key1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t2 NULL index_merge key1,key2 key1,key2 5,5 NULL X 100.00 Using sort_union(key1,key2); Using where; Using filesort +Warnings: +Note 1003 delete from `test`.`t2` where ((`test`.`t2`.`key1` < 13) or (`test`.`t2`.`key2` < 14)) order by `test`.`t2`.`key1` +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 9 +Handler_read_next 7 +Handler_read_rnd 4 +Sort_rows 4 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_delete 4 +Handler_read_key 13 +Handler_read_next 7 +Handler_read_rnd 8 +Sort_rows 4 +Sort_scan 1 + +DROP TABLE t1, t2; +#36 +CREATE TABLE t1 (i INT); +INSERT INTO t1 (i) VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2(a INT, i INT PRIMARY KEY); +INSERT INTO t2 (i) SELECT i FROM t1; +# +# query: DELETE FROM t2 WHERE i > 10 AND i <= 18 ORDER BY i DESC LIMIT 1 +# select: SELECT * FROM t2 WHERE i > 10 AND i <= 18 ORDER BY i DESC LIMIT 1 +# +EXPLAIN DELETE FROM t2 WHERE i > 10 AND i <= 18 ORDER BY i DESC LIMIT 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t2 NULL range PRIMARY PRIMARY 4 const X 100.00 Using where; Backward index scan +Warnings: +Note 1003 delete from `test`.`t2` where ((`test`.`t2`.`i` > 10) and (`test`.`t2`.`i` <= 18)) order by `test`.`t2`.`i` desc limit 1 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 4 +Handler_read_rnd_next 1 +# Status of testing query execution: +Variable_name Value +Handler_delete 1 +Handler_read_key 3 + +DROP TABLE t1, t2; +#37 +CREATE TABLE t1 (i INT); +INSERT INTO t1 (i) VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2 (a CHAR(2), b CHAR(2), c CHAR(2), INDEX (a, b)) charset utf8mb4; +INSERT INTO t2 SELECT i, i, i FROM t1; +# +# query: DELETE FROM t2 ORDER BY a, b DESC LIMIT 5 +# select: SELECT * FROM t2 ORDER BY a, b DESC LIMIT 5 +# +EXPLAIN DELETE FROM t2 ORDER BY a, b DESC LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t2 NULL ALL NULL NULL NULL NULL 26 100.00 Using filesort +Warnings: +Note 1003 delete from `test`.`t2` order by `test`.`t2`.`a`,`test`.`t2`.`b` desc limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 4 +Handler_read_rnd_next 27 +Sort_rows 5 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_delete 5 +Handler_read_first 1 +Handler_read_key 9 +Handler_read_rnd 5 +Handler_read_rnd_next 27 +Sort_rows 26 +Sort_scan 1 + +DROP TABLE t1, t2; +#38 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2 (a CHAR(2), b CHAR(2), c INT, INDEX (a, b)) charset utf8mb4; +INSERT INTO t2 (a, b) SELECT i, i FROM t1; +INSERT INTO t2 (a, b) SELECT t1.i, t1.i FROM t1, t1 x1, t1 x2; +# +# query: DELETE FROM t2 ORDER BY a DESC, b DESC LIMIT 5 +# select: SELECT * FROM t2 ORDER BY a DESC, b DESC LIMIT 5 +# +EXPLAIN DELETE FROM t2 ORDER BY a DESC, b DESC LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t2 NULL index NULL a 18 NULL X 100.00 NULL +Warnings: +Note 1003 delete from `test`.`t2` order by `test`.`t2`.`a` desc,`test`.`t2`.`b` desc limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 4 +Handler_read_last 1 +Handler_read_rnd_next 20 +# Status of testing query execution: +Variable_name Value +Handler_delete 5 +Handler_read_key 4 +Handler_read_last 1 +Handler_read_prev 4 + +DROP TABLE t1, t2; +#39 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2(a INT, i INT PRIMARY KEY); +INSERT INTO t2 (i) SELECT i FROM t1; +# +# query: UPDATE t2 SET a = 10 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 1 +# select: SELECT * FROM t2 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 1 +# +EXPLAIN UPDATE t2 SET a = 10 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t2 NULL range PRIMARY PRIMARY 4 const X 100.00 Using where; Using temporary +Warnings: +Note 1003 update `test`.`t2` set `test`.`t2`.`a` = 10 where ((`test`.`t2`.`i` > 10) and (`test`.`t2`.`i` <= 18)) order by `test`.`t2`.`i` limit 1 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 4 +Handler_read_rnd_next 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 4 +Handler_read_rnd 1 +Handler_update 1 + +DROP TABLE t1, t2; +#40 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2(a INT, i CHAR(2), INDEX(i(1))) charset utf8mb4; +INSERT INTO t2 (i) SELECT i FROM t1; +# +# query: UPDATE t2 SET a = 10 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 5 +# select: SELECT * FROM t2 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 5 +# +EXPLAIN UPDATE t2 SET a = 10 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t2 NULL ALL NULL NULL NULL NULL 26 100.00 Using where; Using filesort +Warnings: +Warning 1739 Cannot use range access on index 'i' due to type or collation conversion on field 'i' +Warning 1739 Cannot use range access on index 'i' due to type or collation conversion on field 'i' +Note 1003 update `test`.`t2` set `test`.`t2`.`a` = 10 where ((`test`.`t2`.`i` > 10) and (`test`.`t2`.`i` <= 18)) order by `test`.`t2`.`i` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 3 +Handler_read_rnd_next 27 +Sort_rows 5 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 8 +Handler_read_rnd 5 +Handler_read_rnd_next 27 +Handler_update 5 +Sort_rows 5 +Sort_scan 1 + +DROP TABLE t1, t2; +#41 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2(a INT, b INT, c INT, d INT, INDEX(a, b, c)); +INSERT INTO t2 (a, b, c) SELECT i, i, i FROM t1; +# +# query: UPDATE t2 SET d = 10 WHERE b = 10 ORDER BY a, c LIMIT 5 +# select: SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# +EXPLAIN UPDATE t2 SET d = 10 WHERE b = 10 ORDER BY a, c LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t2 NULL ALL NULL NULL NULL NULL 26 100.00 Using where; Using filesort +Warnings: +Note 1003 update `test`.`t2` set `test`.`t2`.`d` = 10 where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 5 +Handler_read_rnd_next 27 +# Status of testing query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 6 +Handler_read_rnd 1 +Handler_read_rnd_next 27 +Handler_update 1 +Sort_rows 1 +Sort_scan 1 + +DROP TABLE t1, t2; +#42 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2(a INT, b INT, c INT, d INT, INDEX(a, b, c)); +INSERT INTO t2 (a, b, c) SELECT i, i, i FROM t1; +INSERT INTO t2 (a, b, c) SELECT t1.i, t1.i, t1.i FROM t1, t1 x1, t1 x2; +# +# query: UPDATE t2 SET d = 10 WHERE b = 10 ORDER BY a, c LIMIT 5 +# select: SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# +EXPLAIN UPDATE t2 SET d = 10 WHERE b = 10 ORDER BY a, c LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t2 NULL index NULL a 15 NULL X 100.00 Using where; Using temporary +Warnings: +Note 1003 update `test`.`t2` set `test`.`t2`.`d` = 10 where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 5 +Handler_read_rnd_next 16936 +# Status of testing query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 10 +Handler_read_next 4 +Handler_read_rnd 5 +Handler_update 5 + +DROP TABLE t1, t2; +#43 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2 (a CHAR(2), b CHAR(2), c CHAR(2), d CHAR(2), INDEX (a,b(1),c)) +charset utf8mb4; +INSERT INTO t2 SELECT i, i, i, i FROM t1; +# +# query: UPDATE t2 SET d = 10 WHERE b = 10 ORDER BY a, c LIMIT 5 +# select: SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# +EXPLAIN UPDATE t2 SET d = 10 WHERE b = 10 ORDER BY a, c LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t2 NULL ALL NULL NULL NULL NULL 26 100.00 Using where; Using filesort +Warnings: +Warning 1739 Cannot use range access on index 'a' due to type or collation conversion on field 'b' +Note 1003 update `test`.`t2` set `test`.`t2`.`d` = 10 where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 5 +Handler_read_rnd_next 27 +Sort_rows 1 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 6 +Handler_read_rnd 1 +Handler_read_rnd_next 27 +Sort_rows 1 +Sort_scan 1 + +DROP TABLE t1, t2; +#44 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2 (a CHAR(2), b CHAR(2), c CHAR(2), d CHAR(2), INDEX (a,b,c)) +charset utf8mb4 ENGINE=HEAP; +INSERT INTO t2 SELECT i, i, i, i FROM t1; +# +# query: UPDATE t2 SET d = 10 WHERE b = 10 ORDER BY a, c LIMIT 5 +# select: SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# +EXPLAIN UPDATE t2 SET d = 10 WHERE b = 10 ORDER BY a, c LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t2 NULL ALL NULL NULL NULL NULL 26 100.00 Using where; Using filesort +Warnings: +Warning 1739 Cannot use range access on index 'a' due to type or collation conversion on field 'b' +Note 1003 update `test`.`t2` set `test`.`t2`.`d` = 10 where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 4 +Handler_read_rnd_next 27 +Sort_rows 1 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 4 +Handler_read_rnd 1 +Handler_read_rnd_next 27 +Sort_rows 1 +Sort_scan 1 + +DROP TABLE t1, t2; +#45 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35),(36),(37),(38),(39), +(40),(41),(42),(43),(44); +CREATE TABLE t2 (i INT, key1 INT, key2 INT, INDEX (key1), INDEX (key2)); +INSERT INTO t2 (key1, key2) SELECT i, i FROM t1; +# +# query: UPDATE t2 SET i = 123 WHERE key1 < 13 or key2 < 14 ORDER BY key1 +# select: SELECT * FROM t2 WHERE key1 < 13 or key2 < 14 ORDER BY key1 +# +EXPLAIN UPDATE t2 SET i = 123 WHERE key1 < 13 or key2 < 14 ORDER BY key1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t2 NULL index_merge key1,key2 key1,key2 5,5 NULL X 100.00 Using sort_union(key1,key2); Using where; Using filesort +Warnings: +Note 1003 update `test`.`t2` set `test`.`t2`.`i` = 123 where ((`test`.`t2`.`key1` < 13) or (`test`.`t2`.`key2` < 14)) order by `test`.`t2`.`key1` +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 9 +Handler_read_next 7 +Handler_read_rnd 4 +Sort_rows 4 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 13 +Handler_read_next 7 +Handler_read_rnd 8 +Handler_update 4 +Sort_rows 4 +Sort_scan 1 + +DROP TABLE t1, t2; +#46 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2(a INT, i INT PRIMARY KEY); +INSERT INTO t2 (i) SELECT i FROM t1; +# +# query: UPDATE t2 SET a = 10 WHERE i > 10 AND i <= 18 ORDER BY i DESC LIMIT 1 +# select: SELECT * FROM t2 WHERE i > 10 AND i <= 18 ORDER BY i DESC LIMIT 1 +# +EXPLAIN UPDATE t2 SET a = 10 WHERE i > 10 AND i <= 18 ORDER BY i DESC LIMIT 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t2 NULL range PRIMARY PRIMARY 4 const X 100.00 Using where; Backward index scan; Using temporary +Warnings: +Note 1003 update `test`.`t2` set `test`.`t2`.`a` = 10 where ((`test`.`t2`.`i` > 10) and (`test`.`t2`.`i` <= 18)) order by `test`.`t2`.`i` desc limit 1 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 4 +Handler_read_rnd_next 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 4 +Handler_read_rnd 1 +Handler_update 1 + +DROP TABLE t1, t2; +#47 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2 (a CHAR(2), b CHAR(2), c CHAR(2), INDEX (a, b)) charset utf8mb4; +INSERT INTO t2 SELECT i, i, i FROM t1; +# +# query: UPDATE t2 SET c = 10 ORDER BY a, b DESC LIMIT 5 +# select: SELECT * FROM t2 ORDER BY a, b DESC LIMIT 5 +# +EXPLAIN UPDATE t2 SET c = 10 ORDER BY a, b DESC LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t2 NULL ALL NULL NULL NULL NULL 26 100.00 Using filesort +Warnings: +Note 1003 update `test`.`t2` set `test`.`t2`.`c` = 10 order by `test`.`t2`.`a`,`test`.`t2`.`b` desc limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 4 +Handler_read_rnd_next 27 +Sort_rows 5 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 9 +Handler_read_rnd 5 +Handler_read_rnd_next 27 +Handler_update 4 +Sort_rows 5 +Sort_scan 1 + +DROP TABLE t1, t2; +#48 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2 (a CHAR(2), b CHAR(2), c INT, INDEX (a, b)) charset utf8mb4; +INSERT INTO t2 (a, b) SELECT i, i FROM t1; +INSERT INTO t2 (a, b) SELECT t1.i, t1.i FROM t1, t1 x1, t1 x2; +# +# query: UPDATE t2 SET c = 10 ORDER BY a DESC, b DESC LIMIT 5 +# select: SELECT * FROM t2 ORDER BY a DESC, b DESC LIMIT 5 +# +EXPLAIN UPDATE t2 SET c = 10 ORDER BY a DESC, b DESC LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t2 NULL index NULL a 18 NULL X 100.00 Using temporary +Warnings: +Note 1003 update `test`.`t2` set `test`.`t2`.`c` = 10 order by `test`.`t2`.`a` desc,`test`.`t2`.`b` desc limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 4 +Handler_read_last 1 +Handler_read_rnd_next 20 +# Status of testing query execution: +Variable_name Value +Handler_read_key 9 +Handler_read_last 1 +Handler_read_prev 4 +Handler_read_rnd 5 +Handler_update 5 + +DROP TABLE t1, t2; +#49 +CREATE TABLE t1 ( +pk INT NOT NULL AUTO_INCREMENT, +c1_idx CHAR(1) DEFAULT 'y', +c2 INT, +PRIMARY KEY (pk), +INDEX c1_idx (c1_idx) +) charset utf8mb4; +INSERT INTO t1 VALUES (1,'y',1), (2,'n',2), (3,'y',3), (4,'n',4); +# +# query: UPDATE t1 SET c2 = 0 WHERE c1_idx = 'y' ORDER BY pk DESC LIMIT 2 +# select: SELECT * FROM t1 WHERE c1_idx = 'y' ORDER BY pk DESC LIMIT 2 +# +EXPLAIN UPDATE t1 SET c2 = 0 WHERE c1_idx = 'y' ORDER BY pk DESC LIMIT 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL range c1_idx c1_idx 5 const 2 100.00 Using where; Backward index scan; Using temporary +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`c2` = 0 where (`test`.`t1`.`c1_idx` = 'y') order by `test`.`t1`.`pk` desc limit 2 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 6 +Handler_read_rnd_next 2 +# Status of testing query execution: +Variable_name Value +Handler_read_key 6 +Handler_read_prev 1 +Handler_read_rnd 2 +Handler_update 2 + +# +# query: DELETE FROM t1 WHERE c1_idx = 'y' ORDER BY pk DESC LIMIT 2 +# select: SELECT * FROM t1 WHERE c1_idx = 'y' ORDER BY pk DESC LIMIT 2 +# +EXPLAIN DELETE FROM t1 WHERE c1_idx = 'y' ORDER BY pk DESC LIMIT 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL range c1_idx c1_idx 5 const 2 100.00 Using where; Backward index scan +Warnings: +Note 1003 delete from `test`.`t1` where (`test`.`t1`.`c1_idx` = 'y') order by `test`.`t1`.`pk` desc limit 2 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 6 +Handler_read_rnd_next 2 +# Status of testing query execution: +Variable_name Value +Handler_delete 2 +Handler_read_key 4 +Handler_read_prev 1 + +DROP TABLE t1; +#50 +CREATE TABLE t1 (a INT AUTO_INCREMENT PRIMARY KEY); +INSERT INTO t1 VALUES (),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(); +# +# query: UPDATE t1 SET a=a+10 WHERE a > 34 +# select: SELECT * FROM t1 WHERE a > 34 +# +EXPLAIN UPDATE t1 SET a=a+10 WHERE a > 34; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL range PRIMARY PRIMARY 4 const 2 100.00 Using where; Using temporary +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`a` = (`test`.`t1`.`a` + 10) where (`test`.`t1`.`a` > 34) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 3 +Handler_read_last 1 +Handler_read_rnd_next 3 +# Status of testing query execution: +Variable_name Value +Handler_read_key 4 +Handler_read_next 2 +Handler_read_rnd 2 +Handler_update 2 + +DROP TABLE t1; +#51 +CREATE TABLE t1 (c1 INT, c2 INT, c3 INT); +CREATE TABLE t2 (c1 INT, c2 INT); +INSERT INTO t1 VALUES (1, 1, 10), (2, 2, 20); +# +# query: UPDATE t1 LEFT JOIN t2 ON t1.c1 = t2.c1 SET t2.c2 = 10 +# select: SELECT * FROM t1 LEFT JOIN t2 ON t1.c1 = t2.c1 +# +EXPLAIN UPDATE t1 LEFT JOIN t2 ON t1.c1 = t2.c1 SET t2.c2 = 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 UPDATE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 update `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`c1` = `test`.`t1`.`c1`)) set `test`.`t2`.`c2` = 10 where true +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 2 +Handler_read_key 7 +Handler_read_rnd_next 4 +# Status of testing query execution: +Variable_name Value +Handler_read_first 3 +Handler_read_key 8 +Handler_read_rnd_next 5 + +# +# query: UPDATE t1 LEFT JOIN t2 ON t1.c1 = t2.c1 SET t2.c2 = 10 WHERE t1.c3 = 10 +# select: SELECT * FROM t1 LEFT JOIN t2 ON t1.c1 = t2.c1 WHERE t1.c3 = 10 +# +EXPLAIN UPDATE t1 LEFT JOIN t2 ON t1.c1 = t2.c1 SET t2.c2 = 10 WHERE t1.c3 = 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 UPDATE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 update `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`c1` = `test`.`t1`.`c1`)) set `test`.`t2`.`c2` = 10 where (`test`.`t1`.`c3` = 10) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 2 +Handler_read_key 7 +Handler_read_rnd_next 4 +# Status of testing query execution: +Variable_name Value +Handler_read_first 2 +Handler_read_key 7 +Handler_read_rnd_next 4 + +DROP TABLE t1, t2; +#52 +CREATE TABLE t1(f1 INT, f2 INT); +CREATE TABLE t2(f3 INT, f4 INT); +CREATE INDEX IDX ON t2(f3); +INSERT INTO t1 VALUES(1,0),(2,0); +INSERT INTO t2 VALUES(1,1),(2,2); +# +# query: UPDATE t1 SET t1.f2=(SELECT MAX(t2.f4) FROM t2 WHERE t2.f3=t1.f1) +# select: SELECT (SELECT MAX(t2.f4) FROM t2 WHERE t2.f3=t1.f1) FROM t1 +# +EXPLAIN UPDATE t1 SET t1.f2=(SELECT MAX(t2.f4) FROM t2 WHERE t2.f3=t1.f1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DEPENDENT SUBQUERY t2 NULL ref IDX IDX 5 test.t1.f1 1 100.00 NULL +Warnings: +Note 1276 Field or reference 'test.t1.f1' of SELECT #2 was resolved in SELECT #1 +Note 1003 update `test`.`t1` set `test`.`t1`.`f2` = (/* select#2 */ select max(`test`.`t2`.`f4`) from `test`.`t2` where (`test`.`t2`.`f3` = `test`.`t1`.`f1`)) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 7 +Handler_read_next 2 +Handler_read_rnd_next 3 +# Status of testing query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 7 +Handler_read_next 2 +Handler_read_rnd_next 3 +Handler_update 2 + +DROP TABLE t1, t2; +#55 +CREATE TABLE t1(a INT); +INSERT INTO t1 VALUES (1); +SET @a = NULL; +EXPLAIN DELETE FROM t1 WHERE (@a:= a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +Note 1003 delete from `test`.`t1` where (0 <> (@a:=`test`.`t1`.`a`)) +DROP TABLE t1; +#56 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +DELETE FROM t1 USING t1 WHERE uknown_column = 12345; +ERROR 42S22: Unknown column 'uknown_column' in 'where clause' +EXPLAIN DELETE FROM t1 USING t1 WHERE uknown_column = 12345; +ERROR 42S22: Unknown column 'uknown_column' in 'where clause' +DROP TABLE t1; +#57 +CREATE TABLE t1(f1 INT); +EXPLAIN UPDATE t1 SET f2=1 ORDER BY f2; +ERROR 42S22: Unknown column 'f2' in 'field list' +UPDATE t1 SET f2=1 ORDER BY f2; +ERROR 42S22: Unknown column 'f2' in 'field list' +DROP TABLE t1; +#59 +CREATE TABLE t1 ( a INT, KEY( a ) ); +INSERT INTO t1 VALUES (0), (1); +CREATE VIEW v1 AS SELECT t11.a, t12.a AS b FROM t1 t11, t1 t12; +SET SESSION sql_safe_updates = 1; +EXPLAIN UPDATE IGNORE v1 SET a = 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t11 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t12 NULL index NULL a 5 NULL 2 100.00 Using index +Warnings: +Note 1003 update ignore (`test`.`t1` `t11` join `test`.`t1` `t12`) set `t11`.`a` = 1 +UPDATE IGNORE v1 SET a = 1; +ERROR HY000: You are using safe update mode and you tried to update a table without a WHERE that uses a KEY column. +SET SESSION sql_safe_updates = DEFAULT; +DROP TABLE t1; +DROP VIEW v1; +#62 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (0), (1); +CREATE VIEW v1 AS SELECT t11.a, t12.a AS b FROM t1 t11, t1 t12; +# +# query: UPDATE v1 SET a = 1 WHERE a > 0 +# select: SELECT * FROM v1 WHERE a > 0 +# +EXPLAIN UPDATE v1 SET a = 1 WHERE a > 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t11 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t12 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 update (`test`.`t1` `t11` join `test`.`t1` `t12`) set `t11`.`a` = 1 where (`t11`.`a` > 0) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 2 +Handler_read_key 3 +Handler_read_rnd_next 6 +# Status of testing query execution: +Variable_name Value +Handler_read_first 2 +Handler_read_key 4 +Handler_read_rnd 1 +Handler_read_rnd_next 8 +Handler_write 2 + +# +# query: UPDATE t1, v1 SET v1.a = 1 WHERE t1.a = v1.a +# select: SELECT * FROM t1, v1 WHERE t1.a = v1.a +# +EXPLAIN UPDATE t1, v1 SET v1.a = 1 WHERE t1.a = v1.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 UPDATE t11 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t12 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 update `test`.`t1` join `test`.`t1` `t11` join `test`.`t1` `t12` set `test`.`t11`.`a` = 1 where (`test`.`t11`.`a` = `test`.`t1`.`a`) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 3 +Handler_read_key 4 +Handler_read_rnd_next 9 +# Status of testing query execution: +Variable_name Value +Handler_read_first 5 +Handler_read_key 8 +Handler_read_rnd 2 +Handler_read_rnd_next 18 +Handler_update 1 +Handler_write 4 + +DROP TABLE t1; +DROP VIEW v1; +#63 +CREATE TABLE t1 (a INT, PRIMARY KEY(a)); +INSERT INTO t1 VALUES (1), (2), (3), (4), (5); +CREATE VIEW v1 (a) AS SELECT a FROM t1; +# +# query: DELETE FROM v1 WHERE a < 4 +# select: SELECT * FROM v1 WHERE a < 4 +# +EXPLAIN DELETE FROM v1 WHERE a < 4; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL range PRIMARY PRIMARY 4 const X 100.00 Using where +Warnings: +Note 1003 delete from (`test`.`t1`) where (`test`.`t1`.`a` < 4) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 2 +Handler_read_next 3 +# Status of testing query execution: +Variable_name Value +Handler_delete 3 +Handler_read_first 1 +Handler_read_key 2 +Handler_read_next 3 + +DROP TABLE t1; +DROP VIEW v1; +#64 +CREATE TABLE t1 (a INT, b INT, PRIMARY KEY(a)); +INSERT INTO t1 VALUES (1,2), (2,3), (3,4), (4,5), (5,10); +CREATE TABLE t2 (x INT); +INSERT INTO t2 VALUES (1), (2), (3), (4); +CREATE VIEW v1 (a,c) AS SELECT a, b+1 FROM t1; +# +# query: DELETE v1 FROM t2, v1 WHERE t2.x = v1.a +# select: SELECT * FROM t2, v1 WHERE t2.x = v1.a +# +EXPLAIN DELETE v1 FROM t2, v1 WHERE t2.x = v1.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +1 DELETE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.x 1 100.00 NULL +Warnings: +Note 1003 delete `test`.`t1` from `test`.`t2` join `test`.`t1` where (`test`.`t1`.`a` = `test`.`t2`.`x`) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 8 +Handler_read_rnd_next 5 +# Status of testing query execution: +Variable_name Value +Handler_delete 4 +Handler_read_first 1 +Handler_read_key 12 +Handler_read_rnd 4 +Handler_read_rnd_next 5 + +DROP TABLE t1,t2; +DROP VIEW v1; +#65 +CREATE TABLE t1 (a INT, b INT, PRIMARY KEY(a)); +INSERT INTO t1 VALUES (1,2), (2,3), (3,4), (4,5), (5,10); +CREATE TABLE t2 (x INT); +INSERT INTO t2 VALUES (1), (2), (3), (4); +CREATE VIEW v1 (a,c) AS SELECT a, b+1 FROM t1; +# +# query: DELETE v1 FROM t2, v1 WHERE t2.x = v1.a +# select: SELECT * FROM t2, v1 WHERE t2.x = v1.a +# +EXPLAIN DELETE v1 FROM t2, v1 WHERE t2.x = v1.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +1 DELETE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.x 1 100.00 NULL +Warnings: +Note 1003 delete `test`.`t1` from `test`.`t2` join `test`.`t1` where (`test`.`t1`.`a` = `test`.`t2`.`x`) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 8 +Handler_read_rnd_next 5 +# Status of testing query execution: +Variable_name Value +Handler_delete 4 +Handler_read_first 1 +Handler_read_key 12 +Handler_read_rnd 4 +Handler_read_rnd_next 5 + +DROP TABLE t1,t2; +DROP VIEW v1; +#66 +CREATE TABLE t1 (a INT); +CREATE VIEW v1 (x) AS SELECT a FROM t1; +# +# query: INSERT INTO v1 VALUES (10) +# select: SELECT NULL +# +EXPLAIN INSERT INTO v1 VALUES (10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 INSERT t1 NULL ALL NULL NULL NULL NULL NULL NULL NULL +Warnings: +Note 1003 insert into `test`.`t1` values (10) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +# Status of testing query execution: +Variable_name Value +Handler_read_key 1 +Handler_write 1 + +DROP TABLE t1; +DROP VIEW v1; +#67 +CREATE TABLE t1 (a INT); +CREATE TABLE t2 (b INT); +INSERT INTO t2 VALUES (1), (2), (3); +CREATE VIEW v1 (x) AS SELECT b FROM t2; +# +# query: INSERT INTO v1 SELECT * FROM t1 +# select: SELECT * FROM t1 +# +EXPLAIN INSERT INTO v1 SELECT * FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 INSERT t2 NULL ALL NULL NULL NULL NULL NULL NULL NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 insert into `test`.`t2` /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 2 +Handler_read_rnd_next 1 +# Status of testing query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 3 +Handler_read_rnd_next 1 + +DROP TABLE t1, t2; +DROP VIEW v1; +#69 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +CREATE TABLE t2 (b INT); +INSERT INTO t2 VALUES (1), (2), (3); +# +# query: UPDATE t1 SET a = 10 WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x) +# select: SELECT * FROM t1 WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x) +# +EXPLAIN UPDATE t1 SET a = 10 WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY NULL index_subquery 5 func 2 100.00 Using index +3 DERIVED t2 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`a` = 10 where (`test`.`t1`.`a`,(((`test`.`t1`.`a`) in x on ))) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 2 +Handler_read_key 7 +Handler_read_rnd_next 8 +Handler_write 1 +Sort_rows 3 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_read_first 2 +Handler_read_key 7 +Handler_read_rnd_next 8 +Handler_update 1 +Handler_write 1 +Sort_rows 3 +Sort_scan 1 + +# +# query: UPDATE t1, t2 SET a = 10 WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x) +# select: SELECT * FROM t1, t2 WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x) +# +EXPLAIN UPDATE t1, t2 SET a = 10 WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 DEPENDENT SUBQUERY NULL index_subquery 5 func 2 100.00 Using index +3 DERIVED t2 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 update `test`.`t1` join `test`.`t2` set `test`.`t1`.`a` = 10 where (`test`.`t1`.`a`,(((`test`.`t1`.`a`) in x on ))) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 2 +Handler_read_key 7 +Handler_read_rnd_next 8 +Handler_write 1 +Sort_rows 3 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_read_first 2 +Handler_read_key 7 +Handler_read_rnd_next 8 +Handler_write 1 +Sort_rows 3 +Sort_scan 1 + +# +# query: UPDATE t1, (SELECT * FROM t2) y SET a = 10 WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x) +# select: SELECT * FROM t1, (SELECT * FROM t2) y WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x) +# +EXPLAIN UPDATE t1, (SELECT * FROM t2) y SET a = 10 WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +3 DEPENDENT SUBQUERY NULL index_subquery 5 func 2 100.00 Using index +4 DERIVED t2 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 update `test`.`t1` join `test`.`t2` set `test`.`t1`.`a` = 10 where (`test`.`t1`.`a`,(((`test`.`t1`.`a`) in x on ))) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 2 +Handler_read_key 7 +Handler_read_rnd_next 8 +Handler_write 1 +Sort_rows 3 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_read_first 2 +Handler_read_key 7 +Handler_read_rnd_next 8 +Handler_write 1 +Sort_rows 3 +Sort_scan 1 + +DROP TABLE t1,t2; +#70 +CREATE TABLE t1 (c1 INT KEY); +CREATE TABLE t2 (c2 INT); +CREATE TABLE t3 (c3 INT); +EXPLAIN UPDATE t3 SET c3 = ( +SELECT COUNT(d1.c1) +FROM ( +SELECT a11.c1 FROM t1 AS a11 +STRAIGHT_JOIN t2 AS a21 ON a21.c2 = a11.c1 +JOIN t1 AS a12 ON a12.c1 = a11.c1 +) d1 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t3 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SUBQUERY NULL ALL NULL NULL NULL NULL 2 100.00 NULL +3 DERIVED a11 NULL index PRIMARY PRIMARY 4 NULL 1 100.00 Using index +3 DERIVED a21 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +3 DERIVED a12 NULL eq_ref PRIMARY PRIMARY 4 test.a11.c1 1 100.00 Using index +Warnings: +Note 1003 update `test`.`t3` set `test`.`t3`.`c3` = (/* select#2 */ select count(`d1`.`c1`) from (/* select#3 */ select `test`.`a11`.`c1` AS `c1` from `test`.`t1` `a11` straight_join `test`.`t2` `a21` join `test`.`t1` `a12` where ((`test`.`a21`.`c2` = `test`.`a11`.`c1`) and (`test`.`a12`.`c1` = `test`.`a11`.`c1`))) `d1`) +DROP TABLE t1, t2, t3; +#71 +CREATE TABLE t1 (c1 INT NOT NULL, c2 INT NOT NULL, INDEX i1(c1)); +INSERT INTO t1 VALUES (1,0),(2,0),(3,0),(4,0),(5,0),(6,0),(7,0),(8,0); +CREATE TABLE t2 LIKE t1; +EXPLAIN INSERT INTO t2 SELECT * FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 INSERT t2 NULL ALL NULL NULL NULL NULL X NULL NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL X 100.00 NULL +Warnings: +Note 1003 insert into `test`.`t2` /* select#1 */ select `test`.`t1`.`c1` AS `c1`,`test`.`t1`.`c2` AS `c2` from `test`.`t1` +INSERT INTO t2 SELECT * FROM t1; +SELECT * FROM t1 LEFT JOIN t2 ON t1.c1 = t2.c1; +DROP TABLE t1, t2; +#73 +CREATE TABLE t1 (id INT); +CREATE TABLE t2 (id INT); +INSERT INTO t1 VALUES (1), (2); +EXPLAIN SELECT * FROM t1 LEFT JOIN t2 USING(id) GROUP BY t1.id; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using temporary +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id` from `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`id` = `test`.`t1`.`id`)) where true group by `test`.`t1`.`id` +DROP TABLE t1,t2; +#74 +CREATE TABLE t1(a INT PRIMARY KEY) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1), (2), (3), (4), (5); +# used key is modified & Using temporary +# +# query: UPDATE t1 SET a=a+1 WHERE a>10 +# select: SELECT a t1 FROM t1 WHERE a>10 +# +EXPLAIN UPDATE t1 SET a=a+1 WHERE a>10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL range PRIMARY PRIMARY 4 const 1 100.00 Using where; Using temporary +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`a` = (`test`.`t1`.`a` + 1) where (`test`.`t1`.`a` > 10) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 2 + +# used key is modified & Using filesort +# +# query: UPDATE t1 SET a=a+1 WHERE a>10 ORDER BY a+20 +# select: SELECT a t1 FROM t1 WHERE a>10 ORDER BY a+20 +# +EXPLAIN UPDATE t1 SET a=a+1 WHERE a>10 ORDER BY a+20; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL range PRIMARY PRIMARY 4 const 1 100.00 Using where; Using filesort +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`a` = (`test`.`t1`.`a` + 1) where (`test`.`t1`.`a` > 10) order by (`test`.`t1`.`a` + 20) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 1 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 2 +Sort_scan 1 + +DROP TABLE t1; +# +# Bug #12949629: CLIENT LOSES CONNECTION AFTER EXECUTING A PROCEDURE WITH +# EXPLAIN UPDATE/DEL/INS +# +CREATE TABLE t1 (i INT); +CREATE TABLE t2 (i INT); +CREATE PROCEDURE p1() BEGIN EXPLAIN INSERT INTO t1 VALUES (1);END| +CREATE PROCEDURE p2() BEGIN INSERT INTO t1 VALUES (1);END| +CREATE PROCEDURE p3() BEGIN EXPLAIN INSERT INTO t1 SELECT 1;END| +CREATE PROCEDURE p4() BEGIN INSERT INTO t1 SELECT 1;END| +CREATE PROCEDURE p5() BEGIN EXPLAIN REPLACE INTO t1 VALUES (1);END| +CREATE PROCEDURE p6() BEGIN REPLACE INTO t1 VALUES (1);END| +CREATE PROCEDURE p7() BEGIN EXPLAIN REPLACE INTO t1 SELECT 1;END| +CREATE PROCEDURE p8() BEGIN REPLACE INTO t1 SELECT 1;END| +CREATE PROCEDURE p9() BEGIN EXPLAIN UPDATE t1 SET i = 10;END| +CREATE PROCEDURE p10() BEGIN UPDATE t1 SET i = 10;END| +CREATE PROCEDURE p11() BEGIN EXPLAIN UPDATE t1,t2 SET t1.i = 10 WHERE t1.i = t2.i ;END| +CREATE PROCEDURE p12() BEGIN UPDATE t1,t2 SET t1.i = 10 WHERE t1.i = t2.i ;END| +CREATE PROCEDURE p13() BEGIN +# Disabling binary logging temporarily as optimized delete is not used when log-bin is enabled in row mode +SET @save_log_bin= @@sql_log_bin;SET SQL_LOG_BIN=0; +EXPLAIN DELETE FROM t1; +SET SQL_LOG_BIN=@save_log_bin; END| +CREATE PROCEDURE p14() BEGIN DELETE FROM t1;END| +CREATE PROCEDURE p15() BEGIN EXPLAIN DELETE FROM t1 USING t1;END| +CREATE PROCEDURE p16() BEGIN DELETE FROM t1 USING t1;END| +CALL p16(); +DROP PROCEDURE p16; +CALL p15(); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 delete `test`.`t1` from `test`.`t1` +DROP PROCEDURE p15; +CALL p14(); +DROP PROCEDURE p14; +CALL p13(); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Deleting all rows +DROP PROCEDURE p13; +CALL p12(); +DROP PROCEDURE p12; +CALL p11(); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 update `test`.`t1` join `test`.`t2` set `test`.`t1`.`i` = 10 where (`test`.`t2`.`i` = `test`.`t1`.`i`) +DROP PROCEDURE p11; +CALL p10(); +DROP PROCEDURE p10; +CALL p9(); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`i` = 10 +DROP PROCEDURE p9; +CALL p8(); +DROP PROCEDURE p8; +CALL p7(); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 REPLACE t1 NULL ALL NULL NULL NULL NULL NULL NULL NULL +Warnings: +Note 1003 replace into `test`.`t1` /* select#1 */ select 1 AS `1` from dual +DROP PROCEDURE p7; +CALL p6(); +DROP PROCEDURE p6; +CALL p5(); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 REPLACE t1 NULL ALL NULL NULL NULL NULL NULL NULL NULL +Warnings: +Note 1003 replace into `test`.`t1` values (1) +DROP PROCEDURE p5; +CALL p4(); +DROP PROCEDURE p4; +CALL p3(); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 INSERT t1 NULL ALL NULL NULL NULL NULL NULL NULL NULL +Warnings: +Note 1003 insert into `test`.`t1` /* select#1 */ select 1 AS `1` from dual +DROP PROCEDURE p3; +CALL p2(); +DROP PROCEDURE p2; +CALL p1(); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 INSERT t1 NULL ALL NULL NULL NULL NULL NULL NULL NULL +Warnings: +Note 1003 insert into `test`.`t1` values (1) +DROP PROCEDURE p1; +DROP TABLE t1, t2; +# +set default_storage_engine= @save_storage_engine; +set optimizer_switch=default; diff --git a/mysql-test/r/innodb_icp.result-pq b/mysql-test/r/innodb_icp.result-pq new file mode 100644 index 000000000000..9600a7f8ab2d --- /dev/null +++ b/mysql-test/r/innodb_icp.result-pq @@ -0,0 +1,1130 @@ +set optimizer_switch='index_condition_pushdown=on'; +set @save_storage_engine= @@default_storage_engine; +set default_storage_engine=InnoDB; +# Bug#36981 - "innodb crash when selecting for update" +# +CREATE TABLE t1 ( +c1 CHAR(1), +c2 CHAR(10), +KEY (c1) +); +INSERT INTO t1 VALUES ('3', null); +SELECT * FROM t1 WHERE c1='3' FOR UPDATE; +c1 c2 +3 NULL +DROP TABLE t1; +CREATE TABLE t1 (a INT) charset latin1; +INSERT INTO t1 VALUES (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +CREATE TABLE t2 (a INT) charset latin1; +INSERT INTO t2 SELECT A.a + 10*(B.a + 10*C.a) FROM t1 A, t1 B, t1 C; +CREATE TABLE t3 ( +c1 CHAR(10) NOT NULL, +c2 CHAR(10) NOT NULL, +c3 CHAR(200) NOT NULL, +KEY (c1) +); +INSERT INTO t3 +SELECT CONCAT('c-',1000+t2.a,'=w'), CONCAT('c-',1000+ t2.a,'=w'), 'filler' + FROM t2; +INSERT INTO t3 +SELECT CONCAT('c-',1000+t2.a,'=w'), CONCAT('c-',2000+t2.a,'=w'), 'filler-1' + FROM t2; +INSERT INTO t3 +SELECT CONCAT('c-',1000+t2.a,'=w'), CONCAT('c-',3000+t2.a,'=w'), 'filler-2' + FROM t2; +SELECT c1,c3 FROM t3 WHERE c1 >= 'c-1994=w' and c1 != 'c-1996=w' FOR UPDATE; +c1 c3 +c-1994=w filler +c-1994=w filler-1 +c-1994=w filler-2 +c-1995=w filler +c-1995=w filler-1 +c-1995=w filler-2 +c-1997=w filler +c-1997=w filler-1 +c-1997=w filler-2 +c-1998=w filler +c-1998=w filler-1 +c-1998=w filler-2 +c-1999=w filler +c-1999=w filler-1 +c-1999=w filler-2 +DROP TABLE t1,t2,t3; +# +# Bug#43360 - Server crash with a simple multi-table update +# +CREATE TABLE t1 ( +a CHAR(2) NOT NULL PRIMARY KEY, +b VARCHAR(20) NOT NULL, +KEY (b) +); +CREATE TABLE t2 ( +a CHAR(2) NOT NULL PRIMARY KEY, +b VARCHAR(30) NOT NULL, +KEY (b) +); +INSERT INTO t1 VALUES +('AB','MySQL AB'), +('JA','Sun Microsystems'), +('MS','Microsoft'), +('IB','IBM- Inc.'), +('GO','Google Inc.'); +INSERT INTO t2 VALUES +('AB','Sweden'), +('JA','USA'), +('MS','United States of America'), +('IB','North America'), +('GO','South America'); +UPDATE t1,t2 SET t1.b=UPPER(t1.b) WHERE t1.b LIKE 'United%'; +SELECT * FROM t1 ORDER BY a; +a b +AB MySQL AB +GO Google Inc. +IB IBM- Inc. +JA Sun Microsystems +MS Microsoft +SELECT * FROM t2 ORDER BY a; +a b +AB Sweden +GO South America +IB North America +JA USA +MS United States of America +DROP TABLE t1,t2; +# +# Bug#40992 - InnoDB: Crash when engine_condition_pushdown is on +# +CREATE TABLE t ( +dummy INT PRIMARY KEY, +a INT UNIQUE, +b INT +); +INSERT INTO t VALUES (1,1,1),(3,3,3),(5,5,5); +SELECT * FROM t WHERE a > 2 FOR UPDATE; +dummy a b +3 3 3 +5 5 5 +DROP TABLE t; +# +# Bug#35080 - Innodb crash at mem_block_get_len line 72 +# +CREATE TABLE t1 ( +t1_autoinc INT(11) NOT NULL AUTO_INCREMENT, +uuid VARCHAR(36) DEFAULT NULL, +PRIMARY KEY (t1_autoinc), +KEY k (uuid) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t2 ( +t2_autoinc INT(11) NOT NULL AUTO_INCREMENT, +uuid VARCHAR(36) DEFAULT NULL, +date DATETIME DEFAULT NULL, +PRIMARY KEY (t2_autoinc), +KEY k (uuid) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE VIEW v1 AS +SELECT t1_autoinc, uuid +FROM t1 +WHERE (ISNULL(uuid) OR (uuid like '%-%')); +CREATE VIEW v2 AS +SELECT t2_autoinc, uuid, date +FROM t2 +WHERE (ISNULL(uuid) OR (LENGTH(uuid) = 36)); +CREATE PROCEDURE delete_multi (IN uuid CHAR(36)) +DELETE v1, v2 FROM v1 INNER JOIN v2 +ON v1.uuid = v2.uuid +WHERE v1.uuid = @uuid; +SET @uuid = UUID(); +INSERT INTO v1 (uuid) VALUES (@uuid); +INSERT INTO v2 (uuid, date) VALUES (@uuid, '2009-09-09'); +CALL delete_multi(@uuid); +DROP procedure delete_multi; +DROP table t1,t2; +DROP view v1,v2; +# +# Bug#41996 - multi-table delete crashes server (InnoDB table) +# +CREATE TABLE t1 ( +b BIGINT, +i INT, +KEY (b) +); +INSERT INTO t1 VALUES (2, 2); +DELETE t1 FROM t1 a, t1 WHERE a.i=t1.b; +DROP TABLE t1; +# +# Bug#43448 - Server crashes on multi table delete with Innodb +# +CREATE TABLE t1 ( +id1 INT NOT NULL AUTO_INCREMENT PRIMARY KEY, +t CHAR(12) +); +CREATE TABLE t2 ( +id2 INT NOT NULL, +t CHAR(12) +); +CREATE TABLE t3( +id3 INT NOT NULL, +t CHAR(12), +INDEX(id3) +); +CREATE PROCEDURE insert_data () +BEGIN +DECLARE i1 INT DEFAULT 20; +DECLARE i2 INT; +DECLARE i3 INT; +WHILE (i1 > 0) DO +INSERT INTO t1(t) VALUES (i1); +SET i2 = 2; +WHILE (i2 > 0) DO +INSERT INTO t2(id2, t) VALUES (i1, i2); +SET i3 = 2; +WHILE (i3 > 0) DO +INSERT INTO t3(id3, t) VALUES (i1, i2); +SET i3 = i3 -1; +END WHILE; +SET i2 = i2 -1; +END WHILE; +SET i1 = i1 - 1; +END WHILE; +END | +CALL insert_data(); +SELECT COUNT(*) FROM t1 WHERE id1 > 10; +COUNT(*) +10 +SELECT COUNT(*) FROM t2 WHERE id2 > 10; +COUNT(*) +20 +SELECT COUNT(*) FROM t3 WHERE id3 > 10; +COUNT(*) +40 +DELETE t1, t2, t3 +FROM t1, t2, t3 +WHERE t1.id1 = t2.id2 AND t2.id2 = t3.id3 AND t1.id1 > 3; +SELECT COUNT(*) FROM t1; +COUNT(*) +3 +SELECT COUNT(*) FROM t2; +COUNT(*) +6 +SELECT COUNT(*) FROM t3; +COUNT(*) +12 +DROP PROCEDURE insert_data; +DROP TABLE t1, t2, t3; +# +# Bug#42580 - Innodb's ORDER BY ..LIMIT returns no rows for +# null-safe operator <=> NULL +# +SET sql_mode = 'NO_ENGINE_SUBSTITUTION'; +CREATE TABLE t1( +c1 DATE NOT NULL, +c2 DATE NULL, +c3 DATETIME, +c4 TIMESTAMP, +PRIMARY KEY(c1), +UNIQUE(c2) +); + +INSERT INTO t1 VALUES('0000-00-00', '0000-00-00', '2008-01-04', '2008-01-05'); +INSERT INTO t1 VALUES('2007-05-25', '2007-05-25', '2007-05-26', '2007-05-26'); +INSERT INTO t1 VALUES('2008-01-01', NULL , '2008-01-02', '2008-01-03'); +INSERT INTO t1 VALUES('2008-01-17', NULL , NULL , '2009-01-29'); +INSERT INTO t1 VALUES('2009-01-29', '2009-01-29', '2009-01-29', '2009-01-29'); + +SELECT * FROM t1 WHERE c2 <=> NULL ORDER BY c1,c2; +c1 c2 c3 c4 +2008-01-01 NULL 2008-01-02 00:00:00 2008-01-03 00:00:00 +2008-01-17 NULL NULL 2009-01-29 00:00:00 + +SELECT * FROM t1 WHERE c2 <=> NULL ORDER BY c1,c2 LIMIT 2; +c1 c2 c3 c4 +2008-01-01 NULL 2008-01-02 00:00:00 2008-01-03 00:00:00 +2008-01-17 NULL NULL 2009-01-29 00:00:00 + +DROP TABLE t1; +SET sql_mode = default; +# +# Bug#43617 - Innodb returns wrong results with timestamp's range value +# in IN clause +# (Note: Fixed by patch for BUG#42580) +# +SET sql_mode = 'NO_ENGINE_SUBSTITUTION'; +CREATE TABLE t1( +c1 TIMESTAMP NOT NULL, +c2 TIMESTAMP NULL, +c3 DATE, +c4 DATETIME, +PRIMARY KEY(c1), +UNIQUE INDEX(c2) +); +INSERT INTO t1 VALUES +('0000-00-00 00:00:00','0000-00-00 00:00:00','2008-01-04','2008-01-05 00:00:00'), +('1971-01-01 00:00:01','1980-01-01 00:00:01','2009-01-01','2009-01-02 00:00:00'), +('1999-01-01 00:00:00','1999-01-01 00:00:00', NULL, NULL), +('2007-05-23 09:15:28','2007-05-23 09:15:28','2007-05-24','2007-05-24 09:15:28'), +('2007-05-27 00:00:00','2007-05-25 00:00:00','2007-05-26','2007-05-26 00:00:00'), +('2008-01-01 00:00:00', NULL, '2008-01-02','2008-01-03 00:00:00'), +('2009-01-29 11:11:27','2009-01-29 11:11:27','2009-01-29','2009-01-29 11:11:27'), +('2038-01-09 03:14:07','2038-01-09 03:14:07','2009-01-05','2009-01-06 00:00:00'); + +SELECT * +FROM t1 +WHERE c2 IN ('1971-01-01 00:00:01','2038-01-09 03:14:07') +ORDER BY c2; +c1 c2 c3 c4 +2038-01-09 03:14:07 2038-01-09 03:14:07 2009-01-05 2009-01-06 00:00:00 + +SELECT * +FROM t1 +WHERE c2 IN ('1971-01-01 00:00:01','2038-01-09 03:14:07') +ORDER BY c2 LIMIT 2; +c1 c2 c3 c4 +2038-01-09 03:14:07 2038-01-09 03:14:07 2009-01-05 2009-01-06 00:00:00 + +SELECT * +FROM t1 +WHERE c2 IN ('1971-01-01 00:00:01','2038-01-09 03:14:07') +ORDER BY c2 DESC; +c1 c2 c3 c4 +2038-01-09 03:14:07 2038-01-09 03:14:07 2009-01-05 2009-01-06 00:00:00 + +SELECT * +FROM t1 +WHERE c2 IN ('1971-01-01 00:00:01','2038-01-09 03:14:07') +ORDER BY c2 DESC LIMIT 2; +c1 c2 c3 c4 +2038-01-09 03:14:07 2038-01-09 03:14:07 2009-01-05 2009-01-06 00:00:00 + +DROP TABLE t1; +SET sql_mode = default; +# +# Bug#43249 - Innodb returns zero time for the time column +# with <=> NULL order by limit +# (Note: Fixed by patch for BUG#42580) +# +CREATE TABLE t1( +c1 TIME NOT NULL, +c2 TIME NULL, +c3 DATE, +PRIMARY KEY(c1), +UNIQUE INDEX(c2) +); +INSERT INTO t1 VALUES('8:29:45',NULL,'2009-02-01'); + +SELECT * FROM t1 WHERE c2 <=> NULL ORDER BY c2 LIMIT 2; +c1 c2 c3 +08:29:45 NULL 2009-02-01 + +SELECT * FROM t1 WHERE c2 <=> NULL ORDER BY c2 LIMIT 2; +c1 c2 c3 +08:29:45 NULL 2009-02-01 +DROP TABLE t1; +# +# BUG#43618: MyISAM&Maria returns wrong results with 'between' +# on timestamp +# +CREATE TABLE t1( +ts TIMESTAMP NOT NULL, +c char NULL, +PRIMARY KEY(ts) +); +INSERT INTO t1 VALUES +('1971-01-01','a'), +('2007-05-25','b'), +('2008-01-01','c'), +('2038-01-09','d'); + +# Execute select with invalid timestamp, desc ordering +SET sql_mode = ''; +SELECT * +FROM t1 +WHERE ts BETWEEN '0000-00-00' AND '2010-00-01 00:00:00' +ORDER BY ts DESC +LIMIT 2; +ts c +2008-01-01 00:00:00 c +2007-05-25 00:00:00 b +SET sql_mode = default; + +# Should use index condition +EXPLAIN +SELECT * +FROM t1 +WHERE ts BETWEEN '0000-00-00' AND '2010-00-01 00:00:00' +ORDER BY ts DESC +LIMIT 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range PRIMARY PRIMARY 4 NULL 4 100.00 Using where; Backward index scan + +DROP TABLE t1; +# +# BUG#49906: Assertion failed - Field_varstring::val_str in field.cc +# +CREATE TABLE t1 ( +f1 VARCHAR(1024), +f2 VARCHAR(10), +INDEX test_idx USING BTREE (f2,f1(5)) +); +INSERT INTO t1 VALUES ('a','c'), ('b','d'); +SELECT f1 +FROM t1 +WHERE f2 LIKE 'd' +ORDER BY f1; +f1 +b +DROP TABLE t1; +# +# Bug#52660 - "Perf. regr. using ICP for MyISAM on range queries on +# an index containing TEXT" +# +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +CREATE TABLE t2 (a INT); +INSERT INTO t2 SELECT A.a + 10*(B.a) FROM t1 A, t1 B; +CREATE TABLE t3 ( +c1 TINYTEXT NOT NULL, +i1 INT NOT NULL, +KEY (c1(6),i1) +) charset utf8mb4; +INSERT INTO t3 SELECT CONCAT('c-',1000+t2.a,'=w'), 1 FROM t2; +EXPLAIN SELECT c1 FROM t3 WHERE c1 >= 'c-1004=w' and c1 <= 'c-1006=w' and i1 > 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL range c1 c1 30 NULL 2 33.33 Using index condition; Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`c1` AS `c1` from `test`.`t3` where ((`test`.`t3`.`c1` >= 'c-1004=w') and (`test`.`t3`.`c1` <= 'c-1006=w') and (`test`.`t3`.`i1` > 2)) +EXPLAIN FORMAT=tree SELECT c1 FROM t3 WHERE c1 >= 'c-1004=w' and c1 <= 'c-1006=w' and i1 > 2; +EXPLAIN +-> Filter: ((t3.c1 >= 'c-1004=w') and (t3.c1 <= 'c-1006=w')) (cost=1.16 rows=1) + -> Index range scan on t3 using c1, with index condition: (t3.i1 > 2) (cost=1.16 rows=2) + +SELECT c1 FROM t3 WHERE c1 >= 'c-1004=w' and c1 <= 'c-1006=w' and i1 > 2; +c1 +DROP TABLE t1, t2, t3; +# +# Bug#57372 "Multi-table updates and deletes fail when running with ICP +# against InnoDB" +# +CREATE TABLE t1 ( +a INT KEY, +b INT +) ENGINE = INNODB; +CREATE TABLE t2 ( +a INT KEY, +b INT +) ENGINE = INNODB; +INSERT INTO t1 VALUES (1, 101), (2, 102), (3, 103), (4, 104), (5, 105); +INSERT INTO t2 VALUES (1, 1), (2, 2), (3, 3), (4, 4), (5, 5); +UPDATE t1, t2 +SET t1.a = t1.a + 100, t2.b = t1.a + 10 +WHERE t1.a BETWEEN 2 AND 4 AND t2.a = t1.b - 100; +SELECT * FROM t1; +a b +1 101 +102 102 +103 103 +104 104 +5 105 +SELECT * FROM t2; +a b +1 1 +2 12 +3 13 +4 14 +5 5 +DROP TABLE t1, t2; +# +# Bug#52605 - "Adding LIMIT 1 clause to query with complex range +# predicate causes wrong results" +# +CREATE TABLE t1 ( +pk INT NOT NULL, +c1 INT, +PRIMARY KEY (pk), +KEY k1 (c1) +); +INSERT INTO t1 VALUES (1,NULL); +INSERT INTO t1 VALUES (2,6); +INSERT INTO t1 VALUES (3,NULL); +INSERT INTO t1 VALUES (4,6); +INSERT INTO t1 VALUES (5,NULL); +INSERT INTO t1 VALUES (6,NULL); +INSERT INTO t1 VALUES (7,9); +INSERT INTO t1 VALUES (8,0); +SELECT pk, c1 +FROM t1 +WHERE (pk BETWEEN 4 AND 5 OR pk < 2) AND c1 < 240 +ORDER BY c1 +LIMIT 1; +pk c1 +4 6 +EXPLAIN SELECT pk, c1 +FROM t1 +WHERE (pk BETWEEN 4 AND 5 OR pk < 2) AND c1 < 240 +ORDER BY c1 +LIMIT 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 37.50 Parallel execute (1 workers) +2 SIMPLE t1 NULL range PRIMARY,k1 k1 5 NULL 4 37.50 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`c1` AS `c1` from `test`.`t1` where (((`test`.`t1`.`pk` between 4 and 5) or (`test`.`t1`.`pk` < 2)) and (`test`.`t1`.`c1` < 240)) order by `test`.`t1`.`c1` limit 1 +DROP TABLE t1; +# +# Bug#42991 "invalid memory access and/or crash when using +# index condition pushdown + InnoDB" +# +CREATE TABLE t1 ( +c1 TINYTEXT NOT NULL, +c2 INT NOT NULL, +PRIMARY KEY (c2), +KEY id1 (c1(4)) +) charset utf8mb4; +INSERT INTO t1 VALUES ('Anastasia', 5); +INSERT INTO t1 VALUES ('Karianne', 4); +SELECT * FROM t1 WHERE (c1 <= '6566-06-15' AND c2 <> 3); +c1 c2 +EXPLAIN SELECT * FROM t1 WHERE (c1 <= '6566-06-15' AND c2 <> 3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range PRIMARY,id1 id1 18 NULL 1 100.00 Using index condition; Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c1` AS `c1`,`test`.`t1`.`c2` AS `c2` from `test`.`t1` where ((`test`.`t1`.`c1` <= '6566-06-15') and (`test`.`t1`.`c2` <> 3)) +DROP TABLE t1; +# +# Bug#56529 - "Crash due to long semaphore wait in InnoDB +# with ICP and subqueries" +# +CREATE TABLE t1 ( +col_int_nokey INTEGER, +col_int_key INTEGER, +col_varchar_key VARCHAR(1), +KEY (col_int_key), +KEY (col_varchar_key, col_int_key) +) charset utf8mb4 stats_persistent=0; +INSERT INTO t1 VALUES (NULL,2,'w'); +INSERT INTO t1 VALUES (7,9,'m'); +INSERT INTO t1 VALUES (9,3,'m'); +INSERT INTO t1 VALUES (7,9,'k'); +INSERT INTO t1 VALUES (4,NULL,'r'); +INSERT INTO t1 VALUES (2,9,'t'); +INSERT INTO t1 VALUES (6,3,'j'); +INSERT INTO t1 VALUES (8,8,'u'); +INSERT INTO t1 VALUES (NULL,8,'h'); +INSERT INTO t1 VALUES (5,53,'o'); +INSERT INTO t1 VALUES (NULL,0,NULL); +INSERT INTO t1 VALUES (6,5,'k'); +INSERT INTO t1 VALUES (188,166,'e'); +INSERT INTO t1 VALUES (2,3,'n'); +INSERT INTO t1 VALUES (1,0,'t'); +INSERT INTO t1 VALUES (1,1,'c'); +INSERT INTO t1 VALUES (0,9,'m'); +INSERT INTO t1 VALUES (9,5,'y'); +INSERT INTO t1 VALUES (NULL,6,'f'); +CREATE TABLE t2 ( +c1 INTEGER NOT NULL +) stats_persistent=0; +EXPLAIN SELECT table1.col_int_nokey +FROM t1 AS table1 STRAIGHT_JOIN ( +t1 AS table2 INNER JOIN t1 AS table3 +ON table3.col_varchar_key = table2.col_varchar_key) +ON table3.col_int_nokey = table1.col_int_key +WHERE table3.col_int_key != SOME ( SELECT c1 FROM t2 ); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY table1 NULL ALL col_int_key NULL NULL NULL 19 100.00 NULL +1 PRIMARY table3 NULL ALL col_varchar_key NULL NULL NULL 19 10.00 Using where; Using join buffer (hash join) +1 PRIMARY table2 NULL ref col_varchar_key col_varchar_key 7 test.table3.col_varchar_key 1 100.00 Using index +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`table1`.`col_int_nokey` AS `col_int_nokey` from `test`.`t1` `table1` join `test`.`t1` `table2` join `test`.`t1` `table3` where ((`test`.`table2`.`col_varchar_key` = `test`.`table3`.`col_varchar_key`) and (`test`.`table3`.`col_int_nokey` = `test`.`table1`.`col_int_key`) and ((`test`.`table3`.`col_int_key`,(/* select#2 */ select `test`.`t2`.`c1` from `test`.`t2` where (outer_field_is_not_null, ((`test`.`table3`.`col_int_key`) <> `test`.`t2`.`c1`), true))))) +SELECT table1.col_int_nokey +FROM t1 AS table1 STRAIGHT_JOIN ( +t1 AS table2 INNER JOIN t1 AS table3 +ON table3.col_varchar_key = table2.col_varchar_key) +ON table3.col_int_nokey = table1.col_int_key +WHERE table3.col_int_key != SOME ( SELECT c1 FROM t2 ); +col_int_nokey +DROP TABLE t1, t2; +# +# Bug#58243 "RQG test optimizer_subquery causes server crash +# when running with ICP" +# +CREATE TABLE t1 ( +pk INTEGER NOT NULL, +c1 INTEGER NOT NULL, +c2 INTEGER NOT NULL, +PRIMARY KEY (pk) +); +INSERT INTO t1 VALUES (1,6,7); +CREATE TABLE t2 ( +c1 INTEGER NOT NULL +); +EXPLAIN SELECT t1.c1 +FROM t1 +WHERE t1.pk < 317 AND 2 IN (SELECT COUNT(t2.c1) +FROM t2) +ORDER BY t1.c2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +2 SUBQUERY t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c1` AS `c1` from `test`.`t1` where false order by `test`.`t1`.`c2` +SELECT t1.c1 +FROM t1 +WHERE t1.pk < 317 AND 2 IN (SELECT COUNT(t2.c1) +FROM t2) +ORDER BY t1.c2; +c1 +DROP TABLE t1, t2; +CREATE TABLE t1 ( +i1 INTEGER NOT NULL, +c1 VARCHAR(1) NOT NULL +) charset latin1; +INSERT INTO t1 VALUES (2,'w'); +CREATE TABLE t2 ( +i1 INTEGER NOT NULL, +c1 VARCHAR(1) NOT NULL, +c2 VARCHAR(1) NOT NULL, +KEY (c1, i1) +) charset latin1; +INSERT INTO t2 VALUES (8,'d','d'); +INSERT INTO t2 VALUES (4,'v','v'); +CREATE TABLE t3 ( +c1 VARCHAR(1) NOT NULL +) charset latin1; +INSERT INTO t3 VALUES ('v'); +EXPLAIN SELECT i1 +FROM t1 +WHERE EXISTS (SELECT t2.c1 +FROM (t2 INNER JOIN t3 ON (t3.c1 = t2.c1)) +WHERE t2.c2 != t1.c1 AND t2.c2 = (SELECT MIN(t3.c1) +FROM t3)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 DEPENDENT SUBQUERY t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 DEPENDENT SUBQUERY t2 NULL ref c1 c1 3 test.t3.c1 1 50.00 Using where +3 SUBQUERY t3 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1276 Field or reference 'test.t1.c1' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i1` AS `i1` from `test`.`t1` where exists(/* select#2 */ select `test`.`t2`.`c1` from `test`.`t2` join `test`.`t3` where ((`test`.`t2`.`c1` = `test`.`t3`.`c1`) and (`test`.`t2`.`c2` = (/* select#3 */ select min(`test`.`t3`.`c1`) from `test`.`t3`)) and ((/* select#3 */ select min(`test`.`t3`.`c1`) from `test`.`t3`) <> `test`.`t1`.`c1`))) +SELECT i1 +FROM t1 +WHERE EXISTS (SELECT t2.c1 +FROM (t2 INNER JOIN t3 ON (t3.c1 = t2.c1)) +WHERE t2.c2 != t1.c1 AND t2.c2 = (SELECT MIN(t3.c1) +FROM t3)); +i1 +2 +DROP TABLE t1,t2,t3; +# +# Bug#58015 "Assert in row_sel_field_store_in_mysql_format +# when running innodb_mrr_icp test" +# +create table t1 (a char(2) charset utf8,b double, primary key (a(1)),key (b)); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +insert into t1 values ('',1); +select 1 from t1 where b <= 1 and a <> ''; +1 +drop table t1; +# +# Bug#59259 "Incorrect rows returned for a correlated subquery +# when ICP is on" +# +CREATE TABLE t1 (pk INTEGER PRIMARY KEY, i INTEGER NOT NULL) ENGINE=InnoDB; +INSERT INTO t1 VALUES (11,0); +INSERT INTO t1 VALUES (12,5); +INSERT INTO t1 VALUES (15,0); +CREATE TABLE t2 (pk INTEGER PRIMARY KEY, i INTEGER NOT NULL) ENGINE=InnoDB; +INSERT INTO t2 VALUES (11,1); +INSERT INTO t2 VALUES (12,2); +INSERT INTO t2 VALUES (15,4); +SELECT * FROM t1 +WHERE pk IN (SELECT it.pk FROM t2 JOIN t2 AS it ON it.i=it.i WHERE t1.i); +pk i +12 5 +DROP TABLE t1, t2; +# +# Bug #58816 "Extra temporary duplicate rows in result set when +# switching ICP off" +# +set @save_optimizer_switch_bug58816= @@optimizer_switch; +CREATE TABLE t1 ( +pk INT NOT NULL, +c1 INT NOT NULL, +PRIMARY KEY (pk) +); +INSERT INTO t1 VALUES (1,9),(2,7),(3,6),(4,3),(5,1); +EXPLAIN SELECT pk, c1 FROM t1 WHERE pk <> 3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (2 workers) +2 SIMPLE t1 NULL range PRIMARY PRIMARY 4 NULL 4 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`c1` AS `c1` from `test`.`t1` where (`test`.`t1`.`pk` <> 3) +SET SESSION optimizer_switch='index_condition_pushdown=off'; +SELECT pk, c1 FROM t1 WHERE pk <> 3; +pk c1 +1 9 +2 7 +4 3 +5 1 +DROP TABLE t1; +set optimizer_switch= @save_optimizer_switch_bug58816; +# +# Bug#58837: ICP crash or valgrind error due to uninitialized +# value in innobase_index_cond +# +CREATE TABLE t1 ( +t1_int INT, +t1_time TIME +); +CREATE TABLE t2 ( +t2_int int PRIMARY KEY, +t2_int2 INT +); +INSERT IGNORE INTO t2 VALUES (); +INSERT INTO t1 VALUES (); + +SELECT * +FROM t1 AS t1a +WHERE NOT EXISTS +(SELECT * +FROM t1 AS t1b +WHERE t1b.t1_int NOT IN +(SELECT t2.t2_int +FROM t2 +WHERE t1b.t1_time LIKE t1b.t1_int +OR t1b.t1_time <> t2.t2_int2 +AND 6=7 +) +) +;; +t1_int t1_time + +EXPLAIN SELECT * +FROM t1 AS t1a +WHERE NOT EXISTS +(SELECT * +FROM t1 AS t1b +WHERE t1b.t1_int NOT IN +(SELECT t2.t2_int +FROM t2 +WHERE t1b.t1_time LIKE t1b.t1_int +OR t1b.t1_time <> t2.t2_int2 +AND 6=7 +) +) +;; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +2 SUBQUERY t1b NULL ALL NULL NULL NULL NULL 1 100.00 Using where +3 DEPENDENT SUBQUERY t2 NULL unique_subquery PRIMARY PRIMARY 4 func 1 100.00 Using where; Full scan on NULL key +Warnings: +Note 1276 Field or reference 'test.t1b.t1_time' of SELECT #3 was resolved in SELECT #2 +Note 1276 Field or reference 'test.t1b.t1_int' of SELECT #3 was resolved in SELECT #2 +Note 1276 Field or reference 'test.t1b.t1_time' of SELECT #3 was resolved in SELECT #2 +Note 1003 /* select#1 */ select `test`.`t1a`.`t1_int` AS `t1_int`,`test`.`t1a`.`t1_time` AS `t1_time` from `test`.`t1` `t1a` where false + +DROP TABLE t1,t2; +# +# Bug#59186 Wrong results of join when ICP is enabled +# +CREATE TABLE t1 ( +pk INTEGER NOT NULL, +c1 VARCHAR(3) NOT NULL, +PRIMARY KEY (pk) +); +INSERT INTO t1 VALUES (1,'y'),(0,'or'); +CREATE TABLE t2 ( +pk INTEGER NOT NULL, +c1 VARCHAR(3) NOT NULL, +c2 VARCHAR(6) NOT NULL, +PRIMARY KEY (pk) +); +INSERT INTO t2 VALUES (6,'y','RPOYT'),(10,'m','JINQE'); +EXPLAIN SELECT c2 FROM t1 JOIN t2 ON t1.c1 = t2.c1 +WHERE (t2.pk <= 4 AND t1.pk IN (2,1)) OR +(t1.pk > 1 AND t2.pk BETWEEN 6 AND 6); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range PRIMARY PRIMARY 4 NULL 1 100.00 Using where +2 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`c2` AS `c2` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`c1` = `test`.`t1`.`c1`) and (((`test`.`t2`.`pk` <= 4) and (`test`.`t1`.`pk` in (2,1))) or ((`test`.`t1`.`pk` > 1) and (`test`.`t2`.`pk` between 6 and 6)))) +SELECT c2 FROM t1 JOIN t2 ON t1.c1 = t2.c1 +WHERE (t2.pk <= 4 AND t1.pk IN (2,1)) OR +(t1.pk > 1 AND t2.pk BETWEEN 6 AND 6); +c2 +DROP TABLE t1, t2; +# +# Bug#58838 "Wrong results with HAVING + LIMIT without GROUP BY when +# ICP is enabled" +# +CREATE TABLE t1 ( +pk INT NOT NULL, +c1 INT, +PRIMARY KEY (pk), +KEY col_int_key (c1) +); +INSERT INTO t1 VALUES (1,37),(2,8),(3,-25),(4,NULL),(5,55); +SELECT pk FROM t1 WHERE c1 <> 1 HAVING pk = 3 ORDER BY pk LIMIT 0; +pk +SELECT pk FROM t1 WHERE c1 <> 1 HAVING pk = 3 ORDER BY pk LIMIT 1; +pk +3 +SELECT pk FROM t1 WHERE c1 <> 1 HAVING pk = 3 ORDER BY pk LIMIT 2; +pk +3 +SELECT pk FROM t1 WHERE c1 <> 1 HAVING pk = 3 ORDER BY pk LIMIT 5; +pk +3 +DROP TABLE t1; +# +# Bug#59483 "Crash on INSERT/REPLACE in +# rec_convert_dtuple_to_rec_comp with ICP on" +# +CREATE TABLE t1 ( +pk INTEGER AUTO_INCREMENT PRIMARY KEY, +i1 INTEGER, +c1 CHAR(6), +i2 INTEGER NOT NULL, +KEY (i2) +); +INSERT INTO t1 VALUES +(NULL, 4, 'that', 8), +(NULL, 1, 'she', 6), +(NULL, 6, 'tell', 2); +SELECT * FROM t1 WHERE i2 IN (3, 6) LIMIT 2 FOR UPDATE; +pk i1 c1 i2 +2 1 she 6 +INSERT INTO t1 (i2) VALUES (1); +DROP TABLE t1; +# +# Bug #11766678 - 59843: +# USING UNINITIALISED VALUE IN USES_INDEX_FIELDS_ONLY +# +CREATE TABLE t1 ( +col999 FLOAT NOT NULL, +COL1000 VARBINARY(179) NOT NULL, +col1003 DATE DEFAULT NULL, +KEY idx4267 (col1000, col1003) +); +INSERT IGNORE INTO t1 VALUES (),(); +Warnings: +Warning 1364 Field 'col999' doesn't have a default value +Warning 1364 Field 'COL1000' doesn't have a default value +SELECT col999 FROM t1 WHERE col1000 = "3" AND col1003 <=> sysdate(); +col999 +DROP TABLE t1; +# +# Bug#11873324 "WRONG RESULT WITH ICP AND STRAIGHT_JOIN" +# +CREATE TABLE t1 ( +pk INTEGER NOT NULL, +i1 INTEGER, +PRIMARY KEY (pk), +KEY col_int_key (i1) +); +INSERT INTO t1 VALUES (14,NULL), (18,133); +CREATE TABLE t2 ( +pk INTEGER NOT NULL, +i1 INTEGER, +c1 VARCHAR(1), +PRIMARY KEY (pk), +KEY col_int_key (i1) +); +INSERT INTO t2 VALUES (1,7,'f'); +set @old_opt_switch=@@optimizer_switch; +EXPLAIN SELECT t1.i1 +FROM t1 +WHERE t1.i1 NOT IN +( SELECT STRAIGHT_JOIN subquery_t1.pk +FROM t1 AS subquery_t1 +JOIN t2 AS subquery_t2 +ON subquery_t2.i1 = subquery_t1.pk +WHERE subquery_t1.i1 > 0 +OR subquery_t2.c1 = 'a' +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL index NULL col_int_key 5 NULL 2 100.00 Using where; Using index +2 DEPENDENT SUBQUERY subquery_t1 NULL eq_ref PRIMARY,col_int_key PRIMARY 4 func 1 100.00 Using where; Full scan on NULL key +2 DEPENDENT SUBQUERY subquery_t2 NULL ref col_int_key col_int_key 5 func 1 100.00 Using where; Full scan on NULL key +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i1` AS `i1` from `test`.`t1` where (`test`.`t1`.`i1`,(/* select#2 */ select straight_join `test`.`subquery_t1`.`pk` from `test`.`t1` `subquery_t1` join `test`.`t2` `subquery_t2` where ((`test`.`subquery_t2`.`i1` = `test`.`subquery_t1`.`pk`) and ((`test`.`subquery_t1`.`i1` > 0) or (`test`.`subquery_t2`.`c1` = 'a')) and (outer_field_is_not_null, ((`test`.`t1`.`i1`) = `test`.`subquery_t1`.`pk`), true))) is false) +SELECT t1.i1 +FROM t1 +WHERE t1.i1 NOT IN +( SELECT STRAIGHT_JOIN subquery_t1.pk +FROM t1 AS subquery_t1 +JOIN t2 AS subquery_t2 +ON subquery_t2.i1 = subquery_t1.pk +WHERE subquery_t1.i1 > 0 +OR subquery_t2.c1 = 'a' +); +i1 +NULL +133 +set @@optimizer_switch=@old_opt_switch; +DROP TABLE t1,t2; +# +# Bug#11876420 "MISSING ROW IN RESULT WITH SUBQUERY + IN + XOR + +# NULL VALUES AND ICP ENABLED" +# +CREATE TABLE t1 ( +i1 INTEGER, +c1 VARCHAR(1), +KEY col_varchar_key (c1) +) charset utf8mb4; +INSERT INTO t1 VALUES (1,'j'), (0,'e'), (210,'f'), (8,'v'), (7,'x'), +(5,'m'), (NULL,'c'); +CREATE TABLE t2 ( +i1 INTEGER, +c1 VARCHAR(1), +KEY col_varchar_key (c1) +) charset utf8mb4; +INSERT INTO t2 VALUES (8,NULL); +CREATE TABLE t3 ( +i1 INTEGER, +c1 VARCHAR(1), +KEY col_varchar_key (c1) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t3 VALUES (NULL,'w'), (1,NULL), (2,'d'); +set @old_opt_switch=@@optimizer_switch; +EXPLAIN SELECT i1 +FROM t3 +WHERE c1 IN +( SELECT t1.c1 +FROM t2 JOIN t1 +ON t2.i1 >= t1.i1 +WHERE t1.c1 > t2.c1 +) +XOR i1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t3 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t2 NULL ALL col_varchar_key NULL NULL NULL 1 100.00 NULL +2 DEPENDENT SUBQUERY t1 NULL ref_or_null col_varchar_key col_varchar_key 7 func 2 33.33 Using where; Full scan on NULL key +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`i1` AS `i1` from `test`.`t3` where ((`test`.`t3`.`c1`,(/* select#2 */ select `test`.`t1`.`c1` from `test`.`t2` join `test`.`t1` where ((`test`.`t1`.`c1` > `test`.`t2`.`c1`) and (outer_field_is_not_null, (((`test`.`t3`.`c1`) = `test`.`t1`.`c1`) or (`test`.`t1`.`c1` is null)), true) and (`test`.`t2`.`i1` >= `test`.`t1`.`i1`)) having (outer_field_is_not_null, (`test`.`t1`.`c1`), true))) xor (0 <> `test`.`t3`.`i1`)) +SELECT i1 +FROM t3 +WHERE c1 IN +( SELECT t1.c1 +FROM t2 JOIN t1 +ON t2.i1 >= t1.i1 +WHERE t1.c1 > t2.c1 +) +XOR i1; +i1 +1 +2 +set @@optimizer_switch=@old_opt_switch; +DROP TABLE t1, t2, t3; +# +# Bug#12355958 "FAILING ASSERTION: TRX->LOCK.N_ACTIVE_THRS == 1" +# +CREATE TABLE t1 ( +pk INTEGER PRIMARY KEY, +a INTEGER NOT NULL, +b CHAR(1), +KEY(b) +) charset utf8mb4; +INSERT INTO t1 VALUES (23,5,'d'); +EXPLAIN SELECT a1.pk +FROM t1 AS a1 JOIN (SELECT * FROM t1 LIMIT 1) AS a2 ON a2.b = a1.b +WHERE a1.a = (SELECT pk FROM t1 LIMIT 1) +AND (a1.a != a2.a OR a1.b IS NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL system NULL NULL NULL NULL 1 100.00 NULL +1 PRIMARY a1 NULL ref b b 5 const 1 100.00 Using where +3 SUBQUERY t1 NULL index NULL b 5 NULL 1 100.00 Using index +2 DERIVED t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`a1`.`pk` AS `pk` from `test`.`t1` `a1` where ((`test`.`a1`.`b` = 'd') and (`test`.`a1`.`a` = (/* select#3 */ select `test`.`t1`.`pk` from `test`.`t1` limit 1)) and (((/* select#3 */ select `test`.`t1`.`pk` from `test`.`t1` limit 1) <> '5') or (`test`.`a1`.`b` is null))) +SELECT a1.pk +FROM t1 AS a1 JOIN (SELECT * FROM t1 LIMIT 1) AS a2 ON a2.b = a1.b +WHERE a1.a = (SELECT pk FROM t1 LIMIT 1) +AND (a1.a != a2.a OR a1.b IS NULL); +pk +CREATE VIEW v1 AS SELECT * FROM t1; +EXPLAIN SELECT a1.pk +FROM v1 AS a1 JOIN (SELECT * FROM v1 LIMIT 1) AS a2 ON a2.b = a1.b +WHERE a1.a = (SELECT pk FROM v1 LIMIT 1) +AND (a1.a != a2.a OR a1.b IS NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL system NULL NULL NULL NULL 1 100.00 NULL +1 PRIMARY t1 NULL ref b b 5 const 1 100.00 Using where +3 SUBQUERY t1 NULL index NULL b 5 NULL 1 100.00 Using index +2 DERIVED t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` where ((`test`.`t1`.`b` = 'd') and (`test`.`t1`.`a` = (/* select#3 */ select `test`.`t1`.`pk` from `test`.`t1` limit 1)) and ((`test`.`t1`.`a` <> '5') or (`test`.`t1`.`b` is null))) +SELECT a1.pk +FROM v1 AS a1 JOIN (SELECT * FROM v1 LIMIT 1) AS a2 ON a2.b = a1.b +WHERE a1.a = (SELECT pk FROM v1 LIMIT 1) +AND (a1.a != a2.a OR a1.b IS NULL); +pk +DROP VIEW v1; +DROP TABLE t1; +# +# BUG#12601961 "SEGFAULT IN HANDLER::COMPARE_KEY2" +# BUG#12724899 "SELECT STRAIGHT_JOIN QUERY GIVES 2 DATES VERSUS +# 2 WARNINGS WITH ICP ON" +# +CREATE TABLE t1 ( +pk INTEGER NOT NULL, +i1 INTEGER NOT NULL, +c1 VARCHAR(1) NOT NULL, +PRIMARY KEY (pk) +); +INSERT INTO t1 VALUES (1,3,'j'), (20,8,'e'); +EXPLAIN SELECT alias2.i1 +FROM t1 AS alias1 STRAIGHT_JOIN t1 AS alias2 +ON alias2.pk AND alias2.pk <= alias1.c1 +WHERE alias2.pk = 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE alias1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 SIMPLE alias2 NULL const PRIMARY PRIMARY 4 const 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`alias2`.`i1` AS `i1` from `test`.`t1` `alias1` straight_join `test`.`t1` `alias2` where ((`test`.`alias2`.`pk` = 1) and (cast(`test`.`alias2`.`pk` as double) <= cast(`test`.`alias1`.`c1` as double))) +SELECT alias2.i1 +FROM t1 AS alias1 STRAIGHT_JOIN t1 AS alias2 +ON alias2.pk AND alias2.pk <= alias1.c1 +WHERE alias2.pk = 1; +i1 +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'j' +Warning 1292 Truncated incorrect DOUBLE value: 'e' +DROP TABLE t1; +# +# BUG#12822678 - 2 MORE ROWS WHEN ICP=ON W/ STRAIGHT_JOIN +# +CREATE TABLE t1 ( +i1 INTEGER NOT NULL, +d1 DOUBLE, +KEY k1 (d1) +); +INSERT INTO t1 VALUES (10,1), (17,NULL), (22,NULL); +CREATE TABLE t2 ( +pk INTEGER NOT NULL, +i1 INTEGER NOT NULL, +PRIMARY KEY (pk) +); +INSERT INTO t2 VALUES (4,1); +EXPLAIN SELECT t1.d1, t2.pk, t2.i1 +FROM t1 STRAIGHT_JOIN t2 ON t2.i1 +WHERE t2.pk <> t1.d1 AND t2.pk = 4; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL k1 9 NULL 3 100.00 Using index +2 SIMPLE t2 NULL const PRIMARY PRIMARY 4 const 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`d1` AS `d1`,`test`.`t2`.`pk` AS `pk`,`test`.`t2`.`i1` AS `i1` from `test`.`t1` straight_join `test`.`t2` where ((`test`.`t2`.`pk` = 4) and (`test`.`t2`.`pk` <> `test`.`t1`.`d1`) and (0 <> `test`.`t2`.`i1`)) +SELECT t1.d1, t2.pk, t2.i1 +FROM t1 STRAIGHT_JOIN t2 ON t2.i1 +WHERE t2.pk <> t1.d1 AND t2.pk = 4; +d1 pk i1 +1 4 1 +DROP TABLE t1, t2; +# +# BUG#12838420 "DUPLICATE VALUES FOR GROUP-BY COLUMN WHEN JOIN +# BUFFERING IS OFF" +# +CREATE TABLE t1 ( +col_int_key INT, +pk INT, +PRIMARY KEY (pk), +KEY (col_int_key) +); +INSERT INTO t1 VALUES (2,3),(3,2),(3,5),(4,6); +CREATE TABLE t2 ( +col_int_key INT, +pk INT, +PRIMARY KEY (pk), +KEY (col_int_key) +); +INSERT INTO t2 VALUES (0,9),(3,10),(4,6),(6,1),(100,3),(200,5); +set @old_opt_switch=@@optimizer_switch; +SET optimizer_switch="block_nested_loop=off"; +EXPLAIN SELECT t2.col_int_key AS field1 +FROM t2 USE INDEX(col_int_key) STRAIGHT_JOIN t1 ON t2.col_int_key +WHERE t2.pk < 7 AND t2.col_int_key <> 7 +GROUP BY field1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 6 33.33 Parallel execute (1 workers) +2 SIMPLE t2 NULL index col_int_key col_int_key 5 NULL 6 33.33 Using where; Using index +2 SIMPLE t1 NULL index NULL col_int_key 5 NULL 4 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`col_int_key` AS `field1` from `test`.`t2` USE INDEX (`col_int_key`) straight_join `test`.`t1` where ((`test`.`t2`.`pk` < 7) and (`test`.`t2`.`col_int_key` <> 7) and (0 <> `test`.`t2`.`col_int_key`)) group by `field1` +SELECT t2.col_int_key AS field1 +FROM t2 USE INDEX(col_int_key) STRAIGHT_JOIN t1 ON t2.col_int_key +WHERE t2.pk < 7 AND t2.col_int_key <> 7 +GROUP BY field1; +field1 +4 +6 +100 +200 +SET @@optimizer_switch=@old_opt_switch; +DROP TABLE t1,t2; +# +# Bug#12976163 "CRASH IN INDEX CONDITION PUSHDOWN CODE AGAINST +# A MYISAM TABLE" +# +CREATE TABLE t1 ( +i1 INTEGER NOT NULL, +i2 INTEGER NOT NULL +); +INSERT INTO t1 VALUES (14,1), (15,2), (16,3); +CREATE TABLE t2 ( +i1 INTEGER NOT NULL, +i2 INTEGER NOT NULL, +c1 TINYTEXT +); +INSERT INTO t2 +SELECT i1, 10 * i2, "MySQL" FROM t1; +CREATE PROCEDURE proc1(id INTEGER) +BEGIN +SELECT i2 +FROM ( +(SELECT i1, i2, NULL AS a1 FROM t1) +UNION +(SELECT i1, i2, c1 AS a1 FROM t2) +) u1 +WHERE i1 = id; +END$$ +CALL proc1(15); +i2 +2 +20 +DROP PROCEDURE proc1; +DROP TABLE t1, t2; +# +# Bug#13655397 "CRASH IN SYNC_THREAD_LEVELS_NONEMPTY_TRX" +# +CREATE TABLE t1 ( +i1 INTEGER NOT NULL, +i2 INTEGER NOT NULL, +KEY (i1) +); +INSERT INTO t1 VALUES (4,4), (5,5); +CREATE TABLE t2 ( +pk INTEGER NOT NULL, +PRIMARY KEY (pk) +); +INSERT INTO t2 VALUES (1); +CREATE FUNCTION f1() RETURNS INTEGER +RETURN (SELECT MOD(COUNT(DISTINCT pk), 10) FROM t2); +EXPLAIN SELECT i1, i2 FROM t1 WHERE f1() = 1 AND i1 = 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ref i1 i1 4 const 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i1` AS `i1`,`test`.`t1`.`i2` AS `i2` from `test`.`t1` where ((`test`.`t1`.`i1` = 5) and (`f1`() = 1)) +SELECT i1, i2 FROM t1 WHERE f1() = 1 AND i1 = 5; +i1 i2 +5 5 +DROP FUNCTION f1; +DROP TABLE t1, t2; +set default_storage_engine= @save_storage_engine; +set optimizer_switch=default; diff --git a/mysql-test/r/innodb_icp_all.result-pq b/mysql-test/r/innodb_icp_all.result-pq new file mode 100644 index 000000000000..491744a3268b --- /dev/null +++ b/mysql-test/r/innodb_icp_all.result-pq @@ -0,0 +1,1130 @@ +set optimizer_switch='semijoin=on,materialization=on,firstmatch=on,loosescan=on,index_condition_pushdown=on,mrr=on'; +set @save_storage_engine= @@default_storage_engine; +set default_storage_engine=InnoDB; +# Bug#36981 - "innodb crash when selecting for update" +# +CREATE TABLE t1 ( +c1 CHAR(1), +c2 CHAR(10), +KEY (c1) +); +INSERT INTO t1 VALUES ('3', null); +SELECT * FROM t1 WHERE c1='3' FOR UPDATE; +c1 c2 +3 NULL +DROP TABLE t1; +CREATE TABLE t1 (a INT) charset latin1; +INSERT INTO t1 VALUES (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +CREATE TABLE t2 (a INT) charset latin1; +INSERT INTO t2 SELECT A.a + 10*(B.a + 10*C.a) FROM t1 A, t1 B, t1 C; +CREATE TABLE t3 ( +c1 CHAR(10) NOT NULL, +c2 CHAR(10) NOT NULL, +c3 CHAR(200) NOT NULL, +KEY (c1) +); +INSERT INTO t3 +SELECT CONCAT('c-',1000+t2.a,'=w'), CONCAT('c-',1000+ t2.a,'=w'), 'filler' + FROM t2; +INSERT INTO t3 +SELECT CONCAT('c-',1000+t2.a,'=w'), CONCAT('c-',2000+t2.a,'=w'), 'filler-1' + FROM t2; +INSERT INTO t3 +SELECT CONCAT('c-',1000+t2.a,'=w'), CONCAT('c-',3000+t2.a,'=w'), 'filler-2' + FROM t2; +SELECT c1,c3 FROM t3 WHERE c1 >= 'c-1994=w' and c1 != 'c-1996=w' FOR UPDATE; +c1 c3 +c-1994=w filler +c-1994=w filler-1 +c-1994=w filler-2 +c-1995=w filler +c-1995=w filler-1 +c-1995=w filler-2 +c-1997=w filler +c-1997=w filler-1 +c-1997=w filler-2 +c-1998=w filler +c-1998=w filler-1 +c-1998=w filler-2 +c-1999=w filler +c-1999=w filler-1 +c-1999=w filler-2 +DROP TABLE t1,t2,t3; +# +# Bug#43360 - Server crash with a simple multi-table update +# +CREATE TABLE t1 ( +a CHAR(2) NOT NULL PRIMARY KEY, +b VARCHAR(20) NOT NULL, +KEY (b) +); +CREATE TABLE t2 ( +a CHAR(2) NOT NULL PRIMARY KEY, +b VARCHAR(30) NOT NULL, +KEY (b) +); +INSERT INTO t1 VALUES +('AB','MySQL AB'), +('JA','Sun Microsystems'), +('MS','Microsoft'), +('IB','IBM- Inc.'), +('GO','Google Inc.'); +INSERT INTO t2 VALUES +('AB','Sweden'), +('JA','USA'), +('MS','United States of America'), +('IB','North America'), +('GO','South America'); +UPDATE t1,t2 SET t1.b=UPPER(t1.b) WHERE t1.b LIKE 'United%'; +SELECT * FROM t1 ORDER BY a; +a b +AB MySQL AB +GO Google Inc. +IB IBM- Inc. +JA Sun Microsystems +MS Microsoft +SELECT * FROM t2 ORDER BY a; +a b +AB Sweden +GO South America +IB North America +JA USA +MS United States of America +DROP TABLE t1,t2; +# +# Bug#40992 - InnoDB: Crash when engine_condition_pushdown is on +# +CREATE TABLE t ( +dummy INT PRIMARY KEY, +a INT UNIQUE, +b INT +); +INSERT INTO t VALUES (1,1,1),(3,3,3),(5,5,5); +SELECT * FROM t WHERE a > 2 FOR UPDATE; +dummy a b +3 3 3 +5 5 5 +DROP TABLE t; +# +# Bug#35080 - Innodb crash at mem_block_get_len line 72 +# +CREATE TABLE t1 ( +t1_autoinc INT(11) NOT NULL AUTO_INCREMENT, +uuid VARCHAR(36) DEFAULT NULL, +PRIMARY KEY (t1_autoinc), +KEY k (uuid) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t2 ( +t2_autoinc INT(11) NOT NULL AUTO_INCREMENT, +uuid VARCHAR(36) DEFAULT NULL, +date DATETIME DEFAULT NULL, +PRIMARY KEY (t2_autoinc), +KEY k (uuid) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE VIEW v1 AS +SELECT t1_autoinc, uuid +FROM t1 +WHERE (ISNULL(uuid) OR (uuid like '%-%')); +CREATE VIEW v2 AS +SELECT t2_autoinc, uuid, date +FROM t2 +WHERE (ISNULL(uuid) OR (LENGTH(uuid) = 36)); +CREATE PROCEDURE delete_multi (IN uuid CHAR(36)) +DELETE v1, v2 FROM v1 INNER JOIN v2 +ON v1.uuid = v2.uuid +WHERE v1.uuid = @uuid; +SET @uuid = UUID(); +INSERT INTO v1 (uuid) VALUES (@uuid); +INSERT INTO v2 (uuid, date) VALUES (@uuid, '2009-09-09'); +CALL delete_multi(@uuid); +DROP procedure delete_multi; +DROP table t1,t2; +DROP view v1,v2; +# +# Bug#41996 - multi-table delete crashes server (InnoDB table) +# +CREATE TABLE t1 ( +b BIGINT, +i INT, +KEY (b) +); +INSERT INTO t1 VALUES (2, 2); +DELETE t1 FROM t1 a, t1 WHERE a.i=t1.b; +DROP TABLE t1; +# +# Bug#43448 - Server crashes on multi table delete with Innodb +# +CREATE TABLE t1 ( +id1 INT NOT NULL AUTO_INCREMENT PRIMARY KEY, +t CHAR(12) +); +CREATE TABLE t2 ( +id2 INT NOT NULL, +t CHAR(12) +); +CREATE TABLE t3( +id3 INT NOT NULL, +t CHAR(12), +INDEX(id3) +); +CREATE PROCEDURE insert_data () +BEGIN +DECLARE i1 INT DEFAULT 20; +DECLARE i2 INT; +DECLARE i3 INT; +WHILE (i1 > 0) DO +INSERT INTO t1(t) VALUES (i1); +SET i2 = 2; +WHILE (i2 > 0) DO +INSERT INTO t2(id2, t) VALUES (i1, i2); +SET i3 = 2; +WHILE (i3 > 0) DO +INSERT INTO t3(id3, t) VALUES (i1, i2); +SET i3 = i3 -1; +END WHILE; +SET i2 = i2 -1; +END WHILE; +SET i1 = i1 - 1; +END WHILE; +END | +CALL insert_data(); +SELECT COUNT(*) FROM t1 WHERE id1 > 10; +COUNT(*) +10 +SELECT COUNT(*) FROM t2 WHERE id2 > 10; +COUNT(*) +20 +SELECT COUNT(*) FROM t3 WHERE id3 > 10; +COUNT(*) +40 +DELETE t1, t2, t3 +FROM t1, t2, t3 +WHERE t1.id1 = t2.id2 AND t2.id2 = t3.id3 AND t1.id1 > 3; +SELECT COUNT(*) FROM t1; +COUNT(*) +3 +SELECT COUNT(*) FROM t2; +COUNT(*) +6 +SELECT COUNT(*) FROM t3; +COUNT(*) +12 +DROP PROCEDURE insert_data; +DROP TABLE t1, t2, t3; +# +# Bug#42580 - Innodb's ORDER BY ..LIMIT returns no rows for +# null-safe operator <=> NULL +# +SET sql_mode = 'NO_ENGINE_SUBSTITUTION'; +CREATE TABLE t1( +c1 DATE NOT NULL, +c2 DATE NULL, +c3 DATETIME, +c4 TIMESTAMP, +PRIMARY KEY(c1), +UNIQUE(c2) +); + +INSERT INTO t1 VALUES('0000-00-00', '0000-00-00', '2008-01-04', '2008-01-05'); +INSERT INTO t1 VALUES('2007-05-25', '2007-05-25', '2007-05-26', '2007-05-26'); +INSERT INTO t1 VALUES('2008-01-01', NULL , '2008-01-02', '2008-01-03'); +INSERT INTO t1 VALUES('2008-01-17', NULL , NULL , '2009-01-29'); +INSERT INTO t1 VALUES('2009-01-29', '2009-01-29', '2009-01-29', '2009-01-29'); + +SELECT * FROM t1 WHERE c2 <=> NULL ORDER BY c1,c2; +c1 c2 c3 c4 +2008-01-01 NULL 2008-01-02 00:00:00 2008-01-03 00:00:00 +2008-01-17 NULL NULL 2009-01-29 00:00:00 + +SELECT * FROM t1 WHERE c2 <=> NULL ORDER BY c1,c2 LIMIT 2; +c1 c2 c3 c4 +2008-01-01 NULL 2008-01-02 00:00:00 2008-01-03 00:00:00 +2008-01-17 NULL NULL 2009-01-29 00:00:00 + +DROP TABLE t1; +SET sql_mode = default; +# +# Bug#43617 - Innodb returns wrong results with timestamp's range value +# in IN clause +# (Note: Fixed by patch for BUG#42580) +# +SET sql_mode = 'NO_ENGINE_SUBSTITUTION'; +CREATE TABLE t1( +c1 TIMESTAMP NOT NULL, +c2 TIMESTAMP NULL, +c3 DATE, +c4 DATETIME, +PRIMARY KEY(c1), +UNIQUE INDEX(c2) +); +INSERT INTO t1 VALUES +('0000-00-00 00:00:00','0000-00-00 00:00:00','2008-01-04','2008-01-05 00:00:00'), +('1971-01-01 00:00:01','1980-01-01 00:00:01','2009-01-01','2009-01-02 00:00:00'), +('1999-01-01 00:00:00','1999-01-01 00:00:00', NULL, NULL), +('2007-05-23 09:15:28','2007-05-23 09:15:28','2007-05-24','2007-05-24 09:15:28'), +('2007-05-27 00:00:00','2007-05-25 00:00:00','2007-05-26','2007-05-26 00:00:00'), +('2008-01-01 00:00:00', NULL, '2008-01-02','2008-01-03 00:00:00'), +('2009-01-29 11:11:27','2009-01-29 11:11:27','2009-01-29','2009-01-29 11:11:27'), +('2038-01-09 03:14:07','2038-01-09 03:14:07','2009-01-05','2009-01-06 00:00:00'); + +SELECT * +FROM t1 +WHERE c2 IN ('1971-01-01 00:00:01','2038-01-09 03:14:07') +ORDER BY c2; +c1 c2 c3 c4 +2038-01-09 03:14:07 2038-01-09 03:14:07 2009-01-05 2009-01-06 00:00:00 + +SELECT * +FROM t1 +WHERE c2 IN ('1971-01-01 00:00:01','2038-01-09 03:14:07') +ORDER BY c2 LIMIT 2; +c1 c2 c3 c4 +2038-01-09 03:14:07 2038-01-09 03:14:07 2009-01-05 2009-01-06 00:00:00 + +SELECT * +FROM t1 +WHERE c2 IN ('1971-01-01 00:00:01','2038-01-09 03:14:07') +ORDER BY c2 DESC; +c1 c2 c3 c4 +2038-01-09 03:14:07 2038-01-09 03:14:07 2009-01-05 2009-01-06 00:00:00 + +SELECT * +FROM t1 +WHERE c2 IN ('1971-01-01 00:00:01','2038-01-09 03:14:07') +ORDER BY c2 DESC LIMIT 2; +c1 c2 c3 c4 +2038-01-09 03:14:07 2038-01-09 03:14:07 2009-01-05 2009-01-06 00:00:00 + +DROP TABLE t1; +SET sql_mode = default; +# +# Bug#43249 - Innodb returns zero time for the time column +# with <=> NULL order by limit +# (Note: Fixed by patch for BUG#42580) +# +CREATE TABLE t1( +c1 TIME NOT NULL, +c2 TIME NULL, +c3 DATE, +PRIMARY KEY(c1), +UNIQUE INDEX(c2) +); +INSERT INTO t1 VALUES('8:29:45',NULL,'2009-02-01'); + +SELECT * FROM t1 WHERE c2 <=> NULL ORDER BY c2 LIMIT 2; +c1 c2 c3 +08:29:45 NULL 2009-02-01 + +SELECT * FROM t1 WHERE c2 <=> NULL ORDER BY c2 LIMIT 2; +c1 c2 c3 +08:29:45 NULL 2009-02-01 +DROP TABLE t1; +# +# BUG#43618: MyISAM&Maria returns wrong results with 'between' +# on timestamp +# +CREATE TABLE t1( +ts TIMESTAMP NOT NULL, +c char NULL, +PRIMARY KEY(ts) +); +INSERT INTO t1 VALUES +('1971-01-01','a'), +('2007-05-25','b'), +('2008-01-01','c'), +('2038-01-09','d'); + +# Execute select with invalid timestamp, desc ordering +SET sql_mode = ''; +SELECT * +FROM t1 +WHERE ts BETWEEN '0000-00-00' AND '2010-00-01 00:00:00' +ORDER BY ts DESC +LIMIT 2; +ts c +2008-01-01 00:00:00 c +2007-05-25 00:00:00 b +SET sql_mode = default; + +# Should use index condition +EXPLAIN +SELECT * +FROM t1 +WHERE ts BETWEEN '0000-00-00' AND '2010-00-01 00:00:00' +ORDER BY ts DESC +LIMIT 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range PRIMARY PRIMARY 4 NULL 4 100.00 Using where; Backward index scan + +DROP TABLE t1; +# +# BUG#49906: Assertion failed - Field_varstring::val_str in field.cc +# +CREATE TABLE t1 ( +f1 VARCHAR(1024), +f2 VARCHAR(10), +INDEX test_idx USING BTREE (f2,f1(5)) +); +INSERT INTO t1 VALUES ('a','c'), ('b','d'); +SELECT f1 +FROM t1 +WHERE f2 LIKE 'd' +ORDER BY f1; +f1 +b +DROP TABLE t1; +# +# Bug#52660 - "Perf. regr. using ICP for MyISAM on range queries on +# an index containing TEXT" +# +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +CREATE TABLE t2 (a INT); +INSERT INTO t2 SELECT A.a + 10*(B.a) FROM t1 A, t1 B; +CREATE TABLE t3 ( +c1 TINYTEXT NOT NULL, +i1 INT NOT NULL, +KEY (c1(6),i1) +) charset utf8mb4; +INSERT INTO t3 SELECT CONCAT('c-',1000+t2.a,'=w'), 1 FROM t2; +EXPLAIN SELECT c1 FROM t3 WHERE c1 >= 'c-1004=w' and c1 <= 'c-1006=w' and i1 > 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL range c1 c1 30 NULL 2 33.33 Using index condition; Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`c1` AS `c1` from `test`.`t3` where ((`test`.`t3`.`c1` >= 'c-1004=w') and (`test`.`t3`.`c1` <= 'c-1006=w') and (`test`.`t3`.`i1` > 2)) +EXPLAIN FORMAT=tree SELECT c1 FROM t3 WHERE c1 >= 'c-1004=w' and c1 <= 'c-1006=w' and i1 > 2; +EXPLAIN +-> Filter: ((t3.c1 >= 'c-1004=w') and (t3.c1 <= 'c-1006=w')) (cost=1.16 rows=1) + -> Index range scan on t3 using c1, with index condition: (t3.i1 > 2) (cost=1.16 rows=2) + +SELECT c1 FROM t3 WHERE c1 >= 'c-1004=w' and c1 <= 'c-1006=w' and i1 > 2; +c1 +DROP TABLE t1, t2, t3; +# +# Bug#57372 "Multi-table updates and deletes fail when running with ICP +# against InnoDB" +# +CREATE TABLE t1 ( +a INT KEY, +b INT +) ENGINE = INNODB; +CREATE TABLE t2 ( +a INT KEY, +b INT +) ENGINE = INNODB; +INSERT INTO t1 VALUES (1, 101), (2, 102), (3, 103), (4, 104), (5, 105); +INSERT INTO t2 VALUES (1, 1), (2, 2), (3, 3), (4, 4), (5, 5); +UPDATE t1, t2 +SET t1.a = t1.a + 100, t2.b = t1.a + 10 +WHERE t1.a BETWEEN 2 AND 4 AND t2.a = t1.b - 100; +SELECT * FROM t1; +a b +1 101 +102 102 +103 103 +104 104 +5 105 +SELECT * FROM t2; +a b +1 1 +2 12 +3 13 +4 14 +5 5 +DROP TABLE t1, t2; +# +# Bug#52605 - "Adding LIMIT 1 clause to query with complex range +# predicate causes wrong results" +# +CREATE TABLE t1 ( +pk INT NOT NULL, +c1 INT, +PRIMARY KEY (pk), +KEY k1 (c1) +); +INSERT INTO t1 VALUES (1,NULL); +INSERT INTO t1 VALUES (2,6); +INSERT INTO t1 VALUES (3,NULL); +INSERT INTO t1 VALUES (4,6); +INSERT INTO t1 VALUES (5,NULL); +INSERT INTO t1 VALUES (6,NULL); +INSERT INTO t1 VALUES (7,9); +INSERT INTO t1 VALUES (8,0); +SELECT pk, c1 +FROM t1 +WHERE (pk BETWEEN 4 AND 5 OR pk < 2) AND c1 < 240 +ORDER BY c1 +LIMIT 1; +pk c1 +4 6 +EXPLAIN SELECT pk, c1 +FROM t1 +WHERE (pk BETWEEN 4 AND 5 OR pk < 2) AND c1 < 240 +ORDER BY c1 +LIMIT 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 37.50 Parallel execute (1 workers) +2 SIMPLE t1 NULL range PRIMARY,k1 k1 5 NULL 4 37.50 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`c1` AS `c1` from `test`.`t1` where (((`test`.`t1`.`pk` between 4 and 5) or (`test`.`t1`.`pk` < 2)) and (`test`.`t1`.`c1` < 240)) order by `test`.`t1`.`c1` limit 1 +DROP TABLE t1; +# +# Bug#42991 "invalid memory access and/or crash when using +# index condition pushdown + InnoDB" +# +CREATE TABLE t1 ( +c1 TINYTEXT NOT NULL, +c2 INT NOT NULL, +PRIMARY KEY (c2), +KEY id1 (c1(4)) +) charset utf8mb4; +INSERT INTO t1 VALUES ('Anastasia', 5); +INSERT INTO t1 VALUES ('Karianne', 4); +SELECT * FROM t1 WHERE (c1 <= '6566-06-15' AND c2 <> 3); +c1 c2 +EXPLAIN SELECT * FROM t1 WHERE (c1 <= '6566-06-15' AND c2 <> 3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range PRIMARY,id1 id1 18 NULL 1 100.00 Using index condition; Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c1` AS `c1`,`test`.`t1`.`c2` AS `c2` from `test`.`t1` where ((`test`.`t1`.`c1` <= '6566-06-15') and (`test`.`t1`.`c2` <> 3)) +DROP TABLE t1; +# +# Bug#56529 - "Crash due to long semaphore wait in InnoDB +# with ICP and subqueries" +# +CREATE TABLE t1 ( +col_int_nokey INTEGER, +col_int_key INTEGER, +col_varchar_key VARCHAR(1), +KEY (col_int_key), +KEY (col_varchar_key, col_int_key) +) charset utf8mb4 stats_persistent=0; +INSERT INTO t1 VALUES (NULL,2,'w'); +INSERT INTO t1 VALUES (7,9,'m'); +INSERT INTO t1 VALUES (9,3,'m'); +INSERT INTO t1 VALUES (7,9,'k'); +INSERT INTO t1 VALUES (4,NULL,'r'); +INSERT INTO t1 VALUES (2,9,'t'); +INSERT INTO t1 VALUES (6,3,'j'); +INSERT INTO t1 VALUES (8,8,'u'); +INSERT INTO t1 VALUES (NULL,8,'h'); +INSERT INTO t1 VALUES (5,53,'o'); +INSERT INTO t1 VALUES (NULL,0,NULL); +INSERT INTO t1 VALUES (6,5,'k'); +INSERT INTO t1 VALUES (188,166,'e'); +INSERT INTO t1 VALUES (2,3,'n'); +INSERT INTO t1 VALUES (1,0,'t'); +INSERT INTO t1 VALUES (1,1,'c'); +INSERT INTO t1 VALUES (0,9,'m'); +INSERT INTO t1 VALUES (9,5,'y'); +INSERT INTO t1 VALUES (NULL,6,'f'); +CREATE TABLE t2 ( +c1 INTEGER NOT NULL +) stats_persistent=0; +EXPLAIN SELECT table1.col_int_nokey +FROM t1 AS table1 STRAIGHT_JOIN ( +t1 AS table2 INNER JOIN t1 AS table3 +ON table3.col_varchar_key = table2.col_varchar_key) +ON table3.col_int_nokey = table1.col_int_key +WHERE table3.col_int_key != SOME ( SELECT c1 FROM t2 ); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY table1 NULL ALL col_int_key NULL NULL NULL 19 100.00 NULL +1 PRIMARY table3 NULL ALL col_varchar_key NULL NULL NULL 19 10.00 Using where; Using join buffer (hash join) +1 PRIMARY table2 NULL ref col_varchar_key col_varchar_key 7 test.table3.col_varchar_key 1 100.00 Using index +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`table1`.`col_int_nokey` AS `col_int_nokey` from `test`.`t1` `table1` join `test`.`t1` `table2` join `test`.`t1` `table3` where ((`test`.`table2`.`col_varchar_key` = `test`.`table3`.`col_varchar_key`) and (`test`.`table3`.`col_int_nokey` = `test`.`table1`.`col_int_key`) and ((`test`.`table3`.`col_int_key`,(/* select#2 */ select `test`.`t2`.`c1` from `test`.`t2` where (outer_field_is_not_null, ((`test`.`table3`.`col_int_key`) <> `test`.`t2`.`c1`), true))))) +SELECT table1.col_int_nokey +FROM t1 AS table1 STRAIGHT_JOIN ( +t1 AS table2 INNER JOIN t1 AS table3 +ON table3.col_varchar_key = table2.col_varchar_key) +ON table3.col_int_nokey = table1.col_int_key +WHERE table3.col_int_key != SOME ( SELECT c1 FROM t2 ); +col_int_nokey +DROP TABLE t1, t2; +# +# Bug#58243 "RQG test optimizer_subquery causes server crash +# when running with ICP" +# +CREATE TABLE t1 ( +pk INTEGER NOT NULL, +c1 INTEGER NOT NULL, +c2 INTEGER NOT NULL, +PRIMARY KEY (pk) +); +INSERT INTO t1 VALUES (1,6,7); +CREATE TABLE t2 ( +c1 INTEGER NOT NULL +); +EXPLAIN SELECT t1.c1 +FROM t1 +WHERE t1.pk < 317 AND 2 IN (SELECT COUNT(t2.c1) +FROM t2) +ORDER BY t1.c2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +2 SUBQUERY t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c1` AS `c1` from `test`.`t1` where false order by `test`.`t1`.`c2` +SELECT t1.c1 +FROM t1 +WHERE t1.pk < 317 AND 2 IN (SELECT COUNT(t2.c1) +FROM t2) +ORDER BY t1.c2; +c1 +DROP TABLE t1, t2; +CREATE TABLE t1 ( +i1 INTEGER NOT NULL, +c1 VARCHAR(1) NOT NULL +) charset latin1; +INSERT INTO t1 VALUES (2,'w'); +CREATE TABLE t2 ( +i1 INTEGER NOT NULL, +c1 VARCHAR(1) NOT NULL, +c2 VARCHAR(1) NOT NULL, +KEY (c1, i1) +) charset latin1; +INSERT INTO t2 VALUES (8,'d','d'); +INSERT INTO t2 VALUES (4,'v','v'); +CREATE TABLE t3 ( +c1 VARCHAR(1) NOT NULL +) charset latin1; +INSERT INTO t3 VALUES ('v'); +EXPLAIN SELECT i1 +FROM t1 +WHERE EXISTS (SELECT t2.c1 +FROM (t2 INNER JOIN t3 ON (t3.c1 = t2.c1)) +WHERE t2.c2 != t1.c1 AND t2.c2 = (SELECT MIN(t3.c1) +FROM t3)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 PRIMARY t3 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 PRIMARY t2 NULL ref c1 c1 3 test.t3.c1 1 50.00 Using where; FirstMatch(t1) +3 SUBQUERY t3 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1276 Field or reference 'test.t1.c1' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i1` AS `i1` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`c1` = `test`.`t3`.`c1`) and (`test`.`t2`.`c2` = (/* select#3 */ select min(`test`.`t3`.`c1`) from `test`.`t3`)) and ((/* select#3 */ select min(`test`.`t3`.`c1`) from `test`.`t3`) <> `test`.`t1`.`c1`)) +SELECT i1 +FROM t1 +WHERE EXISTS (SELECT t2.c1 +FROM (t2 INNER JOIN t3 ON (t3.c1 = t2.c1)) +WHERE t2.c2 != t1.c1 AND t2.c2 = (SELECT MIN(t3.c1) +FROM t3)); +i1 +2 +DROP TABLE t1,t2,t3; +# +# Bug#58015 "Assert in row_sel_field_store_in_mysql_format +# when running innodb_mrr_icp test" +# +create table t1 (a char(2) charset utf8,b double, primary key (a(1)),key (b)); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +insert into t1 values ('',1); +select 1 from t1 where b <= 1 and a <> ''; +1 +drop table t1; +# +# Bug#59259 "Incorrect rows returned for a correlated subquery +# when ICP is on" +# +CREATE TABLE t1 (pk INTEGER PRIMARY KEY, i INTEGER NOT NULL) ENGINE=InnoDB; +INSERT INTO t1 VALUES (11,0); +INSERT INTO t1 VALUES (12,5); +INSERT INTO t1 VALUES (15,0); +CREATE TABLE t2 (pk INTEGER PRIMARY KEY, i INTEGER NOT NULL) ENGINE=InnoDB; +INSERT INTO t2 VALUES (11,1); +INSERT INTO t2 VALUES (12,2); +INSERT INTO t2 VALUES (15,4); +SELECT * FROM t1 +WHERE pk IN (SELECT it.pk FROM t2 JOIN t2 AS it ON it.i=it.i WHERE t1.i); +pk i +12 5 +DROP TABLE t1, t2; +# +# Bug #58816 "Extra temporary duplicate rows in result set when +# switching ICP off" +# +set @save_optimizer_switch_bug58816= @@optimizer_switch; +CREATE TABLE t1 ( +pk INT NOT NULL, +c1 INT NOT NULL, +PRIMARY KEY (pk) +); +INSERT INTO t1 VALUES (1,9),(2,7),(3,6),(4,3),(5,1); +EXPLAIN SELECT pk, c1 FROM t1 WHERE pk <> 3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (2 workers) +2 SIMPLE t1 NULL range PRIMARY PRIMARY 4 NULL 4 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`c1` AS `c1` from `test`.`t1` where (`test`.`t1`.`pk` <> 3) +SET SESSION optimizer_switch='index_condition_pushdown=off'; +SELECT pk, c1 FROM t1 WHERE pk <> 3; +pk c1 +1 9 +2 7 +4 3 +5 1 +DROP TABLE t1; +set optimizer_switch= @save_optimizer_switch_bug58816; +# +# Bug#58837: ICP crash or valgrind error due to uninitialized +# value in innobase_index_cond +# +CREATE TABLE t1 ( +t1_int INT, +t1_time TIME +); +CREATE TABLE t2 ( +t2_int int PRIMARY KEY, +t2_int2 INT +); +INSERT IGNORE INTO t2 VALUES (); +INSERT INTO t1 VALUES (); + +SELECT * +FROM t1 AS t1a +WHERE NOT EXISTS +(SELECT * +FROM t1 AS t1b +WHERE t1b.t1_int NOT IN +(SELECT t2.t2_int +FROM t2 +WHERE t1b.t1_time LIKE t1b.t1_int +OR t1b.t1_time <> t2.t2_int2 +AND 6=7 +) +) +;; +t1_int t1_time + +EXPLAIN SELECT * +FROM t1 AS t1a +WHERE NOT EXISTS +(SELECT * +FROM t1 AS t1b +WHERE t1b.t1_int NOT IN +(SELECT t2.t2_int +FROM t2 +WHERE t1b.t1_time LIKE t1b.t1_int +OR t1b.t1_time <> t2.t2_int2 +AND 6=7 +) +) +;; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +2 SUBQUERY t1b NULL ALL NULL NULL NULL NULL 1 100.00 Using where +3 DEPENDENT SUBQUERY t2 NULL unique_subquery PRIMARY PRIMARY 4 func 1 100.00 Using where; Full scan on NULL key +Warnings: +Note 1276 Field or reference 'test.t1b.t1_time' of SELECT #3 was resolved in SELECT #2 +Note 1276 Field or reference 'test.t1b.t1_int' of SELECT #3 was resolved in SELECT #2 +Note 1276 Field or reference 'test.t1b.t1_time' of SELECT #3 was resolved in SELECT #2 +Note 1003 /* select#1 */ select `test`.`t1a`.`t1_int` AS `t1_int`,`test`.`t1a`.`t1_time` AS `t1_time` from `test`.`t1` `t1a` where false + +DROP TABLE t1,t2; +# +# Bug#59186 Wrong results of join when ICP is enabled +# +CREATE TABLE t1 ( +pk INTEGER NOT NULL, +c1 VARCHAR(3) NOT NULL, +PRIMARY KEY (pk) +); +INSERT INTO t1 VALUES (1,'y'),(0,'or'); +CREATE TABLE t2 ( +pk INTEGER NOT NULL, +c1 VARCHAR(3) NOT NULL, +c2 VARCHAR(6) NOT NULL, +PRIMARY KEY (pk) +); +INSERT INTO t2 VALUES (6,'y','RPOYT'),(10,'m','JINQE'); +EXPLAIN SELECT c2 FROM t1 JOIN t2 ON t1.c1 = t2.c1 +WHERE (t2.pk <= 4 AND t1.pk IN (2,1)) OR +(t1.pk > 1 AND t2.pk BETWEEN 6 AND 6); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range PRIMARY PRIMARY 4 NULL 1 100.00 Using where +2 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`c2` AS `c2` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`c1` = `test`.`t1`.`c1`) and (((`test`.`t2`.`pk` <= 4) and (`test`.`t1`.`pk` in (2,1))) or ((`test`.`t1`.`pk` > 1) and (`test`.`t2`.`pk` between 6 and 6)))) +SELECT c2 FROM t1 JOIN t2 ON t1.c1 = t2.c1 +WHERE (t2.pk <= 4 AND t1.pk IN (2,1)) OR +(t1.pk > 1 AND t2.pk BETWEEN 6 AND 6); +c2 +DROP TABLE t1, t2; +# +# Bug#58838 "Wrong results with HAVING + LIMIT without GROUP BY when +# ICP is enabled" +# +CREATE TABLE t1 ( +pk INT NOT NULL, +c1 INT, +PRIMARY KEY (pk), +KEY col_int_key (c1) +); +INSERT INTO t1 VALUES (1,37),(2,8),(3,-25),(4,NULL),(5,55); +SELECT pk FROM t1 WHERE c1 <> 1 HAVING pk = 3 ORDER BY pk LIMIT 0; +pk +SELECT pk FROM t1 WHERE c1 <> 1 HAVING pk = 3 ORDER BY pk LIMIT 1; +pk +3 +SELECT pk FROM t1 WHERE c1 <> 1 HAVING pk = 3 ORDER BY pk LIMIT 2; +pk +3 +SELECT pk FROM t1 WHERE c1 <> 1 HAVING pk = 3 ORDER BY pk LIMIT 5; +pk +3 +DROP TABLE t1; +# +# Bug#59483 "Crash on INSERT/REPLACE in +# rec_convert_dtuple_to_rec_comp with ICP on" +# +CREATE TABLE t1 ( +pk INTEGER AUTO_INCREMENT PRIMARY KEY, +i1 INTEGER, +c1 CHAR(6), +i2 INTEGER NOT NULL, +KEY (i2) +); +INSERT INTO t1 VALUES +(NULL, 4, 'that', 8), +(NULL, 1, 'she', 6), +(NULL, 6, 'tell', 2); +SELECT * FROM t1 WHERE i2 IN (3, 6) LIMIT 2 FOR UPDATE; +pk i1 c1 i2 +2 1 she 6 +INSERT INTO t1 (i2) VALUES (1); +DROP TABLE t1; +# +# Bug #11766678 - 59843: +# USING UNINITIALISED VALUE IN USES_INDEX_FIELDS_ONLY +# +CREATE TABLE t1 ( +col999 FLOAT NOT NULL, +COL1000 VARBINARY(179) NOT NULL, +col1003 DATE DEFAULT NULL, +KEY idx4267 (col1000, col1003) +); +INSERT IGNORE INTO t1 VALUES (),(); +Warnings: +Warning 1364 Field 'col999' doesn't have a default value +Warning 1364 Field 'COL1000' doesn't have a default value +SELECT col999 FROM t1 WHERE col1000 = "3" AND col1003 <=> sysdate(); +col999 +DROP TABLE t1; +# +# Bug#11873324 "WRONG RESULT WITH ICP AND STRAIGHT_JOIN" +# +CREATE TABLE t1 ( +pk INTEGER NOT NULL, +i1 INTEGER, +PRIMARY KEY (pk), +KEY col_int_key (i1) +); +INSERT INTO t1 VALUES (14,NULL), (18,133); +CREATE TABLE t2 ( +pk INTEGER NOT NULL, +i1 INTEGER, +c1 VARCHAR(1), +PRIMARY KEY (pk), +KEY col_int_key (i1) +); +INSERT INTO t2 VALUES (1,7,'f'); +set @old_opt_switch=@@optimizer_switch; +EXPLAIN SELECT t1.i1 +FROM t1 +WHERE t1.i1 NOT IN +( SELECT STRAIGHT_JOIN subquery_t1.pk +FROM t1 AS subquery_t1 +JOIN t2 AS subquery_t2 +ON subquery_t2.i1 = subquery_t1.pk +WHERE subquery_t1.i1 > 0 +OR subquery_t2.c1 = 'a' +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL index NULL col_int_key 5 NULL 2 100.00 Using where; Using index +2 DEPENDENT SUBQUERY subquery_t1 NULL eq_ref PRIMARY,col_int_key PRIMARY 4 func 1 100.00 Using where; Full scan on NULL key +2 DEPENDENT SUBQUERY subquery_t2 NULL ref col_int_key col_int_key 5 func 1 100.00 Using where; Full scan on NULL key +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i1` AS `i1` from `test`.`t1` where (`test`.`t1`.`i1`,(/* select#2 */ select straight_join `test`.`subquery_t1`.`pk` from `test`.`t1` `subquery_t1` join `test`.`t2` `subquery_t2` where ((`test`.`subquery_t2`.`i1` = `test`.`subquery_t1`.`pk`) and ((`test`.`subquery_t1`.`i1` > 0) or (`test`.`subquery_t2`.`c1` = 'a')) and (outer_field_is_not_null, ((`test`.`t1`.`i1`) = `test`.`subquery_t1`.`pk`), true))) is false) +SELECT t1.i1 +FROM t1 +WHERE t1.i1 NOT IN +( SELECT STRAIGHT_JOIN subquery_t1.pk +FROM t1 AS subquery_t1 +JOIN t2 AS subquery_t2 +ON subquery_t2.i1 = subquery_t1.pk +WHERE subquery_t1.i1 > 0 +OR subquery_t2.c1 = 'a' +); +i1 +NULL +133 +set @@optimizer_switch=@old_opt_switch; +DROP TABLE t1,t2; +# +# Bug#11876420 "MISSING ROW IN RESULT WITH SUBQUERY + IN + XOR + +# NULL VALUES AND ICP ENABLED" +# +CREATE TABLE t1 ( +i1 INTEGER, +c1 VARCHAR(1), +KEY col_varchar_key (c1) +) charset utf8mb4; +INSERT INTO t1 VALUES (1,'j'), (0,'e'), (210,'f'), (8,'v'), (7,'x'), +(5,'m'), (NULL,'c'); +CREATE TABLE t2 ( +i1 INTEGER, +c1 VARCHAR(1), +KEY col_varchar_key (c1) +) charset utf8mb4; +INSERT INTO t2 VALUES (8,NULL); +CREATE TABLE t3 ( +i1 INTEGER, +c1 VARCHAR(1), +KEY col_varchar_key (c1) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t3 VALUES (NULL,'w'), (1,NULL), (2,'d'); +set @old_opt_switch=@@optimizer_switch; +EXPLAIN SELECT i1 +FROM t3 +WHERE c1 IN +( SELECT t1.c1 +FROM t2 JOIN t1 +ON t2.i1 >= t1.i1 +WHERE t1.c1 > t2.c1 +) +XOR i1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t3 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t2 NULL ALL col_varchar_key NULL NULL NULL 1 100.00 NULL +2 DEPENDENT SUBQUERY t1 NULL ref_or_null col_varchar_key col_varchar_key 7 func 2 33.33 Using where; Full scan on NULL key +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`i1` AS `i1` from `test`.`t3` where ((`test`.`t3`.`c1`,(/* select#2 */ select `test`.`t1`.`c1` from `test`.`t2` join `test`.`t1` where ((`test`.`t1`.`c1` > `test`.`t2`.`c1`) and (outer_field_is_not_null, (((`test`.`t3`.`c1`) = `test`.`t1`.`c1`) or (`test`.`t1`.`c1` is null)), true) and (`test`.`t2`.`i1` >= `test`.`t1`.`i1`)) having (outer_field_is_not_null, (`test`.`t1`.`c1`), true))) xor (0 <> `test`.`t3`.`i1`)) +SELECT i1 +FROM t3 +WHERE c1 IN +( SELECT t1.c1 +FROM t2 JOIN t1 +ON t2.i1 >= t1.i1 +WHERE t1.c1 > t2.c1 +) +XOR i1; +i1 +1 +2 +set @@optimizer_switch=@old_opt_switch; +DROP TABLE t1, t2, t3; +# +# Bug#12355958 "FAILING ASSERTION: TRX->LOCK.N_ACTIVE_THRS == 1" +# +CREATE TABLE t1 ( +pk INTEGER PRIMARY KEY, +a INTEGER NOT NULL, +b CHAR(1), +KEY(b) +) charset utf8mb4; +INSERT INTO t1 VALUES (23,5,'d'); +EXPLAIN SELECT a1.pk +FROM t1 AS a1 JOIN (SELECT * FROM t1 LIMIT 1) AS a2 ON a2.b = a1.b +WHERE a1.a = (SELECT pk FROM t1 LIMIT 1) +AND (a1.a != a2.a OR a1.b IS NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL system NULL NULL NULL NULL 1 100.00 NULL +1 PRIMARY a1 NULL ref b b 5 const 1 100.00 Using where +3 SUBQUERY t1 NULL index NULL b 5 NULL 1 100.00 Using index +2 DERIVED t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`a1`.`pk` AS `pk` from `test`.`t1` `a1` where ((`test`.`a1`.`b` = 'd') and (`test`.`a1`.`a` = (/* select#3 */ select `test`.`t1`.`pk` from `test`.`t1` limit 1)) and (((/* select#3 */ select `test`.`t1`.`pk` from `test`.`t1` limit 1) <> '5') or (`test`.`a1`.`b` is null))) +SELECT a1.pk +FROM t1 AS a1 JOIN (SELECT * FROM t1 LIMIT 1) AS a2 ON a2.b = a1.b +WHERE a1.a = (SELECT pk FROM t1 LIMIT 1) +AND (a1.a != a2.a OR a1.b IS NULL); +pk +CREATE VIEW v1 AS SELECT * FROM t1; +EXPLAIN SELECT a1.pk +FROM v1 AS a1 JOIN (SELECT * FROM v1 LIMIT 1) AS a2 ON a2.b = a1.b +WHERE a1.a = (SELECT pk FROM v1 LIMIT 1) +AND (a1.a != a2.a OR a1.b IS NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL system NULL NULL NULL NULL 1 100.00 NULL +1 PRIMARY t1 NULL ref b b 5 const 1 100.00 Using where +3 SUBQUERY t1 NULL index NULL b 5 NULL 1 100.00 Using index +2 DERIVED t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` where ((`test`.`t1`.`b` = 'd') and (`test`.`t1`.`a` = (/* select#3 */ select `test`.`t1`.`pk` from `test`.`t1` limit 1)) and ((`test`.`t1`.`a` <> '5') or (`test`.`t1`.`b` is null))) +SELECT a1.pk +FROM v1 AS a1 JOIN (SELECT * FROM v1 LIMIT 1) AS a2 ON a2.b = a1.b +WHERE a1.a = (SELECT pk FROM v1 LIMIT 1) +AND (a1.a != a2.a OR a1.b IS NULL); +pk +DROP VIEW v1; +DROP TABLE t1; +# +# BUG#12601961 "SEGFAULT IN HANDLER::COMPARE_KEY2" +# BUG#12724899 "SELECT STRAIGHT_JOIN QUERY GIVES 2 DATES VERSUS +# 2 WARNINGS WITH ICP ON" +# +CREATE TABLE t1 ( +pk INTEGER NOT NULL, +i1 INTEGER NOT NULL, +c1 VARCHAR(1) NOT NULL, +PRIMARY KEY (pk) +); +INSERT INTO t1 VALUES (1,3,'j'), (20,8,'e'); +EXPLAIN SELECT alias2.i1 +FROM t1 AS alias1 STRAIGHT_JOIN t1 AS alias2 +ON alias2.pk AND alias2.pk <= alias1.c1 +WHERE alias2.pk = 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE alias1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 SIMPLE alias2 NULL const PRIMARY PRIMARY 4 const 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`alias2`.`i1` AS `i1` from `test`.`t1` `alias1` straight_join `test`.`t1` `alias2` where ((`test`.`alias2`.`pk` = 1) and (cast(`test`.`alias2`.`pk` as double) <= cast(`test`.`alias1`.`c1` as double))) +SELECT alias2.i1 +FROM t1 AS alias1 STRAIGHT_JOIN t1 AS alias2 +ON alias2.pk AND alias2.pk <= alias1.c1 +WHERE alias2.pk = 1; +i1 +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'j' +Warning 1292 Truncated incorrect DOUBLE value: 'e' +DROP TABLE t1; +# +# BUG#12822678 - 2 MORE ROWS WHEN ICP=ON W/ STRAIGHT_JOIN +# +CREATE TABLE t1 ( +i1 INTEGER NOT NULL, +d1 DOUBLE, +KEY k1 (d1) +); +INSERT INTO t1 VALUES (10,1), (17,NULL), (22,NULL); +CREATE TABLE t2 ( +pk INTEGER NOT NULL, +i1 INTEGER NOT NULL, +PRIMARY KEY (pk) +); +INSERT INTO t2 VALUES (4,1); +EXPLAIN SELECT t1.d1, t2.pk, t2.i1 +FROM t1 STRAIGHT_JOIN t2 ON t2.i1 +WHERE t2.pk <> t1.d1 AND t2.pk = 4; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL k1 9 NULL 3 100.00 Using index +2 SIMPLE t2 NULL const PRIMARY PRIMARY 4 const 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`d1` AS `d1`,`test`.`t2`.`pk` AS `pk`,`test`.`t2`.`i1` AS `i1` from `test`.`t1` straight_join `test`.`t2` where ((`test`.`t2`.`pk` = 4) and (`test`.`t2`.`pk` <> `test`.`t1`.`d1`) and (0 <> `test`.`t2`.`i1`)) +SELECT t1.d1, t2.pk, t2.i1 +FROM t1 STRAIGHT_JOIN t2 ON t2.i1 +WHERE t2.pk <> t1.d1 AND t2.pk = 4; +d1 pk i1 +1 4 1 +DROP TABLE t1, t2; +# +# BUG#12838420 "DUPLICATE VALUES FOR GROUP-BY COLUMN WHEN JOIN +# BUFFERING IS OFF" +# +CREATE TABLE t1 ( +col_int_key INT, +pk INT, +PRIMARY KEY (pk), +KEY (col_int_key) +); +INSERT INTO t1 VALUES (2,3),(3,2),(3,5),(4,6); +CREATE TABLE t2 ( +col_int_key INT, +pk INT, +PRIMARY KEY (pk), +KEY (col_int_key) +); +INSERT INTO t2 VALUES (0,9),(3,10),(4,6),(6,1),(100,3),(200,5); +set @old_opt_switch=@@optimizer_switch; +SET optimizer_switch="block_nested_loop=off"; +EXPLAIN SELECT t2.col_int_key AS field1 +FROM t2 USE INDEX(col_int_key) STRAIGHT_JOIN t1 ON t2.col_int_key +WHERE t2.pk < 7 AND t2.col_int_key <> 7 +GROUP BY field1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 6 33.33 Parallel execute (1 workers) +2 SIMPLE t2 NULL index col_int_key col_int_key 5 NULL 6 33.33 Using where; Using index +2 SIMPLE t1 NULL index NULL col_int_key 5 NULL 4 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`col_int_key` AS `field1` from `test`.`t2` USE INDEX (`col_int_key`) straight_join `test`.`t1` where ((`test`.`t2`.`pk` < 7) and (`test`.`t2`.`col_int_key` <> 7) and (0 <> `test`.`t2`.`col_int_key`)) group by `field1` +SELECT t2.col_int_key AS field1 +FROM t2 USE INDEX(col_int_key) STRAIGHT_JOIN t1 ON t2.col_int_key +WHERE t2.pk < 7 AND t2.col_int_key <> 7 +GROUP BY field1; +field1 +4 +6 +100 +200 +SET @@optimizer_switch=@old_opt_switch; +DROP TABLE t1,t2; +# +# Bug#12976163 "CRASH IN INDEX CONDITION PUSHDOWN CODE AGAINST +# A MYISAM TABLE" +# +CREATE TABLE t1 ( +i1 INTEGER NOT NULL, +i2 INTEGER NOT NULL +); +INSERT INTO t1 VALUES (14,1), (15,2), (16,3); +CREATE TABLE t2 ( +i1 INTEGER NOT NULL, +i2 INTEGER NOT NULL, +c1 TINYTEXT +); +INSERT INTO t2 +SELECT i1, 10 * i2, "MySQL" FROM t1; +CREATE PROCEDURE proc1(id INTEGER) +BEGIN +SELECT i2 +FROM ( +(SELECT i1, i2, NULL AS a1 FROM t1) +UNION +(SELECT i1, i2, c1 AS a1 FROM t2) +) u1 +WHERE i1 = id; +END$$ +CALL proc1(15); +i2 +2 +20 +DROP PROCEDURE proc1; +DROP TABLE t1, t2; +# +# Bug#13655397 "CRASH IN SYNC_THREAD_LEVELS_NONEMPTY_TRX" +# +CREATE TABLE t1 ( +i1 INTEGER NOT NULL, +i2 INTEGER NOT NULL, +KEY (i1) +); +INSERT INTO t1 VALUES (4,4), (5,5); +CREATE TABLE t2 ( +pk INTEGER NOT NULL, +PRIMARY KEY (pk) +); +INSERT INTO t2 VALUES (1); +CREATE FUNCTION f1() RETURNS INTEGER +RETURN (SELECT MOD(COUNT(DISTINCT pk), 10) FROM t2); +EXPLAIN SELECT i1, i2 FROM t1 WHERE f1() = 1 AND i1 = 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ref i1 i1 4 const 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i1` AS `i1`,`test`.`t1`.`i2` AS `i2` from `test`.`t1` where ((`test`.`t1`.`i1` = 5) and (`f1`() = 1)) +SELECT i1, i2 FROM t1 WHERE f1() = 1 AND i1 = 5; +i1 i2 +5 5 +DROP FUNCTION f1; +DROP TABLE t1, t2; +set default_storage_engine= @save_storage_engine; +set optimizer_switch=default; diff --git a/mysql-test/r/innodb_icp_none.result-pq b/mysql-test/r/innodb_icp_none.result-pq new file mode 100644 index 000000000000..cdf1d558d8e4 --- /dev/null +++ b/mysql-test/r/innodb_icp_none.result-pq @@ -0,0 +1,1129 @@ +set @save_storage_engine= @@default_storage_engine; +set default_storage_engine=InnoDB; +# Bug#36981 - "innodb crash when selecting for update" +# +CREATE TABLE t1 ( +c1 CHAR(1), +c2 CHAR(10), +KEY (c1) +); +INSERT INTO t1 VALUES ('3', null); +SELECT * FROM t1 WHERE c1='3' FOR UPDATE; +c1 c2 +3 NULL +DROP TABLE t1; +CREATE TABLE t1 (a INT) charset latin1; +INSERT INTO t1 VALUES (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +CREATE TABLE t2 (a INT) charset latin1; +INSERT INTO t2 SELECT A.a + 10*(B.a + 10*C.a) FROM t1 A, t1 B, t1 C; +CREATE TABLE t3 ( +c1 CHAR(10) NOT NULL, +c2 CHAR(10) NOT NULL, +c3 CHAR(200) NOT NULL, +KEY (c1) +); +INSERT INTO t3 +SELECT CONCAT('c-',1000+t2.a,'=w'), CONCAT('c-',1000+ t2.a,'=w'), 'filler' + FROM t2; +INSERT INTO t3 +SELECT CONCAT('c-',1000+t2.a,'=w'), CONCAT('c-',2000+t2.a,'=w'), 'filler-1' + FROM t2; +INSERT INTO t3 +SELECT CONCAT('c-',1000+t2.a,'=w'), CONCAT('c-',3000+t2.a,'=w'), 'filler-2' + FROM t2; +SELECT c1,c3 FROM t3 WHERE c1 >= 'c-1994=w' and c1 != 'c-1996=w' FOR UPDATE; +c1 c3 +c-1994=w filler +c-1994=w filler-1 +c-1994=w filler-2 +c-1995=w filler +c-1995=w filler-1 +c-1995=w filler-2 +c-1997=w filler +c-1997=w filler-1 +c-1997=w filler-2 +c-1998=w filler +c-1998=w filler-1 +c-1998=w filler-2 +c-1999=w filler +c-1999=w filler-1 +c-1999=w filler-2 +DROP TABLE t1,t2,t3; +# +# Bug#43360 - Server crash with a simple multi-table update +# +CREATE TABLE t1 ( +a CHAR(2) NOT NULL PRIMARY KEY, +b VARCHAR(20) NOT NULL, +KEY (b) +); +CREATE TABLE t2 ( +a CHAR(2) NOT NULL PRIMARY KEY, +b VARCHAR(30) NOT NULL, +KEY (b) +); +INSERT INTO t1 VALUES +('AB','MySQL AB'), +('JA','Sun Microsystems'), +('MS','Microsoft'), +('IB','IBM- Inc.'), +('GO','Google Inc.'); +INSERT INTO t2 VALUES +('AB','Sweden'), +('JA','USA'), +('MS','United States of America'), +('IB','North America'), +('GO','South America'); +UPDATE t1,t2 SET t1.b=UPPER(t1.b) WHERE t1.b LIKE 'United%'; +SELECT * FROM t1 ORDER BY a; +a b +AB MySQL AB +GO Google Inc. +IB IBM- Inc. +JA Sun Microsystems +MS Microsoft +SELECT * FROM t2 ORDER BY a; +a b +AB Sweden +GO South America +IB North America +JA USA +MS United States of America +DROP TABLE t1,t2; +# +# Bug#40992 - InnoDB: Crash when engine_condition_pushdown is on +# +CREATE TABLE t ( +dummy INT PRIMARY KEY, +a INT UNIQUE, +b INT +); +INSERT INTO t VALUES (1,1,1),(3,3,3),(5,5,5); +SELECT * FROM t WHERE a > 2 FOR UPDATE; +dummy a b +3 3 3 +5 5 5 +DROP TABLE t; +# +# Bug#35080 - Innodb crash at mem_block_get_len line 72 +# +CREATE TABLE t1 ( +t1_autoinc INT(11) NOT NULL AUTO_INCREMENT, +uuid VARCHAR(36) DEFAULT NULL, +PRIMARY KEY (t1_autoinc), +KEY k (uuid) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t2 ( +t2_autoinc INT(11) NOT NULL AUTO_INCREMENT, +uuid VARCHAR(36) DEFAULT NULL, +date DATETIME DEFAULT NULL, +PRIMARY KEY (t2_autoinc), +KEY k (uuid) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE VIEW v1 AS +SELECT t1_autoinc, uuid +FROM t1 +WHERE (ISNULL(uuid) OR (uuid like '%-%')); +CREATE VIEW v2 AS +SELECT t2_autoinc, uuid, date +FROM t2 +WHERE (ISNULL(uuid) OR (LENGTH(uuid) = 36)); +CREATE PROCEDURE delete_multi (IN uuid CHAR(36)) +DELETE v1, v2 FROM v1 INNER JOIN v2 +ON v1.uuid = v2.uuid +WHERE v1.uuid = @uuid; +SET @uuid = UUID(); +INSERT INTO v1 (uuid) VALUES (@uuid); +INSERT INTO v2 (uuid, date) VALUES (@uuid, '2009-09-09'); +CALL delete_multi(@uuid); +DROP procedure delete_multi; +DROP table t1,t2; +DROP view v1,v2; +# +# Bug#41996 - multi-table delete crashes server (InnoDB table) +# +CREATE TABLE t1 ( +b BIGINT, +i INT, +KEY (b) +); +INSERT INTO t1 VALUES (2, 2); +DELETE t1 FROM t1 a, t1 WHERE a.i=t1.b; +DROP TABLE t1; +# +# Bug#43448 - Server crashes on multi table delete with Innodb +# +CREATE TABLE t1 ( +id1 INT NOT NULL AUTO_INCREMENT PRIMARY KEY, +t CHAR(12) +); +CREATE TABLE t2 ( +id2 INT NOT NULL, +t CHAR(12) +); +CREATE TABLE t3( +id3 INT NOT NULL, +t CHAR(12), +INDEX(id3) +); +CREATE PROCEDURE insert_data () +BEGIN +DECLARE i1 INT DEFAULT 20; +DECLARE i2 INT; +DECLARE i3 INT; +WHILE (i1 > 0) DO +INSERT INTO t1(t) VALUES (i1); +SET i2 = 2; +WHILE (i2 > 0) DO +INSERT INTO t2(id2, t) VALUES (i1, i2); +SET i3 = 2; +WHILE (i3 > 0) DO +INSERT INTO t3(id3, t) VALUES (i1, i2); +SET i3 = i3 -1; +END WHILE; +SET i2 = i2 -1; +END WHILE; +SET i1 = i1 - 1; +END WHILE; +END | +CALL insert_data(); +SELECT COUNT(*) FROM t1 WHERE id1 > 10; +COUNT(*) +10 +SELECT COUNT(*) FROM t2 WHERE id2 > 10; +COUNT(*) +20 +SELECT COUNT(*) FROM t3 WHERE id3 > 10; +COUNT(*) +40 +DELETE t1, t2, t3 +FROM t1, t2, t3 +WHERE t1.id1 = t2.id2 AND t2.id2 = t3.id3 AND t1.id1 > 3; +SELECT COUNT(*) FROM t1; +COUNT(*) +3 +SELECT COUNT(*) FROM t2; +COUNT(*) +6 +SELECT COUNT(*) FROM t3; +COUNT(*) +12 +DROP PROCEDURE insert_data; +DROP TABLE t1, t2, t3; +# +# Bug#42580 - Innodb's ORDER BY ..LIMIT returns no rows for +# null-safe operator <=> NULL +# +SET sql_mode = 'NO_ENGINE_SUBSTITUTION'; +CREATE TABLE t1( +c1 DATE NOT NULL, +c2 DATE NULL, +c3 DATETIME, +c4 TIMESTAMP, +PRIMARY KEY(c1), +UNIQUE(c2) +); + +INSERT INTO t1 VALUES('0000-00-00', '0000-00-00', '2008-01-04', '2008-01-05'); +INSERT INTO t1 VALUES('2007-05-25', '2007-05-25', '2007-05-26', '2007-05-26'); +INSERT INTO t1 VALUES('2008-01-01', NULL , '2008-01-02', '2008-01-03'); +INSERT INTO t1 VALUES('2008-01-17', NULL , NULL , '2009-01-29'); +INSERT INTO t1 VALUES('2009-01-29', '2009-01-29', '2009-01-29', '2009-01-29'); + +SELECT * FROM t1 WHERE c2 <=> NULL ORDER BY c1,c2; +c1 c2 c3 c4 +2008-01-01 NULL 2008-01-02 00:00:00 2008-01-03 00:00:00 +2008-01-17 NULL NULL 2009-01-29 00:00:00 + +SELECT * FROM t1 WHERE c2 <=> NULL ORDER BY c1,c2 LIMIT 2; +c1 c2 c3 c4 +2008-01-01 NULL 2008-01-02 00:00:00 2008-01-03 00:00:00 +2008-01-17 NULL NULL 2009-01-29 00:00:00 + +DROP TABLE t1; +SET sql_mode = default; +# +# Bug#43617 - Innodb returns wrong results with timestamp's range value +# in IN clause +# (Note: Fixed by patch for BUG#42580) +# +SET sql_mode = 'NO_ENGINE_SUBSTITUTION'; +CREATE TABLE t1( +c1 TIMESTAMP NOT NULL, +c2 TIMESTAMP NULL, +c3 DATE, +c4 DATETIME, +PRIMARY KEY(c1), +UNIQUE INDEX(c2) +); +INSERT INTO t1 VALUES +('0000-00-00 00:00:00','0000-00-00 00:00:00','2008-01-04','2008-01-05 00:00:00'), +('1971-01-01 00:00:01','1980-01-01 00:00:01','2009-01-01','2009-01-02 00:00:00'), +('1999-01-01 00:00:00','1999-01-01 00:00:00', NULL, NULL), +('2007-05-23 09:15:28','2007-05-23 09:15:28','2007-05-24','2007-05-24 09:15:28'), +('2007-05-27 00:00:00','2007-05-25 00:00:00','2007-05-26','2007-05-26 00:00:00'), +('2008-01-01 00:00:00', NULL, '2008-01-02','2008-01-03 00:00:00'), +('2009-01-29 11:11:27','2009-01-29 11:11:27','2009-01-29','2009-01-29 11:11:27'), +('2038-01-09 03:14:07','2038-01-09 03:14:07','2009-01-05','2009-01-06 00:00:00'); + +SELECT * +FROM t1 +WHERE c2 IN ('1971-01-01 00:00:01','2038-01-09 03:14:07') +ORDER BY c2; +c1 c2 c3 c4 +2038-01-09 03:14:07 2038-01-09 03:14:07 2009-01-05 2009-01-06 00:00:00 + +SELECT * +FROM t1 +WHERE c2 IN ('1971-01-01 00:00:01','2038-01-09 03:14:07') +ORDER BY c2 LIMIT 2; +c1 c2 c3 c4 +2038-01-09 03:14:07 2038-01-09 03:14:07 2009-01-05 2009-01-06 00:00:00 + +SELECT * +FROM t1 +WHERE c2 IN ('1971-01-01 00:00:01','2038-01-09 03:14:07') +ORDER BY c2 DESC; +c1 c2 c3 c4 +2038-01-09 03:14:07 2038-01-09 03:14:07 2009-01-05 2009-01-06 00:00:00 + +SELECT * +FROM t1 +WHERE c2 IN ('1971-01-01 00:00:01','2038-01-09 03:14:07') +ORDER BY c2 DESC LIMIT 2; +c1 c2 c3 c4 +2038-01-09 03:14:07 2038-01-09 03:14:07 2009-01-05 2009-01-06 00:00:00 + +DROP TABLE t1; +SET sql_mode = default; +# +# Bug#43249 - Innodb returns zero time for the time column +# with <=> NULL order by limit +# (Note: Fixed by patch for BUG#42580) +# +CREATE TABLE t1( +c1 TIME NOT NULL, +c2 TIME NULL, +c3 DATE, +PRIMARY KEY(c1), +UNIQUE INDEX(c2) +); +INSERT INTO t1 VALUES('8:29:45',NULL,'2009-02-01'); + +SELECT * FROM t1 WHERE c2 <=> NULL ORDER BY c2 LIMIT 2; +c1 c2 c3 +08:29:45 NULL 2009-02-01 + +SELECT * FROM t1 WHERE c2 <=> NULL ORDER BY c2 LIMIT 2; +c1 c2 c3 +08:29:45 NULL 2009-02-01 +DROP TABLE t1; +# +# BUG#43618: MyISAM&Maria returns wrong results with 'between' +# on timestamp +# +CREATE TABLE t1( +ts TIMESTAMP NOT NULL, +c char NULL, +PRIMARY KEY(ts) +); +INSERT INTO t1 VALUES +('1971-01-01','a'), +('2007-05-25','b'), +('2008-01-01','c'), +('2038-01-09','d'); + +# Execute select with invalid timestamp, desc ordering +SET sql_mode = ''; +SELECT * +FROM t1 +WHERE ts BETWEEN '0000-00-00' AND '2010-00-01 00:00:00' +ORDER BY ts DESC +LIMIT 2; +ts c +2008-01-01 00:00:00 c +2007-05-25 00:00:00 b +SET sql_mode = default; + +# Should use index condition +EXPLAIN +SELECT * +FROM t1 +WHERE ts BETWEEN '0000-00-00' AND '2010-00-01 00:00:00' +ORDER BY ts DESC +LIMIT 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range PRIMARY PRIMARY 4 NULL 4 100.00 Using where; Backward index scan + +DROP TABLE t1; +# +# BUG#49906: Assertion failed - Field_varstring::val_str in field.cc +# +CREATE TABLE t1 ( +f1 VARCHAR(1024), +f2 VARCHAR(10), +INDEX test_idx USING BTREE (f2,f1(5)) +); +INSERT INTO t1 VALUES ('a','c'), ('b','d'); +SELECT f1 +FROM t1 +WHERE f2 LIKE 'd' +ORDER BY f1; +f1 +b +DROP TABLE t1; +# +# Bug#52660 - "Perf. regr. using ICP for MyISAM on range queries on +# an index containing TEXT" +# +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +CREATE TABLE t2 (a INT); +INSERT INTO t2 SELECT A.a + 10*(B.a) FROM t1 A, t1 B; +CREATE TABLE t3 ( +c1 TINYTEXT NOT NULL, +i1 INT NOT NULL, +KEY (c1(6),i1) +) charset utf8mb4; +INSERT INTO t3 SELECT CONCAT('c-',1000+t2.a,'=w'), 1 FROM t2; +EXPLAIN SELECT c1 FROM t3 WHERE c1 >= 'c-1004=w' and c1 <= 'c-1006=w' and i1 > 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL range c1 c1 30 NULL 2 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`c1` AS `c1` from `test`.`t3` where ((`test`.`t3`.`c1` >= 'c-1004=w') and (`test`.`t3`.`c1` <= 'c-1006=w') and (`test`.`t3`.`i1` > 2)) +EXPLAIN FORMAT=tree SELECT c1 FROM t3 WHERE c1 >= 'c-1004=w' and c1 <= 'c-1006=w' and i1 > 2; +EXPLAIN +-> Filter: ((t3.c1 >= 'c-1004=w') and (t3.c1 <= 'c-1006=w') and (t3.i1 > 2)) (cost=1.16 rows=1) + -> Index range scan on t3 using c1 (cost=1.16 rows=2) + +SELECT c1 FROM t3 WHERE c1 >= 'c-1004=w' and c1 <= 'c-1006=w' and i1 > 2; +c1 +DROP TABLE t1, t2, t3; +# +# Bug#57372 "Multi-table updates and deletes fail when running with ICP +# against InnoDB" +# +CREATE TABLE t1 ( +a INT KEY, +b INT +) ENGINE = INNODB; +CREATE TABLE t2 ( +a INT KEY, +b INT +) ENGINE = INNODB; +INSERT INTO t1 VALUES (1, 101), (2, 102), (3, 103), (4, 104), (5, 105); +INSERT INTO t2 VALUES (1, 1), (2, 2), (3, 3), (4, 4), (5, 5); +UPDATE t1, t2 +SET t1.a = t1.a + 100, t2.b = t1.a + 10 +WHERE t1.a BETWEEN 2 AND 4 AND t2.a = t1.b - 100; +SELECT * FROM t1; +a b +1 101 +102 102 +103 103 +104 104 +5 105 +SELECT * FROM t2; +a b +1 1 +2 12 +3 13 +4 14 +5 5 +DROP TABLE t1, t2; +# +# Bug#52605 - "Adding LIMIT 1 clause to query with complex range +# predicate causes wrong results" +# +CREATE TABLE t1 ( +pk INT NOT NULL, +c1 INT, +PRIMARY KEY (pk), +KEY k1 (c1) +); +INSERT INTO t1 VALUES (1,NULL); +INSERT INTO t1 VALUES (2,6); +INSERT INTO t1 VALUES (3,NULL); +INSERT INTO t1 VALUES (4,6); +INSERT INTO t1 VALUES (5,NULL); +INSERT INTO t1 VALUES (6,NULL); +INSERT INTO t1 VALUES (7,9); +INSERT INTO t1 VALUES (8,0); +SELECT pk, c1 +FROM t1 +WHERE (pk BETWEEN 4 AND 5 OR pk < 2) AND c1 < 240 +ORDER BY c1 +LIMIT 1; +pk c1 +4 6 +EXPLAIN SELECT pk, c1 +FROM t1 +WHERE (pk BETWEEN 4 AND 5 OR pk < 2) AND c1 < 240 +ORDER BY c1 +LIMIT 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 37.50 Parallel execute (1 workers) +2 SIMPLE t1 NULL range PRIMARY,k1 k1 5 NULL 4 37.50 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`c1` AS `c1` from `test`.`t1` where (((`test`.`t1`.`pk` between 4 and 5) or (`test`.`t1`.`pk` < 2)) and (`test`.`t1`.`c1` < 240)) order by `test`.`t1`.`c1` limit 1 +DROP TABLE t1; +# +# Bug#42991 "invalid memory access and/or crash when using +# index condition pushdown + InnoDB" +# +CREATE TABLE t1 ( +c1 TINYTEXT NOT NULL, +c2 INT NOT NULL, +PRIMARY KEY (c2), +KEY id1 (c1(4)) +) charset utf8mb4; +INSERT INTO t1 VALUES ('Anastasia', 5); +INSERT INTO t1 VALUES ('Karianne', 4); +SELECT * FROM t1 WHERE (c1 <= '6566-06-15' AND c2 <> 3); +c1 c2 +EXPLAIN SELECT * FROM t1 WHERE (c1 <= '6566-06-15' AND c2 <> 3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range PRIMARY,id1 id1 18 NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c1` AS `c1`,`test`.`t1`.`c2` AS `c2` from `test`.`t1` where ((`test`.`t1`.`c1` <= '6566-06-15') and (`test`.`t1`.`c2` <> 3)) +DROP TABLE t1; +# +# Bug#56529 - "Crash due to long semaphore wait in InnoDB +# with ICP and subqueries" +# +CREATE TABLE t1 ( +col_int_nokey INTEGER, +col_int_key INTEGER, +col_varchar_key VARCHAR(1), +KEY (col_int_key), +KEY (col_varchar_key, col_int_key) +) charset utf8mb4 stats_persistent=0; +INSERT INTO t1 VALUES (NULL,2,'w'); +INSERT INTO t1 VALUES (7,9,'m'); +INSERT INTO t1 VALUES (9,3,'m'); +INSERT INTO t1 VALUES (7,9,'k'); +INSERT INTO t1 VALUES (4,NULL,'r'); +INSERT INTO t1 VALUES (2,9,'t'); +INSERT INTO t1 VALUES (6,3,'j'); +INSERT INTO t1 VALUES (8,8,'u'); +INSERT INTO t1 VALUES (NULL,8,'h'); +INSERT INTO t1 VALUES (5,53,'o'); +INSERT INTO t1 VALUES (NULL,0,NULL); +INSERT INTO t1 VALUES (6,5,'k'); +INSERT INTO t1 VALUES (188,166,'e'); +INSERT INTO t1 VALUES (2,3,'n'); +INSERT INTO t1 VALUES (1,0,'t'); +INSERT INTO t1 VALUES (1,1,'c'); +INSERT INTO t1 VALUES (0,9,'m'); +INSERT INTO t1 VALUES (9,5,'y'); +INSERT INTO t1 VALUES (NULL,6,'f'); +CREATE TABLE t2 ( +c1 INTEGER NOT NULL +) stats_persistent=0; +EXPLAIN SELECT table1.col_int_nokey +FROM t1 AS table1 STRAIGHT_JOIN ( +t1 AS table2 INNER JOIN t1 AS table3 +ON table3.col_varchar_key = table2.col_varchar_key) +ON table3.col_int_nokey = table1.col_int_key +WHERE table3.col_int_key != SOME ( SELECT c1 FROM t2 ); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY table1 NULL ALL col_int_key NULL NULL NULL 19 100.00 NULL +1 PRIMARY table3 NULL ALL col_varchar_key NULL NULL NULL 19 10.00 Using where; Using join buffer (hash join) +1 PRIMARY table2 NULL ref col_varchar_key col_varchar_key 7 test.table3.col_varchar_key 1 100.00 Using index +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`table1`.`col_int_nokey` AS `col_int_nokey` from `test`.`t1` `table1` join `test`.`t1` `table2` join `test`.`t1` `table3` where ((`test`.`table2`.`col_varchar_key` = `test`.`table3`.`col_varchar_key`) and (`test`.`table3`.`col_int_nokey` = `test`.`table1`.`col_int_key`) and ((`test`.`table3`.`col_int_key`,(/* select#2 */ select `test`.`t2`.`c1` from `test`.`t2` where (outer_field_is_not_null, ((`test`.`table3`.`col_int_key`) <> `test`.`t2`.`c1`), true))))) +SELECT table1.col_int_nokey +FROM t1 AS table1 STRAIGHT_JOIN ( +t1 AS table2 INNER JOIN t1 AS table3 +ON table3.col_varchar_key = table2.col_varchar_key) +ON table3.col_int_nokey = table1.col_int_key +WHERE table3.col_int_key != SOME ( SELECT c1 FROM t2 ); +col_int_nokey +DROP TABLE t1, t2; +# +# Bug#58243 "RQG test optimizer_subquery causes server crash +# when running with ICP" +# +CREATE TABLE t1 ( +pk INTEGER NOT NULL, +c1 INTEGER NOT NULL, +c2 INTEGER NOT NULL, +PRIMARY KEY (pk) +); +INSERT INTO t1 VALUES (1,6,7); +CREATE TABLE t2 ( +c1 INTEGER NOT NULL +); +EXPLAIN SELECT t1.c1 +FROM t1 +WHERE t1.pk < 317 AND 2 IN (SELECT COUNT(t2.c1) +FROM t2) +ORDER BY t1.c2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +2 SUBQUERY t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c1` AS `c1` from `test`.`t1` where false order by `test`.`t1`.`c2` +SELECT t1.c1 +FROM t1 +WHERE t1.pk < 317 AND 2 IN (SELECT COUNT(t2.c1) +FROM t2) +ORDER BY t1.c2; +c1 +DROP TABLE t1, t2; +CREATE TABLE t1 ( +i1 INTEGER NOT NULL, +c1 VARCHAR(1) NOT NULL +) charset latin1; +INSERT INTO t1 VALUES (2,'w'); +CREATE TABLE t2 ( +i1 INTEGER NOT NULL, +c1 VARCHAR(1) NOT NULL, +c2 VARCHAR(1) NOT NULL, +KEY (c1, i1) +) charset latin1; +INSERT INTO t2 VALUES (8,'d','d'); +INSERT INTO t2 VALUES (4,'v','v'); +CREATE TABLE t3 ( +c1 VARCHAR(1) NOT NULL +) charset latin1; +INSERT INTO t3 VALUES ('v'); +EXPLAIN SELECT i1 +FROM t1 +WHERE EXISTS (SELECT t2.c1 +FROM (t2 INNER JOIN t3 ON (t3.c1 = t2.c1)) +WHERE t2.c2 != t1.c1 AND t2.c2 = (SELECT MIN(t3.c1) +FROM t3)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 DEPENDENT SUBQUERY t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 DEPENDENT SUBQUERY t2 NULL ref c1 c1 3 test.t3.c1 1 50.00 Using where +3 SUBQUERY t3 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1276 Field or reference 'test.t1.c1' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i1` AS `i1` from `test`.`t1` where exists(/* select#2 */ select `test`.`t2`.`c1` from `test`.`t2` join `test`.`t3` where ((`test`.`t2`.`c1` = `test`.`t3`.`c1`) and (`test`.`t2`.`c2` = (/* select#3 */ select min(`test`.`t3`.`c1`) from `test`.`t3`)) and ((/* select#3 */ select min(`test`.`t3`.`c1`) from `test`.`t3`) <> `test`.`t1`.`c1`))) +SELECT i1 +FROM t1 +WHERE EXISTS (SELECT t2.c1 +FROM (t2 INNER JOIN t3 ON (t3.c1 = t2.c1)) +WHERE t2.c2 != t1.c1 AND t2.c2 = (SELECT MIN(t3.c1) +FROM t3)); +i1 +2 +DROP TABLE t1,t2,t3; +# +# Bug#58015 "Assert in row_sel_field_store_in_mysql_format +# when running innodb_mrr_icp test" +# +create table t1 (a char(2) charset utf8,b double, primary key (a(1)),key (b)); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +insert into t1 values ('',1); +select 1 from t1 where b <= 1 and a <> ''; +1 +drop table t1; +# +# Bug#59259 "Incorrect rows returned for a correlated subquery +# when ICP is on" +# +CREATE TABLE t1 (pk INTEGER PRIMARY KEY, i INTEGER NOT NULL) ENGINE=InnoDB; +INSERT INTO t1 VALUES (11,0); +INSERT INTO t1 VALUES (12,5); +INSERT INTO t1 VALUES (15,0); +CREATE TABLE t2 (pk INTEGER PRIMARY KEY, i INTEGER NOT NULL) ENGINE=InnoDB; +INSERT INTO t2 VALUES (11,1); +INSERT INTO t2 VALUES (12,2); +INSERT INTO t2 VALUES (15,4); +SELECT * FROM t1 +WHERE pk IN (SELECT it.pk FROM t2 JOIN t2 AS it ON it.i=it.i WHERE t1.i); +pk i +12 5 +DROP TABLE t1, t2; +# +# Bug #58816 "Extra temporary duplicate rows in result set when +# switching ICP off" +# +set @save_optimizer_switch_bug58816= @@optimizer_switch; +CREATE TABLE t1 ( +pk INT NOT NULL, +c1 INT NOT NULL, +PRIMARY KEY (pk) +); +INSERT INTO t1 VALUES (1,9),(2,7),(3,6),(4,3),(5,1); +EXPLAIN SELECT pk, c1 FROM t1 WHERE pk <> 3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (2 workers) +2 SIMPLE t1 NULL range PRIMARY PRIMARY 4 NULL 4 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`c1` AS `c1` from `test`.`t1` where (`test`.`t1`.`pk` <> 3) +SET SESSION optimizer_switch='index_condition_pushdown=off'; +SELECT pk, c1 FROM t1 WHERE pk <> 3; +pk c1 +1 9 +2 7 +4 3 +5 1 +DROP TABLE t1; +set optimizer_switch= @save_optimizer_switch_bug58816; +# +# Bug#58837: ICP crash or valgrind error due to uninitialized +# value in innobase_index_cond +# +CREATE TABLE t1 ( +t1_int INT, +t1_time TIME +); +CREATE TABLE t2 ( +t2_int int PRIMARY KEY, +t2_int2 INT +); +INSERT IGNORE INTO t2 VALUES (); +INSERT INTO t1 VALUES (); + +SELECT * +FROM t1 AS t1a +WHERE NOT EXISTS +(SELECT * +FROM t1 AS t1b +WHERE t1b.t1_int NOT IN +(SELECT t2.t2_int +FROM t2 +WHERE t1b.t1_time LIKE t1b.t1_int +OR t1b.t1_time <> t2.t2_int2 +AND 6=7 +) +) +;; +t1_int t1_time + +EXPLAIN SELECT * +FROM t1 AS t1a +WHERE NOT EXISTS +(SELECT * +FROM t1 AS t1b +WHERE t1b.t1_int NOT IN +(SELECT t2.t2_int +FROM t2 +WHERE t1b.t1_time LIKE t1b.t1_int +OR t1b.t1_time <> t2.t2_int2 +AND 6=7 +) +) +;; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +2 SUBQUERY t1b NULL ALL NULL NULL NULL NULL 1 100.00 Using where +3 DEPENDENT SUBQUERY t2 NULL unique_subquery PRIMARY PRIMARY 4 func 1 100.00 Using where; Full scan on NULL key +Warnings: +Note 1276 Field or reference 'test.t1b.t1_time' of SELECT #3 was resolved in SELECT #2 +Note 1276 Field or reference 'test.t1b.t1_int' of SELECT #3 was resolved in SELECT #2 +Note 1276 Field or reference 'test.t1b.t1_time' of SELECT #3 was resolved in SELECT #2 +Note 1003 /* select#1 */ select `test`.`t1a`.`t1_int` AS `t1_int`,`test`.`t1a`.`t1_time` AS `t1_time` from `test`.`t1` `t1a` where false + +DROP TABLE t1,t2; +# +# Bug#59186 Wrong results of join when ICP is enabled +# +CREATE TABLE t1 ( +pk INTEGER NOT NULL, +c1 VARCHAR(3) NOT NULL, +PRIMARY KEY (pk) +); +INSERT INTO t1 VALUES (1,'y'),(0,'or'); +CREATE TABLE t2 ( +pk INTEGER NOT NULL, +c1 VARCHAR(3) NOT NULL, +c2 VARCHAR(6) NOT NULL, +PRIMARY KEY (pk) +); +INSERT INTO t2 VALUES (6,'y','RPOYT'),(10,'m','JINQE'); +EXPLAIN SELECT c2 FROM t1 JOIN t2 ON t1.c1 = t2.c1 +WHERE (t2.pk <= 4 AND t1.pk IN (2,1)) OR +(t1.pk > 1 AND t2.pk BETWEEN 6 AND 6); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range PRIMARY PRIMARY 4 NULL 1 100.00 Using where +2 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`c2` AS `c2` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`c1` = `test`.`t1`.`c1`) and (((`test`.`t2`.`pk` <= 4) and (`test`.`t1`.`pk` in (2,1))) or ((`test`.`t1`.`pk` > 1) and (`test`.`t2`.`pk` between 6 and 6)))) +SELECT c2 FROM t1 JOIN t2 ON t1.c1 = t2.c1 +WHERE (t2.pk <= 4 AND t1.pk IN (2,1)) OR +(t1.pk > 1 AND t2.pk BETWEEN 6 AND 6); +c2 +DROP TABLE t1, t2; +# +# Bug#58838 "Wrong results with HAVING + LIMIT without GROUP BY when +# ICP is enabled" +# +CREATE TABLE t1 ( +pk INT NOT NULL, +c1 INT, +PRIMARY KEY (pk), +KEY col_int_key (c1) +); +INSERT INTO t1 VALUES (1,37),(2,8),(3,-25),(4,NULL),(5,55); +SELECT pk FROM t1 WHERE c1 <> 1 HAVING pk = 3 ORDER BY pk LIMIT 0; +pk +SELECT pk FROM t1 WHERE c1 <> 1 HAVING pk = 3 ORDER BY pk LIMIT 1; +pk +3 +SELECT pk FROM t1 WHERE c1 <> 1 HAVING pk = 3 ORDER BY pk LIMIT 2; +pk +3 +SELECT pk FROM t1 WHERE c1 <> 1 HAVING pk = 3 ORDER BY pk LIMIT 5; +pk +3 +DROP TABLE t1; +# +# Bug#59483 "Crash on INSERT/REPLACE in +# rec_convert_dtuple_to_rec_comp with ICP on" +# +CREATE TABLE t1 ( +pk INTEGER AUTO_INCREMENT PRIMARY KEY, +i1 INTEGER, +c1 CHAR(6), +i2 INTEGER NOT NULL, +KEY (i2) +); +INSERT INTO t1 VALUES +(NULL, 4, 'that', 8), +(NULL, 1, 'she', 6), +(NULL, 6, 'tell', 2); +SELECT * FROM t1 WHERE i2 IN (3, 6) LIMIT 2 FOR UPDATE; +pk i1 c1 i2 +2 1 she 6 +INSERT INTO t1 (i2) VALUES (1); +DROP TABLE t1; +# +# Bug #11766678 - 59843: +# USING UNINITIALISED VALUE IN USES_INDEX_FIELDS_ONLY +# +CREATE TABLE t1 ( +col999 FLOAT NOT NULL, +COL1000 VARBINARY(179) NOT NULL, +col1003 DATE DEFAULT NULL, +KEY idx4267 (col1000, col1003) +); +INSERT IGNORE INTO t1 VALUES (),(); +Warnings: +Warning 1364 Field 'col999' doesn't have a default value +Warning 1364 Field 'COL1000' doesn't have a default value +SELECT col999 FROM t1 WHERE col1000 = "3" AND col1003 <=> sysdate(); +col999 +DROP TABLE t1; +# +# Bug#11873324 "WRONG RESULT WITH ICP AND STRAIGHT_JOIN" +# +CREATE TABLE t1 ( +pk INTEGER NOT NULL, +i1 INTEGER, +PRIMARY KEY (pk), +KEY col_int_key (i1) +); +INSERT INTO t1 VALUES (14,NULL), (18,133); +CREATE TABLE t2 ( +pk INTEGER NOT NULL, +i1 INTEGER, +c1 VARCHAR(1), +PRIMARY KEY (pk), +KEY col_int_key (i1) +); +INSERT INTO t2 VALUES (1,7,'f'); +set @old_opt_switch=@@optimizer_switch; +EXPLAIN SELECT t1.i1 +FROM t1 +WHERE t1.i1 NOT IN +( SELECT STRAIGHT_JOIN subquery_t1.pk +FROM t1 AS subquery_t1 +JOIN t2 AS subquery_t2 +ON subquery_t2.i1 = subquery_t1.pk +WHERE subquery_t1.i1 > 0 +OR subquery_t2.c1 = 'a' +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL index NULL col_int_key 5 NULL 2 100.00 Using where; Using index +2 DEPENDENT SUBQUERY subquery_t1 NULL eq_ref PRIMARY,col_int_key PRIMARY 4 func 1 100.00 Using where; Full scan on NULL key +2 DEPENDENT SUBQUERY subquery_t2 NULL ref col_int_key col_int_key 5 func 1 100.00 Using where; Full scan on NULL key +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i1` AS `i1` from `test`.`t1` where (`test`.`t1`.`i1`,(/* select#2 */ select straight_join `test`.`subquery_t1`.`pk` from `test`.`t1` `subquery_t1` join `test`.`t2` `subquery_t2` where ((`test`.`subquery_t2`.`i1` = `test`.`subquery_t1`.`pk`) and ((`test`.`subquery_t1`.`i1` > 0) or (`test`.`subquery_t2`.`c1` = 'a')) and (outer_field_is_not_null, ((`test`.`t1`.`i1`) = `test`.`subquery_t1`.`pk`), true))) is false) +SELECT t1.i1 +FROM t1 +WHERE t1.i1 NOT IN +( SELECT STRAIGHT_JOIN subquery_t1.pk +FROM t1 AS subquery_t1 +JOIN t2 AS subquery_t2 +ON subquery_t2.i1 = subquery_t1.pk +WHERE subquery_t1.i1 > 0 +OR subquery_t2.c1 = 'a' +); +i1 +NULL +133 +set @@optimizer_switch=@old_opt_switch; +DROP TABLE t1,t2; +# +# Bug#11876420 "MISSING ROW IN RESULT WITH SUBQUERY + IN + XOR + +# NULL VALUES AND ICP ENABLED" +# +CREATE TABLE t1 ( +i1 INTEGER, +c1 VARCHAR(1), +KEY col_varchar_key (c1) +) charset utf8mb4; +INSERT INTO t1 VALUES (1,'j'), (0,'e'), (210,'f'), (8,'v'), (7,'x'), +(5,'m'), (NULL,'c'); +CREATE TABLE t2 ( +i1 INTEGER, +c1 VARCHAR(1), +KEY col_varchar_key (c1) +) charset utf8mb4; +INSERT INTO t2 VALUES (8,NULL); +CREATE TABLE t3 ( +i1 INTEGER, +c1 VARCHAR(1), +KEY col_varchar_key (c1) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t3 VALUES (NULL,'w'), (1,NULL), (2,'d'); +set @old_opt_switch=@@optimizer_switch; +EXPLAIN SELECT i1 +FROM t3 +WHERE c1 IN +( SELECT t1.c1 +FROM t2 JOIN t1 +ON t2.i1 >= t1.i1 +WHERE t1.c1 > t2.c1 +) +XOR i1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t3 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t2 NULL ALL col_varchar_key NULL NULL NULL 1 100.00 NULL +2 DEPENDENT SUBQUERY t1 NULL ref_or_null col_varchar_key col_varchar_key 7 func 2 33.33 Using where; Full scan on NULL key +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`i1` AS `i1` from `test`.`t3` where ((`test`.`t3`.`c1`,(/* select#2 */ select `test`.`t1`.`c1` from `test`.`t2` join `test`.`t1` where ((`test`.`t1`.`c1` > `test`.`t2`.`c1`) and (outer_field_is_not_null, (((`test`.`t3`.`c1`) = `test`.`t1`.`c1`) or (`test`.`t1`.`c1` is null)), true) and (`test`.`t2`.`i1` >= `test`.`t1`.`i1`)) having (outer_field_is_not_null, (`test`.`t1`.`c1`), true))) xor (0 <> `test`.`t3`.`i1`)) +SELECT i1 +FROM t3 +WHERE c1 IN +( SELECT t1.c1 +FROM t2 JOIN t1 +ON t2.i1 >= t1.i1 +WHERE t1.c1 > t2.c1 +) +XOR i1; +i1 +1 +2 +set @@optimizer_switch=@old_opt_switch; +DROP TABLE t1, t2, t3; +# +# Bug#12355958 "FAILING ASSERTION: TRX->LOCK.N_ACTIVE_THRS == 1" +# +CREATE TABLE t1 ( +pk INTEGER PRIMARY KEY, +a INTEGER NOT NULL, +b CHAR(1), +KEY(b) +) charset utf8mb4; +INSERT INTO t1 VALUES (23,5,'d'); +EXPLAIN SELECT a1.pk +FROM t1 AS a1 JOIN (SELECT * FROM t1 LIMIT 1) AS a2 ON a2.b = a1.b +WHERE a1.a = (SELECT pk FROM t1 LIMIT 1) +AND (a1.a != a2.a OR a1.b IS NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL system NULL NULL NULL NULL 1 100.00 NULL +1 PRIMARY a1 NULL ref b b 5 const 1 100.00 Using where +3 SUBQUERY t1 NULL index NULL b 5 NULL 1 100.00 Using index +2 DERIVED t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`a1`.`pk` AS `pk` from `test`.`t1` `a1` where ((`test`.`a1`.`b` = 'd') and (`test`.`a1`.`a` = (/* select#3 */ select `test`.`t1`.`pk` from `test`.`t1` limit 1)) and (((/* select#3 */ select `test`.`t1`.`pk` from `test`.`t1` limit 1) <> '5') or (`test`.`a1`.`b` is null))) +SELECT a1.pk +FROM t1 AS a1 JOIN (SELECT * FROM t1 LIMIT 1) AS a2 ON a2.b = a1.b +WHERE a1.a = (SELECT pk FROM t1 LIMIT 1) +AND (a1.a != a2.a OR a1.b IS NULL); +pk +CREATE VIEW v1 AS SELECT * FROM t1; +EXPLAIN SELECT a1.pk +FROM v1 AS a1 JOIN (SELECT * FROM v1 LIMIT 1) AS a2 ON a2.b = a1.b +WHERE a1.a = (SELECT pk FROM v1 LIMIT 1) +AND (a1.a != a2.a OR a1.b IS NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL system NULL NULL NULL NULL 1 100.00 NULL +1 PRIMARY t1 NULL ref b b 5 const 1 100.00 Using where +3 SUBQUERY t1 NULL index NULL b 5 NULL 1 100.00 Using index +2 DERIVED t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` where ((`test`.`t1`.`b` = 'd') and (`test`.`t1`.`a` = (/* select#3 */ select `test`.`t1`.`pk` from `test`.`t1` limit 1)) and ((`test`.`t1`.`a` <> '5') or (`test`.`t1`.`b` is null))) +SELECT a1.pk +FROM v1 AS a1 JOIN (SELECT * FROM v1 LIMIT 1) AS a2 ON a2.b = a1.b +WHERE a1.a = (SELECT pk FROM v1 LIMIT 1) +AND (a1.a != a2.a OR a1.b IS NULL); +pk +DROP VIEW v1; +DROP TABLE t1; +# +# BUG#12601961 "SEGFAULT IN HANDLER::COMPARE_KEY2" +# BUG#12724899 "SELECT STRAIGHT_JOIN QUERY GIVES 2 DATES VERSUS +# 2 WARNINGS WITH ICP ON" +# +CREATE TABLE t1 ( +pk INTEGER NOT NULL, +i1 INTEGER NOT NULL, +c1 VARCHAR(1) NOT NULL, +PRIMARY KEY (pk) +); +INSERT INTO t1 VALUES (1,3,'j'), (20,8,'e'); +EXPLAIN SELECT alias2.i1 +FROM t1 AS alias1 STRAIGHT_JOIN t1 AS alias2 +ON alias2.pk AND alias2.pk <= alias1.c1 +WHERE alias2.pk = 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE alias1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 SIMPLE alias2 NULL const PRIMARY PRIMARY 4 const 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`alias2`.`i1` AS `i1` from `test`.`t1` `alias1` straight_join `test`.`t1` `alias2` where ((`test`.`alias2`.`pk` = 1) and (cast(`test`.`alias2`.`pk` as double) <= cast(`test`.`alias1`.`c1` as double))) +SELECT alias2.i1 +FROM t1 AS alias1 STRAIGHT_JOIN t1 AS alias2 +ON alias2.pk AND alias2.pk <= alias1.c1 +WHERE alias2.pk = 1; +i1 +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'j' +Warning 1292 Truncated incorrect DOUBLE value: 'e' +DROP TABLE t1; +# +# BUG#12822678 - 2 MORE ROWS WHEN ICP=ON W/ STRAIGHT_JOIN +# +CREATE TABLE t1 ( +i1 INTEGER NOT NULL, +d1 DOUBLE, +KEY k1 (d1) +); +INSERT INTO t1 VALUES (10,1), (17,NULL), (22,NULL); +CREATE TABLE t2 ( +pk INTEGER NOT NULL, +i1 INTEGER NOT NULL, +PRIMARY KEY (pk) +); +INSERT INTO t2 VALUES (4,1); +EXPLAIN SELECT t1.d1, t2.pk, t2.i1 +FROM t1 STRAIGHT_JOIN t2 ON t2.i1 +WHERE t2.pk <> t1.d1 AND t2.pk = 4; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL k1 9 NULL 3 100.00 Using index +2 SIMPLE t2 NULL const PRIMARY PRIMARY 4 const 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`d1` AS `d1`,`test`.`t2`.`pk` AS `pk`,`test`.`t2`.`i1` AS `i1` from `test`.`t1` straight_join `test`.`t2` where ((`test`.`t2`.`pk` = 4) and (`test`.`t2`.`pk` <> `test`.`t1`.`d1`) and (0 <> `test`.`t2`.`i1`)) +SELECT t1.d1, t2.pk, t2.i1 +FROM t1 STRAIGHT_JOIN t2 ON t2.i1 +WHERE t2.pk <> t1.d1 AND t2.pk = 4; +d1 pk i1 +1 4 1 +DROP TABLE t1, t2; +# +# BUG#12838420 "DUPLICATE VALUES FOR GROUP-BY COLUMN WHEN JOIN +# BUFFERING IS OFF" +# +CREATE TABLE t1 ( +col_int_key INT, +pk INT, +PRIMARY KEY (pk), +KEY (col_int_key) +); +INSERT INTO t1 VALUES (2,3),(3,2),(3,5),(4,6); +CREATE TABLE t2 ( +col_int_key INT, +pk INT, +PRIMARY KEY (pk), +KEY (col_int_key) +); +INSERT INTO t2 VALUES (0,9),(3,10),(4,6),(6,1),(100,3),(200,5); +set @old_opt_switch=@@optimizer_switch; +SET optimizer_switch="block_nested_loop=off"; +EXPLAIN SELECT t2.col_int_key AS field1 +FROM t2 USE INDEX(col_int_key) STRAIGHT_JOIN t1 ON t2.col_int_key +WHERE t2.pk < 7 AND t2.col_int_key <> 7 +GROUP BY field1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 6 33.33 Parallel execute (1 workers) +2 SIMPLE t2 NULL index col_int_key col_int_key 5 NULL 6 33.33 Using where; Using index +2 SIMPLE t1 NULL index NULL col_int_key 5 NULL 4 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`col_int_key` AS `field1` from `test`.`t2` USE INDEX (`col_int_key`) straight_join `test`.`t1` where ((`test`.`t2`.`pk` < 7) and (`test`.`t2`.`col_int_key` <> 7) and (0 <> `test`.`t2`.`col_int_key`)) group by `field1` +SELECT t2.col_int_key AS field1 +FROM t2 USE INDEX(col_int_key) STRAIGHT_JOIN t1 ON t2.col_int_key +WHERE t2.pk < 7 AND t2.col_int_key <> 7 +GROUP BY field1; +field1 +4 +6 +100 +200 +SET @@optimizer_switch=@old_opt_switch; +DROP TABLE t1,t2; +# +# Bug#12976163 "CRASH IN INDEX CONDITION PUSHDOWN CODE AGAINST +# A MYISAM TABLE" +# +CREATE TABLE t1 ( +i1 INTEGER NOT NULL, +i2 INTEGER NOT NULL +); +INSERT INTO t1 VALUES (14,1), (15,2), (16,3); +CREATE TABLE t2 ( +i1 INTEGER NOT NULL, +i2 INTEGER NOT NULL, +c1 TINYTEXT +); +INSERT INTO t2 +SELECT i1, 10 * i2, "MySQL" FROM t1; +CREATE PROCEDURE proc1(id INTEGER) +BEGIN +SELECT i2 +FROM ( +(SELECT i1, i2, NULL AS a1 FROM t1) +UNION +(SELECT i1, i2, c1 AS a1 FROM t2) +) u1 +WHERE i1 = id; +END$$ +CALL proc1(15); +i2 +2 +20 +DROP PROCEDURE proc1; +DROP TABLE t1, t2; +# +# Bug#13655397 "CRASH IN SYNC_THREAD_LEVELS_NONEMPTY_TRX" +# +CREATE TABLE t1 ( +i1 INTEGER NOT NULL, +i2 INTEGER NOT NULL, +KEY (i1) +); +INSERT INTO t1 VALUES (4,4), (5,5); +CREATE TABLE t2 ( +pk INTEGER NOT NULL, +PRIMARY KEY (pk) +); +INSERT INTO t2 VALUES (1); +CREATE FUNCTION f1() RETURNS INTEGER +RETURN (SELECT MOD(COUNT(DISTINCT pk), 10) FROM t2); +EXPLAIN SELECT i1, i2 FROM t1 WHERE f1() = 1 AND i1 = 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ref i1 i1 4 const 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i1` AS `i1`,`test`.`t1`.`i2` AS `i2` from `test`.`t1` where ((`test`.`t1`.`i1` = 5) and (`f1`() = 1)) +SELECT i1, i2 FROM t1 WHERE f1() = 1 AND i1 = 5; +i1 i2 +5 5 +DROP FUNCTION f1; +DROP TABLE t1, t2; +set default_storage_engine= @save_storage_engine; +set optimizer_switch=default; diff --git a/mysql-test/r/innodb_mrr.result-pq b/mysql-test/r/innodb_mrr.result-pq new file mode 100644 index 000000000000..8a815a8c866c --- /dev/null +++ b/mysql-test/r/innodb_mrr.result-pq @@ -0,0 +1,801 @@ +set optimizer_switch='mrr=on,mrr_cost_based=off'; +set @save_storage_engine= @@default_storage_engine; +set default_storage_engine=InnoDB; +create table t1(a int) charset utf8mb4; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t2(a int); +insert into t2 select A.a + 10*(B.a + 10*C.a) from t1 A, t1 B, t1 C; +create table t3 ( +a char(8) not null, b char(8) not null, filler char(200), +key(a) +); +insert into t3 select @a:=concat('c-', 1000+ A.a, '=w'), @a, 'filler' from t2 A; +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +insert into t3 select concat('c-', 1000+A.a, '=w'), concat('c-', 2000+A.a, '=w'), +'filler-1' from t2 A; +insert into t3 select concat('c-', 1000+A.a, '=w'), concat('c-', 3000+A.a, '=w'), +'filler-2' from t2 A; +select a,filler from t3 where a >= 'c-9011=w'; +a filler +select a,filler from t3 where a >= 'c-1011=w' and a <= 'c-1015=w'; +a filler +c-1011=w filler +c-1011=w filler-1 +c-1011=w filler-2 +c-1012=w filler +c-1012=w filler-1 +c-1012=w filler-2 +c-1013=w filler +c-1013=w filler-1 +c-1013=w filler-2 +c-1014=w filler +c-1014=w filler-1 +c-1014=w filler-2 +c-1015=w filler +c-1015=w filler-1 +c-1015=w filler-2 +select a,filler from t3 where (a>='c-1011=w' and a <= 'c-1013=w') or +(a>='c-1014=w' and a <= 'c-1015=w'); +a filler +c-1011=w filler +c-1011=w filler-1 +c-1011=w filler-2 +c-1012=w filler +c-1012=w filler-1 +c-1012=w filler-2 +c-1013=w filler +c-1013=w filler-1 +c-1013=w filler-2 +c-1014=w filler +c-1014=w filler-1 +c-1014=w filler-2 +c-1015=w filler +c-1015=w filler-1 +c-1015=w filler-2 +insert into t3 values ('c-1013=z', 'c-1013=z', 'err'); +insert into t3 values ('a-1014=w', 'a-1014=w', 'err'); +select a,filler from t3 where (a>='c-1011=w' and a <= 'c-1013=w') or +(a>='c-1014=w' and a <= 'c-1015=w'); +a filler +c-1011=w filler +c-1011=w filler-1 +c-1011=w filler-2 +c-1012=w filler +c-1012=w filler-1 +c-1012=w filler-2 +c-1013=w filler +c-1013=w filler-1 +c-1013=w filler-2 +c-1014=w filler +c-1014=w filler-1 +c-1014=w filler-2 +c-1015=w filler +c-1015=w filler-1 +c-1015=w filler-2 +delete from t3 where b in ('c-1013=z', 'a-1014=w'); +select a,filler from t3 where a='c-1011=w' or a='c-1012=w' or a='c-1013=w' or +a='c-1014=w' or a='c-1015=w'; +a filler +c-1011=w filler +c-1011=w filler-1 +c-1011=w filler-2 +c-1012=w filler +c-1012=w filler-1 +c-1012=w filler-2 +c-1013=w filler +c-1013=w filler-1 +c-1013=w filler-2 +c-1014=w filler +c-1014=w filler-1 +c-1014=w filler-2 +c-1015=w filler +c-1015=w filler-1 +c-1015=w filler-2 +insert into t3 values ('c-1013=w', 'del-me', 'inserted'); +select a,filler from t3 where a='c-1011=w' or a='c-1012=w' or a='c-1013=w' or +a='c-1014=w' or a='c-1015=w'; +a filler +c-1011=w filler +c-1011=w filler-1 +c-1011=w filler-2 +c-1012=w filler +c-1012=w filler-1 +c-1012=w filler-2 +c-1013=w filler +c-1013=w filler-1 +c-1013=w filler-2 +c-1013=w inserted +c-1014=w filler +c-1014=w filler-1 +c-1014=w filler-2 +c-1015=w filler +c-1015=w filler-1 +c-1015=w filler-2 +delete from t3 where b='del-me'; +alter table t3 add primary key(b); +select b,filler from t3 where (b>='c-1011=w' and b<= 'c-1018=w') or +b IN ('c-1019=w', 'c-1020=w', 'c-1021=w', +'c-1022=w', 'c-1023=w', 'c-1024=w'); +b filler +c-1011=w filler +c-1012=w filler +c-1013=w filler +c-1014=w filler +c-1015=w filler +c-1016=w filler +c-1017=w filler +c-1018=w filler +c-1019=w filler +c-1020=w filler +c-1021=w filler +c-1022=w filler +c-1023=w filler +c-1024=w filler +select b,filler from t3 where (b>='c-1011=w' and b<= 'c-1020=w') or +b IN ('c-1021=w', 'c-1022=w', 'c-1023=w'); +b filler +c-1011=w filler +c-1012=w filler +c-1013=w filler +c-1014=w filler +c-1015=w filler +c-1016=w filler +c-1017=w filler +c-1018=w filler +c-1019=w filler +c-1020=w filler +c-1021=w filler +c-1022=w filler +c-1023=w filler +select b,filler from t3 where (b>='c-1011=w' and b<= 'c-1018=w') or +b IN ('c-1019=w', 'c-1020=w') or +(b>='c-1021=w' and b<= 'c-1023=w'); +b filler +c-1011=w filler +c-1012=w filler +c-1013=w filler +c-1014=w filler +c-1015=w filler +c-1016=w filler +c-1017=w filler +c-1018=w filler +c-1019=w filler +c-1020=w filler +c-1021=w filler +c-1022=w filler +c-1023=w filler +create table t4 (a varchar(10), b int, c char(10), filler char(200), +key idx1 (a, b, c)) charset utf8mb4; +insert into t4 (filler) select concat('NULL-', 15-a) from t2 order by a limit 15; +insert into t4 (a,b,c,filler) +select 'b-1',NULL,'c-1', concat('NULL-', 15-a) from t2 order by a limit 15; +insert into t4 (a,b,c,filler) +select 'b-1',NULL,'c-222', concat('NULL-', 15-a) from t2 order by a limit 15; +insert into t4 (a,b,c,filler) +select 'bb-1',NULL,'cc-2', concat('NULL-', 15-a) from t2 order by a limit 15; +insert into t4 (a,b,c,filler) +select 'zz-1',NULL,'cc-2', 'filler-data' from t2 order by a limit 500; +explain +select * from t4 where a IS NULL and b IS NULL and (c IS NULL or c='no-such-row1' + or c='no-such-row2'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 16 100.00 Parallel execute (2 workers) +2 SIMPLE t4 NULL range idx1 idx1 89 NULL 16 100.00 Using where; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t4`.`c` AS `c`,`test`.`t4`.`filler` AS `filler` from `test`.`t4` where ((`test`.`t4`.`a` is null) and (`test`.`t4`.`b` is null) and ((`test`.`t4`.`c` is null) or (`test`.`t4`.`c` = 'no-such-row1') or (`test`.`t4`.`c` = 'no-such-row2'))) +select * from t4 where a IS NULL and b IS NULL and (c IS NULL or c='no-such-row1' + or c='no-such-row2'); +a b c filler +NULL NULL NULL NULL-15 +NULL NULL NULL NULL-14 +NULL NULL NULL NULL-13 +NULL NULL NULL NULL-12 +NULL NULL NULL NULL-11 +NULL NULL NULL NULL-10 +NULL NULL NULL NULL-9 +NULL NULL NULL NULL-8 +NULL NULL NULL NULL-7 +NULL NULL NULL NULL-6 +NULL NULL NULL NULL-5 +NULL NULL NULL NULL-4 +NULL NULL NULL NULL-3 +NULL NULL NULL NULL-2 +NULL NULL NULL NULL-1 +explain +select * from t4 where (a ='b-1' or a='bb-1') and b IS NULL and (c='c-1' or c='cc-2'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 32 100.00 Parallel execute (4 workers) +2 SIMPLE t4 NULL range idx1 idx1 89 NULL 32 100.00 Using where; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t4`.`c` AS `c`,`test`.`t4`.`filler` AS `filler` from `test`.`t4` where (((`test`.`t4`.`a` = 'b-1') or (`test`.`t4`.`a` = 'bb-1')) and (`test`.`t4`.`b` is null) and ((`test`.`t4`.`c` = 'c-1') or (`test`.`t4`.`c` = 'cc-2'))) +select * from t4 where (a ='b-1' or a='bb-1') and b IS NULL and (c='c-1' or c='cc-2'); +a b c filler +b-1 NULL c-1 NULL-15 +b-1 NULL c-1 NULL-14 +b-1 NULL c-1 NULL-13 +b-1 NULL c-1 NULL-12 +b-1 NULL c-1 NULL-11 +b-1 NULL c-1 NULL-10 +b-1 NULL c-1 NULL-9 +b-1 NULL c-1 NULL-8 +b-1 NULL c-1 NULL-7 +b-1 NULL c-1 NULL-6 +b-1 NULL c-1 NULL-5 +b-1 NULL c-1 NULL-4 +b-1 NULL c-1 NULL-3 +b-1 NULL c-1 NULL-2 +b-1 NULL c-1 NULL-1 +bb-1 NULL cc-2 NULL-15 +bb-1 NULL cc-2 NULL-14 +bb-1 NULL cc-2 NULL-13 +bb-1 NULL cc-2 NULL-12 +bb-1 NULL cc-2 NULL-11 +bb-1 NULL cc-2 NULL-10 +bb-1 NULL cc-2 NULL-9 +bb-1 NULL cc-2 NULL-8 +bb-1 NULL cc-2 NULL-7 +bb-1 NULL cc-2 NULL-6 +bb-1 NULL cc-2 NULL-5 +bb-1 NULL cc-2 NULL-4 +bb-1 NULL cc-2 NULL-3 +bb-1 NULL cc-2 NULL-2 +bb-1 NULL cc-2 NULL-1 +select * from t4 ignore index(idx1) where (a ='b-1' or a='bb-1') and b IS NULL and (c='c-1' or c='cc-2'); +a b c filler +b-1 NULL c-1 NULL-15 +b-1 NULL c-1 NULL-14 +b-1 NULL c-1 NULL-13 +b-1 NULL c-1 NULL-12 +b-1 NULL c-1 NULL-11 +b-1 NULL c-1 NULL-10 +b-1 NULL c-1 NULL-9 +b-1 NULL c-1 NULL-8 +b-1 NULL c-1 NULL-7 +b-1 NULL c-1 NULL-6 +b-1 NULL c-1 NULL-5 +b-1 NULL c-1 NULL-4 +b-1 NULL c-1 NULL-3 +b-1 NULL c-1 NULL-2 +b-1 NULL c-1 NULL-1 +bb-1 NULL cc-2 NULL-15 +bb-1 NULL cc-2 NULL-14 +bb-1 NULL cc-2 NULL-13 +bb-1 NULL cc-2 NULL-12 +bb-1 NULL cc-2 NULL-11 +bb-1 NULL cc-2 NULL-10 +bb-1 NULL cc-2 NULL-9 +bb-1 NULL cc-2 NULL-8 +bb-1 NULL cc-2 NULL-7 +bb-1 NULL cc-2 NULL-6 +bb-1 NULL cc-2 NULL-5 +bb-1 NULL cc-2 NULL-4 +bb-1 NULL cc-2 NULL-3 +bb-1 NULL cc-2 NULL-2 +bb-1 NULL cc-2 NULL-1 +drop table t1, t2, t3, t4; +create table t1 (a int, b int not null,unique key (a,b),index(b)); +insert ignore into t1 values (1,1),(2,2),(3,3),(4,4),(5,5),(6,6),(null,7),(9,9),(8,8),(7,7),(null,9),(null,9),(6,6); +Warnings: +Warning 1062 Duplicate entry '6-6' for key 't1.a' +create table t2 like t1; +insert into t2 select * from t1; +alter table t1 modify b blob not null, add c int not null, drop key a, add unique key (a,b(20),c), drop key b, add key (b(10)); +select * from t1 where a is null; +a b c +NULL 7 0 +NULL 9 0 +NULL 9 0 +select * from t1 where (a is null or a > 0 and a < 3) and b > 7 limit 3; +a b c +NULL 9 0 +NULL 9 0 +select * from t1 where a is null and b=9 or a is null and b=7 limit 3; +a b c +NULL 7 0 +NULL 9 0 +NULL 9 0 +drop table t1, t2; +CREATE TABLE t1 ( +ID int(10) unsigned NOT NULL AUTO_INCREMENT, +col1 int(10) unsigned DEFAULT NULL, +key1 int(10) unsigned NOT NULL DEFAULT '0', +key2 int(10) unsigned DEFAULT NULL, +text1 text, +text2 text, +col2 smallint(6) DEFAULT '100', +col3 enum('headers','bodyandsubject') NOT NULL DEFAULT 'bodyandsubject', +col4 tinyint(3) unsigned NOT NULL DEFAULT '0', +PRIMARY KEY (ID), +KEY (key1), +KEY (key2) +) AUTO_INCREMENT=6 DEFAULT CHARSET=utf8; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES +(1,NULL,1130,NULL,'Hello',NULL,100,'bodyandsubject',0), +(2,NULL,1130,NULL,'bye',NULL,100,'bodyandsubject',0), +(3,NULL,1130,NULL,'red',NULL,100,'bodyandsubject',0), +(4,NULL,1130,NULL,'yellow',NULL,100,'bodyandsubject',0), +(5,NULL,1130,NULL,'blue',NULL,100,'bodyandsubject',0); +select * FROM t1 WHERE key1=1130 AND col1 IS NULL ORDER BY text1; +ID col1 key1 key2 text1 text2 col2 col3 col4 +5 NULL 1130 NULL blue NULL 100 bodyandsubject 0 +2 NULL 1130 NULL bye NULL 100 bodyandsubject 0 +1 NULL 1130 NULL Hello NULL 100 bodyandsubject 0 +3 NULL 1130 NULL red NULL 100 bodyandsubject 0 +4 NULL 1130 NULL yellow NULL 100 bodyandsubject 0 +drop table t1; + +BUG#37851: Crash in test_if_skip_sort_order tab->select is zero + +CREATE TABLE t1 ( +pk int(11) NOT NULL AUTO_INCREMENT, +PRIMARY KEY (pk) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (1); +CREATE TABLE t2 ( +pk int(11) NOT NULL AUTO_INCREMENT, +int_key int(11) DEFAULT NULL, +PRIMARY KEY (pk), +KEY int_key (int_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (1,1),(2,6),(3,0); +EXPLAIN +SELECT MIN(t1.pk) +FROM t1 WHERE EXISTS ( +SELECT t2.pk +FROM t2 +WHERE t2.int_key IS NULL +GROUP BY t2.pk +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +2 SUBQUERY t2 NULL ref int_key int_key 5 const 1 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select min(`test`.`t1`.`pk`) AS `MIN(t1.pk)` from `test`.`t1` where false +DROP TABLE t1, t2; +# +# BUG#42048 Discrepancy between MyISAM and Maria's ICP implementation +# +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (a int, b char(20), filler char(200), key(a,b(10))); +insert into t1 select A.a + 10*(B.a + 10*C.a), 'bbb','filler' from t0 A, t0 B, t0 C; +update t1 set b=repeat(char(65+a), 20) where a < 25; +This must show range + using index condition: +explain select * from t1 where a < 10 and b = repeat(char(65+a), 20); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL x x Parallel execute (1 workers) +2 SIMPLE t1 NULL range a a 5 NULL x x Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`filler` AS `filler` from `test`.`t1` where ((`test`.`t1`.`a` < 10) and (`test`.`t1`.`b` = repeat(char((65 + `test`.`t1`.`a`)),20))) +select * from t1 where a < 10 and b = repeat(char(65+a), 20); +a b filler +0 AAAAAAAAAAAAAAAAAAAA filler +1 BBBBBBBBBBBBBBBBBBBB filler +2 CCCCCCCCCCCCCCCCCCCC filler +3 DDDDDDDDDDDDDDDDDDDD filler +4 EEEEEEEEEEEEEEEEEEEE filler +5 FFFFFFFFFFFFFFFFFFFF filler +6 GGGGGGGGGGGGGGGGGGGG filler +7 HHHHHHHHHHHHHHHHHHHH filler +8 IIIIIIIIIIIIIIIIIIII filler +9 JJJJJJJJJJJJJJJJJJJJ filler +drop table t0,t1; +# +# BUG#41136: ORDER BY + range access: EXPLAIN shows "Using MRR" while MRR is actually not used +# +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (a int, b int, key(a)); +insert into t1 select A.a + 10 *(B.a + 10*C.a), A.a + 10 *(B.a + 10*C.a) from t0 A, t0 B, t0 C; +This mustn't show "Using MRR": +explain select * from t1 where a < 20 order by a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 20 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range a a 5 NULL 20 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (`test`.`t1`.`a` < 20) order by `test`.`t1`.`a` +drop table t0, t1; +set @read_rnd_buffer_size_save= @@read_rnd_buffer_size; +set read_rnd_buffer_size=64; +create table t1(a int); +insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t2(a char(8), b char(8), c char(8), filler char(100), key k1(a,b,c) ) charset utf8mb4; +insert into t2 select +concat('a-', 1000 + A.a, '-a'), +concat('b-', 1000 + B.a, '-b'), +concat('c-', 1000 + C.a, '-c'), +'filler' +from t1 A, t1 B, t1 C; +EXPLAIN select count(length(a) + length(filler)) +from t2 force index (k1) +where a>='a-1000-a' and a <'a-1001-a'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 100 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL range k1 k1 33 NULL 100 100.00 Using where; Using MRR +Warnings: +Note 1003 /* select#1 */ select count((length(`test`.`t2`.`a`) + length(`test`.`t2`.`filler`))) AS `count(length(a) + length(filler))` from `test`.`t2` FORCE INDEX (`k1`) where ((`test`.`t2`.`a` >= 'a-1000-a') and (`test`.`t2`.`a` < 'a-1001-a')) +select count(length(a) + length(filler)) +from t2 force index (k1) +where a>='a-1000-a' and a <'a-1001-a'; +count(length(a) + length(filler)) +100 +drop table t2; +create table t2 (a char(100), b char(100), c char(100), d int, +filler char(10), key(d), primary key (a,b,c)) charset latin1; +insert into t2 select A.a, B.a, B.a, A.a, 'filler' from t1 A, t1 B; +explain select * from t2 force index (d) where d < 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (2 workers) +2 SIMPLE t2 NULL range d d 5 NULL # 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c`,`test`.`t2`.`d` AS `d`,`test`.`t2`.`filler` AS `filler` from `test`.`t2` FORCE INDEX (`d`) where (`test`.`t2`.`d` < 10) +drop table t2; +drop table t1; +set @@read_rnd_buffer_size= @read_rnd_buffer_size_save; +create table t1 (f1 int not null, f2 int not null,f3 int not null, f4 char(1), primary key (f1,f2), key ix(f3)); +select * from t1 where (f3>=5 and f3<=10) or (f3>=1 and f3<=4); +f1 f2 f3 f4 +1 1 1 A +10 10 10 A +2 2 2 A +3 3 3 A +4 4 4 A +5 5 5 A +6 6 6 A +7 7 7 A +8 8 8 A +9 9 9 A +drop table t1; + +BUG#37977: Wrong result returned on GROUP BY + OR + Innodb + +CREATE TABLE t1 ( +`pk` int(11) NOT NULL AUTO_INCREMENT, +`int_nokey` int(11) NOT NULL, +`int_key` int(11) NOT NULL, +`date_key` date NOT NULL, +`date_nokey` date NOT NULL, +`time_key` time NOT NULL, +`time_nokey` time NOT NULL, +`datetime_key` datetime NOT NULL, +`datetime_nokey` datetime NOT NULL, +`varchar_key` varchar(5) DEFAULT NULL, +`varchar_nokey` varchar(5) DEFAULT NULL, +PRIMARY KEY (`pk`), +KEY `int_key` (`int_key`), +KEY `date_key` (`date_key`), +KEY `time_key` (`time_key`), +KEY `datetime_key` (`datetime_key`), +KEY `varchar_key` (`varchar_key`) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT IGNORE INTO t1 VALUES +(1,5,5,'2009-10-16','2009-10-16','09:28:15','09:28:15','2007-09-14 05:34:08','2007-09-14 05:34:08','qk','qk'), +(2,6,6,'0000-00-00','0000-00-00','23:06:39','23:06:39','0000-00-00 00:00:00','0000-00-00 00:00:00','j','j'), +(3,10,10,'2000-12-18','2000-12-18','22:16:19','22:16:19','2006-11-04 15:42:50','2006-11-04 15:42:50','aew','aew'), +(4,0,0,'2001-09-18','2001-09-18','00:00:00','00:00:00','2004-03-23 13:23:35','2004-03-23 13:23:35',NULL,NULL), +(5,6,6,'2007-08-16','2007-08-16','22:13:38','22:13:38','2004-08-19 11:01:28','2004-08-19 11:01:28','qu','qu'); +Warnings: +Warning 1264 Out of range value for column 'date_key' at row 2 +Warning 1264 Out of range value for column 'date_nokey' at row 2 +Warning 1264 Out of range value for column 'datetime_key' at row 2 +Warning 1264 Out of range value for column 'datetime_nokey' at row 2 +select pk from t1 WHERE `varchar_key` > 'kr' group by pk; +pk +1 +5 +select pk from t1 WHERE `int_nokey` IS NULL OR `varchar_key` > 'kr' group by pk; +pk +1 +5 +drop table t1; +# +# BUG#39447: Error with NOT NULL condition and LIMIT 1 +# +CREATE TABLE t1 ( +id int(11) NOT NULL, +parent_id int(11) DEFAULT NULL, +name varchar(10) DEFAULT NULL, +PRIMARY KEY (id), +KEY ind_parent_id (parent_id) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t1 (id, parent_id, name) values +(10,NULL,'A'), +(20,10,'B'), +(30,10,'C'), +(40,NULL,'D'), +(50,40,'E'), +(60,40,'F'), +(70,NULL,'J'); +SELECT id FROM t1 WHERE parent_id IS NOT NULL ORDER BY id DESC LIMIT 1; +id +60 +This must show type=index, extra=Using where +explain SELECT * FROM t1 WHERE parent_id IS NOT NULL ORDER BY id DESC LIMIT 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 57.14 Backward index scan; Parallel execute (1 workers) +2 SIMPLE t1 NULL index ind_parent_id PRIMARY 4 NULL 1 57.14 Using where; Backward index scan +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,`test`.`t1`.`parent_id` AS `parent_id`,`test`.`t1`.`name` AS `name` from `test`.`t1` where (`test`.`t1`.`parent_id` is not null) order by `test`.`t1`.`id` desc limit 1 +SELECT * FROM t1 WHERE parent_id IS NOT NULL ORDER BY id DESC LIMIT 1; +id parent_id name +60 40 F +drop table t1; +# +# Bug#50381 "Assertion failing in handler.h:1283: +# void COST_VECT::add_io(double, double)" +# +CREATE TABLE t1 ( +c1 INT NOT NULL, +c2 VARCHAR(1) DEFAULT NULL, +PRIMARY KEY (c1) +); +CREATE TABLE t2 ( +c1 INT NOT NULL, +c2 VARCHAR(1) DEFAULT NULL, +PRIMARY KEY (c1) +); +INSERT INTO t2 VALUES (10,'v'); +INSERT INTO t2 VALUES (11,'r'); +SELECT t1.c2 +FROM t2 STRAIGHT_JOIN t1 ON t1.c1 < t2.c1; +c2 +DROP TABLE t1, t2; +# +# Bug#12321461: CRASH IN DSMRR_IMPL::DSMRR_INIT ON SELECT STRAIGHT_JOIN +# +set @save_optimizer_switch = @@optimizer_switch; +set optimizer_switch='block_nested_loop=off,batched_key_access=off'; +CREATE TABLE t1 ( +pk INTEGER, +c1 VARCHAR(1) NOT NULL, +PRIMARY KEY (pk) +); +CREATE TABLE t2 ( +c1 VARCHAR(1) NOT NULL +); +INSERT INTO t2 VALUES ('v'), ('c'); +EXPLAIN SELECT STRAIGHT_JOIN t1.c1 +FROM t1 RIGHT OUTER JOIN t2 ON t1.c1 = t2.c1 +WHERE t1.pk > 176; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 SIMPLE t1 NULL range PRIMARY PRIMARY 4 NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select straight_join `test`.`t1`.`c1` AS `c1` from `test`.`t2` join `test`.`t1` where ((`test`.`t1`.`c1` = `test`.`t2`.`c1`) and (`test`.`t1`.`pk` > 176)) +SELECT STRAIGHT_JOIN t1.c1 +FROM t1 RIGHT OUTER JOIN t2 ON t1.c1 = t2.c1 +WHERE t1.pk > 176; +c1 +DROP TABLE t1,t2; +set optimizer_switch= @save_optimizer_switch; +# +# Bug#13249966 MRR: RANDOM ERROR DUE TO UNINITIALIZED RES WITH +# SMALL READ_RND_BUFFER_SIZE +# +set @read_rnd_buffer_size_save= @@read_rnd_buffer_size; +set read_rnd_buffer_size=1; +select @@read_rnd_buffer_size; +@@read_rnd_buffer_size +1 +CREATE TABLE t1 ( +i1 INTEGER NOT NULL, +i2 INTEGER NOT NULL, +KEY (i2) +); +INSERT INTO t1 VALUES (0,1),(1,2),(2,3); +EXPLAIN SELECT i1 +FROM t1 +WHERE i2 > 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range i2 i2 4 NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i1` AS `i1` from `test`.`t1` where (`test`.`t1`.`i2` > 2) +SELECT i1 +FROM t1 +WHERE i2 > 2; +i1 +2 +DROP TABLE t1; +set @@read_rnd_buffer_size= @read_rnd_buffer_size_save; +select @@read_rnd_buffer_size; +@@read_rnd_buffer_size +262144 +# +# Bug 12365385 STRAIGHT_JOIN QUERY QUICKLY EXHAUSTS SYSTEM+VIRT. +# MEMORY LEADING TO SYSTEM CRASH +# +CREATE TABLE ten (a INTEGER); +INSERT INTO ten VALUES (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +CREATE TABLE t1 ( +pk INTEGER NOT NULL, +i1 INTEGER NOT NULL, +c1 VARCHAR(10) NOT NULL, +PRIMARY KEY (pk) +) charset latin1; +INSERT INTO t1 +SELECT a, 1, 'MySQL' FROM ten; +CREATE TABLE t2 ( +pk INTEGER NOT NULL, +c1 VARCHAR(10) NOT NULL, +c2 varchar(10) NOT NULL, +PRIMARY KEY (pk) +) charset latin1; +INSERT INTO t2 +SELECT a, 'MySQL', 'MySQL' FROM ten; +CREATE TABLE t3 ( +pk INTEGER NOT NULL, +c1 VARCHAR(10) NOT NULL, +PRIMARY KEY (pk) +) charset latin1; +INSERT INTO t3 +SELECT a, 'MySQL' FROM ten; +CREATE TABLE t4 ( +pk int(11) NOT NULL, +c1_key varchar(10) CHARACTER SET utf8 NOT NULL, +c2 varchar(10) NOT NULL, +c3 varchar(10) NOT NULL, +PRIMARY KEY (pk), +KEY k1 (c1_key) +) charset latin1; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +CREATE TABLE t5 ( +pk INTEGER NOT NULL, +c1 VARCHAR(10) NOT NULL, +PRIMARY KEY (pk) +) charset latin1; +INSERT INTO t5 +SELECT a, 'MySQL' FROM ten; +EXPLAIN SELECT STRAIGHT_JOIN * +FROM +(t1 LEFT JOIN +(t2 LEFT JOIN +(t3 LEFT OUTER JOIN t4 ON t3.c1 <= t4.c1_key) +ON t2.c1 = t4.c3) +ON t1.c1 = t4.c2) +RIGHT OUTER JOIN t5 ON t2.c2 <= t5.c1 +WHERE t1.i1 = 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 100.00 Parallel execute (1 workers) +2 SIMPLE t5 NULL ALL NULL NULL NULL NULL 10 100.00 NULL +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 10.00 Using where; Using join buffer (hash join) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 10 33.33 Using where; Using join buffer (hash join) +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 10 100.00 Using join buffer (hash join) +2 SIMPLE t4 NULL ALL k1 NULL NULL NULL 1 100.00 Range checked for each record (index map: 0x2) +Warnings: +Note 1003 /* select#1 */ select straight_join `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`i1` AS `i1`,`test`.`t1`.`c1` AS `c1`,`test`.`t2`.`pk` AS `pk`,`test`.`t2`.`c1` AS `c1`,`test`.`t2`.`c2` AS `c2`,`test`.`t3`.`pk` AS `pk`,`test`.`t3`.`c1` AS `c1`,`test`.`t4`.`pk` AS `pk`,`test`.`t4`.`c1_key` AS `c1_key`,`test`.`t4`.`c2` AS `c2`,`test`.`t4`.`c3` AS `c3`,`test`.`t5`.`pk` AS `pk`,`test`.`t5`.`c1` AS `c1` from `test`.`t5` join `test`.`t1` join `test`.`t2` join `test`.`t3` join `test`.`t4` where ((`test`.`t4`.`c3` = `test`.`t2`.`c1`) and (`test`.`t4`.`c2` = `test`.`t1`.`c1`) and (`test`.`t1`.`i1` = 1) and (`test`.`t2`.`c2` <= `test`.`t5`.`c1`) and (`test`.`t3`.`c1` <= `test`.`t4`.`c1_key`)) +SELECT STRAIGHT_JOIN * +FROM +(t1 LEFT JOIN +(t2 LEFT JOIN +(t3 LEFT OUTER JOIN t4 ON t3.c1 <= t4.c1_key) +ON t2.c1 = t4.c3) +ON t1.c1 = t4.c2) +RIGHT OUTER JOIN t5 ON t2.c2 <= t5.c1 +WHERE t1.i1 = 1; +pk i1 c1 pk c1 c2 pk c1 pk c1_key c2 c3 pk c1 +DROP TABLE ten, t1, t2, t3, t4, t5; +# +# Bug 18172819 CRASH ON DSMRR_IMPL::CHOOSE_MRR_IMPL IN SQL/HANDLER.CC +# +set @big_tables_save= @@big_tables; +set @optimizer_switch_save=@@optimizer_switch; +set big_tables=ON; +set optimizer_switch='derived_merge=off'; +SELECT @@big_tables; +@@big_tables +1 +CREATE TABLE t1 ( +i1 INTEGER NOT NULL, +c1 VARCHAR(1) +) charset utf8mb4; +INSERT INTO t1 VALUES (1,'a'), (2, NULL); +CREATE TABLE t2 ( +c1 VARCHAR(1), +i1 INTEGER NOT NULL, +KEY (c1) +) charset utf8mb4; +INSERT INTO t2 VALUES ('a', 1), (NULL, 2); +EXPLAIN SELECT * +FROM +( SELECT * FROM t1 ) AS d1 +WHERE d1.c1 IN ( SELECT c1 FROM t2 ) +AND d1.c1 IS NULL +ORDER BY d1.i1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using filesort +3 DEPENDENT SUBQUERY t2 NULL index_subquery c1 c1 7 func 1 100.00 Using index +2 DERIVED t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `d1`.`i1` AS `i1`,`d1`.`c1` AS `c1` from (/* select#2 */ select `test`.`t1`.`i1` AS `i1`,`test`.`t1`.`c1` AS `c1` from `test`.`t1` where (`test`.`t1`.`c1` is null)) `d1` where (`d1`.`c1`,(((`d1`.`c1`) in t2 on c1))) order by `d1`.`i1` +SELECT * +FROM +( SELECT * FROM t1 ) AS d1 +WHERE d1.c1 IN ( SELECT c1 FROM t2 ) +AND d1.c1 IS NULL +ORDER BY d1.i1; +i1 c1 +DROP TABLE t1, t2; +set big_tables=@big_tables_save; +set optimizer_switch=@optimizer_switch_save; +# +# Bug#41029 "MRR: SELECT FOR UPDATE fails to lock gaps (InnoDB table)" +# +SET AUTOCOMMIT=0; +CREATE TABLE t1 ( +dummy INT PRIMARY KEY, +a INT UNIQUE, +b INT +) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1,1,1),(3,3,3),(5,5,5); +COMMIT; +SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ; +SELECT @@transaction_isolation; +@@transaction_isolation +REPEATABLE-READ +START TRANSACTION; +EXPLAIN SELECT * FROM t1 WHERE a > 2 FOR UPDATE; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range a a 5 NULL 2 100.00 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`dummy` AS `dummy`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (`test`.`t1`.`a` > 2) +SELECT * FROM t1 WHERE a > 2 FOR UPDATE; +dummy a b +3 3 3 +5 5 5 +SET AUTOCOMMIT=0; +START TRANSACTION; +INSERT INTO t1 VALUES (2,2,2); +ERROR HY000: Lock wait timeout exceeded; try restarting transaction +ROLLBACK; +ROLLBACK; +DROP TABLE t1; +# +# Bug#54286 "Server crash at lock timeout with MRR" +# +SET AUTOCOMMIT=0; +CREATE TABLE t1 ( +dummy INT PRIMARY KEY, +a INT UNIQUE, +b INT +) ENGINE=InnoDB; +COMMIT; +INSERT INTO t1 VALUES (1,1,1),(3,3,3),(5,5,5); +SET AUTOCOMMIT=0; +SELECT * FROM t1 WHERE a > 2 FOR UPDATE; +ERROR HY000: Lock wait timeout exceeded; try restarting transaction +ROLLBACK; +ROLLBACK; +DROP TABLE t1; +COMMIT; +set default_storage_engine= @save_storage_engine; +set optimizer_switch=default; diff --git a/mysql-test/r/innodb_mrr_all.result-pq b/mysql-test/r/innodb_mrr_all.result-pq new file mode 100644 index 000000000000..2c5444f5b3a2 --- /dev/null +++ b/mysql-test/r/innodb_mrr_all.result-pq @@ -0,0 +1,802 @@ +set optimizer_switch='semijoin=on,materialization=on,firstmatch=on,loosescan=on,index_condition_pushdown=on,mrr=on,mrr_cost_based=off'; +set @save_storage_engine= @@default_storage_engine; +set default_storage_engine=InnoDB; +create table t1(a int) charset utf8mb4; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t2(a int); +insert into t2 select A.a + 10*(B.a + 10*C.a) from t1 A, t1 B, t1 C; +create table t3 ( +a char(8) not null, b char(8) not null, filler char(200), +key(a) +); +insert into t3 select @a:=concat('c-', 1000+ A.a, '=w'), @a, 'filler' from t2 A; +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +insert into t3 select concat('c-', 1000+A.a, '=w'), concat('c-', 2000+A.a, '=w'), +'filler-1' from t2 A; +insert into t3 select concat('c-', 1000+A.a, '=w'), concat('c-', 3000+A.a, '=w'), +'filler-2' from t2 A; +select a,filler from t3 where a >= 'c-9011=w'; +a filler +select a,filler from t3 where a >= 'c-1011=w' and a <= 'c-1015=w'; +a filler +c-1011=w filler +c-1011=w filler-1 +c-1011=w filler-2 +c-1012=w filler +c-1012=w filler-1 +c-1012=w filler-2 +c-1013=w filler +c-1013=w filler-1 +c-1013=w filler-2 +c-1014=w filler +c-1014=w filler-1 +c-1014=w filler-2 +c-1015=w filler +c-1015=w filler-1 +c-1015=w filler-2 +select a,filler from t3 where (a>='c-1011=w' and a <= 'c-1013=w') or +(a>='c-1014=w' and a <= 'c-1015=w'); +a filler +c-1011=w filler +c-1011=w filler-1 +c-1011=w filler-2 +c-1012=w filler +c-1012=w filler-1 +c-1012=w filler-2 +c-1013=w filler +c-1013=w filler-1 +c-1013=w filler-2 +c-1014=w filler +c-1014=w filler-1 +c-1014=w filler-2 +c-1015=w filler +c-1015=w filler-1 +c-1015=w filler-2 +insert into t3 values ('c-1013=z', 'c-1013=z', 'err'); +insert into t3 values ('a-1014=w', 'a-1014=w', 'err'); +select a,filler from t3 where (a>='c-1011=w' and a <= 'c-1013=w') or +(a>='c-1014=w' and a <= 'c-1015=w'); +a filler +c-1011=w filler +c-1011=w filler-1 +c-1011=w filler-2 +c-1012=w filler +c-1012=w filler-1 +c-1012=w filler-2 +c-1013=w filler +c-1013=w filler-1 +c-1013=w filler-2 +c-1014=w filler +c-1014=w filler-1 +c-1014=w filler-2 +c-1015=w filler +c-1015=w filler-1 +c-1015=w filler-2 +delete from t3 where b in ('c-1013=z', 'a-1014=w'); +select a,filler from t3 where a='c-1011=w' or a='c-1012=w' or a='c-1013=w' or +a='c-1014=w' or a='c-1015=w'; +a filler +c-1011=w filler +c-1011=w filler-1 +c-1011=w filler-2 +c-1012=w filler +c-1012=w filler-1 +c-1012=w filler-2 +c-1013=w filler +c-1013=w filler-1 +c-1013=w filler-2 +c-1014=w filler +c-1014=w filler-1 +c-1014=w filler-2 +c-1015=w filler +c-1015=w filler-1 +c-1015=w filler-2 +insert into t3 values ('c-1013=w', 'del-me', 'inserted'); +select a,filler from t3 where a='c-1011=w' or a='c-1012=w' or a='c-1013=w' or +a='c-1014=w' or a='c-1015=w'; +a filler +c-1011=w filler +c-1011=w filler-1 +c-1011=w filler-2 +c-1012=w filler +c-1012=w filler-1 +c-1012=w filler-2 +c-1013=w filler +c-1013=w filler-1 +c-1013=w filler-2 +c-1013=w inserted +c-1014=w filler +c-1014=w filler-1 +c-1014=w filler-2 +c-1015=w filler +c-1015=w filler-1 +c-1015=w filler-2 +delete from t3 where b='del-me'; +alter table t3 add primary key(b); +select b,filler from t3 where (b>='c-1011=w' and b<= 'c-1018=w') or +b IN ('c-1019=w', 'c-1020=w', 'c-1021=w', +'c-1022=w', 'c-1023=w', 'c-1024=w'); +b filler +c-1011=w filler +c-1012=w filler +c-1013=w filler +c-1014=w filler +c-1015=w filler +c-1016=w filler +c-1017=w filler +c-1018=w filler +c-1019=w filler +c-1020=w filler +c-1021=w filler +c-1022=w filler +c-1023=w filler +c-1024=w filler +select b,filler from t3 where (b>='c-1011=w' and b<= 'c-1020=w') or +b IN ('c-1021=w', 'c-1022=w', 'c-1023=w'); +b filler +c-1011=w filler +c-1012=w filler +c-1013=w filler +c-1014=w filler +c-1015=w filler +c-1016=w filler +c-1017=w filler +c-1018=w filler +c-1019=w filler +c-1020=w filler +c-1021=w filler +c-1022=w filler +c-1023=w filler +select b,filler from t3 where (b>='c-1011=w' and b<= 'c-1018=w') or +b IN ('c-1019=w', 'c-1020=w') or +(b>='c-1021=w' and b<= 'c-1023=w'); +b filler +c-1011=w filler +c-1012=w filler +c-1013=w filler +c-1014=w filler +c-1015=w filler +c-1016=w filler +c-1017=w filler +c-1018=w filler +c-1019=w filler +c-1020=w filler +c-1021=w filler +c-1022=w filler +c-1023=w filler +create table t4 (a varchar(10), b int, c char(10), filler char(200), +key idx1 (a, b, c)) charset utf8mb4; +insert into t4 (filler) select concat('NULL-', 15-a) from t2 order by a limit 15; +insert into t4 (a,b,c,filler) +select 'b-1',NULL,'c-1', concat('NULL-', 15-a) from t2 order by a limit 15; +insert into t4 (a,b,c,filler) +select 'b-1',NULL,'c-222', concat('NULL-', 15-a) from t2 order by a limit 15; +insert into t4 (a,b,c,filler) +select 'bb-1',NULL,'cc-2', concat('NULL-', 15-a) from t2 order by a limit 15; +insert into t4 (a,b,c,filler) +select 'zz-1',NULL,'cc-2', 'filler-data' from t2 order by a limit 500; +explain +select * from t4 where a IS NULL and b IS NULL and (c IS NULL or c='no-such-row1' + or c='no-such-row2'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 16 100.00 Parallel execute (2 workers) +2 SIMPLE t4 NULL range idx1 idx1 89 NULL 16 100.00 Using index condition; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t4`.`c` AS `c`,`test`.`t4`.`filler` AS `filler` from `test`.`t4` where ((`test`.`t4`.`a` is null) and (`test`.`t4`.`b` is null) and ((`test`.`t4`.`c` is null) or (`test`.`t4`.`c` = 'no-such-row1') or (`test`.`t4`.`c` = 'no-such-row2'))) +select * from t4 where a IS NULL and b IS NULL and (c IS NULL or c='no-such-row1' + or c='no-such-row2'); +a b c filler +NULL NULL NULL NULL-15 +NULL NULL NULL NULL-14 +NULL NULL NULL NULL-13 +NULL NULL NULL NULL-12 +NULL NULL NULL NULL-11 +NULL NULL NULL NULL-10 +NULL NULL NULL NULL-9 +NULL NULL NULL NULL-8 +NULL NULL NULL NULL-7 +NULL NULL NULL NULL-6 +NULL NULL NULL NULL-5 +NULL NULL NULL NULL-4 +NULL NULL NULL NULL-3 +NULL NULL NULL NULL-2 +NULL NULL NULL NULL-1 +explain +select * from t4 where (a ='b-1' or a='bb-1') and b IS NULL and (c='c-1' or c='cc-2'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 32 100.00 Parallel execute (4 workers) +2 SIMPLE t4 NULL range idx1 idx1 89 NULL 32 100.00 Using index condition; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t4`.`c` AS `c`,`test`.`t4`.`filler` AS `filler` from `test`.`t4` where (((`test`.`t4`.`a` = 'b-1') or (`test`.`t4`.`a` = 'bb-1')) and (`test`.`t4`.`b` is null) and ((`test`.`t4`.`c` = 'c-1') or (`test`.`t4`.`c` = 'cc-2'))) +select * from t4 where (a ='b-1' or a='bb-1') and b IS NULL and (c='c-1' or c='cc-2'); +a b c filler +b-1 NULL c-1 NULL-15 +b-1 NULL c-1 NULL-14 +b-1 NULL c-1 NULL-13 +b-1 NULL c-1 NULL-12 +b-1 NULL c-1 NULL-11 +b-1 NULL c-1 NULL-10 +b-1 NULL c-1 NULL-9 +b-1 NULL c-1 NULL-8 +b-1 NULL c-1 NULL-7 +b-1 NULL c-1 NULL-6 +b-1 NULL c-1 NULL-5 +b-1 NULL c-1 NULL-4 +b-1 NULL c-1 NULL-3 +b-1 NULL c-1 NULL-2 +b-1 NULL c-1 NULL-1 +bb-1 NULL cc-2 NULL-15 +bb-1 NULL cc-2 NULL-14 +bb-1 NULL cc-2 NULL-13 +bb-1 NULL cc-2 NULL-12 +bb-1 NULL cc-2 NULL-11 +bb-1 NULL cc-2 NULL-10 +bb-1 NULL cc-2 NULL-9 +bb-1 NULL cc-2 NULL-8 +bb-1 NULL cc-2 NULL-7 +bb-1 NULL cc-2 NULL-6 +bb-1 NULL cc-2 NULL-5 +bb-1 NULL cc-2 NULL-4 +bb-1 NULL cc-2 NULL-3 +bb-1 NULL cc-2 NULL-2 +bb-1 NULL cc-2 NULL-1 +select * from t4 ignore index(idx1) where (a ='b-1' or a='bb-1') and b IS NULL and (c='c-1' or c='cc-2'); +a b c filler +b-1 NULL c-1 NULL-15 +b-1 NULL c-1 NULL-14 +b-1 NULL c-1 NULL-13 +b-1 NULL c-1 NULL-12 +b-1 NULL c-1 NULL-11 +b-1 NULL c-1 NULL-10 +b-1 NULL c-1 NULL-9 +b-1 NULL c-1 NULL-8 +b-1 NULL c-1 NULL-7 +b-1 NULL c-1 NULL-6 +b-1 NULL c-1 NULL-5 +b-1 NULL c-1 NULL-4 +b-1 NULL c-1 NULL-3 +b-1 NULL c-1 NULL-2 +b-1 NULL c-1 NULL-1 +bb-1 NULL cc-2 NULL-15 +bb-1 NULL cc-2 NULL-14 +bb-1 NULL cc-2 NULL-13 +bb-1 NULL cc-2 NULL-12 +bb-1 NULL cc-2 NULL-11 +bb-1 NULL cc-2 NULL-10 +bb-1 NULL cc-2 NULL-9 +bb-1 NULL cc-2 NULL-8 +bb-1 NULL cc-2 NULL-7 +bb-1 NULL cc-2 NULL-6 +bb-1 NULL cc-2 NULL-5 +bb-1 NULL cc-2 NULL-4 +bb-1 NULL cc-2 NULL-3 +bb-1 NULL cc-2 NULL-2 +bb-1 NULL cc-2 NULL-1 +drop table t1, t2, t3, t4; +create table t1 (a int, b int not null,unique key (a,b),index(b)); +insert ignore into t1 values (1,1),(2,2),(3,3),(4,4),(5,5),(6,6),(null,7),(9,9),(8,8),(7,7),(null,9),(null,9),(6,6); +Warnings: +Warning 1062 Duplicate entry '6-6' for key 't1.a' +create table t2 like t1; +insert into t2 select * from t1; +alter table t1 modify b blob not null, add c int not null, drop key a, add unique key (a,b(20),c), drop key b, add key (b(10)); +select * from t1 where a is null; +a b c +NULL 7 0 +NULL 9 0 +NULL 9 0 +select * from t1 where (a is null or a > 0 and a < 3) and b > 7 limit 3; +a b c +NULL 9 0 +NULL 9 0 +select * from t1 where a is null and b=9 or a is null and b=7 limit 3; +a b c +NULL 7 0 +NULL 9 0 +NULL 9 0 +drop table t1, t2; +CREATE TABLE t1 ( +ID int(10) unsigned NOT NULL AUTO_INCREMENT, +col1 int(10) unsigned DEFAULT NULL, +key1 int(10) unsigned NOT NULL DEFAULT '0', +key2 int(10) unsigned DEFAULT NULL, +text1 text, +text2 text, +col2 smallint(6) DEFAULT '100', +col3 enum('headers','bodyandsubject') NOT NULL DEFAULT 'bodyandsubject', +col4 tinyint(3) unsigned NOT NULL DEFAULT '0', +PRIMARY KEY (ID), +KEY (key1), +KEY (key2) +) AUTO_INCREMENT=6 DEFAULT CHARSET=utf8; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES +(1,NULL,1130,NULL,'Hello',NULL,100,'bodyandsubject',0), +(2,NULL,1130,NULL,'bye',NULL,100,'bodyandsubject',0), +(3,NULL,1130,NULL,'red',NULL,100,'bodyandsubject',0), +(4,NULL,1130,NULL,'yellow',NULL,100,'bodyandsubject',0), +(5,NULL,1130,NULL,'blue',NULL,100,'bodyandsubject',0); +select * FROM t1 WHERE key1=1130 AND col1 IS NULL ORDER BY text1; +ID col1 key1 key2 text1 text2 col2 col3 col4 +5 NULL 1130 NULL blue NULL 100 bodyandsubject 0 +2 NULL 1130 NULL bye NULL 100 bodyandsubject 0 +1 NULL 1130 NULL Hello NULL 100 bodyandsubject 0 +3 NULL 1130 NULL red NULL 100 bodyandsubject 0 +4 NULL 1130 NULL yellow NULL 100 bodyandsubject 0 +drop table t1; + +BUG#37851: Crash in test_if_skip_sort_order tab->select is zero + +CREATE TABLE t1 ( +pk int(11) NOT NULL AUTO_INCREMENT, +PRIMARY KEY (pk) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (1); +CREATE TABLE t2 ( +pk int(11) NOT NULL AUTO_INCREMENT, +int_key int(11) DEFAULT NULL, +PRIMARY KEY (pk), +KEY int_key (int_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (1,1),(2,6),(3,0); +EXPLAIN +SELECT MIN(t1.pk) +FROM t1 WHERE EXISTS ( +SELECT t2.pk +FROM t2 +WHERE t2.int_key IS NULL +GROUP BY t2.pk +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL PRIMARY 4 NULL 1 100.00 Using index +2 SIMPLE t2 NULL ref int_key int_key 5 const 1 100.00 Using where; Using index; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select min(`test`.`t1`.`pk`) AS `MIN(t1.pk)` from `test`.`t1` semi join (`test`.`t2`) where (`test`.`t2`.`int_key` is null) +DROP TABLE t1, t2; +# +# BUG#42048 Discrepancy between MyISAM and Maria's ICP implementation +# +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (a int, b char(20), filler char(200), key(a,b(10))); +insert into t1 select A.a + 10*(B.a + 10*C.a), 'bbb','filler' from t0 A, t0 B, t0 C; +update t1 set b=repeat(char(65+a), 20) where a < 25; +This must show range + using index condition: +explain select * from t1 where a < 10 and b = repeat(char(65+a), 20); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL x x Parallel execute (1 workers) +2 SIMPLE t1 NULL range a a 5 NULL x x Using index condition; Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`filler` AS `filler` from `test`.`t1` where ((`test`.`t1`.`a` < 10) and (`test`.`t1`.`b` = repeat(char((65 + `test`.`t1`.`a`)),20))) +select * from t1 where a < 10 and b = repeat(char(65+a), 20); +a b filler +0 AAAAAAAAAAAAAAAAAAAA filler +1 BBBBBBBBBBBBBBBBBBBB filler +2 CCCCCCCCCCCCCCCCCCCC filler +3 DDDDDDDDDDDDDDDDDDDD filler +4 EEEEEEEEEEEEEEEEEEEE filler +5 FFFFFFFFFFFFFFFFFFFF filler +6 GGGGGGGGGGGGGGGGGGGG filler +7 HHHHHHHHHHHHHHHHHHHH filler +8 IIIIIIIIIIIIIIIIIIII filler +9 JJJJJJJJJJJJJJJJJJJJ filler +drop table t0,t1; +# +# BUG#41136: ORDER BY + range access: EXPLAIN shows "Using MRR" while MRR is actually not used +# +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (a int, b int, key(a)); +insert into t1 select A.a + 10 *(B.a + 10*C.a), A.a + 10 *(B.a + 10*C.a) from t0 A, t0 B, t0 C; +This mustn't show "Using MRR": +explain select * from t1 where a < 20 order by a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 20 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range a a 5 NULL 20 100.00 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (`test`.`t1`.`a` < 20) order by `test`.`t1`.`a` +drop table t0, t1; +set @read_rnd_buffer_size_save= @@read_rnd_buffer_size; +set read_rnd_buffer_size=64; +create table t1(a int); +insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t2(a char(8), b char(8), c char(8), filler char(100), key k1(a,b,c) ) charset utf8mb4; +insert into t2 select +concat('a-', 1000 + A.a, '-a'), +concat('b-', 1000 + B.a, '-b'), +concat('c-', 1000 + C.a, '-c'), +'filler' +from t1 A, t1 B, t1 C; +EXPLAIN select count(length(a) + length(filler)) +from t2 force index (k1) +where a>='a-1000-a' and a <'a-1001-a'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 100 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL range k1 k1 33 NULL 100 100.00 Using index condition; Using MRR +Warnings: +Note 1003 /* select#1 */ select count((length(`test`.`t2`.`a`) + length(`test`.`t2`.`filler`))) AS `count(length(a) + length(filler))` from `test`.`t2` FORCE INDEX (`k1`) where ((`test`.`t2`.`a` >= 'a-1000-a') and (`test`.`t2`.`a` < 'a-1001-a')) +select count(length(a) + length(filler)) +from t2 force index (k1) +where a>='a-1000-a' and a <'a-1001-a'; +count(length(a) + length(filler)) +100 +drop table t2; +create table t2 (a char(100), b char(100), c char(100), d int, +filler char(10), key(d), primary key (a,b,c)) charset latin1; +insert into t2 select A.a, B.a, B.a, A.a, 'filler' from t1 A, t1 B; +explain select * from t2 force index (d) where d < 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (2 workers) +2 SIMPLE t2 NULL range d d 5 NULL # 100.00 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c`,`test`.`t2`.`d` AS `d`,`test`.`t2`.`filler` AS `filler` from `test`.`t2` FORCE INDEX (`d`) where (`test`.`t2`.`d` < 10) +drop table t2; +drop table t1; +set @@read_rnd_buffer_size= @read_rnd_buffer_size_save; +create table t1 (f1 int not null, f2 int not null,f3 int not null, f4 char(1), primary key (f1,f2), key ix(f3)); +select * from t1 where (f3>=5 and f3<=10) or (f3>=1 and f3<=4); +f1 f2 f3 f4 +1 1 1 A +10 10 10 A +2 2 2 A +3 3 3 A +4 4 4 A +5 5 5 A +6 6 6 A +7 7 7 A +8 8 8 A +9 9 9 A +drop table t1; + +BUG#37977: Wrong result returned on GROUP BY + OR + Innodb + +CREATE TABLE t1 ( +`pk` int(11) NOT NULL AUTO_INCREMENT, +`int_nokey` int(11) NOT NULL, +`int_key` int(11) NOT NULL, +`date_key` date NOT NULL, +`date_nokey` date NOT NULL, +`time_key` time NOT NULL, +`time_nokey` time NOT NULL, +`datetime_key` datetime NOT NULL, +`datetime_nokey` datetime NOT NULL, +`varchar_key` varchar(5) DEFAULT NULL, +`varchar_nokey` varchar(5) DEFAULT NULL, +PRIMARY KEY (`pk`), +KEY `int_key` (`int_key`), +KEY `date_key` (`date_key`), +KEY `time_key` (`time_key`), +KEY `datetime_key` (`datetime_key`), +KEY `varchar_key` (`varchar_key`) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT IGNORE INTO t1 VALUES +(1,5,5,'2009-10-16','2009-10-16','09:28:15','09:28:15','2007-09-14 05:34:08','2007-09-14 05:34:08','qk','qk'), +(2,6,6,'0000-00-00','0000-00-00','23:06:39','23:06:39','0000-00-00 00:00:00','0000-00-00 00:00:00','j','j'), +(3,10,10,'2000-12-18','2000-12-18','22:16:19','22:16:19','2006-11-04 15:42:50','2006-11-04 15:42:50','aew','aew'), +(4,0,0,'2001-09-18','2001-09-18','00:00:00','00:00:00','2004-03-23 13:23:35','2004-03-23 13:23:35',NULL,NULL), +(5,6,6,'2007-08-16','2007-08-16','22:13:38','22:13:38','2004-08-19 11:01:28','2004-08-19 11:01:28','qu','qu'); +Warnings: +Warning 1264 Out of range value for column 'date_key' at row 2 +Warning 1264 Out of range value for column 'date_nokey' at row 2 +Warning 1264 Out of range value for column 'datetime_key' at row 2 +Warning 1264 Out of range value for column 'datetime_nokey' at row 2 +select pk from t1 WHERE `varchar_key` > 'kr' group by pk; +pk +1 +5 +select pk from t1 WHERE `int_nokey` IS NULL OR `varchar_key` > 'kr' group by pk; +pk +1 +5 +drop table t1; +# +# BUG#39447: Error with NOT NULL condition and LIMIT 1 +# +CREATE TABLE t1 ( +id int(11) NOT NULL, +parent_id int(11) DEFAULT NULL, +name varchar(10) DEFAULT NULL, +PRIMARY KEY (id), +KEY ind_parent_id (parent_id) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t1 (id, parent_id, name) values +(10,NULL,'A'), +(20,10,'B'), +(30,10,'C'), +(40,NULL,'D'), +(50,40,'E'), +(60,40,'F'), +(70,NULL,'J'); +SELECT id FROM t1 WHERE parent_id IS NOT NULL ORDER BY id DESC LIMIT 1; +id +60 +This must show type=index, extra=Using where +explain SELECT * FROM t1 WHERE parent_id IS NOT NULL ORDER BY id DESC LIMIT 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 57.14 Backward index scan; Parallel execute (1 workers) +2 SIMPLE t1 NULL index ind_parent_id PRIMARY 4 NULL 1 57.14 Using where; Backward index scan +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,`test`.`t1`.`parent_id` AS `parent_id`,`test`.`t1`.`name` AS `name` from `test`.`t1` where (`test`.`t1`.`parent_id` is not null) order by `test`.`t1`.`id` desc limit 1 +SELECT * FROM t1 WHERE parent_id IS NOT NULL ORDER BY id DESC LIMIT 1; +id parent_id name +60 40 F +drop table t1; +# +# Bug#50381 "Assertion failing in handler.h:1283: +# void COST_VECT::add_io(double, double)" +# +CREATE TABLE t1 ( +c1 INT NOT NULL, +c2 VARCHAR(1) DEFAULT NULL, +PRIMARY KEY (c1) +); +CREATE TABLE t2 ( +c1 INT NOT NULL, +c2 VARCHAR(1) DEFAULT NULL, +PRIMARY KEY (c1) +); +INSERT INTO t2 VALUES (10,'v'); +INSERT INTO t2 VALUES (11,'r'); +SELECT t1.c2 +FROM t2 STRAIGHT_JOIN t1 ON t1.c1 < t2.c1; +c2 +DROP TABLE t1, t2; +# +# Bug#12321461: CRASH IN DSMRR_IMPL::DSMRR_INIT ON SELECT STRAIGHT_JOIN +# +set @save_optimizer_switch = @@optimizer_switch; +set optimizer_switch='block_nested_loop=off,batched_key_access=off'; +CREATE TABLE t1 ( +pk INTEGER, +c1 VARCHAR(1) NOT NULL, +PRIMARY KEY (pk) +); +CREATE TABLE t2 ( +c1 VARCHAR(1) NOT NULL +); +INSERT INTO t2 VALUES ('v'), ('c'); +EXPLAIN SELECT STRAIGHT_JOIN t1.c1 +FROM t1 RIGHT OUTER JOIN t2 ON t1.c1 = t2.c1 +WHERE t1.pk > 176; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 SIMPLE t1 NULL range PRIMARY PRIMARY 4 NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select straight_join `test`.`t1`.`c1` AS `c1` from `test`.`t2` join `test`.`t1` where ((`test`.`t1`.`c1` = `test`.`t2`.`c1`) and (`test`.`t1`.`pk` > 176)) +SELECT STRAIGHT_JOIN t1.c1 +FROM t1 RIGHT OUTER JOIN t2 ON t1.c1 = t2.c1 +WHERE t1.pk > 176; +c1 +DROP TABLE t1,t2; +set optimizer_switch= @save_optimizer_switch; +# +# Bug#13249966 MRR: RANDOM ERROR DUE TO UNINITIALIZED RES WITH +# SMALL READ_RND_BUFFER_SIZE +# +set @read_rnd_buffer_size_save= @@read_rnd_buffer_size; +set read_rnd_buffer_size=1; +select @@read_rnd_buffer_size; +@@read_rnd_buffer_size +1 +CREATE TABLE t1 ( +i1 INTEGER NOT NULL, +i2 INTEGER NOT NULL, +KEY (i2) +); +INSERT INTO t1 VALUES (0,1),(1,2),(2,3); +EXPLAIN SELECT i1 +FROM t1 +WHERE i2 > 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range i2 i2 4 NULL 1 100.00 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i1` AS `i1` from `test`.`t1` where (`test`.`t1`.`i2` > 2) +SELECT i1 +FROM t1 +WHERE i2 > 2; +i1 +2 +DROP TABLE t1; +set @@read_rnd_buffer_size= @read_rnd_buffer_size_save; +select @@read_rnd_buffer_size; +@@read_rnd_buffer_size +262144 +# +# Bug 12365385 STRAIGHT_JOIN QUERY QUICKLY EXHAUSTS SYSTEM+VIRT. +# MEMORY LEADING TO SYSTEM CRASH +# +CREATE TABLE ten (a INTEGER); +INSERT INTO ten VALUES (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +CREATE TABLE t1 ( +pk INTEGER NOT NULL, +i1 INTEGER NOT NULL, +c1 VARCHAR(10) NOT NULL, +PRIMARY KEY (pk) +) charset latin1; +INSERT INTO t1 +SELECT a, 1, 'MySQL' FROM ten; +CREATE TABLE t2 ( +pk INTEGER NOT NULL, +c1 VARCHAR(10) NOT NULL, +c2 varchar(10) NOT NULL, +PRIMARY KEY (pk) +) charset latin1; +INSERT INTO t2 +SELECT a, 'MySQL', 'MySQL' FROM ten; +CREATE TABLE t3 ( +pk INTEGER NOT NULL, +c1 VARCHAR(10) NOT NULL, +PRIMARY KEY (pk) +) charset latin1; +INSERT INTO t3 +SELECT a, 'MySQL' FROM ten; +CREATE TABLE t4 ( +pk int(11) NOT NULL, +c1_key varchar(10) CHARACTER SET utf8 NOT NULL, +c2 varchar(10) NOT NULL, +c3 varchar(10) NOT NULL, +PRIMARY KEY (pk), +KEY k1 (c1_key) +) charset latin1; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +CREATE TABLE t5 ( +pk INTEGER NOT NULL, +c1 VARCHAR(10) NOT NULL, +PRIMARY KEY (pk) +) charset latin1; +INSERT INTO t5 +SELECT a, 'MySQL' FROM ten; +EXPLAIN SELECT STRAIGHT_JOIN * +FROM +(t1 LEFT JOIN +(t2 LEFT JOIN +(t3 LEFT OUTER JOIN t4 ON t3.c1 <= t4.c1_key) +ON t2.c1 = t4.c3) +ON t1.c1 = t4.c2) +RIGHT OUTER JOIN t5 ON t2.c2 <= t5.c1 +WHERE t1.i1 = 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 100.00 Parallel execute (1 workers) +2 SIMPLE t5 NULL ALL NULL NULL NULL NULL 10 100.00 NULL +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 10.00 Using where; Using join buffer (hash join) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 10 33.33 Using where; Using join buffer (hash join) +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 10 100.00 Using join buffer (hash join) +2 SIMPLE t4 NULL ALL k1 NULL NULL NULL 1 100.00 Range checked for each record (index map: 0x2) +Warnings: +Note 1003 /* select#1 */ select straight_join `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`i1` AS `i1`,`test`.`t1`.`c1` AS `c1`,`test`.`t2`.`pk` AS `pk`,`test`.`t2`.`c1` AS `c1`,`test`.`t2`.`c2` AS `c2`,`test`.`t3`.`pk` AS `pk`,`test`.`t3`.`c1` AS `c1`,`test`.`t4`.`pk` AS `pk`,`test`.`t4`.`c1_key` AS `c1_key`,`test`.`t4`.`c2` AS `c2`,`test`.`t4`.`c3` AS `c3`,`test`.`t5`.`pk` AS `pk`,`test`.`t5`.`c1` AS `c1` from `test`.`t5` join `test`.`t1` join `test`.`t2` join `test`.`t3` join `test`.`t4` where ((`test`.`t4`.`c3` = `test`.`t2`.`c1`) and (`test`.`t4`.`c2` = `test`.`t1`.`c1`) and (`test`.`t1`.`i1` = 1) and (`test`.`t2`.`c2` <= `test`.`t5`.`c1`) and (`test`.`t3`.`c1` <= `test`.`t4`.`c1_key`)) +SELECT STRAIGHT_JOIN * +FROM +(t1 LEFT JOIN +(t2 LEFT JOIN +(t3 LEFT OUTER JOIN t4 ON t3.c1 <= t4.c1_key) +ON t2.c1 = t4.c3) +ON t1.c1 = t4.c2) +RIGHT OUTER JOIN t5 ON t2.c2 <= t5.c1 +WHERE t1.i1 = 1; +pk i1 c1 pk c1 c2 pk c1 pk c1_key c2 c3 pk c1 +DROP TABLE ten, t1, t2, t3, t4, t5; +# +# Bug 18172819 CRASH ON DSMRR_IMPL::CHOOSE_MRR_IMPL IN SQL/HANDLER.CC +# +set @big_tables_save= @@big_tables; +set @optimizer_switch_save=@@optimizer_switch; +set big_tables=ON; +set optimizer_switch='derived_merge=off'; +SELECT @@big_tables; +@@big_tables +1 +CREATE TABLE t1 ( +i1 INTEGER NOT NULL, +c1 VARCHAR(1) +) charset utf8mb4; +INSERT INTO t1 VALUES (1,'a'), (2, NULL); +CREATE TABLE t2 ( +c1 VARCHAR(1), +i1 INTEGER NOT NULL, +KEY (c1) +) charset utf8mb4; +INSERT INTO t2 VALUES ('a', 1), (NULL, 2); +EXPLAIN SELECT * +FROM +( SELECT * FROM t1 ) AS d1 +WHERE d1.c1 IN ( SELECT c1 FROM t2 ) +AND d1.c1 IS NULL +ORDER BY d1.i1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t2 NULL index c1 c1 7 NULL 2 100.00 Using index; Using temporary; Using filesort; LooseScan +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 DERIVED t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `d1`.`i1` AS `i1`,`d1`.`c1` AS `c1` from (/* select#2 */ select `test`.`t1`.`i1` AS `i1`,`test`.`t1`.`c1` AS `c1` from `test`.`t1` where (`test`.`t1`.`c1` is null)) `d1` semi join (`test`.`t2`) where (`d1`.`c1` = `test`.`t2`.`c1`) order by `d1`.`i1` +SELECT * +FROM +( SELECT * FROM t1 ) AS d1 +WHERE d1.c1 IN ( SELECT c1 FROM t2 ) +AND d1.c1 IS NULL +ORDER BY d1.i1; +i1 c1 +DROP TABLE t1, t2; +set big_tables=@big_tables_save; +set optimizer_switch=@optimizer_switch_save; +# +# Bug#41029 "MRR: SELECT FOR UPDATE fails to lock gaps (InnoDB table)" +# +SET AUTOCOMMIT=0; +CREATE TABLE t1 ( +dummy INT PRIMARY KEY, +a INT UNIQUE, +b INT +) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1,1,1),(3,3,3),(5,5,5); +COMMIT; +SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ; +SELECT @@transaction_isolation; +@@transaction_isolation +REPEATABLE-READ +START TRANSACTION; +EXPLAIN SELECT * FROM t1 WHERE a > 2 FOR UPDATE; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range a a 5 NULL 2 100.00 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`dummy` AS `dummy`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (`test`.`t1`.`a` > 2) +SELECT * FROM t1 WHERE a > 2 FOR UPDATE; +dummy a b +3 3 3 +5 5 5 +SET AUTOCOMMIT=0; +START TRANSACTION; +INSERT INTO t1 VALUES (2,2,2); +ERROR HY000: Lock wait timeout exceeded; try restarting transaction +ROLLBACK; +ROLLBACK; +DROP TABLE t1; +# +# Bug#54286 "Server crash at lock timeout with MRR" +# +SET AUTOCOMMIT=0; +CREATE TABLE t1 ( +dummy INT PRIMARY KEY, +a INT UNIQUE, +b INT +) ENGINE=InnoDB; +COMMIT; +INSERT INTO t1 VALUES (1,1,1),(3,3,3),(5,5,5); +SET AUTOCOMMIT=0; +SELECT * FROM t1 WHERE a > 2 FOR UPDATE; +ERROR HY000: Lock wait timeout exceeded; try restarting transaction +ROLLBACK; +ROLLBACK; +DROP TABLE t1; +COMMIT; +set default_storage_engine= @save_storage_engine; +set optimizer_switch=default; diff --git a/mysql-test/r/innodb_mrr_cost.result-pq b/mysql-test/r/innodb_mrr_cost.result-pq new file mode 100644 index 000000000000..ada1e5f08009 --- /dev/null +++ b/mysql-test/r/innodb_mrr_cost.result-pq @@ -0,0 +1,801 @@ +set optimizer_switch='mrr=on,mrr_cost_based=on'; +set @save_storage_engine= @@default_storage_engine; +set default_storage_engine=InnoDB; +create table t1(a int) charset utf8mb4; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t2(a int); +insert into t2 select A.a + 10*(B.a + 10*C.a) from t1 A, t1 B, t1 C; +create table t3 ( +a char(8) not null, b char(8) not null, filler char(200), +key(a) +); +insert into t3 select @a:=concat('c-', 1000+ A.a, '=w'), @a, 'filler' from t2 A; +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +insert into t3 select concat('c-', 1000+A.a, '=w'), concat('c-', 2000+A.a, '=w'), +'filler-1' from t2 A; +insert into t3 select concat('c-', 1000+A.a, '=w'), concat('c-', 3000+A.a, '=w'), +'filler-2' from t2 A; +select a,filler from t3 where a >= 'c-9011=w'; +a filler +select a,filler from t3 where a >= 'c-1011=w' and a <= 'c-1015=w'; +a filler +c-1011=w filler +c-1011=w filler-1 +c-1011=w filler-2 +c-1012=w filler +c-1012=w filler-1 +c-1012=w filler-2 +c-1013=w filler +c-1013=w filler-1 +c-1013=w filler-2 +c-1014=w filler +c-1014=w filler-1 +c-1014=w filler-2 +c-1015=w filler +c-1015=w filler-1 +c-1015=w filler-2 +select a,filler from t3 where (a>='c-1011=w' and a <= 'c-1013=w') or +(a>='c-1014=w' and a <= 'c-1015=w'); +a filler +c-1011=w filler +c-1011=w filler-1 +c-1011=w filler-2 +c-1012=w filler +c-1012=w filler-1 +c-1012=w filler-2 +c-1013=w filler +c-1013=w filler-1 +c-1013=w filler-2 +c-1014=w filler +c-1014=w filler-1 +c-1014=w filler-2 +c-1015=w filler +c-1015=w filler-1 +c-1015=w filler-2 +insert into t3 values ('c-1013=z', 'c-1013=z', 'err'); +insert into t3 values ('a-1014=w', 'a-1014=w', 'err'); +select a,filler from t3 where (a>='c-1011=w' and a <= 'c-1013=w') or +(a>='c-1014=w' and a <= 'c-1015=w'); +a filler +c-1011=w filler +c-1011=w filler-1 +c-1011=w filler-2 +c-1012=w filler +c-1012=w filler-1 +c-1012=w filler-2 +c-1013=w filler +c-1013=w filler-1 +c-1013=w filler-2 +c-1014=w filler +c-1014=w filler-1 +c-1014=w filler-2 +c-1015=w filler +c-1015=w filler-1 +c-1015=w filler-2 +delete from t3 where b in ('c-1013=z', 'a-1014=w'); +select a,filler from t3 where a='c-1011=w' or a='c-1012=w' or a='c-1013=w' or +a='c-1014=w' or a='c-1015=w'; +a filler +c-1011=w filler +c-1011=w filler-1 +c-1011=w filler-2 +c-1012=w filler +c-1012=w filler-1 +c-1012=w filler-2 +c-1013=w filler +c-1013=w filler-1 +c-1013=w filler-2 +c-1014=w filler +c-1014=w filler-1 +c-1014=w filler-2 +c-1015=w filler +c-1015=w filler-1 +c-1015=w filler-2 +insert into t3 values ('c-1013=w', 'del-me', 'inserted'); +select a,filler from t3 where a='c-1011=w' or a='c-1012=w' or a='c-1013=w' or +a='c-1014=w' or a='c-1015=w'; +a filler +c-1011=w filler +c-1011=w filler-1 +c-1011=w filler-2 +c-1012=w filler +c-1012=w filler-1 +c-1012=w filler-2 +c-1013=w filler +c-1013=w filler-1 +c-1013=w filler-2 +c-1013=w inserted +c-1014=w filler +c-1014=w filler-1 +c-1014=w filler-2 +c-1015=w filler +c-1015=w filler-1 +c-1015=w filler-2 +delete from t3 where b='del-me'; +alter table t3 add primary key(b); +select b,filler from t3 where (b>='c-1011=w' and b<= 'c-1018=w') or +b IN ('c-1019=w', 'c-1020=w', 'c-1021=w', +'c-1022=w', 'c-1023=w', 'c-1024=w'); +b filler +c-1011=w filler +c-1012=w filler +c-1013=w filler +c-1014=w filler +c-1015=w filler +c-1016=w filler +c-1017=w filler +c-1018=w filler +c-1019=w filler +c-1020=w filler +c-1021=w filler +c-1022=w filler +c-1023=w filler +c-1024=w filler +select b,filler from t3 where (b>='c-1011=w' and b<= 'c-1020=w') or +b IN ('c-1021=w', 'c-1022=w', 'c-1023=w'); +b filler +c-1011=w filler +c-1012=w filler +c-1013=w filler +c-1014=w filler +c-1015=w filler +c-1016=w filler +c-1017=w filler +c-1018=w filler +c-1019=w filler +c-1020=w filler +c-1021=w filler +c-1022=w filler +c-1023=w filler +select b,filler from t3 where (b>='c-1011=w' and b<= 'c-1018=w') or +b IN ('c-1019=w', 'c-1020=w') or +(b>='c-1021=w' and b<= 'c-1023=w'); +b filler +c-1011=w filler +c-1012=w filler +c-1013=w filler +c-1014=w filler +c-1015=w filler +c-1016=w filler +c-1017=w filler +c-1018=w filler +c-1019=w filler +c-1020=w filler +c-1021=w filler +c-1022=w filler +c-1023=w filler +create table t4 (a varchar(10), b int, c char(10), filler char(200), +key idx1 (a, b, c)) charset utf8mb4; +insert into t4 (filler) select concat('NULL-', 15-a) from t2 order by a limit 15; +insert into t4 (a,b,c,filler) +select 'b-1',NULL,'c-1', concat('NULL-', 15-a) from t2 order by a limit 15; +insert into t4 (a,b,c,filler) +select 'b-1',NULL,'c-222', concat('NULL-', 15-a) from t2 order by a limit 15; +insert into t4 (a,b,c,filler) +select 'bb-1',NULL,'cc-2', concat('NULL-', 15-a) from t2 order by a limit 15; +insert into t4 (a,b,c,filler) +select 'zz-1',NULL,'cc-2', 'filler-data' from t2 order by a limit 500; +explain +select * from t4 where a IS NULL and b IS NULL and (c IS NULL or c='no-such-row1' + or c='no-such-row2'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 16 100.00 Parallel execute (2 workers) +2 SIMPLE t4 NULL range idx1 idx1 89 NULL 16 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t4`.`c` AS `c`,`test`.`t4`.`filler` AS `filler` from `test`.`t4` where ((`test`.`t4`.`a` is null) and (`test`.`t4`.`b` is null) and ((`test`.`t4`.`c` is null) or (`test`.`t4`.`c` = 'no-such-row1') or (`test`.`t4`.`c` = 'no-such-row2'))) +select * from t4 where a IS NULL and b IS NULL and (c IS NULL or c='no-such-row1' + or c='no-such-row2'); +a b c filler +NULL NULL NULL NULL-15 +NULL NULL NULL NULL-14 +NULL NULL NULL NULL-13 +NULL NULL NULL NULL-12 +NULL NULL NULL NULL-11 +NULL NULL NULL NULL-10 +NULL NULL NULL NULL-9 +NULL NULL NULL NULL-8 +NULL NULL NULL NULL-7 +NULL NULL NULL NULL-6 +NULL NULL NULL NULL-5 +NULL NULL NULL NULL-4 +NULL NULL NULL NULL-3 +NULL NULL NULL NULL-2 +NULL NULL NULL NULL-1 +explain +select * from t4 where (a ='b-1' or a='bb-1') and b IS NULL and (c='c-1' or c='cc-2'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 32 100.00 Parallel execute (4 workers) +2 SIMPLE t4 NULL range idx1 idx1 89 NULL 32 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t4`.`c` AS `c`,`test`.`t4`.`filler` AS `filler` from `test`.`t4` where (((`test`.`t4`.`a` = 'b-1') or (`test`.`t4`.`a` = 'bb-1')) and (`test`.`t4`.`b` is null) and ((`test`.`t4`.`c` = 'c-1') or (`test`.`t4`.`c` = 'cc-2'))) +select * from t4 where (a ='b-1' or a='bb-1') and b IS NULL and (c='c-1' or c='cc-2'); +a b c filler +b-1 NULL c-1 NULL-15 +b-1 NULL c-1 NULL-14 +b-1 NULL c-1 NULL-13 +b-1 NULL c-1 NULL-12 +b-1 NULL c-1 NULL-11 +b-1 NULL c-1 NULL-10 +b-1 NULL c-1 NULL-9 +b-1 NULL c-1 NULL-8 +b-1 NULL c-1 NULL-7 +b-1 NULL c-1 NULL-6 +b-1 NULL c-1 NULL-5 +b-1 NULL c-1 NULL-4 +b-1 NULL c-1 NULL-3 +b-1 NULL c-1 NULL-2 +b-1 NULL c-1 NULL-1 +bb-1 NULL cc-2 NULL-15 +bb-1 NULL cc-2 NULL-14 +bb-1 NULL cc-2 NULL-13 +bb-1 NULL cc-2 NULL-12 +bb-1 NULL cc-2 NULL-11 +bb-1 NULL cc-2 NULL-10 +bb-1 NULL cc-2 NULL-9 +bb-1 NULL cc-2 NULL-8 +bb-1 NULL cc-2 NULL-7 +bb-1 NULL cc-2 NULL-6 +bb-1 NULL cc-2 NULL-5 +bb-1 NULL cc-2 NULL-4 +bb-1 NULL cc-2 NULL-3 +bb-1 NULL cc-2 NULL-2 +bb-1 NULL cc-2 NULL-1 +select * from t4 ignore index(idx1) where (a ='b-1' or a='bb-1') and b IS NULL and (c='c-1' or c='cc-2'); +a b c filler +b-1 NULL c-1 NULL-15 +b-1 NULL c-1 NULL-14 +b-1 NULL c-1 NULL-13 +b-1 NULL c-1 NULL-12 +b-1 NULL c-1 NULL-11 +b-1 NULL c-1 NULL-10 +b-1 NULL c-1 NULL-9 +b-1 NULL c-1 NULL-8 +b-1 NULL c-1 NULL-7 +b-1 NULL c-1 NULL-6 +b-1 NULL c-1 NULL-5 +b-1 NULL c-1 NULL-4 +b-1 NULL c-1 NULL-3 +b-1 NULL c-1 NULL-2 +b-1 NULL c-1 NULL-1 +bb-1 NULL cc-2 NULL-15 +bb-1 NULL cc-2 NULL-14 +bb-1 NULL cc-2 NULL-13 +bb-1 NULL cc-2 NULL-12 +bb-1 NULL cc-2 NULL-11 +bb-1 NULL cc-2 NULL-10 +bb-1 NULL cc-2 NULL-9 +bb-1 NULL cc-2 NULL-8 +bb-1 NULL cc-2 NULL-7 +bb-1 NULL cc-2 NULL-6 +bb-1 NULL cc-2 NULL-5 +bb-1 NULL cc-2 NULL-4 +bb-1 NULL cc-2 NULL-3 +bb-1 NULL cc-2 NULL-2 +bb-1 NULL cc-2 NULL-1 +drop table t1, t2, t3, t4; +create table t1 (a int, b int not null,unique key (a,b),index(b)); +insert ignore into t1 values (1,1),(2,2),(3,3),(4,4),(5,5),(6,6),(null,7),(9,9),(8,8),(7,7),(null,9),(null,9),(6,6); +Warnings: +Warning 1062 Duplicate entry '6-6' for key 't1.a' +create table t2 like t1; +insert into t2 select * from t1; +alter table t1 modify b blob not null, add c int not null, drop key a, add unique key (a,b(20),c), drop key b, add key (b(10)); +select * from t1 where a is null; +a b c +NULL 7 0 +NULL 9 0 +NULL 9 0 +select * from t1 where (a is null or a > 0 and a < 3) and b > 7 limit 3; +a b c +NULL 9 0 +NULL 9 0 +select * from t1 where a is null and b=9 or a is null and b=7 limit 3; +a b c +NULL 7 0 +NULL 9 0 +NULL 9 0 +drop table t1, t2; +CREATE TABLE t1 ( +ID int(10) unsigned NOT NULL AUTO_INCREMENT, +col1 int(10) unsigned DEFAULT NULL, +key1 int(10) unsigned NOT NULL DEFAULT '0', +key2 int(10) unsigned DEFAULT NULL, +text1 text, +text2 text, +col2 smallint(6) DEFAULT '100', +col3 enum('headers','bodyandsubject') NOT NULL DEFAULT 'bodyandsubject', +col4 tinyint(3) unsigned NOT NULL DEFAULT '0', +PRIMARY KEY (ID), +KEY (key1), +KEY (key2) +) AUTO_INCREMENT=6 DEFAULT CHARSET=utf8; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES +(1,NULL,1130,NULL,'Hello',NULL,100,'bodyandsubject',0), +(2,NULL,1130,NULL,'bye',NULL,100,'bodyandsubject',0), +(3,NULL,1130,NULL,'red',NULL,100,'bodyandsubject',0), +(4,NULL,1130,NULL,'yellow',NULL,100,'bodyandsubject',0), +(5,NULL,1130,NULL,'blue',NULL,100,'bodyandsubject',0); +select * FROM t1 WHERE key1=1130 AND col1 IS NULL ORDER BY text1; +ID col1 key1 key2 text1 text2 col2 col3 col4 +5 NULL 1130 NULL blue NULL 100 bodyandsubject 0 +2 NULL 1130 NULL bye NULL 100 bodyandsubject 0 +1 NULL 1130 NULL Hello NULL 100 bodyandsubject 0 +3 NULL 1130 NULL red NULL 100 bodyandsubject 0 +4 NULL 1130 NULL yellow NULL 100 bodyandsubject 0 +drop table t1; + +BUG#37851: Crash in test_if_skip_sort_order tab->select is zero + +CREATE TABLE t1 ( +pk int(11) NOT NULL AUTO_INCREMENT, +PRIMARY KEY (pk) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (1); +CREATE TABLE t2 ( +pk int(11) NOT NULL AUTO_INCREMENT, +int_key int(11) DEFAULT NULL, +PRIMARY KEY (pk), +KEY int_key (int_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (1,1),(2,6),(3,0); +EXPLAIN +SELECT MIN(t1.pk) +FROM t1 WHERE EXISTS ( +SELECT t2.pk +FROM t2 +WHERE t2.int_key IS NULL +GROUP BY t2.pk +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +2 SUBQUERY t2 NULL ref int_key int_key 5 const 1 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select min(`test`.`t1`.`pk`) AS `MIN(t1.pk)` from `test`.`t1` where false +DROP TABLE t1, t2; +# +# BUG#42048 Discrepancy between MyISAM and Maria's ICP implementation +# +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (a int, b char(20), filler char(200), key(a,b(10))); +insert into t1 select A.a + 10*(B.a + 10*C.a), 'bbb','filler' from t0 A, t0 B, t0 C; +update t1 set b=repeat(char(65+a), 20) where a < 25; +This must show range + using index condition: +explain select * from t1 where a < 10 and b = repeat(char(65+a), 20); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL x x Parallel execute (1 workers) +2 SIMPLE t1 NULL range a a 5 NULL x x Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`filler` AS `filler` from `test`.`t1` where ((`test`.`t1`.`a` < 10) and (`test`.`t1`.`b` = repeat(char((65 + `test`.`t1`.`a`)),20))) +select * from t1 where a < 10 and b = repeat(char(65+a), 20); +a b filler +0 AAAAAAAAAAAAAAAAAAAA filler +1 BBBBBBBBBBBBBBBBBBBB filler +2 CCCCCCCCCCCCCCCCCCCC filler +3 DDDDDDDDDDDDDDDDDDDD filler +4 EEEEEEEEEEEEEEEEEEEE filler +5 FFFFFFFFFFFFFFFFFFFF filler +6 GGGGGGGGGGGGGGGGGGGG filler +7 HHHHHHHHHHHHHHHHHHHH filler +8 IIIIIIIIIIIIIIIIIIII filler +9 JJJJJJJJJJJJJJJJJJJJ filler +drop table t0,t1; +# +# BUG#41136: ORDER BY + range access: EXPLAIN shows "Using MRR" while MRR is actually not used +# +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (a int, b int, key(a)); +insert into t1 select A.a + 10 *(B.a + 10*C.a), A.a + 10 *(B.a + 10*C.a) from t0 A, t0 B, t0 C; +This mustn't show "Using MRR": +explain select * from t1 where a < 20 order by a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 20 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range a a 5 NULL 20 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (`test`.`t1`.`a` < 20) order by `test`.`t1`.`a` +drop table t0, t1; +set @read_rnd_buffer_size_save= @@read_rnd_buffer_size; +set read_rnd_buffer_size=64; +create table t1(a int); +insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t2(a char(8), b char(8), c char(8), filler char(100), key k1(a,b,c) ) charset utf8mb4; +insert into t2 select +concat('a-', 1000 + A.a, '-a'), +concat('b-', 1000 + B.a, '-b'), +concat('c-', 1000 + C.a, '-c'), +'filler' +from t1 A, t1 B, t1 C; +EXPLAIN select count(length(a) + length(filler)) +from t2 force index (k1) +where a>='a-1000-a' and a <'a-1001-a'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 100 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL range k1 k1 33 NULL 100 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select count((length(`test`.`t2`.`a`) + length(`test`.`t2`.`filler`))) AS `count(length(a) + length(filler))` from `test`.`t2` FORCE INDEX (`k1`) where ((`test`.`t2`.`a` >= 'a-1000-a') and (`test`.`t2`.`a` < 'a-1001-a')) +select count(length(a) + length(filler)) +from t2 force index (k1) +where a>='a-1000-a' and a <'a-1001-a'; +count(length(a) + length(filler)) +100 +drop table t2; +create table t2 (a char(100), b char(100), c char(100), d int, +filler char(10), key(d), primary key (a,b,c)) charset latin1; +insert into t2 select A.a, B.a, B.a, A.a, 'filler' from t1 A, t1 B; +explain select * from t2 force index (d) where d < 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (2 workers) +2 SIMPLE t2 NULL range d d 5 NULL # 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c`,`test`.`t2`.`d` AS `d`,`test`.`t2`.`filler` AS `filler` from `test`.`t2` FORCE INDEX (`d`) where (`test`.`t2`.`d` < 10) +drop table t2; +drop table t1; +set @@read_rnd_buffer_size= @read_rnd_buffer_size_save; +create table t1 (f1 int not null, f2 int not null,f3 int not null, f4 char(1), primary key (f1,f2), key ix(f3)); +select * from t1 where (f3>=5 and f3<=10) or (f3>=1 and f3<=4); +f1 f2 f3 f4 +1 1 1 A +10 10 10 A +2 2 2 A +3 3 3 A +4 4 4 A +5 5 5 A +6 6 6 A +7 7 7 A +8 8 8 A +9 9 9 A +drop table t1; + +BUG#37977: Wrong result returned on GROUP BY + OR + Innodb + +CREATE TABLE t1 ( +`pk` int(11) NOT NULL AUTO_INCREMENT, +`int_nokey` int(11) NOT NULL, +`int_key` int(11) NOT NULL, +`date_key` date NOT NULL, +`date_nokey` date NOT NULL, +`time_key` time NOT NULL, +`time_nokey` time NOT NULL, +`datetime_key` datetime NOT NULL, +`datetime_nokey` datetime NOT NULL, +`varchar_key` varchar(5) DEFAULT NULL, +`varchar_nokey` varchar(5) DEFAULT NULL, +PRIMARY KEY (`pk`), +KEY `int_key` (`int_key`), +KEY `date_key` (`date_key`), +KEY `time_key` (`time_key`), +KEY `datetime_key` (`datetime_key`), +KEY `varchar_key` (`varchar_key`) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT IGNORE INTO t1 VALUES +(1,5,5,'2009-10-16','2009-10-16','09:28:15','09:28:15','2007-09-14 05:34:08','2007-09-14 05:34:08','qk','qk'), +(2,6,6,'0000-00-00','0000-00-00','23:06:39','23:06:39','0000-00-00 00:00:00','0000-00-00 00:00:00','j','j'), +(3,10,10,'2000-12-18','2000-12-18','22:16:19','22:16:19','2006-11-04 15:42:50','2006-11-04 15:42:50','aew','aew'), +(4,0,0,'2001-09-18','2001-09-18','00:00:00','00:00:00','2004-03-23 13:23:35','2004-03-23 13:23:35',NULL,NULL), +(5,6,6,'2007-08-16','2007-08-16','22:13:38','22:13:38','2004-08-19 11:01:28','2004-08-19 11:01:28','qu','qu'); +Warnings: +Warning 1264 Out of range value for column 'date_key' at row 2 +Warning 1264 Out of range value for column 'date_nokey' at row 2 +Warning 1264 Out of range value for column 'datetime_key' at row 2 +Warning 1264 Out of range value for column 'datetime_nokey' at row 2 +select pk from t1 WHERE `varchar_key` > 'kr' group by pk; +pk +1 +5 +select pk from t1 WHERE `int_nokey` IS NULL OR `varchar_key` > 'kr' group by pk; +pk +1 +5 +drop table t1; +# +# BUG#39447: Error with NOT NULL condition and LIMIT 1 +# +CREATE TABLE t1 ( +id int(11) NOT NULL, +parent_id int(11) DEFAULT NULL, +name varchar(10) DEFAULT NULL, +PRIMARY KEY (id), +KEY ind_parent_id (parent_id) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t1 (id, parent_id, name) values +(10,NULL,'A'), +(20,10,'B'), +(30,10,'C'), +(40,NULL,'D'), +(50,40,'E'), +(60,40,'F'), +(70,NULL,'J'); +SELECT id FROM t1 WHERE parent_id IS NOT NULL ORDER BY id DESC LIMIT 1; +id +60 +This must show type=index, extra=Using where +explain SELECT * FROM t1 WHERE parent_id IS NOT NULL ORDER BY id DESC LIMIT 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 57.14 Backward index scan; Parallel execute (1 workers) +2 SIMPLE t1 NULL index ind_parent_id PRIMARY 4 NULL 1 57.14 Using where; Backward index scan +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,`test`.`t1`.`parent_id` AS `parent_id`,`test`.`t1`.`name` AS `name` from `test`.`t1` where (`test`.`t1`.`parent_id` is not null) order by `test`.`t1`.`id` desc limit 1 +SELECT * FROM t1 WHERE parent_id IS NOT NULL ORDER BY id DESC LIMIT 1; +id parent_id name +60 40 F +drop table t1; +# +# Bug#50381 "Assertion failing in handler.h:1283: +# void COST_VECT::add_io(double, double)" +# +CREATE TABLE t1 ( +c1 INT NOT NULL, +c2 VARCHAR(1) DEFAULT NULL, +PRIMARY KEY (c1) +); +CREATE TABLE t2 ( +c1 INT NOT NULL, +c2 VARCHAR(1) DEFAULT NULL, +PRIMARY KEY (c1) +); +INSERT INTO t2 VALUES (10,'v'); +INSERT INTO t2 VALUES (11,'r'); +SELECT t1.c2 +FROM t2 STRAIGHT_JOIN t1 ON t1.c1 < t2.c1; +c2 +DROP TABLE t1, t2; +# +# Bug#12321461: CRASH IN DSMRR_IMPL::DSMRR_INIT ON SELECT STRAIGHT_JOIN +# +set @save_optimizer_switch = @@optimizer_switch; +set optimizer_switch='block_nested_loop=off,batched_key_access=off'; +CREATE TABLE t1 ( +pk INTEGER, +c1 VARCHAR(1) NOT NULL, +PRIMARY KEY (pk) +); +CREATE TABLE t2 ( +c1 VARCHAR(1) NOT NULL +); +INSERT INTO t2 VALUES ('v'), ('c'); +EXPLAIN SELECT STRAIGHT_JOIN t1.c1 +FROM t1 RIGHT OUTER JOIN t2 ON t1.c1 = t2.c1 +WHERE t1.pk > 176; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 SIMPLE t1 NULL range PRIMARY PRIMARY 4 NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select straight_join `test`.`t1`.`c1` AS `c1` from `test`.`t2` join `test`.`t1` where ((`test`.`t1`.`c1` = `test`.`t2`.`c1`) and (`test`.`t1`.`pk` > 176)) +SELECT STRAIGHT_JOIN t1.c1 +FROM t1 RIGHT OUTER JOIN t2 ON t1.c1 = t2.c1 +WHERE t1.pk > 176; +c1 +DROP TABLE t1,t2; +set optimizer_switch= @save_optimizer_switch; +# +# Bug#13249966 MRR: RANDOM ERROR DUE TO UNINITIALIZED RES WITH +# SMALL READ_RND_BUFFER_SIZE +# +set @read_rnd_buffer_size_save= @@read_rnd_buffer_size; +set read_rnd_buffer_size=1; +select @@read_rnd_buffer_size; +@@read_rnd_buffer_size +1 +CREATE TABLE t1 ( +i1 INTEGER NOT NULL, +i2 INTEGER NOT NULL, +KEY (i2) +); +INSERT INTO t1 VALUES (0,1),(1,2),(2,3); +EXPLAIN SELECT i1 +FROM t1 +WHERE i2 > 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range i2 i2 4 NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i1` AS `i1` from `test`.`t1` where (`test`.`t1`.`i2` > 2) +SELECT i1 +FROM t1 +WHERE i2 > 2; +i1 +2 +DROP TABLE t1; +set @@read_rnd_buffer_size= @read_rnd_buffer_size_save; +select @@read_rnd_buffer_size; +@@read_rnd_buffer_size +262144 +# +# Bug 12365385 STRAIGHT_JOIN QUERY QUICKLY EXHAUSTS SYSTEM+VIRT. +# MEMORY LEADING TO SYSTEM CRASH +# +CREATE TABLE ten (a INTEGER); +INSERT INTO ten VALUES (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +CREATE TABLE t1 ( +pk INTEGER NOT NULL, +i1 INTEGER NOT NULL, +c1 VARCHAR(10) NOT NULL, +PRIMARY KEY (pk) +) charset latin1; +INSERT INTO t1 +SELECT a, 1, 'MySQL' FROM ten; +CREATE TABLE t2 ( +pk INTEGER NOT NULL, +c1 VARCHAR(10) NOT NULL, +c2 varchar(10) NOT NULL, +PRIMARY KEY (pk) +) charset latin1; +INSERT INTO t2 +SELECT a, 'MySQL', 'MySQL' FROM ten; +CREATE TABLE t3 ( +pk INTEGER NOT NULL, +c1 VARCHAR(10) NOT NULL, +PRIMARY KEY (pk) +) charset latin1; +INSERT INTO t3 +SELECT a, 'MySQL' FROM ten; +CREATE TABLE t4 ( +pk int(11) NOT NULL, +c1_key varchar(10) CHARACTER SET utf8 NOT NULL, +c2 varchar(10) NOT NULL, +c3 varchar(10) NOT NULL, +PRIMARY KEY (pk), +KEY k1 (c1_key) +) charset latin1; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +CREATE TABLE t5 ( +pk INTEGER NOT NULL, +c1 VARCHAR(10) NOT NULL, +PRIMARY KEY (pk) +) charset latin1; +INSERT INTO t5 +SELECT a, 'MySQL' FROM ten; +EXPLAIN SELECT STRAIGHT_JOIN * +FROM +(t1 LEFT JOIN +(t2 LEFT JOIN +(t3 LEFT OUTER JOIN t4 ON t3.c1 <= t4.c1_key) +ON t2.c1 = t4.c3) +ON t1.c1 = t4.c2) +RIGHT OUTER JOIN t5 ON t2.c2 <= t5.c1 +WHERE t1.i1 = 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 100.00 Parallel execute (1 workers) +2 SIMPLE t5 NULL ALL NULL NULL NULL NULL 10 100.00 NULL +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 10.00 Using where; Using join buffer (hash join) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 10 33.33 Using where; Using join buffer (hash join) +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 10 100.00 Using join buffer (hash join) +2 SIMPLE t4 NULL ALL k1 NULL NULL NULL 1 100.00 Range checked for each record (index map: 0x2) +Warnings: +Note 1003 /* select#1 */ select straight_join `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`i1` AS `i1`,`test`.`t1`.`c1` AS `c1`,`test`.`t2`.`pk` AS `pk`,`test`.`t2`.`c1` AS `c1`,`test`.`t2`.`c2` AS `c2`,`test`.`t3`.`pk` AS `pk`,`test`.`t3`.`c1` AS `c1`,`test`.`t4`.`pk` AS `pk`,`test`.`t4`.`c1_key` AS `c1_key`,`test`.`t4`.`c2` AS `c2`,`test`.`t4`.`c3` AS `c3`,`test`.`t5`.`pk` AS `pk`,`test`.`t5`.`c1` AS `c1` from `test`.`t5` join `test`.`t1` join `test`.`t2` join `test`.`t3` join `test`.`t4` where ((`test`.`t4`.`c3` = `test`.`t2`.`c1`) and (`test`.`t4`.`c2` = `test`.`t1`.`c1`) and (`test`.`t1`.`i1` = 1) and (`test`.`t2`.`c2` <= `test`.`t5`.`c1`) and (`test`.`t3`.`c1` <= `test`.`t4`.`c1_key`)) +SELECT STRAIGHT_JOIN * +FROM +(t1 LEFT JOIN +(t2 LEFT JOIN +(t3 LEFT OUTER JOIN t4 ON t3.c1 <= t4.c1_key) +ON t2.c1 = t4.c3) +ON t1.c1 = t4.c2) +RIGHT OUTER JOIN t5 ON t2.c2 <= t5.c1 +WHERE t1.i1 = 1; +pk i1 c1 pk c1 c2 pk c1 pk c1_key c2 c3 pk c1 +DROP TABLE ten, t1, t2, t3, t4, t5; +# +# Bug 18172819 CRASH ON DSMRR_IMPL::CHOOSE_MRR_IMPL IN SQL/HANDLER.CC +# +set @big_tables_save= @@big_tables; +set @optimizer_switch_save=@@optimizer_switch; +set big_tables=ON; +set optimizer_switch='derived_merge=off'; +SELECT @@big_tables; +@@big_tables +1 +CREATE TABLE t1 ( +i1 INTEGER NOT NULL, +c1 VARCHAR(1) +) charset utf8mb4; +INSERT INTO t1 VALUES (1,'a'), (2, NULL); +CREATE TABLE t2 ( +c1 VARCHAR(1), +i1 INTEGER NOT NULL, +KEY (c1) +) charset utf8mb4; +INSERT INTO t2 VALUES ('a', 1), (NULL, 2); +EXPLAIN SELECT * +FROM +( SELECT * FROM t1 ) AS d1 +WHERE d1.c1 IN ( SELECT c1 FROM t2 ) +AND d1.c1 IS NULL +ORDER BY d1.i1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using filesort +3 DEPENDENT SUBQUERY t2 NULL index_subquery c1 c1 7 func 1 100.00 Using index +2 DERIVED t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `d1`.`i1` AS `i1`,`d1`.`c1` AS `c1` from (/* select#2 */ select `test`.`t1`.`i1` AS `i1`,`test`.`t1`.`c1` AS `c1` from `test`.`t1` where (`test`.`t1`.`c1` is null)) `d1` where (`d1`.`c1`,(((`d1`.`c1`) in t2 on c1))) order by `d1`.`i1` +SELECT * +FROM +( SELECT * FROM t1 ) AS d1 +WHERE d1.c1 IN ( SELECT c1 FROM t2 ) +AND d1.c1 IS NULL +ORDER BY d1.i1; +i1 c1 +DROP TABLE t1, t2; +set big_tables=@big_tables_save; +set optimizer_switch=@optimizer_switch_save; +# +# Bug#41029 "MRR: SELECT FOR UPDATE fails to lock gaps (InnoDB table)" +# +SET AUTOCOMMIT=0; +CREATE TABLE t1 ( +dummy INT PRIMARY KEY, +a INT UNIQUE, +b INT +) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1,1,1),(3,3,3),(5,5,5); +COMMIT; +SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ; +SELECT @@transaction_isolation; +@@transaction_isolation +REPEATABLE-READ +START TRANSACTION; +EXPLAIN SELECT * FROM t1 WHERE a > 2 FOR UPDATE; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range a a 5 NULL 2 100.00 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`dummy` AS `dummy`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (`test`.`t1`.`a` > 2) +SELECT * FROM t1 WHERE a > 2 FOR UPDATE; +dummy a b +3 3 3 +5 5 5 +SET AUTOCOMMIT=0; +START TRANSACTION; +INSERT INTO t1 VALUES (2,2,2); +ERROR HY000: Lock wait timeout exceeded; try restarting transaction +ROLLBACK; +ROLLBACK; +DROP TABLE t1; +# +# Bug#54286 "Server crash at lock timeout with MRR" +# +SET AUTOCOMMIT=0; +CREATE TABLE t1 ( +dummy INT PRIMARY KEY, +a INT UNIQUE, +b INT +) ENGINE=InnoDB; +COMMIT; +INSERT INTO t1 VALUES (1,1,1),(3,3,3),(5,5,5); +SET AUTOCOMMIT=0; +SELECT * FROM t1 WHERE a > 2 FOR UPDATE; +ERROR HY000: Lock wait timeout exceeded; try restarting transaction +ROLLBACK; +ROLLBACK; +DROP TABLE t1; +COMMIT; +set default_storage_engine= @save_storage_engine; +set optimizer_switch=default; diff --git a/mysql-test/r/innodb_mrr_cost_all.result-pq b/mysql-test/r/innodb_mrr_cost_all.result-pq new file mode 100644 index 000000000000..f6b38624e432 --- /dev/null +++ b/mysql-test/r/innodb_mrr_cost_all.result-pq @@ -0,0 +1,802 @@ +set optimizer_switch='semijoin=on,materialization=on,firstmatch=on,loosescan=on,index_condition_pushdown=on,mrr=on,mrr_cost_based=on'; +set @save_storage_engine= @@default_storage_engine; +set default_storage_engine=InnoDB; +create table t1(a int) charset utf8mb4; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t2(a int); +insert into t2 select A.a + 10*(B.a + 10*C.a) from t1 A, t1 B, t1 C; +create table t3 ( +a char(8) not null, b char(8) not null, filler char(200), +key(a) +); +insert into t3 select @a:=concat('c-', 1000+ A.a, '=w'), @a, 'filler' from t2 A; +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +insert into t3 select concat('c-', 1000+A.a, '=w'), concat('c-', 2000+A.a, '=w'), +'filler-1' from t2 A; +insert into t3 select concat('c-', 1000+A.a, '=w'), concat('c-', 3000+A.a, '=w'), +'filler-2' from t2 A; +select a,filler from t3 where a >= 'c-9011=w'; +a filler +select a,filler from t3 where a >= 'c-1011=w' and a <= 'c-1015=w'; +a filler +c-1011=w filler +c-1011=w filler-1 +c-1011=w filler-2 +c-1012=w filler +c-1012=w filler-1 +c-1012=w filler-2 +c-1013=w filler +c-1013=w filler-1 +c-1013=w filler-2 +c-1014=w filler +c-1014=w filler-1 +c-1014=w filler-2 +c-1015=w filler +c-1015=w filler-1 +c-1015=w filler-2 +select a,filler from t3 where (a>='c-1011=w' and a <= 'c-1013=w') or +(a>='c-1014=w' and a <= 'c-1015=w'); +a filler +c-1011=w filler +c-1011=w filler-1 +c-1011=w filler-2 +c-1012=w filler +c-1012=w filler-1 +c-1012=w filler-2 +c-1013=w filler +c-1013=w filler-1 +c-1013=w filler-2 +c-1014=w filler +c-1014=w filler-1 +c-1014=w filler-2 +c-1015=w filler +c-1015=w filler-1 +c-1015=w filler-2 +insert into t3 values ('c-1013=z', 'c-1013=z', 'err'); +insert into t3 values ('a-1014=w', 'a-1014=w', 'err'); +select a,filler from t3 where (a>='c-1011=w' and a <= 'c-1013=w') or +(a>='c-1014=w' and a <= 'c-1015=w'); +a filler +c-1011=w filler +c-1011=w filler-1 +c-1011=w filler-2 +c-1012=w filler +c-1012=w filler-1 +c-1012=w filler-2 +c-1013=w filler +c-1013=w filler-1 +c-1013=w filler-2 +c-1014=w filler +c-1014=w filler-1 +c-1014=w filler-2 +c-1015=w filler +c-1015=w filler-1 +c-1015=w filler-2 +delete from t3 where b in ('c-1013=z', 'a-1014=w'); +select a,filler from t3 where a='c-1011=w' or a='c-1012=w' or a='c-1013=w' or +a='c-1014=w' or a='c-1015=w'; +a filler +c-1011=w filler +c-1011=w filler-1 +c-1011=w filler-2 +c-1012=w filler +c-1012=w filler-1 +c-1012=w filler-2 +c-1013=w filler +c-1013=w filler-1 +c-1013=w filler-2 +c-1014=w filler +c-1014=w filler-1 +c-1014=w filler-2 +c-1015=w filler +c-1015=w filler-1 +c-1015=w filler-2 +insert into t3 values ('c-1013=w', 'del-me', 'inserted'); +select a,filler from t3 where a='c-1011=w' or a='c-1012=w' or a='c-1013=w' or +a='c-1014=w' or a='c-1015=w'; +a filler +c-1011=w filler +c-1011=w filler-1 +c-1011=w filler-2 +c-1012=w filler +c-1012=w filler-1 +c-1012=w filler-2 +c-1013=w filler +c-1013=w filler-1 +c-1013=w filler-2 +c-1013=w inserted +c-1014=w filler +c-1014=w filler-1 +c-1014=w filler-2 +c-1015=w filler +c-1015=w filler-1 +c-1015=w filler-2 +delete from t3 where b='del-me'; +alter table t3 add primary key(b); +select b,filler from t3 where (b>='c-1011=w' and b<= 'c-1018=w') or +b IN ('c-1019=w', 'c-1020=w', 'c-1021=w', +'c-1022=w', 'c-1023=w', 'c-1024=w'); +b filler +c-1011=w filler +c-1012=w filler +c-1013=w filler +c-1014=w filler +c-1015=w filler +c-1016=w filler +c-1017=w filler +c-1018=w filler +c-1019=w filler +c-1020=w filler +c-1021=w filler +c-1022=w filler +c-1023=w filler +c-1024=w filler +select b,filler from t3 where (b>='c-1011=w' and b<= 'c-1020=w') or +b IN ('c-1021=w', 'c-1022=w', 'c-1023=w'); +b filler +c-1011=w filler +c-1012=w filler +c-1013=w filler +c-1014=w filler +c-1015=w filler +c-1016=w filler +c-1017=w filler +c-1018=w filler +c-1019=w filler +c-1020=w filler +c-1021=w filler +c-1022=w filler +c-1023=w filler +select b,filler from t3 where (b>='c-1011=w' and b<= 'c-1018=w') or +b IN ('c-1019=w', 'c-1020=w') or +(b>='c-1021=w' and b<= 'c-1023=w'); +b filler +c-1011=w filler +c-1012=w filler +c-1013=w filler +c-1014=w filler +c-1015=w filler +c-1016=w filler +c-1017=w filler +c-1018=w filler +c-1019=w filler +c-1020=w filler +c-1021=w filler +c-1022=w filler +c-1023=w filler +create table t4 (a varchar(10), b int, c char(10), filler char(200), +key idx1 (a, b, c)) charset utf8mb4; +insert into t4 (filler) select concat('NULL-', 15-a) from t2 order by a limit 15; +insert into t4 (a,b,c,filler) +select 'b-1',NULL,'c-1', concat('NULL-', 15-a) from t2 order by a limit 15; +insert into t4 (a,b,c,filler) +select 'b-1',NULL,'c-222', concat('NULL-', 15-a) from t2 order by a limit 15; +insert into t4 (a,b,c,filler) +select 'bb-1',NULL,'cc-2', concat('NULL-', 15-a) from t2 order by a limit 15; +insert into t4 (a,b,c,filler) +select 'zz-1',NULL,'cc-2', 'filler-data' from t2 order by a limit 500; +explain +select * from t4 where a IS NULL and b IS NULL and (c IS NULL or c='no-such-row1' + or c='no-such-row2'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 16 100.00 Parallel execute (2 workers) +2 SIMPLE t4 NULL range idx1 idx1 89 NULL 16 100.00 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t4`.`c` AS `c`,`test`.`t4`.`filler` AS `filler` from `test`.`t4` where ((`test`.`t4`.`a` is null) and (`test`.`t4`.`b` is null) and ((`test`.`t4`.`c` is null) or (`test`.`t4`.`c` = 'no-such-row1') or (`test`.`t4`.`c` = 'no-such-row2'))) +select * from t4 where a IS NULL and b IS NULL and (c IS NULL or c='no-such-row1' + or c='no-such-row2'); +a b c filler +NULL NULL NULL NULL-15 +NULL NULL NULL NULL-14 +NULL NULL NULL NULL-13 +NULL NULL NULL NULL-12 +NULL NULL NULL NULL-11 +NULL NULL NULL NULL-10 +NULL NULL NULL NULL-9 +NULL NULL NULL NULL-8 +NULL NULL NULL NULL-7 +NULL NULL NULL NULL-6 +NULL NULL NULL NULL-5 +NULL NULL NULL NULL-4 +NULL NULL NULL NULL-3 +NULL NULL NULL NULL-2 +NULL NULL NULL NULL-1 +explain +select * from t4 where (a ='b-1' or a='bb-1') and b IS NULL and (c='c-1' or c='cc-2'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 32 100.00 Parallel execute (4 workers) +2 SIMPLE t4 NULL range idx1 idx1 89 NULL 32 100.00 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t4`.`c` AS `c`,`test`.`t4`.`filler` AS `filler` from `test`.`t4` where (((`test`.`t4`.`a` = 'b-1') or (`test`.`t4`.`a` = 'bb-1')) and (`test`.`t4`.`b` is null) and ((`test`.`t4`.`c` = 'c-1') or (`test`.`t4`.`c` = 'cc-2'))) +select * from t4 where (a ='b-1' or a='bb-1') and b IS NULL and (c='c-1' or c='cc-2'); +a b c filler +b-1 NULL c-1 NULL-15 +b-1 NULL c-1 NULL-14 +b-1 NULL c-1 NULL-13 +b-1 NULL c-1 NULL-12 +b-1 NULL c-1 NULL-11 +b-1 NULL c-1 NULL-10 +b-1 NULL c-1 NULL-9 +b-1 NULL c-1 NULL-8 +b-1 NULL c-1 NULL-7 +b-1 NULL c-1 NULL-6 +b-1 NULL c-1 NULL-5 +b-1 NULL c-1 NULL-4 +b-1 NULL c-1 NULL-3 +b-1 NULL c-1 NULL-2 +b-1 NULL c-1 NULL-1 +bb-1 NULL cc-2 NULL-15 +bb-1 NULL cc-2 NULL-14 +bb-1 NULL cc-2 NULL-13 +bb-1 NULL cc-2 NULL-12 +bb-1 NULL cc-2 NULL-11 +bb-1 NULL cc-2 NULL-10 +bb-1 NULL cc-2 NULL-9 +bb-1 NULL cc-2 NULL-8 +bb-1 NULL cc-2 NULL-7 +bb-1 NULL cc-2 NULL-6 +bb-1 NULL cc-2 NULL-5 +bb-1 NULL cc-2 NULL-4 +bb-1 NULL cc-2 NULL-3 +bb-1 NULL cc-2 NULL-2 +bb-1 NULL cc-2 NULL-1 +select * from t4 ignore index(idx1) where (a ='b-1' or a='bb-1') and b IS NULL and (c='c-1' or c='cc-2'); +a b c filler +b-1 NULL c-1 NULL-15 +b-1 NULL c-1 NULL-14 +b-1 NULL c-1 NULL-13 +b-1 NULL c-1 NULL-12 +b-1 NULL c-1 NULL-11 +b-1 NULL c-1 NULL-10 +b-1 NULL c-1 NULL-9 +b-1 NULL c-1 NULL-8 +b-1 NULL c-1 NULL-7 +b-1 NULL c-1 NULL-6 +b-1 NULL c-1 NULL-5 +b-1 NULL c-1 NULL-4 +b-1 NULL c-1 NULL-3 +b-1 NULL c-1 NULL-2 +b-1 NULL c-1 NULL-1 +bb-1 NULL cc-2 NULL-15 +bb-1 NULL cc-2 NULL-14 +bb-1 NULL cc-2 NULL-13 +bb-1 NULL cc-2 NULL-12 +bb-1 NULL cc-2 NULL-11 +bb-1 NULL cc-2 NULL-10 +bb-1 NULL cc-2 NULL-9 +bb-1 NULL cc-2 NULL-8 +bb-1 NULL cc-2 NULL-7 +bb-1 NULL cc-2 NULL-6 +bb-1 NULL cc-2 NULL-5 +bb-1 NULL cc-2 NULL-4 +bb-1 NULL cc-2 NULL-3 +bb-1 NULL cc-2 NULL-2 +bb-1 NULL cc-2 NULL-1 +drop table t1, t2, t3, t4; +create table t1 (a int, b int not null,unique key (a,b),index(b)); +insert ignore into t1 values (1,1),(2,2),(3,3),(4,4),(5,5),(6,6),(null,7),(9,9),(8,8),(7,7),(null,9),(null,9),(6,6); +Warnings: +Warning 1062 Duplicate entry '6-6' for key 't1.a' +create table t2 like t1; +insert into t2 select * from t1; +alter table t1 modify b blob not null, add c int not null, drop key a, add unique key (a,b(20),c), drop key b, add key (b(10)); +select * from t1 where a is null; +a b c +NULL 7 0 +NULL 9 0 +NULL 9 0 +select * from t1 where (a is null or a > 0 and a < 3) and b > 7 limit 3; +a b c +NULL 9 0 +NULL 9 0 +select * from t1 where a is null and b=9 or a is null and b=7 limit 3; +a b c +NULL 7 0 +NULL 9 0 +NULL 9 0 +drop table t1, t2; +CREATE TABLE t1 ( +ID int(10) unsigned NOT NULL AUTO_INCREMENT, +col1 int(10) unsigned DEFAULT NULL, +key1 int(10) unsigned NOT NULL DEFAULT '0', +key2 int(10) unsigned DEFAULT NULL, +text1 text, +text2 text, +col2 smallint(6) DEFAULT '100', +col3 enum('headers','bodyandsubject') NOT NULL DEFAULT 'bodyandsubject', +col4 tinyint(3) unsigned NOT NULL DEFAULT '0', +PRIMARY KEY (ID), +KEY (key1), +KEY (key2) +) AUTO_INCREMENT=6 DEFAULT CHARSET=utf8; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES +(1,NULL,1130,NULL,'Hello',NULL,100,'bodyandsubject',0), +(2,NULL,1130,NULL,'bye',NULL,100,'bodyandsubject',0), +(3,NULL,1130,NULL,'red',NULL,100,'bodyandsubject',0), +(4,NULL,1130,NULL,'yellow',NULL,100,'bodyandsubject',0), +(5,NULL,1130,NULL,'blue',NULL,100,'bodyandsubject',0); +select * FROM t1 WHERE key1=1130 AND col1 IS NULL ORDER BY text1; +ID col1 key1 key2 text1 text2 col2 col3 col4 +5 NULL 1130 NULL blue NULL 100 bodyandsubject 0 +2 NULL 1130 NULL bye NULL 100 bodyandsubject 0 +1 NULL 1130 NULL Hello NULL 100 bodyandsubject 0 +3 NULL 1130 NULL red NULL 100 bodyandsubject 0 +4 NULL 1130 NULL yellow NULL 100 bodyandsubject 0 +drop table t1; + +BUG#37851: Crash in test_if_skip_sort_order tab->select is zero + +CREATE TABLE t1 ( +pk int(11) NOT NULL AUTO_INCREMENT, +PRIMARY KEY (pk) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (1); +CREATE TABLE t2 ( +pk int(11) NOT NULL AUTO_INCREMENT, +int_key int(11) DEFAULT NULL, +PRIMARY KEY (pk), +KEY int_key (int_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (1,1),(2,6),(3,0); +EXPLAIN +SELECT MIN(t1.pk) +FROM t1 WHERE EXISTS ( +SELECT t2.pk +FROM t2 +WHERE t2.int_key IS NULL +GROUP BY t2.pk +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL PRIMARY 4 NULL 1 100.00 Using index +2 SIMPLE t2 NULL ref int_key int_key 5 const 1 100.00 Using where; Using index; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select min(`test`.`t1`.`pk`) AS `MIN(t1.pk)` from `test`.`t1` semi join (`test`.`t2`) where (`test`.`t2`.`int_key` is null) +DROP TABLE t1, t2; +# +# BUG#42048 Discrepancy between MyISAM and Maria's ICP implementation +# +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (a int, b char(20), filler char(200), key(a,b(10))); +insert into t1 select A.a + 10*(B.a + 10*C.a), 'bbb','filler' from t0 A, t0 B, t0 C; +update t1 set b=repeat(char(65+a), 20) where a < 25; +This must show range + using index condition: +explain select * from t1 where a < 10 and b = repeat(char(65+a), 20); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL x x Parallel execute (1 workers) +2 SIMPLE t1 NULL range a a 5 NULL x x Using index condition; Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`filler` AS `filler` from `test`.`t1` where ((`test`.`t1`.`a` < 10) and (`test`.`t1`.`b` = repeat(char((65 + `test`.`t1`.`a`)),20))) +select * from t1 where a < 10 and b = repeat(char(65+a), 20); +a b filler +0 AAAAAAAAAAAAAAAAAAAA filler +1 BBBBBBBBBBBBBBBBBBBB filler +2 CCCCCCCCCCCCCCCCCCCC filler +3 DDDDDDDDDDDDDDDDDDDD filler +4 EEEEEEEEEEEEEEEEEEEE filler +5 FFFFFFFFFFFFFFFFFFFF filler +6 GGGGGGGGGGGGGGGGGGGG filler +7 HHHHHHHHHHHHHHHHHHHH filler +8 IIIIIIIIIIIIIIIIIIII filler +9 JJJJJJJJJJJJJJJJJJJJ filler +drop table t0,t1; +# +# BUG#41136: ORDER BY + range access: EXPLAIN shows "Using MRR" while MRR is actually not used +# +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (a int, b int, key(a)); +insert into t1 select A.a + 10 *(B.a + 10*C.a), A.a + 10 *(B.a + 10*C.a) from t0 A, t0 B, t0 C; +This mustn't show "Using MRR": +explain select * from t1 where a < 20 order by a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 20 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range a a 5 NULL 20 100.00 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (`test`.`t1`.`a` < 20) order by `test`.`t1`.`a` +drop table t0, t1; +set @read_rnd_buffer_size_save= @@read_rnd_buffer_size; +set read_rnd_buffer_size=64; +create table t1(a int); +insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t2(a char(8), b char(8), c char(8), filler char(100), key k1(a,b,c) ) charset utf8mb4; +insert into t2 select +concat('a-', 1000 + A.a, '-a'), +concat('b-', 1000 + B.a, '-b'), +concat('c-', 1000 + C.a, '-c'), +'filler' +from t1 A, t1 B, t1 C; +EXPLAIN select count(length(a) + length(filler)) +from t2 force index (k1) +where a>='a-1000-a' and a <'a-1001-a'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 100 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL range k1 k1 33 NULL 100 100.00 Using index condition +Warnings: +Note 1003 /* select#1 */ select count((length(`test`.`t2`.`a`) + length(`test`.`t2`.`filler`))) AS `count(length(a) + length(filler))` from `test`.`t2` FORCE INDEX (`k1`) where ((`test`.`t2`.`a` >= 'a-1000-a') and (`test`.`t2`.`a` < 'a-1001-a')) +select count(length(a) + length(filler)) +from t2 force index (k1) +where a>='a-1000-a' and a <'a-1001-a'; +count(length(a) + length(filler)) +100 +drop table t2; +create table t2 (a char(100), b char(100), c char(100), d int, +filler char(10), key(d), primary key (a,b,c)) charset latin1; +insert into t2 select A.a, B.a, B.a, A.a, 'filler' from t1 A, t1 B; +explain select * from t2 force index (d) where d < 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (2 workers) +2 SIMPLE t2 NULL range d d 5 NULL # 100.00 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c`,`test`.`t2`.`d` AS `d`,`test`.`t2`.`filler` AS `filler` from `test`.`t2` FORCE INDEX (`d`) where (`test`.`t2`.`d` < 10) +drop table t2; +drop table t1; +set @@read_rnd_buffer_size= @read_rnd_buffer_size_save; +create table t1 (f1 int not null, f2 int not null,f3 int not null, f4 char(1), primary key (f1,f2), key ix(f3)); +select * from t1 where (f3>=5 and f3<=10) or (f3>=1 and f3<=4); +f1 f2 f3 f4 +1 1 1 A +10 10 10 A +2 2 2 A +3 3 3 A +4 4 4 A +5 5 5 A +6 6 6 A +7 7 7 A +8 8 8 A +9 9 9 A +drop table t1; + +BUG#37977: Wrong result returned on GROUP BY + OR + Innodb + +CREATE TABLE t1 ( +`pk` int(11) NOT NULL AUTO_INCREMENT, +`int_nokey` int(11) NOT NULL, +`int_key` int(11) NOT NULL, +`date_key` date NOT NULL, +`date_nokey` date NOT NULL, +`time_key` time NOT NULL, +`time_nokey` time NOT NULL, +`datetime_key` datetime NOT NULL, +`datetime_nokey` datetime NOT NULL, +`varchar_key` varchar(5) DEFAULT NULL, +`varchar_nokey` varchar(5) DEFAULT NULL, +PRIMARY KEY (`pk`), +KEY `int_key` (`int_key`), +KEY `date_key` (`date_key`), +KEY `time_key` (`time_key`), +KEY `datetime_key` (`datetime_key`), +KEY `varchar_key` (`varchar_key`) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT IGNORE INTO t1 VALUES +(1,5,5,'2009-10-16','2009-10-16','09:28:15','09:28:15','2007-09-14 05:34:08','2007-09-14 05:34:08','qk','qk'), +(2,6,6,'0000-00-00','0000-00-00','23:06:39','23:06:39','0000-00-00 00:00:00','0000-00-00 00:00:00','j','j'), +(3,10,10,'2000-12-18','2000-12-18','22:16:19','22:16:19','2006-11-04 15:42:50','2006-11-04 15:42:50','aew','aew'), +(4,0,0,'2001-09-18','2001-09-18','00:00:00','00:00:00','2004-03-23 13:23:35','2004-03-23 13:23:35',NULL,NULL), +(5,6,6,'2007-08-16','2007-08-16','22:13:38','22:13:38','2004-08-19 11:01:28','2004-08-19 11:01:28','qu','qu'); +Warnings: +Warning 1264 Out of range value for column 'date_key' at row 2 +Warning 1264 Out of range value for column 'date_nokey' at row 2 +Warning 1264 Out of range value for column 'datetime_key' at row 2 +Warning 1264 Out of range value for column 'datetime_nokey' at row 2 +select pk from t1 WHERE `varchar_key` > 'kr' group by pk; +pk +1 +5 +select pk from t1 WHERE `int_nokey` IS NULL OR `varchar_key` > 'kr' group by pk; +pk +1 +5 +drop table t1; +# +# BUG#39447: Error with NOT NULL condition and LIMIT 1 +# +CREATE TABLE t1 ( +id int(11) NOT NULL, +parent_id int(11) DEFAULT NULL, +name varchar(10) DEFAULT NULL, +PRIMARY KEY (id), +KEY ind_parent_id (parent_id) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t1 (id, parent_id, name) values +(10,NULL,'A'), +(20,10,'B'), +(30,10,'C'), +(40,NULL,'D'), +(50,40,'E'), +(60,40,'F'), +(70,NULL,'J'); +SELECT id FROM t1 WHERE parent_id IS NOT NULL ORDER BY id DESC LIMIT 1; +id +60 +This must show type=index, extra=Using where +explain SELECT * FROM t1 WHERE parent_id IS NOT NULL ORDER BY id DESC LIMIT 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 57.14 Backward index scan; Parallel execute (1 workers) +2 SIMPLE t1 NULL index ind_parent_id PRIMARY 4 NULL 1 57.14 Using where; Backward index scan +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,`test`.`t1`.`parent_id` AS `parent_id`,`test`.`t1`.`name` AS `name` from `test`.`t1` where (`test`.`t1`.`parent_id` is not null) order by `test`.`t1`.`id` desc limit 1 +SELECT * FROM t1 WHERE parent_id IS NOT NULL ORDER BY id DESC LIMIT 1; +id parent_id name +60 40 F +drop table t1; +# +# Bug#50381 "Assertion failing in handler.h:1283: +# void COST_VECT::add_io(double, double)" +# +CREATE TABLE t1 ( +c1 INT NOT NULL, +c2 VARCHAR(1) DEFAULT NULL, +PRIMARY KEY (c1) +); +CREATE TABLE t2 ( +c1 INT NOT NULL, +c2 VARCHAR(1) DEFAULT NULL, +PRIMARY KEY (c1) +); +INSERT INTO t2 VALUES (10,'v'); +INSERT INTO t2 VALUES (11,'r'); +SELECT t1.c2 +FROM t2 STRAIGHT_JOIN t1 ON t1.c1 < t2.c1; +c2 +DROP TABLE t1, t2; +# +# Bug#12321461: CRASH IN DSMRR_IMPL::DSMRR_INIT ON SELECT STRAIGHT_JOIN +# +set @save_optimizer_switch = @@optimizer_switch; +set optimizer_switch='block_nested_loop=off,batched_key_access=off'; +CREATE TABLE t1 ( +pk INTEGER, +c1 VARCHAR(1) NOT NULL, +PRIMARY KEY (pk) +); +CREATE TABLE t2 ( +c1 VARCHAR(1) NOT NULL +); +INSERT INTO t2 VALUES ('v'), ('c'); +EXPLAIN SELECT STRAIGHT_JOIN t1.c1 +FROM t1 RIGHT OUTER JOIN t2 ON t1.c1 = t2.c1 +WHERE t1.pk > 176; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 SIMPLE t1 NULL range PRIMARY PRIMARY 4 NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select straight_join `test`.`t1`.`c1` AS `c1` from `test`.`t2` join `test`.`t1` where ((`test`.`t1`.`c1` = `test`.`t2`.`c1`) and (`test`.`t1`.`pk` > 176)) +SELECT STRAIGHT_JOIN t1.c1 +FROM t1 RIGHT OUTER JOIN t2 ON t1.c1 = t2.c1 +WHERE t1.pk > 176; +c1 +DROP TABLE t1,t2; +set optimizer_switch= @save_optimizer_switch; +# +# Bug#13249966 MRR: RANDOM ERROR DUE TO UNINITIALIZED RES WITH +# SMALL READ_RND_BUFFER_SIZE +# +set @read_rnd_buffer_size_save= @@read_rnd_buffer_size; +set read_rnd_buffer_size=1; +select @@read_rnd_buffer_size; +@@read_rnd_buffer_size +1 +CREATE TABLE t1 ( +i1 INTEGER NOT NULL, +i2 INTEGER NOT NULL, +KEY (i2) +); +INSERT INTO t1 VALUES (0,1),(1,2),(2,3); +EXPLAIN SELECT i1 +FROM t1 +WHERE i2 > 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range i2 i2 4 NULL 1 100.00 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i1` AS `i1` from `test`.`t1` where (`test`.`t1`.`i2` > 2) +SELECT i1 +FROM t1 +WHERE i2 > 2; +i1 +2 +DROP TABLE t1; +set @@read_rnd_buffer_size= @read_rnd_buffer_size_save; +select @@read_rnd_buffer_size; +@@read_rnd_buffer_size +262144 +# +# Bug 12365385 STRAIGHT_JOIN QUERY QUICKLY EXHAUSTS SYSTEM+VIRT. +# MEMORY LEADING TO SYSTEM CRASH +# +CREATE TABLE ten (a INTEGER); +INSERT INTO ten VALUES (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +CREATE TABLE t1 ( +pk INTEGER NOT NULL, +i1 INTEGER NOT NULL, +c1 VARCHAR(10) NOT NULL, +PRIMARY KEY (pk) +) charset latin1; +INSERT INTO t1 +SELECT a, 1, 'MySQL' FROM ten; +CREATE TABLE t2 ( +pk INTEGER NOT NULL, +c1 VARCHAR(10) NOT NULL, +c2 varchar(10) NOT NULL, +PRIMARY KEY (pk) +) charset latin1; +INSERT INTO t2 +SELECT a, 'MySQL', 'MySQL' FROM ten; +CREATE TABLE t3 ( +pk INTEGER NOT NULL, +c1 VARCHAR(10) NOT NULL, +PRIMARY KEY (pk) +) charset latin1; +INSERT INTO t3 +SELECT a, 'MySQL' FROM ten; +CREATE TABLE t4 ( +pk int(11) NOT NULL, +c1_key varchar(10) CHARACTER SET utf8 NOT NULL, +c2 varchar(10) NOT NULL, +c3 varchar(10) NOT NULL, +PRIMARY KEY (pk), +KEY k1 (c1_key) +) charset latin1; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +CREATE TABLE t5 ( +pk INTEGER NOT NULL, +c1 VARCHAR(10) NOT NULL, +PRIMARY KEY (pk) +) charset latin1; +INSERT INTO t5 +SELECT a, 'MySQL' FROM ten; +EXPLAIN SELECT STRAIGHT_JOIN * +FROM +(t1 LEFT JOIN +(t2 LEFT JOIN +(t3 LEFT OUTER JOIN t4 ON t3.c1 <= t4.c1_key) +ON t2.c1 = t4.c3) +ON t1.c1 = t4.c2) +RIGHT OUTER JOIN t5 ON t2.c2 <= t5.c1 +WHERE t1.i1 = 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 100.00 Parallel execute (1 workers) +2 SIMPLE t5 NULL ALL NULL NULL NULL NULL 10 100.00 NULL +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 10.00 Using where; Using join buffer (hash join) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 10 33.33 Using where; Using join buffer (hash join) +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 10 100.00 Using join buffer (hash join) +2 SIMPLE t4 NULL ALL k1 NULL NULL NULL 1 100.00 Range checked for each record (index map: 0x2) +Warnings: +Note 1003 /* select#1 */ select straight_join `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`i1` AS `i1`,`test`.`t1`.`c1` AS `c1`,`test`.`t2`.`pk` AS `pk`,`test`.`t2`.`c1` AS `c1`,`test`.`t2`.`c2` AS `c2`,`test`.`t3`.`pk` AS `pk`,`test`.`t3`.`c1` AS `c1`,`test`.`t4`.`pk` AS `pk`,`test`.`t4`.`c1_key` AS `c1_key`,`test`.`t4`.`c2` AS `c2`,`test`.`t4`.`c3` AS `c3`,`test`.`t5`.`pk` AS `pk`,`test`.`t5`.`c1` AS `c1` from `test`.`t5` join `test`.`t1` join `test`.`t2` join `test`.`t3` join `test`.`t4` where ((`test`.`t4`.`c3` = `test`.`t2`.`c1`) and (`test`.`t4`.`c2` = `test`.`t1`.`c1`) and (`test`.`t1`.`i1` = 1) and (`test`.`t2`.`c2` <= `test`.`t5`.`c1`) and (`test`.`t3`.`c1` <= `test`.`t4`.`c1_key`)) +SELECT STRAIGHT_JOIN * +FROM +(t1 LEFT JOIN +(t2 LEFT JOIN +(t3 LEFT OUTER JOIN t4 ON t3.c1 <= t4.c1_key) +ON t2.c1 = t4.c3) +ON t1.c1 = t4.c2) +RIGHT OUTER JOIN t5 ON t2.c2 <= t5.c1 +WHERE t1.i1 = 1; +pk i1 c1 pk c1 c2 pk c1 pk c1_key c2 c3 pk c1 +DROP TABLE ten, t1, t2, t3, t4, t5; +# +# Bug 18172819 CRASH ON DSMRR_IMPL::CHOOSE_MRR_IMPL IN SQL/HANDLER.CC +# +set @big_tables_save= @@big_tables; +set @optimizer_switch_save=@@optimizer_switch; +set big_tables=ON; +set optimizer_switch='derived_merge=off'; +SELECT @@big_tables; +@@big_tables +1 +CREATE TABLE t1 ( +i1 INTEGER NOT NULL, +c1 VARCHAR(1) +) charset utf8mb4; +INSERT INTO t1 VALUES (1,'a'), (2, NULL); +CREATE TABLE t2 ( +c1 VARCHAR(1), +i1 INTEGER NOT NULL, +KEY (c1) +) charset utf8mb4; +INSERT INTO t2 VALUES ('a', 1), (NULL, 2); +EXPLAIN SELECT * +FROM +( SELECT * FROM t1 ) AS d1 +WHERE d1.c1 IN ( SELECT c1 FROM t2 ) +AND d1.c1 IS NULL +ORDER BY d1.i1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t2 NULL index c1 c1 7 NULL 2 100.00 Using index; Using temporary; Using filesort; LooseScan +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 DERIVED t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `d1`.`i1` AS `i1`,`d1`.`c1` AS `c1` from (/* select#2 */ select `test`.`t1`.`i1` AS `i1`,`test`.`t1`.`c1` AS `c1` from `test`.`t1` where (`test`.`t1`.`c1` is null)) `d1` semi join (`test`.`t2`) where (`d1`.`c1` = `test`.`t2`.`c1`) order by `d1`.`i1` +SELECT * +FROM +( SELECT * FROM t1 ) AS d1 +WHERE d1.c1 IN ( SELECT c1 FROM t2 ) +AND d1.c1 IS NULL +ORDER BY d1.i1; +i1 c1 +DROP TABLE t1, t2; +set big_tables=@big_tables_save; +set optimizer_switch=@optimizer_switch_save; +# +# Bug#41029 "MRR: SELECT FOR UPDATE fails to lock gaps (InnoDB table)" +# +SET AUTOCOMMIT=0; +CREATE TABLE t1 ( +dummy INT PRIMARY KEY, +a INT UNIQUE, +b INT +) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1,1,1),(3,3,3),(5,5,5); +COMMIT; +SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ; +SELECT @@transaction_isolation; +@@transaction_isolation +REPEATABLE-READ +START TRANSACTION; +EXPLAIN SELECT * FROM t1 WHERE a > 2 FOR UPDATE; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range a a 5 NULL 2 100.00 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`dummy` AS `dummy`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (`test`.`t1`.`a` > 2) +SELECT * FROM t1 WHERE a > 2 FOR UPDATE; +dummy a b +3 3 3 +5 5 5 +SET AUTOCOMMIT=0; +START TRANSACTION; +INSERT INTO t1 VALUES (2,2,2); +ERROR HY000: Lock wait timeout exceeded; try restarting transaction +ROLLBACK; +ROLLBACK; +DROP TABLE t1; +# +# Bug#54286 "Server crash at lock timeout with MRR" +# +SET AUTOCOMMIT=0; +CREATE TABLE t1 ( +dummy INT PRIMARY KEY, +a INT UNIQUE, +b INT +) ENGINE=InnoDB; +COMMIT; +INSERT INTO t1 VALUES (1,1,1),(3,3,3),(5,5,5); +SET AUTOCOMMIT=0; +SELECT * FROM t1 WHERE a > 2 FOR UPDATE; +ERROR HY000: Lock wait timeout exceeded; try restarting transaction +ROLLBACK; +ROLLBACK; +DROP TABLE t1; +COMMIT; +set default_storage_engine= @save_storage_engine; +set optimizer_switch=default; diff --git a/mysql-test/r/innodb_mrr_cost_icp.result-pq b/mysql-test/r/innodb_mrr_cost_icp.result-pq new file mode 100644 index 000000000000..c4a585bc8eaf --- /dev/null +++ b/mysql-test/r/innodb_mrr_cost_icp.result-pq @@ -0,0 +1,801 @@ +set optimizer_switch='index_condition_pushdown=on,mrr=on,mrr_cost_based=on'; +set @save_storage_engine= @@default_storage_engine; +set default_storage_engine=InnoDB; +create table t1(a int) charset utf8mb4; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t2(a int); +insert into t2 select A.a + 10*(B.a + 10*C.a) from t1 A, t1 B, t1 C; +create table t3 ( +a char(8) not null, b char(8) not null, filler char(200), +key(a) +); +insert into t3 select @a:=concat('c-', 1000+ A.a, '=w'), @a, 'filler' from t2 A; +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +insert into t3 select concat('c-', 1000+A.a, '=w'), concat('c-', 2000+A.a, '=w'), +'filler-1' from t2 A; +insert into t3 select concat('c-', 1000+A.a, '=w'), concat('c-', 3000+A.a, '=w'), +'filler-2' from t2 A; +select a,filler from t3 where a >= 'c-9011=w'; +a filler +select a,filler from t3 where a >= 'c-1011=w' and a <= 'c-1015=w'; +a filler +c-1011=w filler +c-1011=w filler-1 +c-1011=w filler-2 +c-1012=w filler +c-1012=w filler-1 +c-1012=w filler-2 +c-1013=w filler +c-1013=w filler-1 +c-1013=w filler-2 +c-1014=w filler +c-1014=w filler-1 +c-1014=w filler-2 +c-1015=w filler +c-1015=w filler-1 +c-1015=w filler-2 +select a,filler from t3 where (a>='c-1011=w' and a <= 'c-1013=w') or +(a>='c-1014=w' and a <= 'c-1015=w'); +a filler +c-1011=w filler +c-1011=w filler-1 +c-1011=w filler-2 +c-1012=w filler +c-1012=w filler-1 +c-1012=w filler-2 +c-1013=w filler +c-1013=w filler-1 +c-1013=w filler-2 +c-1014=w filler +c-1014=w filler-1 +c-1014=w filler-2 +c-1015=w filler +c-1015=w filler-1 +c-1015=w filler-2 +insert into t3 values ('c-1013=z', 'c-1013=z', 'err'); +insert into t3 values ('a-1014=w', 'a-1014=w', 'err'); +select a,filler from t3 where (a>='c-1011=w' and a <= 'c-1013=w') or +(a>='c-1014=w' and a <= 'c-1015=w'); +a filler +c-1011=w filler +c-1011=w filler-1 +c-1011=w filler-2 +c-1012=w filler +c-1012=w filler-1 +c-1012=w filler-2 +c-1013=w filler +c-1013=w filler-1 +c-1013=w filler-2 +c-1014=w filler +c-1014=w filler-1 +c-1014=w filler-2 +c-1015=w filler +c-1015=w filler-1 +c-1015=w filler-2 +delete from t3 where b in ('c-1013=z', 'a-1014=w'); +select a,filler from t3 where a='c-1011=w' or a='c-1012=w' or a='c-1013=w' or +a='c-1014=w' or a='c-1015=w'; +a filler +c-1011=w filler +c-1011=w filler-1 +c-1011=w filler-2 +c-1012=w filler +c-1012=w filler-1 +c-1012=w filler-2 +c-1013=w filler +c-1013=w filler-1 +c-1013=w filler-2 +c-1014=w filler +c-1014=w filler-1 +c-1014=w filler-2 +c-1015=w filler +c-1015=w filler-1 +c-1015=w filler-2 +insert into t3 values ('c-1013=w', 'del-me', 'inserted'); +select a,filler from t3 where a='c-1011=w' or a='c-1012=w' or a='c-1013=w' or +a='c-1014=w' or a='c-1015=w'; +a filler +c-1011=w filler +c-1011=w filler-1 +c-1011=w filler-2 +c-1012=w filler +c-1012=w filler-1 +c-1012=w filler-2 +c-1013=w filler +c-1013=w filler-1 +c-1013=w filler-2 +c-1013=w inserted +c-1014=w filler +c-1014=w filler-1 +c-1014=w filler-2 +c-1015=w filler +c-1015=w filler-1 +c-1015=w filler-2 +delete from t3 where b='del-me'; +alter table t3 add primary key(b); +select b,filler from t3 where (b>='c-1011=w' and b<= 'c-1018=w') or +b IN ('c-1019=w', 'c-1020=w', 'c-1021=w', +'c-1022=w', 'c-1023=w', 'c-1024=w'); +b filler +c-1011=w filler +c-1012=w filler +c-1013=w filler +c-1014=w filler +c-1015=w filler +c-1016=w filler +c-1017=w filler +c-1018=w filler +c-1019=w filler +c-1020=w filler +c-1021=w filler +c-1022=w filler +c-1023=w filler +c-1024=w filler +select b,filler from t3 where (b>='c-1011=w' and b<= 'c-1020=w') or +b IN ('c-1021=w', 'c-1022=w', 'c-1023=w'); +b filler +c-1011=w filler +c-1012=w filler +c-1013=w filler +c-1014=w filler +c-1015=w filler +c-1016=w filler +c-1017=w filler +c-1018=w filler +c-1019=w filler +c-1020=w filler +c-1021=w filler +c-1022=w filler +c-1023=w filler +select b,filler from t3 where (b>='c-1011=w' and b<= 'c-1018=w') or +b IN ('c-1019=w', 'c-1020=w') or +(b>='c-1021=w' and b<= 'c-1023=w'); +b filler +c-1011=w filler +c-1012=w filler +c-1013=w filler +c-1014=w filler +c-1015=w filler +c-1016=w filler +c-1017=w filler +c-1018=w filler +c-1019=w filler +c-1020=w filler +c-1021=w filler +c-1022=w filler +c-1023=w filler +create table t4 (a varchar(10), b int, c char(10), filler char(200), +key idx1 (a, b, c)) charset utf8mb4; +insert into t4 (filler) select concat('NULL-', 15-a) from t2 order by a limit 15; +insert into t4 (a,b,c,filler) +select 'b-1',NULL,'c-1', concat('NULL-', 15-a) from t2 order by a limit 15; +insert into t4 (a,b,c,filler) +select 'b-1',NULL,'c-222', concat('NULL-', 15-a) from t2 order by a limit 15; +insert into t4 (a,b,c,filler) +select 'bb-1',NULL,'cc-2', concat('NULL-', 15-a) from t2 order by a limit 15; +insert into t4 (a,b,c,filler) +select 'zz-1',NULL,'cc-2', 'filler-data' from t2 order by a limit 500; +explain +select * from t4 where a IS NULL and b IS NULL and (c IS NULL or c='no-such-row1' + or c='no-such-row2'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 16 100.00 Parallel execute (2 workers) +2 SIMPLE t4 NULL range idx1 idx1 89 NULL 16 100.00 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t4`.`c` AS `c`,`test`.`t4`.`filler` AS `filler` from `test`.`t4` where ((`test`.`t4`.`a` is null) and (`test`.`t4`.`b` is null) and ((`test`.`t4`.`c` is null) or (`test`.`t4`.`c` = 'no-such-row1') or (`test`.`t4`.`c` = 'no-such-row2'))) +select * from t4 where a IS NULL and b IS NULL and (c IS NULL or c='no-such-row1' + or c='no-such-row2'); +a b c filler +NULL NULL NULL NULL-15 +NULL NULL NULL NULL-14 +NULL NULL NULL NULL-13 +NULL NULL NULL NULL-12 +NULL NULL NULL NULL-11 +NULL NULL NULL NULL-10 +NULL NULL NULL NULL-9 +NULL NULL NULL NULL-8 +NULL NULL NULL NULL-7 +NULL NULL NULL NULL-6 +NULL NULL NULL NULL-5 +NULL NULL NULL NULL-4 +NULL NULL NULL NULL-3 +NULL NULL NULL NULL-2 +NULL NULL NULL NULL-1 +explain +select * from t4 where (a ='b-1' or a='bb-1') and b IS NULL and (c='c-1' or c='cc-2'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 32 100.00 Parallel execute (4 workers) +2 SIMPLE t4 NULL range idx1 idx1 89 NULL 32 100.00 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t4`.`c` AS `c`,`test`.`t4`.`filler` AS `filler` from `test`.`t4` where (((`test`.`t4`.`a` = 'b-1') or (`test`.`t4`.`a` = 'bb-1')) and (`test`.`t4`.`b` is null) and ((`test`.`t4`.`c` = 'c-1') or (`test`.`t4`.`c` = 'cc-2'))) +select * from t4 where (a ='b-1' or a='bb-1') and b IS NULL and (c='c-1' or c='cc-2'); +a b c filler +b-1 NULL c-1 NULL-15 +b-1 NULL c-1 NULL-14 +b-1 NULL c-1 NULL-13 +b-1 NULL c-1 NULL-12 +b-1 NULL c-1 NULL-11 +b-1 NULL c-1 NULL-10 +b-1 NULL c-1 NULL-9 +b-1 NULL c-1 NULL-8 +b-1 NULL c-1 NULL-7 +b-1 NULL c-1 NULL-6 +b-1 NULL c-1 NULL-5 +b-1 NULL c-1 NULL-4 +b-1 NULL c-1 NULL-3 +b-1 NULL c-1 NULL-2 +b-1 NULL c-1 NULL-1 +bb-1 NULL cc-2 NULL-15 +bb-1 NULL cc-2 NULL-14 +bb-1 NULL cc-2 NULL-13 +bb-1 NULL cc-2 NULL-12 +bb-1 NULL cc-2 NULL-11 +bb-1 NULL cc-2 NULL-10 +bb-1 NULL cc-2 NULL-9 +bb-1 NULL cc-2 NULL-8 +bb-1 NULL cc-2 NULL-7 +bb-1 NULL cc-2 NULL-6 +bb-1 NULL cc-2 NULL-5 +bb-1 NULL cc-2 NULL-4 +bb-1 NULL cc-2 NULL-3 +bb-1 NULL cc-2 NULL-2 +bb-1 NULL cc-2 NULL-1 +select * from t4 ignore index(idx1) where (a ='b-1' or a='bb-1') and b IS NULL and (c='c-1' or c='cc-2'); +a b c filler +b-1 NULL c-1 NULL-15 +b-1 NULL c-1 NULL-14 +b-1 NULL c-1 NULL-13 +b-1 NULL c-1 NULL-12 +b-1 NULL c-1 NULL-11 +b-1 NULL c-1 NULL-10 +b-1 NULL c-1 NULL-9 +b-1 NULL c-1 NULL-8 +b-1 NULL c-1 NULL-7 +b-1 NULL c-1 NULL-6 +b-1 NULL c-1 NULL-5 +b-1 NULL c-1 NULL-4 +b-1 NULL c-1 NULL-3 +b-1 NULL c-1 NULL-2 +b-1 NULL c-1 NULL-1 +bb-1 NULL cc-2 NULL-15 +bb-1 NULL cc-2 NULL-14 +bb-1 NULL cc-2 NULL-13 +bb-1 NULL cc-2 NULL-12 +bb-1 NULL cc-2 NULL-11 +bb-1 NULL cc-2 NULL-10 +bb-1 NULL cc-2 NULL-9 +bb-1 NULL cc-2 NULL-8 +bb-1 NULL cc-2 NULL-7 +bb-1 NULL cc-2 NULL-6 +bb-1 NULL cc-2 NULL-5 +bb-1 NULL cc-2 NULL-4 +bb-1 NULL cc-2 NULL-3 +bb-1 NULL cc-2 NULL-2 +bb-1 NULL cc-2 NULL-1 +drop table t1, t2, t3, t4; +create table t1 (a int, b int not null,unique key (a,b),index(b)); +insert ignore into t1 values (1,1),(2,2),(3,3),(4,4),(5,5),(6,6),(null,7),(9,9),(8,8),(7,7),(null,9),(null,9),(6,6); +Warnings: +Warning 1062 Duplicate entry '6-6' for key 't1.a' +create table t2 like t1; +insert into t2 select * from t1; +alter table t1 modify b blob not null, add c int not null, drop key a, add unique key (a,b(20),c), drop key b, add key (b(10)); +select * from t1 where a is null; +a b c +NULL 7 0 +NULL 9 0 +NULL 9 0 +select * from t1 where (a is null or a > 0 and a < 3) and b > 7 limit 3; +a b c +NULL 9 0 +NULL 9 0 +select * from t1 where a is null and b=9 or a is null and b=7 limit 3; +a b c +NULL 7 0 +NULL 9 0 +NULL 9 0 +drop table t1, t2; +CREATE TABLE t1 ( +ID int(10) unsigned NOT NULL AUTO_INCREMENT, +col1 int(10) unsigned DEFAULT NULL, +key1 int(10) unsigned NOT NULL DEFAULT '0', +key2 int(10) unsigned DEFAULT NULL, +text1 text, +text2 text, +col2 smallint(6) DEFAULT '100', +col3 enum('headers','bodyandsubject') NOT NULL DEFAULT 'bodyandsubject', +col4 tinyint(3) unsigned NOT NULL DEFAULT '0', +PRIMARY KEY (ID), +KEY (key1), +KEY (key2) +) AUTO_INCREMENT=6 DEFAULT CHARSET=utf8; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES +(1,NULL,1130,NULL,'Hello',NULL,100,'bodyandsubject',0), +(2,NULL,1130,NULL,'bye',NULL,100,'bodyandsubject',0), +(3,NULL,1130,NULL,'red',NULL,100,'bodyandsubject',0), +(4,NULL,1130,NULL,'yellow',NULL,100,'bodyandsubject',0), +(5,NULL,1130,NULL,'blue',NULL,100,'bodyandsubject',0); +select * FROM t1 WHERE key1=1130 AND col1 IS NULL ORDER BY text1; +ID col1 key1 key2 text1 text2 col2 col3 col4 +5 NULL 1130 NULL blue NULL 100 bodyandsubject 0 +2 NULL 1130 NULL bye NULL 100 bodyandsubject 0 +1 NULL 1130 NULL Hello NULL 100 bodyandsubject 0 +3 NULL 1130 NULL red NULL 100 bodyandsubject 0 +4 NULL 1130 NULL yellow NULL 100 bodyandsubject 0 +drop table t1; + +BUG#37851: Crash in test_if_skip_sort_order tab->select is zero + +CREATE TABLE t1 ( +pk int(11) NOT NULL AUTO_INCREMENT, +PRIMARY KEY (pk) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (1); +CREATE TABLE t2 ( +pk int(11) NOT NULL AUTO_INCREMENT, +int_key int(11) DEFAULT NULL, +PRIMARY KEY (pk), +KEY int_key (int_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (1,1),(2,6),(3,0); +EXPLAIN +SELECT MIN(t1.pk) +FROM t1 WHERE EXISTS ( +SELECT t2.pk +FROM t2 +WHERE t2.int_key IS NULL +GROUP BY t2.pk +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +2 SUBQUERY t2 NULL ref int_key int_key 5 const 1 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select min(`test`.`t1`.`pk`) AS `MIN(t1.pk)` from `test`.`t1` where false +DROP TABLE t1, t2; +# +# BUG#42048 Discrepancy between MyISAM and Maria's ICP implementation +# +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (a int, b char(20), filler char(200), key(a,b(10))); +insert into t1 select A.a + 10*(B.a + 10*C.a), 'bbb','filler' from t0 A, t0 B, t0 C; +update t1 set b=repeat(char(65+a), 20) where a < 25; +This must show range + using index condition: +explain select * from t1 where a < 10 and b = repeat(char(65+a), 20); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL x x Parallel execute (1 workers) +2 SIMPLE t1 NULL range a a 5 NULL x x Using index condition; Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`filler` AS `filler` from `test`.`t1` where ((`test`.`t1`.`a` < 10) and (`test`.`t1`.`b` = repeat(char((65 + `test`.`t1`.`a`)),20))) +select * from t1 where a < 10 and b = repeat(char(65+a), 20); +a b filler +0 AAAAAAAAAAAAAAAAAAAA filler +1 BBBBBBBBBBBBBBBBBBBB filler +2 CCCCCCCCCCCCCCCCCCCC filler +3 DDDDDDDDDDDDDDDDDDDD filler +4 EEEEEEEEEEEEEEEEEEEE filler +5 FFFFFFFFFFFFFFFFFFFF filler +6 GGGGGGGGGGGGGGGGGGGG filler +7 HHHHHHHHHHHHHHHHHHHH filler +8 IIIIIIIIIIIIIIIIIIII filler +9 JJJJJJJJJJJJJJJJJJJJ filler +drop table t0,t1; +# +# BUG#41136: ORDER BY + range access: EXPLAIN shows "Using MRR" while MRR is actually not used +# +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (a int, b int, key(a)); +insert into t1 select A.a + 10 *(B.a + 10*C.a), A.a + 10 *(B.a + 10*C.a) from t0 A, t0 B, t0 C; +This mustn't show "Using MRR": +explain select * from t1 where a < 20 order by a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 20 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range a a 5 NULL 20 100.00 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (`test`.`t1`.`a` < 20) order by `test`.`t1`.`a` +drop table t0, t1; +set @read_rnd_buffer_size_save= @@read_rnd_buffer_size; +set read_rnd_buffer_size=64; +create table t1(a int); +insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t2(a char(8), b char(8), c char(8), filler char(100), key k1(a,b,c) ) charset utf8mb4; +insert into t2 select +concat('a-', 1000 + A.a, '-a'), +concat('b-', 1000 + B.a, '-b'), +concat('c-', 1000 + C.a, '-c'), +'filler' +from t1 A, t1 B, t1 C; +EXPLAIN select count(length(a) + length(filler)) +from t2 force index (k1) +where a>='a-1000-a' and a <'a-1001-a'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 100 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL range k1 k1 33 NULL 100 100.00 Using index condition +Warnings: +Note 1003 /* select#1 */ select count((length(`test`.`t2`.`a`) + length(`test`.`t2`.`filler`))) AS `count(length(a) + length(filler))` from `test`.`t2` FORCE INDEX (`k1`) where ((`test`.`t2`.`a` >= 'a-1000-a') and (`test`.`t2`.`a` < 'a-1001-a')) +select count(length(a) + length(filler)) +from t2 force index (k1) +where a>='a-1000-a' and a <'a-1001-a'; +count(length(a) + length(filler)) +100 +drop table t2; +create table t2 (a char(100), b char(100), c char(100), d int, +filler char(10), key(d), primary key (a,b,c)) charset latin1; +insert into t2 select A.a, B.a, B.a, A.a, 'filler' from t1 A, t1 B; +explain select * from t2 force index (d) where d < 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (2 workers) +2 SIMPLE t2 NULL range d d 5 NULL # 100.00 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c`,`test`.`t2`.`d` AS `d`,`test`.`t2`.`filler` AS `filler` from `test`.`t2` FORCE INDEX (`d`) where (`test`.`t2`.`d` < 10) +drop table t2; +drop table t1; +set @@read_rnd_buffer_size= @read_rnd_buffer_size_save; +create table t1 (f1 int not null, f2 int not null,f3 int not null, f4 char(1), primary key (f1,f2), key ix(f3)); +select * from t1 where (f3>=5 and f3<=10) or (f3>=1 and f3<=4); +f1 f2 f3 f4 +1 1 1 A +10 10 10 A +2 2 2 A +3 3 3 A +4 4 4 A +5 5 5 A +6 6 6 A +7 7 7 A +8 8 8 A +9 9 9 A +drop table t1; + +BUG#37977: Wrong result returned on GROUP BY + OR + Innodb + +CREATE TABLE t1 ( +`pk` int(11) NOT NULL AUTO_INCREMENT, +`int_nokey` int(11) NOT NULL, +`int_key` int(11) NOT NULL, +`date_key` date NOT NULL, +`date_nokey` date NOT NULL, +`time_key` time NOT NULL, +`time_nokey` time NOT NULL, +`datetime_key` datetime NOT NULL, +`datetime_nokey` datetime NOT NULL, +`varchar_key` varchar(5) DEFAULT NULL, +`varchar_nokey` varchar(5) DEFAULT NULL, +PRIMARY KEY (`pk`), +KEY `int_key` (`int_key`), +KEY `date_key` (`date_key`), +KEY `time_key` (`time_key`), +KEY `datetime_key` (`datetime_key`), +KEY `varchar_key` (`varchar_key`) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT IGNORE INTO t1 VALUES +(1,5,5,'2009-10-16','2009-10-16','09:28:15','09:28:15','2007-09-14 05:34:08','2007-09-14 05:34:08','qk','qk'), +(2,6,6,'0000-00-00','0000-00-00','23:06:39','23:06:39','0000-00-00 00:00:00','0000-00-00 00:00:00','j','j'), +(3,10,10,'2000-12-18','2000-12-18','22:16:19','22:16:19','2006-11-04 15:42:50','2006-11-04 15:42:50','aew','aew'), +(4,0,0,'2001-09-18','2001-09-18','00:00:00','00:00:00','2004-03-23 13:23:35','2004-03-23 13:23:35',NULL,NULL), +(5,6,6,'2007-08-16','2007-08-16','22:13:38','22:13:38','2004-08-19 11:01:28','2004-08-19 11:01:28','qu','qu'); +Warnings: +Warning 1264 Out of range value for column 'date_key' at row 2 +Warning 1264 Out of range value for column 'date_nokey' at row 2 +Warning 1264 Out of range value for column 'datetime_key' at row 2 +Warning 1264 Out of range value for column 'datetime_nokey' at row 2 +select pk from t1 WHERE `varchar_key` > 'kr' group by pk; +pk +1 +5 +select pk from t1 WHERE `int_nokey` IS NULL OR `varchar_key` > 'kr' group by pk; +pk +1 +5 +drop table t1; +# +# BUG#39447: Error with NOT NULL condition and LIMIT 1 +# +CREATE TABLE t1 ( +id int(11) NOT NULL, +parent_id int(11) DEFAULT NULL, +name varchar(10) DEFAULT NULL, +PRIMARY KEY (id), +KEY ind_parent_id (parent_id) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t1 (id, parent_id, name) values +(10,NULL,'A'), +(20,10,'B'), +(30,10,'C'), +(40,NULL,'D'), +(50,40,'E'), +(60,40,'F'), +(70,NULL,'J'); +SELECT id FROM t1 WHERE parent_id IS NOT NULL ORDER BY id DESC LIMIT 1; +id +60 +This must show type=index, extra=Using where +explain SELECT * FROM t1 WHERE parent_id IS NOT NULL ORDER BY id DESC LIMIT 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 57.14 Backward index scan; Parallel execute (1 workers) +2 SIMPLE t1 NULL index ind_parent_id PRIMARY 4 NULL 1 57.14 Using where; Backward index scan +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,`test`.`t1`.`parent_id` AS `parent_id`,`test`.`t1`.`name` AS `name` from `test`.`t1` where (`test`.`t1`.`parent_id` is not null) order by `test`.`t1`.`id` desc limit 1 +SELECT * FROM t1 WHERE parent_id IS NOT NULL ORDER BY id DESC LIMIT 1; +id parent_id name +60 40 F +drop table t1; +# +# Bug#50381 "Assertion failing in handler.h:1283: +# void COST_VECT::add_io(double, double)" +# +CREATE TABLE t1 ( +c1 INT NOT NULL, +c2 VARCHAR(1) DEFAULT NULL, +PRIMARY KEY (c1) +); +CREATE TABLE t2 ( +c1 INT NOT NULL, +c2 VARCHAR(1) DEFAULT NULL, +PRIMARY KEY (c1) +); +INSERT INTO t2 VALUES (10,'v'); +INSERT INTO t2 VALUES (11,'r'); +SELECT t1.c2 +FROM t2 STRAIGHT_JOIN t1 ON t1.c1 < t2.c1; +c2 +DROP TABLE t1, t2; +# +# Bug#12321461: CRASH IN DSMRR_IMPL::DSMRR_INIT ON SELECT STRAIGHT_JOIN +# +set @save_optimizer_switch = @@optimizer_switch; +set optimizer_switch='block_nested_loop=off,batched_key_access=off'; +CREATE TABLE t1 ( +pk INTEGER, +c1 VARCHAR(1) NOT NULL, +PRIMARY KEY (pk) +); +CREATE TABLE t2 ( +c1 VARCHAR(1) NOT NULL +); +INSERT INTO t2 VALUES ('v'), ('c'); +EXPLAIN SELECT STRAIGHT_JOIN t1.c1 +FROM t1 RIGHT OUTER JOIN t2 ON t1.c1 = t2.c1 +WHERE t1.pk > 176; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 SIMPLE t1 NULL range PRIMARY PRIMARY 4 NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select straight_join `test`.`t1`.`c1` AS `c1` from `test`.`t2` join `test`.`t1` where ((`test`.`t1`.`c1` = `test`.`t2`.`c1`) and (`test`.`t1`.`pk` > 176)) +SELECT STRAIGHT_JOIN t1.c1 +FROM t1 RIGHT OUTER JOIN t2 ON t1.c1 = t2.c1 +WHERE t1.pk > 176; +c1 +DROP TABLE t1,t2; +set optimizer_switch= @save_optimizer_switch; +# +# Bug#13249966 MRR: RANDOM ERROR DUE TO UNINITIALIZED RES WITH +# SMALL READ_RND_BUFFER_SIZE +# +set @read_rnd_buffer_size_save= @@read_rnd_buffer_size; +set read_rnd_buffer_size=1; +select @@read_rnd_buffer_size; +@@read_rnd_buffer_size +1 +CREATE TABLE t1 ( +i1 INTEGER NOT NULL, +i2 INTEGER NOT NULL, +KEY (i2) +); +INSERT INTO t1 VALUES (0,1),(1,2),(2,3); +EXPLAIN SELECT i1 +FROM t1 +WHERE i2 > 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range i2 i2 4 NULL 1 100.00 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i1` AS `i1` from `test`.`t1` where (`test`.`t1`.`i2` > 2) +SELECT i1 +FROM t1 +WHERE i2 > 2; +i1 +2 +DROP TABLE t1; +set @@read_rnd_buffer_size= @read_rnd_buffer_size_save; +select @@read_rnd_buffer_size; +@@read_rnd_buffer_size +262144 +# +# Bug 12365385 STRAIGHT_JOIN QUERY QUICKLY EXHAUSTS SYSTEM+VIRT. +# MEMORY LEADING TO SYSTEM CRASH +# +CREATE TABLE ten (a INTEGER); +INSERT INTO ten VALUES (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +CREATE TABLE t1 ( +pk INTEGER NOT NULL, +i1 INTEGER NOT NULL, +c1 VARCHAR(10) NOT NULL, +PRIMARY KEY (pk) +) charset latin1; +INSERT INTO t1 +SELECT a, 1, 'MySQL' FROM ten; +CREATE TABLE t2 ( +pk INTEGER NOT NULL, +c1 VARCHAR(10) NOT NULL, +c2 varchar(10) NOT NULL, +PRIMARY KEY (pk) +) charset latin1; +INSERT INTO t2 +SELECT a, 'MySQL', 'MySQL' FROM ten; +CREATE TABLE t3 ( +pk INTEGER NOT NULL, +c1 VARCHAR(10) NOT NULL, +PRIMARY KEY (pk) +) charset latin1; +INSERT INTO t3 +SELECT a, 'MySQL' FROM ten; +CREATE TABLE t4 ( +pk int(11) NOT NULL, +c1_key varchar(10) CHARACTER SET utf8 NOT NULL, +c2 varchar(10) NOT NULL, +c3 varchar(10) NOT NULL, +PRIMARY KEY (pk), +KEY k1 (c1_key) +) charset latin1; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +CREATE TABLE t5 ( +pk INTEGER NOT NULL, +c1 VARCHAR(10) NOT NULL, +PRIMARY KEY (pk) +) charset latin1; +INSERT INTO t5 +SELECT a, 'MySQL' FROM ten; +EXPLAIN SELECT STRAIGHT_JOIN * +FROM +(t1 LEFT JOIN +(t2 LEFT JOIN +(t3 LEFT OUTER JOIN t4 ON t3.c1 <= t4.c1_key) +ON t2.c1 = t4.c3) +ON t1.c1 = t4.c2) +RIGHT OUTER JOIN t5 ON t2.c2 <= t5.c1 +WHERE t1.i1 = 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 100.00 Parallel execute (1 workers) +2 SIMPLE t5 NULL ALL NULL NULL NULL NULL 10 100.00 NULL +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 10.00 Using where; Using join buffer (hash join) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 10 33.33 Using where; Using join buffer (hash join) +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 10 100.00 Using join buffer (hash join) +2 SIMPLE t4 NULL ALL k1 NULL NULL NULL 1 100.00 Range checked for each record (index map: 0x2) +Warnings: +Note 1003 /* select#1 */ select straight_join `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`i1` AS `i1`,`test`.`t1`.`c1` AS `c1`,`test`.`t2`.`pk` AS `pk`,`test`.`t2`.`c1` AS `c1`,`test`.`t2`.`c2` AS `c2`,`test`.`t3`.`pk` AS `pk`,`test`.`t3`.`c1` AS `c1`,`test`.`t4`.`pk` AS `pk`,`test`.`t4`.`c1_key` AS `c1_key`,`test`.`t4`.`c2` AS `c2`,`test`.`t4`.`c3` AS `c3`,`test`.`t5`.`pk` AS `pk`,`test`.`t5`.`c1` AS `c1` from `test`.`t5` join `test`.`t1` join `test`.`t2` join `test`.`t3` join `test`.`t4` where ((`test`.`t4`.`c3` = `test`.`t2`.`c1`) and (`test`.`t4`.`c2` = `test`.`t1`.`c1`) and (`test`.`t1`.`i1` = 1) and (`test`.`t2`.`c2` <= `test`.`t5`.`c1`) and (`test`.`t3`.`c1` <= `test`.`t4`.`c1_key`)) +SELECT STRAIGHT_JOIN * +FROM +(t1 LEFT JOIN +(t2 LEFT JOIN +(t3 LEFT OUTER JOIN t4 ON t3.c1 <= t4.c1_key) +ON t2.c1 = t4.c3) +ON t1.c1 = t4.c2) +RIGHT OUTER JOIN t5 ON t2.c2 <= t5.c1 +WHERE t1.i1 = 1; +pk i1 c1 pk c1 c2 pk c1 pk c1_key c2 c3 pk c1 +DROP TABLE ten, t1, t2, t3, t4, t5; +# +# Bug 18172819 CRASH ON DSMRR_IMPL::CHOOSE_MRR_IMPL IN SQL/HANDLER.CC +# +set @big_tables_save= @@big_tables; +set @optimizer_switch_save=@@optimizer_switch; +set big_tables=ON; +set optimizer_switch='derived_merge=off'; +SELECT @@big_tables; +@@big_tables +1 +CREATE TABLE t1 ( +i1 INTEGER NOT NULL, +c1 VARCHAR(1) +) charset utf8mb4; +INSERT INTO t1 VALUES (1,'a'), (2, NULL); +CREATE TABLE t2 ( +c1 VARCHAR(1), +i1 INTEGER NOT NULL, +KEY (c1) +) charset utf8mb4; +INSERT INTO t2 VALUES ('a', 1), (NULL, 2); +EXPLAIN SELECT * +FROM +( SELECT * FROM t1 ) AS d1 +WHERE d1.c1 IN ( SELECT c1 FROM t2 ) +AND d1.c1 IS NULL +ORDER BY d1.i1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using filesort +3 DEPENDENT SUBQUERY t2 NULL index_subquery c1 c1 7 func 1 100.00 Using index +2 DERIVED t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `d1`.`i1` AS `i1`,`d1`.`c1` AS `c1` from (/* select#2 */ select `test`.`t1`.`i1` AS `i1`,`test`.`t1`.`c1` AS `c1` from `test`.`t1` where (`test`.`t1`.`c1` is null)) `d1` where (`d1`.`c1`,(((`d1`.`c1`) in t2 on c1))) order by `d1`.`i1` +SELECT * +FROM +( SELECT * FROM t1 ) AS d1 +WHERE d1.c1 IN ( SELECT c1 FROM t2 ) +AND d1.c1 IS NULL +ORDER BY d1.i1; +i1 c1 +DROP TABLE t1, t2; +set big_tables=@big_tables_save; +set optimizer_switch=@optimizer_switch_save; +# +# Bug#41029 "MRR: SELECT FOR UPDATE fails to lock gaps (InnoDB table)" +# +SET AUTOCOMMIT=0; +CREATE TABLE t1 ( +dummy INT PRIMARY KEY, +a INT UNIQUE, +b INT +) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1,1,1),(3,3,3),(5,5,5); +COMMIT; +SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ; +SELECT @@transaction_isolation; +@@transaction_isolation +REPEATABLE-READ +START TRANSACTION; +EXPLAIN SELECT * FROM t1 WHERE a > 2 FOR UPDATE; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range a a 5 NULL 2 100.00 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`dummy` AS `dummy`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (`test`.`t1`.`a` > 2) +SELECT * FROM t1 WHERE a > 2 FOR UPDATE; +dummy a b +3 3 3 +5 5 5 +SET AUTOCOMMIT=0; +START TRANSACTION; +INSERT INTO t1 VALUES (2,2,2); +ERROR HY000: Lock wait timeout exceeded; try restarting transaction +ROLLBACK; +ROLLBACK; +DROP TABLE t1; +# +# Bug#54286 "Server crash at lock timeout with MRR" +# +SET AUTOCOMMIT=0; +CREATE TABLE t1 ( +dummy INT PRIMARY KEY, +a INT UNIQUE, +b INT +) ENGINE=InnoDB; +COMMIT; +INSERT INTO t1 VALUES (1,1,1),(3,3,3),(5,5,5); +SET AUTOCOMMIT=0; +SELECT * FROM t1 WHERE a > 2 FOR UPDATE; +ERROR HY000: Lock wait timeout exceeded; try restarting transaction +ROLLBACK; +ROLLBACK; +DROP TABLE t1; +COMMIT; +set default_storage_engine= @save_storage_engine; +set optimizer_switch=default; diff --git a/mysql-test/r/innodb_mrr_icp.result-pq b/mysql-test/r/innodb_mrr_icp.result-pq new file mode 100644 index 000000000000..7c7fe469a168 --- /dev/null +++ b/mysql-test/r/innodb_mrr_icp.result-pq @@ -0,0 +1,801 @@ +set optimizer_switch='index_condition_pushdown=on,mrr=on,mrr_cost_based=off'; +set @save_storage_engine= @@default_storage_engine; +set default_storage_engine=InnoDB; +create table t1(a int) charset utf8mb4; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t2(a int); +insert into t2 select A.a + 10*(B.a + 10*C.a) from t1 A, t1 B, t1 C; +create table t3 ( +a char(8) not null, b char(8) not null, filler char(200), +key(a) +); +insert into t3 select @a:=concat('c-', 1000+ A.a, '=w'), @a, 'filler' from t2 A; +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +insert into t3 select concat('c-', 1000+A.a, '=w'), concat('c-', 2000+A.a, '=w'), +'filler-1' from t2 A; +insert into t3 select concat('c-', 1000+A.a, '=w'), concat('c-', 3000+A.a, '=w'), +'filler-2' from t2 A; +select a,filler from t3 where a >= 'c-9011=w'; +a filler +select a,filler from t3 where a >= 'c-1011=w' and a <= 'c-1015=w'; +a filler +c-1011=w filler +c-1011=w filler-1 +c-1011=w filler-2 +c-1012=w filler +c-1012=w filler-1 +c-1012=w filler-2 +c-1013=w filler +c-1013=w filler-1 +c-1013=w filler-2 +c-1014=w filler +c-1014=w filler-1 +c-1014=w filler-2 +c-1015=w filler +c-1015=w filler-1 +c-1015=w filler-2 +select a,filler from t3 where (a>='c-1011=w' and a <= 'c-1013=w') or +(a>='c-1014=w' and a <= 'c-1015=w'); +a filler +c-1011=w filler +c-1011=w filler-1 +c-1011=w filler-2 +c-1012=w filler +c-1012=w filler-1 +c-1012=w filler-2 +c-1013=w filler +c-1013=w filler-1 +c-1013=w filler-2 +c-1014=w filler +c-1014=w filler-1 +c-1014=w filler-2 +c-1015=w filler +c-1015=w filler-1 +c-1015=w filler-2 +insert into t3 values ('c-1013=z', 'c-1013=z', 'err'); +insert into t3 values ('a-1014=w', 'a-1014=w', 'err'); +select a,filler from t3 where (a>='c-1011=w' and a <= 'c-1013=w') or +(a>='c-1014=w' and a <= 'c-1015=w'); +a filler +c-1011=w filler +c-1011=w filler-1 +c-1011=w filler-2 +c-1012=w filler +c-1012=w filler-1 +c-1012=w filler-2 +c-1013=w filler +c-1013=w filler-1 +c-1013=w filler-2 +c-1014=w filler +c-1014=w filler-1 +c-1014=w filler-2 +c-1015=w filler +c-1015=w filler-1 +c-1015=w filler-2 +delete from t3 where b in ('c-1013=z', 'a-1014=w'); +select a,filler from t3 where a='c-1011=w' or a='c-1012=w' or a='c-1013=w' or +a='c-1014=w' or a='c-1015=w'; +a filler +c-1011=w filler +c-1011=w filler-1 +c-1011=w filler-2 +c-1012=w filler +c-1012=w filler-1 +c-1012=w filler-2 +c-1013=w filler +c-1013=w filler-1 +c-1013=w filler-2 +c-1014=w filler +c-1014=w filler-1 +c-1014=w filler-2 +c-1015=w filler +c-1015=w filler-1 +c-1015=w filler-2 +insert into t3 values ('c-1013=w', 'del-me', 'inserted'); +select a,filler from t3 where a='c-1011=w' or a='c-1012=w' or a='c-1013=w' or +a='c-1014=w' or a='c-1015=w'; +a filler +c-1011=w filler +c-1011=w filler-1 +c-1011=w filler-2 +c-1012=w filler +c-1012=w filler-1 +c-1012=w filler-2 +c-1013=w filler +c-1013=w filler-1 +c-1013=w filler-2 +c-1013=w inserted +c-1014=w filler +c-1014=w filler-1 +c-1014=w filler-2 +c-1015=w filler +c-1015=w filler-1 +c-1015=w filler-2 +delete from t3 where b='del-me'; +alter table t3 add primary key(b); +select b,filler from t3 where (b>='c-1011=w' and b<= 'c-1018=w') or +b IN ('c-1019=w', 'c-1020=w', 'c-1021=w', +'c-1022=w', 'c-1023=w', 'c-1024=w'); +b filler +c-1011=w filler +c-1012=w filler +c-1013=w filler +c-1014=w filler +c-1015=w filler +c-1016=w filler +c-1017=w filler +c-1018=w filler +c-1019=w filler +c-1020=w filler +c-1021=w filler +c-1022=w filler +c-1023=w filler +c-1024=w filler +select b,filler from t3 where (b>='c-1011=w' and b<= 'c-1020=w') or +b IN ('c-1021=w', 'c-1022=w', 'c-1023=w'); +b filler +c-1011=w filler +c-1012=w filler +c-1013=w filler +c-1014=w filler +c-1015=w filler +c-1016=w filler +c-1017=w filler +c-1018=w filler +c-1019=w filler +c-1020=w filler +c-1021=w filler +c-1022=w filler +c-1023=w filler +select b,filler from t3 where (b>='c-1011=w' and b<= 'c-1018=w') or +b IN ('c-1019=w', 'c-1020=w') or +(b>='c-1021=w' and b<= 'c-1023=w'); +b filler +c-1011=w filler +c-1012=w filler +c-1013=w filler +c-1014=w filler +c-1015=w filler +c-1016=w filler +c-1017=w filler +c-1018=w filler +c-1019=w filler +c-1020=w filler +c-1021=w filler +c-1022=w filler +c-1023=w filler +create table t4 (a varchar(10), b int, c char(10), filler char(200), +key idx1 (a, b, c)) charset utf8mb4; +insert into t4 (filler) select concat('NULL-', 15-a) from t2 order by a limit 15; +insert into t4 (a,b,c,filler) +select 'b-1',NULL,'c-1', concat('NULL-', 15-a) from t2 order by a limit 15; +insert into t4 (a,b,c,filler) +select 'b-1',NULL,'c-222', concat('NULL-', 15-a) from t2 order by a limit 15; +insert into t4 (a,b,c,filler) +select 'bb-1',NULL,'cc-2', concat('NULL-', 15-a) from t2 order by a limit 15; +insert into t4 (a,b,c,filler) +select 'zz-1',NULL,'cc-2', 'filler-data' from t2 order by a limit 500; +explain +select * from t4 where a IS NULL and b IS NULL and (c IS NULL or c='no-such-row1' + or c='no-such-row2'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 16 100.00 Parallel execute (2 workers) +2 SIMPLE t4 NULL range idx1 idx1 89 NULL 16 100.00 Using index condition; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t4`.`c` AS `c`,`test`.`t4`.`filler` AS `filler` from `test`.`t4` where ((`test`.`t4`.`a` is null) and (`test`.`t4`.`b` is null) and ((`test`.`t4`.`c` is null) or (`test`.`t4`.`c` = 'no-such-row1') or (`test`.`t4`.`c` = 'no-such-row2'))) +select * from t4 where a IS NULL and b IS NULL and (c IS NULL or c='no-such-row1' + or c='no-such-row2'); +a b c filler +NULL NULL NULL NULL-15 +NULL NULL NULL NULL-14 +NULL NULL NULL NULL-13 +NULL NULL NULL NULL-12 +NULL NULL NULL NULL-11 +NULL NULL NULL NULL-10 +NULL NULL NULL NULL-9 +NULL NULL NULL NULL-8 +NULL NULL NULL NULL-7 +NULL NULL NULL NULL-6 +NULL NULL NULL NULL-5 +NULL NULL NULL NULL-4 +NULL NULL NULL NULL-3 +NULL NULL NULL NULL-2 +NULL NULL NULL NULL-1 +explain +select * from t4 where (a ='b-1' or a='bb-1') and b IS NULL and (c='c-1' or c='cc-2'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 32 100.00 Parallel execute (4 workers) +2 SIMPLE t4 NULL range idx1 idx1 89 NULL 32 100.00 Using index condition; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t4`.`c` AS `c`,`test`.`t4`.`filler` AS `filler` from `test`.`t4` where (((`test`.`t4`.`a` = 'b-1') or (`test`.`t4`.`a` = 'bb-1')) and (`test`.`t4`.`b` is null) and ((`test`.`t4`.`c` = 'c-1') or (`test`.`t4`.`c` = 'cc-2'))) +select * from t4 where (a ='b-1' or a='bb-1') and b IS NULL and (c='c-1' or c='cc-2'); +a b c filler +b-1 NULL c-1 NULL-15 +b-1 NULL c-1 NULL-14 +b-1 NULL c-1 NULL-13 +b-1 NULL c-1 NULL-12 +b-1 NULL c-1 NULL-11 +b-1 NULL c-1 NULL-10 +b-1 NULL c-1 NULL-9 +b-1 NULL c-1 NULL-8 +b-1 NULL c-1 NULL-7 +b-1 NULL c-1 NULL-6 +b-1 NULL c-1 NULL-5 +b-1 NULL c-1 NULL-4 +b-1 NULL c-1 NULL-3 +b-1 NULL c-1 NULL-2 +b-1 NULL c-1 NULL-1 +bb-1 NULL cc-2 NULL-15 +bb-1 NULL cc-2 NULL-14 +bb-1 NULL cc-2 NULL-13 +bb-1 NULL cc-2 NULL-12 +bb-1 NULL cc-2 NULL-11 +bb-1 NULL cc-2 NULL-10 +bb-1 NULL cc-2 NULL-9 +bb-1 NULL cc-2 NULL-8 +bb-1 NULL cc-2 NULL-7 +bb-1 NULL cc-2 NULL-6 +bb-1 NULL cc-2 NULL-5 +bb-1 NULL cc-2 NULL-4 +bb-1 NULL cc-2 NULL-3 +bb-1 NULL cc-2 NULL-2 +bb-1 NULL cc-2 NULL-1 +select * from t4 ignore index(idx1) where (a ='b-1' or a='bb-1') and b IS NULL and (c='c-1' or c='cc-2'); +a b c filler +b-1 NULL c-1 NULL-15 +b-1 NULL c-1 NULL-14 +b-1 NULL c-1 NULL-13 +b-1 NULL c-1 NULL-12 +b-1 NULL c-1 NULL-11 +b-1 NULL c-1 NULL-10 +b-1 NULL c-1 NULL-9 +b-1 NULL c-1 NULL-8 +b-1 NULL c-1 NULL-7 +b-1 NULL c-1 NULL-6 +b-1 NULL c-1 NULL-5 +b-1 NULL c-1 NULL-4 +b-1 NULL c-1 NULL-3 +b-1 NULL c-1 NULL-2 +b-1 NULL c-1 NULL-1 +bb-1 NULL cc-2 NULL-15 +bb-1 NULL cc-2 NULL-14 +bb-1 NULL cc-2 NULL-13 +bb-1 NULL cc-2 NULL-12 +bb-1 NULL cc-2 NULL-11 +bb-1 NULL cc-2 NULL-10 +bb-1 NULL cc-2 NULL-9 +bb-1 NULL cc-2 NULL-8 +bb-1 NULL cc-2 NULL-7 +bb-1 NULL cc-2 NULL-6 +bb-1 NULL cc-2 NULL-5 +bb-1 NULL cc-2 NULL-4 +bb-1 NULL cc-2 NULL-3 +bb-1 NULL cc-2 NULL-2 +bb-1 NULL cc-2 NULL-1 +drop table t1, t2, t3, t4; +create table t1 (a int, b int not null,unique key (a,b),index(b)); +insert ignore into t1 values (1,1),(2,2),(3,3),(4,4),(5,5),(6,6),(null,7),(9,9),(8,8),(7,7),(null,9),(null,9),(6,6); +Warnings: +Warning 1062 Duplicate entry '6-6' for key 't1.a' +create table t2 like t1; +insert into t2 select * from t1; +alter table t1 modify b blob not null, add c int not null, drop key a, add unique key (a,b(20),c), drop key b, add key (b(10)); +select * from t1 where a is null; +a b c +NULL 7 0 +NULL 9 0 +NULL 9 0 +select * from t1 where (a is null or a > 0 and a < 3) and b > 7 limit 3; +a b c +NULL 9 0 +NULL 9 0 +select * from t1 where a is null and b=9 or a is null and b=7 limit 3; +a b c +NULL 7 0 +NULL 9 0 +NULL 9 0 +drop table t1, t2; +CREATE TABLE t1 ( +ID int(10) unsigned NOT NULL AUTO_INCREMENT, +col1 int(10) unsigned DEFAULT NULL, +key1 int(10) unsigned NOT NULL DEFAULT '0', +key2 int(10) unsigned DEFAULT NULL, +text1 text, +text2 text, +col2 smallint(6) DEFAULT '100', +col3 enum('headers','bodyandsubject') NOT NULL DEFAULT 'bodyandsubject', +col4 tinyint(3) unsigned NOT NULL DEFAULT '0', +PRIMARY KEY (ID), +KEY (key1), +KEY (key2) +) AUTO_INCREMENT=6 DEFAULT CHARSET=utf8; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES +(1,NULL,1130,NULL,'Hello',NULL,100,'bodyandsubject',0), +(2,NULL,1130,NULL,'bye',NULL,100,'bodyandsubject',0), +(3,NULL,1130,NULL,'red',NULL,100,'bodyandsubject',0), +(4,NULL,1130,NULL,'yellow',NULL,100,'bodyandsubject',0), +(5,NULL,1130,NULL,'blue',NULL,100,'bodyandsubject',0); +select * FROM t1 WHERE key1=1130 AND col1 IS NULL ORDER BY text1; +ID col1 key1 key2 text1 text2 col2 col3 col4 +5 NULL 1130 NULL blue NULL 100 bodyandsubject 0 +2 NULL 1130 NULL bye NULL 100 bodyandsubject 0 +1 NULL 1130 NULL Hello NULL 100 bodyandsubject 0 +3 NULL 1130 NULL red NULL 100 bodyandsubject 0 +4 NULL 1130 NULL yellow NULL 100 bodyandsubject 0 +drop table t1; + +BUG#37851: Crash in test_if_skip_sort_order tab->select is zero + +CREATE TABLE t1 ( +pk int(11) NOT NULL AUTO_INCREMENT, +PRIMARY KEY (pk) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (1); +CREATE TABLE t2 ( +pk int(11) NOT NULL AUTO_INCREMENT, +int_key int(11) DEFAULT NULL, +PRIMARY KEY (pk), +KEY int_key (int_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (1,1),(2,6),(3,0); +EXPLAIN +SELECT MIN(t1.pk) +FROM t1 WHERE EXISTS ( +SELECT t2.pk +FROM t2 +WHERE t2.int_key IS NULL +GROUP BY t2.pk +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +2 SUBQUERY t2 NULL ref int_key int_key 5 const 1 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select min(`test`.`t1`.`pk`) AS `MIN(t1.pk)` from `test`.`t1` where false +DROP TABLE t1, t2; +# +# BUG#42048 Discrepancy between MyISAM and Maria's ICP implementation +# +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (a int, b char(20), filler char(200), key(a,b(10))); +insert into t1 select A.a + 10*(B.a + 10*C.a), 'bbb','filler' from t0 A, t0 B, t0 C; +update t1 set b=repeat(char(65+a), 20) where a < 25; +This must show range + using index condition: +explain select * from t1 where a < 10 and b = repeat(char(65+a), 20); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL x x Parallel execute (1 workers) +2 SIMPLE t1 NULL range a a 5 NULL x x Using index condition; Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`filler` AS `filler` from `test`.`t1` where ((`test`.`t1`.`a` < 10) and (`test`.`t1`.`b` = repeat(char((65 + `test`.`t1`.`a`)),20))) +select * from t1 where a < 10 and b = repeat(char(65+a), 20); +a b filler +0 AAAAAAAAAAAAAAAAAAAA filler +1 BBBBBBBBBBBBBBBBBBBB filler +2 CCCCCCCCCCCCCCCCCCCC filler +3 DDDDDDDDDDDDDDDDDDDD filler +4 EEEEEEEEEEEEEEEEEEEE filler +5 FFFFFFFFFFFFFFFFFFFF filler +6 GGGGGGGGGGGGGGGGGGGG filler +7 HHHHHHHHHHHHHHHHHHHH filler +8 IIIIIIIIIIIIIIIIIIII filler +9 JJJJJJJJJJJJJJJJJJJJ filler +drop table t0,t1; +# +# BUG#41136: ORDER BY + range access: EXPLAIN shows "Using MRR" while MRR is actually not used +# +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (a int, b int, key(a)); +insert into t1 select A.a + 10 *(B.a + 10*C.a), A.a + 10 *(B.a + 10*C.a) from t0 A, t0 B, t0 C; +This mustn't show "Using MRR": +explain select * from t1 where a < 20 order by a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 20 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range a a 5 NULL 20 100.00 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (`test`.`t1`.`a` < 20) order by `test`.`t1`.`a` +drop table t0, t1; +set @read_rnd_buffer_size_save= @@read_rnd_buffer_size; +set read_rnd_buffer_size=64; +create table t1(a int); +insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t2(a char(8), b char(8), c char(8), filler char(100), key k1(a,b,c) ) charset utf8mb4; +insert into t2 select +concat('a-', 1000 + A.a, '-a'), +concat('b-', 1000 + B.a, '-b'), +concat('c-', 1000 + C.a, '-c'), +'filler' +from t1 A, t1 B, t1 C; +EXPLAIN select count(length(a) + length(filler)) +from t2 force index (k1) +where a>='a-1000-a' and a <'a-1001-a'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 100 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL range k1 k1 33 NULL 100 100.00 Using index condition; Using MRR +Warnings: +Note 1003 /* select#1 */ select count((length(`test`.`t2`.`a`) + length(`test`.`t2`.`filler`))) AS `count(length(a) + length(filler))` from `test`.`t2` FORCE INDEX (`k1`) where ((`test`.`t2`.`a` >= 'a-1000-a') and (`test`.`t2`.`a` < 'a-1001-a')) +select count(length(a) + length(filler)) +from t2 force index (k1) +where a>='a-1000-a' and a <'a-1001-a'; +count(length(a) + length(filler)) +100 +drop table t2; +create table t2 (a char(100), b char(100), c char(100), d int, +filler char(10), key(d), primary key (a,b,c)) charset latin1; +insert into t2 select A.a, B.a, B.a, A.a, 'filler' from t1 A, t1 B; +explain select * from t2 force index (d) where d < 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (2 workers) +2 SIMPLE t2 NULL range d d 5 NULL # 100.00 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c`,`test`.`t2`.`d` AS `d`,`test`.`t2`.`filler` AS `filler` from `test`.`t2` FORCE INDEX (`d`) where (`test`.`t2`.`d` < 10) +drop table t2; +drop table t1; +set @@read_rnd_buffer_size= @read_rnd_buffer_size_save; +create table t1 (f1 int not null, f2 int not null,f3 int not null, f4 char(1), primary key (f1,f2), key ix(f3)); +select * from t1 where (f3>=5 and f3<=10) or (f3>=1 and f3<=4); +f1 f2 f3 f4 +1 1 1 A +10 10 10 A +2 2 2 A +3 3 3 A +4 4 4 A +5 5 5 A +6 6 6 A +7 7 7 A +8 8 8 A +9 9 9 A +drop table t1; + +BUG#37977: Wrong result returned on GROUP BY + OR + Innodb + +CREATE TABLE t1 ( +`pk` int(11) NOT NULL AUTO_INCREMENT, +`int_nokey` int(11) NOT NULL, +`int_key` int(11) NOT NULL, +`date_key` date NOT NULL, +`date_nokey` date NOT NULL, +`time_key` time NOT NULL, +`time_nokey` time NOT NULL, +`datetime_key` datetime NOT NULL, +`datetime_nokey` datetime NOT NULL, +`varchar_key` varchar(5) DEFAULT NULL, +`varchar_nokey` varchar(5) DEFAULT NULL, +PRIMARY KEY (`pk`), +KEY `int_key` (`int_key`), +KEY `date_key` (`date_key`), +KEY `time_key` (`time_key`), +KEY `datetime_key` (`datetime_key`), +KEY `varchar_key` (`varchar_key`) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT IGNORE INTO t1 VALUES +(1,5,5,'2009-10-16','2009-10-16','09:28:15','09:28:15','2007-09-14 05:34:08','2007-09-14 05:34:08','qk','qk'), +(2,6,6,'0000-00-00','0000-00-00','23:06:39','23:06:39','0000-00-00 00:00:00','0000-00-00 00:00:00','j','j'), +(3,10,10,'2000-12-18','2000-12-18','22:16:19','22:16:19','2006-11-04 15:42:50','2006-11-04 15:42:50','aew','aew'), +(4,0,0,'2001-09-18','2001-09-18','00:00:00','00:00:00','2004-03-23 13:23:35','2004-03-23 13:23:35',NULL,NULL), +(5,6,6,'2007-08-16','2007-08-16','22:13:38','22:13:38','2004-08-19 11:01:28','2004-08-19 11:01:28','qu','qu'); +Warnings: +Warning 1264 Out of range value for column 'date_key' at row 2 +Warning 1264 Out of range value for column 'date_nokey' at row 2 +Warning 1264 Out of range value for column 'datetime_key' at row 2 +Warning 1264 Out of range value for column 'datetime_nokey' at row 2 +select pk from t1 WHERE `varchar_key` > 'kr' group by pk; +pk +1 +5 +select pk from t1 WHERE `int_nokey` IS NULL OR `varchar_key` > 'kr' group by pk; +pk +1 +5 +drop table t1; +# +# BUG#39447: Error with NOT NULL condition and LIMIT 1 +# +CREATE TABLE t1 ( +id int(11) NOT NULL, +parent_id int(11) DEFAULT NULL, +name varchar(10) DEFAULT NULL, +PRIMARY KEY (id), +KEY ind_parent_id (parent_id) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t1 (id, parent_id, name) values +(10,NULL,'A'), +(20,10,'B'), +(30,10,'C'), +(40,NULL,'D'), +(50,40,'E'), +(60,40,'F'), +(70,NULL,'J'); +SELECT id FROM t1 WHERE parent_id IS NOT NULL ORDER BY id DESC LIMIT 1; +id +60 +This must show type=index, extra=Using where +explain SELECT * FROM t1 WHERE parent_id IS NOT NULL ORDER BY id DESC LIMIT 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 57.14 Backward index scan; Parallel execute (1 workers) +2 SIMPLE t1 NULL index ind_parent_id PRIMARY 4 NULL 1 57.14 Using where; Backward index scan +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,`test`.`t1`.`parent_id` AS `parent_id`,`test`.`t1`.`name` AS `name` from `test`.`t1` where (`test`.`t1`.`parent_id` is not null) order by `test`.`t1`.`id` desc limit 1 +SELECT * FROM t1 WHERE parent_id IS NOT NULL ORDER BY id DESC LIMIT 1; +id parent_id name +60 40 F +drop table t1; +# +# Bug#50381 "Assertion failing in handler.h:1283: +# void COST_VECT::add_io(double, double)" +# +CREATE TABLE t1 ( +c1 INT NOT NULL, +c2 VARCHAR(1) DEFAULT NULL, +PRIMARY KEY (c1) +); +CREATE TABLE t2 ( +c1 INT NOT NULL, +c2 VARCHAR(1) DEFAULT NULL, +PRIMARY KEY (c1) +); +INSERT INTO t2 VALUES (10,'v'); +INSERT INTO t2 VALUES (11,'r'); +SELECT t1.c2 +FROM t2 STRAIGHT_JOIN t1 ON t1.c1 < t2.c1; +c2 +DROP TABLE t1, t2; +# +# Bug#12321461: CRASH IN DSMRR_IMPL::DSMRR_INIT ON SELECT STRAIGHT_JOIN +# +set @save_optimizer_switch = @@optimizer_switch; +set optimizer_switch='block_nested_loop=off,batched_key_access=off'; +CREATE TABLE t1 ( +pk INTEGER, +c1 VARCHAR(1) NOT NULL, +PRIMARY KEY (pk) +); +CREATE TABLE t2 ( +c1 VARCHAR(1) NOT NULL +); +INSERT INTO t2 VALUES ('v'), ('c'); +EXPLAIN SELECT STRAIGHT_JOIN t1.c1 +FROM t1 RIGHT OUTER JOIN t2 ON t1.c1 = t2.c1 +WHERE t1.pk > 176; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 SIMPLE t1 NULL range PRIMARY PRIMARY 4 NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select straight_join `test`.`t1`.`c1` AS `c1` from `test`.`t2` join `test`.`t1` where ((`test`.`t1`.`c1` = `test`.`t2`.`c1`) and (`test`.`t1`.`pk` > 176)) +SELECT STRAIGHT_JOIN t1.c1 +FROM t1 RIGHT OUTER JOIN t2 ON t1.c1 = t2.c1 +WHERE t1.pk > 176; +c1 +DROP TABLE t1,t2; +set optimizer_switch= @save_optimizer_switch; +# +# Bug#13249966 MRR: RANDOM ERROR DUE TO UNINITIALIZED RES WITH +# SMALL READ_RND_BUFFER_SIZE +# +set @read_rnd_buffer_size_save= @@read_rnd_buffer_size; +set read_rnd_buffer_size=1; +select @@read_rnd_buffer_size; +@@read_rnd_buffer_size +1 +CREATE TABLE t1 ( +i1 INTEGER NOT NULL, +i2 INTEGER NOT NULL, +KEY (i2) +); +INSERT INTO t1 VALUES (0,1),(1,2),(2,3); +EXPLAIN SELECT i1 +FROM t1 +WHERE i2 > 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range i2 i2 4 NULL 1 100.00 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i1` AS `i1` from `test`.`t1` where (`test`.`t1`.`i2` > 2) +SELECT i1 +FROM t1 +WHERE i2 > 2; +i1 +2 +DROP TABLE t1; +set @@read_rnd_buffer_size= @read_rnd_buffer_size_save; +select @@read_rnd_buffer_size; +@@read_rnd_buffer_size +262144 +# +# Bug 12365385 STRAIGHT_JOIN QUERY QUICKLY EXHAUSTS SYSTEM+VIRT. +# MEMORY LEADING TO SYSTEM CRASH +# +CREATE TABLE ten (a INTEGER); +INSERT INTO ten VALUES (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +CREATE TABLE t1 ( +pk INTEGER NOT NULL, +i1 INTEGER NOT NULL, +c1 VARCHAR(10) NOT NULL, +PRIMARY KEY (pk) +) charset latin1; +INSERT INTO t1 +SELECT a, 1, 'MySQL' FROM ten; +CREATE TABLE t2 ( +pk INTEGER NOT NULL, +c1 VARCHAR(10) NOT NULL, +c2 varchar(10) NOT NULL, +PRIMARY KEY (pk) +) charset latin1; +INSERT INTO t2 +SELECT a, 'MySQL', 'MySQL' FROM ten; +CREATE TABLE t3 ( +pk INTEGER NOT NULL, +c1 VARCHAR(10) NOT NULL, +PRIMARY KEY (pk) +) charset latin1; +INSERT INTO t3 +SELECT a, 'MySQL' FROM ten; +CREATE TABLE t4 ( +pk int(11) NOT NULL, +c1_key varchar(10) CHARACTER SET utf8 NOT NULL, +c2 varchar(10) NOT NULL, +c3 varchar(10) NOT NULL, +PRIMARY KEY (pk), +KEY k1 (c1_key) +) charset latin1; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +CREATE TABLE t5 ( +pk INTEGER NOT NULL, +c1 VARCHAR(10) NOT NULL, +PRIMARY KEY (pk) +) charset latin1; +INSERT INTO t5 +SELECT a, 'MySQL' FROM ten; +EXPLAIN SELECT STRAIGHT_JOIN * +FROM +(t1 LEFT JOIN +(t2 LEFT JOIN +(t3 LEFT OUTER JOIN t4 ON t3.c1 <= t4.c1_key) +ON t2.c1 = t4.c3) +ON t1.c1 = t4.c2) +RIGHT OUTER JOIN t5 ON t2.c2 <= t5.c1 +WHERE t1.i1 = 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 100.00 Parallel execute (1 workers) +2 SIMPLE t5 NULL ALL NULL NULL NULL NULL 10 100.00 NULL +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 10.00 Using where; Using join buffer (hash join) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 10 33.33 Using where; Using join buffer (hash join) +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 10 100.00 Using join buffer (hash join) +2 SIMPLE t4 NULL ALL k1 NULL NULL NULL 1 100.00 Range checked for each record (index map: 0x2) +Warnings: +Note 1003 /* select#1 */ select straight_join `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`i1` AS `i1`,`test`.`t1`.`c1` AS `c1`,`test`.`t2`.`pk` AS `pk`,`test`.`t2`.`c1` AS `c1`,`test`.`t2`.`c2` AS `c2`,`test`.`t3`.`pk` AS `pk`,`test`.`t3`.`c1` AS `c1`,`test`.`t4`.`pk` AS `pk`,`test`.`t4`.`c1_key` AS `c1_key`,`test`.`t4`.`c2` AS `c2`,`test`.`t4`.`c3` AS `c3`,`test`.`t5`.`pk` AS `pk`,`test`.`t5`.`c1` AS `c1` from `test`.`t5` join `test`.`t1` join `test`.`t2` join `test`.`t3` join `test`.`t4` where ((`test`.`t4`.`c3` = `test`.`t2`.`c1`) and (`test`.`t4`.`c2` = `test`.`t1`.`c1`) and (`test`.`t1`.`i1` = 1) and (`test`.`t2`.`c2` <= `test`.`t5`.`c1`) and (`test`.`t3`.`c1` <= `test`.`t4`.`c1_key`)) +SELECT STRAIGHT_JOIN * +FROM +(t1 LEFT JOIN +(t2 LEFT JOIN +(t3 LEFT OUTER JOIN t4 ON t3.c1 <= t4.c1_key) +ON t2.c1 = t4.c3) +ON t1.c1 = t4.c2) +RIGHT OUTER JOIN t5 ON t2.c2 <= t5.c1 +WHERE t1.i1 = 1; +pk i1 c1 pk c1 c2 pk c1 pk c1_key c2 c3 pk c1 +DROP TABLE ten, t1, t2, t3, t4, t5; +# +# Bug 18172819 CRASH ON DSMRR_IMPL::CHOOSE_MRR_IMPL IN SQL/HANDLER.CC +# +set @big_tables_save= @@big_tables; +set @optimizer_switch_save=@@optimizer_switch; +set big_tables=ON; +set optimizer_switch='derived_merge=off'; +SELECT @@big_tables; +@@big_tables +1 +CREATE TABLE t1 ( +i1 INTEGER NOT NULL, +c1 VARCHAR(1) +) charset utf8mb4; +INSERT INTO t1 VALUES (1,'a'), (2, NULL); +CREATE TABLE t2 ( +c1 VARCHAR(1), +i1 INTEGER NOT NULL, +KEY (c1) +) charset utf8mb4; +INSERT INTO t2 VALUES ('a', 1), (NULL, 2); +EXPLAIN SELECT * +FROM +( SELECT * FROM t1 ) AS d1 +WHERE d1.c1 IN ( SELECT c1 FROM t2 ) +AND d1.c1 IS NULL +ORDER BY d1.i1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using filesort +3 DEPENDENT SUBQUERY t2 NULL index_subquery c1 c1 7 func 1 100.00 Using index +2 DERIVED t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `d1`.`i1` AS `i1`,`d1`.`c1` AS `c1` from (/* select#2 */ select `test`.`t1`.`i1` AS `i1`,`test`.`t1`.`c1` AS `c1` from `test`.`t1` where (`test`.`t1`.`c1` is null)) `d1` where (`d1`.`c1`,(((`d1`.`c1`) in t2 on c1))) order by `d1`.`i1` +SELECT * +FROM +( SELECT * FROM t1 ) AS d1 +WHERE d1.c1 IN ( SELECT c1 FROM t2 ) +AND d1.c1 IS NULL +ORDER BY d1.i1; +i1 c1 +DROP TABLE t1, t2; +set big_tables=@big_tables_save; +set optimizer_switch=@optimizer_switch_save; +# +# Bug#41029 "MRR: SELECT FOR UPDATE fails to lock gaps (InnoDB table)" +# +SET AUTOCOMMIT=0; +CREATE TABLE t1 ( +dummy INT PRIMARY KEY, +a INT UNIQUE, +b INT +) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1,1,1),(3,3,3),(5,5,5); +COMMIT; +SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ; +SELECT @@transaction_isolation; +@@transaction_isolation +REPEATABLE-READ +START TRANSACTION; +EXPLAIN SELECT * FROM t1 WHERE a > 2 FOR UPDATE; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range a a 5 NULL 2 100.00 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`dummy` AS `dummy`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (`test`.`t1`.`a` > 2) +SELECT * FROM t1 WHERE a > 2 FOR UPDATE; +dummy a b +3 3 3 +5 5 5 +SET AUTOCOMMIT=0; +START TRANSACTION; +INSERT INTO t1 VALUES (2,2,2); +ERROR HY000: Lock wait timeout exceeded; try restarting transaction +ROLLBACK; +ROLLBACK; +DROP TABLE t1; +# +# Bug#54286 "Server crash at lock timeout with MRR" +# +SET AUTOCOMMIT=0; +CREATE TABLE t1 ( +dummy INT PRIMARY KEY, +a INT UNIQUE, +b INT +) ENGINE=InnoDB; +COMMIT; +INSERT INTO t1 VALUES (1,1,1),(3,3,3),(5,5,5); +SET AUTOCOMMIT=0; +SELECT * FROM t1 WHERE a > 2 FOR UPDATE; +ERROR HY000: Lock wait timeout exceeded; try restarting transaction +ROLLBACK; +ROLLBACK; +DROP TABLE t1; +COMMIT; +set default_storage_engine= @save_storage_engine; +set optimizer_switch=default; diff --git a/mysql-test/r/innodb_mrr_none.result-pq b/mysql-test/r/innodb_mrr_none.result-pq new file mode 100644 index 000000000000..960dd112094c --- /dev/null +++ b/mysql-test/r/innodb_mrr_none.result-pq @@ -0,0 +1,800 @@ +set @save_storage_engine= @@default_storage_engine; +set default_storage_engine=InnoDB; +create table t1(a int) charset utf8mb4; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t2(a int); +insert into t2 select A.a + 10*(B.a + 10*C.a) from t1 A, t1 B, t1 C; +create table t3 ( +a char(8) not null, b char(8) not null, filler char(200), +key(a) +); +insert into t3 select @a:=concat('c-', 1000+ A.a, '=w'), @a, 'filler' from t2 A; +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +insert into t3 select concat('c-', 1000+A.a, '=w'), concat('c-', 2000+A.a, '=w'), +'filler-1' from t2 A; +insert into t3 select concat('c-', 1000+A.a, '=w'), concat('c-', 3000+A.a, '=w'), +'filler-2' from t2 A; +select a,filler from t3 where a >= 'c-9011=w'; +a filler +select a,filler from t3 where a >= 'c-1011=w' and a <= 'c-1015=w'; +a filler +c-1011=w filler +c-1011=w filler-1 +c-1011=w filler-2 +c-1012=w filler +c-1012=w filler-1 +c-1012=w filler-2 +c-1013=w filler +c-1013=w filler-1 +c-1013=w filler-2 +c-1014=w filler +c-1014=w filler-1 +c-1014=w filler-2 +c-1015=w filler +c-1015=w filler-1 +c-1015=w filler-2 +select a,filler from t3 where (a>='c-1011=w' and a <= 'c-1013=w') or +(a>='c-1014=w' and a <= 'c-1015=w'); +a filler +c-1011=w filler +c-1011=w filler-1 +c-1011=w filler-2 +c-1012=w filler +c-1012=w filler-1 +c-1012=w filler-2 +c-1013=w filler +c-1013=w filler-1 +c-1013=w filler-2 +c-1014=w filler +c-1014=w filler-1 +c-1014=w filler-2 +c-1015=w filler +c-1015=w filler-1 +c-1015=w filler-2 +insert into t3 values ('c-1013=z', 'c-1013=z', 'err'); +insert into t3 values ('a-1014=w', 'a-1014=w', 'err'); +select a,filler from t3 where (a>='c-1011=w' and a <= 'c-1013=w') or +(a>='c-1014=w' and a <= 'c-1015=w'); +a filler +c-1011=w filler +c-1011=w filler-1 +c-1011=w filler-2 +c-1012=w filler +c-1012=w filler-1 +c-1012=w filler-2 +c-1013=w filler +c-1013=w filler-1 +c-1013=w filler-2 +c-1014=w filler +c-1014=w filler-1 +c-1014=w filler-2 +c-1015=w filler +c-1015=w filler-1 +c-1015=w filler-2 +delete from t3 where b in ('c-1013=z', 'a-1014=w'); +select a,filler from t3 where a='c-1011=w' or a='c-1012=w' or a='c-1013=w' or +a='c-1014=w' or a='c-1015=w'; +a filler +c-1011=w filler +c-1011=w filler-1 +c-1011=w filler-2 +c-1012=w filler +c-1012=w filler-1 +c-1012=w filler-2 +c-1013=w filler +c-1013=w filler-1 +c-1013=w filler-2 +c-1014=w filler +c-1014=w filler-1 +c-1014=w filler-2 +c-1015=w filler +c-1015=w filler-1 +c-1015=w filler-2 +insert into t3 values ('c-1013=w', 'del-me', 'inserted'); +select a,filler from t3 where a='c-1011=w' or a='c-1012=w' or a='c-1013=w' or +a='c-1014=w' or a='c-1015=w'; +a filler +c-1011=w filler +c-1011=w filler-1 +c-1011=w filler-2 +c-1012=w filler +c-1012=w filler-1 +c-1012=w filler-2 +c-1013=w filler +c-1013=w filler-1 +c-1013=w filler-2 +c-1013=w inserted +c-1014=w filler +c-1014=w filler-1 +c-1014=w filler-2 +c-1015=w filler +c-1015=w filler-1 +c-1015=w filler-2 +delete from t3 where b='del-me'; +alter table t3 add primary key(b); +select b,filler from t3 where (b>='c-1011=w' and b<= 'c-1018=w') or +b IN ('c-1019=w', 'c-1020=w', 'c-1021=w', +'c-1022=w', 'c-1023=w', 'c-1024=w'); +b filler +c-1011=w filler +c-1012=w filler +c-1013=w filler +c-1014=w filler +c-1015=w filler +c-1016=w filler +c-1017=w filler +c-1018=w filler +c-1019=w filler +c-1020=w filler +c-1021=w filler +c-1022=w filler +c-1023=w filler +c-1024=w filler +select b,filler from t3 where (b>='c-1011=w' and b<= 'c-1020=w') or +b IN ('c-1021=w', 'c-1022=w', 'c-1023=w'); +b filler +c-1011=w filler +c-1012=w filler +c-1013=w filler +c-1014=w filler +c-1015=w filler +c-1016=w filler +c-1017=w filler +c-1018=w filler +c-1019=w filler +c-1020=w filler +c-1021=w filler +c-1022=w filler +c-1023=w filler +select b,filler from t3 where (b>='c-1011=w' and b<= 'c-1018=w') or +b IN ('c-1019=w', 'c-1020=w') or +(b>='c-1021=w' and b<= 'c-1023=w'); +b filler +c-1011=w filler +c-1012=w filler +c-1013=w filler +c-1014=w filler +c-1015=w filler +c-1016=w filler +c-1017=w filler +c-1018=w filler +c-1019=w filler +c-1020=w filler +c-1021=w filler +c-1022=w filler +c-1023=w filler +create table t4 (a varchar(10), b int, c char(10), filler char(200), +key idx1 (a, b, c)) charset utf8mb4; +insert into t4 (filler) select concat('NULL-', 15-a) from t2 order by a limit 15; +insert into t4 (a,b,c,filler) +select 'b-1',NULL,'c-1', concat('NULL-', 15-a) from t2 order by a limit 15; +insert into t4 (a,b,c,filler) +select 'b-1',NULL,'c-222', concat('NULL-', 15-a) from t2 order by a limit 15; +insert into t4 (a,b,c,filler) +select 'bb-1',NULL,'cc-2', concat('NULL-', 15-a) from t2 order by a limit 15; +insert into t4 (a,b,c,filler) +select 'zz-1',NULL,'cc-2', 'filler-data' from t2 order by a limit 500; +explain +select * from t4 where a IS NULL and b IS NULL and (c IS NULL or c='no-such-row1' + or c='no-such-row2'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 16 100.00 Parallel execute (2 workers) +2 SIMPLE t4 NULL range idx1 idx1 89 NULL 16 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t4`.`c` AS `c`,`test`.`t4`.`filler` AS `filler` from `test`.`t4` where ((`test`.`t4`.`a` is null) and (`test`.`t4`.`b` is null) and ((`test`.`t4`.`c` is null) or (`test`.`t4`.`c` = 'no-such-row1') or (`test`.`t4`.`c` = 'no-such-row2'))) +select * from t4 where a IS NULL and b IS NULL and (c IS NULL or c='no-such-row1' + or c='no-such-row2'); +a b c filler +NULL NULL NULL NULL-15 +NULL NULL NULL NULL-14 +NULL NULL NULL NULL-13 +NULL NULL NULL NULL-12 +NULL NULL NULL NULL-11 +NULL NULL NULL NULL-10 +NULL NULL NULL NULL-9 +NULL NULL NULL NULL-8 +NULL NULL NULL NULL-7 +NULL NULL NULL NULL-6 +NULL NULL NULL NULL-5 +NULL NULL NULL NULL-4 +NULL NULL NULL NULL-3 +NULL NULL NULL NULL-2 +NULL NULL NULL NULL-1 +explain +select * from t4 where (a ='b-1' or a='bb-1') and b IS NULL and (c='c-1' or c='cc-2'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 32 100.00 Parallel execute (4 workers) +2 SIMPLE t4 NULL range idx1 idx1 89 NULL 32 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t4`.`c` AS `c`,`test`.`t4`.`filler` AS `filler` from `test`.`t4` where (((`test`.`t4`.`a` = 'b-1') or (`test`.`t4`.`a` = 'bb-1')) and (`test`.`t4`.`b` is null) and ((`test`.`t4`.`c` = 'c-1') or (`test`.`t4`.`c` = 'cc-2'))) +select * from t4 where (a ='b-1' or a='bb-1') and b IS NULL and (c='c-1' or c='cc-2'); +a b c filler +b-1 NULL c-1 NULL-15 +b-1 NULL c-1 NULL-14 +b-1 NULL c-1 NULL-13 +b-1 NULL c-1 NULL-12 +b-1 NULL c-1 NULL-11 +b-1 NULL c-1 NULL-10 +b-1 NULL c-1 NULL-9 +b-1 NULL c-1 NULL-8 +b-1 NULL c-1 NULL-7 +b-1 NULL c-1 NULL-6 +b-1 NULL c-1 NULL-5 +b-1 NULL c-1 NULL-4 +b-1 NULL c-1 NULL-3 +b-1 NULL c-1 NULL-2 +b-1 NULL c-1 NULL-1 +bb-1 NULL cc-2 NULL-15 +bb-1 NULL cc-2 NULL-14 +bb-1 NULL cc-2 NULL-13 +bb-1 NULL cc-2 NULL-12 +bb-1 NULL cc-2 NULL-11 +bb-1 NULL cc-2 NULL-10 +bb-1 NULL cc-2 NULL-9 +bb-1 NULL cc-2 NULL-8 +bb-1 NULL cc-2 NULL-7 +bb-1 NULL cc-2 NULL-6 +bb-1 NULL cc-2 NULL-5 +bb-1 NULL cc-2 NULL-4 +bb-1 NULL cc-2 NULL-3 +bb-1 NULL cc-2 NULL-2 +bb-1 NULL cc-2 NULL-1 +select * from t4 ignore index(idx1) where (a ='b-1' or a='bb-1') and b IS NULL and (c='c-1' or c='cc-2'); +a b c filler +b-1 NULL c-1 NULL-15 +b-1 NULL c-1 NULL-14 +b-1 NULL c-1 NULL-13 +b-1 NULL c-1 NULL-12 +b-1 NULL c-1 NULL-11 +b-1 NULL c-1 NULL-10 +b-1 NULL c-1 NULL-9 +b-1 NULL c-1 NULL-8 +b-1 NULL c-1 NULL-7 +b-1 NULL c-1 NULL-6 +b-1 NULL c-1 NULL-5 +b-1 NULL c-1 NULL-4 +b-1 NULL c-1 NULL-3 +b-1 NULL c-1 NULL-2 +b-1 NULL c-1 NULL-1 +bb-1 NULL cc-2 NULL-15 +bb-1 NULL cc-2 NULL-14 +bb-1 NULL cc-2 NULL-13 +bb-1 NULL cc-2 NULL-12 +bb-1 NULL cc-2 NULL-11 +bb-1 NULL cc-2 NULL-10 +bb-1 NULL cc-2 NULL-9 +bb-1 NULL cc-2 NULL-8 +bb-1 NULL cc-2 NULL-7 +bb-1 NULL cc-2 NULL-6 +bb-1 NULL cc-2 NULL-5 +bb-1 NULL cc-2 NULL-4 +bb-1 NULL cc-2 NULL-3 +bb-1 NULL cc-2 NULL-2 +bb-1 NULL cc-2 NULL-1 +drop table t1, t2, t3, t4; +create table t1 (a int, b int not null,unique key (a,b),index(b)); +insert ignore into t1 values (1,1),(2,2),(3,3),(4,4),(5,5),(6,6),(null,7),(9,9),(8,8),(7,7),(null,9),(null,9),(6,6); +Warnings: +Warning 1062 Duplicate entry '6-6' for key 't1.a' +create table t2 like t1; +insert into t2 select * from t1; +alter table t1 modify b blob not null, add c int not null, drop key a, add unique key (a,b(20),c), drop key b, add key (b(10)); +select * from t1 where a is null; +a b c +NULL 7 0 +NULL 9 0 +NULL 9 0 +select * from t1 where (a is null or a > 0 and a < 3) and b > 7 limit 3; +a b c +NULL 9 0 +NULL 9 0 +select * from t1 where a is null and b=9 or a is null and b=7 limit 3; +a b c +NULL 7 0 +NULL 9 0 +NULL 9 0 +drop table t1, t2; +CREATE TABLE t1 ( +ID int(10) unsigned NOT NULL AUTO_INCREMENT, +col1 int(10) unsigned DEFAULT NULL, +key1 int(10) unsigned NOT NULL DEFAULT '0', +key2 int(10) unsigned DEFAULT NULL, +text1 text, +text2 text, +col2 smallint(6) DEFAULT '100', +col3 enum('headers','bodyandsubject') NOT NULL DEFAULT 'bodyandsubject', +col4 tinyint(3) unsigned NOT NULL DEFAULT '0', +PRIMARY KEY (ID), +KEY (key1), +KEY (key2) +) AUTO_INCREMENT=6 DEFAULT CHARSET=utf8; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES +(1,NULL,1130,NULL,'Hello',NULL,100,'bodyandsubject',0), +(2,NULL,1130,NULL,'bye',NULL,100,'bodyandsubject',0), +(3,NULL,1130,NULL,'red',NULL,100,'bodyandsubject',0), +(4,NULL,1130,NULL,'yellow',NULL,100,'bodyandsubject',0), +(5,NULL,1130,NULL,'blue',NULL,100,'bodyandsubject',0); +select * FROM t1 WHERE key1=1130 AND col1 IS NULL ORDER BY text1; +ID col1 key1 key2 text1 text2 col2 col3 col4 +5 NULL 1130 NULL blue NULL 100 bodyandsubject 0 +2 NULL 1130 NULL bye NULL 100 bodyandsubject 0 +1 NULL 1130 NULL Hello NULL 100 bodyandsubject 0 +3 NULL 1130 NULL red NULL 100 bodyandsubject 0 +4 NULL 1130 NULL yellow NULL 100 bodyandsubject 0 +drop table t1; + +BUG#37851: Crash in test_if_skip_sort_order tab->select is zero + +CREATE TABLE t1 ( +pk int(11) NOT NULL AUTO_INCREMENT, +PRIMARY KEY (pk) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (1); +CREATE TABLE t2 ( +pk int(11) NOT NULL AUTO_INCREMENT, +int_key int(11) DEFAULT NULL, +PRIMARY KEY (pk), +KEY int_key (int_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (1,1),(2,6),(3,0); +EXPLAIN +SELECT MIN(t1.pk) +FROM t1 WHERE EXISTS ( +SELECT t2.pk +FROM t2 +WHERE t2.int_key IS NULL +GROUP BY t2.pk +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +2 SUBQUERY t2 NULL ref int_key int_key 5 const 1 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select min(`test`.`t1`.`pk`) AS `MIN(t1.pk)` from `test`.`t1` where false +DROP TABLE t1, t2; +# +# BUG#42048 Discrepancy between MyISAM and Maria's ICP implementation +# +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (a int, b char(20), filler char(200), key(a,b(10))); +insert into t1 select A.a + 10*(B.a + 10*C.a), 'bbb','filler' from t0 A, t0 B, t0 C; +update t1 set b=repeat(char(65+a), 20) where a < 25; +This must show range + using index condition: +explain select * from t1 where a < 10 and b = repeat(char(65+a), 20); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL x x Parallel execute (1 workers) +2 SIMPLE t1 NULL range a a 5 NULL x x Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`filler` AS `filler` from `test`.`t1` where ((`test`.`t1`.`a` < 10) and (`test`.`t1`.`b` = repeat(char((65 + `test`.`t1`.`a`)),20))) +select * from t1 where a < 10 and b = repeat(char(65+a), 20); +a b filler +0 AAAAAAAAAAAAAAAAAAAA filler +1 BBBBBBBBBBBBBBBBBBBB filler +2 CCCCCCCCCCCCCCCCCCCC filler +3 DDDDDDDDDDDDDDDDDDDD filler +4 EEEEEEEEEEEEEEEEEEEE filler +5 FFFFFFFFFFFFFFFFFFFF filler +6 GGGGGGGGGGGGGGGGGGGG filler +7 HHHHHHHHHHHHHHHHHHHH filler +8 IIIIIIIIIIIIIIIIIIII filler +9 JJJJJJJJJJJJJJJJJJJJ filler +drop table t0,t1; +# +# BUG#41136: ORDER BY + range access: EXPLAIN shows "Using MRR" while MRR is actually not used +# +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (a int, b int, key(a)); +insert into t1 select A.a + 10 *(B.a + 10*C.a), A.a + 10 *(B.a + 10*C.a) from t0 A, t0 B, t0 C; +This mustn't show "Using MRR": +explain select * from t1 where a < 20 order by a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 20 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range a a 5 NULL 20 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (`test`.`t1`.`a` < 20) order by `test`.`t1`.`a` +drop table t0, t1; +set @read_rnd_buffer_size_save= @@read_rnd_buffer_size; +set read_rnd_buffer_size=64; +create table t1(a int); +insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t2(a char(8), b char(8), c char(8), filler char(100), key k1(a,b,c) ) charset utf8mb4; +insert into t2 select +concat('a-', 1000 + A.a, '-a'), +concat('b-', 1000 + B.a, '-b'), +concat('c-', 1000 + C.a, '-c'), +'filler' +from t1 A, t1 B, t1 C; +EXPLAIN select count(length(a) + length(filler)) +from t2 force index (k1) +where a>='a-1000-a' and a <'a-1001-a'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 100 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL range k1 k1 33 NULL 100 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select count((length(`test`.`t2`.`a`) + length(`test`.`t2`.`filler`))) AS `count(length(a) + length(filler))` from `test`.`t2` FORCE INDEX (`k1`) where ((`test`.`t2`.`a` >= 'a-1000-a') and (`test`.`t2`.`a` < 'a-1001-a')) +select count(length(a) + length(filler)) +from t2 force index (k1) +where a>='a-1000-a' and a <'a-1001-a'; +count(length(a) + length(filler)) +100 +drop table t2; +create table t2 (a char(100), b char(100), c char(100), d int, +filler char(10), key(d), primary key (a,b,c)) charset latin1; +insert into t2 select A.a, B.a, B.a, A.a, 'filler' from t1 A, t1 B; +explain select * from t2 force index (d) where d < 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (2 workers) +2 SIMPLE t2 NULL range d d 5 NULL # 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c`,`test`.`t2`.`d` AS `d`,`test`.`t2`.`filler` AS `filler` from `test`.`t2` FORCE INDEX (`d`) where (`test`.`t2`.`d` < 10) +drop table t2; +drop table t1; +set @@read_rnd_buffer_size= @read_rnd_buffer_size_save; +create table t1 (f1 int not null, f2 int not null,f3 int not null, f4 char(1), primary key (f1,f2), key ix(f3)); +select * from t1 where (f3>=5 and f3<=10) or (f3>=1 and f3<=4); +f1 f2 f3 f4 +1 1 1 A +10 10 10 A +2 2 2 A +3 3 3 A +4 4 4 A +5 5 5 A +6 6 6 A +7 7 7 A +8 8 8 A +9 9 9 A +drop table t1; + +BUG#37977: Wrong result returned on GROUP BY + OR + Innodb + +CREATE TABLE t1 ( +`pk` int(11) NOT NULL AUTO_INCREMENT, +`int_nokey` int(11) NOT NULL, +`int_key` int(11) NOT NULL, +`date_key` date NOT NULL, +`date_nokey` date NOT NULL, +`time_key` time NOT NULL, +`time_nokey` time NOT NULL, +`datetime_key` datetime NOT NULL, +`datetime_nokey` datetime NOT NULL, +`varchar_key` varchar(5) DEFAULT NULL, +`varchar_nokey` varchar(5) DEFAULT NULL, +PRIMARY KEY (`pk`), +KEY `int_key` (`int_key`), +KEY `date_key` (`date_key`), +KEY `time_key` (`time_key`), +KEY `datetime_key` (`datetime_key`), +KEY `varchar_key` (`varchar_key`) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT IGNORE INTO t1 VALUES +(1,5,5,'2009-10-16','2009-10-16','09:28:15','09:28:15','2007-09-14 05:34:08','2007-09-14 05:34:08','qk','qk'), +(2,6,6,'0000-00-00','0000-00-00','23:06:39','23:06:39','0000-00-00 00:00:00','0000-00-00 00:00:00','j','j'), +(3,10,10,'2000-12-18','2000-12-18','22:16:19','22:16:19','2006-11-04 15:42:50','2006-11-04 15:42:50','aew','aew'), +(4,0,0,'2001-09-18','2001-09-18','00:00:00','00:00:00','2004-03-23 13:23:35','2004-03-23 13:23:35',NULL,NULL), +(5,6,6,'2007-08-16','2007-08-16','22:13:38','22:13:38','2004-08-19 11:01:28','2004-08-19 11:01:28','qu','qu'); +Warnings: +Warning 1264 Out of range value for column 'date_key' at row 2 +Warning 1264 Out of range value for column 'date_nokey' at row 2 +Warning 1264 Out of range value for column 'datetime_key' at row 2 +Warning 1264 Out of range value for column 'datetime_nokey' at row 2 +select pk from t1 WHERE `varchar_key` > 'kr' group by pk; +pk +1 +5 +select pk from t1 WHERE `int_nokey` IS NULL OR `varchar_key` > 'kr' group by pk; +pk +1 +5 +drop table t1; +# +# BUG#39447: Error with NOT NULL condition and LIMIT 1 +# +CREATE TABLE t1 ( +id int(11) NOT NULL, +parent_id int(11) DEFAULT NULL, +name varchar(10) DEFAULT NULL, +PRIMARY KEY (id), +KEY ind_parent_id (parent_id) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t1 (id, parent_id, name) values +(10,NULL,'A'), +(20,10,'B'), +(30,10,'C'), +(40,NULL,'D'), +(50,40,'E'), +(60,40,'F'), +(70,NULL,'J'); +SELECT id FROM t1 WHERE parent_id IS NOT NULL ORDER BY id DESC LIMIT 1; +id +60 +This must show type=index, extra=Using where +explain SELECT * FROM t1 WHERE parent_id IS NOT NULL ORDER BY id DESC LIMIT 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 57.14 Backward index scan; Parallel execute (1 workers) +2 SIMPLE t1 NULL index ind_parent_id PRIMARY 4 NULL 1 57.14 Using where; Backward index scan +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,`test`.`t1`.`parent_id` AS `parent_id`,`test`.`t1`.`name` AS `name` from `test`.`t1` where (`test`.`t1`.`parent_id` is not null) order by `test`.`t1`.`id` desc limit 1 +SELECT * FROM t1 WHERE parent_id IS NOT NULL ORDER BY id DESC LIMIT 1; +id parent_id name +60 40 F +drop table t1; +# +# Bug#50381 "Assertion failing in handler.h:1283: +# void COST_VECT::add_io(double, double)" +# +CREATE TABLE t1 ( +c1 INT NOT NULL, +c2 VARCHAR(1) DEFAULT NULL, +PRIMARY KEY (c1) +); +CREATE TABLE t2 ( +c1 INT NOT NULL, +c2 VARCHAR(1) DEFAULT NULL, +PRIMARY KEY (c1) +); +INSERT INTO t2 VALUES (10,'v'); +INSERT INTO t2 VALUES (11,'r'); +SELECT t1.c2 +FROM t2 STRAIGHT_JOIN t1 ON t1.c1 < t2.c1; +c2 +DROP TABLE t1, t2; +# +# Bug#12321461: CRASH IN DSMRR_IMPL::DSMRR_INIT ON SELECT STRAIGHT_JOIN +# +set @save_optimizer_switch = @@optimizer_switch; +set optimizer_switch='block_nested_loop=off,batched_key_access=off'; +CREATE TABLE t1 ( +pk INTEGER, +c1 VARCHAR(1) NOT NULL, +PRIMARY KEY (pk) +); +CREATE TABLE t2 ( +c1 VARCHAR(1) NOT NULL +); +INSERT INTO t2 VALUES ('v'), ('c'); +EXPLAIN SELECT STRAIGHT_JOIN t1.c1 +FROM t1 RIGHT OUTER JOIN t2 ON t1.c1 = t2.c1 +WHERE t1.pk > 176; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 SIMPLE t1 NULL range PRIMARY PRIMARY 4 NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select straight_join `test`.`t1`.`c1` AS `c1` from `test`.`t2` join `test`.`t1` where ((`test`.`t1`.`c1` = `test`.`t2`.`c1`) and (`test`.`t1`.`pk` > 176)) +SELECT STRAIGHT_JOIN t1.c1 +FROM t1 RIGHT OUTER JOIN t2 ON t1.c1 = t2.c1 +WHERE t1.pk > 176; +c1 +DROP TABLE t1,t2; +set optimizer_switch= @save_optimizer_switch; +# +# Bug#13249966 MRR: RANDOM ERROR DUE TO UNINITIALIZED RES WITH +# SMALL READ_RND_BUFFER_SIZE +# +set @read_rnd_buffer_size_save= @@read_rnd_buffer_size; +set read_rnd_buffer_size=1; +select @@read_rnd_buffer_size; +@@read_rnd_buffer_size +1 +CREATE TABLE t1 ( +i1 INTEGER NOT NULL, +i2 INTEGER NOT NULL, +KEY (i2) +); +INSERT INTO t1 VALUES (0,1),(1,2),(2,3); +EXPLAIN SELECT i1 +FROM t1 +WHERE i2 > 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range i2 i2 4 NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i1` AS `i1` from `test`.`t1` where (`test`.`t1`.`i2` > 2) +SELECT i1 +FROM t1 +WHERE i2 > 2; +i1 +2 +DROP TABLE t1; +set @@read_rnd_buffer_size= @read_rnd_buffer_size_save; +select @@read_rnd_buffer_size; +@@read_rnd_buffer_size +262144 +# +# Bug 12365385 STRAIGHT_JOIN QUERY QUICKLY EXHAUSTS SYSTEM+VIRT. +# MEMORY LEADING TO SYSTEM CRASH +# +CREATE TABLE ten (a INTEGER); +INSERT INTO ten VALUES (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +CREATE TABLE t1 ( +pk INTEGER NOT NULL, +i1 INTEGER NOT NULL, +c1 VARCHAR(10) NOT NULL, +PRIMARY KEY (pk) +) charset latin1; +INSERT INTO t1 +SELECT a, 1, 'MySQL' FROM ten; +CREATE TABLE t2 ( +pk INTEGER NOT NULL, +c1 VARCHAR(10) NOT NULL, +c2 varchar(10) NOT NULL, +PRIMARY KEY (pk) +) charset latin1; +INSERT INTO t2 +SELECT a, 'MySQL', 'MySQL' FROM ten; +CREATE TABLE t3 ( +pk INTEGER NOT NULL, +c1 VARCHAR(10) NOT NULL, +PRIMARY KEY (pk) +) charset latin1; +INSERT INTO t3 +SELECT a, 'MySQL' FROM ten; +CREATE TABLE t4 ( +pk int(11) NOT NULL, +c1_key varchar(10) CHARACTER SET utf8 NOT NULL, +c2 varchar(10) NOT NULL, +c3 varchar(10) NOT NULL, +PRIMARY KEY (pk), +KEY k1 (c1_key) +) charset latin1; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +CREATE TABLE t5 ( +pk INTEGER NOT NULL, +c1 VARCHAR(10) NOT NULL, +PRIMARY KEY (pk) +) charset latin1; +INSERT INTO t5 +SELECT a, 'MySQL' FROM ten; +EXPLAIN SELECT STRAIGHT_JOIN * +FROM +(t1 LEFT JOIN +(t2 LEFT JOIN +(t3 LEFT OUTER JOIN t4 ON t3.c1 <= t4.c1_key) +ON t2.c1 = t4.c3) +ON t1.c1 = t4.c2) +RIGHT OUTER JOIN t5 ON t2.c2 <= t5.c1 +WHERE t1.i1 = 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 100.00 Parallel execute (1 workers) +2 SIMPLE t5 NULL ALL NULL NULL NULL NULL 10 100.00 NULL +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 10.00 Using where; Using join buffer (hash join) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 10 33.33 Using where; Using join buffer (hash join) +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 10 100.00 Using join buffer (hash join) +2 SIMPLE t4 NULL ALL k1 NULL NULL NULL 1 100.00 Range checked for each record (index map: 0x2) +Warnings: +Note 1003 /* select#1 */ select straight_join `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`i1` AS `i1`,`test`.`t1`.`c1` AS `c1`,`test`.`t2`.`pk` AS `pk`,`test`.`t2`.`c1` AS `c1`,`test`.`t2`.`c2` AS `c2`,`test`.`t3`.`pk` AS `pk`,`test`.`t3`.`c1` AS `c1`,`test`.`t4`.`pk` AS `pk`,`test`.`t4`.`c1_key` AS `c1_key`,`test`.`t4`.`c2` AS `c2`,`test`.`t4`.`c3` AS `c3`,`test`.`t5`.`pk` AS `pk`,`test`.`t5`.`c1` AS `c1` from `test`.`t5` join `test`.`t1` join `test`.`t2` join `test`.`t3` join `test`.`t4` where ((`test`.`t4`.`c3` = `test`.`t2`.`c1`) and (`test`.`t4`.`c2` = `test`.`t1`.`c1`) and (`test`.`t1`.`i1` = 1) and (`test`.`t2`.`c2` <= `test`.`t5`.`c1`) and (`test`.`t3`.`c1` <= `test`.`t4`.`c1_key`)) +SELECT STRAIGHT_JOIN * +FROM +(t1 LEFT JOIN +(t2 LEFT JOIN +(t3 LEFT OUTER JOIN t4 ON t3.c1 <= t4.c1_key) +ON t2.c1 = t4.c3) +ON t1.c1 = t4.c2) +RIGHT OUTER JOIN t5 ON t2.c2 <= t5.c1 +WHERE t1.i1 = 1; +pk i1 c1 pk c1 c2 pk c1 pk c1_key c2 c3 pk c1 +DROP TABLE ten, t1, t2, t3, t4, t5; +# +# Bug 18172819 CRASH ON DSMRR_IMPL::CHOOSE_MRR_IMPL IN SQL/HANDLER.CC +# +set @big_tables_save= @@big_tables; +set @optimizer_switch_save=@@optimizer_switch; +set big_tables=ON; +set optimizer_switch='derived_merge=off'; +SELECT @@big_tables; +@@big_tables +1 +CREATE TABLE t1 ( +i1 INTEGER NOT NULL, +c1 VARCHAR(1) +) charset utf8mb4; +INSERT INTO t1 VALUES (1,'a'), (2, NULL); +CREATE TABLE t2 ( +c1 VARCHAR(1), +i1 INTEGER NOT NULL, +KEY (c1) +) charset utf8mb4; +INSERT INTO t2 VALUES ('a', 1), (NULL, 2); +EXPLAIN SELECT * +FROM +( SELECT * FROM t1 ) AS d1 +WHERE d1.c1 IN ( SELECT c1 FROM t2 ) +AND d1.c1 IS NULL +ORDER BY d1.i1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using filesort +3 DEPENDENT SUBQUERY t2 NULL index_subquery c1 c1 7 func 1 100.00 Using index +2 DERIVED t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `d1`.`i1` AS `i1`,`d1`.`c1` AS `c1` from (/* select#2 */ select `test`.`t1`.`i1` AS `i1`,`test`.`t1`.`c1` AS `c1` from `test`.`t1` where (`test`.`t1`.`c1` is null)) `d1` where (`d1`.`c1`,(((`d1`.`c1`) in t2 on c1))) order by `d1`.`i1` +SELECT * +FROM +( SELECT * FROM t1 ) AS d1 +WHERE d1.c1 IN ( SELECT c1 FROM t2 ) +AND d1.c1 IS NULL +ORDER BY d1.i1; +i1 c1 +DROP TABLE t1, t2; +set big_tables=@big_tables_save; +set optimizer_switch=@optimizer_switch_save; +# +# Bug#41029 "MRR: SELECT FOR UPDATE fails to lock gaps (InnoDB table)" +# +SET AUTOCOMMIT=0; +CREATE TABLE t1 ( +dummy INT PRIMARY KEY, +a INT UNIQUE, +b INT +) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1,1,1),(3,3,3),(5,5,5); +COMMIT; +SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ; +SELECT @@transaction_isolation; +@@transaction_isolation +REPEATABLE-READ +START TRANSACTION; +EXPLAIN SELECT * FROM t1 WHERE a > 2 FOR UPDATE; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range a a 5 NULL 2 100.00 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`dummy` AS `dummy`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (`test`.`t1`.`a` > 2) +SELECT * FROM t1 WHERE a > 2 FOR UPDATE; +dummy a b +3 3 3 +5 5 5 +SET AUTOCOMMIT=0; +START TRANSACTION; +INSERT INTO t1 VALUES (2,2,2); +ERROR HY000: Lock wait timeout exceeded; try restarting transaction +ROLLBACK; +ROLLBACK; +DROP TABLE t1; +# +# Bug#54286 "Server crash at lock timeout with MRR" +# +SET AUTOCOMMIT=0; +CREATE TABLE t1 ( +dummy INT PRIMARY KEY, +a INT UNIQUE, +b INT +) ENGINE=InnoDB; +COMMIT; +INSERT INTO t1 VALUES (1,1,1),(3,3,3),(5,5,5); +SET AUTOCOMMIT=0; +SELECT * FROM t1 WHERE a > 2 FOR UPDATE; +ERROR HY000: Lock wait timeout exceeded; try restarting transaction +ROLLBACK; +ROLLBACK; +DROP TABLE t1; +COMMIT; +set default_storage_engine= @save_storage_engine; +set optimizer_switch=default; diff --git a/mysql-test/r/innodb_pk_extension_off.result-pq b/mysql-test/r/innodb_pk_extension_off.result-pq new file mode 100644 index 000000000000..836cb2c974a5 --- /dev/null +++ b/mysql-test/r/innodb_pk_extension_off.result-pq @@ -0,0 +1,496 @@ +# +# WL#6266 Make use of hidden key parts +# +# +# Optimizer switch use_index_extensions=off +# +set optimizer_switch= "use_index_extensions=off"; +CREATE TABLE t1 +( +pk_1 INT, +pk_2 INT, +f1 DATETIME, +f2 INT, +PRIMARY KEY(pk_1, pk_2), +KEY k1(f1), +KEY k2(f2) +) ENGINE = InnoDB; +INSERT INTO t1 VALUES +(1, 1, '2000-01-01', 1), (1, 2, '2000-01-02', 2), (1, 3, '2000-01-03', 3), (1, 4, '2000-01-04', 4), (1, 5, '2000-01-05', 5), +(2, 1, '2000-01-01', 6), (2, 2, '2000-01-02', 7), (2, 3, '2000-01-03', 8), (2, 4, '2000-01-04', 9), (2, 5, '2000-01-05', 10), +(3, 1, '2000-01-01', 11), (3, 2, '2000-01-02', 12), (3, 3, '2000-01-03', 13), (3, 4, '2000-01-04', 14), (3, 5, '2000-01-05', 15), +(4, 1, '2000-01-01', 16), (4, 2, '2000-01-02', 17), (4, 3, '2000-01-03', 18), (4, 4, '2000-01-04', 19), (4, 5, '2000-01-05', 20), +(5, 1, '2000-01-01', 21), (5, 2, '2000-01-02', 22), (5, 3, '2000-01-03', 23), (5, 4, '2000-01-04', 24), (5, 5, '2000-01-05', 25), +(6, 1, '2000-01-06', 26), (6, 2, '2000-01-06', 27), (6, 3, '2000-01-03', 28), (6, 4, '2000-01-06', 29), (6, 5, '2000-01-06', 30), +(7, 1, '2000-01-06', 31), (7, 2, '2000-01-06', 32), (7, 3, '2000-01-03', 33), (7, 4, '2000-01-06', 34), (7, 5, '2000-01-06', 35), +(8, 1, '2000-01-06', 36), (8, 2, '2000-01-06', 37), (8, 3, '2000-01-03', 38), (8, 4, '2000-01-06', 39), (8, 5, '2000-01-06', 40), +(9, 1, '2000-01-06', 41), (9, 2, '2000-01-06', 42), (9, 3, '2000-01-03', 43), (9, 4, '2000-01-06', 44), (9, 5, '2000-01-06', 45); +INSERT INTO t1 VALUES +(11, 1, '2000-01-01', 1), (11, 2, '2000-01-02', 2), (11, 3, '2000-01-03', 3), (11, 4, '2000-01-04', 4), (11, 5, '2000-01-05', 5), +(12, 1, '2000-01-01', 6), (12, 2, '2000-01-02', 7), (12, 3, '2000-01-03', 8), (12, 4, '2000-01-04', 9), (12, 5, '2000-01-05', 10), +(13, 1, '2000-01-01', 11), (13, 2, '2000-01-02', 12), (13, 3, '2000-01-03', 13), (13, 4, '2000-01-04', 14), (13, 5, '2000-01-05', 15), +(14, 1, '2000-01-01', 16), (14, 2, '2000-01-02', 17), (14, 3, '2000-01-03', 18), (14, 4, '2000-01-04', 19), (14, 5, '2000-01-05', 20), +(15, 1, '2000-01-01', 1), (15, 2, '2000-01-02', 2), (15, 3, '2000-01-03', 3), (15, 4, '2000-01-04', 4), (15, 5, '2000-01-05', 5), +(16, 1, '2000-01-06', 6), (16, 2, '2000-01-06', 7), (16, 3, '2000-01-03', 8), (16, 4, '2000-01-06', 9), (16, 5, '2000-01-06', 10), +(17, 1, '2000-01-06', 31), (17, 2, '2000-01-06', 32), (17, 3, '2000-01-03', 33), (17, 4, '2000-01-06', 34), (17, 5, '2000-01-06', 35), +(18, 1, '2000-01-06', 36), (18, 2, '2000-01-06', 37), (18, 3, '2000-01-03', 38), (18, 4, '2000-01-06', 39), (18, 5, '2000-01-06', 40), +(19, 1, '2000-01-06', 1), (19, 2, '2000-01-06', 2), (19, 3, '2000-01-03', 3), (19, 4, '2000-01-06', 4), (19, 5, '2000-01-06', 5); +INSERT INTO t1 VALUES +(21, 1, '2000-01-01', 1), (21, 2, '2000-01-02', 2), (31, 3, '2000-01-03', 3), (41, 4, '2000-01-04', 4), (51, 5, '2000-01-05', 5), +(22, 1, '2000-01-01', 6), (22, 2, '2000-01-02', 7), (32, 3, '2000-01-03', 8), (42, 4, '2000-01-04', 9), (52, 5, '2000-01-05', 10), +(23, 1, '2000-01-01', 11), (23, 2, '2000-01-02', 12), (33, 3, '2000-01-03', 13), (43, 4, '2000-01-04', 14), (53, 5, '2000-01-05', 15), +(24, 1, '2000-01-01', 16), (24, 2, '2000-01-02', 17), (34, 3, '2000-01-03', 18), (44, 4, '2000-01-04', 19), (54, 5, '2000-01-05', 20), +(25, 1, '2000-01-01', 1), (25, 2, '2000-01-02', 2), (35, 3, '2000-01-03', 3), (45, 4, '2000-01-04', 4), (55, 5, '2000-01-05', 5), +(26, 1, '2000-01-06', 6), (26, 2, '2000-01-06', 7), (36, 3, '2000-01-03', 8), (46, 4, '2000-01-06', 9), (56, 5, '2000-01-06', 10), +(27, 1, '2000-01-06', 31), (27, 2, '2000-01-06', 32), (37, 3, '2000-01-03', 33), (47, 4, '2000-01-06', 34), (57, 5, '2000-01-06', 35), +(28, 1, '2000-01-06', 36), (28, 2, '2000-01-06', 37), (38, 3, '2000-01-03', 38), (48, 4, '2000-01-06', 39), (58, 5, '2000-01-06', 40), +(29, 1, '2000-01-06', 1), (29, 2, '2000-01-06', 2), (39, 3, '2000-01-03', 3), (49, 4, '2000-01-06', 4), (59, 5, '2000-01-06', 5); +INSERT INTO t1 SELECT pk_1 + 60, pk_2, f1, f2 FROM t1; +INSERT INTO t1 SELECT pk_1 + 120, pk_2, f1, f2 FROM t1; +INSERT INTO t1 SELECT pk_1 + 240, pk_2, f1, f2 FROM t1; +INSERT INTO t1 SELECT pk_1, pk_2 + 10, f1, f2 FROM t1; +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +# +# REF access optimization +# +EXPLAIN SELECT count(*) FROM t1 WHERE pk_1 = 3 and f1 = '2000-01-03'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 20.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref PRIMARY,k1 PRIMARY 4 const # 20.00 Using where +Warnings: +Note 1003 /* select#1 */ select count(0) AS `count(*)` from `test`.`t1` where ((`test`.`t1`.`f1` = TIMESTAMP'2000-01-03 00:00:00') and (`test`.`t1`.`pk_1` = 3)) +FLUSH STATUS; +SELECT count(*) FROM t1 WHERE pk_1 = 3 and f1 = '2000-01-03'; +count(*) +2 +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 3 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 11 +EXPLAIN SELECT pk_2 FROM t1 WHERE pk_1 = 3 and f1 = '2000-01-03'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 20.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref PRIMARY,k1 PRIMARY 4 const # 20.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk_2` AS `pk_2` from `test`.`t1` where ((`test`.`t1`.`f1` = TIMESTAMP'2000-01-03 00:00:00') and (`test`.`t1`.`pk_1` = 3)) +FLUSH STATUS; +SELECT pk_2 FROM t1 WHERE pk_1 = 3 and f1 = '2000-01-03'; +pk_2 +3 +13 +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 3 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 11 +# +# RANGE access optimization +# +EXPLAIN SELECT count(*) FROM t1 WHERE pk_1 BETWEEN 3 AND 5 AND f1 = '2000-01-03'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 20.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range PRIMARY,k1 PRIMARY 4 NULL # 20.00 Using where +Warnings: +Note 1003 /* select#1 */ select count(0) AS `count(*)` from `test`.`t1` where ((`test`.`t1`.`f1` = TIMESTAMP'2000-01-03 00:00:00') and (`test`.`t1`.`pk_1` between 3 and 5)) +FLUSH STATUS; +SELECT count(*) FROM t1 WHERE pk_1 BETWEEN 3 AND 5 AND f1 = '2000-01-03'; +count(*) +6 +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 2 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 31 +EXPLAIN SELECT pk_1, pk_2 FROM t1 WHERE pk_1 BETWEEN 3 AND 5 AND f1 = '2000-01-03'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 20.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range PRIMARY,k1 PRIMARY 4 NULL # 20.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk_1` AS `pk_1`,`test`.`t1`.`pk_2` AS `pk_2` from `test`.`t1` where ((`test`.`t1`.`f1` = TIMESTAMP'2000-01-03 00:00:00') and (`test`.`t1`.`pk_1` between 3 and 5)) +FLUSH STATUS; +SELECT pk_1, pk_2 FROM t1 WHERE pk_1 BETWEEN 3 AND 5 AND f1 = '2000-01-03'; +pk_1 pk_2 +3 3 +3 13 +4 3 +4 13 +5 3 +5 13 +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 2 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 31 +# +# MAX/MIN optimization +# +EXPLAIN SELECT MIN(pk_1) FROM t1 WHERE f1 = '2000-01-03'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (2 workers) +2 SIMPLE t1 NULL ref k1 k1 6 const # 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select min(`test`.`t1`.`pk_1`) AS `MIN(pk_1)` from `test`.`t1` where (`test`.`t1`.`f1` = TIMESTAMP'2000-01-03 00:00:00') +FLUSH STATUS; +SELECT MIN(pk_1) FROM t1 WHERE f1 = '2000-01-03'; +MIN(pk_1) +1 +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 3 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 434 +EXPLAIN SELECT MIN(pk_1) FROM t1 WHERE pk_1 BETWEEN 3 AND 5 AND f1 = '2000-01-03'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 20.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range PRIMARY,k1 PRIMARY 4 NULL # 20.00 Using where +Warnings: +Note 1003 /* select#1 */ select min(`test`.`t1`.`pk_1`) AS `MIN(pk_1)` from `test`.`t1` where ((`test`.`t1`.`f1` = TIMESTAMP'2000-01-03 00:00:00') and (`test`.`t1`.`pk_1` between 3 and 5)) +FLUSH STATUS; +SELECT MIN(pk_1) FROM t1 WHERE pk_1 BETWEEN 3 AND 5 AND f1 = '2000-01-03'; +MIN(pk_1) +3 +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 2 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 31 +EXPLAIN SELECT MAX(pk_1) FROM t1 WHERE f1 = '2000-01-03'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (2 workers) +2 SIMPLE t1 NULL ref k1 k1 6 const # 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select max(`test`.`t1`.`pk_1`) AS `MAX(pk_1)` from `test`.`t1` where (`test`.`t1`.`f1` = TIMESTAMP'2000-01-03 00:00:00') +FLUSH STATUS; +SELECT MAX(pk_1) FROM t1 WHERE f1 = '2000-01-03'; +MAX(pk_1) +459 +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 3 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 434 +EXPLAIN SELECT MAX(pk_1) FROM t1 WHERE pk_1 BETWEEN 3 AND 5 AND f1 = '2000-01-03'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 20.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range PRIMARY,k1 PRIMARY 4 NULL # 20.00 Using where +Warnings: +Note 1003 /* select#1 */ select max(`test`.`t1`.`pk_1`) AS `MAX(pk_1)` from `test`.`t1` where ((`test`.`t1`.`f1` = TIMESTAMP'2000-01-03 00:00:00') and (`test`.`t1`.`pk_1` between 3 and 5)) +FLUSH STATUS; +SELECT MAX(pk_1) FROM t1 WHERE pk_1 BETWEEN 3 AND 5 AND f1 = '2000-01-03'; +MAX(pk_1) +5 +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 2 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 31 +# +# Loose index scan +# +EXPLAIN SELECT MIN(pk_1) FROM t1 WHERE f2 BETWEEN 13 AND 14 GROUP BY f2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (2 workers) +2 SIMPLE t1 NULL range k2 k2 5 NULL # 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select min(`test`.`t1`.`pk_1`) AS `MIN(pk_1)` from `test`.`t1` where (`test`.`t1`.`f2` between 13 and 14) group by `test`.`t1`.`f2` +FLUSH STATUS; +SELECT MIN(pk_1) FROM t1 WHERE f2 BETWEEN 13 AND 14 GROUP BY f2; +MIN(pk_1) +3 +3 +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 2 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 98 +EXPLAIN SELECT MIN(pk_1) FROM t1 WHERE f2 IN (1, 2) GROUP BY f2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (2 workers) +2 SIMPLE t1 NULL range k2 k2 5 NULL # 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select min(`test`.`t1`.`pk_1`) AS `MIN(pk_1)` from `test`.`t1` where (`test`.`t1`.`f2` in (1,2)) group by `test`.`t1`.`f2` +FLUSH STATUS; +SELECT MIN(pk_1) FROM t1 WHERE f2 IN (1, 2) GROUP BY f2; +MIN(pk_1) +1 +1 +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 4 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 226 +# +# JOIN optimization +# +EXPLAIN SELECT count(*) FROM t1 AS t1 JOIN t1 AS t2 +ON t2.pk_1 = t1.pk_1 WHERE t1.f1 = '2000-01-03' AND t2.f1 = '2000-01-03'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (2 workers) +2 SIMPLE t1 NULL ref PRIMARY,k1 k1 6 const # 100.00 Using index +2 SIMPLE t2 NULL ref PRIMARY,k1 PRIMARY 4 test.t1.pk_1 # 20.00 Using where +Warnings: +Note 1003 /* select#1 */ select count(0) AS `count(*)` from `test`.`t1` join `test`.`t1` `t2` where ((`test`.`t2`.`pk_1` = `test`.`t1`.`pk_1`) and (`test`.`t2`.`f1` = TIMESTAMP'2000-01-03 00:00:00') and (`test`.`t1`.`f1` = TIMESTAMP'2000-01-03 00:00:00')) +FLUSH STATUS; +SELECT count(*) FROM t1 AS t1 JOIN t1 AS t2 +ON t2.pk_1 = t1.pk_1 WHERE t1.f1 = '2000-01-03' AND t2.f1 = '2000-01-03'; +count(*) +864 +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 435 +Handler_read_last 0 +Handler_read_next 3168 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 434 +# +# Optimization of sorting +# Also verifies FORMAT=tree for reverse ref access. +# +EXPLAIN SELECT f1, pk_1, pk_2 FROM t1 WHERE pk_1 = 3 AND f1 = '2000-01-03' +ORDER BY pk_2 DESC LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 20.00 Backward index scan; Parallel execute (1 workers) +2 SIMPLE t1 NULL ref PRIMARY,k1 PRIMARY 4 const # 20.00 Using where; Backward index scan +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`f1` AS `f1`,`test`.`t1`.`pk_1` AS `pk_1`,`test`.`t1`.`pk_2` AS `pk_2` from `test`.`t1` where ((`test`.`t1`.`f1` = TIMESTAMP'2000-01-03 00:00:00') and (`test`.`t1`.`pk_1` = 3)) order by `test`.`t1`.`pk_2` desc limit 5 +EXPLAIN FORMAT=tree SELECT f1, pk_1, pk_2 FROM t1 WHERE pk_1 = 3 AND f1 = '2000-01-03' +ORDER BY pk_2 DESC LIMIT 5; +EXPLAIN +-> Limit: 5 row(s) + -> Parallel scan on + -> Limit: 5 row(s) (cost=0.45 rows=2) + -> Filter: (t1.f1 = TIMESTAMP'2000-01-03 00:00:00') (cost=0.45 rows=2) + -> PQblock lookup on t1 using PRIMARY (pk_1=3; iterate backwards) (cost=0.45 rows=10) + +FLUSH STATUS; +SELECT f1, pk_1, pk_2 FROM t1 WHERE pk_1 = 3 AND f1 = '2000-01-03' +ORDER BY pk_2 DESC LIMIT 5; +f1 pk_1 pk_2 +2000-01-03 00:00:00 3 13 +2000-01-03 00:00:00 3 3 +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 3 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 11 +EXPLAIN SELECT f1, pk_1, pk_2 FROM t1 WHERE pk_1 BETWEEN 3 AND 5 AND f1 = '2000-01-03' +ORDER BY pk_2 DESC LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 20.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range PRIMARY,k1 PRIMARY 4 NULL # 20.00 Using where; Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`f1` AS `f1`,`test`.`t1`.`pk_1` AS `pk_1`,`test`.`t1`.`pk_2` AS `pk_2` from `test`.`t1` where ((`test`.`t1`.`f1` = TIMESTAMP'2000-01-03 00:00:00') and (`test`.`t1`.`pk_1` between 3 and 5)) order by `test`.`t1`.`pk_2` desc limit 5 +FLUSH STATUS; +SELECT f1, pk_1, pk_2 FROM t1 WHERE pk_1 BETWEEN 3 AND 5 AND f1 = '2000-01-03' +ORDER BY pk_2 DESC LIMIT 5; +f1 pk_1 pk_2 +2000-01-03 00:00:00 3 13 +2000-01-03 00:00:00 4 13 +2000-01-03 00:00:00 5 13 +2000-01-03 00:00:00 3 3 +2000-01-03 00:00:00 4 3 +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 2 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 31 +DROP TABLE t1; +# +# Max key part limitation +# +CREATE TABLE t1 +( +f1 INT, f2 INT, f3 INT, f4 INT, f5 INT, f6 INT, f7 INT, f8 INT, f9 INT, f10 INT, +f11 INT, f12 INT, f13 INT, f14 INT, f15 INT, f16 INT, f17 INT, f18 INT, +PRIMARY KEY (f1, f2, f3, f4, f5, f6, f7, f8, f9, f10), +KEY k1 (f11, f12, f13, f14, f15, f16, f17) +) ENGINE = InnoDB; +EXPLAIN SELECT f17 FROM t1 FORCE INDEX (k1) WHERE +f1 = 0 AND f2 = 0 AND f3 = 0 AND f4 = 0 AND f5 = 0 AND +f6 = 0 AND f7 = 0 AND f8 = 0 AND f9 = 0 AND f10 = 0 AND +f11 = 0 AND f12 = 0 AND f13 = 0 AND f14 = 0 AND +f15 = 0 AND f16 = 0 AND f17 = 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref k1 k1 35 const,const,const,const,const,const,const # 100.00 Using index condition; Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`f17` AS `f17` from `test`.`t1` FORCE INDEX (`k1`) where ((`test`.`t1`.`f17` = 0) and (`test`.`t1`.`f16` = 0) and (`test`.`t1`.`f15` = 0) and (`test`.`t1`.`f14` = 0) and (`test`.`t1`.`f13` = 0) and (`test`.`t1`.`f12` = 0) and (`test`.`t1`.`f11` = 0) and (`test`.`t1`.`f10` = 0) and (`test`.`t1`.`f9` = 0) and (`test`.`t1`.`f8` = 0) and (`test`.`t1`.`f7` = 0) and (`test`.`t1`.`f6` = 0) and (`test`.`t1`.`f5` = 0) and (`test`.`t1`.`f4` = 0) and (`test`.`t1`.`f3` = 0) and (`test`.`t1`.`f2` = 0) and (`test`.`t1`.`f1` = 0)) +EXPLAIN SELECT f17 FROM t1 FORCE INDEX (k1) WHERE +f1 = 0 AND f2 = 0 AND f3 = 0 AND f4 = 0 AND f5 = 0 AND +f6 = 0 AND f7 = 0 AND f8 = 0 AND f9 = 0 AND +f11 = 0 AND f12 = 0 AND f13 = 0 AND f14 = 0 AND +f15 = 0 AND f16 = 0 AND f17 = 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref k1 k1 35 const,const,const,const,const,const,const # 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`f17` AS `f17` from `test`.`t1` FORCE INDEX (`k1`) where ((`test`.`t1`.`f17` = 0) and (`test`.`t1`.`f16` = 0) and (`test`.`t1`.`f15` = 0) and (`test`.`t1`.`f14` = 0) and (`test`.`t1`.`f13` = 0) and (`test`.`t1`.`f12` = 0) and (`test`.`t1`.`f11` = 0) and (`test`.`t1`.`f9` = 0) and (`test`.`t1`.`f8` = 0) and (`test`.`t1`.`f7` = 0) and (`test`.`t1`.`f6` = 0) and (`test`.`t1`.`f5` = 0) and (`test`.`t1`.`f4` = 0) and (`test`.`t1`.`f3` = 0) and (`test`.`t1`.`f2` = 0) and (`test`.`t1`.`f1` = 0)) +DROP TABLE t1; +# +# Max key length limitation +# +CREATE TABLE t1 +( +f1 VARCHAR(500), f2 VARCHAR(500), f3 VARCHAR(500), +f4 VARCHAR(500), f5 VARCHAR(500), f6 VARCHAR(500), +f7 VARCHAR(500), +PRIMARY KEY (f1, f2, f3, f4), +KEY k1 (f5, f6, f7) +) charset latin1 ENGINE = InnoDB; +EXPLAIN SELECT f5 FROM t1 FORCE INDEX (k1) WHERE +f1 = 'a' AND f2 = 'a' AND f3 = 'a' AND f4 = 'a' AND +f5 = 'a' AND f6 = 'a' AND f7 = 'a'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref k1 k1 1509 const,const,const # 100.00 Using index condition; Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`f5` AS `f5` from `test`.`t1` FORCE INDEX (`k1`) where ((`test`.`t1`.`f7` = 'a') and (`test`.`t1`.`f6` = 'a') and (`test`.`t1`.`f5` = 'a') and (`test`.`t1`.`f4` = 'a') and (`test`.`t1`.`f3` = 'a') and (`test`.`t1`.`f2` = 'a') and (`test`.`t1`.`f1` = 'a')) +EXPLAIN SELECT f5 FROM t1 FORCE INDEX (k1) WHERE +f1 = 'a' AND f2 = 'a' AND f3 = 'a' AND +f5 = 'a' AND f6 = 'a' AND f7 = 'a'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref k1 k1 1509 const,const,const # 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`f5` AS `f5` from `test`.`t1` FORCE INDEX (`k1`) where ((`test`.`t1`.`f7` = 'a') and (`test`.`t1`.`f6` = 'a') and (`test`.`t1`.`f5` = 'a') and (`test`.`t1`.`f3` = 'a') and (`test`.`t1`.`f2` = 'a') and (`test`.`t1`.`f1` = 'a')) +EXPLAIN SELECT f5 FROM t1 FORCE INDEX (k1) WHERE +f1 = 'a' AND f2 = 'a' AND f4 = 'a' AND +f5 = 'a' AND f6 = 'a' AND f7 = 'a'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref k1 k1 1509 const,const,const # 100.00 Using index condition; Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`f5` AS `f5` from `test`.`t1` FORCE INDEX (`k1`) where ((`test`.`t1`.`f7` = 'a') and (`test`.`t1`.`f6` = 'a') and (`test`.`t1`.`f5` = 'a') and (`test`.`t1`.`f4` = 'a') and (`test`.`t1`.`f2` = 'a') and (`test`.`t1`.`f1` = 'a')) +DROP TABLE t1; +# +# Unique extended key +# +CREATE TABLE t1 +( +pk INT NOT NULL auto_increment, +f1 INT NOT NULL, +KEY (f1), +PRIMARY KEY (pk) +) ENGINE = INNODB; +CREATE TABLE t2 +( +f1 INT, +f2 INT +) ENGINE = INNODB; +INSERT INTO t1(f1) VALUES (1),(2); +INSERT INTO t1(f1) SELECT f1 + 2 FROM t1; +INSERT INTO t1(f1) SELECT f1 + 4 FROM t1; +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +INSERT INTO t2 VALUES (1,1), (2,2); +EXPLAIN SELECT t2.f1 FROM t2 JOIN t1 IGNORE INDEX(primary) ON t2.f1 = t1.pk and t2.f2 = t1.f1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +2 SIMPLE t1 NULL ref f1 f1 4 test.t2.f2 1 12.50 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`f1` AS `f1` from `test`.`t2` join `test`.`t1` IGNORE INDEX (PRIMARY) where ((`test`.`t1`.`f1` = `test`.`t2`.`f2`) and (`test`.`t1`.`pk` = `test`.`t2`.`f1`)) +FLUSH STATUS; +SELECT t2.f1 FROM t2 JOIN t1 IGNORE INDEX(primary) ON t2.f1 = t1.pk and t2.f2 = t1.f1; +f1 +1 +2 +SHOW STATUS LIKE 'Handler_read%'; +Variable_name Value +Handler_read_first 1 +Handler_read_key 3 +Handler_read_last 0 +Handler_read_next 2 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 3 +DROP TABLE t1, t2; +# +# Bug#20430526 ADDRESSSANITIZER: HEAP-BUFFER-OVERFLOW IN +# FIELD_BLOB::GET_KEY_IMAGE FLOAT8STORE +# +CREATE TABLE t1 +(a GEOMETRY NOT NULL SRID 0, SPATIAL KEY(a)) ENGINE=INNODB; +INSERT INTO t1 VALUES (point(7, 7)); +SELECT st_astext(a) FROM t1 WHERE st_equals(a, point(7, 7)); +st_astext(a) +POINT(7 7) +DROP TABLE t1; +# +# Bug #31617858 INCORRECT RESULTS WHEN USING INDEX ON LONG CHARACTER COLS. +# +CREATE TABLE t( +a VARCHAR(256) NOT NULL, +i VARCHAR(512) NOT NULL, +PRIMARY KEY (a), +KEY (i)) DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; +INSERT INTO t VALUES +('aaa12345678','aaa'), ('aaa2','aaa'), ('aaa4','aaa'), +('aaa3','aaa'),('aaa1','aaa'); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +EXPLAIN SELECT DISTINCT(i) FROM t FORCE INDEX(i) WHERE a LIKE '%aaa12345678%'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL index i i 2050 NULL 5 20.00 Using where +Warnings: +Note 1003 /* select#1 */ select distinct `test`.`t`.`i` AS `i` from `test`.`t` FORCE INDEX (`i`) where (`test`.`t`.`a` like '%aaa12345678%') +SELECT DISTINCT(i) FROM t FORCE INDEX(i) WHERE a LIKE '%aaa12345678%'; +i +aaa +DROP TABLE t; +set optimizer_switch=default; diff --git a/mysql-test/r/innodb_pk_extension_on.result-pq b/mysql-test/r/innodb_pk_extension_on.result-pq new file mode 100644 index 000000000000..5ea122c5b6fb --- /dev/null +++ b/mysql-test/r/innodb_pk_extension_on.result-pq @@ -0,0 +1,489 @@ +# +# WL#6266 Make use of hidden key parts +# +# +# Optimizer switch use_index_extensions=on +# +set optimizer_switch= "use_index_extensions=on"; +CREATE TABLE t1 +( +pk_1 INT, +pk_2 INT, +f1 DATETIME, +f2 INT, +PRIMARY KEY(pk_1, pk_2), +KEY k1(f1), +KEY k2(f2) +) ENGINE = InnoDB; +INSERT INTO t1 VALUES +(1, 1, '2000-01-01', 1), (1, 2, '2000-01-02', 2), (1, 3, '2000-01-03', 3), (1, 4, '2000-01-04', 4), (1, 5, '2000-01-05', 5), +(2, 1, '2000-01-01', 6), (2, 2, '2000-01-02', 7), (2, 3, '2000-01-03', 8), (2, 4, '2000-01-04', 9), (2, 5, '2000-01-05', 10), +(3, 1, '2000-01-01', 11), (3, 2, '2000-01-02', 12), (3, 3, '2000-01-03', 13), (3, 4, '2000-01-04', 14), (3, 5, '2000-01-05', 15), +(4, 1, '2000-01-01', 16), (4, 2, '2000-01-02', 17), (4, 3, '2000-01-03', 18), (4, 4, '2000-01-04', 19), (4, 5, '2000-01-05', 20), +(5, 1, '2000-01-01', 21), (5, 2, '2000-01-02', 22), (5, 3, '2000-01-03', 23), (5, 4, '2000-01-04', 24), (5, 5, '2000-01-05', 25), +(6, 1, '2000-01-06', 26), (6, 2, '2000-01-06', 27), (6, 3, '2000-01-03', 28), (6, 4, '2000-01-06', 29), (6, 5, '2000-01-06', 30), +(7, 1, '2000-01-06', 31), (7, 2, '2000-01-06', 32), (7, 3, '2000-01-03', 33), (7, 4, '2000-01-06', 34), (7, 5, '2000-01-06', 35), +(8, 1, '2000-01-06', 36), (8, 2, '2000-01-06', 37), (8, 3, '2000-01-03', 38), (8, 4, '2000-01-06', 39), (8, 5, '2000-01-06', 40), +(9, 1, '2000-01-06', 41), (9, 2, '2000-01-06', 42), (9, 3, '2000-01-03', 43), (9, 4, '2000-01-06', 44), (9, 5, '2000-01-06', 45); +INSERT INTO t1 VALUES +(11, 1, '2000-01-01', 1), (11, 2, '2000-01-02', 2), (11, 3, '2000-01-03', 3), (11, 4, '2000-01-04', 4), (11, 5, '2000-01-05', 5), +(12, 1, '2000-01-01', 6), (12, 2, '2000-01-02', 7), (12, 3, '2000-01-03', 8), (12, 4, '2000-01-04', 9), (12, 5, '2000-01-05', 10), +(13, 1, '2000-01-01', 11), (13, 2, '2000-01-02', 12), (13, 3, '2000-01-03', 13), (13, 4, '2000-01-04', 14), (13, 5, '2000-01-05', 15), +(14, 1, '2000-01-01', 16), (14, 2, '2000-01-02', 17), (14, 3, '2000-01-03', 18), (14, 4, '2000-01-04', 19), (14, 5, '2000-01-05', 20), +(15, 1, '2000-01-01', 1), (15, 2, '2000-01-02', 2), (15, 3, '2000-01-03', 3), (15, 4, '2000-01-04', 4), (15, 5, '2000-01-05', 5), +(16, 1, '2000-01-06', 6), (16, 2, '2000-01-06', 7), (16, 3, '2000-01-03', 8), (16, 4, '2000-01-06', 9), (16, 5, '2000-01-06', 10), +(17, 1, '2000-01-06', 31), (17, 2, '2000-01-06', 32), (17, 3, '2000-01-03', 33), (17, 4, '2000-01-06', 34), (17, 5, '2000-01-06', 35), +(18, 1, '2000-01-06', 36), (18, 2, '2000-01-06', 37), (18, 3, '2000-01-03', 38), (18, 4, '2000-01-06', 39), (18, 5, '2000-01-06', 40), +(19, 1, '2000-01-06', 1), (19, 2, '2000-01-06', 2), (19, 3, '2000-01-03', 3), (19, 4, '2000-01-06', 4), (19, 5, '2000-01-06', 5); +INSERT INTO t1 VALUES +(21, 1, '2000-01-01', 1), (21, 2, '2000-01-02', 2), (31, 3, '2000-01-03', 3), (41, 4, '2000-01-04', 4), (51, 5, '2000-01-05', 5), +(22, 1, '2000-01-01', 6), (22, 2, '2000-01-02', 7), (32, 3, '2000-01-03', 8), (42, 4, '2000-01-04', 9), (52, 5, '2000-01-05', 10), +(23, 1, '2000-01-01', 11), (23, 2, '2000-01-02', 12), (33, 3, '2000-01-03', 13), (43, 4, '2000-01-04', 14), (53, 5, '2000-01-05', 15), +(24, 1, '2000-01-01', 16), (24, 2, '2000-01-02', 17), (34, 3, '2000-01-03', 18), (44, 4, '2000-01-04', 19), (54, 5, '2000-01-05', 20), +(25, 1, '2000-01-01', 1), (25, 2, '2000-01-02', 2), (35, 3, '2000-01-03', 3), (45, 4, '2000-01-04', 4), (55, 5, '2000-01-05', 5), +(26, 1, '2000-01-06', 6), (26, 2, '2000-01-06', 7), (36, 3, '2000-01-03', 8), (46, 4, '2000-01-06', 9), (56, 5, '2000-01-06', 10), +(27, 1, '2000-01-06', 31), (27, 2, '2000-01-06', 32), (37, 3, '2000-01-03', 33), (47, 4, '2000-01-06', 34), (57, 5, '2000-01-06', 35), +(28, 1, '2000-01-06', 36), (28, 2, '2000-01-06', 37), (38, 3, '2000-01-03', 38), (48, 4, '2000-01-06', 39), (58, 5, '2000-01-06', 40), +(29, 1, '2000-01-06', 1), (29, 2, '2000-01-06', 2), (39, 3, '2000-01-03', 3), (49, 4, '2000-01-06', 4), (59, 5, '2000-01-06', 5); +INSERT INTO t1 SELECT pk_1 + 60, pk_2, f1, f2 FROM t1; +INSERT INTO t1 SELECT pk_1 + 120, pk_2, f1, f2 FROM t1; +INSERT INTO t1 SELECT pk_1 + 240, pk_2, f1, f2 FROM t1; +INSERT INTO t1 SELECT pk_1, pk_2 + 10, f1, f2 FROM t1; +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +# +# REF access optimization +# +EXPLAIN SELECT count(*) FROM t1 WHERE pk_1 = 3 and f1 = '2000-01-03'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref PRIMARY,k1 k1 10 const,const # 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select count(0) AS `count(*)` from `test`.`t1` where ((`test`.`t1`.`f1` = TIMESTAMP'2000-01-03 00:00:00') and (`test`.`t1`.`pk_1` = 3)) +FLUSH STATUS; +SELECT count(*) FROM t1 WHERE pk_1 = 3 and f1 = '2000-01-03'; +count(*) +2 +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 3 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 3 +EXPLAIN SELECT pk_2 FROM t1 WHERE pk_1 = 3 and f1 = '2000-01-03'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref PRIMARY,k1 k1 10 const,const # 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk_2` AS `pk_2` from `test`.`t1` where ((`test`.`t1`.`f1` = TIMESTAMP'2000-01-03 00:00:00') and (`test`.`t1`.`pk_1` = 3)) +FLUSH STATUS; +SELECT pk_2 FROM t1 WHERE pk_1 = 3 and f1 = '2000-01-03'; +pk_2 +3 +13 +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 3 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 3 +# +# RANGE access optimization +# +EXPLAIN SELECT count(*) FROM t1 WHERE pk_1 BETWEEN 3 AND 5 AND f1 = '2000-01-03'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range PRIMARY,k1 k1 10 NULL # 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select count(0) AS `count(*)` from `test`.`t1` where ((`test`.`t1`.`f1` = TIMESTAMP'2000-01-03 00:00:00') and (`test`.`t1`.`pk_1` between 3 and 5)) +FLUSH STATUS; +SELECT count(*) FROM t1 WHERE pk_1 BETWEEN 3 AND 5 AND f1 = '2000-01-03'; +count(*) +6 +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 2 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 7 +EXPLAIN SELECT pk_1, pk_2 FROM t1 WHERE pk_1 BETWEEN 3 AND 5 AND f1 = '2000-01-03'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range PRIMARY,k1 k1 10 NULL # 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk_1` AS `pk_1`,`test`.`t1`.`pk_2` AS `pk_2` from `test`.`t1` where ((`test`.`t1`.`f1` = TIMESTAMP'2000-01-03 00:00:00') and (`test`.`t1`.`pk_1` between 3 and 5)) +FLUSH STATUS; +SELECT pk_1, pk_2 FROM t1 WHERE pk_1 BETWEEN 3 AND 5 AND f1 = '2000-01-03'; +pk_1 pk_2 +3 3 +3 13 +4 3 +4 13 +5 3 +5 13 +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 2 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 7 +# +# MAX/MIN optimization +# +EXPLAIN SELECT MIN(pk_1) FROM t1 WHERE f1 = '2000-01-03'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL # NULL Select tables optimized away +Warnings: +Note 1003 /* select#1 */ select min(`test`.`t1`.`pk_1`) AS `MIN(pk_1)` from `test`.`t1` where multiple equal(TIMESTAMP'2000-01-03 00:00:00', `test`.`t1`.`f1`) +FLUSH STATUS; +SELECT MIN(pk_1) FROM t1 WHERE f1 = '2000-01-03'; +MIN(pk_1) +1 +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 1 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +EXPLAIN SELECT MIN(pk_1) FROM t1 WHERE pk_1 BETWEEN 3 AND 5 AND f1 = '2000-01-03'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL # NULL Select tables optimized away +Warnings: +Note 1003 /* select#1 */ select min(`test`.`t1`.`pk_1`) AS `MIN(pk_1)` from `test`.`t1` where ((`test`.`t1`.`pk_1` between 3 and 5) and multiple equal(TIMESTAMP'2000-01-03 00:00:00', `test`.`t1`.`f1`)) +FLUSH STATUS; +SELECT MIN(pk_1) FROM t1 WHERE pk_1 BETWEEN 3 AND 5 AND f1 = '2000-01-03'; +MIN(pk_1) +3 +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 1 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +EXPLAIN SELECT MAX(pk_1) FROM t1 WHERE f1 = '2000-01-03'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL # NULL Select tables optimized away +Warnings: +Note 1003 /* select#1 */ select max(`test`.`t1`.`pk_1`) AS `MAX(pk_1)` from `test`.`t1` where multiple equal(TIMESTAMP'2000-01-03 00:00:00', `test`.`t1`.`f1`) +FLUSH STATUS; +SELECT MAX(pk_1) FROM t1 WHERE f1 = '2000-01-03'; +MAX(pk_1) +459 +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 1 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +EXPLAIN SELECT MAX(pk_1) FROM t1 WHERE pk_1 BETWEEN 3 AND 5 AND f1 = '2000-01-03'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL # NULL Select tables optimized away +Warnings: +Note 1003 /* select#1 */ select max(`test`.`t1`.`pk_1`) AS `MAX(pk_1)` from `test`.`t1` where ((`test`.`t1`.`pk_1` between 3 and 5) and multiple equal(TIMESTAMP'2000-01-03 00:00:00', `test`.`t1`.`f1`)) +FLUSH STATUS; +SELECT MAX(pk_1) FROM t1 WHERE pk_1 BETWEEN 3 AND 5 AND f1 = '2000-01-03'; +MAX(pk_1) +5 +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 1 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +# +# Loose index scan +# +EXPLAIN SELECT MIN(pk_1) FROM t1 WHERE f2 BETWEEN 13 AND 14 GROUP BY f2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range k2 k2 5 NULL # 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select min(`test`.`t1`.`pk_1`) AS `MIN(pk_1)` from `test`.`t1` where (`test`.`t1`.`f2` between 13 and 14) group by `test`.`t1`.`f2` +FLUSH STATUS; +SELECT MIN(pk_1) FROM t1 WHERE f2 BETWEEN 13 AND 14 GROUP BY f2; +MIN(pk_1) +3 +3 +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 4 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +EXPLAIN SELECT MIN(pk_1) FROM t1 WHERE f2 IN (1, 2) GROUP BY f2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range k2 k2 5 NULL # 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select min(`test`.`t1`.`pk_1`) AS `MIN(pk_1)` from `test`.`t1` where (`test`.`t1`.`f2` in (1,2)) group by `test`.`t1`.`f2` +FLUSH STATUS; +SELECT MIN(pk_1) FROM t1 WHERE f2 IN (1, 2) GROUP BY f2; +MIN(pk_1) +1 +1 +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 5 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +# +# JOIN optimization +# +EXPLAIN SELECT count(*) FROM t1 AS t1 JOIN t1 AS t2 +ON t2.pk_1 = t1.pk_1 WHERE t1.f1 = '2000-01-03' AND t2.f1 = '2000-01-03'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (2 workers) +2 SIMPLE t1 NULL ref PRIMARY,k1 k1 6 const # 100.00 Using index +2 SIMPLE t2 NULL ref PRIMARY,k1 k1 10 const,test.t1.pk_1 # 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select count(0) AS `count(*)` from `test`.`t1` join `test`.`t1` `t2` where ((`test`.`t2`.`pk_1` = `test`.`t1`.`pk_1`) and (`test`.`t2`.`f1` = TIMESTAMP'2000-01-03 00:00:00') and (`test`.`t1`.`f1` = TIMESTAMP'2000-01-03 00:00:00')) +FLUSH STATUS; +SELECT count(*) FROM t1 AS t1 JOIN t1 AS t2 +ON t2.pk_1 = t1.pk_1 WHERE t1.f1 = '2000-01-03' AND t2.f1 = '2000-01-03'; +count(*) +864 +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 435 +Handler_read_last 0 +Handler_read_next 864 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 434 +# +# Optimization of sorting +# Also verifies FORMAT=tree for reverse ref access. +# +EXPLAIN SELECT f1, pk_1, pk_2 FROM t1 WHERE pk_1 = 3 AND f1 = '2000-01-03' +ORDER BY pk_2 DESC LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Backward index scan; Parallel execute (1 workers) +2 SIMPLE t1 NULL ref PRIMARY,k1 k1 10 const,const # 100.00 Backward index scan; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`f1` AS `f1`,`test`.`t1`.`pk_1` AS `pk_1`,`test`.`t1`.`pk_2` AS `pk_2` from `test`.`t1` where ((`test`.`t1`.`f1` = TIMESTAMP'2000-01-03 00:00:00') and (`test`.`t1`.`pk_1` = 3)) order by `test`.`t1`.`pk_2` desc limit 5 +EXPLAIN FORMAT=tree SELECT f1, pk_1, pk_2 FROM t1 WHERE pk_1 = 3 AND f1 = '2000-01-03' +ORDER BY pk_2 DESC LIMIT 5; +EXPLAIN +-> Limit: 5 row(s) + -> Parallel scan on + -> Limit: 5 row(s) (cost=0.45 rows=2) + -> PQblock lookup on t1 using k1 (f1=TIMESTAMP'2000-01-03 00:00:00', pk_1=3; iterate backwards) (cost=0.45 rows=2) + +FLUSH STATUS; +SELECT f1, pk_1, pk_2 FROM t1 WHERE pk_1 = 3 AND f1 = '2000-01-03' +ORDER BY pk_2 DESC LIMIT 5; +f1 pk_1 pk_2 +2000-01-03 00:00:00 3 13 +2000-01-03 00:00:00 3 3 +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 3 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 3 +EXPLAIN SELECT f1, pk_1, pk_2 FROM t1 WHERE pk_1 BETWEEN 3 AND 5 AND f1 = '2000-01-03' +ORDER BY pk_2 DESC LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range PRIMARY,k1 k1 10 NULL # 100.00 Using where; Using index; Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`f1` AS `f1`,`test`.`t1`.`pk_1` AS `pk_1`,`test`.`t1`.`pk_2` AS `pk_2` from `test`.`t1` where ((`test`.`t1`.`f1` = TIMESTAMP'2000-01-03 00:00:00') and (`test`.`t1`.`pk_1` between 3 and 5)) order by `test`.`t1`.`pk_2` desc limit 5 +FLUSH STATUS; +SELECT f1, pk_1, pk_2 FROM t1 WHERE pk_1 BETWEEN 3 AND 5 AND f1 = '2000-01-03' +ORDER BY pk_2 DESC LIMIT 5; +f1 pk_1 pk_2 +2000-01-03 00:00:00 3 13 +2000-01-03 00:00:00 4 13 +2000-01-03 00:00:00 5 13 +2000-01-03 00:00:00 3 3 +2000-01-03 00:00:00 4 3 +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 2 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 7 +DROP TABLE t1; +# +# Max key part limitation +# +CREATE TABLE t1 +( +f1 INT, f2 INT, f3 INT, f4 INT, f5 INT, f6 INT, f7 INT, f8 INT, f9 INT, f10 INT, +f11 INT, f12 INT, f13 INT, f14 INT, f15 INT, f16 INT, f17 INT, f18 INT, +PRIMARY KEY (f1, f2, f3, f4, f5, f6, f7, f8, f9, f10), +KEY k1 (f11, f12, f13, f14, f15, f16, f17) +) ENGINE = InnoDB; +EXPLAIN SELECT f17 FROM t1 FORCE INDEX (k1) WHERE +f1 = 0 AND f2 = 0 AND f3 = 0 AND f4 = 0 AND f5 = 0 AND +f6 = 0 AND f7 = 0 AND f8 = 0 AND f9 = 0 AND f10 = 0 AND +f11 = 0 AND f12 = 0 AND f13 = 0 AND f14 = 0 AND +f15 = 0 AND f16 = 0 AND f17 = 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref k1 k1 71 const,const,const,const,const,const,const,const,const,const,const,const,const,const,const,const # 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`f17` AS `f17` from `test`.`t1` FORCE INDEX (`k1`) where ((`test`.`t1`.`f17` = 0) and (`test`.`t1`.`f16` = 0) and (`test`.`t1`.`f15` = 0) and (`test`.`t1`.`f14` = 0) and (`test`.`t1`.`f13` = 0) and (`test`.`t1`.`f12` = 0) and (`test`.`t1`.`f11` = 0) and (`test`.`t1`.`f10` = 0) and (`test`.`t1`.`f9` = 0) and (`test`.`t1`.`f8` = 0) and (`test`.`t1`.`f7` = 0) and (`test`.`t1`.`f6` = 0) and (`test`.`t1`.`f5` = 0) and (`test`.`t1`.`f4` = 0) and (`test`.`t1`.`f3` = 0) and (`test`.`t1`.`f2` = 0) and (`test`.`t1`.`f1` = 0)) +EXPLAIN SELECT f17 FROM t1 FORCE INDEX (k1) WHERE +f1 = 0 AND f2 = 0 AND f3 = 0 AND f4 = 0 AND f5 = 0 AND +f6 = 0 AND f7 = 0 AND f8 = 0 AND f9 = 0 AND +f11 = 0 AND f12 = 0 AND f13 = 0 AND f14 = 0 AND +f15 = 0 AND f16 = 0 AND f17 = 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref k1 k1 71 const,const,const,const,const,const,const,const,const,const,const,const,const,const,const,const # 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`f17` AS `f17` from `test`.`t1` FORCE INDEX (`k1`) where ((`test`.`t1`.`f17` = 0) and (`test`.`t1`.`f16` = 0) and (`test`.`t1`.`f15` = 0) and (`test`.`t1`.`f14` = 0) and (`test`.`t1`.`f13` = 0) and (`test`.`t1`.`f12` = 0) and (`test`.`t1`.`f11` = 0) and (`test`.`t1`.`f9` = 0) and (`test`.`t1`.`f8` = 0) and (`test`.`t1`.`f7` = 0) and (`test`.`t1`.`f6` = 0) and (`test`.`t1`.`f5` = 0) and (`test`.`t1`.`f4` = 0) and (`test`.`t1`.`f3` = 0) and (`test`.`t1`.`f2` = 0) and (`test`.`t1`.`f1` = 0)) +DROP TABLE t1; +# +# Max key length limitation +# +CREATE TABLE t1 +( +f1 VARCHAR(500), f2 VARCHAR(500), f3 VARCHAR(500), +f4 VARCHAR(500), f5 VARCHAR(500), f6 VARCHAR(500), +f7 VARCHAR(500), +PRIMARY KEY (f1, f2, f3, f4), +KEY k1 (f5, f6, f7) +) charset latin1 ENGINE = InnoDB; +EXPLAIN SELECT f5 FROM t1 FORCE INDEX (k1) WHERE +f1 = 'a' AND f2 = 'a' AND f3 = 'a' AND f4 = 'a' AND +f5 = 'a' AND f6 = 'a' AND f7 = 'a'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref k1 k1 3015 const,const,const,const,const,const # 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`f5` AS `f5` from `test`.`t1` FORCE INDEX (`k1`) where ((`test`.`t1`.`f7` = 'a') and (`test`.`t1`.`f6` = 'a') and (`test`.`t1`.`f5` = 'a') and (`test`.`t1`.`f4` = 'a') and (`test`.`t1`.`f3` = 'a') and (`test`.`t1`.`f2` = 'a') and (`test`.`t1`.`f1` = 'a')) +EXPLAIN SELECT f5 FROM t1 FORCE INDEX (k1) WHERE +f1 = 'a' AND f2 = 'a' AND f3 = 'a' AND +f5 = 'a' AND f6 = 'a' AND f7 = 'a'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref k1 k1 3015 const,const,const,const,const,const # 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`f5` AS `f5` from `test`.`t1` FORCE INDEX (`k1`) where ((`test`.`t1`.`f7` = 'a') and (`test`.`t1`.`f6` = 'a') and (`test`.`t1`.`f5` = 'a') and (`test`.`t1`.`f3` = 'a') and (`test`.`t1`.`f2` = 'a') and (`test`.`t1`.`f1` = 'a')) +EXPLAIN SELECT f5 FROM t1 FORCE INDEX (k1) WHERE +f1 = 'a' AND f2 = 'a' AND f4 = 'a' AND +f5 = 'a' AND f6 = 'a' AND f7 = 'a'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref k1 k1 2513 const,const,const,const,const # 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`f5` AS `f5` from `test`.`t1` FORCE INDEX (`k1`) where ((`test`.`t1`.`f7` = 'a') and (`test`.`t1`.`f6` = 'a') and (`test`.`t1`.`f5` = 'a') and (`test`.`t1`.`f4` = 'a') and (`test`.`t1`.`f2` = 'a') and (`test`.`t1`.`f1` = 'a')) +DROP TABLE t1; +# +# Unique extended key +# +CREATE TABLE t1 +( +pk INT NOT NULL auto_increment, +f1 INT NOT NULL, +KEY (f1), +PRIMARY KEY (pk) +) ENGINE = INNODB; +CREATE TABLE t2 +( +f1 INT, +f2 INT +) ENGINE = INNODB; +INSERT INTO t1(f1) VALUES (1),(2); +INSERT INTO t1(f1) SELECT f1 + 2 FROM t1; +INSERT INTO t1(f1) SELECT f1 + 4 FROM t1; +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +INSERT INTO t2 VALUES (1,1), (2,2); +EXPLAIN SELECT t2.f1 FROM t2 JOIN t1 IGNORE INDEX(primary) ON t2.f1 = t1.pk and t2.f2 = t1.f1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +2 SIMPLE t1 NULL eq_ref f1 f1 8 test.t2.f2,test.t2.f1 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`f1` AS `f1` from `test`.`t2` join `test`.`t1` IGNORE INDEX (PRIMARY) where ((`test`.`t1`.`f1` = `test`.`t2`.`f2`) and (`test`.`t1`.`pk` = `test`.`t2`.`f1`)) +FLUSH STATUS; +SELECT t2.f1 FROM t2 JOIN t1 IGNORE INDEX(primary) ON t2.f1 = t1.pk and t2.f2 = t1.f1; +f1 +1 +2 +SHOW STATUS LIKE 'Handler_read%'; +Variable_name Value +Handler_read_first 1 +Handler_read_key 3 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 3 +DROP TABLE t1, t2; +# +# Bug#20430526 ADDRESSSANITIZER: HEAP-BUFFER-OVERFLOW IN +# FIELD_BLOB::GET_KEY_IMAGE FLOAT8STORE +# +CREATE TABLE t1 +(a GEOMETRY NOT NULL SRID 0, SPATIAL KEY(a)) ENGINE=INNODB; +INSERT INTO t1 VALUES (point(7, 7)); +SELECT st_astext(a) FROM t1 WHERE st_equals(a, point(7, 7)); +st_astext(a) +POINT(7 7) +DROP TABLE t1; +# +# Bug #31617858 INCORRECT RESULTS WHEN USING INDEX ON LONG CHARACTER COLS. +# +CREATE TABLE t( +a VARCHAR(256) NOT NULL, +i VARCHAR(512) NOT NULL, +PRIMARY KEY (a), +KEY (i)) DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; +INSERT INTO t VALUES +('aaa12345678','aaa'), ('aaa2','aaa'), ('aaa4','aaa'), +('aaa3','aaa'),('aaa1','aaa'); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +EXPLAIN SELECT DISTINCT(i) FROM t FORCE INDEX(i) WHERE a LIKE '%aaa12345678%'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL index i i 2050 NULL 5 20.00 Using where +Warnings: +Note 1003 /* select#1 */ select distinct `test`.`t`.`i` AS `i` from `test`.`t` FORCE INDEX (`i`) where (`test`.`t`.`a` like '%aaa12345678%') +SELECT DISTINCT(i) FROM t FORCE INDEX(i) WHERE a LIKE '%aaa12345678%'; +i +aaa +DROP TABLE t; +set optimizer_switch=default; diff --git a/mysql-test/r/innodb_tmp_table_heap_to_disk.result-pq b/mysql-test/r/innodb_tmp_table_heap_to_disk.result-pq new file mode 100644 index 000000000000..ba15e51020f3 --- /dev/null +++ b/mysql-test/r/innodb_tmp_table_heap_to_disk.result-pq @@ -0,0 +1,125 @@ +set @old_heap_size= @@max_heap_table_size; +set max_heap_table_size = 16384; +select * from information_schema.collations order by id limit 1; +COLLATION_NAME CHARACTER_SET_NAME ID IS_DEFAULT IS_COMPILED SORTLEN PAD_ATTRIBUTE +big5_chinese_ci big5 1 Yes Yes 1 PAD SPACE +set optimizer_switch='firstmatch=off'; +set optimizer_switch='loosescan=off'; +drop table if exists t1; +Warnings: +Note 1051 Unknown table 'test.t1' +create table t1 ( +a int not null, +b int not null, +c datetime default null +); +insert into t1 values +(406989,67,'2006-02-23 17:08:46'), (150078,67,'2005-10-26 11:17:45'), +(406993,67,'2006-02-27 11:20:57'), (245655,67,'2005-12-08 15:59:08'), +(406994,67,'2006-02-27 11:26:46'), (256,67,null), +(398341,67,'2006-02-20 04:48:44'), (254,67,null),(1120,67,null), +(406988,67,'2006-02-23 17:07:22'), (255,67,null), +(398340,67,'2006-02-20 04:38:53'),(406631,67,'2006-02-23 10:49:42'), +(245653,67,'2005-12-08 15:59:07'),(406992,67,'2006-02-24 16:47:18'), +(245654,67,'2005-12-08 15:59:08'),(406995,67,'2006-02-28 11:55:00'), +(127261,67,'2005-10-13 12:17:58'),(406991,67,'2006-02-24 16:42:32'), +(245652,67,'2005-12-08 15:58:27'),(398545,67,'2006-02-20 04:53:13'), +(154504,67,'2005-10-28 11:53:01'),(9199,67,null),(1,67,'2006-02-23 15:01:35'), +(223456,67,null),(4101,67,null),(1133,67,null), +(406990,67,'2006-02-23 18:01:45'),(148815,67,'2005-10-25 15:34:17'), +(148812,67,'2005-10-25 15:30:01'),(245651,67,'2005-12-08 15:58:27'); +insert into t1 select a+10, b+10, c from t1; +insert into t1 select a+20, b+20, c from t1; +insert into t1 select a+30, b+30, c from t1; +insert into t1 select a+40, b+40, c from t1; +insert into t1 select a+50, b+50, c from t1; +insert into t1 select a+60, b+60, c from t1; +insert into t1 select a+70, b+70, c from t1; +insert into t1 select a+80, b+80, c from t1; +drop table if exists t11; +Warnings: +Note 1051 Unknown table 'test.t11' +create table t11 select * from t1; +insert into t1 select a+80, b+80, c from t1; +explain select * from t1 where a in (select a from t11) order by 1, 2, 3 limit 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL x 100.00 Using filesort +1 SIMPLE NULL eq_ref 4 test.t1.a x 100.00 NULL +2 MATERIALIZED t11 NULL ALL NULL NULL NULL NULL x 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` semi join (`test`.`t11`) where (``.`a` = `test`.`t1`.`a`) order by `test`.`t1`.`a`,`test`.`t1`.`b`,`test`.`t1`.`c` limit 1 +select * from t1 where a in (select a from t11) order by 1, 2, 3 limit 1; +a b c +1 67 2006-02-23 15:01:35 +set optimizer_switch='materialization=off'; +explain select * from t1 where a in (select a from t11) order by 1, 2, 3 limit 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t11 NULL ALL NULL NULL NULL NULL x 100.00 Using temporary; Using filesort; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL x 10.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` semi join (`test`.`t11`) where (`test`.`t1`.`a` = `test`.`t11`.`a`) order by `test`.`t1`.`a`,`test`.`t1`.`b`,`test`.`t1`.`c` limit 1 +select * from t1 where a in (select a from t11) order by 1, 2, 3 limit 1; +a b c +1 67 2006-02-23 15:01:35 +drop table t11; +set optimizer_switch=default; +drop table if exists t1, t2; +Warnings: +Note 1051 Unknown table 'test.t2' +CREATE TABLE t1 (id INTEGER); +CREATE TABLE t2 (id INTEGER); +INSERT INTO t1 (id) VALUES (1), (1), (1),(1); +INSERT INTO t1 (id) SELECT id FROM t1; +/* 8 */ +INSERT INTO t1 (id) SELECT id FROM t1; +/* 12 */ +INSERT INTO t1 (id) SELECT id FROM t1; +/* 16 */ +INSERT INTO t1 (id) SELECT id FROM t1; +/* 20 */ +INSERT INTO t1 (id) SELECT id FROM t1; +/* 24 */ +INSERT INTO t1 SELECT id+1 FROM t1; +INSERT INTO t1 SELECT id+2 FROM t1; +INSERT INTO t1 SELECT id+4 FROM t1; +INSERT INTO t1 SELECT id+8 FROM t1; +INSERT INTO t1 SELECT id+16 FROM t1; +INSERT INTO t1 SELECT id+32 FROM t1; +INSERT INTO t1 SELECT id+64 FROM t1; +INSERT INTO t1 SELECT id+128 FROM t1; +INSERT INTO t1 SELECT id+256 FROM t1; +INSERT INTO t1 SELECT id+512 FROM t1; +INSERT INTO t1 SELECT id+1024 FROM t1; +INSERT INTO t2 SELECT id + 2000 FROM t1 limit 4000; +explain select * from t1 union select * from t2 order by 1 limit 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL x 100.00 NULL +2 UNION t2 NULL ALL NULL NULL NULL NULL x 100.00 NULL +NULL UNION RESULT NULL ALL NULL NULL NULL NULL x NULL Using temporary; Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id` from `test`.`t1` union /* select#2 */ select `test`.`t2`.`id` AS `id` from `test`.`t2` order by `id` limit 1 +select * from t1 union select * from t2 order by 1 limit 1; +id +1 +explain SELECT SUM(id) sm FROM t1 group by id order by sm limit 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL x 100.00 Parallel execute (4 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL x 100.00 Using temporary; Using filesort +Warnings: +Note 1003 /* select#1 */ select sum(`test`.`t1`.`id`) AS `sm` from `test`.`t1` group by `test`.`t1`.`id` order by `sm` limit 1 +SELECT SUM(id) sm FROM t1 group by id order by sm limit 1; +sm +128 +explain SELECT SUM(DISTINCT t1.id) sm FROM t1 left join t2 on t1.id=t2.id GROUP BY t1.id order by sm limit 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL x 100.00 Using temporary; Using filesort +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL x 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select sum(distinct `test`.`t1`.`id`) AS `sm` from `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`id` = `test`.`t1`.`id`)) where true group by `test`.`t1`.`id` order by `sm` limit 1 +SELECT SUM(DISTINCT t1.id) sm FROM t1 left join t2 on t1.id=t2.id GROUP BY t1.id order by sm limit 1; +sm +1 +set max_heap_table_size = @old_heap_size; +drop table t1; +drop table t2; +# diff --git a/mysql-test/r/insert_update.result-pq b/mysql-test/r/insert_update.result-pq new file mode 100644 index 000000000000..947f239f8554 --- /dev/null +++ b/mysql-test/r/insert_update.result-pq @@ -0,0 +1,1080 @@ +DROP TABLE IF EXISTS t1, t2; +CREATE TABLE t1 (a INT, b INT, c INT, UNIQUE (A), UNIQUE(B)); +INSERT t1 VALUES (1,2,10), (3,4,20); +INSERT t1 VALUES (5,6,30) ON DUPLICATE KEY UPDATE c=c+100; +SELECT * FROM t1; +a b c +1 2 10 +3 4 20 +5 6 30 +INSERT t1 VALUES (5,7,40) ON DUPLICATE KEY UPDATE c=c+100; +SELECT * FROM t1; +a b c +1 2 10 +3 4 20 +5 6 130 +INSERT t1 VALUES (8,4,50) ON DUPLICATE KEY UPDATE c=c+1000; +SELECT * FROM t1; +a b c +1 2 10 +3 4 1020 +5 6 130 +INSERT t1 VALUES (1,4,60) ON DUPLICATE KEY UPDATE c=c+10000; +SELECT * FROM t1; +a b c +1 2 10010 +3 4 1020 +5 6 130 +INSERT t1 VALUES (1,9,70) ON DUPLICATE KEY UPDATE c=c+100000, b=4; +ERROR 23000: Duplicate entry '4' for key 't1.b' +SELECT * FROM t1; +a b c +1 2 10010 +3 4 1020 +5 6 130 +TRUNCATE TABLE t1; +INSERT t1 VALUES (1,2,10), (3,4,20); +INSERT t1 VALUES (5,6,30), (7,4,40), (8,9,60) ON DUPLICATE KEY UPDATE c=c+100; +SELECT * FROM t1; +a b c +1 2 10 +3 4 120 +5 6 30 +8 9 60 +INSERT t1 SET a=5 ON DUPLICATE KEY UPDATE b=0; +SELECT * FROM t1; +a b c +1 2 10 +3 4 120 +5 0 30 +8 9 60 +INSERT t1 VALUES (2,1,11), (7,4,40) ON DUPLICATE KEY UPDATE c=c+VALUES(a); +Warnings: +Warning 1287 'VALUES function' is deprecated and will be removed in a future release. Please use an alias (INSERT INTO ... VALUES (...) AS alias) and replace VALUES(col) in the ON DUPLICATE KEY UPDATE clause with alias.col instead +SELECT *, VALUES(a) FROM t1; +a b c VALUES(a) +1 2 10 NULL +3 4 127 NULL +5 0 30 NULL +8 9 60 NULL +2 1 11 NULL +Warnings: +Warning 1681 'VALUES function' is deprecated and will be removed in a future release. +analyze table t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +explain SELECT *, VALUES(a) FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL # 100.00 NULL +Warnings: +Warning 1#81 'VALUES function' is deprecated and will be removed in a future release. +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c`,NULL AS `VALUES(a)` from `test`.`t1` +explain select * from t1 where values(a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Warning 1681 'VALUES function' is deprecated and will be removed in a future release. +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` where false +DROP TABLE t1; +create table t1(a int primary key, b int); +insert into t1 values(1,1),(2,2),(3,3),(4,4),(5,5); +select * from t1; +a b +1 1 +2 2 +3 3 +4 4 +5 5 +insert into t1 values(4,14),(5,15),(6,16),(7,17),(8,18) +on duplicate key update b=b+10; +affected rows: 7 +info: Records: 5 Duplicates: 2 Warnings: 0 +select * from t1; +a b +1 1 +2 2 +3 3 +4 14 +5 15 +6 16 +7 17 +8 18 +replace into t1 values(5,25),(6,26),(7,27),(8,28),(9,29); +affected rows: 9 +info: Records: 5 Duplicates: 4 Warnings: 0 +select * from t1; +a b +1 1 +2 2 +3 3 +4 14 +5 25 +6 26 +7 27 +8 28 +9 29 +drop table t1; +CREATE TABLE t1 (a INT, b INT, c INT, UNIQUE (A), UNIQUE(B)); +INSERT t1 VALUES (1,2,10), (3,4,20); +INSERT t1 SELECT 5,6,30 FROM DUAL ON DUPLICATE KEY UPDATE c=c+100; +SELECT * FROM t1; +a b c +1 2 10 +3 4 20 +5 6 30 +INSERT t1 SELECT 5,7,40 FROM DUAL ON DUPLICATE KEY UPDATE c=c+100; +SELECT * FROM t1; +a b c +1 2 10 +3 4 20 +5 6 130 +INSERT t1 SELECT 8,4,50 FROM DUAL ON DUPLICATE KEY UPDATE c=c+1000; +SELECT * FROM t1; +a b c +1 2 10 +3 4 1020 +5 6 130 +INSERT t1 SELECT 1,4,60 FROM DUAL ON DUPLICATE KEY UPDATE c=c+10000; +SELECT * FROM t1; +a b c +1 2 10010 +3 4 1020 +5 6 130 +INSERT t1 SELECT 1,9,70 FROM DUAL ON DUPLICATE KEY UPDATE c=c+100000, b=4; +ERROR 23000: Duplicate entry '4' for key 't1.b' +SELECT * FROM t1; +a b c +1 2 10010 +3 4 1020 +5 6 130 +TRUNCATE TABLE t1; +INSERT t1 VALUES (1,2,10), (3,4,20); +CREATE TABLE t2 (a INT, b INT, c INT, d INT); +INSERT t2 VALUES (5,6,30,1), (7,4,40,1), (8,9,60,1); +INSERT t2 VALUES (2,1,11,2), (7,4,40,2); +INSERT t1 SELECT a,b,c FROM t2 WHERE d=1 ON DUPLICATE KEY UPDATE c=t1.c+100; +SELECT * FROM t1; +a b c +1 2 10 +3 4 120 +5 6 30 +8 9 60 +INSERT t1 SET a=5 ON DUPLICATE KEY UPDATE b=0; +SELECT * FROM t1; +a b c +1 2 10 +3 4 120 +5 0 30 +8 9 60 +INSERT t1 SELECT a,b,c FROM t2 WHERE d=2 ON DUPLICATE KEY UPDATE c=c+VALUES(a); +ERROR 23000: Column 'c' in field list is ambiguous +INSERT t1 SELECT a,b,c FROM t2 WHERE d=2 ON DUPLICATE KEY UPDATE c=t1.c+VALUES(t1.a); +Warnings: +Warning 1287 'VALUES function' is deprecated and will be removed in a future release. Please use an alias (INSERT INTO ... VALUES (...) AS alias) and replace VALUES(col) in the ON DUPLICATE KEY UPDATE clause with alias.col instead +SELECT *, VALUES(a) FROM t1; +a b c VALUES(a) +1 2 10 NULL +3 4 127 NULL +5 0 30 NULL +8 9 60 NULL +2 1 11 NULL +Warnings: +Warning 1681 'VALUES function' is deprecated and will be removed in a future release. +DROP TABLE t1; +DROP TABLE t2; +CREATE TABLE t1 +( +a BIGINT UNSIGNED, +b BIGINT UNSIGNED, +PRIMARY KEY (a) +); +INSERT INTO t1 VALUES (45, 1) ON DUPLICATE KEY UPDATE b = +IF(VALUES(b) > t1.b, VALUES(b), t1.b); +Warnings: +Warning 1287 'VALUES function' is deprecated and will be removed in a future release. Please use an alias (INSERT INTO ... VALUES (...) AS alias) and replace VALUES(col) in the ON DUPLICATE KEY UPDATE clause with alias.col instead +Warning 1287 'VALUES function' is deprecated and will be removed in a future release. Please use an alias (INSERT INTO ... VALUES (...) AS alias) and replace VALUES(col) in the ON DUPLICATE KEY UPDATE clause with alias.col instead +SELECT * FROM t1; +a b +45 1 +INSERT INTO t1 VALUES (45, 2) ON DUPLICATE KEY UPDATE b = +IF(VALUES(b) > t1.b, VALUES(b), t1.b); +Warnings: +Warning 1287 'VALUES function' is deprecated and will be removed in a future release. Please use an alias (INSERT INTO ... VALUES (...) AS alias) and replace VALUES(col) in the ON DUPLICATE KEY UPDATE clause with alias.col instead +Warning 1287 'VALUES function' is deprecated and will be removed in a future release. Please use an alias (INSERT INTO ... VALUES (...) AS alias) and replace VALUES(col) in the ON DUPLICATE KEY UPDATE clause with alias.col instead +SELECT * FROM t1; +a b +45 2 +INSERT INTO t1 VALUES (45, 1) ON DUPLICATE KEY UPDATE b = +IF(VALUES(b) > t1.b, VALUES(b), t1.b); +Warnings: +Warning 1287 'VALUES function' is deprecated and will be removed in a future release. Please use an alias (INSERT INTO ... VALUES (...) AS alias) and replace VALUES(col) in the ON DUPLICATE KEY UPDATE clause with alias.col instead +Warning 1287 'VALUES function' is deprecated and will be removed in a future release. Please use an alias (INSERT INTO ... VALUES (...) AS alias) and replace VALUES(col) in the ON DUPLICATE KEY UPDATE clause with alias.col instead +SELECT * FROM t1; +a b +45 2 +DROP TABLE t1; +CREATE TABLE t1 (i INT PRIMARY KEY, j INT); +INSERT INTO t1 SELECT 1, j; +ERROR 42S22: Unknown column 'j' in 'field list' +DROP TABLE t1; +CREATE TABLE t1 (i INT PRIMARY KEY, j INT); +CREATE TABLE t2 (a INT, b INT); +CREATE TABLE t3 (a INT, c INT); +INSERT INTO t1 SELECT 1, a FROM t2 NATURAL JOIN t3 +ON DUPLICATE KEY UPDATE j= a; +DROP TABLE t1,t2,t3; +CREATE TABLE t1 (i INT PRIMARY KEY, j INT); +CREATE TABLE t2 (a INT); +INSERT INTO t1 VALUES (1, 1); +INSERT INTO t2 VALUES (1), (3); +INSERT INTO t1 SELECT 1, COUNT(*) FROM t2 ON DUPLICATE KEY UPDATE j= a; +ERROR 42S22: Unknown column 'a' in 'field list' +DROP TABLE t1,t2; +SET SQL_MODE = 'TRADITIONAL'; +CREATE TABLE t1 (a INT PRIMARY KEY, b INT NOT NULL); +INSERT INTO t1 (a) VALUES (1); +ERROR HY000: Field 'b' doesn't have a default value +INSERT INTO t1 (a) VALUES (1) ON DUPLICATE KEY UPDATE a = b; +ERROR HY000: Field 'b' doesn't have a default value +INSERT INTO t1 (a) VALUES (1) ON DUPLICATE KEY UPDATE b = b; +ERROR HY000: Field 'b' doesn't have a default value +SELECT * FROM t1; +a b +DROP TABLE t1; +CREATE TABLE t1 (f1 INT AUTO_INCREMENT PRIMARY KEY, +f2 VARCHAR(5) NOT NULL UNIQUE); +INSERT t1 (f2) VALUES ('test') ON DUPLICATE KEY UPDATE f1 = LAST_INSERT_ID(f1); +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +1 +INSERT t1 (f2) VALUES ('test') ON DUPLICATE KEY UPDATE f1 = LAST_INSERT_ID(f1); +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +1 +DROP TABLE t1; +SET SQL_MODE='NO_AUTO_VALUE_ON_ZERO'; +CREATE TABLE `t1` ( +`id` int(11) PRIMARY KEY auto_increment, +`f1` varchar(10) NOT NULL UNIQUE, +tim1 timestamp default '2003-01-01 00:00:00' on update current_timestamp +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 (f1) VALUES ("test1"); +SELECT id, f1 FROM t1; +id f1 +1 test1 +REPLACE INTO t1 VALUES (0,"test1",null); +SELECT id, f1 FROM t1; +id f1 +0 test1 +DROP TABLE t1; +SET SQL_MODE=''; +CREATE TABLE t1 ( +id INT AUTO_INCREMENT PRIMARY KEY, +c1 CHAR(1) UNIQUE KEY, +cnt INT DEFAULT 1 +); +INSERT INTO t1 (c1) VALUES ('A'), ('B'), ('C'); +SELECT * FROM t1; +id c1 cnt +1 A 1 +2 B 1 +3 C 1 +INSERT INTO t1 (c1) VALUES ('A'), ('X'), ('Y'), ('Z') +ON DUPLICATE KEY UPDATE cnt=cnt+1; +SELECT * FROM t1; +id c1 cnt +1 A 2 +2 B 1 +3 C 1 +4 X 1 +5 Y 1 +6 Z 1 +DROP TABLE t1; +CREATE TABLE t1 ( +id INT AUTO_INCREMENT PRIMARY KEY, +c1 INT NOT NULL, +cnt INT DEFAULT 1 +); +INSERT INTO t1 (id,c1) VALUES (1,10); +SELECT * FROM t1; +id c1 cnt +1 10 1 +CREATE TABLE t2 (id INT, c1 INT); +INSERT INTO t2 VALUES (1,NULL), (2,2); +INSERT INTO t1 (id,c1) SELECT 1,NULL +ON DUPLICATE KEY UPDATE c1=NULL; +ERROR 23000: Column 'c1' cannot be null +SELECT * FROM t1; +id c1 cnt +1 10 1 +INSERT IGNORE INTO t1 (id,c1) SELECT 1,NULL +ON DUPLICATE KEY UPDATE c1=NULL, cnt=cnt+1; +Warnings: +Warning 1048 Column 'c1' cannot be null +Warning 1048 Column 'c1' cannot be null +SELECT * FROM t1; +id c1 cnt +1 0 2 +INSERT IGNORE INTO t1 (id,c1) SELECT * FROM t2 +ON DUPLICATE KEY UPDATE c1=NULL, cnt=cnt+1; +Warnings: +Warning 1048 Column 'c1' cannot be null +Warning 1048 Column 'c1' cannot be null +SELECT * FROM t1; +id c1 cnt +1 0 3 +2 2 1 +DROP TABLE t1; +DROP TABLE t2; +create table t1(f1 int primary key, +f2 timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP); +insert into t1(f1) values(1); +select @stamp1:=f2 from t1; +@stamp1:=f2 +# +Warnings: +# 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +insert into t1(f1) values(1) on duplicate key update f1=1; +select @stamp2:=f2 from t1; +@stamp2:=f2 +# +Warnings: +# 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +select if( @stamp1 = @stamp2, "correct", "wrong"); +if( @stamp1 = @stamp2, "correct", "wrong") +correct +drop table t1; +# Bug 21774967: MYSQL ACCEPTS NON-ASCII IN ASCII COLUMNS +CREATE TABLE t1( +a CHAR(20) CHARACTER SET ascii, +b VARCHAR(20) CHARACTER SET ascii, +c TEXT(20) CHARACTER SET ascii +); +CREATE TABLE t2( +a CHAR(20) CHARACTER SET ascii COLLATE ascii_general_ci, +b VARCHAR(20) CHARACTER SET ascii COLLATE ascii_general_ci, +c TEXT(20) CHARACTER SET ascii COLLATE ascii_general_ci +); +CREATE TABLE t3( +a CHAR(20) CHARACTER SET ascii COLLATE ascii_bin, +b VARCHAR(20) CHARACTER SET ascii COLLATE ascii_bin, +c TEXT(20) CHARACTER SET ascii COLLATE ascii_bin +); +SET SQL_MODE="STRICT_TRANS_TABLES"; +Warnings: +Warning 3135 'NO_ZERO_DATE', 'NO_ZERO_IN_DATE' and 'ERROR_FOR_DIVISION_BY_ZERO' sql modes should be used with strict mode. They will be merged with strict mode in a future release. +INSERT INTO t1 values(x'8142', x'8142', x'8142'); +ERROR HY000: Incorrect string value: '\x81B' for column 'a' at row 1 +INSERT INTO t1 values(x'6162', x'6162', x'6162'); +UPDATE t1 SET a=x'8243' where a=x'6162'; +ERROR HY000: Incorrect string value: '\x82C' for column 'a' at row 1 +INSERT INTO t2 values(x'8142', x'8142', x'8142'); +ERROR HY000: Incorrect string value: '\x81B' for column 'a' at row 1 +INSERT INTO t2 values(x'6162', x'6162', x'6162'); +UPDATE t2 SET a=x'8243' where a=x'6162'; +ERROR HY000: Incorrect string value: '\x82C' for column 'a' at row 1 +INSERT INTO t3 values(x'8142', x'8142', x'8142'); +ERROR HY000: Incorrect string value: '\x81B' for column 'a' at row 1 +INSERT INTO t3 values(x'6162', x'6162', x'6162'); +UPDATE t3 SET a=x'8243' where a=x'6162'; +ERROR HY000: Incorrect string value: '\x82C' for column 'a' at row 1 +SET SQL_MODE=""; +INSERT INTO t1 values(x'8142', x'8142', x'8142'); +Warnings: +Warning 1366 Incorrect string value: '\x81B' for column 'a' at row 1 +Warning 1366 Incorrect string value: '\x81B' for column 'b' at row 1 +Warning 1366 Incorrect string value: '\x81B' for column 'c' at row 1 +INSERT INTO t1 values(x'6162', x'6162', x'6162'); +UPDATE t1 SET a=x'8243' where a=x'6162'; +Warnings: +Warning 1366 Incorrect string value: '\x82C' for column 'a' at row 1 +Warning 1366 Incorrect string value: '\x82C' for column 'a' at row 3 +INSERT INTO t2 values(x'8142', x'8142', x'8142'); +Warnings: +Warning 1366 Incorrect string value: '\x81B' for column 'a' at row 1 +Warning 1366 Incorrect string value: '\x81B' for column 'b' at row 1 +Warning 1366 Incorrect string value: '\x81B' for column 'c' at row 1 +INSERT INTO t2 values(x'6162', x'6162', x'6162'); +UPDATE t2 SET a=x'8243' where a=x'6162'; +Warnings: +Warning 1366 Incorrect string value: '\x82C' for column 'a' at row 1 +Warning 1366 Incorrect string value: '\x82C' for column 'a' at row 3 +INSERT INTO t3 values(x'8142', x'8142', x'8142'); +Warnings: +Warning 1366 Incorrect string value: '\x81B' for column 'a' at row 1 +Warning 1366 Incorrect string value: '\x81B' for column 'b' at row 1 +Warning 1366 Incorrect string value: '\x81B' for column 'c' at row 1 +INSERT INTO t3 values(x'6162', x'6162', x'6162'); +UPDATE t3 SET a=x'8243' where a=x'6162'; +Warnings: +Warning 1366 Incorrect string value: '\x82C' for column 'a' at row 1 +Warning 1366 Incorrect string value: '\x82C' for column 'a' at row 3 +CREATE VIEW v1 AS SELECT * FROM t1; +CREATE VIEW v2 AS SELECT * FROM t2; +CREATE VIEW v3 AS SELECT * FROM t3; +SET SQL_MODE="STRICT_TRANS_TABLES"; +Warnings: +Warning 3135 'NO_ZERO_DATE', 'NO_ZERO_IN_DATE' and 'ERROR_FOR_DIVISION_BY_ZERO' sql modes should be used with strict mode. They will be merged with strict mode in a future release. +INSERT INTO v1 values(x'8142', x'8142', x'8142'); +ERROR HY000: Incorrect string value: '\x81B' for column 'a' at row 1 +INSERT INTO v1 values(x'6162', x'6162', x'6162'); +UPDATE v1 SET a=x'8243' where a=x'6162'; +ERROR HY000: Incorrect string value: '\x82C' for column 'a' at row 4 +INSERT INTO v2 values(x'8142', x'8142', x'8142'); +ERROR HY000: Incorrect string value: '\x81B' for column 'a' at row 1 +INSERT INTO v2 values(x'6162', x'6162', x'6162'); +UPDATE v2 SET a=x'8243' where a=x'6162'; +ERROR HY000: Incorrect string value: '\x82C' for column 'a' at row 4 +INSERT INTO v3 values(x'8142', x'8142', x'8142'); +ERROR HY000: Incorrect string value: '\x81B' for column 'a' at row 1 +INSERT INTO v3 values(x'6162', x'6162', x'6162'); +UPDATE v3 SET a=x'8243' where a=x'6162'; +ERROR HY000: Incorrect string value: '\x82C' for column 'a' at row 4 +SET SQL_MODE=""; +INSERT INTO v1 values(x'8142', x'8142', x'8142'); +Warnings: +Warning 1366 Incorrect string value: '\x81B' for column 'a' at row 1 +Warning 1366 Incorrect string value: '\x81B' for column 'b' at row 1 +Warning 1366 Incorrect string value: '\x81B' for column 'c' at row 1 +INSERT INTO v1 values(x'6162', x'6162', x'6162'); +UPDATE v1 SET a=x'8243' where a=x'6162'; +Warnings: +Warning 1366 Incorrect string value: '\x82C' for column 'a' at row 4 +Warning 1366 Incorrect string value: '\x82C' for column 'a' at row 6 +INSERT INTO v2 values(x'8142', x'8142', x'8142'); +Warnings: +Warning 1366 Incorrect string value: '\x81B' for column 'a' at row 1 +Warning 1366 Incorrect string value: '\x81B' for column 'b' at row 1 +Warning 1366 Incorrect string value: '\x81B' for column 'c' at row 1 +INSERT INTO v2 values(x'6162', x'6162', x'6162'); +UPDATE v2 SET a=x'8243' where a=x'6162'; +Warnings: +Warning 1366 Incorrect string value: '\x82C' for column 'a' at row 4 +Warning 1366 Incorrect string value: '\x82C' for column 'a' at row 6 +INSERT INTO v3 values(x'8142', x'8142', x'8142'); +Warnings: +Warning 1366 Incorrect string value: '\x81B' for column 'a' at row 1 +Warning 1366 Incorrect string value: '\x81B' for column 'b' at row 1 +Warning 1366 Incorrect string value: '\x81B' for column 'c' at row 1 +INSERT INTO v3 values(x'6162', x'6162', x'6162'); +UPDATE v3 SET a=x'8243' where a=x'6162'; +Warnings: +Warning 1366 Incorrect string value: '\x82C' for column 'a' at row 4 +Warning 1366 Incorrect string value: '\x82C' for column 'a' at row 6 +DROP VIEW v1; +DROP VIEW v2; +DROP VIEW v3; +DROP TABLE t1; +DROP TABLE t2; +DROP TABLE t3; +CREATE TABLE t_latin1( +a CHAR(20) CHARACTER SET latin1, +b VARCHAR(20) CHARACTER SET latin1, +c TEXT(20) CHARACTER SET latin1 +); +CREATE TABLE t_gb2312( +a CHAR(20) CHARACTER SET gb2312, +b VARCHAR(20) CHARACTER SET gb2312, +c TEXT(20) CHARACTER SET gb2312 +); +CREATE TABLE t_utf8( +a CHAR(20) CHARACTER SET utf8, +b VARCHAR(20) CHARACTER SET utf8, +c TEXT(20) CHARACTER SET utf8 +); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +SET SQL_MODE="STRICT_TRANS_TABLES"; +Warnings: +Warning 3135 'NO_ZERO_DATE', 'NO_ZERO_IN_DATE' and 'ERROR_FOR_DIVISION_BY_ZERO' sql modes should be used with strict mode. They will be merged with strict mode in a future release. +INSERT INTO t_latin1 values(x'f242', x'f242', x'f242'); +UPDATE t_latin1 SET a=x'f343' where a=x'f242'; +INSERT INTO t_gb2312 values(x'e5ac', x'e5ac', x'e5ac'); +UPDATE t_gb2312 SET a=x'e6af' where a=x'e5ac'; +INSERT INTO t_utf8 values(x'e4b8ad', x'e4b8ad', x'e4b8ad'); +INSERT INTO t_utf8 values(x'f4b8ad', x'f4b8ad', x'f4b8ad'); +ERROR HY000: Incorrect string value: '\xF4\xB8\xAD' for column 'a' at row 1 +UPDATE t_utf8 SET a=x'e69687' where a=x'e4b8ad'; +UPDATE t_utf8 SET a=x'f69687' where a=x'e69687'; +ERROR HY000: Incorrect string value: '\xF6\x96\x87' for column 'a' at row 1 +SET SQL_MODE=""; +INSERT INTO t_latin1 values(x'f242', x'f242', x'f242'); +UPDATE t_latin1 SET a=x'f343' where a=x'f242'; +INSERT INTO t_gb2312 values(x'e5ac', x'e5ac', x'e5ac'); +UPDATE t_gb2312 SET a=x'e6af' where a=x'e5ac'; +INSERT INTO t_utf8 values(x'e4b8ad', x'e4b8ad', x'e4b8ad'); +INSERT INTO t_utf8 values(x'f4b8ad', x'f4b8ad', x'f4b8ad'); +Warnings: +Warning 1366 Incorrect string value: '\xF4\xB8\xAD' for column 'a' at row 1 +Warning 1366 Incorrect string value: '\xF4\xB8\xAD' for column 'b' at row 1 +Warning 1366 Incorrect string value: '\xF4\xB8\xAD' for column 'c' at row 1 +UPDATE t_utf8 SET a=x'e69687' where a=x'e4b8ad'; +UPDATE t_utf8 SET a=x'f69687' where a=x'e69687'; +Warnings: +Warning 1366 Incorrect string value: '\xF6\x96\x87' for column 'a' at row 1 +Warning 1366 Incorrect string value: '\xF6\x96\x87' for column 'a' at row 2 +CREATE VIEW v_latin1 AS SELECT * FROM t_latin1; +CREATE VIEW v_gb2312 AS SELECT * FROM t_gb2312; +CREATE VIEW v_utf8 AS SELECT * FROM t_utf8; +SET SQL_MODE="STRICT_TRANS_TABLES"; +Warnings: +Warning 3135 'NO_ZERO_DATE', 'NO_ZERO_IN_DATE' and 'ERROR_FOR_DIVISION_BY_ZERO' sql modes should be used with strict mode. They will be merged with strict mode in a future release. +INSERT INTO v_latin1 values(x'f242', x'f242', x'f242'); +UPDATE v_latin1 SET a=x'f343' where a=x'f242'; +INSERT INTO v_gb2312 values(x'e5ac', x'e5ac', x'e5ac'); +UPDATE v_gb2312 SET a=x'e6af' where a=x'e5ac'; +INSERT INTO v_utf8 values(x'e4b8ad', x'e4b8ad', x'e4b8ad'); +INSERT INTO v_utf8 values(x'f4b8ad', x'f4b8ad', x'f4b8ad'); +ERROR HY000: Incorrect string value: '\xF4\xB8\xAD' for column 'a' at row 1 +UPDATE v_utf8 SET a=x'e69687' where a=x'e4b8ad'; +UPDATE v_utf8 SET a=x'f69687' where a=x'e69687'; +ERROR HY000: Incorrect string value: '\xF6\x96\x87' for column 'a' at row 4 +SET SQL_MODE=""; +INSERT INTO v_latin1 values(x'f242', x'f242', x'f242'); +UPDATE v_latin1 SET a=x'f343' where a=x'f242'; +INSERT INTO v_gb2312 values(x'e5ac', x'e5ac', x'e5ac'); +UPDATE v_gb2312 SET a=x'e6af' where a=x'e5ac'; +INSERT INTO v_utf8 values(x'e4b8ad', x'e4b8ad', x'e4b8ad'); +INSERT INTO v_utf8 values(x'f4b8ad', x'f4b8ad', x'f4b8ad'); +Warnings: +Warning 1366 Incorrect string value: '\xF4\xB8\xAD' for column 'a' at row 1 +Warning 1366 Incorrect string value: '\xF4\xB8\xAD' for column 'b' at row 1 +Warning 1366 Incorrect string value: '\xF4\xB8\xAD' for column 'c' at row 1 +UPDATE v_utf8 SET a=x'e69687' where a=x'e4b8ad'; +UPDATE v_utf8 SET a=x'f69687' where a=x'e69687'; +Warnings: +Warning 1366 Incorrect string value: '\xF6\x96\x87' for column 'a' at row 4 +Warning 1366 Incorrect string value: '\xF6\x96\x87' for column 'a' at row 5 +DROP VIEW v_latin1; +DROP VIEW v_gb2312; +DROP VIEW v_utf8; +DROP TABLE t_latin1; +DROP TABLE t_gb2312; +DROP TABLE t_utf8; +SET SQL_MODE=DEFAULT; +# WL#5094: Refactor DML statements +# Semantic changes in INSERT ... ON DUPLICATE KEY +CREATE TABLE t0 (k INTEGER PRIMARY KEY); +CREATE TABLE t1(a INTEGER); +CREATE TABLE t2(a INTEGER); +INSERT INTO t1 VALUES (1), (2); +INSERT INTO t2 VALUES (1), (3); +INSERT INTO t0 SELECT a FROM t1 UNION SELECT a FROM t2; +# Allowed: Reference column from a single table +INSERT INTO t0 +SELECT a FROM t1 +ON DUPLICATE KEY UPDATE k= a + t1.a + 10; +SELECT * FROM t0; +k +3 +12 +14 +DELETE FROM t0; +INSERT INTO t0 SELECT a FROM t1 UNION SELECT a FROM t2; +# Allowed: Reference column from a join over multiple tables +INSERT INTO t0 +SELECT t1.a FROM t1 JOIN t2 ON t1.a=t2.a +ON DUPLICATE KEY UPDATE k= t1.a + t2.a + 10; +SELECT * FROM t0; +k +2 +3 +12 +DELETE FROM t0; +INSERT INTO t0 SELECT a FROM t1 UNION SELECT a FROM t2; +INSERT INTO t0 +SELECT a FROM t1 JOIN t2 USING (a) +ON DUPLICATE KEY UPDATE k= t1.a + t2.a + 10; +SELECT * FROM t0; +k +2 +3 +12 +DELETE FROM t0; +INSERT INTO t0 SELECT a FROM t1 UNION SELECT a FROM t2; +INSERT INTO t0 +SELECT a FROM t1 LEFT JOIN t2 USING (a) +ON DUPLICATE KEY UPDATE k= a + 10; +SELECT * FROM t0; +k +3 +11 +12 +DELETE FROM t0; +INSERT INTO t0 SELECT a FROM t1 UNION SELECT a FROM t2; +INSERT INTO t0 +SELECT DISTINCT a FROM t1 +ON DUPLICATE KEY UPDATE k= a + 10; +SELECT * FROM t0; +k +3 +11 +12 +DELETE FROM t0; +INSERT INTO t0 SELECT a FROM t1 UNION SELECT a FROM t2; +# Allowed: Wrap a distinct query in a derived table +INSERT INTO t0 +SELECT a FROM (SELECT DISTINCT a FROM t1) AS dt +ON DUPLICATE KEY UPDATE k= a + 10; +SELECT * FROM t0; +k +3 +11 +12 +DELETE FROM t0; +INSERT INTO t0 SELECT a FROM t1 UNION SELECT a FROM t2; +# Not allowed: Reference column from an explicitly grouped query +INSERT INTO t0 +SELECT a FROM t1 GROUP BY a +ON DUPLICATE KEY UPDATE k= a + 10; +ERROR 42S22: Unknown column 'a' in 'field list' +# Not allowed: Reference column from an implicitly grouped query +INSERT INTO t0 +SELECT SUM(a) FROM t1 +ON DUPLICATE KEY UPDATE k= a + 10; +ERROR 42S22: Unknown column 'a' in 'field list' +# Allowed: Wrap a grouped query in a derived table +INSERT INTO t0 +SELECT a FROM (SELECT a FROM t1 GROUP BY a) AS dt +ON DUPLICATE KEY UPDATE k= a + 10; +SELECT * FROM t0; +k +3 +11 +12 +DELETE FROM t0; +INSERT INTO t0 SELECT a FROM t1 UNION SELECT a FROM t2; +# Not allowed: Reference column from a UNION query +INSERT INTO t0 +SELECT a FROM t1 UNION SELECT a FROM t2 +ON DUPLICATE KEY UPDATE k= a + 10; +ERROR 42S22: Unknown column 'a' in 'field list' +# Allowed:: Wrap a UNION query in a derived table +INSERT INTO t0 +SELECT a +FROM (SELECT a, COUNT(*) AS c FROM t1 GROUP BY a +UNION +SELECT a, COUNT(*) AS c FROM t2 GROUP BY a) AS dt +ON DUPLICATE KEY UPDATE k= dt.a + dt.c + 10; +SELECT * FROM t0; +k +12 +13 +14 +DELETE FROM t0; +INSERT INTO t0 SELECT a FROM t1 UNION SELECT a FROM t2; +DROP TABLE t0, t1, t2; +# Bug#25526439: Assertion failed: is_fixed_or_outer_ref(this) +CREATE TABLE t1 ( +a INTEGER NOT NULL +); +INSERT INTO t1 VALUES(0); +CREATE TABLE t2 ( +d INTEGER +); +# Query from bug report +INSERT INTO t1(a) VALUES (1) +ON DUPLICATE KEY UPDATE a= (SELECT d FROM t2 GROUP BY 1); +SELECT * FROM t1; +a +0 +1 +# Similar query with a simple query block +INSERT INTO t1(a) SELECT 1 +ON DUPLICATE KEY UPDATE a= (SELECT d FROM t2 GROUP BY 1); +SELECT * FROM t1; +a +0 +1 +1 +# Similar query with a UNION +INSERT INTO t1(a) SELECT 1 UNION SELECT 2 +ON DUPLICATE KEY UPDATE a= (SELECT d FROM t2 GROUP BY 1); +SELECT * FROM t1; +a +0 +1 +1 +1 +2 +DROP TABLE t1, t2; +# Bug#25071305: Assertion failed: first_execution || +# !tl->is_view_or_derived() || tl->is_merged() +CREATE TABLE t1(a INTEGER); +CREATE TABLE t2(b INTEGER); +INSERT INTO t2 VALUES (1),(1); +INSERT INTO t1(a) VALUES (1) +ON DUPLICATE KEY UPDATE a= (SELECT b FROM (SELECT b FROM t2) AS w); +DROP TABLE t1, t2; +# Bug#24716127: Incorrect behavior by insert statement with +# "on duplicate key update" +CREATE TABLE t1(a INTEGER, b INTEGER, PRIMARY KEY(a,b)); +CREATE TABLE t2(c2 INTEGER NOT NULL PRIMARY KEY); +CREATE TABLE t3(c3 INTEGER NOT NULL PRIMARY KEY); +INSERT INTO t1 VALUES (1, 1); +INSERT INTO t2 VALUES (1), (2); +INSERT INTO t3 VALUES (1), (2); +INSERT INTO t1 VALUES (1,1) +ON DUPLICATE KEY UPDATE a= (SELECT c2 +FROM t2 JOIN t3 ON c3 = c2 +WHERE c2 = 1); +SELECT * FROM t1; +a b +1 1 +INSERT INTO t1 +SELECT 1, 1 FROM t2 +ON DUPLICATE KEY UPDATE a= t2.c2 + 100, b= t2.c2 + 100; +SELECT * FROM t1; +a b +1 1 +101 101 +DROP TABLE t1, t2, t3; +# +# Bug#28995498 INSERT IS FINE BUT "ON DUPLICATE UPDATE" UPDATING WRONG DATA +# +CREATE TABLE t1 (pk VARCHAR(10) PRIMARY KEY, col VARCHAR(10)); +INSERT INTO t1 VALUES (1 , "Carmen" ),(2 , "Martin" ); +INSERT INTO t1 SELECT * FROM t1 AS source +ON DUPLICATE KEY UPDATE t1.col = source.col; +SELECT * FROM t1 ; +pk col +1 Carmen +2 Martin +DROP TABLE t1; +# WL#6312: Referencing new row in INSERT .. VALUES .. ON DUPLICATE KEY UPDATE. +CREATE TABLE t0(a INT PRIMARY KEY, b INT); +CREATE TABLE t1(x INT PRIMARY KEY, y INT); +# Allowed: Referencing VALUES from the update list. +INSERT INTO t0 VALUES (1, 3), (2, 3) AS n(a, b) +ON DUPLICATE KEY UPDATE b= t0.b + n.b; +SELECT * FROM t0; +a b +1 3 +2 3 +INSERT INTO t0 VALUES (1, 3), (2, 3) AS n(a, b) +ON DUPLICATE KEY UPDATE b= t0.b + n.b; +SELECT * FROM t0; +a b +1 6 +2 6 +# Allowed: Not naming columns for VALUES table. +INSERT INTO t0 VALUES (1, 5), (2, 7) AS n +ON DUPLICATE KEY UPDATE b= t0.b + n.b; +SELECT * FROM t0; +a b +1 11 +2 13 +# Not allowed: Naming the VALUES table the same as the table inserted into. +INSERT INTO t0 VALUES (1, 5), (2, 7) AS t0 +ON DUPLICATE KEY UPDATE b= t0.a; +ERROR 42000: Not unique table/alias: 't0' +# Not allowed: Naming multiple VALUES columns the same. +INSERT INTO t0 VALUES (1, 5), (2, 7) AS n(a, a) +ON DUPLICATE KEY UPDATE b= t0.a; +ERROR 42S21: Duplicate column name 'a' +# Not allowed: Unequal number of columns in VALUES table and inserted rows. +INSERT INTO t0 VALUES (1, 5), (2, 7) AS n(a) +ON DUPLICATE KEY UPDATE b= t0.a; +ERROR HY000: In definition of view, derived table or common table expression, SELECT list and column names list have different column counts +# Allowed: Referencing VALUES table from within a subquery. +INSERT INTO t1 VALUES (1, 50), (2, 100); +INSERT INTO t0 VALUES (1, 10), (2, 20) AS n +ON DUPLICATE KEY UPDATE b= (SELECT y FROM t1 WHERE x = n.a); +SELECT * FROM t0; +a b +1 50 +2 100 +# Allowed: Overriding the VALUES table name from within a subquery. +INSERT INTO t0 VALUES (1, 10) AS n(a, b) +ON DUPLICATE KEY UPDATE b= 20 + (SELECT n.y FROM t1 AS n WHERE n.x = t0.a); +SELECT * FROM t0; +a b +1 70 +2 100 +# Allowed: VALUES table name overriding table names. +CREATE TABLE n(a INT, b INT); +INSERT INTO t0 VALUES (1, 10) AS n(a, b) +ON DUPLICATE KEY UPDATE b= n.b; +SELECT * FROM t0; +a b +1 10 +2 100 +# Allowed: FROM clause in subquery overriding VALUES table name. +INSERT INTO n VALUES (1, 50); +INSERT INTO t0 VALUES (1, 20) AS n(a, b) +ON DUPLICATE KEY UPDATE b= (SELECT n.b FROM n); +SELECT * FROM t0; +a b +1 50 +2 100 +# Allowed: Discrepancy between specified insert columns and column names of VALUES table. +CREATE TABLE t2(a INT, b INT PRIMARY KEY, c INT); +INSERT INTO t2 VALUES (1, 10, 100); +INSERT INTO t2(b, c) VALUES (10, 20) AS n(a, b) +ON DUPLICATE KEY UPDATE c= n.b; +SELECT * FROM t2; +a b c +1 10 20 +# Allowed: Using the «INSERT .. SET» syntax. +DROP TABLE t0; +CREATE TABLE t0(a INT PRIMARY KEY, b INT); +INSERT INTO t0 VALUES (1, 10); +INSERT INTO t0 SET a=1, b=20 AS n +ON DUPLICATE KEY UPDATE b= n.b; +SELECT * FROM t0; +a b +1 20 +# Allowed: Referring to the VALUES table from inside functions. +DROP TABLE t1; +CREATE TABLE t1(a BIGINT UNSIGNED PRIMARY KEY, b BIGINT UNSIGNED); +INSERT INTO t1 VALUES (45, 1) AS n +ON DUPLICATE KEY UPDATE b= IF(n.b > t1.b, n.b, t1.b); +SELECT * FROM t1; +a b +45 1 +INSERT INTO t1 VALUES (45, 2) AS n +ON DUPLICATE KEY UPDATE b= IF(n.b > t1.b, n.b, t1.b); +SELECT * FROM t1; +a b +45 2 +INSERT INTO t1 VALUES (45, 1) AS n +ON DUPLICATE KEY UPDATE b= IF(n.b > t1.b, n.b, t1.b); +SELECT * FROM t1; +a b +45 2 +# Allowed: Using ODKU when inserting into a view. +DROP TABLE t1; +CREATE TABLE t1(a INT PRIMARY KEY DEFAULT 3, b INT); +CREATE VIEW v AS SELECT b FROM t1; +INSERT INTO t1 VALUES(3, 2); +INSERT INTO v VALUES(3) AS n +ON DUPLICATE KEY UPDATE b= n.b; +SELECT * FROM t1; +a b +3 3 +SELECT * FROM v; +b +3 +# Allowed: Creating a VALUES alias with no ODKU statement. +DROP TABLE t1; +CREATE TABLE t1(a INT PRIMARY KEY, b INT); +INSERT INTO t1 VALUES(1, 10) as n; +SELECT * FROM t1; +a b +1 10 +# Not allowed: Referencing the VALUES table inside the VALUES clause. +INSERT INTO t1 VALUES(n.a, 10) as n +ON DUPLICATE KEY UPDATE b= n.b; +ERROR 42S22: Unknown column 'n.a' in 'field list' +# If a table reference within an update expression does not find the +# column in the VALUES table, it should look further in outer contexts. +DROP TABLE n; +CREATE TABLE n(x INT, y INT); +DROP TABLE t0; +CREATE TABLE t0(a INT PRIMARY KEY, b INT); +DELETE FROM t0; +INSERT INTO t0 VALUES(1, 10); +INSERT INTO n VALUES(1, 11); +INSERT INTO t0 VALUES(1, 19) as n(a, b) +ON DUPLICATE KEY UPDATE b= (SELECT n.y FROM n); +SELECT * FROM t0; +a b +1 11 +# Allowed: Referring to the old row of the insert table from within an +# ODKU update expression. +DELETE FROM t0; +INSERT INTO t0 VALUES(1, 10); +INSERT INTO t0 VALUES(2, 20); +INSERT INTO t0 VALUES(2, 29) as n +ON DUPLICATE KEY UPDATE b= t0.b+1; +SELECT * FROM t0; +a b +1 10 +2 21 +DROP TABLE t0; +DROP TABLE t1; +DROP TABLE t2; +DROP TABLE n; +DROP VIEW v; +# WL#6312: Referencing new row in INSERT .. VALUES .. ON DUPLICATE KEY UPDATE. +# Compare old and new syntax (VALUES() vs. AS new) for regressions. +# binlog_unsafe.test. More than one unique key. +# Old syntax. +CREATE TABLE insert_2_keys (a INT UNIQUE KEY, b INT UNIQUE KEY); +INSERT INTO insert_2_keys values (1, 1); +INSERT INTO insert_2_keys VALUES (1, 2) +ON DUPLICATE KEY UPDATE a= VALUES(a) + 10, b= VALUES(b) + 10; +Warnings: +Warning 1287 'VALUES function' is deprecated and will be removed in a future release. Please use an alias (INSERT INTO ... VALUES (...) AS alias) and replace VALUES(col) in the ON DUPLICATE KEY UPDATE clause with alias.col instead +Warning 1287 'VALUES function' is deprecated and will be removed in a future release. Please use an alias (INSERT INTO ... VALUES (...) AS alias) and replace VALUES(col) in the ON DUPLICATE KEY UPDATE clause with alias.col instead +SELECT * FROM insert_2_keys; +a b +11 12 +DROP TABLE insert_2_keys; +# New syntax. +CREATE TABLE insert_2_keys (a INT UNIQUE KEY, b INT UNIQUE KEY); +INSERT INTO insert_2_keys values (1, 1); +INSERT INTO insert_2_keys VALUES (1, 2) AS n +ON DUPLICATE KEY UPDATE a= n.a + 10, b= n.b + 10; +SELECT * FROM insert_2_keys; +a b +11 12 +DROP TABLE insert_2_keys; +# json_functions.inc. JSON should work with INSERT .. ON DUPLICATE KEY UPDATE. +# Old syntax. +CREATE TABLE t(id INT PRIMARY KEY, j JSON); +INSERT INTO t VALUES (1, '[1]') +ON DUPLICATE KEY UPDATE j = JSON_OBJECT("a", VALUES(j)); +Warnings: +Warning 1287 'VALUES function' is deprecated and will be removed in a future release. Please use an alias (INSERT INTO ... VALUES (...) AS alias) and replace VALUES(col) in the ON DUPLICATE KEY UPDATE clause with alias.col instead +SELECT * FROM t; +id j +1 [1] +INSERT INTO t VALUES (1, '[1,2]') +ON DUPLICATE KEY UPDATE j = JSON_OBJECT("ab", VALUES(j)); +Warnings: +Warning 1287 'VALUES function' is deprecated and will be removed in a future release. Please use an alias (INSERT INTO ... VALUES (...) AS alias) and replace VALUES(col) in the ON DUPLICATE KEY UPDATE clause with alias.col instead +SELECT * FROM t; +id j +1 {"ab": [1, 2]} +INSERT INTO t VALUES (1, '[1,2,3]') +ON DUPLICATE KEY UPDATE j = JSON_OBJECT("abc", VALUES(j)); +Warnings: +Warning 1287 'VALUES function' is deprecated and will be removed in a future release. Please use an alias (INSERT INTO ... VALUES (...) AS alias) and replace VALUES(col) in the ON DUPLICATE KEY UPDATE clause with alias.col instead +SELECT * FROM t; +id j +1 {"abc": [1, 2, 3]} +DROP TABLE t; +# New syntax. +CREATE TABLE t(id INT PRIMARY KEY, j JSON); +INSERT INTO t VALUES (1, '[1]') AS n +ON DUPLICATE KEY UPDATE j = JSON_OBJECT("a", n.j); +SELECT * FROM t; +id j +1 [1] +INSERT INTO t VALUES (1, '[1,2]') AS n +ON DUPLICATE KEY UPDATE j = JSON_OBJECT("ab", n.j); +SELECT * FROM t; +id j +1 {"ab": [1, 2]} +INSERT INTO t VALUES (1, '[1,2,3]') AS n +ON DUPLICATE KEY UPDATE j = JSON_OBJECT("abc", n.j); +SELECT * FROM t; +id j +1 {"abc": [1, 2, 3]} +DROP TABLE t; +# errors.test. Subquery with VALUES table reference. +# Old syntax. +CREATE TABLE t1(a INT); +CREATE TABLE t2(a INT PRIMARY KEY, b INT); +INSERT INTO t1 VALUES (10); +INSERT INTO t2(a, b) VALUES (1, 0); +INSERT INTO t2(a, b) VALUES (1, 0) +ON DUPLICATE KEY UPDATE b= (SELECT VALUES(a) + 2 FROM t1); +Warnings: +Warning 1287 The VALUES function is deprecated and will be removed in a future release. It always returns NULL in this context. If you meant to access a value from the VALUES clause of the INSERT statement, consider using an alias (INSERT INTO ... VALUES (...) AS alias) and reference alias.col instead of VALUES(col) in the ON DUPLICATE KEY UPDATE clause. +SELECT * FROM t2; +a b +1 NULL +DROP TABLE t1; +DROP TABLE t2; +# New syntax. +CREATE TABLE t1 (a INT); +CREATE TABLE t2(a INT PRIMARY KEY, b INT); +INSERT INTO t1 VALUES (10); +INSERT INTO t2(a, b) VALUES (1, 0); +INSERT INTO t2(a, b) VALUES (1, 0) AS n +ON DUPLICATE KEY UPDATE b= (SELECT n.a + 2 FROM t1); +SELECT * FROM t2; +a b +1 3 +DROP TABLE t1; +DROP TABLE t2; +# func_test.test. New syntax should work inside functions. +# Old syntax. +CREATE TABLE t1(a INT PRIMARY KEY, b INT); +INSERT INTO t1 VALUES (1, 2); +INSERT INTO t1 VALUES (1, 3) +ON DUPLICATE KEY UPDATE b= GREATEST(b, VALUES(b)); +Warnings: +Warning 1287 'VALUES function' is deprecated and will be removed in a future release. Please use an alias (INSERT INTO ... VALUES (...) AS alias) and replace VALUES(col) in the ON DUPLICATE KEY UPDATE clause with alias.col instead +SELECT * FROM t1; +a b +1 3 +DROP TABLE t1; +# New syntax. +CREATE TABLE t1(a INT PRIMARY KEY, b INT); +INSERT INTO t1 VALUES (1, 2); +INSERT INTO t1 VALUES (1, 3) AS n +ON DUPLICATE KEY UPDATE b= GREATEST(t1.b, n.b); +SELECT * FROM t1; +a b +1 3 +DROP TABLE t1; +# type_blob-bug13901905_myisam.test. INSERT .. SET syntax should work with blobs. +# Old syntax. +CREATE TABLE t1 (a INT, b BLOB, UNIQUE KEY(a)); +INSERT INTO t1 SET b='11', a=0 +ON DUPLICATE KEY UPDATE b= VALUES(a), a= values(b); +Warnings: +Warning 1287 'VALUES function' is deprecated and will be removed in a future release. Please use an alias (INSERT INTO ... VALUES (...) AS alias) and replace VALUES(col) in the ON DUPLICATE KEY UPDATE clause with alias.col instead +Warning 1287 'VALUES function' is deprecated and will be removed in a future release. Please use an alias (INSERT INTO ... VALUES (...) AS alias) and replace VALUES(col) in the ON DUPLICATE KEY UPDATE clause with alias.col instead +INSERT INTO t1 SET b='11', a=0 +ON DUPLICATE KEY UPDATE b= VALUES(a), a= values(b); +Warnings: +Warning 1287 'VALUES function' is deprecated and will be removed in a future release. Please use an alias (INSERT INTO ... VALUES (...) AS alias) and replace VALUES(col) in the ON DUPLICATE KEY UPDATE clause with alias.col instead +Warning 1287 'VALUES function' is deprecated and will be removed in a future release. Please use an alias (INSERT INTO ... VALUES (...) AS alias) and replace VALUES(col) in the ON DUPLICATE KEY UPDATE clause with alias.col instead +SELECT * FROM t1; +a b +11 0 +DROP TABLE t1; +# New syntax +CREATE TABLE t1 (a INT, b BLOB, UNIQUE KEY(a)); +INSERT INTO t1 SET b='11', a=0 AS n +ON DUPLICATE KEY UPDATE b= n.a, a= n.b; +INSERT INTO t1 SET b='11', a=0 AS n +ON DUPLICATE KEY UPDATE b= n.a, a= n.b; +SELECT * FROM t1; +a b +11 0 +DROP TABLE t1; +# insert-bug25361251.test. Text fields should work. +# Old syntax. +CREATE TABLE t1(id INT NOT NULL, text1 TEXT, text2 TEXT, PRIMARY KEY (id)); +INSERT INTO t1 VALUES (0, "x", "x"), (1, "y", "y"); +INSERT INTO t1 (id, text1, text2) VALUES (0, "x", "y") +ON DUPLICATE KEY UPDATE text1 = VALUES(text1), text2 = VALUES(text2); +Warnings: +Warning 1287 'VALUES function' is deprecated and will be removed in a future release. Please use an alias (INSERT INTO ... VALUES (...) AS alias) and replace VALUES(col) in the ON DUPLICATE KEY UPDATE clause with alias.col instead +Warning 1287 'VALUES function' is deprecated and will be removed in a future release. Please use an alias (INSERT INTO ... VALUES (...) AS alias) and replace VALUES(col) in the ON DUPLICATE KEY UPDATE clause with alias.col instead +SELECT * FROM t1; +id text1 text2 +0 x y +1 y y +DROP TABLE t1; +# New syntax. +CREATE TABLE t1(id INT NOT NULL, text1 TEXT, text2 TEXT, PRIMARY KEY (id)); +INSERT INTO t1 VALUES (0, "x", "x"), (1, "y", "y"); +INSERT INTO t1 (id, text1, text2) VALUES (0, "x", "y") AS n +ON DUPLICATE KEY UPDATE text1 = n.text1, text2 = n.text2; +SELECT * FROM t1; +id text1 text2 +0 x y +1 y y +DROP TABLE t1; +# Bug#30051303: SERVER CRASHED WHILE RUNNING INSERT ON DUPLICATE KEY +# UPDATE OVER VIEW +CREATE TABLE t0(a INT PRIMARY KEY, b INT, c INT); +CREATE VIEW v AS SELECT t0.a AS va, t0.b AS vb, t0.c AS vc FROM t0; +INSERT INTO v(va, vb, vc) VALUES(1, 10, 100) AS n +ON DUPLICATE KEY UPDATE vc= 199; +SELECT * FROM t0; +a b c +1 10 100 +DROP TABLE t0; +DROP VIEW v; diff --git a/mysql-test/r/invisible_indexes.result-pq b/mysql-test/r/invisible_indexes.result-pq new file mode 100644 index 000000000000..d2a20aa7426f --- /dev/null +++ b/mysql-test/r/invisible_indexes.result-pq @@ -0,0 +1,600 @@ +# +# WL#8697: Invisible Indexes +# +SET SESSION information_schema_stats_expiry=0; +# Test of ALTER INDEX syntax. +CREATE TABLE t1 ( a INT, KEY (a) ); +SHOW KEYS FROM t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible Expression +t1 1 a 1 a A 0 NULL NULL YES BTREE YES NULL +ALTER TABLE t1 ALTER INDEX a INVISIBLE; +SHOW KEYS FROM t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible Expression +t1 1 a 1 a A 0 NULL NULL YES BTREE NO NULL +ALTER TABLE t1 ALTER INDEX a VISIBLE; +SHOW KEYS FROM t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible Expression +t1 1 a 1 a A 0 NULL NULL YES BTREE YES NULL +DROP TABLE t1; +# Test of CREATE INDEX syntax with invisible indexes. +CREATE TABLE t1 ( a INT, b INT ); +CREATE INDEX a_invisible ON t1(a) INVISIBLE; +CREATE INDEX b_visible ON t1(a) VISIBLE; +Warnings: +Warning 1831 Duplicate index 'b_visible' defined on the table 'test.t1'. This is deprecated and will be disallowed in a future release. +CREATE INDEX a_b_invisible ON t1(a, b) INVISIBLE; +SHOW INDEXES FROM t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible Expression +t1 1 a_invisible 1 a A 0 NULL NULL YES BTREE NO NULL +t1 1 b_visible 1 a A 0 NULL NULL YES BTREE YES NULL +t1 1 a_b_invisible 1 a A 0 NULL NULL YES BTREE NO NULL +t1 1 a_b_invisible 2 b A 0 NULL NULL YES BTREE NO NULL +DROP TABLE t1; +# Test that invisible indexes are not used. +CREATE TABLE t1 ( a INT, KEY (a) ); +CREATE TABLE t2 ( a INT, KEY (a) INVISIBLE ); +INSERT INTO t1 VALUES (1), (2), (3), (4), (5); +INSERT INTO t2 SELECT * FROM t1; +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN SELECT a FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL a 5 NULL 5 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` +ALTER TABLE t1 ALTER INDEX a INVISIBLE; +EXPLAIN SELECT a FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` +ALTER TABLE t1 ALTER INDEX a VISIBLE; +EXPLAIN SELECT a FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL a 5 NULL 5 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` +EXPLAIN SELECT a FROM t2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` +ALTER TABLE t2 ALTER INDEX a VISIBLE; +EXPLAIN SELECT a FROM t2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL index NULL a 5 NULL 5 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` +DROP TABLE t1, t2; +# Test that renaming an index does not change visibility and vice versa. +CREATE TABLE t1 ( +a INT, INDEX (a), +b INT, INDEX (b) INVISIBLE +); +SHOW INDEXES FROM t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible Expression +t1 1 a 1 a A 0 NULL NULL YES BTREE YES NULL +t1 1 b 1 b A 0 NULL NULL YES BTREE NO NULL +ALTER TABLE t1 RENAME INDEX a TO a1; +ALTER TABLE t1 RENAME INDEX b TO b1; +SHOW INDEXES FROM t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible Expression +t1 1 a1 1 a A 0 NULL NULL YES BTREE YES NULL +t1 1 b1 1 b A 0 NULL NULL YES BTREE NO NULL +ALTER TABLE t1 ALTER INDEX a1 INVISIBLE; +ALTER TABLE t1 ALTER INDEX b1 VISIBLE; +SHOW INDEXES FROM t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible Expression +t1 1 a1 1 a A 0 NULL NULL YES BTREE NO NULL +t1 1 b1 1 b A 0 NULL NULL YES BTREE YES NULL +DROP TABLE t1; +# Test of SHOW CREATE TABLE. +CREATE TABLE t1 ( +a INT, +b INT, +c INT, +INDEX (a) VISIBLE, +INDEX (b) INVISIBLE, +INDEX (c) +); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int DEFAULT NULL, + `b` int DEFAULT NULL, + `c` int DEFAULT NULL, + KEY `a` (`a`), + KEY `b` (`b`) /*!80000 INVISIBLE */, + KEY `c` (`c`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +DROP TABLE t1; +# Test that primary key indexes can't be made invisible. +CREATE TABLE t1 ( a INT, PRIMARY KEY (a) INVISIBLE ); +ERROR HY000: A primary key index cannot be invisible +ALTER TABLE t1 ALTER INDEX PRIMARY INVISIBLE; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'PRIMARY INVISIBLE' at line 1 +ALTER TABLE t1 ADD PRIMARY KEY (a) INVISIBLE; +ERROR HY000: A primary key index cannot be invisible +# +# Currently we allow to name the primary key index, but the name is +# silently changed to PRIMARY. If this behavior changes in the future, +# we need to take some additional measures to rule out invisible primary +# key indexes. The below two tests serve as triggers for such a change. +# +CREATE TABLE t1( a INT ); +ALTER TABLE t1 ADD CONSTRAINT pk PRIMARY KEY (a); +SHOW INDEXES FROM t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible Expression +t1 0 PRIMARY 1 a A 0 NULL NULL BTREE YES NULL +DROP TABLE t1; +CREATE TABLE t1( a INT, PRIMARY KEY pk (a) ); +SHOW INDEXES FROM t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible Expression +t1 0 PRIMARY 1 a A 0 NULL NULL BTREE YES NULL +DROP TABLE t1; +CREATE TABLE t1 ( +a INT, KEY (a), +b INT, KEY (b) INVISIBLE +); +ALTER TABLE t1 RENAME INDEX no_such_index TO x; +ERROR 42000: Key 'no_such_index' doesn't exist in table 't1' +ALTER TABLE t1 ALTER INDEX no_such_index INVISIBLE; +ERROR 42000: Key 'no_such_index' doesn't exist in table 't1' +# +# Repeated alter actions. Should work. +# +ALTER TABLE t1 ALTER INDEX a INVISIBLE, ALTER INDEX a VISIBLE; +ALTER TABLE t1 ALTER INDEX a INVISIBLE, ALTER INDEX b VISIBLE; +SHOW INDEXES FROM t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible Expression +t1 1 a 1 a A 0 NULL NULL YES BTREE NO NULL +t1 1 b 1 b A 0 NULL NULL YES BTREE YES NULL +# +# Various combinations of RENAME INDEX and ALTER INDEX ... INVISIBLE. +# +ALTER TABLE t1 RENAME INDEX a TO x, RENAME INDEX x TO a; +ERROR 42000: Key 'x' doesn't exist in table 't1' +ALTER TABLE t1 RENAME INDEX a TO x, ALTER INDEX x INVISIBLE; +ERROR 42000: Key 'x' doesn't exist in table 't1' +ALTER TABLE t1 RENAME INDEX a TO x, ALTER INDEX a VISIBLE; +ERROR 42000: Key 'a' doesn't exist in table 't1' +ALTER TABLE t1 ALTER INDEX a VISIBLE, RENAME INDEX a TO x; +ERROR 42000: Key 'a' doesn't exist in table 't1' +# +# Various algorithms and their effects. +# +INSERT INTO t1 VALUES (1, 1), (2, 2), (3, 3); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +ALTER TABLE t1 ALTER INDEX a INVISIBLE, ALGORITHM = COPY; +affected rows: 3 +info: Records: 3 Duplicates: 0 Warnings: 0 +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +SHOW INDEXES FROM t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible Expression +t1 1 a 1 a A 3 NULL NULL YES BTREE NO NULL +t1 1 b 1 b A 3 NULL NULL YES BTREE YES NULL +ALTER TABLE t1 ALTER INDEX a VISIBLE, ALGORITHM = INPLACE; +affected rows: 0 +info: Records: 0 Duplicates: 0 Warnings: 0 +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +SHOW INDEXES FROM t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible Expression +t1 1 a 1 a A 3 NULL NULL YES BTREE YES NULL +t1 1 b 1 b A 3 NULL NULL YES BTREE YES NULL +ALTER TABLE t1 ALTER INDEX a INVISIBLE, ALGORITHM = DEFAULT; +affected rows: 0 +info: Records: 0 Duplicates: 0 Warnings: 0 +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +SHOW INDEXES FROM t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible Expression +t1 1 a 1 a A 3 NULL NULL YES BTREE NO NULL +t1 1 b 1 b A 3 NULL NULL YES BTREE YES NULL +ALTER TABLE t1 ALTER INDEX a VISIBLE; +affected rows: 0 +info: Records: 0 Duplicates: 0 Warnings: 0 +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +SHOW INDEXES FROM t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible Expression +t1 1 a 1 a A 3 NULL NULL YES BTREE YES NULL +t1 1 b 1 b A 3 NULL NULL YES BTREE YES NULL +ALTER TABLE t1 ADD INDEX ab(a, b), ALTER INDEX ab INVISIBLE; +ERROR 42000: Key 'ab' doesn't exist in table 't1' +DROP TABLE t1; +# +# Test that constraints implemented by the indexes are still enforced +# while the index is invisible. +# +CREATE TABLE t1 ( a INT, UNIQUE KEY (a) INVISIBLE ); +CREATE TABLE t2 ( a INT UNIQUE ); +CREATE TABLE t3 ( a INT NOT NULL, KEY (a) INVISIBLE, b INT PRIMARY KEY ); +CREATE TABLE t4 ( a INT NOT NULL, UNIQUE KEY (a) INVISIBLE, +b INT PRIMARY KEY AUTO_INCREMENT ); +CREATE TABLE t5 ( a INT, b INT, c INT, UNIQUE KEY (a, b, c) INVISIBLE ); +INSERT INTO t1 VALUES (1); +INSERT INTO t1 VALUES (1); +ERROR 23000: Duplicate entry '1' for key 't1.a' +ALTER TABLE t2 ALTER INDEX a INVISIBLE; +INSERT INTO t2 VALUES (1); +INSERT INTO t2 VALUES (1); +ERROR 23000: Duplicate entry '1' for key 't2.a' +INSERT INTO t3(a) VALUES (NULL); +ERROR 23000: Column 'a' cannot be null +INSERT INTO t4(a) VALUES (NULL); +ERROR 23000: Column 'a' cannot be null +INSERT INTO t4(a) VALUES (1); +INSERT INTO t4(a) VALUES (1); +ERROR 23000: Duplicate entry '1' for key 't4.a' +INSERT INTO t5 VALUES (1, 2, 3); +INSERT INTO t5 VALUES (1, 2, 3); +ERROR 23000: Duplicate entry '1-2-3' for key 't5.a' +DROP TABLE t1, t2, t3, t4, t5; +# +# Bug#23256900: WL#8697: ASSERTION +# `TABLE_SHARE->IS_MISSING_PRIMARY_KEY() ...` FAILED. +# +# Test for when an index is implicitly promoted to primary key index. +# The first NOT NULL UNIQUE index is candidate for promotion. +# These indexes can't be invisible, either. +CREATE TABLE t1 ( a INT NOT NULL, UNIQUE KEY (a) ); +ALTER TABLE t1 ALTER INDEX a INVISIBLE; +ERROR HY000: A primary key index cannot be invisible +EXPLAIN +SELECT * FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL a 4 NULL 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` +SELECT * FROM t1; +a +DROP TABLE t1; +# The first NOT NULL UNIQUE index may of course be invisible if it is +# not promoted. +CREATE TABLE t1 ( +a INT NOT NULL, +b INT NOT NULL PRIMARY KEY, +UNIQUE KEY (a) INVISIBLE +); +SHOW INDEXES FROM t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible Expression +t1 0 PRIMARY 1 b A 0 NULL NULL BTREE YES NULL +t1 0 a 1 a A 0 NULL NULL BTREE NO NULL +DROP TABLE t1; +# The check above applies only to the first NOT NULL UNIQUE index. +CREATE TABLE t1 ( +a INT NOT NULL, +b INT NOT NULL, +UNIQUE KEY (a), +UNIQUE KEY (b) INVISIBLE +); +SHOW INDEXES FROM t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible Expression +t1 0 a 1 a A 0 NULL NULL BTREE YES NULL +t1 0 b 1 b A 0 NULL NULL BTREE NO NULL +DROP TABLE t1; +CREATE TABLE t1 ( a INT NOT NULL, UNIQUE KEY (a) INVISIBLE ); +ERROR HY000: A primary key index cannot be invisible +# +# Bug#23264435: WL#8697: FULLTEXT INDEXES CANNOT BE MADE INVISIBLE +# +CREATE TABLE t1 ( a INT NOT NULL, KEY (a) INVISIBLE, b INT NOT NULL UNIQUE ); +CREATE TABLE t2 ( a INT PRIMARY KEY, b INT, INDEX(b) INVISIBLE); +ALTER TABLE t2 ALTER INDEX b VISIBLE; +DROP TABLE t1, t2; +CREATE TEMPORARY TABLE t1 ( a INT, KEY (a) INVISIBLE ); +SHOW INDEXES FROM t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible Expression +t1 1 a 1 a A 0 NULL NULL YES BTREE NO NULL +EXPLAIN SELECT a FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` +DROP TABLE t1; +# +# Invisible spatial indexes. +# +CREATE TABLE t1 ( +fid INT NOT NULL AUTO_INCREMENT PRIMARY KEY, +g GEOMETRY NOT NULL SRID 0, +SPATIAL KEY(g) +); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +# There appears to be a bug causing the cardinality number to fluctuate +# for spatial indexes. +EXPLAIN SELECT * +FROM t1 +WHERE ST_Within(g, +ST_GeomFromText('Polygon((140 140,160 140,160 160,140 140))')); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range g g 34 NULL X 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`fid` AS `fid`,`test`.`t1`.`g` AS `g` from `test`.`t1` where st_within(`test`.`t1`.`g`,(st_geomfromtext('Polygon((140 140,160 140,160 160,140 140))'))) +ALTER TABLE t1 ALTER INDEX g INVISIBLE; +SHOW INDEXES FROM t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible Expression +t1 0 PRIMARY 1 fid A X NULL NULL BTREE YES NULL +t1 1 g 1 g A X 32 NULL SPATIAL NO NULL +EXPLAIN SELECT * +FROM t1 +WHERE ST_Within(g, +ST_GeomFromText('Polygon((140 140,160 140,160 160,140 140))')); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL X 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`fid` AS `fid`,`test`.`t1`.`g` AS `g` from `test`.`t1` where st_within(`test`.`t1`.`g`,(st_geomfromtext('Polygon((140 140,160 140,160 160,140 140))'))) +DROP TABLE t1; +# +# Test of invisible fulltext indexes. +# +CREATE TABLE t1 (a VARCHAR(200), b TEXT, FULLTEXT (a,b)); +INSERT INTO t1 VALUES('Some data', 'for full-text search'); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT * FROM t1 WHERE MATCH(a, b) AGAINST ("collections"); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL fulltext a a 0 const 1 100.00 Using where; Ft_hints: sorted +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (match `test`.`t1`.`a`,`test`.`t1`.`b` against ('collections')) +EXPLAIN SELECT * FROM t1 WHERE MATCH(a, b) AGAINST ("collections" IN BOOLEAN MODE); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL fulltext a a 0 const 1 100.00 Using where; Ft_hints: no_ranking +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (match `test`.`t1`.`a`,`test`.`t1`.`b` against ('collections' in boolean mode)) +ALTER TABLE t1 ALTER INDEX a INVISIBLE; +SHOW INDEXES FROM t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible Expression +t1 1 a 1 a NULL 1 NULL NULL YES FULLTEXT NO NULL +t1 1 a 2 b NULL 1 NULL NULL YES FULLTEXT NO NULL +EXPLAIN SELECT * FROM t1 WHERE MATCH(a, b) AGAINST ("collections"); +ERROR HY000: Can't find FULLTEXT index matching the column list +EXPLAIN SELECT * FROM t1 WHERE MATCH(a, b) AGAINST ("collections" IN BOOLEAN MODE); +ERROR HY000: Can't find FULLTEXT index matching the column list +SELECT * FROM t1 WHERE MATCH(a, b) AGAINST ("collections"); +ERROR HY000: Can't find FULLTEXT index matching the column list +SELECT * FROM t1 WHERE MATCH(a, b) AGAINST ("collections" IN BOOLEAN MODE); +ERROR HY000: Can't find FULLTEXT index matching the column list +DROP TABLE t1; +# +# Invisible indexes on AUTO_INCREMENT columns. +# +CREATE TABLE t1 ( a INT AUTO_INCREMENT, KEY ( a ) ); +INSERT INTO t1 VALUES (), (), (); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT a FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL a 4 NULL 3 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` +ALTER TABLE t1 ALTER INDEX a INVISIBLE; +SHOW INDEXES FROM t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible Expression +t1 1 a 1 a A 3 NULL NULL BTREE NO NULL +EXPLAIN SELECT a FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` +DROP TABLE t1; +# +# Bug#24660093: REMOVING AN INVISIBLE INDEX BREAKS EXPLAIN +# +CREATE TABLE t1 ( a INT, KEY(a) INVISIBLE ); +SELECT * FROM t1 FORCE INDEX(a); +ERROR 42000: Key 'a' doesn't exist in table 't1' +SELECT * FROM t1 FORCE INDEX FOR JOIN (a); +ERROR 42000: Key 'a' doesn't exist in table 't1' +SELECT * FROM t1 FORCE INDEX FOR ORDER BY (a); +ERROR 42000: Key 'a' doesn't exist in table 't1' +SELECT * FROM t1 FORCE INDEX FOR GROUP BY (a); +ERROR 42000: Key 'a' doesn't exist in table 't1' +SELECT * FROM t1 USE INDEX(a); +ERROR 42000: Key 'a' doesn't exist in table 't1' +SELECT * FROM t1 USE INDEX FOR JOIN (a); +ERROR 42000: Key 'a' doesn't exist in table 't1' +SELECT * FROM t1 USE INDEX FOR ORDER BY (a); +ERROR 42000: Key 'a' doesn't exist in table 't1' +SELECT * FROM t1 USE INDEX FOR GROUP BY (a); +ERROR 42000: Key 'a' doesn't exist in table 't1' +SELECT * FROM t1 IGNORE INDEX(a); +ERROR 42000: Key 'a' doesn't exist in table 't1' +SELECT * FROM t1 IGNORE INDEX FOR JOIN (a); +ERROR 42000: Key 'a' doesn't exist in table 't1' +SELECT * FROM t1 IGNORE INDEX FOR ORDER BY (a); +ERROR 42000: Key 'a' doesn't exist in table 't1' +SELECT * FROM t1 IGNORE INDEX FOR GROUP BY (a); +ERROR 42000: Key 'a' doesn't exist in table 't1' +DROP TABLE t1; +# +# Tests that don't work on MyISAM ( native partitioning, indexes on +# generated columns, etc.) +# +# +# Partitioning on keys with an invisible index, invisible indexes over +# partitioned tables. +# +CREATE TABLE t1 ( +a CHAR(2) NOT NULL, +b CHAR(2) NOT NULL, +c INT(10) UNSIGNED NOT NULL, +d VARCHAR(255) DEFAULT NULL, +e VARCHAR(1000) DEFAULT NULL, +KEY (a) INVISIBLE, +KEY (b) +) PARTITION BY KEY (a) PARTITIONS 20; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 (a, b, c, d, e) VALUES +('07', '03', 343, '1', '07_03_343'), +('01', '04', 343, '2', '01_04_343'), +('01', '06', 343, '3', '01_06_343'), +('01', '07', 343, '4', '01_07_343'), +('01', '08', 343, '5', '01_08_343'), +('01', '09', 343, '6', '01_09_343'), +('03', '03', 343, '7', '03_03_343'), +('03', '06', 343, '8', '03_06_343'), +('03', '07', 343, '9', '03_07_343'), +('04', '03', 343, '10', '04_03_343'), +('04', '06', 343, '11', '04_06_343'), +('05', '03', 343, '12', '05_03_343'), +('11', '03', 343, '13', '11_03_343'), +('11', '04', 343, '14', '11_04_343'); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT a FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 p0,p1,p2,p3,p4,p5,p6,p7,p8,p9,p10,p11,p12,p13,p14,p15,p16,p17,p18,p19 ALL NULL NULL NULL NULL 14 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` +EXPLAIN SELECT b FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 p0,p1,p2,p3,p4,p5,p6,p7,p8,p9,p10,p11,p12,p13,p14,p15,p16,p17,p18,p19 index NULL b 8 NULL 14 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`b` AS `b` from `test`.`t1` +EXPLAIN SELECT * FROM t1 WHERE a = '04'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 p0 ALL NULL NULL NULL NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c`,`test`.`t1`.`d` AS `d`,`test`.`t1`.`e` AS `e` from `test`.`t1` where (`test`.`t1`.`a` = '04') +ALTER TABLE t1 ALTER INDEX a VISIBLE; +EXPLAIN SELECT a FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 p0,p1,p2,p3,p4,p5,p6,p7,p8,p9,p10,p11,p12,p13,p14,p15,p16,p17,p18,p19 index NULL a 8 NULL 14 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` +EXPLAIN SELECT * FROM t1 WHERE a = '04'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 p0 ref a a 8 const 2 100.00 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c`,`test`.`t1`.`d` AS `d`,`test`.`t1`.`e` AS `e` from `test`.`t1` where (`test`.`t1`.`a` = '04') +ALTER TABLE t1 ALTER INDEX b INVISIBLE; +EXPLAIN SELECT b FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 p0,p1,p2,p3,p4,p5,p6,p7,p8,p9,p10,p11,p12,p13,p14,p15,p16,p17,p18,p19 ALL NULL NULL NULL NULL 14 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`b` AS `b` from `test`.`t1` +DROP TABLE t1; +CREATE TABLE t1 ( a INT GENERATED ALWAYS AS (1), KEY (a) INVISIBLE ); +SHOW INDEXES FROM t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible Expression +t1 1 a 1 a A 0 NULL NULL YES BTREE NO NULL +EXPLAIN SELECT a FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` +DROP TABLE t1; +# +# Test that referential constraints implemented by the indexes are still +# enforced while the index is invisible. +# +CREATE TABLE t1p ( a INT KEY ); +CREATE TABLE t1c ( t1p_a INT ); +ALTER TABLE t1c ADD CONSTRAINT FOREIGN KEY ( t1p_a ) REFERENCES t1p( a ); +ALTER TABLE t1c ALTER INDEX t1p_a INVISIBLE; +INSERT INTO t1c VALUES ( 1 ); +ERROR 23000: Cannot add or update a child row: a foreign key constraint fails (`test`.`t1c`, CONSTRAINT `t1c_ibfk_1` FOREIGN KEY (`t1p_a`) REFERENCES `t1p` (`a`)) +SELECT * FROM t1c; +t1p_a +DROP TABLE t1c, t1p; +# +# Bug#25837038: FEATURE REQUEST : USE INVISIBLE INDEXES SPECIFIC QUERY +# +CREATE TABLE t1 ( a INT, KEY( a ) INVISIBLE ); +INSERT INTO t1 VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10); +EXPLAIN SELECT a FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL X 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL X 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` +SELECT @@optimizer_switch; +@@optimizer_switch +index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,engine_condition_pushdown=on,index_condition_pushdown=on,mrr=on,mrr_cost_based=on,block_nested_loop=on,batched_key_access=off,materialization=on,semijoin=on,loosescan=on,firstmatch=on,duplicateweedout=on,subquery_materialization_cost_based=on,use_index_extensions=on,condition_fanout_filter=on,derived_merge=on,use_invisible_indexes=off,skip_scan=on,hash_join=on,subquery_to_derived=off,prefer_ordering_index=on,hypergraph_optimizer=off,derived_condition_pushdown=on +EXPLAIN SELECT a FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL X 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL X 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` +SET @@optimizer_switch='use_invisible_indexes=on'; +EXPLAIN SELECT a FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL X 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL a 5 NULL X 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` +SELECT @@optimizer_switch; +@@optimizer_switch +index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,engine_condition_pushdown=on,index_condition_pushdown=on,mrr=on,mrr_cost_based=on,block_nested_loop=on,batched_key_access=off,materialization=on,semijoin=on,loosescan=on,firstmatch=on,duplicateweedout=on,subquery_materialization_cost_based=on,use_index_extensions=on,condition_fanout_filter=on,derived_merge=on,use_invisible_indexes=off,skip_scan=on,hash_join=on,subquery_to_derived=off,prefer_ordering_index=on,hypergraph_optimizer=off,derived_condition_pushdown=on +EXPLAIN SELECT a FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL X 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL X 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` +SELECT @@optimizer_switch; +@@optimizer_switch +index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,engine_condition_pushdown=on,index_condition_pushdown=on,mrr=on,mrr_cost_based=on,block_nested_loop=on,batched_key_access=off,materialization=on,semijoin=on,loosescan=on,firstmatch=on,duplicateweedout=on,subquery_materialization_cost_based=on,use_index_extensions=on,condition_fanout_filter=on,derived_merge=on,use_invisible_indexes=on,skip_scan=on,hash_join=on,subquery_to_derived=off,prefer_ordering_index=on,hypergraph_optimizer=off,derived_condition_pushdown=on +SET @@optimizer_switch='use_invisible_indexes=off'; +EXPLAIN SELECT a FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL X 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL X 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` +EXPLAIN SELECT a FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL X 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL X 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` +DROP TABLE t1; +# +# Bug#31550839 OPTIMIZER SWITCH USE_INVISIBLE_INDEXES=ON DOES NOT ALLOW FORCE INDEX +# +CREATE TABLE t1 ( +id INT NOT NULL PRIMARY KEY, +b INT NOT NULL, +INDEX (b) INVISIBLE +); +INSERT INTO t1 VALUES (1, 1), (2,2),(3,3),(4,4),(5,5); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +SET optimizer_switch="use_invisible_indexes=on"; +EXPLAIN SELECT * FROM t1 FORCE INDEX (b) WHERE b = 3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref b b 4 const 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,`test`.`t1`.`b` AS `b` from `test`.`t1` FORCE INDEX (`b`) where (`test`.`t1`.`b` = 3) +SET optimizer_switch="use_invisible_indexes=default"; +EXPLAIN SELECT * FROM t1 FORCE INDEX (b) WHERE b = 3; +ERROR 42000: Key 'b' doesn't exist in table 't1' +DROP TABLE t1; diff --git a/mysql-test/r/join.result-pq b/mysql-test/r/join.result-pq new file mode 100644 index 000000000000..3e98c027892a --- /dev/null +++ b/mysql-test/r/join.result-pq @@ -0,0 +1,2157 @@ +drop table if exists t1,t2,t3; +CREATE TABLE t1 (S1 INT); +CREATE TABLE t2 (S1 INT); +INSERT INTO t1 VALUES (1); +INSERT INTO t2 VALUES (2); +SELECT * FROM t1 JOIN t2; +S1 S1 +1 2 +SELECT * FROM t1 INNER JOIN t2; +S1 S1 +1 2 +SELECT * from t1 JOIN t2 USING (S1); +S1 +SELECT * FROM t1 INNER JOIN t2 USING (S1); +S1 +SELECT * from t1 CROSS JOIN t2; +S1 S1 +1 2 +SELECT * from t1 LEFT JOIN t2 USING(S1); +S1 +1 +SELECT * from t1 LEFT JOIN t2 ON(t2.S1=2); +S1 S1 +1 2 +SELECT * from t1 RIGHT JOIN t2 USING(S1); +S1 +2 +SELECT * from t1 RIGHT JOIN t2 ON(t1.S1=1); +S1 S1 +1 2 +drop table t1,t2; +create table t1 (id int primary key); +create table t2 (id int); +insert into t1 values (75); +insert into t1 values (79); +insert into t1 values (78); +insert into t1 values (77); +replace into t1 values (76); +replace into t1 values (76); +insert into t1 values (104); +insert into t1 values (103); +insert into t1 values (102); +insert into t1 values (101); +insert into t1 values (105); +insert into t1 values (106); +insert into t1 values (107); +insert into t2 values (107),(75),(1000); +select t1.id, t2.id from t1, t2 where t2.id = t1.id; +id id +107 107 +75 75 +select t1.id, count(t2.id) from t1,t2 where t2.id = t1.id group by t1.id; +id count(t2.id) +107 1 +75 1 +select t1.id, count(t2.id) from t1,t2 where t2.id = t1.id group by t2.id; +id count(t2.id) +107 1 +75 1 +select t1.id,t2.id from t2 left join t1 on t1.id>=74 and t1.id<=0 where t2.id=75 and t1.id is null; +id id +NULL 75 +explain select t1.id,t2.id from t2 left join t1 on t1.id>=74 and t1.id<=0 where t2.id=75 and t1.id is null; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL const PRIMARY NULL NULL NULL 1 100.00 Impossible ON condition +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE t1 NULL const PRIMARY NULL NULL NULL 1 100.00 Impossible ON condition +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,`test`.`t2`.`id` AS `id` from `test`.`t2` left join `test`.`t1` on(((`test`.`t1`.`id` >= 74) and (`test`.`t1`.`id` <= 0))) where ((`test`.`t2`.`id` = 75) and (`test`.`t1`.`id` is null)) +explain select t1.id, t2.id from t1, t2 where t2.id = t1.id and t1.id <0 and t1.id > 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,`test`.`t2`.`id` AS `id` from `test`.`t1` join `test`.`t2` where ((`test`.`t1`.`id` < 0) and (`test`.`t1`.`id` > 0) and multiple equal(`test`.`t2`.`id`, `test`.`t1`.`id`)) +drop table t1,t2; +SET sql_mode = 'NO_ENGINE_SUBSTITUTION'; +CREATE TABLE t1 ( +id int(11) NOT NULL auto_increment, +token varchar(100) DEFAULT '' NOT NULL, +count int(11) DEFAULT '0' NOT NULL, +qty int(11), +phone char(1) DEFAULT '' NOT NULL, +timestamp datetime DEFAULT '0000-00-00 00:00:00' NOT NULL, +PRIMARY KEY (id), +KEY token (token(15)), +KEY timestamp (timestamp), +UNIQUE token_2 (token(75),count,phone) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +SET sql_mode = default; +INSERT INTO t1 VALUES (21,'e45703b64de71482360de8fec94c3ade',3,7800,'n','1999-12-23 17:22:21'); +INSERT INTO t1 VALUES (22,'e45703b64de71482360de8fec94c3ade',4,5000,'y','1999-12-23 17:22:21'); +INSERT INTO t1 VALUES (18,'346d1cb63c89285b2351f0ca4de40eda',3,13200,'b','1999-12-23 11:58:04'); +INSERT INTO t1 VALUES (17,'ca6ddeb689e1b48a04146b1b5b6f936a',4,15000,'b','1999-12-23 11:36:53'); +INSERT INTO t1 VALUES (16,'ca6ddeb689e1b48a04146b1b5b6f936a',3,13200,'b','1999-12-23 11:36:53'); +INSERT INTO t1 VALUES (26,'a71250b7ed780f6ef3185bfffe027983',5,1500,'b','1999-12-27 09:44:24'); +INSERT INTO t1 VALUES (24,'4d75906f3c37ecff478a1eb56637aa09',3,5400,'y','1999-12-23 17:29:12'); +INSERT INTO t1 VALUES (25,'4d75906f3c37ecff478a1eb56637aa09',4,6500,'y','1999-12-23 17:29:12'); +INSERT INTO t1 VALUES (27,'a71250b7ed780f6ef3185bfffe027983',3,6200,'b','1999-12-27 09:44:24'); +INSERT INTO t1 VALUES (28,'a71250b7ed780f6ef3185bfffe027983',3,5400,'y','1999-12-27 09:44:36'); +INSERT INTO t1 VALUES (29,'a71250b7ed780f6ef3185bfffe027983',4,17700,'b','1999-12-27 09:45:05'); +CREATE TABLE t2 ( +id int(11) NOT NULL auto_increment, +category int(11) DEFAULT '0' NOT NULL, +county int(11) DEFAULT '0' NOT NULL, +state int(11) DEFAULT '0' NOT NULL, +phones int(11) DEFAULT '0' NOT NULL, +nophones int(11) DEFAULT '0' NOT NULL, +PRIMARY KEY (id), +KEY category (category,county,state) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (3,2,11,12,5400,7800); +INSERT INTO t2 VALUES (4,2,25,12,6500,11200); +INSERT INTO t2 VALUES (5,1,37,6,10000,12000); +select a.id, b.category as catid, b.state as stateid, b.county as countyid from t1 a, t2 b ignore index (primary) where (a.token ='a71250b7ed780f6ef3185bfffe027983') and (a.count = b.id); +id catid stateid countyid +26 1 6 37 +27 2 12 11 +28 2 12 11 +29 2 12 25 +select a.id, b.category as catid, b.state as stateid, b.county as +countyid from t1 a, t2 b where (a.token = +'a71250b7ed780f6ef3185bfffe027983') and (a.count = b.id) order by a.id; +id catid stateid countyid +26 1 6 37 +27 2 12 11 +28 2 12 11 +29 2 12 25 +drop table t1, t2; +create table t1 (a int primary key); +insert into t1 values(1),(2); +select t1.a from t1 as t1 left join t1 as t2 using (a) left join t1 as t3 using (a) left join t1 as t4 using (a) left join t1 as t5 using (a) left join t1 as t6 using (a) left join t1 as t7 using (a) left join t1 as t8 using (a) left join t1 as t9 using (a) left join t1 as t10 using (a) left join t1 as t11 using (a) left join t1 as t12 using (a) left join t1 as t13 using (a) left join t1 as t14 using (a) left join t1 as t15 using (a) left join t1 as t16 using (a) left join t1 as t17 using (a) left join t1 as t18 using (a) left join t1 as t19 using (a) left join t1 as t20 using (a) left join t1 as t21 using (a) left join t1 as t22 using (a) left join t1 as t23 using (a) left join t1 as t24 using (a) left join t1 as t25 using (a) left join t1 as t26 using (a) left join t1 as t27 using (a) left join t1 as t28 using (a) left join t1 as t29 using (a) left join t1 as t30 using (a) left join t1 as t31 using (a); +a +1 +2 +select t1.a from t1 as t1 left join t1 as t2 using (a) left join t1 as t3 using (a) left join t1 as t4 using (a) left join t1 as t5 using (a) left join t1 as t6 using (a) left join t1 as t7 using (a) left join t1 as t8 using (a) left join t1 as t9 using (a) left join t1 as t10 using (a) left join t1 as t11 using (a) left join t1 as t12 using (a) left join t1 as t13 using (a) left join t1 as t14 using (a) left join t1 as t15 using (a) left join t1 as t16 using (a) left join t1 as t17 using (a) left join t1 as t18 using (a) left join t1 as t19 using (a) left join t1 as t20 using (a) left join t1 as t21 using (a) left join t1 as t22 using (a) left join t1 as t23 using (a) left join t1 as t24 using (a) left join t1 as t25 using (a) left join t1 as t26 using (a) left join t1 as t27 using (a) left join t1 as t28 using (a) left join t1 as t29 using (a) left join t1 as t30 using (a) left join t1 as t31 using (a) left join t1 as t32 using (a) left join t1 as t33 using (a) left join t1 as t34 using (a) left join t1 as t35 using (a) left join t1 as t36 using (a) left join t1 as t37 using (a) left join t1 as t38 using (a) left join t1 as t39 using (a) left join t1 as t40 using (a) left join t1 as t41 using (a) left join t1 as t42 using (a) left join t1 as t43 using (a) left join t1 as t44 using (a) left join t1 as t45 using (a) left join t1 as t46 using (a) left join t1 as t47 using (a) left join t1 as t48 using (a) left join t1 as t49 using (a) left join t1 as t50 using (a) left join t1 as t51 using (a) left join t1 as t52 using (a) left join t1 as t53 using (a) left join t1 as t54 using (a) left join t1 as t55 using (a) left join t1 as t56 using (a) left join t1 as t57 using (a) left join t1 as t58 using (a) left join t1 as t59 using (a) left join t1 as t60 using (a) left join t1 as t61 using (a) left join t1 as t62 using (a) left join t1 as t63 using (a) left join t1 as t64 using (a) left join t1 as t65 using (a); +ERROR HY000: Too many tables; MySQL can only use XX tables in a join +select a from t1 as t1 left join t1 as t2 using (a) left join t1 as t3 using (a) left join t1 as t4 using (a) left join t1 as t5 using (a) left join t1 as t6 using (a) left join t1 as t7 using (a) left join t1 as t8 using (a) left join t1 as t9 using (a) left join t1 as t10 using (a) left join t1 as t11 using (a) left join t1 as t12 using (a) left join t1 as t13 using (a) left join t1 as t14 using (a) left join t1 as t15 using (a) left join t1 as t16 using (a) left join t1 as t17 using (a) left join t1 as t18 using (a) left join t1 as t19 using (a) left join t1 as t20 using (a) left join t1 as t21 using (a) left join t1 as t22 using (a) left join t1 as t23 using (a) left join t1 as t24 using (a) left join t1 as t25 using (a) left join t1 as t26 using (a) left join t1 as t27 using (a) left join t1 as t28 using (a) left join t1 as t29 using (a) left join t1 as t30 using (a) left join t1 as t31 using (a); +a +1 +2 +select a from t1 as t1 left join t1 as t2 using (a) left join t1 as t3 using (a) left join t1 as t4 using (a) left join t1 as t5 using (a) left join t1 as t6 using (a) left join t1 as t7 using (a) left join t1 as t8 using (a) left join t1 as t9 using (a) left join t1 as t10 using (a) left join t1 as t11 using (a) left join t1 as t12 using (a) left join t1 as t13 using (a) left join t1 as t14 using (a) left join t1 as t15 using (a) left join t1 as t16 using (a) left join t1 as t17 using (a) left join t1 as t18 using (a) left join t1 as t19 using (a) left join t1 as t20 using (a) left join t1 as t21 using (a) left join t1 as t22 using (a) left join t1 as t23 using (a) left join t1 as t24 using (a) left join t1 as t25 using (a) left join t1 as t26 using (a) left join t1 as t27 using (a) left join t1 as t28 using (a) left join t1 as t29 using (a) left join t1 as t30 using (a) left join t1 as t31 using (a) left join t1 as t32 using (a) left join t1 as t33 using (a) left join t1 as t34 using (a) left join t1 as t35 using (a) left join t1 as t36 using (a) left join t1 as t37 using (a) left join t1 as t38 using (a) left join t1 as t39 using (a) left join t1 as t40 using (a) left join t1 as t41 using (a) left join t1 as t42 using (a) left join t1 as t43 using (a) left join t1 as t44 using (a) left join t1 as t45 using (a) left join t1 as t46 using (a) left join t1 as t47 using (a) left join t1 as t48 using (a) left join t1 as t49 using (a) left join t1 as t50 using (a) left join t1 as t51 using (a) left join t1 as t52 using (a) left join t1 as t53 using (a) left join t1 as t54 using (a) left join t1 as t55 using (a) left join t1 as t56 using (a) left join t1 as t57 using (a) left join t1 as t58 using (a) left join t1 as t59 using (a) left join t1 as t60 using (a) left join t1 as t61 using (a) left join t1 as t62 using (a) left join t1 as t63 using (a) left join t1 as t64 using (a) left join t1 as t65 using (a); +ERROR HY000: Too many tables; MySQL can only use XX tables in a join +drop table t1; +CREATE TABLE t1 ( +a int(11) NOT NULL, +b int(11) NOT NULL, +PRIMARY KEY (a,b) +) ENGINE=MyISAM; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (1,1),(1,2),(1,3),(1,4),(1,5),(1,6),(1,7),(2,3); +CREATE TABLE t2 ( +a int(11) default NULL +) ENGINE=MyISAM; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (2),(3); +SELECT t1.a,t2.a,b FROM t1,t2 WHERE t1.a=t2.a AND (t1.a=1 OR t1.a=2) AND b>=1 AND b<=3; +a a b +2 2 3 +DROP TABLE t1, t2; +CREATE TABLE t1 (d DATE NOT NULL); +CREATE TABLE t2 (d DATE NOT NULL); +INSERT INTO t1 (d) VALUES ('2001-08-01'),('1000-01-01'); +SELECT * FROM t1 LEFT JOIN t2 USING (d) WHERE t2.d IS NULL; +d +2001-08-01 +1000-01-01 +SELECT * FROM t1 LEFT JOIN t2 USING (d) WHERE d IS NULL; +d +SELECT * from t1 WHERE t1.d IS NULL; +d +SELECT * FROM t1 WHERE 1/0 IS NULL; +d +2001-08-01 +1000-01-01 +Warnings: +Warning 1365 Division by 0 +DROP TABLE t1,t2; +CREATE TABLE t1 ( +Document_ID varchar(50) NOT NULL default '', +Contractor_ID varchar(6) NOT NULL default '', +Language_ID char(3) NOT NULL default '', +Expiration_Date datetime default NULL, +Publishing_Date datetime default NULL, +Title text, +Column_ID varchar(50) NOT NULL default '', +PRIMARY KEY (Language_ID,Document_ID,Contractor_ID) +); +INSERT INTO t1 VALUES ('xep80','1','ger','2001-12-31 20:00:00','2001-11-12 10:58:00','Kartenbestellung - jetzt auch online','anle'),('','999998','',NULL,NULL,NULL,''); +CREATE TABLE t2 ( +Contractor_ID char(6) NOT NULL default '', +Language_ID char(3) NOT NULL default '', +Document_ID char(50) NOT NULL default '', +CanRead char(1) default NULL, +Customer_ID int(11) NOT NULL default '0', +PRIMARY KEY (Contractor_ID,Language_ID,Document_ID,Customer_ID) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES ('5','ger','xep80','1',999999),('1','ger','xep80','1',999999); +CREATE TABLE t3 ( +Language_ID char(3) NOT NULL default '', +Column_ID char(50) NOT NULL default '', +Contractor_ID char(6) NOT NULL default '', +CanRead char(1) default NULL, +Active char(1) default NULL, +PRIMARY KEY (Language_ID,Column_ID,Contractor_ID) +); +INSERT INTO t3 VALUES ('ger','home','1','1','1'),('ger','Test','1','0','0'),('ger','derclu','1','0','0'),('ger','clubne','1','0','0'),('ger','philos','1','0','0'),('ger','clubko','1','0','0'),('ger','clubim','1','1','1'),('ger','progra','1','0','0'),('ger','progvo','1','0','0'),('ger','progsp','1','0','0'),('ger','progau','1','0','0'),('ger','progku','1','0','0'),('ger','progss','1','0','0'),('ger','nachl','1','0','0'),('ger','mitgli','1','0','0'),('ger','mitsu','1','0','0'),('ger','mitbus','1','0','0'),('ger','ergmar','1','1','1'),('ger','home','4','1','1'),('ger','derclu','4','1','1'),('ger','clubne','4','0','0'),('ger','philos','4','1','1'),('ger','clubko','4','1','1'),('ger','clubim','4','1','1'),('ger','progra','4','1','1'),('ger','progvo','4','1','1'),('ger','progsp','4','1','1'),('ger','progau','4','0','0'),('ger','progku','4','1','1'),('ger','progss','4','1','1'),('ger','nachl','4','1','1'),('ger','mitgli','4','0','0'),('ger','mitsu','4','0','0'),('ger','mitbus','4','0','0'),('ger','ergmar','4','1','1'),('ger','progra2','1','0','0'),('ger','archiv','4','1','1'),('ger','anmeld','4','1','1'),('ger','thema','4','1','1'),('ger','edito','4','1','1'),('ger','madis','4','1','1'),('ger','enma','4','1','1'),('ger','madis','1','1','1'),('ger','enma','1','1','1'),('ger','vorsch','4','0','0'),('ger','veranst','4','0','0'),('ger','anle','4','1','1'),('ger','redak','4','1','1'),('ger','nele','4','1','1'),('ger','aukt','4','1','1'),('ger','callcenter','4','1','1'),('ger','anle','1','0','0'); +delete from t1 where Contractor_ID='999998'; +insert into t1 (Contractor_ID) Values ('999998'); +SELECT DISTINCT COUNT(t1.Title) FROM t1, +t2, t3 WHERE +t1.Document_ID='xep80' AND t1.Contractor_ID='1' AND +t1.Language_ID='ger' AND '2001-12-21 23:14:24' >= +Publishing_Date AND '2001-12-21 23:14:24' <= Expiration_Date AND +t1.Document_ID = t2.Document_ID AND +t1.Language_ID = t2.Language_ID AND +t1.Contractor_ID = t2.Contractor_ID AND ( +t2.Customer_ID = '4' OR +t2.Customer_ID = '999999' OR +t2.Customer_ID = '1' )AND t2.CanRead += '1' AND t1.Column_ID=t3.Column_ID AND +t1.Language_ID=t3.Language_ID AND ( +t3.Contractor_ID = '4' OR +t3.Contractor_ID = '999999' OR +t3.Contractor_ID = '1') AND +t3.CanRead='1' AND t3.Active='1'; +COUNT(t1.Title) +1 +SELECT DISTINCT COUNT(t1.Title) FROM t1, +t2, t3 WHERE +t1.Document_ID='xep80' AND t1.Contractor_ID='1' AND +t1.Language_ID='ger' AND '2001-12-21 23:14:24' >= +Publishing_Date AND '2001-12-21 23:14:24' <= Expiration_Date AND +t1.Document_ID = t2.Document_ID AND +t1.Language_ID = t2.Language_ID AND +t1.Contractor_ID = t2.Contractor_ID AND ( +t2.Customer_ID = '4' OR +t2.Customer_ID = '999999' OR +t2.Customer_ID = '1' )AND t2.CanRead += '1' AND t1.Column_ID=t3.Column_ID AND +t1.Language_ID=t3.Language_ID AND ( +t3.Contractor_ID = '4' OR +t3.Contractor_ID = '999999' OR +t3.Contractor_ID = '1') AND +t3.CanRead='1' AND t3.Active='1'; +COUNT(t1.Title) +1 +drop table t1,t2,t3; +CREATE TABLE t1 ( +t1_id int(11) default NULL, +t2_id int(11) default NULL, +type enum('Cost','Percent') default NULL, +cost_unit enum('Cost','Unit') default NULL, +min_value double default NULL, +max_value double default NULL, +t3_id int(11) default NULL, +item_id int(11) default NULL +) ENGINE=MyISAM; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (12,5,'Percent','Cost',-1,0,-1,-1),(14,4,'Percent','Cost',-1,0,-1,-1),(18,5,'Percent','Cost',-1,0,-1,-1),(19,4,'Percent','Cost',-1,0,-1,-1),(20,5,'Percent','Cost',100,-1,22,291),(21,5,'Percent','Cost',100,-1,18,291),(22,1,'Percent','Cost',100,-1,6,291),(23,1,'Percent','Cost',100,-1,21,291),(24,1,'Percent','Cost',100,-1,9,291),(25,1,'Percent','Cost',100,-1,4,291),(26,1,'Percent','Cost',100,-1,20,291),(27,4,'Percent','Cost',100,-1,7,202),(28,1,'Percent','Cost',50,-1,-1,137),(29,2,'Percent','Cost',100,-1,4,354),(30,2,'Percent','Cost',100,-1,9,137),(93,2,'Cost','Cost',-1,10000000,-1,-1); +CREATE TABLE t2 ( +id int(10) unsigned NOT NULL auto_increment, +name varchar(255) default NULL, +PRIMARY KEY (id) +) ENGINE=MyISAM; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (1,'s1'),(2,'s2'),(3,'s3'),(4,'s4'),(5,'s5'); +select t1.*, t2.* from t1, t2 where t2.id=t1.t2_id limit 2; +t1_id t2_id type cost_unit min_value max_value t3_id item_id id name +12 5 Percent Cost -1 0 -1 -1 5 s5 +14 4 Percent Cost -1 0 -1 -1 4 s4 +drop table t1,t2; +CREATE TABLE t1 ( +siteid varchar(25) NOT NULL default '', +emp_id varchar(30) NOT NULL default '', +rate_code varchar(10) default NULL, +UNIQUE KEY site_emp (siteid,emp_id), +KEY siteid (siteid) +) ENGINE=MyISAM; +INSERT INTO t1 VALUES ('rivercats','psmith','cust'), ('rivercats','KWalker','cust'); +CREATE TABLE t2 ( +siteid varchar(25) NOT NULL default '', +rate_code varchar(10) NOT NULL default '', +base_rate float NOT NULL default '0', +PRIMARY KEY (siteid,rate_code), +FULLTEXT KEY rate_code (rate_code) +) ENGINE=MyISAM; +INSERT INTO t2 VALUES ('rivercats','cust',20); +SELECT emp.rate_code, lr.base_rate FROM t1 AS emp LEFT JOIN t2 AS lr USING (siteid, rate_code) WHERE emp.emp_id = 'psmith' AND lr.siteid = 'rivercats'; +rate_code base_rate +cust 20 +SELECT emp.rate_code, lr.base_rate FROM t1 AS emp LEFT JOIN t2 AS lr USING (siteid, rate_code) WHERE lr.siteid = 'rivercats' AND emp.emp_id = 'psmith'; +rate_code base_rate +cust 20 +SELECT rate_code, lr.base_rate FROM t1 AS emp LEFT JOIN t2 AS lr USING (siteid, rate_code) WHERE emp.emp_id = 'psmith' AND siteid = 'rivercats'; +rate_code base_rate +cust 20 +SELECT rate_code, lr.base_rate FROM t1 AS emp LEFT JOIN t2 AS lr USING (siteid, rate_code) WHERE siteid = 'rivercats' AND emp.emp_id = 'psmith'; +rate_code base_rate +cust 20 +drop table t1,t2; +CREATE TABLE t1 (ID INTEGER NOT NULL PRIMARY KEY, Value1 VARCHAR(255)); +CREATE TABLE t2 (ID INTEGER NOT NULL PRIMARY KEY, Value2 VARCHAR(255)); +INSERT INTO t1 VALUES (1, 'A'); +INSERT INTO t2 VALUES (1, 'B'); +SELECT * FROM t1 NATURAL JOIN t2 WHERE 1 AND (Value1 = 'A' AND Value2 <> 'B'); +ID Value1 Value2 +SELECT * FROM t1 NATURAL JOIN t2 WHERE 1 AND Value1 = 'A' AND Value2 <> 'B'; +ID Value1 Value2 +SELECT * FROM t1 NATURAL JOIN t2 WHERE (Value1 = 'A' AND Value2 <> 'B') AND 1; +ID Value1 Value2 +drop table t1,t2; +CREATE TABLE t1 (a int); +CREATE TABLE t2 (b int); +CREATE TABLE t3 (c int); +SELECT * FROM t1 NATURAL JOIN t2 NATURAL JOIN t3; +a b c +DROP TABLE t1, t2, t3; +create table t1 (i int); +create table t2 (i int); +create table t3 (i int); +insert into t1 values(1),(2); +insert into t2 values(2),(3); +insert into t3 values (2),(4); +select * from t1 natural left join t2; +i +1 +2 +select * from t1 left join t2 on (t1.i=t2.i); +i i +1 NULL +2 2 +select * from t1 natural left join t2 natural left join t3; +i +1 +2 +select * from t1 left join t2 on (t1.i=t2.i) left join t3 on (t2.i=t3.i); +i i i +1 NULL NULL +2 2 2 +select * from t3 natural right join t2; +i +2 +3 +select * from t3 right join t2 on (t3.i=t2.i); +i i +2 2 +NULL 3 +select * from t3 natural right join t2 natural right join t1; +i +1 +2 +select * from t3 right join t2 on (t3.i=t2.i) right join t1 on (t2.i=t1.i); +i i i +2 2 2 +NULL NULL 1 +select * from t1,t2 natural left join t3 order by t1.i,t2.i,t3.i; +i i +1 2 +1 3 +2 2 +2 3 +select * from t1,t2 left join t3 on (t2.i=t3.i) order by t1.i,t2.i,t3.i; +i i i +1 2 2 +1 3 NULL +2 2 2 +2 3 NULL +select t1.i,t2.i,t3.i from t2 natural left join t3,t1 order by t1.i,t2.i,t3.i; +i i i +1 2 2 +1 3 NULL +2 2 2 +2 3 NULL +select t1.i,t2.i,t3.i from t2 left join t3 on (t2.i=t3.i),t1 order by t1.i,t2.i,t3.i; +i i i +1 2 2 +1 3 NULL +2 2 2 +2 3 NULL +select * from t1,t2 natural right join t3 order by t1.i,t2.i,t3.i; +i i +1 4 +1 2 +2 4 +2 2 +select * from t1,t2 right join t3 on (t2.i=t3.i) order by t1.i,t2.i,t3.i; +i i i +1 NULL 4 +1 2 2 +2 NULL 4 +2 2 2 +select t1.i,t2.i,t3.i from t2 natural right join t3,t1 order by t1.i,t2.i,t3.i; +i i i +1 NULL 4 +1 2 2 +2 NULL 4 +2 2 2 +select t1.i,t2.i,t3.i from t2 right join t3 on (t2.i=t3.i),t1 order by t1.i,t2.i,t3.i; +i i i +1 NULL 4 +1 2 2 +2 NULL 4 +2 2 2 +drop table t1,t2,t3; +CREATE TABLE t1 (a int, b int default 0, c int default 1); +INSERT INTO t1 (a) VALUES (1),(2),(3),(4),(5),(6),(7),(8); +INSERT INTO t1 (a) SELECT a + 8 FROM t1; +INSERT INTO t1 (a) SELECT a + 16 FROM t1; +CREATE TABLE t2 (a int, d int, e int default 0); +INSERT INTO t2 (a, d) VALUES (1,1),(2,2),(3,3),(4,4); +INSERT INTO t2 (a, d) SELECT a+4, a+4 FROM t2; +INSERT INTO t2 (a, d) SELECT a+8, a+8 FROM t2; +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN +SELECT STRAIGHT_JOIN t2.e FROM t1,t2 WHERE t2.d=1 AND t1.b=t2.e +ORDER BY t1.b, t1.c; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 32 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 32 100.00 Using temporary; Using filesort +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 16 6.25 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select straight_join `test`.`t2`.`e` AS `e` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`e` = `test`.`t1`.`b`) and (`test`.`t2`.`d` = 1)) order by `test`.`t1`.`b`,`test`.`t1`.`c` +SELECT STRAIGHT_JOIN t2.e FROM t1,t2 WHERE t2.d=1 AND t1.b=t2.e +ORDER BY t1.b, t1.c; +e +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +DROP TABLE t1,t2; +create table t1 (c int, b int); +create table t2 (a int, b int); +create table t3 (b int, c int); +create table t4 (y int, c int); +create table t5 (y int, z int); +create table t6 (a int, c int); +insert into t1 values (10,1); +insert into t1 values (3 ,1); +insert into t1 values (3 ,2); +insert into t2 values (2, 1); +insert into t3 values (1, 3); +insert into t3 values (1,10); +insert into t4 values (11,3); +insert into t4 values (2, 3); +insert into t5 values (11,4); +insert into t6 values (2, 3); +create algorithm=merge view v1a as +select * from t1 natural join t2; +create algorithm=merge view v1b(a,b,c) as +select * from t1 natural join t2; +create algorithm=merge view v1c as +select b as a, c as b, a as c from t1 natural join t2; +create algorithm=merge view v1d(b, a, c) as +select a as c, c as b, b as a from t1 natural join t2; +create algorithm=merge view v2a as +select t1.c, t1.b, t2.a from t1 join (t2 join t4 on b + 1 = y) on t1.c = t4.c; +create algorithm=merge view v2b as +select t1.c as b, t1.b as a, t2.a as c +from t1 join (t2 join t4 on b + 1 = y) on t1.c = t4.c; +create algorithm=merge view v3a as +select * from t1 natural join t2 natural join t3; +create algorithm=merge view v3b as +select * from t1 natural join (t2 natural join t3); +create algorithm=merge view v4 as +select * from v2a natural join v3a; +select * from (t1 natural join t2) natural join (t3 natural join t4); +b c a y +1 3 2 11 +1 3 2 2 +select * from (t1 natural join t2) natural left join (t3 natural join t4); +b c a y +1 10 2 NULL +1 3 2 11 +1 3 2 2 +select * from (t3 natural join t4) natural right join (t1 natural join t2); +b c a y +1 10 2 NULL +1 3 2 11 +1 3 2 2 +select * from (t1 natural left join t2) natural left join (t3 natural left join t4); +b c a y +1 10 2 NULL +1 3 2 11 +1 3 2 2 +2 3 NULL NULL +select * from (t4 natural right join t3) natural right join (t2 natural right join t1); +b c a y +1 10 2 NULL +1 3 2 11 +1 3 2 2 +2 3 NULL NULL +select * from t1 natural join t2 natural join t3 natural join t4; +c b a y +3 1 2 11 +3 1 2 2 +select * from ((t1 natural join t2) natural join t3) natural join t4; +c b a y +3 1 2 11 +3 1 2 2 +select * from t1 natural join (t2 natural join (t3 natural join t4)); +c b a y +3 1 2 11 +3 1 2 2 +select * from t5 natural right join (t4 natural right join ((t2 natural right join t1) natural right join t3)); +y c b a z +11 3 1 2 4 +2 3 1 2 NULL +NULL 10 1 2 NULL +select * from (t1 natural join t2), (t3 natural join t4); +b c a c b y +1 10 2 3 1 11 +1 10 2 3 1 2 +1 3 2 3 1 11 +1 3 2 3 1 2 +select * from t5 natural join ((t1 natural join t2), (t3 natural join t4)); +y z b c a c b +11 4 1 10 2 3 1 +11 4 1 3 2 3 1 +select * from ((t1 natural join t2), (t3 natural join t4)) natural join t5; +y b c a c b z +11 1 10 2 3 1 4 +11 1 3 2 3 1 4 +select * from t5 natural join ((t1 natural join t2) cross join (t3 natural join t4)); +y z b c a c b +11 4 1 10 2 3 1 +11 4 1 3 2 3 1 +select * from ((t1 natural join t2) cross join (t3 natural join t4)) natural join t5; +y b c a c b z +11 1 10 2 3 1 4 +11 1 3 2 3 1 4 +select * from (t1 join t2 using (b)) join (t3 join t4 using (c)) using (c); +c b a b y +3 1 2 1 11 +3 1 2 1 2 +select * from (t1 join t2 using (b)) natural join (t3 join t4 using (c)); +b c a y +1 3 2 11 +1 3 2 2 +select a,b,c from (t1 natural join t2) natural join (t3 natural join t4) +where b + 1 = y or b + 10 = y group by b,c,a having min(b) < max(y) order by a; +a b c +2 1 3 +select * from (t1 natural join t2) natural left join (t3 natural join t4) +where b + 1 = y or b + 10 = y group by b,c,a,y having min(b) < max(y) order by a, y; +b c a y +1 3 2 2 +1 3 2 11 +select * from (t3 natural join t4) natural right join (t1 natural join t2) +where b + 1 = y or b + 10 = y group by b,c,a,y having min(b) < max(y) order by a, y; +b c a y +1 3 2 2 +1 3 2 11 +select * from t1 natural join t2 where t1.c > t2.a; +b c a +1 10 2 +1 3 2 +select * from t1 natural join t2 where t1.b > t2.b; +b c a +select * from t1 natural left join (t4 natural join t5) where t5.z is not NULL; +c b y z +3 1 11 4 +3 2 11 4 +select * from t1 join (t2 join t4 on b + 1 = y) on t1.c = t4.c; +c b a b y c +3 1 2 1 2 3 +3 2 2 1 2 3 +select * from (t2 join t4 on b + 1 = y) join t1 on t1.c = t4.c; +a b y c c b +2 1 2 3 3 1 +2 1 2 3 3 2 +select * from t1 natural join (t2 join t4 on b + 1 = y); +c b a y +3 1 2 2 +select * from (t1 cross join t2) join (t3 cross join t4) on (a < y and t2.b < t3.c); +c b a b b c y c +10 1 2 1 1 10 11 3 +10 1 2 1 1 3 11 3 +3 1 2 1 1 10 11 3 +3 1 2 1 1 3 11 3 +3 2 2 1 1 10 11 3 +3 2 2 1 1 3 11 3 +select * from (t1, t2) join (t3, t4) on (a < y and t2.b < t3.c); +c b a b b c y c +10 1 2 1 1 10 11 3 +10 1 2 1 1 3 11 3 +3 1 2 1 1 10 11 3 +3 1 2 1 1 3 11 3 +3 2 2 1 1 10 11 3 +3 2 2 1 1 3 11 3 +select * from (t1 natural join t2) join (t3 natural join t4) on a = y; +b c a c b y +1 10 2 3 1 2 +1 3 2 3 1 2 +select * from ((t3 join (t1 join t2 on c > a) on t3.b < t2.a) join t4 on y > t1.c) join t5 on z = t1.b + 3; +b c c b a b y c y z +1 10 10 1 2 1 11 3 11 4 +1 10 3 1 2 1 11 3 11 4 +1 3 10 1 2 1 11 3 11 4 +1 3 3 1 2 1 11 3 11 4 +select * from t1 natural join t2 where t1.b > 0; +b c a +1 10 2 +1 3 2 +select * from t1 natural join (t4 natural join t5) where t4.y > 7; +c b y z +3 1 11 4 +3 2 11 4 +select * from (t4 natural join t5) natural join t1 where t4.y > 7; +c y z b +3 11 4 1 +3 11 4 2 +select * from t1 natural left join (t4 natural join t5) where t4.y > 7; +c b y z +3 1 11 4 +3 2 11 4 +select * from (t4 natural join t5) natural right join t1 where t4.y > 7; +c b y z +3 1 11 4 +3 2 11 4 +select * from (t1 natural join t2) join (t3 natural join t4) on t1.b = t3.b; +b c a c b y +1 10 2 3 1 11 +1 10 2 3 1 2 +1 3 2 3 1 11 +1 3 2 3 1 2 +select t1.*, t2.* from t1 natural join t2; +c b a b +10 1 2 1 +3 1 2 1 +select t1.*, t2.*, t3.*, t4.* from (t1 natural join t2) natural join (t3 natural join t4); +c b a b b c y c +3 1 2 1 1 3 11 3 +3 1 2 1 1 3 2 3 +select * from (select * from t1 natural join t2) as t12 +natural join +(select * from t3 natural join t4) as t34; +b c a y +1 3 2 11 +1 3 2 2 +select * from (select * from t1 natural join t2) as t12 +natural left join +(select * from t3 natural join t4) as t34; +b c a y +1 10 2 NULL +1 3 2 11 +1 3 2 2 +select * from (select * from t3 natural join t4) as t34 +natural right join +(select * from t1 natural join t2) as t12; +b c a y +1 10 2 NULL +1 3 2 11 +1 3 2 2 +select * from v1a; +b c a +1 10 2 +1 3 2 +select * from v1b; +a b c +1 10 2 +1 3 2 +select * from v1c; +a b c +1 10 2 +1 3 2 +select * from v1d; +b a c +2 10 1 +2 3 1 +select * from v2a; +c b a +3 1 2 +3 2 2 +select * from v2b; +b a c +3 1 2 +3 2 2 +select * from v3a; +b c a +1 10 2 +1 3 2 +select * from v3b; +c b a +10 1 2 +3 1 2 +select * from v4; +c b a +3 1 2 +select * from v1a natural join v2a; +b c a +1 3 2 +select v2a.* from v1a natural join v2a; +c b a +3 1 2 +select * from v1b join v2a on v1b.b = v2a.c; +a b c c b a +1 3 2 3 1 2 +1 3 2 3 2 2 +select * from v1c join v2a on v1c.b = v2a.c; +a b c c b a +1 3 2 3 1 2 +1 3 2 3 2 2 +select * from v1d join v2a on v1d.a = v2a.c; +b a c c b a +2 3 1 3 1 2 +2 3 1 3 2 2 +select * from v1a join (t3 natural join t4) on a = y; +b c a c b y +1 10 2 3 1 2 +1 3 2 3 1 2 +select * from t1 natural join (t3 cross join t4); +ERROR 23000: Column 'c' in from clause is ambiguous +select * from (t3 cross join t4) natural join t1; +ERROR 23000: Column 'c' in from clause is ambiguous +select * from t1 join (t2, t3) using (b); +ERROR 23000: Column 'b' in from clause is ambiguous +select * from ((t1 natural join t2), (t3 natural join t4)) natural join t6; +ERROR 23000: Column 'c' in from clause is ambiguous +select * from ((t1 natural join t2), (t3 natural join t4)) natural join t6; +ERROR 23000: Column 'c' in from clause is ambiguous +select * from t6 natural join ((t1 natural join t2), (t3 natural join t4)); +ERROR 23000: Column 'c' in from clause is ambiguous +select * from (t1 join t2 on t1.b=t2.b) natural join (t3 natural join t4); +ERROR 23000: Column 'b' in from clause is ambiguous +select * from (t3 natural join t4) natural join (t1 join t2 on t1.b=t2.b); +ERROR 23000: Column 'b' in from clause is ambiguous +select * from (t3 join (t4 natural join t5) on (b < z)) +natural join +(t1 natural join t2); +ERROR 23000: Column 'c' in from clause is ambiguous +select * from (t1 natural join t2) natural join (t3 join (t4 natural join t5) on (b < z)); +ERROR 23000: Column 'c' in from clause is ambiguous +select t1.b from v1a; +ERROR 42S22: Unknown column 't1.b' in 'field list' +select * from v1a join v1b on t1.b = t2.b; +ERROR 42S22: Unknown column 't1.b' in 'on clause' +ANALYZE TABLE mysql.user; +Table Op Msg_type Msg_text +mysql.user analyze status OK +select +statistics.TABLE_NAME, statistics.COLUMN_NAME, statistics.TABLE_CATALOG, statistics.TABLE_SCHEMA, statistics.NON_UNIQUE, statistics.INDEX_SCHEMA, statistics.INDEX_NAME, statistics.SEQ_IN_INDEX, statistics.COLLATION, statistics.SUB_PART, statistics.PACKED, statistics.NULLABLE, statistics.INDEX_TYPE, statistics.COMMENT, +columns.TABLE_CATALOG, columns.TABLE_SCHEMA, columns.COLUMN_DEFAULT, columns.IS_NULLABLE, columns.DATA_TYPE, columns.CHARACTER_MAXIMUM_LENGTH, columns.CHARACTER_OCTET_LENGTH, columns.NUMERIC_PRECISION, columns.NUMERIC_SCALE, columns.CHARACTER_SET_NAME, columns.COLLATION_NAME, columns.COLUMN_TYPE, columns.COLUMN_KEY, columns.EXTRA, columns.PRIVILEGES, columns.COLUMN_COMMENT +from information_schema.statistics join information_schema.columns using(table_name,column_name) where table_name='user'; +TABLE_NAME COLUMN_NAME TABLE_CATALOG TABLE_SCHEMA NON_UNIQUE INDEX_SCHEMA INDEX_NAME SEQ_IN_INDEX COLLATION SUB_PART PACKED NULLABLE INDEX_TYPE COMMENT TABLE_CATALOG TABLE_SCHEMA COLUMN_DEFAULT IS_NULLABLE DATA_TYPE CHARACTER_MAXIMUM_LENGTH CHARACTER_OCTET_LENGTH NUMERIC_PRECISION NUMERIC_SCALE CHARACTER_SET_NAME COLLATION_NAME COLUMN_TYPE COLUMN_KEY EXTRA PRIVILEGES COLUMN_COMMENT +user Host def mysql 0 mysql PRIMARY 1 A NULL NULL BTREE def mysql NO char 255 255 NULL NULL ascii ascii_general_ci char(255) PRI select,insert,update,references +user User def mysql 0 mysql PRIMARY 2 A NULL NULL BTREE def mysql NO char 32 96 NULL NULL utf8 utf8_bin char(32) PRI select,insert,update,references +drop table t1; +drop table t2; +drop table t3; +drop table t4; +drop table t5; +drop table t6; +drop view v1a; +drop view v1b; +drop view v1c; +drop view v1d; +drop view v2a; +drop view v2b; +drop view v3a; +drop view v3b; +drop view v4; +create table t1 (a1 int, a2 int); +create table t2 (a1 int, b int); +create table t3 (c1 int, c2 int); +create table t4 (c2 int); +insert into t1 values (1,1); +insert into t2 values (1,1); +insert into t3 values (1,1); +insert into t4 values (1); +select * from t1 join t2 using (a1) join t3 on b=c1 join t4 using (c2); +c2 a1 a2 b c1 +1 1 1 1 1 +select * from t3 join (t1 join t2 using (a1)) on b=c1 join t4 using (c2); +c2 c1 a1 a2 b +1 1 1 1 1 +select a2 from t1 join t2 using (a1) join t3 on b=c1 join t4 using (c2); +a2 +1 +select a2 from t3 join (t1 join t2 using (a1)) on b=c1 join t4 using (c2); +a2 +1 +select a2 from ((t1 join t2 using (a1)) join t3 on b=c1) join t4 using (c2); +a2 +1 +select a2 from ((t1 natural join t2) join t3 on b=c1) natural join t4; +a2 +1 +drop table t1,t2,t3,t4; +create table t1 (c int, b int); +create table t2 (a int, b int); +create table t3 (b int, c int); +create table t4 (y int, c int); +create table t5 (y int, z int); +insert into t1 values (3,2); +insert into t2 values (1,2); +insert into t3 values (2,3); +insert into t4 values (1,3); +insert into t5 values (1,4); +prepare stmt1 from "select * from ((t3 natural join (t1 natural join t2)) +natural join t4) natural join t5"; +execute stmt1; +y c b a z +1 3 2 1 4 +select * from ((t3 natural join (t1 natural join t2)) natural join t4) +natural join t5; +y c b a z +1 3 2 1 4 +drop table t1, t2, t3, t4, t5; +CREATE TABLE t1 (ID INTEGER, Name VARCHAR(50)); +CREATE TABLE t2 (Test_ID INTEGER); +CREATE VIEW v1 (Test_ID, Description) AS SELECT ID, Name FROM t1; +CREATE TABLE tv1 SELECT Description AS Name FROM v1 JOIN t2 +USING (Test_ID); +DESCRIBE tv1; +Field Type Null Key Default Extra +Name varchar(50) YES NULL +CREATE TABLE tv2 SELECT Description AS Name FROM v1 JOIN t2 +ON v1.Test_ID = t2.Test_ID; +DESCRIBE tv2; +Field Type Null Key Default Extra +Name varchar(50) YES NULL +DROP VIEW v1; +DROP TABLE t1,t2,tv1,tv2; +create table t1 (a int, b int); +insert into t1 values +(NULL, 1), +(NULL, 2), +(NULL, 3), +(NULL, 4); +create table t2 (a int not null, primary key(a)); +insert into t2 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t3 (a int not null, primary key(a)); +insert into t3 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +ANALYZE TABLE t1, t2, t3; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +flush status; +select * from t1, t2, t3 where t3.a=t1.a and t2.a=t1.b; +a b a a +explain select * from t1, t2, t3 where t3.a=t1.a and t2.a=t1.b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +2 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.b 1 100.00 Using index +2 SIMPLE t3 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t3`.`a` AS `a` from `test`.`t1` join `test`.`t2` join `test`.`t3` where ((`test`.`t2`.`a` = `test`.`t1`.`b`) and (`test`.`t3`.`a` = `test`.`t1`.`a`)) +We expect rnd_next=5, and read_key must be 0 because of short-cutting: +show status like 'Handler_read%'; +Variable_name Value +Handler_read_first 2 +Handler_read_key 2 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 5 +drop table t1, t2, t3; +create table t1 (a int); +insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t2 (a int, b int, filler char(100), key(a), key(b)); +create table t3 (a int, b int, filler char(100), key(a), key(b)); +insert into t2 +select @a:= A.a + 10*(B.a + 10*C.a), @a, 'filler' from t1 A, t1 B, t1 C; +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +insert into t3 select * from t2 where a < 800; +ANALYZE TABLE t1, t2, t3; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +explain select * from t2,t3 where t2.a < 400 and t2.b=t3.b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1000 40.00 Parallel execute (4 workers) +2 SIMPLE t2 NULL ALL a,b NULL NULL NULL 1000 40.00 Using where +2 SIMPLE t3 NULL ref b b 5 test.t2.b 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`filler` AS `filler`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t3`.`filler` AS `filler` from `test`.`t2` join `test`.`t3` where ((`test`.`t3`.`b` = `test`.`t2`.`b`) and (`test`.`t2`.`a` < 400)) +drop table t1, t2, t3; +create table t1 (a int); +insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t2 (a int, b int, primary key(a)); +insert into t2 select @v:=A.a+10*B.a, @v from t1 A, t1 B; +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +explain select * from t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL # 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` +show status like '%cost%'; +Variable_name Value +Last_query_cost 1.249000 +select 'The cost of accessing t1 (dont care if it changes' '^'; +The cost of accessing t1 (dont care if it changes +The cost of accessing t1 (dont care if it changes^ +select 'vv: Following query must use ALL(t1), eq_ref(A), eq_ref(B): vv' Z; +Z +vv: Following query must use ALL(t1), eq_ref(A), eq_ref(B): vv +explain select * from t1, t2 a, t2 b where a.a = t1.a and b.a=a.b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 100.00 Using where +2 SIMPLE a NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using where +2 SIMPLE b NULL eq_ref PRIMARY PRIMARY 4 test.a.b 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`a`.`a` AS `a`,`test`.`a`.`b` AS `b`,`test`.`b`.`a` AS `a`,`test`.`b`.`b` AS `b` from `test`.`t1` join `test`.`t2` `a` join `test`.`t2` `b` where ((`test`.`b`.`a` = `test`.`a`.`b`) and (`test`.`a`.`a` = `test`.`t1`.`a`)) +show status like '%cost%'; +Variable_name Value +Last_query_cost 8.249000 +select '^^: The above should be ~= 8 + cost(select * from t1). Value less than 8 is an error' Z; +Z +^^: The above should be ~= 8 + cost(select * from t1). Value less than 8 is an error +drop table t1, t2; +CREATE TABLE t1 (a INT PRIMARY KEY, b INT); +CREATE TABLE t2 (c INT PRIMARY KEY, d INT); +INSERT INTO t1 VALUES(1,NULL),(2,NULL),(3,NULL),(4,NULL); +INSERT INTO t1 SELECT a + 4, b FROM t1; +INSERT INTO t1 SELECT a + 8, b FROM t1; +INSERT INTO t1 SELECT a + 16, b FROM t1; +INSERT INTO t1 SELECT a + 32, b FROM t1; +INSERT INTO t1 SELECT a + 64, b FROM t1; +INSERT INTO t2 SELECT a, b FROM t1; +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN SELECT * FROM t1 JOIN t2 ON b=c ORDER BY a LIMIT 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL PRIMARY 4 NULL 2 100.00 Using where +2 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.b 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`c` AS `c`,`test`.`t2`.`d` AS `d` from `test`.`t1` join `test`.`t2` where (`test`.`t2`.`c` = `test`.`t1`.`b`) order by `test`.`t1`.`a` limit 2 +EXPLAIN SELECT * FROM t1 JOIN t2 ON a=c ORDER BY a LIMIT 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index PRIMARY PRIMARY 4 NULL 2 100.00 NULL +2 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`c` AS `c`,`test`.`t2`.`d` AS `d` from `test`.`t1` join `test`.`t2` where (`test`.`t2`.`c` = `test`.`t1`.`a`) order by `test`.`t1`.`a` limit 2 +SELECT * FROM t1 JOIN t2 ON b=c ORDER BY a LIMIT 2; +a b c d +SELECT * FROM t1 JOIN t2 ON a=c ORDER BY a LIMIT 2; +a b c d +1 NULL 1 NULL +2 NULL 2 NULL +EXPLAIN SELECT * FROM t1 JOIN t2 ON b=c ORDER BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 128 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL PRIMARY 4 NULL 128 100.00 Using where +2 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.b 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`c` AS `c`,`test`.`t2`.`d` AS `d` from `test`.`t1` join `test`.`t2` where (`test`.`t2`.`c` = `test`.`t1`.`b`) order by `test`.`t1`.`a` +EXPLAIN SELECT * FROM t1 JOIN t2 ON a=c ORDER BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 128 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index PRIMARY PRIMARY 4 NULL 128 100.00 NULL +2 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`c` AS `c`,`test`.`t2`.`d` AS `d` from `test`.`t1` join `test`.`t2` where (`test`.`t2`.`c` = `test`.`t1`.`a`) order by `test`.`t1`.`a` +SELECT * FROM t1 JOIN t2 ON b=c ORDER BY a; +a b c d +SELECT * FROM t1 JOIN t2 ON a=c ORDER BY a; +a b c d +1 NULL 1 NULL +2 NULL 2 NULL +3 NULL 3 NULL +4 NULL 4 NULL +5 NULL 5 NULL +6 NULL 6 NULL +7 NULL 7 NULL +8 NULL 8 NULL +9 NULL 9 NULL +10 NULL 10 NULL +11 NULL 11 NULL +12 NULL 12 NULL +13 NULL 13 NULL +14 NULL 14 NULL +15 NULL 15 NULL +16 NULL 16 NULL +17 NULL 17 NULL +18 NULL 18 NULL +19 NULL 19 NULL +20 NULL 20 NULL +21 NULL 21 NULL +22 NULL 22 NULL +23 NULL 23 NULL +24 NULL 24 NULL +25 NULL 25 NULL +26 NULL 26 NULL +27 NULL 27 NULL +28 NULL 28 NULL +29 NULL 29 NULL +30 NULL 30 NULL +31 NULL 31 NULL +32 NULL 32 NULL +33 NULL 33 NULL +34 NULL 34 NULL +35 NULL 35 NULL +36 NULL 36 NULL +37 NULL 37 NULL +38 NULL 38 NULL +39 NULL 39 NULL +40 NULL 40 NULL +41 NULL 41 NULL +42 NULL 42 NULL +43 NULL 43 NULL +44 NULL 44 NULL +45 NULL 45 NULL +46 NULL 46 NULL +47 NULL 47 NULL +48 NULL 48 NULL +49 NULL 49 NULL +50 NULL 50 NULL +51 NULL 51 NULL +52 NULL 52 NULL +53 NULL 53 NULL +54 NULL 54 NULL +55 NULL 55 NULL +56 NULL 56 NULL +57 NULL 57 NULL +58 NULL 58 NULL +59 NULL 59 NULL +60 NULL 60 NULL +61 NULL 61 NULL +62 NULL 62 NULL +63 NULL 63 NULL +64 NULL 64 NULL +65 NULL 65 NULL +66 NULL 66 NULL +67 NULL 67 NULL +68 NULL 68 NULL +69 NULL 69 NULL +70 NULL 70 NULL +71 NULL 71 NULL +72 NULL 72 NULL +73 NULL 73 NULL +74 NULL 74 NULL +75 NULL 75 NULL +76 NULL 76 NULL +77 NULL 77 NULL +78 NULL 78 NULL +79 NULL 79 NULL +80 NULL 80 NULL +81 NULL 81 NULL +82 NULL 82 NULL +83 NULL 83 NULL +84 NULL 84 NULL +85 NULL 85 NULL +86 NULL 86 NULL +87 NULL 87 NULL +88 NULL 88 NULL +89 NULL 89 NULL +90 NULL 90 NULL +91 NULL 91 NULL +92 NULL 92 NULL +93 NULL 93 NULL +94 NULL 94 NULL +95 NULL 95 NULL +96 NULL 96 NULL +97 NULL 97 NULL +98 NULL 98 NULL +99 NULL 99 NULL +100 NULL 100 NULL +101 NULL 101 NULL +102 NULL 102 NULL +103 NULL 103 NULL +104 NULL 104 NULL +105 NULL 105 NULL +106 NULL 106 NULL +107 NULL 107 NULL +108 NULL 108 NULL +109 NULL 109 NULL +110 NULL 110 NULL +111 NULL 111 NULL +112 NULL 112 NULL +113 NULL 113 NULL +114 NULL 114 NULL +115 NULL 115 NULL +116 NULL 116 NULL +117 NULL 117 NULL +118 NULL 118 NULL +119 NULL 119 NULL +120 NULL 120 NULL +121 NULL 121 NULL +122 NULL 122 NULL +123 NULL 123 NULL +124 NULL 124 NULL +125 NULL 125 NULL +126 NULL 126 NULL +127 NULL 127 NULL +128 NULL 128 NULL +DROP TABLE IF EXISTS t1,t2; +# +# Bug #42116: Mysql crash on specific query +# +CREATE TABLE t1 (a INT); +CREATE TABLE t2 (a INT); +CREATE TABLE t3 (a INT, INDEX (a)); +CREATE TABLE t4 (a INT); +CREATE TABLE t5 (a INT); +CREATE TABLE t6 (a INT); +INSERT INTO t1 VALUES (1), (1), (1); +INSERT INTO t2 VALUES +(2), (2), (2), (2), (2), (2), (2), (2), (2), (2); +INSERT INTO t3 VALUES +(3), (3), (3), (3), (3), (3), (3), (3), (3), (3); +ANALYZE TABLE t1, t2, t3, t4, t5, t6; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +test.t4 analyze status OK +test.t5 analyze status OK +test.t6 analyze status OK +EXPLAIN +SELECT * +FROM +t1 JOIN t2 ON t1.a = t2.a +LEFT JOIN +( +( +t3 LEFT JOIN t4 ON t3.a = t4.a +) +LEFT JOIN +( +t5 LEFT JOIN t6 ON t5.a = t6.a +) +ON t4.a = t5.a +) +ON t1.a = t3.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 10 10.00 Using where; Using join buffer (hash join) +2 SIMPLE t3 NULL ref a a 5 test.t1.a 10 100.00 Using where; Using index +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 SIMPLE t5 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 SIMPLE t6 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t4`.`a` AS `a`,`test`.`t5`.`a` AS `a`,`test`.`t6`.`a` AS `a` from `test`.`t1` join `test`.`t2` left join (`test`.`t3` left join `test`.`t4` on((`test`.`t4`.`a` = `test`.`t1`.`a`)) left join (`test`.`t5` left join `test`.`t6` on((`test`.`t6`.`a` = `test`.`t4`.`a`))) on((`test`.`t5`.`a` = `test`.`t4`.`a`))) on(((`test`.`t2`.`a` = `test`.`t1`.`a`) and (`test`.`t3`.`a` = `test`.`t1`.`a`))) where (`test`.`t2`.`a` = `test`.`t1`.`a`) +SELECT * +FROM +t1 JOIN t2 ON t1.a = t2.a +LEFT JOIN +( +( +t3 LEFT JOIN t4 ON t3.a = t4.a +) +LEFT JOIN +( +t5 LEFT JOIN t6 ON t5.a = t6.a +) +ON t4.a = t5.a +) +ON t1.a = t3.a; +a a a a a a +DROP TABLE t1,t2,t3,t4,t5,t6; +# +# Bug#48483: crash in get_best_combination() +# +CREATE TABLE t1(f1 INT); +INSERT INTO t1 VALUES (1),(2); +CREATE VIEW v1 AS SELECT 1 FROM t1 LEFT JOIN t1 AS t2 on 1=1; +EXPLAIN +SELECT 1 FROM v1 right join v1 AS v2 ON RAND(); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` left join `test`.`t1` `t2` on(true) left join (`test`.`t1` left join `test`.`t1` `t2` on(true)) on((0 <> rand())) where true +DROP VIEW v1; +DROP TABLE t1; +# +# Bug#52177 crash with explain, row comparison, join, text field +# +CREATE TABLE t1 (a TINYINT, b TEXT, KEY (a)); +INSERT INTO t1 VALUES (0,''),(0,''); +FLUSH TABLES; +EXPLAIN SELECT 1 FROM t1 LEFT JOIN t1 a ON 1 +WHERE ROW(t1.a, 1111.11) = ROW(1111.11, 1111.11) AND +ROW(t1.b, 1111.11) <=> ROW('',''); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` left join `test`.`t1` `a` on(true) where false +DROP TABLE t1; +# +# Bug #50335: Assertion `!(order->used & map)' in eq_ref_table +# +CREATE TABLE t1 (a INT NOT NULL, b INT NOT NULL, PRIMARY KEY (a,b)); +INSERT INTO t1 VALUES (0,0), (1,1); +SELECT * FROM t1 STRAIGHT_JOIN t1 t2 ON t1.a=t2.a AND t1.a=t2.b ORDER BY t2.a, t1.a; +a b a b +0 0 0 0 +1 1 1 1 +DROP TABLE t1; +End of 5.0 tests. +CREATE TABLE t1 (f1 int); +CREATE TABLE t2 (f1 int); +INSERT INTO t2 VALUES (1); +CREATE VIEW v1 AS SELECT * FROM t2; +PREPARE stmt FROM 'UPDATE t2 AS A NATURAL JOIN v1 B SET B.f1 = 1'; +EXECUTE stmt; +EXECUTE stmt; +DEALLOCATE PREPARE stmt; +DROP VIEW v1; +DROP TABLE t1, t2; +CREATE TABLE t1(a CHAR(9),b INT,KEY(b),KEY(a)) ENGINE=MYISAM; +CREATE TABLE t2(a CHAR(9),b INT,KEY(b),KEY(a)) ENGINE=MYISAM; +INSERT INTO t1 VALUES ('1',null),(null,null); +INSERT INTO t2 VALUES ('1',null),(null,null); +CREATE TABLE mm1(a CHAR(9),b INT,KEY(b),KEY(a)) +ENGINE=MERGE UNION=(t1,t2); +SELECT t1.a FROM mm1,t1; +a +1 +1 +1 +1 +NULL +NULL +NULL +NULL +DROP TABLE t1, t2, mm1; +# +# Bug #54468: crash after item's print() function when ordering/grouping +# by subquery +# +CREATE TABLE t1(a INT, b INT); +INSERT INTO t1 VALUES (), (); +SELECT 1 FROM t1 +GROUP BY +GREATEST(t1.a, +(SELECT 1 FROM +(SELECT t1.b FROM t1,t1 t2 +ORDER BY t1.a, t1.a LIMIT 1) AS d) +); +1 +1 +DROP TABLE t1; +# +# Bug #53544: Server hangs during JOIN query in stored procedure called +# twice in a row +# +CREATE TABLE t1(c INT); +INSERT INTO t1 VALUES (1), (2); +PREPARE stmt FROM "SELECT t2.c AS f1 FROM t1 LEFT JOIN + t1 t2 ON t1.c=t2.c RIGHT JOIN + t1 t3 ON t1.c=t3.c + GROUP BY f1;"; +EXECUTE stmt; +f1 +1 +2 +EXECUTE stmt; +f1 +1 +2 +DEALLOCATE PREPARE stmt; +DROP TABLE t1; +End of 5.1 tests +# +# Bug #59696 Optimizer fails to move WHERE condition on JOIN column +# when joining with a view +# +CREATE TABLE t1 ( +c1 INTEGER NOT NULL +); +INSERT INTO t1 VALUES (1),(2),(3); +CREATE TABLE t2 ( +pk INTEGER NOT NULL, +c1 INTEGER NOT NULL, +PRIMARY KEY (pk) +); +INSERT INTO t2 VALUES (1,4),(3,5),(2,6); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN SELECT t2.pk, t2.c1 FROM t2, t1 +WHERE t2.pk = t1.c1 AND t2.pk >= 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.c1 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`pk` AS `pk`,`test`.`t2`.`c1` AS `c1` from `test`.`t2` join `test`.`t1` where ((`test`.`t2`.`pk` = `test`.`t1`.`c1`) and (`test`.`t1`.`c1` >= 2)) +SELECT t2.pk, t2.c1 FROM t2, t1 +WHERE t2.pk = t1.c1 AND t2.pk >= 2; +pk c1 +2 6 +3 5 +CREATE VIEW v_t2 AS SELECT * FROM t2; +EXPLAIN SELECT v_t2.pk, v_t2.c1 FROM v_t2, t1 +WHERE v_t2.pk = t1.c1 AND v_t2.pk >= 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.c1 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`pk` AS `pk`,`test`.`t2`.`c1` AS `c1` from `test`.`t2` join `test`.`t1` where ((`test`.`t2`.`pk` = `test`.`t1`.`c1`) and (`test`.`t2`.`pk` >= 2)) +SELECT v_t2.pk, v_t2.c1 FROM v_t2, t1 +WHERE v_t2.pk = t1.c1 AND v_t2.pk >= 2; +pk c1 +2 6 +3 5 +DROP VIEW v_t2; +DROP TABLE t1, t2; +# +# Bug 13102033 - CRASH IN COPY_FUNCS IN SQL_SELECT.CC ON JOIN + +# GROUP BY + ORDER BY +# +CREATE TABLE t1 ( +pk INTEGER NOT NULL, +i1 INTEGER NOT NULL, +i2 INTEGER NOT NULL, +PRIMARY KEY (pk) +); +INSERT INTO t1 VALUES (7,8,1), (8,2,2); +CREATE VIEW v1 AS SELECT * FROM t1; +EXPLAIN SELECT t1.pk +FROM v1, t1 +WHERE v1.i2 = 211 +AND v1.i2 > 7 +OR t1.i1 < 3 +GROUP BY t1.pk +ORDER BY v1.i2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using temporary; Using filesort +1 SIMPLE t1 NULL ALL PRIMARY NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` join `test`.`t1` where (((`test`.`t1`.`i2` = 211) and (`test`.`t1`.`i2` > 7)) or (`test`.`t1`.`i1` < 3)) group by `test`.`t1`.`pk` order by `test`.`t1`.`i2` +SELECT t1.pk +FROM v1, t1 +WHERE v1.i2 = 211 +AND v1.i2 > 7 +OR t1.i1 < 3 +GROUP BY t1.pk +ORDER BY v1.i2; +pk +8 +EXPLAIN SELECT t1.pk +FROM v1, t1 +WHERE (v1.i2 = 211 AND v1.i2 > 7) +OR (t1.i1 < 3 AND v1.i2 < 10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 62.50 Using where +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` join `test`.`t1` where (((`test`.`t1`.`i2` = 211) and (`test`.`t1`.`i2` > 7)) or ((`test`.`t1`.`i1` < 3) and (`test`.`t1`.`i2` < 10))) +SELECT t1.pk +FROM v1, t1 +WHERE (v1.i2 = 211 AND v1.i2 > 7) +OR (t1.i1 < 3 AND v1.i2 < 10); +pk +8 +8 +DROP VIEW v1; +DROP TABLE t1; +# +# BUG#11752239 - 43368: STRAIGHT_JOIN DOESN'T WORK FOR NESTED JOINS +# +create table t1(c1 int primary key, c2 char(10)) engine=myisam; +create table t2(c1 int primary key, c2 char(10), ref_t1 int) engine=myisam; +create table t3(c1 int primary key, c2 char(10), ref_t1 int) engine=myisam; +create table t4(c1 int primary key, c2 char(10), ref_t1 int) engine=myisam; +insert into t1 values(1,'a'); +insert into t2 values(1,'a', 1); +insert into t3 values(1,'a', 1); +insert into t3 values(2,'b',2); +insert into t4 values(1,'a', 1); +insert into t4 values(2,'a', 2); +insert into t4 values(3,'a', 3); +insert into t4 values(4,'a', 4); +insert into t1 values(2,'b'); +insert into t1 values(3,'c'); +EXPLAIN SELECT * FROM t4 JOIN (t1 join t3 on t3.ref_t1 = +t1.c1 join t2 on t2.ref_t1 = t1.c1) on t4.ref_t1 = t1.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t4 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`c1` AS `c1`,`test`.`t4`.`c2` AS `c2`,`test`.`t4`.`ref_t1` AS `ref_t1`,'1' AS `c1`,'a' AS `c2`,`test`.`t3`.`c1` AS `c1`,`test`.`t3`.`c2` AS `c2`,`test`.`t3`.`ref_t1` AS `ref_t1`,'1' AS `c1`,'a' AS `c2`,'1' AS `ref_t1` from `test`.`t4` join `test`.`t1` join `test`.`t3` where ((`test`.`t3`.`ref_t1` = '1') and (`test`.`t4`.`ref_t1` = '1')) +EXPLAIN SELECT STRAIGHT_JOIN * FROM t4 JOIN (t1 join t3 on t3.ref_t1 = +t1.c1 join t2 on t2.ref_t1 = t1.c1) on t4.ref_t1 = t1.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t4 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t4.ref_t1 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select straight_join `test`.`t4`.`c1` AS `c1`,`test`.`t4`.`c2` AS `c2`,`test`.`t4`.`ref_t1` AS `ref_t1`,`test`.`t1`.`c1` AS `c1`,`test`.`t1`.`c2` AS `c2`,`test`.`t3`.`c1` AS `c1`,`test`.`t3`.`c2` AS `c2`,`test`.`t3`.`ref_t1` AS `ref_t1`,`test`.`t2`.`c1` AS `c1`,`test`.`t2`.`c2` AS `c2`,`test`.`t2`.`ref_t1` AS `ref_t1` from `test`.`t4` join `test`.`t1` join `test`.`t3` join `test`.`t2` where ((`test`.`t1`.`c1` = `test`.`t4`.`ref_t1`) and (`test`.`t3`.`ref_t1` = `test`.`t4`.`ref_t1`) and (`test`.`t2`.`ref_t1` = `test`.`t4`.`ref_t1`)) +EXPLAIN SELECT * FROM t4 STRAIGHT_JOIN (t1 join t3 on t3.ref_t1 = +t1.c1 join t2 on t2.ref_t1 = t1.c1) on t4.ref_t1 = t1.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t4 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t4.ref_t1 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`c1` AS `c1`,`test`.`t4`.`c2` AS `c2`,`test`.`t4`.`ref_t1` AS `ref_t1`,`test`.`t1`.`c1` AS `c1`,`test`.`t1`.`c2` AS `c2`,`test`.`t3`.`c1` AS `c1`,`test`.`t3`.`c2` AS `c2`,`test`.`t3`.`ref_t1` AS `ref_t1`,`test`.`t2`.`c1` AS `c1`,`test`.`t2`.`c2` AS `c2`,`test`.`t2`.`ref_t1` AS `ref_t1` from `test`.`t4` join `test`.`t1` join `test`.`t3` join `test`.`t2` where ((`test`.`t2`.`ref_t1` = `test`.`t4`.`ref_t1`) and (`test`.`t3`.`ref_t1` = `test`.`t4`.`ref_t1`) and (`test`.`t1`.`c1` = `test`.`t4`.`ref_t1`)) +drop table t1,t2,t3,t4; +# Bug#20455184: Assertion failed: join_cond in optimizer.cc +CREATE TABLE t1(a INTEGER) engine=innodb; +explain SELECT 1 +FROM (SELECT 1 FROM t1 WHERE a) AS q +NATURAL LEFT JOIN t1 +NATURAL LEFT JOIN t1 AS t2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` left join `test`.`t1` on(true) left join `test`.`t1` `t2` on((`test`.`t2`.`a` = `test`.`t1`.`a`)) where (0 <> `test`.`t1`.`a`) +SELECT 1 +FROM (SELECT 1 FROM t1 WHERE a) AS q +NATURAL LEFT JOIN t1 +NATURAL LEFT JOIN t1 AS t2; +1 +explain SELECT 1 +FROM t1 +NATURAL RIGHT JOIN t1 AS t2 +NATURAL RIGHT JOIN (SELECT 1 FROM t1 WHERE a) AS q; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` left join (`test`.`t1` `t2` left join `test`.`t1` on((`test`.`t1`.`a` = `test`.`t2`.`a`))) on(true) where (0 <> `test`.`t1`.`a`) +SELECT 1 +FROM t1 +NATURAL RIGHT JOIN t1 AS t2 +NATURAL RIGHT JOIN (SELECT 1 FROM t1 WHERE a) AS q; +1 +DROP TABLE t1; +# Bug#21045724: Assertion '!table || !table->read_set ... +CREATE TABLE t1 +(pk INTEGER, +dummy VARCHAR(64), +col_check TINYINT, +PRIMARY KEY(pk) +) engine=innodb; +INSERT INTO t1 VALUES (13, '13', 13); +CREATE VIEW v1 AS +SELECT * +FROM t1 +WHERE pk BETWEEN 13 AND 14; +PREPARE st1 FROM " +UPDATE v1 AS a NATURAL JOIN v1 AS b +SET a.dummy = '', b.col_check = NULL "; +EXECUTE st1; +EXECUTE st1; +DEALLOCATE PREPARE st1; +DROP VIEW v1; +DROP TABLE t1; +# Bug#25424289: Assert '!table->has_null_row()' failed in join_read_key +CREATE TABLE t1 +(pk INT, +col_int_key INT DEFAULT NULL, +col_varchar_10_latin1_key VARCHAR(10) DEFAULT NULL, +col_varchar_255_utf8 VARCHAR(255) CHARACTER SET utf8 DEFAULT NULL, +col_int INT DEFAULT NULL, +col_datetime_key datetime DEFAULT NULL, +col_varchar_255_latin1_key VARCHAR(255) DEFAULT NULL, +col_date_key date DEFAULT NULL, +col_datetime datetime DEFAULT NULL, +PRIMARY KEY (pk), +KEY col_date_key (col_date_key) +) charset latin1 ENGINE=MyISAM; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES +(8,9,'h','FDUMQ',-1356726272,'2007-09-02 05:48:23','she','2002-04-02','2002-12-20 17:54:07'); +CREATE TABLE t2 +(pk INT, +col_int INT DEFAULT NULL, +col_int_key INT DEFAULT NULL, +PRIMARY KEY (pk) +) charset latin1 ENGINE=MyISAM; +CREATE TABLE t3 +(col_int INT DEFAULT NULL, +col_int_key INT DEFAULT NULL, +pk INT, +PRIMARY KEY (pk), +KEY test_idx (col_int_key,pk,col_int) +) charset latin1 ENGINE=InnoDB; +INSERT INTO t3 VALUES +(NULL,9, 41), (NULL,-1596719104, 48), (-1068105728,9, 49); +CREATE TABLE t4 +(col_varchar_255_latin1_key VARCHAR(255) DEFAULT NULL, +pk INT, +PRIMARY KEY (pk) +) charset latin1 ENGINE=MyISAM; +INSERT INTO t4 VALUES ('RUXDY',8); +ANALYZE TABLE t1, t2, t3, t4; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status Table is already up to date +test.t3 analyze status OK +test.t4 analyze status OK +explain SELECT alias1.pk AS field5 +FROM t3 AS alias1 +LEFT JOIN t4 AS alias2 +LEFT JOIN t4 AS alias3 +LEFT JOIN t1 AS alias4 +LEFT JOIN t2 AS alias5 +ON alias4.pk = alias5.col_int_key +ON alias3.pk = alias5.col_int +ON alias2.col_varchar_255_latin1_key = alias4.col_varchar_10_latin1_key +RIGHT JOIN t1 AS alias6 +ON alias4.pk = alias6.pk +RIGHT JOIN t4 AS alias7 +ON alias6.pk = alias7.pk +ON alias1.col_int_key = alias6.col_int_key +WHERE alias1.col_int > 5 OR +alias5.col_int > 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE alias1 NULL index NULL test_idx 14 NULL 3 100.00 Using index +1 SIMPLE alias7 NULL index PRIMARY PRIMARY 4 NULL 1 100.00 Using index +1 SIMPLE alias6 NULL eq_ref PRIMARY PRIMARY 4 test.alias7.pk 1 100.00 Using where +1 SIMPLE alias4 NULL eq_ref PRIMARY PRIMARY 4 test.alias6.pk 1 100.00 Using where +1 SIMPLE alias5 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE alias2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE alias3 NULL eq_ref PRIMARY PRIMARY 4 test.alias5.col_int 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`alias1`.`pk` AS `field5` from `test`.`t3` `alias1` left join (`test`.`t4` `alias7` join `test`.`t1` `alias6` left join (`test`.`t4` `alias2` join `test`.`t4` `alias3` join `test`.`t1` `alias4` join `test`.`t2` `alias5`) on(((`test`.`alias3`.`pk` = `test`.`alias5`.`col_int`) and (`test`.`alias4`.`pk` = `test`.`alias7`.`pk`) and (`test`.`alias5`.`col_int_key` = `test`.`alias7`.`pk`) and (`test`.`alias2`.`col_varchar_255_latin1_key` = `test`.`alias4`.`col_varchar_10_latin1_key`)))) on(((`test`.`alias6`.`pk` = `test`.`alias7`.`pk`) and (`test`.`alias6`.`col_int_key` = `test`.`alias1`.`col_int_key`))) where ((`test`.`alias1`.`col_int` > 5) or (`test`.`alias5`.`col_int` > 5)) +SELECT alias1.pk AS field5 +FROM t3 AS alias1 +LEFT JOIN t4 AS alias2 +LEFT JOIN t4 AS alias3 +LEFT JOIN t1 AS alias4 +LEFT JOIN t2 AS alias5 +ON alias4.pk = alias5.col_int_key +ON alias3.pk = alias5.col_int +ON alias2.col_varchar_255_latin1_key = alias4.col_varchar_10_latin1_key +RIGHT JOIN t1 AS alias6 +ON alias4.pk = alias6.pk +RIGHT JOIN t4 AS alias7 +ON alias6.pk = alias7.pk +ON alias1.col_int_key = alias6.col_int_key +WHERE alias1.col_int > 5 OR +alias5.col_int > 5; +field5 +DROP TABLE t1, t2, t3, t4; +# Bug#28727717: Duplicated 'is not null' predicates +create table parent(a int primary key, b int, c int, d int) engine=innodb; +create table eq_child(a int, b int, c int, d int, primary key(a,b)) engine=innodb; +insert into parent values (1,1,1,1); +insert into eq_child select * from parent; +explain format=json select straight_join count(*) from parent +join eq_child as c1 on c1.a = parent.b and c1.b = parent.b +join eq_child as c2 on c2.a = parent.b and c2.b = parent.b +join eq_child as c3 on c3.a = parent.b and c3.b = parent.b +join eq_child as c4 on c4.a = parent.b and c4.b = parent.b +; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.75" + }, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.10", + "prefix_cost": "0.35", + "data_read_per_join": "16" + }, + "used_columns": [ + "count(*)" + ], + "query_block": { + "cost_info": { + "query_cost": "1.75" + }, + "nested_loop": [ + { + "table": { + "select_id": 2, + "table_name": "parent", + "access_type": "ALL", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.10", + "prefix_cost": "0.35", + "data_read_per_join": "24" + }, + "used_columns": [ + "b" + ], + "attached_condition": "(`test`.`parent`.`b` is not null)" + } + }, + { + "table": { + "select_id": 2, + "table_name": "c1", + "access_type": "eq_ref", + "possible_keys": [ + "PRIMARY" + ], + "key": "PRIMARY", + "used_key_parts": [ + "a", + "b" + ], + "key_length": "8", + "ref": [ + "test.parent.b", + "test.parent.b" + ], + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "using_index": true, + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.10", + "prefix_cost": "0.70", + "data_read_per_join": "24" + }, + "used_columns": [ + "a", + "b" + ] + } + }, + { + "table": { + "select_id": 2, + "table_name": "c2", + "access_type": "eq_ref", + "possible_keys": [ + "PRIMARY" + ], + "key": "PRIMARY", + "used_key_parts": [ + "a", + "b" + ], + "key_length": "8", + "ref": [ + "test.parent.b", + "test.parent.b" + ], + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "using_index": true, + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.10", + "prefix_cost": "1.05", + "data_read_per_join": "24" + }, + "used_columns": [ + "a", + "b" + ] + } + }, + { + "table": { + "select_id": 2, + "table_name": "c3", + "access_type": "eq_ref", + "possible_keys": [ + "PRIMARY" + ], + "key": "PRIMARY", + "used_key_parts": [ + "a", + "b" + ], + "key_length": "8", + "ref": [ + "test.parent.b", + "test.parent.b" + ], + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "using_index": true, + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.10", + "prefix_cost": "1.40", + "data_read_per_join": "24" + }, + "used_columns": [ + "a", + "b" + ] + } + }, + { + "table": { + "select_id": 2, + "table_name": "c4", + "access_type": "eq_ref", + "possible_keys": [ + "PRIMARY" + ], + "key": "PRIMARY", + "used_key_parts": [ + "a", + "b" + ], + "key_length": "8", + "ref": [ + "test.parent.b", + "test.parent.b" + ], + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "using_index": true, + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.10", + "prefix_cost": "1.75", + "data_read_per_join": "24" + }, + "used_columns": [ + "a", + "b" + ] + } + } + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select straight_join count(0) AS `count(*)` from `test`.`parent` join `test`.`eq_child` `c1` join `test`.`eq_child` `c2` join `test`.`eq_child` `c3` join `test`.`eq_child` `c4` where ((`test`.`c1`.`a` = `test`.`parent`.`b`) and (`test`.`c1`.`b` = `test`.`parent`.`b`) and (`test`.`c2`.`a` = `test`.`parent`.`b`) and (`test`.`c2`.`b` = `test`.`parent`.`b`) and (`test`.`c3`.`a` = `test`.`parent`.`b`) and (`test`.`c3`.`b` = `test`.`parent`.`b`) and (`test`.`c4`.`a` = `test`.`parent`.`b`) and (`test`.`c4`.`b` = `test`.`parent`.`b`)) +drop table parent, eq_child; +# +# Bug #29954680: BACKWARDS REF SCAN DOES NOT PERFORM LATE NULLS FILTERING +# +CREATE TABLE t (i INTEGER PRIMARY KEY AUTO_INCREMENT, j INTEGER, KEY(j)) ENGINE=InnoDB; +INSERT INTO t VALUES (NULL, NULL); +INSERT INTO t SELECT NULL, NULL FROM t; +INSERT INTO t SELECT NULL, NULL FROM t; +INSERT INTO t SELECT NULL, NULL FROM t; +INSERT INTO t SELECT NULL, NULL FROM t; +INSERT INTO t SELECT NULL, NULL FROM t; +INSERT INTO t SELECT NULL, NULL FROM t; +INSERT INTO t SELECT NULL, NULL FROM t; +INSERT INTO t SELECT NULL, NULL FROM t; +INSERT INTO t SELECT NULL, NULL FROM t; +INSERT INTO t SELECT NULL, NULL FROM t; +INSERT INTO t SELECT NULL, NULL FROM t; +INSERT INTO t SELECT NULL, NULL FROM t; +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +EXPLAIN FORMAT=tree SELECT t1.i AS a, (SELECT t2.i FROM t t2 WHERE t1.j = t2.j ORDER BY j DESC, i DESC LIMIT 1) AS b FROM t t1; +EXPLAIN +-> Index scan on t1 using j (cost=411.60 rows=4096) +-> Select #2 (subquery in projection; dependent) + -> Limit: 1 row(s) (cost=410.97 rows=1) + -> Index lookup on t2 using j (j=t1.j; iterate backwards) (cost=410.97 rows=4096) + +Warnings: +Note 1276 Field or reference 'test.t1.j' of SELECT #2 was resolved in SELECT #1 +FLUSH STATUS; +SELECT t1.i AS a, (SELECT t2.i FROM t t2 WHERE t1.j = t2.j ORDER BY j DESC, i DESC LIMIT 1) AS b FROM t t1; +SHOW STATUS LIKE 'Handler_read_key'; +Variable_name Value +Handler_read_key 1 +DROP TABLE t; +set global default_storage_engine=innodb; +set session default_storage_engine=innodb; +# +# Bug#30350696 REFERENCE FROM DERIVED TABLE JOIN CONDITION TO PRECEDING TABLE COLUMN FAILS +# Bug#11748138 ERROR 1054 (42S22): UNKNOWN COLUMN 'T2.I2' IN 'ON CLAUSE' +# +create table t(a int, b int); +insert into t values(1,10),(2,20); +set optimizer_switch="block_nested_loop=off"; +explain format=tree select t1.*, (select count(*) +from t t2 +left join t t3 on t3.a>t2.a-t1.a) +from t t1; +EXPLAIN +-> Table scan on t1 (cost=0.45 rows=2) +-> Select #2 (subquery in projection; dependent) + -> Aggregate: count(0) + -> Nested loop left join (cost=1.35 rows=4) + -> Table scan on t2 (cost=0.45 rows=2) + -> Filter: (t3.a > (t2.a - t1.a)) (cost=0.35 rows=2) + -> Table scan on t3 (cost=0.35 rows=2) + +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 +select t1.*, (select count(*) +from t t2 +left join t t3 on t3.a>t2.a-t1.a) +from t t1; +a b (select count(*) +from t t2 +left join t t3 on t3.a>t2.a-t1.a) +1 10 3 +2 20 4 +explain format=tree select t1.a, (select count(*) +from t t2 +left join t t3 on t3.a>t2.a-t1.a) +from t t1 +group by t1.a; +EXPLAIN +-> Table scan on (cost=1.26..2.52 rows=2) + -> Temporary table with deduplication (cost=1.91..3.17 rows=2) + -> Table scan on t1 (cost=0.45 rows=2) +-> Select #2 (subquery in projection; dependent) + -> Aggregate: count(0) + -> Nested loop left join (cost=1.35 rows=4) + -> Table scan on t2 (cost=0.45 rows=2) + -> Filter: (t3.a > (t2.a - t1.a)) (cost=0.35 rows=2) + -> Table scan on t3 (cost=0.35 rows=2) + +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 +select t1.a, (select count(*) +from t t2 +left join t t3 on t3.a>t2.a-t1.a) +from t t1 +group by t1.a; +a (select count(*) +from t t2 +left join t t3 on t3.a>t2.a-t1.a) +1 3 +2 4 +create view v1 as select * from t; +explain format=tree select v1.*, (select count(*) +from t t2 +left join t t3 on t3.a>t2.a-v1.a) +from v1; +EXPLAIN +-> Table scan on t (cost=0.45 rows=2) +-> Select #2 (subquery in projection; dependent) + -> Aggregate: count(0) + -> Nested loop left join (cost=1.35 rows=4) + -> Table scan on t2 (cost=0.45 rows=2) + -> Filter: (t3.a > (t2.a - t.a)) (cost=0.35 rows=2) + -> Table scan on t3 (cost=0.35 rows=2) + +Warnings: +Note 1276 Field or reference 'v1.a' of SELECT #2 was resolved in SELECT #1 +select v1.*, (select count(*) +from t t2 +left join t t3 on t3.a>t2.a-v1.a) +from v1; +a b (select count(*) +from t t2 +left join t t3 on t3.a>t2.a-v1.a) +1 10 3 +2 20 4 +drop view v1; +explain format=tree select t1.*, (select * from +(select count(*) +from t t2 +left join t t3 on t3.a>t2.a-t1.a) as dt) +from t t1; +EXPLAIN +-> Table scan on t1 (cost=0.45 rows=2) +-> Select #2 (subquery in projection; dependent) + -> Table scan on dt (cost=2.50..2.50 rows=0) + -> Materialize (cost=2.50..2.50 rows=0) + -> Aggregate: count(0) + -> Nested loop left join (cost=1.35 rows=4) + -> Table scan on t2 (cost=0.45 rows=2) + -> Filter: (t3.a > (t2.a - t1.a)) (cost=0.35 rows=2) + -> Table scan on t3 (cost=0.35 rows=2) + +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #3 was resolved in SELECT #1 +select t1.*, (select * from +(select count(*) +from t t2 +left join t t3 on t3.a>t2.a-t1.a) as dt) +from t t1; +a b (select * from +(select count(*) +from t t2 +left join t t3 on t3.a>t2.a-t1.a) as dt) +1 10 3 +2 20 4 +explain format=tree select t1.*, dt.c +from t t1, +(select count(*) as c +from t t2 +left join t t3 on t3.a>t2.a-t1.a) as dt; +ERROR 42S22: Unknown column 't1.a' in 'on clause' +explain format=tree select t1.*, dt.c +from t t1, +lateral +(select count(*) as c +from t t2 +left join t t3 on t3.a>t2.a-t1.a) as dt; +EXPLAIN +-> Nested loop inner join (cost=7.05 rows=0) + -> Invalidate materialized tables (row from t1) (cost=0.45 rows=2) + -> Table scan on t1 (cost=0.45 rows=2) + -> Table scan on dt (cost=2.50..2.50 rows=0) + -> Materialize (invalidate on row from t1) (cost=2.50..2.50 rows=0) + -> Aggregate: count(0) + -> Nested loop left join (cost=1.35 rows=4) + -> Table scan on t2 (cost=0.45 rows=2) + -> Filter: (t3.a > (t2.a - t1.a)) (cost=0.35 rows=2) + -> Table scan on t3 (cost=0.35 rows=2) + +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 +select t1.*, dt.c +from t t1, +lateral +(select count(*) as c +from t t2 +left join t t3 on t3.a>t2.a-t1.a) as dt; +a b c +1 10 3 +2 20 4 +explain format=tree select t1.*, dt.c +from t t1 cross join +lateral +(select count(*) as c +from t t2 +left join t t3 on t3.a>t2.a-t1.a) as dt; +EXPLAIN +-> Nested loop inner join (cost=7.05 rows=0) + -> Invalidate materialized tables (row from t1) (cost=0.45 rows=2) + -> Table scan on t1 (cost=0.45 rows=2) + -> Table scan on dt (cost=2.50..2.50 rows=0) + -> Materialize (invalidate on row from t1) (cost=2.50..2.50 rows=0) + -> Aggregate: count(0) + -> Nested loop left join (cost=1.35 rows=4) + -> Table scan on t2 (cost=0.45 rows=2) + -> Filter: (t3.a > (t2.a - t1.a)) (cost=0.35 rows=2) + -> Table scan on t3 (cost=0.35 rows=2) + +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 +select t1.*, dt.c +from t t1 cross join +lateral +(select count(*) as c +from t t2 +left join t t3 on t3.a>t2.a-t1.a) as dt; +a b c +1 10 3 +2 20 4 +explain format=tree select t1.*, dt.c +from t t1 join +lateral +(select count(*) as c +from t t2 +left join t t3 on t3.a>t2.a-t1.a) as dt +on true; +EXPLAIN +-> Nested loop inner join (cost=7.05 rows=0) + -> Invalidate materialized tables (row from t1) (cost=0.45 rows=2) + -> Table scan on t1 (cost=0.45 rows=2) + -> Table scan on dt (cost=2.50..2.50 rows=0) + -> Materialize (invalidate on row from t1) (cost=2.50..2.50 rows=0) + -> Aggregate: count(0) + -> Nested loop left join (cost=1.35 rows=4) + -> Table scan on t2 (cost=0.45 rows=2) + -> Filter: (t3.a > (t2.a - t1.a)) (cost=0.35 rows=2) + -> Table scan on t3 (cost=0.35 rows=2) + +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 +select t1.*, dt.c +from t t1 join +lateral +(select count(*) as c +from t t2 +left join t t3 on t3.a>t2.a-t1.a) as dt +on true; +a b c +1 10 3 +2 20 4 +select t1.* from t t0 cross join (t t1 join t t2 on 100=t0.a); +ERROR 42S22: Unknown column 't0.a' in 'on clause' +select t1.* from t t0 cross join (t t1 join t t2 +on 100=(select count(*) +from t t3 +left join t t4 +on t4.a>t3.a-t0.a)); +ERROR 42S22: Unknown column 't0.a' in 'on clause' +select t1.* from t t0 cross join t t1 join t t2 +on 100=(select count(*) +from t t3 +left join t t4 +on t4.a>t3.a-t0.a); +a b +set optimizer_switch=default; +drop table t; +create table t(a int); +insert into t values(1),(2); +set optimizer_switch="firstmatch=off,block_nested_loop=off"; +explain format=tree select * from t t1 +where t1.a in (select dt.a +from t t2 +left join (select * from t t3 where t3.a>t1.a) dt +on true); +EXPLAIN +-> Parallel scan on + -> Nested loop inner join (cost=1.75 rows=4) + -> Filter: (t1.a > t1.a) (cost=0.45 rows=2) + -> PQblock scan on t1 (cost=0.45 rows=2) + -> Limit: 1 row(s) (cost=1.00 rows=2) + -> Nested loop inner join (cost=1.00 rows=2) + -> Filter: (t3.a = t1.a) (cost=0.30 rows=1) + -> Table scan on t3 (cost=0.30 rows=2) + -> Table scan on t2 (cost=0.70 rows=2) + +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #3 was resolved in SELECT #1 +select * from t t1 +where t1.a in (select dt.a +from t t2 +left join (select * from t t3 where t3.a>t1.a) dt +on true); +a +drop table t; +set optimizer_switch=default; +set global default_storage_engine=innodb; +# +# WL#14071: ASSERTION `!(USED_TABS & (~READ_TABLES & ~FILTER_FOR_TABLE))' FAILED +# +CREATE TABLE t1 ( +a INTEGER +); +CREATE TABLE t2 ( +pk INTEGER NOT NULL, +a INTEGER +); +SELECT * FROM +( +t2 LEFT JOIN t2 AS t3 ON t2.pk IS NULL +) LEFT JOIN t1 ON t1.a = t3.a; +pk a pk a a +DROP TABLE t1, t2; +# +# Bug #31924828: WL#14071: HYPERGAPH RETURNS DIFFERENT RESULTS WITH ONLY_FULL_GROUP_BY DISABLED +# +CREATE TABLE t1 ( pk INTEGER ); +INSERT INTO t1 VALUES (1); +CREATE TABLE t2 ( pk INTEGER ); +SELECT * FROM t1 LEFT JOIN t2 ON TRUE WHERE t2.pk <=> 3; +pk pk +DROP TABLE t1, t2; +# +# Bug #31947917: WL#14071: ASAN LEAKS SEEN DURING SHUTDOWN +# +CREATE TABLE A ( pk INTEGER ); +SELECT t1.pk FROM A t1, A t2, A t3, A t4, A t5 GROUP BY t1.pk; +pk +DROP TABLE A; +# +# Bug #32234666: HASHJOINITERATOR::READROWFROMPROBEITERATOR(): ASSERTION `!THD()->IS_ERROR()' FAILED. +# +CREATE TABLE t ( +a BIT(50), +b VARCHAR(22772) character set ucs2, +c INTEGER, +d TINYBLOB, +PRIMARY KEY (a), +KEY i0001 (c,d(163)) +); +INSERT INTO t VALUES (1,'',1,'1'); +INSERT INTO t VALUES (0x03ffffffffffff,'2',0,'2'); +SELECT t2.b FROM t AS t1 +LEFT JOIN t AS t2 ON t2.c < 70 +WHERE t2.a - from_unixtime(0) > 0; +ERROR 22003: BIGINT UNSIGNED value is out of range in '(`test`.`t2`.`a` - (from_unixtime(0)))' +DROP TABLE t; diff --git a/mysql-test/r/join_cache_nojb.result-pq b/mysql-test/r/join_cache_nojb.result-pq new file mode 100644 index 000000000000..037a4746465d --- /dev/null +++ b/mysql-test/r/join_cache_nojb.result-pq @@ -0,0 +1,3247 @@ +set optimizer_switch='block_nested_loop=off,batched_key_access=off'; +set optimizer_switch='mrr_cost_based=off'; +DROP TABLE IF EXISTS t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11; +DROP DATABASE IF EXISTS world; +set names utf8; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +CREATE DATABASE world; +use world; +CREATE TABLE country ( +Code char(3) NOT NULL default '', +Name char(52) NOT NULL default '', +SurfaceArea float(10,2) NOT NULL default '0.00', +Population int(11) NOT NULL default '0', +Capital int(11) default NULL +); +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE city ( +ID int(11) NOT NULL, +Name char(35) NOT NULL default '', +Country char(3) NOT NULL default '', +Population int(11) NOT NULL default '0' +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE countrylanguage ( +Country char(3) NOT NULL default '', +Language char(30) NOT NULL default '', +Percentage float NOT NULL default '0.0' +); +ANALYZE TABLE city, country, countrylanguage; +Table Op Msg_type Msg_text +world.city analyze status OK +world.country analyze status OK +world.countrylanguage analyze status OK +SELECT COUNT(*) FROM country; +COUNT(*) +239 +SELECT COUNT(*) FROM city; +COUNT(*) +4079 +SELECT COUNT(*) FROM countrylanguage; +COUNT(*) +984 +show variables like 'join_buffer_size'; +Variable_name Value +join_buffer_size 262144 +EXPLAIN +SELECT city.Name, country.Name FROM city,country +WHERE city.Country=country.Code AND +country.Name LIKE 'L%' AND city.Population > 100000; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 239 11.11 Parallel execute (2 workers) +2 SIMPLE country NULL ALL NULL NULL NULL NULL 239 11.11 Using where +2 SIMPLE city NULL ALL NULL NULL NULL NULL 4059 3.33 Using where +Warnings: +Note 1003 /* select#1 */ select `world`.`city`.`Name` AS `Name`,`world`.`country`.`Name` AS `Name` from `world`.`city` join `world`.`country` where ((`world`.`city`.`Country` = `world`.`country`.`Code`) and (`world`.`country`.`Name` like 'L%') and (`world`.`city`.`Population` > 100000)) +SELECT city.Name, country.Name FROM city,country +WHERE city.Country=country.Code AND +country.Name LIKE 'L%' AND city.Population > 100000; +Name Name +Beirut Lebanon +Bengasi Libyan Arab Jamahiriya +Daugavpils Latvia +Kaunas Lithuania +Klaipeda Lithuania +Maseru Lesotho +Misrata Libyan Arab Jamahiriya +Monrovia Liberia +Panevezys Lithuania +Riga Latvia +Tripoli Lebanon +Tripoli Libyan Arab Jamahiriya +Vientiane Laos +Vilnius Lithuania +Šiauliai Lithuania +EXPLAIN +SELECT city.Name, country.Name, countrylanguage.Language +FROM city,country,countrylanguage +WHERE city.Country=country.Code AND +countrylanguage.Country=country.Code AND +city.Name LIKE 'L%' AND country.Population > 3000000 AND +countrylanguage.Percentage > 50; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 239 33.33 Parallel execute (2 workers) +2 SIMPLE country NULL ALL NULL NULL NULL NULL 239 33.33 Using where +2 SIMPLE countrylanguage NULL ALL NULL NULL NULL NULL 984 3.33 Using where +2 SIMPLE city NULL ALL NULL NULL NULL NULL 4059 1.11 Using where +Warnings: +Note 1003 /* select#1 */ select `world`.`city`.`Name` AS `Name`,`world`.`country`.`Name` AS `Name`,`world`.`countrylanguage`.`Language` AS `Language` from `world`.`city` join `world`.`country` join `world`.`countrylanguage` where ((`world`.`countrylanguage`.`Country` = `world`.`country`.`Code`) and (`world`.`city`.`Country` = `world`.`country`.`Code`) and (`world`.`city`.`Name` like 'L%') and (`world`.`country`.`Population` > 3000000) and (`world`.`countrylanguage`.`Percentage` > 50)) +SELECT city.Name, country.Name, countrylanguage.Language +FROM city,country,countrylanguage +WHERE city.Country=country.Code AND +countrylanguage.Country=country.Code AND +city.Name LIKE 'L%' AND country.Population > 3000000 AND +countrylanguage.Percentage > 50; +Name Name Language +La Ceiba Honduras Spanish +La Habana Cuba Spanish +La Matanza Argentina Spanish +La Paz Bolivia Spanish +La Paz Mexico Spanish +La Paz Mexico Spanish +La Plata Argentina Spanish +La Rioja Argentina Spanish +La Romana Dominican Republic Spanish +La Serena Chile Spanish +La Spezia Italy Italian +Lafayette United States English +Lages Brazil Portuguese +Lagos de Moreno Mexico Spanish +Lahti Finland Finnish +Laiwu China Chinese +Laiyang China Chinese +Laizhou China Chinese +Lakewood United States English +Lalitapur Nepal Nepali +Lambaré Paraguay Spanish +Lancaster United States English +Langfang China Chinese +Lansing United States English +Lanzhou China Chinese +Lanús Argentina Spanish +Laohekou China Chinese +Laredo United States English +Larisa Greece Greek +Las Heras Argentina Spanish +Las Margaritas Mexico Spanish +Las Palmas de Gran Canaria Spain Spanish +Las Vegas United States English +Lashio (Lasho) Myanmar Burmese +Latakia Syria Arabic +Latina Italy Italian +Lauro de Freitas Brazil Portuguese +Lausanne Switzerland German +Laval Canada English +Le Havre France French +Le Mans France French +Le-Cap-Haïtien Haiti Haiti Creole +Lecce Italy Italian +Leeds United Kingdom English +Leganés Spain Spanish +Legnica Poland Polish +Leicester United Kingdom English +Leiden Netherlands Dutch +Leipzig Germany German +Leiyang China Chinese +Lengshuijiang China Chinese +Leninsk-Kuznetski Russian Federation Russian +Lerdo Mexico Spanish +Lerma Mexico Spanish +Leshan China Chinese +Leverkusen Germany German +Lexington-Fayette United States English +León Mexico Spanish +León Nicaragua Spanish +León Spain Spanish +Lhasa China Chinese +Liangcheng China Chinese +Lianyuan China Chinese +Lianyungang China Chinese +Liaocheng China Chinese +Liaoyang China Chinese +Liaoyuan China Chinese +Liberec Czech Republic Czech +Lida Belarus Belorussian +Liling China Chinese +Lille France French +Lilongwe Malawi Chichewa +Lima Peru Spanish +Limeira Brazil Portuguese +Limoges France French +Linchuan China Chinese +Lincoln United States English +Linfen China Chinese +Linhai China Chinese +Linhares Brazil Portuguese +Linhe China Chinese +Linköping Sweden Swedish +Linqing China Chinese +Linyi China Chinese +Linz Austria German +Lipetsk Russian Federation Russian +Lisboa Portugal Portuguese +Little Rock United States English +Liupanshui China Chinese +Liuzhou China Chinese +Liu´an China Chinese +Liverpool United Kingdom English +Livonia United States English +Livorno Italy Italian +Liyang China Chinese +Liège Belgium Dutch +Ljubertsy Russian Federation Russian +Lleida (Lérida) Spain Spanish +Logroño Spain Spanish +Loja Ecuador Spanish +Lomas de Zamora Argentina Spanish +London Canada English +London United Kingdom English +Londrina Brazil Portuguese +Long Beach United States English +Long Xuyen Vietnam Vietnamese +Longjing China Chinese +Longkou China Chinese +Longueuil Canada English +Longyan China Chinese +Los Angeles Chile Spanish +Los Angeles United States English +Los Cabos Mexico Spanish +Los Teques Venezuela Spanish +Loudi China Chinese +Louisville United States English +Lowell United States English +Lower Hutt New Zealand English +Lubbock United States English +Lublin Poland Polish +Luchou Taiwan Min +Ludwigshafen am Rhein Germany German +Lugansk Ukraine Ukrainian +Lund Sweden Swedish +Lungtan Taiwan Min +Luohe China Chinese +Luoyang China Chinese +Luton United Kingdom English +Lutsk Ukraine Ukrainian +Luxor Egypt Arabic +Luzhou China Chinese +Luziânia Brazil Portuguese +Lviv Ukraine Ukrainian +Lyon France French +Lysytšansk Ukraine Ukrainian +L´Hospitalet de Llobregat Spain Spanish +Lázaro Cárdenas Mexico Spanish +Lódz Poland Polish +Lübeck Germany German +Lünen Germany German +set join_buffer_size=2048; +show variables like 'join_buffer_size'; +Variable_name Value +join_buffer_size 2048 +EXPLAIN +SELECT city.Name, country.Name FROM city,country +WHERE city.Country=country.Code AND +country.Name LIKE 'L%' AND city.Population > 100000; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 239 11.11 Parallel execute (2 workers) +2 SIMPLE country NULL ALL NULL NULL NULL NULL 239 11.11 Using where +2 SIMPLE city NULL ALL NULL NULL NULL NULL 4059 3.33 Using where +Warnings: +Note 1003 /* select#1 */ select `world`.`city`.`Name` AS `Name`,`world`.`country`.`Name` AS `Name` from `world`.`city` join `world`.`country` where ((`world`.`city`.`Country` = `world`.`country`.`Code`) and (`world`.`country`.`Name` like 'L%') and (`world`.`city`.`Population` > 100000)) +SELECT city.Name, country.Name FROM city,country +WHERE city.Country=country.Code AND +country.Name LIKE 'L%' AND city.Population > 100000; +Name Name +Beirut Lebanon +Bengasi Libyan Arab Jamahiriya +Daugavpils Latvia +Kaunas Lithuania +Klaipeda Lithuania +Maseru Lesotho +Misrata Libyan Arab Jamahiriya +Monrovia Liberia +Panevezys Lithuania +Riga Latvia +Tripoli Lebanon +Tripoli Libyan Arab Jamahiriya +Vientiane Laos +Vilnius Lithuania +Šiauliai Lithuania +EXPLAIN +SELECT city.Name, country.Name, countrylanguage.Language +FROM city,country,countrylanguage +WHERE city.Country=country.Code AND +countrylanguage.Country=country.Code AND +city.Name LIKE 'L%' AND country.Population > 3000000 AND +countrylanguage.Percentage > 50; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 239 33.33 Parallel execute (2 workers) +2 SIMPLE country NULL ALL NULL NULL NULL NULL 239 33.33 Using where +2 SIMPLE countrylanguage NULL ALL NULL NULL NULL NULL 984 3.33 Using where +2 SIMPLE city NULL ALL NULL NULL NULL NULL 4059 1.11 Using where +Warnings: +Note 1003 /* select#1 */ select `world`.`city`.`Name` AS `Name`,`world`.`country`.`Name` AS `Name`,`world`.`countrylanguage`.`Language` AS `Language` from `world`.`city` join `world`.`country` join `world`.`countrylanguage` where ((`world`.`countrylanguage`.`Country` = `world`.`country`.`Code`) and (`world`.`city`.`Country` = `world`.`country`.`Code`) and (`world`.`city`.`Name` like 'L%') and (`world`.`country`.`Population` > 3000000) and (`world`.`countrylanguage`.`Percentage` > 50)) +SELECT city.Name, country.Name, countrylanguage.Language +FROM city,country,countrylanguage +WHERE city.Country=country.Code AND +countrylanguage.Country=country.Code AND +city.Name LIKE 'L%' AND country.Population > 3000000 AND +countrylanguage.Percentage > 50; +Name Name Language +La Ceiba Honduras Spanish +La Habana Cuba Spanish +La Matanza Argentina Spanish +La Paz Bolivia Spanish +La Paz Mexico Spanish +La Paz Mexico Spanish +La Plata Argentina Spanish +La Rioja Argentina Spanish +La Romana Dominican Republic Spanish +La Serena Chile Spanish +La Spezia Italy Italian +Lafayette United States English +Lages Brazil Portuguese +Lagos de Moreno Mexico Spanish +Lahti Finland Finnish +Laiwu China Chinese +Laiyang China Chinese +Laizhou China Chinese +Lakewood United States English +Lalitapur Nepal Nepali +Lambaré Paraguay Spanish +Lancaster United States English +Langfang China Chinese +Lansing United States English +Lanzhou China Chinese +Lanús Argentina Spanish +Laohekou China Chinese +Laredo United States English +Larisa Greece Greek +Las Heras Argentina Spanish +Las Margaritas Mexico Spanish +Las Palmas de Gran Canaria Spain Spanish +Las Vegas United States English +Lashio (Lasho) Myanmar Burmese +Latakia Syria Arabic +Latina Italy Italian +Lauro de Freitas Brazil Portuguese +Lausanne Switzerland German +Laval Canada English +Le Havre France French +Le Mans France French +Le-Cap-Haïtien Haiti Haiti Creole +Lecce Italy Italian +Leeds United Kingdom English +Leganés Spain Spanish +Legnica Poland Polish +Leicester United Kingdom English +Leiden Netherlands Dutch +Leipzig Germany German +Leiyang China Chinese +Lengshuijiang China Chinese +Leninsk-Kuznetski Russian Federation Russian +Lerdo Mexico Spanish +Lerma Mexico Spanish +Leshan China Chinese +Leverkusen Germany German +Lexington-Fayette United States English +León Mexico Spanish +León Nicaragua Spanish +León Spain Spanish +Lhasa China Chinese +Liangcheng China Chinese +Lianyuan China Chinese +Lianyungang China Chinese +Liaocheng China Chinese +Liaoyang China Chinese +Liaoyuan China Chinese +Liberec Czech Republic Czech +Lida Belarus Belorussian +Liling China Chinese +Lille France French +Lilongwe Malawi Chichewa +Lima Peru Spanish +Limeira Brazil Portuguese +Limoges France French +Linchuan China Chinese +Lincoln United States English +Linfen China Chinese +Linhai China Chinese +Linhares Brazil Portuguese +Linhe China Chinese +Linköping Sweden Swedish +Linqing China Chinese +Linyi China Chinese +Linz Austria German +Lipetsk Russian Federation Russian +Lisboa Portugal Portuguese +Little Rock United States English +Liupanshui China Chinese +Liuzhou China Chinese +Liu´an China Chinese +Liverpool United Kingdom English +Livonia United States English +Livorno Italy Italian +Liyang China Chinese +Liège Belgium Dutch +Ljubertsy Russian Federation Russian +Lleida (Lérida) Spain Spanish +Logroño Spain Spanish +Loja Ecuador Spanish +Lomas de Zamora Argentina Spanish +London Canada English +London United Kingdom English +Londrina Brazil Portuguese +Long Beach United States English +Long Xuyen Vietnam Vietnamese +Longjing China Chinese +Longkou China Chinese +Longueuil Canada English +Longyan China Chinese +Los Angeles Chile Spanish +Los Angeles United States English +Los Cabos Mexico Spanish +Los Teques Venezuela Spanish +Loudi China Chinese +Louisville United States English +Lowell United States English +Lower Hutt New Zealand English +Lubbock United States English +Lublin Poland Polish +Luchou Taiwan Min +Ludwigshafen am Rhein Germany German +Lugansk Ukraine Ukrainian +Lund Sweden Swedish +Lungtan Taiwan Min +Luohe China Chinese +Luoyang China Chinese +Luton United Kingdom English +Lutsk Ukraine Ukrainian +Luxor Egypt Arabic +Luzhou China Chinese +Luziânia Brazil Portuguese +Lviv Ukraine Ukrainian +Lyon France French +Lysytšansk Ukraine Ukrainian +L´Hospitalet de Llobregat Spain Spanish +Lázaro Cárdenas Mexico Spanish +Lódz Poland Polish +Lübeck Germany German +Lünen Germany German +set join_buffer_size=default; +show variables like 'join_buffer_size'; +Variable_name Value +join_buffer_size 262144 +DROP DATABASE world; +CREATE DATABASE world; +use world; +CREATE TABLE country ( +Code char(3) NOT NULL default '', +Name char(52) NOT NULL default '', +SurfaceArea float(10,2) NOT NULL default '0.00', +Population int(11) NOT NULL default '0', +Capital int(11) default NULL, +PRIMARY KEY (Code), +UNIQUE INDEX (Name) +); +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE city ( +ID int(11) NOT NULL auto_increment, +Name char(35) NOT NULL default '', +Country char(3) NOT NULL default '', +Population int(11) NOT NULL default '0', +PRIMARY KEY (ID), +INDEX (Population), +INDEX (Country) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE countrylanguage ( +Country char(3) NOT NULL default '', +Language char(30) NOT NULL default '', +Percentage float NOT NULL default '0.0', +PRIMARY KEY (Country, Language), +INDEX (Percentage) +); +ANALYZE TABLE city, country, countrylanguage; +Table Op Msg_type Msg_text +world.city analyze status OK +world.country analyze status OK +world.countrylanguage analyze status OK +show variables like 'join_buffer_size'; +Variable_name Value +join_buffer_size 262144 +EXPLAIN +SELECT city.Name, country.Name FROM city,country +WHERE city.country=country.Code AND +country.Name LIKE 'L%' AND city.Population > 100000; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 9 100.00 Parallel execute (1 workers) +2 SIMPLE country NULL range PRIMARY,Name Name 208 NULL 9 100.00 Using where; Using index +2 SIMPLE city NULL ref Population,Country Country 12 world.country.Code 17 87.23 Using where +Warnings: +Note 1003 /* select#1 */ select `world`.`city`.`Name` AS `Name`,`world`.`country`.`Name` AS `Name` from `world`.`city` join `world`.`country` where ((`world`.`city`.`Country` = `world`.`country`.`Code`) and (`world`.`country`.`Name` like 'L%') and (`world`.`city`.`Population` > 100000)) +SELECT city.Name, country.Name FROM city,country +WHERE city.country=country.Code AND +country.Name LIKE 'L%' AND city.Population > 100000; +Name Name +Beirut Lebanon +Bengasi Libyan Arab Jamahiriya +Daugavpils Latvia +Kaunas Lithuania +Klaipeda Lithuania +Maseru Lesotho +Misrata Libyan Arab Jamahiriya +Monrovia Liberia +Panevezys Lithuania +Riga Latvia +Tripoli Lebanon +Tripoli Libyan Arab Jamahiriya +Vientiane Laos +Vilnius Lithuania +Šiauliai Lithuania +EXPLAIN +SELECT city.Name, country.Name, countrylanguage.Language +FROM city,country,countrylanguage +WHERE city.country=country.Code AND +countrylanguage.country=country.Code AND +city.Name LIKE 'L%' AND country.Population > 3000000 AND +countrylanguage.Percentage > 50; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 239 33.33 Parallel execute (2 workers) +2 SIMPLE country NULL ALL PRIMARY NULL NULL NULL 239 33.33 Using where +2 SIMPLE countrylanguage NULL ref PRIMARY,Percentage PRIMARY 12 world.country.Code 4 17.07 Using where +2 SIMPLE city NULL ref Country Country 12 world.country.Code 17 11.11 Using where +Warnings: +Note 1003 /* select#1 */ select `world`.`city`.`Name` AS `Name`,`world`.`country`.`Name` AS `Name`,`world`.`countrylanguage`.`Language` AS `Language` from `world`.`city` join `world`.`country` join `world`.`countrylanguage` where ((`world`.`countrylanguage`.`Country` = `world`.`country`.`Code`) and (`world`.`city`.`Country` = `world`.`country`.`Code`) and (`world`.`city`.`Name` like 'L%') and (`world`.`country`.`Population` > 3000000) and (`world`.`countrylanguage`.`Percentage` > 50)) +SELECT city.Name, country.Name, countrylanguage.Language +FROM city,country,countrylanguage +WHERE city.country=country.Code AND +countrylanguage.country=country.Code AND +city.Name LIKE 'L%' AND country.Population > 3000000 AND +countrylanguage.Percentage > 50; +Name Name Language +La Ceiba Honduras Spanish +La Habana Cuba Spanish +La Matanza Argentina Spanish +La Paz Bolivia Spanish +La Paz Mexico Spanish +La Paz Mexico Spanish +La Plata Argentina Spanish +La Rioja Argentina Spanish +La Romana Dominican Republic Spanish +La Serena Chile Spanish +La Spezia Italy Italian +Lafayette United States English +Lages Brazil Portuguese +Lagos de Moreno Mexico Spanish +Lahti Finland Finnish +Laiwu China Chinese +Laiyang China Chinese +Laizhou China Chinese +Lakewood United States English +Lalitapur Nepal Nepali +Lambaré Paraguay Spanish +Lancaster United States English +Langfang China Chinese +Lansing United States English +Lanzhou China Chinese +Lanús Argentina Spanish +Laohekou China Chinese +Laredo United States English +Larisa Greece Greek +Las Heras Argentina Spanish +Las Margaritas Mexico Spanish +Las Palmas de Gran Canaria Spain Spanish +Las Vegas United States English +Lashio (Lasho) Myanmar Burmese +Latakia Syria Arabic +Latina Italy Italian +Lauro de Freitas Brazil Portuguese +Lausanne Switzerland German +Laval Canada English +Le Havre France French +Le Mans France French +Le-Cap-Haïtien Haiti Haiti Creole +Lecce Italy Italian +Leeds United Kingdom English +Leganés Spain Spanish +Legnica Poland Polish +Leicester United Kingdom English +Leiden Netherlands Dutch +Leipzig Germany German +Leiyang China Chinese +Lengshuijiang China Chinese +Leninsk-Kuznetski Russian Federation Russian +Lerdo Mexico Spanish +Lerma Mexico Spanish +Leshan China Chinese +Leverkusen Germany German +Lexington-Fayette United States English +León Mexico Spanish +León Nicaragua Spanish +León Spain Spanish +Lhasa China Chinese +Liangcheng China Chinese +Lianyuan China Chinese +Lianyungang China Chinese +Liaocheng China Chinese +Liaoyang China Chinese +Liaoyuan China Chinese +Liberec Czech Republic Czech +Lida Belarus Belorussian +Liling China Chinese +Lille France French +Lilongwe Malawi Chichewa +Lima Peru Spanish +Limeira Brazil Portuguese +Limoges France French +Linchuan China Chinese +Lincoln United States English +Linfen China Chinese +Linhai China Chinese +Linhares Brazil Portuguese +Linhe China Chinese +Linköping Sweden Swedish +Linqing China Chinese +Linyi China Chinese +Linz Austria German +Lipetsk Russian Federation Russian +Lisboa Portugal Portuguese +Little Rock United States English +Liupanshui China Chinese +Liuzhou China Chinese +Liu´an China Chinese +Liverpool United Kingdom English +Livonia United States English +Livorno Italy Italian +Liyang China Chinese +Liège Belgium Dutch +Ljubertsy Russian Federation Russian +Lleida (Lérida) Spain Spanish +Logroño Spain Spanish +Loja Ecuador Spanish +Lomas de Zamora Argentina Spanish +London Canada English +London United Kingdom English +Londrina Brazil Portuguese +Long Beach United States English +Long Xuyen Vietnam Vietnamese +Longjing China Chinese +Longkou China Chinese +Longueuil Canada English +Longyan China Chinese +Los Angeles Chile Spanish +Los Angeles United States English +Los Cabos Mexico Spanish +Los Teques Venezuela Spanish +Loudi China Chinese +Louisville United States English +Lowell United States English +Lower Hutt New Zealand English +Lubbock United States English +Lublin Poland Polish +Luchou Taiwan Min +Ludwigshafen am Rhein Germany German +Lugansk Ukraine Ukrainian +Lund Sweden Swedish +Lungtan Taiwan Min +Luohe China Chinese +Luoyang China Chinese +Luton United Kingdom English +Lutsk Ukraine Ukrainian +Luxor Egypt Arabic +Luzhou China Chinese +Luziânia Brazil Portuguese +Lviv Ukraine Ukrainian +Lyon France French +Lysytšansk Ukraine Ukrainian +L´Hospitalet de Llobregat Spain Spanish +Lázaro Cárdenas Mexico Spanish +Lódz Poland Polish +Lübeck Germany German +Lünen Germany German +EXPLAIN +SELECT Name FROM city +WHERE city.country IN (SELECT Code FROM country WHERE country.Name LIKE 'L%') AND +city.Population > 100000; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 9 100.00 Parallel execute (1 workers) +2 SIMPLE country NULL range PRIMARY,Name Name 208 NULL 9 100.00 Using where; Using index +2 SIMPLE city NULL ref Population,Country Country 12 world.country.Code 17 87.23 Using where +Warnings: +Note 1003 /* select#1 */ select `world`.`city`.`Name` AS `Name` from `world`.`country` join `world`.`city` where ((`world`.`city`.`Country` = `world`.`country`.`Code`) and (`world`.`city`.`Population` > 100000) and (`world`.`country`.`Name` like 'L%')) +SELECT Name FROM city +WHERE city.country IN (SELECT Code FROM country WHERE country.Name LIKE 'L%') AND +city.Population > 100000; +Name +Beirut +Bengasi +Daugavpils +Kaunas +Klaipeda +Maseru +Misrata +Monrovia +Panevezys +Riga +Tripoli +Tripoli +Vientiane +Vilnius +Šiauliai +EXPLAIN +SELECT country.Name, IF(ISNULL(countrylanguage.country), NULL, countrylanguage.Percentage) +FROM country LEFT JOIN countrylanguage ON +(countrylanguage.country=country.Code AND Language='English') +WHERE +country.Population > 10000000; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 239 33.33 Parallel execute (2 workers) +2 SIMPLE country NULL ALL NULL NULL NULL NULL 239 33.33 Using where +2 SIMPLE countrylanguage NULL eq_ref PRIMARY PRIMARY 132 world.country.Code,const 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `world`.`country`.`Name` AS `Name`,if((`world`.`countrylanguage`.`Country` is null),NULL,`world`.`countrylanguage`.`Percentage`) AS `IF(ISNULL(countrylanguage.country), NULL, countrylanguage.Percentage)` from `world`.`country` left join `world`.`countrylanguage` on(((`world`.`countrylanguage`.`Language` = 'English') and (`world`.`countrylanguage`.`Country` = `world`.`country`.`Code`))) where (`world`.`country`.`Population` > 10000000) +SELECT country.Name, IF(ISNULL(countrylanguage.country), NULL, countrylanguage.Percentage) +FROM country LEFT JOIN countrylanguage ON +(countrylanguage.country=country.Code AND Language='English') +WHERE +country.Population > 10000000; +Name IF(ISNULL(countrylanguage.country), NULL, countrylanguage.Percentage) +Afghanistan NULL +Algeria NULL +Angola NULL +Argentina NULL +Australia 81.19999694824219 +Bangladesh NULL +Belarus NULL +Belgium NULL +Brazil NULL +Burkina Faso NULL +Cambodia NULL +Cameroon NULL +Canada 60.400001525878906 +Chile NULL +China NULL +Colombia NULL +Congo, The Democratic Republic of the NULL +Cuba NULL +Czech Republic NULL +Côte d’Ivoire NULL +Ecuador NULL +Egypt NULL +Ethiopia NULL +France NULL +Germany NULL +Ghana NULL +Greece NULL +Guatemala NULL +Hungary NULL +India NULL +Indonesia NULL +Iran NULL +Iraq NULL +Italy NULL +Japan 0.10000000149011612 +Kazakstan NULL +Kenya NULL +Madagascar NULL +Malawi NULL +Malaysia 1.600000023841858 +Mali NULL +Mexico NULL +Morocco NULL +Mozambique NULL +Myanmar NULL +Nepal NULL +Netherlands NULL +Niger NULL +Nigeria NULL +North Korea NULL +Pakistan NULL +Peru NULL +Philippines NULL +Poland NULL +Romania NULL +Russian Federation NULL +Saudi Arabia NULL +Somalia NULL +South Africa 8.5 +South Korea NULL +Spain NULL +Sri Lanka NULL +Sudan NULL +Syria NULL +Taiwan NULL +Tanzania NULL +Thailand NULL +Turkey NULL +Uganda NULL +Ukraine NULL +United Kingdom 97.30000305175781 +United States 86.19999694824219 +Uzbekistan NULL +Venezuela NULL +Vietnam NULL +Yemen NULL +Yugoslavia NULL +Zimbabwe 2.200000047683716 +set join_buffer_size=256; +show variables like 'join_buffer_size'; +Variable_name Value +join_buffer_size 256 +EXPLAIN +SELECT city.Name, country.Name FROM city,country +WHERE city.country=country.Code AND +country.Name LIKE 'L%' AND city.Population > 100000; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 9 100.00 Parallel execute (1 workers) +2 SIMPLE country NULL range PRIMARY,Name Name 208 NULL 9 100.00 Using where; Using index +2 SIMPLE city NULL ref Population,Country Country 12 world.country.Code 17 87.23 Using where +Warnings: +Note 1003 /* select#1 */ select `world`.`city`.`Name` AS `Name`,`world`.`country`.`Name` AS `Name` from `world`.`city` join `world`.`country` where ((`world`.`city`.`Country` = `world`.`country`.`Code`) and (`world`.`country`.`Name` like 'L%') and (`world`.`city`.`Population` > 100000)) +SELECT city.Name, country.Name FROM city,country +WHERE city.country=country.Code AND +country.Name LIKE 'L%' AND city.Population > 100000; +Name Name +Beirut Lebanon +Bengasi Libyan Arab Jamahiriya +Daugavpils Latvia +Kaunas Lithuania +Klaipeda Lithuania +Maseru Lesotho +Misrata Libyan Arab Jamahiriya +Monrovia Liberia +Panevezys Lithuania +Riga Latvia +Tripoli Lebanon +Tripoli Libyan Arab Jamahiriya +Vientiane Laos +Vilnius Lithuania +Šiauliai Lithuania +EXPLAIN +SELECT city.Name, country.Name, countrylanguage.Language +FROM city,country,countrylanguage +WHERE city.country=country.Code AND +countrylanguage.country=country.Code AND +city.Name LIKE 'L%' AND country.Population > 3000000 AND +countrylanguage.Percentage > 50; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 239 33.33 Parallel execute (2 workers) +2 SIMPLE country NULL ALL PRIMARY NULL NULL NULL 239 33.33 Using where +2 SIMPLE countrylanguage NULL ref PRIMARY,Percentage PRIMARY 12 world.country.Code 4 17.07 Using where +2 SIMPLE city NULL ref Country Country 12 world.country.Code 17 11.11 Using where +Warnings: +Note 1003 /* select#1 */ select `world`.`city`.`Name` AS `Name`,`world`.`country`.`Name` AS `Name`,`world`.`countrylanguage`.`Language` AS `Language` from `world`.`city` join `world`.`country` join `world`.`countrylanguage` where ((`world`.`countrylanguage`.`Country` = `world`.`country`.`Code`) and (`world`.`city`.`Country` = `world`.`country`.`Code`) and (`world`.`city`.`Name` like 'L%') and (`world`.`country`.`Population` > 3000000) and (`world`.`countrylanguage`.`Percentage` > 50)) +SELECT city.Name, country.Name, countrylanguage.Language +FROM city,country,countrylanguage +WHERE city.country=country.Code AND +countrylanguage.country=country.Code AND +city.Name LIKE 'L%' AND country.Population > 3000000 AND +countrylanguage.Percentage > 50; +Name Name Language +La Ceiba Honduras Spanish +La Habana Cuba Spanish +La Matanza Argentina Spanish +La Paz Bolivia Spanish +La Paz Mexico Spanish +La Paz Mexico Spanish +La Plata Argentina Spanish +La Rioja Argentina Spanish +La Romana Dominican Republic Spanish +La Serena Chile Spanish +La Spezia Italy Italian +Lafayette United States English +Lages Brazil Portuguese +Lagos de Moreno Mexico Spanish +Lahti Finland Finnish +Laiwu China Chinese +Laiyang China Chinese +Laizhou China Chinese +Lakewood United States English +Lalitapur Nepal Nepali +Lambaré Paraguay Spanish +Lancaster United States English +Langfang China Chinese +Lansing United States English +Lanzhou China Chinese +Lanús Argentina Spanish +Laohekou China Chinese +Laredo United States English +Larisa Greece Greek +Las Heras Argentina Spanish +Las Margaritas Mexico Spanish +Las Palmas de Gran Canaria Spain Spanish +Las Vegas United States English +Lashio (Lasho) Myanmar Burmese +Latakia Syria Arabic +Latina Italy Italian +Lauro de Freitas Brazil Portuguese +Lausanne Switzerland German +Laval Canada English +Le Havre France French +Le Mans France French +Le-Cap-Haïtien Haiti Haiti Creole +Lecce Italy Italian +Leeds United Kingdom English +Leganés Spain Spanish +Legnica Poland Polish +Leicester United Kingdom English +Leiden Netherlands Dutch +Leipzig Germany German +Leiyang China Chinese +Lengshuijiang China Chinese +Leninsk-Kuznetski Russian Federation Russian +Lerdo Mexico Spanish +Lerma Mexico Spanish +Leshan China Chinese +Leverkusen Germany German +Lexington-Fayette United States English +León Mexico Spanish +León Nicaragua Spanish +León Spain Spanish +Lhasa China Chinese +Liangcheng China Chinese +Lianyuan China Chinese +Lianyungang China Chinese +Liaocheng China Chinese +Liaoyang China Chinese +Liaoyuan China Chinese +Liberec Czech Republic Czech +Lida Belarus Belorussian +Liling China Chinese +Lille France French +Lilongwe Malawi Chichewa +Lima Peru Spanish +Limeira Brazil Portuguese +Limoges France French +Linchuan China Chinese +Lincoln United States English +Linfen China Chinese +Linhai China Chinese +Linhares Brazil Portuguese +Linhe China Chinese +Linköping Sweden Swedish +Linqing China Chinese +Linyi China Chinese +Linz Austria German +Lipetsk Russian Federation Russian +Lisboa Portugal Portuguese +Little Rock United States English +Liupanshui China Chinese +Liuzhou China Chinese +Liu´an China Chinese +Liverpool United Kingdom English +Livonia United States English +Livorno Italy Italian +Liyang China Chinese +Liège Belgium Dutch +Ljubertsy Russian Federation Russian +Lleida (Lérida) Spain Spanish +Logroño Spain Spanish +Loja Ecuador Spanish +Lomas de Zamora Argentina Spanish +London Canada English +London United Kingdom English +Londrina Brazil Portuguese +Long Beach United States English +Long Xuyen Vietnam Vietnamese +Longjing China Chinese +Longkou China Chinese +Longueuil Canada English +Longyan China Chinese +Los Angeles Chile Spanish +Los Angeles United States English +Los Cabos Mexico Spanish +Los Teques Venezuela Spanish +Loudi China Chinese +Louisville United States English +Lowell United States English +Lower Hutt New Zealand English +Lubbock United States English +Lublin Poland Polish +Luchou Taiwan Min +Ludwigshafen am Rhein Germany German +Lugansk Ukraine Ukrainian +Lund Sweden Swedish +Lungtan Taiwan Min +Luohe China Chinese +Luoyang China Chinese +Luton United Kingdom English +Lutsk Ukraine Ukrainian +Luxor Egypt Arabic +Luzhou China Chinese +Luziânia Brazil Portuguese +Lviv Ukraine Ukrainian +Lyon France French +Lysytšansk Ukraine Ukrainian +L´Hospitalet de Llobregat Spain Spanish +Lázaro Cárdenas Mexico Spanish +Lódz Poland Polish +Lübeck Germany German +Lünen Germany German +EXPLAIN +SELECT Name FROM city +WHERE city.country IN (SELECT Code FROM country WHERE country.Name LIKE 'L%') AND +city.Population > 100000; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 9 100.00 Parallel execute (1 workers) +2 SIMPLE country NULL range PRIMARY,Name Name 208 NULL 9 100.00 Using where; Using index +2 SIMPLE city NULL ref Population,Country Country 12 world.country.Code 17 87.23 Using where +Warnings: +Note 1003 /* select#1 */ select `world`.`city`.`Name` AS `Name` from `world`.`country` join `world`.`city` where ((`world`.`city`.`Country` = `world`.`country`.`Code`) and (`world`.`city`.`Population` > 100000) and (`world`.`country`.`Name` like 'L%')) +SELECT Name FROM city +WHERE city.country IN (SELECT Code FROM country WHERE country.Name LIKE 'L%') AND +city.Population > 100000; +Name +Beirut +Bengasi +Daugavpils +Kaunas +Klaipeda +Maseru +Misrata +Monrovia +Panevezys +Riga +Tripoli +Tripoli +Vientiane +Vilnius +Šiauliai +set join_buffer_size=default; +show variables like 'join_buffer_size'; +Variable_name Value +join_buffer_size 262144 +SELECT city.Name, country.Name FROM city,country +WHERE city.country=country.Code AND city.Population > 3000000; +Name Name +Alexandria Egypt +Ankara Turkey +Baghdad Iraq +Bangkok Thailand +Berlin Germany +Cairo Egypt +Calcutta [Kolkata] India +Chengdu China +Chennai (Madras) India +Chongqing China +Ciudad de México Mexico +Delhi India +Dhaka Bangladesh +Harbin China +Ho Chi Minh City Vietnam +Istanbul Turkey +Jakarta Indonesia +Jokohama [Yokohama] Japan +Kanton [Guangzhou] China +Karachi Pakistan +Kinshasa Congo, The Democratic Republic of the +Lahore Pakistan +Lima Peru +London United Kingdom +Los Angeles United States +Moscow Russian Federation +Mumbai (Bombay) India +New York United States +Peking China +Pusan South Korea +Rangoon (Yangon) Myanmar +Rio de Janeiro Brazil +Riyadh Saudi Arabia +Santafé de Bogotá Colombia +Santiago de Chile Chile +Seoul South Korea +Shanghai China +Shenyang China +Singapore Singapore +St Petersburg Russian Federation +Sydney Australia +São Paulo Brazil +Teheran Iran +Tianjin China +Tokyo Japan +Wuhan China +set join_buffer_size=256; +EXPLAIN +SELECT city.Name, country.Name FROM city,country +WHERE city.country=country.Code AND city.Population > 3000000; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (1 workers) +2 SIMPLE city NULL range Population,Country Population 4 NULL # 100.00 Using index condition; Using MRR +2 SIMPLE country NULL eq_ref PRIMARY PRIMARY 12 world.city.Country # 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `world`.`city`.`Name` AS `Name`,`world`.`country`.`Name` AS `Name` from `world`.`city` join `world`.`country` where ((`world`.`country`.`Code` = `world`.`city`.`Country`) and (`world`.`city`.`Population` > 3000000)) +SELECT city.Name, country.Name FROM city,country +WHERE city.country=country.Code AND city.Population > 3000000; +Name Name +Alexandria Egypt +Ankara Turkey +Baghdad Iraq +Bangkok Thailand +Berlin Germany +Cairo Egypt +Calcutta [Kolkata] India +Chengdu China +Chennai (Madras) India +Chongqing China +Ciudad de México Mexico +Delhi India +Dhaka Bangladesh +Harbin China +Ho Chi Minh City Vietnam +Istanbul Turkey +Jakarta Indonesia +Jokohama [Yokohama] Japan +Kanton [Guangzhou] China +Karachi Pakistan +Kinshasa Congo, The Democratic Republic of the +Lahore Pakistan +Lima Peru +London United Kingdom +Los Angeles United States +Moscow Russian Federation +Mumbai (Bombay) India +New York United States +Peking China +Pusan South Korea +Rangoon (Yangon) Myanmar +Rio de Janeiro Brazil +Riyadh Saudi Arabia +Santafé de Bogotá Colombia +Santiago de Chile Chile +Seoul South Korea +Shanghai China +Shenyang China +Singapore Singapore +St Petersburg Russian Federation +Sydney Australia +São Paulo Brazil +Teheran Iran +Tianjin China +Tokyo Japan +Wuhan China +set join_buffer_size=default; +ALTER TABLE country MODIFY Name varchar(52) NOT NULL default ''; +SELECT city.Name, country.Name FROM city,country +WHERE city.country=country.Code AND +country.Name LIKE 'L%' AND city.Population > 100000; +Name Name +Beirut Lebanon +Bengasi Libyan Arab Jamahiriya +Daugavpils Latvia +Kaunas Lithuania +Klaipeda Lithuania +Maseru Lesotho +Misrata Libyan Arab Jamahiriya +Monrovia Liberia +Panevezys Lithuania +Riga Latvia +Tripoli Lebanon +Tripoli Libyan Arab Jamahiriya +Vientiane Laos +Vilnius Lithuania +Šiauliai Lithuania +ALTER TABLE country MODIFY Name varchar(250) NOT NULL default ''; +SELECT city.Name, country.Name FROM city,country +WHERE city.country=country.Code AND +country.Name LIKE 'L%' AND city.Population > 100000; +Name Name +Beirut Lebanon +Bengasi Libyan Arab Jamahiriya +Daugavpils Latvia +Kaunas Lithuania +Klaipeda Lithuania +Maseru Lesotho +Misrata Libyan Arab Jamahiriya +Monrovia Liberia +Panevezys Lithuania +Riga Latvia +Tripoli Lebanon +Tripoli Libyan Arab Jamahiriya +Vientiane Laos +Vilnius Lithuania +Šiauliai Lithuania +ALTER TABLE country ADD COLUMN PopulationBar text; +UPDATE country +SET PopulationBar=REPEAT('x', CAST(Population/100000 AS unsigned int)); +SELECT city.Name, country.Name, country.PopulationBar FROM city,country +WHERE city.country=country.Code AND +country.Name LIKE 'L%' AND city.Population > 100000; +Name Name PopulationBar +Beirut Lebanon xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx +Bengasi Libyan Arab Jamahiriya xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx +Daugavpils Latvia xxxxxxxxxxxxxxxxxxxxxxxx +Kaunas Lithuania xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx +Klaipeda Lithuania xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx +Maseru Lesotho xxxxxxxxxxxxxxxxxxxxxx +Misrata Libyan Arab Jamahiriya xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx +Monrovia Liberia xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx +Panevezys Lithuania xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx +Riga Latvia xxxxxxxxxxxxxxxxxxxxxxxx +Tripoli Lebanon xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx +Tripoli Libyan Arab Jamahiriya xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx +Vientiane Laos xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx +Vilnius Lithuania xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx +Šiauliai Lithuania xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx +set join_buffer_size=256; +SELECT city.Name, country.Name, country.PopulationBar FROM city,country +WHERE city.country=country.Code AND +country.Name LIKE 'L%' AND city.Population > 100000; +Name Name PopulationBar +Beirut Lebanon xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx +Bengasi Libyan Arab Jamahiriya xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx +Daugavpils Latvia xxxxxxxxxxxxxxxxxxxxxxxx +Kaunas Lithuania xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx +Klaipeda Lithuania xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx +Maseru Lesotho xxxxxxxxxxxxxxxxxxxxxx +Misrata Libyan Arab Jamahiriya xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx +Monrovia Liberia xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx +Panevezys Lithuania xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx +Riga Latvia xxxxxxxxxxxxxxxxxxxxxxxx +Tripoli Lebanon xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx +Tripoli Libyan Arab Jamahiriya xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx +Vientiane Laos xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx +Vilnius Lithuania xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx +Šiauliai Lithuania xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx +set join_buffer_size=default; +DROP DATABASE world; +use test; +CREATE TABLE t1( +affiliatetometaid int NOT NULL default '0', +uniquekey int NOT NULL default '0', +metaid int NOT NULL default '0', +affiliateid int NOT NULL default '0', +xml text, +isactive char(1) NOT NULL default 'Y', +PRIMARY KEY (affiliatetometaid) +); +CREATE UNIQUE INDEX t1_uniquekey ON t1(uniquekey); +CREATE INDEX t1_affiliateid ON t1(affiliateid); +CREATE INDEX t1_metaid on t1 (metaid); +INSERT INTO t1 VALUES +(1616, 1571693233, 1391, 2, NULL, 'Y'), (1943, 1993216749, 1726, 2, NULL, 'Y'); +CREATE TABLE t2( +metaid int NOT NULL default '0', +name varchar(80) NOT NULL default '', +dateadded timestamp NOT NULL , +xml text, +status int default NULL, +origin int default NULL, +gid int NOT NULL default '1', +formattypeid int default NULL, +PRIMARY KEY (metaid) +); +CREATE INDEX t2_status ON t2(status); +CREATE INDEX t2_gid ON t2(gid); +CREATE INDEX t2_formattypeid ON t2(formattypeid); +INSERT INTO t2 VALUES +(1391, "I Just Died", "2003-10-02 10:07:37", "", 1, NULL, 3, NULL), +(1726, "Me, Myself & I", "2003-12-05 11:24:36", " ", 1, NULL, 3, NULL); +CREATE TABLE t3( +mediaid int NOT NULL , +metaid int NOT NULL default '0', +formatid int NOT NULL default '0', +status int default NULL, +path varchar(100) NOT NULL default '', +datemodified timestamp NOT NULL , +resourcetype int NOT NULL default '1', +parameters text, +signature int default NULL, +quality int NOT NULL default '255', +PRIMARY KEY (mediaid) +); +CREATE INDEX t3_metaid ON t3(metaid); +CREATE INDEX t3_formatid ON t3(formatid); +CREATE INDEX t3_status ON t3(status); +CREATE INDEX t3_metaidformatid ON t3(metaid,formatid); +CREATE INDEX t3_signature ON t3(signature); +CREATE INDEX t3_quality ON t3(quality); +INSERT INTO t3 VALUES +(6, 4, 8, 0, "010101_anastacia_spmidi.mid", "2004-03-16 13:40:00", 1, NULL, NULL, 255), +(3343, 3, 8, 1, "010102_4VN4bsPwnxRQUJW5Zp1RhG2IL9vvl_8.mid", "2004-03-16 13:40:00", 1, NULL, NULL, 255); +CREATE TABLE t4( +formatid int NOT NULL , +name varchar(60) NOT NULL default '', +formatclassid int NOT NULL default '0', +mime varchar(60) default NULL, +extension varchar(10) default NULL, +priority int NOT NULL default '0', +canaddtocapability char(1) NOT NULL default 'Y', +PRIMARY KEY (formatid) +); +CREATE INDEX t4_formatclassid ON t4(formatclassid); +CREATE INDEX t4_formats_idx ON t4(canaddtocapability); +INSERT INTO t4 VALUES +(19, "XHTML", 11, "text/html", "xhtml", 10, 'Y'), +(54, "AMR (wide band)", 13, "audio/amr-wb", "awb", 0, 'Y'); +CREATE TABLE t5( +formatclassid int NOT NULL , +name varchar(60) NOT NULL default '', +priority int NOT NULL default '0', +formattypeid int NOT NULL default '0', +PRIMARY KEY (formatclassid) +); +CREATE INDEX t5_formattypeid on t5(formattypeid); +INSERT INTO t5 VALUES +(11, "Info", 0, 4), (13, "Digital Audio", 0, 2); +CREATE TABLE t6( +formattypeid int NOT NULL , +name varchar(60) NOT NULL default '', +priority int default NULL, +PRIMARY KEY (formattypeid) +); +INSERT INTO t6 VALUES +(2, "Ringtones", 0); +CREATE TABLE t7( +metaid int NOT NULL default '0', +artistid int NOT NULL default '0', +PRIMARY KEY (metaid,artistid) +); +INSERT INTO t7 VALUES +(4, 5), (3, 4); +CREATE TABLE t8( +artistid int NOT NULL , +name varchar(80) NOT NULL default '', +PRIMARY KEY (artistid) +); +INSERT INTO t8 VALUES +(5, "Anastacia"), (4, "John Mayer"); +CREATE TABLE t9( +subgenreid int NOT NULL default '0', +metaid int NOT NULL default '0', +PRIMARY KEY (subgenreid,metaid) +) ; +CREATE INDEX t9_subgenreid ON t9(subgenreid); +CREATE INDEX t9_metaid ON t9(metaid); +INSERT INTO t9 VALUES +(138, 4), (31, 3); +CREATE TABLE t10( +subgenreid int NOT NULL , +genreid int NOT NULL default '0', +name varchar(80) NOT NULL default '', +PRIMARY KEY (subgenreid) +) ; +CREATE INDEX t10_genreid ON t10(genreid); +INSERT INTO t10 VALUES +(138, 19, ''), (31, 3, ''); +CREATE TABLE t11( +genreid int NOT NULL default '0', +name char(80) NOT NULL default '', +priority int NOT NULL default '0', +masterclip char(1) default NULL, +PRIMARY KEY (genreid) +) ; +CREATE INDEX t11_masterclip ON t11( masterclip); +INSERT INTO t11 VALUES +(19, "Pop & Dance", 95, 'Y'), (3, "Rock & Alternative", 100, 'Y'); +ANALYZE TABLE t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +test.t4 analyze status OK +test.t5 analyze status OK +test.t6 analyze status OK +test.t7 analyze status OK +test.t8 analyze status OK +test.t9 analyze status OK +test.t10 analyze status OK +test.t11 analyze status OK +EXPLAIN +SELECT t1.uniquekey, t1.xml AS affiliateXml, +t8.name AS artistName, t8.artistid, +t11.name AS genreName, t11.genreid, t11.priority AS genrePriority, +t10.subgenreid, t10.name AS subgenreName, +t2.name AS metaName, t2.metaid, t2.xml AS metaXml, +t4.priority + t5.priority + t6.priority AS overallPriority, +t3.path AS path, t3.mediaid, +t4.formatid, t4.name AS formatName, +t5.formatclassid, t5.name AS formatclassName, +t6.formattypeid, t6.name AS formattypeName +FROM t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11 +WHERE t7.metaid = t2.metaid AND t7.artistid = t8.artistid AND +t9.metaid = t2.metaid AND t9.subgenreid = t10.subgenreid AND +t10.genreid = t11.genreid AND t3.metaid = t2.metaid AND +t3.formatid = t4.formatid AND t4.formatclassid = t5.formatclassid AND +t4.canaddtocapability = 'Y' AND t5.formattypeid = t6.formattypeid AND +t6.formattypeid IN (2) AND (t3.formatid IN (31, 8, 76)) AND +t1.metaid = t2.metaid AND t1.affiliateid = '2'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ref t1_affiliateid,t1_metaid t1_metaid 4 test.t7.metaid 1 100.00 Using where +1 SIMPLE t10 NULL eq_ref PRIMARY,t10_genreid PRIMARY 4 test.t9.subgenreid 1 100.00 NULL +1 SIMPLE t11 NULL eq_ref PRIMARY PRIMARY 4 test.t10.genreid 1 100.00 NULL +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t7.metaid 1 100.00 NULL +1 SIMPLE t3 NULL ref t3_metaid,t3_formatid,t3_metaidformatid t3_metaid 4 test.t7.metaid 1 100.00 Using where +1 SIMPLE t4 NULL ref PRIMARY,t4_formatclassid,t4_formats_idx t4_formatclassid 4 test.t5.formatclassid 1 100.00 Using index condition; Using where +1 SIMPLE t5 NULL ref PRIMARY,t5_formattypeid t5_formattypeid 4 const 1 100.00 NULL +1 SIMPLE t6 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +1 SIMPLE t7 NULL index PRIMARY PRIMARY 8 NULL 2 50.00 Using where; Using index +1 SIMPLE t8 NULL ALL PRIMARY NULL NULL NULL 2 100.00 NULL +1 SIMPLE t9 NULL ref PRIMARY,t9_subgenreid,t9_metaid t9_metaid 4 test.t7.metaid 1 100.00 Using index +SELECT t1.uniquekey, t1.xml AS affiliateXml, +t8.name AS artistName, t8.artistid, +t11.name AS genreName, t11.genreid, t11.priority AS genrePriority, +t10.subgenreid, t10.name AS subgenreName, +t2.name AS metaName, t2.metaid, t2.xml AS metaXml, +t4.priority + t5.priority + t6.priority AS overallPriority, +t3.path AS path, t3.mediaid, +t4.formatid, t4.name AS formatName, +t5.formatclassid, t5.name AS formatclassName, +t6.formattypeid, t6.name AS formattypeName +FROM t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11 +WHERE t7.metaid = t2.metaid AND t7.artistid = t8.artistid AND +t9.metaid = t2.metaid AND t9.subgenreid = t10.subgenreid AND +t10.genreid = t11.genreid AND t3.metaid = t2.metaid AND +t3.formatid = t4.formatid AND t4.formatclassid = t5.formatclassid AND +t4.canaddtocapability = 'Y' AND t5.formattypeid = t6.formattypeid AND +t6.formattypeid IN (2) AND (t3.formatid IN (31, 8, 76)) AND +t1.metaid = t2.metaid AND t1.affiliateid = '2'; +uniquekey affiliateXml artistName artistid genreName genreid genrePriority subgenreid subgenreName metaName metaid metaXml overallPriority path mediaid formatid formatName formatclassid formatclassName formattypeid formattypeName +DROP TABLE t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11; +CREATE TABLE t1 (a1 int, filler1 char(64) default ' ' ); +CREATE TABLE t2 ( +a2 int, b2 int, filler2 char(64) default ' ', +PRIMARY KEY idx(a2,b2,filler2) +) ; +CREATE TABLE t3 (b3 int, c3 int, INDEX idx(b3)); +INSERT INTO t1(a1) VALUES +(4), (7), (1), (9), (8), (5), (3), (6), (2); +INSERT INTO t2(a2,b2) VALUES +(1,30), (3,40), (2,61), (6,73), (8,92), (9,27), (4,18), (5,84), (7,56), +(4,14), (6,76), (8,98), (7,55), (1,39), (2,68), (3,45), (9,21), (5,81), +(5,88), (2,65), (6,74), (9,23), (1,37), (3,44), (4,17), (8,99), (7,51), +(9,28), (7,52), (1,33), (4,13), (5,87), (3,43), (8,91), (2,62), (6,79), +(3,49), (8,93), (7,34), (5,82), (6,78), (2,63), (1,32), (9,22), (4,11); +INSERT INTO t3 VALUES +(30,302), (92,923), (18,187), (45,459), (30,309), +(39,393), (68,685), (45,458), (21,210), (81,817), +(40,405), (61,618), (73,738), (92,929), (27,275), +(18,188), (84,846), (56,564), (14,144), (76,763), +(98,982), (55,551), (17,174), (99,998), (51,513), +(28,282), (52,527), (33,336), (13,138), (87,878), +(43,431), (91,916), (62,624), (79,797), (49,494), +(93,933), (34,347), (82,829), (78,780), (63,634), +(32,329), (22,228), (11,114), (74,749), (23,236); +ANALYZE TABLE t1, t2, t3; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +EXPLAIN +SELECT a1<>a2, a1, a2, b2, b3, c3, +SUBSTR(filler1,1,1) AS s1, SUBSTR(filler2,1,1) AS s2 +FROM t1,t2,t3 WHERE a1=a2 AND b2=b3 AND MOD(c3,10)>7; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL # 100.00 Using where +2 SIMPLE t2 NULL ref PRIMARY PRIMARY 4 test.t1.a1 # 100.00 Using index +2 SIMPLE t3 NULL ref idx idx 5 test.t2.b2 # 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select (`test`.`t1`.`a1` <> `test`.`t2`.`a2`) AS `a1<>a2`,`test`.`t1`.`a1` AS `a1`,`test`.`t2`.`a2` AS `a2`,`test`.`t2`.`b2` AS `b2`,`test`.`t3`.`b3` AS `b3`,`test`.`t3`.`c3` AS `c3`,substr(`test`.`t1`.`filler1`,1,1) AS `s1`,substr(`test`.`t2`.`filler2`,1,1) AS `s2` from `test`.`t1` join `test`.`t2` join `test`.`t3` where ((`test`.`t3`.`b3` = `test`.`t2`.`b2`) and (`test`.`t2`.`a2` = `test`.`t1`.`a1`) and ((`test`.`t3`.`c3` % 10) > 7)) +SELECT a1<>a2, a1, a2, b2, b3, c3, +SUBSTR(filler1,1,1) AS s1, SUBSTR(filler2,1,1) AS s2 +FROM t1,t2,t3 WHERE a1=a2 AND b2=b3 AND MOD(c3,10)>7; +a1<>a2 a1 a2 b2 b3 c3 s1 s2 +0 1 1 30 30 309 +0 1 1 32 32 329 +0 2 2 61 61 618 +0 3 3 45 45 458 +0 3 3 45 45 459 +0 4 4 13 13 138 +0 4 4 18 18 188 +0 5 5 82 82 829 +0 5 5 87 87 878 +0 6 6 73 73 738 +0 6 6 74 74 749 +0 8 8 92 92 929 +0 8 8 99 99 998 +0 9 9 22 22 228 +set join_buffer_size=512; +EXPLAIN +SELECT a1<>a2, a1, a2, b2, b3, c3, +SUBSTR(filler1,1,1) AS s1, SUBSTR(filler2,1,1) AS s2 +FROM t1,t2,t3 WHERE a1=a2 AND b2=b3 AND MOD(c3,10)>7; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL # 100.00 Using where +2 SIMPLE t2 NULL ref PRIMARY PRIMARY 4 test.t1.a1 # 100.00 Using index +2 SIMPLE t3 NULL ref idx idx 5 test.t2.b2 # 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select (`test`.`t1`.`a1` <> `test`.`t2`.`a2`) AS `a1<>a2`,`test`.`t1`.`a1` AS `a1`,`test`.`t2`.`a2` AS `a2`,`test`.`t2`.`b2` AS `b2`,`test`.`t3`.`b3` AS `b3`,`test`.`t3`.`c3` AS `c3`,substr(`test`.`t1`.`filler1`,1,1) AS `s1`,substr(`test`.`t2`.`filler2`,1,1) AS `s2` from `test`.`t1` join `test`.`t2` join `test`.`t3` where ((`test`.`t3`.`b3` = `test`.`t2`.`b2`) and (`test`.`t2`.`a2` = `test`.`t1`.`a1`) and ((`test`.`t3`.`c3` % 10) > 7)) +SELECT a1<>a2, a1, a2, b2, b3, c3, +SUBSTR(filler1,1,1) AS s1, SUBSTR(filler2,1,1) AS s2 +FROM t1,t2,t3 WHERE a1=a2 AND b2=b3 AND MOD(c3,10)>7; +a1<>a2 a1 a2 b2 b3 c3 s1 s2 +0 1 1 30 30 309 +0 1 1 32 32 329 +0 2 2 61 61 618 +0 3 3 45 45 458 +0 3 3 45 45 459 +0 4 4 13 13 138 +0 4 4 18 18 188 +0 5 5 82 82 829 +0 5 5 87 87 878 +0 6 6 73 73 738 +0 6 6 74 74 749 +0 8 8 92 92 929 +0 8 8 99 99 998 +0 9 9 22 22 228 +DROP TABLE t1,t2,t3; +CREATE TABLE t1 (a int, b int, INDEX idx(b)); +CREATE TABLE t2 (a int, b int, INDEX idx(a)); +INSERT INTO t1 VALUES (5,30), (3,20), (7,40), (2,10), (8,30), (1,10), (4,20); +INSERT INTO t2 VALUES (7,10), (1,20), (2,20), (8,20), (8,10), (1,20); +INSERT INTO t2 VALUES (1,10), (4,20), (3,20), (7,20), (7,10), (1,20); +set join_buffer_size=32; +Warnings: +Warning 1292 Truncated incorrect join_buffer_size value: '32' +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN SELECT * FROM t1,t2 WHERE t1.a=t2.a AND t1.b >= 30; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range idx idx 5 NULL 3 100.00 Using index condition; Using where; Using MRR +2 SIMPLE t2 NULL ref idx idx 5 test.t1.a 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`a` = `test`.`t1`.`a`) and (`test`.`t1`.`b` >= 30)) +SELECT * FROM t1,t2 WHERE t1.a=t2.a AND t1.b >= 30; +a b a b +7 40 7 10 +7 40 7 10 +7 40 7 20 +8 30 8 10 +8 30 8 20 +DROP TABLE t1,t2; + +BUG#40136: Group by is ignored when join buffer is used for an outer join + +create table t1(a int PRIMARY KEY, b int); +insert into t1 values +(5, 10), (2, 70), (7, 80), (6, 20), (1, 50), (9, 40), (8, 30), (3, 60); +create table t2 (p int, a int, INDEX i_a(a)); +insert into t2 values +(103, 7), (109, 3), (102, 3), (108, 1), (106, 3), +(107, 7), (105, 1), (101, 3), (100, 7), (110, 1); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +explain +select t1.a, count(t2.p) as count +from t1 left join t2 on t1.a=t2.a and t2.p % 2 = 1 group by t1.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index PRIMARY PRIMARY 4 NULL # 100.00 Using index +2 SIMPLE t2 NULL ref i_a i_a 5 test.t1.a # 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,count(`test`.`t2`.`p`) AS `count` from `test`.`t1` left join `test`.`t2` on(((`test`.`t2`.`a` = `test`.`t1`.`a`) and ((`test`.`t2`.`p` % 2) = 1))) where true group by `test`.`t1`.`a` +select t1.a, count(t2.p) as count +from t1 left join t2 on t1.a=t2.a and t2.p % 2 = 1 group by t1.a order by t1.a; +a count +1 1 +2 0 +3 2 +5 0 +6 0 +7 2 +8 0 +9 0 +drop table t1, t2; +# +# Bug #40134: outer join with not exists optimization and join buffer +# +set join_buffer_size=default; +CREATE TABLE t1 (a int NOT NULL); +INSERT INTO t1 VALUES (2), (4), (3), (5), (1); +CREATE TABLE t2 (a int NOT NULL, b int NOT NULL, INDEX i_a(a)); +INSERT INTO t2 VALUES (4,10), (2,10), (2,30), (2,20), (4,20); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN +SELECT * FROM t1 LEFT JOIN t2 ON t1.a=t2.a WHERE t2.b IS NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +2 SIMPLE t2 NULL ref i_a i_a 4 test.t1.a 2 20.00 Using where; Not exists +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`a` = `test`.`t1`.`a`)) where (`test`.`t2`.`b` is null) +SELECT * FROM t1 LEFT JOIN t2 ON t1.a=t2.a WHERE t2.b IS NULL; +a a b +3 NULL NULL +5 NULL NULL +1 NULL NULL +DROP TABLE t1, t2; +# +# BUG#40268: Nested outer join with not null-rejecting where condition +# over an inner table which is not the last in the nest +# +CREATE TABLE t2 (a int, b int, c int); +CREATE TABLE t3 (a int, b int, c int); +CREATE TABLE t4 (a int, b int, c int); +INSERT INTO t2 VALUES (3,3,0), (4,2,0), (5,3,0); +INSERT INTO t3 VALUES (1,2,0), (2,2,0); +INSERT INTO t4 VALUES (3,2,0), (4,2,0); +SELECT t2.a,t2.b,t3.a,t3.b,t4.a,t4.b +FROM t2 LEFT JOIN (t3, t4) ON t2.b=t4.b +WHERE t3.a+2 NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 55.56 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`c` AS `c` from `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`a` = `test`.`t1`.`a`)) where ((`test`.`t2`.`c` = 102) or (`test`.`t2`.`c` is null)) +select * from t1 left join t2 on t1.a=t2.a where t2.c=102 or t2.c is null; +a b a c +2 20 NULL NULL +3 30 3 102 +drop table t1, t2; +# +# Bug #40317: outer join with with constant on expression equal to FALSE +# +create table t1 (a int); +insert into t1 values (30), (40), (20); +create table t2 (b int); +insert into t2 values (200), (100); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +select * from t1 left join t2 on (1=0); +a b +30 NULL +40 NULL +20 NULL +explain select * from t1 left join t2 on (1=0) where a=40; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` left join `test`.`t2` on(false) where (`test`.`t1`.`a` = 40) +select * from t1 left join t2 on (1=0) where a=40; +a b +40 NULL +drop table t1, t2; +# +# Bug #41204: small buffer with big rec_per_key for ref access +# +CREATE TABLE t1 (a int); +INSERT INTO t1 VALUES (0); +INSERT INTO t1(a) SELECT a FROM t1; +INSERT INTO t1(a) SELECT a FROM t1; +INSERT INTO t1(a) SELECT a FROM t1; +INSERT INTO t1(a) SELECT a FROM t1; +INSERT INTO t1(a) SELECT a FROM t1; +INSERT INTO t1(a) SELECT a FROM t1; +INSERT INTO t1(a) SELECT a FROM t1; +INSERT INTO t1(a) SELECT a FROM t1; +INSERT INTO t1(a) SELECT a FROM t1; +INSERT INTO t1(a) SELECT a FROM t1; +INSERT INTO t1(a) SELECT a FROM t1; +INSERT INTO t1 VALUES (20000), (10000); +CREATE TABLE t2 (pk int AUTO_INCREMENT PRIMARY KEY, b int, c int, INDEX idx(b)); +INSERT INTO t2(b,c) VALUES (10000, 3), (20000, 7), (20000, 1), (10000, 9), (20000, 5); +INSERT INTO t2(b,c) SELECT b,c FROM t2; +INSERT INTO t2(b,c) SELECT b,c FROM t2; +INSERT INTO t2(b,c) SELECT b,c FROM t2; +INSERT INTO t2(b,c) SELECT b,c FROM t2; +INSERT INTO t2(b,c) SELECT b,c FROM t2; +INSERT INTO t2(b,c) SELECT b,c FROM t2; +INSERT INTO t2(b,c) SELECT b,c FROM t2; +INSERT INTO t2(b,c) SELECT b,c FROM t2; +ANALYZE TABLE t1,t2; +set join_buffer_size=1024; +EXPLAIN SELECT AVG(c) FROM t1,t2 WHERE t1.a=t2.b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2050 100.00 Parallel execute (4 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2050 100.00 Using where +2 SIMPLE t2 NULL ref idx idx 5 test.t1.a 640 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select avg(`test`.`t2`.`c`) AS `AVG(c)` from `test`.`t1` join `test`.`t2` where (`test`.`t2`.`b` = `test`.`t1`.`a`) +SELECT AVG(c) FROM t1,t2 WHERE t1.a=t2.b; +AVG(c) +5.0000 +set join_buffer_size=default; +DROP TABLE t1, t2; +# +# Bug #41894: big join buffer of level 7 used to join records +# with null values in place of varchar strings +# +CREATE TABLE t1 (a int NOT NULL AUTO_INCREMENT PRIMARY KEY, +b varchar(127) DEFAULT NULL); +INSERT INTO t1(a) VALUES (1); +INSERT INTO t1(b) SELECT b FROM t1; +INSERT INTO t1(b) SELECT b FROM t1; +INSERT INTO t1(b) SELECT b FROM t1; +INSERT INTO t1(b) SELECT b FROM t1; +INSERT INTO t1(b) SELECT b FROM t1; +INSERT INTO t1(b) SELECT b FROM t1; +INSERT INTO t1(b) SELECT b FROM t1; +INSERT INTO t1(b) SELECT b FROM t1; +INSERT INTO t1(b) SELECT b FROM t1; +INSERT INTO t1(b) SELECT b FROM t1; +INSERT INTO t1(b) SELECT b FROM t1; +INSERT INTO t1(b) SELECT b FROM t1; +INSERT INTO t1(b) SELECT b FROM t1; +INSERT INTO t1(b) SELECT b FROM t1; +CREATE TABLE t2 (a int NOT NULL PRIMARY KEY, b varchar(127) DEFAULT NULL); +INSERT INTO t2 SELECT * FROM t1; +CREATE TABLE t3 (a int NOT NULL PRIMARY KEY, b varchar(127) DEFAULT NULL); +INSERT INTO t3 SELECT * FROM t1; +set join_buffer_size=1024*1024; +ANALYZE TABLE t1, t2, t3; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +EXPLAIN +SELECT COUNT(*) FROM t1,t2,t3 +WHERE t1.a=t2.a AND t2.a=t3.a AND +t1.b IS NULL AND t2.b IS NULL AND t3.b IS NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE # NULL ALL NULL NULL NULL # 16400 10.00 Parallel execute (4 workers) +2 SIMPLE # NULL ALL PRIMARY NULL NULL # 16400 10.00 Using where +2 SIMPLE # NULL eq_ref PRIMARY PRIMARY 4 # 1 10.00 Using where +2 SIMPLE # NULL eq_ref PRIMARY PRIMARY 4 # 1 10.00 Using where +SELECT COUNT(*) FROM t1,t2,t3 +WHERE t1.a=t2.a AND t2.a=t3.a AND +t1.b IS NULL AND t2.b IS NULL AND t3.b IS NULL; +COUNT(*) +16384 +set join_buffer_size=default; +DROP TABLE t1,t2,t3; +# +# Bug #42020: join buffer is used for outer join with fields of +# several outer tables in join buffer +# +CREATE TABLE t1 ( +a bigint NOT NULL, +PRIMARY KEY (a) +); +INSERT INTO t1 VALUES +(2), (1); +CREATE TABLE t2 ( +a bigint NOT NULL, +b bigint NOT NULL, +PRIMARY KEY (a,b) +); +INSERT INTO t2 VALUES +(2,30), (2,40), (2,50), (2,60), (2,70), (2,80), +(1,10), (1, 20), (1,30), (1,40), (1,50); +CREATE TABLE t3 ( +pk bigint NOT NULL AUTO_INCREMENT, +a bigint NOT NULL, +b bigint NOT NULL, +val bigint DEFAULT '0', +PRIMARY KEY (pk), +KEY idx (a,b) +); +INSERT INTO t3(a,b) VALUES +(2,30), (2,40), (2,50), (2,60), (2,70), (2,80), +(4,30), (4,40), (4,50), (4,60), (4,70), (4,80), +(5,30), (5,40), (5,50), (5,60), (5,70), (5,80), +(7,30), (7,40), (7,50), (7,60), (7,70), (7,80); +SELECT t1.a, t2.a, t3.a, t2.b, t3.b, t3.val +FROM (t1,t2) LEFT JOIN t3 ON (t1.a=t3.a AND t2.b=t3.b) +WHERE t1.a=t2.a; +a a a b b val +1 1 NULL 10 NULL NULL +1 1 NULL 20 NULL NULL +1 1 NULL 30 NULL NULL +1 1 NULL 40 NULL NULL +1 1 NULL 50 NULL NULL +2 2 2 30 30 0 +2 2 2 40 40 0 +2 2 2 50 50 0 +2 2 2 60 60 0 +2 2 2 70 70 0 +2 2 2 80 80 0 +set join_buffer_size=256; +ANALYZE TABLE t1, t2, t3; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +EXPLAIN +SELECT t1.a, t2.a, t3.a, t2.b, t3.b, t3.val +FROM (t1,t2) LEFT JOIN t3 ON (t1.a=t3.a AND t2.b=t3.b) +WHERE t1.a=t2.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index PRIMARY PRIMARY 8 NULL 2 100.00 Using index +2 SIMPLE t2 NULL ref PRIMARY PRIMARY 8 test.t1.a 5 100.00 Using index +2 SIMPLE t3 NULL ref idx idx 16 test.t1.a,test.t2.b 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`b` AS `b`,`test`.`t3`.`val` AS `val` from `test`.`t1` join `test`.`t2` left join `test`.`t3` on(((`test`.`t3`.`b` = `test`.`t2`.`b`) and (`test`.`t3`.`a` = `test`.`t1`.`a`))) where (`test`.`t2`.`a` = `test`.`t1`.`a`) +SELECT t1.a, t2.a, t3.a, t2.b, t3.b, t3.val +FROM (t1,t2) LEFT JOIN t3 ON (t1.a=t3.a AND t2.b=t3.b) +WHERE t1.a=t2.a; +a a a b b val +1 1 NULL 10 NULL NULL +1 1 NULL 20 NULL NULL +1 1 NULL 30 NULL NULL +1 1 NULL 40 NULL NULL +1 1 NULL 50 NULL NULL +2 2 2 30 30 0 +2 2 2 40 40 0 +2 2 2 50 50 0 +2 2 2 60 60 0 +2 2 2 70 70 0 +2 2 2 80 80 0 +DROP INDEX idx ON t3; +ANALYZE TABLE t1, t2, t3; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +EXPLAIN +SELECT t1.a, t2.a, t3.a, t2.b, t3.b, t3.val +FROM (t1,t2) LEFT JOIN t3 ON (t1.a=t3.a AND t2.b=t3.b) +WHERE t1.a=t2.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index PRIMARY PRIMARY 8 NULL 2 100.00 Using index +2 SIMPLE t2 NULL ref PRIMARY PRIMARY 8 test.t1.a 5 100.00 Using index +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 24 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`b` AS `b`,`test`.`t3`.`val` AS `val` from `test`.`t1` join `test`.`t2` left join `test`.`t3` on(((`test`.`t3`.`b` = `test`.`t2`.`b`) and (`test`.`t3`.`a` = `test`.`t1`.`a`))) where (`test`.`t2`.`a` = `test`.`t1`.`a`) +SELECT t1.a, t2.a, t3.a, t2.b, t3.b, t3.val +FROM (t1,t2) LEFT JOIN t3 ON (t1.a=t3.a AND t2.b=t3.b) +WHERE t1.a=t2.a; +a a a b b val +1 1 NULL 10 NULL NULL +1 1 NULL 20 NULL NULL +1 1 NULL 30 NULL NULL +1 1 NULL 40 NULL NULL +1 1 NULL 50 NULL NULL +2 2 2 30 30 0 +2 2 2 40 40 0 +2 2 2 50 50 0 +2 2 2 60 60 0 +2 2 2 70 70 0 +2 2 2 80 80 0 +set join_buffer_size=default; +DROP TABLE t1,t2,t3; +create table t1(f1 int, f2 int); +insert into t1 values (1,1),(2,2),(3,3); +create table t2(f1 int not null, f2 int not null, f3 char(200), key(f1,f2)); +insert into t2 values (1,1, 'qwerty'),(1,2, 'qwerty'),(1,3, 'qwerty'); +insert into t2 values (2,1, 'qwerty'),(2,2, 'qwerty'),(2,3, 'qwerty'), +(2,4, 'qwerty'),(2,5, 'qwerty'); +insert into t2 values (3,1, 'qwerty'),(3,4, 'qwerty'); +insert into t2 values (4,1, 'qwerty'),(4,2, 'qwerty'),(4,3, 'qwerty'), +(4,4, 'qwerty'); +insert into t2 values (1,1, 'qwerty'),(1,2, 'qwerty'),(1,3, 'qwerty'); +insert into t2 values (2,1, 'qwerty'),(2,2, 'qwerty'),(2,3, 'qwerty'), +(2,4, 'qwerty'),(2,5, 'qwerty'); +insert into t2 values (3,1, 'qwerty'),(3,4, 'qwerty'); +insert into t2 values (4,1, 'qwerty'),(4,2, 'qwerty'),(4,3, 'qwerty'), +(4,4, 'qwerty'); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +select t2.f1, t2.f2, t2.f3 from t1,t2 +where t1.f1=t2.f1 and t2.f2 between t1.f1 and t1.f2 and t2.f2 + 1 >= t1.f1 + 1; +f1 f2 f3 +1 1 qwerty +1 1 qwerty +2 2 qwerty +2 2 qwerty +explain select t2.f1, t2.f2, t2.f3 from t1,t2 +where t1.f1=t2.f1 and t2.f2 between t1.f1 and t2.f2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 SIMPLE t2 NULL ref f1 f1 4 test.t1.f1 7 11.11 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`f1` AS `f1`,`test`.`t2`.`f2` AS `f2`,`test`.`t2`.`f3` AS `f3` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`f1` = `test`.`t1`.`f1`) and (`test`.`t2`.`f2` between `test`.`t1`.`f1` and `test`.`t2`.`f2`)) +drop table t1,t2; +# +# Bug #42955: join with GROUP BY/ORDER BY and when BKA is enabled +# +create table t1 (d int, id1 int, index idx1 (d, id1)); +insert into t1 values +(3, 20), (2, 40), (3, 10), (1, 10), (3, 20), (1, 40), (2, 30), (3, 30); +create table t2 (id1 int, id2 int, index idx2 (id1)); +insert into t2 values +(20, 100), (30, 400), (20, 400), (30, 200), (10, 300), (10, 200), (40, 100), +(40, 200), (30, 300), (10, 400), (20, 200), (20, 300); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +explain +select t1.id1, sum(t2.id2) from t1 join t2 on t1.id1=t2.id1 +where t1.d=3 group by t1.id1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref idx1 idx1 5 const 4 100.00 Using where; Using index +2 SIMPLE t2 NULL ref idx2 idx2 5 test.t1.id1 3 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id1` AS `id1`,sum(`test`.`t2`.`id2`) AS `sum(t2.id2)` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`id1` = `test`.`t1`.`id1`) and (`test`.`t1`.`d` = 3)) group by `test`.`t1`.`id1` +select t1.id1, sum(t2.id2) from t1 join t2 on t1.id1=t2.id1 +where t1.d=3 group by t1.id1; +id1 sum(t2.id2) +10 900 +20 2000 +30 900 +explain +select t1.id1 from t1 join t2 on t1.id1=t2.id1 +where t1.d=3 and t2.id2 > 200 order by t1.id1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref idx1 idx1 5 const 4 100.00 Using where; Using index +2 SIMPLE t2 NULL ref idx2 idx2 5 test.t1.id1 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id1` AS `id1` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`id1` = `test`.`t1`.`id1`) and (`test`.`t1`.`d` = 3) and (`test`.`t2`.`id2` > 200)) order by `test`.`t1`.`id1` +select t1.id1 from t1 join t2 on t1.id1=t2.id1 +where t1.d=3 and t2.id2 > 200 order by t1.id1; +id1 +10 +10 +20 +20 +20 +20 +30 +30 +drop table t1,t2; +# +# Bug #44019: star-like multi-join query executed optimizer_join_cache_level=6 +# +create table t1 (a int, b int, c int, d int); +create table t2 (b int, e varchar(16), index idx(b)); +create table t3 (d int, f varchar(16), index idx(d)); +create table t4 (c int, g varchar(16), index idx(c)); +insert into t1 values +(5, 50, 500, 5000), (3, 30, 300, 3000), (9, 90, 900, 9000), +(2, 20, 200, 2000), (4, 40, 400, 4000), (8, 80, 800, 800), +(7, 70, 700, 7000); +insert into t2 values +(30, 'bbb'), (10, 'b'), (70, 'bbbbbbb'), (60, 'bbbbbb'), +(31, 'bbb'), (11, 'b'), (71, 'bbbbbbb'), (61, 'bbbbbb'), +(32, 'bbb'), (12, 'b'), (72, 'bbbbbbb'), (62, 'bbbbbb'); +insert into t3 values +(4000, 'dddd'), (3000, 'ddd'), (1000, 'd'), (8000, 'dddddddd'), +(4001, 'dddd'), (3001, 'ddd'), (1001, 'd'), (8001, 'dddddddd'), +(4002, 'dddd'), (3002, 'ddd'), (1002, 'd'), (8002, 'dddddddd'); +insert into t4 values +(200, 'cc'), (600, 'cccccc'), (300, 'ccc'), (500, 'ccccc'), +(201, 'cc'), (601, 'cccccc'), (301, 'ccc'), (501, 'ccccc'), +(202, 'cc'), (602, 'cccccc'), (302, 'ccc'), (502, 'ccccc'); +analyze table t2,t3,t4; +ANALYZE TABLE t1, t2, t3, t4; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +test.t4 analyze status OK +explain +select t1.a, t1.b, t1.c, t1.d, t2.e, t3.f, t4.g from t1,t2,t3,t4 +where t2.b=t1.b and t3.d=t1.d and t4.c=t1.c; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 7 100.00 Using where +2 SIMPLE t2 NULL ref idx idx 5 test.t1.b 1 100.00 NULL +2 SIMPLE t3 NULL ref idx idx 5 test.t1.d 1 100.00 NULL +2 SIMPLE t4 NULL ref idx idx 5 test.t1.c 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c`,`test`.`t1`.`d` AS `d`,`test`.`t2`.`e` AS `e`,`test`.`t3`.`f` AS `f`,`test`.`t4`.`g` AS `g` from `test`.`t1` join `test`.`t2` join `test`.`t3` join `test`.`t4` where ((`test`.`t4`.`c` = `test`.`t1`.`c`) and (`test`.`t3`.`d` = `test`.`t1`.`d`) and (`test`.`t2`.`b` = `test`.`t1`.`b`)) +select t1.a, t1.b, t1.c, t1.d, t2.e, t3.f, t4.g from t1,t2,t3,t4 +where t2.b=t1.b and t3.d=t1.d and t4.c=t1.c; +a b c d e f g +3 30 300 3000 bbb ddd ccc +drop table t1,t2,t3,t4; +# +# Bug #44250: Corruption of linked join buffers when using BKA +# +CREATE TABLE t1 ( +id1 bigint(20) DEFAULT NULL, +id2 bigint(20) DEFAULT NULL, +id3 bigint(20) DEFAULT NULL, +num1 bigint(20) DEFAULT NULL, +num2 int(11) DEFAULT NULL, +num3 bigint(20) DEFAULT NULL +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t2 ( +id3 bigint(20) NOT NULL DEFAULT '0', +id4 bigint(20) DEFAULT NULL, +enum1 enum('Enabled','Disabled','Paused') DEFAULT NULL, +PRIMARY KEY (id3) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t3 ( +id4 bigint(20) NOT NULL DEFAULT '0', +text1 text, +PRIMARY KEY (id4) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t4 ( +id2 bigint(20) NOT NULL DEFAULT '0', +dummy int(11) DEFAULT '0', +PRIMARY KEY (id2) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t5 ( +id1 bigint(20) NOT NULL DEFAULT '0', +id2 bigint(20) NOT NULL DEFAULT '0', +enum2 enum('Active','Deleted','Paused') DEFAULT NULL, +PRIMARY KEY (id1,id2) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +set join_buffer_size=2048; +ANALYZE TABLE t1, t2, t3, t4, t5; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +test.t4 analyze status OK +test.t5 analyze status OK +EXPLAIN +SELECT STRAIGHT_JOIN t1.id1, t1.num3, t3.text1, t3.id4, t2.id3, t4.dummy +FROM t1 JOIN t2 JOIN t3 JOIN t4 JOIN t5 +WHERE t1.id1=t5.id1 AND t1.id2=t5.id2 and t4.id2=t1.id2 AND +t5.enum2='Active' AND t3.id4=t2.id4 AND t2.id3=t1.id3 AND t3.text1<'D'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL # 100.00 Using where +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 8 test.t1.id3 # 100.00 Using where +1 SIMPLE t3 NULL eq_ref PRIMARY PRIMARY 8 test.t2.id4 # 33.33 Using where +1 SIMPLE t4 NULL eq_ref PRIMARY PRIMARY 8 test.t1.id2 # 100.00 NULL +1 SIMPLE t5 NULL eq_ref PRIMARY PRIMARY 16 test.t1.id1,test.t1.id2 # 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select straight_join `test`.`t1`.`id1` AS `id1`,`test`.`t1`.`num3` AS `num3`,`test`.`t3`.`text1` AS `text1`,`test`.`t3`.`id4` AS `id4`,`test`.`t2`.`id3` AS `id3`,`test`.`t4`.`dummy` AS `dummy` from `test`.`t1` join `test`.`t2` join `test`.`t3` join `test`.`t4` join `test`.`t5` where ((`test`.`t2`.`id3` = `test`.`t1`.`id3`) and (`test`.`t3`.`id4` = `test`.`t2`.`id4`) and (`test`.`t5`.`enum2` = 'Active') and (`test`.`t4`.`id2` = `test`.`t1`.`id2`) and (`test`.`t5`.`id2` = `test`.`t1`.`id2`) and (`test`.`t5`.`id1` = `test`.`t1`.`id1`) and (`test`.`t3`.`text1` < 'D')) +SELECT STRAIGHT_JOIN t1.id1, t1.num3, t3.text1, t3.id4, t2.id3, t4.dummy +FROM t1 JOIN t2 JOIN t3 JOIN t4 JOIN t5 +WHERE t1.id1=t5.id1 AND t1.id2=t5.id2 and t4.id2=t1.id2 AND +t5.enum2='Active' AND t3.id4=t2.id4 AND t2.id3=t1.id3 AND t3.text1<'D'; +id1 num3 text1 id4 id3 dummy +228172702 134 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA 2567095402 2667134182 0 +228172702 14 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA 2567095402 2667134182 0 +228172702 15 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA 2567095402 2667134182 0 +228172702 3 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA 2567095402 2667134182 0 +228808822 1 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC 2381969632 2482416112 0 +228808822 1 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC 2381969632 2482416112 0 +228808822 1 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC 826928662 935693782 0 +228808822 10 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC 2381969632 2482416112 0 +228808822 13 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC 826928662 935693782 0 +228808822 13 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC 826928662 935693782 0 +228808822 14 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC 2381969632 2482416112 0 +228808822 17 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC 826928662 935693782 0 +228808822 18 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC 826928662 935693782 0 +228808822 19 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC 2381969632 2482416112 0 +228808822 26 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC 2381969632 2482416112 0 +228808822 28 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC 2381969632 2482416112 0 +228808822 3 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC 2381969632 2482416112 0 +228808822 3 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC 2381969632 2482416112 0 +228808822 3 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC 826928662 935693782 0 +228808822 3 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC 826928662 935693782 0 +228808822 4 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC 2381969632 2482416112 0 +228808822 4 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC 826928662 935693782 0 +228808822 4 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC 826928662 935693782 0 +228808822 50 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC 826928662 935693782 0 +228808822 6 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC 826928662 935693782 0 +228808822 60 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC 826928662 935693782 0 +228808822 61 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC 826928662 935693782 0 +228808822 62 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC 2381969632 2482416112 0 +228808822 84 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC 2381969632 2482416112 0 +228808822 89 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC 2381969632 2482416112 0 +228808822 9 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC 2381969632 2482416112 0 +set join_buffer_size=default; +DROP TABLE t1,t2,t3,t4,t5; +# +# Bug #46328: Use of aggregate function without GROUP BY clause +# returns many rows (vs. one ) +# +CREATE TABLE t1 ( +int_key int(11) NOT NULL, +KEY int_key (int_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES +(0),(2),(2),(2),(3),(4),(5),(5),(6),(6),(8),(8),(9),(9); +CREATE TABLE t2 ( +int_key int(11) NOT NULL, +KEY int_key (int_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (2),(3); + +# The query shall return 1 record with a max value 9 and one of the +# int_key values inserted above (undefined which one, so it's replaced +# with "#"). +SELECT MAX(t1.int_key), t1.int_key +FROM t1 STRAIGHT_JOIN t2 +ORDER BY t1.int_key; +MAX(t1.int_key) int_key +9 # + +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +explain +SELECT MAX(t1.int_key), t1.int_key +FROM t1 STRAIGHT_JOIN t2 +ORDER BY t1.int_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 14 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL int_key 4 NULL 14 100.00 Using index +2 SIMPLE t2 NULL index NULL int_key 4 NULL 2 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select max(`test`.`t1`.`int_key`) AS `MAX(t1.int_key)`,`test`.`t1`.`int_key` AS `int_key` from `test`.`t1` straight_join `test`.`t2` + +DROP TABLE t1,t2; +# +# Bug #45019: join buffer contains two blob columns one of which is +# used in the key employed to access the joined table +# +CREATE TABLE t1 (c1 int, c2 int, key (c2)); +INSERT INTO t1 VALUES (1,1); +INSERT INTO t1 VALUES (2,2); +CREATE TABLE t2 (c1 text, c2 text); +INSERT INTO t2 VALUES('tt', 'uu'); +INSERT INTO t2 VALUES('zzzz', 'xxxxxxxxx'); +ANALYZE TABLE t1,t2; +SELECT t1.*, t2.*, LENGTH(t2.c1), LENGTH(t2.c2) FROM t1,t2 +WHERE t1.c2=LENGTH(t2.c2) and t1.c1=LENGTH(t2.c1); +c1 c2 c1 c2 LENGTH(t2.c1) LENGTH(t2.c2) +2 2 tt uu 2 2 +DROP TABLE t1,t2; +# +# Regression test for +# Bug#46733 - NULL value not returned for aggregate on empty result +# set w/ semijoin on +CREATE TABLE t1 ( +i int(11) NOT NULL, +v varchar(1) DEFAULT NULL, +PRIMARY KEY (i) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (10,'a'),(11,'b'),(12,'c'),(13,'d'); +CREATE TABLE t2 ( +i int(11) NOT NULL, +v varchar(1) DEFAULT NULL, +PRIMARY KEY (i) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (1,'x'),(2,'y'); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK + +SELECT MAX(t1.i) +FROM t1 JOIN t2 ON t2.v +ORDER BY t2.v; +MAX(t1.i) +13 +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'x' +Warning 1292 Truncated incorrect DOUBLE value: 'y' + +EXPLAIN +SELECT MAX(t1.i) +FROM t1 JOIN t2 ON t2.v +ORDER BY t2.v; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 50.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 SIMPLE t1 NULL index NULL PRIMARY 4 NULL 4 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select max(`test`.`t1`.`i`) AS `MAX(t1.i)` from `test`.`t1` join `test`.`t2` where (0 <> `test`.`t2`.`v`) + +DROP TABLE t1,t2; +# +# Bug#51092: Linked join buffer gives wrong result +# for 3-way cross join +# +CREATE TABLE t1 (a INT, b INT); +INSERT INTO t1 VALUES (1,1),(2,2); +CREATE TABLE t2 (a INT, b INT); +INSERT INTO t2 VALUES (1,1),(2,2); +CREATE TABLE t3 (a INT, b INT); +INSERT INTO t3 VALUES (1,1),(2,2); +ANALYZE TABLE t1, t2, t3; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +EXPLAIN SELECT t1.* FROM t1,t2,t3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` join `test`.`t2` join `test`.`t3` +SELECT t1.* FROM t1,t2,t3; +a b +1 1 +1 1 +1 1 +1 1 +2 2 +2 2 +2 2 +2 2 +DROP TABLE t1,t2,t3; +# +# BUG#52394 Segfault in JOIN_CACHE::get_offset () at sql_select.h:445 +# +CREATE TABLE C(a int); +INSERT INTO C VALUES(1),(2),(3),(4),(5); +CREATE TABLE D (a int(11), b varchar(1)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO D VALUES (6,'r'),(27,'o'); +CREATE TABLE E (a int(11) primary key, b varchar(1)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO E VALUES +(14,'d'),(15,'z'),(16,'e'),(17,'h'),(18,'b'),(19,'s'),(20,'e'),(21,'j'),(22,'e'),(23,'f'),(24,'v'),(25,'x'),(26,'m'),(27,'c'); +SELECT 1 FROM C,D,E WHERE D.a = E.a AND D.b = E.b; +1 +DROP TABLE C,D,E; +# +# BUG#52540 Crash in JOIN_CACHE::set_match_flag_if_none () at sql_join_cache.cc:1883 +# +CREATE TABLE t1 (a int); +INSERT INTO t1 VALUES (2); +CREATE TABLE t2 (a varchar(10)); +INSERT INTO t2 VALUES ('f'),('x'); +CREATE TABLE t3 (pk int(11) PRIMARY KEY); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t3 VALUES (2); +CREATE TABLE t4 (a varchar(10)); +ANALYZE TABLE t1, t2, t3, t4; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +test.t4 analyze status OK +EXPLAIN SELECT 1 +FROM t2 LEFT JOIN +((t1 JOIN t3 ON t1.a = t3.pk) +LEFT JOIN t4 ON 1 ) +ON 1 ; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t3 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using index +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t2` left join (`test`.`t1` join `test`.`t3` left join `test`.`t4` on(true)) on(((`test`.`t3`.`pk` = `test`.`t1`.`a`))) where true +SELECT 1 +FROM t2 LEFT JOIN +((t1 JOIN t3 ON t1.a = t3.pk) +LEFT JOIN t4 ON 1 ) +ON 1 ; +1 +1 +1 +DROP TABLE t1,t2,t3,t4; +# +# Bug#51084: Batched key access crashes for SELECT with +# derived table and LEFT JOIN +# +CREATE TABLE t1 ( +carrier int, +id int PRIMARY KEY +); +INSERT INTO t1 VALUES (1,11),(1,12),(2,13); +CREATE TABLE t2 ( +scan_date int, +package_id int +); +INSERT INTO t2 VALUES (2008,21),(2008,22); +CREATE TABLE t3 ( +carrier int PRIMARY KEY, +id int +); +INSERT INTO t3 VALUES (1,31); +CREATE TABLE t4 ( +carrier_id int, +INDEX carrier_id(carrier_id) +); +INSERT INTO t4 VALUES (31),(32); +ANALYZE TABLE t1, t2, t3, t4; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +test.t4 analyze status OK + +SELECT COUNT(*) +FROM (t2 JOIN t1) LEFT JOIN (t3 JOIN t4 ON t3.id = t4.carrier_id) +ON t3.carrier = t1.carrier; +COUNT(*) +6 + +EXPLAIN +SELECT COUNT(*) +FROM (t2 JOIN t1) LEFT JOIN (t3 JOIN t4 ON t3.id = t4.carrier_id) +ON t3.carrier = t1.carrier; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 SIMPLE t3 NULL eq_ref PRIMARY PRIMARY 4 test.t1.carrier 1 100.00 NULL +2 SIMPLE t4 NULL ref carrier_id carrier_id 5 test.t3.id 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t2` join `test`.`t1` left join (`test`.`t3` join `test`.`t4`) on(((`test`.`t4`.`carrier_id` = `test`.`t3`.`id`) and (`test`.`t3`.`carrier` = `test`.`t1`.`carrier`))) where true + +DROP TABLE t1,t2,t3,t4; +# +# Bug#45267: Incomplete check caused wrong result. +# +CREATE TABLE t1 ( +`pk` int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t3 ( +`pk` int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t3 VALUES +(1),(2),(3),(4),(5),(6),(7),(8),(9),(10),(11),(12),(13),(14),(15), +(16),(17),(18),(19),(20); +CREATE TABLE t2 ( +`pk` int(11) NOT NULL AUTO_INCREMENT, +`int_nokey` int(11) NOT NULL, +`time_key` time NOT NULL, +PRIMARY KEY (`pk`), +KEY `time_key` (`time_key`) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (10,9,'22:36:46'),(11,0,'08:46:46'); +SELECT DISTINCT t1.`pk` +FROM t1 RIGHT JOIN t2 STRAIGHT_JOIN t3 ON t2.`int_nokey` ON t2.`time_key` +GROUP BY 1; +pk +NULL +DROP TABLE IF EXISTS t1, t2, t3; +# +# BUG#52636 6.0 allowing JOINs on NULL values w/ optimizer_join_cache_level = 5-8 +# +CREATE TABLE t1 (b int); +INSERT INTO t1 VALUES (NULL),(3); +CREATE TABLE t2 (a int, b int, KEY (b)); +INSERT INTO t2 VALUES (100,NULL),(150,200); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN SELECT t2.a FROM t1 LEFT JOIN t2 FORCE INDEX (b) ON t2.b = t1.b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 SIMPLE t2 NULL ref b b 5 test.t1.b 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t1` left join `test`.`t2` FORCE INDEX (`b`) on((`test`.`t2`.`b` = `test`.`t1`.`b`)) where true +SELECT t2.a FROM t1 LEFT JOIN t2 FORCE INDEX (b) ON t2.b = t1.b; +a +NULL +NULL +delete from t1; +INSERT INTO t1 VALUES (NULL),(NULL); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN SELECT t2.a FROM t1 LEFT JOIN t2 FORCE INDEX (b) ON t2.b = t1.b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 SIMPLE t2 NULL ref b b 5 test.t1.b 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t1` left join `test`.`t2` FORCE INDEX (`b`) on((`test`.`t2`.`b` = `test`.`t1`.`b`)) where true +SELECT t2.a FROM t1 LEFT JOIN t2 FORCE INDEX (b) ON t2.b = t1.b; +a +NULL +NULL +DROP TABLE t1,t2; +CREATE TABLE t1 (b varchar(100)); +INSERT INTO t1 VALUES (NULL),("some varchar"); +CREATE TABLE t2 (a int, b varchar(100), KEY (b)); +INSERT INTO t2 VALUES (100,NULL),(150,"varchar"),(200,NULL),(250,"long long varchar"); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +explain SELECT t2.a FROM t1 LEFT JOIN t2 ON t2.b = t1.b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 SIMPLE t2 NULL ref b b 403 test.t1.b 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`b` = `test`.`t1`.`b`)) where true +SELECT t2.a FROM t1 LEFT JOIN t2 ON t2.b = t1.b; +a +NULL +NULL +DROP TABLE t1,t2; +# +# BUG#54359 "Extra rows with join_cache_level=7,8 and two joins +# --and multi-column index" +# +CREATE TABLE t1 ( +`pk` int(11) NOT NULL, +`col_int_key` int(11) DEFAULT NULL, +`col_varchar_key` varchar(1) DEFAULT NULL, +`col_varchar_nokey` varchar(1) DEFAULT NULL, +KEY `col_varchar_key` (`col_varchar_key`,`col_int_key`)) +; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (4,9,'k','k'); +INSERT INTO t1 VALUES (12,5,'k','k'); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +explain SELECT table2 .`col_int_key` FROM t1 table2, +t1 table3 force index (`col_varchar_key`) +where table3 .`pk` and table3 .`col_int_key` >= table2 .`pk` +and table3 .`col_varchar_key` = table2 .`col_varchar_nokey`; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 50.00 Parallel execute (1 workers) +2 SIMPLE table3 NULL ALL col_varchar_key NULL NULL NULL 2 50.00 Using where +2 SIMPLE table2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`table2`.`col_int_key` AS `col_int_key` from `test`.`t1` `table2` join `test`.`t1` `table3` FORCE INDEX (`col_varchar_key`) where ((`test`.`table2`.`col_varchar_nokey` = `test`.`table3`.`col_varchar_key`) and (0 <> `test`.`table3`.`pk`) and (`test`.`table3`.`col_int_key` >= `test`.`table2`.`pk`)) +SELECT table2 .`col_int_key` FROM t1 table2, +t1 table3 force index (`col_varchar_key`) +where table3 .`pk` and table3 .`col_int_key` >= table2 .`pk` +and table3 .`col_varchar_key` = table2 .`col_varchar_nokey`; +col_int_key +9 +9 +drop table t1; +# +# BUG#54481 "GROUP BY loses effect with JOIN + ORDER BY + LIMIT +# and join_cache_level=5-8" +# +CREATE TABLE t1 ( +`col_int_key` int, +`col_datetime` datetime, +KEY `col_int_key` (`col_int_key`) +); +INSERT INTO t1 VALUES (2,'2003-02-11 21:19:41'); +INSERT INTO t1 VALUES (3,'2009-10-18 02:27:49'); +INSERT INTO t1 VALUES (0,'2000-09-26 07:45:57'); +INSERT INTO t1 VALUES (4,'2000-09-26 07:45:57'); +CREATE TABLE t2 ( +`col_int` int, +`col_int_key` int, +KEY `col_int_key` (`col_int_key`) +); +INSERT INTO t2 VALUES (14,1); +INSERT INTO t2 VALUES (98,1); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +explain SELECT t1.col_int_key, t1.col_datetime +FROM t1,t2 +WHERE t2.col_int_key = 1 AND t2.col_int >= 3 +GROUP BY t1.col_int_key +ORDER BY t1.col_int_key, t1.col_datetime +LIMIT 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL col_int_key NULL NULL NULL 4 100.00 Using temporary; Using filesort +2 SIMPLE t2 NULL ref col_int_key col_int_key 5 const 2 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col_int_key` AS `col_int_key`,`test`.`t1`.`col_datetime` AS `col_datetime` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`col_int_key` = 1) and (`test`.`t2`.`col_int` >= 3)) group by `test`.`t1`.`col_int_key` order by `test`.`t1`.`col_int_key`,`test`.`t1`.`col_datetime` limit 2 +SELECT t1.col_int_key, t1.col_datetime +FROM t1,t2 +WHERE t2.col_int_key = 1 AND t2.col_int >= 3 +GROUP BY t1.col_int_key +ORDER BY t1.col_int_key, t1.col_datetime +LIMIT 2; +col_int_key col_datetime +0 2000-09-26 07:45:57 +2 2003-02-11 21:19:41 +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +explain SELECT t1.col_int_key, t1.col_datetime +FROM t1 force index (col_int_key), t2 ignore index (col_int_key) +WHERE t2.col_int_key = 1 AND t2.col_int >= 3 +GROUP BY t1.col_int_key +ORDER BY t1.col_int_key, t1.col_datetime +LIMIT 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index col_int_key col_int_key 5 NULL 4 100.00 Using temporary; Using filesort +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col_int_key` AS `col_int_key`,`test`.`t1`.`col_datetime` AS `col_datetime` from `test`.`t1` FORCE INDEX (`col_int_key`) join `test`.`t2` IGNORE INDEX (`col_int_key`) where ((`test`.`t2`.`col_int_key` = 1) and (`test`.`t2`.`col_int` >= 3)) group by `test`.`t1`.`col_int_key` order by `test`.`t1`.`col_int_key`,`test`.`t1`.`col_datetime` limit 2 +SELECT t1.col_int_key, t1.col_datetime +FROM t1 force index (col_int_key), t2 ignore index (col_int_key) +WHERE t2.col_int_key = 1 AND t2.col_int >= 3 +GROUP BY t1.col_int_key +ORDER BY t1.col_int_key, t1.col_datetime +LIMIT 2; +col_int_key col_datetime +0 2000-09-26 07:45:57 +2 2003-02-11 21:19:41 +drop table t1,t2; + +# Bug#11766522 "59651: ASSERTION `TABLE_REF->HAS_RECORD' FAILED +# WITH JOIN_CACHE_LEVEL=3" + +CREATE TABLE t1 ( +b varchar(20) +) ; +INSERT INTO t1 VALUES ('1'),('1'); +CREATE TABLE t4 ( +col253 text +) ; +INSERT INTO t4 VALUES (''),('pf'); +CREATE TABLE t6 ( +col282 timestamp +) ; +INSERT INTO t6 VALUES ('2010-11-07 01:04:45'),('2010-12-13 01:36:32'); +CREATE TABLE t7 ( +col319 timestamp NOT NULL, +UNIQUE KEY idx263 (col319) +) ; +insert into t7 values("2000-01-01"),("2000-01-02"); +CREATE TABLE t3 ( +col582 char(230) CHARACTER SET utf8 DEFAULT NULL +) ; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t3 VALUES ('cymej'),('spb'); +CREATE TABLE t5 ( +col712 time +) ; +insert into t5 values(0),(0); +CREATE TABLE t8 ( +col804 char(169), +col805 varchar(51) +) ; +INSERT INTO t8 VALUES ('tmqcb','pwk'); +CREATE TABLE t2 ( +col841 varchar(10) +) ; +INSERT INTO t2 VALUES (''),(''); +set join_buffer_size=1; +Warnings: +Warning 1292 Truncated incorrect join_buffer_size value: '1' +select @@join_buffer_size; +@@join_buffer_size +128 +select count(*) from +(t1 join t2 join t3) +left join t4 on 1 +left join t5 on 1 like t4.col253 +left join t6 on t5.col712 is null +left join t7 on t1.b <=>t7.col319 +left join t8 on t3.col582 <= 1; +count(*) +32 +drop table t1,t2,t3,t4,t5,t6,t7,t8; +# +# Bug#12616131 - JCL: NULL VS DATE + TWICE AS MANY ROWS +# RETURNED WHEN JCL>=7 +# +CREATE TABLE t1 (t1a int, t1b int); +INSERT INTO t1 VALUES (99, NULL),(99, 3),(99,0); +CREATE TABLE t2 (t2a int, t2b int, KEY idx (t2b)); +INSERT INTO t2 VALUES (100,0),(150,200),(999, 0),(999, NULL); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK + +# t2b is NULL-able + +EXPLAIN SELECT * FROM t1 LEFT JOIN t2 force index (idx) ON t2.t2b = t1.t1b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL # 100.00 NULL +2 SIMPLE t2 NULL ref idx idx 5 test.t1.t1b # 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`t1a` AS `t1a`,`test`.`t1`.`t1b` AS `t1b`,`test`.`t2`.`t2a` AS `t2a`,`test`.`t2`.`t2b` AS `t2b` from `test`.`t1` left join `test`.`t2` FORCE INDEX (`idx`) on((`test`.`t2`.`t2b` = `test`.`t1`.`t1b`)) where true +SELECT * FROM t1 LEFT JOIN t2 force index (idx) ON t2.t2b = t1.t1b; +t1a t1b t2a t2b +99 0 100 0 +99 0 999 0 +99 3 NULL NULL +99 NULL NULL NULL + +EXPLAIN SELECT * FROM t1 LEFT JOIN t2 force index (idx) ON t2.t2b <=> t1.t1b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL # 100.00 NULL +2 SIMPLE t2 NULL ref idx idx 5 test.t1.t1b # 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`t1a` AS `t1a`,`test`.`t1`.`t1b` AS `t1b`,`test`.`t2`.`t2a` AS `t2a`,`test`.`t2`.`t2b` AS `t2b` from `test`.`t1` left join `test`.`t2` FORCE INDEX (`idx`) on((`test`.`t2`.`t2b` <=> `test`.`t1`.`t1b`)) where true +SELECT * FROM t1 LEFT JOIN t2 force index (idx) ON t2.t2b <=> t1.t1b; +t1a t1b t2a t2b +99 0 100 0 +99 0 999 0 +99 3 NULL NULL +99 NULL 999 NULL + +DROP TABLE t2; +CREATE TABLE t2 (t2a int, t2b int NOT NULL, KEY idx (t2b)); +INSERT INTO t2 VALUES (100,0),(150,200),(999, 0); +ANALYZE TABLE t2; +Table Op Msg_type Msg_text +test.t2 analyze status OK + +# t2b is NOT NULL + +EXPLAIN SELECT * FROM t1 LEFT JOIN t2 force index (idx) ON t2.t2b = t1.t1b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL # 100.00 NULL +2 SIMPLE t2 NULL ref idx idx 4 test.t1.t1b # 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`t1a` AS `t1a`,`test`.`t1`.`t1b` AS `t1b`,`test`.`t2`.`t2a` AS `t2a`,`test`.`t2`.`t2b` AS `t2b` from `test`.`t1` left join `test`.`t2` FORCE INDEX (`idx`) on((`test`.`t2`.`t2b` = `test`.`t1`.`t1b`)) where true +SELECT * FROM t1 LEFT JOIN t2 force index (idx) ON t2.t2b = t1.t1b; +t1a t1b t2a t2b +99 0 100 0 +99 0 999 0 +99 3 NULL NULL +99 NULL NULL NULL + +EXPLAIN SELECT * FROM t1 LEFT JOIN t2 force index (idx) ON t2.t2b <=> t1.t1b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL # 100.00 NULL +2 SIMPLE t2 NULL ref idx idx 4 test.t1.t1b # 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`t1a` AS `t1a`,`test`.`t1`.`t1b` AS `t1b`,`test`.`t2`.`t2a` AS `t2a`,`test`.`t2`.`t2b` AS `t2b` from `test`.`t1` left join `test`.`t2` FORCE INDEX (`idx`) on((`test`.`t2`.`t2b` <=> `test`.`t1`.`t1b`)) where true +SELECT * FROM t1 LEFT JOIN t2 force index (idx) ON t2.t2b <=> t1.t1b; +t1a t1b t2a t2b +99 0 100 0 +99 0 999 0 +99 3 NULL NULL +99 NULL NULL NULL + +DROP TABLE t1,t2; +# +# BUG#12619399 - JCL: NO ROWS VS 3X NULL QUERY OUTPUT WHEN JCL>=5 +# +CREATE TABLE t1 ( +c1 INTEGER NOT NULL, +c2_key INTEGER NOT NULL, +KEY col_int_key (c2_key) +) ENGINE=InnoDB; +INSERT INTO t1 VALUES (24,204); +CREATE TABLE t2 ( +pk INTEGER NOT NULL, +PRIMARY KEY (pk) +) ENGINE=InnoDB; +INSERT INTO t2 VALUES (10); +CREATE TABLE t3 ( +c1 INTEGER, +KEY k1 (c1) +) ENGINE=InnoDB; +INSERT INTO t3 VALUES (NULL), (NULL); +set @old_opt_switch=@@optimizer_switch; + +ANALYZE TABLE t1, t2, t3; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +explain format=tree SELECT t3.c1 FROM t3 +WHERE t3.c1 = SOME (SELECT t1.c2_key FROM t2 JOIN t1 ON t2.pk < t1.c1) +XOR TRUE; +EXPLAIN +-> Filter: ((t3.c1,(select #2)) xor true) (cost=0.45 rows=2) + -> Index scan on t3 using k1 (cost=0.45 rows=2) + -> Select #2 (subquery in condition; dependent) + -> Limit: 1 row(s) (cost=0.70 rows=1) + -> Nested loop inner join (cost=0.70 rows=1) + -> Filter: (outer_field_is_not_null, ((t3.c1) = t1.c2_key), true) (cost=0.35 rows=1) + -> Alternative plans for IN subquery: Index lookup unless c2_key IS NULL (cost=0.35 rows=1) + -> Index lookup on t1 using col_int_key (c2_key=(t3.c1)) + -> Table scan on t1 + -> Filter: (t2.pk < t1.c1) (cost=0.35 rows=1) + -> Index range scan on t2 (re-planned for each iteration) (cost=0.35 rows=1) + +explain SELECT t3.c1 FROM t3 +WHERE t3.c1 = SOME (SELECT t1.c2_key FROM t2 JOIN t1 ON t2.pk < t1.c1) +XOR TRUE; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t3 NULL index NULL k1 5 NULL 2 100.00 Using where; Using index +2 DEPENDENT SUBQUERY t1 NULL ref col_int_key col_int_key 4 func 1 100.00 Using where; Full scan on NULL key +2 DEPENDENT SUBQUERY t2 NULL ALL PRIMARY NULL NULL NULL 1 100.00 Range checked for each record (index map: 0x1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`c1` AS `c1` from `test`.`t3` where ((`test`.`t3`.`c1`,(/* select#2 */ select `test`.`t1`.`c2_key` from `test`.`t2` join `test`.`t1` where ((outer_field_is_not_null, ((`test`.`t3`.`c1`) = `test`.`t1`.`c2_key`), true) and (`test`.`t2`.`pk` < `test`.`t1`.`c1`)))) xor true) +explain SELECT t3.c1 FROM t3 +WHERE t3.c1 = ANY (SELECT t1.c2_key FROM t2 JOIN t1 ON t2.pk < t1.c1) +XOR TRUE; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t3 NULL index NULL k1 5 NULL 2 100.00 Using where; Using index +2 DEPENDENT SUBQUERY t1 NULL ref col_int_key col_int_key 4 func 1 100.00 Using where; Full scan on NULL key +2 DEPENDENT SUBQUERY t2 NULL ALL PRIMARY NULL NULL NULL 1 100.00 Range checked for each record (index map: 0x1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`c1` AS `c1` from `test`.`t3` where ((`test`.`t3`.`c1`,(/* select#2 */ select `test`.`t1`.`c2_key` from `test`.`t2` join `test`.`t1` where ((outer_field_is_not_null, ((`test`.`t3`.`c1`) = `test`.`t1`.`c2_key`), true) and (`test`.`t2`.`pk` < `test`.`t1`.`c1`)))) xor true) +explain SELECT t3.c1 FROM t3 +WHERE t3.c1 IN (SELECT t1.c2_key FROM t2 JOIN t1 ON t2.pk < t1.c1) +XOR TRUE; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t3 NULL index NULL k1 5 NULL 2 100.00 Using where; Using index +2 DEPENDENT SUBQUERY t1 NULL ref col_int_key col_int_key 4 func 1 100.00 Using where; Full scan on NULL key +2 DEPENDENT SUBQUERY t2 NULL ALL PRIMARY NULL NULL NULL 1 100.00 Range checked for each record (index map: 0x1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`c1` AS `c1` from `test`.`t3` where ((`test`.`t3`.`c1`,(/* select#2 */ select `test`.`t1`.`c2_key` from `test`.`t2` join `test`.`t1` where ((outer_field_is_not_null, ((`test`.`t3`.`c1`) = `test`.`t1`.`c2_key`), true) and (`test`.`t2`.`pk` < `test`.`t1`.`c1`)))) xor true) +explain SELECT t3.c1 FROM t3 +WHERE t3.c1 NOT IN (SELECT t1.c2_key FROM t2 JOIN t1 ON t2.pk < t1.c1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t3 NULL index NULL k1 5 NULL 2 100.00 Using where; Using index +2 DEPENDENT SUBQUERY t1 NULL ref col_int_key col_int_key 4 func 1 100.00 Using where; Full scan on NULL key +2 DEPENDENT SUBQUERY t2 NULL ALL PRIMARY NULL NULL NULL 1 100.00 Range checked for each record (index map: 0x1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`c1` AS `c1` from `test`.`t3` where (`test`.`t3`.`c1`,(/* select#2 */ select `test`.`t1`.`c2_key` from `test`.`t2` join `test`.`t1` where ((outer_field_is_not_null, ((`test`.`t3`.`c1`) = `test`.`t1`.`c2_key`), true) and (`test`.`t2`.`pk` < `test`.`t1`.`c1`))) is false) +explain SELECT t3.c1 FROM t3 +WHERE t3.c1 IN (SELECT t1.c2_key FROM t2 JOIN t1 ON t2.pk < t1.c1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL col_int_key NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t2 NULL ALL PRIMARY NULL NULL NULL 1 100.00 Range checked for each record (index map: 0x1) +1 SIMPLE t3 NULL ref k1 k1 5 test.t1.c2_key 2 100.00 Using index; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`c1` AS `c1` from `test`.`t3` semi join (`test`.`t2` join `test`.`t1`) where ((`test`.`t3`.`c1` = `test`.`t1`.`c2_key`) and (`test`.`t2`.`pk` < `test`.`t1`.`c1`)) +SELECT t3.c1 FROM t3 +WHERE t3.c1 = SOME (SELECT t1.c2_key FROM t2 JOIN t1 ON t2.pk < t1.c1) +XOR TRUE; +c1 +SELECT t3.c1 FROM t3 +WHERE t3.c1 = ANY (SELECT t1.c2_key FROM t2 JOIN t1 ON t2.pk < t1.c1) +XOR TRUE; +c1 +SELECT t3.c1 FROM t3 +WHERE t3.c1 IN (SELECT t1.c2_key FROM t2 JOIN t1 ON t2.pk < t1.c1) +XOR TRUE; +c1 +SELECT t3.c1 FROM t3 +WHERE t3.c1 NOT IN (SELECT t1.c2_key FROM t2 JOIN t1 ON t2.pk < t1.c1); +c1 +SELECT t3.c1 FROM t3 +WHERE t3.c1 IN (SELECT t1.c2_key FROM t2 JOIN t1 ON t2.pk < t1.c1); +c1 + +set @@optimizer_switch=@old_opt_switch; +DROP TABLE t1, t2, t3; +set @@join_buffer_size=default; + +# BUG#12586926 "EXTRA ROW WITH JOIN + GROUP BY + ORDER BY WITH +# JCL>=5 AND MRR ENABLED" + +CREATE TABLE t1 ( col_int_key int(11) NOT NULL, +col_varchar_key varchar(1) NOT NULL, +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) ENGINE=innodb; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (0,'j'),(4,'b'),(4,'d'); +CREATE TABLE t2 ( +col_datetime_key datetime NOT NULL, +col_varchar_key varchar(1) NOT NULL, +KEY col_varchar_key (col_varchar_key) +) ENGINE=innodb; +INSERT INTO t2 VALUES ('2003-08-21 00:00:00','b'); +explain SELECT MIN(t2.col_datetime_key) AS field1, +t1.col_int_key AS field2 +FROM t1 +LEFT JOIN t2 force index (col_varchar_key) +ON t1.col_varchar_key = t2.col_varchar_key +GROUP BY field2 +ORDER BY field1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index col_int_key,col_varchar_key col_int_key 4 NULL 3 100.00 Using temporary; Using filesort +2 SIMPLE t2 NULL ref col_varchar_key col_varchar_key 6 test.t1.col_varchar_key 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select min(`test`.`t2`.`col_datetime_key`) AS `field1`,`test`.`t1`.`col_int_key` AS `field2` from `test`.`t1` left join `test`.`t2` FORCE INDEX (`col_varchar_key`) on((`test`.`t2`.`col_varchar_key` = `test`.`t1`.`col_varchar_key`)) where true group by `field2` order by `field1` +SELECT MIN(t2.col_datetime_key) AS field1, +t1.col_int_key AS field2 +FROM t1 +LEFT JOIN t2 force index (col_varchar_key) +ON t1.col_varchar_key = t2.col_varchar_key +GROUP BY field2 +ORDER BY field1; +field1 field2 +2003-08-21 00:00:00 4 +NULL 0 +DROP TABLE t1,t2; + +# BUG#12619510 "JCL: MORE ROWS AND DIFFERENT OUTPUT WITH JCL>=5" + +CREATE TABLE t1 ( +col_int_key int(11) NOT NULL, +col_datetime_key datetime NOT NULL, +col_varchar_nokey varchar(1) NOT NULL, +KEY col_int_key (col_int_key), +KEY col_datetime_key (col_datetime_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (7,'2004-06-06 04:22:12','v'); +INSERT INTO t1 VALUES (0,'2005-11-13 01:12:31','s'); +INSERT INTO t1 VALUES (9,'2002-05-04 01:50:00','l'); +INSERT INTO t1 VALUES (3,'2004-10-27 10:28:45','y'); +INSERT INTO t1 VALUES (4,'2006-07-22 05:24:23','c'); +INSERT INTO t1 VALUES (2,'2002-05-16 21:34:03','i'); +INSERT INTO t1 VALUES (5,'2008-04-17 10:45:30','h'); +INSERT INTO t1 VALUES (3,'2009-04-21 02:58:02','q'); +INSERT INTO t1 VALUES (1,'2008-01-11 11:01:51','a'); +INSERT INTO t1 VALUES (3,'1900-01-01 00:00:00','v'); +INSERT INTO t1 VALUES (6,'2007-05-17 18:24:57','u'); +INSERT INTO t1 VALUES (7,'2007-08-07 00:00:00','s'); +INSERT INTO t1 VALUES (5,'2001-08-28 00:00:00','y'); +INSERT INTO t1 VALUES (1,'2004-04-16 00:27:28','z'); +INSERT INTO t1 VALUES (204,'2005-05-03 07:06:22','h'); +INSERT INTO t1 VALUES (224,'2009-03-11 17:09:50','p'); +INSERT INTO t1 VALUES (9,'2007-12-08 01:54:28','e'); +INSERT INTO t1 VALUES (5,'2009-07-28 18:19:54','i'); +INSERT INTO t1 VALUES (0,'2008-06-08 00:00:00','y'); +INSERT INTO t1 VALUES (3,'2005-02-09 09:20:26','w'); +CREATE TABLE t2 ( +pk int(11) NOT NULL, +col_varchar_key varchar(1) NOT NULL, +PRIMARY KEY (pk) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES +(1,'j'),(2,'v'),(3,'c'),(4,'m'),(5,'d'),(6,'d'),(7,'y'), +(8,'t'),(9,'d'),(10,'s'),(11,'r'),(12,'m'),(13,'b'),(14,'x'), +(15,'g'),(16,'p'),(17,'q'),(18,'w'),(19,'d'),(20,'e'); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +explain SELECT t2.col_varchar_key AS field1 , COUNT(DISTINCT t1.col_varchar_nokey), t2.pk AS field4 +FROM t1 +RIGHT JOIN t2 ON t2.pk = t1.col_int_key +GROUP BY field1 , field4 +ORDER BY t1.col_datetime_key ; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 20 100.00 Using temporary; Using filesort +1 SIMPLE t1 NULL ref col_int_key col_int_key 4 test.t2.pk 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`col_varchar_key` AS `field1`,count(distinct `test`.`t1`.`col_varchar_nokey`) AS `COUNT(DISTINCT t1.col_varchar_nokey)`,`test`.`t2`.`pk` AS `field4` from `test`.`t2` left join `test`.`t1` on((`test`.`t1`.`col_int_key` = `test`.`t2`.`pk`)) where true group by `field1`,`field4` order by `test`.`t1`.`col_datetime_key` +SELECT t2.col_varchar_key AS field1 , COUNT(DISTINCT t1.col_varchar_nokey), t2.pk AS field4 +FROM t1 +RIGHT JOIN t2 ON t2.pk = t1.col_int_key +GROUP BY field1 , field4 +ORDER BY t1.col_datetime_key ; +field1 COUNT(DISTINCT t1.col_varchar_nokey) field4 +b 0 13 +c 4 3 +d 0 19 +d 1 6 +d 2 9 +d 3 5 +e 0 20 +g 0 15 +j 2 1 +m 0 12 +m 1 4 +p 0 16 +q 0 17 +r 0 11 +s 0 10 +t 0 8 +v 1 2 +w 0 18 +x 0 14 +y 2 7 +DROP TABLE t1,t2; + +# BUG#12619868 "JCL: MORE ROWS OF OUTPUT WHEN JCL>=5" + +CREATE TABLE t1 (col_varchar_key varchar(1)); +CREATE TABLE t2 ( +pk int(11) NOT NULL, +col_int_nokey int(11) NOT NULL, +col_int_key int(11) NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (5,3,9); +INSERT INTO t2 VALUES (6,246,24); +INSERT INTO t2 VALUES (7,2,6); +INSERT INTO t2 VALUES (8,9,1); +INSERT INTO t2 VALUES (9,3,6); +INSERT INTO t2 VALUES (10,8,2); +INSERT INTO t2 VALUES (11,1,4); +INSERT INTO t2 VALUES (12,8,8); +INSERT INTO t2 VALUES (13,8,4); +INSERT INTO t2 VALUES (14,5,4); +INSERT INTO t2 VALUES (15,7,7); +INSERT INTO t2 VALUES (16,5,4); +INSERT INTO t2 VALUES (17,1,1); +INSERT INTO t2 VALUES (18,6,9); +INSERT INTO t2 VALUES (19,2,4); +INSERT INTO t2 VALUES (20,9,8); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +ANALYZE TABLE t1, t2, t3, t4; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze Error Table 'test.t3' doesn't exist +test.t3 analyze status Operation failed +test.t4 analyze Error Table 'test.t4' doesn't exist +test.t4 analyze status Operation failed +explain SELECT t1.col_varchar_key AS field1, alias2.col_int_key AS field4 +FROM t2 AS alias2 STRAIGHT_JOIN t2 AS alias3 ON alias3.pk = +alias2.col_int_nokey +left join t1 +ON alias3.col_int_nokey +GROUP BY field1, field4 +LIMIT 15; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 16 100.00 Parallel execute (1 workers) +2 SIMPLE alias2 NULL ALL NULL NULL NULL NULL 16 100.00 Using temporary +2 SIMPLE alias3 NULL eq_ref PRIMARY PRIMARY 4 test.alias2.col_int_nokey 1 100.00 NULL +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col_varchar_key` AS `field1`,`test`.`alias2`.`col_int_key` AS `field4` from `test`.`t2` `alias2` straight_join `test`.`t2` `alias3` left join `test`.`t1` on((0 <> `test`.`alias3`.`col_int_nokey`)) where (`test`.`alias3`.`pk` = `test`.`alias2`.`col_int_nokey`) group by `field1`,`field4` limit 15 +SELECT t1.col_varchar_key AS field1, alias2.col_int_key AS field4 +FROM t2 AS alias2 STRAIGHT_JOIN t2 AS alias3 ON alias3.pk = +alias2.col_int_nokey +left join t1 +ON alias3.col_int_nokey +GROUP BY field1, field4 +LIMIT 15; +field1 field4 +NULL 1 +NULL 2 +NULL 4 +NULL 7 +NULL 8 +NULL 9 +DROP TABLE t1,t2; + +# BUG#12722133 - JCL: JOIN QUERY GIVES DIFFERENT RESULTS AT +# JCL=6 ONLY [NULL VERSUS NULL+#INTS] + +CREATE TABLE t1 (pk INTEGER PRIMARY KEY, k INTEGER, i INTEGER, KEY k(k)); +CREATE TABLE t2 LIKE t1; +CREATE TABLE t3 LIKE t1; +CREATE TABLE t4 LIKE t1; +INSERT INTO t1 VALUES (6,NULL,6),(0,1,11); +INSERT INTO t2 VALUES (1,NULL,NULL),(4,7,NULL); +INSERT INTO t3 VALUES (2,3,0),(3,4,4); +INSERT INTO t4 VALUES (1,9,-1),(4,7,NULL); +ANALYZE TABLE t1, t2, t3, t4; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +test.t4 analyze status OK +EXPLAIN SELECT t2.pk as t2_pk, t4.pk as t4_pk, t4.k as t4_k, t4.i +as t4_i FROM t1 +LEFT JOIN t2 ON t1.k = t2.pk +LEFT JOIN t3 ON t3.i +LEFT JOIN t4 ON t4.pk = t2.pk; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL k 5 NULL 2 100.00 Using index +2 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.k 1 100.00 Using index +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +2 SIMPLE t4 NULL eq_ref PRIMARY PRIMARY 4 test.t2.pk 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`pk` AS `t2_pk`,`test`.`t4`.`pk` AS `t4_pk`,`test`.`t4`.`k` AS `t4_k`,`test`.`t4`.`i` AS `t4_i` from `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`pk` = `test`.`t1`.`k`)) left join `test`.`t3` on((0 <> `test`.`t3`.`i`)) left join `test`.`t4` on((`test`.`t4`.`pk` = `test`.`t2`.`pk`)) where true +SELECT t2.pk as t2_pk, t4.pk as t4_pk, t4.k as t4_k, t4.i +as t4_i FROM t1 +LEFT JOIN t2 ON t1.k = t2.pk +LEFT JOIN t3 ON t3.i +LEFT JOIN t4 ON t4.pk = t2.pk; +t2_pk t4_pk t4_k t4_i +1 1 9 -1 +NULL NULL NULL NULL +DROP TABLE t1, t2, t3, t4; + +# BUG#12827509 - BNL/BKA: SELECT LEFT/RIGHT JOIN QUERY GIVES +# DIFFERENT OUTPUT ON BNL=OFF+BKA=ON +# (Duplicate of BUG#12722133) + +CREATE TABLE t1 ( +col_int INTEGER +); +INSERT INTO t1 VALUES (3), (7), (2), (8), (6); +CREATE TABLE t2 ( +pk INTEGER, +col_int INTEGER, +PRIMARY KEY (pk) +); +INSERT INTO t2 VALUES (1,5), (2,8), (6,3), (8,7), (9,9); +CREATE TABLE t3 ( +pk INTEGER, +col_int INTEGER, +PRIMARY KEY (pk) +); +INSERT INTO t3 VALUES (3,2), (4,3), (8,2); +CREATE TABLE t4 ( +pk INTEGER, +col_int INTEGER, +PRIMARY KEY (pk) +); +INSERT INTO t4 VALUES (2,3), (6,1), (8,2); +ANALYZE TABLE t2, t3, t4; +Table Op Msg_type Msg_text +test.t2 analyze status OK +test.t3 analyze status OK +test.t4 analyze status OK +EXPLAIN +SELECT t4.col_int +FROM t1 +LEFT JOIN t2 ON t1.col_int = t2.col_int +LEFT JOIN t3 ON t2.pk = t3.pk +LEFT JOIN t4 ON t4.pk = t2.pk +WHERE t1.col_int OR t3.col_int; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL # 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL # 100.00 Using where +2 SIMPLE t3 NULL eq_ref PRIMARY PRIMARY 4 test.t2.pk # 100.00 Using where +2 SIMPLE t4 NULL eq_ref PRIMARY PRIMARY 4 test.t2.pk # 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`col_int` AS `col_int` from `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`col_int` = `test`.`t1`.`col_int`)) left join `test`.`t3` on((`test`.`t3`.`pk` = `test`.`t2`.`pk`)) left join `test`.`t4` on((`test`.`t4`.`pk` = `test`.`t2`.`pk`)) where ((0 <> `test`.`t1`.`col_int`) or (0 <> `test`.`t3`.`col_int`)) +SELECT t4.col_int +FROM t1 +LEFT JOIN t2 ON t1.col_int = t2.col_int +LEFT JOIN t3 ON t2.pk = t3.pk +LEFT JOIN t4 ON t4.pk = t2.pk +WHERE t1.col_int OR t3.col_int; +col_int +1 +2 +3 +NULL +NULL +DROP TABLE t1, t2, t3, t4; +# +# Bug#12997905: VALGRIND: SYSCALL PARAM PWRITE64(BUF) +# POINTS TO UNINITIALISED BYTE(S) +# +CREATE TABLE t1 ( +col1 varchar(10), +col2 varchar(1024) +) ENGINE=innodb; +INSERT INTO t1 VALUES ('a','a'); +CREATE TABLE t2 (i varchar(10)) ENGINE=innodb; +INSERT INTO t2 VALUES ('a'); +SELECT t1.col1 +FROM t1 JOIN t2 ON t1.col1 = t2.i +GROUP BY t1.col2; +col1 +a +DROP TABLE t1,t2; +# End of Bug#12997905 +# +# Bug 13596330 - EXTRA ROW ON SELECT WITH NESTED IN CLAUSE + IS +# NULL WHEN SEMIJOIN + BNL IS ON +# +CREATE TABLE t1 ( +col_int_nokey int +); +INSERT INTO t1 VALUES(-1),(-1); +CREATE TABLE t2 ( +col_int_nokey int, +col_datetime_nokey datetime NOT NULL, +col_varchar_key varchar(1), +KEY col_varchar_key (col_varchar_key) +); +INSERT INTO t2 VALUES (9, '2002-08-25 20:35:06', 'e'), +(9, '2002-08-25 20:35:06', 'e'); +set @optimizer_switch_saved=@@session.optimizer_switch; +set @@session.optimizer_switch='semijoin=off'; +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN SELECT parent1.col_varchar_key +FROM t2 AS parent1 LEFT JOIN t1 USING (col_int_nokey) +WHERE parent1.col_varchar_key IN +( SELECT col_varchar_key FROM t2 AS child1 +WHERE parent1.col_datetime_nokey IS NULL +AND t1.col_int_nokey IS NULL ) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY parent1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +2 DEPENDENT SUBQUERY child1 NULL index_subquery col_varchar_key col_varchar_key 7 func 2 100.00 Using where; Using index +Warnings: +Note 1276 Field or reference 'test.parent1.col_datetime_nokey' of SELECT #2 was resolved in SELECT #1 +Note 1276 Field or reference 'test.t1.col_int_nokey' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`parent1`.`col_varchar_key` AS `col_varchar_key` from `test`.`t2` `parent1` left join `test`.`t1` on((`test`.`t1`.`col_int_nokey` = `test`.`parent1`.`col_int_nokey`)) where (`test`.`parent1`.`col_varchar_key`,(((`test`.`parent1`.`col_varchar_key`) in t2 on col_varchar_key where ((`test`.`parent1`.`col_datetime_nokey` = TIMESTAMP'0000-00-00 00:00:00') and (`test`.`t1`.`col_int_nokey` is null))))) +SELECT parent1.col_varchar_key +FROM t2 AS parent1 LEFT JOIN t1 USING (col_int_nokey) +WHERE parent1.col_varchar_key IN +( SELECT col_varchar_key FROM t2 AS child1 +WHERE parent1.col_datetime_nokey IS NULL +AND t1.col_int_nokey IS NULL ) +; +col_varchar_key +set @@session.optimizer_switch=@optimizer_switch_saved; +DROP TABLE t1,t2; +# +# Bug#29435133 JOIN_CACHE::JOIN_RECORD() MAY LEAVE A TABLE IN HAS_NULL_ROW-STATE +# +CREATE TABLE t1 ( +col_varchar_10_unique varchar(10) +) ENGINE=innodb; +INSERT INTO t1 VALUES ('nthfyejwxd'); +INSERT INTO t1 VALUES ('drrqahbhai'); +CREATE TABLE t3 ( +col_int int(11) NOT NULL, +col_int_unique int(11) not null, +col_varchar_10 varchar(10) not null +) ENGINE=innodb; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t3 VALUES(9, 4, ''); +CREATE TABLE t4 ( +col_int_unique int(11) +) ENGINE=innodb; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t4 VALUES(3); +CREATE TABLE t2 ( +col_int int(11) +) ENGINE=innodb; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN SELECT * FROM t1 AS table1 +WHERE +table1.col_varchar_10_unique = ALL ( +SELECT STRAIGHT_JOIN table3s.col_varchar_10 AS field3 FROM +t4 AS table4s LEFT JOIN +(t3 AS table3s JOIN t2 AS table2s) +ON table3s.col_int_unique = table4s.col_int_unique); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY table1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +2 DEPENDENT SUBQUERY table4s NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 DEPENDENT SUBQUERY table3s NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 DEPENDENT SUBQUERY table2s NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`table1`.`col_varchar_10_unique` AS `col_varchar_10_unique` from `test`.`t1` `table1` where ((`test`.`table1`.`col_varchar_10_unique`,(/* select#2 */ select straight_join `test`.`table3s`.`col_varchar_10` AS `field3` from `test`.`t4` `table4s` left join (`test`.`t3` `table3s` join `test`.`t2` `table2s`) on((`test`.`table3s`.`col_int_unique` = `test`.`table4s`.`col_int_unique`)) where (outer_field_is_not_null, (((`test`.`table1`.`col_varchar_10_unique`) <> `test`.`table3s`.`col_varchar_10`) or (`test`.`table3s`.`col_varchar_10` is null)), true) having (outer_field_is_not_null, (`test`.`table3s`.`col_varchar_10`), true)))) +SELECT * FROM t1 AS table1 +WHERE +table1.col_varchar_10_unique = ALL ( +SELECT STRAIGHT_JOIN table3s.col_varchar_10 AS field3 FROM +t4 AS table4s LEFT JOIN +(t3 AS table3s JOIN t2 AS table2s) +ON table3s.col_int_unique = table4s.col_int_unique); +col_varchar_10_unique +DROP TABLE t1,t2,t3,t4; +# +# t2 and t3 are const tables, which makes for a t1-t4 join on a constant, +# where the constant comes from a multi-equality. Verify that we get the expected +# query plan and don't crash (we don't care about the result). +# +CREATE TABLE t1 ( +pk integer NOT NULL, +a integer, +b integer, +PRIMARY KEY (pk), +KEY idx1 (b) +) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1,5,5); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN FORMAT=tree SELECT * +FROM +t1 +LEFT JOIN t1 AS t2 ON t1.a = t2.pk +LEFT JOIN t1 AS t3 ON t2.pk = t3.pk +LEFT JOIN t1 AS t4 ON t3.b = t4.b +WHERE t2.pk = 1; +EXPLAIN +-> Parallel scan on + -> Nested loop left join (cost=0.70 rows=1) + -> Filter: (t1.a = 1) (cost=0.35 rows=1) + -> PQblock scan on t1 (cost=0.35 rows=1) + -> Index lookup on t4 using idx1 (b='5') (cost=0.35 rows=1) + +DROP TABLE t1; +set optimizer_switch = default; diff --git a/mysql-test/r/join_nested.result-pq b/mysql-test/r/join_nested.result-pq new file mode 100644 index 000000000000..4f6687409038 --- /dev/null +++ b/mysql-test/r/join_nested.result-pq @@ -0,0 +1,2649 @@ +DROP TABLE IF EXISTS t0,t1,t2,t3,t4,t5,t6,t7,t8,t9; +CREATE TABLE t0 (a int, b int, c int); +CREATE TABLE t1 (a int, b int, c int); +CREATE TABLE t2 (a int, b int, c int); +CREATE TABLE t3 (a int, b int, c int); +CREATE TABLE t4 (a int, b int, c int); +CREATE TABLE t5 (a int, b int, c int); +CREATE TABLE t6 (a int, b int, c int); +CREATE TABLE t7 (a int, b int, c int); +CREATE TABLE t8 (a int, b int, c int); +CREATE TABLE t9 (a int, b int, c int); +INSERT INTO t0 VALUES (1,1,0), (1,2,0), (2,2,0); +INSERT INTO t1 VALUES (1,3,0), (2,2,0), (3,2,0); +INSERT INTO t2 VALUES (3,3,0), (4,2,0), (5,3,0); +INSERT INTO t3 VALUES (1,2,0), (2,2,0); +INSERT INTO t4 VALUES (3,2,0), (4,2,0); +INSERT INTO t5 VALUES (3,1,0), (2,2,0), (3,3,0); +INSERT INTO t6 VALUES (3,2,0), (6,2,0), (6,1,0); +INSERT INTO t7 VALUES (1,1,0), (2,2,0); +INSERT INTO t8 VALUES (0,2,0), (1,2,0); +INSERT INTO t9 VALUES (1,1,0), (1,2,0), (3,3,0); +CREATE TABLE t34 (a3 int, b3 int, c3 int, a4 int, b4 int, c4 int); +INSERT INTO t34 +SELECT t3.*, t4.* +FROM t3 CROSS JOIN t4; +CREATE TABLE t345 (a3 int, b3 int, c3 int, a4 int, b4 int, c4 int, +a5 int, b5 int, c5 int); +INSERT INTO t345 +SELECT t3.*, t4.*, t5.* +FROM t3 CROSS JOIN t4 CROSS JOIN t5; +CREATE TABLE t67 (a6 int, b6 int, c6 int, a7 int, b7 int, c7 int); +INSERT INTO t67 +SELECT t6.*, t7.* +FROM t6 CROSS JOIN t7; +SELECT t2.a,t2.b +FROM t2; +a b +3 3 +4 2 +5 3 +SELECT t3.a,t3.b +FROM t3; +a b +1 2 +2 2 +SELECT t4.a,t4.b +FROM t4; +a b +3 2 +4 2 +SELECT t3.a,t3.b,t4.a,t4.b +FROM t3,t4; +a b a b +1 2 3 2 +1 2 4 2 +2 2 3 2 +2 2 4 2 +SELECT t2.a,t2.b,t3.a,t3.b,t4.a,t4.b +FROM t2 +LEFT JOIN +(t3, t4) +ON t2.b=t4.b; +a b a b a b +3 3 NULL NULL NULL NULL +4 2 1 2 3 2 +4 2 1 2 4 2 +4 2 2 2 3 2 +4 2 2 2 4 2 +5 3 NULL NULL NULL NULL +"Standard compliant copy of above query" +SELECT t2.a,t2.b,t34.a3,t34.b3,t34.a4,t34.b4 +FROM t2 +LEFT JOIN t34 +ON t2.b=t34.b4; +a b a3 b3 a4 b4 +3 3 NULL NULL NULL NULL +4 2 1 2 3 2 +4 2 1 2 4 2 +4 2 2 2 3 2 +4 2 2 2 4 2 +5 3 NULL NULL NULL NULL +SELECT t2.a,t2.b,t3.a,t3.b,t4.a,t4.b +FROM t2 +LEFT JOIN +(t3, t4) +ON t3.a=1 AND t2.b=t4.b; +a b a b a b +3 3 NULL NULL NULL NULL +4 2 1 2 3 2 +4 2 1 2 4 2 +5 3 NULL NULL NULL NULL +"Standard compliant copy of above query" +SELECT t2.a,t2.b,t34.a3,t34.b3,t34.a4,t34.b4 +FROM t2 +LEFT JOIN t34 +ON t34.a3=1 AND t2.b=t34.b4; +a b a3 b3 a4 b4 +3 3 NULL NULL NULL NULL +4 2 1 2 3 2 +4 2 1 2 4 2 +5 3 NULL NULL NULL NULL +ANALYZE TABLE t1, t2, t3, t4; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +test.t4 analyze status OK +EXPLAIN +SELECT t2.a,t2.b,t3.a,t3.b,t4.a,t4.b +FROM t2 +LEFT JOIN +(t3, t4) +ON t2.b=t4.b +WHERE t3.a=1 OR t3.c IS NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 75.00 Using where; Using join buffer (hash join) +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b` from `test`.`t2` left join (`test`.`t3` join `test`.`t4`) on((`test`.`t4`.`b` = `test`.`t2`.`b`)) where ((`test`.`t3`.`a` = 1) or (`test`.`t3`.`c` is null)) +SELECT t2.a,t2.b,t3.a,t3.b,t4.a,t4.b +FROM t2 +LEFT JOIN +(t3, t4) +ON t2.b=t4.b +WHERE t3.a=1 OR t3.c IS NULL; +a b a b a b +3 3 NULL NULL NULL NULL +4 2 1 2 3 2 +4 2 1 2 4 2 +5 3 NULL NULL NULL NULL +"Standard compliant copy of above query" +SELECT t2.a,t2.b,t34.a3,t34.b3,t34.a4,t34.b4 +FROM t2 +LEFT JOIN t34 +ON t2.b=t34.b4 +WHERE t34.a3=1 OR t34.c3 IS NULL; +a b a3 b3 a4 b4 +3 3 NULL NULL NULL NULL +4 2 1 2 3 2 +4 2 1 2 4 2 +5 3 NULL NULL NULL NULL +SELECT t2.a,t2.b,t3.a,t3.b,t4.a,t4.b +FROM t2 +LEFT JOIN +(t3, t4) +ON t2.b=t4.b +WHERE t3.a>1 OR t3.c IS NULL; +a b a b a b +3 3 NULL NULL NULL NULL +4 2 2 2 3 2 +4 2 2 2 4 2 +5 3 NULL NULL NULL NULL +"Standard compliant copy of above query" +SELECT t2.a,t2.b,t34.a3,t34.b3,t34.a4,t34.b4 +FROM t2 +LEFT JOIN t34 +ON t2.b=t34.b4 +WHERE t34.a3>1 OR t34.c3 IS NULL; +a b a3 b3 a4 b4 +3 3 NULL NULL NULL NULL +4 2 2 2 3 2 +4 2 2 2 4 2 +5 3 NULL NULL NULL NULL +SELECT t5.a,t5.b +FROM t5; +a b +3 1 +2 2 +3 3 +SELECT t3.a,t3.b,t4.a,t4.b,t5.a,t5.b +FROM t3,t4,t5; +a b a b a b +1 2 3 2 2 2 +1 2 3 2 3 1 +1 2 3 2 3 3 +1 2 4 2 2 2 +1 2 4 2 3 1 +1 2 4 2 3 3 +2 2 3 2 2 2 +2 2 3 2 3 1 +2 2 3 2 3 3 +2 2 4 2 2 2 +2 2 4 2 3 1 +2 2 4 2 3 3 +SELECT t2.a,t2.b,t3.a,t3.b,t4.a,t4.b,t5.a,t5.b +FROM t2 +LEFT JOIN +(t3, t4, t5) +ON t2.b=t4.b; +a b a b a b a b +3 3 NULL NULL NULL NULL NULL NULL +4 2 1 2 3 2 2 2 +4 2 1 2 3 2 3 1 +4 2 1 2 3 2 3 3 +4 2 1 2 4 2 2 2 +4 2 1 2 4 2 3 1 +4 2 1 2 4 2 3 3 +4 2 2 2 3 2 2 2 +4 2 2 2 3 2 3 1 +4 2 2 2 3 2 3 3 +4 2 2 2 4 2 2 2 +4 2 2 2 4 2 3 1 +4 2 2 2 4 2 3 3 +5 3 NULL NULL NULL NULL NULL NULL +"Standard compliant copy of above query" +SELECT t2.a,t2.b,t345.a3,t345.b3,t345.a4,t345.b4,t345.a5,t345.b5 +FROM t2 +LEFT JOIN t345 +ON t2.b=t345.b4; +a b a3 b3 a4 b4 a5 b5 +3 3 NULL NULL NULL NULL NULL NULL +4 2 1 2 3 2 2 2 +4 2 1 2 3 2 3 1 +4 2 1 2 3 2 3 3 +4 2 1 2 4 2 2 2 +4 2 1 2 4 2 3 1 +4 2 1 2 4 2 3 3 +4 2 2 2 3 2 2 2 +4 2 2 2 3 2 3 1 +4 2 2 2 3 2 3 3 +4 2 2 2 4 2 2 2 +4 2 2 2 4 2 3 1 +4 2 2 2 4 2 3 3 +5 3 NULL NULL NULL NULL NULL NULL +ANALYZE TABLE t2, t3, t4, t5; +Table Op Msg_type Msg_text +test.t2 analyze status OK +test.t3 analyze status OK +test.t4 analyze status OK +test.t5 analyze status OK +EXPLAIN +SELECT t2.a,t2.b,t3.a,t3.b,t4.a,t4.b,t5.a,t5.b +FROM t2 +LEFT JOIN +(t3, t4, t5) +ON t2.b=t4.b +WHERE t3.a>1 OR t3.c IS NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 75.00 Using where; Using join buffer (hash join) +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t5 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t5`.`a` AS `a`,`test`.`t5`.`b` AS `b` from `test`.`t2` left join (`test`.`t3` join `test`.`t4` join `test`.`t5`) on((`test`.`t4`.`b` = `test`.`t2`.`b`)) where ((`test`.`t3`.`a` > 1) or (`test`.`t3`.`c` is null)) +SELECT t2.a,t2.b,t3.a,t3.b,t4.a,t4.b,t5.a,t5.b +FROM t2 +LEFT JOIN +(t3, t4, t5) +ON t2.b=t4.b +WHERE t3.a>1 OR t3.c IS NULL; +a b a b a b a b +3 3 NULL NULL NULL NULL NULL NULL +4 2 2 2 3 2 2 2 +4 2 2 2 3 2 3 1 +4 2 2 2 3 2 3 3 +4 2 2 2 4 2 2 2 +4 2 2 2 4 2 3 1 +4 2 2 2 4 2 3 3 +5 3 NULL NULL NULL NULL NULL NULL +"Standard compliant copy of above query" +SELECT t2.a,t2.b,t345.a3,t345.b3,t345.a4,t345.b4,t345.a5,t345.b5 +FROM t2 +LEFT JOIN t345 +ON t2.b=t345.b4 +WHERE t345.a3>1 OR t345.c3 IS NULL; +a b a3 b3 a4 b4 a5 b5 +3 3 NULL NULL NULL NULL NULL NULL +4 2 2 2 3 2 2 2 +4 2 2 2 3 2 3 1 +4 2 2 2 3 2 3 3 +4 2 2 2 4 2 2 2 +4 2 2 2 4 2 3 1 +4 2 2 2 4 2 3 3 +5 3 NULL NULL NULL NULL NULL NULL +ANALYZE TABLE t2, t3, t4, t5; +Table Op Msg_type Msg_text +test.t2 analyze status OK +test.t3 analyze status OK +test.t4 analyze status OK +test.t5 analyze status OK +EXPLAIN +SELECT t2.a,t2.b,t3.a,t3.b,t4.a,t4.b,t5.a,t5.b +FROM t2 +LEFT JOIN +(t3, t4, t5) +ON t2.b=t4.b +WHERE (t3.a>1 OR t3.c IS NULL) AND +(t5.a<3 OR t5.c IS NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 75.00 Using where; Using join buffer (hash join) +2 SIMPLE t5 NULL ALL NULL NULL NULL NULL 3 55.56 Using where; Using join buffer (hash join) +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t5`.`a` AS `a`,`test`.`t5`.`b` AS `b` from `test`.`t2` left join (`test`.`t3` join `test`.`t4` join `test`.`t5`) on((`test`.`t4`.`b` = `test`.`t2`.`b`)) where (((`test`.`t3`.`a` > 1) or (`test`.`t3`.`c` is null)) and ((`test`.`t5`.`a` < 3) or (`test`.`t5`.`c` is null))) +SELECT t2.a,t2.b,t3.a,t3.b,t4.a,t4.b,t5.a,t5.b +FROM t2 +LEFT JOIN +(t3, t4, t5) +ON t2.b=t4.b +WHERE (t3.a>1 OR t3.c IS NULL) AND +(t5.a<3 OR t5.c IS NULL); +a b a b a b a b +3 3 NULL NULL NULL NULL NULL NULL +4 2 2 2 3 2 2 2 +4 2 2 2 4 2 2 2 +5 3 NULL NULL NULL NULL NULL NULL +"Standard compliant copy of above query" +SELECT t2.a,t2.b,t345.a3,t345.b3,t345.a4,t345.b4,t345.a5,t345.b5 +FROM t2 +LEFT JOIN t345 +ON t2.b=t345.b4 +WHERE (t345.a3>1 OR t345.c3 IS NULL) AND +(t345.a5<3 OR t345.c5 IS NULL); +a b a3 b3 a4 b4 a5 b5 +3 3 NULL NULL NULL NULL NULL NULL +4 2 2 2 3 2 2 2 +4 2 2 2 4 2 2 2 +5 3 NULL NULL NULL NULL NULL NULL +SELECT t6.a,t6.b +FROM t6; +a b +3 2 +6 2 +6 1 +SELECT t7.a,t7.b +FROM t7; +a b +1 1 +2 2 +SELECT t6.a,t6.b,t7.a,t7.b +FROM t6,t7; +a b a b +3 2 1 1 +3 2 2 2 +6 1 1 1 +6 1 2 2 +6 2 1 1 +6 2 2 2 +SELECT t8.a,t8.b +FROM t8; +a b +0 2 +1 2 +ANALYZE TABLE t6, t7, t8; +Table Op Msg_type Msg_text +test.t6 analyze status OK +test.t7 analyze status OK +test.t8 analyze status OK +EXPLAIN +SELECT t6.a,t6.b,t7.a,t7.b,t8.a,t8.b +FROM (t6, t7) +LEFT JOIN +t8 +ON t7.b=t8.b AND t6.b < 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t7 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 SIMPLE t6 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 SIMPLE t8 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t6`.`a` AS `a`,`test`.`t6`.`b` AS `b`,`test`.`t7`.`a` AS `a`,`test`.`t7`.`b` AS `b`,`test`.`t8`.`a` AS `a`,`test`.`t8`.`b` AS `b` from `test`.`t6` join `test`.`t7` left join `test`.`t8` on(((`test`.`t8`.`b` = `test`.`t7`.`b`) and (`test`.`t6`.`b` < 10))) where true +SELECT t6.a,t6.b,t7.a,t7.b,t8.a,t8.b +FROM (t6, t7) +LEFT JOIN +t8 +ON t7.b=t8.b AND t6.b < 10; +a b a b a b +3 2 1 1 NULL NULL +3 2 2 2 0 2 +3 2 2 2 1 2 +6 1 1 1 NULL NULL +6 1 2 2 0 2 +6 1 2 2 1 2 +6 2 1 1 NULL NULL +6 2 2 2 0 2 +6 2 2 2 1 2 +"Standard compliant copy of above query" +SELECT t67.a6,t67.b6,t67.a7,t67.b7,t8.a,t8.b +FROM t67 +LEFT JOIN +t8 +ON t67.b7=t8.b AND t67.b6 < 10; +a6 b6 a7 b7 a b +3 2 1 1 NULL NULL +3 2 2 2 0 2 +3 2 2 2 1 2 +6 1 1 1 NULL NULL +6 1 2 2 0 2 +6 1 2 2 1 2 +6 2 1 1 NULL NULL +6 2 2 2 0 2 +6 2 2 2 1 2 +SELECT t5.a,t5.b +FROM t5; +a b +3 1 +2 2 +3 3 +SELECT t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b +FROM t5 +LEFT JOIN +( +(t6, t7) +LEFT JOIN +t8 +ON t7.b=t8.b AND t6.b < 10 +) +ON t6.b >= 2 AND t5.b=t7.b; +a b a b a b a b +2 2 3 2 2 2 0 2 +2 2 3 2 2 2 1 2 +2 2 6 2 2 2 0 2 +2 2 6 2 2 2 1 2 +3 1 3 2 1 1 NULL NULL +3 1 6 2 1 1 NULL NULL +3 3 NULL NULL NULL NULL NULL NULL +"Standard compliant copy of above query" +SELECT t5.a,t5.b,t67.a6,t67.b6,t67.a7,t67.b7,t8.a,t8.b +FROM t5 +LEFT JOIN +( +t67 +LEFT JOIN +t8 +ON t67.b7=t8.b AND t67.b6 < 10 +) +ON t67.b6 >= 2 AND t5.b=t67.b7; +a b a6 b6 a7 b7 a b +2 2 3 2 2 2 0 2 +2 2 3 2 2 2 1 2 +2 2 6 2 2 2 0 2 +2 2 6 2 2 2 1 2 +3 1 3 2 1 1 NULL NULL +3 1 6 2 1 1 NULL NULL +3 3 NULL NULL NULL NULL NULL NULL +SELECT t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b +FROM t5 +LEFT JOIN +( +(t6, t7) +LEFT JOIN +t8 +ON t7.b=t8.b AND t6.b < 10 +) +ON t6.b >= 2 AND t5.b=t7.b AND +(t8.a < 1 OR t8.c IS NULL); +a b a b a b a b +2 2 3 2 2 2 0 2 +2 2 6 2 2 2 0 2 +3 1 3 2 1 1 NULL NULL +3 1 6 2 1 1 NULL NULL +3 3 NULL NULL NULL NULL NULL NULL +"Standard compliant copy of above query" +SELECT t5.a,t5.b,t67.a6,t67.b6,t67.a7,t67.b7,t8.a,t8.b +FROM t5 +LEFT JOIN +( +t67 +LEFT JOIN +t8 +ON t67.b7=t8.b AND t67.b6 < 10 +) +ON t67.b6 >= 2 AND t5.b=t67.b7 AND +(t8.a < 1 OR t8.c IS NULL); +a b a6 b6 a7 b7 a b +2 2 3 2 2 2 0 2 +2 2 6 2 2 2 0 2 +3 1 3 2 1 1 NULL NULL +3 1 6 2 1 1 NULL NULL +3 3 NULL NULL NULL NULL NULL NULL +SELECT t2.a,t2.b,t3.a,t3.b,t4.a,t4.b +FROM t2 +LEFT JOIN +(t3, t4) +ON t3.a=1 AND t2.b=t4.b; +a b a b a b +3 3 NULL NULL NULL NULL +4 2 1 2 3 2 +4 2 1 2 4 2 +5 3 NULL NULL NULL NULL +"Standard compliant copy of above query" +SELECT t2.a,t2.b,t34.a3,t34.b3,t34.a4,t34.b4 +FROM t2 +LEFT JOIN t34 +ON t34.a3=1 AND t2.b=t34.b4; +a b a3 b3 a4 b4 +3 3 NULL NULL NULL NULL +4 2 1 2 3 2 +4 2 1 2 4 2 +5 3 NULL NULL NULL NULL +SELECT t2.a,t2.b,t3.a,t3.b,t4.a,t4.b, +t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b +FROM t2 +LEFT JOIN +(t3, t4) +ON t3.a=1 AND t2.b=t4.b, +t5 +LEFT JOIN +( +(t6, t7) +LEFT JOIN +t8 +ON t7.b=t8.b AND t6.b < 10 +) +ON t6.b >= 2 AND t5.b=t7.b; +a b a b a b a b a b a b a b +3 3 NULL NULL NULL NULL 2 2 3 2 2 2 0 2 +3 3 NULL NULL NULL NULL 2 2 3 2 2 2 1 2 +3 3 NULL NULL NULL NULL 2 2 6 2 2 2 0 2 +3 3 NULL NULL NULL NULL 2 2 6 2 2 2 1 2 +3 3 NULL NULL NULL NULL 3 1 3 2 1 1 NULL NULL +3 3 NULL NULL NULL NULL 3 1 6 2 1 1 NULL NULL +3 3 NULL NULL NULL NULL 3 3 NULL NULL NULL NULL NULL NULL +4 2 1 2 3 2 2 2 3 2 2 2 0 2 +4 2 1 2 3 2 2 2 3 2 2 2 1 2 +4 2 1 2 3 2 2 2 6 2 2 2 0 2 +4 2 1 2 3 2 2 2 6 2 2 2 1 2 +4 2 1 2 3 2 3 1 3 2 1 1 NULL NULL +4 2 1 2 3 2 3 1 6 2 1 1 NULL NULL +4 2 1 2 3 2 3 3 NULL NULL NULL NULL NULL NULL +4 2 1 2 4 2 2 2 3 2 2 2 0 2 +4 2 1 2 4 2 2 2 3 2 2 2 1 2 +4 2 1 2 4 2 2 2 6 2 2 2 0 2 +4 2 1 2 4 2 2 2 6 2 2 2 1 2 +4 2 1 2 4 2 3 1 3 2 1 1 NULL NULL +4 2 1 2 4 2 3 1 6 2 1 1 NULL NULL +4 2 1 2 4 2 3 3 NULL NULL NULL NULL NULL NULL +5 3 NULL NULL NULL NULL 2 2 3 2 2 2 0 2 +5 3 NULL NULL NULL NULL 2 2 3 2 2 2 1 2 +5 3 NULL NULL NULL NULL 2 2 6 2 2 2 0 2 +5 3 NULL NULL NULL NULL 2 2 6 2 2 2 1 2 +5 3 NULL NULL NULL NULL 3 1 3 2 1 1 NULL NULL +5 3 NULL NULL NULL NULL 3 1 6 2 1 1 NULL NULL +5 3 NULL NULL NULL NULL 3 3 NULL NULL NULL NULL NULL NULL +"Standard compliant copy of above query" +SELECT t2.a,t2.b,t34.a3,t34.b3,t34.a4,t34.b4, +t5.a,t5.b,t67.a6,t67.b6,t67.a7,t67.b7,t8.a,t8.b +FROM t2 +LEFT JOIN t34 +ON t34.a3=1 AND t2.b=t34.b4 +CROSS JOIN t5 +LEFT JOIN +( +t67 +LEFT JOIN +t8 +ON t67.b7=t8.b AND t67.b6 < 10 +) +ON t67.b6 >= 2 AND t5.b=t67.b7; +a b a3 b3 a4 b4 a b a6 b6 a7 b7 a b +3 3 NULL NULL NULL NULL 2 2 3 2 2 2 0 2 +3 3 NULL NULL NULL NULL 2 2 3 2 2 2 1 2 +3 3 NULL NULL NULL NULL 2 2 6 2 2 2 0 2 +3 3 NULL NULL NULL NULL 2 2 6 2 2 2 1 2 +3 3 NULL NULL NULL NULL 3 1 3 2 1 1 NULL NULL +3 3 NULL NULL NULL NULL 3 1 6 2 1 1 NULL NULL +3 3 NULL NULL NULL NULL 3 3 NULL NULL NULL NULL NULL NULL +4 2 1 2 3 2 2 2 3 2 2 2 0 2 +4 2 1 2 3 2 2 2 3 2 2 2 1 2 +4 2 1 2 3 2 2 2 6 2 2 2 0 2 +4 2 1 2 3 2 2 2 6 2 2 2 1 2 +4 2 1 2 3 2 3 1 3 2 1 1 NULL NULL +4 2 1 2 3 2 3 1 6 2 1 1 NULL NULL +4 2 1 2 3 2 3 3 NULL NULL NULL NULL NULL NULL +4 2 1 2 4 2 2 2 3 2 2 2 0 2 +4 2 1 2 4 2 2 2 3 2 2 2 1 2 +4 2 1 2 4 2 2 2 6 2 2 2 0 2 +4 2 1 2 4 2 2 2 6 2 2 2 1 2 +4 2 1 2 4 2 3 1 3 2 1 1 NULL NULL +4 2 1 2 4 2 3 1 6 2 1 1 NULL NULL +4 2 1 2 4 2 3 3 NULL NULL NULL NULL NULL NULL +5 3 NULL NULL NULL NULL 2 2 3 2 2 2 0 2 +5 3 NULL NULL NULL NULL 2 2 3 2 2 2 1 2 +5 3 NULL NULL NULL NULL 2 2 6 2 2 2 0 2 +5 3 NULL NULL NULL NULL 2 2 6 2 2 2 1 2 +5 3 NULL NULL NULL NULL 3 1 3 2 1 1 NULL NULL +5 3 NULL NULL NULL NULL 3 1 6 2 1 1 NULL NULL +5 3 NULL NULL NULL NULL 3 3 NULL NULL NULL NULL NULL NULL +SELECT t2.a,t2.b,t3.a,t3.b,t4.a,t4.b, +t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b +FROM t2 +LEFT JOIN +(t3, t4) +ON t3.a=1 AND t2.b=t4.b, +t5 +LEFT JOIN +( +(t6, t7) +LEFT JOIN +t8 +ON t7.b=t8.b AND t6.b < 10 +) +ON t6.b >= 2 AND t5.b=t7.b +WHERE t2.a > 3 AND +(t6.a < 6 OR t6.c IS NULL); +a b a b a b a b a b a b a b +4 2 1 2 3 2 2 2 3 2 2 2 0 2 +4 2 1 2 3 2 2 2 3 2 2 2 1 2 +4 2 1 2 3 2 3 1 3 2 1 1 NULL NULL +4 2 1 2 3 2 3 3 NULL NULL NULL NULL NULL NULL +4 2 1 2 4 2 2 2 3 2 2 2 0 2 +4 2 1 2 4 2 2 2 3 2 2 2 1 2 +4 2 1 2 4 2 3 1 3 2 1 1 NULL NULL +4 2 1 2 4 2 3 3 NULL NULL NULL NULL NULL NULL +5 3 NULL NULL NULL NULL 2 2 3 2 2 2 0 2 +5 3 NULL NULL NULL NULL 2 2 3 2 2 2 1 2 +5 3 NULL NULL NULL NULL 3 1 3 2 1 1 NULL NULL +5 3 NULL NULL NULL NULL 3 3 NULL NULL NULL NULL NULL NULL +"Standard compliant copy of above query" +SELECT t2.a,t2.b,t34.a3,t34.b3,t34.a4,t34.b4, +t5.a,t5.b,t67.a6,t67.b6,t67.a7,t67.b7,t8.a,t8.b +FROM t2 +LEFT JOIN t34 +ON t34.a3=1 AND t2.b=t34.b4 +CROSS JOIN t5 +LEFT JOIN +( +t67 +LEFT JOIN +t8 +ON t67.b7=t8.b AND t67.b6 < 10 +) +ON t67.b6 >= 2 AND t5.b=t67.b7 +WHERE t2.a > 3 AND +(t67.a6 < 6 OR t67.c6 IS NULL); +a b a3 b3 a4 b4 a b a6 b6 a7 b7 a b +4 2 1 2 3 2 2 2 3 2 2 2 0 2 +4 2 1 2 3 2 2 2 3 2 2 2 1 2 +4 2 1 2 3 2 3 1 3 2 1 1 NULL NULL +4 2 1 2 3 2 3 3 NULL NULL NULL NULL NULL NULL +4 2 1 2 4 2 2 2 3 2 2 2 0 2 +4 2 1 2 4 2 2 2 3 2 2 2 1 2 +4 2 1 2 4 2 3 1 3 2 1 1 NULL NULL +4 2 1 2 4 2 3 3 NULL NULL NULL NULL NULL NULL +5 3 NULL NULL NULL NULL 2 2 3 2 2 2 0 2 +5 3 NULL NULL NULL NULL 2 2 3 2 2 2 1 2 +5 3 NULL NULL NULL NULL 3 1 3 2 1 1 NULL NULL +5 3 NULL NULL NULL NULL 3 3 NULL NULL NULL NULL NULL NULL +SELECT t1.a,t1.b +FROM t1; +a b +1 3 +2 2 +3 2 +SELECT t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b, +t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b +FROM t1 +LEFT JOIN +( +t2 +LEFT JOIN +(t3, t4) +ON t3.a=1 AND t2.b=t4.b, +t5 +LEFT JOIN +( +(t6, t7) +LEFT JOIN +t8 +ON t7.b=t8.b AND t6.b < 10 +) +ON t6.b >= 2 AND t5.b=t7.b +) +ON (t3.b=2 OR t3.c IS NULL) AND (t6.b=2 OR t6.c IS NULL) AND +(t1.b=t5.b OR t3.c IS NULL OR t6.c IS NULL or t8.c IS NULL) AND +(t1.a != 2); +a b a b a b a b a b a b a b a b +1 3 3 3 NULL NULL NULL NULL 2 2 3 2 2 2 0 2 +1 3 3 3 NULL NULL NULL NULL 2 2 3 2 2 2 1 2 +1 3 3 3 NULL NULL NULL NULL 2 2 6 2 2 2 0 2 +1 3 3 3 NULL NULL NULL NULL 2 2 6 2 2 2 1 2 +1 3 3 3 NULL NULL NULL NULL 3 1 3 2 1 1 NULL NULL +1 3 3 3 NULL NULL NULL NULL 3 1 6 2 1 1 NULL NULL +1 3 3 3 NULL NULL NULL NULL 3 3 NULL NULL NULL NULL NULL NULL +1 3 4 2 1 2 3 2 3 1 3 2 1 1 NULL NULL +1 3 4 2 1 2 3 2 3 1 6 2 1 1 NULL NULL +1 3 4 2 1 2 3 2 3 3 NULL NULL NULL NULL NULL NULL +1 3 4 2 1 2 4 2 3 1 3 2 1 1 NULL NULL +1 3 4 2 1 2 4 2 3 1 6 2 1 1 NULL NULL +1 3 4 2 1 2 4 2 3 3 NULL NULL NULL NULL NULL NULL +1 3 5 3 NULL NULL NULL NULL 2 2 3 2 2 2 0 2 +1 3 5 3 NULL NULL NULL NULL 2 2 3 2 2 2 1 2 +1 3 5 3 NULL NULL NULL NULL 2 2 6 2 2 2 0 2 +1 3 5 3 NULL NULL NULL NULL 2 2 6 2 2 2 1 2 +1 3 5 3 NULL NULL NULL NULL 3 1 3 2 1 1 NULL NULL +1 3 5 3 NULL NULL NULL NULL 3 1 6 2 1 1 NULL NULL +1 3 5 3 NULL NULL NULL NULL 3 3 NULL NULL NULL NULL NULL NULL +2 2 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL +3 2 3 3 NULL NULL NULL NULL 2 2 3 2 2 2 0 2 +3 2 3 3 NULL NULL NULL NULL 2 2 3 2 2 2 1 2 +3 2 3 3 NULL NULL NULL NULL 2 2 6 2 2 2 0 2 +3 2 3 3 NULL NULL NULL NULL 2 2 6 2 2 2 1 2 +3 2 3 3 NULL NULL NULL NULL 3 1 3 2 1 1 NULL NULL +3 2 3 3 NULL NULL NULL NULL 3 1 6 2 1 1 NULL NULL +3 2 3 3 NULL NULL NULL NULL 3 3 NULL NULL NULL NULL NULL NULL +3 2 4 2 1 2 3 2 2 2 3 2 2 2 0 2 +3 2 4 2 1 2 3 2 2 2 3 2 2 2 1 2 +3 2 4 2 1 2 3 2 2 2 6 2 2 2 0 2 +3 2 4 2 1 2 3 2 2 2 6 2 2 2 1 2 +3 2 4 2 1 2 3 2 3 1 3 2 1 1 NULL NULL +3 2 4 2 1 2 3 2 3 1 6 2 1 1 NULL NULL +3 2 4 2 1 2 3 2 3 3 NULL NULL NULL NULL NULL NULL +3 2 4 2 1 2 4 2 2 2 3 2 2 2 0 2 +3 2 4 2 1 2 4 2 2 2 3 2 2 2 1 2 +3 2 4 2 1 2 4 2 2 2 6 2 2 2 0 2 +3 2 4 2 1 2 4 2 2 2 6 2 2 2 1 2 +3 2 4 2 1 2 4 2 3 1 3 2 1 1 NULL NULL +3 2 4 2 1 2 4 2 3 1 6 2 1 1 NULL NULL +3 2 4 2 1 2 4 2 3 3 NULL NULL NULL NULL NULL NULL +3 2 5 3 NULL NULL NULL NULL 2 2 3 2 2 2 0 2 +3 2 5 3 NULL NULL NULL NULL 2 2 3 2 2 2 1 2 +3 2 5 3 NULL NULL NULL NULL 2 2 6 2 2 2 0 2 +3 2 5 3 NULL NULL NULL NULL 2 2 6 2 2 2 1 2 +3 2 5 3 NULL NULL NULL NULL 3 1 3 2 1 1 NULL NULL +3 2 5 3 NULL NULL NULL NULL 3 1 6 2 1 1 NULL NULL +3 2 5 3 NULL NULL NULL NULL 3 3 NULL NULL NULL NULL NULL NULL +"Standard compliant copy of above query" +SELECT t1.a,t1.b,t2.a,t2.b,t34.a3,t34.b3,t34.a4,t34.b4, +t5.a,t5.b,t67.a6,t67.b6,t67.a7,t67.b7,t8.a,t8.b +FROM t1 +LEFT JOIN +( +t2 +LEFT JOIN t34 +ON t34.a3=1 AND t2.b=t34.b4 +CROSS JOIN t5 +LEFT JOIN +( +t67 +LEFT JOIN +t8 +ON t67.b7=t8.b AND t67.b6 < 10 +) +ON t67.b6 >= 2 AND t5.b=t67.b7 +) +ON (t34.b3=2 OR t34.c3 IS NULL) AND (t67.b6=2 OR t67.c6 IS NULL) AND +(t1.b=t5.b OR t34.c3 IS NULL OR t67.c6 IS NULL or t8.c IS NULL) AND +(t1.a <> 2); +a b a b a3 b3 a4 b4 a b a6 b6 a7 b7 a b +1 3 3 3 NULL NULL NULL NULL 2 2 3 2 2 2 0 2 +1 3 3 3 NULL NULL NULL NULL 2 2 3 2 2 2 1 2 +1 3 3 3 NULL NULL NULL NULL 2 2 6 2 2 2 0 2 +1 3 3 3 NULL NULL NULL NULL 2 2 6 2 2 2 1 2 +1 3 3 3 NULL NULL NULL NULL 3 1 3 2 1 1 NULL NULL +1 3 3 3 NULL NULL NULL NULL 3 1 6 2 1 1 NULL NULL +1 3 3 3 NULL NULL NULL NULL 3 3 NULL NULL NULL NULL NULL NULL +1 3 4 2 1 2 3 2 3 1 3 2 1 1 NULL NULL +1 3 4 2 1 2 3 2 3 1 6 2 1 1 NULL NULL +1 3 4 2 1 2 3 2 3 3 NULL NULL NULL NULL NULL NULL +1 3 4 2 1 2 4 2 3 1 3 2 1 1 NULL NULL +1 3 4 2 1 2 4 2 3 1 6 2 1 1 NULL NULL +1 3 4 2 1 2 4 2 3 3 NULL NULL NULL NULL NULL NULL +1 3 5 3 NULL NULL NULL NULL 2 2 3 2 2 2 0 2 +1 3 5 3 NULL NULL NULL NULL 2 2 3 2 2 2 1 2 +1 3 5 3 NULL NULL NULL NULL 2 2 6 2 2 2 0 2 +1 3 5 3 NULL NULL NULL NULL 2 2 6 2 2 2 1 2 +1 3 5 3 NULL NULL NULL NULL 3 1 3 2 1 1 NULL NULL +1 3 5 3 NULL NULL NULL NULL 3 1 6 2 1 1 NULL NULL +1 3 5 3 NULL NULL NULL NULL 3 3 NULL NULL NULL NULL NULL NULL +2 2 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL +3 2 3 3 NULL NULL NULL NULL 2 2 3 2 2 2 0 2 +3 2 3 3 NULL NULL NULL NULL 2 2 3 2 2 2 1 2 +3 2 3 3 NULL NULL NULL NULL 2 2 6 2 2 2 0 2 +3 2 3 3 NULL NULL NULL NULL 2 2 6 2 2 2 1 2 +3 2 3 3 NULL NULL NULL NULL 3 1 3 2 1 1 NULL NULL +3 2 3 3 NULL NULL NULL NULL 3 1 6 2 1 1 NULL NULL +3 2 3 3 NULL NULL NULL NULL 3 3 NULL NULL NULL NULL NULL NULL +3 2 4 2 1 2 3 2 2 2 3 2 2 2 0 2 +3 2 4 2 1 2 3 2 2 2 3 2 2 2 1 2 +3 2 4 2 1 2 3 2 2 2 6 2 2 2 0 2 +3 2 4 2 1 2 3 2 2 2 6 2 2 2 1 2 +3 2 4 2 1 2 3 2 3 1 3 2 1 1 NULL NULL +3 2 4 2 1 2 3 2 3 1 6 2 1 1 NULL NULL +3 2 4 2 1 2 3 2 3 3 NULL NULL NULL NULL NULL NULL +3 2 4 2 1 2 4 2 2 2 3 2 2 2 0 2 +3 2 4 2 1 2 4 2 2 2 3 2 2 2 1 2 +3 2 4 2 1 2 4 2 2 2 6 2 2 2 0 2 +3 2 4 2 1 2 4 2 2 2 6 2 2 2 1 2 +3 2 4 2 1 2 4 2 3 1 3 2 1 1 NULL NULL +3 2 4 2 1 2 4 2 3 1 6 2 1 1 NULL NULL +3 2 4 2 1 2 4 2 3 3 NULL NULL NULL NULL NULL NULL +3 2 5 3 NULL NULL NULL NULL 2 2 3 2 2 2 0 2 +3 2 5 3 NULL NULL NULL NULL 2 2 3 2 2 2 1 2 +3 2 5 3 NULL NULL NULL NULL 2 2 6 2 2 2 0 2 +3 2 5 3 NULL NULL NULL NULL 2 2 6 2 2 2 1 2 +3 2 5 3 NULL NULL NULL NULL 3 1 3 2 1 1 NULL NULL +3 2 5 3 NULL NULL NULL NULL 3 1 6 2 1 1 NULL NULL +3 2 5 3 NULL NULL NULL NULL 3 3 NULL NULL NULL NULL NULL NULL +SELECT t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b, +t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b +FROM t1 +LEFT JOIN +( +t2 +LEFT JOIN +(t3, t4) +ON t3.a=1 AND t2.b=t4.b, +t5 +LEFT JOIN +( +(t6, t7) +LEFT JOIN +t8 +ON t7.b=t8.b AND t6.b < 10 +) +ON t6.b >= 2 AND t5.b=t7.b +) +ON (t3.b=2 OR t3.c IS NULL) AND (t6.b=2 OR t6.c IS NULL) AND +(t1.b=t5.b OR t3.c IS NULL OR t6.c IS NULL or t8.c IS NULL) AND +(t1.a != 2) +WHERE (t2.a >= 4 OR t2.c IS NULL); +a b a b a b a b a b a b a b a b +1 3 4 2 1 2 3 2 3 1 3 2 1 1 NULL NULL +1 3 4 2 1 2 3 2 3 1 6 2 1 1 NULL NULL +1 3 4 2 1 2 3 2 3 3 NULL NULL NULL NULL NULL NULL +1 3 4 2 1 2 4 2 3 1 3 2 1 1 NULL NULL +1 3 4 2 1 2 4 2 3 1 6 2 1 1 NULL NULL +1 3 4 2 1 2 4 2 3 3 NULL NULL NULL NULL NULL NULL +1 3 5 3 NULL NULL NULL NULL 2 2 3 2 2 2 0 2 +1 3 5 3 NULL NULL NULL NULL 2 2 3 2 2 2 1 2 +1 3 5 3 NULL NULL NULL NULL 2 2 6 2 2 2 0 2 +1 3 5 3 NULL NULL NULL NULL 2 2 6 2 2 2 1 2 +1 3 5 3 NULL NULL NULL NULL 3 1 3 2 1 1 NULL NULL +1 3 5 3 NULL NULL NULL NULL 3 1 6 2 1 1 NULL NULL +1 3 5 3 NULL NULL NULL NULL 3 3 NULL NULL NULL NULL NULL NULL +2 2 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL +3 2 4 2 1 2 3 2 2 2 3 2 2 2 0 2 +3 2 4 2 1 2 3 2 2 2 3 2 2 2 1 2 +3 2 4 2 1 2 3 2 2 2 6 2 2 2 0 2 +3 2 4 2 1 2 3 2 2 2 6 2 2 2 1 2 +3 2 4 2 1 2 3 2 3 1 3 2 1 1 NULL NULL +3 2 4 2 1 2 3 2 3 1 6 2 1 1 NULL NULL +3 2 4 2 1 2 3 2 3 3 NULL NULL NULL NULL NULL NULL +3 2 4 2 1 2 4 2 2 2 3 2 2 2 0 2 +3 2 4 2 1 2 4 2 2 2 3 2 2 2 1 2 +3 2 4 2 1 2 4 2 2 2 6 2 2 2 0 2 +3 2 4 2 1 2 4 2 2 2 6 2 2 2 1 2 +3 2 4 2 1 2 4 2 3 1 3 2 1 1 NULL NULL +3 2 4 2 1 2 4 2 3 1 6 2 1 1 NULL NULL +3 2 4 2 1 2 4 2 3 3 NULL NULL NULL NULL NULL NULL +3 2 5 3 NULL NULL NULL NULL 2 2 3 2 2 2 0 2 +3 2 5 3 NULL NULL NULL NULL 2 2 3 2 2 2 1 2 +3 2 5 3 NULL NULL NULL NULL 2 2 6 2 2 2 0 2 +3 2 5 3 NULL NULL NULL NULL 2 2 6 2 2 2 1 2 +3 2 5 3 NULL NULL NULL NULL 3 1 3 2 1 1 NULL NULL +3 2 5 3 NULL NULL NULL NULL 3 1 6 2 1 1 NULL NULL +3 2 5 3 NULL NULL NULL NULL 3 3 NULL NULL NULL NULL NULL NULL +"Standard compliant copy of above query" +SELECT t1.a,t1.b,t2.a,t2.b,t34.a3,t34.b3,t34.a4,t34.b4, +t5.a,t5.b,t67.a6,t67.b6,t67.a7,t67.b7,t8.a,t8.b +FROM t1 +LEFT JOIN +( +t2 +LEFT JOIN t34 +ON t34.a3=1 AND t2.b=t34.b4 +CROSS JOIN t5 +LEFT JOIN +( +t67 +LEFT JOIN +t8 +ON t67.b7=t8.b AND t67.b6 < 10 +) +ON t67.b6 >= 2 AND t5.b=t67.b7 +) +ON (t34.b3=2 OR t34.c3 IS NULL) AND (t67.b6=2 OR t67.c6 IS NULL) AND +(t1.b=t5.b OR t34.c3 IS NULL OR t67.c6 IS NULL or t8.c IS NULL) AND +(t1.a <> 2) +WHERE (t2.a >= 4 OR t2.c IS NULL); +a b a b a3 b3 a4 b4 a b a6 b6 a7 b7 a b +1 3 4 2 1 2 3 2 3 1 3 2 1 1 NULL NULL +1 3 4 2 1 2 3 2 3 1 6 2 1 1 NULL NULL +1 3 4 2 1 2 3 2 3 3 NULL NULL NULL NULL NULL NULL +1 3 4 2 1 2 4 2 3 1 3 2 1 1 NULL NULL +1 3 4 2 1 2 4 2 3 1 6 2 1 1 NULL NULL +1 3 4 2 1 2 4 2 3 3 NULL NULL NULL NULL NULL NULL +1 3 5 3 NULL NULL NULL NULL 2 2 3 2 2 2 0 2 +1 3 5 3 NULL NULL NULL NULL 2 2 3 2 2 2 1 2 +1 3 5 3 NULL NULL NULL NULL 2 2 6 2 2 2 0 2 +1 3 5 3 NULL NULL NULL NULL 2 2 6 2 2 2 1 2 +1 3 5 3 NULL NULL NULL NULL 3 1 3 2 1 1 NULL NULL +1 3 5 3 NULL NULL NULL NULL 3 1 6 2 1 1 NULL NULL +1 3 5 3 NULL NULL NULL NULL 3 3 NULL NULL NULL NULL NULL NULL +2 2 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL +3 2 4 2 1 2 3 2 2 2 3 2 2 2 0 2 +3 2 4 2 1 2 3 2 2 2 3 2 2 2 1 2 +3 2 4 2 1 2 3 2 2 2 6 2 2 2 0 2 +3 2 4 2 1 2 3 2 2 2 6 2 2 2 1 2 +3 2 4 2 1 2 3 2 3 1 3 2 1 1 NULL NULL +3 2 4 2 1 2 3 2 3 1 6 2 1 1 NULL NULL +3 2 4 2 1 2 3 2 3 3 NULL NULL NULL NULL NULL NULL +3 2 4 2 1 2 4 2 2 2 3 2 2 2 0 2 +3 2 4 2 1 2 4 2 2 2 3 2 2 2 1 2 +3 2 4 2 1 2 4 2 2 2 6 2 2 2 0 2 +3 2 4 2 1 2 4 2 2 2 6 2 2 2 1 2 +3 2 4 2 1 2 4 2 3 1 3 2 1 1 NULL NULL +3 2 4 2 1 2 4 2 3 1 6 2 1 1 NULL NULL +3 2 4 2 1 2 4 2 3 3 NULL NULL NULL NULL NULL NULL +3 2 5 3 NULL NULL NULL NULL 2 2 3 2 2 2 0 2 +3 2 5 3 NULL NULL NULL NULL 2 2 3 2 2 2 1 2 +3 2 5 3 NULL NULL NULL NULL 2 2 6 2 2 2 0 2 +3 2 5 3 NULL NULL NULL NULL 2 2 6 2 2 2 1 2 +3 2 5 3 NULL NULL NULL NULL 3 1 3 2 1 1 NULL NULL +3 2 5 3 NULL NULL NULL NULL 3 1 6 2 1 1 NULL NULL +3 2 5 3 NULL NULL NULL NULL 3 3 NULL NULL NULL NULL NULL NULL +SELECT t0.a,t0.b +FROM t0; +a b +1 1 +1 2 +2 2 +ANALYZE TABLE t0, t1, t2, t3, t4, t5, t6, t7, t8; +Table Op Msg_type Msg_text +test.t0 analyze status OK +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +test.t4 analyze status OK +test.t5 analyze status OK +test.t6 analyze status OK +test.t7 analyze status OK +test.t8 analyze status OK +EXPLAIN +SELECT t0.a,t0.b,t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b, +t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b +FROM t0,t1 +LEFT JOIN +( +t2 +LEFT JOIN +(t3, t4) +ON t3.a=1 AND t2.b=t4.b, +t5 +LEFT JOIN +( +(t6, t7) +LEFT JOIN +t8 +ON t7.b=t8.b AND t6.b < 10 +) +ON t6.b >= 2 AND t5.b=t7.b +) +ON (t3.b=2 OR t3.c IS NULL) AND (t6.b=2 OR t6.c IS NULL) AND +(t1.b=t5.b OR t3.c IS NULL OR t6.c IS NULL or t8.c IS NULL) AND +(t1.a != 2) +WHERE t0.a=1 AND +t0.b=t1.b AND +(t2.a >= 4 OR t2.c IS NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE t0 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 55.56 Using where; Using join buffer (hash join) +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t5 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 SIMPLE t7 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t6 NULL ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t8 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a`,`test`.`t0`.`b` AS `b`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t5`.`a` AS `a`,`test`.`t5`.`b` AS `b`,`test`.`t6`.`a` AS `a`,`test`.`t6`.`b` AS `b`,`test`.`t7`.`a` AS `a`,`test`.`t7`.`b` AS `b`,`test`.`t8`.`a` AS `a`,`test`.`t8`.`b` AS `b` from `test`.`t0` join `test`.`t1` left join (`test`.`t2` left join (`test`.`t3` join `test`.`t4`) on(((`test`.`t4`.`b` = `test`.`t2`.`b`) and (`test`.`t3`.`a` = 1))) join `test`.`t5` left join (`test`.`t6` join `test`.`t7` left join `test`.`t8` on(((`test`.`t8`.`b` = `test`.`t7`.`b`) and (`test`.`t6`.`b` < 10)))) on(((`test`.`t7`.`b` = `test`.`t5`.`b`) and (`test`.`t6`.`b` >= 2)))) on((((`test`.`t3`.`b` = 2) or (`test`.`t3`.`c` is null)) and ((`test`.`t6`.`b` = 2) or (`test`.`t6`.`c` is null)) and ((`test`.`t5`.`b` = `test`.`t0`.`b`) or (`test`.`t3`.`c` is null) or (`test`.`t6`.`c` is null) or (`test`.`t8`.`c` is null)) and (`test`.`t1`.`a` <> 2))) where ((`test`.`t1`.`b` = `test`.`t0`.`b`) and (`test`.`t0`.`a` = 1) and ((`test`.`t2`.`a` >= 4) or (`test`.`t2`.`c` is null))) +SELECT t0.a,t0.b,t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b, +t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b +FROM t0,t1 +LEFT JOIN +( +t2 +LEFT JOIN +(t3, t4) +ON t3.a=1 AND t2.b=t4.b, +t5 +LEFT JOIN +( +(t6, t7) +LEFT JOIN +t8 +ON t7.b=t8.b AND t6.b < 10 +) +ON t6.b >= 2 AND t5.b=t7.b +) +ON (t3.b=2 OR t3.c IS NULL) AND (t6.b=2 OR t6.c IS NULL) AND +(t1.b=t5.b OR t3.c IS NULL OR t6.c IS NULL or t8.c IS NULL) AND +(t1.a != 2) +WHERE t0.a=1 AND +t0.b=t1.b AND +(t2.a >= 4 OR t2.c IS NULL); +a b a b a b a b a b a b a b a b a b +1 2 2 2 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL +1 2 3 2 4 2 1 2 3 2 2 2 3 2 2 2 0 2 +1 2 3 2 4 2 1 2 3 2 2 2 3 2 2 2 1 2 +1 2 3 2 4 2 1 2 3 2 2 2 6 2 2 2 0 2 +1 2 3 2 4 2 1 2 3 2 2 2 6 2 2 2 1 2 +1 2 3 2 4 2 1 2 3 2 3 1 3 2 1 1 NULL NULL +1 2 3 2 4 2 1 2 3 2 3 1 6 2 1 1 NULL NULL +1 2 3 2 4 2 1 2 3 2 3 3 NULL NULL NULL NULL NULL NULL +1 2 3 2 4 2 1 2 4 2 2 2 3 2 2 2 0 2 +1 2 3 2 4 2 1 2 4 2 2 2 3 2 2 2 1 2 +1 2 3 2 4 2 1 2 4 2 2 2 6 2 2 2 0 2 +1 2 3 2 4 2 1 2 4 2 2 2 6 2 2 2 1 2 +1 2 3 2 4 2 1 2 4 2 3 1 3 2 1 1 NULL NULL +1 2 3 2 4 2 1 2 4 2 3 1 6 2 1 1 NULL NULL +1 2 3 2 4 2 1 2 4 2 3 3 NULL NULL NULL NULL NULL NULL +1 2 3 2 5 3 NULL NULL NULL NULL 2 2 3 2 2 2 0 2 +1 2 3 2 5 3 NULL NULL NULL NULL 2 2 3 2 2 2 1 2 +1 2 3 2 5 3 NULL NULL NULL NULL 2 2 6 2 2 2 0 2 +1 2 3 2 5 3 NULL NULL NULL NULL 2 2 6 2 2 2 1 2 +1 2 3 2 5 3 NULL NULL NULL NULL 3 1 3 2 1 1 NULL NULL +1 2 3 2 5 3 NULL NULL NULL NULL 3 1 6 2 1 1 NULL NULL +1 2 3 2 5 3 NULL NULL NULL NULL 3 3 NULL NULL NULL NULL NULL NULL +"Standard compliant copy of above query" +SELECT t0.a,t0.b,t1.a,t1.b,t2.a,t2.b,t34.a3,t34.b3,t34.a4,t34.b4, +t5.a,t5.b,t67.a6,t67.b6,t67.a7,t67.b7,t8.a,t8.b +FROM t0 +CROSS JOIN t1 +LEFT JOIN +( +t2 +LEFT JOIN t34 +ON t34.a3=1 AND t2.b=t34.b4 +CROSS JOIN t5 +LEFT JOIN +( +t67 +LEFT JOIN +t8 +ON t67.b7=t8.b AND t67.b6 < 10 +) +ON t67.b6 >= 2 AND t5.b=t67.b7 +) +ON (t34.b3=2 OR t34.c3 IS NULL) AND (t67.b6=2 OR t67.c6 IS NULL) AND +(t1.b=t5.b OR t34.c3 IS NULL OR t67.c6 IS NULL or t8.c IS NULL) AND +(t1.a <> 2) +WHERE t0.a=1 AND +t0.b=t1.b AND +(t2.a >= 4 OR t2.c IS NULL); +a b a b a b a3 b3 a4 b4 a b a6 b6 a7 b7 a b +1 2 2 2 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL +1 2 3 2 4 2 1 2 3 2 2 2 3 2 2 2 0 2 +1 2 3 2 4 2 1 2 3 2 2 2 3 2 2 2 1 2 +1 2 3 2 4 2 1 2 3 2 2 2 6 2 2 2 0 2 +1 2 3 2 4 2 1 2 3 2 2 2 6 2 2 2 1 2 +1 2 3 2 4 2 1 2 3 2 3 1 3 2 1 1 NULL NULL +1 2 3 2 4 2 1 2 3 2 3 1 6 2 1 1 NULL NULL +1 2 3 2 4 2 1 2 3 2 3 3 NULL NULL NULL NULL NULL NULL +1 2 3 2 4 2 1 2 4 2 2 2 3 2 2 2 0 2 +1 2 3 2 4 2 1 2 4 2 2 2 3 2 2 2 1 2 +1 2 3 2 4 2 1 2 4 2 2 2 6 2 2 2 0 2 +1 2 3 2 4 2 1 2 4 2 2 2 6 2 2 2 1 2 +1 2 3 2 4 2 1 2 4 2 3 1 3 2 1 1 NULL NULL +1 2 3 2 4 2 1 2 4 2 3 1 6 2 1 1 NULL NULL +1 2 3 2 4 2 1 2 4 2 3 3 NULL NULL NULL NULL NULL NULL +1 2 3 2 5 3 NULL NULL NULL NULL 2 2 3 2 2 2 0 2 +1 2 3 2 5 3 NULL NULL NULL NULL 2 2 3 2 2 2 1 2 +1 2 3 2 5 3 NULL NULL NULL NULL 2 2 6 2 2 2 0 2 +1 2 3 2 5 3 NULL NULL NULL NULL 2 2 6 2 2 2 1 2 +1 2 3 2 5 3 NULL NULL NULL NULL 3 1 3 2 1 1 NULL NULL +1 2 3 2 5 3 NULL NULL NULL NULL 3 1 6 2 1 1 NULL NULL +1 2 3 2 5 3 NULL NULL NULL NULL 3 3 NULL NULL NULL NULL NULL NULL +ANALYZE TABLE t0, t1, t2, t3, t4, t5, t6, t7, t8, t9; +Table Op Msg_type Msg_text +test.t0 analyze status OK +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +test.t4 analyze status OK +test.t5 analyze status OK +test.t6 analyze status OK +test.t7 analyze status OK +test.t8 analyze status OK +test.t9 analyze status OK +EXPLAIN +SELECT t0.a,t0.b,t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b, +t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b,t9.a,t9.b +FROM t0,t1 +LEFT JOIN +( +t2 +LEFT JOIN +(t3, t4) +ON t3.a=1 AND t2.b=t4.b, +t5 +LEFT JOIN +( +(t6, t7) +LEFT JOIN +t8 +ON t7.b=t8.b AND t6.b < 10 +) +ON t6.b >= 2 AND t5.b=t7.b +) +ON (t3.b=2 OR t3.c IS NULL) AND (t6.b=2 OR t6.c IS NULL) AND +(t1.b=t5.b OR t3.c IS NULL OR t6.c IS NULL or t8.c IS NULL) AND +(t1.a != 2), +t9 +WHERE t0.a=1 AND +t0.b=t1.b AND +(t2.a >= 4 OR t2.c IS NULL) AND +(t3.a < 5 OR t3.c IS NULL) AND +(t3.b=t4.b OR t3.c IS NULL OR t4.c IS NULL) AND +(t5.a >=2 OR t5.c IS NULL) AND +(t6.a >=4 OR t6.c IS NULL) AND +(t7.a <= 2 OR t7.c IS NULL) AND +(t8.a < 1 OR t8.c IS NULL) AND +(t8.b=t9.b OR t8.c IS NULL) AND +(t9.a=1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE t0 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +2 SIMPLE t9 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 55.56 Using where; Using join buffer (hash join) +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 75.00 Using where; Using join buffer (hash join) +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t5 NULL ALL NULL NULL NULL NULL 3 55.56 Using where; Using join buffer (hash join) +2 SIMPLE t7 NULL ALL NULL NULL NULL NULL 2 75.00 Using where; Using join buffer (hash join) +2 SIMPLE t6 NULL ALL NULL NULL NULL NULL 3 55.56 Using where; Using join buffer (hash join) +2 SIMPLE t8 NULL ALL NULL NULL NULL NULL 2 56.25 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a`,`test`.`t0`.`b` AS `b`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t5`.`a` AS `a`,`test`.`t5`.`b` AS `b`,`test`.`t6`.`a` AS `a`,`test`.`t6`.`b` AS `b`,`test`.`t7`.`a` AS `a`,`test`.`t7`.`b` AS `b`,`test`.`t8`.`a` AS `a`,`test`.`t8`.`b` AS `b`,`test`.`t9`.`a` AS `a`,`test`.`t9`.`b` AS `b` from `test`.`t0` join `test`.`t1` left join (`test`.`t2` left join (`test`.`t3` join `test`.`t4`) on(((`test`.`t4`.`b` = `test`.`t2`.`b`) and (`test`.`t3`.`a` = 1))) join `test`.`t5` left join (`test`.`t6` join `test`.`t7` left join `test`.`t8` on(((`test`.`t8`.`b` = `test`.`t7`.`b`) and (`test`.`t6`.`b` < 10)))) on(((`test`.`t7`.`b` = `test`.`t5`.`b`) and (`test`.`t6`.`b` >= 2)))) on((((`test`.`t3`.`b` = 2) or (`test`.`t3`.`c` is null)) and ((`test`.`t6`.`b` = 2) or (`test`.`t6`.`c` is null)) and ((`test`.`t5`.`b` = `test`.`t0`.`b`) or (`test`.`t3`.`c` is null) or (`test`.`t6`.`c` is null) or (`test`.`t8`.`c` is null)) and (`test`.`t1`.`a` <> 2))) join `test`.`t9` where ((`test`.`t9`.`a` = 1) and (`test`.`t1`.`b` = `test`.`t0`.`b`) and (`test`.`t0`.`a` = 1) and ((`test`.`t2`.`a` >= 4) or (`test`.`t2`.`c` is null)) and ((`test`.`t3`.`a` < 5) or (`test`.`t3`.`c` is null)) and ((`test`.`t4`.`b` = `test`.`t3`.`b`) or (`test`.`t3`.`c` is null) or (`test`.`t4`.`c` is null)) and ((`test`.`t5`.`a` >= 2) or (`test`.`t5`.`c` is null)) and ((`test`.`t6`.`a` >= 4) or (`test`.`t6`.`c` is null)) and ((`test`.`t7`.`a` <= 2) or (`test`.`t7`.`c` is null)) and ((`test`.`t8`.`a` < 1) or (`test`.`t8`.`c` is null)) and ((`test`.`t8`.`b` = `test`.`t9`.`b`) or (`test`.`t8`.`c` is null))) +SELECT t9.a,t9.b +FROM t9; +a b +1 1 +1 2 +3 3 +SELECT t0.a,t0.b,t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b, +t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b,t9.a,t9.b +FROM t0,t1 +LEFT JOIN +( +t2 +LEFT JOIN +(t3, t4) +ON t3.a=1 AND t2.b=t4.b, +t5 +LEFT JOIN +( +(t6, t7) +LEFT JOIN +t8 +ON t7.b=t8.b AND t6.b < 10 +) +ON t6.b >= 2 AND t5.b=t7.b +) +ON (t3.b=2 OR t3.c IS NULL) AND (t6.b=2 OR t6.c IS NULL) AND +(t1.b=t5.b OR t3.c IS NULL OR t6.c IS NULL or t8.c IS NULL) AND +(t1.a != 2), +t9 +WHERE t0.a=1 AND +t0.b=t1.b AND +(t2.a >= 4 OR t2.c IS NULL) AND +(t3.a < 5 OR t3.c IS NULL) AND +(t3.b=t4.b OR t3.c IS NULL OR t4.c IS NULL) AND +(t5.a >=2 OR t5.c IS NULL) AND +(t6.a >=4 OR t6.c IS NULL) AND +(t7.a <= 2 OR t7.c IS NULL) AND +(t8.a < 1 OR t8.c IS NULL) AND +(t8.b=t9.b OR t8.c IS NULL) AND +(t9.a=1); +a b a b a b a b a b a b a b a b a b a b +1 2 2 2 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL 1 1 +1 2 2 2 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL 1 2 +1 2 3 2 4 2 1 2 3 2 2 2 6 2 2 2 0 2 1 2 +1 2 3 2 4 2 1 2 3 2 3 1 6 2 1 1 NULL NULL 1 1 +1 2 3 2 4 2 1 2 3 2 3 1 6 2 1 1 NULL NULL 1 2 +1 2 3 2 4 2 1 2 3 2 3 3 NULL NULL NULL NULL NULL NULL 1 1 +1 2 3 2 4 2 1 2 3 2 3 3 NULL NULL NULL NULL NULL NULL 1 2 +1 2 3 2 4 2 1 2 4 2 2 2 6 2 2 2 0 2 1 2 +1 2 3 2 4 2 1 2 4 2 3 1 6 2 1 1 NULL NULL 1 1 +1 2 3 2 4 2 1 2 4 2 3 1 6 2 1 1 NULL NULL 1 2 +1 2 3 2 4 2 1 2 4 2 3 3 NULL NULL NULL NULL NULL NULL 1 1 +1 2 3 2 4 2 1 2 4 2 3 3 NULL NULL NULL NULL NULL NULL 1 2 +1 2 3 2 5 3 NULL NULL NULL NULL 2 2 6 2 2 2 0 2 1 2 +1 2 3 2 5 3 NULL NULL NULL NULL 3 1 6 2 1 1 NULL NULL 1 1 +1 2 3 2 5 3 NULL NULL NULL NULL 3 1 6 2 1 1 NULL NULL 1 2 +1 2 3 2 5 3 NULL NULL NULL NULL 3 3 NULL NULL NULL NULL NULL NULL 1 1 +1 2 3 2 5 3 NULL NULL NULL NULL 3 3 NULL NULL NULL NULL NULL NULL 1 2 +"Standard compliant copy of above query" +SELECT t0.a,t0.b,t1.a,t1.b,t2.a,t2.b,t34.a3,t34.b3,t34.a4,t34.b4, +t5.a,t5.b,t67.a6,t67.b6,t67.a7,t67.b7,t8.a,t8.b,t9.a,t9.b +FROM t0 +CROSS JOIN t1 +LEFT JOIN +( +t2 +LEFT JOIN t34 +ON t34.a3=1 AND t2.b=t34.b4 +CROSS JOIN t5 +LEFT JOIN +( +t67 +LEFT JOIN +t8 +ON t67.b7=t8.b AND t67.b6 < 10 +) +ON t67.b6 >= 2 AND t5.b=t67.b7 +) +ON (t34.b3=2 OR t34.c3 IS NULL) AND (t67.b6=2 OR t67.c6 IS NULL) AND +(t1.b=t5.b OR t34.c3 IS NULL OR t67.c6 IS NULL or t8.c IS NULL) AND +(t1.a <> 2), +t9 +WHERE t0.a=1 AND +t0.b=t1.b AND +(t2.a >= 4 OR t2.c IS NULL) AND +(t34.a3 < 5 OR t34.c3 IS NULL) AND +(t34.b3=t34.b4 OR t34.c3 IS NULL OR t34.c4 IS NULL) AND +(t5.a >=2 OR t5.c IS NULL) AND +(t67.a6 >=4 OR t67.c6 IS NULL) AND +(t67.a7 <= 2 OR t67.c7 IS NULL) AND +(t8.a < 1 OR t8.c IS NULL) AND +(t8.b=t9.b OR t8.c IS NULL) AND +(t9.a=1); +a b a b a b a3 b3 a4 b4 a b a6 b6 a7 b7 a b a b +1 2 2 2 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL 1 1 +1 2 2 2 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL 1 2 +1 2 3 2 4 2 1 2 3 2 2 2 6 2 2 2 0 2 1 2 +1 2 3 2 4 2 1 2 3 2 3 1 6 2 1 1 NULL NULL 1 1 +1 2 3 2 4 2 1 2 3 2 3 1 6 2 1 1 NULL NULL 1 2 +1 2 3 2 4 2 1 2 3 2 3 3 NULL NULL NULL NULL NULL NULL 1 1 +1 2 3 2 4 2 1 2 3 2 3 3 NULL NULL NULL NULL NULL NULL 1 2 +1 2 3 2 4 2 1 2 4 2 2 2 6 2 2 2 0 2 1 2 +1 2 3 2 4 2 1 2 4 2 3 1 6 2 1 1 NULL NULL 1 1 +1 2 3 2 4 2 1 2 4 2 3 1 6 2 1 1 NULL NULL 1 2 +1 2 3 2 4 2 1 2 4 2 3 3 NULL NULL NULL NULL NULL NULL 1 1 +1 2 3 2 4 2 1 2 4 2 3 3 NULL NULL NULL NULL NULL NULL 1 2 +1 2 3 2 5 3 NULL NULL NULL NULL 2 2 6 2 2 2 0 2 1 2 +1 2 3 2 5 3 NULL NULL NULL NULL 3 1 6 2 1 1 NULL NULL 1 1 +1 2 3 2 5 3 NULL NULL NULL NULL 3 1 6 2 1 1 NULL NULL 1 2 +1 2 3 2 5 3 NULL NULL NULL NULL 3 3 NULL NULL NULL NULL NULL NULL 1 1 +1 2 3 2 5 3 NULL NULL NULL NULL 3 3 NULL NULL NULL NULL NULL NULL 1 2 +SELECT t1.a,t1.b +FROM t1; +a b +1 3 +2 2 +3 2 +SELECT t2.a,t2.b +FROM t2; +a b +3 3 +4 2 +5 3 +SELECT t3.a,t3.b +FROM t3; +a b +1 2 +2 2 +SELECT t2.a,t2.b,t3.a,t3.b +FROM t2 +LEFT JOIN +t3 +ON t2.b=t3.b; +a b a b +3 3 NULL NULL +4 2 1 2 +4 2 2 2 +5 3 NULL NULL +SELECT t1.a,t1.b,t2.a,t2.b,t3.a,t3.b +FROM t1, t2 +LEFT JOIN +t3 +ON t2.b=t3.b +WHERE t1.a <= 2; +a b a b a b +1 3 3 3 NULL NULL +1 3 4 2 1 2 +1 3 4 2 2 2 +1 3 5 3 NULL NULL +2 2 3 3 NULL NULL +2 2 4 2 1 2 +2 2 4 2 2 2 +2 2 5 3 NULL NULL +"Standard compliant copy of above query" +SELECT t1.a,t1.b,t2.a,t2.b,t3.a,t3.b +FROM t1 +CROSS JOIN t2 +LEFT JOIN +t3 +ON t2.b=t3.b +WHERE t1.a <= 2; +a b a b a b +1 3 3 3 NULL NULL +1 3 4 2 1 2 +1 3 4 2 2 2 +1 3 5 3 NULL NULL +2 2 3 3 NULL NULL +2 2 4 2 1 2 +2 2 4 2 2 2 +2 2 5 3 NULL NULL +SELECT t1.a,t1.b,t2.a,t2.b,t3.a,t3.b +FROM t1, t3 +RIGHT JOIN +t2 +ON t2.b=t3.b +WHERE t1.a <= 2; +a b a b a b +1 3 3 3 NULL NULL +1 3 4 2 1 2 +1 3 4 2 2 2 +1 3 5 3 NULL NULL +2 2 3 3 NULL NULL +2 2 4 2 1 2 +2 2 4 2 2 2 +2 2 5 3 NULL NULL +"Standard compliant copy of above query" +SELECT t1.a,t1.b,t2.a,t2.b,t3.a,t3.b +FROM t1 CROSS JOIN +( +t3 +RIGHT JOIN +t2 +ON t2.b=t3.b +) +WHERE t1.a <= 2; +a b a b a b +1 3 3 3 NULL NULL +1 3 4 2 1 2 +1 3 4 2 2 2 +1 3 5 3 NULL NULL +2 2 3 3 NULL NULL +2 2 4 2 1 2 +2 2 4 2 2 2 +2 2 5 3 NULL NULL +SELECT t3.a,t3.b,t4.a,t4.b +FROM t3,t4; +a b a b +1 2 3 2 +1 2 4 2 +2 2 3 2 +2 2 4 2 +SELECT t2.a,t2.b,t3.a,t3.b,t4.a,t4.b +FROM t2 +LEFT JOIN +(t3, t4) +ON t3.a=1 AND t2.b=t4.b; +a b a b a b +3 3 NULL NULL NULL NULL +4 2 1 2 3 2 +4 2 1 2 4 2 +5 3 NULL NULL NULL NULL +"Standard compliant copy of above query" +SELECT t2.a,t2.b,t3.a,t3.b,t4.a,t4.b +FROM t2 +LEFT JOIN +(t3 CROSS JOIN t4) +ON t3.a=1 AND t2.b=t4.b; +a b a b a b +3 3 NULL NULL NULL NULL +4 2 1 2 3 2 +4 2 1 2 4 2 +5 3 NULL NULL NULL NULL +SELECT t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b +FROM t1 CROSS JOIN +( +t2 +LEFT JOIN +(t3, t4) +ON t3.a=1 AND t2.b=t4.b +) +WHERE t1.a <= 2; +a b a b a b a b +1 3 3 3 NULL NULL NULL NULL +1 3 4 2 1 2 3 2 +1 3 4 2 1 2 4 2 +1 3 5 3 NULL NULL NULL NULL +2 2 3 3 NULL NULL NULL NULL +2 2 4 2 1 2 3 2 +2 2 4 2 1 2 4 2 +2 2 5 3 NULL NULL NULL NULL +"Standard compliant copy of above query" +SELECT t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b +FROM t1 CROSS JOIN +( +t2 +LEFT JOIN +(t3 CROSS JOIN t4) +ON t3.a=1 AND t2.b=t4.b +) +WHERE t1.a <= 2; +a b a b a b a b +1 3 3 3 NULL NULL NULL NULL +1 3 4 2 1 2 3 2 +1 3 4 2 1 2 4 2 +1 3 5 3 NULL NULL NULL NULL +2 2 3 3 NULL NULL NULL NULL +2 2 4 2 1 2 3 2 +2 2 4 2 1 2 4 2 +2 2 5 3 NULL NULL NULL NULL +SELECT t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b +FROM t1, (t3, t4) +RIGHT JOIN +t2 +ON t3.a=1 AND t2.b=t4.b +WHERE t1.a <= 2; +a b a b a b a b +1 3 3 3 NULL NULL NULL NULL +1 3 4 2 1 2 3 2 +1 3 4 2 1 2 4 2 +1 3 5 3 NULL NULL NULL NULL +2 2 3 3 NULL NULL NULL NULL +2 2 4 2 1 2 3 2 +2 2 4 2 1 2 4 2 +2 2 5 3 NULL NULL NULL NULL +"Standard compliant copy of above query" +SELECT t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b +FROM t1 CROSS JOIN +( +(t3 CROSS JOIN t4) +RIGHT JOIN +t2 +ON t3.a=1 AND t2.b=t4.b +) +WHERE t1.a <= 2; +a b a b a b a b +1 3 3 3 NULL NULL NULL NULL +1 3 4 2 1 2 3 2 +1 3 4 2 1 2 4 2 +1 3 5 3 NULL NULL NULL NULL +2 2 3 3 NULL NULL NULL NULL +2 2 4 2 1 2 3 2 +2 2 4 2 1 2 4 2 +2 2 5 3 NULL NULL NULL NULL +SELECT t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b +FROM t1, (t3, t4) +RIGHT JOIN +t2 +ON t3.a=1 AND t2.b=t4.b +WHERE t1.a <= 2; +a b a b a b a b +1 3 3 3 NULL NULL NULL NULL +1 3 4 2 1 2 3 2 +1 3 4 2 1 2 4 2 +1 3 5 3 NULL NULL NULL NULL +2 2 3 3 NULL NULL NULL NULL +2 2 4 2 1 2 3 2 +2 2 4 2 1 2 4 2 +2 2 5 3 NULL NULL NULL NULL +"Standard compliant copy of above query" +SELECT t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b +FROM t1 CROSS JOIN +( +(t3 CROSS JOIN t4) +RIGHT JOIN +t2 +ON t3.a=1 AND t2.b=t4.b +) +WHERE t1.a <= 2; +a b a b a b a b +1 3 3 3 NULL NULL NULL NULL +1 3 4 2 1 2 3 2 +1 3 4 2 1 2 4 2 +1 3 5 3 NULL NULL NULL NULL +2 2 3 3 NULL NULL NULL NULL +2 2 4 2 1 2 3 2 +2 2 4 2 1 2 4 2 +2 2 5 3 NULL NULL NULL NULL +EXPLAIN +SELECT t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b +FROM t1, (t3, t4) +RIGHT JOIN +t2 +ON t3.a=1 AND t2.b=t4.b +WHERE t1.a <= 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b` from `test`.`t1` join `test`.`t2` left join (`test`.`t3` join `test`.`t4`) on(((`test`.`t4`.`b` = `test`.`t2`.`b`) and (`test`.`t3`.`a` = 1))) where (`test`.`t1`.`a` <= 2) +CREATE INDEX idx_b ON t2(b); +EXPLAIN +SELECT t2.a,t2.b,t3.a,t3.b,t4.a,t4.b +FROM (t3,t4) +LEFT JOIN +(t1,t2) +ON t3.a=1 AND t3.b=t2.b AND t2.b=t4.b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t2 NULL ALL idx_b NULL NULL NULL 3 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b` from `test`.`t3` join `test`.`t4` left join (`test`.`t1` join `test`.`t2`) on(((`test`.`t4`.`b` = `test`.`t2`.`b`) and (`test`.`t2`.`b` = `test`.`t3`.`b`) and (`test`.`t3`.`a` = 1))) where true +SELECT t2.a,t2.b,t3.a,t3.b,t4.a,t4.b +FROM (t3,t4) +LEFT JOIN +(t1,t2) +ON t3.a=1 AND t3.b=t2.b AND t2.b=t4.b; +a b a b a b +4 2 1 2 3 2 +4 2 1 2 3 2 +4 2 1 2 3 2 +4 2 1 2 4 2 +4 2 1 2 4 2 +4 2 1 2 4 2 +NULL NULL 2 2 3 2 +NULL NULL 2 2 4 2 +"Standard compliant copy of above query" +SELECT t2.a,t2.b,t3.a,t3.b,t4.a,t4.b +FROM (t3 CROSS JOIN t4) +LEFT JOIN +(t1 CROSS JOIN t2) +ON t3.a=1 AND t3.b=t2.b AND t2.b=t4.b; +a b a b a b +4 2 1 2 3 2 +4 2 1 2 3 2 +4 2 1 2 3 2 +4 2 1 2 4 2 +4 2 1 2 4 2 +4 2 1 2 4 2 +NULL NULL 2 2 3 2 +NULL NULL 2 2 4 2 +ANALYZE TABLE t0, t1, t2, t3, t4, t5, t6, t7, t8, t9; +Table Op Msg_type Msg_text +test.t0 analyze status OK +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +test.t4 analyze status OK +test.t5 analyze status OK +test.t6 analyze status OK +test.t7 analyze status OK +test.t8 analyze status OK +test.t9 analyze status OK +EXPLAIN +SELECT t0.a,t0.b,t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b, +t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b,t9.a,t9.b +FROM t0,t1 +LEFT JOIN +( +t2 +LEFT JOIN +(t3, t4) +ON t3.a=1 AND t2.b=t4.b, +t5 +LEFT JOIN +( +(t6, t7) +LEFT JOIN +t8 +ON t7.b=t8.b AND t6.b < 10 +) +ON t6.b >= 2 AND t5.b=t7.b +) +ON (t3.b=2 OR t3.c IS NULL) AND (t6.b=2 OR t6.c IS NULL) AND +(t1.b=t5.b OR t3.c IS NULL OR t6.c IS NULL or t8.c IS NULL) AND +(t1.a != 2), +t9 +WHERE t0.a=1 AND +t0.b=t1.b AND +(t2.a >= 4 OR t2.c IS NULL) AND +(t3.a < 5 OR t3.c IS NULL) AND +(t3.b=t4.b OR t3.c IS NULL OR t4.c IS NULL) AND +(t5.a >=2 OR t5.c IS NULL) AND +(t6.a >=4 OR t6.c IS NULL) AND +(t7.a <= 2 OR t7.c IS NULL) AND +(t8.a < 1 OR t8.c IS NULL) AND +(t8.b=t9.b OR t8.c IS NULL) AND +(t9.a=1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE t0 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +2 SIMPLE t9 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 55.56 Using where; Using join buffer (hash join) +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 75.00 Using where; Using join buffer (hash join) +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t5 NULL ALL NULL NULL NULL NULL 3 55.56 Using where; Using join buffer (hash join) +2 SIMPLE t7 NULL ALL NULL NULL NULL NULL 2 75.00 Using where; Using join buffer (hash join) +2 SIMPLE t6 NULL ALL NULL NULL NULL NULL 3 55.56 Using where; Using join buffer (hash join) +2 SIMPLE t8 NULL ALL NULL NULL NULL NULL 2 56.25 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a`,`test`.`t0`.`b` AS `b`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t5`.`a` AS `a`,`test`.`t5`.`b` AS `b`,`test`.`t6`.`a` AS `a`,`test`.`t6`.`b` AS `b`,`test`.`t7`.`a` AS `a`,`test`.`t7`.`b` AS `b`,`test`.`t8`.`a` AS `a`,`test`.`t8`.`b` AS `b`,`test`.`t9`.`a` AS `a`,`test`.`t9`.`b` AS `b` from `test`.`t0` join `test`.`t1` left join (`test`.`t2` left join (`test`.`t3` join `test`.`t4`) on(((`test`.`t4`.`b` = `test`.`t2`.`b`) and (`test`.`t3`.`a` = 1))) join `test`.`t5` left join (`test`.`t6` join `test`.`t7` left join `test`.`t8` on(((`test`.`t8`.`b` = `test`.`t7`.`b`) and (`test`.`t6`.`b` < 10)))) on(((`test`.`t7`.`b` = `test`.`t5`.`b`) and (`test`.`t6`.`b` >= 2)))) on((((`test`.`t3`.`b` = 2) or (`test`.`t3`.`c` is null)) and ((`test`.`t6`.`b` = 2) or (`test`.`t6`.`c` is null)) and ((`test`.`t5`.`b` = `test`.`t0`.`b`) or (`test`.`t3`.`c` is null) or (`test`.`t6`.`c` is null) or (`test`.`t8`.`c` is null)) and (`test`.`t1`.`a` <> 2))) join `test`.`t9` where ((`test`.`t9`.`a` = 1) and (`test`.`t1`.`b` = `test`.`t0`.`b`) and (`test`.`t0`.`a` = 1) and ((`test`.`t2`.`a` >= 4) or (`test`.`t2`.`c` is null)) and ((`test`.`t3`.`a` < 5) or (`test`.`t3`.`c` is null)) and ((`test`.`t4`.`b` = `test`.`t3`.`b`) or (`test`.`t3`.`c` is null) or (`test`.`t4`.`c` is null)) and ((`test`.`t5`.`a` >= 2) or (`test`.`t5`.`c` is null)) and ((`test`.`t6`.`a` >= 4) or (`test`.`t6`.`c` is null)) and ((`test`.`t7`.`a` <= 2) or (`test`.`t7`.`c` is null)) and ((`test`.`t8`.`a` < 1) or (`test`.`t8`.`c` is null)) and ((`test`.`t8`.`b` = `test`.`t9`.`b`) or (`test`.`t8`.`c` is null))) +CREATE INDEX idx_b ON t4(b); +CREATE INDEX idx_b ON t5(b); +ANALYZE TABLE t0, t1, t2, t3, t4, t5, t6, t7, t8, t9; +Table Op Msg_type Msg_text +test.t0 analyze status OK +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +test.t4 analyze status OK +test.t5 analyze status OK +test.t6 analyze status OK +test.t7 analyze status OK +test.t8 analyze status OK +test.t9 analyze status OK +EXPLAIN +SELECT t0.a,t0.b,t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b, +t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b,t9.a,t9.b +FROM t0,t1 +LEFT JOIN +( +t2 +LEFT JOIN +(t3, t4) +ON t3.a=1 AND t2.b=t4.b, +t5 +LEFT JOIN +( +(t6, t7) +LEFT JOIN +t8 +ON t7.b=t8.b AND t6.b < 10 +) +ON t6.b >= 2 AND t5.b=t7.b +) +ON (t3.b=2 OR t3.c IS NULL) AND (t6.b=2 OR t6.c IS NULL) AND +(t1.b=t5.b OR t3.c IS NULL OR t6.c IS NULL or t8.c IS NULL) AND +(t1.a != 2), +t9 +WHERE t0.a=1 AND +t0.b=t1.b AND +(t2.a >= 4 OR t2.c IS NULL) AND +(t3.a < 5 OR t3.c IS NULL) AND +(t3.b=t4.b OR t3.c IS NULL OR t4.c IS NULL) AND +(t5.a >=2 OR t5.c IS NULL) AND +(t6.a >=4 OR t6.c IS NULL) AND +(t7.a <= 2 OR t7.c IS NULL) AND +(t8.a < 1 OR t8.c IS NULL) AND +(t8.b=t9.b OR t8.c IS NULL) AND +(t9.a=1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE t0 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +2 SIMPLE t9 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 55.56 Using where; Using join buffer (hash join) +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 75.00 Using where; Using join buffer (hash join) +2 SIMPLE t4 NULL ALL idx_b NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t5 NULL ALL idx_b NULL NULL NULL 3 55.56 Using where; Using join buffer (hash join) +2 SIMPLE t7 NULL ALL NULL NULL NULL NULL 2 75.00 Using where; Using join buffer (hash join) +2 SIMPLE t6 NULL ALL NULL NULL NULL NULL 3 55.56 Using where; Using join buffer (hash join) +2 SIMPLE t8 NULL ALL NULL NULL NULL NULL 2 56.25 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a`,`test`.`t0`.`b` AS `b`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t5`.`a` AS `a`,`test`.`t5`.`b` AS `b`,`test`.`t6`.`a` AS `a`,`test`.`t6`.`b` AS `b`,`test`.`t7`.`a` AS `a`,`test`.`t7`.`b` AS `b`,`test`.`t8`.`a` AS `a`,`test`.`t8`.`b` AS `b`,`test`.`t9`.`a` AS `a`,`test`.`t9`.`b` AS `b` from `test`.`t0` join `test`.`t1` left join (`test`.`t2` left join (`test`.`t3` join `test`.`t4`) on(((`test`.`t4`.`b` = `test`.`t2`.`b`) and (`test`.`t3`.`a` = 1))) join `test`.`t5` left join (`test`.`t6` join `test`.`t7` left join `test`.`t8` on(((`test`.`t8`.`b` = `test`.`t7`.`b`) and (`test`.`t6`.`b` < 10)))) on(((`test`.`t7`.`b` = `test`.`t5`.`b`) and (`test`.`t6`.`b` >= 2)))) on((((`test`.`t3`.`b` = 2) or (`test`.`t3`.`c` is null)) and ((`test`.`t6`.`b` = 2) or (`test`.`t6`.`c` is null)) and ((`test`.`t5`.`b` = `test`.`t0`.`b`) or (`test`.`t3`.`c` is null) or (`test`.`t6`.`c` is null) or (`test`.`t8`.`c` is null)) and (`test`.`t1`.`a` <> 2))) join `test`.`t9` where ((`test`.`t9`.`a` = 1) and (`test`.`t1`.`b` = `test`.`t0`.`b`) and (`test`.`t0`.`a` = 1) and ((`test`.`t2`.`a` >= 4) or (`test`.`t2`.`c` is null)) and ((`test`.`t3`.`a` < 5) or (`test`.`t3`.`c` is null)) and ((`test`.`t4`.`b` = `test`.`t3`.`b`) or (`test`.`t3`.`c` is null) or (`test`.`t4`.`c` is null)) and ((`test`.`t5`.`a` >= 2) or (`test`.`t5`.`c` is null)) and ((`test`.`t6`.`a` >= 4) or (`test`.`t6`.`c` is null)) and ((`test`.`t7`.`a` <= 2) or (`test`.`t7`.`c` is null)) and ((`test`.`t8`.`a` < 1) or (`test`.`t8`.`c` is null)) and ((`test`.`t8`.`b` = `test`.`t9`.`b`) or (`test`.`t8`.`c` is null))) +CREATE INDEX idx_b ON t8(b); +ANALYZE TABLE t0, t1, t2, t3, t4, t5, t6, t7, t8, t9; +Table Op Msg_type Msg_text +test.t0 analyze status OK +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +test.t4 analyze status OK +test.t5 analyze status OK +test.t6 analyze status OK +test.t7 analyze status OK +test.t8 analyze status OK +test.t9 analyze status OK +EXPLAIN +SELECT t0.a,t0.b,t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b, +t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b,t9.a,t9.b +FROM t0,t1 +LEFT JOIN +( +t2 +LEFT JOIN +(t3, t4) +ON t3.a=1 AND t2.b=t4.b, +t5 +LEFT JOIN +( +(t6, t7) +LEFT JOIN +t8 +ON t7.b=t8.b AND t6.b < 10 +) +ON t6.b >= 2 AND t5.b=t7.b +) +ON (t3.b=2 OR t3.c IS NULL) AND (t6.b=2 OR t6.c IS NULL) AND +(t1.b=t5.b OR t3.c IS NULL OR t6.c IS NULL or t8.c IS NULL) AND +(t1.a != 2), +t9 +WHERE t0.a=1 AND +t0.b=t1.b AND +(t2.a >= 4 OR t2.c IS NULL) AND +(t3.a < 5 OR t3.c IS NULL) AND +(t3.b=t4.b OR t3.c IS NULL OR t4.c IS NULL) AND +(t5.a >=2 OR t5.c IS NULL) AND +(t6.a >=4 OR t6.c IS NULL) AND +(t7.a <= 2 OR t7.c IS NULL) AND +(t8.a < 1 OR t8.c IS NULL) AND +(t8.b=t9.b OR t8.c IS NULL) AND +(t9.a=1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE t0 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +2 SIMPLE t9 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 55.56 Using where; Using join buffer (hash join) +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 75.00 Using where; Using join buffer (hash join) +2 SIMPLE t4 NULL ALL idx_b NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t5 NULL ALL idx_b NULL NULL NULL 3 55.56 Using where; Using join buffer (hash join) +2 SIMPLE t7 NULL ALL NULL NULL NULL NULL 2 75.00 Using where; Using join buffer (hash join) +2 SIMPLE t6 NULL ALL NULL NULL NULL NULL 3 55.56 Using where; Using join buffer (hash join) +2 SIMPLE t8 NULL ALL idx_b NULL NULL NULL 2 75.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a`,`test`.`t0`.`b` AS `b`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t5`.`a` AS `a`,`test`.`t5`.`b` AS `b`,`test`.`t6`.`a` AS `a`,`test`.`t6`.`b` AS `b`,`test`.`t7`.`a` AS `a`,`test`.`t7`.`b` AS `b`,`test`.`t8`.`a` AS `a`,`test`.`t8`.`b` AS `b`,`test`.`t9`.`a` AS `a`,`test`.`t9`.`b` AS `b` from `test`.`t0` join `test`.`t1` left join (`test`.`t2` left join (`test`.`t3` join `test`.`t4`) on(((`test`.`t4`.`b` = `test`.`t2`.`b`) and (`test`.`t3`.`a` = 1))) join `test`.`t5` left join (`test`.`t6` join `test`.`t7` left join `test`.`t8` on(((`test`.`t8`.`b` = `test`.`t7`.`b`) and (`test`.`t6`.`b` < 10)))) on(((`test`.`t7`.`b` = `test`.`t5`.`b`) and (`test`.`t6`.`b` >= 2)))) on((((`test`.`t3`.`b` = 2) or (`test`.`t3`.`c` is null)) and ((`test`.`t6`.`b` = 2) or (`test`.`t6`.`c` is null)) and ((`test`.`t5`.`b` = `test`.`t0`.`b`) or (`test`.`t3`.`c` is null) or (`test`.`t6`.`c` is null) or (`test`.`t8`.`c` is null)) and (`test`.`t1`.`a` <> 2))) join `test`.`t9` where ((`test`.`t9`.`a` = 1) and (`test`.`t1`.`b` = `test`.`t0`.`b`) and (`test`.`t0`.`a` = 1) and ((`test`.`t2`.`a` >= 4) or (`test`.`t2`.`c` is null)) and ((`test`.`t3`.`a` < 5) or (`test`.`t3`.`c` is null)) and ((`test`.`t4`.`b` = `test`.`t3`.`b`) or (`test`.`t3`.`c` is null) or (`test`.`t4`.`c` is null)) and ((`test`.`t5`.`a` >= 2) or (`test`.`t5`.`c` is null)) and ((`test`.`t6`.`a` >= 4) or (`test`.`t6`.`c` is null)) and ((`test`.`t7`.`a` <= 2) or (`test`.`t7`.`c` is null)) and ((`test`.`t8`.`a` < 1) or (`test`.`t8`.`c` is null)) and ((`test`.`t8`.`b` = `test`.`t9`.`b`) or (`test`.`t8`.`c` is null))) +CREATE INDEX idx_b ON t1(b); +CREATE INDEX idx_a ON t0(a); +ANALYZE TABLE t0, t1, t2, t3, t4, t5, t6, t7, t8, t9; +Table Op Msg_type Msg_text +test.t0 analyze status OK +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +test.t4 analyze status OK +test.t5 analyze status OK +test.t6 analyze status OK +test.t7 analyze status OK +test.t8 analyze status OK +test.t9 analyze status OK +EXPLAIN +SELECT t0.a,t0.b,t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b, +t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b,t9.a,t9.b +FROM t0,t1 +LEFT JOIN +( +t2 +LEFT JOIN +(t3, t4) +ON t3.a=1 AND t2.b=t4.b, +t5 +LEFT JOIN +( +(t6, t7) +LEFT JOIN +t8 +ON t7.b=t8.b AND t6.b < 10 +) +ON t6.b >= 2 AND t5.b=t7.b +) +ON (t3.b=2 OR t3.c IS NULL) AND (t6.b=2 OR t6.c IS NULL) AND +(t1.b=t5.b OR t3.c IS NULL OR t6.c IS NULL or t8.c IS NULL) AND +(t1.a != 2), +t9 +WHERE t0.a=1 AND +t0.b=t1.b AND +(t2.a >= 4 OR t2.c IS NULL) AND +(t3.a < 5 OR t3.c IS NULL) AND +(t3.b=t4.b OR t3.c IS NULL OR t4.c IS NULL) AND +(t5.a >=2 OR t5.c IS NULL) AND +(t6.a >=4 OR t6.c IS NULL) AND +(t7.a <= 2 OR t7.c IS NULL) AND +(t8.a < 1 OR t8.c IS NULL) AND +(t8.b=t9.b OR t8.c IS NULL) AND +(t9.a=1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE t9 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +2 SIMPLE t1 NULL ALL idx_b NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 SIMPLE t0 NULL ref idx_a idx_a 5 const 2 33.33 Using where +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 55.56 Using where; Using join buffer (hash join) +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 75.00 Using where; Using join buffer (hash join) +2 SIMPLE t4 NULL ALL idx_b NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t5 NULL ALL idx_b NULL NULL NULL 3 55.56 Using where; Using join buffer (hash join) +2 SIMPLE t7 NULL ALL NULL NULL NULL NULL 2 75.00 Using where; Using join buffer (hash join) +2 SIMPLE t6 NULL ALL NULL NULL NULL NULL 3 55.56 Using where; Using join buffer (hash join) +2 SIMPLE t8 NULL ALL idx_b NULL NULL NULL 2 75.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a`,`test`.`t0`.`b` AS `b`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t5`.`a` AS `a`,`test`.`t5`.`b` AS `b`,`test`.`t6`.`a` AS `a`,`test`.`t6`.`b` AS `b`,`test`.`t7`.`a` AS `a`,`test`.`t7`.`b` AS `b`,`test`.`t8`.`a` AS `a`,`test`.`t8`.`b` AS `b`,`test`.`t9`.`a` AS `a`,`test`.`t9`.`b` AS `b` from `test`.`t0` join `test`.`t1` left join (`test`.`t2` left join (`test`.`t3` join `test`.`t4`) on(((`test`.`t4`.`b` = `test`.`t2`.`b`) and (`test`.`t3`.`a` = 1))) join `test`.`t5` left join (`test`.`t6` join `test`.`t7` left join `test`.`t8` on(((`test`.`t8`.`b` = `test`.`t7`.`b`) and (`test`.`t6`.`b` < 10)))) on(((`test`.`t7`.`b` = `test`.`t5`.`b`) and (`test`.`t6`.`b` >= 2)))) on((((`test`.`t3`.`b` = 2) or (`test`.`t3`.`c` is null)) and ((`test`.`t6`.`b` = 2) or (`test`.`t6`.`c` is null)) and ((`test`.`t5`.`b` = `test`.`t1`.`b`) or (`test`.`t3`.`c` is null) or (`test`.`t6`.`c` is null) or (`test`.`t8`.`c` is null)) and (`test`.`t1`.`a` <> 2))) join `test`.`t9` where ((`test`.`t9`.`a` = 1) and (`test`.`t0`.`b` = `test`.`t1`.`b`) and (`test`.`t0`.`a` = 1) and ((`test`.`t2`.`a` >= 4) or (`test`.`t2`.`c` is null)) and ((`test`.`t3`.`a` < 5) or (`test`.`t3`.`c` is null)) and ((`test`.`t4`.`b` = `test`.`t3`.`b`) or (`test`.`t3`.`c` is null) or (`test`.`t4`.`c` is null)) and ((`test`.`t5`.`a` >= 2) or (`test`.`t5`.`c` is null)) and ((`test`.`t6`.`a` >= 4) or (`test`.`t6`.`c` is null)) and ((`test`.`t7`.`a` <= 2) or (`test`.`t7`.`c` is null)) and ((`test`.`t8`.`a` < 1) or (`test`.`t8`.`c` is null)) and ((`test`.`t8`.`b` = `test`.`t9`.`b`) or (`test`.`t8`.`c` is null))) +SELECT t0.a,t0.b,t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b, +t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b,t9.a,t9.b +FROM t0,t1 +LEFT JOIN +( +t2 +LEFT JOIN +(t3, t4) +ON t3.a=1 AND t2.b=t4.b, +t5 +LEFT JOIN +( +(t6, t7) +LEFT JOIN +t8 +ON t7.b=t8.b AND t6.b < 10 +) +ON t6.b >= 2 AND t5.b=t7.b +) +ON (t3.b=2 OR t3.c IS NULL) AND (t6.b=2 OR t6.c IS NULL) AND +(t1.b=t5.b OR t3.c IS NULL OR t6.c IS NULL or t8.c IS NULL) AND +(t1.a != 2), +t9 +WHERE t0.a=1 AND +t0.b=t1.b AND +(t2.a >= 4 OR t2.c IS NULL) AND +(t3.a < 5 OR t3.c IS NULL) AND +(t3.b=t4.b OR t3.c IS NULL OR t4.c IS NULL) AND +(t5.a >=2 OR t5.c IS NULL) AND +(t6.a >=4 OR t6.c IS NULL) AND +(t7.a <= 2 OR t7.c IS NULL) AND +(t8.a < 1 OR t8.c IS NULL) AND +(t8.b=t9.b OR t8.c IS NULL) AND +(t9.a=1); +a b a b a b a b a b a b a b a b a b a b +1 2 2 2 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL 1 1 +1 2 2 2 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL 1 2 +1 2 3 2 4 2 1 2 3 2 2 2 6 2 2 2 0 2 1 2 +1 2 3 2 4 2 1 2 3 2 3 1 6 2 1 1 NULL NULL 1 1 +1 2 3 2 4 2 1 2 3 2 3 1 6 2 1 1 NULL NULL 1 2 +1 2 3 2 4 2 1 2 3 2 3 3 NULL NULL NULL NULL NULL NULL 1 1 +1 2 3 2 4 2 1 2 3 2 3 3 NULL NULL NULL NULL NULL NULL 1 2 +1 2 3 2 4 2 1 2 4 2 2 2 6 2 2 2 0 2 1 2 +1 2 3 2 4 2 1 2 4 2 3 1 6 2 1 1 NULL NULL 1 1 +1 2 3 2 4 2 1 2 4 2 3 1 6 2 1 1 NULL NULL 1 2 +1 2 3 2 4 2 1 2 4 2 3 3 NULL NULL NULL NULL NULL NULL 1 1 +1 2 3 2 4 2 1 2 4 2 3 3 NULL NULL NULL NULL NULL NULL 1 2 +1 2 3 2 5 3 NULL NULL NULL NULL 2 2 6 2 2 2 0 2 1 2 +1 2 3 2 5 3 NULL NULL NULL NULL 3 1 6 2 1 1 NULL NULL 1 1 +1 2 3 2 5 3 NULL NULL NULL NULL 3 1 6 2 1 1 NULL NULL 1 2 +1 2 3 2 5 3 NULL NULL NULL NULL 3 3 NULL NULL NULL NULL NULL NULL 1 1 +1 2 3 2 5 3 NULL NULL NULL NULL 3 3 NULL NULL NULL NULL NULL NULL 1 2 +"Standard compliant copy of above query" +SELECT t0.a,t0.b,t1.a,t1.b,t2.a,t2.b,t34.a3,t34.b3,t34.a4,t34.b4, +t5.a,t5.b,t67.a6,t67.b6,t67.a7,t67.b7,t8.a,t8.b,t9.a,t9.b +FROM t0 +CROSS JOIN t1 +LEFT JOIN +( +t2 +LEFT JOIN +t34 +ON t34.a3=1 AND t2.b=t34.b4 +CROSS JOIN t5 +LEFT JOIN +( +t67 +LEFT JOIN +t8 +ON t67.b7=t8.b AND t67.b6 < 10 +) +ON t67.b6 >= 2 AND t5.b=t67.b7 +) +ON (t34.b3=2 OR t34.c3 IS NULL) AND (t67.b6=2 OR t67.c6 IS NULL) AND +(t1.b=t5.b OR t34.c3 IS NULL OR t67.c6 IS NULL or t8.c IS NULL) AND +(t1.a <> 2) +CROSS JOIN t9 +WHERE t0.a=1 AND +t0.b=t1.b AND +(t2.a >= 4 OR t2.c IS NULL) AND +(t34.a3 < 5 OR t34.c3 IS NULL) AND +(t34.b3=t34.b4 OR t34.c3 IS NULL OR t34.c4 IS NULL) AND +(t5.a >=2 OR t5.c IS NULL) AND +(t67.a6 >=4 OR t67.c6 IS NULL) AND +(t67.a7 <= 2 OR t67.c7 IS NULL) AND +(t8.a < 1 OR t8.c IS NULL) AND +(t8.b=t9.b OR t8.c IS NULL) AND +(t9.a=1); +a b a b a b a3 b3 a4 b4 a b a6 b6 a7 b7 a b a b +1 2 2 2 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL 1 1 +1 2 2 2 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL 1 2 +1 2 3 2 4 2 1 2 3 2 2 2 6 2 2 2 0 2 1 2 +1 2 3 2 4 2 1 2 3 2 3 1 6 2 1 1 NULL NULL 1 1 +1 2 3 2 4 2 1 2 3 2 3 1 6 2 1 1 NULL NULL 1 2 +1 2 3 2 4 2 1 2 3 2 3 3 NULL NULL NULL NULL NULL NULL 1 1 +1 2 3 2 4 2 1 2 3 2 3 3 NULL NULL NULL NULL NULL NULL 1 2 +1 2 3 2 4 2 1 2 4 2 2 2 6 2 2 2 0 2 1 2 +1 2 3 2 4 2 1 2 4 2 3 1 6 2 1 1 NULL NULL 1 1 +1 2 3 2 4 2 1 2 4 2 3 1 6 2 1 1 NULL NULL 1 2 +1 2 3 2 4 2 1 2 4 2 3 3 NULL NULL NULL NULL NULL NULL 1 1 +1 2 3 2 4 2 1 2 4 2 3 3 NULL NULL NULL NULL NULL NULL 1 2 +1 2 3 2 5 3 NULL NULL NULL NULL 2 2 6 2 2 2 0 2 1 2 +1 2 3 2 5 3 NULL NULL NULL NULL 3 1 6 2 1 1 NULL NULL 1 1 +1 2 3 2 5 3 NULL NULL NULL NULL 3 1 6 2 1 1 NULL NULL 1 2 +1 2 3 2 5 3 NULL NULL NULL NULL 3 3 NULL NULL NULL NULL NULL NULL 1 1 +1 2 3 2 5 3 NULL NULL NULL NULL 3 3 NULL NULL NULL NULL NULL NULL 1 2 +SELECT t2.a,t2.b +FROM t2; +a b +3 3 +4 2 +5 3 +SELECT t3.a,t3.b +FROM t3; +a b +1 2 +2 2 +SELECT t2.a,t2.b,t3.a,t3.b +FROM t2 LEFT JOIN t3 ON t2.b=t3.b +WHERE t2.a = 4 OR (t2.a > 4 AND t3.a IS NULL); +a b a b +4 2 1 2 +4 2 2 2 +5 3 NULL NULL +SELECT t2.a,t2.b,t3.a,t3.b +FROM t2 LEFT JOIN (t3) ON t2.b=t3.b +WHERE t2.a = 4 OR (t2.a > 4 AND t3.a IS NULL); +a b a b +4 2 1 2 +4 2 2 2 +5 3 NULL NULL +ALTER TABLE t3 +CHANGE COLUMN a a1 int, +CHANGE COLUMN c c1 int; +SELECT t2.a,t2.b,t3.a1,t3.b +FROM t2 LEFT JOIN t3 ON t2.b=t3.b +WHERE t2.a = 4 OR (t2.a > 4 AND t3.a1 IS NULL); +a b a1 b +4 2 1 2 +4 2 2 2 +5 3 NULL NULL +SELECT t2.a,t2.b,t3.a1,t3.b +FROM t2 NATURAL LEFT JOIN t3 +WHERE t2.a = 4 OR (t2.a > 4 AND t3.a1 IS NULL); +a b a1 b +4 2 1 2 +4 2 2 2 +5 3 NULL NULL +DROP TABLE t0,t1,t2,t3,t4,t5,t6,t7,t8,t9; +DROP TABLE t34, t345, t67; +CREATE TABLE t1 (a int); +CREATE TABLE t2 (a int); +CREATE TABLE t3 (a int); +INSERT INTO t1 VALUES (1); +INSERT INTO t2 VALUES (2); +INSERT INTO t3 VALUES (2); +INSERT INTO t1 VALUES (2); +SELECT * FROM t1 LEFT JOIN (t2 LEFT JOIN t3 ON t2.a=t3.a) ON t1.a=t3.a; +a a a +1 NULL NULL +2 2 2 +SELECT * FROM t1 LEFT JOIN t2 LEFT JOIN t3 ON t2.a=t3.a ON t1.a=t3.a; +a a a +1 NULL NULL +2 2 2 +DELETE FROM t1 WHERE a=2; +SELECT * FROM t1 LEFT JOIN t2 LEFT JOIN t3 ON t2.a=t3.a ON t1.a=t3.a; +a a a +1 NULL NULL +DELETE FROM t2; +SELECT * FROM t1 LEFT JOIN t2 LEFT JOIN t3 ON t2.a=t3.a ON t1.a=t3.a; +a a a +1 NULL NULL +DROP TABLE t1,t2,t3; +CREATE TABLE t1(a int, key (a)); +CREATE TABLE t2(b int, key (b)); +CREATE TABLE t3(c int, key (c)); +INSERT INTO t1 VALUES (NULL), (0), (1), (2), (3), (4), (5), (6), (7), (8), (9), +(10), (11), (12), (13), (14), (15), (16), (17), (18), (19); +INSERT INTO t2 VALUES (NULL), (0), (1), (2), (3), (4), (5), (6), (7), (8), (9), +(10), (11), (12), (13), (14), (15), (16), (17), (18), (19); +INSERT INTO t3 VALUES (0), (1), (2), (3), (4), (5); +ANALYZE TABLE t1, t2, t3; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +EXPLAIN SELECT a, b, c FROM t1 LEFT JOIN (t2, t3) ON c < 3 and b = c; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 21 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL a 5 NULL 21 100.00 Using index +2 SIMPLE t3 NULL index c c 5 NULL 6 100.00 Using where; Using index +2 SIMPLE t2 NULL ref b b 5 test.t3.c 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`c` AS `c` from `test`.`t1` left join (`test`.`t2` join `test`.`t3`) on(((`test`.`t2`.`b` = `test`.`t3`.`c`) and (`test`.`t3`.`c` < 3))) where true +EXPLAIN SELECT a, b, c FROM t1 LEFT JOIN (t2, t3) ON b < 3 and b = c; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 21 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL a 5 NULL 21 100.00 Using index +2 SIMPLE t3 NULL index c c 5 NULL 6 100.00 Using where; Using index +2 SIMPLE t2 NULL ref b b 5 test.t3.c 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`c` AS `c` from `test`.`t1` left join (`test`.`t2` join `test`.`t3`) on(((`test`.`t2`.`b` = `test`.`t3`.`c`) and (`test`.`t3`.`c` < 3))) where true +SELECT a, b, c FROM t1 LEFT JOIN (t2, t3) ON b < 3 and b = c; +a b c +0 0 0 +0 1 1 +0 2 2 +1 0 0 +1 1 1 +1 2 2 +10 0 0 +10 1 1 +10 2 2 +11 0 0 +11 1 1 +11 2 2 +12 0 0 +12 1 1 +12 2 2 +13 0 0 +13 1 1 +13 2 2 +14 0 0 +14 1 1 +14 2 2 +15 0 0 +15 1 1 +15 2 2 +16 0 0 +16 1 1 +16 2 2 +17 0 0 +17 1 1 +17 2 2 +18 0 0 +18 1 1 +18 2 2 +19 0 0 +19 1 1 +19 2 2 +2 0 0 +2 1 1 +2 2 2 +3 0 0 +3 1 1 +3 2 2 +4 0 0 +4 1 1 +4 2 2 +5 0 0 +5 1 1 +5 2 2 +6 0 0 +6 1 1 +6 2 2 +7 0 0 +7 1 1 +7 2 2 +8 0 0 +8 1 1 +8 2 2 +9 0 0 +9 1 1 +9 2 2 +NULL 0 0 +NULL 1 1 +NULL 2 2 +DELETE FROM t3; +ANALYZE TABLE t3; +Table Op Msg_type Msg_text +test.t3 analyze status OK +EXPLAIN SELECT a, b, c FROM t1 LEFT JOIN (t2, t3) ON b < 3 and b = c; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 21 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL a 5 NULL 21 100.00 Using index +2 SIMPLE t3 NULL index c c 5 NULL 1 100.00 Using where; Using index +2 SIMPLE t2 NULL ref b b 5 test.t3.c 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`c` AS `c` from `test`.`t1` left join (`test`.`t2` join `test`.`t3`) on(((`test`.`t2`.`b` = `test`.`t3`.`c`) and (`test`.`t3`.`c` < 3))) where true +SELECT a, b, c FROM t1 LEFT JOIN (t2, t3) ON b < 3 and b = c; +a b c +0 NULL NULL +1 NULL NULL +10 NULL NULL +11 NULL NULL +12 NULL NULL +13 NULL NULL +14 NULL NULL +15 NULL NULL +16 NULL NULL +17 NULL NULL +18 NULL NULL +19 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 NULL NULL +7 NULL NULL +8 NULL NULL +9 NULL NULL +NULL NULL NULL +DROP TABLE t1,t2,t3; +CREATE TABLE t1 (c11 int); +CREATE TABLE t2 (c21 int); +CREATE TABLE t3 (c31 int); +INSERT INTO t1 VALUES (4), (5); +ANALYZE TABLE t1, t2, t3; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +SELECT * FROM t1 LEFT JOIN t2 ON c11=c21; +c11 c21 +4 NULL +5 NULL +EXPLAIN SELECT * FROM t1 LEFT JOIN t2 ON c11=c21; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c11` AS `c11`,`test`.`t2`.`c21` AS `c21` from `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`c21` = `test`.`t1`.`c11`)) where true +SELECT * FROM t1 LEFT JOIN (t2 LEFT JOIN t3 ON c21=c31) ON c11=c21; +c11 c21 c31 +4 NULL NULL +5 NULL NULL +EXPLAIN SELECT * FROM t1 LEFT JOIN (t2 LEFT JOIN t3 ON c21=c31) ON c11=c21; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c11` AS `c11`,`test`.`t2`.`c21` AS `c21`,`test`.`t3`.`c31` AS `c31` from `test`.`t1` left join (`test`.`t2` left join `test`.`t3` on((`test`.`t3`.`c31` = `test`.`t2`.`c21`))) on((`test`.`t2`.`c21` = `test`.`t1`.`c11`)) where true +DROP TABLE t1,t2,t3; +CREATE TABLE t1 (goods int(12) NOT NULL, price varchar(128) NOT NULL); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (23, 2340), (26, 9900); +CREATE TABLE t2 (goods int(12), name varchar(50), shop char(2)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (23, 'as300', 'fr'), (26, 'as600', 'fr'); +create table t3 (groupid int(12) NOT NULL, goodsid int(12) NOT NULL); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t3 VALUES (3,23), (6,26); +CREATE TABLE t4 (groupid int(12)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t4 VALUES (1), (2), (3), (4), (5), (6); +SELECT * FROM +(SELECT DISTINCT gl.groupid, gp.price +FROM t4 gl +LEFT JOIN +(t3 g INNER JOIN t2 p ON g.goodsid = p.goods +INNER JOIN t1 gp ON p.goods = gp.goods) +ON gl.groupid = g.groupid and p.shop = 'fr') t; +groupid price +1 NULL +2 NULL +3 2340 +4 NULL +5 NULL +6 9900 +CREATE VIEW v1 AS +SELECT g.groupid groupid, p.goods goods, +p.name name, p.shop shop, +gp.price price +FROM t3 g INNER JOIN t2 p ON g.goodsid = p.goods +INNER JOIN t1 gp on p.goods = gp.goods; +CREATE VIEW v2 AS +SELECT DISTINCT g.groupid, fr.price +FROM t4 g +LEFT JOIN +v1 fr on g.groupid = fr.groupid and fr.shop = 'fr'; +SELECT * FROM v2; +groupid price +1 NULL +2 NULL +3 2340 +4 NULL +5 NULL +6 9900 +SELECT * FROM +(SELECT DISTINCT g.groupid, fr.price +FROM t4 g +LEFT JOIN +v1 fr on g.groupid = fr.groupid and fr.shop = 'fr') t; +groupid price +1 NULL +2 NULL +3 2340 +4 NULL +5 NULL +6 9900 +DROP VIEW v1,v2; +DROP TABLE t1,t2,t3,t4; +CREATE TABLE t1(a int); +CREATE TABLE t2(b int); +CREATE TABLE t3(c int, d int); +CREATE TABLE t4(d int); +CREATE TABLE t5(e int, f int); +CREATE TABLE t6(f int); +CREATE VIEW v1 AS +SELECT e FROM t5 JOIN t6 ON t5.e=t6.f; +CREATE VIEW v2 AS +SELECT e FROM t5 NATURAL JOIN t6; +SELECT t1.a FROM t1 JOIN t2 ON a=b JOIN t3 ON a=c JOIN t4 USING(d); +a +SELECT t1.x FROM t1 JOIN t2 ON a=b JOIN t3 ON a=c JOIN t4 USING(d); +ERROR 42S22: Unknown column 't1.x' in 'field list' +SELECT t1.a FROM t1 JOIN t2 ON a=b JOIN t3 ON a=c NATURAL JOIN t4; +a +SELECT t1.x FROM t1 JOIN t2 ON a=b JOIN t3 ON a=c NATURAL JOIN t4; +ERROR 42S22: Unknown column 't1.x' in 'field list' +SELECT v1.e FROM v1 JOIN t2 ON e=b JOIN t3 ON e=c JOIN t4 USING(d); +e +SELECT v1.x FROM v1 JOIN t2 ON e=b JOIN t3 ON e=c JOIN t4 USING(d); +ERROR 42S22: Unknown column 'v1.x' in 'field list' +SELECT v2.e FROM v2 JOIN t2 ON e=b JOIN t3 ON e=c JOIN t4 USING(d); +e +SELECT v2.x FROM v2 JOIN t2 ON e=b JOIN t3 ON e=c JOIN t4 USING(d); +ERROR 42S22: Unknown column 'v2.x' in 'field list' +DROP VIEW v1, v2; +DROP TABLE t1, t2, t3, t4, t5, t6; +create table t1 (id1 int(11) not null); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t1 values (1),(2); +create table t2 (id2 int(11) not null); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t2 values (1),(2),(3),(4); +create table t3 (id3 char(16) not null); +insert into t3 values ('100'); +create table t4 (id2 int(11) not null, id3 char(16)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +create table t5 (id1 int(11) not null, key (id1)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t5 values (1),(2),(1); +create view v1 as +select t4.id3 from t4 join t2 on t4.id2 = t2.id2; +select t1.id1 from t1 inner join (t3 left join v1 on t3.id3 = v1.id3); +id1 +1 +2 +drop view v1; +drop table t1, t2, t3, t4, t5; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3); +create table t1(a int); +insert into t1 select A.a + 10*(B.a) from t0 A, t0 B; +create table t2 (a int, b int); +insert into t2 values (1,1), (2,2), (3,3); +create table t3(a int, b int, filler char(200), key(a)); +insert into t3 select a,a,'filler' from t1; +insert into t3 select a,a,'filler' from t1; +create table t4 like t3; +insert into t4 select * from t3; +insert into t4 select * from t3; +create table t5 like t4; +insert into t5 select * from t4; +insert into t5 select * from t4; +create table t6 like t5; +insert into t6 select * from t5; +insert into t6 select * from t5; +create table t7 like t6; +insert into t7 select * from t6; +insert into t7 select * from t6; +ANALYZE TABLE t1, t2, t3, t4, t5, t6, t7; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +test.t4 analyze status OK +test.t5 analyze status OK +test.t6 analyze status OK +test.t7 analyze status OK +explain select * from t4 join +t2 left join (t3 join t5 on t5.a=t3.b) on t3.a=t2.b where t4.a<=>t3.b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL X 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL X 100.00 NULL +2 SIMPLE t3 NULL ref a a 5 test.t2.b X 100.00 NULL +2 SIMPLE t5 NULL ref a a 5 test.t3.b X 100.00 NULL +2 SIMPLE t4 NULL ref a a 5 test.t3.b X 100.00 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t4`.`filler` AS `filler`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t3`.`filler` AS `filler`,`test`.`t5`.`a` AS `a`,`test`.`t5`.`b` AS `b`,`test`.`t5`.`filler` AS `filler` from `test`.`t4` join `test`.`t2` left join (`test`.`t3` join `test`.`t5`) on(((`test`.`t5`.`a` = `test`.`t3`.`b`) and (`test`.`t3`.`a` = `test`.`t2`.`b`))) where (`test`.`t4`.`a` <=> `test`.`t3`.`b`) +explain select * from (t4 join t6 on t6.a=t4.b) right join t3 on t4.a=t3.b +join t2 left join (t5 join t7 on t7.a=t5.b) on t5.a=t2.b where t3.a<=>t2.b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL X 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL X 100.00 NULL +2 SIMPLE t3 NULL ref a a 5 test.t2.b X 100.00 Using index condition +2 SIMPLE t4 NULL ref a a 5 test.t3.b X 100.00 NULL +2 SIMPLE t6 NULL ref a a 5 test.t4.b X 100.00 NULL +2 SIMPLE t5 NULL ref a a 5 test.t2.b X 100.00 NULL +2 SIMPLE t7 NULL ref a a 5 test.t5.b X 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t4`.`filler` AS `filler`,`test`.`t6`.`a` AS `a`,`test`.`t6`.`b` AS `b`,`test`.`t6`.`filler` AS `filler`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t3`.`filler` AS `filler`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t5`.`a` AS `a`,`test`.`t5`.`b` AS `b`,`test`.`t5`.`filler` AS `filler`,`test`.`t7`.`a` AS `a`,`test`.`t7`.`b` AS `b`,`test`.`t7`.`filler` AS `filler` from `test`.`t3` left join (`test`.`t4` join `test`.`t6`) on(((`test`.`t6`.`a` = `test`.`t4`.`b`) and (`test`.`t4`.`a` = `test`.`t3`.`b`))) join `test`.`t2` left join (`test`.`t5` join `test`.`t7`) on(((`test`.`t7`.`a` = `test`.`t5`.`b`) and (`test`.`t5`.`a` = `test`.`t2`.`b`))) where (`test`.`t3`.`a` <=> `test`.`t2`.`b`) +explain select * from t2 left join +(t3 left join (t4 join t6 on t6.a=t4.b) on t4.a=t3.b +join t5 on t5.a=t3.b) on t3.a=t2.b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL X 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL X 100.00 NULL +2 SIMPLE t3 NULL ref a a 5 test.t2.b X 100.00 NULL +2 SIMPLE t5 NULL ref a a 5 test.t3.b X 100.00 NULL +2 SIMPLE t4 NULL ref a a 5 test.t5.a X 100.00 Using where +2 SIMPLE t6 NULL ref a a 5 test.t4.b X 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t3`.`filler` AS `filler`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t4`.`filler` AS `filler`,`test`.`t6`.`a` AS `a`,`test`.`t6`.`b` AS `b`,`test`.`t6`.`filler` AS `filler`,`test`.`t5`.`a` AS `a`,`test`.`t5`.`b` AS `b`,`test`.`t5`.`filler` AS `filler` from `test`.`t2` left join (`test`.`t3` left join (`test`.`t4` join `test`.`t6`) on(((`test`.`t6`.`a` = `test`.`t4`.`b`) and (`test`.`t4`.`a` = `test`.`t3`.`b`))) join `test`.`t5`) on(((`test`.`t5`.`a` = `test`.`t3`.`b`) and (`test`.`t3`.`a` = `test`.`t2`.`b`))) where true +drop table t0, t1, t2, t3, t4, t5, t6, t7; +create table t1 (a int); +insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t2 (a int, filler char(100), key(a)); +insert into t2 select A.a + 10*B.a, '' from t1 A, t1 B; +create table t3 like t2; +insert into t3 select * from t2; +ANALYZE TABLE t1, t2, t3; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +explain select * from t1 left join +(t2 left join t3 on (t2.a = t3.a)) +on (t1.a = t2.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 100.00 NULL +2 SIMPLE t2 NULL ref a a 5 test.t1.a 1 100.00 NULL +2 SIMPLE t3 NULL ref a a 5 test.t1.a 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`filler` AS `filler`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`filler` AS `filler` from `test`.`t1` left join (`test`.`t2` left join `test`.`t3` on((`test`.`t3`.`a` = `test`.`t1`.`a`))) on((`test`.`t2`.`a` = `test`.`t1`.`a`)) where true +drop table t1, t2, t3; +CREATE TABLE t1 (id int NOT NULL PRIMARY KEY, type varchar(10)); +CREATE TABLE t2 (pid int NOT NULL PRIMARY KEY, type varchar(10)); +CREATE TABLE t3 (cid int NOT NULL PRIMARY KEY, +id int NOT NULL, +pid int NOT NULL); +INSERT INTO t1 VALUES (1, 'A'), (3, 'C'); +INSERT INTO t2 VALUES (1, 'A'), (3, 'C'); +INSERT INTO t3 VALUES (1, 1, 1), (3, 3, 3); +SELECT * FROM t1 p LEFT JOIN (t3 JOIN t1) +ON (t1.id=t3.id AND t1.type='B' AND p.id=t3.id) +LEFT JOIN t2 ON (t3.pid=t2.pid) +WHERE p.id=1; +id type cid id pid id type pid type +1 A NULL NULL NULL NULL NULL NULL NULL +CREATE VIEW v1 AS +SELECT t3.* FROM t3 JOIN t1 ON t1.id=t3.id AND t1.type='B'; +SELECT * FROM t1 p LEFT JOIN v1 ON p.id=v1.id +LEFT JOIN t2 ON v1.pid=t2.pid +WHERE p.id=1; +id type cid id pid pid type +1 A NULL NULL NULL NULL NULL +DROP VIEW v1; +DROP TABLE t1,t2,t3; +CREATE TABLE t1 (id1 int PRIMARY KEY, id2 int); +CREATE TABLE t2 (id1 int PRIMARY KEY, id2 int); +CREATE TABLE t3 (id1 int PRIMARY KEY, id2 int); +CREATE TABLE t4 (id1 int PRIMARY KEY, id2 int); +CREATE TABLE t5 (id1 int PRIMARY KEY, id2 int); +SELECT t1.id1 AS id, t5.id1 AS ngroupbynsa +FROM t1 INNER JOIN t2 ON t2.id2 = t1.id1 +LEFT OUTER JOIN +(t3 INNER JOIN t4 ON t4.id1 = t3.id2 INNER JOIN t5 ON t4.id2 = t5.id1) +ON t3.id2 IS NOT NULL +WHERE t1.id1=2; +id ngroupbynsa +PREPARE stmt FROM +"SELECT t1.id1 AS id, t5.id1 AS ngroupbynsa + FROM t1 INNER JOIN t2 ON t2.id2 = t1.id1 + LEFT OUTER JOIN + (t3 INNER JOIN t4 ON t4.id1 = t3.id2 INNER JOIN t5 ON t4.id2 = t5.id1) + ON t3.id2 IS NOT NULL + WHERE t1.id1=2"; +EXECUTE stmt; +id ngroupbynsa +EXECUTE stmt; +id ngroupbynsa +EXECUTE stmt; +id ngroupbynsa +EXECUTE stmt; +id ngroupbynsa +INSERT INTO t1 VALUES (1,1), (2,1), (3,2); +INSERT INTO t2 VALUES (2,1), (3,2), (4,3); +INSERT INTO t3 VALUES (1,1), (3,2), (2,NULL); +INSERT INTO t4 VALUES (1,1), (2,1), (3,3); +INSERT INTO t5 VALUES (1,1), (2,2), (3,3), (4,3); +EXECUTE stmt; +id ngroupbynsa +2 1 +2 1 +EXECUTE stmt; +id ngroupbynsa +2 1 +2 1 +EXECUTE stmt; +id ngroupbynsa +2 1 +2 1 +EXECUTE stmt; +id ngroupbynsa +2 1 +2 1 +SELECT t1.id1 AS id, t5.id1 AS ngroupbynsa +FROM t1 INNER JOIN t2 ON t2.id2 = t1.id1 +LEFT OUTER JOIN +(t3 INNER JOIN t4 ON t4.id1 = t3.id2 INNER JOIN t5 ON t4.id2 = t5.id1) +ON t3.id2 IS NOT NULL +WHERE t1.id1=2; +id ngroupbynsa +2 1 +2 1 +DROP TABLE t1,t2,t3,t4,t5; +CREATE TABLE t1 ( +id int NOT NULL PRIMARY KEY, +ct int DEFAULT NULL, +pc int DEFAULT NULL, +INDEX idx_ct (ct), +INDEX idx_pc (pc) +); +INSERT INTO t1 VALUES +(1,NULL,NULL),(2,NULL,NULL),(3,NULL,NULL),(4,NULL,NULL),(5,NULL,NULL); +CREATE TABLE t2 ( +id int NOT NULL PRIMARY KEY, +sr int NOT NULL, +nm varchar(255) NOT NULL, +INDEX idx_sr (sr) +); +INSERT INTO t2 VALUES +(2441905,4308,'LesAbymes'),(2441906,4308,'Anse-Bertrand'); +CREATE TABLE t3 ( +id int NOT NULL PRIMARY KEY, +ct int NOT NULL, +ln int NOT NULL, +INDEX idx_ct (ct), +INDEX idx_ln (ln) +); +CREATE TABLE t4 ( +id int NOT NULL PRIMARY KEY, +nm varchar(255) NOT NULL +); +INSERT INTO t4 VALUES (4308,'Guadeloupe'),(4309,'Martinique'); +SELECT t1.* +FROM t1 LEFT JOIN +(t2 LEFT JOIN t3 ON t3.ct=t2.id AND t3.ln='5') ON t1.ct=t2.id +WHERE t1.id='5'; +id ct pc +5 NULL NULL +SELECT t1.*, t4.nm +FROM t1 LEFT JOIN +(t2 LEFT JOIN t3 ON t3.ct=t2.id AND t3.ln='5') ON t1.ct=t2.id +LEFT JOIN t4 ON t2.sr=t4.id +WHERE t1.id='5'; +id ct pc nm +5 NULL NULL NULL +DROP TABLE t1,t2,t3,t4; +CREATE TABLE t1 (a INT, b INT); +CREATE TABLE t2 (a INT); +CREATE TABLE t3 (a INT, c INT); +CREATE TABLE t4 (a INT, c INT); +CREATE TABLE t5 (a INT, c INT); +SELECT b FROM t1 JOIN (t2 LEFT JOIN t3 USING (a) LEFT JOIN t4 USING (a) +LEFT JOIN t5 USING (a)) USING (a); +b +SELECT c FROM t1 JOIN (t2 LEFT JOIN t3 USING (a) LEFT JOIN t4 USING (a) +LEFT JOIN t5 USING (a)) USING (a); +ERROR 23000: Column 'c' in field list is ambiguous +SELECT b FROM t1 JOIN (t2 JOIN t3 USING (a) JOIN t4 USING (a) +JOIN t5 USING (a)) USING (a); +b +SELECT c FROM t1 JOIN (t2 JOIN t3 USING (a) JOIN t4 USING (a) +JOIN t5 USING (a)) USING (a); +ERROR 23000: Column 'c' in field list is ambiguous +DROP TABLE t1,t2,t3,t4,t5; +CREATE TABLE t1 (a INT, b INT); +CREATE TABLE t2 (a INT, b INT); +CREATE TABLE t3 (a INT, b INT); +INSERT INTO t1 VALUES (1,1); +INSERT INTO t2 VALUES (1,1); +INSERT INTO t3 VALUES (1,1); +SELECT * FROM t1 JOIN (t2 JOIN t3 USING (b)) USING (a); +ERROR 23000: Column 'a' in from clause is ambiguous +DROP TABLE t1,t2,t3; +CREATE TABLE t1 ( +carrier char(2) default NULL, +id int NOT NULL auto_increment PRIMARY KEY +) CHARSET utf8mb4; +INSERT INTO t1 VALUES +('CO',235371754),('CO',235376554),('CO',235376884),('CO',235377874), +('CO',231060394),('CO',231059224),('CO',231059314),('CO',231060484), +('CO',231060274),('CO',231060124),('CO',231060244),('CO',231058594), +('CO',231058924),('CO',231058504),('CO',231059344),('CO',231060424), +('CO',231059554),('CO',231060304),('CO',231059644),('CO',231059464), +('CO',231059764),('CO',231058294),('CO',231058624),('CO',231058864), +('CO',231059374),('CO',231059584),('CO',231059734),('CO',231059014), +('CO',231059854),('CO',231059494),('CO',231059794),('CO',231058534), +('CO',231058324),('CO',231058684),('CO',231059524),('CO',231059974); +CREATE TABLE t2 ( +scan_date date default NULL, +package_id int default NULL, +INDEX scan_date(scan_date), +INDEX package_id(package_id) +); +INSERT INTO t2 VALUES +('2008-12-29',231062944),('2008-12-29',231065764),('2008-12-29',231066124), +('2008-12-29',231060094),('2008-12-29',231061054),('2008-12-29',231065644), +('2008-12-29',231064384),('2008-12-29',231064444),('2008-12-29',231073774), +('2008-12-29',231058594),('2008-12-29',231059374),('2008-12-29',231066004), +('2008-12-29',231068494),('2008-12-29',231070174),('2008-12-29',231071884), +('2008-12-29',231063274),('2008-12-29',231063754),('2008-12-29',231064144), +('2008-12-29',231069424),('2008-12-29',231073714),('2008-12-29',231058414), +('2008-12-29',231060994),('2008-12-29',231069154),('2008-12-29',231068614), +('2008-12-29',231071464),('2008-12-29',231074014),('2008-12-29',231059614), +('2008-12-29',231059074),('2008-12-29',231059464),('2008-12-29',231069094), +('2008-12-29',231067294),('2008-12-29',231070144),('2008-12-29',231073804), +('2008-12-29',231072634),('2008-12-29',231058294),('2008-12-29',231065344), +('2008-12-29',231066094),('2008-12-29',231069034),('2008-12-29',231058594), +('2008-12-29',231059854),('2008-12-29',231059884),('2008-12-29',231059914), +('2008-12-29',231063664),('2008-12-29',231063814),('2008-12-29',231063904); +CREATE TABLE t3 ( +package_id int default NULL, +INDEX package_id(package_id) +); +INSERT INTO t3 VALUES +(231058294),(231058324),(231058354),(231058384),(231058414),(231058444), +(231058474),(231058504),(231058534),(231058564),(231058594),(231058624), +(231058684),(231058744),(231058804),(231058864),(231058924),(231058954), +(231059014),(231059074),(231059104),(231059134),(231059164),(231059194), +(231059224),(231059254),(231059284),(231059314),(231059344),(231059374), +(231059404),(231059434),(231059464),(231059494),(231059524),(231059554), +(231059584),(231059614),(231059644),(231059674),(231059704),(231059734), +(231059764),(231059794),(231059824),(231059854),(231059884),(231059914), +(231059944),(231059974),(231060004),(231060034),(231060064),(231060094), +(231060124),(231060154),(231060184),(231060214),(231060244),(231060274), +(231060304),(231060334),(231060364),(231060394),(231060424),(231060454), +(231060484),(231060514),(231060544),(231060574),(231060604),(231060634), +(231060664),(231060694),(231060724),(231060754),(231060784),(231060814), +(231060844),(231060874),(231060904),(231060934),(231060964),(231060994), +(231061024),(231061054),(231061084),(231061144),(231061174),(231061204), +(231061234),(231061294),(231061354),(231061384),(231061414),(231061474), +(231061564),(231061594),(231061624),(231061684),(231061714),(231061774), +(231061804),(231061894),(231061984),(231062074),(231062134),(231062224), +(231062254),(231062314),(231062374),(231062434),(231062494),(231062554), +(231062584),(231062614),(231062644),(231062704),(231062734),(231062794), +(231062854),(231062884),(231062944),(231063004),(231063034),(231063064), +(231063124),(231063154),(231063184),(231063214),(231063274),(231063334), +(231063394),(231063424),(231063454),(231063514),(231063574),(231063664); +CREATE TABLE t4 ( +carrier char(2) NOT NULL default '' PRIMARY KEY, +id int(11) default NULL, +INDEX id(id) +) CHARSET utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t4 VALUES +('99',6),('SK',456),('UA',486),('AI',1081),('OS',1111),('VS',1510); +CREATE TABLE t5 ( +carrier_id int default NULL, +INDEX carrier_id(carrier_id) +); +INSERT INTO t5 VALUES +(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6), +(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6), +(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6), +(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6), +(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6), +(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(456),(456),(456), +(456),(456),(456),(456),(456),(456),(456),(456),(456),(456),(456),(456), +(456),(486),(1081),(1111),(1111),(1111),(1111),(1510); +ANALYZE TABLE t1, t2, t3, t4, t5; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +test.t4 analyze status OK +test.t5 analyze status OK +SELECT COUNT(*) +FROM((t2 JOIN t1 ON t2.package_id = t1.id) +JOIN t3 ON t3.package_id = t1.id); +COUNT(*) +6 +EXPLAIN +SELECT COUNT(*) +FROM ((t2 JOIN t1 ON t2.package_id = t1.id) +JOIN t3 ON t3.package_id = t1.id) +LEFT JOIN +(t5 JOIN t4 ON t5.carrier_id = t4.id) +ON t4.carrier = t1.carrier; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 45 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL index package_id package_id 5 NULL 45 100.00 Using where; Using index +2 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.package_id 1 100.00 NULL +2 SIMPLE t4 NULL eq_ref PRIMARY,id PRIMARY 8 test.t1.carrier 1 100.00 NULL +2 SIMPLE t5 NULL ref carrier_id carrier_id 5 test.t4.id 22 100.00 Using index +2 SIMPLE t3 NULL ref package_id package_id 5 test.t2.package_id 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t2` join `test`.`t1` join `test`.`t3` left join (`test`.`t5` join `test`.`t4`) on(((`test`.`t5`.`carrier_id` = `test`.`t4`.`id`) and (`test`.`t4`.`carrier` = `test`.`t1`.`carrier`))) where ((`test`.`t1`.`id` = `test`.`t2`.`package_id`) and (`test`.`t3`.`package_id` = `test`.`t2`.`package_id`)) +SELECT COUNT(*) +FROM ((t2 JOIN t1 ON t2.package_id = t1.id) +JOIN t3 ON t3.package_id = t1.id) +LEFT JOIN +(t5 JOIN t4 ON t5.carrier_id = t4.id) +ON t4.carrier = t1.carrier; +COUNT(*) +6 +DROP TABLE t1,t2,t3,t4,t5; +End of 5.0 tests +# +# Bug#24909223: EXCESSIVE MEMORY USAGE BY QUERY +# +CREATE TABLE t ( +a INT, +b CHAR(255), +c CHAR(255), +d INT, +e INT, +PRIMARY KEY (e), +KEY (d) +) ENGINE=InnoDB; +INSERT INTO t VALUES +(1, '14effca2', 'cffa3819', 98927, 8767), +(1, '2f7cbd33', '421aff88', 87613, 70956), +(1, '5c44507d', '05fd27d3', 36002, 5146), +(1, '6542ee43', 'c09ee30f', 3673, 91467), +(1, '786737dd', '6ac95ccb', 46890, 62953), +(1, '8929d195', '64102e63', 50531, 9712), +(1, '8cc0c106', '17283316', 16399, 26119), +(1, '8f3063de', 'ce5d0f35', 21769, 76667), +(1, 'c32c9202', 'c9525fe8', 12704, 43998), +(1, 'c5567e1c', 'bc2e97e6', 85805, 84174), +(1, 'c7acb4d4', '6d67fea7', 58347, 51235), +(1, 'dbd66341', '03b59a03', 46577, 52495), +(1, 'f8e0354e', '41a6e523', 36055, 32646), +(1, 'fb66b513', '10f3de43', 41297, 74334), +(1, 'ffec6d1b', '2fca4073', 12896, 95807), +(1, 'aa3fcff8', 'f4981ed8', 99211, 18778); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +EXPLAIN SELECT a.c AS c FROM ( +SELECT a.c AS c FROM ( +SELECT a.a AS c FROM t AS a +INNER JOIN t AS b ON a.b > b.b +) AS a +INNER JOIN t AS b ON a.c >= b.a +) AS a +INNER JOIN t AS b ON a.c >= b.d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 16 100.00 Parallel execute (1 workers) +2 SIMPLE a NULL ALL NULL NULL NULL NULL 16 100.00 NULL +2 SIMPLE b NULL ALL NULL NULL NULL NULL 16 33.33 Using where; Using join buffer (hash join) +2 SIMPLE b NULL ALL NULL NULL NULL NULL 16 33.33 Using where; Using join buffer (hash join) +2 SIMPLE b NULL ALL d NULL NULL NULL 16 33.33 Range checked for each record (index map: 0x2) +Warnings: +Note 1003 /* select#1 */ select `test`.`a`.`a` AS `c` from `test`.`t` `a` join `test`.`t` `b` join `test`.`t` `b` join `test`.`t` `b` where ((`test`.`a`.`a` >= `test`.`b`.`d`) and (`test`.`a`.`a` >= `test`.`b`.`a`) and (`test`.`a`.`b` > `test`.`b`.`b`)) +TRUNCATE TABLE performance_schema.memory_summary_by_thread_by_event_name; +SELECT a.c AS c FROM ( +SELECT a.c AS c FROM ( +SELECT a.a AS c FROM t AS a +INNER JOIN t AS b ON a.b > b.b +) AS a +INNER JOIN t AS b ON a.c >= b.a +) AS a +INNER JOIN t AS b ON a.c >= b.d; +c +SELECT * FROM performance_schema.memory_summary_by_thread_by_event_name +WHERE event_name = 'memory/sql/thd::main_mem_root' +AND thread_id = ps_thread_id(connection_id()) +AND sum_number_of_bytes_alloc > 1000000 +DROP TABLE t; diff --git a/mysql-test/r/join_nested_bka.result-pq b/mysql-test/r/join_nested_bka.result-pq new file mode 100644 index 000000000000..b671bf1d803f --- /dev/null +++ b/mysql-test/r/join_nested_bka.result-pq @@ -0,0 +1,2777 @@ +set optimizer_switch='batched_key_access=on,mrr_cost_based=off'; +DROP TABLE IF EXISTS t0,t1,t2,t3,t4,t5,t6,t7,t8,t9; +CREATE TABLE t0 (a int, b int, c int); +CREATE TABLE t1 (a int, b int, c int); +CREATE TABLE t2 (a int, b int, c int); +CREATE TABLE t3 (a int, b int, c int); +CREATE TABLE t4 (a int, b int, c int); +CREATE TABLE t5 (a int, b int, c int); +CREATE TABLE t6 (a int, b int, c int); +CREATE TABLE t7 (a int, b int, c int); +CREATE TABLE t8 (a int, b int, c int); +CREATE TABLE t9 (a int, b int, c int); +INSERT INTO t0 VALUES (1,1,0), (1,2,0), (2,2,0); +INSERT INTO t1 VALUES (1,3,0), (2,2,0), (3,2,0); +INSERT INTO t2 VALUES (3,3,0), (4,2,0), (5,3,0); +INSERT INTO t3 VALUES (1,2,0), (2,2,0); +INSERT INTO t4 VALUES (3,2,0), (4,2,0); +INSERT INTO t5 VALUES (3,1,0), (2,2,0), (3,3,0); +INSERT INTO t6 VALUES (3,2,0), (6,2,0), (6,1,0); +INSERT INTO t7 VALUES (1,1,0), (2,2,0); +INSERT INTO t8 VALUES (0,2,0), (1,2,0); +INSERT INTO t9 VALUES (1,1,0), (1,2,0), (3,3,0); +CREATE TABLE t34 (a3 int, b3 int, c3 int, a4 int, b4 int, c4 int); +INSERT INTO t34 +SELECT t3.*, t4.* +FROM t3 CROSS JOIN t4; +CREATE TABLE t345 (a3 int, b3 int, c3 int, a4 int, b4 int, c4 int, +a5 int, b5 int, c5 int); +INSERT INTO t345 +SELECT t3.*, t4.*, t5.* +FROM t3 CROSS JOIN t4 CROSS JOIN t5; +CREATE TABLE t67 (a6 int, b6 int, c6 int, a7 int, b7 int, c7 int); +INSERT INTO t67 +SELECT t6.*, t7.* +FROM t6 CROSS JOIN t7; +SELECT t2.a,t2.b +FROM t2; +a b +3 3 +4 2 +5 3 +SELECT t3.a,t3.b +FROM t3; +a b +1 2 +2 2 +SELECT t4.a,t4.b +FROM t4; +a b +3 2 +4 2 +SELECT t3.a,t3.b,t4.a,t4.b +FROM t3,t4; +a b a b +1 2 3 2 +1 2 4 2 +2 2 3 2 +2 2 4 2 +SELECT t2.a,t2.b,t3.a,t3.b,t4.a,t4.b +FROM t2 +LEFT JOIN +(t3, t4) +ON t2.b=t4.b; +a b a b a b +3 3 NULL NULL NULL NULL +4 2 1 2 3 2 +4 2 1 2 4 2 +4 2 2 2 3 2 +4 2 2 2 4 2 +5 3 NULL NULL NULL NULL +"Standard compliant copy of above query" +SELECT t2.a,t2.b,t34.a3,t34.b3,t34.a4,t34.b4 +FROM t2 +LEFT JOIN t34 +ON t2.b=t34.b4; +a b a3 b3 a4 b4 +3 3 NULL NULL NULL NULL +4 2 1 2 3 2 +4 2 1 2 4 2 +4 2 2 2 3 2 +4 2 2 2 4 2 +5 3 NULL NULL NULL NULL +SELECT t2.a,t2.b,t3.a,t3.b,t4.a,t4.b +FROM t2 +LEFT JOIN +(t3, t4) +ON t3.a=1 AND t2.b=t4.b; +a b a b a b +3 3 NULL NULL NULL NULL +4 2 1 2 3 2 +4 2 1 2 4 2 +5 3 NULL NULL NULL NULL +"Standard compliant copy of above query" +SELECT t2.a,t2.b,t34.a3,t34.b3,t34.a4,t34.b4 +FROM t2 +LEFT JOIN t34 +ON t34.a3=1 AND t2.b=t34.b4; +a b a3 b3 a4 b4 +3 3 NULL NULL NULL NULL +4 2 1 2 3 2 +4 2 1 2 4 2 +5 3 NULL NULL NULL NULL +ANALYZE TABLE t1, t2, t3, t4; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +test.t4 analyze status OK +EXPLAIN +SELECT t2.a,t2.b,t3.a,t3.b,t4.a,t4.b +FROM t2 +LEFT JOIN +(t3, t4) +ON t2.b=t4.b +WHERE t3.a=1 OR t3.c IS NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 75.00 Using where; Using join buffer (hash join) +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b` from `test`.`t2` left join (`test`.`t3` join `test`.`t4`) on((`test`.`t4`.`b` = `test`.`t2`.`b`)) where ((`test`.`t3`.`a` = 1) or (`test`.`t3`.`c` is null)) +SELECT t2.a,t2.b,t3.a,t3.b,t4.a,t4.b +FROM t2 +LEFT JOIN +(t3, t4) +ON t2.b=t4.b +WHERE t3.a=1 OR t3.c IS NULL; +a b a b a b +3 3 NULL NULL NULL NULL +4 2 1 2 3 2 +4 2 1 2 4 2 +5 3 NULL NULL NULL NULL +"Standard compliant copy of above query" +SELECT t2.a,t2.b,t34.a3,t34.b3,t34.a4,t34.b4 +FROM t2 +LEFT JOIN t34 +ON t2.b=t34.b4 +WHERE t34.a3=1 OR t34.c3 IS NULL; +a b a3 b3 a4 b4 +3 3 NULL NULL NULL NULL +4 2 1 2 3 2 +4 2 1 2 4 2 +5 3 NULL NULL NULL NULL +SELECT t2.a,t2.b,t3.a,t3.b,t4.a,t4.b +FROM t2 +LEFT JOIN +(t3, t4) +ON t2.b=t4.b +WHERE t3.a>1 OR t3.c IS NULL; +a b a b a b +3 3 NULL NULL NULL NULL +4 2 2 2 3 2 +4 2 2 2 4 2 +5 3 NULL NULL NULL NULL +"Standard compliant copy of above query" +SELECT t2.a,t2.b,t34.a3,t34.b3,t34.a4,t34.b4 +FROM t2 +LEFT JOIN t34 +ON t2.b=t34.b4 +WHERE t34.a3>1 OR t34.c3 IS NULL; +a b a3 b3 a4 b4 +3 3 NULL NULL NULL NULL +4 2 2 2 3 2 +4 2 2 2 4 2 +5 3 NULL NULL NULL NULL +SELECT t5.a,t5.b +FROM t5; +a b +3 1 +2 2 +3 3 +SELECT t3.a,t3.b,t4.a,t4.b,t5.a,t5.b +FROM t3,t4,t5; +a b a b a b +1 2 3 2 2 2 +1 2 3 2 3 1 +1 2 3 2 3 3 +1 2 4 2 2 2 +1 2 4 2 3 1 +1 2 4 2 3 3 +2 2 3 2 2 2 +2 2 3 2 3 1 +2 2 3 2 3 3 +2 2 4 2 2 2 +2 2 4 2 3 1 +2 2 4 2 3 3 +SELECT t2.a,t2.b,t3.a,t3.b,t4.a,t4.b,t5.a,t5.b +FROM t2 +LEFT JOIN +(t3, t4, t5) +ON t2.b=t4.b; +a b a b a b a b +3 3 NULL NULL NULL NULL NULL NULL +4 2 1 2 3 2 2 2 +4 2 1 2 3 2 3 1 +4 2 1 2 3 2 3 3 +4 2 1 2 4 2 2 2 +4 2 1 2 4 2 3 1 +4 2 1 2 4 2 3 3 +4 2 2 2 3 2 2 2 +4 2 2 2 3 2 3 1 +4 2 2 2 3 2 3 3 +4 2 2 2 4 2 2 2 +4 2 2 2 4 2 3 1 +4 2 2 2 4 2 3 3 +5 3 NULL NULL NULL NULL NULL NULL +"Standard compliant copy of above query" +SELECT t2.a,t2.b,t345.a3,t345.b3,t345.a4,t345.b4,t345.a5,t345.b5 +FROM t2 +LEFT JOIN t345 +ON t2.b=t345.b4; +a b a3 b3 a4 b4 a5 b5 +3 3 NULL NULL NULL NULL NULL NULL +4 2 1 2 3 2 2 2 +4 2 1 2 3 2 3 1 +4 2 1 2 3 2 3 3 +4 2 1 2 4 2 2 2 +4 2 1 2 4 2 3 1 +4 2 1 2 4 2 3 3 +4 2 2 2 3 2 2 2 +4 2 2 2 3 2 3 1 +4 2 2 2 3 2 3 3 +4 2 2 2 4 2 2 2 +4 2 2 2 4 2 3 1 +4 2 2 2 4 2 3 3 +5 3 NULL NULL NULL NULL NULL NULL +ANALYZE TABLE t2, t3, t4, t5; +Table Op Msg_type Msg_text +test.t2 analyze status OK +test.t3 analyze status OK +test.t4 analyze status OK +test.t5 analyze status OK +EXPLAIN +SELECT t2.a,t2.b,t3.a,t3.b,t4.a,t4.b,t5.a,t5.b +FROM t2 +LEFT JOIN +(t3, t4, t5) +ON t2.b=t4.b +WHERE t3.a>1 OR t3.c IS NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 75.00 Using where; Using join buffer (hash join) +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t5 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t5`.`a` AS `a`,`test`.`t5`.`b` AS `b` from `test`.`t2` left join (`test`.`t3` join `test`.`t4` join `test`.`t5`) on((`test`.`t4`.`b` = `test`.`t2`.`b`)) where ((`test`.`t3`.`a` > 1) or (`test`.`t3`.`c` is null)) +SELECT t2.a,t2.b,t3.a,t3.b,t4.a,t4.b,t5.a,t5.b +FROM t2 +LEFT JOIN +(t3, t4, t5) +ON t2.b=t4.b +WHERE t3.a>1 OR t3.c IS NULL; +a b a b a b a b +3 3 NULL NULL NULL NULL NULL NULL +4 2 2 2 3 2 2 2 +4 2 2 2 3 2 3 1 +4 2 2 2 3 2 3 3 +4 2 2 2 4 2 2 2 +4 2 2 2 4 2 3 1 +4 2 2 2 4 2 3 3 +5 3 NULL NULL NULL NULL NULL NULL +"Standard compliant copy of above query" +SELECT t2.a,t2.b,t345.a3,t345.b3,t345.a4,t345.b4,t345.a5,t345.b5 +FROM t2 +LEFT JOIN t345 +ON t2.b=t345.b4 +WHERE t345.a3>1 OR t345.c3 IS NULL; +a b a3 b3 a4 b4 a5 b5 +3 3 NULL NULL NULL NULL NULL NULL +4 2 2 2 3 2 2 2 +4 2 2 2 3 2 3 1 +4 2 2 2 3 2 3 3 +4 2 2 2 4 2 2 2 +4 2 2 2 4 2 3 1 +4 2 2 2 4 2 3 3 +5 3 NULL NULL NULL NULL NULL NULL +ANALYZE TABLE t2, t3, t4, t5; +Table Op Msg_type Msg_text +test.t2 analyze status OK +test.t3 analyze status OK +test.t4 analyze status OK +test.t5 analyze status OK +EXPLAIN +SELECT t2.a,t2.b,t3.a,t3.b,t4.a,t4.b,t5.a,t5.b +FROM t2 +LEFT JOIN +(t3, t4, t5) +ON t2.b=t4.b +WHERE (t3.a>1 OR t3.c IS NULL) AND +(t5.a<3 OR t5.c IS NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 75.00 Using where; Using join buffer (hash join) +2 SIMPLE t5 NULL ALL NULL NULL NULL NULL 3 55.56 Using where; Using join buffer (hash join) +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t5`.`a` AS `a`,`test`.`t5`.`b` AS `b` from `test`.`t2` left join (`test`.`t3` join `test`.`t4` join `test`.`t5`) on((`test`.`t4`.`b` = `test`.`t2`.`b`)) where (((`test`.`t3`.`a` > 1) or (`test`.`t3`.`c` is null)) and ((`test`.`t5`.`a` < 3) or (`test`.`t5`.`c` is null))) +SELECT t2.a,t2.b,t3.a,t3.b,t4.a,t4.b,t5.a,t5.b +FROM t2 +LEFT JOIN +(t3, t4, t5) +ON t2.b=t4.b +WHERE (t3.a>1 OR t3.c IS NULL) AND +(t5.a<3 OR t5.c IS NULL); +a b a b a b a b +3 3 NULL NULL NULL NULL NULL NULL +4 2 2 2 3 2 2 2 +4 2 2 2 4 2 2 2 +5 3 NULL NULL NULL NULL NULL NULL +"Standard compliant copy of above query" +SELECT t2.a,t2.b,t345.a3,t345.b3,t345.a4,t345.b4,t345.a5,t345.b5 +FROM t2 +LEFT JOIN t345 +ON t2.b=t345.b4 +WHERE (t345.a3>1 OR t345.c3 IS NULL) AND +(t345.a5<3 OR t345.c5 IS NULL); +a b a3 b3 a4 b4 a5 b5 +3 3 NULL NULL NULL NULL NULL NULL +4 2 2 2 3 2 2 2 +4 2 2 2 4 2 2 2 +5 3 NULL NULL NULL NULL NULL NULL +SELECT t6.a,t6.b +FROM t6; +a b +3 2 +6 2 +6 1 +SELECT t7.a,t7.b +FROM t7; +a b +1 1 +2 2 +SELECT t6.a,t6.b,t7.a,t7.b +FROM t6,t7; +a b a b +3 2 1 1 +3 2 2 2 +6 1 1 1 +6 1 2 2 +6 2 1 1 +6 2 2 2 +SELECT t8.a,t8.b +FROM t8; +a b +0 2 +1 2 +ANALYZE TABLE t6, t7, t8; +Table Op Msg_type Msg_text +test.t6 analyze status OK +test.t7 analyze status OK +test.t8 analyze status OK +EXPLAIN +SELECT t6.a,t6.b,t7.a,t7.b,t8.a,t8.b +FROM (t6, t7) +LEFT JOIN +t8 +ON t7.b=t8.b AND t6.b < 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t7 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 SIMPLE t6 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 SIMPLE t8 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t6`.`a` AS `a`,`test`.`t6`.`b` AS `b`,`test`.`t7`.`a` AS `a`,`test`.`t7`.`b` AS `b`,`test`.`t8`.`a` AS `a`,`test`.`t8`.`b` AS `b` from `test`.`t6` join `test`.`t7` left join `test`.`t8` on(((`test`.`t8`.`b` = `test`.`t7`.`b`) and (`test`.`t6`.`b` < 10))) where true +SELECT t6.a,t6.b,t7.a,t7.b,t8.a,t8.b +FROM (t6, t7) +LEFT JOIN +t8 +ON t7.b=t8.b AND t6.b < 10; +a b a b a b +3 2 1 1 NULL NULL +3 2 2 2 0 2 +3 2 2 2 1 2 +6 1 1 1 NULL NULL +6 1 2 2 0 2 +6 1 2 2 1 2 +6 2 1 1 NULL NULL +6 2 2 2 0 2 +6 2 2 2 1 2 +"Standard compliant copy of above query" +SELECT t67.a6,t67.b6,t67.a7,t67.b7,t8.a,t8.b +FROM t67 +LEFT JOIN +t8 +ON t67.b7=t8.b AND t67.b6 < 10; +a6 b6 a7 b7 a b +3 2 1 1 NULL NULL +3 2 2 2 0 2 +3 2 2 2 1 2 +6 1 1 1 NULL NULL +6 1 2 2 0 2 +6 1 2 2 1 2 +6 2 1 1 NULL NULL +6 2 2 2 0 2 +6 2 2 2 1 2 +SELECT t5.a,t5.b +FROM t5; +a b +3 1 +2 2 +3 3 +SELECT t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b +FROM t5 +LEFT JOIN +( +(t6, t7) +LEFT JOIN +t8 +ON t7.b=t8.b AND t6.b < 10 +) +ON t6.b >= 2 AND t5.b=t7.b; +a b a b a b a b +2 2 3 2 2 2 0 2 +2 2 3 2 2 2 1 2 +2 2 6 2 2 2 0 2 +2 2 6 2 2 2 1 2 +3 1 3 2 1 1 NULL NULL +3 1 6 2 1 1 NULL NULL +3 3 NULL NULL NULL NULL NULL NULL +"Standard compliant copy of above query" +SELECT t5.a,t5.b,t67.a6,t67.b6,t67.a7,t67.b7,t8.a,t8.b +FROM t5 +LEFT JOIN +( +t67 +LEFT JOIN +t8 +ON t67.b7=t8.b AND t67.b6 < 10 +) +ON t67.b6 >= 2 AND t5.b=t67.b7; +a b a6 b6 a7 b7 a b +2 2 3 2 2 2 0 2 +2 2 3 2 2 2 1 2 +2 2 6 2 2 2 0 2 +2 2 6 2 2 2 1 2 +3 1 3 2 1 1 NULL NULL +3 1 6 2 1 1 NULL NULL +3 3 NULL NULL NULL NULL NULL NULL +SELECT t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b +FROM t5 +LEFT JOIN +( +(t6, t7) +LEFT JOIN +t8 +ON t7.b=t8.b AND t6.b < 10 +) +ON t6.b >= 2 AND t5.b=t7.b AND +(t8.a < 1 OR t8.c IS NULL); +a b a b a b a b +2 2 3 2 2 2 0 2 +2 2 6 2 2 2 0 2 +3 1 3 2 1 1 NULL NULL +3 1 6 2 1 1 NULL NULL +3 3 NULL NULL NULL NULL NULL NULL +"Standard compliant copy of above query" +SELECT t5.a,t5.b,t67.a6,t67.b6,t67.a7,t67.b7,t8.a,t8.b +FROM t5 +LEFT JOIN +( +t67 +LEFT JOIN +t8 +ON t67.b7=t8.b AND t67.b6 < 10 +) +ON t67.b6 >= 2 AND t5.b=t67.b7 AND +(t8.a < 1 OR t8.c IS NULL); +a b a6 b6 a7 b7 a b +2 2 3 2 2 2 0 2 +2 2 6 2 2 2 0 2 +3 1 3 2 1 1 NULL NULL +3 1 6 2 1 1 NULL NULL +3 3 NULL NULL NULL NULL NULL NULL +SELECT t2.a,t2.b,t3.a,t3.b,t4.a,t4.b +FROM t2 +LEFT JOIN +(t3, t4) +ON t3.a=1 AND t2.b=t4.b; +a b a b a b +3 3 NULL NULL NULL NULL +4 2 1 2 3 2 +4 2 1 2 4 2 +5 3 NULL NULL NULL NULL +"Standard compliant copy of above query" +SELECT t2.a,t2.b,t34.a3,t34.b3,t34.a4,t34.b4 +FROM t2 +LEFT JOIN t34 +ON t34.a3=1 AND t2.b=t34.b4; +a b a3 b3 a4 b4 +3 3 NULL NULL NULL NULL +4 2 1 2 3 2 +4 2 1 2 4 2 +5 3 NULL NULL NULL NULL +SELECT t2.a,t2.b,t3.a,t3.b,t4.a,t4.b, +t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b +FROM t2 +LEFT JOIN +(t3, t4) +ON t3.a=1 AND t2.b=t4.b, +t5 +LEFT JOIN +( +(t6, t7) +LEFT JOIN +t8 +ON t7.b=t8.b AND t6.b < 10 +) +ON t6.b >= 2 AND t5.b=t7.b; +a b a b a b a b a b a b a b +3 3 NULL NULL NULL NULL 2 2 3 2 2 2 0 2 +3 3 NULL NULL NULL NULL 2 2 3 2 2 2 1 2 +3 3 NULL NULL NULL NULL 2 2 6 2 2 2 0 2 +3 3 NULL NULL NULL NULL 2 2 6 2 2 2 1 2 +3 3 NULL NULL NULL NULL 3 1 3 2 1 1 NULL NULL +3 3 NULL NULL NULL NULL 3 1 6 2 1 1 NULL NULL +3 3 NULL NULL NULL NULL 3 3 NULL NULL NULL NULL NULL NULL +4 2 1 2 3 2 2 2 3 2 2 2 0 2 +4 2 1 2 3 2 2 2 3 2 2 2 1 2 +4 2 1 2 3 2 2 2 6 2 2 2 0 2 +4 2 1 2 3 2 2 2 6 2 2 2 1 2 +4 2 1 2 3 2 3 1 3 2 1 1 NULL NULL +4 2 1 2 3 2 3 1 6 2 1 1 NULL NULL +4 2 1 2 3 2 3 3 NULL NULL NULL NULL NULL NULL +4 2 1 2 4 2 2 2 3 2 2 2 0 2 +4 2 1 2 4 2 2 2 3 2 2 2 1 2 +4 2 1 2 4 2 2 2 6 2 2 2 0 2 +4 2 1 2 4 2 2 2 6 2 2 2 1 2 +4 2 1 2 4 2 3 1 3 2 1 1 NULL NULL +4 2 1 2 4 2 3 1 6 2 1 1 NULL NULL +4 2 1 2 4 2 3 3 NULL NULL NULL NULL NULL NULL +5 3 NULL NULL NULL NULL 2 2 3 2 2 2 0 2 +5 3 NULL NULL NULL NULL 2 2 3 2 2 2 1 2 +5 3 NULL NULL NULL NULL 2 2 6 2 2 2 0 2 +5 3 NULL NULL NULL NULL 2 2 6 2 2 2 1 2 +5 3 NULL NULL NULL NULL 3 1 3 2 1 1 NULL NULL +5 3 NULL NULL NULL NULL 3 1 6 2 1 1 NULL NULL +5 3 NULL NULL NULL NULL 3 3 NULL NULL NULL NULL NULL NULL +"Standard compliant copy of above query" +SELECT t2.a,t2.b,t34.a3,t34.b3,t34.a4,t34.b4, +t5.a,t5.b,t67.a6,t67.b6,t67.a7,t67.b7,t8.a,t8.b +FROM t2 +LEFT JOIN t34 +ON t34.a3=1 AND t2.b=t34.b4 +CROSS JOIN t5 +LEFT JOIN +( +t67 +LEFT JOIN +t8 +ON t67.b7=t8.b AND t67.b6 < 10 +) +ON t67.b6 >= 2 AND t5.b=t67.b7; +a b a3 b3 a4 b4 a b a6 b6 a7 b7 a b +3 3 NULL NULL NULL NULL 2 2 3 2 2 2 0 2 +3 3 NULL NULL NULL NULL 2 2 3 2 2 2 1 2 +3 3 NULL NULL NULL NULL 2 2 6 2 2 2 0 2 +3 3 NULL NULL NULL NULL 2 2 6 2 2 2 1 2 +3 3 NULL NULL NULL NULL 3 1 3 2 1 1 NULL NULL +3 3 NULL NULL NULL NULL 3 1 6 2 1 1 NULL NULL +3 3 NULL NULL NULL NULL 3 3 NULL NULL NULL NULL NULL NULL +4 2 1 2 3 2 2 2 3 2 2 2 0 2 +4 2 1 2 3 2 2 2 3 2 2 2 1 2 +4 2 1 2 3 2 2 2 6 2 2 2 0 2 +4 2 1 2 3 2 2 2 6 2 2 2 1 2 +4 2 1 2 3 2 3 1 3 2 1 1 NULL NULL +4 2 1 2 3 2 3 1 6 2 1 1 NULL NULL +4 2 1 2 3 2 3 3 NULL NULL NULL NULL NULL NULL +4 2 1 2 4 2 2 2 3 2 2 2 0 2 +4 2 1 2 4 2 2 2 3 2 2 2 1 2 +4 2 1 2 4 2 2 2 6 2 2 2 0 2 +4 2 1 2 4 2 2 2 6 2 2 2 1 2 +4 2 1 2 4 2 3 1 3 2 1 1 NULL NULL +4 2 1 2 4 2 3 1 6 2 1 1 NULL NULL +4 2 1 2 4 2 3 3 NULL NULL NULL NULL NULL NULL +5 3 NULL NULL NULL NULL 2 2 3 2 2 2 0 2 +5 3 NULL NULL NULL NULL 2 2 3 2 2 2 1 2 +5 3 NULL NULL NULL NULL 2 2 6 2 2 2 0 2 +5 3 NULL NULL NULL NULL 2 2 6 2 2 2 1 2 +5 3 NULL NULL NULL NULL 3 1 3 2 1 1 NULL NULL +5 3 NULL NULL NULL NULL 3 1 6 2 1 1 NULL NULL +5 3 NULL NULL NULL NULL 3 3 NULL NULL NULL NULL NULL NULL +SELECT t2.a,t2.b,t3.a,t3.b,t4.a,t4.b, +t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b +FROM t2 +LEFT JOIN +(t3, t4) +ON t3.a=1 AND t2.b=t4.b, +t5 +LEFT JOIN +( +(t6, t7) +LEFT JOIN +t8 +ON t7.b=t8.b AND t6.b < 10 +) +ON t6.b >= 2 AND t5.b=t7.b +WHERE t2.a > 3 AND +(t6.a < 6 OR t6.c IS NULL); +a b a b a b a b a b a b a b +4 2 1 2 3 2 2 2 3 2 2 2 0 2 +4 2 1 2 3 2 2 2 3 2 2 2 1 2 +4 2 1 2 3 2 3 1 3 2 1 1 NULL NULL +4 2 1 2 3 2 3 3 NULL NULL NULL NULL NULL NULL +4 2 1 2 4 2 2 2 3 2 2 2 0 2 +4 2 1 2 4 2 2 2 3 2 2 2 1 2 +4 2 1 2 4 2 3 1 3 2 1 1 NULL NULL +4 2 1 2 4 2 3 3 NULL NULL NULL NULL NULL NULL +5 3 NULL NULL NULL NULL 2 2 3 2 2 2 0 2 +5 3 NULL NULL NULL NULL 2 2 3 2 2 2 1 2 +5 3 NULL NULL NULL NULL 3 1 3 2 1 1 NULL NULL +5 3 NULL NULL NULL NULL 3 3 NULL NULL NULL NULL NULL NULL +"Standard compliant copy of above query" +SELECT t2.a,t2.b,t34.a3,t34.b3,t34.a4,t34.b4, +t5.a,t5.b,t67.a6,t67.b6,t67.a7,t67.b7,t8.a,t8.b +FROM t2 +LEFT JOIN t34 +ON t34.a3=1 AND t2.b=t34.b4 +CROSS JOIN t5 +LEFT JOIN +( +t67 +LEFT JOIN +t8 +ON t67.b7=t8.b AND t67.b6 < 10 +) +ON t67.b6 >= 2 AND t5.b=t67.b7 +WHERE t2.a > 3 AND +(t67.a6 < 6 OR t67.c6 IS NULL); +a b a3 b3 a4 b4 a b a6 b6 a7 b7 a b +4 2 1 2 3 2 2 2 3 2 2 2 0 2 +4 2 1 2 3 2 2 2 3 2 2 2 1 2 +4 2 1 2 3 2 3 1 3 2 1 1 NULL NULL +4 2 1 2 3 2 3 3 NULL NULL NULL NULL NULL NULL +4 2 1 2 4 2 2 2 3 2 2 2 0 2 +4 2 1 2 4 2 2 2 3 2 2 2 1 2 +4 2 1 2 4 2 3 1 3 2 1 1 NULL NULL +4 2 1 2 4 2 3 3 NULL NULL NULL NULL NULL NULL +5 3 NULL NULL NULL NULL 2 2 3 2 2 2 0 2 +5 3 NULL NULL NULL NULL 2 2 3 2 2 2 1 2 +5 3 NULL NULL NULL NULL 3 1 3 2 1 1 NULL NULL +5 3 NULL NULL NULL NULL 3 3 NULL NULL NULL NULL NULL NULL +SELECT t1.a,t1.b +FROM t1; +a b +1 3 +2 2 +3 2 +SELECT t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b, +t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b +FROM t1 +LEFT JOIN +( +t2 +LEFT JOIN +(t3, t4) +ON t3.a=1 AND t2.b=t4.b, +t5 +LEFT JOIN +( +(t6, t7) +LEFT JOIN +t8 +ON t7.b=t8.b AND t6.b < 10 +) +ON t6.b >= 2 AND t5.b=t7.b +) +ON (t3.b=2 OR t3.c IS NULL) AND (t6.b=2 OR t6.c IS NULL) AND +(t1.b=t5.b OR t3.c IS NULL OR t6.c IS NULL or t8.c IS NULL) AND +(t1.a != 2); +a b a b a b a b a b a b a b a b +1 3 3 3 NULL NULL NULL NULL 2 2 3 2 2 2 0 2 +1 3 3 3 NULL NULL NULL NULL 2 2 3 2 2 2 1 2 +1 3 3 3 NULL NULL NULL NULL 2 2 6 2 2 2 0 2 +1 3 3 3 NULL NULL NULL NULL 2 2 6 2 2 2 1 2 +1 3 3 3 NULL NULL NULL NULL 3 1 3 2 1 1 NULL NULL +1 3 3 3 NULL NULL NULL NULL 3 1 6 2 1 1 NULL NULL +1 3 3 3 NULL NULL NULL NULL 3 3 NULL NULL NULL NULL NULL NULL +1 3 4 2 1 2 3 2 3 1 3 2 1 1 NULL NULL +1 3 4 2 1 2 3 2 3 1 6 2 1 1 NULL NULL +1 3 4 2 1 2 3 2 3 3 NULL NULL NULL NULL NULL NULL +1 3 4 2 1 2 4 2 3 1 3 2 1 1 NULL NULL +1 3 4 2 1 2 4 2 3 1 6 2 1 1 NULL NULL +1 3 4 2 1 2 4 2 3 3 NULL NULL NULL NULL NULL NULL +1 3 5 3 NULL NULL NULL NULL 2 2 3 2 2 2 0 2 +1 3 5 3 NULL NULL NULL NULL 2 2 3 2 2 2 1 2 +1 3 5 3 NULL NULL NULL NULL 2 2 6 2 2 2 0 2 +1 3 5 3 NULL NULL NULL NULL 2 2 6 2 2 2 1 2 +1 3 5 3 NULL NULL NULL NULL 3 1 3 2 1 1 NULL NULL +1 3 5 3 NULL NULL NULL NULL 3 1 6 2 1 1 NULL NULL +1 3 5 3 NULL NULL NULL NULL 3 3 NULL NULL NULL NULL NULL NULL +2 2 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL +3 2 3 3 NULL NULL NULL NULL 2 2 3 2 2 2 0 2 +3 2 3 3 NULL NULL NULL NULL 2 2 3 2 2 2 1 2 +3 2 3 3 NULL NULL NULL NULL 2 2 6 2 2 2 0 2 +3 2 3 3 NULL NULL NULL NULL 2 2 6 2 2 2 1 2 +3 2 3 3 NULL NULL NULL NULL 3 1 3 2 1 1 NULL NULL +3 2 3 3 NULL NULL NULL NULL 3 1 6 2 1 1 NULL NULL +3 2 3 3 NULL NULL NULL NULL 3 3 NULL NULL NULL NULL NULL NULL +3 2 4 2 1 2 3 2 2 2 3 2 2 2 0 2 +3 2 4 2 1 2 3 2 2 2 3 2 2 2 1 2 +3 2 4 2 1 2 3 2 2 2 6 2 2 2 0 2 +3 2 4 2 1 2 3 2 2 2 6 2 2 2 1 2 +3 2 4 2 1 2 3 2 3 1 3 2 1 1 NULL NULL +3 2 4 2 1 2 3 2 3 1 6 2 1 1 NULL NULL +3 2 4 2 1 2 3 2 3 3 NULL NULL NULL NULL NULL NULL +3 2 4 2 1 2 4 2 2 2 3 2 2 2 0 2 +3 2 4 2 1 2 4 2 2 2 3 2 2 2 1 2 +3 2 4 2 1 2 4 2 2 2 6 2 2 2 0 2 +3 2 4 2 1 2 4 2 2 2 6 2 2 2 1 2 +3 2 4 2 1 2 4 2 3 1 3 2 1 1 NULL NULL +3 2 4 2 1 2 4 2 3 1 6 2 1 1 NULL NULL +3 2 4 2 1 2 4 2 3 3 NULL NULL NULL NULL NULL NULL +3 2 5 3 NULL NULL NULL NULL 2 2 3 2 2 2 0 2 +3 2 5 3 NULL NULL NULL NULL 2 2 3 2 2 2 1 2 +3 2 5 3 NULL NULL NULL NULL 2 2 6 2 2 2 0 2 +3 2 5 3 NULL NULL NULL NULL 2 2 6 2 2 2 1 2 +3 2 5 3 NULL NULL NULL NULL 3 1 3 2 1 1 NULL NULL +3 2 5 3 NULL NULL NULL NULL 3 1 6 2 1 1 NULL NULL +3 2 5 3 NULL NULL NULL NULL 3 3 NULL NULL NULL NULL NULL NULL +"Standard compliant copy of above query" +SELECT t1.a,t1.b,t2.a,t2.b,t34.a3,t34.b3,t34.a4,t34.b4, +t5.a,t5.b,t67.a6,t67.b6,t67.a7,t67.b7,t8.a,t8.b +FROM t1 +LEFT JOIN +( +t2 +LEFT JOIN t34 +ON t34.a3=1 AND t2.b=t34.b4 +CROSS JOIN t5 +LEFT JOIN +( +t67 +LEFT JOIN +t8 +ON t67.b7=t8.b AND t67.b6 < 10 +) +ON t67.b6 >= 2 AND t5.b=t67.b7 +) +ON (t34.b3=2 OR t34.c3 IS NULL) AND (t67.b6=2 OR t67.c6 IS NULL) AND +(t1.b=t5.b OR t34.c3 IS NULL OR t67.c6 IS NULL or t8.c IS NULL) AND +(t1.a <> 2); +a b a b a3 b3 a4 b4 a b a6 b6 a7 b7 a b +1 3 3 3 NULL NULL NULL NULL 2 2 3 2 2 2 0 2 +1 3 3 3 NULL NULL NULL NULL 2 2 3 2 2 2 1 2 +1 3 3 3 NULL NULL NULL NULL 2 2 6 2 2 2 0 2 +1 3 3 3 NULL NULL NULL NULL 2 2 6 2 2 2 1 2 +1 3 3 3 NULL NULL NULL NULL 3 1 3 2 1 1 NULL NULL +1 3 3 3 NULL NULL NULL NULL 3 1 6 2 1 1 NULL NULL +1 3 3 3 NULL NULL NULL NULL 3 3 NULL NULL NULL NULL NULL NULL +1 3 4 2 1 2 3 2 3 1 3 2 1 1 NULL NULL +1 3 4 2 1 2 3 2 3 1 6 2 1 1 NULL NULL +1 3 4 2 1 2 3 2 3 3 NULL NULL NULL NULL NULL NULL +1 3 4 2 1 2 4 2 3 1 3 2 1 1 NULL NULL +1 3 4 2 1 2 4 2 3 1 6 2 1 1 NULL NULL +1 3 4 2 1 2 4 2 3 3 NULL NULL NULL NULL NULL NULL +1 3 5 3 NULL NULL NULL NULL 2 2 3 2 2 2 0 2 +1 3 5 3 NULL NULL NULL NULL 2 2 3 2 2 2 1 2 +1 3 5 3 NULL NULL NULL NULL 2 2 6 2 2 2 0 2 +1 3 5 3 NULL NULL NULL NULL 2 2 6 2 2 2 1 2 +1 3 5 3 NULL NULL NULL NULL 3 1 3 2 1 1 NULL NULL +1 3 5 3 NULL NULL NULL NULL 3 1 6 2 1 1 NULL NULL +1 3 5 3 NULL NULL NULL NULL 3 3 NULL NULL NULL NULL NULL NULL +2 2 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL +3 2 3 3 NULL NULL NULL NULL 2 2 3 2 2 2 0 2 +3 2 3 3 NULL NULL NULL NULL 2 2 3 2 2 2 1 2 +3 2 3 3 NULL NULL NULL NULL 2 2 6 2 2 2 0 2 +3 2 3 3 NULL NULL NULL NULL 2 2 6 2 2 2 1 2 +3 2 3 3 NULL NULL NULL NULL 3 1 3 2 1 1 NULL NULL +3 2 3 3 NULL NULL NULL NULL 3 1 6 2 1 1 NULL NULL +3 2 3 3 NULL NULL NULL NULL 3 3 NULL NULL NULL NULL NULL NULL +3 2 4 2 1 2 3 2 2 2 3 2 2 2 0 2 +3 2 4 2 1 2 3 2 2 2 3 2 2 2 1 2 +3 2 4 2 1 2 3 2 2 2 6 2 2 2 0 2 +3 2 4 2 1 2 3 2 2 2 6 2 2 2 1 2 +3 2 4 2 1 2 3 2 3 1 3 2 1 1 NULL NULL +3 2 4 2 1 2 3 2 3 1 6 2 1 1 NULL NULL +3 2 4 2 1 2 3 2 3 3 NULL NULL NULL NULL NULL NULL +3 2 4 2 1 2 4 2 2 2 3 2 2 2 0 2 +3 2 4 2 1 2 4 2 2 2 3 2 2 2 1 2 +3 2 4 2 1 2 4 2 2 2 6 2 2 2 0 2 +3 2 4 2 1 2 4 2 2 2 6 2 2 2 1 2 +3 2 4 2 1 2 4 2 3 1 3 2 1 1 NULL NULL +3 2 4 2 1 2 4 2 3 1 6 2 1 1 NULL NULL +3 2 4 2 1 2 4 2 3 3 NULL NULL NULL NULL NULL NULL +3 2 5 3 NULL NULL NULL NULL 2 2 3 2 2 2 0 2 +3 2 5 3 NULL NULL NULL NULL 2 2 3 2 2 2 1 2 +3 2 5 3 NULL NULL NULL NULL 2 2 6 2 2 2 0 2 +3 2 5 3 NULL NULL NULL NULL 2 2 6 2 2 2 1 2 +3 2 5 3 NULL NULL NULL NULL 3 1 3 2 1 1 NULL NULL +3 2 5 3 NULL NULL NULL NULL 3 1 6 2 1 1 NULL NULL +3 2 5 3 NULL NULL NULL NULL 3 3 NULL NULL NULL NULL NULL NULL +SELECT t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b, +t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b +FROM t1 +LEFT JOIN +( +t2 +LEFT JOIN +(t3, t4) +ON t3.a=1 AND t2.b=t4.b, +t5 +LEFT JOIN +( +(t6, t7) +LEFT JOIN +t8 +ON t7.b=t8.b AND t6.b < 10 +) +ON t6.b >= 2 AND t5.b=t7.b +) +ON (t3.b=2 OR t3.c IS NULL) AND (t6.b=2 OR t6.c IS NULL) AND +(t1.b=t5.b OR t3.c IS NULL OR t6.c IS NULL or t8.c IS NULL) AND +(t1.a != 2) +WHERE (t2.a >= 4 OR t2.c IS NULL); +a b a b a b a b a b a b a b a b +1 3 4 2 1 2 3 2 3 1 3 2 1 1 NULL NULL +1 3 4 2 1 2 3 2 3 1 6 2 1 1 NULL NULL +1 3 4 2 1 2 3 2 3 3 NULL NULL NULL NULL NULL NULL +1 3 4 2 1 2 4 2 3 1 3 2 1 1 NULL NULL +1 3 4 2 1 2 4 2 3 1 6 2 1 1 NULL NULL +1 3 4 2 1 2 4 2 3 3 NULL NULL NULL NULL NULL NULL +1 3 5 3 NULL NULL NULL NULL 2 2 3 2 2 2 0 2 +1 3 5 3 NULL NULL NULL NULL 2 2 3 2 2 2 1 2 +1 3 5 3 NULL NULL NULL NULL 2 2 6 2 2 2 0 2 +1 3 5 3 NULL NULL NULL NULL 2 2 6 2 2 2 1 2 +1 3 5 3 NULL NULL NULL NULL 3 1 3 2 1 1 NULL NULL +1 3 5 3 NULL NULL NULL NULL 3 1 6 2 1 1 NULL NULL +1 3 5 3 NULL NULL NULL NULL 3 3 NULL NULL NULL NULL NULL NULL +2 2 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL +3 2 4 2 1 2 3 2 2 2 3 2 2 2 0 2 +3 2 4 2 1 2 3 2 2 2 3 2 2 2 1 2 +3 2 4 2 1 2 3 2 2 2 6 2 2 2 0 2 +3 2 4 2 1 2 3 2 2 2 6 2 2 2 1 2 +3 2 4 2 1 2 3 2 3 1 3 2 1 1 NULL NULL +3 2 4 2 1 2 3 2 3 1 6 2 1 1 NULL NULL +3 2 4 2 1 2 3 2 3 3 NULL NULL NULL NULL NULL NULL +3 2 4 2 1 2 4 2 2 2 3 2 2 2 0 2 +3 2 4 2 1 2 4 2 2 2 3 2 2 2 1 2 +3 2 4 2 1 2 4 2 2 2 6 2 2 2 0 2 +3 2 4 2 1 2 4 2 2 2 6 2 2 2 1 2 +3 2 4 2 1 2 4 2 3 1 3 2 1 1 NULL NULL +3 2 4 2 1 2 4 2 3 1 6 2 1 1 NULL NULL +3 2 4 2 1 2 4 2 3 3 NULL NULL NULL NULL NULL NULL +3 2 5 3 NULL NULL NULL NULL 2 2 3 2 2 2 0 2 +3 2 5 3 NULL NULL NULL NULL 2 2 3 2 2 2 1 2 +3 2 5 3 NULL NULL NULL NULL 2 2 6 2 2 2 0 2 +3 2 5 3 NULL NULL NULL NULL 2 2 6 2 2 2 1 2 +3 2 5 3 NULL NULL NULL NULL 3 1 3 2 1 1 NULL NULL +3 2 5 3 NULL NULL NULL NULL 3 1 6 2 1 1 NULL NULL +3 2 5 3 NULL NULL NULL NULL 3 3 NULL NULL NULL NULL NULL NULL +"Standard compliant copy of above query" +SELECT t1.a,t1.b,t2.a,t2.b,t34.a3,t34.b3,t34.a4,t34.b4, +t5.a,t5.b,t67.a6,t67.b6,t67.a7,t67.b7,t8.a,t8.b +FROM t1 +LEFT JOIN +( +t2 +LEFT JOIN t34 +ON t34.a3=1 AND t2.b=t34.b4 +CROSS JOIN t5 +LEFT JOIN +( +t67 +LEFT JOIN +t8 +ON t67.b7=t8.b AND t67.b6 < 10 +) +ON t67.b6 >= 2 AND t5.b=t67.b7 +) +ON (t34.b3=2 OR t34.c3 IS NULL) AND (t67.b6=2 OR t67.c6 IS NULL) AND +(t1.b=t5.b OR t34.c3 IS NULL OR t67.c6 IS NULL or t8.c IS NULL) AND +(t1.a <> 2) +WHERE (t2.a >= 4 OR t2.c IS NULL); +a b a b a3 b3 a4 b4 a b a6 b6 a7 b7 a b +1 3 4 2 1 2 3 2 3 1 3 2 1 1 NULL NULL +1 3 4 2 1 2 3 2 3 1 6 2 1 1 NULL NULL +1 3 4 2 1 2 3 2 3 3 NULL NULL NULL NULL NULL NULL +1 3 4 2 1 2 4 2 3 1 3 2 1 1 NULL NULL +1 3 4 2 1 2 4 2 3 1 6 2 1 1 NULL NULL +1 3 4 2 1 2 4 2 3 3 NULL NULL NULL NULL NULL NULL +1 3 5 3 NULL NULL NULL NULL 2 2 3 2 2 2 0 2 +1 3 5 3 NULL NULL NULL NULL 2 2 3 2 2 2 1 2 +1 3 5 3 NULL NULL NULL NULL 2 2 6 2 2 2 0 2 +1 3 5 3 NULL NULL NULL NULL 2 2 6 2 2 2 1 2 +1 3 5 3 NULL NULL NULL NULL 3 1 3 2 1 1 NULL NULL +1 3 5 3 NULL NULL NULL NULL 3 1 6 2 1 1 NULL NULL +1 3 5 3 NULL NULL NULL NULL 3 3 NULL NULL NULL NULL NULL NULL +2 2 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL +3 2 4 2 1 2 3 2 2 2 3 2 2 2 0 2 +3 2 4 2 1 2 3 2 2 2 3 2 2 2 1 2 +3 2 4 2 1 2 3 2 2 2 6 2 2 2 0 2 +3 2 4 2 1 2 3 2 2 2 6 2 2 2 1 2 +3 2 4 2 1 2 3 2 3 1 3 2 1 1 NULL NULL +3 2 4 2 1 2 3 2 3 1 6 2 1 1 NULL NULL +3 2 4 2 1 2 3 2 3 3 NULL NULL NULL NULL NULL NULL +3 2 4 2 1 2 4 2 2 2 3 2 2 2 0 2 +3 2 4 2 1 2 4 2 2 2 3 2 2 2 1 2 +3 2 4 2 1 2 4 2 2 2 6 2 2 2 0 2 +3 2 4 2 1 2 4 2 2 2 6 2 2 2 1 2 +3 2 4 2 1 2 4 2 3 1 3 2 1 1 NULL NULL +3 2 4 2 1 2 4 2 3 1 6 2 1 1 NULL NULL +3 2 4 2 1 2 4 2 3 3 NULL NULL NULL NULL NULL NULL +3 2 5 3 NULL NULL NULL NULL 2 2 3 2 2 2 0 2 +3 2 5 3 NULL NULL NULL NULL 2 2 3 2 2 2 1 2 +3 2 5 3 NULL NULL NULL NULL 2 2 6 2 2 2 0 2 +3 2 5 3 NULL NULL NULL NULL 2 2 6 2 2 2 1 2 +3 2 5 3 NULL NULL NULL NULL 3 1 3 2 1 1 NULL NULL +3 2 5 3 NULL NULL NULL NULL 3 1 6 2 1 1 NULL NULL +3 2 5 3 NULL NULL NULL NULL 3 3 NULL NULL NULL NULL NULL NULL +SELECT t0.a,t0.b +FROM t0; +a b +1 1 +1 2 +2 2 +ANALYZE TABLE t0, t1, t2, t3, t4, t5, t6, t7, t8; +Table Op Msg_type Msg_text +test.t0 analyze status OK +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +test.t4 analyze status OK +test.t5 analyze status OK +test.t6 analyze status OK +test.t7 analyze status OK +test.t8 analyze status OK +EXPLAIN +SELECT t0.a,t0.b,t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b, +t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b +FROM t0,t1 +LEFT JOIN +( +t2 +LEFT JOIN +(t3, t4) +ON t3.a=1 AND t2.b=t4.b, +t5 +LEFT JOIN +( +(t6, t7) +LEFT JOIN +t8 +ON t7.b=t8.b AND t6.b < 10 +) +ON t6.b >= 2 AND t5.b=t7.b +) +ON (t3.b=2 OR t3.c IS NULL) AND (t6.b=2 OR t6.c IS NULL) AND +(t1.b=t5.b OR t3.c IS NULL OR t6.c IS NULL or t8.c IS NULL) AND +(t1.a != 2) +WHERE t0.a=1 AND +t0.b=t1.b AND +(t2.a >= 4 OR t2.c IS NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE t0 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 55.56 Using where; Using join buffer (hash join) +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t5 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 SIMPLE t7 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t6 NULL ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t8 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a`,`test`.`t0`.`b` AS `b`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t5`.`a` AS `a`,`test`.`t5`.`b` AS `b`,`test`.`t6`.`a` AS `a`,`test`.`t6`.`b` AS `b`,`test`.`t7`.`a` AS `a`,`test`.`t7`.`b` AS `b`,`test`.`t8`.`a` AS `a`,`test`.`t8`.`b` AS `b` from `test`.`t0` join `test`.`t1` left join (`test`.`t2` left join (`test`.`t3` join `test`.`t4`) on(((`test`.`t4`.`b` = `test`.`t2`.`b`) and (`test`.`t3`.`a` = 1))) join `test`.`t5` left join (`test`.`t6` join `test`.`t7` left join `test`.`t8` on(((`test`.`t8`.`b` = `test`.`t7`.`b`) and (`test`.`t6`.`b` < 10)))) on(((`test`.`t7`.`b` = `test`.`t5`.`b`) and (`test`.`t6`.`b` >= 2)))) on((((`test`.`t3`.`b` = 2) or (`test`.`t3`.`c` is null)) and ((`test`.`t6`.`b` = 2) or (`test`.`t6`.`c` is null)) and ((`test`.`t5`.`b` = `test`.`t0`.`b`) or (`test`.`t3`.`c` is null) or (`test`.`t6`.`c` is null) or (`test`.`t8`.`c` is null)) and (`test`.`t1`.`a` <> 2))) where ((`test`.`t1`.`b` = `test`.`t0`.`b`) and (`test`.`t0`.`a` = 1) and ((`test`.`t2`.`a` >= 4) or (`test`.`t2`.`c` is null))) +SELECT t0.a,t0.b,t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b, +t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b +FROM t0,t1 +LEFT JOIN +( +t2 +LEFT JOIN +(t3, t4) +ON t3.a=1 AND t2.b=t4.b, +t5 +LEFT JOIN +( +(t6, t7) +LEFT JOIN +t8 +ON t7.b=t8.b AND t6.b < 10 +) +ON t6.b >= 2 AND t5.b=t7.b +) +ON (t3.b=2 OR t3.c IS NULL) AND (t6.b=2 OR t6.c IS NULL) AND +(t1.b=t5.b OR t3.c IS NULL OR t6.c IS NULL or t8.c IS NULL) AND +(t1.a != 2) +WHERE t0.a=1 AND +t0.b=t1.b AND +(t2.a >= 4 OR t2.c IS NULL); +a b a b a b a b a b a b a b a b a b +1 2 2 2 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL +1 2 3 2 4 2 1 2 3 2 2 2 3 2 2 2 0 2 +1 2 3 2 4 2 1 2 3 2 2 2 3 2 2 2 1 2 +1 2 3 2 4 2 1 2 3 2 2 2 6 2 2 2 0 2 +1 2 3 2 4 2 1 2 3 2 2 2 6 2 2 2 1 2 +1 2 3 2 4 2 1 2 3 2 3 1 3 2 1 1 NULL NULL +1 2 3 2 4 2 1 2 3 2 3 1 6 2 1 1 NULL NULL +1 2 3 2 4 2 1 2 3 2 3 3 NULL NULL NULL NULL NULL NULL +1 2 3 2 4 2 1 2 4 2 2 2 3 2 2 2 0 2 +1 2 3 2 4 2 1 2 4 2 2 2 3 2 2 2 1 2 +1 2 3 2 4 2 1 2 4 2 2 2 6 2 2 2 0 2 +1 2 3 2 4 2 1 2 4 2 2 2 6 2 2 2 1 2 +1 2 3 2 4 2 1 2 4 2 3 1 3 2 1 1 NULL NULL +1 2 3 2 4 2 1 2 4 2 3 1 6 2 1 1 NULL NULL +1 2 3 2 4 2 1 2 4 2 3 3 NULL NULL NULL NULL NULL NULL +1 2 3 2 5 3 NULL NULL NULL NULL 2 2 3 2 2 2 0 2 +1 2 3 2 5 3 NULL NULL NULL NULL 2 2 3 2 2 2 1 2 +1 2 3 2 5 3 NULL NULL NULL NULL 2 2 6 2 2 2 0 2 +1 2 3 2 5 3 NULL NULL NULL NULL 2 2 6 2 2 2 1 2 +1 2 3 2 5 3 NULL NULL NULL NULL 3 1 3 2 1 1 NULL NULL +1 2 3 2 5 3 NULL NULL NULL NULL 3 1 6 2 1 1 NULL NULL +1 2 3 2 5 3 NULL NULL NULL NULL 3 3 NULL NULL NULL NULL NULL NULL +"Standard compliant copy of above query" +SELECT t0.a,t0.b,t1.a,t1.b,t2.a,t2.b,t34.a3,t34.b3,t34.a4,t34.b4, +t5.a,t5.b,t67.a6,t67.b6,t67.a7,t67.b7,t8.a,t8.b +FROM t0 +CROSS JOIN t1 +LEFT JOIN +( +t2 +LEFT JOIN t34 +ON t34.a3=1 AND t2.b=t34.b4 +CROSS JOIN t5 +LEFT JOIN +( +t67 +LEFT JOIN +t8 +ON t67.b7=t8.b AND t67.b6 < 10 +) +ON t67.b6 >= 2 AND t5.b=t67.b7 +) +ON (t34.b3=2 OR t34.c3 IS NULL) AND (t67.b6=2 OR t67.c6 IS NULL) AND +(t1.b=t5.b OR t34.c3 IS NULL OR t67.c6 IS NULL or t8.c IS NULL) AND +(t1.a <> 2) +WHERE t0.a=1 AND +t0.b=t1.b AND +(t2.a >= 4 OR t2.c IS NULL); +a b a b a b a3 b3 a4 b4 a b a6 b6 a7 b7 a b +1 2 2 2 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL +1 2 3 2 4 2 1 2 3 2 2 2 3 2 2 2 0 2 +1 2 3 2 4 2 1 2 3 2 2 2 3 2 2 2 1 2 +1 2 3 2 4 2 1 2 3 2 2 2 6 2 2 2 0 2 +1 2 3 2 4 2 1 2 3 2 2 2 6 2 2 2 1 2 +1 2 3 2 4 2 1 2 3 2 3 1 3 2 1 1 NULL NULL +1 2 3 2 4 2 1 2 3 2 3 1 6 2 1 1 NULL NULL +1 2 3 2 4 2 1 2 3 2 3 3 NULL NULL NULL NULL NULL NULL +1 2 3 2 4 2 1 2 4 2 2 2 3 2 2 2 0 2 +1 2 3 2 4 2 1 2 4 2 2 2 3 2 2 2 1 2 +1 2 3 2 4 2 1 2 4 2 2 2 6 2 2 2 0 2 +1 2 3 2 4 2 1 2 4 2 2 2 6 2 2 2 1 2 +1 2 3 2 4 2 1 2 4 2 3 1 3 2 1 1 NULL NULL +1 2 3 2 4 2 1 2 4 2 3 1 6 2 1 1 NULL NULL +1 2 3 2 4 2 1 2 4 2 3 3 NULL NULL NULL NULL NULL NULL +1 2 3 2 5 3 NULL NULL NULL NULL 2 2 3 2 2 2 0 2 +1 2 3 2 5 3 NULL NULL NULL NULL 2 2 3 2 2 2 1 2 +1 2 3 2 5 3 NULL NULL NULL NULL 2 2 6 2 2 2 0 2 +1 2 3 2 5 3 NULL NULL NULL NULL 2 2 6 2 2 2 1 2 +1 2 3 2 5 3 NULL NULL NULL NULL 3 1 3 2 1 1 NULL NULL +1 2 3 2 5 3 NULL NULL NULL NULL 3 1 6 2 1 1 NULL NULL +1 2 3 2 5 3 NULL NULL NULL NULL 3 3 NULL NULL NULL NULL NULL NULL +ANALYZE TABLE t0, t1, t2, t3, t4, t5, t6, t7, t8, t9; +Table Op Msg_type Msg_text +test.t0 analyze status OK +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +test.t4 analyze status OK +test.t5 analyze status OK +test.t6 analyze status OK +test.t7 analyze status OK +test.t8 analyze status OK +test.t9 analyze status OK +EXPLAIN +SELECT t0.a,t0.b,t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b, +t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b,t9.a,t9.b +FROM t0,t1 +LEFT JOIN +( +t2 +LEFT JOIN +(t3, t4) +ON t3.a=1 AND t2.b=t4.b, +t5 +LEFT JOIN +( +(t6, t7) +LEFT JOIN +t8 +ON t7.b=t8.b AND t6.b < 10 +) +ON t6.b >= 2 AND t5.b=t7.b +) +ON (t3.b=2 OR t3.c IS NULL) AND (t6.b=2 OR t6.c IS NULL) AND +(t1.b=t5.b OR t3.c IS NULL OR t6.c IS NULL or t8.c IS NULL) AND +(t1.a != 2), +t9 +WHERE t0.a=1 AND +t0.b=t1.b AND +(t2.a >= 4 OR t2.c IS NULL) AND +(t3.a < 5 OR t3.c IS NULL) AND +(t3.b=t4.b OR t3.c IS NULL OR t4.c IS NULL) AND +(t5.a >=2 OR t5.c IS NULL) AND +(t6.a >=4 OR t6.c IS NULL) AND +(t7.a <= 2 OR t7.c IS NULL) AND +(t8.a < 1 OR t8.c IS NULL) AND +(t8.b=t9.b OR t8.c IS NULL) AND +(t9.a=1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE t0 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +2 SIMPLE t9 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 55.56 Using where; Using join buffer (hash join) +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 75.00 Using where; Using join buffer (hash join) +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t5 NULL ALL NULL NULL NULL NULL 3 55.56 Using where; Using join buffer (hash join) +2 SIMPLE t7 NULL ALL NULL NULL NULL NULL 2 75.00 Using where; Using join buffer (hash join) +2 SIMPLE t6 NULL ALL NULL NULL NULL NULL 3 55.56 Using where; Using join buffer (hash join) +2 SIMPLE t8 NULL ALL NULL NULL NULL NULL 2 56.25 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a`,`test`.`t0`.`b` AS `b`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t5`.`a` AS `a`,`test`.`t5`.`b` AS `b`,`test`.`t6`.`a` AS `a`,`test`.`t6`.`b` AS `b`,`test`.`t7`.`a` AS `a`,`test`.`t7`.`b` AS `b`,`test`.`t8`.`a` AS `a`,`test`.`t8`.`b` AS `b`,`test`.`t9`.`a` AS `a`,`test`.`t9`.`b` AS `b` from `test`.`t0` join `test`.`t1` left join (`test`.`t2` left join (`test`.`t3` join `test`.`t4`) on(((`test`.`t4`.`b` = `test`.`t2`.`b`) and (`test`.`t3`.`a` = 1))) join `test`.`t5` left join (`test`.`t6` join `test`.`t7` left join `test`.`t8` on(((`test`.`t8`.`b` = `test`.`t7`.`b`) and (`test`.`t6`.`b` < 10)))) on(((`test`.`t7`.`b` = `test`.`t5`.`b`) and (`test`.`t6`.`b` >= 2)))) on((((`test`.`t3`.`b` = 2) or (`test`.`t3`.`c` is null)) and ((`test`.`t6`.`b` = 2) or (`test`.`t6`.`c` is null)) and ((`test`.`t5`.`b` = `test`.`t0`.`b`) or (`test`.`t3`.`c` is null) or (`test`.`t6`.`c` is null) or (`test`.`t8`.`c` is null)) and (`test`.`t1`.`a` <> 2))) join `test`.`t9` where ((`test`.`t9`.`a` = 1) and (`test`.`t1`.`b` = `test`.`t0`.`b`) and (`test`.`t0`.`a` = 1) and ((`test`.`t2`.`a` >= 4) or (`test`.`t2`.`c` is null)) and ((`test`.`t3`.`a` < 5) or (`test`.`t3`.`c` is null)) and ((`test`.`t4`.`b` = `test`.`t3`.`b`) or (`test`.`t3`.`c` is null) or (`test`.`t4`.`c` is null)) and ((`test`.`t5`.`a` >= 2) or (`test`.`t5`.`c` is null)) and ((`test`.`t6`.`a` >= 4) or (`test`.`t6`.`c` is null)) and ((`test`.`t7`.`a` <= 2) or (`test`.`t7`.`c` is null)) and ((`test`.`t8`.`a` < 1) or (`test`.`t8`.`c` is null)) and ((`test`.`t8`.`b` = `test`.`t9`.`b`) or (`test`.`t8`.`c` is null))) +SELECT t9.a,t9.b +FROM t9; +a b +1 1 +1 2 +3 3 +SELECT t0.a,t0.b,t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b, +t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b,t9.a,t9.b +FROM t0,t1 +LEFT JOIN +( +t2 +LEFT JOIN +(t3, t4) +ON t3.a=1 AND t2.b=t4.b, +t5 +LEFT JOIN +( +(t6, t7) +LEFT JOIN +t8 +ON t7.b=t8.b AND t6.b < 10 +) +ON t6.b >= 2 AND t5.b=t7.b +) +ON (t3.b=2 OR t3.c IS NULL) AND (t6.b=2 OR t6.c IS NULL) AND +(t1.b=t5.b OR t3.c IS NULL OR t6.c IS NULL or t8.c IS NULL) AND +(t1.a != 2), +t9 +WHERE t0.a=1 AND +t0.b=t1.b AND +(t2.a >= 4 OR t2.c IS NULL) AND +(t3.a < 5 OR t3.c IS NULL) AND +(t3.b=t4.b OR t3.c IS NULL OR t4.c IS NULL) AND +(t5.a >=2 OR t5.c IS NULL) AND +(t6.a >=4 OR t6.c IS NULL) AND +(t7.a <= 2 OR t7.c IS NULL) AND +(t8.a < 1 OR t8.c IS NULL) AND +(t8.b=t9.b OR t8.c IS NULL) AND +(t9.a=1); +a b a b a b a b a b a b a b a b a b a b +1 2 2 2 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL 1 1 +1 2 2 2 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL 1 2 +1 2 3 2 4 2 1 2 3 2 2 2 6 2 2 2 0 2 1 2 +1 2 3 2 4 2 1 2 3 2 3 1 6 2 1 1 NULL NULL 1 1 +1 2 3 2 4 2 1 2 3 2 3 1 6 2 1 1 NULL NULL 1 2 +1 2 3 2 4 2 1 2 3 2 3 3 NULL NULL NULL NULL NULL NULL 1 1 +1 2 3 2 4 2 1 2 3 2 3 3 NULL NULL NULL NULL NULL NULL 1 2 +1 2 3 2 4 2 1 2 4 2 2 2 6 2 2 2 0 2 1 2 +1 2 3 2 4 2 1 2 4 2 3 1 6 2 1 1 NULL NULL 1 1 +1 2 3 2 4 2 1 2 4 2 3 1 6 2 1 1 NULL NULL 1 2 +1 2 3 2 4 2 1 2 4 2 3 3 NULL NULL NULL NULL NULL NULL 1 1 +1 2 3 2 4 2 1 2 4 2 3 3 NULL NULL NULL NULL NULL NULL 1 2 +1 2 3 2 5 3 NULL NULL NULL NULL 2 2 6 2 2 2 0 2 1 2 +1 2 3 2 5 3 NULL NULL NULL NULL 3 1 6 2 1 1 NULL NULL 1 1 +1 2 3 2 5 3 NULL NULL NULL NULL 3 1 6 2 1 1 NULL NULL 1 2 +1 2 3 2 5 3 NULL NULL NULL NULL 3 3 NULL NULL NULL NULL NULL NULL 1 1 +1 2 3 2 5 3 NULL NULL NULL NULL 3 3 NULL NULL NULL NULL NULL NULL 1 2 +"Standard compliant copy of above query" +SELECT t0.a,t0.b,t1.a,t1.b,t2.a,t2.b,t34.a3,t34.b3,t34.a4,t34.b4, +t5.a,t5.b,t67.a6,t67.b6,t67.a7,t67.b7,t8.a,t8.b,t9.a,t9.b +FROM t0 +CROSS JOIN t1 +LEFT JOIN +( +t2 +LEFT JOIN t34 +ON t34.a3=1 AND t2.b=t34.b4 +CROSS JOIN t5 +LEFT JOIN +( +t67 +LEFT JOIN +t8 +ON t67.b7=t8.b AND t67.b6 < 10 +) +ON t67.b6 >= 2 AND t5.b=t67.b7 +) +ON (t34.b3=2 OR t34.c3 IS NULL) AND (t67.b6=2 OR t67.c6 IS NULL) AND +(t1.b=t5.b OR t34.c3 IS NULL OR t67.c6 IS NULL or t8.c IS NULL) AND +(t1.a <> 2), +t9 +WHERE t0.a=1 AND +t0.b=t1.b AND +(t2.a >= 4 OR t2.c IS NULL) AND +(t34.a3 < 5 OR t34.c3 IS NULL) AND +(t34.b3=t34.b4 OR t34.c3 IS NULL OR t34.c4 IS NULL) AND +(t5.a >=2 OR t5.c IS NULL) AND +(t67.a6 >=4 OR t67.c6 IS NULL) AND +(t67.a7 <= 2 OR t67.c7 IS NULL) AND +(t8.a < 1 OR t8.c IS NULL) AND +(t8.b=t9.b OR t8.c IS NULL) AND +(t9.a=1); +a b a b a b a3 b3 a4 b4 a b a6 b6 a7 b7 a b a b +1 2 2 2 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL 1 1 +1 2 2 2 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL 1 2 +1 2 3 2 4 2 1 2 3 2 2 2 6 2 2 2 0 2 1 2 +1 2 3 2 4 2 1 2 3 2 3 1 6 2 1 1 NULL NULL 1 1 +1 2 3 2 4 2 1 2 3 2 3 1 6 2 1 1 NULL NULL 1 2 +1 2 3 2 4 2 1 2 3 2 3 3 NULL NULL NULL NULL NULL NULL 1 1 +1 2 3 2 4 2 1 2 3 2 3 3 NULL NULL NULL NULL NULL NULL 1 2 +1 2 3 2 4 2 1 2 4 2 2 2 6 2 2 2 0 2 1 2 +1 2 3 2 4 2 1 2 4 2 3 1 6 2 1 1 NULL NULL 1 1 +1 2 3 2 4 2 1 2 4 2 3 1 6 2 1 1 NULL NULL 1 2 +1 2 3 2 4 2 1 2 4 2 3 3 NULL NULL NULL NULL NULL NULL 1 1 +1 2 3 2 4 2 1 2 4 2 3 3 NULL NULL NULL NULL NULL NULL 1 2 +1 2 3 2 5 3 NULL NULL NULL NULL 2 2 6 2 2 2 0 2 1 2 +1 2 3 2 5 3 NULL NULL NULL NULL 3 1 6 2 1 1 NULL NULL 1 1 +1 2 3 2 5 3 NULL NULL NULL NULL 3 1 6 2 1 1 NULL NULL 1 2 +1 2 3 2 5 3 NULL NULL NULL NULL 3 3 NULL NULL NULL NULL NULL NULL 1 1 +1 2 3 2 5 3 NULL NULL NULL NULL 3 3 NULL NULL NULL NULL NULL NULL 1 2 +SELECT t1.a,t1.b +FROM t1; +a b +1 3 +2 2 +3 2 +SELECT t2.a,t2.b +FROM t2; +a b +3 3 +4 2 +5 3 +SELECT t3.a,t3.b +FROM t3; +a b +1 2 +2 2 +SELECT t2.a,t2.b,t3.a,t3.b +FROM t2 +LEFT JOIN +t3 +ON t2.b=t3.b; +a b a b +3 3 NULL NULL +4 2 1 2 +4 2 2 2 +5 3 NULL NULL +SELECT t1.a,t1.b,t2.a,t2.b,t3.a,t3.b +FROM t1, t2 +LEFT JOIN +t3 +ON t2.b=t3.b +WHERE t1.a <= 2; +a b a b a b +1 3 3 3 NULL NULL +1 3 4 2 1 2 +1 3 4 2 2 2 +1 3 5 3 NULL NULL +2 2 3 3 NULL NULL +2 2 4 2 1 2 +2 2 4 2 2 2 +2 2 5 3 NULL NULL +"Standard compliant copy of above query" +SELECT t1.a,t1.b,t2.a,t2.b,t3.a,t3.b +FROM t1 +CROSS JOIN t2 +LEFT JOIN +t3 +ON t2.b=t3.b +WHERE t1.a <= 2; +a b a b a b +1 3 3 3 NULL NULL +1 3 4 2 1 2 +1 3 4 2 2 2 +1 3 5 3 NULL NULL +2 2 3 3 NULL NULL +2 2 4 2 1 2 +2 2 4 2 2 2 +2 2 5 3 NULL NULL +SELECT t1.a,t1.b,t2.a,t2.b,t3.a,t3.b +FROM t1, t3 +RIGHT JOIN +t2 +ON t2.b=t3.b +WHERE t1.a <= 2; +a b a b a b +1 3 3 3 NULL NULL +1 3 4 2 1 2 +1 3 4 2 2 2 +1 3 5 3 NULL NULL +2 2 3 3 NULL NULL +2 2 4 2 1 2 +2 2 4 2 2 2 +2 2 5 3 NULL NULL +"Standard compliant copy of above query" +SELECT t1.a,t1.b,t2.a,t2.b,t3.a,t3.b +FROM t1 CROSS JOIN +( +t3 +RIGHT JOIN +t2 +ON t2.b=t3.b +) +WHERE t1.a <= 2; +a b a b a b +1 3 3 3 NULL NULL +1 3 4 2 1 2 +1 3 4 2 2 2 +1 3 5 3 NULL NULL +2 2 3 3 NULL NULL +2 2 4 2 1 2 +2 2 4 2 2 2 +2 2 5 3 NULL NULL +SELECT t3.a,t3.b,t4.a,t4.b +FROM t3,t4; +a b a b +1 2 3 2 +1 2 4 2 +2 2 3 2 +2 2 4 2 +SELECT t2.a,t2.b,t3.a,t3.b,t4.a,t4.b +FROM t2 +LEFT JOIN +(t3, t4) +ON t3.a=1 AND t2.b=t4.b; +a b a b a b +3 3 NULL NULL NULL NULL +4 2 1 2 3 2 +4 2 1 2 4 2 +5 3 NULL NULL NULL NULL +"Standard compliant copy of above query" +SELECT t2.a,t2.b,t3.a,t3.b,t4.a,t4.b +FROM t2 +LEFT JOIN +(t3 CROSS JOIN t4) +ON t3.a=1 AND t2.b=t4.b; +a b a b a b +3 3 NULL NULL NULL NULL +4 2 1 2 3 2 +4 2 1 2 4 2 +5 3 NULL NULL NULL NULL +SELECT t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b +FROM t1 CROSS JOIN +( +t2 +LEFT JOIN +(t3, t4) +ON t3.a=1 AND t2.b=t4.b +) +WHERE t1.a <= 2; +a b a b a b a b +1 3 3 3 NULL NULL NULL NULL +1 3 4 2 1 2 3 2 +1 3 4 2 1 2 4 2 +1 3 5 3 NULL NULL NULL NULL +2 2 3 3 NULL NULL NULL NULL +2 2 4 2 1 2 3 2 +2 2 4 2 1 2 4 2 +2 2 5 3 NULL NULL NULL NULL +"Standard compliant copy of above query" +SELECT t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b +FROM t1 CROSS JOIN +( +t2 +LEFT JOIN +(t3 CROSS JOIN t4) +ON t3.a=1 AND t2.b=t4.b +) +WHERE t1.a <= 2; +a b a b a b a b +1 3 3 3 NULL NULL NULL NULL +1 3 4 2 1 2 3 2 +1 3 4 2 1 2 4 2 +1 3 5 3 NULL NULL NULL NULL +2 2 3 3 NULL NULL NULL NULL +2 2 4 2 1 2 3 2 +2 2 4 2 1 2 4 2 +2 2 5 3 NULL NULL NULL NULL +SELECT t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b +FROM t1, (t3, t4) +RIGHT JOIN +t2 +ON t3.a=1 AND t2.b=t4.b +WHERE t1.a <= 2; +a b a b a b a b +1 3 3 3 NULL NULL NULL NULL +1 3 4 2 1 2 3 2 +1 3 4 2 1 2 4 2 +1 3 5 3 NULL NULL NULL NULL +2 2 3 3 NULL NULL NULL NULL +2 2 4 2 1 2 3 2 +2 2 4 2 1 2 4 2 +2 2 5 3 NULL NULL NULL NULL +"Standard compliant copy of above query" +SELECT t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b +FROM t1 CROSS JOIN +( +(t3 CROSS JOIN t4) +RIGHT JOIN +t2 +ON t3.a=1 AND t2.b=t4.b +) +WHERE t1.a <= 2; +a b a b a b a b +1 3 3 3 NULL NULL NULL NULL +1 3 4 2 1 2 3 2 +1 3 4 2 1 2 4 2 +1 3 5 3 NULL NULL NULL NULL +2 2 3 3 NULL NULL NULL NULL +2 2 4 2 1 2 3 2 +2 2 4 2 1 2 4 2 +2 2 5 3 NULL NULL NULL NULL +SELECT t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b +FROM t1, (t3, t4) +RIGHT JOIN +t2 +ON t3.a=1 AND t2.b=t4.b +WHERE t1.a <= 2; +a b a b a b a b +1 3 3 3 NULL NULL NULL NULL +1 3 4 2 1 2 3 2 +1 3 4 2 1 2 4 2 +1 3 5 3 NULL NULL NULL NULL +2 2 3 3 NULL NULL NULL NULL +2 2 4 2 1 2 3 2 +2 2 4 2 1 2 4 2 +2 2 5 3 NULL NULL NULL NULL +"Standard compliant copy of above query" +SELECT t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b +FROM t1 CROSS JOIN +( +(t3 CROSS JOIN t4) +RIGHT JOIN +t2 +ON t3.a=1 AND t2.b=t4.b +) +WHERE t1.a <= 2; +a b a b a b a b +1 3 3 3 NULL NULL NULL NULL +1 3 4 2 1 2 3 2 +1 3 4 2 1 2 4 2 +1 3 5 3 NULL NULL NULL NULL +2 2 3 3 NULL NULL NULL NULL +2 2 4 2 1 2 3 2 +2 2 4 2 1 2 4 2 +2 2 5 3 NULL NULL NULL NULL +EXPLAIN +SELECT t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b +FROM t1, (t3, t4) +RIGHT JOIN +t2 +ON t3.a=1 AND t2.b=t4.b +WHERE t1.a <= 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b` from `test`.`t1` join `test`.`t2` left join (`test`.`t3` join `test`.`t4`) on(((`test`.`t4`.`b` = `test`.`t2`.`b`) and (`test`.`t3`.`a` = 1))) where (`test`.`t1`.`a` <= 2) +CREATE INDEX idx_b ON t2(b); +EXPLAIN +SELECT t2.a,t2.b,t3.a,t3.b,t4.a,t4.b +FROM (t3,t4) +LEFT JOIN +(t1,t2) +ON t3.a=1 AND t3.b=t2.b AND t2.b=t4.b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t2 NULL ALL idx_b NULL NULL NULL 3 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b` from `test`.`t3` join `test`.`t4` left join (`test`.`t1` join `test`.`t2`) on(((`test`.`t4`.`b` = `test`.`t2`.`b`) and (`test`.`t2`.`b` = `test`.`t3`.`b`) and (`test`.`t3`.`a` = 1))) where true +SELECT t2.a,t2.b,t3.a,t3.b,t4.a,t4.b +FROM (t3,t4) +LEFT JOIN +(t1,t2) +ON t3.a=1 AND t3.b=t2.b AND t2.b=t4.b; +a b a b a b +4 2 1 2 3 2 +4 2 1 2 3 2 +4 2 1 2 3 2 +4 2 1 2 4 2 +4 2 1 2 4 2 +4 2 1 2 4 2 +NULL NULL 2 2 3 2 +NULL NULL 2 2 4 2 +"Standard compliant copy of above query" +SELECT t2.a,t2.b,t3.a,t3.b,t4.a,t4.b +FROM (t3 CROSS JOIN t4) +LEFT JOIN +(t1 CROSS JOIN t2) +ON t3.a=1 AND t3.b=t2.b AND t2.b=t4.b; +a b a b a b +4 2 1 2 3 2 +4 2 1 2 3 2 +4 2 1 2 3 2 +4 2 1 2 4 2 +4 2 1 2 4 2 +4 2 1 2 4 2 +NULL NULL 2 2 3 2 +NULL NULL 2 2 4 2 +ANALYZE TABLE t0, t1, t2, t3, t4, t5, t6, t7, t8, t9; +Table Op Msg_type Msg_text +test.t0 analyze status OK +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +test.t4 analyze status OK +test.t5 analyze status OK +test.t6 analyze status OK +test.t7 analyze status OK +test.t8 analyze status OK +test.t9 analyze status OK +EXPLAIN +SELECT t0.a,t0.b,t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b, +t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b,t9.a,t9.b +FROM t0,t1 +LEFT JOIN +( +t2 +LEFT JOIN +(t3, t4) +ON t3.a=1 AND t2.b=t4.b, +t5 +LEFT JOIN +( +(t6, t7) +LEFT JOIN +t8 +ON t7.b=t8.b AND t6.b < 10 +) +ON t6.b >= 2 AND t5.b=t7.b +) +ON (t3.b=2 OR t3.c IS NULL) AND (t6.b=2 OR t6.c IS NULL) AND +(t1.b=t5.b OR t3.c IS NULL OR t6.c IS NULL or t8.c IS NULL) AND +(t1.a != 2), +t9 +WHERE t0.a=1 AND +t0.b=t1.b AND +(t2.a >= 4 OR t2.c IS NULL) AND +(t3.a < 5 OR t3.c IS NULL) AND +(t3.b=t4.b OR t3.c IS NULL OR t4.c IS NULL) AND +(t5.a >=2 OR t5.c IS NULL) AND +(t6.a >=4 OR t6.c IS NULL) AND +(t7.a <= 2 OR t7.c IS NULL) AND +(t8.a < 1 OR t8.c IS NULL) AND +(t8.b=t9.b OR t8.c IS NULL) AND +(t9.a=1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE t0 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +2 SIMPLE t9 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 55.56 Using where; Using join buffer (hash join) +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 75.00 Using where; Using join buffer (hash join) +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t5 NULL ALL NULL NULL NULL NULL 3 55.56 Using where; Using join buffer (hash join) +2 SIMPLE t7 NULL ALL NULL NULL NULL NULL 2 75.00 Using where; Using join buffer (hash join) +2 SIMPLE t6 NULL ALL NULL NULL NULL NULL 3 55.56 Using where; Using join buffer (hash join) +2 SIMPLE t8 NULL ALL NULL NULL NULL NULL 2 56.25 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a`,`test`.`t0`.`b` AS `b`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t5`.`a` AS `a`,`test`.`t5`.`b` AS `b`,`test`.`t6`.`a` AS `a`,`test`.`t6`.`b` AS `b`,`test`.`t7`.`a` AS `a`,`test`.`t7`.`b` AS `b`,`test`.`t8`.`a` AS `a`,`test`.`t8`.`b` AS `b`,`test`.`t9`.`a` AS `a`,`test`.`t9`.`b` AS `b` from `test`.`t0` join `test`.`t1` left join (`test`.`t2` left join (`test`.`t3` join `test`.`t4`) on(((`test`.`t4`.`b` = `test`.`t2`.`b`) and (`test`.`t3`.`a` = 1))) join `test`.`t5` left join (`test`.`t6` join `test`.`t7` left join `test`.`t8` on(((`test`.`t8`.`b` = `test`.`t7`.`b`) and (`test`.`t6`.`b` < 10)))) on(((`test`.`t7`.`b` = `test`.`t5`.`b`) and (`test`.`t6`.`b` >= 2)))) on((((`test`.`t3`.`b` = 2) or (`test`.`t3`.`c` is null)) and ((`test`.`t6`.`b` = 2) or (`test`.`t6`.`c` is null)) and ((`test`.`t5`.`b` = `test`.`t0`.`b`) or (`test`.`t3`.`c` is null) or (`test`.`t6`.`c` is null) or (`test`.`t8`.`c` is null)) and (`test`.`t1`.`a` <> 2))) join `test`.`t9` where ((`test`.`t9`.`a` = 1) and (`test`.`t1`.`b` = `test`.`t0`.`b`) and (`test`.`t0`.`a` = 1) and ((`test`.`t2`.`a` >= 4) or (`test`.`t2`.`c` is null)) and ((`test`.`t3`.`a` < 5) or (`test`.`t3`.`c` is null)) and ((`test`.`t4`.`b` = `test`.`t3`.`b`) or (`test`.`t3`.`c` is null) or (`test`.`t4`.`c` is null)) and ((`test`.`t5`.`a` >= 2) or (`test`.`t5`.`c` is null)) and ((`test`.`t6`.`a` >= 4) or (`test`.`t6`.`c` is null)) and ((`test`.`t7`.`a` <= 2) or (`test`.`t7`.`c` is null)) and ((`test`.`t8`.`a` < 1) or (`test`.`t8`.`c` is null)) and ((`test`.`t8`.`b` = `test`.`t9`.`b`) or (`test`.`t8`.`c` is null))) +CREATE INDEX idx_b ON t4(b); +CREATE INDEX idx_b ON t5(b); +ANALYZE TABLE t0, t1, t2, t3, t4, t5, t6, t7, t8, t9; +Table Op Msg_type Msg_text +test.t0 analyze status OK +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +test.t4 analyze status OK +test.t5 analyze status OK +test.t6 analyze status OK +test.t7 analyze status OK +test.t8 analyze status OK +test.t9 analyze status OK +EXPLAIN +SELECT t0.a,t0.b,t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b, +t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b,t9.a,t9.b +FROM t0,t1 +LEFT JOIN +( +t2 +LEFT JOIN +(t3, t4) +ON t3.a=1 AND t2.b=t4.b, +t5 +LEFT JOIN +( +(t6, t7) +LEFT JOIN +t8 +ON t7.b=t8.b AND t6.b < 10 +) +ON t6.b >= 2 AND t5.b=t7.b +) +ON (t3.b=2 OR t3.c IS NULL) AND (t6.b=2 OR t6.c IS NULL) AND +(t1.b=t5.b OR t3.c IS NULL OR t6.c IS NULL or t8.c IS NULL) AND +(t1.a != 2), +t9 +WHERE t0.a=1 AND +t0.b=t1.b AND +(t2.a >= 4 OR t2.c IS NULL) AND +(t3.a < 5 OR t3.c IS NULL) AND +(t3.b=t4.b OR t3.c IS NULL OR t4.c IS NULL) AND +(t5.a >=2 OR t5.c IS NULL) AND +(t6.a >=4 OR t6.c IS NULL) AND +(t7.a <= 2 OR t7.c IS NULL) AND +(t8.a < 1 OR t8.c IS NULL) AND +(t8.b=t9.b OR t8.c IS NULL) AND +(t9.a=1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE t0 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +2 SIMPLE t9 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 55.56 Using where; Using join buffer (hash join) +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 75.00 Using where; Using join buffer (hash join) +2 SIMPLE t4 NULL ALL idx_b NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t5 NULL ALL idx_b NULL NULL NULL 3 55.56 Using where; Using join buffer (hash join) +2 SIMPLE t7 NULL ALL NULL NULL NULL NULL 2 75.00 Using where; Using join buffer (hash join) +2 SIMPLE t6 NULL ALL NULL NULL NULL NULL 3 55.56 Using where; Using join buffer (hash join) +2 SIMPLE t8 NULL ALL NULL NULL NULL NULL 2 56.25 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a`,`test`.`t0`.`b` AS `b`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t5`.`a` AS `a`,`test`.`t5`.`b` AS `b`,`test`.`t6`.`a` AS `a`,`test`.`t6`.`b` AS `b`,`test`.`t7`.`a` AS `a`,`test`.`t7`.`b` AS `b`,`test`.`t8`.`a` AS `a`,`test`.`t8`.`b` AS `b`,`test`.`t9`.`a` AS `a`,`test`.`t9`.`b` AS `b` from `test`.`t0` join `test`.`t1` left join (`test`.`t2` left join (`test`.`t3` join `test`.`t4`) on(((`test`.`t4`.`b` = `test`.`t2`.`b`) and (`test`.`t3`.`a` = 1))) join `test`.`t5` left join (`test`.`t6` join `test`.`t7` left join `test`.`t8` on(((`test`.`t8`.`b` = `test`.`t7`.`b`) and (`test`.`t6`.`b` < 10)))) on(((`test`.`t7`.`b` = `test`.`t5`.`b`) and (`test`.`t6`.`b` >= 2)))) on((((`test`.`t3`.`b` = 2) or (`test`.`t3`.`c` is null)) and ((`test`.`t6`.`b` = 2) or (`test`.`t6`.`c` is null)) and ((`test`.`t5`.`b` = `test`.`t0`.`b`) or (`test`.`t3`.`c` is null) or (`test`.`t6`.`c` is null) or (`test`.`t8`.`c` is null)) and (`test`.`t1`.`a` <> 2))) join `test`.`t9` where ((`test`.`t9`.`a` = 1) and (`test`.`t1`.`b` = `test`.`t0`.`b`) and (`test`.`t0`.`a` = 1) and ((`test`.`t2`.`a` >= 4) or (`test`.`t2`.`c` is null)) and ((`test`.`t3`.`a` < 5) or (`test`.`t3`.`c` is null)) and ((`test`.`t4`.`b` = `test`.`t3`.`b`) or (`test`.`t3`.`c` is null) or (`test`.`t4`.`c` is null)) and ((`test`.`t5`.`a` >= 2) or (`test`.`t5`.`c` is null)) and ((`test`.`t6`.`a` >= 4) or (`test`.`t6`.`c` is null)) and ((`test`.`t7`.`a` <= 2) or (`test`.`t7`.`c` is null)) and ((`test`.`t8`.`a` < 1) or (`test`.`t8`.`c` is null)) and ((`test`.`t8`.`b` = `test`.`t9`.`b`) or (`test`.`t8`.`c` is null))) +CREATE INDEX idx_b ON t8(b); +ANALYZE TABLE t0, t1, t2, t3, t4, t5, t6, t7, t8, t9; +Table Op Msg_type Msg_text +test.t0 analyze status OK +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +test.t4 analyze status OK +test.t5 analyze status OK +test.t6 analyze status OK +test.t7 analyze status OK +test.t8 analyze status OK +test.t9 analyze status OK +EXPLAIN +SELECT t0.a,t0.b,t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b, +t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b,t9.a,t9.b +FROM t0,t1 +LEFT JOIN +( +t2 +LEFT JOIN +(t3, t4) +ON t3.a=1 AND t2.b=t4.b, +t5 +LEFT JOIN +( +(t6, t7) +LEFT JOIN +t8 +ON t7.b=t8.b AND t6.b < 10 +) +ON t6.b >= 2 AND t5.b=t7.b +) +ON (t3.b=2 OR t3.c IS NULL) AND (t6.b=2 OR t6.c IS NULL) AND +(t1.b=t5.b OR t3.c IS NULL OR t6.c IS NULL or t8.c IS NULL) AND +(t1.a != 2), +t9 +WHERE t0.a=1 AND +t0.b=t1.b AND +(t2.a >= 4 OR t2.c IS NULL) AND +(t3.a < 5 OR t3.c IS NULL) AND +(t3.b=t4.b OR t3.c IS NULL OR t4.c IS NULL) AND +(t5.a >=2 OR t5.c IS NULL) AND +(t6.a >=4 OR t6.c IS NULL) AND +(t7.a <= 2 OR t7.c IS NULL) AND +(t8.a < 1 OR t8.c IS NULL) AND +(t8.b=t9.b OR t8.c IS NULL) AND +(t9.a=1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE t0 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +2 SIMPLE t9 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 55.56 Using where; Using join buffer (hash join) +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 75.00 Using where; Using join buffer (hash join) +2 SIMPLE t4 NULL ALL idx_b NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t5 NULL ALL idx_b NULL NULL NULL 3 55.56 Using where; Using join buffer (hash join) +2 SIMPLE t7 NULL ALL NULL NULL NULL NULL 2 75.00 Using where; Using join buffer (hash join) +2 SIMPLE t6 NULL ALL NULL NULL NULL NULL 3 55.56 Using where; Using join buffer (hash join) +2 SIMPLE t8 NULL ALL idx_b NULL NULL NULL 2 75.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a`,`test`.`t0`.`b` AS `b`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t5`.`a` AS `a`,`test`.`t5`.`b` AS `b`,`test`.`t6`.`a` AS `a`,`test`.`t6`.`b` AS `b`,`test`.`t7`.`a` AS `a`,`test`.`t7`.`b` AS `b`,`test`.`t8`.`a` AS `a`,`test`.`t8`.`b` AS `b`,`test`.`t9`.`a` AS `a`,`test`.`t9`.`b` AS `b` from `test`.`t0` join `test`.`t1` left join (`test`.`t2` left join (`test`.`t3` join `test`.`t4`) on(((`test`.`t4`.`b` = `test`.`t2`.`b`) and (`test`.`t3`.`a` = 1))) join `test`.`t5` left join (`test`.`t6` join `test`.`t7` left join `test`.`t8` on(((`test`.`t8`.`b` = `test`.`t7`.`b`) and (`test`.`t6`.`b` < 10)))) on(((`test`.`t7`.`b` = `test`.`t5`.`b`) and (`test`.`t6`.`b` >= 2)))) on((((`test`.`t3`.`b` = 2) or (`test`.`t3`.`c` is null)) and ((`test`.`t6`.`b` = 2) or (`test`.`t6`.`c` is null)) and ((`test`.`t5`.`b` = `test`.`t0`.`b`) or (`test`.`t3`.`c` is null) or (`test`.`t6`.`c` is null) or (`test`.`t8`.`c` is null)) and (`test`.`t1`.`a` <> 2))) join `test`.`t9` where ((`test`.`t9`.`a` = 1) and (`test`.`t1`.`b` = `test`.`t0`.`b`) and (`test`.`t0`.`a` = 1) and ((`test`.`t2`.`a` >= 4) or (`test`.`t2`.`c` is null)) and ((`test`.`t3`.`a` < 5) or (`test`.`t3`.`c` is null)) and ((`test`.`t4`.`b` = `test`.`t3`.`b`) or (`test`.`t3`.`c` is null) or (`test`.`t4`.`c` is null)) and ((`test`.`t5`.`a` >= 2) or (`test`.`t5`.`c` is null)) and ((`test`.`t6`.`a` >= 4) or (`test`.`t6`.`c` is null)) and ((`test`.`t7`.`a` <= 2) or (`test`.`t7`.`c` is null)) and ((`test`.`t8`.`a` < 1) or (`test`.`t8`.`c` is null)) and ((`test`.`t8`.`b` = `test`.`t9`.`b`) or (`test`.`t8`.`c` is null))) +CREATE INDEX idx_b ON t1(b); +CREATE INDEX idx_a ON t0(a); +ANALYZE TABLE t0, t1, t2, t3, t4, t5, t6, t7, t8, t9; +Table Op Msg_type Msg_text +test.t0 analyze status OK +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +test.t4 analyze status OK +test.t5 analyze status OK +test.t6 analyze status OK +test.t7 analyze status OK +test.t8 analyze status OK +test.t9 analyze status OK +EXPLAIN +SELECT t0.a,t0.b,t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b, +t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b,t9.a,t9.b +FROM t0,t1 +LEFT JOIN +( +t2 +LEFT JOIN +(t3, t4) +ON t3.a=1 AND t2.b=t4.b, +t5 +LEFT JOIN +( +(t6, t7) +LEFT JOIN +t8 +ON t7.b=t8.b AND t6.b < 10 +) +ON t6.b >= 2 AND t5.b=t7.b +) +ON (t3.b=2 OR t3.c IS NULL) AND (t6.b=2 OR t6.c IS NULL) AND +(t1.b=t5.b OR t3.c IS NULL OR t6.c IS NULL or t8.c IS NULL) AND +(t1.a != 2), +t9 +WHERE t0.a=1 AND +t0.b=t1.b AND +(t2.a >= 4 OR t2.c IS NULL) AND +(t3.a < 5 OR t3.c IS NULL) AND +(t3.b=t4.b OR t3.c IS NULL OR t4.c IS NULL) AND +(t5.a >=2 OR t5.c IS NULL) AND +(t6.a >=4 OR t6.c IS NULL) AND +(t7.a <= 2 OR t7.c IS NULL) AND +(t8.a < 1 OR t8.c IS NULL) AND +(t8.b=t9.b OR t8.c IS NULL) AND +(t9.a=1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE t9 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +2 SIMPLE t1 NULL ALL idx_b NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 SIMPLE t0 NULL ref idx_a idx_a 5 const 2 33.33 Using where; Using join buffer (Batched Key Access) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 55.56 Using where; Using join buffer (hash join) +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 75.00 Using where; Using join buffer (hash join) +2 SIMPLE t4 NULL ALL idx_b NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t5 NULL ALL idx_b NULL NULL NULL 3 55.56 Using where; Using join buffer (hash join) +2 SIMPLE t7 NULL ALL NULL NULL NULL NULL 2 75.00 Using where; Using join buffer (hash join) +2 SIMPLE t6 NULL ALL NULL NULL NULL NULL 3 55.56 Using where; Using join buffer (hash join) +2 SIMPLE t8 NULL ALL idx_b NULL NULL NULL 2 75.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a`,`test`.`t0`.`b` AS `b`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t5`.`a` AS `a`,`test`.`t5`.`b` AS `b`,`test`.`t6`.`a` AS `a`,`test`.`t6`.`b` AS `b`,`test`.`t7`.`a` AS `a`,`test`.`t7`.`b` AS `b`,`test`.`t8`.`a` AS `a`,`test`.`t8`.`b` AS `b`,`test`.`t9`.`a` AS `a`,`test`.`t9`.`b` AS `b` from `test`.`t0` join `test`.`t1` left join (`test`.`t2` left join (`test`.`t3` join `test`.`t4`) on(((`test`.`t4`.`b` = `test`.`t2`.`b`) and (`test`.`t3`.`a` = 1))) join `test`.`t5` left join (`test`.`t6` join `test`.`t7` left join `test`.`t8` on(((`test`.`t8`.`b` = `test`.`t7`.`b`) and (`test`.`t6`.`b` < 10)))) on(((`test`.`t7`.`b` = `test`.`t5`.`b`) and (`test`.`t6`.`b` >= 2)))) on((((`test`.`t3`.`b` = 2) or (`test`.`t3`.`c` is null)) and ((`test`.`t6`.`b` = 2) or (`test`.`t6`.`c` is null)) and ((`test`.`t5`.`b` = `test`.`t1`.`b`) or (`test`.`t3`.`c` is null) or (`test`.`t6`.`c` is null) or (`test`.`t8`.`c` is null)) and (`test`.`t1`.`a` <> 2))) join `test`.`t9` where ((`test`.`t9`.`a` = 1) and (`test`.`t0`.`b` = `test`.`t1`.`b`) and (`test`.`t0`.`a` = 1) and ((`test`.`t2`.`a` >= 4) or (`test`.`t2`.`c` is null)) and ((`test`.`t3`.`a` < 5) or (`test`.`t3`.`c` is null)) and ((`test`.`t4`.`b` = `test`.`t3`.`b`) or (`test`.`t3`.`c` is null) or (`test`.`t4`.`c` is null)) and ((`test`.`t5`.`a` >= 2) or (`test`.`t5`.`c` is null)) and ((`test`.`t6`.`a` >= 4) or (`test`.`t6`.`c` is null)) and ((`test`.`t7`.`a` <= 2) or (`test`.`t7`.`c` is null)) and ((`test`.`t8`.`a` < 1) or (`test`.`t8`.`c` is null)) and ((`test`.`t8`.`b` = `test`.`t9`.`b`) or (`test`.`t8`.`c` is null))) +SELECT t0.a,t0.b,t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b, +t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b,t9.a,t9.b +FROM t0,t1 +LEFT JOIN +( +t2 +LEFT JOIN +(t3, t4) +ON t3.a=1 AND t2.b=t4.b, +t5 +LEFT JOIN +( +(t6, t7) +LEFT JOIN +t8 +ON t7.b=t8.b AND t6.b < 10 +) +ON t6.b >= 2 AND t5.b=t7.b +) +ON (t3.b=2 OR t3.c IS NULL) AND (t6.b=2 OR t6.c IS NULL) AND +(t1.b=t5.b OR t3.c IS NULL OR t6.c IS NULL or t8.c IS NULL) AND +(t1.a != 2), +t9 +WHERE t0.a=1 AND +t0.b=t1.b AND +(t2.a >= 4 OR t2.c IS NULL) AND +(t3.a < 5 OR t3.c IS NULL) AND +(t3.b=t4.b OR t3.c IS NULL OR t4.c IS NULL) AND +(t5.a >=2 OR t5.c IS NULL) AND +(t6.a >=4 OR t6.c IS NULL) AND +(t7.a <= 2 OR t7.c IS NULL) AND +(t8.a < 1 OR t8.c IS NULL) AND +(t8.b=t9.b OR t8.c IS NULL) AND +(t9.a=1); +a b a b a b a b a b a b a b a b a b a b +1 2 2 2 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL 1 1 +1 2 2 2 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL 1 2 +1 2 3 2 4 2 1 2 3 2 2 2 6 2 2 2 0 2 1 2 +1 2 3 2 4 2 1 2 3 2 3 1 6 2 1 1 NULL NULL 1 1 +1 2 3 2 4 2 1 2 3 2 3 1 6 2 1 1 NULL NULL 1 2 +1 2 3 2 4 2 1 2 3 2 3 3 NULL NULL NULL NULL NULL NULL 1 1 +1 2 3 2 4 2 1 2 3 2 3 3 NULL NULL NULL NULL NULL NULL 1 2 +1 2 3 2 4 2 1 2 4 2 2 2 6 2 2 2 0 2 1 2 +1 2 3 2 4 2 1 2 4 2 3 1 6 2 1 1 NULL NULL 1 1 +1 2 3 2 4 2 1 2 4 2 3 1 6 2 1 1 NULL NULL 1 2 +1 2 3 2 4 2 1 2 4 2 3 3 NULL NULL NULL NULL NULL NULL 1 1 +1 2 3 2 4 2 1 2 4 2 3 3 NULL NULL NULL NULL NULL NULL 1 2 +1 2 3 2 5 3 NULL NULL NULL NULL 2 2 6 2 2 2 0 2 1 2 +1 2 3 2 5 3 NULL NULL NULL NULL 3 1 6 2 1 1 NULL NULL 1 1 +1 2 3 2 5 3 NULL NULL NULL NULL 3 1 6 2 1 1 NULL NULL 1 2 +1 2 3 2 5 3 NULL NULL NULL NULL 3 3 NULL NULL NULL NULL NULL NULL 1 1 +1 2 3 2 5 3 NULL NULL NULL NULL 3 3 NULL NULL NULL NULL NULL NULL 1 2 +"Standard compliant copy of above query" +SELECT t0.a,t0.b,t1.a,t1.b,t2.a,t2.b,t34.a3,t34.b3,t34.a4,t34.b4, +t5.a,t5.b,t67.a6,t67.b6,t67.a7,t67.b7,t8.a,t8.b,t9.a,t9.b +FROM t0 +CROSS JOIN t1 +LEFT JOIN +( +t2 +LEFT JOIN +t34 +ON t34.a3=1 AND t2.b=t34.b4 +CROSS JOIN t5 +LEFT JOIN +( +t67 +LEFT JOIN +t8 +ON t67.b7=t8.b AND t67.b6 < 10 +) +ON t67.b6 >= 2 AND t5.b=t67.b7 +) +ON (t34.b3=2 OR t34.c3 IS NULL) AND (t67.b6=2 OR t67.c6 IS NULL) AND +(t1.b=t5.b OR t34.c3 IS NULL OR t67.c6 IS NULL or t8.c IS NULL) AND +(t1.a <> 2) +CROSS JOIN t9 +WHERE t0.a=1 AND +t0.b=t1.b AND +(t2.a >= 4 OR t2.c IS NULL) AND +(t34.a3 < 5 OR t34.c3 IS NULL) AND +(t34.b3=t34.b4 OR t34.c3 IS NULL OR t34.c4 IS NULL) AND +(t5.a >=2 OR t5.c IS NULL) AND +(t67.a6 >=4 OR t67.c6 IS NULL) AND +(t67.a7 <= 2 OR t67.c7 IS NULL) AND +(t8.a < 1 OR t8.c IS NULL) AND +(t8.b=t9.b OR t8.c IS NULL) AND +(t9.a=1); +a b a b a b a3 b3 a4 b4 a b a6 b6 a7 b7 a b a b +1 2 2 2 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL 1 1 +1 2 2 2 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL 1 2 +1 2 3 2 4 2 1 2 3 2 2 2 6 2 2 2 0 2 1 2 +1 2 3 2 4 2 1 2 3 2 3 1 6 2 1 1 NULL NULL 1 1 +1 2 3 2 4 2 1 2 3 2 3 1 6 2 1 1 NULL NULL 1 2 +1 2 3 2 4 2 1 2 3 2 3 3 NULL NULL NULL NULL NULL NULL 1 1 +1 2 3 2 4 2 1 2 3 2 3 3 NULL NULL NULL NULL NULL NULL 1 2 +1 2 3 2 4 2 1 2 4 2 2 2 6 2 2 2 0 2 1 2 +1 2 3 2 4 2 1 2 4 2 3 1 6 2 1 1 NULL NULL 1 1 +1 2 3 2 4 2 1 2 4 2 3 1 6 2 1 1 NULL NULL 1 2 +1 2 3 2 4 2 1 2 4 2 3 3 NULL NULL NULL NULL NULL NULL 1 1 +1 2 3 2 4 2 1 2 4 2 3 3 NULL NULL NULL NULL NULL NULL 1 2 +1 2 3 2 5 3 NULL NULL NULL NULL 2 2 6 2 2 2 0 2 1 2 +1 2 3 2 5 3 NULL NULL NULL NULL 3 1 6 2 1 1 NULL NULL 1 1 +1 2 3 2 5 3 NULL NULL NULL NULL 3 1 6 2 1 1 NULL NULL 1 2 +1 2 3 2 5 3 NULL NULL NULL NULL 3 3 NULL NULL NULL NULL NULL NULL 1 1 +1 2 3 2 5 3 NULL NULL NULL NULL 3 3 NULL NULL NULL NULL NULL NULL 1 2 +SELECT t2.a,t2.b +FROM t2; +a b +3 3 +4 2 +5 3 +SELECT t3.a,t3.b +FROM t3; +a b +1 2 +2 2 +SELECT t2.a,t2.b,t3.a,t3.b +FROM t2 LEFT JOIN t3 ON t2.b=t3.b +WHERE t2.a = 4 OR (t2.a > 4 AND t3.a IS NULL); +a b a b +4 2 1 2 +4 2 2 2 +5 3 NULL NULL +SELECT t2.a,t2.b,t3.a,t3.b +FROM t2 LEFT JOIN (t3) ON t2.b=t3.b +WHERE t2.a = 4 OR (t2.a > 4 AND t3.a IS NULL); +a b a b +4 2 1 2 +4 2 2 2 +5 3 NULL NULL +ALTER TABLE t3 +CHANGE COLUMN a a1 int, +CHANGE COLUMN c c1 int; +SELECT t2.a,t2.b,t3.a1,t3.b +FROM t2 LEFT JOIN t3 ON t2.b=t3.b +WHERE t2.a = 4 OR (t2.a > 4 AND t3.a1 IS NULL); +a b a1 b +4 2 1 2 +4 2 2 2 +5 3 NULL NULL +SELECT t2.a,t2.b,t3.a1,t3.b +FROM t2 NATURAL LEFT JOIN t3 +WHERE t2.a = 4 OR (t2.a > 4 AND t3.a1 IS NULL); +a b a1 b +4 2 1 2 +4 2 2 2 +5 3 NULL NULL +DROP TABLE t0,t1,t2,t3,t4,t5,t6,t7,t8,t9; +DROP TABLE t34, t345, t67; +CREATE TABLE t1 (a int); +CREATE TABLE t2 (a int); +CREATE TABLE t3 (a int); +INSERT INTO t1 VALUES (1); +INSERT INTO t2 VALUES (2); +INSERT INTO t3 VALUES (2); +INSERT INTO t1 VALUES (2); +SELECT * FROM t1 LEFT JOIN (t2 LEFT JOIN t3 ON t2.a=t3.a) ON t1.a=t3.a; +a a a +1 NULL NULL +2 2 2 +SELECT * FROM t1 LEFT JOIN t2 LEFT JOIN t3 ON t2.a=t3.a ON t1.a=t3.a; +a a a +1 NULL NULL +2 2 2 +DELETE FROM t1 WHERE a=2; +SELECT * FROM t1 LEFT JOIN t2 LEFT JOIN t3 ON t2.a=t3.a ON t1.a=t3.a; +a a a +1 NULL NULL +DELETE FROM t2; +SELECT * FROM t1 LEFT JOIN t2 LEFT JOIN t3 ON t2.a=t3.a ON t1.a=t3.a; +a a a +1 NULL NULL +DROP TABLE t1,t2,t3; +CREATE TABLE t1(a int, key (a)); +CREATE TABLE t2(b int, key (b)); +CREATE TABLE t3(c int, key (c)); +INSERT INTO t1 VALUES (NULL), (0), (1), (2), (3), (4), (5), (6), (7), (8), (9), +(10), (11), (12), (13), (14), (15), (16), (17), (18), (19); +INSERT INTO t2 VALUES (NULL), (0), (1), (2), (3), (4), (5), (6), (7), (8), (9), +(10), (11), (12), (13), (14), (15), (16), (17), (18), (19); +INSERT INTO t3 VALUES (0), (1), (2), (3), (4), (5); +ANALYZE TABLE t1, t2, t3; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +EXPLAIN SELECT a, b, c FROM t1 LEFT JOIN (t2, t3) ON c < 3 and b = c; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 21 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL a 5 NULL 21 100.00 Using index +2 SIMPLE t3 NULL index c c 5 NULL 6 100.00 Using where; Using index +2 SIMPLE t2 NULL ref b b 5 test.t3.c 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`c` AS `c` from `test`.`t1` left join (`test`.`t2` join `test`.`t3`) on(((`test`.`t2`.`b` = `test`.`t3`.`c`) and (`test`.`t3`.`c` < 3))) where true +EXPLAIN SELECT a, b, c FROM t1 LEFT JOIN (t2, t3) ON b < 3 and b = c; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 21 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL a 5 NULL 21 100.00 Using index +2 SIMPLE t3 NULL index c c 5 NULL 6 100.00 Using where; Using index +2 SIMPLE t2 NULL ref b b 5 test.t3.c 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`c` AS `c` from `test`.`t1` left join (`test`.`t2` join `test`.`t3`) on(((`test`.`t2`.`b` = `test`.`t3`.`c`) and (`test`.`t3`.`c` < 3))) where true +SELECT a, b, c FROM t1 LEFT JOIN (t2, t3) ON b < 3 and b = c; +a b c +0 0 0 +0 1 1 +0 2 2 +1 0 0 +1 1 1 +1 2 2 +10 0 0 +10 1 1 +10 2 2 +11 0 0 +11 1 1 +11 2 2 +12 0 0 +12 1 1 +12 2 2 +13 0 0 +13 1 1 +13 2 2 +14 0 0 +14 1 1 +14 2 2 +15 0 0 +15 1 1 +15 2 2 +16 0 0 +16 1 1 +16 2 2 +17 0 0 +17 1 1 +17 2 2 +18 0 0 +18 1 1 +18 2 2 +19 0 0 +19 1 1 +19 2 2 +2 0 0 +2 1 1 +2 2 2 +3 0 0 +3 1 1 +3 2 2 +4 0 0 +4 1 1 +4 2 2 +5 0 0 +5 1 1 +5 2 2 +6 0 0 +6 1 1 +6 2 2 +7 0 0 +7 1 1 +7 2 2 +8 0 0 +8 1 1 +8 2 2 +9 0 0 +9 1 1 +9 2 2 +NULL 0 0 +NULL 1 1 +NULL 2 2 +DELETE FROM t3; +ANALYZE TABLE t3; +Table Op Msg_type Msg_text +test.t3 analyze status OK +EXPLAIN SELECT a, b, c FROM t1 LEFT JOIN (t2, t3) ON b < 3 and b = c; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 21 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL a 5 NULL 21 100.00 Using index +2 SIMPLE t3 NULL index c c 5 NULL 1 100.00 Using where; Using index +2 SIMPLE t2 NULL ref b b 5 test.t3.c 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`c` AS `c` from `test`.`t1` left join (`test`.`t2` join `test`.`t3`) on(((`test`.`t2`.`b` = `test`.`t3`.`c`) and (`test`.`t3`.`c` < 3))) where true +SELECT a, b, c FROM t1 LEFT JOIN (t2, t3) ON b < 3 and b = c; +a b c +0 NULL NULL +1 NULL NULL +10 NULL NULL +11 NULL NULL +12 NULL NULL +13 NULL NULL +14 NULL NULL +15 NULL NULL +16 NULL NULL +17 NULL NULL +18 NULL NULL +19 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 NULL NULL +7 NULL NULL +8 NULL NULL +9 NULL NULL +NULL NULL NULL +DROP TABLE t1,t2,t3; +CREATE TABLE t1 (c11 int); +CREATE TABLE t2 (c21 int); +CREATE TABLE t3 (c31 int); +INSERT INTO t1 VALUES (4), (5); +ANALYZE TABLE t1, t2, t3; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +SELECT * FROM t1 LEFT JOIN t2 ON c11=c21; +c11 c21 +4 NULL +5 NULL +EXPLAIN SELECT * FROM t1 LEFT JOIN t2 ON c11=c21; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c11` AS `c11`,`test`.`t2`.`c21` AS `c21` from `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`c21` = `test`.`t1`.`c11`)) where true +SELECT * FROM t1 LEFT JOIN (t2 LEFT JOIN t3 ON c21=c31) ON c11=c21; +c11 c21 c31 +4 NULL NULL +5 NULL NULL +EXPLAIN SELECT * FROM t1 LEFT JOIN (t2 LEFT JOIN t3 ON c21=c31) ON c11=c21; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c11` AS `c11`,`test`.`t2`.`c21` AS `c21`,`test`.`t3`.`c31` AS `c31` from `test`.`t1` left join (`test`.`t2` left join `test`.`t3` on((`test`.`t3`.`c31` = `test`.`t2`.`c21`))) on((`test`.`t2`.`c21` = `test`.`t1`.`c11`)) where true +DROP TABLE t1,t2,t3; +CREATE TABLE t1 (goods int(12) NOT NULL, price varchar(128) NOT NULL); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (23, 2340), (26, 9900); +CREATE TABLE t2 (goods int(12), name varchar(50), shop char(2)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (23, 'as300', 'fr'), (26, 'as600', 'fr'); +create table t3 (groupid int(12) NOT NULL, goodsid int(12) NOT NULL); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t3 VALUES (3,23), (6,26); +CREATE TABLE t4 (groupid int(12)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t4 VALUES (1), (2), (3), (4), (5), (6); +SELECT * FROM +(SELECT DISTINCT gl.groupid, gp.price +FROM t4 gl +LEFT JOIN +(t3 g INNER JOIN t2 p ON g.goodsid = p.goods +INNER JOIN t1 gp ON p.goods = gp.goods) +ON gl.groupid = g.groupid and p.shop = 'fr') t; +groupid price +1 NULL +2 NULL +3 2340 +4 NULL +5 NULL +6 9900 +CREATE VIEW v1 AS +SELECT g.groupid groupid, p.goods goods, +p.name name, p.shop shop, +gp.price price +FROM t3 g INNER JOIN t2 p ON g.goodsid = p.goods +INNER JOIN t1 gp on p.goods = gp.goods; +CREATE VIEW v2 AS +SELECT DISTINCT g.groupid, fr.price +FROM t4 g +LEFT JOIN +v1 fr on g.groupid = fr.groupid and fr.shop = 'fr'; +SELECT * FROM v2; +groupid price +1 NULL +2 NULL +3 2340 +4 NULL +5 NULL +6 9900 +SELECT * FROM +(SELECT DISTINCT g.groupid, fr.price +FROM t4 g +LEFT JOIN +v1 fr on g.groupid = fr.groupid and fr.shop = 'fr') t; +groupid price +1 NULL +2 NULL +3 2340 +4 NULL +5 NULL +6 9900 +DROP VIEW v1,v2; +DROP TABLE t1,t2,t3,t4; +CREATE TABLE t1(a int); +CREATE TABLE t2(b int); +CREATE TABLE t3(c int, d int); +CREATE TABLE t4(d int); +CREATE TABLE t5(e int, f int); +CREATE TABLE t6(f int); +CREATE VIEW v1 AS +SELECT e FROM t5 JOIN t6 ON t5.e=t6.f; +CREATE VIEW v2 AS +SELECT e FROM t5 NATURAL JOIN t6; +SELECT t1.a FROM t1 JOIN t2 ON a=b JOIN t3 ON a=c JOIN t4 USING(d); +a +SELECT t1.x FROM t1 JOIN t2 ON a=b JOIN t3 ON a=c JOIN t4 USING(d); +ERROR 42S22: Unknown column 't1.x' in 'field list' +SELECT t1.a FROM t1 JOIN t2 ON a=b JOIN t3 ON a=c NATURAL JOIN t4; +a +SELECT t1.x FROM t1 JOIN t2 ON a=b JOIN t3 ON a=c NATURAL JOIN t4; +ERROR 42S22: Unknown column 't1.x' in 'field list' +SELECT v1.e FROM v1 JOIN t2 ON e=b JOIN t3 ON e=c JOIN t4 USING(d); +e +SELECT v1.x FROM v1 JOIN t2 ON e=b JOIN t3 ON e=c JOIN t4 USING(d); +ERROR 42S22: Unknown column 'v1.x' in 'field list' +SELECT v2.e FROM v2 JOIN t2 ON e=b JOIN t3 ON e=c JOIN t4 USING(d); +e +SELECT v2.x FROM v2 JOIN t2 ON e=b JOIN t3 ON e=c JOIN t4 USING(d); +ERROR 42S22: Unknown column 'v2.x' in 'field list' +DROP VIEW v1, v2; +DROP TABLE t1, t2, t3, t4, t5, t6; +create table t1 (id1 int(11) not null); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t1 values (1),(2); +create table t2 (id2 int(11) not null); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t2 values (1),(2),(3),(4); +create table t3 (id3 char(16) not null); +insert into t3 values ('100'); +create table t4 (id2 int(11) not null, id3 char(16)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +create table t5 (id1 int(11) not null, key (id1)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t5 values (1),(2),(1); +create view v1 as +select t4.id3 from t4 join t2 on t4.id2 = t2.id2; +select t1.id1 from t1 inner join (t3 left join v1 on t3.id3 = v1.id3); +id1 +1 +2 +drop view v1; +drop table t1, t2, t3, t4, t5; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3); +create table t1(a int); +insert into t1 select A.a + 10*(B.a) from t0 A, t0 B; +create table t2 (a int, b int); +insert into t2 values (1,1), (2,2), (3,3); +create table t3(a int, b int, filler char(200), key(a)); +insert into t3 select a,a,'filler' from t1; +insert into t3 select a,a,'filler' from t1; +create table t4 like t3; +insert into t4 select * from t3; +insert into t4 select * from t3; +create table t5 like t4; +insert into t5 select * from t4; +insert into t5 select * from t4; +create table t6 like t5; +insert into t6 select * from t5; +insert into t6 select * from t5; +create table t7 like t6; +insert into t7 select * from t6; +insert into t7 select * from t6; +ANALYZE TABLE t1, t2, t3, t4, t5, t6, t7; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +test.t4 analyze status OK +test.t5 analyze status OK +test.t6 analyze status OK +test.t7 analyze status OK +explain select * from t4 join +t2 left join (t3 join t5 on t5.a=t3.b) on t3.a=t2.b where t4.a<=>t3.b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL X 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL X 100.00 NULL +2 SIMPLE t3 NULL ref a a 5 test.t2.b X 100.00 Using join buffer (Batched Key Access) +2 SIMPLE t5 NULL ref a a 5 test.t3.b X 100.00 Using join buffer (Batched Key Access) +2 SIMPLE t4 NULL ref a a 5 test.t3.b X 100.00 Using index condition; Using join buffer (Batched Key Access) +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t4`.`filler` AS `filler`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t3`.`filler` AS `filler`,`test`.`t5`.`a` AS `a`,`test`.`t5`.`b` AS `b`,`test`.`t5`.`filler` AS `filler` from `test`.`t4` join `test`.`t2` left join (`test`.`t3` join `test`.`t5`) on(((`test`.`t5`.`a` = `test`.`t3`.`b`) and (`test`.`t3`.`a` = `test`.`t2`.`b`))) where (`test`.`t4`.`a` <=> `test`.`t3`.`b`) +explain select * from (t4 join t6 on t6.a=t4.b) right join t3 on t4.a=t3.b +join t2 left join (t5 join t7 on t7.a=t5.b) on t5.a=t2.b where t3.a<=>t2.b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL X 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL X 100.00 NULL +2 SIMPLE t3 NULL ref a a 5 test.t2.b X 100.00 Using index condition; Using join buffer (Batched Key Access) +2 SIMPLE t4 NULL ref a a 5 test.t3.b X 100.00 Using join buffer (Batched Key Access) +2 SIMPLE t6 NULL ref a a 5 test.t4.b X 100.00 Using join buffer (Batched Key Access) +2 SIMPLE t5 NULL ref a a 5 test.t2.b X 100.00 Using join buffer (Batched Key Access) +2 SIMPLE t7 NULL ref a a 5 test.t5.b X 100.00 Using join buffer (Batched Key Access) +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t4`.`filler` AS `filler`,`test`.`t6`.`a` AS `a`,`test`.`t6`.`b` AS `b`,`test`.`t6`.`filler` AS `filler`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t3`.`filler` AS `filler`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t5`.`a` AS `a`,`test`.`t5`.`b` AS `b`,`test`.`t5`.`filler` AS `filler`,`test`.`t7`.`a` AS `a`,`test`.`t7`.`b` AS `b`,`test`.`t7`.`filler` AS `filler` from `test`.`t3` left join (`test`.`t4` join `test`.`t6`) on(((`test`.`t6`.`a` = `test`.`t4`.`b`) and (`test`.`t4`.`a` = `test`.`t3`.`b`))) join `test`.`t2` left join (`test`.`t5` join `test`.`t7`) on(((`test`.`t7`.`a` = `test`.`t5`.`b`) and (`test`.`t5`.`a` = `test`.`t2`.`b`))) where (`test`.`t3`.`a` <=> `test`.`t2`.`b`) +explain select * from t2 left join +(t3 left join (t4 join t6 on t6.a=t4.b) on t4.a=t3.b +join t5 on t5.a=t3.b) on t3.a=t2.b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL X 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL X 100.00 NULL +2 SIMPLE t3 NULL ref a a 5 test.t2.b X 100.00 Using join buffer (Batched Key Access) +2 SIMPLE t5 NULL ref a a 5 test.t3.b X 100.00 Using join buffer (Batched Key Access) +2 SIMPLE t4 NULL ref a a 5 test.t5.a X 100.00 Using where; Using join buffer (Batched Key Access) +2 SIMPLE t6 NULL ref a a 5 test.t4.b X 100.00 Using join buffer (Batched Key Access) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t3`.`filler` AS `filler`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t4`.`filler` AS `filler`,`test`.`t6`.`a` AS `a`,`test`.`t6`.`b` AS `b`,`test`.`t6`.`filler` AS `filler`,`test`.`t5`.`a` AS `a`,`test`.`t5`.`b` AS `b`,`test`.`t5`.`filler` AS `filler` from `test`.`t2` left join (`test`.`t3` left join (`test`.`t4` join `test`.`t6`) on(((`test`.`t6`.`a` = `test`.`t4`.`b`) and (`test`.`t4`.`a` = `test`.`t3`.`b`))) join `test`.`t5`) on(((`test`.`t5`.`a` = `test`.`t3`.`b`) and (`test`.`t3`.`a` = `test`.`t2`.`b`))) where true +drop table t0, t1, t2, t3, t4, t5, t6, t7; +create table t1 (a int); +insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t2 (a int, filler char(100), key(a)); +insert into t2 select A.a + 10*B.a, '' from t1 A, t1 B; +create table t3 like t2; +insert into t3 select * from t2; +ANALYZE TABLE t1, t2, t3; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +explain select * from t1 left join +(t2 left join t3 on (t2.a = t3.a)) +on (t1.a = t2.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 100.00 NULL +2 SIMPLE t2 NULL ref a a 5 test.t1.a 1 100.00 Using join buffer (Batched Key Access) +2 SIMPLE t3 NULL ref a a 5 test.t1.a 1 100.00 Using join buffer (Batched Key Access) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`filler` AS `filler`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`filler` AS `filler` from `test`.`t1` left join (`test`.`t2` left join `test`.`t3` on((`test`.`t3`.`a` = `test`.`t1`.`a`))) on((`test`.`t2`.`a` = `test`.`t1`.`a`)) where true +drop table t1, t2, t3; +CREATE TABLE t1 (id int NOT NULL PRIMARY KEY, type varchar(10)); +CREATE TABLE t2 (pid int NOT NULL PRIMARY KEY, type varchar(10)); +CREATE TABLE t3 (cid int NOT NULL PRIMARY KEY, +id int NOT NULL, +pid int NOT NULL); +INSERT INTO t1 VALUES (1, 'A'), (3, 'C'); +INSERT INTO t2 VALUES (1, 'A'), (3, 'C'); +INSERT INTO t3 VALUES (1, 1, 1), (3, 3, 3); +SELECT * FROM t1 p LEFT JOIN (t3 JOIN t1) +ON (t1.id=t3.id AND t1.type='B' AND p.id=t3.id) +LEFT JOIN t2 ON (t3.pid=t2.pid) +WHERE p.id=1; +id type cid id pid id type pid type +1 A NULL NULL NULL NULL NULL NULL NULL +CREATE VIEW v1 AS +SELECT t3.* FROM t3 JOIN t1 ON t1.id=t3.id AND t1.type='B'; +SELECT * FROM t1 p LEFT JOIN v1 ON p.id=v1.id +LEFT JOIN t2 ON v1.pid=t2.pid +WHERE p.id=1; +id type cid id pid pid type +1 A NULL NULL NULL NULL NULL +DROP VIEW v1; +DROP TABLE t1,t2,t3; +CREATE TABLE t1 (id1 int PRIMARY KEY, id2 int); +CREATE TABLE t2 (id1 int PRIMARY KEY, id2 int); +CREATE TABLE t3 (id1 int PRIMARY KEY, id2 int); +CREATE TABLE t4 (id1 int PRIMARY KEY, id2 int); +CREATE TABLE t5 (id1 int PRIMARY KEY, id2 int); +SELECT t1.id1 AS id, t5.id1 AS ngroupbynsa +FROM t1 INNER JOIN t2 ON t2.id2 = t1.id1 +LEFT OUTER JOIN +(t3 INNER JOIN t4 ON t4.id1 = t3.id2 INNER JOIN t5 ON t4.id2 = t5.id1) +ON t3.id2 IS NOT NULL +WHERE t1.id1=2; +id ngroupbynsa +PREPARE stmt FROM +"SELECT t1.id1 AS id, t5.id1 AS ngroupbynsa + FROM t1 INNER JOIN t2 ON t2.id2 = t1.id1 + LEFT OUTER JOIN + (t3 INNER JOIN t4 ON t4.id1 = t3.id2 INNER JOIN t5 ON t4.id2 = t5.id1) + ON t3.id2 IS NOT NULL + WHERE t1.id1=2"; +EXECUTE stmt; +id ngroupbynsa +EXECUTE stmt; +id ngroupbynsa +EXECUTE stmt; +id ngroupbynsa +EXECUTE stmt; +id ngroupbynsa +INSERT INTO t1 VALUES (1,1), (2,1), (3,2); +INSERT INTO t2 VALUES (2,1), (3,2), (4,3); +INSERT INTO t3 VALUES (1,1), (3,2), (2,NULL); +INSERT INTO t4 VALUES (1,1), (2,1), (3,3); +INSERT INTO t5 VALUES (1,1), (2,2), (3,3), (4,3); +EXECUTE stmt; +id ngroupbynsa +2 1 +2 1 +EXECUTE stmt; +id ngroupbynsa +2 1 +2 1 +EXECUTE stmt; +id ngroupbynsa +2 1 +2 1 +EXECUTE stmt; +id ngroupbynsa +2 1 +2 1 +SELECT t1.id1 AS id, t5.id1 AS ngroupbynsa +FROM t1 INNER JOIN t2 ON t2.id2 = t1.id1 +LEFT OUTER JOIN +(t3 INNER JOIN t4 ON t4.id1 = t3.id2 INNER JOIN t5 ON t4.id2 = t5.id1) +ON t3.id2 IS NOT NULL +WHERE t1.id1=2; +id ngroupbynsa +2 1 +2 1 +DROP TABLE t1,t2,t3,t4,t5; +CREATE TABLE t1 ( +id int NOT NULL PRIMARY KEY, +ct int DEFAULT NULL, +pc int DEFAULT NULL, +INDEX idx_ct (ct), +INDEX idx_pc (pc) +); +INSERT INTO t1 VALUES +(1,NULL,NULL),(2,NULL,NULL),(3,NULL,NULL),(4,NULL,NULL),(5,NULL,NULL); +CREATE TABLE t2 ( +id int NOT NULL PRIMARY KEY, +sr int NOT NULL, +nm varchar(255) NOT NULL, +INDEX idx_sr (sr) +); +INSERT INTO t2 VALUES +(2441905,4308,'LesAbymes'),(2441906,4308,'Anse-Bertrand'); +CREATE TABLE t3 ( +id int NOT NULL PRIMARY KEY, +ct int NOT NULL, +ln int NOT NULL, +INDEX idx_ct (ct), +INDEX idx_ln (ln) +); +CREATE TABLE t4 ( +id int NOT NULL PRIMARY KEY, +nm varchar(255) NOT NULL +); +INSERT INTO t4 VALUES (4308,'Guadeloupe'),(4309,'Martinique'); +SELECT t1.* +FROM t1 LEFT JOIN +(t2 LEFT JOIN t3 ON t3.ct=t2.id AND t3.ln='5') ON t1.ct=t2.id +WHERE t1.id='5'; +id ct pc +5 NULL NULL +SELECT t1.*, t4.nm +FROM t1 LEFT JOIN +(t2 LEFT JOIN t3 ON t3.ct=t2.id AND t3.ln='5') ON t1.ct=t2.id +LEFT JOIN t4 ON t2.sr=t4.id +WHERE t1.id='5'; +id ct pc nm +5 NULL NULL NULL +DROP TABLE t1,t2,t3,t4; +CREATE TABLE t1 (a INT, b INT); +CREATE TABLE t2 (a INT); +CREATE TABLE t3 (a INT, c INT); +CREATE TABLE t4 (a INT, c INT); +CREATE TABLE t5 (a INT, c INT); +SELECT b FROM t1 JOIN (t2 LEFT JOIN t3 USING (a) LEFT JOIN t4 USING (a) +LEFT JOIN t5 USING (a)) USING (a); +b +SELECT c FROM t1 JOIN (t2 LEFT JOIN t3 USING (a) LEFT JOIN t4 USING (a) +LEFT JOIN t5 USING (a)) USING (a); +ERROR 23000: Column 'c' in field list is ambiguous +SELECT b FROM t1 JOIN (t2 JOIN t3 USING (a) JOIN t4 USING (a) +JOIN t5 USING (a)) USING (a); +b +SELECT c FROM t1 JOIN (t2 JOIN t3 USING (a) JOIN t4 USING (a) +JOIN t5 USING (a)) USING (a); +ERROR 23000: Column 'c' in field list is ambiguous +DROP TABLE t1,t2,t3,t4,t5; +CREATE TABLE t1 (a INT, b INT); +CREATE TABLE t2 (a INT, b INT); +CREATE TABLE t3 (a INT, b INT); +INSERT INTO t1 VALUES (1,1); +INSERT INTO t2 VALUES (1,1); +INSERT INTO t3 VALUES (1,1); +SELECT * FROM t1 JOIN (t2 JOIN t3 USING (b)) USING (a); +ERROR 23000: Column 'a' in from clause is ambiguous +DROP TABLE t1,t2,t3; +CREATE TABLE t1 ( +carrier char(2) default NULL, +id int NOT NULL auto_increment PRIMARY KEY +) CHARSET utf8mb4; +INSERT INTO t1 VALUES +('CO',235371754),('CO',235376554),('CO',235376884),('CO',235377874), +('CO',231060394),('CO',231059224),('CO',231059314),('CO',231060484), +('CO',231060274),('CO',231060124),('CO',231060244),('CO',231058594), +('CO',231058924),('CO',231058504),('CO',231059344),('CO',231060424), +('CO',231059554),('CO',231060304),('CO',231059644),('CO',231059464), +('CO',231059764),('CO',231058294),('CO',231058624),('CO',231058864), +('CO',231059374),('CO',231059584),('CO',231059734),('CO',231059014), +('CO',231059854),('CO',231059494),('CO',231059794),('CO',231058534), +('CO',231058324),('CO',231058684),('CO',231059524),('CO',231059974); +CREATE TABLE t2 ( +scan_date date default NULL, +package_id int default NULL, +INDEX scan_date(scan_date), +INDEX package_id(package_id) +); +INSERT INTO t2 VALUES +('2008-12-29',231062944),('2008-12-29',231065764),('2008-12-29',231066124), +('2008-12-29',231060094),('2008-12-29',231061054),('2008-12-29',231065644), +('2008-12-29',231064384),('2008-12-29',231064444),('2008-12-29',231073774), +('2008-12-29',231058594),('2008-12-29',231059374),('2008-12-29',231066004), +('2008-12-29',231068494),('2008-12-29',231070174),('2008-12-29',231071884), +('2008-12-29',231063274),('2008-12-29',231063754),('2008-12-29',231064144), +('2008-12-29',231069424),('2008-12-29',231073714),('2008-12-29',231058414), +('2008-12-29',231060994),('2008-12-29',231069154),('2008-12-29',231068614), +('2008-12-29',231071464),('2008-12-29',231074014),('2008-12-29',231059614), +('2008-12-29',231059074),('2008-12-29',231059464),('2008-12-29',231069094), +('2008-12-29',231067294),('2008-12-29',231070144),('2008-12-29',231073804), +('2008-12-29',231072634),('2008-12-29',231058294),('2008-12-29',231065344), +('2008-12-29',231066094),('2008-12-29',231069034),('2008-12-29',231058594), +('2008-12-29',231059854),('2008-12-29',231059884),('2008-12-29',231059914), +('2008-12-29',231063664),('2008-12-29',231063814),('2008-12-29',231063904); +CREATE TABLE t3 ( +package_id int default NULL, +INDEX package_id(package_id) +); +INSERT INTO t3 VALUES +(231058294),(231058324),(231058354),(231058384),(231058414),(231058444), +(231058474),(231058504),(231058534),(231058564),(231058594),(231058624), +(231058684),(231058744),(231058804),(231058864),(231058924),(231058954), +(231059014),(231059074),(231059104),(231059134),(231059164),(231059194), +(231059224),(231059254),(231059284),(231059314),(231059344),(231059374), +(231059404),(231059434),(231059464),(231059494),(231059524),(231059554), +(231059584),(231059614),(231059644),(231059674),(231059704),(231059734), +(231059764),(231059794),(231059824),(231059854),(231059884),(231059914), +(231059944),(231059974),(231060004),(231060034),(231060064),(231060094), +(231060124),(231060154),(231060184),(231060214),(231060244),(231060274), +(231060304),(231060334),(231060364),(231060394),(231060424),(231060454), +(231060484),(231060514),(231060544),(231060574),(231060604),(231060634), +(231060664),(231060694),(231060724),(231060754),(231060784),(231060814), +(231060844),(231060874),(231060904),(231060934),(231060964),(231060994), +(231061024),(231061054),(231061084),(231061144),(231061174),(231061204), +(231061234),(231061294),(231061354),(231061384),(231061414),(231061474), +(231061564),(231061594),(231061624),(231061684),(231061714),(231061774), +(231061804),(231061894),(231061984),(231062074),(231062134),(231062224), +(231062254),(231062314),(231062374),(231062434),(231062494),(231062554), +(231062584),(231062614),(231062644),(231062704),(231062734),(231062794), +(231062854),(231062884),(231062944),(231063004),(231063034),(231063064), +(231063124),(231063154),(231063184),(231063214),(231063274),(231063334), +(231063394),(231063424),(231063454),(231063514),(231063574),(231063664); +CREATE TABLE t4 ( +carrier char(2) NOT NULL default '' PRIMARY KEY, +id int(11) default NULL, +INDEX id(id) +) CHARSET utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t4 VALUES +('99',6),('SK',456),('UA',486),('AI',1081),('OS',1111),('VS',1510); +CREATE TABLE t5 ( +carrier_id int default NULL, +INDEX carrier_id(carrier_id) +); +INSERT INTO t5 VALUES +(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6), +(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6), +(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6), +(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6), +(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6), +(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(456),(456),(456), +(456),(456),(456),(456),(456),(456),(456),(456),(456),(456),(456),(456), +(456),(486),(1081),(1111),(1111),(1111),(1111),(1510); +ANALYZE TABLE t1, t2, t3, t4, t5; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +test.t4 analyze status OK +test.t5 analyze status OK +SELECT COUNT(*) +FROM((t2 JOIN t1 ON t2.package_id = t1.id) +JOIN t3 ON t3.package_id = t1.id); +COUNT(*) +6 +EXPLAIN +SELECT COUNT(*) +FROM ((t2 JOIN t1 ON t2.package_id = t1.id) +JOIN t3 ON t3.package_id = t1.id) +LEFT JOIN +(t5 JOIN t4 ON t5.carrier_id = t4.id) +ON t4.carrier = t1.carrier; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 45 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL index package_id package_id 5 NULL 45 100.00 Using where; Using index +2 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.package_id 1 100.00 NULL +2 SIMPLE t4 NULL eq_ref PRIMARY,id PRIMARY 8 test.t1.carrier 1 100.00 NULL +2 SIMPLE t5 NULL ref carrier_id carrier_id 5 test.t4.id 22 100.00 Using index +2 SIMPLE t3 NULL ref package_id package_id 5 test.t2.package_id 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t2` join `test`.`t1` join `test`.`t3` left join (`test`.`t5` join `test`.`t4`) on(((`test`.`t5`.`carrier_id` = `test`.`t4`.`id`) and (`test`.`t4`.`carrier` = `test`.`t1`.`carrier`))) where ((`test`.`t1`.`id` = `test`.`t2`.`package_id`) and (`test`.`t3`.`package_id` = `test`.`t2`.`package_id`)) +SELECT COUNT(*) +FROM ((t2 JOIN t1 ON t2.package_id = t1.id) +JOIN t3 ON t3.package_id = t1.id) +LEFT JOIN +(t5 JOIN t4 ON t5.carrier_id = t4.id) +ON t4.carrier = t1.carrier; +COUNT(*) +6 +DROP TABLE t1,t2,t3,t4,t5; +End of 5.0 tests +# +# Bug#24909223: EXCESSIVE MEMORY USAGE BY QUERY +# +CREATE TABLE t ( +a INT, +b CHAR(255), +c CHAR(255), +d INT, +e INT, +PRIMARY KEY (e), +KEY (d) +) ENGINE=InnoDB; +INSERT INTO t VALUES +(1, '14effca2', 'cffa3819', 98927, 8767), +(1, '2f7cbd33', '421aff88', 87613, 70956), +(1, '5c44507d', '05fd27d3', 36002, 5146), +(1, '6542ee43', 'c09ee30f', 3673, 91467), +(1, '786737dd', '6ac95ccb', 46890, 62953), +(1, '8929d195', '64102e63', 50531, 9712), +(1, '8cc0c106', '17283316', 16399, 26119), +(1, '8f3063de', 'ce5d0f35', 21769, 76667), +(1, 'c32c9202', 'c9525fe8', 12704, 43998), +(1, 'c5567e1c', 'bc2e97e6', 85805, 84174), +(1, 'c7acb4d4', '6d67fea7', 58347, 51235), +(1, 'dbd66341', '03b59a03', 46577, 52495), +(1, 'f8e0354e', '41a6e523', 36055, 32646), +(1, 'fb66b513', '10f3de43', 41297, 74334), +(1, 'ffec6d1b', '2fca4073', 12896, 95807), +(1, 'aa3fcff8', 'f4981ed8', 99211, 18778); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +EXPLAIN SELECT a.c AS c FROM ( +SELECT a.c AS c FROM ( +SELECT a.a AS c FROM t AS a +INNER JOIN t AS b ON a.b > b.b +) AS a +INNER JOIN t AS b ON a.c >= b.a +) AS a +INNER JOIN t AS b ON a.c >= b.d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 16 100.00 Parallel execute (1 workers) +2 SIMPLE a NULL ALL NULL NULL NULL NULL 16 100.00 NULL +2 SIMPLE b NULL ALL NULL NULL NULL NULL 16 33.33 Using where; Using join buffer (hash join) +2 SIMPLE b NULL ALL NULL NULL NULL NULL 16 33.33 Using where; Using join buffer (hash join) +2 SIMPLE b NULL ALL d NULL NULL NULL 16 33.33 Range checked for each record (index map: 0x2) +Warnings: +Note 1003 /* select#1 */ select `test`.`a`.`a` AS `c` from `test`.`t` `a` join `test`.`t` `b` join `test`.`t` `b` join `test`.`t` `b` where ((`test`.`a`.`a` >= `test`.`b`.`d`) and (`test`.`a`.`a` >= `test`.`b`.`a`) and (`test`.`a`.`b` > `test`.`b`.`b`)) +TRUNCATE TABLE performance_schema.memory_summary_by_thread_by_event_name; +SELECT a.c AS c FROM ( +SELECT a.c AS c FROM ( +SELECT a.a AS c FROM t AS a +INNER JOIN t AS b ON a.b > b.b +) AS a +INNER JOIN t AS b ON a.c >= b.a +) AS a +INNER JOIN t AS b ON a.c >= b.d; +c +SELECT * FROM performance_schema.memory_summary_by_thread_by_event_name +WHERE event_name = 'memory/sql/thd::main_mem_root' +AND thread_id = ps_thread_id(connection_id()) +AND sum_number_of_bytes_alloc > 1000000 +DROP TABLE t; +CREATE TABLE t5 (a int, b int, c int, PRIMARY KEY(a), KEY b_i (b)); +CREATE TABLE t6 (a int, b int, c int, PRIMARY KEY(a), KEY b_i (b)); +CREATE TABLE t7 (a int, b int, c int, PRIMARY KEY(a), KEY b_i (b)); +CREATE TABLE t8 (a int, b int, c int, PRIMARY KEY(a), KEY b_i (b)); +INSERT INTO t5 VALUES (1,1,0), (2,2,0), (3,3,0); +INSERT INTO t6 VALUES (1,2,0), (3,2,0), (6,1,0); +INSERT INTO t7 VALUES (1,1,0), (2,2,0); +INSERT INTO t8 VALUES (0,2,0), (1,2,0); +ANALYZE TABLE t5, t6, t7, t8; +Table Op Msg_type Msg_text +test.t5 analyze status OK +test.t6 analyze status OK +test.t7 analyze status OK +test.t8 analyze status OK +EXPLAIN +SELECT t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b +FROM t5 +LEFT JOIN +( +(t6, t7) +LEFT JOIN +t8 +ON t7.b=t8.b AND t6.b < 10 +) +ON t6.b >= 2 AND t5.b=t7.b AND +(t8.a > 0 OR t8.c IS NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t5 NULL index NULL b_i 5 NULL 3 100.00 Using index +2 SIMPLE t7 NULL ref b_i b_i 5 test.t5.b 1 100.00 Using index +2 SIMPLE t6 NULL index b_i b_i 5 NULL 3 100.00 Using where; Using index +2 SIMPLE t8 NULL ALL b_i NULL NULL NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t5`.`a` AS `a`,`test`.`t5`.`b` AS `b`,`test`.`t6`.`a` AS `a`,`test`.`t6`.`b` AS `b`,`test`.`t7`.`a` AS `a`,`test`.`t7`.`b` AS `b`,`test`.`t8`.`a` AS `a`,`test`.`t8`.`b` AS `b` from `test`.`t5` left join (`test`.`t6` join `test`.`t7` left join `test`.`t8` on(((`test`.`t8`.`b` = `test`.`t5`.`b`) and (`test`.`t6`.`b` < 10)))) on(((`test`.`t7`.`b` = `test`.`t5`.`b`) and (`test`.`t6`.`b` >= 2) and ((`test`.`t8`.`a` > 0) or (`test`.`t8`.`c` is null)))) where true +SELECT t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b +FROM t5 +LEFT JOIN +( +(t6, t7) +LEFT JOIN +t8 +ON t7.b=t8.b AND t6.b < 10 +) +ON t6.b >= 2 AND t5.b=t7.b AND +(t8.a > 0 OR t8.c IS NULL); +a b a b a b a b +1 1 1 2 1 1 NULL NULL +1 1 3 2 1 1 NULL NULL +2 2 1 2 2 2 1 2 +2 2 3 2 2 2 1 2 +3 3 NULL NULL NULL NULL NULL NULL +DELETE FROM t5; +DELETE FROM t6; +DELETE FROM t7; +DELETE FROM t8; +INSERT INTO t5 VALUES (1,3,0), (3,2,0); +INSERT INTO t6 VALUES (3,3,0); +INSERT INTO t7 VALUES (1,2,0); +INSERT INTO t8 VALUES (1,1,0); +ANALYZE TABLE t5, t6, t7, t8; +Table Op Msg_type Msg_text +test.t5 analyze status OK +test.t6 analyze status OK +test.t7 analyze status OK +test.t8 analyze status OK +EXPLAIN +SELECT t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b +FROM t5 LEFT JOIN +(t6 LEFT JOIN t7 ON t7.a=1, t8) +ON (t5.b=t8.b); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t5 NULL index NULL b_i 5 NULL 2 100.00 Using index +2 SIMPLE t6 NULL index NULL b_i 5 NULL 1 100.00 Using index +2 SIMPLE t7 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +2 SIMPLE t8 NULL ref b_i b_i 5 test.t5.b 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t5`.`a` AS `a`,`test`.`t5`.`b` AS `b`,`test`.`t6`.`a` AS `a`,`test`.`t6`.`b` AS `b`,`test`.`t7`.`a` AS `a`,`test`.`t7`.`b` AS `b`,`test`.`t8`.`a` AS `a`,`test`.`t8`.`b` AS `b` from `test`.`t5` left join (`test`.`t6` left join `test`.`t7` on((`test`.`t7`.`a` = 1)) join `test`.`t8`) on((`test`.`t8`.`b` = `test`.`t5`.`b`)) where true +SELECT t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b +FROM t5 LEFT JOIN +(t6 LEFT JOIN t7 ON t7.a=1, t8) +ON (t5.b=t8.b); +a b a b a b a b +1 3 NULL NULL NULL NULL NULL NULL +3 2 NULL NULL NULL NULL NULL NULL +EXPLAIN +SELECT t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b +FROM t5 LEFT JOIN +(t6 LEFT JOIN t7 ON t7.b=2, t8) +ON (t5.b=t8.b); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t5 NULL index NULL b_i 5 NULL 2 100.00 Using index +2 SIMPLE t6 NULL index NULL b_i 5 NULL 1 100.00 Using index +2 SIMPLE t7 NULL ref b_i b_i 5 const 1 100.00 Using index +2 SIMPLE t8 NULL ref b_i b_i 5 test.t5.b 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t5`.`a` AS `a`,`test`.`t5`.`b` AS `b`,`test`.`t6`.`a` AS `a`,`test`.`t6`.`b` AS `b`,`test`.`t7`.`a` AS `a`,`test`.`t7`.`b` AS `b`,`test`.`t8`.`a` AS `a`,`test`.`t8`.`b` AS `b` from `test`.`t5` left join (`test`.`t6` left join `test`.`t7` on((`test`.`t7`.`b` = 2)) join `test`.`t8`) on((`test`.`t8`.`b` = `test`.`t5`.`b`)) where true +SELECT t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b +FROM t5 LEFT JOIN +(t6 LEFT JOIN t7 ON t7.b=2, t8) +ON (t5.b=t8.b); +a b a b a b a b +1 3 NULL NULL NULL NULL NULL NULL +3 2 NULL NULL NULL NULL NULL NULL +EXPLAIN +SELECT t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b +FROM t5 LEFT JOIN +(t8, t6 LEFT JOIN t7 ON t7.a=1) +ON (t5.b=t8.b); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t5 NULL index NULL b_i 5 NULL 2 100.00 Using index +2 SIMPLE t8 NULL ref b_i b_i 5 test.t5.b 1 100.00 Using index +2 SIMPLE t6 NULL index NULL b_i 5 NULL 1 100.00 Using index +2 SIMPLE t7 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t5`.`a` AS `a`,`test`.`t5`.`b` AS `b`,`test`.`t6`.`a` AS `a`,`test`.`t6`.`b` AS `b`,`test`.`t7`.`a` AS `a`,`test`.`t7`.`b` AS `b`,`test`.`t8`.`a` AS `a`,`test`.`t8`.`b` AS `b` from `test`.`t5` left join (`test`.`t8` join `test`.`t6` left join `test`.`t7` on((`test`.`t7`.`a` = 1))) on((`test`.`t8`.`b` = `test`.`t5`.`b`)) where true +SELECT t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b +FROM t5 LEFT JOIN +(t8, t6 LEFT JOIN t7 ON t7.a=1) +ON (t5.b=t8.b); +a b a b a b a b +1 3 NULL NULL NULL NULL NULL NULL +3 2 NULL NULL NULL NULL NULL NULL +DROP TABLE t5,t6,t7,t8; +set optimizer_switch=default; diff --git a/mysql-test/r/join_nested_bka_nobnl.result-pq b/mysql-test/r/join_nested_bka_nobnl.result-pq new file mode 100644 index 000000000000..0e8024075dad --- /dev/null +++ b/mysql-test/r/join_nested_bka_nobnl.result-pq @@ -0,0 +1,2777 @@ +set optimizer_switch='batched_key_access=on,block_nested_loop=off,mrr_cost_based=off'; +DROP TABLE IF EXISTS t0,t1,t2,t3,t4,t5,t6,t7,t8,t9; +CREATE TABLE t0 (a int, b int, c int); +CREATE TABLE t1 (a int, b int, c int); +CREATE TABLE t2 (a int, b int, c int); +CREATE TABLE t3 (a int, b int, c int); +CREATE TABLE t4 (a int, b int, c int); +CREATE TABLE t5 (a int, b int, c int); +CREATE TABLE t6 (a int, b int, c int); +CREATE TABLE t7 (a int, b int, c int); +CREATE TABLE t8 (a int, b int, c int); +CREATE TABLE t9 (a int, b int, c int); +INSERT INTO t0 VALUES (1,1,0), (1,2,0), (2,2,0); +INSERT INTO t1 VALUES (1,3,0), (2,2,0), (3,2,0); +INSERT INTO t2 VALUES (3,3,0), (4,2,0), (5,3,0); +INSERT INTO t3 VALUES (1,2,0), (2,2,0); +INSERT INTO t4 VALUES (3,2,0), (4,2,0); +INSERT INTO t5 VALUES (3,1,0), (2,2,0), (3,3,0); +INSERT INTO t6 VALUES (3,2,0), (6,2,0), (6,1,0); +INSERT INTO t7 VALUES (1,1,0), (2,2,0); +INSERT INTO t8 VALUES (0,2,0), (1,2,0); +INSERT INTO t9 VALUES (1,1,0), (1,2,0), (3,3,0); +CREATE TABLE t34 (a3 int, b3 int, c3 int, a4 int, b4 int, c4 int); +INSERT INTO t34 +SELECT t3.*, t4.* +FROM t3 CROSS JOIN t4; +CREATE TABLE t345 (a3 int, b3 int, c3 int, a4 int, b4 int, c4 int, +a5 int, b5 int, c5 int); +INSERT INTO t345 +SELECT t3.*, t4.*, t5.* +FROM t3 CROSS JOIN t4 CROSS JOIN t5; +CREATE TABLE t67 (a6 int, b6 int, c6 int, a7 int, b7 int, c7 int); +INSERT INTO t67 +SELECT t6.*, t7.* +FROM t6 CROSS JOIN t7; +SELECT t2.a,t2.b +FROM t2; +a b +3 3 +4 2 +5 3 +SELECT t3.a,t3.b +FROM t3; +a b +1 2 +2 2 +SELECT t4.a,t4.b +FROM t4; +a b +3 2 +4 2 +SELECT t3.a,t3.b,t4.a,t4.b +FROM t3,t4; +a b a b +1 2 3 2 +1 2 4 2 +2 2 3 2 +2 2 4 2 +SELECT t2.a,t2.b,t3.a,t3.b,t4.a,t4.b +FROM t2 +LEFT JOIN +(t3, t4) +ON t2.b=t4.b; +a b a b a b +3 3 NULL NULL NULL NULL +4 2 1 2 3 2 +4 2 1 2 4 2 +4 2 2 2 3 2 +4 2 2 2 4 2 +5 3 NULL NULL NULL NULL +"Standard compliant copy of above query" +SELECT t2.a,t2.b,t34.a3,t34.b3,t34.a4,t34.b4 +FROM t2 +LEFT JOIN t34 +ON t2.b=t34.b4; +a b a3 b3 a4 b4 +3 3 NULL NULL NULL NULL +4 2 1 2 3 2 +4 2 1 2 4 2 +4 2 2 2 3 2 +4 2 2 2 4 2 +5 3 NULL NULL NULL NULL +SELECT t2.a,t2.b,t3.a,t3.b,t4.a,t4.b +FROM t2 +LEFT JOIN +(t3, t4) +ON t3.a=1 AND t2.b=t4.b; +a b a b a b +3 3 NULL NULL NULL NULL +4 2 1 2 3 2 +4 2 1 2 4 2 +5 3 NULL NULL NULL NULL +"Standard compliant copy of above query" +SELECT t2.a,t2.b,t34.a3,t34.b3,t34.a4,t34.b4 +FROM t2 +LEFT JOIN t34 +ON t34.a3=1 AND t2.b=t34.b4; +a b a3 b3 a4 b4 +3 3 NULL NULL NULL NULL +4 2 1 2 3 2 +4 2 1 2 4 2 +5 3 NULL NULL NULL NULL +ANALYZE TABLE t1, t2, t3, t4; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +test.t4 analyze status OK +EXPLAIN +SELECT t2.a,t2.b,t3.a,t3.b,t4.a,t4.b +FROM t2 +LEFT JOIN +(t3, t4) +ON t2.b=t4.b +WHERE t3.a=1 OR t3.c IS NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 75.00 Using where +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b` from `test`.`t2` left join (`test`.`t3` join `test`.`t4`) on((`test`.`t4`.`b` = `test`.`t2`.`b`)) where ((`test`.`t3`.`a` = 1) or (`test`.`t3`.`c` is null)) +SELECT t2.a,t2.b,t3.a,t3.b,t4.a,t4.b +FROM t2 +LEFT JOIN +(t3, t4) +ON t2.b=t4.b +WHERE t3.a=1 OR t3.c IS NULL; +a b a b a b +3 3 NULL NULL NULL NULL +4 2 1 2 3 2 +4 2 1 2 4 2 +5 3 NULL NULL NULL NULL +"Standard compliant copy of above query" +SELECT t2.a,t2.b,t34.a3,t34.b3,t34.a4,t34.b4 +FROM t2 +LEFT JOIN t34 +ON t2.b=t34.b4 +WHERE t34.a3=1 OR t34.c3 IS NULL; +a b a3 b3 a4 b4 +3 3 NULL NULL NULL NULL +4 2 1 2 3 2 +4 2 1 2 4 2 +5 3 NULL NULL NULL NULL +SELECT t2.a,t2.b,t3.a,t3.b,t4.a,t4.b +FROM t2 +LEFT JOIN +(t3, t4) +ON t2.b=t4.b +WHERE t3.a>1 OR t3.c IS NULL; +a b a b a b +3 3 NULL NULL NULL NULL +4 2 2 2 3 2 +4 2 2 2 4 2 +5 3 NULL NULL NULL NULL +"Standard compliant copy of above query" +SELECT t2.a,t2.b,t34.a3,t34.b3,t34.a4,t34.b4 +FROM t2 +LEFT JOIN t34 +ON t2.b=t34.b4 +WHERE t34.a3>1 OR t34.c3 IS NULL; +a b a3 b3 a4 b4 +3 3 NULL NULL NULL NULL +4 2 2 2 3 2 +4 2 2 2 4 2 +5 3 NULL NULL NULL NULL +SELECT t5.a,t5.b +FROM t5; +a b +3 1 +2 2 +3 3 +SELECT t3.a,t3.b,t4.a,t4.b,t5.a,t5.b +FROM t3,t4,t5; +a b a b a b +1 2 3 2 2 2 +1 2 3 2 3 1 +1 2 3 2 3 3 +1 2 4 2 2 2 +1 2 4 2 3 1 +1 2 4 2 3 3 +2 2 3 2 2 2 +2 2 3 2 3 1 +2 2 3 2 3 3 +2 2 4 2 2 2 +2 2 4 2 3 1 +2 2 4 2 3 3 +SELECT t2.a,t2.b,t3.a,t3.b,t4.a,t4.b,t5.a,t5.b +FROM t2 +LEFT JOIN +(t3, t4, t5) +ON t2.b=t4.b; +a b a b a b a b +3 3 NULL NULL NULL NULL NULL NULL +4 2 1 2 3 2 2 2 +4 2 1 2 3 2 3 1 +4 2 1 2 3 2 3 3 +4 2 1 2 4 2 2 2 +4 2 1 2 4 2 3 1 +4 2 1 2 4 2 3 3 +4 2 2 2 3 2 2 2 +4 2 2 2 3 2 3 1 +4 2 2 2 3 2 3 3 +4 2 2 2 4 2 2 2 +4 2 2 2 4 2 3 1 +4 2 2 2 4 2 3 3 +5 3 NULL NULL NULL NULL NULL NULL +"Standard compliant copy of above query" +SELECT t2.a,t2.b,t345.a3,t345.b3,t345.a4,t345.b4,t345.a5,t345.b5 +FROM t2 +LEFT JOIN t345 +ON t2.b=t345.b4; +a b a3 b3 a4 b4 a5 b5 +3 3 NULL NULL NULL NULL NULL NULL +4 2 1 2 3 2 2 2 +4 2 1 2 3 2 3 1 +4 2 1 2 3 2 3 3 +4 2 1 2 4 2 2 2 +4 2 1 2 4 2 3 1 +4 2 1 2 4 2 3 3 +4 2 2 2 3 2 2 2 +4 2 2 2 3 2 3 1 +4 2 2 2 3 2 3 3 +4 2 2 2 4 2 2 2 +4 2 2 2 4 2 3 1 +4 2 2 2 4 2 3 3 +5 3 NULL NULL NULL NULL NULL NULL +ANALYZE TABLE t2, t3, t4, t5; +Table Op Msg_type Msg_text +test.t2 analyze status OK +test.t3 analyze status OK +test.t4 analyze status OK +test.t5 analyze status OK +EXPLAIN +SELECT t2.a,t2.b,t3.a,t3.b,t4.a,t4.b,t5.a,t5.b +FROM t2 +LEFT JOIN +(t3, t4, t5) +ON t2.b=t4.b +WHERE t3.a>1 OR t3.c IS NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 75.00 Using where +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +2 SIMPLE t5 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t5`.`a` AS `a`,`test`.`t5`.`b` AS `b` from `test`.`t2` left join (`test`.`t3` join `test`.`t4` join `test`.`t5`) on((`test`.`t4`.`b` = `test`.`t2`.`b`)) where ((`test`.`t3`.`a` > 1) or (`test`.`t3`.`c` is null)) +SELECT t2.a,t2.b,t3.a,t3.b,t4.a,t4.b,t5.a,t5.b +FROM t2 +LEFT JOIN +(t3, t4, t5) +ON t2.b=t4.b +WHERE t3.a>1 OR t3.c IS NULL; +a b a b a b a b +3 3 NULL NULL NULL NULL NULL NULL +4 2 2 2 3 2 2 2 +4 2 2 2 3 2 3 1 +4 2 2 2 3 2 3 3 +4 2 2 2 4 2 2 2 +4 2 2 2 4 2 3 1 +4 2 2 2 4 2 3 3 +5 3 NULL NULL NULL NULL NULL NULL +"Standard compliant copy of above query" +SELECT t2.a,t2.b,t345.a3,t345.b3,t345.a4,t345.b4,t345.a5,t345.b5 +FROM t2 +LEFT JOIN t345 +ON t2.b=t345.b4 +WHERE t345.a3>1 OR t345.c3 IS NULL; +a b a3 b3 a4 b4 a5 b5 +3 3 NULL NULL NULL NULL NULL NULL +4 2 2 2 3 2 2 2 +4 2 2 2 3 2 3 1 +4 2 2 2 3 2 3 3 +4 2 2 2 4 2 2 2 +4 2 2 2 4 2 3 1 +4 2 2 2 4 2 3 3 +5 3 NULL NULL NULL NULL NULL NULL +ANALYZE TABLE t2, t3, t4, t5; +Table Op Msg_type Msg_text +test.t2 analyze status OK +test.t3 analyze status OK +test.t4 analyze status OK +test.t5 analyze status OK +EXPLAIN +SELECT t2.a,t2.b,t3.a,t3.b,t4.a,t4.b,t5.a,t5.b +FROM t2 +LEFT JOIN +(t3, t4, t5) +ON t2.b=t4.b +WHERE (t3.a>1 OR t3.c IS NULL) AND +(t5.a<3 OR t5.c IS NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 75.00 Using where +2 SIMPLE t5 NULL ALL NULL NULL NULL NULL 3 55.56 Using where +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t5`.`a` AS `a`,`test`.`t5`.`b` AS `b` from `test`.`t2` left join (`test`.`t3` join `test`.`t4` join `test`.`t5`) on((`test`.`t4`.`b` = `test`.`t2`.`b`)) where (((`test`.`t3`.`a` > 1) or (`test`.`t3`.`c` is null)) and ((`test`.`t5`.`a` < 3) or (`test`.`t5`.`c` is null))) +SELECT t2.a,t2.b,t3.a,t3.b,t4.a,t4.b,t5.a,t5.b +FROM t2 +LEFT JOIN +(t3, t4, t5) +ON t2.b=t4.b +WHERE (t3.a>1 OR t3.c IS NULL) AND +(t5.a<3 OR t5.c IS NULL); +a b a b a b a b +3 3 NULL NULL NULL NULL NULL NULL +4 2 2 2 3 2 2 2 +4 2 2 2 4 2 2 2 +5 3 NULL NULL NULL NULL NULL NULL +"Standard compliant copy of above query" +SELECT t2.a,t2.b,t345.a3,t345.b3,t345.a4,t345.b4,t345.a5,t345.b5 +FROM t2 +LEFT JOIN t345 +ON t2.b=t345.b4 +WHERE (t345.a3>1 OR t345.c3 IS NULL) AND +(t345.a5<3 OR t345.c5 IS NULL); +a b a3 b3 a4 b4 a5 b5 +3 3 NULL NULL NULL NULL NULL NULL +4 2 2 2 3 2 2 2 +4 2 2 2 4 2 2 2 +5 3 NULL NULL NULL NULL NULL NULL +SELECT t6.a,t6.b +FROM t6; +a b +3 2 +6 2 +6 1 +SELECT t7.a,t7.b +FROM t7; +a b +1 1 +2 2 +SELECT t6.a,t6.b,t7.a,t7.b +FROM t6,t7; +a b a b +3 2 1 1 +3 2 2 2 +6 1 1 1 +6 1 2 2 +6 2 1 1 +6 2 2 2 +SELECT t8.a,t8.b +FROM t8; +a b +0 2 +1 2 +ANALYZE TABLE t6, t7, t8; +Table Op Msg_type Msg_text +test.t6 analyze status OK +test.t7 analyze status OK +test.t8 analyze status OK +EXPLAIN +SELECT t6.a,t6.b,t7.a,t7.b,t8.a,t8.b +FROM (t6, t7) +LEFT JOIN +t8 +ON t7.b=t8.b AND t6.b < 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t7 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 SIMPLE t6 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 SIMPLE t8 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t6`.`a` AS `a`,`test`.`t6`.`b` AS `b`,`test`.`t7`.`a` AS `a`,`test`.`t7`.`b` AS `b`,`test`.`t8`.`a` AS `a`,`test`.`t8`.`b` AS `b` from `test`.`t6` join `test`.`t7` left join `test`.`t8` on(((`test`.`t8`.`b` = `test`.`t7`.`b`) and (`test`.`t6`.`b` < 10))) where true +SELECT t6.a,t6.b,t7.a,t7.b,t8.a,t8.b +FROM (t6, t7) +LEFT JOIN +t8 +ON t7.b=t8.b AND t6.b < 10; +a b a b a b +3 2 1 1 NULL NULL +3 2 2 2 0 2 +3 2 2 2 1 2 +6 1 1 1 NULL NULL +6 1 2 2 0 2 +6 1 2 2 1 2 +6 2 1 1 NULL NULL +6 2 2 2 0 2 +6 2 2 2 1 2 +"Standard compliant copy of above query" +SELECT t67.a6,t67.b6,t67.a7,t67.b7,t8.a,t8.b +FROM t67 +LEFT JOIN +t8 +ON t67.b7=t8.b AND t67.b6 < 10; +a6 b6 a7 b7 a b +3 2 1 1 NULL NULL +3 2 2 2 0 2 +3 2 2 2 1 2 +6 1 1 1 NULL NULL +6 1 2 2 0 2 +6 1 2 2 1 2 +6 2 1 1 NULL NULL +6 2 2 2 0 2 +6 2 2 2 1 2 +SELECT t5.a,t5.b +FROM t5; +a b +3 1 +2 2 +3 3 +SELECT t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b +FROM t5 +LEFT JOIN +( +(t6, t7) +LEFT JOIN +t8 +ON t7.b=t8.b AND t6.b < 10 +) +ON t6.b >= 2 AND t5.b=t7.b; +a b a b a b a b +2 2 3 2 2 2 0 2 +2 2 3 2 2 2 1 2 +2 2 6 2 2 2 0 2 +2 2 6 2 2 2 1 2 +3 1 3 2 1 1 NULL NULL +3 1 6 2 1 1 NULL NULL +3 3 NULL NULL NULL NULL NULL NULL +"Standard compliant copy of above query" +SELECT t5.a,t5.b,t67.a6,t67.b6,t67.a7,t67.b7,t8.a,t8.b +FROM t5 +LEFT JOIN +( +t67 +LEFT JOIN +t8 +ON t67.b7=t8.b AND t67.b6 < 10 +) +ON t67.b6 >= 2 AND t5.b=t67.b7; +a b a6 b6 a7 b7 a b +2 2 3 2 2 2 0 2 +2 2 3 2 2 2 1 2 +2 2 6 2 2 2 0 2 +2 2 6 2 2 2 1 2 +3 1 3 2 1 1 NULL NULL +3 1 6 2 1 1 NULL NULL +3 3 NULL NULL NULL NULL NULL NULL +SELECT t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b +FROM t5 +LEFT JOIN +( +(t6, t7) +LEFT JOIN +t8 +ON t7.b=t8.b AND t6.b < 10 +) +ON t6.b >= 2 AND t5.b=t7.b AND +(t8.a < 1 OR t8.c IS NULL); +a b a b a b a b +2 2 3 2 2 2 0 2 +2 2 6 2 2 2 0 2 +3 1 3 2 1 1 NULL NULL +3 1 6 2 1 1 NULL NULL +3 3 NULL NULL NULL NULL NULL NULL +"Standard compliant copy of above query" +SELECT t5.a,t5.b,t67.a6,t67.b6,t67.a7,t67.b7,t8.a,t8.b +FROM t5 +LEFT JOIN +( +t67 +LEFT JOIN +t8 +ON t67.b7=t8.b AND t67.b6 < 10 +) +ON t67.b6 >= 2 AND t5.b=t67.b7 AND +(t8.a < 1 OR t8.c IS NULL); +a b a6 b6 a7 b7 a b +2 2 3 2 2 2 0 2 +2 2 6 2 2 2 0 2 +3 1 3 2 1 1 NULL NULL +3 1 6 2 1 1 NULL NULL +3 3 NULL NULL NULL NULL NULL NULL +SELECT t2.a,t2.b,t3.a,t3.b,t4.a,t4.b +FROM t2 +LEFT JOIN +(t3, t4) +ON t3.a=1 AND t2.b=t4.b; +a b a b a b +3 3 NULL NULL NULL NULL +4 2 1 2 3 2 +4 2 1 2 4 2 +5 3 NULL NULL NULL NULL +"Standard compliant copy of above query" +SELECT t2.a,t2.b,t34.a3,t34.b3,t34.a4,t34.b4 +FROM t2 +LEFT JOIN t34 +ON t34.a3=1 AND t2.b=t34.b4; +a b a3 b3 a4 b4 +3 3 NULL NULL NULL NULL +4 2 1 2 3 2 +4 2 1 2 4 2 +5 3 NULL NULL NULL NULL +SELECT t2.a,t2.b,t3.a,t3.b,t4.a,t4.b, +t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b +FROM t2 +LEFT JOIN +(t3, t4) +ON t3.a=1 AND t2.b=t4.b, +t5 +LEFT JOIN +( +(t6, t7) +LEFT JOIN +t8 +ON t7.b=t8.b AND t6.b < 10 +) +ON t6.b >= 2 AND t5.b=t7.b; +a b a b a b a b a b a b a b +3 3 NULL NULL NULL NULL 2 2 3 2 2 2 0 2 +3 3 NULL NULL NULL NULL 2 2 3 2 2 2 1 2 +3 3 NULL NULL NULL NULL 2 2 6 2 2 2 0 2 +3 3 NULL NULL NULL NULL 2 2 6 2 2 2 1 2 +3 3 NULL NULL NULL NULL 3 1 3 2 1 1 NULL NULL +3 3 NULL NULL NULL NULL 3 1 6 2 1 1 NULL NULL +3 3 NULL NULL NULL NULL 3 3 NULL NULL NULL NULL NULL NULL +4 2 1 2 3 2 2 2 3 2 2 2 0 2 +4 2 1 2 3 2 2 2 3 2 2 2 1 2 +4 2 1 2 3 2 2 2 6 2 2 2 0 2 +4 2 1 2 3 2 2 2 6 2 2 2 1 2 +4 2 1 2 3 2 3 1 3 2 1 1 NULL NULL +4 2 1 2 3 2 3 1 6 2 1 1 NULL NULL +4 2 1 2 3 2 3 3 NULL NULL NULL NULL NULL NULL +4 2 1 2 4 2 2 2 3 2 2 2 0 2 +4 2 1 2 4 2 2 2 3 2 2 2 1 2 +4 2 1 2 4 2 2 2 6 2 2 2 0 2 +4 2 1 2 4 2 2 2 6 2 2 2 1 2 +4 2 1 2 4 2 3 1 3 2 1 1 NULL NULL +4 2 1 2 4 2 3 1 6 2 1 1 NULL NULL +4 2 1 2 4 2 3 3 NULL NULL NULL NULL NULL NULL +5 3 NULL NULL NULL NULL 2 2 3 2 2 2 0 2 +5 3 NULL NULL NULL NULL 2 2 3 2 2 2 1 2 +5 3 NULL NULL NULL NULL 2 2 6 2 2 2 0 2 +5 3 NULL NULL NULL NULL 2 2 6 2 2 2 1 2 +5 3 NULL NULL NULL NULL 3 1 3 2 1 1 NULL NULL +5 3 NULL NULL NULL NULL 3 1 6 2 1 1 NULL NULL +5 3 NULL NULL NULL NULL 3 3 NULL NULL NULL NULL NULL NULL +"Standard compliant copy of above query" +SELECT t2.a,t2.b,t34.a3,t34.b3,t34.a4,t34.b4, +t5.a,t5.b,t67.a6,t67.b6,t67.a7,t67.b7,t8.a,t8.b +FROM t2 +LEFT JOIN t34 +ON t34.a3=1 AND t2.b=t34.b4 +CROSS JOIN t5 +LEFT JOIN +( +t67 +LEFT JOIN +t8 +ON t67.b7=t8.b AND t67.b6 < 10 +) +ON t67.b6 >= 2 AND t5.b=t67.b7; +a b a3 b3 a4 b4 a b a6 b6 a7 b7 a b +3 3 NULL NULL NULL NULL 2 2 3 2 2 2 0 2 +3 3 NULL NULL NULL NULL 2 2 3 2 2 2 1 2 +3 3 NULL NULL NULL NULL 2 2 6 2 2 2 0 2 +3 3 NULL NULL NULL NULL 2 2 6 2 2 2 1 2 +3 3 NULL NULL NULL NULL 3 1 3 2 1 1 NULL NULL +3 3 NULL NULL NULL NULL 3 1 6 2 1 1 NULL NULL +3 3 NULL NULL NULL NULL 3 3 NULL NULL NULL NULL NULL NULL +4 2 1 2 3 2 2 2 3 2 2 2 0 2 +4 2 1 2 3 2 2 2 3 2 2 2 1 2 +4 2 1 2 3 2 2 2 6 2 2 2 0 2 +4 2 1 2 3 2 2 2 6 2 2 2 1 2 +4 2 1 2 3 2 3 1 3 2 1 1 NULL NULL +4 2 1 2 3 2 3 1 6 2 1 1 NULL NULL +4 2 1 2 3 2 3 3 NULL NULL NULL NULL NULL NULL +4 2 1 2 4 2 2 2 3 2 2 2 0 2 +4 2 1 2 4 2 2 2 3 2 2 2 1 2 +4 2 1 2 4 2 2 2 6 2 2 2 0 2 +4 2 1 2 4 2 2 2 6 2 2 2 1 2 +4 2 1 2 4 2 3 1 3 2 1 1 NULL NULL +4 2 1 2 4 2 3 1 6 2 1 1 NULL NULL +4 2 1 2 4 2 3 3 NULL NULL NULL NULL NULL NULL +5 3 NULL NULL NULL NULL 2 2 3 2 2 2 0 2 +5 3 NULL NULL NULL NULL 2 2 3 2 2 2 1 2 +5 3 NULL NULL NULL NULL 2 2 6 2 2 2 0 2 +5 3 NULL NULL NULL NULL 2 2 6 2 2 2 1 2 +5 3 NULL NULL NULL NULL 3 1 3 2 1 1 NULL NULL +5 3 NULL NULL NULL NULL 3 1 6 2 1 1 NULL NULL +5 3 NULL NULL NULL NULL 3 3 NULL NULL NULL NULL NULL NULL +SELECT t2.a,t2.b,t3.a,t3.b,t4.a,t4.b, +t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b +FROM t2 +LEFT JOIN +(t3, t4) +ON t3.a=1 AND t2.b=t4.b, +t5 +LEFT JOIN +( +(t6, t7) +LEFT JOIN +t8 +ON t7.b=t8.b AND t6.b < 10 +) +ON t6.b >= 2 AND t5.b=t7.b +WHERE t2.a > 3 AND +(t6.a < 6 OR t6.c IS NULL); +a b a b a b a b a b a b a b +4 2 1 2 3 2 2 2 3 2 2 2 0 2 +4 2 1 2 3 2 2 2 3 2 2 2 1 2 +4 2 1 2 3 2 3 1 3 2 1 1 NULL NULL +4 2 1 2 3 2 3 3 NULL NULL NULL NULL NULL NULL +4 2 1 2 4 2 2 2 3 2 2 2 0 2 +4 2 1 2 4 2 2 2 3 2 2 2 1 2 +4 2 1 2 4 2 3 1 3 2 1 1 NULL NULL +4 2 1 2 4 2 3 3 NULL NULL NULL NULL NULL NULL +5 3 NULL NULL NULL NULL 2 2 3 2 2 2 0 2 +5 3 NULL NULL NULL NULL 2 2 3 2 2 2 1 2 +5 3 NULL NULL NULL NULL 3 1 3 2 1 1 NULL NULL +5 3 NULL NULL NULL NULL 3 3 NULL NULL NULL NULL NULL NULL +"Standard compliant copy of above query" +SELECT t2.a,t2.b,t34.a3,t34.b3,t34.a4,t34.b4, +t5.a,t5.b,t67.a6,t67.b6,t67.a7,t67.b7,t8.a,t8.b +FROM t2 +LEFT JOIN t34 +ON t34.a3=1 AND t2.b=t34.b4 +CROSS JOIN t5 +LEFT JOIN +( +t67 +LEFT JOIN +t8 +ON t67.b7=t8.b AND t67.b6 < 10 +) +ON t67.b6 >= 2 AND t5.b=t67.b7 +WHERE t2.a > 3 AND +(t67.a6 < 6 OR t67.c6 IS NULL); +a b a3 b3 a4 b4 a b a6 b6 a7 b7 a b +4 2 1 2 3 2 2 2 3 2 2 2 0 2 +4 2 1 2 3 2 2 2 3 2 2 2 1 2 +4 2 1 2 3 2 3 1 3 2 1 1 NULL NULL +4 2 1 2 3 2 3 3 NULL NULL NULL NULL NULL NULL +4 2 1 2 4 2 2 2 3 2 2 2 0 2 +4 2 1 2 4 2 2 2 3 2 2 2 1 2 +4 2 1 2 4 2 3 1 3 2 1 1 NULL NULL +4 2 1 2 4 2 3 3 NULL NULL NULL NULL NULL NULL +5 3 NULL NULL NULL NULL 2 2 3 2 2 2 0 2 +5 3 NULL NULL NULL NULL 2 2 3 2 2 2 1 2 +5 3 NULL NULL NULL NULL 3 1 3 2 1 1 NULL NULL +5 3 NULL NULL NULL NULL 3 3 NULL NULL NULL NULL NULL NULL +SELECT t1.a,t1.b +FROM t1; +a b +1 3 +2 2 +3 2 +SELECT t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b, +t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b +FROM t1 +LEFT JOIN +( +t2 +LEFT JOIN +(t3, t4) +ON t3.a=1 AND t2.b=t4.b, +t5 +LEFT JOIN +( +(t6, t7) +LEFT JOIN +t8 +ON t7.b=t8.b AND t6.b < 10 +) +ON t6.b >= 2 AND t5.b=t7.b +) +ON (t3.b=2 OR t3.c IS NULL) AND (t6.b=2 OR t6.c IS NULL) AND +(t1.b=t5.b OR t3.c IS NULL OR t6.c IS NULL or t8.c IS NULL) AND +(t1.a != 2); +a b a b a b a b a b a b a b a b +1 3 3 3 NULL NULL NULL NULL 2 2 3 2 2 2 0 2 +1 3 3 3 NULL NULL NULL NULL 2 2 3 2 2 2 1 2 +1 3 3 3 NULL NULL NULL NULL 2 2 6 2 2 2 0 2 +1 3 3 3 NULL NULL NULL NULL 2 2 6 2 2 2 1 2 +1 3 3 3 NULL NULL NULL NULL 3 1 3 2 1 1 NULL NULL +1 3 3 3 NULL NULL NULL NULL 3 1 6 2 1 1 NULL NULL +1 3 3 3 NULL NULL NULL NULL 3 3 NULL NULL NULL NULL NULL NULL +1 3 4 2 1 2 3 2 3 1 3 2 1 1 NULL NULL +1 3 4 2 1 2 3 2 3 1 6 2 1 1 NULL NULL +1 3 4 2 1 2 3 2 3 3 NULL NULL NULL NULL NULL NULL +1 3 4 2 1 2 4 2 3 1 3 2 1 1 NULL NULL +1 3 4 2 1 2 4 2 3 1 6 2 1 1 NULL NULL +1 3 4 2 1 2 4 2 3 3 NULL NULL NULL NULL NULL NULL +1 3 5 3 NULL NULL NULL NULL 2 2 3 2 2 2 0 2 +1 3 5 3 NULL NULL NULL NULL 2 2 3 2 2 2 1 2 +1 3 5 3 NULL NULL NULL NULL 2 2 6 2 2 2 0 2 +1 3 5 3 NULL NULL NULL NULL 2 2 6 2 2 2 1 2 +1 3 5 3 NULL NULL NULL NULL 3 1 3 2 1 1 NULL NULL +1 3 5 3 NULL NULL NULL NULL 3 1 6 2 1 1 NULL NULL +1 3 5 3 NULL NULL NULL NULL 3 3 NULL NULL NULL NULL NULL NULL +2 2 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL +3 2 3 3 NULL NULL NULL NULL 2 2 3 2 2 2 0 2 +3 2 3 3 NULL NULL NULL NULL 2 2 3 2 2 2 1 2 +3 2 3 3 NULL NULL NULL NULL 2 2 6 2 2 2 0 2 +3 2 3 3 NULL NULL NULL NULL 2 2 6 2 2 2 1 2 +3 2 3 3 NULL NULL NULL NULL 3 1 3 2 1 1 NULL NULL +3 2 3 3 NULL NULL NULL NULL 3 1 6 2 1 1 NULL NULL +3 2 3 3 NULL NULL NULL NULL 3 3 NULL NULL NULL NULL NULL NULL +3 2 4 2 1 2 3 2 2 2 3 2 2 2 0 2 +3 2 4 2 1 2 3 2 2 2 3 2 2 2 1 2 +3 2 4 2 1 2 3 2 2 2 6 2 2 2 0 2 +3 2 4 2 1 2 3 2 2 2 6 2 2 2 1 2 +3 2 4 2 1 2 3 2 3 1 3 2 1 1 NULL NULL +3 2 4 2 1 2 3 2 3 1 6 2 1 1 NULL NULL +3 2 4 2 1 2 3 2 3 3 NULL NULL NULL NULL NULL NULL +3 2 4 2 1 2 4 2 2 2 3 2 2 2 0 2 +3 2 4 2 1 2 4 2 2 2 3 2 2 2 1 2 +3 2 4 2 1 2 4 2 2 2 6 2 2 2 0 2 +3 2 4 2 1 2 4 2 2 2 6 2 2 2 1 2 +3 2 4 2 1 2 4 2 3 1 3 2 1 1 NULL NULL +3 2 4 2 1 2 4 2 3 1 6 2 1 1 NULL NULL +3 2 4 2 1 2 4 2 3 3 NULL NULL NULL NULL NULL NULL +3 2 5 3 NULL NULL NULL NULL 2 2 3 2 2 2 0 2 +3 2 5 3 NULL NULL NULL NULL 2 2 3 2 2 2 1 2 +3 2 5 3 NULL NULL NULL NULL 2 2 6 2 2 2 0 2 +3 2 5 3 NULL NULL NULL NULL 2 2 6 2 2 2 1 2 +3 2 5 3 NULL NULL NULL NULL 3 1 3 2 1 1 NULL NULL +3 2 5 3 NULL NULL NULL NULL 3 1 6 2 1 1 NULL NULL +3 2 5 3 NULL NULL NULL NULL 3 3 NULL NULL NULL NULL NULL NULL +"Standard compliant copy of above query" +SELECT t1.a,t1.b,t2.a,t2.b,t34.a3,t34.b3,t34.a4,t34.b4, +t5.a,t5.b,t67.a6,t67.b6,t67.a7,t67.b7,t8.a,t8.b +FROM t1 +LEFT JOIN +( +t2 +LEFT JOIN t34 +ON t34.a3=1 AND t2.b=t34.b4 +CROSS JOIN t5 +LEFT JOIN +( +t67 +LEFT JOIN +t8 +ON t67.b7=t8.b AND t67.b6 < 10 +) +ON t67.b6 >= 2 AND t5.b=t67.b7 +) +ON (t34.b3=2 OR t34.c3 IS NULL) AND (t67.b6=2 OR t67.c6 IS NULL) AND +(t1.b=t5.b OR t34.c3 IS NULL OR t67.c6 IS NULL or t8.c IS NULL) AND +(t1.a <> 2); +a b a b a3 b3 a4 b4 a b a6 b6 a7 b7 a b +1 3 3 3 NULL NULL NULL NULL 2 2 3 2 2 2 0 2 +1 3 3 3 NULL NULL NULL NULL 2 2 3 2 2 2 1 2 +1 3 3 3 NULL NULL NULL NULL 2 2 6 2 2 2 0 2 +1 3 3 3 NULL NULL NULL NULL 2 2 6 2 2 2 1 2 +1 3 3 3 NULL NULL NULL NULL 3 1 3 2 1 1 NULL NULL +1 3 3 3 NULL NULL NULL NULL 3 1 6 2 1 1 NULL NULL +1 3 3 3 NULL NULL NULL NULL 3 3 NULL NULL NULL NULL NULL NULL +1 3 4 2 1 2 3 2 3 1 3 2 1 1 NULL NULL +1 3 4 2 1 2 3 2 3 1 6 2 1 1 NULL NULL +1 3 4 2 1 2 3 2 3 3 NULL NULL NULL NULL NULL NULL +1 3 4 2 1 2 4 2 3 1 3 2 1 1 NULL NULL +1 3 4 2 1 2 4 2 3 1 6 2 1 1 NULL NULL +1 3 4 2 1 2 4 2 3 3 NULL NULL NULL NULL NULL NULL +1 3 5 3 NULL NULL NULL NULL 2 2 3 2 2 2 0 2 +1 3 5 3 NULL NULL NULL NULL 2 2 3 2 2 2 1 2 +1 3 5 3 NULL NULL NULL NULL 2 2 6 2 2 2 0 2 +1 3 5 3 NULL NULL NULL NULL 2 2 6 2 2 2 1 2 +1 3 5 3 NULL NULL NULL NULL 3 1 3 2 1 1 NULL NULL +1 3 5 3 NULL NULL NULL NULL 3 1 6 2 1 1 NULL NULL +1 3 5 3 NULL NULL NULL NULL 3 3 NULL NULL NULL NULL NULL NULL +2 2 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL +3 2 3 3 NULL NULL NULL NULL 2 2 3 2 2 2 0 2 +3 2 3 3 NULL NULL NULL NULL 2 2 3 2 2 2 1 2 +3 2 3 3 NULL NULL NULL NULL 2 2 6 2 2 2 0 2 +3 2 3 3 NULL NULL NULL NULL 2 2 6 2 2 2 1 2 +3 2 3 3 NULL NULL NULL NULL 3 1 3 2 1 1 NULL NULL +3 2 3 3 NULL NULL NULL NULL 3 1 6 2 1 1 NULL NULL +3 2 3 3 NULL NULL NULL NULL 3 3 NULL NULL NULL NULL NULL NULL +3 2 4 2 1 2 3 2 2 2 3 2 2 2 0 2 +3 2 4 2 1 2 3 2 2 2 3 2 2 2 1 2 +3 2 4 2 1 2 3 2 2 2 6 2 2 2 0 2 +3 2 4 2 1 2 3 2 2 2 6 2 2 2 1 2 +3 2 4 2 1 2 3 2 3 1 3 2 1 1 NULL NULL +3 2 4 2 1 2 3 2 3 1 6 2 1 1 NULL NULL +3 2 4 2 1 2 3 2 3 3 NULL NULL NULL NULL NULL NULL +3 2 4 2 1 2 4 2 2 2 3 2 2 2 0 2 +3 2 4 2 1 2 4 2 2 2 3 2 2 2 1 2 +3 2 4 2 1 2 4 2 2 2 6 2 2 2 0 2 +3 2 4 2 1 2 4 2 2 2 6 2 2 2 1 2 +3 2 4 2 1 2 4 2 3 1 3 2 1 1 NULL NULL +3 2 4 2 1 2 4 2 3 1 6 2 1 1 NULL NULL +3 2 4 2 1 2 4 2 3 3 NULL NULL NULL NULL NULL NULL +3 2 5 3 NULL NULL NULL NULL 2 2 3 2 2 2 0 2 +3 2 5 3 NULL NULL NULL NULL 2 2 3 2 2 2 1 2 +3 2 5 3 NULL NULL NULL NULL 2 2 6 2 2 2 0 2 +3 2 5 3 NULL NULL NULL NULL 2 2 6 2 2 2 1 2 +3 2 5 3 NULL NULL NULL NULL 3 1 3 2 1 1 NULL NULL +3 2 5 3 NULL NULL NULL NULL 3 1 6 2 1 1 NULL NULL +3 2 5 3 NULL NULL NULL NULL 3 3 NULL NULL NULL NULL NULL NULL +SELECT t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b, +t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b +FROM t1 +LEFT JOIN +( +t2 +LEFT JOIN +(t3, t4) +ON t3.a=1 AND t2.b=t4.b, +t5 +LEFT JOIN +( +(t6, t7) +LEFT JOIN +t8 +ON t7.b=t8.b AND t6.b < 10 +) +ON t6.b >= 2 AND t5.b=t7.b +) +ON (t3.b=2 OR t3.c IS NULL) AND (t6.b=2 OR t6.c IS NULL) AND +(t1.b=t5.b OR t3.c IS NULL OR t6.c IS NULL or t8.c IS NULL) AND +(t1.a != 2) +WHERE (t2.a >= 4 OR t2.c IS NULL); +a b a b a b a b a b a b a b a b +1 3 4 2 1 2 3 2 3 1 3 2 1 1 NULL NULL +1 3 4 2 1 2 3 2 3 1 6 2 1 1 NULL NULL +1 3 4 2 1 2 3 2 3 3 NULL NULL NULL NULL NULL NULL +1 3 4 2 1 2 4 2 3 1 3 2 1 1 NULL NULL +1 3 4 2 1 2 4 2 3 1 6 2 1 1 NULL NULL +1 3 4 2 1 2 4 2 3 3 NULL NULL NULL NULL NULL NULL +1 3 5 3 NULL NULL NULL NULL 2 2 3 2 2 2 0 2 +1 3 5 3 NULL NULL NULL NULL 2 2 3 2 2 2 1 2 +1 3 5 3 NULL NULL NULL NULL 2 2 6 2 2 2 0 2 +1 3 5 3 NULL NULL NULL NULL 2 2 6 2 2 2 1 2 +1 3 5 3 NULL NULL NULL NULL 3 1 3 2 1 1 NULL NULL +1 3 5 3 NULL NULL NULL NULL 3 1 6 2 1 1 NULL NULL +1 3 5 3 NULL NULL NULL NULL 3 3 NULL NULL NULL NULL NULL NULL +2 2 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL +3 2 4 2 1 2 3 2 2 2 3 2 2 2 0 2 +3 2 4 2 1 2 3 2 2 2 3 2 2 2 1 2 +3 2 4 2 1 2 3 2 2 2 6 2 2 2 0 2 +3 2 4 2 1 2 3 2 2 2 6 2 2 2 1 2 +3 2 4 2 1 2 3 2 3 1 3 2 1 1 NULL NULL +3 2 4 2 1 2 3 2 3 1 6 2 1 1 NULL NULL +3 2 4 2 1 2 3 2 3 3 NULL NULL NULL NULL NULL NULL +3 2 4 2 1 2 4 2 2 2 3 2 2 2 0 2 +3 2 4 2 1 2 4 2 2 2 3 2 2 2 1 2 +3 2 4 2 1 2 4 2 2 2 6 2 2 2 0 2 +3 2 4 2 1 2 4 2 2 2 6 2 2 2 1 2 +3 2 4 2 1 2 4 2 3 1 3 2 1 1 NULL NULL +3 2 4 2 1 2 4 2 3 1 6 2 1 1 NULL NULL +3 2 4 2 1 2 4 2 3 3 NULL NULL NULL NULL NULL NULL +3 2 5 3 NULL NULL NULL NULL 2 2 3 2 2 2 0 2 +3 2 5 3 NULL NULL NULL NULL 2 2 3 2 2 2 1 2 +3 2 5 3 NULL NULL NULL NULL 2 2 6 2 2 2 0 2 +3 2 5 3 NULL NULL NULL NULL 2 2 6 2 2 2 1 2 +3 2 5 3 NULL NULL NULL NULL 3 1 3 2 1 1 NULL NULL +3 2 5 3 NULL NULL NULL NULL 3 1 6 2 1 1 NULL NULL +3 2 5 3 NULL NULL NULL NULL 3 3 NULL NULL NULL NULL NULL NULL +"Standard compliant copy of above query" +SELECT t1.a,t1.b,t2.a,t2.b,t34.a3,t34.b3,t34.a4,t34.b4, +t5.a,t5.b,t67.a6,t67.b6,t67.a7,t67.b7,t8.a,t8.b +FROM t1 +LEFT JOIN +( +t2 +LEFT JOIN t34 +ON t34.a3=1 AND t2.b=t34.b4 +CROSS JOIN t5 +LEFT JOIN +( +t67 +LEFT JOIN +t8 +ON t67.b7=t8.b AND t67.b6 < 10 +) +ON t67.b6 >= 2 AND t5.b=t67.b7 +) +ON (t34.b3=2 OR t34.c3 IS NULL) AND (t67.b6=2 OR t67.c6 IS NULL) AND +(t1.b=t5.b OR t34.c3 IS NULL OR t67.c6 IS NULL or t8.c IS NULL) AND +(t1.a <> 2) +WHERE (t2.a >= 4 OR t2.c IS NULL); +a b a b a3 b3 a4 b4 a b a6 b6 a7 b7 a b +1 3 4 2 1 2 3 2 3 1 3 2 1 1 NULL NULL +1 3 4 2 1 2 3 2 3 1 6 2 1 1 NULL NULL +1 3 4 2 1 2 3 2 3 3 NULL NULL NULL NULL NULL NULL +1 3 4 2 1 2 4 2 3 1 3 2 1 1 NULL NULL +1 3 4 2 1 2 4 2 3 1 6 2 1 1 NULL NULL +1 3 4 2 1 2 4 2 3 3 NULL NULL NULL NULL NULL NULL +1 3 5 3 NULL NULL NULL NULL 2 2 3 2 2 2 0 2 +1 3 5 3 NULL NULL NULL NULL 2 2 3 2 2 2 1 2 +1 3 5 3 NULL NULL NULL NULL 2 2 6 2 2 2 0 2 +1 3 5 3 NULL NULL NULL NULL 2 2 6 2 2 2 1 2 +1 3 5 3 NULL NULL NULL NULL 3 1 3 2 1 1 NULL NULL +1 3 5 3 NULL NULL NULL NULL 3 1 6 2 1 1 NULL NULL +1 3 5 3 NULL NULL NULL NULL 3 3 NULL NULL NULL NULL NULL NULL +2 2 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL +3 2 4 2 1 2 3 2 2 2 3 2 2 2 0 2 +3 2 4 2 1 2 3 2 2 2 3 2 2 2 1 2 +3 2 4 2 1 2 3 2 2 2 6 2 2 2 0 2 +3 2 4 2 1 2 3 2 2 2 6 2 2 2 1 2 +3 2 4 2 1 2 3 2 3 1 3 2 1 1 NULL NULL +3 2 4 2 1 2 3 2 3 1 6 2 1 1 NULL NULL +3 2 4 2 1 2 3 2 3 3 NULL NULL NULL NULL NULL NULL +3 2 4 2 1 2 4 2 2 2 3 2 2 2 0 2 +3 2 4 2 1 2 4 2 2 2 3 2 2 2 1 2 +3 2 4 2 1 2 4 2 2 2 6 2 2 2 0 2 +3 2 4 2 1 2 4 2 2 2 6 2 2 2 1 2 +3 2 4 2 1 2 4 2 3 1 3 2 1 1 NULL NULL +3 2 4 2 1 2 4 2 3 1 6 2 1 1 NULL NULL +3 2 4 2 1 2 4 2 3 3 NULL NULL NULL NULL NULL NULL +3 2 5 3 NULL NULL NULL NULL 2 2 3 2 2 2 0 2 +3 2 5 3 NULL NULL NULL NULL 2 2 3 2 2 2 1 2 +3 2 5 3 NULL NULL NULL NULL 2 2 6 2 2 2 0 2 +3 2 5 3 NULL NULL NULL NULL 2 2 6 2 2 2 1 2 +3 2 5 3 NULL NULL NULL NULL 3 1 3 2 1 1 NULL NULL +3 2 5 3 NULL NULL NULL NULL 3 1 6 2 1 1 NULL NULL +3 2 5 3 NULL NULL NULL NULL 3 3 NULL NULL NULL NULL NULL NULL +SELECT t0.a,t0.b +FROM t0; +a b +1 1 +1 2 +2 2 +ANALYZE TABLE t0, t1, t2, t3, t4, t5, t6, t7, t8; +Table Op Msg_type Msg_text +test.t0 analyze status OK +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +test.t4 analyze status OK +test.t5 analyze status OK +test.t6 analyze status OK +test.t7 analyze status OK +test.t8 analyze status OK +EXPLAIN +SELECT t0.a,t0.b,t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b, +t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b +FROM t0,t1 +LEFT JOIN +( +t2 +LEFT JOIN +(t3, t4) +ON t3.a=1 AND t2.b=t4.b, +t5 +LEFT JOIN +( +(t6, t7) +LEFT JOIN +t8 +ON t7.b=t8.b AND t6.b < 10 +) +ON t6.b >= 2 AND t5.b=t7.b +) +ON (t3.b=2 OR t3.c IS NULL) AND (t6.b=2 OR t6.c IS NULL) AND +(t1.b=t5.b OR t3.c IS NULL OR t6.c IS NULL or t8.c IS NULL) AND +(t1.a != 2) +WHERE t0.a=1 AND +t0.b=t1.b AND +(t2.a >= 4 OR t2.c IS NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE t0 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 55.56 Using where +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +2 SIMPLE t5 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 SIMPLE t7 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +2 SIMPLE t6 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 SIMPLE t8 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a`,`test`.`t0`.`b` AS `b`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t5`.`a` AS `a`,`test`.`t5`.`b` AS `b`,`test`.`t6`.`a` AS `a`,`test`.`t6`.`b` AS `b`,`test`.`t7`.`a` AS `a`,`test`.`t7`.`b` AS `b`,`test`.`t8`.`a` AS `a`,`test`.`t8`.`b` AS `b` from `test`.`t0` join `test`.`t1` left join (`test`.`t2` left join (`test`.`t3` join `test`.`t4`) on(((`test`.`t4`.`b` = `test`.`t2`.`b`) and (`test`.`t3`.`a` = 1))) join `test`.`t5` left join (`test`.`t6` join `test`.`t7` left join `test`.`t8` on(((`test`.`t8`.`b` = `test`.`t5`.`b`) and (`test`.`t6`.`b` < 10)))) on(((`test`.`t7`.`b` = `test`.`t5`.`b`) and (`test`.`t6`.`b` >= 2)))) on((((`test`.`t3`.`b` = 2) or (`test`.`t3`.`c` is null)) and ((`test`.`t6`.`b` = 2) or (`test`.`t6`.`c` is null)) and ((`test`.`t5`.`b` = `test`.`t0`.`b`) or (`test`.`t3`.`c` is null) or (`test`.`t6`.`c` is null) or (`test`.`t8`.`c` is null)) and (`test`.`t1`.`a` <> 2))) where ((`test`.`t1`.`b` = `test`.`t0`.`b`) and (`test`.`t0`.`a` = 1) and ((`test`.`t2`.`a` >= 4) or (`test`.`t2`.`c` is null))) +SELECT t0.a,t0.b,t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b, +t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b +FROM t0,t1 +LEFT JOIN +( +t2 +LEFT JOIN +(t3, t4) +ON t3.a=1 AND t2.b=t4.b, +t5 +LEFT JOIN +( +(t6, t7) +LEFT JOIN +t8 +ON t7.b=t8.b AND t6.b < 10 +) +ON t6.b >= 2 AND t5.b=t7.b +) +ON (t3.b=2 OR t3.c IS NULL) AND (t6.b=2 OR t6.c IS NULL) AND +(t1.b=t5.b OR t3.c IS NULL OR t6.c IS NULL or t8.c IS NULL) AND +(t1.a != 2) +WHERE t0.a=1 AND +t0.b=t1.b AND +(t2.a >= 4 OR t2.c IS NULL); +a b a b a b a b a b a b a b a b a b +1 2 2 2 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL +1 2 3 2 4 2 1 2 3 2 2 2 3 2 2 2 0 2 +1 2 3 2 4 2 1 2 3 2 2 2 3 2 2 2 1 2 +1 2 3 2 4 2 1 2 3 2 2 2 6 2 2 2 0 2 +1 2 3 2 4 2 1 2 3 2 2 2 6 2 2 2 1 2 +1 2 3 2 4 2 1 2 3 2 3 1 3 2 1 1 NULL NULL +1 2 3 2 4 2 1 2 3 2 3 1 6 2 1 1 NULL NULL +1 2 3 2 4 2 1 2 3 2 3 3 NULL NULL NULL NULL NULL NULL +1 2 3 2 4 2 1 2 4 2 2 2 3 2 2 2 0 2 +1 2 3 2 4 2 1 2 4 2 2 2 3 2 2 2 1 2 +1 2 3 2 4 2 1 2 4 2 2 2 6 2 2 2 0 2 +1 2 3 2 4 2 1 2 4 2 2 2 6 2 2 2 1 2 +1 2 3 2 4 2 1 2 4 2 3 1 3 2 1 1 NULL NULL +1 2 3 2 4 2 1 2 4 2 3 1 6 2 1 1 NULL NULL +1 2 3 2 4 2 1 2 4 2 3 3 NULL NULL NULL NULL NULL NULL +1 2 3 2 5 3 NULL NULL NULL NULL 2 2 3 2 2 2 0 2 +1 2 3 2 5 3 NULL NULL NULL NULL 2 2 3 2 2 2 1 2 +1 2 3 2 5 3 NULL NULL NULL NULL 2 2 6 2 2 2 0 2 +1 2 3 2 5 3 NULL NULL NULL NULL 2 2 6 2 2 2 1 2 +1 2 3 2 5 3 NULL NULL NULL NULL 3 1 3 2 1 1 NULL NULL +1 2 3 2 5 3 NULL NULL NULL NULL 3 1 6 2 1 1 NULL NULL +1 2 3 2 5 3 NULL NULL NULL NULL 3 3 NULL NULL NULL NULL NULL NULL +"Standard compliant copy of above query" +SELECT t0.a,t0.b,t1.a,t1.b,t2.a,t2.b,t34.a3,t34.b3,t34.a4,t34.b4, +t5.a,t5.b,t67.a6,t67.b6,t67.a7,t67.b7,t8.a,t8.b +FROM t0 +CROSS JOIN t1 +LEFT JOIN +( +t2 +LEFT JOIN t34 +ON t34.a3=1 AND t2.b=t34.b4 +CROSS JOIN t5 +LEFT JOIN +( +t67 +LEFT JOIN +t8 +ON t67.b7=t8.b AND t67.b6 < 10 +) +ON t67.b6 >= 2 AND t5.b=t67.b7 +) +ON (t34.b3=2 OR t34.c3 IS NULL) AND (t67.b6=2 OR t67.c6 IS NULL) AND +(t1.b=t5.b OR t34.c3 IS NULL OR t67.c6 IS NULL or t8.c IS NULL) AND +(t1.a <> 2) +WHERE t0.a=1 AND +t0.b=t1.b AND +(t2.a >= 4 OR t2.c IS NULL); +a b a b a b a3 b3 a4 b4 a b a6 b6 a7 b7 a b +1 2 2 2 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL +1 2 3 2 4 2 1 2 3 2 2 2 3 2 2 2 0 2 +1 2 3 2 4 2 1 2 3 2 2 2 3 2 2 2 1 2 +1 2 3 2 4 2 1 2 3 2 2 2 6 2 2 2 0 2 +1 2 3 2 4 2 1 2 3 2 2 2 6 2 2 2 1 2 +1 2 3 2 4 2 1 2 3 2 3 1 3 2 1 1 NULL NULL +1 2 3 2 4 2 1 2 3 2 3 1 6 2 1 1 NULL NULL +1 2 3 2 4 2 1 2 3 2 3 3 NULL NULL NULL NULL NULL NULL +1 2 3 2 4 2 1 2 4 2 2 2 3 2 2 2 0 2 +1 2 3 2 4 2 1 2 4 2 2 2 3 2 2 2 1 2 +1 2 3 2 4 2 1 2 4 2 2 2 6 2 2 2 0 2 +1 2 3 2 4 2 1 2 4 2 2 2 6 2 2 2 1 2 +1 2 3 2 4 2 1 2 4 2 3 1 3 2 1 1 NULL NULL +1 2 3 2 4 2 1 2 4 2 3 1 6 2 1 1 NULL NULL +1 2 3 2 4 2 1 2 4 2 3 3 NULL NULL NULL NULL NULL NULL +1 2 3 2 5 3 NULL NULL NULL NULL 2 2 3 2 2 2 0 2 +1 2 3 2 5 3 NULL NULL NULL NULL 2 2 3 2 2 2 1 2 +1 2 3 2 5 3 NULL NULL NULL NULL 2 2 6 2 2 2 0 2 +1 2 3 2 5 3 NULL NULL NULL NULL 2 2 6 2 2 2 1 2 +1 2 3 2 5 3 NULL NULL NULL NULL 3 1 3 2 1 1 NULL NULL +1 2 3 2 5 3 NULL NULL NULL NULL 3 1 6 2 1 1 NULL NULL +1 2 3 2 5 3 NULL NULL NULL NULL 3 3 NULL NULL NULL NULL NULL NULL +ANALYZE TABLE t0, t1, t2, t3, t4, t5, t6, t7, t8, t9; +Table Op Msg_type Msg_text +test.t0 analyze status OK +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +test.t4 analyze status OK +test.t5 analyze status OK +test.t6 analyze status OK +test.t7 analyze status OK +test.t8 analyze status OK +test.t9 analyze status OK +EXPLAIN +SELECT t0.a,t0.b,t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b, +t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b,t9.a,t9.b +FROM t0,t1 +LEFT JOIN +( +t2 +LEFT JOIN +(t3, t4) +ON t3.a=1 AND t2.b=t4.b, +t5 +LEFT JOIN +( +(t6, t7) +LEFT JOIN +t8 +ON t7.b=t8.b AND t6.b < 10 +) +ON t6.b >= 2 AND t5.b=t7.b +) +ON (t3.b=2 OR t3.c IS NULL) AND (t6.b=2 OR t6.c IS NULL) AND +(t1.b=t5.b OR t3.c IS NULL OR t6.c IS NULL or t8.c IS NULL) AND +(t1.a != 2), +t9 +WHERE t0.a=1 AND +t0.b=t1.b AND +(t2.a >= 4 OR t2.c IS NULL) AND +(t3.a < 5 OR t3.c IS NULL) AND +(t3.b=t4.b OR t3.c IS NULL OR t4.c IS NULL) AND +(t5.a >=2 OR t5.c IS NULL) AND +(t6.a >=4 OR t6.c IS NULL) AND +(t7.a <= 2 OR t7.c IS NULL) AND +(t8.a < 1 OR t8.c IS NULL) AND +(t8.b=t9.b OR t8.c IS NULL) AND +(t9.a=1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE t0 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +2 SIMPLE t9 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 55.56 Using where +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 75.00 Using where +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +2 SIMPLE t5 NULL ALL NULL NULL NULL NULL 3 55.56 Using where +2 SIMPLE t7 NULL ALL NULL NULL NULL NULL 2 75.00 Using where +2 SIMPLE t6 NULL ALL NULL NULL NULL NULL 3 55.56 Using where +2 SIMPLE t8 NULL ALL NULL NULL NULL NULL 2 56.25 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a`,`test`.`t0`.`b` AS `b`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t5`.`a` AS `a`,`test`.`t5`.`b` AS `b`,`test`.`t6`.`a` AS `a`,`test`.`t6`.`b` AS `b`,`test`.`t7`.`a` AS `a`,`test`.`t7`.`b` AS `b`,`test`.`t8`.`a` AS `a`,`test`.`t8`.`b` AS `b`,`test`.`t9`.`a` AS `a`,`test`.`t9`.`b` AS `b` from `test`.`t0` join `test`.`t1` left join (`test`.`t2` left join (`test`.`t3` join `test`.`t4`) on(((`test`.`t4`.`b` = `test`.`t2`.`b`) and (`test`.`t3`.`a` = 1))) join `test`.`t5` left join (`test`.`t6` join `test`.`t7` left join `test`.`t8` on(((`test`.`t8`.`b` = `test`.`t5`.`b`) and (`test`.`t6`.`b` < 10)))) on(((`test`.`t7`.`b` = `test`.`t5`.`b`) and (`test`.`t6`.`b` >= 2)))) on((((`test`.`t3`.`b` = 2) or (`test`.`t3`.`c` is null)) and ((`test`.`t6`.`b` = 2) or (`test`.`t6`.`c` is null)) and ((`test`.`t5`.`b` = `test`.`t0`.`b`) or (`test`.`t3`.`c` is null) or (`test`.`t6`.`c` is null) or (`test`.`t8`.`c` is null)) and (`test`.`t1`.`a` <> 2))) join `test`.`t9` where ((`test`.`t9`.`a` = 1) and (`test`.`t1`.`b` = `test`.`t0`.`b`) and (`test`.`t0`.`a` = 1) and ((`test`.`t2`.`a` >= 4) or (`test`.`t2`.`c` is null)) and ((`test`.`t3`.`a` < 5) or (`test`.`t3`.`c` is null)) and ((`test`.`t4`.`b` = `test`.`t3`.`b`) or (`test`.`t3`.`c` is null) or (`test`.`t4`.`c` is null)) and ((`test`.`t5`.`a` >= 2) or (`test`.`t5`.`c` is null)) and ((`test`.`t6`.`a` >= 4) or (`test`.`t6`.`c` is null)) and ((`test`.`t7`.`a` <= 2) or (`test`.`t7`.`c` is null)) and ((`test`.`t8`.`a` < 1) or (`test`.`t8`.`c` is null)) and ((`test`.`t8`.`b` = `test`.`t9`.`b`) or (`test`.`t8`.`c` is null))) +SELECT t9.a,t9.b +FROM t9; +a b +1 1 +1 2 +3 3 +SELECT t0.a,t0.b,t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b, +t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b,t9.a,t9.b +FROM t0,t1 +LEFT JOIN +( +t2 +LEFT JOIN +(t3, t4) +ON t3.a=1 AND t2.b=t4.b, +t5 +LEFT JOIN +( +(t6, t7) +LEFT JOIN +t8 +ON t7.b=t8.b AND t6.b < 10 +) +ON t6.b >= 2 AND t5.b=t7.b +) +ON (t3.b=2 OR t3.c IS NULL) AND (t6.b=2 OR t6.c IS NULL) AND +(t1.b=t5.b OR t3.c IS NULL OR t6.c IS NULL or t8.c IS NULL) AND +(t1.a != 2), +t9 +WHERE t0.a=1 AND +t0.b=t1.b AND +(t2.a >= 4 OR t2.c IS NULL) AND +(t3.a < 5 OR t3.c IS NULL) AND +(t3.b=t4.b OR t3.c IS NULL OR t4.c IS NULL) AND +(t5.a >=2 OR t5.c IS NULL) AND +(t6.a >=4 OR t6.c IS NULL) AND +(t7.a <= 2 OR t7.c IS NULL) AND +(t8.a < 1 OR t8.c IS NULL) AND +(t8.b=t9.b OR t8.c IS NULL) AND +(t9.a=1); +a b a b a b a b a b a b a b a b a b a b +1 2 2 2 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL 1 1 +1 2 2 2 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL 1 2 +1 2 3 2 4 2 1 2 3 2 2 2 6 2 2 2 0 2 1 2 +1 2 3 2 4 2 1 2 3 2 3 1 6 2 1 1 NULL NULL 1 1 +1 2 3 2 4 2 1 2 3 2 3 1 6 2 1 1 NULL NULL 1 2 +1 2 3 2 4 2 1 2 3 2 3 3 NULL NULL NULL NULL NULL NULL 1 1 +1 2 3 2 4 2 1 2 3 2 3 3 NULL NULL NULL NULL NULL NULL 1 2 +1 2 3 2 4 2 1 2 4 2 2 2 6 2 2 2 0 2 1 2 +1 2 3 2 4 2 1 2 4 2 3 1 6 2 1 1 NULL NULL 1 1 +1 2 3 2 4 2 1 2 4 2 3 1 6 2 1 1 NULL NULL 1 2 +1 2 3 2 4 2 1 2 4 2 3 3 NULL NULL NULL NULL NULL NULL 1 1 +1 2 3 2 4 2 1 2 4 2 3 3 NULL NULL NULL NULL NULL NULL 1 2 +1 2 3 2 5 3 NULL NULL NULL NULL 2 2 6 2 2 2 0 2 1 2 +1 2 3 2 5 3 NULL NULL NULL NULL 3 1 6 2 1 1 NULL NULL 1 1 +1 2 3 2 5 3 NULL NULL NULL NULL 3 1 6 2 1 1 NULL NULL 1 2 +1 2 3 2 5 3 NULL NULL NULL NULL 3 3 NULL NULL NULL NULL NULL NULL 1 1 +1 2 3 2 5 3 NULL NULL NULL NULL 3 3 NULL NULL NULL NULL NULL NULL 1 2 +"Standard compliant copy of above query" +SELECT t0.a,t0.b,t1.a,t1.b,t2.a,t2.b,t34.a3,t34.b3,t34.a4,t34.b4, +t5.a,t5.b,t67.a6,t67.b6,t67.a7,t67.b7,t8.a,t8.b,t9.a,t9.b +FROM t0 +CROSS JOIN t1 +LEFT JOIN +( +t2 +LEFT JOIN t34 +ON t34.a3=1 AND t2.b=t34.b4 +CROSS JOIN t5 +LEFT JOIN +( +t67 +LEFT JOIN +t8 +ON t67.b7=t8.b AND t67.b6 < 10 +) +ON t67.b6 >= 2 AND t5.b=t67.b7 +) +ON (t34.b3=2 OR t34.c3 IS NULL) AND (t67.b6=2 OR t67.c6 IS NULL) AND +(t1.b=t5.b OR t34.c3 IS NULL OR t67.c6 IS NULL or t8.c IS NULL) AND +(t1.a <> 2), +t9 +WHERE t0.a=1 AND +t0.b=t1.b AND +(t2.a >= 4 OR t2.c IS NULL) AND +(t34.a3 < 5 OR t34.c3 IS NULL) AND +(t34.b3=t34.b4 OR t34.c3 IS NULL OR t34.c4 IS NULL) AND +(t5.a >=2 OR t5.c IS NULL) AND +(t67.a6 >=4 OR t67.c6 IS NULL) AND +(t67.a7 <= 2 OR t67.c7 IS NULL) AND +(t8.a < 1 OR t8.c IS NULL) AND +(t8.b=t9.b OR t8.c IS NULL) AND +(t9.a=1); +a b a b a b a3 b3 a4 b4 a b a6 b6 a7 b7 a b a b +1 2 2 2 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL 1 1 +1 2 2 2 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL 1 2 +1 2 3 2 4 2 1 2 3 2 2 2 6 2 2 2 0 2 1 2 +1 2 3 2 4 2 1 2 3 2 3 1 6 2 1 1 NULL NULL 1 1 +1 2 3 2 4 2 1 2 3 2 3 1 6 2 1 1 NULL NULL 1 2 +1 2 3 2 4 2 1 2 3 2 3 3 NULL NULL NULL NULL NULL NULL 1 1 +1 2 3 2 4 2 1 2 3 2 3 3 NULL NULL NULL NULL NULL NULL 1 2 +1 2 3 2 4 2 1 2 4 2 2 2 6 2 2 2 0 2 1 2 +1 2 3 2 4 2 1 2 4 2 3 1 6 2 1 1 NULL NULL 1 1 +1 2 3 2 4 2 1 2 4 2 3 1 6 2 1 1 NULL NULL 1 2 +1 2 3 2 4 2 1 2 4 2 3 3 NULL NULL NULL NULL NULL NULL 1 1 +1 2 3 2 4 2 1 2 4 2 3 3 NULL NULL NULL NULL NULL NULL 1 2 +1 2 3 2 5 3 NULL NULL NULL NULL 2 2 6 2 2 2 0 2 1 2 +1 2 3 2 5 3 NULL NULL NULL NULL 3 1 6 2 1 1 NULL NULL 1 1 +1 2 3 2 5 3 NULL NULL NULL NULL 3 1 6 2 1 1 NULL NULL 1 2 +1 2 3 2 5 3 NULL NULL NULL NULL 3 3 NULL NULL NULL NULL NULL NULL 1 1 +1 2 3 2 5 3 NULL NULL NULL NULL 3 3 NULL NULL NULL NULL NULL NULL 1 2 +SELECT t1.a,t1.b +FROM t1; +a b +1 3 +2 2 +3 2 +SELECT t2.a,t2.b +FROM t2; +a b +3 3 +4 2 +5 3 +SELECT t3.a,t3.b +FROM t3; +a b +1 2 +2 2 +SELECT t2.a,t2.b,t3.a,t3.b +FROM t2 +LEFT JOIN +t3 +ON t2.b=t3.b; +a b a b +3 3 NULL NULL +4 2 1 2 +4 2 2 2 +5 3 NULL NULL +SELECT t1.a,t1.b,t2.a,t2.b,t3.a,t3.b +FROM t1, t2 +LEFT JOIN +t3 +ON t2.b=t3.b +WHERE t1.a <= 2; +a b a b a b +1 3 3 3 NULL NULL +1 3 4 2 1 2 +1 3 4 2 2 2 +1 3 5 3 NULL NULL +2 2 3 3 NULL NULL +2 2 4 2 1 2 +2 2 4 2 2 2 +2 2 5 3 NULL NULL +"Standard compliant copy of above query" +SELECT t1.a,t1.b,t2.a,t2.b,t3.a,t3.b +FROM t1 +CROSS JOIN t2 +LEFT JOIN +t3 +ON t2.b=t3.b +WHERE t1.a <= 2; +a b a b a b +1 3 3 3 NULL NULL +1 3 4 2 1 2 +1 3 4 2 2 2 +1 3 5 3 NULL NULL +2 2 3 3 NULL NULL +2 2 4 2 1 2 +2 2 4 2 2 2 +2 2 5 3 NULL NULL +SELECT t1.a,t1.b,t2.a,t2.b,t3.a,t3.b +FROM t1, t3 +RIGHT JOIN +t2 +ON t2.b=t3.b +WHERE t1.a <= 2; +a b a b a b +1 3 3 3 NULL NULL +1 3 4 2 1 2 +1 3 4 2 2 2 +1 3 5 3 NULL NULL +2 2 3 3 NULL NULL +2 2 4 2 1 2 +2 2 4 2 2 2 +2 2 5 3 NULL NULL +"Standard compliant copy of above query" +SELECT t1.a,t1.b,t2.a,t2.b,t3.a,t3.b +FROM t1 CROSS JOIN +( +t3 +RIGHT JOIN +t2 +ON t2.b=t3.b +) +WHERE t1.a <= 2; +a b a b a b +1 3 3 3 NULL NULL +1 3 4 2 1 2 +1 3 4 2 2 2 +1 3 5 3 NULL NULL +2 2 3 3 NULL NULL +2 2 4 2 1 2 +2 2 4 2 2 2 +2 2 5 3 NULL NULL +SELECT t3.a,t3.b,t4.a,t4.b +FROM t3,t4; +a b a b +1 2 3 2 +1 2 4 2 +2 2 3 2 +2 2 4 2 +SELECT t2.a,t2.b,t3.a,t3.b,t4.a,t4.b +FROM t2 +LEFT JOIN +(t3, t4) +ON t3.a=1 AND t2.b=t4.b; +a b a b a b +3 3 NULL NULL NULL NULL +4 2 1 2 3 2 +4 2 1 2 4 2 +5 3 NULL NULL NULL NULL +"Standard compliant copy of above query" +SELECT t2.a,t2.b,t3.a,t3.b,t4.a,t4.b +FROM t2 +LEFT JOIN +(t3 CROSS JOIN t4) +ON t3.a=1 AND t2.b=t4.b; +a b a b a b +3 3 NULL NULL NULL NULL +4 2 1 2 3 2 +4 2 1 2 4 2 +5 3 NULL NULL NULL NULL +SELECT t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b +FROM t1 CROSS JOIN +( +t2 +LEFT JOIN +(t3, t4) +ON t3.a=1 AND t2.b=t4.b +) +WHERE t1.a <= 2; +a b a b a b a b +1 3 3 3 NULL NULL NULL NULL +1 3 4 2 1 2 3 2 +1 3 4 2 1 2 4 2 +1 3 5 3 NULL NULL NULL NULL +2 2 3 3 NULL NULL NULL NULL +2 2 4 2 1 2 3 2 +2 2 4 2 1 2 4 2 +2 2 5 3 NULL NULL NULL NULL +"Standard compliant copy of above query" +SELECT t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b +FROM t1 CROSS JOIN +( +t2 +LEFT JOIN +(t3 CROSS JOIN t4) +ON t3.a=1 AND t2.b=t4.b +) +WHERE t1.a <= 2; +a b a b a b a b +1 3 3 3 NULL NULL NULL NULL +1 3 4 2 1 2 3 2 +1 3 4 2 1 2 4 2 +1 3 5 3 NULL NULL NULL NULL +2 2 3 3 NULL NULL NULL NULL +2 2 4 2 1 2 3 2 +2 2 4 2 1 2 4 2 +2 2 5 3 NULL NULL NULL NULL +SELECT t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b +FROM t1, (t3, t4) +RIGHT JOIN +t2 +ON t3.a=1 AND t2.b=t4.b +WHERE t1.a <= 2; +a b a b a b a b +1 3 3 3 NULL NULL NULL NULL +1 3 4 2 1 2 3 2 +1 3 4 2 1 2 4 2 +1 3 5 3 NULL NULL NULL NULL +2 2 3 3 NULL NULL NULL NULL +2 2 4 2 1 2 3 2 +2 2 4 2 1 2 4 2 +2 2 5 3 NULL NULL NULL NULL +"Standard compliant copy of above query" +SELECT t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b +FROM t1 CROSS JOIN +( +(t3 CROSS JOIN t4) +RIGHT JOIN +t2 +ON t3.a=1 AND t2.b=t4.b +) +WHERE t1.a <= 2; +a b a b a b a b +1 3 3 3 NULL NULL NULL NULL +1 3 4 2 1 2 3 2 +1 3 4 2 1 2 4 2 +1 3 5 3 NULL NULL NULL NULL +2 2 3 3 NULL NULL NULL NULL +2 2 4 2 1 2 3 2 +2 2 4 2 1 2 4 2 +2 2 5 3 NULL NULL NULL NULL +SELECT t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b +FROM t1, (t3, t4) +RIGHT JOIN +t2 +ON t3.a=1 AND t2.b=t4.b +WHERE t1.a <= 2; +a b a b a b a b +1 3 3 3 NULL NULL NULL NULL +1 3 4 2 1 2 3 2 +1 3 4 2 1 2 4 2 +1 3 5 3 NULL NULL NULL NULL +2 2 3 3 NULL NULL NULL NULL +2 2 4 2 1 2 3 2 +2 2 4 2 1 2 4 2 +2 2 5 3 NULL NULL NULL NULL +"Standard compliant copy of above query" +SELECT t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b +FROM t1 CROSS JOIN +( +(t3 CROSS JOIN t4) +RIGHT JOIN +t2 +ON t3.a=1 AND t2.b=t4.b +) +WHERE t1.a <= 2; +a b a b a b a b +1 3 3 3 NULL NULL NULL NULL +1 3 4 2 1 2 3 2 +1 3 4 2 1 2 4 2 +1 3 5 3 NULL NULL NULL NULL +2 2 3 3 NULL NULL NULL NULL +2 2 4 2 1 2 3 2 +2 2 4 2 1 2 4 2 +2 2 5 3 NULL NULL NULL NULL +EXPLAIN +SELECT t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b +FROM t1, (t3, t4) +RIGHT JOIN +t2 +ON t3.a=1 AND t2.b=t4.b +WHERE t1.a <= 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b` from `test`.`t1` join `test`.`t2` left join (`test`.`t3` join `test`.`t4`) on(((`test`.`t4`.`b` = `test`.`t2`.`b`) and (`test`.`t3`.`a` = 1))) where (`test`.`t1`.`a` <= 2) +CREATE INDEX idx_b ON t2(b); +EXPLAIN +SELECT t2.a,t2.b,t3.a,t3.b,t4.a,t4.b +FROM (t3,t4) +LEFT JOIN +(t1,t2) +ON t3.a=1 AND t3.b=t2.b AND t2.b=t4.b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 SIMPLE t2 NULL ref idx_b idx_b 5 test.t3.b 1 100.00 Using where +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b` from `test`.`t3` join `test`.`t4` left join (`test`.`t1` join `test`.`t2`) on(((`test`.`t4`.`b` = `test`.`t3`.`b`) and (`test`.`t2`.`b` = `test`.`t3`.`b`) and (`test`.`t3`.`a` = 1))) where true +SELECT t2.a,t2.b,t3.a,t3.b,t4.a,t4.b +FROM (t3,t4) +LEFT JOIN +(t1,t2) +ON t3.a=1 AND t3.b=t2.b AND t2.b=t4.b; +a b a b a b +4 2 1 2 3 2 +4 2 1 2 3 2 +4 2 1 2 3 2 +4 2 1 2 4 2 +4 2 1 2 4 2 +4 2 1 2 4 2 +NULL NULL 2 2 3 2 +NULL NULL 2 2 4 2 +"Standard compliant copy of above query" +SELECT t2.a,t2.b,t3.a,t3.b,t4.a,t4.b +FROM (t3 CROSS JOIN t4) +LEFT JOIN +(t1 CROSS JOIN t2) +ON t3.a=1 AND t3.b=t2.b AND t2.b=t4.b; +a b a b a b +4 2 1 2 3 2 +4 2 1 2 3 2 +4 2 1 2 3 2 +4 2 1 2 4 2 +4 2 1 2 4 2 +4 2 1 2 4 2 +NULL NULL 2 2 3 2 +NULL NULL 2 2 4 2 +ANALYZE TABLE t0, t1, t2, t3, t4, t5, t6, t7, t8, t9; +Table Op Msg_type Msg_text +test.t0 analyze status OK +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +test.t4 analyze status OK +test.t5 analyze status OK +test.t6 analyze status OK +test.t7 analyze status OK +test.t8 analyze status OK +test.t9 analyze status OK +EXPLAIN +SELECT t0.a,t0.b,t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b, +t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b,t9.a,t9.b +FROM t0,t1 +LEFT JOIN +( +t2 +LEFT JOIN +(t3, t4) +ON t3.a=1 AND t2.b=t4.b, +t5 +LEFT JOIN +( +(t6, t7) +LEFT JOIN +t8 +ON t7.b=t8.b AND t6.b < 10 +) +ON t6.b >= 2 AND t5.b=t7.b +) +ON (t3.b=2 OR t3.c IS NULL) AND (t6.b=2 OR t6.c IS NULL) AND +(t1.b=t5.b OR t3.c IS NULL OR t6.c IS NULL or t8.c IS NULL) AND +(t1.a != 2), +t9 +WHERE t0.a=1 AND +t0.b=t1.b AND +(t2.a >= 4 OR t2.c IS NULL) AND +(t3.a < 5 OR t3.c IS NULL) AND +(t3.b=t4.b OR t3.c IS NULL OR t4.c IS NULL) AND +(t5.a >=2 OR t5.c IS NULL) AND +(t6.a >=4 OR t6.c IS NULL) AND +(t7.a <= 2 OR t7.c IS NULL) AND +(t8.a < 1 OR t8.c IS NULL) AND +(t8.b=t9.b OR t8.c IS NULL) AND +(t9.a=1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE t0 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +2 SIMPLE t9 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 55.56 Using where +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 75.00 Using where +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +2 SIMPLE t5 NULL ALL NULL NULL NULL NULL 3 55.56 Using where +2 SIMPLE t7 NULL ALL NULL NULL NULL NULL 2 75.00 Using where +2 SIMPLE t6 NULL ALL NULL NULL NULL NULL 3 55.56 Using where +2 SIMPLE t8 NULL ALL NULL NULL NULL NULL 2 56.25 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a`,`test`.`t0`.`b` AS `b`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t5`.`a` AS `a`,`test`.`t5`.`b` AS `b`,`test`.`t6`.`a` AS `a`,`test`.`t6`.`b` AS `b`,`test`.`t7`.`a` AS `a`,`test`.`t7`.`b` AS `b`,`test`.`t8`.`a` AS `a`,`test`.`t8`.`b` AS `b`,`test`.`t9`.`a` AS `a`,`test`.`t9`.`b` AS `b` from `test`.`t0` join `test`.`t1` left join (`test`.`t2` left join (`test`.`t3` join `test`.`t4`) on(((`test`.`t4`.`b` = `test`.`t2`.`b`) and (`test`.`t3`.`a` = 1))) join `test`.`t5` left join (`test`.`t6` join `test`.`t7` left join `test`.`t8` on(((`test`.`t8`.`b` = `test`.`t5`.`b`) and (`test`.`t6`.`b` < 10)))) on(((`test`.`t7`.`b` = `test`.`t5`.`b`) and (`test`.`t6`.`b` >= 2)))) on((((`test`.`t3`.`b` = 2) or (`test`.`t3`.`c` is null)) and ((`test`.`t6`.`b` = 2) or (`test`.`t6`.`c` is null)) and ((`test`.`t5`.`b` = `test`.`t0`.`b`) or (`test`.`t3`.`c` is null) or (`test`.`t6`.`c` is null) or (`test`.`t8`.`c` is null)) and (`test`.`t1`.`a` <> 2))) join `test`.`t9` where ((`test`.`t9`.`a` = 1) and (`test`.`t1`.`b` = `test`.`t0`.`b`) and (`test`.`t0`.`a` = 1) and ((`test`.`t2`.`a` >= 4) or (`test`.`t2`.`c` is null)) and ((`test`.`t3`.`a` < 5) or (`test`.`t3`.`c` is null)) and ((`test`.`t4`.`b` = `test`.`t3`.`b`) or (`test`.`t3`.`c` is null) or (`test`.`t4`.`c` is null)) and ((`test`.`t5`.`a` >= 2) or (`test`.`t5`.`c` is null)) and ((`test`.`t6`.`a` >= 4) or (`test`.`t6`.`c` is null)) and ((`test`.`t7`.`a` <= 2) or (`test`.`t7`.`c` is null)) and ((`test`.`t8`.`a` < 1) or (`test`.`t8`.`c` is null)) and ((`test`.`t8`.`b` = `test`.`t9`.`b`) or (`test`.`t8`.`c` is null))) +CREATE INDEX idx_b ON t4(b); +CREATE INDEX idx_b ON t5(b); +ANALYZE TABLE t0, t1, t2, t3, t4, t5, t6, t7, t8, t9; +Table Op Msg_type Msg_text +test.t0 analyze status OK +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +test.t4 analyze status OK +test.t5 analyze status OK +test.t6 analyze status OK +test.t7 analyze status OK +test.t8 analyze status OK +test.t9 analyze status OK +EXPLAIN +SELECT t0.a,t0.b,t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b, +t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b,t9.a,t9.b +FROM t0,t1 +LEFT JOIN +( +t2 +LEFT JOIN +(t3, t4) +ON t3.a=1 AND t2.b=t4.b, +t5 +LEFT JOIN +( +(t6, t7) +LEFT JOIN +t8 +ON t7.b=t8.b AND t6.b < 10 +) +ON t6.b >= 2 AND t5.b=t7.b +) +ON (t3.b=2 OR t3.c IS NULL) AND (t6.b=2 OR t6.c IS NULL) AND +(t1.b=t5.b OR t3.c IS NULL OR t6.c IS NULL or t8.c IS NULL) AND +(t1.a != 2), +t9 +WHERE t0.a=1 AND +t0.b=t1.b AND +(t2.a >= 4 OR t2.c IS NULL) AND +(t3.a < 5 OR t3.c IS NULL) AND +(t3.b=t4.b OR t3.c IS NULL OR t4.c IS NULL) AND +(t5.a >=2 OR t5.c IS NULL) AND +(t6.a >=4 OR t6.c IS NULL) AND +(t7.a <= 2 OR t7.c IS NULL) AND +(t8.a < 1 OR t8.c IS NULL) AND +(t8.b=t9.b OR t8.c IS NULL) AND +(t9.a=1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE t0 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +2 SIMPLE t9 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 55.56 Using where +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 75.00 Using where +2 SIMPLE t4 NULL ALL idx_b NULL NULL NULL 2 100.00 Using where +2 SIMPLE t5 NULL ALL idx_b NULL NULL NULL 3 55.56 Using where +2 SIMPLE t7 NULL ALL NULL NULL NULL NULL 2 75.00 Using where +2 SIMPLE t6 NULL ALL NULL NULL NULL NULL 3 55.56 Using where +2 SIMPLE t8 NULL ALL NULL NULL NULL NULL 2 56.25 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a`,`test`.`t0`.`b` AS `b`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t5`.`a` AS `a`,`test`.`t5`.`b` AS `b`,`test`.`t6`.`a` AS `a`,`test`.`t6`.`b` AS `b`,`test`.`t7`.`a` AS `a`,`test`.`t7`.`b` AS `b`,`test`.`t8`.`a` AS `a`,`test`.`t8`.`b` AS `b`,`test`.`t9`.`a` AS `a`,`test`.`t9`.`b` AS `b` from `test`.`t0` join `test`.`t1` left join (`test`.`t2` left join (`test`.`t3` join `test`.`t4`) on(((`test`.`t4`.`b` = `test`.`t2`.`b`) and (`test`.`t3`.`a` = 1))) join `test`.`t5` left join (`test`.`t6` join `test`.`t7` left join `test`.`t8` on(((`test`.`t8`.`b` = `test`.`t5`.`b`) and (`test`.`t6`.`b` < 10)))) on(((`test`.`t7`.`b` = `test`.`t5`.`b`) and (`test`.`t6`.`b` >= 2)))) on((((`test`.`t3`.`b` = 2) or (`test`.`t3`.`c` is null)) and ((`test`.`t6`.`b` = 2) or (`test`.`t6`.`c` is null)) and ((`test`.`t5`.`b` = `test`.`t0`.`b`) or (`test`.`t3`.`c` is null) or (`test`.`t6`.`c` is null) or (`test`.`t8`.`c` is null)) and (`test`.`t1`.`a` <> 2))) join `test`.`t9` where ((`test`.`t9`.`a` = 1) and (`test`.`t1`.`b` = `test`.`t0`.`b`) and (`test`.`t0`.`a` = 1) and ((`test`.`t2`.`a` >= 4) or (`test`.`t2`.`c` is null)) and ((`test`.`t3`.`a` < 5) or (`test`.`t3`.`c` is null)) and ((`test`.`t4`.`b` = `test`.`t3`.`b`) or (`test`.`t3`.`c` is null) or (`test`.`t4`.`c` is null)) and ((`test`.`t5`.`a` >= 2) or (`test`.`t5`.`c` is null)) and ((`test`.`t6`.`a` >= 4) or (`test`.`t6`.`c` is null)) and ((`test`.`t7`.`a` <= 2) or (`test`.`t7`.`c` is null)) and ((`test`.`t8`.`a` < 1) or (`test`.`t8`.`c` is null)) and ((`test`.`t8`.`b` = `test`.`t9`.`b`) or (`test`.`t8`.`c` is null))) +CREATE INDEX idx_b ON t8(b); +ANALYZE TABLE t0, t1, t2, t3, t4, t5, t6, t7, t8, t9; +Table Op Msg_type Msg_text +test.t0 analyze status OK +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +test.t4 analyze status OK +test.t5 analyze status OK +test.t6 analyze status OK +test.t7 analyze status OK +test.t8 analyze status OK +test.t9 analyze status OK +EXPLAIN +SELECT t0.a,t0.b,t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b, +t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b,t9.a,t9.b +FROM t0,t1 +LEFT JOIN +( +t2 +LEFT JOIN +(t3, t4) +ON t3.a=1 AND t2.b=t4.b, +t5 +LEFT JOIN +( +(t6, t7) +LEFT JOIN +t8 +ON t7.b=t8.b AND t6.b < 10 +) +ON t6.b >= 2 AND t5.b=t7.b +) +ON (t3.b=2 OR t3.c IS NULL) AND (t6.b=2 OR t6.c IS NULL) AND +(t1.b=t5.b OR t3.c IS NULL OR t6.c IS NULL or t8.c IS NULL) AND +(t1.a != 2), +t9 +WHERE t0.a=1 AND +t0.b=t1.b AND +(t2.a >= 4 OR t2.c IS NULL) AND +(t3.a < 5 OR t3.c IS NULL) AND +(t3.b=t4.b OR t3.c IS NULL OR t4.c IS NULL) AND +(t5.a >=2 OR t5.c IS NULL) AND +(t6.a >=4 OR t6.c IS NULL) AND +(t7.a <= 2 OR t7.c IS NULL) AND +(t8.a < 1 OR t8.c IS NULL) AND +(t8.b=t9.b OR t8.c IS NULL) AND +(t9.a=1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE t0 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +2 SIMPLE t9 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 55.56 Using where +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 75.00 Using where +2 SIMPLE t4 NULL ALL idx_b NULL NULL NULL 2 100.00 Using where +2 SIMPLE t5 NULL ALL idx_b NULL NULL NULL 3 55.56 Using where +2 SIMPLE t7 NULL ALL NULL NULL NULL NULL 2 75.00 Using where +2 SIMPLE t6 NULL ALL NULL NULL NULL NULL 3 55.56 Using where +2 SIMPLE t8 NULL ALL idx_b NULL NULL NULL 2 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a`,`test`.`t0`.`b` AS `b`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t5`.`a` AS `a`,`test`.`t5`.`b` AS `b`,`test`.`t6`.`a` AS `a`,`test`.`t6`.`b` AS `b`,`test`.`t7`.`a` AS `a`,`test`.`t7`.`b` AS `b`,`test`.`t8`.`a` AS `a`,`test`.`t8`.`b` AS `b`,`test`.`t9`.`a` AS `a`,`test`.`t9`.`b` AS `b` from `test`.`t0` join `test`.`t1` left join (`test`.`t2` left join (`test`.`t3` join `test`.`t4`) on(((`test`.`t4`.`b` = `test`.`t2`.`b`) and (`test`.`t3`.`a` = 1))) join `test`.`t5` left join (`test`.`t6` join `test`.`t7` left join `test`.`t8` on(((`test`.`t8`.`b` = `test`.`t5`.`b`) and (`test`.`t6`.`b` < 10)))) on(((`test`.`t7`.`b` = `test`.`t5`.`b`) and (`test`.`t6`.`b` >= 2)))) on((((`test`.`t3`.`b` = 2) or (`test`.`t3`.`c` is null)) and ((`test`.`t6`.`b` = 2) or (`test`.`t6`.`c` is null)) and ((`test`.`t5`.`b` = `test`.`t0`.`b`) or (`test`.`t3`.`c` is null) or (`test`.`t6`.`c` is null) or (`test`.`t8`.`c` is null)) and (`test`.`t1`.`a` <> 2))) join `test`.`t9` where ((`test`.`t9`.`a` = 1) and (`test`.`t1`.`b` = `test`.`t0`.`b`) and (`test`.`t0`.`a` = 1) and ((`test`.`t2`.`a` >= 4) or (`test`.`t2`.`c` is null)) and ((`test`.`t3`.`a` < 5) or (`test`.`t3`.`c` is null)) and ((`test`.`t4`.`b` = `test`.`t3`.`b`) or (`test`.`t3`.`c` is null) or (`test`.`t4`.`c` is null)) and ((`test`.`t5`.`a` >= 2) or (`test`.`t5`.`c` is null)) and ((`test`.`t6`.`a` >= 4) or (`test`.`t6`.`c` is null)) and ((`test`.`t7`.`a` <= 2) or (`test`.`t7`.`c` is null)) and ((`test`.`t8`.`a` < 1) or (`test`.`t8`.`c` is null)) and ((`test`.`t8`.`b` = `test`.`t9`.`b`) or (`test`.`t8`.`c` is null))) +CREATE INDEX idx_b ON t1(b); +CREATE INDEX idx_a ON t0(a); +ANALYZE TABLE t0, t1, t2, t3, t4, t5, t6, t7, t8, t9; +Table Op Msg_type Msg_text +test.t0 analyze status OK +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +test.t4 analyze status OK +test.t5 analyze status OK +test.t6 analyze status OK +test.t7 analyze status OK +test.t8 analyze status OK +test.t9 analyze status OK +EXPLAIN +SELECT t0.a,t0.b,t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b, +t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b,t9.a,t9.b +FROM t0,t1 +LEFT JOIN +( +t2 +LEFT JOIN +(t3, t4) +ON t3.a=1 AND t2.b=t4.b, +t5 +LEFT JOIN +( +(t6, t7) +LEFT JOIN +t8 +ON t7.b=t8.b AND t6.b < 10 +) +ON t6.b >= 2 AND t5.b=t7.b +) +ON (t3.b=2 OR t3.c IS NULL) AND (t6.b=2 OR t6.c IS NULL) AND +(t1.b=t5.b OR t3.c IS NULL OR t6.c IS NULL or t8.c IS NULL) AND +(t1.a != 2), +t9 +WHERE t0.a=1 AND +t0.b=t1.b AND +(t2.a >= 4 OR t2.c IS NULL) AND +(t3.a < 5 OR t3.c IS NULL) AND +(t3.b=t4.b OR t3.c IS NULL OR t4.c IS NULL) AND +(t5.a >=2 OR t5.c IS NULL) AND +(t6.a >=4 OR t6.c IS NULL) AND +(t7.a <= 2 OR t7.c IS NULL) AND +(t8.a < 1 OR t8.c IS NULL) AND +(t8.b=t9.b OR t8.c IS NULL) AND +(t9.a=1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE t9 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +2 SIMPLE t1 NULL ALL idx_b NULL NULL NULL 3 100.00 NULL +2 SIMPLE t0 NULL ref idx_a idx_a 5 const 2 33.33 Using where; Using join buffer (Batched Key Access) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 55.56 Using where +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 75.00 Using where +2 SIMPLE t4 NULL ALL idx_b NULL NULL NULL 2 100.00 Using where +2 SIMPLE t5 NULL ALL idx_b NULL NULL NULL 3 55.56 Using where +2 SIMPLE t7 NULL ALL NULL NULL NULL NULL 2 75.00 Using where +2 SIMPLE t6 NULL ALL NULL NULL NULL NULL 3 55.56 Using where +2 SIMPLE t8 NULL ALL idx_b NULL NULL NULL 2 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a`,`test`.`t0`.`b` AS `b`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t5`.`a` AS `a`,`test`.`t5`.`b` AS `b`,`test`.`t6`.`a` AS `a`,`test`.`t6`.`b` AS `b`,`test`.`t7`.`a` AS `a`,`test`.`t7`.`b` AS `b`,`test`.`t8`.`a` AS `a`,`test`.`t8`.`b` AS `b`,`test`.`t9`.`a` AS `a`,`test`.`t9`.`b` AS `b` from `test`.`t0` join `test`.`t1` left join (`test`.`t2` left join (`test`.`t3` join `test`.`t4`) on(((`test`.`t4`.`b` = `test`.`t2`.`b`) and (`test`.`t3`.`a` = 1))) join `test`.`t5` left join (`test`.`t6` join `test`.`t7` left join `test`.`t8` on(((`test`.`t8`.`b` = `test`.`t5`.`b`) and (`test`.`t6`.`b` < 10)))) on(((`test`.`t7`.`b` = `test`.`t5`.`b`) and (`test`.`t6`.`b` >= 2)))) on((((`test`.`t3`.`b` = 2) or (`test`.`t3`.`c` is null)) and ((`test`.`t6`.`b` = 2) or (`test`.`t6`.`c` is null)) and ((`test`.`t5`.`b` = `test`.`t1`.`b`) or (`test`.`t3`.`c` is null) or (`test`.`t6`.`c` is null) or (`test`.`t8`.`c` is null)) and (`test`.`t1`.`a` <> 2))) join `test`.`t9` where ((`test`.`t9`.`a` = 1) and (`test`.`t0`.`b` = `test`.`t1`.`b`) and (`test`.`t0`.`a` = 1) and ((`test`.`t2`.`a` >= 4) or (`test`.`t2`.`c` is null)) and ((`test`.`t3`.`a` < 5) or (`test`.`t3`.`c` is null)) and ((`test`.`t4`.`b` = `test`.`t3`.`b`) or (`test`.`t3`.`c` is null) or (`test`.`t4`.`c` is null)) and ((`test`.`t5`.`a` >= 2) or (`test`.`t5`.`c` is null)) and ((`test`.`t6`.`a` >= 4) or (`test`.`t6`.`c` is null)) and ((`test`.`t7`.`a` <= 2) or (`test`.`t7`.`c` is null)) and ((`test`.`t8`.`a` < 1) or (`test`.`t8`.`c` is null)) and ((`test`.`t8`.`b` = `test`.`t9`.`b`) or (`test`.`t8`.`c` is null))) +SELECT t0.a,t0.b,t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b, +t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b,t9.a,t9.b +FROM t0,t1 +LEFT JOIN +( +t2 +LEFT JOIN +(t3, t4) +ON t3.a=1 AND t2.b=t4.b, +t5 +LEFT JOIN +( +(t6, t7) +LEFT JOIN +t8 +ON t7.b=t8.b AND t6.b < 10 +) +ON t6.b >= 2 AND t5.b=t7.b +) +ON (t3.b=2 OR t3.c IS NULL) AND (t6.b=2 OR t6.c IS NULL) AND +(t1.b=t5.b OR t3.c IS NULL OR t6.c IS NULL or t8.c IS NULL) AND +(t1.a != 2), +t9 +WHERE t0.a=1 AND +t0.b=t1.b AND +(t2.a >= 4 OR t2.c IS NULL) AND +(t3.a < 5 OR t3.c IS NULL) AND +(t3.b=t4.b OR t3.c IS NULL OR t4.c IS NULL) AND +(t5.a >=2 OR t5.c IS NULL) AND +(t6.a >=4 OR t6.c IS NULL) AND +(t7.a <= 2 OR t7.c IS NULL) AND +(t8.a < 1 OR t8.c IS NULL) AND +(t8.b=t9.b OR t8.c IS NULL) AND +(t9.a=1); +a b a b a b a b a b a b a b a b a b a b +1 2 2 2 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL 1 1 +1 2 2 2 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL 1 2 +1 2 3 2 4 2 1 2 3 2 2 2 6 2 2 2 0 2 1 2 +1 2 3 2 4 2 1 2 3 2 3 1 6 2 1 1 NULL NULL 1 1 +1 2 3 2 4 2 1 2 3 2 3 1 6 2 1 1 NULL NULL 1 2 +1 2 3 2 4 2 1 2 3 2 3 3 NULL NULL NULL NULL NULL NULL 1 1 +1 2 3 2 4 2 1 2 3 2 3 3 NULL NULL NULL NULL NULL NULL 1 2 +1 2 3 2 4 2 1 2 4 2 2 2 6 2 2 2 0 2 1 2 +1 2 3 2 4 2 1 2 4 2 3 1 6 2 1 1 NULL NULL 1 1 +1 2 3 2 4 2 1 2 4 2 3 1 6 2 1 1 NULL NULL 1 2 +1 2 3 2 4 2 1 2 4 2 3 3 NULL NULL NULL NULL NULL NULL 1 1 +1 2 3 2 4 2 1 2 4 2 3 3 NULL NULL NULL NULL NULL NULL 1 2 +1 2 3 2 5 3 NULL NULL NULL NULL 2 2 6 2 2 2 0 2 1 2 +1 2 3 2 5 3 NULL NULL NULL NULL 3 1 6 2 1 1 NULL NULL 1 1 +1 2 3 2 5 3 NULL NULL NULL NULL 3 1 6 2 1 1 NULL NULL 1 2 +1 2 3 2 5 3 NULL NULL NULL NULL 3 3 NULL NULL NULL NULL NULL NULL 1 1 +1 2 3 2 5 3 NULL NULL NULL NULL 3 3 NULL NULL NULL NULL NULL NULL 1 2 +"Standard compliant copy of above query" +SELECT t0.a,t0.b,t1.a,t1.b,t2.a,t2.b,t34.a3,t34.b3,t34.a4,t34.b4, +t5.a,t5.b,t67.a6,t67.b6,t67.a7,t67.b7,t8.a,t8.b,t9.a,t9.b +FROM t0 +CROSS JOIN t1 +LEFT JOIN +( +t2 +LEFT JOIN +t34 +ON t34.a3=1 AND t2.b=t34.b4 +CROSS JOIN t5 +LEFT JOIN +( +t67 +LEFT JOIN +t8 +ON t67.b7=t8.b AND t67.b6 < 10 +) +ON t67.b6 >= 2 AND t5.b=t67.b7 +) +ON (t34.b3=2 OR t34.c3 IS NULL) AND (t67.b6=2 OR t67.c6 IS NULL) AND +(t1.b=t5.b OR t34.c3 IS NULL OR t67.c6 IS NULL or t8.c IS NULL) AND +(t1.a <> 2) +CROSS JOIN t9 +WHERE t0.a=1 AND +t0.b=t1.b AND +(t2.a >= 4 OR t2.c IS NULL) AND +(t34.a3 < 5 OR t34.c3 IS NULL) AND +(t34.b3=t34.b4 OR t34.c3 IS NULL OR t34.c4 IS NULL) AND +(t5.a >=2 OR t5.c IS NULL) AND +(t67.a6 >=4 OR t67.c6 IS NULL) AND +(t67.a7 <= 2 OR t67.c7 IS NULL) AND +(t8.a < 1 OR t8.c IS NULL) AND +(t8.b=t9.b OR t8.c IS NULL) AND +(t9.a=1); +a b a b a b a3 b3 a4 b4 a b a6 b6 a7 b7 a b a b +1 2 2 2 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL 1 1 +1 2 2 2 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL 1 2 +1 2 3 2 4 2 1 2 3 2 2 2 6 2 2 2 0 2 1 2 +1 2 3 2 4 2 1 2 3 2 3 1 6 2 1 1 NULL NULL 1 1 +1 2 3 2 4 2 1 2 3 2 3 1 6 2 1 1 NULL NULL 1 2 +1 2 3 2 4 2 1 2 3 2 3 3 NULL NULL NULL NULL NULL NULL 1 1 +1 2 3 2 4 2 1 2 3 2 3 3 NULL NULL NULL NULL NULL NULL 1 2 +1 2 3 2 4 2 1 2 4 2 2 2 6 2 2 2 0 2 1 2 +1 2 3 2 4 2 1 2 4 2 3 1 6 2 1 1 NULL NULL 1 1 +1 2 3 2 4 2 1 2 4 2 3 1 6 2 1 1 NULL NULL 1 2 +1 2 3 2 4 2 1 2 4 2 3 3 NULL NULL NULL NULL NULL NULL 1 1 +1 2 3 2 4 2 1 2 4 2 3 3 NULL NULL NULL NULL NULL NULL 1 2 +1 2 3 2 5 3 NULL NULL NULL NULL 2 2 6 2 2 2 0 2 1 2 +1 2 3 2 5 3 NULL NULL NULL NULL 3 1 6 2 1 1 NULL NULL 1 1 +1 2 3 2 5 3 NULL NULL NULL NULL 3 1 6 2 1 1 NULL NULL 1 2 +1 2 3 2 5 3 NULL NULL NULL NULL 3 3 NULL NULL NULL NULL NULL NULL 1 1 +1 2 3 2 5 3 NULL NULL NULL NULL 3 3 NULL NULL NULL NULL NULL NULL 1 2 +SELECT t2.a,t2.b +FROM t2; +a b +3 3 +4 2 +5 3 +SELECT t3.a,t3.b +FROM t3; +a b +1 2 +2 2 +SELECT t2.a,t2.b,t3.a,t3.b +FROM t2 LEFT JOIN t3 ON t2.b=t3.b +WHERE t2.a = 4 OR (t2.a > 4 AND t3.a IS NULL); +a b a b +4 2 1 2 +4 2 2 2 +5 3 NULL NULL +SELECT t2.a,t2.b,t3.a,t3.b +FROM t2 LEFT JOIN (t3) ON t2.b=t3.b +WHERE t2.a = 4 OR (t2.a > 4 AND t3.a IS NULL); +a b a b +4 2 1 2 +4 2 2 2 +5 3 NULL NULL +ALTER TABLE t3 +CHANGE COLUMN a a1 int, +CHANGE COLUMN c c1 int; +SELECT t2.a,t2.b,t3.a1,t3.b +FROM t2 LEFT JOIN t3 ON t2.b=t3.b +WHERE t2.a = 4 OR (t2.a > 4 AND t3.a1 IS NULL); +a b a1 b +4 2 1 2 +4 2 2 2 +5 3 NULL NULL +SELECT t2.a,t2.b,t3.a1,t3.b +FROM t2 NATURAL LEFT JOIN t3 +WHERE t2.a = 4 OR (t2.a > 4 AND t3.a1 IS NULL); +a b a1 b +4 2 1 2 +4 2 2 2 +5 3 NULL NULL +DROP TABLE t0,t1,t2,t3,t4,t5,t6,t7,t8,t9; +DROP TABLE t34, t345, t67; +CREATE TABLE t1 (a int); +CREATE TABLE t2 (a int); +CREATE TABLE t3 (a int); +INSERT INTO t1 VALUES (1); +INSERT INTO t2 VALUES (2); +INSERT INTO t3 VALUES (2); +INSERT INTO t1 VALUES (2); +SELECT * FROM t1 LEFT JOIN (t2 LEFT JOIN t3 ON t2.a=t3.a) ON t1.a=t3.a; +a a a +1 NULL NULL +2 2 2 +SELECT * FROM t1 LEFT JOIN t2 LEFT JOIN t3 ON t2.a=t3.a ON t1.a=t3.a; +a a a +1 NULL NULL +2 2 2 +DELETE FROM t1 WHERE a=2; +SELECT * FROM t1 LEFT JOIN t2 LEFT JOIN t3 ON t2.a=t3.a ON t1.a=t3.a; +a a a +1 NULL NULL +DELETE FROM t2; +SELECT * FROM t1 LEFT JOIN t2 LEFT JOIN t3 ON t2.a=t3.a ON t1.a=t3.a; +a a a +1 NULL NULL +DROP TABLE t1,t2,t3; +CREATE TABLE t1(a int, key (a)); +CREATE TABLE t2(b int, key (b)); +CREATE TABLE t3(c int, key (c)); +INSERT INTO t1 VALUES (NULL), (0), (1), (2), (3), (4), (5), (6), (7), (8), (9), +(10), (11), (12), (13), (14), (15), (16), (17), (18), (19); +INSERT INTO t2 VALUES (NULL), (0), (1), (2), (3), (4), (5), (6), (7), (8), (9), +(10), (11), (12), (13), (14), (15), (16), (17), (18), (19); +INSERT INTO t3 VALUES (0), (1), (2), (3), (4), (5); +ANALYZE TABLE t1, t2, t3; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +EXPLAIN SELECT a, b, c FROM t1 LEFT JOIN (t2, t3) ON c < 3 and b = c; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 21 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL a 5 NULL 21 100.00 Using index +2 SIMPLE t3 NULL index c c 5 NULL 6 100.00 Using where; Using index +2 SIMPLE t2 NULL ref b b 5 test.t3.c 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`c` AS `c` from `test`.`t1` left join (`test`.`t2` join `test`.`t3`) on(((`test`.`t2`.`b` = `test`.`t3`.`c`) and (`test`.`t3`.`c` < 3))) where true +EXPLAIN SELECT a, b, c FROM t1 LEFT JOIN (t2, t3) ON b < 3 and b = c; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 21 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL a 5 NULL 21 100.00 Using index +2 SIMPLE t3 NULL index c c 5 NULL 6 100.00 Using where; Using index +2 SIMPLE t2 NULL ref b b 5 test.t3.c 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`c` AS `c` from `test`.`t1` left join (`test`.`t2` join `test`.`t3`) on(((`test`.`t2`.`b` = `test`.`t3`.`c`) and (`test`.`t3`.`c` < 3))) where true +SELECT a, b, c FROM t1 LEFT JOIN (t2, t3) ON b < 3 and b = c; +a b c +0 0 0 +0 1 1 +0 2 2 +1 0 0 +1 1 1 +1 2 2 +10 0 0 +10 1 1 +10 2 2 +11 0 0 +11 1 1 +11 2 2 +12 0 0 +12 1 1 +12 2 2 +13 0 0 +13 1 1 +13 2 2 +14 0 0 +14 1 1 +14 2 2 +15 0 0 +15 1 1 +15 2 2 +16 0 0 +16 1 1 +16 2 2 +17 0 0 +17 1 1 +17 2 2 +18 0 0 +18 1 1 +18 2 2 +19 0 0 +19 1 1 +19 2 2 +2 0 0 +2 1 1 +2 2 2 +3 0 0 +3 1 1 +3 2 2 +4 0 0 +4 1 1 +4 2 2 +5 0 0 +5 1 1 +5 2 2 +6 0 0 +6 1 1 +6 2 2 +7 0 0 +7 1 1 +7 2 2 +8 0 0 +8 1 1 +8 2 2 +9 0 0 +9 1 1 +9 2 2 +NULL 0 0 +NULL 1 1 +NULL 2 2 +DELETE FROM t3; +ANALYZE TABLE t3; +Table Op Msg_type Msg_text +test.t3 analyze status OK +EXPLAIN SELECT a, b, c FROM t1 LEFT JOIN (t2, t3) ON b < 3 and b = c; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 21 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL a 5 NULL 21 100.00 Using index +2 SIMPLE t3 NULL index c c 5 NULL 1 100.00 Using where; Using index +2 SIMPLE t2 NULL ref b b 5 test.t3.c 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`c` AS `c` from `test`.`t1` left join (`test`.`t2` join `test`.`t3`) on(((`test`.`t2`.`b` = `test`.`t3`.`c`) and (`test`.`t3`.`c` < 3))) where true +SELECT a, b, c FROM t1 LEFT JOIN (t2, t3) ON b < 3 and b = c; +a b c +0 NULL NULL +1 NULL NULL +10 NULL NULL +11 NULL NULL +12 NULL NULL +13 NULL NULL +14 NULL NULL +15 NULL NULL +16 NULL NULL +17 NULL NULL +18 NULL NULL +19 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 NULL NULL +7 NULL NULL +8 NULL NULL +9 NULL NULL +NULL NULL NULL +DROP TABLE t1,t2,t3; +CREATE TABLE t1 (c11 int); +CREATE TABLE t2 (c21 int); +CREATE TABLE t3 (c31 int); +INSERT INTO t1 VALUES (4), (5); +ANALYZE TABLE t1, t2, t3; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +SELECT * FROM t1 LEFT JOIN t2 ON c11=c21; +c11 c21 +4 NULL +5 NULL +EXPLAIN SELECT * FROM t1 LEFT JOIN t2 ON c11=c21; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c11` AS `c11`,`test`.`t2`.`c21` AS `c21` from `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`c21` = `test`.`t1`.`c11`)) where true +SELECT * FROM t1 LEFT JOIN (t2 LEFT JOIN t3 ON c21=c31) ON c11=c21; +c11 c21 c31 +4 NULL NULL +5 NULL NULL +EXPLAIN SELECT * FROM t1 LEFT JOIN (t2 LEFT JOIN t3 ON c21=c31) ON c11=c21; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c11` AS `c11`,`test`.`t2`.`c21` AS `c21`,`test`.`t3`.`c31` AS `c31` from `test`.`t1` left join (`test`.`t2` left join `test`.`t3` on((`test`.`t3`.`c31` = `test`.`t1`.`c11`))) on((`test`.`t2`.`c21` = `test`.`t1`.`c11`)) where true +DROP TABLE t1,t2,t3; +CREATE TABLE t1 (goods int(12) NOT NULL, price varchar(128) NOT NULL); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (23, 2340), (26, 9900); +CREATE TABLE t2 (goods int(12), name varchar(50), shop char(2)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (23, 'as300', 'fr'), (26, 'as600', 'fr'); +create table t3 (groupid int(12) NOT NULL, goodsid int(12) NOT NULL); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t3 VALUES (3,23), (6,26); +CREATE TABLE t4 (groupid int(12)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t4 VALUES (1), (2), (3), (4), (5), (6); +SELECT * FROM +(SELECT DISTINCT gl.groupid, gp.price +FROM t4 gl +LEFT JOIN +(t3 g INNER JOIN t2 p ON g.goodsid = p.goods +INNER JOIN t1 gp ON p.goods = gp.goods) +ON gl.groupid = g.groupid and p.shop = 'fr') t; +groupid price +1 NULL +2 NULL +3 2340 +4 NULL +5 NULL +6 9900 +CREATE VIEW v1 AS +SELECT g.groupid groupid, p.goods goods, +p.name name, p.shop shop, +gp.price price +FROM t3 g INNER JOIN t2 p ON g.goodsid = p.goods +INNER JOIN t1 gp on p.goods = gp.goods; +CREATE VIEW v2 AS +SELECT DISTINCT g.groupid, fr.price +FROM t4 g +LEFT JOIN +v1 fr on g.groupid = fr.groupid and fr.shop = 'fr'; +SELECT * FROM v2; +groupid price +1 NULL +2 NULL +3 2340 +4 NULL +5 NULL +6 9900 +SELECT * FROM +(SELECT DISTINCT g.groupid, fr.price +FROM t4 g +LEFT JOIN +v1 fr on g.groupid = fr.groupid and fr.shop = 'fr') t; +groupid price +1 NULL +2 NULL +3 2340 +4 NULL +5 NULL +6 9900 +DROP VIEW v1,v2; +DROP TABLE t1,t2,t3,t4; +CREATE TABLE t1(a int); +CREATE TABLE t2(b int); +CREATE TABLE t3(c int, d int); +CREATE TABLE t4(d int); +CREATE TABLE t5(e int, f int); +CREATE TABLE t6(f int); +CREATE VIEW v1 AS +SELECT e FROM t5 JOIN t6 ON t5.e=t6.f; +CREATE VIEW v2 AS +SELECT e FROM t5 NATURAL JOIN t6; +SELECT t1.a FROM t1 JOIN t2 ON a=b JOIN t3 ON a=c JOIN t4 USING(d); +a +SELECT t1.x FROM t1 JOIN t2 ON a=b JOIN t3 ON a=c JOIN t4 USING(d); +ERROR 42S22: Unknown column 't1.x' in 'field list' +SELECT t1.a FROM t1 JOIN t2 ON a=b JOIN t3 ON a=c NATURAL JOIN t4; +a +SELECT t1.x FROM t1 JOIN t2 ON a=b JOIN t3 ON a=c NATURAL JOIN t4; +ERROR 42S22: Unknown column 't1.x' in 'field list' +SELECT v1.e FROM v1 JOIN t2 ON e=b JOIN t3 ON e=c JOIN t4 USING(d); +e +SELECT v1.x FROM v1 JOIN t2 ON e=b JOIN t3 ON e=c JOIN t4 USING(d); +ERROR 42S22: Unknown column 'v1.x' in 'field list' +SELECT v2.e FROM v2 JOIN t2 ON e=b JOIN t3 ON e=c JOIN t4 USING(d); +e +SELECT v2.x FROM v2 JOIN t2 ON e=b JOIN t3 ON e=c JOIN t4 USING(d); +ERROR 42S22: Unknown column 'v2.x' in 'field list' +DROP VIEW v1, v2; +DROP TABLE t1, t2, t3, t4, t5, t6; +create table t1 (id1 int(11) not null); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t1 values (1),(2); +create table t2 (id2 int(11) not null); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t2 values (1),(2),(3),(4); +create table t3 (id3 char(16) not null); +insert into t3 values ('100'); +create table t4 (id2 int(11) not null, id3 char(16)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +create table t5 (id1 int(11) not null, key (id1)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t5 values (1),(2),(1); +create view v1 as +select t4.id3 from t4 join t2 on t4.id2 = t2.id2; +select t1.id1 from t1 inner join (t3 left join v1 on t3.id3 = v1.id3); +id1 +1 +2 +drop view v1; +drop table t1, t2, t3, t4, t5; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3); +create table t1(a int); +insert into t1 select A.a + 10*(B.a) from t0 A, t0 B; +create table t2 (a int, b int); +insert into t2 values (1,1), (2,2), (3,3); +create table t3(a int, b int, filler char(200), key(a)); +insert into t3 select a,a,'filler' from t1; +insert into t3 select a,a,'filler' from t1; +create table t4 like t3; +insert into t4 select * from t3; +insert into t4 select * from t3; +create table t5 like t4; +insert into t5 select * from t4; +insert into t5 select * from t4; +create table t6 like t5; +insert into t6 select * from t5; +insert into t6 select * from t5; +create table t7 like t6; +insert into t7 select * from t6; +insert into t7 select * from t6; +ANALYZE TABLE t1, t2, t3, t4, t5, t6, t7; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +test.t4 analyze status OK +test.t5 analyze status OK +test.t6 analyze status OK +test.t7 analyze status OK +explain select * from t4 join +t2 left join (t3 join t5 on t5.a=t3.b) on t3.a=t2.b where t4.a<=>t3.b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL X 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL X 100.00 NULL +2 SIMPLE t3 NULL ref a a 5 test.t2.b X 100.00 Using join buffer (Batched Key Access) +2 SIMPLE t5 NULL ref a a 5 test.t3.b X 100.00 Using join buffer (Batched Key Access) +2 SIMPLE t4 NULL ref a a 5 test.t3.b X 100.00 Using index condition; Using join buffer (Batched Key Access) +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t4`.`filler` AS `filler`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t3`.`filler` AS `filler`,`test`.`t5`.`a` AS `a`,`test`.`t5`.`b` AS `b`,`test`.`t5`.`filler` AS `filler` from `test`.`t4` join `test`.`t2` left join (`test`.`t3` join `test`.`t5`) on(((`test`.`t5`.`a` = `test`.`t3`.`b`) and (`test`.`t3`.`a` = `test`.`t2`.`b`))) where (`test`.`t4`.`a` <=> `test`.`t3`.`b`) +explain select * from (t4 join t6 on t6.a=t4.b) right join t3 on t4.a=t3.b +join t2 left join (t5 join t7 on t7.a=t5.b) on t5.a=t2.b where t3.a<=>t2.b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL X 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL X 100.00 NULL +2 SIMPLE t3 NULL ref a a 5 test.t2.b X 100.00 Using index condition; Using join buffer (Batched Key Access) +2 SIMPLE t4 NULL ref a a 5 test.t3.b X 100.00 Using join buffer (Batched Key Access) +2 SIMPLE t6 NULL ref a a 5 test.t4.b X 100.00 Using join buffer (Batched Key Access) +2 SIMPLE t5 NULL ref a a 5 test.t2.b X 100.00 Using join buffer (Batched Key Access) +2 SIMPLE t7 NULL ref a a 5 test.t5.b X 100.00 Using join buffer (Batched Key Access) +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t4`.`filler` AS `filler`,`test`.`t6`.`a` AS `a`,`test`.`t6`.`b` AS `b`,`test`.`t6`.`filler` AS `filler`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t3`.`filler` AS `filler`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t5`.`a` AS `a`,`test`.`t5`.`b` AS `b`,`test`.`t5`.`filler` AS `filler`,`test`.`t7`.`a` AS `a`,`test`.`t7`.`b` AS `b`,`test`.`t7`.`filler` AS `filler` from `test`.`t3` left join (`test`.`t4` join `test`.`t6`) on(((`test`.`t6`.`a` = `test`.`t4`.`b`) and (`test`.`t4`.`a` = `test`.`t3`.`b`))) join `test`.`t2` left join (`test`.`t5` join `test`.`t7`) on(((`test`.`t7`.`a` = `test`.`t5`.`b`) and (`test`.`t5`.`a` = `test`.`t2`.`b`))) where (`test`.`t3`.`a` <=> `test`.`t2`.`b`) +explain select * from t2 left join +(t3 left join (t4 join t6 on t6.a=t4.b) on t4.a=t3.b +join t5 on t5.a=t3.b) on t3.a=t2.b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL X 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL X 100.00 NULL +2 SIMPLE t3 NULL ref a a 5 test.t2.b X 100.00 Using join buffer (Batched Key Access) +2 SIMPLE t5 NULL ref a a 5 test.t3.b X 100.00 Using join buffer (Batched Key Access) +2 SIMPLE t4 NULL ref a a 5 test.t5.a X 100.00 Using where; Using join buffer (Batched Key Access) +2 SIMPLE t6 NULL ref a a 5 test.t4.b X 100.00 Using join buffer (Batched Key Access) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t3`.`filler` AS `filler`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t4`.`filler` AS `filler`,`test`.`t6`.`a` AS `a`,`test`.`t6`.`b` AS `b`,`test`.`t6`.`filler` AS `filler`,`test`.`t5`.`a` AS `a`,`test`.`t5`.`b` AS `b`,`test`.`t5`.`filler` AS `filler` from `test`.`t2` left join (`test`.`t3` left join (`test`.`t4` join `test`.`t6`) on(((`test`.`t6`.`a` = `test`.`t4`.`b`) and (`test`.`t4`.`a` = `test`.`t3`.`b`))) join `test`.`t5`) on(((`test`.`t5`.`a` = `test`.`t3`.`b`) and (`test`.`t3`.`a` = `test`.`t2`.`b`))) where true +drop table t0, t1, t2, t3, t4, t5, t6, t7; +create table t1 (a int); +insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t2 (a int, filler char(100), key(a)); +insert into t2 select A.a + 10*B.a, '' from t1 A, t1 B; +create table t3 like t2; +insert into t3 select * from t2; +ANALYZE TABLE t1, t2, t3; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +explain select * from t1 left join +(t2 left join t3 on (t2.a = t3.a)) +on (t1.a = t2.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 100.00 NULL +2 SIMPLE t2 NULL ref a a 5 test.t1.a 1 100.00 Using join buffer (Batched Key Access) +2 SIMPLE t3 NULL ref a a 5 test.t1.a 1 100.00 Using join buffer (Batched Key Access) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`filler` AS `filler`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`filler` AS `filler` from `test`.`t1` left join (`test`.`t2` left join `test`.`t3` on((`test`.`t3`.`a` = `test`.`t1`.`a`))) on((`test`.`t2`.`a` = `test`.`t1`.`a`)) where true +drop table t1, t2, t3; +CREATE TABLE t1 (id int NOT NULL PRIMARY KEY, type varchar(10)); +CREATE TABLE t2 (pid int NOT NULL PRIMARY KEY, type varchar(10)); +CREATE TABLE t3 (cid int NOT NULL PRIMARY KEY, +id int NOT NULL, +pid int NOT NULL); +INSERT INTO t1 VALUES (1, 'A'), (3, 'C'); +INSERT INTO t2 VALUES (1, 'A'), (3, 'C'); +INSERT INTO t3 VALUES (1, 1, 1), (3, 3, 3); +SELECT * FROM t1 p LEFT JOIN (t3 JOIN t1) +ON (t1.id=t3.id AND t1.type='B' AND p.id=t3.id) +LEFT JOIN t2 ON (t3.pid=t2.pid) +WHERE p.id=1; +id type cid id pid id type pid type +1 A NULL NULL NULL NULL NULL NULL NULL +CREATE VIEW v1 AS +SELECT t3.* FROM t3 JOIN t1 ON t1.id=t3.id AND t1.type='B'; +SELECT * FROM t1 p LEFT JOIN v1 ON p.id=v1.id +LEFT JOIN t2 ON v1.pid=t2.pid +WHERE p.id=1; +id type cid id pid pid type +1 A NULL NULL NULL NULL NULL +DROP VIEW v1; +DROP TABLE t1,t2,t3; +CREATE TABLE t1 (id1 int PRIMARY KEY, id2 int); +CREATE TABLE t2 (id1 int PRIMARY KEY, id2 int); +CREATE TABLE t3 (id1 int PRIMARY KEY, id2 int); +CREATE TABLE t4 (id1 int PRIMARY KEY, id2 int); +CREATE TABLE t5 (id1 int PRIMARY KEY, id2 int); +SELECT t1.id1 AS id, t5.id1 AS ngroupbynsa +FROM t1 INNER JOIN t2 ON t2.id2 = t1.id1 +LEFT OUTER JOIN +(t3 INNER JOIN t4 ON t4.id1 = t3.id2 INNER JOIN t5 ON t4.id2 = t5.id1) +ON t3.id2 IS NOT NULL +WHERE t1.id1=2; +id ngroupbynsa +PREPARE stmt FROM +"SELECT t1.id1 AS id, t5.id1 AS ngroupbynsa + FROM t1 INNER JOIN t2 ON t2.id2 = t1.id1 + LEFT OUTER JOIN + (t3 INNER JOIN t4 ON t4.id1 = t3.id2 INNER JOIN t5 ON t4.id2 = t5.id1) + ON t3.id2 IS NOT NULL + WHERE t1.id1=2"; +EXECUTE stmt; +id ngroupbynsa +EXECUTE stmt; +id ngroupbynsa +EXECUTE stmt; +id ngroupbynsa +EXECUTE stmt; +id ngroupbynsa +INSERT INTO t1 VALUES (1,1), (2,1), (3,2); +INSERT INTO t2 VALUES (2,1), (3,2), (4,3); +INSERT INTO t3 VALUES (1,1), (3,2), (2,NULL); +INSERT INTO t4 VALUES (1,1), (2,1), (3,3); +INSERT INTO t5 VALUES (1,1), (2,2), (3,3), (4,3); +EXECUTE stmt; +id ngroupbynsa +2 1 +2 1 +EXECUTE stmt; +id ngroupbynsa +2 1 +2 1 +EXECUTE stmt; +id ngroupbynsa +2 1 +2 1 +EXECUTE stmt; +id ngroupbynsa +2 1 +2 1 +SELECT t1.id1 AS id, t5.id1 AS ngroupbynsa +FROM t1 INNER JOIN t2 ON t2.id2 = t1.id1 +LEFT OUTER JOIN +(t3 INNER JOIN t4 ON t4.id1 = t3.id2 INNER JOIN t5 ON t4.id2 = t5.id1) +ON t3.id2 IS NOT NULL +WHERE t1.id1=2; +id ngroupbynsa +2 1 +2 1 +DROP TABLE t1,t2,t3,t4,t5; +CREATE TABLE t1 ( +id int NOT NULL PRIMARY KEY, +ct int DEFAULT NULL, +pc int DEFAULT NULL, +INDEX idx_ct (ct), +INDEX idx_pc (pc) +); +INSERT INTO t1 VALUES +(1,NULL,NULL),(2,NULL,NULL),(3,NULL,NULL),(4,NULL,NULL),(5,NULL,NULL); +CREATE TABLE t2 ( +id int NOT NULL PRIMARY KEY, +sr int NOT NULL, +nm varchar(255) NOT NULL, +INDEX idx_sr (sr) +); +INSERT INTO t2 VALUES +(2441905,4308,'LesAbymes'),(2441906,4308,'Anse-Bertrand'); +CREATE TABLE t3 ( +id int NOT NULL PRIMARY KEY, +ct int NOT NULL, +ln int NOT NULL, +INDEX idx_ct (ct), +INDEX idx_ln (ln) +); +CREATE TABLE t4 ( +id int NOT NULL PRIMARY KEY, +nm varchar(255) NOT NULL +); +INSERT INTO t4 VALUES (4308,'Guadeloupe'),(4309,'Martinique'); +SELECT t1.* +FROM t1 LEFT JOIN +(t2 LEFT JOIN t3 ON t3.ct=t2.id AND t3.ln='5') ON t1.ct=t2.id +WHERE t1.id='5'; +id ct pc +5 NULL NULL +SELECT t1.*, t4.nm +FROM t1 LEFT JOIN +(t2 LEFT JOIN t3 ON t3.ct=t2.id AND t3.ln='5') ON t1.ct=t2.id +LEFT JOIN t4 ON t2.sr=t4.id +WHERE t1.id='5'; +id ct pc nm +5 NULL NULL NULL +DROP TABLE t1,t2,t3,t4; +CREATE TABLE t1 (a INT, b INT); +CREATE TABLE t2 (a INT); +CREATE TABLE t3 (a INT, c INT); +CREATE TABLE t4 (a INT, c INT); +CREATE TABLE t5 (a INT, c INT); +SELECT b FROM t1 JOIN (t2 LEFT JOIN t3 USING (a) LEFT JOIN t4 USING (a) +LEFT JOIN t5 USING (a)) USING (a); +b +SELECT c FROM t1 JOIN (t2 LEFT JOIN t3 USING (a) LEFT JOIN t4 USING (a) +LEFT JOIN t5 USING (a)) USING (a); +ERROR 23000: Column 'c' in field list is ambiguous +SELECT b FROM t1 JOIN (t2 JOIN t3 USING (a) JOIN t4 USING (a) +JOIN t5 USING (a)) USING (a); +b +SELECT c FROM t1 JOIN (t2 JOIN t3 USING (a) JOIN t4 USING (a) +JOIN t5 USING (a)) USING (a); +ERROR 23000: Column 'c' in field list is ambiguous +DROP TABLE t1,t2,t3,t4,t5; +CREATE TABLE t1 (a INT, b INT); +CREATE TABLE t2 (a INT, b INT); +CREATE TABLE t3 (a INT, b INT); +INSERT INTO t1 VALUES (1,1); +INSERT INTO t2 VALUES (1,1); +INSERT INTO t3 VALUES (1,1); +SELECT * FROM t1 JOIN (t2 JOIN t3 USING (b)) USING (a); +ERROR 23000: Column 'a' in from clause is ambiguous +DROP TABLE t1,t2,t3; +CREATE TABLE t1 ( +carrier char(2) default NULL, +id int NOT NULL auto_increment PRIMARY KEY +) CHARSET utf8mb4; +INSERT INTO t1 VALUES +('CO',235371754),('CO',235376554),('CO',235376884),('CO',235377874), +('CO',231060394),('CO',231059224),('CO',231059314),('CO',231060484), +('CO',231060274),('CO',231060124),('CO',231060244),('CO',231058594), +('CO',231058924),('CO',231058504),('CO',231059344),('CO',231060424), +('CO',231059554),('CO',231060304),('CO',231059644),('CO',231059464), +('CO',231059764),('CO',231058294),('CO',231058624),('CO',231058864), +('CO',231059374),('CO',231059584),('CO',231059734),('CO',231059014), +('CO',231059854),('CO',231059494),('CO',231059794),('CO',231058534), +('CO',231058324),('CO',231058684),('CO',231059524),('CO',231059974); +CREATE TABLE t2 ( +scan_date date default NULL, +package_id int default NULL, +INDEX scan_date(scan_date), +INDEX package_id(package_id) +); +INSERT INTO t2 VALUES +('2008-12-29',231062944),('2008-12-29',231065764),('2008-12-29',231066124), +('2008-12-29',231060094),('2008-12-29',231061054),('2008-12-29',231065644), +('2008-12-29',231064384),('2008-12-29',231064444),('2008-12-29',231073774), +('2008-12-29',231058594),('2008-12-29',231059374),('2008-12-29',231066004), +('2008-12-29',231068494),('2008-12-29',231070174),('2008-12-29',231071884), +('2008-12-29',231063274),('2008-12-29',231063754),('2008-12-29',231064144), +('2008-12-29',231069424),('2008-12-29',231073714),('2008-12-29',231058414), +('2008-12-29',231060994),('2008-12-29',231069154),('2008-12-29',231068614), +('2008-12-29',231071464),('2008-12-29',231074014),('2008-12-29',231059614), +('2008-12-29',231059074),('2008-12-29',231059464),('2008-12-29',231069094), +('2008-12-29',231067294),('2008-12-29',231070144),('2008-12-29',231073804), +('2008-12-29',231072634),('2008-12-29',231058294),('2008-12-29',231065344), +('2008-12-29',231066094),('2008-12-29',231069034),('2008-12-29',231058594), +('2008-12-29',231059854),('2008-12-29',231059884),('2008-12-29',231059914), +('2008-12-29',231063664),('2008-12-29',231063814),('2008-12-29',231063904); +CREATE TABLE t3 ( +package_id int default NULL, +INDEX package_id(package_id) +); +INSERT INTO t3 VALUES +(231058294),(231058324),(231058354),(231058384),(231058414),(231058444), +(231058474),(231058504),(231058534),(231058564),(231058594),(231058624), +(231058684),(231058744),(231058804),(231058864),(231058924),(231058954), +(231059014),(231059074),(231059104),(231059134),(231059164),(231059194), +(231059224),(231059254),(231059284),(231059314),(231059344),(231059374), +(231059404),(231059434),(231059464),(231059494),(231059524),(231059554), +(231059584),(231059614),(231059644),(231059674),(231059704),(231059734), +(231059764),(231059794),(231059824),(231059854),(231059884),(231059914), +(231059944),(231059974),(231060004),(231060034),(231060064),(231060094), +(231060124),(231060154),(231060184),(231060214),(231060244),(231060274), +(231060304),(231060334),(231060364),(231060394),(231060424),(231060454), +(231060484),(231060514),(231060544),(231060574),(231060604),(231060634), +(231060664),(231060694),(231060724),(231060754),(231060784),(231060814), +(231060844),(231060874),(231060904),(231060934),(231060964),(231060994), +(231061024),(231061054),(231061084),(231061144),(231061174),(231061204), +(231061234),(231061294),(231061354),(231061384),(231061414),(231061474), +(231061564),(231061594),(231061624),(231061684),(231061714),(231061774), +(231061804),(231061894),(231061984),(231062074),(231062134),(231062224), +(231062254),(231062314),(231062374),(231062434),(231062494),(231062554), +(231062584),(231062614),(231062644),(231062704),(231062734),(231062794), +(231062854),(231062884),(231062944),(231063004),(231063034),(231063064), +(231063124),(231063154),(231063184),(231063214),(231063274),(231063334), +(231063394),(231063424),(231063454),(231063514),(231063574),(231063664); +CREATE TABLE t4 ( +carrier char(2) NOT NULL default '' PRIMARY KEY, +id int(11) default NULL, +INDEX id(id) +) CHARSET utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t4 VALUES +('99',6),('SK',456),('UA',486),('AI',1081),('OS',1111),('VS',1510); +CREATE TABLE t5 ( +carrier_id int default NULL, +INDEX carrier_id(carrier_id) +); +INSERT INTO t5 VALUES +(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6), +(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6), +(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6), +(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6), +(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6), +(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(456),(456),(456), +(456),(456),(456),(456),(456),(456),(456),(456),(456),(456),(456),(456), +(456),(486),(1081),(1111),(1111),(1111),(1111),(1510); +ANALYZE TABLE t1, t2, t3, t4, t5; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +test.t4 analyze status OK +test.t5 analyze status OK +SELECT COUNT(*) +FROM((t2 JOIN t1 ON t2.package_id = t1.id) +JOIN t3 ON t3.package_id = t1.id); +COUNT(*) +6 +EXPLAIN +SELECT COUNT(*) +FROM ((t2 JOIN t1 ON t2.package_id = t1.id) +JOIN t3 ON t3.package_id = t1.id) +LEFT JOIN +(t5 JOIN t4 ON t5.carrier_id = t4.id) +ON t4.carrier = t1.carrier; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 45 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL index package_id package_id 5 NULL 45 100.00 Using where; Using index +2 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.package_id 1 100.00 NULL +2 SIMPLE t4 NULL eq_ref PRIMARY,id PRIMARY 8 test.t1.carrier 1 100.00 NULL +2 SIMPLE t5 NULL ref carrier_id carrier_id 5 test.t4.id 22 100.00 Using index +2 SIMPLE t3 NULL ref package_id package_id 5 test.t2.package_id 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t2` join `test`.`t1` join `test`.`t3` left join (`test`.`t5` join `test`.`t4`) on(((`test`.`t5`.`carrier_id` = `test`.`t4`.`id`) and (`test`.`t4`.`carrier` = `test`.`t1`.`carrier`))) where ((`test`.`t1`.`id` = `test`.`t2`.`package_id`) and (`test`.`t3`.`package_id` = `test`.`t2`.`package_id`)) +SELECT COUNT(*) +FROM ((t2 JOIN t1 ON t2.package_id = t1.id) +JOIN t3 ON t3.package_id = t1.id) +LEFT JOIN +(t5 JOIN t4 ON t5.carrier_id = t4.id) +ON t4.carrier = t1.carrier; +COUNT(*) +6 +DROP TABLE t1,t2,t3,t4,t5; +End of 5.0 tests +# +# Bug#24909223: EXCESSIVE MEMORY USAGE BY QUERY +# +CREATE TABLE t ( +a INT, +b CHAR(255), +c CHAR(255), +d INT, +e INT, +PRIMARY KEY (e), +KEY (d) +) ENGINE=InnoDB; +INSERT INTO t VALUES +(1, '14effca2', 'cffa3819', 98927, 8767), +(1, '2f7cbd33', '421aff88', 87613, 70956), +(1, '5c44507d', '05fd27d3', 36002, 5146), +(1, '6542ee43', 'c09ee30f', 3673, 91467), +(1, '786737dd', '6ac95ccb', 46890, 62953), +(1, '8929d195', '64102e63', 50531, 9712), +(1, '8cc0c106', '17283316', 16399, 26119), +(1, '8f3063de', 'ce5d0f35', 21769, 76667), +(1, 'c32c9202', 'c9525fe8', 12704, 43998), +(1, 'c5567e1c', 'bc2e97e6', 85805, 84174), +(1, 'c7acb4d4', '6d67fea7', 58347, 51235), +(1, 'dbd66341', '03b59a03', 46577, 52495), +(1, 'f8e0354e', '41a6e523', 36055, 32646), +(1, 'fb66b513', '10f3de43', 41297, 74334), +(1, 'ffec6d1b', '2fca4073', 12896, 95807), +(1, 'aa3fcff8', 'f4981ed8', 99211, 18778); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +EXPLAIN SELECT a.c AS c FROM ( +SELECT a.c AS c FROM ( +SELECT a.a AS c FROM t AS a +INNER JOIN t AS b ON a.b > b.b +) AS a +INNER JOIN t AS b ON a.c >= b.a +) AS a +INNER JOIN t AS b ON a.c >= b.d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 16 100.00 Parallel execute (1 workers) +2 SIMPLE a NULL ALL NULL NULL NULL NULL 16 100.00 NULL +2 SIMPLE b NULL ALL NULL NULL NULL NULL 16 33.33 Using where +2 SIMPLE b NULL ALL NULL NULL NULL NULL 16 33.33 Using where +2 SIMPLE b NULL ALL d NULL NULL NULL 16 33.33 Range checked for each record (index map: 0x2) +Warnings: +Note 1003 /* select#1 */ select `test`.`a`.`a` AS `c` from `test`.`t` `a` join `test`.`t` `b` join `test`.`t` `b` join `test`.`t` `b` where ((`test`.`a`.`a` >= `test`.`b`.`d`) and (`test`.`a`.`a` >= `test`.`b`.`a`) and (`test`.`a`.`b` > `test`.`b`.`b`)) +TRUNCATE TABLE performance_schema.memory_summary_by_thread_by_event_name; +SELECT a.c AS c FROM ( +SELECT a.c AS c FROM ( +SELECT a.a AS c FROM t AS a +INNER JOIN t AS b ON a.b > b.b +) AS a +INNER JOIN t AS b ON a.c >= b.a +) AS a +INNER JOIN t AS b ON a.c >= b.d; +c +SELECT * FROM performance_schema.memory_summary_by_thread_by_event_name +WHERE event_name = 'memory/sql/thd::main_mem_root' +AND thread_id = ps_thread_id(connection_id()) +AND sum_number_of_bytes_alloc > 1000000 +DROP TABLE t; +CREATE TABLE t5 (a int, b int, c int, PRIMARY KEY(a), KEY b_i (b)); +CREATE TABLE t6 (a int, b int, c int, PRIMARY KEY(a), KEY b_i (b)); +CREATE TABLE t7 (a int, b int, c int, PRIMARY KEY(a), KEY b_i (b)); +CREATE TABLE t8 (a int, b int, c int, PRIMARY KEY(a), KEY b_i (b)); +INSERT INTO t5 VALUES (1,1,0), (2,2,0), (3,3,0); +INSERT INTO t6 VALUES (1,2,0), (3,2,0), (6,1,0); +INSERT INTO t7 VALUES (1,1,0), (2,2,0); +INSERT INTO t8 VALUES (0,2,0), (1,2,0); +ANALYZE TABLE t5, t6, t7, t8; +Table Op Msg_type Msg_text +test.t5 analyze status OK +test.t6 analyze status OK +test.t7 analyze status OK +test.t8 analyze status OK +EXPLAIN +SELECT t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b +FROM t5 +LEFT JOIN +( +(t6, t7) +LEFT JOIN +t8 +ON t7.b=t8.b AND t6.b < 10 +) +ON t6.b >= 2 AND t5.b=t7.b AND +(t8.a > 0 OR t8.c IS NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t5 NULL index NULL b_i 5 NULL 3 100.00 Using index +2 SIMPLE t7 NULL ref b_i b_i 5 test.t5.b 1 100.00 Using index +2 SIMPLE t6 NULL index b_i b_i 5 NULL 3 100.00 Using where; Using index +2 SIMPLE t8 NULL ALL b_i NULL NULL NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t5`.`a` AS `a`,`test`.`t5`.`b` AS `b`,`test`.`t6`.`a` AS `a`,`test`.`t6`.`b` AS `b`,`test`.`t7`.`a` AS `a`,`test`.`t7`.`b` AS `b`,`test`.`t8`.`a` AS `a`,`test`.`t8`.`b` AS `b` from `test`.`t5` left join (`test`.`t6` join `test`.`t7` left join `test`.`t8` on(((`test`.`t8`.`b` = `test`.`t5`.`b`) and (`test`.`t6`.`b` < 10)))) on(((`test`.`t7`.`b` = `test`.`t5`.`b`) and (`test`.`t6`.`b` >= 2) and ((`test`.`t8`.`a` > 0) or (`test`.`t8`.`c` is null)))) where true +SELECT t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b +FROM t5 +LEFT JOIN +( +(t6, t7) +LEFT JOIN +t8 +ON t7.b=t8.b AND t6.b < 10 +) +ON t6.b >= 2 AND t5.b=t7.b AND +(t8.a > 0 OR t8.c IS NULL); +a b a b a b a b +1 1 1 2 1 1 NULL NULL +1 1 3 2 1 1 NULL NULL +2 2 1 2 2 2 1 2 +2 2 3 2 2 2 1 2 +3 3 NULL NULL NULL NULL NULL NULL +DELETE FROM t5; +DELETE FROM t6; +DELETE FROM t7; +DELETE FROM t8; +INSERT INTO t5 VALUES (1,3,0), (3,2,0); +INSERT INTO t6 VALUES (3,3,0); +INSERT INTO t7 VALUES (1,2,0); +INSERT INTO t8 VALUES (1,1,0); +ANALYZE TABLE t5, t6, t7, t8; +Table Op Msg_type Msg_text +test.t5 analyze status OK +test.t6 analyze status OK +test.t7 analyze status OK +test.t8 analyze status OK +EXPLAIN +SELECT t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b +FROM t5 LEFT JOIN +(t6 LEFT JOIN t7 ON t7.a=1, t8) +ON (t5.b=t8.b); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t5 NULL index NULL b_i 5 NULL 2 100.00 Using index +2 SIMPLE t6 NULL index NULL b_i 5 NULL 1 100.00 Using index +2 SIMPLE t7 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +2 SIMPLE t8 NULL ref b_i b_i 5 test.t5.b 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t5`.`a` AS `a`,`test`.`t5`.`b` AS `b`,`test`.`t6`.`a` AS `a`,`test`.`t6`.`b` AS `b`,`test`.`t7`.`a` AS `a`,`test`.`t7`.`b` AS `b`,`test`.`t8`.`a` AS `a`,`test`.`t8`.`b` AS `b` from `test`.`t5` left join (`test`.`t6` left join `test`.`t7` on((`test`.`t7`.`a` = 1)) join `test`.`t8`) on((`test`.`t8`.`b` = `test`.`t5`.`b`)) where true +SELECT t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b +FROM t5 LEFT JOIN +(t6 LEFT JOIN t7 ON t7.a=1, t8) +ON (t5.b=t8.b); +a b a b a b a b +1 3 NULL NULL NULL NULL NULL NULL +3 2 NULL NULL NULL NULL NULL NULL +EXPLAIN +SELECT t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b +FROM t5 LEFT JOIN +(t6 LEFT JOIN t7 ON t7.b=2, t8) +ON (t5.b=t8.b); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t5 NULL index NULL b_i 5 NULL 2 100.00 Using index +2 SIMPLE t6 NULL index NULL b_i 5 NULL 1 100.00 Using index +2 SIMPLE t7 NULL ref b_i b_i 5 const 1 100.00 Using index +2 SIMPLE t8 NULL ref b_i b_i 5 test.t5.b 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t5`.`a` AS `a`,`test`.`t5`.`b` AS `b`,`test`.`t6`.`a` AS `a`,`test`.`t6`.`b` AS `b`,`test`.`t7`.`a` AS `a`,`test`.`t7`.`b` AS `b`,`test`.`t8`.`a` AS `a`,`test`.`t8`.`b` AS `b` from `test`.`t5` left join (`test`.`t6` left join `test`.`t7` on((`test`.`t7`.`b` = 2)) join `test`.`t8`) on((`test`.`t8`.`b` = `test`.`t5`.`b`)) where true +SELECT t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b +FROM t5 LEFT JOIN +(t6 LEFT JOIN t7 ON t7.b=2, t8) +ON (t5.b=t8.b); +a b a b a b a b +1 3 NULL NULL NULL NULL NULL NULL +3 2 NULL NULL NULL NULL NULL NULL +EXPLAIN +SELECT t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b +FROM t5 LEFT JOIN +(t8, t6 LEFT JOIN t7 ON t7.a=1) +ON (t5.b=t8.b); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t5 NULL index NULL b_i 5 NULL 2 100.00 Using index +2 SIMPLE t8 NULL ref b_i b_i 5 test.t5.b 1 100.00 Using index +2 SIMPLE t6 NULL index NULL b_i 5 NULL 1 100.00 Using index +2 SIMPLE t7 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t5`.`a` AS `a`,`test`.`t5`.`b` AS `b`,`test`.`t6`.`a` AS `a`,`test`.`t6`.`b` AS `b`,`test`.`t7`.`a` AS `a`,`test`.`t7`.`b` AS `b`,`test`.`t8`.`a` AS `a`,`test`.`t8`.`b` AS `b` from `test`.`t5` left join (`test`.`t8` join `test`.`t6` left join `test`.`t7` on((`test`.`t7`.`a` = 1))) on((`test`.`t8`.`b` = `test`.`t5`.`b`)) where true +SELECT t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b +FROM t5 LEFT JOIN +(t8, t6 LEFT JOIN t7 ON t7.a=1) +ON (t5.b=t8.b); +a b a b a b a b +1 3 NULL NULL NULL NULL NULL NULL +3 2 NULL NULL NULL NULL NULL NULL +DROP TABLE t5,t6,t7,t8; +set optimizer_switch=default; diff --git a/mysql-test/r/join_outer.result-pq b/mysql-test/r/join_outer.result-pq new file mode 100644 index 000000000000..217f7b6e7238 --- /dev/null +++ b/mysql-test/r/join_outer.result-pq @@ -0,0 +1,3835 @@ +drop table if exists t0,t1,t2,t3,t4,t5; +CREATE TABLE t1 ( +grp int(11) default NULL, +a bigint(20) unsigned default NULL, +c char(10) NOT NULL default '' +) ENGINE=MyISAM; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (1,1,'a'),(2,2,'b'),(2,3,'c'),(3,4,'E'),(3,5,'C'),(3,6,'D'),(NULL,NULL,''); +create table t2 (id int, a bigint unsigned not null, c char(10), d int, primary key (a)); +insert into t2 values (1,1,"a",1),(3,4,"A",4),(3,5,"B",5),(3,6,"C",6),(4,7,"D",7); +select t1.*,t2.* from t1 JOIN t2 where t1.a=t2.a; +grp a c id a c d +1 1 a 1 1 a 1 +3 4 E 3 4 A 4 +3 5 C 3 5 B 5 +3 6 D 3 6 C 6 +EXPLAIN FORMAT=tree select t1.*,t2.* from t1 left join t2 on (t1.a=t2.a) order by t1.grp,t1.a,t2.c; +EXPLAIN +-> Sort: t1.grp, t1.a, t2.c + -> Stream results (cost=3.67 rows=7) + -> Nested loop left join (cost=3.67 rows=7) + -> Table scan on t1 (cost=1.22 rows=7) + -> Single-row index lookup on t2 using PRIMARY (a=t1.a) (cost=0.26 rows=1) + +select t1.*,t2.* from t1 left join t2 on (t1.a=t2.a) order by t1.grp,t1.a,t2.c; +grp a c id a c d +NULL NULL NULL NULL NULL NULL +1 1 a 1 1 a 1 +2 2 b NULL NULL NULL NULL +2 3 c NULL NULL NULL NULL +3 4 E 3 4 A 4 +3 5 C 3 5 B 5 +3 6 D 3 6 C 6 +select t1.*,t2.* from { oj t2 left outer join t1 on (t1.a=t2.a) }; +grp a c id a c d +1 1 a 1 1 a 1 +3 4 E 3 4 A 4 +3 5 C 3 5 B 5 +3 6 D 3 6 C 6 +NULL NULL NULL 4 7 D 7 +select t1.*,t2.* from t1 as t0,{ oj t2 left outer join t1 on (t1.a=t2.a) } WHERE t0.a=2; +grp a c id a c d +1 1 a 1 1 a 1 +3 4 E 3 4 A 4 +3 5 C 3 5 B 5 +3 6 D 3 6 C 6 +NULL NULL NULL 4 7 D 7 +select t1.*,t2.* from t1 left join t2 using (a); +grp a c id a c d +1 1 a 1 1 a 1 +2 2 b NULL NULL NULL NULL +2 3 c NULL NULL NULL NULL +3 4 E 3 4 A 4 +3 5 C 3 5 B 5 +3 6 D 3 6 C 6 +NULL NULL NULL NULL NULL NULL +select t1.*,t2.* from t1 left join t2 using (a) where t1.a=t2.a; +grp a c id a c d +1 1 a 1 1 a 1 +3 4 E 3 4 A 4 +3 5 C 3 5 B 5 +3 6 D 3 6 C 6 +select t1.*,t2.* from t1 left join t2 using (a,c); +grp a c id a c d +1 1 a 1 1 a 1 +2 2 b NULL NULL NULL NULL +2 3 c NULL NULL NULL NULL +3 4 E NULL NULL NULL NULL +3 5 C NULL NULL NULL NULL +3 6 D NULL NULL NULL NULL +NULL NULL NULL NULL NULL NULL +select t1.*,t2.* from t1 left join t2 using (c); +grp a c id a c d +1 1 a 1 1 a 1 +1 1 a 3 4 A 4 +2 2 b 3 5 B 5 +2 3 c 3 6 C 6 +3 4 E NULL NULL NULL NULL +3 5 C 3 6 C 6 +3 6 D 4 7 D 7 +NULL NULL NULL NULL NULL NULL +select t1.*,t2.* from t1 natural left outer join t2; +grp a c id a c d +1 1 a 1 1 a 1 +2 2 b NULL NULL NULL NULL +2 3 c NULL NULL NULL NULL +3 4 E NULL NULL NULL NULL +3 5 C NULL NULL NULL NULL +3 6 D NULL NULL NULL NULL +NULL NULL NULL NULL NULL NULL +select t1.*,t2.* from t1 left join t2 on (t1.a=t2.a) where t2.id=3; +grp a c id a c d +3 4 E 3 4 A 4 +3 5 C 3 5 B 5 +3 6 D 3 6 C 6 +select t1.*,t2.* from t1 left join t2 on (t1.a=t2.a) where t2.id is null; +grp a c id a c d +2 2 b NULL NULL NULL NULL +2 3 c NULL NULL NULL NULL +NULL NULL NULL NULL NULL NULL +explain select t1.*,t2.* from t1,t2 where t1.a=t2.a and isnull(t2.a)=1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`grp` AS `grp`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`c` AS `c`,`test`.`t2`.`id` AS `id`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`c` AS `c`,`test`.`t2`.`d` AS `d` from `test`.`t1` join `test`.`t2` where false +explain select t1.*,t2.* from t1 left join t2 on t1.a=t2.a where isnull(t2.a)=1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 7 100.00 NULL +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 8 test.t1.a 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`grp` AS `grp`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`c` AS `c`,`test`.`t2`.`id` AS `id`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`c` AS `c`,`test`.`t2`.`d` AS `d` from `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`a` = `test`.`t1`.`a`)) where ((`test`.`t2`.`a` is null) = 1) +select t1.*,t2.*,t3.a from t1 left join t2 on (t1.a=t2.a) left join t1 as t3 on (t2.a=t3.a); +grp a c id a c d a +1 1 a 1 1 a 1 1 +2 2 b NULL NULL NULL NULL NULL +2 3 c NULL NULL NULL NULL NULL +3 4 E 3 4 A 4 4 +3 5 C 3 5 B 5 5 +3 6 D 3 6 C 6 6 +NULL NULL NULL NULL NULL NULL NULL +explain select t1.*,t2.*,t3.a from t1 left join t2 on (t3.a=t2.a) left join t1 as t3 on (t1.a=t3.a); +ERROR 42S22: Unknown column 't3.a' in 'on clause' +select t1.*,t2.*,t3.a from t1 left join t2 on (t3.a=t2.a) left join t1 as t3 on (t1.a=t3.a); +ERROR 42S22: Unknown column 't3.a' in 'on clause' +select t1.*,t2.*,t3.a from t1 left join t2 on (t3.a=t2.a) left join t1 as t3 on (t2.a=t3.a); +ERROR 42S22: Unknown column 't3.a' in 'on clause' +select t1.*,t2.* from t1 inner join t2 using (a); +grp a c id a c d +1 1 a 1 1 a 1 +3 4 E 3 4 A 4 +3 5 C 3 5 B 5 +3 6 D 3 6 C 6 +select t1.*,t2.* from t1 inner join t2 on (t1.a=t2.a); +grp a c id a c d +1 1 a 1 1 a 1 +3 4 E 3 4 A 4 +3 5 C 3 5 B 5 +3 6 D 3 6 C 6 +select t1.*,t2.* from t1 natural join t2; +grp a c id a c d +1 1 a 1 1 a 1 +drop table t1,t2; +CREATE TABLE t1 ( +usr_id INT unsigned NOT NULL, +uniq_id INT unsigned NOT NULL AUTO_INCREMENT, +start_num INT unsigned NOT NULL DEFAULT 1, +increment INT unsigned NOT NULL DEFAULT 1, +PRIMARY KEY (uniq_id), +INDEX usr_uniq_idx (usr_id, uniq_id), +INDEX uniq_usr_idx (uniq_id, usr_id) +); +CREATE TABLE t2 ( +id INT unsigned NOT NULL DEFAULT 0, +usr2_id INT unsigned NOT NULL DEFAULT 0, +max INT unsigned NOT NULL DEFAULT 0, +c_amount INT unsigned NOT NULL DEFAULT 0, +d_max INT unsigned NOT NULL DEFAULT 0, +d_num INT unsigned NOT NULL DEFAULT 0, +orig_time INT unsigned NOT NULL DEFAULT 0, +c_time INT unsigned NOT NULL DEFAULT 0, +active ENUM ("no","yes") NOT NULL, +PRIMARY KEY (id,usr2_id), +INDEX id_idx (id), +INDEX usr2_idx (usr2_id) +); +INSERT INTO t1 VALUES (3,NULL,0,50),(3,NULL,0,200),(3,NULL,0,25),(3,NULL,0,84676),(3,NULL,0,235),(3,NULL,0,10),(3,NULL,0,3098),(3,NULL,0,2947),(3,NULL,0,8987),(3,NULL,0,8347654),(3,NULL,0,20398),(3,NULL,0,8976),(3,NULL,0,500),(3,NULL,0,198); +SELECT t1.usr_id,t1.uniq_id,t1.increment, +t2.usr2_id,t2.c_amount,t2.max +FROM t1 +LEFT JOIN t2 ON t2.id = t1.uniq_id +WHERE t1.uniq_id = 4 +ORDER BY t2.c_amount; +usr_id uniq_id increment usr2_id c_amount max +3 4 84676 NULL NULL NULL +SELECT t1.usr_id,t1.uniq_id,t1.increment, +t2.usr2_id,t2.c_amount,t2.max +FROM t2 +RIGHT JOIN t1 ON t2.id = t1.uniq_id +WHERE t1.uniq_id = 4 +ORDER BY t2.c_amount; +usr_id uniq_id increment usr2_id c_amount max +3 4 84676 NULL NULL NULL +INSERT INTO t2 VALUES (2,3,3000,6000,0,0,746584,837484,'yes'); +INSERT INTO t2 VALUES (2,3,3000,6000,0,0,746584,837484,'yes'); +ERROR 23000: Duplicate entry '2-3' for key 't2.PRIMARY' +INSERT INTO t2 VALUES (7,3,1000,2000,0,0,746294,937484,'yes'); +SELECT t1.usr_id,t1.uniq_id,t1.increment,t2.usr2_id,t2.c_amount,t2.max FROM t1 LEFT JOIN t2 ON t2.id = t1.uniq_id WHERE t1.uniq_id = 4 ORDER BY t2.c_amount; +usr_id uniq_id increment usr2_id c_amount max +3 4 84676 NULL NULL NULL +SELECT t1.usr_id,t1.uniq_id,t1.increment,t2.usr2_id,t2.c_amount,t2.max FROM t1 LEFT JOIN t2 ON t2.id = t1.uniq_id WHERE t1.uniq_id = 4 GROUP BY t2.c_amount; +usr_id uniq_id increment usr2_id c_amount max +3 4 84676 NULL NULL NULL +SELECT t1.usr_id,t1.uniq_id,t1.increment,t2.usr2_id,t2.c_amount,t2.max FROM t1 LEFT JOIN t2 ON t2.id = t1.uniq_id WHERE t1.uniq_id = 4; +usr_id uniq_id increment usr2_id c_amount max +3 4 84676 NULL NULL NULL +drop table t1,t2; +CREATE TABLE t1 ( +cod_asig int(11) DEFAULT '0' NOT NULL, +desc_larga_cat varchar(80) DEFAULT '' NOT NULL, +desc_larga_cas varchar(80) DEFAULT '' NOT NULL, +desc_corta_cat varchar(40) DEFAULT '' NOT NULL, +desc_corta_cas varchar(40) DEFAULT '' NOT NULL, +cred_total double(3,1) DEFAULT '0.0' NOT NULL, +pre_requisit int(11), +co_requisit int(11), +preco_requisit int(11), +PRIMARY KEY (cod_asig) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (10360,'asdfggfg','Introduccion a los Ordenadores I','asdfggfg','Introduccio Ordinadors I',6.0,NULL,NULL,NULL); +INSERT INTO t1 VALUES (10361,'Components i Circuits Electronics I','Componentes y Circuitos Electronicos I','Components i Circuits Electronics I','Comp. i Circ. Electr. I',6.0,NULL,NULL,NULL); +INSERT INTO t1 VALUES (10362,'Laboratori d`Ordinadors','Laboratorio de Ordenadores','Laboratori d`Ordinadors','Laboratori Ordinadors',4.5,NULL,NULL,NULL); +INSERT INTO t1 VALUES (10363,'Tecniques de Comunicacio Oral i Escrita','Tecnicas de Comunicacion Oral y Escrita','Tecniques de Comunicacio Oral i Escrita','Tec. Com. Oral i Escrita',4.5,NULL,NULL,NULL); +INSERT INTO t1 VALUES (11403,'Projecte Fi de Carrera','Proyecto Fin de Carrera','Projecte Fi de Carrera','PFC',9.0,NULL,NULL,NULL); +INSERT INTO t1 VALUES (11404,'+lgebra lineal','Algebra lineal','+lgebra lineal','+lgebra lineal',15.0,NULL,NULL,NULL); +INSERT INTO t1 VALUES (11405,'+lgebra lineal','Algebra lineal','+lgebra lineal','+lgebra lineal',18.0,NULL,NULL,NULL); +INSERT INTO t1 VALUES (11406,'Calcul Infinitesimal','Cßlculo Infinitesimal','Calcul Infinitesimal','Calcul Infinitesimal',15.0,NULL,NULL,NULL); +CREATE TABLE t2 ( +idAssignatura int(11) DEFAULT '0' NOT NULL, +Grup int(11) DEFAULT '0' NOT NULL, +Places smallint(6) DEFAULT '0' NOT NULL, +PlacesOcupades int(11) DEFAULT '0', +PRIMARY KEY (idAssignatura,Grup) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (10360,12,333,0); +INSERT INTO t2 VALUES (10361,30,2,0); +INSERT INTO t2 VALUES (10361,40,3,0); +INSERT INTO t2 VALUES (10360,45,10,0); +INSERT INTO t2 VALUES (10362,10,12,0); +INSERT INTO t2 VALUES (10360,55,2,0); +INSERT INTO t2 VALUES (10360,70,0,0); +INSERT INTO t2 VALUES (10360,565656,0,0); +INSERT INTO t2 VALUES (10360,32767,7,0); +INSERT INTO t2 VALUES (10360,33,8,0); +INSERT INTO t2 VALUES (10360,7887,85,0); +INSERT INTO t2 VALUES (11405,88,8,0); +INSERT INTO t2 VALUES (10360,0,55,0); +INSERT INTO t2 VALUES (10360,99,0,0); +INSERT INTO t2 VALUES (11411,30,10,0); +INSERT INTO t2 VALUES (11404,0,0,0); +INSERT INTO t2 VALUES (10362,11,111,0); +INSERT INTO t2 VALUES (10363,33,333,0); +INSERT INTO t2 VALUES (11412,55,0,0); +INSERT INTO t2 VALUES (50003,66,6,0); +INSERT INTO t2 VALUES (11403,5,0,0); +INSERT INTO t2 VALUES (11406,11,11,0); +INSERT INTO t2 VALUES (11410,11410,131,0); +INSERT INTO t2 VALUES (11416,11416,32767,0); +INSERT INTO t2 VALUES (11409,0,0,0); +CREATE TABLE t3 ( +id int(11) NOT NULL auto_increment, +dni_pasaporte char(16) DEFAULT '' NOT NULL, +idPla int(11) DEFAULT '0' NOT NULL, +cod_asig int(11) DEFAULT '0' NOT NULL, +any smallint(6) DEFAULT '0' NOT NULL, +quatrimestre smallint(6) DEFAULT '0' NOT NULL, +estat char(1) DEFAULT 'M' NOT NULL, +PRIMARY KEY (id), +UNIQUE dni_pasaporte (dni_pasaporte,idPla), +UNIQUE dni_pasaporte_2 (dni_pasaporte,idPla,cod_asig,any,quatrimestre) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t3 VALUES (1,'11111111',1,10362,98,1,'M'); +CREATE TABLE t4 ( +id int(11) NOT NULL auto_increment, +papa int(11) DEFAULT '0' NOT NULL, +fill int(11) DEFAULT '0' NOT NULL, +idPla int(11) DEFAULT '0' NOT NULL, +PRIMARY KEY (id), +KEY papa (idPla,papa), +UNIQUE papa_2 (idPla,papa,fill) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t4 VALUES (1,-1,10360,1); +INSERT INTO t4 VALUES (2,-1,10361,1); +INSERT INTO t4 VALUES (3,-1,10362,1); +SELECT DISTINCT fill,desc_larga_cat,cred_total,Grup,Places,PlacesOcupades FROM t4 LEFT JOIN t3 ON t3.cod_asig=fill AND estat='S' AND dni_pasaporte='11111111' AND t3.idPla=1 , t2,t1 WHERE fill=t1.cod_asig AND Places>PlacesOcupades AND fill=idAssignatura AND t4.idPla=1 AND papa=-1; +fill desc_larga_cat cred_total Grup Places PlacesOcupades +10360 asdfggfg 6.0 0 55 0 +10360 asdfggfg 6.0 12 333 0 +10360 asdfggfg 6.0 33 8 0 +10360 asdfggfg 6.0 45 10 0 +10360 asdfggfg 6.0 55 2 0 +10360 asdfggfg 6.0 7887 85 0 +10360 asdfggfg 6.0 32767 7 0 +10361 Components i Circuits Electronics I 6.0 30 2 0 +10361 Components i Circuits Electronics I 6.0 40 3 0 +10362 Laboratori d`Ordinadors 4.5 10 12 0 +10362 Laboratori d`Ordinadors 4.5 11 111 0 +SELECT DISTINCT fill,t3.idPla FROM t4 LEFT JOIN t3 ON t3.cod_asig=t4.fill AND t3.estat='S' AND t3.dni_pasaporte='1234' AND t3.idPla=1 ; +fill idPla +10360 NULL +10361 NULL +10362 NULL +INSERT INTO t3 VALUES (3,'1234',1,10360,98,1,'S'); +SELECT DISTINCT fill,t3.idPla FROM t4 LEFT JOIN t3 ON t3.cod_asig=t4.fill AND t3.estat='S' AND t3.dni_pasaporte='1234' AND t3.idPla=1 ; +fill idPla +10360 1 +10361 NULL +10362 NULL +drop table t1,t2,t3,test.t4; +CREATE TABLE t1 ( +id smallint(5) unsigned NOT NULL auto_increment, +name char(60) DEFAULT '' NOT NULL, +PRIMARY KEY (id) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (1,'Antonio Paz'); +INSERT INTO t1 VALUES (2,'Lilliana Angelovska'); +INSERT INTO t1 VALUES (3,'Thimble Smith'); +CREATE TABLE t2 ( +id smallint(5) unsigned NOT NULL auto_increment, +owner smallint(5) unsigned DEFAULT '0' NOT NULL, +name char(60), +PRIMARY KEY (id) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (1,1,'El Gato'); +INSERT INTO t2 VALUES (2,1,'Perrito'); +INSERT INTO t2 VALUES (3,3,'Happy'); +select t1.name, t2.name, t2.id from t1 left join t2 on (t1.id = t2.owner); +name name id +Antonio Paz El Gato 1 +Antonio Paz Perrito 2 +Lilliana Angelovska NULL NULL +Thimble Smith Happy 3 +select t1.name, t2.name, t2.id from t1 left join t2 on (t1.id = t2.owner) where t2.id is null; +name name id +Lilliana Angelovska NULL NULL +explain select t1.name, t2.name, t2.id from t1 left join t2 on (t1.id = t2.owner) where t2.id is null; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Not exists; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`name` AS `name`,`test`.`t2`.`name` AS `name`,`test`.`t2`.`id` AS `id` from `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`owner` = `test`.`t1`.`id`)) where (`test`.`t2`.`id` is null) +explain select t1.name, t2.name, t2.id from t1 left join t2 on (t1.id = t2.owner) where t2.name is null; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`name` AS `name`,`test`.`t2`.`name` AS `name`,`test`.`t2`.`id` AS `id` from `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`owner` = `test`.`t1`.`id`)) where (`test`.`t2`.`name` is null) +select count(*) from t1 left join t2 on (t1.id = t2.owner); +count(*) +4 +select t1.name, t2.name, t2.id from t2 right join t1 on (t1.id = t2.owner); +name name id +Antonio Paz El Gato 1 +Antonio Paz Perrito 2 +Lilliana Angelovska NULL NULL +Thimble Smith Happy 3 +select t1.name, t2.name, t2.id from t2 right join t1 on (t1.id = t2.owner) where t2.id is null; +name name id +Lilliana Angelovska NULL NULL +explain select t1.name, t2.name, t2.id from t2 right join t1 on (t1.id = t2.owner) where t2.id is null; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Not exists; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`name` AS `name`,`test`.`t2`.`name` AS `name`,`test`.`t2`.`id` AS `id` from `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`owner` = `test`.`t1`.`id`)) where (`test`.`t2`.`id` is null) +explain select t1.name, t2.name, t2.id from t2 right join t1 on (t1.id = t2.owner) where t2.name is null; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`name` AS `name`,`test`.`t2`.`name` AS `name`,`test`.`t2`.`id` AS `id` from `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`owner` = `test`.`t1`.`id`)) where (`test`.`t2`.`name` is null) +select count(*) from t2 right join t1 on (t1.id = t2.owner); +count(*) +4 +select t1.name, t2.name, t2.id,t3.id from t2 right join t1 on (t1.id = t2.owner) left join t1 as t3 on t3.id=t2.owner; +name name id id +Antonio Paz El Gato 1 1 +Antonio Paz Perrito 2 1 +Lilliana Angelovska NULL NULL NULL +Thimble Smith Happy 3 3 +select t1.name, t2.name, t2.id,t3.id from t1 right join t2 on (t1.id = t2.owner) right join t1 as t3 on t3.id=t2.owner; +name name id id +Antonio Paz El Gato 1 1 +Antonio Paz Perrito 2 1 +NULL NULL NULL 2 +Thimble Smith Happy 3 3 +explain format=tree select t1.name, t2.name, t2.id, t2.owner, t3.id from t1 left join t2 on (t1.id = t2.owner) right join t1 as t3 on t3.id=t2.owner; +EXPLAIN +-> Parallel scan on + -> Nested loop left join (cost=2.20 rows=9) + -> PQblock scan on t3 using PRIMARY (cost=0.55 rows=3) + -> Nested loop inner join (cost=0.83 rows=3) + -> Single-row index lookup on t1 using PRIMARY (id=t3.id) (cost=0.28 rows=1) + -> Filter: (t2.`owner` = t3.id) (cost=0.18 rows=3) + -> Table scan on t2 (cost=0.18 rows=3) + +select t1.name, t2.name, t2.id, t2.owner, t3.id from t1 left join t2 on (t1.id = t2.owner) right join t1 as t3 on t3.id=t2.owner; +name name id owner id +Antonio Paz El Gato 1 1 1 +Antonio Paz Perrito 2 1 1 +NULL NULL NULL NULL 2 +Thimble Smith Happy 3 3 3 +drop table t1,t2; +create table t1 (id int not null, str char(10), index(str)); +insert into t1 values (1, null), (2, null), (3, "foo"), (4, "bar"); +select * from t1 where str is not null order by id; +id str +3 foo +4 bar +select * from t1 where str is null; +id str +1 NULL +2 NULL +explain select * from t1 where str is null; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref str str 41 const 2 100.00 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,`test`.`t1`.`str` AS `str` from `test`.`t1` where (`test`.`t1`.`str` is null) +explain format=tree select * from t1 where str is null; +EXPLAIN +-> Parallel scan on + -> PQblock lookup on t1 using str (str=NULL), with index condition: (t1.str is null) (cost=0.70 rows=2) + +drop table t1; +CREATE TABLE t1 ( +t1_id bigint(21) NOT NULL auto_increment, +PRIMARY KEY (t1_id) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t2 ( +t2_id bigint(21) NOT NULL auto_increment, +PRIMARY KEY (t2_id) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t3 ( +t3_id bigint(21) NOT NULL auto_increment, +PRIMARY KEY (t3_id) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t4 ( +seq_0_id bigint(21) DEFAULT '0' NOT NULL, +seq_1_id bigint(21) DEFAULT '0' NOT NULL, +KEY seq_0_id (seq_0_id), +KEY seq_1_id (seq_1_id) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t5 ( +seq_0_id bigint(21) DEFAULT '0' NOT NULL, +seq_1_id bigint(21) DEFAULT '0' NOT NULL, +KEY seq_1_id (seq_1_id), +KEY seq_0_id (seq_0_id) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t1 values (1); +insert into t2 values (1); +insert into t3 values (1); +insert into t4 values (1,1); +insert into t5 values (1,1); +explain select * from t3 left join t4 on t4.seq_1_id = t2.t2_id left join t1 on t1.t1_id = t4.seq_0_id left join t5 on t5.seq_0_id = t1.t1_id left join t2 on t2.t2_id = t5.seq_1_id where t3.t3_id = 23; +ERROR 42S22: Unknown column 't2.t2_id' in 'on clause' +drop table t1,t2,t3,t4,t5; +create table t1 (n int, m int, o int, key(n)); +create table t2 (n int not null, m int, o int, primary key(n)); +insert into t1 values (1, 2, 11), (1, 2, 7), (2, 2, 8), (1,2,9),(1,3,9); +insert into t2 values (1, 2, 3),(2, 2, 8), (4,3,9),(3,2,10); +select t1.*, t2.* from t1 left join t2 on t1.n = t2.n and +t1.m = t2.m where t1.n = 1; +n m o n m o +1 2 11 1 2 3 +1 2 7 1 2 3 +1 2 9 1 2 3 +1 3 9 NULL NULL NULL +select t1.*, t2.* from t1 left join t2 on t1.n = t2.n and +t1.m = t2.m where t1.n = 1 order by t1.o,t1.m; +n m o n m o +1 2 7 1 2 3 +1 2 9 1 2 3 +1 3 9 NULL NULL NULL +1 2 11 1 2 3 +drop table t1,t2; +CREATE TABLE t1 (id1 INT NOT NULL PRIMARY KEY, dat1 CHAR(1), id2 INT); +INSERT INTO t1 VALUES (1,'a',1); +INSERT INTO t1 VALUES (2,'b',1); +INSERT INTO t1 VALUES (3,'c',2); +CREATE TABLE t2 (id2 INT NOT NULL PRIMARY KEY, dat2 CHAR(1)); +INSERT INTO t2 VALUES (1,'x'); +INSERT INTO t2 VALUES (2,'y'); +INSERT INTO t2 VALUES (3,'z'); +SELECT t2.id2 FROM t2 LEFT OUTER JOIN t1 ON t1.id2 = t2.id2 WHERE id1 IS NULL; +id2 +3 +SELECT t2.id2 FROM t2 NATURAL LEFT OUTER JOIN t1 WHERE id1 IS NULL; +id2 +3 +drop table t1,t2; +create table t1 ( color varchar(20), name varchar(20) ); +insert into t1 values ( 'red', 'apple' ); +insert into t1 values ( 'yellow', 'banana' ); +insert into t1 values ( 'green', 'lime' ); +insert into t1 values ( 'black', 'grape' ); +insert into t1 values ( 'blue', 'blueberry' ); +create table t2 ( count int, color varchar(20) ); +insert into t2 values (10, 'green'); +insert into t2 values (5, 'black'); +insert into t2 values (15, 'white'); +insert into t2 values (7, 'green'); +select * from t1; +color name +red apple +yellow banana +green lime +black grape +blue blueberry +select * from t2; +count color +10 green +5 black +15 white +7 green +select * from t2 natural join t1; +color count name +black 5 grape +green 10 lime +green 7 lime +select t2.count, t1.name from t2 natural join t1; +count name +10 lime +5 grape +7 lime +select t2.count, t1.name from t2 inner join t1 using (color); +count name +10 lime +5 grape +7 lime +drop table t1; +drop table t2; +CREATE TABLE t1 ( +pcode varchar(8) DEFAULT '' NOT NULL +); +INSERT INTO t1 VALUES ('kvw2000'),('kvw2001'),('kvw3000'),('kvw3001'),('kvw3002'),('kvw3500'),('kvw3501'),('kvw3502'),('kvw3800'),('kvw3801'),('kvw3802'),('kvw3900'),('kvw3901'),('kvw3902'),('kvw4000'),('kvw4001'),('kvw4002'),('kvw4200'),('kvw4500'),('kvw5000'),('kvw5001'),('kvw5500'),('kvw5510'),('kvw5600'),('kvw5601'),('kvw6000'),('klw1000'),('klw1020'),('klw1500'),('klw2000'),('klw2001'),('klw2002'),('kld2000'),('klw2500'),('kmw1000'),('kmw1500'),('kmw2000'),('kmw2001'),('kmw2100'),('kmw3000'),('kmw3200'); +CREATE TABLE t2 ( +pcode varchar(8) DEFAULT '' NOT NULL, +KEY pcode (pcode) +); +INSERT INTO t2 VALUES ('kvw2000'),('kvw2000'),('kvw2000'),('kvw2000'),('kvw2000'),('kvw2000'),('kvw2000'),('kvw2000'),('kvw2000'),('kvw2000'),('kvw2000'),('kvw2000'),('kvw2000'),('kvw2000'),('kvw2000'),('kvw2000'),('kvw2000'),('kvw2000'),('kvw2000'),('kvw2000'),('kvw2000'),('kvw2000'),('kvw2000'),('kvw2000'),('kvw2000'),('kvw2000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw6000'),('kvw6000'),('kld2000'); +SELECT t1.pcode, IF(ISNULL(t2.pcode), 0, COUNT(*)) AS count FROM t1 +LEFT JOIN t2 ON t1.pcode = t2.pcode GROUP BY t1.pcode; +pcode count +kld2000 1 +klw1000 0 +klw1020 0 +klw1500 0 +klw2000 0 +klw2001 0 +klw2002 0 +klw2500 0 +kmw1000 0 +kmw1500 0 +kmw2000 0 +kmw2001 0 +kmw2100 0 +kmw3000 0 +kmw3200 0 +kvw2000 26 +kvw2001 0 +kvw3000 36 +kvw3001 0 +kvw3002 0 +kvw3500 26 +kvw3501 0 +kvw3502 0 +kvw3800 0 +kvw3801 0 +kvw3802 0 +kvw3900 0 +kvw3901 0 +kvw3902 0 +kvw4000 0 +kvw4001 0 +kvw4002 0 +kvw4200 0 +kvw4500 0 +kvw5000 0 +kvw5001 0 +kvw5500 0 +kvw5510 0 +kvw5600 0 +kvw5601 0 +kvw6000 2 +SELECT SQL_BIG_RESULT t1.pcode, IF(ISNULL(t2.pcode), 0, COUNT(*)) AS count FROM t1 LEFT JOIN t2 ON t1.pcode = t2.pcode GROUP BY t1.pcode; +pcode count +kld2000 1 +klw1000 0 +klw1020 0 +klw1500 0 +klw2000 0 +klw2001 0 +klw2002 0 +klw2500 0 +kmw1000 0 +kmw1500 0 +kmw2000 0 +kmw2001 0 +kmw2100 0 +kmw3000 0 +kmw3200 0 +kvw2000 26 +kvw2001 0 +kvw3000 36 +kvw3001 0 +kvw3002 0 +kvw3500 26 +kvw3501 0 +kvw3502 0 +kvw3800 0 +kvw3801 0 +kvw3802 0 +kvw3900 0 +kvw3901 0 +kvw3902 0 +kvw4000 0 +kvw4001 0 +kvw4002 0 +kvw4200 0 +kvw4500 0 +kvw5000 0 +kvw5001 0 +kvw5500 0 +kvw5510 0 +kvw5600 0 +kvw5601 0 +kvw6000 2 +drop table t1,t2; +SET sql_mode = 'NO_ENGINE_SUBSTITUTION'; +CREATE TABLE t1 ( +id int(11), +pid int(11), +rep_del tinyint(4), +KEY id (id), +KEY pid (pid) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (1,NULL,NULL); +INSERT INTO t1 VALUES (2,1,NULL); +select * from t1 LEFT JOIN t1 t2 ON (t1.id=t2.pid) AND t2.rep_del IS NULL; +id pid rep_del id pid rep_del +1 NULL NULL 2 1 NULL +2 1 NULL NULL NULL NULL +create index rep_del ON t1(rep_del); +select * from t1 LEFT JOIN t1 t2 ON (t1.id=t2.pid) AND t2.rep_del IS NULL; +id pid rep_del id pid rep_del +1 NULL NULL 2 1 NULL +2 1 NULL NULL NULL NULL +drop table t1; +CREATE TABLE t1 ( +id int(11) DEFAULT '0' NOT NULL, +name tinytext DEFAULT '' NOT NULL, +UNIQUE id (id) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1101 BLOB, TEXT, GEOMETRY or JSON column 'name' can't have a default value +INSERT INTO t1 VALUES (1,'yes'),(2,'no'); +CREATE TABLE t2 ( +id int(11) DEFAULT '0' NOT NULL, +idx int(11) DEFAULT '0' NOT NULL, +UNIQUE id (id,idx) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (1,1); +explain SELECT * from t1 left join t2 on t1.id=t2.id where t2.id IS NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ref id id 4 test.t1.id 1 100.00 Using where; Not exists; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,`test`.`t1`.`name` AS `name`,`test`.`t2`.`id` AS `id`,`test`.`t2`.`idx` AS `idx` from `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`id` = `test`.`t1`.`id`)) where (`test`.`t2`.`id` is null) +SELECT * from t1 left join t2 on t1.id=t2.id where t2.id IS NULL; +id name id idx +2 no NULL NULL +drop table t1,t2; +SET sql_mode = default; +create table t1 (bug_id mediumint, reporter mediumint); +create table t2 (bug_id mediumint, who mediumint, index(who)); +insert into t2 values (1,1),(1,2); +insert into t1 values (1,1),(2,1); +SELECT * FROM t1 LEFT JOIN t2 ON (t1.bug_id = t2.bug_id AND t2.who = 2) WHERE (t1.reporter = 2 OR t2.who = 2); +bug_id reporter bug_id who +1 1 1 2 +drop table t1,t2; +create table t1 (fooID smallint unsigned auto_increment, primary key (fooID)); +create table t2 (fooID smallint unsigned not null, barID smallint unsigned not null, primary key (fooID,barID)); +insert into t1 (fooID) values (10),(20),(30); +insert into t2 values (10,1),(20,2),(30,3); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +explain select * from t2 left join t1 on t1.fooID = t2.fooID and t1.fooID = 30; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL index NULL PRIMARY 4 NULL 3 100.00 Using index +2 SIMPLE t1 NULL const PRIMARY PRIMARY 2 const 1 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`fooID` AS `fooID`,`test`.`t2`.`barID` AS `barID`,`test`.`t1`.`fooID` AS `fooID` from `test`.`t2` left join `test`.`t1` on(((`test`.`t2`.`fooID` = 30) and (`test`.`t1`.`fooID` = 30))) where true +select * from t2 left join t1 on t1.fooID = t2.fooID and t1.fooID = 30; +fooID barID fooID +10 1 NULL +20 2 NULL +30 3 30 +select * from t2 left join t1 ignore index(primary) on t1.fooID = t2.fooID and t1.fooID = 30; +fooID barID fooID +10 1 NULL +20 2 NULL +30 3 30 +drop table t1,t2; +create table t1 (i int); +create table t2 (i int); +create table t3 (i int); +insert into t1 values(1),(2); +insert into t2 values(2),(3); +insert into t3 values(2),(4); +select * from t1 natural left join t2 natural left join t3; +i +1 +2 +select * from t1 natural left join t2 where (t2.i is not null)=0; +i +1 +select * from t1 natural left join t2 where (t2.i is not null) is not null; +i +1 +2 +select * from t1 natural left join t2 where (i is not null)=0; +i +select * from t1 natural left join t2 where (i is not null) is not null; +i +1 +2 +drop table t1,t2,t3; +create table t1 (f1 integer,f2 integer,f3 integer); +create table t2 (f2 integer,f4 integer); +create table t3 (f3 integer,f5 integer); +select * from t1 +left outer join t2 using (f2) +left outer join t3 using (f3); +f3 f2 f1 f4 f5 +drop table t1,t2,t3; +create table t1 (a1 int, a2 int); +create table t2 (b1 int not null, b2 int); +create table t3 (c1 int, c2 int); +insert into t1 values (1,2), (2,2), (3,2); +insert into t2 values (1,3), (2,3); +insert into t3 values (2,4), (3,4); +ANALYZE TABLE t1, t2, t3; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +select * from t1 left join t2 on b1 = a1 left join t3 on c1 = a1 and b1 is null; +a1 a2 b1 b2 c1 c2 +1 2 1 3 NULL NULL +2 2 2 3 NULL NULL +3 2 NULL NULL 3 4 +explain select * from t1 left join t2 on b1 = a1 left join t3 on c1 = a1 and b1 is null; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,`test`.`t2`.`b1` AS `b1`,`test`.`t2`.`b2` AS `b2`,`test`.`t3`.`c1` AS `c1`,`test`.`t3`.`c2` AS `c2` from `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`b1` = `test`.`t1`.`a1`)) left join `test`.`t3` on(((`test`.`t3`.`c1` = `test`.`t1`.`a1`) and (`test`.`t2`.`b1` is null))) where true +drop table t1, t2, t3; +create table t1 ( +a int(11), +b char(10), +key (a) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t1 (a) values (1),(2),(3),(4); +create table t2 (a int); +select * from t1 left join t2 on t1.a=t2.a where not (t2.a <=> t1.a); +a b a +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +select * from t1 left join t2 on t1.a=t2.a having not (t2.a <=> t1.a); +a b a +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +drop table t1,t2; +create table t1 ( +match_id tinyint(3) unsigned not null auto_increment, +home tinyint(3) unsigned default '0', +unique key match_id (match_id), +key match_id_2 (match_id) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t1 values("1", "2"); +create table t2 ( +player_id tinyint(3) unsigned default '0', +match_1_h tinyint(3) unsigned default '0', +key player_id (player_id) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t2 values("1", "5"); +insert into t2 values("2", "9"); +insert into t2 values("3", "3"); +insert into t2 values("4", "7"); +insert into t2 values("5", "6"); +insert into t2 values("6", "8"); +insert into t2 values("7", "4"); +insert into t2 values("8", "12"); +insert into t2 values("9", "11"); +insert into t2 values("10", "10"); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +explain select s.*, '*', m.*, (s.match_1_h - m.home) UUX from +(t2 s left join t1 m on m.match_id = 1) +order by m.match_id desc; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 100.00 Parallel execute (1 workers) +2 SIMPLE s NULL ALL NULL NULL NULL NULL 10 100.00 Using temporary; Using filesort +2 SIMPLE m NULL const match_id,match_id_2 match_id 1 const 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`s`.`player_id` AS `player_id`,`test`.`s`.`match_1_h` AS `match_1_h`,'*' AS `*`,`test`.`m`.`match_id` AS `match_id`,`test`.`m`.`home` AS `home`,(`test`.`s`.`match_1_h` - `test`.`m`.`home`) AS `UUX` from `test`.`t2` `s` left join `test`.`t1` `m` on((`test`.`m`.`match_id` = 1)) where true order by `test`.`m`.`match_id` desc +explain select s.*, '*', m.*, (s.match_1_h - m.home) UUX from +(t2 s left join t1 m on m.match_id = 1) +order by UUX desc; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 100.00 Parallel execute (1 workers) +2 SIMPLE s NULL ALL NULL NULL NULL NULL 10 100.00 Using temporary; Using filesort +2 SIMPLE m NULL const match_id,match_id_2 match_id 1 const 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`s`.`player_id` AS `player_id`,`test`.`s`.`match_1_h` AS `match_1_h`,'*' AS `*`,`test`.`m`.`match_id` AS `match_id`,`test`.`m`.`home` AS `home`,(`test`.`s`.`match_1_h` - `test`.`m`.`home`) AS `UUX` from `test`.`t2` `s` left join `test`.`t1` `m` on((`test`.`m`.`match_id` = 1)) where true order by `UUX` desc +select s.*, '*', m.*, (s.match_1_h - m.home) UUX from +(t2 s left join t1 m on m.match_id = 1) +order by UUX desc; +player_id match_1_h * match_id home UUX +8 12 * 1 2 10 +9 11 * 1 2 9 +10 10 * 1 2 8 +2 9 * 1 2 7 +6 8 * 1 2 6 +4 7 * 1 2 5 +5 6 * 1 2 4 +1 5 * 1 2 3 +7 4 * 1 2 2 +3 3 * 1 2 1 +explain select s.*, '*', m.*, (s.match_1_h - m.home) UUX from +t2 s straight_join t1 m where m.match_id = 1 +order by UUX desc; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 100.00 Parallel execute (1 workers) +2 SIMPLE s NULL ALL NULL NULL NULL NULL 10 100.00 Using temporary; Using filesort +2 SIMPLE m NULL const match_id,match_id_2 match_id 1 const 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`s`.`player_id` AS `player_id`,`test`.`s`.`match_1_h` AS `match_1_h`,'*' AS `*`,`test`.`m`.`match_id` AS `match_id`,`test`.`m`.`home` AS `home`,(`test`.`s`.`match_1_h` - `test`.`m`.`home`) AS `UUX` from `test`.`t2` `s` straight_join `test`.`t1` `m` where (`test`.`m`.`match_id` = 1) order by `UUX` desc +select s.*, '*', m.*, (s.match_1_h - m.home) UUX from +t2 s straight_join t1 m where m.match_id = 1 +order by UUX desc; +player_id match_1_h * match_id home UUX +8 12 * 1 2 10 +9 11 * 1 2 9 +10 10 * 1 2 8 +2 9 * 1 2 7 +6 8 * 1 2 6 +4 7 * 1 2 5 +5 6 * 1 2 4 +1 5 * 1 2 3 +7 4 * 1 2 2 +3 3 * 1 2 1 +drop table t1, t2; +create table t1 (a int, b int, unique index idx (a, b)); +create table t2 (a int, b int, c int, unique index idx (a, b)); +insert into t1 values (1, 10), (1,11), (2,10), (2,11); +insert into t2 values (1,10,3); +select t1.a, t1.b, t2.c from t1 left join t2 +on t1.a=t2.a and t1.b=t2.b and t2.c=3 +where t1.a=1 and t2.c is null; +a b c +1 11 NULL +drop table t1, t2; +CREATE TABLE t1 ( +ts_id bigint(20) default NULL, +inst_id tinyint(4) default NULL, +flag_name varchar(64) default NULL, +flag_value text, +UNIQUE KEY ts_id (ts_id,inst_id,flag_name) +) ENGINE=MyISAM DEFAULT CHARSET=utf8; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +CREATE TABLE t2 ( +ts_id bigint(20) default NULL, +inst_id tinyint(4) default NULL, +flag_name varchar(64) default NULL, +flag_value text, +UNIQUE KEY ts_id (ts_id,inst_id,flag_name) +) ENGINE=MyISAM DEFAULT CHARSET=utf8; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES +(111056548820001, 0, 'flag1', NULL), +(111056548820001, 0, 'flag2', NULL), +(2, 0, 'other_flag', NULL); +INSERT INTO t2 VALUES +(111056548820001, 3, 'flag1', 'sss'); +SELECT t1.flag_name,t2.flag_value +FROM t1 LEFT JOIN t2 +ON (t1.ts_id = t2.ts_id AND t1.flag_name = t2.flag_name AND +t2.inst_id = 3) +WHERE t1.inst_id = 0 AND t1.ts_id=111056548820001 AND +t2.flag_value IS NULL; +flag_name flag_value +flag2 NULL +DROP TABLE t1,t2; +CREATE TABLE t1 ( +id int(11) unsigned NOT NULL auto_increment, +text_id int(10) unsigned default NULL, +PRIMARY KEY (id) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES("1", "0"); +INSERT INTO t1 VALUES("2", "10"); +CREATE TABLE t2 ( +text_id char(3) NOT NULL default '', +language_id char(3) NOT NULL default '', +text_data text, +PRIMARY KEY (text_id,language_id) +); +INSERT INTO t2 VALUES("0", "EN", "0-EN"); +INSERT INTO t2 VALUES("0", "SV", "0-SV"); +INSERT INTO t2 VALUES("10", "EN", "10-EN"); +INSERT INTO t2 VALUES("10", "SV", "10-SV"); +SELECT t1.id, t1.text_id, t2.text_data +FROM t1 LEFT JOIN t2 +ON t1.text_id = t2.text_id +AND t2.language_id = 'SV' + WHERE (t1.id LIKE '%' OR t2.text_data LIKE '%'); +id text_id text_data +1 0 0-SV +2 10 10-SV +DROP TABLE t1, t2; +CREATE TABLE t0 (a0 int PRIMARY KEY); +CREATE TABLE t1 (a1 int PRIMARY KEY); +CREATE TABLE t2 (a2 int); +CREATE TABLE t3 (a3 int); +INSERT INTO t0 VALUES (1); +INSERT INTO t1 VALUES (1); +INSERT INTO t2 VALUES (1), (2); +INSERT INTO t3 VALUES (1), (2); +SELECT * FROM t1 LEFT JOIN t2 ON a1=0; +a1 a2 +1 NULL +EXPLAIN SELECT * FROM t1 LEFT JOIN t2 ON a1=0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL PRIMARY 4 NULL 1 100.00 Using index +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t2`.`a2` AS `a2` from `test`.`t1` left join `test`.`t2` on((`test`.`t1`.`a1` = 0)) where true +SELECT * FROM t1 LEFT JOIN (t2,t3) ON a1=0; +a1 a2 a3 +1 NULL NULL +EXPLAIN SELECT * FROM t1 LEFT JOIN (t2,t3) ON a1=0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL PRIMARY 4 NULL 1 100.00 Using index +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t2`.`a2` AS `a2`,`test`.`t3`.`a3` AS `a3` from `test`.`t1` left join (`test`.`t2` join `test`.`t3`) on((`test`.`t1`.`a1` = 0)) where true +SELECT * FROM t0, t1 LEFT JOIN (t2,t3) ON a1=0 WHERE a0=a1; +a0 a1 a2 a3 +1 1 NULL NULL +EXPLAIN SELECT * FROM t0, t1 LEFT JOIN (t2,t3) ON a1=0 WHERE a0=a1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t0 NULL index PRIMARY PRIMARY 4 NULL 1 100.00 Using index +2 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t0.a0 1 100.00 Using index +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`a0` AS `a0`,`test`.`t1`.`a1` AS `a1`,`test`.`t2`.`a2` AS `a2`,`test`.`t3`.`a3` AS `a3` from `test`.`t0` join `test`.`t1` left join (`test`.`t2` join `test`.`t3`) on(((`test`.`t0`.`a0` = 0) and (`test`.`t1`.`a1` = 0))) where (`test`.`t1`.`a1` = `test`.`t0`.`a0`) +INSERT INTO t0 VALUES (0); +INSERT INTO t1 VALUES (0); +SELECT * FROM t0, t1 LEFT JOIN (t2,t3) ON a1=5 WHERE a0=a1 AND a0=1; +a0 a1 a2 a3 +1 1 NULL NULL +EXPLAIN SELECT * FROM t0, t1 LEFT JOIN (t2,t3) ON a1=5 WHERE a0=a1 AND a0=1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL const PRIMARY PRIMARY 4 const 1 100.00 Using index +1 SIMPLE t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 Using index +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select '1' AS `a0`,'1' AS `a1`,`test`.`t2`.`a2` AS `a2`,`test`.`t3`.`a3` AS `a3` from `test`.`t0` join `test`.`t1` left join (`test`.`t2` join `test`.`t3`) on(false) where true +drop table t1,t2; +create table t1 (a int, b int); +insert into t1 values (1,1),(2,2),(3,3); +create table t2 (a int, b int); +insert into t2 values (1,1), (2,2); +select * from t2 right join t1 on t2.a=t1.a; +a b a b +1 1 1 1 +2 2 2 2 +NULL NULL 3 3 +select straight_join * from t2 right join t1 on t2.a=t1.a; +a b a b +1 1 1 1 +2 2 2 2 +NULL NULL 3 3 +DROP TABLE t0,t1,t2,t3; +CREATE TABLE t1 (a int PRIMARY KEY, b int); +CREATE TABLE t2 (a int PRIMARY KEY, b int); +INSERT INTO t1 VALUES (1,1), (2,1), (3,1), (4,2); +INSERT INTO t2 VALUES (1,2), (2,2); +SELECT * FROM t1 LEFT JOIN t2 ON t1.a=t2.a; +a b a b +1 1 1 2 +2 1 2 2 +3 1 NULL NULL +4 2 NULL NULL +SELECT * FROM t1 LEFT JOIN t2 ON t1.a=t2.a WHERE t1.b=1; +a b a b +1 1 1 2 +2 1 2 2 +3 1 NULL NULL +SELECT * FROM t1 LEFT JOIN t2 ON t1.a=t2.a +WHERE t1.b=1 XOR (NOT ISNULL(t2.a) AND t2.b=1); +a b a b +1 1 1 2 +2 1 2 2 +3 1 NULL NULL +SELECT * FROM t1 LEFT JOIN t2 ON t1.a=t2.a WHERE not(0+(t1.a=30 and t2.b=1)); +a b a b +1 1 1 2 +2 1 2 2 +3 1 NULL NULL +4 2 NULL NULL +DROP TABLE t1,t2; +set group_concat_max_len=5; +create table t1 (a int, b varchar(20)); +create table t2 (a int, c varchar(20)); +insert into t1 values (1,"aaaaaaaaaa"),(2,"bbbbbbbbbb"); +insert into t2 values (1,"cccccccccc"),(2,"dddddddddd"); +select group_concat(t1.b,t2.c) from t1 left join t2 using(a) group by t1.a; +group_concat(t1.b,t2.c) +aaaaa +bbbbb +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +select group_concat(t1.b,t2.c) from t1 inner join t2 using(a) group by t1.a; +group_concat(t1.b,t2.c) +aaaaa +bbbbb +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +select group_concat(t1.b,t2.c) from t1 left join t2 using(a) group by a; +group_concat(t1.b,t2.c) +aaaaa +bbbbb +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +select group_concat(t1.b,t2.c) from t1 inner join t2 using(a) group by a; +group_concat(t1.b,t2.c) +aaaaa +bbbbb +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +drop table t1, t2; +set group_concat_max_len=default; +create table t1 (gid smallint(5) unsigned not null, x int(11) not null, y int(11) not null, art int(11) not null, primary key (gid,x,y)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert t1 values (1, -5, -8, 2), (1, 2, 2, 1), (1, 1, 1, 1); +create table t2 (gid smallint(5) unsigned not null, x int(11) not null, y int(11) not null, id int(11) not null, primary key (gid,id,x,y), key id (id)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert t2 values (1, -5, -8, 1), (1, 1, 1, 1), (1, 2, 2, 1); +create table t3 ( set_id smallint(5) unsigned not null, id tinyint(4) unsigned not null, name char(12) not null, primary key (id,set_id)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert t3 values (0, 1, 'a'), (1, 1, 'b'), (0, 2, 'c'), (1, 2, 'd'), (1, 3, 'e'), (1, 4, 'f'), (1, 5, 'g'), (1, 6, 'h'); +explain select name from t1 left join t2 on t1.x = t2.x and t1.y = t2.y +left join t3 on t1.art = t3.id where t2.id =1 and t2.x = -5 and t2.y =-8 +and t1.gid =1 and t2.gid =1 and t3.set_id =1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL const PRIMARY PRIMARY 10 const,const,const 1 100.00 NULL +1 SIMPLE t2 NULL const PRIMARY,id PRIMARY 14 const,const,const,const 1 100.00 Using index +1 SIMPLE t3 NULL const PRIMARY PRIMARY 3 const,const 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select 'd' AS `name` from `test`.`t1` join `test`.`t2` join `test`.`t3` where true +drop tables t1,t2,t3; +CREATE TABLE t1 (EMPNUM INT, GRP INT); +INSERT INTO t1 VALUES (0, 10); +INSERT INTO t1 VALUES (2, 30); +CREATE TABLE t2 (EMPNUM INT, NAME CHAR(5)); +INSERT INTO t2 VALUES (0, 'KERI'); +INSERT INTO t2 VALUES (9, 'BARRY'); +CREATE VIEW v1 AS +SELECT COALESCE(t2.EMPNUM,t1.EMPNUM) AS EMPNUM, NAME, GRP +FROM t2 LEFT OUTER JOIN t1 ON t2.EMPNUM=t1.EMPNUM; +SELECT * FROM v1; +EMPNUM NAME GRP +0 KERI 10 +9 BARRY NULL +SELECT * FROM v1 WHERE EMPNUM < 10; +EMPNUM NAME GRP +0 KERI 10 +9 BARRY NULL +DROP VIEW v1; +DROP TABLE t1,t2; +CREATE TABLE t1 (c11 int); +CREATE TABLE t2 (c21 int); +INSERT INTO t1 VALUES (30), (40), (50); +INSERT INTO t2 VALUES (300), (400), (500); +SELECT * FROM t1 LEFT JOIN t2 ON (c11=c21 AND c21=30) WHERE c11=40; +c11 c21 +40 NULL +DROP TABLE t1, t2; +CREATE TABLE t1 (a int PRIMARY KEY, b int); +CREATE TABLE t2 (a int PRIMARY KEY, b int); +INSERT INTO t1 VALUES (1,2), (2,1), (3,2), (4,3), (5,6), (6,5), (7,8), (8,7), (9,10); +INSERT INTO t2 VALUES (3,0), (4,1), (6,4), (7,5); +SELECT * FROM t1 LEFT JOIN t2 ON t1.a = t2.a WHERE t2.b <= t1.a AND t1.a <= t1.b; +a b a b +7 8 7 5 +SELECT * FROM t1 LEFT JOIN t2 ON t1.a = t2.a WHERE t1.a BETWEEN t2.b AND t1.b; +a b a b +7 8 7 5 +SELECT * FROM t1 LEFT JOIN t2 ON t1.a = t2.a WHERE NOT(t1.a NOT BETWEEN t2.b AND t1.b); +a b a b +7 8 7 5 +SELECT * FROM t1 LEFT JOIN t2 ON t1.a = t2.a WHERE t2.b > t1.a OR t1.a > t1.b; +a b a b +2 1 NULL NULL +3 2 3 0 +4 3 4 1 +6 5 6 4 +8 7 NULL NULL +SELECT * FROM t1 LEFT JOIN t2 ON t1.a = t2.a WHERE t1.a NOT BETWEEN t2.b AND t1.b; +a b a b +2 1 NULL NULL +3 2 3 0 +4 3 4 1 +6 5 6 4 +8 7 NULL NULL +SELECT * FROM t1 LEFT JOIN t2 ON t1.a = t2.a WHERE NOT(t1.a BETWEEN t2.b AND t1.b); +a b a b +2 1 NULL NULL +3 2 3 0 +4 3 4 1 +6 5 6 4 +8 7 NULL NULL +SELECT * FROM t1 LEFT JOIN t2 ON t1.a = t2.a WHERE t1.a = t2.a OR t2.b > t1.a OR t1.a > t1.b; +a b a b +2 1 NULL NULL +3 2 3 0 +4 3 4 1 +6 5 6 4 +7 8 7 5 +8 7 NULL NULL +SELECT * FROM t1 LEFT JOIN t2 ON t1.a = t2.a WHERE NOT(t1.a != t2.a AND t1.a BETWEEN t2.b AND t1.b); +a b a b +2 1 NULL NULL +3 2 3 0 +4 3 4 1 +6 5 6 4 +7 8 7 5 +8 7 NULL NULL +SELECT * FROM t1 LEFT JOIN t2 ON t1.a = t2.a WHERE t1.a = t2.a AND (t2.b > t1.a OR t1.a > t1.b); +a b a b +3 2 3 0 +4 3 4 1 +6 5 6 4 +SELECT * FROM t1 LEFT JOIN t2 ON t1.a = t2.a WHERE NOT(t1.a != t2.a OR t1.a BETWEEN t2.b AND t1.b); +a b a b +3 2 3 0 +4 3 4 1 +6 5 6 4 +SELECT * FROM t1 LEFT JOIN t2 ON t1.a = t2.a WHERE t1.a = t2.a OR t1.a = t2.b; +a b a b +3 2 3 0 +4 3 4 1 +6 5 6 4 +7 8 7 5 +SELECT * FROM t1 LEFT JOIN t2 ON t1.a = t2.a WHERE t1.a IN(t2.a, t2.b); +a b a b +3 2 3 0 +4 3 4 1 +6 5 6 4 +7 8 7 5 +SELECT * FROM t1 LEFT JOIN t2 ON t1.a = t2.a WHERE NOT(t1.a NOT IN(t2.a, t2.b)); +a b a b +3 2 3 0 +4 3 4 1 +6 5 6 4 +7 8 7 5 +SELECT * FROM t1 LEFT JOIN t2 ON t1.a = t2.a WHERE t1.a != t1.b AND t1.a != t2.b; +a b a b +3 2 3 0 +4 3 4 1 +6 5 6 4 +7 8 7 5 +SELECT * FROM t1 LEFT JOIN t2 ON t1.a = t2.a WHERE t1.a NOT IN(t1.b, t2.b); +a b a b +3 2 3 0 +4 3 4 1 +6 5 6 4 +7 8 7 5 +SELECT * FROM t1 LEFT JOIN t2 ON t1.a = t2.a WHERE NOT(t1.a IN(t1.b, t2.b)); +a b a b +3 2 3 0 +4 3 4 1 +6 5 6 4 +7 8 7 5 +SELECT * FROM t1 LEFT JOIN t2 ON t1.a = t2.a WHERE t2.a != t2.b OR (t1.a != t2.a AND t1.a != t2.b); +a b a b +3 2 3 0 +4 3 4 1 +6 5 6 4 +7 8 7 5 +SELECT * FROM t1 LEFT JOIN t2 ON t1.a = t2.a WHERE NOT(t2.a = t2.b AND t1.a IN(t2.a, t2.b)); +a b a b +3 2 3 0 +4 3 4 1 +6 5 6 4 +7 8 7 5 +SELECT * FROM t1 LEFT JOIN t2 ON t1.a = t2.a WHERE t2.a != t2.b AND t1.a != t1.b AND t1.a != t2.b; +a b a b +3 2 3 0 +4 3 4 1 +6 5 6 4 +7 8 7 5 +SELECT * FROM t1 LEFT JOIN t2 ON t1.a = t2.a WHERE NOT(t2.a = t2.b OR t1.a IN(t1.b, t2.b)); +a b a b +3 2 3 0 +4 3 4 1 +6 5 6 4 +7 8 7 5 +EXPLAIN SELECT * FROM t1 LEFT JOIN t2 ON t1.a = t2.a WHERE t1.a = t2.a OR t1.a = t2.b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ALL PRIMARY NULL NULL NULL 4 100.00 Using where +2 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.a 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` join `test`.`t2` where (`test`.`t1`.`a` = `test`.`t2`.`a`) +EXPLAIN SELECT * FROM t1 LEFT JOIN t2 ON t1.a = t2.a WHERE t1.a IN(t2.a, t2.b); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ALL PRIMARY NULL NULL NULL 4 100.00 Using where +2 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.a 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` join `test`.`t2` where ((`test`.`t1`.`a` = `test`.`t2`.`a`) and (`test`.`t2`.`a` in (`test`.`t2`.`a`,`test`.`t2`.`b`))) +EXPLAIN SELECT * FROM t1 LEFT JOIN t2 ON t1.a = t2.a WHERE t1.a > IF(t1.a = t2.b-2, t2.b, t2.b-1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ALL PRIMARY NULL NULL NULL 4 100.00 Using where +2 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.a 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` join `test`.`t2` where ((`test`.`t1`.`a` = `test`.`t2`.`a`) and (`test`.`t2`.`a` > if((`test`.`t2`.`a` = (`test`.`t2`.`b` - 2)),`test`.`t2`.`b`,(`test`.`t2`.`b` - 1)))) +DROP TABLE t1,t2; +DROP VIEW IF EXISTS v1,v2; +DROP TABLE IF EXISTS t1,t2; +CREATE TABLE t1 (a int); +CREATE table t2 (b int); +INSERT INTO t1 VALUES (1), (2), (3), (4), (1), (1), (3); +INSERT INTO t2 VALUES (2), (3); +CREATE VIEW v1 AS SELECT a FROM t1 JOIN t2 ON t1.a=t2.b; +CREATE VIEW v2 AS SELECT b FROM t2 JOIN t1 ON t2.b=t1.a; +SELECT v1.a, v2. b +FROM v1 LEFT OUTER JOIN v2 ON (v1.a=v2.b) AND (v1.a >= 3) +GROUP BY v1.a; +a b +2 NULL +3 3 +SELECT v1.a, v2. b +FROM { OJ v1 LEFT OUTER JOIN v2 ON (v1.a=v2.b) AND (v1.a >= 3) } +GROUP BY v1.a; +a b +2 NULL +3 3 +DROP VIEW v1,v2; +DROP TABLE t1,t2; +CREATE TABLE t1 (a int); +CREATE TABLE t2 (b int); +INSERT INTO t1 VALUES (1), (2), (3), (4); +INSERT INTO t2 VALUES (2), (3); +SELECT * FROM t1 LEFT JOIN t2 ON t1.a = t2.b WHERE (1=1); +a b +1 NULL +2 2 +3 3 +4 NULL +SELECT * FROM t1 LEFT JOIN t2 ON t1.a = t2.b WHERE (1 OR 1); +a b +1 NULL +2 2 +3 3 +4 NULL +SELECT * FROM t1 LEFT JOIN t2 ON t1.a = t2.b WHERE (0 OR 1); +a b +1 NULL +2 2 +3 3 +4 NULL +SELECT * FROM t1 LEFT JOIN t2 ON t1.a = t2.b WHERE (1=1 OR 2=2); +a b +1 NULL +2 2 +3 3 +4 NULL +SELECT * FROM t1 LEFT JOIN t2 ON t1.a = t2.b WHERE (1=1 OR 1=0); +a b +1 NULL +2 2 +3 3 +4 NULL +DROP TABLE t1,t2; +CREATE TABLE t1 ( +f1 varchar(16) collate latin1_swedish_ci PRIMARY KEY, +f2 varchar(16) collate latin1_swedish_ci +); +CREATE TABLE t2 ( +f1 varchar(16) collate latin1_swedish_ci PRIMARY KEY, +f3 varchar(16) collate latin1_swedish_ci +); +INSERT INTO t1 VALUES ('bla','blah'); +INSERT INTO t2 VALUES ('bla','sheep'); +SELECT * FROM t1 JOIN t2 USING(f1) WHERE f1='Bla'; +f1 f2 f3 +bla blah sheep +SELECT * FROM t1 LEFT JOIN t2 USING(f1) WHERE f1='bla'; +f1 f2 f3 +bla blah sheep +SELECT * FROM t1 LEFT JOIN t2 USING(f1) WHERE f1='Bla'; +f1 f2 f3 +bla blah sheep +DROP TABLE t1,t2; +CREATE TABLE t1 (id int PRIMARY KEY, a varchar(8)); +CREATE TABLE t2 (id int NOT NULL, b int NOT NULL, INDEX idx(id)); +INSERT INTO t1 VALUES +(1,'aaaaaaa'), (5,'eeeeeee'), (4,'ddddddd'), (2,'bbbbbbb'), (3,'ccccccc'); +INSERT INTO t2 VALUES +(3,10), (2,20), (5,30), (3,20), (5,10), (3,40), (3,30), (2,10), (2,40); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN +SELECT t1.id, a FROM t1 LEFT JOIN t2 ON t1.id=t2.id WHERE t2.b IS NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +2 SIMPLE t2 NULL ALL idx NULL NULL NULL 9 11.11 Using where; Not exists; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,`test`.`t1`.`a` AS `a` from `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`id` = `test`.`t1`.`id`)) where (`test`.`t2`.`b` is null) +flush status; +SELECT t1.id, a FROM t1 LEFT JOIN t2 ON t1.id=t2.id WHERE t2.b IS NULL; +id a +1 aaaaaaa +4 ddddddd +show status like 'Handler_read%'; +Variable_name Value +Handler_read_first 2 +Handler_read_key 2 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 16 +DROP TABLE t1,t2; +CREATE TABLE t1 (c int PRIMARY KEY, e int NOT NULL); +INSERT INTO t1 VALUES (1,0), (2,1); +CREATE TABLE t2 (d int PRIMARY KEY); +INSERT INTO t2 VALUES (1), (2), (3); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN SELECT * FROM t1 LEFT JOIN t2 ON e<>0 WHERE c=1 AND d IS NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +1 SIMPLE t2 NULL index NULL PRIMARY 4 NULL 3 33.33 Using where; Not exists; Using index +Warnings: +Note 1003 /* select#1 */ select '1' AS `c`,'0' AS `e`,`test`.`t2`.`d` AS `d` from `test`.`t1` left join `test`.`t2` on(('0' <> 0)) where ((`test`.`t2`.`d` is null)) +SELECT * FROM t1 LEFT JOIN t2 ON e<>0 WHERE c=1 AND d IS NULL; +c e d +1 0 NULL +SELECT * FROM t1 LEFT JOIN t2 ON e<>0 WHERE c=1 AND d<=>NULL; +c e d +1 0 NULL +DROP TABLE t1,t2; +# +# Bug#47650: using group by with rollup without indexes returns incorrect +# results with where +# +CREATE TABLE t1 ( a INT ); +INSERT INTO t1 VALUES (1); +CREATE TABLE t2 ( a INT, b INT ); +INSERT INTO t2 VALUES (1, 1),(1, 2),(1, 3),(2, 4),(2, 5); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN +SELECT t1.a, COUNT( t2.b ), SUM( t2.b ), MAX( t2.b ) +FROM t1 LEFT JOIN t2 USING( a ) +GROUP BY t1.a WITH ROLLUP; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using temporary; Using filesort +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 5 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,rollup_sum_switcher(count(`test`.`t2`.`b`)) AS `COUNT( t2.b )`,rollup_sum_switcher(sum(`test`.`t2`.`b`)) AS `SUM( t2.b )`,rollup_sum_switcher(max(`test`.`t2`.`b`)) AS `MAX( t2.b )` from `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`a` = `test`.`t1`.`a`)) where true group by `test`.`t1`.`a` with rollup +SELECT t1.a, COUNT( t2.b ), SUM( t2.b ), MAX( t2.b ) +FROM t1 LEFT JOIN t2 USING( a ) +GROUP BY t1.a WITH ROLLUP; +a COUNT( t2.b ) SUM( t2.b ) MAX( t2.b ) +1 3 6 3 +NULL 3 6 3 +EXPLAIN +SELECT t1.a, COUNT( t2.b ), SUM( t2.b ), MAX( t2.b ) +FROM t1 JOIN t2 USING( a ) +GROUP BY t1.a WITH ROLLUP; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using temporary; Using filesort +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 5 20.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,rollup_sum_switcher(count(`test`.`t2`.`b`)) AS `COUNT( t2.b )`,rollup_sum_switcher(sum(`test`.`t2`.`b`)) AS `SUM( t2.b )`,rollup_sum_switcher(max(`test`.`t2`.`b`)) AS `MAX( t2.b )` from `test`.`t1` join `test`.`t2` where (`test`.`t2`.`a` = `test`.`t1`.`a`) group by `test`.`t1`.`a` with rollup +SELECT t1.a, COUNT( t2.b ), SUM( t2.b ), MAX( t2.b ) +FROM t1 JOIN t2 USING( a ) +GROUP BY t1.a WITH ROLLUP; +a COUNT( t2.b ) SUM( t2.b ) MAX( t2.b ) +1 3 6 3 +NULL 3 6 3 +DROP TABLE t1, t2; +# +# Bug#51598 Inconsistent behaviour with a COALESCE statement inside an IN comparison +# +CREATE TABLE t1(f1 INT, f2 INT, f3 INT); +INSERT INTO t1 VALUES (1, NULL, 3); +CREATE TABLE t2(f1 INT, f2 INT); +INSERT INTO t2 VALUES (2, 1); +EXPLAIN SELECT * FROM t1 LEFT JOIN t2 ON t1.f2 = t2.f2 +WHERE (COALESCE(t1.f1, t2.f1), f3) IN ((1, 3), (2, 2)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`f1` AS `f1`,`test`.`t1`.`f2` AS `f2`,`test`.`t1`.`f3` AS `f3`,`test`.`t2`.`f1` AS `f1`,`test`.`t2`.`f2` AS `f2` from `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`f2` = `test`.`t1`.`f2`)) where ((coalesce(`test`.`t1`.`f1`,`test`.`t2`.`f1`),`test`.`t1`.`f3`) in ((1,3),(2,2))) +SELECT * FROM t1 LEFT JOIN t2 ON t1.f2 = t2.f2 +WHERE (COALESCE(t1.f1, t2.f1), f3) IN ((1, 3), (2, 2)); +f1 f2 f3 f1 f2 +1 NULL 3 NULL NULL +DROP TABLE t1, t2; +# +# Bug#52357: Assertion failed: join->best_read in greedy_search +# optimizer_search_depth=0 +# +CREATE TABLE t1( a INT ); +INSERT INTO t1 VALUES (1),(2); +SET optimizer_search_depth = 0; +# Should not core dump on query preparation +EXPLAIN +SELECT 1 +FROM t1 tt3 LEFT OUTER JOIN t1 tt4 ON 1 +LEFT OUTER JOIN t1 tt5 ON 1 +LEFT OUTER JOIN t1 tt6 ON 1 +LEFT OUTER JOIN t1 tt7 ON 1 +LEFT OUTER JOIN t1 tt8 ON 1 +RIGHT OUTER JOIN t1 tt2 ON 1 +RIGHT OUTER JOIN t1 tt1 ON 1 +STRAIGHT_JOIN t1 tt9 ON 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE tt1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 SIMPLE tt2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +2 SIMPLE tt3 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +2 SIMPLE tt4 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +2 SIMPLE tt5 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +2 SIMPLE tt6 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +2 SIMPLE tt7 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +2 SIMPLE tt8 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +2 SIMPLE tt9 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` `tt1` left join (`test`.`t1` `tt2` left join (`test`.`t1` `tt3` left join `test`.`t1` `tt4` on(true) left join `test`.`t1` `tt5` on(true) left join `test`.`t1` `tt6` on(true) left join `test`.`t1` `tt7` on(true) left join `test`.`t1` `tt8` on(true)) on(true)) on(true) straight_join `test`.`t1` `tt9` where true +SET optimizer_search_depth = DEFAULT; +DROP TABLE t1; +# +# Bug#46091 STRAIGHT_JOIN + RIGHT JOIN returns different result +# +CREATE TABLE t1 (f1 INT NOT NULL); +INSERT INTO t1 VALUES (9),(0); +CREATE TABLE t2 (f1 INT NOT NULL); +INSERT INTO t2 VALUES +(5),(3),(0),(3),(1),(0),(1),(7),(1),(0),(0),(8),(4),(9),(0),(2),(0),(8),(5),(1); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +SELECT STRAIGHT_JOIN COUNT(*) FROM t1 ta1 +RIGHT JOIN t2 ta2 JOIN t2 ta3 ON ta2.f1 ON ta3.f1; +COUNT(*) +476 +EXPLAIN SELECT STRAIGHT_JOIN COUNT(*) FROM t1 ta1 +RIGHT JOIN t2 ta2 JOIN t2 ta3 ON ta2.f1 ON ta3.f1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 20 90.00 Parallel execute (1 workers) +2 SIMPLE ta2 NULL ALL NULL NULL NULL NULL 20 90.00 Using where +2 SIMPLE ta3 NULL ALL NULL NULL NULL NULL 20 100.00 Using join buffer (hash join) +2 SIMPLE ta1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select straight_join count(0) AS `COUNT(*)` from `test`.`t2` `ta2` join `test`.`t2` `ta3` left join `test`.`t1` `ta1` on((0 <> `test`.`ta3`.`f1`)) where (0 <> `test`.`ta2`.`f1`) +DROP TABLE t1, t2; +# +# Bug#48971 Segfault in add_found_match_trig_cond () at sql_select.cc:5990 +# +CREATE TABLE t1(f1 INT, PRIMARY KEY (f1)); +INSERT INTO t1 VALUES (1),(2); +EXPLAIN SELECT STRAIGHT_JOIN jt1.f1 FROM t1 AS jt1 +LEFT JOIN t1 AS jt2 +RIGHT JOIN t1 AS jt3 +JOIN t1 AS jt4 ON 1 +LEFT JOIN t1 AS jt5 ON 1 +ON 1 +RIGHT JOIN t1 AS jt6 ON jt6.f1 +ON 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE jt1 NULL index NULL PRIMARY 4 NULL 2 100.00 Using index +2 SIMPLE jt6 NULL index NULL PRIMARY 4 NULL 2 100.00 Using where; Using index; Using join buffer (hash join) +2 SIMPLE jt3 NULL index NULL PRIMARY 4 NULL 2 100.00 Using where; Using index; Using join buffer (hash join) +2 SIMPLE jt4 NULL index NULL PRIMARY 4 NULL 2 100.00 Using index; Using join buffer (hash join) +2 SIMPLE jt5 NULL index NULL PRIMARY 4 NULL 2 100.00 Using where; Using index; Using join buffer (hash join) +2 SIMPLE jt2 NULL index NULL PRIMARY 4 NULL 2 100.00 Using where; Using index; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select straight_join `test`.`jt1`.`f1` AS `f1` from `test`.`t1` `jt1` left join (`test`.`t1` `jt6` left join (`test`.`t1` `jt3` join `test`.`t1` `jt4` left join `test`.`t1` `jt5` on(true) left join `test`.`t1` `jt2` on(true)) on(((0 <> `test`.`jt6`.`f1`)))) on(true) where true +EXPLAIN SELECT STRAIGHT_JOIN jt1.f1 FROM t1 AS jt1 +RIGHT JOIN t1 AS jt2 +RIGHT JOIN t1 AS jt3 +JOIN t1 AS jt4 ON 1 +LEFT JOIN t1 AS jt5 ON 1 +ON 1 +RIGHT JOIN t1 AS jt6 ON jt6.f1 +ON 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE jt6 NULL index NULL PRIMARY 4 NULL 2 100.00 Using index +2 SIMPLE jt3 NULL index NULL PRIMARY 4 NULL 2 100.00 Using where; Using index; Using join buffer (hash join) +2 SIMPLE jt4 NULL index NULL PRIMARY 4 NULL 2 100.00 Using index; Using join buffer (hash join) +2 SIMPLE jt5 NULL index NULL PRIMARY 4 NULL 2 100.00 Using where; Using index; Using join buffer (hash join) +2 SIMPLE jt2 NULL index NULL PRIMARY 4 NULL 2 100.00 Using where; Using index; Using join buffer (hash join) +2 SIMPLE jt1 NULL index NULL PRIMARY 4 NULL 2 100.00 Using where; Using index; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select straight_join `test`.`jt1`.`f1` AS `f1` from `test`.`t1` `jt6` left join (`test`.`t1` `jt3` join `test`.`t1` `jt4` left join `test`.`t1` `jt5` on(true) left join `test`.`t1` `jt2` on(true)) on(((0 <> `test`.`jt6`.`f1`))) left join `test`.`t1` `jt1` on(true) where true +DROP TABLE t1; +# +# Bug#57688 Assertion `!table || (!table->write_set || bitmap_is_set(table->write_set, field +# +CREATE TABLE t1 (f1 INT NOT NULL, PRIMARY KEY (f1)); +CREATE TABLE t2 (f1 INT NOT NULL, f2 INT NOT NULL, PRIMARY KEY (f1, f2)); +INSERT INTO t1 VALUES (4); +INSERT INTO t2 VALUES (3, 3); +INSERT INTO t2 VALUES (7, 7); +EXPLAIN SELECT * FROM t1 LEFT JOIN t2 ON t2.f1 = t1.f1 +WHERE t1.f1 = 4 +GROUP BY t2.f1, t2.f2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 Using index; Using temporary +1 SIMPLE t2 NULL ref PRIMARY PRIMARY 4 const 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select '4' AS `f1`,`test`.`t2`.`f1` AS `f1`,`test`.`t2`.`f2` AS `f2` from `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`f1` = 4)) where true group by `test`.`t2`.`f1`,`test`.`t2`.`f2` +SELECT * FROM t1 LEFT JOIN t2 ON t2.f1 = t1.f1 +WHERE t1.f1 = 4 +GROUP BY t2.f1, t2.f2; +f1 f1 f2 +4 NULL NULL +EXPLAIN SELECT * FROM t1 LEFT JOIN t2 ON t2.f1 = t1.f1 +WHERE t1.f1 = 4 AND t2.f1 IS NOT NULL AND t2.f2 IS NOT NULL +GROUP BY t2.f1, t2.f2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 Using index +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 50.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 Using index +2 SIMPLE t2 NULL ref PRIMARY PRIMARY 4 const 1 50.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select '4' AS `f1`,`test`.`t2`.`f1` AS `f1`,`test`.`t2`.`f2` AS `f2` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`f1` = 4) and (`test`.`t2`.`f2` is not null)) group by `test`.`t2`.`f1`,`test`.`t2`.`f2` +SELECT * FROM t1 LEFT JOIN t2 ON t2.f1 = t1.f1 +WHERE t1.f1 = 4 AND t2.f1 IS NOT NULL AND t2.f2 IS NOT NULL +GROUP BY t2.f1, t2.f2; +f1 f1 f2 +DROP TABLE t1,t2; +# +# Bug#57034 incorrect OUTER JOIN result when joined on unique key +# +CREATE TABLE t1 (pk INT PRIMARY KEY, +col_int INT, +col_int_unique INT UNIQUE KEY); +INSERT INTO t1 VALUES (1,NULL,2), (2,0,0); +CREATE TABLE t2 (pk INT PRIMARY KEY, +col_int INT, +col_int_unique INT UNIQUE KEY); +INSERT INTO t2 VALUES (1,0,1), (2,0,2); +EXPLAIN +SELECT * FROM t1 LEFT JOIN t2 +ON t1.col_int_unique = t2.col_int_unique AND t1.col_int = t2.col_int +WHERE t1.pk=1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +1 SIMPLE t2 NULL const col_int_unique col_int_unique 5 const 1 100.00 Impossible ON condition +Warnings: +Note 1003 /* select#1 */ select '1' AS `pk`,NULL AS `col_int`,'2' AS `col_int_unique`,NULL AS `pk`,NULL AS `col_int`,NULL AS `col_int_unique` from `test`.`t1` left join `test`.`t2` on((multiple equal('2', NULL) and multiple equal(NULL, NULL))) where true +SELECT * FROM t1 LEFT JOIN t2 +ON t1.col_int_unique = t2.col_int_unique AND t1.col_int = t2.col_int +WHERE t1.pk=1; +pk col_int col_int_unique pk col_int col_int_unique +1 NULL 2 NULL NULL NULL +DROP TABLE t1,t2; +# +# Bug#48046 Server incorrectly processing JOINs on NULL values +# +CREATE TABLE `BB` ( +`pk` int(11) NOT NULL AUTO_INCREMENT, +`time_key` time DEFAULT NULL, +`varchar_key` varchar(1) DEFAULT NULL, +`varchar_nokey` varchar(1) DEFAULT NULL, +PRIMARY KEY (`pk`), +KEY `time_key` (`time_key`), +KEY `varchar_key` (`varchar_key`) +) ENGINE=MyISAM AUTO_INCREMENT=11 DEFAULT CHARSET=latin1; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO `BB` VALUES (10,'18:27:58',NULL,NULL); +SELECT table1.time_key AS field1, table2.pk +FROM BB table1 LEFT JOIN BB table2 +ON table2.varchar_nokey = table1.varchar_key +HAVING field1; +field1 pk +18:27:58 NULL +DROP TABLE BB; +# +# Bug#49600 Server incorrectly processing RIGHT JOIN with +# constant WHERE clause and no index +# +CREATE TABLE `BB` ( +`col_datetime_key` datetime DEFAULT NULL, +`col_varchar_key` varchar(1) DEFAULT NULL, +`col_varchar_nokey` varchar(1) DEFAULT NULL, +KEY `col_datetime_key` (`col_datetime_key`), +KEY `col_varchar_key` (`col_varchar_key`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1; +INSERT INTO `BB` VALUES ('1900-01-01 00:00:00',NULL,NULL); +SELECT table1.col_datetime_key +FROM BB table1 RIGHT JOIN BB table2 +ON table2 .col_varchar_nokey = table1.col_varchar_key +WHERE 7; +col_datetime_key +NULL +ALTER TABLE BB DISABLE KEYS; +SELECT table1.col_datetime_key +FROM BB table1 RIGHT JOIN BB table2 +ON table2 .col_varchar_nokey = table1.col_varchar_key +WHERE 7; +col_datetime_key +NULL +DROP TABLE BB; +# +# Bug#58490: Incorrect result in multi level OUTER JOIN +# in combination with IS NULL +# +CREATE TABLE t1 (i INT NOT NULL); +INSERT INTO t1 VALUES (0), (2),(3),(4); +CREATE TABLE t2 (i INT NOT NULL); +INSERT INTO t2 VALUES (0),(1), (3),(4); +CREATE TABLE t3 (i INT NOT NULL); +INSERT INTO t3 VALUES (0),(1),(2), (4); +CREATE TABLE t4 (i INT NOT NULL); +INSERT INTO t4 VALUES (0),(1),(2),(3) ; +SELECT * FROM +t1 LEFT JOIN +( t2 LEFT JOIN +( t3 LEFT JOIN +t4 +ON t4.i = t3.i +) +ON t3.i = t2.i +) +ON t2.i = t1.i +; +i i i i +0 0 0 0 +2 NULL NULL NULL +3 3 NULL NULL +4 4 4 NULL +SELECT * FROM +t1 LEFT JOIN +( t2 LEFT JOIN +( t3 LEFT JOIN +t4 +ON t4.i = t3.i +) +ON t3.i = t2.i +) +ON t2.i = t1.i +WHERE t4.i IS NULL; +i i i i +2 NULL NULL NULL +3 3 NULL NULL +4 4 4 NULL +SELECT * FROM +t1 LEFT JOIN +( ( t2 LEFT JOIN +t3 +ON t3.i = t2.i +) +) +ON t2.i = t1.i +WHERE t3.i IS NULL; +i i i +2 NULL NULL +3 3 NULL +SELECT * FROM +t1 LEFT JOIN +( ( t2 LEFT JOIN +t3 +ON t3.i = t2.i +) +JOIN t4 +ON t4.i=t2.i +) +ON t2.i = t1.i +WHERE t3.i IS NULL; +i i i i +2 NULL NULL NULL +3 3 NULL 3 +4 NULL NULL NULL +SELECT * FROM +t1 LEFT JOIN +( ( t2 LEFT JOIN +t3 +ON t3.i = t2.i +) +JOIN (t4 AS t4a JOIN t4 AS t4b ON t4a.i=t4b.i) +ON t4a.i=t2.i +) +ON t2.i = t1.i +WHERE t3.i IS NULL; +i i i i i +2 NULL NULL NULL NULL +3 3 NULL 3 3 +4 NULL NULL NULL NULL +SELECT * FROM +t1 LEFT JOIN +( ( t2 LEFT JOIN +t3 +ON t3.i = t2.i +) +JOIN (t4 AS t4a, t4 AS t4b) +ON t4a.i=t2.i +) +ON t2.i = t1.i +WHERE t3.i IS NULL; +i i i i i +2 NULL NULL NULL NULL +3 3 NULL 3 0 +3 3 NULL 3 1 +3 3 NULL 3 2 +3 3 NULL 3 3 +4 NULL NULL NULL NULL +DROP TABLE t1,t2,t3,t4; +# +# Bug#49322(Duplicate): Server is adding extra NULL row +# on processing a WHERE clause +# +CREATE TABLE h (pk INT NOT NULL, col_int_key INT); +INSERT INTO h VALUES (1,NULL),(4,2),(5,2),(3,4),(2,8); +CREATE TABLE m (pk INT NOT NULL, col_int_key INT); +INSERT INTO m VALUES (1,2),(2,7),(3,5),(4,7),(5,5),(6,NULL),(7,NULL),(8,9); +CREATE TABLE k (pk INT NOT NULL, col_int_key INT); +INSERT INTO k VALUES (1,9),(2,2),(3,5),(4,2),(5,7),(6,0),(7,5); +SELECT TABLE1.pk FROM k TABLE1 +RIGHT JOIN h TABLE2 ON TABLE1.col_int_key=TABLE2.col_int_key +RIGHT JOIN m TABLE4 ON TABLE2.col_int_key=TABLE4.col_int_key; +pk +2 +2 +4 +4 +NULL +NULL +NULL +NULL +NULL +NULL +NULL +SELECT TABLE1.pk FROM k TABLE1 +RIGHT JOIN h TABLE2 ON TABLE1.col_int_key=TABLE2.col_int_key +RIGHT JOIN m TABLE4 ON TABLE2.col_int_key=TABLE4.col_int_key +WHERE TABLE1.pk IS NULL; +pk +NULL +NULL +NULL +NULL +NULL +NULL +NULL +DROP TABLE h,m,k; +# +# Bug #11765810 58813: SERVER THREAD HANGS WHEN JOIN + WHERE + GROUP BY +# IS EXECUTED TWICE FROM P +# +CREATE TABLE t1 ( a INT ) ENGINE = MYISAM; +INSERT INTO t1 VALUES (1); +PREPARE prep_stmt FROM ' + SELECT 1 AS f FROM t1 + LEFT JOIN t1 t2 + RIGHT JOIN t1 t3 + JOIN t1 t4 + ON 1 + ON 1 + ON 1 + GROUP BY f'; +EXECUTE prep_stmt; +f +1 +EXECUTE prep_stmt; +f +1 +DROP TABLE t1; +End of 5.1 tests +# +# Bug#54235 Extra rows with join_cache_level=4,6,8 and two LEFT JOIN +# +CREATE TABLE t1 (a int); +CREATE TABLE t2 (a int); +CREATE TABLE t3 (a int); +CREATE TABLE t4 (a int); +INSERT INTO t1 VALUES (null),(null); +explain SELECT t1.a FROM t1 LEFT JOIN (t2 LEFT JOIN t3 ON t2.a) +ON 0 WHERE t1.a OR t3.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` left join (`test`.`t2` left join `test`.`t3` on((0 <> `test`.`t2`.`a`))) on(false) where ((0 <> `test`.`t1`.`a`) or (0 <> `test`.`t3`.`a`)) +SELECT t1.a FROM t1 LEFT JOIN (t2 LEFT JOIN t3 ON t2.a) +ON 0 WHERE t1.a OR t3.a; +a +explain SELECT t1.a FROM t1 LEFT JOIN +(t2 LEFT JOIN (t3 LEFT JOIN t4 ON 1) ON t2.a) +ON 0 WHERE t1.a OR t4.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` left join (`test`.`t2` left join (`test`.`t3` left join `test`.`t4` on(true)) on((0 <> `test`.`t2`.`a`))) on(false) where ((0 <> `test`.`t1`.`a`) or (0 <> `test`.`t4`.`a`)) +SELECT t1.a FROM t1 LEFT JOIN +(t2 LEFT JOIN (t3 LEFT JOIN t4 ON 1) ON t2.a) +ON 0 WHERE t1.a OR t4.a; +a +DROP TABLE t1,t2,t3,t4; +# +# Bug#56254 Assertion tab->ref.use_count fails in +# join_read_key_unlock_row() on 4-way JOIN +# +CREATE TABLE t1 ( +pk INT NOT NULL, +col_int_key INT, +col_int INT, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +); +INSERT INTO t1 VALUES (6, -448724992, NULL); +CREATE TABLE t2 ( +col_int INT, +col_varchar_10 VARCHAR(10) +); +INSERT INTO t2 VALUES (6,'afasdkiyum'); +CREATE TABLE t3 ( +col_varchar_10 VARCHAR(10), +col_int INT +); +CREATE TABLE t4 ( +pk INT NOT NULL, +PRIMARY KEY (pk) +); +INSERT INTO t4 VALUES (1); +INSERT INTO t4 VALUES (2); +SELECT t1.col_int +FROM t1 +LEFT JOIN t2 +LEFT JOIN t3 +JOIN t4 +ON t3.col_int = t4.pk +ON t2.col_varchar_10 = t3.col_varchar_10 +ON t2.col_int = t1.pk +WHERE t1.col_int_key IS NULL OR t4.pk < t3.col_int; +col_int +EXPLAIN FORMAT=tree SELECT t1.col_int +FROM t1 +LEFT JOIN t2 +LEFT JOIN t3 +JOIN t4 +ON t3.col_int = t4.pk +ON t2.col_varchar_10 = t3.col_varchar_10 +ON t2.col_int = t1.pk +WHERE t1.col_int_key IS NULL OR t4.pk < t3.col_int; +EXPLAIN +-> Parallel scan on + -> Filter: (found_match(t3..t4), ((t1.col_int_key is null) or (t4.pk < t3.col_int)), true) (cost=0.70 rows=1) + -> Nested loop left join (cost=0.70 rows=1) + -> PQblock scan on t1 (cost=0.35 rows=1) + -> Nested loop left join (cost=0.70 rows=1) + -> Filter: (t2.col_int = t1.pk) (cost=0.35 rows=1) + -> Table scan on t2 (cost=0.35 rows=1) + -> Nested loop inner join (cost=0.70 rows=1) + -> Filter: (t3.col_varchar_10 = t2.col_varchar_10) (cost=0.35 rows=1) + -> Table scan on t3 (cost=0.35 rows=1) + -> Single-row index lookup on t4 using PRIMARY (pk=t3.col_int) (cost=0.35 rows=1) + +DROP TABLE t1,t2,t3,t4; + +# BUG#12567331 - INFINITE LOOP WHEN RESOLVING AN ALIASED COLUMN +# USED IN GROUP BY + +CREATE TABLE t1 (pk int(11)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +PREPARE prep_stmt_9846 FROM ' +SELECT alias1.pk AS field1 FROM +t1 AS alias1 +LEFT JOIN +( + t1 AS alias2 + RIGHT JOIN + ( + t1 AS alias3 + JOIN t1 AS alias4 + ON 1 + ) + ON 1 +) +ON 1 +GROUP BY field1'; +execute prep_stmt_9846; +field1 +execute prep_stmt_9846; +field1 +deallocate prepare prep_stmt_9846; +drop table t1; +# +# Bug#13040136 - ASSERT IN PLAN_CHANGE_WATCHDOG::~PLAN_CHANGE_WATCHDOG() +# +CREATE TABLE t1 ( +col_varchar_10 VARCHAR(10), +col_int_key INTEGER, +col_varchar_10_key VARCHAR(10), +pk INTEGER NOT NULL, +PRIMARY KEY (pk), +KEY (col_int_key), +KEY (col_varchar_10_key) +); +INSERT INTO t1 VALUES ('q',NULL,'o',1); +CREATE TABLE t2 ( +pk INTEGER NOT NULL AUTO_INCREMENT, +col_varchar_10_key VARCHAR(10), +col_int_key INTEGER, +col_varchar_10 VARCHAR(10), +PRIMARY KEY (pk), +KEY (col_varchar_10_key), +KEY col_int_key (col_int_key) +); +INSERT INTO t2 VALUES +(1,'r',NULL,'would'),(2,'tell',-655032320,'t'), +(3,'d',9,'a'),(4,'gvafasdkiy',6,'ugvafasdki'), +(5,'that\'s',NULL,'she'),(6,'bwftwugvaf',7,'cbwftwugva'), +(7,'f',-700055552,'mkacbwftwu'),(8,'a',9,'be'), +(9,'d',NULL,'u'),(10,'ckiixcsxmk',NULL,'o'); +SELECT DISTINCT t2.col_int_key +FROM +t1 +LEFT JOIN t2 +ON t1.col_varchar_10 = t2.col_varchar_10_key +WHERE t2.pk +ORDER BY t2.col_int_key; +col_int_key +DROP TABLE t1,t2; +# +# Bug#13068506 - QUERY WITH GROUP BY ON NON-AGGR COLUMN RETURNS WRONG RESULT +# +CREATE TABLE t1 (i1 int); +INSERT INTO t1 VALUES (100), (101); +CREATE TABLE t2 (i2 int, i3 int); +INSERT INTO t2 VALUES (20,1),(10,2); +CREATE TABLE t3 (i4 int(11)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t3 VALUES (1),(2); + +SELECT ( +SELECT MAX( t2.i2 ) +FROM t3 RIGHT JOIN t2 ON ( t2.i3 = 2 ) +WHERE t2.i3 <> t1.i1 +) AS field1 +FROM t1;; +field1 +20 +20 + +SELECT ( +SELECT MAX( t2.i2 ) +FROM t3 RIGHT JOIN t2 ON ( t2.i3 = 2 ) +WHERE t2.i3 <> t1.i1 +) AS field1 +FROM t1 GROUP BY field1;; +field1 +20 + +drop table t1,t2,t3; +# Bug#11766384 - 59487: WRONG RESULT WITH STRAIGHT_JOIN AND RIGHT JOIN +CREATE TABLE t1 ( +pk int(11) NOT NULL, +col_varchar_10_latin1_key varchar(10) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (1,'1'); +CREATE TABLE t2 ( +pk int(11) NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (1); +CREATE TABLE t3 ( +pk int(11) NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t3 VALUES (1); +CREATE TABLE t4 ( +pk int(11) NOT NULL, +col_int int(11) DEFAULT NULL, +col_int_key int(11) DEFAULT NULL, +col_varchar_10_latin1_key varchar(10) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t4 VALUES (1,1,1,'1'); +CREATE TABLE t5 ( +col_int int(11) DEFAULT NULL, +col_varchar_10_utf8_key varchar(10) CHARACTER SET utf8 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t5 VALUES (1,'1'); +CREATE TABLE t6 ( +col_int_key int(11) DEFAULT NULL, +col_varchar_10_latin1_key varchar(10) DEFAULT NULL, +pk int(11) NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t6 VALUES (1,'1',1); +SELECT STRAIGHT_JOIN t6a.pk, t2.pk +FROM +t6 AS t6a +LEFT JOIN +( +t2 +RIGHT JOIN +( +( +t1 +LEFT JOIN +( +t4 +JOIN +t3 +ON t4.col_int +) +ON t4.col_int_key = t1.pk +) +LEFT JOIN +( +t5 +JOIN +t6 AS t6b +ON t5.col_varchar_10_utf8_key = t6b.col_varchar_10_latin1_key +) +ON t1.pk = t5.col_int +) +ON t4.col_varchar_10_latin1_key = t1.col_varchar_10_latin1_key +AND t5.col_varchar_10_utf8_key = 0 +) +ON t6a.pk IS TRUE +WHERE t6b.col_int_key IS TRUE +; +pk pk +1 NULL +EXPLAIN SELECT STRAIGHT_JOIN t6a.pk, t2.pk +FROM +t6 AS t6a +LEFT JOIN +( +t2 +RIGHT JOIN +( +( +t1 +LEFT JOIN +( +t4 +JOIN +t3 +ON t4.col_int +) +ON t4.col_int_key = t1.pk +) +LEFT JOIN +( +t5 +JOIN +t6 AS t6b +ON t5.col_varchar_10_utf8_key = t6b.col_varchar_10_latin1_key +) +ON t1.pk = t5.col_int +) +ON t4.col_varchar_10_latin1_key = t1.col_varchar_10_latin1_key +AND t5.col_varchar_10_utf8_key = 0 +) +ON t6a.pk IS TRUE +WHERE t6b.col_int_key IS TRUE +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t6a NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using join buffer (hash join) +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using join buffer (hash join) +2 SIMPLE t5 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t6b NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select straight_join `test`.`t6a`.`pk` AS `pk`,`test`.`t2`.`pk` AS `pk` from `test`.`t6` `t6a` join `test`.`t1` left join (`test`.`t4` join `test`.`t3`) on(((`test`.`t4`.`col_int_key` = `test`.`t1`.`pk`) and (0 <> `test`.`t4`.`col_int`))) join `test`.`t5` join `test`.`t6` `t6b` left join `test`.`t2` on(((`test`.`t4`.`col_varchar_10_latin1_key` = `test`.`t1`.`col_varchar_10_latin1_key`) and (`test`.`t5`.`col_varchar_10_utf8_key` = 0))) where ((`test`.`t5`.`col_int` = `test`.`t1`.`pk`) and ((0 <> `test`.`t6b`.`col_int_key`) is true) and (`test`.`t5`.`col_varchar_10_utf8_key` = `test`.`t6b`.`col_varchar_10_latin1_key`) and ((0 <> `test`.`t6a`.`pk`) is true)) +SELECT t6a.pk, t2.pk +FROM +t6 AS t6a +LEFT JOIN +( +t2 +RIGHT JOIN +( +( +t1 +LEFT JOIN +( +t4 +JOIN +t3 +ON t4.col_int +) +ON t4.col_int_key = t1.pk +) +LEFT JOIN +( +t5 +JOIN +t6 AS t6b +ON t5.col_varchar_10_utf8_key = t6b.col_varchar_10_latin1_key +) +ON t1.pk = t5.col_int +) +ON t4.col_varchar_10_latin1_key = t1.col_varchar_10_latin1_key +AND t5.col_varchar_10_utf8_key = 0 +) +ON t6a.pk IS TRUE +WHERE t6b.col_int_key IS TRUE +; +pk pk +1 NULL +EXPLAIN SELECT t6a.pk, t2.pk +FROM +t6 AS t6a +LEFT JOIN +( +t2 +RIGHT JOIN +( +( +t1 +LEFT JOIN +( +t4 +JOIN +t3 +ON t4.col_int +) +ON t4.col_int_key = t1.pk +) +LEFT JOIN +( +t5 +JOIN +t6 AS t6b +ON t5.col_varchar_10_utf8_key = t6b.col_varchar_10_latin1_key +) +ON t1.pk = t5.col_int +) +ON t4.col_varchar_10_latin1_key = t1.col_varchar_10_latin1_key +AND t5.col_varchar_10_utf8_key = 0 +) +ON t6a.pk IS TRUE +WHERE t6b.col_int_key IS TRUE +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t6a NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using join buffer (hash join) +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using join buffer (hash join) +2 SIMPLE t5 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t6b NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t6a`.`pk` AS `pk`,`test`.`t2`.`pk` AS `pk` from `test`.`t6` `t6a` join `test`.`t1` left join (`test`.`t4` join `test`.`t3`) on(((`test`.`t4`.`col_int_key` = `test`.`t1`.`pk`) and (0 <> `test`.`t4`.`col_int`))) join `test`.`t5` join `test`.`t6` `t6b` left join `test`.`t2` on(((`test`.`t4`.`col_varchar_10_latin1_key` = `test`.`t1`.`col_varchar_10_latin1_key`) and (`test`.`t5`.`col_varchar_10_utf8_key` = 0))) where ((`test`.`t5`.`col_int` = `test`.`t1`.`pk`) and ((0 <> `test`.`t6b`.`col_int_key`) is true) and (`test`.`t5`.`col_varchar_10_utf8_key` = `test`.`t6b`.`col_varchar_10_latin1_key`) and ((0 <> `test`.`t6a`.`pk`) is true)) +EXPLAIN SELECT * FROM t5 LEFT JOIN t6 ON t5.col_int=1000 +WHERE t6.col_int_key IS TRUE; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t5 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 SIMPLE t6 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t5`.`col_int` AS `col_int`,`test`.`t5`.`col_varchar_10_utf8_key` AS `col_varchar_10_utf8_key`,`test`.`t6`.`col_int_key` AS `col_int_key`,`test`.`t6`.`col_varchar_10_latin1_key` AS `col_varchar_10_latin1_key`,`test`.`t6`.`pk` AS `pk` from `test`.`t5` join `test`.`t6` where ((`test`.`t5`.`col_int` = 1000) and ((0 <> `test`.`t6`.`col_int_key`) is true)) +EXPLAIN SELECT * FROM t5 LEFT JOIN t6 ON t5.col_int=1000 +WHERE t6.col_int_key IS NOT TRUE; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t5 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t6 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t5`.`col_int` AS `col_int`,`test`.`t5`.`col_varchar_10_utf8_key` AS `col_varchar_10_utf8_key`,`test`.`t6`.`col_int_key` AS `col_int_key`,`test`.`t6`.`col_varchar_10_latin1_key` AS `col_varchar_10_latin1_key`,`test`.`t6`.`pk` AS `pk` from `test`.`t5` left join `test`.`t6` on((`test`.`t5`.`col_int` = 1000)) where ((0 <> `test`.`t6`.`col_int_key`) is not true) +drop table t1,t2,t3,t4,t5,t6; +# +# Verify that the "not exists" optimization works. +# +CREATE TABLE t1(a INT); +CREATE TABLE t2(a INT NOT NULL); +INSERT INTO t1 VALUES(1),(2); +INSERT INTO t2 VALUES(1),(2); +EXPLAIN SELECT * FROM t1 LEFT JOIN t2 ON t1.a=t2.a WHERE t2.a IS NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Not exists; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a` from `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`a` = `test`.`t1`.`a`)) where (`test`.`t2`.`a` is null) +FLUSH STATUS; +SELECT * FROM t1 LEFT JOIN t2 ON t1.a=t2.a WHERE t2.a IS NULL; +a a +SHOW STATUS LIKE 'HANDLER_READ%'; +Variable_name Value +Handler_read_first 2 +Handler_read_key 2 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 6 +DROP TABLE t1,t2; +# +# Bug#13464334 SAME QUERY PRODUCES DIFFERENT RESULTS WHEN USED WITH AND +# WITHOUT UNION ALL +# +CREATE TABLE t1 (p1 INT PRIMARY KEY, a CHAR(1)); +CREATE TABLE t2 (p2 INT PRIMARY KEY, b CHAR(1)); +INSERT INTO t1 VALUES (1,'a'),(2,'b'),(3,'c'); +INSERT INTO t2 VALUES (1,'h'),(2,'i'),(3,'j'),(4,'k'); +CREATE VIEW v1 AS SELECT * FROM t1; +CREATE VIEW v2 AS SELECT * FROM t2; +(SELECT p1 FROM v2 LEFT JOIN v1 ON b = a WHERE p2 = 1 GROUP BY p1 ORDER BY p1) +UNION (SELECT NULL LIMIT 0); +p1 +NULL +DROP VIEW v1, v2; +DROP TABLE t1, t2; +# +# Bug#13980954 Missing data on left join + null value + where..in +# +CREATE TABLE t1 (ik INT, vc varchar(1)) charset utf8mb4 ENGINE=Innodb; +explain format=json SELECT straight_join t1.vc, t1.ik +FROM t1 JOIN t1 AS t2 ON t1.vc=t2.vc LEFT JOIN t1 AS t3 ON t1.vc=t3.vc; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.05" + }, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.10", + "prefix_cost": "0.35", + "data_read_per_join": "16" + }, + "used_columns": [ + "vc", + "ik" + ], + "query_block": { + "cost_info": { + "query_cost": "1.05" + }, + "nested_loop": [ + { + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.10", + "prefix_cost": "0.35", + "data_read_per_join": "16" + }, + "used_columns": [ + "ik", + "vc" + ] + } + }, + { + "table": { + "select_id": 2, + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.10", + "prefix_cost": "0.70", + "data_read_per_join": "16" + }, + "used_columns": [ + "vc" + ], + "attached_condition": "(`test`.`t2`.`vc` = `test`.`t1`.`vc`)" + } + }, + { + "table": { + "select_id": 2, + "table_name": "t3", + "access_type": "ALL", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.10", + "prefix_cost": "1.05", + "data_read_per_join": "16" + }, + "used_columns": [ + "vc" + ], + "attached_condition": "(is_not_null_compl(t3), (`test`.`t3`.`vc` = `test`.`t1`.`vc`), true)" + } + } + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select straight_join `test`.`t1`.`vc` AS `vc`,`test`.`t1`.`ik` AS `ik` from `test`.`t1` join `test`.`t1` `t2` left join `test`.`t1` `t3` on((`test`.`t3`.`vc` = `test`.`t1`.`vc`)) where (`test`.`t2`.`vc` = `test`.`t1`.`vc`) +SELECT straight_join t1.vc, t1.ik +FROM t1 JOIN t1 AS t2 ON t1.vc=t2.vc LEFT JOIN t1 AS t3 ON t1.vc=t3.vc; +vc ik +DROP TABLE t1; +# +# Bug #18345786 CRASH AROUND ST_JOIN_TABLE::AND_WITH_CONDITION +# +CREATE TABLE t1(a INT) ENGINE=INNODB; +SET @a:=(SELECT ROW(1, 2)= +ROW((SELECT 1 FROM t1 LEFT JOIN t1 t2 ON 1), 1)); +DROP TABLE t1; +# +# Coverage for "unique row not found" +# +create table t1(a int, unique key(a)) engine=innodb; +insert into t1 values(1); +explain select * from t1 left join t1 as t2 +on t2.a=12 +where t1.a=1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL const a a 5 const 1 100.00 Using index +1 SIMPLE t2 NULL const a a 5 const 0 0.00 unique row not found +Warnings: +Note 1003 /* select#1 */ select '1' AS `a`,NULL AS `a` from `test`.`t1` left join `test`.`t1` `t2` on(multiple equal(12, NULL)) where true +select * from t1 left join t1 as t2 +on t2.a=12 +where t1.a=1; +a a +1 NULL +drop table t1; +# +# Bug#18717059 MISSING ROWS ON NESTED JOIN WITH SUBQUERY +# WITH MYISAM OR MEMORY +# +CREATE TABLE t1 ( +pk INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +PRIMARY KEY (pk), +KEY col_varchar_key (col_varchar_key, col_int_key) +) ENGINE=MyISAM; +INSERT INTO t1 VALUES (23,4,'d'); +INSERT INTO t1 VALUES (24,8,'g'); +INSERT INTO t1 VALUES (25,NULL,'x'); +INSERT INTO t1 VALUES (26,NULL,'f'); +INSERT INTO t1 VALUES (27,0,'p'); +INSERT INTO t1 VALUES (28,NULL,'j'); +INSERT INTO t1 VALUES (29,8,'c'); +CREATE TABLE t2 ( +pk INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +PRIMARY KEY (pk) +) ENGINE=MyISAM; +SELECT 9 +FROM t1 AS table1 +RIGHT JOIN t1 AS table2 +ON table2.col_int_key = table1.col_int_key +AND table1.col_varchar_key = ( +SELECT subquery2_t2.col_varchar_key +FROM t2 +STRAIGHT_JOIN ( t2 AS subquery2_t2 +JOIN t1 AS subquery2_t3 +) ON ( subquery2_t3.col_int_key = subquery2_t2.pk ) +); +9 +9 +9 +9 +9 +9 +9 +9 +CREATE TABLE where_subselect_table AS +SELECT 9 +FROM t1 AS table1 +RIGHT JOIN t1 AS table2 +ON table2.col_int_key = table1.col_int_key +AND table1.col_varchar_key = ( +SELECT subquery2_t2.col_varchar_key +FROM t2 +STRAIGHT_JOIN ( t2 AS subquery2_t2 +JOIN t1 AS subquery2_t3 +) ON ( subquery2_t3.col_int_key = subquery2_t2.pk ) +); +set optimizer_switch='condition_fanout_filter=on'; +SELECT * +FROM where_subselect_table +WHERE (9) IN ( SELECT 9 +FROM t1 AS table1 +RIGHT JOIN t1 AS table2 +ON table2.col_int_key = table1.col_int_key +AND table1.col_varchar_key = ( +SELECT subquery2_t2.col_varchar_key +FROM t2 +STRAIGHT_JOIN ( t2 AS subquery2_t2 +JOIN t1 AS subquery2_t3 +) ON ( subquery2_t3.col_int_key = subquery2_t2.pk ) +) ) +/* TRANSFORM_OUTCOME_UNORDERED_MATCH */; +9 +9 +9 +9 +9 +9 +9 +9 +set optimizer_switch='condition_fanout_filter=off'; +SELECT * +FROM where_subselect_table +WHERE (9) IN ( SELECT 9 +FROM t1 AS table1 +RIGHT JOIN t1 AS table2 +ON table2.col_int_key = table1.col_int_key +AND table1.col_varchar_key = ( +SELECT subquery2_t2.col_varchar_key +FROM t2 +STRAIGHT_JOIN ( t2 AS subquery2_t2 +JOIN t1 AS subquery2_t3 +) ON ( subquery2_t3.col_int_key = subquery2_t2.pk ) +) ) +/* TRANSFORM_OUTCOME_UNORDERED_MATCH */; +9 +9 +9 +9 +9 +9 +9 +9 +DROP TABLE t1, t2, where_subselect_table; +# Bug#14358878 Wrong results on table left join view +CREATE TABLE a (id INTEGER); +CREATE TABLE b (id INTEGER); +CREATE ALGORITHM=MERGE VIEW vmerge AS SELECT 1 AS id, id AS b_id FROM b; +CREATE ALGORITHM=TEMPTABLE VIEW vmat AS SELECT 1 AS id, id AS b_id FROM b; +INSERT INTO a(id) VALUES (1); +SELECT * +FROM a LEFT JOIN vmerge AS v ON a.id = v.id; +id id b_id +1 NULL NULL +SELECT * +FROM a LEFT JOIN vmat AS v ON a.id = v.id; +id id b_id +1 NULL NULL +SELECT * +FROM a LEFT JOIN (SELECT 1 AS one, id FROM b) AS v ON a.id = v.id; +id one id +1 NULL NULL +SELECT * +FROM a LEFT JOIN (SELECT DISTINCT 1 AS one, id FROM b) AS v ON a.id = v.id; +id one id +1 NULL NULL +SELECT * +FROM a LEFT JOIN vmerge AS v ON a.id = v.id +UNION DISTINCT +SELECT * +FROM a LEFT JOIN vmerge AS v ON a.id = v.id; +id id b_id +1 NULL NULL +SELECT * +FROM a LEFT JOIN vmerge AS v ON a.id = v.id +UNION ALL +SELECT * +FROM a LEFT JOIN vmerge AS v ON a.id = v.id; +id id b_id +1 NULL NULL +1 NULL NULL +DROP VIEW vmerge, vmat; +DROP TABLE a, b; +# Bug#15936817 Table left join view, unmatched rows problem where +# view contains an IF +CREATE TABLE small ( +id INTEGER not null, +PRIMARY KEY (id) +); +CREATE TABLE big ( +id INTEGER not null, +PRIMARY KEY (id) +); +INSERT INTO small VALUES (1), (2); +INSERT INTO big VALUES (1), (2), (3), (4); +CREATE VIEW small_view AS +SELECT *, IF (id % 2 = 1, 1, 0) AS is_odd +FROM small; +CREATE VIEW big_view AS +SELECT big.*, small_view.id AS small_id, small_view.is_odd +FROM big LEFT JOIN small_view ON small_view.id = big.id; +SELECT * FROM big_view; +id small_id is_odd +1 1 1 +2 2 0 +3 NULL NULL +4 NULL NULL +SELECT big.*, small.id AS small_id, small.is_odd +FROM big LEFT JOIN +(SELECT id, IF (id % 2 = 1, 1, 0) AS is_odd FROM small) AS small +ON big.id = small.id; +id small_id is_odd +1 1 1 +2 2 0 +3 NULL NULL +4 NULL NULL +# Check the IS NULL and thruth predicates +SELECT big.*, dt.* +FROM big LEFT JOIN (SELECT id as dt_id, +id IS NULL AS nul, +id IS NOT NULL AS nnul, +id IS TRUE AS t, +id IS NOT TRUE AS nt, +id IS FALSE AS f, +id IS NOT FALSE AS nf, +id IS UNKNOWN AS u, +id IS NOT UNKNOWN AS nu +FROM small) AS dt +ON big.id=dt.dt_id; +id dt_id nul nnul t nt f nf u nu +1 1 0 1 1 0 0 1 0 1 +2 2 0 1 1 0 0 1 0 1 +3 NULL NULL NULL NULL NULL NULL NULL NULL NULL +4 NULL NULL NULL NULL NULL NULL NULL NULL NULL +# Check comparison predicates +SELECT big.*, dt.* +FROM big LEFT JOIN (SELECT id as dt_id, +id = 1 AS eq, +id <> 1 AS ne, +id > 1 AS gt, +id >= 1 AS ge, +id < 1 AS lt, +id <= 1 AS le, +id <=> 1 AS equal +FROM small) AS dt +ON big.id=dt.dt_id; +id dt_id eq ne gt ge lt le equal +1 1 1 0 0 1 0 1 1 +2 2 0 1 1 1 0 0 0 +3 NULL NULL NULL NULL NULL NULL NULL NULL +4 NULL NULL NULL NULL NULL NULL NULL NULL +# Check CASE, NULLIF and COALESCE +SELECT big.*, dt.* +FROM big LEFT JOIN (SELECT id as dt_id, +CASE id WHEN 0 THEN 0 ELSE 1 END AS simple, +CASE WHEN id=0 THEN NULL ELSE 1 END AS cond, +NULLIF(1, NULL) AS nullif, +IFNULL(1, NULL) AS ifnull, +COALESCE(id) AS coal, +INTERVAL(NULL, 1, 2, 3) as intv, +IF (id % 2 = 1, NULL, 1) AS iff +FROM small) AS dt +ON big.id=dt.dt_id; +id dt_id simple cond nullif ifnull coal intv iff +1 1 1 1 1 1 1 -1 NULL +2 2 1 1 1 1 2 -1 1 +3 NULL NULL NULL NULL NULL NULL NULL NULL +4 NULL NULL NULL NULL NULL NULL NULL NULL +DROP VIEW small_view, big_view; +DROP TABLE small, big; +# +# Bug#16893426 OPTIMIZER FAILS TO OPTIMIZE EXPRESSION OF THE +# FORM 'FOO' IS NULL +# +CREATE TABLE t1 ( +id int(11) NOT NULL PRIMARY KEY, +name varchar(20), +INDEX (name) +) ENGINE=InnoDB; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t2 ( +id int(11) NOT NULL PRIMARY KEY, +f_id int(11), +FOREIGN KEY (f_id) REFERENCES t2(id) +) ENGINE=InnoDB; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (1,'A1'),(2,'A2'),(3,'B'); +INSERT INTO t2 VALUES (1,1),(2,2),(3,2),(4,3),(5,3); +ANALYZE TABLE t1; +ANALYZE TABLE t2; +EXPLAIN SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE t1.name LIKE 'A%'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range PRIMARY,name name 83 NULL 2 100.00 Using where; Using index +2 SIMPLE t2 NULL ref f_id f_id 5 test.t1.id 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`id` AS `id`,`test`.`t2`.`f_id` AS `f_id`,`test`.`t1`.`id` AS `id`,`test`.`t1`.`name` AS `name` from `test`.`t2` join `test`.`t1` where ((`test`.`t2`.`f_id` = `test`.`t1`.`id`) and (`test`.`t1`.`name` like 'A%')) +SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE t1.name LIKE 'A%'; +id f_id id name +1 1 1 A1 +2 2 2 A2 +3 2 2 A2 +PREPARE stmt FROM "SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE t1.name LIKE 'A%'"; +EXECUTE stmt; +id f_id id name +1 1 1 A1 +2 2 2 A2 +3 2 2 A2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE t1.name LIKE 'A%' OR 'ASDFGH' IS NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range PRIMARY,name name 83 NULL 2 100.00 Using where; Using index +2 SIMPLE t2 NULL ref f_id f_id 5 test.t1.id 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`id` AS `id`,`test`.`t2`.`f_id` AS `f_id`,`test`.`t1`.`id` AS `id`,`test`.`t1`.`name` AS `name` from `test`.`t2` join `test`.`t1` where ((`test`.`t2`.`f_id` = `test`.`t1`.`id`) and (`test`.`t1`.`name` like 'A%')) +SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE t1.name LIKE 'A%' OR 'ASDFGH' IS NULL; +id f_id id name +1 1 1 A1 +2 2 2 A2 +3 2 2 A2 +PREPARE stmt FROM "SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE t1.name LIKE 'A%' OR 'ASDFGH' IS NULL"; +EXECUTE stmt; +id f_id id name +1 1 1 A1 +2 2 2 A2 +3 2 2 A2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE 0 OR 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`id` AS `id`,`test`.`t2`.`f_id` AS `f_id`,`test`.`t1`.`id` AS `id`,`test`.`t1`.`name` AS `name` from `test`.`t2` left join `test`.`t1` on(multiple equal(`test`.`t2`.`f_id`, `test`.`t1`.`id`)) where false +SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE 0 OR 0; +id f_id id name +PREPARE stmt FROM "SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE 0 OR 0"; +EXECUTE stmt; +id f_id id name +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE 1 OR 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL index NULL f_id 5 NULL 5 100.00 Using index +2 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.f_id 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`id` AS `id`,`test`.`t2`.`f_id` AS `f_id`,`test`.`t1`.`id` AS `id`,`test`.`t1`.`name` AS `name` from `test`.`t2` left join `test`.`t1` on((`test`.`t1`.`id` = `test`.`t2`.`f_id`)) where true +SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE 1 OR 0; +id f_id id name +1 1 1 A1 +2 2 2 A2 +3 2 2 A2 +4 3 3 B +5 3 3 B +PREPARE stmt FROM "SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE 1 OR 0"; +EXECUTE stmt; +id f_id id name +1 1 1 A1 +2 2 2 A2 +3 2 2 A2 +4 3 3 B +5 3 3 B +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE NOT(NOT (0)) OR 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL index NULL f_id 5 NULL 5 100.00 Using index +2 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.f_id 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`id` AS `id`,`test`.`t2`.`f_id` AS `f_id`,`test`.`t1`.`id` AS `id`,`test`.`t1`.`name` AS `name` from `test`.`t2` left join `test`.`t1` on((`test`.`t1`.`id` = `test`.`t2`.`f_id`)) where true +SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE NOT(NOT (0)) OR 1; +id f_id id name +1 1 1 A1 +2 2 2 A2 +3 2 2 A2 +4 3 3 B +5 3 3 B +PREPARE stmt FROM "SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE NOT(NOT (0)) OR 1"; +EXECUTE stmt; +id f_id id name +1 1 1 A1 +2 2 2 A2 +3 2 2 A2 +4 3 3 B +5 3 3 B +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE NOT(NOT (0)) OR 0 = 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`id` AS `id`,`test`.`t2`.`f_id` AS `f_id`,`test`.`t1`.`id` AS `id`,`test`.`t1`.`name` AS `name` from `test`.`t2` left join `test`.`t1` on(multiple equal(`test`.`t2`.`f_id`, `test`.`t1`.`id`)) where false +SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE NOT(NOT (0)) OR 0 = 1; +id f_id id name +PREPARE stmt FROM "SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE NOT(NOT (0)) OR 0 = 1"; +EXECUTE stmt; +id f_id id name +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE 1 IS NOT TRUE AND 0 IS TRUE ; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`id` AS `id`,`test`.`t2`.`f_id` AS `f_id`,`test`.`t1`.`id` AS `id`,`test`.`t1`.`name` AS `name` from `test`.`t2` left join `test`.`t1` on(multiple equal(`test`.`t2`.`f_id`, `test`.`t1`.`id`)) where false +SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE 1 IS NOT TRUE AND 0 IS TRUE ; +id f_id id name +PREPARE stmt FROM "SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE 1 IS NOT TRUE AND 0 IS TRUE "; +EXECUTE stmt; +id f_id id name +EXPLAIN SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE 'a' LIKE 1 OR 2 LIKE '2%' ; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL index NULL f_id 5 NULL 5 100.00 Using index +2 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.f_id 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`id` AS `id`,`test`.`t2`.`f_id` AS `f_id`,`test`.`t1`.`id` AS `id`,`test`.`t1`.`name` AS `name` from `test`.`t2` left join `test`.`t1` on((`test`.`t1`.`id` = `test`.`t2`.`f_id`)) where true +SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE 'a' LIKE 1 OR 2 LIKE '2%' ; +id f_id id name +1 1 1 A1 +2 2 2 A2 +3 2 2 A2 +4 3 3 B +5 3 3 B +PREPARE stmt FROM "SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE 'a' LIKE 1 OR 2 LIKE '2%' "; +EXECUTE stmt; +id f_id id name +1 1 1 A1 +2 2 2 A2 +3 2 2 A2 +4 3 3 B +5 3 3 B +EXPLAIN SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE 1 IS NOT NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL index NULL f_id 5 NULL 5 100.00 Using index +2 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.f_id 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`id` AS `id`,`test`.`t2`.`f_id` AS `f_id`,`test`.`t1`.`id` AS `id`,`test`.`t1`.`name` AS `name` from `test`.`t2` left join `test`.`t1` on((`test`.`t1`.`id` = `test`.`t2`.`f_id`)) where true +SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE 1 IS NOT NULL; +id f_id id name +1 1 1 A1 +2 2 2 A2 +3 2 2 A2 +4 3 3 B +5 3 3 B +PREPARE stmt FROM "SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE 1 IS NOT NULL"; +EXECUTE stmt; +id f_id id name +1 1 1 A1 +2 2 2 A2 +3 2 2 A2 +4 3 3 B +5 3 3 B +EXPLAIN SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE (1<2 AND 2<3) OR (1>1 AND 2<3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL index NULL f_id 5 NULL 5 100.00 Using index +2 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.f_id 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`id` AS `id`,`test`.`t2`.`f_id` AS `f_id`,`test`.`t1`.`id` AS `id`,`test`.`t1`.`name` AS `name` from `test`.`t2` left join `test`.`t1` on((`test`.`t1`.`id` = `test`.`t2`.`f_id`)) where true +SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE (1<2 AND 2<3) OR (1>1 AND 2<3); +id f_id id name +1 1 1 A1 +2 2 2 A2 +3 2 2 A2 +4 3 3 B +5 3 3 B +PREPARE stmt FROM "SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE (1<2 AND 2<3) OR (1>1 AND 2<3)"; +EXECUTE stmt; +id f_id id name +1 1 1 A1 +2 2 2 A2 +3 2 2 A2 +4 3 3 B +5 3 3 B +EXPLAIN SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE (1>=1 AND 2<=2) OR (1=1 AND 2<3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL index NULL f_id 5 NULL 5 100.00 Using index +2 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.f_id 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`id` AS `id`,`test`.`t2`.`f_id` AS `f_id`,`test`.`t1`.`id` AS `id`,`test`.`t1`.`name` AS `name` from `test`.`t2` left join `test`.`t1` on((`test`.`t1`.`id` = `test`.`t2`.`f_id`)) where true +SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE (1>=1 AND 2<=2) OR (1=1 AND 2<3); +id f_id id name +1 1 1 A1 +2 2 2 A2 +3 2 2 A2 +4 3 3 B +5 3 3 B +PREPARE stmt FROM "SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE (1>=1 AND 2<=2) OR (1=1 AND 2<3)"; +EXECUTE stmt; +id f_id id name +1 1 1 A1 +2 2 2 A2 +3 2 2 A2 +4 3 3 B +5 3 3 B +EXPLAIN SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE (1<>1 AND 2=2) OR (1 BETWEEN 0 AND 2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL index NULL f_id 5 NULL 5 100.00 Using index +2 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.f_id 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`id` AS `id`,`test`.`t2`.`f_id` AS `f_id`,`test`.`t1`.`id` AS `id`,`test`.`t1`.`name` AS `name` from `test`.`t2` left join `test`.`t1` on((`test`.`t1`.`id` = `test`.`t2`.`f_id`)) where true +SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE (1<>1 AND 2=2) OR (1 BETWEEN 0 AND 2); +id f_id id name +1 1 1 A1 +2 2 2 A2 +3 2 2 A2 +4 3 3 B +5 3 3 B +PREPARE stmt FROM "SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE (1<>1 AND 2=2) OR (1 BETWEEN 0 AND 2)"; +EXECUTE stmt; +id f_id id name +1 1 1 A1 +2 2 2 A2 +3 2 2 A2 +4 3 3 B +5 3 3 B +DROP TABLE t1,t2; +# +# Bug#22103398 BUG#16893426:SIG11 IN +# ST_SELECT_LEX::FLATTEN_SUBQUERIES | SQL_RESOLVER.CC +# +CREATE TABLE t1(c1 INT, c2 INT, c3 CHAR(1), KEY(c3))ENGINE=InnoDB; +CREATE TABLE t2(c1 INT, c2 INT, c3 CHAR(1), KEY(c3))ENGINE=InnoDB; +SELECT b.c2 AS f1 FROM (t2 AS a JOIN +((t2 AS b JOIN t2 AS c ON (c.c3=b.c3))) +ON (c.c1=b.c2)) +WHERE (c.c3 IN (SELECT subquery1_b.c3 AS subquery1_f1 +FROM (t1 AS subquery1_a JOIN t2 AS subquery1_b ON +(subquery1_b.c1=subquery1_a.c1)))) AND +(a.c1=a.c1 AND (SELECT''FROM DUAL) IS NULL); +f1 +DROP TABLE t1, t2; +# End of Bug#16893426 +# Bug#22561937 Wrong result on outer join with multiple join conditions +# and derived table +CREATE TABLE t1 ( +col_int INT, +pk INT NOT NULL, +PRIMARY KEY (pk) +); +INSERT INTO t1 VALUES +(2,1), (2,2), (6,3), (4,4), (7,5), +(188,6), (0,7), (6,8), (0,9), (9,10); +CREATE TABLE t2 ( +pk INT NOT NULL, +col_int INT, +PRIMARY KEY (pk) +); +INSERT INTO t2 VALUES +(1,0), (2,0), (3,2), (4,NULL), (5,2), +(6,3), (7,3), (8,100), (9,3), (10,6); +explain SELECT table2.pk, table1.col_int +FROM t2 AS table1 +LEFT JOIN t1 AS table2 +ON table2.pk < table1.col_int AND +table2.pk = table1.col_int; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 100.00 Parallel execute (1 workers) +2 SIMPLE table1 NULL ALL NULL NULL NULL NULL 10 100.00 NULL +2 SIMPLE table2 NULL eq_ref PRIMARY PRIMARY 4 test.table1.col_int 1 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`table2`.`pk` AS `pk`,`test`.`table1`.`col_int` AS `col_int` from `test`.`t2` `table1` left join `test`.`t1` `table2` on(((`test`.`table2`.`pk` = `test`.`table1`.`col_int`) and (`test`.`table1`.`col_int` < `test`.`table1`.`col_int`))) where true +SELECT table2.pk, table1.col_int +FROM t2 AS table1 +LEFT JOIN t1 AS table2 +ON table2.pk < table1.col_int AND +table2.pk = table1.col_int; +pk col_int +NULL 0 +NULL 0 +NULL 2 +NULL NULL +NULL 2 +NULL 3 +NULL 3 +NULL 100 +NULL 3 +NULL 6 +explain SELECT table2.pk, table1.col_int +FROM t2 AS table1 +LEFT JOIN (SELECT * FROM t1) AS table2 +ON table2.pk < table1.col_int AND +table2.pk = table1.col_int; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 100.00 Parallel execute (1 workers) +2 SIMPLE table1 NULL ALL NULL NULL NULL NULL 10 100.00 NULL +2 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.table1.col_int 1 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`table1`.`col_int` AS `col_int` from `test`.`t2` `table1` left join (`test`.`t1`) on(((`test`.`t1`.`pk` = `test`.`table1`.`col_int`) and (`test`.`t1`.`pk` < `test`.`table1`.`col_int`))) where true +SELECT table2.pk, table1.col_int +FROM t2 AS table1 +LEFT JOIN (SELECT * FROM t1) AS table2 +ON table2.pk < table1.col_int AND +table2.pk = table1.col_int; +pk col_int +NULL 0 +NULL 0 +NULL 2 +NULL NULL +NULL 2 +NULL 3 +NULL 3 +NULL 100 +NULL 3 +NULL 6 +DROP TABLE t1, t2; +# Bug#22671557: Wrong results on JOIN when composite index is present +CREATE TABLE t1 ( +col_int INT DEFAULT NULL, +col_int_key INT DEFAULT NULL, +pk INT NOT NULL, +PRIMARY KEY (pk), +KEY test_idx (col_int_key,col_int) +); +INSERT INTO t1 VALUES (0, -7, 1), (9, NULL, 15), (182, NULL, 25); +CREATE TABLE t2 ( +col_int INT DEFAULT NULL, +pk INT NOT NULL, +PRIMARY KEY (pk) +); +INSERT INTO t2 VALUES (NULL, 4), (-208, 5), (5, 6), (NULL, 75); +CREATE TABLE t3 ( +col_datetime_key DATETIME DEFAULT NULL, +pk INT NOT NULL, +PRIMARY KEY (pk) +); +INSERT INTO t3 VALUES ('1970-01-01 00:00:00', 5); +CREATE TABLE t4 ( +col_int INT DEFAULT NULL, +pk INT NOT NULL, +col_int_key INT DEFAULT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +); +INSERT INTO t4 VALUES (0, 15, 6), (9, 16, 6); +SELECT alias2.col_datetime_key +FROM +t1 AS alias1 +LEFT JOIN t3 AS alias2 +LEFT JOIN t2 AS alias3 +LEFT JOIN t4 AS alias4 +ON alias3.pk = alias4.col_int_key +ON alias2.pk = alias3.col_int +ON alias1.col_int = alias4.col_int +; +col_datetime_key +1970-01-01 00:00:00 +1970-01-01 00:00:00 +NULL +DROP TABLE t1, t2, t3, t4; +# Bug#22833364: Left join returns incorrect results on the outer side +CREATE TABLE ta ( +a1 varchar(1024) NOT NULL, +a2 int NOT NULL, +KEY user_id(a2) +); +INSERT INTO ta (a1, a2) VALUES ('row1', 4), ('row2', 4); +CREATE TABLE tb ( +b1 int NOT NULL, +b2 varchar(1024) NOT NULL, +b3 int NOT NULL, +PRIMARY KEY (b1) +); +INSERT INTO tb (b1, b2, b3) VALUES +(1, 'text1', 0), (2, 'text2', 0), (3, 'text3', 1), (4, 'text4', 1); +explain SELECT ta.a1, tb.b1, tb.b2 +FROM ta LEFT OUTER JOIN tb +ON ta.a2 = tb.b1 AND tb.b3 = 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE ta NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 SIMPLE tb NULL eq_ref PRIMARY PRIMARY 4 test.ta.a2 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`ta`.`a1` AS `a1`,`test`.`tb`.`b1` AS `b1`,`test`.`tb`.`b2` AS `b2` from `test`.`ta` left join `test`.`tb` on(((`test`.`tb`.`b3` = 0) and (`test`.`tb`.`b1` = `test`.`ta`.`a2`))) where true +SELECT ta.a1, tb.b1, tb.b2 +FROM ta LEFT OUTER JOIN tb +ON ta.a2 = tb.b1 AND tb.b3 = 0; +a1 b1 b2 +row1 NULL NULL +row2 NULL NULL +DROP TABLE ta, tb; +# Bug#23079533: Left join on PK + extra condition doesn't return match +CREATE TABLE m ( +machineid VARCHAR(32) NOT NULL, +orderid bigint unsigned DEFAULT NULL, +extra bigint unsigned DEFAULT NULL, +PRIMARY KEY (machineid) +); +INSERT INTO m (machineid, orderid) +VALUES ('m1', NULL), ('m2', 2), ('m3', NULL), ('m4', NULL); +CREATE TABLE o ( +orderid bigint unsigned NOT NULL, +machineid VARCHAR(32) DEFAULT NULL, +PRIMARY KEY (orderid) +); +INSERT INTO o (orderid, machineid) +VALUES (1, 'm2'), (2, 'm2'); +SELECT o.*,'|' as sep, m.* +FROM o LEFT JOIN m +ON m.machineid = o.machineid AND +m.orderid = o.orderid; +orderid machineid sep machineid orderid extra +1 m2 | NULL NULL NULL +2 m2 | m2 2 NULL +DROP TABLE m, o; +# Bug#23086825: Incorrect query results using left join against derived +CREATE TABLE t1 ( +adslot varchar(5) NOT NULL +); +INSERT INTO t1(adslot) VALUES ('1'), ('2'), ('3'); +CREATE TABLE t2 ( +ionumber varchar(20) NOT NULL, +adslot varchar(5) NOT NULL +); +INSERT INTO t2 (ionumber, adslot) VALUES ('01602', 1), ('01602', 3); +CREATE TABLE t3 ( +ionumber varchar(20) NOT NULL, +ioattribute varchar(5) NOT NULL, +PRIMARY KEY (ionumber) +); +INSERT INTO t3 VALUES ('01602', 'BOB'), ('01603', 'SALLY'); +SELECT s.adslot, lid.ionumber1, lid.ionumber2, lid.ioattribute +FROM t1 s LEFT JOIN +(SELECT lid.adslot, +i.ionumber as ionumber1, +lid.ionumber as ionumber2, +i.ioattribute +FROM t2 lid JOIN t3 i +USING (ionumber) +) AS lid +USING (adslot); +adslot ionumber1 ionumber2 ioattribute +1 01602 01602 BOB +2 NULL NULL NULL +3 01602 01602 BOB +DROP TABLE t1, t2, t3; +# +# Bug #26432173: INCORRECT SUBQUERY OPTIMIZATION WITH +# LEFT JOIN(SUBQUERY) AND ORDER BY +# +CREATE TABLE t1 (a INT); +INSERT t1 values (1),(2),(15),(24),(5); +CREATE TABLE t2 (t1_a INT, b VARCHAR(10)); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN SELECT t1.a, subq.st_value +FROM t1 +LEFT JOIN (SELECT t2.t1_a, 'red' AS st_value +FROM t2) AS subq +ON subq.t1_a = t1.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,'red' AS `st_value` from `test`.`t1` left join (`test`.`t2`) on((`test`.`t2`.`t1_a` = `test`.`t1`.`a`)) where true +EXPLAIN SELECT t1.a, subq.st_value +FROM t1 +LEFT JOIN (SELECT t2.t1_a, 'red' AS st_value +FROM t2) AS subq +ON subq.t1_a = t1.a +ORDER BY t1.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 100.00 Using temporary; Using filesort +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,'red' AS `st_value` from `test`.`t1` left join (`test`.`t2`) on((`test`.`t2`.`t1_a` = `test`.`t1`.`a`)) where true order by `test`.`t1`.`a` +EXPLAIN SELECT t1.a, subq.st_value +FROM (SELECT t2.t1_a, 'red' AS st_value +FROM t2) AS subq +LEFT JOIN t1 +ON subq.t1_a = t1.a +ORDER BY t1.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using temporary; Using filesort +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,'red' AS `st_value` from `test`.`t2` left join `test`.`t1` on((`test`.`t1`.`a` = `test`.`t2`.`t1_a`)) where true order by `test`.`t1`.`a` +SELECT t1.a, subq.st_value +FROM t1 +LEFT JOIN (SELECT t2.t1_a, 'red' AS st_value +FROM t2) AS subq +ON subq.t1_a = t1.a; +a st_value +1 NULL +2 NULL +15 NULL +24 NULL +5 NULL +SELECT t1.a, subq.st_value +FROM t1 +LEFT JOIN (SELECT t2.t1_a, 'red' AS st_value +FROM t2) AS subq +ON subq.t1_a = t1.a +ORDER BY t1.a; +a st_value +1 NULL +2 NULL +5 NULL +15 NULL +24 NULL +SELECT t1.a, subq.st_value +FROM (SELECT t2.t1_a, 'red' AS st_value +FROM t2) AS subq +LEFT JOIN t1 +ON subq.t1_a = t1.a +ORDER BY t1.a; +a st_value +DROP TABLE t1, t2; +# Bug #18898433: EXTREMELY SLOW PERFORMANCE WITH OUTER JOINS AND JOIN +# BUFFER. +# +CREATE TABLE t1 (i INT NOT NULL); +INSERT INTO t1 VALUES (0),(2),(3),(4); +CREATE TABLE t2 (i INT NOT NULL); +INSERT INTO t2 VALUES (0),(1),(3),(4); +CREATE TABLE t3 (i INT NOT NULL); +INSERT INTO t3 VALUES (0),(1),(2),(4); +CREATE TABLE t4 (i INT NOT NULL); +INSERT INTO t4 VALUES (0),(1),(2),(3); +ANALYZE TABLE t1, t2, t3, t4; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +test.t4 analyze status OK +EXPLAIN SELECT * +FROM t1 LEFT JOIN +( +(t2 LEFT JOIN t3 ON t3.i= t2.i) +LEFT JOIN t4 ON t3.i= t4.i +)ON t2.i= t1.i; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i`,`test`.`t2`.`i` AS `i`,`test`.`t3`.`i` AS `i`,`test`.`t4`.`i` AS `i` from `test`.`t1` left join (`test`.`t2` left join `test`.`t3` on((`test`.`t3`.`i` = `test`.`t2`.`i`)) left join `test`.`t4` on((`test`.`t4`.`i` = `test`.`t3`.`i`))) on((`test`.`t2`.`i` = `test`.`t1`.`i`)) where true +EXPLAIN SELECT * +FROM t1 LEFT JOIN +( +(t2 INNER JOIN t3 ON t3.i= t2.i) +LEFT JOIN t4 ON t3.i= t4.i +)ON t2.i= t1.i; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i`,`test`.`t2`.`i` AS `i`,`test`.`t3`.`i` AS `i`,`test`.`t4`.`i` AS `i` from `test`.`t1` left join (`test`.`t2` join `test`.`t3` left join `test`.`t4` on((`test`.`t4`.`i` = `test`.`t2`.`i`))) on(((`test`.`t2`.`i` = `test`.`t1`.`i`) and (`test`.`t3`.`i` = `test`.`t1`.`i`))) where true +EXPLAIN SELECT * +FROM t1 LEFT JOIN t2 ON t2.i= t1.i +LEFT JOIN t3 ON t3.i= t2.i +LEFT JOIN t4 ON t3.i= t4.i; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i`,`test`.`t2`.`i` AS `i`,`test`.`t3`.`i` AS `i`,`test`.`t4`.`i` AS `i` from `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t1`.`i`)) left join `test`.`t3` on((`test`.`t3`.`i` = `test`.`t2`.`i`)) left join `test`.`t4` on((`test`.`t4`.`i` = `test`.`t3`.`i`)) where true +flush status; +SELECT * +FROM t1 LEFT JOIN +( +(t2 LEFT JOIN t3 ON t3.i= t2.i) +LEFT JOIN t4 ON t3.i= t4.i +)ON t2.i= t1.i; +i i i i +0 0 0 0 +2 NULL NULL NULL +3 3 NULL NULL +4 4 4 NULL +SHOW STATUS LIKE 'HANDLER_%'; +Variable_name Value +Handler_commit 1 +Handler_delete 0 +Handler_discover 0 +Handler_external_lock 8 +Handler_mrr_init 0 +Handler_prepare 0 +Handler_read_first 4 +Handler_read_key 4 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 20 +Handler_rollback 0 +Handler_savepoint 0 +Handler_savepoint_rollback 0 +Handler_update 0 +Handler_write 0 +flush status; +SELECT * +FROM t1 LEFT JOIN +( +(t2 INNER JOIN t3 ON t3.i= t2.i) +LEFT JOIN t4 ON t3.i= t4.i +)ON t2.i= t1.i; +i i i i +0 0 0 0 +2 NULL NULL NULL +3 NULL NULL NULL +4 4 4 NULL +SHOW STATUS LIKE 'HANDLER_%'; +Variable_name Value +Handler_commit 1 +Handler_delete 0 +Handler_discover 0 +Handler_external_lock 8 +Handler_mrr_init 0 +Handler_prepare 0 +Handler_read_first 4 +Handler_read_key 4 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 20 +Handler_rollback 0 +Handler_savepoint 0 +Handler_savepoint_rollback 0 +Handler_update 0 +Handler_write 0 +flush status; +SELECT * +FROM t1 LEFT JOIN t2 ON t2.i= t1.i +LEFT JOIN t3 ON t3.i= t2.i +LEFT JOIN t4 ON t3.i= t4.i; +i i i i +0 0 0 0 +2 NULL NULL NULL +3 3 NULL NULL +4 4 4 NULL +SHOW STATUS LIKE 'HANDLER_%'; +Variable_name Value +Handler_commit 1 +Handler_delete 0 +Handler_discover 0 +Handler_external_lock 8 +Handler_mrr_init 0 +Handler_prepare 0 +Handler_read_first 4 +Handler_read_key 4 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 20 +Handler_rollback 0 +Handler_savepoint 0 +Handler_savepoint_rollback 0 +Handler_update 0 +Handler_write 0 +DROP TABLE t1, t2, t3, t4; +# +# Bug #26627181: WRONG RESULT WITH LEFT JOIN + DERIVED TABLES +# +CREATE TABLE t1 (id INT); +CREATE TABLE t2 (id INT); +INSERT INTO t1 VALUES (1), (2); +INSERT INTO t2 VALUES (1); +EXPLAIN SELECT * +FROM (SELECT id +FROM t1) AS a +LEFT JOIN +(SELECT id, 2 AS tall +FROM t2) AS b +ON a.id = b.id +WHERE b.tall IS NOT NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,`test`.`t2`.`id` AS `id`,2 AS `tall` from `test`.`t1` left join (`test`.`t2`) on((`test`.`t2`.`id` = `test`.`t1`.`id`)) where (2 is not null) +SELECT * +FROM (SELECT id +FROM t1) AS a +LEFT JOIN +(SELECT id, 2 AS tall +FROM t2) AS b +ON a.id = b.id +WHERE b.tall IS NOT NULL; +id id tall +1 1 2 +DROP TABLE t1, t2; +# +# Bug #23169204: Left join + merged derived table + group by = bad result +# +CREATE TABLE t1(doc text); +CREATE TABLE t2(a INTEGER DEFAULT NULL); +INSERT INTO t2 VALUES(1); +SELECT je +FROM t2 LEFT JOIN (SELECT 1 AS je FROM t1 LIMIT 1) AS dt ON FALSE; +je +NULL +SELECT je +FROM t2 LEFT JOIN (SELECT 1 AS je FROM t1 LIMIT 1) AS dt ON FALSE +GROUP BY je; +je +NULL +SELECT je +FROM t2 LEFT JOIN (SELECT 1 AS je FROM t1) AS dt ON FALSE; +je +NULL +SELECT je +FROM t2 LEFT JOIN (SELECT 1 AS je FROM t1) AS dt ON FALSE +GROUP BY je; +je +NULL +DROP TABLE t1, t2; +# +# Bug#22489105 WL#9571 : SIG11 IN ITEM_SUBSELECT::EXEC | SQL/ITEM_SUBSELECT.CC +# +SELECT (SELECT * FROM (SELECT 'a') t) AS f1 HAVING (f1 = 'a' OR TRUE); +f1 +a +SELECT (SELECT * FROM (SELECT 'a') t) + 1 AS f1 HAVING (f1 = 'a' OR TRUE); +f1 +1 +SELECT 1 + (SELECT * FROM (SELECT 'a') t) AS f1 HAVING (f1 = 'a' OR TRUE); +f1 +1 +# +# Bug#28237111: WL#9571: TABLE FULL ERROR +# +CREATE TABLE t1 (pk INTEGER, f1 INTEGER, primary key(pk)); +CREATE TABLE t2 (pk INTEGER, f1 INTEGER, primary key(pk)); +CREATE TABLE t3 (pk INTEGER); +INSERT INTO t1 VALUES (1,1),(2,1),(3,1); +INSERT INTO t2 VALUES (1,1),(2,1),(3,1); +INSERT INTO t3 VALUES (1); +SELECT * FROM (t1 RIGHT JOIN +(SELECT * FROM t3 WHERE (DAYNAME('1995'))) AS table2 ON +(( t1.f1 ,t1.pk) IN (SELECT 7,4 UNION SELECT 9,2))) WHERE +(NOT EXISTS (SELECT t1.f1 FROM (t1 INNER JOIN t2 ON (t1.pk=t2.f1)) +WHERE 0 IS NOT NULL)) AND t1.f1 > 50; +pk f1 pk +Warnings: +Warning 1292 Incorrect datetime value: '1995' +DROP TABLE t3,t1,t2; +# +# Bug#28341790: WL#9571: SIG11 IN ITEM_COND::FIX_FIELDS() AT SQL/ITEM_CMPFUNC.CC +# +CREATE TABLE t1 (col_varchar varchar(1) DEFAULT NULL); +INSERT INTO t1 VALUES ('Z') ; +CREATE TABLE t2 (col_varchar varchar(1) DEFAULT NULL); +INSERT INTO t2 VALUES ('Z') ; +PREPARE prep_stmt FROM " SELECT 1 FROM ( ( SELECT * FROM t1 WHERE col_varchar +>= 1 ) AS table1 RIGHT JOIN t2 ON ( ( NULL < NULL ) IS NULL OR 1 = 0 ) ) " ; +EXECUTE prep_stmt ; +1 +1 +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'Z' +EXECUTE prep_stmt ; +1 +1 +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'Z' +DROP TABLE t1,t2; +# +# More coverage for IS TRUE in LEFT JOIN conditions +# +CREATE TABLE t1(c1 INT); +INSERT INTO t1 VALUES(1),(2); +CREATE TABLE t2(c2 INT); +INSERT INTO t2 VALUES(1); +SELECT * FROM t1 LEFT JOIN t2 ON c1=c2; +c1 c2 +1 1 +2 NULL +SELECT * FROM t1 LEFT JOIN t2 ON c1=c2 WHERE c2 IS NULL; +c1 c2 +2 NULL +SELECT * FROM t1 LEFT JOIN t2 ON c1=c2 WHERE c2 IS NOT NULL; +c1 c2 +1 1 +SELECT * FROM t1 LEFT JOIN t2 ON c1=c2 WHERE (c2 IS NOT NULL) = 1; +c1 c2 +1 1 +SELECT * FROM t1 LEFT JOIN t2 ON c1=c2 WHERE (c2 IS NOT NULL) IS TRUE; +c1 c2 +1 1 +SELECT * FROM t1 LEFT JOIN t2 ON c1=c2 WHERE (c2 IS NOT NULL) = 0; +c1 c2 +2 NULL +SELECT * FROM t1 LEFT JOIN t2 ON c1=c2 WHERE (c2 IS NOT NULL) IS FALSE; +c1 c2 +2 NULL +DROP TABLE t1,t2; +# +# Bug#29402481: INCORRECT RESULT FROM OUTER JOIN QUERIES +# +CREATE TABLE t1 ( +pk int primary key auto_increment, +col_int_unique int unique +) ENGINE=InnoDB; +INSERT INTO t1(col_int_unique) values (6),(7); +CREATE TABLE t2 ( +pk int primary key auto_increment, +col_int_key int(11) DEFAULT NULL, +col_int_unique int(11) DEFAULT NULL, +UNIQUE KEY `ix2` (col_int_key,col_int_unique), +KEY col_int_key (col_int_key) +) ENGINE=InnoDB; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t3 ( +pk int NOT NULL +) ENGINE=InnoDB; +INSERT INTO t3(pk) values (6),(7); +SELECT STRAIGHT_JOIN t1.col_int_unique, t2.col_int_key, t3.pk +FROM +(t1 LEFT JOIN t2 ON t1.col_int_unique = t2.col_int_key) +LEFT JOIN t3 ON t3.pk = t1.col_int_unique AND +t1.col_int_unique = t2.col_int_key; +col_int_unique col_int_key pk +6 NULL NULL +7 NULL NULL +DROP TABLE t1,t2,t3; +# +# Bug#29493830 CONST'IFIED OUTER JOIN RETURN INCORRECT RESULTS +# +CREATE TABLE t1 ( +col_int_unique INT DEFAULT NULL, +col_int_key INT DEFAULT NULL, +UNIQUE KEY col_int_unique (col_int_unique) +) ENGINE=InnoDB; +INSERT INTO t1 VALUES (5,0); +CREATE TABLE t2 ( +col_char_16_unique char(16) DEFAULT NULL, +col_int_key INT DEFAULT NULL, +col_int_unique INT DEFAULT NULL, +UNIQUE KEY col_int_unique (col_int_unique) +) ENGINE=InnoDB; +INSERT INTO t2 VALUES ("just",21,5); +CREATE TABLE t3 ( +col_int INT DEFAULT NULL, +col_char_16_unique CHAR(16) DEFAULT NULL, +UNIQUE KEY col_char_16_unique (col_char_16_unique) +) ENGINE=InnoDB; +INSERT INTO t3 VALUES (9,"foo"); +CREATE TABLE t4 ( +col_int INT DEFAULT NULL, +col_int_unique INT DEFAULT NULL, +UNIQUE KEY col_int_unique (col_int_unique) +) ENGINE=InnoDB; +INSERT INTO t4 VALUES (9,5); +explain SELECT STRAIGHT_JOIN +t3.col_int, t4.col_int, +t3.col_int = t4.col_int or t4.col_int IS NULL +FROM (t1 +LEFT JOIN t2 +ON t1.col_int_key = t2.col_int_key AND +t1.col_int_unique = t2.col_int_unique +LEFT JOIN t3 +ON t3.col_char_16_unique = t2.col_char_16_unique +LEFT JOIN t4 +ON t4.col_int = t3.col_int AND #Note, this pred term +t4.col_int_unique = t1.col_int_unique +) WHERE t1.col_int_unique = 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL const col_int_unique col_int_unique 5 const 1 100.00 NULL +1 SIMPLE t2 NULL const col_int_unique col_int_unique 5 const 1 100.00 Impossible ON condition +1 SIMPLE t3 NULL const col_char_16_unique NULL NULL NULL 1 100.00 Impossible ON condition +1 SIMPLE t4 NULL const col_int_unique col_int_unique 5 const 1 100.00 Impossible ON condition +Warnings: +Note 1003 /* select#1 */ select straight_join NULL AS `col_int`,NULL AS `col_int`,((NULL = NULL) or (NULL is null)) AS `t3.col_int = t4.col_int or t4.col_int IS NULL` from `test`.`t1` left join `test`.`t2` on((multiple equal('0', NULL) and multiple equal(5, NULL))) left join `test`.`t3` on(multiple equal(NULL, NULL)) left join `test`.`t4` on((multiple equal(NULL, NULL) and multiple equal(5, NULL))) where true +SELECT STRAIGHT_JOIN +t3.col_int, t4.col_int, +t3.col_int = t4.col_int or t4.col_int IS NULL +FROM (t1 +LEFT JOIN t2 +ON t1.col_int_key = t2.col_int_key AND +t1.col_int_unique = t2.col_int_unique +LEFT JOIN t3 +ON t3.col_char_16_unique = t2.col_char_16_unique +LEFT JOIN t4 +ON t4.col_int = t3.col_int AND #Note, this pred term +t4.col_int_unique = t1.col_int_unique +) WHERE t1.col_int_unique = 5; +col_int col_int t3.col_int = t4.col_int or t4.col_int IS NULL +NULL NULL 1 +DROP TABLE t1, t2, t3, t4; +# +# Bug #30659532: WL#13476: DIFFERENT NUMBER OF ROWS WITH NESTED LOOP JOINS +# +CREATE TABLE t1 ( +pk INTEGER NOT NULL +); +INSERT INTO t1 VALUES (1); +INSERT INTO t1 VALUES (2); +CREATE TABLE t2 ( +pk INTEGER NOT NULL, +PRIMARY KEY (pk) +); +INSERT INTO t2 VALUES (1); +INSERT INTO t2 VALUES (2); +INSERT INTO t2 VALUES (3); +CREATE TABLE t3 ( +f1 INTEGER, +f2 INTEGER, +KEY k2 (f2) +); +INSERT INTO t3 VALUES (NULL,NULL); +INSERT INTO t3 VALUES (NULL,295010100); +INSERT INTO t3 VALUES (NULL,NULL); +INSERT INTO t3 VALUES (NULL,-1762438755); +INSERT INTO t3 VALUES (NULL,4); +ANALYZE TABLE t1, t2, t3; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +EXPLAIN FORMAT=tree SELECT * FROM t1 LEFT JOIN t2 ON t1.pk = t2.pk LEFT JOIN t3 ON t2.pk = t3.f2 WHERE t2.pk < 5; +EXPLAIN +-> Parallel scan on + -> Nested loop left join (cost=2.02 rows=2) + -> Nested loop inner join (cost=1.15 rows=2) + -> Filter: (t1.pk < 5) (cost=0.45 rows=2) + -> PQblock scan on t1 (cost=0.45 rows=2) + -> Single-row index lookup on t2 using PRIMARY (pk=t1.pk) (cost=0.30 rows=1) + -> Index lookup on t3 using k2 (f2=t1.pk) (cost=0.38 rows=1) + +SELECT * FROM t1 LEFT JOIN t2 ON t1.pk = t2.pk LEFT JOIN t3 ON t2.pk = t3.f2 WHERE t2.pk < 5; +pk pk f1 f2 +1 1 NULL NULL +2 2 NULL NULL +DROP TABLE t1, t2, t3; +# +# Bug #30654713: WL#13476: DIFFERENT ROWS WITH BATCHED KEY ACCESS LEFT JOIN +# +CREATE TABLE t1 ( +col_int INTEGER, +a INTEGER, +b varchar(10), +KEY key_a (a) +); +INSERT INTO t1 VALUES (5,NULL,'p'); +INSERT INTO t1 VALUES (6,NULL,''); +INSERT INTO t1 VALUES (7,NULL,''); +INSERT INTO t1 VALUES (8,NULL,'Z'); +INSERT INTO t1 VALUES (9,4,'g'); +INSERT INTO t1 VALUES (10,NULL,'if'); +INSERT INTO t1 VALUES (11,NULL,'j'); +INSERT INTO t1 VALUES (12,9,''); +CREATE TABLE t2 ( +a INTEGER, +b varchar(10), +KEY key_b (b) +); +INSERT INTO t2 VALUES (1,'j'); +INSERT INTO t2 VALUES (2,'o'); +INSERT INTO t2 VALUES (3,'z'); +INSERT INTO t2 VALUES (4,'really'); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN format=tree SELECT t1.col_int as t1_ci, t1.a as t1_a, t1.b as t1_b, t2.a as t2_a, t2.b as t2_b, t3.col_int as t3_ci, t3.a as t3_a, t3.b as t3_b +FROM t1 +LEFT JOIN ( t2 LEFT JOIN t1 AS t3 ON t2.a=t3.a ) +ON t1.b = t2.b; +EXPLAIN +-> Parallel scan on + -> Left hash join (t2.b = t1.b) (cost=23.25 rows=144) + -> PQblock scan on t1 (cost=1.05 rows=8) + -> Hash + -> Left hash join (t3.a = t2.a) (cost=3.70 rows=24) + -> Table scan on t2 (cost=0.08 rows=4) + -> Hash + -> Table scan on t3 (cost=0.04 rows=8) + +SELECT t1.col_int as t1_ci, t1.a as t1_a, t1.b as t1_b, t2.a as t2_a, t2.b as t2_b, t3.col_int as t3_ci, t3.a as t3_a, t3.b as t3_b +FROM t1 +LEFT JOIN ( t2 LEFT JOIN t1 AS t3 ON t2.a=t3.a ) +ON t1.b = t2.b; +t1_ci t1_a t1_b t2_a t2_b t3_ci t3_a t3_b +10 NULL if NULL NULL NULL NULL NULL +11 NULL j 1 j NULL NULL NULL +12 9 NULL NULL NULL NULL NULL +5 NULL p NULL NULL NULL NULL NULL +6 NULL NULL NULL NULL NULL NULL +7 NULL NULL NULL NULL NULL NULL +8 NULL Z 3 z NULL NULL NULL +9 4 g NULL NULL NULL NULL NULL +DROP TABLE t1, t2; +# +# Bug#30520749 - REGRESSION: LEFT JOIN WITH IMPOSSIBLE ON CONDITION PERFORMS SLOWLY +# +set optimizer_switch='block_nested_loop=off'; +CREATE TABLE t1 ( f1 INTEGER ); +INSERT INTO t1 VALUES (1), (2), (3), (4), (5); +CREATE TABLE t2 AS SELECT * FROM t1; +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN FORMAT=tree SELECT * FROM t1 LEFT JOIN t2 ON 1=2; +EXPLAIN +-> Parallel scan on + -> Nested loop left join (cost=4.50 rows=25) + -> PQblock scan on t1 (cost=0.75 rows=5) + -> Zero rows (Impossible filter) (cost=0.07..0.35 rows=5) + +DROP TABLE t1, t2; +set optimizer_switch='block_nested_loop=on'; +# +# Bug #31252625: DATA IN WRONG ROW ON LEFT JOIN +# +CREATE TABLE t1 ( +id INTEGER NOT NULL, +b INTEGER, +PRIMARY KEY (id) +); +INSERT INTO t1 VALUES (17,NULL); +INSERT INTO t1 VALUES (136,564); +INSERT INTO t1 VALUES (137,NULL); +CREATE TABLE t2 ( +id INTEGER NOT NULL, +PRIMARY KEY (id) +); +INSERT INTO t2 VALUES (564); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +SELECT * FROM t1 LEFT JOIN t2 ON t1.b = t2.id GROUP BY t1.id; +id b id +17 NULL NULL +136 564 564 +137 NULL NULL +DROP TABLE t1, t2; diff --git a/mysql-test/r/join_outer_bka.result-pq b/mysql-test/r/join_outer_bka.result-pq new file mode 100644 index 000000000000..ef95cac6ec96 --- /dev/null +++ b/mysql-test/r/join_outer_bka.result-pq @@ -0,0 +1,3838 @@ +set optimizer_switch='batched_key_access=on,mrr_cost_based=off'; +drop table if exists t0,t1,t2,t3,t4,t5; +CREATE TABLE t1 ( +grp int(11) default NULL, +a bigint(20) unsigned default NULL, +c char(10) NOT NULL default '' +) ENGINE=MyISAM; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (1,1,'a'),(2,2,'b'),(2,3,'c'),(3,4,'E'),(3,5,'C'),(3,6,'D'),(NULL,NULL,''); +create table t2 (id int, a bigint unsigned not null, c char(10), d int, primary key (a)); +insert into t2 values (1,1,"a",1),(3,4,"A",4),(3,5,"B",5),(3,6,"C",6),(4,7,"D",7); +select t1.*,t2.* from t1 JOIN t2 where t1.a=t2.a; +grp a c id a c d +1 1 a 1 1 a 1 +3 4 E 3 4 A 4 +3 5 C 3 5 B 5 +3 6 D 3 6 C 6 +EXPLAIN FORMAT=tree select t1.*,t2.* from t1 left join t2 on (t1.a=t2.a) order by t1.grp,t1.a,t2.c; +EXPLAIN +-> Sort: t1.grp, t1.a, t2.c + -> Stream results (cost=3.67 rows=7) + -> Nested loop left join (cost=3.67 rows=7) + -> Table scan on t1 (cost=1.22 rows=7) + -> Single-row index lookup on t2 using PRIMARY (a=t1.a) (cost=0.26 rows=1) + +select t1.*,t2.* from t1 left join t2 on (t1.a=t2.a) order by t1.grp,t1.a,t2.c; +grp a c id a c d +NULL NULL NULL NULL NULL NULL +1 1 a 1 1 a 1 +2 2 b NULL NULL NULL NULL +2 3 c NULL NULL NULL NULL +3 4 E 3 4 A 4 +3 5 C 3 5 B 5 +3 6 D 3 6 C 6 +select t1.*,t2.* from { oj t2 left outer join t1 on (t1.a=t2.a) }; +grp a c id a c d +1 1 a 1 1 a 1 +3 4 E 3 4 A 4 +3 5 C 3 5 B 5 +3 6 D 3 6 C 6 +NULL NULL NULL 4 7 D 7 +select t1.*,t2.* from t1 as t0,{ oj t2 left outer join t1 on (t1.a=t2.a) } WHERE t0.a=2; +grp a c id a c d +1 1 a 1 1 a 1 +3 4 E 3 4 A 4 +3 5 C 3 5 B 5 +3 6 D 3 6 C 6 +NULL NULL NULL 4 7 D 7 +select t1.*,t2.* from t1 left join t2 using (a); +grp a c id a c d +1 1 a 1 1 a 1 +2 2 b NULL NULL NULL NULL +2 3 c NULL NULL NULL NULL +3 4 E 3 4 A 4 +3 5 C 3 5 B 5 +3 6 D 3 6 C 6 +NULL NULL NULL NULL NULL NULL +select t1.*,t2.* from t1 left join t2 using (a) where t1.a=t2.a; +grp a c id a c d +1 1 a 1 1 a 1 +3 4 E 3 4 A 4 +3 5 C 3 5 B 5 +3 6 D 3 6 C 6 +select t1.*,t2.* from t1 left join t2 using (a,c); +grp a c id a c d +1 1 a 1 1 a 1 +2 2 b NULL NULL NULL NULL +2 3 c NULL NULL NULL NULL +3 4 E NULL NULL NULL NULL +3 5 C NULL NULL NULL NULL +3 6 D NULL NULL NULL NULL +NULL NULL NULL NULL NULL NULL +select t1.*,t2.* from t1 left join t2 using (c); +grp a c id a c d +1 1 a 1 1 a 1 +1 1 a 3 4 A 4 +2 2 b 3 5 B 5 +2 3 c 3 6 C 6 +3 4 E NULL NULL NULL NULL +3 5 C 3 6 C 6 +3 6 D 4 7 D 7 +NULL NULL NULL NULL NULL NULL +select t1.*,t2.* from t1 natural left outer join t2; +grp a c id a c d +1 1 a 1 1 a 1 +2 2 b NULL NULL NULL NULL +2 3 c NULL NULL NULL NULL +3 4 E NULL NULL NULL NULL +3 5 C NULL NULL NULL NULL +3 6 D NULL NULL NULL NULL +NULL NULL NULL NULL NULL NULL +select t1.*,t2.* from t1 left join t2 on (t1.a=t2.a) where t2.id=3; +grp a c id a c d +3 4 E 3 4 A 4 +3 5 C 3 5 B 5 +3 6 D 3 6 C 6 +select t1.*,t2.* from t1 left join t2 on (t1.a=t2.a) where t2.id is null; +grp a c id a c d +2 2 b NULL NULL NULL NULL +2 3 c NULL NULL NULL NULL +NULL NULL NULL NULL NULL NULL +explain select t1.*,t2.* from t1,t2 where t1.a=t2.a and isnull(t2.a)=1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`grp` AS `grp`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`c` AS `c`,`test`.`t2`.`id` AS `id`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`c` AS `c`,`test`.`t2`.`d` AS `d` from `test`.`t1` join `test`.`t2` where false +explain select t1.*,t2.* from t1 left join t2 on t1.a=t2.a where isnull(t2.a)=1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 7 100.00 NULL +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 8 test.t1.a 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`grp` AS `grp`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`c` AS `c`,`test`.`t2`.`id` AS `id`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`c` AS `c`,`test`.`t2`.`d` AS `d` from `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`a` = `test`.`t1`.`a`)) where ((`test`.`t2`.`a` is null) = 1) +select t1.*,t2.*,t3.a from t1 left join t2 on (t1.a=t2.a) left join t1 as t3 on (t2.a=t3.a); +grp a c id a c d a +1 1 a 1 1 a 1 1 +2 2 b NULL NULL NULL NULL NULL +2 3 c NULL NULL NULL NULL NULL +3 4 E 3 4 A 4 4 +3 5 C 3 5 B 5 5 +3 6 D 3 6 C 6 6 +NULL NULL NULL NULL NULL NULL NULL +explain select t1.*,t2.*,t3.a from t1 left join t2 on (t3.a=t2.a) left join t1 as t3 on (t1.a=t3.a); +ERROR 42S22: Unknown column 't3.a' in 'on clause' +select t1.*,t2.*,t3.a from t1 left join t2 on (t3.a=t2.a) left join t1 as t3 on (t1.a=t3.a); +ERROR 42S22: Unknown column 't3.a' in 'on clause' +select t1.*,t2.*,t3.a from t1 left join t2 on (t3.a=t2.a) left join t1 as t3 on (t2.a=t3.a); +ERROR 42S22: Unknown column 't3.a' in 'on clause' +select t1.*,t2.* from t1 inner join t2 using (a); +grp a c id a c d +1 1 a 1 1 a 1 +3 4 E 3 4 A 4 +3 5 C 3 5 B 5 +3 6 D 3 6 C 6 +select t1.*,t2.* from t1 inner join t2 on (t1.a=t2.a); +grp a c id a c d +1 1 a 1 1 a 1 +3 4 E 3 4 A 4 +3 5 C 3 5 B 5 +3 6 D 3 6 C 6 +select t1.*,t2.* from t1 natural join t2; +grp a c id a c d +1 1 a 1 1 a 1 +drop table t1,t2; +CREATE TABLE t1 ( +usr_id INT unsigned NOT NULL, +uniq_id INT unsigned NOT NULL AUTO_INCREMENT, +start_num INT unsigned NOT NULL DEFAULT 1, +increment INT unsigned NOT NULL DEFAULT 1, +PRIMARY KEY (uniq_id), +INDEX usr_uniq_idx (usr_id, uniq_id), +INDEX uniq_usr_idx (uniq_id, usr_id) +); +CREATE TABLE t2 ( +id INT unsigned NOT NULL DEFAULT 0, +usr2_id INT unsigned NOT NULL DEFAULT 0, +max INT unsigned NOT NULL DEFAULT 0, +c_amount INT unsigned NOT NULL DEFAULT 0, +d_max INT unsigned NOT NULL DEFAULT 0, +d_num INT unsigned NOT NULL DEFAULT 0, +orig_time INT unsigned NOT NULL DEFAULT 0, +c_time INT unsigned NOT NULL DEFAULT 0, +active ENUM ("no","yes") NOT NULL, +PRIMARY KEY (id,usr2_id), +INDEX id_idx (id), +INDEX usr2_idx (usr2_id) +); +INSERT INTO t1 VALUES (3,NULL,0,50),(3,NULL,0,200),(3,NULL,0,25),(3,NULL,0,84676),(3,NULL,0,235),(3,NULL,0,10),(3,NULL,0,3098),(3,NULL,0,2947),(3,NULL,0,8987),(3,NULL,0,8347654),(3,NULL,0,20398),(3,NULL,0,8976),(3,NULL,0,500),(3,NULL,0,198); +SELECT t1.usr_id,t1.uniq_id,t1.increment, +t2.usr2_id,t2.c_amount,t2.max +FROM t1 +LEFT JOIN t2 ON t2.id = t1.uniq_id +WHERE t1.uniq_id = 4 +ORDER BY t2.c_amount; +usr_id uniq_id increment usr2_id c_amount max +3 4 84676 NULL NULL NULL +SELECT t1.usr_id,t1.uniq_id,t1.increment, +t2.usr2_id,t2.c_amount,t2.max +FROM t2 +RIGHT JOIN t1 ON t2.id = t1.uniq_id +WHERE t1.uniq_id = 4 +ORDER BY t2.c_amount; +usr_id uniq_id increment usr2_id c_amount max +3 4 84676 NULL NULL NULL +INSERT INTO t2 VALUES (2,3,3000,6000,0,0,746584,837484,'yes'); +INSERT INTO t2 VALUES (2,3,3000,6000,0,0,746584,837484,'yes'); +ERROR 23000: Duplicate entry '2-3' for key 't2.PRIMARY' +INSERT INTO t2 VALUES (7,3,1000,2000,0,0,746294,937484,'yes'); +SELECT t1.usr_id,t1.uniq_id,t1.increment,t2.usr2_id,t2.c_amount,t2.max FROM t1 LEFT JOIN t2 ON t2.id = t1.uniq_id WHERE t1.uniq_id = 4 ORDER BY t2.c_amount; +usr_id uniq_id increment usr2_id c_amount max +3 4 84676 NULL NULL NULL +SELECT t1.usr_id,t1.uniq_id,t1.increment,t2.usr2_id,t2.c_amount,t2.max FROM t1 LEFT JOIN t2 ON t2.id = t1.uniq_id WHERE t1.uniq_id = 4 GROUP BY t2.c_amount; +usr_id uniq_id increment usr2_id c_amount max +3 4 84676 NULL NULL NULL +SELECT t1.usr_id,t1.uniq_id,t1.increment,t2.usr2_id,t2.c_amount,t2.max FROM t1 LEFT JOIN t2 ON t2.id = t1.uniq_id WHERE t1.uniq_id = 4; +usr_id uniq_id increment usr2_id c_amount max +3 4 84676 NULL NULL NULL +drop table t1,t2; +CREATE TABLE t1 ( +cod_asig int(11) DEFAULT '0' NOT NULL, +desc_larga_cat varchar(80) DEFAULT '' NOT NULL, +desc_larga_cas varchar(80) DEFAULT '' NOT NULL, +desc_corta_cat varchar(40) DEFAULT '' NOT NULL, +desc_corta_cas varchar(40) DEFAULT '' NOT NULL, +cred_total double(3,1) DEFAULT '0.0' NOT NULL, +pre_requisit int(11), +co_requisit int(11), +preco_requisit int(11), +PRIMARY KEY (cod_asig) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (10360,'asdfggfg','Introduccion a los Ordenadores I','asdfggfg','Introduccio Ordinadors I',6.0,NULL,NULL,NULL); +INSERT INTO t1 VALUES (10361,'Components i Circuits Electronics I','Componentes y Circuitos Electronicos I','Components i Circuits Electronics I','Comp. i Circ. Electr. I',6.0,NULL,NULL,NULL); +INSERT INTO t1 VALUES (10362,'Laboratori d`Ordinadors','Laboratorio de Ordenadores','Laboratori d`Ordinadors','Laboratori Ordinadors',4.5,NULL,NULL,NULL); +INSERT INTO t1 VALUES (10363,'Tecniques de Comunicacio Oral i Escrita','Tecnicas de Comunicacion Oral y Escrita','Tecniques de Comunicacio Oral i Escrita','Tec. Com. Oral i Escrita',4.5,NULL,NULL,NULL); +INSERT INTO t1 VALUES (11403,'Projecte Fi de Carrera','Proyecto Fin de Carrera','Projecte Fi de Carrera','PFC',9.0,NULL,NULL,NULL); +INSERT INTO t1 VALUES (11404,'+lgebra lineal','Algebra lineal','+lgebra lineal','+lgebra lineal',15.0,NULL,NULL,NULL); +INSERT INTO t1 VALUES (11405,'+lgebra lineal','Algebra lineal','+lgebra lineal','+lgebra lineal',18.0,NULL,NULL,NULL); +INSERT INTO t1 VALUES (11406,'Calcul Infinitesimal','Cßlculo Infinitesimal','Calcul Infinitesimal','Calcul Infinitesimal',15.0,NULL,NULL,NULL); +CREATE TABLE t2 ( +idAssignatura int(11) DEFAULT '0' NOT NULL, +Grup int(11) DEFAULT '0' NOT NULL, +Places smallint(6) DEFAULT '0' NOT NULL, +PlacesOcupades int(11) DEFAULT '0', +PRIMARY KEY (idAssignatura,Grup) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (10360,12,333,0); +INSERT INTO t2 VALUES (10361,30,2,0); +INSERT INTO t2 VALUES (10361,40,3,0); +INSERT INTO t2 VALUES (10360,45,10,0); +INSERT INTO t2 VALUES (10362,10,12,0); +INSERT INTO t2 VALUES (10360,55,2,0); +INSERT INTO t2 VALUES (10360,70,0,0); +INSERT INTO t2 VALUES (10360,565656,0,0); +INSERT INTO t2 VALUES (10360,32767,7,0); +INSERT INTO t2 VALUES (10360,33,8,0); +INSERT INTO t2 VALUES (10360,7887,85,0); +INSERT INTO t2 VALUES (11405,88,8,0); +INSERT INTO t2 VALUES (10360,0,55,0); +INSERT INTO t2 VALUES (10360,99,0,0); +INSERT INTO t2 VALUES (11411,30,10,0); +INSERT INTO t2 VALUES (11404,0,0,0); +INSERT INTO t2 VALUES (10362,11,111,0); +INSERT INTO t2 VALUES (10363,33,333,0); +INSERT INTO t2 VALUES (11412,55,0,0); +INSERT INTO t2 VALUES (50003,66,6,0); +INSERT INTO t2 VALUES (11403,5,0,0); +INSERT INTO t2 VALUES (11406,11,11,0); +INSERT INTO t2 VALUES (11410,11410,131,0); +INSERT INTO t2 VALUES (11416,11416,32767,0); +INSERT INTO t2 VALUES (11409,0,0,0); +CREATE TABLE t3 ( +id int(11) NOT NULL auto_increment, +dni_pasaporte char(16) DEFAULT '' NOT NULL, +idPla int(11) DEFAULT '0' NOT NULL, +cod_asig int(11) DEFAULT '0' NOT NULL, +any smallint(6) DEFAULT '0' NOT NULL, +quatrimestre smallint(6) DEFAULT '0' NOT NULL, +estat char(1) DEFAULT 'M' NOT NULL, +PRIMARY KEY (id), +UNIQUE dni_pasaporte (dni_pasaporte,idPla), +UNIQUE dni_pasaporte_2 (dni_pasaporte,idPla,cod_asig,any,quatrimestre) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t3 VALUES (1,'11111111',1,10362,98,1,'M'); +CREATE TABLE t4 ( +id int(11) NOT NULL auto_increment, +papa int(11) DEFAULT '0' NOT NULL, +fill int(11) DEFAULT '0' NOT NULL, +idPla int(11) DEFAULT '0' NOT NULL, +PRIMARY KEY (id), +KEY papa (idPla,papa), +UNIQUE papa_2 (idPla,papa,fill) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t4 VALUES (1,-1,10360,1); +INSERT INTO t4 VALUES (2,-1,10361,1); +INSERT INTO t4 VALUES (3,-1,10362,1); +SELECT DISTINCT fill,desc_larga_cat,cred_total,Grup,Places,PlacesOcupades FROM t4 LEFT JOIN t3 ON t3.cod_asig=fill AND estat='S' AND dni_pasaporte='11111111' AND t3.idPla=1 , t2,t1 WHERE fill=t1.cod_asig AND Places>PlacesOcupades AND fill=idAssignatura AND t4.idPla=1 AND papa=-1; +fill desc_larga_cat cred_total Grup Places PlacesOcupades +10360 asdfggfg 6.0 0 55 0 +10360 asdfggfg 6.0 12 333 0 +10360 asdfggfg 6.0 33 8 0 +10360 asdfggfg 6.0 45 10 0 +10360 asdfggfg 6.0 55 2 0 +10360 asdfggfg 6.0 7887 85 0 +10360 asdfggfg 6.0 32767 7 0 +10361 Components i Circuits Electronics I 6.0 30 2 0 +10361 Components i Circuits Electronics I 6.0 40 3 0 +10362 Laboratori d`Ordinadors 4.5 10 12 0 +10362 Laboratori d`Ordinadors 4.5 11 111 0 +SELECT DISTINCT fill,t3.idPla FROM t4 LEFT JOIN t3 ON t3.cod_asig=t4.fill AND t3.estat='S' AND t3.dni_pasaporte='1234' AND t3.idPla=1 ; +fill idPla +10360 NULL +10361 NULL +10362 NULL +INSERT INTO t3 VALUES (3,'1234',1,10360,98,1,'S'); +SELECT DISTINCT fill,t3.idPla FROM t4 LEFT JOIN t3 ON t3.cod_asig=t4.fill AND t3.estat='S' AND t3.dni_pasaporte='1234' AND t3.idPla=1 ; +fill idPla +10360 1 +10361 NULL +10362 NULL +drop table t1,t2,t3,test.t4; +CREATE TABLE t1 ( +id smallint(5) unsigned NOT NULL auto_increment, +name char(60) DEFAULT '' NOT NULL, +PRIMARY KEY (id) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (1,'Antonio Paz'); +INSERT INTO t1 VALUES (2,'Lilliana Angelovska'); +INSERT INTO t1 VALUES (3,'Thimble Smith'); +CREATE TABLE t2 ( +id smallint(5) unsigned NOT NULL auto_increment, +owner smallint(5) unsigned DEFAULT '0' NOT NULL, +name char(60), +PRIMARY KEY (id) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (1,1,'El Gato'); +INSERT INTO t2 VALUES (2,1,'Perrito'); +INSERT INTO t2 VALUES (3,3,'Happy'); +select t1.name, t2.name, t2.id from t1 left join t2 on (t1.id = t2.owner); +name name id +Antonio Paz El Gato 1 +Antonio Paz Perrito 2 +Lilliana Angelovska NULL NULL +Thimble Smith Happy 3 +select t1.name, t2.name, t2.id from t1 left join t2 on (t1.id = t2.owner) where t2.id is null; +name name id +Lilliana Angelovska NULL NULL +explain select t1.name, t2.name, t2.id from t1 left join t2 on (t1.id = t2.owner) where t2.id is null; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Not exists; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`name` AS `name`,`test`.`t2`.`name` AS `name`,`test`.`t2`.`id` AS `id` from `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`owner` = `test`.`t1`.`id`)) where (`test`.`t2`.`id` is null) +explain select t1.name, t2.name, t2.id from t1 left join t2 on (t1.id = t2.owner) where t2.name is null; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`name` AS `name`,`test`.`t2`.`name` AS `name`,`test`.`t2`.`id` AS `id` from `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`owner` = `test`.`t1`.`id`)) where (`test`.`t2`.`name` is null) +select count(*) from t1 left join t2 on (t1.id = t2.owner); +count(*) +4 +select t1.name, t2.name, t2.id from t2 right join t1 on (t1.id = t2.owner); +name name id +Antonio Paz El Gato 1 +Antonio Paz Perrito 2 +Lilliana Angelovska NULL NULL +Thimble Smith Happy 3 +select t1.name, t2.name, t2.id from t2 right join t1 on (t1.id = t2.owner) where t2.id is null; +name name id +Lilliana Angelovska NULL NULL +explain select t1.name, t2.name, t2.id from t2 right join t1 on (t1.id = t2.owner) where t2.id is null; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Not exists; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`name` AS `name`,`test`.`t2`.`name` AS `name`,`test`.`t2`.`id` AS `id` from `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`owner` = `test`.`t1`.`id`)) where (`test`.`t2`.`id` is null) +explain select t1.name, t2.name, t2.id from t2 right join t1 on (t1.id = t2.owner) where t2.name is null; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`name` AS `name`,`test`.`t2`.`name` AS `name`,`test`.`t2`.`id` AS `id` from `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`owner` = `test`.`t1`.`id`)) where (`test`.`t2`.`name` is null) +select count(*) from t2 right join t1 on (t1.id = t2.owner); +count(*) +4 +select t1.name, t2.name, t2.id,t3.id from t2 right join t1 on (t1.id = t2.owner) left join t1 as t3 on t3.id=t2.owner; +name name id id +Antonio Paz El Gato 1 1 +Antonio Paz Perrito 2 1 +Lilliana Angelovska NULL NULL NULL +Thimble Smith Happy 3 3 +select t1.name, t2.name, t2.id,t3.id from t1 right join t2 on (t1.id = t2.owner) right join t1 as t3 on t3.id=t2.owner; +name name id id +Antonio Paz El Gato 1 1 +Antonio Paz Perrito 2 1 +NULL NULL NULL 2 +Thimble Smith Happy 3 3 +explain format=tree select t1.name, t2.name, t2.id, t2.owner, t3.id from t1 left join t2 on (t1.id = t2.owner) right join t1 as t3 on t3.id=t2.owner; +EXPLAIN +-> Parallel scan on + -> Nested loop left join (cost=2.20 rows=9) + -> PQblock scan on t3 using PRIMARY (cost=0.55 rows=3) + -> Nested loop inner join (cost=0.83 rows=3) + -> Single-row index lookup on t1 using PRIMARY (id=t3.id) (cost=0.28 rows=1) + -> Filter: (t2.`owner` = t3.id) (cost=0.18 rows=3) + -> Table scan on t2 (cost=0.18 rows=3) + +select t1.name, t2.name, t2.id, t2.owner, t3.id from t1 left join t2 on (t1.id = t2.owner) right join t1 as t3 on t3.id=t2.owner; +name name id owner id +Antonio Paz El Gato 1 1 1 +Antonio Paz Perrito 2 1 1 +NULL NULL NULL NULL 2 +Thimble Smith Happy 3 3 3 +drop table t1,t2; +create table t1 (id int not null, str char(10), index(str)); +insert into t1 values (1, null), (2, null), (3, "foo"), (4, "bar"); +select * from t1 where str is not null order by id; +id str +3 foo +4 bar +select * from t1 where str is null; +id str +1 NULL +2 NULL +explain select * from t1 where str is null; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref str str 41 const 2 100.00 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,`test`.`t1`.`str` AS `str` from `test`.`t1` where (`test`.`t1`.`str` is null) +explain format=tree select * from t1 where str is null; +EXPLAIN +-> Parallel scan on + -> PQblock lookup on t1 using str (str=NULL), with index condition: (t1.str is null) (cost=0.70 rows=2) + +drop table t1; +CREATE TABLE t1 ( +t1_id bigint(21) NOT NULL auto_increment, +PRIMARY KEY (t1_id) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t2 ( +t2_id bigint(21) NOT NULL auto_increment, +PRIMARY KEY (t2_id) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t3 ( +t3_id bigint(21) NOT NULL auto_increment, +PRIMARY KEY (t3_id) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t4 ( +seq_0_id bigint(21) DEFAULT '0' NOT NULL, +seq_1_id bigint(21) DEFAULT '0' NOT NULL, +KEY seq_0_id (seq_0_id), +KEY seq_1_id (seq_1_id) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t5 ( +seq_0_id bigint(21) DEFAULT '0' NOT NULL, +seq_1_id bigint(21) DEFAULT '0' NOT NULL, +KEY seq_1_id (seq_1_id), +KEY seq_0_id (seq_0_id) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t1 values (1); +insert into t2 values (1); +insert into t3 values (1); +insert into t4 values (1,1); +insert into t5 values (1,1); +explain select * from t3 left join t4 on t4.seq_1_id = t2.t2_id left join t1 on t1.t1_id = t4.seq_0_id left join t5 on t5.seq_0_id = t1.t1_id left join t2 on t2.t2_id = t5.seq_1_id where t3.t3_id = 23; +ERROR 42S22: Unknown column 't2.t2_id' in 'on clause' +drop table t1,t2,t3,t4,t5; +create table t1 (n int, m int, o int, key(n)); +create table t2 (n int not null, m int, o int, primary key(n)); +insert into t1 values (1, 2, 11), (1, 2, 7), (2, 2, 8), (1,2,9),(1,3,9); +insert into t2 values (1, 2, 3),(2, 2, 8), (4,3,9),(3,2,10); +select t1.*, t2.* from t1 left join t2 on t1.n = t2.n and +t1.m = t2.m where t1.n = 1; +n m o n m o +1 2 11 1 2 3 +1 2 7 1 2 3 +1 2 9 1 2 3 +1 3 9 NULL NULL NULL +select t1.*, t2.* from t1 left join t2 on t1.n = t2.n and +t1.m = t2.m where t1.n = 1 order by t1.o,t1.m; +n m o n m o +1 2 7 1 2 3 +1 2 9 1 2 3 +1 3 9 NULL NULL NULL +1 2 11 1 2 3 +drop table t1,t2; +CREATE TABLE t1 (id1 INT NOT NULL PRIMARY KEY, dat1 CHAR(1), id2 INT); +INSERT INTO t1 VALUES (1,'a',1); +INSERT INTO t1 VALUES (2,'b',1); +INSERT INTO t1 VALUES (3,'c',2); +CREATE TABLE t2 (id2 INT NOT NULL PRIMARY KEY, dat2 CHAR(1)); +INSERT INTO t2 VALUES (1,'x'); +INSERT INTO t2 VALUES (2,'y'); +INSERT INTO t2 VALUES (3,'z'); +SELECT t2.id2 FROM t2 LEFT OUTER JOIN t1 ON t1.id2 = t2.id2 WHERE id1 IS NULL; +id2 +3 +SELECT t2.id2 FROM t2 NATURAL LEFT OUTER JOIN t1 WHERE id1 IS NULL; +id2 +3 +drop table t1,t2; +create table t1 ( color varchar(20), name varchar(20) ); +insert into t1 values ( 'red', 'apple' ); +insert into t1 values ( 'yellow', 'banana' ); +insert into t1 values ( 'green', 'lime' ); +insert into t1 values ( 'black', 'grape' ); +insert into t1 values ( 'blue', 'blueberry' ); +create table t2 ( count int, color varchar(20) ); +insert into t2 values (10, 'green'); +insert into t2 values (5, 'black'); +insert into t2 values (15, 'white'); +insert into t2 values (7, 'green'); +select * from t1; +color name +red apple +yellow banana +green lime +black grape +blue blueberry +select * from t2; +count color +10 green +5 black +15 white +7 green +select * from t2 natural join t1; +color count name +black 5 grape +green 10 lime +green 7 lime +select t2.count, t1.name from t2 natural join t1; +count name +10 lime +5 grape +7 lime +select t2.count, t1.name from t2 inner join t1 using (color); +count name +10 lime +5 grape +7 lime +drop table t1; +drop table t2; +CREATE TABLE t1 ( +pcode varchar(8) DEFAULT '' NOT NULL +); +INSERT INTO t1 VALUES ('kvw2000'),('kvw2001'),('kvw3000'),('kvw3001'),('kvw3002'),('kvw3500'),('kvw3501'),('kvw3502'),('kvw3800'),('kvw3801'),('kvw3802'),('kvw3900'),('kvw3901'),('kvw3902'),('kvw4000'),('kvw4001'),('kvw4002'),('kvw4200'),('kvw4500'),('kvw5000'),('kvw5001'),('kvw5500'),('kvw5510'),('kvw5600'),('kvw5601'),('kvw6000'),('klw1000'),('klw1020'),('klw1500'),('klw2000'),('klw2001'),('klw2002'),('kld2000'),('klw2500'),('kmw1000'),('kmw1500'),('kmw2000'),('kmw2001'),('kmw2100'),('kmw3000'),('kmw3200'); +CREATE TABLE t2 ( +pcode varchar(8) DEFAULT '' NOT NULL, +KEY pcode (pcode) +); +INSERT INTO t2 VALUES ('kvw2000'),('kvw2000'),('kvw2000'),('kvw2000'),('kvw2000'),('kvw2000'),('kvw2000'),('kvw2000'),('kvw2000'),('kvw2000'),('kvw2000'),('kvw2000'),('kvw2000'),('kvw2000'),('kvw2000'),('kvw2000'),('kvw2000'),('kvw2000'),('kvw2000'),('kvw2000'),('kvw2000'),('kvw2000'),('kvw2000'),('kvw2000'),('kvw2000'),('kvw2000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw6000'),('kvw6000'),('kld2000'); +SELECT t1.pcode, IF(ISNULL(t2.pcode), 0, COUNT(*)) AS count FROM t1 +LEFT JOIN t2 ON t1.pcode = t2.pcode GROUP BY t1.pcode; +pcode count +kld2000 1 +klw1000 0 +klw1020 0 +klw1500 0 +klw2000 0 +klw2001 0 +klw2002 0 +klw2500 0 +kmw1000 0 +kmw1500 0 +kmw2000 0 +kmw2001 0 +kmw2100 0 +kmw3000 0 +kmw3200 0 +kvw2000 26 +kvw2001 0 +kvw3000 36 +kvw3001 0 +kvw3002 0 +kvw3500 26 +kvw3501 0 +kvw3502 0 +kvw3800 0 +kvw3801 0 +kvw3802 0 +kvw3900 0 +kvw3901 0 +kvw3902 0 +kvw4000 0 +kvw4001 0 +kvw4002 0 +kvw4200 0 +kvw4500 0 +kvw5000 0 +kvw5001 0 +kvw5500 0 +kvw5510 0 +kvw5600 0 +kvw5601 0 +kvw6000 2 +SELECT SQL_BIG_RESULT t1.pcode, IF(ISNULL(t2.pcode), 0, COUNT(*)) AS count FROM t1 LEFT JOIN t2 ON t1.pcode = t2.pcode GROUP BY t1.pcode; +pcode count +kld2000 1 +klw1000 0 +klw1020 0 +klw1500 0 +klw2000 0 +klw2001 0 +klw2002 0 +klw2500 0 +kmw1000 0 +kmw1500 0 +kmw2000 0 +kmw2001 0 +kmw2100 0 +kmw3000 0 +kmw3200 0 +kvw2000 26 +kvw2001 0 +kvw3000 36 +kvw3001 0 +kvw3002 0 +kvw3500 26 +kvw3501 0 +kvw3502 0 +kvw3800 0 +kvw3801 0 +kvw3802 0 +kvw3900 0 +kvw3901 0 +kvw3902 0 +kvw4000 0 +kvw4001 0 +kvw4002 0 +kvw4200 0 +kvw4500 0 +kvw5000 0 +kvw5001 0 +kvw5500 0 +kvw5510 0 +kvw5600 0 +kvw5601 0 +kvw6000 2 +drop table t1,t2; +SET sql_mode = 'NO_ENGINE_SUBSTITUTION'; +CREATE TABLE t1 ( +id int(11), +pid int(11), +rep_del tinyint(4), +KEY id (id), +KEY pid (pid) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (1,NULL,NULL); +INSERT INTO t1 VALUES (2,1,NULL); +select * from t1 LEFT JOIN t1 t2 ON (t1.id=t2.pid) AND t2.rep_del IS NULL; +id pid rep_del id pid rep_del +1 NULL NULL 2 1 NULL +2 1 NULL NULL NULL NULL +create index rep_del ON t1(rep_del); +select * from t1 LEFT JOIN t1 t2 ON (t1.id=t2.pid) AND t2.rep_del IS NULL; +id pid rep_del id pid rep_del +1 NULL NULL 2 1 NULL +2 1 NULL NULL NULL NULL +drop table t1; +CREATE TABLE t1 ( +id int(11) DEFAULT '0' NOT NULL, +name tinytext DEFAULT '' NOT NULL, +UNIQUE id (id) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1101 BLOB, TEXT, GEOMETRY or JSON column 'name' can't have a default value +INSERT INTO t1 VALUES (1,'yes'),(2,'no'); +CREATE TABLE t2 ( +id int(11) DEFAULT '0' NOT NULL, +idx int(11) DEFAULT '0' NOT NULL, +UNIQUE id (id,idx) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (1,1); +explain SELECT * from t1 left join t2 on t1.id=t2.id where t2.id IS NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ref id id 4 test.t1.id 1 100.00 Using where; Not exists; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,`test`.`t1`.`name` AS `name`,`test`.`t2`.`id` AS `id`,`test`.`t2`.`idx` AS `idx` from `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`id` = `test`.`t1`.`id`)) where (`test`.`t2`.`id` is null) +SELECT * from t1 left join t2 on t1.id=t2.id where t2.id IS NULL; +id name id idx +2 no NULL NULL +drop table t1,t2; +SET sql_mode = default; +create table t1 (bug_id mediumint, reporter mediumint); +create table t2 (bug_id mediumint, who mediumint, index(who)); +insert into t2 values (1,1),(1,2); +insert into t1 values (1,1),(2,1); +SELECT * FROM t1 LEFT JOIN t2 ON (t1.bug_id = t2.bug_id AND t2.who = 2) WHERE (t1.reporter = 2 OR t2.who = 2); +bug_id reporter bug_id who +1 1 1 2 +drop table t1,t2; +create table t1 (fooID smallint unsigned auto_increment, primary key (fooID)); +create table t2 (fooID smallint unsigned not null, barID smallint unsigned not null, primary key (fooID,barID)); +insert into t1 (fooID) values (10),(20),(30); +insert into t2 values (10,1),(20,2),(30,3); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +explain select * from t2 left join t1 on t1.fooID = t2.fooID and t1.fooID = 30; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL index NULL PRIMARY 4 NULL 3 100.00 Using index +2 SIMPLE t1 NULL const PRIMARY PRIMARY 2 const 1 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`fooID` AS `fooID`,`test`.`t2`.`barID` AS `barID`,`test`.`t1`.`fooID` AS `fooID` from `test`.`t2` left join `test`.`t1` on(((`test`.`t2`.`fooID` = 30) and (`test`.`t1`.`fooID` = 30))) where true +select * from t2 left join t1 on t1.fooID = t2.fooID and t1.fooID = 30; +fooID barID fooID +10 1 NULL +20 2 NULL +30 3 30 +select * from t2 left join t1 ignore index(primary) on t1.fooID = t2.fooID and t1.fooID = 30; +fooID barID fooID +10 1 NULL +20 2 NULL +30 3 30 +drop table t1,t2; +create table t1 (i int); +create table t2 (i int); +create table t3 (i int); +insert into t1 values(1),(2); +insert into t2 values(2),(3); +insert into t3 values(2),(4); +select * from t1 natural left join t2 natural left join t3; +i +1 +2 +select * from t1 natural left join t2 where (t2.i is not null)=0; +i +1 +select * from t1 natural left join t2 where (t2.i is not null) is not null; +i +1 +2 +select * from t1 natural left join t2 where (i is not null)=0; +i +select * from t1 natural left join t2 where (i is not null) is not null; +i +1 +2 +drop table t1,t2,t3; +create table t1 (f1 integer,f2 integer,f3 integer); +create table t2 (f2 integer,f4 integer); +create table t3 (f3 integer,f5 integer); +select * from t1 +left outer join t2 using (f2) +left outer join t3 using (f3); +f3 f2 f1 f4 f5 +drop table t1,t2,t3; +create table t1 (a1 int, a2 int); +create table t2 (b1 int not null, b2 int); +create table t3 (c1 int, c2 int); +insert into t1 values (1,2), (2,2), (3,2); +insert into t2 values (1,3), (2,3); +insert into t3 values (2,4), (3,4); +ANALYZE TABLE t1, t2, t3; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +select * from t1 left join t2 on b1 = a1 left join t3 on c1 = a1 and b1 is null; +a1 a2 b1 b2 c1 c2 +1 2 1 3 NULL NULL +2 2 2 3 NULL NULL +3 2 NULL NULL 3 4 +explain select * from t1 left join t2 on b1 = a1 left join t3 on c1 = a1 and b1 is null; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,`test`.`t2`.`b1` AS `b1`,`test`.`t2`.`b2` AS `b2`,`test`.`t3`.`c1` AS `c1`,`test`.`t3`.`c2` AS `c2` from `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`b1` = `test`.`t1`.`a1`)) left join `test`.`t3` on(((`test`.`t3`.`c1` = `test`.`t1`.`a1`) and (`test`.`t2`.`b1` is null))) where true +drop table t1, t2, t3; +create table t1 ( +a int(11), +b char(10), +key (a) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t1 (a) values (1),(2),(3),(4); +create table t2 (a int); +select * from t1 left join t2 on t1.a=t2.a where not (t2.a <=> t1.a); +a b a +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +select * from t1 left join t2 on t1.a=t2.a having not (t2.a <=> t1.a); +a b a +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +drop table t1,t2; +create table t1 ( +match_id tinyint(3) unsigned not null auto_increment, +home tinyint(3) unsigned default '0', +unique key match_id (match_id), +key match_id_2 (match_id) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t1 values("1", "2"); +create table t2 ( +player_id tinyint(3) unsigned default '0', +match_1_h tinyint(3) unsigned default '0', +key player_id (player_id) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t2 values("1", "5"); +insert into t2 values("2", "9"); +insert into t2 values("3", "3"); +insert into t2 values("4", "7"); +insert into t2 values("5", "6"); +insert into t2 values("6", "8"); +insert into t2 values("7", "4"); +insert into t2 values("8", "12"); +insert into t2 values("9", "11"); +insert into t2 values("10", "10"); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +explain select s.*, '*', m.*, (s.match_1_h - m.home) UUX from +(t2 s left join t1 m on m.match_id = 1) +order by m.match_id desc; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 100.00 Parallel execute (1 workers) +2 SIMPLE s NULL ALL NULL NULL NULL NULL 10 100.00 Using temporary; Using filesort +2 SIMPLE m NULL const match_id,match_id_2 match_id 1 const 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`s`.`player_id` AS `player_id`,`test`.`s`.`match_1_h` AS `match_1_h`,'*' AS `*`,`test`.`m`.`match_id` AS `match_id`,`test`.`m`.`home` AS `home`,(`test`.`s`.`match_1_h` - `test`.`m`.`home`) AS `UUX` from `test`.`t2` `s` left join `test`.`t1` `m` on((`test`.`m`.`match_id` = 1)) where true order by `test`.`m`.`match_id` desc +explain select s.*, '*', m.*, (s.match_1_h - m.home) UUX from +(t2 s left join t1 m on m.match_id = 1) +order by UUX desc; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 100.00 Parallel execute (1 workers) +2 SIMPLE s NULL ALL NULL NULL NULL NULL 10 100.00 Using temporary; Using filesort +2 SIMPLE m NULL const match_id,match_id_2 match_id 1 const 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`s`.`player_id` AS `player_id`,`test`.`s`.`match_1_h` AS `match_1_h`,'*' AS `*`,`test`.`m`.`match_id` AS `match_id`,`test`.`m`.`home` AS `home`,(`test`.`s`.`match_1_h` - `test`.`m`.`home`) AS `UUX` from `test`.`t2` `s` left join `test`.`t1` `m` on((`test`.`m`.`match_id` = 1)) where true order by `UUX` desc +select s.*, '*', m.*, (s.match_1_h - m.home) UUX from +(t2 s left join t1 m on m.match_id = 1) +order by UUX desc; +player_id match_1_h * match_id home UUX +8 12 * 1 2 10 +9 11 * 1 2 9 +10 10 * 1 2 8 +2 9 * 1 2 7 +6 8 * 1 2 6 +4 7 * 1 2 5 +5 6 * 1 2 4 +1 5 * 1 2 3 +7 4 * 1 2 2 +3 3 * 1 2 1 +explain select s.*, '*', m.*, (s.match_1_h - m.home) UUX from +t2 s straight_join t1 m where m.match_id = 1 +order by UUX desc; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 100.00 Parallel execute (1 workers) +2 SIMPLE s NULL ALL NULL NULL NULL NULL 10 100.00 Using temporary; Using filesort +2 SIMPLE m NULL const match_id,match_id_2 match_id 1 const 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`s`.`player_id` AS `player_id`,`test`.`s`.`match_1_h` AS `match_1_h`,'*' AS `*`,`test`.`m`.`match_id` AS `match_id`,`test`.`m`.`home` AS `home`,(`test`.`s`.`match_1_h` - `test`.`m`.`home`) AS `UUX` from `test`.`t2` `s` straight_join `test`.`t1` `m` where (`test`.`m`.`match_id` = 1) order by `UUX` desc +select s.*, '*', m.*, (s.match_1_h - m.home) UUX from +t2 s straight_join t1 m where m.match_id = 1 +order by UUX desc; +player_id match_1_h * match_id home UUX +8 12 * 1 2 10 +9 11 * 1 2 9 +10 10 * 1 2 8 +2 9 * 1 2 7 +6 8 * 1 2 6 +4 7 * 1 2 5 +5 6 * 1 2 4 +1 5 * 1 2 3 +7 4 * 1 2 2 +3 3 * 1 2 1 +drop table t1, t2; +create table t1 (a int, b int, unique index idx (a, b)); +create table t2 (a int, b int, c int, unique index idx (a, b)); +insert into t1 values (1, 10), (1,11), (2,10), (2,11); +insert into t2 values (1,10,3); +select t1.a, t1.b, t2.c from t1 left join t2 +on t1.a=t2.a and t1.b=t2.b and t2.c=3 +where t1.a=1 and t2.c is null; +a b c +1 11 NULL +drop table t1, t2; +CREATE TABLE t1 ( +ts_id bigint(20) default NULL, +inst_id tinyint(4) default NULL, +flag_name varchar(64) default NULL, +flag_value text, +UNIQUE KEY ts_id (ts_id,inst_id,flag_name) +) ENGINE=MyISAM DEFAULT CHARSET=utf8; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +CREATE TABLE t2 ( +ts_id bigint(20) default NULL, +inst_id tinyint(4) default NULL, +flag_name varchar(64) default NULL, +flag_value text, +UNIQUE KEY ts_id (ts_id,inst_id,flag_name) +) ENGINE=MyISAM DEFAULT CHARSET=utf8; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES +(111056548820001, 0, 'flag1', NULL), +(111056548820001, 0, 'flag2', NULL), +(2, 0, 'other_flag', NULL); +INSERT INTO t2 VALUES +(111056548820001, 3, 'flag1', 'sss'); +SELECT t1.flag_name,t2.flag_value +FROM t1 LEFT JOIN t2 +ON (t1.ts_id = t2.ts_id AND t1.flag_name = t2.flag_name AND +t2.inst_id = 3) +WHERE t1.inst_id = 0 AND t1.ts_id=111056548820001 AND +t2.flag_value IS NULL; +flag_name flag_value +flag2 NULL +DROP TABLE t1,t2; +CREATE TABLE t1 ( +id int(11) unsigned NOT NULL auto_increment, +text_id int(10) unsigned default NULL, +PRIMARY KEY (id) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES("1", "0"); +INSERT INTO t1 VALUES("2", "10"); +CREATE TABLE t2 ( +text_id char(3) NOT NULL default '', +language_id char(3) NOT NULL default '', +text_data text, +PRIMARY KEY (text_id,language_id) +); +INSERT INTO t2 VALUES("0", "EN", "0-EN"); +INSERT INTO t2 VALUES("0", "SV", "0-SV"); +INSERT INTO t2 VALUES("10", "EN", "10-EN"); +INSERT INTO t2 VALUES("10", "SV", "10-SV"); +SELECT t1.id, t1.text_id, t2.text_data +FROM t1 LEFT JOIN t2 +ON t1.text_id = t2.text_id +AND t2.language_id = 'SV' + WHERE (t1.id LIKE '%' OR t2.text_data LIKE '%'); +id text_id text_data +1 0 0-SV +2 10 10-SV +DROP TABLE t1, t2; +CREATE TABLE t0 (a0 int PRIMARY KEY); +CREATE TABLE t1 (a1 int PRIMARY KEY); +CREATE TABLE t2 (a2 int); +CREATE TABLE t3 (a3 int); +INSERT INTO t0 VALUES (1); +INSERT INTO t1 VALUES (1); +INSERT INTO t2 VALUES (1), (2); +INSERT INTO t3 VALUES (1), (2); +SELECT * FROM t1 LEFT JOIN t2 ON a1=0; +a1 a2 +1 NULL +EXPLAIN SELECT * FROM t1 LEFT JOIN t2 ON a1=0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL PRIMARY 4 NULL 1 100.00 Using index +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t2`.`a2` AS `a2` from `test`.`t1` left join `test`.`t2` on((`test`.`t1`.`a1` = 0)) where true +SELECT * FROM t1 LEFT JOIN (t2,t3) ON a1=0; +a1 a2 a3 +1 NULL NULL +EXPLAIN SELECT * FROM t1 LEFT JOIN (t2,t3) ON a1=0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL PRIMARY 4 NULL 1 100.00 Using index +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t2`.`a2` AS `a2`,`test`.`t3`.`a3` AS `a3` from `test`.`t1` left join (`test`.`t2` join `test`.`t3`) on((`test`.`t1`.`a1` = 0)) where true +SELECT * FROM t0, t1 LEFT JOIN (t2,t3) ON a1=0 WHERE a0=a1; +a0 a1 a2 a3 +1 1 NULL NULL +EXPLAIN SELECT * FROM t0, t1 LEFT JOIN (t2,t3) ON a1=0 WHERE a0=a1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t0 NULL index PRIMARY PRIMARY 4 NULL 1 100.00 Using index +2 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t0.a0 1 100.00 Using index +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`a0` AS `a0`,`test`.`t1`.`a1` AS `a1`,`test`.`t2`.`a2` AS `a2`,`test`.`t3`.`a3` AS `a3` from `test`.`t0` join `test`.`t1` left join (`test`.`t2` join `test`.`t3`) on(((`test`.`t0`.`a0` = 0) and (`test`.`t1`.`a1` = 0))) where (`test`.`t1`.`a1` = `test`.`t0`.`a0`) +INSERT INTO t0 VALUES (0); +INSERT INTO t1 VALUES (0); +SELECT * FROM t0, t1 LEFT JOIN (t2,t3) ON a1=5 WHERE a0=a1 AND a0=1; +a0 a1 a2 a3 +1 1 NULL NULL +EXPLAIN SELECT * FROM t0, t1 LEFT JOIN (t2,t3) ON a1=5 WHERE a0=a1 AND a0=1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL const PRIMARY PRIMARY 4 const 1 100.00 Using index +1 SIMPLE t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 Using index +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select '1' AS `a0`,'1' AS `a1`,`test`.`t2`.`a2` AS `a2`,`test`.`t3`.`a3` AS `a3` from `test`.`t0` join `test`.`t1` left join (`test`.`t2` join `test`.`t3`) on(false) where true +drop table t1,t2; +create table t1 (a int, b int); +insert into t1 values (1,1),(2,2),(3,3); +create table t2 (a int, b int); +insert into t2 values (1,1), (2,2); +select * from t2 right join t1 on t2.a=t1.a; +a b a b +1 1 1 1 +2 2 2 2 +NULL NULL 3 3 +select straight_join * from t2 right join t1 on t2.a=t1.a; +a b a b +1 1 1 1 +2 2 2 2 +NULL NULL 3 3 +DROP TABLE t0,t1,t2,t3; +CREATE TABLE t1 (a int PRIMARY KEY, b int); +CREATE TABLE t2 (a int PRIMARY KEY, b int); +INSERT INTO t1 VALUES (1,1), (2,1), (3,1), (4,2); +INSERT INTO t2 VALUES (1,2), (2,2); +SELECT * FROM t1 LEFT JOIN t2 ON t1.a=t2.a; +a b a b +1 1 1 2 +2 1 2 2 +3 1 NULL NULL +4 2 NULL NULL +SELECT * FROM t1 LEFT JOIN t2 ON t1.a=t2.a WHERE t1.b=1; +a b a b +1 1 1 2 +2 1 2 2 +3 1 NULL NULL +SELECT * FROM t1 LEFT JOIN t2 ON t1.a=t2.a +WHERE t1.b=1 XOR (NOT ISNULL(t2.a) AND t2.b=1); +a b a b +1 1 1 2 +2 1 2 2 +3 1 NULL NULL +SELECT * FROM t1 LEFT JOIN t2 ON t1.a=t2.a WHERE not(0+(t1.a=30 and t2.b=1)); +a b a b +1 1 1 2 +2 1 2 2 +3 1 NULL NULL +4 2 NULL NULL +DROP TABLE t1,t2; +set group_concat_max_len=5; +create table t1 (a int, b varchar(20)); +create table t2 (a int, c varchar(20)); +insert into t1 values (1,"aaaaaaaaaa"),(2,"bbbbbbbbbb"); +insert into t2 values (1,"cccccccccc"),(2,"dddddddddd"); +select group_concat(t1.b,t2.c) from t1 left join t2 using(a) group by t1.a; +group_concat(t1.b,t2.c) +aaaaa +bbbbb +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +select group_concat(t1.b,t2.c) from t1 inner join t2 using(a) group by t1.a; +group_concat(t1.b,t2.c) +aaaaa +bbbbb +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +select group_concat(t1.b,t2.c) from t1 left join t2 using(a) group by a; +group_concat(t1.b,t2.c) +aaaaa +bbbbb +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +select group_concat(t1.b,t2.c) from t1 inner join t2 using(a) group by a; +group_concat(t1.b,t2.c) +aaaaa +bbbbb +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +drop table t1, t2; +set group_concat_max_len=default; +create table t1 (gid smallint(5) unsigned not null, x int(11) not null, y int(11) not null, art int(11) not null, primary key (gid,x,y)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert t1 values (1, -5, -8, 2), (1, 2, 2, 1), (1, 1, 1, 1); +create table t2 (gid smallint(5) unsigned not null, x int(11) not null, y int(11) not null, id int(11) not null, primary key (gid,id,x,y), key id (id)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert t2 values (1, -5, -8, 1), (1, 1, 1, 1), (1, 2, 2, 1); +create table t3 ( set_id smallint(5) unsigned not null, id tinyint(4) unsigned not null, name char(12) not null, primary key (id,set_id)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert t3 values (0, 1, 'a'), (1, 1, 'b'), (0, 2, 'c'), (1, 2, 'd'), (1, 3, 'e'), (1, 4, 'f'), (1, 5, 'g'), (1, 6, 'h'); +explain select name from t1 left join t2 on t1.x = t2.x and t1.y = t2.y +left join t3 on t1.art = t3.id where t2.id =1 and t2.x = -5 and t2.y =-8 +and t1.gid =1 and t2.gid =1 and t3.set_id =1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL const PRIMARY PRIMARY 10 const,const,const 1 100.00 NULL +1 SIMPLE t2 NULL const PRIMARY,id PRIMARY 14 const,const,const,const 1 100.00 Using index +1 SIMPLE t3 NULL const PRIMARY PRIMARY 3 const,const 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select 'd' AS `name` from `test`.`t1` join `test`.`t2` join `test`.`t3` where true +drop tables t1,t2,t3; +CREATE TABLE t1 (EMPNUM INT, GRP INT); +INSERT INTO t1 VALUES (0, 10); +INSERT INTO t1 VALUES (2, 30); +CREATE TABLE t2 (EMPNUM INT, NAME CHAR(5)); +INSERT INTO t2 VALUES (0, 'KERI'); +INSERT INTO t2 VALUES (9, 'BARRY'); +CREATE VIEW v1 AS +SELECT COALESCE(t2.EMPNUM,t1.EMPNUM) AS EMPNUM, NAME, GRP +FROM t2 LEFT OUTER JOIN t1 ON t2.EMPNUM=t1.EMPNUM; +SELECT * FROM v1; +EMPNUM NAME GRP +0 KERI 10 +9 BARRY NULL +SELECT * FROM v1 WHERE EMPNUM < 10; +EMPNUM NAME GRP +0 KERI 10 +9 BARRY NULL +DROP VIEW v1; +DROP TABLE t1,t2; +CREATE TABLE t1 (c11 int); +CREATE TABLE t2 (c21 int); +INSERT INTO t1 VALUES (30), (40), (50); +INSERT INTO t2 VALUES (300), (400), (500); +SELECT * FROM t1 LEFT JOIN t2 ON (c11=c21 AND c21=30) WHERE c11=40; +c11 c21 +40 NULL +DROP TABLE t1, t2; +CREATE TABLE t1 (a int PRIMARY KEY, b int); +CREATE TABLE t2 (a int PRIMARY KEY, b int); +INSERT INTO t1 VALUES (1,2), (2,1), (3,2), (4,3), (5,6), (6,5), (7,8), (8,7), (9,10); +INSERT INTO t2 VALUES (3,0), (4,1), (6,4), (7,5); +SELECT * FROM t1 LEFT JOIN t2 ON t1.a = t2.a WHERE t2.b <= t1.a AND t1.a <= t1.b; +a b a b +7 8 7 5 +SELECT * FROM t1 LEFT JOIN t2 ON t1.a = t2.a WHERE t1.a BETWEEN t2.b AND t1.b; +a b a b +7 8 7 5 +SELECT * FROM t1 LEFT JOIN t2 ON t1.a = t2.a WHERE NOT(t1.a NOT BETWEEN t2.b AND t1.b); +a b a b +7 8 7 5 +SELECT * FROM t1 LEFT JOIN t2 ON t1.a = t2.a WHERE t2.b > t1.a OR t1.a > t1.b; +a b a b +2 1 NULL NULL +3 2 3 0 +4 3 4 1 +6 5 6 4 +8 7 NULL NULL +SELECT * FROM t1 LEFT JOIN t2 ON t1.a = t2.a WHERE t1.a NOT BETWEEN t2.b AND t1.b; +a b a b +2 1 NULL NULL +3 2 3 0 +4 3 4 1 +6 5 6 4 +8 7 NULL NULL +SELECT * FROM t1 LEFT JOIN t2 ON t1.a = t2.a WHERE NOT(t1.a BETWEEN t2.b AND t1.b); +a b a b +2 1 NULL NULL +3 2 3 0 +4 3 4 1 +6 5 6 4 +8 7 NULL NULL +SELECT * FROM t1 LEFT JOIN t2 ON t1.a = t2.a WHERE t1.a = t2.a OR t2.b > t1.a OR t1.a > t1.b; +a b a b +2 1 NULL NULL +3 2 3 0 +4 3 4 1 +6 5 6 4 +7 8 7 5 +8 7 NULL NULL +SELECT * FROM t1 LEFT JOIN t2 ON t1.a = t2.a WHERE NOT(t1.a != t2.a AND t1.a BETWEEN t2.b AND t1.b); +a b a b +2 1 NULL NULL +3 2 3 0 +4 3 4 1 +6 5 6 4 +7 8 7 5 +8 7 NULL NULL +SELECT * FROM t1 LEFT JOIN t2 ON t1.a = t2.a WHERE t1.a = t2.a AND (t2.b > t1.a OR t1.a > t1.b); +a b a b +3 2 3 0 +4 3 4 1 +6 5 6 4 +SELECT * FROM t1 LEFT JOIN t2 ON t1.a = t2.a WHERE NOT(t1.a != t2.a OR t1.a BETWEEN t2.b AND t1.b); +a b a b +3 2 3 0 +4 3 4 1 +6 5 6 4 +SELECT * FROM t1 LEFT JOIN t2 ON t1.a = t2.a WHERE t1.a = t2.a OR t1.a = t2.b; +a b a b +3 2 3 0 +4 3 4 1 +6 5 6 4 +7 8 7 5 +SELECT * FROM t1 LEFT JOIN t2 ON t1.a = t2.a WHERE t1.a IN(t2.a, t2.b); +a b a b +3 2 3 0 +4 3 4 1 +6 5 6 4 +7 8 7 5 +SELECT * FROM t1 LEFT JOIN t2 ON t1.a = t2.a WHERE NOT(t1.a NOT IN(t2.a, t2.b)); +a b a b +3 2 3 0 +4 3 4 1 +6 5 6 4 +7 8 7 5 +SELECT * FROM t1 LEFT JOIN t2 ON t1.a = t2.a WHERE t1.a != t1.b AND t1.a != t2.b; +a b a b +3 2 3 0 +4 3 4 1 +6 5 6 4 +7 8 7 5 +SELECT * FROM t1 LEFT JOIN t2 ON t1.a = t2.a WHERE t1.a NOT IN(t1.b, t2.b); +a b a b +3 2 3 0 +4 3 4 1 +6 5 6 4 +7 8 7 5 +SELECT * FROM t1 LEFT JOIN t2 ON t1.a = t2.a WHERE NOT(t1.a IN(t1.b, t2.b)); +a b a b +3 2 3 0 +4 3 4 1 +6 5 6 4 +7 8 7 5 +SELECT * FROM t1 LEFT JOIN t2 ON t1.a = t2.a WHERE t2.a != t2.b OR (t1.a != t2.a AND t1.a != t2.b); +a b a b +3 2 3 0 +4 3 4 1 +6 5 6 4 +7 8 7 5 +SELECT * FROM t1 LEFT JOIN t2 ON t1.a = t2.a WHERE NOT(t2.a = t2.b AND t1.a IN(t2.a, t2.b)); +a b a b +3 2 3 0 +4 3 4 1 +6 5 6 4 +7 8 7 5 +SELECT * FROM t1 LEFT JOIN t2 ON t1.a = t2.a WHERE t2.a != t2.b AND t1.a != t1.b AND t1.a != t2.b; +a b a b +3 2 3 0 +4 3 4 1 +6 5 6 4 +7 8 7 5 +SELECT * FROM t1 LEFT JOIN t2 ON t1.a = t2.a WHERE NOT(t2.a = t2.b OR t1.a IN(t1.b, t2.b)); +a b a b +3 2 3 0 +4 3 4 1 +6 5 6 4 +7 8 7 5 +EXPLAIN SELECT * FROM t1 LEFT JOIN t2 ON t1.a = t2.a WHERE t1.a = t2.a OR t1.a = t2.b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ALL PRIMARY NULL NULL NULL 4 100.00 Using where +2 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.a 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` join `test`.`t2` where (`test`.`t1`.`a` = `test`.`t2`.`a`) +EXPLAIN SELECT * FROM t1 LEFT JOIN t2 ON t1.a = t2.a WHERE t1.a IN(t2.a, t2.b); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ALL PRIMARY NULL NULL NULL 4 100.00 Using where +2 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.a 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` join `test`.`t2` where ((`test`.`t1`.`a` = `test`.`t2`.`a`) and (`test`.`t2`.`a` in (`test`.`t2`.`a`,`test`.`t2`.`b`))) +EXPLAIN SELECT * FROM t1 LEFT JOIN t2 ON t1.a = t2.a WHERE t1.a > IF(t1.a = t2.b-2, t2.b, t2.b-1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ALL PRIMARY NULL NULL NULL 4 100.00 Using where +2 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.a 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` join `test`.`t2` where ((`test`.`t1`.`a` = `test`.`t2`.`a`) and (`test`.`t2`.`a` > if((`test`.`t2`.`a` = (`test`.`t2`.`b` - 2)),`test`.`t2`.`b`,(`test`.`t2`.`b` - 1)))) +DROP TABLE t1,t2; +DROP VIEW IF EXISTS v1,v2; +DROP TABLE IF EXISTS t1,t2; +CREATE TABLE t1 (a int); +CREATE table t2 (b int); +INSERT INTO t1 VALUES (1), (2), (3), (4), (1), (1), (3); +INSERT INTO t2 VALUES (2), (3); +CREATE VIEW v1 AS SELECT a FROM t1 JOIN t2 ON t1.a=t2.b; +CREATE VIEW v2 AS SELECT b FROM t2 JOIN t1 ON t2.b=t1.a; +SELECT v1.a, v2. b +FROM v1 LEFT OUTER JOIN v2 ON (v1.a=v2.b) AND (v1.a >= 3) +GROUP BY v1.a; +a b +2 NULL +3 3 +SELECT v1.a, v2. b +FROM { OJ v1 LEFT OUTER JOIN v2 ON (v1.a=v2.b) AND (v1.a >= 3) } +GROUP BY v1.a; +a b +2 NULL +3 3 +DROP VIEW v1,v2; +DROP TABLE t1,t2; +CREATE TABLE t1 (a int); +CREATE TABLE t2 (b int); +INSERT INTO t1 VALUES (1), (2), (3), (4); +INSERT INTO t2 VALUES (2), (3); +SELECT * FROM t1 LEFT JOIN t2 ON t1.a = t2.b WHERE (1=1); +a b +1 NULL +2 2 +3 3 +4 NULL +SELECT * FROM t1 LEFT JOIN t2 ON t1.a = t2.b WHERE (1 OR 1); +a b +1 NULL +2 2 +3 3 +4 NULL +SELECT * FROM t1 LEFT JOIN t2 ON t1.a = t2.b WHERE (0 OR 1); +a b +1 NULL +2 2 +3 3 +4 NULL +SELECT * FROM t1 LEFT JOIN t2 ON t1.a = t2.b WHERE (1=1 OR 2=2); +a b +1 NULL +2 2 +3 3 +4 NULL +SELECT * FROM t1 LEFT JOIN t2 ON t1.a = t2.b WHERE (1=1 OR 1=0); +a b +1 NULL +2 2 +3 3 +4 NULL +DROP TABLE t1,t2; +CREATE TABLE t1 ( +f1 varchar(16) collate latin1_swedish_ci PRIMARY KEY, +f2 varchar(16) collate latin1_swedish_ci +); +CREATE TABLE t2 ( +f1 varchar(16) collate latin1_swedish_ci PRIMARY KEY, +f3 varchar(16) collate latin1_swedish_ci +); +INSERT INTO t1 VALUES ('bla','blah'); +INSERT INTO t2 VALUES ('bla','sheep'); +SELECT * FROM t1 JOIN t2 USING(f1) WHERE f1='Bla'; +f1 f2 f3 +bla blah sheep +SELECT * FROM t1 LEFT JOIN t2 USING(f1) WHERE f1='bla'; +f1 f2 f3 +bla blah sheep +SELECT * FROM t1 LEFT JOIN t2 USING(f1) WHERE f1='Bla'; +f1 f2 f3 +bla blah sheep +DROP TABLE t1,t2; +CREATE TABLE t1 (id int PRIMARY KEY, a varchar(8)); +CREATE TABLE t2 (id int NOT NULL, b int NOT NULL, INDEX idx(id)); +INSERT INTO t1 VALUES +(1,'aaaaaaa'), (5,'eeeeeee'), (4,'ddddddd'), (2,'bbbbbbb'), (3,'ccccccc'); +INSERT INTO t2 VALUES +(3,10), (2,20), (5,30), (3,20), (5,10), (3,40), (3,30), (2,10), (2,40); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN +SELECT t1.id, a FROM t1 LEFT JOIN t2 ON t1.id=t2.id WHERE t2.b IS NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +2 SIMPLE t2 NULL ALL idx NULL NULL NULL 9 11.11 Using where; Not exists; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,`test`.`t1`.`a` AS `a` from `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`id` = `test`.`t1`.`id`)) where (`test`.`t2`.`b` is null) +flush status; +SELECT t1.id, a FROM t1 LEFT JOIN t2 ON t1.id=t2.id WHERE t2.b IS NULL; +id a +1 aaaaaaa +4 ddddddd +show status like 'Handler_read%'; +Variable_name Value +Handler_read_first 2 +Handler_read_key 2 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 16 +DROP TABLE t1,t2; +CREATE TABLE t1 (c int PRIMARY KEY, e int NOT NULL); +INSERT INTO t1 VALUES (1,0), (2,1); +CREATE TABLE t2 (d int PRIMARY KEY); +INSERT INTO t2 VALUES (1), (2), (3); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN SELECT * FROM t1 LEFT JOIN t2 ON e<>0 WHERE c=1 AND d IS NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +1 SIMPLE t2 NULL index NULL PRIMARY 4 NULL 3 33.33 Using where; Not exists; Using index +Warnings: +Note 1003 /* select#1 */ select '1' AS `c`,'0' AS `e`,`test`.`t2`.`d` AS `d` from `test`.`t1` left join `test`.`t2` on(('0' <> 0)) where ((`test`.`t2`.`d` is null)) +SELECT * FROM t1 LEFT JOIN t2 ON e<>0 WHERE c=1 AND d IS NULL; +c e d +1 0 NULL +SELECT * FROM t1 LEFT JOIN t2 ON e<>0 WHERE c=1 AND d<=>NULL; +c e d +1 0 NULL +DROP TABLE t1,t2; +# +# Bug#47650: using group by with rollup without indexes returns incorrect +# results with where +# +CREATE TABLE t1 ( a INT ); +INSERT INTO t1 VALUES (1); +CREATE TABLE t2 ( a INT, b INT ); +INSERT INTO t2 VALUES (1, 1),(1, 2),(1, 3),(2, 4),(2, 5); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN +SELECT t1.a, COUNT( t2.b ), SUM( t2.b ), MAX( t2.b ) +FROM t1 LEFT JOIN t2 USING( a ) +GROUP BY t1.a WITH ROLLUP; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using temporary; Using filesort +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 5 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,rollup_sum_switcher(count(`test`.`t2`.`b`)) AS `COUNT( t2.b )`,rollup_sum_switcher(sum(`test`.`t2`.`b`)) AS `SUM( t2.b )`,rollup_sum_switcher(max(`test`.`t2`.`b`)) AS `MAX( t2.b )` from `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`a` = `test`.`t1`.`a`)) where true group by `test`.`t1`.`a` with rollup +SELECT t1.a, COUNT( t2.b ), SUM( t2.b ), MAX( t2.b ) +FROM t1 LEFT JOIN t2 USING( a ) +GROUP BY t1.a WITH ROLLUP; +a COUNT( t2.b ) SUM( t2.b ) MAX( t2.b ) +1 3 6 3 +NULL 3 6 3 +EXPLAIN +SELECT t1.a, COUNT( t2.b ), SUM( t2.b ), MAX( t2.b ) +FROM t1 JOIN t2 USING( a ) +GROUP BY t1.a WITH ROLLUP; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using temporary; Using filesort +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 5 20.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,rollup_sum_switcher(count(`test`.`t2`.`b`)) AS `COUNT( t2.b )`,rollup_sum_switcher(sum(`test`.`t2`.`b`)) AS `SUM( t2.b )`,rollup_sum_switcher(max(`test`.`t2`.`b`)) AS `MAX( t2.b )` from `test`.`t1` join `test`.`t2` where (`test`.`t2`.`a` = `test`.`t1`.`a`) group by `test`.`t1`.`a` with rollup +SELECT t1.a, COUNT( t2.b ), SUM( t2.b ), MAX( t2.b ) +FROM t1 JOIN t2 USING( a ) +GROUP BY t1.a WITH ROLLUP; +a COUNT( t2.b ) SUM( t2.b ) MAX( t2.b ) +1 3 6 3 +NULL 3 6 3 +DROP TABLE t1, t2; +# +# Bug#51598 Inconsistent behaviour with a COALESCE statement inside an IN comparison +# +CREATE TABLE t1(f1 INT, f2 INT, f3 INT); +INSERT INTO t1 VALUES (1, NULL, 3); +CREATE TABLE t2(f1 INT, f2 INT); +INSERT INTO t2 VALUES (2, 1); +EXPLAIN SELECT * FROM t1 LEFT JOIN t2 ON t1.f2 = t2.f2 +WHERE (COALESCE(t1.f1, t2.f1), f3) IN ((1, 3), (2, 2)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`f1` AS `f1`,`test`.`t1`.`f2` AS `f2`,`test`.`t1`.`f3` AS `f3`,`test`.`t2`.`f1` AS `f1`,`test`.`t2`.`f2` AS `f2` from `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`f2` = `test`.`t1`.`f2`)) where ((coalesce(`test`.`t1`.`f1`,`test`.`t2`.`f1`),`test`.`t1`.`f3`) in ((1,3),(2,2))) +SELECT * FROM t1 LEFT JOIN t2 ON t1.f2 = t2.f2 +WHERE (COALESCE(t1.f1, t2.f1), f3) IN ((1, 3), (2, 2)); +f1 f2 f3 f1 f2 +1 NULL 3 NULL NULL +DROP TABLE t1, t2; +# +# Bug#52357: Assertion failed: join->best_read in greedy_search +# optimizer_search_depth=0 +# +CREATE TABLE t1( a INT ); +INSERT INTO t1 VALUES (1),(2); +SET optimizer_search_depth = 0; +# Should not core dump on query preparation +EXPLAIN +SELECT 1 +FROM t1 tt3 LEFT OUTER JOIN t1 tt4 ON 1 +LEFT OUTER JOIN t1 tt5 ON 1 +LEFT OUTER JOIN t1 tt6 ON 1 +LEFT OUTER JOIN t1 tt7 ON 1 +LEFT OUTER JOIN t1 tt8 ON 1 +RIGHT OUTER JOIN t1 tt2 ON 1 +RIGHT OUTER JOIN t1 tt1 ON 1 +STRAIGHT_JOIN t1 tt9 ON 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE tt1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 SIMPLE tt2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +2 SIMPLE tt3 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +2 SIMPLE tt4 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +2 SIMPLE tt5 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +2 SIMPLE tt6 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +2 SIMPLE tt7 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +2 SIMPLE tt8 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +2 SIMPLE tt9 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` `tt1` left join (`test`.`t1` `tt2` left join (`test`.`t1` `tt3` left join `test`.`t1` `tt4` on(true) left join `test`.`t1` `tt5` on(true) left join `test`.`t1` `tt6` on(true) left join `test`.`t1` `tt7` on(true) left join `test`.`t1` `tt8` on(true)) on(true)) on(true) straight_join `test`.`t1` `tt9` where true +SET optimizer_search_depth = DEFAULT; +DROP TABLE t1; +# +# Bug#46091 STRAIGHT_JOIN + RIGHT JOIN returns different result +# +CREATE TABLE t1 (f1 INT NOT NULL); +INSERT INTO t1 VALUES (9),(0); +CREATE TABLE t2 (f1 INT NOT NULL); +INSERT INTO t2 VALUES +(5),(3),(0),(3),(1),(0),(1),(7),(1),(0),(0),(8),(4),(9),(0),(2),(0),(8),(5),(1); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +SELECT STRAIGHT_JOIN COUNT(*) FROM t1 ta1 +RIGHT JOIN t2 ta2 JOIN t2 ta3 ON ta2.f1 ON ta3.f1; +COUNT(*) +476 +EXPLAIN SELECT STRAIGHT_JOIN COUNT(*) FROM t1 ta1 +RIGHT JOIN t2 ta2 JOIN t2 ta3 ON ta2.f1 ON ta3.f1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 20 90.00 Parallel execute (1 workers) +2 SIMPLE ta2 NULL ALL NULL NULL NULL NULL 20 90.00 Using where +2 SIMPLE ta3 NULL ALL NULL NULL NULL NULL 20 100.00 Using join buffer (hash join) +2 SIMPLE ta1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select straight_join count(0) AS `COUNT(*)` from `test`.`t2` `ta2` join `test`.`t2` `ta3` left join `test`.`t1` `ta1` on((0 <> `test`.`ta3`.`f1`)) where (0 <> `test`.`ta2`.`f1`) +DROP TABLE t1, t2; +# +# Bug#48971 Segfault in add_found_match_trig_cond () at sql_select.cc:5990 +# +CREATE TABLE t1(f1 INT, PRIMARY KEY (f1)); +INSERT INTO t1 VALUES (1),(2); +EXPLAIN SELECT STRAIGHT_JOIN jt1.f1 FROM t1 AS jt1 +LEFT JOIN t1 AS jt2 +RIGHT JOIN t1 AS jt3 +JOIN t1 AS jt4 ON 1 +LEFT JOIN t1 AS jt5 ON 1 +ON 1 +RIGHT JOIN t1 AS jt6 ON jt6.f1 +ON 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE jt1 NULL index NULL PRIMARY 4 NULL 2 100.00 Using index +2 SIMPLE jt6 NULL index NULL PRIMARY 4 NULL 2 100.00 Using where; Using index; Using join buffer (hash join) +2 SIMPLE jt3 NULL index NULL PRIMARY 4 NULL 2 100.00 Using where; Using index; Using join buffer (hash join) +2 SIMPLE jt4 NULL index NULL PRIMARY 4 NULL 2 100.00 Using index; Using join buffer (hash join) +2 SIMPLE jt5 NULL index NULL PRIMARY 4 NULL 2 100.00 Using where; Using index; Using join buffer (hash join) +2 SIMPLE jt2 NULL index NULL PRIMARY 4 NULL 2 100.00 Using where; Using index; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select straight_join `test`.`jt1`.`f1` AS `f1` from `test`.`t1` `jt1` left join (`test`.`t1` `jt6` left join (`test`.`t1` `jt3` join `test`.`t1` `jt4` left join `test`.`t1` `jt5` on(true) left join `test`.`t1` `jt2` on(true)) on(((0 <> `test`.`jt6`.`f1`)))) on(true) where true +EXPLAIN SELECT STRAIGHT_JOIN jt1.f1 FROM t1 AS jt1 +RIGHT JOIN t1 AS jt2 +RIGHT JOIN t1 AS jt3 +JOIN t1 AS jt4 ON 1 +LEFT JOIN t1 AS jt5 ON 1 +ON 1 +RIGHT JOIN t1 AS jt6 ON jt6.f1 +ON 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE jt6 NULL index NULL PRIMARY 4 NULL 2 100.00 Using index +2 SIMPLE jt3 NULL index NULL PRIMARY 4 NULL 2 100.00 Using where; Using index; Using join buffer (hash join) +2 SIMPLE jt4 NULL index NULL PRIMARY 4 NULL 2 100.00 Using index; Using join buffer (hash join) +2 SIMPLE jt5 NULL index NULL PRIMARY 4 NULL 2 100.00 Using where; Using index; Using join buffer (hash join) +2 SIMPLE jt2 NULL index NULL PRIMARY 4 NULL 2 100.00 Using where; Using index; Using join buffer (hash join) +2 SIMPLE jt1 NULL index NULL PRIMARY 4 NULL 2 100.00 Using where; Using index; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select straight_join `test`.`jt1`.`f1` AS `f1` from `test`.`t1` `jt6` left join (`test`.`t1` `jt3` join `test`.`t1` `jt4` left join `test`.`t1` `jt5` on(true) left join `test`.`t1` `jt2` on(true)) on(((0 <> `test`.`jt6`.`f1`))) left join `test`.`t1` `jt1` on(true) where true +DROP TABLE t1; +# +# Bug#57688 Assertion `!table || (!table->write_set || bitmap_is_set(table->write_set, field +# +CREATE TABLE t1 (f1 INT NOT NULL, PRIMARY KEY (f1)); +CREATE TABLE t2 (f1 INT NOT NULL, f2 INT NOT NULL, PRIMARY KEY (f1, f2)); +INSERT INTO t1 VALUES (4); +INSERT INTO t2 VALUES (3, 3); +INSERT INTO t2 VALUES (7, 7); +EXPLAIN SELECT * FROM t1 LEFT JOIN t2 ON t2.f1 = t1.f1 +WHERE t1.f1 = 4 +GROUP BY t2.f1, t2.f2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 Using index; Using temporary +1 SIMPLE t2 NULL ref PRIMARY PRIMARY 4 const 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select '4' AS `f1`,`test`.`t2`.`f1` AS `f1`,`test`.`t2`.`f2` AS `f2` from `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`f1` = 4)) where true group by `test`.`t2`.`f1`,`test`.`t2`.`f2` +SELECT * FROM t1 LEFT JOIN t2 ON t2.f1 = t1.f1 +WHERE t1.f1 = 4 +GROUP BY t2.f1, t2.f2; +f1 f1 f2 +4 NULL NULL +EXPLAIN SELECT * FROM t1 LEFT JOIN t2 ON t2.f1 = t1.f1 +WHERE t1.f1 = 4 AND t2.f1 IS NOT NULL AND t2.f2 IS NOT NULL +GROUP BY t2.f1, t2.f2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 Using index +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 50.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 Using index +2 SIMPLE t2 NULL ref PRIMARY PRIMARY 4 const 1 50.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select '4' AS `f1`,`test`.`t2`.`f1` AS `f1`,`test`.`t2`.`f2` AS `f2` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`f1` = 4) and (`test`.`t2`.`f2` is not null)) group by `test`.`t2`.`f1`,`test`.`t2`.`f2` +SELECT * FROM t1 LEFT JOIN t2 ON t2.f1 = t1.f1 +WHERE t1.f1 = 4 AND t2.f1 IS NOT NULL AND t2.f2 IS NOT NULL +GROUP BY t2.f1, t2.f2; +f1 f1 f2 +DROP TABLE t1,t2; +# +# Bug#57034 incorrect OUTER JOIN result when joined on unique key +# +CREATE TABLE t1 (pk INT PRIMARY KEY, +col_int INT, +col_int_unique INT UNIQUE KEY); +INSERT INTO t1 VALUES (1,NULL,2), (2,0,0); +CREATE TABLE t2 (pk INT PRIMARY KEY, +col_int INT, +col_int_unique INT UNIQUE KEY); +INSERT INTO t2 VALUES (1,0,1), (2,0,2); +EXPLAIN +SELECT * FROM t1 LEFT JOIN t2 +ON t1.col_int_unique = t2.col_int_unique AND t1.col_int = t2.col_int +WHERE t1.pk=1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +1 SIMPLE t2 NULL const col_int_unique col_int_unique 5 const 1 100.00 Impossible ON condition +Warnings: +Note 1003 /* select#1 */ select '1' AS `pk`,NULL AS `col_int`,'2' AS `col_int_unique`,NULL AS `pk`,NULL AS `col_int`,NULL AS `col_int_unique` from `test`.`t1` left join `test`.`t2` on((multiple equal('2', NULL) and multiple equal(NULL, NULL))) where true +SELECT * FROM t1 LEFT JOIN t2 +ON t1.col_int_unique = t2.col_int_unique AND t1.col_int = t2.col_int +WHERE t1.pk=1; +pk col_int col_int_unique pk col_int col_int_unique +1 NULL 2 NULL NULL NULL +DROP TABLE t1,t2; +# +# Bug#48046 Server incorrectly processing JOINs on NULL values +# +CREATE TABLE `BB` ( +`pk` int(11) NOT NULL AUTO_INCREMENT, +`time_key` time DEFAULT NULL, +`varchar_key` varchar(1) DEFAULT NULL, +`varchar_nokey` varchar(1) DEFAULT NULL, +PRIMARY KEY (`pk`), +KEY `time_key` (`time_key`), +KEY `varchar_key` (`varchar_key`) +) ENGINE=MyISAM AUTO_INCREMENT=11 DEFAULT CHARSET=latin1; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO `BB` VALUES (10,'18:27:58',NULL,NULL); +SELECT table1.time_key AS field1, table2.pk +FROM BB table1 LEFT JOIN BB table2 +ON table2.varchar_nokey = table1.varchar_key +HAVING field1; +field1 pk +18:27:58 NULL +DROP TABLE BB; +# +# Bug#49600 Server incorrectly processing RIGHT JOIN with +# constant WHERE clause and no index +# +CREATE TABLE `BB` ( +`col_datetime_key` datetime DEFAULT NULL, +`col_varchar_key` varchar(1) DEFAULT NULL, +`col_varchar_nokey` varchar(1) DEFAULT NULL, +KEY `col_datetime_key` (`col_datetime_key`), +KEY `col_varchar_key` (`col_varchar_key`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1; +INSERT INTO `BB` VALUES ('1900-01-01 00:00:00',NULL,NULL); +SELECT table1.col_datetime_key +FROM BB table1 RIGHT JOIN BB table2 +ON table2 .col_varchar_nokey = table1.col_varchar_key +WHERE 7; +col_datetime_key +NULL +ALTER TABLE BB DISABLE KEYS; +SELECT table1.col_datetime_key +FROM BB table1 RIGHT JOIN BB table2 +ON table2 .col_varchar_nokey = table1.col_varchar_key +WHERE 7; +col_datetime_key +NULL +DROP TABLE BB; +# +# Bug#58490: Incorrect result in multi level OUTER JOIN +# in combination with IS NULL +# +CREATE TABLE t1 (i INT NOT NULL); +INSERT INTO t1 VALUES (0), (2),(3),(4); +CREATE TABLE t2 (i INT NOT NULL); +INSERT INTO t2 VALUES (0),(1), (3),(4); +CREATE TABLE t3 (i INT NOT NULL); +INSERT INTO t3 VALUES (0),(1),(2), (4); +CREATE TABLE t4 (i INT NOT NULL); +INSERT INTO t4 VALUES (0),(1),(2),(3) ; +SELECT * FROM +t1 LEFT JOIN +( t2 LEFT JOIN +( t3 LEFT JOIN +t4 +ON t4.i = t3.i +) +ON t3.i = t2.i +) +ON t2.i = t1.i +; +i i i i +0 0 0 0 +2 NULL NULL NULL +3 3 NULL NULL +4 4 4 NULL +SELECT * FROM +t1 LEFT JOIN +( t2 LEFT JOIN +( t3 LEFT JOIN +t4 +ON t4.i = t3.i +) +ON t3.i = t2.i +) +ON t2.i = t1.i +WHERE t4.i IS NULL; +i i i i +2 NULL NULL NULL +3 3 NULL NULL +4 4 4 NULL +SELECT * FROM +t1 LEFT JOIN +( ( t2 LEFT JOIN +t3 +ON t3.i = t2.i +) +) +ON t2.i = t1.i +WHERE t3.i IS NULL; +i i i +2 NULL NULL +3 3 NULL +SELECT * FROM +t1 LEFT JOIN +( ( t2 LEFT JOIN +t3 +ON t3.i = t2.i +) +JOIN t4 +ON t4.i=t2.i +) +ON t2.i = t1.i +WHERE t3.i IS NULL; +i i i i +2 NULL NULL NULL +3 3 NULL 3 +4 NULL NULL NULL +SELECT * FROM +t1 LEFT JOIN +( ( t2 LEFT JOIN +t3 +ON t3.i = t2.i +) +JOIN (t4 AS t4a JOIN t4 AS t4b ON t4a.i=t4b.i) +ON t4a.i=t2.i +) +ON t2.i = t1.i +WHERE t3.i IS NULL; +i i i i i +2 NULL NULL NULL NULL +3 3 NULL 3 3 +4 NULL NULL NULL NULL +SELECT * FROM +t1 LEFT JOIN +( ( t2 LEFT JOIN +t3 +ON t3.i = t2.i +) +JOIN (t4 AS t4a, t4 AS t4b) +ON t4a.i=t2.i +) +ON t2.i = t1.i +WHERE t3.i IS NULL; +i i i i i +2 NULL NULL NULL NULL +3 3 NULL 3 0 +3 3 NULL 3 1 +3 3 NULL 3 2 +3 3 NULL 3 3 +4 NULL NULL NULL NULL +DROP TABLE t1,t2,t3,t4; +# +# Bug#49322(Duplicate): Server is adding extra NULL row +# on processing a WHERE clause +# +CREATE TABLE h (pk INT NOT NULL, col_int_key INT); +INSERT INTO h VALUES (1,NULL),(4,2),(5,2),(3,4),(2,8); +CREATE TABLE m (pk INT NOT NULL, col_int_key INT); +INSERT INTO m VALUES (1,2),(2,7),(3,5),(4,7),(5,5),(6,NULL),(7,NULL),(8,9); +CREATE TABLE k (pk INT NOT NULL, col_int_key INT); +INSERT INTO k VALUES (1,9),(2,2),(3,5),(4,2),(5,7),(6,0),(7,5); +SELECT TABLE1.pk FROM k TABLE1 +RIGHT JOIN h TABLE2 ON TABLE1.col_int_key=TABLE2.col_int_key +RIGHT JOIN m TABLE4 ON TABLE2.col_int_key=TABLE4.col_int_key; +pk +2 +2 +4 +4 +NULL +NULL +NULL +NULL +NULL +NULL +NULL +SELECT TABLE1.pk FROM k TABLE1 +RIGHT JOIN h TABLE2 ON TABLE1.col_int_key=TABLE2.col_int_key +RIGHT JOIN m TABLE4 ON TABLE2.col_int_key=TABLE4.col_int_key +WHERE TABLE1.pk IS NULL; +pk +NULL +NULL +NULL +NULL +NULL +NULL +NULL +DROP TABLE h,m,k; +# +# Bug #11765810 58813: SERVER THREAD HANGS WHEN JOIN + WHERE + GROUP BY +# IS EXECUTED TWICE FROM P +# +CREATE TABLE t1 ( a INT ) ENGINE = MYISAM; +INSERT INTO t1 VALUES (1); +PREPARE prep_stmt FROM ' + SELECT 1 AS f FROM t1 + LEFT JOIN t1 t2 + RIGHT JOIN t1 t3 + JOIN t1 t4 + ON 1 + ON 1 + ON 1 + GROUP BY f'; +EXECUTE prep_stmt; +f +1 +EXECUTE prep_stmt; +f +1 +DROP TABLE t1; +End of 5.1 tests +# +# Bug#54235 Extra rows with join_cache_level=4,6,8 and two LEFT JOIN +# +CREATE TABLE t1 (a int); +CREATE TABLE t2 (a int); +CREATE TABLE t3 (a int); +CREATE TABLE t4 (a int); +INSERT INTO t1 VALUES (null),(null); +explain SELECT t1.a FROM t1 LEFT JOIN (t2 LEFT JOIN t3 ON t2.a) +ON 0 WHERE t1.a OR t3.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` left join (`test`.`t2` left join `test`.`t3` on((0 <> `test`.`t2`.`a`))) on(false) where ((0 <> `test`.`t1`.`a`) or (0 <> `test`.`t3`.`a`)) +SELECT t1.a FROM t1 LEFT JOIN (t2 LEFT JOIN t3 ON t2.a) +ON 0 WHERE t1.a OR t3.a; +a +explain SELECT t1.a FROM t1 LEFT JOIN +(t2 LEFT JOIN (t3 LEFT JOIN t4 ON 1) ON t2.a) +ON 0 WHERE t1.a OR t4.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` left join (`test`.`t2` left join (`test`.`t3` left join `test`.`t4` on(true)) on((0 <> `test`.`t2`.`a`))) on(false) where ((0 <> `test`.`t1`.`a`) or (0 <> `test`.`t4`.`a`)) +SELECT t1.a FROM t1 LEFT JOIN +(t2 LEFT JOIN (t3 LEFT JOIN t4 ON 1) ON t2.a) +ON 0 WHERE t1.a OR t4.a; +a +DROP TABLE t1,t2,t3,t4; +# +# Bug#56254 Assertion tab->ref.use_count fails in +# join_read_key_unlock_row() on 4-way JOIN +# +CREATE TABLE t1 ( +pk INT NOT NULL, +col_int_key INT, +col_int INT, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +); +INSERT INTO t1 VALUES (6, -448724992, NULL); +CREATE TABLE t2 ( +col_int INT, +col_varchar_10 VARCHAR(10) +); +INSERT INTO t2 VALUES (6,'afasdkiyum'); +CREATE TABLE t3 ( +col_varchar_10 VARCHAR(10), +col_int INT +); +CREATE TABLE t4 ( +pk INT NOT NULL, +PRIMARY KEY (pk) +); +INSERT INTO t4 VALUES (1); +INSERT INTO t4 VALUES (2); +SELECT t1.col_int +FROM t1 +LEFT JOIN t2 +LEFT JOIN t3 +JOIN t4 +ON t3.col_int = t4.pk +ON t2.col_varchar_10 = t3.col_varchar_10 +ON t2.col_int = t1.pk +WHERE t1.col_int_key IS NULL OR t4.pk < t3.col_int; +col_int +EXPLAIN FORMAT=tree SELECT t1.col_int +FROM t1 +LEFT JOIN t2 +LEFT JOIN t3 +JOIN t4 +ON t3.col_int = t4.pk +ON t2.col_varchar_10 = t3.col_varchar_10 +ON t2.col_int = t1.pk +WHERE t1.col_int_key IS NULL OR t4.pk < t3.col_int; +EXPLAIN +-> Parallel scan on + -> Filter: (found_match(t3..t4), ((t1.col_int_key is null) or (t4.pk < t3.col_int)), true) (cost=0.70 rows=1) + -> Nested loop left join (cost=0.70 rows=1) + -> PQblock scan on t1 (cost=0.35 rows=1) + -> Nested loop left join (cost=0.70 rows=1) + -> Filter: (t2.col_int = t1.pk) (cost=0.35 rows=1) + -> Table scan on t2 (cost=0.35 rows=1) + -> Nested loop inner join (cost=0.70 rows=1) + -> Filter: (t3.col_varchar_10 = t2.col_varchar_10) (cost=0.35 rows=1) + -> Table scan on t3 (cost=0.35 rows=1) + -> Single-row index lookup on t4 using PRIMARY (pk=t3.col_int) (cost=0.35 rows=1) + +DROP TABLE t1,t2,t3,t4; + +# BUG#12567331 - INFINITE LOOP WHEN RESOLVING AN ALIASED COLUMN +# USED IN GROUP BY + +CREATE TABLE t1 (pk int(11)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +PREPARE prep_stmt_9846 FROM ' +SELECT alias1.pk AS field1 FROM +t1 AS alias1 +LEFT JOIN +( + t1 AS alias2 + RIGHT JOIN + ( + t1 AS alias3 + JOIN t1 AS alias4 + ON 1 + ) + ON 1 +) +ON 1 +GROUP BY field1'; +execute prep_stmt_9846; +field1 +execute prep_stmt_9846; +field1 +deallocate prepare prep_stmt_9846; +drop table t1; +# +# Bug#13040136 - ASSERT IN PLAN_CHANGE_WATCHDOG::~PLAN_CHANGE_WATCHDOG() +# +CREATE TABLE t1 ( +col_varchar_10 VARCHAR(10), +col_int_key INTEGER, +col_varchar_10_key VARCHAR(10), +pk INTEGER NOT NULL, +PRIMARY KEY (pk), +KEY (col_int_key), +KEY (col_varchar_10_key) +); +INSERT INTO t1 VALUES ('q',NULL,'o',1); +CREATE TABLE t2 ( +pk INTEGER NOT NULL AUTO_INCREMENT, +col_varchar_10_key VARCHAR(10), +col_int_key INTEGER, +col_varchar_10 VARCHAR(10), +PRIMARY KEY (pk), +KEY (col_varchar_10_key), +KEY col_int_key (col_int_key) +); +INSERT INTO t2 VALUES +(1,'r',NULL,'would'),(2,'tell',-655032320,'t'), +(3,'d',9,'a'),(4,'gvafasdkiy',6,'ugvafasdki'), +(5,'that\'s',NULL,'she'),(6,'bwftwugvaf',7,'cbwftwugva'), +(7,'f',-700055552,'mkacbwftwu'),(8,'a',9,'be'), +(9,'d',NULL,'u'),(10,'ckiixcsxmk',NULL,'o'); +SELECT DISTINCT t2.col_int_key +FROM +t1 +LEFT JOIN t2 +ON t1.col_varchar_10 = t2.col_varchar_10_key +WHERE t2.pk +ORDER BY t2.col_int_key; +col_int_key +DROP TABLE t1,t2; +# +# Bug#13068506 - QUERY WITH GROUP BY ON NON-AGGR COLUMN RETURNS WRONG RESULT +# +CREATE TABLE t1 (i1 int); +INSERT INTO t1 VALUES (100), (101); +CREATE TABLE t2 (i2 int, i3 int); +INSERT INTO t2 VALUES (20,1),(10,2); +CREATE TABLE t3 (i4 int(11)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t3 VALUES (1),(2); + +SELECT ( +SELECT MAX( t2.i2 ) +FROM t3 RIGHT JOIN t2 ON ( t2.i3 = 2 ) +WHERE t2.i3 <> t1.i1 +) AS field1 +FROM t1;; +field1 +20 +20 + +SELECT ( +SELECT MAX( t2.i2 ) +FROM t3 RIGHT JOIN t2 ON ( t2.i3 = 2 ) +WHERE t2.i3 <> t1.i1 +) AS field1 +FROM t1 GROUP BY field1;; +field1 +20 + +drop table t1,t2,t3; +# Bug#11766384 - 59487: WRONG RESULT WITH STRAIGHT_JOIN AND RIGHT JOIN +CREATE TABLE t1 ( +pk int(11) NOT NULL, +col_varchar_10_latin1_key varchar(10) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (1,'1'); +CREATE TABLE t2 ( +pk int(11) NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (1); +CREATE TABLE t3 ( +pk int(11) NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t3 VALUES (1); +CREATE TABLE t4 ( +pk int(11) NOT NULL, +col_int int(11) DEFAULT NULL, +col_int_key int(11) DEFAULT NULL, +col_varchar_10_latin1_key varchar(10) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t4 VALUES (1,1,1,'1'); +CREATE TABLE t5 ( +col_int int(11) DEFAULT NULL, +col_varchar_10_utf8_key varchar(10) CHARACTER SET utf8 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t5 VALUES (1,'1'); +CREATE TABLE t6 ( +col_int_key int(11) DEFAULT NULL, +col_varchar_10_latin1_key varchar(10) DEFAULT NULL, +pk int(11) NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t6 VALUES (1,'1',1); +SELECT STRAIGHT_JOIN t6a.pk, t2.pk +FROM +t6 AS t6a +LEFT JOIN +( +t2 +RIGHT JOIN +( +( +t1 +LEFT JOIN +( +t4 +JOIN +t3 +ON t4.col_int +) +ON t4.col_int_key = t1.pk +) +LEFT JOIN +( +t5 +JOIN +t6 AS t6b +ON t5.col_varchar_10_utf8_key = t6b.col_varchar_10_latin1_key +) +ON t1.pk = t5.col_int +) +ON t4.col_varchar_10_latin1_key = t1.col_varchar_10_latin1_key +AND t5.col_varchar_10_utf8_key = 0 +) +ON t6a.pk IS TRUE +WHERE t6b.col_int_key IS TRUE +; +pk pk +1 NULL +EXPLAIN SELECT STRAIGHT_JOIN t6a.pk, t2.pk +FROM +t6 AS t6a +LEFT JOIN +( +t2 +RIGHT JOIN +( +( +t1 +LEFT JOIN +( +t4 +JOIN +t3 +ON t4.col_int +) +ON t4.col_int_key = t1.pk +) +LEFT JOIN +( +t5 +JOIN +t6 AS t6b +ON t5.col_varchar_10_utf8_key = t6b.col_varchar_10_latin1_key +) +ON t1.pk = t5.col_int +) +ON t4.col_varchar_10_latin1_key = t1.col_varchar_10_latin1_key +AND t5.col_varchar_10_utf8_key = 0 +) +ON t6a.pk IS TRUE +WHERE t6b.col_int_key IS TRUE +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t6a NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using join buffer (hash join) +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using join buffer (hash join) +2 SIMPLE t5 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t6b NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select straight_join `test`.`t6a`.`pk` AS `pk`,`test`.`t2`.`pk` AS `pk` from `test`.`t6` `t6a` join `test`.`t1` left join (`test`.`t4` join `test`.`t3`) on(((`test`.`t4`.`col_int_key` = `test`.`t1`.`pk`) and (0 <> `test`.`t4`.`col_int`))) join `test`.`t5` join `test`.`t6` `t6b` left join `test`.`t2` on(((`test`.`t4`.`col_varchar_10_latin1_key` = `test`.`t1`.`col_varchar_10_latin1_key`) and (`test`.`t5`.`col_varchar_10_utf8_key` = 0))) where ((`test`.`t5`.`col_int` = `test`.`t1`.`pk`) and ((0 <> `test`.`t6b`.`col_int_key`) is true) and (`test`.`t5`.`col_varchar_10_utf8_key` = `test`.`t6b`.`col_varchar_10_latin1_key`) and ((0 <> `test`.`t6a`.`pk`) is true)) +SELECT t6a.pk, t2.pk +FROM +t6 AS t6a +LEFT JOIN +( +t2 +RIGHT JOIN +( +( +t1 +LEFT JOIN +( +t4 +JOIN +t3 +ON t4.col_int +) +ON t4.col_int_key = t1.pk +) +LEFT JOIN +( +t5 +JOIN +t6 AS t6b +ON t5.col_varchar_10_utf8_key = t6b.col_varchar_10_latin1_key +) +ON t1.pk = t5.col_int +) +ON t4.col_varchar_10_latin1_key = t1.col_varchar_10_latin1_key +AND t5.col_varchar_10_utf8_key = 0 +) +ON t6a.pk IS TRUE +WHERE t6b.col_int_key IS TRUE +; +pk pk +1 NULL +EXPLAIN SELECT t6a.pk, t2.pk +FROM +t6 AS t6a +LEFT JOIN +( +t2 +RIGHT JOIN +( +( +t1 +LEFT JOIN +( +t4 +JOIN +t3 +ON t4.col_int +) +ON t4.col_int_key = t1.pk +) +LEFT JOIN +( +t5 +JOIN +t6 AS t6b +ON t5.col_varchar_10_utf8_key = t6b.col_varchar_10_latin1_key +) +ON t1.pk = t5.col_int +) +ON t4.col_varchar_10_latin1_key = t1.col_varchar_10_latin1_key +AND t5.col_varchar_10_utf8_key = 0 +) +ON t6a.pk IS TRUE +WHERE t6b.col_int_key IS TRUE +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t6a NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using join buffer (hash join) +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using join buffer (hash join) +2 SIMPLE t5 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t6b NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t6a`.`pk` AS `pk`,`test`.`t2`.`pk` AS `pk` from `test`.`t6` `t6a` join `test`.`t1` left join (`test`.`t4` join `test`.`t3`) on(((`test`.`t4`.`col_int_key` = `test`.`t1`.`pk`) and (0 <> `test`.`t4`.`col_int`))) join `test`.`t5` join `test`.`t6` `t6b` left join `test`.`t2` on(((`test`.`t4`.`col_varchar_10_latin1_key` = `test`.`t1`.`col_varchar_10_latin1_key`) and (`test`.`t5`.`col_varchar_10_utf8_key` = 0))) where ((`test`.`t5`.`col_int` = `test`.`t1`.`pk`) and ((0 <> `test`.`t6b`.`col_int_key`) is true) and (`test`.`t5`.`col_varchar_10_utf8_key` = `test`.`t6b`.`col_varchar_10_latin1_key`) and ((0 <> `test`.`t6a`.`pk`) is true)) +EXPLAIN SELECT * FROM t5 LEFT JOIN t6 ON t5.col_int=1000 +WHERE t6.col_int_key IS TRUE; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t5 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 SIMPLE t6 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t5`.`col_int` AS `col_int`,`test`.`t5`.`col_varchar_10_utf8_key` AS `col_varchar_10_utf8_key`,`test`.`t6`.`col_int_key` AS `col_int_key`,`test`.`t6`.`col_varchar_10_latin1_key` AS `col_varchar_10_latin1_key`,`test`.`t6`.`pk` AS `pk` from `test`.`t5` join `test`.`t6` where ((`test`.`t5`.`col_int` = 1000) and ((0 <> `test`.`t6`.`col_int_key`) is true)) +EXPLAIN SELECT * FROM t5 LEFT JOIN t6 ON t5.col_int=1000 +WHERE t6.col_int_key IS NOT TRUE; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t5 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t6 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t5`.`col_int` AS `col_int`,`test`.`t5`.`col_varchar_10_utf8_key` AS `col_varchar_10_utf8_key`,`test`.`t6`.`col_int_key` AS `col_int_key`,`test`.`t6`.`col_varchar_10_latin1_key` AS `col_varchar_10_latin1_key`,`test`.`t6`.`pk` AS `pk` from `test`.`t5` left join `test`.`t6` on((`test`.`t5`.`col_int` = 1000)) where ((0 <> `test`.`t6`.`col_int_key`) is not true) +drop table t1,t2,t3,t4,t5,t6; +# +# Verify that the "not exists" optimization works. +# +CREATE TABLE t1(a INT); +CREATE TABLE t2(a INT NOT NULL); +INSERT INTO t1 VALUES(1),(2); +INSERT INTO t2 VALUES(1),(2); +EXPLAIN SELECT * FROM t1 LEFT JOIN t2 ON t1.a=t2.a WHERE t2.a IS NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Not exists; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a` from `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`a` = `test`.`t1`.`a`)) where (`test`.`t2`.`a` is null) +FLUSH STATUS; +SELECT * FROM t1 LEFT JOIN t2 ON t1.a=t2.a WHERE t2.a IS NULL; +a a +SHOW STATUS LIKE 'HANDLER_READ%'; +Variable_name Value +Handler_read_first 2 +Handler_read_key 2 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 6 +DROP TABLE t1,t2; +# +# Bug#13464334 SAME QUERY PRODUCES DIFFERENT RESULTS WHEN USED WITH AND +# WITHOUT UNION ALL +# +CREATE TABLE t1 (p1 INT PRIMARY KEY, a CHAR(1)); +CREATE TABLE t2 (p2 INT PRIMARY KEY, b CHAR(1)); +INSERT INTO t1 VALUES (1,'a'),(2,'b'),(3,'c'); +INSERT INTO t2 VALUES (1,'h'),(2,'i'),(3,'j'),(4,'k'); +CREATE VIEW v1 AS SELECT * FROM t1; +CREATE VIEW v2 AS SELECT * FROM t2; +(SELECT p1 FROM v2 LEFT JOIN v1 ON b = a WHERE p2 = 1 GROUP BY p1 ORDER BY p1) +UNION (SELECT NULL LIMIT 0); +p1 +NULL +DROP VIEW v1, v2; +DROP TABLE t1, t2; +# +# Bug#13980954 Missing data on left join + null value + where..in +# +CREATE TABLE t1 (ik INT, vc varchar(1)) charset utf8mb4 ENGINE=Innodb; +explain format=json SELECT straight_join t1.vc, t1.ik +FROM t1 JOIN t1 AS t2 ON t1.vc=t2.vc LEFT JOIN t1 AS t3 ON t1.vc=t3.vc; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.05" + }, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.10", + "prefix_cost": "0.35", + "data_read_per_join": "16" + }, + "used_columns": [ + "vc", + "ik" + ], + "query_block": { + "cost_info": { + "query_cost": "1.05" + }, + "nested_loop": [ + { + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.10", + "prefix_cost": "0.35", + "data_read_per_join": "16" + }, + "used_columns": [ + "ik", + "vc" + ] + } + }, + { + "table": { + "select_id": 2, + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.10", + "prefix_cost": "0.70", + "data_read_per_join": "16" + }, + "used_columns": [ + "vc" + ], + "attached_condition": "(`test`.`t2`.`vc` = `test`.`t1`.`vc`)" + } + }, + { + "table": { + "select_id": 2, + "table_name": "t3", + "access_type": "ALL", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.10", + "prefix_cost": "1.05", + "data_read_per_join": "16" + }, + "used_columns": [ + "vc" + ], + "attached_condition": "(is_not_null_compl(t3), (`test`.`t3`.`vc` = `test`.`t1`.`vc`), true)" + } + } + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select straight_join `test`.`t1`.`vc` AS `vc`,`test`.`t1`.`ik` AS `ik` from `test`.`t1` join `test`.`t1` `t2` left join `test`.`t1` `t3` on((`test`.`t3`.`vc` = `test`.`t1`.`vc`)) where (`test`.`t2`.`vc` = `test`.`t1`.`vc`) +SELECT straight_join t1.vc, t1.ik +FROM t1 JOIN t1 AS t2 ON t1.vc=t2.vc LEFT JOIN t1 AS t3 ON t1.vc=t3.vc; +vc ik +DROP TABLE t1; +# +# Bug #18345786 CRASH AROUND ST_JOIN_TABLE::AND_WITH_CONDITION +# +CREATE TABLE t1(a INT) ENGINE=INNODB; +SET @a:=(SELECT ROW(1, 2)= +ROW((SELECT 1 FROM t1 LEFT JOIN t1 t2 ON 1), 1)); +DROP TABLE t1; +# +# Coverage for "unique row not found" +# +create table t1(a int, unique key(a)) engine=innodb; +insert into t1 values(1); +explain select * from t1 left join t1 as t2 +on t2.a=12 +where t1.a=1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL const a a 5 const 1 100.00 Using index +1 SIMPLE t2 NULL const a a 5 const 0 0.00 unique row not found +Warnings: +Note 1003 /* select#1 */ select '1' AS `a`,NULL AS `a` from `test`.`t1` left join `test`.`t1` `t2` on(multiple equal(12, NULL)) where true +select * from t1 left join t1 as t2 +on t2.a=12 +where t1.a=1; +a a +1 NULL +drop table t1; +# +# Bug#18717059 MISSING ROWS ON NESTED JOIN WITH SUBQUERY +# WITH MYISAM OR MEMORY +# +CREATE TABLE t1 ( +pk INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +PRIMARY KEY (pk), +KEY col_varchar_key (col_varchar_key, col_int_key) +) ENGINE=MyISAM; +INSERT INTO t1 VALUES (23,4,'d'); +INSERT INTO t1 VALUES (24,8,'g'); +INSERT INTO t1 VALUES (25,NULL,'x'); +INSERT INTO t1 VALUES (26,NULL,'f'); +INSERT INTO t1 VALUES (27,0,'p'); +INSERT INTO t1 VALUES (28,NULL,'j'); +INSERT INTO t1 VALUES (29,8,'c'); +CREATE TABLE t2 ( +pk INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +PRIMARY KEY (pk) +) ENGINE=MyISAM; +SELECT 9 +FROM t1 AS table1 +RIGHT JOIN t1 AS table2 +ON table2.col_int_key = table1.col_int_key +AND table1.col_varchar_key = ( +SELECT subquery2_t2.col_varchar_key +FROM t2 +STRAIGHT_JOIN ( t2 AS subquery2_t2 +JOIN t1 AS subquery2_t3 +) ON ( subquery2_t3.col_int_key = subquery2_t2.pk ) +); +9 +9 +9 +9 +9 +9 +9 +9 +CREATE TABLE where_subselect_table AS +SELECT 9 +FROM t1 AS table1 +RIGHT JOIN t1 AS table2 +ON table2.col_int_key = table1.col_int_key +AND table1.col_varchar_key = ( +SELECT subquery2_t2.col_varchar_key +FROM t2 +STRAIGHT_JOIN ( t2 AS subquery2_t2 +JOIN t1 AS subquery2_t3 +) ON ( subquery2_t3.col_int_key = subquery2_t2.pk ) +); +set optimizer_switch='condition_fanout_filter=on'; +SELECT * +FROM where_subselect_table +WHERE (9) IN ( SELECT 9 +FROM t1 AS table1 +RIGHT JOIN t1 AS table2 +ON table2.col_int_key = table1.col_int_key +AND table1.col_varchar_key = ( +SELECT subquery2_t2.col_varchar_key +FROM t2 +STRAIGHT_JOIN ( t2 AS subquery2_t2 +JOIN t1 AS subquery2_t3 +) ON ( subquery2_t3.col_int_key = subquery2_t2.pk ) +) ) +/* TRANSFORM_OUTCOME_UNORDERED_MATCH */; +9 +9 +9 +9 +9 +9 +9 +9 +set optimizer_switch='condition_fanout_filter=off'; +SELECT * +FROM where_subselect_table +WHERE (9) IN ( SELECT 9 +FROM t1 AS table1 +RIGHT JOIN t1 AS table2 +ON table2.col_int_key = table1.col_int_key +AND table1.col_varchar_key = ( +SELECT subquery2_t2.col_varchar_key +FROM t2 +STRAIGHT_JOIN ( t2 AS subquery2_t2 +JOIN t1 AS subquery2_t3 +) ON ( subquery2_t3.col_int_key = subquery2_t2.pk ) +) ) +/* TRANSFORM_OUTCOME_UNORDERED_MATCH */; +9 +9 +9 +9 +9 +9 +9 +9 +DROP TABLE t1, t2, where_subselect_table; +# Bug#14358878 Wrong results on table left join view +CREATE TABLE a (id INTEGER); +CREATE TABLE b (id INTEGER); +CREATE ALGORITHM=MERGE VIEW vmerge AS SELECT 1 AS id, id AS b_id FROM b; +CREATE ALGORITHM=TEMPTABLE VIEW vmat AS SELECT 1 AS id, id AS b_id FROM b; +INSERT INTO a(id) VALUES (1); +SELECT * +FROM a LEFT JOIN vmerge AS v ON a.id = v.id; +id id b_id +1 NULL NULL +SELECT * +FROM a LEFT JOIN vmat AS v ON a.id = v.id; +id id b_id +1 NULL NULL +SELECT * +FROM a LEFT JOIN (SELECT 1 AS one, id FROM b) AS v ON a.id = v.id; +id one id +1 NULL NULL +SELECT * +FROM a LEFT JOIN (SELECT DISTINCT 1 AS one, id FROM b) AS v ON a.id = v.id; +id one id +1 NULL NULL +SELECT * +FROM a LEFT JOIN vmerge AS v ON a.id = v.id +UNION DISTINCT +SELECT * +FROM a LEFT JOIN vmerge AS v ON a.id = v.id; +id id b_id +1 NULL NULL +SELECT * +FROM a LEFT JOIN vmerge AS v ON a.id = v.id +UNION ALL +SELECT * +FROM a LEFT JOIN vmerge AS v ON a.id = v.id; +id id b_id +1 NULL NULL +1 NULL NULL +DROP VIEW vmerge, vmat; +DROP TABLE a, b; +# Bug#15936817 Table left join view, unmatched rows problem where +# view contains an IF +CREATE TABLE small ( +id INTEGER not null, +PRIMARY KEY (id) +); +CREATE TABLE big ( +id INTEGER not null, +PRIMARY KEY (id) +); +INSERT INTO small VALUES (1), (2); +INSERT INTO big VALUES (1), (2), (3), (4); +CREATE VIEW small_view AS +SELECT *, IF (id % 2 = 1, 1, 0) AS is_odd +FROM small; +CREATE VIEW big_view AS +SELECT big.*, small_view.id AS small_id, small_view.is_odd +FROM big LEFT JOIN small_view ON small_view.id = big.id; +SELECT * FROM big_view; +id small_id is_odd +1 1 1 +2 2 0 +3 NULL NULL +4 NULL NULL +SELECT big.*, small.id AS small_id, small.is_odd +FROM big LEFT JOIN +(SELECT id, IF (id % 2 = 1, 1, 0) AS is_odd FROM small) AS small +ON big.id = small.id; +id small_id is_odd +1 1 1 +2 2 0 +3 NULL NULL +4 NULL NULL +# Check the IS NULL and thruth predicates +SELECT big.*, dt.* +FROM big LEFT JOIN (SELECT id as dt_id, +id IS NULL AS nul, +id IS NOT NULL AS nnul, +id IS TRUE AS t, +id IS NOT TRUE AS nt, +id IS FALSE AS f, +id IS NOT FALSE AS nf, +id IS UNKNOWN AS u, +id IS NOT UNKNOWN AS nu +FROM small) AS dt +ON big.id=dt.dt_id; +id dt_id nul nnul t nt f nf u nu +1 1 0 1 1 0 0 1 0 1 +2 2 0 1 1 0 0 1 0 1 +3 NULL NULL NULL NULL NULL NULL NULL NULL NULL +4 NULL NULL NULL NULL NULL NULL NULL NULL NULL +# Check comparison predicates +SELECT big.*, dt.* +FROM big LEFT JOIN (SELECT id as dt_id, +id = 1 AS eq, +id <> 1 AS ne, +id > 1 AS gt, +id >= 1 AS ge, +id < 1 AS lt, +id <= 1 AS le, +id <=> 1 AS equal +FROM small) AS dt +ON big.id=dt.dt_id; +id dt_id eq ne gt ge lt le equal +1 1 1 0 0 1 0 1 1 +2 2 0 1 1 1 0 0 0 +3 NULL NULL NULL NULL NULL NULL NULL NULL +4 NULL NULL NULL NULL NULL NULL NULL NULL +# Check CASE, NULLIF and COALESCE +SELECT big.*, dt.* +FROM big LEFT JOIN (SELECT id as dt_id, +CASE id WHEN 0 THEN 0 ELSE 1 END AS simple, +CASE WHEN id=0 THEN NULL ELSE 1 END AS cond, +NULLIF(1, NULL) AS nullif, +IFNULL(1, NULL) AS ifnull, +COALESCE(id) AS coal, +INTERVAL(NULL, 1, 2, 3) as intv, +IF (id % 2 = 1, NULL, 1) AS iff +FROM small) AS dt +ON big.id=dt.dt_id; +id dt_id simple cond nullif ifnull coal intv iff +1 1 1 1 1 1 1 -1 NULL +2 2 1 1 1 1 2 -1 1 +3 NULL NULL NULL NULL NULL NULL NULL NULL +4 NULL NULL NULL NULL NULL NULL NULL NULL +DROP VIEW small_view, big_view; +DROP TABLE small, big; +# +# Bug#16893426 OPTIMIZER FAILS TO OPTIMIZE EXPRESSION OF THE +# FORM 'FOO' IS NULL +# +CREATE TABLE t1 ( +id int(11) NOT NULL PRIMARY KEY, +name varchar(20), +INDEX (name) +) ENGINE=InnoDB; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t2 ( +id int(11) NOT NULL PRIMARY KEY, +f_id int(11), +FOREIGN KEY (f_id) REFERENCES t2(id) +) ENGINE=InnoDB; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (1,'A1'),(2,'A2'),(3,'B'); +INSERT INTO t2 VALUES (1,1),(2,2),(3,2),(4,3),(5,3); +ANALYZE TABLE t1; +ANALYZE TABLE t2; +EXPLAIN SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE t1.name LIKE 'A%'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range PRIMARY,name name 83 NULL 2 100.00 Using where; Using index +2 SIMPLE t2 NULL ref f_id f_id 5 test.t1.id 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`id` AS `id`,`test`.`t2`.`f_id` AS `f_id`,`test`.`t1`.`id` AS `id`,`test`.`t1`.`name` AS `name` from `test`.`t2` join `test`.`t1` where ((`test`.`t2`.`f_id` = `test`.`t1`.`id`) and (`test`.`t1`.`name` like 'A%')) +SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE t1.name LIKE 'A%'; +id f_id id name +1 1 1 A1 +2 2 2 A2 +3 2 2 A2 +PREPARE stmt FROM "SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE t1.name LIKE 'A%'"; +EXECUTE stmt; +id f_id id name +1 1 1 A1 +2 2 2 A2 +3 2 2 A2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE t1.name LIKE 'A%' OR 'ASDFGH' IS NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range PRIMARY,name name 83 NULL 2 100.00 Using where; Using index +2 SIMPLE t2 NULL ref f_id f_id 5 test.t1.id 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`id` AS `id`,`test`.`t2`.`f_id` AS `f_id`,`test`.`t1`.`id` AS `id`,`test`.`t1`.`name` AS `name` from `test`.`t2` join `test`.`t1` where ((`test`.`t2`.`f_id` = `test`.`t1`.`id`) and (`test`.`t1`.`name` like 'A%')) +SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE t1.name LIKE 'A%' OR 'ASDFGH' IS NULL; +id f_id id name +1 1 1 A1 +2 2 2 A2 +3 2 2 A2 +PREPARE stmt FROM "SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE t1.name LIKE 'A%' OR 'ASDFGH' IS NULL"; +EXECUTE stmt; +id f_id id name +1 1 1 A1 +2 2 2 A2 +3 2 2 A2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE 0 OR 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`id` AS `id`,`test`.`t2`.`f_id` AS `f_id`,`test`.`t1`.`id` AS `id`,`test`.`t1`.`name` AS `name` from `test`.`t2` left join `test`.`t1` on(multiple equal(`test`.`t2`.`f_id`, `test`.`t1`.`id`)) where false +SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE 0 OR 0; +id f_id id name +PREPARE stmt FROM "SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE 0 OR 0"; +EXECUTE stmt; +id f_id id name +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE 1 OR 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL index NULL f_id 5 NULL 5 100.00 Using index +2 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.f_id 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`id` AS `id`,`test`.`t2`.`f_id` AS `f_id`,`test`.`t1`.`id` AS `id`,`test`.`t1`.`name` AS `name` from `test`.`t2` left join `test`.`t1` on((`test`.`t1`.`id` = `test`.`t2`.`f_id`)) where true +SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE 1 OR 0; +id f_id id name +1 1 1 A1 +2 2 2 A2 +3 2 2 A2 +4 3 3 B +5 3 3 B +PREPARE stmt FROM "SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE 1 OR 0"; +EXECUTE stmt; +id f_id id name +1 1 1 A1 +2 2 2 A2 +3 2 2 A2 +4 3 3 B +5 3 3 B +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE NOT(NOT (0)) OR 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL index NULL f_id 5 NULL 5 100.00 Using index +2 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.f_id 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`id` AS `id`,`test`.`t2`.`f_id` AS `f_id`,`test`.`t1`.`id` AS `id`,`test`.`t1`.`name` AS `name` from `test`.`t2` left join `test`.`t1` on((`test`.`t1`.`id` = `test`.`t2`.`f_id`)) where true +SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE NOT(NOT (0)) OR 1; +id f_id id name +1 1 1 A1 +2 2 2 A2 +3 2 2 A2 +4 3 3 B +5 3 3 B +PREPARE stmt FROM "SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE NOT(NOT (0)) OR 1"; +EXECUTE stmt; +id f_id id name +1 1 1 A1 +2 2 2 A2 +3 2 2 A2 +4 3 3 B +5 3 3 B +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE NOT(NOT (0)) OR 0 = 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`id` AS `id`,`test`.`t2`.`f_id` AS `f_id`,`test`.`t1`.`id` AS `id`,`test`.`t1`.`name` AS `name` from `test`.`t2` left join `test`.`t1` on(multiple equal(`test`.`t2`.`f_id`, `test`.`t1`.`id`)) where false +SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE NOT(NOT (0)) OR 0 = 1; +id f_id id name +PREPARE stmt FROM "SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE NOT(NOT (0)) OR 0 = 1"; +EXECUTE stmt; +id f_id id name +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE 1 IS NOT TRUE AND 0 IS TRUE ; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`id` AS `id`,`test`.`t2`.`f_id` AS `f_id`,`test`.`t1`.`id` AS `id`,`test`.`t1`.`name` AS `name` from `test`.`t2` left join `test`.`t1` on(multiple equal(`test`.`t2`.`f_id`, `test`.`t1`.`id`)) where false +SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE 1 IS NOT TRUE AND 0 IS TRUE ; +id f_id id name +PREPARE stmt FROM "SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE 1 IS NOT TRUE AND 0 IS TRUE "; +EXECUTE stmt; +id f_id id name +EXPLAIN SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE 'a' LIKE 1 OR 2 LIKE '2%' ; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL index NULL f_id 5 NULL 5 100.00 Using index +2 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.f_id 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`id` AS `id`,`test`.`t2`.`f_id` AS `f_id`,`test`.`t1`.`id` AS `id`,`test`.`t1`.`name` AS `name` from `test`.`t2` left join `test`.`t1` on((`test`.`t1`.`id` = `test`.`t2`.`f_id`)) where true +SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE 'a' LIKE 1 OR 2 LIKE '2%' ; +id f_id id name +1 1 1 A1 +2 2 2 A2 +3 2 2 A2 +4 3 3 B +5 3 3 B +PREPARE stmt FROM "SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE 'a' LIKE 1 OR 2 LIKE '2%' "; +EXECUTE stmt; +id f_id id name +1 1 1 A1 +2 2 2 A2 +3 2 2 A2 +4 3 3 B +5 3 3 B +EXPLAIN SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE 1 IS NOT NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL index NULL f_id 5 NULL 5 100.00 Using index +2 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.f_id 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`id` AS `id`,`test`.`t2`.`f_id` AS `f_id`,`test`.`t1`.`id` AS `id`,`test`.`t1`.`name` AS `name` from `test`.`t2` left join `test`.`t1` on((`test`.`t1`.`id` = `test`.`t2`.`f_id`)) where true +SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE 1 IS NOT NULL; +id f_id id name +1 1 1 A1 +2 2 2 A2 +3 2 2 A2 +4 3 3 B +5 3 3 B +PREPARE stmt FROM "SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE 1 IS NOT NULL"; +EXECUTE stmt; +id f_id id name +1 1 1 A1 +2 2 2 A2 +3 2 2 A2 +4 3 3 B +5 3 3 B +EXPLAIN SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE (1<2 AND 2<3) OR (1>1 AND 2<3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL index NULL f_id 5 NULL 5 100.00 Using index +2 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.f_id 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`id` AS `id`,`test`.`t2`.`f_id` AS `f_id`,`test`.`t1`.`id` AS `id`,`test`.`t1`.`name` AS `name` from `test`.`t2` left join `test`.`t1` on((`test`.`t1`.`id` = `test`.`t2`.`f_id`)) where true +SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE (1<2 AND 2<3) OR (1>1 AND 2<3); +id f_id id name +1 1 1 A1 +2 2 2 A2 +3 2 2 A2 +4 3 3 B +5 3 3 B +PREPARE stmt FROM "SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE (1<2 AND 2<3) OR (1>1 AND 2<3)"; +EXECUTE stmt; +id f_id id name +1 1 1 A1 +2 2 2 A2 +3 2 2 A2 +4 3 3 B +5 3 3 B +EXPLAIN SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE (1>=1 AND 2<=2) OR (1=1 AND 2<3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL index NULL f_id 5 NULL 5 100.00 Using index +2 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.f_id 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`id` AS `id`,`test`.`t2`.`f_id` AS `f_id`,`test`.`t1`.`id` AS `id`,`test`.`t1`.`name` AS `name` from `test`.`t2` left join `test`.`t1` on((`test`.`t1`.`id` = `test`.`t2`.`f_id`)) where true +SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE (1>=1 AND 2<=2) OR (1=1 AND 2<3); +id f_id id name +1 1 1 A1 +2 2 2 A2 +3 2 2 A2 +4 3 3 B +5 3 3 B +PREPARE stmt FROM "SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE (1>=1 AND 2<=2) OR (1=1 AND 2<3)"; +EXECUTE stmt; +id f_id id name +1 1 1 A1 +2 2 2 A2 +3 2 2 A2 +4 3 3 B +5 3 3 B +EXPLAIN SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE (1<>1 AND 2=2) OR (1 BETWEEN 0 AND 2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL index NULL f_id 5 NULL 5 100.00 Using index +2 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.f_id 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`id` AS `id`,`test`.`t2`.`f_id` AS `f_id`,`test`.`t1`.`id` AS `id`,`test`.`t1`.`name` AS `name` from `test`.`t2` left join `test`.`t1` on((`test`.`t1`.`id` = `test`.`t2`.`f_id`)) where true +SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE (1<>1 AND 2=2) OR (1 BETWEEN 0 AND 2); +id f_id id name +1 1 1 A1 +2 2 2 A2 +3 2 2 A2 +4 3 3 B +5 3 3 B +PREPARE stmt FROM "SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE (1<>1 AND 2=2) OR (1 BETWEEN 0 AND 2)"; +EXECUTE stmt; +id f_id id name +1 1 1 A1 +2 2 2 A2 +3 2 2 A2 +4 3 3 B +5 3 3 B +DROP TABLE t1,t2; +# +# Bug#22103398 BUG#16893426:SIG11 IN +# ST_SELECT_LEX::FLATTEN_SUBQUERIES | SQL_RESOLVER.CC +# +CREATE TABLE t1(c1 INT, c2 INT, c3 CHAR(1), KEY(c3))ENGINE=InnoDB; +CREATE TABLE t2(c1 INT, c2 INT, c3 CHAR(1), KEY(c3))ENGINE=InnoDB; +SELECT b.c2 AS f1 FROM (t2 AS a JOIN +((t2 AS b JOIN t2 AS c ON (c.c3=b.c3))) +ON (c.c1=b.c2)) +WHERE (c.c3 IN (SELECT subquery1_b.c3 AS subquery1_f1 +FROM (t1 AS subquery1_a JOIN t2 AS subquery1_b ON +(subquery1_b.c1=subquery1_a.c1)))) AND +(a.c1=a.c1 AND (SELECT''FROM DUAL) IS NULL); +f1 +DROP TABLE t1, t2; +# End of Bug#16893426 +# Bug#22561937 Wrong result on outer join with multiple join conditions +# and derived table +CREATE TABLE t1 ( +col_int INT, +pk INT NOT NULL, +PRIMARY KEY (pk) +); +INSERT INTO t1 VALUES +(2,1), (2,2), (6,3), (4,4), (7,5), +(188,6), (0,7), (6,8), (0,9), (9,10); +CREATE TABLE t2 ( +pk INT NOT NULL, +col_int INT, +PRIMARY KEY (pk) +); +INSERT INTO t2 VALUES +(1,0), (2,0), (3,2), (4,NULL), (5,2), +(6,3), (7,3), (8,100), (9,3), (10,6); +explain SELECT table2.pk, table1.col_int +FROM t2 AS table1 +LEFT JOIN t1 AS table2 +ON table2.pk < table1.col_int AND +table2.pk = table1.col_int; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 100.00 Parallel execute (1 workers) +2 SIMPLE table1 NULL ALL NULL NULL NULL NULL 10 100.00 NULL +2 SIMPLE table2 NULL eq_ref PRIMARY PRIMARY 4 test.table1.col_int 1 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`table2`.`pk` AS `pk`,`test`.`table1`.`col_int` AS `col_int` from `test`.`t2` `table1` left join `test`.`t1` `table2` on(((`test`.`table2`.`pk` = `test`.`table1`.`col_int`) and (`test`.`table1`.`col_int` < `test`.`table1`.`col_int`))) where true +SELECT table2.pk, table1.col_int +FROM t2 AS table1 +LEFT JOIN t1 AS table2 +ON table2.pk < table1.col_int AND +table2.pk = table1.col_int; +pk col_int +NULL 0 +NULL 0 +NULL 2 +NULL NULL +NULL 2 +NULL 3 +NULL 3 +NULL 100 +NULL 3 +NULL 6 +explain SELECT table2.pk, table1.col_int +FROM t2 AS table1 +LEFT JOIN (SELECT * FROM t1) AS table2 +ON table2.pk < table1.col_int AND +table2.pk = table1.col_int; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 100.00 Parallel execute (1 workers) +2 SIMPLE table1 NULL ALL NULL NULL NULL NULL 10 100.00 NULL +2 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.table1.col_int 1 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`table1`.`col_int` AS `col_int` from `test`.`t2` `table1` left join (`test`.`t1`) on(((`test`.`t1`.`pk` = `test`.`table1`.`col_int`) and (`test`.`t1`.`pk` < `test`.`table1`.`col_int`))) where true +SELECT table2.pk, table1.col_int +FROM t2 AS table1 +LEFT JOIN (SELECT * FROM t1) AS table2 +ON table2.pk < table1.col_int AND +table2.pk = table1.col_int; +pk col_int +NULL 0 +NULL 0 +NULL 2 +NULL NULL +NULL 2 +NULL 3 +NULL 3 +NULL 100 +NULL 3 +NULL 6 +DROP TABLE t1, t2; +# Bug#22671557: Wrong results on JOIN when composite index is present +CREATE TABLE t1 ( +col_int INT DEFAULT NULL, +col_int_key INT DEFAULT NULL, +pk INT NOT NULL, +PRIMARY KEY (pk), +KEY test_idx (col_int_key,col_int) +); +INSERT INTO t1 VALUES (0, -7, 1), (9, NULL, 15), (182, NULL, 25); +CREATE TABLE t2 ( +col_int INT DEFAULT NULL, +pk INT NOT NULL, +PRIMARY KEY (pk) +); +INSERT INTO t2 VALUES (NULL, 4), (-208, 5), (5, 6), (NULL, 75); +CREATE TABLE t3 ( +col_datetime_key DATETIME DEFAULT NULL, +pk INT NOT NULL, +PRIMARY KEY (pk) +); +INSERT INTO t3 VALUES ('1970-01-01 00:00:00', 5); +CREATE TABLE t4 ( +col_int INT DEFAULT NULL, +pk INT NOT NULL, +col_int_key INT DEFAULT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +); +INSERT INTO t4 VALUES (0, 15, 6), (9, 16, 6); +SELECT alias2.col_datetime_key +FROM +t1 AS alias1 +LEFT JOIN t3 AS alias2 +LEFT JOIN t2 AS alias3 +LEFT JOIN t4 AS alias4 +ON alias3.pk = alias4.col_int_key +ON alias2.pk = alias3.col_int +ON alias1.col_int = alias4.col_int +; +col_datetime_key +1970-01-01 00:00:00 +1970-01-01 00:00:00 +NULL +DROP TABLE t1, t2, t3, t4; +# Bug#22833364: Left join returns incorrect results on the outer side +CREATE TABLE ta ( +a1 varchar(1024) NOT NULL, +a2 int NOT NULL, +KEY user_id(a2) +); +INSERT INTO ta (a1, a2) VALUES ('row1', 4), ('row2', 4); +CREATE TABLE tb ( +b1 int NOT NULL, +b2 varchar(1024) NOT NULL, +b3 int NOT NULL, +PRIMARY KEY (b1) +); +INSERT INTO tb (b1, b2, b3) VALUES +(1, 'text1', 0), (2, 'text2', 0), (3, 'text3', 1), (4, 'text4', 1); +explain SELECT ta.a1, tb.b1, tb.b2 +FROM ta LEFT OUTER JOIN tb +ON ta.a2 = tb.b1 AND tb.b3 = 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE ta NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 SIMPLE tb NULL eq_ref PRIMARY PRIMARY 4 test.ta.a2 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`ta`.`a1` AS `a1`,`test`.`tb`.`b1` AS `b1`,`test`.`tb`.`b2` AS `b2` from `test`.`ta` left join `test`.`tb` on(((`test`.`tb`.`b3` = 0) and (`test`.`tb`.`b1` = `test`.`ta`.`a2`))) where true +SELECT ta.a1, tb.b1, tb.b2 +FROM ta LEFT OUTER JOIN tb +ON ta.a2 = tb.b1 AND tb.b3 = 0; +a1 b1 b2 +row1 NULL NULL +row2 NULL NULL +DROP TABLE ta, tb; +# Bug#23079533: Left join on PK + extra condition doesn't return match +CREATE TABLE m ( +machineid VARCHAR(32) NOT NULL, +orderid bigint unsigned DEFAULT NULL, +extra bigint unsigned DEFAULT NULL, +PRIMARY KEY (machineid) +); +INSERT INTO m (machineid, orderid) +VALUES ('m1', NULL), ('m2', 2), ('m3', NULL), ('m4', NULL); +CREATE TABLE o ( +orderid bigint unsigned NOT NULL, +machineid VARCHAR(32) DEFAULT NULL, +PRIMARY KEY (orderid) +); +INSERT INTO o (orderid, machineid) +VALUES (1, 'm2'), (2, 'm2'); +SELECT o.*,'|' as sep, m.* +FROM o LEFT JOIN m +ON m.machineid = o.machineid AND +m.orderid = o.orderid; +orderid machineid sep machineid orderid extra +1 m2 | NULL NULL NULL +2 m2 | m2 2 NULL +DROP TABLE m, o; +# Bug#23086825: Incorrect query results using left join against derived +CREATE TABLE t1 ( +adslot varchar(5) NOT NULL +); +INSERT INTO t1(adslot) VALUES ('1'), ('2'), ('3'); +CREATE TABLE t2 ( +ionumber varchar(20) NOT NULL, +adslot varchar(5) NOT NULL +); +INSERT INTO t2 (ionumber, adslot) VALUES ('01602', 1), ('01602', 3); +CREATE TABLE t3 ( +ionumber varchar(20) NOT NULL, +ioattribute varchar(5) NOT NULL, +PRIMARY KEY (ionumber) +); +INSERT INTO t3 VALUES ('01602', 'BOB'), ('01603', 'SALLY'); +SELECT s.adslot, lid.ionumber1, lid.ionumber2, lid.ioattribute +FROM t1 s LEFT JOIN +(SELECT lid.adslot, +i.ionumber as ionumber1, +lid.ionumber as ionumber2, +i.ioattribute +FROM t2 lid JOIN t3 i +USING (ionumber) +) AS lid +USING (adslot); +adslot ionumber1 ionumber2 ioattribute +1 01602 01602 BOB +2 NULL NULL NULL +3 01602 01602 BOB +DROP TABLE t1, t2, t3; +# +# Bug #26432173: INCORRECT SUBQUERY OPTIMIZATION WITH +# LEFT JOIN(SUBQUERY) AND ORDER BY +# +CREATE TABLE t1 (a INT); +INSERT t1 values (1),(2),(15),(24),(5); +CREATE TABLE t2 (t1_a INT, b VARCHAR(10)); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN SELECT t1.a, subq.st_value +FROM t1 +LEFT JOIN (SELECT t2.t1_a, 'red' AS st_value +FROM t2) AS subq +ON subq.t1_a = t1.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,'red' AS `st_value` from `test`.`t1` left join (`test`.`t2`) on((`test`.`t2`.`t1_a` = `test`.`t1`.`a`)) where true +EXPLAIN SELECT t1.a, subq.st_value +FROM t1 +LEFT JOIN (SELECT t2.t1_a, 'red' AS st_value +FROM t2) AS subq +ON subq.t1_a = t1.a +ORDER BY t1.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 100.00 Using temporary; Using filesort +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,'red' AS `st_value` from `test`.`t1` left join (`test`.`t2`) on((`test`.`t2`.`t1_a` = `test`.`t1`.`a`)) where true order by `test`.`t1`.`a` +EXPLAIN SELECT t1.a, subq.st_value +FROM (SELECT t2.t1_a, 'red' AS st_value +FROM t2) AS subq +LEFT JOIN t1 +ON subq.t1_a = t1.a +ORDER BY t1.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using temporary; Using filesort +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,'red' AS `st_value` from `test`.`t2` left join `test`.`t1` on((`test`.`t1`.`a` = `test`.`t2`.`t1_a`)) where true order by `test`.`t1`.`a` +SELECT t1.a, subq.st_value +FROM t1 +LEFT JOIN (SELECT t2.t1_a, 'red' AS st_value +FROM t2) AS subq +ON subq.t1_a = t1.a; +a st_value +1 NULL +2 NULL +15 NULL +24 NULL +5 NULL +SELECT t1.a, subq.st_value +FROM t1 +LEFT JOIN (SELECT t2.t1_a, 'red' AS st_value +FROM t2) AS subq +ON subq.t1_a = t1.a +ORDER BY t1.a; +a st_value +1 NULL +2 NULL +5 NULL +15 NULL +24 NULL +SELECT t1.a, subq.st_value +FROM (SELECT t2.t1_a, 'red' AS st_value +FROM t2) AS subq +LEFT JOIN t1 +ON subq.t1_a = t1.a +ORDER BY t1.a; +a st_value +DROP TABLE t1, t2; +# Bug #18898433: EXTREMELY SLOW PERFORMANCE WITH OUTER JOINS AND JOIN +# BUFFER. +# +CREATE TABLE t1 (i INT NOT NULL); +INSERT INTO t1 VALUES (0),(2),(3),(4); +CREATE TABLE t2 (i INT NOT NULL); +INSERT INTO t2 VALUES (0),(1),(3),(4); +CREATE TABLE t3 (i INT NOT NULL); +INSERT INTO t3 VALUES (0),(1),(2),(4); +CREATE TABLE t4 (i INT NOT NULL); +INSERT INTO t4 VALUES (0),(1),(2),(3); +ANALYZE TABLE t1, t2, t3, t4; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +test.t4 analyze status OK +EXPLAIN SELECT * +FROM t1 LEFT JOIN +( +(t2 LEFT JOIN t3 ON t3.i= t2.i) +LEFT JOIN t4 ON t3.i= t4.i +)ON t2.i= t1.i; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i`,`test`.`t2`.`i` AS `i`,`test`.`t3`.`i` AS `i`,`test`.`t4`.`i` AS `i` from `test`.`t1` left join (`test`.`t2` left join `test`.`t3` on((`test`.`t3`.`i` = `test`.`t2`.`i`)) left join `test`.`t4` on((`test`.`t4`.`i` = `test`.`t3`.`i`))) on((`test`.`t2`.`i` = `test`.`t1`.`i`)) where true +EXPLAIN SELECT * +FROM t1 LEFT JOIN +( +(t2 INNER JOIN t3 ON t3.i= t2.i) +LEFT JOIN t4 ON t3.i= t4.i +)ON t2.i= t1.i; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i`,`test`.`t2`.`i` AS `i`,`test`.`t3`.`i` AS `i`,`test`.`t4`.`i` AS `i` from `test`.`t1` left join (`test`.`t2` join `test`.`t3` left join `test`.`t4` on((`test`.`t4`.`i` = `test`.`t2`.`i`))) on(((`test`.`t2`.`i` = `test`.`t1`.`i`) and (`test`.`t3`.`i` = `test`.`t1`.`i`))) where true +EXPLAIN SELECT * +FROM t1 LEFT JOIN t2 ON t2.i= t1.i +LEFT JOIN t3 ON t3.i= t2.i +LEFT JOIN t4 ON t3.i= t4.i; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i`,`test`.`t2`.`i` AS `i`,`test`.`t3`.`i` AS `i`,`test`.`t4`.`i` AS `i` from `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t1`.`i`)) left join `test`.`t3` on((`test`.`t3`.`i` = `test`.`t2`.`i`)) left join `test`.`t4` on((`test`.`t4`.`i` = `test`.`t3`.`i`)) where true +flush status; +SELECT * +FROM t1 LEFT JOIN +( +(t2 LEFT JOIN t3 ON t3.i= t2.i) +LEFT JOIN t4 ON t3.i= t4.i +)ON t2.i= t1.i; +i i i i +0 0 0 0 +2 NULL NULL NULL +3 3 NULL NULL +4 4 4 NULL +SHOW STATUS LIKE 'HANDLER_%'; +Variable_name Value +Handler_commit 1 +Handler_delete 0 +Handler_discover 0 +Handler_external_lock 8 +Handler_mrr_init 0 +Handler_prepare 0 +Handler_read_first 4 +Handler_read_key 4 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 20 +Handler_rollback 0 +Handler_savepoint 0 +Handler_savepoint_rollback 0 +Handler_update 0 +Handler_write 0 +flush status; +SELECT * +FROM t1 LEFT JOIN +( +(t2 INNER JOIN t3 ON t3.i= t2.i) +LEFT JOIN t4 ON t3.i= t4.i +)ON t2.i= t1.i; +i i i i +0 0 0 0 +2 NULL NULL NULL +3 NULL NULL NULL +4 4 4 NULL +SHOW STATUS LIKE 'HANDLER_%'; +Variable_name Value +Handler_commit 1 +Handler_delete 0 +Handler_discover 0 +Handler_external_lock 8 +Handler_mrr_init 0 +Handler_prepare 0 +Handler_read_first 4 +Handler_read_key 4 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 20 +Handler_rollback 0 +Handler_savepoint 0 +Handler_savepoint_rollback 0 +Handler_update 0 +Handler_write 0 +flush status; +SELECT * +FROM t1 LEFT JOIN t2 ON t2.i= t1.i +LEFT JOIN t3 ON t3.i= t2.i +LEFT JOIN t4 ON t3.i= t4.i; +i i i i +0 0 0 0 +2 NULL NULL NULL +3 3 NULL NULL +4 4 4 NULL +SHOW STATUS LIKE 'HANDLER_%'; +Variable_name Value +Handler_commit 1 +Handler_delete 0 +Handler_discover 0 +Handler_external_lock 8 +Handler_mrr_init 0 +Handler_prepare 0 +Handler_read_first 4 +Handler_read_key 4 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 20 +Handler_rollback 0 +Handler_savepoint 0 +Handler_savepoint_rollback 0 +Handler_update 0 +Handler_write 0 +DROP TABLE t1, t2, t3, t4; +# +# Bug #26627181: WRONG RESULT WITH LEFT JOIN + DERIVED TABLES +# +CREATE TABLE t1 (id INT); +CREATE TABLE t2 (id INT); +INSERT INTO t1 VALUES (1), (2); +INSERT INTO t2 VALUES (1); +EXPLAIN SELECT * +FROM (SELECT id +FROM t1) AS a +LEFT JOIN +(SELECT id, 2 AS tall +FROM t2) AS b +ON a.id = b.id +WHERE b.tall IS NOT NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,`test`.`t2`.`id` AS `id`,2 AS `tall` from `test`.`t1` left join (`test`.`t2`) on((`test`.`t2`.`id` = `test`.`t1`.`id`)) where (2 is not null) +SELECT * +FROM (SELECT id +FROM t1) AS a +LEFT JOIN +(SELECT id, 2 AS tall +FROM t2) AS b +ON a.id = b.id +WHERE b.tall IS NOT NULL; +id id tall +1 1 2 +DROP TABLE t1, t2; +# +# Bug #23169204: Left join + merged derived table + group by = bad result +# +CREATE TABLE t1(doc text); +CREATE TABLE t2(a INTEGER DEFAULT NULL); +INSERT INTO t2 VALUES(1); +SELECT je +FROM t2 LEFT JOIN (SELECT 1 AS je FROM t1 LIMIT 1) AS dt ON FALSE; +je +NULL +SELECT je +FROM t2 LEFT JOIN (SELECT 1 AS je FROM t1 LIMIT 1) AS dt ON FALSE +GROUP BY je; +je +NULL +SELECT je +FROM t2 LEFT JOIN (SELECT 1 AS je FROM t1) AS dt ON FALSE; +je +NULL +SELECT je +FROM t2 LEFT JOIN (SELECT 1 AS je FROM t1) AS dt ON FALSE +GROUP BY je; +je +NULL +DROP TABLE t1, t2; +# +# Bug#22489105 WL#9571 : SIG11 IN ITEM_SUBSELECT::EXEC | SQL/ITEM_SUBSELECT.CC +# +SELECT (SELECT * FROM (SELECT 'a') t) AS f1 HAVING (f1 = 'a' OR TRUE); +f1 +a +SELECT (SELECT * FROM (SELECT 'a') t) + 1 AS f1 HAVING (f1 = 'a' OR TRUE); +f1 +1 +SELECT 1 + (SELECT * FROM (SELECT 'a') t) AS f1 HAVING (f1 = 'a' OR TRUE); +f1 +1 +# +# Bug#28237111: WL#9571: TABLE FULL ERROR +# +CREATE TABLE t1 (pk INTEGER, f1 INTEGER, primary key(pk)); +CREATE TABLE t2 (pk INTEGER, f1 INTEGER, primary key(pk)); +CREATE TABLE t3 (pk INTEGER); +INSERT INTO t1 VALUES (1,1),(2,1),(3,1); +INSERT INTO t2 VALUES (1,1),(2,1),(3,1); +INSERT INTO t3 VALUES (1); +SELECT * FROM (t1 RIGHT JOIN +(SELECT * FROM t3 WHERE (DAYNAME('1995'))) AS table2 ON +(( t1.f1 ,t1.pk) IN (SELECT 7,4 UNION SELECT 9,2))) WHERE +(NOT EXISTS (SELECT t1.f1 FROM (t1 INNER JOIN t2 ON (t1.pk=t2.f1)) +WHERE 0 IS NOT NULL)) AND t1.f1 > 50; +pk f1 pk +Warnings: +Warning 1292 Incorrect datetime value: '1995' +DROP TABLE t3,t1,t2; +# +# Bug#28341790: WL#9571: SIG11 IN ITEM_COND::FIX_FIELDS() AT SQL/ITEM_CMPFUNC.CC +# +CREATE TABLE t1 (col_varchar varchar(1) DEFAULT NULL); +INSERT INTO t1 VALUES ('Z') ; +CREATE TABLE t2 (col_varchar varchar(1) DEFAULT NULL); +INSERT INTO t2 VALUES ('Z') ; +PREPARE prep_stmt FROM " SELECT 1 FROM ( ( SELECT * FROM t1 WHERE col_varchar +>= 1 ) AS table1 RIGHT JOIN t2 ON ( ( NULL < NULL ) IS NULL OR 1 = 0 ) ) " ; +EXECUTE prep_stmt ; +1 +1 +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'Z' +EXECUTE prep_stmt ; +1 +1 +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'Z' +DROP TABLE t1,t2; +# +# More coverage for IS TRUE in LEFT JOIN conditions +# +CREATE TABLE t1(c1 INT); +INSERT INTO t1 VALUES(1),(2); +CREATE TABLE t2(c2 INT); +INSERT INTO t2 VALUES(1); +SELECT * FROM t1 LEFT JOIN t2 ON c1=c2; +c1 c2 +1 1 +2 NULL +SELECT * FROM t1 LEFT JOIN t2 ON c1=c2 WHERE c2 IS NULL; +c1 c2 +2 NULL +SELECT * FROM t1 LEFT JOIN t2 ON c1=c2 WHERE c2 IS NOT NULL; +c1 c2 +1 1 +SELECT * FROM t1 LEFT JOIN t2 ON c1=c2 WHERE (c2 IS NOT NULL) = 1; +c1 c2 +1 1 +SELECT * FROM t1 LEFT JOIN t2 ON c1=c2 WHERE (c2 IS NOT NULL) IS TRUE; +c1 c2 +1 1 +SELECT * FROM t1 LEFT JOIN t2 ON c1=c2 WHERE (c2 IS NOT NULL) = 0; +c1 c2 +2 NULL +SELECT * FROM t1 LEFT JOIN t2 ON c1=c2 WHERE (c2 IS NOT NULL) IS FALSE; +c1 c2 +2 NULL +DROP TABLE t1,t2; +# +# Bug#29402481: INCORRECT RESULT FROM OUTER JOIN QUERIES +# +CREATE TABLE t1 ( +pk int primary key auto_increment, +col_int_unique int unique +) ENGINE=InnoDB; +INSERT INTO t1(col_int_unique) values (6),(7); +CREATE TABLE t2 ( +pk int primary key auto_increment, +col_int_key int(11) DEFAULT NULL, +col_int_unique int(11) DEFAULT NULL, +UNIQUE KEY `ix2` (col_int_key,col_int_unique), +KEY col_int_key (col_int_key) +) ENGINE=InnoDB; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t3 ( +pk int NOT NULL +) ENGINE=InnoDB; +INSERT INTO t3(pk) values (6),(7); +SELECT STRAIGHT_JOIN t1.col_int_unique, t2.col_int_key, t3.pk +FROM +(t1 LEFT JOIN t2 ON t1.col_int_unique = t2.col_int_key) +LEFT JOIN t3 ON t3.pk = t1.col_int_unique AND +t1.col_int_unique = t2.col_int_key; +col_int_unique col_int_key pk +6 NULL NULL +7 NULL NULL +DROP TABLE t1,t2,t3; +# +# Bug#29493830 CONST'IFIED OUTER JOIN RETURN INCORRECT RESULTS +# +CREATE TABLE t1 ( +col_int_unique INT DEFAULT NULL, +col_int_key INT DEFAULT NULL, +UNIQUE KEY col_int_unique (col_int_unique) +) ENGINE=InnoDB; +INSERT INTO t1 VALUES (5,0); +CREATE TABLE t2 ( +col_char_16_unique char(16) DEFAULT NULL, +col_int_key INT DEFAULT NULL, +col_int_unique INT DEFAULT NULL, +UNIQUE KEY col_int_unique (col_int_unique) +) ENGINE=InnoDB; +INSERT INTO t2 VALUES ("just",21,5); +CREATE TABLE t3 ( +col_int INT DEFAULT NULL, +col_char_16_unique CHAR(16) DEFAULT NULL, +UNIQUE KEY col_char_16_unique (col_char_16_unique) +) ENGINE=InnoDB; +INSERT INTO t3 VALUES (9,"foo"); +CREATE TABLE t4 ( +col_int INT DEFAULT NULL, +col_int_unique INT DEFAULT NULL, +UNIQUE KEY col_int_unique (col_int_unique) +) ENGINE=InnoDB; +INSERT INTO t4 VALUES (9,5); +explain SELECT STRAIGHT_JOIN +t3.col_int, t4.col_int, +t3.col_int = t4.col_int or t4.col_int IS NULL +FROM (t1 +LEFT JOIN t2 +ON t1.col_int_key = t2.col_int_key AND +t1.col_int_unique = t2.col_int_unique +LEFT JOIN t3 +ON t3.col_char_16_unique = t2.col_char_16_unique +LEFT JOIN t4 +ON t4.col_int = t3.col_int AND #Note, this pred term +t4.col_int_unique = t1.col_int_unique +) WHERE t1.col_int_unique = 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL const col_int_unique col_int_unique 5 const 1 100.00 NULL +1 SIMPLE t2 NULL const col_int_unique col_int_unique 5 const 1 100.00 Impossible ON condition +1 SIMPLE t3 NULL const col_char_16_unique NULL NULL NULL 1 100.00 Impossible ON condition +1 SIMPLE t4 NULL const col_int_unique col_int_unique 5 const 1 100.00 Impossible ON condition +Warnings: +Note 1003 /* select#1 */ select straight_join NULL AS `col_int`,NULL AS `col_int`,((NULL = NULL) or (NULL is null)) AS `t3.col_int = t4.col_int or t4.col_int IS NULL` from `test`.`t1` left join `test`.`t2` on((multiple equal('0', NULL) and multiple equal(5, NULL))) left join `test`.`t3` on(multiple equal(NULL, NULL)) left join `test`.`t4` on((multiple equal(NULL, NULL) and multiple equal(5, NULL))) where true +SELECT STRAIGHT_JOIN +t3.col_int, t4.col_int, +t3.col_int = t4.col_int or t4.col_int IS NULL +FROM (t1 +LEFT JOIN t2 +ON t1.col_int_key = t2.col_int_key AND +t1.col_int_unique = t2.col_int_unique +LEFT JOIN t3 +ON t3.col_char_16_unique = t2.col_char_16_unique +LEFT JOIN t4 +ON t4.col_int = t3.col_int AND #Note, this pred term +t4.col_int_unique = t1.col_int_unique +) WHERE t1.col_int_unique = 5; +col_int col_int t3.col_int = t4.col_int or t4.col_int IS NULL +NULL NULL 1 +DROP TABLE t1, t2, t3, t4; +# +# Bug #30659532: WL#13476: DIFFERENT NUMBER OF ROWS WITH NESTED LOOP JOINS +# +CREATE TABLE t1 ( +pk INTEGER NOT NULL +); +INSERT INTO t1 VALUES (1); +INSERT INTO t1 VALUES (2); +CREATE TABLE t2 ( +pk INTEGER NOT NULL, +PRIMARY KEY (pk) +); +INSERT INTO t2 VALUES (1); +INSERT INTO t2 VALUES (2); +INSERT INTO t2 VALUES (3); +CREATE TABLE t3 ( +f1 INTEGER, +f2 INTEGER, +KEY k2 (f2) +); +INSERT INTO t3 VALUES (NULL,NULL); +INSERT INTO t3 VALUES (NULL,295010100); +INSERT INTO t3 VALUES (NULL,NULL); +INSERT INTO t3 VALUES (NULL,-1762438755); +INSERT INTO t3 VALUES (NULL,4); +ANALYZE TABLE t1, t2, t3; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +EXPLAIN FORMAT=tree SELECT * FROM t1 LEFT JOIN t2 ON t1.pk = t2.pk LEFT JOIN t3 ON t2.pk = t3.f2 WHERE t2.pk < 5; +EXPLAIN +-> Parallel scan on + -> Batched key access left join + -> Batch input rows + -> Nested loop inner join (cost=1.15 rows=2) + -> Filter: (t1.pk < 5) (cost=0.45 rows=2) + -> PQblock scan on t1 (cost=0.45 rows=2) + -> Single-row index lookup on t2 using PRIMARY (pk=t1.pk) (cost=0.30 rows=1) + -> Multi-range index lookup on t3 using k2 (f2=t1.pk) + +SELECT * FROM t1 LEFT JOIN t2 ON t1.pk = t2.pk LEFT JOIN t3 ON t2.pk = t3.f2 WHERE t2.pk < 5; +pk pk f1 f2 +1 1 NULL NULL +2 2 NULL NULL +DROP TABLE t1, t2, t3; +# +# Bug #30654713: WL#13476: DIFFERENT ROWS WITH BATCHED KEY ACCESS LEFT JOIN +# +CREATE TABLE t1 ( +col_int INTEGER, +a INTEGER, +b varchar(10), +KEY key_a (a) +); +INSERT INTO t1 VALUES (5,NULL,'p'); +INSERT INTO t1 VALUES (6,NULL,''); +INSERT INTO t1 VALUES (7,NULL,''); +INSERT INTO t1 VALUES (8,NULL,'Z'); +INSERT INTO t1 VALUES (9,4,'g'); +INSERT INTO t1 VALUES (10,NULL,'if'); +INSERT INTO t1 VALUES (11,NULL,'j'); +INSERT INTO t1 VALUES (12,9,''); +CREATE TABLE t2 ( +a INTEGER, +b varchar(10), +KEY key_b (b) +); +INSERT INTO t2 VALUES (1,'j'); +INSERT INTO t2 VALUES (2,'o'); +INSERT INTO t2 VALUES (3,'z'); +INSERT INTO t2 VALUES (4,'really'); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN format=tree SELECT t1.col_int as t1_ci, t1.a as t1_a, t1.b as t1_b, t2.a as t2_a, t2.b as t2_b, t3.col_int as t3_ci, t3.a as t3_a, t3.b as t3_b +FROM t1 +LEFT JOIN ( t2 LEFT JOIN t1 AS t3 ON t2.a=t3.a ) +ON t1.b = t2.b; +EXPLAIN +-> Parallel scan on + -> Left hash join (t2.b = t1.b) (cost=23.25 rows=144) + -> PQblock scan on t1 (cost=1.05 rows=8) + -> Hash + -> Left hash join (t3.a = t2.a) (cost=3.70 rows=24) + -> Table scan on t2 (cost=0.08 rows=4) + -> Hash + -> Table scan on t3 (cost=0.04 rows=8) + +SELECT t1.col_int as t1_ci, t1.a as t1_a, t1.b as t1_b, t2.a as t2_a, t2.b as t2_b, t3.col_int as t3_ci, t3.a as t3_a, t3.b as t3_b +FROM t1 +LEFT JOIN ( t2 LEFT JOIN t1 AS t3 ON t2.a=t3.a ) +ON t1.b = t2.b; +t1_ci t1_a t1_b t2_a t2_b t3_ci t3_a t3_b +10 NULL if NULL NULL NULL NULL NULL +11 NULL j 1 j NULL NULL NULL +12 9 NULL NULL NULL NULL NULL +5 NULL p NULL NULL NULL NULL NULL +6 NULL NULL NULL NULL NULL NULL +7 NULL NULL NULL NULL NULL NULL +8 NULL Z 3 z NULL NULL NULL +9 4 g NULL NULL NULL NULL NULL +DROP TABLE t1, t2; +# +# Bug#30520749 - REGRESSION: LEFT JOIN WITH IMPOSSIBLE ON CONDITION PERFORMS SLOWLY +# +set optimizer_switch='block_nested_loop=off'; +CREATE TABLE t1 ( f1 INTEGER ); +INSERT INTO t1 VALUES (1), (2), (3), (4), (5); +CREATE TABLE t2 AS SELECT * FROM t1; +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN FORMAT=tree SELECT * FROM t1 LEFT JOIN t2 ON 1=2; +EXPLAIN +-> Parallel scan on + -> Nested loop left join (cost=4.50 rows=25) + -> PQblock scan on t1 (cost=0.75 rows=5) + -> Zero rows (Impossible filter) (cost=0.07..0.35 rows=5) + +DROP TABLE t1, t2; +set optimizer_switch='block_nested_loop=on'; +# +# Bug #31252625: DATA IN WRONG ROW ON LEFT JOIN +# +CREATE TABLE t1 ( +id INTEGER NOT NULL, +b INTEGER, +PRIMARY KEY (id) +); +INSERT INTO t1 VALUES (17,NULL); +INSERT INTO t1 VALUES (136,564); +INSERT INTO t1 VALUES (137,NULL); +CREATE TABLE t2 ( +id INTEGER NOT NULL, +PRIMARY KEY (id) +); +INSERT INTO t2 VALUES (564); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +SELECT * FROM t1 LEFT JOIN t2 ON t1.b = t2.id GROUP BY t1.id; +id b id +17 NULL NULL +136 564 564 +137 NULL NULL +DROP TABLE t1, t2; +set optimizer_switch=default; diff --git a/mysql-test/r/join_outer_bka_nobnl.result-pq b/mysql-test/r/join_outer_bka_nobnl.result-pq new file mode 100644 index 000000000000..16a915a9a878 --- /dev/null +++ b/mysql-test/r/join_outer_bka_nobnl.result-pq @@ -0,0 +1,3835 @@ +set optimizer_switch='batched_key_access=on,block_nested_loop=off,mrr_cost_based=off'; +drop table if exists t0,t1,t2,t3,t4,t5; +CREATE TABLE t1 ( +grp int(11) default NULL, +a bigint(20) unsigned default NULL, +c char(10) NOT NULL default '' +) ENGINE=MyISAM; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (1,1,'a'),(2,2,'b'),(2,3,'c'),(3,4,'E'),(3,5,'C'),(3,6,'D'),(NULL,NULL,''); +create table t2 (id int, a bigint unsigned not null, c char(10), d int, primary key (a)); +insert into t2 values (1,1,"a",1),(3,4,"A",4),(3,5,"B",5),(3,6,"C",6),(4,7,"D",7); +select t1.*,t2.* from t1 JOIN t2 where t1.a=t2.a; +grp a c id a c d +1 1 a 1 1 a 1 +3 4 E 3 4 A 4 +3 5 C 3 5 B 5 +3 6 D 3 6 C 6 +EXPLAIN FORMAT=tree select t1.*,t2.* from t1 left join t2 on (t1.a=t2.a) order by t1.grp,t1.a,t2.c; +EXPLAIN +-> Sort: t1.grp, t1.a, t2.c + -> Stream results (cost=3.67 rows=7) + -> Nested loop left join (cost=3.67 rows=7) + -> Table scan on t1 (cost=1.22 rows=7) + -> Single-row index lookup on t2 using PRIMARY (a=t1.a) (cost=0.26 rows=1) + +select t1.*,t2.* from t1 left join t2 on (t1.a=t2.a) order by t1.grp,t1.a,t2.c; +grp a c id a c d +NULL NULL NULL NULL NULL NULL +1 1 a 1 1 a 1 +2 2 b NULL NULL NULL NULL +2 3 c NULL NULL NULL NULL +3 4 E 3 4 A 4 +3 5 C 3 5 B 5 +3 6 D 3 6 C 6 +select t1.*,t2.* from { oj t2 left outer join t1 on (t1.a=t2.a) }; +grp a c id a c d +1 1 a 1 1 a 1 +3 4 E 3 4 A 4 +3 5 C 3 5 B 5 +3 6 D 3 6 C 6 +NULL NULL NULL 4 7 D 7 +select t1.*,t2.* from t1 as t0,{ oj t2 left outer join t1 on (t1.a=t2.a) } WHERE t0.a=2; +grp a c id a c d +1 1 a 1 1 a 1 +3 4 E 3 4 A 4 +3 5 C 3 5 B 5 +3 6 D 3 6 C 6 +NULL NULL NULL 4 7 D 7 +select t1.*,t2.* from t1 left join t2 using (a); +grp a c id a c d +1 1 a 1 1 a 1 +2 2 b NULL NULL NULL NULL +2 3 c NULL NULL NULL NULL +3 4 E 3 4 A 4 +3 5 C 3 5 B 5 +3 6 D 3 6 C 6 +NULL NULL NULL NULL NULL NULL +select t1.*,t2.* from t1 left join t2 using (a) where t1.a=t2.a; +grp a c id a c d +1 1 a 1 1 a 1 +3 4 E 3 4 A 4 +3 5 C 3 5 B 5 +3 6 D 3 6 C 6 +select t1.*,t2.* from t1 left join t2 using (a,c); +grp a c id a c d +1 1 a 1 1 a 1 +2 2 b NULL NULL NULL NULL +2 3 c NULL NULL NULL NULL +3 4 E NULL NULL NULL NULL +3 5 C NULL NULL NULL NULL +3 6 D NULL NULL NULL NULL +NULL NULL NULL NULL NULL NULL +select t1.*,t2.* from t1 left join t2 using (c); +grp a c id a c d +1 1 a 1 1 a 1 +1 1 a 3 4 A 4 +2 2 b 3 5 B 5 +2 3 c 3 6 C 6 +3 4 E NULL NULL NULL NULL +3 5 C 3 6 C 6 +3 6 D 4 7 D 7 +NULL NULL NULL NULL NULL NULL +select t1.*,t2.* from t1 natural left outer join t2; +grp a c id a c d +1 1 a 1 1 a 1 +2 2 b NULL NULL NULL NULL +2 3 c NULL NULL NULL NULL +3 4 E NULL NULL NULL NULL +3 5 C NULL NULL NULL NULL +3 6 D NULL NULL NULL NULL +NULL NULL NULL NULL NULL NULL +select t1.*,t2.* from t1 left join t2 on (t1.a=t2.a) where t2.id=3; +grp a c id a c d +3 4 E 3 4 A 4 +3 5 C 3 5 B 5 +3 6 D 3 6 C 6 +select t1.*,t2.* from t1 left join t2 on (t1.a=t2.a) where t2.id is null; +grp a c id a c d +2 2 b NULL NULL NULL NULL +2 3 c NULL NULL NULL NULL +NULL NULL NULL NULL NULL NULL +explain select t1.*,t2.* from t1,t2 where t1.a=t2.a and isnull(t2.a)=1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`grp` AS `grp`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`c` AS `c`,`test`.`t2`.`id` AS `id`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`c` AS `c`,`test`.`t2`.`d` AS `d` from `test`.`t1` join `test`.`t2` where false +explain select t1.*,t2.* from t1 left join t2 on t1.a=t2.a where isnull(t2.a)=1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 7 100.00 NULL +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 8 test.t1.a 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`grp` AS `grp`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`c` AS `c`,`test`.`t2`.`id` AS `id`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`c` AS `c`,`test`.`t2`.`d` AS `d` from `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`a` = `test`.`t1`.`a`)) where ((`test`.`t2`.`a` is null) = 1) +select t1.*,t2.*,t3.a from t1 left join t2 on (t1.a=t2.a) left join t1 as t3 on (t2.a=t3.a); +grp a c id a c d a +1 1 a 1 1 a 1 1 +2 2 b NULL NULL NULL NULL NULL +2 3 c NULL NULL NULL NULL NULL +3 4 E 3 4 A 4 4 +3 5 C 3 5 B 5 5 +3 6 D 3 6 C 6 6 +NULL NULL NULL NULL NULL NULL NULL +explain select t1.*,t2.*,t3.a from t1 left join t2 on (t3.a=t2.a) left join t1 as t3 on (t1.a=t3.a); +ERROR 42S22: Unknown column 't3.a' in 'on clause' +select t1.*,t2.*,t3.a from t1 left join t2 on (t3.a=t2.a) left join t1 as t3 on (t1.a=t3.a); +ERROR 42S22: Unknown column 't3.a' in 'on clause' +select t1.*,t2.*,t3.a from t1 left join t2 on (t3.a=t2.a) left join t1 as t3 on (t2.a=t3.a); +ERROR 42S22: Unknown column 't3.a' in 'on clause' +select t1.*,t2.* from t1 inner join t2 using (a); +grp a c id a c d +1 1 a 1 1 a 1 +3 4 E 3 4 A 4 +3 5 C 3 5 B 5 +3 6 D 3 6 C 6 +select t1.*,t2.* from t1 inner join t2 on (t1.a=t2.a); +grp a c id a c d +1 1 a 1 1 a 1 +3 4 E 3 4 A 4 +3 5 C 3 5 B 5 +3 6 D 3 6 C 6 +select t1.*,t2.* from t1 natural join t2; +grp a c id a c d +1 1 a 1 1 a 1 +drop table t1,t2; +CREATE TABLE t1 ( +usr_id INT unsigned NOT NULL, +uniq_id INT unsigned NOT NULL AUTO_INCREMENT, +start_num INT unsigned NOT NULL DEFAULT 1, +increment INT unsigned NOT NULL DEFAULT 1, +PRIMARY KEY (uniq_id), +INDEX usr_uniq_idx (usr_id, uniq_id), +INDEX uniq_usr_idx (uniq_id, usr_id) +); +CREATE TABLE t2 ( +id INT unsigned NOT NULL DEFAULT 0, +usr2_id INT unsigned NOT NULL DEFAULT 0, +max INT unsigned NOT NULL DEFAULT 0, +c_amount INT unsigned NOT NULL DEFAULT 0, +d_max INT unsigned NOT NULL DEFAULT 0, +d_num INT unsigned NOT NULL DEFAULT 0, +orig_time INT unsigned NOT NULL DEFAULT 0, +c_time INT unsigned NOT NULL DEFAULT 0, +active ENUM ("no","yes") NOT NULL, +PRIMARY KEY (id,usr2_id), +INDEX id_idx (id), +INDEX usr2_idx (usr2_id) +); +INSERT INTO t1 VALUES (3,NULL,0,50),(3,NULL,0,200),(3,NULL,0,25),(3,NULL,0,84676),(3,NULL,0,235),(3,NULL,0,10),(3,NULL,0,3098),(3,NULL,0,2947),(3,NULL,0,8987),(3,NULL,0,8347654),(3,NULL,0,20398),(3,NULL,0,8976),(3,NULL,0,500),(3,NULL,0,198); +SELECT t1.usr_id,t1.uniq_id,t1.increment, +t2.usr2_id,t2.c_amount,t2.max +FROM t1 +LEFT JOIN t2 ON t2.id = t1.uniq_id +WHERE t1.uniq_id = 4 +ORDER BY t2.c_amount; +usr_id uniq_id increment usr2_id c_amount max +3 4 84676 NULL NULL NULL +SELECT t1.usr_id,t1.uniq_id,t1.increment, +t2.usr2_id,t2.c_amount,t2.max +FROM t2 +RIGHT JOIN t1 ON t2.id = t1.uniq_id +WHERE t1.uniq_id = 4 +ORDER BY t2.c_amount; +usr_id uniq_id increment usr2_id c_amount max +3 4 84676 NULL NULL NULL +INSERT INTO t2 VALUES (2,3,3000,6000,0,0,746584,837484,'yes'); +INSERT INTO t2 VALUES (2,3,3000,6000,0,0,746584,837484,'yes'); +ERROR 23000: Duplicate entry '2-3' for key 't2.PRIMARY' +INSERT INTO t2 VALUES (7,3,1000,2000,0,0,746294,937484,'yes'); +SELECT t1.usr_id,t1.uniq_id,t1.increment,t2.usr2_id,t2.c_amount,t2.max FROM t1 LEFT JOIN t2 ON t2.id = t1.uniq_id WHERE t1.uniq_id = 4 ORDER BY t2.c_amount; +usr_id uniq_id increment usr2_id c_amount max +3 4 84676 NULL NULL NULL +SELECT t1.usr_id,t1.uniq_id,t1.increment,t2.usr2_id,t2.c_amount,t2.max FROM t1 LEFT JOIN t2 ON t2.id = t1.uniq_id WHERE t1.uniq_id = 4 GROUP BY t2.c_amount; +usr_id uniq_id increment usr2_id c_amount max +3 4 84676 NULL NULL NULL +SELECT t1.usr_id,t1.uniq_id,t1.increment,t2.usr2_id,t2.c_amount,t2.max FROM t1 LEFT JOIN t2 ON t2.id = t1.uniq_id WHERE t1.uniq_id = 4; +usr_id uniq_id increment usr2_id c_amount max +3 4 84676 NULL NULL NULL +drop table t1,t2; +CREATE TABLE t1 ( +cod_asig int(11) DEFAULT '0' NOT NULL, +desc_larga_cat varchar(80) DEFAULT '' NOT NULL, +desc_larga_cas varchar(80) DEFAULT '' NOT NULL, +desc_corta_cat varchar(40) DEFAULT '' NOT NULL, +desc_corta_cas varchar(40) DEFAULT '' NOT NULL, +cred_total double(3,1) DEFAULT '0.0' NOT NULL, +pre_requisit int(11), +co_requisit int(11), +preco_requisit int(11), +PRIMARY KEY (cod_asig) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (10360,'asdfggfg','Introduccion a los Ordenadores I','asdfggfg','Introduccio Ordinadors I',6.0,NULL,NULL,NULL); +INSERT INTO t1 VALUES (10361,'Components i Circuits Electronics I','Componentes y Circuitos Electronicos I','Components i Circuits Electronics I','Comp. i Circ. Electr. I',6.0,NULL,NULL,NULL); +INSERT INTO t1 VALUES (10362,'Laboratori d`Ordinadors','Laboratorio de Ordenadores','Laboratori d`Ordinadors','Laboratori Ordinadors',4.5,NULL,NULL,NULL); +INSERT INTO t1 VALUES (10363,'Tecniques de Comunicacio Oral i Escrita','Tecnicas de Comunicacion Oral y Escrita','Tecniques de Comunicacio Oral i Escrita','Tec. Com. Oral i Escrita',4.5,NULL,NULL,NULL); +INSERT INTO t1 VALUES (11403,'Projecte Fi de Carrera','Proyecto Fin de Carrera','Projecte Fi de Carrera','PFC',9.0,NULL,NULL,NULL); +INSERT INTO t1 VALUES (11404,'+lgebra lineal','Algebra lineal','+lgebra lineal','+lgebra lineal',15.0,NULL,NULL,NULL); +INSERT INTO t1 VALUES (11405,'+lgebra lineal','Algebra lineal','+lgebra lineal','+lgebra lineal',18.0,NULL,NULL,NULL); +INSERT INTO t1 VALUES (11406,'Calcul Infinitesimal','Cßlculo Infinitesimal','Calcul Infinitesimal','Calcul Infinitesimal',15.0,NULL,NULL,NULL); +CREATE TABLE t2 ( +idAssignatura int(11) DEFAULT '0' NOT NULL, +Grup int(11) DEFAULT '0' NOT NULL, +Places smallint(6) DEFAULT '0' NOT NULL, +PlacesOcupades int(11) DEFAULT '0', +PRIMARY KEY (idAssignatura,Grup) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (10360,12,333,0); +INSERT INTO t2 VALUES (10361,30,2,0); +INSERT INTO t2 VALUES (10361,40,3,0); +INSERT INTO t2 VALUES (10360,45,10,0); +INSERT INTO t2 VALUES (10362,10,12,0); +INSERT INTO t2 VALUES (10360,55,2,0); +INSERT INTO t2 VALUES (10360,70,0,0); +INSERT INTO t2 VALUES (10360,565656,0,0); +INSERT INTO t2 VALUES (10360,32767,7,0); +INSERT INTO t2 VALUES (10360,33,8,0); +INSERT INTO t2 VALUES (10360,7887,85,0); +INSERT INTO t2 VALUES (11405,88,8,0); +INSERT INTO t2 VALUES (10360,0,55,0); +INSERT INTO t2 VALUES (10360,99,0,0); +INSERT INTO t2 VALUES (11411,30,10,0); +INSERT INTO t2 VALUES (11404,0,0,0); +INSERT INTO t2 VALUES (10362,11,111,0); +INSERT INTO t2 VALUES (10363,33,333,0); +INSERT INTO t2 VALUES (11412,55,0,0); +INSERT INTO t2 VALUES (50003,66,6,0); +INSERT INTO t2 VALUES (11403,5,0,0); +INSERT INTO t2 VALUES (11406,11,11,0); +INSERT INTO t2 VALUES (11410,11410,131,0); +INSERT INTO t2 VALUES (11416,11416,32767,0); +INSERT INTO t2 VALUES (11409,0,0,0); +CREATE TABLE t3 ( +id int(11) NOT NULL auto_increment, +dni_pasaporte char(16) DEFAULT '' NOT NULL, +idPla int(11) DEFAULT '0' NOT NULL, +cod_asig int(11) DEFAULT '0' NOT NULL, +any smallint(6) DEFAULT '0' NOT NULL, +quatrimestre smallint(6) DEFAULT '0' NOT NULL, +estat char(1) DEFAULT 'M' NOT NULL, +PRIMARY KEY (id), +UNIQUE dni_pasaporte (dni_pasaporte,idPla), +UNIQUE dni_pasaporte_2 (dni_pasaporte,idPla,cod_asig,any,quatrimestre) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t3 VALUES (1,'11111111',1,10362,98,1,'M'); +CREATE TABLE t4 ( +id int(11) NOT NULL auto_increment, +papa int(11) DEFAULT '0' NOT NULL, +fill int(11) DEFAULT '0' NOT NULL, +idPla int(11) DEFAULT '0' NOT NULL, +PRIMARY KEY (id), +KEY papa (idPla,papa), +UNIQUE papa_2 (idPla,papa,fill) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t4 VALUES (1,-1,10360,1); +INSERT INTO t4 VALUES (2,-1,10361,1); +INSERT INTO t4 VALUES (3,-1,10362,1); +SELECT DISTINCT fill,desc_larga_cat,cred_total,Grup,Places,PlacesOcupades FROM t4 LEFT JOIN t3 ON t3.cod_asig=fill AND estat='S' AND dni_pasaporte='11111111' AND t3.idPla=1 , t2,t1 WHERE fill=t1.cod_asig AND Places>PlacesOcupades AND fill=idAssignatura AND t4.idPla=1 AND papa=-1; +fill desc_larga_cat cred_total Grup Places PlacesOcupades +10360 asdfggfg 6.0 0 55 0 +10360 asdfggfg 6.0 12 333 0 +10360 asdfggfg 6.0 33 8 0 +10360 asdfggfg 6.0 45 10 0 +10360 asdfggfg 6.0 55 2 0 +10360 asdfggfg 6.0 7887 85 0 +10360 asdfggfg 6.0 32767 7 0 +10361 Components i Circuits Electronics I 6.0 30 2 0 +10361 Components i Circuits Electronics I 6.0 40 3 0 +10362 Laboratori d`Ordinadors 4.5 10 12 0 +10362 Laboratori d`Ordinadors 4.5 11 111 0 +SELECT DISTINCT fill,t3.idPla FROM t4 LEFT JOIN t3 ON t3.cod_asig=t4.fill AND t3.estat='S' AND t3.dni_pasaporte='1234' AND t3.idPla=1 ; +fill idPla +10360 NULL +10361 NULL +10362 NULL +INSERT INTO t3 VALUES (3,'1234',1,10360,98,1,'S'); +SELECT DISTINCT fill,t3.idPla FROM t4 LEFT JOIN t3 ON t3.cod_asig=t4.fill AND t3.estat='S' AND t3.dni_pasaporte='1234' AND t3.idPla=1 ; +fill idPla +10360 1 +10361 NULL +10362 NULL +drop table t1,t2,t3,test.t4; +CREATE TABLE t1 ( +id smallint(5) unsigned NOT NULL auto_increment, +name char(60) DEFAULT '' NOT NULL, +PRIMARY KEY (id) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (1,'Antonio Paz'); +INSERT INTO t1 VALUES (2,'Lilliana Angelovska'); +INSERT INTO t1 VALUES (3,'Thimble Smith'); +CREATE TABLE t2 ( +id smallint(5) unsigned NOT NULL auto_increment, +owner smallint(5) unsigned DEFAULT '0' NOT NULL, +name char(60), +PRIMARY KEY (id) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (1,1,'El Gato'); +INSERT INTO t2 VALUES (2,1,'Perrito'); +INSERT INTO t2 VALUES (3,3,'Happy'); +select t1.name, t2.name, t2.id from t1 left join t2 on (t1.id = t2.owner); +name name id +Antonio Paz El Gato 1 +Antonio Paz Perrito 2 +Lilliana Angelovska NULL NULL +Thimble Smith Happy 3 +select t1.name, t2.name, t2.id from t1 left join t2 on (t1.id = t2.owner) where t2.id is null; +name name id +Lilliana Angelovska NULL NULL +explain select t1.name, t2.name, t2.id from t1 left join t2 on (t1.id = t2.owner) where t2.id is null; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Not exists +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`name` AS `name`,`test`.`t2`.`name` AS `name`,`test`.`t2`.`id` AS `id` from `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`owner` = `test`.`t1`.`id`)) where (`test`.`t2`.`id` is null) +explain select t1.name, t2.name, t2.id from t1 left join t2 on (t1.id = t2.owner) where t2.name is null; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`name` AS `name`,`test`.`t2`.`name` AS `name`,`test`.`t2`.`id` AS `id` from `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`owner` = `test`.`t1`.`id`)) where (`test`.`t2`.`name` is null) +select count(*) from t1 left join t2 on (t1.id = t2.owner); +count(*) +4 +select t1.name, t2.name, t2.id from t2 right join t1 on (t1.id = t2.owner); +name name id +Antonio Paz El Gato 1 +Antonio Paz Perrito 2 +Lilliana Angelovska NULL NULL +Thimble Smith Happy 3 +select t1.name, t2.name, t2.id from t2 right join t1 on (t1.id = t2.owner) where t2.id is null; +name name id +Lilliana Angelovska NULL NULL +explain select t1.name, t2.name, t2.id from t2 right join t1 on (t1.id = t2.owner) where t2.id is null; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Not exists +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`name` AS `name`,`test`.`t2`.`name` AS `name`,`test`.`t2`.`id` AS `id` from `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`owner` = `test`.`t1`.`id`)) where (`test`.`t2`.`id` is null) +explain select t1.name, t2.name, t2.id from t2 right join t1 on (t1.id = t2.owner) where t2.name is null; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`name` AS `name`,`test`.`t2`.`name` AS `name`,`test`.`t2`.`id` AS `id` from `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`owner` = `test`.`t1`.`id`)) where (`test`.`t2`.`name` is null) +select count(*) from t2 right join t1 on (t1.id = t2.owner); +count(*) +4 +select t1.name, t2.name, t2.id,t3.id from t2 right join t1 on (t1.id = t2.owner) left join t1 as t3 on t3.id=t2.owner; +name name id id +Antonio Paz El Gato 1 1 +Antonio Paz Perrito 2 1 +Lilliana Angelovska NULL NULL NULL +Thimble Smith Happy 3 3 +select t1.name, t2.name, t2.id,t3.id from t1 right join t2 on (t1.id = t2.owner) right join t1 as t3 on t3.id=t2.owner; +name name id id +Antonio Paz El Gato 1 1 +Antonio Paz Perrito 2 1 +NULL NULL NULL 2 +Thimble Smith Happy 3 3 +explain format=tree select t1.name, t2.name, t2.id, t2.owner, t3.id from t1 left join t2 on (t1.id = t2.owner) right join t1 as t3 on t3.id=t2.owner; +EXPLAIN +-> Parallel scan on + -> Nested loop left join (cost=2.20 rows=9) + -> PQblock scan on t3 using PRIMARY (cost=0.55 rows=3) + -> Nested loop inner join (cost=1.33 rows=3) + -> Single-row index lookup on t1 using PRIMARY (id=t3.id) (cost=0.28 rows=1) + -> Filter: (t2.`owner` = t3.id) (cost=0.35 rows=3) + -> Table scan on t2 (cost=0.35 rows=3) + +select t1.name, t2.name, t2.id, t2.owner, t3.id from t1 left join t2 on (t1.id = t2.owner) right join t1 as t3 on t3.id=t2.owner; +name name id owner id +Antonio Paz El Gato 1 1 1 +Antonio Paz Perrito 2 1 1 +NULL NULL NULL NULL 2 +Thimble Smith Happy 3 3 3 +drop table t1,t2; +create table t1 (id int not null, str char(10), index(str)); +insert into t1 values (1, null), (2, null), (3, "foo"), (4, "bar"); +select * from t1 where str is not null order by id; +id str +3 foo +4 bar +select * from t1 where str is null; +id str +1 NULL +2 NULL +explain select * from t1 where str is null; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref str str 41 const 2 100.00 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,`test`.`t1`.`str` AS `str` from `test`.`t1` where (`test`.`t1`.`str` is null) +explain format=tree select * from t1 where str is null; +EXPLAIN +-> Parallel scan on + -> PQblock lookup on t1 using str (str=NULL), with index condition: (t1.str is null) (cost=0.70 rows=2) + +drop table t1; +CREATE TABLE t1 ( +t1_id bigint(21) NOT NULL auto_increment, +PRIMARY KEY (t1_id) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t2 ( +t2_id bigint(21) NOT NULL auto_increment, +PRIMARY KEY (t2_id) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t3 ( +t3_id bigint(21) NOT NULL auto_increment, +PRIMARY KEY (t3_id) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t4 ( +seq_0_id bigint(21) DEFAULT '0' NOT NULL, +seq_1_id bigint(21) DEFAULT '0' NOT NULL, +KEY seq_0_id (seq_0_id), +KEY seq_1_id (seq_1_id) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t5 ( +seq_0_id bigint(21) DEFAULT '0' NOT NULL, +seq_1_id bigint(21) DEFAULT '0' NOT NULL, +KEY seq_1_id (seq_1_id), +KEY seq_0_id (seq_0_id) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t1 values (1); +insert into t2 values (1); +insert into t3 values (1); +insert into t4 values (1,1); +insert into t5 values (1,1); +explain select * from t3 left join t4 on t4.seq_1_id = t2.t2_id left join t1 on t1.t1_id = t4.seq_0_id left join t5 on t5.seq_0_id = t1.t1_id left join t2 on t2.t2_id = t5.seq_1_id where t3.t3_id = 23; +ERROR 42S22: Unknown column 't2.t2_id' in 'on clause' +drop table t1,t2,t3,t4,t5; +create table t1 (n int, m int, o int, key(n)); +create table t2 (n int not null, m int, o int, primary key(n)); +insert into t1 values (1, 2, 11), (1, 2, 7), (2, 2, 8), (1,2,9),(1,3,9); +insert into t2 values (1, 2, 3),(2, 2, 8), (4,3,9),(3,2,10); +select t1.*, t2.* from t1 left join t2 on t1.n = t2.n and +t1.m = t2.m where t1.n = 1; +n m o n m o +1 2 11 1 2 3 +1 2 7 1 2 3 +1 2 9 1 2 3 +1 3 9 NULL NULL NULL +select t1.*, t2.* from t1 left join t2 on t1.n = t2.n and +t1.m = t2.m where t1.n = 1 order by t1.o,t1.m; +n m o n m o +1 2 7 1 2 3 +1 2 9 1 2 3 +1 3 9 NULL NULL NULL +1 2 11 1 2 3 +drop table t1,t2; +CREATE TABLE t1 (id1 INT NOT NULL PRIMARY KEY, dat1 CHAR(1), id2 INT); +INSERT INTO t1 VALUES (1,'a',1); +INSERT INTO t1 VALUES (2,'b',1); +INSERT INTO t1 VALUES (3,'c',2); +CREATE TABLE t2 (id2 INT NOT NULL PRIMARY KEY, dat2 CHAR(1)); +INSERT INTO t2 VALUES (1,'x'); +INSERT INTO t2 VALUES (2,'y'); +INSERT INTO t2 VALUES (3,'z'); +SELECT t2.id2 FROM t2 LEFT OUTER JOIN t1 ON t1.id2 = t2.id2 WHERE id1 IS NULL; +id2 +3 +SELECT t2.id2 FROM t2 NATURAL LEFT OUTER JOIN t1 WHERE id1 IS NULL; +id2 +3 +drop table t1,t2; +create table t1 ( color varchar(20), name varchar(20) ); +insert into t1 values ( 'red', 'apple' ); +insert into t1 values ( 'yellow', 'banana' ); +insert into t1 values ( 'green', 'lime' ); +insert into t1 values ( 'black', 'grape' ); +insert into t1 values ( 'blue', 'blueberry' ); +create table t2 ( count int, color varchar(20) ); +insert into t2 values (10, 'green'); +insert into t2 values (5, 'black'); +insert into t2 values (15, 'white'); +insert into t2 values (7, 'green'); +select * from t1; +color name +red apple +yellow banana +green lime +black grape +blue blueberry +select * from t2; +count color +10 green +5 black +15 white +7 green +select * from t2 natural join t1; +color count name +black 5 grape +green 10 lime +green 7 lime +select t2.count, t1.name from t2 natural join t1; +count name +10 lime +5 grape +7 lime +select t2.count, t1.name from t2 inner join t1 using (color); +count name +10 lime +5 grape +7 lime +drop table t1; +drop table t2; +CREATE TABLE t1 ( +pcode varchar(8) DEFAULT '' NOT NULL +); +INSERT INTO t1 VALUES ('kvw2000'),('kvw2001'),('kvw3000'),('kvw3001'),('kvw3002'),('kvw3500'),('kvw3501'),('kvw3502'),('kvw3800'),('kvw3801'),('kvw3802'),('kvw3900'),('kvw3901'),('kvw3902'),('kvw4000'),('kvw4001'),('kvw4002'),('kvw4200'),('kvw4500'),('kvw5000'),('kvw5001'),('kvw5500'),('kvw5510'),('kvw5600'),('kvw5601'),('kvw6000'),('klw1000'),('klw1020'),('klw1500'),('klw2000'),('klw2001'),('klw2002'),('kld2000'),('klw2500'),('kmw1000'),('kmw1500'),('kmw2000'),('kmw2001'),('kmw2100'),('kmw3000'),('kmw3200'); +CREATE TABLE t2 ( +pcode varchar(8) DEFAULT '' NOT NULL, +KEY pcode (pcode) +); +INSERT INTO t2 VALUES ('kvw2000'),('kvw2000'),('kvw2000'),('kvw2000'),('kvw2000'),('kvw2000'),('kvw2000'),('kvw2000'),('kvw2000'),('kvw2000'),('kvw2000'),('kvw2000'),('kvw2000'),('kvw2000'),('kvw2000'),('kvw2000'),('kvw2000'),('kvw2000'),('kvw2000'),('kvw2000'),('kvw2000'),('kvw2000'),('kvw2000'),('kvw2000'),('kvw2000'),('kvw2000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw6000'),('kvw6000'),('kld2000'); +SELECT t1.pcode, IF(ISNULL(t2.pcode), 0, COUNT(*)) AS count FROM t1 +LEFT JOIN t2 ON t1.pcode = t2.pcode GROUP BY t1.pcode; +pcode count +kld2000 1 +klw1000 0 +klw1020 0 +klw1500 0 +klw2000 0 +klw2001 0 +klw2002 0 +klw2500 0 +kmw1000 0 +kmw1500 0 +kmw2000 0 +kmw2001 0 +kmw2100 0 +kmw3000 0 +kmw3200 0 +kvw2000 26 +kvw2001 0 +kvw3000 36 +kvw3001 0 +kvw3002 0 +kvw3500 26 +kvw3501 0 +kvw3502 0 +kvw3800 0 +kvw3801 0 +kvw3802 0 +kvw3900 0 +kvw3901 0 +kvw3902 0 +kvw4000 0 +kvw4001 0 +kvw4002 0 +kvw4200 0 +kvw4500 0 +kvw5000 0 +kvw5001 0 +kvw5500 0 +kvw5510 0 +kvw5600 0 +kvw5601 0 +kvw6000 2 +SELECT SQL_BIG_RESULT t1.pcode, IF(ISNULL(t2.pcode), 0, COUNT(*)) AS count FROM t1 LEFT JOIN t2 ON t1.pcode = t2.pcode GROUP BY t1.pcode; +pcode count +kld2000 1 +klw1000 0 +klw1020 0 +klw1500 0 +klw2000 0 +klw2001 0 +klw2002 0 +klw2500 0 +kmw1000 0 +kmw1500 0 +kmw2000 0 +kmw2001 0 +kmw2100 0 +kmw3000 0 +kmw3200 0 +kvw2000 26 +kvw2001 0 +kvw3000 36 +kvw3001 0 +kvw3002 0 +kvw3500 26 +kvw3501 0 +kvw3502 0 +kvw3800 0 +kvw3801 0 +kvw3802 0 +kvw3900 0 +kvw3901 0 +kvw3902 0 +kvw4000 0 +kvw4001 0 +kvw4002 0 +kvw4200 0 +kvw4500 0 +kvw5000 0 +kvw5001 0 +kvw5500 0 +kvw5510 0 +kvw5600 0 +kvw5601 0 +kvw6000 2 +drop table t1,t2; +SET sql_mode = 'NO_ENGINE_SUBSTITUTION'; +CREATE TABLE t1 ( +id int(11), +pid int(11), +rep_del tinyint(4), +KEY id (id), +KEY pid (pid) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (1,NULL,NULL); +INSERT INTO t1 VALUES (2,1,NULL); +select * from t1 LEFT JOIN t1 t2 ON (t1.id=t2.pid) AND t2.rep_del IS NULL; +id pid rep_del id pid rep_del +1 NULL NULL 2 1 NULL +2 1 NULL NULL NULL NULL +create index rep_del ON t1(rep_del); +select * from t1 LEFT JOIN t1 t2 ON (t1.id=t2.pid) AND t2.rep_del IS NULL; +id pid rep_del id pid rep_del +1 NULL NULL 2 1 NULL +2 1 NULL NULL NULL NULL +drop table t1; +CREATE TABLE t1 ( +id int(11) DEFAULT '0' NOT NULL, +name tinytext DEFAULT '' NOT NULL, +UNIQUE id (id) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1101 BLOB, TEXT, GEOMETRY or JSON column 'name' can't have a default value +INSERT INTO t1 VALUES (1,'yes'),(2,'no'); +CREATE TABLE t2 ( +id int(11) DEFAULT '0' NOT NULL, +idx int(11) DEFAULT '0' NOT NULL, +UNIQUE id (id,idx) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (1,1); +explain SELECT * from t1 left join t2 on t1.id=t2.id where t2.id IS NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ref id id 4 test.t1.id 1 100.00 Using where; Not exists; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,`test`.`t1`.`name` AS `name`,`test`.`t2`.`id` AS `id`,`test`.`t2`.`idx` AS `idx` from `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`id` = `test`.`t1`.`id`)) where (`test`.`t2`.`id` is null) +SELECT * from t1 left join t2 on t1.id=t2.id where t2.id IS NULL; +id name id idx +2 no NULL NULL +drop table t1,t2; +SET sql_mode = default; +create table t1 (bug_id mediumint, reporter mediumint); +create table t2 (bug_id mediumint, who mediumint, index(who)); +insert into t2 values (1,1),(1,2); +insert into t1 values (1,1),(2,1); +SELECT * FROM t1 LEFT JOIN t2 ON (t1.bug_id = t2.bug_id AND t2.who = 2) WHERE (t1.reporter = 2 OR t2.who = 2); +bug_id reporter bug_id who +1 1 1 2 +drop table t1,t2; +create table t1 (fooID smallint unsigned auto_increment, primary key (fooID)); +create table t2 (fooID smallint unsigned not null, barID smallint unsigned not null, primary key (fooID,barID)); +insert into t1 (fooID) values (10),(20),(30); +insert into t2 values (10,1),(20,2),(30,3); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +explain select * from t2 left join t1 on t1.fooID = t2.fooID and t1.fooID = 30; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL index NULL PRIMARY 4 NULL 3 100.00 Using index +2 SIMPLE t1 NULL const PRIMARY PRIMARY 2 const 1 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`fooID` AS `fooID`,`test`.`t2`.`barID` AS `barID`,`test`.`t1`.`fooID` AS `fooID` from `test`.`t2` left join `test`.`t1` on(((`test`.`t2`.`fooID` = 30) and (`test`.`t1`.`fooID` = 30))) where true +select * from t2 left join t1 on t1.fooID = t2.fooID and t1.fooID = 30; +fooID barID fooID +10 1 NULL +20 2 NULL +30 3 30 +select * from t2 left join t1 ignore index(primary) on t1.fooID = t2.fooID and t1.fooID = 30; +fooID barID fooID +10 1 NULL +20 2 NULL +30 3 30 +drop table t1,t2; +create table t1 (i int); +create table t2 (i int); +create table t3 (i int); +insert into t1 values(1),(2); +insert into t2 values(2),(3); +insert into t3 values(2),(4); +select * from t1 natural left join t2 natural left join t3; +i +1 +2 +select * from t1 natural left join t2 where (t2.i is not null)=0; +i +1 +select * from t1 natural left join t2 where (t2.i is not null) is not null; +i +1 +2 +select * from t1 natural left join t2 where (i is not null)=0; +i +select * from t1 natural left join t2 where (i is not null) is not null; +i +1 +2 +drop table t1,t2,t3; +create table t1 (f1 integer,f2 integer,f3 integer); +create table t2 (f2 integer,f4 integer); +create table t3 (f3 integer,f5 integer); +select * from t1 +left outer join t2 using (f2) +left outer join t3 using (f3); +f3 f2 f1 f4 f5 +drop table t1,t2,t3; +create table t1 (a1 int, a2 int); +create table t2 (b1 int not null, b2 int); +create table t3 (c1 int, c2 int); +insert into t1 values (1,2), (2,2), (3,2); +insert into t2 values (1,3), (2,3); +insert into t3 values (2,4), (3,4); +ANALYZE TABLE t1, t2, t3; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +select * from t1 left join t2 on b1 = a1 left join t3 on c1 = a1 and b1 is null; +a1 a2 b1 b2 c1 c2 +1 2 1 3 NULL NULL +2 2 2 3 NULL NULL +3 2 NULL NULL 3 4 +explain select * from t1 left join t2 on b1 = a1 left join t3 on c1 = a1 and b1 is null; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,`test`.`t2`.`b1` AS `b1`,`test`.`t2`.`b2` AS `b2`,`test`.`t3`.`c1` AS `c1`,`test`.`t3`.`c2` AS `c2` from `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`b1` = `test`.`t1`.`a1`)) left join `test`.`t3` on(((`test`.`t3`.`c1` = `test`.`t1`.`a1`) and (`test`.`t2`.`b1` is null))) where true +drop table t1, t2, t3; +create table t1 ( +a int(11), +b char(10), +key (a) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t1 (a) values (1),(2),(3),(4); +create table t2 (a int); +select * from t1 left join t2 on t1.a=t2.a where not (t2.a <=> t1.a); +a b a +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +select * from t1 left join t2 on t1.a=t2.a having not (t2.a <=> t1.a); +a b a +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +drop table t1,t2; +create table t1 ( +match_id tinyint(3) unsigned not null auto_increment, +home tinyint(3) unsigned default '0', +unique key match_id (match_id), +key match_id_2 (match_id) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t1 values("1", "2"); +create table t2 ( +player_id tinyint(3) unsigned default '0', +match_1_h tinyint(3) unsigned default '0', +key player_id (player_id) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t2 values("1", "5"); +insert into t2 values("2", "9"); +insert into t2 values("3", "3"); +insert into t2 values("4", "7"); +insert into t2 values("5", "6"); +insert into t2 values("6", "8"); +insert into t2 values("7", "4"); +insert into t2 values("8", "12"); +insert into t2 values("9", "11"); +insert into t2 values("10", "10"); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +explain select s.*, '*', m.*, (s.match_1_h - m.home) UUX from +(t2 s left join t1 m on m.match_id = 1) +order by m.match_id desc; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 100.00 Parallel execute (1 workers) +2 SIMPLE s NULL ALL NULL NULL NULL NULL 10 100.00 Using temporary; Using filesort +2 SIMPLE m NULL const match_id,match_id_2 match_id 1 const 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`s`.`player_id` AS `player_id`,`test`.`s`.`match_1_h` AS `match_1_h`,'*' AS `*`,`test`.`m`.`match_id` AS `match_id`,`test`.`m`.`home` AS `home`,(`test`.`s`.`match_1_h` - `test`.`m`.`home`) AS `UUX` from `test`.`t2` `s` left join `test`.`t1` `m` on((`test`.`m`.`match_id` = 1)) where true order by `test`.`m`.`match_id` desc +explain select s.*, '*', m.*, (s.match_1_h - m.home) UUX from +(t2 s left join t1 m on m.match_id = 1) +order by UUX desc; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 100.00 Parallel execute (1 workers) +2 SIMPLE s NULL ALL NULL NULL NULL NULL 10 100.00 Using temporary; Using filesort +2 SIMPLE m NULL const match_id,match_id_2 match_id 1 const 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`s`.`player_id` AS `player_id`,`test`.`s`.`match_1_h` AS `match_1_h`,'*' AS `*`,`test`.`m`.`match_id` AS `match_id`,`test`.`m`.`home` AS `home`,(`test`.`s`.`match_1_h` - `test`.`m`.`home`) AS `UUX` from `test`.`t2` `s` left join `test`.`t1` `m` on((`test`.`m`.`match_id` = 1)) where true order by `UUX` desc +select s.*, '*', m.*, (s.match_1_h - m.home) UUX from +(t2 s left join t1 m on m.match_id = 1) +order by UUX desc; +player_id match_1_h * match_id home UUX +8 12 * 1 2 10 +9 11 * 1 2 9 +10 10 * 1 2 8 +2 9 * 1 2 7 +6 8 * 1 2 6 +4 7 * 1 2 5 +5 6 * 1 2 4 +1 5 * 1 2 3 +7 4 * 1 2 2 +3 3 * 1 2 1 +explain select s.*, '*', m.*, (s.match_1_h - m.home) UUX from +t2 s straight_join t1 m where m.match_id = 1 +order by UUX desc; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 100.00 Parallel execute (1 workers) +2 SIMPLE s NULL ALL NULL NULL NULL NULL 10 100.00 Using temporary; Using filesort +2 SIMPLE m NULL const match_id,match_id_2 match_id 1 const 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`s`.`player_id` AS `player_id`,`test`.`s`.`match_1_h` AS `match_1_h`,'*' AS `*`,`test`.`m`.`match_id` AS `match_id`,`test`.`m`.`home` AS `home`,(`test`.`s`.`match_1_h` - `test`.`m`.`home`) AS `UUX` from `test`.`t2` `s` straight_join `test`.`t1` `m` where (`test`.`m`.`match_id` = 1) order by `UUX` desc +select s.*, '*', m.*, (s.match_1_h - m.home) UUX from +t2 s straight_join t1 m where m.match_id = 1 +order by UUX desc; +player_id match_1_h * match_id home UUX +8 12 * 1 2 10 +9 11 * 1 2 9 +10 10 * 1 2 8 +2 9 * 1 2 7 +6 8 * 1 2 6 +4 7 * 1 2 5 +5 6 * 1 2 4 +1 5 * 1 2 3 +7 4 * 1 2 2 +3 3 * 1 2 1 +drop table t1, t2; +create table t1 (a int, b int, unique index idx (a, b)); +create table t2 (a int, b int, c int, unique index idx (a, b)); +insert into t1 values (1, 10), (1,11), (2,10), (2,11); +insert into t2 values (1,10,3); +select t1.a, t1.b, t2.c from t1 left join t2 +on t1.a=t2.a and t1.b=t2.b and t2.c=3 +where t1.a=1 and t2.c is null; +a b c +1 11 NULL +drop table t1, t2; +CREATE TABLE t1 ( +ts_id bigint(20) default NULL, +inst_id tinyint(4) default NULL, +flag_name varchar(64) default NULL, +flag_value text, +UNIQUE KEY ts_id (ts_id,inst_id,flag_name) +) ENGINE=MyISAM DEFAULT CHARSET=utf8; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +CREATE TABLE t2 ( +ts_id bigint(20) default NULL, +inst_id tinyint(4) default NULL, +flag_name varchar(64) default NULL, +flag_value text, +UNIQUE KEY ts_id (ts_id,inst_id,flag_name) +) ENGINE=MyISAM DEFAULT CHARSET=utf8; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES +(111056548820001, 0, 'flag1', NULL), +(111056548820001, 0, 'flag2', NULL), +(2, 0, 'other_flag', NULL); +INSERT INTO t2 VALUES +(111056548820001, 3, 'flag1', 'sss'); +SELECT t1.flag_name,t2.flag_value +FROM t1 LEFT JOIN t2 +ON (t1.ts_id = t2.ts_id AND t1.flag_name = t2.flag_name AND +t2.inst_id = 3) +WHERE t1.inst_id = 0 AND t1.ts_id=111056548820001 AND +t2.flag_value IS NULL; +flag_name flag_value +flag2 NULL +DROP TABLE t1,t2; +CREATE TABLE t1 ( +id int(11) unsigned NOT NULL auto_increment, +text_id int(10) unsigned default NULL, +PRIMARY KEY (id) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES("1", "0"); +INSERT INTO t1 VALUES("2", "10"); +CREATE TABLE t2 ( +text_id char(3) NOT NULL default '', +language_id char(3) NOT NULL default '', +text_data text, +PRIMARY KEY (text_id,language_id) +); +INSERT INTO t2 VALUES("0", "EN", "0-EN"); +INSERT INTO t2 VALUES("0", "SV", "0-SV"); +INSERT INTO t2 VALUES("10", "EN", "10-EN"); +INSERT INTO t2 VALUES("10", "SV", "10-SV"); +SELECT t1.id, t1.text_id, t2.text_data +FROM t1 LEFT JOIN t2 +ON t1.text_id = t2.text_id +AND t2.language_id = 'SV' + WHERE (t1.id LIKE '%' OR t2.text_data LIKE '%'); +id text_id text_data +1 0 0-SV +2 10 10-SV +DROP TABLE t1, t2; +CREATE TABLE t0 (a0 int PRIMARY KEY); +CREATE TABLE t1 (a1 int PRIMARY KEY); +CREATE TABLE t2 (a2 int); +CREATE TABLE t3 (a3 int); +INSERT INTO t0 VALUES (1); +INSERT INTO t1 VALUES (1); +INSERT INTO t2 VALUES (1), (2); +INSERT INTO t3 VALUES (1), (2); +SELECT * FROM t1 LEFT JOIN t2 ON a1=0; +a1 a2 +1 NULL +EXPLAIN SELECT * FROM t1 LEFT JOIN t2 ON a1=0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL PRIMARY 4 NULL 1 100.00 Using index +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t2`.`a2` AS `a2` from `test`.`t1` left join `test`.`t2` on((`test`.`t1`.`a1` = 0)) where true +SELECT * FROM t1 LEFT JOIN (t2,t3) ON a1=0; +a1 a2 a3 +1 NULL NULL +EXPLAIN SELECT * FROM t1 LEFT JOIN (t2,t3) ON a1=0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL PRIMARY 4 NULL 1 100.00 Using index +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t2`.`a2` AS `a2`,`test`.`t3`.`a3` AS `a3` from `test`.`t1` left join (`test`.`t2` join `test`.`t3`) on((`test`.`t1`.`a1` = 0)) where true +SELECT * FROM t0, t1 LEFT JOIN (t2,t3) ON a1=0 WHERE a0=a1; +a0 a1 a2 a3 +1 1 NULL NULL +EXPLAIN SELECT * FROM t0, t1 LEFT JOIN (t2,t3) ON a1=0 WHERE a0=a1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t0 NULL index PRIMARY PRIMARY 4 NULL 1 100.00 Using index +2 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t0.a0 1 100.00 Using index +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`a0` AS `a0`,`test`.`t1`.`a1` AS `a1`,`test`.`t2`.`a2` AS `a2`,`test`.`t3`.`a3` AS `a3` from `test`.`t0` join `test`.`t1` left join (`test`.`t2` join `test`.`t3`) on(((`test`.`t0`.`a0` = 0) and (`test`.`t1`.`a1` = 0))) where (`test`.`t1`.`a1` = `test`.`t0`.`a0`) +INSERT INTO t0 VALUES (0); +INSERT INTO t1 VALUES (0); +SELECT * FROM t0, t1 LEFT JOIN (t2,t3) ON a1=5 WHERE a0=a1 AND a0=1; +a0 a1 a2 a3 +1 1 NULL NULL +EXPLAIN SELECT * FROM t0, t1 LEFT JOIN (t2,t3) ON a1=5 WHERE a0=a1 AND a0=1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL const PRIMARY PRIMARY 4 const 1 100.00 Using index +1 SIMPLE t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 Using index +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select '1' AS `a0`,'1' AS `a1`,`test`.`t2`.`a2` AS `a2`,`test`.`t3`.`a3` AS `a3` from `test`.`t0` join `test`.`t1` left join (`test`.`t2` join `test`.`t3`) on(false) where true +drop table t1,t2; +create table t1 (a int, b int); +insert into t1 values (1,1),(2,2),(3,3); +create table t2 (a int, b int); +insert into t2 values (1,1), (2,2); +select * from t2 right join t1 on t2.a=t1.a; +a b a b +1 1 1 1 +2 2 2 2 +NULL NULL 3 3 +select straight_join * from t2 right join t1 on t2.a=t1.a; +a b a b +1 1 1 1 +2 2 2 2 +NULL NULL 3 3 +DROP TABLE t0,t1,t2,t3; +CREATE TABLE t1 (a int PRIMARY KEY, b int); +CREATE TABLE t2 (a int PRIMARY KEY, b int); +INSERT INTO t1 VALUES (1,1), (2,1), (3,1), (4,2); +INSERT INTO t2 VALUES (1,2), (2,2); +SELECT * FROM t1 LEFT JOIN t2 ON t1.a=t2.a; +a b a b +1 1 1 2 +2 1 2 2 +3 1 NULL NULL +4 2 NULL NULL +SELECT * FROM t1 LEFT JOIN t2 ON t1.a=t2.a WHERE t1.b=1; +a b a b +1 1 1 2 +2 1 2 2 +3 1 NULL NULL +SELECT * FROM t1 LEFT JOIN t2 ON t1.a=t2.a +WHERE t1.b=1 XOR (NOT ISNULL(t2.a) AND t2.b=1); +a b a b +1 1 1 2 +2 1 2 2 +3 1 NULL NULL +SELECT * FROM t1 LEFT JOIN t2 ON t1.a=t2.a WHERE not(0+(t1.a=30 and t2.b=1)); +a b a b +1 1 1 2 +2 1 2 2 +3 1 NULL NULL +4 2 NULL NULL +DROP TABLE t1,t2; +set group_concat_max_len=5; +create table t1 (a int, b varchar(20)); +create table t2 (a int, c varchar(20)); +insert into t1 values (1,"aaaaaaaaaa"),(2,"bbbbbbbbbb"); +insert into t2 values (1,"cccccccccc"),(2,"dddddddddd"); +select group_concat(t1.b,t2.c) from t1 left join t2 using(a) group by t1.a; +group_concat(t1.b,t2.c) +aaaaa +bbbbb +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +select group_concat(t1.b,t2.c) from t1 inner join t2 using(a) group by t1.a; +group_concat(t1.b,t2.c) +aaaaa +bbbbb +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +select group_concat(t1.b,t2.c) from t1 left join t2 using(a) group by a; +group_concat(t1.b,t2.c) +aaaaa +bbbbb +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +select group_concat(t1.b,t2.c) from t1 inner join t2 using(a) group by a; +group_concat(t1.b,t2.c) +aaaaa +bbbbb +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +drop table t1, t2; +set group_concat_max_len=default; +create table t1 (gid smallint(5) unsigned not null, x int(11) not null, y int(11) not null, art int(11) not null, primary key (gid,x,y)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert t1 values (1, -5, -8, 2), (1, 2, 2, 1), (1, 1, 1, 1); +create table t2 (gid smallint(5) unsigned not null, x int(11) not null, y int(11) not null, id int(11) not null, primary key (gid,id,x,y), key id (id)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert t2 values (1, -5, -8, 1), (1, 1, 1, 1), (1, 2, 2, 1); +create table t3 ( set_id smallint(5) unsigned not null, id tinyint(4) unsigned not null, name char(12) not null, primary key (id,set_id)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert t3 values (0, 1, 'a'), (1, 1, 'b'), (0, 2, 'c'), (1, 2, 'd'), (1, 3, 'e'), (1, 4, 'f'), (1, 5, 'g'), (1, 6, 'h'); +explain select name from t1 left join t2 on t1.x = t2.x and t1.y = t2.y +left join t3 on t1.art = t3.id where t2.id =1 and t2.x = -5 and t2.y =-8 +and t1.gid =1 and t2.gid =1 and t3.set_id =1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL const PRIMARY PRIMARY 10 const,const,const 1 100.00 NULL +1 SIMPLE t2 NULL const PRIMARY,id PRIMARY 14 const,const,const,const 1 100.00 Using index +1 SIMPLE t3 NULL const PRIMARY PRIMARY 3 const,const 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select 'd' AS `name` from `test`.`t1` join `test`.`t2` join `test`.`t3` where true +drop tables t1,t2,t3; +CREATE TABLE t1 (EMPNUM INT, GRP INT); +INSERT INTO t1 VALUES (0, 10); +INSERT INTO t1 VALUES (2, 30); +CREATE TABLE t2 (EMPNUM INT, NAME CHAR(5)); +INSERT INTO t2 VALUES (0, 'KERI'); +INSERT INTO t2 VALUES (9, 'BARRY'); +CREATE VIEW v1 AS +SELECT COALESCE(t2.EMPNUM,t1.EMPNUM) AS EMPNUM, NAME, GRP +FROM t2 LEFT OUTER JOIN t1 ON t2.EMPNUM=t1.EMPNUM; +SELECT * FROM v1; +EMPNUM NAME GRP +0 KERI 10 +9 BARRY NULL +SELECT * FROM v1 WHERE EMPNUM < 10; +EMPNUM NAME GRP +0 KERI 10 +9 BARRY NULL +DROP VIEW v1; +DROP TABLE t1,t2; +CREATE TABLE t1 (c11 int); +CREATE TABLE t2 (c21 int); +INSERT INTO t1 VALUES (30), (40), (50); +INSERT INTO t2 VALUES (300), (400), (500); +SELECT * FROM t1 LEFT JOIN t2 ON (c11=c21 AND c21=30) WHERE c11=40; +c11 c21 +40 NULL +DROP TABLE t1, t2; +CREATE TABLE t1 (a int PRIMARY KEY, b int); +CREATE TABLE t2 (a int PRIMARY KEY, b int); +INSERT INTO t1 VALUES (1,2), (2,1), (3,2), (4,3), (5,6), (6,5), (7,8), (8,7), (9,10); +INSERT INTO t2 VALUES (3,0), (4,1), (6,4), (7,5); +SELECT * FROM t1 LEFT JOIN t2 ON t1.a = t2.a WHERE t2.b <= t1.a AND t1.a <= t1.b; +a b a b +7 8 7 5 +SELECT * FROM t1 LEFT JOIN t2 ON t1.a = t2.a WHERE t1.a BETWEEN t2.b AND t1.b; +a b a b +7 8 7 5 +SELECT * FROM t1 LEFT JOIN t2 ON t1.a = t2.a WHERE NOT(t1.a NOT BETWEEN t2.b AND t1.b); +a b a b +7 8 7 5 +SELECT * FROM t1 LEFT JOIN t2 ON t1.a = t2.a WHERE t2.b > t1.a OR t1.a > t1.b; +a b a b +2 1 NULL NULL +3 2 3 0 +4 3 4 1 +6 5 6 4 +8 7 NULL NULL +SELECT * FROM t1 LEFT JOIN t2 ON t1.a = t2.a WHERE t1.a NOT BETWEEN t2.b AND t1.b; +a b a b +2 1 NULL NULL +3 2 3 0 +4 3 4 1 +6 5 6 4 +8 7 NULL NULL +SELECT * FROM t1 LEFT JOIN t2 ON t1.a = t2.a WHERE NOT(t1.a BETWEEN t2.b AND t1.b); +a b a b +2 1 NULL NULL +3 2 3 0 +4 3 4 1 +6 5 6 4 +8 7 NULL NULL +SELECT * FROM t1 LEFT JOIN t2 ON t1.a = t2.a WHERE t1.a = t2.a OR t2.b > t1.a OR t1.a > t1.b; +a b a b +2 1 NULL NULL +3 2 3 0 +4 3 4 1 +6 5 6 4 +7 8 7 5 +8 7 NULL NULL +SELECT * FROM t1 LEFT JOIN t2 ON t1.a = t2.a WHERE NOT(t1.a != t2.a AND t1.a BETWEEN t2.b AND t1.b); +a b a b +2 1 NULL NULL +3 2 3 0 +4 3 4 1 +6 5 6 4 +7 8 7 5 +8 7 NULL NULL +SELECT * FROM t1 LEFT JOIN t2 ON t1.a = t2.a WHERE t1.a = t2.a AND (t2.b > t1.a OR t1.a > t1.b); +a b a b +3 2 3 0 +4 3 4 1 +6 5 6 4 +SELECT * FROM t1 LEFT JOIN t2 ON t1.a = t2.a WHERE NOT(t1.a != t2.a OR t1.a BETWEEN t2.b AND t1.b); +a b a b +3 2 3 0 +4 3 4 1 +6 5 6 4 +SELECT * FROM t1 LEFT JOIN t2 ON t1.a = t2.a WHERE t1.a = t2.a OR t1.a = t2.b; +a b a b +3 2 3 0 +4 3 4 1 +6 5 6 4 +7 8 7 5 +SELECT * FROM t1 LEFT JOIN t2 ON t1.a = t2.a WHERE t1.a IN(t2.a, t2.b); +a b a b +3 2 3 0 +4 3 4 1 +6 5 6 4 +7 8 7 5 +SELECT * FROM t1 LEFT JOIN t2 ON t1.a = t2.a WHERE NOT(t1.a NOT IN(t2.a, t2.b)); +a b a b +3 2 3 0 +4 3 4 1 +6 5 6 4 +7 8 7 5 +SELECT * FROM t1 LEFT JOIN t2 ON t1.a = t2.a WHERE t1.a != t1.b AND t1.a != t2.b; +a b a b +3 2 3 0 +4 3 4 1 +6 5 6 4 +7 8 7 5 +SELECT * FROM t1 LEFT JOIN t2 ON t1.a = t2.a WHERE t1.a NOT IN(t1.b, t2.b); +a b a b +3 2 3 0 +4 3 4 1 +6 5 6 4 +7 8 7 5 +SELECT * FROM t1 LEFT JOIN t2 ON t1.a = t2.a WHERE NOT(t1.a IN(t1.b, t2.b)); +a b a b +3 2 3 0 +4 3 4 1 +6 5 6 4 +7 8 7 5 +SELECT * FROM t1 LEFT JOIN t2 ON t1.a = t2.a WHERE t2.a != t2.b OR (t1.a != t2.a AND t1.a != t2.b); +a b a b +3 2 3 0 +4 3 4 1 +6 5 6 4 +7 8 7 5 +SELECT * FROM t1 LEFT JOIN t2 ON t1.a = t2.a WHERE NOT(t2.a = t2.b AND t1.a IN(t2.a, t2.b)); +a b a b +3 2 3 0 +4 3 4 1 +6 5 6 4 +7 8 7 5 +SELECT * FROM t1 LEFT JOIN t2 ON t1.a = t2.a WHERE t2.a != t2.b AND t1.a != t1.b AND t1.a != t2.b; +a b a b +3 2 3 0 +4 3 4 1 +6 5 6 4 +7 8 7 5 +SELECT * FROM t1 LEFT JOIN t2 ON t1.a = t2.a WHERE NOT(t2.a = t2.b OR t1.a IN(t1.b, t2.b)); +a b a b +3 2 3 0 +4 3 4 1 +6 5 6 4 +7 8 7 5 +EXPLAIN SELECT * FROM t1 LEFT JOIN t2 ON t1.a = t2.a WHERE t1.a = t2.a OR t1.a = t2.b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ALL PRIMARY NULL NULL NULL 4 100.00 Using where +2 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.a 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` join `test`.`t2` where (`test`.`t1`.`a` = `test`.`t2`.`a`) +EXPLAIN SELECT * FROM t1 LEFT JOIN t2 ON t1.a = t2.a WHERE t1.a IN(t2.a, t2.b); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ALL PRIMARY NULL NULL NULL 4 100.00 Using where +2 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.a 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` join `test`.`t2` where ((`test`.`t1`.`a` = `test`.`t2`.`a`) and (`test`.`t2`.`a` in (`test`.`t2`.`a`,`test`.`t2`.`b`))) +EXPLAIN SELECT * FROM t1 LEFT JOIN t2 ON t1.a = t2.a WHERE t1.a > IF(t1.a = t2.b-2, t2.b, t2.b-1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ALL PRIMARY NULL NULL NULL 4 100.00 Using where +2 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.a 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` join `test`.`t2` where ((`test`.`t1`.`a` = `test`.`t2`.`a`) and (`test`.`t2`.`a` > if((`test`.`t2`.`a` = (`test`.`t2`.`b` - 2)),`test`.`t2`.`b`,(`test`.`t2`.`b` - 1)))) +DROP TABLE t1,t2; +DROP VIEW IF EXISTS v1,v2; +DROP TABLE IF EXISTS t1,t2; +CREATE TABLE t1 (a int); +CREATE table t2 (b int); +INSERT INTO t1 VALUES (1), (2), (3), (4), (1), (1), (3); +INSERT INTO t2 VALUES (2), (3); +CREATE VIEW v1 AS SELECT a FROM t1 JOIN t2 ON t1.a=t2.b; +CREATE VIEW v2 AS SELECT b FROM t2 JOIN t1 ON t2.b=t1.a; +SELECT v1.a, v2. b +FROM v1 LEFT OUTER JOIN v2 ON (v1.a=v2.b) AND (v1.a >= 3) +GROUP BY v1.a; +a b +2 NULL +3 3 +SELECT v1.a, v2. b +FROM { OJ v1 LEFT OUTER JOIN v2 ON (v1.a=v2.b) AND (v1.a >= 3) } +GROUP BY v1.a; +a b +2 NULL +3 3 +DROP VIEW v1,v2; +DROP TABLE t1,t2; +CREATE TABLE t1 (a int); +CREATE TABLE t2 (b int); +INSERT INTO t1 VALUES (1), (2), (3), (4); +INSERT INTO t2 VALUES (2), (3); +SELECT * FROM t1 LEFT JOIN t2 ON t1.a = t2.b WHERE (1=1); +a b +1 NULL +2 2 +3 3 +4 NULL +SELECT * FROM t1 LEFT JOIN t2 ON t1.a = t2.b WHERE (1 OR 1); +a b +1 NULL +2 2 +3 3 +4 NULL +SELECT * FROM t1 LEFT JOIN t2 ON t1.a = t2.b WHERE (0 OR 1); +a b +1 NULL +2 2 +3 3 +4 NULL +SELECT * FROM t1 LEFT JOIN t2 ON t1.a = t2.b WHERE (1=1 OR 2=2); +a b +1 NULL +2 2 +3 3 +4 NULL +SELECT * FROM t1 LEFT JOIN t2 ON t1.a = t2.b WHERE (1=1 OR 1=0); +a b +1 NULL +2 2 +3 3 +4 NULL +DROP TABLE t1,t2; +CREATE TABLE t1 ( +f1 varchar(16) collate latin1_swedish_ci PRIMARY KEY, +f2 varchar(16) collate latin1_swedish_ci +); +CREATE TABLE t2 ( +f1 varchar(16) collate latin1_swedish_ci PRIMARY KEY, +f3 varchar(16) collate latin1_swedish_ci +); +INSERT INTO t1 VALUES ('bla','blah'); +INSERT INTO t2 VALUES ('bla','sheep'); +SELECT * FROM t1 JOIN t2 USING(f1) WHERE f1='Bla'; +f1 f2 f3 +bla blah sheep +SELECT * FROM t1 LEFT JOIN t2 USING(f1) WHERE f1='bla'; +f1 f2 f3 +bla blah sheep +SELECT * FROM t1 LEFT JOIN t2 USING(f1) WHERE f1='Bla'; +f1 f2 f3 +bla blah sheep +DROP TABLE t1,t2; +CREATE TABLE t1 (id int PRIMARY KEY, a varchar(8)); +CREATE TABLE t2 (id int NOT NULL, b int NOT NULL, INDEX idx(id)); +INSERT INTO t1 VALUES +(1,'aaaaaaa'), (5,'eeeeeee'), (4,'ddddddd'), (2,'bbbbbbb'), (3,'ccccccc'); +INSERT INTO t2 VALUES +(3,10), (2,20), (5,30), (3,20), (5,10), (3,40), (3,30), (2,10), (2,40); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN +SELECT t1.id, a FROM t1 LEFT JOIN t2 ON t1.id=t2.id WHERE t2.b IS NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +2 SIMPLE t2 NULL ref idx idx 4 test.t1.id 3 11.11 Using where; Not exists; Using join buffer (Batched Key Access) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,`test`.`t1`.`a` AS `a` from `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`id` = `test`.`t1`.`id`)) where (`test`.`t2`.`b` is null) +flush status; +SELECT t1.id, a FROM t1 LEFT JOIN t2 ON t1.id=t2.id WHERE t2.b IS NULL; +id a +1 aaaaaaa +4 ddddddd +show status like 'Handler_read%'; +Variable_name Value +Handler_read_first 1 +Handler_read_key 9 +Handler_read_last 0 +Handler_read_next 9 +Handler_read_prev 0 +Handler_read_rnd 3 +Handler_read_rnd_next 6 +DROP TABLE t1,t2; +CREATE TABLE t1 (c int PRIMARY KEY, e int NOT NULL); +INSERT INTO t1 VALUES (1,0), (2,1); +CREATE TABLE t2 (d int PRIMARY KEY); +INSERT INTO t2 VALUES (1), (2), (3); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN SELECT * FROM t1 LEFT JOIN t2 ON e<>0 WHERE c=1 AND d IS NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +1 SIMPLE t2 NULL index NULL PRIMARY 4 NULL 3 33.33 Using where; Not exists; Using index +Warnings: +Note 1003 /* select#1 */ select '1' AS `c`,'0' AS `e`,`test`.`t2`.`d` AS `d` from `test`.`t1` left join `test`.`t2` on(('0' <> 0)) where ((`test`.`t2`.`d` is null)) +SELECT * FROM t1 LEFT JOIN t2 ON e<>0 WHERE c=1 AND d IS NULL; +c e d +1 0 NULL +SELECT * FROM t1 LEFT JOIN t2 ON e<>0 WHERE c=1 AND d<=>NULL; +c e d +1 0 NULL +DROP TABLE t1,t2; +# +# Bug#47650: using group by with rollup without indexes returns incorrect +# results with where +# +CREATE TABLE t1 ( a INT ); +INSERT INTO t1 VALUES (1); +CREATE TABLE t2 ( a INT, b INT ); +INSERT INTO t2 VALUES (1, 1),(1, 2),(1, 3),(2, 4),(2, 5); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN +SELECT t1.a, COUNT( t2.b ), SUM( t2.b ), MAX( t2.b ) +FROM t1 LEFT JOIN t2 USING( a ) +GROUP BY t1.a WITH ROLLUP; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using temporary; Using filesort +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 5 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,rollup_sum_switcher(count(`test`.`t2`.`b`)) AS `COUNT( t2.b )`,rollup_sum_switcher(sum(`test`.`t2`.`b`)) AS `SUM( t2.b )`,rollup_sum_switcher(max(`test`.`t2`.`b`)) AS `MAX( t2.b )` from `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`a` = `test`.`t1`.`a`)) where true group by `test`.`t1`.`a` with rollup +SELECT t1.a, COUNT( t2.b ), SUM( t2.b ), MAX( t2.b ) +FROM t1 LEFT JOIN t2 USING( a ) +GROUP BY t1.a WITH ROLLUP; +a COUNT( t2.b ) SUM( t2.b ) MAX( t2.b ) +1 3 6 3 +NULL 3 6 3 +EXPLAIN +SELECT t1.a, COUNT( t2.b ), SUM( t2.b ), MAX( t2.b ) +FROM t1 JOIN t2 USING( a ) +GROUP BY t1.a WITH ROLLUP; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using filesort +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 5 20.00 Using where +Warnings: +Note 1003 /* select#1 */ select rollup_group_item(`test`.`t1`.`a`,0) AS `a`,rollup_sum_switcher(count(`test`.`t2`.`b`)) AS `COUNT( t2.b )`,rollup_sum_switcher(sum(`test`.`t2`.`b`)) AS `SUM( t2.b )`,rollup_sum_switcher(max(`test`.`t2`.`b`)) AS `MAX( t2.b )` from `test`.`t1` join `test`.`t2` where (`test`.`t2`.`a` = `test`.`t1`.`a`) group by `test`.`t1`.`a` with rollup +SELECT t1.a, COUNT( t2.b ), SUM( t2.b ), MAX( t2.b ) +FROM t1 JOIN t2 USING( a ) +GROUP BY t1.a WITH ROLLUP; +a COUNT( t2.b ) SUM( t2.b ) MAX( t2.b ) +1 3 6 3 +NULL 3 6 3 +DROP TABLE t1, t2; +# +# Bug#51598 Inconsistent behaviour with a COALESCE statement inside an IN comparison +# +CREATE TABLE t1(f1 INT, f2 INT, f3 INT); +INSERT INTO t1 VALUES (1, NULL, 3); +CREATE TABLE t2(f1 INT, f2 INT); +INSERT INTO t2 VALUES (2, 1); +EXPLAIN SELECT * FROM t1 LEFT JOIN t2 ON t1.f2 = t2.f2 +WHERE (COALESCE(t1.f1, t2.f1), f3) IN ((1, 3), (2, 2)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`f1` AS `f1`,`test`.`t1`.`f2` AS `f2`,`test`.`t1`.`f3` AS `f3`,`test`.`t2`.`f1` AS `f1`,`test`.`t2`.`f2` AS `f2` from `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`f2` = `test`.`t1`.`f2`)) where ((coalesce(`test`.`t1`.`f1`,`test`.`t2`.`f1`),`test`.`t1`.`f3`) in ((1,3),(2,2))) +SELECT * FROM t1 LEFT JOIN t2 ON t1.f2 = t2.f2 +WHERE (COALESCE(t1.f1, t2.f1), f3) IN ((1, 3), (2, 2)); +f1 f2 f3 f1 f2 +1 NULL 3 NULL NULL +DROP TABLE t1, t2; +# +# Bug#52357: Assertion failed: join->best_read in greedy_search +# optimizer_search_depth=0 +# +CREATE TABLE t1( a INT ); +INSERT INTO t1 VALUES (1),(2); +SET optimizer_search_depth = 0; +# Should not core dump on query preparation +EXPLAIN +SELECT 1 +FROM t1 tt3 LEFT OUTER JOIN t1 tt4 ON 1 +LEFT OUTER JOIN t1 tt5 ON 1 +LEFT OUTER JOIN t1 tt6 ON 1 +LEFT OUTER JOIN t1 tt7 ON 1 +LEFT OUTER JOIN t1 tt8 ON 1 +RIGHT OUTER JOIN t1 tt2 ON 1 +RIGHT OUTER JOIN t1 tt1 ON 1 +STRAIGHT_JOIN t1 tt9 ON 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE tt1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 SIMPLE tt2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +2 SIMPLE tt3 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +2 SIMPLE tt4 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +2 SIMPLE tt5 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +2 SIMPLE tt6 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +2 SIMPLE tt7 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +2 SIMPLE tt8 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +2 SIMPLE tt9 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` `tt1` left join (`test`.`t1` `tt2` left join (`test`.`t1` `tt3` left join `test`.`t1` `tt4` on(true) left join `test`.`t1` `tt5` on(true) left join `test`.`t1` `tt6` on(true) left join `test`.`t1` `tt7` on(true) left join `test`.`t1` `tt8` on(true)) on(true)) on(true) straight_join `test`.`t1` `tt9` where true +SET optimizer_search_depth = DEFAULT; +DROP TABLE t1; +# +# Bug#46091 STRAIGHT_JOIN + RIGHT JOIN returns different result +# +CREATE TABLE t1 (f1 INT NOT NULL); +INSERT INTO t1 VALUES (9),(0); +CREATE TABLE t2 (f1 INT NOT NULL); +INSERT INTO t2 VALUES +(5),(3),(0),(3),(1),(0),(1),(7),(1),(0),(0),(8),(4),(9),(0),(2),(0),(8),(5),(1); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +SELECT STRAIGHT_JOIN COUNT(*) FROM t1 ta1 +RIGHT JOIN t2 ta2 JOIN t2 ta3 ON ta2.f1 ON ta3.f1; +COUNT(*) +476 +EXPLAIN SELECT STRAIGHT_JOIN COUNT(*) FROM t1 ta1 +RIGHT JOIN t2 ta2 JOIN t2 ta3 ON ta2.f1 ON ta3.f1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 20 90.00 Parallel execute (1 workers) +2 SIMPLE ta2 NULL ALL NULL NULL NULL NULL 20 90.00 Using where +2 SIMPLE ta3 NULL ALL NULL NULL NULL NULL 20 100.00 NULL +2 SIMPLE ta1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select straight_join count(0) AS `COUNT(*)` from `test`.`t2` `ta2` join `test`.`t2` `ta3` left join `test`.`t1` `ta1` on((0 <> `test`.`ta3`.`f1`)) where (0 <> `test`.`ta2`.`f1`) +DROP TABLE t1, t2; +# +# Bug#48971 Segfault in add_found_match_trig_cond () at sql_select.cc:5990 +# +CREATE TABLE t1(f1 INT, PRIMARY KEY (f1)); +INSERT INTO t1 VALUES (1),(2); +EXPLAIN SELECT STRAIGHT_JOIN jt1.f1 FROM t1 AS jt1 +LEFT JOIN t1 AS jt2 +RIGHT JOIN t1 AS jt3 +JOIN t1 AS jt4 ON 1 +LEFT JOIN t1 AS jt5 ON 1 +ON 1 +RIGHT JOIN t1 AS jt6 ON jt6.f1 +ON 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE jt1 NULL index NULL PRIMARY 4 NULL 2 100.00 Using index +2 SIMPLE jt6 NULL index NULL PRIMARY 4 NULL 2 100.00 Using where; Using index +2 SIMPLE jt3 NULL index NULL PRIMARY 4 NULL 2 100.00 Using where; Using index +2 SIMPLE jt4 NULL index NULL PRIMARY 4 NULL 2 100.00 Using index +2 SIMPLE jt5 NULL index NULL PRIMARY 4 NULL 2 100.00 Using where; Using index +2 SIMPLE jt2 NULL index NULL PRIMARY 4 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select straight_join `test`.`jt1`.`f1` AS `f1` from `test`.`t1` `jt1` left join (`test`.`t1` `jt6` left join (`test`.`t1` `jt3` join `test`.`t1` `jt4` left join `test`.`t1` `jt5` on(true) left join `test`.`t1` `jt2` on(true)) on(((0 <> `test`.`jt6`.`f1`)))) on(true) where true +EXPLAIN SELECT STRAIGHT_JOIN jt1.f1 FROM t1 AS jt1 +RIGHT JOIN t1 AS jt2 +RIGHT JOIN t1 AS jt3 +JOIN t1 AS jt4 ON 1 +LEFT JOIN t1 AS jt5 ON 1 +ON 1 +RIGHT JOIN t1 AS jt6 ON jt6.f1 +ON 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE jt6 NULL index NULL PRIMARY 4 NULL 2 100.00 Using index +2 SIMPLE jt3 NULL index NULL PRIMARY 4 NULL 2 100.00 Using where; Using index +2 SIMPLE jt4 NULL index NULL PRIMARY 4 NULL 2 100.00 Using index +2 SIMPLE jt5 NULL index NULL PRIMARY 4 NULL 2 100.00 Using where; Using index +2 SIMPLE jt2 NULL index NULL PRIMARY 4 NULL 2 100.00 Using where; Using index +2 SIMPLE jt1 NULL index NULL PRIMARY 4 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select straight_join `test`.`jt1`.`f1` AS `f1` from `test`.`t1` `jt6` left join (`test`.`t1` `jt3` join `test`.`t1` `jt4` left join `test`.`t1` `jt5` on(true) left join `test`.`t1` `jt2` on(true)) on(((0 <> `test`.`jt6`.`f1`))) left join `test`.`t1` `jt1` on(true) where true +DROP TABLE t1; +# +# Bug#57688 Assertion `!table || (!table->write_set || bitmap_is_set(table->write_set, field +# +CREATE TABLE t1 (f1 INT NOT NULL, PRIMARY KEY (f1)); +CREATE TABLE t2 (f1 INT NOT NULL, f2 INT NOT NULL, PRIMARY KEY (f1, f2)); +INSERT INTO t1 VALUES (4); +INSERT INTO t2 VALUES (3, 3); +INSERT INTO t2 VALUES (7, 7); +EXPLAIN SELECT * FROM t1 LEFT JOIN t2 ON t2.f1 = t1.f1 +WHERE t1.f1 = 4 +GROUP BY t2.f1, t2.f2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 Using index; Using temporary +1 SIMPLE t2 NULL ref PRIMARY PRIMARY 4 const 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select '4' AS `f1`,`test`.`t2`.`f1` AS `f1`,`test`.`t2`.`f2` AS `f2` from `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`f1` = 4)) where true group by `test`.`t2`.`f1`,`test`.`t2`.`f2` +SELECT * FROM t1 LEFT JOIN t2 ON t2.f1 = t1.f1 +WHERE t1.f1 = 4 +GROUP BY t2.f1, t2.f2; +f1 f1 f2 +4 NULL NULL +EXPLAIN SELECT * FROM t1 LEFT JOIN t2 ON t2.f1 = t1.f1 +WHERE t1.f1 = 4 AND t2.f1 IS NOT NULL AND t2.f2 IS NOT NULL +GROUP BY t2.f1, t2.f2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 Using index +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 50.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 Using index +2 SIMPLE t2 NULL ref PRIMARY PRIMARY 4 const 1 50.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select '4' AS `f1`,`test`.`t2`.`f1` AS `f1`,`test`.`t2`.`f2` AS `f2` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`f1` = 4) and (`test`.`t2`.`f2` is not null)) group by `test`.`t2`.`f1`,`test`.`t2`.`f2` +SELECT * FROM t1 LEFT JOIN t2 ON t2.f1 = t1.f1 +WHERE t1.f1 = 4 AND t2.f1 IS NOT NULL AND t2.f2 IS NOT NULL +GROUP BY t2.f1, t2.f2; +f1 f1 f2 +DROP TABLE t1,t2; +# +# Bug#57034 incorrect OUTER JOIN result when joined on unique key +# +CREATE TABLE t1 (pk INT PRIMARY KEY, +col_int INT, +col_int_unique INT UNIQUE KEY); +INSERT INTO t1 VALUES (1,NULL,2), (2,0,0); +CREATE TABLE t2 (pk INT PRIMARY KEY, +col_int INT, +col_int_unique INT UNIQUE KEY); +INSERT INTO t2 VALUES (1,0,1), (2,0,2); +EXPLAIN +SELECT * FROM t1 LEFT JOIN t2 +ON t1.col_int_unique = t2.col_int_unique AND t1.col_int = t2.col_int +WHERE t1.pk=1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +1 SIMPLE t2 NULL const col_int_unique col_int_unique 5 const 1 100.00 Impossible ON condition +Warnings: +Note 1003 /* select#1 */ select '1' AS `pk`,NULL AS `col_int`,'2' AS `col_int_unique`,NULL AS `pk`,NULL AS `col_int`,NULL AS `col_int_unique` from `test`.`t1` left join `test`.`t2` on((multiple equal('2', NULL) and multiple equal(NULL, NULL))) where true +SELECT * FROM t1 LEFT JOIN t2 +ON t1.col_int_unique = t2.col_int_unique AND t1.col_int = t2.col_int +WHERE t1.pk=1; +pk col_int col_int_unique pk col_int col_int_unique +1 NULL 2 NULL NULL NULL +DROP TABLE t1,t2; +# +# Bug#48046 Server incorrectly processing JOINs on NULL values +# +CREATE TABLE `BB` ( +`pk` int(11) NOT NULL AUTO_INCREMENT, +`time_key` time DEFAULT NULL, +`varchar_key` varchar(1) DEFAULT NULL, +`varchar_nokey` varchar(1) DEFAULT NULL, +PRIMARY KEY (`pk`), +KEY `time_key` (`time_key`), +KEY `varchar_key` (`varchar_key`) +) ENGINE=MyISAM AUTO_INCREMENT=11 DEFAULT CHARSET=latin1; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO `BB` VALUES (10,'18:27:58',NULL,NULL); +SELECT table1.time_key AS field1, table2.pk +FROM BB table1 LEFT JOIN BB table2 +ON table2.varchar_nokey = table1.varchar_key +HAVING field1; +field1 pk +18:27:58 NULL +DROP TABLE BB; +# +# Bug#49600 Server incorrectly processing RIGHT JOIN with +# constant WHERE clause and no index +# +CREATE TABLE `BB` ( +`col_datetime_key` datetime DEFAULT NULL, +`col_varchar_key` varchar(1) DEFAULT NULL, +`col_varchar_nokey` varchar(1) DEFAULT NULL, +KEY `col_datetime_key` (`col_datetime_key`), +KEY `col_varchar_key` (`col_varchar_key`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1; +INSERT INTO `BB` VALUES ('1900-01-01 00:00:00',NULL,NULL); +SELECT table1.col_datetime_key +FROM BB table1 RIGHT JOIN BB table2 +ON table2 .col_varchar_nokey = table1.col_varchar_key +WHERE 7; +col_datetime_key +NULL +ALTER TABLE BB DISABLE KEYS; +SELECT table1.col_datetime_key +FROM BB table1 RIGHT JOIN BB table2 +ON table2 .col_varchar_nokey = table1.col_varchar_key +WHERE 7; +col_datetime_key +NULL +DROP TABLE BB; +# +# Bug#58490: Incorrect result in multi level OUTER JOIN +# in combination with IS NULL +# +CREATE TABLE t1 (i INT NOT NULL); +INSERT INTO t1 VALUES (0), (2),(3),(4); +CREATE TABLE t2 (i INT NOT NULL); +INSERT INTO t2 VALUES (0),(1), (3),(4); +CREATE TABLE t3 (i INT NOT NULL); +INSERT INTO t3 VALUES (0),(1),(2), (4); +CREATE TABLE t4 (i INT NOT NULL); +INSERT INTO t4 VALUES (0),(1),(2),(3) ; +SELECT * FROM +t1 LEFT JOIN +( t2 LEFT JOIN +( t3 LEFT JOIN +t4 +ON t4.i = t3.i +) +ON t3.i = t2.i +) +ON t2.i = t1.i +; +i i i i +0 0 0 0 +2 NULL NULL NULL +3 3 NULL NULL +4 4 4 NULL +SELECT * FROM +t1 LEFT JOIN +( t2 LEFT JOIN +( t3 LEFT JOIN +t4 +ON t4.i = t3.i +) +ON t3.i = t2.i +) +ON t2.i = t1.i +WHERE t4.i IS NULL; +i i i i +2 NULL NULL NULL +3 3 NULL NULL +4 4 4 NULL +SELECT * FROM +t1 LEFT JOIN +( ( t2 LEFT JOIN +t3 +ON t3.i = t2.i +) +) +ON t2.i = t1.i +WHERE t3.i IS NULL; +i i i +2 NULL NULL +3 3 NULL +SELECT * FROM +t1 LEFT JOIN +( ( t2 LEFT JOIN +t3 +ON t3.i = t2.i +) +JOIN t4 +ON t4.i=t2.i +) +ON t2.i = t1.i +WHERE t3.i IS NULL; +i i i i +2 NULL NULL NULL +3 3 NULL 3 +4 NULL NULL NULL +SELECT * FROM +t1 LEFT JOIN +( ( t2 LEFT JOIN +t3 +ON t3.i = t2.i +) +JOIN (t4 AS t4a JOIN t4 AS t4b ON t4a.i=t4b.i) +ON t4a.i=t2.i +) +ON t2.i = t1.i +WHERE t3.i IS NULL; +i i i i i +2 NULL NULL NULL NULL +3 3 NULL 3 3 +4 NULL NULL NULL NULL +SELECT * FROM +t1 LEFT JOIN +( ( t2 LEFT JOIN +t3 +ON t3.i = t2.i +) +JOIN (t4 AS t4a, t4 AS t4b) +ON t4a.i=t2.i +) +ON t2.i = t1.i +WHERE t3.i IS NULL; +i i i i i +2 NULL NULL NULL NULL +3 3 NULL 3 0 +3 3 NULL 3 1 +3 3 NULL 3 2 +3 3 NULL 3 3 +4 NULL NULL NULL NULL +DROP TABLE t1,t2,t3,t4; +# +# Bug#49322(Duplicate): Server is adding extra NULL row +# on processing a WHERE clause +# +CREATE TABLE h (pk INT NOT NULL, col_int_key INT); +INSERT INTO h VALUES (1,NULL),(4,2),(5,2),(3,4),(2,8); +CREATE TABLE m (pk INT NOT NULL, col_int_key INT); +INSERT INTO m VALUES (1,2),(2,7),(3,5),(4,7),(5,5),(6,NULL),(7,NULL),(8,9); +CREATE TABLE k (pk INT NOT NULL, col_int_key INT); +INSERT INTO k VALUES (1,9),(2,2),(3,5),(4,2),(5,7),(6,0),(7,5); +SELECT TABLE1.pk FROM k TABLE1 +RIGHT JOIN h TABLE2 ON TABLE1.col_int_key=TABLE2.col_int_key +RIGHT JOIN m TABLE4 ON TABLE2.col_int_key=TABLE4.col_int_key; +pk +2 +2 +4 +4 +NULL +NULL +NULL +NULL +NULL +NULL +NULL +SELECT TABLE1.pk FROM k TABLE1 +RIGHT JOIN h TABLE2 ON TABLE1.col_int_key=TABLE2.col_int_key +RIGHT JOIN m TABLE4 ON TABLE2.col_int_key=TABLE4.col_int_key +WHERE TABLE1.pk IS NULL; +pk +NULL +NULL +NULL +NULL +NULL +NULL +NULL +DROP TABLE h,m,k; +# +# Bug #11765810 58813: SERVER THREAD HANGS WHEN JOIN + WHERE + GROUP BY +# IS EXECUTED TWICE FROM P +# +CREATE TABLE t1 ( a INT ) ENGINE = MYISAM; +INSERT INTO t1 VALUES (1); +PREPARE prep_stmt FROM ' + SELECT 1 AS f FROM t1 + LEFT JOIN t1 t2 + RIGHT JOIN t1 t3 + JOIN t1 t4 + ON 1 + ON 1 + ON 1 + GROUP BY f'; +EXECUTE prep_stmt; +f +1 +EXECUTE prep_stmt; +f +1 +DROP TABLE t1; +End of 5.1 tests +# +# Bug#54235 Extra rows with join_cache_level=4,6,8 and two LEFT JOIN +# +CREATE TABLE t1 (a int); +CREATE TABLE t2 (a int); +CREATE TABLE t3 (a int); +CREATE TABLE t4 (a int); +INSERT INTO t1 VALUES (null),(null); +explain SELECT t1.a FROM t1 LEFT JOIN (t2 LEFT JOIN t3 ON t2.a) +ON 0 WHERE t1.a OR t3.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` left join (`test`.`t2` left join `test`.`t3` on((0 <> `test`.`t2`.`a`))) on(false) where ((0 <> `test`.`t1`.`a`) or (0 <> `test`.`t3`.`a`)) +SELECT t1.a FROM t1 LEFT JOIN (t2 LEFT JOIN t3 ON t2.a) +ON 0 WHERE t1.a OR t3.a; +a +explain SELECT t1.a FROM t1 LEFT JOIN +(t2 LEFT JOIN (t3 LEFT JOIN t4 ON 1) ON t2.a) +ON 0 WHERE t1.a OR t4.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` left join (`test`.`t2` left join (`test`.`t3` left join `test`.`t4` on(true)) on((0 <> `test`.`t2`.`a`))) on(false) where ((0 <> `test`.`t1`.`a`) or (0 <> `test`.`t4`.`a`)) +SELECT t1.a FROM t1 LEFT JOIN +(t2 LEFT JOIN (t3 LEFT JOIN t4 ON 1) ON t2.a) +ON 0 WHERE t1.a OR t4.a; +a +DROP TABLE t1,t2,t3,t4; +# +# Bug#56254 Assertion tab->ref.use_count fails in +# join_read_key_unlock_row() on 4-way JOIN +# +CREATE TABLE t1 ( +pk INT NOT NULL, +col_int_key INT, +col_int INT, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +); +INSERT INTO t1 VALUES (6, -448724992, NULL); +CREATE TABLE t2 ( +col_int INT, +col_varchar_10 VARCHAR(10) +); +INSERT INTO t2 VALUES (6,'afasdkiyum'); +CREATE TABLE t3 ( +col_varchar_10 VARCHAR(10), +col_int INT +); +CREATE TABLE t4 ( +pk INT NOT NULL, +PRIMARY KEY (pk) +); +INSERT INTO t4 VALUES (1); +INSERT INTO t4 VALUES (2); +SELECT t1.col_int +FROM t1 +LEFT JOIN t2 +LEFT JOIN t3 +JOIN t4 +ON t3.col_int = t4.pk +ON t2.col_varchar_10 = t3.col_varchar_10 +ON t2.col_int = t1.pk +WHERE t1.col_int_key IS NULL OR t4.pk < t3.col_int; +col_int +EXPLAIN FORMAT=tree SELECT t1.col_int +FROM t1 +LEFT JOIN t2 +LEFT JOIN t3 +JOIN t4 +ON t3.col_int = t4.pk +ON t2.col_varchar_10 = t3.col_varchar_10 +ON t2.col_int = t1.pk +WHERE t1.col_int_key IS NULL OR t4.pk < t3.col_int; +EXPLAIN +-> Parallel scan on + -> Filter: (found_match(t3..t4), ((t1.col_int_key is null) or (t4.pk < t3.col_int)), true) (cost=0.70 rows=1) + -> Nested loop left join (cost=0.70 rows=1) + -> PQblock scan on t1 (cost=0.35 rows=1) + -> Nested loop left join (cost=0.70 rows=1) + -> Filter: (t2.col_int = t1.pk) (cost=0.35 rows=1) + -> Table scan on t2 (cost=0.35 rows=1) + -> Nested loop inner join (cost=0.70 rows=1) + -> Filter: (t3.col_varchar_10 = t2.col_varchar_10) (cost=0.35 rows=1) + -> Table scan on t3 (cost=0.35 rows=1) + -> Single-row index lookup on t4 using PRIMARY (pk=t3.col_int) (cost=0.35 rows=1) + +DROP TABLE t1,t2,t3,t4; + +# BUG#12567331 - INFINITE LOOP WHEN RESOLVING AN ALIASED COLUMN +# USED IN GROUP BY + +CREATE TABLE t1 (pk int(11)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +PREPARE prep_stmt_9846 FROM ' +SELECT alias1.pk AS field1 FROM +t1 AS alias1 +LEFT JOIN +( + t1 AS alias2 + RIGHT JOIN + ( + t1 AS alias3 + JOIN t1 AS alias4 + ON 1 + ) + ON 1 +) +ON 1 +GROUP BY field1'; +execute prep_stmt_9846; +field1 +execute prep_stmt_9846; +field1 +deallocate prepare prep_stmt_9846; +drop table t1; +# +# Bug#13040136 - ASSERT IN PLAN_CHANGE_WATCHDOG::~PLAN_CHANGE_WATCHDOG() +# +CREATE TABLE t1 ( +col_varchar_10 VARCHAR(10), +col_int_key INTEGER, +col_varchar_10_key VARCHAR(10), +pk INTEGER NOT NULL, +PRIMARY KEY (pk), +KEY (col_int_key), +KEY (col_varchar_10_key) +); +INSERT INTO t1 VALUES ('q',NULL,'o',1); +CREATE TABLE t2 ( +pk INTEGER NOT NULL AUTO_INCREMENT, +col_varchar_10_key VARCHAR(10), +col_int_key INTEGER, +col_varchar_10 VARCHAR(10), +PRIMARY KEY (pk), +KEY (col_varchar_10_key), +KEY col_int_key (col_int_key) +); +INSERT INTO t2 VALUES +(1,'r',NULL,'would'),(2,'tell',-655032320,'t'), +(3,'d',9,'a'),(4,'gvafasdkiy',6,'ugvafasdki'), +(5,'that\'s',NULL,'she'),(6,'bwftwugvaf',7,'cbwftwugva'), +(7,'f',-700055552,'mkacbwftwu'),(8,'a',9,'be'), +(9,'d',NULL,'u'),(10,'ckiixcsxmk',NULL,'o'); +SELECT DISTINCT t2.col_int_key +FROM +t1 +LEFT JOIN t2 +ON t1.col_varchar_10 = t2.col_varchar_10_key +WHERE t2.pk +ORDER BY t2.col_int_key; +col_int_key +DROP TABLE t1,t2; +# +# Bug#13068506 - QUERY WITH GROUP BY ON NON-AGGR COLUMN RETURNS WRONG RESULT +# +CREATE TABLE t1 (i1 int); +INSERT INTO t1 VALUES (100), (101); +CREATE TABLE t2 (i2 int, i3 int); +INSERT INTO t2 VALUES (20,1),(10,2); +CREATE TABLE t3 (i4 int(11)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t3 VALUES (1),(2); + +SELECT ( +SELECT MAX( t2.i2 ) +FROM t3 RIGHT JOIN t2 ON ( t2.i3 = 2 ) +WHERE t2.i3 <> t1.i1 +) AS field1 +FROM t1;; +field1 +20 +20 + +SELECT ( +SELECT MAX( t2.i2 ) +FROM t3 RIGHT JOIN t2 ON ( t2.i3 = 2 ) +WHERE t2.i3 <> t1.i1 +) AS field1 +FROM t1 GROUP BY field1;; +field1 +20 + +drop table t1,t2,t3; +# Bug#11766384 - 59487: WRONG RESULT WITH STRAIGHT_JOIN AND RIGHT JOIN +CREATE TABLE t1 ( +pk int(11) NOT NULL, +col_varchar_10_latin1_key varchar(10) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (1,'1'); +CREATE TABLE t2 ( +pk int(11) NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (1); +CREATE TABLE t3 ( +pk int(11) NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t3 VALUES (1); +CREATE TABLE t4 ( +pk int(11) NOT NULL, +col_int int(11) DEFAULT NULL, +col_int_key int(11) DEFAULT NULL, +col_varchar_10_latin1_key varchar(10) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t4 VALUES (1,1,1,'1'); +CREATE TABLE t5 ( +col_int int(11) DEFAULT NULL, +col_varchar_10_utf8_key varchar(10) CHARACTER SET utf8 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t5 VALUES (1,'1'); +CREATE TABLE t6 ( +col_int_key int(11) DEFAULT NULL, +col_varchar_10_latin1_key varchar(10) DEFAULT NULL, +pk int(11) NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t6 VALUES (1,'1',1); +SELECT STRAIGHT_JOIN t6a.pk, t2.pk +FROM +t6 AS t6a +LEFT JOIN +( +t2 +RIGHT JOIN +( +( +t1 +LEFT JOIN +( +t4 +JOIN +t3 +ON t4.col_int +) +ON t4.col_int_key = t1.pk +) +LEFT JOIN +( +t5 +JOIN +t6 AS t6b +ON t5.col_varchar_10_utf8_key = t6b.col_varchar_10_latin1_key +) +ON t1.pk = t5.col_int +) +ON t4.col_varchar_10_latin1_key = t1.col_varchar_10_latin1_key +AND t5.col_varchar_10_utf8_key = 0 +) +ON t6a.pk IS TRUE +WHERE t6b.col_int_key IS TRUE +; +pk pk +1 NULL +EXPLAIN SELECT STRAIGHT_JOIN t6a.pk, t2.pk +FROM +t6 AS t6a +LEFT JOIN +( +t2 +RIGHT JOIN +( +( +t1 +LEFT JOIN +( +t4 +JOIN +t3 +ON t4.col_int +) +ON t4.col_int_key = t1.pk +) +LEFT JOIN +( +t5 +JOIN +t6 AS t6b +ON t5.col_varchar_10_utf8_key = t6b.col_varchar_10_latin1_key +) +ON t1.pk = t5.col_int +) +ON t4.col_varchar_10_latin1_key = t1.col_varchar_10_latin1_key +AND t5.col_varchar_10_utf8_key = 0 +) +ON t6a.pk IS TRUE +WHERE t6b.col_int_key IS TRUE +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t6a NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t5 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 SIMPLE t6b NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select straight_join `test`.`t6a`.`pk` AS `pk`,`test`.`t2`.`pk` AS `pk` from `test`.`t6` `t6a` join `test`.`t1` left join (`test`.`t4` join `test`.`t3`) on(((`test`.`t4`.`col_int_key` = `test`.`t1`.`pk`) and (0 <> `test`.`t4`.`col_int`))) join `test`.`t5` join `test`.`t6` `t6b` left join `test`.`t2` on(((`test`.`t4`.`col_varchar_10_latin1_key` = `test`.`t1`.`col_varchar_10_latin1_key`) and (`test`.`t5`.`col_varchar_10_utf8_key` = 0))) where ((`test`.`t5`.`col_int` = `test`.`t1`.`pk`) and ((0 <> `test`.`t6b`.`col_int_key`) is true) and (`test`.`t5`.`col_varchar_10_utf8_key` = `test`.`t6b`.`col_varchar_10_latin1_key`) and ((0 <> `test`.`t6a`.`pk`) is true)) +SELECT t6a.pk, t2.pk +FROM +t6 AS t6a +LEFT JOIN +( +t2 +RIGHT JOIN +( +( +t1 +LEFT JOIN +( +t4 +JOIN +t3 +ON t4.col_int +) +ON t4.col_int_key = t1.pk +) +LEFT JOIN +( +t5 +JOIN +t6 AS t6b +ON t5.col_varchar_10_utf8_key = t6b.col_varchar_10_latin1_key +) +ON t1.pk = t5.col_int +) +ON t4.col_varchar_10_latin1_key = t1.col_varchar_10_latin1_key +AND t5.col_varchar_10_utf8_key = 0 +) +ON t6a.pk IS TRUE +WHERE t6b.col_int_key IS TRUE +; +pk pk +1 NULL +EXPLAIN SELECT t6a.pk, t2.pk +FROM +t6 AS t6a +LEFT JOIN +( +t2 +RIGHT JOIN +( +( +t1 +LEFT JOIN +( +t4 +JOIN +t3 +ON t4.col_int +) +ON t4.col_int_key = t1.pk +) +LEFT JOIN +( +t5 +JOIN +t6 AS t6b +ON t5.col_varchar_10_utf8_key = t6b.col_varchar_10_latin1_key +) +ON t1.pk = t5.col_int +) +ON t4.col_varchar_10_latin1_key = t1.col_varchar_10_latin1_key +AND t5.col_varchar_10_utf8_key = 0 +) +ON t6a.pk IS TRUE +WHERE t6b.col_int_key IS TRUE +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t6a NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t5 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 SIMPLE t6b NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t6a`.`pk` AS `pk`,`test`.`t2`.`pk` AS `pk` from `test`.`t6` `t6a` join `test`.`t1` left join (`test`.`t4` join `test`.`t3`) on(((`test`.`t4`.`col_int_key` = `test`.`t1`.`pk`) and (0 <> `test`.`t4`.`col_int`))) join `test`.`t5` join `test`.`t6` `t6b` left join `test`.`t2` on(((`test`.`t4`.`col_varchar_10_latin1_key` = `test`.`t1`.`col_varchar_10_latin1_key`) and (`test`.`t5`.`col_varchar_10_utf8_key` = 0))) where ((`test`.`t5`.`col_int` = `test`.`t1`.`pk`) and ((0 <> `test`.`t6b`.`col_int_key`) is true) and (`test`.`t5`.`col_varchar_10_utf8_key` = `test`.`t6b`.`col_varchar_10_latin1_key`) and ((0 <> `test`.`t6a`.`pk`) is true)) +EXPLAIN SELECT * FROM t5 LEFT JOIN t6 ON t5.col_int=1000 +WHERE t6.col_int_key IS TRUE; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t5 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 SIMPLE t6 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t5`.`col_int` AS `col_int`,`test`.`t5`.`col_varchar_10_utf8_key` AS `col_varchar_10_utf8_key`,`test`.`t6`.`col_int_key` AS `col_int_key`,`test`.`t6`.`col_varchar_10_latin1_key` AS `col_varchar_10_latin1_key`,`test`.`t6`.`pk` AS `pk` from `test`.`t5` join `test`.`t6` where ((`test`.`t5`.`col_int` = 1000) and ((0 <> `test`.`t6`.`col_int_key`) is true)) +EXPLAIN SELECT * FROM t5 LEFT JOIN t6 ON t5.col_int=1000 +WHERE t6.col_int_key IS NOT TRUE; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t5 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t6 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t5`.`col_int` AS `col_int`,`test`.`t5`.`col_varchar_10_utf8_key` AS `col_varchar_10_utf8_key`,`test`.`t6`.`col_int_key` AS `col_int_key`,`test`.`t6`.`col_varchar_10_latin1_key` AS `col_varchar_10_latin1_key`,`test`.`t6`.`pk` AS `pk` from `test`.`t5` left join `test`.`t6` on((`test`.`t5`.`col_int` = 1000)) where ((0 <> `test`.`t6`.`col_int_key`) is not true) +drop table t1,t2,t3,t4,t5,t6; +# +# Verify that the "not exists" optimization works. +# +CREATE TABLE t1(a INT); +CREATE TABLE t2(a INT NOT NULL); +INSERT INTO t1 VALUES(1),(2); +INSERT INTO t2 VALUES(1),(2); +EXPLAIN SELECT * FROM t1 LEFT JOIN t2 ON t1.a=t2.a WHERE t2.a IS NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Not exists +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a` from `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`a` = `test`.`t1`.`a`)) where (`test`.`t2`.`a` is null) +FLUSH STATUS; +SELECT * FROM t1 LEFT JOIN t2 ON t1.a=t2.a WHERE t2.a IS NULL; +a a +SHOW STATUS LIKE 'HANDLER_READ%'; +Variable_name Value +Handler_read_first 3 +Handler_read_key 3 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 6 +DROP TABLE t1,t2; +# +# Bug#13464334 SAME QUERY PRODUCES DIFFERENT RESULTS WHEN USED WITH AND +# WITHOUT UNION ALL +# +CREATE TABLE t1 (p1 INT PRIMARY KEY, a CHAR(1)); +CREATE TABLE t2 (p2 INT PRIMARY KEY, b CHAR(1)); +INSERT INTO t1 VALUES (1,'a'),(2,'b'),(3,'c'); +INSERT INTO t2 VALUES (1,'h'),(2,'i'),(3,'j'),(4,'k'); +CREATE VIEW v1 AS SELECT * FROM t1; +CREATE VIEW v2 AS SELECT * FROM t2; +(SELECT p1 FROM v2 LEFT JOIN v1 ON b = a WHERE p2 = 1 GROUP BY p1 ORDER BY p1) +UNION (SELECT NULL LIMIT 0); +p1 +NULL +DROP VIEW v1, v2; +DROP TABLE t1, t2; +# +# Bug#13980954 Missing data on left join + null value + where..in +# +CREATE TABLE t1 (ik INT, vc varchar(1)) charset utf8mb4 ENGINE=Innodb; +explain format=json SELECT straight_join t1.vc, t1.ik +FROM t1 JOIN t1 AS t2 ON t1.vc=t2.vc LEFT JOIN t1 AS t3 ON t1.vc=t3.vc; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.05" + }, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.10", + "prefix_cost": "0.35", + "data_read_per_join": "16" + }, + "used_columns": [ + "vc", + "ik" + ], + "query_block": { + "cost_info": { + "query_cost": "1.05" + }, + "nested_loop": [ + { + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.10", + "prefix_cost": "0.35", + "data_read_per_join": "16" + }, + "used_columns": [ + "ik", + "vc" + ] + } + }, + { + "table": { + "select_id": 2, + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.10", + "prefix_cost": "0.70", + "data_read_per_join": "16" + }, + "used_columns": [ + "vc" + ], + "attached_condition": "(`test`.`t2`.`vc` = `test`.`t1`.`vc`)" + } + }, + { + "table": { + "select_id": 2, + "table_name": "t3", + "access_type": "ALL", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.10", + "prefix_cost": "1.05", + "data_read_per_join": "16" + }, + "used_columns": [ + "vc" + ], + "attached_condition": "(is_not_null_compl(t3), (`test`.`t3`.`vc` = `test`.`t1`.`vc`), true)" + } + } + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select straight_join `test`.`t1`.`vc` AS `vc`,`test`.`t1`.`ik` AS `ik` from `test`.`t1` join `test`.`t1` `t2` left join `test`.`t1` `t3` on((`test`.`t3`.`vc` = `test`.`t1`.`vc`)) where (`test`.`t2`.`vc` = `test`.`t1`.`vc`) +SELECT straight_join t1.vc, t1.ik +FROM t1 JOIN t1 AS t2 ON t1.vc=t2.vc LEFT JOIN t1 AS t3 ON t1.vc=t3.vc; +vc ik +DROP TABLE t1; +# +# Bug #18345786 CRASH AROUND ST_JOIN_TABLE::AND_WITH_CONDITION +# +CREATE TABLE t1(a INT) ENGINE=INNODB; +SET @a:=(SELECT ROW(1, 2)= +ROW((SELECT 1 FROM t1 LEFT JOIN t1 t2 ON 1), 1)); +DROP TABLE t1; +# +# Coverage for "unique row not found" +# +create table t1(a int, unique key(a)) engine=innodb; +insert into t1 values(1); +explain select * from t1 left join t1 as t2 +on t2.a=12 +where t1.a=1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL const a a 5 const 1 100.00 Using index +1 SIMPLE t2 NULL const a a 5 const 0 0.00 unique row not found +Warnings: +Note 1003 /* select#1 */ select '1' AS `a`,NULL AS `a` from `test`.`t1` left join `test`.`t1` `t2` on(multiple equal(12, NULL)) where true +select * from t1 left join t1 as t2 +on t2.a=12 +where t1.a=1; +a a +1 NULL +drop table t1; +# +# Bug#18717059 MISSING ROWS ON NESTED JOIN WITH SUBQUERY +# WITH MYISAM OR MEMORY +# +CREATE TABLE t1 ( +pk INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +PRIMARY KEY (pk), +KEY col_varchar_key (col_varchar_key, col_int_key) +) ENGINE=MyISAM; +INSERT INTO t1 VALUES (23,4,'d'); +INSERT INTO t1 VALUES (24,8,'g'); +INSERT INTO t1 VALUES (25,NULL,'x'); +INSERT INTO t1 VALUES (26,NULL,'f'); +INSERT INTO t1 VALUES (27,0,'p'); +INSERT INTO t1 VALUES (28,NULL,'j'); +INSERT INTO t1 VALUES (29,8,'c'); +CREATE TABLE t2 ( +pk INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +PRIMARY KEY (pk) +) ENGINE=MyISAM; +SELECT 9 +FROM t1 AS table1 +RIGHT JOIN t1 AS table2 +ON table2.col_int_key = table1.col_int_key +AND table1.col_varchar_key = ( +SELECT subquery2_t2.col_varchar_key +FROM t2 +STRAIGHT_JOIN ( t2 AS subquery2_t2 +JOIN t1 AS subquery2_t3 +) ON ( subquery2_t3.col_int_key = subquery2_t2.pk ) +); +9 +9 +9 +9 +9 +9 +9 +9 +CREATE TABLE where_subselect_table AS +SELECT 9 +FROM t1 AS table1 +RIGHT JOIN t1 AS table2 +ON table2.col_int_key = table1.col_int_key +AND table1.col_varchar_key = ( +SELECT subquery2_t2.col_varchar_key +FROM t2 +STRAIGHT_JOIN ( t2 AS subquery2_t2 +JOIN t1 AS subquery2_t3 +) ON ( subquery2_t3.col_int_key = subquery2_t2.pk ) +); +set optimizer_switch='condition_fanout_filter=on'; +SELECT * +FROM where_subselect_table +WHERE (9) IN ( SELECT 9 +FROM t1 AS table1 +RIGHT JOIN t1 AS table2 +ON table2.col_int_key = table1.col_int_key +AND table1.col_varchar_key = ( +SELECT subquery2_t2.col_varchar_key +FROM t2 +STRAIGHT_JOIN ( t2 AS subquery2_t2 +JOIN t1 AS subquery2_t3 +) ON ( subquery2_t3.col_int_key = subquery2_t2.pk ) +) ) +/* TRANSFORM_OUTCOME_UNORDERED_MATCH */; +9 +9 +9 +9 +9 +9 +9 +9 +set optimizer_switch='condition_fanout_filter=off'; +SELECT * +FROM where_subselect_table +WHERE (9) IN ( SELECT 9 +FROM t1 AS table1 +RIGHT JOIN t1 AS table2 +ON table2.col_int_key = table1.col_int_key +AND table1.col_varchar_key = ( +SELECT subquery2_t2.col_varchar_key +FROM t2 +STRAIGHT_JOIN ( t2 AS subquery2_t2 +JOIN t1 AS subquery2_t3 +) ON ( subquery2_t3.col_int_key = subquery2_t2.pk ) +) ) +/* TRANSFORM_OUTCOME_UNORDERED_MATCH */; +9 +9 +9 +9 +9 +9 +9 +9 +DROP TABLE t1, t2, where_subselect_table; +# Bug#14358878 Wrong results on table left join view +CREATE TABLE a (id INTEGER); +CREATE TABLE b (id INTEGER); +CREATE ALGORITHM=MERGE VIEW vmerge AS SELECT 1 AS id, id AS b_id FROM b; +CREATE ALGORITHM=TEMPTABLE VIEW vmat AS SELECT 1 AS id, id AS b_id FROM b; +INSERT INTO a(id) VALUES (1); +SELECT * +FROM a LEFT JOIN vmerge AS v ON a.id = v.id; +id id b_id +1 NULL NULL +SELECT * +FROM a LEFT JOIN vmat AS v ON a.id = v.id; +id id b_id +1 NULL NULL +SELECT * +FROM a LEFT JOIN (SELECT 1 AS one, id FROM b) AS v ON a.id = v.id; +id one id +1 NULL NULL +SELECT * +FROM a LEFT JOIN (SELECT DISTINCT 1 AS one, id FROM b) AS v ON a.id = v.id; +id one id +1 NULL NULL +SELECT * +FROM a LEFT JOIN vmerge AS v ON a.id = v.id +UNION DISTINCT +SELECT * +FROM a LEFT JOIN vmerge AS v ON a.id = v.id; +id id b_id +1 NULL NULL +SELECT * +FROM a LEFT JOIN vmerge AS v ON a.id = v.id +UNION ALL +SELECT * +FROM a LEFT JOIN vmerge AS v ON a.id = v.id; +id id b_id +1 NULL NULL +1 NULL NULL +DROP VIEW vmerge, vmat; +DROP TABLE a, b; +# Bug#15936817 Table left join view, unmatched rows problem where +# view contains an IF +CREATE TABLE small ( +id INTEGER not null, +PRIMARY KEY (id) +); +CREATE TABLE big ( +id INTEGER not null, +PRIMARY KEY (id) +); +INSERT INTO small VALUES (1), (2); +INSERT INTO big VALUES (1), (2), (3), (4); +CREATE VIEW small_view AS +SELECT *, IF (id % 2 = 1, 1, 0) AS is_odd +FROM small; +CREATE VIEW big_view AS +SELECT big.*, small_view.id AS small_id, small_view.is_odd +FROM big LEFT JOIN small_view ON small_view.id = big.id; +SELECT * FROM big_view; +id small_id is_odd +1 1 1 +2 2 0 +3 NULL NULL +4 NULL NULL +SELECT big.*, small.id AS small_id, small.is_odd +FROM big LEFT JOIN +(SELECT id, IF (id % 2 = 1, 1, 0) AS is_odd FROM small) AS small +ON big.id = small.id; +id small_id is_odd +1 1 1 +2 2 0 +3 NULL NULL +4 NULL NULL +# Check the IS NULL and thruth predicates +SELECT big.*, dt.* +FROM big LEFT JOIN (SELECT id as dt_id, +id IS NULL AS nul, +id IS NOT NULL AS nnul, +id IS TRUE AS t, +id IS NOT TRUE AS nt, +id IS FALSE AS f, +id IS NOT FALSE AS nf, +id IS UNKNOWN AS u, +id IS NOT UNKNOWN AS nu +FROM small) AS dt +ON big.id=dt.dt_id; +id dt_id nul nnul t nt f nf u nu +1 1 0 1 1 0 0 1 0 1 +2 2 0 1 1 0 0 1 0 1 +3 NULL NULL NULL NULL NULL NULL NULL NULL NULL +4 NULL NULL NULL NULL NULL NULL NULL NULL NULL +# Check comparison predicates +SELECT big.*, dt.* +FROM big LEFT JOIN (SELECT id as dt_id, +id = 1 AS eq, +id <> 1 AS ne, +id > 1 AS gt, +id >= 1 AS ge, +id < 1 AS lt, +id <= 1 AS le, +id <=> 1 AS equal +FROM small) AS dt +ON big.id=dt.dt_id; +id dt_id eq ne gt ge lt le equal +1 1 1 0 0 1 0 1 1 +2 2 0 1 1 1 0 0 0 +3 NULL NULL NULL NULL NULL NULL NULL NULL +4 NULL NULL NULL NULL NULL NULL NULL NULL +# Check CASE, NULLIF and COALESCE +SELECT big.*, dt.* +FROM big LEFT JOIN (SELECT id as dt_id, +CASE id WHEN 0 THEN 0 ELSE 1 END AS simple, +CASE WHEN id=0 THEN NULL ELSE 1 END AS cond, +NULLIF(1, NULL) AS nullif, +IFNULL(1, NULL) AS ifnull, +COALESCE(id) AS coal, +INTERVAL(NULL, 1, 2, 3) as intv, +IF (id % 2 = 1, NULL, 1) AS iff +FROM small) AS dt +ON big.id=dt.dt_id; +id dt_id simple cond nullif ifnull coal intv iff +1 1 1 1 1 1 1 -1 NULL +2 2 1 1 1 1 2 -1 1 +3 NULL NULL NULL NULL NULL NULL NULL NULL +4 NULL NULL NULL NULL NULL NULL NULL NULL +DROP VIEW small_view, big_view; +DROP TABLE small, big; +# +# Bug#16893426 OPTIMIZER FAILS TO OPTIMIZE EXPRESSION OF THE +# FORM 'FOO' IS NULL +# +CREATE TABLE t1 ( +id int(11) NOT NULL PRIMARY KEY, +name varchar(20), +INDEX (name) +) ENGINE=InnoDB; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t2 ( +id int(11) NOT NULL PRIMARY KEY, +f_id int(11), +FOREIGN KEY (f_id) REFERENCES t2(id) +) ENGINE=InnoDB; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (1,'A1'),(2,'A2'),(3,'B'); +INSERT INTO t2 VALUES (1,1),(2,2),(3,2),(4,3),(5,3); +ANALYZE TABLE t1; +ANALYZE TABLE t2; +EXPLAIN SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE t1.name LIKE 'A%'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range PRIMARY,name name 83 NULL 2 100.00 Using where; Using index +2 SIMPLE t2 NULL ref f_id f_id 5 test.t1.id 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`id` AS `id`,`test`.`t2`.`f_id` AS `f_id`,`test`.`t1`.`id` AS `id`,`test`.`t1`.`name` AS `name` from `test`.`t2` join `test`.`t1` where ((`test`.`t2`.`f_id` = `test`.`t1`.`id`) and (`test`.`t1`.`name` like 'A%')) +SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE t1.name LIKE 'A%'; +id f_id id name +1 1 1 A1 +2 2 2 A2 +3 2 2 A2 +PREPARE stmt FROM "SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE t1.name LIKE 'A%'"; +EXECUTE stmt; +id f_id id name +1 1 1 A1 +2 2 2 A2 +3 2 2 A2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE t1.name LIKE 'A%' OR 'ASDFGH' IS NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range PRIMARY,name name 83 NULL 2 100.00 Using where; Using index +2 SIMPLE t2 NULL ref f_id f_id 5 test.t1.id 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`id` AS `id`,`test`.`t2`.`f_id` AS `f_id`,`test`.`t1`.`id` AS `id`,`test`.`t1`.`name` AS `name` from `test`.`t2` join `test`.`t1` where ((`test`.`t2`.`f_id` = `test`.`t1`.`id`) and (`test`.`t1`.`name` like 'A%')) +SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE t1.name LIKE 'A%' OR 'ASDFGH' IS NULL; +id f_id id name +1 1 1 A1 +2 2 2 A2 +3 2 2 A2 +PREPARE stmt FROM "SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE t1.name LIKE 'A%' OR 'ASDFGH' IS NULL"; +EXECUTE stmt; +id f_id id name +1 1 1 A1 +2 2 2 A2 +3 2 2 A2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE 0 OR 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`id` AS `id`,`test`.`t2`.`f_id` AS `f_id`,`test`.`t1`.`id` AS `id`,`test`.`t1`.`name` AS `name` from `test`.`t2` left join `test`.`t1` on(multiple equal(`test`.`t2`.`f_id`, `test`.`t1`.`id`)) where false +SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE 0 OR 0; +id f_id id name +PREPARE stmt FROM "SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE 0 OR 0"; +EXECUTE stmt; +id f_id id name +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE 1 OR 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL index NULL f_id 5 NULL 5 100.00 Using index +2 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.f_id 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`id` AS `id`,`test`.`t2`.`f_id` AS `f_id`,`test`.`t1`.`id` AS `id`,`test`.`t1`.`name` AS `name` from `test`.`t2` left join `test`.`t1` on((`test`.`t1`.`id` = `test`.`t2`.`f_id`)) where true +SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE 1 OR 0; +id f_id id name +1 1 1 A1 +2 2 2 A2 +3 2 2 A2 +4 3 3 B +5 3 3 B +PREPARE stmt FROM "SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE 1 OR 0"; +EXECUTE stmt; +id f_id id name +1 1 1 A1 +2 2 2 A2 +3 2 2 A2 +4 3 3 B +5 3 3 B +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE NOT(NOT (0)) OR 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL index NULL f_id 5 NULL 5 100.00 Using index +2 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.f_id 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`id` AS `id`,`test`.`t2`.`f_id` AS `f_id`,`test`.`t1`.`id` AS `id`,`test`.`t1`.`name` AS `name` from `test`.`t2` left join `test`.`t1` on((`test`.`t1`.`id` = `test`.`t2`.`f_id`)) where true +SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE NOT(NOT (0)) OR 1; +id f_id id name +1 1 1 A1 +2 2 2 A2 +3 2 2 A2 +4 3 3 B +5 3 3 B +PREPARE stmt FROM "SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE NOT(NOT (0)) OR 1"; +EXECUTE stmt; +id f_id id name +1 1 1 A1 +2 2 2 A2 +3 2 2 A2 +4 3 3 B +5 3 3 B +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE NOT(NOT (0)) OR 0 = 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`id` AS `id`,`test`.`t2`.`f_id` AS `f_id`,`test`.`t1`.`id` AS `id`,`test`.`t1`.`name` AS `name` from `test`.`t2` left join `test`.`t1` on(multiple equal(`test`.`t2`.`f_id`, `test`.`t1`.`id`)) where false +SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE NOT(NOT (0)) OR 0 = 1; +id f_id id name +PREPARE stmt FROM "SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE NOT(NOT (0)) OR 0 = 1"; +EXECUTE stmt; +id f_id id name +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE 1 IS NOT TRUE AND 0 IS TRUE ; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`id` AS `id`,`test`.`t2`.`f_id` AS `f_id`,`test`.`t1`.`id` AS `id`,`test`.`t1`.`name` AS `name` from `test`.`t2` left join `test`.`t1` on(multiple equal(`test`.`t2`.`f_id`, `test`.`t1`.`id`)) where false +SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE 1 IS NOT TRUE AND 0 IS TRUE ; +id f_id id name +PREPARE stmt FROM "SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE 1 IS NOT TRUE AND 0 IS TRUE "; +EXECUTE stmt; +id f_id id name +EXPLAIN SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE 'a' LIKE 1 OR 2 LIKE '2%' ; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL index NULL f_id 5 NULL 5 100.00 Using index +2 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.f_id 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`id` AS `id`,`test`.`t2`.`f_id` AS `f_id`,`test`.`t1`.`id` AS `id`,`test`.`t1`.`name` AS `name` from `test`.`t2` left join `test`.`t1` on((`test`.`t1`.`id` = `test`.`t2`.`f_id`)) where true +SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE 'a' LIKE 1 OR 2 LIKE '2%' ; +id f_id id name +1 1 1 A1 +2 2 2 A2 +3 2 2 A2 +4 3 3 B +5 3 3 B +PREPARE stmt FROM "SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE 'a' LIKE 1 OR 2 LIKE '2%' "; +EXECUTE stmt; +id f_id id name +1 1 1 A1 +2 2 2 A2 +3 2 2 A2 +4 3 3 B +5 3 3 B +EXPLAIN SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE 1 IS NOT NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL index NULL f_id 5 NULL 5 100.00 Using index +2 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.f_id 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`id` AS `id`,`test`.`t2`.`f_id` AS `f_id`,`test`.`t1`.`id` AS `id`,`test`.`t1`.`name` AS `name` from `test`.`t2` left join `test`.`t1` on((`test`.`t1`.`id` = `test`.`t2`.`f_id`)) where true +SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE 1 IS NOT NULL; +id f_id id name +1 1 1 A1 +2 2 2 A2 +3 2 2 A2 +4 3 3 B +5 3 3 B +PREPARE stmt FROM "SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE 1 IS NOT NULL"; +EXECUTE stmt; +id f_id id name +1 1 1 A1 +2 2 2 A2 +3 2 2 A2 +4 3 3 B +5 3 3 B +EXPLAIN SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE (1<2 AND 2<3) OR (1>1 AND 2<3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL index NULL f_id 5 NULL 5 100.00 Using index +2 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.f_id 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`id` AS `id`,`test`.`t2`.`f_id` AS `f_id`,`test`.`t1`.`id` AS `id`,`test`.`t1`.`name` AS `name` from `test`.`t2` left join `test`.`t1` on((`test`.`t1`.`id` = `test`.`t2`.`f_id`)) where true +SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE (1<2 AND 2<3) OR (1>1 AND 2<3); +id f_id id name +1 1 1 A1 +2 2 2 A2 +3 2 2 A2 +4 3 3 B +5 3 3 B +PREPARE stmt FROM "SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE (1<2 AND 2<3) OR (1>1 AND 2<3)"; +EXECUTE stmt; +id f_id id name +1 1 1 A1 +2 2 2 A2 +3 2 2 A2 +4 3 3 B +5 3 3 B +EXPLAIN SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE (1>=1 AND 2<=2) OR (1=1 AND 2<3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL index NULL f_id 5 NULL 5 100.00 Using index +2 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.f_id 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`id` AS `id`,`test`.`t2`.`f_id` AS `f_id`,`test`.`t1`.`id` AS `id`,`test`.`t1`.`name` AS `name` from `test`.`t2` left join `test`.`t1` on((`test`.`t1`.`id` = `test`.`t2`.`f_id`)) where true +SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE (1>=1 AND 2<=2) OR (1=1 AND 2<3); +id f_id id name +1 1 1 A1 +2 2 2 A2 +3 2 2 A2 +4 3 3 B +5 3 3 B +PREPARE stmt FROM "SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE (1>=1 AND 2<=2) OR (1=1 AND 2<3)"; +EXECUTE stmt; +id f_id id name +1 1 1 A1 +2 2 2 A2 +3 2 2 A2 +4 3 3 B +5 3 3 B +EXPLAIN SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE (1<>1 AND 2=2) OR (1 BETWEEN 0 AND 2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL index NULL f_id 5 NULL 5 100.00 Using index +2 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.f_id 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`id` AS `id`,`test`.`t2`.`f_id` AS `f_id`,`test`.`t1`.`id` AS `id`,`test`.`t1`.`name` AS `name` from `test`.`t2` left join `test`.`t1` on((`test`.`t1`.`id` = `test`.`t2`.`f_id`)) where true +SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE (1<>1 AND 2=2) OR (1 BETWEEN 0 AND 2); +id f_id id name +1 1 1 A1 +2 2 2 A2 +3 2 2 A2 +4 3 3 B +5 3 3 B +PREPARE stmt FROM "SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE (1<>1 AND 2=2) OR (1 BETWEEN 0 AND 2)"; +EXECUTE stmt; +id f_id id name +1 1 1 A1 +2 2 2 A2 +3 2 2 A2 +4 3 3 B +5 3 3 B +DROP TABLE t1,t2; +# +# Bug#22103398 BUG#16893426:SIG11 IN +# ST_SELECT_LEX::FLATTEN_SUBQUERIES | SQL_RESOLVER.CC +# +CREATE TABLE t1(c1 INT, c2 INT, c3 CHAR(1), KEY(c3))ENGINE=InnoDB; +CREATE TABLE t2(c1 INT, c2 INT, c3 CHAR(1), KEY(c3))ENGINE=InnoDB; +SELECT b.c2 AS f1 FROM (t2 AS a JOIN +((t2 AS b JOIN t2 AS c ON (c.c3=b.c3))) +ON (c.c1=b.c2)) +WHERE (c.c3 IN (SELECT subquery1_b.c3 AS subquery1_f1 +FROM (t1 AS subquery1_a JOIN t2 AS subquery1_b ON +(subquery1_b.c1=subquery1_a.c1)))) AND +(a.c1=a.c1 AND (SELECT''FROM DUAL) IS NULL); +f1 +DROP TABLE t1, t2; +# End of Bug#16893426 +# Bug#22561937 Wrong result on outer join with multiple join conditions +# and derived table +CREATE TABLE t1 ( +col_int INT, +pk INT NOT NULL, +PRIMARY KEY (pk) +); +INSERT INTO t1 VALUES +(2,1), (2,2), (6,3), (4,4), (7,5), +(188,6), (0,7), (6,8), (0,9), (9,10); +CREATE TABLE t2 ( +pk INT NOT NULL, +col_int INT, +PRIMARY KEY (pk) +); +INSERT INTO t2 VALUES +(1,0), (2,0), (3,2), (4,NULL), (5,2), +(6,3), (7,3), (8,100), (9,3), (10,6); +explain SELECT table2.pk, table1.col_int +FROM t2 AS table1 +LEFT JOIN t1 AS table2 +ON table2.pk < table1.col_int AND +table2.pk = table1.col_int; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 100.00 Parallel execute (1 workers) +2 SIMPLE table1 NULL ALL NULL NULL NULL NULL 10 100.00 NULL +2 SIMPLE table2 NULL eq_ref PRIMARY PRIMARY 4 test.table1.col_int 1 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`table2`.`pk` AS `pk`,`test`.`table1`.`col_int` AS `col_int` from `test`.`t2` `table1` left join `test`.`t1` `table2` on(((`test`.`table2`.`pk` = `test`.`table1`.`col_int`) and (`test`.`table1`.`col_int` < `test`.`table1`.`col_int`))) where true +SELECT table2.pk, table1.col_int +FROM t2 AS table1 +LEFT JOIN t1 AS table2 +ON table2.pk < table1.col_int AND +table2.pk = table1.col_int; +pk col_int +NULL 0 +NULL 0 +NULL 2 +NULL NULL +NULL 2 +NULL 3 +NULL 3 +NULL 100 +NULL 3 +NULL 6 +explain SELECT table2.pk, table1.col_int +FROM t2 AS table1 +LEFT JOIN (SELECT * FROM t1) AS table2 +ON table2.pk < table1.col_int AND +table2.pk = table1.col_int; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 100.00 Parallel execute (1 workers) +2 SIMPLE table1 NULL ALL NULL NULL NULL NULL 10 100.00 NULL +2 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.table1.col_int 1 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`table1`.`col_int` AS `col_int` from `test`.`t2` `table1` left join (`test`.`t1`) on(((`test`.`t1`.`pk` = `test`.`table1`.`col_int`) and (`test`.`t1`.`pk` < `test`.`table1`.`col_int`))) where true +SELECT table2.pk, table1.col_int +FROM t2 AS table1 +LEFT JOIN (SELECT * FROM t1) AS table2 +ON table2.pk < table1.col_int AND +table2.pk = table1.col_int; +pk col_int +NULL 0 +NULL 0 +NULL 2 +NULL NULL +NULL 2 +NULL 3 +NULL 3 +NULL 100 +NULL 3 +NULL 6 +DROP TABLE t1, t2; +# Bug#22671557: Wrong results on JOIN when composite index is present +CREATE TABLE t1 ( +col_int INT DEFAULT NULL, +col_int_key INT DEFAULT NULL, +pk INT NOT NULL, +PRIMARY KEY (pk), +KEY test_idx (col_int_key,col_int) +); +INSERT INTO t1 VALUES (0, -7, 1), (9, NULL, 15), (182, NULL, 25); +CREATE TABLE t2 ( +col_int INT DEFAULT NULL, +pk INT NOT NULL, +PRIMARY KEY (pk) +); +INSERT INTO t2 VALUES (NULL, 4), (-208, 5), (5, 6), (NULL, 75); +CREATE TABLE t3 ( +col_datetime_key DATETIME DEFAULT NULL, +pk INT NOT NULL, +PRIMARY KEY (pk) +); +INSERT INTO t3 VALUES ('1970-01-01 00:00:00', 5); +CREATE TABLE t4 ( +col_int INT DEFAULT NULL, +pk INT NOT NULL, +col_int_key INT DEFAULT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +); +INSERT INTO t4 VALUES (0, 15, 6), (9, 16, 6); +SELECT alias2.col_datetime_key +FROM +t1 AS alias1 +LEFT JOIN t3 AS alias2 +LEFT JOIN t2 AS alias3 +LEFT JOIN t4 AS alias4 +ON alias3.pk = alias4.col_int_key +ON alias2.pk = alias3.col_int +ON alias1.col_int = alias4.col_int +; +col_datetime_key +1970-01-01 00:00:00 +1970-01-01 00:00:00 +NULL +DROP TABLE t1, t2, t3, t4; +# Bug#22833364: Left join returns incorrect results on the outer side +CREATE TABLE ta ( +a1 varchar(1024) NOT NULL, +a2 int NOT NULL, +KEY user_id(a2) +); +INSERT INTO ta (a1, a2) VALUES ('row1', 4), ('row2', 4); +CREATE TABLE tb ( +b1 int NOT NULL, +b2 varchar(1024) NOT NULL, +b3 int NOT NULL, +PRIMARY KEY (b1) +); +INSERT INTO tb (b1, b2, b3) VALUES +(1, 'text1', 0), (2, 'text2', 0), (3, 'text3', 1), (4, 'text4', 1); +explain SELECT ta.a1, tb.b1, tb.b2 +FROM ta LEFT OUTER JOIN tb +ON ta.a2 = tb.b1 AND tb.b3 = 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE ta NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 SIMPLE tb NULL eq_ref PRIMARY PRIMARY 4 test.ta.a2 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`ta`.`a1` AS `a1`,`test`.`tb`.`b1` AS `b1`,`test`.`tb`.`b2` AS `b2` from `test`.`ta` left join `test`.`tb` on(((`test`.`tb`.`b3` = 0) and (`test`.`tb`.`b1` = `test`.`ta`.`a2`))) where true +SELECT ta.a1, tb.b1, tb.b2 +FROM ta LEFT OUTER JOIN tb +ON ta.a2 = tb.b1 AND tb.b3 = 0; +a1 b1 b2 +row1 NULL NULL +row2 NULL NULL +DROP TABLE ta, tb; +# Bug#23079533: Left join on PK + extra condition doesn't return match +CREATE TABLE m ( +machineid VARCHAR(32) NOT NULL, +orderid bigint unsigned DEFAULT NULL, +extra bigint unsigned DEFAULT NULL, +PRIMARY KEY (machineid) +); +INSERT INTO m (machineid, orderid) +VALUES ('m1', NULL), ('m2', 2), ('m3', NULL), ('m4', NULL); +CREATE TABLE o ( +orderid bigint unsigned NOT NULL, +machineid VARCHAR(32) DEFAULT NULL, +PRIMARY KEY (orderid) +); +INSERT INTO o (orderid, machineid) +VALUES (1, 'm2'), (2, 'm2'); +SELECT o.*,'|' as sep, m.* +FROM o LEFT JOIN m +ON m.machineid = o.machineid AND +m.orderid = o.orderid; +orderid machineid sep machineid orderid extra +1 m2 | NULL NULL NULL +2 m2 | m2 2 NULL +DROP TABLE m, o; +# Bug#23086825: Incorrect query results using left join against derived +CREATE TABLE t1 ( +adslot varchar(5) NOT NULL +); +INSERT INTO t1(adslot) VALUES ('1'), ('2'), ('3'); +CREATE TABLE t2 ( +ionumber varchar(20) NOT NULL, +adslot varchar(5) NOT NULL +); +INSERT INTO t2 (ionumber, adslot) VALUES ('01602', 1), ('01602', 3); +CREATE TABLE t3 ( +ionumber varchar(20) NOT NULL, +ioattribute varchar(5) NOT NULL, +PRIMARY KEY (ionumber) +); +INSERT INTO t3 VALUES ('01602', 'BOB'), ('01603', 'SALLY'); +SELECT s.adslot, lid.ionumber1, lid.ionumber2, lid.ioattribute +FROM t1 s LEFT JOIN +(SELECT lid.adslot, +i.ionumber as ionumber1, +lid.ionumber as ionumber2, +i.ioattribute +FROM t2 lid JOIN t3 i +USING (ionumber) +) AS lid +USING (adslot); +adslot ionumber1 ionumber2 ioattribute +1 01602 01602 BOB +2 NULL NULL NULL +3 01602 01602 BOB +DROP TABLE t1, t2, t3; +# +# Bug #26432173: INCORRECT SUBQUERY OPTIMIZATION WITH +# LEFT JOIN(SUBQUERY) AND ORDER BY +# +CREATE TABLE t1 (a INT); +INSERT t1 values (1),(2),(15),(24),(5); +CREATE TABLE t2 (t1_a INT, b VARCHAR(10)); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN SELECT t1.a, subq.st_value +FROM t1 +LEFT JOIN (SELECT t2.t1_a, 'red' AS st_value +FROM t2) AS subq +ON subq.t1_a = t1.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,'red' AS `st_value` from `test`.`t1` left join (`test`.`t2`) on((`test`.`t2`.`t1_a` = `test`.`t1`.`a`)) where true +EXPLAIN SELECT t1.a, subq.st_value +FROM t1 +LEFT JOIN (SELECT t2.t1_a, 'red' AS st_value +FROM t2) AS subq +ON subq.t1_a = t1.a +ORDER BY t1.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 100.00 Using filesort +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,'red' AS `st_value` from `test`.`t1` left join (`test`.`t2`) on((`test`.`t2`.`t1_a` = `test`.`t1`.`a`)) where true order by `test`.`t1`.`a` +EXPLAIN SELECT t1.a, subq.st_value +FROM (SELECT t2.t1_a, 'red' AS st_value +FROM t2) AS subq +LEFT JOIN t1 +ON subq.t1_a = t1.a +ORDER BY t1.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using temporary; Using filesort +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,'red' AS `st_value` from `test`.`t2` left join `test`.`t1` on((`test`.`t1`.`a` = `test`.`t2`.`t1_a`)) where true order by `test`.`t1`.`a` +SELECT t1.a, subq.st_value +FROM t1 +LEFT JOIN (SELECT t2.t1_a, 'red' AS st_value +FROM t2) AS subq +ON subq.t1_a = t1.a; +a st_value +1 NULL +2 NULL +15 NULL +24 NULL +5 NULL +SELECT t1.a, subq.st_value +FROM t1 +LEFT JOIN (SELECT t2.t1_a, 'red' AS st_value +FROM t2) AS subq +ON subq.t1_a = t1.a +ORDER BY t1.a; +a st_value +1 NULL +2 NULL +5 NULL +15 NULL +24 NULL +SELECT t1.a, subq.st_value +FROM (SELECT t2.t1_a, 'red' AS st_value +FROM t2) AS subq +LEFT JOIN t1 +ON subq.t1_a = t1.a +ORDER BY t1.a; +a st_value +DROP TABLE t1, t2; +# Bug #18898433: EXTREMELY SLOW PERFORMANCE WITH OUTER JOINS AND JOIN +# BUFFER. +# +CREATE TABLE t1 (i INT NOT NULL); +INSERT INTO t1 VALUES (0),(2),(3),(4); +CREATE TABLE t2 (i INT NOT NULL); +INSERT INTO t2 VALUES (0),(1),(3),(4); +CREATE TABLE t3 (i INT NOT NULL); +INSERT INTO t3 VALUES (0),(1),(2),(4); +CREATE TABLE t4 (i INT NOT NULL); +INSERT INTO t4 VALUES (0),(1),(2),(3); +ANALYZE TABLE t1, t2, t3, t4; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +test.t4 analyze status OK +EXPLAIN SELECT * +FROM t1 LEFT JOIN +( +(t2 LEFT JOIN t3 ON t3.i= t2.i) +LEFT JOIN t4 ON t3.i= t4.i +)ON t2.i= t1.i; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i`,`test`.`t2`.`i` AS `i`,`test`.`t3`.`i` AS `i`,`test`.`t4`.`i` AS `i` from `test`.`t1` left join (`test`.`t2` left join `test`.`t3` on((`test`.`t3`.`i` = `test`.`t1`.`i`)) left join `test`.`t4` on((`test`.`t4`.`i` = `test`.`t3`.`i`))) on((`test`.`t2`.`i` = `test`.`t1`.`i`)) where true +EXPLAIN SELECT * +FROM t1 LEFT JOIN +( +(t2 INNER JOIN t3 ON t3.i= t2.i) +LEFT JOIN t4 ON t3.i= t4.i +)ON t2.i= t1.i; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i`,`test`.`t2`.`i` AS `i`,`test`.`t3`.`i` AS `i`,`test`.`t4`.`i` AS `i` from `test`.`t1` left join (`test`.`t2` join `test`.`t3` left join `test`.`t4` on((`test`.`t4`.`i` = `test`.`t1`.`i`))) on(((`test`.`t2`.`i` = `test`.`t1`.`i`) and (`test`.`t3`.`i` = `test`.`t1`.`i`))) where true +EXPLAIN SELECT * +FROM t1 LEFT JOIN t2 ON t2.i= t1.i +LEFT JOIN t3 ON t3.i= t2.i +LEFT JOIN t4 ON t3.i= t4.i; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i`,`test`.`t2`.`i` AS `i`,`test`.`t3`.`i` AS `i`,`test`.`t4`.`i` AS `i` from `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t1`.`i`)) left join `test`.`t3` on((`test`.`t3`.`i` = `test`.`t2`.`i`)) left join `test`.`t4` on((`test`.`t4`.`i` = `test`.`t3`.`i`)) where true +flush status; +SELECT * +FROM t1 LEFT JOIN +( +(t2 LEFT JOIN t3 ON t3.i= t2.i) +LEFT JOIN t4 ON t3.i= t4.i +)ON t2.i= t1.i; +i i i i +0 0 0 0 +2 NULL NULL NULL +3 3 NULL NULL +4 4 4 NULL +SHOW STATUS LIKE 'HANDLER_%'; +Variable_name Value +Handler_commit 1 +Handler_delete 0 +Handler_discover 0 +Handler_external_lock 8 +Handler_mrr_init 0 +Handler_prepare 0 +Handler_read_first 11 +Handler_read_key 11 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 55 +Handler_rollback 0 +Handler_savepoint 0 +Handler_savepoint_rollback 0 +Handler_update 0 +Handler_write 0 +flush status; +SELECT * +FROM t1 LEFT JOIN +( +(t2 INNER JOIN t3 ON t3.i= t2.i) +LEFT JOIN t4 ON t3.i= t4.i +)ON t2.i= t1.i; +i i i i +0 0 0 0 +2 NULL NULL NULL +3 NULL NULL NULL +4 4 4 NULL +SHOW STATUS LIKE 'HANDLER_%'; +Variable_name Value +Handler_commit 1 +Handler_delete 0 +Handler_discover 0 +Handler_external_lock 8 +Handler_mrr_init 0 +Handler_prepare 0 +Handler_read_first 10 +Handler_read_key 10 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 50 +Handler_rollback 0 +Handler_savepoint 0 +Handler_savepoint_rollback 0 +Handler_update 0 +Handler_write 0 +flush status; +SELECT * +FROM t1 LEFT JOIN t2 ON t2.i= t1.i +LEFT JOIN t3 ON t3.i= t2.i +LEFT JOIN t4 ON t3.i= t4.i; +i i i i +0 0 0 0 +2 NULL NULL NULL +3 3 NULL NULL +4 4 4 NULL +SHOW STATUS LIKE 'HANDLER_%'; +Variable_name Value +Handler_commit 1 +Handler_delete 0 +Handler_discover 0 +Handler_external_lock 8 +Handler_mrr_init 0 +Handler_prepare 0 +Handler_read_first 13 +Handler_read_key 13 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 65 +Handler_rollback 0 +Handler_savepoint 0 +Handler_savepoint_rollback 0 +Handler_update 0 +Handler_write 0 +DROP TABLE t1, t2, t3, t4; +# +# Bug #26627181: WRONG RESULT WITH LEFT JOIN + DERIVED TABLES +# +CREATE TABLE t1 (id INT); +CREATE TABLE t2 (id INT); +INSERT INTO t1 VALUES (1), (2); +INSERT INTO t2 VALUES (1); +EXPLAIN SELECT * +FROM (SELECT id +FROM t1) AS a +LEFT JOIN +(SELECT id, 2 AS tall +FROM t2) AS b +ON a.id = b.id +WHERE b.tall IS NOT NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,`test`.`t2`.`id` AS `id`,2 AS `tall` from `test`.`t1` left join (`test`.`t2`) on((`test`.`t2`.`id` = `test`.`t1`.`id`)) where (2 is not null) +SELECT * +FROM (SELECT id +FROM t1) AS a +LEFT JOIN +(SELECT id, 2 AS tall +FROM t2) AS b +ON a.id = b.id +WHERE b.tall IS NOT NULL; +id id tall +1 1 2 +DROP TABLE t1, t2; +# +# Bug #23169204: Left join + merged derived table + group by = bad result +# +CREATE TABLE t1(doc text); +CREATE TABLE t2(a INTEGER DEFAULT NULL); +INSERT INTO t2 VALUES(1); +SELECT je +FROM t2 LEFT JOIN (SELECT 1 AS je FROM t1 LIMIT 1) AS dt ON FALSE; +je +NULL +SELECT je +FROM t2 LEFT JOIN (SELECT 1 AS je FROM t1 LIMIT 1) AS dt ON FALSE +GROUP BY je; +je +NULL +SELECT je +FROM t2 LEFT JOIN (SELECT 1 AS je FROM t1) AS dt ON FALSE; +je +NULL +SELECT je +FROM t2 LEFT JOIN (SELECT 1 AS je FROM t1) AS dt ON FALSE +GROUP BY je; +je +NULL +DROP TABLE t1, t2; +# +# Bug#22489105 WL#9571 : SIG11 IN ITEM_SUBSELECT::EXEC | SQL/ITEM_SUBSELECT.CC +# +SELECT (SELECT * FROM (SELECT 'a') t) AS f1 HAVING (f1 = 'a' OR TRUE); +f1 +a +SELECT (SELECT * FROM (SELECT 'a') t) + 1 AS f1 HAVING (f1 = 'a' OR TRUE); +f1 +1 +SELECT 1 + (SELECT * FROM (SELECT 'a') t) AS f1 HAVING (f1 = 'a' OR TRUE); +f1 +1 +# +# Bug#28237111: WL#9571: TABLE FULL ERROR +# +CREATE TABLE t1 (pk INTEGER, f1 INTEGER, primary key(pk)); +CREATE TABLE t2 (pk INTEGER, f1 INTEGER, primary key(pk)); +CREATE TABLE t3 (pk INTEGER); +INSERT INTO t1 VALUES (1,1),(2,1),(3,1); +INSERT INTO t2 VALUES (1,1),(2,1),(3,1); +INSERT INTO t3 VALUES (1); +SELECT * FROM (t1 RIGHT JOIN +(SELECT * FROM t3 WHERE (DAYNAME('1995'))) AS table2 ON +(( t1.f1 ,t1.pk) IN (SELECT 7,4 UNION SELECT 9,2))) WHERE +(NOT EXISTS (SELECT t1.f1 FROM (t1 INNER JOIN t2 ON (t1.pk=t2.f1)) +WHERE 0 IS NOT NULL)) AND t1.f1 > 50; +pk f1 pk +Warnings: +Warning 1292 Incorrect datetime value: '1995' +DROP TABLE t3,t1,t2; +# +# Bug#28341790: WL#9571: SIG11 IN ITEM_COND::FIX_FIELDS() AT SQL/ITEM_CMPFUNC.CC +# +CREATE TABLE t1 (col_varchar varchar(1) DEFAULT NULL); +INSERT INTO t1 VALUES ('Z') ; +CREATE TABLE t2 (col_varchar varchar(1) DEFAULT NULL); +INSERT INTO t2 VALUES ('Z') ; +PREPARE prep_stmt FROM " SELECT 1 FROM ( ( SELECT * FROM t1 WHERE col_varchar +>= 1 ) AS table1 RIGHT JOIN t2 ON ( ( NULL < NULL ) IS NULL OR 1 = 0 ) ) " ; +EXECUTE prep_stmt ; +1 +1 +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'Z' +EXECUTE prep_stmt ; +1 +1 +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'Z' +DROP TABLE t1,t2; +# +# More coverage for IS TRUE in LEFT JOIN conditions +# +CREATE TABLE t1(c1 INT); +INSERT INTO t1 VALUES(1),(2); +CREATE TABLE t2(c2 INT); +INSERT INTO t2 VALUES(1); +SELECT * FROM t1 LEFT JOIN t2 ON c1=c2; +c1 c2 +1 1 +2 NULL +SELECT * FROM t1 LEFT JOIN t2 ON c1=c2 WHERE c2 IS NULL; +c1 c2 +2 NULL +SELECT * FROM t1 LEFT JOIN t2 ON c1=c2 WHERE c2 IS NOT NULL; +c1 c2 +1 1 +SELECT * FROM t1 LEFT JOIN t2 ON c1=c2 WHERE (c2 IS NOT NULL) = 1; +c1 c2 +1 1 +SELECT * FROM t1 LEFT JOIN t2 ON c1=c2 WHERE (c2 IS NOT NULL) IS TRUE; +c1 c2 +1 1 +SELECT * FROM t1 LEFT JOIN t2 ON c1=c2 WHERE (c2 IS NOT NULL) = 0; +c1 c2 +2 NULL +SELECT * FROM t1 LEFT JOIN t2 ON c1=c2 WHERE (c2 IS NOT NULL) IS FALSE; +c1 c2 +2 NULL +DROP TABLE t1,t2; +# +# Bug#29402481: INCORRECT RESULT FROM OUTER JOIN QUERIES +# +CREATE TABLE t1 ( +pk int primary key auto_increment, +col_int_unique int unique +) ENGINE=InnoDB; +INSERT INTO t1(col_int_unique) values (6),(7); +CREATE TABLE t2 ( +pk int primary key auto_increment, +col_int_key int(11) DEFAULT NULL, +col_int_unique int(11) DEFAULT NULL, +UNIQUE KEY `ix2` (col_int_key,col_int_unique), +KEY col_int_key (col_int_key) +) ENGINE=InnoDB; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t3 ( +pk int NOT NULL +) ENGINE=InnoDB; +INSERT INTO t3(pk) values (6),(7); +SELECT STRAIGHT_JOIN t1.col_int_unique, t2.col_int_key, t3.pk +FROM +(t1 LEFT JOIN t2 ON t1.col_int_unique = t2.col_int_key) +LEFT JOIN t3 ON t3.pk = t1.col_int_unique AND +t1.col_int_unique = t2.col_int_key; +col_int_unique col_int_key pk +6 NULL NULL +7 NULL NULL +DROP TABLE t1,t2,t3; +# +# Bug#29493830 CONST'IFIED OUTER JOIN RETURN INCORRECT RESULTS +# +CREATE TABLE t1 ( +col_int_unique INT DEFAULT NULL, +col_int_key INT DEFAULT NULL, +UNIQUE KEY col_int_unique (col_int_unique) +) ENGINE=InnoDB; +INSERT INTO t1 VALUES (5,0); +CREATE TABLE t2 ( +col_char_16_unique char(16) DEFAULT NULL, +col_int_key INT DEFAULT NULL, +col_int_unique INT DEFAULT NULL, +UNIQUE KEY col_int_unique (col_int_unique) +) ENGINE=InnoDB; +INSERT INTO t2 VALUES ("just",21,5); +CREATE TABLE t3 ( +col_int INT DEFAULT NULL, +col_char_16_unique CHAR(16) DEFAULT NULL, +UNIQUE KEY col_char_16_unique (col_char_16_unique) +) ENGINE=InnoDB; +INSERT INTO t3 VALUES (9,"foo"); +CREATE TABLE t4 ( +col_int INT DEFAULT NULL, +col_int_unique INT DEFAULT NULL, +UNIQUE KEY col_int_unique (col_int_unique) +) ENGINE=InnoDB; +INSERT INTO t4 VALUES (9,5); +explain SELECT STRAIGHT_JOIN +t3.col_int, t4.col_int, +t3.col_int = t4.col_int or t4.col_int IS NULL +FROM (t1 +LEFT JOIN t2 +ON t1.col_int_key = t2.col_int_key AND +t1.col_int_unique = t2.col_int_unique +LEFT JOIN t3 +ON t3.col_char_16_unique = t2.col_char_16_unique +LEFT JOIN t4 +ON t4.col_int = t3.col_int AND #Note, this pred term +t4.col_int_unique = t1.col_int_unique +) WHERE t1.col_int_unique = 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL const col_int_unique col_int_unique 5 const 1 100.00 NULL +1 SIMPLE t2 NULL const col_int_unique col_int_unique 5 const 1 100.00 Impossible ON condition +1 SIMPLE t3 NULL const col_char_16_unique NULL NULL NULL 1 100.00 Impossible ON condition +1 SIMPLE t4 NULL const col_int_unique col_int_unique 5 const 1 100.00 Impossible ON condition +Warnings: +Note 1003 /* select#1 */ select straight_join NULL AS `col_int`,NULL AS `col_int`,((NULL = NULL) or (NULL is null)) AS `t3.col_int = t4.col_int or t4.col_int IS NULL` from `test`.`t1` left join `test`.`t2` on((multiple equal('0', NULL) and multiple equal(5, NULL))) left join `test`.`t3` on(multiple equal(NULL, NULL)) left join `test`.`t4` on((multiple equal(NULL, NULL) and multiple equal(5, NULL))) where true +SELECT STRAIGHT_JOIN +t3.col_int, t4.col_int, +t3.col_int = t4.col_int or t4.col_int IS NULL +FROM (t1 +LEFT JOIN t2 +ON t1.col_int_key = t2.col_int_key AND +t1.col_int_unique = t2.col_int_unique +LEFT JOIN t3 +ON t3.col_char_16_unique = t2.col_char_16_unique +LEFT JOIN t4 +ON t4.col_int = t3.col_int AND #Note, this pred term +t4.col_int_unique = t1.col_int_unique +) WHERE t1.col_int_unique = 5; +col_int col_int t3.col_int = t4.col_int or t4.col_int IS NULL +NULL NULL 1 +DROP TABLE t1, t2, t3, t4; +# +# Bug #30659532: WL#13476: DIFFERENT NUMBER OF ROWS WITH NESTED LOOP JOINS +# +CREATE TABLE t1 ( +pk INTEGER NOT NULL +); +INSERT INTO t1 VALUES (1); +INSERT INTO t1 VALUES (2); +CREATE TABLE t2 ( +pk INTEGER NOT NULL, +PRIMARY KEY (pk) +); +INSERT INTO t2 VALUES (1); +INSERT INTO t2 VALUES (2); +INSERT INTO t2 VALUES (3); +CREATE TABLE t3 ( +f1 INTEGER, +f2 INTEGER, +KEY k2 (f2) +); +INSERT INTO t3 VALUES (NULL,NULL); +INSERT INTO t3 VALUES (NULL,295010100); +INSERT INTO t3 VALUES (NULL,NULL); +INSERT INTO t3 VALUES (NULL,-1762438755); +INSERT INTO t3 VALUES (NULL,4); +ANALYZE TABLE t1, t2, t3; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +EXPLAIN FORMAT=tree SELECT * FROM t1 LEFT JOIN t2 ON t1.pk = t2.pk LEFT JOIN t3 ON t2.pk = t3.f2 WHERE t2.pk < 5; +EXPLAIN +-> Parallel scan on + -> Batched key access left join + -> Batch input rows + -> Nested loop inner join (cost=1.15 rows=2) + -> Filter: (t1.pk < 5) (cost=0.45 rows=2) + -> PQblock scan on t1 (cost=0.45 rows=2) + -> Single-row index lookup on t2 using PRIMARY (pk=t1.pk) (cost=0.30 rows=1) + -> Multi-range index lookup on t3 using k2 (f2=t1.pk) + +SELECT * FROM t1 LEFT JOIN t2 ON t1.pk = t2.pk LEFT JOIN t3 ON t2.pk = t3.f2 WHERE t2.pk < 5; +pk pk f1 f2 +1 1 NULL NULL +2 2 NULL NULL +DROP TABLE t1, t2, t3; +# +# Bug #30654713: WL#13476: DIFFERENT ROWS WITH BATCHED KEY ACCESS LEFT JOIN +# +CREATE TABLE t1 ( +col_int INTEGER, +a INTEGER, +b varchar(10), +KEY key_a (a) +); +INSERT INTO t1 VALUES (5,NULL,'p'); +INSERT INTO t1 VALUES (6,NULL,''); +INSERT INTO t1 VALUES (7,NULL,''); +INSERT INTO t1 VALUES (8,NULL,'Z'); +INSERT INTO t1 VALUES (9,4,'g'); +INSERT INTO t1 VALUES (10,NULL,'if'); +INSERT INTO t1 VALUES (11,NULL,'j'); +INSERT INTO t1 VALUES (12,9,''); +CREATE TABLE t2 ( +a INTEGER, +b varchar(10), +KEY key_b (b) +); +INSERT INTO t2 VALUES (1,'j'); +INSERT INTO t2 VALUES (2,'o'); +INSERT INTO t2 VALUES (3,'z'); +INSERT INTO t2 VALUES (4,'really'); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN format=tree SELECT t1.col_int as t1_ci, t1.a as t1_a, t1.b as t1_b, t2.a as t2_a, t2.b as t2_b, t3.col_int as t3_ci, t3.a as t3_a, t3.b as t3_b +FROM t1 +LEFT JOIN ( t2 LEFT JOIN t1 AS t3 ON t2.a=t3.a ) +ON t1.b = t2.b; +EXPLAIN +-> Parallel scan on + -> Nested loop left join + -> PQblock scan on t1 (cost=1.05 rows=8) + -> Batched key access left join + -> Batch input rows + -> Index lookup on t2 using key_b (b=t1.b) (cost=0.26 rows=1) + -> Multi-range index lookup on t3 using key_a (a=t2.a) + +SELECT t1.col_int as t1_ci, t1.a as t1_a, t1.b as t1_b, t2.a as t2_a, t2.b as t2_b, t3.col_int as t3_ci, t3.a as t3_a, t3.b as t3_b +FROM t1 +LEFT JOIN ( t2 LEFT JOIN t1 AS t3 ON t2.a=t3.a ) +ON t1.b = t2.b; +t1_ci t1_a t1_b t2_a t2_b t3_ci t3_a t3_b +10 NULL if NULL NULL NULL NULL NULL +11 NULL j 1 j NULL NULL NULL +12 9 NULL NULL NULL NULL NULL +5 NULL p NULL NULL NULL NULL NULL +6 NULL NULL NULL NULL NULL NULL +7 NULL NULL NULL NULL NULL NULL +8 NULL Z 3 z NULL NULL NULL +9 4 g NULL NULL NULL NULL NULL +DROP TABLE t1, t2; +# +# Bug#30520749 - REGRESSION: LEFT JOIN WITH IMPOSSIBLE ON CONDITION PERFORMS SLOWLY +# +set optimizer_switch='block_nested_loop=off'; +CREATE TABLE t1 ( f1 INTEGER ); +INSERT INTO t1 VALUES (1), (2), (3), (4), (5); +CREATE TABLE t2 AS SELECT * FROM t1; +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN FORMAT=tree SELECT * FROM t1 LEFT JOIN t2 ON 1=2; +EXPLAIN +-> Parallel scan on + -> Nested loop left join (cost=4.50 rows=25) + -> PQblock scan on t1 (cost=0.75 rows=5) + -> Zero rows (Impossible filter) (cost=0.07..0.35 rows=5) + +DROP TABLE t1, t2; +set optimizer_switch='block_nested_loop=on'; +# +# Bug #31252625: DATA IN WRONG ROW ON LEFT JOIN +# +CREATE TABLE t1 ( +id INTEGER NOT NULL, +b INTEGER, +PRIMARY KEY (id) +); +INSERT INTO t1 VALUES (17,NULL); +INSERT INTO t1 VALUES (136,564); +INSERT INTO t1 VALUES (137,NULL); +CREATE TABLE t2 ( +id INTEGER NOT NULL, +PRIMARY KEY (id) +); +INSERT INTO t2 VALUES (564); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +SELECT * FROM t1 LEFT JOIN t2 ON t1.b = t2.id GROUP BY t1.id; +id b id +17 NULL NULL +136 564 564 +137 NULL NULL +DROP TABLE t1, t2; +set optimizer_switch=default; diff --git a/mysql-test/r/join_outer_innodb.result-pq b/mysql-test/r/join_outer_innodb.result-pq new file mode 100644 index 000000000000..f1600d3ce843 --- /dev/null +++ b/mysql-test/r/join_outer_innodb.result-pq @@ -0,0 +1,90 @@ +CREATE TABLE t1 (id int(11) NOT NULL PRIMARY KEY, name varchar(20), +INDEX (name)) charset utf8mb4 ENGINE=InnoDB; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t2 (id int(11) NOT NULL PRIMARY KEY, fkey int(11), +FOREIGN KEY (fkey) REFERENCES t2(id)) ENGINE=InnoDB; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (1,'A1'),(2,'A2'),(3,'B'); +INSERT INTO t2 VALUES (1,1),(2,2),(3,2),(4,3),(5,3); +ANALYZE TABLE t1; +ANALYZE TABLE t2; +EXPLAIN +SELECT COUNT(*) FROM t2 LEFT JOIN t1 ON t2.fkey = t1.id +WHERE t1.name LIKE 'A%'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range PRIMARY,name name 83 NULL 2 100.00 Using where; Using index +2 SIMPLE t2 NULL ref fkey fkey 5 test.t1.id 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t2` join `test`.`t1` where ((`test`.`t2`.`fkey` = `test`.`t1`.`id`) and (`test`.`t1`.`name` like 'A%')) +EXPLAIN +SELECT COUNT(*) FROM t2 LEFT JOIN t1 ON t2.fkey = t1.id +WHERE t1.name LIKE 'A%' OR FALSE; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range PRIMARY,name name 83 NULL 2 100.00 Using where; Using index +2 SIMPLE t2 NULL ref fkey fkey 5 test.t1.id 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t2` join `test`.`t1` where ((`test`.`t2`.`fkey` = `test`.`t1`.`id`) and (`test`.`t1`.`name` like 'A%')) +DROP TABLE t1,t2; +# +# BUG#58456: Assertion 0 in QUICK_INDEX_MERGE_SELECT::need_sorted_output +# in opt_range.h +# +CREATE TABLE t1 ( +col_int INT, +col_int_key INT, +pk INT NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +) ENGINE=InnoDB; +INSERT INTO t1 VALUES (NULL,1,1), (6,2,2), (5,3,3), (NULL,4,4); +INSERT INTO t1 VALUES (1,NULL,6), (8,5,7), (NULL,8,8), (8,NULL,5); +ANALYZE TABLE t1; +CREATE TABLE t2 ( +pk INT PRIMARY KEY +) ENGINE=InnoDB; + +EXPLAIN SELECT t1.pk +FROM t2 LEFT JOIN t1 ON t2.pk = t1.col_int +WHERE t1.col_int_key BETWEEN 5 AND 6 +AND t1.pk IS NULL OR t1.pk IN (5) +ORDER BY pk; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL index PRIMARY PRIMARY 4 NULL 1 100.00 Using index +2 SIMPLE t1 NULL const PRIMARY,col_int_key PRIMARY 4 const 1 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t2` join `test`.`t1` where ((`test`.`t1`.`col_int` = `test`.`t2`.`pk`) and (((`test`.`t1`.`col_int_key` between 5 and 6) and (`test`.`t1`.`pk` is null)) or (`test`.`t1`.`pk` = 5))) order by `test`.`t1`.`pk` + +SELECT t1.pk +FROM t2 LEFT JOIN t1 ON t2.pk = t1.col_int +WHERE t1.col_int_key BETWEEN 5 AND 6 +AND t1.pk IS NULL OR t1.pk IN (5) +ORDER BY pk; +pk + +DROP TABLE t1,t2; +# End BUG#58456 +# +# Bug #20939184:INNODB: UNLOCK ROW COULD NOT FIND A 2 MODE LOCK ON THE +# RECORD +# +CREATE TABLE t1 (c1 INT, c2 INT, c3 INT, PRIMARY KEY (c1,c2) ); +CREATE TABLE t2 (c1 INT, c2 INT, c3 INT, PRIMARY KEY (c1), KEY (c2)); +INSERT INTO t1 VALUES (1,2,3),(2,3,4),(3,4,5); +INSERT INTO t2 SELECT * FROM t1; +SET TRANSACTION ISOLATION LEVEL READ COMMITTED; +START TRANSACTION; +SELECT * FROM t1 LEFT JOIN t2 ON t1.c2=t2.c2 AND t2.c1=1 FOR UPDATE; +c1 c2 c3 c1 c2 c3 +1 2 3 1 2 3 +2 3 4 NULL NULL NULL +3 4 5 NULL NULL NULL +UPDATE t1 LEFT JOIN t2 ON t1.c1 = t2.c2 AND t2.c1 = 3 SET t1.c3 = RAND()*10; +COMMIT; +SET TRANSACTION ISOLATION LEVEL REPEATABLE READ; +DROP TABLE t1,t2; diff --git a/mysql-test/r/key_diff.result-pq b/mysql-test/r/key_diff.result-pq new file mode 100644 index 000000000000..e7c402f3b4d5 --- /dev/null +++ b/mysql-test/r/key_diff.result-pq @@ -0,0 +1,58 @@ +drop table if exists t1; +CREATE TABLE t1 ( +a char(5) NOT NULL, +b char(4) NOT NULL, +KEY (a), +KEY (b) +) charset utf8mb4; +INSERT INTO t1 VALUES ('A','B'),('b','A'),('C','c'),('D','E'),('a','a'); +select * from t1,t1 as t2; +a b a b +A B A B +A B C c +A B D E +A B a a +A B b A +C c A B +C c C c +C c D E +C c a a +C c b A +D E A B +D E C c +D E D E +D E a a +D E b A +a a A B +a a C c +a a D E +a a a a +a a b A +b A A B +b A C c +b A D E +b A a a +b A b A +analyze table t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +explain select t1.*,t2.* from t1,t1 as t2 where t1.A=t2.B; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL a NULL NULL NULL 5 100.00 NULL +2 SIMPLE t2 NULL ref b b 16 test.t1.a 1 100.00 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` join `test`.`t1` `t2` where (`test`.`t1`.`a` = `test`.`t2`.`b`) +select t1.*,t2.* from t1,t1 as t2 where t1.A=t2.B order by binary t1.a,t2.a; +a b a b +A B a a +A B b A +C c C c +a a a a +a a b A +b A A B +select * from t1 where a='a'; +a b +A B +a a +drop table t1; diff --git a/mysql-test/r/limit.result-pq b/mysql-test/r/limit.result-pq new file mode 100644 index 000000000000..07e70d58929b --- /dev/null +++ b/mysql-test/r/limit.result-pq @@ -0,0 +1,780 @@ +CREATE TABLE t1(a INTEGER); +INSERT INTO t1 VALUES(11),(12),(13),(14),(15),(16),(17),(18),(19); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +CREATE TABLE t2(a INTEGER); +INSERT INTO t2 VALUES(21),(22),(23),(24),(25),(26),(27); +SELECT * FROM t1 LIMIT 6; +a +11 +12 +13 +14 +15 +16 +SELECT * FROM t1 LIMIT 5 OFFSET 1; +a +12 +13 +14 +15 +16 +EXPLAIN FORMAT=TREE SELECT * FROM t1 LIMIT 5 OFFSET 1; +EXPLAIN +-> Limit/Offset: 5/1 row(s) + -> Parallel scan on + -> Limit: 6 row(s) (cost=1.15 rows=6) + -> PQblock scan on t1 (cost=1.15 rows=9) + +(SELECT * FROM t1 LIMIT 7) ORDER BY a DESC LIMIT 4; +a +17 +16 +15 +14 +(SELECT * FROM t1 LIMIT 7 OFFSET 1) ORDER BY a DESC LIMIT 4 OFFSET 2; +a +16 +15 +14 +13 +(SELECT * FROM t1 ORDER BY a DESC LIMIT 7) ORDER BY a LIMIT 4; +a +13 +14 +15 +16 +(SELECT * FROM t1 ORDER BY a DESC LIMIT 7 OFFSET 1) ORDER BY a LIMIT 4 OFFSET 2; +a +14 +15 +16 +17 +SELECT * FROM t1 UNION SELECT * FROM t2 LIMIT 5; +a +11 +12 +13 +14 +15 +SELECT * FROM t1 UNION SELECT * FROM t2 LIMIT 5 OFFSET 6; +a +17 +18 +19 +21 +22 +SELECT * FROM t1 UNION SELECT * FROM t2 ORDER BY a LIMIT 5; +a +11 +12 +13 +14 +15 +SELECT * FROM t1 UNION SELECT * FROM t2 ORDER BY a LIMIT 5 OFFSET 6; +a +17 +18 +19 +21 +22 +SELECT * FROM t1 UNION ALL SELECT * FROM t2 LIMIT 5; +a +11 +12 +13 +14 +15 +SELECT * FROM t1 UNION ALL SELECT * FROM t2 LIMIT 5 OFFSET 6; +a +17 +18 +19 +21 +22 +SELECT * FROM t1 UNION ALL SELECT * FROM t2 ORDER BY a LIMIT 5; +a +11 +12 +13 +14 +15 +SELECT * FROM t1 UNION ALL SELECT * FROM t2 ORDER BY a LIMIT 5 OFFSET 6; +a +17 +18 +19 +21 +22 +(SELECT * FROM t1 LIMIT 5) UNION +SELECT * FROM t2 +LIMIT 8; +a +11 +12 +13 +14 +15 +21 +22 +23 +(SELECT * FROM t1 LIMIT 5 OFFSET 4) UNION +SELECT * FROM t2 +LIMIT 8 OFFSET 1; +a +16 +17 +18 +19 +21 +22 +23 +24 +(SELECT * FROM t1 ORDER BY a DESC LIMIT 5) UNION +SELECT * FROM t2 +LIMIT 8; +a +19 +18 +17 +16 +15 +21 +22 +23 +(SELECT * FROM t1 ORDER BY a DESC LIMIT 5 OFFSET 4) UNION +SELECT * FROM t2 +LIMIT 8 OFFSET 1; +a +14 +13 +12 +11 +21 +22 +23 +24 +(SELECT * FROM t1 LIMIT 5) UNION +SELECT * FROM t2 +ORDER BY a LIMIT 8; +a +11 +12 +13 +14 +15 +21 +22 +23 +(SELECT * FROM t1 LIMIT 5 OFFSET 4) UNION +SELECT * FROM t2 +ORDER BY a LIMIT 8 OFFSET 1; +a +16 +17 +18 +19 +21 +22 +23 +24 +(SELECT * FROM t1 ORDER BY a DESC LIMIT 5) UNION +SELECT * FROM t2 +ORDER BY a LIMIT 8; +a +15 +16 +17 +18 +19 +21 +22 +23 +(SELECT * FROM t1 ORDER BY a DESC LIMIT 5 OFFSET 4) UNION +SELECT * FROM t2 +ORDER BY a LIMIT 8 OFFSET 1; +a +12 +13 +14 +15 +21 +22 +23 +24 +(SELECT * FROM t1 LIMIT 5) UNION ALL +SELECT * FROM t2 +LIMIT 8; +a +11 +12 +13 +14 +15 +21 +22 +23 +(SELECT * FROM t1 LIMIT 5 OFFSET 4) UNION ALL +SELECT * FROM t2 +LIMIT 8 OFFSET 1; +a +16 +17 +18 +19 +21 +22 +23 +24 +(SELECT * FROM t1 ORDER BY a DESC LIMIT 5) UNION ALL +SELECT * FROM t2 +LIMIT 8; +a +19 +18 +17 +16 +15 +21 +22 +23 +(SELECT * FROM t1 ORDER BY a DESC LIMIT 5 OFFSET 4) UNION ALL +SELECT * FROM t2 +LIMIT 8 OFFSET 1; +a +14 +13 +12 +11 +21 +22 +23 +24 +(SELECT * FROM t1 LIMIT 5) UNION ALL +SELECT * FROM t2 +ORDER BY a LIMIT 8; +a +11 +12 +13 +14 +15 +21 +22 +23 +(SELECT * FROM t1 LIMIT 5 OFFSET 4) UNION ALL +SELECT * FROM t2 +ORDER BY a LIMIT 8 OFFSET 1; +a +16 +17 +18 +19 +21 +22 +23 +24 +(SELECT * FROM t1 ORDER BY a DESC LIMIT 5) UNION ALL +SELECT * FROM t2 +ORDER BY a LIMIT 8; +a +15 +16 +17 +18 +19 +21 +22 +23 +(SELECT * FROM t1 ORDER BY a DESC LIMIT 5 OFFSET 4) UNION ALL +SELECT * FROM t2 +ORDER BY a LIMIT 8 OFFSET 1; +a +12 +13 +14 +15 +21 +22 +23 +24 +(SELECT * FROM t1 LIMIT 5) UNION +(SELECT * FROM t2 LIMIT 4) +LIMIT 7; +a +11 +12 +13 +14 +15 +21 +22 +(SELECT * FROM t1 LIMIT 5 OFFSET 4) UNION +(SELECT * FROM t2 LIMIT 4 OFFSET 2) +LIMIT 7 OFFSET 1; +a +16 +17 +18 +19 +23 +24 +25 +(SELECT * FROM t1 ORDER BY a DESC LIMIT 5) UNION +(SELECT * FROM t2 ORDER BY a DESC LIMIT 4) +LIMIT 7; +a +19 +18 +17 +16 +15 +27 +26 +(SELECT * FROM t1 ORDER BY a DESC LIMIT 5 OFFSET 4) UNION +(SELECT * FROM t2 ORDER BY a DESC LIMIT 4 OFFSET 2) +LIMIT 7 OFFSET 1; +a +14 +13 +12 +11 +25 +24 +23 +(SELECT * FROM t1 LIMIT 5) UNION +(SELECT * FROM t2 LIMIT 4) +ORDER BY a LIMIT 7; +a +11 +12 +13 +14 +15 +21 +22 +(SELECT * FROM t1 LIMIT 5 OFFSET 4) UNION +(SELECT * FROM t2 LIMIT 4 OFFSET 2) +ORDER BY a LIMIT 7 OFFSET 1; +a +16 +17 +18 +19 +23 +24 +25 +(SELECT * FROM t1 ORDER BY a DESC LIMIT 5) UNION +(SELECT * FROM t2 ORDER BY a DESC LIMIT 4) +ORDER BY a LIMIT 7; +a +15 +16 +17 +18 +19 +24 +25 +(SELECT * FROM t1 ORDER BY a DESC LIMIT 5 OFFSET 4) UNION +(SELECT * FROM t2 ORDER BY a DESC LIMIT 4 OFFSET 2) +ORDER BY a LIMIT 7 OFFSET 1; +a +12 +13 +14 +15 +22 +23 +24 +(SELECT * FROM t1 LIMIT 5) UNION ALL +(SELECT * FROM t2 LIMIT 4) +LIMIT 7; +a +11 +12 +13 +14 +15 +21 +22 +(SELECT * FROM t1 LIMIT 5 OFFSET 4) UNION ALL +(SELECT * FROM t2 LIMIT 4 OFFSET 2) +LIMIT 7 OFFSET 1; +a +16 +17 +18 +19 +23 +24 +25 +(SELECT * FROM t1 ORDER BY a DESC LIMIT 5) UNION ALL +(SELECT * FROM t2 ORDER BY a DESC LIMIT 4) +LIMIT 7; +a +19 +18 +17 +16 +15 +27 +26 +(SELECT * FROM t1 ORDER BY a DESC LIMIT 5 OFFSET 4) UNION ALL +(SELECT * FROM t2 ORDER BY a DESC LIMIT 4 OFFSET 2) +LIMIT 7 OFFSET 1; +a +14 +13 +12 +11 +25 +24 +23 +(SELECT * FROM t1 LIMIT 5) UNION ALL +(SELECT * FROM t2 LIMIT 4) +ORDER BY a LIMIT 7; +a +11 +12 +13 +14 +15 +21 +22 +(SELECT * FROM t1 LIMIT 5 OFFSET 4) UNION ALL +(SELECT * FROM t2 LIMIT 4 OFFSET 2) +ORDER BY a LIMIT 7 OFFSET 1; +a +16 +17 +18 +19 +23 +24 +25 +(SELECT * FROM t1 ORDER BY a DESC LIMIT 5) UNION ALL +(SELECT * FROM t2 ORDER BY a DESC LIMIT 4) +ORDER BY a LIMIT 7; +a +15 +16 +17 +18 +19 +24 +25 +(SELECT * FROM t1 ORDER BY a DESC LIMIT 5 OFFSET 4) UNION ALL +(SELECT * FROM t2 ORDER BY a DESC LIMIT 4 OFFSET 2) +ORDER BY a LIMIT 7 OFFSET 1; +a +12 +13 +14 +15 +22 +23 +24 +DROP TABLE t1, t2; +create table t1 (a int not null default 0 primary key, b int not null default 0); +insert into t1 () values (); +insert into t1 values (1,1),(2,1),(3,1); +update t1 set a=4 where b=1 limit 1; +select * from t1; +a b +0 0 +2 1 +3 1 +4 1 +update t1 set b=2 where b=1 limit 2; +select * from t1; +a b +0 0 +2 2 +3 2 +4 1 +update t1 set b=4 where b=1; +select * from t1; +a b +0 0 +2 2 +3 2 +4 4 +delete from t1 where b=2 limit 1; +select * from t1; +a b +0 0 +3 2 +4 4 +delete from t1 limit 1; +select * from t1; +a b +3 2 +4 4 +drop table t1; +create table t1 (i int); +insert into t1 (i) values(1),(1),(1); +delete from t1 limit 1; +update t1 set i=2 limit 1; +delete from t1 limit 0; +update t1 set i=3 limit 0; +select * from t1; +i +2 +1 +drop table t1; +select 0 limit 0; +0 +CREATE TABLE t1(id int auto_increment primary key, id2 int, index(id2)); +INSERT INTO t1 (id2) values (0),(0),(0); +DELETE FROM t1 WHERE id=1; +INSERT INTO t1 SET id2=0; +SELECT * FROM t1; +id id2 +2 0 +3 0 +4 0 +DELETE FROM t1 WHERE id2 = 0 ORDER BY id LIMIT 1; +SELECT * FROM t1; +id id2 +3 0 +4 0 +DELETE FROM t1 WHERE id2 = 0 ORDER BY id desc LIMIT 1; +SELECT * FROM t1; +id id2 +3 0 +DROP TABLE t1; +create table t1 (a integer); +insert into t1 values (1); +select 1 as a from t1 union all select 1 from dual limit 1; +a +1 +(select 1 as a from t1) union all (select 1 from dual) limit 1; +a +1 +drop table t1; +create table t1 (a int); +insert into t1 values (1),(2),(3),(4),(5),(6),(7); +analyze table t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +explain select count(*) c FROM t1 WHERE a > 0 ORDER BY c LIMIT 3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select count(0) AS `c` from `test`.`t1` where (`test`.`t1`.`a` > 0) limit 3 +select count(*) c FROM t1 WHERE a > 0 ORDER BY c LIMIT 3; +c +7 +explain select sum(a) c FROM t1 WHERE a > 0 ORDER BY c LIMIT 3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select sum(`test`.`t1`.`a`) AS `c` from `test`.`t1` where (`test`.`t1`.`a` > 0) limit 3 +select sum(a) c FROM t1 WHERE a > 0 ORDER BY c LIMIT 3; +c +28 +drop table t1; +prepare s from "select 1 limit ?"; +set @a='qwe'; +execute s using @a; +ERROR HY000: Incorrect arguments to EXECUTE +set @a=-1; +execute s using @a; +ERROR 22003: unsigned integer value is out of range in 'EXECUTE' +prepare s from "select 1 limit 1, ?"; +execute s using @a; +ERROR 22003: unsigned integer value is out of range in 'EXECUTE' +prepare s from "select 1 limit ?, ?"; +execute s using @a, @a; +ERROR 22003: unsigned integer value is out of range in 'EXECUTE' +set @a=14632475938453979136; +execute s using @a, @a; +1 +set @a=-14632475938453979136; +execute s using @a, @a; +ERROR HY000: Incorrect arguments to EXECUTE +End of 5.0 tests +select 1 as a limit 4294967296,10; +a +End of 5.1 tests +# Bug #28961843: COUNT() WITH LIMIT AND OFFSET RETURNS WRONG RESULT +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (1); +SELECT COUNT(*) FROM t1 LIMIT 1 OFFSET 3; +COUNT(*) +DROP TABLE t1; +# +# Bug #29148115: SIG 6 IN TEMPTABLE::RESULT TEMPTABLE::HANDLER::INDEX_NEXT_CONDITIONAL +# +CREATE TABLE t1 (pk INTEGER PRIMARY KEY); +INSERT INTO t1 VALUES (1); +SELECT t1.pk FROM (SELECT DISTINCT * FROM t1) AS t1 WHERE t1.pk=1 LIMIT 1 OFFSET 2; +pk +DROP TABLE t1; +# +# Bug #29373972: SIG 6 AT HANDLER::START_PSI_BATCH_MODE() +# +set @old_opt_switch=@@optimizer_switch; +set optimizer_switch='block_nested_loop=off'; +CREATE TABLE t1 ( pk INTEGER ); +INSERT INTO t1 VALUES (1), (2); +EXPLAIN FORMAT=tree SELECT JSON_OBJECTAGG(NULL, '') FROM t1, t1 AS t2 GROUP BY t1.pk LIMIT 2 OFFSET 5; +EXPLAIN +-> Limit/Offset: 2/5 row(s) + -> Group aggregate: json_objectagg(NULL,'') + -> Nested loop inner join (cost=1.35 rows=4) + -> Sort: t1.pk (cost=0.45 rows=2) + -> Table scan on t1 (cost=0.45 rows=2) + -> Table scan on t2 (cost=0.35 rows=2) + +SELECT JSON_OBJECTAGG(NULL, '') FROM t1, t1 AS t2 GROUP BY t1.pk LIMIT 2 OFFSET 5; +ERROR 22032: JSON documents may not contain NULL member names. +FLUSH TABLES; +DROP TABLE t1; +set optimizer_switch=@old_opt_switch; +# +# Bug#29531472: SIG 6 AT JOIN::TEST_SKIP_SORT | SQL_OPTIMIZER.CC +# +CREATE TABLE t1 ( +col_int_key INT DEFAULT NULL, +col_varchar_key VARCHAR(1) DEFAULT NULL, +KEY idx_CC_col_int_key (col_int_key), +KEY idx_CC_col_varchar_key (col_varchar_key) +); +INSERT INTO t1 VALUES(1,'A'); +SELECT col_varchar_key AS f1 +FROM t1 +WHERE (col_int_key NOT BETWEEN 10 AND 15 OR col_varchar_key < '2') AND col_int_key IS NULL +GROUP BY f1 LIMIT 100; +f1 +EXPLAIN +SELECT col_varchar_key AS f1 +FROM t1 +WHERE (col_int_key NOT BETWEEN 10 AND 15 OR col_varchar_key < '2') AND col_int_key IS NULL +GROUP BY f1 LIMIT 100; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index idx_CC_col_int_key,idx_CC_col_varchar_key idx_CC_col_varchar_key 7 NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col_varchar_key` AS `f1` from `test`.`t1` where (((`test`.`t1`.`col_int_key` not between 10 and 15) or (`test`.`t1`.`col_varchar_key` < '2')) and (`test`.`t1`.`col_int_key` is null)) group by `f1` limit 100 +DROP TABLE t1; +# +# Bug#30521803: LIMIT CLAUSE OUTSIDE PARENTHESES CAN SUPPRESS ORDERING +# CLAUSES INSIDE +# +CREATE TEMPORARY TABLE t1 (i INT); +INSERT INTO t1 VALUES (1), (2), (3), (4), (5); +# All 3 queries below should return the same result: +SELECT * FROM (SELECT * FROM t1 ORDER BY i DESC LIMIT 3) AS alias LIMIT 2; +i +5 +4 +(SELECT * FROM t1 ORDER BY i DESC LIMIT 3) LIMIT 2; +i +5 +4 +WITH cte AS (SELECT 1) (SELECT * FROM t1 ORDER BY i DESC LIMIT 3) LIMIT 2; +i +5 +4 +DROP TABLE t1; +# +# Bug#30204811 ASSERTION `SELECT_LIMIT > 0' FAILED AT +# TEST_IF_SKIP_SORT_ORDER +# +CREATE TABLE a ( +col_int int, +col_varchar_255 varchar(255), +pk integer auto_increment primary key +) ENGINE=myisam; +CREATE TABLE b ( +col_varchar_10 varchar(10), +pk integer primary key +) ENGINE=myisam; +INSERT INTO a(col_int,col_varchar_255) VALUES (0,""),(1,""); +explain format=tree SELECT STRAIGHT_JOIN a.pk +FROM a +JOIN b ON a.col_varchar_255 = b.col_varchar_10 +WHERE b.pk <= a.col_int +ORDER BY a.pk LIMIT 10; +EXPLAIN +-> Limit: 10 row(s) (cost=1.21 rows=0) + -> Nested loop inner join (cost=1.21 rows=0) + -> Sort: a.pk (cost=0.70 rows=2) + -> Table scan on a (cost=0.70 rows=2) + -> Filter: ((b.pk <= a.col_int) and (a.col_varchar_255 = b.col_varchar_10)) (cost=0.50 rows=0) + -> Index range scan on b (re-planned for each iteration) (cost=0.50 rows=0) + +INSERT INTO a(col_int,col_varchar_255) SELECT col_int,col_varchar_255 FROM a; +INSERT INTO a(col_int,col_varchar_255) SELECT col_int,col_varchar_255 FROM a; +INSERT INTO a(col_int,col_varchar_255) SELECT col_int,col_varchar_255 FROM a; +INSERT INTO a(col_int,col_varchar_255) SELECT col_int,col_varchar_255 FROM a; +INSERT INTO a(col_int,col_varchar_255) SELECT col_int,col_varchar_255 FROM a; +INSERT INTO a(col_int,col_varchar_255) SELECT col_int,col_varchar_255 FROM a; +INSERT INTO a(col_int,col_varchar_255) SELECT col_int,col_varchar_255 FROM a; +INSERT INTO a(col_int,col_varchar_255) SELECT col_int,col_varchar_255 FROM a; +INSERT INTO a(col_int,col_varchar_255) SELECT col_int,col_varchar_255 FROM a; +INSERT INTO a(col_int,col_varchar_255) SELECT col_int,col_varchar_255 FROM a; +INSERT INTO a(col_int,col_varchar_255) SELECT col_int,col_varchar_255 FROM a; +explain format=tree SELECT STRAIGHT_JOIN a.pk +FROM a +JOIN b ON a.col_varchar_255 = b.col_varchar_10 +WHERE b.pk <= a.col_int +ORDER BY a.pk LIMIT 10; +EXPLAIN +-> Limit: 10 row(s) (cost=423.65 rows=0) + -> Nested loop inner join (cost=423.65 rows=0) + -> Sort: a.pk (cost=415.10 rows=4096) + -> Table scan on a (cost=415.10 rows=4096) + -> Filter: ((b.pk <= a.col_int) and (a.col_varchar_255 = b.col_varchar_10)) (cost=8.55 rows=0) + -> Index range scan on b (re-planned for each iteration) (cost=8.55 rows=0) + +DROP TABLE a; +DROP TABLE b; +# Bug#31667061: Inconsistent behavior of @@SQL_SELECT_LIMIT +# with prepared statements +CREATE TABLE t1(id INTEGER); +INSERT INTO t1 (id) VALUES (1), (2), (3); +SET @@sql_select_limit=1; +PREPARE stmt FROM "SELECT * FROM t1 WHERE id > ?"; +SET @a = 0; +EXECUTE stmt using @a; +id +1 +set @@sql_select_limit=2; +EXECUTE stmt using @a; +id +1 +2 +set @@sql_select_limit=DEFAULT; +EXECUTE stmt USING @a; +id +1 +2 +3 +DEALLOCATE PREPARE stmt; +DROP TABLE t1; +CREATE TABLE t1(id INTEGER, c1 INTEGER, c2 INTEGER, c3 INTEGER); +INSERT INTO t1 VALUES(1,1,1,1),(2,2,2,2),(3,9,9,9),(4,10,10,10),(6,1,2,888); +PREPARE stmt FROM +"(SELECT * FROM t1 LIMIT 2) UNION ALL (SELECT * FROM t1 ORDER BY 1)"; +SET @@sql_select_limit=2; +EXECUTE stmt; +id c1 c2 c3 +1 1 1 1 +2 2 2 2 +SET @@sql_select_limit=DEFAULT; +EXECUTE stmt; +id c1 c2 c3 +1 1 1 1 +2 2 2 2 +1 1 1 1 +2 2 2 2 +3 9 9 9 +4 10 10 10 +6 1 2 888 +DEALLOCATE PREPARE stmt; +DROP TABLE t1; diff --git a/mysql-test/r/loose_scan.result-pq b/mysql-test/r/loose_scan.result-pq new file mode 100644 index 000000000000..954da2b1c4b9 --- /dev/null +++ b/mysql-test/r/loose_scan.result-pq @@ -0,0 +1,212 @@ +# +# Bug#13464493 "19 X HIGHER THAN EXPECTED EXEC. TIME FOR +# MYSQL_BENCH/COUNT_DISTINCT_KEY_PREFIX" +# +CREATE TABLE t1 ( +c1 CHAR(1) NOT NULL, +i1 INTEGER NOT NULL, +i2 INTEGER NOT NULL, +PRIMARY KEY (c1,i1), +UNIQUE KEY k1 (c1,i2) +) ENGINE=InnoDB, CHARSET utf8mb4; +INSERT INTO t1 VALUES ('A',0,999),('A',6,993),('A',12,987), +('A',18,981),('A',24,975),('A',30,969),('A',36,963),('A',42,957), +('A',48,951),('A',54,945),('A',60,939),('A',66,933),('A',72,927), +('A',78,921),('A',84,915),('A',90,909),('A',96,903),('A',102,897), +('A',108,891),('A',114,885),('A',120,879),('A',126,873),('A',132,867), +('A',138,861),('A',144,855),('A',150,849),('A',156,843),('A',162,837), +('A',168,831),('A',174,825),('A',180,819),('A',186,813),('A',192,807), +('A',198,801),('A',204,795),('B',210,789),('B',216,783),('B',222,777), +('B',228,771),('B',234,765),('B',240,759),('B',246,753),('B',252,747), +('B',258,741),('B',264,735),('B',270,729),('B',276,723),('B',282,717), +('B',288,711),('B',294,705),('B',300,699),('B',306,693),('B',312,687), +('B',318,681),('B',324,675),('B',330,669),('B',336,663),('B',342,657), +('B',348,651),('B',354,645),('B',360,639),('B',366,633),('B',372,627), +('B',378,621),('C',384,615),('C',390,609),('C',396,603),('C',402,597), +('C',408,591),('C',414,585),('C',420,579),('C',426,573),('C',432,567), +('C',438,561),('C',444,555),('C',450,549),('C',456,543),('C',462,537), +('C',468,531),('C',474,525),('C',480,519),('C',486,513),('C',492,507), +('C',498,501),('C',504,495),('C',510,489),('C',516,483),('C',522,477), +('C',528,471),('C',534,465),('C',540,459),('C',546,453),('C',552,447), +('C',558,441),('C',564,435),('C',570,429),('C',576,423),('C',582,417), +('C',588,411),('C',594,405); +ANALYZE TABLE t1; +EXPLAIN SELECT COUNT(DISTINCT c1) FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range PRIMARY,k1 k1 4 NULL 4 100.00 Using index for group-by +Warnings: +Note 1003 /* select#1 */ select count(distinct `test`.`t1`.`c1`) AS `COUNT(DISTINCT c1)` from `test`.`t1` +SELECT COUNT(DISTINCT c1) FROM t1; +COUNT(DISTINCT c1) +3 +DROP TABLE t1; +# +# Bug#11757108 "CHANGE IN EXECUTION PLAN FOR COUNT_DISTINCT_GROUP_ON_KEY +# CAUSES PEFORMANCE REGRESSIONS" +# +CREATE TABLE t0 ( +i1 INTEGER NOT NULL +); +INSERT INTO t0 VALUES (1),(2),(3),(4),(5),(6),(7),(8),(9),(10), +(11),(12),(13),(14),(15),(16),(17),(18),(19),(20), +(21),(22),(23),(24),(25),(26),(27),(28),(29),(30); +CREATE TABLE t1 ( +c1 CHAR(1) NOT NULL, +i1 INTEGER NOT NULL, +i2 INTEGER NOT NULL, +PRIMARY KEY (c1,i1), +UNIQUE KEY k1 (c1,i2) +) ENGINE=InnoDB, CHARSET utf8mb4; +INSERT INTO t1 SELECT 'A',i1,i1 FROM t0; +INSERT INTO t1 SELECT 'B',i1,i1 FROM t0; +INSERT INTO t1 SELECT 'C',i1,i1 FROM t0; +INSERT INTO t1 SELECT 'D',i1,i1 FROM t0; +INSERT INTO t1 SELECT 'E',i1,i1 FROM t0; +INSERT INTO t1 SELECT 'F',i1,i1 FROM t0; +ANALYZE TABLE t1; +EXPLAIN select c1,count(distinct i2) from t1 group by c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range PRIMARY,k1 k1 8 NULL 181 100.00 Using index for group-by (scanning) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c1` AS `c1`,count(distinct `test`.`t1`.`i2`) AS `count(distinct i2)` from `test`.`t1` group by `test`.`t1`.`c1` +FLUSH STATUS; +select c1,count(distinct i2) from t1 group by c1; +c1 count(distinct i2) +A 30 +B 30 +C 30 +D 30 +E 30 +F 30 +SHOW STATUS LIKE 'Handler_read_key'; +Variable_name Value +Handler_read_key 2 +SHOW STATUS LIKE 'Handler_read_next'; +Variable_name Value +Handler_read_next 180 +DROP TABLE t0, t1; +# +# Bug#17222452 SELECT COUNT(DISTINCT A,B) INCORRECTLY COUNTS +# ROWS CONTAINING NULL +# +CREATE TABLE t (a INT, b INT,KEY k(a,b)); +INSERT INTO t VALUES (1,2), +(NULL,3),(3,3),(1,NULL), +(NULL,2), (NULL,NULL); +EXPLAIN SELECT COUNT(DISTINCT a,b) FROM t; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k k 10 NULL # # Using index for group-by (scanning) +Warnings: +Note 1003 /* select#1 */ select count(distinct `test`.`t`.`a`,`test`.`t`.`b`) AS `COUNT(DISTINCT a,b)` from `test`.`t` +SELECT COUNT(DISTINCT a,b) FROM t; +COUNT(DISTINCT a,b) +2 +EXPLAIN SELECT COUNT(DISTINCT a,b) FROM t IGNORE INDEX (k); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL ALL NULL NULL NULL NULL # 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select count(distinct `test`.`t`.`a`,`test`.`t`.`b`) AS `COUNT(DISTINCT a,b)` from `test`.`t` IGNORE INDEX (`k`) +SELECT COUNT(DISTINCT a,b) FROM t IGNORE INDEX (k); +COUNT(DISTINCT a,b) +2 +DROP TABLE t; +# +# Bug#16982071: ASSERT `TAB->KEYS.IS_SET(KEYNO)' FAILED IN +# SETUP_SEMIJOIN_DUPS_ELIMINATION +# +CREATE TABLE t1 ( +pk INTEGER, +col_int INTEGER, +PRIMARY KEY (pk) +); +CREATE TABLE t2 ( +pk INTEGER, +col_varchar_key VARCHAR(1), +PRIMARY KEY (pk), +KEY (col_varchar_key) +) CHARSET utf8mb4; +INSERT INTO t2 VALUES (1, 'g'); +CREATE TABLE t3 ( +pk INTEGER, +col_varchar_key VARCHAR(1), +PRIMARY KEY (pk), +KEY (col_varchar_key) +) CHARSET utf8mb4; +INSERT INTO t3 VALUES (1, 'v'),(2, NULL); +EXPLAIN SELECT t1.col_int +FROM t1, t3 +WHERE t3.col_varchar_key IN ( +SELECT t2.col_varchar_key FROM t2 WHERE t2.pk > t1.col_int +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL # 100.00 NULL +2 SIMPLE t2 NULL index PRIMARY,col_varchar_key col_varchar_key 7 NULL # 100.00 Using where; Using index; LooseScan +2 SIMPLE t3 NULL ref col_varchar_key col_varchar_key 7 test.t2.col_varchar_key # 100.00 Using index +Warnings: +Note 1276 Field or reference 'test.t1.col_int' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`col_int` AS `col_int` from `test`.`t1` join `test`.`t3` semi join (`test`.`t2`) where ((`test`.`t3`.`col_varchar_key` = `test`.`t2`.`col_varchar_key`) and (`test`.`t2`.`pk` > `test`.`t1`.`col_int`)) +SELECT t1.col_int +FROM t1, t3 +WHERE t3.col_varchar_key IN ( +SELECT t2.col_varchar_key FROM t2 WHERE t2.pk > t1.col_int +); +col_int +DROP TABLE t1, t2, t3; +# +# Bug #30659810: INCORRECT QUERY RESULTS +# +CREATE TABLE t1 ( +a INTEGER NOT NULL +); +INSERT INTO t1 VALUES (2),(2); +CREATE TABLE t2 ( +b INTEGER +); +INSERT INTO t2 VALUES (2),(11),(11); +CREATE TABLE t3 ( +b INTEGER, +pk INTEGER, +KEY b_key (b) +); +INSERT INTO t3 VALUES (2,5); +CREATE TABLE t4 ( +pk INTEGER NOT NULL +); +INSERT INTO t4 VALUES (5),(7); +ANALYZE TABLE t1,t2,t3,t4; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +test.t4 analyze status OK +EXPLAIN FORMAT=TREE SELECT * +FROM t1 +JOIN t2 ON t1.a = t2.b +WHERE t2.b IN ( +SELECT t3.b +FROM t3 JOIN t4 ON t3.pk = t4.pk +); +EXPLAIN +-> Parallel scan on + -> Inner hash join (t2.b = t1.a) (cost=2.00 rows=2) + -> Table scan on t2 (cost=0.18 rows=3) + -> Hash + -> Nested loop inner join (cost=1.15 rows=2) + -> PQblock scan on t1 (cost=0.45 rows=2) + -> Nested loop semijoin with duplicate removal on b_key (cost=1.00 rows=1) + -> Index lookup on t3 using b_key (b=t1.a) (cost=0.30 rows=1) + -> Filter: (t4.pk = t3.pk) (cost=0.30 rows=1) + -> Table scan on t4 (cost=0.30 rows=2) + +SELECT * +FROM t1 +JOIN t2 ON t1.a = t2.b +WHERE t2.b IN ( +SELECT t3.b +FROM t3 JOIN t4 ON t3.pk = t4.pk +); +a b +2 2 +2 2 +DROP TABLE t1, t2, t3, t4; diff --git a/mysql-test/r/myisam_explain_json_non_select_all.result-pq b/mysql-test/r/myisam_explain_json_non_select_all.result-pq new file mode 100644 index 000000000000..17a8b536ac94 --- /dev/null +++ b/mysql-test/r/myisam_explain_json_non_select_all.result-pq @@ -0,0 +1,8249 @@ +set optimizer_switch='semijoin=on,materialization=on,firstmatch=on,loosescan=on,index_condition_pushdown=on,mrr=on,mrr_cost_based=off'; +set @save_storage_engine= @@session.default_storage_engine; +set session default_storage_engine = MyISAM; +set end_markers_in_json=on; +#1 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +# +# query: UPDATE t1 SET a = 10 WHERE a < 10 +# select: SELECT * FROM t1 WHERE a < 10 +# +EXPLAIN UPDATE t1 SET a = 10 WHERE a < 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`a` = 10 where (`test`.`t1`.`a` < 10) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t1 SET a = 10 WHERE a < 10;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "table": { + "update": true, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "filtered": "100.00", + "attached_condition": "(`test`.`t1`.`a` < 10)" + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`a` = 10 where (`test`.`t1`.`a` < 10) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 WHERE a < 10;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.80" + } /* cost_info */, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 1, + "filtered": "33.33", + "cost_info": { + "read_cost": "0.70", + "eval_cost": "0.10", + "prefix_cost": "0.80", + "data_read_per_join": "8" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`a` < 10)" + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` < 10) +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 1 +Handler_read_rnd_next 4 +# Status of testing query execution: +Variable_name Value +Handler_read_key 1 +Handler_read_rnd_next 4 +Handler_update 3 + +DROP TABLE t1; +#2 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +# +# query: DELETE FROM t1 WHERE a < 10 +# select: SELECT * FROM t1 WHERE a < 10 +# +EXPLAIN DELETE FROM t1 WHERE a < 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 delete from `test`.`t1` where (`test`.`t1`.`a` < 10) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t1 WHERE a < 10;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "table": { + "delete": true, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "filtered": "100.00", + "attached_condition": "(`test`.`t1`.`a` < 10)" + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 delete from `test`.`t1` where (`test`.`t1`.`a` < 10) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 WHERE a < 10;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.80" + } /* cost_info */, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 1, + "filtered": "33.33", + "cost_info": { + "read_cost": "0.70", + "eval_cost": "0.10", + "prefix_cost": "0.80", + "data_read_per_join": "8" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`a` < 10)" + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` < 10) +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 1 +Handler_read_rnd_next 4 +# Status of testing query execution: +Variable_name Value +Handler_delete 3 +Handler_read_key 1 +Handler_read_rnd_next 4 + +DROP TABLE t1; +#3 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +# +# query: DELETE FROM t1 USING t1 WHERE a = 1 +# select: SELECT * FROM t1 WHERE a = 1 +# +EXPLAIN DELETE FROM t1 USING t1 WHERE a = 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 delete `test`.`t1` from `test`.`t1` where (`test`.`t1`.`a` = 1) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t1 USING t1 WHERE a = 1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.80" + } /* cost_info */, + "table": { + "delete": true, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 1, + "filtered": "33.33", + "cost_info": { + "read_cost": "0.70", + "eval_cost": "0.10", + "prefix_cost": "0.80", + "data_read_per_join": "8" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`a` = 1)" + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 delete `test`.`t1` from `test`.`t1` where (`test`.`t1`.`a` = 1) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 WHERE a = 1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.80" + } /* cost_info */, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 1, + "filtered": "33.33", + "cost_info": { + "read_cost": "0.70", + "eval_cost": "0.10", + "prefix_cost": "0.80", + "data_read_per_join": "8" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`a` = 1)" + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` = 1) +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 1 +Handler_read_rnd_next 4 +# Status of testing query execution: +Variable_name Value +Handler_delete 1 +Handler_read_key 1 +Handler_read_rnd_next 4 + +DROP TABLE t1; +#4 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +CREATE TABLE t2 (b INT); +INSERT INTO t2 VALUES (1), (2), (3); +# +# query: UPDATE t1, t2 SET t1.a = 10 WHERE t1.a = 1 +# select: SELECT * FROM t1, t2 WHERE t1.a = 1 +# +EXPLAIN UPDATE t1, t2 SET t1.a = 10 WHERE t1.a = 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 update `test`.`t1` join `test`.`t2` set `test`.`t1`.`a` = 10 where (`test`.`t1`.`a` = 1) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t1, t2 SET t1.a = 10 WHERE t1.a = 1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.60" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "update": true, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 1, + "filtered": "33.33", + "cost_info": { + "read_cost": "0.70", + "eval_cost": "0.10", + "prefix_cost": "0.80", + "data_read_per_join": "8" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`a` = 1)" + } /* table */ + }, + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.30", + "prefix_cost": "1.60", + "data_read_per_join": "24" + } /* cost_info */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t1` join `test`.`t2` set `test`.`t1`.`a` = 10 where (`test`.`t1`.`a` = 1) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1, t2 WHERE t1.a = 1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.60" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 1, + "filtered": "33.33", + "cost_info": { + "read_cost": "0.70", + "eval_cost": "0.10", + "prefix_cost": "0.80", + "data_read_per_join": "8" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`a` = 1)" + } /* table */ + }, + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.30", + "prefix_cost": "1.60", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "b" + ] /* used_columns */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` join `test`.`t2` where (`test`.`t1`.`a` = 1) +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 8 +# Status of testing query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 8 +Handler_update 1 + +DROP TABLE t1, t2; +#5 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +CREATE TABLE t2 (b INT); +INSERT INTO t2 VALUES (1), (2), (3); +# +# query: UPDATE t1 t11, (SELECT * FROM t2) t12 SET t11.a = 10 WHERE t11.a = 1 +# select: SELECT * FROM t1 t11, (SELECT * FROM t2) t12 WHERE t11.a = 1 +# +EXPLAIN UPDATE t1 t11, (SELECT * FROM t2) t12 SET t11.a = 10 WHERE t11.a = 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t11 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 update `test`.`t1` `t11` join `test`.`t2` set `test`.`t11`.`a` = 10 where (`test`.`t11`.`a` = 1) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t1 t11, (SELECT * FROM t2) t12 SET t11.a = 10 WHERE t11.a = 1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.60" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "update": true, + "table_name": "t11", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 1, + "filtered": "33.33", + "cost_info": { + "read_cost": "0.70", + "eval_cost": "0.10", + "prefix_cost": "0.80", + "data_read_per_join": "8" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t11`.`a` = 1)" + } /* table */ + }, + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.30", + "prefix_cost": "1.60", + "data_read_per_join": "24" + } /* cost_info */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t1` `t11` join `test`.`t2` set `test`.`t11`.`a` = 10 where (`test`.`t11`.`a` = 1) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 t11, (SELECT * FROM t2) t12 WHERE t11.a = 1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.60" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "table_name": "t11", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 1, + "filtered": "33.33", + "cost_info": { + "read_cost": "0.70", + "eval_cost": "0.10", + "prefix_cost": "0.80", + "data_read_per_join": "8" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t11`.`a` = 1)" + } /* table */ + }, + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.30", + "prefix_cost": "1.60", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "b" + ] /* used_columns */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t11`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` `t11` join `test`.`t2` where (`test`.`t11`.`a` = 1) +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 8 +# Status of testing query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 8 +Handler_update 1 + +DROP TABLE t1, t2; +#6 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +CREATE TABLE t2 (b INT); +INSERT INTO t2 VALUES (1), (2), (3); +# +# query: UPDATE t1 SET a = 10 WHERE 1 IN (SELECT 1 FROM t2 WHERE t2.b < 3) +# select: SELECT * FROM t1 WHERE 1 IN (SELECT 1 FROM t2 WHERE t2.b < 3) +# +EXPLAIN UPDATE t1 SET a = 10 WHERE 1 IN (SELECT 1 FROM t2 WHERE t2.b < 3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`a` = 10 where (`test`.`t2`.`b` < 3) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t1 SET a = 10 WHERE 1 IN (SELECT 1 FROM t2 WHERE t2.b < 3);; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.60" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 1, + "filtered": "33.33", + "first_match": true, + "cost_info": { + "read_cost": "0.70", + "eval_cost": "0.10", + "prefix_cost": "0.80", + "data_read_per_join": "8" + } /* cost_info */, + "used_columns": [ + "b" + ] /* used_columns */, + "attached_condition": "(`test`.`t2`.`b` < 3)" + } /* table */ + }, + { + "table": { + "update": true, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.30", + "prefix_cost": "1.60", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`a` = 10 where (`test`.`t2`.`b` < 3) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 WHERE 1 IN (SELECT 1 FROM t2 WHERE t2.b < 3);; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.60" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 1, + "filtered": "33.33", + "first_match": true, + "cost_info": { + "read_cost": "0.70", + "eval_cost": "0.10", + "prefix_cost": "0.80", + "data_read_per_join": "8" + } /* cost_info */, + "used_columns": [ + "b" + ] /* used_columns */, + "attached_condition": "(`test`.`t2`.`b` < 3)" + } /* table */ + }, + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.30", + "prefix_cost": "1.60", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t2`) where (`test`.`t2`.`b` < 3) +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 5 +# Status of testing query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd 3 +Handler_read_rnd_next 9 +Handler_update 3 +Handler_write 3 + +DROP TABLE t1, t2; +#7 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +CREATE TABLE t2 (b INT); +INSERT INTO t2 VALUES (1), (2), (3); +# +# query: UPDATE t1 SET a = 10 WHERE a IN (SELECT b FROM t2 WHERE t1.a < 3) +# select: SELECT * FROM t1 WHERE a IN (SELECT b FROM t2 WHERE t1.a < 3) +# +EXPLAIN UPDATE t1 SET a = 10 WHERE a IN (SELECT b FROM t2 WHERE t1.a < 3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 update `test`.`t1` set `test`.`t1`.`a` = 10 where ((`test`.`t2`.`b` = `test`.`t1`.`a`) and (`test`.`t1`.`a` < 3)) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t1 SET a = 10 WHERE a IN (SELECT b FROM t2 WHERE t1.a < 3);; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.60" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "update": true, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 1, + "filtered": "33.33", + "cost_info": { + "read_cost": "0.70", + "eval_cost": "0.10", + "prefix_cost": "0.80", + "data_read_per_join": "8" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`a` < 3)" + } /* table */ + }, + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 1, + "filtered": "33.33", + "first_match": "t1", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.10", + "prefix_cost": "1.60", + "data_read_per_join": "8" + } /* cost_info */, + "used_columns": [ + "b" + ] /* used_columns */, + "attached_condition": "(`test`.`t2`.`b` = `test`.`t1`.`a`)" + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 update `test`.`t1` set `test`.`t1`.`a` = 10 where ((`test`.`t2`.`b` = `test`.`t1`.`a`) and (`test`.`t1`.`a` < 3)) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 WHERE a IN (SELECT b FROM t2 WHERE t1.a < 3);; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.60" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 1, + "filtered": "33.33", + "cost_info": { + "read_cost": "0.70", + "eval_cost": "0.10", + "prefix_cost": "0.80", + "data_read_per_join": "8" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`a` < 3)" + } /* table */ + }, + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 1, + "filtered": "33.33", + "first_match": "t1", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.10", + "prefix_cost": "1.60", + "data_read_per_join": "8" + } /* cost_info */, + "used_columns": [ + "b" + ] /* used_columns */, + "attached_condition": "(`test`.`t2`.`b` = `test`.`t1`.`a`)" + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`b` = `test`.`t1`.`a`) and (`test`.`t1`.`a` < 3)) +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 8 +# Status of testing query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 7 +Handler_update 2 + +DROP TABLE t1, t2; +#7 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +CREATE TABLE t2 (b INT); +INSERT INTO t2 VALUES (1), (2), (3); +# +# query: UPDATE t1, t2 SET a = 10 WHERE a IN (SELECT b FROM t2 WHERE t2.b < 3) +# select: SELECT * FROM t1, t2 WHERE a IN (SELECT b FROM t2 WHERE t2.b < 3) +# +EXPLAIN UPDATE t1, t2 SET a = 10 WHERE a IN (SELECT b FROM t2 WHERE t2.b < 3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(t1) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 update `test`.`t1` join `test`.`t2` semi join (`test`.`t2`) set `test`.`t1`.`a` = 10 where ((`test`.`t2`.`b` = `test`.`t1`.`a`) and (`test`.`t1`.`a` < 3)) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t1, t2 SET a = 10 WHERE a IN (SELECT b FROM t2 WHERE t2.b < 3);; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "3.20" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "update": true, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.30", + "prefix_cost": "0.80", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`a` < 3)" + } /* table */ + }, + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "33.33", + "first_match": "t1", + "cost_info": { + "read_cost": "0.70", + "eval_cost": "0.30", + "prefix_cost": "1.80", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "b" + ] /* used_columns */, + "attached_condition": "(`test`.`t2`.`b` = `test`.`t1`.`a`)" + } /* table */ + }, + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 9, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.90", + "prefix_cost": "3.20", + "data_read_per_join": "72" + } /* cost_info */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t1` join `test`.`t2` semi join (`test`.`t2`) set `test`.`t1`.`a` = 10 where ((`test`.`t2`.`b` = `test`.`t1`.`a`) and (`test`.`t1`.`a` < 3)) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1, t2 WHERE a IN (SELECT b FROM t2 WHERE t2.b < 3);; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "3.20" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.30", + "prefix_cost": "0.80", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`a` < 3)" + } /* table */ + }, + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "33.33", + "first_match": "t1", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.70", + "eval_cost": "0.30", + "prefix_cost": "1.80", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "b" + ] /* used_columns */, + "attached_condition": "(`test`.`t2`.`b` = `test`.`t1`.`a`)" + } /* table */ + }, + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 9, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.90", + "prefix_cost": "3.20", + "data_read_per_join": "72" + } /* cost_info */, + "used_columns": [ + "b" + ] /* used_columns */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` join `test`.`t2` semi join (`test`.`t2`) where ((`test`.`t2`.`b` = `test`.`t1`.`a`) and (`test`.`t1`.`a` < 3)) +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 12 +# Status of testing query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 15 +Handler_update 2 + +DROP TABLE t1, t2; +#8 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +CREATE TABLE t2 (b INT); +INSERT INTO t2 VALUES (1), (2), (3); +# +# query: UPDATE t1 t11, (SELECT * FROM t2) t12 SET t11.a = t11.a + 10 +# select: SELECT * FROM t1 t11, (SELECT * FROM t2) t12 +# +EXPLAIN UPDATE t1 t11, (SELECT * FROM t2) t12 SET t11.a = t11.a + 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t11 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 update `test`.`t1` `t11` join `test`.`t2` set `test`.`t11`.`a` = (`test`.`t11`.`a` + 10) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t1 t11, (SELECT * FROM t2) t12 SET t11.a = t11.a + 10;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "2.20" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "update": true, + "table_name": "t11", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.30", + "prefix_cost": "0.80", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */ + } /* table */ + }, + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 9, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.90", + "prefix_cost": "2.20", + "data_read_per_join": "72" + } /* cost_info */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t1` `t11` join `test`.`t2` set `test`.`t11`.`a` = (`test`.`t11`.`a` + 10) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 t11, (SELECT * FROM t2) t12;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "2.20" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "table_name": "t11", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.30", + "prefix_cost": "0.80", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */ + } /* table */ + }, + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 9, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.90", + "prefix_cost": "2.20", + "data_read_per_join": "72" + } /* cost_info */, + "used_columns": [ + "b" + ] /* used_columns */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t11`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` `t11` join `test`.`t2` +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 8 +# Status of testing query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 16 +Handler_update 3 + +DROP TABLE t1, t2; +#9 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +CREATE TABLE t2 (b INT); +INSERT INTO t2 VALUES (1), (2), (3); +# +# query: UPDATE t1 t11, (SELECT 1 FROM DUAL) t12 SET t11.a = t11.a + 10 +# select: SELECT * FROM t1 t11, (SELECT 1 FROM DUAL) t12 +# +EXPLAIN UPDATE t1 t11, (SELECT 1 FROM DUAL) t12 SET t11.a = t11.a + 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL system NULL NULL NULL NULL 1 100.00 NULL +1 UPDATE t11 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 update `test`.`t1` `t11` join (/* select#2 */ select 1 AS `1`) `t12` set `test`.`t11`.`a` = (`test`.`t11`.`a` + 10) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t1 t11, (SELECT 1 FROM DUAL) t12 SET t11.a = t11.a + 10;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.80" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "table_name": "t12", + "access_type": "system", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.00", + "eval_cost": "0.10", + "prefix_cost": "0.00", + "data_read_per_join": "16" + } /* cost_info */, + "used_columns": [ + "1" + ] /* used_columns */, + "materialized_from_subquery": { + "using_temporary_table": true, + "dependent": false, + "cacheable": true, + "query_block": { + "select_id": 2, + "message": "No tables used" + } /* query_block */ + } /* materialized_from_subquery */ + } /* table */ + }, + { + "table": { + "update": true, + "table_name": "t11", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.30", + "prefix_cost": "0.80", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t1` `t11` join (/* select#2 */ select 1 AS `1`) `t12` set `test`.`t11`.`a` = (`test`.`t11`.`a` + 10) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 t11, (SELECT 1 FROM DUAL) t12;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.80" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "table_name": "t12", + "access_type": "system", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.00", + "eval_cost": "0.10", + "prefix_cost": "0.00", + "data_read_per_join": "16" + } /* cost_info */, + "used_columns": [ + "1" + ] /* used_columns */, + "materialized_from_subquery": { + "using_temporary_table": true, + "dependent": false, + "cacheable": true, + "query_block": { + "select_id": 2, + "message": "No tables used" + } /* query_block */ + } /* materialized_from_subquery */ + } /* table */ + }, + { + "table": { + "table_name": "t11", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.30", + "prefix_cost": "0.80", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t11`.`a` AS `a`,'1' AS `1` from `test`.`t1` `t11` +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 1 +Handler_read_rnd_next 5 +Handler_write 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 1 +Handler_read_rnd 3 +Handler_read_rnd_next 9 +Handler_update 3 +Handler_write 4 + +DROP TABLE t1, t2; +#10 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +CREATE TABLE t2 (b INT); +INSERT INTO t2 VALUES (1), (2), (3); +# +# query: UPDATE t1 t11, (SELECT * FROM t2) t12 SET t11.a = 10 WHERE t11.a > 1 +# select: SELECT * FROM t1 t11, (SELECT * FROM t2) t12 WHERE t11.a > 1 +# +EXPLAIN UPDATE t1 t11, (SELECT * FROM t2) t12 SET t11.a = 10 WHERE t11.a > 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t11 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 update `test`.`t1` `t11` join `test`.`t2` set `test`.`t11`.`a` = 10 where (`test`.`t11`.`a` > 1) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t1 t11, (SELECT * FROM t2) t12 SET t11.a = 10 WHERE t11.a > 1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.60" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "update": true, + "table_name": "t11", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 1, + "filtered": "33.33", + "cost_info": { + "read_cost": "0.70", + "eval_cost": "0.10", + "prefix_cost": "0.80", + "data_read_per_join": "8" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t11`.`a` > 1)" + } /* table */ + }, + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.30", + "prefix_cost": "1.60", + "data_read_per_join": "24" + } /* cost_info */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t1` `t11` join `test`.`t2` set `test`.`t11`.`a` = 10 where (`test`.`t11`.`a` > 1) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 t11, (SELECT * FROM t2) t12 WHERE t11.a > 1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.60" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "table_name": "t11", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 1, + "filtered": "33.33", + "cost_info": { + "read_cost": "0.70", + "eval_cost": "0.10", + "prefix_cost": "0.80", + "data_read_per_join": "8" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t11`.`a` > 1)" + } /* table */ + }, + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.30", + "prefix_cost": "1.60", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "b" + ] /* used_columns */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t11`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` `t11` join `test`.`t2` where (`test`.`t11`.`a` > 1) +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 8 +# Status of testing query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 12 +Handler_update 2 + +DROP TABLE t1, t2; +#11 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +# +# query: DELETE FROM t1 WHERE a > 1 LIMIT 1 +# select: SELECT * FROM t1 WHERE a > 1 LIMIT 1 +# +EXPLAIN DELETE FROM t1 WHERE a > 1 LIMIT 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 delete from `test`.`t1` where (`test`.`t1`.`a` > 1) limit 1 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t1 WHERE a > 1 LIMIT 1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "table": { + "delete": true, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "filtered": "100.00", + "attached_condition": "(`test`.`t1`.`a` > 1)" + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 delete from `test`.`t1` where (`test`.`t1`.`a` > 1) limit 1 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 WHERE a > 1 LIMIT 1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.80" + } /* cost_info */, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 1, + "filtered": "33.33", + "cost_info": { + "read_cost": "0.70", + "eval_cost": "0.10", + "prefix_cost": "0.80", + "data_read_per_join": "8" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`a` > 1)" + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` > 1) limit 1 +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 1 +Handler_read_rnd_next 2 +# Status of testing query execution: +Variable_name Value +Handler_delete 1 +Handler_read_key 1 +Handler_read_rnd_next 2 + +DROP TABLE t1; +#12 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +# +# query: DELETE FROM t1 WHERE 0 +# select: SELECT * FROM t1 WHERE 0 +# +EXPLAIN DELETE FROM t1 WHERE 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 delete from `test`.`t1` where false +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t1 WHERE 0;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "message": "Impossible WHERE" + } /* query_block */ +} +Warnings: +Note 1003 delete from `test`.`t1` where false +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 WHERE 0;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "message": "Impossible WHERE" + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where false +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 1 + +DROP TABLE t1; +#13 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +# +# query: DELETE FROM t1 USING t1 WHERE 0 +# select: SELECT * FROM t1 WHERE 0 +# +EXPLAIN DELETE FROM t1 USING t1 WHERE 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 delete `test`.`t1` from `test`.`t1` where false +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t1 USING t1 WHERE 0;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "message": "Impossible WHERE" + } /* query_block */ +} +Warnings: +Note 1003 delete `test`.`t1` from `test`.`t1` where false +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 WHERE 0;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "message": "Impossible WHERE" + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where false +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 1 + +DROP TABLE t1; +#14 +CREATE TABLE t1 (a INT, b INT, UNIQUE KEY (a), KEY (b)); +INSERT INTO t1 VALUES (3, 3), (7, 7); +# +# query: DELETE FROM t1 WHERE a = 3 +# select: SELECT * FROM t1 WHERE a = 3 +# +EXPLAIN DELETE FROM t1 WHERE a = 3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL range a a 5 const 1 100.00 Using where +Warnings: +Note 1003 delete from `test`.`t1` where (`test`.`t1`.`a` = 3) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t1 WHERE a = 3;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "table": { + "delete": true, + "table_name": "t1", + "access_type": "range", + "possible_keys": [ + "a" + ] /* possible_keys */, + "key": "a", + "used_key_parts": [ + "a" + ] /* used_key_parts */, + "key_length": "5", + "ref": [ + "const" + ] /* ref */, + "rows_examined_per_scan": 1, + "filtered": "100.00", + "attached_condition": "(`test`.`t1`.`a` = 3)" + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 delete from `test`.`t1` where (`test`.`t1`.`a` = 3) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 WHERE a = 3;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.00" + } /* cost_info */, + "table": { + "table_name": "t1", + "access_type": "const", + "possible_keys": [ + "a" + ] /* possible_keys */, + "key": "a", + "used_key_parts": [ + "a" + ] /* used_key_parts */, + "key_length": "5", + "ref": [ + "const" + ] /* ref */, + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.00", + "eval_cost": "0.10", + "prefix_cost": "0.00", + "data_read_per_join": "16" + } /* cost_info */, + "used_columns": [ + "a", + "b" + ] /* used_columns */ + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select '3' AS `a`,'3' AS `b` from `test`.`t1` where true +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 3 +# Status of testing query execution: +Variable_name Value +Handler_delete 1 +Handler_read_key 3 + +DROP TABLE t1; +#15 +CREATE TABLE t1 (a INT, b INT, UNIQUE KEY (a), KEY (b)); +INSERT INTO t1 VALUES (3, 3), (7, 7); +# +# query: DELETE FROM t1 WHERE a < 3 +# select: SELECT * FROM t1 WHERE a < 3 +# +EXPLAIN DELETE FROM t1 WHERE a < 3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL range a a 5 const 1 100.00 Using where +Warnings: +Note 1003 delete from `test`.`t1` where (`test`.`t1`.`a` < 3) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t1 WHERE a < 3;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "table": { + "delete": true, + "table_name": "t1", + "access_type": "range", + "possible_keys": [ + "a" + ] /* possible_keys */, + "key": "a", + "used_key_parts": [ + "a" + ] /* used_key_parts */, + "key_length": "5", + "ref": [ + "const" + ] /* ref */, + "rows_examined_per_scan": 1, + "filtered": "100.00", + "attached_condition": "(`test`.`t1`.`a` < 3)" + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 delete from `test`.`t1` where (`test`.`t1`.`a` < 3) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 WHERE a < 3;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.70" + } /* cost_info */, + "table": { + "table_name": "t1", + "access_type": "range", + "possible_keys": [ + "a" + ] /* possible_keys */, + "key": "a", + "used_key_parts": [ + "a" + ] /* used_key_parts */, + "key_length": "5", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "index_condition": "(`test`.`t1`.`a` < 3)", + "using_MRR": true, + "cost_info": { + "read_cost": "0.60", + "eval_cost": "0.10", + "prefix_cost": "0.70", + "data_read_per_join": "16" + } /* cost_info */, + "used_columns": [ + "a", + "b" + ] /* used_columns */ + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (`test`.`t1`.`a` < 3) +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 3 +# Status of testing query execution: +Variable_name Value +Handler_read_key 3 + +DROP TABLE t1; +#16 +CREATE TABLE t1 ( a int PRIMARY KEY ); +# +# query: DELETE FROM t1 WHERE t1.a > 0 ORDER BY t1.a +# select: SELECT * FROM t1 WHERE t1.a > 0 ORDER BY t1.a +# +EXPLAIN DELETE FROM t1 WHERE t1.a > 0 ORDER BY t1.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL range PRIMARY PRIMARY 4 const 1 100.00 Using where +Warnings: +Note 1003 delete from `test`.`t1` where (`test`.`t1`.`a` > 0) order by `test`.`t1`.`a` +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t1 WHERE t1.a > 0 ORDER BY t1.a;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_filesort": false, + "table": { + "delete": true, + "table_name": "t1", + "access_type": "range", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "a" + ] /* used_key_parts */, + "key_length": "4", + "ref": [ + "const" + ] /* ref */, + "rows_examined_per_scan": 1, + "filtered": "100.00", + "attached_condition": "(`test`.`t1`.`a` > 0)" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 delete from `test`.`t1` where (`test`.`t1`.`a` > 0) order by `test`.`t1`.`a` +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 WHERE t1.a > 0 ORDER BY t1.a;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "message": "no matching row in const table" + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select NULL AS `a` from `test`.`t1` where (NULL > 0) order by NULL +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 1 +Handler_read_rnd_next 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 2 + +INSERT INTO t1 VALUES (1), (2), (3); +# +# query: DELETE FROM t1 WHERE t1.a > 0 ORDER BY t1.a +# select: SELECT * FROM t1 WHERE t1.a > 0 ORDER BY t1.a +# +EXPLAIN DELETE FROM t1 WHERE t1.a > 0 ORDER BY t1.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL range PRIMARY PRIMARY 4 const 3 100.00 Using where +Warnings: +Note 1003 delete from `test`.`t1` where (`test`.`t1`.`a` > 0) order by `test`.`t1`.`a` +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t1 WHERE t1.a > 0 ORDER BY t1.a;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_filesort": false, + "table": { + "delete": true, + "table_name": "t1", + "access_type": "range", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "a" + ] /* used_key_parts */, + "key_length": "4", + "ref": [ + "const" + ] /* ref */, + "rows_examined_per_scan": 3, + "filtered": "100.00", + "attached_condition": "(`test`.`t1`.`a` > 0)" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 delete from `test`.`t1` where (`test`.`t1`.`a` > 0) order by `test`.`t1`.`a` +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 WHERE t1.a > 0 ORDER BY t1.a;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.80" + } /* cost_info */, + "ordering_operation": { + "using_filesort": false, + "table": { + "table_name": "t1", + "access_type": "index", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "a" + ] /* used_key_parts */, + "key_length": "4", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "using_index": true, + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.30", + "prefix_cost": "0.80", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`a` > 0)" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` > 0) order by `test`.`t1`.`a` +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 1 +Handler_read_next 3 +# Status of testing query execution: +Variable_name Value +Handler_delete 3 +Handler_read_key 2 +Handler_read_next 3 + +DROP TABLE t1; +#17 +CREATE TABLE t1(a INT PRIMARY KEY); +INSERT INTO t1 VALUES (4),(3),(1),(2); +# +# query: DELETE FROM t1 WHERE (@a:= a) ORDER BY a LIMIT 1 +# select: SELECT * FROM t1 WHERE (@a:= a) ORDER BY a LIMIT 1 +# +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +EXPLAIN DELETE FROM t1 WHERE (@a:= a) ORDER BY a LIMIT 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL index NULL PRIMARY 4 NULL 4 100.00 Using where +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +Note 1003 delete from `test`.`t1` where (0 <> (@a:=`test`.`t1`.`a`)) order by `test`.`t1`.`a` limit 1 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t1 WHERE (@a:= a) ORDER BY a LIMIT 1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_filesort": false, + "table": { + "delete": true, + "table_name": "t1", + "access_type": "index", + "key": "PRIMARY", + "used_key_parts": [ + "a" + ] /* used_key_parts */, + "key_length": "4", + "rows_examined_per_scan": 4, + "filtered": "100.00", + "attached_condition": "(0 <> (@a:=`test`.`t1`.`a`))" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +Note 1003 delete from `test`.`t1` where (0 <> (@a:=`test`.`t1`.`a`)) order by `test`.`t1`.`a` limit 1 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 WHERE (@a:= a) ORDER BY a LIMIT 1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.90" + } /* cost_info */, + "ordering_operation": { + "using_filesort": false, + "table": { + "table_name": "t1", + "access_type": "index", + "key": "PRIMARY", + "used_key_parts": [ + "a" + ] /* used_key_parts */, + "key_length": "4", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 4, + "filtered": "100.00", + "using_index": true, + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.40", + "prefix_cost": "0.90", + "data_read_per_join": "32" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(0 <> (@a:=`test`.`t1`.`a`))" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (0 <> (@a:=`test`.`t1`.`a`)) order by `test`.`t1`.`a` limit 1 +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 1 +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +# Status of testing query execution: +Variable_name Value +Handler_delete 1 +Handler_read_first 1 +Handler_read_key 1 + +DROP TABLE t1; +#18 +CREATE TABLE t1 (a DATE, b TIME, c INT, KEY c(c), KEY b(b), KEY a(a)); +INSERT INTO t1 VALUES (), (), (), (), (), (), (), (), (), (); +UPDATE t1 SET a = c, b = c; +# +# query: DELETE FROM t1 ORDER BY a ASC, b ASC LIMIT 1 +# select: SELECT * FROM t1 ORDER BY a ASC, b ASC LIMIT 1 +# +EXPLAIN DELETE FROM t1 ORDER BY a ASC, b ASC LIMIT 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 10 100.00 Using filesort +Warnings: +Note 1003 delete from `test`.`t1` order by `test`.`t1`.`a`,`test`.`t1`.`b` limit 1 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t1 ORDER BY a ASC, b ASC LIMIT 1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_filesort": true, + "table": { + "delete": true, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 10, + "filtered": "100.00" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 delete from `test`.`t1` order by `test`.`t1`.`a`,`test`.`t1`.`b` limit 1 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 ORDER BY a ASC, b ASC LIMIT 1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.51" + } /* cost_info */, + "ordering_operation": { + "using_filesort": true, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 10, + "rows_produced_per_join": 10, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "1.00", + "prefix_cost": "1.51", + "data_read_per_join": "160" + } /* cost_info */, + "used_columns": [ + "a", + "b", + "c" + ] /* used_columns */ + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` order by `test`.`t1`.`a`,`test`.`t1`.`b` limit 1 +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 3 +Handler_read_rnd_next 11 +Sort_rows 1 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_delete 1 +Handler_read_key 3 +Handler_read_rnd 1 +Handler_read_rnd_next 11 +Sort_rows 10 +Sort_scan 1 + +DROP TABLE t1; +#19 +CREATE TABLE t1 (a1 INT NOT NULL, b1 INT NOT NULL); +CREATE TABLE t2 (a2 INT NOT NULL, b2 INT NOT NULL, PRIMARY KEY (a2,b2)); +CREATE TABLE t3 (a3 INT NOT NULL, b3 INT NOT NULL, PRIMARY KEY (a3,b3)); +INSERT INTO t1 VALUES (1,1), (2,1), (1,3); +INSERT INTO t2 VALUES (1,1), (2,2), (3,3); +INSERT INTO t3 VALUES (1,1), (2,1), (1,3); +# +# query: DELETE t1,t2,t3 FROM t1,t2,t3 WHERE a1=a2 AND b2=a3 AND b1=b3 +# select: SELECT * FROM t1,t2,t3 WHERE a1=a2 AND b2=a3 AND b1=b3 +# +EXPLAIN DELETE t1,t2,t3 FROM t1,t2,t3 WHERE a1=a2 AND b2=a3 AND b1=b3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 DELETE t2 NULL ref PRIMARY PRIMARY 4 test.t1.a1 1 100.00 NULL +1 DELETE t3 NULL eq_ref PRIMARY PRIMARY 8 test.t2.b2,test.t1.b1 1 100.00 NULL +Warnings: +Note 1003 delete `test`.`t1`, `test`.`t2`, `test`.`t3` from `test`.`t1` join `test`.`t2` join `test`.`t3` where ((`test`.`t3`.`b3` = `test`.`t1`.`b1`) and (`test`.`t3`.`a3` = `test`.`t2`.`b2`) and (`test`.`t2`.`a2` = `test`.`t1`.`a1`)) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE t1,t2,t3 FROM t1,t2,t3 WHERE a1=a2 AND b2=a3 AND b1=b3;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "2.90" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "delete": true, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.30", + "prefix_cost": "0.80", + "data_read_per_join": "48" + } /* cost_info */, + "used_columns": [ + "a1", + "b1" + ] /* used_columns */ + } /* table */ + }, + { + "table": { + "delete": true, + "table_name": "t2", + "access_type": "ref", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "a2" + ] /* used_key_parts */, + "key_length": "4", + "ref": [ + "test.t1.a1" + ] /* ref */, + "rows_examined_per_scan": 1, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.75", + "eval_cost": "0.30", + "prefix_cost": "1.85", + "data_read_per_join": "48" + } /* cost_info */, + "used_columns": [ + "a2", + "b2" + ] /* used_columns */ + } /* table */ + }, + { + "table": { + "delete": true, + "table_name": "t3", + "access_type": "eq_ref", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "a3", + "b3" + ] /* used_key_parts */, + "key_length": "8", + "ref": [ + "test.t2.b2", + "test.t1.b1" + ] /* ref */, + "rows_examined_per_scan": 1, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.75", + "eval_cost": "0.30", + "prefix_cost": "2.90", + "data_read_per_join": "48" + } /* cost_info */, + "used_columns": [ + "a3", + "b3" + ] /* used_columns */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 delete `test`.`t1`, `test`.`t2`, `test`.`t3` from `test`.`t1` join `test`.`t2` join `test`.`t3` where ((`test`.`t3`.`b3` = `test`.`t1`.`b1`) and (`test`.`t3`.`a3` = `test`.`t2`.`b2`) and (`test`.`t2`.`a2` = `test`.`t1`.`a1`)) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1,t2,t3 WHERE a1=a2 AND b2=a3 AND b1=b3;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "2.90" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.30", + "prefix_cost": "0.80", + "data_read_per_join": "48" + } /* cost_info */, + "used_columns": [ + "a1", + "b1" + ] /* used_columns */ + } /* table */ + }, + { + "table": { + "table_name": "t2", + "access_type": "ref", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "a2" + ] /* used_key_parts */, + "key_length": "4", + "ref": [ + "test.t1.a1" + ] /* ref */, + "rows_examined_per_scan": 1, + "rows_produced_per_join": 3, + "filtered": "100.00", + "using_index": true, + "cost_info": { + "read_cost": "0.75", + "eval_cost": "0.30", + "prefix_cost": "1.85", + "data_read_per_join": "48" + } /* cost_info */, + "used_columns": [ + "a2", + "b2" + ] /* used_columns */ + } /* table */ + }, + { + "table": { + "table_name": "t3", + "access_type": "eq_ref", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "a3", + "b3" + ] /* used_key_parts */, + "key_length": "8", + "ref": [ + "test.t2.b2", + "test.t1.b1" + ] /* ref */, + "rows_examined_per_scan": 1, + "rows_produced_per_join": 3, + "filtered": "100.00", + "using_index": true, + "cost_info": { + "read_cost": "0.75", + "eval_cost": "0.30", + "prefix_cost": "2.90", + "data_read_per_join": "48" + } /* cost_info */, + "used_columns": [ + "a3", + "b3" + ] /* used_columns */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`b1` AS `b1`,`test`.`t2`.`a2` AS `a2`,`test`.`t2`.`b2` AS `b2`,`test`.`t3`.`a3` AS `a3`,`test`.`t3`.`b3` AS `b3` from `test`.`t1` join `test`.`t2` join `test`.`t3` where ((`test`.`t3`.`b3` = `test`.`t1`.`b1`) and (`test`.`t3`.`a3` = `test`.`t2`.`b2`) and (`test`.`t2`.`a2` = `test`.`t1`.`a1`)) +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 12 +Handler_read_next 3 +Handler_read_rnd_next 4 +# Status of testing query execution: +Variable_name Value +Handler_delete 8 +Handler_read_key 12 +Handler_read_next 3 +Handler_read_rnd 5 +Handler_read_rnd_next 4 + +DROP TABLE t1, t2, t3; +#20 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +CREATE TABLE t2 (a INT); +INSERT INTO t2 VALUES (1), (2), (3); +# +# query: UPDATE t1 SET a = 10 WHERE a IN (SELECT a FROM t2) +# select: SELECT * FROM t1 WHERE a IN (SELECT a FROM t2) +# +EXPLAIN UPDATE t1 SET a = 10 WHERE a IN (SELECT a FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(t1) +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`a` = 10 where (`test`.`t2`.`a` = `test`.`t1`.`a`) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t1 SET a = 10 WHERE a IN (SELECT a FROM t2);; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "2.20" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "update": true, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.30", + "prefix_cost": "0.80", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */ + } /* table */ + }, + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "33.33", + "first_match": "t1", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.30", + "prefix_cost": "2.20", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t2`.`a` = `test`.`t1`.`a`)" + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`a` = 10 where (`test`.`t2`.`a` = `test`.`t1`.`a`) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 WHERE a IN (SELECT a FROM t2);; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "2.20" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.30", + "prefix_cost": "0.80", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */ + } /* table */ + }, + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "33.33", + "first_match": "t1", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.30", + "prefix_cost": "2.20", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t2`.`a` = `test`.`t1`.`a`)" + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t2`) where (`test`.`t2`.`a` = `test`.`t1`.`a`) +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 8 +# Status of testing query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 10 +Handler_update 3 + +DROP TABLE t1, t2; +#21 +CREATE TABLE t1 (a1 INT); +INSERT INTO t1 VALUES (1), (2), (3), (4), (5); +CREATE TABLE t2 (a2 VARCHAR(10)) charset utf8mb4; +INSERT INTO t2 VALUES (1), (2), (3), (4), (5); +SET @save_optimizer_switch= @@optimizer_switch; +# +# query: DELETE FROM t1 WHERE a1 IN (SELECT a2 FROM t2 WHERE a2 > 2) +# select: SELECT * FROM t1 WHERE a1 IN (SELECT a2 FROM t2 WHERE a2 > 2) +# +EXPLAIN DELETE FROM t1 WHERE a1 IN (SELECT a2 FROM t2 WHERE a2 > 2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 5 100.00 Using where +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 5 20.00 Using where +Warnings: +Note 1003 delete from `test`.`t1` where (`test`.`t1`.`a1`,(/* select#2 */ select `test`.`t2`.`a2` from `test`.`t2` where ((`test`.`t2`.`a2` > 2) and ((`test`.`t1`.`a1`) = `test`.`t2`.`a2`)))) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t1 WHERE a1 IN (SELECT a2 FROM t2 WHERE a2 > 2);; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.00" + } /* cost_info */, + "table": { + "delete": true, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.50", + "prefix_cost": "1.00", + "data_read_per_join": "40" + } /* cost_info */, + "used_columns": [ + "a1" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`a1`,(/* select#2 */ select `test`.`t2`.`a2` from `test`.`t2` where ((`test`.`t2`.`a2` > 2) and ((`test`.`t1`.`a1`) = `test`.`t2`.`a2`))))", + "attached_subqueries": [ + { + "dependent": true, + "cacheable": false, + "query_block": { + "select_id": 2, + "cost_info": { + "query_cost": "1.01" + } /* cost_info */, + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 1, + "filtered": "20.00", + "cost_info": { + "read_cost": "0.84", + "eval_cost": "0.10", + "prefix_cost": "1.01", + "data_read_per_join": "48" + } /* cost_info */, + "used_columns": [ + "a2" + ] /* used_columns */, + "attached_condition": "((`test`.`t2`.`a2` > 2) and ((`test`.`t1`.`a1`) = `test`.`t2`.`a2`))" + } /* table */ + } /* query_block */ + } + ] /* attached_subqueries */ + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 delete from `test`.`t1` where (`test`.`t1`.`a1`,(/* select#2 */ select `test`.`t2`.`a2` from `test`.`t2` where ((`test`.`t2`.`a2` > 2) and ((`test`.`t1`.`a1`) = `test`.`t2`.`a2`)))) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 WHERE a1 IN (SELECT a2 FROM t2 WHERE a2 > 2);; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.00" + } /* cost_info */, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.50", + "prefix_cost": "1.00", + "data_read_per_join": "40" + } /* cost_info */, + "used_columns": [ + "a1" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`a1`,(/* select#2 */ select `test`.`t2`.`a2` from `test`.`t2` where ((`test`.`t2`.`a2` > 2) and ((`test`.`t1`.`a1`) = `test`.`t2`.`a2`))))", + "attached_subqueries": [ + { + "dependent": true, + "cacheable": false, + "query_block": { + "select_id": 2, + "cost_info": { + "query_cost": "1.01" + } /* cost_info */, + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 1, + "filtered": "20.00", + "cost_info": { + "read_cost": "0.84", + "eval_cost": "0.10", + "prefix_cost": "1.01", + "data_read_per_join": "48" + } /* cost_info */, + "used_columns": [ + "a2" + ] /* used_columns */, + "attached_condition": "((`test`.`t2`.`a2` > 2) and ((`test`.`t1`.`a1`) = `test`.`t2`.`a2`))" + } /* table */ + } /* query_block */ + } + ] /* attached_subqueries */ + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1` from `test`.`t1` where (`test`.`t1`.`a1`,(/* select#2 */ select `test`.`t2`.`a2` from `test`.`t2` where ((`test`.`t2`.`a2` > 2) and ((`test`.`t1`.`a1`) = `test`.`t2`.`a2`)))) +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 30 +# Status of testing query execution: +Variable_name Value +Handler_delete 3 +Handler_read_key 2 +Handler_read_rnd_next 30 + +SET @@optimizer_switch= @save_optimizer_switch; +TRUNCATE t1; +INSERT INTO t1 VALUES (1), (2), (3), (4), (5); +# +# query: DELETE FROM t1 WHERE a1 IN (SELECT a2 FROM t2 WHERE a2 > 2) +# select: SELECT * FROM t1 WHERE a1 IN (SELECT a2 FROM t2 WHERE a2 > 2) +# +EXPLAIN DELETE FROM t1 WHERE a1 IN (SELECT a2 FROM t2 WHERE a2 > 2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 5 20.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 delete from `test`.`t1` where ((`test`.`t2`.`a2` > 2) and (cast(`test`.`t1`.`a1` as double) = cast(`test`.`t2`.`a2` as double))) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t1 WHERE a1 IN (SELECT a2 FROM t2 WHERE a2 > 2);; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "2.67" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "delete": true, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.50", + "prefix_cost": "1.00", + "data_read_per_join": "40" + } /* cost_info */, + "used_columns": [ + "a1" + ] /* used_columns */ + } /* table */ + }, + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "20.00", + "first_match": "t1", + "cost_info": { + "read_cost": "0.84", + "eval_cost": "0.50", + "prefix_cost": "2.67", + "data_read_per_join": "240" + } /* cost_info */, + "used_columns": [ + "a2" + ] /* used_columns */, + "attached_condition": "((`test`.`t2`.`a2` > 2) and (cast(`test`.`t1`.`a1` as double) = cast(`test`.`t2`.`a2` as double)))" + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 delete from `test`.`t1` where ((`test`.`t2`.`a2` > 2) and (cast(`test`.`t1`.`a1` as double) = cast(`test`.`t2`.`a2` as double))) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 WHERE a1 IN (SELECT a2 FROM t2 WHERE a2 > 2);; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "2.67" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.50", + "prefix_cost": "1.00", + "data_read_per_join": "40" + } /* cost_info */, + "used_columns": [ + "a1" + ] /* used_columns */ + } /* table */ + }, + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "20.00", + "first_match": "t1", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.84", + "eval_cost": "0.50", + "prefix_cost": "2.67", + "data_read_per_join": "240" + } /* cost_info */, + "used_columns": [ + "a2" + ] /* used_columns */, + "attached_condition": "((`test`.`t2`.`a2` > 2) and (cast(`test`.`t1`.`a1` as double) = cast(`test`.`t2`.`a2` as double)))" + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`a2` > 2) and (cast(`test`.`t1`.`a1` as double) = cast(`test`.`t2`.`a2` as double))) +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 12 +# Status of testing query execution: +Variable_name Value +Handler_delete 3 +Handler_read_key 2 +Handler_read_rnd_next 30 + +DROP TABLE t1, t2; +#22 +CREATE TABLE t1 (i INT, j INT); +INSERT INTO t1 VALUES (1, 1), (2, 2), (3, 3), (4, 4), (5, 5); +# +# query: UPDATE t1 SET i = 10 +# select: SELECT * FROM t1 +# +EXPLAIN UPDATE t1 SET i = 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`i` = 10 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t1 SET i = 10;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "table": { + "update": true, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "filtered": "100.00" + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`i` = 10 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.00" + } /* cost_info */, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.50", + "prefix_cost": "1.00", + "data_read_per_join": "80" + } /* cost_info */, + "used_columns": [ + "i", + "j" + ] /* used_columns */ + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i`,`test`.`t1`.`j` AS `j` from `test`.`t1` +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 6 +# Status of testing query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 6 +Handler_update 5 + +DROP TABLE t1; +#23 +CREATE TABLE t1 (i INT, j INT); +INSERT INTO t1 VALUES (1, 1), (2, 2), (3, 3), (4, 4), (5, 5); +# +# query: DELETE FROM t1 +# select: SELECT * FROM t1 +# +EXPLAIN DELETE FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 5 100.00 Deleting all rows +Warnings: +Note 1003 delete from `test`.`t1` +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "table": { + "delete": true, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "filtered": "100.00", + "message": "Deleting all rows" + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 delete from `test`.`t1` +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.00" + } /* cost_info */, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.50", + "prefix_cost": "1.00", + "data_read_per_join": "80" + } /* cost_info */, + "used_columns": [ + "i", + "j" + ] /* used_columns */ + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i`,`test`.`t1`.`j` AS `j` from `test`.`t1` +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 6 +# Status of testing query execution: +Variable_name Value +Handler_read_key 2 + +DROP TABLE t1; +#24 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2(a INT, b INT, c INT, d INT, INDEX(a, b, c)); +INSERT INTO t2 (a, b, c) SELECT i, i, i FROM t1; +INSERT INTO t2 (a, b, c) SELECT t1.i, t1.i, t1.i FROM t1, t1 x1, t1 x2; +# +# query: DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# select: SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# +EXPLAIN DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t2 NULL index NULL a 15 NULL 17602 100.00 Using where +Warnings: +Note 1003 delete from `test`.`t2` where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_filesort": false, + "table": { + "delete": true, + "table_name": "t2", + "access_type": "index", + "key": "a", + "used_key_parts": [ + "a", + "b", + "c" + ] /* used_key_parts */, + "key_length": "15", + "rows_examined_per_scan": 17602, + "filtered": "100.00", + "attached_condition": "(`test`.`t2`.`b` = 10)" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 delete from `test`.`t2` where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1778.96" + } /* cost_info */, + "ordering_operation": { + "using_filesort": false, + "table": { + "table_name": "t2", + "access_type": "index", + "key": "a", + "used_key_parts": [ + "a", + "b", + "c" + ] /* used_key_parts */, + "key_length": "15", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 1760, + "filtered": "10.00", + "cost_info": { + "read_cost": "1602.94", + "eval_cost": "176.02", + "prefix_cost": "1778.96", + "data_read_per_join": "41K" + } /* cost_info */, + "used_columns": [ + "a", + "b", + "c", + "d" + ] /* used_columns */, + "attached_condition": "(`test`.`t2`.`b` = 10)" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c`,`test`.`t2`.`d` AS `d` from `test`.`t2` where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 4 +Handler_read_next 4 +# Status of testing query execution: +Variable_name Value +Handler_delete 5 +Handler_read_first 1 +Handler_read_key 4 +Handler_read_next 4 + +DROP TABLE t1, t2; +#25 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (1), (2), (3); +CREATE TABLE t2 (i INT); +# +# query: INSERT INTO t2 SELECT * FROM t1 +# select: SELECT * FROM t1 +# +EXPLAIN INSERT INTO t2 SELECT * FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 INSERT t2 NULL ALL NULL NULL NULL NULL NULL NULL NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 insert into `test`.`t2` /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON INSERT INTO t2 SELECT * FROM t1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.80" + } /* cost_info */, + "table": { + "insert": true, + "table_name": "t2", + "access_type": "ALL" + } /* table */, + "insert_from": { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.30", + "prefix_cost": "0.80", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "i" + ] /* used_columns */ + } /* table */ + } /* insert_from */ + } /* query_block */ +} +Warnings: +Note 1003 insert into `test`.`t2` /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.80" + } /* cost_info */, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.30", + "prefix_cost": "0.80", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "i" + ] /* used_columns */ + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 1 +Handler_read_rnd_next 4 +# Status of testing query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 4 +Handler_write 3 + +# +# query: INSERT INTO t2 SELECT * FROM t1 JOIN t1 AS tt USING(i) +# select: SELECT * FROM t1 JOIN t1 AS tt USING(i) +# +EXPLAIN INSERT INTO t2 SELECT * FROM t1 JOIN t1 AS tt USING(i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 INSERT t2 NULL ALL NULL NULL NULL NULL NULL NULL NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE tt NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +Warnings: +Note 1003 insert into `test`.`t2` /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` join `test`.`t1` `tt` where (`test`.`tt`.`i` = `test`.`t1`.`i`) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON INSERT INTO t2 SELECT * FROM t1 JOIN t1 AS tt USING(i);; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "2.20" + } /* cost_info */, + "table": { + "insert": true, + "table_name": "t2", + "access_type": "ALL" + } /* table */, + "insert_from": { + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.30", + "prefix_cost": "0.80", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "i" + ] /* used_columns */ + } /* table */ + }, + { + "table": { + "table_name": "tt", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "33.33", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.30", + "prefix_cost": "2.20", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "i" + ] /* used_columns */, + "attached_condition": "(`test`.`tt`.`i` = `test`.`t1`.`i`)" + } /* table */ + } + ] /* nested_loop */ + } /* insert_from */ + } /* query_block */ +} +Warnings: +Note 1003 insert into `test`.`t2` /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` join `test`.`t1` `tt` where (`test`.`tt`.`i` = `test`.`t1`.`i`) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 JOIN t1 AS tt USING(i);; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "2.20" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.30", + "prefix_cost": "0.80", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "i" + ] /* used_columns */ + } /* table */ + }, + { + "table": { + "table_name": "tt", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "33.33", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.30", + "prefix_cost": "2.20", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "i" + ] /* used_columns */, + "attached_condition": "(`test`.`tt`.`i` = `test`.`t1`.`i`)" + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` join `test`.`t1` `tt` where (`test`.`tt`.`i` = `test`.`t1`.`i`) +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 1 +Handler_read_rnd_next 8 +# Status of testing query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 8 +Handler_write 3 + +DROP TABLE t1, t2; +#26 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (1), (2), (3); +CREATE TABLE t2 (i INT); +# +# query: REPLACE INTO t2 SELECT * FROM t1 +# select: SELECT * FROM t1 +# +EXPLAIN REPLACE INTO t2 SELECT * FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 REPLACE t2 NULL ALL NULL NULL NULL NULL NULL NULL NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 replace into `test`.`t2` /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON REPLACE INTO t2 SELECT * FROM t1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.80" + } /* cost_info */, + "table": { + "replace": true, + "table_name": "t2", + "access_type": "ALL" + } /* table */, + "insert_from": { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.30", + "prefix_cost": "0.80", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "i" + ] /* used_columns */ + } /* table */ + } /* insert_from */ + } /* query_block */ +} +Warnings: +Note 1003 replace into `test`.`t2` /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.80" + } /* cost_info */, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.30", + "prefix_cost": "0.80", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "i" + ] /* used_columns */ + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 1 +Handler_read_rnd_next 4 +# Status of testing query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 4 +Handler_write 3 + +DROP TABLE t1, t2; +#27 +CREATE TABLE t1 (i INT); +# +# query: INSERT INTO t1 SET i = 10 +# select: +# +EXPLAIN INSERT INTO t1 SET i = 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 INSERT t1 NULL ALL NULL NULL NULL NULL NULL NULL NULL +Warnings: +Note 1003 insert into `test`.`t1` (`test`.`t1`.`i`) values (10) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON INSERT INTO t1 SET i = 10;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "table": { + "insert": true, + "table_name": "t1", + "access_type": "ALL" + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 insert into `test`.`t1` (`test`.`t1`.`i`) values (10) +# Status of testing query execution: +Variable_name Value +Handler_read_key 1 +Handler_write 1 + +DROP TABLE t1; +#28 +CREATE TABLE t1 (i INT); +# +# query: REPLACE INTO t1 SET i = 10 +# select: +# +EXPLAIN REPLACE INTO t1 SET i = 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 REPLACE t1 NULL ALL NULL NULL NULL NULL NULL NULL NULL +Warnings: +Note 1003 replace into `test`.`t1` (`test`.`t1`.`i`) values (10) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON REPLACE INTO t1 SET i = 10;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "table": { + "replace": true, + "table_name": "t1", + "access_type": "ALL" + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 replace into `test`.`t1` (`test`.`t1`.`i`) values (10) +# Status of testing query execution: +Variable_name Value +Handler_read_key 1 +Handler_write 1 + +DROP TABLE t1; +#29 +CREATE TABLE t1 (a INT, i INT PRIMARY KEY); +INSERT INTO t1 (i) VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +# +# query: DELETE FROM t1 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 1 +# select: SELECT * FROM t1 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 1 +# +EXPLAIN DELETE FROM t1 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL range PRIMARY PRIMARY 4 const 8 100.00 Using where +Warnings: +Note 1003 delete from `test`.`t1` where ((`test`.`t1`.`i` > 10) and (`test`.`t1`.`i` <= 18)) order by `test`.`t1`.`i` limit 1 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t1 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_filesort": false, + "table": { + "delete": true, + "table_name": "t1", + "access_type": "range", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "i" + ] /* used_key_parts */, + "key_length": "4", + "ref": [ + "const" + ] /* ref */, + "rows_examined_per_scan": 8, + "filtered": "100.00", + "attached_condition": "((`test`.`t1`.`i` > 10) and (`test`.`t1`.`i` <= 18))" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 delete from `test`.`t1` where ((`test`.`t1`.`i` > 10) and (`test`.`t1`.`i` <= 18)) order by `test`.`t1`.`i` limit 1 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "2.26" + } /* cost_info */, + "ordering_operation": { + "using_filesort": false, + "table": { + "table_name": "t1", + "access_type": "range", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "i" + ] /* used_key_parts */, + "key_length": "4", + "rows_examined_per_scan": 8, + "rows_produced_per_join": 8, + "filtered": "100.00", + "index_condition": "((`test`.`t1`.`i` > 10) and (`test`.`t1`.`i` <= 18))", + "cost_info": { + "read_cost": "1.46", + "eval_cost": "0.80", + "prefix_cost": "2.26", + "data_read_per_join": "128" + } /* cost_info */, + "used_columns": [ + "a", + "i" + ] /* used_columns */ + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`i` AS `i` from `test`.`t1` where ((`test`.`t1`.`i` > 10) and (`test`.`t1`.`i` <= 18)) order by `test`.`t1`.`i` limit 1 +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 3 +# Status of testing query execution: +Variable_name Value +Handler_delete 1 +Handler_read_key 3 + +DROP TABLE t1; +#30 +CREATE TABLE t1(a INT, i CHAR(2), INDEX(i(1))) charset utf8mb4; +INSERT INTO t1 (i) VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +# +# query: DELETE FROM t1 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 5 +# select: SELECT * FROM t1 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 5 +# +EXPLAIN DELETE FROM t1 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 26 100.00 Using where; Using filesort +Warnings: +Warning 1739 Cannot use range access on index 'i' due to type or collation conversion on field 'i' +Warning 1739 Cannot use range access on index 'i' due to type or collation conversion on field 'i' +Note 1003 delete from `test`.`t1` where ((`test`.`t1`.`i` > 10) and (`test`.`t1`.`i` <= 18)) order by `test`.`t1`.`i` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t1 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_filesort": true, + "table": { + "delete": true, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 26, + "filtered": "100.00", + "attached_condition": "((`test`.`t1`.`i` > 10) and (`test`.`t1`.`i` <= 18))" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Warning 1739 Cannot use range access on index 'i' due to type or collation conversion on field 'i' +Warning 1739 Cannot use range access on index 'i' due to type or collation conversion on field 'i' +Note 1003 delete from `test`.`t1` where ((`test`.`t1`.`i` > 10) and (`test`.`t1`.`i` <= 18)) order by `test`.`t1`.`i` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "6.01" + } /* cost_info */, + "ordering_operation": { + "using_filesort": true, + "cost_info": { + "sort_cost": "2.89" + } /* cost_info */, + "table": { + "table_name": "t1", + "access_type": "ALL", + "possible_keys": [ + "i" + ] /* possible_keys */, + "rows_examined_per_scan": 26, + "rows_produced_per_join": 2, + "filtered": "11.11", + "cost_info": { + "read_cost": "2.83", + "eval_cost": "0.29", + "prefix_cost": "3.12", + "data_read_per_join": "46" + } /* cost_info */, + "used_columns": [ + "a", + "i" + ] /* used_columns */, + "attached_condition": "((`test`.`t1`.`i` > 10) and (`test`.`t1`.`i` <= 18))" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Warning 1739 Cannot use range access on index 'i' due to type or collation conversion on field 'i' +Warning 1739 Cannot use range access on index 'i' due to type or collation conversion on field 'i' +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`i` AS `i` from `test`.`t1` where ((`test`.`t1`.`i` > 10) and (`test`.`t1`.`i` <= 18)) order by `test`.`t1`.`i` limit 5 +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 27 +Sort_rows 5 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_delete 5 +Handler_read_key 2 +Handler_read_rnd 5 +Handler_read_rnd_next 27 +Sort_rows 8 +Sort_scan 1 + +DROP TABLE t1; +#31 +CREATE TABLE t1 (i INT); +INSERT INTO t1 (i) VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2(a INT, b INT, c INT, d INT, INDEX(a, b, c)); +INSERT INTO t2 (a, b, c) SELECT i, i, i FROM t1; +# +# query: DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# select: SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# +EXPLAIN DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t2 NULL ALL NULL NULL NULL NULL 26 100.00 Using where; Using filesort +Warnings: +Note 1003 delete from `test`.`t2` where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_filesort": true, + "table": { + "delete": true, + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 26, + "filtered": "100.00", + "attached_condition": "(`test`.`t2`.`b` = 10)" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 delete from `test`.`t2` where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "3.13" + } /* cost_info */, + "ordering_operation": { + "using_filesort": false, + "table": { + "table_name": "t2", + "access_type": "index", + "key": "a", + "used_key_parts": [ + "a", + "b", + "c" + ] /* used_key_parts */, + "key_length": "15", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 2, + "filtered": "10.00", + "cost_info": { + "read_cost": "2.87", + "eval_cost": "0.26", + "prefix_cost": "3.13", + "data_read_per_join": "62" + } /* cost_info */, + "used_columns": [ + "a", + "b", + "c", + "d" + ] /* used_columns */, + "attached_condition": "(`test`.`t2`.`b` = 10)" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c`,`test`.`t2`.`d` AS `d` from `test`.`t2` where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 4 +Handler_read_next 26 +# Status of testing query execution: +Variable_name Value +Handler_delete 1 +Handler_read_key 4 +Handler_read_rnd 1 +Handler_read_rnd_next 27 +Sort_rows 1 +Sort_scan 1 + +DROP TABLE t1, t2; +#32 +CREATE TABLE t1 (i INT); +INSERT INTO t1 (i) VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2(a INT, b INT, c INT, d INT, INDEX(a, b, c)); +INSERT INTO t2 (a, b, c) SELECT i, i, i FROM t1; +INSERT INTO t2 (a, b, c) SELECT t1.i, t1.i, t1.i FROM t1, t1 x1, t1 x2; +# +# query: DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# select: SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# +EXPLAIN DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t2 NULL index NULL a 15 NULL 17602 100.00 Using where +Warnings: +Note 1003 delete from `test`.`t2` where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_filesort": false, + "table": { + "delete": true, + "table_name": "t2", + "access_type": "index", + "key": "a", + "used_key_parts": [ + "a", + "b", + "c" + ] /* used_key_parts */, + "key_length": "15", + "rows_examined_per_scan": 17602, + "filtered": "100.00", + "attached_condition": "(`test`.`t2`.`b` = 10)" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 delete from `test`.`t2` where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1778.96" + } /* cost_info */, + "ordering_operation": { + "using_filesort": false, + "table": { + "table_name": "t2", + "access_type": "index", + "key": "a", + "used_key_parts": [ + "a", + "b", + "c" + ] /* used_key_parts */, + "key_length": "15", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 1760, + "filtered": "10.00", + "cost_info": { + "read_cost": "1602.94", + "eval_cost": "176.02", + "prefix_cost": "1778.96", + "data_read_per_join": "41K" + } /* cost_info */, + "used_columns": [ + "a", + "b", + "c", + "d" + ] /* used_columns */, + "attached_condition": "(`test`.`t2`.`b` = 10)" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c`,`test`.`t2`.`d` AS `d` from `test`.`t2` where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 4 +Handler_read_next 4 +# Status of testing query execution: +Variable_name Value +Handler_delete 5 +Handler_read_first 1 +Handler_read_key 4 +Handler_read_next 4 + +DROP TABLE t1, t2; +#33 +CREATE TABLE t1 (i INT); +INSERT INTO t1 (i) VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2 (a CHAR(2), b CHAR(2), c CHAR(2), d CHAR(2), INDEX (a,b(1),c)) +charset utf8mb4; +INSERT INTO t2 SELECT i, i, i, i FROM t1; +# +# query: DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# select: SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# +EXPLAIN DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t2 NULL ALL NULL NULL NULL NULL 26 100.00 Using where; Using filesort +Warnings: +Warning 1739 Cannot use range access on index 'a' due to type or collation conversion on field 'b' +Note 1003 delete from `test`.`t2` where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_filesort": true, + "table": { + "delete": true, + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 26, + "filtered": "100.00", + "attached_condition": "(`test`.`t2`.`b` = 10)" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Warning 1739 Cannot use range access on index 'a' due to type or collation conversion on field 'b' +Note 1003 delete from `test`.`t2` where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "5.75" + } /* cost_info */, + "ordering_operation": { + "using_filesort": true, + "cost_info": { + "sort_cost": "2.60" + } /* cost_info */, + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 26, + "rows_produced_per_join": 2, + "filtered": "10.00", + "cost_info": { + "read_cost": "2.89", + "eval_cost": "0.26", + "prefix_cost": "3.15", + "data_read_per_join": "104" + } /* cost_info */, + "used_columns": [ + "a", + "b", + "c", + "d" + ] /* used_columns */, + "attached_condition": "(`test`.`t2`.`b` = 10)" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c`,`test`.`t2`.`d` AS `d` from `test`.`t2` where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 4 +Handler_read_rnd_next 27 +Sort_rows 1 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_delete 1 +Handler_read_key 4 +Handler_read_rnd 1 +Handler_read_rnd_next 27 +Sort_rows 1 +Sort_scan 1 + +DROP TABLE t1, t2; +#34 +CREATE TABLE t1 (i INT); +INSERT INTO t1 (i) VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2 (a CHAR(2), b CHAR(2), c CHAR(2), d CHAR(2), INDEX (a,b,c)) +charset utf8mb4 ENGINE=HEAP; +INSERT INTO t2 SELECT i, i, i, i FROM t1; +# +# query: DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# select: SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# +EXPLAIN DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t2 NULL ALL NULL NULL NULL NULL 26 100.00 Using where; Using filesort +Warnings: +Warning 1739 Cannot use range access on index 'a' due to type or collation conversion on field 'b' +Note 1003 delete from `test`.`t2` where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_filesort": true, + "table": { + "delete": true, + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 26, + "filtered": "100.00", + "attached_condition": "(`test`.`t2`.`b` = 10)" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Warning 1739 Cannot use range access on index 'a' due to type or collation conversion on field 'b' +Note 1003 delete from `test`.`t2` where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "8.02" + } /* cost_info */, + "ordering_operation": { + "using_filesort": true, + "cost_info": { + "sort_cost": "2.60" + } /* cost_info */, + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 26, + "rows_produced_per_join": 2, + "filtered": "10.00", + "cost_info": { + "read_cost": "5.16", + "eval_cost": "0.26", + "prefix_cost": "5.42", + "data_read_per_join": "104" + } /* cost_info */, + "used_columns": [ + "a", + "b", + "c", + "d" + ] /* used_columns */, + "attached_condition": "(`test`.`t2`.`b` = 10)" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Warning 1739 Cannot use range access on index 'a' due to type or collation conversion on field 'b' +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c`,`test`.`t2`.`d` AS `d` from `test`.`t2` where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 4 +Handler_read_rnd_next 27 +Sort_rows 1 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_delete 1 +Handler_read_key 4 +Handler_read_rnd 1 +Handler_read_rnd_next 27 +Sort_rows 1 +Sort_scan 1 + +DROP TABLE t1, t2; +#35 +CREATE TABLE t1 (i INT); +INSERT INTO t1 (i) VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35),(36),(37),(38),(39), +(40),(41),(42),(43),(44); +CREATE TABLE t2 (i INT, key1 INT, key2 INT, INDEX (key1), INDEX (key2)); +INSERT INTO t2 (key1, key2) SELECT i, i FROM t1; +# +# query: DELETE FROM t2 WHERE key1 < 13 or key2 < 14 ORDER BY key1 +# select: SELECT * FROM t2 WHERE key1 < 13 or key2 < 14 ORDER BY key1 +# +EXPLAIN DELETE FROM t2 WHERE key1 < 13 or key2 < 14 ORDER BY key1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t2 NULL index_merge key1,key2 key1,key2 5,5 NULL 7 100.00 Using sort_union(key1,key2); Using where; Using filesort +Warnings: +Note 1003 delete from `test`.`t2` where ((`test`.`t2`.`key1` < 13) or (`test`.`t2`.`key2` < 14)) order by `test`.`t2`.`key1` +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t2 WHERE key1 < 13 or key2 < 14 ORDER BY key1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_filesort": true, + "table": { + "delete": true, + "table_name": "t2", + "access_type": "index_merge", + "possible_keys": [ + "key1", + "key2" + ] /* possible_keys */, + "key": "sort_union(key1,key2)", + "key_length": "5,5", + "rows_examined_per_scan": 7, + "filtered": "100.00", + "attached_condition": "((`test`.`t2`.`key1` < 13) or (`test`.`t2`.`key2` < 14))" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 delete from `test`.`t2` where ((`test`.`t2`.`key1` < 13) or (`test`.`t2`.`key2` < 14)) order by `test`.`t2`.`key1` +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t2 WHERE key1 < 13 or key2 < 14 ORDER BY key1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "10.73" + } /* cost_info */, + "ordering_operation": { + "using_filesort": true, + "cost_info": { + "sort_cost": "7.00" + } /* cost_info */, + "table": { + "table_name": "t2", + "access_type": "index_merge", + "possible_keys": [ + "key1", + "key2" + ] /* possible_keys */, + "key": "sort_union(key1,key2)", + "key_length": "5,5", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "3.03", + "eval_cost": "0.70", + "prefix_cost": "3.73", + "data_read_per_join": "112" + } /* cost_info */, + "used_columns": [ + "i", + "key1", + "key2" + ] /* used_columns */, + "attached_condition": "((`test`.`t2`.`key1` < 13) or (`test`.`t2`.`key2` < 14))" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`i` AS `i`,`test`.`t2`.`key1` AS `key1`,`test`.`t2`.`key2` AS `key2` from `test`.`t2` where ((`test`.`t2`.`key1` < 13) or (`test`.`t2`.`key2` < 14)) order by `test`.`t2`.`key1` +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 5 +Handler_read_next 7 +Handler_read_rnd 4 +Sort_rows 4 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_delete 4 +Handler_read_key 5 +Handler_read_next 7 +Handler_read_rnd 8 +Sort_rows 4 +Sort_scan 1 + +DROP TABLE t1, t2; +#36 +CREATE TABLE t1 (i INT); +INSERT INTO t1 (i) VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2(a INT, i INT PRIMARY KEY); +INSERT INTO t2 (i) SELECT i FROM t1; +# +# query: DELETE FROM t2 WHERE i > 10 AND i <= 18 ORDER BY i DESC LIMIT 1 +# select: SELECT * FROM t2 WHERE i > 10 AND i <= 18 ORDER BY i DESC LIMIT 1 +# +EXPLAIN DELETE FROM t2 WHERE i > 10 AND i <= 18 ORDER BY i DESC LIMIT 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t2 NULL range PRIMARY PRIMARY 4 const 8 100.00 Using where; Backward index scan +Warnings: +Note 1003 delete from `test`.`t2` where ((`test`.`t2`.`i` > 10) and (`test`.`t2`.`i` <= 18)) order by `test`.`t2`.`i` desc limit 1 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t2 WHERE i > 10 AND i <= 18 ORDER BY i DESC LIMIT 1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_filesort": false, + "table": { + "delete": true, + "table_name": "t2", + "access_type": "range", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "i" + ] /* used_key_parts */, + "key_length": "4", + "ref": [ + "const" + ] /* ref */, + "rows_examined_per_scan": 8, + "filtered": "100.00", + "backward_index_scan": true, + "attached_condition": "((`test`.`t2`.`i` > 10) and (`test`.`t2`.`i` <= 18))" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 delete from `test`.`t2` where ((`test`.`t2`.`i` > 10) and (`test`.`t2`.`i` <= 18)) order by `test`.`t2`.`i` desc limit 1 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t2 WHERE i > 10 AND i <= 18 ORDER BY i DESC LIMIT 1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "2.26" + } /* cost_info */, + "ordering_operation": { + "using_filesort": false, + "table": { + "table_name": "t2", + "access_type": "range", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "i" + ] /* used_key_parts */, + "key_length": "4", + "rows_examined_per_scan": 8, + "rows_produced_per_join": 8, + "filtered": "100.00", + "index_condition": "((`test`.`t2`.`i` > 10) and (`test`.`t2`.`i` <= 18))", + "backward_index_scan": true, + "cost_info": { + "read_cost": "1.46", + "eval_cost": "0.80", + "prefix_cost": "2.26", + "data_read_per_join": "128" + } /* cost_info */, + "used_columns": [ + "a", + "i" + ] /* used_columns */ + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`i` AS `i` from `test`.`t2` where ((`test`.`t2`.`i` > 10) and (`test`.`t2`.`i` <= 18)) order by `test`.`t2`.`i` desc limit 1 +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 3 +# Status of testing query execution: +Variable_name Value +Handler_delete 1 +Handler_read_key 3 + +DROP TABLE t1, t2; +#37 +CREATE TABLE t1 (i INT); +INSERT INTO t1 (i) VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2 (a CHAR(2), b CHAR(2), c CHAR(2), INDEX (a, b)) charset utf8mb4; +INSERT INTO t2 SELECT i, i, i FROM t1; +# +# query: DELETE FROM t2 ORDER BY a, b DESC LIMIT 5 +# select: SELECT * FROM t2 ORDER BY a, b DESC LIMIT 5 +# +EXPLAIN DELETE FROM t2 ORDER BY a, b DESC LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t2 NULL ALL NULL NULL NULL NULL 26 100.00 Using filesort +Warnings: +Note 1003 delete from `test`.`t2` order by `test`.`t2`.`a`,`test`.`t2`.`b` desc limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t2 ORDER BY a, b DESC LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_filesort": true, + "table": { + "delete": true, + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 26, + "filtered": "100.00" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 delete from `test`.`t2` order by `test`.`t2`.`a`,`test`.`t2`.`b` desc limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t2 ORDER BY a, b DESC LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "3.14" + } /* cost_info */, + "ordering_operation": { + "using_filesort": true, + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 26, + "rows_produced_per_join": 26, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.54", + "eval_cost": "2.60", + "prefix_cost": "3.14", + "data_read_per_join": "832" + } /* cost_info */, + "used_columns": [ + "a", + "b", + "c" + ] /* used_columns */ + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c` from `test`.`t2` order by `test`.`t2`.`a`,`test`.`t2`.`b` desc limit 5 +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 3 +Handler_read_rnd_next 27 +Sort_rows 5 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_delete 5 +Handler_read_key 3 +Handler_read_rnd 5 +Handler_read_rnd_next 27 +Sort_rows 26 +Sort_scan 1 + +DROP TABLE t1, t2; +#38 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2 (a CHAR(2), b CHAR(2), c INT, INDEX (a, b)) charset utf8mb4; +INSERT INTO t2 (a, b) SELECT i, i FROM t1; +INSERT INTO t2 (a, b) SELECT t1.i, t1.i FROM t1, t1 x1, t1 x2; +# +# query: DELETE FROM t2 ORDER BY a DESC, b DESC LIMIT 5 +# select: SELECT * FROM t2 ORDER BY a DESC, b DESC LIMIT 5 +# +EXPLAIN DELETE FROM t2 ORDER BY a DESC, b DESC LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t2 NULL index NULL a 18 NULL 5 100.00 NULL +Warnings: +Note 1003 delete from `test`.`t2` order by `test`.`t2`.`a` desc,`test`.`t2`.`b` desc limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t2 ORDER BY a DESC, b DESC LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_filesort": false, + "table": { + "delete": true, + "table_name": "t2", + "access_type": "index", + "key": "a", + "used_key_parts": [ + "a", + "b" + ] /* used_key_parts */, + "key_length": "18", + "rows_examined_per_scan": 5, + "filtered": "100.00" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 delete from `test`.`t2` order by `test`.`t2`.`a` desc,`test`.`t2`.`b` desc limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t2 ORDER BY a DESC, b DESC LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1783.26" + } /* cost_info */, + "ordering_operation": { + "using_filesort": false, + "table": { + "table_name": "t2", + "access_type": "index", + "key": "a", + "used_key_parts": [ + "a", + "b" + ] /* used_key_parts */, + "key_length": "18", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 17602, + "filtered": "100.00", + "backward_index_scan": true, + "cost_info": { + "read_cost": "23.06", + "eval_cost": "1760.20", + "prefix_cost": "1783.26", + "data_read_per_join": "412K" + } /* cost_info */, + "used_columns": [ + "a", + "b", + "c" + ] /* used_columns */ + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c` from `test`.`t2` order by `test`.`t2`.`a` desc,`test`.`t2`.`b` desc limit 5 +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 3 +Handler_read_last 1 +Handler_read_prev 4 +# Status of testing query execution: +Variable_name Value +Handler_delete 5 +Handler_read_key 3 +Handler_read_last 1 +Handler_read_prev 4 + +DROP TABLE t1, t2; +#39 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2(a INT, i INT PRIMARY KEY); +INSERT INTO t2 (i) SELECT i FROM t1; +# +# query: UPDATE t2 SET a = 10 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 1 +# select: SELECT * FROM t2 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 1 +# +EXPLAIN UPDATE t2 SET a = 10 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t2 NULL range PRIMARY PRIMARY 4 const 8 100.00 Using where; Using temporary +Warnings: +Note 1003 update `test`.`t2` set `test`.`t2`.`a` = 10 where ((`test`.`t2`.`i` > 10) and (`test`.`t2`.`i` <= 18)) order by `test`.`t2`.`i` limit 1 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t2 SET a = 10 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_temporary_table": true, + "using_filesort": false, + "table": { + "update": true, + "table_name": "t2", + "access_type": "range", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "i" + ] /* used_key_parts */, + "key_length": "4", + "ref": [ + "const" + ] /* ref */, + "rows_examined_per_scan": 8, + "filtered": "100.00", + "attached_condition": "((`test`.`t2`.`i` > 10) and (`test`.`t2`.`i` <= 18))" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t2` set `test`.`t2`.`a` = 10 where ((`test`.`t2`.`i` > 10) and (`test`.`t2`.`i` <= 18)) order by `test`.`t2`.`i` limit 1 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t2 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "2.26" + } /* cost_info */, + "ordering_operation": { + "using_filesort": false, + "table": { + "table_name": "t2", + "access_type": "range", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "i" + ] /* used_key_parts */, + "key_length": "4", + "rows_examined_per_scan": 8, + "rows_produced_per_join": 8, + "filtered": "100.00", + "index_condition": "((`test`.`t2`.`i` > 10) and (`test`.`t2`.`i` <= 18))", + "cost_info": { + "read_cost": "1.46", + "eval_cost": "0.80", + "prefix_cost": "2.26", + "data_read_per_join": "128" + } /* cost_info */, + "used_columns": [ + "a", + "i" + ] /* used_columns */ + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`i` AS `i` from `test`.`t2` where ((`test`.`t2`.`i` > 10) and (`test`.`t2`.`i` <= 18)) order by `test`.`t2`.`i` limit 1 +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 3 +# Status of testing query execution: +Variable_name Value +Handler_read_key 3 +Handler_read_rnd 1 +Handler_update 1 + +DROP TABLE t1, t2; +#40 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2(a INT, i CHAR(2), INDEX(i(1))) charset utf8mb4; +INSERT INTO t2 (i) SELECT i FROM t1; +# +# query: UPDATE t2 SET a = 10 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 5 +# select: SELECT * FROM t2 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 5 +# +EXPLAIN UPDATE t2 SET a = 10 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t2 NULL ALL NULL NULL NULL NULL 26 100.00 Using where; Using filesort +Warnings: +Warning 1739 Cannot use range access on index 'i' due to type or collation conversion on field 'i' +Warning 1739 Cannot use range access on index 'i' due to type or collation conversion on field 'i' +Note 1003 update `test`.`t2` set `test`.`t2`.`a` = 10 where ((`test`.`t2`.`i` > 10) and (`test`.`t2`.`i` <= 18)) order by `test`.`t2`.`i` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t2 SET a = 10 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_filesort": true, + "table": { + "update": true, + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 26, + "filtered": "100.00", + "attached_condition": "((`test`.`t2`.`i` > 10) and (`test`.`t2`.`i` <= 18))" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Warning 1739 Cannot use range access on index 'i' due to type or collation conversion on field 'i' +Warning 1739 Cannot use range access on index 'i' due to type or collation conversion on field 'i' +Note 1003 update `test`.`t2` set `test`.`t2`.`a` = 10 where ((`test`.`t2`.`i` > 10) and (`test`.`t2`.`i` <= 18)) order by `test`.`t2`.`i` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t2 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "6.01" + } /* cost_info */, + "ordering_operation": { + "using_filesort": true, + "cost_info": { + "sort_cost": "2.89" + } /* cost_info */, + "table": { + "table_name": "t2", + "access_type": "ALL", + "possible_keys": [ + "i" + ] /* possible_keys */, + "rows_examined_per_scan": 26, + "rows_produced_per_join": 2, + "filtered": "11.11", + "cost_info": { + "read_cost": "2.83", + "eval_cost": "0.29", + "prefix_cost": "3.12", + "data_read_per_join": "46" + } /* cost_info */, + "used_columns": [ + "a", + "i" + ] /* used_columns */, + "attached_condition": "((`test`.`t2`.`i` > 10) and (`test`.`t2`.`i` <= 18))" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Warning 1739 Cannot use range access on index 'i' due to type or collation conversion on field 'i' +Warning 1739 Cannot use range access on index 'i' due to type or collation conversion on field 'i' +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`i` AS `i` from `test`.`t2` where ((`test`.`t2`.`i` > 10) and (`test`.`t2`.`i` <= 18)) order by `test`.`t2`.`i` limit 5 +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 27 +Sort_rows 5 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd 5 +Handler_read_rnd_next 27 +Handler_update 5 +Sort_rows 5 +Sort_scan 1 + +DROP TABLE t1, t2; +#41 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2(a INT, b INT, c INT, d INT, INDEX(a, b, c)); +INSERT INTO t2 (a, b, c) SELECT i, i, i FROM t1; +# +# query: UPDATE t2 SET d = 10 WHERE b = 10 ORDER BY a, c LIMIT 5 +# select: SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# +EXPLAIN UPDATE t2 SET d = 10 WHERE b = 10 ORDER BY a, c LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t2 NULL ALL NULL NULL NULL NULL 26 100.00 Using where; Using filesort +Warnings: +Note 1003 update `test`.`t2` set `test`.`t2`.`d` = 10 where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t2 SET d = 10 WHERE b = 10 ORDER BY a, c LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_filesort": true, + "table": { + "update": true, + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 26, + "filtered": "100.00", + "attached_condition": "(`test`.`t2`.`b` = 10)" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t2` set `test`.`t2`.`d` = 10 where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "3.13" + } /* cost_info */, + "ordering_operation": { + "using_filesort": false, + "table": { + "table_name": "t2", + "access_type": "index", + "key": "a", + "used_key_parts": [ + "a", + "b", + "c" + ] /* used_key_parts */, + "key_length": "15", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 2, + "filtered": "10.00", + "cost_info": { + "read_cost": "2.87", + "eval_cost": "0.26", + "prefix_cost": "3.13", + "data_read_per_join": "62" + } /* cost_info */, + "used_columns": [ + "a", + "b", + "c", + "d" + ] /* used_columns */, + "attached_condition": "(`test`.`t2`.`b` = 10)" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c`,`test`.`t2`.`d` AS `d` from `test`.`t2` where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 4 +Handler_read_next 26 +# Status of testing query execution: +Variable_name Value +Handler_read_key 4 +Handler_read_rnd 1 +Handler_read_rnd_next 27 +Handler_update 1 +Sort_rows 1 +Sort_scan 1 + +DROP TABLE t1, t2; +#42 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2(a INT, b INT, c INT, d INT, INDEX(a, b, c)); +INSERT INTO t2 (a, b, c) SELECT i, i, i FROM t1; +INSERT INTO t2 (a, b, c) SELECT t1.i, t1.i, t1.i FROM t1, t1 x1, t1 x2; +# +# query: UPDATE t2 SET d = 10 WHERE b = 10 ORDER BY a, c LIMIT 5 +# select: SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# +EXPLAIN UPDATE t2 SET d = 10 WHERE b = 10 ORDER BY a, c LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t2 NULL index NULL a 15 NULL 17602 100.00 Using where; Using temporary +Warnings: +Note 1003 update `test`.`t2` set `test`.`t2`.`d` = 10 where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t2 SET d = 10 WHERE b = 10 ORDER BY a, c LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_temporary_table": true, + "using_filesort": false, + "table": { + "update": true, + "table_name": "t2", + "access_type": "index", + "key": "a", + "used_key_parts": [ + "a", + "b", + "c" + ] /* used_key_parts */, + "key_length": "15", + "rows_examined_per_scan": 17602, + "filtered": "100.00", + "attached_condition": "(`test`.`t2`.`b` = 10)" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t2` set `test`.`t2`.`d` = 10 where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1778.96" + } /* cost_info */, + "ordering_operation": { + "using_filesort": false, + "table": { + "table_name": "t2", + "access_type": "index", + "key": "a", + "used_key_parts": [ + "a", + "b", + "c" + ] /* used_key_parts */, + "key_length": "15", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 1760, + "filtered": "10.00", + "cost_info": { + "read_cost": "1602.94", + "eval_cost": "176.02", + "prefix_cost": "1778.96", + "data_read_per_join": "41K" + } /* cost_info */, + "used_columns": [ + "a", + "b", + "c", + "d" + ] /* used_columns */, + "attached_condition": "(`test`.`t2`.`b` = 10)" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c`,`test`.`t2`.`d` AS `d` from `test`.`t2` where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 4 +Handler_read_next 4 +# Status of testing query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 4 +Handler_read_next 4 +Handler_read_rnd 5 +Handler_update 5 + +DROP TABLE t1, t2; +#43 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2 (a CHAR(2), b CHAR(2), c CHAR(2), d CHAR(2), INDEX (a,b(1),c)) +charset utf8mb4; +INSERT INTO t2 SELECT i, i, i, i FROM t1; +# +# query: UPDATE t2 SET d = 10 WHERE b = 10 ORDER BY a, c LIMIT 5 +# select: SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# +EXPLAIN UPDATE t2 SET d = 10 WHERE b = 10 ORDER BY a, c LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t2 NULL ALL NULL NULL NULL NULL 26 100.00 Using where; Using filesort +Warnings: +Warning 1739 Cannot use range access on index 'a' due to type or collation conversion on field 'b' +Note 1003 update `test`.`t2` set `test`.`t2`.`d` = 10 where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t2 SET d = 10 WHERE b = 10 ORDER BY a, c LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_filesort": true, + "table": { + "update": true, + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 26, + "filtered": "100.00", + "attached_condition": "(`test`.`t2`.`b` = 10)" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Warning 1739 Cannot use range access on index 'a' due to type or collation conversion on field 'b' +Note 1003 update `test`.`t2` set `test`.`t2`.`d` = 10 where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "5.75" + } /* cost_info */, + "ordering_operation": { + "using_filesort": true, + "cost_info": { + "sort_cost": "2.60" + } /* cost_info */, + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 26, + "rows_produced_per_join": 2, + "filtered": "10.00", + "cost_info": { + "read_cost": "2.89", + "eval_cost": "0.26", + "prefix_cost": "3.15", + "data_read_per_join": "104" + } /* cost_info */, + "used_columns": [ + "a", + "b", + "c", + "d" + ] /* used_columns */, + "attached_condition": "(`test`.`t2`.`b` = 10)" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c`,`test`.`t2`.`d` AS `d` from `test`.`t2` where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 4 +Handler_read_rnd_next 27 +Sort_rows 1 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 4 +Handler_read_rnd 1 +Handler_read_rnd_next 27 +Sort_rows 1 +Sort_scan 1 + +DROP TABLE t1, t2; +#44 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2 (a CHAR(2), b CHAR(2), c CHAR(2), d CHAR(2), INDEX (a,b,c)) +charset utf8mb4 ENGINE=HEAP; +INSERT INTO t2 SELECT i, i, i, i FROM t1; +# +# query: UPDATE t2 SET d = 10 WHERE b = 10 ORDER BY a, c LIMIT 5 +# select: SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# +EXPLAIN UPDATE t2 SET d = 10 WHERE b = 10 ORDER BY a, c LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t2 NULL ALL NULL NULL NULL NULL 26 100.00 Using where; Using filesort +Warnings: +Warning 1739 Cannot use range access on index 'a' due to type or collation conversion on field 'b' +Note 1003 update `test`.`t2` set `test`.`t2`.`d` = 10 where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t2 SET d = 10 WHERE b = 10 ORDER BY a, c LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_filesort": true, + "table": { + "update": true, + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 26, + "filtered": "100.00", + "attached_condition": "(`test`.`t2`.`b` = 10)" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Warning 1739 Cannot use range access on index 'a' due to type or collation conversion on field 'b' +Note 1003 update `test`.`t2` set `test`.`t2`.`d` = 10 where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "8.02" + } /* cost_info */, + "ordering_operation": { + "using_filesort": true, + "cost_info": { + "sort_cost": "2.60" + } /* cost_info */, + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 26, + "rows_produced_per_join": 2, + "filtered": "10.00", + "cost_info": { + "read_cost": "5.16", + "eval_cost": "0.26", + "prefix_cost": "5.42", + "data_read_per_join": "104" + } /* cost_info */, + "used_columns": [ + "a", + "b", + "c", + "d" + ] /* used_columns */, + "attached_condition": "(`test`.`t2`.`b` = 10)" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Warning 1739 Cannot use range access on index 'a' due to type or collation conversion on field 'b' +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c`,`test`.`t2`.`d` AS `d` from `test`.`t2` where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 4 +Handler_read_rnd_next 27 +Sort_rows 1 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 4 +Handler_read_rnd 1 +Handler_read_rnd_next 27 +Sort_rows 1 +Sort_scan 1 + +DROP TABLE t1, t2; +#45 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35),(36),(37),(38),(39), +(40),(41),(42),(43),(44); +CREATE TABLE t2 (i INT, key1 INT, key2 INT, INDEX (key1), INDEX (key2)); +INSERT INTO t2 (key1, key2) SELECT i, i FROM t1; +# +# query: UPDATE t2 SET i = 123 WHERE key1 < 13 or key2 < 14 ORDER BY key1 +# select: SELECT * FROM t2 WHERE key1 < 13 or key2 < 14 ORDER BY key1 +# +EXPLAIN UPDATE t2 SET i = 123 WHERE key1 < 13 or key2 < 14 ORDER BY key1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t2 NULL index_merge key1,key2 key1,key2 5,5 NULL 7 100.00 Using sort_union(key1,key2); Using where; Using filesort +Warnings: +Note 1003 update `test`.`t2` set `test`.`t2`.`i` = 123 where ((`test`.`t2`.`key1` < 13) or (`test`.`t2`.`key2` < 14)) order by `test`.`t2`.`key1` +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t2 SET i = 123 WHERE key1 < 13 or key2 < 14 ORDER BY key1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_filesort": true, + "table": { + "update": true, + "table_name": "t2", + "access_type": "index_merge", + "possible_keys": [ + "key1", + "key2" + ] /* possible_keys */, + "key": "sort_union(key1,key2)", + "key_length": "5,5", + "rows_examined_per_scan": 7, + "filtered": "100.00", + "attached_condition": "((`test`.`t2`.`key1` < 13) or (`test`.`t2`.`key2` < 14))" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t2` set `test`.`t2`.`i` = 123 where ((`test`.`t2`.`key1` < 13) or (`test`.`t2`.`key2` < 14)) order by `test`.`t2`.`key1` +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t2 WHERE key1 < 13 or key2 < 14 ORDER BY key1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "10.73" + } /* cost_info */, + "ordering_operation": { + "using_filesort": true, + "cost_info": { + "sort_cost": "7.00" + } /* cost_info */, + "table": { + "table_name": "t2", + "access_type": "index_merge", + "possible_keys": [ + "key1", + "key2" + ] /* possible_keys */, + "key": "sort_union(key1,key2)", + "key_length": "5,5", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "3.03", + "eval_cost": "0.70", + "prefix_cost": "3.73", + "data_read_per_join": "112" + } /* cost_info */, + "used_columns": [ + "i", + "key1", + "key2" + ] /* used_columns */, + "attached_condition": "((`test`.`t2`.`key1` < 13) or (`test`.`t2`.`key2` < 14))" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`i` AS `i`,`test`.`t2`.`key1` AS `key1`,`test`.`t2`.`key2` AS `key2` from `test`.`t2` where ((`test`.`t2`.`key1` < 13) or (`test`.`t2`.`key2` < 14)) order by `test`.`t2`.`key1` +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 5 +Handler_read_next 7 +Handler_read_rnd 4 +Sort_rows 4 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 5 +Handler_read_next 7 +Handler_read_rnd 8 +Handler_update 4 +Sort_rows 4 +Sort_scan 1 + +DROP TABLE t1, t2; +#46 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2(a INT, i INT PRIMARY KEY); +INSERT INTO t2 (i) SELECT i FROM t1; +# +# query: UPDATE t2 SET a = 10 WHERE i > 10 AND i <= 18 ORDER BY i DESC LIMIT 1 +# select: SELECT * FROM t2 WHERE i > 10 AND i <= 18 ORDER BY i DESC LIMIT 1 +# +EXPLAIN UPDATE t2 SET a = 10 WHERE i > 10 AND i <= 18 ORDER BY i DESC LIMIT 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t2 NULL range PRIMARY PRIMARY 4 const 8 100.00 Using where; Backward index scan; Using temporary +Warnings: +Note 1003 update `test`.`t2` set `test`.`t2`.`a` = 10 where ((`test`.`t2`.`i` > 10) and (`test`.`t2`.`i` <= 18)) order by `test`.`t2`.`i` desc limit 1 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t2 SET a = 10 WHERE i > 10 AND i <= 18 ORDER BY i DESC LIMIT 1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_temporary_table": true, + "using_filesort": false, + "table": { + "update": true, + "table_name": "t2", + "access_type": "range", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "i" + ] /* used_key_parts */, + "key_length": "4", + "ref": [ + "const" + ] /* ref */, + "rows_examined_per_scan": 8, + "filtered": "100.00", + "backward_index_scan": true, + "attached_condition": "((`test`.`t2`.`i` > 10) and (`test`.`t2`.`i` <= 18))" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t2` set `test`.`t2`.`a` = 10 where ((`test`.`t2`.`i` > 10) and (`test`.`t2`.`i` <= 18)) order by `test`.`t2`.`i` desc limit 1 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t2 WHERE i > 10 AND i <= 18 ORDER BY i DESC LIMIT 1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "2.26" + } /* cost_info */, + "ordering_operation": { + "using_filesort": false, + "table": { + "table_name": "t2", + "access_type": "range", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "i" + ] /* used_key_parts */, + "key_length": "4", + "rows_examined_per_scan": 8, + "rows_produced_per_join": 8, + "filtered": "100.00", + "index_condition": "((`test`.`t2`.`i` > 10) and (`test`.`t2`.`i` <= 18))", + "backward_index_scan": true, + "cost_info": { + "read_cost": "1.46", + "eval_cost": "0.80", + "prefix_cost": "2.26", + "data_read_per_join": "128" + } /* cost_info */, + "used_columns": [ + "a", + "i" + ] /* used_columns */ + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`i` AS `i` from `test`.`t2` where ((`test`.`t2`.`i` > 10) and (`test`.`t2`.`i` <= 18)) order by `test`.`t2`.`i` desc limit 1 +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 3 +# Status of testing query execution: +Variable_name Value +Handler_read_key 3 +Handler_read_rnd 1 +Handler_update 1 + +DROP TABLE t1, t2; +#47 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2 (a CHAR(2), b CHAR(2), c CHAR(2), INDEX (a, b)) charset utf8mb4; +INSERT INTO t2 SELECT i, i, i FROM t1; +# +# query: UPDATE t2 SET c = 10 ORDER BY a, b DESC LIMIT 5 +# select: SELECT * FROM t2 ORDER BY a, b DESC LIMIT 5 +# +EXPLAIN UPDATE t2 SET c = 10 ORDER BY a, b DESC LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t2 NULL ALL NULL NULL NULL NULL 26 100.00 Using filesort +Warnings: +Note 1003 update `test`.`t2` set `test`.`t2`.`c` = 10 order by `test`.`t2`.`a`,`test`.`t2`.`b` desc limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t2 SET c = 10 ORDER BY a, b DESC LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_filesort": true, + "table": { + "update": true, + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 26, + "filtered": "100.00" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t2` set `test`.`t2`.`c` = 10 order by `test`.`t2`.`a`,`test`.`t2`.`b` desc limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t2 ORDER BY a, b DESC LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "3.14" + } /* cost_info */, + "ordering_operation": { + "using_filesort": true, + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 26, + "rows_produced_per_join": 26, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.54", + "eval_cost": "2.60", + "prefix_cost": "3.14", + "data_read_per_join": "832" + } /* cost_info */, + "used_columns": [ + "a", + "b", + "c" + ] /* used_columns */ + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c` from `test`.`t2` order by `test`.`t2`.`a`,`test`.`t2`.`b` desc limit 5 +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 3 +Handler_read_rnd_next 27 +Sort_rows 5 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 3 +Handler_read_rnd 5 +Handler_read_rnd_next 27 +Handler_update 4 +Sort_rows 5 +Sort_scan 1 + +DROP TABLE t1, t2; +#48 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2 (a CHAR(2), b CHAR(2), c INT, INDEX (a, b)) charset utf8mb4; +INSERT INTO t2 (a, b) SELECT i, i FROM t1; +INSERT INTO t2 (a, b) SELECT t1.i, t1.i FROM t1, t1 x1, t1 x2; +# +# query: UPDATE t2 SET c = 10 ORDER BY a DESC, b DESC LIMIT 5 +# select: SELECT * FROM t2 ORDER BY a DESC, b DESC LIMIT 5 +# +EXPLAIN UPDATE t2 SET c = 10 ORDER BY a DESC, b DESC LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t2 NULL index NULL a 18 NULL 5 100.00 Using temporary +Warnings: +Note 1003 update `test`.`t2` set `test`.`t2`.`c` = 10 order by `test`.`t2`.`a` desc,`test`.`t2`.`b` desc limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t2 SET c = 10 ORDER BY a DESC, b DESC LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_temporary_table": true, + "using_filesort": false, + "table": { + "update": true, + "table_name": "t2", + "access_type": "index", + "key": "a", + "used_key_parts": [ + "a", + "b" + ] /* used_key_parts */, + "key_length": "18", + "rows_examined_per_scan": 5, + "filtered": "100.00" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t2` set `test`.`t2`.`c` = 10 order by `test`.`t2`.`a` desc,`test`.`t2`.`b` desc limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t2 ORDER BY a DESC, b DESC LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1783.26" + } /* cost_info */, + "ordering_operation": { + "using_filesort": false, + "table": { + "table_name": "t2", + "access_type": "index", + "key": "a", + "used_key_parts": [ + "a", + "b" + ] /* used_key_parts */, + "key_length": "18", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 17602, + "filtered": "100.00", + "backward_index_scan": true, + "cost_info": { + "read_cost": "23.06", + "eval_cost": "1760.20", + "prefix_cost": "1783.26", + "data_read_per_join": "412K" + } /* cost_info */, + "used_columns": [ + "a", + "b", + "c" + ] /* used_columns */ + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c` from `test`.`t2` order by `test`.`t2`.`a` desc,`test`.`t2`.`b` desc limit 5 +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 3 +Handler_read_last 1 +Handler_read_prev 4 +# Status of testing query execution: +Variable_name Value +Handler_read_key 3 +Handler_read_last 1 +Handler_read_prev 4 +Handler_read_rnd 5 +Handler_update 5 + +DROP TABLE t1, t2; +#49 +CREATE TABLE t1 ( +pk INT NOT NULL AUTO_INCREMENT, +c1_idx CHAR(1) DEFAULT 'y', +c2 INT, +PRIMARY KEY (pk), +INDEX c1_idx (c1_idx) +) charset utf8mb4; +INSERT INTO t1 VALUES (1,'y',1), (2,'n',2), (3,'y',3), (4,'n',4); +# +# query: UPDATE t1 SET c2 = 0 WHERE c1_idx = 'y' ORDER BY pk DESC LIMIT 2 +# select: SELECT * FROM t1 WHERE c1_idx = 'y' ORDER BY pk DESC LIMIT 2 +# +EXPLAIN UPDATE t1 SET c2 = 0 WHERE c1_idx = 'y' ORDER BY pk DESC LIMIT 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL range c1_idx c1_idx 5 const 2 100.00 Using where; Using filesort +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`c2` = 0 where (`test`.`t1`.`c1_idx` = 'y') order by `test`.`t1`.`pk` desc limit 2 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t1 SET c2 = 0 WHERE c1_idx = 'y' ORDER BY pk DESC LIMIT 2;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_filesort": true, + "table": { + "update": true, + "table_name": "t1", + "access_type": "range", + "possible_keys": [ + "c1_idx" + ] /* possible_keys */, + "key": "c1_idx", + "used_key_parts": [ + "c1_idx" + ] /* used_key_parts */, + "key_length": "5", + "ref": [ + "const" + ] /* ref */, + "rows_examined_per_scan": 2, + "filtered": "100.00", + "attached_condition": "(`test`.`t1`.`c1_idx` = 'y')" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`c2` = 0 where (`test`.`t1`.`c1_idx` = 'y') order by `test`.`t1`.`pk` desc limit 2 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 WHERE c1_idx = 'y' ORDER BY pk DESC LIMIT 2;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.70" + } /* cost_info */, + "ordering_operation": { + "using_filesort": true, + "table": { + "table_name": "t1", + "access_type": "ref", + "possible_keys": [ + "c1_idx" + ] /* possible_keys */, + "key": "c1_idx", + "used_key_parts": [ + "c1_idx" + ] /* used_key_parts */, + "key_length": "5", + "ref": [ + "const" + ] /* ref */, + "rows_examined_per_scan": 2, + "rows_produced_per_join": 2, + "filtered": "100.00", + "index_condition": "(`test`.`t1`.`c1_idx` = 'y')", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.20", + "prefix_cost": "0.70", + "data_read_per_join": "32" + } /* cost_info */, + "used_columns": [ + "pk", + "c1_idx", + "c2" + ] /* used_columns */ + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`c1_idx` AS `c1_idx`,`test`.`t1`.`c2` AS `c2` from `test`.`t1` where (`test`.`t1`.`c1_idx` = 'y') order by `test`.`t1`.`pk` desc limit 2 +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 4 +Handler_read_next 2 +Sort_rows 2 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 4 +Handler_read_next 2 +Handler_read_rnd 2 +Handler_update 2 +Sort_rows 2 +Sort_scan 1 + +# +# query: DELETE FROM t1 WHERE c1_idx = 'y' ORDER BY pk DESC LIMIT 2 +# select: SELECT * FROM t1 WHERE c1_idx = 'y' ORDER BY pk DESC LIMIT 2 +# +EXPLAIN DELETE FROM t1 WHERE c1_idx = 'y' ORDER BY pk DESC LIMIT 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL range c1_idx c1_idx 5 const 2 100.00 Using where; Using filesort +Warnings: +Note 1003 delete from `test`.`t1` where (`test`.`t1`.`c1_idx` = 'y') order by `test`.`t1`.`pk` desc limit 2 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t1 WHERE c1_idx = 'y' ORDER BY pk DESC LIMIT 2;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_filesort": true, + "table": { + "delete": true, + "table_name": "t1", + "access_type": "range", + "possible_keys": [ + "c1_idx" + ] /* possible_keys */, + "key": "c1_idx", + "used_key_parts": [ + "c1_idx" + ] /* used_key_parts */, + "key_length": "5", + "ref": [ + "const" + ] /* ref */, + "rows_examined_per_scan": 2, + "filtered": "100.00", + "attached_condition": "(`test`.`t1`.`c1_idx` = 'y')" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 delete from `test`.`t1` where (`test`.`t1`.`c1_idx` = 'y') order by `test`.`t1`.`pk` desc limit 2 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 WHERE c1_idx = 'y' ORDER BY pk DESC LIMIT 2;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.70" + } /* cost_info */, + "ordering_operation": { + "using_filesort": true, + "table": { + "table_name": "t1", + "access_type": "ref", + "possible_keys": [ + "c1_idx" + ] /* possible_keys */, + "key": "c1_idx", + "used_key_parts": [ + "c1_idx" + ] /* used_key_parts */, + "key_length": "5", + "ref": [ + "const" + ] /* ref */, + "rows_examined_per_scan": 2, + "rows_produced_per_join": 2, + "filtered": "100.00", + "index_condition": "(`test`.`t1`.`c1_idx` = 'y')", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.20", + "prefix_cost": "0.70", + "data_read_per_join": "32" + } /* cost_info */, + "used_columns": [ + "pk", + "c1_idx", + "c2" + ] /* used_columns */ + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`c1_idx` AS `c1_idx`,`test`.`t1`.`c2` AS `c2` from `test`.`t1` where (`test`.`t1`.`c1_idx` = 'y') order by `test`.`t1`.`pk` desc limit 2 +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 4 +Handler_read_next 2 +Sort_rows 2 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_delete 2 +Handler_read_key 4 +Handler_read_next 2 +Handler_read_rnd 2 +Sort_rows 2 +Sort_scan 1 + +DROP TABLE t1; +#50 +CREATE TABLE t1 (a INT AUTO_INCREMENT PRIMARY KEY); +INSERT INTO t1 VALUES (),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(); +# +# query: UPDATE t1 SET a=a+10 WHERE a > 34 +# select: SELECT * FROM t1 WHERE a > 34 +# +EXPLAIN UPDATE t1 SET a=a+10 WHERE a > 34; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL range PRIMARY PRIMARY 4 const 3 100.00 Using where; Using temporary +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`a` = (`test`.`t1`.`a` + 10) where (`test`.`t1`.`a` > 34) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t1 SET a=a+10 WHERE a > 34;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "table": { + "update": true, + "table_name": "t1", + "access_type": "range", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "a" + ] /* used_key_parts */, + "key_length": "4", + "ref": [ + "const" + ] /* ref */, + "rows_examined_per_scan": 3, + "filtered": "100.00", + "using_temporary_table": "for update", + "attached_condition": "(`test`.`t1`.`a` > 34)" + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`a` = (`test`.`t1`.`a` + 10) where (`test`.`t1`.`a` > 34) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 WHERE a > 34;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.87" + } /* cost_info */, + "table": { + "table_name": "t1", + "access_type": "range", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "a" + ] /* used_key_parts */, + "key_length": "4", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "using_index": true, + "cost_info": { + "read_cost": "0.57", + "eval_cost": "0.30", + "prefix_cost": "0.87", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`a` > 34)" + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` > 34) +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_next 2 +# Status of testing query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_next 2 +Handler_read_rnd 2 +Handler_update 2 + +DROP TABLE t1; +#51 +CREATE TABLE t1 (c1 INT, c2 INT, c3 INT); +CREATE TABLE t2 (c1 INT, c2 INT); +INSERT INTO t1 VALUES (1, 1, 10), (2, 2, 20); +# +# query: UPDATE t1 LEFT JOIN t2 ON t1.c1 = t2.c1 SET t2.c2 = 10 +# select: SELECT * FROM t1 LEFT JOIN t2 ON t1.c1 = t2.c1 +# +EXPLAIN UPDATE t1 LEFT JOIN t2 ON t1.c1 = t2.c1 SET t2.c2 = 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t2 NULL system NULL NULL NULL NULL 0 0.00 const row not found +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 update `test`.`t1` left join `test`.`t2` on(multiple equal(`test`.`t1`.`c1`, `test`.`t2`.`c1`)) set `test`.`t2`.`c2` = 10 where true +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t1 LEFT JOIN t2 ON t1.c1 = t2.c1 SET t2.c2 = 10;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.70" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "update": true, + "table_name": "t2", + "access_type": "system", + "rows_examined_per_scan": 0, + "rows_produced_per_join": 1, + "filtered": "0.00", + "const_row_not_found": true, + "cost_info": { + "read_cost": "0.00", + "eval_cost": "0.10", + "prefix_cost": "0.00", + "data_read_per_join": "16" + } /* cost_info */, + "used_columns": [ + "c1", + "c2" + ] /* used_columns */ + } /* table */ + }, + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 2, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.20", + "prefix_cost": "0.70", + "data_read_per_join": "32" + } /* cost_info */, + "used_columns": [ + "c1" + ] /* used_columns */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t1` left join `test`.`t2` on(multiple equal(`test`.`t1`.`c1`, `test`.`t2`.`c1`)) set `test`.`t2`.`c2` = 10 where true +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 LEFT JOIN t2 ON t1.c1 = t2.c1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.70" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "system", + "rows_examined_per_scan": 0, + "rows_produced_per_join": 1, + "filtered": "0.00", + "const_row_not_found": true, + "cost_info": { + "read_cost": "0.00", + "eval_cost": "0.10", + "prefix_cost": "0.00", + "data_read_per_join": "16" + } /* cost_info */, + "used_columns": [ + "c1", + "c2" + ] /* used_columns */ + } /* table */ + }, + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 2, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.20", + "prefix_cost": "0.70", + "data_read_per_join": "32" + } /* cost_info */, + "used_columns": [ + "c1", + "c2", + "c3" + ] /* used_columns */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c1` AS `c1`,`test`.`t1`.`c2` AS `c2`,`test`.`t1`.`c3` AS `c3`,NULL AS `c1`,NULL AS `c2` from `test`.`t1` where true +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 5 +Handler_read_rnd_next 4 +# Status of testing query execution: +Variable_name Value +Handler_read_key 5 +Handler_read_rnd_next 4 + +# +# query: UPDATE t1 LEFT JOIN t2 ON t1.c1 = t2.c1 SET t2.c2 = 10 WHERE t1.c3 = 10 +# select: SELECT * FROM t1 LEFT JOIN t2 ON t1.c1 = t2.c1 WHERE t1.c3 = 10 +# +EXPLAIN UPDATE t1 LEFT JOIN t2 ON t1.c1 = t2.c1 SET t2.c2 = 10 WHERE t1.c3 = 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t2 NULL system NULL NULL NULL NULL 0 0.00 const row not found +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1003 update `test`.`t1` left join `test`.`t2` on(multiple equal(`test`.`t1`.`c1`, `test`.`t2`.`c1`)) set `test`.`t2`.`c2` = 10 where (`test`.`t1`.`c3` = 10) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t1 LEFT JOIN t2 ON t1.c1 = t2.c1 SET t2.c2 = 10 WHERE t1.c3 = 10;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.70" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "update": true, + "table_name": "t2", + "access_type": "system", + "rows_examined_per_scan": 0, + "rows_produced_per_join": 1, + "filtered": "0.00", + "const_row_not_found": true, + "cost_info": { + "read_cost": "0.00", + "eval_cost": "0.10", + "prefix_cost": "0.00", + "data_read_per_join": "16" + } /* cost_info */, + "used_columns": [ + "c1", + "c2" + ] /* used_columns */ + } /* table */ + }, + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 1, + "filtered": "50.00", + "cost_info": { + "read_cost": "0.60", + "eval_cost": "0.10", + "prefix_cost": "0.70", + "data_read_per_join": "16" + } /* cost_info */, + "used_columns": [ + "c1", + "c3" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`c3` = 10)" + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t1` left join `test`.`t2` on(multiple equal(`test`.`t1`.`c1`, `test`.`t2`.`c1`)) set `test`.`t2`.`c2` = 10 where (`test`.`t1`.`c3` = 10) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 LEFT JOIN t2 ON t1.c1 = t2.c1 WHERE t1.c3 = 10;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.70" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "system", + "rows_examined_per_scan": 0, + "rows_produced_per_join": 1, + "filtered": "0.00", + "const_row_not_found": true, + "cost_info": { + "read_cost": "0.00", + "eval_cost": "0.10", + "prefix_cost": "0.00", + "data_read_per_join": "16" + } /* cost_info */, + "used_columns": [ + "c1", + "c2" + ] /* used_columns */ + } /* table */ + }, + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 1, + "filtered": "50.00", + "cost_info": { + "read_cost": "0.60", + "eval_cost": "0.10", + "prefix_cost": "0.70", + "data_read_per_join": "16" + } /* cost_info */, + "used_columns": [ + "c1", + "c2", + "c3" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`c3` = 10)" + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c1` AS `c1`,`test`.`t1`.`c2` AS `c2`,`test`.`t1`.`c3` AS `c3`,NULL AS `c1`,NULL AS `c2` from `test`.`t1` where (`test`.`t1`.`c3` = 10) +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 5 +Handler_read_rnd_next 4 +# Status of testing query execution: +Variable_name Value +Handler_read_key 5 +Handler_read_rnd_next 4 + +DROP TABLE t1, t2; +#52 +CREATE TABLE t1(f1 INT, f2 INT); +CREATE TABLE t2(f3 INT, f4 INT); +CREATE INDEX IDX ON t2(f3); +INSERT INTO t1 VALUES(1,0),(2,0); +INSERT INTO t2 VALUES(1,1),(2,2); +# +# query: UPDATE t1 SET t1.f2=(SELECT MAX(t2.f4) FROM t2 WHERE t2.f3=t1.f1) +# select: SELECT (SELECT MAX(t2.f4) FROM t2 WHERE t2.f3=t1.f1) FROM t1 +# +EXPLAIN UPDATE t1 SET t1.f2=(SELECT MAX(t2.f4) FROM t2 WHERE t2.f3=t1.f1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DEPENDENT SUBQUERY t2 NULL ref IDX IDX 5 test.t1.f1 1 100.00 NULL +Warnings: +Note 1276 Field or reference 'test.t1.f1' of SELECT #2 was resolved in SELECT #1 +Note 1003 update `test`.`t1` set `test`.`t1`.`f2` = (/* select#2 */ select max(`test`.`t2`.`f4`) from `test`.`t2` where (`test`.`t2`.`f3` = `test`.`t1`.`f1`)) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t1 SET t1.f2=(SELECT MAX(t2.f4) FROM t2 WHERE t2.f3=t1.f1);; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "table": { + "update": true, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "filtered": "100.00" + } /* table */, + "update_value_subqueries": [ + { + "dependent": true, + "cacheable": false, + "query_block": { + "select_id": 2, + "cost_info": { + "query_cost": "0.35" + } /* cost_info */, + "table": { + "table_name": "t2", + "access_type": "ref", + "possible_keys": [ + "IDX" + ] /* possible_keys */, + "key": "IDX", + "used_key_parts": [ + "f3" + ] /* used_key_parts */, + "key_length": "5", + "ref": [ + "test.t1.f1" + ] /* ref */, + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.10", + "prefix_cost": "0.35", + "data_read_per_join": "16" + } /* cost_info */, + "used_columns": [ + "f3", + "f4" + ] /* used_columns */ + } /* table */ + } /* query_block */ + } + ] /* update_value_subqueries */ + } /* query_block */ +} +Warnings: +Note 1276 Field or reference 'test.t1.f1' of SELECT #2 was resolved in SELECT #1 +Note 1003 update `test`.`t1` set `test`.`t1`.`f2` = (/* select#2 */ select max(`test`.`t2`.`f4`) from `test`.`t2` where (`test`.`t2`.`f3` = `test`.`t1`.`f1`)) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT (SELECT MAX(t2.f4) FROM t2 WHERE t2.f3=t1.f1) FROM t1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.70" + } /* cost_info */, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 2, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.20", + "prefix_cost": "0.70", + "data_read_per_join": "32" + } /* cost_info */, + "used_columns": [ + "f1" + ] /* used_columns */ + } /* table */, + "select_list_subqueries": [ + { + "dependent": true, + "cacheable": false, + "query_block": { + "select_id": 2, + "cost_info": { + "query_cost": "0.35" + } /* cost_info */, + "table": { + "table_name": "t2", + "access_type": "ref", + "possible_keys": [ + "IDX" + ] /* possible_keys */, + "key": "IDX", + "used_key_parts": [ + "f3" + ] /* used_key_parts */, + "key_length": "5", + "ref": [ + "test.t1.f1" + ] /* ref */, + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.10", + "prefix_cost": "0.35", + "data_read_per_join": "16" + } /* cost_info */, + "used_columns": [ + "f3", + "f4" + ] /* used_columns */ + } /* table */ + } /* query_block */ + } + ] /* select_list_subqueries */ + } /* query_block */ +} +Warnings: +Note 1276 Field or reference 'test.t1.f1' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select (/* select#2 */ select max(`test`.`t2`.`f4`) from `test`.`t2` where (`test`.`t2`.`f3` = `test`.`t1`.`f1`)) AS `(SELECT MAX(t2.f4) FROM t2 WHERE t2.f3=t1.f1)` from `test`.`t1` +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 6 +Handler_read_next 2 +Handler_read_rnd_next 3 +# Status of testing query execution: +Variable_name Value +Handler_read_key 6 +Handler_read_next 2 +Handler_read_rnd_next 3 +Handler_update 2 + +DROP TABLE t1, t2; +#55 +CREATE TABLE t1(a INT); +INSERT INTO t1 VALUES (1); +SET @a = NULL; +EXPLAIN DELETE FROM t1 WHERE (@a:= a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +Note 1003 delete from `test`.`t1` where (0 <> (@a:=`test`.`t1`.`a`)) +DROP TABLE t1; +#56 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +DELETE FROM t1 USING t1 WHERE uknown_column = 12345; +ERROR 42S22: Unknown column 'uknown_column' in 'where clause' +EXPLAIN DELETE FROM t1 USING t1 WHERE uknown_column = 12345; +ERROR 42S22: Unknown column 'uknown_column' in 'where clause' +DROP TABLE t1; +#57 +CREATE TABLE t1(f1 INT); +EXPLAIN UPDATE t1 SET f2=1 ORDER BY f2; +ERROR 42S22: Unknown column 'f2' in 'field list' +UPDATE t1 SET f2=1 ORDER BY f2; +ERROR 42S22: Unknown column 'f2' in 'field list' +DROP TABLE t1; +#59 +CREATE TABLE t1 ( a INT, KEY( a ) ); +INSERT INTO t1 VALUES (0), (1); +CREATE VIEW v1 AS SELECT t11.a, t12.a AS b FROM t1 t11, t1 t12; +SET SESSION sql_safe_updates = 1; +EXPLAIN UPDATE IGNORE v1 SET a = 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t11 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t12 NULL index NULL a 5 NULL 2 100.00 Using index +Warnings: +Note 1003 update ignore (`test`.`t1` `t11` join `test`.`t1` `t12`) set `t11`.`a` = 1 +UPDATE IGNORE v1 SET a = 1; +ERROR HY000: You are using safe update mode and you tried to update a table without a WHERE that uses a KEY column. +SET SESSION sql_safe_updates = DEFAULT; +DROP TABLE t1; +DROP VIEW v1; +#62 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (0), (1); +CREATE VIEW v1 AS SELECT t11.a, t12.a AS b FROM t1 t11, t1 t12; +# +# query: UPDATE v1 SET a = 1 WHERE a > 0 +# select: SELECT * FROM v1 WHERE a > 0 +# +EXPLAIN UPDATE v1 SET a = 1 WHERE a > 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t11 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t12 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 update (`test`.`t1` `t11` join `test`.`t1` `t12`) set `t11`.`a` = 1 where (`t11`.`a` > 0) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE v1 SET a = 1 WHERE a > 0;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.40" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "update": true, + "table_name": "t11", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 1, + "filtered": "50.00", + "cost_info": { + "read_cost": "0.60", + "eval_cost": "0.10", + "prefix_cost": "0.70", + "data_read_per_join": "8" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t11`.`a` > 0)" + } /* table */ + }, + { + "table": { + "table_name": "t12", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 2, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.20", + "prefix_cost": "1.40", + "data_read_per_join": "16" + } /* cost_info */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 update (`test`.`t1` `t11` join `test`.`t1` `t12`) set `test`.`t11`.`a` = 1 where (`test`.`t11`.`a` > 0) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM v1 WHERE a > 0;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.40" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "table_name": "t11", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 1, + "filtered": "50.00", + "cost_info": { + "read_cost": "0.60", + "eval_cost": "0.10", + "prefix_cost": "0.70", + "data_read_per_join": "8" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t11`.`a` > 0)" + } /* table */ + }, + { + "table": { + "table_name": "t12", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 2, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.20", + "prefix_cost": "1.40", + "data_read_per_join": "16" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t11`.`a` AS `a`,`test`.`t12`.`a` AS `b` from `test`.`t1` `t11` join `test`.`t1` `t12` where (`test`.`t11`.`a` > 0) +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 1 +Handler_read_rnd_next 6 +# Status of testing query execution: +Variable_name Value +Handler_read_key 1 +Handler_read_rnd 1 +Handler_read_rnd_next 8 +Handler_write 2 + +# +# query: UPDATE t1, v1 SET v1.a = 1 WHERE t1.a = v1.a +# select: SELECT * FROM t1, v1 WHERE t1.a = v1.a +# +EXPLAIN UPDATE t1, v1 SET v1.a = 1 WHERE t1.a = v1.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 UPDATE t11 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t12 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 update `test`.`t1` join `test`.`t1` `t11` join `test`.`t1` `t12` set `test`.`t11`.`a` = 1 where (`test`.`t11`.`a` = `test`.`t1`.`a`) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t1, v1 SET v1.a = 1 WHERE t1.a = v1.a;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "2.50" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 2, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.20", + "prefix_cost": "0.70", + "data_read_per_join": "16" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */ + } /* table */ + }, + { + "table": { + "update": true, + "table_name": "t11", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 2, + "filtered": "50.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.20", + "prefix_cost": "1.60", + "data_read_per_join": "16" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t11`.`a` = `test`.`t1`.`a`)" + } /* table */ + }, + { + "table": { + "table_name": "t12", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 4, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.40", + "prefix_cost": "2.50", + "data_read_per_join": "32" + } /* cost_info */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t1` join `test`.`t1` `t11` join `test`.`t1` `t12` set `test`.`t11`.`a` = 1 where (`test`.`t11`.`a` = `test`.`t1`.`a`) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1, v1 WHERE t1.a = v1.a;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "2.50" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 2, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.20", + "prefix_cost": "0.70", + "data_read_per_join": "16" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */ + } /* table */ + }, + { + "table": { + "table_name": "t11", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 2, + "filtered": "50.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.20", + "prefix_cost": "1.60", + "data_read_per_join": "16" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t11`.`a` = `test`.`t1`.`a`)" + } /* table */ + }, + { + "table": { + "table_name": "t12", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 4, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.40", + "prefix_cost": "2.50", + "data_read_per_join": "32" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t11`.`a` AS `a`,`test`.`t12`.`a` AS `b` from `test`.`t1` join `test`.`t1` `t11` join `test`.`t1` `t12` where (`test`.`t11`.`a` = `test`.`t1`.`a`) +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 1 +Handler_read_rnd_next 9 +# Status of testing query execution: +Variable_name Value +Handler_read_key 1 +Handler_read_rnd 2 +Handler_read_rnd_next 18 +Handler_update 1 +Handler_write 4 + +DROP TABLE t1; +DROP VIEW v1; +#63 +CREATE TABLE t1 (a INT, PRIMARY KEY(a)); +INSERT INTO t1 VALUES (1), (2), (3), (4), (5); +CREATE VIEW v1 (a) AS SELECT a FROM t1; +# +# query: DELETE FROM v1 WHERE a < 4 +# select: SELECT * FROM v1 WHERE a < 4 +# +EXPLAIN DELETE FROM v1 WHERE a < 4; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL range PRIMARY PRIMARY 4 const 3 100.00 Using where +Warnings: +Note 1003 delete from (`test`.`t1`) where (`test`.`t1`.`a` < 4) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM v1 WHERE a < 4;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "table": { + "delete": true, + "table_name": "t1", + "access_type": "range", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "a" + ] /* used_key_parts */, + "key_length": "4", + "ref": [ + "const" + ] /* ref */, + "rows_examined_per_scan": 3, + "filtered": "100.00", + "attached_condition": "(`test`.`t1`.`a` < 4)" + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 delete from (`test`.`t1`) where (`test`.`t1`.`a` < 4) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM v1 WHERE a < 4;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.87" + } /* cost_info */, + "table": { + "table_name": "t1", + "access_type": "range", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "a" + ] /* used_key_parts */, + "key_length": "4", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "using_index": true, + "cost_info": { + "read_cost": "0.57", + "eval_cost": "0.30", + "prefix_cost": "0.87", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`a` < 4)" + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` < 4) +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 1 +Handler_read_next 3 +# Status of testing query execution: +Variable_name Value +Handler_delete 3 +Handler_read_first 1 +Handler_read_key 1 +Handler_read_next 3 + +DROP TABLE t1; +DROP VIEW v1; +#64 +CREATE TABLE t1 (a INT, b INT, PRIMARY KEY(a)); +INSERT INTO t1 VALUES (1,2), (2,3), (3,4), (4,5), (5,10); +CREATE TABLE t2 (x INT); +INSERT INTO t2 VALUES (1), (2), (3), (4); +CREATE VIEW v1 (a,c) AS SELECT a, b+1 FROM t1; +# +# query: DELETE v1 FROM t2, v1 WHERE t2.x = v1.a +# select: SELECT * FROM t2, v1 WHERE t2.x = v1.a +# +EXPLAIN DELETE v1 FROM t2, v1 WHERE t2.x = v1.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +1 DELETE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.x 1 100.00 NULL +Warnings: +Note 1003 delete `test`.`t1` from `test`.`t2` join `test`.`t1` where (`test`.`t1`.`a` = `test`.`t2`.`x`) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE v1 FROM t2, v1 WHERE t2.x = v1.a;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "2.30" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 4, + "rows_produced_per_join": 4, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.40", + "prefix_cost": "0.90", + "data_read_per_join": "32" + } /* cost_info */, + "used_columns": [ + "x" + ] /* used_columns */, + "attached_condition": "(`test`.`t2`.`x` is not null)" + } /* table */ + }, + { + "table": { + "delete": true, + "table_name": "t1", + "access_type": "eq_ref", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "a" + ] /* used_key_parts */, + "key_length": "4", + "ref": [ + "test.t2.x" + ] /* ref */, + "rows_examined_per_scan": 1, + "rows_produced_per_join": 4, + "filtered": "100.00", + "cost_info": { + "read_cost": "1.00", + "eval_cost": "0.40", + "prefix_cost": "2.30", + "data_read_per_join": "64" + } /* cost_info */, + "used_columns": [ + "a", + "b" + ] /* used_columns */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 delete `test`.`t1` from `test`.`t2` join `test`.`t1` where (`test`.`t1`.`a` = `test`.`t2`.`x`) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t2, v1 WHERE t2.x = v1.a;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "2.30" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 4, + "rows_produced_per_join": 4, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.40", + "prefix_cost": "0.90", + "data_read_per_join": "32" + } /* cost_info */, + "used_columns": [ + "x" + ] /* used_columns */, + "attached_condition": "(`test`.`t2`.`x` is not null)" + } /* table */ + }, + { + "table": { + "table_name": "t1", + "access_type": "eq_ref", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "a" + ] /* used_key_parts */, + "key_length": "4", + "ref": [ + "test.t2.x" + ] /* ref */, + "rows_examined_per_scan": 1, + "rows_produced_per_join": 4, + "filtered": "100.00", + "cost_info": { + "read_cost": "1.00", + "eval_cost": "0.40", + "prefix_cost": "2.30", + "data_read_per_join": "64" + } /* cost_info */, + "used_columns": [ + "a", + "b" + ] /* used_columns */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`x` AS `x`,`test`.`t1`.`a` AS `a`,(`test`.`t1`.`b` + 1) AS `c` from `test`.`t2` join `test`.`t1` where (`test`.`t1`.`a` = `test`.`t2`.`x`) +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 7 +Handler_read_rnd_next 5 +# Status of testing query execution: +Variable_name Value +Handler_delete 4 +Handler_read_key 7 +Handler_read_rnd 4 +Handler_read_rnd_next 5 + +DROP TABLE t1,t2; +DROP VIEW v1; +#65 +CREATE TABLE t1 (a INT, b INT, PRIMARY KEY(a)); +INSERT INTO t1 VALUES (1,2), (2,3), (3,4), (4,5), (5,10); +CREATE TABLE t2 (x INT); +INSERT INTO t2 VALUES (1), (2), (3), (4); +CREATE VIEW v1 (a,c) AS SELECT a, b+1 FROM t1; +# +# query: DELETE v1 FROM t2, v1 WHERE t2.x = v1.a +# select: SELECT * FROM t2, v1 WHERE t2.x = v1.a +# +EXPLAIN DELETE v1 FROM t2, v1 WHERE t2.x = v1.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +1 DELETE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.x 1 100.00 NULL +Warnings: +Note 1003 delete `test`.`t1` from `test`.`t2` join `test`.`t1` where (`test`.`t1`.`a` = `test`.`t2`.`x`) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE v1 FROM t2, v1 WHERE t2.x = v1.a;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "2.30" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 4, + "rows_produced_per_join": 4, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.40", + "prefix_cost": "0.90", + "data_read_per_join": "32" + } /* cost_info */, + "used_columns": [ + "x" + ] /* used_columns */, + "attached_condition": "(`test`.`t2`.`x` is not null)" + } /* table */ + }, + { + "table": { + "delete": true, + "table_name": "t1", + "access_type": "eq_ref", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "a" + ] /* used_key_parts */, + "key_length": "4", + "ref": [ + "test.t2.x" + ] /* ref */, + "rows_examined_per_scan": 1, + "rows_produced_per_join": 4, + "filtered": "100.00", + "cost_info": { + "read_cost": "1.00", + "eval_cost": "0.40", + "prefix_cost": "2.30", + "data_read_per_join": "64" + } /* cost_info */, + "used_columns": [ + "a", + "b" + ] /* used_columns */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 delete `test`.`t1` from `test`.`t2` join `test`.`t1` where (`test`.`t1`.`a` = `test`.`t2`.`x`) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t2, v1 WHERE t2.x = v1.a;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "2.30" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 4, + "rows_produced_per_join": 4, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.40", + "prefix_cost": "0.90", + "data_read_per_join": "32" + } /* cost_info */, + "used_columns": [ + "x" + ] /* used_columns */, + "attached_condition": "(`test`.`t2`.`x` is not null)" + } /* table */ + }, + { + "table": { + "table_name": "t1", + "access_type": "eq_ref", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "a" + ] /* used_key_parts */, + "key_length": "4", + "ref": [ + "test.t2.x" + ] /* ref */, + "rows_examined_per_scan": 1, + "rows_produced_per_join": 4, + "filtered": "100.00", + "cost_info": { + "read_cost": "1.00", + "eval_cost": "0.40", + "prefix_cost": "2.30", + "data_read_per_join": "64" + } /* cost_info */, + "used_columns": [ + "a", + "b" + ] /* used_columns */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`x` AS `x`,`test`.`t1`.`a` AS `a`,(`test`.`t1`.`b` + 1) AS `c` from `test`.`t2` join `test`.`t1` where (`test`.`t1`.`a` = `test`.`t2`.`x`) +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 7 +Handler_read_rnd_next 5 +# Status of testing query execution: +Variable_name Value +Handler_delete 4 +Handler_read_key 7 +Handler_read_rnd 4 +Handler_read_rnd_next 5 + +DROP TABLE t1,t2; +DROP VIEW v1; +#66 +CREATE TABLE t1 (a INT); +CREATE VIEW v1 (x) AS SELECT a FROM t1; +# +# query: INSERT INTO v1 VALUES (10) +# select: SELECT NULL +# +EXPLAIN INSERT INTO v1 VALUES (10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 INSERT t1 NULL ALL NULL NULL NULL NULL NULL NULL NULL +Warnings: +Note 1003 insert into `test`.`t1` values (10) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON INSERT INTO v1 VALUES (10);; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "table": { + "insert": true, + "table_name": "t1", + "access_type": "ALL" + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 insert into `test`.`t1` values (10) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT NULL;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "message": "No tables used" + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select NULL AS `NULL` +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +# Status of testing query execution: +Variable_name Value +Handler_read_key 1 +Handler_write 1 + +DROP TABLE t1; +DROP VIEW v1; +#67 +CREATE TABLE t1 (a INT); +CREATE TABLE t2 (b INT); +INSERT INTO t2 VALUES (1), (2), (3); +CREATE VIEW v1 (x) AS SELECT b FROM t2; +# +# query: INSERT INTO v1 SELECT * FROM t1 +# select: SELECT * FROM t1 +# +EXPLAIN INSERT INTO v1 SELECT * FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 INSERT NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 insert into `test`.`t2` /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON INSERT INTO v1 SELECT * FROM t1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "message": "no matching row in const table" + } /* query_block */ +} +Warnings: +Note 1003 insert into `test`.`t2` /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "message": "no matching row in const table" + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select NULL AS `a` from `test`.`t1` +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 1 +Handler_read_rnd_next 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 1 + +DROP TABLE t1, t2; +DROP VIEW v1; +#69 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +CREATE TABLE t2 (b INT); +INSERT INTO t2 VALUES (1), (2), (3); +# +# query: UPDATE t1 SET a = 10 WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x) +# select: SELECT * FROM t1 WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x) +# +EXPLAIN UPDATE t1 SET a = 10 WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 PRIMARY NULL ref 5 test.t1.a 2 100.00 Using index; FirstMatch(t1) +3 DERIVED t2 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`a` = 10 where (`x`.`b` = `test`.`t1`.`a`) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t1 SET a = 10 WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x);; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "2.90" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "update": true, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.30", + "prefix_cost": "0.80", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`a` is not null)" + } /* table */ + }, + { + "table": { + "table_name": "x", + "access_type": "ref", + "possible_keys": [ + "" + ] /* possible_keys */, + "key": "", + "used_key_parts": [ + "b" + ] /* used_key_parts */, + "key_length": "5", + "ref": [ + "test.t1.a" + ] /* ref */, + "rows_examined_per_scan": 2, + "rows_produced_per_join": 3, + "filtered": "100.00", + "using_index": true, + "first_match": "t1", + "cost_info": { + "read_cost": "1.50", + "eval_cost": "0.30", + "prefix_cost": "2.90", + "data_read_per_join": "48" + } /* cost_info */, + "used_columns": [ + "b" + ] /* used_columns */, + "materialized_from_subquery": { + "using_temporary_table": true, + "dependent": false, + "cacheable": true, + "query_block": { + "select_id": 3, + "cost_info": { + "query_cost": "3.80" + } /* cost_info */, + "ordering_operation": { + "using_filesort": true, + "cost_info": { + "sort_cost": "3.00" + } /* cost_info */, + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.30", + "prefix_cost": "0.80", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "b" + ] /* used_columns */ + } /* table */ + } /* ordering_operation */ + } /* query_block */ + } /* materialized_from_subquery */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`a` = 10 where (`x`.`b` = `test`.`t1`.`a`) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x);; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "2.90" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.30", + "prefix_cost": "0.80", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`a` is not null)" + } /* table */ + }, + { + "table": { + "table_name": "x", + "access_type": "ref", + "possible_keys": [ + "" + ] /* possible_keys */, + "key": "", + "used_key_parts": [ + "b" + ] /* used_key_parts */, + "key_length": "5", + "ref": [ + "test.t1.a" + ] /* ref */, + "rows_examined_per_scan": 2, + "rows_produced_per_join": 3, + "filtered": "100.00", + "using_index": true, + "first_match": "t1", + "cost_info": { + "read_cost": "1.50", + "eval_cost": "0.30", + "prefix_cost": "2.90", + "data_read_per_join": "48" + } /* cost_info */, + "used_columns": [ + "b" + ] /* used_columns */, + "materialized_from_subquery": { + "using_temporary_table": true, + "dependent": false, + "cacheable": true, + "query_block": { + "select_id": 3, + "cost_info": { + "query_cost": "3.80" + } /* cost_info */, + "ordering_operation": { + "using_filesort": true, + "cost_info": { + "sort_cost": "3.00" + } /* cost_info */, + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.30", + "prefix_cost": "0.80", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "b" + ] /* used_columns */ + } /* table */ + } /* ordering_operation */ + } /* query_block */ + } /* materialized_from_subquery */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join ((/* select#3 */ select `test`.`t2`.`b` AS `b` from `test`.`t2` order by `test`.`t2`.`b` limit 2,2) `x`) where (`x`.`b` = `test`.`t1`.`a`) +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 5 +Handler_read_rnd_next 8 +Handler_write 1 +Sort_rows 3 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 5 +Handler_read_rnd_next 8 +Handler_update 1 +Handler_write 1 +Sort_rows 3 +Sort_scan 1 + +# +# query: UPDATE t1, t2 SET a = 10 WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x) +# select: SELECT * FROM t1, t2 WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x) +# +EXPLAIN UPDATE t1, t2 SET a = 10 WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 PRIMARY NULL ref 5 test.t1.a 2 100.00 Using index; FirstMatch(t1) +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +3 DERIVED t2 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 update `test`.`t1` join `test`.`t2` semi join ((/* select#3 */ select `test`.`t2`.`b` AS `b` from `test`.`t2` order by `test`.`t2`.`b` limit 2,2) `x`) set `test`.`t1`.`a` = 10 where (`x`.`b` = `test`.`t1`.`a`) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t1, t2 SET a = 10 WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x);; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "4.30" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "update": true, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.30", + "prefix_cost": "0.80", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`a` is not null)" + } /* table */ + }, + { + "table": { + "table_name": "x", + "access_type": "ref", + "possible_keys": [ + "" + ] /* possible_keys */, + "key": "", + "used_key_parts": [ + "b" + ] /* used_key_parts */, + "key_length": "5", + "ref": [ + "test.t1.a" + ] /* ref */, + "rows_examined_per_scan": 2, + "rows_produced_per_join": 3, + "filtered": "100.00", + "using_index": true, + "first_match": "t1", + "cost_info": { + "read_cost": "1.50", + "eval_cost": "0.30", + "prefix_cost": "2.90", + "data_read_per_join": "48" + } /* cost_info */, + "used_columns": [ + "b" + ] /* used_columns */, + "materialized_from_subquery": { + "using_temporary_table": true, + "dependent": false, + "cacheable": true, + "query_block": { + "select_id": 3, + "cost_info": { + "query_cost": "3.80" + } /* cost_info */, + "ordering_operation": { + "using_filesort": true, + "cost_info": { + "sort_cost": "3.00" + } /* cost_info */, + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.30", + "prefix_cost": "0.80", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "b" + ] /* used_columns */ + } /* table */ + } /* ordering_operation */ + } /* query_block */ + } /* materialized_from_subquery */ + } /* table */ + }, + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 9, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.90", + "prefix_cost": "4.30", + "data_read_per_join": "72" + } /* cost_info */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t1` join `test`.`t2` semi join ((/* select#3 */ select `test`.`t2`.`b` AS `b` from `test`.`t2` order by `test`.`t2`.`b` limit 2,2) `x`) set `test`.`t1`.`a` = 10 where (`x`.`b` = `test`.`t1`.`a`) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1, t2 WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x);; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "4.30" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.30", + "prefix_cost": "0.80", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`a` is not null)" + } /* table */ + }, + { + "table": { + "table_name": "x", + "access_type": "ref", + "possible_keys": [ + "" + ] /* possible_keys */, + "key": "", + "used_key_parts": [ + "b" + ] /* used_key_parts */, + "key_length": "5", + "ref": [ + "test.t1.a" + ] /* ref */, + "rows_examined_per_scan": 2, + "rows_produced_per_join": 3, + "filtered": "100.00", + "using_index": true, + "first_match": "t1", + "cost_info": { + "read_cost": "1.50", + "eval_cost": "0.30", + "prefix_cost": "2.90", + "data_read_per_join": "48" + } /* cost_info */, + "used_columns": [ + "b" + ] /* used_columns */, + "materialized_from_subquery": { + "using_temporary_table": true, + "dependent": false, + "cacheable": true, + "query_block": { + "select_id": 3, + "cost_info": { + "query_cost": "3.80" + } /* cost_info */, + "ordering_operation": { + "using_filesort": true, + "cost_info": { + "sort_cost": "3.00" + } /* cost_info */, + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.30", + "prefix_cost": "0.80", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "b" + ] /* used_columns */ + } /* table */ + } /* ordering_operation */ + } /* query_block */ + } /* materialized_from_subquery */ + } /* table */ + }, + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 9, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.90", + "prefix_cost": "4.30", + "data_read_per_join": "72" + } /* cost_info */, + "used_columns": [ + "b" + ] /* used_columns */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` join `test`.`t2` semi join ((/* select#3 */ select `test`.`t2`.`b` AS `b` from `test`.`t2` order by `test`.`t2`.`b` limit 2,2) `x`) where (`x`.`b` = `test`.`t1`.`a`) +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 5 +Handler_read_rnd_next 8 +Handler_write 1 +Sort_rows 3 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 5 +Handler_read_rnd_next 8 +Handler_write 1 +Sort_rows 3 +Sort_scan 1 + +# +# query: UPDATE t1, (SELECT * FROM t2) y SET a = 10 WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x) +# select: SELECT * FROM t1, (SELECT * FROM t2) y WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x) +# +EXPLAIN UPDATE t1, (SELECT * FROM t2) y SET a = 10 WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 PRIMARY NULL ref 5 test.t1.a 2 100.00 Using index; FirstMatch(t1) +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +4 DERIVED t2 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 update `test`.`t1` join `test`.`t2` semi join ((/* select#4 */ select `test`.`t2`.`b` AS `b` from `test`.`t2` order by `test`.`t2`.`b` limit 2,2) `x`) set `test`.`t1`.`a` = 10 where (`x`.`b` = `test`.`t1`.`a`) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t1, (SELECT * FROM t2) y SET a = 10 WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x);; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "4.30" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "update": true, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.30", + "prefix_cost": "0.80", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`a` is not null)" + } /* table */ + }, + { + "table": { + "table_name": "x", + "access_type": "ref", + "possible_keys": [ + "" + ] /* possible_keys */, + "key": "", + "used_key_parts": [ + "b" + ] /* used_key_parts */, + "key_length": "5", + "ref": [ + "test.t1.a" + ] /* ref */, + "rows_examined_per_scan": 2, + "rows_produced_per_join": 3, + "filtered": "100.00", + "using_index": true, + "first_match": "t1", + "cost_info": { + "read_cost": "1.50", + "eval_cost": "0.30", + "prefix_cost": "2.90", + "data_read_per_join": "48" + } /* cost_info */, + "used_columns": [ + "b" + ] /* used_columns */, + "materialized_from_subquery": { + "using_temporary_table": true, + "dependent": false, + "cacheable": true, + "query_block": { + "select_id": 4, + "cost_info": { + "query_cost": "3.80" + } /* cost_info */, + "ordering_operation": { + "using_filesort": true, + "cost_info": { + "sort_cost": "3.00" + } /* cost_info */, + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.30", + "prefix_cost": "0.80", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "b" + ] /* used_columns */ + } /* table */ + } /* ordering_operation */ + } /* query_block */ + } /* materialized_from_subquery */ + } /* table */ + }, + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 9, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.90", + "prefix_cost": "4.30", + "data_read_per_join": "72" + } /* cost_info */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t1` join `test`.`t2` semi join ((/* select#4 */ select `test`.`t2`.`b` AS `b` from `test`.`t2` order by `test`.`t2`.`b` limit 2,2) `x`) set `test`.`t1`.`a` = 10 where (`x`.`b` = `test`.`t1`.`a`) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1, (SELECT * FROM t2) y WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x);; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "4.30" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.30", + "prefix_cost": "0.80", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`a` is not null)" + } /* table */ + }, + { + "table": { + "table_name": "x", + "access_type": "ref", + "possible_keys": [ + "" + ] /* possible_keys */, + "key": "", + "used_key_parts": [ + "b" + ] /* used_key_parts */, + "key_length": "5", + "ref": [ + "test.t1.a" + ] /* ref */, + "rows_examined_per_scan": 2, + "rows_produced_per_join": 3, + "filtered": "100.00", + "using_index": true, + "first_match": "t1", + "cost_info": { + "read_cost": "1.50", + "eval_cost": "0.30", + "prefix_cost": "2.90", + "data_read_per_join": "48" + } /* cost_info */, + "used_columns": [ + "b" + ] /* used_columns */, + "materialized_from_subquery": { + "using_temporary_table": true, + "dependent": false, + "cacheable": true, + "query_block": { + "select_id": 4, + "cost_info": { + "query_cost": "3.80" + } /* cost_info */, + "ordering_operation": { + "using_filesort": true, + "cost_info": { + "sort_cost": "3.00" + } /* cost_info */, + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.30", + "prefix_cost": "0.80", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "b" + ] /* used_columns */ + } /* table */ + } /* ordering_operation */ + } /* query_block */ + } /* materialized_from_subquery */ + } /* table */ + }, + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 9, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.90", + "prefix_cost": "4.30", + "data_read_per_join": "72" + } /* cost_info */, + "used_columns": [ + "b" + ] /* used_columns */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` join `test`.`t2` semi join ((/* select#4 */ select `test`.`t2`.`b` AS `b` from `test`.`t2` order by `test`.`t2`.`b` limit 2,2) `x`) where (`x`.`b` = `test`.`t1`.`a`) +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 5 +Handler_read_rnd_next 8 +Handler_write 1 +Sort_rows 3 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 5 +Handler_read_rnd_next 8 +Handler_write 1 +Sort_rows 3 +Sort_scan 1 + +DROP TABLE t1,t2; +#70 +CREATE TABLE t1 (c1 INT KEY); +CREATE TABLE t2 (c2 INT); +CREATE TABLE t3 (c3 INT); +EXPLAIN UPDATE t3 SET c3 = ( +SELECT COUNT(d1.c1) +FROM ( +SELECT a11.c1 FROM t1 AS a11 +STRAIGHT_JOIN t2 AS a21 ON a21.c2 = a11.c1 +JOIN t1 AS a12 ON a12.c1 = a11.c1 +) d1 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t3 NULL ALL NULL NULL NULL NULL 0 100.00 NULL +2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +3 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 update `test`.`t3` set `test`.`t3`.`c3` = (/* select#2 */ select count(NULL) from (/* select#3 */ select NULL AS `c1` from `test`.`t1` `a11` straight_join `test`.`t2` `a21` join `test`.`t1` `a12` where multiple equal(NULL, NULL, NULL)) `d1`) +DROP TABLE t1, t2, t3; +#71 +CREATE TABLE t1 (c1 INT NOT NULL, c2 INT NOT NULL, INDEX i1(c1)); +INSERT INTO t1 VALUES (1,0),(2,0),(3,0),(4,0),(5,0),(6,0),(7,0),(8,0); +CREATE TABLE t2 LIKE t1; +EXPLAIN INSERT INTO t2 SELECT * FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 INSERT t2 NULL ALL NULL NULL NULL NULL X NULL NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL X 100.00 NULL +Warnings: +Note 1003 insert into `test`.`t2` /* select#1 */ select `test`.`t1`.`c1` AS `c1`,`test`.`t1`.`c2` AS `c2` from `test`.`t1` +INSERT INTO t2 SELECT * FROM t1; +SELECT * FROM t1 LEFT JOIN t2 ON t1.c1 = t2.c1; +DROP TABLE t1, t2; +#73 +CREATE TABLE t1 (id INT); +CREATE TABLE t2 (id INT); +INSERT INTO t1 VALUES (1), (2); +EXPLAIN SELECT * FROM t1 LEFT JOIN t2 USING(id) GROUP BY t1.id; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL system NULL NULL NULL NULL 0 0.00 const row not found +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id` from `test`.`t1` where true group by `test`.`t1`.`id` +DROP TABLE t1,t2; +#74 +CREATE TABLE t1(a INT PRIMARY KEY) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1), (2), (3), (4), (5); +# used key is modified & Using temporary +# +# query: UPDATE t1 SET a=a+1 WHERE a>10 +# select: SELECT a t1 FROM t1 WHERE a>10 +# +EXPLAIN UPDATE t1 SET a=a+1 WHERE a>10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL range PRIMARY PRIMARY 4 const 1 100.00 Using where; Using temporary +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`a` = (`test`.`t1`.`a` + 1) where (`test`.`t1`.`a` > 10) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t1 SET a=a+1 WHERE a>10;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "table": { + "update": true, + "table_name": "t1", + "access_type": "range", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "a" + ] /* used_key_parts */, + "key_length": "4", + "ref": [ + "const" + ] /* ref */, + "rows_examined_per_scan": 1, + "filtered": "100.00", + "using_temporary_table": "for update", + "attached_condition": "(`test`.`t1`.`a` > 10)" + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`a` = (`test`.`t1`.`a` + 1) where (`test`.`t1`.`a` > 10) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT a t1 FROM t1 WHERE a>10;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.46" + } /* cost_info */, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.36", + "eval_cost": "0.10", + "prefix_cost": "0.46", + "data_read_per_join": "16" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "query_block": { + "cost_info": { + "query_cost": "0.46" + } /* cost_info */, + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "range", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "a" + ] /* used_key_parts */, + "key_length": "4", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "using_index": true, + "cost_info": { + "read_cost": "0.36", + "eval_cost": "0.10", + "prefix_cost": "0.46", + "data_read_per_join": "8" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`a` > 10)" + } /* table */ + } /* query_block */ + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `t1` from `test`.`t1` where (`test`.`t1`.`a` > 10) +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 2 + +# used key is modified & Using filesort +# +# query: UPDATE t1 SET a=a+1 WHERE a>10 ORDER BY a+20 +# select: SELECT a t1 FROM t1 WHERE a>10 ORDER BY a+20 +# +EXPLAIN UPDATE t1 SET a=a+1 WHERE a>10 ORDER BY a+20; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL range PRIMARY PRIMARY 4 const 1 100.00 Using where; Using filesort +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`a` = (`test`.`t1`.`a` + 1) where (`test`.`t1`.`a` > 10) order by (`test`.`t1`.`a` + 20) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t1 SET a=a+1 WHERE a>10 ORDER BY a+20;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_filesort": true, + "table": { + "update": true, + "table_name": "t1", + "access_type": "range", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "a" + ] /* used_key_parts */, + "key_length": "4", + "ref": [ + "const" + ] /* ref */, + "rows_examined_per_scan": 1, + "filtered": "100.00", + "attached_condition": "(`test`.`t1`.`a` > 10)" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`a` = (`test`.`t1`.`a` + 1) where (`test`.`t1`.`a` > 10) order by (`test`.`t1`.`a` + 20) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT a t1 FROM t1 WHERE a>10 ORDER BY a+20;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.46" + } /* cost_info */, + "ordering_operation": { + "using_filesort": true, + "cost_info": { + "sort_cost": "1.00" + } /* cost_info */, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.36", + "eval_cost": "0.10", + "prefix_cost": "0.46", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "(t1.a + 20)", + "a" + ] /* used_columns */, + "ordering_operation": { + "using_filesort": true, + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "range", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "a" + ] /* used_key_parts */, + "key_length": "4", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "using_index": true, + "cost_info": { + "read_cost": "0.36", + "eval_cost": "0.10", + "prefix_cost": "0.46", + "data_read_per_join": "8" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`a` > 10)" + } /* table */ + } /* ordering_operation */ + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `t1` from `test`.`t1` where (`test`.`t1`.`a` > 10) order by `(t1.a + 20)` +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 1 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 2 +Sort_scan 1 + +DROP TABLE t1; +# +# Bug #12949629: CLIENT LOSES CONNECTION AFTER EXECUTING A PROCEDURE WITH +# EXPLAIN UPDATE/DEL/INS +# +CREATE TABLE t1 (i INT); +CREATE TABLE t2 (i INT); +CREATE PROCEDURE p1() BEGIN EXPLAIN INSERT INTO t1 VALUES (1);END| +CREATE PROCEDURE p2() BEGIN INSERT INTO t1 VALUES (1);END| +CREATE PROCEDURE p3() BEGIN EXPLAIN INSERT INTO t1 SELECT 1;END| +CREATE PROCEDURE p4() BEGIN INSERT INTO t1 SELECT 1;END| +CREATE PROCEDURE p5() BEGIN EXPLAIN REPLACE INTO t1 VALUES (1);END| +CREATE PROCEDURE p6() BEGIN REPLACE INTO t1 VALUES (1);END| +CREATE PROCEDURE p7() BEGIN EXPLAIN REPLACE INTO t1 SELECT 1;END| +CREATE PROCEDURE p8() BEGIN REPLACE INTO t1 SELECT 1;END| +CREATE PROCEDURE p9() BEGIN EXPLAIN UPDATE t1 SET i = 10;END| +CREATE PROCEDURE p10() BEGIN UPDATE t1 SET i = 10;END| +CREATE PROCEDURE p11() BEGIN EXPLAIN UPDATE t1,t2 SET t1.i = 10 WHERE t1.i = t2.i ;END| +CREATE PROCEDURE p12() BEGIN UPDATE t1,t2 SET t1.i = 10 WHERE t1.i = t2.i ;END| +CREATE PROCEDURE p13() BEGIN +# Disabling binary logging temporarily as optimized delete is not used when log-bin is enabled in row mode +SET @save_log_bin= @@sql_log_bin;SET SQL_LOG_BIN=0; +EXPLAIN DELETE FROM t1; +SET SQL_LOG_BIN=@save_log_bin; END| +CREATE PROCEDURE p14() BEGIN DELETE FROM t1;END| +CREATE PROCEDURE p15() BEGIN EXPLAIN DELETE FROM t1 USING t1;END| +CREATE PROCEDURE p16() BEGIN DELETE FROM t1 USING t1;END| +CALL p16(); +DROP PROCEDURE p16; +CALL p15(); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 delete `test`.`t1` from `test`.`t1` +DROP PROCEDURE p15; +CALL p14(); +DROP PROCEDURE p14; +CALL p13(); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 0 100.00 Deleting all rows +DROP PROCEDURE p13; +CALL p12(); +DROP PROCEDURE p12; +CALL p11(); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 update `test`.`t1` join `test`.`t2` set `test`.`t1`.`i` = 10 where multiple equal(`test`.`t1`.`i`, `test`.`t2`.`i`) +DROP PROCEDURE p11; +CALL p10(); +DROP PROCEDURE p10; +CALL p9(); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 0 100.00 NULL +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`i` = 10 +DROP PROCEDURE p9; +CALL p8(); +DROP PROCEDURE p8; +CALL p7(); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 REPLACE t1 NULL ALL NULL NULL NULL NULL NULL NULL NULL +Warnings: +Note 1003 replace into `test`.`t1` /* select#1 */ select 1 AS `1` from dual +DROP PROCEDURE p7; +CALL p6(); +DROP PROCEDURE p6; +CALL p5(); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 REPLACE t1 NULL ALL NULL NULL NULL NULL NULL NULL NULL +Warnings: +Note 1003 replace into `test`.`t1` values (1) +DROP PROCEDURE p5; +CALL p4(); +DROP PROCEDURE p4; +CALL p3(); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 INSERT t1 NULL ALL NULL NULL NULL NULL NULL NULL NULL +Warnings: +Note 1003 insert into `test`.`t1` /* select#1 */ select 1 AS `1` from dual +DROP PROCEDURE p3; +CALL p2(); +DROP PROCEDURE p2; +CALL p1(); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 INSERT t1 NULL ALL NULL NULL NULL NULL NULL NULL NULL +Warnings: +Note 1003 insert into `test`.`t1` values (1) +DROP PROCEDURE p1; +DROP TABLE t1, t2; +# +set default_storage_engine= @save_storage_engine; +set optimizer_switch=default; diff --git a/mysql-test/r/myisam_explain_json_non_select_none.result-pq b/mysql-test/r/myisam_explain_json_non_select_none.result-pq new file mode 100644 index 000000000000..1bf175c17d22 --- /dev/null +++ b/mysql-test/r/myisam_explain_json_non_select_none.result-pq @@ -0,0 +1,8270 @@ +set @save_storage_engine= @@session.default_storage_engine; +set session default_storage_engine = MyISAM; +set end_markers_in_json=on; +#1 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +# +# query: UPDATE t1 SET a = 10 WHERE a < 10 +# select: SELECT * FROM t1 WHERE a < 10 +# +EXPLAIN UPDATE t1 SET a = 10 WHERE a < 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`a` = 10 where (`test`.`t1`.`a` < 10) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t1 SET a = 10 WHERE a < 10;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "table": { + "update": true, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "filtered": "100.00", + "attached_condition": "(`test`.`t1`.`a` < 10)" + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`a` = 10 where (`test`.`t1`.`a` < 10) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 WHERE a < 10;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.80" + } /* cost_info */, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 1, + "filtered": "33.33", + "cost_info": { + "read_cost": "0.70", + "eval_cost": "0.10", + "prefix_cost": "0.80", + "data_read_per_join": "8" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`a` < 10)" + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` < 10) +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 1 +Handler_read_rnd_next 4 +# Status of testing query execution: +Variable_name Value +Handler_read_key 1 +Handler_read_rnd_next 4 +Handler_update 3 + +DROP TABLE t1; +#2 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +# +# query: DELETE FROM t1 WHERE a < 10 +# select: SELECT * FROM t1 WHERE a < 10 +# +EXPLAIN DELETE FROM t1 WHERE a < 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 delete from `test`.`t1` where (`test`.`t1`.`a` < 10) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t1 WHERE a < 10;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "table": { + "delete": true, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "filtered": "100.00", + "attached_condition": "(`test`.`t1`.`a` < 10)" + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 delete from `test`.`t1` where (`test`.`t1`.`a` < 10) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 WHERE a < 10;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.80" + } /* cost_info */, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 1, + "filtered": "33.33", + "cost_info": { + "read_cost": "0.70", + "eval_cost": "0.10", + "prefix_cost": "0.80", + "data_read_per_join": "8" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`a` < 10)" + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` < 10) +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 1 +Handler_read_rnd_next 4 +# Status of testing query execution: +Variable_name Value +Handler_delete 3 +Handler_read_key 1 +Handler_read_rnd_next 4 + +DROP TABLE t1; +#3 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +# +# query: DELETE FROM t1 USING t1 WHERE a = 1 +# select: SELECT * FROM t1 WHERE a = 1 +# +EXPLAIN DELETE FROM t1 USING t1 WHERE a = 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 delete `test`.`t1` from `test`.`t1` where (`test`.`t1`.`a` = 1) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t1 USING t1 WHERE a = 1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.80" + } /* cost_info */, + "table": { + "delete": true, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 1, + "filtered": "33.33", + "cost_info": { + "read_cost": "0.70", + "eval_cost": "0.10", + "prefix_cost": "0.80", + "data_read_per_join": "8" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`a` = 1)" + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 delete `test`.`t1` from `test`.`t1` where (`test`.`t1`.`a` = 1) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 WHERE a = 1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.80" + } /* cost_info */, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 1, + "filtered": "33.33", + "cost_info": { + "read_cost": "0.70", + "eval_cost": "0.10", + "prefix_cost": "0.80", + "data_read_per_join": "8" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`a` = 1)" + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` = 1) +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 1 +Handler_read_rnd_next 4 +# Status of testing query execution: +Variable_name Value +Handler_delete 1 +Handler_read_key 1 +Handler_read_rnd_next 4 + +DROP TABLE t1; +#4 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +CREATE TABLE t2 (b INT); +INSERT INTO t2 VALUES (1), (2), (3); +# +# query: UPDATE t1, t2 SET t1.a = 10 WHERE t1.a = 1 +# select: SELECT * FROM t1, t2 WHERE t1.a = 1 +# +EXPLAIN UPDATE t1, t2 SET t1.a = 10 WHERE t1.a = 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 update `test`.`t1` join `test`.`t2` set `test`.`t1`.`a` = 10 where (`test`.`t1`.`a` = 1) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t1, t2 SET t1.a = 10 WHERE t1.a = 1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.60" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "update": true, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 1, + "filtered": "33.33", + "cost_info": { + "read_cost": "0.70", + "eval_cost": "0.10", + "prefix_cost": "0.80", + "data_read_per_join": "8" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`a` = 1)" + } /* table */ + }, + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.30", + "prefix_cost": "1.60", + "data_read_per_join": "24" + } /* cost_info */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t1` join `test`.`t2` set `test`.`t1`.`a` = 10 where (`test`.`t1`.`a` = 1) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1, t2 WHERE t1.a = 1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.60" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 1, + "filtered": "33.33", + "cost_info": { + "read_cost": "0.70", + "eval_cost": "0.10", + "prefix_cost": "0.80", + "data_read_per_join": "8" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`a` = 1)" + } /* table */ + }, + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.30", + "prefix_cost": "1.60", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "b" + ] /* used_columns */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` join `test`.`t2` where (`test`.`t1`.`a` = 1) +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 8 +# Status of testing query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 8 +Handler_update 1 + +DROP TABLE t1, t2; +#5 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +CREATE TABLE t2 (b INT); +INSERT INTO t2 VALUES (1), (2), (3); +# +# query: UPDATE t1 t11, (SELECT * FROM t2) t12 SET t11.a = 10 WHERE t11.a = 1 +# select: SELECT * FROM t1 t11, (SELECT * FROM t2) t12 WHERE t11.a = 1 +# +EXPLAIN UPDATE t1 t11, (SELECT * FROM t2) t12 SET t11.a = 10 WHERE t11.a = 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t11 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 update `test`.`t1` `t11` join `test`.`t2` set `test`.`t11`.`a` = 10 where (`test`.`t11`.`a` = 1) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t1 t11, (SELECT * FROM t2) t12 SET t11.a = 10 WHERE t11.a = 1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.60" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "update": true, + "table_name": "t11", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 1, + "filtered": "33.33", + "cost_info": { + "read_cost": "0.70", + "eval_cost": "0.10", + "prefix_cost": "0.80", + "data_read_per_join": "8" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t11`.`a` = 1)" + } /* table */ + }, + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.30", + "prefix_cost": "1.60", + "data_read_per_join": "24" + } /* cost_info */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t1` `t11` join `test`.`t2` set `test`.`t11`.`a` = 10 where (`test`.`t11`.`a` = 1) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 t11, (SELECT * FROM t2) t12 WHERE t11.a = 1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.60" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "table_name": "t11", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 1, + "filtered": "33.33", + "cost_info": { + "read_cost": "0.70", + "eval_cost": "0.10", + "prefix_cost": "0.80", + "data_read_per_join": "8" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t11`.`a` = 1)" + } /* table */ + }, + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.30", + "prefix_cost": "1.60", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "b" + ] /* used_columns */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t11`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` `t11` join `test`.`t2` where (`test`.`t11`.`a` = 1) +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 8 +# Status of testing query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 8 +Handler_update 1 + +DROP TABLE t1, t2; +#6 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +CREATE TABLE t2 (b INT); +INSERT INTO t2 VALUES (1), (2), (3); +# +# query: UPDATE t1 SET a = 10 WHERE 1 IN (SELECT 1 FROM t2 WHERE t2.b < 3) +# select: SELECT * FROM t1 WHERE 1 IN (SELECT 1 FROM t2 WHERE t2.b < 3) +# +EXPLAIN UPDATE t1 SET a = 10 WHERE 1 IN (SELECT 1 FROM t2 WHERE t2.b < 3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 SUBQUERY t2 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`a` = 10 where (1,(/* select#2 */ select 1 from `test`.`t2` where (`test`.`t2`.`b` < 3))) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t1 SET a = 10 WHERE 1 IN (SELECT 1 FROM t2 WHERE t2.b < 3);; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "table": { + "update": true, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "filtered": "100.00", + "attached_subqueries": [ + { + "dependent": false, + "cacheable": true, + "query_block": { + "select_id": 2, + "cost_info": { + "query_cost": "0.80" + } /* cost_info */, + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 1, + "filtered": "33.33", + "cost_info": { + "read_cost": "0.70", + "eval_cost": "0.10", + "prefix_cost": "0.80", + "data_read_per_join": "8" + } /* cost_info */, + "used_columns": [ + "b" + ] /* used_columns */, + "attached_condition": "(`test`.`t2`.`b` < 3)" + } /* table */ + } /* query_block */ + } + ] /* attached_subqueries */ + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`a` = 10 where (1,(/* select#2 */ select 1 from `test`.`t2` where (`test`.`t2`.`b` < 3))) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 WHERE 1 IN (SELECT 1 FROM t2 WHERE t2.b < 3);; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.80" + } /* cost_info */, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.30", + "prefix_cost": "0.80", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */ + } /* table */, + "optimized_away_subqueries": [ + { + "dependent": false, + "cacheable": true, + "query_block": { + "select_id": 2, + "cost_info": { + "query_cost": "0.80" + } /* cost_info */, + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 1, + "filtered": "33.33", + "cost_info": { + "read_cost": "0.70", + "eval_cost": "0.10", + "prefix_cost": "0.80", + "data_read_per_join": "8" + } /* cost_info */, + "used_columns": [ + "b" + ] /* used_columns */, + "attached_condition": "(`test`.`t2`.`b` < 3)" + } /* table */ + } /* query_block */ + } + ] /* optimized_away_subqueries */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where true +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 5 +# Status of testing query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 5 +Handler_update 3 + +DROP TABLE t1, t2; +#7 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +CREATE TABLE t2 (b INT); +INSERT INTO t2 VALUES (1), (2), (3); +# +# query: UPDATE t1 SET a = 10 WHERE a IN (SELECT b FROM t2 WHERE t1.a < 3) +# select: SELECT * FROM t1 WHERE a IN (SELECT b FROM t2 WHERE t1.a < 3) +# +EXPLAIN UPDATE t1 SET a = 10 WHERE a IN (SELECT b FROM t2 WHERE t1.a < 3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 update `test`.`t1` set `test`.`t1`.`a` = 10 where (`test`.`t1`.`a`,(/* select#2 */ select `test`.`t2`.`b` from `test`.`t2` where ((`test`.`t1`.`a` < 3) and ((`test`.`t1`.`a`) = `test`.`t2`.`b`)))) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t1 SET a = 10 WHERE a IN (SELECT b FROM t2 WHERE t1.a < 3);; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "table": { + "update": true, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "filtered": "100.00", + "attached_condition": "(`test`.`t1`.`a`,(/* select#2 */ select `test`.`t2`.`b` from `test`.`t2` where ((`test`.`t1`.`a` < 3) and ((`test`.`t1`.`a`) = `test`.`t2`.`b`))))", + "attached_subqueries": [ + { + "dependent": true, + "cacheable": false, + "query_block": { + "select_id": 2, + "cost_info": { + "query_cost": "0.80" + } /* cost_info */, + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 1, + "filtered": "33.33", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.10", + "prefix_cost": "0.80", + "data_read_per_join": "8" + } /* cost_info */, + "used_columns": [ + "b" + ] /* used_columns */, + "attached_condition": "((`test`.`t1`.`a` < 3) and ((`test`.`t1`.`a`) = `test`.`t2`.`b`))" + } /* table */ + } /* query_block */ + } + ] /* attached_subqueries */ + } /* table */ + } /* query_block */ +} +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 update `test`.`t1` set `test`.`t1`.`a` = 10 where (`test`.`t1`.`a`,(/* select#2 */ select `test`.`t2`.`b` from `test`.`t2` where ((`test`.`t1`.`a` < 3) and ((`test`.`t1`.`a`) = `test`.`t2`.`b`)))) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 WHERE a IN (SELECT b FROM t2 WHERE t1.a < 3);; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.80" + } /* cost_info */, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.30", + "prefix_cost": "0.80", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`a`,(/* select#2 */ select `test`.`t2`.`b` from `test`.`t2` where ((`test`.`t1`.`a` < 3) and ((`test`.`t1`.`a`) = `test`.`t2`.`b`))))", + "attached_subqueries": [ + { + "dependent": true, + "cacheable": false, + "query_block": { + "select_id": 2, + "cost_info": { + "query_cost": "0.80" + } /* cost_info */, + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 1, + "filtered": "33.33", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.10", + "prefix_cost": "0.80", + "data_read_per_join": "8" + } /* cost_info */, + "used_columns": [ + "b" + ] /* used_columns */, + "attached_condition": "((`test`.`t1`.`a` < 3) and ((`test`.`t1`.`a`) = `test`.`t2`.`b`))" + } /* table */ + } /* query_block */ + } + ] /* attached_subqueries */ + } /* table */ + } /* query_block */ +} +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a`,(/* select#2 */ select `test`.`t2`.`b` from `test`.`t2` where ((`test`.`t1`.`a` < 3) and ((`test`.`t1`.`a`) = `test`.`t2`.`b`)))) +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 11 +# Status of testing query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 11 +Handler_update 2 + +DROP TABLE t1, t2; +#7 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +CREATE TABLE t2 (b INT); +INSERT INTO t2 VALUES (1), (2), (3); +# +# query: UPDATE t1, t2 SET a = 10 WHERE a IN (SELECT b FROM t2 WHERE t2.b < 3) +# select: SELECT * FROM t1, t2 WHERE a IN (SELECT b FROM t2 WHERE t2.b < 3) +# +EXPLAIN UPDATE t1, t2 SET a = 10 WHERE a IN (SELECT b FROM t2 WHERE t2.b < 3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 update `test`.`t1` join `test`.`t2` set `test`.`t1`.`a` = 10 where (`test`.`t1`.`a`,(/* select#2 */ select `test`.`t2`.`b` from `test`.`t2` where ((`test`.`t2`.`b` < 3) and ((`test`.`t1`.`a`) = `test`.`t2`.`b`)))) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t1, t2 SET a = 10 WHERE a IN (SELECT b FROM t2 WHERE t2.b < 3);; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "2.20" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "update": true, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.30", + "prefix_cost": "0.80", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`a`,(/* select#2 */ select `test`.`t2`.`b` from `test`.`t2` where ((`test`.`t2`.`b` < 3) and ((`test`.`t1`.`a`) = `test`.`t2`.`b`))))", + "attached_subqueries": [ + { + "dependent": true, + "cacheable": false, + "query_block": { + "select_id": 2, + "cost_info": { + "query_cost": "0.80" + } /* cost_info */, + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 1, + "filtered": "33.33", + "cost_info": { + "read_cost": "0.70", + "eval_cost": "0.10", + "prefix_cost": "0.80", + "data_read_per_join": "8" + } /* cost_info */, + "used_columns": [ + "b" + ] /* used_columns */, + "attached_condition": "((`test`.`t2`.`b` < 3) and ((`test`.`t1`.`a`) = `test`.`t2`.`b`))" + } /* table */ + } /* query_block */ + } + ] /* attached_subqueries */ + } /* table */ + }, + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 9, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.90", + "prefix_cost": "2.20", + "data_read_per_join": "72" + } /* cost_info */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t1` join `test`.`t2` set `test`.`t1`.`a` = 10 where (`test`.`t1`.`a`,(/* select#2 */ select `test`.`t2`.`b` from `test`.`t2` where ((`test`.`t2`.`b` < 3) and ((`test`.`t1`.`a`) = `test`.`t2`.`b`)))) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1, t2 WHERE a IN (SELECT b FROM t2 WHERE t2.b < 3);; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "2.20" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.30", + "prefix_cost": "0.80", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`a`,(/* select#2 */ select `test`.`t2`.`b` from `test`.`t2` where ((`test`.`t2`.`b` < 3) and ((`test`.`t1`.`a`) = `test`.`t2`.`b`))))", + "attached_subqueries": [ + { + "dependent": true, + "cacheable": false, + "query_block": { + "select_id": 2, + "cost_info": { + "query_cost": "0.80" + } /* cost_info */, + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 1, + "filtered": "33.33", + "cost_info": { + "read_cost": "0.70", + "eval_cost": "0.10", + "prefix_cost": "0.80", + "data_read_per_join": "8" + } /* cost_info */, + "used_columns": [ + "b" + ] /* used_columns */, + "attached_condition": "((`test`.`t2`.`b` < 3) and ((`test`.`t1`.`a`) = `test`.`t2`.`b`))" + } /* table */ + } /* query_block */ + } + ] /* attached_subqueries */ + } /* table */ + }, + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 9, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.90", + "prefix_cost": "2.20", + "data_read_per_join": "72" + } /* cost_info */, + "used_columns": [ + "b" + ] /* used_columns */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` join `test`.`t2` where (`test`.`t1`.`a`,(/* select#2 */ select `test`.`t2`.`b` from `test`.`t2` where ((`test`.`t2`.`b` < 3) and ((`test`.`t1`.`a`) = `test`.`t2`.`b`)))) +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 15 +# Status of testing query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 19 +Handler_update 2 + +DROP TABLE t1, t2; +#8 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +CREATE TABLE t2 (b INT); +INSERT INTO t2 VALUES (1), (2), (3); +# +# query: UPDATE t1 t11, (SELECT * FROM t2) t12 SET t11.a = t11.a + 10 +# select: SELECT * FROM t1 t11, (SELECT * FROM t2) t12 +# +EXPLAIN UPDATE t1 t11, (SELECT * FROM t2) t12 SET t11.a = t11.a + 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t11 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 update `test`.`t1` `t11` join `test`.`t2` set `test`.`t11`.`a` = (`test`.`t11`.`a` + 10) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t1 t11, (SELECT * FROM t2) t12 SET t11.a = t11.a + 10;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "2.20" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "update": true, + "table_name": "t11", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.30", + "prefix_cost": "0.80", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */ + } /* table */ + }, + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 9, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.90", + "prefix_cost": "2.20", + "data_read_per_join": "72" + } /* cost_info */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t1` `t11` join `test`.`t2` set `test`.`t11`.`a` = (`test`.`t11`.`a` + 10) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 t11, (SELECT * FROM t2) t12;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "2.20" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "table_name": "t11", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.30", + "prefix_cost": "0.80", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */ + } /* table */ + }, + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 9, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.90", + "prefix_cost": "2.20", + "data_read_per_join": "72" + } /* cost_info */, + "used_columns": [ + "b" + ] /* used_columns */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t11`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` `t11` join `test`.`t2` +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 8 +# Status of testing query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 16 +Handler_update 3 + +DROP TABLE t1, t2; +#9 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +CREATE TABLE t2 (b INT); +INSERT INTO t2 VALUES (1), (2), (3); +# +# query: UPDATE t1 t11, (SELECT 1 FROM DUAL) t12 SET t11.a = t11.a + 10 +# select: SELECT * FROM t1 t11, (SELECT 1 FROM DUAL) t12 +# +EXPLAIN UPDATE t1 t11, (SELECT 1 FROM DUAL) t12 SET t11.a = t11.a + 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL system NULL NULL NULL NULL 1 100.00 NULL +1 UPDATE t11 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 update `test`.`t1` `t11` join (/* select#2 */ select 1 AS `1`) `t12` set `test`.`t11`.`a` = (`test`.`t11`.`a` + 10) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t1 t11, (SELECT 1 FROM DUAL) t12 SET t11.a = t11.a + 10;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.80" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "table_name": "t12", + "access_type": "system", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.00", + "eval_cost": "0.10", + "prefix_cost": "0.00", + "data_read_per_join": "16" + } /* cost_info */, + "used_columns": [ + "1" + ] /* used_columns */, + "materialized_from_subquery": { + "using_temporary_table": true, + "dependent": false, + "cacheable": true, + "query_block": { + "select_id": 2, + "message": "No tables used" + } /* query_block */ + } /* materialized_from_subquery */ + } /* table */ + }, + { + "table": { + "update": true, + "table_name": "t11", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.30", + "prefix_cost": "0.80", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t1` `t11` join (/* select#2 */ select 1 AS `1`) `t12` set `test`.`t11`.`a` = (`test`.`t11`.`a` + 10) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 t11, (SELECT 1 FROM DUAL) t12;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.80" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "table_name": "t12", + "access_type": "system", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.00", + "eval_cost": "0.10", + "prefix_cost": "0.00", + "data_read_per_join": "16" + } /* cost_info */, + "used_columns": [ + "1" + ] /* used_columns */, + "materialized_from_subquery": { + "using_temporary_table": true, + "dependent": false, + "cacheable": true, + "query_block": { + "select_id": 2, + "message": "No tables used" + } /* query_block */ + } /* materialized_from_subquery */ + } /* table */ + }, + { + "table": { + "table_name": "t11", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.30", + "prefix_cost": "0.80", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t11`.`a` AS `a`,'1' AS `1` from `test`.`t1` `t11` +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 1 +Handler_read_rnd_next 5 +Handler_write 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 1 +Handler_read_rnd 3 +Handler_read_rnd_next 9 +Handler_update 3 +Handler_write 4 + +DROP TABLE t1, t2; +#10 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +CREATE TABLE t2 (b INT); +INSERT INTO t2 VALUES (1), (2), (3); +# +# query: UPDATE t1 t11, (SELECT * FROM t2) t12 SET t11.a = 10 WHERE t11.a > 1 +# select: SELECT * FROM t1 t11, (SELECT * FROM t2) t12 WHERE t11.a > 1 +# +EXPLAIN UPDATE t1 t11, (SELECT * FROM t2) t12 SET t11.a = 10 WHERE t11.a > 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t11 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 update `test`.`t1` `t11` join `test`.`t2` set `test`.`t11`.`a` = 10 where (`test`.`t11`.`a` > 1) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t1 t11, (SELECT * FROM t2) t12 SET t11.a = 10 WHERE t11.a > 1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.60" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "update": true, + "table_name": "t11", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 1, + "filtered": "33.33", + "cost_info": { + "read_cost": "0.70", + "eval_cost": "0.10", + "prefix_cost": "0.80", + "data_read_per_join": "8" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t11`.`a` > 1)" + } /* table */ + }, + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.30", + "prefix_cost": "1.60", + "data_read_per_join": "24" + } /* cost_info */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t1` `t11` join `test`.`t2` set `test`.`t11`.`a` = 10 where (`test`.`t11`.`a` > 1) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 t11, (SELECT * FROM t2) t12 WHERE t11.a > 1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.60" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "table_name": "t11", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 1, + "filtered": "33.33", + "cost_info": { + "read_cost": "0.70", + "eval_cost": "0.10", + "prefix_cost": "0.80", + "data_read_per_join": "8" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t11`.`a` > 1)" + } /* table */ + }, + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.30", + "prefix_cost": "1.60", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "b" + ] /* used_columns */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t11`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` `t11` join `test`.`t2` where (`test`.`t11`.`a` > 1) +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 8 +# Status of testing query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 12 +Handler_update 2 + +DROP TABLE t1, t2; +#11 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +# +# query: DELETE FROM t1 WHERE a > 1 LIMIT 1 +# select: SELECT * FROM t1 WHERE a > 1 LIMIT 1 +# +EXPLAIN DELETE FROM t1 WHERE a > 1 LIMIT 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 delete from `test`.`t1` where (`test`.`t1`.`a` > 1) limit 1 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t1 WHERE a > 1 LIMIT 1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "table": { + "delete": true, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "filtered": "100.00", + "attached_condition": "(`test`.`t1`.`a` > 1)" + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 delete from `test`.`t1` where (`test`.`t1`.`a` > 1) limit 1 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 WHERE a > 1 LIMIT 1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.80" + } /* cost_info */, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 1, + "filtered": "33.33", + "cost_info": { + "read_cost": "0.70", + "eval_cost": "0.10", + "prefix_cost": "0.80", + "data_read_per_join": "8" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`a` > 1)" + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` > 1) limit 1 +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 1 +Handler_read_rnd_next 2 +# Status of testing query execution: +Variable_name Value +Handler_delete 1 +Handler_read_key 1 +Handler_read_rnd_next 2 + +DROP TABLE t1; +#12 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +# +# query: DELETE FROM t1 WHERE 0 +# select: SELECT * FROM t1 WHERE 0 +# +EXPLAIN DELETE FROM t1 WHERE 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 delete from `test`.`t1` where false +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t1 WHERE 0;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "message": "Impossible WHERE" + } /* query_block */ +} +Warnings: +Note 1003 delete from `test`.`t1` where false +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 WHERE 0;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "message": "Impossible WHERE" + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where false +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 1 + +DROP TABLE t1; +#13 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +# +# query: DELETE FROM t1 USING t1 WHERE 0 +# select: SELECT * FROM t1 WHERE 0 +# +EXPLAIN DELETE FROM t1 USING t1 WHERE 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 delete `test`.`t1` from `test`.`t1` where false +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t1 USING t1 WHERE 0;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "message": "Impossible WHERE" + } /* query_block */ +} +Warnings: +Note 1003 delete `test`.`t1` from `test`.`t1` where false +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 WHERE 0;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "message": "Impossible WHERE" + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where false +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 1 + +DROP TABLE t1; +#14 +CREATE TABLE t1 (a INT, b INT, UNIQUE KEY (a), KEY (b)); +INSERT INTO t1 VALUES (3, 3), (7, 7); +# +# query: DELETE FROM t1 WHERE a = 3 +# select: SELECT * FROM t1 WHERE a = 3 +# +EXPLAIN DELETE FROM t1 WHERE a = 3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL range a a 5 const 1 100.00 Using where +Warnings: +Note 1003 delete from `test`.`t1` where (`test`.`t1`.`a` = 3) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t1 WHERE a = 3;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "table": { + "delete": true, + "table_name": "t1", + "access_type": "range", + "possible_keys": [ + "a" + ] /* possible_keys */, + "key": "a", + "used_key_parts": [ + "a" + ] /* used_key_parts */, + "key_length": "5", + "ref": [ + "const" + ] /* ref */, + "rows_examined_per_scan": 1, + "filtered": "100.00", + "attached_condition": "(`test`.`t1`.`a` = 3)" + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 delete from `test`.`t1` where (`test`.`t1`.`a` = 3) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 WHERE a = 3;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.00" + } /* cost_info */, + "table": { + "table_name": "t1", + "access_type": "const", + "possible_keys": [ + "a" + ] /* possible_keys */, + "key": "a", + "used_key_parts": [ + "a" + ] /* used_key_parts */, + "key_length": "5", + "ref": [ + "const" + ] /* ref */, + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.00", + "eval_cost": "0.10", + "prefix_cost": "0.00", + "data_read_per_join": "16" + } /* cost_info */, + "used_columns": [ + "a", + "b" + ] /* used_columns */ + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select '3' AS `a`,'3' AS `b` from `test`.`t1` where true +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 3 +# Status of testing query execution: +Variable_name Value +Handler_delete 1 +Handler_read_key 3 + +DROP TABLE t1; +#15 +CREATE TABLE t1 (a INT, b INT, UNIQUE KEY (a), KEY (b)); +INSERT INTO t1 VALUES (3, 3), (7, 7); +# +# query: DELETE FROM t1 WHERE a < 3 +# select: SELECT * FROM t1 WHERE a < 3 +# +EXPLAIN DELETE FROM t1 WHERE a < 3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL range a a 5 const 1 100.00 Using where +Warnings: +Note 1003 delete from `test`.`t1` where (`test`.`t1`.`a` < 3) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t1 WHERE a < 3;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "table": { + "delete": true, + "table_name": "t1", + "access_type": "range", + "possible_keys": [ + "a" + ] /* possible_keys */, + "key": "a", + "used_key_parts": [ + "a" + ] /* used_key_parts */, + "key_length": "5", + "ref": [ + "const" + ] /* ref */, + "rows_examined_per_scan": 1, + "filtered": "100.00", + "attached_condition": "(`test`.`t1`.`a` < 3)" + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 delete from `test`.`t1` where (`test`.`t1`.`a` < 3) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 WHERE a < 3;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.71" + } /* cost_info */, + "table": { + "table_name": "t1", + "access_type": "range", + "possible_keys": [ + "a" + ] /* possible_keys */, + "key": "a", + "used_key_parts": [ + "a" + ] /* used_key_parts */, + "key_length": "5", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.61", + "eval_cost": "0.10", + "prefix_cost": "0.71", + "data_read_per_join": "16" + } /* cost_info */, + "used_columns": [ + "a", + "b" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`a` < 3)" + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (`test`.`t1`.`a` < 3) +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 3 +# Status of testing query execution: +Variable_name Value +Handler_read_key 3 + +DROP TABLE t1; +#16 +CREATE TABLE t1 ( a int PRIMARY KEY ); +# +# query: DELETE FROM t1 WHERE t1.a > 0 ORDER BY t1.a +# select: SELECT * FROM t1 WHERE t1.a > 0 ORDER BY t1.a +# +EXPLAIN DELETE FROM t1 WHERE t1.a > 0 ORDER BY t1.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL range PRIMARY PRIMARY 4 const 1 100.00 Using where +Warnings: +Note 1003 delete from `test`.`t1` where (`test`.`t1`.`a` > 0) order by `test`.`t1`.`a` +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t1 WHERE t1.a > 0 ORDER BY t1.a;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_filesort": false, + "table": { + "delete": true, + "table_name": "t1", + "access_type": "range", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "a" + ] /* used_key_parts */, + "key_length": "4", + "ref": [ + "const" + ] /* ref */, + "rows_examined_per_scan": 1, + "filtered": "100.00", + "attached_condition": "(`test`.`t1`.`a` > 0)" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 delete from `test`.`t1` where (`test`.`t1`.`a` > 0) order by `test`.`t1`.`a` +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 WHERE t1.a > 0 ORDER BY t1.a;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "message": "no matching row in const table" + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select NULL AS `a` from `test`.`t1` where (NULL > 0) order by NULL +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 1 +Handler_read_rnd_next 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 2 + +INSERT INTO t1 VALUES (1), (2), (3); +# +# query: DELETE FROM t1 WHERE t1.a > 0 ORDER BY t1.a +# select: SELECT * FROM t1 WHERE t1.a > 0 ORDER BY t1.a +# +EXPLAIN DELETE FROM t1 WHERE t1.a > 0 ORDER BY t1.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL range PRIMARY PRIMARY 4 const 3 100.00 Using where +Warnings: +Note 1003 delete from `test`.`t1` where (`test`.`t1`.`a` > 0) order by `test`.`t1`.`a` +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t1 WHERE t1.a > 0 ORDER BY t1.a;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_filesort": false, + "table": { + "delete": true, + "table_name": "t1", + "access_type": "range", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "a" + ] /* used_key_parts */, + "key_length": "4", + "ref": [ + "const" + ] /* ref */, + "rows_examined_per_scan": 3, + "filtered": "100.00", + "attached_condition": "(`test`.`t1`.`a` > 0)" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 delete from `test`.`t1` where (`test`.`t1`.`a` > 0) order by `test`.`t1`.`a` +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 WHERE t1.a > 0 ORDER BY t1.a;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.80" + } /* cost_info */, + "ordering_operation": { + "using_filesort": false, + "table": { + "table_name": "t1", + "access_type": "index", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "a" + ] /* used_key_parts */, + "key_length": "4", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "using_index": true, + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.30", + "prefix_cost": "0.80", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`a` > 0)" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` > 0) order by `test`.`t1`.`a` +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 1 +Handler_read_next 3 +# Status of testing query execution: +Variable_name Value +Handler_delete 3 +Handler_read_key 2 +Handler_read_next 3 + +DROP TABLE t1; +#17 +CREATE TABLE t1(a INT PRIMARY KEY); +INSERT INTO t1 VALUES (4),(3),(1),(2); +# +# query: DELETE FROM t1 WHERE (@a:= a) ORDER BY a LIMIT 1 +# select: SELECT * FROM t1 WHERE (@a:= a) ORDER BY a LIMIT 1 +# +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +EXPLAIN DELETE FROM t1 WHERE (@a:= a) ORDER BY a LIMIT 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL index NULL PRIMARY 4 NULL 4 100.00 Using where +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +Note 1003 delete from `test`.`t1` where (0 <> (@a:=`test`.`t1`.`a`)) order by `test`.`t1`.`a` limit 1 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t1 WHERE (@a:= a) ORDER BY a LIMIT 1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_filesort": false, + "table": { + "delete": true, + "table_name": "t1", + "access_type": "index", + "key": "PRIMARY", + "used_key_parts": [ + "a" + ] /* used_key_parts */, + "key_length": "4", + "rows_examined_per_scan": 4, + "filtered": "100.00", + "attached_condition": "(0 <> (@a:=`test`.`t1`.`a`))" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +Note 1003 delete from `test`.`t1` where (0 <> (@a:=`test`.`t1`.`a`)) order by `test`.`t1`.`a` limit 1 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 WHERE (@a:= a) ORDER BY a LIMIT 1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.90" + } /* cost_info */, + "ordering_operation": { + "using_filesort": false, + "table": { + "table_name": "t1", + "access_type": "index", + "key": "PRIMARY", + "used_key_parts": [ + "a" + ] /* used_key_parts */, + "key_length": "4", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 4, + "filtered": "100.00", + "using_index": true, + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.40", + "prefix_cost": "0.90", + "data_read_per_join": "32" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(0 <> (@a:=`test`.`t1`.`a`))" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (0 <> (@a:=`test`.`t1`.`a`)) order by `test`.`t1`.`a` limit 1 +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 1 +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +# Status of testing query execution: +Variable_name Value +Handler_delete 1 +Handler_read_first 1 +Handler_read_key 1 + +DROP TABLE t1; +#18 +CREATE TABLE t1 (a DATE, b TIME, c INT, KEY c(c), KEY b(b), KEY a(a)); +INSERT INTO t1 VALUES (), (), (), (), (), (), (), (), (), (); +UPDATE t1 SET a = c, b = c; +# +# query: DELETE FROM t1 ORDER BY a ASC, b ASC LIMIT 1 +# select: SELECT * FROM t1 ORDER BY a ASC, b ASC LIMIT 1 +# +EXPLAIN DELETE FROM t1 ORDER BY a ASC, b ASC LIMIT 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 10 100.00 Using filesort +Warnings: +Note 1003 delete from `test`.`t1` order by `test`.`t1`.`a`,`test`.`t1`.`b` limit 1 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t1 ORDER BY a ASC, b ASC LIMIT 1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_filesort": true, + "table": { + "delete": true, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 10, + "filtered": "100.00" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 delete from `test`.`t1` order by `test`.`t1`.`a`,`test`.`t1`.`b` limit 1 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 ORDER BY a ASC, b ASC LIMIT 1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.51" + } /* cost_info */, + "ordering_operation": { + "using_filesort": true, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 10, + "rows_produced_per_join": 10, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "1.00", + "prefix_cost": "1.51", + "data_read_per_join": "160" + } /* cost_info */, + "used_columns": [ + "a", + "b", + "c" + ] /* used_columns */ + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` order by `test`.`t1`.`a`,`test`.`t1`.`b` limit 1 +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 3 +Handler_read_rnd_next 11 +Sort_rows 1 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_delete 1 +Handler_read_key 3 +Handler_read_rnd 1 +Handler_read_rnd_next 11 +Sort_rows 10 +Sort_scan 1 + +DROP TABLE t1; +#19 +CREATE TABLE t1 (a1 INT NOT NULL, b1 INT NOT NULL); +CREATE TABLE t2 (a2 INT NOT NULL, b2 INT NOT NULL, PRIMARY KEY (a2,b2)); +CREATE TABLE t3 (a3 INT NOT NULL, b3 INT NOT NULL, PRIMARY KEY (a3,b3)); +INSERT INTO t1 VALUES (1,1), (2,1), (1,3); +INSERT INTO t2 VALUES (1,1), (2,2), (3,3); +INSERT INTO t3 VALUES (1,1), (2,1), (1,3); +# +# query: DELETE t1,t2,t3 FROM t1,t2,t3 WHERE a1=a2 AND b2=a3 AND b1=b3 +# select: SELECT * FROM t1,t2,t3 WHERE a1=a2 AND b2=a3 AND b1=b3 +# +EXPLAIN DELETE t1,t2,t3 FROM t1,t2,t3 WHERE a1=a2 AND b2=a3 AND b1=b3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 DELETE t2 NULL ref PRIMARY PRIMARY 4 test.t1.a1 1 100.00 NULL +1 DELETE t3 NULL eq_ref PRIMARY PRIMARY 8 test.t2.b2,test.t1.b1 1 100.00 NULL +Warnings: +Note 1003 delete `test`.`t1`, `test`.`t2`, `test`.`t3` from `test`.`t1` join `test`.`t2` join `test`.`t3` where ((`test`.`t3`.`b3` = `test`.`t1`.`b1`) and (`test`.`t3`.`a3` = `test`.`t2`.`b2`) and (`test`.`t2`.`a2` = `test`.`t1`.`a1`)) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE t1,t2,t3 FROM t1,t2,t3 WHERE a1=a2 AND b2=a3 AND b1=b3;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "2.90" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "delete": true, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.30", + "prefix_cost": "0.80", + "data_read_per_join": "48" + } /* cost_info */, + "used_columns": [ + "a1", + "b1" + ] /* used_columns */ + } /* table */ + }, + { + "table": { + "delete": true, + "table_name": "t2", + "access_type": "ref", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "a2" + ] /* used_key_parts */, + "key_length": "4", + "ref": [ + "test.t1.a1" + ] /* ref */, + "rows_examined_per_scan": 1, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.75", + "eval_cost": "0.30", + "prefix_cost": "1.85", + "data_read_per_join": "48" + } /* cost_info */, + "used_columns": [ + "a2", + "b2" + ] /* used_columns */ + } /* table */ + }, + { + "table": { + "delete": true, + "table_name": "t3", + "access_type": "eq_ref", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "a3", + "b3" + ] /* used_key_parts */, + "key_length": "8", + "ref": [ + "test.t2.b2", + "test.t1.b1" + ] /* ref */, + "rows_examined_per_scan": 1, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.75", + "eval_cost": "0.30", + "prefix_cost": "2.90", + "data_read_per_join": "48" + } /* cost_info */, + "used_columns": [ + "a3", + "b3" + ] /* used_columns */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 delete `test`.`t1`, `test`.`t2`, `test`.`t3` from `test`.`t1` join `test`.`t2` join `test`.`t3` where ((`test`.`t3`.`b3` = `test`.`t1`.`b1`) and (`test`.`t3`.`a3` = `test`.`t2`.`b2`) and (`test`.`t2`.`a2` = `test`.`t1`.`a1`)) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1,t2,t3 WHERE a1=a2 AND b2=a3 AND b1=b3;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "2.90" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.30", + "prefix_cost": "0.80", + "data_read_per_join": "48" + } /* cost_info */, + "used_columns": [ + "a1", + "b1" + ] /* used_columns */ + } /* table */ + }, + { + "table": { + "table_name": "t2", + "access_type": "ref", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "a2" + ] /* used_key_parts */, + "key_length": "4", + "ref": [ + "test.t1.a1" + ] /* ref */, + "rows_examined_per_scan": 1, + "rows_produced_per_join": 3, + "filtered": "100.00", + "using_index": true, + "cost_info": { + "read_cost": "0.75", + "eval_cost": "0.30", + "prefix_cost": "1.85", + "data_read_per_join": "48" + } /* cost_info */, + "used_columns": [ + "a2", + "b2" + ] /* used_columns */ + } /* table */ + }, + { + "table": { + "table_name": "t3", + "access_type": "eq_ref", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "a3", + "b3" + ] /* used_key_parts */, + "key_length": "8", + "ref": [ + "test.t2.b2", + "test.t1.b1" + ] /* ref */, + "rows_examined_per_scan": 1, + "rows_produced_per_join": 3, + "filtered": "100.00", + "using_index": true, + "cost_info": { + "read_cost": "0.75", + "eval_cost": "0.30", + "prefix_cost": "2.90", + "data_read_per_join": "48" + } /* cost_info */, + "used_columns": [ + "a3", + "b3" + ] /* used_columns */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`b1` AS `b1`,`test`.`t2`.`a2` AS `a2`,`test`.`t2`.`b2` AS `b2`,`test`.`t3`.`a3` AS `a3`,`test`.`t3`.`b3` AS `b3` from `test`.`t1` join `test`.`t2` join `test`.`t3` where ((`test`.`t3`.`b3` = `test`.`t1`.`b1`) and (`test`.`t3`.`a3` = `test`.`t2`.`b2`) and (`test`.`t2`.`a2` = `test`.`t1`.`a1`)) +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 12 +Handler_read_next 3 +Handler_read_rnd_next 4 +# Status of testing query execution: +Variable_name Value +Handler_delete 8 +Handler_read_key 12 +Handler_read_next 3 +Handler_read_rnd 5 +Handler_read_rnd_next 4 + +DROP TABLE t1, t2, t3; +#20 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +CREATE TABLE t2 (a INT); +INSERT INTO t2 VALUES (1), (2), (3); +# +# query: UPDATE t1 SET a = 10 WHERE a IN (SELECT a FROM t2) +# select: SELECT * FROM t1 WHERE a IN (SELECT a FROM t2) +# +EXPLAIN UPDATE t1 SET a = 10 WHERE a IN (SELECT a FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`a` = 10 where (`test`.`t1`.`a`,(/* select#2 */ select `test`.`t2`.`a` from `test`.`t2` where ((`test`.`t1`.`a`) = `test`.`t2`.`a`))) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t1 SET a = 10 WHERE a IN (SELECT a FROM t2);; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "table": { + "update": true, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "filtered": "100.00", + "attached_condition": "(`test`.`t1`.`a`,(/* select#2 */ select `test`.`t2`.`a` from `test`.`t2` where ((`test`.`t1`.`a`) = `test`.`t2`.`a`)))", + "attached_subqueries": [ + { + "dependent": true, + "cacheable": false, + "query_block": { + "select_id": 2, + "cost_info": { + "query_cost": "0.80" + } /* cost_info */, + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 1, + "filtered": "33.33", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.10", + "prefix_cost": "0.80", + "data_read_per_join": "8" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "((`test`.`t1`.`a`) = `test`.`t2`.`a`)" + } /* table */ + } /* query_block */ + } + ] /* attached_subqueries */ + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`a` = 10 where (`test`.`t1`.`a`,(/* select#2 */ select `test`.`t2`.`a` from `test`.`t2` where ((`test`.`t1`.`a`) = `test`.`t2`.`a`))) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 WHERE a IN (SELECT a FROM t2);; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.80" + } /* cost_info */, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.30", + "prefix_cost": "0.80", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`a`,(/* select#2 */ select `test`.`t2`.`a` from `test`.`t2` where ((`test`.`t1`.`a`) = `test`.`t2`.`a`)))", + "attached_subqueries": [ + { + "dependent": true, + "cacheable": false, + "query_block": { + "select_id": 2, + "cost_info": { + "query_cost": "0.80" + } /* cost_info */, + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 1, + "filtered": "33.33", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.10", + "prefix_cost": "0.80", + "data_read_per_join": "8" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "((`test`.`t1`.`a`) = `test`.`t2`.`a`)" + } /* table */ + } /* query_block */ + } + ] /* attached_subqueries */ + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a`,(/* select#2 */ select `test`.`t2`.`a` from `test`.`t2` where ((`test`.`t1`.`a`) = `test`.`t2`.`a`))) +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 10 +# Status of testing query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 10 +Handler_update 3 + +DROP TABLE t1, t2; +#21 +CREATE TABLE t1 (a1 INT); +INSERT INTO t1 VALUES (1), (2), (3), (4), (5); +CREATE TABLE t2 (a2 VARCHAR(10)) charset utf8mb4; +INSERT INTO t2 VALUES (1), (2), (3), (4), (5); +SET @save_optimizer_switch= @@optimizer_switch; +# +# query: DELETE FROM t1 WHERE a1 IN (SELECT a2 FROM t2 WHERE a2 > 2) +# select: SELECT * FROM t1 WHERE a1 IN (SELECT a2 FROM t2 WHERE a2 > 2) +# +EXPLAIN DELETE FROM t1 WHERE a1 IN (SELECT a2 FROM t2 WHERE a2 > 2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 5 100.00 Using where +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 5 20.00 Using where +Warnings: +Note 1003 delete from `test`.`t1` where (`test`.`t1`.`a1`,(/* select#2 */ select `test`.`t2`.`a2` from `test`.`t2` where ((`test`.`t2`.`a2` > 2) and ((`test`.`t1`.`a1`) = `test`.`t2`.`a2`)))) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t1 WHERE a1 IN (SELECT a2 FROM t2 WHERE a2 > 2);; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "table": { + "delete": true, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "filtered": "100.00", + "attached_condition": "(`test`.`t1`.`a1`,(/* select#2 */ select `test`.`t2`.`a2` from `test`.`t2` where ((`test`.`t2`.`a2` > 2) and ((`test`.`t1`.`a1`) = `test`.`t2`.`a2`))))", + "attached_subqueries": [ + { + "dependent": true, + "cacheable": false, + "query_block": { + "select_id": 2, + "cost_info": { + "query_cost": "1.01" + } /* cost_info */, + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 1, + "filtered": "20.00", + "cost_info": { + "read_cost": "0.84", + "eval_cost": "0.10", + "prefix_cost": "1.01", + "data_read_per_join": "48" + } /* cost_info */, + "used_columns": [ + "a2" + ] /* used_columns */, + "attached_condition": "((`test`.`t2`.`a2` > 2) and ((`test`.`t1`.`a1`) = `test`.`t2`.`a2`))" + } /* table */ + } /* query_block */ + } + ] /* attached_subqueries */ + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 delete from `test`.`t1` where (`test`.`t1`.`a1`,(/* select#2 */ select `test`.`t2`.`a2` from `test`.`t2` where ((`test`.`t2`.`a2` > 2) and ((`test`.`t1`.`a1`) = `test`.`t2`.`a2`)))) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 WHERE a1 IN (SELECT a2 FROM t2 WHERE a2 > 2);; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.00" + } /* cost_info */, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.50", + "prefix_cost": "1.00", + "data_read_per_join": "40" + } /* cost_info */, + "used_columns": [ + "a1" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`a1`,(/* select#2 */ select `test`.`t2`.`a2` from `test`.`t2` where ((`test`.`t2`.`a2` > 2) and ((`test`.`t1`.`a1`) = `test`.`t2`.`a2`))))", + "attached_subqueries": [ + { + "dependent": true, + "cacheable": false, + "query_block": { + "select_id": 2, + "cost_info": { + "query_cost": "1.01" + } /* cost_info */, + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 1, + "filtered": "20.00", + "cost_info": { + "read_cost": "0.84", + "eval_cost": "0.10", + "prefix_cost": "1.01", + "data_read_per_join": "48" + } /* cost_info */, + "used_columns": [ + "a2" + ] /* used_columns */, + "attached_condition": "((`test`.`t2`.`a2` > 2) and ((`test`.`t1`.`a1`) = `test`.`t2`.`a2`))" + } /* table */ + } /* query_block */ + } + ] /* attached_subqueries */ + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1` from `test`.`t1` where (`test`.`t1`.`a1`,(/* select#2 */ select `test`.`t2`.`a2` from `test`.`t2` where ((`test`.`t2`.`a2` > 2) and ((`test`.`t1`.`a1`) = `test`.`t2`.`a2`)))) +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 30 +# Status of testing query execution: +Variable_name Value +Handler_delete 3 +Handler_read_key 2 +Handler_read_rnd_next 30 + +SET @@optimizer_switch= @save_optimizer_switch; +TRUNCATE t1; +INSERT INTO t1 VALUES (1), (2), (3), (4), (5); +# +# query: DELETE FROM t1 WHERE a1 IN (SELECT a2 FROM t2 WHERE a2 > 2) +# select: SELECT * FROM t1 WHERE a1 IN (SELECT a2 FROM t2 WHERE a2 > 2) +# +EXPLAIN DELETE FROM t1 WHERE a1 IN (SELECT a2 FROM t2 WHERE a2 > 2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 5 100.00 Using where +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 5 20.00 Using where +Warnings: +Note 1003 delete from `test`.`t1` where (`test`.`t1`.`a1`,(/* select#2 */ select `test`.`t2`.`a2` from `test`.`t2` where ((`test`.`t2`.`a2` > 2) and ((`test`.`t1`.`a1`) = `test`.`t2`.`a2`)))) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t1 WHERE a1 IN (SELECT a2 FROM t2 WHERE a2 > 2);; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "table": { + "delete": true, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "filtered": "100.00", + "attached_condition": "(`test`.`t1`.`a1`,(/* select#2 */ select `test`.`t2`.`a2` from `test`.`t2` where ((`test`.`t2`.`a2` > 2) and ((`test`.`t1`.`a1`) = `test`.`t2`.`a2`))))", + "attached_subqueries": [ + { + "dependent": true, + "cacheable": false, + "query_block": { + "select_id": 2, + "cost_info": { + "query_cost": "1.01" + } /* cost_info */, + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 1, + "filtered": "20.00", + "cost_info": { + "read_cost": "0.84", + "eval_cost": "0.10", + "prefix_cost": "1.01", + "data_read_per_join": "48" + } /* cost_info */, + "used_columns": [ + "a2" + ] /* used_columns */, + "attached_condition": "((`test`.`t2`.`a2` > 2) and ((`test`.`t1`.`a1`) = `test`.`t2`.`a2`))" + } /* table */ + } /* query_block */ + } + ] /* attached_subqueries */ + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 delete from `test`.`t1` where (`test`.`t1`.`a1`,(/* select#2 */ select `test`.`t2`.`a2` from `test`.`t2` where ((`test`.`t2`.`a2` > 2) and ((`test`.`t1`.`a1`) = `test`.`t2`.`a2`)))) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 WHERE a1 IN (SELECT a2 FROM t2 WHERE a2 > 2);; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.00" + } /* cost_info */, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.50", + "prefix_cost": "1.00", + "data_read_per_join": "40" + } /* cost_info */, + "used_columns": [ + "a1" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`a1`,(/* select#2 */ select `test`.`t2`.`a2` from `test`.`t2` where ((`test`.`t2`.`a2` > 2) and ((`test`.`t1`.`a1`) = `test`.`t2`.`a2`))))", + "attached_subqueries": [ + { + "dependent": true, + "cacheable": false, + "query_block": { + "select_id": 2, + "cost_info": { + "query_cost": "1.01" + } /* cost_info */, + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 1, + "filtered": "20.00", + "cost_info": { + "read_cost": "0.84", + "eval_cost": "0.10", + "prefix_cost": "1.01", + "data_read_per_join": "48" + } /* cost_info */, + "used_columns": [ + "a2" + ] /* used_columns */, + "attached_condition": "((`test`.`t2`.`a2` > 2) and ((`test`.`t1`.`a1`) = `test`.`t2`.`a2`))" + } /* table */ + } /* query_block */ + } + ] /* attached_subqueries */ + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1` from `test`.`t1` where (`test`.`t1`.`a1`,(/* select#2 */ select `test`.`t2`.`a2` from `test`.`t2` where ((`test`.`t2`.`a2` > 2) and ((`test`.`t1`.`a1`) = `test`.`t2`.`a2`)))) +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 30 +# Status of testing query execution: +Variable_name Value +Handler_delete 3 +Handler_read_key 2 +Handler_read_rnd_next 30 + +DROP TABLE t1, t2; +#22 +CREATE TABLE t1 (i INT, j INT); +INSERT INTO t1 VALUES (1, 1), (2, 2), (3, 3), (4, 4), (5, 5); +# +# query: UPDATE t1 SET i = 10 +# select: SELECT * FROM t1 +# +EXPLAIN UPDATE t1 SET i = 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`i` = 10 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t1 SET i = 10;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "table": { + "update": true, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "filtered": "100.00" + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`i` = 10 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.00" + } /* cost_info */, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.50", + "prefix_cost": "1.00", + "data_read_per_join": "80" + } /* cost_info */, + "used_columns": [ + "i", + "j" + ] /* used_columns */ + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i`,`test`.`t1`.`j` AS `j` from `test`.`t1` +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 6 +# Status of testing query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 6 +Handler_update 5 + +DROP TABLE t1; +#23 +CREATE TABLE t1 (i INT, j INT); +INSERT INTO t1 VALUES (1, 1), (2, 2), (3, 3), (4, 4), (5, 5); +# +# query: DELETE FROM t1 +# select: SELECT * FROM t1 +# +EXPLAIN DELETE FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 5 100.00 Deleting all rows +Warnings: +Note 1003 delete from `test`.`t1` +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "table": { + "delete": true, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "filtered": "100.00", + "message": "Deleting all rows" + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 delete from `test`.`t1` +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.00" + } /* cost_info */, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.50", + "prefix_cost": "1.00", + "data_read_per_join": "80" + } /* cost_info */, + "used_columns": [ + "i", + "j" + ] /* used_columns */ + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i`,`test`.`t1`.`j` AS `j` from `test`.`t1` +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 6 +# Status of testing query execution: +Variable_name Value +Handler_read_key 2 + +DROP TABLE t1; +#24 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2(a INT, b INT, c INT, d INT, INDEX(a, b, c)); +INSERT INTO t2 (a, b, c) SELECT i, i, i FROM t1; +INSERT INTO t2 (a, b, c) SELECT t1.i, t1.i, t1.i FROM t1, t1 x1, t1 x2; +# +# query: DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# select: SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# +EXPLAIN DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t2 NULL index NULL a 15 NULL 17602 100.00 Using where +Warnings: +Note 1003 delete from `test`.`t2` where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_filesort": false, + "table": { + "delete": true, + "table_name": "t2", + "access_type": "index", + "key": "a", + "used_key_parts": [ + "a", + "b", + "c" + ] /* used_key_parts */, + "key_length": "15", + "rows_examined_per_scan": 17602, + "filtered": "100.00", + "attached_condition": "(`test`.`t2`.`b` = 10)" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 delete from `test`.`t2` where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1778.96" + } /* cost_info */, + "ordering_operation": { + "using_filesort": false, + "table": { + "table_name": "t2", + "access_type": "index", + "key": "a", + "used_key_parts": [ + "a", + "b", + "c" + ] /* used_key_parts */, + "key_length": "15", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 1760, + "filtered": "10.00", + "cost_info": { + "read_cost": "1602.94", + "eval_cost": "176.02", + "prefix_cost": "1778.96", + "data_read_per_join": "41K" + } /* cost_info */, + "used_columns": [ + "a", + "b", + "c", + "d" + ] /* used_columns */, + "attached_condition": "(`test`.`t2`.`b` = 10)" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c`,`test`.`t2`.`d` AS `d` from `test`.`t2` where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 4 +Handler_read_next 4 +# Status of testing query execution: +Variable_name Value +Handler_delete 5 +Handler_read_first 1 +Handler_read_key 4 +Handler_read_next 4 + +DROP TABLE t1, t2; +#25 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (1), (2), (3); +CREATE TABLE t2 (i INT); +# +# query: INSERT INTO t2 SELECT * FROM t1 +# select: SELECT * FROM t1 +# +EXPLAIN INSERT INTO t2 SELECT * FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 INSERT t2 NULL ALL NULL NULL NULL NULL NULL NULL NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 insert into `test`.`t2` /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON INSERT INTO t2 SELECT * FROM t1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.80" + } /* cost_info */, + "table": { + "insert": true, + "table_name": "t2", + "access_type": "ALL" + } /* table */, + "insert_from": { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.30", + "prefix_cost": "0.80", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "i" + ] /* used_columns */ + } /* table */ + } /* insert_from */ + } /* query_block */ +} +Warnings: +Note 1003 insert into `test`.`t2` /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.80" + } /* cost_info */, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.30", + "prefix_cost": "0.80", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "i" + ] /* used_columns */ + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 1 +Handler_read_rnd_next 4 +# Status of testing query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 4 +Handler_write 3 + +# +# query: INSERT INTO t2 SELECT * FROM t1 JOIN t1 AS tt USING(i) +# select: SELECT * FROM t1 JOIN t1 AS tt USING(i) +# +EXPLAIN INSERT INTO t2 SELECT * FROM t1 JOIN t1 AS tt USING(i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 INSERT t2 NULL ALL NULL NULL NULL NULL NULL NULL NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE tt NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +Warnings: +Note 1003 insert into `test`.`t2` /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` join `test`.`t1` `tt` where (`test`.`tt`.`i` = `test`.`t1`.`i`) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON INSERT INTO t2 SELECT * FROM t1 JOIN t1 AS tt USING(i);; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "2.20" + } /* cost_info */, + "table": { + "insert": true, + "table_name": "t2", + "access_type": "ALL" + } /* table */, + "insert_from": { + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.30", + "prefix_cost": "0.80", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "i" + ] /* used_columns */ + } /* table */ + }, + { + "table": { + "table_name": "tt", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "33.33", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.30", + "prefix_cost": "2.20", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "i" + ] /* used_columns */, + "attached_condition": "(`test`.`tt`.`i` = `test`.`t1`.`i`)" + } /* table */ + } + ] /* nested_loop */ + } /* insert_from */ + } /* query_block */ +} +Warnings: +Note 1003 insert into `test`.`t2` /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` join `test`.`t1` `tt` where (`test`.`tt`.`i` = `test`.`t1`.`i`) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 JOIN t1 AS tt USING(i);; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "2.20" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.30", + "prefix_cost": "0.80", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "i" + ] /* used_columns */ + } /* table */ + }, + { + "table": { + "table_name": "tt", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "33.33", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.30", + "prefix_cost": "2.20", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "i" + ] /* used_columns */, + "attached_condition": "(`test`.`tt`.`i` = `test`.`t1`.`i`)" + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` join `test`.`t1` `tt` where (`test`.`tt`.`i` = `test`.`t1`.`i`) +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 1 +Handler_read_rnd_next 8 +# Status of testing query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 8 +Handler_write 3 + +DROP TABLE t1, t2; +#26 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (1), (2), (3); +CREATE TABLE t2 (i INT); +# +# query: REPLACE INTO t2 SELECT * FROM t1 +# select: SELECT * FROM t1 +# +EXPLAIN REPLACE INTO t2 SELECT * FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 REPLACE t2 NULL ALL NULL NULL NULL NULL NULL NULL NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 replace into `test`.`t2` /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON REPLACE INTO t2 SELECT * FROM t1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.80" + } /* cost_info */, + "table": { + "replace": true, + "table_name": "t2", + "access_type": "ALL" + } /* table */, + "insert_from": { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.30", + "prefix_cost": "0.80", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "i" + ] /* used_columns */ + } /* table */ + } /* insert_from */ + } /* query_block */ +} +Warnings: +Note 1003 replace into `test`.`t2` /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.80" + } /* cost_info */, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.30", + "prefix_cost": "0.80", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "i" + ] /* used_columns */ + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 1 +Handler_read_rnd_next 4 +# Status of testing query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 4 +Handler_write 3 + +DROP TABLE t1, t2; +#27 +CREATE TABLE t1 (i INT); +# +# query: INSERT INTO t1 SET i = 10 +# select: +# +EXPLAIN INSERT INTO t1 SET i = 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 INSERT t1 NULL ALL NULL NULL NULL NULL NULL NULL NULL +Warnings: +Note 1003 insert into `test`.`t1` (`test`.`t1`.`i`) values (10) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON INSERT INTO t1 SET i = 10;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "table": { + "insert": true, + "table_name": "t1", + "access_type": "ALL" + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 insert into `test`.`t1` (`test`.`t1`.`i`) values (10) +# Status of testing query execution: +Variable_name Value +Handler_read_key 1 +Handler_write 1 + +DROP TABLE t1; +#28 +CREATE TABLE t1 (i INT); +# +# query: REPLACE INTO t1 SET i = 10 +# select: +# +EXPLAIN REPLACE INTO t1 SET i = 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 REPLACE t1 NULL ALL NULL NULL NULL NULL NULL NULL NULL +Warnings: +Note 1003 replace into `test`.`t1` (`test`.`t1`.`i`) values (10) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON REPLACE INTO t1 SET i = 10;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "table": { + "replace": true, + "table_name": "t1", + "access_type": "ALL" + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 replace into `test`.`t1` (`test`.`t1`.`i`) values (10) +# Status of testing query execution: +Variable_name Value +Handler_read_key 1 +Handler_write 1 + +DROP TABLE t1; +#29 +CREATE TABLE t1 (a INT, i INT PRIMARY KEY); +INSERT INTO t1 (i) VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +# +# query: DELETE FROM t1 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 1 +# select: SELECT * FROM t1 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 1 +# +EXPLAIN DELETE FROM t1 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL range PRIMARY PRIMARY 4 const 8 100.00 Using where +Warnings: +Note 1003 delete from `test`.`t1` where ((`test`.`t1`.`i` > 10) and (`test`.`t1`.`i` <= 18)) order by `test`.`t1`.`i` limit 1 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t1 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_filesort": false, + "table": { + "delete": true, + "table_name": "t1", + "access_type": "range", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "i" + ] /* used_key_parts */, + "key_length": "4", + "ref": [ + "const" + ] /* ref */, + "rows_examined_per_scan": 8, + "filtered": "100.00", + "attached_condition": "((`test`.`t1`.`i` > 10) and (`test`.`t1`.`i` <= 18))" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 delete from `test`.`t1` where ((`test`.`t1`.`i` > 10) and (`test`.`t1`.`i` <= 18)) order by `test`.`t1`.`i` limit 1 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "3.86" + } /* cost_info */, + "ordering_operation": { + "using_filesort": false, + "table": { + "table_name": "t1", + "access_type": "range", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "i" + ] /* used_key_parts */, + "key_length": "4", + "rows_examined_per_scan": 8, + "rows_produced_per_join": 8, + "filtered": "100.00", + "cost_info": { + "read_cost": "3.06", + "eval_cost": "0.80", + "prefix_cost": "3.86", + "data_read_per_join": "128" + } /* cost_info */, + "used_columns": [ + "a", + "i" + ] /* used_columns */, + "attached_condition": "((`test`.`t1`.`i` > 10) and (`test`.`t1`.`i` <= 18))" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`i` AS `i` from `test`.`t1` where ((`test`.`t1`.`i` > 10) and (`test`.`t1`.`i` <= 18)) order by `test`.`t1`.`i` limit 1 +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 3 +# Status of testing query execution: +Variable_name Value +Handler_delete 1 +Handler_read_key 3 + +DROP TABLE t1; +#30 +CREATE TABLE t1(a INT, i CHAR(2), INDEX(i(1))) charset utf8mb4; +INSERT INTO t1 (i) VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +# +# query: DELETE FROM t1 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 5 +# select: SELECT * FROM t1 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 5 +# +EXPLAIN DELETE FROM t1 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 26 100.00 Using where; Using filesort +Warnings: +Warning 1739 Cannot use range access on index 'i' due to type or collation conversion on field 'i' +Warning 1739 Cannot use range access on index 'i' due to type or collation conversion on field 'i' +Note 1003 delete from `test`.`t1` where ((`test`.`t1`.`i` > 10) and (`test`.`t1`.`i` <= 18)) order by `test`.`t1`.`i` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t1 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_filesort": true, + "table": { + "delete": true, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 26, + "filtered": "100.00", + "attached_condition": "((`test`.`t1`.`i` > 10) and (`test`.`t1`.`i` <= 18))" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Warning 1739 Cannot use range access on index 'i' due to type or collation conversion on field 'i' +Warning 1739 Cannot use range access on index 'i' due to type or collation conversion on field 'i' +Note 1003 delete from `test`.`t1` where ((`test`.`t1`.`i` > 10) and (`test`.`t1`.`i` <= 18)) order by `test`.`t1`.`i` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "6.01" + } /* cost_info */, + "ordering_operation": { + "using_filesort": true, + "cost_info": { + "sort_cost": "2.89" + } /* cost_info */, + "table": { + "table_name": "t1", + "access_type": "ALL", + "possible_keys": [ + "i" + ] /* possible_keys */, + "rows_examined_per_scan": 26, + "rows_produced_per_join": 2, + "filtered": "11.11", + "cost_info": { + "read_cost": "2.83", + "eval_cost": "0.29", + "prefix_cost": "3.12", + "data_read_per_join": "46" + } /* cost_info */, + "used_columns": [ + "a", + "i" + ] /* used_columns */, + "attached_condition": "((`test`.`t1`.`i` > 10) and (`test`.`t1`.`i` <= 18))" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Warning 1739 Cannot use range access on index 'i' due to type or collation conversion on field 'i' +Warning 1739 Cannot use range access on index 'i' due to type or collation conversion on field 'i' +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`i` AS `i` from `test`.`t1` where ((`test`.`t1`.`i` > 10) and (`test`.`t1`.`i` <= 18)) order by `test`.`t1`.`i` limit 5 +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 27 +Sort_rows 5 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_delete 5 +Handler_read_key 2 +Handler_read_rnd 5 +Handler_read_rnd_next 27 +Sort_rows 8 +Sort_scan 1 + +DROP TABLE t1; +#31 +CREATE TABLE t1 (i INT); +INSERT INTO t1 (i) VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2(a INT, b INT, c INT, d INT, INDEX(a, b, c)); +INSERT INTO t2 (a, b, c) SELECT i, i, i FROM t1; +# +# query: DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# select: SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# +EXPLAIN DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t2 NULL ALL NULL NULL NULL NULL 26 100.00 Using where; Using filesort +Warnings: +Note 1003 delete from `test`.`t2` where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_filesort": true, + "table": { + "delete": true, + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 26, + "filtered": "100.00", + "attached_condition": "(`test`.`t2`.`b` = 10)" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 delete from `test`.`t2` where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "3.13" + } /* cost_info */, + "ordering_operation": { + "using_filesort": false, + "table": { + "table_name": "t2", + "access_type": "index", + "key": "a", + "used_key_parts": [ + "a", + "b", + "c" + ] /* used_key_parts */, + "key_length": "15", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 2, + "filtered": "10.00", + "cost_info": { + "read_cost": "2.87", + "eval_cost": "0.26", + "prefix_cost": "3.13", + "data_read_per_join": "62" + } /* cost_info */, + "used_columns": [ + "a", + "b", + "c", + "d" + ] /* used_columns */, + "attached_condition": "(`test`.`t2`.`b` = 10)" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c`,`test`.`t2`.`d` AS `d` from `test`.`t2` where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 4 +Handler_read_next 26 +# Status of testing query execution: +Variable_name Value +Handler_delete 1 +Handler_read_key 4 +Handler_read_rnd 1 +Handler_read_rnd_next 27 +Sort_rows 1 +Sort_scan 1 + +DROP TABLE t1, t2; +#32 +CREATE TABLE t1 (i INT); +INSERT INTO t1 (i) VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2(a INT, b INT, c INT, d INT, INDEX(a, b, c)); +INSERT INTO t2 (a, b, c) SELECT i, i, i FROM t1; +INSERT INTO t2 (a, b, c) SELECT t1.i, t1.i, t1.i FROM t1, t1 x1, t1 x2; +# +# query: DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# select: SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# +EXPLAIN DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t2 NULL index NULL a 15 NULL 17602 100.00 Using where +Warnings: +Note 1003 delete from `test`.`t2` where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_filesort": false, + "table": { + "delete": true, + "table_name": "t2", + "access_type": "index", + "key": "a", + "used_key_parts": [ + "a", + "b", + "c" + ] /* used_key_parts */, + "key_length": "15", + "rows_examined_per_scan": 17602, + "filtered": "100.00", + "attached_condition": "(`test`.`t2`.`b` = 10)" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 delete from `test`.`t2` where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1778.96" + } /* cost_info */, + "ordering_operation": { + "using_filesort": false, + "table": { + "table_name": "t2", + "access_type": "index", + "key": "a", + "used_key_parts": [ + "a", + "b", + "c" + ] /* used_key_parts */, + "key_length": "15", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 1760, + "filtered": "10.00", + "cost_info": { + "read_cost": "1602.94", + "eval_cost": "176.02", + "prefix_cost": "1778.96", + "data_read_per_join": "41K" + } /* cost_info */, + "used_columns": [ + "a", + "b", + "c", + "d" + ] /* used_columns */, + "attached_condition": "(`test`.`t2`.`b` = 10)" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c`,`test`.`t2`.`d` AS `d` from `test`.`t2` where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 4 +Handler_read_next 4 +# Status of testing query execution: +Variable_name Value +Handler_delete 5 +Handler_read_first 1 +Handler_read_key 4 +Handler_read_next 4 + +DROP TABLE t1, t2; +#33 +CREATE TABLE t1 (i INT); +INSERT INTO t1 (i) VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2 (a CHAR(2), b CHAR(2), c CHAR(2), d CHAR(2), INDEX (a,b(1),c)) +charset utf8mb4; +INSERT INTO t2 SELECT i, i, i, i FROM t1; +# +# query: DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# select: SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# +EXPLAIN DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t2 NULL ALL NULL NULL NULL NULL 26 100.00 Using where; Using filesort +Warnings: +Warning 1739 Cannot use range access on index 'a' due to type or collation conversion on field 'b' +Note 1003 delete from `test`.`t2` where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_filesort": true, + "table": { + "delete": true, + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 26, + "filtered": "100.00", + "attached_condition": "(`test`.`t2`.`b` = 10)" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Warning 1739 Cannot use range access on index 'a' due to type or collation conversion on field 'b' +Note 1003 delete from `test`.`t2` where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "5.75" + } /* cost_info */, + "ordering_operation": { + "using_filesort": true, + "cost_info": { + "sort_cost": "2.60" + } /* cost_info */, + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 26, + "rows_produced_per_join": 2, + "filtered": "10.00", + "cost_info": { + "read_cost": "2.89", + "eval_cost": "0.26", + "prefix_cost": "3.15", + "data_read_per_join": "104" + } /* cost_info */, + "used_columns": [ + "a", + "b", + "c", + "d" + ] /* used_columns */, + "attached_condition": "(`test`.`t2`.`b` = 10)" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c`,`test`.`t2`.`d` AS `d` from `test`.`t2` where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 4 +Handler_read_rnd_next 27 +Sort_rows 1 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_delete 1 +Handler_read_key 4 +Handler_read_rnd 1 +Handler_read_rnd_next 27 +Sort_rows 1 +Sort_scan 1 + +DROP TABLE t1, t2; +#34 +CREATE TABLE t1 (i INT); +INSERT INTO t1 (i) VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2 (a CHAR(2), b CHAR(2), c CHAR(2), d CHAR(2), INDEX (a,b,c)) +charset utf8mb4 ENGINE=HEAP; +INSERT INTO t2 SELECT i, i, i, i FROM t1; +# +# query: DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# select: SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# +EXPLAIN DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t2 NULL ALL NULL NULL NULL NULL 26 100.00 Using where; Using filesort +Warnings: +Warning 1739 Cannot use range access on index 'a' due to type or collation conversion on field 'b' +Note 1003 delete from `test`.`t2` where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_filesort": true, + "table": { + "delete": true, + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 26, + "filtered": "100.00", + "attached_condition": "(`test`.`t2`.`b` = 10)" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Warning 1739 Cannot use range access on index 'a' due to type or collation conversion on field 'b' +Note 1003 delete from `test`.`t2` where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "8.02" + } /* cost_info */, + "ordering_operation": { + "using_filesort": true, + "cost_info": { + "sort_cost": "2.60" + } /* cost_info */, + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 26, + "rows_produced_per_join": 2, + "filtered": "10.00", + "cost_info": { + "read_cost": "5.16", + "eval_cost": "0.26", + "prefix_cost": "5.42", + "data_read_per_join": "104" + } /* cost_info */, + "used_columns": [ + "a", + "b", + "c", + "d" + ] /* used_columns */, + "attached_condition": "(`test`.`t2`.`b` = 10)" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Warning 1739 Cannot use range access on index 'a' due to type or collation conversion on field 'b' +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c`,`test`.`t2`.`d` AS `d` from `test`.`t2` where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 4 +Handler_read_rnd_next 27 +Sort_rows 1 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_delete 1 +Handler_read_key 4 +Handler_read_rnd 1 +Handler_read_rnd_next 27 +Sort_rows 1 +Sort_scan 1 + +DROP TABLE t1, t2; +#35 +CREATE TABLE t1 (i INT); +INSERT INTO t1 (i) VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35),(36),(37),(38),(39), +(40),(41),(42),(43),(44); +CREATE TABLE t2 (i INT, key1 INT, key2 INT, INDEX (key1), INDEX (key2)); +INSERT INTO t2 (key1, key2) SELECT i, i FROM t1; +# +# query: DELETE FROM t2 WHERE key1 < 13 or key2 < 14 ORDER BY key1 +# select: SELECT * FROM t2 WHERE key1 < 13 or key2 < 14 ORDER BY key1 +# +EXPLAIN DELETE FROM t2 WHERE key1 < 13 or key2 < 14 ORDER BY key1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t2 NULL index_merge key1,key2 key1,key2 5,5 NULL 7 100.00 Using sort_union(key1,key2); Using where; Using filesort +Warnings: +Note 1003 delete from `test`.`t2` where ((`test`.`t2`.`key1` < 13) or (`test`.`t2`.`key2` < 14)) order by `test`.`t2`.`key1` +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t2 WHERE key1 < 13 or key2 < 14 ORDER BY key1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_filesort": true, + "table": { + "delete": true, + "table_name": "t2", + "access_type": "index_merge", + "possible_keys": [ + "key1", + "key2" + ] /* possible_keys */, + "key": "sort_union(key1,key2)", + "key_length": "5,5", + "rows_examined_per_scan": 7, + "filtered": "100.00", + "attached_condition": "((`test`.`t2`.`key1` < 13) or (`test`.`t2`.`key2` < 14))" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 delete from `test`.`t2` where ((`test`.`t2`.`key1` < 13) or (`test`.`t2`.`key2` < 14)) order by `test`.`t2`.`key1` +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t2 WHERE key1 < 13 or key2 < 14 ORDER BY key1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "10.73" + } /* cost_info */, + "ordering_operation": { + "using_filesort": true, + "cost_info": { + "sort_cost": "7.00" + } /* cost_info */, + "table": { + "table_name": "t2", + "access_type": "index_merge", + "possible_keys": [ + "key1", + "key2" + ] /* possible_keys */, + "key": "sort_union(key1,key2)", + "key_length": "5,5", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "3.03", + "eval_cost": "0.70", + "prefix_cost": "3.73", + "data_read_per_join": "112" + } /* cost_info */, + "used_columns": [ + "i", + "key1", + "key2" + ] /* used_columns */, + "attached_condition": "((`test`.`t2`.`key1` < 13) or (`test`.`t2`.`key2` < 14))" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`i` AS `i`,`test`.`t2`.`key1` AS `key1`,`test`.`t2`.`key2` AS `key2` from `test`.`t2` where ((`test`.`t2`.`key1` < 13) or (`test`.`t2`.`key2` < 14)) order by `test`.`t2`.`key1` +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 5 +Handler_read_next 7 +Handler_read_rnd 4 +Sort_rows 4 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_delete 4 +Handler_read_key 5 +Handler_read_next 7 +Handler_read_rnd 8 +Sort_rows 4 +Sort_scan 1 + +DROP TABLE t1, t2; +#36 +CREATE TABLE t1 (i INT); +INSERT INTO t1 (i) VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2(a INT, i INT PRIMARY KEY); +INSERT INTO t2 (i) SELECT i FROM t1; +# +# query: DELETE FROM t2 WHERE i > 10 AND i <= 18 ORDER BY i DESC LIMIT 1 +# select: SELECT * FROM t2 WHERE i > 10 AND i <= 18 ORDER BY i DESC LIMIT 1 +# +EXPLAIN DELETE FROM t2 WHERE i > 10 AND i <= 18 ORDER BY i DESC LIMIT 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t2 NULL range PRIMARY PRIMARY 4 const 8 100.00 Using where; Backward index scan +Warnings: +Note 1003 delete from `test`.`t2` where ((`test`.`t2`.`i` > 10) and (`test`.`t2`.`i` <= 18)) order by `test`.`t2`.`i` desc limit 1 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t2 WHERE i > 10 AND i <= 18 ORDER BY i DESC LIMIT 1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_filesort": false, + "table": { + "delete": true, + "table_name": "t2", + "access_type": "range", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "i" + ] /* used_key_parts */, + "key_length": "4", + "ref": [ + "const" + ] /* ref */, + "rows_examined_per_scan": 8, + "filtered": "100.00", + "backward_index_scan": true, + "attached_condition": "((`test`.`t2`.`i` > 10) and (`test`.`t2`.`i` <= 18))" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 delete from `test`.`t2` where ((`test`.`t2`.`i` > 10) and (`test`.`t2`.`i` <= 18)) order by `test`.`t2`.`i` desc limit 1 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t2 WHERE i > 10 AND i <= 18 ORDER BY i DESC LIMIT 1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "3.86" + } /* cost_info */, + "ordering_operation": { + "using_filesort": false, + "table": { + "table_name": "t2", + "access_type": "range", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "i" + ] /* used_key_parts */, + "key_length": "4", + "rows_examined_per_scan": 8, + "rows_produced_per_join": 8, + "filtered": "100.00", + "backward_index_scan": true, + "cost_info": { + "read_cost": "3.06", + "eval_cost": "0.80", + "prefix_cost": "3.86", + "data_read_per_join": "128" + } /* cost_info */, + "used_columns": [ + "a", + "i" + ] /* used_columns */, + "attached_condition": "((`test`.`t2`.`i` > 10) and (`test`.`t2`.`i` <= 18))" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`i` AS `i` from `test`.`t2` where ((`test`.`t2`.`i` > 10) and (`test`.`t2`.`i` <= 18)) order by `test`.`t2`.`i` desc limit 1 +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 3 +# Status of testing query execution: +Variable_name Value +Handler_delete 1 +Handler_read_key 3 + +DROP TABLE t1, t2; +#37 +CREATE TABLE t1 (i INT); +INSERT INTO t1 (i) VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2 (a CHAR(2), b CHAR(2), c CHAR(2), INDEX (a, b)) charset utf8mb4; +INSERT INTO t2 SELECT i, i, i FROM t1; +# +# query: DELETE FROM t2 ORDER BY a, b DESC LIMIT 5 +# select: SELECT * FROM t2 ORDER BY a, b DESC LIMIT 5 +# +EXPLAIN DELETE FROM t2 ORDER BY a, b DESC LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t2 NULL ALL NULL NULL NULL NULL 26 100.00 Using filesort +Warnings: +Note 1003 delete from `test`.`t2` order by `test`.`t2`.`a`,`test`.`t2`.`b` desc limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t2 ORDER BY a, b DESC LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_filesort": true, + "table": { + "delete": true, + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 26, + "filtered": "100.00" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 delete from `test`.`t2` order by `test`.`t2`.`a`,`test`.`t2`.`b` desc limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t2 ORDER BY a, b DESC LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "3.14" + } /* cost_info */, + "ordering_operation": { + "using_filesort": true, + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 26, + "rows_produced_per_join": 26, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.54", + "eval_cost": "2.60", + "prefix_cost": "3.14", + "data_read_per_join": "832" + } /* cost_info */, + "used_columns": [ + "a", + "b", + "c" + ] /* used_columns */ + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c` from `test`.`t2` order by `test`.`t2`.`a`,`test`.`t2`.`b` desc limit 5 +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 3 +Handler_read_rnd_next 27 +Sort_rows 5 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_delete 5 +Handler_read_key 3 +Handler_read_rnd 5 +Handler_read_rnd_next 27 +Sort_rows 26 +Sort_scan 1 + +DROP TABLE t1, t2; +#38 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2 (a CHAR(2), b CHAR(2), c INT, INDEX (a, b)) charset utf8mb4; +INSERT INTO t2 (a, b) SELECT i, i FROM t1; +INSERT INTO t2 (a, b) SELECT t1.i, t1.i FROM t1, t1 x1, t1 x2; +# +# query: DELETE FROM t2 ORDER BY a DESC, b DESC LIMIT 5 +# select: SELECT * FROM t2 ORDER BY a DESC, b DESC LIMIT 5 +# +EXPLAIN DELETE FROM t2 ORDER BY a DESC, b DESC LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t2 NULL index NULL a 18 NULL 5 100.00 NULL +Warnings: +Note 1003 delete from `test`.`t2` order by `test`.`t2`.`a` desc,`test`.`t2`.`b` desc limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t2 ORDER BY a DESC, b DESC LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_filesort": false, + "table": { + "delete": true, + "table_name": "t2", + "access_type": "index", + "key": "a", + "used_key_parts": [ + "a", + "b" + ] /* used_key_parts */, + "key_length": "18", + "rows_examined_per_scan": 5, + "filtered": "100.00" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 delete from `test`.`t2` order by `test`.`t2`.`a` desc,`test`.`t2`.`b` desc limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t2 ORDER BY a DESC, b DESC LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1783.26" + } /* cost_info */, + "ordering_operation": { + "using_filesort": false, + "table": { + "table_name": "t2", + "access_type": "index", + "key": "a", + "used_key_parts": [ + "a", + "b" + ] /* used_key_parts */, + "key_length": "18", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 17602, + "filtered": "100.00", + "backward_index_scan": true, + "cost_info": { + "read_cost": "23.06", + "eval_cost": "1760.20", + "prefix_cost": "1783.26", + "data_read_per_join": "412K" + } /* cost_info */, + "used_columns": [ + "a", + "b", + "c" + ] /* used_columns */ + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c` from `test`.`t2` order by `test`.`t2`.`a` desc,`test`.`t2`.`b` desc limit 5 +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 3 +Handler_read_last 1 +Handler_read_prev 4 +# Status of testing query execution: +Variable_name Value +Handler_delete 5 +Handler_read_key 3 +Handler_read_last 1 +Handler_read_prev 4 + +DROP TABLE t1, t2; +#39 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2(a INT, i INT PRIMARY KEY); +INSERT INTO t2 (i) SELECT i FROM t1; +# +# query: UPDATE t2 SET a = 10 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 1 +# select: SELECT * FROM t2 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 1 +# +EXPLAIN UPDATE t2 SET a = 10 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t2 NULL range PRIMARY PRIMARY 4 const 8 100.00 Using where; Using temporary +Warnings: +Note 1003 update `test`.`t2` set `test`.`t2`.`a` = 10 where ((`test`.`t2`.`i` > 10) and (`test`.`t2`.`i` <= 18)) order by `test`.`t2`.`i` limit 1 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t2 SET a = 10 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_temporary_table": true, + "using_filesort": false, + "table": { + "update": true, + "table_name": "t2", + "access_type": "range", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "i" + ] /* used_key_parts */, + "key_length": "4", + "ref": [ + "const" + ] /* ref */, + "rows_examined_per_scan": 8, + "filtered": "100.00", + "attached_condition": "((`test`.`t2`.`i` > 10) and (`test`.`t2`.`i` <= 18))" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t2` set `test`.`t2`.`a` = 10 where ((`test`.`t2`.`i` > 10) and (`test`.`t2`.`i` <= 18)) order by `test`.`t2`.`i` limit 1 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t2 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "3.86" + } /* cost_info */, + "ordering_operation": { + "using_filesort": false, + "table": { + "table_name": "t2", + "access_type": "range", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "i" + ] /* used_key_parts */, + "key_length": "4", + "rows_examined_per_scan": 8, + "rows_produced_per_join": 8, + "filtered": "100.00", + "cost_info": { + "read_cost": "3.06", + "eval_cost": "0.80", + "prefix_cost": "3.86", + "data_read_per_join": "128" + } /* cost_info */, + "used_columns": [ + "a", + "i" + ] /* used_columns */, + "attached_condition": "((`test`.`t2`.`i` > 10) and (`test`.`t2`.`i` <= 18))" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`i` AS `i` from `test`.`t2` where ((`test`.`t2`.`i` > 10) and (`test`.`t2`.`i` <= 18)) order by `test`.`t2`.`i` limit 1 +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 3 +# Status of testing query execution: +Variable_name Value +Handler_read_key 3 +Handler_read_rnd 1 +Handler_update 1 + +DROP TABLE t1, t2; +#40 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2(a INT, i CHAR(2), INDEX(i(1))) charset utf8mb4; +INSERT INTO t2 (i) SELECT i FROM t1; +# +# query: UPDATE t2 SET a = 10 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 5 +# select: SELECT * FROM t2 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 5 +# +EXPLAIN UPDATE t2 SET a = 10 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t2 NULL ALL NULL NULL NULL NULL 26 100.00 Using where; Using filesort +Warnings: +Warning 1739 Cannot use range access on index 'i' due to type or collation conversion on field 'i' +Warning 1739 Cannot use range access on index 'i' due to type or collation conversion on field 'i' +Note 1003 update `test`.`t2` set `test`.`t2`.`a` = 10 where ((`test`.`t2`.`i` > 10) and (`test`.`t2`.`i` <= 18)) order by `test`.`t2`.`i` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t2 SET a = 10 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_filesort": true, + "table": { + "update": true, + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 26, + "filtered": "100.00", + "attached_condition": "((`test`.`t2`.`i` > 10) and (`test`.`t2`.`i` <= 18))" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Warning 1739 Cannot use range access on index 'i' due to type or collation conversion on field 'i' +Warning 1739 Cannot use range access on index 'i' due to type or collation conversion on field 'i' +Note 1003 update `test`.`t2` set `test`.`t2`.`a` = 10 where ((`test`.`t2`.`i` > 10) and (`test`.`t2`.`i` <= 18)) order by `test`.`t2`.`i` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t2 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "6.01" + } /* cost_info */, + "ordering_operation": { + "using_filesort": true, + "cost_info": { + "sort_cost": "2.89" + } /* cost_info */, + "table": { + "table_name": "t2", + "access_type": "ALL", + "possible_keys": [ + "i" + ] /* possible_keys */, + "rows_examined_per_scan": 26, + "rows_produced_per_join": 2, + "filtered": "11.11", + "cost_info": { + "read_cost": "2.83", + "eval_cost": "0.29", + "prefix_cost": "3.12", + "data_read_per_join": "46" + } /* cost_info */, + "used_columns": [ + "a", + "i" + ] /* used_columns */, + "attached_condition": "((`test`.`t2`.`i` > 10) and (`test`.`t2`.`i` <= 18))" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Warning 1739 Cannot use range access on index 'i' due to type or collation conversion on field 'i' +Warning 1739 Cannot use range access on index 'i' due to type or collation conversion on field 'i' +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`i` AS `i` from `test`.`t2` where ((`test`.`t2`.`i` > 10) and (`test`.`t2`.`i` <= 18)) order by `test`.`t2`.`i` limit 5 +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 27 +Sort_rows 5 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd 5 +Handler_read_rnd_next 27 +Handler_update 5 +Sort_rows 5 +Sort_scan 1 + +DROP TABLE t1, t2; +#41 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2(a INT, b INT, c INT, d INT, INDEX(a, b, c)); +INSERT INTO t2 (a, b, c) SELECT i, i, i FROM t1; +# +# query: UPDATE t2 SET d = 10 WHERE b = 10 ORDER BY a, c LIMIT 5 +# select: SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# +EXPLAIN UPDATE t2 SET d = 10 WHERE b = 10 ORDER BY a, c LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t2 NULL ALL NULL NULL NULL NULL 26 100.00 Using where; Using filesort +Warnings: +Note 1003 update `test`.`t2` set `test`.`t2`.`d` = 10 where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t2 SET d = 10 WHERE b = 10 ORDER BY a, c LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_filesort": true, + "table": { + "update": true, + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 26, + "filtered": "100.00", + "attached_condition": "(`test`.`t2`.`b` = 10)" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t2` set `test`.`t2`.`d` = 10 where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "3.13" + } /* cost_info */, + "ordering_operation": { + "using_filesort": false, + "table": { + "table_name": "t2", + "access_type": "index", + "key": "a", + "used_key_parts": [ + "a", + "b", + "c" + ] /* used_key_parts */, + "key_length": "15", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 2, + "filtered": "10.00", + "cost_info": { + "read_cost": "2.87", + "eval_cost": "0.26", + "prefix_cost": "3.13", + "data_read_per_join": "62" + } /* cost_info */, + "used_columns": [ + "a", + "b", + "c", + "d" + ] /* used_columns */, + "attached_condition": "(`test`.`t2`.`b` = 10)" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c`,`test`.`t2`.`d` AS `d` from `test`.`t2` where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 4 +Handler_read_next 26 +# Status of testing query execution: +Variable_name Value +Handler_read_key 4 +Handler_read_rnd 1 +Handler_read_rnd_next 27 +Handler_update 1 +Sort_rows 1 +Sort_scan 1 + +DROP TABLE t1, t2; +#42 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2(a INT, b INT, c INT, d INT, INDEX(a, b, c)); +INSERT INTO t2 (a, b, c) SELECT i, i, i FROM t1; +INSERT INTO t2 (a, b, c) SELECT t1.i, t1.i, t1.i FROM t1, t1 x1, t1 x2; +# +# query: UPDATE t2 SET d = 10 WHERE b = 10 ORDER BY a, c LIMIT 5 +# select: SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# +EXPLAIN UPDATE t2 SET d = 10 WHERE b = 10 ORDER BY a, c LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t2 NULL index NULL a 15 NULL 17602 100.00 Using where; Using temporary +Warnings: +Note 1003 update `test`.`t2` set `test`.`t2`.`d` = 10 where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t2 SET d = 10 WHERE b = 10 ORDER BY a, c LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_temporary_table": true, + "using_filesort": false, + "table": { + "update": true, + "table_name": "t2", + "access_type": "index", + "key": "a", + "used_key_parts": [ + "a", + "b", + "c" + ] /* used_key_parts */, + "key_length": "15", + "rows_examined_per_scan": 17602, + "filtered": "100.00", + "attached_condition": "(`test`.`t2`.`b` = 10)" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t2` set `test`.`t2`.`d` = 10 where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1778.96" + } /* cost_info */, + "ordering_operation": { + "using_filesort": false, + "table": { + "table_name": "t2", + "access_type": "index", + "key": "a", + "used_key_parts": [ + "a", + "b", + "c" + ] /* used_key_parts */, + "key_length": "15", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 1760, + "filtered": "10.00", + "cost_info": { + "read_cost": "1602.94", + "eval_cost": "176.02", + "prefix_cost": "1778.96", + "data_read_per_join": "41K" + } /* cost_info */, + "used_columns": [ + "a", + "b", + "c", + "d" + ] /* used_columns */, + "attached_condition": "(`test`.`t2`.`b` = 10)" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c`,`test`.`t2`.`d` AS `d` from `test`.`t2` where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 4 +Handler_read_next 4 +# Status of testing query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 4 +Handler_read_next 4 +Handler_read_rnd 5 +Handler_update 5 + +DROP TABLE t1, t2; +#43 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2 (a CHAR(2), b CHAR(2), c CHAR(2), d CHAR(2), INDEX (a,b(1),c)) +charset utf8mb4; +INSERT INTO t2 SELECT i, i, i, i FROM t1; +# +# query: UPDATE t2 SET d = 10 WHERE b = 10 ORDER BY a, c LIMIT 5 +# select: SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# +EXPLAIN UPDATE t2 SET d = 10 WHERE b = 10 ORDER BY a, c LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t2 NULL ALL NULL NULL NULL NULL 26 100.00 Using where; Using filesort +Warnings: +Warning 1739 Cannot use range access on index 'a' due to type or collation conversion on field 'b' +Note 1003 update `test`.`t2` set `test`.`t2`.`d` = 10 where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t2 SET d = 10 WHERE b = 10 ORDER BY a, c LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_filesort": true, + "table": { + "update": true, + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 26, + "filtered": "100.00", + "attached_condition": "(`test`.`t2`.`b` = 10)" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Warning 1739 Cannot use range access on index 'a' due to type or collation conversion on field 'b' +Note 1003 update `test`.`t2` set `test`.`t2`.`d` = 10 where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "5.75" + } /* cost_info */, + "ordering_operation": { + "using_filesort": true, + "cost_info": { + "sort_cost": "2.60" + } /* cost_info */, + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 26, + "rows_produced_per_join": 2, + "filtered": "10.00", + "cost_info": { + "read_cost": "2.89", + "eval_cost": "0.26", + "prefix_cost": "3.15", + "data_read_per_join": "104" + } /* cost_info */, + "used_columns": [ + "a", + "b", + "c", + "d" + ] /* used_columns */, + "attached_condition": "(`test`.`t2`.`b` = 10)" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c`,`test`.`t2`.`d` AS `d` from `test`.`t2` where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 4 +Handler_read_rnd_next 27 +Sort_rows 1 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 4 +Handler_read_rnd 1 +Handler_read_rnd_next 27 +Sort_rows 1 +Sort_scan 1 + +DROP TABLE t1, t2; +#44 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2 (a CHAR(2), b CHAR(2), c CHAR(2), d CHAR(2), INDEX (a,b,c)) +charset utf8mb4 ENGINE=HEAP; +INSERT INTO t2 SELECT i, i, i, i FROM t1; +# +# query: UPDATE t2 SET d = 10 WHERE b = 10 ORDER BY a, c LIMIT 5 +# select: SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# +EXPLAIN UPDATE t2 SET d = 10 WHERE b = 10 ORDER BY a, c LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t2 NULL ALL NULL NULL NULL NULL 26 100.00 Using where; Using filesort +Warnings: +Warning 1739 Cannot use range access on index 'a' due to type or collation conversion on field 'b' +Note 1003 update `test`.`t2` set `test`.`t2`.`d` = 10 where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t2 SET d = 10 WHERE b = 10 ORDER BY a, c LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_filesort": true, + "table": { + "update": true, + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 26, + "filtered": "100.00", + "attached_condition": "(`test`.`t2`.`b` = 10)" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Warning 1739 Cannot use range access on index 'a' due to type or collation conversion on field 'b' +Note 1003 update `test`.`t2` set `test`.`t2`.`d` = 10 where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "8.02" + } /* cost_info */, + "ordering_operation": { + "using_filesort": true, + "cost_info": { + "sort_cost": "2.60" + } /* cost_info */, + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 26, + "rows_produced_per_join": 2, + "filtered": "10.00", + "cost_info": { + "read_cost": "5.16", + "eval_cost": "0.26", + "prefix_cost": "5.42", + "data_read_per_join": "104" + } /* cost_info */, + "used_columns": [ + "a", + "b", + "c", + "d" + ] /* used_columns */, + "attached_condition": "(`test`.`t2`.`b` = 10)" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Warning 1739 Cannot use range access on index 'a' due to type or collation conversion on field 'b' +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c`,`test`.`t2`.`d` AS `d` from `test`.`t2` where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 4 +Handler_read_rnd_next 27 +Sort_rows 1 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 4 +Handler_read_rnd 1 +Handler_read_rnd_next 27 +Sort_rows 1 +Sort_scan 1 + +DROP TABLE t1, t2; +#45 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35),(36),(37),(38),(39), +(40),(41),(42),(43),(44); +CREATE TABLE t2 (i INT, key1 INT, key2 INT, INDEX (key1), INDEX (key2)); +INSERT INTO t2 (key1, key2) SELECT i, i FROM t1; +# +# query: UPDATE t2 SET i = 123 WHERE key1 < 13 or key2 < 14 ORDER BY key1 +# select: SELECT * FROM t2 WHERE key1 < 13 or key2 < 14 ORDER BY key1 +# +EXPLAIN UPDATE t2 SET i = 123 WHERE key1 < 13 or key2 < 14 ORDER BY key1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t2 NULL index_merge key1,key2 key1,key2 5,5 NULL 7 100.00 Using sort_union(key1,key2); Using where; Using filesort +Warnings: +Note 1003 update `test`.`t2` set `test`.`t2`.`i` = 123 where ((`test`.`t2`.`key1` < 13) or (`test`.`t2`.`key2` < 14)) order by `test`.`t2`.`key1` +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t2 SET i = 123 WHERE key1 < 13 or key2 < 14 ORDER BY key1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_filesort": true, + "table": { + "update": true, + "table_name": "t2", + "access_type": "index_merge", + "possible_keys": [ + "key1", + "key2" + ] /* possible_keys */, + "key": "sort_union(key1,key2)", + "key_length": "5,5", + "rows_examined_per_scan": 7, + "filtered": "100.00", + "attached_condition": "((`test`.`t2`.`key1` < 13) or (`test`.`t2`.`key2` < 14))" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t2` set `test`.`t2`.`i` = 123 where ((`test`.`t2`.`key1` < 13) or (`test`.`t2`.`key2` < 14)) order by `test`.`t2`.`key1` +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t2 WHERE key1 < 13 or key2 < 14 ORDER BY key1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "10.73" + } /* cost_info */, + "ordering_operation": { + "using_filesort": true, + "cost_info": { + "sort_cost": "7.00" + } /* cost_info */, + "table": { + "table_name": "t2", + "access_type": "index_merge", + "possible_keys": [ + "key1", + "key2" + ] /* possible_keys */, + "key": "sort_union(key1,key2)", + "key_length": "5,5", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "3.03", + "eval_cost": "0.70", + "prefix_cost": "3.73", + "data_read_per_join": "112" + } /* cost_info */, + "used_columns": [ + "i", + "key1", + "key2" + ] /* used_columns */, + "attached_condition": "((`test`.`t2`.`key1` < 13) or (`test`.`t2`.`key2` < 14))" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`i` AS `i`,`test`.`t2`.`key1` AS `key1`,`test`.`t2`.`key2` AS `key2` from `test`.`t2` where ((`test`.`t2`.`key1` < 13) or (`test`.`t2`.`key2` < 14)) order by `test`.`t2`.`key1` +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 5 +Handler_read_next 7 +Handler_read_rnd 4 +Sort_rows 4 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 5 +Handler_read_next 7 +Handler_read_rnd 8 +Handler_update 4 +Sort_rows 4 +Sort_scan 1 + +DROP TABLE t1, t2; +#46 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2(a INT, i INT PRIMARY KEY); +INSERT INTO t2 (i) SELECT i FROM t1; +# +# query: UPDATE t2 SET a = 10 WHERE i > 10 AND i <= 18 ORDER BY i DESC LIMIT 1 +# select: SELECT * FROM t2 WHERE i > 10 AND i <= 18 ORDER BY i DESC LIMIT 1 +# +EXPLAIN UPDATE t2 SET a = 10 WHERE i > 10 AND i <= 18 ORDER BY i DESC LIMIT 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t2 NULL range PRIMARY PRIMARY 4 const 8 100.00 Using where; Backward index scan; Using temporary +Warnings: +Note 1003 update `test`.`t2` set `test`.`t2`.`a` = 10 where ((`test`.`t2`.`i` > 10) and (`test`.`t2`.`i` <= 18)) order by `test`.`t2`.`i` desc limit 1 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t2 SET a = 10 WHERE i > 10 AND i <= 18 ORDER BY i DESC LIMIT 1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_temporary_table": true, + "using_filesort": false, + "table": { + "update": true, + "table_name": "t2", + "access_type": "range", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "i" + ] /* used_key_parts */, + "key_length": "4", + "ref": [ + "const" + ] /* ref */, + "rows_examined_per_scan": 8, + "filtered": "100.00", + "backward_index_scan": true, + "attached_condition": "((`test`.`t2`.`i` > 10) and (`test`.`t2`.`i` <= 18))" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t2` set `test`.`t2`.`a` = 10 where ((`test`.`t2`.`i` > 10) and (`test`.`t2`.`i` <= 18)) order by `test`.`t2`.`i` desc limit 1 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t2 WHERE i > 10 AND i <= 18 ORDER BY i DESC LIMIT 1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "3.86" + } /* cost_info */, + "ordering_operation": { + "using_filesort": false, + "table": { + "table_name": "t2", + "access_type": "range", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "i" + ] /* used_key_parts */, + "key_length": "4", + "rows_examined_per_scan": 8, + "rows_produced_per_join": 8, + "filtered": "100.00", + "backward_index_scan": true, + "cost_info": { + "read_cost": "3.06", + "eval_cost": "0.80", + "prefix_cost": "3.86", + "data_read_per_join": "128" + } /* cost_info */, + "used_columns": [ + "a", + "i" + ] /* used_columns */, + "attached_condition": "((`test`.`t2`.`i` > 10) and (`test`.`t2`.`i` <= 18))" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`i` AS `i` from `test`.`t2` where ((`test`.`t2`.`i` > 10) and (`test`.`t2`.`i` <= 18)) order by `test`.`t2`.`i` desc limit 1 +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 3 +# Status of testing query execution: +Variable_name Value +Handler_read_key 3 +Handler_read_rnd 1 +Handler_update 1 + +DROP TABLE t1, t2; +#47 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2 (a CHAR(2), b CHAR(2), c CHAR(2), INDEX (a, b)) charset utf8mb4; +INSERT INTO t2 SELECT i, i, i FROM t1; +# +# query: UPDATE t2 SET c = 10 ORDER BY a, b DESC LIMIT 5 +# select: SELECT * FROM t2 ORDER BY a, b DESC LIMIT 5 +# +EXPLAIN UPDATE t2 SET c = 10 ORDER BY a, b DESC LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t2 NULL ALL NULL NULL NULL NULL 26 100.00 Using filesort +Warnings: +Note 1003 update `test`.`t2` set `test`.`t2`.`c` = 10 order by `test`.`t2`.`a`,`test`.`t2`.`b` desc limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t2 SET c = 10 ORDER BY a, b DESC LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_filesort": true, + "table": { + "update": true, + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 26, + "filtered": "100.00" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t2` set `test`.`t2`.`c` = 10 order by `test`.`t2`.`a`,`test`.`t2`.`b` desc limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t2 ORDER BY a, b DESC LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "3.14" + } /* cost_info */, + "ordering_operation": { + "using_filesort": true, + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 26, + "rows_produced_per_join": 26, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.54", + "eval_cost": "2.60", + "prefix_cost": "3.14", + "data_read_per_join": "832" + } /* cost_info */, + "used_columns": [ + "a", + "b", + "c" + ] /* used_columns */ + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c` from `test`.`t2` order by `test`.`t2`.`a`,`test`.`t2`.`b` desc limit 5 +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 3 +Handler_read_rnd_next 27 +Sort_rows 5 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 3 +Handler_read_rnd 5 +Handler_read_rnd_next 27 +Handler_update 4 +Sort_rows 5 +Sort_scan 1 + +DROP TABLE t1, t2; +#48 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2 (a CHAR(2), b CHAR(2), c INT, INDEX (a, b)) charset utf8mb4; +INSERT INTO t2 (a, b) SELECT i, i FROM t1; +INSERT INTO t2 (a, b) SELECT t1.i, t1.i FROM t1, t1 x1, t1 x2; +# +# query: UPDATE t2 SET c = 10 ORDER BY a DESC, b DESC LIMIT 5 +# select: SELECT * FROM t2 ORDER BY a DESC, b DESC LIMIT 5 +# +EXPLAIN UPDATE t2 SET c = 10 ORDER BY a DESC, b DESC LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t2 NULL index NULL a 18 NULL 5 100.00 Using temporary +Warnings: +Note 1003 update `test`.`t2` set `test`.`t2`.`c` = 10 order by `test`.`t2`.`a` desc,`test`.`t2`.`b` desc limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t2 SET c = 10 ORDER BY a DESC, b DESC LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_temporary_table": true, + "using_filesort": false, + "table": { + "update": true, + "table_name": "t2", + "access_type": "index", + "key": "a", + "used_key_parts": [ + "a", + "b" + ] /* used_key_parts */, + "key_length": "18", + "rows_examined_per_scan": 5, + "filtered": "100.00" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t2` set `test`.`t2`.`c` = 10 order by `test`.`t2`.`a` desc,`test`.`t2`.`b` desc limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t2 ORDER BY a DESC, b DESC LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1783.26" + } /* cost_info */, + "ordering_operation": { + "using_filesort": false, + "table": { + "table_name": "t2", + "access_type": "index", + "key": "a", + "used_key_parts": [ + "a", + "b" + ] /* used_key_parts */, + "key_length": "18", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 17602, + "filtered": "100.00", + "backward_index_scan": true, + "cost_info": { + "read_cost": "23.06", + "eval_cost": "1760.20", + "prefix_cost": "1783.26", + "data_read_per_join": "412K" + } /* cost_info */, + "used_columns": [ + "a", + "b", + "c" + ] /* used_columns */ + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c` from `test`.`t2` order by `test`.`t2`.`a` desc,`test`.`t2`.`b` desc limit 5 +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 3 +Handler_read_last 1 +Handler_read_prev 4 +# Status of testing query execution: +Variable_name Value +Handler_read_key 3 +Handler_read_last 1 +Handler_read_prev 4 +Handler_read_rnd 5 +Handler_update 5 + +DROP TABLE t1, t2; +#49 +CREATE TABLE t1 ( +pk INT NOT NULL AUTO_INCREMENT, +c1_idx CHAR(1) DEFAULT 'y', +c2 INT, +PRIMARY KEY (pk), +INDEX c1_idx (c1_idx) +) charset utf8mb4; +INSERT INTO t1 VALUES (1,'y',1), (2,'n',2), (3,'y',3), (4,'n',4); +# +# query: UPDATE t1 SET c2 = 0 WHERE c1_idx = 'y' ORDER BY pk DESC LIMIT 2 +# select: SELECT * FROM t1 WHERE c1_idx = 'y' ORDER BY pk DESC LIMIT 2 +# +EXPLAIN UPDATE t1 SET c2 = 0 WHERE c1_idx = 'y' ORDER BY pk DESC LIMIT 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL range c1_idx c1_idx 5 const 2 100.00 Using where; Using filesort +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`c2` = 0 where (`test`.`t1`.`c1_idx` = 'y') order by `test`.`t1`.`pk` desc limit 2 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t1 SET c2 = 0 WHERE c1_idx = 'y' ORDER BY pk DESC LIMIT 2;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_filesort": true, + "table": { + "update": true, + "table_name": "t1", + "access_type": "range", + "possible_keys": [ + "c1_idx" + ] /* possible_keys */, + "key": "c1_idx", + "used_key_parts": [ + "c1_idx" + ] /* used_key_parts */, + "key_length": "5", + "ref": [ + "const" + ] /* ref */, + "rows_examined_per_scan": 2, + "filtered": "100.00", + "attached_condition": "(`test`.`t1`.`c1_idx` = 'y')" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`c2` = 0 where (`test`.`t1`.`c1_idx` = 'y') order by `test`.`t1`.`pk` desc limit 2 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 WHERE c1_idx = 'y' ORDER BY pk DESC LIMIT 2;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.70" + } /* cost_info */, + "ordering_operation": { + "using_filesort": true, + "table": { + "table_name": "t1", + "access_type": "ref", + "possible_keys": [ + "c1_idx" + ] /* possible_keys */, + "key": "c1_idx", + "used_key_parts": [ + "c1_idx" + ] /* used_key_parts */, + "key_length": "5", + "ref": [ + "const" + ] /* ref */, + "rows_examined_per_scan": 2, + "rows_produced_per_join": 2, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.20", + "prefix_cost": "0.70", + "data_read_per_join": "32" + } /* cost_info */, + "used_columns": [ + "pk", + "c1_idx", + "c2" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`c1_idx` = 'y')" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`c1_idx` AS `c1_idx`,`test`.`t1`.`c2` AS `c2` from `test`.`t1` where (`test`.`t1`.`c1_idx` = 'y') order by `test`.`t1`.`pk` desc limit 2 +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 4 +Handler_read_next 2 +Sort_rows 2 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 4 +Handler_read_next 2 +Handler_read_rnd 2 +Handler_update 2 +Sort_rows 2 +Sort_scan 1 + +# +# query: DELETE FROM t1 WHERE c1_idx = 'y' ORDER BY pk DESC LIMIT 2 +# select: SELECT * FROM t1 WHERE c1_idx = 'y' ORDER BY pk DESC LIMIT 2 +# +EXPLAIN DELETE FROM t1 WHERE c1_idx = 'y' ORDER BY pk DESC LIMIT 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL range c1_idx c1_idx 5 const 2 100.00 Using where; Using filesort +Warnings: +Note 1003 delete from `test`.`t1` where (`test`.`t1`.`c1_idx` = 'y') order by `test`.`t1`.`pk` desc limit 2 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t1 WHERE c1_idx = 'y' ORDER BY pk DESC LIMIT 2;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_filesort": true, + "table": { + "delete": true, + "table_name": "t1", + "access_type": "range", + "possible_keys": [ + "c1_idx" + ] /* possible_keys */, + "key": "c1_idx", + "used_key_parts": [ + "c1_idx" + ] /* used_key_parts */, + "key_length": "5", + "ref": [ + "const" + ] /* ref */, + "rows_examined_per_scan": 2, + "filtered": "100.00", + "attached_condition": "(`test`.`t1`.`c1_idx` = 'y')" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 delete from `test`.`t1` where (`test`.`t1`.`c1_idx` = 'y') order by `test`.`t1`.`pk` desc limit 2 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 WHERE c1_idx = 'y' ORDER BY pk DESC LIMIT 2;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.70" + } /* cost_info */, + "ordering_operation": { + "using_filesort": true, + "table": { + "table_name": "t1", + "access_type": "ref", + "possible_keys": [ + "c1_idx" + ] /* possible_keys */, + "key": "c1_idx", + "used_key_parts": [ + "c1_idx" + ] /* used_key_parts */, + "key_length": "5", + "ref": [ + "const" + ] /* ref */, + "rows_examined_per_scan": 2, + "rows_produced_per_join": 2, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.20", + "prefix_cost": "0.70", + "data_read_per_join": "32" + } /* cost_info */, + "used_columns": [ + "pk", + "c1_idx", + "c2" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`c1_idx` = 'y')" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`c1_idx` AS `c1_idx`,`test`.`t1`.`c2` AS `c2` from `test`.`t1` where (`test`.`t1`.`c1_idx` = 'y') order by `test`.`t1`.`pk` desc limit 2 +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 4 +Handler_read_next 2 +Sort_rows 2 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_delete 2 +Handler_read_key 4 +Handler_read_next 2 +Handler_read_rnd 2 +Sort_rows 2 +Sort_scan 1 + +DROP TABLE t1; +#50 +CREATE TABLE t1 (a INT AUTO_INCREMENT PRIMARY KEY); +INSERT INTO t1 VALUES (),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(); +# +# query: UPDATE t1 SET a=a+10 WHERE a > 34 +# select: SELECT * FROM t1 WHERE a > 34 +# +EXPLAIN UPDATE t1 SET a=a+10 WHERE a > 34; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL range PRIMARY PRIMARY 4 const 3 100.00 Using where; Using temporary +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`a` = (`test`.`t1`.`a` + 10) where (`test`.`t1`.`a` > 34) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t1 SET a=a+10 WHERE a > 34;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "table": { + "update": true, + "table_name": "t1", + "access_type": "range", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "a" + ] /* used_key_parts */, + "key_length": "4", + "ref": [ + "const" + ] /* ref */, + "rows_examined_per_scan": 3, + "filtered": "100.00", + "using_temporary_table": "for update", + "attached_condition": "(`test`.`t1`.`a` > 34)" + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`a` = (`test`.`t1`.`a` + 10) where (`test`.`t1`.`a` > 34) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 WHERE a > 34;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.87" + } /* cost_info */, + "table": { + "table_name": "t1", + "access_type": "range", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "a" + ] /* used_key_parts */, + "key_length": "4", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "using_index": true, + "cost_info": { + "read_cost": "0.57", + "eval_cost": "0.30", + "prefix_cost": "0.87", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`a` > 34)" + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` > 34) +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_next 2 +# Status of testing query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_next 2 +Handler_read_rnd 2 +Handler_update 2 + +DROP TABLE t1; +#51 +CREATE TABLE t1 (c1 INT, c2 INT, c3 INT); +CREATE TABLE t2 (c1 INT, c2 INT); +INSERT INTO t1 VALUES (1, 1, 10), (2, 2, 20); +# +# query: UPDATE t1 LEFT JOIN t2 ON t1.c1 = t2.c1 SET t2.c2 = 10 +# select: SELECT * FROM t1 LEFT JOIN t2 ON t1.c1 = t2.c1 +# +EXPLAIN UPDATE t1 LEFT JOIN t2 ON t1.c1 = t2.c1 SET t2.c2 = 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t2 NULL system NULL NULL NULL NULL 0 0.00 const row not found +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 update `test`.`t1` left join `test`.`t2` on(multiple equal(`test`.`t1`.`c1`, `test`.`t2`.`c1`)) set `test`.`t2`.`c2` = 10 where true +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t1 LEFT JOIN t2 ON t1.c1 = t2.c1 SET t2.c2 = 10;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.70" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "update": true, + "table_name": "t2", + "access_type": "system", + "rows_examined_per_scan": 0, + "rows_produced_per_join": 1, + "filtered": "0.00", + "const_row_not_found": true, + "cost_info": { + "read_cost": "0.00", + "eval_cost": "0.10", + "prefix_cost": "0.00", + "data_read_per_join": "16" + } /* cost_info */, + "used_columns": [ + "c1", + "c2" + ] /* used_columns */ + } /* table */ + }, + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 2, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.20", + "prefix_cost": "0.70", + "data_read_per_join": "32" + } /* cost_info */, + "used_columns": [ + "c1" + ] /* used_columns */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t1` left join `test`.`t2` on(multiple equal(`test`.`t1`.`c1`, `test`.`t2`.`c1`)) set `test`.`t2`.`c2` = 10 where true +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 LEFT JOIN t2 ON t1.c1 = t2.c1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.70" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "system", + "rows_examined_per_scan": 0, + "rows_produced_per_join": 1, + "filtered": "0.00", + "const_row_not_found": true, + "cost_info": { + "read_cost": "0.00", + "eval_cost": "0.10", + "prefix_cost": "0.00", + "data_read_per_join": "16" + } /* cost_info */, + "used_columns": [ + "c1", + "c2" + ] /* used_columns */ + } /* table */ + }, + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 2, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.20", + "prefix_cost": "0.70", + "data_read_per_join": "32" + } /* cost_info */, + "used_columns": [ + "c1", + "c2", + "c3" + ] /* used_columns */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c1` AS `c1`,`test`.`t1`.`c2` AS `c2`,`test`.`t1`.`c3` AS `c3`,NULL AS `c1`,NULL AS `c2` from `test`.`t1` where true +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 5 +Handler_read_rnd_next 4 +# Status of testing query execution: +Variable_name Value +Handler_read_key 5 +Handler_read_rnd_next 4 + +# +# query: UPDATE t1 LEFT JOIN t2 ON t1.c1 = t2.c1 SET t2.c2 = 10 WHERE t1.c3 = 10 +# select: SELECT * FROM t1 LEFT JOIN t2 ON t1.c1 = t2.c1 WHERE t1.c3 = 10 +# +EXPLAIN UPDATE t1 LEFT JOIN t2 ON t1.c1 = t2.c1 SET t2.c2 = 10 WHERE t1.c3 = 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t2 NULL system NULL NULL NULL NULL 0 0.00 const row not found +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1003 update `test`.`t1` left join `test`.`t2` on(multiple equal(`test`.`t1`.`c1`, `test`.`t2`.`c1`)) set `test`.`t2`.`c2` = 10 where (`test`.`t1`.`c3` = 10) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t1 LEFT JOIN t2 ON t1.c1 = t2.c1 SET t2.c2 = 10 WHERE t1.c3 = 10;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.70" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "update": true, + "table_name": "t2", + "access_type": "system", + "rows_examined_per_scan": 0, + "rows_produced_per_join": 1, + "filtered": "0.00", + "const_row_not_found": true, + "cost_info": { + "read_cost": "0.00", + "eval_cost": "0.10", + "prefix_cost": "0.00", + "data_read_per_join": "16" + } /* cost_info */, + "used_columns": [ + "c1", + "c2" + ] /* used_columns */ + } /* table */ + }, + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 1, + "filtered": "50.00", + "cost_info": { + "read_cost": "0.60", + "eval_cost": "0.10", + "prefix_cost": "0.70", + "data_read_per_join": "16" + } /* cost_info */, + "used_columns": [ + "c1", + "c3" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`c3` = 10)" + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t1` left join `test`.`t2` on(multiple equal(`test`.`t1`.`c1`, `test`.`t2`.`c1`)) set `test`.`t2`.`c2` = 10 where (`test`.`t1`.`c3` = 10) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 LEFT JOIN t2 ON t1.c1 = t2.c1 WHERE t1.c3 = 10;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.70" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "system", + "rows_examined_per_scan": 0, + "rows_produced_per_join": 1, + "filtered": "0.00", + "const_row_not_found": true, + "cost_info": { + "read_cost": "0.00", + "eval_cost": "0.10", + "prefix_cost": "0.00", + "data_read_per_join": "16" + } /* cost_info */, + "used_columns": [ + "c1", + "c2" + ] /* used_columns */ + } /* table */ + }, + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 1, + "filtered": "50.00", + "cost_info": { + "read_cost": "0.60", + "eval_cost": "0.10", + "prefix_cost": "0.70", + "data_read_per_join": "16" + } /* cost_info */, + "used_columns": [ + "c1", + "c2", + "c3" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`c3` = 10)" + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c1` AS `c1`,`test`.`t1`.`c2` AS `c2`,`test`.`t1`.`c3` AS `c3`,NULL AS `c1`,NULL AS `c2` from `test`.`t1` where (`test`.`t1`.`c3` = 10) +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 5 +Handler_read_rnd_next 4 +# Status of testing query execution: +Variable_name Value +Handler_read_key 5 +Handler_read_rnd_next 4 + +DROP TABLE t1, t2; +#52 +CREATE TABLE t1(f1 INT, f2 INT); +CREATE TABLE t2(f3 INT, f4 INT); +CREATE INDEX IDX ON t2(f3); +INSERT INTO t1 VALUES(1,0),(2,0); +INSERT INTO t2 VALUES(1,1),(2,2); +# +# query: UPDATE t1 SET t1.f2=(SELECT MAX(t2.f4) FROM t2 WHERE t2.f3=t1.f1) +# select: SELECT (SELECT MAX(t2.f4) FROM t2 WHERE t2.f3=t1.f1) FROM t1 +# +EXPLAIN UPDATE t1 SET t1.f2=(SELECT MAX(t2.f4) FROM t2 WHERE t2.f3=t1.f1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DEPENDENT SUBQUERY t2 NULL ref IDX IDX 5 test.t1.f1 1 100.00 NULL +Warnings: +Note 1276 Field or reference 'test.t1.f1' of SELECT #2 was resolved in SELECT #1 +Note 1003 update `test`.`t1` set `test`.`t1`.`f2` = (/* select#2 */ select max(`test`.`t2`.`f4`) from `test`.`t2` where (`test`.`t2`.`f3` = `test`.`t1`.`f1`)) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t1 SET t1.f2=(SELECT MAX(t2.f4) FROM t2 WHERE t2.f3=t1.f1);; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "table": { + "update": true, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "filtered": "100.00" + } /* table */, + "update_value_subqueries": [ + { + "dependent": true, + "cacheable": false, + "query_block": { + "select_id": 2, + "cost_info": { + "query_cost": "0.35" + } /* cost_info */, + "table": { + "table_name": "t2", + "access_type": "ref", + "possible_keys": [ + "IDX" + ] /* possible_keys */, + "key": "IDX", + "used_key_parts": [ + "f3" + ] /* used_key_parts */, + "key_length": "5", + "ref": [ + "test.t1.f1" + ] /* ref */, + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.10", + "prefix_cost": "0.35", + "data_read_per_join": "16" + } /* cost_info */, + "used_columns": [ + "f3", + "f4" + ] /* used_columns */ + } /* table */ + } /* query_block */ + } + ] /* update_value_subqueries */ + } /* query_block */ +} +Warnings: +Note 1276 Field or reference 'test.t1.f1' of SELECT #2 was resolved in SELECT #1 +Note 1003 update `test`.`t1` set `test`.`t1`.`f2` = (/* select#2 */ select max(`test`.`t2`.`f4`) from `test`.`t2` where (`test`.`t2`.`f3` = `test`.`t1`.`f1`)) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT (SELECT MAX(t2.f4) FROM t2 WHERE t2.f3=t1.f1) FROM t1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.70" + } /* cost_info */, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 2, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.20", + "prefix_cost": "0.70", + "data_read_per_join": "32" + } /* cost_info */, + "used_columns": [ + "f1" + ] /* used_columns */ + } /* table */, + "select_list_subqueries": [ + { + "dependent": true, + "cacheable": false, + "query_block": { + "select_id": 2, + "cost_info": { + "query_cost": "0.35" + } /* cost_info */, + "table": { + "table_name": "t2", + "access_type": "ref", + "possible_keys": [ + "IDX" + ] /* possible_keys */, + "key": "IDX", + "used_key_parts": [ + "f3" + ] /* used_key_parts */, + "key_length": "5", + "ref": [ + "test.t1.f1" + ] /* ref */, + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.10", + "prefix_cost": "0.35", + "data_read_per_join": "16" + } /* cost_info */, + "used_columns": [ + "f3", + "f4" + ] /* used_columns */ + } /* table */ + } /* query_block */ + } + ] /* select_list_subqueries */ + } /* query_block */ +} +Warnings: +Note 1276 Field or reference 'test.t1.f1' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select (/* select#2 */ select max(`test`.`t2`.`f4`) from `test`.`t2` where (`test`.`t2`.`f3` = `test`.`t1`.`f1`)) AS `(SELECT MAX(t2.f4) FROM t2 WHERE t2.f3=t1.f1)` from `test`.`t1` +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 6 +Handler_read_next 2 +Handler_read_rnd_next 3 +# Status of testing query execution: +Variable_name Value +Handler_read_key 6 +Handler_read_next 2 +Handler_read_rnd_next 3 +Handler_update 2 + +DROP TABLE t1, t2; +#55 +CREATE TABLE t1(a INT); +INSERT INTO t1 VALUES (1); +SET @a = NULL; +EXPLAIN DELETE FROM t1 WHERE (@a:= a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +Note 1003 delete from `test`.`t1` where (0 <> (@a:=`test`.`t1`.`a`)) +DROP TABLE t1; +#56 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +DELETE FROM t1 USING t1 WHERE uknown_column = 12345; +ERROR 42S22: Unknown column 'uknown_column' in 'where clause' +EXPLAIN DELETE FROM t1 USING t1 WHERE uknown_column = 12345; +ERROR 42S22: Unknown column 'uknown_column' in 'where clause' +DROP TABLE t1; +#57 +CREATE TABLE t1(f1 INT); +EXPLAIN UPDATE t1 SET f2=1 ORDER BY f2; +ERROR 42S22: Unknown column 'f2' in 'field list' +UPDATE t1 SET f2=1 ORDER BY f2; +ERROR 42S22: Unknown column 'f2' in 'field list' +DROP TABLE t1; +#59 +CREATE TABLE t1 ( a INT, KEY( a ) ); +INSERT INTO t1 VALUES (0), (1); +CREATE VIEW v1 AS SELECT t11.a, t12.a AS b FROM t1 t11, t1 t12; +SET SESSION sql_safe_updates = 1; +EXPLAIN UPDATE IGNORE v1 SET a = 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t11 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t12 NULL index NULL a 5 NULL 2 100.00 Using index +Warnings: +Note 1003 update ignore (`test`.`t1` `t11` join `test`.`t1` `t12`) set `t11`.`a` = 1 +UPDATE IGNORE v1 SET a = 1; +ERROR HY000: You are using safe update mode and you tried to update a table without a WHERE that uses a KEY column. +SET SESSION sql_safe_updates = DEFAULT; +DROP TABLE t1; +DROP VIEW v1; +#62 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (0), (1); +CREATE VIEW v1 AS SELECT t11.a, t12.a AS b FROM t1 t11, t1 t12; +# +# query: UPDATE v1 SET a = 1 WHERE a > 0 +# select: SELECT * FROM v1 WHERE a > 0 +# +EXPLAIN UPDATE v1 SET a = 1 WHERE a > 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t11 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t12 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 update (`test`.`t1` `t11` join `test`.`t1` `t12`) set `t11`.`a` = 1 where (`t11`.`a` > 0) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE v1 SET a = 1 WHERE a > 0;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.40" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "update": true, + "table_name": "t11", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 1, + "filtered": "50.00", + "cost_info": { + "read_cost": "0.60", + "eval_cost": "0.10", + "prefix_cost": "0.70", + "data_read_per_join": "8" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t11`.`a` > 0)" + } /* table */ + }, + { + "table": { + "table_name": "t12", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 2, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.20", + "prefix_cost": "1.40", + "data_read_per_join": "16" + } /* cost_info */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 update (`test`.`t1` `t11` join `test`.`t1` `t12`) set `test`.`t11`.`a` = 1 where (`test`.`t11`.`a` > 0) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM v1 WHERE a > 0;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.40" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "table_name": "t11", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 1, + "filtered": "50.00", + "cost_info": { + "read_cost": "0.60", + "eval_cost": "0.10", + "prefix_cost": "0.70", + "data_read_per_join": "8" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t11`.`a` > 0)" + } /* table */ + }, + { + "table": { + "table_name": "t12", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 2, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.20", + "prefix_cost": "1.40", + "data_read_per_join": "16" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t11`.`a` AS `a`,`test`.`t12`.`a` AS `b` from `test`.`t1` `t11` join `test`.`t1` `t12` where (`test`.`t11`.`a` > 0) +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 1 +Handler_read_rnd_next 6 +# Status of testing query execution: +Variable_name Value +Handler_read_key 1 +Handler_read_rnd 1 +Handler_read_rnd_next 8 +Handler_write 2 + +# +# query: UPDATE t1, v1 SET v1.a = 1 WHERE t1.a = v1.a +# select: SELECT * FROM t1, v1 WHERE t1.a = v1.a +# +EXPLAIN UPDATE t1, v1 SET v1.a = 1 WHERE t1.a = v1.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 UPDATE t11 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t12 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 update `test`.`t1` join `test`.`t1` `t11` join `test`.`t1` `t12` set `test`.`t11`.`a` = 1 where (`test`.`t11`.`a` = `test`.`t1`.`a`) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t1, v1 SET v1.a = 1 WHERE t1.a = v1.a;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "2.50" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 2, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.20", + "prefix_cost": "0.70", + "data_read_per_join": "16" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */ + } /* table */ + }, + { + "table": { + "update": true, + "table_name": "t11", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 2, + "filtered": "50.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.20", + "prefix_cost": "1.60", + "data_read_per_join": "16" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t11`.`a` = `test`.`t1`.`a`)" + } /* table */ + }, + { + "table": { + "table_name": "t12", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 4, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.40", + "prefix_cost": "2.50", + "data_read_per_join": "32" + } /* cost_info */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t1` join `test`.`t1` `t11` join `test`.`t1` `t12` set `test`.`t11`.`a` = 1 where (`test`.`t11`.`a` = `test`.`t1`.`a`) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1, v1 WHERE t1.a = v1.a;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "2.50" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 2, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.20", + "prefix_cost": "0.70", + "data_read_per_join": "16" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */ + } /* table */ + }, + { + "table": { + "table_name": "t11", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 2, + "filtered": "50.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.20", + "prefix_cost": "1.60", + "data_read_per_join": "16" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t11`.`a` = `test`.`t1`.`a`)" + } /* table */ + }, + { + "table": { + "table_name": "t12", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 4, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.40", + "prefix_cost": "2.50", + "data_read_per_join": "32" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t11`.`a` AS `a`,`test`.`t12`.`a` AS `b` from `test`.`t1` join `test`.`t1` `t11` join `test`.`t1` `t12` where (`test`.`t11`.`a` = `test`.`t1`.`a`) +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 1 +Handler_read_rnd_next 9 +# Status of testing query execution: +Variable_name Value +Handler_read_key 1 +Handler_read_rnd 2 +Handler_read_rnd_next 18 +Handler_update 1 +Handler_write 4 + +DROP TABLE t1; +DROP VIEW v1; +#63 +CREATE TABLE t1 (a INT, PRIMARY KEY(a)); +INSERT INTO t1 VALUES (1), (2), (3), (4), (5); +CREATE VIEW v1 (a) AS SELECT a FROM t1; +# +# query: DELETE FROM v1 WHERE a < 4 +# select: SELECT * FROM v1 WHERE a < 4 +# +EXPLAIN DELETE FROM v1 WHERE a < 4; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL range PRIMARY PRIMARY 4 const 3 100.00 Using where +Warnings: +Note 1003 delete from (`test`.`t1`) where (`test`.`t1`.`a` < 4) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM v1 WHERE a < 4;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "table": { + "delete": true, + "table_name": "t1", + "access_type": "range", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "a" + ] /* used_key_parts */, + "key_length": "4", + "ref": [ + "const" + ] /* ref */, + "rows_examined_per_scan": 3, + "filtered": "100.00", + "attached_condition": "(`test`.`t1`.`a` < 4)" + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 delete from (`test`.`t1`) where (`test`.`t1`.`a` < 4) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM v1 WHERE a < 4;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.87" + } /* cost_info */, + "table": { + "table_name": "t1", + "access_type": "range", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "a" + ] /* used_key_parts */, + "key_length": "4", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "using_index": true, + "cost_info": { + "read_cost": "0.57", + "eval_cost": "0.30", + "prefix_cost": "0.87", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`a` < 4)" + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` < 4) +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 1 +Handler_read_next 3 +# Status of testing query execution: +Variable_name Value +Handler_delete 3 +Handler_read_first 1 +Handler_read_key 1 +Handler_read_next 3 + +DROP TABLE t1; +DROP VIEW v1; +#64 +CREATE TABLE t1 (a INT, b INT, PRIMARY KEY(a)); +INSERT INTO t1 VALUES (1,2), (2,3), (3,4), (4,5), (5,10); +CREATE TABLE t2 (x INT); +INSERT INTO t2 VALUES (1), (2), (3), (4); +CREATE VIEW v1 (a,c) AS SELECT a, b+1 FROM t1; +# +# query: DELETE v1 FROM t2, v1 WHERE t2.x = v1.a +# select: SELECT * FROM t2, v1 WHERE t2.x = v1.a +# +EXPLAIN DELETE v1 FROM t2, v1 WHERE t2.x = v1.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +1 DELETE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.x 1 100.00 NULL +Warnings: +Note 1003 delete `test`.`t1` from `test`.`t2` join `test`.`t1` where (`test`.`t1`.`a` = `test`.`t2`.`x`) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE v1 FROM t2, v1 WHERE t2.x = v1.a;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "2.30" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 4, + "rows_produced_per_join": 4, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.40", + "prefix_cost": "0.90", + "data_read_per_join": "32" + } /* cost_info */, + "used_columns": [ + "x" + ] /* used_columns */, + "attached_condition": "(`test`.`t2`.`x` is not null)" + } /* table */ + }, + { + "table": { + "delete": true, + "table_name": "t1", + "access_type": "eq_ref", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "a" + ] /* used_key_parts */, + "key_length": "4", + "ref": [ + "test.t2.x" + ] /* ref */, + "rows_examined_per_scan": 1, + "rows_produced_per_join": 4, + "filtered": "100.00", + "cost_info": { + "read_cost": "1.00", + "eval_cost": "0.40", + "prefix_cost": "2.30", + "data_read_per_join": "64" + } /* cost_info */, + "used_columns": [ + "a", + "b" + ] /* used_columns */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 delete `test`.`t1` from `test`.`t2` join `test`.`t1` where (`test`.`t1`.`a` = `test`.`t2`.`x`) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t2, v1 WHERE t2.x = v1.a;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "2.30" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 4, + "rows_produced_per_join": 4, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.40", + "prefix_cost": "0.90", + "data_read_per_join": "32" + } /* cost_info */, + "used_columns": [ + "x" + ] /* used_columns */, + "attached_condition": "(`test`.`t2`.`x` is not null)" + } /* table */ + }, + { + "table": { + "table_name": "t1", + "access_type": "eq_ref", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "a" + ] /* used_key_parts */, + "key_length": "4", + "ref": [ + "test.t2.x" + ] /* ref */, + "rows_examined_per_scan": 1, + "rows_produced_per_join": 4, + "filtered": "100.00", + "cost_info": { + "read_cost": "1.00", + "eval_cost": "0.40", + "prefix_cost": "2.30", + "data_read_per_join": "64" + } /* cost_info */, + "used_columns": [ + "a", + "b" + ] /* used_columns */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`x` AS `x`,`test`.`t1`.`a` AS `a`,(`test`.`t1`.`b` + 1) AS `c` from `test`.`t2` join `test`.`t1` where (`test`.`t1`.`a` = `test`.`t2`.`x`) +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 7 +Handler_read_rnd_next 5 +# Status of testing query execution: +Variable_name Value +Handler_delete 4 +Handler_read_key 7 +Handler_read_rnd 4 +Handler_read_rnd_next 5 + +DROP TABLE t1,t2; +DROP VIEW v1; +#65 +CREATE TABLE t1 (a INT, b INT, PRIMARY KEY(a)); +INSERT INTO t1 VALUES (1,2), (2,3), (3,4), (4,5), (5,10); +CREATE TABLE t2 (x INT); +INSERT INTO t2 VALUES (1), (2), (3), (4); +CREATE VIEW v1 (a,c) AS SELECT a, b+1 FROM t1; +# +# query: DELETE v1 FROM t2, v1 WHERE t2.x = v1.a +# select: SELECT * FROM t2, v1 WHERE t2.x = v1.a +# +EXPLAIN DELETE v1 FROM t2, v1 WHERE t2.x = v1.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +1 DELETE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.x 1 100.00 NULL +Warnings: +Note 1003 delete `test`.`t1` from `test`.`t2` join `test`.`t1` where (`test`.`t1`.`a` = `test`.`t2`.`x`) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE v1 FROM t2, v1 WHERE t2.x = v1.a;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "2.30" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 4, + "rows_produced_per_join": 4, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.40", + "prefix_cost": "0.90", + "data_read_per_join": "32" + } /* cost_info */, + "used_columns": [ + "x" + ] /* used_columns */, + "attached_condition": "(`test`.`t2`.`x` is not null)" + } /* table */ + }, + { + "table": { + "delete": true, + "table_name": "t1", + "access_type": "eq_ref", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "a" + ] /* used_key_parts */, + "key_length": "4", + "ref": [ + "test.t2.x" + ] /* ref */, + "rows_examined_per_scan": 1, + "rows_produced_per_join": 4, + "filtered": "100.00", + "cost_info": { + "read_cost": "1.00", + "eval_cost": "0.40", + "prefix_cost": "2.30", + "data_read_per_join": "64" + } /* cost_info */, + "used_columns": [ + "a", + "b" + ] /* used_columns */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 delete `test`.`t1` from `test`.`t2` join `test`.`t1` where (`test`.`t1`.`a` = `test`.`t2`.`x`) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t2, v1 WHERE t2.x = v1.a;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "2.30" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 4, + "rows_produced_per_join": 4, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.40", + "prefix_cost": "0.90", + "data_read_per_join": "32" + } /* cost_info */, + "used_columns": [ + "x" + ] /* used_columns */, + "attached_condition": "(`test`.`t2`.`x` is not null)" + } /* table */ + }, + { + "table": { + "table_name": "t1", + "access_type": "eq_ref", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "a" + ] /* used_key_parts */, + "key_length": "4", + "ref": [ + "test.t2.x" + ] /* ref */, + "rows_examined_per_scan": 1, + "rows_produced_per_join": 4, + "filtered": "100.00", + "cost_info": { + "read_cost": "1.00", + "eval_cost": "0.40", + "prefix_cost": "2.30", + "data_read_per_join": "64" + } /* cost_info */, + "used_columns": [ + "a", + "b" + ] /* used_columns */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`x` AS `x`,`test`.`t1`.`a` AS `a`,(`test`.`t1`.`b` + 1) AS `c` from `test`.`t2` join `test`.`t1` where (`test`.`t1`.`a` = `test`.`t2`.`x`) +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 7 +Handler_read_rnd_next 5 +# Status of testing query execution: +Variable_name Value +Handler_delete 4 +Handler_read_key 7 +Handler_read_rnd 4 +Handler_read_rnd_next 5 + +DROP TABLE t1,t2; +DROP VIEW v1; +#66 +CREATE TABLE t1 (a INT); +CREATE VIEW v1 (x) AS SELECT a FROM t1; +# +# query: INSERT INTO v1 VALUES (10) +# select: SELECT NULL +# +EXPLAIN INSERT INTO v1 VALUES (10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 INSERT t1 NULL ALL NULL NULL NULL NULL NULL NULL NULL +Warnings: +Note 1003 insert into `test`.`t1` values (10) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON INSERT INTO v1 VALUES (10);; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "table": { + "insert": true, + "table_name": "t1", + "access_type": "ALL" + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 insert into `test`.`t1` values (10) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT NULL;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "message": "No tables used" + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select NULL AS `NULL` +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +# Status of testing query execution: +Variable_name Value +Handler_read_key 1 +Handler_write 1 + +DROP TABLE t1; +DROP VIEW v1; +#67 +CREATE TABLE t1 (a INT); +CREATE TABLE t2 (b INT); +INSERT INTO t2 VALUES (1), (2), (3); +CREATE VIEW v1 (x) AS SELECT b FROM t2; +# +# query: INSERT INTO v1 SELECT * FROM t1 +# select: SELECT * FROM t1 +# +EXPLAIN INSERT INTO v1 SELECT * FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 INSERT NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 insert into `test`.`t2` /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON INSERT INTO v1 SELECT * FROM t1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "message": "no matching row in const table" + } /* query_block */ +} +Warnings: +Note 1003 insert into `test`.`t2` /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "message": "no matching row in const table" + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select NULL AS `a` from `test`.`t1` +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 1 +Handler_read_rnd_next 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 1 + +DROP TABLE t1, t2; +DROP VIEW v1; +#69 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +CREATE TABLE t2 (b INT); +INSERT INTO t2 VALUES (1), (2), (3); +# +# query: UPDATE t1 SET a = 10 WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x) +# select: SELECT * FROM t1 WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x) +# +EXPLAIN UPDATE t1 SET a = 10 WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY NULL index_subquery 5 func 2 100.00 Using index +3 DERIVED t2 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`a` = 10 where (`test`.`t1`.`a`,(((`test`.`t1`.`a`) in x on ))) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t1 SET a = 10 WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x);; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "table": { + "update": true, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "filtered": "100.00", + "attached_condition": "(`test`.`t1`.`a`,(((`test`.`t1`.`a`) in x on )))", + "attached_subqueries": [ + { + "dependent": true, + "cacheable": false, + "query_block": { + "select_id": 2, + "cost_info": { + "query_cost": "0.70" + } /* cost_info */, + "table": { + "table_name": "x", + "access_type": "index_subquery", + "possible_keys": [ + "" + ] /* possible_keys */, + "key": "", + "used_key_parts": [ + "b" + ] /* used_key_parts */, + "key_length": "5", + "ref": [ + "func" + ] /* ref */, + "rows_examined_per_scan": 2, + "rows_produced_per_join": 2, + "filtered": "100.00", + "using_index": true, + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.20", + "prefix_cost": "0.70", + "data_read_per_join": "32" + } /* cost_info */, + "used_columns": [ + "b" + ] /* used_columns */, + "materialized_from_subquery": { + "using_temporary_table": true, + "dependent": false, + "cacheable": true, + "query_block": { + "select_id": 3, + "cost_info": { + "query_cost": "3.80" + } /* cost_info */, + "ordering_operation": { + "using_filesort": true, + "cost_info": { + "sort_cost": "3.00" + } /* cost_info */, + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.30", + "prefix_cost": "0.80", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "b" + ] /* used_columns */ + } /* table */ + } /* ordering_operation */ + } /* query_block */ + } /* materialized_from_subquery */ + } /* table */ + } /* query_block */ + } + ] /* attached_subqueries */ + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`a` = 10 where (`test`.`t1`.`a`,(((`test`.`t1`.`a`) in x on ))) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x);; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.80" + } /* cost_info */, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.30", + "prefix_cost": "0.80", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`a`,(((`test`.`t1`.`a`) in x on )))", + "attached_subqueries": [ + { + "dependent": true, + "cacheable": false, + "query_block": { + "select_id": 2, + "cost_info": { + "query_cost": "0.70" + } /* cost_info */, + "table": { + "table_name": "x", + "access_type": "index_subquery", + "possible_keys": [ + "" + ] /* possible_keys */, + "key": "", + "used_key_parts": [ + "b" + ] /* used_key_parts */, + "key_length": "5", + "ref": [ + "func" + ] /* ref */, + "rows_examined_per_scan": 2, + "rows_produced_per_join": 2, + "filtered": "100.00", + "using_index": true, + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.20", + "prefix_cost": "0.70", + "data_read_per_join": "32" + } /* cost_info */, + "used_columns": [ + "b" + ] /* used_columns */, + "materialized_from_subquery": { + "using_temporary_table": true, + "dependent": false, + "cacheable": true, + "query_block": { + "select_id": 3, + "cost_info": { + "query_cost": "3.80" + } /* cost_info */, + "ordering_operation": { + "using_filesort": true, + "cost_info": { + "sort_cost": "3.00" + } /* cost_info */, + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.30", + "prefix_cost": "0.80", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "b" + ] /* used_columns */ + } /* table */ + } /* ordering_operation */ + } /* query_block */ + } /* materialized_from_subquery */ + } /* table */ + } /* query_block */ + } + ] /* attached_subqueries */ + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a`,(((`test`.`t1`.`a`) in x on ))) +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 5 +Handler_read_rnd_next 8 +Handler_write 1 +Sort_rows 3 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 5 +Handler_read_rnd_next 8 +Handler_update 1 +Handler_write 1 +Sort_rows 3 +Sort_scan 1 + +# +# query: UPDATE t1, t2 SET a = 10 WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x) +# select: SELECT * FROM t1, t2 WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x) +# +EXPLAIN UPDATE t1, t2 SET a = 10 WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 DEPENDENT SUBQUERY NULL index_subquery 5 func 2 100.00 Using index +3 DERIVED t2 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 update `test`.`t1` join `test`.`t2` set `test`.`t1`.`a` = 10 where (`test`.`t1`.`a`,(((`test`.`t1`.`a`) in x on ))) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t1, t2 SET a = 10 WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x);; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "2.20" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "update": true, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.30", + "prefix_cost": "0.80", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`a`,(((`test`.`t1`.`a`) in x on )))", + "attached_subqueries": [ + { + "dependent": true, + "cacheable": false, + "query_block": { + "select_id": 2, + "cost_info": { + "query_cost": "0.70" + } /* cost_info */, + "table": { + "table_name": "x", + "access_type": "index_subquery", + "possible_keys": [ + "" + ] /* possible_keys */, + "key": "", + "used_key_parts": [ + "b" + ] /* used_key_parts */, + "key_length": "5", + "ref": [ + "func" + ] /* ref */, + "rows_examined_per_scan": 2, + "rows_produced_per_join": 2, + "filtered": "100.00", + "using_index": true, + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.20", + "prefix_cost": "0.70", + "data_read_per_join": "32" + } /* cost_info */, + "used_columns": [ + "b" + ] /* used_columns */, + "materialized_from_subquery": { + "using_temporary_table": true, + "dependent": false, + "cacheable": true, + "query_block": { + "select_id": 3, + "cost_info": { + "query_cost": "3.80" + } /* cost_info */, + "ordering_operation": { + "using_filesort": true, + "cost_info": { + "sort_cost": "3.00" + } /* cost_info */, + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.30", + "prefix_cost": "0.80", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "b" + ] /* used_columns */ + } /* table */ + } /* ordering_operation */ + } /* query_block */ + } /* materialized_from_subquery */ + } /* table */ + } /* query_block */ + } + ] /* attached_subqueries */ + } /* table */ + }, + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 9, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.90", + "prefix_cost": "2.20", + "data_read_per_join": "72" + } /* cost_info */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t1` join `test`.`t2` set `test`.`t1`.`a` = 10 where (`test`.`t1`.`a`,(((`test`.`t1`.`a`) in x on ))) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1, t2 WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x);; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "2.20" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.30", + "prefix_cost": "0.80", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`a`,(((`test`.`t1`.`a`) in x on )))", + "attached_subqueries": [ + { + "dependent": true, + "cacheable": false, + "query_block": { + "select_id": 2, + "cost_info": { + "query_cost": "0.70" + } /* cost_info */, + "table": { + "table_name": "x", + "access_type": "index_subquery", + "possible_keys": [ + "" + ] /* possible_keys */, + "key": "", + "used_key_parts": [ + "b" + ] /* used_key_parts */, + "key_length": "5", + "ref": [ + "func" + ] /* ref */, + "rows_examined_per_scan": 2, + "rows_produced_per_join": 2, + "filtered": "100.00", + "using_index": true, + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.20", + "prefix_cost": "0.70", + "data_read_per_join": "32" + } /* cost_info */, + "used_columns": [ + "b" + ] /* used_columns */, + "materialized_from_subquery": { + "using_temporary_table": true, + "dependent": false, + "cacheable": true, + "query_block": { + "select_id": 3, + "cost_info": { + "query_cost": "3.80" + } /* cost_info */, + "ordering_operation": { + "using_filesort": true, + "cost_info": { + "sort_cost": "3.00" + } /* cost_info */, + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.30", + "prefix_cost": "0.80", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "b" + ] /* used_columns */ + } /* table */ + } /* ordering_operation */ + } /* query_block */ + } /* materialized_from_subquery */ + } /* table */ + } /* query_block */ + } + ] /* attached_subqueries */ + } /* table */ + }, + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 9, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.90", + "prefix_cost": "2.20", + "data_read_per_join": "72" + } /* cost_info */, + "used_columns": [ + "b" + ] /* used_columns */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` join `test`.`t2` where (`test`.`t1`.`a`,(((`test`.`t1`.`a`) in x on ))) +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 5 +Handler_read_rnd_next 8 +Handler_write 1 +Sort_rows 3 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 5 +Handler_read_rnd_next 8 +Handler_write 1 +Sort_rows 3 +Sort_scan 1 + +# +# query: UPDATE t1, (SELECT * FROM t2) y SET a = 10 WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x) +# select: SELECT * FROM t1, (SELECT * FROM t2) y WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x) +# +EXPLAIN UPDATE t1, (SELECT * FROM t2) y SET a = 10 WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +3 DEPENDENT SUBQUERY NULL index_subquery 5 func 2 100.00 Using index +4 DERIVED t2 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 update `test`.`t1` join `test`.`t2` set `test`.`t1`.`a` = 10 where (`test`.`t1`.`a`,(((`test`.`t1`.`a`) in x on ))) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t1, (SELECT * FROM t2) y SET a = 10 WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x);; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "2.20" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "update": true, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.30", + "prefix_cost": "0.80", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`a`,(((`test`.`t1`.`a`) in x on )))", + "attached_subqueries": [ + { + "dependent": true, + "cacheable": false, + "query_block": { + "select_id": 3, + "cost_info": { + "query_cost": "0.70" + } /* cost_info */, + "table": { + "table_name": "x", + "access_type": "index_subquery", + "possible_keys": [ + "" + ] /* possible_keys */, + "key": "", + "used_key_parts": [ + "b" + ] /* used_key_parts */, + "key_length": "5", + "ref": [ + "func" + ] /* ref */, + "rows_examined_per_scan": 2, + "rows_produced_per_join": 2, + "filtered": "100.00", + "using_index": true, + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.20", + "prefix_cost": "0.70", + "data_read_per_join": "32" + } /* cost_info */, + "used_columns": [ + "b" + ] /* used_columns */, + "materialized_from_subquery": { + "using_temporary_table": true, + "dependent": false, + "cacheable": true, + "query_block": { + "select_id": 4, + "cost_info": { + "query_cost": "3.80" + } /* cost_info */, + "ordering_operation": { + "using_filesort": true, + "cost_info": { + "sort_cost": "3.00" + } /* cost_info */, + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.30", + "prefix_cost": "0.80", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "b" + ] /* used_columns */ + } /* table */ + } /* ordering_operation */ + } /* query_block */ + } /* materialized_from_subquery */ + } /* table */ + } /* query_block */ + } + ] /* attached_subqueries */ + } /* table */ + }, + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 9, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.90", + "prefix_cost": "2.20", + "data_read_per_join": "72" + } /* cost_info */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t1` join `test`.`t2` set `test`.`t1`.`a` = 10 where (`test`.`t1`.`a`,(((`test`.`t1`.`a`) in x on ))) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1, (SELECT * FROM t2) y WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x);; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "2.20" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.30", + "prefix_cost": "0.80", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`a`,(((`test`.`t1`.`a`) in x on )))", + "attached_subqueries": [ + { + "dependent": true, + "cacheable": false, + "query_block": { + "select_id": 3, + "cost_info": { + "query_cost": "0.70" + } /* cost_info */, + "table": { + "table_name": "x", + "access_type": "index_subquery", + "possible_keys": [ + "" + ] /* possible_keys */, + "key": "", + "used_key_parts": [ + "b" + ] /* used_key_parts */, + "key_length": "5", + "ref": [ + "func" + ] /* ref */, + "rows_examined_per_scan": 2, + "rows_produced_per_join": 2, + "filtered": "100.00", + "using_index": true, + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.20", + "prefix_cost": "0.70", + "data_read_per_join": "32" + } /* cost_info */, + "used_columns": [ + "b" + ] /* used_columns */, + "materialized_from_subquery": { + "using_temporary_table": true, + "dependent": false, + "cacheable": true, + "query_block": { + "select_id": 4, + "cost_info": { + "query_cost": "3.80" + } /* cost_info */, + "ordering_operation": { + "using_filesort": true, + "cost_info": { + "sort_cost": "3.00" + } /* cost_info */, + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.30", + "prefix_cost": "0.80", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "b" + ] /* used_columns */ + } /* table */ + } /* ordering_operation */ + } /* query_block */ + } /* materialized_from_subquery */ + } /* table */ + } /* query_block */ + } + ] /* attached_subqueries */ + } /* table */ + }, + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 9, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.90", + "prefix_cost": "2.20", + "data_read_per_join": "72" + } /* cost_info */, + "used_columns": [ + "b" + ] /* used_columns */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` join `test`.`t2` where (`test`.`t1`.`a`,(((`test`.`t1`.`a`) in x on ))) +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 5 +Handler_read_rnd_next 8 +Handler_write 1 +Sort_rows 3 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 5 +Handler_read_rnd_next 8 +Handler_write 1 +Sort_rows 3 +Sort_scan 1 + +DROP TABLE t1,t2; +#70 +CREATE TABLE t1 (c1 INT KEY); +CREATE TABLE t2 (c2 INT); +CREATE TABLE t3 (c3 INT); +EXPLAIN UPDATE t3 SET c3 = ( +SELECT COUNT(d1.c1) +FROM ( +SELECT a11.c1 FROM t1 AS a11 +STRAIGHT_JOIN t2 AS a21 ON a21.c2 = a11.c1 +JOIN t1 AS a12 ON a12.c1 = a11.c1 +) d1 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t3 NULL ALL NULL NULL NULL NULL 0 100.00 NULL +2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +3 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 update `test`.`t3` set `test`.`t3`.`c3` = (/* select#2 */ select count(NULL) from (/* select#3 */ select NULL AS `c1` from `test`.`t1` `a11` straight_join `test`.`t2` `a21` join `test`.`t1` `a12` where multiple equal(NULL, NULL, NULL)) `d1`) +DROP TABLE t1, t2, t3; +#71 +CREATE TABLE t1 (c1 INT NOT NULL, c2 INT NOT NULL, INDEX i1(c1)); +INSERT INTO t1 VALUES (1,0),(2,0),(3,0),(4,0),(5,0),(6,0),(7,0),(8,0); +CREATE TABLE t2 LIKE t1; +EXPLAIN INSERT INTO t2 SELECT * FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 INSERT t2 NULL ALL NULL NULL NULL NULL X NULL NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL X 100.00 NULL +Warnings: +Note 1003 insert into `test`.`t2` /* select#1 */ select `test`.`t1`.`c1` AS `c1`,`test`.`t1`.`c2` AS `c2` from `test`.`t1` +INSERT INTO t2 SELECT * FROM t1; +SELECT * FROM t1 LEFT JOIN t2 ON t1.c1 = t2.c1; +DROP TABLE t1, t2; +#73 +CREATE TABLE t1 (id INT); +CREATE TABLE t2 (id INT); +INSERT INTO t1 VALUES (1), (2); +EXPLAIN SELECT * FROM t1 LEFT JOIN t2 USING(id) GROUP BY t1.id; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL system NULL NULL NULL NULL 0 0.00 const row not found +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id` from `test`.`t1` where true group by `test`.`t1`.`id` +DROP TABLE t1,t2; +#74 +CREATE TABLE t1(a INT PRIMARY KEY) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1), (2), (3), (4), (5); +# used key is modified & Using temporary +# +# query: UPDATE t1 SET a=a+1 WHERE a>10 +# select: SELECT a t1 FROM t1 WHERE a>10 +# +EXPLAIN UPDATE t1 SET a=a+1 WHERE a>10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL range PRIMARY PRIMARY 4 const 1 100.00 Using where; Using temporary +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`a` = (`test`.`t1`.`a` + 1) where (`test`.`t1`.`a` > 10) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t1 SET a=a+1 WHERE a>10;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "table": { + "update": true, + "table_name": "t1", + "access_type": "range", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "a" + ] /* used_key_parts */, + "key_length": "4", + "ref": [ + "const" + ] /* ref */, + "rows_examined_per_scan": 1, + "filtered": "100.00", + "using_temporary_table": "for update", + "attached_condition": "(`test`.`t1`.`a` > 10)" + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`a` = (`test`.`t1`.`a` + 1) where (`test`.`t1`.`a` > 10) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT a t1 FROM t1 WHERE a>10;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.46" + } /* cost_info */, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.36", + "eval_cost": "0.10", + "prefix_cost": "0.46", + "data_read_per_join": "16" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "query_block": { + "cost_info": { + "query_cost": "0.46" + } /* cost_info */, + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "range", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "a" + ] /* used_key_parts */, + "key_length": "4", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "using_index": true, + "cost_info": { + "read_cost": "0.36", + "eval_cost": "0.10", + "prefix_cost": "0.46", + "data_read_per_join": "8" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`a` > 10)" + } /* table */ + } /* query_block */ + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `t1` from `test`.`t1` where (`test`.`t1`.`a` > 10) +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 2 + +# used key is modified & Using filesort +# +# query: UPDATE t1 SET a=a+1 WHERE a>10 ORDER BY a+20 +# select: SELECT a t1 FROM t1 WHERE a>10 ORDER BY a+20 +# +EXPLAIN UPDATE t1 SET a=a+1 WHERE a>10 ORDER BY a+20; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL range PRIMARY PRIMARY 4 const 1 100.00 Using where; Using filesort +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`a` = (`test`.`t1`.`a` + 1) where (`test`.`t1`.`a` > 10) order by (`test`.`t1`.`a` + 20) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t1 SET a=a+1 WHERE a>10 ORDER BY a+20;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_filesort": true, + "table": { + "update": true, + "table_name": "t1", + "access_type": "range", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "a" + ] /* used_key_parts */, + "key_length": "4", + "ref": [ + "const" + ] /* ref */, + "rows_examined_per_scan": 1, + "filtered": "100.00", + "attached_condition": "(`test`.`t1`.`a` > 10)" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`a` = (`test`.`t1`.`a` + 1) where (`test`.`t1`.`a` > 10) order by (`test`.`t1`.`a` + 20) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT a t1 FROM t1 WHERE a>10 ORDER BY a+20;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.46" + } /* cost_info */, + "ordering_operation": { + "using_filesort": true, + "cost_info": { + "sort_cost": "1.00" + } /* cost_info */, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.36", + "eval_cost": "0.10", + "prefix_cost": "0.46", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "(t1.a + 20)", + "a" + ] /* used_columns */, + "ordering_operation": { + "using_filesort": true, + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "range", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "a" + ] /* used_key_parts */, + "key_length": "4", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "using_index": true, + "cost_info": { + "read_cost": "0.36", + "eval_cost": "0.10", + "prefix_cost": "0.46", + "data_read_per_join": "8" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`a` > 10)" + } /* table */ + } /* ordering_operation */ + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `t1` from `test`.`t1` where (`test`.`t1`.`a` > 10) order by `(t1.a + 20)` +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 1 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 2 +Sort_scan 1 + +DROP TABLE t1; +# +# Bug #12949629: CLIENT LOSES CONNECTION AFTER EXECUTING A PROCEDURE WITH +# EXPLAIN UPDATE/DEL/INS +# +CREATE TABLE t1 (i INT); +CREATE TABLE t2 (i INT); +CREATE PROCEDURE p1() BEGIN EXPLAIN INSERT INTO t1 VALUES (1);END| +CREATE PROCEDURE p2() BEGIN INSERT INTO t1 VALUES (1);END| +CREATE PROCEDURE p3() BEGIN EXPLAIN INSERT INTO t1 SELECT 1;END| +CREATE PROCEDURE p4() BEGIN INSERT INTO t1 SELECT 1;END| +CREATE PROCEDURE p5() BEGIN EXPLAIN REPLACE INTO t1 VALUES (1);END| +CREATE PROCEDURE p6() BEGIN REPLACE INTO t1 VALUES (1);END| +CREATE PROCEDURE p7() BEGIN EXPLAIN REPLACE INTO t1 SELECT 1;END| +CREATE PROCEDURE p8() BEGIN REPLACE INTO t1 SELECT 1;END| +CREATE PROCEDURE p9() BEGIN EXPLAIN UPDATE t1 SET i = 10;END| +CREATE PROCEDURE p10() BEGIN UPDATE t1 SET i = 10;END| +CREATE PROCEDURE p11() BEGIN EXPLAIN UPDATE t1,t2 SET t1.i = 10 WHERE t1.i = t2.i ;END| +CREATE PROCEDURE p12() BEGIN UPDATE t1,t2 SET t1.i = 10 WHERE t1.i = t2.i ;END| +CREATE PROCEDURE p13() BEGIN +# Disabling binary logging temporarily as optimized delete is not used when log-bin is enabled in row mode +SET @save_log_bin= @@sql_log_bin;SET SQL_LOG_BIN=0; +EXPLAIN DELETE FROM t1; +SET SQL_LOG_BIN=@save_log_bin; END| +CREATE PROCEDURE p14() BEGIN DELETE FROM t1;END| +CREATE PROCEDURE p15() BEGIN EXPLAIN DELETE FROM t1 USING t1;END| +CREATE PROCEDURE p16() BEGIN DELETE FROM t1 USING t1;END| +CALL p16(); +DROP PROCEDURE p16; +CALL p15(); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 delete `test`.`t1` from `test`.`t1` +DROP PROCEDURE p15; +CALL p14(); +DROP PROCEDURE p14; +CALL p13(); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 0 100.00 Deleting all rows +DROP PROCEDURE p13; +CALL p12(); +DROP PROCEDURE p12; +CALL p11(); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 update `test`.`t1` join `test`.`t2` set `test`.`t1`.`i` = 10 where multiple equal(`test`.`t1`.`i`, `test`.`t2`.`i`) +DROP PROCEDURE p11; +CALL p10(); +DROP PROCEDURE p10; +CALL p9(); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 0 100.00 NULL +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`i` = 10 +DROP PROCEDURE p9; +CALL p8(); +DROP PROCEDURE p8; +CALL p7(); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 REPLACE t1 NULL ALL NULL NULL NULL NULL NULL NULL NULL +Warnings: +Note 1003 replace into `test`.`t1` /* select#1 */ select 1 AS `1` from dual +DROP PROCEDURE p7; +CALL p6(); +DROP PROCEDURE p6; +CALL p5(); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 REPLACE t1 NULL ALL NULL NULL NULL NULL NULL NULL NULL +Warnings: +Note 1003 replace into `test`.`t1` values (1) +DROP PROCEDURE p5; +CALL p4(); +DROP PROCEDURE p4; +CALL p3(); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 INSERT t1 NULL ALL NULL NULL NULL NULL NULL NULL NULL +Warnings: +Note 1003 insert into `test`.`t1` /* select#1 */ select 1 AS `1` from dual +DROP PROCEDURE p3; +CALL p2(); +DROP PROCEDURE p2; +CALL p1(); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 INSERT t1 NULL ALL NULL NULL NULL NULL NULL NULL NULL +Warnings: +Note 1003 insert into `test`.`t1` values (1) +DROP PROCEDURE p1; +DROP TABLE t1, t2; +# +set default_storage_engine= @save_storage_engine; +set optimizer_switch=default; diff --git a/mysql-test/r/myisam_explain_non_select_all.result-pq b/mysql-test/r/myisam_explain_non_select_all.result-pq new file mode 100644 index 000000000000..fb59d5ba24e7 --- /dev/null +++ b/mysql-test/r/myisam_explain_non_select_all.result-pq @@ -0,0 +1,2520 @@ +set optimizer_switch='semijoin=on,materialization=on,firstmatch=on,loosescan=on,index_condition_pushdown=on,mrr=on,mrr_cost_based=off'; +set @save_storage_engine= @@session.default_storage_engine; +set session default_storage_engine = MyISAM; +set end_markers_in_json=on; +#1 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +# +# query: UPDATE t1 SET a = 10 WHERE a < 10 +# select: SELECT * FROM t1 WHERE a < 10 +# +EXPLAIN UPDATE t1 SET a = 10 WHERE a < 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`a` = 10 where (`test`.`t1`.`a` < 10) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 1 +Handler_read_rnd_next 4 +# Status of testing query execution: +Variable_name Value +Handler_read_key 1 +Handler_read_rnd_next 4 +Handler_update 3 + +DROP TABLE t1; +#2 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +# +# query: DELETE FROM t1 WHERE a < 10 +# select: SELECT * FROM t1 WHERE a < 10 +# +EXPLAIN DELETE FROM t1 WHERE a < 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 delete from `test`.`t1` where (`test`.`t1`.`a` < 10) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 1 +Handler_read_rnd_next 4 +# Status of testing query execution: +Variable_name Value +Handler_delete 3 +Handler_read_key 1 +Handler_read_rnd_next 4 + +DROP TABLE t1; +#3 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +# +# query: DELETE FROM t1 USING t1 WHERE a = 1 +# select: SELECT * FROM t1 WHERE a = 1 +# +EXPLAIN DELETE FROM t1 USING t1 WHERE a = 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 delete `test`.`t1` from `test`.`t1` where (`test`.`t1`.`a` = 1) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 1 +Handler_read_rnd_next 4 +# Status of testing query execution: +Variable_name Value +Handler_delete 1 +Handler_read_key 1 +Handler_read_rnd_next 4 + +DROP TABLE t1; +#4 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +CREATE TABLE t2 (b INT); +INSERT INTO t2 VALUES (1), (2), (3); +# +# query: UPDATE t1, t2 SET t1.a = 10 WHERE t1.a = 1 +# select: SELECT * FROM t1, t2 WHERE t1.a = 1 +# +EXPLAIN UPDATE t1, t2 SET t1.a = 10 WHERE t1.a = 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 update `test`.`t1` join `test`.`t2` set `test`.`t1`.`a` = 10 where (`test`.`t1`.`a` = 1) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 8 +# Status of testing query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 8 +Handler_update 1 + +DROP TABLE t1, t2; +#5 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +CREATE TABLE t2 (b INT); +INSERT INTO t2 VALUES (1), (2), (3); +# +# query: UPDATE t1 t11, (SELECT * FROM t2) t12 SET t11.a = 10 WHERE t11.a = 1 +# select: SELECT * FROM t1 t11, (SELECT * FROM t2) t12 WHERE t11.a = 1 +# +EXPLAIN UPDATE t1 t11, (SELECT * FROM t2) t12 SET t11.a = 10 WHERE t11.a = 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t11 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 update `test`.`t1` `t11` join `test`.`t2` set `test`.`t11`.`a` = 10 where (`test`.`t11`.`a` = 1) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 8 +# Status of testing query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 8 +Handler_update 1 + +DROP TABLE t1, t2; +#6 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +CREATE TABLE t2 (b INT); +INSERT INTO t2 VALUES (1), (2), (3); +# +# query: UPDATE t1 SET a = 10 WHERE 1 IN (SELECT 1 FROM t2 WHERE t2.b < 3) +# select: SELECT * FROM t1 WHERE 1 IN (SELECT 1 FROM t2 WHERE t2.b < 3) +# +EXPLAIN UPDATE t1 SET a = 10 WHERE 1 IN (SELECT 1 FROM t2 WHERE t2.b < 3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`a` = 10 where (`test`.`t2`.`b` < 3) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 5 +# Status of testing query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd 3 +Handler_read_rnd_next 9 +Handler_update 3 +Handler_write 3 + +DROP TABLE t1, t2; +#7 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +CREATE TABLE t2 (b INT); +INSERT INTO t2 VALUES (1), (2), (3); +# +# query: UPDATE t1 SET a = 10 WHERE a IN (SELECT b FROM t2 WHERE t1.a < 3) +# select: SELECT * FROM t1 WHERE a IN (SELECT b FROM t2 WHERE t1.a < 3) +# +EXPLAIN UPDATE t1 SET a = 10 WHERE a IN (SELECT b FROM t2 WHERE t1.a < 3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 update `test`.`t1` set `test`.`t1`.`a` = 10 where ((`test`.`t2`.`b` = `test`.`t1`.`a`) and (`test`.`t1`.`a` < 3)) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 8 +# Status of testing query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 7 +Handler_update 2 + +DROP TABLE t1, t2; +#7 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +CREATE TABLE t2 (b INT); +INSERT INTO t2 VALUES (1), (2), (3); +# +# query: UPDATE t1, t2 SET a = 10 WHERE a IN (SELECT b FROM t2 WHERE t2.b < 3) +# select: SELECT * FROM t1, t2 WHERE a IN (SELECT b FROM t2 WHERE t2.b < 3) +# +EXPLAIN UPDATE t1, t2 SET a = 10 WHERE a IN (SELECT b FROM t2 WHERE t2.b < 3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(t1) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 update `test`.`t1` join `test`.`t2` semi join (`test`.`t2`) set `test`.`t1`.`a` = 10 where ((`test`.`t2`.`b` = `test`.`t1`.`a`) and (`test`.`t1`.`a` < 3)) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 12 +# Status of testing query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 15 +Handler_update 2 + +DROP TABLE t1, t2; +#8 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +CREATE TABLE t2 (b INT); +INSERT INTO t2 VALUES (1), (2), (3); +# +# query: UPDATE t1 t11, (SELECT * FROM t2) t12 SET t11.a = t11.a + 10 +# select: SELECT * FROM t1 t11, (SELECT * FROM t2) t12 +# +EXPLAIN UPDATE t1 t11, (SELECT * FROM t2) t12 SET t11.a = t11.a + 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t11 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 update `test`.`t1` `t11` join `test`.`t2` set `test`.`t11`.`a` = (`test`.`t11`.`a` + 10) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 8 +# Status of testing query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 16 +Handler_update 3 + +DROP TABLE t1, t2; +#9 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +CREATE TABLE t2 (b INT); +INSERT INTO t2 VALUES (1), (2), (3); +# +# query: UPDATE t1 t11, (SELECT 1 FROM DUAL) t12 SET t11.a = t11.a + 10 +# select: SELECT * FROM t1 t11, (SELECT 1 FROM DUAL) t12 +# +EXPLAIN UPDATE t1 t11, (SELECT 1 FROM DUAL) t12 SET t11.a = t11.a + 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL system NULL NULL NULL NULL 1 100.00 NULL +1 UPDATE t11 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 update `test`.`t1` `t11` join (/* select#2 */ select 1 AS `1`) `t12` set `test`.`t11`.`a` = (`test`.`t11`.`a` + 10) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 1 +Handler_read_rnd_next 5 +Handler_write 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 1 +Handler_read_rnd 3 +Handler_read_rnd_next 9 +Handler_update 3 +Handler_write 4 + +DROP TABLE t1, t2; +#10 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +CREATE TABLE t2 (b INT); +INSERT INTO t2 VALUES (1), (2), (3); +# +# query: UPDATE t1 t11, (SELECT * FROM t2) t12 SET t11.a = 10 WHERE t11.a > 1 +# select: SELECT * FROM t1 t11, (SELECT * FROM t2) t12 WHERE t11.a > 1 +# +EXPLAIN UPDATE t1 t11, (SELECT * FROM t2) t12 SET t11.a = 10 WHERE t11.a > 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t11 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 update `test`.`t1` `t11` join `test`.`t2` set `test`.`t11`.`a` = 10 where (`test`.`t11`.`a` > 1) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 8 +# Status of testing query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 12 +Handler_update 2 + +DROP TABLE t1, t2; +#11 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +# +# query: DELETE FROM t1 WHERE a > 1 LIMIT 1 +# select: SELECT * FROM t1 WHERE a > 1 LIMIT 1 +# +EXPLAIN DELETE FROM t1 WHERE a > 1 LIMIT 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 delete from `test`.`t1` where (`test`.`t1`.`a` > 1) limit 1 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 1 +Handler_read_rnd_next 2 +# Status of testing query execution: +Variable_name Value +Handler_delete 1 +Handler_read_key 1 +Handler_read_rnd_next 2 + +DROP TABLE t1; +#12 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +# +# query: DELETE FROM t1 WHERE 0 +# select: SELECT * FROM t1 WHERE 0 +# +EXPLAIN DELETE FROM t1 WHERE 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 delete from `test`.`t1` where false +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 1 + +DROP TABLE t1; +#13 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +# +# query: DELETE FROM t1 USING t1 WHERE 0 +# select: SELECT * FROM t1 WHERE 0 +# +EXPLAIN DELETE FROM t1 USING t1 WHERE 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 delete `test`.`t1` from `test`.`t1` where false +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 1 + +DROP TABLE t1; +#14 +CREATE TABLE t1 (a INT, b INT, UNIQUE KEY (a), KEY (b)); +INSERT INTO t1 VALUES (3, 3), (7, 7); +# +# query: DELETE FROM t1 WHERE a = 3 +# select: SELECT * FROM t1 WHERE a = 3 +# +EXPLAIN DELETE FROM t1 WHERE a = 3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL range a a 5 const 1 100.00 Using where +Warnings: +Note 1003 delete from `test`.`t1` where (`test`.`t1`.`a` = 3) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 3 +# Status of testing query execution: +Variable_name Value +Handler_delete 1 +Handler_read_key 3 + +DROP TABLE t1; +#15 +CREATE TABLE t1 (a INT, b INT, UNIQUE KEY (a), KEY (b)); +INSERT INTO t1 VALUES (3, 3), (7, 7); +# +# query: DELETE FROM t1 WHERE a < 3 +# select: SELECT * FROM t1 WHERE a < 3 +# +EXPLAIN DELETE FROM t1 WHERE a < 3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL range a a 5 const 1 100.00 Using where +Warnings: +Note 1003 delete from `test`.`t1` where (`test`.`t1`.`a` < 3) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 3 +# Status of testing query execution: +Variable_name Value +Handler_read_key 3 + +DROP TABLE t1; +#16 +CREATE TABLE t1 ( a int PRIMARY KEY ); +# +# query: DELETE FROM t1 WHERE t1.a > 0 ORDER BY t1.a +# select: SELECT * FROM t1 WHERE t1.a > 0 ORDER BY t1.a +# +EXPLAIN DELETE FROM t1 WHERE t1.a > 0 ORDER BY t1.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL range PRIMARY PRIMARY 4 const 1 100.00 Using where +Warnings: +Note 1003 delete from `test`.`t1` where (`test`.`t1`.`a` > 0) order by `test`.`t1`.`a` +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 1 +Handler_read_rnd_next 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 2 + +INSERT INTO t1 VALUES (1), (2), (3); +# +# query: DELETE FROM t1 WHERE t1.a > 0 ORDER BY t1.a +# select: SELECT * FROM t1 WHERE t1.a > 0 ORDER BY t1.a +# +EXPLAIN DELETE FROM t1 WHERE t1.a > 0 ORDER BY t1.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL range PRIMARY PRIMARY 4 const 3 100.00 Using where +Warnings: +Note 1003 delete from `test`.`t1` where (`test`.`t1`.`a` > 0) order by `test`.`t1`.`a` +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 1 +Handler_read_next 3 +# Status of testing query execution: +Variable_name Value +Handler_delete 3 +Handler_read_key 2 +Handler_read_next 3 + +DROP TABLE t1; +#17 +CREATE TABLE t1(a INT PRIMARY KEY); +INSERT INTO t1 VALUES (4),(3),(1),(2); +# +# query: DELETE FROM t1 WHERE (@a:= a) ORDER BY a LIMIT 1 +# select: SELECT * FROM t1 WHERE (@a:= a) ORDER BY a LIMIT 1 +# +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +EXPLAIN DELETE FROM t1 WHERE (@a:= a) ORDER BY a LIMIT 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL index NULL PRIMARY 4 NULL 4 100.00 Using where +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +Note 1003 delete from `test`.`t1` where (0 <> (@a:=`test`.`t1`.`a`)) order by `test`.`t1`.`a` limit 1 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 1 +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +# Status of testing query execution: +Variable_name Value +Handler_delete 1 +Handler_read_first 1 +Handler_read_key 1 + +DROP TABLE t1; +#18 +CREATE TABLE t1 (a DATE, b TIME, c INT, KEY c(c), KEY b(b), KEY a(a)); +INSERT INTO t1 VALUES (), (), (), (), (), (), (), (), (), (); +UPDATE t1 SET a = c, b = c; +# +# query: DELETE FROM t1 ORDER BY a ASC, b ASC LIMIT 1 +# select: SELECT * FROM t1 ORDER BY a ASC, b ASC LIMIT 1 +# +EXPLAIN DELETE FROM t1 ORDER BY a ASC, b ASC LIMIT 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 10 100.00 Using filesort +Warnings: +Note 1003 delete from `test`.`t1` order by `test`.`t1`.`a`,`test`.`t1`.`b` limit 1 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 3 +Handler_read_rnd_next 11 +Sort_rows 1 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_delete 1 +Handler_read_key 3 +Handler_read_rnd 1 +Handler_read_rnd_next 11 +Sort_rows 10 +Sort_scan 1 + +DROP TABLE t1; +#19 +CREATE TABLE t1 (a1 INT NOT NULL, b1 INT NOT NULL); +CREATE TABLE t2 (a2 INT NOT NULL, b2 INT NOT NULL, PRIMARY KEY (a2,b2)); +CREATE TABLE t3 (a3 INT NOT NULL, b3 INT NOT NULL, PRIMARY KEY (a3,b3)); +INSERT INTO t1 VALUES (1,1), (2,1), (1,3); +INSERT INTO t2 VALUES (1,1), (2,2), (3,3); +INSERT INTO t3 VALUES (1,1), (2,1), (1,3); +# +# query: DELETE t1,t2,t3 FROM t1,t2,t3 WHERE a1=a2 AND b2=a3 AND b1=b3 +# select: SELECT * FROM t1,t2,t3 WHERE a1=a2 AND b2=a3 AND b1=b3 +# +EXPLAIN DELETE t1,t2,t3 FROM t1,t2,t3 WHERE a1=a2 AND b2=a3 AND b1=b3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 DELETE t2 NULL ref PRIMARY PRIMARY 4 test.t1.a1 1 100.00 NULL +1 DELETE t3 NULL eq_ref PRIMARY PRIMARY 8 test.t2.b2,test.t1.b1 1 100.00 NULL +Warnings: +Note 1003 delete `test`.`t1`, `test`.`t2`, `test`.`t3` from `test`.`t1` join `test`.`t2` join `test`.`t3` where ((`test`.`t3`.`b3` = `test`.`t1`.`b1`) and (`test`.`t3`.`a3` = `test`.`t2`.`b2`) and (`test`.`t2`.`a2` = `test`.`t1`.`a1`)) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 12 +Handler_read_next 3 +Handler_read_rnd_next 4 +# Status of testing query execution: +Variable_name Value +Handler_delete 8 +Handler_read_key 12 +Handler_read_next 3 +Handler_read_rnd 5 +Handler_read_rnd_next 4 + +DROP TABLE t1, t2, t3; +#20 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +CREATE TABLE t2 (a INT); +INSERT INTO t2 VALUES (1), (2), (3); +# +# query: UPDATE t1 SET a = 10 WHERE a IN (SELECT a FROM t2) +# select: SELECT * FROM t1 WHERE a IN (SELECT a FROM t2) +# +EXPLAIN UPDATE t1 SET a = 10 WHERE a IN (SELECT a FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(t1) +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`a` = 10 where (`test`.`t2`.`a` = `test`.`t1`.`a`) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 8 +# Status of testing query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 10 +Handler_update 3 + +DROP TABLE t1, t2; +#21 +CREATE TABLE t1 (a1 INT); +INSERT INTO t1 VALUES (1), (2), (3), (4), (5); +CREATE TABLE t2 (a2 VARCHAR(10)) charset utf8mb4; +INSERT INTO t2 VALUES (1), (2), (3), (4), (5); +SET @save_optimizer_switch= @@optimizer_switch; +# +# query: DELETE FROM t1 WHERE a1 IN (SELECT a2 FROM t2 WHERE a2 > 2) +# select: SELECT * FROM t1 WHERE a1 IN (SELECT a2 FROM t2 WHERE a2 > 2) +# +EXPLAIN DELETE FROM t1 WHERE a1 IN (SELECT a2 FROM t2 WHERE a2 > 2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 5 100.00 Using where +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 5 20.00 Using where +Warnings: +Note 1003 delete from `test`.`t1` where (`test`.`t1`.`a1`,(/* select#2 */ select `test`.`t2`.`a2` from `test`.`t2` where ((`test`.`t2`.`a2` > 2) and ((`test`.`t1`.`a1`) = `test`.`t2`.`a2`)))) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 30 +# Status of testing query execution: +Variable_name Value +Handler_delete 3 +Handler_read_key 2 +Handler_read_rnd_next 30 + +SET @@optimizer_switch= @save_optimizer_switch; +TRUNCATE t1; +INSERT INTO t1 VALUES (1), (2), (3), (4), (5); +# +# query: DELETE FROM t1 WHERE a1 IN (SELECT a2 FROM t2 WHERE a2 > 2) +# select: SELECT * FROM t1 WHERE a1 IN (SELECT a2 FROM t2 WHERE a2 > 2) +# +EXPLAIN DELETE FROM t1 WHERE a1 IN (SELECT a2 FROM t2 WHERE a2 > 2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 5 20.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 delete from `test`.`t1` where ((`test`.`t2`.`a2` > 2) and (cast(`test`.`t1`.`a1` as double) = cast(`test`.`t2`.`a2` as double))) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 12 +# Status of testing query execution: +Variable_name Value +Handler_delete 3 +Handler_read_key 2 +Handler_read_rnd_next 30 + +DROP TABLE t1, t2; +#22 +CREATE TABLE t1 (i INT, j INT); +INSERT INTO t1 VALUES (1, 1), (2, 2), (3, 3), (4, 4), (5, 5); +# +# query: UPDATE t1 SET i = 10 +# select: SELECT * FROM t1 +# +EXPLAIN UPDATE t1 SET i = 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`i` = 10 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 6 +# Status of testing query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 6 +Handler_update 5 + +DROP TABLE t1; +#23 +CREATE TABLE t1 (i INT, j INT); +INSERT INTO t1 VALUES (1, 1), (2, 2), (3, 3), (4, 4), (5, 5); +# +# query: DELETE FROM t1 +# select: SELECT * FROM t1 +# +EXPLAIN DELETE FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 5 100.00 Deleting all rows +Warnings: +Note 1003 delete from `test`.`t1` +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 6 +# Status of testing query execution: +Variable_name Value +Handler_read_key 2 + +DROP TABLE t1; +#24 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2(a INT, b INT, c INT, d INT, INDEX(a, b, c)); +INSERT INTO t2 (a, b, c) SELECT i, i, i FROM t1; +INSERT INTO t2 (a, b, c) SELECT t1.i, t1.i, t1.i FROM t1, t1 x1, t1 x2; +# +# query: DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# select: SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# +EXPLAIN DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t2 NULL index NULL a 15 NULL 17602 100.00 Using where +Warnings: +Note 1003 delete from `test`.`t2` where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 4 +Handler_read_next 4 +# Status of testing query execution: +Variable_name Value +Handler_delete 5 +Handler_read_first 1 +Handler_read_key 4 +Handler_read_next 4 + +DROP TABLE t1, t2; +#25 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (1), (2), (3); +CREATE TABLE t2 (i INT); +# +# query: INSERT INTO t2 SELECT * FROM t1 +# select: SELECT * FROM t1 +# +EXPLAIN INSERT INTO t2 SELECT * FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 INSERT t2 NULL ALL NULL NULL NULL NULL NULL NULL NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 insert into `test`.`t2` /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 1 +Handler_read_rnd_next 4 +# Status of testing query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 4 +Handler_write 3 + +# +# query: INSERT INTO t2 SELECT * FROM t1 JOIN t1 AS tt USING(i) +# select: SELECT * FROM t1 JOIN t1 AS tt USING(i) +# +EXPLAIN INSERT INTO t2 SELECT * FROM t1 JOIN t1 AS tt USING(i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 INSERT t2 NULL ALL NULL NULL NULL NULL NULL NULL NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE tt NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +Warnings: +Note 1003 insert into `test`.`t2` /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` join `test`.`t1` `tt` where (`test`.`tt`.`i` = `test`.`t1`.`i`) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 1 +Handler_read_rnd_next 8 +# Status of testing query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 8 +Handler_write 3 + +DROP TABLE t1, t2; +#26 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (1), (2), (3); +CREATE TABLE t2 (i INT); +# +# query: REPLACE INTO t2 SELECT * FROM t1 +# select: SELECT * FROM t1 +# +EXPLAIN REPLACE INTO t2 SELECT * FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 REPLACE t2 NULL ALL NULL NULL NULL NULL NULL NULL NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 replace into `test`.`t2` /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 1 +Handler_read_rnd_next 4 +# Status of testing query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 4 +Handler_write 3 + +DROP TABLE t1, t2; +#27 +CREATE TABLE t1 (i INT); +# +# query: INSERT INTO t1 SET i = 10 +# select: +# +EXPLAIN INSERT INTO t1 SET i = 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 INSERT t1 NULL ALL NULL NULL NULL NULL NULL NULL NULL +Warnings: +Note 1003 insert into `test`.`t1` (`test`.`t1`.`i`) values (10) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# Status of testing query execution: +Variable_name Value +Handler_read_key 1 +Handler_write 1 + +DROP TABLE t1; +#28 +CREATE TABLE t1 (i INT); +# +# query: REPLACE INTO t1 SET i = 10 +# select: +# +EXPLAIN REPLACE INTO t1 SET i = 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 REPLACE t1 NULL ALL NULL NULL NULL NULL NULL NULL NULL +Warnings: +Note 1003 replace into `test`.`t1` (`test`.`t1`.`i`) values (10) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# Status of testing query execution: +Variable_name Value +Handler_read_key 1 +Handler_write 1 + +DROP TABLE t1; +#29 +CREATE TABLE t1 (a INT, i INT PRIMARY KEY); +INSERT INTO t1 (i) VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +# +# query: DELETE FROM t1 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 1 +# select: SELECT * FROM t1 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 1 +# +EXPLAIN DELETE FROM t1 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL range PRIMARY PRIMARY 4 const 8 100.00 Using where +Warnings: +Note 1003 delete from `test`.`t1` where ((`test`.`t1`.`i` > 10) and (`test`.`t1`.`i` <= 18)) order by `test`.`t1`.`i` limit 1 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 3 +# Status of testing query execution: +Variable_name Value +Handler_delete 1 +Handler_read_key 3 + +DROP TABLE t1; +#30 +CREATE TABLE t1(a INT, i CHAR(2), INDEX(i(1))) charset utf8mb4; +INSERT INTO t1 (i) VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +# +# query: DELETE FROM t1 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 5 +# select: SELECT * FROM t1 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 5 +# +EXPLAIN DELETE FROM t1 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 26 100.00 Using where; Using filesort +Warnings: +Warning 1739 Cannot use range access on index 'i' due to type or collation conversion on field 'i' +Warning 1739 Cannot use range access on index 'i' due to type or collation conversion on field 'i' +Note 1003 delete from `test`.`t1` where ((`test`.`t1`.`i` > 10) and (`test`.`t1`.`i` <= 18)) order by `test`.`t1`.`i` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 27 +Sort_rows 5 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_delete 5 +Handler_read_key 2 +Handler_read_rnd 5 +Handler_read_rnd_next 27 +Sort_rows 8 +Sort_scan 1 + +DROP TABLE t1; +#31 +CREATE TABLE t1 (i INT); +INSERT INTO t1 (i) VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2(a INT, b INT, c INT, d INT, INDEX(a, b, c)); +INSERT INTO t2 (a, b, c) SELECT i, i, i FROM t1; +# +# query: DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# select: SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# +EXPLAIN DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t2 NULL ALL NULL NULL NULL NULL 26 100.00 Using where; Using filesort +Warnings: +Note 1003 delete from `test`.`t2` where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 4 +Handler_read_next 26 +# Status of testing query execution: +Variable_name Value +Handler_delete 1 +Handler_read_key 4 +Handler_read_rnd 1 +Handler_read_rnd_next 27 +Sort_rows 1 +Sort_scan 1 + +DROP TABLE t1, t2; +#32 +CREATE TABLE t1 (i INT); +INSERT INTO t1 (i) VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2(a INT, b INT, c INT, d INT, INDEX(a, b, c)); +INSERT INTO t2 (a, b, c) SELECT i, i, i FROM t1; +INSERT INTO t2 (a, b, c) SELECT t1.i, t1.i, t1.i FROM t1, t1 x1, t1 x2; +# +# query: DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# select: SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# +EXPLAIN DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t2 NULL index NULL a 15 NULL 17602 100.00 Using where +Warnings: +Note 1003 delete from `test`.`t2` where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 4 +Handler_read_next 4 +# Status of testing query execution: +Variable_name Value +Handler_delete 5 +Handler_read_first 1 +Handler_read_key 4 +Handler_read_next 4 + +DROP TABLE t1, t2; +#33 +CREATE TABLE t1 (i INT); +INSERT INTO t1 (i) VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2 (a CHAR(2), b CHAR(2), c CHAR(2), d CHAR(2), INDEX (a,b(1),c)) +charset utf8mb4; +INSERT INTO t2 SELECT i, i, i, i FROM t1; +# +# query: DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# select: SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# +EXPLAIN DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t2 NULL ALL NULL NULL NULL NULL 26 100.00 Using where; Using filesort +Warnings: +Warning 1739 Cannot use range access on index 'a' due to type or collation conversion on field 'b' +Note 1003 delete from `test`.`t2` where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 4 +Handler_read_rnd_next 27 +Sort_rows 1 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_delete 1 +Handler_read_key 4 +Handler_read_rnd 1 +Handler_read_rnd_next 27 +Sort_rows 1 +Sort_scan 1 + +DROP TABLE t1, t2; +#34 +CREATE TABLE t1 (i INT); +INSERT INTO t1 (i) VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2 (a CHAR(2), b CHAR(2), c CHAR(2), d CHAR(2), INDEX (a,b,c)) +charset utf8mb4 ENGINE=HEAP; +INSERT INTO t2 SELECT i, i, i, i FROM t1; +# +# query: DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# select: SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# +EXPLAIN DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t2 NULL ALL NULL NULL NULL NULL 26 100.00 Using where; Using filesort +Warnings: +Warning 1739 Cannot use range access on index 'a' due to type or collation conversion on field 'b' +Note 1003 delete from `test`.`t2` where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 4 +Handler_read_rnd_next 27 +Sort_rows 1 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_delete 1 +Handler_read_key 4 +Handler_read_rnd 1 +Handler_read_rnd_next 27 +Sort_rows 1 +Sort_scan 1 + +DROP TABLE t1, t2; +#35 +CREATE TABLE t1 (i INT); +INSERT INTO t1 (i) VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35),(36),(37),(38),(39), +(40),(41),(42),(43),(44); +CREATE TABLE t2 (i INT, key1 INT, key2 INT, INDEX (key1), INDEX (key2)); +INSERT INTO t2 (key1, key2) SELECT i, i FROM t1; +# +# query: DELETE FROM t2 WHERE key1 < 13 or key2 < 14 ORDER BY key1 +# select: SELECT * FROM t2 WHERE key1 < 13 or key2 < 14 ORDER BY key1 +# +EXPLAIN DELETE FROM t2 WHERE key1 < 13 or key2 < 14 ORDER BY key1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t2 NULL index_merge key1,key2 key1,key2 5,5 NULL 7 100.00 Using sort_union(key1,key2); Using where; Using filesort +Warnings: +Note 1003 delete from `test`.`t2` where ((`test`.`t2`.`key1` < 13) or (`test`.`t2`.`key2` < 14)) order by `test`.`t2`.`key1` +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 5 +Handler_read_next 7 +Handler_read_rnd 4 +Sort_rows 4 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_delete 4 +Handler_read_key 5 +Handler_read_next 7 +Handler_read_rnd 8 +Sort_rows 4 +Sort_scan 1 + +DROP TABLE t1, t2; +#36 +CREATE TABLE t1 (i INT); +INSERT INTO t1 (i) VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2(a INT, i INT PRIMARY KEY); +INSERT INTO t2 (i) SELECT i FROM t1; +# +# query: DELETE FROM t2 WHERE i > 10 AND i <= 18 ORDER BY i DESC LIMIT 1 +# select: SELECT * FROM t2 WHERE i > 10 AND i <= 18 ORDER BY i DESC LIMIT 1 +# +EXPLAIN DELETE FROM t2 WHERE i > 10 AND i <= 18 ORDER BY i DESC LIMIT 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t2 NULL range PRIMARY PRIMARY 4 const 8 100.00 Using where; Backward index scan +Warnings: +Note 1003 delete from `test`.`t2` where ((`test`.`t2`.`i` > 10) and (`test`.`t2`.`i` <= 18)) order by `test`.`t2`.`i` desc limit 1 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 3 +# Status of testing query execution: +Variable_name Value +Handler_delete 1 +Handler_read_key 3 + +DROP TABLE t1, t2; +#37 +CREATE TABLE t1 (i INT); +INSERT INTO t1 (i) VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2 (a CHAR(2), b CHAR(2), c CHAR(2), INDEX (a, b)) charset utf8mb4; +INSERT INTO t2 SELECT i, i, i FROM t1; +# +# query: DELETE FROM t2 ORDER BY a, b DESC LIMIT 5 +# select: SELECT * FROM t2 ORDER BY a, b DESC LIMIT 5 +# +EXPLAIN DELETE FROM t2 ORDER BY a, b DESC LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t2 NULL ALL NULL NULL NULL NULL 26 100.00 Using filesort +Warnings: +Note 1003 delete from `test`.`t2` order by `test`.`t2`.`a`,`test`.`t2`.`b` desc limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 3 +Handler_read_rnd_next 27 +Sort_rows 5 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_delete 5 +Handler_read_key 3 +Handler_read_rnd 5 +Handler_read_rnd_next 27 +Sort_rows 26 +Sort_scan 1 + +DROP TABLE t1, t2; +#38 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2 (a CHAR(2), b CHAR(2), c INT, INDEX (a, b)) charset utf8mb4; +INSERT INTO t2 (a, b) SELECT i, i FROM t1; +INSERT INTO t2 (a, b) SELECT t1.i, t1.i FROM t1, t1 x1, t1 x2; +# +# query: DELETE FROM t2 ORDER BY a DESC, b DESC LIMIT 5 +# select: SELECT * FROM t2 ORDER BY a DESC, b DESC LIMIT 5 +# +EXPLAIN DELETE FROM t2 ORDER BY a DESC, b DESC LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t2 NULL index NULL a 18 NULL 5 100.00 NULL +Warnings: +Note 1003 delete from `test`.`t2` order by `test`.`t2`.`a` desc,`test`.`t2`.`b` desc limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 3 +Handler_read_last 1 +Handler_read_prev 4 +# Status of testing query execution: +Variable_name Value +Handler_delete 5 +Handler_read_key 3 +Handler_read_last 1 +Handler_read_prev 4 + +DROP TABLE t1, t2; +#39 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2(a INT, i INT PRIMARY KEY); +INSERT INTO t2 (i) SELECT i FROM t1; +# +# query: UPDATE t2 SET a = 10 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 1 +# select: SELECT * FROM t2 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 1 +# +EXPLAIN UPDATE t2 SET a = 10 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t2 NULL range PRIMARY PRIMARY 4 const 8 100.00 Using where; Using temporary +Warnings: +Note 1003 update `test`.`t2` set `test`.`t2`.`a` = 10 where ((`test`.`t2`.`i` > 10) and (`test`.`t2`.`i` <= 18)) order by `test`.`t2`.`i` limit 1 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 3 +# Status of testing query execution: +Variable_name Value +Handler_read_key 3 +Handler_read_rnd 1 +Handler_update 1 + +DROP TABLE t1, t2; +#40 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2(a INT, i CHAR(2), INDEX(i(1))) charset utf8mb4; +INSERT INTO t2 (i) SELECT i FROM t1; +# +# query: UPDATE t2 SET a = 10 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 5 +# select: SELECT * FROM t2 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 5 +# +EXPLAIN UPDATE t2 SET a = 10 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t2 NULL ALL NULL NULL NULL NULL 26 100.00 Using where; Using filesort +Warnings: +Warning 1739 Cannot use range access on index 'i' due to type or collation conversion on field 'i' +Warning 1739 Cannot use range access on index 'i' due to type or collation conversion on field 'i' +Note 1003 update `test`.`t2` set `test`.`t2`.`a` = 10 where ((`test`.`t2`.`i` > 10) and (`test`.`t2`.`i` <= 18)) order by `test`.`t2`.`i` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 27 +Sort_rows 5 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd 5 +Handler_read_rnd_next 27 +Handler_update 5 +Sort_rows 5 +Sort_scan 1 + +DROP TABLE t1, t2; +#41 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2(a INT, b INT, c INT, d INT, INDEX(a, b, c)); +INSERT INTO t2 (a, b, c) SELECT i, i, i FROM t1; +# +# query: UPDATE t2 SET d = 10 WHERE b = 10 ORDER BY a, c LIMIT 5 +# select: SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# +EXPLAIN UPDATE t2 SET d = 10 WHERE b = 10 ORDER BY a, c LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t2 NULL ALL NULL NULL NULL NULL 26 100.00 Using where; Using filesort +Warnings: +Note 1003 update `test`.`t2` set `test`.`t2`.`d` = 10 where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 4 +Handler_read_next 26 +# Status of testing query execution: +Variable_name Value +Handler_read_key 4 +Handler_read_rnd 1 +Handler_read_rnd_next 27 +Handler_update 1 +Sort_rows 1 +Sort_scan 1 + +DROP TABLE t1, t2; +#42 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2(a INT, b INT, c INT, d INT, INDEX(a, b, c)); +INSERT INTO t2 (a, b, c) SELECT i, i, i FROM t1; +INSERT INTO t2 (a, b, c) SELECT t1.i, t1.i, t1.i FROM t1, t1 x1, t1 x2; +# +# query: UPDATE t2 SET d = 10 WHERE b = 10 ORDER BY a, c LIMIT 5 +# select: SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# +EXPLAIN UPDATE t2 SET d = 10 WHERE b = 10 ORDER BY a, c LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t2 NULL index NULL a 15 NULL 17602 100.00 Using where; Using temporary +Warnings: +Note 1003 update `test`.`t2` set `test`.`t2`.`d` = 10 where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 4 +Handler_read_next 4 +# Status of testing query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 4 +Handler_read_next 4 +Handler_read_rnd 5 +Handler_update 5 + +DROP TABLE t1, t2; +#43 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2 (a CHAR(2), b CHAR(2), c CHAR(2), d CHAR(2), INDEX (a,b(1),c)) +charset utf8mb4; +INSERT INTO t2 SELECT i, i, i, i FROM t1; +# +# query: UPDATE t2 SET d = 10 WHERE b = 10 ORDER BY a, c LIMIT 5 +# select: SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# +EXPLAIN UPDATE t2 SET d = 10 WHERE b = 10 ORDER BY a, c LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t2 NULL ALL NULL NULL NULL NULL 26 100.00 Using where; Using filesort +Warnings: +Warning 1739 Cannot use range access on index 'a' due to type or collation conversion on field 'b' +Note 1003 update `test`.`t2` set `test`.`t2`.`d` = 10 where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 4 +Handler_read_rnd_next 27 +Sort_rows 1 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 4 +Handler_read_rnd 1 +Handler_read_rnd_next 27 +Sort_rows 1 +Sort_scan 1 + +DROP TABLE t1, t2; +#44 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2 (a CHAR(2), b CHAR(2), c CHAR(2), d CHAR(2), INDEX (a,b,c)) +charset utf8mb4 ENGINE=HEAP; +INSERT INTO t2 SELECT i, i, i, i FROM t1; +# +# query: UPDATE t2 SET d = 10 WHERE b = 10 ORDER BY a, c LIMIT 5 +# select: SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# +EXPLAIN UPDATE t2 SET d = 10 WHERE b = 10 ORDER BY a, c LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t2 NULL ALL NULL NULL NULL NULL 26 100.00 Using where; Using filesort +Warnings: +Warning 1739 Cannot use range access on index 'a' due to type or collation conversion on field 'b' +Note 1003 update `test`.`t2` set `test`.`t2`.`d` = 10 where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 4 +Handler_read_rnd_next 27 +Sort_rows 1 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 4 +Handler_read_rnd 1 +Handler_read_rnd_next 27 +Sort_rows 1 +Sort_scan 1 + +DROP TABLE t1, t2; +#45 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35),(36),(37),(38),(39), +(40),(41),(42),(43),(44); +CREATE TABLE t2 (i INT, key1 INT, key2 INT, INDEX (key1), INDEX (key2)); +INSERT INTO t2 (key1, key2) SELECT i, i FROM t1; +# +# query: UPDATE t2 SET i = 123 WHERE key1 < 13 or key2 < 14 ORDER BY key1 +# select: SELECT * FROM t2 WHERE key1 < 13 or key2 < 14 ORDER BY key1 +# +EXPLAIN UPDATE t2 SET i = 123 WHERE key1 < 13 or key2 < 14 ORDER BY key1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t2 NULL index_merge key1,key2 key1,key2 5,5 NULL 7 100.00 Using sort_union(key1,key2); Using where; Using filesort +Warnings: +Note 1003 update `test`.`t2` set `test`.`t2`.`i` = 123 where ((`test`.`t2`.`key1` < 13) or (`test`.`t2`.`key2` < 14)) order by `test`.`t2`.`key1` +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 5 +Handler_read_next 7 +Handler_read_rnd 4 +Sort_rows 4 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 5 +Handler_read_next 7 +Handler_read_rnd 8 +Handler_update 4 +Sort_rows 4 +Sort_scan 1 + +DROP TABLE t1, t2; +#46 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2(a INT, i INT PRIMARY KEY); +INSERT INTO t2 (i) SELECT i FROM t1; +# +# query: UPDATE t2 SET a = 10 WHERE i > 10 AND i <= 18 ORDER BY i DESC LIMIT 1 +# select: SELECT * FROM t2 WHERE i > 10 AND i <= 18 ORDER BY i DESC LIMIT 1 +# +EXPLAIN UPDATE t2 SET a = 10 WHERE i > 10 AND i <= 18 ORDER BY i DESC LIMIT 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t2 NULL range PRIMARY PRIMARY 4 const 8 100.00 Using where; Backward index scan; Using temporary +Warnings: +Note 1003 update `test`.`t2` set `test`.`t2`.`a` = 10 where ((`test`.`t2`.`i` > 10) and (`test`.`t2`.`i` <= 18)) order by `test`.`t2`.`i` desc limit 1 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 3 +# Status of testing query execution: +Variable_name Value +Handler_read_key 3 +Handler_read_rnd 1 +Handler_update 1 + +DROP TABLE t1, t2; +#47 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2 (a CHAR(2), b CHAR(2), c CHAR(2), INDEX (a, b)) charset utf8mb4; +INSERT INTO t2 SELECT i, i, i FROM t1; +# +# query: UPDATE t2 SET c = 10 ORDER BY a, b DESC LIMIT 5 +# select: SELECT * FROM t2 ORDER BY a, b DESC LIMIT 5 +# +EXPLAIN UPDATE t2 SET c = 10 ORDER BY a, b DESC LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t2 NULL ALL NULL NULL NULL NULL 26 100.00 Using filesort +Warnings: +Note 1003 update `test`.`t2` set `test`.`t2`.`c` = 10 order by `test`.`t2`.`a`,`test`.`t2`.`b` desc limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 3 +Handler_read_rnd_next 27 +Sort_rows 5 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 3 +Handler_read_rnd 5 +Handler_read_rnd_next 27 +Handler_update 4 +Sort_rows 5 +Sort_scan 1 + +DROP TABLE t1, t2; +#48 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2 (a CHAR(2), b CHAR(2), c INT, INDEX (a, b)) charset utf8mb4; +INSERT INTO t2 (a, b) SELECT i, i FROM t1; +INSERT INTO t2 (a, b) SELECT t1.i, t1.i FROM t1, t1 x1, t1 x2; +# +# query: UPDATE t2 SET c = 10 ORDER BY a DESC, b DESC LIMIT 5 +# select: SELECT * FROM t2 ORDER BY a DESC, b DESC LIMIT 5 +# +EXPLAIN UPDATE t2 SET c = 10 ORDER BY a DESC, b DESC LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t2 NULL index NULL a 18 NULL 5 100.00 Using temporary +Warnings: +Note 1003 update `test`.`t2` set `test`.`t2`.`c` = 10 order by `test`.`t2`.`a` desc,`test`.`t2`.`b` desc limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 3 +Handler_read_last 1 +Handler_read_prev 4 +# Status of testing query execution: +Variable_name Value +Handler_read_key 3 +Handler_read_last 1 +Handler_read_prev 4 +Handler_read_rnd 5 +Handler_update 5 + +DROP TABLE t1, t2; +#49 +CREATE TABLE t1 ( +pk INT NOT NULL AUTO_INCREMENT, +c1_idx CHAR(1) DEFAULT 'y', +c2 INT, +PRIMARY KEY (pk), +INDEX c1_idx (c1_idx) +) charset utf8mb4; +INSERT INTO t1 VALUES (1,'y',1), (2,'n',2), (3,'y',3), (4,'n',4); +# +# query: UPDATE t1 SET c2 = 0 WHERE c1_idx = 'y' ORDER BY pk DESC LIMIT 2 +# select: SELECT * FROM t1 WHERE c1_idx = 'y' ORDER BY pk DESC LIMIT 2 +# +EXPLAIN UPDATE t1 SET c2 = 0 WHERE c1_idx = 'y' ORDER BY pk DESC LIMIT 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL range c1_idx c1_idx 5 const 2 100.00 Using where; Using filesort +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`c2` = 0 where (`test`.`t1`.`c1_idx` = 'y') order by `test`.`t1`.`pk` desc limit 2 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 4 +Handler_read_next 2 +Sort_rows 2 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 4 +Handler_read_next 2 +Handler_read_rnd 2 +Handler_update 2 +Sort_rows 2 +Sort_scan 1 + +# +# query: DELETE FROM t1 WHERE c1_idx = 'y' ORDER BY pk DESC LIMIT 2 +# select: SELECT * FROM t1 WHERE c1_idx = 'y' ORDER BY pk DESC LIMIT 2 +# +EXPLAIN DELETE FROM t1 WHERE c1_idx = 'y' ORDER BY pk DESC LIMIT 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL range c1_idx c1_idx 5 const 2 100.00 Using where; Using filesort +Warnings: +Note 1003 delete from `test`.`t1` where (`test`.`t1`.`c1_idx` = 'y') order by `test`.`t1`.`pk` desc limit 2 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 4 +Handler_read_next 2 +Sort_rows 2 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_delete 2 +Handler_read_key 4 +Handler_read_next 2 +Handler_read_rnd 2 +Sort_rows 2 +Sort_scan 1 + +DROP TABLE t1; +#50 +CREATE TABLE t1 (a INT AUTO_INCREMENT PRIMARY KEY); +INSERT INTO t1 VALUES (),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(); +# +# query: UPDATE t1 SET a=a+10 WHERE a > 34 +# select: SELECT * FROM t1 WHERE a > 34 +# +EXPLAIN UPDATE t1 SET a=a+10 WHERE a > 34; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL range PRIMARY PRIMARY 4 const 3 100.00 Using where; Using temporary +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`a` = (`test`.`t1`.`a` + 10) where (`test`.`t1`.`a` > 34) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_next 2 +# Status of testing query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_next 2 +Handler_read_rnd 2 +Handler_update 2 + +DROP TABLE t1; +#51 +CREATE TABLE t1 (c1 INT, c2 INT, c3 INT); +CREATE TABLE t2 (c1 INT, c2 INT); +INSERT INTO t1 VALUES (1, 1, 10), (2, 2, 20); +# +# query: UPDATE t1 LEFT JOIN t2 ON t1.c1 = t2.c1 SET t2.c2 = 10 +# select: SELECT * FROM t1 LEFT JOIN t2 ON t1.c1 = t2.c1 +# +EXPLAIN UPDATE t1 LEFT JOIN t2 ON t1.c1 = t2.c1 SET t2.c2 = 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t2 NULL system NULL NULL NULL NULL 0 0.00 const row not found +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 update `test`.`t1` left join `test`.`t2` on(multiple equal(`test`.`t1`.`c1`, `test`.`t2`.`c1`)) set `test`.`t2`.`c2` = 10 where true +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 5 +Handler_read_rnd_next 4 +# Status of testing query execution: +Variable_name Value +Handler_read_key 5 +Handler_read_rnd_next 4 + +# +# query: UPDATE t1 LEFT JOIN t2 ON t1.c1 = t2.c1 SET t2.c2 = 10 WHERE t1.c3 = 10 +# select: SELECT * FROM t1 LEFT JOIN t2 ON t1.c1 = t2.c1 WHERE t1.c3 = 10 +# +EXPLAIN UPDATE t1 LEFT JOIN t2 ON t1.c1 = t2.c1 SET t2.c2 = 10 WHERE t1.c3 = 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t2 NULL system NULL NULL NULL NULL 0 0.00 const row not found +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1003 update `test`.`t1` left join `test`.`t2` on(multiple equal(`test`.`t1`.`c1`, `test`.`t2`.`c1`)) set `test`.`t2`.`c2` = 10 where (`test`.`t1`.`c3` = 10) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 5 +Handler_read_rnd_next 4 +# Status of testing query execution: +Variable_name Value +Handler_read_key 5 +Handler_read_rnd_next 4 + +DROP TABLE t1, t2; +#52 +CREATE TABLE t1(f1 INT, f2 INT); +CREATE TABLE t2(f3 INT, f4 INT); +CREATE INDEX IDX ON t2(f3); +INSERT INTO t1 VALUES(1,0),(2,0); +INSERT INTO t2 VALUES(1,1),(2,2); +# +# query: UPDATE t1 SET t1.f2=(SELECT MAX(t2.f4) FROM t2 WHERE t2.f3=t1.f1) +# select: SELECT (SELECT MAX(t2.f4) FROM t2 WHERE t2.f3=t1.f1) FROM t1 +# +EXPLAIN UPDATE t1 SET t1.f2=(SELECT MAX(t2.f4) FROM t2 WHERE t2.f3=t1.f1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DEPENDENT SUBQUERY t2 NULL ref IDX IDX 5 test.t1.f1 1 100.00 NULL +Warnings: +Note 1276 Field or reference 'test.t1.f1' of SELECT #2 was resolved in SELECT #1 +Note 1003 update `test`.`t1` set `test`.`t1`.`f2` = (/* select#2 */ select max(`test`.`t2`.`f4`) from `test`.`t2` where (`test`.`t2`.`f3` = `test`.`t1`.`f1`)) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 6 +Handler_read_next 2 +Handler_read_rnd_next 3 +# Status of testing query execution: +Variable_name Value +Handler_read_key 6 +Handler_read_next 2 +Handler_read_rnd_next 3 +Handler_update 2 + +DROP TABLE t1, t2; +#55 +CREATE TABLE t1(a INT); +INSERT INTO t1 VALUES (1); +SET @a = NULL; +EXPLAIN DELETE FROM t1 WHERE (@a:= a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +Note 1003 delete from `test`.`t1` where (0 <> (@a:=`test`.`t1`.`a`)) +DROP TABLE t1; +#56 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +DELETE FROM t1 USING t1 WHERE uknown_column = 12345; +ERROR 42S22: Unknown column 'uknown_column' in 'where clause' +EXPLAIN DELETE FROM t1 USING t1 WHERE uknown_column = 12345; +ERROR 42S22: Unknown column 'uknown_column' in 'where clause' +DROP TABLE t1; +#57 +CREATE TABLE t1(f1 INT); +EXPLAIN UPDATE t1 SET f2=1 ORDER BY f2; +ERROR 42S22: Unknown column 'f2' in 'field list' +UPDATE t1 SET f2=1 ORDER BY f2; +ERROR 42S22: Unknown column 'f2' in 'field list' +DROP TABLE t1; +#59 +CREATE TABLE t1 ( a INT, KEY( a ) ); +INSERT INTO t1 VALUES (0), (1); +CREATE VIEW v1 AS SELECT t11.a, t12.a AS b FROM t1 t11, t1 t12; +SET SESSION sql_safe_updates = 1; +EXPLAIN UPDATE IGNORE v1 SET a = 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t11 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t12 NULL index NULL a 5 NULL 2 100.00 Using index +Warnings: +Note 1003 update ignore (`test`.`t1` `t11` join `test`.`t1` `t12`) set `t11`.`a` = 1 +UPDATE IGNORE v1 SET a = 1; +ERROR HY000: You are using safe update mode and you tried to update a table without a WHERE that uses a KEY column. +SET SESSION sql_safe_updates = DEFAULT; +DROP TABLE t1; +DROP VIEW v1; +#62 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (0), (1); +CREATE VIEW v1 AS SELECT t11.a, t12.a AS b FROM t1 t11, t1 t12; +# +# query: UPDATE v1 SET a = 1 WHERE a > 0 +# select: SELECT * FROM v1 WHERE a > 0 +# +EXPLAIN UPDATE v1 SET a = 1 WHERE a > 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t11 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t12 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 update (`test`.`t1` `t11` join `test`.`t1` `t12`) set `t11`.`a` = 1 where (`t11`.`a` > 0) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 1 +Handler_read_rnd_next 6 +# Status of testing query execution: +Variable_name Value +Handler_read_key 1 +Handler_read_rnd 1 +Handler_read_rnd_next 8 +Handler_write 2 + +# +# query: UPDATE t1, v1 SET v1.a = 1 WHERE t1.a = v1.a +# select: SELECT * FROM t1, v1 WHERE t1.a = v1.a +# +EXPLAIN UPDATE t1, v1 SET v1.a = 1 WHERE t1.a = v1.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 UPDATE t11 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t12 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 update `test`.`t1` join `test`.`t1` `t11` join `test`.`t1` `t12` set `test`.`t11`.`a` = 1 where (`test`.`t11`.`a` = `test`.`t1`.`a`) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 1 +Handler_read_rnd_next 9 +# Status of testing query execution: +Variable_name Value +Handler_read_key 1 +Handler_read_rnd 2 +Handler_read_rnd_next 18 +Handler_update 1 +Handler_write 4 + +DROP TABLE t1; +DROP VIEW v1; +#63 +CREATE TABLE t1 (a INT, PRIMARY KEY(a)); +INSERT INTO t1 VALUES (1), (2), (3), (4), (5); +CREATE VIEW v1 (a) AS SELECT a FROM t1; +# +# query: DELETE FROM v1 WHERE a < 4 +# select: SELECT * FROM v1 WHERE a < 4 +# +EXPLAIN DELETE FROM v1 WHERE a < 4; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL range PRIMARY PRIMARY 4 const 3 100.00 Using where +Warnings: +Note 1003 delete from (`test`.`t1`) where (`test`.`t1`.`a` < 4) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 1 +Handler_read_next 3 +# Status of testing query execution: +Variable_name Value +Handler_delete 3 +Handler_read_first 1 +Handler_read_key 1 +Handler_read_next 3 + +DROP TABLE t1; +DROP VIEW v1; +#64 +CREATE TABLE t1 (a INT, b INT, PRIMARY KEY(a)); +INSERT INTO t1 VALUES (1,2), (2,3), (3,4), (4,5), (5,10); +CREATE TABLE t2 (x INT); +INSERT INTO t2 VALUES (1), (2), (3), (4); +CREATE VIEW v1 (a,c) AS SELECT a, b+1 FROM t1; +# +# query: DELETE v1 FROM t2, v1 WHERE t2.x = v1.a +# select: SELECT * FROM t2, v1 WHERE t2.x = v1.a +# +EXPLAIN DELETE v1 FROM t2, v1 WHERE t2.x = v1.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +1 DELETE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.x 1 100.00 NULL +Warnings: +Note 1003 delete `test`.`t1` from `test`.`t2` join `test`.`t1` where (`test`.`t1`.`a` = `test`.`t2`.`x`) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 7 +Handler_read_rnd_next 5 +# Status of testing query execution: +Variable_name Value +Handler_delete 4 +Handler_read_key 7 +Handler_read_rnd 4 +Handler_read_rnd_next 5 + +DROP TABLE t1,t2; +DROP VIEW v1; +#65 +CREATE TABLE t1 (a INT, b INT, PRIMARY KEY(a)); +INSERT INTO t1 VALUES (1,2), (2,3), (3,4), (4,5), (5,10); +CREATE TABLE t2 (x INT); +INSERT INTO t2 VALUES (1), (2), (3), (4); +CREATE VIEW v1 (a,c) AS SELECT a, b+1 FROM t1; +# +# query: DELETE v1 FROM t2, v1 WHERE t2.x = v1.a +# select: SELECT * FROM t2, v1 WHERE t2.x = v1.a +# +EXPLAIN DELETE v1 FROM t2, v1 WHERE t2.x = v1.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +1 DELETE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.x 1 100.00 NULL +Warnings: +Note 1003 delete `test`.`t1` from `test`.`t2` join `test`.`t1` where (`test`.`t1`.`a` = `test`.`t2`.`x`) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 7 +Handler_read_rnd_next 5 +# Status of testing query execution: +Variable_name Value +Handler_delete 4 +Handler_read_key 7 +Handler_read_rnd 4 +Handler_read_rnd_next 5 + +DROP TABLE t1,t2; +DROP VIEW v1; +#66 +CREATE TABLE t1 (a INT); +CREATE VIEW v1 (x) AS SELECT a FROM t1; +# +# query: INSERT INTO v1 VALUES (10) +# select: SELECT NULL +# +EXPLAIN INSERT INTO v1 VALUES (10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 INSERT t1 NULL ALL NULL NULL NULL NULL NULL NULL NULL +Warnings: +Note 1003 insert into `test`.`t1` values (10) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +# Status of testing query execution: +Variable_name Value +Handler_read_key 1 +Handler_write 1 + +DROP TABLE t1; +DROP VIEW v1; +#67 +CREATE TABLE t1 (a INT); +CREATE TABLE t2 (b INT); +INSERT INTO t2 VALUES (1), (2), (3); +CREATE VIEW v1 (x) AS SELECT b FROM t2; +# +# query: INSERT INTO v1 SELECT * FROM t1 +# select: SELECT * FROM t1 +# +EXPLAIN INSERT INTO v1 SELECT * FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 INSERT NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 insert into `test`.`t2` /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 1 +Handler_read_rnd_next 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 1 + +DROP TABLE t1, t2; +DROP VIEW v1; +#69 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +CREATE TABLE t2 (b INT); +INSERT INTO t2 VALUES (1), (2), (3); +# +# query: UPDATE t1 SET a = 10 WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x) +# select: SELECT * FROM t1 WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x) +# +EXPLAIN UPDATE t1 SET a = 10 WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 PRIMARY NULL ref 5 test.t1.a 2 100.00 Using index; FirstMatch(t1) +3 DERIVED t2 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`a` = 10 where (`x`.`b` = `test`.`t1`.`a`) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 5 +Handler_read_rnd_next 8 +Handler_write 1 +Sort_rows 3 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 5 +Handler_read_rnd_next 8 +Handler_update 1 +Handler_write 1 +Sort_rows 3 +Sort_scan 1 + +# +# query: UPDATE t1, t2 SET a = 10 WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x) +# select: SELECT * FROM t1, t2 WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x) +# +EXPLAIN UPDATE t1, t2 SET a = 10 WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 PRIMARY NULL ref 5 test.t1.a 2 100.00 Using index; FirstMatch(t1) +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +3 DERIVED t2 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 update `test`.`t1` join `test`.`t2` semi join ((/* select#3 */ select `test`.`t2`.`b` AS `b` from `test`.`t2` order by `test`.`t2`.`b` limit 2,2) `x`) set `test`.`t1`.`a` = 10 where (`x`.`b` = `test`.`t1`.`a`) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 5 +Handler_read_rnd_next 8 +Handler_write 1 +Sort_rows 3 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 5 +Handler_read_rnd_next 8 +Handler_write 1 +Sort_rows 3 +Sort_scan 1 + +# +# query: UPDATE t1, (SELECT * FROM t2) y SET a = 10 WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x) +# select: SELECT * FROM t1, (SELECT * FROM t2) y WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x) +# +EXPLAIN UPDATE t1, (SELECT * FROM t2) y SET a = 10 WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 PRIMARY NULL ref 5 test.t1.a 2 100.00 Using index; FirstMatch(t1) +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +4 DERIVED t2 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 update `test`.`t1` join `test`.`t2` semi join ((/* select#4 */ select `test`.`t2`.`b` AS `b` from `test`.`t2` order by `test`.`t2`.`b` limit 2,2) `x`) set `test`.`t1`.`a` = 10 where (`x`.`b` = `test`.`t1`.`a`) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 5 +Handler_read_rnd_next 8 +Handler_write 1 +Sort_rows 3 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 5 +Handler_read_rnd_next 8 +Handler_write 1 +Sort_rows 3 +Sort_scan 1 + +DROP TABLE t1,t2; +#70 +CREATE TABLE t1 (c1 INT KEY); +CREATE TABLE t2 (c2 INT); +CREATE TABLE t3 (c3 INT); +EXPLAIN UPDATE t3 SET c3 = ( +SELECT COUNT(d1.c1) +FROM ( +SELECT a11.c1 FROM t1 AS a11 +STRAIGHT_JOIN t2 AS a21 ON a21.c2 = a11.c1 +JOIN t1 AS a12 ON a12.c1 = a11.c1 +) d1 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t3 NULL ALL NULL NULL NULL NULL 0 100.00 NULL +2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +3 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 update `test`.`t3` set `test`.`t3`.`c3` = (/* select#2 */ select count(NULL) from (/* select#3 */ select NULL AS `c1` from `test`.`t1` `a11` straight_join `test`.`t2` `a21` join `test`.`t1` `a12` where multiple equal(NULL, NULL, NULL)) `d1`) +DROP TABLE t1, t2, t3; +#71 +CREATE TABLE t1 (c1 INT NOT NULL, c2 INT NOT NULL, INDEX i1(c1)); +INSERT INTO t1 VALUES (1,0),(2,0),(3,0),(4,0),(5,0),(6,0),(7,0),(8,0); +CREATE TABLE t2 LIKE t1; +EXPLAIN INSERT INTO t2 SELECT * FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 INSERT t2 NULL ALL NULL NULL NULL NULL X NULL NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL X 100.00 NULL +Warnings: +Note 1003 insert into `test`.`t2` /* select#1 */ select `test`.`t1`.`c1` AS `c1`,`test`.`t1`.`c2` AS `c2` from `test`.`t1` +INSERT INTO t2 SELECT * FROM t1; +SELECT * FROM t1 LEFT JOIN t2 ON t1.c1 = t2.c1; +DROP TABLE t1, t2; +#73 +CREATE TABLE t1 (id INT); +CREATE TABLE t2 (id INT); +INSERT INTO t1 VALUES (1), (2); +EXPLAIN SELECT * FROM t1 LEFT JOIN t2 USING(id) GROUP BY t1.id; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL system NULL NULL NULL NULL 0 0.00 const row not found +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id` from `test`.`t1` where true group by `test`.`t1`.`id` +DROP TABLE t1,t2; +#74 +CREATE TABLE t1(a INT PRIMARY KEY) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1), (2), (3), (4), (5); +# used key is modified & Using temporary +# +# query: UPDATE t1 SET a=a+1 WHERE a>10 +# select: SELECT a t1 FROM t1 WHERE a>10 +# +EXPLAIN UPDATE t1 SET a=a+1 WHERE a>10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL range PRIMARY PRIMARY 4 const 1 100.00 Using where; Using temporary +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`a` = (`test`.`t1`.`a` + 1) where (`test`.`t1`.`a` > 10) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 2 + +# used key is modified & Using filesort +# +# query: UPDATE t1 SET a=a+1 WHERE a>10 ORDER BY a+20 +# select: SELECT a t1 FROM t1 WHERE a>10 ORDER BY a+20 +# +EXPLAIN UPDATE t1 SET a=a+1 WHERE a>10 ORDER BY a+20; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL range PRIMARY PRIMARY 4 const 1 100.00 Using where; Using filesort +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`a` = (`test`.`t1`.`a` + 1) where (`test`.`t1`.`a` > 10) order by (`test`.`t1`.`a` + 20) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 1 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 2 +Sort_scan 1 + +DROP TABLE t1; +# +# Bug #12949629: CLIENT LOSES CONNECTION AFTER EXECUTING A PROCEDURE WITH +# EXPLAIN UPDATE/DEL/INS +# +CREATE TABLE t1 (i INT); +CREATE TABLE t2 (i INT); +CREATE PROCEDURE p1() BEGIN EXPLAIN INSERT INTO t1 VALUES (1);END| +CREATE PROCEDURE p2() BEGIN INSERT INTO t1 VALUES (1);END| +CREATE PROCEDURE p3() BEGIN EXPLAIN INSERT INTO t1 SELECT 1;END| +CREATE PROCEDURE p4() BEGIN INSERT INTO t1 SELECT 1;END| +CREATE PROCEDURE p5() BEGIN EXPLAIN REPLACE INTO t1 VALUES (1);END| +CREATE PROCEDURE p6() BEGIN REPLACE INTO t1 VALUES (1);END| +CREATE PROCEDURE p7() BEGIN EXPLAIN REPLACE INTO t1 SELECT 1;END| +CREATE PROCEDURE p8() BEGIN REPLACE INTO t1 SELECT 1;END| +CREATE PROCEDURE p9() BEGIN EXPLAIN UPDATE t1 SET i = 10;END| +CREATE PROCEDURE p10() BEGIN UPDATE t1 SET i = 10;END| +CREATE PROCEDURE p11() BEGIN EXPLAIN UPDATE t1,t2 SET t1.i = 10 WHERE t1.i = t2.i ;END| +CREATE PROCEDURE p12() BEGIN UPDATE t1,t2 SET t1.i = 10 WHERE t1.i = t2.i ;END| +CREATE PROCEDURE p13() BEGIN +# Disabling binary logging temporarily as optimized delete is not used when log-bin is enabled in row mode +SET @save_log_bin= @@sql_log_bin;SET SQL_LOG_BIN=0; +EXPLAIN DELETE FROM t1; +SET SQL_LOG_BIN=@save_log_bin; END| +CREATE PROCEDURE p14() BEGIN DELETE FROM t1;END| +CREATE PROCEDURE p15() BEGIN EXPLAIN DELETE FROM t1 USING t1;END| +CREATE PROCEDURE p16() BEGIN DELETE FROM t1 USING t1;END| +CALL p16(); +DROP PROCEDURE p16; +CALL p15(); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 delete `test`.`t1` from `test`.`t1` +DROP PROCEDURE p15; +CALL p14(); +DROP PROCEDURE p14; +CALL p13(); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 0 100.00 Deleting all rows +DROP PROCEDURE p13; +CALL p12(); +DROP PROCEDURE p12; +CALL p11(); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 update `test`.`t1` join `test`.`t2` set `test`.`t1`.`i` = 10 where multiple equal(`test`.`t1`.`i`, `test`.`t2`.`i`) +DROP PROCEDURE p11; +CALL p10(); +DROP PROCEDURE p10; +CALL p9(); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 0 100.00 NULL +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`i` = 10 +DROP PROCEDURE p9; +CALL p8(); +DROP PROCEDURE p8; +CALL p7(); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 REPLACE t1 NULL ALL NULL NULL NULL NULL NULL NULL NULL +Warnings: +Note 1003 replace into `test`.`t1` /* select#1 */ select 1 AS `1` from dual +DROP PROCEDURE p7; +CALL p6(); +DROP PROCEDURE p6; +CALL p5(); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 REPLACE t1 NULL ALL NULL NULL NULL NULL NULL NULL NULL +Warnings: +Note 1003 replace into `test`.`t1` values (1) +DROP PROCEDURE p5; +CALL p4(); +DROP PROCEDURE p4; +CALL p3(); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 INSERT t1 NULL ALL NULL NULL NULL NULL NULL NULL NULL +Warnings: +Note 1003 insert into `test`.`t1` /* select#1 */ select 1 AS `1` from dual +DROP PROCEDURE p3; +CALL p2(); +DROP PROCEDURE p2; +CALL p1(); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 INSERT t1 NULL ALL NULL NULL NULL NULL NULL NULL NULL +Warnings: +Note 1003 insert into `test`.`t1` values (1) +DROP PROCEDURE p1; +DROP TABLE t1, t2; +# +set default_storage_engine= @save_storage_engine; +set optimizer_switch=default; diff --git a/mysql-test/r/myisam_explain_non_select_none.result-pq b/mysql-test/r/myisam_explain_non_select_none.result-pq new file mode 100644 index 000000000000..c1af85a2da50 --- /dev/null +++ b/mysql-test/r/myisam_explain_non_select_none.result-pq @@ -0,0 +1,2517 @@ +set @save_storage_engine= @@session.default_storage_engine; +set session default_storage_engine = MyISAM; +set end_markers_in_json=on; +#1 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +# +# query: UPDATE t1 SET a = 10 WHERE a < 10 +# select: SELECT * FROM t1 WHERE a < 10 +# +EXPLAIN UPDATE t1 SET a = 10 WHERE a < 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`a` = 10 where (`test`.`t1`.`a` < 10) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 1 +Handler_read_rnd_next 4 +# Status of testing query execution: +Variable_name Value +Handler_read_key 1 +Handler_read_rnd_next 4 +Handler_update 3 + +DROP TABLE t1; +#2 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +# +# query: DELETE FROM t1 WHERE a < 10 +# select: SELECT * FROM t1 WHERE a < 10 +# +EXPLAIN DELETE FROM t1 WHERE a < 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 delete from `test`.`t1` where (`test`.`t1`.`a` < 10) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 1 +Handler_read_rnd_next 4 +# Status of testing query execution: +Variable_name Value +Handler_delete 3 +Handler_read_key 1 +Handler_read_rnd_next 4 + +DROP TABLE t1; +#3 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +# +# query: DELETE FROM t1 USING t1 WHERE a = 1 +# select: SELECT * FROM t1 WHERE a = 1 +# +EXPLAIN DELETE FROM t1 USING t1 WHERE a = 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 delete `test`.`t1` from `test`.`t1` where (`test`.`t1`.`a` = 1) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 1 +Handler_read_rnd_next 4 +# Status of testing query execution: +Variable_name Value +Handler_delete 1 +Handler_read_key 1 +Handler_read_rnd_next 4 + +DROP TABLE t1; +#4 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +CREATE TABLE t2 (b INT); +INSERT INTO t2 VALUES (1), (2), (3); +# +# query: UPDATE t1, t2 SET t1.a = 10 WHERE t1.a = 1 +# select: SELECT * FROM t1, t2 WHERE t1.a = 1 +# +EXPLAIN UPDATE t1, t2 SET t1.a = 10 WHERE t1.a = 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 update `test`.`t1` join `test`.`t2` set `test`.`t1`.`a` = 10 where (`test`.`t1`.`a` = 1) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 8 +# Status of testing query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 8 +Handler_update 1 + +DROP TABLE t1, t2; +#5 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +CREATE TABLE t2 (b INT); +INSERT INTO t2 VALUES (1), (2), (3); +# +# query: UPDATE t1 t11, (SELECT * FROM t2) t12 SET t11.a = 10 WHERE t11.a = 1 +# select: SELECT * FROM t1 t11, (SELECT * FROM t2) t12 WHERE t11.a = 1 +# +EXPLAIN UPDATE t1 t11, (SELECT * FROM t2) t12 SET t11.a = 10 WHERE t11.a = 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t11 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 update `test`.`t1` `t11` join `test`.`t2` set `test`.`t11`.`a` = 10 where (`test`.`t11`.`a` = 1) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 8 +# Status of testing query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 8 +Handler_update 1 + +DROP TABLE t1, t2; +#6 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +CREATE TABLE t2 (b INT); +INSERT INTO t2 VALUES (1), (2), (3); +# +# query: UPDATE t1 SET a = 10 WHERE 1 IN (SELECT 1 FROM t2 WHERE t2.b < 3) +# select: SELECT * FROM t1 WHERE 1 IN (SELECT 1 FROM t2 WHERE t2.b < 3) +# +EXPLAIN UPDATE t1 SET a = 10 WHERE 1 IN (SELECT 1 FROM t2 WHERE t2.b < 3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 SUBQUERY t2 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`a` = 10 where (1,(/* select#2 */ select 1 from `test`.`t2` where (`test`.`t2`.`b` < 3))) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 5 +# Status of testing query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 5 +Handler_update 3 + +DROP TABLE t1, t2; +#7 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +CREATE TABLE t2 (b INT); +INSERT INTO t2 VALUES (1), (2), (3); +# +# query: UPDATE t1 SET a = 10 WHERE a IN (SELECT b FROM t2 WHERE t1.a < 3) +# select: SELECT * FROM t1 WHERE a IN (SELECT b FROM t2 WHERE t1.a < 3) +# +EXPLAIN UPDATE t1 SET a = 10 WHERE a IN (SELECT b FROM t2 WHERE t1.a < 3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 update `test`.`t1` set `test`.`t1`.`a` = 10 where (`test`.`t1`.`a`,(/* select#2 */ select `test`.`t2`.`b` from `test`.`t2` where ((`test`.`t1`.`a` < 3) and ((`test`.`t1`.`a`) = `test`.`t2`.`b`)))) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 11 +# Status of testing query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 11 +Handler_update 2 + +DROP TABLE t1, t2; +#7 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +CREATE TABLE t2 (b INT); +INSERT INTO t2 VALUES (1), (2), (3); +# +# query: UPDATE t1, t2 SET a = 10 WHERE a IN (SELECT b FROM t2 WHERE t2.b < 3) +# select: SELECT * FROM t1, t2 WHERE a IN (SELECT b FROM t2 WHERE t2.b < 3) +# +EXPLAIN UPDATE t1, t2 SET a = 10 WHERE a IN (SELECT b FROM t2 WHERE t2.b < 3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 update `test`.`t1` join `test`.`t2` set `test`.`t1`.`a` = 10 where (`test`.`t1`.`a`,(/* select#2 */ select `test`.`t2`.`b` from `test`.`t2` where ((`test`.`t2`.`b` < 3) and ((`test`.`t1`.`a`) = `test`.`t2`.`b`)))) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 15 +# Status of testing query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 19 +Handler_update 2 + +DROP TABLE t1, t2; +#8 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +CREATE TABLE t2 (b INT); +INSERT INTO t2 VALUES (1), (2), (3); +# +# query: UPDATE t1 t11, (SELECT * FROM t2) t12 SET t11.a = t11.a + 10 +# select: SELECT * FROM t1 t11, (SELECT * FROM t2) t12 +# +EXPLAIN UPDATE t1 t11, (SELECT * FROM t2) t12 SET t11.a = t11.a + 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t11 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 update `test`.`t1` `t11` join `test`.`t2` set `test`.`t11`.`a` = (`test`.`t11`.`a` + 10) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 8 +# Status of testing query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 16 +Handler_update 3 + +DROP TABLE t1, t2; +#9 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +CREATE TABLE t2 (b INT); +INSERT INTO t2 VALUES (1), (2), (3); +# +# query: UPDATE t1 t11, (SELECT 1 FROM DUAL) t12 SET t11.a = t11.a + 10 +# select: SELECT * FROM t1 t11, (SELECT 1 FROM DUAL) t12 +# +EXPLAIN UPDATE t1 t11, (SELECT 1 FROM DUAL) t12 SET t11.a = t11.a + 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL system NULL NULL NULL NULL 1 100.00 NULL +1 UPDATE t11 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 update `test`.`t1` `t11` join (/* select#2 */ select 1 AS `1`) `t12` set `test`.`t11`.`a` = (`test`.`t11`.`a` + 10) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 1 +Handler_read_rnd_next 5 +Handler_write 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 1 +Handler_read_rnd 3 +Handler_read_rnd_next 9 +Handler_update 3 +Handler_write 4 + +DROP TABLE t1, t2; +#10 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +CREATE TABLE t2 (b INT); +INSERT INTO t2 VALUES (1), (2), (3); +# +# query: UPDATE t1 t11, (SELECT * FROM t2) t12 SET t11.a = 10 WHERE t11.a > 1 +# select: SELECT * FROM t1 t11, (SELECT * FROM t2) t12 WHERE t11.a > 1 +# +EXPLAIN UPDATE t1 t11, (SELECT * FROM t2) t12 SET t11.a = 10 WHERE t11.a > 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t11 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 update `test`.`t1` `t11` join `test`.`t2` set `test`.`t11`.`a` = 10 where (`test`.`t11`.`a` > 1) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 8 +# Status of testing query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 12 +Handler_update 2 + +DROP TABLE t1, t2; +#11 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +# +# query: DELETE FROM t1 WHERE a > 1 LIMIT 1 +# select: SELECT * FROM t1 WHERE a > 1 LIMIT 1 +# +EXPLAIN DELETE FROM t1 WHERE a > 1 LIMIT 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 delete from `test`.`t1` where (`test`.`t1`.`a` > 1) limit 1 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 1 +Handler_read_rnd_next 2 +# Status of testing query execution: +Variable_name Value +Handler_delete 1 +Handler_read_key 1 +Handler_read_rnd_next 2 + +DROP TABLE t1; +#12 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +# +# query: DELETE FROM t1 WHERE 0 +# select: SELECT * FROM t1 WHERE 0 +# +EXPLAIN DELETE FROM t1 WHERE 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 delete from `test`.`t1` where false +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 1 + +DROP TABLE t1; +#13 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +# +# query: DELETE FROM t1 USING t1 WHERE 0 +# select: SELECT * FROM t1 WHERE 0 +# +EXPLAIN DELETE FROM t1 USING t1 WHERE 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 delete `test`.`t1` from `test`.`t1` where false +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 1 + +DROP TABLE t1; +#14 +CREATE TABLE t1 (a INT, b INT, UNIQUE KEY (a), KEY (b)); +INSERT INTO t1 VALUES (3, 3), (7, 7); +# +# query: DELETE FROM t1 WHERE a = 3 +# select: SELECT * FROM t1 WHERE a = 3 +# +EXPLAIN DELETE FROM t1 WHERE a = 3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL range a a 5 const 1 100.00 Using where +Warnings: +Note 1003 delete from `test`.`t1` where (`test`.`t1`.`a` = 3) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 3 +# Status of testing query execution: +Variable_name Value +Handler_delete 1 +Handler_read_key 3 + +DROP TABLE t1; +#15 +CREATE TABLE t1 (a INT, b INT, UNIQUE KEY (a), KEY (b)); +INSERT INTO t1 VALUES (3, 3), (7, 7); +# +# query: DELETE FROM t1 WHERE a < 3 +# select: SELECT * FROM t1 WHERE a < 3 +# +EXPLAIN DELETE FROM t1 WHERE a < 3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL range a a 5 const 1 100.00 Using where +Warnings: +Note 1003 delete from `test`.`t1` where (`test`.`t1`.`a` < 3) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 3 +# Status of testing query execution: +Variable_name Value +Handler_read_key 3 + +DROP TABLE t1; +#16 +CREATE TABLE t1 ( a int PRIMARY KEY ); +# +# query: DELETE FROM t1 WHERE t1.a > 0 ORDER BY t1.a +# select: SELECT * FROM t1 WHERE t1.a > 0 ORDER BY t1.a +# +EXPLAIN DELETE FROM t1 WHERE t1.a > 0 ORDER BY t1.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL range PRIMARY PRIMARY 4 const 1 100.00 Using where +Warnings: +Note 1003 delete from `test`.`t1` where (`test`.`t1`.`a` > 0) order by `test`.`t1`.`a` +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 1 +Handler_read_rnd_next 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 2 + +INSERT INTO t1 VALUES (1), (2), (3); +# +# query: DELETE FROM t1 WHERE t1.a > 0 ORDER BY t1.a +# select: SELECT * FROM t1 WHERE t1.a > 0 ORDER BY t1.a +# +EXPLAIN DELETE FROM t1 WHERE t1.a > 0 ORDER BY t1.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL range PRIMARY PRIMARY 4 const 3 100.00 Using where +Warnings: +Note 1003 delete from `test`.`t1` where (`test`.`t1`.`a` > 0) order by `test`.`t1`.`a` +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 1 +Handler_read_next 3 +# Status of testing query execution: +Variable_name Value +Handler_delete 3 +Handler_read_key 2 +Handler_read_next 3 + +DROP TABLE t1; +#17 +CREATE TABLE t1(a INT PRIMARY KEY); +INSERT INTO t1 VALUES (4),(3),(1),(2); +# +# query: DELETE FROM t1 WHERE (@a:= a) ORDER BY a LIMIT 1 +# select: SELECT * FROM t1 WHERE (@a:= a) ORDER BY a LIMIT 1 +# +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +EXPLAIN DELETE FROM t1 WHERE (@a:= a) ORDER BY a LIMIT 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL index NULL PRIMARY 4 NULL 4 100.00 Using where +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +Note 1003 delete from `test`.`t1` where (0 <> (@a:=`test`.`t1`.`a`)) order by `test`.`t1`.`a` limit 1 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 1 +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +# Status of testing query execution: +Variable_name Value +Handler_delete 1 +Handler_read_first 1 +Handler_read_key 1 + +DROP TABLE t1; +#18 +CREATE TABLE t1 (a DATE, b TIME, c INT, KEY c(c), KEY b(b), KEY a(a)); +INSERT INTO t1 VALUES (), (), (), (), (), (), (), (), (), (); +UPDATE t1 SET a = c, b = c; +# +# query: DELETE FROM t1 ORDER BY a ASC, b ASC LIMIT 1 +# select: SELECT * FROM t1 ORDER BY a ASC, b ASC LIMIT 1 +# +EXPLAIN DELETE FROM t1 ORDER BY a ASC, b ASC LIMIT 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 10 100.00 Using filesort +Warnings: +Note 1003 delete from `test`.`t1` order by `test`.`t1`.`a`,`test`.`t1`.`b` limit 1 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 3 +Handler_read_rnd_next 11 +Sort_rows 1 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_delete 1 +Handler_read_key 3 +Handler_read_rnd 1 +Handler_read_rnd_next 11 +Sort_rows 10 +Sort_scan 1 + +DROP TABLE t1; +#19 +CREATE TABLE t1 (a1 INT NOT NULL, b1 INT NOT NULL); +CREATE TABLE t2 (a2 INT NOT NULL, b2 INT NOT NULL, PRIMARY KEY (a2,b2)); +CREATE TABLE t3 (a3 INT NOT NULL, b3 INT NOT NULL, PRIMARY KEY (a3,b3)); +INSERT INTO t1 VALUES (1,1), (2,1), (1,3); +INSERT INTO t2 VALUES (1,1), (2,2), (3,3); +INSERT INTO t3 VALUES (1,1), (2,1), (1,3); +# +# query: DELETE t1,t2,t3 FROM t1,t2,t3 WHERE a1=a2 AND b2=a3 AND b1=b3 +# select: SELECT * FROM t1,t2,t3 WHERE a1=a2 AND b2=a3 AND b1=b3 +# +EXPLAIN DELETE t1,t2,t3 FROM t1,t2,t3 WHERE a1=a2 AND b2=a3 AND b1=b3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 DELETE t2 NULL ref PRIMARY PRIMARY 4 test.t1.a1 1 100.00 NULL +1 DELETE t3 NULL eq_ref PRIMARY PRIMARY 8 test.t2.b2,test.t1.b1 1 100.00 NULL +Warnings: +Note 1003 delete `test`.`t1`, `test`.`t2`, `test`.`t3` from `test`.`t1` join `test`.`t2` join `test`.`t3` where ((`test`.`t3`.`b3` = `test`.`t1`.`b1`) and (`test`.`t3`.`a3` = `test`.`t2`.`b2`) and (`test`.`t2`.`a2` = `test`.`t1`.`a1`)) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 12 +Handler_read_next 3 +Handler_read_rnd_next 4 +# Status of testing query execution: +Variable_name Value +Handler_delete 8 +Handler_read_key 12 +Handler_read_next 3 +Handler_read_rnd 5 +Handler_read_rnd_next 4 + +DROP TABLE t1, t2, t3; +#20 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +CREATE TABLE t2 (a INT); +INSERT INTO t2 VALUES (1), (2), (3); +# +# query: UPDATE t1 SET a = 10 WHERE a IN (SELECT a FROM t2) +# select: SELECT * FROM t1 WHERE a IN (SELECT a FROM t2) +# +EXPLAIN UPDATE t1 SET a = 10 WHERE a IN (SELECT a FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`a` = 10 where (`test`.`t1`.`a`,(/* select#2 */ select `test`.`t2`.`a` from `test`.`t2` where ((`test`.`t1`.`a`) = `test`.`t2`.`a`))) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 10 +# Status of testing query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 10 +Handler_update 3 + +DROP TABLE t1, t2; +#21 +CREATE TABLE t1 (a1 INT); +INSERT INTO t1 VALUES (1), (2), (3), (4), (5); +CREATE TABLE t2 (a2 VARCHAR(10)) charset utf8mb4; +INSERT INTO t2 VALUES (1), (2), (3), (4), (5); +SET @save_optimizer_switch= @@optimizer_switch; +# +# query: DELETE FROM t1 WHERE a1 IN (SELECT a2 FROM t2 WHERE a2 > 2) +# select: SELECT * FROM t1 WHERE a1 IN (SELECT a2 FROM t2 WHERE a2 > 2) +# +EXPLAIN DELETE FROM t1 WHERE a1 IN (SELECT a2 FROM t2 WHERE a2 > 2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 5 100.00 Using where +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 5 20.00 Using where +Warnings: +Note 1003 delete from `test`.`t1` where (`test`.`t1`.`a1`,(/* select#2 */ select `test`.`t2`.`a2` from `test`.`t2` where ((`test`.`t2`.`a2` > 2) and ((`test`.`t1`.`a1`) = `test`.`t2`.`a2`)))) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 30 +# Status of testing query execution: +Variable_name Value +Handler_delete 3 +Handler_read_key 2 +Handler_read_rnd_next 30 + +SET @@optimizer_switch= @save_optimizer_switch; +TRUNCATE t1; +INSERT INTO t1 VALUES (1), (2), (3), (4), (5); +# +# query: DELETE FROM t1 WHERE a1 IN (SELECT a2 FROM t2 WHERE a2 > 2) +# select: SELECT * FROM t1 WHERE a1 IN (SELECT a2 FROM t2 WHERE a2 > 2) +# +EXPLAIN DELETE FROM t1 WHERE a1 IN (SELECT a2 FROM t2 WHERE a2 > 2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 5 100.00 Using where +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 5 20.00 Using where +Warnings: +Note 1003 delete from `test`.`t1` where (`test`.`t1`.`a1`,(/* select#2 */ select `test`.`t2`.`a2` from `test`.`t2` where ((`test`.`t2`.`a2` > 2) and ((`test`.`t1`.`a1`) = `test`.`t2`.`a2`)))) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 30 +# Status of testing query execution: +Variable_name Value +Handler_delete 3 +Handler_read_key 2 +Handler_read_rnd_next 30 + +DROP TABLE t1, t2; +#22 +CREATE TABLE t1 (i INT, j INT); +INSERT INTO t1 VALUES (1, 1), (2, 2), (3, 3), (4, 4), (5, 5); +# +# query: UPDATE t1 SET i = 10 +# select: SELECT * FROM t1 +# +EXPLAIN UPDATE t1 SET i = 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`i` = 10 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 6 +# Status of testing query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 6 +Handler_update 5 + +DROP TABLE t1; +#23 +CREATE TABLE t1 (i INT, j INT); +INSERT INTO t1 VALUES (1, 1), (2, 2), (3, 3), (4, 4), (5, 5); +# +# query: DELETE FROM t1 +# select: SELECT * FROM t1 +# +EXPLAIN DELETE FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 5 100.00 Deleting all rows +Warnings: +Note 1003 delete from `test`.`t1` +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 6 +# Status of testing query execution: +Variable_name Value +Handler_read_key 2 + +DROP TABLE t1; +#24 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2(a INT, b INT, c INT, d INT, INDEX(a, b, c)); +INSERT INTO t2 (a, b, c) SELECT i, i, i FROM t1; +INSERT INTO t2 (a, b, c) SELECT t1.i, t1.i, t1.i FROM t1, t1 x1, t1 x2; +# +# query: DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# select: SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# +EXPLAIN DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t2 NULL index NULL a 15 NULL 17602 100.00 Using where +Warnings: +Note 1003 delete from `test`.`t2` where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 4 +Handler_read_next 4 +# Status of testing query execution: +Variable_name Value +Handler_delete 5 +Handler_read_first 1 +Handler_read_key 4 +Handler_read_next 4 + +DROP TABLE t1, t2; +#25 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (1), (2), (3); +CREATE TABLE t2 (i INT); +# +# query: INSERT INTO t2 SELECT * FROM t1 +# select: SELECT * FROM t1 +# +EXPLAIN INSERT INTO t2 SELECT * FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 INSERT t2 NULL ALL NULL NULL NULL NULL NULL NULL NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 insert into `test`.`t2` /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 1 +Handler_read_rnd_next 4 +# Status of testing query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 4 +Handler_write 3 + +# +# query: INSERT INTO t2 SELECT * FROM t1 JOIN t1 AS tt USING(i) +# select: SELECT * FROM t1 JOIN t1 AS tt USING(i) +# +EXPLAIN INSERT INTO t2 SELECT * FROM t1 JOIN t1 AS tt USING(i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 INSERT t2 NULL ALL NULL NULL NULL NULL NULL NULL NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE tt NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +Warnings: +Note 1003 insert into `test`.`t2` /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` join `test`.`t1` `tt` where (`test`.`tt`.`i` = `test`.`t1`.`i`) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 1 +Handler_read_rnd_next 8 +# Status of testing query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 8 +Handler_write 3 + +DROP TABLE t1, t2; +#26 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (1), (2), (3); +CREATE TABLE t2 (i INT); +# +# query: REPLACE INTO t2 SELECT * FROM t1 +# select: SELECT * FROM t1 +# +EXPLAIN REPLACE INTO t2 SELECT * FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 REPLACE t2 NULL ALL NULL NULL NULL NULL NULL NULL NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 replace into `test`.`t2` /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 1 +Handler_read_rnd_next 4 +# Status of testing query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 4 +Handler_write 3 + +DROP TABLE t1, t2; +#27 +CREATE TABLE t1 (i INT); +# +# query: INSERT INTO t1 SET i = 10 +# select: +# +EXPLAIN INSERT INTO t1 SET i = 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 INSERT t1 NULL ALL NULL NULL NULL NULL NULL NULL NULL +Warnings: +Note 1003 insert into `test`.`t1` (`test`.`t1`.`i`) values (10) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# Status of testing query execution: +Variable_name Value +Handler_read_key 1 +Handler_write 1 + +DROP TABLE t1; +#28 +CREATE TABLE t1 (i INT); +# +# query: REPLACE INTO t1 SET i = 10 +# select: +# +EXPLAIN REPLACE INTO t1 SET i = 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 REPLACE t1 NULL ALL NULL NULL NULL NULL NULL NULL NULL +Warnings: +Note 1003 replace into `test`.`t1` (`test`.`t1`.`i`) values (10) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# Status of testing query execution: +Variable_name Value +Handler_read_key 1 +Handler_write 1 + +DROP TABLE t1; +#29 +CREATE TABLE t1 (a INT, i INT PRIMARY KEY); +INSERT INTO t1 (i) VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +# +# query: DELETE FROM t1 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 1 +# select: SELECT * FROM t1 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 1 +# +EXPLAIN DELETE FROM t1 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL range PRIMARY PRIMARY 4 const 8 100.00 Using where +Warnings: +Note 1003 delete from `test`.`t1` where ((`test`.`t1`.`i` > 10) and (`test`.`t1`.`i` <= 18)) order by `test`.`t1`.`i` limit 1 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 3 +# Status of testing query execution: +Variable_name Value +Handler_delete 1 +Handler_read_key 3 + +DROP TABLE t1; +#30 +CREATE TABLE t1(a INT, i CHAR(2), INDEX(i(1))) charset utf8mb4; +INSERT INTO t1 (i) VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +# +# query: DELETE FROM t1 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 5 +# select: SELECT * FROM t1 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 5 +# +EXPLAIN DELETE FROM t1 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 26 100.00 Using where; Using filesort +Warnings: +Warning 1739 Cannot use range access on index 'i' due to type or collation conversion on field 'i' +Warning 1739 Cannot use range access on index 'i' due to type or collation conversion on field 'i' +Note 1003 delete from `test`.`t1` where ((`test`.`t1`.`i` > 10) and (`test`.`t1`.`i` <= 18)) order by `test`.`t1`.`i` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 27 +Sort_rows 5 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_delete 5 +Handler_read_key 2 +Handler_read_rnd 5 +Handler_read_rnd_next 27 +Sort_rows 8 +Sort_scan 1 + +DROP TABLE t1; +#31 +CREATE TABLE t1 (i INT); +INSERT INTO t1 (i) VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2(a INT, b INT, c INT, d INT, INDEX(a, b, c)); +INSERT INTO t2 (a, b, c) SELECT i, i, i FROM t1; +# +# query: DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# select: SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# +EXPLAIN DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t2 NULL ALL NULL NULL NULL NULL 26 100.00 Using where; Using filesort +Warnings: +Note 1003 delete from `test`.`t2` where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 4 +Handler_read_next 26 +# Status of testing query execution: +Variable_name Value +Handler_delete 1 +Handler_read_key 4 +Handler_read_rnd 1 +Handler_read_rnd_next 27 +Sort_rows 1 +Sort_scan 1 + +DROP TABLE t1, t2; +#32 +CREATE TABLE t1 (i INT); +INSERT INTO t1 (i) VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2(a INT, b INT, c INT, d INT, INDEX(a, b, c)); +INSERT INTO t2 (a, b, c) SELECT i, i, i FROM t1; +INSERT INTO t2 (a, b, c) SELECT t1.i, t1.i, t1.i FROM t1, t1 x1, t1 x2; +# +# query: DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# select: SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# +EXPLAIN DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t2 NULL index NULL a 15 NULL 17602 100.00 Using where +Warnings: +Note 1003 delete from `test`.`t2` where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 4 +Handler_read_next 4 +# Status of testing query execution: +Variable_name Value +Handler_delete 5 +Handler_read_first 1 +Handler_read_key 4 +Handler_read_next 4 + +DROP TABLE t1, t2; +#33 +CREATE TABLE t1 (i INT); +INSERT INTO t1 (i) VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2 (a CHAR(2), b CHAR(2), c CHAR(2), d CHAR(2), INDEX (a,b(1),c)) +charset utf8mb4; +INSERT INTO t2 SELECT i, i, i, i FROM t1; +# +# query: DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# select: SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# +EXPLAIN DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t2 NULL ALL NULL NULL NULL NULL 26 100.00 Using where; Using filesort +Warnings: +Warning 1739 Cannot use range access on index 'a' due to type or collation conversion on field 'b' +Note 1003 delete from `test`.`t2` where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 4 +Handler_read_rnd_next 27 +Sort_rows 1 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_delete 1 +Handler_read_key 4 +Handler_read_rnd 1 +Handler_read_rnd_next 27 +Sort_rows 1 +Sort_scan 1 + +DROP TABLE t1, t2; +#34 +CREATE TABLE t1 (i INT); +INSERT INTO t1 (i) VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2 (a CHAR(2), b CHAR(2), c CHAR(2), d CHAR(2), INDEX (a,b,c)) +charset utf8mb4 ENGINE=HEAP; +INSERT INTO t2 SELECT i, i, i, i FROM t1; +# +# query: DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# select: SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# +EXPLAIN DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t2 NULL ALL NULL NULL NULL NULL 26 100.00 Using where; Using filesort +Warnings: +Warning 1739 Cannot use range access on index 'a' due to type or collation conversion on field 'b' +Note 1003 delete from `test`.`t2` where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 4 +Handler_read_rnd_next 27 +Sort_rows 1 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_delete 1 +Handler_read_key 4 +Handler_read_rnd 1 +Handler_read_rnd_next 27 +Sort_rows 1 +Sort_scan 1 + +DROP TABLE t1, t2; +#35 +CREATE TABLE t1 (i INT); +INSERT INTO t1 (i) VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35),(36),(37),(38),(39), +(40),(41),(42),(43),(44); +CREATE TABLE t2 (i INT, key1 INT, key2 INT, INDEX (key1), INDEX (key2)); +INSERT INTO t2 (key1, key2) SELECT i, i FROM t1; +# +# query: DELETE FROM t2 WHERE key1 < 13 or key2 < 14 ORDER BY key1 +# select: SELECT * FROM t2 WHERE key1 < 13 or key2 < 14 ORDER BY key1 +# +EXPLAIN DELETE FROM t2 WHERE key1 < 13 or key2 < 14 ORDER BY key1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t2 NULL index_merge key1,key2 key1,key2 5,5 NULL 7 100.00 Using sort_union(key1,key2); Using where; Using filesort +Warnings: +Note 1003 delete from `test`.`t2` where ((`test`.`t2`.`key1` < 13) or (`test`.`t2`.`key2` < 14)) order by `test`.`t2`.`key1` +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 5 +Handler_read_next 7 +Handler_read_rnd 4 +Sort_rows 4 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_delete 4 +Handler_read_key 5 +Handler_read_next 7 +Handler_read_rnd 8 +Sort_rows 4 +Sort_scan 1 + +DROP TABLE t1, t2; +#36 +CREATE TABLE t1 (i INT); +INSERT INTO t1 (i) VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2(a INT, i INT PRIMARY KEY); +INSERT INTO t2 (i) SELECT i FROM t1; +# +# query: DELETE FROM t2 WHERE i > 10 AND i <= 18 ORDER BY i DESC LIMIT 1 +# select: SELECT * FROM t2 WHERE i > 10 AND i <= 18 ORDER BY i DESC LIMIT 1 +# +EXPLAIN DELETE FROM t2 WHERE i > 10 AND i <= 18 ORDER BY i DESC LIMIT 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t2 NULL range PRIMARY PRIMARY 4 const 8 100.00 Using where; Backward index scan +Warnings: +Note 1003 delete from `test`.`t2` where ((`test`.`t2`.`i` > 10) and (`test`.`t2`.`i` <= 18)) order by `test`.`t2`.`i` desc limit 1 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 3 +# Status of testing query execution: +Variable_name Value +Handler_delete 1 +Handler_read_key 3 + +DROP TABLE t1, t2; +#37 +CREATE TABLE t1 (i INT); +INSERT INTO t1 (i) VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2 (a CHAR(2), b CHAR(2), c CHAR(2), INDEX (a, b)) charset utf8mb4; +INSERT INTO t2 SELECT i, i, i FROM t1; +# +# query: DELETE FROM t2 ORDER BY a, b DESC LIMIT 5 +# select: SELECT * FROM t2 ORDER BY a, b DESC LIMIT 5 +# +EXPLAIN DELETE FROM t2 ORDER BY a, b DESC LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t2 NULL ALL NULL NULL NULL NULL 26 100.00 Using filesort +Warnings: +Note 1003 delete from `test`.`t2` order by `test`.`t2`.`a`,`test`.`t2`.`b` desc limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 3 +Handler_read_rnd_next 27 +Sort_rows 5 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_delete 5 +Handler_read_key 3 +Handler_read_rnd 5 +Handler_read_rnd_next 27 +Sort_rows 26 +Sort_scan 1 + +DROP TABLE t1, t2; +#38 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2 (a CHAR(2), b CHAR(2), c INT, INDEX (a, b)) charset utf8mb4; +INSERT INTO t2 (a, b) SELECT i, i FROM t1; +INSERT INTO t2 (a, b) SELECT t1.i, t1.i FROM t1, t1 x1, t1 x2; +# +# query: DELETE FROM t2 ORDER BY a DESC, b DESC LIMIT 5 +# select: SELECT * FROM t2 ORDER BY a DESC, b DESC LIMIT 5 +# +EXPLAIN DELETE FROM t2 ORDER BY a DESC, b DESC LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t2 NULL index NULL a 18 NULL 5 100.00 NULL +Warnings: +Note 1003 delete from `test`.`t2` order by `test`.`t2`.`a` desc,`test`.`t2`.`b` desc limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 3 +Handler_read_last 1 +Handler_read_prev 4 +# Status of testing query execution: +Variable_name Value +Handler_delete 5 +Handler_read_key 3 +Handler_read_last 1 +Handler_read_prev 4 + +DROP TABLE t1, t2; +#39 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2(a INT, i INT PRIMARY KEY); +INSERT INTO t2 (i) SELECT i FROM t1; +# +# query: UPDATE t2 SET a = 10 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 1 +# select: SELECT * FROM t2 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 1 +# +EXPLAIN UPDATE t2 SET a = 10 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t2 NULL range PRIMARY PRIMARY 4 const 8 100.00 Using where; Using temporary +Warnings: +Note 1003 update `test`.`t2` set `test`.`t2`.`a` = 10 where ((`test`.`t2`.`i` > 10) and (`test`.`t2`.`i` <= 18)) order by `test`.`t2`.`i` limit 1 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 3 +# Status of testing query execution: +Variable_name Value +Handler_read_key 3 +Handler_read_rnd 1 +Handler_update 1 + +DROP TABLE t1, t2; +#40 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2(a INT, i CHAR(2), INDEX(i(1))) charset utf8mb4; +INSERT INTO t2 (i) SELECT i FROM t1; +# +# query: UPDATE t2 SET a = 10 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 5 +# select: SELECT * FROM t2 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 5 +# +EXPLAIN UPDATE t2 SET a = 10 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t2 NULL ALL NULL NULL NULL NULL 26 100.00 Using where; Using filesort +Warnings: +Warning 1739 Cannot use range access on index 'i' due to type or collation conversion on field 'i' +Warning 1739 Cannot use range access on index 'i' due to type or collation conversion on field 'i' +Note 1003 update `test`.`t2` set `test`.`t2`.`a` = 10 where ((`test`.`t2`.`i` > 10) and (`test`.`t2`.`i` <= 18)) order by `test`.`t2`.`i` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 27 +Sort_rows 5 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd 5 +Handler_read_rnd_next 27 +Handler_update 5 +Sort_rows 5 +Sort_scan 1 + +DROP TABLE t1, t2; +#41 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2(a INT, b INT, c INT, d INT, INDEX(a, b, c)); +INSERT INTO t2 (a, b, c) SELECT i, i, i FROM t1; +# +# query: UPDATE t2 SET d = 10 WHERE b = 10 ORDER BY a, c LIMIT 5 +# select: SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# +EXPLAIN UPDATE t2 SET d = 10 WHERE b = 10 ORDER BY a, c LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t2 NULL ALL NULL NULL NULL NULL 26 100.00 Using where; Using filesort +Warnings: +Note 1003 update `test`.`t2` set `test`.`t2`.`d` = 10 where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 4 +Handler_read_next 26 +# Status of testing query execution: +Variable_name Value +Handler_read_key 4 +Handler_read_rnd 1 +Handler_read_rnd_next 27 +Handler_update 1 +Sort_rows 1 +Sort_scan 1 + +DROP TABLE t1, t2; +#42 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2(a INT, b INT, c INT, d INT, INDEX(a, b, c)); +INSERT INTO t2 (a, b, c) SELECT i, i, i FROM t1; +INSERT INTO t2 (a, b, c) SELECT t1.i, t1.i, t1.i FROM t1, t1 x1, t1 x2; +# +# query: UPDATE t2 SET d = 10 WHERE b = 10 ORDER BY a, c LIMIT 5 +# select: SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# +EXPLAIN UPDATE t2 SET d = 10 WHERE b = 10 ORDER BY a, c LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t2 NULL index NULL a 15 NULL 17602 100.00 Using where; Using temporary +Warnings: +Note 1003 update `test`.`t2` set `test`.`t2`.`d` = 10 where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 4 +Handler_read_next 4 +# Status of testing query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 4 +Handler_read_next 4 +Handler_read_rnd 5 +Handler_update 5 + +DROP TABLE t1, t2; +#43 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2 (a CHAR(2), b CHAR(2), c CHAR(2), d CHAR(2), INDEX (a,b(1),c)) +charset utf8mb4; +INSERT INTO t2 SELECT i, i, i, i FROM t1; +# +# query: UPDATE t2 SET d = 10 WHERE b = 10 ORDER BY a, c LIMIT 5 +# select: SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# +EXPLAIN UPDATE t2 SET d = 10 WHERE b = 10 ORDER BY a, c LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t2 NULL ALL NULL NULL NULL NULL 26 100.00 Using where; Using filesort +Warnings: +Warning 1739 Cannot use range access on index 'a' due to type or collation conversion on field 'b' +Note 1003 update `test`.`t2` set `test`.`t2`.`d` = 10 where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 4 +Handler_read_rnd_next 27 +Sort_rows 1 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 4 +Handler_read_rnd 1 +Handler_read_rnd_next 27 +Sort_rows 1 +Sort_scan 1 + +DROP TABLE t1, t2; +#44 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2 (a CHAR(2), b CHAR(2), c CHAR(2), d CHAR(2), INDEX (a,b,c)) +charset utf8mb4 ENGINE=HEAP; +INSERT INTO t2 SELECT i, i, i, i FROM t1; +# +# query: UPDATE t2 SET d = 10 WHERE b = 10 ORDER BY a, c LIMIT 5 +# select: SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# +EXPLAIN UPDATE t2 SET d = 10 WHERE b = 10 ORDER BY a, c LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t2 NULL ALL NULL NULL NULL NULL 26 100.00 Using where; Using filesort +Warnings: +Warning 1739 Cannot use range access on index 'a' due to type or collation conversion on field 'b' +Note 1003 update `test`.`t2` set `test`.`t2`.`d` = 10 where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 4 +Handler_read_rnd_next 27 +Sort_rows 1 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 4 +Handler_read_rnd 1 +Handler_read_rnd_next 27 +Sort_rows 1 +Sort_scan 1 + +DROP TABLE t1, t2; +#45 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35),(36),(37),(38),(39), +(40),(41),(42),(43),(44); +CREATE TABLE t2 (i INT, key1 INT, key2 INT, INDEX (key1), INDEX (key2)); +INSERT INTO t2 (key1, key2) SELECT i, i FROM t1; +# +# query: UPDATE t2 SET i = 123 WHERE key1 < 13 or key2 < 14 ORDER BY key1 +# select: SELECT * FROM t2 WHERE key1 < 13 or key2 < 14 ORDER BY key1 +# +EXPLAIN UPDATE t2 SET i = 123 WHERE key1 < 13 or key2 < 14 ORDER BY key1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t2 NULL index_merge key1,key2 key1,key2 5,5 NULL 7 100.00 Using sort_union(key1,key2); Using where; Using filesort +Warnings: +Note 1003 update `test`.`t2` set `test`.`t2`.`i` = 123 where ((`test`.`t2`.`key1` < 13) or (`test`.`t2`.`key2` < 14)) order by `test`.`t2`.`key1` +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 5 +Handler_read_next 7 +Handler_read_rnd 4 +Sort_rows 4 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 5 +Handler_read_next 7 +Handler_read_rnd 8 +Handler_update 4 +Sort_rows 4 +Sort_scan 1 + +DROP TABLE t1, t2; +#46 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2(a INT, i INT PRIMARY KEY); +INSERT INTO t2 (i) SELECT i FROM t1; +# +# query: UPDATE t2 SET a = 10 WHERE i > 10 AND i <= 18 ORDER BY i DESC LIMIT 1 +# select: SELECT * FROM t2 WHERE i > 10 AND i <= 18 ORDER BY i DESC LIMIT 1 +# +EXPLAIN UPDATE t2 SET a = 10 WHERE i > 10 AND i <= 18 ORDER BY i DESC LIMIT 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t2 NULL range PRIMARY PRIMARY 4 const 8 100.00 Using where; Backward index scan; Using temporary +Warnings: +Note 1003 update `test`.`t2` set `test`.`t2`.`a` = 10 where ((`test`.`t2`.`i` > 10) and (`test`.`t2`.`i` <= 18)) order by `test`.`t2`.`i` desc limit 1 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 3 +# Status of testing query execution: +Variable_name Value +Handler_read_key 3 +Handler_read_rnd 1 +Handler_update 1 + +DROP TABLE t1, t2; +#47 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2 (a CHAR(2), b CHAR(2), c CHAR(2), INDEX (a, b)) charset utf8mb4; +INSERT INTO t2 SELECT i, i, i FROM t1; +# +# query: UPDATE t2 SET c = 10 ORDER BY a, b DESC LIMIT 5 +# select: SELECT * FROM t2 ORDER BY a, b DESC LIMIT 5 +# +EXPLAIN UPDATE t2 SET c = 10 ORDER BY a, b DESC LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t2 NULL ALL NULL NULL NULL NULL 26 100.00 Using filesort +Warnings: +Note 1003 update `test`.`t2` set `test`.`t2`.`c` = 10 order by `test`.`t2`.`a`,`test`.`t2`.`b` desc limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 3 +Handler_read_rnd_next 27 +Sort_rows 5 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 3 +Handler_read_rnd 5 +Handler_read_rnd_next 27 +Handler_update 4 +Sort_rows 5 +Sort_scan 1 + +DROP TABLE t1, t2; +#48 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2 (a CHAR(2), b CHAR(2), c INT, INDEX (a, b)) charset utf8mb4; +INSERT INTO t2 (a, b) SELECT i, i FROM t1; +INSERT INTO t2 (a, b) SELECT t1.i, t1.i FROM t1, t1 x1, t1 x2; +# +# query: UPDATE t2 SET c = 10 ORDER BY a DESC, b DESC LIMIT 5 +# select: SELECT * FROM t2 ORDER BY a DESC, b DESC LIMIT 5 +# +EXPLAIN UPDATE t2 SET c = 10 ORDER BY a DESC, b DESC LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t2 NULL index NULL a 18 NULL 5 100.00 Using temporary +Warnings: +Note 1003 update `test`.`t2` set `test`.`t2`.`c` = 10 order by `test`.`t2`.`a` desc,`test`.`t2`.`b` desc limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 3 +Handler_read_last 1 +Handler_read_prev 4 +# Status of testing query execution: +Variable_name Value +Handler_read_key 3 +Handler_read_last 1 +Handler_read_prev 4 +Handler_read_rnd 5 +Handler_update 5 + +DROP TABLE t1, t2; +#49 +CREATE TABLE t1 ( +pk INT NOT NULL AUTO_INCREMENT, +c1_idx CHAR(1) DEFAULT 'y', +c2 INT, +PRIMARY KEY (pk), +INDEX c1_idx (c1_idx) +) charset utf8mb4; +INSERT INTO t1 VALUES (1,'y',1), (2,'n',2), (3,'y',3), (4,'n',4); +# +# query: UPDATE t1 SET c2 = 0 WHERE c1_idx = 'y' ORDER BY pk DESC LIMIT 2 +# select: SELECT * FROM t1 WHERE c1_idx = 'y' ORDER BY pk DESC LIMIT 2 +# +EXPLAIN UPDATE t1 SET c2 = 0 WHERE c1_idx = 'y' ORDER BY pk DESC LIMIT 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL range c1_idx c1_idx 5 const 2 100.00 Using where; Using filesort +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`c2` = 0 where (`test`.`t1`.`c1_idx` = 'y') order by `test`.`t1`.`pk` desc limit 2 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 4 +Handler_read_next 2 +Sort_rows 2 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 4 +Handler_read_next 2 +Handler_read_rnd 2 +Handler_update 2 +Sort_rows 2 +Sort_scan 1 + +# +# query: DELETE FROM t1 WHERE c1_idx = 'y' ORDER BY pk DESC LIMIT 2 +# select: SELECT * FROM t1 WHERE c1_idx = 'y' ORDER BY pk DESC LIMIT 2 +# +EXPLAIN DELETE FROM t1 WHERE c1_idx = 'y' ORDER BY pk DESC LIMIT 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL range c1_idx c1_idx 5 const 2 100.00 Using where; Using filesort +Warnings: +Note 1003 delete from `test`.`t1` where (`test`.`t1`.`c1_idx` = 'y') order by `test`.`t1`.`pk` desc limit 2 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 4 +Handler_read_next 2 +Sort_rows 2 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_delete 2 +Handler_read_key 4 +Handler_read_next 2 +Handler_read_rnd 2 +Sort_rows 2 +Sort_scan 1 + +DROP TABLE t1; +#50 +CREATE TABLE t1 (a INT AUTO_INCREMENT PRIMARY KEY); +INSERT INTO t1 VALUES (),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(); +# +# query: UPDATE t1 SET a=a+10 WHERE a > 34 +# select: SELECT * FROM t1 WHERE a > 34 +# +EXPLAIN UPDATE t1 SET a=a+10 WHERE a > 34; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL range PRIMARY PRIMARY 4 const 3 100.00 Using where; Using temporary +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`a` = (`test`.`t1`.`a` + 10) where (`test`.`t1`.`a` > 34) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_next 2 +# Status of testing query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_next 2 +Handler_read_rnd 2 +Handler_update 2 + +DROP TABLE t1; +#51 +CREATE TABLE t1 (c1 INT, c2 INT, c3 INT); +CREATE TABLE t2 (c1 INT, c2 INT); +INSERT INTO t1 VALUES (1, 1, 10), (2, 2, 20); +# +# query: UPDATE t1 LEFT JOIN t2 ON t1.c1 = t2.c1 SET t2.c2 = 10 +# select: SELECT * FROM t1 LEFT JOIN t2 ON t1.c1 = t2.c1 +# +EXPLAIN UPDATE t1 LEFT JOIN t2 ON t1.c1 = t2.c1 SET t2.c2 = 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t2 NULL system NULL NULL NULL NULL 0 0.00 const row not found +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 update `test`.`t1` left join `test`.`t2` on(multiple equal(`test`.`t1`.`c1`, `test`.`t2`.`c1`)) set `test`.`t2`.`c2` = 10 where true +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 5 +Handler_read_rnd_next 4 +# Status of testing query execution: +Variable_name Value +Handler_read_key 5 +Handler_read_rnd_next 4 + +# +# query: UPDATE t1 LEFT JOIN t2 ON t1.c1 = t2.c1 SET t2.c2 = 10 WHERE t1.c3 = 10 +# select: SELECT * FROM t1 LEFT JOIN t2 ON t1.c1 = t2.c1 WHERE t1.c3 = 10 +# +EXPLAIN UPDATE t1 LEFT JOIN t2 ON t1.c1 = t2.c1 SET t2.c2 = 10 WHERE t1.c3 = 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t2 NULL system NULL NULL NULL NULL 0 0.00 const row not found +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1003 update `test`.`t1` left join `test`.`t2` on(multiple equal(`test`.`t1`.`c1`, `test`.`t2`.`c1`)) set `test`.`t2`.`c2` = 10 where (`test`.`t1`.`c3` = 10) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 5 +Handler_read_rnd_next 4 +# Status of testing query execution: +Variable_name Value +Handler_read_key 5 +Handler_read_rnd_next 4 + +DROP TABLE t1, t2; +#52 +CREATE TABLE t1(f1 INT, f2 INT); +CREATE TABLE t2(f3 INT, f4 INT); +CREATE INDEX IDX ON t2(f3); +INSERT INTO t1 VALUES(1,0),(2,0); +INSERT INTO t2 VALUES(1,1),(2,2); +# +# query: UPDATE t1 SET t1.f2=(SELECT MAX(t2.f4) FROM t2 WHERE t2.f3=t1.f1) +# select: SELECT (SELECT MAX(t2.f4) FROM t2 WHERE t2.f3=t1.f1) FROM t1 +# +EXPLAIN UPDATE t1 SET t1.f2=(SELECT MAX(t2.f4) FROM t2 WHERE t2.f3=t1.f1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DEPENDENT SUBQUERY t2 NULL ref IDX IDX 5 test.t1.f1 1 100.00 NULL +Warnings: +Note 1276 Field or reference 'test.t1.f1' of SELECT #2 was resolved in SELECT #1 +Note 1003 update `test`.`t1` set `test`.`t1`.`f2` = (/* select#2 */ select max(`test`.`t2`.`f4`) from `test`.`t2` where (`test`.`t2`.`f3` = `test`.`t1`.`f1`)) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 6 +Handler_read_next 2 +Handler_read_rnd_next 3 +# Status of testing query execution: +Variable_name Value +Handler_read_key 6 +Handler_read_next 2 +Handler_read_rnd_next 3 +Handler_update 2 + +DROP TABLE t1, t2; +#55 +CREATE TABLE t1(a INT); +INSERT INTO t1 VALUES (1); +SET @a = NULL; +EXPLAIN DELETE FROM t1 WHERE (@a:= a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +Note 1003 delete from `test`.`t1` where (0 <> (@a:=`test`.`t1`.`a`)) +DROP TABLE t1; +#56 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +DELETE FROM t1 USING t1 WHERE uknown_column = 12345; +ERROR 42S22: Unknown column 'uknown_column' in 'where clause' +EXPLAIN DELETE FROM t1 USING t1 WHERE uknown_column = 12345; +ERROR 42S22: Unknown column 'uknown_column' in 'where clause' +DROP TABLE t1; +#57 +CREATE TABLE t1(f1 INT); +EXPLAIN UPDATE t1 SET f2=1 ORDER BY f2; +ERROR 42S22: Unknown column 'f2' in 'field list' +UPDATE t1 SET f2=1 ORDER BY f2; +ERROR 42S22: Unknown column 'f2' in 'field list' +DROP TABLE t1; +#59 +CREATE TABLE t1 ( a INT, KEY( a ) ); +INSERT INTO t1 VALUES (0), (1); +CREATE VIEW v1 AS SELECT t11.a, t12.a AS b FROM t1 t11, t1 t12; +SET SESSION sql_safe_updates = 1; +EXPLAIN UPDATE IGNORE v1 SET a = 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t11 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t12 NULL index NULL a 5 NULL 2 100.00 Using index +Warnings: +Note 1003 update ignore (`test`.`t1` `t11` join `test`.`t1` `t12`) set `t11`.`a` = 1 +UPDATE IGNORE v1 SET a = 1; +ERROR HY000: You are using safe update mode and you tried to update a table without a WHERE that uses a KEY column. +SET SESSION sql_safe_updates = DEFAULT; +DROP TABLE t1; +DROP VIEW v1; +#62 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (0), (1); +CREATE VIEW v1 AS SELECT t11.a, t12.a AS b FROM t1 t11, t1 t12; +# +# query: UPDATE v1 SET a = 1 WHERE a > 0 +# select: SELECT * FROM v1 WHERE a > 0 +# +EXPLAIN UPDATE v1 SET a = 1 WHERE a > 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t11 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t12 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 update (`test`.`t1` `t11` join `test`.`t1` `t12`) set `t11`.`a` = 1 where (`t11`.`a` > 0) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 1 +Handler_read_rnd_next 6 +# Status of testing query execution: +Variable_name Value +Handler_read_key 1 +Handler_read_rnd 1 +Handler_read_rnd_next 8 +Handler_write 2 + +# +# query: UPDATE t1, v1 SET v1.a = 1 WHERE t1.a = v1.a +# select: SELECT * FROM t1, v1 WHERE t1.a = v1.a +# +EXPLAIN UPDATE t1, v1 SET v1.a = 1 WHERE t1.a = v1.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 UPDATE t11 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t12 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 update `test`.`t1` join `test`.`t1` `t11` join `test`.`t1` `t12` set `test`.`t11`.`a` = 1 where (`test`.`t11`.`a` = `test`.`t1`.`a`) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 1 +Handler_read_rnd_next 9 +# Status of testing query execution: +Variable_name Value +Handler_read_key 1 +Handler_read_rnd 2 +Handler_read_rnd_next 18 +Handler_update 1 +Handler_write 4 + +DROP TABLE t1; +DROP VIEW v1; +#63 +CREATE TABLE t1 (a INT, PRIMARY KEY(a)); +INSERT INTO t1 VALUES (1), (2), (3), (4), (5); +CREATE VIEW v1 (a) AS SELECT a FROM t1; +# +# query: DELETE FROM v1 WHERE a < 4 +# select: SELECT * FROM v1 WHERE a < 4 +# +EXPLAIN DELETE FROM v1 WHERE a < 4; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL range PRIMARY PRIMARY 4 const 3 100.00 Using where +Warnings: +Note 1003 delete from (`test`.`t1`) where (`test`.`t1`.`a` < 4) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 1 +Handler_read_next 3 +# Status of testing query execution: +Variable_name Value +Handler_delete 3 +Handler_read_first 1 +Handler_read_key 1 +Handler_read_next 3 + +DROP TABLE t1; +DROP VIEW v1; +#64 +CREATE TABLE t1 (a INT, b INT, PRIMARY KEY(a)); +INSERT INTO t1 VALUES (1,2), (2,3), (3,4), (4,5), (5,10); +CREATE TABLE t2 (x INT); +INSERT INTO t2 VALUES (1), (2), (3), (4); +CREATE VIEW v1 (a,c) AS SELECT a, b+1 FROM t1; +# +# query: DELETE v1 FROM t2, v1 WHERE t2.x = v1.a +# select: SELECT * FROM t2, v1 WHERE t2.x = v1.a +# +EXPLAIN DELETE v1 FROM t2, v1 WHERE t2.x = v1.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +1 DELETE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.x 1 100.00 NULL +Warnings: +Note 1003 delete `test`.`t1` from `test`.`t2` join `test`.`t1` where (`test`.`t1`.`a` = `test`.`t2`.`x`) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 7 +Handler_read_rnd_next 5 +# Status of testing query execution: +Variable_name Value +Handler_delete 4 +Handler_read_key 7 +Handler_read_rnd 4 +Handler_read_rnd_next 5 + +DROP TABLE t1,t2; +DROP VIEW v1; +#65 +CREATE TABLE t1 (a INT, b INT, PRIMARY KEY(a)); +INSERT INTO t1 VALUES (1,2), (2,3), (3,4), (4,5), (5,10); +CREATE TABLE t2 (x INT); +INSERT INTO t2 VALUES (1), (2), (3), (4); +CREATE VIEW v1 (a,c) AS SELECT a, b+1 FROM t1; +# +# query: DELETE v1 FROM t2, v1 WHERE t2.x = v1.a +# select: SELECT * FROM t2, v1 WHERE t2.x = v1.a +# +EXPLAIN DELETE v1 FROM t2, v1 WHERE t2.x = v1.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +1 DELETE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.x 1 100.00 NULL +Warnings: +Note 1003 delete `test`.`t1` from `test`.`t2` join `test`.`t1` where (`test`.`t1`.`a` = `test`.`t2`.`x`) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 7 +Handler_read_rnd_next 5 +# Status of testing query execution: +Variable_name Value +Handler_delete 4 +Handler_read_key 7 +Handler_read_rnd 4 +Handler_read_rnd_next 5 + +DROP TABLE t1,t2; +DROP VIEW v1; +#66 +CREATE TABLE t1 (a INT); +CREATE VIEW v1 (x) AS SELECT a FROM t1; +# +# query: INSERT INTO v1 VALUES (10) +# select: SELECT NULL +# +EXPLAIN INSERT INTO v1 VALUES (10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 INSERT t1 NULL ALL NULL NULL NULL NULL NULL NULL NULL +Warnings: +Note 1003 insert into `test`.`t1` values (10) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +# Status of testing query execution: +Variable_name Value +Handler_read_key 1 +Handler_write 1 + +DROP TABLE t1; +DROP VIEW v1; +#67 +CREATE TABLE t1 (a INT); +CREATE TABLE t2 (b INT); +INSERT INTO t2 VALUES (1), (2), (3); +CREATE VIEW v1 (x) AS SELECT b FROM t2; +# +# query: INSERT INTO v1 SELECT * FROM t1 +# select: SELECT * FROM t1 +# +EXPLAIN INSERT INTO v1 SELECT * FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 INSERT NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 insert into `test`.`t2` /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 1 +Handler_read_rnd_next 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 1 + +DROP TABLE t1, t2; +DROP VIEW v1; +#69 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +CREATE TABLE t2 (b INT); +INSERT INTO t2 VALUES (1), (2), (3); +# +# query: UPDATE t1 SET a = 10 WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x) +# select: SELECT * FROM t1 WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x) +# +EXPLAIN UPDATE t1 SET a = 10 WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY NULL index_subquery 5 func 2 100.00 Using index +3 DERIVED t2 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`a` = 10 where (`test`.`t1`.`a`,(((`test`.`t1`.`a`) in x on ))) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 5 +Handler_read_rnd_next 8 +Handler_write 1 +Sort_rows 3 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 5 +Handler_read_rnd_next 8 +Handler_update 1 +Handler_write 1 +Sort_rows 3 +Sort_scan 1 + +# +# query: UPDATE t1, t2 SET a = 10 WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x) +# select: SELECT * FROM t1, t2 WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x) +# +EXPLAIN UPDATE t1, t2 SET a = 10 WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 DEPENDENT SUBQUERY NULL index_subquery 5 func 2 100.00 Using index +3 DERIVED t2 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 update `test`.`t1` join `test`.`t2` set `test`.`t1`.`a` = 10 where (`test`.`t1`.`a`,(((`test`.`t1`.`a`) in x on ))) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 5 +Handler_read_rnd_next 8 +Handler_write 1 +Sort_rows 3 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 5 +Handler_read_rnd_next 8 +Handler_write 1 +Sort_rows 3 +Sort_scan 1 + +# +# query: UPDATE t1, (SELECT * FROM t2) y SET a = 10 WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x) +# select: SELECT * FROM t1, (SELECT * FROM t2) y WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x) +# +EXPLAIN UPDATE t1, (SELECT * FROM t2) y SET a = 10 WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +3 DEPENDENT SUBQUERY NULL index_subquery 5 func 2 100.00 Using index +4 DERIVED t2 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 update `test`.`t1` join `test`.`t2` set `test`.`t1`.`a` = 10 where (`test`.`t1`.`a`,(((`test`.`t1`.`a`) in x on ))) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 5 +Handler_read_rnd_next 8 +Handler_write 1 +Sort_rows 3 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 5 +Handler_read_rnd_next 8 +Handler_write 1 +Sort_rows 3 +Sort_scan 1 + +DROP TABLE t1,t2; +#70 +CREATE TABLE t1 (c1 INT KEY); +CREATE TABLE t2 (c2 INT); +CREATE TABLE t3 (c3 INT); +EXPLAIN UPDATE t3 SET c3 = ( +SELECT COUNT(d1.c1) +FROM ( +SELECT a11.c1 FROM t1 AS a11 +STRAIGHT_JOIN t2 AS a21 ON a21.c2 = a11.c1 +JOIN t1 AS a12 ON a12.c1 = a11.c1 +) d1 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t3 NULL ALL NULL NULL NULL NULL 0 100.00 NULL +2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +3 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 update `test`.`t3` set `test`.`t3`.`c3` = (/* select#2 */ select count(NULL) from (/* select#3 */ select NULL AS `c1` from `test`.`t1` `a11` straight_join `test`.`t2` `a21` join `test`.`t1` `a12` where multiple equal(NULL, NULL, NULL)) `d1`) +DROP TABLE t1, t2, t3; +#71 +CREATE TABLE t1 (c1 INT NOT NULL, c2 INT NOT NULL, INDEX i1(c1)); +INSERT INTO t1 VALUES (1,0),(2,0),(3,0),(4,0),(5,0),(6,0),(7,0),(8,0); +CREATE TABLE t2 LIKE t1; +EXPLAIN INSERT INTO t2 SELECT * FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 INSERT t2 NULL ALL NULL NULL NULL NULL X NULL NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL X 100.00 NULL +Warnings: +Note 1003 insert into `test`.`t2` /* select#1 */ select `test`.`t1`.`c1` AS `c1`,`test`.`t1`.`c2` AS `c2` from `test`.`t1` +INSERT INTO t2 SELECT * FROM t1; +SELECT * FROM t1 LEFT JOIN t2 ON t1.c1 = t2.c1; +DROP TABLE t1, t2; +#73 +CREATE TABLE t1 (id INT); +CREATE TABLE t2 (id INT); +INSERT INTO t1 VALUES (1), (2); +EXPLAIN SELECT * FROM t1 LEFT JOIN t2 USING(id) GROUP BY t1.id; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL system NULL NULL NULL NULL 0 0.00 const row not found +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id` from `test`.`t1` where true group by `test`.`t1`.`id` +DROP TABLE t1,t2; +#74 +CREATE TABLE t1(a INT PRIMARY KEY) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1), (2), (3), (4), (5); +# used key is modified & Using temporary +# +# query: UPDATE t1 SET a=a+1 WHERE a>10 +# select: SELECT a t1 FROM t1 WHERE a>10 +# +EXPLAIN UPDATE t1 SET a=a+1 WHERE a>10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL range PRIMARY PRIMARY 4 const 1 100.00 Using where; Using temporary +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`a` = (`test`.`t1`.`a` + 1) where (`test`.`t1`.`a` > 10) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 2 + +# used key is modified & Using filesort +# +# query: UPDATE t1 SET a=a+1 WHERE a>10 ORDER BY a+20 +# select: SELECT a t1 FROM t1 WHERE a>10 ORDER BY a+20 +# +EXPLAIN UPDATE t1 SET a=a+1 WHERE a>10 ORDER BY a+20; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL range PRIMARY PRIMARY 4 const 1 100.00 Using where; Using filesort +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`a` = (`test`.`t1`.`a` + 1) where (`test`.`t1`.`a` > 10) order by (`test`.`t1`.`a` + 20) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 1 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 2 +Sort_scan 1 + +DROP TABLE t1; +# +# Bug #12949629: CLIENT LOSES CONNECTION AFTER EXECUTING A PROCEDURE WITH +# EXPLAIN UPDATE/DEL/INS +# +CREATE TABLE t1 (i INT); +CREATE TABLE t2 (i INT); +CREATE PROCEDURE p1() BEGIN EXPLAIN INSERT INTO t1 VALUES (1);END| +CREATE PROCEDURE p2() BEGIN INSERT INTO t1 VALUES (1);END| +CREATE PROCEDURE p3() BEGIN EXPLAIN INSERT INTO t1 SELECT 1;END| +CREATE PROCEDURE p4() BEGIN INSERT INTO t1 SELECT 1;END| +CREATE PROCEDURE p5() BEGIN EXPLAIN REPLACE INTO t1 VALUES (1);END| +CREATE PROCEDURE p6() BEGIN REPLACE INTO t1 VALUES (1);END| +CREATE PROCEDURE p7() BEGIN EXPLAIN REPLACE INTO t1 SELECT 1;END| +CREATE PROCEDURE p8() BEGIN REPLACE INTO t1 SELECT 1;END| +CREATE PROCEDURE p9() BEGIN EXPLAIN UPDATE t1 SET i = 10;END| +CREATE PROCEDURE p10() BEGIN UPDATE t1 SET i = 10;END| +CREATE PROCEDURE p11() BEGIN EXPLAIN UPDATE t1,t2 SET t1.i = 10 WHERE t1.i = t2.i ;END| +CREATE PROCEDURE p12() BEGIN UPDATE t1,t2 SET t1.i = 10 WHERE t1.i = t2.i ;END| +CREATE PROCEDURE p13() BEGIN +# Disabling binary logging temporarily as optimized delete is not used when log-bin is enabled in row mode +SET @save_log_bin= @@sql_log_bin;SET SQL_LOG_BIN=0; +EXPLAIN DELETE FROM t1; +SET SQL_LOG_BIN=@save_log_bin; END| +CREATE PROCEDURE p14() BEGIN DELETE FROM t1;END| +CREATE PROCEDURE p15() BEGIN EXPLAIN DELETE FROM t1 USING t1;END| +CREATE PROCEDURE p16() BEGIN DELETE FROM t1 USING t1;END| +CALL p16(); +DROP PROCEDURE p16; +CALL p15(); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 delete `test`.`t1` from `test`.`t1` +DROP PROCEDURE p15; +CALL p14(); +DROP PROCEDURE p14; +CALL p13(); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 0 100.00 Deleting all rows +DROP PROCEDURE p13; +CALL p12(); +DROP PROCEDURE p12; +CALL p11(); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 update `test`.`t1` join `test`.`t2` set `test`.`t1`.`i` = 10 where multiple equal(`test`.`t1`.`i`, `test`.`t2`.`i`) +DROP PROCEDURE p11; +CALL p10(); +DROP PROCEDURE p10; +CALL p9(); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 0 100.00 NULL +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`i` = 10 +DROP PROCEDURE p9; +CALL p8(); +DROP PROCEDURE p8; +CALL p7(); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 REPLACE t1 NULL ALL NULL NULL NULL NULL NULL NULL NULL +Warnings: +Note 1003 replace into `test`.`t1` /* select#1 */ select 1 AS `1` from dual +DROP PROCEDURE p7; +CALL p6(); +DROP PROCEDURE p6; +CALL p5(); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 REPLACE t1 NULL ALL NULL NULL NULL NULL NULL NULL NULL +Warnings: +Note 1003 replace into `test`.`t1` values (1) +DROP PROCEDURE p5; +CALL p4(); +DROP PROCEDURE p4; +CALL p3(); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 INSERT t1 NULL ALL NULL NULL NULL NULL NULL NULL NULL +Warnings: +Note 1003 insert into `test`.`t1` /* select#1 */ select 1 AS `1` from dual +DROP PROCEDURE p3; +CALL p2(); +DROP PROCEDURE p2; +CALL p1(); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 INSERT t1 NULL ALL NULL NULL NULL NULL NULL NULL NULL +Warnings: +Note 1003 insert into `test`.`t1` values (1) +DROP PROCEDURE p1; +DROP TABLE t1, t2; +# +set default_storage_engine= @save_storage_engine; +set optimizer_switch=default; diff --git a/mysql-test/r/negation_elimination.result-pq b/mysql-test/r/negation_elimination.result-pq new file mode 100644 index 000000000000..f7806d3cd414 --- /dev/null +++ b/mysql-test/r/negation_elimination.result-pq @@ -0,0 +1,589 @@ +drop table if exists t1; +create table t1 (a int, key (a)); +insert into t1 values (NULL), (0), (1), (2), (3), (4), (5), (6), (7), (8), (9), +(10), (11), (12), (13), (14), (15), (16), (17), (18), (19); +analyze table t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +explain select * from t1 where not(not(a)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL # NULL NULL NULL NULL # # Parallel execute (2 workers) +2 SIMPLE t1 NULL # a a 5 NULL # # Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (0 <> `test`.`t1`.`a`) +select * from t1 where not(not(a)); +a +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +explain select * from t1 where not(not(not(a > 10))); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range a a 5 NULL 11 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` <= 10) +select * from t1 where not(not(not(a > 10))); +a +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +explain select * from t1 where not(not(not(a < 5) and not(a > 10))); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 6 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range a a 5 NULL 6 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where ((`test`.`t1`.`a` >= 5) and (`test`.`t1`.`a` <= 10)) +select * from t1 where not(not(not(a < 5) and not(a > 10))); +a +5 +6 +7 +8 +9 +10 +explain select * from t1 where not(a = 10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 19 100.00 Parallel execute (2 workers) +2 SIMPLE t1 NULL range a a 5 NULL 19 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` <> 10) +select * from t1 where not(a = 10); +a +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +11 +12 +13 +14 +15 +16 +17 +18 +19 +explain select * from t1 where not(a != 10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref a a 5 const 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` = 10) +select * from t1 where not(a != 1); +a +1 +explain select * from t1 where not(a < 10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range a a 5 NULL 10 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` >= 10) +select * from t1 where not(a < 10); +a +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +explain select * from t1 where not(a >= 10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range a a 5 NULL 10 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` < 10) +select * from t1 where not(a >= 10); +a +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +explain select * from t1 where not(a > 10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range a a 5 NULL 11 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` <= 10) +select * from t1 where not(a > 10); +a +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +explain select * from t1 where not(a <= 10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 9 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range a a 5 NULL 9 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` > 10) +select * from t1 where not(a <= 10); +a +11 +12 +13 +14 +15 +16 +17 +18 +19 +explain select * from t1 where not(a is null); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 20 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range a a 5 NULL 20 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` is not null) +select * from t1 where not(a is null); +a +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +explain select * from t1 where not(a is not null); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref a a 5 const 1 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` is null) +select * from t1 where not(a is not null); +a +NULL +explain select * from t1 where not(a < 5 or a > 15); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range a a 5 NULL 11 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where ((`test`.`t1`.`a` >= 5) and (`test`.`t1`.`a` <= 15)) +select * from t1 where not(a < 5 or a > 15); +a +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +explain select * from t1 where not(a < 15 and a > 5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 100.00 Parallel execute (2 workers) +2 SIMPLE t1 NULL range a a 5 NULL 11 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where ((`test`.`t1`.`a` >= 15) or (`test`.`t1`.`a` <= 5)) +select * from t1 where not(a < 15 and a > 5); +a +0 +1 +2 +3 +4 +5 +15 +16 +17 +18 +19 +explain select * from t1 where a = 2 or not(a < 10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 100.00 Parallel execute (2 workers) +2 SIMPLE t1 NULL range a a 5 NULL 11 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where ((`test`.`t1`.`a` = 2) or (`test`.`t1`.`a` >= 10)) +select * from t1 where a = 2 or not(a < 10); +a +2 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +explain select * from t1 where a > 5 and not(a > 10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range a a 5 NULL 5 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where ((`test`.`t1`.`a` > 5) and (`test`.`t1`.`a` <= 10)) +select * from t1 where a > 5 and not(a > 10); +a +6 +7 +8 +9 +10 +explain select * from t1 where a > 5 xor a < 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 21 44.44 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL a 5 NULL 21 44.44 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where ((`test`.`t1`.`a` > 5) xor (`test`.`t1`.`a` < 10)) +select * from t1 where a > 5 xor a < 10; +a +0 +1 +2 +3 +4 +5 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +explain select * from t1 where a = 2 or not(a < 5 or a > 15); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 12 100.00 Parallel execute (2 workers) +2 SIMPLE t1 NULL range a a 5 NULL 12 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where ((`test`.`t1`.`a` = 2) or ((`test`.`t1`.`a` >= 5) and (`test`.`t1`.`a` <= 15))) +select * from t1 where a = 2 or not(a < 5 or a > 15); +a +2 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +explain select * from t1 where a = 7 or not(a < 15 and a > 5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 12 100.00 Parallel execute (3 workers) +2 SIMPLE t1 NULL range a a 5 NULL 12 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where ((`test`.`t1`.`a` = 7) or (`test`.`t1`.`a` >= 15) or (`test`.`t1`.`a` <= 5)) +select * from t1 where a = 7 or not(a < 15 and a > 5); +a +0 +1 +2 +3 +4 +5 +7 +15 +16 +17 +18 +19 +explain select * from t1 where NULL or not(a < 15 and a > 5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 100.00 Parallel execute (2 workers) +2 SIMPLE t1 NULL range a a 5 NULL 11 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where ((`test`.`t1`.`a` >= 15) or (`test`.`t1`.`a` <= 5)) +select * from t1 where NULL or not(a < 15 and a > 5); +a +0 +1 +2 +3 +4 +5 +15 +16 +17 +18 +19 +explain select * from t1 where not(NULL and a > 5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 6 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range a a 5 NULL 6 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` <= 5) +select * from t1 where not(NULL and a > 5); +a +0 +1 +2 +3 +4 +5 +explain select * from t1 where not(NULL or a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where false +select * from t1 where not(NULL or a); +a +explain select * from t1 where not(NULL and a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref a a 5 const 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` = 0) +select * from t1 where not(NULL and a); +a +0 +explain select * from t1 where not((a < 5 or a < 10) and (not(a > 16) or a > 17)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range a a 5 NULL 10 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (((`test`.`t1`.`a` >= 5) and (`test`.`t1`.`a` >= 10)) or ((`test`.`t1`.`a` > 16) and (`test`.`t1`.`a` <= 17))) +select * from t1 where not((a < 5 or a < 10) and (not(a > 16) or a > 17)); +a +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +explain select * from t1 where not((a < 5 and a < 10) and (not(a > 16) or a > 17)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 15 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range a a 5 NULL 15 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where ((`test`.`t1`.`a` >= 5) or (`test`.`t1`.`a` >= 10) or ((`test`.`t1`.`a` > 16) and (`test`.`t1`.`a` <= 17))) +select * from t1 where not((a < 5 and a < 10) and (not(a > 16) or a > 17)); +a +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +explain select * from t1 where ((a between 5 and 15) and (not(a like 10))); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range a a 5 NULL 11 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where ((`test`.`t1`.`a` between 5 and 15) and (not((`test`.`t1`.`a` like 10)))) +select * from t1 where ((a between 5 and 15) and (not(a like 10))); +a +5 +6 +7 +8 +9 +11 +12 +13 +14 +15 +# XOR (Note: XOR is negated by negating one of the operands) +# Should return 6,7 +SELECT * FROM t1 WHERE ((a > 5) XOR (a > 7)); +a +6 +7 +# Should return 0..5,8..19 +SELECT * FROM t1 WHERE ((NOT (a > 5)) XOR (a > 7)); +a +0 +1 +2 +3 +4 +5 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +SELECT * FROM t1 WHERE ((a > 5) XOR (NOT (a > 7))); +a +0 +1 +2 +3 +4 +5 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +SELECT * FROM t1 WHERE NOT ((a > 5) XOR (a > 7)); +a +0 +1 +2 +3 +4 +5 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +# Should return 6,7 +SELECT * FROM t1 WHERE NOT ((NOT (a > 5)) XOR (a > 7)); +a +6 +7 +SELECT * FROM t1 WHERE NOT ((a > 5) XOR (NOT (a > 7))); +a +6 +7 +# Should return 0..5,8..19 +SELECT * FROM t1 WHERE NOT ((NOT (a > 5)) XOR (NOT (a > 7))); +a +0 +1 +2 +3 +4 +5 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +# Should have empty result +SELECT * FROM t1 WHERE (NULL XOR (a > 7)); +a +SELECT * FROM t1 WHERE NOT (NULL XOR (a > 7)); +a +# Should be simplified to "...WHERE (a XOR a) +EXPLAIN SELECT * FROM t1 WHERE NOT ((NOT a) XOR (a)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 21 18.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL a 5 NULL 21 18.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where ((0 <> `test`.`t1`.`a`) xor (0 <> `test`.`t1`.`a`)) +# Should be simplified to "...WHERE (a XOR a) +EXPLAIN SELECT * FROM t1 WHERE NOT (a XOR (NOT a)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 21 18.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL a 5 NULL 21 18.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where ((0 = `test`.`t1`.`a`) xor (0 = `test`.`t1`.`a`)) +# End XOR +delete from t1 where a > 3; +select a, not(not(a)) from t1; +a not(not(a)) +NULL NULL +0 0 +1 1 +2 1 +3 1 +analyze table t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +explain select a, not(not(a)), not(a <= 2 and not(a)), not(a not like "1"), not (a not in (1,2)), not(a != 2) from t1 where not(not(a)) having not(not(a)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL # NULL NULL NULL NULL # # Parallel execute (2 workers) +2 SIMPLE t1 NULL # a a 5 NULL # # Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,(0 <> `test`.`t1`.`a`) AS `not(not(a))`,((`test`.`t1`.`a` > 2) or (0 <> `test`.`t1`.`a`)) AS `not(a <= 2 and not(a))`,(`test`.`t1`.`a` like '1') AS `not(a not like "1")`,(`test`.`t1`.`a` in (1,2)) AS `not (a not in (1,2))`,(`test`.`t1`.`a` = 2) AS `not(a != 2)` from `test`.`t1` where (0 <> `test`.`t1`.`a`) having (0 <> `test`.`t1`.`a`) +drop table t1; diff --git a/mysql-test/r/null.result-pq b/mysql-test/r/null.result-pq new file mode 100644 index 000000000000..2ef3cde91628 --- /dev/null +++ b/mysql-test/r/null.result-pq @@ -0,0 +1,440 @@ +drop table if exists t1, t2; +select null,isnull(null),isnull(1/0),isnull(1/0 = null),ifnull(null,1),ifnull(null,"TRUE"),ifnull("TRUE","ERROR"),1/0 is null,1 is not null; +NULL isnull(null) isnull(1/0) isnull(1/0 = null) ifnull(null,1) ifnull(null,"TRUE") ifnull("TRUE","ERROR") 1/0 is null 1 is not null +NULL 1 1 1 1 TRUE TRUE 1 1 +Warnings: +Warning 1365 Division by 0 +Warning 1365 Division by 0 +Warning 1365 Division by 0 +explain select null,isnull(null),isnull(1/0),isnull(1/0 = null),ifnull(null,1),ifnull(null,"TRUE"),ifnull("TRUE","ERROR"),1/0 is null,1 is not null; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Warning 1365 Division by 0 +Warning 1365 Division by 0 +Warning 1365 Division by 0 +Note 1003 /* select#1 */ select NULL AS `NULL`,(NULL is null) AS `isnull(null)`,((1 / 0) is null) AS `isnull(1/0)`,(((1 / 0) = NULL) is null) AS `isnull(1/0 = null)`,ifnull(NULL,1) AS `ifnull(null,1)`,ifnull(NULL,'TRUE') AS `ifnull(null,"TRUE")`,ifnull('TRUE','ERROR') AS `ifnull("TRUE","ERROR")`,((1 / 0) is null) AS `1/0 is null`,(1 is not null) AS `1 is not null` +select 1 | NULL,1 & NULL,1+NULL,1-NULL; +1 | NULL 1 & NULL 1+NULL 1-NULL +NULL NULL NULL NULL +select NULL=NULL,NULL<>NULL,IFNULL(NULL,1.1)+0,IFNULL(NULL,1) | 0; +NULL=NULL NULL<>NULL IFNULL(NULL,1.1)+0 IFNULL(NULL,1) | 0 +NULL NULL 1.1 1 +select strcmp("a",NULL),(1NULL; +indexed_field +NULL +NULL +DROP TABLE t1; +create table t1 (a int, b int); +insert into t1 values(20,null); +select t2.b, ifnull(t2.b,"this is null") from t1 as t2 left join t1 as t3 on +t2.b=t3.a; +b ifnull(t2.b,"this is null") +NULL this is null +select t2.b, ifnull(t2.b,"this is null") from t1 as t2 left join t1 as t3 on +t2.b=t3.a order by 1; +b ifnull(t2.b,"this is null") +NULL this is null +insert into t1 values(10,null); +select t2.b, ifnull(t2.b,"this is null") from t1 as t2 left join t1 as t3 on +t2.b=t3.a order by 1; +b ifnull(t2.b,"this is null") +NULL this is null +NULL this is null +drop table t1; +SET sql_mode = 'NO_ENGINE_SUBSTITUTION'; +CREATE TABLE t1 (a varchar(16) NOT NULL default '', b smallint(6) NOT NULL default 0, c datetime NOT NULL default '0000-00-00 00:00:00', d smallint(6) NOT NULL default 0); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 SET a = "", d= "2003-01-14 03:54:55"; +Warnings: +Warning 1265 Data truncated for column 'd' at row 1 +UPDATE t1 SET d=1/NULL; +Warnings: +Warning 1048 Column 'd' cannot be null +UPDATE t1 SET d=NULL; +Warnings: +Warning 1048 Column 'd' cannot be null +INSERT INTO t1 (a) values (null); +ERROR 23000: Column 'a' cannot be null +INSERT INTO t1 (a) values (1/null); +ERROR 23000: Column 'a' cannot be null +INSERT INTO t1 (a) values (null),(null); +Warnings: +Warning 1048 Column 'a' cannot be null +INSERT INTO t1 (b) values (null); +ERROR 23000: Column 'b' cannot be null +INSERT INTO t1 (b) values (1/null); +ERROR 23000: Column 'b' cannot be null +INSERT INTO t1 (b) values (null),(null); +Warnings: +Warning 1048 Column 'b' cannot be null +INSERT INTO t1 (c) values (null); +ERROR 23000: Column 'c' cannot be null +INSERT INTO t1 (c) values (1/null); +ERROR 23000: Column 'c' cannot be null +INSERT INTO t1 (c) values (null),(null); +Warnings: +Warning 1048 Column 'c' cannot be null +INSERT INTO t1 (d) values (null); +ERROR 23000: Column 'd' cannot be null +INSERT INTO t1 (d) values (1/null); +ERROR 23000: Column 'd' cannot be null +INSERT INTO t1 (d) values (null),(null); +Warnings: +Warning 1048 Column 'd' cannot be null +select * from t1; +a b c d + 0 0000-00-00 00:00:00 0 + 0 0000-00-00 00:00:00 0 + 0 0000-00-00 00:00:00 0 + 0 0000-00-00 00:00:00 0 + 0 0000-00-00 00:00:00 0 + 0 0000-00-00 00:00:00 0 + 0 0000-00-00 00:00:00 0 + 0 0000-00-00 00:00:00 0 + 0 0000-00-00 00:00:00 0 +drop table t1; +SET sql_mode = default; +create table t1 (a int not null, b int not null, index idx(a)); +insert into t1 values +(1,1), (2,2), (3,3), (4,4), (5,5), (6,6), +(7,7), (8,8), (9,9), (10,10), (11,11), (12,12); +analyze table t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +explain select * from t1 where a between 2 and 3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range idx idx 4 NULL 2 100.00 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (`test`.`t1`.`a` between 2 and 3) +explain select * from t1 where a between 2 and 3 or b is null; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range idx idx 4 NULL 2 100.00 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (`test`.`t1`.`a` between 2 and 3) +drop table t1; +select cast(NULL as signed); +cast(NULL as signed) +NULL +create table t1(i int, key(i)); +insert into t1 values(1); +insert into t1 select i*2 from t1; +insert into t1 select i*2 from t1; +insert into t1 select i*2 from t1; +insert into t1 select i*2 from t1; +insert into t1 select i*2 from t1; +insert into t1 select i*2 from t1; +insert into t1 select i*2 from t1; +insert into t1 select i*2 from t1; +insert into t1 select i*2 from t1; +insert into t1 values(null); +analyze table t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +explain select * from t1 where i=2 or i is null; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ref_or_null i i 5 const 10 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` where ((`test`.`t1`.`i` = 2) or (`test`.`t1`.`i` is null)) +select count(*) from t1 where i=2 or i is null; +count(*) +10 +SET sql_mode = 'NO_ENGINE_SUBSTITUTION'; +alter table t1 change i i int not null; +Warnings: +Warning 1265 Data truncated for column 'i' at row 513 +SET sql_mode = default; +explain select * from t1 where i=2 or i is null; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 9 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref i i 4 const 9 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` where (`test`.`t1`.`i` = 2) +select count(*) from t1 where i=2 or i is null; +count(*) +9 +drop table t1; +set names latin2; +create table t1 select +null as c00, +if(1, null, 'string') as c01, +if(0, null, 'string') as c02, +ifnull(null, 'string') as c03, +ifnull('string', null) as c04, +case when 0 then null else 'string' end as c05, +case when 1 then null else 'string' end as c06, +coalesce(null, 'string') as c07, +coalesce('string', null) as c08, +least('string',null) as c09, +least(null, 'string') as c10, +greatest('string',null) as c11, +greatest(null, 'string') as c12, +nullif('string', null) as c13, +nullif(null, 'string') as c14, +trim('string' from null) as c15, +trim(null from 'string') as c16, +substring_index('string', null, 1) as c17, +substring_index(null, 'string', 1) as c18, +elt(1, null, 'string') as c19, +elt(1, 'string', null) as c20, +concat('string', null) as c21, +concat(null, 'string') as c22, +concat_ws('sep', 'string', null) as c23, +concat_ws('sep', null, 'string') as c24, +concat_ws(null, 'string', 'string') as c25, +make_set(3, 'string', null) as c26, +make_set(3, null, 'string') as c27, +export_set(3, null, 'off', 'sep') as c29, +export_set(3, 'on', null, 'sep') as c30, +export_set(3, 'on', 'off', null) as c31, +replace(null, 'from', 'to') as c32, +replace('str', null, 'to') as c33, +replace('str', 'from', null) as c34, +insert('str', 1, 2, null) as c35, +insert(null, 1, 2, 'str') as c36, +lpad('str', 10, null) as c37, +rpad(null, 10, 'str') as c38; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c00` binary(0) DEFAULT NULL, + `c01` varchar(6) CHARACTER SET latin2 DEFAULT NULL, + `c02` varchar(6) CHARACTER SET latin2 DEFAULT NULL, + `c03` varchar(6) CHARACTER SET latin2 NOT NULL DEFAULT '', + `c04` varchar(6) CHARACTER SET latin2 NOT NULL DEFAULT '', + `c05` varchar(6) CHARACTER SET latin2 DEFAULT NULL, + `c06` varchar(6) CHARACTER SET latin2 DEFAULT NULL, + `c07` varchar(6) CHARACTER SET latin2 NOT NULL DEFAULT '', + `c08` varchar(6) CHARACTER SET latin2 NOT NULL DEFAULT '', + `c09` varchar(6) CHARACTER SET latin2 DEFAULT NULL, + `c10` varchar(6) CHARACTER SET latin2 DEFAULT NULL, + `c11` varchar(6) CHARACTER SET latin2 DEFAULT NULL, + `c12` varchar(6) CHARACTER SET latin2 DEFAULT NULL, + `c13` varchar(6) CHARACTER SET latin2 DEFAULT NULL, + `c14` binary(0) DEFAULT NULL, + `c15` binary(0) DEFAULT NULL, + `c16` varchar(6) CHARACTER SET latin2 DEFAULT NULL, + `c17` varchar(6) CHARACTER SET latin2 DEFAULT NULL, + `c18` binary(0) DEFAULT NULL, + `c19` varchar(6) CHARACTER SET latin2 DEFAULT NULL, + `c20` varchar(6) CHARACTER SET latin2 DEFAULT NULL, + `c21` varchar(6) CHARACTER SET latin2 DEFAULT NULL, + `c22` varchar(6) CHARACTER SET latin2 DEFAULT NULL, + `c23` varchar(9) CHARACTER SET latin2 DEFAULT NULL, + `c24` varchar(9) CHARACTER SET latin2 DEFAULT NULL, + `c25` varchar(12) CHARACTER SET latin2 DEFAULT NULL, + `c26` varchar(7) CHARACTER SET latin2 DEFAULT NULL, + `c27` varchar(7) CHARACTER SET latin2 DEFAULT NULL, + `c29` varchar(381) CHARACTER SET latin2 DEFAULT NULL, + `c30` varchar(317) CHARACTER SET latin2 DEFAULT NULL, + `c31` varchar(192) CHARACTER SET latin2 DEFAULT NULL, + `c32` binary(0) DEFAULT NULL, + `c33` varchar(3) CHARACTER SET latin2 DEFAULT NULL, + `c34` varchar(3) CHARACTER SET latin2 DEFAULT NULL, + `c35` varchar(3) CHARACTER SET latin2 DEFAULT NULL, + `c36` varchar(3) CHARACTER SET latin2 DEFAULT NULL, + `c37` varchar(10) CHARACTER SET latin2 DEFAULT NULL, + `c38` varchar(10) CHARACTER SET latin2 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select +case 'str' when 'STR' then 'str' when null then 'null' end as c01, +case 'str' when null then 'null' when 'STR' then 'str' end as c02, +field(null, 'str1', 'str2') as c03, +field('str1','STR1', null) as c04, +field('str1', null, 'STR1') as c05, +'string' in ('STRING', null) as c08, +'string' in (null, 'STRING') as c09; +c01 c02 c03 c04 c05 c08 c09 +str str 0 1 2 1 1 +set names latin1; +create table bug19145a (e enum('a','b','c') default 'b' , s set('x', 'y', 'z') default 'y' ); +create table bug19145b (e enum('a','b','c') default null, s set('x', 'y', 'z') default null); +create table bug19145c (e enum('a','b','c') not null default 'b' , s set('x', 'y', 'z') not null default 'y' ); +create table bug19145setnotnulldefaultnull (e enum('a','b','c') default null, s set('x', 'y', 'z') not null default null); +ERROR 42000: Invalid default value for 's' +create table bug19145enumnotnulldefaultnull (e enum('a','b','c') not null default null, s set('x', 'y', 'z') default null); +ERROR 42000: Invalid default value for 'e' +alter table bug19145a alter column e set default null; +alter table bug19145a alter column s set default null; +alter table bug19145a add column (i int); +alter table bug19145b alter column e set default null; +alter table bug19145b alter column s set default null; +alter table bug19145b add column (i int); +alter table bug19145c alter column e set default null; +ERROR 42000: Invalid default value for 'e' +alter table bug19145c alter column s set default null; +ERROR 42000: Invalid default value for 's' +alter table bug19145c add column (i int); +show create table bug19145a; +Table Create Table +bug19145a CREATE TABLE `bug19145a` ( + `e` enum('a','b','c') DEFAULT NULL, + `s` set('x','y','z') DEFAULT NULL, + `i` int DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +show create table bug19145b; +Table Create Table +bug19145b CREATE TABLE `bug19145b` ( + `e` enum('a','b','c') DEFAULT NULL, + `s` set('x','y','z') DEFAULT NULL, + `i` int DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +show create table bug19145c; +Table Create Table +bug19145c CREATE TABLE `bug19145c` ( + `e` enum('a','b','c') NOT NULL DEFAULT 'b', + `s` set('x','y','z') NOT NULL DEFAULT 'y', + `i` int DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table bug19145a; +drop table bug19145b; +drop table bug19145c; +# End of 4.1 tests +# +# Bug #31471: decimal_bin_size: Assertion `scale >= 0 && +# precision > 0 && scale <= precision' +# +CREATE TABLE t1 (a DECIMAL (1, 0) ZEROFILL, b DECIMAL (1, 0) ZEROFILL); +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +INSERT INTO t1 (a, b) VALUES (0, 0); +CREATE TABLE t2 SELECT IFNULL(a, b) FROM t1; +Warnings: +Warning 1681 UNSIGNED for decimal and floating point data types is deprecated and support for it will be removed in a future release. +DESCRIBE t2; +Field Type Null Key Default Extra +IFNULL(a, b) decimal(1,0) unsigned YES NULL +DROP TABLE t2; +CREATE TABLE t2 SELECT IFNULL(a, NULL) FROM t1; +Warnings: +Warning 1681 UNSIGNED for decimal and floating point data types is deprecated and support for it will be removed in a future release. +DESCRIBE t2; +Field Type Null Key Default Extra +IFNULL(a, NULL) decimal(1,0) unsigned YES NULL +DROP TABLE t2; +CREATE TABLE t2 SELECT IFNULL(NULL, b) FROM t1; +Warnings: +Warning 1681 UNSIGNED for decimal and floating point data types is deprecated and support for it will be removed in a future release. +DESCRIBE t2; +Field Type Null Key Default Extra +IFNULL(NULL, b) decimal(1,0) unsigned YES NULL +DROP TABLE t1, t2; +# End of 5.0 tests +# +# WL#7247: Removal of \N +# +SELECT \N; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '\N' at line 1 +# +# Bug#29337233 'LATE NULLS FILTERING' NEEDED EVEN FOR EQ_REF JOINS KEYS +# +create table t1 ( +pk int primary key, +col_int_unique int, +c char(255) not null default 'xxxx' +) engine = innoDb; +create unique index ix1 ON t1(col_int_unique); +insert into t1(pk,col_int_unique) values (1,1), (2,NULL); +insert into t1(pk,col_int_unique) values (3,3), (4,4), (5,5), (6,6), (7,7), (8,8); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN +SELECT STRAIGHT_JOIN * +FROM t1 LEFT OUTER JOIN t1 AS t2 +ON t1.col_int_unique = t2.col_int_unique; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +2 SIMPLE t2 NULL eq_ref ix1 ix1 5 test.t1.col_int_unique 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select straight_join `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`col_int_unique` AS `col_int_unique`,`test`.`t1`.`c` AS `c`,`test`.`t2`.`pk` AS `pk`,`test`.`t2`.`col_int_unique` AS `col_int_unique`,`test`.`t2`.`c` AS `c` from `test`.`t1` left join `test`.`t1` `t2` on((`test`.`t2`.`col_int_unique` = `test`.`t1`.`col_int_unique`)) where true +SELECT STRAIGHT_JOIN * +FROM t1 LEFT OUTER JOIN t1 AS t2 +ON t1.col_int_unique = t2.col_int_unique; +pk col_int_unique c pk col_int_unique c +1 1 xxxx 1 1 xxxx +2 NULL xxxx NULL NULL NULL +3 3 xxxx 3 3 xxxx +4 4 xxxx 4 4 xxxx +5 5 xxxx 5 5 xxxx +6 6 xxxx 6 6 xxxx +7 7 xxxx 7 7 xxxx +8 8 xxxx 8 8 xxxx +flush status; +SELECT STRAIGHT_JOIN * +FROM t1 JOIN t1 AS t2 +ON t1.col_int_unique = t2.col_int_unique +WHERE t1.pk = 2; +pk col_int_unique c pk col_int_unique c +show status like 'handler_read_key'; +Variable_name Value +Handler_read_key 1 +drop table t1; diff --git a/mysql-test/r/null_key_all_innodb.result-pq b/mysql-test/r/null_key_all_innodb.result-pq new file mode 100644 index 000000000000..0cc14ae484ee --- /dev/null +++ b/mysql-test/r/null_key_all_innodb.result-pq @@ -0,0 +1,163 @@ +set optimizer_switch='semijoin=on,materialization=on,firstmatch=on,loosescan=on,index_condition_pushdown=on,mrr=on'; +SET sql_mode = 'NO_ENGINE_SUBSTITUTION'; +create table t1 (id int); +insert into t1 values (null), (0); +create table t2 (id int); +insert into t2 values (null); +select * from t1, t2 where t1.id = t2.id; +id id +alter table t1 add key id (id); +select * from t1, t2 where t1.id = t2.id; +id id +drop table t1,t2; +create table t1 ( +id integer, +id2 integer not null, +index (id), +index (id2) +); +insert into t1 values(null,null),(1,1); +Warnings: +Warning 1048 Column 'id2' cannot be null +select * from t1; +id id2 +NULL 0 +1 1 +select * from t1 where id <=> null; +id id2 +NULL 0 +select * from t1 where id <=> null or id > 0; +id id2 +NULL 0 +1 1 +select * from t1 where id is null or id > 0; +id id2 +NULL 0 +1 1 +select * from t1 where id2 <=> null or id2 > 0; +id id2 +1 1 +select * from t1 where id2 is null or id2 > 0; +id id2 +1 1 +delete from t1 where id <=> NULL; +select * from t1; +id id2 +1 1 +drop table t1; +CREATE TABLE t1 (a int); +CREATE TABLE t2 (a int, b int, INDEX idx(a)); +CREATE TABLE t3 (b int, INDEX idx(b)); +CREATE TABLE t4 (b int, INDEX idx(b)); +INSERT INTO t1 VALUES (1), (2), (3), (4); +INSERT INTO t2 VALUES (1, 1), (3, 1); +INSERT INTO t3 VALUES +(NULL), (NULL), (NULL), (NULL), (NULL), +(NULL), (NULL), (NULL), (NULL), (NULL); +INSERT INTO t4 SELECT * FROM t3; +INSERT INTO t3 SELECT * FROM t4; +INSERT INTO t4 SELECT * FROM t3; +INSERT INTO t3 SELECT * FROM t4; +INSERT INTO t4 SELECT * FROM t3; +INSERT INTO t3 SELECT * FROM t4; +INSERT INTO t4 SELECT * FROM t3; +INSERT INTO t3 SELECT * FROM t4; +INSERT INTO t4 SELECT * FROM t3; +INSERT INTO t3 SELECT * FROM t4; +INSERT INTO t4 SELECT * FROM t3; +INSERT INTO t3 SELECT * FROM t4; +INSERT INTO t4 SELECT * FROM t3; +INSERT INTO t3 SELECT * FROM t4; +INSERT INTO t4 SELECT * FROM t3; +INSERT INTO t3 SELECT * FROM t4; +INSERT INTO t3 VALUES (2), (3); +ANALYZE table t1, t2, t3; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +SELECT COUNT(*) FROM t3; +COUNT(*) +15972 +EXPLAIN SELECT SQL_CALC_FOUND_ROWS * FROM t1 LEFT JOIN t2 ON t1.a=t2.a +LEFT JOIN t3 ON t2.b=t3.b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL # 100.00 NULL +2 SIMPLE t2 NULL ALL idx NULL NULL NULL # 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t3 NULL ref idx idx 5 test.t2.b # 100.00 Using index +Warnings: +Warning 1287 SQL_CALC_FOUND_ROWS is deprecated and will be removed in a future release. Consider using two separate queries instead. +Note 1003 /* select#1 */ select sql_calc_found_rows `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`b` AS `b` from `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`a` = `test`.`t1`.`a`)) left join `test`.`t3` on((`test`.`t3`.`b` = `test`.`t2`.`b`)) where true +FLUSH STATUS ; +SELECT SQL_CALC_FOUND_ROWS * FROM t1 LEFT JOIN t2 ON t1.a=t2.a +LEFT JOIN t3 ON t2.b=t3.b; +a a b b +1 1 1 NULL +2 NULL NULL NULL +3 3 1 NULL +4 NULL NULL NULL +Warning 1287 SQL_CALC_FOUND_ROWS is deprecated and will be removed in a future release. Consider using two separate queries instead. +Warnings: +SELECT FOUND_ROWS(); +FOUND_ROWS() +4 +Warnings: +Warning 1287 FOUND_ROWS() is deprecated and will be removed in a future release. Consider using COUNT(*) instead. +SHOW STATUS LIKE "handler_read%"; +Variable_name Value +Handler_read_first 2 +Handler_read_key 4 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 8 +DROP TABLE t1,t2,t3,t4; +CREATE TABLE t1 ( +a int(11) default NULL, +b int(11) default NULL, +KEY a (a,b) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (0,10),(0,11),(0,12); +CREATE TABLE t2 ( +a int(11) default NULL, +b int(11) default NULL, +KEY a (a) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (3,NULL),(3,11),(3,12); +SELECT * FROM t2 inner join t1 WHERE ( t1.a = 0 OR t1.a IS NULL) AND t2.a = 3 AND t2.b = t1.b; +a b a b +3 11 0 11 +3 12 0 12 +drop table t1, t2; +End of 5.0 tests +# +# Bug#54608 Query using IN + OR + IS TRUE and IS NULL returns +# NULL when should be empty +# +CREATE TABLE t1 (a INT, KEY (a)); +INSERT INTO t1 VALUES (1), (2), (NULL); +explain SELECT a FROM t1 WHERE a IN (42) OR (a IS TRUE AND a IS NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ref_or_null a a 5 const 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where ((`test`.`t1`.`a` = 42) or (((0 <> `test`.`t1`.`a`) is true) and (`test`.`t1`.`a` is null))) +SELECT a FROM t1 WHERE a IN (42) OR (a IS TRUE AND a IS NULL); +a +explain SELECT a FROM t1 WHERE a IN (42) OR (a=NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ref_or_null a a 5 const # 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where ((`test`.`t1`.`a` = 42) or (`test`.`t1`.`a` = NULL)) +SELECT a FROM t1 WHERE a IN (42) OR (a=NULL); +a +drop table t1; +SET sql_mode = default; +set optimizer_switch=default; diff --git a/mysql-test/r/null_key_icp_innodb.result-pq b/mysql-test/r/null_key_icp_innodb.result-pq new file mode 100644 index 000000000000..f7f8c53482f5 --- /dev/null +++ b/mysql-test/r/null_key_icp_innodb.result-pq @@ -0,0 +1,163 @@ +set optimizer_switch='index_condition_pushdown=on'; +SET sql_mode = 'NO_ENGINE_SUBSTITUTION'; +create table t1 (id int); +insert into t1 values (null), (0); +create table t2 (id int); +insert into t2 values (null); +select * from t1, t2 where t1.id = t2.id; +id id +alter table t1 add key id (id); +select * from t1, t2 where t1.id = t2.id; +id id +drop table t1,t2; +create table t1 ( +id integer, +id2 integer not null, +index (id), +index (id2) +); +insert into t1 values(null,null),(1,1); +Warnings: +Warning 1048 Column 'id2' cannot be null +select * from t1; +id id2 +NULL 0 +1 1 +select * from t1 where id <=> null; +id id2 +NULL 0 +select * from t1 where id <=> null or id > 0; +id id2 +NULL 0 +1 1 +select * from t1 where id is null or id > 0; +id id2 +NULL 0 +1 1 +select * from t1 where id2 <=> null or id2 > 0; +id id2 +1 1 +select * from t1 where id2 is null or id2 > 0; +id id2 +1 1 +delete from t1 where id <=> NULL; +select * from t1; +id id2 +1 1 +drop table t1; +CREATE TABLE t1 (a int); +CREATE TABLE t2 (a int, b int, INDEX idx(a)); +CREATE TABLE t3 (b int, INDEX idx(b)); +CREATE TABLE t4 (b int, INDEX idx(b)); +INSERT INTO t1 VALUES (1), (2), (3), (4); +INSERT INTO t2 VALUES (1, 1), (3, 1); +INSERT INTO t3 VALUES +(NULL), (NULL), (NULL), (NULL), (NULL), +(NULL), (NULL), (NULL), (NULL), (NULL); +INSERT INTO t4 SELECT * FROM t3; +INSERT INTO t3 SELECT * FROM t4; +INSERT INTO t4 SELECT * FROM t3; +INSERT INTO t3 SELECT * FROM t4; +INSERT INTO t4 SELECT * FROM t3; +INSERT INTO t3 SELECT * FROM t4; +INSERT INTO t4 SELECT * FROM t3; +INSERT INTO t3 SELECT * FROM t4; +INSERT INTO t4 SELECT * FROM t3; +INSERT INTO t3 SELECT * FROM t4; +INSERT INTO t4 SELECT * FROM t3; +INSERT INTO t3 SELECT * FROM t4; +INSERT INTO t4 SELECT * FROM t3; +INSERT INTO t3 SELECT * FROM t4; +INSERT INTO t4 SELECT * FROM t3; +INSERT INTO t3 SELECT * FROM t4; +INSERT INTO t3 VALUES (2), (3); +ANALYZE table t1, t2, t3; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +SELECT COUNT(*) FROM t3; +COUNT(*) +15972 +EXPLAIN SELECT SQL_CALC_FOUND_ROWS * FROM t1 LEFT JOIN t2 ON t1.a=t2.a +LEFT JOIN t3 ON t2.b=t3.b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL # 100.00 NULL +2 SIMPLE t2 NULL ALL idx NULL NULL NULL # 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t3 NULL ref idx idx 5 test.t2.b # 100.00 Using index +Warnings: +Warning 1287 SQL_CALC_FOUND_ROWS is deprecated and will be removed in a future release. Consider using two separate queries instead. +Note 1003 /* select#1 */ select sql_calc_found_rows `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`b` AS `b` from `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`a` = `test`.`t1`.`a`)) left join `test`.`t3` on((`test`.`t3`.`b` = `test`.`t2`.`b`)) where true +FLUSH STATUS ; +SELECT SQL_CALC_FOUND_ROWS * FROM t1 LEFT JOIN t2 ON t1.a=t2.a +LEFT JOIN t3 ON t2.b=t3.b; +a a b b +1 1 1 NULL +2 NULL NULL NULL +3 3 1 NULL +4 NULL NULL NULL +Warning 1287 SQL_CALC_FOUND_ROWS is deprecated and will be removed in a future release. Consider using two separate queries instead. +Warnings: +SELECT FOUND_ROWS(); +FOUND_ROWS() +4 +Warnings: +Warning 1287 FOUND_ROWS() is deprecated and will be removed in a future release. Consider using COUNT(*) instead. +SHOW STATUS LIKE "handler_read%"; +Variable_name Value +Handler_read_first 2 +Handler_read_key 4 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 8 +DROP TABLE t1,t2,t3,t4; +CREATE TABLE t1 ( +a int(11) default NULL, +b int(11) default NULL, +KEY a (a,b) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (0,10),(0,11),(0,12); +CREATE TABLE t2 ( +a int(11) default NULL, +b int(11) default NULL, +KEY a (a) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (3,NULL),(3,11),(3,12); +SELECT * FROM t2 inner join t1 WHERE ( t1.a = 0 OR t1.a IS NULL) AND t2.a = 3 AND t2.b = t1.b; +a b a b +3 11 0 11 +3 12 0 12 +drop table t1, t2; +End of 5.0 tests +# +# Bug#54608 Query using IN + OR + IS TRUE and IS NULL returns +# NULL when should be empty +# +CREATE TABLE t1 (a INT, KEY (a)); +INSERT INTO t1 VALUES (1), (2), (NULL); +explain SELECT a FROM t1 WHERE a IN (42) OR (a IS TRUE AND a IS NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ref_or_null a a 5 const 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where ((`test`.`t1`.`a` = 42) or (((0 <> `test`.`t1`.`a`) is true) and (`test`.`t1`.`a` is null))) +SELECT a FROM t1 WHERE a IN (42) OR (a IS TRUE AND a IS NULL); +a +explain SELECT a FROM t1 WHERE a IN (42) OR (a=NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ref_or_null a a 5 const # 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where ((`test`.`t1`.`a` = 42) or (`test`.`t1`.`a` = NULL)) +SELECT a FROM t1 WHERE a IN (42) OR (a=NULL); +a +drop table t1; +SET sql_mode = default; +set optimizer_switch=default; diff --git a/mysql-test/r/null_key_none_innodb.result-pq b/mysql-test/r/null_key_none_innodb.result-pq new file mode 100644 index 000000000000..c6e84d796c25 --- /dev/null +++ b/mysql-test/r/null_key_none_innodb.result-pq @@ -0,0 +1,162 @@ +SET sql_mode = 'NO_ENGINE_SUBSTITUTION'; +create table t1 (id int); +insert into t1 values (null), (0); +create table t2 (id int); +insert into t2 values (null); +select * from t1, t2 where t1.id = t2.id; +id id +alter table t1 add key id (id); +select * from t1, t2 where t1.id = t2.id; +id id +drop table t1,t2; +create table t1 ( +id integer, +id2 integer not null, +index (id), +index (id2) +); +insert into t1 values(null,null),(1,1); +Warnings: +Warning 1048 Column 'id2' cannot be null +select * from t1; +id id2 +NULL 0 +1 1 +select * from t1 where id <=> null; +id id2 +NULL 0 +select * from t1 where id <=> null or id > 0; +id id2 +NULL 0 +1 1 +select * from t1 where id is null or id > 0; +id id2 +NULL 0 +1 1 +select * from t1 where id2 <=> null or id2 > 0; +id id2 +1 1 +select * from t1 where id2 is null or id2 > 0; +id id2 +1 1 +delete from t1 where id <=> NULL; +select * from t1; +id id2 +1 1 +drop table t1; +CREATE TABLE t1 (a int); +CREATE TABLE t2 (a int, b int, INDEX idx(a)); +CREATE TABLE t3 (b int, INDEX idx(b)); +CREATE TABLE t4 (b int, INDEX idx(b)); +INSERT INTO t1 VALUES (1), (2), (3), (4); +INSERT INTO t2 VALUES (1, 1), (3, 1); +INSERT INTO t3 VALUES +(NULL), (NULL), (NULL), (NULL), (NULL), +(NULL), (NULL), (NULL), (NULL), (NULL); +INSERT INTO t4 SELECT * FROM t3; +INSERT INTO t3 SELECT * FROM t4; +INSERT INTO t4 SELECT * FROM t3; +INSERT INTO t3 SELECT * FROM t4; +INSERT INTO t4 SELECT * FROM t3; +INSERT INTO t3 SELECT * FROM t4; +INSERT INTO t4 SELECT * FROM t3; +INSERT INTO t3 SELECT * FROM t4; +INSERT INTO t4 SELECT * FROM t3; +INSERT INTO t3 SELECT * FROM t4; +INSERT INTO t4 SELECT * FROM t3; +INSERT INTO t3 SELECT * FROM t4; +INSERT INTO t4 SELECT * FROM t3; +INSERT INTO t3 SELECT * FROM t4; +INSERT INTO t4 SELECT * FROM t3; +INSERT INTO t3 SELECT * FROM t4; +INSERT INTO t3 VALUES (2), (3); +ANALYZE table t1, t2, t3; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +SELECT COUNT(*) FROM t3; +COUNT(*) +15972 +EXPLAIN SELECT SQL_CALC_FOUND_ROWS * FROM t1 LEFT JOIN t2 ON t1.a=t2.a +LEFT JOIN t3 ON t2.b=t3.b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL # 100.00 NULL +2 SIMPLE t2 NULL ALL idx NULL NULL NULL # 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t3 NULL ref idx idx 5 test.t2.b # 100.00 Using index +Warnings: +Warning 1287 SQL_CALC_FOUND_ROWS is deprecated and will be removed in a future release. Consider using two separate queries instead. +Note 1003 /* select#1 */ select sql_calc_found_rows `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`b` AS `b` from `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`a` = `test`.`t1`.`a`)) left join `test`.`t3` on((`test`.`t3`.`b` = `test`.`t2`.`b`)) where true +FLUSH STATUS ; +SELECT SQL_CALC_FOUND_ROWS * FROM t1 LEFT JOIN t2 ON t1.a=t2.a +LEFT JOIN t3 ON t2.b=t3.b; +a a b b +1 1 1 NULL +2 NULL NULL NULL +3 3 1 NULL +4 NULL NULL NULL +Warning 1287 SQL_CALC_FOUND_ROWS is deprecated and will be removed in a future release. Consider using two separate queries instead. +Warnings: +SELECT FOUND_ROWS(); +FOUND_ROWS() +4 +Warnings: +Warning 1287 FOUND_ROWS() is deprecated and will be removed in a future release. Consider using COUNT(*) instead. +SHOW STATUS LIKE "handler_read%"; +Variable_name Value +Handler_read_first 2 +Handler_read_key 4 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 8 +DROP TABLE t1,t2,t3,t4; +CREATE TABLE t1 ( +a int(11) default NULL, +b int(11) default NULL, +KEY a (a,b) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (0,10),(0,11),(0,12); +CREATE TABLE t2 ( +a int(11) default NULL, +b int(11) default NULL, +KEY a (a) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (3,NULL),(3,11),(3,12); +SELECT * FROM t2 inner join t1 WHERE ( t1.a = 0 OR t1.a IS NULL) AND t2.a = 3 AND t2.b = t1.b; +a b a b +3 11 0 11 +3 12 0 12 +drop table t1, t2; +End of 5.0 tests +# +# Bug#54608 Query using IN + OR + IS TRUE and IS NULL returns +# NULL when should be empty +# +CREATE TABLE t1 (a INT, KEY (a)); +INSERT INTO t1 VALUES (1), (2), (NULL); +explain SELECT a FROM t1 WHERE a IN (42) OR (a IS TRUE AND a IS NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ref_or_null a a 5 const 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where ((`test`.`t1`.`a` = 42) or (((0 <> `test`.`t1`.`a`) is true) and (`test`.`t1`.`a` is null))) +SELECT a FROM t1 WHERE a IN (42) OR (a IS TRUE AND a IS NULL); +a +explain SELECT a FROM t1 WHERE a IN (42) OR (a=NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ref_or_null a a 5 const # 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where ((`test`.`t1`.`a` = 42) or (`test`.`t1`.`a` = NULL)) +SELECT a FROM t1 WHERE a IN (42) OR (a=NULL); +a +drop table t1; +SET sql_mode = default; +set optimizer_switch=default; diff --git a/mysql-test/r/opt_costmodel.result-pq b/mysql-test/r/opt_costmodel.result-pq new file mode 100644 index 000000000000..26877e6205ca --- /dev/null +++ b/mysql-test/r/opt_costmodel.result-pq @@ -0,0 +1,597 @@ +# +# Bug#20443863 USE OF WORST_SEEKS IN FIND_BEST_REF() CAN LEAD TO +# WRONG QUERY PLAN +# +CREATE TABLE t1 ( +i1 INTEGER, +i2 INTEGER, +i3 INTEGER, +KEY(i1,i2) +) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1, 1, 1), (1, 1, 1),(1, 1, 1),(1, 1, 1), +(2, 2, 1), (2, 2, 1),(2, 2, 1),(2, 2, 1), +(3, 3, 1), (3, 3, 1),(3, 3, 1),(3, 3, 1); +EXPLAIN FORMAT=JSON SELECT i3 FROM t1 WHERE i1 = 1 AND i2 = 1; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.90" + }, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 4, + "rows_produced_per_join": 4, + "filtered": "100.00", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.40", + "prefix_cost": "0.90", + "data_read_per_join": "64" + }, + "used_columns": [ + "i3" + ], + "query_block": { + "cost_info": { + "query_cost": "0.90" + }, + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "ref", + "possible_keys": [ + "i1" + ], + "key": "i1", + "used_key_parts": [ + "i1", + "i2" + ], + "key_length": "10", + "ref": [ + "const", + "const" + ], + "rows_examined_per_scan": 4, + "rows_produced_per_join": 4, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.40", + "prefix_cost": "0.90", + "data_read_per_join": "64" + }, + "used_columns": [ + "i1", + "i2", + "i3" + ] + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i3` AS `i3` from `test`.`t1` where ((`test`.`t1`.`i2` = 1) and (`test`.`t1`.`i1` = 1)) +EXPLAIN FORMAT=JSON SELECT i3 FROM t1 WHERE i1 = 1 AND i3 = 1; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.90" + }, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 4, + "rows_produced_per_join": 0, + "filtered": "10.00", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.04", + "prefix_cost": "0.90", + "data_read_per_join": "6" + }, + "used_columns": [ + "i3" + ], + "query_block": { + "cost_info": { + "query_cost": "0.90" + }, + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "ref", + "possible_keys": [ + "i1" + ], + "key": "i1", + "used_key_parts": [ + "i1" + ], + "key_length": "5", + "ref": [ + "const" + ], + "rows_examined_per_scan": 4, + "rows_produced_per_join": 0, + "filtered": "10.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.04", + "prefix_cost": "0.90", + "data_read_per_join": "6" + }, + "used_columns": [ + "i1", + "i3" + ], + "attached_condition": "(`test`.`t1`.`i3` = 1)" + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i3` AS `i3` from `test`.`t1` where ((`test`.`t1`.`i3` = 1) and (`test`.`t1`.`i1` = 1)) +UPDATE mysql.server_cost +SET cost_value=0.1 +WHERE cost_name="row_evaluate_cost"; +UPDATE mysql.server_cost +SET cost_value=0.05 +WHERE cost_name="key_compare_cost"; +UPDATE mysql.server_cost +SET cost_value=1.0 +WHERE cost_name="memory_temptable_create_cost"; +UPDATE mysql.server_cost +SET cost_value=0.1 +WHERE cost_name="memory_temptable_row_cost"; +UPDATE mysql.server_cost +SET cost_value=20 +WHERE cost_name="disk_temptable_create_cost"; +UPDATE mysql.server_cost +SET cost_value=0.5 +WHERE cost_name="disk_temptable_row_cost"; +UPDATE mysql.engine_cost +SET cost_value=0.25 +WHERE cost_name="memory_block_read_cost"; +UPDATE mysql.engine_cost +SET cost_value=1.0 +WHERE cost_name="io_block_read_cost"; +UPDATE mysql.server_cost +SET cost_value = 2 * cost_value; +UPDATE mysql.engine_cost +SET cost_value = 2 * cost_value; +SELECT cost_name, cost_value FROM mysql.server_cost; +cost_name cost_value +disk_temptable_create_cost 40 +disk_temptable_row_cost 1 +key_compare_cost 0.1 +memory_temptable_create_cost 2 +memory_temptable_row_cost 0.2 +row_evaluate_cost 0.2 +SELECT cost_name, cost_value FROM mysql.engine_cost; +cost_name cost_value +io_block_read_cost 2 +memory_block_read_cost 0.5 +FLUSH OPTIMIZER_COSTS; +EXPLAIN FORMAT=JSON SELECT i3 FROM t1 WHERE i1 = 1 AND i2 = 1; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.80" + }, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 4, + "rows_produced_per_join": 4, + "filtered": "100.00", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "1.00", + "eval_cost": "0.80", + "prefix_cost": "1.80", + "data_read_per_join": "64" + }, + "used_columns": [ + "i3" + ], + "query_block": { + "cost_info": { + "query_cost": "1.80" + }, + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "ref", + "possible_keys": [ + "i1" + ], + "key": "i1", + "used_key_parts": [ + "i1", + "i2" + ], + "key_length": "10", + "ref": [ + "const", + "const" + ], + "rows_examined_per_scan": 4, + "rows_produced_per_join": 4, + "filtered": "100.00", + "cost_info": { + "read_cost": "1.00", + "eval_cost": "0.80", + "prefix_cost": "1.80", + "data_read_per_join": "64" + }, + "used_columns": [ + "i1", + "i2", + "i3" + ] + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i3` AS `i3` from `test`.`t1` where ((`test`.`t1`.`i2` = 1) and (`test`.`t1`.`i1` = 1)) +EXPLAIN FORMAT=JSON SELECT i3 FROM t1 WHERE i1 = 1 AND i3 = 1; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.80" + }, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 4, + "rows_produced_per_join": 0, + "filtered": "10.00", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "1.00", + "eval_cost": "0.08", + "prefix_cost": "1.80", + "data_read_per_join": "6" + }, + "used_columns": [ + "i3" + ], + "query_block": { + "cost_info": { + "query_cost": "1.80" + }, + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "ref", + "possible_keys": [ + "i1" + ], + "key": "i1", + "used_key_parts": [ + "i1" + ], + "key_length": "5", + "ref": [ + "const" + ], + "rows_examined_per_scan": 4, + "rows_produced_per_join": 0, + "filtered": "10.00", + "cost_info": { + "read_cost": "1.00", + "eval_cost": "0.08", + "prefix_cost": "1.80", + "data_read_per_join": "6" + }, + "used_columns": [ + "i1", + "i3" + ], + "attached_condition": "(`test`.`t1`.`i3` = 1)" + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i3` AS `i3` from `test`.`t1` where ((`test`.`t1`.`i3` = 1) and (`test`.`t1`.`i1` = 1)) +UPDATE mysql.server_cost +SET cost_value=DEFAULT; +UPDATE mysql.engine_cost +SET cost_value=DEFAULT; +FLUSH OPTIMIZER_COSTS; +DROP TABLE t1; +# +# Bug#20947871 INDEX SCAN COST IN TEST_IF_CHEAPER_ORDERING() DOES +# NOT USE COST CONSTANTS +# +CREATE TABLE t1 ( +pk INTEGER PRIMARY KEY, +a INTEGER, +b INTEGER, +c CHAR(255), +UNIQUE KEY k1 (a) +); +INSERT INTO t1 VALUES (1, 1, NULL, "Abc"), (2, 2, NULL, "Abc"), +(3, 3, NULL, "Abc"), (4, 4, NULL, "Abc"); +INSERT INTO t1 SELECT a + 4, a + 4, b, c FROM t1; +INSERT INTO t1 SELECT a + 8, a + 8, b, c FROM t1; +INSERT INTO t1 SELECT a + 16, a + 16, b, c FROM t1; +INSERT INTO t1 SELECT a + 32, a + 32, b, c FROM t1; +INSERT INTO t1 SELECT a + 64, a + 64, b, c FROM t1; +INSERT INTO t1 SELECT a + 128, a + 128, b, c FROM t1; +CREATE TABLE t2 ( +d INTEGER PRIMARY KEY, +e INTEGER +); +INSERT INTO t2 SELECT a, b FROM t1; +# Query should be optimized for the LIMIT. Query plan should +# use index without filesort +EXPLAIN FORMAT=JSON SELECT * FROM t1 JOIN t2 ON b=d ORDER BY a LIMIT 4; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "116.95" + }, + "ordering_operation": { + "using_filesort": false, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 4, + "rows_produced_per_join": 256, + "filtered": "100.00", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "1.75", + "eval_cost": "25.60", + "prefix_cost": "27.35", + "data_read_per_join": "262K" + }, + "used_columns": [ + "pk", + "a", + "b", + "c", + "d", + "e" + ], + "ordering_operation": { + "using_filesort": false, + "nested_loop": [ + { + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "index", + "key": "k1", + "used_key_parts": [ + "a" + ], + "key_length": "5", + "rows_examined_per_scan": 4, + "rows_produced_per_join": 256, + "filtered": "100.00", + "cost_info": { + "read_cost": "1.75", + "eval_cost": "25.60", + "prefix_cost": "27.35", + "data_read_per_join": "260K" + }, + "used_columns": [ + "pk", + "a", + "b", + "c" + ], + "attached_condition": "(`test`.`t1`.`b` is not null)" + } + }, + { + "table": { + "select_id": 2, + "table_name": "t2", + "access_type": "eq_ref", + "possible_keys": [ + "PRIMARY" + ], + "key": "PRIMARY", + "used_key_parts": [ + "d" + ], + "key_length": "4", + "ref": [ + "test.t1.b" + ], + "rows_examined_per_scan": 1, + "rows_produced_per_join": 256, + "filtered": "100.00", + "cost_info": { + "read_cost": "64.00", + "eval_cost": "25.60", + "prefix_cost": "116.95", + "data_read_per_join": "4K" + }, + "used_columns": [ + "d", + "e" + ] + } + } + ] + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c`,`test`.`t2`.`d` AS `d`,`test`.`t2`.`e` AS `e` from `test`.`t1` join `test`.`t2` where (`test`.`t2`.`d` = `test`.`t1`.`b`) order by `test`.`t1`.`a` limit 4 +UPDATE mysql.server_cost +SET cost_value=0.1 +WHERE cost_name="row_evaluate_cost"; +UPDATE mysql.server_cost +SET cost_value=0.05 +WHERE cost_name="key_compare_cost"; +UPDATE mysql.server_cost +SET cost_value=1.0 +WHERE cost_name="memory_temptable_create_cost"; +UPDATE mysql.server_cost +SET cost_value=0.1 +WHERE cost_name="memory_temptable_row_cost"; +UPDATE mysql.server_cost +SET cost_value=20 +WHERE cost_name="disk_temptable_create_cost"; +UPDATE mysql.server_cost +SET cost_value=0.5 +WHERE cost_name="disk_temptable_row_cost"; +UPDATE mysql.engine_cost +SET cost_value=0.25 +WHERE cost_name="memory_block_read_cost"; +UPDATE mysql.engine_cost +SET cost_value=1.0 +WHERE cost_name="io_block_read_cost"; +UPDATE mysql.server_cost +SET cost_value = 0.5 * cost_value; +UPDATE mysql.engine_cost +SET cost_value = 0.5 * cost_value; +SELECT cost_name, cost_value FROM mysql.server_cost; +cost_name cost_value +disk_temptable_create_cost 10 +disk_temptable_row_cost 0.25 +key_compare_cost 0.025 +memory_temptable_create_cost 0.5 +memory_temptable_row_cost 0.05 +row_evaluate_cost 0.05 +SELECT cost_name, cost_value FROM mysql.engine_cost; +cost_name cost_value +io_block_read_cost 0.5 +memory_block_read_cost 0.125 +FLUSH OPTIMIZER_COSTS; +# This should be optimized for the LIMIT. Query plan should +# use index without filesort +EXPLAIN FORMAT=JSON SELECT * FROM t1 JOIN t2 ON b=d ORDER BY a LIMIT 4; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "58.47" + }, + "ordering_operation": { + "using_filesort": false, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 4, + "rows_produced_per_join": 256, + "filtered": "100.00", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.88", + "eval_cost": "12.80", + "prefix_cost": "13.68", + "data_read_per_join": "262K" + }, + "used_columns": [ + "pk", + "a", + "b", + "c", + "d", + "e" + ], + "ordering_operation": { + "using_filesort": false, + "nested_loop": [ + { + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "index", + "key": "k1", + "used_key_parts": [ + "a" + ], + "key_length": "5", + "rows_examined_per_scan": 4, + "rows_produced_per_join": 256, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.88", + "eval_cost": "12.80", + "prefix_cost": "13.68", + "data_read_per_join": "260K" + }, + "used_columns": [ + "pk", + "a", + "b", + "c" + ], + "attached_condition": "(`test`.`t1`.`b` is not null)" + } + }, + { + "table": { + "select_id": 2, + "table_name": "t2", + "access_type": "eq_ref", + "possible_keys": [ + "PRIMARY" + ], + "key": "PRIMARY", + "used_key_parts": [ + "d" + ], + "key_length": "4", + "ref": [ + "test.t1.b" + ], + "rows_examined_per_scan": 1, + "rows_produced_per_join": 256, + "filtered": "100.00", + "cost_info": { + "read_cost": "32.00", + "eval_cost": "12.80", + "prefix_cost": "58.48", + "data_read_per_join": "4K" + }, + "used_columns": [ + "d", + "e" + ] + } + } + ] + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c`,`test`.`t2`.`d` AS `d`,`test`.`t2`.`e` AS `e` from `test`.`t1` join `test`.`t2` where (`test`.`t2`.`d` = `test`.`t1`.`b`) order by `test`.`t1`.`a` limit 4 +UPDATE mysql.server_cost +SET cost_value=DEFAULT; +UPDATE mysql.engine_cost +SET cost_value=DEFAULT; +FLUSH OPTIMIZER_COSTS; +DROP TABLE t1, t2; diff --git a/mysql-test/r/opt_costmodel_flush.result-pq b/mysql-test/r/opt_costmodel_flush.result-pq new file mode 100644 index 000000000000..94b25b9f248f --- /dev/null +++ b/mysql-test/r/opt_costmodel_flush.result-pq @@ -0,0 +1,1163 @@ +CREATE TABLE t0 ( +i1 INTEGER +); +INSERT INTO t0 VALUE (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +CREATE TABLE t1 ( +pk INTEGER PRIMARY KEY, +i1 INTEGER NOT NULL, +c1 CHAR(250), +c2 CHAR(250), +c3 CHAR(250), +c4 CHAR(250), +INDEX i1_key (i1) +) ENGINE=InnoDB; +# Since ANALYZE TABLE only reads a subset of the data, the statistics for +# table t1 depends on the row order. And since the INSERT INTO ... SELECT +# may be executed using different execution plans, we've added ORDER BY +# to ensure that we rows has the same order every time. If not, the +# estimated number of rows in EXPLAIN may change on different platforms. +INSERT INTO t1 +SELECT a0.i1 + 10 * a1.i1, a0.i1, 'abc', 'def', 'ghi', 'jkl' +FROM t0 AS a0, t0 AS a1 ORDER BY a0.i1, a1.i1; +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN FORMAT=JSON SELECT * FROM t1; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "12.75" + }, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 100, + "rows_produced_per_join": 100, + "filtered": "100.00", + "parallel_execute": "4 workers", + "cost_info": { + "read_cost": "2.75", + "eval_cost": "10.00", + "prefix_cost": "12.75", + "data_read_per_join": "392K" + }, + "used_columns": [ + "pk", + "i1", + "c1", + "c2", + "c3", + "c4" + ], + "query_block": { + "cost_info": { + "query_cost": "12.75" + }, + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 100, + "rows_produced_per_join": 100, + "filtered": "100.00", + "cost_info": { + "read_cost": "2.75", + "eval_cost": "10.00", + "prefix_cost": "12.75", + "data_read_per_join": "392K" + }, + "used_columns": [ + "pk", + "i1", + "c1", + "c2", + "c3", + "c4" + ] + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`i1` AS `i1`,`test`.`t1`.`c1` AS `c1`,`test`.`t1`.`c2` AS `c2`,`test`.`t1`.`c3` AS `c3`,`test`.`t1`.`c4` AS `c4` from `test`.`t1` +# +# Test that updating the cost constants does not influence on an +# existing connection +# +UPDATE mysql.server_cost +SET cost_value=0.4 +WHERE cost_name="row_evaluate_cost"; +FLUSH OPTIMIZER_COSTS; +# +# The cost estimates should not have changed +# +EXPLAIN FORMAT=JSON SELECT * FROM t1; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "12.75" + }, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 100, + "rows_produced_per_join": 100, + "filtered": "100.00", + "parallel_execute": "4 workers", + "cost_info": { + "read_cost": "2.75", + "eval_cost": "10.00", + "prefix_cost": "12.75", + "data_read_per_join": "392K" + }, + "used_columns": [ + "pk", + "i1", + "c1", + "c2", + "c3", + "c4" + ], + "query_block": { + "cost_info": { + "query_cost": "12.75" + }, + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 100, + "rows_produced_per_join": 100, + "filtered": "100.00", + "cost_info": { + "read_cost": "2.75", + "eval_cost": "40.00", + "prefix_cost": "12.75", + "data_read_per_join": "392K" + }, + "used_columns": [ + "pk", + "i1", + "c1", + "c2", + "c3", + "c4" + ] + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`i1` AS `i1`,`test`.`t1`.`c1` AS `c1`,`test`.`t1`.`c2` AS `c2`,`test`.`t1`.`c3` AS `c3`,`test`.`t1`.`c4` AS `c4` from `test`.`t1` +UPDATE mysql.server_cost +SET cost_value=DEFAULT; +# +# Test effect of changing the row_evalute_cost +# +UPDATE mysql.server_cost +SET cost_value=0.2 +WHERE cost_name="row_evaluate_cost"; +FLUSH OPTIMIZER_COSTS; +# +# Verify that the cost estimate for evalution cost has doubled +# +EXPLAIN FORMAT=JSON SELECT * FROM t1; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "22.75" + }, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 100, + "rows_produced_per_join": 100, + "filtered": "100.00", + "parallel_execute": "4 workers", + "cost_info": { + "read_cost": "2.75", + "eval_cost": "20.00", + "prefix_cost": "22.75", + "data_read_per_join": "392K" + }, + "used_columns": [ + "pk", + "i1", + "c1", + "c2", + "c3", + "c4" + ], + "query_block": { + "cost_info": { + "query_cost": "22.75" + }, + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 100, + "rows_produced_per_join": 100, + "filtered": "100.00", + "cost_info": { + "read_cost": "2.75", + "eval_cost": "20.00", + "prefix_cost": "22.75", + "data_read_per_join": "392K" + }, + "used_columns": [ + "pk", + "i1", + "c1", + "c2", + "c3", + "c4" + ] + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`i1` AS `i1`,`test`.`t1`.`c1` AS `c1`,`test`.`t1`.`c2` AS `c2`,`test`.`t1`.`c3` AS `c3`,`test`.`t1`.`c4` AS `c4` from `test`.`t1` +UPDATE mysql.server_cost +SET cost_value=DEFAULT; +# +# Test effect of changing key_compare_cost +# +# Use a query that will use loose index scan since loose index scan +# is comparing keys in order to determine group boundaries. +# Result from running query with default cost constants: +# +EXPLAIN FORMAT=JSON SELECT DISTINCT(i1) FROM t1; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "3.00" + }, + "duplicates_removal": { + "using_filesort": false, + "table": { + "table_name": "t1", + "access_type": "range", + "possible_keys": [ + "i1_key" + ], + "key": "i1_key", + "used_key_parts": [ + "i1" + ], + "key_length": "4", + "rows_examined_per_scan": 11, + "rows_produced_per_join": 11, + "filtered": "100.00", + "using_index_for_group_by": true, + "cost_info": { + "read_cost": "1.90", + "eval_cost": "1.10", + "prefix_cost": "3.00", + "data_read_per_join": "43K" + }, + "used_columns": [ + "pk", + "i1" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select distinct `test`.`t1`.`i1` AS `i1` from `test`.`t1` +UPDATE mysql.server_cost +SET cost_value=0.1 +WHERE cost_name="key_compare_cost"; +FLUSH OPTIMIZER_COSTS; +# +# Verify that the cost estimate for read cost is increased +# +EXPLAIN FORMAT=JSON SELECT DISTINCT(i1) FROM t1; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "3.55" + }, + "duplicates_removal": { + "using_filesort": false, + "table": { + "table_name": "t1", + "access_type": "range", + "possible_keys": [ + "i1_key" + ], + "key": "i1_key", + "used_key_parts": [ + "i1" + ], + "key_length": "4", + "rows_examined_per_scan": 11, + "rows_produced_per_join": 11, + "filtered": "100.00", + "using_index_for_group_by": true, + "cost_info": { + "read_cost": "2.45", + "eval_cost": "1.10", + "prefix_cost": "3.55", + "data_read_per_join": "43K" + }, + "used_columns": [ + "pk", + "i1" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select distinct `test`.`t1`.`i1` AS `i1` from `test`.`t1` +UPDATE mysql.server_cost +SET cost_value=DEFAULT; +# +# Test effect of changing memory_temptable_create_cost +# +# Use a query that creates a temporary table for a subquery. +# Run query with default cost constants. +# +EXPLAIN FORMAT=JSON SELECT * FROM t1 +WHERE i1 IN (SELECT i1 FROM t1); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "46.50" + }, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "possible_keys": [ + "i1_key" + ], + "rows_examined_per_scan": 100, + "rows_produced_per_join": 100, + "filtered": "100.00", + "cost_info": { + "read_cost": "2.75", + "eval_cost": "10.00", + "prefix_cost": "12.75", + "data_read_per_join": "392K" + }, + "used_columns": [ + "pk", + "i1", + "c1", + "c2", + "c3", + "c4" + ] + } + }, + { + "table": { + "table_name": "", + "access_type": "eq_ref", + "key": "", + "key_length": "4", + "ref": [ + "test.t1.i1" + ], + "rows_examined_per_scan": 1, + "materialized_from_subquery": { + "using_temporary_table": true, + "query_block": { + "table": { + "table_name": "t1", + "access_type": "index", + "possible_keys": [ + "i1_key" + ], + "key": "i1_key", + "used_key_parts": [ + "i1" + ], + "key_length": "4", + "rows_examined_per_scan": 100, + "rows_produced_per_join": 100, + "filtered": "100.00", + "using_index": true, + "cost_info": { + "read_cost": "2.75", + "eval_cost": "10.00", + "prefix_cost": "12.75", + "data_read_per_join": "392K" + }, + "used_columns": [ + "i1" + ] + } + } + } + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`i1` AS `i1`,`test`.`t1`.`c1` AS `c1`,`test`.`t1`.`c2` AS `c2`,`test`.`t1`.`c3` AS `c3`,`test`.`t1`.`c4` AS `c4` from `test`.`t1` semi join (`test`.`t1`) where (``.`i1` = `test`.`t1`.`i1`) +UPDATE mysql.server_cost +SET cost_value=10.0 +WHERE cost_name="memory_temptable_create_cost"; +FLUSH OPTIMIZER_COSTS; +# +# Verify that the cost estimate for the query is incrased (by 9.0) +# +EXPLAIN FORMAT=JSON SELECT * FROM t1 +WHERE i1 IN (SELECT i1 FROM t1); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "55.50" + }, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "possible_keys": [ + "i1_key" + ], + "rows_examined_per_scan": 100, + "rows_produced_per_join": 100, + "filtered": "100.00", + "cost_info": { + "read_cost": "2.75", + "eval_cost": "10.00", + "prefix_cost": "12.75", + "data_read_per_join": "392K" + }, + "used_columns": [ + "pk", + "i1", + "c1", + "c2", + "c3", + "c4" + ] + } + }, + { + "table": { + "table_name": "", + "access_type": "eq_ref", + "key": "", + "key_length": "4", + "ref": [ + "test.t1.i1" + ], + "rows_examined_per_scan": 1, + "materialized_from_subquery": { + "using_temporary_table": true, + "query_block": { + "table": { + "table_name": "t1", + "access_type": "index", + "possible_keys": [ + "i1_key" + ], + "key": "i1_key", + "used_key_parts": [ + "i1" + ], + "key_length": "4", + "rows_examined_per_scan": 100, + "rows_produced_per_join": 100, + "filtered": "100.00", + "using_index": true, + "cost_info": { + "read_cost": "2.75", + "eval_cost": "10.00", + "prefix_cost": "12.75", + "data_read_per_join": "392K" + }, + "used_columns": [ + "i1" + ] + } + } + } + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`i1` AS `i1`,`test`.`t1`.`c1` AS `c1`,`test`.`t1`.`c2` AS `c2`,`test`.`t1`.`c3` AS `c3`,`test`.`t1`.`c4` AS `c4` from `test`.`t1` semi join (`test`.`t1`) where (``.`i1` = `test`.`t1`.`i1`) +UPDATE mysql.server_cost +SET cost_value=DEFAULT; +# +# Test effect of changing memory_temptable_row_cost +# +# Use a query that creates a temporary table for a subquery. +# Result from running query with default cost constants: +# +EXPLAIN FORMAT=JSON SELECT * FROM t1 +WHERE i1 IN (SELECT i1 FROM t1); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "46.50" + }, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "possible_keys": [ + "i1_key" + ], + "rows_examined_per_scan": 100, + "rows_produced_per_join": 100, + "filtered": "100.00", + "cost_info": { + "read_cost": "2.75", + "eval_cost": "10.00", + "prefix_cost": "12.75", + "data_read_per_join": "392K" + }, + "used_columns": [ + "pk", + "i1", + "c1", + "c2", + "c3", + "c4" + ] + } + }, + { + "table": { + "table_name": "", + "access_type": "eq_ref", + "key": "", + "key_length": "4", + "ref": [ + "test.t1.i1" + ], + "rows_examined_per_scan": 1, + "materialized_from_subquery": { + "using_temporary_table": true, + "query_block": { + "table": { + "table_name": "t1", + "access_type": "index", + "possible_keys": [ + "i1_key" + ], + "key": "i1_key", + "used_key_parts": [ + "i1" + ], + "key_length": "4", + "rows_examined_per_scan": 100, + "rows_produced_per_join": 100, + "filtered": "100.00", + "using_index": true, + "cost_info": { + "read_cost": "2.75", + "eval_cost": "10.00", + "prefix_cost": "12.75", + "data_read_per_join": "392K" + }, + "used_columns": [ + "i1" + ] + } + } + } + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`i1` AS `i1`,`test`.`t1`.`c1` AS `c1`,`test`.`t1`.`c2` AS `c2`,`test`.`t1`.`c3` AS `c3`,`test`.`t1`.`c4` AS `c4` from `test`.`t1` semi join (`test`.`t1`) where (``.`i1` = `test`.`t1`.`i1`) +UPDATE mysql.server_cost +SET cost_value=0.2 +WHERE cost_name="memory_temptable_row_cost"; +FLUSH OPTIMIZER_COSTS; +# +# Verify that the cost estimate for the query is incrased by: +# 100 rows that needs to be inserted and read from the temporary table. +# The cost of each insert and read is increased by 0.1, ie cost should +# be increased by 100 * 2 * 0.1 = 20. +# +EXPLAIN FORMAT=JSON SELECT * FROM t1 +WHERE i1 IN (SELECT i1 FROM t1); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "66.50" + }, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "possible_keys": [ + "i1_key" + ], + "rows_examined_per_scan": 100, + "rows_produced_per_join": 100, + "filtered": "100.00", + "cost_info": { + "read_cost": "2.75", + "eval_cost": "10.00", + "prefix_cost": "12.75", + "data_read_per_join": "392K" + }, + "used_columns": [ + "pk", + "i1", + "c1", + "c2", + "c3", + "c4" + ] + } + }, + { + "table": { + "table_name": "", + "access_type": "eq_ref", + "key": "", + "key_length": "4", + "ref": [ + "test.t1.i1" + ], + "rows_examined_per_scan": 1, + "materialized_from_subquery": { + "using_temporary_table": true, + "query_block": { + "table": { + "table_name": "t1", + "access_type": "index", + "possible_keys": [ + "i1_key" + ], + "key": "i1_key", + "used_key_parts": [ + "i1" + ], + "key_length": "4", + "rows_examined_per_scan": 100, + "rows_produced_per_join": 100, + "filtered": "100.00", + "using_index": true, + "cost_info": { + "read_cost": "2.75", + "eval_cost": "10.00", + "prefix_cost": "12.75", + "data_read_per_join": "392K" + }, + "used_columns": [ + "i1" + ] + } + } + } + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`i1` AS `i1`,`test`.`t1`.`c1` AS `c1`,`test`.`t1`.`c2` AS `c2`,`test`.`t1`.`c3` AS `c3`,`test`.`t1`.`c4` AS `c4` from `test`.`t1` semi join (`test`.`t1`) where (``.`i1` = `test`.`t1`.`i1`) +UPDATE mysql.server_cost +SET cost_value=DEFAULT; +set global internal_tmp_mem_storage_engine='memory'; +set session internal_tmp_mem_storage_engine='memory'; +set @max_heap_table_size_save= @@max_heap_table_size; +set max_heap_table_size= 16384; +# +# Test effect of changing disk_temptable_create_cost +# +# Use a query that creates a temporary table for a subquery. +# Result from running query with default cost constants: +# +EXPLAIN FORMAT=JSON SELECT * FROM t1 +WHERE c1 IN (SELECT c1 FROM t1); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "145.50" + }, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 100, + "rows_produced_per_join": 100, + "filtered": "100.00", + "cost_info": { + "read_cost": "2.75", + "eval_cost": "10.00", + "prefix_cost": "12.75", + "data_read_per_join": "392K" + }, + "used_columns": [ + "pk", + "i1", + "c1", + "c2", + "c3", + "c4" + ], + "attached_condition": "(`test`.`t1`.`c1` is not null)" + } + }, + { + "table": { + "table_name": "", + "access_type": "eq_ref", + "key": "", + "key_length": "1001", + "ref": [ + "test.t1.c1" + ], + "rows_examined_per_scan": 1, + "materialized_from_subquery": { + "using_temporary_table": true, + "query_block": { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 100, + "rows_produced_per_join": 100, + "filtered": "100.00", + "cost_info": { + "read_cost": "2.75", + "eval_cost": "10.00", + "prefix_cost": "12.75", + "data_read_per_join": "392K" + }, + "used_columns": [ + "c1" + ] + } + } + } + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`i1` AS `i1`,`test`.`t1`.`c1` AS `c1`,`test`.`t1`.`c2` AS `c2`,`test`.`t1`.`c3` AS `c3`,`test`.`t1`.`c4` AS `c4` from `test`.`t1` semi join (`test`.`t1`) where (``.`c1` = `test`.`t1`.`c1`) +UPDATE mysql.server_cost +SET cost_value=40.0 +WHERE cost_name="disk_temptable_create_cost"; +FLUSH OPTIMIZER_COSTS; +set max_heap_table_size= 16384; +# +# Verify that the cost estimate for the query is incrased (by 20.0) +# +EXPLAIN FORMAT=JSON SELECT * FROM t1 +WHERE c1 IN (SELECT c1 FROM t1); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "165.50" + }, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 100, + "rows_produced_per_join": 100, + "filtered": "100.00", + "cost_info": { + "read_cost": "2.75", + "eval_cost": "10.00", + "prefix_cost": "12.75", + "data_read_per_join": "392K" + }, + "used_columns": [ + "pk", + "i1", + "c1", + "c2", + "c3", + "c4" + ], + "attached_condition": "(`test`.`t1`.`c1` is not null)" + } + }, + { + "table": { + "table_name": "", + "access_type": "eq_ref", + "key": "", + "key_length": "1001", + "ref": [ + "test.t1.c1" + ], + "rows_examined_per_scan": 1, + "materialized_from_subquery": { + "using_temporary_table": true, + "query_block": { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 100, + "rows_produced_per_join": 100, + "filtered": "100.00", + "cost_info": { + "read_cost": "2.75", + "eval_cost": "10.00", + "prefix_cost": "12.75", + "data_read_per_join": "392K" + }, + "used_columns": [ + "c1" + ] + } + } + } + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`i1` AS `i1`,`test`.`t1`.`c1` AS `c1`,`test`.`t1`.`c2` AS `c2`,`test`.`t1`.`c3` AS `c3`,`test`.`t1`.`c4` AS `c4` from `test`.`t1` semi join (`test`.`t1`) where (``.`c1` = `test`.`t1`.`c1`) +UPDATE mysql.server_cost +SET cost_value=DEFAULT; +# +# Test effect of changing disk_temptable_row_cost +# +# Use a query that creates a temporary table for a subquery +# Result from running query with default cost constants: +# +EXPLAIN FORMAT=JSON SELECT * FROM t1 +WHERE c1 IN (SELECT c1 FROM t1); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "145.50" + }, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 100, + "rows_produced_per_join": 100, + "filtered": "100.00", + "cost_info": { + "read_cost": "2.75", + "eval_cost": "10.00", + "prefix_cost": "12.75", + "data_read_per_join": "392K" + }, + "used_columns": [ + "pk", + "i1", + "c1", + "c2", + "c3", + "c4" + ], + "attached_condition": "(`test`.`t1`.`c1` is not null)" + } + }, + { + "table": { + "table_name": "", + "access_type": "eq_ref", + "key": "", + "key_length": "1001", + "ref": [ + "test.t1.c1" + ], + "rows_examined_per_scan": 1, + "materialized_from_subquery": { + "using_temporary_table": true, + "query_block": { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 100, + "rows_produced_per_join": 100, + "filtered": "100.00", + "cost_info": { + "read_cost": "2.75", + "eval_cost": "10.00", + "prefix_cost": "12.75", + "data_read_per_join": "392K" + }, + "used_columns": [ + "c1" + ] + } + } + } + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`i1` AS `i1`,`test`.`t1`.`c1` AS `c1`,`test`.`t1`.`c2` AS `c2`,`test`.`t1`.`c3` AS `c3`,`test`.`t1`.`c4` AS `c4` from `test`.`t1` semi join (`test`.`t1`) where (``.`c1` = `test`.`t1`.`c1`) +UPDATE mysql.server_cost +SET cost_value=1.0 +WHERE cost_name="disk_temptable_row_cost"; +FLUSH OPTIMIZER_COSTS; +set max_heap_table_size= 16384; +# +# Verify that the cost estimate for the query is incrased by: +# 100 rows that needs to be inserted and read from the temporary table. +# The cost of each insert and read is increased by 0.5, ie cost should +# be increased by 100 * 2 * 0.5 = 100. +# +EXPLAIN FORMAT=JSON SELECT * FROM t1 +WHERE c1 IN (SELECT c1 FROM t1); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "245.50" + }, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 100, + "rows_produced_per_join": 100, + "filtered": "100.00", + "cost_info": { + "read_cost": "2.75", + "eval_cost": "10.00", + "prefix_cost": "12.75", + "data_read_per_join": "392K" + }, + "used_columns": [ + "pk", + "i1", + "c1", + "c2", + "c3", + "c4" + ], + "attached_condition": "(`test`.`t1`.`c1` is not null)" + } + }, + { + "table": { + "table_name": "", + "access_type": "eq_ref", + "key": "", + "key_length": "1001", + "ref": [ + "test.t1.c1" + ], + "rows_examined_per_scan": 1, + "materialized_from_subquery": { + "using_temporary_table": true, + "query_block": { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 100, + "rows_produced_per_join": 100, + "filtered": "100.00", + "cost_info": { + "read_cost": "2.75", + "eval_cost": "10.00", + "prefix_cost": "12.75", + "data_read_per_join": "392K" + }, + "used_columns": [ + "c1" + ] + } + } + } + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`i1` AS `i1`,`test`.`t1`.`c1` AS `c1`,`test`.`t1`.`c2` AS `c2`,`test`.`t1`.`c3` AS `c3`,`test`.`t1`.`c4` AS `c4` from `test`.`t1` semi join (`test`.`t1`) where (``.`c1` = `test`.`t1`.`c1`) +UPDATE mysql.server_cost +SET cost_value=DEFAULT; +set max_heap_table_size= @max_heap_table_size_save; +set session internal_tmp_mem_storage_engine=default; +set global internal_tmp_mem_storage_engine=default; +# +# Test effect of changing the memory_block_read_cost +# +# Result from running query with default cost constants: +# +EXPLAIN FORMAT=JSON SELECT * FROM t1; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "12.75" + }, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 100, + "rows_produced_per_join": 100, + "filtered": "100.00", + "parallel_execute": "4 workers", + "cost_info": { + "read_cost": "2.75", + "eval_cost": "10.00", + "prefix_cost": "12.75", + "data_read_per_join": "392K" + }, + "used_columns": [ + "pk", + "i1", + "c1", + "c2", + "c3", + "c4" + ], + "query_block": { + "cost_info": { + "query_cost": "12.75" + }, + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 100, + "rows_produced_per_join": 100, + "filtered": "100.00", + "cost_info": { + "read_cost": "2.75", + "eval_cost": "10.00", + "prefix_cost": "12.75", + "data_read_per_join": "392K" + }, + "used_columns": [ + "pk", + "i1", + "c1", + "c2", + "c3", + "c4" + ] + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`i1` AS `i1`,`test`.`t1`.`c1` AS `c1`,`test`.`t1`.`c2` AS `c2`,`test`.`t1`.`c3` AS `c3`,`test`.`t1`.`c4` AS `c4` from `test`.`t1` +UPDATE mysql.engine_cost +SET cost_value=0.5 +WHERE cost_name="memory_block_read_cost"; +FLUSH OPTIMIZER_COSTS; +# +# Verify that the cost estimate for read cost has doubled +# +EXPLAIN FORMAT=JSON SELECT * FROM t1; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "15.50" + }, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 100, + "rows_produced_per_join": 100, + "filtered": "100.00", + "parallel_execute": "4 workers", + "cost_info": { + "read_cost": "5.50", + "eval_cost": "10.00", + "prefix_cost": "15.50", + "data_read_per_join": "392K" + }, + "used_columns": [ + "pk", + "i1", + "c1", + "c2", + "c3", + "c4" + ], + "query_block": { + "cost_info": { + "query_cost": "15.50" + }, + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 100, + "rows_produced_per_join": 100, + "filtered": "100.00", + "cost_info": { + "read_cost": "5.50", + "eval_cost": "10.00", + "prefix_cost": "15.50", + "data_read_per_join": "392K" + }, + "used_columns": [ + "pk", + "i1", + "c1", + "c2", + "c3", + "c4" + ] + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`i1` AS `i1`,`test`.`t1`.`c1` AS `c1`,`test`.`t1`.`c2` AS `c2`,`test`.`t1`.`c3` AS `c3`,`test`.`t1`.`c4` AS `c4` from `test`.`t1` +UPDATE mysql.engine_cost +SET cost_value=DEFAULT; +FLUSH OPTIMIZER_COSTS; +DROP TABLE t0,t1; diff --git a/mysql-test/r/opt_costmodel_restart.result-pq b/mysql-test/r/opt_costmodel_restart.result-pq new file mode 100644 index 000000000000..e45c6c029d6a --- /dev/null +++ b/mysql-test/r/opt_costmodel_restart.result-pq @@ -0,0 +1,276 @@ +SELECT cost_name,cost_value FROM mysql.server_cost; +cost_name cost_value +disk_temptable_create_cost NULL +disk_temptable_row_cost NULL +key_compare_cost NULL +memory_temptable_create_cost NULL +memory_temptable_row_cost NULL +row_evaluate_cost NULL +SELECT engine_name,cost_name,cost_value FROM mysql.engine_cost; +engine_name cost_name cost_value +default io_block_read_cost NULL +default memory_block_read_cost NULL +CREATE TABLE t0 ( +i1 INTEGER +); +INSERT INTO t0 VALUE (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +CREATE TABLE t1_innodb ( +pk INTEGER PRIMARY KEY, +i1 INTEGER NOT NULL, +c1 CHAR(250), +c2 CHAR(250), +c3 CHAR(250), +c4 CHAR(250), +INDEX i1_key (i1) +) ENGINE=InnoDB; +# Since ANALYZE TABLE only reads a subset of the data, the statistics for +# table t1 depends on the row order. And since the INSERT INTO ... SELECT +# may be executed using different execution plans, we've added ORDER BY +# to ensure that we rows has the same order every time. If not, the +# estimated number of rows in EXPLAIN may change on different platforms. +INSERT INTO t1_innodb +SELECT a0.i1 + 10 * a1.i1, a0.i1, 'abc', 'def', 'ghi', 'jkl' +FROM t0 AS a0, t0 AS a1 ORDER BY a0.i1, a1.i1; +ANALYZE TABLE t1_innodb; +Table Op Msg_type Msg_text +test.t1_innodb analyze status OK +"Explain with cost estimate against InnoDB" +EXPLAIN FORMAT=JSON SELECT * FROM t1_innodb; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "12.75" + }, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 100, + "rows_produced_per_join": 100, + "filtered": "100.00", + "parallel_execute": "4 workers", + "cost_info": { + "read_cost": "2.75", + "eval_cost": "10.00", + "prefix_cost": "12.75", + "data_read_per_join": "392K" + }, + "used_columns": [ + "pk", + "i1", + "c1", + "c2", + "c3", + "c4" + ], + "query_block": { + "cost_info": { + "query_cost": "12.75" + }, + "table": { + "select_id": 2, + "table_name": "t1_innodb", + "access_type": "ALL", + "rows_examined_per_scan": 100, + "rows_produced_per_join": 100, + "filtered": "100.00", + "cost_info": { + "read_cost": "2.75", + "eval_cost": "10.00", + "prefix_cost": "12.75", + "data_read_per_join": "392K" + }, + "used_columns": [ + "pk", + "i1", + "c1", + "c2", + "c3", + "c4" + ] + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1_innodb`.`pk` AS `pk`,`test`.`t1_innodb`.`i1` AS `i1`,`test`.`t1_innodb`.`c1` AS `c1`,`test`.`t1_innodb`.`c2` AS `c2`,`test`.`t1_innodb`.`c3` AS `c3`,`test`.`t1_innodb`.`c4` AS `c4` from `test`.`t1_innodb` +UPDATE mysql.server_cost +SET cost_value=0.4 +WHERE cost_name="row_evaluate_cost"; +UPDATE mysql.engine_cost +SET cost_value=2.0 +WHERE cost_name="memory_block_read_cost"; +UPDATE mysql.engine_cost +SET cost_value=2.0 +WHERE cost_name="io_block_read_cost"; +"Restarting MySQL server" +# restart +"MySQL restarted" +SELECT cost_name, cost_value FROM mysql.server_cost; +cost_name cost_value +disk_temptable_create_cost NULL +disk_temptable_row_cost NULL +key_compare_cost NULL +memory_temptable_create_cost NULL +memory_temptable_row_cost NULL +row_evaluate_cost 0.4 +SELECT engine_name, cost_name, cost_value FROM mysql.engine_cost; +engine_name cost_name cost_value +default io_block_read_cost 2 +default memory_block_read_cost 2 +"Explain with cost estimate against MyISAM" +EXPLAIN FORMAT=JSON SELECT * FROM t1_innodb; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "62.00" + }, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 100, + "rows_produced_per_join": 100, + "filtered": "100.00", + "parallel_execute": "4 workers", + "cost_info": { + "read_cost": "22.00", + "eval_cost": "40.00", + "prefix_cost": "62.00", + "data_read_per_join": "392K" + }, + "used_columns": [ + "pk", + "i1", + "c1", + "c2", + "c3", + "c4" + ], + "query_block": { + "cost_info": { + "query_cost": "62.00" + }, + "table": { + "select_id": 2, + "table_name": "t1_innodb", + "access_type": "ALL", + "rows_examined_per_scan": 100, + "rows_produced_per_join": 100, + "filtered": "100.00", + "cost_info": { + "read_cost": "22.00", + "eval_cost": "40.00", + "prefix_cost": "62.00", + "data_read_per_join": "392K" + }, + "used_columns": [ + "pk", + "i1", + "c1", + "c2", + "c3", + "c4" + ] + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1_innodb`.`pk` AS `pk`,`test`.`t1_innodb`.`i1` AS `i1`,`test`.`t1_innodb`.`c1` AS `c1`,`test`.`t1_innodb`.`c2` AS `c2`,`test`.`t1_innodb`.`c3` AS `c3`,`test`.`t1_innodb`.`c4` AS `c4` from `test`.`t1_innodb` +UPDATE mysql.server_cost +SET cost_value=DEFAULT; +UPDATE mysql.engine_cost +SET cost_value=DEFAULT; +INSERT INTO mysql.engine_cost VALUES +("InnoDB", 0, "memory_block_read_cost", 4.0, CURRENT_TIMESTAMP, DEFAULT, DEFAULT); +INSERT INTO mysql.engine_cost VALUES +("InnoDB", 0, "io_block_read_cost", 4.0, CURRENT_TIMESTAMP, DEFAULT, DEFAULT); +"Restarting MySQL server" +# restart +"MySQL restarted" +SELECT cost_name, cost_value FROM mysql.server_cost; +cost_name cost_value +disk_temptable_create_cost NULL +disk_temptable_row_cost NULL +key_compare_cost NULL +memory_temptable_create_cost NULL +memory_temptable_row_cost NULL +row_evaluate_cost NULL +SELECT engine_name, cost_name, cost_value FROM mysql.engine_cost; +engine_name cost_name cost_value +default io_block_read_cost NULL +InnoDB io_block_read_cost 4 +default memory_block_read_cost NULL +InnoDB memory_block_read_cost 4 +"Explain with cost estimate against InnoDB" +EXPLAIN FORMAT=JSON SELECT * FROM t1_innodb; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "54.00" + }, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 100, + "rows_produced_per_join": 100, + "filtered": "100.00", + "parallel_execute": "4 workers", + "cost_info": { + "read_cost": "44.00", + "eval_cost": "10.00", + "prefix_cost": "54.00", + "data_read_per_join": "392K" + }, + "used_columns": [ + "pk", + "i1", + "c1", + "c2", + "c3", + "c4" + ], + "query_block": { + "cost_info": { + "query_cost": "54.00" + }, + "table": { + "select_id": 2, + "table_name": "t1_innodb", + "access_type": "ALL", + "rows_examined_per_scan": 100, + "rows_produced_per_join": 100, + "filtered": "100.00", + "cost_info": { + "read_cost": "44.00", + "eval_cost": "10.00", + "prefix_cost": "54.00", + "data_read_per_join": "392K" + }, + "used_columns": [ + "pk", + "i1", + "c1", + "c2", + "c3", + "c4" + ] + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1_innodb`.`pk` AS `pk`,`test`.`t1_innodb`.`i1` AS `i1`,`test`.`t1_innodb`.`c1` AS `c1`,`test`.`t1_innodb`.`c2` AS `c2`,`test`.`t1_innodb`.`c3` AS `c3`,`test`.`t1_innodb`.`c4` AS `c4` from `test`.`t1_innodb` +DELETE FROM mysql.engine_cost +WHERE engine_name NOT LIKE "default"; +"Restarting MySQL server" +# restart +DROP TABLE t0, t1_innodb; diff --git a/mysql-test/r/opt_hint_timeout.result-pq b/mysql-test/r/opt_hint_timeout.result-pq new file mode 100644 index 000000000000..98d1d117b28b --- /dev/null +++ b/mysql-test/r/opt_hint_timeout.result-pq @@ -0,0 +1,74 @@ +# WL#8017 Infrastructure for Optimizer Hints +# MAX_EXECUTION_TIME hint testing +# MAX_EXECUTION_TIME hint testing +CREATE TABLE t1 (a INT, b VARCHAR(300)); +INSERT INTO t1 VALUES (1, 'string'); +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +SELECT /*+ MAX_EXECUTION_TIME(1) */ * FROM t1 a, t1 b; +ERROR HY000: Query execution was interrupted, maximum statement execution time exceeded +EXPLAIN SELECT /*+ MAX_EXECUTION_TIME(10) MAX_EXECUTION_TIME(100) */ * FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2048 100.00 Parallel execute (4 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2048 100.00 NULL +Warnings: +Warning 3126 Hint MAX_EXECUTION_TIME(100) is ignored as conflicting/duplicated +Note 1003 /* select#1 */ select /*+ MAX_EXECUTION_TIME(10) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` +DROP TABLE t1; + +# test the MAX_EXECUTION_TIME hint for SELECT statements: + +CREATE TABLE t1 (i INT, j INT); +CREATE INDEX i1 ON t1(i); +CREATE INDEX i2 ON t1(j); +INSERT INTO t1 VALUES (1, 1), (2, 2); +SELECT /*+ MAX_EXECUTION_TIME(4294967296) */ 1 FROM t1; +1 +1 +1 +Warnings: +Warning 1064 Unsupported MAX_EXECUTION_TIME near ') */ 1 FROM t1' at line 1 +SELECT /*+ MAX_EXECUTION_TIME(1) */ *, SLEEP(1000) FROM t1; +ERROR HY000: Query execution was interrupted, maximum statement execution time exceeded +SELECT /*+ MAX_EXECUTION_TIME(1) */ *, SLEEP(1000) FROM t1 UNION SELECT 1, 2, 3; +ERROR HY000: Query execution was interrupted, maximum statement execution time exceeded +(SELECT /*+ MAX_EXECUTION_TIME(1) */ *, SLEEP(1000) FROM t1) UNION (SELECT 1, 2, 3); +ERROR HY000: Query execution was interrupted, maximum statement execution time exceeded +((SELECT /*+ MAX_EXECUTION_TIME(1) */ *, SLEEP(1000) FROM t1)); +ERROR HY000: Query execution was interrupted, maximum statement execution time exceeded + +# only SELECT statements supports the MAX_EXECUTION_TIME hint (warning): + +CREATE TABLE t2 (i INT); +INSERT /*+ MAX_EXECUTION_TIME(1) */ INTO t2 SELECT 1; +Warnings: +Warning 3125 MAX_EXECUTION_TIME hint is supported by top-level standalone SELECT statements only +REPLACE /*+ MAX_EXECUTION_TIME(1) */ INTO t2 SELECT 1; +Warnings: +Warning 3125 MAX_EXECUTION_TIME hint is supported by top-level standalone SELECT statements only +UPDATE /*+ MAX_EXECUTION_TIME(1) */ t2 SET i = 1; +Warnings: +Warning 3125 MAX_EXECUTION_TIME hint is supported by top-level standalone SELECT statements only +DELETE /*+ MAX_EXECUTION_TIME(1) */ FROM t2 WHERE i = 1; +Warnings: +Warning 3125 MAX_EXECUTION_TIME hint is supported by top-level standalone SELECT statements only +DROP TABLE t1, t2; +SELECT 1 FROM (SELECT /*+ MAX_EXECUTION_TIME(10) */ 1) a; +1 +1 +Warnings: +Warning 3125 MAX_EXECUTION_TIME hint is supported by top-level standalone SELECT statements only +CREATE FUNCTION f1() RETURNS INT BEGIN SELECT /*+ MAX_EXECUTION_TIME(10) */ 1 +INTO @a; RETURN 1; END| +Warnings: +Warning 3125 MAX_EXECUTION_TIME hint is supported by top-level standalone SELECT statements only +DROP FUNCTION f1; diff --git a/mysql-test/r/opt_hints.result-pq b/mysql-test/r/opt_hints.result-pq new file mode 100644 index 000000000000..6ef02c6376ed --- /dev/null +++ b/mysql-test/r/opt_hints.result-pq @@ -0,0 +1,2315 @@ +# WL#8017 Infrastructure for Optimizer Hints +CREATE TABLE t1(f1 INT, f2 INT); +INSERT INTO t1 VALUES +(1,1),(2,2),(3,3); +CREATE TABLE t2(f1 INT NOT NULL, f2 INT NOT NULL, f3 CHAR(200), KEY(f1, f2)); +INSERT INTO t2 VALUES +(1,1, 'qwerty'),(1,2, 'qwerty'),(1,3, 'qwerty'), +(2,1, 'qwerty'),(2,2, 'qwerty'),(2,3, 'qwerty'), (2,4, 'qwerty'),(2,5, 'qwerty'), +(3,1, 'qwerty'),(3,4, 'qwerty'), +(4,1, 'qwerty'),(4,2, 'qwerty'),(4,3, 'qwerty'), (4,4, 'qwerty'), +(1,1, 'qwerty'),(1,2, 'qwerty'),(1,3, 'qwerty'), +(2,1, 'qwerty'),(2,2, 'qwerty'),(2,3, 'qwerty'), (2,4, 'qwerty'),(2,5, 'qwerty'), +(3,1, 'qwerty'),(3,4, 'qwerty'), +(4,1, 'qwerty'),(4,2, 'qwerty'),(4,3, 'qwerty'), (4,4, 'qwerty'); +CREATE TABLE t3 (f1 INT NOT NULL, f2 INT, f3 VARCHAR(32), +PRIMARY KEY(f1), KEY f2_idx(f1), KEY f3_idx(f3)); +INSERT INTO t3 VALUES +(1, 1, 'qwerty'), (2, 1, 'ytrewq'), +(3, 2, 'uiop'), (4, 2, 'poiu'), (5, 2, 'lkjh'), +(6, 2, 'uiop'), (7, 2, 'poiu'), (8, 2, 'lkjh'), +(9, 2, 'uiop'), (10, 2, 'poiu'), (11, 2, 'lkjh'), +(12, 2, 'uiop'), (13, 2, 'poiu'), (14, 2, 'lkjh'); +INSERT INTO t3 SELECT f1 + 20, f2, f3 FROM t3; +INSERT INTO t3 SELECT f1 + 40, f2, f3 FROM t3; +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +ANALYZE TABLE t2; +Table Op Msg_type Msg_text +test.t2 analyze status OK +ANALYZE TABLE t3; +Table Op Msg_type Msg_text +test.t3 analyze status OK +# NO_RANGE_OPTIMIZATION hint testing +set optimizer_switch=default; +# Check statistics with no hint +FLUSH STATUS; +SELECT f1 FROM t3 WHERE f1 > 30 AND f1 < 33; +f1 +31 +32 +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 2 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 3 +# Check statistics with hint +FLUSH STATUS; +SELECT /*+ NO_RANGE_OPTIMIZATION(t3) */ f1 FROM t3 WHERE f1 > 30 AND f1 < 33; +f1 +31 +32 +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 1 +Handler_read_key 1 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 57 +EXPLAIN SELECT f1 FROM t3 WHERE f1 > 30 AND f1 < 33; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t3 NULL range PRIMARY,f2_idx,f3_idx f2_idx 4 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`f1` AS `f1` from `test`.`t3` where ((`test`.`t3`.`f1` > 30) and (`test`.`t3`.`f1` < 33)) +# Turn off range access for PRIMARY key +# Should use range access by f2_idx key +EXPLAIN SELECT /*+ NO_RANGE_OPTIMIZATION(t3 PRIMARY) */ f1 FROM t3 WHERE f1 > 30 AND f1 < 33; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t3 NULL range PRIMARY,f2_idx,f3_idx f2_idx 4 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select /*+ NO_RANGE_OPTIMIZATION(`t3`@`select#1` `PRIMARY`) */ `test`.`t3`.`f1` AS `f1` from `test`.`t3` where ((`test`.`t3`.`f1` > 30) and (`test`.`t3`.`f1` < 33)) +# Turn off range access for PRIMARY & f2_idx keys +# Should use skip scan for f3_idx index +EXPLAIN SELECT /*+ NO_RANGE_OPTIMIZATION(t3 PRIMARY, f2_idx) */ f1 FROM t3 WHERE f1 > 30 AND f1 < 33; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL range PRIMARY,f2_idx,f3_idx f3_idx 135 NULL 6 100.00 Using where; Using index for skip scan +Warnings: +Note 1003 /* select#1 */ select /*+ NO_RANGE_OPTIMIZATION(`t3`@`select#1` `PRIMARY`) NO_RANGE_OPTIMIZATION(`t3`@`select#1` `f2_idx`) */ `test`.`t3`.`f1` AS `f1` from `test`.`t3` where ((`test`.`t3`.`f1` > 30) and (`test`.`t3`.`f1` < 33)) +# Turn off range access for all keys +# Should use index access +EXPLAIN SELECT /*+ NO_RANGE_OPTIMIZATION(t3) */ f1 FROM t3 WHERE f1 > 30 AND f1 < 33; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 56 11.11 Parallel execute (1 workers) +2 SIMPLE t3 NULL index PRIMARY,f2_idx f2_idx 4 NULL 56 11.11 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select /*+ NO_RANGE_OPTIMIZATION(`t3`@`select#1`) */ `test`.`t3`.`f1` AS `f1` from `test`.`t3` where ((`test`.`t3`.`f1` > 30) and (`test`.`t3`.`f1` < 33)) +# Turn off range access for PRIMARY & f2_idx keys +# Should use index access +EXPLAIN SELECT /*+ NO_RANGE_OPTIMIZATION(t3 PRIMARY) NO_RANGE_OPTIMIZATION(t3 f2_idx) */ f1 FROM t3 WHERE f1 > 30 AND f1 < 33; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL range PRIMARY,f2_idx,f3_idx f3_idx 135 NULL 6 100.00 Using where; Using index for skip scan +Warnings: +Note 1003 /* select#1 */ select /*+ NO_RANGE_OPTIMIZATION(`t3`@`select#1` `PRIMARY`) NO_RANGE_OPTIMIZATION(`t3`@`select#1` `f2_idx`) */ `test`.`t3`.`f1` AS `f1` from `test`.`t3` where ((`test`.`t3`.`f1` > 30) and (`test`.`t3`.`f1` < 33)) +# NO_ICP hint testing +set optimizer_switch='index_condition_pushdown=on'; +EXPLAIN SELECT f2 FROM +(SELECT f2, f3, f1 FROM t3 WHERE f1 > 27 AND f3 = 'poiu') AS TD +WHERE TD.f1 > 27 AND TD.f3 = 'poiu'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 100.00 Parallel execute (1 workers) +2 SIMPLE t3 NULL range PRIMARY,f2_idx,f3_idx f3_idx 135 NULL 10 100.00 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`f2` AS `f2` from `test`.`t3` where ((`test`.`t3`.`f3` = 'poiu') and (`test`.`t3`.`f1` > 27) and (`test`.`t3`.`f1` > 27)) +EXPLAIN SELECT /*+ NO_ICP(t3@qb1 f3_idx) */ f2 FROM +(SELECT /*+ QB_NAME(QB1) */ f2, f3, f1 FROM t3 WHERE f1 > 27 AND f3 = 'poiu') AS TD +WHERE TD.f1 > 27 AND TD.f3 = 'poiu'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 100.00 Parallel execute (1 workers) +2 SIMPLE t3 NULL range PRIMARY,f2_idx,f3_idx f3_idx 135 NULL 10 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select /*+ NO_ICP(`t3`@`QB1` `f3_idx`) */ `test`.`t3`.`f2` AS `f2` from `test`.`t3` where ((`test`.`t3`.`f3` = 'poiu') and (`test`.`t3`.`f1` > 27) and (`test`.`t3`.`f1` > 27)) +EXPLAIN SELECT /*+ NO_ICP(t3@qb1) */ f2 FROM +(SELECT /*+ QB_NAME(QB1) */ f2, f3, f1 FROM t3 WHERE f1 > 27 AND f3 = 'poiu') AS TD +WHERE TD.f1 > 27 AND TD.f3 = 'poiu'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 100.00 Parallel execute (1 workers) +2 SIMPLE t3 NULL range PRIMARY,f2_idx,f3_idx f3_idx 135 NULL 10 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select /*+ NO_ICP(`t3`@`QB1`) */ `test`.`t3`.`f2` AS `f2` from `test`.`t3` where ((`test`.`t3`.`f3` = 'poiu') and (`test`.`t3`.`f1` > 27) and (`test`.`t3`.`f1` > 27)) +# Expected warning for f1_idx key, unresolved name. +EXPLAIN SELECT f2 FROM +(SELECT /*+ NO_ICP(t3 f3_idx, f1_idx, f2_idx) */ f2, f3, f1 FROM t3 WHERE f1 > 27 AND f3 = 'poiu') AS TD +WHERE TD.f1 > 27 AND TD.f3 = 'poiu'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 100.00 Parallel execute (1 workers) +2 SIMPLE t3 NULL range PRIMARY,f2_idx,f3_idx f3_idx 135 NULL 10 100.00 Using where +Warnings: +Warning 3128 Unresolved name `t3`@`select#2` `f1_idx` for NO_ICP hint +Note 1003 /* select#1 */ select /*+ NO_ICP(`t3`@`select#2` `f3_idx`) NO_ICP(`t3`@`select#2` `f2_idx`) */ `test`.`t3`.`f2` AS `f2` from `test`.`t3` where ((`test`.`t3`.`f3` = 'poiu') and (`test`.`t3`.`f1` > 27) and (`test`.`t3`.`f1` > 27)) +# ICP should still be used. +EXPLAIN SELECT f2 FROM +(SELECT /*+ NO_ICP(t3 f1_idx, f2_idx) */ f2, f3, f1 FROM t3 WHERE f1 > 27 AND f3 = 'poiu') AS TD +WHERE TD.f1 > 27 AND TD.f3 = 'poiu'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 100.00 Parallel execute (1 workers) +2 SIMPLE t3 NULL range PRIMARY,f2_idx,f3_idx f3_idx 135 NULL 10 100.00 Using index condition +Warnings: +Warning 3128 Unresolved name `t3`@`select#2` `f1_idx` for NO_ICP hint +Note 1003 /* select#1 */ select /*+ NO_ICP(`t3`@`select#2` `f2_idx`) */ `test`.`t3`.`f2` AS `f2` from `test`.`t3` where ((`test`.`t3`.`f3` = 'poiu') and (`test`.`t3`.`f1` > 27) and (`test`.`t3`.`f1` > 27)) +# BKA & NO_BKA hint testing +set optimizer_switch=default; +set optimizer_switch='batched_key_access=off,mrr_cost_based=off'; +# Check statistics without hint +FLUSH STATUS; +SELECT t2.f1, t2.f2, t2.f3 FROM t1,t2 +WHERE t1.f1=t2.f1 AND t2.f2 BETWEEN t1.f1 and t1.f2 and t2.f2 + 1 >= t1.f1 + 1; +f1 f2 f3 +1 1 qwerty +1 1 qwerty +2 2 qwerty +2 2 qwerty +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 1 +Handler_read_key 4 +Handler_read_last 0 +Handler_read_next 4 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 4 +# Check statistics with hint +FLUSH STATUS; +SELECT /*+ BKA() */ t2.f1, t2.f2, t2.f3 FROM t1,t2 +WHERE t1.f1=t2.f1 AND t2.f2 BETWEEN t1.f1 and t1.f2 and t2.f2 + 1 >= t1.f1 + 1; +f1 f2 f3 +1 1 qwerty +1 1 qwerty +2 2 qwerty +2 2 qwerty +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 1 +Handler_read_key 8 +Handler_read_last 0 +Handler_read_next 20 +Handler_read_prev 0 +Handler_read_rnd 4 +Handler_read_rnd_next 4 +EXPLAIN SELECT t2.f1, t2.f2, t2.f3 FROM t1,t2 +WHERE t1.f1=t2.f1 AND t2.f2 BETWEEN t1.f1 and t1.f2 and t2.f2 + 1 >= t1.f1 + 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 SIMPLE t2 NULL ref f1 f1 4 test.t1.f1 7 11.11 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`f1` AS `f1`,`test`.`t2`.`f2` AS `f2`,`test`.`t2`.`f3` AS `f3` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`f1` = `test`.`t1`.`f1`) and (`test`.`t2`.`f2` between `test`.`t1`.`f1` and `test`.`t1`.`f2`) and ((`test`.`t2`.`f2` + 1) >= (`test`.`t1`.`f1` + 1))) +EXPLAIN SELECT /*+ BKA(t2) */ t2.f1, t2.f2, t2.f3 FROM t1,t2 +WHERE t1.f1=t2.f1 AND t2.f2 BETWEEN t1.f1 and t1.f2 and t2.f2 + 1 >= t1.f1 + 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 SIMPLE t2 NULL ref f1 f1 4 test.t1.f1 7 11.11 Using index condition; Using join buffer (Batched Key Access) +Warnings: +Note 1003 /* select#1 */ select /*+ BKA(`t2`@`select#1`) */ `test`.`t2`.`f1` AS `f1`,`test`.`t2`.`f2` AS `f2`,`test`.`t2`.`f3` AS `f3` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`f1` = `test`.`t1`.`f1`) and (`test`.`t2`.`f2` between `test`.`t1`.`f1` and `test`.`t1`.`f2`) and ((`test`.`t2`.`f2` + 1) >= (`test`.`t1`.`f1` + 1))) +EXPLAIN SELECT /*+ BKA() */ t2.f1, t2.f2, t2.f3 FROM t1,t2 +WHERE t1.f1=t2.f1 AND t2.f2 BETWEEN t1.f1 and t1.f2 and t2.f2 + 1 >= t1.f1 + 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 SIMPLE t2 NULL ref f1 f1 4 test.t1.f1 7 11.11 Using index condition; Using join buffer (Batched Key Access) +Warnings: +Note 1003 /* select#1 */ select /*+ BKA(@`select#1`) */ `test`.`t2`.`f1` AS `f1`,`test`.`t2`.`f2` AS `f2`,`test`.`t2`.`f3` AS `f3` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`f1` = `test`.`t1`.`f1`) and (`test`.`t2`.`f2` between `test`.`t1`.`f1` and `test`.`t1`.`f2`) and ((`test`.`t2`.`f2` + 1) >= (`test`.`t1`.`f1` + 1))) +EXPLAIN SELECT /*+ BKA(t1, t2) */ t2.f1, t2.f2, t2.f3 FROM t1,t2 +WHERE t1.f1=t2.f1 AND t2.f2 BETWEEN t1.f1 and t1.f2 and t2.f2 + 1 >= t1.f1 + 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 SIMPLE t2 NULL ref f1 f1 4 test.t1.f1 7 11.11 Using index condition; Using join buffer (Batched Key Access) +Warnings: +Note 1003 /* select#1 */ select /*+ BKA(`t1`@`select#1`) BKA(`t2`@`select#1`) */ `test`.`t2`.`f1` AS `f1`,`test`.`t2`.`f2` AS `f2`,`test`.`t2`.`f3` AS `f3` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`f1` = `test`.`t1`.`f1`) and (`test`.`t2`.`f2` between `test`.`t1`.`f1` and `test`.`t1`.`f2`) and ((`test`.`t2`.`f2` + 1) >= (`test`.`t1`.`f1` + 1))) +EXPLAIN SELECT /*+ BKA(t1) */ t2.f1, t2.f2, t2.f3 FROM t1,t2 +WHERE t1.f1=t2.f1 AND t2.f2 BETWEEN t1.f1 and t1.f2 and t2.f2 + 1 >= t1.f1 + 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 SIMPLE t2 NULL ref f1 f1 4 test.t1.f1 7 11.11 Using index condition +Warnings: +Note 1003 /* select#1 */ select /*+ BKA(`t1`@`select#1`) */ `test`.`t2`.`f1` AS `f1`,`test`.`t2`.`f2` AS `f2`,`test`.`t2`.`f3` AS `f3` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`f1` = `test`.`t1`.`f1`) and (`test`.`t2`.`f2` between `test`.`t1`.`f1` and `test`.`t1`.`f2`) and ((`test`.`t2`.`f2` + 1) >= (`test`.`t1`.`f1` + 1))) +EXPLAIN SELECT /*+ QB_NAME(QB1) BKA(t2@QB1) */ t2.f1, t2.f2, t2.f3 FROM t1,t2 +WHERE t1.f1=t2.f1 AND t2.f2 BETWEEN t1.f1 and t1.f2 and t2.f2 + 1 >= t1.f1 + 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 SIMPLE t2 NULL ref f1 f1 4 test.t1.f1 7 11.11 Using index condition; Using join buffer (Batched Key Access) +Warnings: +Note 1003 /* select#1 */ select /*+ QB_NAME(`QB1`) BKA(`t2`@`QB1`) */ `test`.`t2`.`f1` AS `f1`,`test`.`t2`.`f2` AS `f2`,`test`.`t2`.`f3` AS `f3` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`f1` = `test`.`t1`.`f1`) and (`test`.`t2`.`f2` between `test`.`t1`.`f1` and `test`.`t1`.`f2`) and ((`test`.`t2`.`f2` + 1) >= (`test`.`t1`.`f1` + 1))) +set optimizer_switch='batched_key_access=off,mrr_cost_based=on'; +EXPLAIN SELECT t2.f1, t2.f2, t2.f3 FROM t1,t2 +WHERE t1.f1=t2.f1 AND t2.f2 BETWEEN t1.f1 and t1.f2 and t2.f2 + 1 >= t1.f1 + 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 SIMPLE t2 NULL ref f1 f1 4 test.t1.f1 7 11.11 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`f1` AS `f1`,`test`.`t2`.`f2` AS `f2`,`test`.`t2`.`f3` AS `f3` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`f1` = `test`.`t1`.`f1`) and (`test`.`t2`.`f2` between `test`.`t1`.`f1` and `test`.`t1`.`f2`) and ((`test`.`t2`.`f2` + 1) >= (`test`.`t1`.`f1` + 1))) +EXPLAIN SELECT /*+ BKA(t2) */ t2.f1, t2.f2, t2.f3 FROM t1,t2 +WHERE t1.f1=t2.f1 AND t2.f2 BETWEEN t1.f1 and t1.f2 and t2.f2 + 1 >= t1.f1 + 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 SIMPLE t2 NULL ref f1 f1 4 test.t1.f1 7 11.11 Using index condition; Using join buffer (Batched Key Access) +Warnings: +Note 1003 /* select#1 */ select /*+ BKA(`t2`@`select#1`) */ `test`.`t2`.`f1` AS `f1`,`test`.`t2`.`f2` AS `f2`,`test`.`t2`.`f3` AS `f3` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`f1` = `test`.`t1`.`f1`) and (`test`.`t2`.`f2` between `test`.`t1`.`f1` and `test`.`t1`.`f2`) and ((`test`.`t2`.`f2` + 1) >= (`test`.`t1`.`f1` + 1))) +EXPLAIN SELECT /*+ BKA() */ t2.f1, t2.f2, t2.f3 FROM t1,t2 +WHERE t1.f1=t2.f1 AND t2.f2 BETWEEN t1.f1 and t1.f2 and t2.f2 + 1 >= t1.f1 + 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 SIMPLE t2 NULL ref f1 f1 4 test.t1.f1 7 11.11 Using index condition; Using join buffer (Batched Key Access) +Warnings: +Note 1003 /* select#1 */ select /*+ BKA(@`select#1`) */ `test`.`t2`.`f1` AS `f1`,`test`.`t2`.`f2` AS `f2`,`test`.`t2`.`f3` AS `f3` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`f1` = `test`.`t1`.`f1`) and (`test`.`t2`.`f2` between `test`.`t1`.`f1` and `test`.`t1`.`f2`) and ((`test`.`t2`.`f2` + 1) >= (`test`.`t1`.`f1` + 1))) +EXPLAIN SELECT /*+ BKA(t1, t2) */ t2.f1, t2.f2, t2.f3 FROM t1,t2 +WHERE t1.f1=t2.f1 AND t2.f2 BETWEEN t1.f1 and t1.f2 and t2.f2 + 1 >= t1.f1 + 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 SIMPLE t2 NULL ref f1 f1 4 test.t1.f1 7 11.11 Using index condition; Using join buffer (Batched Key Access) +Warnings: +Note 1003 /* select#1 */ select /*+ BKA(`t1`@`select#1`) BKA(`t2`@`select#1`) */ `test`.`t2`.`f1` AS `f1`,`test`.`t2`.`f2` AS `f2`,`test`.`t2`.`f3` AS `f3` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`f1` = `test`.`t1`.`f1`) and (`test`.`t2`.`f2` between `test`.`t1`.`f1` and `test`.`t1`.`f2`) and ((`test`.`t2`.`f2` + 1) >= (`test`.`t1`.`f1` + 1))) +EXPLAIN SELECT /*+ QB_NAME(QB1) BKA(t2@QB1) */ t2.f1, t2.f2, t2.f3 FROM t1,t2 +WHERE t1.f1=t2.f1 AND t2.f2 BETWEEN t1.f1 and t1.f2 and t2.f2 + 1 >= t1.f1 + 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 SIMPLE t2 NULL ref f1 f1 4 test.t1.f1 7 11.11 Using index condition; Using join buffer (Batched Key Access) +Warnings: +Note 1003 /* select#1 */ select /*+ QB_NAME(`QB1`) BKA(`t2`@`QB1`) */ `test`.`t2`.`f1` AS `f1`,`test`.`t2`.`f2` AS `f2`,`test`.`t2`.`f3` AS `f3` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`f1` = `test`.`t1`.`f1`) and (`test`.`t2`.`f2` between `test`.`t1`.`f1` and `test`.`t1`.`f2`) and ((`test`.`t2`.`f2` + 1) >= (`test`.`t1`.`f1` + 1))) +set optimizer_switch='batched_key_access=on,mrr_cost_based=off'; +EXPLAIN SELECT t2.f1, t2.f2, t2.f3 FROM t1,t2 +WHERE t1.f1=t2.f1 AND t2.f2 BETWEEN t1.f1 and t1.f2 and t2.f2 + 1 >= t1.f1 + 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 SIMPLE t2 NULL ref f1 f1 4 test.t1.f1 7 11.11 Using index condition; Using join buffer (Batched Key Access) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`f1` AS `f1`,`test`.`t2`.`f2` AS `f2`,`test`.`t2`.`f3` AS `f3` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`f1` = `test`.`t1`.`f1`) and (`test`.`t2`.`f2` between `test`.`t1`.`f1` and `test`.`t1`.`f2`) and ((`test`.`t2`.`f2` + 1) >= (`test`.`t1`.`f1` + 1))) +set optimizer_switch='mrr=off'; +EXPLAIN SELECT t2.f1, t2.f2, t2.f3 FROM t1,t2 +WHERE t1.f1=t2.f1 AND t2.f2 BETWEEN t1.f1 and t1.f2 and t2.f2 + 1 >= t1.f1 + 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 SIMPLE t2 NULL ref f1 f1 4 test.t1.f1 7 11.11 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`f1` AS `f1`,`test`.`t2`.`f2` AS `f2`,`test`.`t2`.`f3` AS `f3` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`f1` = `test`.`t1`.`f1`) and (`test`.`t2`.`f2` between `test`.`t1`.`f1` and `test`.`t1`.`f2`) and ((`test`.`t2`.`f2` + 1) >= (`test`.`t1`.`f1` + 1))) +# MRR switch should not affect BKA. +# BKA should be used for table t2. +EXPLAIN SELECT /*+ BKA(t2) */ t2.f1, t2.f2, t2.f3 FROM t1,t2 +WHERE t1.f1=t2.f1 AND t2.f2 BETWEEN t1.f1 and t1.f2 and t2.f2 + 1 >= t1.f1 + 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 SIMPLE t2 NULL ref f1 f1 4 test.t1.f1 7 11.11 Using index condition; Using join buffer (Batched Key Access) +Warnings: +Note 1003 /* select#1 */ select /*+ BKA(`t2`@`select#1`) */ `test`.`t2`.`f1` AS `f1`,`test`.`t2`.`f2` AS `f2`,`test`.`t2`.`f3` AS `f3` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`f1` = `test`.`t1`.`f1`) and (`test`.`t2`.`f2` between `test`.`t1`.`f1` and `test`.`t1`.`f2`) and ((`test`.`t2`.`f2` + 1) >= (`test`.`t1`.`f1` + 1))) +set optimizer_switch='mrr=on'; +EXPLAIN SELECT /*+ NO_BKA(t2) */ t2.f1, t2.f2, t2.f3 FROM t1,t2 +WHERE t1.f1=t2.f1 AND t2.f2 BETWEEN t1.f1 and t1.f2 and t2.f2 + 1 >= t1.f1 + 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 SIMPLE t2 NULL ref f1 f1 4 test.t1.f1 7 11.11 Using index condition +Warnings: +Note 1003 /* select#1 */ select /*+ NO_BKA(`t2`@`select#1`) */ `test`.`t2`.`f1` AS `f1`,`test`.`t2`.`f2` AS `f2`,`test`.`t2`.`f3` AS `f3` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`f1` = `test`.`t1`.`f1`) and (`test`.`t2`.`f2` between `test`.`t1`.`f1` and `test`.`t1`.`f2`) and ((`test`.`t2`.`f2` + 1) >= (`test`.`t1`.`f1` + 1))) +EXPLAIN SELECT /*+ NO_BKA() */ t2.f1, t2.f2, t2.f3 FROM t1,t2 +WHERE t1.f1=t2.f1 AND t2.f2 BETWEEN t1.f1 and t1.f2 and t2.f2 + 1 >= t1.f1 + 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 SIMPLE t2 NULL ref f1 f1 4 test.t1.f1 7 11.11 Using index condition +Warnings: +Note 1003 /* select#1 */ select /*+ NO_BKA(@`select#1`) */ `test`.`t2`.`f1` AS `f1`,`test`.`t2`.`f2` AS `f2`,`test`.`t2`.`f3` AS `f3` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`f1` = `test`.`t1`.`f1`) and (`test`.`t2`.`f2` between `test`.`t1`.`f1` and `test`.`t1`.`f2`) and ((`test`.`t2`.`f2` + 1) >= (`test`.`t1`.`f1` + 1))) +EXPLAIN SELECT /*+ NO_BKA(t1, t2) */ t2.f1, t2.f2, t2.f3 FROM t1,t2 +WHERE t1.f1=t2.f1 AND t2.f2 BETWEEN t1.f1 and t1.f2 and t2.f2 + 1 >= t1.f1 + 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 SIMPLE t2 NULL ref f1 f1 4 test.t1.f1 7 11.11 Using index condition +Warnings: +Note 1003 /* select#1 */ select /*+ NO_BKA(`t1`@`select#1`) NO_BKA(`t2`@`select#1`) */ `test`.`t2`.`f1` AS `f1`,`test`.`t2`.`f2` AS `f2`,`test`.`t2`.`f3` AS `f3` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`f1` = `test`.`t1`.`f1`) and (`test`.`t2`.`f2` between `test`.`t1`.`f1` and `test`.`t1`.`f2`) and ((`test`.`t2`.`f2` + 1) >= (`test`.`t1`.`f1` + 1))) +EXPLAIN SELECT /*+ QB_NAME(QB1) NO_BKA(t2@QB1) */ t2.f1, t2.f2, t2.f3 FROM t1,t2 +WHERE t1.f1=t2.f1 AND t2.f2 BETWEEN t1.f1 and t1.f2 and t2.f2 + 1 >= t1.f1 + 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 SIMPLE t2 NULL ref f1 f1 4 test.t1.f1 7 11.11 Using index condition +Warnings: +Note 1003 /* select#1 */ select /*+ QB_NAME(`QB1`) NO_BKA(`t2`@`QB1`) */ `test`.`t2`.`f1` AS `f1`,`test`.`t2`.`f2` AS `f2`,`test`.`t2`.`f3` AS `f3` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`f1` = `test`.`t1`.`f1`) and (`test`.`t2`.`f2` between `test`.`t1`.`f1` and `test`.`t1`.`f2`) and ((`test`.`t2`.`f2` + 1) >= (`test`.`t1`.`f1` + 1))) +# UPDATE|DELETE|INSERT|REPLACE hint testing +set optimizer_switch='batched_key_access=off,mrr_cost_based=off,semijoin=off,materialization=off'; +EXPLAIN UPDATE t3 +SET f3 = 'mnbv' WHERE f1 > 30 AND f1 < 33 AND (t3.f1, t3.f2, t3.f3) IN +(SELECT t2.f1, t2.f2, t2.f3 FROM t1,t2 WHERE t1.f1=t2.f1 AND +t2.f2 BETWEEN t1.f1 AND t1.f2 AND t2.f2 + 1 >= t1.f1 + 1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t3 NULL range PRIMARY,f2_idx PRIMARY 4 const 2 100.00 Using where +2 DEPENDENT SUBQUERY t2 NULL ref f1 f1 8 func,func 2 10.00 Using index condition; Using where +2 DEPENDENT SUBQUERY t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +Warnings: +Note 1003 update `test`.`t3` set `test`.`t3`.`f3` = 'mnbv' where ((`test`.`t3`.`f1` > 30) and (`test`.`t3`.`f1` < 33) and ((`test`.`t3`.`f1`,`test`.`t3`.`f2`,`test`.`t3`.`f3`),(/* select#2 */ select `test`.`t2`.`f1`,`test`.`t2`.`f2`,`test`.`t2`.`f3` from `test`.`t1` join `test`.`t2` where ((`test`.`t1`.`f1` = `test`.`t2`.`f1`) and (`test`.`t2`.`f2` between `test`.`t2`.`f1` and `test`.`t1`.`f2`) and ((`test`.`t2`.`f2` + 1) >= (`test`.`t2`.`f1` + 1)) and ((`test`.`t3`.`f1`) = `test`.`t2`.`f1`) and ((`test`.`t3`.`f2`) = `test`.`t2`.`f2`) and ((`test`.`t3`.`f3`) = `test`.`t2`.`f3`))))) +# Turn off range access for PRIMARY key. +# Range access should be used for f2_idx key. +EXPLAIN UPDATE /*+ NO_RANGE_OPTIMIZATION(t3 PRIMARY) */ t3 +SET f3 = 'mnbv' WHERE f1 > 30 AND f1 < 33 AND (t3.f1, t3.f2, t3.f3) IN +(SELECT /*+ BKA(t2) NO_BNL(t1) */ t2.f1, t2.f2, t2.f3 FROM t1,t2 WHERE t1.f1=t2.f1 AND +t2.f2 BETWEEN t1.f1 AND t1.f2 AND t2.f2 + 1 >= t1.f1 + 1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t3 NULL range f2_idx f2_idx 4 const 2 100.00 Using where +2 DEPENDENT SUBQUERY t2 NULL ref f1 f1 8 func,func 2 10.00 Using index condition; Using where +2 DEPENDENT SUBQUERY t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 update /*+ BKA(`t2`@`select#2`) NO_BNL(`t1`@`select#2`) NO_RANGE_OPTIMIZATION(`t3`@`select#1` `PRIMARY`) */ `test`.`t3` set `test`.`t3`.`f3` = 'mnbv' where ((`test`.`t3`.`f1` > 30) and (`test`.`t3`.`f1` < 33) and ((`test`.`t3`.`f1`,`test`.`t3`.`f2`,`test`.`t3`.`f3`),(/* select#2 */ select `test`.`t2`.`f1`,`test`.`t2`.`f2`,`test`.`t2`.`f3` from `test`.`t1` join `test`.`t2` where ((`test`.`t1`.`f1` = `test`.`t2`.`f1`) and (`test`.`t2`.`f2` between `test`.`t2`.`f1` and `test`.`t1`.`f2`) and ((`test`.`t2`.`f2` + 1) >= (`test`.`t2`.`f1` + 1)) and ((`test`.`t3`.`f1`) = `test`.`t2`.`f1`) and ((`test`.`t3`.`f2`) = `test`.`t2`.`f2`) and ((`test`.`t3`.`f3`) = `test`.`t2`.`f3`))))) +EXPLAIN DELETE FROM t3 +WHERE f1 > 30 AND f1 < 33 AND (t3.f1, t3.f2, t3.f3) IN +(SELECT /*+ QB_NAME(qb1) */ t2.f1, t2.f2, t2.f3 FROM t1,t2 WHERE t1.f1=t2.f1 AND +t2.f2 BETWEEN t1.f1 AND t1.f2 AND t2.f2 + 1 >= t1.f1 + 1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t3 NULL range PRIMARY,f2_idx PRIMARY 4 const 2 100.00 Using where +2 DEPENDENT SUBQUERY t2 NULL ref f1 f1 8 func,func 2 10.00 Using index condition; Using where +2 DEPENDENT SUBQUERY t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +Warnings: +Note 1003 delete from `test`.`t3` where ((`test`.`t3`.`f1` > 30) and (`test`.`t3`.`f1` < 33) and ((`test`.`t3`.`f1`,`test`.`t3`.`f2`,`test`.`t3`.`f3`),(/* select#2 */ select /*+ QB_NAME(`qb1`) */ `test`.`t2`.`f1`,`test`.`t2`.`f2`,`test`.`t2`.`f3` from `test`.`t1` join `test`.`t2` where ((`test`.`t1`.`f1` = `test`.`t2`.`f1`) and (`test`.`t2`.`f2` between `test`.`t2`.`f1` and `test`.`t1`.`f2`) and ((`test`.`t2`.`f2` + 1) >= (`test`.`t2`.`f1` + 1)) and ((`test`.`t3`.`f1`) = `test`.`t2`.`f1`) and ((`test`.`t3`.`f2`) = `test`.`t2`.`f2`) and ((`test`.`t3`.`f3`) = `test`.`t2`.`f3`))))) +# Turn off range access. Range access should not be used. +# Turn off BNL. BNL should not be used. +EXPLAIN DELETE /*+ NO_RANGE_OPTIMIZATION(t3 PRIMARY, f2_idx) NO_BNL(t1@QB1) */ FROM t3 +WHERE f1 > 30 AND f1 < 33 AND (t3.f1, t3.f2, t3.f3) IN +(SELECT /*+ QB_NAME(qb1) */ t2.f1, t2.f2, t2.f3 FROM t1,t2 WHERE t1.f1=t2.f1 AND +t2.f2 BETWEEN t1.f1 AND t1.f2 AND t2.f2 + 1 >= t1.f1 + 1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t3 NULL ALL NULL NULL NULL NULL 56 100.00 Using where +2 DEPENDENT SUBQUERY t2 NULL ref f1 f1 8 func,func 2 10.00 Using index condition; Using where +2 DEPENDENT SUBQUERY t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 delete /*+ NO_BNL(`t1`@`qb1`) NO_RANGE_OPTIMIZATION(`t3`@`select#1` `PRIMARY`) NO_RANGE_OPTIMIZATION(`t3`@`select#1` `f2_idx`) */ from `test`.`t3` where ((`test`.`t3`.`f1` > 30) and (`test`.`t3`.`f1` < 33) and ((`test`.`t3`.`f1`,`test`.`t3`.`f2`,`test`.`t3`.`f3`),(/* select#2 */ select /*+ QB_NAME(`qb1`) */ `test`.`t2`.`f1`,`test`.`t2`.`f2`,`test`.`t2`.`f3` from `test`.`t1` join `test`.`t2` where ((`test`.`t1`.`f1` = `test`.`t2`.`f1`) and (`test`.`t2`.`f2` between `test`.`t2`.`f1` and `test`.`t1`.`f2`) and ((`test`.`t2`.`f2` + 1) >= (`test`.`t2`.`f1` + 1)) and ((`test`.`t3`.`f1`) = `test`.`t2`.`f1`) and ((`test`.`t3`.`f2`) = `test`.`t2`.`f2`) and ((`test`.`t3`.`f3`) = `test`.`t2`.`f3`))))) +EXPLAIN INSERT INTO t3(f1, f2, f3) +(SELECT t2.f1, t2.f2, t2.f3 FROM t1,t2 WHERE t1.f1=t2.f1 AND +t2.f2 BETWEEN t1.f1 AND t1.f2 AND t2.f2 + 1 >= t1.f1 + 1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 INSERT t3 NULL ALL NULL NULL NULL NULL NULL NULL NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t2 NULL ref f1 f1 4 test.t1.f1 7 11.11 Using index condition +Warnings: +Note 1003 insert into `test`.`t3` (`test`.`t3`.`f1`,`test`.`t3`.`f2`,`test`.`t3`.`f3`) /* select#1 */ select `test`.`t2`.`f1` AS `f1`,`test`.`t2`.`f2` AS `f2`,`test`.`t2`.`f3` AS `f3` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`f1` = `test`.`t1`.`f1`) and (`test`.`t2`.`f2` between `test`.`t1`.`f1` and `test`.`t1`.`f2`) and ((`test`.`t2`.`f2` + 1) >= (`test`.`t1`.`f1` + 1))) +# Turn off ICP. ICP should not be used. +EXPLAIN INSERT INTO t3(f1, f2, f3) +(SELECT /*+ NO_ICP(t2) */ t2.f1, t2.f2, t2.f3 FROM t1,t2 WHERE t1.f1=t2.f1 AND +t2.f2 BETWEEN t1.f1 AND t1.f2 AND t2.f2 + 1 >= t1.f1 + 1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 INSERT t3 NULL ALL NULL NULL NULL NULL NULL NULL NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t2 NULL ref f1 f1 4 test.t1.f1 7 11.11 Using where +Warnings: +Note 1003 insert /*+ NO_ICP(`t2`@`select#1`) */ into `test`.`t3` (`test`.`t3`.`f1`,`test`.`t3`.`f2`,`test`.`t3`.`f3`) /* select#1 */ select `test`.`t2`.`f1` AS `f1`,`test`.`t2`.`f2` AS `f2`,`test`.`t2`.`f3` AS `f3` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`f1` = `test`.`t1`.`f1`) and (`test`.`t2`.`f2` between `test`.`t1`.`f1` and `test`.`t1`.`f2`) and ((`test`.`t2`.`f2` + 1) >= (`test`.`t1`.`f1` + 1))) +# Turn off ICP. ICP should not be used. +EXPLAIN INSERT /*+ NO_ICP(t2@QB1 f1) */ INTO t3(f1, f2, f3) +(SELECT /*+ QB_NAME(qb1) */ t2.f1, t2.f2, t2.f3 FROM t1,t2 WHERE t1.f1=t2.f1 AND +t2.f2 BETWEEN t1.f1 AND t1.f2 AND t2.f2 + 1 >= t1.f1 + 1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 INSERT t3 NULL ALL NULL NULL NULL NULL NULL NULL NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t2 NULL ref f1 f1 4 test.t1.f1 7 11.11 Using where +Warnings: +Note 1003 insert /*+ NO_ICP(`t2`@`qb1` `f1`) */ into `test`.`t3` (`test`.`t3`.`f1`,`test`.`t3`.`f2`,`test`.`t3`.`f3`) /* select#1 */ select /*+ QB_NAME(`qb1`) */ `test`.`t2`.`f1` AS `f1`,`test`.`t2`.`f2` AS `f2`,`test`.`t2`.`f3` AS `f3` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`f1` = `test`.`t1`.`f1`) and (`test`.`t2`.`f2` between `test`.`t1`.`f1` and `test`.`t1`.`f2`) and ((`test`.`t2`.`f2` + 1) >= (`test`.`t1`.`f1` + 1))) +EXPLAIN REPLACE INTO t3(f1, f2, f3) +(SELECT t2.f1, t2.f2, t2.f3 FROM t1,t2 WHERE t1.f1=t2.f1 AND +t2.f2 BETWEEN t1.f1 AND t1.f2 AND t2.f2 + 1 >= t1.f1 + 1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 REPLACE t3 NULL ALL NULL NULL NULL NULL NULL NULL NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t2 NULL ref f1 f1 4 test.t1.f1 7 11.11 Using index condition +Warnings: +Note 1003 replace into `test`.`t3` (`test`.`t3`.`f1`,`test`.`t3`.`f2`,`test`.`t3`.`f3`) /* select#1 */ select `test`.`t2`.`f1` AS `f1`,`test`.`t2`.`f2` AS `f2`,`test`.`t2`.`f3` AS `f3` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`f1` = `test`.`t1`.`f1`) and (`test`.`t2`.`f2` between `test`.`t1`.`f1` and `test`.`t1`.`f2`) and ((`test`.`t2`.`f2` + 1) >= (`test`.`t1`.`f1` + 1))) +# Turn off ICP. ICP should not be used. +EXPLAIN REPLACE INTO t3(f1, f2, f3) +(SELECT /*+ NO_ICP(t2) */ t2.f1, t2.f2, t2.f3 FROM t1,t2 WHERE t1.f1=t2.f1 AND +t2.f2 BETWEEN t1.f1 AND t1.f2 AND t2.f2 + 1 >= t1.f1 + 1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 REPLACE t3 NULL ALL NULL NULL NULL NULL NULL NULL NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t2 NULL ref f1 f1 4 test.t1.f1 7 11.11 Using where +Warnings: +Note 1003 replace /*+ NO_ICP(`t2`@`select#1`) */ into `test`.`t3` (`test`.`t3`.`f1`,`test`.`t3`.`f2`,`test`.`t3`.`f3`) /* select#1 */ select `test`.`t2`.`f1` AS `f1`,`test`.`t2`.`f2` AS `f2`,`test`.`t2`.`f3` AS `f3` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`f1` = `test`.`t1`.`f1`) and (`test`.`t2`.`f2` between `test`.`t1`.`f1` and `test`.`t1`.`f2`) and ((`test`.`t2`.`f2` + 1) >= (`test`.`t1`.`f1` + 1))) +# Turn off ICP for nonexistent table. ICP should be used. +EXPLAIN REPLACE /*+ NO_ICP(t2@qb1) */ INTO t3(f1, f2, f3) +SELECT /*+ QB_NAME(qb2) */ t2.f1, t2.f2, t2.f3 FROM t1,t2 WHERE t1.f1=t2.f1 AND +t2.f2 BETWEEN t1.f1 AND t1.f2 AND t2.f2 + 1 >= t1.f1 + 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 REPLACE t3 NULL ALL NULL NULL NULL NULL NULL NULL NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t2 NULL ref f1 f1 4 test.t1.f1 7 11.11 Using index condition +Warnings: +Warning 3127 Query block name `qb1` is not found for NO_ICP hint +Note 1003 replace into `test`.`t3` (`test`.`t3`.`f1`,`test`.`t3`.`f2`,`test`.`t3`.`f3`) /* select#1 */ select /*+ QB_NAME(`qb2`) */ `test`.`t2`.`f1` AS `f1`,`test`.`t2`.`f2` AS `f2`,`test`.`t2`.`f3` AS `f3` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`f1` = `test`.`t1`.`f1`) and (`test`.`t2`.`f2` between `test`.`t1`.`f1` and `test`.`t1`.`f2`) and ((`test`.`t2`.`f2` + 1) >= (`test`.`t1`.`f1` + 1))) +# Turn off ICP. ICP should not be used. +EXPLAIN REPLACE /*+ NO_ICP(t2@qb1) */ INTO t3(f1, f2, f3) +SELECT /*+ QB_NAME(qb1) */ t2.f1, t2.f2, t2.f3 FROM t1,t2 WHERE t1.f1=t2.f1 AND +t2.f2 BETWEEN t1.f1 AND t1.f2 AND t2.f2 + 1 >= t1.f1 + 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 REPLACE t3 NULL ALL NULL NULL NULL NULL NULL NULL NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t2 NULL ref f1 f1 4 test.t1.f1 7 11.11 Using where +Warnings: +Note 1003 replace /*+ NO_ICP(`t2`@`qb1`) */ into `test`.`t3` (`test`.`t3`.`f1`,`test`.`t3`.`f2`,`test`.`t3`.`f3`) /* select#1 */ select /*+ QB_NAME(`qb1`) */ `test`.`t2`.`f1` AS `f1`,`test`.`t2`.`f2` AS `f2`,`test`.`t2`.`f3` AS `f3` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`f1` = `test`.`t1`.`f1`) and (`test`.`t2`.`f2` between `test`.`t1`.`f1` and `test`.`t1`.`f2`) and ((`test`.`t2`.`f2` + 1) >= (`test`.`t1`.`f1` + 1))) +# Misc tests +# Should issue warning +EXPLAIN SELECT /*+ QB_NAME(qb1) QB_NAME(qb1 ) */ * FROM t2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 28 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 28 100.00 NULL +Warnings: +Warning 3126 Hint QB_NAME(`qb1`) is ignored as conflicting/duplicated +Note 1003 /* select#1 */ select /*+ QB_NAME(`qb1`) */ `test`.`t2`.`f1` AS `f1`,`test`.`t2`.`f2` AS `f2`,`test`.`t2`.`f3` AS `f3` from `test`.`t2` +# Should issue warning +EXPLAIN SELECT /*+ BKA(@qb1) QB_NAME(qb1) */ t2.f1, t2.f2, t2.f3 FROM t1,t2 +WHERE t1.f1=t2.f1 AND t2.f2 BETWEEN t1.f1 and t1.f2 and t2.f2 + 1 >= t1.f1 + 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 SIMPLE t2 NULL ref f1 f1 4 test.t1.f1 7 11.11 Using index condition +Warnings: +Warning 3127 Query block name `qb1` is not found for BKA hint +Note 1003 /* select#1 */ select /*+ QB_NAME(`qb1`) */ `test`.`t2`.`f1` AS `f1`,`test`.`t2`.`f2` AS `f2`,`test`.`t2`.`f3` AS `f3` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`f1` = `test`.`t1`.`f1`) and (`test`.`t2`.`f2` between `test`.`t1`.`f1` and `test`.`t1`.`f2`) and ((`test`.`t2`.`f2` + 1) >= (`test`.`t1`.`f1` + 1))) +# Should not crash +PREPARE stmt1 FROM "SELECT /*+ BKA(t2) */ t2.f1, t2.f2, t2.f3 FROM t1,t2 +WHERE t1.f1=t2.f1 AND t2.f2 BETWEEN t1.f1 and t1.f2 and t2.f2 + 1 >= t1.f1 + 1"; +EXECUTE stmt1; +f1 f2 f3 +1 1 qwerty +2 2 qwerty +1 1 qwerty +2 2 qwerty +EXECUTE stmt1; +f1 f2 f3 +1 1 qwerty +2 2 qwerty +1 1 qwerty +2 2 qwerty +DEALLOCATE PREPARE stmt1; +# Check use of alias +EXPLAIN SELECT tbl2.f1, tbl2.f2, tbl2.f3 FROM t1 tbl1,t2 tbl2 +WHERE tbl1.f1=tbl2.f1 AND tbl2.f2 BETWEEN tbl1.f1 and tbl1.f2 and tbl2.f2 + 1 >= tbl1.f1 + 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE tbl1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 SIMPLE tbl2 NULL ref f1 f1 4 test.tbl1.f1 7 11.11 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl2`.`f1` AS `f1`,`test`.`tbl2`.`f2` AS `f2`,`test`.`tbl2`.`f3` AS `f3` from `test`.`t1` `tbl1` join `test`.`t2` `tbl2` where ((`test`.`tbl2`.`f1` = `test`.`tbl1`.`f1`) and (`test`.`tbl2`.`f2` between `test`.`tbl1`.`f1` and `test`.`tbl1`.`f2`) and ((`test`.`tbl2`.`f2` + 1) >= (`test`.`tbl1`.`f1` + 1))) +# Turn on BKA for multiple tables. BKA should be used for tbl2. +EXPLAIN SELECT /*+ BKA(tbl1, tbl2) */ tbl2.f1, tbl2.f2, tbl2.f3 FROM t1 tbl1,t2 tbl2 +WHERE tbl1.f1=tbl2.f1 AND tbl2.f2 BETWEEN tbl1.f1 and tbl1.f2 and tbl2.f2 + 1 >= tbl1.f1 + 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE tbl1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 SIMPLE tbl2 NULL ref f1 f1 4 test.tbl1.f1 7 11.11 Using index condition; Using join buffer (Batched Key Access) +Warnings: +Note 1003 /* select#1 */ select /*+ BKA(`tbl1`@`select#1`) BKA(`tbl2`@`select#1`) */ `test`.`tbl2`.`f1` AS `f1`,`test`.`tbl2`.`f2` AS `f2`,`test`.`tbl2`.`f3` AS `f3` from `test`.`t1` `tbl1` join `test`.`t2` `tbl2` where ((`test`.`tbl2`.`f1` = `test`.`tbl1`.`f1`) and (`test`.`tbl2`.`f2` between `test`.`tbl1`.`f1` and `test`.`tbl1`.`f2`) and ((`test`.`tbl2`.`f2` + 1) >= (`test`.`tbl1`.`f1` + 1))) +# Print warnings for nonexistent names +EXPLAIN +SELECT /*+ BKA(t2) NO_BNL(t1) BKA(t3) NO_RANGE_OPTIMIZATION(t3 idx1) NO_RANGE_OPTIMIZATION(t3) */ +t2.f1, t2.f2, t2.f3 FROM t1,t2 WHERE t1.f1=t2.f1 AND +t2.f2 BETWEEN t1.f1 AND t1.f2 AND t2.f2 + 1 >= t1.f1 + 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 SIMPLE t2 NULL ref f1 f1 4 test.t1.f1 7 11.11 Using index condition; Using join buffer (Batched Key Access) +Warnings: +Warning 3128 Unresolved name `t3`@`select#1` for BKA hint +Warning 3128 Unresolved name `t3`@`select#1` for NO_RANGE_OPTIMIZATION hint +Warning 3128 Unresolved name `t3`@`select#1` `idx1` for NO_RANGE_OPTIMIZATION hint +Note 1003 /* select#1 */ select /*+ BKA(`t2`@`select#1`) NO_BNL(`t1`@`select#1`) */ `test`.`t2`.`f1` AS `f1`,`test`.`t2`.`f2` AS `f2`,`test`.`t2`.`f3` AS `f3` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`f1` = `test`.`t1`.`f1`) and (`test`.`t2`.`f2` between `test`.`t1`.`f1` and `test`.`t1`.`f2`) and ((`test`.`t2`.`f2` + 1) >= (`test`.`t1`.`f1` + 1))) +# Check illegal syntax +EXPLAIN SELECT /*+ BKA(qb1 t3@qb1) */ f2 FROM +(SELECT /*+ QB_NAME(qb1) */ f2, f3, f1 FROM t3 WHERE f1 > 2 AND f3 = 'poiu') AS TD +WHERE TD.f1 > 2 AND TD.f3 = 'poiu'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 16 100.00 Parallel execute (1 workers) +2 SIMPLE t3 NULL range PRIMARY,f2_idx,f3_idx f3_idx 135 NULL 16 100.00 Using index condition; Using MRR +Warnings: +Warning 1064 Optimizer hint syntax error near 't3@qb1) */ f2 FROM +(SELECT /*+ QB_NAME(qb1) */ f2, f3, f1 FROM t3 WHERE f1 > 2 A' at line 1 +Note 1003 /* select#1 */ select `test`.`t3`.`f2` AS `f2` from `test`.`t3` where ((`test`.`t3`.`f3` = 'poiu') and (`test`.`t3`.`f1` > 2) and (`test`.`t3`.`f1` > 2)) +# Check illegal syntax +EXPLAIN SELECT * FROM +(SELECT /*+ QB_NAME(qb1) BKA(@qb1 t1@qb1, t2@qb1, t3) */ t2.f1, t2.f2, t2.f3 FROM t1,t2,t3) tt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 28 100.00 Using join buffer (hash join) +2 SIMPLE t3 NULL index NULL f2_idx 4 NULL 56 100.00 Using index; Using join buffer (hash join) +Warnings: +Warning 1064 Optimizer hint syntax error near 'qb1, t2@qb1, t3) */ t2.f1, t2.f2, t2.f3 FROM t1,t2,t3) tt' at line 2 +Note 1003 /* select#1 */ select `test`.`t2`.`f1` AS `f1`,`test`.`t2`.`f2` AS `f2`,`test`.`t2`.`f3` AS `f3` from `test`.`t1` join `test`.`t2` join `test`.`t3` +# Check '@qb_name table_name' syntax. BKA should be used for t2. +EXPLAIN SELECT /*+ BKA(@qb1 t2) */ * FROM (SELECT /*+ QB_NAME(QB1) */ t2.f1, t2.f2, t2.f3 FROM t1,t2 +WHERE t1.f1=t2.f1 AND t2.f2 BETWEEN t1.f1 and t1.f2 and t2.f2 + 1 >= t1.f1 + 1) AS s1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 SIMPLE t2 NULL ref f1 f1 4 test.t1.f1 7 11.11 Using index condition; Using join buffer (Batched Key Access) +Warnings: +Note 1003 /* select#1 */ select /*+ BKA(`t2`@`QB1`) */ `test`.`t2`.`f1` AS `f1`,`test`.`t2`.`f2` AS `f2`,`test`.`t2`.`f3` AS `f3` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`f1` = `test`.`t1`.`f1`) and (`test`.`t2`.`f2` between `test`.`t1`.`f1` and `test`.`t1`.`f2`) and ((`test`.`t2`.`f2` + 1) >= (`test`.`t1`.`f1` + 1))) +# Check that original table name is not recognized if alias is used. +EXPLAIN SELECT * FROM (SELECT /*+ BKA(t2) */ tb2.f1, tb2.f2, tb2.f3 FROM t1 tb1,t2 tb2 +WHERE tb1.f1=tb2.f1 AND tb2.f2 BETWEEN tb1.f1 and tb1.f2 and tb2.f2 + 1 >= tb1.f1 + 1) AS s1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE tb1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 SIMPLE tb2 NULL ref f1 f1 4 test.tb1.f1 7 11.11 Using index condition +Warnings: +Warning 3128 Unresolved name `t2`@`select#2` for BKA hint +Note 1003 /* select#1 */ select `test`.`tb2`.`f1` AS `f1`,`test`.`tb2`.`f2` AS `f2`,`test`.`tb2`.`f3` AS `f3` from `test`.`t1` `tb1` join `test`.`t2` `tb2` where ((`test`.`tb2`.`f1` = `test`.`tb1`.`f1`) and (`test`.`tb2`.`f2` between `test`.`tb1`.`f1` and `test`.`tb1`.`f2`) and ((`test`.`tb2`.`f2` + 1) >= (`test`.`tb1`.`f1` + 1))) +# Table t2 should use BKA. +EXPLAIN SELECT * FROM (SELECT /*+ BKA(tb2) */ tb2.f1, tb2.f2, tb2.f3 FROM t1 tb1,t2 tb2 +WHERE tb1.f1=tb2.f1 AND tb2.f2 BETWEEN tb1.f1 and tb1.f2 and tb2.f2 + 1 >= tb1.f1 + 1) AS s1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE tb1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 SIMPLE tb2 NULL ref f1 f1 4 test.tb1.f1 7 11.11 Using index condition; Using join buffer (Batched Key Access) +Warnings: +Note 1003 /* select#1 */ select /*+ BKA(`tb2`@`select#2`) */ `test`.`tb2`.`f1` AS `f1`,`test`.`tb2`.`f2` AS `f2`,`test`.`tb2`.`f3` AS `f3` from `test`.`t1` `tb1` join `test`.`t2` `tb2` where ((`test`.`tb2`.`f1` = `test`.`tb1`.`f1`) and (`test`.`tb2`.`f2` between `test`.`tb1`.`f1` and `test`.`tb1`.`f2`) and ((`test`.`tb2`.`f2` + 1) >= (`test`.`tb1`.`f1` + 1))) +# Check that PS and conventional statements give the same result. +FLUSH STATUS; +SELECT /*+ BKA(@qb1 t2) */ * FROM (SELECT /*+ QB_NAME(QB1) */ t2.f1, t2.f2, t2.f3 FROM t1,t2 +WHERE t1.f1=t2.f1 AND t2.f2 BETWEEN t1.f1 and t1.f2 and t2.f2 + 1 >= t1.f1 + 1) AS s1; +f1 f2 f3 +1 1 qwerty +2 2 qwerty +1 1 qwerty +2 2 qwerty +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 1 +Handler_read_key 8 +Handler_read_last 0 +Handler_read_next 20 +Handler_read_prev 0 +Handler_read_rnd 4 +Handler_read_rnd_next 4 +PREPARE stmt1 FROM "SELECT /*+ BKA(@qb1 t2) */ * FROM (SELECT /*+ QB_NAME(QB1) */ t2.f1, t2.f2, t2.f3 FROM t1,t2 +WHERE t1.f1=t2.f1 AND t2.f2 BETWEEN t1.f1 and t1.f2 and t2.f2 + 1 >= t1.f1 + 1) AS s1"; +FLUSH STATUS; +EXECUTE stmt1; +f1 f2 f3 +1 1 qwerty +2 2 qwerty +1 1 qwerty +2 2 qwerty +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 1 +Handler_read_key 8 +Handler_read_last 0 +Handler_read_next 20 +Handler_read_prev 0 +Handler_read_rnd 4 +Handler_read_rnd_next 4 +FLUSH STATUS; +EXECUTE stmt1; +f1 f2 f3 +1 1 qwerty +2 2 qwerty +1 1 qwerty +2 2 qwerty +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 1 +Handler_read_key 8 +Handler_read_last 0 +Handler_read_next 20 +Handler_read_prev 0 +Handler_read_rnd 4 +Handler_read_rnd_next 4 +DEALLOCATE PREPARE stmt1; +DROP TABLE t1, t2, t3; +# BNL & NO_BNL hint testing +set optimizer_switch=default; +set optimizer_switch='block_nested_loop=on'; +CREATE TABLE t1 (a INT, b INT); +INSERT INTO t1 VALUES (1,1),(2,2); +CREATE TABLE t2 (a INT, b INT); +INSERT INTO t2 VALUES (1,1),(2,2); +CREATE TABLE t3 (a INT, b INT); +INSERT INTO t3 VALUES (1,1),(2,2); +# Check statistics without hint +FLUSH STATUS; +SELECT t1.* FROM t1,t2,t3; +a b +1 1 +1 1 +1 1 +1 1 +2 2 +2 2 +2 2 +2 2 +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 3 +Handler_read_key 3 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 9 +# Check statistics with hint +FLUSH STATUS; +SELECT /*+ NO_BNL() */t1.* FROM t1,t2,t3; +a b +1 1 +1 1 +1 1 +1 1 +2 2 +2 2 +2 2 +2 2 +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 7 +Handler_read_key 7 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 21 +EXPLAIN SELECT t1.* FROM t1,t2,t3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` join `test`.`t2` join `test`.`t3` +EXPLAIN SELECT /*+ NO_BNL() */t1.* FROM t1,t2,t3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select /*+ NO_BNL(@`select#1`) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` join `test`.`t2` join `test`.`t3` +EXPLAIN SELECT /*+ NO_BNL(t2, t3) */t1.* FROM t1,t2,t3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select /*+ NO_BNL(`t2`@`select#1`) NO_BNL(`t3`@`select#1`) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` join `test`.`t2` join `test`.`t3` +EXPLAIN SELECT /*+ NO_BNL(t1, t3) */t1.* FROM t1,t2,t3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select /*+ NO_BNL(`t1`@`select#1`) NO_BNL(`t3`@`select#1`) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` join `test`.`t2` join `test`.`t3` +set optimizer_switch='block_nested_loop=off'; +EXPLAIN SELECT t1.* FROM t1,t2,t3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` join `test`.`t2` join `test`.`t3` +EXPLAIN SELECT /*+ BNL() */t1.* FROM t1,t2,t3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select /*+ BNL(@`select#1`) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` join `test`.`t2` join `test`.`t3` +EXPLAIN SELECT /*+ BNL(t2, t3) */t1.* FROM t1,t2,t3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select /*+ BNL(`t2`@`select#1`) BNL(`t3`@`select#1`) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` join `test`.`t2` join `test`.`t3` +EXPLAIN SELECT /*+ BNL(t1, t3) */t1.* FROM t1,t2,t3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select /*+ BNL(`t1`@`select#1`) BNL(`t3`@`select#1`) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` join `test`.`t2` join `test`.`t3` +EXPLAIN SELECT /*+ BNL(t2) BNL(t3) */t1.* FROM t1,t2,t3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select /*+ BNL(`t2`@`select#1`) BNL(`t3`@`select#1`) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` join `test`.`t2` join `test`.`t3` +DROP TABLE t1, t2, t3; +# BNL in subquery +set optimizer_switch = DEFAULT; +CREATE TABLE t1 (a INT, b INT, PRIMARY KEY (a)); +CREATE TABLE t2 (a INT, INDEX a (a)); +CREATE TABLE t3 (a INT, b INT, INDEX a (a,b)); +INSERT INTO t1 VALUES (1,10), (2,20), (3,30), (4,40); +INSERT INTO t2 VALUES (2), (3), (4), (5); +INSERT INTO t3 VALUES (10,3), (20,4), (30,5); +ANALYZE TABLE t1, t2, t3; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +SET optimizer_prune_level = 0; +EXPLAIN SELECT /*+ QB_NAME(q) */ * FROM t1 JOIN t2 ON t1.b = t2.a WHERE +t2.a IN (SELECT /*+ QB_NAME(subq1) */ t3.b FROM t3 JOIN t1 t4 ON t3.b = t4.b); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using where +1 SIMPLE t2 NULL ref a a 5 .b 1 100.00 Using index +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t3 NULL index NULL a 10 NULL 3 100.00 Using index +2 MATERIALIZED t4 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select /*+ QB_NAME(`q`) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a` from `test`.`t1` join `test`.`t2` semi join (`test`.`t3` join `test`.`t1` `t4`) where ((`test`.`t2`.`a` = ``.`b`) and (`test`.`t1`.`b` = ``.`b`) and (`test`.`t4`.`b` = `test`.`t3`.`b`)) +EXPLAIN SELECT /*+ QB_NAME(q) NO_BNL() */ * FROM t1 JOIN t2 ON t1.b = t2.a WHERE +t2.a IN (SELECT /*+ QB_NAME(subq1) */ t3.b FROM t3 JOIN t1 t4 ON t3.b = t4.b); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using where +1 SIMPLE t2 NULL ref a a 5 .b 1 100.00 Using index +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 25.00 Using where +2 MATERIALIZED t3 NULL index NULL a 10 NULL 3 100.00 Using index +2 MATERIALIZED t4 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select /*+ QB_NAME(`q`) NO_BNL(@`q`) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a` from `test`.`t1` join `test`.`t2` semi join (`test`.`t3` join `test`.`t1` `t4`) where ((`test`.`t2`.`a` = ``.`b`) and (`test`.`t1`.`b` = ``.`b`) and (`test`.`t4`.`b` = `test`.`t3`.`b`)) +EXPLAIN SELECT /*+ QB_NAME(q) NO_BNL(t1, t2) */ * FROM t1 JOIN t2 ON t1.b = t2.a WHERE +t2.a IN (SELECT /*+ QB_NAME(subq1) */ t3.b FROM t3 JOIN t1 t4 ON t3.b = t4.b); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using where +1 SIMPLE t2 NULL ref a a 5 .b 1 100.00 Using index +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 25.00 Using where +2 MATERIALIZED t3 NULL index NULL a 10 NULL 3 100.00 Using index +2 MATERIALIZED t4 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select /*+ QB_NAME(`q`) NO_BNL(`t1`@`q`) NO_BNL(`t2`@`q`) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a` from `test`.`t1` join `test`.`t2` semi join (`test`.`t3` join `test`.`t1` `t4`) where ((`test`.`t2`.`a` = ``.`b`) and (`test`.`t1`.`b` = ``.`b`) and (`test`.`t4`.`b` = `test`.`t3`.`b`)) +EXPLAIN SELECT /*+ QB_NAME(q) NO_BNL(@subq1) */ * FROM t1 JOIN t2 ON t1.b = t2.a WHERE +t2.a IN (SELECT /*+ QB_NAME(subq1) */ t3.b FROM t3 JOIN t1 t4 ON t3.b = t4.b); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using where +1 SIMPLE t2 NULL ref a a 5 .b 1 100.00 Using index +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t3 NULL index NULL a 10 NULL 3 100.00 Using index +2 MATERIALIZED t4 NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select /*+ QB_NAME(`q`) NO_BNL(@`subq1`) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a` from `test`.`t1` join `test`.`t2` semi join (`test`.`t3` join `test`.`t1` `t4`) where ((`test`.`t2`.`a` = ``.`b`) and (`test`.`t1`.`b` = ``.`b`) and (`test`.`t4`.`b` = `test`.`t3`.`b`)) +EXPLAIN SELECT /*+ QB_NAME(q) NO_BNL(t4@subq1) */ * FROM t1 JOIN t2 ON t1.b = t2.a WHERE +t2.a IN (SELECT /*+ QB_NAME(subq1) */ t3.b FROM t3 JOIN t1 t4 ON t3.b = t4.b); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using where +1 SIMPLE t2 NULL ref a a 5 .b 1 100.00 Using index +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t4 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +2 MATERIALIZED t3 NULL index NULL a 10 NULL 3 33.33 Using where; Using index; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select /*+ QB_NAME(`q`) NO_BNL(`t4`@`subq1`) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a` from `test`.`t1` join `test`.`t2` semi join (`test`.`t3` join `test`.`t1` `t4`) where ((`test`.`t2`.`a` = ``.`b`) and (`test`.`t1`.`b` = ``.`b`) and (`test`.`t3`.`b` = `test`.`t4`.`b`)) +EXPLAIN SELECT /*+ QB_NAME(q) NO_BNL(t3@subq1,t4@subq1) */ * FROM t1 JOIN t2 ON t1.b = t2.a WHERE +t2.a IN (SELECT /*+ QB_NAME(subq1) */ t3.b FROM t3 JOIN t1 t4 ON t3.b = t4.b); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using where +1 SIMPLE t2 NULL ref a a 5 .b 1 100.00 Using index +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t3 NULL index NULL a 10 NULL 3 100.00 Using index +2 MATERIALIZED t4 NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select /*+ QB_NAME(`q`) NO_BNL(`t3`@`subq1`) NO_BNL(`t4`@`subq1`) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a` from `test`.`t1` join `test`.`t2` semi join (`test`.`t3` join `test`.`t1` `t4`) where ((`test`.`t2`.`a` = ``.`b`) and (`test`.`t1`.`b` = ``.`b`) and (`test`.`t4`.`b` = `test`.`t3`.`b`)) +EXPLAIN SELECT /*+ QB_NAME(q) NO_BNL(@subq1 t3, t4) */ * FROM t1 JOIN t2 ON t1.b = t2.a WHERE +t2.a IN (SELECT /*+ QB_NAME(subq1) */ t3.b FROM t3 JOIN t1 t4 ON t3.b = t4.b); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using where +1 SIMPLE t2 NULL ref a a 5 .b 1 100.00 Using index +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t3 NULL index NULL a 10 NULL 3 100.00 Using index +2 MATERIALIZED t4 NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select /*+ QB_NAME(`q`) NO_BNL(`t3`@`subq1`) NO_BNL(`t4`@`subq1`) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a` from `test`.`t1` join `test`.`t2` semi join (`test`.`t3` join `test`.`t1` `t4`) where ((`test`.`t2`.`a` = ``.`b`) and (`test`.`t1`.`b` = ``.`b`) and (`test`.`t4`.`b` = `test`.`t3`.`b`)) +EXPLAIN SELECT /*+ QB_NAME(q) */ * FROM t1 JOIN t2 ON t1.b = t2.a WHERE +t2.a IN (SELECT /*+ QB_NAME(subq1) NO_BNL(t3, t4) */ t3.b FROM t3 JOIN t1 t4 ON t3.b = t4.b); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using where +1 SIMPLE t2 NULL ref a a 5 .b 1 100.00 Using index +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t3 NULL index NULL a 10 NULL 3 100.00 Using index +2 MATERIALIZED t4 NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select /*+ QB_NAME(`q`) NO_BNL(`t3`@`subq1`) NO_BNL(`t4`@`subq1`) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a` from `test`.`t1` join `test`.`t2` semi join (`test`.`t3` join `test`.`t1` `t4`) where ((`test`.`t2`.`a` = ``.`b`) and (`test`.`t1`.`b` = ``.`b`) and (`test`.`t4`.`b` = `test`.`t3`.`b`)) +SET optimizer_prune_level = DEFAULT; +DROP TABLE t1, t2, t3; +# MRR & NO_MRR hint testing +set optimizer_switch=default; +CREATE TABLE t1 +( +f1 int NOT NULL DEFAULT '0', +f2 int NOT NULL DEFAULT '0', +f3 int NOT NULL DEFAULT '0', +INDEX idx1(f2, f3), INDEX idx2(f3) +); +INSERT INTO t1(f1) VALUES (1), (2), (3), (4), (5), (6), (7), (8); +INSERT INTO t1(f2, f3) VALUES (3,4), (3,4); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +set optimizer_switch='mrr=on,mrr_cost_based=off'; +# Check statistics without hint +FLUSH STATUS; +SELECT * FROM t1 WHERE f2 <= 3 AND 3 <= f3; +f1 f2 f3 +0 3 4 +0 3 4 +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 2 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 3 +# Check statistics with hint +FLUSH STATUS; +SELECT /*+ NO_MRR(t1) */ * FROM t1 WHERE f2 <= 3 AND 3 <= f3; +f1 f2 f3 +0 3 4 +0 3 4 +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 2 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 3 +EXPLAIN SELECT * FROM t1 WHERE f2 <= 3 AND 3 <= f3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range idx1,idx2 idx2 4 NULL 2 100.00 Using index condition; Using where; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`f1` AS `f1`,`test`.`t1`.`f2` AS `f2`,`test`.`t1`.`f3` AS `f3` from `test`.`t1` where ((`test`.`t1`.`f2` <= 3) and (3 <= `test`.`t1`.`f3`)) +# Turn off MRR. MRR should not be used. +EXPLAIN SELECT /*+ NO_MRR(t1) */ * FROM t1 WHERE f2 <= 3 AND 3 <= f3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range idx1,idx2 idx2 4 NULL 2 100.00 Using index condition; Using where +Warnings: +Note 1003 /* select#1 */ select /*+ NO_MRR(`t1`@`select#1`) */ `test`.`t1`.`f1` AS `f1`,`test`.`t1`.`f2` AS `f2`,`test`.`t1`.`f3` AS `f3` from `test`.`t1` where ((`test`.`t1`.`f2` <= 3) and (3 <= `test`.`t1`.`f3`)) +# Turn off MRR. MRR should not be used. +EXPLAIN SELECT /*+ NO_MRR(t1 idx2) */ * FROM t1 WHERE f2 <= 3 AND 3 <= f3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range idx1,idx2 idx2 4 NULL 2 100.00 Using index condition; Using where +Warnings: +Note 1003 /* select#1 */ select /*+ NO_MRR(`t1`@`select#1` `idx2`) */ `test`.`t1`.`f1` AS `f1`,`test`.`t1`.`f2` AS `f2`,`test`.`t1`.`f3` AS `f3` from `test`.`t1` where ((`test`.`t1`.`f2` <= 3) and (3 <= `test`.`t1`.`f3`)) +# Turn off MRR for unused key. MRR should be used. +EXPLAIN SELECT /*+ NO_MRR(t1 idx1) */ * FROM t1 WHERE f2 <= 3 AND 3 <= f3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range idx1,idx2 idx2 4 NULL 2 100.00 Using index condition; Using where; Using MRR +Warnings: +Note 1003 /* select#1 */ select /*+ NO_MRR(`t1`@`select#1` `idx1`) */ `test`.`t1`.`f1` AS `f1`,`test`.`t1`.`f2` AS `f2`,`test`.`t1`.`f3` AS `f3` from `test`.`t1` where ((`test`.`t1`.`f2` <= 3) and (3 <= `test`.`t1`.`f3`)) +set optimizer_switch='mrr=off,mrr_cost_based=off'; +EXPLAIN SELECT * FROM t1 WHERE f2 <= 3 AND 3 <= f3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range idx1,idx2 idx2 4 NULL 2 100.00 Using index condition; Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`f1` AS `f1`,`test`.`t1`.`f2` AS `f2`,`test`.`t1`.`f3` AS `f3` from `test`.`t1` where ((`test`.`t1`.`f2` <= 3) and (3 <= `test`.`t1`.`f3`)) +# Turn on MRR. MRR should be used. +EXPLAIN SELECT /*+ MRR(t1) */ * FROM t1 WHERE f2 <= 3 AND 3 <= f3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range idx1,idx2 idx2 4 NULL 2 100.00 Using index condition; Using where; Using MRR +Warnings: +Note 1003 /* select#1 */ select /*+ MRR(`t1`@`select#1`) */ `test`.`t1`.`f1` AS `f1`,`test`.`t1`.`f2` AS `f2`,`test`.`t1`.`f3` AS `f3` from `test`.`t1` where ((`test`.`t1`.`f2` <= 3) and (3 <= `test`.`t1`.`f3`)) +# Turn on MRR. MRR should be used. +EXPLAIN SELECT /*+ MRR(t1 IDX2) */ * FROM t1 WHERE f2 <= 3 AND 3 <= f3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range idx1,idx2 idx2 4 NULL 2 100.00 Using index condition; Using where; Using MRR +Warnings: +Note 1003 /* select#1 */ select /*+ MRR(`t1`@`select#1` `IDX2`) */ `test`.`t1`.`f1` AS `f1`,`test`.`t1`.`f2` AS `f2`,`test`.`t1`.`f3` AS `f3` from `test`.`t1` where ((`test`.`t1`.`f2` <= 3) and (3 <= `test`.`t1`.`f3`)) +# Turn on MRR for unused key. MRR should not be used. +EXPLAIN SELECT /*+ MRR(t1 idx1) */ * FROM t1 WHERE f2 <= 3 AND 3 <= f3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range idx1,idx2 idx2 4 NULL 2 100.00 Using index condition; Using where +Warnings: +Note 1003 /* select#1 */ select /*+ MRR(`t1`@`select#1` `idx1`) */ `test`.`t1`.`f1` AS `f1`,`test`.`t1`.`f2` AS `f2`,`test`.`t1`.`f3` AS `f3` from `test`.`t1` where ((`test`.`t1`.`f2` <= 3) and (3 <= `test`.`t1`.`f3`)) +set optimizer_switch='mrr=off,mrr_cost_based=on'; +EXPLAIN SELECT * FROM t1 WHERE f2 <= 3 AND 3 <= f3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range idx1,idx2 idx2 4 NULL 2 100.00 Using index condition; Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`f1` AS `f1`,`test`.`t1`.`f2` AS `f2`,`test`.`t1`.`f3` AS `f3` from `test`.`t1` where ((`test`.`t1`.`f2` <= 3) and (3 <= `test`.`t1`.`f3`)) +# Turn on MRR. MRR should be used. +EXPLAIN SELECT /*+ MRR(t1) */ * FROM t1 WHERE f2 <= 3 AND 3 <= f3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range idx1,idx2 idx2 4 NULL 2 100.00 Using index condition; Using where; Using MRR +Warnings: +Note 1003 /* select#1 */ select /*+ MRR(`t1`@`select#1`) */ `test`.`t1`.`f1` AS `f1`,`test`.`t1`.`f2` AS `f2`,`test`.`t1`.`f3` AS `f3` from `test`.`t1` where ((`test`.`t1`.`f2` <= 3) and (3 <= `test`.`t1`.`f3`)) +# Turn on MRR. MRR should be used. +EXPLAIN SELECT /*+ MRR(t1 idx2) */ * FROM t1 WHERE f2 <= 3 AND 3 <= f3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range idx1,idx2 idx2 4 NULL 2 100.00 Using index condition; Using where; Using MRR +Warnings: +Note 1003 /* select#1 */ select /*+ MRR(`t1`@`select#1` `idx2`) */ `test`.`t1`.`f1` AS `f1`,`test`.`t1`.`f2` AS `f2`,`test`.`t1`.`f3` AS `f3` from `test`.`t1` where ((`test`.`t1`.`f2` <= 3) and (3 <= `test`.`t1`.`f3`)) +# Turn on MRR for unused key. MRR should not be used. +EXPLAIN SELECT /*+ MRR(t1 IDX1) */ * FROM t1 WHERE f2 <= 3 AND 3 <= f3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range idx1,idx2 idx2 4 NULL 2 100.00 Using index condition; Using where +Warnings: +Note 1003 /* select#1 */ select /*+ MRR(`t1`@`select#1` `IDX1`) */ `test`.`t1`.`f1` AS `f1`,`test`.`t1`.`f2` AS `f2`,`test`.`t1`.`f3` AS `f3` from `test`.`t1` where ((`test`.`t1`.`f2` <= 3) and (3 <= `test`.`t1`.`f3`)) +DROP TABLE t1; +# +# Bug#21205282 CRASH/ASSERTION IN JOIN_CACHE::SET_MATCH_FLAG_IF_NONE WITH NO_BNL HINT +# +CREATE TABLE t(a INT); +INSERT INTO t VALUES (1); +SET optimizer_switch='block_nested_loop=on'; +EXPLAIN SELECT 1 FROM t t1 LEFT JOIN t t2 ON 1 LEFT JOIN (t t3 LEFT JOIN t t4 ON 1) ON 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t` `t1` left join `test`.`t` `t2` on(true) left join (`test`.`t` `t3` left join `test`.`t` `t4` on(true)) on(true) where true +EXPLAIN SELECT /*+ NO_BNL(t1) */ 1 FROM t t1 LEFT JOIN t t2 ON 1 LEFT JOIN (t t3 LEFT JOIN t t4 ON 1) ON 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select /*+ NO_BNL(`t1`@`select#1`) */ 1 AS `1` from `test`.`t` `t1` left join `test`.`t` `t2` on(true) left join (`test`.`t` `t3` left join `test`.`t` `t4` on(true)) on(true) where true +EXPLAIN SELECT /*+ NO_BNL(t2) */ 1 FROM t t1 LEFT JOIN t t2 ON 1 LEFT JOIN (t t3 LEFT JOIN t t4 ON 1) ON 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select /*+ NO_BNL(`t2`@`select#1`) */ 1 AS `1` from `test`.`t` `t1` left join `test`.`t` `t2` on(true) left join (`test`.`t` `t3` left join `test`.`t` `t4` on(true)) on(true) where true +EXPLAIN SELECT /*+ NO_BNL(t3) */ 1 FROM t t1 LEFT JOIN t t2 ON 1 LEFT JOIN (t t3 LEFT JOIN t t4 ON 1) ON 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select /*+ NO_BNL(`t3`@`select#1`) */ 1 AS `1` from `test`.`t` `t1` left join `test`.`t` `t2` on(true) left join (`test`.`t` `t3` left join `test`.`t` `t4` on(true)) on(true) where true +EXPLAIN SELECT /*+ NO_BNL(t4) */ 1 FROM t t1 LEFT JOIN t t2 ON 1 LEFT JOIN (t t3 LEFT JOIN t t4 ON 1) ON 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select /*+ NO_BNL(`t4`@`select#1`) */ 1 AS `1` from `test`.`t` `t1` left join `test`.`t` `t2` on(true) left join (`test`.`t` `t3` left join `test`.`t` `t4` on(true)) on(true) where true +EXPLAIN SELECT /*+ NO_BNL(t3) */ 1 FROM t t1 LEFT JOIN (t t2 LEFT JOIN t t3 ON 1 LEFT JOIN t t4 ON 1) ON 1 WHERE 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select /*+ NO_BNL(`t3`@`select#1`) */ 1 AS `1` from `test`.`t` `t1` left join (`test`.`t` `t2` left join `test`.`t` `t3` on(true) left join `test`.`t` `t4` on(true)) on(true) where true +SELECT /*+ NO_BNL(t4) */ 1 FROM t t1 LEFT JOIN t t2 ON 1 LEFT JOIN (t t3 LEFT JOIN t t4 ON 1) ON 1; +1 +1 +SELECT /*+ NO_BNL(t3) */ 1 FROM t t1 LEFT JOIN (t t2 LEFT JOIN t t3 ON 1 LEFT JOIN t t4 ON 1) ON 1 WHERE 1; +1 +1 +SET optimizer_switch='block_nested_loop=off'; +EXPLAIN SELECT 1 FROM t t1 LEFT JOIN (t t2 LEFT JOIN t t3 ON 1 INNER JOIN t t4 ON 1) ON 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t` `t1` left join (`test`.`t` `t2` left join `test`.`t` `t3` on(true) join `test`.`t` `t4`) on((true)) where true +EXPLAIN SELECT /*+ BNL(t1) */ 1 FROM t t1 LEFT JOIN (t t2 LEFT JOIN t t3 ON 1 INNER JOIN t t4 ON 1) ON 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select /*+ BNL(`t1`@`select#1`) */ 1 AS `1` from `test`.`t` `t1` left join (`test`.`t` `t2` left join `test`.`t` `t3` on(true) join `test`.`t` `t4`) on((true)) where true +EXPLAIN SELECT /*+ BNL(t2) */ 1 FROM t t1 LEFT JOIN (t t2 LEFT JOIN t t3 ON 1 INNER JOIN t t4 ON 1) ON 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select /*+ BNL(`t2`@`select#1`) */ 1 AS `1` from `test`.`t` `t1` left join (`test`.`t` `t2` left join `test`.`t` `t3` on(true) join `test`.`t` `t4`) on((true)) where true +EXPLAIN SELECT /*+ BNL(t3) */ 1 FROM t t1 LEFT JOIN (t t2 LEFT JOIN t t3 ON 1 INNER JOIN t t4 ON 1) ON 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select /*+ BNL(`t3`@`select#1`) */ 1 AS `1` from `test`.`t` `t1` left join (`test`.`t` `t2` left join `test`.`t` `t3` on(true) join `test`.`t` `t4`) on((true)) where true +EXPLAIN SELECT /*+ BNL(t4) */ 1 FROM t t1 LEFT JOIN (t t2 LEFT JOIN t t3 ON 1 INNER JOIN t t4 ON 1) ON 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select /*+ BNL(`t4`@`select#1`) */ 1 AS `1` from `test`.`t` `t1` left join (`test`.`t` `t2` left join `test`.`t` `t3` on(true) join `test`.`t` `t4`) on((true)) where true +EXPLAIN SELECT /*+ BNL(t2, t3) */ 1 FROM t t1 LEFT JOIN (t t2 LEFT JOIN t t3 ON 1 INNER JOIN t t4 ON 1) ON 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select /*+ BNL(`t2`@`select#1`) BNL(`t3`@`select#1`) */ 1 AS `1` from `test`.`t` `t1` left join (`test`.`t` `t2` left join `test`.`t` `t3` on(true) join `test`.`t` `t4`) on((true)) where true +EXPLAIN SELECT /*+ BNL(t3, t4) */ 1 FROM t t1 LEFT JOIN (t t2 LEFT JOIN t t3 ON 1 INNER JOIN t t4 ON 1) ON 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select /*+ BNL(`t3`@`select#1`) BNL(`t4`@`select#1`) */ 1 AS `1` from `test`.`t` `t1` left join (`test`.`t` `t2` left join `test`.`t` `t3` on(true) join `test`.`t` `t4`) on((true)) where true +EXPLAIN SELECT /*+ BNL(t2, t3, t4) */ 1 FROM t t1 LEFT JOIN (t t2 LEFT JOIN t t3 ON 1 INNER JOIN t t4 ON 1) ON 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 1 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select /*+ BNL(`t2`@`select#1`) BNL(`t3`@`select#1`) BNL(`t4`@`select#1`) */ 1 AS `1` from `test`.`t` `t1` left join (`test`.`t` `t2` left join `test`.`t` `t3` on(true) join `test`.`t` `t4`) on((true)) where true +DROP TABLE t; +CREATE TABLE t(a INT, b INT, KEY k(a)); +INSERT INTO t VALUES (1,1); +EXPLAIN SELECT * FROM t t1 LEFT JOIN (t t2 LEFT JOIN t t3 USING(a) LEFT JOIN t t4 USING(a)) USING(a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t2 NULL ref k k 5 test.t1.a 1 100.00 NULL +2 SIMPLE t3 NULL ref k k 5 test.t1.a 1 100.00 NULL +2 SIMPLE t4 NULL ref k k 5 test.t1.a 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`b` AS `b` from `test`.`t` `t1` left join (`test`.`t` `t2` left join `test`.`t` `t3` on((`test`.`t3`.`a` = `test`.`t1`.`a`)) left join `test`.`t` `t4` on((`test`.`t4`.`a` = `test`.`t1`.`a`))) on((`test`.`t2`.`a` = `test`.`t1`.`a`)) where true +EXPLAIN SELECT /*+ BKA(t1) */ * FROM t t1 LEFT JOIN (t t2 LEFT JOIN t t3 USING(a) LEFT JOIN t t4 USING(a)) USING(a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t2 NULL ref k k 5 test.t1.a 1 100.00 NULL +2 SIMPLE t3 NULL ref k k 5 test.t1.a 1 100.00 NULL +2 SIMPLE t4 NULL ref k k 5 test.t1.a 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select /*+ BKA(`t1`@`select#1`) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`b` AS `b` from `test`.`t` `t1` left join (`test`.`t` `t2` left join `test`.`t` `t3` on((`test`.`t3`.`a` = `test`.`t1`.`a`)) left join `test`.`t` `t4` on((`test`.`t4`.`a` = `test`.`t1`.`a`))) on((`test`.`t2`.`a` = `test`.`t1`.`a`)) where true +EXPLAIN SELECT /*+ BKA(t2) */ * FROM t t1 LEFT JOIN (t t2 LEFT JOIN t t3 USING(a) LEFT JOIN t t4 USING(a)) USING(a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t2 NULL ref k k 5 test.t1.a 1 100.00 NULL +2 SIMPLE t3 NULL ref k k 5 test.t1.a 1 100.00 NULL +2 SIMPLE t4 NULL ref k k 5 test.t1.a 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select /*+ BKA(`t2`@`select#1`) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`b` AS `b` from `test`.`t` `t1` left join (`test`.`t` `t2` left join `test`.`t` `t3` on((`test`.`t3`.`a` = `test`.`t1`.`a`)) left join `test`.`t` `t4` on((`test`.`t4`.`a` = `test`.`t1`.`a`))) on((`test`.`t2`.`a` = `test`.`t1`.`a`)) where true +EXPLAIN SELECT /*+ BKA(t3) */ * FROM t t1 LEFT JOIN (t t2 LEFT JOIN t t3 USING(a) LEFT JOIN t t4 USING(a)) USING(a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t2 NULL ref k k 5 test.t1.a 1 100.00 NULL +2 SIMPLE t3 NULL ref k k 5 test.t1.a 1 100.00 NULL +2 SIMPLE t4 NULL ref k k 5 test.t1.a 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select /*+ BKA(`t3`@`select#1`) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`b` AS `b` from `test`.`t` `t1` left join (`test`.`t` `t2` left join `test`.`t` `t3` on((`test`.`t3`.`a` = `test`.`t1`.`a`)) left join `test`.`t` `t4` on((`test`.`t4`.`a` = `test`.`t1`.`a`))) on((`test`.`t2`.`a` = `test`.`t1`.`a`)) where true +EXPLAIN SELECT /*+ BKA(t4) */ * FROM t t1 LEFT JOIN (t t2 LEFT JOIN t t3 USING(a) LEFT JOIN t t4 USING(a)) USING(a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t2 NULL ref k k 5 test.t1.a 1 100.00 NULL +2 SIMPLE t3 NULL ref k k 5 test.t1.a 1 100.00 NULL +2 SIMPLE t4 NULL ref k k 5 test.t1.a 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select /*+ BKA(`t4`@`select#1`) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`b` AS `b` from `test`.`t` `t1` left join (`test`.`t` `t2` left join `test`.`t` `t3` on((`test`.`t3`.`a` = `test`.`t1`.`a`)) left join `test`.`t` `t4` on((`test`.`t4`.`a` = `test`.`t1`.`a`))) on((`test`.`t2`.`a` = `test`.`t1`.`a`)) where true +EXPLAIN SELECT /*+ BKA(t2, t3) */ * FROM t t1 LEFT JOIN (t t2 LEFT JOIN t t3 USING(a) LEFT JOIN t t4 USING(a)) USING(a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t2 NULL ref k k 5 test.t1.a 1 100.00 NULL +2 SIMPLE t3 NULL ref k k 5 test.t1.a 1 100.00 NULL +2 SIMPLE t4 NULL ref k k 5 test.t1.a 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select /*+ BKA(`t2`@`select#1`) BKA(`t3`@`select#1`) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`b` AS `b` from `test`.`t` `t1` left join (`test`.`t` `t2` left join `test`.`t` `t3` on((`test`.`t3`.`a` = `test`.`t1`.`a`)) left join `test`.`t` `t4` on((`test`.`t4`.`a` = `test`.`t1`.`a`))) on((`test`.`t2`.`a` = `test`.`t1`.`a`)) where true +EXPLAIN SELECT /*+ BKA(t2, t4) */ * FROM t t1 LEFT JOIN (t t2 LEFT JOIN t t3 USING(a) LEFT JOIN t t4 USING(a)) USING(a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t2 NULL ref k k 5 test.t1.a 1 100.00 NULL +2 SIMPLE t3 NULL ref k k 5 test.t1.a 1 100.00 NULL +2 SIMPLE t4 NULL ref k k 5 test.t1.a 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select /*+ BKA(`t2`@`select#1`) BKA(`t4`@`select#1`) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`b` AS `b` from `test`.`t` `t1` left join (`test`.`t` `t2` left join `test`.`t` `t3` on((`test`.`t3`.`a` = `test`.`t1`.`a`)) left join `test`.`t` `t4` on((`test`.`t4`.`a` = `test`.`t1`.`a`))) on((`test`.`t2`.`a` = `test`.`t1`.`a`)) where true +EXPLAIN SELECT /*+ BKA(t2, t3, t4) */ * FROM t t1 LEFT JOIN (t t2 LEFT JOIN t t3 USING(a) LEFT JOIN t t4 USING(a)) USING(a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t2 NULL ref k k 5 test.t1.a 1 100.00 Using join buffer (Batched Key Access) +2 SIMPLE t3 NULL ref k k 5 test.t1.a 1 100.00 Using join buffer (Batched Key Access) +2 SIMPLE t4 NULL ref k k 5 test.t1.a 1 100.00 Using join buffer (Batched Key Access) +Warnings: +Note 1003 /* select#1 */ select /*+ BKA(`t2`@`select#1`) BKA(`t3`@`select#1`) BKA(`t4`@`select#1`) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`b` AS `b` from `test`.`t` `t1` left join (`test`.`t` `t2` left join `test`.`t` `t3` on((`test`.`t3`.`a` = `test`.`t1`.`a`)) left join `test`.`t` `t4` on((`test`.`t4`.`a` = `test`.`t1`.`a`))) on((`test`.`t2`.`a` = `test`.`t1`.`a`)) where true +SET optimizer_switch='block_nested_loop=on,batched_key_access=on,mrr_cost_based=off'; +EXPLAIN SELECT * FROM t t1 INNER JOIN (t t2 LEFT JOIN t t3 ON t2.b=t3.b LEFT JOIN t t4 ON t3.b=t4.b) ON t1.a=t2.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL k NULL NULL NULL 1 100.00 Using where +2 SIMPLE t2 NULL ref k k 5 test.t1.a 1 100.00 NULL +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b` from `test`.`t` `t1` join `test`.`t` `t2` left join `test`.`t` `t3` on((`test`.`t3`.`b` = `test`.`t2`.`b`)) left join `test`.`t` `t4` on((`test`.`t4`.`b` = `test`.`t3`.`b`)) where (`test`.`t2`.`a` = `test`.`t1`.`a`) +EXPLAIN SELECT /*+ NO_BKA(t1) */ * FROM t t1 INNER JOIN (t t2 LEFT JOIN t t3 ON t2.b=t3.b LEFT JOIN t t4 ON t3.b=t4.b) ON t1.a=t2.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL k NULL NULL NULL 1 100.00 Using where +2 SIMPLE t2 NULL ref k k 5 test.t1.a 1 100.00 NULL +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select /*+ NO_BKA(`t1`@`select#1`) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b` from `test`.`t` `t1` join `test`.`t` `t2` left join `test`.`t` `t3` on((`test`.`t3`.`b` = `test`.`t2`.`b`)) left join `test`.`t` `t4` on((`test`.`t4`.`b` = `test`.`t3`.`b`)) where (`test`.`t2`.`a` = `test`.`t1`.`a`) +EXPLAIN SELECT /*+ NO_BKA(t2) */ * FROM t t1 INNER JOIN (t t2 LEFT JOIN t t3 ON t2.b=t3.b LEFT JOIN t t4 ON t3.b=t4.b) ON t1.a=t2.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL k NULL NULL NULL 1 100.00 Using where +2 SIMPLE t2 NULL ref k k 5 test.t1.a 1 100.00 NULL +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select /*+ NO_BKA(`t2`@`select#1`) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b` from `test`.`t` `t1` join `test`.`t` `t2` left join `test`.`t` `t3` on((`test`.`t3`.`b` = `test`.`t2`.`b`)) left join `test`.`t` `t4` on((`test`.`t4`.`b` = `test`.`t3`.`b`)) where (`test`.`t2`.`a` = `test`.`t1`.`a`) +EXPLAIN SELECT /*+ NO_BNL(t3) */ * FROM t t1 INNER JOIN (t t2 LEFT JOIN t t3 ON t2.b=t3.b LEFT JOIN t t4 ON t3.b=t4.b) ON t1.a=t2.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL k NULL NULL NULL 1 100.00 Using where +2 SIMPLE t2 NULL ref k k 5 test.t1.a 1 100.00 NULL +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select /*+ NO_BNL(`t3`@`select#1`) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b` from `test`.`t` `t1` join `test`.`t` `t2` left join `test`.`t` `t3` on((`test`.`t3`.`b` = `test`.`t2`.`b`)) left join `test`.`t` `t4` on((`test`.`t4`.`b` = `test`.`t3`.`b`)) where (`test`.`t2`.`a` = `test`.`t1`.`a`) +EXPLAIN SELECT /*+ NO_BNL(t4) */ * FROM t t1 INNER JOIN (t t2 LEFT JOIN t t3 ON t2.b=t3.b LEFT JOIN t t4 ON t3.b=t4.b) ON t1.a=t2.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL k NULL NULL NULL 1 100.00 Using where +2 SIMPLE t2 NULL ref k k 5 test.t1.a 1 100.00 NULL +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select /*+ NO_BNL(`t4`@`select#1`) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b` from `test`.`t` `t1` join `test`.`t` `t2` left join `test`.`t` `t3` on((`test`.`t3`.`b` = `test`.`t2`.`b`)) left join `test`.`t` `t4` on((`test`.`t4`.`b` = `test`.`t3`.`b`)) where (`test`.`t2`.`a` = `test`.`t1`.`a`) +EXPLAIN SELECT /*+ NO_BKA(t2) NO_BNL(t3) */ * FROM t t1 INNER JOIN (t t2 LEFT JOIN t t3 ON t2.b=t3.b LEFT JOIN t t4 ON t3.b=t4.b) ON t1.a=t2.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL k NULL NULL NULL 1 100.00 Using where +2 SIMPLE t2 NULL ref k k 5 test.t1.a 1 100.00 NULL +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select /*+ NO_BKA(`t2`@`select#1`) NO_BNL(`t3`@`select#1`) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b` from `test`.`t` `t1` join `test`.`t` `t2` left join `test`.`t` `t3` on((`test`.`t3`.`b` = `test`.`t2`.`b`)) left join `test`.`t` `t4` on((`test`.`t4`.`b` = `test`.`t3`.`b`)) where (`test`.`t2`.`a` = `test`.`t1`.`a`) +EXPLAIN SELECT /*+ NO_BNL(t3) NO_BKA(t4) */ * FROM t t1 INNER JOIN (t t2 LEFT JOIN t t3 ON t2.b=t3.b LEFT JOIN t t4 ON t3.b=t4.b) ON t1.a=t2.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL k NULL NULL NULL 1 100.00 Using where +2 SIMPLE t2 NULL ref k k 5 test.t1.a 1 100.00 NULL +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select /*+ NO_BNL(`t3`@`select#1`) NO_BKA(`t4`@`select#1`) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b` from `test`.`t` `t1` join `test`.`t` `t2` left join `test`.`t` `t3` on((`test`.`t3`.`b` = `test`.`t2`.`b`)) left join `test`.`t` `t4` on((`test`.`t4`.`b` = `test`.`t3`.`b`)) where (`test`.`t2`.`a` = `test`.`t1`.`a`) +EXPLAIN SELECT /*+ NO_BKA(t2) NO_BNL(t3) NO_BKA(t4) */ * FROM t t1 INNER JOIN (t t2 LEFT JOIN t t3 ON t2.b=t3.b LEFT JOIN t t4 ON t3.b=t4.b) ON t1.a=t2.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL k NULL NULL NULL 1 100.00 Using where +2 SIMPLE t2 NULL ref k k 5 test.t1.a 1 100.00 NULL +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select /*+ NO_BKA(`t2`@`select#1`) NO_BNL(`t3`@`select#1`) NO_BKA(`t4`@`select#1`) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b` from `test`.`t` `t1` join `test`.`t` `t2` left join `test`.`t` `t3` on((`test`.`t3`.`b` = `test`.`t2`.`b`)) left join `test`.`t` `t4` on((`test`.`t4`.`b` = `test`.`t3`.`b`)) where (`test`.`t2`.`a` = `test`.`t1`.`a`) +SET optimizer_switch='batched_key_access=off'; +EXPLAIN SELECT * FROM t t1 LEFT JOIN (t t2 LEFT JOIN t t3 ON t2.b=t3.b INNER JOIN t t4 ON t3.a=t4.a) ON t1.b=t2.b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 SIMPLE t3 NULL ALL k NULL NULL NULL 1 100.00 Using where +2 SIMPLE t4 NULL ref k k 5 test.t3.a 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b` from `test`.`t` `t1` left join (`test`.`t` `t2` join `test`.`t` `t3` join `test`.`t` `t4`) on(((`test`.`t4`.`a` = `test`.`t3`.`a`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t3`.`b` = `test`.`t1`.`b`))) where true +EXPLAIN SELECT /*+ BKA(t1) */ * FROM t t1 LEFT JOIN (t t2 LEFT JOIN t t3 ON t2.b=t3.b INNER JOIN t t4 ON t3.a=t4.a) ON t1.b=t2.b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 SIMPLE t3 NULL ALL k NULL NULL NULL 1 100.00 Using where +2 SIMPLE t4 NULL ref k k 5 test.t3.a 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select /*+ BKA(`t1`@`select#1`) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b` from `test`.`t` `t1` left join (`test`.`t` `t2` join `test`.`t` `t3` join `test`.`t` `t4`) on(((`test`.`t4`.`a` = `test`.`t3`.`a`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t3`.`b` = `test`.`t1`.`b`))) where true +EXPLAIN SELECT /*+ NO_BNL(t2) */ * FROM t t1 LEFT JOIN (t t2 LEFT JOIN t t3 ON t2.b=t3.b INNER JOIN t t4 ON t3.a=t4.a) ON t1.b=t2.b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 SIMPLE t3 NULL ALL k NULL NULL NULL 1 100.00 Using where +2 SIMPLE t4 NULL ref k k 5 test.t3.a 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select /*+ NO_BNL(`t2`@`select#1`) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b` from `test`.`t` `t1` left join (`test`.`t` `t2` join `test`.`t` `t3` join `test`.`t` `t4`) on(((`test`.`t4`.`a` = `test`.`t3`.`a`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t3`.`b` = `test`.`t1`.`b`))) where true +EXPLAIN SELECT /*+ BNL(t3) */ * FROM t t1 LEFT JOIN (t t2 LEFT JOIN t t3 ON t2.b=t3.b INNER JOIN t t4 ON t3.a=t4.a) ON t1.b=t2.b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 SIMPLE t3 NULL ALL k NULL NULL NULL 1 100.00 Using where +2 SIMPLE t4 NULL ref k k 5 test.t3.a 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select /*+ BNL(`t3`@`select#1`) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b` from `test`.`t` `t1` left join (`test`.`t` `t2` join `test`.`t` `t3` join `test`.`t` `t4`) on(((`test`.`t4`.`a` = `test`.`t3`.`a`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t3`.`b` = `test`.`t1`.`b`))) where true +EXPLAIN SELECT /*+ BKA(t4) */ * FROM t t1 LEFT JOIN (t t2 LEFT JOIN t t3 ON t2.b=t3.b INNER JOIN t t4 ON t3.a=t4.a) ON t1.b=t2.b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t3 NULL ALL k NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t4 NULL ref k k 5 test.t3.a 1 100.00 Using join buffer (Batched Key Access) +Warnings: +Note 1003 /* select#1 */ select /*+ BKA(`t4`@`select#1`) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b` from `test`.`t` `t1` left join (`test`.`t` `t2` join `test`.`t` `t3` join `test`.`t` `t4`) on(((`test`.`t4`.`a` = `test`.`t3`.`a`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t3`.`b` = `test`.`t1`.`b`))) where true +EXPLAIN SELECT /*+ BNL(t2, t3) */ * FROM t t1 LEFT JOIN (t t2 LEFT JOIN t t3 ON t2.b=t3.b INNER JOIN t t4 ON t3.a=t4.a) ON t1.b=t2.b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 SIMPLE t3 NULL ALL k NULL NULL NULL 1 100.00 Using where +2 SIMPLE t4 NULL ref k k 5 test.t3.a 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select /*+ BNL(`t2`@`select#1`) BNL(`t3`@`select#1`) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b` from `test`.`t` `t1` left join (`test`.`t` `t2` join `test`.`t` `t3` join `test`.`t` `t4`) on(((`test`.`t4`.`a` = `test`.`t3`.`a`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t3`.`b` = `test`.`t1`.`b`))) where true +EXPLAIN SELECT /*+ BKA(t3, t4) */ * FROM t t1 LEFT JOIN (t t2 LEFT JOIN t t3 ON t2.b=t3.b INNER JOIN t t4 ON t3.a=t4.a) ON t1.b=t2.b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t3 NULL ALL k NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t4 NULL ref k k 5 test.t3.a 1 100.00 Using join buffer (Batched Key Access) +Warnings: +Note 1003 /* select#1 */ select /*+ BKA(`t3`@`select#1`) BKA(`t4`@`select#1`) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b` from `test`.`t` `t1` left join (`test`.`t` `t2` join `test`.`t` `t3` join `test`.`t` `t4`) on(((`test`.`t4`.`a` = `test`.`t3`.`a`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t3`.`b` = `test`.`t1`.`b`))) where true +SET optimizer_switch='block_nested_loop=off'; +EXPLAIN SELECT * FROM t t1 LEFT JOIN (t t2 LEFT JOIN t t3 ON t2.b=t3.b INNER JOIN t t4 ON t3.a=t4.a) ON t1.b=t2.b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 SIMPLE t3 NULL ALL k NULL NULL NULL 1 100.00 Using where +2 SIMPLE t4 NULL ref k k 5 test.t3.a 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b` from `test`.`t` `t1` left join (`test`.`t` `t2` join `test`.`t` `t3` join `test`.`t` `t4`) on(((`test`.`t4`.`a` = `test`.`t3`.`a`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t3`.`b` = `test`.`t1`.`b`))) where true +EXPLAIN SELECT /*+ BKA(t1) */ * FROM t t1 LEFT JOIN (t t2 LEFT JOIN t t3 ON t2.b=t3.b INNER JOIN t t4 ON t3.a=t4.a) ON t1.b=t2.b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 SIMPLE t3 NULL ALL k NULL NULL NULL 1 100.00 Using where +2 SIMPLE t4 NULL ref k k 5 test.t3.a 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select /*+ BKA(`t1`@`select#1`) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b` from `test`.`t` `t1` left join (`test`.`t` `t2` join `test`.`t` `t3` join `test`.`t` `t4`) on(((`test`.`t4`.`a` = `test`.`t3`.`a`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t3`.`b` = `test`.`t1`.`b`))) where true +EXPLAIN SELECT /*+ BNL(t2) */ * FROM t t1 LEFT JOIN (t t2 LEFT JOIN t t3 ON t2.b=t3.b INNER JOIN t t4 ON t3.a=t4.a) ON t1.b=t2.b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 SIMPLE t3 NULL ALL k NULL NULL NULL 1 100.00 Using where +2 SIMPLE t4 NULL ref k k 5 test.t3.a 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select /*+ BNL(`t2`@`select#1`) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b` from `test`.`t` `t1` left join (`test`.`t` `t2` join `test`.`t` `t3` join `test`.`t` `t4`) on(((`test`.`t4`.`a` = `test`.`t3`.`a`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t3`.`b` = `test`.`t1`.`b`))) where true +EXPLAIN SELECT /*+ BNL(t3) */ * FROM t t1 LEFT JOIN (t t2 LEFT JOIN t t3 ON t2.b=t3.b INNER JOIN t t4 ON t3.a=t4.a) ON t1.b=t2.b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 SIMPLE t3 NULL ALL k NULL NULL NULL 1 100.00 Using where +2 SIMPLE t4 NULL ref k k 5 test.t3.a 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select /*+ BNL(`t3`@`select#1`) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b` from `test`.`t` `t1` left join (`test`.`t` `t2` join `test`.`t` `t3` join `test`.`t` `t4`) on(((`test`.`t4`.`a` = `test`.`t3`.`a`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t3`.`b` = `test`.`t1`.`b`))) where true +EXPLAIN SELECT /*+ BKA(t4) */ * FROM t t1 LEFT JOIN (t t2 LEFT JOIN t t3 ON t2.b=t3.b INNER JOIN t t4 ON t3.a=t4.a) ON t1.b=t2.b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 SIMPLE t3 NULL ALL k NULL NULL NULL 1 100.00 Using where +2 SIMPLE t4 NULL ref k k 5 test.t3.a 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select /*+ BKA(`t4`@`select#1`) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b` from `test`.`t` `t1` left join (`test`.`t` `t2` join `test`.`t` `t3` join `test`.`t` `t4`) on(((`test`.`t4`.`a` = `test`.`t3`.`a`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t3`.`b` = `test`.`t1`.`b`))) where true +EXPLAIN SELECT /*+ BNL(t2, t3) */ * FROM t t1 LEFT JOIN (t t2 LEFT JOIN t t3 ON t2.b=t3.b INNER JOIN t t4 ON t3.a=t4.a) ON t1.b=t2.b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 SIMPLE t3 NULL ALL k NULL NULL NULL 1 100.00 Using where +2 SIMPLE t4 NULL ref k k 5 test.t3.a 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select /*+ BNL(`t2`@`select#1`) BNL(`t3`@`select#1`) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b` from `test`.`t` `t1` left join (`test`.`t` `t2` join `test`.`t` `t3` join `test`.`t` `t4`) on(((`test`.`t4`.`a` = `test`.`t3`.`a`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t3`.`b` = `test`.`t1`.`b`))) where true +EXPLAIN SELECT /*+ BKA(t3, t4) */ * FROM t t1 LEFT JOIN (t t2 LEFT JOIN t t3 ON t2.b=t3.b INNER JOIN t t4 ON t3.a=t4.a) ON t1.b=t2.b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 SIMPLE t3 NULL ALL k NULL NULL NULL 1 100.00 Using where +2 SIMPLE t4 NULL ref k k 5 test.t3.a 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select /*+ BKA(`t3`@`select#1`) BKA(`t4`@`select#1`) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b` from `test`.`t` `t1` left join (`test`.`t` `t2` join `test`.`t` `t3` join `test`.`t` `t4`) on(((`test`.`t4`.`a` = `test`.`t3`.`a`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t3`.`b` = `test`.`t1`.`b`))) where true +EXPLAIN SELECT /*+ BNL(t2, t3, t4) */ * FROM t t1 LEFT JOIN (t t2 LEFT JOIN t t3 ON t2.b=t3.b INNER JOIN t t4 ON t3.a=t4.a) ON t1.b=t2.b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 SIMPLE t3 NULL ALL k NULL NULL NULL 1 100.00 Using where +2 SIMPLE t4 NULL ref k k 5 test.t3.a 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select /*+ BNL(`t2`@`select#1`) BNL(`t3`@`select#1`) BNL(`t4`@`select#1`) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b` from `test`.`t` `t1` left join (`test`.`t` `t2` join `test`.`t` `t3` join `test`.`t` `t4`) on(((`test`.`t4`.`a` = `test`.`t3`.`a`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t3`.`b` = `test`.`t1`.`b`))) where true +DROP TABLE t; +set optimizer_switch=default; +# +# Duplicate hints +# +CREATE TABLE t1 (i INT PRIMARY KEY); +SELECT /*+ BKA() BKA() */ 1; +1 +1 +Warnings: +Warning 3126 Hint BKA( ) is ignored as conflicting/duplicated +SELECT /*+ BKA(t1) BKA(t1) */ * FROM t1; +i +Warnings: +Warning 3126 Hint BKA(`t1` ) is ignored as conflicting/duplicated +SELECT /*+ QB_NAME(q1) BKA(t1@q1) BKA(t1@q1) */ * FROM t1; +i +Warnings: +Warning 3126 Hint BKA(`t1`@`q1` ) is ignored as conflicting/duplicated +SELECT /*+ QB_NAME(q1) NO_ICP(@q1 t1 PRIMARY) NO_ICP(@q1 t1 PRIMARY) */ * FROM t1; +i +Warnings: +Warning 3126 Hint NO_ICP(`t1`@`q1` `PRIMARY` ) is ignored as conflicting/duplicated +DROP TABLE t1; +# +# Bug#21192857 ASSERTION FAILED: KEYINFO_ARRAY.SIZE() == 0, FILE OPT_HINTS.CC:280 +# +CREATE TABLE t1(a INT, KEY(a)); +INSERT INTO t1(a) SELECT /*+ NO_RANGE_OPTIMIZATION(t1 a)*/ 1 FROM t1; +DROP TABLE t1; +# WL#8016 Parser for optimizer hints +CREATE TABLE t1 (i INT, j INT); +CREATE INDEX i1 ON t1(i); +CREATE INDEX i2 ON t1(j); + +# empty hint comment is ok: + +SELECT /*+*/ 1; +1 +1 +Warnings: +Warning 1064 Optimizer hint syntax error near '*/' at line 1 +SELECT /*+ */ 1; +1 +1 +Warnings: +Warning 1064 Optimizer hint syntax error near '*/' at line 1 +SELECT /*+ * ** / // /* */ 1; +1 +1 +Warnings: +Warning 1064 Optimizer hint syntax error near '* ** / // /* */ 1' at line 1 +SELECT /*+ @ */ 1; +1 +1 +Warnings: +Warning 1064 Optimizer hint syntax error near '@ */ 1' at line 1 +SELECT /*+ @foo */ 1; +1 +1 +Warnings: +Warning 1064 Optimizer hint syntax error near '@foo */ 1' at line 1 +SELECT /*+ foo@bar */ 1; +1 +1 +Warnings: +Warning 1064 Optimizer hint syntax error near 'foo@bar */ 1' at line 1 +SELECT /*+ foo @bar */ 1; +1 +1 +Warnings: +Warning 1064 Optimizer hint syntax error near 'foo @bar */ 1' at line 1 +SELECT /*+ `@` */ 1; +1 +1 +Warnings: +Warning 1064 Optimizer hint syntax error near '`@` */ 1' at line 1 +SELECT /*+ `@foo` */ 1; +1 +1 +Warnings: +Warning 1064 Optimizer hint syntax error near '`@foo` */ 1' at line 1 +SELECT /*+ `foo@bar` */ 1; +1 +1 +Warnings: +Warning 1064 Optimizer hint syntax error near '`foo@bar` */ 1' at line 1 +SELECT /*+ `foo @bar` */ 1; +1 +1 +Warnings: +Warning 1064 Optimizer hint syntax error near '`foo @bar` */ 1' at line 1 +SELECT /*+ BKA( @) */ 1; +1 +1 +Warnings: +Warning 1064 Optimizer hint syntax error near ') */ 1' at line 1 +SELECT /*+ BKA( @) */ 1; +1 +1 +Warnings: +Warning 1064 Optimizer hint syntax error near ') */ 1' at line 1 +SELECT /*+ BKA(t1 @) */ 1; +1 +1 +Warnings: +Warning 1064 Optimizer hint syntax error near '@) */ 1' at line 1 + +# We don't support "*/" inside quoted identifiers (syntax error): + +SELECT /*+ BKA(`test*/`) */ 1; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '`) */ 1' at line 1 + +# valid hint sequences: + +SELECT /*+ NO_ICP() */ 1; +1 +1 +Warnings: +Warning 1064 Optimizer hint syntax error near ') */ 1' at line 1 +SELECT /*+NO_ICP()*/ 1; +1 +1 +Warnings: +Warning 1064 Optimizer hint syntax error near ')*/ 1' at line 1 +SELECT /*+ NO_ICP () */ 1; +1 +1 +Warnings: +Warning 1064 Optimizer hint syntax error near ') */ 1' at line 1 +SELECT /*+ NO_ICP ( ) */ 1; +1 +1 +Warnings: +Warning 1064 Optimizer hint syntax error near ') */ 1' at line 1 +SELECT /*+ NO_ICP() */ 1 UNION SELECT 1; +1 +1 +Warnings: +Warning 1064 Optimizer hint syntax error near ') */ 1 UNION SELECT 1' at line 1 +(SELECT /*+ NO_ICP() */ 1) UNION (SELECT 1); +1 +1 +Warnings: +Warning 1064 Optimizer hint syntax error near ') */ 1) UNION (SELECT 1)' at line 1 +((SELECT /* + NO_ICP() */ 1)); +1 +1 +EXPLAIN SELECT /*+ QB_NAME(qb1) */ 1 UNION SELECT /*+ QB_NAME(qb2) */ 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +2 UNION NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +NULL UNION RESULT NULL ALL NULL NULL NULL NULL NULL NULL Using temporary +Warnings: +Note 1003 /* select#1 */ select /*+ QB_NAME(`qb1`) */ 1 AS `1` union /* select#2 */ select /*+ QB_NAME(`qb2`) */ 1 AS `1` +EXPLAIN (SELECT /*+ QB_NAME(qb1) */ 1) UNION (SELECT /*+ QB_NAME(qb2) */ 1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +2 UNION NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +NULL UNION RESULT NULL ALL NULL NULL NULL NULL NULL NULL Using temporary +Warnings: +Note 1003 /* select#1 */ select /*+ QB_NAME(`qb1`) */ 1 AS `1` union /* select#2 */ select /*+ QB_NAME(`qb2`) */ 1 AS `1` +UPDATE /*+ NO_ICP() */ t1 SET i = 10; +Warnings: +Warning 1064 Optimizer hint syntax error near ') */ t1 SET i = 10' at line 1 +INSERT /*+ NO_ICP() */ INTO t1 VALUES (); +Warnings: +Warning 1064 Optimizer hint syntax error near ') */ INTO t1 VALUES ()' at line 1 +REPLACE /*+ NO_ICP() */ INTO t1 VALUES (); +Warnings: +Warning 1064 Optimizer hint syntax error near ') */ INTO t1 VALUES ()' at line 1 +DELETE /*+ NO_ICP() */ FROM t1 WHERE 1; +Warnings: +Warning 1064 Optimizer hint syntax error near ') */ FROM t1 WHERE 1' at line 1 +SELECT /*+ BKA(t1) */ 1 FROM t1; +1 +SELECT /*+ BKA(a b) */ 1 FROM t1 a, t1 b; +1 +Warnings: +Warning 1064 Optimizer hint syntax error near 'b) */ 1 FROM t1 a, t1 b' at line 1 +SELECT /*+ NO_ICP(i1) */ 1 FROM t1; +1 +Warnings: +Warning 3128 Unresolved name `i1`@`select#1` for NO_ICP hint +SELECT /*+ NO_ICP(i1 i2) */ 1 FROM t1; +1 +Warnings: +Warning 3128 Unresolved name `i1`@`select#1` `i2` for NO_ICP hint +SELECT /*+ NO_ICP(@qb ident) */ 1 FROM t1; +1 +Warnings: +Warning 3127 Query block name `qb` is not found for NO_ICP hint +# +# test explainable statements for hint support: +# they should warn with a hint syntax error near "test */" +# +EXPLAIN SELECT /*+ test */ 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Warning 1064 Optimizer hint syntax error near 'test */ 1' at line 1 +Note 1003 /* select#1 */ select 1 AS `1` +EXPLAIN INSERT /*+ test */ INTO t1 VALUES (10, 10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 INSERT t1 NULL ALL NULL NULL NULL NULL NULL NULL NULL +Warnings: +Warning 1064 Optimizer hint syntax error near 'test */ INTO t1 VALUES (10, 10)' at line 1 +Note 1003 insert into `test`.`t1` values (10,10) +EXPLAIN REPLACE /*+ test */ INTO t1 VALUES (10, 10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 REPLACE t1 NULL ALL NULL NULL NULL NULL NULL NULL NULL +Warnings: +Warning 1064 Optimizer hint syntax error near 'test */ INTO t1 VALUES (10, 10)' at line 1 +Note 1003 replace into `test`.`t1` values (10,10) +EXPLAIN UPDATE /*+ test */ t1 SET i = 10 WHERE j = 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL range i2 i2 5 const 1 100.00 Using where +Warnings: +Warning 1064 Optimizer hint syntax error near 'test */ t1 SET i = 10 WHERE j = 10' at line 1 +Note 1003 update `test`.`t1` set `test`.`t1`.`i` = 10 where (`test`.`t1`.`j` = 10) +EXPLAIN DELETE /*+ test */ FROM t1 WHERE i = 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL range i1 i1 5 const 1 100.00 Using where +Warnings: +Warning 1064 Optimizer hint syntax error near 'test */ FROM t1 WHERE i = 10' at line 1 +Note 1003 delete from `test`.`t1` where (`test`.`t1`.`i` = 10) + +# non-alphabetic and non-ASCII identifiers: + +CREATE INDEX 3rd_index ON t1(i, j); +SELECT /*+ NO_ICP(3rd_index) */ 1 FROM t1; +1 +Warnings: +Warning 3128 Unresolved name `3rd_index`@`select#1` for NO_ICP hint +CREATE INDEX $index ON t1(j, i); +SELECT /*+ NO_ICP($index) */ 1 FROM t1; +1 +Warnings: +Warning 3128 Unresolved name `$index`@`select#1` for NO_ICP hint +CREATE TABLE ` quoted name теÑÑ‚` (i INT); +SELECT /*+ BKA(` quoted name теÑÑ‚`) */ 1 FROM t1; +1 +Warnings: +Warning 3128 Unresolved name ` quoted name теÑÑ‚`@`select#1` for BKA hint +SELECT /*+ BKA(` quoted name теÑÑ‚`@`select#1`) */ 1 FROM t1; +1 +Warnings: +Warning 3128 Unresolved name ` quoted name теÑÑ‚`@`select#1` for BKA hint +DROP TABLE ` quoted name теÑÑ‚`; +SET SQL_MODE = 'ANSI_QUOTES'; +CREATE TABLE " quoted name теÑÑ‚" (i INT); +SELECT /*+ BKA(" quoted name теÑÑ‚") */ 1 FROM t1; +1 +Warnings: +Warning 3128 Unresolved name " quoted name теÑÑ‚"@"select#1" for BKA hint +SELECT /*+ BKA(" quoted name теÑÑ‚"@"select#1") */ 1 FROM t1; +1 +Warnings: +Warning 3128 Unresolved name " quoted name теÑÑ‚"@"select#1" for BKA hint +CREATE TABLE `test1``test2``` (i INT); +SELECT /*+ BKA(`test1``test2```) */ 1; +1 +1 +Warnings: +Warning 3128 Unresolved name "test1`test2`"@"select#1" for BKA hint +SELECT /*+ BKA("test1""test2""") */ 1; +1 +1 +Warnings: +Warning 3128 Unresolved name "test1""test2"""@"select#1" for BKA hint +SET SQL_MODE = ''; +# should warn: +SELECT /*+ BKA(" quoted name теÑÑ‚") */ 1 FROM t1; +1 +Warnings: +Warning 1064 Optimizer hint syntax error near '" quoted name теÑÑ‚") */ 1 FROM t1' at line 1 +DROP TABLE ` quoted name теÑÑ‚`; +DROP TABLE `test1``test2```; +EXPLAIN SELECT /*+ QB_NAME(`*`) */ 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 /* select#1 */ select /*+ QB_NAME(`*`) */ 1 AS `1` +EXPLAIN SELECT /*+ QB_NAME(`a*`) */ 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 /* select#1 */ select /*+ QB_NAME(`a*`) */ 1 AS `1` +EXPLAIN SELECT /*+ QB_NAME(`*b`) */ 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 /* select#1 */ select /*+ QB_NAME(`*b`) */ 1 AS `1` +EXPLAIN SELECT /*+ QB_NAME(`a +b`) */ 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 /* select#1 */ select /*+ QB_NAME(`a +b`) */ 1 AS `1` +# hint syntax error: empty quoted identifier +EXPLAIN SELECT /*+ QB_NAME(``) */ 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Warning 1064 Optimizer hint syntax error near '``) */ 1' at line 1 +Note 1003 /* select#1 */ select 1 AS `1` +SET NAMES utf8; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +EXPLAIN SELECT /*+ QB_NAME(`¿``¿`) */ 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 /* select#1 */ select /*+ QB_NAME(`¿``¿`) */ 1 AS `1` +CREATE TABLE tableТ (i INT); +SELECT /*+ BKA(tableТ) */ 1 FROM t1; +1 +Warnings: +Warning 3128 Unresolved name `tableТ`@`select#1` for BKA hint +SELECT /*+ BKA(test@tableТ) */ 1 FROM t1; +1 +Warnings: +Warning 3127 Query block name `tableТ` is not found for BKA hint +DROP TABLE tableТ; +CREATE TABLE таблица (i INT); +SELECT /*+ BKA(`таблица`) */ 1 FROM t1; +1 +Warnings: +Warning 3128 Unresolved name `таблица`@`select#1` for BKA hint +SELECT /*+ BKA(таблица) */ 1 FROM t1; +1 +Warnings: +Warning 3128 Unresolved name `таблица`@`select#1` for BKA hint +SELECT /*+ BKA(test@таблица) */ 1 FROM t1; +1 +Warnings: +Warning 3127 Query block name `таблица` is not found for BKA hint +# broken multibyte char, should warn: +SELECT /*+ NO_ICP(`Ñ`) */ 1 FROM t1; +1 +Warnings: +Warning 1064 Optimizer hint syntax error near '`?`) */ 1 FROM t1' at line 1 +DROP TABLE таблица; +SET NAMES DEFAULT; + +# derived tables and other subqueries: + +SELECT * FROM (SELECT /*+ DEBUG_HINT3 */ 1) a; +1 +1 +Warnings: +Warning 1064 Optimizer hint syntax error near 'DEBUG_HINT3 */ 1) a' at line 1 +SELECT (SELECT /*+ DEBUG_HINT3 */ 1); +(SELECT /*+ DEBUG_HINT3 */ 1) +1 +Warnings: +Warning 1064 Optimizer hint syntax error near 'DEBUG_HINT3 */ 1)' at line 1 +SELECT 1 FROM DUAL WHERE 1 IN (SELECT /*+ DEBUG_HINT3 */ 1); +1 +1 +Warnings: +Warning 1064 Optimizer hint syntax error near 'DEBUG_HINT3 */ 1)' at line 1 + +# invalid hint sequences (should warn): + +SELECT /*+ 10 */ 1; +1 +1 +Warnings: +Warning 1064 Optimizer hint syntax error near '10 */ 1' at line 1 +SELECT /*+ NO_ICP() */ 1; +1 +1 +Warnings: +Warning 1064 Optimizer hint syntax error near ') */ 1' at line 1 +SELECT /*+ NO_ICP(10) */ 1; +1 +1 +Warnings: +Warning 1064 Optimizer hint syntax error near '10) */ 1' at line 1 +SELECT /*+ NO_ICP( */ 1; +1 +1 +Warnings: +Warning 1064 Optimizer hint syntax error near '*/' at line 1 +SELECT /*+ NO_ICP) */ 1; +1 +1 +Warnings: +Warning 1064 Optimizer hint syntax error near ') */ 1' at line 1 +SELECT /*+ NO_ICP(t1 */ 1; +1 +1 +Warnings: +Warning 1064 Optimizer hint syntax error near '*/' at line 1 +SELECT /*+ NO_ICP(t1 ( */ 1; +1 +1 +Warnings: +Warning 1064 Optimizer hint syntax error near '( */ 1' at line 1 +(SELECT 1) UNION (SELECT /*+ NO_ICP() */ 1); +1 +1 +Warnings: +Warning 1064 Optimizer hint syntax error near ') */ 1)' at line 1 +INSERT INTO t1 VALUES (1, 1), (2, 2); + +# wrong place for hint, so recognize that stuff as a regular commentary: + +SELECT 1 FROM /*+ regular commentary, not a hint! */ t1; +1 +1 +1 +SELECT 1 FROM /*+ #1 */ t1 WHERE /*+ #2 */ 1 /*+ #3 */; +1 +1 +1 +SELECT /*+ NO_ICP() */ 1 +FROM /*+ regular commentary, not a hint! */ t1; +1 +1 +1 +Warnings: +Warning 1064 Optimizer hint syntax error near ') */ 1 +FROM /*+ regular commentary, not a hint! */ t1' at line 1 +SELECT /*+ NO_ICP(t1) bad_hint */ 1 FROM t1; +1 +1 +1 +Warnings: +Warning 1064 Optimizer hint syntax error near 'bad_hint */ 1 FROM t1' at line 1 +SELECT /*+ +NO_ICP(@qb ident) +*/ 1 FROM t1; +1 +1 +1 +Warnings: +Warning 3127 Query block name `qb` is not found for NO_ICP hint +SELECT /*+ +? bad syntax +*/ 1; +1 +1 +Warnings: +Warning 1064 Optimizer hint syntax error near '? bad syntax +*/ 1' at line 2 +SELECT +/*+ ? bad syntax */ 1; +1 +1 +Warnings: +Warning 1064 Optimizer hint syntax error near '? bad syntax */ 1' at line 2 +DROP TABLE t1; +# +# Bug #21095608: OPTIMIZER HINT PARSER DOESN'T ACCEPT NUMBER-PREFIXED +# QUERY BLOCK NAMES AFTER @ +# +CREATE TABLE t1 (i INT); +EXPLAIN SELECT /*+ QB_NAME(1a) BKA(t1@1a) */ 1 FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select /*+ QB_NAME(`1a`) BKA(`t1`@`1a`) */ 1 AS `1` from `test`.`t1` +DROP TABLE t1; +# +# Bug #21148405: OPTIMIZER HINTS: READ OF FREE MEMORY FOR INVALID HINTS +# +CREATE PROCEDURE p1() +BEGIN +DECLARE cur1 CURSOR FOR SELECT /*+ NO_MRR(q w)*/1; +OPEN cur1; +END| +CALL p1(); +Warnings: +Warning 3128 Unresolved name `q`@`select#1` `w` for NO_MRR hint +CALL p1(); +DROP PROCEDURE p1; +# +# WL#9307 MERGE/NO_MERGE hint for derived table, view +# +create table t1(a int); +explain select * from (select * from t1) as dt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` +explain select /*+ merge(dt) */ * from (select * from t1) as dt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select /*+ MERGE(`dt`@`select#1`) */ `test`.`t1`.`a` AS `a` from `test`.`t1` +explain select /*+ no_merge(dt) */ * from (select * from t1) as dt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DERIVED t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select /*+ NO_MERGE(`dt`@`select#1`) */ `dt`.`a` AS `a` from (/* select#2 */ select `test`.`t1`.`a` AS `a` from `test`.`t1`) `dt` +# Also testing that case of letters is irrelevant. +explain select /*+ no_mERge(dt) */ * from (select * from t1) as dt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DERIVED t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select /*+ NO_MERGE(`dt`@`select#1`) */ `dt`.`a` AS `a` from (/* select#2 */ select `test`.`t1`.`a` AS `a` from `test`.`t1`) `dt` +create view v1 as (select * from t1); +explain select * from v1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` +explain select /*+ merge(v1) */ * from v1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select /*+ MERGE(`v1`@`select#1`) */ `test`.`t1`.`a` AS `a` from `test`.`t1` +explain select /*+ no_merge(v1) */ * from v1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DERIVED t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select /*+ NO_MERGE(`v1`@`select#1`) */ `test`.`v1`.`a` AS `a` from `test`.`v1` +drop view v1; +# hint is OVERRIDDEN by algorithm= +create algorithm=merge view v1 as (select * from t1); +explain select * from v1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` +explain select /*+ merge(v1) */ * from v1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select /*+ MERGE(`v1`@`select#1`) */ `test`.`t1`.`a` AS `a` from `test`.`t1` +explain select /*+ no_merge(v1) */ * from v1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select /*+ NO_MERGE(`v1`@`select#1`) */ `test`.`t1`.`a` AS `a` from `test`.`t1` +drop view v1; +create algorithm=temptable view v1 as (select * from t1); +explain select * from v1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DERIVED t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`v1`.`a` AS `a` from `test`.`v1` +explain select /*+ merge(v1) */ * from v1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DERIVED t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select /*+ MERGE(`v1`@`select#1`) */ `test`.`v1`.`a` AS `a` from `test`.`v1` +explain select /*+ no_merge(v1) */ * from v1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DERIVED t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select /*+ NO_MERGE(`v1`@`select#1`) */ `test`.`v1`.`a` AS `a` from `test`.`v1` +drop view v1; +# hint OVERRIDES optimizer_switch +set optimizer_switch="derived_merge=off"; +explain select * from (select * from t1) as dt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DERIVED t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `dt`.`a` AS `a` from (/* select#2 */ select `test`.`t1`.`a` AS `a` from `test`.`t1`) `dt` +explain select /*+ merge(dt) */ * from (select * from t1) as dt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select /*+ MERGE(`dt`@`select#1`) */ `test`.`t1`.`a` AS `a` from `test`.`t1` +explain select /*+ no_merge(dt) */ * from (select * from t1) as dt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DERIVED t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select /*+ NO_MERGE(`dt`@`select#1`) */ `dt`.`a` AS `a` from (/* select#2 */ select `test`.`t1`.`a` AS `a` from `test`.`t1`) `dt` +create view v1 as (select * from t1); +explain select * from v1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DERIVED t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`v1`.`a` AS `a` from `test`.`v1` +explain select /*+ merge(v1) */ * from v1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select /*+ MERGE(`v1`@`select#1`) */ `test`.`t1`.`a` AS `a` from `test`.`t1` +explain select /*+ no_merge(v1) */ * from v1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DERIVED t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select /*+ NO_MERGE(`v1`@`select#1`) */ `test`.`v1`.`a` AS `a` from `test`.`v1` +drop view v1; +set optimizer_switch=default; +# Can apply to certain derived tables +create table t2(a int, b int); +create table t3 like t2; +explain select /*+ no_merge(dt) merge(dt2) */ * +from (select * from t1) as dt, (select * from t2) as dt2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +2 DERIVED t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select /*+ NO_MERGE(`dt`@`select#1`) MERGE(`dt2`@`select#1`) */ `dt`.`a` AS `a`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from (/* select#2 */ select `test`.`t1`.`a` AS `a` from `test`.`t1`) `dt` join `test`.`t2` +# Or to all: +explain select /*+ no_merge() */ * +from (select * from t1) as dt, (select * from t2) as dt2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +3 DERIVED t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 DERIVED t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select /*+ NO_MERGE(@`select#1`) */ `dt`.`a` AS `a`,`dt2`.`a` AS `a`,`dt2`.`b` AS `b` from (/* select#2 */ select `test`.`t1`.`a` AS `a` from `test`.`t1`) `dt` join (/* select#3 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t2`) `dt2` +# And be specified in outer blocks, with naming: +explain select /*+ no_merge(dt@qb1) merge(dt2@qb1) */ * from t1 where a = +(select /*+ qb_name(qb1) */ 3 +from (select * from t1) as dt, (select * from t2) as dt2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 SUBQUERY t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SUBQUERY NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +3 DERIVED t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select /*+ NO_MERGE(`dt`@`qb1`) MERGE(`dt2`@`qb1`) */ `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` = (/* select#2 */ select /*+ QB_NAME(`qb1`) */ 3 from (/* select#3 */ select `test`.`t1`.`a` AS `a` from `test`.`t1`) `dt` join `test`.`t2`)) +# with another syntax: +explain select /*+ no_merge(@qb1 dt) merge(@qb1 dt2) */ * from t1 where a = +(select /*+ qb_name(qb1) */ 3 +from (select * from t1) as dt, (select * from t2) as dt2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 SUBQUERY t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SUBQUERY NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +3 DERIVED t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select /*+ NO_MERGE(`dt`@`qb1`) MERGE(`dt2`@`qb1`) */ `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` = (/* select#2 */ select /*+ QB_NAME(`qb1`) */ 3 from (/* select#3 */ select `test`.`t1`.`a` AS `a` from `test`.`t1`) `dt` join `test`.`t2`)) +# A hint can list more than one table +explain select /*+ merge(dt2) no_merge(dt,dt3) */ * +from (select * from t1) as dt, (select * from t2) as dt2, +(select * from t3) as dt3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +4 DERIVED t3 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 DERIVED t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select /*+ MERGE(`dt2`@`select#1`) NO_MERGE(`dt`@`select#1`) NO_MERGE(`dt3`@`select#1`) */ `dt`.`a` AS `a`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`dt3`.`a` AS `a`,`dt3`.`b` AS `b` from (/* select#2 */ select `test`.`t1`.`a` AS `a` from `test`.`t1`) `dt` join `test`.`t2` join (/* select#4 */ select `test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b` from `test`.`t3`) `dt3` +# Merge hint OVERRIDES heuristics, for example the one which +# materializes when user variables are set. +explain select * from +( +select * from t1 +where (1,a,2) = ( +select @n:=@n+1, t2.a, sum(t2.b) +from (select @n:=1) as dt, t2 +group by t2.a +) +) as dt2 +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DERIVED t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +3 UNCACHEABLE SUBQUERY NULL system NULL NULL NULL NULL 1 100.00 Using temporary +3 UNCACHEABLE SUBQUERY t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +4 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +Note 1003 /* select#1 */ select `dt2`.`a` AS `a` from (/* select#2 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where ((1,`test`.`t1`.`a`,2) = (/* select#3 */ select (@n:=((@`n`) + 1)),`test`.`t2`.`a`,sum(`test`.`t2`.`b`) from `test`.`t2` group by `test`.`t2`.`a`))) `dt2` +explain select /*+ merge(dt2) */ * from +( +select * from t1 +where (1,a,2) = ( +select @n:=@n+1, t2.a, sum(t2.b) +from (select @n:=1) as dt, t2 +group by t2.a +) +) as dt2 +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +3 UNCACHEABLE SUBQUERY NULL system NULL NULL NULL NULL 1 100.00 Using temporary +3 UNCACHEABLE SUBQUERY t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +4 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +Note 1003 /* select#1 */ select /*+ MERGE(`dt2`@`select#1`) */ `test`.`t1`.`a` AS `a` from `test`.`t1` where ((1,`test`.`t1`.`a`,2) = (/* select#3 */ select (@n:=((@`n`) + 1)),`test`.`t2`.`a`,sum(`test`.`t2`.`b`) from `test`.`t2` group by `test`.`t2`.`a`)) +# ALGORITHM clause overrides heuristics too +create view v1 as select (select t1.a from t1 where t1.a=t2.a) from t2; +explain select * from v1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DERIVED t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +3 DEPENDENT SUBQUERY t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1276 Field or reference 'test.t2.a' of SELECT #3 was resolved in SELECT #2 +Note 1003 /* select#1 */ select `test`.`v1`.`(select t1.a from t1 where t1.a=t2.a)` AS `(select t1.a from t1 where t1.a=t2.a)` from `test`.`v1` +drop view v1; +create algorithm=merge view v1 as select (select t1.a from t1 where t1.a=t2.a) from t2; +explain select * from v1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +3 DEPENDENT SUBQUERY t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1276 Field or reference 'test.t2.a' of SELECT #3 was resolved in SELECT #2 +Note 1003 /* select#1 */ select (/* select#3 */ select `test`.`t1`.`a` from `test`.`t1` where (`test`.`t1`.`a` = `test`.`t2`.`a`)) AS `(select t1.a from t1 where t1.a=t2.a)` from `test`.`t2` +drop view v1; +# Hint for index is useless and should be ignored +select /*+ no_mrr(dt idx1) */ * from (select 1 from t1 limit 1) dt; +1 +Warnings: +Warning 3128 Unresolved name `dt`@`select#1` `idx1` for NO_MRR hint +select /*+ no_mrr(dt idx1) */ * from (select 1 from t1) dt; +1 +Warnings: +Warning 3128 Unresolved name `dt`@`select#1` `idx1` for NO_MRR hint +# Hint for UPDATE +insert into t1 values(1),(2); +create view v1 as +select * from t1 where a <> 0; +delete from t3; +insert into t3 values(1,1),(2,2); +explain update t3, v1 set t3.a=v1.a+10 where t3.a-v1.a=0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 UPDATE t3 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +Warnings: +Note 1003 update `test`.`t3` join `test`.`t1` set `test`.`t3`.`a` = (`test`.`t1`.`a` + 10) where (((`test`.`t3`.`a` - `test`.`t1`.`a`) = 0) and (`test`.`t1`.`a` <> 0)) +update t3, v1 set t3.a=v1.a+10 where t3.a-v1.a=0; +select * from t3; +a b +11 1 +12 2 +delete from t3; +insert into t3 values(1,1),(2,2); +explain update /*+ no_merge(v1) */ t3, v1 set t3.a=v1.a+10 where t3.a-v1.a=0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t3 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 Using where +2 DERIVED t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1003 update /*+ NO_MERGE(`v1`@`select#1`) */ `test`.`t3` join `test`.`v1` set `test`.`t3`.`a` = (`test`.`v1`.`a` + 10) where ((`test`.`t3`.`a` - `test`.`v1`.`a`) = 0) +update /*+ no_merge(v1) */ t3, v1 set t3.a=v1.a+10 where t3.a-v1.a=0; +select * from t3; +a b +11 1 +12 2 +# Update v1 +delete from t3; +insert into t3 values(1,1),(2,2); +delete from t1; +insert into t1 values(1),(2); +explain update t3, v1 set v1.a=t3.a+10 where t3.a-v1.a=0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +Warnings: +Note 1003 update `test`.`t3` join `test`.`t1` set `test`.`t1`.`a` = (`test`.`t3`.`a` + 10) where (((`test`.`t3`.`a` - `test`.`t1`.`a`) = 0) and (`test`.`t1`.`a` <> 0)) +update t3, v1 set v1.a=t3.a+10 where t3.a-v1.a=0; +select * from t1; +a +11 +12 +delete from t1; +insert into t1 values(1),(2); +update /*+ no_merge(v1) */ t3, v1 set v1.a=t3.a+10 where t3.a-v1.a=0; +ERROR HY000: The target table v1 of the UPDATE is not updatable +select * from t1; +a +1 +2 +# A derived table in UPDATE +delete from t1; +insert into t1 values(1),(2); +delete from t3; +insert into t3 values(1,1),(2,2); +explain update t3, (select * from t1) dt set t3.a=dt.a+10 where t3.a-dt.a=0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t3 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +Warnings: +Note 1003 update `test`.`t3` join `test`.`t1` set `test`.`t3`.`a` = (`test`.`t1`.`a` + 10) where ((`test`.`t3`.`a` - `test`.`t1`.`a`) = 0) +update t3, (select * from t1) dt set t3.a=dt.a+10 where t3.a-dt.a=0; +select * from t3; +a b +11 1 +12 2 +delete from t3; +insert into t3 values(1,1),(2,2); +explain update /*+ no_merge(dt) */ t3, (select * from t1) dt set t3.a=dt.a+10 where t3.a-dt.a=0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t3 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 Using where +2 DERIVED t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 update /*+ NO_MERGE(`dt`@`select#1`) */ `test`.`t3` join (/* select#2 */ select `test`.`t1`.`a` AS `a` from `test`.`t1`) `dt` set `test`.`t3`.`a` = (`dt`.`a` + 10) where ((`test`.`t3`.`a` - `dt`.`a`) = 0) +update /*+ no_merge(dt) */ t3, (select * from t1) dt set t3.a=dt.a+10 where t3.a-dt.a=0; +select * from t3; +a b +11 1 +12 2 +# A derived table in first-level subquery of UPDATE, the update +# target not being in the derived table. Before the WL, the +# derived table would always be materialized; now it's only +# heuristic and can be overridden. +delete from t1; +insert into t1 values(1),(2); +delete from t3; +insert into t3 values(1,1),(2,2); +explain update t3 set b=NULL +where a in (select /*+ qb_name(sub) */ a +from (select * from t1 where a>1) dt); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t3 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 PRIMARY NULL ref 5 test.t3.a 2 100.00 Using index; FirstMatch(t3) +3 DERIVED t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1003 update `test`.`t3` set `test`.`t3`.`b` = NULL where (`dt`.`a` = `test`.`t3`.`a`) +update t3 set b=NULL +where a in (select /*+ qb_name(sub) */ a +from (select * from t1 where a>1) dt); +select * from t3; +a b +1 1 +2 NULL +delete from t3; +insert into t3 values(1,1),(2,2); +explain update /*+ merge(dt@sub) */ t3 set b=NULL +where a in (select /*+ qb_name(sub) */ a +from (select * from t1 where a>1) dt); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t3 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t3) +Warnings: +Note 1003 update /*+ MERGE(`dt`@`sub`) */ `test`.`t3` set `test`.`t3`.`b` = NULL where ((`test`.`t1`.`a` = `test`.`t3`.`a`) and (`test`.`t3`.`a` > 1)) +update /*+ merge(dt@sub) */ t3 set b=NULL +where a in (select /*+ qb_name(sub) */ a +from (select * from t1 where a>1) dt); +select * from t3; +a b +1 1 +2 NULL +# A derived table in UPDATE, the update target being in the +# derived table. +delete from t3; +insert into t3 values(1,1),(2,2); +explain update t3 set b=NULL +where a in (select /*+ qb_name(sub) */ a +from (select * from t3 where b>1) dt); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t3 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 PRIMARY NULL ref 5 test.t3.a 2 100.00 FirstMatch(t3) +3 DERIVED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1003 update `test`.`t3` set `test`.`t3`.`b` = NULL where (`dt`.`a` = `test`.`t3`.`a`) +update t3 set b=NULL +where a in (select /*+ qb_name(sub) */ a +from (select * from t3 where b>1) dt); +select * from t3; +a b +1 1 +2 NULL +delete from t3; +insert into t3 values(1,1),(2,2); +# The heuristic which materializes, intends to allow the query; +# if you disable it, the query cannot run: +update /*+ merge(dt@sub) */ t3 set b=NULL +where a in (select /*+ qb_name(sub) */ a +from (select * from t3 where b>1) dt); +ERROR HY000: You can't specify target table 't3' for update in FROM clause +select * from t3; +a b +1 1 +2 2 +# DELETE. +delete from t3; +insert into t3 values(1,1),(2,2); +explain delete t3.* from t3, v1 where t3.a-v1.a=0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 DELETE t3 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +Warnings: +Note 1003 delete `test`.`t3` from `test`.`t3` join `test`.`t1` where (((`test`.`t3`.`a` - `test`.`t1`.`a`) = 0) and (`test`.`t1`.`a` <> 0)) +delete t3.* from t3, v1 where t3.a-v1.a=0; +select * from t3; +a b +delete from t3; +insert into t3 values(1,1),(2,2); +explain delete /*+ no_merge(v1) */ t3.* from t3, v1 where t3.a-v1.a=0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t3 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 Using where +2 DERIVED t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1003 delete /*+ NO_MERGE(`v1`@`select#1`) */ `test`.`t3` from `test`.`t3` join `test`.`v1` where ((`test`.`t3`.`a` - `test`.`v1`.`a`) = 0) +delete /*+ no_merge(v1) */ t3.* from t3, v1 where t3.a-v1.a=0; +select * from t3; +a b +drop view v1; +drop table t1,t2,t3; +# +# Non-terminated comment test +# +PREPARE stmt FROM 'SELECT /*+ 10'; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '/*+ 10' at line 1 diff --git a/mysql-test/r/opt_hints_index.result-pq b/mysql-test/r/opt_hints_index.result-pq new file mode 100644 index 000000000000..9a3d11935d89 --- /dev/null +++ b/mysql-test/r/opt_hints_index.result-pq @@ -0,0 +1,230 @@ +CREATE TABLE t1 (a INT, b INT, c INT, d INT, +KEY i_a(a), KEY i_b(b), +KEY i_ab(a,b), KEY i_c(c), KEY i_d(d)); +INSERT INTO t1 VALUES +(1,1,1,1),(2,2,2,1),(3,3,3,1),(4,4,4,1), +(5,5,5,1),(6,6,6,1),(7,7,7,1),(8,8,8,1); +INSERT INTO t1 SELECT a,b, c + 10, d FROM t1; +INSERT INTO t1 SELECT a,b, c + 20, d FROM t1; +INSERT INTO t1 SELECT a,b, c + 40, d FROM t1; +INSERT INTO t1 SELECT a,b, c + 80, d FROM t1; +INSERT INTO t1 SELECT a,b, c + 160, d FROM t1; +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT /*+ INDEX(t1) JOIN_INDEX(t1) */ a FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 256 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL i_a 5 NULL 256 100.00 Using index +Warnings: +Warning 3126 Hint JOIN_INDEX(`t1` ) is ignored as conflicting/duplicated +Note 1003 /* select#1 */ select /*+ INDEX(`t1`@`select#1`) */ `test`.`t1`.`a` AS `a` from `test`.`t1` +EXPLAIN SELECT /*+ INDEX(t1 i_a, i_b, i_c) INDEX(t1 i_d) */ a FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 256 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL i_a 5 NULL 256 100.00 Using index +Warnings: +Warning 3126 Hint INDEX(`t1` `i_d`) is ignored as conflicting/duplicated +Note 1003 /* select#1 */ select /*+ INDEX(`t1`@`select#1` `i_a`, `i_b`, `i_c`) */ `test`.`t1`.`a` AS `a` from `test`.`t1` +EXPLAIN SELECT /*+ INDEX(t1 i_a) JOIN_INDEX(t1 i_a, i_b) JOIN_INDEX(t1 i_b) */ a FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 256 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL i_a 5 NULL 256 100.00 Using index +Warnings: +Warning 3126 Hint JOIN_INDEX(`t1` `i_a`, `i_b`) is ignored as conflicting/duplicated +Note 1003 /* select#1 */ select /*+ INDEX(`t1`@`select#1` `i_a`) JOIN_INDEX(`t1`@`select#1` `i_b`) */ `test`.`t1`.`a` AS `a` from `test`.`t1` +EXPLAIN SELECT /*+ INDEX(t1 i_a) GROUP_INDEX(t1 i_a, i_b) GROUP_INDEX(t1 i_b) */ a FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 256 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL i_a 5 NULL 256 100.00 Using index +Warnings: +Warning 3126 Hint GROUP_INDEX(`t1` `i_a`, `i_b`) is ignored as conflicting/duplicated +Note 1003 /* select#1 */ select /*+ INDEX(`t1`@`select#1` `i_a`) GROUP_INDEX(`t1`@`select#1` `i_b`) */ `test`.`t1`.`a` AS `a` from `test`.`t1` +EXPLAIN SELECT /*+ INDEX(t1 i_a) GROUP_INDEX(t1) */ a FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 256 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL i_a 5 NULL 256 100.00 Using index +Warnings: +Warning 3126 Hint GROUP_INDEX(`t1` ) is ignored as conflicting/duplicated +Note 1003 /* select#1 */ select /*+ INDEX(`t1`@`select#1` `i_a`) */ `test`.`t1`.`a` AS `a` from `test`.`t1` +EXPLAIN SELECT /*+ INDEX(t1 i_a) ORDER_INDEX(t1 i_a, i_b) ORDER_INDEX(t1 i_b) */ a FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 256 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL i_a 5 NULL 256 100.00 Using index +Warnings: +Warning 3126 Hint ORDER_INDEX(`t1` `i_a`, `i_b`) is ignored as conflicting/duplicated +Note 1003 /* select#1 */ select /*+ INDEX(`t1`@`select#1` `i_a`) ORDER_INDEX(`t1`@`select#1` `i_b`) */ `test`.`t1`.`a` AS `a` from `test`.`t1` +EXPLAIN SELECT /*+ INDEX(t1 i_a) ORDER_INDEX(t1) */ a FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 256 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL i_a 5 NULL 256 100.00 Using index +Warnings: +Warning 3126 Hint ORDER_INDEX(`t1` ) is ignored as conflicting/duplicated +Note 1003 /* select#1 */ select /*+ INDEX(`t1`@`select#1` `i_a`) */ `test`.`t1`.`a` AS `a` from `test`.`t1` +EXPLAIN SELECT /*+ ORDER_INDEX(t1 i_a, i_b) ORDER_INDEX(t1 i_b) INDEX(t1 i_c)*/ a FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 256 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL i_a 5 NULL 256 100.00 Using index +Warnings: +Warning 3126 Hint ORDER_INDEX(`t1` `i_b`) is ignored as conflicting/duplicated +Note 1003 /* select#1 */ select /*+ INDEX(`t1`@`select#1` `i_c`) ORDER_INDEX(`t1`@`select#1` `i_a`, `i_b`) */ `test`.`t1`.`a` AS `a` from `test`.`t1` +EXPLAIN SELECT /*+ ORDER_INDEX(t1 i_a, i_b) GROUP_INDEX(t1 i_b) INDEX(t1)*/ a FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 256 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL i_a 5 NULL 256 100.00 Using index +Warnings: +Warning 3126 Hint INDEX(`t1` ) is ignored as conflicting/duplicated +Note 1003 /* select#1 */ select /*+ GROUP_INDEX(`t1`@`select#1` `i_b`) ORDER_INDEX(`t1`@`select#1` `i_a`, `i_b`) */ `test`.`t1`.`a` AS `a` from `test`.`t1` +EXPLAIN SELECT /*+ ORDER_INDEX(t1) GROUP_INDEX(t1) INDEX(t1)*/ a FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 256 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL i_a 5 NULL 256 100.00 Using index +Warnings: +Warning 3126 Hint INDEX(`t1` ) is ignored as conflicting/duplicated +Note 1003 /* select#1 */ select /*+ GROUP_INDEX(`t1`@`select#1`) ORDER_INDEX(`t1`@`select#1`) */ `test`.`t1`.`a` AS `a` from `test`.`t1` +EXPLAIN SELECT /*+ INDEX(t1 i_a, i_b) */ a FROM t1 WHERE a = 1 AND b = 2 AND c = 3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge i_a,i_b i_a,i_b 5,5 NULL 4 1.25 Using intersect(i_a,i_b); Using where +Warnings: +Note 1003 /* select#1 */ select /*+ INDEX(`t1`@`select#1` `i_a`, `i_b`) */ `test`.`t1`.`a` AS `a` from `test`.`t1` where ((`test`.`t1`.`c` = 3) and (`test`.`t1`.`b` = 2) and (`test`.`t1`.`a` = 1)) +EXPLAIN SELECT /*+ INDEX(t1 i_a, i_ab) */ a FROM t1 WHERE a = 1 AND b = 2 AND c = 3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 5.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref i_a,i_ab i_ab 10 const,const 1 5.00 Using where +Warnings: +Note 1003 /* select#1 */ select /*+ INDEX(`t1`@`select#1` `i_a`, `i_ab`) */ `test`.`t1`.`a` AS `a` from `test`.`t1` where ((`test`.`t1`.`c` = 3) and (`test`.`t1`.`b` = 2) and (`test`.`t1`.`a` = 1)) +EXPLAIN SELECT /*+ INDEX(t1 i_a, i_b) JOIN_INDEX(t1 i_c) */ * FROM t1 WHERE a = 1 AND b = 2 AND c = 3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 5.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref i_a,i_b,i_c i_c 5 const 1 5.00 Using where +Warnings: +Note 1003 /* select#1 */ select /*+ INDEX(`t1`@`select#1` `i_a`, `i_b`) JOIN_INDEX(`t1`@`select#1` `i_c`) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c`,`test`.`t1`.`d` AS `d` from `test`.`t1` where ((`test`.`t1`.`c` = 3) and (`test`.`t1`.`b` = 2) and (`test`.`t1`.`a` = 1)) +EXPLAIN SELECT /*+ NO_INDEX(t1 i_ab) */ a, max(b) FROM t1 WHERE b = 2 GROUP BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 32 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref i_a,i_b i_b 5 const 32 100.00 Using temporary +Warnings: +Note 1003 /* select#1 */ select /*+ NO_INDEX(`t1`@`select#1` `i_ab`) */ `test`.`t1`.`a` AS `a`,max(`test`.`t1`.`b`) AS `max(b)` from `test`.`t1` where (`test`.`t1`.`b` = 2) group by `test`.`t1`.`a` +EXPLAIN SELECT /*+ NO_JOIN_INDEX(t1 i_ab) */ a, max(b) FROM t1 WHERE b = 2 GROUP BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 32 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref i_a,i_b,i_ab i_b 5 const 32 100.00 Using temporary +Warnings: +Note 1003 /* select#1 */ select /*+ NO_JOIN_INDEX(`t1`@`select#1` `i_ab`) */ `test`.`t1`.`a` AS `a`,max(`test`.`t1`.`b`) AS `max(b)` from `test`.`t1` where (`test`.`t1`.`b` = 2) group by `test`.`t1`.`a` +EXPLAIN SELECT /*+ GROUP_INDEX(t1 i_ab) */ a, max(b) FROM t1 GROUP BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 256 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index i_ab i_ab 10 NULL 256 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select /*+ GROUP_INDEX(`t1`@`select#1` `i_ab`) */ `test`.`t1`.`a` AS `a`,max(`test`.`t1`.`b`) AS `max(b)` from `test`.`t1` group by `test`.`t1`.`a` +EXPLAIN SELECT /*+ JOIN_INDEX(t1 i_ab) */ a, max(b) FROM t1 GROUP BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range i_ab i_ab 5 NULL 9 100.00 Using index for group-by; Using temporary +Warnings: +Note 1003 /* select#1 */ select /*+ JOIN_INDEX(`t1`@`select#1` `i_ab`) */ `test`.`t1`.`a` AS `a`,max(`test`.`t1`.`b`) AS `max(b)` from `test`.`t1` group by `test`.`t1`.`a` +EXPLAIN SELECT /*+ NO_ORDER_INDEX(t1 i_ab) */ a FROM t1 +ORDER BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 256 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL i_a 5 NULL 256 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select /*+ NO_ORDER_INDEX(`t1`@`select#1` `i_ab`) */ `test`.`t1`.`a` AS `a` from `test`.`t1` order by `test`.`t1`.`a` +EXPLAIN SELECT /*+ NO_ORDER_INDEX(t1 i_a) */ a FROM t1 +ORDER BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 256 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL i_a 5 NULL 256 100.00 Using index; Using filesort +Warnings: +Note 1003 /* select#1 */ select /*+ NO_ORDER_INDEX(`t1`@`select#1` `i_a`) */ `test`.`t1`.`a` AS `a` from `test`.`t1` order by `test`.`t1`.`a` +EXPLAIN SELECT /*+ ORDER_INDEX(t1 i_ab) */ a FROM t1 +ORDER BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 256 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL i_ab 10 NULL 256 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select /*+ ORDER_INDEX(`t1`@`select#1` `i_ab`) */ `test`.`t1`.`a` AS `a` from `test`.`t1` order by `test`.`t1`.`a` +EXPLAIN SELECT /*+ ORDER_INDEX(t1 i_a) */ a FROM t1 +ORDER BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 256 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL i_a 5 NULL 256 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select /*+ ORDER_INDEX(`t1`@`select#1` `i_a`) */ `test`.`t1`.`a` AS `a` from `test`.`t1` order by `test`.`t1`.`a` +EXPLAIN SELECT /*+ ORDER_INDEX(t1 i_a) */ * FROM t1 +ORDER BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 256 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL i_a 5 NULL 256 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select /*+ ORDER_INDEX(`t1`@`select#1` `i_a`) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c`,`test`.`t1`.`d` AS `d` from `test`.`t1` order by `test`.`t1`.`a` +EXPLAIN SELECT /*+ NO_INDEX(t1) */ * FROM t1 WHERE a = 1 AND b = 2 AND c = 3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 256 0.39 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 256 0.39 Using where +Warnings: +Note 1003 /* select#1 */ select /*+ NO_INDEX(`t1`@`select#1`) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c`,`test`.`t1`.`d` AS `d` from `test`.`t1` where ((`test`.`t1`.`c` = 3) and (`test`.`t1`.`b` = 2) and (`test`.`t1`.`a` = 1)) +EXPLAIN SELECT /*+ INDEX_MERGE(t1) */ * FROM t1 IGNORE INDEX (i_a) +WHERE a = 1 AND b = 2 AND c = 3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge i_b,i_ab,i_c i_ab,i_c 10,5 NULL 1 100.00 Using intersect(i_ab,i_c); Using where +Warnings: +Note 1003 /* select#1 */ select /*+ INDEX_MERGE(`t1`@`select#1`) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c`,`test`.`t1`.`d` AS `d` from `test`.`t1` IGNORE INDEX (`i_a`) where ((`test`.`t1`.`c` = 3) and (`test`.`t1`.`b` = 2) and (`test`.`t1`.`a` = 1)) +EXPLAIN UPDATE /*+ INDEX(t1 i_a) */ t1 SET d = 1 WHERE a = 1 AND b = 2 AND c = 3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL range i_a i_a 5 const 32 100.00 Using where +Warnings: +Note 1003 update /*+ INDEX(`t1`@`select#1` `i_a`) */ `test`.`t1` set `test`.`t1`.`d` = 1 where ((`test`.`t1`.`c` = 3) and (`test`.`t1`.`b` = 2) and (`test`.`t1`.`a` = 1)) +EXPLAIN DELETE /*+ INDEX(t1 i_a) */ FROM t1 WHERE a = 1 AND b = 2 AND c = 3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL range i_a i_a 5 const 32 100.00 Using where +Warnings: +Note 1003 delete /*+ INDEX(`t1`@`select#1` `i_a`) */ from `test`.`t1` where ((`test`.`t1`.`c` = 3) and (`test`.`t1`.`b` = 2) and (`test`.`t1`.`a` = 1)) +CREATE VIEW v1 AS SELECT /*+ NO_INDEX(t1 i_a,i_b) */ a FROM t1 WHERE +b IN (SELECT /*+ NO_INDEX(t1 i_ab,i_b) */ a FROM t1 WHERE a > 3) +ORDER BY a; +SHOW CREATE VIEW v1; +View Create View character_set_client collation_connection +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select /*+ NO_INDEX(`t1`@`select#1` `i_a`, `i_b`) NO_INDEX(`t1`@`select#2` `i_ab`, `i_b`) */ `t1`.`a` AS `a` from `t1` where `t1`.`b` in (select `t1`.`a` from `t1` where (`t1`.`a` > 3)) order by `t1`.`a` utf8mb4 utf8mb4_0900_ai_ci +EXPLAIN SELECT a FROM v1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range i_a i_a 5 NULL 160 5.00 Using where; Using index; Using temporary; Using filesort; LooseScan +1 SIMPLE t1 NULL index NULL i_ab 10 NULL 256 12.50 Using where; Using index; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` /*+ NO_INDEX(`t1`@`select#1` `i_a`, `i_b`) */ semi join (`test`.`t1` /*+ NO_INDEX(`t1`@`select#2` `i_ab`, `i_b`) */ ) where ((`test`.`t1`.`b` = `test`.`t1`.`a`) and (`test`.`t1`.`a` > 3)) order by `test`.`t1`.`a` +EXPLAIN SELECT /*+ INDEX(ta i_a) */ ta.a FROM v1, t1 ta WHERE ta.a > 3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range i_a i_a 5 NULL 160 5.00 Using where; Using index; LooseScan +1 SIMPLE t1 NULL index NULL i_ab 10 NULL 256 12.50 Using where; Using index; Using join buffer (hash join) +1 SIMPLE ta NULL range i_a i_a 5 NULL 160 100.00 Using where; Using index; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select /*+ INDEX(`ta`@`select#1` `i_a`) */ `test`.`ta`.`a` AS `a` from `test`.`t1` /*+ NO_INDEX(`t1`@`select#1` `i_a`, `i_b`) */ semi join (`test`.`t1` /*+ NO_INDEX(`t1`@`select#2` `i_ab`, `i_b`) */ ) join `test`.`t1` `ta` where ((`test`.`t1`.`b` = `test`.`t1`.`a`) and (`test`.`ta`.`a` > 3) and (`test`.`t1`.`a` > 3)) +CREATE VIEW v2 AS SELECT /*+ INDEX(ta i_a) */ ta.a FROM v1, t1 ta WHERE ta.a > 3; +SHOW CREATE VIEW v2; +View Create View character_set_client collation_connection +v2 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v2` AS select /*+ INDEX(`ta`@`select#1` `i_a`) */ `ta`.`a` AS `a` from (`v1` join `t1` `ta`) where (`ta`.`a` > 3) utf8mb4 utf8mb4_0900_ai_ci +EXPLAIN SELECT a FROM v2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range i_a i_a 5 NULL 160 5.00 Using where; Using index; LooseScan +1 SIMPLE t1 NULL index NULL i_ab 10 NULL 256 12.50 Using where; Using index; Using join buffer (hash join) +1 SIMPLE ta NULL range i_a i_a 5 NULL 160 100.00 Using where; Using index; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `ta`.`a` AS `a` from `test`.`t1` /*+ NO_INDEX(`t1`@`select#1` `i_a`, `i_b`) */ semi join (`test`.`t1` /*+ NO_INDEX(`t1`@`select#2` `i_ab`, `i_b`) */ ) join `test`.`t1` `ta` /*+ INDEX(`ta`@`select#1` `i_a`) */ where ((`test`.`t1`.`b` = `test`.`t1`.`a`) and (`ta`.`a` > 3) and (`test`.`t1`.`a` > 3)) +EXPLAIN SELECT /*+ INDEX(tb i_a) */ tb.a FROM v2, t1 tb WHERE tb.a > 3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range i_a i_a 5 NULL 160 5.00 Using where; Using index; LooseScan +1 SIMPLE t1 NULL index NULL i_ab 10 NULL 256 12.50 Using where; Using index; Using join buffer (hash join) +1 SIMPLE ta NULL range i_a i_a 5 NULL 160 100.00 Using where; Using index; Using join buffer (hash join) +1 SIMPLE tb NULL range i_a i_a 5 NULL 160 100.00 Using where; Using index; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select /*+ INDEX(`tb`@`select#1` `i_a`) */ `test`.`tb`.`a` AS `a` from `test`.`t1` /*+ NO_INDEX(`t1`@`select#1` `i_a`, `i_b`) */ semi join (`test`.`t1` /*+ NO_INDEX(`t1`@`select#2` `i_ab`, `i_b`) */ ) join `test`.`t1` `ta` /*+ INDEX(`ta`@`select#1` `i_a`) */ join `test`.`t1` `tb` where ((`test`.`t1`.`b` = `test`.`t1`.`a`) and (`test`.`tb`.`a` > 3) and (`ta`.`a` > 3) and (`test`.`t1`.`a` > 3)) +EXPLAIN SELECT /*+ INDEX(t1 i_a) */ * FROM t1 IGNORE INDEX(i_a) +WHERE a = 1 AND b = 2 AND c = 3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 32 0.39 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref i_a i_a 5 const 32 0.39 Using where +Warnings: +Note 1003 /* select#1 */ select /*+ INDEX(`t1`@`select#1` `i_a`) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c`,`test`.`t1`.`d` AS `d` from `test`.`t1` IGNORE INDEX (`i_a`) where ((`test`.`t1`.`c` = 3) and (`test`.`t1`.`b` = 2) and (`test`.`t1`.`a` = 1)) +CREATE VIEW v3 AS SELECT /*+ INDEX_MERGE(t1) */a FROM t1 +WHERE a = 1 AND b = 2 AND c = 3; +DROP VIEW v1, v2, v3; +DROP TABLE t1; diff --git a/mysql-test/r/opt_hints_index_merge.result-pq b/mysql-test/r/opt_hints_index_merge.result-pq new file mode 100644 index 000000000000..567f8b657ae9 --- /dev/null +++ b/mysql-test/r/opt_hints_index_merge.result-pq @@ -0,0 +1,560 @@ +CREATE TABLE t1 (f1 INT, f2 INT, f3 CHAR(1), f4 CHAR(1), f5 CHAR(1), f6 CHAR(1), f7 CHAR(1), +PRIMARY KEY (f5, f1), KEY (f2), KEY (f3), KEY (f4), KEY(f7) ); +INSERT INTO t1 VALUES (1, 1, 'a', 'h', 'i', '', ''), (2, 3, 'a', 'h', 'i', '', ''), +(3, 2, 'b', '', 'j', '', ''), (4, 2, 'b', '', 'j', '', ''); +INSERT INTO t1 VALUES (5, 1, 'a', 'h', 'i', '', ''), (6, 3, 'a', 'h', 'i', '', ''), +(7, 2, 'b', '', 'j', '', ''), (8, 2, 'b', '', 'j', '', ''); +INSERT INTO t1 SELECT f1 + 8, f2, f3, f4, f5, f6, f7 FROM t1; +INSERT INTO t1 SELECT f1 + 16, f2, f3, f4, f5, f6, f7 FROM t1; +INSERT INTO t1 VALUES (33, 3, 'c', 'g', '', '', ''), (34, 4, 'c', 'g', '', '', ''), +(35, 5, 'd', 'f', '', '', ''), (36, 6, 'd', 'f', '', '', ''); +INSERT INTO t1 SELECT f1 + 36, f2, f3, f4, f5, f6, f7 FROM t1; +INSERT INTO t1 SELECT f1 + 72, f2, f3, f4, f5, f6, f7 FROM t1; +INSERT INTO t1 SELECT f1 + 144, f2, f3, f4, f5, f6, f7 FROM t1; +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT COUNT(*) FROM t1 WHERE f4 = 'h' AND f2 = 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge f2,f4 f2,f4 5,5 NULL 56 100.00 Using intersect(f2,f4); Using where; Using index +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where ((`test`.`t1`.`f2` = 2) and (`test`.`t1`.`f4` = 'h')) +EXPLAIN SELECT COUNT(*) FROM t1 WHERE f4 = 'h' AND f3 = 'b'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge f3,f4 f3,f4 5,5 NULL 56 100.00 Using intersect(f3,f4); Using where; Using index +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where ((`test`.`t1`.`f3` = 'b') and (`test`.`t1`.`f4` = 'h')) +EXPLAIN SELECT COUNT(*) FROM t1 WHERE f4 = 'h' AND f2 = 2 AND f3 = 'b'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge f2,f3,f4 f2,f3,f4 5,5,5 NULL 25 100.00 Using intersect(f2,f3,f4); Using where; Using index +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where ((`test`.`t1`.`f3` = 'b') and (`test`.`t1`.`f2` = 2) and (`test`.`t1`.`f4` = 'h')) +EXPLAIN SELECT * FROM t1 WHERE f2 BETWEEN 5 AND 6 OR f3 = 'c' OR f4 = 'f'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge f2,f3,f4 f2,f3,f4 5,5,5 NULL 48 100.00 Using sort_union(f2,f3,f4); Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`f1` AS `f1`,`test`.`t1`.`f2` AS `f2`,`test`.`t1`.`f3` AS `f3`,`test`.`t1`.`f4` AS `f4`,`test`.`t1`.`f5` AS `f5`,`test`.`t1`.`f6` AS `f6`,`test`.`t1`.`f7` AS `f7` from `test`.`t1` where ((`test`.`t1`.`f2` between 5 and 6) or (`test`.`t1`.`f3` = 'c') or (`test`.`t1`.`f4` = 'f')) +EXPLAIN SELECT * FROM t1 WHERE (f2 BETWEEN 5 AND 6 OR f3 = 'c') AND (f2 BETWEEN 5 AND 6 OR f4 = 'f'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge f2,f3,f4 f2,f3 5,5 NULL 32 100.00 Using sort_union(f2,f3); Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`f1` AS `f1`,`test`.`t1`.`f2` AS `f2`,`test`.`t1`.`f3` AS `f3`,`test`.`t1`.`f4` AS `f4`,`test`.`t1`.`f5` AS `f5`,`test`.`t1`.`f6` AS `f6`,`test`.`t1`.`f7` AS `f7` from `test`.`t1` where (((`test`.`t1`.`f2` between 5 and 6) or (`test`.`t1`.`f3` = 'c')) and ((`test`.`t1`.`f2` between 5 and 6) or (`test`.`t1`.`f4` = 'f'))) +EXPLAIN SELECT f1 FROM t1 WHERE f2 = 5 OR f3 = 'c' OR f4 = 'f'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge f2,f3,f4 f2,f3,f4 5,5,5 NULL 40 100.00 Using union(f2,f3,f4); Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`f1` AS `f1` from `test`.`t1` where ((`test`.`t1`.`f2` = 5) or (`test`.`t1`.`f3` = 'c') or (`test`.`t1`.`f4` = 'f')) +EXPLAIN SELECT /*+ INDEX_MERGE(t1) INDEX_MERGE(t1 f2, f3, f4) */ f2 FROM t1 WHERE f4 = 'h' AND f2 = 2 AND f3 = 'b'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge f2,f3,f4 f2,f3,f4 5,5,5 NULL 25 100.00 Using intersect(f2,f3,f4); Using where; Using index +Warnings: +Warning 3126 Hint INDEX_MERGE(`t1` `f2`, `f3`, `f4`) is ignored as conflicting/duplicated +Note 1003 /* select#1 */ select /*+ INDEX_MERGE(`t1`@`select#1`) */ `test`.`t1`.`f2` AS `f2` from `test`.`t1` where ((`test`.`t1`.`f3` = 'b') and (`test`.`t1`.`f2` = 2) and (`test`.`t1`.`f4` = 'h')) +EXPLAIN SELECT /*+ INDEX_MERGE(t1 f2, f3, f4) INDEX_MERGE(t1) */ f2 FROM t1 WHERE f4 = 'h' AND f2 = 2 AND f3 = 'b'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge f2,f3,f4 f2,f3,f4 5,5,5 NULL 25 100.00 Using intersect(f2,f3,f4); Using where; Using index +Warnings: +Warning 3126 Hint INDEX_MERGE(`t1` ) is ignored as conflicting/duplicated +Note 1003 /* select#1 */ select /*+ INDEX_MERGE(`t1`@`select#1` `f2`, `f3`, `f4`) */ `test`.`t1`.`f2` AS `f2` from `test`.`t1` where ((`test`.`t1`.`f3` = 'b') and (`test`.`t1`.`f2` = 2) and (`test`.`t1`.`f4` = 'h')) +EXPLAIN SELECT /*+ INDEX_MERGE(t1 f2, f3, f4) NO_INDEX_MERGE(t1) */ f2 FROM t1 WHERE f4 = 'h' AND f2 = 2 AND f3 = 'b'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge f2,f3,f4 f2,f3,f4 5,5,5 NULL 25 100.00 Using intersect(f2,f3,f4); Using where; Using index +Warnings: +Warning 3126 Hint NO_INDEX_MERGE(`t1` ) is ignored as conflicting/duplicated +Note 1003 /* select#1 */ select /*+ INDEX_MERGE(`t1`@`select#1` `f2`, `f3`, `f4`) */ `test`.`t1`.`f2` AS `f2` from `test`.`t1` where ((`test`.`t1`.`f3` = 'b') and (`test`.`t1`.`f2` = 2) and (`test`.`t1`.`f4` = 'h')) +EXPLAIN SELECT /*+ NO_INDEX_MERGE(t1) INDEX_MERGE(t1 f2, f3, f4) */ f2 FROM t1 WHERE f4 = 'h' AND f2 = 2 AND f3 = 'b'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 128 19.75 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref f2,f3,f4 f2 5 const 128 19.75 Using where +Warnings: +Warning 3126 Hint INDEX_MERGE(`t1` `f2`, `f3`, `f4`) is ignored as conflicting/duplicated +Note 1003 /* select#1 */ select /*+ NO_INDEX_MERGE(`t1`@`select#1`) */ `test`.`t1`.`f2` AS `f2` from `test`.`t1` where ((`test`.`t1`.`f3` = 'b') and (`test`.`t1`.`f2` = 2) and (`test`.`t1`.`f4` = 'h')) +EXPLAIN SELECT /*+ NO_INDEX_MERGE(t1 f2, f4) INDEX_MERGE(t1 f2, f3, f4) */ f2 FROM t1 WHERE f4 = 'h' AND f2 = 2 AND f3 = 'b'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 128 19.75 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref f2,f3,f4 f2 5 const 128 19.75 Using where +Warnings: +Warning 3126 Hint INDEX_MERGE(`t1` `f2`, `f3`, `f4`) is ignored as conflicting/duplicated +Note 1003 /* select#1 */ select /*+ NO_INDEX_MERGE(`t1`@`select#1` `f2`, `f4`) */ `test`.`t1`.`f2` AS `f2` from `test`.`t1` where ((`test`.`t1`.`f3` = 'b') and (`test`.`t1`.`f2` = 2) and (`test`.`t1`.`f4` = 'h')) +EXPLAIN SELECT /*+ INDEX_MERGE(t5) */ f2 FROM t1 WHERE f4 = 'h' AND f2 = 2 AND f3 = 'b'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge f2,f3,f4 f2,f3,f4 5,5,5 NULL 25 100.00 Using intersect(f2,f3,f4); Using where; Using index +Warnings: +Warning 3128 Unresolved name `t5`@`select#1` for INDEX_MERGE hint +Note 1003 /* select#1 */ select `test`.`t1`.`f2` AS `f2` from `test`.`t1` where ((`test`.`t1`.`f3` = 'b') and (`test`.`t1`.`f2` = 2) and (`test`.`t1`.`f4` = 'h')) +EXPLAIN SELECT /*+ INDEX_MERGE(t1 f2, f5) */ f2 FROM t1 WHERE f4 = 'h' AND f2 = 2 AND f3 = 'b'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge f2,f3,f4 f2,f3,f4 5,5,5 NULL 25 100.00 Using intersect(f2,f3,f4); Using where; Using index +Warnings: +Warning 3128 Unresolved name `t1`@`select#1` `f5` for INDEX_MERGE hint +Note 1003 /* select#1 */ select `test`.`t1`.`f2` AS `f2` from `test`.`t1` where ((`test`.`t1`.`f3` = 'b') and (`test`.`t1`.`f2` = 2) and (`test`.`t1`.`f4` = 'h')) +EXPLAIN SELECT /*+ INDEX_MERGE(t1 f6, f5, primary) */ f2 FROM t1 WHERE f4 = 'h' AND f2 = 2 AND f3 = 'b'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge f2,f3,f4 f2,f3,f4 5,5,5 NULL 25 100.00 Using intersect(f2,f3,f4); Using where; Using index +Warnings: +Warning 3128 Unresolved name `t1`@`select#1` `f6` for INDEX_MERGE hint +Warning 3128 Unresolved name `t1`@`select#1` `f5` for INDEX_MERGE hint +Note 1003 /* select#1 */ select `test`.`t1`.`f2` AS `f2` from `test`.`t1` where ((`test`.`t1`.`f3` = 'b') and (`test`.`t1`.`f2` = 2) and (`test`.`t1`.`f4` = 'h')) +EXPLAIN SELECT /*+ INDEX_MERGE(t2 f9, f10) */ COUNT(*) FROM t1 WHERE f4 = '' AND f2 = 2 AND f3 = 'b'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge f2,f3,f4 f2,f3,f4 5,5,5 NULL 25 100.00 Using intersect(f2,f3,f4); Using where; Using index +Warnings: +Warning 3128 Unresolved name `t2`@`select#1` for INDEX_MERGE hint +Warning 3128 Unresolved name `t2`@`select#1` `f9` for INDEX_MERGE hint +Warning 3128 Unresolved name `t2`@`select#1` `f10` for INDEX_MERGE hint +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where ((`test`.`t1`.`f3` = 'b') and (`test`.`t1`.`f2` = 2) and (`test`.`t1`.`f4` = '')) +EXPLAIN SELECT /*+ INDEX_MERGE(t1 f9, f10) */ COUNT(*) FROM t1 WHERE f4 = '' AND f2 = 2 AND f3 = 'b'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge f2,f3,f4 f2,f3,f4 5,5,5 NULL 25 100.00 Using intersect(f2,f3,f4); Using where; Using index +Warnings: +Warning 3128 Unresolved name `t1`@`select#1` `f9` for INDEX_MERGE hint +Warning 3128 Unresolved name `t1`@`select#1` `f10` for INDEX_MERGE hint +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where ((`test`.`t1`.`f3` = 'b') and (`test`.`t1`.`f2` = 2) and (`test`.`t1`.`f4` = '')) +SET optimizer_switch='index_merge_intersection=off'; +EXPLAIN SELECT /*+ INDEX_MERGE(t1 f4, f2) */ COUNT(*) FROM t1 WHERE f4 = 'h' AND f2 = 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge f2,f4 f2,f4 5,5 NULL 56 100.00 Using intersect(f2,f4); Using where; Using index +Warnings: +Note 1003 /* select#1 */ select /*+ INDEX_MERGE(`t1`@`select#1` `f4`, `f2`) */ count(0) AS `COUNT(*)` from `test`.`t1` where ((`test`.`t1`.`f2` = 2) and (`test`.`t1`.`f4` = 'h')) +EXPLAIN SELECT /*+ INDEX_MERGE(t1 f2, f4, f3) */ COUNT(*) FROM t1 WHERE f4 = 'h' AND f2 = 2 AND f3 = 'b'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge f2,f3,f4 f2,f3,f4 5,5,5 NULL 25 100.00 Using intersect(f2,f3,f4); Using where; Using index +Warnings: +Note 1003 /* select#1 */ select /*+ INDEX_MERGE(`t1`@`select#1` `f2`, `f4`, `f3`) */ count(0) AS `COUNT(*)` from `test`.`t1` where ((`test`.`t1`.`f3` = 'b') and (`test`.`t1`.`f2` = 2) and (`test`.`t1`.`f4` = 'h')) +EXPLAIN SELECT /*+ INDEX_MERGE(t1 f4, f3) */ COUNT(*) FROM t1 WHERE f4 = 'h' AND f2 = 2 AND f3 = 'b'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge f2,f3,f4 f3,f4 5,5 NULL 56 44.44 Using intersect(f3,f4); Using where +Warnings: +Note 1003 /* select#1 */ select /*+ INDEX_MERGE(`t1`@`select#1` `f4`, `f3`) */ count(0) AS `COUNT(*)` from `test`.`t1` where ((`test`.`t1`.`f3` = 'b') and (`test`.`t1`.`f2` = 2) and (`test`.`t1`.`f4` = 'h')) +EXPLAIN SELECT /*+ INDEX_MERGE(t1) */ COUNT(*) FROM t1 WHERE f4 = 'h' AND f2 = 2 AND f3 = 'b'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge f2,f3,f4 f2,f3,f4 5,5,5 NULL 25 100.00 Using intersect(f2,f3,f4); Using where; Using index +Warnings: +Note 1003 /* select#1 */ select /*+ INDEX_MERGE(`t1`@`select#1`) */ count(0) AS `COUNT(*)` from `test`.`t1` where ((`test`.`t1`.`f3` = 'b') and (`test`.`t1`.`f2` = 2) and (`test`.`t1`.`f4` = 'h')) +EXPLAIN SELECT /*+ INDEX_MERGE(t1 f2, f4, f3) */ COUNT(*) FROM t1 WHERE f4 = 'h' AND f3 = 'b' AND f5 = 'i'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge PRIMARY,f3,f4 f3,f4 9,9 NULL 1 100.00 Using intersect(f3,f4); Using where; Using index +Warnings: +Note 1003 /* select#1 */ select /*+ INDEX_MERGE(`t1`@`select#1` `f2`, `f4`, `f3`) */ count(0) AS `COUNT(*)` from `test`.`t1` where ((`test`.`t1`.`f5` = 'i') and (`test`.`t1`.`f3` = 'b') and (`test`.`t1`.`f4` = 'h')) +EXPLAIN SELECT /*+ INDEX_MERGE(t1 PRIMARY, f4, f3) */ COUNT(*) FROM t1 WHERE f4 = 'h' AND f3 = 'b' AND f5 = 'i'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge PRIMARY,f3,f4 f3,f4 9,9 NULL 1 100.00 Using intersect(f3,f4); Using where; Using index +Warnings: +Note 1003 /* select#1 */ select /*+ INDEX_MERGE(`t1`@`select#1` `PRIMARY`, `f4`, `f3`) */ count(0) AS `COUNT(*)` from `test`.`t1` where ((`test`.`t1`.`f5` = 'i') and (`test`.`t1`.`f3` = 'b') and (`test`.`t1`.`f4` = 'h')) +EXPLAIN SELECT count(*) FROM t1 WHERE f2 = 3 AND f5 > '' AND f3 = 'c'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 16.67 Parallel execute (1 workers) +2 SIMPLE t1 NULL range PRIMARY,f2,f3 f3 9 NULL 1 16.67 Using index condition; Using where +Warnings: +Note 1003 /* select#1 */ select count(0) AS `count(*)` from `test`.`t1` where ((`test`.`t1`.`f3` = 'c') and (`test`.`t1`.`f2` = 3) and (`test`.`t1`.`f5` > '')) +EXPLAIN SELECT /*+ INDEX_MERGE(t1 f3, PRIMARY) */ count(*) FROM t1 WHERE f2 = 3 AND f5 > '' AND f3 = 'c'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge PRIMARY,f2,f3 f3,PRIMARY 9,4 NULL 1 16.67 Using intersect(f3,PRIMARY); Using where +Warnings: +Note 1003 /* select#1 */ select /*+ INDEX_MERGE(`t1`@`select#1` `f3`, `PRIMARY`) */ count(0) AS `count(*)` from `test`.`t1` where ((`test`.`t1`.`f3` = 'c') and (`test`.`t1`.`f2` = 3) and (`test`.`t1`.`f5` > '')) +EXPLAIN SELECT /*+ INDEX_MERGE(t1 f2, PRIMARY) */ count(*) FROM t1 WHERE f2 = 3 AND f5 > '' AND f3 = 'c'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge PRIMARY,f2,f3 f2,PRIMARY 9,4 NULL 56 25.00 Using intersect(f2,PRIMARY); Using where +Warnings: +Note 1003 /* select#1 */ select /*+ INDEX_MERGE(`t1`@`select#1` `f2`, `PRIMARY`) */ count(0) AS `count(*)` from `test`.`t1` where ((`test`.`t1`.`f3` = 'c') and (`test`.`t1`.`f2` = 3) and (`test`.`t1`.`f5` > '')) +EXPLAIN SELECT /*+ INDEX_MERGE(t1 f2, f4, f5) */ f3 FROM t1 WHERE f4 = 'h' AND f2 = 2 AND f3 = 'b'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 128 19.75 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref f2,f3,f4 f2 5 const 128 19.75 Using where +Warnings: +Warning 3128 Unresolved name `t1`@`select#1` `f5` for INDEX_MERGE hint +Note 1003 /* select#1 */ select `test`.`t1`.`f3` AS `f3` from `test`.`t1` where ((`test`.`t1`.`f3` = 'b') and (`test`.`t1`.`f2` = 2) and (`test`.`t1`.`f4` = 'h')) +EXPLAIN SELECT /*+ INDEX_MERGE(t1) */ COUNT(*) FROM t1 WHERE f4 = 'd' AND f2 = 2 AND f3 = 'b'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge f2,f3,f4 f4,f3 5,5 NULL 1 44.44 Using intersect(f4,f3); Using where +Warnings: +Note 1003 /* select#1 */ select /*+ INDEX_MERGE(`t1`@`select#1`) */ count(0) AS `COUNT(*)` from `test`.`t1` where ((`test`.`t1`.`f3` = 'b') and (`test`.`t1`.`f2` = 2) and (`test`.`t1`.`f4` = 'd')) +EXPLAIN SELECT /*+ INDEX_MERGE(t1) */ COUNT(*) FROM t1 WHERE f4 = 'h' AND f2 = 2 AND f3 = 'b'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge f2,f3,f4 f2,f3,f4 5,5,5 NULL 25 100.00 Using intersect(f2,f3,f4); Using where; Using index +Warnings: +Note 1003 /* select#1 */ select /*+ INDEX_MERGE(`t1`@`select#1`) */ count(0) AS `COUNT(*)` from `test`.`t1` where ((`test`.`t1`.`f3` = 'b') and (`test`.`t1`.`f2` = 2) and (`test`.`t1`.`f4` = 'h')) +EXPLAIN SELECT /*+ INDEX_MERGE(t1 f2, f3, f4, f7) */ COUNT(*) FROM t1 WHERE f4 = '' AND f2 = 2 AND f3 = 'b' AND f7 = ''; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge f2,f3,f4,f7 f2,f3,f4,f7 5,5,5,5 NULL 25 100.00 Using intersect(f2,f3,f4,f7); Using where; Using index +Warnings: +Note 1003 /* select#1 */ select /*+ INDEX_MERGE(`t1`@`select#1` `f2`, `f3`, `f4`, `f7`) */ count(0) AS `COUNT(*)` from `test`.`t1` where ((`test`.`t1`.`f7` = '') and (`test`.`t1`.`f3` = 'b') and (`test`.`t1`.`f2` = 2) and (`test`.`t1`.`f4` = '')) +EXPLAIN SELECT /*+ INDEX_MERGE(t1) */ COUNT(*) FROM t1 WHERE f4 = 'd' AND f2 = 2 AND f3 = 'b' AND f7 = ''; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge f2,f3,f4,f7 f4,f3 5,5 NULL 1 44.44 Using intersect(f4,f3); Using where +Warnings: +Note 1003 /* select#1 */ select /*+ INDEX_MERGE(`t1`@`select#1`) */ count(0) AS `COUNT(*)` from `test`.`t1` where ((`test`.`t1`.`f7` = '') and (`test`.`t1`.`f3` = 'b') and (`test`.`t1`.`f2` = 2) and (`test`.`t1`.`f4` = 'd')) +EXPLAIN SELECT /*+ INDEX_MERGE(t1) */ COUNT(*) FROM t1 WHERE f4 = '' AND f2 = 2 AND f3 = 'b' AND f7 = ''; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge f2,f3,f4,f7 f2,f3 5,5 NULL 56 44.44 Using intersect(f2,f3); Using where +Warnings: +Note 1003 /* select#1 */ select /*+ INDEX_MERGE(`t1`@`select#1`) */ count(0) AS `COUNT(*)` from `test`.`t1` where ((`test`.`t1`.`f7` = '') and (`test`.`t1`.`f3` = 'b') and (`test`.`t1`.`f2` = 2) and (`test`.`t1`.`f4` = '')) +SET optimizer_switch='index_merge=off'; +EXPLAIN SELECT COUNT(*) FROM t1 WHERE f4 = 'h' AND f2 = 2 AND f3 = 'b'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 128 19.75 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref f2,f3,f4 f2 5 const 128 19.75 Using where +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where ((`test`.`t1`.`f3` = 'b') and (`test`.`t1`.`f2` = 2) and (`test`.`t1`.`f4` = 'h')) +EXPLAIN SELECT /*+ INDEX_MERGE(t1 f2, f3, f4) */ COUNT(*) FROM t1 WHERE f4 = 'h' AND f2 = 2 AND f3 = 'b'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge f2,f3,f4 f2,f3,f4 5,5,5 NULL 25 100.00 Using intersect(f2,f3,f4); Using where; Using index +Warnings: +Note 1003 /* select#1 */ select /*+ INDEX_MERGE(`t1`@`select#1` `f2`, `f3`, `f4`) */ count(0) AS `COUNT(*)` from `test`.`t1` where ((`test`.`t1`.`f3` = 'b') and (`test`.`t1`.`f2` = 2) and (`test`.`t1`.`f4` = 'h')) +SET optimizer_switch='index_merge=on'; +SET optimizer_switch='index_merge_intersection=on'; +EXPLAIN SELECT /*+ NO_INDEX_MERGE(t1 f4) */ COUNT(*) FROM t1 WHERE f4 = 'h' AND f2 = 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 128 44.44 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref f2,f4 f2 5 const 128 44.44 Using where +Warnings: +Note 1003 /* select#1 */ select /*+ NO_INDEX_MERGE(`t1`@`select#1` `f4`) */ count(0) AS `COUNT(*)` from `test`.`t1` where ((`test`.`t1`.`f2` = 2) and (`test`.`t1`.`f4` = 'h')) +EXPLAIN SELECT /*+ NO_INDEX_MERGE(t1) */ COUNT(*) FROM t1 WHERE f4 = 'h' AND f2 = 2 AND f3 = 'b'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 128 19.75 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref f2,f3,f4 f2 5 const 128 19.75 Using where +Warnings: +Note 1003 /* select#1 */ select /*+ NO_INDEX_MERGE(`t1`@`select#1`) */ count(0) AS `COUNT(*)` from `test`.`t1` where ((`test`.`t1`.`f3` = 'b') and (`test`.`t1`.`f2` = 2) and (`test`.`t1`.`f4` = 'h')) +EXPLAIN SELECT /*+ NO_INDEX_MERGE(t1 f3) */ COUNT(*) FROM t1 WHERE f4 = 'h' AND f2 = 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge f2,f4 f2,f4 5,5 NULL 56 100.00 Using intersect(f2,f4); Using where; Using index +Warnings: +Note 1003 /* select#1 */ select /*+ NO_INDEX_MERGE(`t1`@`select#1` `f3`) */ count(0) AS `COUNT(*)` from `test`.`t1` where ((`test`.`t1`.`f2` = 2) and (`test`.`t1`.`f4` = 'h')) +EXPLAIN SELECT /*+ NO_INDEX_MERGE(t1 f4) */ COUNT(*) FROM t1 WHERE f4 = 'h' AND f2 = 2 AND f3 = 'b'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 128 19.75 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref f2,f3,f4 f2 5 const 128 19.75 Using where +Warnings: +Note 1003 /* select#1 */ select /*+ NO_INDEX_MERGE(`t1`@`select#1` `f4`) */ count(0) AS `COUNT(*)` from `test`.`t1` where ((`test`.`t1`.`f3` = 'b') and (`test`.`t1`.`f2` = 2) and (`test`.`t1`.`f4` = 'h')) +EXPLAIN SELECT count(*) FROM t1 WHERE f2 = 3 AND f5 > '' AND f3 = 'c'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge PRIMARY,f2,f3 f3,PRIMARY 9,4 NULL 1 16.67 Using intersect(f3,PRIMARY); Using where +Warnings: +Note 1003 /* select#1 */ select count(0) AS `count(*)` from `test`.`t1` where ((`test`.`t1`.`f3` = 'c') and (`test`.`t1`.`f2` = 3) and (`test`.`t1`.`f5` > '')) +EXPLAIN SELECT /*+ NO_INDEX_MERGE(t1 PRIMARY) */ count(*) FROM t1 WHERE f2 = 3 AND f5 > '' AND f3 = 'c'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 16.67 Parallel execute (1 workers) +2 SIMPLE t1 NULL range PRIMARY,f2,f3 f3 9 NULL 1 16.67 Using index condition; Using where +Warnings: +Note 1003 /* select#1 */ select /*+ NO_INDEX_MERGE(`t1`@`select#1` `PRIMARY`) */ count(0) AS `count(*)` from `test`.`t1` where ((`test`.`t1`.`f3` = 'c') and (`test`.`t1`.`f2` = 3) and (`test`.`t1`.`f5` > '')) +EXPLAIN SELECT /*+ NO_INDEX_MERGE(t1 f2) */ count(*) FROM t1 WHERE f2 = 3 AND f5 > '' AND f3 = 'c'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge PRIMARY,f2,f3 f3,PRIMARY 9,4 NULL 1 16.67 Using intersect(f3,PRIMARY); Using where +Warnings: +Note 1003 /* select#1 */ select /*+ NO_INDEX_MERGE(`t1`@`select#1` `f2`) */ count(0) AS `count(*)` from `test`.`t1` where ((`test`.`t1`.`f3` = 'c') and (`test`.`t1`.`f2` = 3) and (`test`.`t1`.`f5` > '')) +EXPLAIN SELECT /*+ NO_INDEX_MERGE(t1 f3) */ count(*) FROM t1 WHERE f2 = 3 AND f5 > '' AND f3 = 'c'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 64 25.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range PRIMARY,f2,f3 f2 9 NULL 64 25.00 Using index condition; Using where +Warnings: +Note 1003 /* select#1 */ select /*+ NO_INDEX_MERGE(`t1`@`select#1` `f3`) */ count(0) AS `count(*)` from `test`.`t1` where ((`test`.`t1`.`f3` = 'c') and (`test`.`t1`.`f2` = 3) and (`test`.`t1`.`f5` > '')) +EXPLAIN SELECT COUNT(*) FROM t1 WHERE f4 = 'x' AND f2 = 5 AND f3 = 'n'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 5.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref f2,f3,f4 f3 5 const 1 5.00 Using index condition; Using where +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where ((`test`.`t1`.`f3` = 'n') and (`test`.`t1`.`f2` = 5) and (`test`.`t1`.`f4` = 'x')) +EXPLAIN SELECT /*+ INDEX_MERGE(t1) */ COUNT(*) FROM t1 WHERE f4 = 'x' AND f2 = 5 AND f3 = 'n'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge f2,f3,f4 f3,f4 5,5 NULL 1 5.00 Using intersect(f3,f4); Using where +Warnings: +Note 1003 /* select#1 */ select /*+ INDEX_MERGE(`t1`@`select#1`) */ count(0) AS `COUNT(*)` from `test`.`t1` where ((`test`.`t1`.`f3` = 'n') and (`test`.`t1`.`f2` = 5) and (`test`.`t1`.`f4` = 'x')) +EXPLAIN SELECT /*+ INDEX_MERGE(t1 f4, f2) */ COUNT(*) FROM t1 WHERE f4 = 'x' AND f2 = 5 AND f3 = 'n'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge f2,f3,f4 f4,f2 5,5 NULL 1 5.00 Using intersect(f4,f2); Using where +Warnings: +Note 1003 /* select#1 */ select /*+ INDEX_MERGE(`t1`@`select#1` `f4`, `f2`) */ count(0) AS `COUNT(*)` from `test`.`t1` where ((`test`.`t1`.`f3` = 'n') and (`test`.`t1`.`f2` = 5) and (`test`.`t1`.`f4` = 'x')) +EXPLAIN SELECT /*+ INDEX_MERGE(t1 f3, f2) */ COUNT(*) FROM t1 WHERE f4 = 'x' AND f2 = 5 AND f3 = 'n'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge f2,f3,f4 f3,f2 5,5 NULL 1 5.00 Using intersect(f3,f2); Using where +Warnings: +Note 1003 /* select#1 */ select /*+ INDEX_MERGE(`t1`@`select#1` `f3`, `f2`) */ count(0) AS `COUNT(*)` from `test`.`t1` where ((`test`.`t1`.`f3` = 'n') and (`test`.`t1`.`f2` = 5) and (`test`.`t1`.`f4` = 'x')) +EXPLAIN SELECT /*+ INDEX_MERGE(t1 f4, f3) */ COUNT(*) FROM t1 WHERE f4 = 'x' AND f2 = 5 AND f3 = 'n'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge f2,f3,f4 f3,f4 5,5 NULL 1 5.00 Using intersect(f3,f4); Using where +Warnings: +Note 1003 /* select#1 */ select /*+ INDEX_MERGE(`t1`@`select#1` `f4`, `f3`) */ count(0) AS `COUNT(*)` from `test`.`t1` where ((`test`.`t1`.`f3` = 'n') and (`test`.`t1`.`f2` = 5) and (`test`.`t1`.`f4` = 'x')) +EXPLAIN SELECT /*+ INDEX_MERGE(t1 f2, f4) */ COUNT(*) FROM t1 WHERE f4 = 'h' AND f2 > 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 128 33.33 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref f2,f4 f4 5 const 128 33.33 Using index condition; Using where +Warnings: +Note 1003 /* select#1 */ select /*+ INDEX_MERGE(`t1`@`select#1` `f2`, `f4`) */ count(0) AS `COUNT(*)` from `test`.`t1` where ((`test`.`t1`.`f4` = 'h') and (`test`.`t1`.`f2` > 2)) +SET optimizer_switch='index_merge_union=off,index_merge=off'; +EXPLAIN SELECT /*+ INDEX_MERGE(t1 f2, f3, f4) */ f1 FROM t1 WHERE f2 = 5 OR f3 = 'c' OR f4 = 'f'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge f2,f3,f4 f2,f3,f4 5,5,5 NULL 40 100.00 Using union(f2,f3,f4); Using where +Warnings: +Note 1003 /* select#1 */ select /*+ INDEX_MERGE(`t1`@`select#1` `f2`, `f3`, `f4`) */ `test`.`t1`.`f1` AS `f1` from `test`.`t1` where ((`test`.`t1`.`f2` = 5) or (`test`.`t1`.`f3` = 'c') or (`test`.`t1`.`f4` = 'f')) +EXPLAIN SELECT /*+ INDEX_MERGE(t1 f2, f3) */ f1 FROM t1 WHERE f2 = 5 OR f3 = 'c' OR f4 = 'f'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 288 53.12 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL f2,f3,f4 NULL NULL NULL 288 53.12 Using where +Warnings: +Note 1003 /* select#1 */ select /*+ INDEX_MERGE(`t1`@`select#1` `f2`, `f3`) */ `test`.`t1`.`f1` AS `f1` from `test`.`t1` where ((`test`.`t1`.`f2` = 5) or (`test`.`t1`.`f3` = 'c') or (`test`.`t1`.`f4` = 'f')) +EXPLAIN SELECT /*+ INDEX_MERGE(t1 f2, f3) */ f1 FROM t1 WHERE (f2 = 5 OR f3 = 'c') AND (f1 = 4 OR f4 = 'f'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge f2,f3,f4 f2,f3 5,5 NULL 24 32.50 Using union(f2,f3); Using where +Warnings: +Note 1003 /* select#1 */ select /*+ INDEX_MERGE(`t1`@`select#1` `f2`, `f3`) */ `test`.`t1`.`f1` AS `f1` from `test`.`t1` where (((`test`.`t1`.`f2` = 5) or (`test`.`t1`.`f3` = 'c')) and ((`test`.`t1`.`f1` = 4) or (`test`.`t1`.`f4` = 'f'))) +EXPLAIN SELECT /*+ INDEX_MERGE(t1 PRIMARY, f4) */ f1 FROM t1 WHERE (f2 = 5 OR f3 = 'c') AND (f5 = 'i' OR f4 = 'f'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge PRIMARY,f2,f3,f4 PRIMARY,f4 4,5 NULL 144 37.50 Using union(PRIMARY,f4); Using where +Warnings: +Note 1003 /* select#1 */ select /*+ INDEX_MERGE(`t1`@`select#1` `PRIMARY`, `f4`) */ `test`.`t1`.`f1` AS `f1` from `test`.`t1` where (((`test`.`t1`.`f2` = 5) or (`test`.`t1`.`f3` = 'c')) and ((`test`.`t1`.`f5` = 'i') or (`test`.`t1`.`f4` = 'f'))) +SET optimizer_switch='index_merge_union=on,index_merge=on'; +EXPLAIN SELECT /*+ NO_INDEX_MERGE(t1 f2, f3, f4) */ f1 FROM t1 WHERE f2 = 5 OR f3 = 'c' OR f4 = 'f'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 288 53.12 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL f2,f3,f4 NULL NULL NULL 288 53.12 Using where +Warnings: +Note 1003 /* select#1 */ select /*+ NO_INDEX_MERGE(`t1`@`select#1` `f2`, `f3`, `f4`) */ `test`.`t1`.`f1` AS `f1` from `test`.`t1` where ((`test`.`t1`.`f2` = 5) or (`test`.`t1`.`f3` = 'c') or (`test`.`t1`.`f4` = 'f')) +EXPLAIN SELECT /*+ NO_INDEX_MERGE(t1 f2, f3) */ f1 FROM t1 WHERE (f2 = 5 OR f3 = 'c') AND (f1 = 4 OR f4 = 'f'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 288 12.19 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL f2,f3,f4 NULL NULL NULL 288 12.19 Using where +Warnings: +Note 1003 /* select#1 */ select /*+ NO_INDEX_MERGE(`t1`@`select#1` `f2`, `f3`) */ `test`.`t1`.`f1` AS `f1` from `test`.`t1` where (((`test`.`t1`.`f2` = 5) or (`test`.`t1`.`f3` = 'c')) and ((`test`.`t1`.`f1` = 4) or (`test`.`t1`.`f4` = 'f'))) +EXPLAIN SELECT /*+ NO_INDEX_MERGE(t1 f4) */ f1 FROM t1 WHERE (f2 = 5 OR f3 = 'c') AND (f1 = 4 OR f4 = 'f'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge f2,f3,f4 f2,f3 5,5 NULL 24 32.50 Using union(f2,f3); Using where +Warnings: +Note 1003 /* select#1 */ select /*+ NO_INDEX_MERGE(`t1`@`select#1` `f4`) */ `test`.`t1`.`f1` AS `f1` from `test`.`t1` where (((`test`.`t1`.`f2` = 5) or (`test`.`t1`.`f3` = 'c')) and ((`test`.`t1`.`f1` = 4) or (`test`.`t1`.`f4` = 'f'))) +EXPLAIN SELECT * FROM t1 WHERE f2 = 400 AND (f3 = 'x' OR f4 = 'n'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 43.75 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref f2,f3,f4 f2 5 const 1 43.75 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`f1` AS `f1`,`test`.`t1`.`f2` AS `f2`,`test`.`t1`.`f3` AS `f3`,`test`.`t1`.`f4` AS `f4`,`test`.`t1`.`f5` AS `f5`,`test`.`t1`.`f6` AS `f6`,`test`.`t1`.`f7` AS `f7` from `test`.`t1` where ((`test`.`t1`.`f2` = 400) and ((`test`.`t1`.`f3` = 'x') or (`test`.`t1`.`f4` = 'n'))) +EXPLAIN SELECT /*+ INDEX_MERGE(t1 f3, f4) */ * FROM t1 WHERE f2 = 400 AND (f3 = 'x' OR f4 = 'n'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge f2,f3,f4 f3,f4 5,5 NULL 2 2.50 Using union(f3,f4); Using where +Warnings: +Note 1003 /* select#1 */ select /*+ INDEX_MERGE(`t1`@`select#1` `f3`, `f4`) */ `test`.`t1`.`f1` AS `f1`,`test`.`t1`.`f2` AS `f2`,`test`.`t1`.`f3` AS `f3`,`test`.`t1`.`f4` AS `f4`,`test`.`t1`.`f5` AS `f5`,`test`.`t1`.`f6` AS `f6`,`test`.`t1`.`f7` AS `f7` from `test`.`t1` where ((`test`.`t1`.`f2` = 400) and ((`test`.`t1`.`f3` = 'x') or (`test`.`t1`.`f4` = 'n'))) +SET optimizer_switch='index_merge_sort_union=off,index_merge=off'; +EXPLAIN SELECT /*+ INDEX_MERGE(t1 f2, f4) */ * FROM t1 WHERE (f2 BETWEEN 5 AND 6 OR f3 = 'c') AND (f2 BETWEEN 5 AND 6 OR f4 = 'f'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge f2,f3,f4 f2,f4 5,5 NULL 32 100.00 Using sort_union(f2,f4); Using where +Warnings: +Note 1003 /* select#1 */ select /*+ INDEX_MERGE(`t1`@`select#1` `f2`, `f4`) */ `test`.`t1`.`f1` AS `f1`,`test`.`t1`.`f2` AS `f2`,`test`.`t1`.`f3` AS `f3`,`test`.`t1`.`f4` AS `f4`,`test`.`t1`.`f5` AS `f5`,`test`.`t1`.`f6` AS `f6`,`test`.`t1`.`f7` AS `f7` from `test`.`t1` where (((`test`.`t1`.`f2` between 5 and 6) or (`test`.`t1`.`f3` = 'c')) and ((`test`.`t1`.`f2` between 5 and 6) or (`test`.`t1`.`f4` = 'f'))) +EXPLAIN SELECT /*+ INDEX_MERGE(t1 f2, f3) */ * FROM t1 WHERE (f2 BETWEEN 5 AND 6 OR f3 = 'c') AND (f2 BETWEEN 5 AND 6 OR f4 = 'f'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge f2,f3,f4 f2,f3 5,5 NULL 32 100.00 Using sort_union(f2,f3); Using where +Warnings: +Note 1003 /* select#1 */ select /*+ INDEX_MERGE(`t1`@`select#1` `f2`, `f3`) */ `test`.`t1`.`f1` AS `f1`,`test`.`t1`.`f2` AS `f2`,`test`.`t1`.`f3` AS `f3`,`test`.`t1`.`f4` AS `f4`,`test`.`t1`.`f5` AS `f5`,`test`.`t1`.`f6` AS `f6`,`test`.`t1`.`f7` AS `f7` from `test`.`t1` where (((`test`.`t1`.`f2` between 5 and 6) or (`test`.`t1`.`f3` = 'c')) and ((`test`.`t1`.`f2` between 5 and 6) or (`test`.`t1`.`f4` = 'f'))) +EXPLAIN SELECT /*+ INDEX_MERGE(t1 f3) */ * FROM t1 WHERE (f2 BETWEEN 5 AND 6 OR f3 = 'c') AND (f2 BETWEEN 5 AND 6 OR f4 = 'f'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 288 11.11 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL f2,f3,f4 NULL NULL NULL 288 11.11 Using where +Warnings: +Warning 3614 Invalid number of arguments for hint INDEX_MERGE(`t1` `f3`) +Note 1003 /* select#1 */ select `test`.`t1`.`f1` AS `f1`,`test`.`t1`.`f2` AS `f2`,`test`.`t1`.`f3` AS `f3`,`test`.`t1`.`f4` AS `f4`,`test`.`t1`.`f5` AS `f5`,`test`.`t1`.`f6` AS `f6`,`test`.`t1`.`f7` AS `f7` from `test`.`t1` where (((`test`.`t1`.`f2` between 5 and 6) or (`test`.`t1`.`f3` = 'c')) and ((`test`.`t1`.`f2` between 5 and 6) or (`test`.`t1`.`f4` = 'f'))) +EXPLAIN SELECT /*+ INDEX_MERGE(t1 f2, f4) */ * FROM t1 +WHERE (f2 BETWEEN 5 AND 6 OR f3 = 'c') AND (f2 BETWEEN 5 AND 6 OR f4 = 'f') AND f3 = 'n'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge f2,f3,f4 f2,f4 5,5 NULL 32 0.35 Using sort_union(f2,f4); Using where +Warnings: +Note 1003 /* select#1 */ select /*+ INDEX_MERGE(`t1`@`select#1` `f2`, `f4`) */ `test`.`t1`.`f1` AS `f1`,`test`.`t1`.`f2` AS `f2`,`test`.`t1`.`f3` AS `f3`,`test`.`t1`.`f4` AS `f4`,`test`.`t1`.`f5` AS `f5`,`test`.`t1`.`f6` AS `f6`,`test`.`t1`.`f7` AS `f7` from `test`.`t1` where ((`test`.`t1`.`f3` = 'n') and (`test`.`t1`.`f2` between 5 and 6) and ((`test`.`t1`.`f2` between 5 and 6) or (`test`.`t1`.`f4` = 'f'))) +SET optimizer_switch='index_merge_sort_union=on,index_merge=on'; +EXPLAIN SELECT /*+ NO_INDEX_MERGE(t1 f2, f4) */ * FROM t1 WHERE (f2 BETWEEN 5 AND 6 OR f3 = 'c') AND (f2 BETWEEN 5 AND 6 OR f4 = 'f'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 288 11.11 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL f2,f3,f4 NULL NULL NULL 288 11.11 Using where +Warnings: +Note 1003 /* select#1 */ select /*+ NO_INDEX_MERGE(`t1`@`select#1` `f2`, `f4`) */ `test`.`t1`.`f1` AS `f1`,`test`.`t1`.`f2` AS `f2`,`test`.`t1`.`f3` AS `f3`,`test`.`t1`.`f4` AS `f4`,`test`.`t1`.`f5` AS `f5`,`test`.`t1`.`f6` AS `f6`,`test`.`t1`.`f7` AS `f7` from `test`.`t1` where (((`test`.`t1`.`f2` between 5 and 6) or (`test`.`t1`.`f3` = 'c')) and ((`test`.`t1`.`f2` between 5 and 6) or (`test`.`t1`.`f4` = 'f'))) +EXPLAIN SELECT /*+ NO_INDEX_MERGE(t1 f2, f3) */ * FROM t1 WHERE (f2 BETWEEN 5 AND 6 OR f3 = 'c') AND (f2 BETWEEN 5 AND 6 OR f4 = 'f'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 288 11.11 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL f2,f3,f4 NULL NULL NULL 288 11.11 Using where +Warnings: +Note 1003 /* select#1 */ select /*+ NO_INDEX_MERGE(`t1`@`select#1` `f2`, `f3`) */ `test`.`t1`.`f1` AS `f1`,`test`.`t1`.`f2` AS `f2`,`test`.`t1`.`f3` AS `f3`,`test`.`t1`.`f4` AS `f4`,`test`.`t1`.`f5` AS `f5`,`test`.`t1`.`f6` AS `f6`,`test`.`t1`.`f7` AS `f7` from `test`.`t1` where (((`test`.`t1`.`f2` between 5 and 6) or (`test`.`t1`.`f3` = 'c')) and ((`test`.`t1`.`f2` between 5 and 6) or (`test`.`t1`.`f4` = 'f'))) +EXPLAIN SELECT /*+ NO_INDEX_MERGE(t1 f4) */ * FROM t1 WHERE (f2 BETWEEN 5 AND 6 OR f3 = 'c') AND (f2 BETWEEN 5 AND 6 OR f4 = 'f'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge f2,f3,f4 f2,f3 5,5 NULL 32 100.00 Using sort_union(f2,f3); Using where +Warnings: +Note 1003 /* select#1 */ select /*+ NO_INDEX_MERGE(`t1`@`select#1` `f4`) */ `test`.`t1`.`f1` AS `f1`,`test`.`t1`.`f2` AS `f2`,`test`.`t1`.`f3` AS `f3`,`test`.`t1`.`f4` AS `f4`,`test`.`t1`.`f5` AS `f5`,`test`.`t1`.`f6` AS `f6`,`test`.`t1`.`f7` AS `f7` from `test`.`t1` where (((`test`.`t1`.`f2` between 5 and 6) or (`test`.`t1`.`f3` = 'c')) and ((`test`.`t1`.`f2` between 5 and 6) or (`test`.`t1`.`f4` = 'f'))) +EXPLAIN SELECT /*+ NO_INDEX_MERGE(t1 f3) */ * FROM t1 WHERE (f2 BETWEEN 5 AND 6 OR f3 = 'c') AND (f2 BETWEEN 5 AND 6 OR f4 = 'f'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge f2,f3,f4 f2,f4 5,5 NULL 32 100.00 Using sort_union(f2,f4); Using where +Warnings: +Note 1003 /* select#1 */ select /*+ NO_INDEX_MERGE(`t1`@`select#1` `f3`) */ `test`.`t1`.`f1` AS `f1`,`test`.`t1`.`f2` AS `f2`,`test`.`t1`.`f3` AS `f3`,`test`.`t1`.`f4` AS `f4`,`test`.`t1`.`f5` AS `f5`,`test`.`t1`.`f6` AS `f6`,`test`.`t1`.`f7` AS `f7` from `test`.`t1` where (((`test`.`t1`.`f2` between 5 and 6) or (`test`.`t1`.`f3` = 'c')) and ((`test`.`t1`.`f2` between 5 and 6) or (`test`.`t1`.`f4` = 'f'))) +EXPLAIN SELECT * FROM t1 WHERE (f2 BETWEEN 1 AND 200 OR f3 = 'c') AND (f2 BETWEEN 1 AND 200 OR f4 = 'f'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 288 11.11 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL f2,f3,f4 NULL NULL NULL 288 11.11 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`f1` AS `f1`,`test`.`t1`.`f2` AS `f2`,`test`.`t1`.`f3` AS `f3`,`test`.`t1`.`f4` AS `f4`,`test`.`t1`.`f5` AS `f5`,`test`.`t1`.`f6` AS `f6`,`test`.`t1`.`f7` AS `f7` from `test`.`t1` where (((`test`.`t1`.`f2` between 1 and 200) or (`test`.`t1`.`f3` = 'c')) and ((`test`.`t1`.`f2` between 1 and 200) or (`test`.`t1`.`f4` = 'f'))) +EXPLAIN SELECT /*+ INDEX_MERGE(t1) */ * FROM t1 WHERE (f2 BETWEEN 1 AND 200 OR f3 = 'c') AND (f2 BETWEEN 1 AND 200 OR f4 = 'f'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge f2,f3,f4 f2,f3 5,5 NULL 288 100.00 Using sort_union(f2,f3); Using where +Warnings: +Note 1003 /* select#1 */ select /*+ INDEX_MERGE(`t1`@`select#1`) */ `test`.`t1`.`f1` AS `f1`,`test`.`t1`.`f2` AS `f2`,`test`.`t1`.`f3` AS `f3`,`test`.`t1`.`f4` AS `f4`,`test`.`t1`.`f5` AS `f5`,`test`.`t1`.`f6` AS `f6`,`test`.`t1`.`f7` AS `f7` from `test`.`t1` where (((`test`.`t1`.`f2` between 1 and 200) or (`test`.`t1`.`f3` = 'c')) and ((`test`.`t1`.`f2` between 1 and 200) or (`test`.`t1`.`f4` = 'f'))) +EXPLAIN SELECT /*+ INDEX_MERGE(t1 f2, f4) */ * FROM t1 WHERE (f2 BETWEEN 1 AND 200 OR f3 = 'c') AND (f2 BETWEEN 1 AND 200 OR f4 = 'f'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge f2,f3,f4 f2,f4 5,5 NULL 288 100.00 Using sort_union(f2,f4); Using where +Warnings: +Note 1003 /* select#1 */ select /*+ INDEX_MERGE(`t1`@`select#1` `f2`, `f4`) */ `test`.`t1`.`f1` AS `f1`,`test`.`t1`.`f2` AS `f2`,`test`.`t1`.`f3` AS `f3`,`test`.`t1`.`f4` AS `f4`,`test`.`t1`.`f5` AS `f5`,`test`.`t1`.`f6` AS `f6`,`test`.`t1`.`f7` AS `f7` from `test`.`t1` where (((`test`.`t1`.`f2` between 1 and 200) or (`test`.`t1`.`f3` = 'c')) and ((`test`.`t1`.`f2` between 1 and 200) or (`test`.`t1`.`f4` = 'f'))) +EXPLAIN SELECT f1 FROM t1 WHERE (f2 = 5 OR f3 = 'c' OR f4 = 'f') AND (f2 BETWEEN 1 AND 200 OR f3 = 'c'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge f2,f3,f4 f2,f3,f4 5,5,5 NULL 40 100.00 Using union(f2,f3,f4); Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`f1` AS `f1` from `test`.`t1` where (((`test`.`t1`.`f2` = 5) or (`test`.`t1`.`f3` = 'c') or (`test`.`t1`.`f4` = 'f')) and ((`test`.`t1`.`f2` between 1 and 200) or (`test`.`t1`.`f3` = 'c'))) +EXPLAIN SELECT /*+ INDEX_MERGE(t1 f2, f3) */ f1 FROM t1 WHERE (f2 = 5 OR f3 = 'c' OR f4 = 'f') AND (f2 BETWEEN 1 AND 200 OR f3 = 'c'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge f2,f3,f4 f2,f3 5,5 NULL 288 100.00 Using sort_union(f2,f3); Using where +Warnings: +Note 1003 /* select#1 */ select /*+ INDEX_MERGE(`t1`@`select#1` `f2`, `f3`) */ `test`.`t1`.`f1` AS `f1` from `test`.`t1` where (((`test`.`t1`.`f2` = 5) or (`test`.`t1`.`f3` = 'c') or (`test`.`t1`.`f4` = 'f')) and ((`test`.`t1`.`f2` between 1 and 200) or (`test`.`t1`.`f3` = 'c'))) +SET optimizer_switch=default; +EXPLAIN SELECT COUNT(*) FROM t1 WHERE (f4 = 'h' AND f2 = 2 AND f3 = 'b') OR (f7 = 'd' AND f6 = 'e'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge f2,f3,f4,f7 f2,f7 5,5 NULL 129 15.62 Using union(f2,f7); Using where +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (((`test`.`t1`.`f3` = 'b') and (`test`.`t1`.`f2` = 2) and (`test`.`t1`.`f4` = 'h')) or ((`test`.`t1`.`f6` = 'e') and (`test`.`t1`.`f7` = 'd'))) +EXPLAIN SELECT /*+ INDEX_MERGE(t1) */ COUNT(*) FROM t1 WHERE (f4 = 'h' AND f2 = 2 AND f3 = 'b') OR (f7 = 'd' AND f6 = 'e'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge f2,f3,f4,f7 f2,f7 5,5 NULL 129 15.62 Using union(f2,f7); Using where +Warnings: +Note 1003 /* select#1 */ select /*+ INDEX_MERGE(`t1`@`select#1`) */ count(0) AS `COUNT(*)` from `test`.`t1` where (((`test`.`t1`.`f3` = 'b') and (`test`.`t1`.`f2` = 2) and (`test`.`t1`.`f4` = 'h')) or ((`test`.`t1`.`f6` = 'e') and (`test`.`t1`.`f7` = 'd'))) +EXPLAIN SELECT /*+ INDEX_MERGE(t1 f2,f3,f7) */ COUNT(*) FROM t1 WHERE (f4 = 'h' AND f2 = 2 AND f3 = 'b') OR (f7 = 'd' AND f6 = 'e'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge f2,f3,f4,f7 f2,f3,f7 5,5,5 NULL 57 32.50 Using union(intersect(f2,f3),f7); Using where +Warnings: +Note 1003 /* select#1 */ select /*+ INDEX_MERGE(`t1`@`select#1` `f2`, `f3`, `f7`) */ count(0) AS `COUNT(*)` from `test`.`t1` where (((`test`.`t1`.`f3` = 'b') and (`test`.`t1`.`f2` = 2) and (`test`.`t1`.`f4` = 'h')) or ((`test`.`t1`.`f6` = 'e') and (`test`.`t1`.`f7` = 'd'))) +EXPLAIN SELECT f3 FROM t1 WHERE f4 = 'f' AND f2 = 3 AND f5 > ''; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge PRIMARY,f2,f4 f4,PRIMARY 9,4 NULL 1 16.67 Using intersect(f4,PRIMARY); Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`f3` AS `f3` from `test`.`t1` where ((`test`.`t1`.`f2` = 3) and (`test`.`t1`.`f4` = 'f') and (`test`.`t1`.`f5` > '')) +EXPLAIN SELECT /*+ INDEX_MERGE(t1) */ f3 FROM t1 WHERE f4 = 'f' AND f2 = 3 AND f5 > ''; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge PRIMARY,f2,f4 f4,PRIMARY 9,4 NULL 1 16.67 Using intersect(f4,PRIMARY); Using where +Warnings: +Note 1003 /* select#1 */ select /*+ INDEX_MERGE(`t1`@`select#1`) */ `test`.`t1`.`f3` AS `f3` from `test`.`t1` where ((`test`.`t1`.`f2` = 3) and (`test`.`t1`.`f4` = 'f') and (`test`.`t1`.`f5` > '')) +EXPLAIN SELECT f3 FROM t1 WHERE f2 = 3 AND f4 = 'g' AND f5 = ''; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge PRIMARY,f2,f4 f2,f4 9,9 NULL 1 100.00 Using intersect(f2,f4); Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`f3` AS `f3` from `test`.`t1` where ((`test`.`t1`.`f5` = '') and (`test`.`t1`.`f4` = 'g') and (`test`.`t1`.`f2` = 3)) +EXPLAIN SELECT /*+ INDEX_MERGE(t1) */ f3 FROM t1 WHERE f2 = 3 AND f4 = 'g' AND f5 = ''; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge PRIMARY,f2,f4 f2,f4 9,9 NULL 1 100.00 Using intersect(f2,f4); Using where +Warnings: +Note 1003 /* select#1 */ select /*+ INDEX_MERGE(`t1`@`select#1`) */ `test`.`t1`.`f3` AS `f3` from `test`.`t1` where ((`test`.`t1`.`f5` = '') and (`test`.`t1`.`f4` = 'g') and (`test`.`t1`.`f2` = 3)) +EXPLAIN SELECT f3 FROM t1 WHERE f2 = 3 AND f4 = '' AND f5 > ''; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 64 25.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range PRIMARY,f2,f4 f2 9 NULL 64 25.00 Using index condition; Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`f3` AS `f3` from `test`.`t1` where ((`test`.`t1`.`f4` = '') and (`test`.`t1`.`f2` = 3) and (`test`.`t1`.`f5` > '')) +EXPLAIN SELECT /*+ INDEX_MERGE(t1) */ f3 FROM t1 WHERE f2 = 3 AND f4 = '' AND f5 > ''; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge PRIMARY,f2,f4 f2,PRIMARY 9,4 NULL 56 25.00 Using intersect(f2,PRIMARY); Using where +Warnings: +Note 1003 /* select#1 */ select /*+ INDEX_MERGE(`t1`@`select#1`) */ `test`.`t1`.`f3` AS `f3` from `test`.`t1` where ((`test`.`t1`.`f4` = '') and (`test`.`t1`.`f2` = 3) and (`test`.`t1`.`f5` > '')) +EXPLAIN SELECT f3 FROM t1 WHERE (f2 = 3 AND f4 = '' AND f5 > '') OR (f7 = 'd' AND f6 = 'e'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge PRIMARY,f2,f4,f7 f2,f7 9,5 NULL 65 32.50 Using union(f2,f7); Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`f3` AS `f3` from `test`.`t1` where (((`test`.`t1`.`f4` = '') and (`test`.`t1`.`f2` = 3) and (`test`.`t1`.`f5` > '')) or ((`test`.`t1`.`f6` = 'e') and (`test`.`t1`.`f7` = 'd'))) +EXPLAIN SELECT /*+ INDEX_MERGE(t1) */ f3 FROM t1 WHERE (f2 = 3 AND f4 = '' AND f5 > '') OR (f7 = 'd' AND f6 = 'e'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge PRIMARY,f2,f4,f7 f2,f7 9,5 NULL 65 32.50 Using union(f2,f7); Using where +Warnings: +Note 1003 /* select#1 */ select /*+ INDEX_MERGE(`t1`@`select#1`) */ `test`.`t1`.`f3` AS `f3` from `test`.`t1` where (((`test`.`t1`.`f4` = '') and (`test`.`t1`.`f2` = 3) and (`test`.`t1`.`f5` > '')) or ((`test`.`t1`.`f6` = 'e') and (`test`.`t1`.`f7` = 'd'))) +EXPLAIN SELECT /*+ INDEX_MERGE(t1 f2, PRIMARY, f7) */ f3 FROM t1 WHERE (f2 = 3 AND f4 = '' AND f5 > '') OR (f7 = 'd' AND f6 = 'e'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge PRIMARY,f2,f4,f7 f2,PRIMARY,f7 9,4,5 NULL 57 32.50 Using union(intersect(f2,PRIMARY),f7); Using where +Warnings: +Note 1003 /* select#1 */ select /*+ INDEX_MERGE(`t1`@`select#1` `f2`, `PRIMARY`, `f7`) */ `test`.`t1`.`f3` AS `f3` from `test`.`t1` where (((`test`.`t1`.`f4` = '') and (`test`.`t1`.`f2` = 3) and (`test`.`t1`.`f5` > '')) or ((`test`.`t1`.`f6` = 'e') and (`test`.`t1`.`f7` = 'd'))) +EXPLAIN SELECT /*+ INDEX_MERGE(t1) */ f2 FROM t1 WHERE f2 = 2 AND f4 = 'g' AND f5 = ''; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge PRIMARY,f2,f4 f2,f4 9,9 NULL 1 100.00 Using intersect(f2,f4); Using where; Using index +Warnings: +Note 1003 /* select#1 */ select /*+ INDEX_MERGE(`t1`@`select#1`) */ `test`.`t1`.`f2` AS `f2` from `test`.`t1` where ((`test`.`t1`.`f5` = '') and (`test`.`t1`.`f4` = 'g') and (`test`.`t1`.`f2` = 2)) +EXPLAIN SELECT /*+ INDEX_MERGE(t1 f3, f4) */ * FROM t1 IGNORE INDEX (f3) WHERE f2 = 400 AND (f3 = 'x' OR f4 = 'n'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 43.75 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref f2,f4 f2 5 const 1 43.75 Using where +Warnings: +Note 1003 /* select#1 */ select /*+ INDEX_MERGE(`t1`@`select#1` `f3`, `f4`) */ `test`.`t1`.`f1` AS `f1`,`test`.`t1`.`f2` AS `f2`,`test`.`t1`.`f3` AS `f3`,`test`.`t1`.`f4` AS `f4`,`test`.`t1`.`f5` AS `f5`,`test`.`t1`.`f6` AS `f6`,`test`.`t1`.`f7` AS `f7` from `test`.`t1` IGNORE INDEX (`f3`) where ((`test`.`t1`.`f2` = 400) and ((`test`.`t1`.`f3` = 'x') or (`test`.`t1`.`f4` = 'n'))) +EXPLAIN SELECT /*+ INDEX_MERGE(t1 f3, f4) */ * FROM t1 FORCE INDEX (f3) WHERE f2 = 400 AND (f3 = 'x' OR f4 = 'n'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 288 7.29 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL f3 NULL NULL NULL 288 7.29 Using where +Warnings: +Note 1003 /* select#1 */ select /*+ INDEX_MERGE(`t1`@`select#1` `f3`, `f4`) */ `test`.`t1`.`f1` AS `f1`,`test`.`t1`.`f2` AS `f2`,`test`.`t1`.`f3` AS `f3`,`test`.`t1`.`f4` AS `f4`,`test`.`t1`.`f5` AS `f5`,`test`.`t1`.`f6` AS `f6`,`test`.`t1`.`f7` AS `f7` from `test`.`t1` FORCE INDEX (`f3`) where ((`test`.`t1`.`f2` = 400) and ((`test`.`t1`.`f3` = 'x') or (`test`.`t1`.`f4` = 'n'))) +EXPLAIN SELECT /*+ INDEX_MERGE(t1 f2, f4) */ * FROM t1 IGNORE INDEX (f4) +WHERE (f2 BETWEEN 1 AND 200 OR f3 = 'c') AND (f2 BETWEEN 1 AND 200 OR f4 = 'f'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 288 11.11 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL f2,f3 NULL NULL NULL 288 11.11 Using where +Warnings: +Note 1003 /* select#1 */ select /*+ INDEX_MERGE(`t1`@`select#1` `f2`, `f4`) */ `test`.`t1`.`f1` AS `f1`,`test`.`t1`.`f2` AS `f2`,`test`.`t1`.`f3` AS `f3`,`test`.`t1`.`f4` AS `f4`,`test`.`t1`.`f5` AS `f5`,`test`.`t1`.`f6` AS `f6`,`test`.`t1`.`f7` AS `f7` from `test`.`t1` IGNORE INDEX (`f4`) where (((`test`.`t1`.`f2` between 1 and 200) or (`test`.`t1`.`f3` = 'c')) and ((`test`.`t1`.`f2` between 1 and 200) or (`test`.`t1`.`f4` = 'f'))) +EXPLAIN SELECT /*+ INDEX_MERGE(t1 f2, f4) */ * FROM t1 FORCE INDEX (f4) +WHERE (f2 BETWEEN 1 AND 200 OR f3 = 'c') AND (f2 BETWEEN 1 AND 200 OR f4 = 'f'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 288 11.11 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL f4 NULL NULL NULL 288 11.11 Using where +Warnings: +Note 1003 /* select#1 */ select /*+ INDEX_MERGE(`t1`@`select#1` `f2`, `f4`) */ `test`.`t1`.`f1` AS `f1`,`test`.`t1`.`f2` AS `f2`,`test`.`t1`.`f3` AS `f3`,`test`.`t1`.`f4` AS `f4`,`test`.`t1`.`f5` AS `f5`,`test`.`t1`.`f6` AS `f6`,`test`.`t1`.`f7` AS `f7` from `test`.`t1` FORCE INDEX (`f4`) where (((`test`.`t1`.`f2` between 1 and 200) or (`test`.`t1`.`f3` = 'c')) and ((`test`.`t1`.`f2` between 1 and 200) or (`test`.`t1`.`f4` = 'f'))) +EXPLAIN SELECT /*+ INDEX_MERGE(t1 f2, f3, f4) */ f2 FROM t1 IGNORE INDEX (f2, f3) WHERE f4 = 'h' AND f2 = 2 AND f3 = 'b'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 128 4.17 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref f4 f4 5 const 128 4.17 Using index condition; Using where +Warnings: +Note 1003 /* select#1 */ select /*+ INDEX_MERGE(`t1`@`select#1` `f2`, `f3`, `f4`) */ `test`.`t1`.`f2` AS `f2` from `test`.`t1` IGNORE INDEX (`f3`) IGNORE INDEX (`f2`) where ((`test`.`t1`.`f3` = 'b') and (`test`.`t1`.`f2` = 2) and (`test`.`t1`.`f4` = 'h')) +EXPLAIN SELECT /*+ INDEX_MERGE(t1 f2, f3, f4) */ f2 FROM t1 FORCE INDEX (f2, f3) WHERE f4 = 'h' AND f2 = 2 AND f3 = 'b'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge f2,f3 f2,f3 5,5 NULL 56 25.00 Using intersect(f2,f3); Using where +Warnings: +Note 1003 /* select#1 */ select /*+ INDEX_MERGE(`t1`@`select#1` `f2`, `f3`, `f4`) */ `test`.`t1`.`f2` AS `f2` from `test`.`t1` FORCE INDEX (`f3`) FORCE INDEX (`f2`) where ((`test`.`t1`.`f3` = 'b') and (`test`.`t1`.`f2` = 2) and (`test`.`t1`.`f4` = 'h')) +EXPLAIN SELECT /*+ INDEX_MERGE(t1 f2, f3, f4) */ f2 FROM t1 USE INDEX (f2, f3) WHERE f4 = 'h' AND f2 = 2 AND f3 = 'b'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge f2,f3 f2,f3 5,5 NULL 56 25.00 Using intersect(f2,f3); Using where +Warnings: +Note 1003 /* select#1 */ select /*+ INDEX_MERGE(`t1`@`select#1` `f2`, `f3`, `f4`) */ `test`.`t1`.`f2` AS `f2` from `test`.`t1` USE INDEX (`f3`) USE INDEX (`f2`) where ((`test`.`t1`.`f3` = 'b') and (`test`.`t1`.`f2` = 2) and (`test`.`t1`.`f4` = 'h')) +ALTER TABLE t1 ADD KEY idx(f3, f4); +# Original query +EXPLAIN SELECT f2 FROM t1 WHERE f2 = 2 AND f3 = 'b' AND f4 = 'h'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 44.44 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref f2,f3,f4,idx idx 10 const,const 1 44.44 Using index condition; Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`f2` AS `f2` from `test`.`t1` where ((`test`.`t1`.`f4` = 'h') and (`test`.`t1`.`f3` = 'b') and (`test`.`t1`.`f2` = 2)) +# Index merge intersection(f2, f3, f4) should be used. +EXPLAIN SELECT /*+ INDEX_MERGE(t1 f2, f3, f4) */ f2 FROM t1 WHERE f2 = 2 AND f3 = 'b' AND f4 = 'h'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge f2,f3,f4,idx f2,f3,f4 5,5,5 NULL 25 100.00 Using intersect(f2,f3,f4); Using where; Using index +Warnings: +Note 1003 /* select#1 */ select /*+ INDEX_MERGE(`t1`@`select#1` `f2`, `f3`, `f4`) */ `test`.`t1`.`f2` AS `f2` from `test`.`t1` where ((`test`.`t1`.`f4` = 'h') and (`test`.`t1`.`f3` = 'b') and (`test`.`t1`.`f2` = 2)) +SET optimizer_switch= default; +DROP TABLE t1; +# +# Bug#24788119 GET_BEST_DISJUNCT_QUICK() - MYSQLD GOT SIGNAL 11 +# +CREATE TABLE t1(f1 INT NOT NULL, f2 INT, f3 INT, PRIMARY KEY(f1), KEY(f2), KEY(f3)); +EXPLAIN SELECT /*+ INDEX_MERGE(t1) */ f1 FROM t1 WHERE f1 < 2 AND (f3 = 3 or f2 = 3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge PRIMARY,f2,f3 f3,f2 5,5 NULL 1 100.00 Using union(f3,f2); Using where +Warnings: +Note 1003 /* select#1 */ select /*+ INDEX_MERGE(`t1`@`select#1`) */ `test`.`t1`.`f1` AS `f1` from `test`.`t1` where ((`test`.`t1`.`f1` < 2) and ((`test`.`t1`.`f3` = 3) or (`test`.`t1`.`f2` = 3))) +DROP TABLE t1; +# +# Bug#24834724 QUICK_ROR_INTERSECT_SELECT::GET_NEXT() - MYSQLD GOT SIGNAL 11 +# +CREATE TABLE t1 ( +f1 VARCHAR(10) DEFAULT NULL, +f2 INT(11) NOT NULL, +f3 INT(11) DEFAULT NULL, +PRIMARY KEY (f2), +KEY f1 (f1), +KEY f3 (f3) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES ('b',1,NULL), ('h',5,NULL); +SELECT /*+ INDEX_MERGE(t1 f3, primary) */ f2 FROM t1 +WHERE f1 = 'o' AND f2 = f3 AND f3 <= 4; +f2 +DROP TABLE t1; diff --git a/mysql-test/r/opt_hints_join_order.result-pq b/mysql-test/r/opt_hints_join_order.result-pq new file mode 100644 index 000000000000..ac1e0dfe0be2 --- /dev/null +++ b/mysql-test/r/opt_hints_join_order.result-pq @@ -0,0 +1,1158 @@ +CREATE TABLE t1 (f1 INT NOT NULL); +INSERT INTO t1 VALUES (9),(0), (7); +CREATE TABLE t2 (f1 INT NOT NULL); +INSERT INTO t2 VALUES +(5),(3),(0),(3),(1),(0),(1),(7),(1),(0),(0),(8),(4),(9),(0),(2),(0),(8),(5),(1); +CREATE TABLE t3 (f1 INT NOT NULL); +INSERT INTO t3 VALUES (9),(0), (7), (4), (5); +CREATE TABLE t4 (f1 INT NOT NULL); +INSERT INTO t4 VALUES (0), (7); +CREATE TABLE t5 (f1 INT NOT NULL, PRIMARY KEY(f1)); +INSERT INTO t5 VALUES (7); +CREATE TABLE t6(f1 INT NOT NULL, PRIMARY KEY(f1)); +INSERT INTO t6 VALUES (7); +ANALYZE TABLE t1, t2, t3, t4, t5, t6; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +test.t4 analyze status OK +test.t5 analyze status OK +test.t6 analyze status OK +SELECT count(*) FROM t1 JOIN t2 JOIN t3 +WHERE t1.f1 IN (SELECT f1 FROM t4) AND t2.f1 IN (SELECT f1 FROM t5); +count(*) +10 +explain SELECT count(*) FROM t1 JOIN t2 JOIN t3 +WHERE t1.f1 IN (SELECT f1 FROM t4) AND t2.f1 IN (SELECT f1 FROM t5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t5 NULL index PRIMARY PRIMARY 4 NULL 1 100.00 Using index; Start temporary +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary; Using join buffer (hash join) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 20 10.00 Using where; Using join buffer (hash join) +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 5 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select count(0) AS `count(*)` from `test`.`t5` join `test`.`t1` join `test`.`t2` join `test`.`t3` semi join (`test`.`t4`) where ((`test`.`t2`.`f1` = `test`.`t5`.`f1`) and (`test`.`t1`.`f1` = `test`.`t4`.`f1`)) +explain SELECT /*+ QB_NAME(q1) JOIN_PREFIX(t3, t2, t2@subq2) */ count(*) FROM t1 JOIN t2 JOIN t3 +WHERE t1.f1 IN (SELECT /*+ QB_NAME(subq1) */ f1 FROM t2) AND +t2.f1 IN (SELECT /*+ QB_NAME(subq2) */ f1 FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 20 100.00 Using join buffer (hash join) +1 SIMPLE NULL eq_ref 4 test.t2.f1 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 SIMPLE NULL eq_ref 4 test.t1.f1 1 100.00 NULL +3 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 20 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 20 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select /*+ QB_NAME(`q1`) JOIN_PREFIX(@`q1` `t3`,`t2`,`t2`@`subq2`) */ count(0) AS `count(*)` from `test`.`t1` join `test`.`t2` join `test`.`t3` semi join (`test`.`t2`) semi join (`test`.`t2`) where ((``.`f1` = `test`.`t2`.`f1`) and (``.`f1` = `test`.`t1`.`f1`)) +# Second JOIN_PREFIX is conflicting +SELECT /*+ JOIN_PREFIX(t3, t2, t1) JOIN_PREFIX(t2, t1) */ count(*) FROM t1 JOIN t2 JOIN t3 +WHERE t1.f1 IN (SELECT /*+ QB_NAME(subq1) */ f1 FROM t4) +AND t2.f1 IN (SELECT /*+ QB_NAME(subq2) */ f1 FROM t5); +count(*) +10 +Warnings: +Warning 3126 Hint JOIN_PREFIX( `t2`,`t1`) is ignored as conflicting/duplicated +explain SELECT /*+ JOIN_PREFIX(t3, t2, t1) JOIN_PREFIX(t2, t1) */ count(*) FROM t1 JOIN t2 JOIN t3 +WHERE t1.f1 IN (SELECT /*+ QB_NAME(subq1) */ f1 FROM t4) +AND t2.f1 IN (SELECT /*+ QB_NAME(subq2) */ f1 FROM t5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 20 100.00 Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 SIMPLE t5 NULL eq_ref PRIMARY PRIMARY 4 test.t2.f1 1 100.00 Using index +1 SIMPLE NULL eq_ref 4 test.t1.f1 1 100.00 NULL +2 MATERIALIZED t4 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Warning 3126 Hint JOIN_PREFIX( `t2`,`t1`) is ignored as conflicting/duplicated +Note 1003 /* select#1 */ select /*+ JOIN_PREFIX(@`select#1` `t3`,`t2`,`t1`) */ count(0) AS `count(*)` from `test`.`t5` join `test`.`t1` join `test`.`t2` join `test`.`t3` semi join (`test`.`t4`) where ((`test`.`t5`.`f1` = `test`.`t2`.`f1`) and (``.`f1` = `test`.`t1`.`f1`)) +# Second JOIN_SUFFIX is conflicting +SELECT /*+ JOIN_SUFFIX(t3, t2) JOIN_SUFFIX(t2, t1) */ count(*) FROM t1 JOIN t2 JOIN t3 +WHERE t1.f1 IN (SELECT /*+ QB_NAME(subq1) */ f1 FROM t4) +AND t2.f1 IN (SELECT /*+ QB_NAME(subq2) */ f1 FROM t5); +count(*) +10 +Warnings: +Warning 3126 Hint JOIN_SUFFIX( `t2`,`t1`) is ignored as conflicting/duplicated +explain SELECT /*+ JOIN_SUFFIX(t3, t2) JOIN_SUFFIX(t2, t1) */ count(*) FROM t1 JOIN t2 JOIN t3 +WHERE t1.f1 IN (SELECT /*+ QB_NAME(subq1) */ f1 FROM t4) +AND t2.f1 IN (SELECT /*+ QB_NAME(subq2) */ f1 FROM t5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t5 NULL index PRIMARY PRIMARY 4 NULL 1 100.00 Using index; Start temporary +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary; Using join buffer (hash join) +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 5 100.00 Using join buffer (hash join) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 20 10.00 Using where; Using join buffer (hash join) +Warnings: +Warning 3126 Hint JOIN_SUFFIX( `t2`,`t1`) is ignored as conflicting/duplicated +Note 1003 /* select#1 */ select /*+ JOIN_SUFFIX(@`select#1` `t3`,`t2`) */ count(0) AS `count(*)` from `test`.`t5` join `test`.`t1` join `test`.`t2` join `test`.`t3` semi join (`test`.`t4`) where ((`test`.`t2`.`f1` = `test`.`t5`.`f1`) and (`test`.`t1`.`f1` = `test`.`t4`.`f1`)) +# Both JOIN_ORDERs applicable +SELECT /*+ JOIN_ORDER(t3, t2) JOIN_ORDER(t1, t2, t5) */ count(*) FROM t1 JOIN t2 JOIN t3 +WHERE t1.f1 IN (SELECT /*+ QB_NAME(subq1) */ f1 FROM t4) +AND t2.f1 IN (SELECT /*+ QB_NAME(subq2) */ f1 FROM t5); +count(*) +10 +explain SELECT /*+ JOIN_ORDER(t3, t2) JOIN_ORDER(t1, t2, t5) */ count(*) FROM t1 JOIN t2 JOIN t3 +WHERE t1.f1 IN (SELECT /*+ QB_NAME(subq1) */ f1 FROM t4) +AND t2.f1 IN (SELECT /*+ QB_NAME(subq2) */ f1 FROM t5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t4 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary; Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 5 100.00 Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 20 100.00 Using join buffer (hash join) +1 SIMPLE t5 NULL eq_ref PRIMARY PRIMARY 4 test.t2.f1 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select /*+ JOIN_ORDER(@`select#1` `t3`,`t2`) JOIN_ORDER(@`select#1` `t1`,`t2`,`t5`) */ count(0) AS `count(*)` from `test`.`t5` join `test`.`t1` join `test`.`t2` join `test`.`t3` semi join (`test`.`t4`) where ((`test`.`t5`.`f1` = `test`.`t2`.`f1`) and (`test`.`t1`.`f1` = `test`.`t4`.`f1`)) +# Unresoled table name t7 in JOIN_ORDER hint, hint ignored +SELECT /*+ JOIN_ORDER(t1, t7, t5) */ count(*) FROM t1 JOIN t2 JOIN t3 +WHERE t1.f1 IN (SELECT /*+ QB_NAME(subq1) */ f1 FROM t4) +AND t2.f1 IN (SELECT /*+ QB_NAME(subq2) */ f1 FROM t5); +count(*) +10 +Warnings: +Warning 3128 Unresolved name `t7` for JOIN_ORDER hint +explain SELECT /*+ JOIN_ORDER(t1, t7, t5) */ count(*) FROM t1 JOIN t2 JOIN t3 +WHERE t1.f1 IN (SELECT /*+ QB_NAME(subq1) */ f1 FROM t4) +AND t2.f1 IN (SELECT /*+ QB_NAME(subq2) */ f1 FROM t5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t5 NULL index PRIMARY PRIMARY 4 NULL 1 100.00 Using index; Start temporary +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary; Using join buffer (hash join) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 20 10.00 Using where; Using join buffer (hash join) +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 5 100.00 Using join buffer (hash join) +Warnings: +Warning 3128 Unresolved name `t7` for JOIN_ORDER hint +Note 1003 /* select#1 */ select count(0) AS `count(*)` from `test`.`t5` join `test`.`t1` join `test`.`t2` join `test`.`t3` semi join (`test`.`t4`) where ((`test`.`t2`.`f1` = `test`.`t5`.`f1`) and (`test`.`t1`.`f1` = `test`.`t4`.`f1`)) +# All hints are applicable +SELECT /*+ JOIN_PREFIX(t2, t5@subq2, t4@subq1) JOIN_ORDER(t4@subq1, t3) JOIN_SUFFIX(t1) */ count(*) +FROM t1 JOIN t2 JOIN t3 +WHERE t1.f1 IN (SELECT /*+ QB_NAME(subq1) */ f1 FROM t4) +AND t2.f1 IN (SELECT /*+ QB_NAME(subq2) */ f1 FROM t5); +count(*) +10 +explain SELECT /*+ JOIN_PREFIX(t2, t5@subq2, t4@subq1) JOIN_ORDER(t4@subq1, t3) JOIN_SUFFIX(t1) */ count(*) +FROM t1 JOIN t2 JOIN t3 +WHERE t1.f1 IN (SELECT /*+ QB_NAME(subq1) */ f1 FROM t4) +AND t2.f1 IN (SELECT /*+ QB_NAME(subq2) */ f1 FROM t5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 20 100.00 NULL +1 SIMPLE t5 NULL eq_ref PRIMARY PRIMARY 4 test.t2.f1 1 100.00 Using index +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 5 100.00 Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +2 MATERIALIZED t4 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select /*+ JOIN_PREFIX(@`select#1` `t2`,`t5`@`subq2`,`t4`@`subq1`) JOIN_ORDER(@`select#1` `t4`@`subq1`,`t3`) JOIN_SUFFIX(@`select#1` `t1`) */ count(0) AS `count(*)` from `test`.`t5` join `test`.`t1` join `test`.`t2` join `test`.`t3` semi join (`test`.`t4`) where ((`test`.`t5`.`f1` = `test`.`t2`.`f1`) and (`test`.`t1`.`f1` = ``.`f1`)) +# Second JOIN_ORDER is silently ignored +SELECT /*+ JOIN_ORDER(t3, t2) JOIN_ORDER(t2, t3) */ count(*) FROM t1 JOIN t2 JOIN t3 +WHERE t1.f1 IN (SELECT /*+ QB_NAME(subq1) */ f1 FROM t4) +AND t2.f1 IN (SELECT /*+ QB_NAME(subq2) */ f1 FROM t5); +count(*) +10 +explain SELECT /*+ JOIN_ORDER(t3, t2) JOIN_ORDER(t2, t3) */ count(*) FROM t1 JOIN t2 JOIN t3 +WHERE t1.f1 IN (SELECT /*+ QB_NAME(subq1) */ f1 FROM t4) +AND t2.f1 IN (SELECT /*+ QB_NAME(subq2) */ f1 FROM t5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t5 NULL index PRIMARY PRIMARY 4 NULL 1 100.00 Using index; Start temporary +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary; Using join buffer (hash join) +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 5 100.00 Using join buffer (hash join) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 20 10.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select /*+ JOIN_ORDER(@`select#1` `t3`,`t2`) */ count(0) AS `count(*)` from `test`.`t5` join `test`.`t1` join `test`.`t2` join `test`.`t3` semi join (`test`.`t4`) where ((`test`.`t2`.`f1` = `test`.`t5`.`f1`) and (`test`.`t1`.`f1` = `test`.`t4`.`f1`)) +# JOIN_SUFFIX is silently ignored +SELECT /*+ JOIN_ORDER(t3, t2) JOIN_SUFFIX(t3) */ count(*) FROM t1 JOIN t2 JOIN t3 +WHERE t1.f1 IN (SELECT /*+ QB_NAME(subq1) */ f1 FROM t4) +AND t2.f1 IN (SELECT /*+ QB_NAME(subq2) */ f1 FROM t5); +count(*) +10 +explain SELECT /*+ JOIN_ORDER(t3, t2) JOIN_SUFFIX(t3) */ count(*) FROM t1 JOIN t2 JOIN t3 +WHERE t1.f1 IN (SELECT /*+ QB_NAME(subq1) */ f1 FROM t4) +AND t2.f1 IN (SELECT /*+ QB_NAME(subq2) */ f1 FROM t5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t5 NULL index PRIMARY PRIMARY 4 NULL 1 100.00 Using index; Start temporary +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary; Using join buffer (hash join) +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 5 100.00 Using join buffer (hash join) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 20 10.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select /*+ JOIN_ORDER(@`select#1` `t3`,`t2`) */ count(0) AS `count(*)` from `test`.`t5` join `test`.`t1` join `test`.`t2` join `test`.`t3` semi join (`test`.`t4`) where ((`test`.`t2`.`f1` = `test`.`t5`.`f1`) and (`test`.`t1`.`f1` = `test`.`t4`.`f1`)) +# JOIN_PREFIX is silently ignored +SELECT /*+ JOIN_ORDER(t3, t2) JOIN_PREFIX(t2) */ count(*) FROM t1 JOIN t2 JOIN t3 +WHERE t1.f1 IN (SELECT /*+ QB_NAME(subq1) */ f1 FROM t4) +AND t2.f1 IN (SELECT /*+ QB_NAME(subq2) */ f1 FROM t5); +count(*) +10 +explain SELECT /*+ JOIN_ORDER(t3, t2) JOIN_PREFIX(t2) */ count(*) FROM t1 JOIN t2 JOIN t3 +WHERE t1.f1 IN (SELECT /*+ QB_NAME(subq1) */ f1 FROM t4) +AND t2.f1 IN (SELECT /*+ QB_NAME(subq2) */ f1 FROM t5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t5 NULL index PRIMARY PRIMARY 4 NULL 1 100.00 Using index; Start temporary +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary; Using join buffer (hash join) +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 5 100.00 Using join buffer (hash join) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 20 10.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select /*+ JOIN_ORDER(@`select#1` `t3`,`t2`) */ count(0) AS `count(*)` from `test`.`t5` join `test`.`t1` join `test`.`t2` join `test`.`t3` semi join (`test`.`t4`) where ((`test`.`t2`.`f1` = `test`.`t5`.`f1`) and (`test`.`t1`.`f1` = `test`.`t4`.`f1`)) +# All hints are applicable +SELECT /*+ JOIN_ORDER(t4@subq1, t3) JOIN_SUFFIX(t1) JOIN_PREFIX(t2, t5@subq2, t4@subq1) */ count(*) +FROM t1 JOIN t2 JOIN t3 +WHERE t1.f1 IN (SELECT /*+ QB_NAME(subq1) */ f1 FROM t4) +AND t2.f1 IN (SELECT /*+ QB_NAME(subq2) */ f1 FROM t5); +count(*) +10 +explain SELECT /*+ JOIN_ORDER(t4@subq1, t3) JOIN_SUFFIX(t1) JOIN_PREFIX(t2, t5@subq2, t4@subq1) */ count(*) +FROM t1 JOIN t2 JOIN t3 +WHERE t1.f1 IN (SELECT /*+ QB_NAME(subq1) */ f1 FROM t4) +AND t2.f1 IN (SELECT /*+ QB_NAME(subq2) */ f1 FROM t5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 20 100.00 NULL +1 SIMPLE t5 NULL eq_ref PRIMARY PRIMARY 4 test.t2.f1 1 100.00 Using index +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 5 100.00 Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +2 MATERIALIZED t4 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select /*+ JOIN_ORDER(@`select#1` `t4`@`subq1`,`t3`) JOIN_SUFFIX(@`select#1` `t1`) JOIN_PREFIX(@`select#1` `t2`,`t5`@`subq2`,`t4`@`subq1`) */ count(0) AS `count(*)` from `test`.`t5` join `test`.`t1` join `test`.`t2` join `test`.`t3` semi join (`test`.`t4`) where ((`test`.`t5`.`f1` = `test`.`t2`.`f1`) and (`test`.`t1`.`f1` = ``.`f1`)) +SELECT /*+ JOIN_PREFIX(t2, t5@subq2, t4@subq1, t3, t1) */ count(*) +FROM t1 JOIN t2 JOIN t3 +WHERE t1.f1 IN (SELECT /*+ QB_NAME(subq1) */ f1 FROM t4) +AND t2.f1 IN (SELECT /*+ QB_NAME(subq2) */ f1 FROM t5); +count(*) +10 +explain SELECT /*+ JOIN_PREFIX(t2, t5@subq2, t4@subq1, t3, t1) */ count(*) +FROM t1 JOIN t2 JOIN t3 +WHERE t1.f1 IN (SELECT /*+ QB_NAME(subq1) */ f1 FROM t4) +AND t2.f1 IN (SELECT /*+ QB_NAME(subq2) */ f1 FROM t5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 20 100.00 NULL +1 SIMPLE t5 NULL eq_ref PRIMARY PRIMARY 4 test.t2.f1 1 100.00 Using index +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 5 100.00 Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +2 MATERIALIZED t4 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select /*+ JOIN_PREFIX(@`select#1` `t2`,`t5`@`subq2`,`t4`@`subq1`,`t3`,`t1`) */ count(0) AS `count(*)` from `test`.`t5` join `test`.`t1` join `test`.`t2` join `test`.`t3` semi join (`test`.`t4`) where ((`test`.`t5`.`f1` = `test`.`t2`.`f1`) and (`test`.`t1`.`f1` = ``.`f1`)) +SELECT /*+ JOIN_SUFFIX(t2, t5@subq2, t4@subq1, t3, t1) */ count(*) +FROM t1 JOIN t2 JOIN t3 +WHERE t1.f1 IN (SELECT /*+ QB_NAME(subq1) */ f1 FROM t4) +AND t2.f1 IN (SELECT /*+ QB_NAME(subq2) */ f1 FROM t5); +count(*) +10 +explain SELECT /*+ JOIN_SUFFIX(t2, t5@subq2, t4@subq1, t3, t1) */ count(*) +FROM t1 JOIN t2 JOIN t3 +WHERE t1.f1 IN (SELECT /*+ QB_NAME(subq1) */ f1 FROM t4) +AND t2.f1 IN (SELECT /*+ QB_NAME(subq2) */ f1 FROM t5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 20 100.00 NULL +1 SIMPLE t5 NULL eq_ref PRIMARY PRIMARY 4 test.t2.f1 1 100.00 Using index +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 5 100.00 Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +2 MATERIALIZED t4 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select /*+ JOIN_SUFFIX(@`select#1` `t2`,`t5`@`subq2`,`t4`@`subq1`,`t3`,`t1`) */ count(0) AS `count(*)` from `test`.`t5` join `test`.`t1` join `test`.`t2` join `test`.`t3` semi join (`test`.`t4`) where ((`test`.`t5`.`f1` = `test`.`t2`.`f1`) and (`test`.`t1`.`f1` = ``.`f1`)) +SELECT /*+ JOIN_ORDER(t2, t5@subq2, t4@subq1, t3, t1) */ count(*) +FROM t1 JOIN t2 JOIN t3 +WHERE t1.f1 IN (SELECT /*+ QB_NAME(subq1) */ f1 FROM t4) +AND t2.f1 IN (SELECT /*+ QB_NAME(subq2) */ f1 FROM t5); +count(*) +10 +explain SELECT /*+ JOIN_ORDER(t2, t5@subq2, t4@subq1, t3, t1) */ count(*) +FROM t1 JOIN t2 JOIN t3 +WHERE t1.f1 IN (SELECT /*+ QB_NAME(subq1) */ f1 FROM t4) +AND t2.f1 IN (SELECT /*+ QB_NAME(subq2) */ f1 FROM t5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 20 100.00 NULL +1 SIMPLE t5 NULL eq_ref PRIMARY PRIMARY 4 test.t2.f1 1 100.00 Using index +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 5 100.00 Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +2 MATERIALIZED t4 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select /*+ JOIN_ORDER(@`select#1` `t2`,`t5`@`subq2`,`t4`@`subq1`,`t3`,`t1`) */ count(0) AS `count(*)` from `test`.`t5` join `test`.`t1` join `test`.`t2` join `test`.`t3` semi join (`test`.`t4`) where ((`test`.`t5`.`f1` = `test`.`t2`.`f1`) and (`test`.`t1`.`f1` = ``.`f1`)) +SELECT /*+ JOIN_SUFFIX(t2, t5@subq2, t4@subq1, t3, t1) +JOIN_ORDER(t2, t5@subq2, t4@subq1, t3, t1) +JOIN_PREFIX(t2, t5@subq2, t4@subq1, t3, t1) */ count(*) +FROM t1 JOIN t2 JOIN t3 +WHERE t1.f1 IN (SELECT /*+ QB_NAME(subq1) */ f1 FROM t4) +AND t2.f1 IN (SELECT /*+ QB_NAME(subq2) */ f1 FROM t5); +count(*) +10 +explain SELECT /*+ JOIN_SUFFIX(t2, t5@subq2, t4@subq1, t3, t1) +JOIN_ORDER(t2, t5@subq2, t4@subq1, t3, t1) +JOIN_PREFIX(t2, t5@subq2, t4@subq1, t3, t1) */ count(*) +FROM t1 JOIN t2 JOIN t3 +WHERE t1.f1 IN (SELECT /*+ QB_NAME(subq1) */ f1 FROM t4) +AND t2.f1 IN (SELECT /*+ QB_NAME(subq2) */ f1 FROM t5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 20 100.00 NULL +1 SIMPLE t5 NULL eq_ref PRIMARY PRIMARY 4 test.t2.f1 1 100.00 Using index +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 5 100.00 Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +2 MATERIALIZED t4 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select /*+ JOIN_SUFFIX(@`select#1` `t2`,`t5`@`subq2`,`t4`@`subq1`,`t3`,`t1`) JOIN_ORDER(@`select#1` `t2`,`t5`@`subq2`,`t4`@`subq1`,`t3`,`t1`) JOIN_PREFIX(@`select#1` `t2`,`t5`@`subq2`,`t4`@`subq1`,`t3`,`t1`) */ count(0) AS `count(*)` from `test`.`t5` join `test`.`t1` join `test`.`t2` join `test`.`t3` semi join (`test`.`t4`) where ((`test`.`t5`.`f1` = `test`.`t2`.`f1`) and (`test`.`t1`.`f1` = ``.`f1`)) +# JOIN_ORDER is ignored due to STRAIGHT_JOIN. +SELECT STRAIGHT_JOIN /*+ QB_NAME(q1) JOIN_ORDER(t2, t1) */ count(*) FROM t1 JOIN t2 JOIN t3 +WHERE t1.f1 IN (SELECT /*+ QB_NAME(subq1) */ f1 FROM t4) +AND t2.f1 IN (SELECT /*+ QB_NAME(subq2) */ f1 FROM t5); +count(*) +10 +explain SELECT STRAIGHT_JOIN /*+ QB_NAME(q1) JOIN_ORDER(t2, t1) */ count(*) FROM t1 JOIN t2 JOIN t3 +WHERE t1.f1 IN (SELECT /*+ QB_NAME(subq1) */ f1 FROM t4) +AND t2.f1 IN (SELECT /*+ QB_NAME(subq2) */ f1 FROM t5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 20 100.00 Using where; Using join buffer (hash join) +1 PRIMARY t3 NULL ALL NULL NULL NULL NULL 5 100.00 Using join buffer (hash join) +3 SUBQUERY t5 NULL index PRIMARY PRIMARY 4 NULL 1 100.00 Using index +2 DEPENDENT SUBQUERY t4 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select straight_join count(0) AS `count(*)` from `test`.`t1` join `test`.`t2` join `test`.`t3` where ((`test`.`t1`.`f1`,(/* select#2 */ select /*+ QB_NAME(`subq1`) */ `test`.`t4`.`f1` from `test`.`t4` where ((`test`.`t1`.`f1`) = `test`.`t4`.`f1`))) and (`test`.`t2`.`f1`,`test`.`t2`.`f1` in ( (/* select#3 */ select /*+ QB_NAME(`subq2`) */ `test`.`t5`.`f1` from `test`.`t5` where true ), (`test`.`t2`.`f1` in on where ((`test`.`t2`.`f1` = ``.`f1`)))))) +SELECT /*+ QB_NAME(q1) JOIN_FIXED_ORDER(@q1) */ count(*) FROM t1 JOIN t2 JOIN t3 +WHERE t1.f1 IN (SELECT /*+ QB_NAME(subq1) */ f1 FROM t4) +AND t2.f1 IN (SELECT /*+ QB_NAME(subq2) */ f1 FROM t5); +count(*) +10 +explain SELECT /*+ QB_NAME(q1) JOIN_FIXED_ORDER(@q1) */ count(*) FROM t1 JOIN t2 JOIN t3 +WHERE t1.f1 IN (SELECT /*+ QB_NAME(subq1) */ f1 FROM t4) +AND t2.f1 IN (SELECT /*+ QB_NAME(subq2) */ f1 FROM t5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 20 100.00 Using where; Using join buffer (hash join) +1 PRIMARY t3 NULL ALL NULL NULL NULL NULL 5 100.00 Using join buffer (hash join) +3 SUBQUERY t5 NULL index PRIMARY PRIMARY 4 NULL 1 100.00 Using index +2 DEPENDENT SUBQUERY t4 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select /*+ QB_NAME(`q1`) JOIN_FIXED_ORDER(@`q1`) */ straight_join count(0) AS `count(*)` from `test`.`t1` join `test`.`t2` join `test`.`t3` where ((`test`.`t1`.`f1`,(/* select#2 */ select /*+ QB_NAME(`subq1`) */ `test`.`t4`.`f1` from `test`.`t4` where ((`test`.`t1`.`f1`) = `test`.`t4`.`f1`))) and (`test`.`t2`.`f1`,`test`.`t2`.`f1` in ( (/* select#3 */ select /*+ QB_NAME(`subq2`) */ `test`.`t5`.`f1` from `test`.`t5` where true ), (`test`.`t2`.`f1` in on where ((`test`.`t2`.`f1` = ``.`f1`)))))) +SELECT /*+ QB_NAME(q1) */ count(*) FROM t1 JOIN t2 JOIN t3 +WHERE t1.f1 IN (SELECT /*+ QB_NAME(subq1) */ f1 FROM t4) +AND t2.f1 IN (SELECT /*+ QB_NAME(subq2) */ f1 FROM t5); +count(*) +10 +explain SELECT /*+ QB_NAME(q1) */ count(*) FROM t1 JOIN t2 JOIN t3 +WHERE t1.f1 IN (SELECT /*+ QB_NAME(subq1) */ f1 FROM t4) +AND t2.f1 IN (SELECT /*+ QB_NAME(subq2) */ f1 FROM t5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t5 NULL index PRIMARY PRIMARY 4 NULL 1 100.00 Using index; Start temporary +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary; Using join buffer (hash join) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 20 10.00 Using where; Using join buffer (hash join) +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 5 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select /*+ QB_NAME(`q1`) */ count(0) AS `count(*)` from `test`.`t5` join `test`.`t1` join `test`.`t2` join `test`.`t3` semi join (`test`.`t4`) where ((`test`.`t2`.`f1` = `test`.`t5`.`f1`) and (`test`.`t1`.`f1` = `test`.`t4`.`f1`)) +SELECT count(*) FROM t1 JOIN t2 STRAIGHT_JOIN t3 +WHERE t1.f1 IN (SELECT f1 FROM t4) AND t2.f1 IN (SELECT f1 FROM t5); +count(*) +10 +explain SELECT count(*) FROM t1 JOIN t2 STRAIGHT_JOIN t3 +WHERE t1.f1 IN (SELECT f1 FROM t4) AND t2.f1 IN (SELECT f1 FROM t5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t5 NULL index PRIMARY PRIMARY 4 NULL 1 100.00 Using index; Start temporary +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary; Using join buffer (hash join) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 20 10.00 Using where; Using join buffer (hash join) +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 5 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select count(0) AS `count(*)` from `test`.`t5` join `test`.`t1` join `test`.`t2` straight_join `test`.`t3` semi join (`test`.`t4`) where ((`test`.`t2`.`f1` = `test`.`t5`.`f1`) and (`test`.`t1`.`f1` = `test`.`t4`.`f1`)) +# t3 can not be first +SELECT /*+ JOIN_PREFIX(t3, t1) */ count(*) FROM t1 JOIN t2 STRAIGHT_JOIN t3 +WHERE t1.f1 IN (SELECT f1 FROM t4) AND t2.f1 IN (SELECT f1 FROM t5); +count(*) +10 +explain SELECT /*+ JOIN_PREFIX(t3, t1) */ count(*) FROM t1 JOIN t2 STRAIGHT_JOIN t3 +WHERE t1.f1 IN (SELECT f1 FROM t4) AND t2.f1 IN (SELECT f1 FROM t5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t5 NULL index PRIMARY PRIMARY 4 NULL 1 100.00 Using index; Start temporary +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary; Using join buffer (hash join) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 20 10.00 Using where; Using join buffer (hash join) +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 5 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select count(0) AS `count(*)` from `test`.`t5` join `test`.`t1` join `test`.`t2` straight_join `test`.`t3` semi join (`test`.`t4`) where ((`test`.`t2`.`f1` = `test`.`t5`.`f1`) and (`test`.`t1`.`f1` = `test`.`t4`.`f1`)) +# hint is applicable +SELECT /*+ JOIN_PREFIX(t1, t2, t3) */ count(*) FROM t1 JOIN t2 STRAIGHT_JOIN t3 +WHERE t1.f1 IN (SELECT f1 FROM t4) AND t2.f1 IN (SELECT f1 FROM t5); +count(*) +10 +explain SELECT /*+ JOIN_PREFIX(t1, t2, t3) */ count(*) FROM t1 JOIN t2 STRAIGHT_JOIN t3 +WHERE t1.f1 IN (SELECT f1 FROM t4) AND t2.f1 IN (SELECT f1 FROM t5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 20 100.00 Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 5 100.00 Using join buffer (hash join) +1 SIMPLE t5 NULL eq_ref PRIMARY PRIMARY 4 test.t2.f1 1 100.00 Using index +1 SIMPLE NULL eq_ref 4 test.t1.f1 1 100.00 NULL +2 MATERIALIZED t4 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select /*+ JOIN_PREFIX(@`select#1` `t1`,`t2`,`t3`) */ count(0) AS `count(*)` from `test`.`t5` join `test`.`t1` join `test`.`t2` straight_join `test`.`t3` semi join (`test`.`t4`) where ((`test`.`t5`.`f1` = `test`.`t2`.`f1`) and (``.`f1` = `test`.`t1`.`f1`)) +# hint is applicable +SELECT /*+ JOIN_SUFFIX(t4, t5) */ count(*) FROM t1 JOIN t2 STRAIGHT_JOIN t3 +WHERE t1.f1 IN (SELECT f1 FROM t4) AND t2.f1 IN (SELECT f1 FROM t5); +count(*) +10 +explain SELECT /*+ JOIN_SUFFIX(t4, t5) */ count(*) FROM t1 JOIN t2 STRAIGHT_JOIN t3 +WHERE t1.f1 IN (SELECT f1 FROM t4) AND t2.f1 IN (SELECT f1 FROM t5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 20 100.00 Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 5 100.00 Using join buffer (hash join) +1 SIMPLE NULL eq_ref 4 test.t1.f1 1 100.00 NULL +1 SIMPLE t5 NULL eq_ref PRIMARY PRIMARY 4 test.t2.f1 1 100.00 Using index +2 MATERIALIZED t4 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select /*+ JOIN_SUFFIX(@`select#1` `t4`,`t5`) */ count(0) AS `count(*)` from `test`.`t5` join `test`.`t1` join `test`.`t2` straight_join `test`.`t3` semi join (`test`.`t4`) where ((`test`.`t5`.`f1` = `test`.`t2`.`f1`) and (``.`f1` = `test`.`t1`.`f1`)) +SELECT /*+ QB_NAME(q1) JOIN_ORDER(@q1 t2, t3, t1) */ count(*) +FROM t1 JOIN t2 JOIN t3 +WHERE t1.f1 IN (SELECT /*+ QB_NAME(subq1) */ f1 FROM t4) +AND t2.f1 IN (SELECT /*+ QB_NAME(subq2) */ f1 FROM t5); +count(*) +10 +explain SELECT /*+ QB_NAME(q1) JOIN_ORDER(@q1 t2, t3, t1) */ count(*) +FROM t1 JOIN t2 JOIN t3 +WHERE t1.f1 IN (SELECT /*+ QB_NAME(subq1) */ f1 FROM t4) +AND t2.f1 IN (SELECT /*+ QB_NAME(subq2) */ f1 FROM t5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t5 NULL index PRIMARY PRIMARY 4 NULL 1 100.00 Using index +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 20 10.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 5 100.00 Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +2 MATERIALIZED t4 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select /*+ QB_NAME(`q1`) JOIN_ORDER(@`q1` `t2`,`t3`,`t1`) */ count(0) AS `count(*)` from `test`.`t5` join `test`.`t1` join `test`.`t2` join `test`.`t3` semi join (`test`.`t4`) where ((`test`.`t2`.`f1` = `test`.`t5`.`f1`) and (`test`.`t1`.`f1` = ``.`f1`)) +SELECT /*+ QB_NAME(q1) JOIN_PREFIX(@q1 t2, t3, t1) */ count(*) +FROM t1 JOIN t2 JOIN t3 +WHERE t1.f1 IN (SELECT /*+ QB_NAME(subq1) */ f1 FROM t4) +AND t2.f1 IN (SELECT /*+ QB_NAME(subq2) */ f1 FROM t5); +count(*) +10 +explain SELECT /*+ QB_NAME(q1) JOIN_PREFIX(@q1 t2, t3, t1) */ count(*) +FROM t1 JOIN t2 JOIN t3 +WHERE t1.f1 IN (SELECT /*+ QB_NAME(subq1) */ f1 FROM t4) +AND t2.f1 IN (SELECT /*+ QB_NAME(subq2) */ f1 FROM t5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 20 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 5 100.00 Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 SIMPLE t5 NULL eq_ref PRIMARY PRIMARY 4 test.t2.f1 1 100.00 Using index +1 SIMPLE NULL eq_ref 4 test.t1.f1 1 100.00 NULL +2 MATERIALIZED t4 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select /*+ QB_NAME(`q1`) JOIN_PREFIX(@`q1` `t2`,`t3`,`t1`) */ count(0) AS `count(*)` from `test`.`t5` join `test`.`t1` join `test`.`t2` join `test`.`t3` semi join (`test`.`t4`) where ((`test`.`t5`.`f1` = `test`.`t2`.`f1`) and (``.`f1` = `test`.`t1`.`f1`)) +SELECT /*+ QB_NAME(q1) JOIN_SUFFIX(@q1 t2, t3, t1) */ count(*) +FROM t1 JOIN t2 JOIN t3 +WHERE t1.f1 IN (SELECT /*+ QB_NAME(subq1) */ f1 FROM t4) +AND t2.f1 IN (SELECT /*+ QB_NAME(subq2) */ f1 FROM t5); +count(*) +10 +explain SELECT /*+ QB_NAME(q1) JOIN_SUFFIX(@q1 t2, t3, t1) */ count(*) +FROM t1 JOIN t2 JOIN t3 +WHERE t1.f1 IN (SELECT /*+ QB_NAME(subq1) */ f1 FROM t4) +AND t2.f1 IN (SELECT /*+ QB_NAME(subq2) */ f1 FROM t5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t5 NULL index PRIMARY PRIMARY 4 NULL 1 100.00 Using index +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 20 10.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 5 100.00 Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +2 MATERIALIZED t4 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select /*+ QB_NAME(`q1`) JOIN_SUFFIX(@`q1` `t2`,`t3`,`t1`) */ count(0) AS `count(*)` from `test`.`t5` join `test`.`t1` join `test`.`t2` join `test`.`t3` semi join (`test`.`t4`) where ((`test`.`t2`.`f1` = `test`.`t5`.`f1`) and (`test`.`t1`.`f1` = ``.`f1`)) +DROP TABLE t1, t2, t3, t4 ,t5, t6; +CREATE TABLE t1 (f1 INT); +CREATE TABLE t2 (f1 INT); +CREATE TABLE t3 (f1 INT); +CREATE TABLE t4 (f1 INT); +EXPLAIN SELECT /*+ JOIN_ORDER(t2, t4, t1) */ 1 FROM t1 +JOIN t2 ON 1 +RIGHT JOIN t3 ON 1 +JOIN t4 ON 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using join buffer (hash join) +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 1 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t3` left join (`test`.`t1` join `test`.`t2`) on((true)) join `test`.`t4` where true +EXPLAIN SELECT /*+ JOIN_ORDER(t2, t1, t4) */ 1 FROM t1 +JOIN t2 ON 1 +RIGHT JOIN t3 ON 1 +JOIN t4 ON 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using join buffer (hash join) +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 1 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select /*+ JOIN_ORDER(@`select#1` `t2`,`t1`,`t4`) */ 1 AS `1` from `test`.`t3` left join (`test`.`t1` join `test`.`t2`) on((true)) join `test`.`t4` where true +EXPLAIN SELECT /*+ JOIN_ORDER(t4, t1, t2) */ 1 FROM t1 +JOIN t2 ON 1 +RIGHT JOIN t3 ON 1 +JOIN t4 ON 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 1 100.00 Using join buffer (hash join) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select /*+ JOIN_ORDER(@`select#1` `t4`,`t1`,`t2`) */ 1 AS `1` from `test`.`t3` left join (`test`.`t1` join `test`.`t2`) on((true)) join `test`.`t4` where true +EXPLAIN SELECT /*+ JOIN_ORDER(t3, t4) */ 1 FROM t1 +JOIN t2 ON 1 +RIGHT JOIN t3 ON 1 +JOIN t4 ON 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using join buffer (hash join) +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 1 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select /*+ JOIN_ORDER(@`select#1` `t3`,`t4`) */ 1 AS `1` from `test`.`t3` left join (`test`.`t1` join `test`.`t2`) on((true)) join `test`.`t4` where true +EXPLAIN SELECT /*+ JOIN_ORDER(t4, t3) */ 1 FROM t1 +JOIN t2 ON 1 +RIGHT JOIN t3 ON 1 +JOIN t4 ON 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using join buffer (hash join) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select /*+ JOIN_ORDER(@`select#1` `t4`,`t3`) */ 1 AS `1` from `test`.`t3` left join (`test`.`t1` join `test`.`t2`) on((true)) join `test`.`t4` where true +EXPLAIN SELECT /*+ JOIN_SUFFIX(t1) */ 1 FROM t1 +JOIN t2 ON 1 +RIGHT JOIN t3 ON 1 +JOIN t4 ON 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 1 100.00 Using join buffer (hash join) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select /*+ JOIN_SUFFIX(@`select#1` `t1`) */ 1 AS `1` from `test`.`t3` left join (`test`.`t1` join `test`.`t2`) on((true)) join `test`.`t4` where true +EXPLAIN SELECT /*+ JOIN_SUFFIX(t2, t1) */ 1 FROM t1 +JOIN t2 ON 1 +RIGHT JOIN t3 ON 1 +JOIN t4 ON 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 1 100.00 Using join buffer (hash join) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select /*+ JOIN_SUFFIX(@`select#1` `t2`,`t1`) */ 1 AS `1` from `test`.`t3` left join (`test`.`t1` join `test`.`t2`) on((true)) join `test`.`t4` where true +DROP TABLE t1, t2, t3, t4; +CREATE TABLE t1 +( +f1 INT(11) NOT NULL AUTO_INCREMENT, +PRIMARY KEY (f1) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t2 +( +f1 INT(11) DEFAULT NULL +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t3 +( +f1 INT(11) DEFAULT NULL +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +EXPLAIN DELETE +FROM ta1.* USING t1 AS ta1 JOIN t1 AS ta2 ON 1 +RIGHT OUTER JOIN t2 ON (ta1.f1 = t2.f1) +WHERE (9) IN (SELECT f1 FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 DELETE ta1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.f1 1 100.00 NULL +1 SIMPLE ta2 NULL index NULL PRIMARY 4 NULL 1 100.00 Using index +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(ta2) +Warnings: +Note 1003 delete `test`.`t1` from `test`.`t2` left join (`test`.`t1` `ta1` join `test`.`t1` `ta2`) on(((`test`.`ta1`.`f1` = `test`.`t2`.`f1`))) semi join (`test`.`t3`) where (`test`.`t3`.`f1` = 9) +# Applicable hint +EXPLAIN DELETE /*+ JOIN_PREFIX(t2, t3, ta2) */ +FROM ta1.* USING t1 AS ta1 JOIN t1 AS ta2 ON 1 +RIGHT OUTER JOIN t2 ON (ta1.f1 = t2.f1) +WHERE (9) IN (SELECT f1 FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t2) +1 SIMPLE ta2 NULL index NULL PRIMARY 4 NULL 1 100.00 Using index +1 DELETE ta1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.f1 1 100.00 NULL +Warnings: +Note 1003 delete /*+ JOIN_PREFIX(@`select#1` `t2`,`t3`,`ta2`) */ `test`.`t1` from `test`.`t2` left join (`test`.`t1` `ta1` join `test`.`t1` `ta2`) on(((`test`.`ta1`.`f1` = `test`.`t2`.`f1`))) semi join (`test`.`t3`) where (`test`.`t3`.`f1` = 9) +# Applicable hint +EXPLAIN DELETE /*+ JOIN_PREFIX(t2, t3, ta1, ta2) */ +FROM ta1.* USING t1 AS ta1 JOIN t1 AS ta2 ON 1 +RIGHT OUTER JOIN t2 ON (ta1.f1 = t2.f1) +WHERE (9) IN (SELECT f1 FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t2) +1 DELETE ta1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.f1 1 100.00 NULL +1 SIMPLE ta2 NULL index NULL PRIMARY 4 NULL 1 100.00 Using index +Warnings: +Note 1003 delete /*+ JOIN_PREFIX(@`select#1` `t2`,`t3`,`ta1`,`ta2`) */ `test`.`t1` from `test`.`t2` left join (`test`.`t1` `ta1` join `test`.`t1` `ta2`) on(((`test`.`ta1`.`f1` = `test`.`t2`.`f1`))) semi join (`test`.`t3`) where (`test`.`t3`.`f1` = 9) +# Applicable hint +EXPLAIN DELETE /*+ JOIN_PREFIX(t2, t3, ta2, ta1) */ +FROM ta1.* USING t1 AS ta1 JOIN t1 AS ta2 ON 1 +RIGHT OUTER JOIN t2 ON (ta1.f1 = t2.f1) +WHERE (9) IN (SELECT f1 FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t2) +1 SIMPLE ta2 NULL index NULL PRIMARY 4 NULL 1 100.00 Using index +1 DELETE ta1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.f1 1 100.00 NULL +Warnings: +Note 1003 delete /*+ JOIN_PREFIX(@`select#1` `t2`,`t3`,`ta2`,`ta1`) */ `test`.`t1` from `test`.`t2` left join (`test`.`t1` `ta1` join `test`.`t1` `ta2`) on(((`test`.`ta1`.`f1` = `test`.`t2`.`f1`))) semi join (`test`.`t3`) where (`test`.`t3`.`f1` = 9) +# Hint should be ignored +EXPLAIN DELETE /*+ JOIN_SUFFIX(ta2, t3, ta1) */ +FROM ta1.* USING t1 AS ta1 JOIN t1 AS ta2 ON 1 +RIGHT OUTER JOIN t2 ON (ta1.f1 = t2.f1) +WHERE (9) IN (SELECT f1 FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 DELETE ta1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.f1 1 100.00 NULL +1 SIMPLE ta2 NULL index NULL PRIMARY 4 NULL 1 100.00 Using index +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(ta2) +Warnings: +Note 1003 delete `test`.`t1` from `test`.`t2` left join (`test`.`t1` `ta1` join `test`.`t1` `ta2`) on(((`test`.`ta1`.`f1` = `test`.`t2`.`f1`))) semi join (`test`.`t3`) where (`test`.`t3`.`f1` = 9) +# Both hints are ignored +EXPLAIN DELETE /*+ JOIN_PREFIX(ta1, t2, t3) JOIN_SUFFIX(t3, ta2) */ +FROM ta1.* USING t1 AS ta1 JOIN t1 AS ta2 ON 1 +RIGHT OUTER JOIN t2 ON (ta1.f1 = t2.f1) +WHERE (9) IN (SELECT f1 FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 DELETE ta1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.f1 1 100.00 NULL +1 SIMPLE ta2 NULL index NULL PRIMARY 4 NULL 1 100.00 Using index +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(ta2) +Warnings: +Note 1003 delete `test`.`t1` from `test`.`t2` left join (`test`.`t1` `ta1` join `test`.`t1` `ta2`) on(((`test`.`ta1`.`f1` = `test`.`t2`.`f1`))) semi join (`test`.`t3`) where (`test`.`t3`.`f1` = 9) +DROP TABLE t1, t2, t3; +CREATE TABLE t1(f1 INT) ENGINE=MyISAM; +INSERT INTO t1 VALUES (1); +CREATE TABLE t2(f1 INT) ENGINE=InnoDB; +INSERT INTO t2 VALUES (1); +EXPLAIN SELECT /*+ JOIN_PREFIX(t1, t2) */ 1 FROM t1 JOIN t2 ON t1.f1 = t2.f1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select /*+ JOIN_PREFIX(@`select#1` `t1`,`t2`) */ 1 AS `1` from `test`.`t2` where (`test`.`t2`.`f1` = '1') +EXPLAIN SELECT /*+ JOIN_PREFIX(t2, t1) */ 1 FROM t1 JOIN t2 ON t1.f1 = t2.f1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select /*+ JOIN_PREFIX(@`select#1` `t2`,`t1`) */ 1 AS `1` from `test`.`t2` where (`test`.`t2`.`f1` = '1') +DROP TABLE t1, t2; +# +# Bug#23144274 WL9158:ASSERTION `JOIN->BEST_READ < DOUBLE(1.79769313486231570815E+308L)' FAILED +# +CREATE TABLE t1 ( +f1 int(11) NOT NULL AUTO_INCREMENT, +f2 varchar(255) DEFAULT NULL, +PRIMARY KEY (f1)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t2 ( +f1 int(11) NOT NULL AUTO_INCREMENT, +f2 varchar(255) CHARACTER SET utf8 DEFAULT NULL, +f3 varchar(10) DEFAULT NULL, +PRIMARY KEY (f1), +KEY f3(f3)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +EXPLAIN SELECT /*+ JOIN_SUFFIX(t1, t2) */ t2.f3 FROM t2 LEFT JOIN t1 +ON t2.f1 = t1.f1 WHERE t1.f2 NOT LIKE ('FMGAU') OR t2.f2 > 't'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.f1 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`f3` AS `f3` from `test`.`t2` left join `test`.`t1` on((`test`.`t1`.`f1` = `test`.`t2`.`f1`)) where ((not((`test`.`t1`.`f2` like 'FMGAU'))) or (`test`.`t2`.`f2` > 't')) +DROP TABLE t1, t2; +CREATE TABLE t1 +( +f1 int(11) DEFAULT NULL, +KEY f1 (f1) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t2 +( +f1 int(11) DEFAULT NULL, +f2 varchar(255) CHARACTER SET utf8 DEFAULT NULL, +KEY f2 (f2), +KEY f1 (f1) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +CREATE TABLE t3 ( +f1 int(11) DEFAULT NULL, +f2 varchar(255) CHARACTER SET cp932 DEFAULT NULL, +KEY f1 (f1), +KEY f2 (f2) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +EXPLAIN SELECT /*+ JOIN_ORDER(t2, t3) JOIN_ORDER(t1, t2) */ t3.f1 +FROM ( t2 INNER JOIN t3 ON t3.f2 = t2.f2 LEFT JOIN t1 ON t1.f1 = t3.f1 ) +WHERE NOT (t2.f1 >= 7); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL range f2,f1 f1 5 NULL 1 100.00 Using index condition +2 SIMPLE t3 NULL ALL f2 NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t1 NULL ref f1 f1 5 test.t3.f1 1 100.00 Using index +Warnings: +Warning 1739 Cannot use ref access on index 'f2' due to type or collation conversion on field 'f2' +Warning 1739 Cannot use range access on index 'f2' due to type or collation conversion on field 'f2' +Note 1003 /* select#1 */ select /*+ JOIN_ORDER(@`select#1` `t2`,`t3`) */ `test`.`t3`.`f1` AS `f1` from `test`.`t2` join `test`.`t3` left join `test`.`t1` on((`test`.`t1`.`f1` = `test`.`t3`.`f1`)) where ((`test`.`t2`.`f1` < 7) and (`test`.`t3`.`f2` = `test`.`t2`.`f2`)) +EXPLAIN SELECT /*+ JOIN_ORDER(t1, t2) JOIN_ORDER(t2, t3) */ t3.f1 +FROM ( t2 INNER JOIN t3 ON t3.f2 = t2.f2 LEFT JOIN t1 ON t1.f1 = t3.f1 ) +WHERE NOT (t2.f1 >= 7); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t3 NULL ALL f2 NULL NULL NULL 1 100.00 Using where +2 SIMPLE t1 NULL ref f1 f1 5 test.t3.f1 1 100.00 Using index +2 SIMPLE t2 NULL ref f2,f1 f2 768 test.t3.f2 1 100.00 Using index condition; Using where +Warnings: +Warning 1739 Cannot use ref access on index 'f2' due to type or collation conversion on field 'f2' +Note 1003 /* select#1 */ select /*+ JOIN_ORDER(@`select#1` `t1`,`t2`) */ `test`.`t3`.`f1` AS `f1` from `test`.`t2` join `test`.`t3` left join `test`.`t1` on((`test`.`t1`.`f1` = `test`.`t3`.`f1`)) where ((`test`.`t2`.`f1` < 7) and (`test`.`t3`.`f2` = `test`.`t2`.`f2`)) +DROP TABLE t1, t2, t3; +CREATE TABLE t1 ( +f1 INT(11) NOT NULL AUTO_INCREMENT, +f2 INT(11) DEFAULT NULL, +PRIMARY KEY (f1) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t2 ( +f1 INT(11) NOT NULL AUTO_INCREMENT, +PRIMARY KEY (f1) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +EXPLAIN SELECT /*+ JOIN_PREFIX(t1, t1) */ t2.f1 FROM t1 JOIN t2 ON t1.f2 = t2.f1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.f2 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`f1` AS `f1` from `test`.`t1` join `test`.`t2` where (`test`.`t2`.`f1` = `test`.`t1`.`f2`) +DROP TABLE t1, t2; +CREATE TABLE t1 +( +f1 DATETIME, +f2 DATE, +f3 VARCHAR(1), +KEY (f1) +) ENGINE=myisam; +CREATE TABLE t2 +( +f1 VARCHAR(1), +f2 INT, +f3 VARCHAR(1), +KEY (f1) +) ENGINE=innodb; +CREATE TABLE t3 +( +f1 VARCHAR(1), +f2 DATE, +f3 DATETIME, +f4 INT +) ENGINE=myisam; +EXPLAIN +UPDATE /*+ JOIN_ORDER(t2, als1, als3) JOIN_FIXED_ORDER() */ t3 AS als1 +JOIN t1 AS als2 ON (als1.f3 = als2 .f1) +JOIN t1 AS als3 ON (als1.f1 = als3.f3) +RIGHT OUTER JOIN t3 AS als4 ON (als1.f3 = als4.f2) +SET als1.f4 = 'eogqjvbhzodzimqahyzlktkbexkhdwxwgifikhcgblhgswxyutepc' +WHERE ('i','b') IN (SELECT f3, f1 FROM t2 WHERE f2 <> f2 AND als2.f2 IS NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Warning 3126 Hint JOIN_FIXED_ORDER( ) is ignored as conflicting/duplicated +Note 1276 Field or reference 'test.als2.f2' of SELECT #2 was resolved in SELECT #1 +Note 1003 update /*+ JOIN_ORDER(@`select#1` `t2`,`als1`,`als3`) */ `test`.`t3` `als4` left join (`test`.`t3` `als1` join `test`.`t1` `als2` join `test`.`t1` `als3`) on(((`test`.`als1`.`f3` = `test`.`als4`.`f2`) and multiple equal(`test`.`als1`.`f1`, `test`.`als3`.`f3`) and multiple equal(`test`.`als1`.`f3`, `test`.`als2`.`f1`))) semi join (`test`.`t2`) set `test`.`als1`.`f4` = 'eogqjvbhzodzimqahyzlktkbexkhdwxwgifikhcgblhgswxyutepc' where false +DROP TABLE t1, t2, t3; +CREATE TABLE t1( +f1 VARCHAR(1)) ENGINE=myisam; +CREATE TABLE t2( +f1 VARCHAR(1), +f2 VARCHAR(1), +f3 DATETIME, +KEY(f2)) ENGINE=innodb; +CREATE TABLE t3( +f1 INT, +f2 DATE, +f3 VARCHAR(1), +KEY(f3)) ENGINE=myisam; +CREATE TABLE t4( +f1 VARCHAR(1), +KEY(f1)) ENGINE=innodb; +ALTER TABLE t4 DISABLE KEYS; +Warnings: +Note 1031 Table storage engine for 't4' doesn't have this option +INSERT INTO t4 VALUES ('x'), (NULL), ('d'), ('x'), ('u'); +ALTER TABLE t4 ENABLE KEYS; +Warnings: +Note 1031 Table storage engine for 't4' doesn't have this option +CREATE TABLE t5( +f1 VARCHAR(1), +KEY(f1) ) ENGINE=myisam; +INSERT INTO t5 VALUES (NULL), ('s'), ('c'), ('x'), ('z'); +EXPLAIN UPDATE /*+ JOIN_ORDER(t4, alias1, alias3) */ t3 AS alias1 +JOIN t5 ON (alias1.f3 = t5.f1) +JOIN t3 AS alias3 ON (alias1.f2 = alias3.f2 ) +RIGHT OUTER JOIN t1 ON (alias1.f3 = t1.f1) +SET alias1.f1 = -1 +WHERE ( 'v', 'o' ) IN +(SELECT DISTINCT t2.f1, t2.f2 FROM t4 RIGHT OUTER JOIN t2 ON (t4.f1 = t2.f1) +WHERE t2.f3 BETWEEN '2001-10-04' AND '2003-05-15'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 update /*+ JOIN_ORDER(@`select#1` `t4`,`alias1`,`alias3`) */ `test`.`t1` left join (`test`.`t3` `alias1` join `test`.`t5` join `test`.`t3` `alias3`) on((multiple equal(`test`.`alias1`.`f3`, `test`.`t1`.`f1`, `test`.`t5`.`f1`) and multiple equal(`test`.`alias1`.`f2`, `test`.`alias3`.`f2`))) semi join (`test`.`t2` left join `test`.`t4` on((`test`.`t4`.`f1` = `test`.`t2`.`f1`))) set `test`.`alias1`.`f1` = -(1) where ((`test`.`t2`.`f3` between '2001-10-04' and '2003-05-15') and multiple equal('v', `test`.`t2`.`f1`) and multiple equal('o', `test`.`t2`.`f2`)) +DROP TABLE t1, t2, t3, t4, t5; +CREATE TABLE t1 ( +f1 INT(11) DEFAULT NULL, +f3 VARCHAR(1) DEFAULT NULL, +f2 INT(11) DEFAULT NULL, +KEY (f1) +) ENGINE=MyISAM; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t2( +f1 INT(11) DEFAULT NULL +) ENGINE=MyISAM; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t3 ( +f1 VARCHAR(1) DEFAULT NULL, +f2 VARCHAR(1) DEFAULT NULL, +KEY (f2) +) ENGINE=InnoDB; +EXPLAIN UPDATE /*+ JOIN_SUFFIX(ta1, t2) */ +t1 AS ta1 JOIN t1 AS ta2 ON ta1.f1 = ta2.f1 RIGHT JOIN t2 ON (ta1.f1 = t2.f1) +SET ta1.f2 = '', ta2.f3 = '' +WHERE ('n', 'r') IN (SELECT f2, f1 FROM t3 WHERE f1 <> f2 XOR ta2.f3 IS NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.ta2.f3' of SELECT #2 was resolved in SELECT #1 +Note 1003 update /*+ JOIN_SUFFIX(@`select#1` `ta1`,`t2`) */ `test`.`t2` left join (`test`.`t1` `ta1` join `test`.`t1` `ta2`) on((multiple equal(`test`.`ta1`.`f1`, `test`.`t2`.`f1`, `test`.`ta2`.`f1`))) semi join (`test`.`t3`) set `test`.`ta1`.`f2` = '',`test`.`ta2`.`f3` = '' where (((`test`.`t3`.`f1` <> `test`.`t3`.`f2`) xor (`test`.`ta2`.`f3` is null)) and multiple equal('n', `test`.`t3`.`f2`) and multiple equal('r', `test`.`t3`.`f1`)) +DROP TABLE t1, t2, t3; +CREATE TABLE t2(f1 VARCHAR(255) DEFAULT NULL, f2 INT(11) DEFAULT NULL, +KEY (f1), KEY (f2)) charset latin1 ENGINE=MyISAM; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t4(f1 INT(11) DEFAULT NULL, f2 INT(11) DEFAULT NULL, KEY (f1)) +charset latin1 ENGINE=MyISAM; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t5(f1 INT(11) NOT NULL AUTO_INCREMENT, f2 INT(11) DEFAULT NULL, PRIMARY KEY (f1)) +charset latin1 ENGINE=InnoDB; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t6(f1 INT(11) NOT NULL AUTO_INCREMENT, PRIMARY KEY (f1)) +charset latin1 ENGINE=InnoDB; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t7 (f1 VARCHAR(255) DEFAULT NULL) +charset latin1 ENGINE=InnoDB; +CREATE TABLE t10(f1 INT(11) NOT NULL AUTO_INCREMENT,f2 INT(11) DEFAULT NULL,f3 VARCHAR(10) DEFAULT NULL, +PRIMARY KEY (f1),KEY (f2),KEY (f3)) charset latin1 ENGINE=MyISAM; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t11(f1 INT(11) DEFAULT NULL,f2 VARCHAR(10) DEFAULT NULL, +KEY (f1),KEY (f2)) charset latin1 ENGINE=InnoDB; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +EXPLAIN +SELECT /*+ JOIN_ORDER(alias11, alias8) */ 1 +FROM t4 AS alias4 +LEFT JOIN t5 AS alias5 JOIN t6 AS alias6 ON alias5.f2 = alias6.f1 +LEFT JOIN t7 AS alias7 JOIN t2 AS alias8 ON alias7.f1 = alias8.f1 +ON alias5.f1 = alias8.f2 ON alias4.f2 = alias6.f1 +JOIN t10 AS alias10 JOIN t11 AS alias11 ON alias10.f1 = alias11.f1 +ON alias4.f2 = alias11.f2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Warning 1739 Cannot use ref access on index 'f2' due to type or collation conversion on field 'f2' +Note 1003 /* select#1 */ select /*+ JOIN_ORDER(@`select#1` `alias11`,`alias8`) */ 1 AS `1` from `test`.`t4` `alias4` left join (`test`.`t5` `alias5` join `test`.`t6` `alias6` left join (`test`.`t7` `alias7` join `test`.`t2` `alias8`) on((multiple equal(`test`.`alias5`.`f1`, `test`.`alias8`.`f2`) and multiple equal(`test`.`alias7`.`f1`, `test`.`alias8`.`f1`)))) on((multiple equal(NULL, `test`.`alias6`.`f1`, `test`.`alias5`.`f2`))) join `test`.`t10` `alias10` join `test`.`t11` `alias11` where ((NULL = `test`.`alias11`.`f2`) and multiple equal(NULL, `test`.`alias11`.`f1`)) +EXPLAIN +SELECT /*+ JOIN_ORDER(alias11, alias10, alias8, alias7) */ 1 +FROM t4 AS alias4 +LEFT JOIN t5 AS alias5 JOIN t6 AS alias6 ON alias5.f2 = alias6.f1 +LEFT JOIN t7 AS alias7 JOIN t2 AS alias8 ON alias7.f1 = alias8.f1 +ON alias5.f1 = alias8.f2 ON alias4.f2 = alias6.f1 +JOIN t10 AS alias10 JOIN t11 AS alias11 ON alias10.f1 = alias11.f1 +ON alias4.f2 = alias11.f2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Warning 1739 Cannot use ref access on index 'f2' due to type or collation conversion on field 'f2' +Note 1003 /* select#1 */ select /*+ JOIN_ORDER(@`select#1` `alias11`,`alias10`,`alias8`,`alias7`) */ 1 AS `1` from `test`.`t4` `alias4` left join (`test`.`t5` `alias5` join `test`.`t6` `alias6` left join (`test`.`t7` `alias7` join `test`.`t2` `alias8`) on((multiple equal(`test`.`alias5`.`f1`, `test`.`alias8`.`f2`) and multiple equal(`test`.`alias7`.`f1`, `test`.`alias8`.`f1`)))) on((multiple equal(NULL, `test`.`alias6`.`f1`, `test`.`alias5`.`f2`))) join `test`.`t10` `alias10` join `test`.`t11` `alias11` where ((NULL = `test`.`alias11`.`f2`) and multiple equal(NULL, `test`.`alias11`.`f1`)) +DROP TABLES t2, t4, t5, t6, t7, t10, t11; +CREATE TABLE t1 (f1 VARCHAR(255) DEFAULT NULL, f2 VARCHAR(255) DEFAULT NULL, +KEY (f1), KEY (f2)) ENGINE=InnoDB; +CREATE TABLE t2(f1 VARCHAR(255) DEFAULT NULL, f2 INT(11) DEFAULT NULL, +KEY (f1), KEY (f2)) ENGINE=InnoDB; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t3( +f1 INT(11) NOT NULL AUTO_INCREMENT, f2 VARCHAR(255) DEFAULT NULL, +PRIMARY KEY (f1), KEY (f2)) ENGINE=InnoDB; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t4(f1 INT(11) DEFAULT NULL, f2 INT(11) DEFAULT NULL, KEY (f1)) ENGINE=InnoDB; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t6(f1 INT(11) NOT NULL AUTO_INCREMENT, PRIMARY KEY (f1)) ENGINE=InnoDB; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t7 (f1 VARCHAR(255) DEFAULT NULL) ENGINE=InnoDB; +CREATE TABLE t10(f1 INT(11) NOT NULL AUTO_INCREMENT,f2 INT(11) DEFAULT NULL,f3 VARCHAR(10) DEFAULT NULL, +PRIMARY KEY (f1),KEY (f2),KEY (f3)) ENGINE=InnoDB; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +EXPLAIN SELECT /*+ JOIN_ORDER(alias8, alias6) */ 1 +FROM t1 AS alias1 +LEFT JOIN t7 alias7 +JOIN t2 AS alias2 +LEFT JOIN t3 AS alias3 JOIN t4 AS alias4 ON alias4.f2 = alias3.f1 +ON alias4.f1 = alias2.f1 +ON alias2.f2 = alias7.f1 +JOIN t10 AS alias5 +LEFT JOIN t6 AS alias6 JOIN t2 AS alias8 ON alias6.f1 = alias8.f2 +ON alias6.f1 = alias5.f1 +ON alias5.f3 = alias7.f1 +ON alias1.f2 = alias7.f1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE alias1 NULL index NULL f2 1023 NULL 1 100.00 Using index +2 SIMPLE alias7 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 SIMPLE alias2 NULL ref f2 f2 5 test.alias7.f1 1 100.00 Using where +2 SIMPLE alias4 NULL ref f1 f1 5 test.alias2.f1 1 100.00 Using where +2 SIMPLE alias3 NULL eq_ref PRIMARY PRIMARY 4 test.alias4.f2 1 100.00 Using index +2 SIMPLE alias5 NULL ref f3 f3 43 test.alias7.f1 1 100.00 Using where; Using index +2 SIMPLE alias8 NULL ref f2 f2 5 test.alias5.f1 1 100.00 Using index +2 SIMPLE alias6 NULL eq_ref PRIMARY PRIMARY 4 test.alias5.f1 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select /*+ JOIN_ORDER(@`select#1` `alias8`,`alias6`) */ 1 AS `1` from `test`.`t1` `alias1` left join (`test`.`t7` `alias7` join `test`.`t2` `alias2` left join (`test`.`t3` `alias3` join `test`.`t4` `alias4`) on(((`test`.`alias3`.`f1` = `test`.`alias4`.`f2`) and (cast(`test`.`alias4`.`f1` as double) = cast(`test`.`alias2`.`f1` as double)))) join `test`.`t10` `alias5` left join (`test`.`t6` `alias6` join `test`.`t2` `alias8`) on(((`test`.`alias8`.`f2` = `test`.`alias5`.`f1`) and (`test`.`alias6`.`f1` = `test`.`alias5`.`f1`)))) on(((`test`.`alias7`.`f1` = `test`.`alias1`.`f2`) and (`test`.`alias5`.`f3` = `test`.`alias1`.`f2`) and (cast(`test`.`alias2`.`f2` as double) = cast(`test`.`alias1`.`f2` as double)))) where true +DROP TABLES t1, t2, t3, t4, t6, t7, t10; +# +# Bug#23144230 WL#9158 : OPT_HINTS_QB::APPLY_JOIN_ORDER_HINTS - MYSQLD GOT SIGNAL 11 +# +CREATE TABLE t1 ( +f1 int(11) NOT NULL AUTO_INCREMENT, +f2 int(11) DEFAULT NULL, +f3 int(11) DEFAULT NULL, +PRIMARY KEY (f1), +KEY f2 (f2)) +ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=latin1; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t2 ( +f1 int(11) NOT NULL AUTO_INCREMENT, +f2 int(11) DEFAULT NULL, +f3 int(11) DEFAULT NULL, +PRIMARY KEY (f1), +KEY f2 (f2)) +ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=latin1; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +EXPLAIN SELECT /*+ JOIN_PREFIX(alias1) */ alias2.f3 AS field1 +FROM ( SELECT * FROM t1 ) AS alias1 JOIN ( SELECT * FROM t2 ) AS alias2 +ON alias1.f2 = alias2.f3 +WHERE alias2.f2 IS NULL HAVING (field1 != 3 AND field1 >= 8); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ref f2 f2 5 const 1 100.00 Using index condition; Using where +2 SIMPLE t1 NULL ref f2 f2 5 test.t2.f3 1 100.00 Using index +Warnings: +Warning 3128 Unresolved name `alias1` for JOIN_PREFIX hint +Note 1003 /* select#1 */ select `test`.`t2`.`f3` AS `field1` from `test`.`t1` join `test`.`t2` where ((`test`.`t1`.`f2` = `test`.`t2`.`f3`) and (`test`.`t2`.`f2` is null)) having ((`field1` <> 3) and (`field1` >= 8)) +DROP TABLE t1, t2; +CREATE TABLE t1 +( +f1 int(11) NOT NULL AUTO_INCREMENT, +f2 INT(11) DEFAULT NULL, +PRIMARY KEY (f1) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t2 +( +f1 int(11) NOT NULL AUTO_INCREMENT, +f2 INT(11) DEFAULT NULL, +PRIMARY KEY (f1), +KEY (f2) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +EXPLAIN SELECT /*+ JOIN_ORDER(t2, t1) JOIN_FIXED_ORDER() */ t2.f1 FROM t1 JOIN t2 ON t1.f1 = t2.f2 +WHERE (t1.f2 > 5 AND t1.f1 <= 5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL index f2 f2 5 NULL 1 100.00 Using where; Using index +2 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.f2 1 100.00 Using where +Warnings: +Warning 3126 Hint JOIN_FIXED_ORDER( ) is ignored as conflicting/duplicated +Note 1003 /* select#1 */ select /*+ JOIN_ORDER(@`select#1` `t2`,`t1`) */ `test`.`t2`.`f1` AS `f1` from `test`.`t1` join `test`.`t2` where ((`test`.`t1`.`f1` = `test`.`t2`.`f2`) and (`test`.`t1`.`f2` > 5) and (`test`.`t2`.`f2` <= 5)) +EXPLAIN SELECT /*+ JOIN_FIXED_ORDER() JOIN_ORDER(t2, t1) */ t2.f1 FROM t1 JOIN t2 ON t1.f1 = t2.f2 +WHERE (t1.f2 > 5 AND t1.f1 <= 5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range PRIMARY PRIMARY 4 NULL 1 100.00 Using where +2 SIMPLE t2 NULL ref f2 f2 5 test.t1.f1 1 100.00 Using index +Warnings: +Warning 3126 Hint JOIN_ORDER( `t2`,`t1`) is ignored as conflicting/duplicated +Note 1003 /* select#1 */ select /*+ JOIN_FIXED_ORDER(@`select#1`) */ straight_join `test`.`t2`.`f1` AS `f1` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`f2` = `test`.`t1`.`f1`) and (`test`.`t1`.`f2` > 5) and (`test`.`t1`.`f1` <= 5)) +EXPLAIN SELECT /*+ JOIN_FIXED_ORDER() JOIN_PREFIX(t2, t1) */ t2.f1 FROM t1 JOIN t2 ON t1.f1 = t2.f2 +WHERE (t1.f2 > 5 AND t1.f1 <= 5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range PRIMARY PRIMARY 4 NULL 1 100.00 Using where +2 SIMPLE t2 NULL ref f2 f2 5 test.t1.f1 1 100.00 Using index +Warnings: +Warning 3126 Hint JOIN_PREFIX( `t2`,`t1`) is ignored as conflicting/duplicated +Note 1003 /* select#1 */ select /*+ JOIN_FIXED_ORDER(@`select#1`) */ straight_join `test`.`t2`.`f1` AS `f1` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`f2` = `test`.`t1`.`f1`) and (`test`.`t1`.`f2` > 5) and (`test`.`t1`.`f1` <= 5)) +EXPLAIN SELECT /*+ JOIN_FIXED_ORDER() JOIN_SUFFIX(t2, t1) */ t2.f1 FROM t1 JOIN t2 ON t1.f1 = t2.f2 +WHERE (t1.f2 > 5 AND t1.f1 <= 5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range PRIMARY PRIMARY 4 NULL 1 100.00 Using where +2 SIMPLE t2 NULL ref f2 f2 5 test.t1.f1 1 100.00 Using index +Warnings: +Warning 3126 Hint JOIN_SUFFIX( `t2`,`t1`) is ignored as conflicting/duplicated +Note 1003 /* select#1 */ select /*+ JOIN_FIXED_ORDER(@`select#1`) */ straight_join `test`.`t2`.`f1` AS `f1` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`f2` = `test`.`t1`.`f1`) and (`test`.`t1`.`f2` > 5) and (`test`.`t1`.`f1` <= 5)) +DROP TABLE t1, t2; +# +# Bug#23651098 WL#9158 : ASSERTION `!(SJ_NEST->SJ_INNER_TABLES & JOIN->CONST_TABLE_MAP)' FAILED +# +CREATE TABLE t1 +( +f1 INT(11) NOT NULL AUTO_INCREMENT, +PRIMARY KEY (f1) +) ENGINE=InnoDB; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t2 +( +f1 VARCHAR(1) DEFAULT NULL +) ENGINE=MyISAM; +CREATE TABLE t3 +( +f1 VARCHAR(1) DEFAULT NULL +) ENGINE=MyISAM; +EXPLAIN SELECT /*+ JOIN_PREFIX(t2, t1) */ t1.f1 FROM t1, t2 +WHERE t2.f1 IN (SELECT t3.f1 FROM t3) AND t1.f1 = 183; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select /*+ JOIN_PREFIX(@`select#1` `t2`,`t1`) */ NULL AS `f1` from `test`.`t1` join `test`.`t2` semi join (`test`.`t3`) where (multiple equal(183, NULL) and multiple equal(NULL, `test`.`t3`.`f1`)) +DROP TABLE t1, t2, t3; +# +# Bug23715779 SELECT QUERY WITH JOIN_PREFIX() HINT RETURNS INCORRECT RESULT +# +CREATE TABLE t1(f1 INT(11) NOT NULL); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (10); +CREATE TABLE t2 +( +f1 INT(11) NOT NULL AUTO_INCREMENT, +f2 INT(11) DEFAULT NULL, +PRIMARY KEY (f1), +KEY (f2) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (1, 7), (2, 1), (4, 7); +CREATE TABLE t4(f1 INT DEFAULT NULL); +INSERT INTO t4 VALUES (2); +ANALYZE TABLE t1, t2, t4; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t4 analyze status OK +SELECT +COUNT(*) FROM t1 JOIN t2 AS ta3 JOIN t2 AS ta4 +WHERE ta4.f1 IN (SELECT /*+ QB_NAME(qb1) */ f1 FROM t4) AND +ta3.f2 IN (SELECT /*+ QB_NAME(qb2) */ f2 FROM t2); +COUNT(*) +3 +EXPLAIN SELECT +COUNT(*) FROM t1 JOIN t2 AS ta3 JOIN t2 AS ta4 +WHERE ta4.f1 IN (SELECT /*+ QB_NAME(qb1) */ f1 FROM t4) AND +ta3.f2 IN (SELECT /*+ QB_NAME(qb2) */ f2 FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +2 SIMPLE ta4 NULL eq_ref PRIMARY PRIMARY 4 test.t4.f1 1 100.00 Using index; End temporary +2 SIMPLE t2 NULL index f2 f2 5 NULL 3 66.67 Using where; Using index; LooseScan +2 SIMPLE ta3 NULL ref f2 f2 5 test.t2.f2 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` join `test`.`t2` `ta3` join `test`.`t2` `ta4` semi join (`test`.`t4`) semi join (`test`.`t2`) where ((`test`.`ta3`.`f2` = `test`.`t2`.`f2`) and (`test`.`ta4`.`f1` = `test`.`t4`.`f1`)) +SELECT /*+ JOIN_PREFIX(t2@qb2, t4@qb1, ta3, ta4) */ +COUNT(*) FROM t1 JOIN t2 AS ta3 JOIN t2 AS ta4 +WHERE ta4.f1 IN (SELECT /*+ QB_NAME(qb1) */ f1 FROM t4) AND +ta3.f2 IN (SELECT /*+ QB_NAME(qb2) */ f2 FROM t2); +COUNT(*) +3 +EXPLAIN SELECT /*+ JOIN_PREFIX(t2@qb2, t4@qb1, ta3, ta4) */ +COUNT(*) FROM t1 JOIN t2 AS ta3 JOIN t2 AS ta4 +WHERE ta4.f1 IN (SELECT /*+ QB_NAME(qb1) */ f1 FROM t4) AND +ta3.f2 IN (SELECT /*+ QB_NAME(qb2) */ f2 FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index f2 f2 5 NULL 3 100.00 Using where; Using index; Start temporary +1 SIMPLE t4 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE ta3 NULL ref f2 f2 5 test.t2.f2 1 100.00 Using index +1 SIMPLE ta4 NULL eq_ref PRIMARY PRIMARY 4 test.t4.f1 1 100.00 Using index; End temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select /*+ JOIN_PREFIX(@`select#1` `t2`@`qb2`,`t4`@`qb1`,`ta3`,`ta4`) */ count(0) AS `COUNT(*)` from `test`.`t1` join `test`.`t2` `ta3` join `test`.`t2` `ta4` semi join (`test`.`t4`) semi join (`test`.`t2`) where ((`test`.`ta3`.`f2` = `test`.`t2`.`f2`) and (`test`.`ta4`.`f1` = `test`.`t4`.`f1`)) +DROP TABLE t1, t2, t4; diff --git a/mysql-test/r/opt_hints_lowercase.result-pq b/mysql-test/r/opt_hints_lowercase.result-pq new file mode 100644 index 000000000000..6205c820b35f --- /dev/null +++ b/mysql-test/r/opt_hints_lowercase.result-pq @@ -0,0 +1,36 @@ +CREATE TABLE t1(f1 INT, f2 INT); +INSERT INTO t1 VALUES +(1,1),(2,2),(3,3); +CREATE TABLE T1 (f1 INT NOT NULL, f2 INT, f3 VARCHAR(32), +PRIMARY KEY(f1), KEY f2_idx(f1), KEY f3_idx(f3)); +INSERT INTO T1 VALUES +(1, 1, 'qwerty'), (2, 1, 'ytrewq'), +(3, 2, 'uiop'), (4, 2, 'poiu'), (5, 2, 'lkjh'), +(6, 2, 'uiop'), (7, 2, 'poiu'), (8, 2, 'lkjh'), +(9, 2, 'uiop'), (10, 2, 'poiu'), (11, 2, 'lkjh'), +(12, 2, 'uiop'), (13, 2, 'poiu'), (14, 2, 'lkjh'); +INSERT INTO T1 SELECT f1 + 20, f2, f3 FROM T1; +INSERT INTO T1 SELECT f1 + 40, f2, f3 FROM T1; +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +ANALYZE TABLE T1; +Table Op Msg_type Msg_text +test.T1 analyze status OK +EXPLAIN SELECT /*+ NO_BNL(t1) */ * FROM t1 t1, T1 T1 WHERE T1.f1 between 1 and 3 +AND t1.f2 = T1.f2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 SIMPLE T1 NULL range PRIMARY,f2_idx PRIMARY 4 NULL 3 10.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select /*+ NO_BNL(`t1`@`select#1`) */ `test`.`t1`.`f1` AS `f1`,`test`.`t1`.`f2` AS `f2`,`test`.`T1`.`f1` AS `f1`,`test`.`T1`.`f2` AS `f2`,`test`.`T1`.`f3` AS `f3` from `test`.`t1` join `test`.`T1` where ((`test`.`T1`.`f2` = `test`.`t1`.`f2`) and (`test`.`T1`.`f1` between 1 and 3)) +EXPLAIN SELECT /*+ NO_BNL(T1) */ * FROM t1 t1, T1 T1 WHERE T1.f1 between 1 and 3 +AND t1.f2 = T1.f2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 SIMPLE T1 NULL range PRIMARY,f2_idx PRIMARY 4 NULL 3 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select /*+ NO_BNL(`T1`@`select#1`) */ `test`.`t1`.`f1` AS `f1`,`test`.`t1`.`f2` AS `f2`,`test`.`T1`.`f1` AS `f1`,`test`.`T1`.`f2` AS `f2`,`test`.`T1`.`f3` AS `f3` from `test`.`t1` join `test`.`T1` where ((`test`.`T1`.`f2` = `test`.`t1`.`f2`) and (`test`.`T1`.`f1` between 1 and 3)) +DROP TABLE t1, T1; diff --git a/mysql-test/r/opt_hints_set_var.result-pq b/mysql-test/r/opt_hints_set_var.result-pq new file mode 100644 index 000000000000..87a328ccf52d --- /dev/null +++ b/mysql-test/r/opt_hints_set_var.result-pq @@ -0,0 +1,925 @@ +CREATE TABLE t1(f1 INT); +SELECT /*+ SET_VAR(foo = 10) */ 1; +1 +1 +Warnings: +Warning 3128 Unresolved name 'foo' for SET_VAR hint +SELECT /*+ SET_VAR(foo = 1K) */ 1; +1 +1 +Warnings: +Warning 3128 Unresolved name 'foo' for SET_VAR hint +SELECT /*+ SET_VAR(foo = 21M) */ 1; +1 +1 +Warnings: +Warning 3128 Unresolved name 'foo' for SET_VAR hint +SELECT /*+ SET_VAR(foo = 321G) */ 1; +1 +1 +Warnings: +Warning 3128 Unresolved name 'foo' for SET_VAR hint +SELECT /*+ SET_VAR(foo = 9000100500G) */ 1; +1 +1 +Warnings: +Warning 1064 A size parameter was incorrectly specified, either number or on the form 10M near '9000100500G) */ 1' at line 1 +SELECT /*+ SET_VAR(foo = 'test') */ 1; +1 +1 +Warnings: +Warning 3128 Unresolved name 'foo' for SET_VAR hint +SELECT /*+ SET_VAR(foo = "test""test") */ 1; +1 +1 +Warnings: +Warning 3128 Unresolved name 'foo' for SET_VAR hint +SELECT /*+ SET_VAR(foo = 900010050018247362846826482468) */ 1; +1 +1 +Warnings: +Warning 1064 A size parameter was incorrectly specified, either number or on the form 10M near '900010050018247362846826482468) */ 1' at line 1 +SELECT /*+ QB_NAME(1KLMN) */ 1; +1 +1 +SELECT /*+ SET_VAR(foo = 900010050018247362846826482468000) */ 1; +1 +1 +Warnings: +Warning 1064 A size parameter was incorrectly specified, either number or on the form 10M near '900010050018247362846826482468000) */ 1' at line 1 +explain SELECT /*+ SET_VAR(optimizer_switch = 'batched_key_access=on') SET_VAR(optimizer_switch = 'batched_key_access=off')*/ * FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Warning 3126 Hint SET_VAR(optimizer_switch='batched_key_access=off') is ignored as conflicting/duplicated +Note 1003 /* select#1 */ select /*+ SET_VAR(optimizer_switch='batched_key_access=on') */ `test`.`t1`.`f1` AS `f1` from `test`.`t1` +explain SELECT /*+ SET_VAR(max_join_size=1) SET_VAR(max_join_size=1) */ * FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Warning 3126 Hint SET_VAR(max_join_size=1) is ignored as conflicting/duplicated +Note 1003 /* select#1 */ select /*+ SET_VAR(max_join_size=1) */ `test`.`t1`.`f1` AS `f1` from `test`.`t1` +explain SELECT /*+ SET_VAR(optimizer_switch = 'batched_key_access=on') +SET_VAR(big_tables=on) +SET_VAR(big_tables=off) */ * FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Warning 3126 Hint SET_VAR(big_tables='off') is ignored as conflicting/duplicated +Note 1003 /* select#1 */ select /*+ SET_VAR(optimizer_switch='batched_key_access=on') SET_VAR(big_tables='on') */ `test`.`t1`.`f1` AS `f1` from `test`.`t1` +explain SELECT /*+ SET_VAR(optimizer_switc = 'batched_key_access=off') */ * FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Warning 3128 Unresolved name 'optimizer_switc' for SET_VAR hint +Note 1003 /* select#1 */ select `test`.`t1`.`f1` AS `f1` from `test`.`t1` +explain SELECT /*+ SET_VAR(optimizer_switch = 'batched_key_access=yes') */ * FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Warning 1231 Variable 'optimizer_switch' can't be set to the value of 'batched_key_access=yes' +Note 1003 /* select#1 */ select `test`.`t1`.`f1` AS `f1` from `test`.`t1` +explain SELECT /*+ SET_VAR(optimizer_switch = 'batched_key_acces=off') */ * FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Warning 1231 Variable 'optimizer_switch' can't be set to the value of 'batched_key_acces=off' +Note 1003 /* select#1 */ select `test`.`t1`.`f1` AS `f1` from `test`.`t1` +explain SELECT /*+ SET_VAR(max_allowed_packet = 1M) */ * FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Warning 3637 Variable 'max_allowed_packet' cannot be set using SET_VAR hint. +Note 1003 /* select#1 */ select `test`.`t1`.`f1` AS `f1` from `test`.`t1` +explain SELECT /*+ SET_VAR(optimizer_switch = 'batched_key_acces=off') SET_VAR(range_alloc_block_size=amba)*/ * FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Warning 1231 Variable 'optimizer_switch' can't be set to the value of 'batched_key_acces=off' +Warning 1232 Incorrect argument type to variable 'range_alloc_block_size' +Note 1003 /* select#1 */ select `test`.`t1`.`f1` AS `f1` from `test`.`t1` +SELECT /*+ SET_VAR(range_alloc_block_size=7000) */ 1; +1 +1 +SHOW WARNINGS LIMIT 1; +Level Code Message +Warning 1292 Truncated incorrect range_alloc_block_size value: '7000' +DROP TABLE t1; +PREPARE stmt FROM "SELECT /*+ SET_VAR(big_tables=on) */ VARIABLE_VALUE FROM performance_schema.session_variables where VARIABLE_NAME = 'big_tables'"; +SELECT VARIABLE_VALUE FROM performance_schema.session_variables where VARIABLE_NAME = 'big_tables'; +VARIABLE_VALUE +OFF +EXECUTE stmt; +VARIABLE_VALUE +ON +SELECT VARIABLE_VALUE FROM performance_schema.session_variables where VARIABLE_NAME = 'big_tables'; +VARIABLE_VALUE +OFF +EXECUTE stmt; +VARIABLE_VALUE +ON +SELECT VARIABLE_VALUE FROM performance_schema.session_variables where VARIABLE_NAME = 'big_tables'; +VARIABLE_VALUE +OFF +DEALLOCATE PREPARE stmt; +CREATE PROCEDURE test_hint (hint_str VARCHAR(255), var_str VARCHAR(64)) +BEGIN +SET @orig_q= CONCAT("SELECT + VARIABLE_VALUE + FROM performance_schema.session_variables where VARIABLE_NAME = '", var_str, "'"); +SET @hint_q= CONCAT("SELECT /*+ ", hint_str, +"*/ VARIABLE_VALUE" , +" FROM performance_schema.session_variables where VARIABLE_NAME = '", var_str, "'"); +PREPARE orig_stmt FROM @orig_q; +PREPARE hint_stmt FROM @hint_q; +EXECUTE orig_stmt; +EXECUTE hint_stmt; +EXECUTE orig_stmt; +DEALLOCATE PREPARE orig_stmt; +DEALLOCATE PREPARE hint_stmt; +END\\ +CREATE TABLE t1 (col INT NOT NULL AUTO_INCREMENT PRIMARY KEY); +INSERT /*+ SET_VAR(auto_increment_increment=10) */ INTO t1 VALUES (NULL), (NULL), (NULL), (NULL); +SELECT * FROM t1; +col +1 +11 +21 +31 +DROP TABLE t1; +CALL test_hint("SET_VAR(auto_increment_increment=10)", "auto_increment_increment"); +VARIABLE_VALUE +1 +VARIABLE_VALUE +10 +VARIABLE_VALUE +1 +CREATE TABLE t1 (col INT NOT NULL AUTO_INCREMENT PRIMARY KEY); +INSERT /*+ SET_VAR(auto_increment_increment=10) SET_VAR(auto_increment_offset=5) */ INTO t1 VALUES (NULL), (NULL), (NULL), (NULL); +SELECT * FROM t1; +col +5 +15 +25 +35 +DROP TABLE t1; +CALL test_hint("SET_VAR(auto_increment_offset=5)", "auto_increment_offset"); +VARIABLE_VALUE +1 +VARIABLE_VALUE +5 +VARIABLE_VALUE +1 +CREATE TABLE t1 (a CHAR PRIMARY KEY); +INSERT INTO t1 VALUES (1),(2); +FLUSH STATUS; +SELECT COUNT(DISTINCT t1.a) FROM t1,t1 t2 WHERE t1.a = 1; +COUNT(DISTINCT t1.a) +1 +SHOW STATUS LIKE '%tmp_disk_tables%'; +Variable_name Value +Created_tmp_disk_tables 0 +FLUSH STATUS; +SELECT /*+ SET_VAR(big_tables=on) */ COUNT(DISTINCT t1.a) FROM t1,t1 t2 WHERE t1.a = 1; +COUNT(DISTINCT t1.a) +1 +SHOW STATUS LIKE '%tmp_disk_tables%'; +Variable_name Value +Created_tmp_disk_tables 1 +DROP TABLE t1; +CALL test_hint("SET_VAR(big_tables=on)", "big_tables"); +VARIABLE_VALUE +OFF +VARIABLE_VALUE +ON +VARIABLE_VALUE +OFF +CALL test_hint("SET_VAR(bulk_insert_buffer_size=0)", "bulk_insert_buffer_size"); +VARIABLE_VALUE +8388608 +VARIABLE_VALUE +0 +VARIABLE_VALUE +8388608 +CREATE TEMPORARY TABLE t1 SELECT 1; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TEMPORARY TABLE `t1` ( + `1` int NOT NULL DEFAULT '0' +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +CREATE TEMPORARY TABLE t2 SELECT /*+ SET_VAR(default_tmp_storage_engine=InnoDB)*/ 1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TEMPORARY TABLE `t2` ( + `1` int NOT NULL DEFAULT '0' +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +DROP TABLE t1, t2; +CALL test_hint("SET_VAR(default_tmp_storage_engine=InnoDB)", "default_tmp_storage_engine"); +VARIABLE_VALUE +InnoDB +VARIABLE_VALUE +InnoDB +VARIABLE_VALUE +InnoDB +SELECT /*+ SET_VAR(div_precision_increment=12) */ 1/2; +1/2 +0.500000000000 +CALL test_hint("SET_VAR(div_precision_increment=12)", "div_precision_increment"); +VARIABLE_VALUE +4 +VARIABLE_VALUE +12 +VARIABLE_VALUE +4 +CALL test_hint("SET_VAR(end_markers_in_json=ON)", "end_markers_in_json"); +VARIABLE_VALUE +OFF +VARIABLE_VALUE +ON +VARIABLE_VALUE +OFF +CALL test_hint("SET_VAR(eq_range_index_dive_limit=0)", "eq_range_index_dive_limit"); +VARIABLE_VALUE +200 +VARIABLE_VALUE +0 +VARIABLE_VALUE +200 +CREATE TABLE t1 +( +id INT PRIMARY KEY +) ENGINE=InnoDB; +CREATE TABLE t2 +( +v INT, +CONSTRAINT c1 FOREIGN KEY (v) REFERENCES t1(id) +) ENGINE=InnoDB; +INSERT /*+ SET_VAR(foreign_key_checks=0) */INTO t2 VALUES(2); +DROP TABLE t2, t1; +CALL test_hint("SET_VAR(foreign_key_checks=0)", "foreign_key_checks"); +VARIABLE_VALUE +ON +VARIABLE_VALUE +OFF +VARIABLE_VALUE +ON +CREATE TABLE t1( a VARCHAR( 10 ), b INT ); +INSERT INTO t1 VALUES ( repeat( 'a', 10 ), 1), +( repeat( 'b', 10 ), 2); +SELECT /*+ SET_VAR(group_concat_max_len=20) */ GROUP_CONCAT(a) FROM t1; +GROUP_CONCAT(a) +aaaaaaaaaa,bbbbbbbbb +Warnings: +Warning 1260 Row 2 was cut by GROUP_CONCAT() +DROP TABLE t1; +CALL test_hint("SET_VAR(group_concat_max_len=20)", "group_concat_max_len"); +VARIABLE_VALUE +1024 +VARIABLE_VALUE +20 +VARIABLE_VALUE +1024 +CREATE TABLE t1 (col INT NOT NULL AUTO_INCREMENT PRIMARY KEY); +INSERT /*+ SET_VAR(insert_id=10) */ INTO t1 VALUES (NULL), (NULL), (NULL), (NULL); +SELECT * FROM t1; +col +10 +11 +12 +13 +DROP TABLE t1; +CALL test_hint("SET_VAR(insert_id=10)", "insert_id"); +VARIABLE_VALUE +0 +VARIABLE_VALUE +10 +VARIABLE_VALUE +0 +CALL test_hint("SET_VAR(join_buffer_size=128)", "join_buffer_size"); +VARIABLE_VALUE +262144 +VARIABLE_VALUE +128 +VARIABLE_VALUE +262144 +CREATE TABLE t1(i INT) ENGINE InnoDB; +LOCK TABLES t1 WRITE; +INSERT /*+ SET_VAR(lock_wait_timeout=1) */INTO t1 VALUES (1); +ERROR HY000: Lock wait timeout exceeded; try restarting transaction +UNLOCK TABLES; +DROP TABLE t1; +CALL test_hint("SET_VAR(lock_wait_timeout=1)", "lock_wait_timeout"); +VARIABLE_VALUE +31536000 +VARIABLE_VALUE +1 +VARIABLE_VALUE +31536000 +CREATE TABLE t1(f1 INT); +EXPLAIN SELECT /*+ SET_VAR(max_error_count=0) SET_VAR(optimizer_switch = 'batched_key_acces=off') SET_VAR(range_alloc_block_size=amba)*/ * FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +DROP TABLE t1; +CALL test_hint("SET_VAR(max_error_count=0)", "max_error_count"); +VARIABLE_VALUE +1024 +VARIABLE_VALUE +0 +VARIABLE_VALUE +1024 +CREATE TABLE t1 (a INT, b VARCHAR(300)); +INSERT INTO t1 VALUES (1, 'string'); +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +SELECT /*+ SET_VAR(max_execution_time=1) */ * FROM t1 a, t1 b; +ERROR HY000: Query execution was interrupted, maximum statement execution time exceeded +DROP TABLE t1; +CALL test_hint("SET_VAR(max_execution_time=1)", "max_execution_time"); +VARIABLE_VALUE +0 +VARIABLE_VALUE +1 +VARIABLE_VALUE +0 +CREATE TABLE t1(f1 CHAR(255) CHARSET utf8); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES('1'),('2'),('3'),('4'),('5'),('6'),('7'),('8'),('9'),('0'); +SET @optimizer_switch_saved= @@optimizer_switch; +SET @@optimizer_switch="derived_merge=off"; +FLUSH STATUS; +SELECT /*+ SET_VAR(max_heap_table_size=16384) SET_VAR(internal_tmp_mem_storage_engine=MEMORY)*/ count(*) +FROM t1 JOIN ( +SELECT t1.f1 FROM t1 JOIN t1 AS t2 JOIN t1 AS t3) tt ON t1.f1 = tt.f1; +count(*) +1000 +SHOW STATUS LIKE 'Handler_write'; +Variable_name Value +Handler_write 1021 +FLUSH STATUS; +SELECT count(*) +FROM t1 JOIN ( +SELECT t1.f1 FROM t1 JOIN t1 AS t2 JOIN t1 AS t3) tt ON t1.f1 = tt.f1; +count(*) +1000 +SHOW STATUS LIKE 'Handler_write'; +Variable_name Value +Handler_write 1000 +SET @@optimizer_switch= @optimizer_switch_saved; +DROP TABLE t1; +CALL test_hint("SET_VAR(max_heap_table_size=16384)", "max_heap_table_size"); +VARIABLE_VALUE +16777216 +VARIABLE_VALUE +16384 +VARIABLE_VALUE +16777216 +CALL test_hint("SET_VAR(internal_tmp_mem_storage_engine=MEMORY)", "internal_tmp_mem_storage_engine"); +VARIABLE_VALUE +TempTable +VARIABLE_VALUE +MEMORY +VARIABLE_VALUE +TempTable +SELECT /*+ SET_VAR(max_points_in_geometry=1048576) */ +st_astext(st_buffer(point(-5,0),8772, st_buffer_strategy( 'point_circle',1024*1024*1024))) as result; +ERROR HY000: Parameter points_per_circle exceeds the maximum number of points in a geometry (1048576) in function st_buffer_strategy. +CALL test_hint("SET_VAR(max_points_in_geometry=1048576)", "max_points_in_geometry"); +VARIABLE_VALUE +65536 +VARIABLE_VALUE +1048576 +VARIABLE_VALUE +65536 +CALL test_hint("SET_VAR(max_seeks_for_key=1)", "max_seeks_for_key"); +VARIABLE_VALUE +DEFAULT +VARIABLE_VALUE +1 +VARIABLE_VALUE +DEFAULT +CREATE TABLE t1 (a INT, b INT, PRIMARY KEY (a)); +CREATE TABLE t2 (a INT, INDEX a (a)); +CREATE TABLE t3 (a INT, b INT, INDEX a (a,b)); +INSERT INTO t1 VALUES (1,10), (2,20), (3,30), (4,40); +INSERT INTO t2 VALUES (2), (3), (4), (5); +INSERT INTO t3 VALUES (10,3), (20,4), (30,5); +ANALYZE TABLE t1, t2, t3; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +EXPLAIN SELECT * FROM t1 JOIN t2 ON t1.b = t2.a WHERE +t2.a IN (SELECT t3.b FROM t3 JOIN t1 t4 ON t3.b = t4.b); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +1 SIMPLE t2 NULL ref a a 5 test.t1.b 1 100.00 Using index +1 SIMPLE NULL eq_ref 5 test.t1.b 1 100.00 NULL +2 MATERIALIZED t3 NULL index NULL a 10 NULL 3 100.00 Using index +2 MATERIALIZED t4 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a` from `test`.`t1` join `test`.`t2` semi join (`test`.`t3` join `test`.`t1` `t4`) where ((`test`.`t2`.`a` = `test`.`t1`.`b`) and (``.`b` = `test`.`t1`.`b`) and (`test`.`t4`.`b` = `test`.`t3`.`b`)) +EXPLAIN SELECT /*+ SET_VAR(optimizer_search_depth=1) */ * FROM t1 JOIN t2 ON t1.b = t2.a WHERE +t2.a IN (SELECT t3.b FROM t3 JOIN t1 t4 ON t3.b = t4.b); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL index NULL a 10 NULL 3 100.00 Using where; Using index; Start temporary +1 SIMPLE t2 NULL ref a a 5 test.t3.b 1 100.00 Using index +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; Using join buffer (hash join) +1 SIMPLE t4 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select /*+ SET_VAR(optimizer_search_depth=1) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a` from `test`.`t1` join `test`.`t2` semi join (`test`.`t3` join `test`.`t1` `t4`) where ((`test`.`t2`.`a` = `test`.`t3`.`b`) and (`test`.`t1`.`b` = `test`.`t3`.`b`) and (`test`.`t4`.`b` = `test`.`t3`.`b`)) +EXPLAIN SELECT /*+ SET_VAR(optimizer_prune_level=0) */ * FROM t1 JOIN t2 ON t1.b = t2.a WHERE +t2.a IN (SELECT t3.b FROM t3 JOIN t1 t4 ON t3.b = t4.b); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using where +1 SIMPLE t2 NULL ref a a 5 .b 1 100.00 Using index +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t3 NULL index NULL a 10 NULL 3 100.00 Using index +2 MATERIALIZED t4 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select /*+ SET_VAR(optimizer_prune_level=0) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a` from `test`.`t1` join `test`.`t2` semi join (`test`.`t3` join `test`.`t1` `t4`) where ((`test`.`t2`.`a` = ``.`b`) and (`test`.`t1`.`b` = ``.`b`) and (`test`.`t4`.`b` = `test`.`t3`.`b`)) +CALL test_hint("SET_VAR(optimizer_search_depth=1)", "optimizer_search_depth"); +VARIABLE_VALUE +62 +VARIABLE_VALUE +1 +VARIABLE_VALUE +62 +CALL test_hint("SET_VAR(optimizer_prune_level=0)", "optimizer_prune_level"); +VARIABLE_VALUE +1 +VARIABLE_VALUE +0 +VARIABLE_VALUE +1 +DROP TABLE t1, t2, t3; +CREATE TABLE t1 +( +f1 int NOT NULL DEFAULT '0', +f2 int NOT NULL DEFAULT '0', +f3 int NOT NULL DEFAULT '0', +INDEX idx1(f2, f3), INDEX idx2(f3) +); +INSERT INTO t1(f1) VALUES (1), (2), (3), (4), (5), (6), (7), (8); +INSERT INTO t1(f2, f3) VALUES (3,4), (3,4); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +set optimizer_switch='mrr=on,mrr_cost_based=off'; +# Check statistics without hint +FLUSH STATUS; +SELECT * FROM t1 WHERE f2 <= 3 AND 3 <= f3; +f1 f2 f3 +0 3 4 +0 3 4 +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 2 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 3 +# Check statistics with hint +FLUSH STATUS; +SELECT /*+ SET_VAR(optimizer_switch='mrr=off') */ * FROM t1 WHERE f2 <= 3 AND 3 <= f3; +f1 f2 f3 +0 3 4 +0 3 4 +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 2 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 3 +set optimizer_switch=default; +DROP TABLE t1; +CALL test_hint("SET_VAR(optimizer_switch='mrr=off')", "optimizer_switch"); +VARIABLE_VALUE +index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,engine_condition_pushdown=on,index_condition_pushdown=on,mrr=on,mrr_cost_based=on,block_nested_loop=on,batched_key_access=off,materialization=on,semijoin=on,loosescan=on,firstmatch=on,duplicateweedout=on,subquery_materialization_cost_based=on,use_index_extensions=on,condition_fanout_filter=on,derived_merge=on,use_invisible_indexes=off,skip_scan=on,hash_join=on,subquery_to_derived=off,prefer_ordering_index=on,hypergraph_optimizer=off,derived_condition_pushdown=on +VARIABLE_VALUE +index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,engine_condition_pushdown=on,index_condition_pushdown=on,mrr=off,mrr_cost_based=on,block_nested_loop=on,batched_key_access=off,materialization=on,semijoin=on,loosescan=on,firstmatch=on,duplicateweedout=on,subquery_materialization_cost_based=on,use_index_extensions=on,condition_fanout_filter=on,derived_merge=on,use_invisible_indexes=off,skip_scan=on,hash_join=on,subquery_to_derived=off,prefer_ordering_index=on,hypergraph_optimizer=off,derived_condition_pushdown=on +VARIABLE_VALUE +index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,engine_condition_pushdown=on,index_condition_pushdown=on,mrr=on,mrr_cost_based=on,block_nested_loop=on,batched_key_access=off,materialization=on,semijoin=on,loosescan=on,firstmatch=on,duplicateweedout=on,subquery_materialization_cost_based=on,use_index_extensions=on,condition_fanout_filter=on,derived_merge=on,use_invisible_indexes=off,skip_scan=on,hash_join=on,subquery_to_derived=off,prefer_ordering_index=on,hypergraph_optimizer=off,derived_condition_pushdown=on +CALL test_hint("SET_VAR(range_alloc_block_size=8192)", "range_alloc_block_size"); +VARIABLE_VALUE +4096 +VARIABLE_VALUE +8192 +VARIABLE_VALUE +4096 +CREATE TABLE t1 (f1 INT, KEY(f1)); +INSERT INTO t1 VALUES (1), (2), (3), (4), (5), (6), (7); +SELECT /*+ SET_VAR(range_optimizer_max_mem_size=1) */ f1 FROM t1 WHERE f1 = 1 OR f1 = 2 OR f1 = 6; +f1 +1 +2 +6 +Warnings: +Warning 3170 Memory capacity of 1 bytes for 'range_optimizer_max_mem_size' exceeded. Range optimization was not done for this query. +DROP TABLE t1; +CALL test_hint("SET_VAR(range_optimizer_max_mem_size=1)", "range_optimizer_max_mem_size"); +VARIABLE_VALUE +8388608 +VARIABLE_VALUE +1 +VARIABLE_VALUE +8388608 +CALL test_hint("SET_VAR(read_buffer_size=8200)", "read_buffer_size"); +VARIABLE_VALUE +131072 +VARIABLE_VALUE +8192 +VARIABLE_VALUE +131072 +CALL test_hint("SET_VAR(read_rnd_buffer_size=1)", "read_rnd_buffer_size"); +VARIABLE_VALUE +262144 +VARIABLE_VALUE +1 +VARIABLE_VALUE +262144 +CREATE TABLE t1 (f1 CHAR(255)); +INSERT INTO t1 VALUES ('aaa'), ('bbb'), ('ccc'), ('ddd'), ('eee'); +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +FLUSH STATUS; +SELECT /*+ SET_VAR(sort_buffer_size=32768) */f1 FROM t1 ORDER BY f1; +SHOW STATUS LIKE 'Sort_merge_passes'; +Variable_name Value +Sort_merge_passes 0 +FLUSH STATUS; +SELECT f1 FROM t1 ORDER BY f1; +SHOW STATUS LIKE 'Sort_merge_passes'; +Variable_name Value +Sort_merge_passes 0 +DROP TABLE t1; +CALL test_hint("SET_VAR(sort_buffer_size=32768)", "sort_buffer_size"); +VARIABLE_VALUE +262144 +VARIABLE_VALUE +32768 +VARIABLE_VALUE +262144 +CREATE TABLE t1 (a INT AUTO_INCREMENT PRIMARY KEY); +SET insert_id = 1; +INSERT INTO t1 VALUES (NULL); +SET insert_id = 0; +SELECT /*+ SET_VAR(sql_auto_is_null=1) */ a FROM t1 WHERE a IS NULL; +a +1 +DROP TABLE t1; +CALL test_hint("SET_VAR(sql_auto_is_null=1)", "sql_auto_is_null"); +VARIABLE_VALUE +OFF +VARIABLE_VALUE +ON +VARIABLE_VALUE +OFF +CREATE TABLE t1 (a INT, b VARCHAR(300)); +INSERT INTO t1 VALUES (1, 'string'); +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +SELECT /*+ SET_VAR(sql_big_selects=0) SET_VAR(max_join_size=1) */ * FROM t1 a, t1 b; +ERROR 42000: The SELECT would examine more than MAX_JOIN_SIZE rows; check your WHERE and use SET SQL_BIG_SELECTS=1 or SET MAX_JOIN_SIZE=# if the SELECT is okay +DROP TABLE t1; +CALL test_hint("SET_VAR(sql_big_selects=0)", "sql_big_selects"); +VARIABLE_VALUE +ON +VARIABLE_VALUE +OFF +VARIABLE_VALUE +ON +CALL test_hint("SET_VAR(max_join_size=1)", "max_join_size"); +VARIABLE_VALUE +18446744073709551615 +VARIABLE_VALUE +1 +VARIABLE_VALUE +18446744073709551615 +CREATE TABLE t1 ( +a int, +b varchar(1), +KEY (b,a) +) charset utf8mb4; +INSERT INTO t1 VALUES (1,NULL),(0,'a'),(1,NULL),(0,'a'); +INSERT INTO t1 VALUES (1,'a'),(0,'a'),(1,'a'),(0,'a'); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT /*+ SET_VAR(sql_buffer_result=1) */ MIN(a), b FROM t1 WHERE t1.b = 'a' GROUP BY b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range b b 12 NULL 2 100.00 Using where; Using index for group-by; Using temporary +Warnings: +Note 1003 /* select#1 */ select /*+ SET_VAR(sql_buffer_result=1) */ sql_buffer_result min(`test`.`t1`.`a`) AS `MIN(a)`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (`test`.`t1`.`b` = 'a') group by `test`.`t1`.`b` +DROP TABLE t1; +CALL test_hint("SET_VAR(sql_buffer_result=1)", "sql_buffer_result"); +VARIABLE_VALUE +OFF +VARIABLE_VALUE +ON +VARIABLE_VALUE +OFF +CREATE TABLE t1 (f1 DATE); +INSERT /*+ SET_VAR(sql_mode='ALLOW_INVALID_DATES') */ INTO t1 VALUES ('00-00-00'); +DROP TABLE t1; +CALL test_hint("SET_VAR(sql_mode='ALLOW_INVALID_DATES')", "sql_mode"); +VARIABLE_VALUE +ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION +VARIABLE_VALUE +ALLOW_INVALID_DATES +VARIABLE_VALUE +ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION +CREATE TABLE t1 ( a INT, KEY( a ) ); +INSERT INTO t1 VALUES (0), (1); +CREATE VIEW v1 AS SELECT t11.a, t12.a AS b FROM t1 t11, t1 t12; +UPDATE /*+ SET_VAR(sql_safe_updates=1) */ IGNORE v1 SET a = 1; +ERROR HY000: You are using safe update mode and you tried to update a table without a WHERE that uses a KEY column. +DROP TABLE t1; +DROP VIEW v1; +CALL test_hint("SET_VAR(sql_safe_updates=1)", "sql_safe_updates"); +VARIABLE_VALUE +OFF +VARIABLE_VALUE +ON +VARIABLE_VALUE +OFF +CREATE TABLE t1 (f1 INT); +INSERT INTO t1 VALUES (1), (2); +SELECT /*+ SET_VAR(sql_select_limit=1) */* FROM t1; +f1 +1 +DROP TABLE t1; +CALL test_hint("SET_VAR(sql_select_limit=1)", "sql_select_limit"); +VARIABLE_VALUE +18446744073709551615 +VARIABLE_VALUE +1 +VARIABLE_VALUE +18446744073709551615 +SELECT /*+ SET_VAR(timestamp=1322115328) */ CAST(UNIX_TIMESTAMP() AS TIME); +CAST(UNIX_TIMESTAMP() AS TIME) +NULL +Warnings: +Warning 1292 Truncated incorrect time value: '1322115328' +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1),(2),(3),(4),(5),(6),(7),(8); +INSERT INTO t1 SELECT a+8 FROM t1; +INSERT INTO t1 SELECT a+16 FROM t1; +INSERT INTO t1 SELECT a+32 FROM t1; +INSERT INTO t1 SELECT a+64 FROM t1; +INSERT INTO t1 VALUE(NULL); +FLUSH STATUS; +SELECT /*+ SET_VAR(tmp_table_size=1024) */ COUNT(DISTINCT a) FROM t1; +COUNT(DISTINCT a) +128 +SHOW STATUS LIKE 'Created_tmp_files'; +Variable_name Value +Created_tmp_files 1 +DROP TABLE t1; +CALL test_hint("SET_VAR(tmp_table_size=1024)", "tmp_table_size"); +VARIABLE_VALUE +16777216 +VARIABLE_VALUE +1024 +VARIABLE_VALUE +16777216 +CALL test_hint("SET_VAR(updatable_views_with_limit=NO)", "updatable_views_with_limit"); +VARIABLE_VALUE +YES +VARIABLE_VALUE +NO +VARIABLE_VALUE +YES +CALL test_hint("SET_VAR(unique_checks=OFF)", "unique_checks"); +VARIABLE_VALUE +ON +VARIABLE_VALUE +OFF +VARIABLE_VALUE +ON +CREATE TABLE t1 (d DOUBLE, id INT, sex CHAR(1), n INT NOT NULL AUTO_INCREMENT, PRIMARY KEY(n)); +INSERT INTO t1(d, id, sex) VALUES (1.0, 1, 'M'), +(2.0, 2, 'F'), +(3.0, 3, 'F'), +(4.0, 4, 'F'), +(5.0, 5, 'M'), +(NULL, NULL, 'M'), +(10.0, 10, NULL), +(10.0, 10, NULL), +(11.0, 11, NULL); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN FORMAT=JSON SELECT +id, AVG(id) over w `avg`, SUM(id) OVER w `sum`, COUNT(*) OVER w cnt +FROM t1 WINDOW w as (ORDER BY id RANGE BETWEEN 1 FOLLOWING AND 2 FOLLOWING); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "10.15" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`id`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "avg", + "sum", + "count" + ] + } + ], + "cost_info": { + "sort_cost": "9.00" + }, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 9, + "rows_produced_per_join": 9, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.90", + "prefix_cost": "1.15", + "data_read_per_join": "216" + }, + "used_columns": [ + "id", + "n" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,avg(`test`.`t1`.`id`) OVER `w` AS `avg`,sum(`test`.`t1`.`id`) OVER `w` AS `sum`,count(0) OVER `w` AS `cnt` from `test`.`t1` window `w` AS (ORDER BY `test`.`t1`.`id` RANGE BETWEEN 1 FOLLOWING AND 2 FOLLOWING) +EXPLAIN FORMAT=JSON SELECT /*+ SET_VAR(windowing_use_high_precision=OFF)*/ +d, AVG(d) over w `avg`, SUM(d) OVER w `sum`, COUNT(*) OVER w cnt +FROM t1 WINDOW w as (ORDER BY d RANGE BETWEEN 1 FOLLOWING AND 2 FOLLOWING); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "10.15" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`d`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "avg", + "sum", + "count" + ] + } + ], + "cost_info": { + "sort_cost": "9.00" + }, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 9, + "rows_produced_per_join": 9, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.90", + "prefix_cost": "1.15", + "data_read_per_join": "216" + }, + "used_columns": [ + "d", + "n" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select /*+ SET_VAR(windowing_use_high_precision='OFF') */ `test`.`t1`.`d` AS `d`,avg(`test`.`t1`.`d`) OVER `w` AS `avg`,sum(`test`.`t1`.`d`) OVER `w` AS `sum`,count(0) OVER `w` AS `cnt` from `test`.`t1` window `w` AS (ORDER BY `test`.`t1`.`d` RANGE BETWEEN 1 FOLLOWING AND 2 FOLLOWING) +DROP TABLE t1; +CALL test_hint("SET_VAR(windowing_use_high_precision=OFF)", "windowing_use_high_precision"); +VARIABLE_VALUE +ON +VARIABLE_VALUE +OFF +VARIABLE_VALUE +ON +WITH RECURSIVE qn AS ( +SELECT 1 AS a UNION ALL +SELECT 1+a FROM qn WHERE a<=10) +SELECT /*+ SET_VAR(cte_max_recursion_depth=5) */ COUNT(*) FROM qn; +ERROR HY000: Recursive query aborted after 6 iterations. Try increasing @@cte_max_recursion_depth to a larger value. +CALL test_hint("SET_VAR(cte_max_recursion_depth=5)", "cte_max_recursion_depth"); +VARIABLE_VALUE +1000 +VARIABLE_VALUE +5 +VARIABLE_VALUE +1000 +DROP PROCEDURE test_hint; +# +# Bug#26482684 WL681: RESULT DIFF SEEN FOR SQL_SELECT_LIMIT HINT. +# +SELECT /*+ SET_VAR(sql_select_limit = 18446744073709551616) */ 1; +1 +1 +Warnings: +Warning 1064 A size parameter was incorrectly specified, either number or on the form 10M near '18446744073709551616) */ 1' at line 1 +SELECT /*+ SET_VAR(sql_select_limit = 18446744073709551615) */ 1; +1 +1 +# +# Bug#29776464 MAKE 'TIME_ZONE' VARIABLE OPTIMIZER HINT SETTABLE. +# +SET time_zone = '-01:00'; +SELECT TIMEDIFF(NOW(), UTC_TIMESTAMP); +TIMEDIFF(NOW(), UTC_TIMESTAMP) +-01:00:00 +SELECT /*+ SET_VAR(time_zone = '+04:00') */ TIMEDIFF(NOW(), UTC_TIMESTAMP); +TIMEDIFF(NOW(), UTC_TIMESTAMP) +04:00:00 +SELECT @@time_zone; +@@time_zone +-01:00 +SELECT /*+ SET_VAR(time_zone = 'UTC') */ TIMEDIFF(NOW(), UTC_TIMESTAMP); +TIMEDIFF(NOW(), UTC_TIMESTAMP) +00:00:00 +SELECT @@time_zone; +@@time_zone +-01:00 +CREATE TABLE t1(f1 VARCHAR(10)); +INSERT INTO t1 VALUES (@@time_zone); +SELECT * FROM t1; +f1 +-01:00 +UPDATE /*+ SET_VAR(time_zone = 'UTC') */ t1 SET f1 = TIMEDIFF(NOW(), UTC_TIMESTAMP); +SELECT * FROM t1; +f1 +00:00:00 +INSERT /*+ SET_VAR(time_zone = 'UTC') */ t1 VALUES (TIMEDIFF(NOW(), UTC_TIMESTAMP)); +SELECT * FROM t1; +f1 +00:00:00 +00:00:00 +DELETE /*+ SET_VAR(time_zone = 'UTC') */ FROM t1 WHERE f1 = TIMEDIFF(NOW(), UTC_TIMESTAMP); +SELECT * FROM t1; +f1 +SELECT @@time_zone; +@@time_zone +-01:00 +DROP TABLE t1; +SET time_zone = default; diff --git a/mysql-test/r/opt_hints_subquery.result-pq b/mysql-test/r/opt_hints_subquery.result-pq new file mode 100644 index 000000000000..fefd6616464a --- /dev/null +++ b/mysql-test/r/opt_hints_subquery.result-pq @@ -0,0 +1,1885 @@ +# WL#8244 Hints for subquery execution +CREATE TABLE t1 (a INTEGER NOT NULL, b INT, PRIMARY KEY (a)); +CREATE TABLE t2 (a INTEGER NOT NULL, KEY (a)); +CREATE TABLE t3 (a INTEGER NOT NULL, b INT, KEY (a)); +INSERT INTO t1 VALUES (1,10), (2,20), (3,30), (4,40); +INSERT INTO t2 VALUES (2), (3), (4), (5); +INSERT INTO t3 VALUES (10,3), (20,4), (30,5); +ANALYZE TABLE t1, t2, t3; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +This query will normally use Table Pull-out +EXPLAIN +SELECT * FROM t2 WHERE t2.a IN (SELECT a FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL index a a 4 NULL 4 100.00 Using index +2 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t1` join `test`.`t2` where (`test`.`t1`.`a` = `test`.`t2`.`a`) +Check that we can disable SEMIJOIN transformation +EXPLAIN +SELECT * FROM t2 WHERE t2.a IN (SELECT /*+ NO_SEMIJOIN() */ a FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t2 NULL index NULL a 4 NULL 4 100.00 Using where; Using index +2 DEPENDENT SUBQUERY t1 NULL unique_subquery PRIMARY PRIMARY 4 func 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select /*+ NO_SEMIJOIN(@`select#2`) */ `test`.`t2`.`a` AS `a` from `test`.`t2` where (`test`.`t2`.`a`,(((`test`.`t2`.`a`) in t1 on PRIMARY))) +Same with hint in outer query +EXPLAIN +SELECT /*+ NO_SEMIJOIN(@subq) */ * FROM t2 +WHERE t2.a IN (SELECT /*+ QB_NAME(subq) */ a FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t2 NULL index NULL a 4 NULL 4 100.00 Using where; Using index +2 DEPENDENT SUBQUERY t1 NULL unique_subquery PRIMARY PRIMARY 4 func 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select /*+ NO_SEMIJOIN(@`subq`) */ `test`.`t2`.`a` AS `a` from `test`.`t2` where (`test`.`t2`.`a`,(((`test`.`t2`.`a`) in t1 on PRIMARY))) +Query with two sub-queries +EXPLAIN +SELECT * FROM t3 +WHERE t3.a IN (SELECT a FROM t1 tx) +AND t3.b IN (SELECT a FROM t1 ty); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t3 NULL ALL a NULL NULL NULL 3 100.00 Using where +2 SIMPLE tx NULL eq_ref PRIMARY PRIMARY 4 test.t3.a 1 100.00 Using index +2 SIMPLE ty NULL eq_ref PRIMARY PRIMARY 4 test.t3.b 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b` from `test`.`t1` `tx` join `test`.`t1` `ty` join `test`.`t3` where ((`test`.`ty`.`a` = `test`.`t3`.`b`) and (`test`.`tx`.`a` = `test`.`t3`.`a`)) +No SEMIJOIN transformation for first subquery +EXPLAIN +SELECT * FROM t3 +WHERE t3.a IN (SELECT /*+ NO_SEMIJOIN() */ a FROM t1 tx) +AND t3.b IN (SELECT a FROM t1 ty); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t3 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 PRIMARY ty NULL eq_ref PRIMARY PRIMARY 4 test.t3.b 1 100.00 Using index +2 DEPENDENT SUBQUERY tx NULL unique_subquery PRIMARY PRIMARY 4 func 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select /*+ NO_SEMIJOIN(@`select#2`) */ `test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b` from `test`.`t1` `ty` join `test`.`t3` where ((`test`.`ty`.`a` = `test`.`t3`.`b`) and (`test`.`t3`.`a`,(((`test`.`t3`.`a`) in t1 on PRIMARY)))) +EXPLAIN +SELECT /*+ NO_SEMIJOIN(@subq1) */ * FROM t3 +WHERE t3.a IN (SELECT /*+ QB_NAME(`subq1`) */ a FROM t1 tx) +AND t3.b IN (SELECT /*+ QB_NAME(subq2) */ a FROM t1 ty); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t3 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 PRIMARY ty NULL eq_ref PRIMARY PRIMARY 4 test.t3.b 1 100.00 Using index +2 DEPENDENT SUBQUERY tx NULL unique_subquery PRIMARY PRIMARY 4 func 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select /*+ NO_SEMIJOIN(@`subq1`) */ `test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b` from `test`.`t1` `ty` join `test`.`t3` where ((`test`.`ty`.`a` = `test`.`t3`.`b`) and (`test`.`t3`.`a`,(((`test`.`t3`.`a`) in t1 on PRIMARY)))) +No SEMIJOIN transformation for latter subquery +EXPLAIN +SELECT * FROM t3 +WHERE t3.a IN (SELECT a FROM t1 tx) +AND t3.b IN (SELECT /*+ NO_SEMIJOIN() */ a FROM t1 ty); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t3 NULL ALL a NULL NULL NULL 3 100.00 Using where +1 PRIMARY tx NULL eq_ref PRIMARY PRIMARY 4 test.t3.a 1 100.00 Using index +3 DEPENDENT SUBQUERY ty NULL unique_subquery PRIMARY PRIMARY 4 func 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select /*+ NO_SEMIJOIN(@`select#3`) */ `test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b` from `test`.`t1` `tx` join `test`.`t3` where ((`test`.`tx`.`a` = `test`.`t3`.`a`) and (`test`.`t3`.`b`,(((`test`.`t3`.`b`) in t1 on PRIMARY)))) +EXPLAIN +SELECT /*+ NO_SEMIJOIN(@`subq2`) */ * FROM t3 +WHERE t3.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t1 tx) +AND t3.b IN (SELECT /*+ QB_NAME(subq2) */ a FROM t1 ty); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t3 NULL ALL a NULL NULL NULL 3 100.00 Using where +1 PRIMARY tx NULL eq_ref PRIMARY PRIMARY 4 test.t3.a 1 100.00 Using index +3 DEPENDENT SUBQUERY ty NULL unique_subquery PRIMARY PRIMARY 4 func 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select /*+ NO_SEMIJOIN(@`subq2`) */ `test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b` from `test`.`t1` `tx` join `test`.`t3` where ((`test`.`tx`.`a` = `test`.`t3`.`a`) and (`test`.`t3`.`b`,(((`test`.`t3`.`b`) in t1 on PRIMARY)))) +No SEMIJOIN transformation for any subquery +EXPLAIN +SELECT * FROM t3 +WHERE t3.a IN (SELECT /*+ NO_SEMIJOIN() */ a FROM t1 tx) +AND t3.b IN (SELECT /*+ NO_SEMIJOIN() */ a FROM t1 ty); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t3 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +3 DEPENDENT SUBQUERY ty NULL unique_subquery PRIMARY PRIMARY 4 func 1 100.00 Using index +2 DEPENDENT SUBQUERY tx NULL unique_subquery PRIMARY PRIMARY 4 func 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select /*+ NO_SEMIJOIN(@`select#2`) NO_SEMIJOIN(@`select#3`) */ `test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b` from `test`.`t3` where ((`test`.`t3`.`a`,(((`test`.`t3`.`a`) in t1 on PRIMARY))) and (`test`.`t3`.`b`,(((`test`.`t3`.`b`) in t1 on PRIMARY)))) +EXPLAIN +SELECT /*+ NO_SEMIJOIN(@subq1) NO_SEMIJOIN(@subq2) */ * FROM t3 +WHERE t3.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t1 tx) +AND t3.b IN (SELECT /*+ QB_NAME(subq2) */ a FROM t1 ty); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t3 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +3 DEPENDENT SUBQUERY ty NULL unique_subquery PRIMARY PRIMARY 4 func 1 100.00 Using index +2 DEPENDENT SUBQUERY tx NULL unique_subquery PRIMARY PRIMARY 4 func 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select /*+ NO_SEMIJOIN(@`subq1`) NO_SEMIJOIN(@`subq2`) */ `test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b` from `test`.`t3` where ((`test`.`t3`.`a`,(((`test`.`t3`.`a`) in t1 on PRIMARY))) and (`test`.`t3`.`b`,(((`test`.`t3`.`b`) in t1 on PRIMARY)))) +Query with nested sub-queries +EXPLAIN +SELECT * FROM t3 +WHERE t3.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t1 tx +WHERE tx.b IN (SELECT /*+ QB_NAME(subq2) */ a FROM t1 ty)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t3 NULL ALL a NULL NULL NULL 3 100.00 NULL +2 SIMPLE tx NULL eq_ref PRIMARY PRIMARY 4 test.t3.a 1 100.00 Using where +2 SIMPLE ty NULL eq_ref PRIMARY PRIMARY 4 test.tx.b 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b` from `test`.`t1` `tx` join `test`.`t1` `ty` join `test`.`t3` where ((`test`.`tx`.`a` = `test`.`t3`.`a`) and (`test`.`ty`.`a` = `test`.`tx`.`b`)) +No SEMIJOIN transformation for outer subquery +EXPLAIN +SELECT /*+ NO_SEMIJOIN(@subq1) */ * FROM t3 +WHERE t3.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t1 tx +WHERE tx.b IN (SELECT /*+ QB_NAME(subq2) */ a FROM t1 ty)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t3 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY tx NULL eq_ref PRIMARY PRIMARY 4 func 1 100.00 Using where +2 DEPENDENT SUBQUERY ty NULL eq_ref PRIMARY PRIMARY 4 test.tx.b 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select /*+ NO_SEMIJOIN(@`subq1`) */ `test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b` from `test`.`t3` where (`test`.`t3`.`a`,(/* select#2 */ select /*+ QB_NAME(`subq1`) */ `test`.`tx`.`a` from `test`.`t1` `ty` join `test`.`t1` `tx` where ((`test`.`ty`.`a` = `test`.`tx`.`b`) and ((`test`.`t3`.`a`) = `test`.`tx`.`a`)))) +No SEMIJOIN transformation for inner-most subquery +EXPLAIN +SELECT /*+ NO_SEMIJOIN(@subq2) */ * FROM t3 +WHERE t3.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t1 tx +WHERE tx.b IN (SELECT /*+ QB_NAME(subq2) */ a FROM t1 ty)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t3 NULL ALL a NULL NULL NULL 3 100.00 NULL +1 PRIMARY tx NULL eq_ref PRIMARY PRIMARY 4 test.t3.a 1 100.00 Using where +3 DEPENDENT SUBQUERY ty NULL unique_subquery PRIMARY PRIMARY 4 func 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select /*+ NO_SEMIJOIN(@`subq2`) */ `test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b` from `test`.`t1` `tx` join `test`.`t3` where ((`test`.`tx`.`a` = `test`.`t3`.`a`) and (`test`.`tx`.`b`,(((`test`.`tx`.`b`) in t1 on PRIMARY)))) +No SEMIJOIN transformation at all +EXPLAIN +SELECT /*+ NO_SEMIJOIN(@subq1) NO_SEMIJOIN(@subq2) */ * FROM t3 +WHERE t3.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t1 tx +WHERE tx.b IN (SELECT /*+ QB_NAME(subq2) */ a FROM t1 ty)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t3 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY tx NULL unique_subquery PRIMARY PRIMARY 4 func 1 100.00 Using where +3 DEPENDENT SUBQUERY ty NULL unique_subquery PRIMARY PRIMARY 4 func 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select /*+ NO_SEMIJOIN(@`subq2`) NO_SEMIJOIN(@`subq1`) */ `test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b` from `test`.`t3` where (`test`.`t3`.`a`,(((`test`.`t3`.`a`) in t1 on PRIMARY where (`test`.`tx`.`b`,(((`test`.`tx`.`b`) in t1 on PRIMARY)))))) +This query does not support SEMIJOIN. SEMIJOIN hint is ignored +EXPLAIN +SELECT /*+ SEMIJOIN(@subq) */ * FROM t2 +WHERE t2.a IN (SELECT /*+ QB_NAME(subq) */ min(a) FROM t1 group by a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t2 NULL index NULL a 4 NULL 4 100.00 Using where; Using index +2 SUBQUERY t1 NULL index PRIMARY PRIMARY 4 NULL 4 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select /*+ SEMIJOIN(@`subq`) */ `test`.`t2`.`a` AS `a` from `test`.`t2` where (`test`.`t2`.`a`,`test`.`t2`.`a` in ( (/* select#2 */ select /*+ QB_NAME(`subq`) */ min(`test`.`t1`.`a`) from `test`.`t1` group by `test`.`t1`.`a` having true ), (`test`.`t2`.`a` in on where ((`test`.`t2`.`a` = ``.`min(a)`))))) +This query will get LooseScan by default +EXPLAIN +SELECT * FROM t2 WHERE t2.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL index a a 4 NULL 3 100.00 Using index; LooseScan +1 SIMPLE t2 NULL ref a a 4 test.t3.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t3`) where (`test`.`t2`.`a` = `test`.`t3`.`a`) +Let's turn off LooseScan, FirstMatch is then SELECTed +EXPLAIN +SELECT /*+ NO_SEMIJOIN(@subq1 LOOSESCAN) */ * FROM t2 +WHERE t2.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL index a a 4 NULL 4 100.00 Using index +2 SIMPLE t3 NULL ref a a 4 test.t2.a 1 100.00 Using index; FirstMatch(t2) +Warnings: +Note 1003 /* select#1 */ select /*+ NO_SEMIJOIN(@`subq1` LOOSESCAN) */ `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t3`) where (`test`.`t3`.`a` = `test`.`t2`.`a`) +Let's also turn off FirstMatch, MatLookup is then used +EXPLAIN +SELECT /*+ NO_SEMIJOIN(@subq1 FIRSTMATCH, LOOSESCAN) */ * FROM t2 +WHERE t2.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index a a 4 NULL 4 100.00 Using index +1 SIMPLE NULL eq_ref 4 test.t2.a 1 100.00 NULL +2 MATERIALIZED t3 NULL index a a 4 NULL 3 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select /*+ NO_SEMIJOIN(@`subq1` FIRSTMATCH, LOOSESCAN) */ `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t3`) where (``.`a` = `test`.`t2`.`a`) +Let's also turn off Materialization, DuplicateWeedout should then be used +EXPLAIN +SELECT /*+ NO_SEMIJOIN(@subq1 FIRSTMATCH, LOOSESCAN, MATERIALIZATION) */ * +FROM t2 +WHERE t2.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL index a a 4 NULL 3 100.00 Using index; Start temporary +1 SIMPLE t2 NULL ref a a 4 test.t3.a 1 100.00 Using index; End temporary +Warnings: +Note 1003 /* select#1 */ select /*+ NO_SEMIJOIN(@`subq1` FIRSTMATCH, LOOSESCAN, MATERIALIZATION) */ `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t3`) where (`test`.`t2`.`a` = `test`.`t3`.`a`) +If we turn off all strategies, DuplicateWeedout should still be used +EXPLAIN +SELECT /*+ NO_SEMIJOIN(@subq1 FIRSTMATCH, LOOSESCAN, MATERIALIZATION, +DUPSWEEDOUT) */ * +FROM t2 +WHERE t2.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL index a a 4 NULL 3 100.00 Using index; Start temporary +1 SIMPLE t2 NULL ref a a 4 test.t3.a 1 100.00 Using index; End temporary +Warnings: +Note 1003 /* select#1 */ select /*+ NO_SEMIJOIN(@`subq1` FIRSTMATCH, LOOSESCAN, MATERIALIZATION, DUPSWEEDOUT) */ `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t3`) where (`test`.`t2`.`a` = `test`.`t3`.`a`) +Turn off non-used strategies, nothing should change. Still Loosescan +EXPLAIN +SELECT /*+ NO_SEMIJOIN(@subq1 FIRSTMATCH, MATERIALIZATION, DUPSWEEDOUT) */ * +FROM t2 +WHERE t2.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL index a a 4 NULL 3 100.00 Using index; LooseScan +1 SIMPLE t2 NULL ref a a 4 test.t3.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select /*+ NO_SEMIJOIN(@`subq1` FIRSTMATCH, MATERIALIZATION, DUPSWEEDOUT) */ `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t3`) where (`test`.`t2`.`a` = `test`.`t3`.`a`) +Test same query with SEMIJOIN hint +Forcing LooseScan, should not change anything +EXPLAIN +SELECT /*+ SEMIJOIN(@subq1 LOOSESCAN) */ * FROM t2 +WHERE t2.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL index a a 4 NULL 3 100.00 Using index; LooseScan +1 SIMPLE t2 NULL ref a a 4 test.t3.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select /*+ SEMIJOIN(@`subq1` LOOSESCAN) */ `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t3`) where (`test`.`t2`.`a` = `test`.`t3`.`a`) +Force FirstMatch +EXPLAIN +SELECT /*+ SEMIJOIN(@subq1 FIRSTMATCH) */ * FROM t2 +WHERE t2.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL index a a 4 NULL 4 100.00 Using index +2 SIMPLE t3 NULL ref a a 4 test.t2.a 1 100.00 Using index; FirstMatch(t2) +Warnings: +Note 1003 /* select#1 */ select /*+ SEMIJOIN(@`subq1` FIRSTMATCH) */ `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t3`) where (`test`.`t3`.`a` = `test`.`t2`.`a`) +Force Materialization +EXPLAIN +SELECT /*+ SEMIJOIN(@subq1 MATERIALIZATION) */ * FROM t2 +WHERE t2.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index a a 4 NULL 4 100.00 Using index +1 SIMPLE NULL eq_ref 4 test.t2.a 1 100.00 NULL +2 MATERIALIZED t3 NULL index a a 4 NULL 3 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select /*+ SEMIJOIN(@`subq1` MATERIALIZATION) */ `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t3`) where (``.`a` = `test`.`t2`.`a`) +Force DuplicateWeedout +EXPLAIN +SELECT /*+ SEMIJOIN(@subq1 DUPSWEEDOUT) */ * FROM t2 +WHERE t2.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL index a a 4 NULL 3 100.00 Using index; Start temporary +1 SIMPLE t2 NULL ref a a 4 test.t3.a 1 100.00 Using index; End temporary +Warnings: +Note 1003 /* select#1 */ select /*+ SEMIJOIN(@`subq1` DUPSWEEDOUT) */ `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t3`) where (`test`.`t2`.`a` = `test`.`t3`.`a`) +If LooseScan is among candidates, it will be used +EXPLAIN +SELECT /*+ SEMIJOIN(@subq1 LOOSESCAN, DUPSWEEDOUT) */ * FROM t2 +WHERE t2.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL index a a 4 NULL 3 100.00 Using index; LooseScan +1 SIMPLE t2 NULL ref a a 4 test.t3.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select /*+ SEMIJOIN(@`subq1` LOOSESCAN, DUPSWEEDOUT) */ `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t3`) where (`test`.`t2`.`a` = `test`.`t3`.`a`) +EXPLAIN +SELECT /*+ SEMIJOIN(@subq1 LOOSESCAN, MATERIALIZATION, DUPSWEEDOUT) */ * FROM t2 +WHERE t2.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL index a a 4 NULL 3 100.00 Using index; LooseScan +1 SIMPLE t2 NULL ref a a 4 test.t3.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select /*+ SEMIJOIN(@`subq1` LOOSESCAN, MATERIALIZATION, DUPSWEEDOUT) */ `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t3`) where (`test`.`t2`.`a` = `test`.`t3`.`a`) +EXPLAIN +SELECT /*+ SEMIJOIN(@subq1 LOOSESCAN, FIRSTMATCH, MATERIALIZATION, +DUPSWEEDOUT) */ * FROM t2 +WHERE t2.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL index a a 4 NULL 3 100.00 Using index; LooseScan +1 SIMPLE t2 NULL ref a a 4 test.t3.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select /*+ SEMIJOIN(@`subq1` FIRSTMATCH, LOOSESCAN, MATERIALIZATION, DUPSWEEDOUT) */ `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t3`) where (`test`.`t2`.`a` = `test`.`t3`.`a`) +Drop LooseScan from list of strategies, FirstMatch will be used +EXPLAIN +SELECT /*+ SEMIJOIN(@subq1 FIRSTMATCH, MATERIALIZATION, DUPSWEEDOUT) */ * FROM t2 +WHERE t2.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL index a a 4 NULL 4 100.00 Using index +2 SIMPLE t3 NULL ref a a 4 test.t2.a 1 100.00 Using index; FirstMatch(t2) +Warnings: +Note 1003 /* select#1 */ select /*+ SEMIJOIN(@`subq1` FIRSTMATCH, MATERIALIZATION, DUPSWEEDOUT) */ `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t3`) where (`test`.`t3`.`a` = `test`.`t2`.`a`) +Drop FirstMatch, MatLookup is next +EXPLAIN +SELECT /*+ SEMIJOIN(@subq1 MATERIALIZATION, DUPSWEEDOUT) */ * FROM t2 +WHERE t2.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index a a 4 NULL 4 100.00 Using index +1 SIMPLE NULL eq_ref 4 test.t2.a 1 100.00 NULL +2 MATERIALIZED t3 NULL index a a 4 NULL 3 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select /*+ SEMIJOIN(@`subq1` MATERIALIZATION, DUPSWEEDOUT) */ `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t3`) where (``.`a` = `test`.`t2`.`a`) +For this query LooseScan and Materialization is not applicable +EXPLAIN +SELECT * FROM t1 +WHERE t1.b IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3 WHERE t3.b = t1.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL PRIMARY NULL NULL NULL 4 100.00 Using where +2 SIMPLE t3 NULL ref a a 4 test.t1.b 1 33.33 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t3`) where ((`test`.`t3`.`b` = `test`.`t1`.`a`) and (`test`.`t3`.`a` = `test`.`t1`.`b`)) +Turn off all applicable strategies. DuplicateWeedout should be used +EXPLAIN +SELECT /*+ NO_SEMIJOIN(@subq1 FIRSTMATCH, DUPSWEEDOUT) */ * FROM t1 +WHERE t1.b IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3 WHERE t3.b = t1.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL PRIMARY NULL NULL NULL 4 100.00 Using where +1 SIMPLE NULL eq_ref 9 test.t1.b,test.t1.a 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL a NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select /*+ NO_SEMIJOIN(@`subq1` FIRSTMATCH, DUPSWEEDOUT) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t3`) where ((``.`b` = `test`.`t1`.`a`) and (``.`a` = `test`.`t1`.`b`)) +Similar with SEMIJOIN hint +EXPLAIN +SELECT /*+ SEMIJOIN(@subq1 LOOSESCAN, MATERIALIZATION) */ * FROM t1 +WHERE t1.b IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3 WHERE t3.b = t1.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL PRIMARY NULL NULL NULL 4 100.00 Using where +1 SIMPLE NULL eq_ref 9 test.t1.b,test.t1.a 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL a NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select /*+ SEMIJOIN(@`subq1` LOOSESCAN, MATERIALIZATION) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t3`) where ((``.`b` = `test`.`t1`.`a`) and (``.`a` = `test`.`t1`.`b`)) +Test multiple subqueries. +Default for this query is Loosecan for first and FirstMatch for latter +EXPLAIN +SELECT * FROM t1 +WHERE t1.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3) +AND t1.b IN (SELECT /*+ QB_NAME(subq2) */ a FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL index a a 4 NULL 3 100.00 Using index; LooseScan +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t3.a 1 100.00 Using where +1 SIMPLE t2 NULL ref a a 4 test.t1.b 1 100.00 Using index; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t3`) semi join (`test`.`t2`) where ((`test`.`t2`.`a` = `test`.`t1`.`b`) and (`test`.`t1`.`a` = `test`.`t3`.`a`)) +Forcing the default strategy should not change anything +EXPLAIN +SELECT /*+ SEMIJOIN(@subq1 LOOSESCAN) SEMIJOIN(@subq2 FIRSTMATCH) */ * FROM t1 +WHERE t1.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3) +AND t1.b IN (SELECT /*+ QB_NAME(subq2) */ a FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL index a a 4 NULL 3 100.00 Using index; LooseScan +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t3.a 1 100.00 Using where +1 SIMPLE t2 NULL ref a a 4 test.t1.b 1 100.00 Using index; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select /*+ SEMIJOIN(@`subq1` LOOSESCAN) SEMIJOIN(@`subq2` FIRSTMATCH) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t3`) semi join (`test`.`t2`) where ((`test`.`t2`.`a` = `test`.`t1`.`b`) and (`test`.`t1`.`a` = `test`.`t3`.`a`)) +Forcing a strategy for one, may change the other due to cost changes +EXPLAIN +SELECT /*+ SEMIJOIN(@subq1 FIRSTMATCH) */ * FROM t1 +WHERE t1.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3) +AND t1.b IN (SELECT /*+ QB_NAME(subq2) */ a FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index a a 4 NULL 4 100.00 Using index; LooseScan +1 SIMPLE t1 NULL ALL PRIMARY NULL NULL NULL 4 25.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ref a a 4 test.t1.a 1 100.00 Using index; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select /*+ SEMIJOIN(@`subq1` FIRSTMATCH) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t3`) semi join (`test`.`t2`) where ((`test`.`t1`.`b` = `test`.`t2`.`a`) and (`test`.`t3`.`a` = `test`.`t1`.`a`)) +Forcing same strategy for both +EXPLAIN +SELECT /*+ SEMIJOIN(@subq1 FIRSTMATCH) SEMIJOIN(@subq2 FIRSTMATCH) */ * FROM t1 +WHERE t1.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3) +AND t1.b IN (SELECT /*+ QB_NAME(subq2) */ a FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL PRIMARY NULL NULL NULL 4 100.00 Using where +2 SIMPLE t3 NULL ref a a 4 test.t1.a 1 100.00 Using index; FirstMatch(t1) +2 SIMPLE t2 NULL ref a a 4 test.t1.b 1 100.00 Using index; FirstMatch(t3) +Warnings: +Note 1003 /* select#1 */ select /*+ SEMIJOIN(@`subq1` FIRSTMATCH) SEMIJOIN(@`subq2` FIRSTMATCH) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t3`) semi join (`test`.`t2`) where ((`test`.`t2`.`a` = `test`.`t1`.`b`) and (`test`.`t3`.`a` = `test`.`t1`.`a`)) +Loosescan for both is not possible, ends up with DuplicateWeedout +EXPLAIN +SELECT /*+ SEMIJOIN(@subq1 LOOSESCAN) SEMIJOIN(@subq2 LOOSESCAN) */ * FROM t1 +WHERE t1.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3) +AND t1.b IN (SELECT /*+ QB_NAME(subq2) */ a FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL index a a 4 NULL 3 100.00 Using index; Start temporary +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t3.a 1 100.00 Using where +1 SIMPLE t2 NULL ref a a 4 test.t1.b 1 100.00 Using index; End temporary +Warnings: +Note 1003 /* select#1 */ select /*+ SEMIJOIN(@`subq1` LOOSESCAN) SEMIJOIN(@`subq2` LOOSESCAN) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t3`) semi join (`test`.`t2`) where ((`test`.`t2`.`a` = `test`.`t1`.`b`) and (`test`.`t1`.`a` = `test`.`t3`.`a`)) +Swap strategies compared to default +EXPLAIN +SELECT /*+ SEMIJOIN(@subq1 FIRSTMATCH) SEMIJOIN(@subq2 LOOSESCAN) */ * FROM t1 +WHERE t1.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3) +AND t1.b IN (SELECT /*+ QB_NAME(subq2) */ a FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index a a 4 NULL 4 100.00 Using index; LooseScan +1 SIMPLE t1 NULL ALL PRIMARY NULL NULL NULL 4 25.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ref a a 4 test.t1.a 1 100.00 Using index; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select /*+ SEMIJOIN(@`subq1` FIRSTMATCH) SEMIJOIN(@`subq2` LOOSESCAN) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t3`) semi join (`test`.`t2`) where ((`test`.`t1`.`b` = `test`.`t2`.`a`) and (`test`.`t3`.`a` = `test`.`t1`.`a`)) +Different subsets of strategies for different subqueries +EXPLAIN +SELECT /*+ SEMIJOIN(@subq1 FIRSTMATCH, LOOSESCAN) +SEMIJOIN(@subq2 MATERIALIZATION, DUPSWEEDOUT) */ * FROM t1 +WHERE t1.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3) +AND t1.b IN (SELECT /*+ QB_NAME(subq2) */ a FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL index a a 4 NULL 3 100.00 Using index; LooseScan +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t3.a 1 100.00 Using where +1 SIMPLE NULL eq_ref 4 test.t1.b 1 100.00 NULL +3 MATERIALIZED t2 NULL index a a 4 NULL 4 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select /*+ SEMIJOIN(@`subq1` FIRSTMATCH, LOOSESCAN) SEMIJOIN(@`subq2` MATERIALIZATION, DUPSWEEDOUT) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t3`) semi join (`test`.`t2`) where ((``.`a` = `test`.`t1`.`b`) and (`test`.`t1`.`a` = `test`.`t3`.`a`)) +Vice versa +EXPLAIN +SELECT /*+ SEMIJOIN(@subq1 MATERIALIZATION, DUPSWEEDOUT) +SEMIJOIN(@subq2 FIRSTMATCH, LOOSESCAN) */ * FROM t1 +WHERE t1.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3) +AND t1.b IN (SELECT /*+ QB_NAME(subq2) */ a FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 .a 1 100.00 Using where +1 SIMPLE t2 NULL ref a a 4 test.t1.b 1 100.00 Using index; FirstMatch(t1) +2 MATERIALIZED t3 NULL index a a 4 NULL 3 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select /*+ SEMIJOIN(@`subq1` MATERIALIZATION, DUPSWEEDOUT) SEMIJOIN(@`subq2` FIRSTMATCH, LOOSESCAN) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t3`) semi join (`test`.`t2`) where ((`test`.`t2`.`a` = `test`.`t1`.`b`) and (`test`.`t1`.`a` = ``.`a`)) +Another combination +EXPLAIN +SELECT /*+ SEMIJOIN(@subq1 MATERIALIZATION, FIRSTMATCH) +SEMIJOIN(@subq2 LOOSESCAN, DUPSWEEDOUT) */ * FROM t1 +WHERE t1.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3) +AND t1.b IN (SELECT /*+ QB_NAME(subq2) */ a FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index a a 4 NULL 4 100.00 Using index; LooseScan +1 SIMPLE t1 NULL ALL PRIMARY NULL NULL NULL 4 25.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ref a a 4 test.t1.a 1 100.00 Using index; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select /*+ SEMIJOIN(@`subq1` FIRSTMATCH, MATERIALIZATION) SEMIJOIN(@`subq2` LOOSESCAN, DUPSWEEDOUT) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t3`) semi join (`test`.`t2`) where ((`test`.`t1`.`b` = `test`.`t2`.`a`) and (`test`.`t3`.`a` = `test`.`t1`.`a`)) +Turn off default +EXPLAIN +SELECT /*+ NO_SEMIJOIN(@subq1 LOOSESCAN) +NO_SEMIJOIN(@subq2 FIRSTMATCH) */ * FROM t1 +WHERE t1.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3) +AND t1.b IN (SELECT /*+ QB_NAME(subq2) */ a FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index a a 4 NULL 4 100.00 Using index; LooseScan +1 SIMPLE t1 NULL ALL PRIMARY NULL NULL NULL 4 25.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ref a a 4 test.t1.a 1 100.00 Using index; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select /*+ NO_SEMIJOIN(@`subq1` LOOSESCAN) NO_SEMIJOIN(@`subq2` FIRSTMATCH) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t3`) semi join (`test`.`t2`) where ((`test`.`t1`.`b` = `test`.`t2`.`a`) and (`test`.`t3`.`a` = `test`.`t1`.`a`)) +Also turn off 2nd choice. Gives DuplicateWeedout over both +EXPLAIN +SELECT /*+ NO_SEMIJOIN(@subq1 LOOSESCAN, FIRSTMATCH) +NO_SEMIJOIN(@subq2 FIRSTMATCH, LOOSESCAN) */ * FROM t1 +WHERE t1.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3) +AND t1.b IN (SELECT /*+ QB_NAME(subq2) */ a FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL index a a 4 NULL 3 100.00 Using index; Start temporary +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t3.a 1 100.00 Using where +1 SIMPLE t2 NULL ref a a 4 test.t1.b 1 100.00 Using index; End temporary +Warnings: +Note 1003 /* select#1 */ select /*+ NO_SEMIJOIN(@`subq1` FIRSTMATCH, LOOSESCAN) NO_SEMIJOIN(@`subq2` FIRSTMATCH, LOOSESCAN) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t3`) semi join (`test`.`t2`) where ((`test`.`t2`.`a` = `test`.`t1`.`b`) and (`test`.`t1`.`a` = `test`.`t3`.`a`)) +Also turn off DuplicateWeedout. Materialization is only one left. +EXPLAIN +SELECT /*+ NO_SEMIJOIN(@subq1 LOOSESCAN, FIRSTMATCH, DUPSWEEDOUT) +NO_SEMIJOIN(@subq2 FIRSTMATCH, LOOSESCAN, DUPSWEEDOUT) */ * FROM t1 +WHERE t1.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3) +AND t1.b IN (SELECT /*+ QB_NAME(subq2) */ a FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 .a 1 100.00 Using where +1 SIMPLE NULL eq_ref 4 test.t1.b 1 100.00 NULL +2 MATERIALIZED t3 NULL index a a 4 NULL 3 100.00 Using index +3 MATERIALIZED t2 NULL index a a 4 NULL 4 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select /*+ NO_SEMIJOIN(@`subq1` FIRSTMATCH, LOOSESCAN, DUPSWEEDOUT) NO_SEMIJOIN(@`subq2` FIRSTMATCH, LOOSESCAN, DUPSWEEDOUT) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t3`) semi join (`test`.`t2`) where ((``.`a` = `test`.`t1`.`b`) and (`test`.`t1`.`a` = ``.`a`)) +Force materialization with SEMIJOIN hints instead +EXPLAIN +SELECT /*+ SEMIJOIN(@subq1 MATERIALIZATION) +SEMIJOIN(@subq2 MATERIALIZATION) */ * FROM t1 +WHERE t1.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3) +AND t1.b IN (SELECT /*+ QB_NAME(subq2) */ a FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 .a 1 100.00 Using where +1 SIMPLE NULL eq_ref 4 test.t1.b 1 100.00 NULL +2 MATERIALIZED t3 NULL index a a 4 NULL 3 100.00 Using index +3 MATERIALIZED t2 NULL index a a 4 NULL 4 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select /*+ SEMIJOIN(@`subq1` MATERIALIZATION) SEMIJOIN(@`subq2` MATERIALIZATION) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t3`) semi join (`test`.`t2`) where ((``.`a` = `test`.`t1`.`b`) and (`test`.`t1`.`a` = ``.`a`)) +This query gives DuplicateWeedout over both since combining +DuplicateWeedout with another strategy does not seem possible. +EXPLAIN +SELECT /*+ SEMIJOIN(@subq1 MATERIALIZATION) +SEMIJOIN(@subq2 DUPSWEEDOUT) */ * FROM t1 +WHERE t1.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3) +AND t1.b IN (SELECT /*+ QB_NAME(subq2) */ a FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL index a a 4 NULL 3 100.00 Using index; Start temporary +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t3.a 1 100.00 Using where +1 SIMPLE t2 NULL ref a a 4 test.t1.b 1 100.00 Using index; End temporary +Warnings: +Note 1003 /* select#1 */ select /*+ SEMIJOIN(@`subq1` MATERIALIZATION) SEMIJOIN(@`subq2` DUPSWEEDOUT) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t3`) semi join (`test`.`t2`) where ((`test`.`t2`.`a` = `test`.`t1`.`b`) and (`test`.`t1`.`a` = `test`.`t3`.`a`)) +More alternatives for 2nd subquery gives Materialization for first +EXPLAIN +SELECT /*+ SEMIJOIN(@subq1 MATERIALIZATION) +SEMIJOIN(@subq2 LOOSESCAN, FIRSTMATCH, DUPSWEEDOUT) */ * FROM t1 +WHERE t1.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3) +AND t1.b IN (SELECT /*+ QB_NAME(subq2) */ a FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 .a 1 100.00 Using where +1 SIMPLE t2 NULL ref a a 4 test.t1.b 1 100.00 Using index; FirstMatch(t1) +2 MATERIALIZED t3 NULL index a a 4 NULL 3 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select /*+ SEMIJOIN(@`subq1` MATERIALIZATION) SEMIJOIN(@`subq2` FIRSTMATCH, LOOSESCAN, DUPSWEEDOUT) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t3`) semi join (`test`.`t2`) where ((`test`.`t2`.`a` = `test`.`t1`.`b`) and (`test`.`t1`.`a` = ``.`a`)) +A query with nested subqueries which by default will use FirstMatch +EXPLAIN +SELECT * FROM t1 +WHERE t1.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3 +WHERE t3.b IN (SELECT /*+ QB_NAME(subq2) */ a FROM t2)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL PRIMARY NULL NULL NULL 4 100.00 NULL +2 SIMPLE t3 NULL ref a a 4 test.t1.a 1 100.00 Using where +2 SIMPLE t2 NULL ref a a 4 test.t3.b 1 100.00 Using index; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t3`.`a` = `test`.`t1`.`a`) and (`test`.`t2`.`a` = `test`.`t3`.`b`)) +Let's turn off FirstMatch, Materialization is then selected +EXPLAIN +SELECT /*+ NO_SEMIJOIN(@subq1 FIRSTMATCH) */ * FROM t1 +WHERE t1.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3 +WHERE t3.b IN (SELECT /*+ QB_NAME(subq2) */ a FROM t2)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 .a 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL a NULL NULL NULL 3 100.00 Using where +2 MATERIALIZED t2 NULL ref a a 4 test.t3.b 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select /*+ NO_SEMIJOIN(@`subq1` FIRSTMATCH) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`a` = ``.`a`) and (`test`.`t2`.`a` = `test`.`t3`.`b`)) +Let's also turn off Materialization, DuplicateWeedout is then used +EXPLAIN +SELECT /*+ NO_SEMIJOIN(@subq1 FIRSTMATCH, MATERIALIZATION) */ * FROM t1 +WHERE t1.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3 +WHERE t3.b IN (SELECT /*+ QB_NAME(subq2) */ a FROM t2)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL a NULL NULL NULL 3 100.00 Using where; Start temporary +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t3.a 1 100.00 NULL +1 SIMPLE t2 NULL ref a a 4 test.t3.b 1 100.00 Using index; End temporary +Warnings: +Note 1003 /* select#1 */ select /*+ NO_SEMIJOIN(@`subq1` FIRSTMATCH, MATERIALIZATION) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`a` = `test`.`t3`.`a`) and (`test`.`t2`.`a` = `test`.`t3`.`b`)) +Also turn off DuplicateWeedout. LooseScan not usable; so still DuplicateWeedout +EXPLAIN +SELECT /*+ NO_SEMIJOIN(@subq1 FIRSTMATCH, MATERIALIZATION, DUPSWEEDOUT) */ * +FROM t1 +WHERE t1.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3 +WHERE t3.b IN (SELECT /*+ QB_NAME(subq2) */ a FROM t2)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL a NULL NULL NULL 3 100.00 Using where; Start temporary +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t3.a 1 100.00 NULL +1 SIMPLE t2 NULL ref a a 4 test.t3.b 1 100.00 Using index; End temporary +Warnings: +Note 1003 /* select#1 */ select /*+ NO_SEMIJOIN(@`subq1` FIRSTMATCH, MATERIALIZATION, DUPSWEEDOUT) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`a` = `test`.`t3`.`a`) and (`test`.`t2`.`a` = `test`.`t3`.`b`)) +If we turn off all strategies, DuplicateWeedout should still be used +EXPLAIN +SELECT /*+ NO_SEMIJOIN(@subq1 FIRSTMATCH, LOOSESCAN, MATERIALIZATION, +DUPSWEEDOUT) */ * +FROM t1 +WHERE t1.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3 +WHERE t3.b IN (SELECT /*+ QB_NAME(subq2) */ a FROM t2)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL a NULL NULL NULL 3 100.00 Using where; Start temporary +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t3.a 1 100.00 NULL +1 SIMPLE t2 NULL ref a a 4 test.t3.b 1 100.00 Using index; End temporary +Warnings: +Note 1003 /* select#1 */ select /*+ NO_SEMIJOIN(@`subq1` FIRSTMATCH, LOOSESCAN, MATERIALIZATION, DUPSWEEDOUT) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`a` = `test`.`t3`.`a`) and (`test`.`t2`.`a` = `test`.`t3`.`b`)) +Test same query with SEMIJOIN hint +Force FirstMatch, should not change anything +EXPLAIN +SELECT /*+ SEMIJOIN(@subq1 FIRSTMATCH) */ * FROM t1 +WHERE t1.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3 +WHERE t3.b IN (SELECT /*+ QB_NAME(subq2) */ a FROM t2)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL PRIMARY NULL NULL NULL 4 100.00 NULL +2 SIMPLE t3 NULL ref a a 4 test.t1.a 1 100.00 Using where +2 SIMPLE t2 NULL ref a a 4 test.t3.b 1 100.00 Using index; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select /*+ SEMIJOIN(@`subq1` FIRSTMATCH) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t3`.`a` = `test`.`t1`.`a`) and (`test`.`t2`.`a` = `test`.`t3`.`b`)) +Force LooseScan, will use DuplicateWeedout +EXPLAIN +SELECT /*+ SEMIJOIN(@subq1 LOOSESCAN) */ * FROM t1 +WHERE t1.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3 +WHERE t3.b IN (SELECT /*+ QB_NAME(subq2) */ a FROM t2)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL a NULL NULL NULL 3 100.00 Using where; Start temporary +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t3.a 1 100.00 NULL +1 SIMPLE t2 NULL ref a a 4 test.t3.b 1 100.00 Using index; End temporary +Warnings: +Note 1003 /* select#1 */ select /*+ SEMIJOIN(@`subq1` LOOSESCAN) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`a` = `test`.`t3`.`a`) and (`test`.`t2`.`a` = `test`.`t3`.`b`)) +Force Materialization +EXPLAIN +SELECT /*+ SEMIJOIN(@subq1 MATERIALIZATION) */ * FROM t1 +WHERE t1.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3 +WHERE t3.b IN (SELECT /*+ QB_NAME(subq2) */ a FROM t2)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 .a 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL a NULL NULL NULL 3 100.00 Using where +2 MATERIALIZED t2 NULL ref a a 4 test.t3.b 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select /*+ SEMIJOIN(@`subq1` MATERIALIZATION) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`a` = ``.`a`) and (`test`.`t2`.`a` = `test`.`t3`.`b`)) +Force DuplicateWeedout +EXPLAIN +SELECT /*+ SEMIJOIN(@subq1 DUPSWEEDOUT) */ * FROM t1 +WHERE t1.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3 +WHERE t3.b IN (SELECT /*+ QB_NAME(subq2) */ a FROM t2)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL a NULL NULL NULL 3 100.00 Using where; Start temporary +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t3.a 1 100.00 NULL +1 SIMPLE t2 NULL ref a a 4 test.t3.b 1 100.00 Using index; End temporary +Warnings: +Note 1003 /* select#1 */ select /*+ SEMIJOIN(@`subq1` DUPSWEEDOUT) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`a` = `test`.`t3`.`a`) and (`test`.`t2`.`a` = `test`.`t3`.`b`)) +If FirstMatch is among candidates, it will be used +EXPLAIN +SELECT /*+ SEMIJOIN(@subq1 FIRSTMATCH, DUPSWEEDOUT) */ * FROM t1 +WHERE t1.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3 +WHERE t3.b IN (SELECT /*+ QB_NAME(subq2) */ a FROM t2)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL PRIMARY NULL NULL NULL 4 100.00 NULL +2 SIMPLE t3 NULL ref a a 4 test.t1.a 1 100.00 Using where +2 SIMPLE t2 NULL ref a a 4 test.t3.b 1 100.00 Using index; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select /*+ SEMIJOIN(@`subq1` FIRSTMATCH, DUPSWEEDOUT) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t3`.`a` = `test`.`t1`.`a`) and (`test`.`t2`.`a` = `test`.`t3`.`b`)) +EXPLAIN +SELECT /*+ SEMIJOIN(@subq1 FIRSTMATCH, LOOSESCAN, DUPSWEEDOUT) */ * FROM t1 +WHERE t1.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3 +WHERE t3.b IN (SELECT /*+ QB_NAME(subq2) */ a FROM t2)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL PRIMARY NULL NULL NULL 4 100.00 NULL +2 SIMPLE t3 NULL ref a a 4 test.t1.a 1 100.00 Using where +2 SIMPLE t2 NULL ref a a 4 test.t3.b 1 100.00 Using index; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select /*+ SEMIJOIN(@`subq1` FIRSTMATCH, LOOSESCAN, DUPSWEEDOUT) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t3`.`a` = `test`.`t1`.`a`) and (`test`.`t2`.`a` = `test`.`t3`.`b`)) +EXPLAIN +SELECT /*+ SEMIJOIN(@subq1 FIRSTMATCH, MATERIALIZATION, LOOSESCAN, +DUPSWEEDOUT) */ * FROM t1 +WHERE t1.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3 +WHERE t3.b IN (SELECT /*+ QB_NAME(subq2) */ a FROM t2)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL PRIMARY NULL NULL NULL 4 100.00 NULL +2 SIMPLE t3 NULL ref a a 4 test.t1.a 1 100.00 Using where +2 SIMPLE t2 NULL ref a a 4 test.t3.b 1 100.00 Using index; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select /*+ SEMIJOIN(@`subq1` FIRSTMATCH, LOOSESCAN, MATERIALIZATION, DUPSWEEDOUT) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t3`.`a` = `test`.`t1`.`a`) and (`test`.`t2`.`a` = `test`.`t3`.`b`)) +Drop FirstMatch. Materialization will be used +EXPLAIN +SELECT /*+ SEMIJOIN(@subq1 MATERIALIZATION, LOOSESCAN, DUPSWEEDOUT) */ * FROM t1 +WHERE t1.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3 +WHERE t3.b IN (SELECT /*+ QB_NAME(subq2) */ a FROM t2)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 .a 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL a NULL NULL NULL 3 100.00 Using where +2 MATERIALIZED t2 NULL ref a a 4 test.t3.b 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select /*+ SEMIJOIN(@`subq1` LOOSESCAN, MATERIALIZATION, DUPSWEEDOUT) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`a` = ``.`a`) and (`test`.`t2`.`a` = `test`.`t3`.`b`)) +Drop Materialization, DuplicateWeedout next +EXPLAIN +SELECT /*+ SEMIJOIN(@subq1 LOOSESCAN, DUPSWEEDOUT) */ * FROM t1 +WHERE t1.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3 +WHERE t3.b IN (SELECT /*+ QB_NAME(subq2) */ a FROM t2)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL a NULL NULL NULL 3 100.00 Using where; Start temporary +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t3.a 1 100.00 NULL +1 SIMPLE t2 NULL ref a a 4 test.t3.b 1 100.00 Using index; End temporary +Warnings: +Note 1003 /* select#1 */ select /*+ SEMIJOIN(@`subq1` LOOSESCAN, DUPSWEEDOUT) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`a` = `test`.`t3`.`a`) and (`test`.`t2`.`a` = `test`.`t3`.`b`)) +Strategy hints on inner-most query is ignored since sj-nests are merged +EXPLAIN +SELECT /*+ NO_SEMIJOIN(@subq2 FIRSTMATCH) */ * FROM t1 +WHERE t1.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3 +WHERE t3.b IN (SELECT /*+ QB_NAME(subq2) */ a FROM t2)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL PRIMARY NULL NULL NULL 4 100.00 NULL +2 SIMPLE t3 NULL ref a a 4 test.t1.a 1 100.00 Using where +2 SIMPLE t2 NULL ref a a 4 test.t3.b 1 100.00 Using index; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select /*+ NO_SEMIJOIN(@`subq2` FIRSTMATCH) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t3`.`a` = `test`.`t1`.`a`) and (`test`.`t2`.`a` = `test`.`t3`.`b`)) +Ditto +EXPLAIN +SELECT /*+ SEMIJOIN(@subq2 MATERIALIZATION) */ * FROM t1 +WHERE t1.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3 +WHERE t3.b IN (SELECT /*+ QB_NAME(subq2) */ a FROM t2)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL PRIMARY NULL NULL NULL 4 100.00 NULL +2 SIMPLE t3 NULL ref a a 4 test.t1.a 1 100.00 Using where +2 SIMPLE t2 NULL ref a a 4 test.t3.b 1 100.00 Using index; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select /*+ SEMIJOIN(@`subq2` MATERIALIZATION) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t3`.`a` = `test`.`t1`.`a`) and (`test`.`t2`.`a` = `test`.`t3`.`b`)) +Turn off semijoin for outer subquery. FirstMatch is used for inner +EXPLAIN +SELECT /*+ NO_SEMIJOIN(@subq1) */ * FROM t1 +WHERE t1.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3 +WHERE t3.b IN (SELECT /*+ QB_NAME(subq2) */ a FROM t2)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +2 DEPENDENT SUBQUERY t3 NULL ref a a 4 func 1 100.00 Using where +2 DEPENDENT SUBQUERY t2 NULL ref a a 4 test.t3.b 1 100.00 Using index; FirstMatch(t3) +Warnings: +Note 1003 /* select#1 */ select /*+ NO_SEMIJOIN(@`subq1`) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (`test`.`t1`.`a`,(/* select#2 */ select /*+ QB_NAME(`subq1`) */ `test`.`t3`.`a` from `test`.`t3` semi join (`test`.`t2`) where ((`test`.`t2`.`a` = `test`.`t3`.`b`) and ((`test`.`t1`.`a`) = `test`.`t3`.`a`)))) +Do not use FirstMatch for inner +EXPLAIN +SELECT /*+ NO_SEMIJOIN(@subq1) NO_SEMIJOIN(@subq2 FIRSTMATCH) */ * FROM t1 +WHERE t1.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3 +WHERE t3.b IN (SELECT /*+ QB_NAME(subq2) */ a FROM t2)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +2 SUBQUERY t3 NULL ALL a NULL NULL NULL 3 100.00 Using where +2 SUBQUERY NULL eq_ref 4 test.t3.b 1 100.00 NULL +3 MATERIALIZED t2 NULL index a a 4 NULL 4 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select /*+ NO_SEMIJOIN(@`subq2` FIRSTMATCH) NO_SEMIJOIN(@`subq1`) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (`test`.`t1`.`a`,`test`.`t1`.`a` in ( (/* select#2 */ select /*+ QB_NAME(`subq1`) */ `test`.`t3`.`a` from `test`.`t3` semi join (`test`.`t2`) where (``.`a` = `test`.`t3`.`b`) ), (`test`.`t1`.`a` in on where ((`test`.`t1`.`a` = ``.`a`))))) +Do not use FirstMatch nor Materialization for inner +EXPLAIN +SELECT /*+ NO_SEMIJOIN(@subq1) +NO_SEMIJOIN(@subq2 FIRSTMATCH, MATERIALIZATION) */ * FROM t1 +WHERE t1.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3 +WHERE t3.b IN (SELECT /*+ QB_NAME(subq2) */ a FROM t2)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +2 SUBQUERY t3 NULL ALL a NULL NULL NULL 3 100.00 Using where +2 SUBQUERY t2 NULL ref a a 4 test.t3.b 1 100.00 Using index; Start temporary; End temporary +Warnings: +Note 1003 /* select#1 */ select /*+ NO_SEMIJOIN(@`subq2` FIRSTMATCH, MATERIALIZATION) NO_SEMIJOIN(@`subq1`) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (`test`.`t1`.`a`,`test`.`t1`.`a` in ( (/* select#2 */ select /*+ QB_NAME(`subq1`) */ `test`.`t3`.`a` from `test`.`t3` semi join (`test`.`t2`) where (`test`.`t2`.`a` = `test`.`t3`.`b`) ), (`test`.`t1`.`a` in on where ((`test`.`t1`.`a` = ``.`a`))))) +LooseScan is last resort +EXPLAIN +SELECT /*+ NO_SEMIJOIN(@subq1) +NO_SEMIJOIN(@subq2 FIRSTMATCH, MATERIALIZATION, DUPSWEEDOUT) */ * +FROM t1 +WHERE t1.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3 +WHERE t3.b IN (SELECT /*+ QB_NAME(subq2) */ a FROM t2)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +2 SUBQUERY t2 NULL index a a 4 NULL 4 100.00 Using index; LooseScan +2 SUBQUERY t3 NULL ALL a NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select /*+ NO_SEMIJOIN(@`subq2` FIRSTMATCH, MATERIALIZATION, DUPSWEEDOUT) NO_SEMIJOIN(@`subq1`) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (`test`.`t1`.`a`,`test`.`t1`.`a` in ( (/* select#2 */ select /*+ QB_NAME(`subq1`) */ `test`.`t3`.`a` from `test`.`t3` semi join (`test`.`t2`) where (`test`.`t3`.`b` = `test`.`t2`.`a`) ), (`test`.`t1`.`a` in on where ((`test`.`t1`.`a` = ``.`a`))))) +Allow all stragies except default +EXPLAIN +SELECT /*+ NO_SEMIJOIN(@subq1) +SEMIJOIN(@subq2 MATERIALIZATION, DUPSWEEDOUT, LOOSESCAN) */ * +FROM t1 +WHERE t1.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3 +WHERE t3.b IN (SELECT /*+ QB_NAME(subq2) */ a FROM t2)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +2 SUBQUERY t3 NULL ALL a NULL NULL NULL 3 100.00 Using where +2 SUBQUERY NULL eq_ref 4 test.t3.b 1 100.00 NULL +3 MATERIALIZED t2 NULL index a a 4 NULL 4 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select /*+ SEMIJOIN(@`subq2` LOOSESCAN, MATERIALIZATION, DUPSWEEDOUT) NO_SEMIJOIN(@`subq1`) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (`test`.`t1`.`a`,`test`.`t1`.`a` in ( (/* select#2 */ select /*+ QB_NAME(`subq1`) */ `test`.`t3`.`a` from `test`.`t3` semi join (`test`.`t2`) where (``.`a` = `test`.`t3`.`b`) ), (`test`.`t1`.`a` in on where ((`test`.`t1`.`a` = ``.`a`))))) +Force a particular strategy +EXPLAIN +SELECT /*+ NO_SEMIJOIN(@subq1) SEMIJOIN(@subq2 LOOSESCAN) */ * FROM t1 +WHERE t1.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3 +WHERE t3.b IN (SELECT /*+ QB_NAME(subq2) */ a FROM t2)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +2 SUBQUERY t2 NULL index a a 4 NULL 4 100.00 Using index; LooseScan +2 SUBQUERY t3 NULL ALL a NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select /*+ SEMIJOIN(@`subq2` LOOSESCAN) NO_SEMIJOIN(@`subq1`) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (`test`.`t1`.`a`,`test`.`t1`.`a` in ( (/* select#2 */ select /*+ QB_NAME(`subq1`) */ `test`.`t3`.`a` from `test`.`t3` semi join (`test`.`t2`) where (`test`.`t3`.`b` = `test`.`t2`.`a`) ), (`test`.`t1`.`a` in on where ((`test`.`t1`.`a` = ``.`a`))))) +Turn off semijoin for inner-most subquery. FirstMatch is used for outer +EXPLAIN +SELECT /*+ NO_SEMIJOIN(@subq2) */ * FROM t1 +WHERE t1.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3 +WHERE t3.b IN (SELECT /*+ QB_NAME(subq2) */ a FROM t2)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL PRIMARY NULL NULL NULL 4 100.00 NULL +1 PRIMARY t3 NULL ref a a 4 test.t1.a 1 100.00 Using where; FirstMatch(t1) +3 DEPENDENT SUBQUERY t2 NULL index_subquery a a 4 func 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select /*+ NO_SEMIJOIN(@`subq2`) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t3`) where ((`test`.`t3`.`a` = `test`.`t1`.`a`) and (`test`.`t3`.`b`,(((`test`.`t3`.`b`) in t2 on a)))) +Do not use FirstMatch for outer +EXPLAIN +SELECT /*+ NO_SEMIJOIN(@subq1 FIRSTMATCH) NO_SEMIJOIN(@subq2) */ * FROM t1 +WHERE t1.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3 +WHERE t3.b IN (SELECT /*+ QB_NAME(subq2) */ a FROM t2)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL PRIMARY NULL NULL NULL 4 100.00 NULL +1 PRIMARY NULL eq_ref 4 test.t1.a 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL a NULL NULL NULL 3 100.00 Using where +3 DEPENDENT SUBQUERY t2 NULL index_subquery a a 4 func 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select /*+ NO_SEMIJOIN(@`subq2`) NO_SEMIJOIN(@`subq1` FIRSTMATCH) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t3`) where ((``.`a` = `test`.`t1`.`a`) and (`test`.`t3`.`b`,(((`test`.`t3`.`b`) in t2 on a)))) +Do not use FirstMatch nor Materialization for outer +EXPLAIN +SELECT /*+ NO_SEMIJOIN(@subq1 FIRSTMATCH, MATERIALIZATION) +NO_SEMIJOIN(@subq2) */ * FROM t1 +WHERE t1.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3 +WHERE t3.b IN (SELECT /*+ QB_NAME(subq2) */ a FROM t2)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t3 NULL ALL a NULL NULL NULL 3 100.00 Using where; Start temporary +1 PRIMARY t1 NULL eq_ref PRIMARY PRIMARY 4 test.t3.a 1 100.00 End temporary +3 DEPENDENT SUBQUERY t2 NULL index_subquery a a 4 func 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select /*+ NO_SEMIJOIN(@`subq2`) NO_SEMIJOIN(@`subq1` FIRSTMATCH, MATERIALIZATION) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t3`) where ((`test`.`t1`.`a` = `test`.`t3`.`a`) and (`test`.`t3`.`b`,(((`test`.`t3`.`b`) in t2 on a)))) +LooseScan can not be used since index scan would not be "covering" +EXPLAIN +SELECT /*+ NO_SEMIJOIN(@subq1 FIRSTMATCH, MATERIALIZATION, DUPSWEEDOUT) +NO_SEMIJOIN(@subq2) */ * FROM t1 +WHERE t1.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3 +WHERE t3.b IN (SELECT /*+ QB_NAME(subq2) */ a FROM t2)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t3 NULL ALL a NULL NULL NULL 3 100.00 Using where; Start temporary +1 PRIMARY t1 NULL eq_ref PRIMARY PRIMARY 4 test.t3.a 1 100.00 End temporary +3 DEPENDENT SUBQUERY t2 NULL index_subquery a a 4 func 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select /*+ NO_SEMIJOIN(@`subq2`) NO_SEMIJOIN(@`subq1` FIRSTMATCH, MATERIALIZATION, DUPSWEEDOUT) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t3`) where ((`test`.`t1`.`a` = `test`.`t3`.`a`) and (`test`.`t3`.`b`,(((`test`.`t3`.`b`) in t2 on a)))) +Allow all stragies except default +EXPLAIN +SELECT /*+ SEMIJOIN(@subq1 MATERIALIZATION, DUPSWEEDOUT, LOOSESCAN) +NO_SEMIJOIN(@subq2) */ * FROM t1 +WHERE t1.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3 +WHERE t3.b IN (SELECT /*+ QB_NAME(subq2) */ a FROM t2)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL PRIMARY NULL NULL NULL 4 100.00 NULL +1 PRIMARY NULL eq_ref 4 test.t1.a 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL a NULL NULL NULL 3 100.00 Using where +3 DEPENDENT SUBQUERY t2 NULL index_subquery a a 4 func 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select /*+ NO_SEMIJOIN(@`subq2`) SEMIJOIN(@`subq1` LOOSESCAN, MATERIALIZATION, DUPSWEEDOUT) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t3`) where ((``.`a` = `test`.`t1`.`a`) and (`test`.`t3`.`b`,(((`test`.`t3`.`b`) in t2 on a)))) +Force a particular strategy +EXPLAIN +SELECT /*+ SEMIJOIN(@subq1 DUPSWEEDOUT) NO_SEMIJOIN(@subq2) */ * FROM t1 +WHERE t1.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3 +WHERE t3.b IN (SELECT /*+ QB_NAME(subq2) */ a FROM t2)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t3 NULL ALL a NULL NULL NULL 3 100.00 Using where; Start temporary +1 PRIMARY t1 NULL eq_ref PRIMARY PRIMARY 4 test.t3.a 1 100.00 End temporary +3 DEPENDENT SUBQUERY t2 NULL index_subquery a a 4 func 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select /*+ NO_SEMIJOIN(@`subq2`) SEMIJOIN(@`subq1` DUPSWEEDOUT) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t3`) where ((`test`.`t1`.`a` = `test`.`t3`.`a`) and (`test`.`t3`.`b`,(((`test`.`t3`.`b`) in t2 on a)))) +Turn off semijoin for both subqueries +EXPLAIN +SELECT /*+ NO_SEMIJOIN(@subq1) NO_SEMIJOIN(@subq2) */ * FROM t1 +WHERE t1.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3 +WHERE t3.b IN (SELECT /*+ QB_NAME(subq2) */ a FROM t2)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +2 DEPENDENT SUBQUERY t3 NULL index_subquery a a 4 func 1 100.00 Using where +3 DEPENDENT SUBQUERY t2 NULL index_subquery a a 4 func 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select /*+ NO_SEMIJOIN(@`subq2`) NO_SEMIJOIN(@`subq1`) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (`test`.`t1`.`a`,(((`test`.`t1`.`a`) in t3 on a where (`test`.`t3`.`b`,(((`test`.`t3`.`b`) in t2 on a)))))) +Test hints with prepared statements +PREPARE stmt1 FROM "EXPLAIN +SELECT /*+ NO_SEMIJOIN(@subq1 FIRSTMATCH, LOOSESCAN) + NO_SEMIJOIN(@subq2 FIRSTMATCH, LOOSESCAN) */ * FROM t1 +WHERE t1.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3) + AND t1.b IN (SELECT /*+ QB_NAME(subq2) */ a FROM t2)"; +EXECUTE stmt1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL index a a 4 NULL 3 100.00 Using index; Start temporary +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t3.a 1 100.00 Using where +1 SIMPLE t2 NULL ref a a 4 test.t1.b 1 100.00 Using index; End temporary +Warnings: +Note 1003 /* select#1 */ select /*+ NO_SEMIJOIN(@`subq1` FIRSTMATCH, LOOSESCAN) NO_SEMIJOIN(@`subq2` FIRSTMATCH, LOOSESCAN) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t3`) semi join (`test`.`t2`) where ((`test`.`t2`.`a` = `test`.`t1`.`b`) and (`test`.`t1`.`a` = `test`.`t3`.`a`)) +EXECUTE stmt1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL index a a 4 NULL 3 100.00 Using index; Start temporary +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t3.a 1 100.00 Using where +1 SIMPLE t2 NULL ref a a 4 test.t1.b 1 100.00 Using index; End temporary +Warnings: +Note 1003 /* select#1 */ select /*+ NO_SEMIJOIN(@`subq1` FIRSTMATCH, LOOSESCAN) NO_SEMIJOIN(@`subq2` FIRSTMATCH, LOOSESCAN) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t3`) semi join (`test`.`t2`) where ((`test`.`t2`.`a` = `test`.`t1`.`b`) and (`test`.`t1`.`a` = `test`.`t3`.`a`)) +DEALLOCATE PREPARE stmt1; +Another Prepared Statement test +PREPARE stmt1 FROM "EXPLAIN +SELECT /*+ NO_SEMIJOIN(@subq1) SEMIJOIN(@subq2 LOOSESCAN) */ * FROM t1 +WHERE t1.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3 + WHERE t3.b IN (SELECT /*+ QB_NAME(subq2) */ a FROM t2))"; +EXECUTE stmt1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +2 SUBQUERY t2 NULL index a a 4 NULL 4 100.00 Using index; LooseScan +2 SUBQUERY t3 NULL ALL a NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select /*+ SEMIJOIN(@`subq2` LOOSESCAN) NO_SEMIJOIN(@`subq1`) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (`test`.`t1`.`a`,`test`.`t1`.`a` in ( (/* select#2 */ select /*+ QB_NAME(`subq1`) */ `test`.`t3`.`a` from `test`.`t3` semi join (`test`.`t2`) where (`test`.`t3`.`b` = `test`.`t2`.`a`) ), (`test`.`t1`.`a` in on where ((`test`.`t1`.`a` = ``.`a`))))) +EXECUTE stmt1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +2 SUBQUERY t2 NULL index a a 4 NULL 4 100.00 Using index; LooseScan +2 SUBQUERY t3 NULL ALL a NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select /*+ SEMIJOIN(@`subq2` LOOSESCAN) NO_SEMIJOIN(@`subq1`) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (`test`.`t1`.`a`,`test`.`t1`.`a` in ( (/* select#2 */ select /*+ QB_NAME(`subq1`) */ `test`.`t3`.`a` from `test`.`t3` semi join (`test`.`t2`) where (`test`.`t3`.`b` = `test`.`t2`.`a`) ), (`test`.`t1`.`a` in on where ((`test`.`t1`.`a` = ``.`a`))))) +DEALLOCATE PREPARE stmt1; +SET optimizer_switch = default; +Tests with non-default optimizer_switch settings +SET optimizer_switch = 'semijoin=off'; +No table pull-out for this query +EXPLAIN +SELECT * FROM t2 WHERE t2.a IN (SELECT a FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t2 NULL index NULL a 4 NULL 4 100.00 Using where; Using index +2 DEPENDENT SUBQUERY t1 NULL unique_subquery PRIMARY PRIMARY 4 func 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` where (`test`.`t2`.`a`,(((`test`.`t2`.`a`) in t1 on PRIMARY))) +This should not change anything +EXPLAIN +SELECT /*+ NO_SEMIJOIN(@subq) */ * FROM t2 +WHERE t2.a IN (SELECT /*+ QB_NAME(subq) */ a FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t2 NULL index NULL a 4 NULL 4 100.00 Using where; Using index +2 DEPENDENT SUBQUERY t1 NULL unique_subquery PRIMARY PRIMARY 4 func 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select /*+ NO_SEMIJOIN(@`subq`) */ `test`.`t2`.`a` AS `a` from `test`.`t2` where (`test`.`t2`.`a`,(((`test`.`t2`.`a`) in t1 on PRIMARY))) +Force semijoin +EXPLAIN +SELECT /*+ SEMIJOIN(@subq) */ * FROM t2 +WHERE t2.a IN (SELECT /*+ QB_NAME(subq) */ a FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL index a a 4 NULL 4 100.00 Using index +2 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select /*+ SEMIJOIN(@`subq`) */ `test`.`t2`.`a` AS `a` from `test`.`t1` join `test`.`t2` where (`test`.`t1`.`a` = `test`.`t2`.`a`) +Setting strategy should still force semijoin +Strategy is ignored since table pull-out is done +EXPLAIN +SELECT /*+ SEMIJOIN(@subq FIRSTMATCH) */ * FROM t2 +WHERE t2.a IN (SELECT /*+ QB_NAME(subq) */ a FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL index a a 4 NULL 4 100.00 Using index +2 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select /*+ SEMIJOIN(@`subq` FIRSTMATCH) */ `test`.`t2`.`a` AS `a` from `test`.`t1` join `test`.`t2` where (`test`.`t1`.`a` = `test`.`t2`.`a`) +Query with two sub-queries +EXPLAIN +SELECT * FROM t3 +WHERE t3.a IN (SELECT a FROM t1 tx) +AND t3.b IN (SELECT a FROM t1 ty); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t3 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +3 DEPENDENT SUBQUERY ty NULL unique_subquery PRIMARY PRIMARY 4 func 1 100.00 Using index +2 DEPENDENT SUBQUERY tx NULL unique_subquery PRIMARY PRIMARY 4 func 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b` from `test`.`t3` where ((`test`.`t3`.`a`,(((`test`.`t3`.`a`) in t1 on PRIMARY))) and (`test`.`t3`.`b`,(((`test`.`t3`.`b`) in t1 on PRIMARY)))) +SEMIJOIN transformation for first subquery +EXPLAIN +SELECT /*+ SEMIJOIN(@subq1) */ * FROM t3 +WHERE t3.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t1 tx) +AND t3.b IN (SELECT /*+ QB_NAME(subq2) */ a FROM t1 ty); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t3 NULL ALL a NULL NULL NULL 3 100.00 Using where +1 PRIMARY tx NULL eq_ref PRIMARY PRIMARY 4 test.t3.a 1 100.00 Using index +3 DEPENDENT SUBQUERY ty NULL unique_subquery PRIMARY PRIMARY 4 func 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select /*+ SEMIJOIN(@`subq1`) */ `test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b` from `test`.`t1` `tx` join `test`.`t3` where ((`test`.`tx`.`a` = `test`.`t3`.`a`) and (`test`.`t3`.`b`,(((`test`.`t3`.`b`) in t1 on PRIMARY)))) +SEMIJOIN transformation for latter subquery +EXPLAIN +SELECT /*+ SEMIJOIN(@subq2) */ * FROM t3 +WHERE t3.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t1 tx) +AND t3.b IN (SELECT /*+ QB_NAME(subq2) */ a FROM t1 ty); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t3 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 PRIMARY ty NULL eq_ref PRIMARY PRIMARY 4 test.t3.b 1 100.00 Using index +2 DEPENDENT SUBQUERY tx NULL unique_subquery PRIMARY PRIMARY 4 func 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select /*+ SEMIJOIN(@`subq2`) */ `test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b` from `test`.`t1` `ty` join `test`.`t3` where ((`test`.`ty`.`a` = `test`.`t3`.`b`) and (`test`.`t3`.`a`,(((`test`.`t3`.`a`) in t1 on PRIMARY)))) +SEMIJOIN transformation for both subqueries +EXPLAIN +SELECT /*+ SEMIJOIN(@subq1) SEMIJOIN(@subq2) */ * FROM t3 +WHERE t3.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t1 tx) +AND t3.b IN (SELECT /*+ QB_NAME(subq2) */ a FROM t1 ty); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t3 NULL ALL a NULL NULL NULL 3 100.00 Using where +2 SIMPLE tx NULL eq_ref PRIMARY PRIMARY 4 test.t3.a 1 100.00 Using index +2 SIMPLE ty NULL eq_ref PRIMARY PRIMARY 4 test.t3.b 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select /*+ SEMIJOIN(@`subq1`) SEMIJOIN(@`subq2`) */ `test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b` from `test`.`t1` `tx` join `test`.`t1` `ty` join `test`.`t3` where ((`test`.`ty`.`a` = `test`.`t3`.`b`) and (`test`.`tx`.`a` = `test`.`t3`.`a`)) +Query with nested sub-queries +EXPLAIN +SELECT * FROM t3 +WHERE t3.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t1 tx +WHERE tx.b IN (SELECT /*+ QB_NAME(subq2) */ a FROM t1 ty)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t3 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY tx NULL unique_subquery PRIMARY PRIMARY 4 func 1 100.00 Using where +3 DEPENDENT SUBQUERY ty NULL unique_subquery PRIMARY PRIMARY 4 func 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b` from `test`.`t3` where (`test`.`t3`.`a`,(((`test`.`t3`.`a`) in t1 on PRIMARY where (`test`.`tx`.`b`,(((`test`.`tx`.`b`) in t1 on PRIMARY)))))) +SEMIJOIN transformation for outer subquery +EXPLAIN +SELECT /*+ SEMIJOIN(@subq1) */ * FROM t3 +WHERE t3.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t1 tx +WHERE tx.b IN (SELECT /*+ QB_NAME(subq2) */ a FROM t1 ty)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t3 NULL ALL a NULL NULL NULL 3 100.00 NULL +1 PRIMARY tx NULL eq_ref PRIMARY PRIMARY 4 test.t3.a 1 100.00 Using where +3 DEPENDENT SUBQUERY ty NULL unique_subquery PRIMARY PRIMARY 4 func 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select /*+ SEMIJOIN(@`subq1`) */ `test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b` from `test`.`t1` `tx` join `test`.`t3` where ((`test`.`tx`.`a` = `test`.`t3`.`a`) and (`test`.`tx`.`b`,(((`test`.`tx`.`b`) in t1 on PRIMARY)))) +SEMIJOIN transformation for inner-most subquery +EXPLAIN +SELECT /*+ SEMIJOIN(@subq2) */ * FROM t3 +WHERE t3.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t1 tx +WHERE tx.b IN (SELECT /*+ QB_NAME(subq2) */ a FROM t1 ty)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t3 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY tx NULL eq_ref PRIMARY PRIMARY 4 func 1 100.00 Using where +2 DEPENDENT SUBQUERY ty NULL eq_ref PRIMARY PRIMARY 4 test.tx.b 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select /*+ SEMIJOIN(@`subq2`) */ `test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b` from `test`.`t3` where (`test`.`t3`.`a`,(/* select#2 */ select /*+ QB_NAME(`subq1`) */ `test`.`tx`.`a` from `test`.`t1` `ty` join `test`.`t1` `tx` where ((`test`.`ty`.`a` = `test`.`tx`.`b`) and ((`test`.`t3`.`a`) = `test`.`tx`.`a`)))) +SEMIJOIN transformation for both +EXPLAIN +SELECT /*+ SEMIJOIN(@subq1) SEMIJOIN(@subq2) */ * FROM t3 +WHERE t3.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t1 tx +WHERE tx.b IN (SELECT /*+ QB_NAME(subq2) */ a FROM t1 ty)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t3 NULL ALL a NULL NULL NULL 3 100.00 NULL +2 SIMPLE tx NULL eq_ref PRIMARY PRIMARY 4 test.t3.a 1 100.00 Using where +2 SIMPLE ty NULL eq_ref PRIMARY PRIMARY 4 test.tx.b 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select /*+ SEMIJOIN(@`subq2`) SEMIJOIN(@`subq1`) */ `test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b` from `test`.`t1` `tx` join `test`.`t1` `ty` join `test`.`t3` where ((`test`.`tx`.`a` = `test`.`t3`.`a`) and (`test`.`ty`.`a` = `test`.`tx`.`b`)) +Test strategies when some are disabled by optimizer_switch +SET optimizer_switch='semijoin=on'; +SET optimizer_switch='loosescan=off'; +This query will get LooseScan by default. FirstMatch now. +EXPLAIN +SELECT * FROM t2 WHERE t2.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL index a a 4 NULL 4 100.00 Using index +2 SIMPLE t3 NULL ref a a 4 test.t2.a 1 100.00 Using index; FirstMatch(t2) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t3`) where (`test`.`t3`.`a` = `test`.`t2`.`a`) +Let's turn off LooseScan also by hint, FirstMatch should still be SELECTed +EXPLAIN +SELECT /*+ NO_SEMIJOIN(@subq1 LOOSESCAN) */ * FROM t2 +WHERE t2.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL index a a 4 NULL 4 100.00 Using index +2 SIMPLE t3 NULL ref a a 4 test.t2.a 1 100.00 Using index; FirstMatch(t2) +Warnings: +Note 1003 /* select#1 */ select /*+ NO_SEMIJOIN(@`subq1` LOOSESCAN) */ `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t3`) where (`test`.`t3`.`a` = `test`.`t2`.`a`) +Let's also turn off FirstMatch, MatLookup should then be used +EXPLAIN +SELECT /*+ NO_SEMIJOIN(@subq1 FIRSTMATCH) */ * FROM t2 +WHERE t2.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index a a 4 NULL 4 100.00 Using index +1 SIMPLE NULL eq_ref 4 test.t2.a 1 100.00 NULL +2 MATERIALIZED t3 NULL index a a 4 NULL 3 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select /*+ NO_SEMIJOIN(@`subq1` FIRSTMATCH) */ `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t3`) where (``.`a` = `test`.`t2`.`a`) +Let's also turn off Materialization, DuplicateWeedout should then be used +EXPLAIN +SELECT /*+ NO_SEMIJOIN(@subq1 FIRSTMATCH, MATERIALIZATION) */ * +FROM t2 +WHERE t2.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL index a a 4 NULL 3 100.00 Using index; Start temporary +1 SIMPLE t2 NULL ref a a 4 test.t3.a 1 100.00 Using index; End temporary +Warnings: +Note 1003 /* select#1 */ select /*+ NO_SEMIJOIN(@`subq1` FIRSTMATCH, MATERIALIZATION) */ `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t3`) where (`test`.`t2`.`a` = `test`.`t3`.`a`) +Let's force LooseScan back on +EXPLAIN +SELECT /*+ SEMIJOIN(@subq1 LOOSESCAN) */ * FROM t2 +WHERE t2.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL index a a 4 NULL 3 100.00 Using index; LooseScan +1 SIMPLE t2 NULL ref a a 4 test.t3.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select /*+ SEMIJOIN(@`subq1` LOOSESCAN) */ `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t3`) where (`test`.`t2`.`a` = `test`.`t3`.`a`) +Forcing another strategy +EXPLAIN +SELECT /*+ SEMIJOIN(@subq1 MATERIALIZATION) */ * FROM t2 +WHERE t2.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index a a 4 NULL 4 100.00 Using index +1 SIMPLE NULL eq_ref 4 test.t2.a 1 100.00 NULL +2 MATERIALIZED t3 NULL index a a 4 NULL 3 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select /*+ SEMIJOIN(@`subq1` MATERIALIZATION) */ `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t3`) where (``.`a` = `test`.`t2`.`a`) +If LooseScan is among candidates, it is used even if originally disabled +EXPLAIN +SELECT /*+ SEMIJOIN(@subq1 LOOSESCAN, DUPSWEEDOUT) */ * FROM t2 +WHERE t2.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL index a a 4 NULL 3 100.00 Using index; LooseScan +1 SIMPLE t2 NULL ref a a 4 test.t3.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select /*+ SEMIJOIN(@`subq1` LOOSESCAN, DUPSWEEDOUT) */ `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t3`) where (`test`.`t2`.`a` = `test`.`t3`.`a`) +EXPLAIN +SELECT /*+ SEMIJOIN(@subq1 LOOSESCAN, MATERIALIZATION, DUPSWEEDOUT) */ * FROM t2 +WHERE t2.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL index a a 4 NULL 3 100.00 Using index; LooseScan +1 SIMPLE t2 NULL ref a a 4 test.t3.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select /*+ SEMIJOIN(@`subq1` LOOSESCAN, MATERIALIZATION, DUPSWEEDOUT) */ `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t3`) where (`test`.`t2`.`a` = `test`.`t3`.`a`) +EXPLAIN +SELECT /*+ SEMIJOIN(@subq1 LOOSESCAN, FIRSTMATCH, MATERIALIZATION, +DUPSWEEDOUT) */ * FROM t2 +WHERE t2.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL index a a 4 NULL 3 100.00 Using index; LooseScan +1 SIMPLE t2 NULL ref a a 4 test.t3.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select /*+ SEMIJOIN(@`subq1` FIRSTMATCH, LOOSESCAN, MATERIALIZATION, DUPSWEEDOUT) */ `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t3`) where (`test`.`t2`.`a` = `test`.`t3`.`a`) +Disable another strategy +SET optimizer_switch='firstmatch=off'; +Turn on FirstMatch, but not LooseScan on with hint +EXPLAIN +SELECT /*+ SEMIJOIN(@subq1 FIRSTMATCH, MATERIALIZATION, DUPSWEEDOUT) */ * FROM t2 +WHERE t2.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL index a a 4 NULL 4 100.00 Using index +2 SIMPLE t3 NULL ref a a 4 test.t2.a 1 100.00 Using index; FirstMatch(t2) +Warnings: +Note 1003 /* select#1 */ select /*+ SEMIJOIN(@`subq1` FIRSTMATCH, MATERIALIZATION, DUPSWEEDOUT) */ `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t3`) where (`test`.`t3`.`a` = `test`.`t2`.`a`) +Drop all remaining strategies with hint, should use DuplicateWeedout +EXPLAIN +SELECT /*+ NO_SEMIJOIN(@subq1 MATERIALIZATION, DUPSWEEDOUT) */ * FROM t2 +WHERE t2.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL index a a 4 NULL 3 100.00 Using index; Start temporary +1 SIMPLE t2 NULL ref a a 4 test.t3.a 1 100.00 Using index; End temporary +Warnings: +Note 1003 /* select#1 */ select /*+ NO_SEMIJOIN(@`subq1` MATERIALIZATION, DUPSWEEDOUT) */ `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t3`) where (`test`.`t2`.`a` = `test`.`t3`.`a`) +For this query LooseScan and Materialization is not applicable +Should use DuplicateWeedout since FirstMatch is disabled +EXPLAIN +SELECT * FROM t1 +WHERE t1.b IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3 WHERE t3.b = t1.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL a NULL NULL NULL 3 100.00 Using where; Start temporary +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t3.b 1 25.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t3`) where ((`test`.`t1`.`a` = `test`.`t3`.`b`) and (`test`.`t1`.`b` = `test`.`t3`.`a`)) +Turn off all applicable strategies. DuplicateWeedout should still be used +EXPLAIN +SELECT /*+ NO_SEMIJOIN(@subq1 FIRSTMATCH, DUPSWEEDOUT) */ * FROM t1 +WHERE t1.b IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3 WHERE t3.b = t1.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL PRIMARY NULL NULL NULL 4 100.00 Using where +1 SIMPLE NULL eq_ref 9 test.t1.b,test.t1.a 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL a NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select /*+ NO_SEMIJOIN(@`subq1` FIRSTMATCH, DUPSWEEDOUT) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t3`) where ((``.`b` = `test`.`t1`.`a`) and (``.`a` = `test`.`t1`.`b`)) +Reverse which strategies are allowed with hint +EXPLAIN +SELECT /*+ SEMIJOIN(@subq1 LOOSESCAN, FIRSTMATCH) */ * FROM t1 +WHERE t1.b IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3 WHERE t3.b = t1.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL PRIMARY NULL NULL NULL 4 100.00 Using where +2 SIMPLE t3 NULL ref a a 4 test.t1.b 1 33.33 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select /*+ SEMIJOIN(@`subq1` FIRSTMATCH, LOOSESCAN) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t3`) where ((`test`.`t3`.`b` = `test`.`t1`.`a`) and (`test`.`t3`.`a` = `test`.`t1`.`b`)) +Default for this query is Loosecan for first and FirstMatch for latter +Since both strategies are disabled, will now use DuplicateWeedout +EXPLAIN +SELECT * FROM t1 +WHERE t1.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3) +AND t1.b IN (SELECT /*+ QB_NAME(subq2) */ a FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL index a a 4 NULL 3 100.00 Using index; Start temporary +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t3.a 1 100.00 Using where +1 SIMPLE t2 NULL ref a a 4 test.t1.b 1 100.00 Using index; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t3`) semi join (`test`.`t2`) where ((`test`.`t2`.`a` = `test`.`t1`.`b`) and (`test`.`t1`.`a` = `test`.`t3`.`a`)) +Allowing LooseScan and FirstMatch and optimizer_switch is ignored +EXPLAIN +SELECT /*+ SEMIJOIN(@subq1 LOOSESCAN, FIRSTMATCH) +SEMIJOIN(@subq2 LOOSESCAN, FIRSTMATCH) */ * FROM t1 +WHERE t1.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3) +AND t1.b IN (SELECT /*+ QB_NAME(subq2) */ a FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL index a a 4 NULL 3 100.00 Using index; LooseScan +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t3.a 1 100.00 Using where +1 SIMPLE t2 NULL ref a a 4 test.t1.b 1 100.00 Using index; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select /*+ SEMIJOIN(@`subq1` FIRSTMATCH, LOOSESCAN) SEMIJOIN(@`subq2` FIRSTMATCH, LOOSESCAN) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t3`) semi join (`test`.`t2`) where ((`test`.`t2`.`a` = `test`.`t1`.`b`) and (`test`.`t1`.`a` = `test`.`t3`.`a`)) +Forcing a disabled strategy for one +EXPLAIN +SELECT /*+ SEMIJOIN(@subq1 FIRSTMATCH) */ * FROM t1 +WHERE t1.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3) +AND t1.b IN (SELECT /*+ QB_NAME(subq2) */ a FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index a a 4 NULL 4 100.00 Using index; Start temporary +1 SIMPLE t1 NULL ALL PRIMARY NULL NULL NULL 4 25.00 Using where; End temporary; Using join buffer (hash join) +1 SIMPLE t3 NULL ref a a 4 test.t1.a 1 100.00 Using index; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select /*+ SEMIJOIN(@`subq1` FIRSTMATCH) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t3`) semi join (`test`.`t2`) where ((`test`.`t1`.`b` = `test`.`t2`.`a`) and (`test`.`t3`.`a` = `test`.`t1`.`a`)) +Forcing same strategy for both +EXPLAIN +SELECT /*+ SEMIJOIN(@subq1 FIRSTMATCH) SEMIJOIN(@subq2 FIRSTMATCH) */ * FROM t1 +WHERE t1.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3) +AND t1.b IN (SELECT /*+ QB_NAME(subq2) */ a FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL PRIMARY NULL NULL NULL 4 100.00 Using where +2 SIMPLE t3 NULL ref a a 4 test.t1.a 1 100.00 Using index; FirstMatch(t1) +2 SIMPLE t2 NULL ref a a 4 test.t1.b 1 100.00 Using index; FirstMatch(t3) +Warnings: +Note 1003 /* select#1 */ select /*+ SEMIJOIN(@`subq1` FIRSTMATCH) SEMIJOIN(@`subq2` FIRSTMATCH) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t3`) semi join (`test`.`t2`) where ((`test`.`t2`.`a` = `test`.`t1`.`b`) and (`test`.`t3`.`a` = `test`.`t1`.`a`)) +Swap strategies compared to default +EXPLAIN +SELECT /*+ SEMIJOIN(@subq1 FIRSTMATCH) SEMIJOIN(@subq2 LOOSESCAN) */ * FROM t1 +WHERE t1.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3) +AND t1.b IN (SELECT /*+ QB_NAME(subq2) */ a FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index a a 4 NULL 4 100.00 Using index; LooseScan +1 SIMPLE t1 NULL ALL PRIMARY NULL NULL NULL 4 25.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ref a a 4 test.t1.a 1 100.00 Using index; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select /*+ SEMIJOIN(@`subq1` FIRSTMATCH) SEMIJOIN(@`subq2` LOOSESCAN) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t3`) semi join (`test`.`t2`) where ((`test`.`t1`.`b` = `test`.`t2`.`a`) and (`test`.`t3`.`a` = `test`.`t1`.`a`)) +Different subsets of strategies for different subqueries +EXPLAIN +SELECT /*+ SEMIJOIN(@subq1 FIRSTMATCH, LOOSESCAN) +SEMIJOIN(@subq2 MATERIALIZATION, DUPSWEEDOUT) */ * FROM t1 +WHERE t1.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3) +AND t1.b IN (SELECT /*+ QB_NAME(subq2) */ a FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL index a a 4 NULL 3 100.00 Using index; LooseScan +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t3.a 1 100.00 Using where +1 SIMPLE NULL eq_ref 4 test.t1.b 1 100.00 NULL +3 MATERIALIZED t2 NULL index a a 4 NULL 4 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select /*+ SEMIJOIN(@`subq1` FIRSTMATCH, LOOSESCAN) SEMIJOIN(@`subq2` MATERIALIZATION, DUPSWEEDOUT) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t3`) semi join (`test`.`t2`) where ((``.`a` = `test`.`t1`.`b`) and (`test`.`t1`.`a` = `test`.`t3`.`a`)) +Turn off DuplicateWeedout for both. Materialization is left +EXPLAIN +SELECT /*+ NO_SEMIJOIN(@subq1 DUPSWEEDOUT) +NO_SEMIJOIN(@subq2 DUPSWEEDOUT) */ * FROM t1 +WHERE t1.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3) +AND t1.b IN (SELECT /*+ QB_NAME(subq2) */ a FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 .a 1 100.00 Using where +1 SIMPLE NULL eq_ref 4 test.t1.b 1 100.00 NULL +2 MATERIALIZED t3 NULL index a a 4 NULL 3 100.00 Using index +3 MATERIALIZED t2 NULL index a a 4 NULL 4 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select /*+ NO_SEMIJOIN(@`subq1` DUPSWEEDOUT) NO_SEMIJOIN(@`subq2` DUPSWEEDOUT) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t3`) semi join (`test`.`t2`) where ((``.`a` = `test`.`t1`.`b`) and (`test`.`t1`.`a` = ``.`a`)) +Forcing materialization should have same effect +EXPLAIN +SELECT /*+ SEMIJOIN(@subq1 MATERIALIZATION) +SEMIJOIN(@subq2 MATERIALIZATION) */ * FROM t1 +WHERE t1.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3) +AND t1.b IN (SELECT /*+ QB_NAME(subq2) */ a FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 .a 1 100.00 Using where +1 SIMPLE NULL eq_ref 4 test.t1.b 1 100.00 NULL +2 MATERIALIZED t3 NULL index a a 4 NULL 3 100.00 Using index +3 MATERIALIZED t2 NULL index a a 4 NULL 4 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select /*+ SEMIJOIN(@`subq1` MATERIALIZATION) SEMIJOIN(@`subq2` MATERIALIZATION) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t3`) semi join (`test`.`t2`) where ((``.`a` = `test`.`t1`.`b`) and (`test`.`t1`.`a` = ``.`a`)) +Turn off DuplicateWeedout for first. Materialization is used for both +EXPLAIN +SELECT /*+ NO_SEMIJOIN(@subq1 DUPSWEEDOUT) */ * FROM t1 +WHERE t1.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3) +AND t1.b IN (SELECT /*+ QB_NAME(subq2) */ a FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 .a 1 100.00 Using where +1 SIMPLE NULL eq_ref 4 test.t1.b 1 100.00 NULL +2 MATERIALIZED t3 NULL index a a 4 NULL 3 100.00 Using index +3 MATERIALIZED t2 NULL index a a 4 NULL 4 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select /*+ NO_SEMIJOIN(@`subq1` DUPSWEEDOUT) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t3`) semi join (`test`.`t2`) where ((``.`a` = `test`.`t1`.`b`) and (`test`.`t1`.`a` = ``.`a`)) +Turn off DuplicateWeedout for second. Same effect. +EXPLAIN +SELECT /*+ NO_SEMIJOIN(@subq2 DUPSWEEDOUT) */ * FROM t1 +WHERE t1.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3) +AND t1.b IN (SELECT /*+ QB_NAME(subq2) */ a FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL PRIMARY NULL NULL NULL 4 25.00 Using where; Using join buffer (hash join) +1 SIMPLE NULL eq_ref 4 test.t1.a 1 100.00 NULL +3 MATERIALIZED t2 NULL index a a 4 NULL 4 100.00 Using index +2 MATERIALIZED t3 NULL index a a 4 NULL 3 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select /*+ NO_SEMIJOIN(@`subq2` DUPSWEEDOUT) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t3`) semi join (`test`.`t2`) where ((`test`.`t1`.`b` = ``.`a`) and (``.`a` = `test`.`t1`.`a`)) +Enable all strategies except DuplicateWeedout +SET optimizer_switch='firstmatch=on,loosescan=on,materialization=on,duplicateweedout=off'; +If we turn off all other strategies, DuplicateWeedout will be used +EXPLAIN +SELECT /*+ NO_SEMIJOIN(@subq1 LOOSESCAN, FIRSTMATCH, MATERIALIZATION) */ * +FROM t2 +WHERE t2.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL index a a 4 NULL 3 100.00 Using index; Start temporary +1 SIMPLE t2 NULL ref a a 4 test.t3.a 1 100.00 Using index; End temporary +Warnings: +Note 1003 /* select#1 */ select /*+ NO_SEMIJOIN(@`subq1` FIRSTMATCH, LOOSESCAN, MATERIALIZATION) */ `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t3`) where (`test`.`t2`.`a` = `test`.`t3`.`a`) +LooseScan and Materialization is not applicable, FirstMatch is used +EXPLAIN +SELECT * FROM t1 +WHERE t1.b IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3 WHERE t3.b = t1.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL PRIMARY NULL NULL NULL 4 100.00 Using where +2 SIMPLE t3 NULL ref a a 4 test.t1.b 1 33.33 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t3`) where ((`test`.`t3`.`b` = `test`.`t1`.`a`) and (`test`.`t3`.`a` = `test`.`t1`.`b`)) +Turn off all applicable strategies. DuplicateWeedout should be used +EXPLAIN +SELECT /*+ NO_SEMIJOIN(@subq1 FIRSTMATCH) */ * FROM t1 +WHERE t1.b IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3 WHERE t3.b = t1.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL PRIMARY NULL NULL NULL 4 100.00 Using where +1 SIMPLE NULL eq_ref 9 test.t1.b,test.t1.a 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL a NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select /*+ NO_SEMIJOIN(@`subq1` FIRSTMATCH) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t3`) where ((``.`b` = `test`.`t1`.`a`) and (``.`a` = `test`.`t1`.`b`)) +Similar with SEMIJOIN hint +EXPLAIN +SELECT /*+ SEMIJOIN(@subq1 LOOSESCAN, MATERIALIZATION) */ * FROM t1 +WHERE t1.b IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3 WHERE t3.b = t1.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL PRIMARY NULL NULL NULL 4 100.00 Using where +1 SIMPLE NULL eq_ref 9 test.t1.b,test.t1.a 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL a NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select /*+ SEMIJOIN(@`subq1` LOOSESCAN, MATERIALIZATION) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t3`) where ((``.`b` = `test`.`t1`.`a`) and (``.`a` = `test`.`t1`.`b`)) +Disable all strategies +SET optimizer_switch='firstmatch=off,loosescan=off,materialization=off,duplicateweedout=off'; +DuplicateWeedout is then used +EXPLAIN +SELECT * FROM t2 WHERE t2.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL index a a 4 NULL 3 100.00 Using index; Start temporary +1 SIMPLE t2 NULL ref a a 4 test.t3.a 1 100.00 Using index; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t3`) where (`test`.`t2`.`a` = `test`.`t3`.`a`) +Turning off extra strategies should not change anything +EXPLAIN +SELECT /*+ NO_SEMIJOIN(@subq1 LOOSESCAN, DUPSWEEDOUT) */ * +FROM t2 +WHERE t2.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL index a a 4 NULL 3 100.00 Using index; Start temporary +1 SIMPLE t2 NULL ref a a 4 test.t3.a 1 100.00 Using index; End temporary +Warnings: +Note 1003 /* select#1 */ select /*+ NO_SEMIJOIN(@`subq1` LOOSESCAN, DUPSWEEDOUT) */ `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t3`) where (`test`.`t2`.`a` = `test`.`t3`.`a`) +Turning on some strategies should give one of those +EXPLAIN +SELECT /*+ SEMIJOIN(@subq1 FIRSTMATCH, MATERIALIZATION) */ * +FROM t2 +WHERE t2.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL index a a 4 NULL 4 100.00 Using index +2 SIMPLE t3 NULL ref a a 4 test.t2.a 1 100.00 Using index; FirstMatch(t2) +Warnings: +Note 1003 /* select#1 */ select /*+ SEMIJOIN(@`subq1` FIRSTMATCH, MATERIALIZATION) */ `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t3`) where (`test`.`t3`.`a` = `test`.`t2`.`a`) +For this query that cannot use LooseScan or Materialization, +turning those on will still give DupliateWeedout +EXPLAIN +SELECT /*+ SEMIJOIN(@subq1 LOOSESCAN, MATERIALIZATION) */ * FROM t1 +WHERE t1.b IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3 WHERE t3.b = t1.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL PRIMARY NULL NULL NULL 4 100.00 Using where +1 SIMPLE NULL eq_ref 9 test.t1.b,test.t1.a 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL a NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select /*+ SEMIJOIN(@`subq1` LOOSESCAN, MATERIALIZATION) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t3`) where ((``.`b` = `test`.`t1`.`a`) and (``.`a` = `test`.`t1`.`b`)) +Turning on FirstMatch should give FirstMatch +EXPLAIN +SELECT /*+ SEMIJOIN(@subq1 LOOSESCAN, FIRSTMATCH) */ * FROM t1 +WHERE t1.b IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3 WHERE t3.b = t1.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL PRIMARY NULL NULL NULL 4 100.00 Using where +2 SIMPLE t3 NULL ref a a 4 test.t1.b 1 33.33 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select /*+ SEMIJOIN(@`subq1` FIRSTMATCH, LOOSESCAN) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t3`) where ((`test`.`t3`.`b` = `test`.`t1`.`a`) and (`test`.`t3`.`a` = `test`.`t1`.`b`)) +SET optimizer_switch = default; +Test that setting optimizer_switch after prepare will change strategy +PREPARE stmt1 FROM "EXPLAIN +SELECT /*+ NO_SEMIJOIN(@subq1 FIRSTMATCH, LOOSESCAN) + NO_SEMIJOIN(@subq2 FIRSTMATCH, LOOSESCAN) */ * FROM t1 +WHERE t1.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3) + AND t1.b IN (SELECT /*+ QB_NAME(subq2) */ a FROM t2)"; +EXECUTE stmt1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL index a a 4 NULL 3 100.00 Using index; Start temporary +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t3.a 1 100.00 Using where +1 SIMPLE t2 NULL ref a a 4 test.t1.b 1 100.00 Using index; End temporary +Warnings: +Note 1003 /* select#1 */ select /*+ NO_SEMIJOIN(@`subq1` FIRSTMATCH, LOOSESCAN) NO_SEMIJOIN(@`subq2` FIRSTMATCH, LOOSESCAN) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t3`) semi join (`test`.`t2`) where ((`test`.`t2`.`a` = `test`.`t1`.`b`) and (`test`.`t1`.`a` = `test`.`t3`.`a`)) +SET optimizer_switch = 'duplicateweedout=off'; +Will now use materialization +EXECUTE stmt1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 .a 1 100.00 Using where +1 SIMPLE NULL eq_ref 4 test.t1.b 1 100.00 NULL +2 MATERIALIZED t3 NULL index a a 4 NULL 3 100.00 Using index +3 MATERIALIZED t2 NULL index a a 4 NULL 4 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select /*+ NO_SEMIJOIN(@`subq1` FIRSTMATCH, LOOSESCAN) NO_SEMIJOIN(@`subq2` FIRSTMATCH, LOOSESCAN) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t3`) semi join (`test`.`t2`) where ((``.`a` = `test`.`t1`.`b`) and (`test`.`t1`.`a` = ``.`a`)) +SET optimizer_switch = 'duplicateweedout=on'; +Turn DuplicateWeedout back on +EXECUTE stmt1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL index a a 4 NULL 3 100.00 Using index; Start temporary +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t3.a 1 100.00 Using where +1 SIMPLE t2 NULL ref a a 4 test.t1.b 1 100.00 Using index; End temporary +Warnings: +Note 1003 /* select#1 */ select /*+ NO_SEMIJOIN(@`subq1` FIRSTMATCH, LOOSESCAN) NO_SEMIJOIN(@`subq2` FIRSTMATCH, LOOSESCAN) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t3`) semi join (`test`.`t2`) where ((`test`.`t2`.`a` = `test`.`t1`.`b`) and (`test`.`t1`.`a` = `test`.`t3`.`a`)) +DEALLOCATE PREPARE stmt1; +SET optimizer_switch = default; +Specifying two SEMIJOIN/NO_SEMIJOIN for same query block gives warning +First has effect, second is ignored +EXPLAIN +SELECT * FROM t2 +WHERE t2.a IN (SELECT /*+ NO_SEMIJOIN() SEMIJOIN() */ a FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t2 NULL index NULL a 4 NULL 4 100.00 Using where; Using index +2 DEPENDENT SUBQUERY t1 NULL unique_subquery PRIMARY PRIMARY 4 func 1 100.00 Using index +Warnings: +Warning 3126 Hint SEMIJOIN( ) is ignored as conflicting/duplicated +Note 1003 /* select#1 */ select /*+ NO_SEMIJOIN(@`select#2`) */ `test`.`t2`.`a` AS `a` from `test`.`t2` where (`test`.`t2`.`a`,(((`test`.`t2`.`a`) in t1 on PRIMARY))) +Try opposite order +EXPLAIN +SELECT * FROM t2 +WHERE t2.a IN (SELECT /*+ SEMIJOIN() NO_SEMIJOIN() */ a FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL index a a 4 NULL 4 100.00 Using index +2 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.a 1 100.00 Using index +Warnings: +Warning 3126 Hint NO_SEMIJOIN( ) is ignored as conflicting/duplicated +Note 1003 /* select#1 */ select /*+ SEMIJOIN(@`select#2`) */ `test`.`t2`.`a` AS `a` from `test`.`t1` join `test`.`t2` where (`test`.`t1`.`a` = `test`.`t2`.`a`) +Specify at different levels, hint inside block has effect +EXPLAIN +SELECT /*+ NO_SEMIJOIN(@subq) */ * FROM t2 +WHERE t2.a IN (SELECT /*+ QB_NAME(subq) SEMIJOIN() */ a FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL index a a 4 NULL 4 100.00 Using index +2 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.a 1 100.00 Using index +Warnings: +Warning 3126 Hint NO_SEMIJOIN(@`subq` ) is ignored as conflicting/duplicated +Note 1003 /* select#1 */ select /*+ SEMIJOIN(@`subq`) */ `test`.`t2`.`a` AS `a` from `test`.`t1` join `test`.`t2` where (`test`.`t1`.`a` = `test`.`t2`.`a`) +Specify at different levels, opposite order +EXPLAIN +SELECT /*+ SEMIJOIN(@subq) */ * FROM t2 +WHERE t2.a IN (SELECT /*+ QB_NAME(subq) NO_SEMIJOIN() */ a FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t2 NULL index NULL a 4 NULL 4 100.00 Using where; Using index +2 DEPENDENT SUBQUERY t1 NULL unique_subquery PRIMARY PRIMARY 4 func 1 100.00 Using index +Warnings: +Warning 3126 Hint SEMIJOIN(@`subq` ) is ignored as conflicting/duplicated +Note 1003 /* select#1 */ select /*+ NO_SEMIJOIN(@`subq`) */ `test`.`t2`.`a` AS `a` from `test`.`t2` where (`test`.`t2`.`a`,(((`test`.`t2`.`a`) in t1 on PRIMARY))) +Duplicate hints also gives warning, but hint has effect +EXPLAIN +SELECT /*+ SEMIJOIN(@subq) */ * FROM t2 +WHERE t2.a IN (SELECT /*+ QB_NAME(subq) SEMIJOIN() */ a FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL index a a 4 NULL 4 100.00 Using index +2 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.a 1 100.00 Using index +Warnings: +Warning 3126 Hint SEMIJOIN(@`subq` ) is ignored as conflicting/duplicated +Note 1003 /* select#1 */ select /*+ SEMIJOIN(@`subq`) */ `test`.`t2`.`a` AS `a` from `test`.`t1` join `test`.`t2` where (`test`.`t1`.`a` = `test`.`t2`.`a`) +EXPLAIN +SELECT /*+ NO_SEMIJOIN(@subq) */ * FROM t2 +WHERE t2.a IN (SELECT /*+ QB_NAME(subq) NO_SEMIJOIN() */ a FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t2 NULL index NULL a 4 NULL 4 100.00 Using where; Using index +2 DEPENDENT SUBQUERY t1 NULL unique_subquery PRIMARY PRIMARY 4 func 1 100.00 Using index +Warnings: +Warning 3126 Hint NO_SEMIJOIN(@`subq` ) is ignored as conflicting/duplicated +Note 1003 /* select#1 */ select /*+ NO_SEMIJOIN(@`subq`) */ `test`.`t2`.`a` AS `a` from `test`.`t2` where (`test`.`t2`.`a`,(((`test`.`t2`.`a`) in t1 on PRIMARY))) +Multiple subqueries with conflicting hints +EXPLAIN +SELECT /*+ SEMIJOIN(@subq1 LOOSESCAN) SEMIJOIN(@subq2 FIRSTMATCH) */ * FROM t1 +WHERE t1.a IN (SELECT /*+ QB_NAME(subq1) NO_SEMIJOIN() */ a FROM t3) +AND t1.b IN (SELECT /*+ QB_NAME(subq2) SEMIJOIN(LOOSESCAN) */ a FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t2 NULL index a a 4 NULL 4 100.00 Using index; LooseScan +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; Using join buffer (hash join) +2 SUBQUERY t3 NULL index a a 4 NULL 3 100.00 Using index +Warnings: +Warning 3126 Hint SEMIJOIN(@`subq1` LOOSESCAN) is ignored as conflicting/duplicated +Warning 3126 Hint SEMIJOIN(@`subq2` FIRSTMATCH) is ignored as conflicting/duplicated +Note 1003 /* select#1 */ select /*+ NO_SEMIJOIN(@`subq1`) SEMIJOIN(@`subq2` LOOSESCAN) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`b` = `test`.`t2`.`a`) and (`test`.`t1`.`a`,`test`.`t1`.`a` in ( (/* select#2 */ select /*+ QB_NAME(`subq1`) */ `test`.`t3`.`a` from `test`.`t3` where true ), (`test`.`t1`.`a` in on where ((`test`.`t1`.`a` = ``.`a`)))))) +EXPLAIN +SELECT /*+ SEMIJOIN(@subq1 LOOSESCAN) SEMIJOIN(@subq2 FIRSTMATCH) */ * FROM t1 +WHERE t1.a IN (SELECT /*+ QB_NAME(subq1) NO_SEMIJOIN(LOOSESCAN) */ a FROM t3) +AND t1.b IN (SELECT /*+ QB_NAME(subq2) SEMIJOIN(LOOSESCAN) */ a FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index a a 4 NULL 4 100.00 Using index; LooseScan +1 SIMPLE t1 NULL ALL PRIMARY NULL NULL NULL 4 25.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ref a a 4 test.t1.a 1 100.00 Using index; FirstMatch(t1) +Warnings: +Warning 3126 Hint SEMIJOIN(@`subq1` LOOSESCAN) is ignored as conflicting/duplicated +Warning 3126 Hint SEMIJOIN(@`subq2` FIRSTMATCH) is ignored as conflicting/duplicated +Note 1003 /* select#1 */ select /*+ NO_SEMIJOIN(@`subq1` LOOSESCAN) SEMIJOIN(@`subq2` LOOSESCAN) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t3`) semi join (`test`.`t2`) where ((`test`.`t1`.`b` = `test`.`t2`.`a`) and (`test`.`t3`.`a` = `test`.`t1`.`a`)) +Conflicting hints in same hint comment +EXPLAIN +SELECT /*+ SEMIJOIN(@subq1 LOOSESCAN) SEMIJOIN(@subq1 FIRSTMATCH) */ * FROM t1 +WHERE t1.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3) +AND t1.b IN (SELECT /*+ QB_NAME(subq2) */ a FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL index a a 4 NULL 3 100.00 Using index; LooseScan +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t3.a 1 100.00 Using where +1 SIMPLE t2 NULL ref a a 4 test.t1.b 1 100.00 Using index; FirstMatch(t1) +Warnings: +Warning 3126 Hint SEMIJOIN(@`subq1` FIRSTMATCH) is ignored as conflicting/duplicated +Note 1003 /* select#1 */ select /*+ SEMIJOIN(@`subq1` LOOSESCAN) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t3`) semi join (`test`.`t2`) where ((`test`.`t2`.`a` = `test`.`t1`.`b`) and (`test`.`t1`.`a` = `test`.`t3`.`a`)) +EXPLAIN +SELECT /*+ SEMIJOIN(@subq1 LOOSESCAN) NO_SEMIJOIN(@subq1 LOOSESCAN) */ * +FROM t1 +WHERE t1.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3) +AND t1.b IN (SELECT /*+ QB_NAME(subq2) */ a FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL index a a 4 NULL 3 100.00 Using index; LooseScan +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t3.a 1 100.00 Using where +1 SIMPLE t2 NULL ref a a 4 test.t1.b 1 100.00 Using index; FirstMatch(t1) +Warnings: +Warning 3126 Hint NO_SEMIJOIN(@`subq1` LOOSESCAN) is ignored as conflicting/duplicated +Note 1003 /* select#1 */ select /*+ SEMIJOIN(@`subq1` LOOSESCAN) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t3`) semi join (`test`.`t2`) where ((`test`.`t2`.`a` = `test`.`t1`.`b`) and (`test`.`t1`.`a` = `test`.`t3`.`a`)) +EXPLAIN +SELECT /*+ NO_SEMIJOIN(@subq1 LOOSESCAN) NO_SEMIJOIN(@subq1 FIRSTMATCH) */ * +FROM t1 +WHERE t1.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3) +AND t1.b IN (SELECT /*+ QB_NAME(subq2) */ a FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index a a 4 NULL 4 100.00 Using index; LooseScan +1 SIMPLE t1 NULL ALL PRIMARY NULL NULL NULL 4 25.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ref a a 4 test.t1.a 1 100.00 Using index; FirstMatch(t1) +Warnings: +Warning 3126 Hint NO_SEMIJOIN(@`subq1` FIRSTMATCH) is ignored as conflicting/duplicated +Note 1003 /* select#1 */ select /*+ NO_SEMIJOIN(@`subq1` LOOSESCAN) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t3`) semi join (`test`.`t2`) where ((`test`.`t1`.`b` = `test`.`t2`.`a`) and (`test`.`t3`.`a` = `test`.`t1`.`a`)) +Non-supported strategies should give warnings +EXPLAIN +SELECT /*+ SEMIJOIN(@subq1 INTOEXISTS) NO_SEMIJOIN(@subq2 INTOEXISTS) */ * +FROM t1 +WHERE t1.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3) +AND t1.b IN (SELECT /*+ QB_NAME(subq2) */ a FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL index a a 4 NULL 3 100.00 Using index; LooseScan +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t3.a 1 100.00 Using where +1 SIMPLE t2 NULL ref a a 4 test.t1.b 1 100.00 Using index; FirstMatch(t1) +Warnings: +Warning 1064 Optimizer hint syntax error near 'INTOEXISTS) NO_SEMIJOIN(@subq2 INTOEXISTS) */ * +FROM t1 +WHERE t1.a IN (SELECT /*' at line 2 +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t3`) semi join (`test`.`t2`) where ((`test`.`t2`.`a` = `test`.`t1`.`b`) and (`test`.`t1`.`a` = `test`.`t3`.`a`)) +SUBQUERY tests +SUBQUERY should disable SEMIJOIN and use specified subquery strategy +EXPLAIN +SELECT * FROM t2 WHERE t2.a IN (SELECT /*+ SUBQUERY(INTOEXISTS) */ a FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t2 NULL index NULL a 4 NULL 4 100.00 Using where; Using index +2 DEPENDENT SUBQUERY t1 NULL unique_subquery PRIMARY PRIMARY 4 func 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select /*+ SUBQUERY(@`select#2` INTOEXISTS) */ `test`.`t2`.`a` AS `a` from `test`.`t2` where (`test`.`t2`.`a`,(((`test`.`t2`.`a`) in t1 on PRIMARY))) +EXPLAIN +SELECT /*+ SUBQUERY(@subq MATERIALIZATION) */ * FROM t2 +WHERE t2.a IN (SELECT /*+ QB_NAME(subq) */ a FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t2 NULL index NULL a 4 NULL 4 100.00 Using where; Using index +2 SUBQUERY t1 NULL index PRIMARY PRIMARY 4 NULL 4 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select /*+ SUBQUERY(@`subq` MATERIALIZATION) */ `test`.`t2`.`a` AS `a` from `test`.`t2` where (`test`.`t2`.`a`,`test`.`t2`.`a` in ( (/* select#2 */ select /*+ QB_NAME(`subq`) */ `test`.`t1`.`a` from `test`.`t1` where true ), (`test`.`t2`.`a` in on where ((`test`.`t2`.`a` = ``.`a`))))) +Query with two subqueries +EXPLAIN +SELECT /*+ SUBQUERY(@subq1 INTOEXISTS) SUBQUERY(@subq2 MATERIALIZATION) */ * +FROM t3 +WHERE t3.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t1 tx) +AND t3.b IN (SELECT /*+ QB_NAME(subq2) */ a FROM t1 ty); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t3 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +3 SUBQUERY ty NULL index PRIMARY PRIMARY 4 NULL 4 100.00 Using index +2 DEPENDENT SUBQUERY tx NULL unique_subquery PRIMARY PRIMARY 4 func 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select /*+ SUBQUERY(@`subq1` INTOEXISTS) SUBQUERY(@`subq2` MATERIALIZATION) */ `test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b` from `test`.`t3` where ((`test`.`t3`.`a`,(((`test`.`t3`.`a`) in t1 on PRIMARY))) and (`test`.`t3`.`b`,`test`.`t3`.`b` in ( (/* select#3 */ select /*+ QB_NAME(`subq2`) */ `test`.`ty`.`a` from `test`.`t1` `ty` where true ), (`test`.`t3`.`b` in on where ((`test`.`t3`.`b` = ``.`a`)))))) +Query with nested sub-queries +EXPLAIN +SELECT /*+ SUBQUERY(@subq1 INTOEXISTS) SUBQUERY(@subq2 MATERIALIZATION) */ * +FROM t3 +WHERE t3.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t1 tx +WHERE tx.b IN (SELECT /*+ QB_NAME(subq2) */ a FROM t1 ty)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t3 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY tx NULL unique_subquery PRIMARY PRIMARY 4 func 1 100.00 Using where +3 SUBQUERY ty NULL index PRIMARY PRIMARY 4 NULL 4 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select /*+ SUBQUERY(@`subq2` MATERIALIZATION) SUBQUERY(@`subq1` INTOEXISTS) */ `test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b` from `test`.`t3` where (`test`.`t3`.`a`,(((`test`.`t3`.`a`) in t1 on PRIMARY where (`test`.`tx`.`b`,`test`.`tx`.`b` in ( (/* select#3 */ select /*+ QB_NAME(`subq2`) */ `test`.`ty`.`a` from `test`.`t1` `ty` where true ), (`test`.`tx`.`b` in on where ((`test`.`tx`.`b` = ``.`a`)))))))) +EXPLAIN +SELECT /*+ SUBQUERY(@subq1 MATERIALIZATION) SUBQUERY(@subq2 INTOEXISTS) */ * +FROM t3 +WHERE t3.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t1 tx +WHERE tx.b IN (SELECT /*+ QB_NAME(subq2) */ a FROM t1 ty)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t3 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 SUBQUERY tx NULL ALL PRIMARY NULL NULL NULL 4 100.00 Using where +3 DEPENDENT SUBQUERY ty NULL unique_subquery PRIMARY PRIMARY 4 func 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select /*+ SUBQUERY(@`subq2` INTOEXISTS) SUBQUERY(@`subq1` MATERIALIZATION) */ `test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b` from `test`.`t3` where (`test`.`t3`.`a`,`test`.`t3`.`a` in ( (/* select#2 */ select /*+ QB_NAME(`subq1`) */ `test`.`tx`.`a` from `test`.`t1` `tx` where (`test`.`tx`.`b`,(((`test`.`tx`.`b`) in t1 on PRIMARY))) ), (`test`.`t3`.`a` in on where ((`test`.`t3`.`a` = ``.`a`))))) +This query does not support SEMIJOIN. Materialization is default +EXPLAIN +SELECT * FROM t2 +WHERE t2.a IN (SELECT /*+ QB_NAME(subq) */ min(a) FROM t1 group by a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t2 NULL index NULL a 4 NULL 4 100.00 Using where; Using index +2 SUBQUERY t1 NULL index PRIMARY PRIMARY 4 NULL 4 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` where (`test`.`t2`.`a`,`test`.`t2`.`a` in ( (/* select#2 */ select /*+ QB_NAME(`subq`) */ min(`test`.`t1`.`a`) from `test`.`t1` group by `test`.`t1`.`a` having true ), (`test`.`t2`.`a` in on where ((`test`.`t2`.`a` = ``.`min(a)`))))) +Use In-to-exists instead +EXPLAIN +SELECT /*+ SUBQUERY(@subq INTOEXISTS) */ * FROM t2 +WHERE t2.a IN (SELECT /*+ QB_NAME(subq) */ min(a) FROM t1 group by a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t2 NULL index NULL a 4 NULL 4 100.00 Using where; Using index +2 DEPENDENT SUBQUERY t1 NULL index PRIMARY PRIMARY 4 NULL 4 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select /*+ SUBQUERY(@`subq` INTOEXISTS) */ `test`.`t2`.`a` AS `a` from `test`.`t2` where (`test`.`t2`.`a`,(/* select#2 */ select /*+ QB_NAME(`subq`) */ min(`test`.`t1`.`a`) from `test`.`t1` group by `test`.`t1`.`a` having ((`test`.`t2`.`a`) = (min(`test`.`t1`.`a`))))) +For this query In-to-exists is default +EXPLAIN +SELECT a, a IN (SELECT a FROM t1) FROM t2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t2 NULL index NULL a 4 NULL 4 100.00 Using index +2 DEPENDENT SUBQUERY t1 NULL unique_subquery PRIMARY PRIMARY 4 func 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,(`test`.`t2`.`a`,(((`test`.`t2`.`a`) in t1 on PRIMARY))) AS `a IN (SELECT a FROM t1)` from `test`.`t2` +Force Subquery Materialization +EXPLAIN +SELECT a, a IN (SELECT /*+ SUBQUERY(MATERIALIZATION) */ a FROM t1) FROM t2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t2 NULL index NULL a 4 NULL 4 100.00 Using index +2 SUBQUERY t1 NULL index PRIMARY PRIMARY 4 NULL 4 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select /*+ SUBQUERY(@`select#2` MATERIALIZATION) */ `test`.`t2`.`a` AS `a`,(`test`.`t2`.`a`,`test`.`t2`.`a` in ( (/* select#2 */ select `test`.`t1`.`a` from `test`.`t1` where true ), (`test`.`t2`.`a` in on where ((`test`.`t2`.`a` = ``.`a`))))) AS `a IN (SELECT /*+ SUBQUERY(MATERIALIZATION) */ a FROM t1)` from `test`.`t2` +EXPLAIN +SELECT /*+ SUBQUERY(@subq MATERIALIZATION) */ a, +a IN (SELECT /*+ QB_NAME(subq) */ a FROM t1) FROM t2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t2 NULL index NULL a 4 NULL 4 100.00 Using index +2 SUBQUERY t1 NULL index PRIMARY PRIMARY 4 NULL 4 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select /*+ SUBQUERY(@`subq` MATERIALIZATION) */ `test`.`t2`.`a` AS `a`,(`test`.`t2`.`a`,`test`.`t2`.`a` in ( (/* select#2 */ select /*+ QB_NAME(`subq`) */ `test`.`t1`.`a` from `test`.`t1` where true ), (`test`.`t2`.`a` in on where ((`test`.`t2`.`a` = ``.`a`))))) AS `a IN (SELECT /*+ QB_NAME(subq) */ a FROM t1)` from `test`.`t2` +This query does not support Subquery Materialization due to type mismatch +EXPLAIN +SELECT * FROM t2 +WHERE t2.a IN (SELECT /*+ QB_NAME(subq) */ concat(sum(b),"") FROM t1 group by a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t2 NULL index NULL a 4 NULL 4 100.00 Using where; Using index +2 DEPENDENT SUBQUERY t1 NULL index PRIMARY PRIMARY 4 NULL 4 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` where (`test`.`t2`.`a`,(/* select#2 */ select /*+ QB_NAME(`subq`) */ concat(sum(`test`.`t1`.`b`),'') from `test`.`t1` group by `test`.`t1`.`a` having ((`test`.`t2`.`a`) = (concat(sum(`test`.`t1`.`b`),''))))) +Trying to force Subquery Materialization will not change anything +EXPLAIN +SELECT /*+ SUBQUERY(@subq MATERIALIZATION) */ * FROM t2 +WHERE t2.a IN (SELECT /*+ QB_NAME(subq) */ concat(sum(b),"") FROM t1 group by a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t2 NULL index NULL a 4 NULL 4 100.00 Using where; Using index +2 DEPENDENT SUBQUERY t1 NULL index PRIMARY PRIMARY 4 NULL 4 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select /*+ SUBQUERY(@`subq` MATERIALIZATION) */ `test`.`t2`.`a` AS `a` from `test`.`t2` where (`test`.`t2`.`a`,(/* select#2 */ select /*+ QB_NAME(`subq`) */ concat(sum(`test`.`t1`.`b`),'') from `test`.`t1` group by `test`.`t1`.`a` having ((`test`.`t2`.`a`) = (concat(sum(`test`.`t1`.`b`),''))))) +Test hints with prepared statements +PREPARE stmt1 FROM "EXPLAIN +SELECT /*+ SUBQUERY(@subq1 MATERIALIZATION) + SUBQUERY(@subq2 INTOEXISTS) */ * FROM t1 +WHERE t1.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3) + AND t1.b IN (SELECT /*+ QB_NAME(subq2) */ a FROM t2)"; +EXECUTE stmt1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +3 DEPENDENT SUBQUERY t2 NULL index_subquery a a 4 func 1 100.00 Using index +2 SUBQUERY t3 NULL index a a 4 NULL 3 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select /*+ SUBQUERY(@`subq1` MATERIALIZATION) SUBQUERY(@`subq2` INTOEXISTS) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`a`,`test`.`t1`.`a` in ( (/* select#2 */ select /*+ QB_NAME(`subq1`) */ `test`.`t3`.`a` from `test`.`t3` where true ), (`test`.`t1`.`a` in on where ((`test`.`t1`.`a` = ``.`a`))))) and (`test`.`t1`.`b`,(((`test`.`t1`.`b`) in t2 on a)))) +EXECUTE stmt1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +3 DEPENDENT SUBQUERY t2 NULL index_subquery a a 4 func 1 100.00 Using index +2 SUBQUERY t3 NULL index a a 4 NULL 3 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select /*+ SUBQUERY(@`subq1` MATERIALIZATION) SUBQUERY(@`subq2` INTOEXISTS) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`a`,`test`.`t1`.`a` in ( (/* select#2 */ select /*+ QB_NAME(`subq1`) */ `test`.`t3`.`a` from `test`.`t3` where true ), (`test`.`t1`.`a` in on where ((`test`.`t1`.`a` = ``.`a`))))) and (`test`.`t1`.`b`,(((`test`.`t1`.`b`) in t2 on a)))) +DEALLOCATE PREPARE stmt1; +Test optimizer_switch settings with SUBQUERY hint +SET optimizer_switch='materialization=off'; +This query will now use In-to-exist +EXPLAIN +SELECT * FROM t2 +WHERE t2.a IN (SELECT /*+ QB_NAME(subq) */ min(a) FROM t1 group by a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t2 NULL index NULL a 4 NULL 4 100.00 Using where; Using index +2 DEPENDENT SUBQUERY t1 NULL index PRIMARY PRIMARY 4 NULL 4 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` where (`test`.`t2`.`a`,(/* select#2 */ select /*+ QB_NAME(`subq`) */ min(`test`.`t1`.`a`) from `test`.`t1` group by `test`.`t1`.`a` having ((`test`.`t2`.`a`) = (min(`test`.`t1`.`a`))))) +Force it to use Materialization +EXPLAIN +SELECT /*+ SUBQUERY(@subq MATERIALIZATION) */ * FROM t2 +WHERE t2.a IN (SELECT /*+ QB_NAME(subq) */ min(a) FROM t1 group by a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t2 NULL index NULL a 4 NULL 4 100.00 Using where; Using index +2 SUBQUERY t1 NULL index PRIMARY PRIMARY 4 NULL 4 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select /*+ SUBQUERY(@`subq` MATERIALIZATION) */ `test`.`t2`.`a` AS `a` from `test`.`t2` where (`test`.`t2`.`a`,`test`.`t2`.`a` in ( (/* select#2 */ select /*+ QB_NAME(`subq`) */ min(`test`.`t1`.`a`) from `test`.`t1` group by `test`.`t1`.`a` having true ), (`test`.`t2`.`a` in on where ((`test`.`t2`.`a` = ``.`min(a)`))))) +SET optimizer_switch='materialization=on,subquery_materialization_cost_based=off'; +This query will now use materialization +EXPLAIN +SELECT a, a IN (SELECT a FROM t1) FROM t2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t2 NULL index NULL a 4 NULL 4 100.00 Using index +2 SUBQUERY t1 NULL index PRIMARY PRIMARY 4 NULL 4 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,(`test`.`t2`.`a`,`test`.`t2`.`a` in ( (/* select#2 */ select `test`.`t1`.`a` from `test`.`t1` where true ), (`test`.`t2`.`a` in on where ((`test`.`t2`.`a` = ``.`a`))))) AS `a IN (SELECT a FROM t1)` from `test`.`t2` +Force In-to-exists +EXPLAIN +SELECT /*+ SUBQUERY(@subq INTOEXISTS) */ a, +a IN (SELECT /*+ QB_NAME(subq) */ a FROM t1) FROM t2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t2 NULL index NULL a 4 NULL 4 100.00 Using index +2 DEPENDENT SUBQUERY t1 NULL unique_subquery PRIMARY PRIMARY 4 func 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select /*+ SUBQUERY(@`subq` INTOEXISTS) */ `test`.`t2`.`a` AS `a`,(`test`.`t2`.`a`,(((`test`.`t2`.`a`) in t1 on PRIMARY))) AS `a IN (SELECT /*+ QB_NAME(subq) */ a FROM t1)` from `test`.`t2` +Specifying both strategies should give a warning +EXPLAIN +SELECT /*+ SUBQUERY(@subq1 MATERIALIZATION, INTOEXISTS) +SUBQUERY(@subq2 MATERIALIZATION, INTOEXISTS) */ * +FROM t3 +WHERE t3.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t1 tx) +AND t3.b IN (SELECT /*+ QB_NAME(subq2) */ a FROM t1 ty); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t3 NULL ALL a NULL NULL NULL 3 100.00 Using where +2 SIMPLE tx NULL eq_ref PRIMARY PRIMARY 4 test.t3.a 1 100.00 Using index +2 SIMPLE ty NULL eq_ref PRIMARY PRIMARY 4 test.t3.b 1 100.00 Using index +Warnings: +Warning 1064 Optimizer hint syntax error near ', INTOEXISTS) +SUBQUERY(@subq2 MATERIALIZATION, INTOEXISTS) */ * +FROM t3 +WHERE t3' at line 2 +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b` from `test`.`t1` `tx` join `test`.`t1` `ty` join `test`.`t3` where ((`test`.`ty`.`a` = `test`.`t3`.`b`) and (`test`.`tx`.`a` = `test`.`t3`.`a`)) +Non-supported strategies should give warnings +EXPLAIN +SELECT /*+ SUBQUERY(@subq1 FIRSTMATCH) SUBQUERY(@subq2 LOOSESCAN) */ * +FROM t3 +WHERE t3.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t1 tx) +AND t3.b IN (SELECT /*+ QB_NAME(subq2) */ a FROM t1 ty); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t3 NULL ALL a NULL NULL NULL 3 100.00 Using where +2 SIMPLE tx NULL eq_ref PRIMARY PRIMARY 4 test.t3.a 1 100.00 Using index +2 SIMPLE ty NULL eq_ref PRIMARY PRIMARY 4 test.t3.b 1 100.00 Using index +Warnings: +Warning 1064 Optimizer hint syntax error near 'FIRSTMATCH) SUBQUERY(@subq2 LOOSESCAN) */ * +FROM t3 +WHERE t3.a IN (SELECT /*+ QB' at line 2 +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b` from `test`.`t1` `tx` join `test`.`t1` `ty` join `test`.`t3` where ((`test`.`ty`.`a` = `test`.`t3`.`b`) and (`test`.`tx`.`a` = `test`.`t3`.`a`)) +SET optimizer_switch= default; +Specifying two SUBQUERY for same query block gives warning +First has effect, second is ignored +EXPLAIN +SELECT * FROM t2 +WHERE t2.a IN (SELECT /*+ SUBQUERY(MATERIALIZATION) SUBQUERY(INTOEXISTS) */ a +FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t2 NULL index NULL a 4 NULL 4 100.00 Using where; Using index +2 SUBQUERY t1 NULL index PRIMARY PRIMARY 4 NULL 4 100.00 Using index +Warnings: +Warning 3126 Hint SUBQUERY( INTOEXISTS) is ignored as conflicting/duplicated +Note 1003 /* select#1 */ select /*+ SUBQUERY(@`select#2` MATERIALIZATION) */ `test`.`t2`.`a` AS `a` from `test`.`t2` where (`test`.`t2`.`a`,`test`.`t2`.`a` in ( (/* select#2 */ select `test`.`t1`.`a` from `test`.`t1` where true ), (`test`.`t2`.`a` in on where ((`test`.`t2`.`a` = ``.`a`))))) +Try opposite order +EXPLAIN +SELECT * FROM t2 +WHERE t2.a IN (SELECT /*+ SUBQUERY(INTOEXISTS) SUBQUERY(MATERIALIZATION) */ a +FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t2 NULL index NULL a 4 NULL 4 100.00 Using where; Using index +2 DEPENDENT SUBQUERY t1 NULL unique_subquery PRIMARY PRIMARY 4 func 1 100.00 Using index +Warnings: +Warning 3126 Hint SUBQUERY( MATERIALIZATION) is ignored as conflicting/duplicated +Note 1003 /* select#1 */ select /*+ SUBQUERY(@`select#2` INTOEXISTS) */ `test`.`t2`.`a` AS `a` from `test`.`t2` where (`test`.`t2`.`a`,(((`test`.`t2`.`a`) in t1 on PRIMARY))) +Specify at different levels, hint inside block has effect +EXPLAIN +SELECT /*+ SUBQUERY(@subq MATERIALIZATION) */ * FROM t2 +WHERE t2.a IN (SELECT /*+ QB_NAME(subq) SUBQUERY(INTOEXISTS) */ a FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t2 NULL index NULL a 4 NULL 4 100.00 Using where; Using index +2 DEPENDENT SUBQUERY t1 NULL unique_subquery PRIMARY PRIMARY 4 func 1 100.00 Using index +Warnings: +Warning 3126 Hint SUBQUERY(@`subq` MATERIALIZATION) is ignored as conflicting/duplicated +Note 1003 /* select#1 */ select /*+ SUBQUERY(@`subq` INTOEXISTS) */ `test`.`t2`.`a` AS `a` from `test`.`t2` where (`test`.`t2`.`a`,(((`test`.`t2`.`a`) in t1 on PRIMARY))) +Specify at different levels, opposite order +EXPLAIN +SELECT /*+ SUBQUERY(@subq INTOEXISTS) */ * FROM t2 +WHERE t2.a IN (SELECT /*+ QB_NAME(subq) SUBQUERY(MATERIALIZATION) */ a FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t2 NULL index NULL a 4 NULL 4 100.00 Using where; Using index +2 SUBQUERY t1 NULL index PRIMARY PRIMARY 4 NULL 4 100.00 Using index +Warnings: +Warning 3126 Hint SUBQUERY(@`subq` INTOEXISTS) is ignored as conflicting/duplicated +Note 1003 /* select#1 */ select /*+ SUBQUERY(@`subq` MATERIALIZATION) */ `test`.`t2`.`a` AS `a` from `test`.`t2` where (`test`.`t2`.`a`,`test`.`t2`.`a` in ( (/* select#2 */ select /*+ QB_NAME(`subq`) */ `test`.`t1`.`a` from `test`.`t1` where true ), (`test`.`t2`.`a` in on where ((`test`.`t2`.`a` = ``.`a`))))) +Specifying combinations of SUBQUERY and SEMIJOIN/NO_SEMIJOIN +for same query block gives warning +First has effect, second is ignored +EXPLAIN +SELECT * FROM t2 +WHERE t2.a IN (SELECT /*+ SUBQUERY(INTOEXISTS) SEMIJOIN() */ a FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t2 NULL index NULL a 4 NULL 4 100.00 Using where; Using index +2 DEPENDENT SUBQUERY t1 NULL unique_subquery PRIMARY PRIMARY 4 func 1 100.00 Using index +Warnings: +Warning 3126 Hint SEMIJOIN( ) is ignored as conflicting/duplicated +Note 1003 /* select#1 */ select /*+ SUBQUERY(@`select#2` INTOEXISTS) */ `test`.`t2`.`a` AS `a` from `test`.`t2` where (`test`.`t2`.`a`,(((`test`.`t2`.`a`) in t1 on PRIMARY))) +Try opposite order +EXPLAIN +SELECT * FROM t2 +WHERE t2.a IN (SELECT /*+ NO_SEMIJOIN() SUBQUERY(MATERIALIZATION) */ a FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t2 NULL index NULL a 4 NULL 4 100.00 Using where; Using index +2 DEPENDENT SUBQUERY t1 NULL unique_subquery PRIMARY PRIMARY 4 func 1 100.00 Using index +Warnings: +Warning 3126 Hint SUBQUERY( MATERIALIZATION) is ignored as conflicting/duplicated +Note 1003 /* select#1 */ select /*+ NO_SEMIJOIN(@`select#2`) */ `test`.`t2`.`a` AS `a` from `test`.`t2` where (`test`.`t2`.`a`,(((`test`.`t2`.`a`) in t1 on PRIMARY))) +Specify at different levels, hint inside block has effect +EXPLAIN +SELECT /*+ SUBQUERY(@subq MATERIALIZATION) */ * FROM t2 +WHERE t2.a IN (SELECT /*+ QB_NAME(subq) SEMIJOIN() */ a FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL index a a 4 NULL 4 100.00 Using index +2 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.a 1 100.00 Using index +Warnings: +Warning 3126 Hint SUBQUERY(@`subq` MATERIALIZATION) is ignored as conflicting/duplicated +Note 1003 /* select#1 */ select /*+ SEMIJOIN(@`subq`) */ `test`.`t2`.`a` AS `a` from `test`.`t1` join `test`.`t2` where (`test`.`t1`.`a` = `test`.`t2`.`a`) +EXPLAIN +SELECT /*+ SUBQUERY(@subq INTOEXISTS) */ * FROM t2 +WHERE t2.a IN (SELECT /*+ QB_NAME(subq) NO_SEMIJOIN() */ a FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t2 NULL index NULL a 4 NULL 4 100.00 Using where; Using index +2 DEPENDENT SUBQUERY t1 NULL unique_subquery PRIMARY PRIMARY 4 func 1 100.00 Using index +Warnings: +Warning 3126 Hint SUBQUERY(@`subq` INTOEXISTS) is ignored as conflicting/duplicated +Note 1003 /* select#1 */ select /*+ NO_SEMIJOIN(@`subq`) */ `test`.`t2`.`a` AS `a` from `test`.`t2` where (`test`.`t2`.`a`,(((`test`.`t2`.`a`) in t1 on PRIMARY))) +EXPLAIN +SELECT /*+ SEMIJOIN(@subq FIRSTMATCH) */ * FROM t2 +WHERE t2.a IN (SELECT /*+ QB_NAME(subq) SUBQUERY(@subq INTOEXISTS) */ a FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t2 NULL index NULL a 4 NULL 4 100.00 Using where; Using index +2 DEPENDENT SUBQUERY t1 NULL unique_subquery PRIMARY PRIMARY 4 func 1 100.00 Using index +Warnings: +Warning 3126 Hint SEMIJOIN(@`subq` FIRSTMATCH) is ignored as conflicting/duplicated +Note 1003 /* select#1 */ select /*+ SUBQUERY(@`subq` INTOEXISTS) */ `test`.`t2`.`a` AS `a` from `test`.`t2` where (`test`.`t2`.`a`,(((`test`.`t2`.`a`) in t1 on PRIMARY))) +drop table t1, t2, t3; diff --git a/mysql-test/r/order_by_limit.result-pq b/mysql-test/r/order_by_limit.result-pq new file mode 100644 index 000000000000..2438bd862363 --- /dev/null +++ b/mysql-test/r/order_by_limit.result-pq @@ -0,0 +1,477 @@ +# +# WL#6986 : Make switching of index due to order by limit cost based +# +# Testcase for Bug#16522053 +CREATE TABLE t1 ( +pk INT PRIMARY KEY AUTO_INCREMENT, +i INT, +j INT, +INDEX (i), +INDEX (j) +); +INSERT INTO t1 (i,j) VALUES (1,1); +set @d=1; +INSERT INTO t1 (i,j) SELECT i+@d, j+@d from t1; +set @d=@d*2; +INSERT INTO t1 (i,j) SELECT i+@d, j+@d from t1; +set @d=@d*2; +INSERT INTO t1 (i,j) SELECT i+@d, j+@d from t1; +set @d=@d*2; +INSERT INTO t1 (i,j) SELECT i+@d, j+@d from t1; +set @d=@d*2; +INSERT INTO t1 (i,j) SELECT i+@d, j+@d from t1; +set @d=@d*2; +INSERT INTO t1 (i,j) SELECT i+@d, j+@d from t1; +set @d=@d*2; +INSERT INTO t1 (i,j) SELECT i+@d, j+@d from t1; +set @d=@d*2; +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT * FROM t1 +WHERE i<100 AND j<10 +ORDER BY i LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 9 77.34 Parallel execute (1 workers) +2 SIMPLE t1 NULL range i,j j 5 NULL 9 77.34 Using index condition; Using where; Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`i` AS `i`,`test`.`t1`.`j` AS `j` from `test`.`t1` where ((`test`.`t1`.`i` < 100) and (`test`.`t1`.`j` < 10)) order by `test`.`t1`.`i` limit 5 +SELECT * FROM t1 +WHERE i<100 AND j<10 +ORDER BY i LIMIT 5; +pk i j +1 1 1 +2 2 2 +3 3 3 +4 4 4 +6 5 5 +DROP TABLE t1; +CREATE TABLE t0 ( +i0 INTEGER NOT NULL +); +INSERT INTO t0 VALUES (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +CREATE TABLE t1 ( +pk INTEGER PRIMARY KEY, +i1 INTEGER NOT NULL, +i2 INTEGER NOT NULL, +INDEX k1 (i1), +INDEX k2 (i1,i2) +) ENGINE=InnoDB; +INSERT INTO t1 +SELECT a0.i0 + 10*a1.i0 + 100*a0.i0 + 1000*a1.i0, +(a0.i0 + 10*a1.i0 + 100*a0.i0 + 1000*a1.i0) % 1000, +(a0.i0 + 10*a1.i0 + 100*a0.i0 + 1000*a1.i0) % 1000 +FROM t0 AS a0, t0 AS a1; +CREATE TABLE t2 ( +pk INTEGER PRIMARY KEY, +i1 INTEGER NOT NULL, +INDEX k1 (i1) +) ENGINE=InnoDB; +INSERT INTO t2 +SELECT a0.i0 + 10*a1.i0 + 100*a0.i0 + 1000*a1.i0, +(a0.i0 + 10*a1.i0 + 100*a0.i0 + 1000*a1.i0) % 500 +FROM t0 AS a0, t0 AS a1; +ANALYZE TABLE t1,t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +# Query should use index to optimize the ORDER BY LIMIT +EXPLAIN SELECT * FROM t1 STRAIGHT_JOIN t2 ON t1.i1=t2.i1 +WHERE t1.pk > 7000 and t1.i1 > 2 +ORDER BY t1.i1 LIMIT 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 6 29.70 Parallel execute (1 workers) +2 SIMPLE t1 NULL index PRIMARY,k1,k2 k1 4 NULL 6 29.70 Using where +2 SIMPLE t2 NULL ref k1 k1 4 test.t1.i1 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`i1` AS `i1`,`test`.`t1`.`i2` AS `i2`,`test`.`t2`.`pk` AS `pk`,`test`.`t2`.`i1` AS `i1` from `test`.`t1` straight_join `test`.`t2` where ((`test`.`t2`.`i1` = `test`.`t1`.`i1`) and (`test`.`t1`.`pk` > 7000) and (`test`.`t1`.`i1` > 2)) order by `test`.`t1`.`i1` limit 2 +# Query should not make the switch to use index to +# optimize ORDER BY LIMIT. So should be using filesort +EXPLAIN SELECT * FROM t1 STRAIGHT_JOIN t2 ON t1.i1=t2.i1 +WHERE t1.pk > 7000 and t1.i1 > 2 +ORDER BY t1.i1 LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 30 99.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range PRIMARY,k1,k2 PRIMARY 4 NULL 30 99.00 Using where; Using filesort +2 SIMPLE t2 NULL ref k1 k1 4 test.t1.i1 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`i1` AS `i1`,`test`.`t1`.`i2` AS `i2`,`test`.`t2`.`pk` AS `pk`,`test`.`t2`.`i1` AS `i1` from `test`.`t1` straight_join `test`.`t2` where ((`test`.`t2`.`i1` = `test`.`t1`.`i1`) and (`test`.`t1`.`pk` > 7000) and (`test`.`t1`.`i1` > 2)) order by `test`.`t1`.`i1` limit 5 +SELECT * FROM t1 STRAIGHT_JOIN t2 ON t1.i1=t2.i1 +WHERE t1.pk > 7000 and t1.i1 > 2 +ORDER BY t1.i1 LIMIT 5; +pk i1 i2 pk i1 +7070 70 70 7070 70 +8080 80 80 8080 80 +9090 90 90 9090 90 +7171 171 171 7171 171 +8181 181 181 8181 181 +# Changing range condition on i1 should make +# key on i1 get picked to give the order +EXPLAIN SELECT * FROM t1 STRAIGHT_JOIN t2 ON t1.i1=t2.i1 +WHERE t1.pk > 7000 and t1.i1 > 800 +ORDER BY t1.i1 LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 20 30.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range PRIMARY,k1,k2 k2 4 NULL 20 30.00 Using where; Using index +2 SIMPLE t2 NULL ref k1 k1 4 test.t1.i1 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`i1` AS `i1`,`test`.`t1`.`i2` AS `i2`,`test`.`t2`.`pk` AS `pk`,`test`.`t2`.`i1` AS `i1` from `test`.`t1` straight_join `test`.`t2` where ((`test`.`t2`.`i1` = `test`.`t1`.`i1`) and (`test`.`t1`.`pk` > 7000) and (`test`.`t1`.`i1` > 800)) order by `test`.`t1`.`i1` limit 5 +SELECT * FROM t1 STRAIGHT_JOIN t2 ON t1.i1=t2.i1 +WHERE t1.pk > 7000 and t1.i1 > 800 +ORDER BY t1.i1 LIMIT 5; +pk i1 i2 pk i1 +# Use range condition only on pk to see if switch +# happens just for ORDER BY LIMIT +# Should not happen unless range results in too +# many records +EXPLAIN SELECT * FROM t1 STRAIGHT_JOIN t2 ON t1.i1=t2.i1 +WHERE t1.pk > 7000 ORDER BY t1.i1 LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 30 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range PRIMARY,k1,k2 PRIMARY 4 NULL 30 100.00 Using where; Using filesort +2 SIMPLE t2 NULL ref k1 k1 4 test.t1.i1 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`i1` AS `i1`,`test`.`t1`.`i2` AS `i2`,`test`.`t2`.`pk` AS `pk`,`test`.`t2`.`i1` AS `i1` from `test`.`t1` straight_join `test`.`t2` where ((`test`.`t2`.`i1` = `test`.`t1`.`i1`) and (`test`.`t1`.`pk` > 7000)) order by `test`.`t1`.`i1` limit 5 +SELECT * FROM t1 STRAIGHT_JOIN t2 ON t1.i1=t2.i1 +WHERE t1.pk > 7000 ORDER BY t1.i1 LIMIT 5; +pk i1 i2 pk i1 +7070 70 70 7070 70 +8080 80 80 8080 80 +9090 90 90 9090 90 +7171 171 171 7171 171 +8181 181 181 8181 181 +EXPLAIN SELECT * FROM t1 STRAIGHT_JOIN t2 ON t1.i1=t2.i1 +WHERE t1.pk > 1000 ORDER BY t1.i1 LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 90.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index PRIMARY,k1,k2 k1 4 NULL 5 90.00 Using where +2 SIMPLE t2 NULL ref k1 k1 4 test.t1.i1 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`i1` AS `i1`,`test`.`t1`.`i2` AS `i2`,`test`.`t2`.`pk` AS `pk`,`test`.`t2`.`i1` AS `i1` from `test`.`t1` straight_join `test`.`t2` where ((`test`.`t2`.`i1` = `test`.`t1`.`i1`) and (`test`.`t1`.`pk` > 1000)) order by `test`.`t1`.`i1` limit 5 +SELECT * FROM t1 STRAIGHT_JOIN t2 ON t1.i1=t2.i1 +WHERE t1.pk > 1000 ORDER BY t1.i1 LIMIT 5; +pk i1 i2 pk i1 +1010 10 10 1010 10 +2020 20 20 2020 20 +3030 30 30 3030 30 +4040 40 40 4040 40 +5050 50 50 5050 50 +# check if switch happens when the index for order +# by is non-covering +EXPLAIN SELECT t1.i1,t1.i2 FROM t1 STRAIGHT_JOIN t2 ON t1.i1=t2.i1 +WHERE t1.pk > 100 ORDER BY t1.i1 LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 99.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index PRIMARY,k1,k2 k1 4 NULL 5 99.00 Using where +2 SIMPLE t2 NULL ref k1 k1 4 test.t1.i1 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i1` AS `i1`,`test`.`t1`.`i2` AS `i2` from `test`.`t1` straight_join `test`.`t2` where ((`test`.`t2`.`i1` = `test`.`t1`.`i1`) and (`test`.`t1`.`pk` > 100)) order by `test`.`t1`.`i1` limit 5 +SELECT t1.i1,t1.i2 FROM t1 STRAIGHT_JOIN t2 ON t1.i1=t2.i1 +WHERE t1.pk > 100 ORDER BY t1.i1 LIMIT 5; +i1 i2 +10 10 +20 20 +30 30 +40 40 +50 50 +# Reduce the fanout for table t2 and check +# that index for order by is not choosen +EXPLAIN SELECT * FROM t1 STRAIGHT_JOIN t2 ON t1.i1=t2.i1 +WHERE t1.pk > 7000 and t2.pk = 100 ORDER BY t1.i1 LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 30 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range PRIMARY,k1,k2 PRIMARY 4 NULL 30 100.00 Using where; Using filesort +2 SIMPLE t2 NULL const PRIMARY,k1 PRIMARY 4 const 1 5.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`i1` AS `i1`,`test`.`t1`.`i2` AS `i2`,`test`.`t2`.`pk` AS `pk`,`test`.`t2`.`i1` AS `i1` from `test`.`t1` straight_join `test`.`t2` where ((`test`.`t2`.`i1` = `test`.`t1`.`i1`) and (`test`.`t2`.`pk` = 100) and (`test`.`t1`.`pk` > 7000)) order by `test`.`t1`.`i1` limit 5 +SELECT * FROM t1 STRAIGHT_JOIN t2 ON t1.i1=t2.i1 +WHERE t1.pk > 7000 and t2.pk = 100 ORDER BY t1.i1 LIMIT 5; +pk i1 i2 pk i1 +# Increase the fanout to see if index gets choosen +# for order by for which range scan was choosen +# earlier +INSERT INTO t2 +SELECT a0.i0 + 10*a1.i0 + 100*a0.i0 + 1000*a1.i0 + 1, +(a0.i0 + 10*a1.i0 + 100*a0.i0 + 1000*a1.i0) % 500 +FROM t0 AS a0, t0 AS a1; +ANALYZE TABLE t2; +Table Op Msg_type Msg_text +test.t2 analyze status OK +EXPLAIN SELECT * FROM t1 STRAIGHT_JOIN t2 ON t1.i1=t2.i1 +WHERE t1.pk > 7000 ORDER BY t1.i1 LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 6 30.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index PRIMARY,k1,k2 k1 4 NULL 6 30.00 Using where +2 SIMPLE t2 NULL ref k1 k1 4 test.t1.i1 2 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`i1` AS `i1`,`test`.`t1`.`i2` AS `i2`,`test`.`t2`.`pk` AS `pk`,`test`.`t2`.`i1` AS `i1` from `test`.`t1` straight_join `test`.`t2` where ((`test`.`t2`.`i1` = `test`.`t1`.`i1`) and (`test`.`t1`.`pk` > 7000)) order by `test`.`t1`.`i1` limit 5 +SELECT * FROM t1 STRAIGHT_JOIN t2 ON t1.i1=t2.i1 +WHERE t1.pk > 7000 ORDER BY t1.i1 LIMIT 5; +pk i1 i2 pk i1 +7070 70 70 7070 70 +7070 70 70 7071 70 +8080 80 80 8080 80 +8080 80 80 8081 80 +9090 90 90 9090 90 +# Check if the index for order by is used when +# force index is done on order by +EXPLAIN SELECT * FROM t1 FORCE INDEX FOR ORDER BY (k2) STRAIGHT_JOIN t2 ON +t1.i1=t2.i1 WHERE t1.pk > 7000 ORDER BY t1.i1 LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 6 30.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index PRIMARY,k1,k2 k2 8 NULL 6 30.00 Using where; Using index +2 SIMPLE t2 NULL ref k1 k1 4 test.t1.i1 2 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`i1` AS `i1`,`test`.`t1`.`i2` AS `i2`,`test`.`t2`.`pk` AS `pk`,`test`.`t2`.`i1` AS `i1` from `test`.`t1` FORCE INDEX FOR ORDER BY (`k2`) straight_join `test`.`t2` where ((`test`.`t2`.`i1` = `test`.`t1`.`i1`) and (`test`.`t1`.`pk` > 7000)) order by `test`.`t1`.`i1` limit 5 +SELECT * FROM t1 FORCE INDEX FOR ORDER BY (k2) STRAIGHT_JOIN t2 ON +t1.i1=t2.i1 WHERE t1.pk > 7000 ORDER BY t1.i1 LIMIT 5; +pk i1 i2 pk i1 +7070 70 70 7070 70 +7070 70 70 7071 70 +8080 80 80 8080 80 +8080 80 80 8081 80 +9090 90 90 9090 90 +DROP TABLE t0, t1, t2; +# +# Bug #26483909: INCORRECT BEHAVIOR FOR QUERY WITH DISTINCT +# and ORDER BY ... LIMIT. +# +CREATE TABLE t1 ( +pk int(11) NOT NULL, +col_int int(11), +col_varchar_key varchar(20), +PRIMARY KEY (pk), +KEY col_varchar_key (col_varchar_key), +KEY col_varchar_key_2 (col_varchar_key(5)) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (1,2,'t'), (2,5,'efqsdksj'), +(3,NULL,'fqsdksjijcs'),(4,8,'qsdksjijc'), +(5,40,NULL),(6,3,'dkz'),(7,2,NULL), +(8,3,'dks'),(9,0,'ksjijcsz'), +(10,84,'sjijcszxwbjj'); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +SET @@SESSION.sql_mode='NO_ENGINE_SUBSTITUTION'; +EXPLAIN SELECT DISTINCT col_int +FROM t1 +WHERE col_varchar_key <> 'c' + OR col_varchar_key > 'w' +ORDER BY col_varchar_key +LIMIT 100; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range col_varchar_key,col_varchar_key_2 col_varchar_key_2 23 NULL 8 100.00 Using where; Using temporary; Using filesort +Warnings: +Note 1003 /* select#1 */ select distinct `test`.`t1`.`col_int` AS `col_int` from `test`.`t1` where ((`test`.`t1`.`col_varchar_key` <> 'c') or (`test`.`t1`.`col_varchar_key` > 'w')) order by `test`.`t1`.`col_varchar_key` limit 100 +SELECT DISTINCT col_int +FROM t1 +WHERE col_varchar_key <> 'c' + OR col_varchar_key > 'w' +ORDER BY col_varchar_key +LIMIT 100; +col_int +3 +5 +NULL +0 +8 +84 +2 +DROP TABLE t1; +# +# Bug#29487181 INCORRECT 'ROWS' AND 'FILTERED' ESTIMATE IN +# 'ORDER BY ... LIMIT .' QUERIES +# +CREATE TABLE t1 ( +col_int_unique INT DEFAULT NULL, +col_int_key INT DEFAULT NULL, +UNIQUE KEY col_int_unique (col_int_unique), +KEY col_int_key (col_int_key) +); +INSERT INTO t1 VALUES (49,49), (9,7), (0,1), (2,42); +CREATE TABLE t2 ( +col_int_unique INT DEFAULT NULL, +pk INT NOT NULL, +PRIMARY KEY (pk), +UNIQUE KEY col_int_unique (col_int_unique) +); +INSERT INTO t2 VALUES (2,8), (5,2), (6,1); +ANALYZE TABLE t1,t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN +SELECT STRAIGHT_JOIN t1.col_int_key AS field1 +FROM t1 JOIN t2 +ON t2.pk = t1.col_int_unique OR +t2.col_int_unique = t1.col_int_key +ORDER BY field1 LIMIT 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL col_int_unique,col_int_key NULL NULL NULL 4 100.00 Using filesort +2 SIMPLE t2 NULL ALL PRIMARY,col_int_unique NULL NULL NULL 3 55.56 Range checked for each record (index map: 0x3) +Warnings: +Note 1003 /* select#1 */ select straight_join `test`.`t1`.`col_int_key` AS `field1` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`pk` = `test`.`t1`.`col_int_unique`) or (`test`.`t2`.`col_int_unique` = `test`.`t1`.`col_int_key`)) order by `field1` limit 2 +DROP TABLE t1,t2; +# +# Bug#30348211: DANGEROUS OPTIMIZATION RECONSIDERING_ACCESS_PATHS_FOR_ +# INDEX_ORDERING +# +CREATE TABLE t (id BIGINT NOT NULL, other_id BIGINT NOT NULL, +covered_column VARCHAR(50) NOT NULL, non_covered_column VARCHAR(50) NOT NULL, +PRIMARY KEY (id), +INDEX index_other_id_covered_column (other_id, covered_column)); +INSERT INTO t (id, other_id, covered_column, non_covered_column) +VALUES (10, 10, '10', '10'); +INSERT INTO t (id, other_id, covered_column, non_covered_column) +VALUES (9, 9, '9', '9'); +INSERT INTO t (id, other_id, covered_column, non_covered_column) +VALUES (8, 8, '8', '8'); +INSERT INTO t (id, other_id, covered_column, non_covered_column) +VALUES (7, 7, '7', '7'); +INSERT INTO t (id, other_id, covered_column, non_covered_column) +VALUES (6, 6, '6', '6'); +INSERT INTO t (id, other_id, covered_column, non_covered_column) +VALUES (5, 5, '5', '5'); +INSERT INTO t (id, other_id, covered_column, non_covered_column) +VALUES (4, 4, '4', '4'); +INSERT INTO t (id, other_id, covered_column, non_covered_column) +VALUES (3, 3, '3', '3'); +INSERT INTO t (id, other_id, covered_column, non_covered_column) +VALUES (2, 2, '2', '2'); +INSERT INTO t (id, other_id, covered_column, non_covered_column) +VALUES (1, 1, '1', '1'); +SET +optimizer_trace = "enabled=on", +optimizer_trace_max_mem_size = 1000000, +end_markers_in_json = ON; +SET optimizer_switch = "prefer_ordering_index=on"; +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +EXPLAIN SELECT non_covered_column FROM t WHERE other_id > 3 ORDER BY id ASC LIMIT 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 70.00 Parallel execute (1 workers) +2 SIMPLE t NULL index index_other_id_covered_column PRIMARY 8 NULL 2 70.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`non_covered_column` AS `non_covered_column` from `test`.`t` where (`test`.`t`.`other_id` > 3) order by `test`.`t`.`id` limit 2 +SELECT (trace LIKE '%"plan_changed": true%') AS should_be_1 FROM information_schema.optimizer_trace; +should_be_1 +1 +SET optimizer_switch = "prefer_ordering_index=off"; +EXPLAIN SELECT non_covered_column FROM t WHERE other_id > 3 ORDER BY id ASC LIMIT 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL range index_other_id_covered_column index_other_id_covered_column 8 NULL 7 100.00 Using index condition; Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`non_covered_column` AS `non_covered_column` from `test`.`t` where (`test`.`t`.`other_id` > 3) order by `test`.`t`.`id` limit 2 +SELECT (trace LIKE '%"plan_changed": true%') AS should_be_0 FROM information_schema.optimizer_trace; +should_be_0 +0 +SET optimizer_switch = default; +EXPLAIN SELECT non_covered_column FROM t WHERE other_id > 3 ORDER BY id ASC LIMIT 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 70.00 Parallel execute (1 workers) +2 SIMPLE t NULL index index_other_id_covered_column PRIMARY 8 NULL 2 70.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`non_covered_column` AS `non_covered_column` from `test`.`t` where (`test`.`t`.`other_id` > 3) order by `test`.`t`.`id` limit 2 +SELECT (trace LIKE '%"plan_changed": true%') AS should_be_1 FROM information_schema.optimizer_trace; +should_be_1 +1 +SET optimizer_switch = "prefer_ordering_index=on"; +EXPLAIN SELECT /*+ ORDER_INDEX(t PRIMARY) */ non_covered_column FROM t WHERE other_id > 3 ORDER BY id ASC LIMIT 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL index NULL PRIMARY 8 NULL 2 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select /*+ ORDER_INDEX(`t`@`select#1` `PRIMARY`) */ `test`.`t`.`non_covered_column` AS `non_covered_column` from `test`.`t` where (`test`.`t`.`other_id` > 3) order by `test`.`t`.`id` limit 2 +SELECT (trace LIKE '%"plan_changed": true%') AS should_be_1 FROM information_schema.optimizer_trace; +should_be_1 +1 +SET optimizer_switch = "prefer_ordering_index=off"; +EXPLAIN SELECT /*+ ORDER_INDEX(t PRIMARY) */ non_covered_column FROM t WHERE other_id > 3 ORDER BY id ASC LIMIT 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL index NULL PRIMARY 8 NULL 2 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select /*+ ORDER_INDEX(`t`@`select#1` `PRIMARY`) */ `test`.`t`.`non_covered_column` AS `non_covered_column` from `test`.`t` where (`test`.`t`.`other_id` > 3) order by `test`.`t`.`id` limit 2 +SELECT (trace LIKE '%"plan_changed": true%') AS should_be_1 FROM information_schema.optimizer_trace; +should_be_1 +1 +INSERT INTO t (id, other_id, covered_column, non_covered_column) +VALUES (10+1+10, 10, '10', '10'); +INSERT INTO t (id, other_id, covered_column, non_covered_column) +VALUES (9+1+10, 9, '9', '9'); +INSERT INTO t (id, other_id, covered_column, non_covered_column) +VALUES (8+1+10, 8, '8', '8'); +INSERT INTO t (id, other_id, covered_column, non_covered_column) +VALUES (7+1+10, 7, '7', '7'); +INSERT INTO t (id, other_id, covered_column, non_covered_column) +VALUES (6+1+10, 6, '6', '6'); +INSERT INTO t (id, other_id, covered_column, non_covered_column) +VALUES (5+1+10, 5, '5', '5'); +INSERT INTO t (id, other_id, covered_column, non_covered_column) +VALUES (4+1+10, 4, '4', '4'); +INSERT INTO t (id, other_id, covered_column, non_covered_column) +VALUES (3+1+10, 3, '3', '3'); +INSERT INTO t (id, other_id, covered_column, non_covered_column) +VALUES (2+1+10, 2, '2', '2'); +INSERT INTO t (id, other_id, covered_column, non_covered_column) +VALUES (1+1+10, 1, '1', '1'); +SET optimizer_switch = "prefer_ordering_index=on"; +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +EXPLAIN SELECT non_covered_column FROM t WHERE id > 8 GROUP BY other_id LIMIT 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 60.00 Parallel execute (1 workers) +2 SIMPLE t NULL index PRIMARY,index_other_id_covered_column index_other_id_covered_column 210 NULL 3 60.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`non_covered_column` AS `non_covered_column` from `test`.`t` where (`test`.`t`.`id` > 8) group by `test`.`t`.`other_id` limit 1 +SELECT (trace LIKE '%"plan_changed": true%') AS should_be_1 FROM information_schema.optimizer_trace; +should_be_1 +1 +SET optimizer_switch = "prefer_ordering_index=off"; +EXPLAIN SELECT non_covered_column FROM t WHERE id > 8 GROUP BY other_id LIMIT 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 12 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL range PRIMARY,index_other_id_covered_column PRIMARY 8 NULL 12 100.00 Using where; Using temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`non_covered_column` AS `non_covered_column` from `test`.`t` where (`test`.`t`.`id` > 8) group by `test`.`t`.`other_id` limit 1 +SELECT (trace LIKE '%"plan_changed": true%') AS should_be_0 FROM information_schema.optimizer_trace; +should_be_0 +0 +SET optimizer_switch = default; +EXPLAIN SELECT non_covered_column FROM t WHERE id > 8 GROUP BY id LIMIT 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 12 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL range PRIMARY,index_other_id_covered_column PRIMARY 8 NULL 12 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`non_covered_column` AS `non_covered_column` from `test`.`t` where (`test`.`t`.`id` > 8) group by `test`.`t`.`id` limit 1 +SELECT (trace LIKE '%"plan_changed": true%') AS should_be_1 FROM information_schema.optimizer_trace; +should_be_1 +0 +SET optimizer_switch = "prefer_ordering_index=on"; +EXPLAIN SELECT /*+ GROUP_INDEX(t index_other_id_covered_column) */ non_covered_column FROM t WHERE id > 8 GROUP BY other_id LIMIT 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL index index_other_id_covered_column index_other_id_covered_column 210 NULL 2 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select /*+ GROUP_INDEX(`t`@`select#1` `index_other_id_covered_column`) */ `test`.`t`.`non_covered_column` AS `non_covered_column` from `test`.`t` where (`test`.`t`.`id` > 8) group by `test`.`t`.`other_id` limit 1 +SELECT (trace LIKE '%"plan_changed": true%') AS should_be_1 FROM information_schema.optimizer_trace; +should_be_1 +1 +SET optimizer_switch = "prefer_ordering_index=off"; +EXPLAIN SELECT /*+ GROUP_INDEX(t index_other_id_covered_column) */ non_covered_column FROM t WHERE id > 8 GROUP BY other_id LIMIT 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL index index_other_id_covered_column index_other_id_covered_column 210 NULL 2 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select /*+ GROUP_INDEX(`t`@`select#1` `index_other_id_covered_column`) */ `test`.`t`.`non_covered_column` AS `non_covered_column` from `test`.`t` where (`test`.`t`.`id` > 8) group by `test`.`t`.`other_id` limit 1 +SELECT (trace LIKE '%"plan_changed": true%') AS should_be_1 FROM information_schema.optimizer_trace; +should_be_1 +1 +DROP TABLE t; diff --git a/mysql-test/r/order_by_sortkey.result-pq b/mysql-test/r/order_by_sortkey.result-pq new file mode 100644 index 000000000000..235cb407fa36 --- /dev/null +++ b/mysql-test/r/order_by_sortkey.result-pq @@ -0,0 +1,269 @@ +CREATE TABLE t1( +f0 int auto_increment PRIMARY KEY, +f1 int, +f2 varchar(200) +) charset latin1; +INSERT INTO t1(f1, f2) VALUES +(0,"0"),(1,"1"),(2,"2"),(3,"3"),(4,"4"),(5,"5"), +(6,"6"),(7,"7"),(8,"8"),(9,"9"),(10,"10"), +(11,"11"),(12,"12"),(13,"13"),(14,"14"),(15,"15"), +(16,"16"),(17,"17"),(18,"18"),(19,"19"),(20,"20"), +(21,"21"),(22,"22"),(23,"23"),(24,"24"),(25,"25"), +(26,"26"),(27,"27"),(28,"28"),(29,"29"),(30,"30"), +(31,"31"),(32,"32"),(33,"33"),(34,"34"),(35,"35"), +(36,"36"),(37,"37"),(38,"38"),(39,"39"),(40,"40"), +(41,"41"),(42,"42"),(43,"43"),(44,"44"),(45,"45"), +(46,"46"),(47,"47"),(48,"48"),(49,"49"),(50,"50"), +(51,"51"),(52,"52"),(53,"53"),(54,"54"),(55,"55"), +(56,"56"),(57,"57"),(58,"58"),(59,"59"),(60,"60"), +(61,"61"),(62,"62"),(63,"63"),(64,"64"),(65,"65"), +(66,"66"),(67,"67"),(68,"68"),(69,"69"),(70,"70"), +(71,"71"),(72,"72"),(73,"73"),(74,"74"),(75,"75"), +(76,"76"),(77,"77"),(78,"78"),(79,"79"),(80,"80"), +(81,"81"),(82,"82"),(83,"83"),(84,"84"),(85,"85"), +(86,"86"),(87,"87"),(88,"88"),(89,"89"),(90,"90"), +(91,"91"),(92,"92"),(93,"93"),(94,"94"),(95,"95"), +(96,"96"),(97,"97"),(98,"98"),(99,"99"); +CREATE TEMPORARY TABLE tmp (f1 int, f2 varchar(20)) charset latin1; +INSERT INTO tmp SELECT f1,f2 FROM t1; +INSERT INTO t1(f1,f2) SELECT * FROM tmp; +INSERT INTO tmp SELECT f1,f2 FROM t1; +INSERT INTO t1(f1,f2) SELECT * FROM tmp; +INSERT INTO t1(f1,f2) SELECT * FROM tmp; +INSERT INTO tmp SELECT f1,f2 FROM t1; +INSERT INTO t1(f1,f2) SELECT * FROM tmp; +INSERT INTO tmp SELECT f1,f2 FROM t1; +INSERT INTO t1(f1,f2) SELECT * FROM tmp; +INSERT INTO tmp SELECT f1,f2 FROM t1; +INSERT INTO t1(f1,f2) SELECT * FROM tmp; +INSERT INTO tmp SELECT f1,f2 FROM t1; +INSERT INTO t1(f1,f2) SELECT * FROM tmp; +INSERT INTO tmp SELECT f1,f2 FROM t1; +INSERT INTO t1(f1,f2) SELECT * FROM tmp; +set sort_buffer_size= 32768; +FLUSH STATUS; +SHOW SESSION STATUS LIKE 'Sort%'; +Variable_name Value +Sort_merge_passes 0 +Sort_range 0 +Sort_rows 0 +Sort_scan 0 +SELECT * FROM t1 ORDER BY f2,f0 LIMIT 101; +f0 f1 f2 +1 0 0 +101 0 0 +228 0 0 +328 0 0 +428 0 0 +739 0 0 +839 0 0 +939 0 0 +1250 0 0 +1350 0 0 +1450 0 0 +1550 0 0 +1650 0 0 +1750 0 0 +1850 0 0 +1950 0 0 +2050 0 0 +2150 0 0 +2250 0 0 +3297 0 0 +3397 0 0 +3497 0 0 +3597 0 0 +3697 0 0 +3797 0 0 +3897 0 0 +3997 0 0 +4097 0 0 +4197 0 0 +4297 0 0 +4397 0 0 +4497 0 0 +4597 0 0 +4697 0 0 +4797 0 0 +4897 0 0 +4997 0 0 +5097 0 0 +5197 0 0 +5297 0 0 +5397 0 0 +5497 0 0 +5597 0 0 +5697 0 0 +5797 0 0 +5897 0 0 +5997 0 0 +6097 0 0 +6197 0 0 +7392 0 0 +7492 0 0 +7592 0 0 +7692 0 0 +7792 0 0 +7892 0 0 +7992 0 0 +8092 0 0 +8192 0 0 +8292 0 0 +8392 0 0 +8492 0 0 +8592 0 0 +8692 0 0 +8792 0 0 +8892 0 0 +8992 0 0 +9092 0 0 +9192 0 0 +9292 0 0 +9392 0 0 +9492 0 0 +9592 0 0 +9692 0 0 +9792 0 0 +9892 0 0 +9992 0 0 +10092 0 0 +10192 0 0 +10292 0 0 +10392 0 0 +10492 0 0 +10592 0 0 +10692 0 0 +10792 0 0 +10892 0 0 +10992 0 0 +11092 0 0 +11192 0 0 +11292 0 0 +11392 0 0 +11492 0 0 +11592 0 0 +11692 0 0 +11792 0 0 +11892 0 0 +11992 0 0 +12092 0 0 +12192 0 0 +12292 0 0 +12392 0 0 +12492 0 0 +SHOW SESSION STATUS LIKE 'Sort%'; +Variable_name Value +Sort_merge_passes 0 +Sort_range 0 +Sort_rows 404 +Sort_scan 4 +FLUSH STATUS; +CREATE TABLE t2 (f1 int); +INSERT INTO t2 VALUES (0), (0); +SELECT * FROM t2 where f1 = +(SELECT f2 from t1 where t1.f1 = t2.f1 ORDER BY f1 LIMIT 1); +f1 +0 +0 +SHOW SESSION STATUS LIKE 'Sort%'; +Variable_name Value +Sort_merge_passes 0 +Sort_range 0 +Sort_rows 2 +Sort_scan 2 +DROP TABLE t1, t2, tmp; +Bug#32038406: Filesort used for ORDER BY .. DESC even when +descending index available and used +CREATE TABLE t ( +col1 INTEGER NOT NULL, +col2 BINARY(16) NOT NULL, +col3 VARCHAR(191) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, +col4 INTEGER NOT NULL, +col5 TIMESTAMP(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6), +col6 BLOB, +PRIMARY KEY (col1), +UNIQUE KEY uc_key (col2, col3, col4) +); +INSERT INTO t VALUES(1, x'4142434445464748494a414243444546', 'WRITEBACK', +0, TIMESTAMP'2020-01-01 00:00:00.000000', NULL); +SELECT t.col1, t.col2, t.col3, t.col4, t.col5, t.col6 +FROM t +WHERE t.col2 IN (x'4142434445464748494a414243444546') AND +t.col3 IN ('WRITEBACK') +ORDER BY t.col2 DESC, t.col3 DESC, t.col4 DESC +LIMIT 1; +col1 col2 col3 col4 col5 col6 +1 ABCDEFGHIJABCDEF WRITEBACK 0 2020-01-01 00:00:00.000000 NULL +explain SELECT t.col1, t.col2, t.col3, t.col4, t.col5, t.col6 +FROM t +WHERE t.col2 IN (x'4142434445464748494a414243444546') AND +t.col3 IN ('WRITEBACK') +ORDER BY t.col2 DESC, t.col3 DESC, t.col4 DESC +LIMIT 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL ref uc_key uc_key 782 const,const 1 100.00 Using where; Backward index scan +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`col1` AS `col1`,`test`.`t`.`col2` AS `col2`,`test`.`t`.`col3` AS `col3`,`test`.`t`.`col4` AS `col4`,`test`.`t`.`col5` AS `col5`,`test`.`t`.`col6` AS `col6` from `test`.`t` where ((`test`.`t`.`col2` = 0x4142434445464748494a414243444546) and (`test`.`t`.`col3` = 'WRITEBACK')) order by `test`.`t`.`col2` desc,`test`.`t`.`col3` desc,`test`.`t`.`col4` desc limit 1 +DROP TABLE t; +Here, latin1 is used because it matches collation of temporal const +CREATE TABLE t1(vc VARCHAR(20) CHARACTER SET latin1); +INSERT INTO t1 VALUES('2021-02-08'), ('21-02-08'); +Verify that a string const value removes ORDER BY clause +SELECT * FROM t1 WHERE vc = '2021-02-08' ORDER BY vc ASC; +vc +2021-02-08 +explain SELECT * FROM t1 WHERE vc = '2021-02-08' ORDER BY vc ASC; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 50.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`vc` AS `vc` from `test`.`t1` where (`test`.`t1`.`vc` = '2021-02-08') order by `test`.`t1`.`vc` +SELECT * FROM t1 WHERE vc = '2021-02-08' ORDER BY vc DESC; +vc +2021-02-08 +explain SELECT * FROM t1 WHERE vc = '2021-02-08' ORDER BY vc DESC; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 50.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`vc` AS `vc` from `test`.`t1` where (`test`.`t1`.`vc` = '2021-02-08') order by `test`.`t1`.`vc` desc +Verify the same with a variable (which is const for execution) +set @strvar = _latin1'2021-02-08'; +SELECT * FROM t1 WHERE vc = @strvar ORDER BY vc ASC; +vc +2021-02-08 +explain SELECT * FROM t1 WHERE vc = @strvar ORDER BY vc ASC; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`vc` AS `vc` from `test`.`t1` where (`test`.`t1`.`vc` = ((@`strvar`))) order by `test`.`t1`.`vc` +SELECT * FROM t1 WHERE vc = @strvar ORDER BY vc DESC; +vc +2021-02-08 +explain SELECT * FROM t1 WHERE vc = @strvar ORDER BY vc DESC; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`vc` AS `vc` from `test`.`t1` where (`test`.`t1`.`vc` = ((@`strvar`))) order by `test`.`t1`.`vc` desc +Verify that a date const value does not remove ORDER BY clause +SELECT * FROM t1 WHERE vc = DATE'2021-02-08' ORDER BY vc ASC; +vc +2021-02-08 +21-02-08 +explain SELECT * FROM t1 WHERE vc = DATE'2021-02-08' ORDER BY vc ASC; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 50.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`vc` AS `vc` from `test`.`t1` where (`test`.`t1`.`vc` = DATE'2021-02-08') order by `test`.`t1`.`vc` +SELECT * FROM t1 WHERE vc = DATE'2021-02-08' ORDER BY vc DESC; +vc +21-02-08 +2021-02-08 +explain SELECT * FROM t1 WHERE vc = DATE'2021-02-08' ORDER BY vc DESC; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 50.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`vc` AS `vc` from `test`.`t1` where (`test`.`t1`.`vc` = DATE'2021-02-08') order by `test`.`t1`.`vc` desc +DROP TABLE t1; diff --git a/mysql-test/r/parser.result-pq b/mysql-test/r/parser.result-pq new file mode 100644 index 000000000000..7b75e6d505ed --- /dev/null +++ b/mysql-test/r/parser.result-pq @@ -0,0 +1,2751 @@ +SET @save_sql_mode=@@sql_mode; +set SQL_MODE=''; +create table ADDDATE(a int); +drop table ADDDATE; +create table ADDDATE (a int); +drop table ADDDATE; +create table BIT_AND(a int); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'BIT_AND(a int)' at line 1 +create table BIT_AND (a int); +drop table BIT_AND; +create table BIT_OR(a int); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'BIT_OR(a int)' at line 1 +create table BIT_OR (a int); +drop table BIT_OR; +create table BIT_XOR(a int); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'BIT_XOR(a int)' at line 1 +create table BIT_XOR (a int); +drop table BIT_XOR; +create table CAST(a int); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'CAST(a int)' at line 1 +create table CAST (a int); +drop table CAST; +create table COUNT(a int); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'COUNT(a int)' at line 1 +create table COUNT (a int); +drop table COUNT; +create table CURDATE(a int); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'CURDATE(a int)' at line 1 +create table CURDATE (a int); +drop table CURDATE; +create table CURTIME(a int); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'CURTIME(a int)' at line 1 +create table CURTIME (a int); +drop table CURTIME; +create table DATE_ADD(a int); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DATE_ADD(a int)' at line 1 +create table DATE_ADD (a int); +drop table DATE_ADD; +create table DATE_SUB(a int); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DATE_SUB(a int)' at line 1 +create table DATE_SUB (a int); +drop table DATE_SUB; +create table EXTRACT(a int); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'EXTRACT(a int)' at line 1 +create table EXTRACT (a int); +drop table EXTRACT; +create table GROUP_CONCAT(a int); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'GROUP_CONCAT(a int)' at line 1 +create table GROUP_CONCAT (a int); +drop table GROUP_CONCAT; +create table GROUP_UNIQUE_USERS(a int); +drop table GROUP_UNIQUE_USERS; +create table GROUP_UNIQUE_USERS (a int); +drop table GROUP_UNIQUE_USERS; +create table MAX(a int); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'MAX(a int)' at line 1 +create table MAX (a int); +drop table MAX; +create table MID(a int); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'MID(a int)' at line 1 +create table MID (a int); +drop table MID; +create table MIN(a int); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'MIN(a int)' at line 1 +create table MIN (a int); +drop table MIN; +create table NOW(a int); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'NOW(a int)' at line 1 +create table NOW (a int); +drop table NOW; +create table POSITION(a int); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'POSITION(a int)' at line 1 +create table POSITION (a int); +drop table POSITION; +create table SESSION_USER(a int); +drop table SESSION_USER; +create table SESSION_USER (a int); +drop table SESSION_USER; +create table STD(a int); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'STD(a int)' at line 1 +create table STD (a int); +drop table STD; +create table STDDEV(a int); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'STDDEV(a int)' at line 1 +create table STDDEV (a int); +drop table STDDEV; +create table STDDEV_POP(a int); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'STDDEV_POP(a int)' at line 1 +create table STDDEV_POP (a int); +drop table STDDEV_POP; +create table STDDEV_SAMP(a int); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'STDDEV_SAMP(a int)' at line 1 +create table STDDEV_SAMP (a int); +drop table STDDEV_SAMP; +create table SUBDATE(a int); +drop table SUBDATE; +create table SUBDATE (a int); +drop table SUBDATE; +create table SUBSTR(a int); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'SUBSTR(a int)' at line 1 +create table SUBSTR (a int); +drop table SUBSTR; +create table SUBSTRING(a int); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'SUBSTRING(a int)' at line 1 +create table SUBSTRING (a int); +drop table SUBSTRING; +create table SUM(a int); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'SUM(a int)' at line 1 +create table SUM (a int); +drop table SUM; +create table SYSDATE(a int); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'SYSDATE(a int)' at line 1 +create table SYSDATE (a int); +drop table SYSDATE; +create table SYSTEM_USER(a int); +drop table SYSTEM_USER; +create table SYSTEM_USER (a int); +drop table SYSTEM_USER; +create table TRIM(a int); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'TRIM(a int)' at line 1 +create table TRIM (a int); +drop table TRIM; +create table UNIQUE_USERS(a int); +drop table UNIQUE_USERS; +create table UNIQUE_USERS (a int); +drop table UNIQUE_USERS; +create table VARIANCE(a int); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'VARIANCE(a int)' at line 1 +create table VARIANCE (a int); +drop table VARIANCE; +create table VAR_POP(a int); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'VAR_POP(a int)' at line 1 +create table VAR_POP (a int); +drop table VAR_POP; +create table VAR_SAMP(a int); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'VAR_SAMP(a int)' at line 1 +create table VAR_SAMP (a int); +drop table VAR_SAMP; +set SQL_MODE='IGNORE_SPACE'; +create table ADDDATE(a int); +drop table ADDDATE; +create table ADDDATE (a int); +drop table ADDDATE; +create table BIT_AND(a int); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'BIT_AND(a int)' at line 1 +create table BIT_AND (a int); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'BIT_AND (a int)' at line 1 +create table BIT_OR(a int); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'BIT_OR(a int)' at line 1 +create table BIT_OR (a int); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'BIT_OR (a int)' at line 1 +create table BIT_XOR(a int); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'BIT_XOR(a int)' at line 1 +create table BIT_XOR (a int); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'BIT_XOR (a int)' at line 1 +create table CAST(a int); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'CAST(a int)' at line 1 +create table CAST (a int); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'CAST (a int)' at line 1 +create table COUNT(a int); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'COUNT(a int)' at line 1 +create table COUNT (a int); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'COUNT (a int)' at line 1 +create table CURDATE(a int); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'CURDATE(a int)' at line 1 +create table CURDATE (a int); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'CURDATE (a int)' at line 1 +create table CURTIME(a int); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'CURTIME(a int)' at line 1 +create table CURTIME (a int); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'CURTIME (a int)' at line 1 +create table DATE_ADD(a int); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DATE_ADD(a int)' at line 1 +create table DATE_ADD (a int); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DATE_ADD (a int)' at line 1 +create table DATE_SUB(a int); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DATE_SUB(a int)' at line 1 +create table DATE_SUB (a int); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DATE_SUB (a int)' at line 1 +create table EXTRACT(a int); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'EXTRACT(a int)' at line 1 +create table EXTRACT (a int); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'EXTRACT (a int)' at line 1 +create table GROUP_CONCAT(a int); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'GROUP_CONCAT(a int)' at line 1 +create table GROUP_CONCAT (a int); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'GROUP_CONCAT (a int)' at line 1 +create table GROUP_UNIQUE_USERS(a int); +drop table GROUP_UNIQUE_USERS; +create table GROUP_UNIQUE_USERS (a int); +drop table GROUP_UNIQUE_USERS; +create table MAX(a int); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'MAX(a int)' at line 1 +create table MAX (a int); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'MAX (a int)' at line 1 +create table MID(a int); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'MID(a int)' at line 1 +create table MID (a int); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'MID (a int)' at line 1 +create table MIN(a int); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'MIN(a int)' at line 1 +create table MIN (a int); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'MIN (a int)' at line 1 +create table NOW(a int); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'NOW(a int)' at line 1 +create table NOW (a int); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'NOW (a int)' at line 1 +create table POSITION(a int); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'POSITION(a int)' at line 1 +create table POSITION (a int); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'POSITION (a int)' at line 1 +create table SESSION_USER(a int); +drop table SESSION_USER; +create table SESSION_USER (a int); +drop table SESSION_USER; +create table STD(a int); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'STD(a int)' at line 1 +create table STD (a int); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'STD (a int)' at line 1 +create table STDDEV(a int); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'STDDEV(a int)' at line 1 +create table STDDEV (a int); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'STDDEV (a int)' at line 1 +create table STDDEV_POP(a int); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'STDDEV_POP(a int)' at line 1 +create table STDDEV_POP (a int); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'STDDEV_POP (a int)' at line 1 +create table STDDEV_SAMP(a int); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'STDDEV_SAMP(a int)' at line 1 +create table STDDEV_SAMP (a int); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'STDDEV_SAMP (a int)' at line 1 +create table SUBDATE(a int); +drop table SUBDATE; +create table SUBDATE (a int); +drop table SUBDATE; +create table SUBSTR(a int); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'SUBSTR(a int)' at line 1 +create table SUBSTR (a int); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'SUBSTR (a int)' at line 1 +create table SUBSTRING(a int); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'SUBSTRING(a int)' at line 1 +create table SUBSTRING (a int); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'SUBSTRING (a int)' at line 1 +create table SUM(a int); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'SUM(a int)' at line 1 +create table SUM (a int); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'SUM (a int)' at line 1 +create table SYSDATE(a int); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'SYSDATE(a int)' at line 1 +create table SYSDATE (a int); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'SYSDATE (a int)' at line 1 +create table SYSTEM_USER(a int); +drop table SYSTEM_USER; +create table SYSTEM_USER (a int); +drop table SYSTEM_USER; +create table TRIM(a int); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'TRIM(a int)' at line 1 +create table TRIM (a int); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'TRIM (a int)' at line 1 +create table UNIQUE_USERS(a int); +drop table UNIQUE_USERS; +create table UNIQUE_USERS (a int); +drop table UNIQUE_USERS; +create table VARIANCE(a int); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'VARIANCE(a int)' at line 1 +create table VARIANCE (a int); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'VARIANCE (a int)' at line 1 +create table VAR_POP(a int); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'VAR_POP(a int)' at line 1 +create table VAR_POP (a int); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'VAR_POP (a int)' at line 1 +create table VAR_SAMP(a int); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'VAR_SAMP(a int)' at line 1 +create table VAR_SAMP (a int); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'VAR_SAMP (a int)' at line 1 +# +# Test "UNIQUE KEY" and "UNIQUE" "KEY" grammar ambiguity +# +CREATE TABLE t1 (i INT KEY); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `i` int NOT NULL, + PRIMARY KEY (`i`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +CREATE TABLE t2 (i INT UNIQUE); +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `i` int DEFAULT NULL, + UNIQUE KEY `i` (`i`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +CREATE TABLE t3 (i INT UNIQUE KEY); +# Should output "UNIQUE KEY `i` (`i`)" only: +SHOW CREATE TABLE t3; +Table Create Table +t3 CREATE TABLE `t3` ( + `i` int DEFAULT NULL, + UNIQUE KEY `i` (`i`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +DROP TABLE t1, t2, t3; +# +DROP TABLE IF EXISTS table_25930_a; +DROP TABLE IF EXISTS table_25930_b; +SET SQL_MODE = 'ANSI_QUOTES'; +CREATE TABLE table_25930_a ( "blah" INT ); +CREATE TABLE table_25930_b SELECT "blah" - 1 FROM table_25930_a; +desc table_25930_b; +Field Type Null Key Default Extra +"blah" - 1 bigint YES NULL +DROP TABLE table_25930_a; +DROP TABLE table_25930_b; +SET @@sql_mode=@save_sql_mode; +DROP PROCEDURE IF EXISTS p26030; +select "non terminated"$$ +non terminated +non terminated +select "terminated";$$ +terminated +terminated +select "non terminated, space" $$ +non terminated, space +non terminated, space +select "terminated, space"; $$ +terminated, space +terminated, space +select "non terminated, comment" /* comment */$$ +non terminated, comment +non terminated, comment +select "terminated, comment"; /* comment */$$ +terminated, comment +terminated, comment +select "stmt 1";select "stmt 2 non terminated"$$ +stmt 1 +stmt 1 +stmt 2 non terminated +stmt 2 non terminated +select "stmt 1";select "stmt 2 terminated";$$ +stmt 1 +stmt 1 +stmt 2 terminated +stmt 2 terminated +select "stmt 1";select "stmt 2 non terminated, space" $$ +stmt 1 +stmt 1 +stmt 2 non terminated, space +stmt 2 non terminated, space +select "stmt 1";select "stmt 2 terminated, space"; $$ +stmt 1 +stmt 1 +stmt 2 terminated, space +stmt 2 terminated, space +select "stmt 1";select "stmt 2 non terminated, comment" /* comment */$$ +stmt 1 +stmt 1 +stmt 2 non terminated, comment +stmt 2 non terminated, comment +select "stmt 1";select "stmt 2 terminated, comment"; /* comment */$$ +stmt 1 +stmt 1 +stmt 2 terminated, comment +stmt 2 terminated, comment +select "stmt 1"; select "space, stmt 2"$$ +stmt 1 +stmt 1 +space, stmt 2 +space, stmt 2 +select "stmt 1";/* comment */select "comment, stmt 2"$$ +stmt 1 +stmt 1 +comment, stmt 2 +comment, stmt 2 +DROP PROCEDURE IF EXISTS p26030; CREATE PROCEDURE p26030() BEGIN SELECT 1; END; CALL p26030() +$$ +1 +1 +DROP PROCEDURE IF EXISTS p26030; CREATE PROCEDURE p26030() SELECT 1; CALL p26030() +$$ +1 +1 +DROP PROCEDURE p26030; +select pi(3.14); +ERROR 42000: Incorrect parameter count in the call to native function 'pi' +select tan(); +ERROR 42000: Incorrect parameter count in the call to native function 'tan' +select tan(1, 2); +ERROR 42000: Incorrect parameter count in the call to native function 'tan' +select makedate(1); +ERROR 42000: Incorrect parameter count in the call to native function 'makedate' +select makedate(1, 2, 3); +ERROR 42000: Incorrect parameter count in the call to native function 'makedate' +select maketime(); +ERROR 42000: Incorrect parameter count in the call to native function 'maketime' +select maketime(1); +ERROR 42000: Incorrect parameter count in the call to native function 'maketime' +select maketime(1, 2); +ERROR 42000: Incorrect parameter count in the call to native function 'maketime' +select maketime(1, 2, 3, 4); +ERROR 42000: Incorrect parameter count in the call to native function 'maketime' +select atan(); +ERROR 42000: Incorrect parameter count in the call to native function 'atan' +select atan2(1, 2, 3); +ERROR 42000: Incorrect parameter count in the call to native function 'atan2' +select concat(); +ERROR 42000: Incorrect parameter count in the call to native function 'concat' +select concat("foo"); +concat("foo") +foo +select concat_ws(); +ERROR 42000: Incorrect parameter count in the call to native function 'concat_ws' +select concat_ws("foo"); +ERROR 42000: Incorrect parameter count in the call to native function 'concat_ws' +select elt(); +ERROR 42000: Incorrect parameter count in the call to native function 'elt' +select elt(1); +ERROR 42000: Incorrect parameter count in the call to native function 'elt' +select export_set(); +ERROR 42000: Incorrect parameter count in the call to native function 'export_set' +select export_set("p1"); +ERROR 42000: Incorrect parameter count in the call to native function 'export_set' +select export_set("p1", "p2"); +ERROR 42000: Incorrect parameter count in the call to native function 'export_set' +select export_set("p1", "p2", "p3", "p4", "p5", "p6"); +ERROR 42000: Incorrect parameter count in the call to native function 'export_set' +select field(); +ERROR 42000: Incorrect parameter count in the call to native function 'field' +select field("p1"); +ERROR 42000: Incorrect parameter count in the call to native function 'field' +select from_unixtime(); +ERROR 42000: Incorrect parameter count in the call to native function 'from_unixtime' +select from_unixtime(1, 2, 3); +ERROR 42000: Incorrect parameter count in the call to native function 'from_unixtime' +select unix_timestamp(1, 2); +ERROR 42000: Incorrect parameter count in the call to native function 'unix_timestamp' +select greatest(); +ERROR 42000: Incorrect parameter count in the call to native function 'greatest' +select greatest(12); +ERROR 42000: Incorrect parameter count in the call to native function 'greatest' +select last_insert_id(1, 2); +ERROR 42000: Incorrect parameter count in the call to native function 'last_insert_id' +select least(); +ERROR 42000: Incorrect parameter count in the call to native function 'least' +select least(12); +ERROR 42000: Incorrect parameter count in the call to native function 'least' +select locate(); +ERROR 42000: Incorrect parameter count in the call to native function 'locate' +select locate(1); +ERROR 42000: Incorrect parameter count in the call to native function 'locate' +select locate(1, 2, 3, 4); +ERROR 42000: Incorrect parameter count in the call to native function 'locate' +select log(); +ERROR 42000: Incorrect parameter count in the call to native function 'log' +select log(1, 2, 3); +ERROR 42000: Incorrect parameter count in the call to native function 'log' +select make_set(); +ERROR 42000: Incorrect parameter count in the call to native function 'make_set' +select make_set(1); +ERROR 42000: Incorrect parameter count in the call to native function 'make_set' +select master_pos_wait(); +ERROR 42000: Incorrect parameter count in the call to native function 'master_pos_wait' +select master_pos_wait(1); +ERROR 42000: Incorrect parameter count in the call to native function 'master_pos_wait' +select master_pos_wait('binlog.999999', 4, -1); +select rand(1, 2, 3); +ERROR 42000: Incorrect parameter count in the call to native function 'rand' +select round(1, 2, 3); +ERROR 42000: Incorrect parameter count in the call to native function 'round' +select yearweek(); +ERROR 42000: Incorrect parameter count in the call to native function 'yearweek' +select yearweek(1, 2, 3); +ERROR 42000: Incorrect parameter count in the call to native function 'yearweek' +select abs(3); +abs(3) +3 +select abs(3 AS three); +ERROR 42000: Incorrect parameters in the call to native function 'abs' +select abs(3 three); +ERROR 42000: Incorrect parameters in the call to native function 'abs' +select abs(3 AS "three"); +ERROR 42000: Incorrect parameters in the call to native function 'abs' +select abs(3 "three"); +ERROR 42000: Incorrect parameters in the call to native function 'abs' +set @bar="bar"; +set @foobar="foobar"; +select instr("foobar", "bar"); +instr("foobar", "bar") +4 +select instr("foobar" AS p1, "bar"); +ERROR 42000: Incorrect parameters in the call to native function 'instr' +select instr("foobar" p1, "bar"); +ERROR 42000: Incorrect parameters in the call to native function 'instr' +select instr("foobar" AS "p1", "bar"); +ERROR 42000: Incorrect parameters in the call to native function 'instr' +select instr("foobar" "p1", "bar"); +instr("foobar" "p1", "bar") +4 +select instr(@foobar "p1", "bar"); +ERROR 42000: Incorrect parameters in the call to native function 'instr' +select instr("foobar", "bar" AS p2); +ERROR 42000: Incorrect parameters in the call to native function 'instr' +select instr("foobar", "bar" p2); +ERROR 42000: Incorrect parameters in the call to native function 'instr' +select instr("foobar", "bar" AS "p2"); +ERROR 42000: Incorrect parameters in the call to native function 'instr' +select instr("foobar", "bar" "p2"); +instr("foobar", "bar" "p2") +0 +select instr("foobar", @bar "p2"); +ERROR 42000: Incorrect parameters in the call to native function 'instr' +select instr("foobar" AS p1, "bar" AS p2); +ERROR 42000: Incorrect parameters in the call to native function 'instr' +select conv(255, 10, 16); +conv(255, 10, 16) +FF +select conv(255 AS p1, 10, 16); +ERROR 42000: Incorrect parameters in the call to native function 'conv' +select conv(255 p1, 10, 16); +ERROR 42000: Incorrect parameters in the call to native function 'conv' +select conv(255 AS "p1", 10, 16); +ERROR 42000: Incorrect parameters in the call to native function 'conv' +select conv(255 "p1", 10, 16); +ERROR 42000: Incorrect parameters in the call to native function 'conv' +select conv(255, 10 AS p2, 16); +ERROR 42000: Incorrect parameters in the call to native function 'conv' +select conv(255, 10 p2, 16); +ERROR 42000: Incorrect parameters in the call to native function 'conv' +select conv(255, 10 AS "p2", 16); +ERROR 42000: Incorrect parameters in the call to native function 'conv' +select conv(255, 10 "p2", 16); +ERROR 42000: Incorrect parameters in the call to native function 'conv' +select conv(255, 10, 16 AS p3); +ERROR 42000: Incorrect parameters in the call to native function 'conv' +select conv(255, 10, 16 p3); +ERROR 42000: Incorrect parameters in the call to native function 'conv' +select conv(255, 10, 16 AS "p3"); +ERROR 42000: Incorrect parameters in the call to native function 'conv' +select conv(255, 10, 16 "p3"); +ERROR 42000: Incorrect parameters in the call to native function 'conv' +select conv(255 AS p1, 10 AS p2, 16 AS p3); +ERROR 42000: Incorrect parameters in the call to native function 'conv' +select atan(10); +atan(10) +1.4711276743037347 +select atan(10 AS p1); +ERROR 42000: Incorrect parameters in the call to native function 'atan' +select atan(10 p1); +ERROR 42000: Incorrect parameters in the call to native function 'atan' +select atan(10 AS "p1"); +ERROR 42000: Incorrect parameters in the call to native function 'atan' +select atan(10 "p1"); +ERROR 42000: Incorrect parameters in the call to native function 'atan' +select atan(10, 20); +atan(10, 20) +0.4636476090008061 +select atan(10 AS p1, 20); +ERROR 42000: Incorrect parameters in the call to native function 'atan' +select atan(10 p1, 20); +ERROR 42000: Incorrect parameters in the call to native function 'atan' +select atan(10 AS "p1", 20); +ERROR 42000: Incorrect parameters in the call to native function 'atan' +select atan(10 "p1", 20); +ERROR 42000: Incorrect parameters in the call to native function 'atan' +select atan(10, 20 AS p2); +ERROR 42000: Incorrect parameters in the call to native function 'atan' +select atan(10, 20 p2); +ERROR 42000: Incorrect parameters in the call to native function 'atan' +select atan(10, 20 AS "p2"); +ERROR 42000: Incorrect parameters in the call to native function 'atan' +select atan(10, 20 "p2"); +ERROR 42000: Incorrect parameters in the call to native function 'atan' +select atan(10 AS p1, 20 AS p2); +ERROR 42000: Incorrect parameters in the call to native function 'atan' +DROP TABLE IF EXISTS t1; +SET sql_mode = 'NO_ENGINE_SUBSTITUTION'; +SELECT STR_TO_DATE('10:00 PM', '%h:%i %p') + INTERVAL 10 MINUTE; +STR_TO_DATE('10:00 PM', '%h:%i %p') + INTERVAL 10 MINUTE +22:10:00 +SELECT STR_TO_DATE('10:00 PM', '%h:%i %p') + INTERVAL (INTERVAL(1,2,3) + 1) MINUTE; +STR_TO_DATE('10:00 PM', '%h:%i %p') + INTERVAL (INTERVAL(1,2,3) + 1) MINUTE +22:01:00 +SELECT "1997-12-31 23:59:59" + INTERVAL 1 SECOND; +"1997-12-31 23:59:59" + INTERVAL 1 SECOND +1998-01-01 00:00:00 +SELECT 1 + INTERVAL(1,0,1,2) + 1; +1 + INTERVAL(1,0,1,2) + 1 +4 +SELECT INTERVAL(1^1,0,1,2) + 1; +INTERVAL(1^1,0,1,2) + 1 +2 +SELECT INTERVAL(1,0+1,2,3) * 5.5; +INTERVAL(1,0+1,2,3) * 5.5 +5.5 +SELECT INTERVAL(3,3,1+3,4+4) / 0.5; +INTERVAL(3,3,1+3,4+4) / 0.5 +2.0000 +SELECT (INTERVAL(1,0,1,2) + 5) * 7 + INTERVAL(1,0,1,2) / 2; +(INTERVAL(1,0,1,2) + 5) * 7 + INTERVAL(1,0,1,2) / 2 +50.0000 +SELECT INTERVAL(1,0,1,2) + 1, 5 * INTERVAL(1,0,1,2); +INTERVAL(1,0,1,2) + 1 5 * INTERVAL(1,0,1,2) +3 10 +SELECT INTERVAL(0,(1*5)/2) + INTERVAL(5,4,3); +INTERVAL(0,(1*5)/2) + INTERVAL(5,4,3) +2 +SELECT 1^1 + INTERVAL 1+1 SECOND & 1 + INTERVAL 1+1 SECOND; +1^1 + INTERVAL 1+1 SECOND & 1 + INTERVAL 1+1 SECOND +NULL +SELECT 1%2 - INTERVAL 1^1 SECOND | 1%2 - INTERVAL 1^1 SECOND; +1%2 - INTERVAL 1^1 SECOND | 1%2 - INTERVAL 1^1 SECOND +NULL +CREATE TABLE t1 (a INT, b DATETIME); +INSERT INTO t1 VALUES (INTERVAL(3,2,1) + 1, "1997-12-31 23:59:59" + INTERVAL 1 SECOND); +SELECT * FROM t1 WHERE a = INTERVAL(3,2,1) + 1; +a b +3 1998-01-01 00:00:00 +DROP TABLE t1; +SET sql_mode = default; +DROP TABLE IF EXISTS t1,t2,t3; +CREATE TABLE t1 (a1 INT, a2 INT, a3 INT, a4 DATETIME); +CREATE TABLE t2 LIKE t1; +CREATE TABLE t3 LIKE t1; +SELECT t1.* FROM t1 AS t0, { OJ t2 INNER JOIN t1 ON (t1.a1=t2.a1) } WHERE t0.a3=2; +a1 a2 a3 a4 +SELECT t1.*,t2.* FROM { OJ ((t1 INNER JOIN t2 ON (t1.a1=t2.a2)) LEFT OUTER JOIN t3 ON t3.a3=t2.a1)}; +a1 a2 a3 a4 a1 a2 a3 a4 +SELECT t1.*,t2.* FROM { OJ ((t1 LEFT OUTER JOIN t2 ON t1.a3=t2.a2) INNER JOIN t3 ON (t3.a1=t2.a2))}; +a1 a2 a3 a4 a1 a2 a3 a4 +SELECT t1.*,t2.* FROM { OJ (t1 LEFT OUTER JOIN t2 ON t1.a1=t2.a2) CROSS JOIN t3 ON (t3.a2=t2.a3)}; +a1 a2 a3 a4 a1 a2 a3 a4 +SELECT * FROM {oj t1 LEFT OUTER JOIN t2 ON t1.a1=t2.a3} WHERE t1.a2 > 10; +a1 a2 a3 a4 a1 a2 a3 a4 +SELECT {fn CONCAT(a1,a2)} FROM t1; +{fn CONCAT(a1,a2)} +UPDATE t3 SET a4={d '1789-07-14'} WHERE a1=0; +SELECT a1, a4 FROM t2 WHERE a4 LIKE {fn UCASE('1789-07-14')}; +a1 a4 +DROP TABLE t1, t2, t3; +# +# End of 5.1 tests +# +CREATE TABLE t (id INT PRIMARY KEY); +ALTER TABLE t RENAME TO `t1';; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '`t1'' at line 1 +DROP TABLE t; +# +# Bug#13819100 BROKEN SYNTAX ACCEPTED FOR START SLAVE, STOP SLAVE +# +STOP SLAVE ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, ; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ',,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,' at line 1 +STOP SLAVE ,,,,,,,,,,,,, sql_thread, ,,,,,,,,,,,,,,,,,,, ; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ',,,,,,,,,,,,, sql_thread, ,,,,,,,,,,,,,,,,,,,' at line 1 +STOP SLAVE ,,,,,,,,,,,,, io_thread, ,,,,,,,,,,,,,,,,,,, ; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ',,,,,,,,,,,,, io_thread, ,,,,,,,,,,,,,,,,,,,' at line 1 +# +# Bug#13819132 BROKEN SYNTAX ACCEPTED FOR START TRANSACTION +# +START TRANSACTION ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, ; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ',,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,' at line 1 +# +# Test of collective fix for three parser bugs: +# +# Bug #17727401, Bug #17426017, Bug #17473479: +# The server accepts wrong syntax and then fails in different ways +# +CREATE TABLE t1 (i INT); +# bug #17426017 +SELECT (SELECT EXISTS(SELECT * LIMIT 1 ORDER BY VALUES (c00))); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'ORDER BY VALUES (c00)))' at line 1 +# bug#17473479 +CREATE TABLE a(a int); +CREATE TABLE b(a int); +DELETE FROM b ORDER BY(SELECT 1 FROM a ORDER BY a ORDER BY a); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'ORDER BY a)' at line 1 +DROP TABLE a, b; +# bug #17727401 +SELECT '' IN (SELECT '1' c FROM t1 ORDER BY '' ORDER BY '') FROM t1; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'ORDER BY '') FROM t1' at line 1 +# regression & coverage tests +# uniform syntax for FROM DUAL clause: +SELECT 1 FROM DUAL WHERE 1 GROUP BY 1 HAVING 1 ORDER BY 1 +FOR UPDATE; +1 +1 +SELECT 1 FROM +(SELECT 1 FROM DUAL WHERE 1 GROUP BY 1 HAVING 1 ORDER BY 1 +FOR UPDATE) a; +1 +1 +SELECT 1 FROM t1 +WHERE EXISTS(SELECT 1 FROM DUAL WHERE 1 GROUP BY 1 HAVING 1 ORDER BY 1 +FOR UPDATE); +1 +SELECT 1 FROM t1 +UNION +SELECT 1 FROM DUAL WHERE 1 GROUP BY 1 HAVING 1 ORDER BY 1 +FOR UPDATE; +1 +1 +(SELECT 1 FROM t1) +UNION +(SELECT 1 FROM DUAL WHERE 1 GROUP BY 1 HAVING 1 ORDER BY 1 +FOR UPDATE); +1 +1 +# "FOR UPDATE" tests +SELECT 1 FROM t1 UNION SELECT 1 FROM t1 ORDER BY 1 LIMIT 1; +1 +SELECT 1 FROM t1 FOR UPDATE UNION SELECT 1 FROM t1 ORDER BY 1 LIMIT 1; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'UNION SELECT 1 FROM t1 ORDER BY 1 LIMIT 1' at line 1 +SELECT 1 FROM t1 UNION SELECT 1 FROM t1 ORDER BY 1 LIMIT 1 FOR UPDATE; +1 +# "INTO" clause tests +SELECT 1 FROM t1 INTO @var17727401; +Warnings: +Warning 1329 No data - zero rows fetched, selected, or processed +SELECT 1 FROM DUAL INTO @var17727401; +SELECT 1 INTO @var17727401; +SELECT 1 INTO @var17727401 FROM t1; +Warnings: +Warning 1329 No data - zero rows fetched, selected, or processed +SELECT 1 INTO @var17727401 FROM DUAL; +SELECT 1 INTO @var17727401_1 FROM t1 INTO @var17727401_2; +ERROR HY000: Multiple INTO clauses in one query block. +SELECT 1 INTO @var17727401_1 FROM DUAL +INTO @var17727401_2; +ERROR HY000: Multiple INTO clauses in one query block. +SELECT 1 INTO @var17727401 FROM t1 WHERE 1 GROUP BY 1 HAVING 1 ORDER BY 1 LIMIT 1; +Warnings: +Warning 1329 No data - zero rows fetched, selected, or processed +SELECT 1 FROM t1 WHERE 1 GROUP BY 1 HAVING 1 ORDER BY 1 LIMIT 1 INTO @var17727401; +Warnings: +Warning 1329 No data - zero rows fetched, selected, or processed +SELECT 1 FROM t1 WHERE 1 INTO @var17727401 GROUP BY 1 HAVING 1 ORDER BY 1 LIMIT 1; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'GROUP BY 1 HAVING 1 ORDER BY 1 LIMIT 1' at line 1 +SELECT 1 INTO @var17727401_1 +FROM t1 WHERE 1 GROUP BY 1 HAVING 1 ORDER BY 1 LIMIT 1 +INTO @var17727401_2; +ERROR HY000: Multiple INTO clauses in one query block. +SELECT (SELECT 1 FROM t1 INTO @var17727401); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'INTO @var17727401)' at line 1 +SELECT 1 FROM (SELECT 1 FROM t1 INTO @var17727401) a; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'INTO @var17727401) a' at line 1 +SELECT EXISTS(SELECT 1 FROM t1 INTO @var17727401); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'INTO @var17727401)' at line 1 +SELECT 1 FROM t1 INTO @var17727401 UNION SELECT 1 FROM t1 INTO t1; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'UNION SELECT 1 FROM t1 INTO t1' at line 1 +(SELECT 1 FROM t1 INTO @var17727401) UNION (SELECT 1 FROM t1 INTO t1); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'UNION (SELECT 1 FROM t1 INTO t1)' at line 1 +SELECT 1 FROM t1 UNION SELECT 1 FROM t1 INTO @var17727401; +Warnings: +Warning 1329 No data - zero rows fetched, selected, or processed +# ORDER and LIMIT clause combinations +(SELECT 1 FROM t1 ORDER BY 1) ORDER BY 1; +1 +(SELECT 1 FROM t1 LIMIT 1) LIMIT 1; +1 +((SELECT 1 FROM t1 ORDER BY 1) ORDER BY 1) ORDER BY 1; +ERROR 42000: This version of MySQL doesn't yet support 'parenthesized query expression with more than one external level of ORDER/LIMIT operations' +((SELECT 1 FROM t1 LIMIT 1) LIMIT 1) LIMIT 1; +1 +(SELECT 1 FROM t1 ORDER BY 1) LIMIT 1; +1 +(SELECT 1 FROM t1 LIMIT 1) ORDER BY 1; +1 +((SELECT 1 FROM t1 ORDER BY 1) LIMIT 1) ORDER BY 1); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')' at line 1 +((SELECT 1 FROM t1 LIMIT 1) ORDER BY 1) LIMIT 1); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')' at line 1 +SELECT 1 FROM t1 UNION SELECT 1 FROM t1 ORDER BY 1; +1 +SELECT (SELECT 1 FROM t1 UNION SELECT 1 FROM t1 ORDER BY 1); +(SELECT 1 FROM t1 UNION SELECT 1 FROM t1 ORDER BY 1) +NULL +SELECT 1 FROM (SELECT 1 FROM t1 UNION SELECT 1 FROM t1 ORDER BY 1) a; +1 +SELECT 1 FROM t1 UNION SELECT 1 FROM t1 LIMIT 1; +1 +SELECT (SELECT 1 FROM t1 UNION SELECT 1 FROM t1 LIMIT 1); +(SELECT 1 FROM t1 UNION SELECT 1 FROM t1 LIMIT 1) +NULL +SELECT 1 FROM (SELECT 1 FROM t1 UNION SELECT 1 FROM t1 LIMIT 1) a; +1 +SELECT 1 FROM t1 UNION SELECT 1 FROM t1 ORDER BY 1 LIMIT 1; +1 +SELECT (SELECT 1 FROM t1 UNION SELECT 1 FROM t1 ORDER BY 1 LIMIT 1); +(SELECT 1 FROM t1 UNION SELECT 1 FROM t1 ORDER BY 1 LIMIT 1) +NULL +SELECT 1 FROM (SELECT 1 FROM t1 UNION SELECT 1 FROM t1 ORDER BY 1 LIMIT 1) a; +1 +SELECT 1 FROM t1 UNION SELECT 1 FROM t1 LIMIT 1 ORDER BY 1; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'ORDER BY 1' at line 1 +SELECT (SELECT 1 FROM t1 UNION SELECT 1 FROM t1 LIMIT 1 ORDER BY 1); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'ORDER BY 1)' at line 1 +SELECT 1 FROM (SELECT 1 FROM t1 UNION SELECT 1 FROM t1 LIMIT 1 ORDER BY 1) a; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'ORDER BY 1) a' at line 1 +SELECT 1 FROM t1 ORDER BY 1 UNION SELECT 1 FROM t1; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'UNION SELECT 1 FROM t1' at line 1 +SELECT (SELECT 1 FROM t1 ORDER BY 1 UNION SELECT 1 FROM t1); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'UNION SELECT 1 FROM t1)' at line 1 +SELECT 1 FROM (SELECT 1 FROM t1 ORDER BY 1 UNION SELECT 1 FROM t1) a; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'UNION SELECT 1 FROM t1) a' at line 1 +SELECT 1 FROM t1 LIMIT 1 UNION SELECT 1 FROM t1; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'UNION SELECT 1 FROM t1' at line 1 +SELECT (SELECT 1 FROM t1 LIMIT 1 UNION SELECT 1 FROM t1); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'UNION SELECT 1 FROM t1)' at line 1 +SELECT 1 FROM (SELECT 1 FROM t1 LIMIT 1 UNION SELECT 1 FROM t1) a; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'UNION SELECT 1 FROM t1) a' at line 1 +SELECT 1 FROM t1 ORDER BY 1 LIMIT 1 UNION SELECT 1 FROM t1; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'UNION SELECT 1 FROM t1' at line 1 +SELECT (SELECT 1 FROM t1 ORDER BY 1 LIMIT 1 UNION SELECT 1 FROM t1); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'UNION SELECT 1 FROM t1)' at line 1 +SELECT 1 FROM (SELECT 1 FROM t1 ORDER BY 1 LIMIT 1 UNION SELECT 1 FROM t1) a; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'UNION SELECT 1 FROM t1) a' at line 1 +SELECT 1 FROM t1 LIMIT 1 ORDER BY 1 UNION SELECT 1 FROM t1; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'ORDER BY 1 UNION SELECT 1 FROM t1' at line 1 +SELECT (SELECT 1 FROM t1 LIMIT 1 ORDER BY 1 UNION SELECT 1 FROM t1); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'ORDER BY 1 UNION SELECT 1 FROM t1)' at line 1 +SELECT 1 FROM (SELECT 1 FROM t1 LIMIT 1 ORDER BY 1 UNION SELECT 1 FROM t1) a; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'ORDER BY 1 UNION SELECT 1 FROM t1) a' at line 1 +SELECT 1 FROM t1 ORDER BY 1 UNION SELECT 1 FROM t1 ORDER BY 1; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'UNION SELECT 1 FROM t1 ORDER BY 1' at line 1 +SELECT (SELECT 1 FROM t1 ORDER BY 1 UNION SELECT 1 FROM t1 ORDER BY 1); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'UNION SELECT 1 FROM t1 ORDER BY 1)' at line 1 +SELECT 1 FROM (SELECT 1 FROM t1 ORDER BY 1 UNION SELECT 1 FROM t1 ORDER BY 1) a; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'UNION SELECT 1 FROM t1 ORDER BY 1) a' at line 1 +SELECT 1 FROM t1 LIMIT 1 UNION SELECT 1 FROM t1 LIMIT 1; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'UNION SELECT 1 FROM t1 LIMIT 1' at line 1 +SELECT (SELECT 1 FROM t1 LIMIT 1 UNION SELECT 1 FROM t1 LIMIT 1); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'UNION SELECT 1 FROM t1 LIMIT 1)' at line 1 +SELECT 1 FROM (SELECT 1 FROM t1 LIMIT 1 UNION SELECT 1 FROM t1 LIMIT 1) a; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'UNION SELECT 1 FROM t1 LIMIT 1) a' at line 1 +SELECT 1 FROM t1 LIMIT 1 UNION SELECT 1 FROM t1 ORDER BY 1; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'UNION SELECT 1 FROM t1 ORDER BY 1' at line 1 +SELECT (SELECT 1 FROM t1 LIMIT 1 UNION SELECT 1 FROM t1 ORDER BY 1); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'UNION SELECT 1 FROM t1 ORDER BY 1)' at line 1 +SELECT 1 FROM (SELECT 1 FROM t1 LIMIT 1 UNION SELECT 1 FROM t1 ORDER BY 1) a; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'UNION SELECT 1 FROM t1 ORDER BY 1) a' at line 1 +SELECT 1 FROM t1 ORDER BY 1 UNION SELECT 1 FROM t1 LIMIT 1; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'UNION SELECT 1 FROM t1 LIMIT 1' at line 1 +SELECT (SELECT 1 FROM t1 ORDER BY 1 UNION SELECT 1 FROM t1 LIMIT 1); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'UNION SELECT 1 FROM t1 LIMIT 1)' at line 1 +SELECT 1 FROM (SELECT 1 FROM t1 ORDER BY 1 UNION SELECT 1 FROM t1 LIMIT 1) a; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'UNION SELECT 1 FROM t1 LIMIT 1) a' at line 1 +DROP TABLE t1; +# +# Bug #18106014: RECENT REGRESSION: MORE CASES OF ASSERTION FAILED: +# !JOIN->PLAN_IS_CONST() +# +SELECT COUNT(1) FROM DUAL GROUP BY '1' ORDER BY 1 ; +COUNT(1) +1 +SELECT COUNT(1) GROUP BY '1' ORDER BY 1 ; +COUNT(1) +1 +DO(SELECT 1 c GROUP BY 1 HAVING 1 ORDER BY COUNT(1)); +DO(SELECT 1 c FROM DUAL GROUP BY 1 HAVING 1 ORDER BY COUNT(1)); +SELECT (SELECT 1 c GROUP BY 1 HAVING 1 ORDER BY COUNT(1)) AS +'null is not expected'; +null is not expected +1 +SELECT (SELECT 1 c FROM DUAL GROUP BY 1 HAVING 1 ORDER BY COUNT(1)) AS +'null is not expected'; +null is not expected +1 +SELECT (SELECT 1 c GROUP BY 1 HAVING 0 ORDER BY COUNT(1)) AS +'null is expected'; +null is expected +NULL +SELECT (SELECT 1 c FROM DUAL GROUP BY 1 HAVING 0 ORDER BY COUNT(1)) AS +'null is expected'; +null is expected +NULL +SELECT (SELECT 1 c WHERE 1 GROUP BY 1 HAVING 1 ORDER BY COUNT(1)) AS +'null is not expected'; +null is not expected +1 +SELECT (SELECT 1 c FROM DUAL WHERE 1 GROUP BY 1 HAVING 1 ORDER BY COUNT(1)) AS +'null is not expected'; +null is not expected +1 +SELECT (SELECT 1 c WHERE 1 GROUP BY 1 HAVING 0 ORDER BY COUNT(1)) AS +'null is expected'; +null is expected +NULL +SELECT (SELECT 1 c FROM DUAL WHERE 1 GROUP BY 1 HAVING 0 ORDER BY COUNT(1)) AS +'null is expected'; +null is expected +NULL +SELECT (SELECT 1 c WHERE 0 GROUP BY 1 HAVING 1 ORDER BY COUNT(1)) AS +'null is expected'; +null is expected +NULL +SELECT (SELECT 1 c FROM DUAL WHERE 0 GROUP BY 1 HAVING 1 ORDER BY COUNT(1)) AS +'null is expected'; +null is expected +NULL +SELECT (SELECT 1 c WHERE 0 GROUP BY 1 HAVING 0 ORDER BY COUNT(1)) AS +'null is expected'; +null is expected +NULL +SELECT (SELECT 1 c FROM DUAL WHERE 0 GROUP BY 1 HAVING 0 ORDER BY COUNT(1)) AS +'null is expected'; +null is expected +NULL +SELECT 1 c FROM DUAL GROUP BY 1 HAVING 1 ORDER BY COUNT(1); +c +1 +SELECT 1 c FROM DUAL GROUP BY 1 HAVING 0 ORDER BY COUNT(1); +c +SELECT 1 c GROUP BY 1 HAVING 1 ORDER BY COUNT(1); +c +1 +# +# Bug #18106058: RECENT REGRESSION: CRASH IN JOIN::MAKE_TMP_TABLES_INFO +# +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (1); +SELECT ((SELECT 1 AS f HAVING EXISTS(SELECT 1 FROM t1) IS TRUE +ORDER BY f)); +((SELECT 1 AS f HAVING EXISTS(SELECT 1 FROM t1) IS TRUE +ORDER BY f)) +1 +SELECT ((SELECT 1 AS f FROM DUAL HAVING EXISTS(SELECT 1 FROM t1) IS TRUE +ORDER BY f)); +((SELECT 1 AS f FROM DUAL HAVING EXISTS(SELECT 1 FROM t1) IS TRUE +ORDER BY f)) +1 +SELECT 1 AS f FROM DUAL HAVING EXISTS(SELECT 1 FROM t1) IS TRUE +ORDER BY f; +f +1 +SELECT 1 AS f HAVING EXISTS(SELECT 1 FROM t1) IS TRUE +ORDER BY f; +f +1 +DROP TABLE t1; +# +# Bug#17075846 : unquoted file names for variable values are +# accepted but parsed incorrectly +# +SET default_storage_engine=a.myisam; +ERROR 42000: Incorrect argument type to variable 'default_storage_engine' +SET default_storage_engine = .a.MyISAM; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '.a.MyISAM' at line 1 +SET default_storage_engine = a.b.MyISAM; +ERROR 42000: Incorrect argument type to variable 'default_storage_engine' +SET default_storage_engine = `a`.MyISAM; +ERROR 42000: Incorrect argument type to variable 'default_storage_engine' +SET default_storage_engine = `a`.`MyISAM`; +ERROR 42000: Incorrect argument type to variable 'default_storage_engine' +set default_storage_engine = "a.MYISAM"; +ERROR 42000: Unknown storage engine 'a.MYISAM' +set default_storage_engine = 'a.MYISAM'; +ERROR 42000: Unknown storage engine 'a.MYISAM' +set default_storage_engine = `a.MYISAM`; +ERROR 42000: Unknown storage engine 'a.MYISAM' +CREATE TABLE t1 (s VARCHAR(100)); +CREATE TRIGGER trigger1 BEFORE INSERT ON t1 FOR EACH ROW +SET default_storage_engine = NEW.INNODB; +ERROR 42S22: Unknown column 'INNODB' in 'NEW' +DROP TABLE t1; +# +# Some additional coverage tests for WL#7199 and friends +# +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (1), (2); +CREATE TABLE t2 (i INT); +INSERT INTO t2 VALUES (10), (20); +SELECT i FROM t1 WHERE i = 1 +UNION +SELECT i FROM t2 WHERE i = 10 +ORDER BY i; +i +1 +10 +SELECT i FROM t1 WHERE i = 1 +UNION +SELECT i FROM t2 WHERE i = 10 +LIMIT 100; +i +1 +10 +SELECT i FROM t1 WHERE i = 1 +UNION +SELECT i FROM t2 GROUP BY i HAVING i = 10 +ORDER BY i; +i +1 +10 +SELECT i FROM t1 WHERE i = 1 +UNION +SELECT i FROM t2 GROUP BY i HAVING i = 10 +LIMIT 100; +i +1 +10 +(SELECT i FROM t1 WHERE i = 1) ORDER BY i; +i +1 +(SELECT i FROM t1 WHERE i = 1) LIMIT 100; +i +1 +(SELECT i FROM t1 GROUP BY i HAVING i = 1) ORDER BY i; +i +1 +(SELECT i FROM t1 GROUP BY i HAVING i = 1) LIMIT 100; +i +1 +DROP TABLE t1, t2; +# +# Bug#18486460 ASSERTION FAILED: N < M_SIZE AFTER FIX_INNER_REFS +# +CREATE TABLE t1(b INT); +CREATE TABLE t2(a INT, b INT, c INT, d INT); +EXPLAIN SELECT +( +SELECT +ROW(t1.b, a) = ROW( ROW(1, t2.c) = ROW(1, d), c) = a +FROM t1 +) +FROM t2 GROUP BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using temporary +2 DEPENDENT SUBQUERY t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1276 Field or reference 'test.t2.c' of SELECT #2 was resolved in SELECT #1 +Note 1276 Field or reference 'test.t2.d' of SELECT #2 was resolved in SELECT #1 +Note 1276 Field or reference 'test.t2.a' of SELECT #2 was resolved in SELECT #1 +Note 1276 Field or reference 'test.t2.c' of SELECT #2 was resolved in SELECT #1 +Note 1276 Field or reference 'test.t2.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select (/* select#2 */ select (((`test`.`t1`.`b` = ((1 = 1) and (`test`.`t2`.`c` = `test`.`t2`.`d`))) and (`test`.`t2`.`a` = `test`.`t2`.`c`)) = `test`.`t2`.`a`) from `test`.`t1`) AS `( +SELECT +ROW(t1.b, a) = ROW( ROW(1, t2.c) = ROW(1, d), c) = a +FROM t1 +)` from `test`.`t2` group by `test`.`t2`.`a` +DROP TABLE t1, t2; +# +# Bug#18498344: SELECT WITH ALIAS NOT WORKING IN 5.7 +# +CREATE TABLE t1 ( +a INT +); +INSERT INTO t1 VALUES ( 2 ); +# Should succeed +SELECT * +FROM ( SELECT a FROM t1 UNION SELECT 1 ORDER BY a ) AS a1 +WHERE a1.a = 1 OR a1.a = 2; +a +1 +2 +DROP TABLE t1; +# +# Bug #18484088: PROBLEMS IN CREATE_FUNC_CAST ON QUERY ERRORS... +# +DO(CONVERT(CONVERT('',DECIMAL(66,0)), DECIMAL(66,0))), CAST(CONVERT(1,DECIMAL(65,31)) AS DATE); +ERROR 42000: Too-big precision 66 specified for ''''. Maximum is 65. +SELECT CONVERT(CONVERT('',DECIMAL(65,0)), DECIMAL(66,0)); +ERROR 42000: Too-big precision 66 specified for 'CONVERT('',DECIMAL(65,0))'. Maximum is 65. +# +# Bug #18759387: PROBLEM IN ITEM_FUNC_XOR::NEG_TRANSFORMER +# +SELECT 1< +!(1 XOR TO_BASE64())); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')' at line 2 +SELECT 1< +!(1 XOR TO_BASE64()); +ERROR 42000: Incorrect parameter count in the call to native function 'TO_BASE64' +SELECT !('' XOR LENGTH()); +ERROR 42000: Incorrect parameter count in the call to native function 'LENGTH' +SELECT !((UNHEX() IS NULL)); +ERROR 42000: Incorrect parameter count in the call to native function 'UNHEX' +# +# Bug #20086997: PARSER CONFUSES WITH 7BIT-CHARACTER STRING DETECTION +# +CREATE DATABASE mysqltest1 CHARACTER SET LATIN2; +USE mysqltest1; +CREATE TABLE t1 (a VARCHAR(255) CHARACTER SET LATIN2); +SET CHARACTER SET cp1250_latin2; +INSERT INTO t1 VALUES ('£¥ª¯'); +INSERT INTO t1 VALUES ('£¥ª¯' ''); +SELECT HEX(a) FROM t1; +HEX(a) +A3A1AAAF +A3A1AAAF +DROP DATABASE mysqltest1; +USE test; +# +# WL #7201, WL #7202 and WL#8062 coverage tests +# +CREATE TABLE t1 (i INT); +INSERT INTO t1 () SELECT * FROM t1; +INSERT INTO t1 SELECT HIGH_PRIORITY * FROM t1; +INSERT INTO t1 SELECT DISTINCT ALL * FROM t1; +ERROR HY000: Incorrect usage of ALL and DISTINCT +REPLACE INTO `` SELECT * FROM ``; +ERROR 42000: Incorrect table name '' +DELETE QUICK FROM t1 WHERE i = 0; +DROP TABLE t1; +# +# Bug #21035515: PARSE_GCOL_EXPR SHOULD BE A KIND OF RESERVED WORD, +# NOT A KEYWORD +SET @parse_gcol_expr = 1; +SELECT 1 AS parse_gcol_expr; +parse_gcol_expr +1 +CREATE TABLE parse_gcol_expr (i INT); +DROP TABLE parse_gcol_expr; +# parse_gcol_expr can't be a label: +CREATE PROCEDURE p1() +BEGIN +parse_gcol_expr: LOOP +SELECT 1; +END LOOP parse_gcol_expr; +END| +DROP PROCEDURE p1; +# PARSE_GCOL_EXPR is not a valid statement: +PARSE_GCOL_EXPR (1); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'PARSE_GCOL_EXPR (1)' at line 1 +# +# Bug #17400320 ALGORITHM= IS NOT SUPPORTED FOR ALTER TABLE WITH +# +CREATE TABLE t1 (x INT PRIMARY KEY); +ALTER TABLE t1; +ALTER TABLE t1 ALGORITHM=DEFAULT; +ALTER TABLE t1 ALGORITHM=COPY; +ALTER TABLE t1 ALGORITHM=INPLACE; +ALTER TABLE t1 LOCK=DEFAULT; +ALTER TABLE t1 LOCK=NONE; +ERROR 0A000: LOCK=NONE/SHARED is not supported for this operation. Try LOCK=EXCLUSIVE. +ALTER TABLE t1 LOCK=SHARED; +ERROR 0A000: LOCK=NONE/SHARED is not supported for this operation. Try LOCK=EXCLUSIVE. +ALTER TABLE t1 LOCK=EXCLUSIVE; +ALTER TABLE t1 LOCK=SHARED, ALGORITHM=COPY, +LOCK=NONE, ALGORITHM=DEFAULT, +LOCK=EXCLUSIVE, ALGORITHM=INPLACE; +ALTER TABLE t1 WITH VALIDATION; +ERROR HY000: Incorrect usage of ALTER and WITH VALIDATION +ALTER TABLE t1 WITHOUT VALIDATION; +ERROR HY000: Incorrect usage of ALTER and WITH VALIDATION +ALTER TABLE t1 LOCK=SHARED, WITH VALIDATION, ALGORITHM=COPY, +LOCK=EXCLUSIVE, WITHOUT VALIDATION, ALGORITHM=INPLACE; +ERROR HY000: Incorrect usage of ALTER and WITH VALIDATION +DROP TABLE t1; +# +# WL#8083: Introduce parser rule +# Bug#14743786: PARSE ERROR WITH UNION PARENTHESES ON TOP LEVEL +# +# +# Part1: Regression Testing. +# +CREATE TABLE t1 ( a INT ); +INSERT INTO t1 VALUES ( 1 ); +CREATE TABLE t2 ( a INT ); +INSERT INTO t2 VALUES ( 2 ), ( 2 ); +CREATE TABLE t3 ( a INT ); +INSERT INTO t3 VALUES ( 3 ), ( 3 ), ( 3 ); +SELECT 1 UNION SELECT 2; +1 +1 +2 +(SELECT 1) UNION SELECT 2; +1 +1 +2 +SELECT 1 UNION (SELECT 2); +1 +1 +2 +(SELECT 1) UNION (SELECT 2); +1 +1 +2 +SELECT 2 FROM t1 UNION ((SELECT 3 FROM t1)); +2 +2 +3 +(SELECT 2 FROM t1) UNION SELECT 3 FROM t1; +2 +2 +3 +((SELECT 2 FROM t1)) UNION SELECT 3 FROM t1; +2 +2 +3 +(SELECT 1 FROM t1 ORDER BY 1) ORDER BY 1; +1 +1 +(SELECT 1 FROM t1 LIMIT 1) LIMIT 1; +1 +1 +SELECT a FROM t1 LIMIT 1 UNION ALL SELECT a FROM t1; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'UNION ALL SELECT a FROM t1' at line 1 +(SELECT 1) UNION (SELECT 2 UNION SELECT 3); +ERROR 42000: This version of MySQL doesn't yet support 'nesting of unions at the right-hand side' +(SELECT a FROM t1 LIMIT 1) UNION ALL (SELECT a FROM t1 ORDER BY a) LIMIT 2; +a +1 +1 +(SELECT a FROM t1 LIMIT 1) UNION ALL ((SELECT a FROM t1 ORDER BY a)) LIMIT 2; +a +1 +1 +SELECT 1 UNION SELECT 2 FROM t1 ORDER BY a LIMIT 1; +ERROR 42S22: Unknown column 'a' in 'order clause' +SELECT 1 UNION (SELECT 2 FROM t1 ORDER BY a LIMIT 1); +1 +1 +2 +(SELECT 1 FROM t1 LIMIT 2) UNION SELECT 2 FROM t1 ORDER BY a LIMIT 1; +ERROR 42S22: Unknown column 'a' in 'order clause' +(SELECT 1 FROM t1 LIMIT 2) UNION (SELECT 2 FROM t1 ORDER BY a LIMIT 1); +1 +1 +2 +(SELECT a FROM t1 LIMIT 2) LIMIT 1; +a +1 +((SELECT a FROM t1 LIMIT 2)) LIMIT 1; +a +1 +(SELECT a FROM t1 LIMIT 2) ORDER BY 1; +a +1 +(SELECT 1 FROM t1 LIMIT 2) UNION (SELECT 2 FROM t1 ORDER BY a LIMIT 1) LIMIT 1; +1 +1 +(SELECT 1 FROM t1 LIMIT 2) UNION (SELECT 2 FROM t1 ORDER BY a LIMIT 1) +ORDER BY a; +ERROR 42S22: Unknown column 'a' in 'order clause' +(SELECT 1 FROM t1 LIMIT 1) UNION ((SELECT 2 FROM t1 ORDER BY a LIMIT 2)) +ORDER BY a; +ERROR 42S22: Unknown column 'a' in 'order clause' +(SELECT a FROM t2 LIMIT 1) UNION (SELECT a FROM t3 LIMIT 2) LIMIT 1; +a +2 +(SELECT 1 FROM t1 ORDER BY 1) ORDER BY 1; +1 +1 +(SELECT a FROM t1 LIMIT 1) ORDER BY t1.a; +ERROR 42000: Table 't1' from one of the SELECTs cannot be used in global ORDER clause +((SELECT a FROM t1 LIMIT 1)) ORDER BY t1.a; +ERROR 42000: Table 't1' from one of the SELECTs cannot be used in global ORDER clause +(SELECT a FROM t1 LIMIT 1) UNION ALL (SELECT 2) ORDER BY t1.b; +ERROR 42000: Table 't1' from one of the SELECTs cannot be used in global ORDER clause +(SELECT a FROM t1 LIMIT 1) UNION ALL ((SELECT 2)) ORDER BY t1.b; +ERROR 42000: Table 't1' from one of the SELECTs cannot be used in global ORDER clause +(SELECT a FROM t1 LIMIT 1) UNION ALL (SELECT a FROM t1 ORDER BY a LIMIT 2) +ORDER BY t1.b; +ERROR 42000: Table 't1' from one of the SELECTs cannot be used in global ORDER clause +SELECT 1 UNION ( SELECT 1 UNION SELECT 1 ); +ERROR 42000: This version of MySQL doesn't yet support 'nesting of unions at the right-hand side' +( SELECT 1 UNION SELECT 1 ) UNION SELECT 1; +1 +1 +( (SELECT 1 UNION SELECT 1 ) UNION SELECT 1 ) UNION SELECT 1; +1 +1 +( SELECT 1 UNION ( SELECT 1 UNION SELECT 1 ) UNION SELECT 1 ); +ERROR 42000: This version of MySQL doesn't yet support 'nesting of unions at the right-hand side' +( SELECT 1 UNION ( SELECT 1 UNION SELECT 1 ) UNION SELECT 1; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1 +SELECT a FROM t1 ORDER BY a UNION SELECT a FROM t1; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'UNION SELECT a FROM t1' at line 1 +(SELECT * FROM t1 LIMIT 1) UNION SELECT * FROM t1; +a +1 +(SELECT * FROM t1 ORDER BY a) UNION SELECT * FROM t1; +a +1 +SELECT a FROM t1 +UNION +SELECT a FROM t1 ORDER BY a +UNION +SELECT a FROM t1; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'UNION +SELECT a FROM t1' at line 4 +(SELECT SQL_CALC_FOUND_ROWS a FROM t1 LIMIT 2) +UNION +(SELECT a FROM t2 ORDER BY a) LIMIT 2; +a +1 +2 +Warnings: +Warning 1287 SQL_CALC_FOUND_ROWS is deprecated and will be removed in a future release. Consider using two separate queries instead. +DROP TABLE t1, t2, t3; +CREATE PROCEDURE p1() BEGIN IF whatever THEN SELECT 1; END IF; END| +CALL p1(); +ERROR 42S22: Unknown column 'whatever' in 'field list' +DROP PROCEDURE p1; +# +# Part 2: Test of changed (fixed) behavior. +# +CREATE TABLE t1 ( a INT ); +INSERT INTO t1 VALUES ( 1 ); +CREATE TABLE t2 ( a INT ); +INSERT INTO t2 VALUES ( 2 ), ( 2 ); +CREATE TABLE t3 ( a INT ); +INSERT INTO t3 VALUES ( 3 ), ( 3 ), ( 3 ); +(SELECT 1 FROM t1 UNION SELECT 2 FROM t1); +1 +1 +2 +((SELECT 1 FROM t1 UNION SELECT 2 FROM t1)); +1 +1 +2 +(SELECT 1 FROM t1 UNION (SELECT 2 FROM t1)); +1 +1 +2 +((SELECT 1 FROM t1 UNION (SELECT 2 FROM t1))); +1 +1 +2 +((SELECT 1 FROM t1 UNION ((SELECT 2 FROM t1)))); +1 +1 +2 +((SELECT 1 FROM t1) UNION SELECT 2 FROM t1); +1 +1 +2 +(((SELECT 1 FROM t1)) UNION SELECT 2 FROM t1); +1 +1 +2 +((((SELECT 1 FROM t1)) UNION SELECT 2 FROM t1)); +1 +1 +2 +((SELECT 1 FROM t1) UNION (SELECT 2 FROM t1)); +1 +1 +2 +(((SELECT 1 FROM t1) UNION (SELECT 2 FROM t1))); +1 +1 +2 +((((SELECT 1 FROM t1)) UNION (SELECT 2 FROM t1))); +1 +1 +2 +(((SELECT 1 FROM t1) UNION ((SELECT 2 FROM t1)))); +1 +1 +2 +((((SELECT 1 FROM t1)) UNION ((SELECT 2 FROM t1)))); +1 +1 +2 +(SELECT 1 UNION SELECT 2) ORDER BY 1; +1 +1 +2 +((SELECT 1 UNION SELECT 2)) ORDER BY 1; +1 +1 +2 +((SELECT 1) ORDER BY 1); +1 +1 +((SELECT 1) LIMIT 1); +1 +1 +(SELECT 1 UNION SELECT 2) LIMIT 1; +1 +1 +((SELECT 1 UNION SELECT 2)) LIMIT 1; +1 +1 +(SELECT a FROM t1) LIMIT 1 UNION ALL ((SELECT a FROM t1 ORDER BY a)) LIMIT 2; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'UNION ALL ((SELECT a FROM t1 ORDER BY a)) LIMIT 2' at line 1 +DROP TABLE t1, t2, t3; +# +# Part 3: The syntax. +# +CREATE TABLE t1 ( a INT ); +INSERT INTO t1 VALUES ( 1 ); +CREATE TABLE t2 ( a INT ); +INSERT INTO t2 VALUES ( 2 ); +CREATE TABLE t3 ( a INT ); +INSERT INTO t3 VALUES ( 3 ); +CREATE TABLE t4 ( a INT ); +INSERT INTO t4 VALUES ( 3 ); +SELECT * FROM (SELECT 1 FROM t1 UNION SELECT 2 FROM t1) dt; +1 +1 +2 +SELECT * FROM ((SELECT 1 FROM t1 UNION SELECT 2 FROM t1)) dt; +1 +1 +2 +SELECT * FROM (SELECT 1 FROM t1 UNION (SELECT 2 FROM t1)) dt; +1 +1 +2 +SELECT * FROM ((SELECT 1 FROM t1 UNION (SELECT 2 FROM t1))) dt; +1 +1 +2 +SELECT * FROM ((SELECT 1 FROM t1 UNION ((SELECT 2 FROM t1)))) dt; +1 +1 +2 +SELECT * FROM ((SELECT 1 FROM t1) UNION SELECT 2 FROM t1) dt; +1 +1 +2 +SELECT * FROM (((SELECT 1 FROM t1)) UNION SELECT 2 FROM t1) dt; +1 +1 +2 +SELECT * FROM ((((SELECT 1 FROM t1)) UNION SELECT 2 FROM t1)) dt; +1 +1 +2 +SELECT * FROM ((SELECT 1 FROM t1) UNION (SELECT 2 FROM t1)) dt; +1 +1 +2 +SELECT * FROM (((SELECT 1 FROM t1) UNION (SELECT 2 FROM t1))) dt; +1 +1 +2 +SELECT * FROM ((((SELECT 1 FROM t1)) UNION (SELECT 2 FROM t1))) dt; +1 +1 +2 +SELECT * FROM (((SELECT 1 FROM t1) UNION ((SELECT 2 FROM t1)))) dt; +1 +1 +2 +SELECT * FROM ((((SELECT 1 FROM t1)) UNION ((SELECT 2 FROM t1)))) dt; +1 +1 +2 +SELECT * FROM (SELECT 1 FROM t1 UNION SELECT 2 FROM t1); +ERROR 42000: Every derived table must have its own alias +SELECT * FROM ((SELECT 1 FROM t1 UNION SELECT 2 FROM t1)); +ERROR 42000: Every derived table must have its own alias +SELECT * FROM (SELECT 1 FROM t1 UNION (SELECT 2 FROM t1)); +ERROR 42000: Every derived table must have its own alias +SELECT * FROM ((SELECT 1 FROM t1 UNION (SELECT 2 FROM t1))); +ERROR 42000: Every derived table must have its own alias +SELECT * FROM ((SELECT 1 FROM t1 UNION ((SELECT 2 FROM t1)))); +ERROR 42000: Every derived table must have its own alias +SELECT * FROM ((SELECT 1 FROM t1) UNION SELECT 2 FROM t1); +ERROR 42000: Every derived table must have its own alias +SELECT * FROM (((SELECT 1 FROM t1)) UNION SELECT 2 FROM t1); +ERROR 42000: Every derived table must have its own alias +SELECT * FROM ((((SELECT 1 FROM t1)) UNION SELECT 2 FROM t1)); +ERROR 42000: Every derived table must have its own alias +SELECT * FROM ((SELECT 1 FROM t1) UNION (SELECT 2 FROM t1)); +ERROR 42000: Every derived table must have its own alias +SELECT * FROM (((SELECT 1 FROM t1) UNION (SELECT 2 FROM t1))); +ERROR 42000: Every derived table must have its own alias +SELECT * FROM ((((SELECT 1 FROM t1)) UNION (SELECT 2 FROM t1))); +ERROR 42000: Every derived table must have its own alias +SELECT * FROM (((SELECT 1 FROM t1) UNION ((SELECT 2 FROM t1)))); +ERROR 42000: Every derived table must have its own alias +SELECT * FROM ((((SELECT 1 FROM t1)) UNION ((SELECT 2 FROM t1)))); +ERROR 42000: Every derived table must have its own alias +SELECT * FROM ( t1 JOIN t2 ON TRUE ); +a a +1 2 +SELECT * FROM (( t1 JOIN t2 ON TRUE )); +a a +1 2 +SELECT * FROM ( t1 JOIN t2 ON TRUE JOIN t3 ON TRUE ); +a a a +1 2 3 +SELECT * FROM ((t1 JOIN t2 ON TRUE) JOIN t3 ON TRUE ); +a a a +1 2 3 +SELECT * FROM (t1 INNER JOIN t2 ON (t1.a = t2.a)); +a a +SELECT 1 FROM (SELECT 1 FROM t1 INTO @v) a; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'INTO @v) a' at line 1 +SELECT 1 FROM (t1); +1 +1 +SELECT 1 FROM ((t1)); +1 +1 +SELECT 1 UNION SELECT 2 FROM (t2); +1 +1 +2 +SELECT 1 FROM (SELECT 2 ORDER BY 1) AS res; +1 +1 +# +# This syntax is no longer allowed +# +SELECT 1 FROM ((SELECT 2) ORDER BY 1) AS res; +1 +1 +SELECT 1 FROM ((SELECT 2) a ORDER BY 1) AS res; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'ORDER BY 1) AS res' at line 1 +SELECT 1 FROM ((SELECT 2) LIMIT 1) AS res; +1 +1 +SELECT 1 FROM ((SELECT 2) a LIMIT 1) AS res; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'LIMIT 1) AS res' at line 1 +SELECT * FROM ( t1 AS alias1 ); +a +1 +SELECT * FROM t1 AS alias1, t2 AS alias2; +a a +1 2 +SELECT * FROM ( t1 AS alias1, t2 AS alias2 ); +a a +1 2 +SELECT * FROM ( t1 JOIN t2 ON TRUE, t1 JOIN t3 ON TRUE ); +ERROR 42000: Not unique table/alias: 't1' +SELECT * FROM ( t1 JOIN t2 ON TRUE, t1 t11 JOIN t3 ON TRUE ) t1a; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 't1a' at line 1 +SELECT * FROM ( t1 JOIN t2 ON TRUE, SELECT 1 FROM DUAL ); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'SELECT 1 FROM DUAL )' at line 1 +SELECT * FROM ( t1 JOIN t2 ON TRUE, (SELECT 1 FROM DUAL) t1a ); +a a 1 +1 2 1 +SELECT * FROM t1 JOIN t2 ON TRUE, (SELECT 1 FROM DUAL) t1a; +a a 1 +1 2 1 +SELECT * FROM ( SELECT 1 FROM DUAL ); +ERROR 42000: Every derived table must have its own alias +SELECT * FROM ( SELECT 1 FROM DUAL ) t1a; +1 +1 +SELECT * FROM ( t1, t2 ); +a a +1 2 +SELECT * FROM (( t1, t2 )); +a a +1 2 +SELECT * FROM ( (t1), t2 ); +a a +1 2 +SELECT * FROM (((t1)), t2 ); +a a +1 2 +SELECT * FROM ( (t1), (t2) ); +a a +1 2 +SELECT * FROM ( t1, (t2) ); +a a +1 2 +((SELECT 1 UNION SELECT 1) UNION SELECT 1); +1 +1 +SELECT * FROM ((SELECT 1 UNION SELECT 1) UNION SELECT 1) a; +1 +1 +SELECT * FROM (t1, t2) JOIN (t3, t4) ON TRUE; +a a a a +1 2 3 3 +SELECT * FROM ((t1, t2) JOIN t3 ON TRUE); +a a a +1 2 3 +SELECT * FROM t1 JOIN ( t2, t3 ) USING ( a ); +ERROR 23000: Column 'a' in from clause is ambiguous +DROP TABLE t1, t2, t3, t4; +# Check the format in the note. +CREATE TABLE t1 (a INT); +EXPLAIN SELECT 1 FROM (SELECT 1 FROM t1) t; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` +DROP TABLE t1; +CREATE TABLE t1 ( a INT ); +CREATE TABLE t2 ( b INT ); +CREATE TABLE t3 ( c INT ); +CREATE TABLE t4 ( d INT ); +INSERT INTO t1 VALUES (1); +INSERT INTO t2 VALUES (2); +INSERT INTO t3 VALUES (2); +INSERT INTO t4 VALUES (2); +SELECT * FROM t1 LEFT JOIN ( t2, t3, t4 ) ON a = c; +a b c d +1 NULL NULL NULL +SELECT * FROM t1 NATURAL JOIN ((t1 NATURAL JOIN t1), (t1 NATURAL JOIN t1)); +ERROR 42000: Not unique table/alias: 't1' +DROP TABLE t1, t2, t3, t4; +CREATE TABLE t1 ( a INT ); +CREATE TABLE t2 ( b INT ); +CREATE TABLE t3 ( c INT ); +CREATE TABLE t4 ( d INT ); +CREATE TABLE t5 ( d INT ); +SELECT * FROM t5 NATURAL JOIN ((t1 NATURAL JOIN t2), (t3 NATURAL JOIN t4)); +d a b c +SELECT * FROM ((t1 NATURAL JOIN t2), (t3 NATURAL JOIN t4)) NATURAL JOIN t5; +d a b c +SELECT * FROM t1 JOIN ( t2, t3 ) ON TRUE; +a b c +SELECT * FROM ( t1, t2 , t3 ); +a b c +SELECT * FROM ( ( t1, t2 ), t3 ); +a b c +SELECT * FROM ( ((t1, t2)), t3 ); +a b c +SELECT * FROM ( t1, ( t2, t3 ) ); +a b c +SELECT * FROM ( t1, ((t2, t3)) ); +a b c +SELECT * FROM ((( t1, t2 ), t3)); +a b c +SELECT * FROM ((((t1, t2)), t3)); +a b c +SELECT * FROM ((t1, ( t2, t3 ))); +a b c +SELECT * FROM ((t1, ((t2, t3)))); +a b c +CREATE VIEW v1 AS SELECT 1 INTO @v; +ERROR HY000: View's SELECT contains a 'INTO' clause +CREATE VIEW v1 AS SELECT 1 FROM ( SELECT 1 FROM t1 ) my_table; +DROP TABLE t1, t2, t3, t4, t5; +DROP VIEW v1; +CREATE TABLE t1( a INT ); +INSERT INTO t1 VALUES (1); +SELECT 1 INTO @v; +(SELECT 1 INTO @v); +((SELECT 1 INTO @v)); +SELECT 1 FROM t1 INTO @v; +(SELECT 1 FROM t1 INTO @v); +((SELECT 1 FROM t1 INTO @v)); +SELECT 1 FROM t1 INTO @v UNION SELECT 1; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'UNION SELECT 1' at line 1 +(SELECT 1 FROM t1 INTO @v) UNION SELECT 1; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'UNION SELECT 1' at line 1 +SELECT 1 FROM t1 INTO @v UNION (SELECT 1); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'UNION (SELECT 1)' at line 1 +((SELECT 1 FROM t1 INTO @v) UNION (SELECT 1)); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'UNION (SELECT 1))' at line 1 +SELECT 1 INTO @v UNION SELECT 1; +ERROR HY000: Misplaced INTO clause, INTO is not allowed inside subqueries, and must be placed at end of UNION clauses. +(SELECT 1 INTO @v) UNION SELECT 1; +ERROR HY000: Misplaced INTO clause, INTO is not allowed inside subqueries, and must be placed at end of UNION clauses. +SELECT 1 INTO @v UNION (SELECT 1); +ERROR HY000: Misplaced INTO clause, INTO is not allowed inside subqueries, and must be placed at end of UNION clauses. +((SELECT 1 INTO @v) UNION (SELECT 1)); +ERROR HY000: Misplaced INTO clause, INTO is not allowed inside subqueries, and must be placed at end of UNION clauses. +SELECT 1 UNION SELECT 2 INTO @v; +ERROR 42000: Result consisted of more than one row +(SELECT 1) UNION SELECT 2 INTO @v; +ERROR 42000: Result consisted of more than one row +(SELECT 1) UNION (SELECT 2 INTO @v); +ERROR 42000: Result consisted of more than one row +((SELECT 1) UNION (SELECT 2 INTO @v)); +ERROR 42000: Result consisted of more than one row +SELECT 1 UNION SELECT 2 INTO @v FROM t1; +ERROR 42000: Result consisted of more than one row +(SELECT 1) UNION SELECT 2 INTO @v FROM t1; +ERROR 42000: Result consisted of more than one row +(SELECT 1) UNION (SELECT 2 INTO @v FROM t1); +ERROR 42000: Result consisted of more than one row +((SELECT 1) UNION (SELECT 2 INTO @v FROM t1)); +ERROR 42000: Result consisted of more than one row +SELECT 1 UNION SELECT 1 INTO @v FROM t1; +Warnings: +Warning 3962 The INTO clause is deprecated inside query blocks of query expressions and will be removed in a future release. Please move the INTO clause to the end of statement instead. +(SELECT 1) UNION SELECT 1 INTO @v FROM t1; +Warnings: +Warning 3962 The INTO clause is deprecated inside query blocks of query expressions and will be removed in a future release. Please move the INTO clause to the end of statement instead. +(SELECT 1) UNION (SELECT 1 INTO @v FROM t1); +Warnings: +Warning 3962 The INTO clause is deprecated inside query blocks of query expressions and will be removed in a future release. Please move the INTO clause to the end of statement instead. +((SELECT 1) UNION (SELECT 1 INTO @v FROM t1)); +Warnings: +Warning 3962 The INTO clause is deprecated inside query blocks of query expressions and will be removed in a future release. Please move the INTO clause to the end of statement instead. +SELECT 1 UNION SELECT 2 INTO OUTFILE 'parser.test.file1'; +SELECT 1 UNION (SELECT 2 INTO OUTFILE 'parser.test.file2'); +Warnings: +Warning 3962 The INTO clause is deprecated inside query blocks of query expressions and will be removed in a future release. Please move the INTO clause to the end of statement instead. +(SELECT 1) UNION SELECT 2 INTO OUTFILE 'parser.test.file3'; +(SELECT 1) UNION (SELECT 2 INTO OUTFILE 'parser.test.file4'); +Warnings: +Warning 3962 The INTO clause is deprecated inside query blocks of query expressions and will be removed in a future release. Please move the INTO clause to the end of statement instead. +((SELECT 1) UNION (SELECT 2 INTO OUTFILE 'parser.test.file5')); +Warnings: +Warning 3962 The INTO clause is deprecated inside query blocks of query expressions and will be removed in a future release. Please move the INTO clause to the end of statement instead. +SELECT * FROM (SELECT a INTO @v FROM t1) t1a; +ERROR HY000: Misplaced INTO clause, INTO is not allowed inside subqueries, and must be placed at end of UNION clauses. +SELECT * FROM (SELECT a INTO @v) t1a; +ERROR HY000: Misplaced INTO clause, INTO is not allowed inside subqueries, and must be placed at end of UNION clauses. +DROP TABLE t1; +# +# Part 4: The syntax. +# +CREATE TABLE t1( a INT ); +CREATE TABLE t2( b INT ); +CREATE TABLE t3( c INT ); +CREATE TABLE t4( d INT ); +CREATE TABLE t5( e INT ); +# We use EXPLAIN so we can get the parser's interpretation of the +# nesting. We don't really care about the execution plan. +SET optimizer_switch = 'block_nested_loop=off'; +SELECT * FROM t1 JOIN t2; +a b +SELECT * FROM t1 JOIN t2 ON a = b; +a b +SELECT * FROM t1 t11 JOIN t1 t12 USING ( a ); +a +SELECT * FROM t1 INNER JOIN t2; +a b +SELECT * FROM t1 INNER JOIN t2 ON a = b; +a b +SELECT * FROM t1 t11 INNER JOIN t1 t12 USING ( a ); +a +SELECT * FROM t1 CROSS JOIN t2; +a b +SELECT * FROM t1 CROSS JOIN t2 ON a = b; +a b +SELECT * FROM t1 t11 CROSS JOIN t1 t12 USING ( a ); +a +SELECT * FROM t1 STRAIGHT_JOIN t2; +a b +SELECT * FROM t1 STRAIGHT_JOIN t2 ON a = b; +a b +SELECT * FROM t1 t11 STRAIGHT_JOIN t1 t12 USING ( a ); +a +SELECT * FROM t1 t11 NATURAL JOIN t1 t12; +a +SELECT * FROM t1 t11 NATURAL JOIN t1 t12 ON t11.a = t12.a; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'ON t11.a = t12.a' at line 1 +SELECT * FROM t1 t11 NATURAL JOIN t1 t12 USING ( a ); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'USING ( a )' at line 1 +SELECT * FROM t1 t11 NATURAL INNER JOIN t1 t12; +a +SELECT * FROM t1 LEFT JOIN t2; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1 +SELECT * FROM t1 LEFT JOIN t2 ON a = b; +a b +SELECT * FROM t1 t11 LEFT JOIN t1 t12 USING ( a ); +a +SELECT * FROM t1 NATURAL LEFT JOIN t2; +a b +SELECT * FROM t1 LEFT OUTER JOIN t2; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1 +SELECT * FROM t1 LEFT OUTER JOIN t2 ON a = b; +a b +SELECT * FROM t1 t11 LEFT OUTER JOIN t1 t12 USING ( a ); +a +SELECT * FROM t1 NATURAL LEFT OUTER JOIN t2; +a b +SELECT * FROM t1 RIGHT JOIN t2; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1 +SELECT * FROM t1 RIGHT JOIN t2 ON a = b; +a b +SELECT * FROM t1 t11 RIGHT JOIN t1 t12 USING ( a ); +a +SELECT * FROM t1 NATURAL RIGHT JOIN t2; +b a +SELECT * FROM t1 RIGHT OUTER JOIN t2; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1 +SELECT * FROM t1 RIGHT OUTER JOIN t2 ON a = b; +a b +SELECT * FROM t1 t11 RIGHT OUTER JOIN t1 t12 USING ( a ); +a +SELECT * FROM t1 NATURAL RIGHT OUTER JOIN t2; +b a +# Right-deep join nesting. +EXPLAIN SELECT * FROM t1 JOIN t2 JOIN t3 ON t2.b = t3.c ON t1.a = t2.b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`c` AS `c` from `test`.`t1` join `test`.`t2` join `test`.`t3` where ((`test`.`t2`.`b` = `test`.`t1`.`a`) and (`test`.`t3`.`c` = `test`.`t1`.`a`)) +# Right-deep join nesting from t2 and on. +EXPLAIN SELECT * FROM t1 JOIN t2 JOIN t3 JOIN t4 ON t3.c = t4.d ON t2.b = t3.c; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`c` AS `c`,`test`.`t4`.`d` AS `d` from `test`.`t1` join `test`.`t2` join `test`.`t3` join `test`.`t4` where ((`test`.`t3`.`c` = `test`.`t2`.`b`) and (`test`.`t4`.`d` = `test`.`t2`.`b`)) +# Right-deep join nesting from t2 and on. +EXPLAIN SELECT * FROM t1 JOIN t2 JOIN t3 JOIN t4 ON t3.c = t4.d ON t1.a = t2.b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`c` AS `c`,`test`.`t4`.`d` AS `d` from `test`.`t1` join `test`.`t2` join `test`.`t3` join `test`.`t4` where ((`test`.`t4`.`d` = `test`.`t3`.`c`) and (`test`.`t2`.`b` = `test`.`t1`.`a`)) +# Left-deep join nesting. +EXPLAIN SELECT * FROM t1 JOIN t2 ON t1.a = t2.b JOIN t3 ON t2.b = t3.c; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`c` AS `c` from `test`.`t1` join `test`.`t2` join `test`.`t3` where ((`test`.`t2`.`b` = `test`.`t1`.`a`) and (`test`.`t3`.`c` = `test`.`t1`.`a`)) +# A cross join joined with an inner join (i.e. with a join condition). +EXPLAIN SELECT * FROM t1 JOIN t2 JOIN t3 ON t1.a = t2.b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`c` AS `c` from `test`.`t1` join `test`.`t2` join `test`.`t3` where (`test`.`t2`.`b` = `test`.`t1`.`a`) +EXPLAIN SELECT * FROM t1 t11 JOIN t2 JOIN t1 t12 USING ( a ); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t11 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t12 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t11`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` `t11` join `test`.`t2` join `test`.`t1` `t12` where (`test`.`t12`.`a` = `test`.`t11`.`a`) +# A left-deep cross join tree joined with an inner join. +EXPLAIN SELECT * FROM t1 JOIN t2 JOIN t3 JOIN t4 ON t1.a = t2.b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`c` AS `c`,`test`.`t4`.`d` AS `d` from `test`.`t1` join `test`.`t2` join `test`.`t3` join `test`.`t4` where (`test`.`t2`.`b` = `test`.`t1`.`a`) +EXPLAIN SELECT * FROM t1 JOIN t2 JOIN t3 JOIN t4 JOIN t5 ON t1.a = t2.b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t5 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`c` AS `c`,`test`.`t4`.`d` AS `d`,`test`.`t5`.`e` AS `e` from `test`.`t1` join `test`.`t2` join `test`.`t3` join `test`.`t4` join `test`.`t5` where (`test`.`t2`.`b` = `test`.`t1`.`a`) +# The different kinds of when used with context-dependent +# join. Tests the top-down build of the parse tree. +EXPLAIN SELECT * FROM t1 JOIN (t2) JOIN t3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`c` AS `c` from `test`.`t1` join `test`.`t2` join `test`.`t3` +EXPLAIN SELECT * FROM t1 JOIN (SELECT 1 AS b) a JOIN t3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL system NULL NULL NULL NULL 1 100.00 NULL +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 PRIMARY t3 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,'1' AS `b`,`test`.`t3`.`c` AS `c` from `test`.`t1` join `test`.`t3` +EXPLAIN SELECT * FROM t1 JOIN (t2 JOIN t3) JOIN t4; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`c` AS `c`,`test`.`t4`.`d` AS `d` from `test`.`t1` join `test`.`t2` join `test`.`t3` join `test`.`t4` +EXPLAIN SELECT * FROM t1 JOIN (t2, t3) JOIN t4; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`c` AS `c`,`test`.`t4`.`d` AS `d` from `test`.`t1` join `test`.`t2` join `test`.`t3` join `test`.`t4` +EXPLAIN SELECT * FROM t1 JOIN t2 JOIN t3 ON t2.b = t3.c JOIN t4 ON t1.a = t4.d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`c` AS `c`,`test`.`t4`.`d` AS `d` from `test`.`t1` join `test`.`t2` join `test`.`t3` join `test`.`t4` where ((`test`.`t3`.`c` = `test`.`t2`.`b`) and (`test`.`t4`.`d` = `test`.`t1`.`a`)) +EXPLAIN SELECT * FROM t1 JOIN t2 JOIN t3 ON t2.b = t3.c JOIN t4 ON t1.a = t2.b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`c` AS `c`,`test`.`t4`.`d` AS `d` from `test`.`t1` join `test`.`t2` join `test`.`t3` join `test`.`t4` where ((`test`.`t2`.`b` = `test`.`t1`.`a`) and (`test`.`t3`.`c` = `test`.`t1`.`a`)) +EXPLAIN SELECT * FROM t1 t11 JOIN t2 JOIN t1 t12 USING(a) JOIN t1 t13 USING(a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t11 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t12 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 SIMPLE t13 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t11`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` `t11` join `test`.`t2` join `test`.`t1` `t12` join `test`.`t1` `t13` where ((`test`.`t12`.`a` = `test`.`t11`.`a`) and (`test`.`t13`.`a` = `test`.`t11`.`a`)) +EXPLAIN SELECT * FROM t2 JOIN t1 t11 JOIN t1 t12 USING(a) JOIN t1 t13 USING(a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t11 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t12 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 SIMPLE t13 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t11`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t2` join `test`.`t1` `t11` join `test`.`t1` `t12` join `test`.`t1` `t13` where ((`test`.`t12`.`a` = `test`.`t11`.`a`) and (`test`.`t13`.`a` = `test`.`t11`.`a`)) +EXPLAIN SELECT * FROM t1 JOIN t2 JOIN t3 JOIN t4 ON t3.c = t4.d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`c` AS `c`,`test`.`t4`.`d` AS `d` from `test`.`t1` join `test`.`t2` join `test`.`t3` join `test`.`t4` where (`test`.`t4`.`d` = `test`.`t3`.`c`) +SET optimizer_switch = DEFAULT; +DROP TABLE t1, t2, t3, t4, t5; +# Testing correct nesting of natural joins. +CREATE TABLE t1( a INT, b int ); +CREATE TABLE t2( a INT, c int ); +CREATE TABLE t3( a INT, d int ); +INSERT INTO t1 VALUES (1, 1), (2, 2), (3, 3); +INSERT INTO t2 VALUES (2, 2), (3, 3), (4, 4); +INSERT INTO t3 VALUES (3, 3), (4, 4), (5, 5); +# The two queries below should produce identical result sets. +SELECT * FROM t1 NATURAL LEFT JOIN t2 NATURAL RIGHT JOIN t3; +a d b c +3 3 3 3 +4 4 NULL NULL +5 5 NULL NULL +SELECT * FROM (t1 NATURAL LEFT JOIN t2) NATURAL RIGHT JOIN t3; +a d b c +3 3 3 3 +4 4 NULL NULL +5 5 NULL NULL +# This result should differ from the result sets above. +SELECT * FROM t1 NATURAL LEFT JOIN (t2 NATURAL RIGHT JOIN t3); +a b d c +1 1 NULL NULL +2 2 NULL NULL +3 3 3 3 +DROP TABLE t1, t2, t3; +# +# Bug#22995438: BUILD INDEX DEFINITION SYNTAX BOTTOM-UP +# +# This is regression testing for the refactoring. +CREATE TABLE t1 ( +a INT, +b INT, +c INT, +d INT, +e INT, +f INT, +g INT, +h INT, +i INT, +j INT, +k INT, +l INT, +m INT, +n INT, +o INT +); +CREATE INDEX a_index ON t1( a ); +CREATE UNIQUE INDEX b_index ON t1( b ); +CREATE INDEX c_index USING btree ON t1( c ); +CREATE INDEX c_index USING btree USING btree ON t1( c ); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'USING btree ON t1( c )' at line 1 +CREATE INDEX d_index USING rtree ON t1( d ); +ERROR 42000: A SPATIAL index may only contain a geometrical type column +CREATE INDEX e_index TYPE btree ON t1( e ); +CREATE INDEX type TYPE btree ON t1( f ); +CREATE INDEX TYPE btree ON t1( g ); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'btree ON t1( g )' at line 1 +CREATE INDEX h_index TYPE rtree ON t1( h ); +ERROR 42000: A SPATIAL index may only contain a geometrical type column +CREATE INDEX i_index ON t1( i ) KEY_BLOCK_SIZE = 1; +CREATE INDEX j_index ON t1( j ) KEY_BLOCK_SIZE = 1 KEY_BLOCK_SIZE = 1; +CREATE INDEX k_index ON t1( k ) COMMENT 'A comment'; +CREATE INDEX k_index2 ON t1( k ) COMMENT 'A comment' COMMENT 'Another comment'; +Warnings: +Warning 1831 Duplicate index 'k_index2' defined on the table 'test.t1'. This is deprecated and will be disallowed in a future release. +CREATE INDEX l_index ON t1( l ) USING btree; +CREATE INDEX m_index ON t1( m ) TYPE btree; +CREATE INDEX n_index USING btree ON t1( n ) USING btree; +CREATE INDEX x_index USING btree ON t1( o ) USING rtree; +ERROR 42000: A SPATIAL index may only contain a geometrical type column +CREATE INDEX o_index USING rtree ON t1( o ) USING btree; +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +SHOW INDEXES FROM t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible Expression +t1 0 b_index 1 b A 0 NULL NULL YES BTREE YES NULL +t1 1 a_index 1 a A 0 NULL NULL YES BTREE YES NULL +t1 1 c_index 1 c A 0 NULL NULL YES BTREE YES NULL +t1 1 e_index 1 e A 0 NULL NULL YES BTREE YES NULL +t1 1 type 1 f A 0 NULL NULL YES BTREE YES NULL +t1 1 i_index 1 i A 0 NULL NULL YES BTREE YES NULL +t1 1 j_index 1 j A 0 NULL NULL YES BTREE YES NULL +t1 1 k_index 1 k A 0 NULL NULL YES BTREE A comment YES NULL +t1 1 k_index2 1 k A 0 NULL NULL YES BTREE Another comment YES NULL +t1 1 l_index 1 l A 0 NULL NULL YES BTREE YES NULL +t1 1 m_index 1 m A 0 NULL NULL YES BTREE YES NULL +t1 1 n_index 1 n A 0 NULL NULL YES BTREE YES NULL +t1 1 o_index 1 o A 0 NULL NULL YES BTREE YES NULL +DROP TABLE t1; +# +# WL#8907: Parser refactoring: merge all SELECT rules into one. +# +# Warning on hints in CREATE or ALTER VIEW: +CREATE VIEW v1 AS SELECT /*+ QB_NAME(a) */ 1; +ALTER VIEW v1 AS SELECT /*+ QB_NAME(a) */ 1; +SELECT * FROM v1; +1 +1 +DROP VIEW v1; +# The "Hints aren't supported in CREATE or ALTER VIEW" warning is masked: +CREATE VIEW v1 AS SELECT /*+ BAD_HINT */ 1; +Warnings: +Warning 1064 Optimizer hint syntax error near 'BAD_HINT */ 1' at line 1 +ALTER VIEW v1 AS SELECT /*+ BAD_HINT */ 1; +Warnings: +Warning 1064 Optimizer hint syntax error near 'BAD_HINT */ 1' at line 1 +SELECT * FROM v1; +1 +1 +DROP VIEW v1; +# +# +# Bug#23321895: CRASH IN IS_VIEW_OR_DERIVED OR +# TABLE_LIST::IS_LEAF_FOR_NAME_RESOLUTION +# +CREATE TABLE t1( a INT ); +CREATE TABLE t2( a INT ); +CREATE TABLE t3( a INT ); +CREATE TABLE t4( a INT ); +SELECT 1 +FROM ( SELECT 1 FROM t1 JOIN t2 ON @@q ) AS d +JOIN t3 LEFT JOIN t4 ON 1; +ERROR HY000: Unknown system variable 'q' +DROP TABLE t1, t2, t3, t4; +# +# Bug#39559: dump of stored procedures / functions with C-style +# comment can't be read back +# ++----------+--------+ +| expected | result | ++----------+--------+ +| 2 | 2 | ++----------+--------+ ++----------+--------+ +| expected | result | ++----------+--------+ +| 1 | 1 | ++----------+--------+ ++----------+--------+ +| expected | result | ++----------+--------+ +| 3 | 3 | ++----------+--------+ ++----------+--------+ +| expected | result | ++----------+--------+ +| 2 | 2 | ++----------+--------+ ++----------+--------+ +| expected | result | ++----------+--------+ +| 7 | 7 | ++----------+--------+ ++----------+--------+ +| expected | result | ++----------+--------+ +| 8 | 8 | ++----------+--------+ ++----------+--------+ +| expected | result | ++----------+--------+ +| 7 | 7 | ++----------+--------+ ++----------+--------+ +| expected | result | ++----------+--------+ +| 4 | 4 | ++----------+--------+ ++----------+--------+ +| expected | result | ++----------+--------+ +| 4 | 4 | ++----------+--------+ +# Bug#46527 "COMMIT AND CHAIN RELEASE does not make sense" +# +COMMIT AND CHAIN RELEASE; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'RELEASE' at line 1 +COMMIT AND NO CHAIN RELEASE; +COMMIT RELEASE; +COMMIT CHAIN RELEASE; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'CHAIN RELEASE' at line 1 +COMMIT NO CHAIN RELEASE; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'CHAIN RELEASE' at line 1 +COMMIT AND NO RELEASE; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'RELEASE' at line 1 +COMMIT AND RELEASE; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'RELEASE' at line 1 +COMMIT NO RELEASE; +COMMIT CHAIN NO RELEASE; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'CHAIN NO RELEASE' at line 1 +COMMIT NO CHAIN NO RELEASE; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'CHAIN NO RELEASE' at line 1 +COMMIT AND RELEASE CHAIN; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'RELEASE CHAIN' at line 1 +COMMIT AND NO CHAIN NO RELEASE; +ROLLBACK AND CHAIN RELEASE; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'RELEASE' at line 1 +ROLLBACK AND NO CHAIN RELEASE; +ROLLBACK RELEASE; +ROLLBACK CHAIN RELEASE; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'CHAIN RELEASE' at line 1 +ROLLBACK NO CHAIN RELEASE; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'CHAIN RELEASE' at line 1 +ROLLBACK AND NO RELEASE; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'RELEASE' at line 1 +ROLLBACK AND RELEASE; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'RELEASE' at line 1 +ROLLBACK NO RELEASE; +ROLLBACK CHAIN NO RELEASE; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'CHAIN NO RELEASE' at line 1 +ROLLBACK NO CHAIN NO RELEASE; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'CHAIN NO RELEASE' at line 1 +ROLLBACK AND RELEASE CHAIN; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'RELEASE CHAIN' at line 1 +ROLLBACK AND NO CHAIN NO RELEASE; +# +# Bug#26132947: SERVER CAN EXIT ON ALTER TABLE ADD PARTITION SYNTAX +# +CREATE TABLE t1 (a INT PRIMARY KEY) PARTITION BY HASH (a) PARTITIONS 1; +ALTER TABLE t1 ADD PARTITION; +ERROR HY000: At least one partition must be added +DROP TABLE t1; +# +# +# Bug#25717617: Wrong syntax error line numbers when sql_mode has the +# IGNORE_SPACE flag +# +SET @save_sql_mode=@@sql_mode; +SET sql_mode='IGNORE_SPACE'; +# Expected error line number is 2: +CREATE +TABLE; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 2 +# Expected error line number is 5: +CREATE +# +# +# +TABLE; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 5 +# +# Regression test added in WL#8657 +# +CREATE TEMPORARY TABLE t1(a INT); +SHOW COLUMNS FROM t1 WHERE FIELD='a'; +Field Type Null Key Default Extra +a int YES NULL NULL +DROP TABLE t1; +ALTER TABLE t1 RENAME TO ``.t1; +ERROR 42000: Incorrect database name '' +CREATE TABLE t1 (a INT) PARTITION BY KEY ALGORITHM = 10 () PARTITIONS 3; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '10 () PARTITIONS 3' at line 1 +ALTER EVENT ev1; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1 +ALTER INSTANCE ROTATE MyISAM MASTER KEY; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'MyISAM MASTER KEY' at line 1 +REVOKE SELECT(c1) ON FUNCTION *.* FROM r1; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1 +GRANT SELECT(c1) ON FUNCTION *.* TO r1; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1 +CREATE INDEX idx1 ON `` (c1); +ERROR 42000: Incorrect table name '' +ALTER TABLE t1 EXCHANGE PARTITION p0 WITH TABLE `` WITH VALIDATION; +ERROR 42000: Incorrect table name '' +CHECK TABLE ``; +ERROR 42000: Incorrect table name '' +DROP INDEX idx1 ON ``; +ERROR 42000: Incorrect table name '' +CACHE INDEX `` IN c; +ERROR 42000: Incorrect table name '' +CACHE INDEX `` PARTITION (ALL) IN c; +ERROR 42000: Incorrect table name '' +LOAD INDEX INTO CACHE `` PARTITION (ALL); +ERROR 42000: Incorrect table name '' +LOAD INDEX INTO CACHE ``; +ERROR 42000: Incorrect table name '' +SET @@sql_mode=@save_sql_mode; +# +# Bug#24756971: REMOVE OBSOLETE LEXER HACK AROUND SELECT LIST +# +SELECT 1,,2; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ',2' at line 1 +SELECT ,,1; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ',,1' at line 1 +SELECT ,,,; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ',,,' at line 1 +# +# Removal of undocumented syntax, see bug#27389878. +# +CREATE DATABASE db CHARSET DEFAULT; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DEFAULT' at line 1 +CREATE DATABASE db COLLATE DEFAULT; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DEFAULT' at line 1 +CREATE TABLE t (i INT) CHARSET DEFAULT; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DEFAULT' at line 1 +CREATE TABLE t (i INT) COLLATE DEFAULT; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DEFAULT' at line 1 +ALTER DATABASE db CHARSET DEFAULT; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DEFAULT' at line 1 +ALTER DATABASE db COLLATE DEFAULT; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DEFAULT' at line 1 +ALTER TABLE t COLLATE DEFAULT; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DEFAULT' at line 1 +SET NAMES utf8 COLLATE DEFAULT; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DEFAULT' at line 1 +SET NAMES DEFAULT COLLATE DEFAULT; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'COLLATE DEFAULT' at line 1 +CREATE PROCEDURE p1() +BEGIN +DECLARE c CHAR(1) CHARSET DEFAULT; +END// +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DEFAULT; +END' at line 3 +CREATE PROCEDURE p1() +BEGIN +DECLARE c CHAR(1) COLLATE DEFAULT; +END// +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DEFAULT; +END' at line 3 +CREATE PROCEDURE p1(c CHAR(1) CHARSET DEFAULT) BEGIN END; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DEFAULT) BEGIN END' at line 1 +CREATE PROCEDURE p1(c CHAR(1) COLLATE DEFAULT) BEGIN END; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DEFAULT) BEGIN END' at line 1 +CREATE FUNCTION f1(c CHAR(1) CHARSET DEFAULT) RETURNS INT RETURN 1; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DEFAULT) RETURNS INT RETURN 1' at line 1 +CREATE FUNCTION f1(c CHAR(1) COLLATE DEFAULT) RETURNS INT RETURN 1; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DEFAULT) RETURNS INT RETURN 1' at line 1 +CREATE FUNCTION f1() RETURNS CHAR(1) CHARSET DEFAULT RETURN ''; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DEFAULT RETURN ''' at line 1 +CREATE FUNCTION f1() RETURNS CHAR(1) COLLATE DEFAULT RETURN ''; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DEFAULT RETURN ''' at line 1 +# +# Bug#27814204: THE "ADMIN" WORD SHOULD BE A NON-RESERVED WORD IN THE +# SQL GRAMMAR +# +CREATE TEMPORARY TABLE admin (admin INT); +DROP TABLE admin; +# +# Bug#27760787: ERROR IN SQL SYNTAX WHEN USING "DEFAULT" KEYWORD IN +# ALTER TABLE COMMAND +SELECT @@default_collation_for_utf8mb4; +@@default_collation_for_utf8mb4 +utf8mb4_0900_ai_ci +######################################################################### +# +# 1. @@default_collation_for_utf8mb4 does not matter: +# +######################################################################### +CREATE DATABASE db1 CHARSET cp1251 COLLATE cp1251_general_ci; +USE db1; +CREATE TABLE t1 (i INT) CHARSET utf8mb4; +# +# Implicit COLLATE: +# +ALTER TABLE t1 CONVERT TO CHARACTER SET DEFAULT; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `i` int DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=cp1251 +# +# Explicit COLLATE: +# +ALTER TABLE t1 CONVERT TO CHARACTER SET DEFAULT COLLATE cp1251_bin; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `i` int DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=cp1251 COLLATE=cp1251_bin +DROP DATABASE db1; +######################################################################### +# +# 2. @@default_collation_for_utf8mb4 == utf8mb4_general_ci +# @@collation_database == utf8mb4_0900_ai_ci +# +######################################################################### +SET @@default_collation_for_utf8mb4 = utf8mb4_general_ci; +Warnings: +Warning 1681 Updating 'default_collation_for_utf8mb4' is deprecated. It will be made read-only in a future release. +CREATE DATABASE db2 COLLATE utf8mb4_0900_ai_ci; +USE db2; +CREATE TABLE t2 (i INT) CHARSET latin1; +# +# Implicit COLLATE result in utf8mb4_0900_ai_ci (@@collation_database): +# +ALTER TABLE t2 CONVERT TO CHARACTER SET DEFAULT; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `i` int DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +# Cleanup: +ALTER TABLE t2 CONVERT TO CHARACTER SET latin1; +# +# Explicit COLLATE should result in utf8mb4_bin: +# +ALTER TABLE t2 CONVERT TO CHARACTER SET DEFAULT COLLATE utf8mb4_bin; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `i` int DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin +DROP DATABASE db2; +######################################################################### +# +# 3. @@default_collation_for_utf8mb4 == utf8mb4_0900_ai_ci +# @@collation_database == utf8mb4_general_ci +# +######################################################################### +SET @@default_collation_for_utf8mb4 = DEFAULT; +Warnings: +Warning 1681 Updating 'default_collation_for_utf8mb4' is deprecated. It will be made read-only in a future release. +SELECT @@default_collation_for_utf8mb4; +@@default_collation_for_utf8mb4 +utf8mb4_0900_ai_ci +CREATE DATABASE db3 COLLATE utf8mb4_general_ci; +USE db3; +CREATE TABLE t3 (i INT) CHARSET latin1; +# +# Implicit COLLATE should result in utf8mb4_general_ci (@@collation_database): +# +ALTER TABLE t3 CONVERT TO CHARACTER SET DEFAULT; +SHOW CREATE TABLE t3; +Table Create Table +t3 CREATE TABLE `t3` ( + `i` int DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci +# +# Explicit COLLATE should result in utf8mb4_bin: +# +ALTER TABLE t3 CONVERT TO CHARACTER SET DEFAULT COLLATE utf8mb4_bin; +SHOW CREATE TABLE t3; +Table Create Table +t3 CREATE TABLE `t3` ( + `i` int DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin +######################################################################### +# +# 4. Incompatible character set in @@character_set_database and COLLATE should fail: +# +######################################################################### +ALTER TABLE t3 CONVERT TO CHARACTER SET DEFAULT COLLATE cp1251_general_cs; +ERROR 42000: COLLATION 'cp1251_general_cs' is not valid for CHARACTER SET 'utf8mb4' +DROP DATABASE db3; +# Cleanup +USE test; + +Bug #27714748: @@PARSER_MAX_MEM_SIZE DOES NOT WORK FOR ROUTINES + +SET parser_max_mem_size = 10000000; +ERROR HY000: Memory capacity of 10000000 bytes for 'parser_max_mem_size' exceeded. Parser bailed out for this query. +SET parser_max_mem_size = default; +# +# Bug #28968848: SIMPLIFY MYSQL_YYABORT +# +CREATE PROCEDURE p1 () wrong syntax; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'syntax' at line 1 +# +# Bug #25220656: THE "PERSIST" EXTENSION IS A RESERVED KEYWORD +# +SELECT 1 AS PERSIST, 2 AS PERSIST_ONLY; +PERSIST PERSIST_ONLY +1 2 +CREATE ROLE EVENT; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'EVENT' at line 1 +CREATE ROLE FILE; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'FILE' at line 1 +CREATE ROLE NONE; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'NONE' at line 1 +CREATE ROLE PROCESS; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'PROCESS' at line 1 +CREATE ROLE PROXY; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'PROXY' at line 1 +CREATE ROLE RELOAD; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'RELOAD' at line 1 +CREATE ROLE REPLICATION; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'REPLICATION' at line 1 +CREATE ROLE RESOURCE; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'RESOURCE' at line 1 +CREATE ROLE SUPER; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'SUPER' at line 1 +SET GLOBAL = DEFAULT; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '= DEFAULT' at line 1 +SET LOCAL = DEFAULT; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '= DEFAULT' at line 1 +SET PERSIST = DEFAULT; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '= DEFAULT' at line 1 +SET PERSIST_ONLY = DEFAULT; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '= DEFAULT' at line 1 +SET SESSION = DEFAULT; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '= DEFAULT' at line 1 +# +# Bug#29033659: SOME NON-RESERVED WORDS CAN'T BE USED AS SP LABELS +# +CREATE FUNCTION f1() RETURNS INT +BEGIN +ACCOUNT: LOOP RETURN 1; END LOOP; +ALWAYS: LOOP RETURN 1; END LOOP; +BACKUP: LOOP RETURN 1; END LOOP; +CLOSE: LOOP RETURN 1; END LOOP; +FORMAT: LOOP RETURN 1; END LOOP; +GROUP_REPLICATION: LOOP RETURN 1; END LOOP; +HOST: LOOP RETURN 1; END LOOP; +INVISIBLE: LOOP RETURN 1; END LOOP; +OPEN: LOOP RETURN 1; END LOOP; +OPTIONS: LOOP RETURN 1; END LOOP; +OWNER: LOOP RETURN 1; END LOOP; +PARSER: LOOP RETURN 1; END LOOP; +PORT: LOOP RETURN 1; END LOOP; +REMOVE: LOOP RETURN 1; END LOOP; +RESTORE: LOOP RETURN 1; END LOOP; +ROLE: LOOP RETURN 1; END LOOP; +SECONDARY: LOOP RETURN 1; END LOOP; +SECONDARY_ENGINE: LOOP RETURN 1; END LOOP; +SECONDARY_LOAD: LOOP RETURN 1; END LOOP; +SECONDARY_UNLOAD: LOOP RETURN 1; END LOOP; +SECURITY: LOOP RETURN 1; END LOOP; +SERVER: LOOP RETURN 1; END LOOP; +SOCKET: LOOP RETURN 1; END LOOP; +SONAME: LOOP RETURN 1; END LOOP; +UPGRADE: LOOP RETURN 1; END LOOP; +VISIBLE: LOOP RETURN 1; END LOOP; +WRAPPER: LOOP RETURN 1; END LOOP; +END| +DROP FUNCTION f1; +# +# Bug#29205289: PARSER ACCEPTS UNDOCUMENTED SYNTAX: `... = TABLE_ALIAS` +# +CREATE TABLE t1 (i INT); +LOCK TABLES t1=a READ; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '=a READ' at line 1 +HANDLER t1 OPEN=a; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '=a' at line 1 +SELECT * FROM t1=a; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '=a' at line 1 +SELECT * FROM (SELECT 1)=a; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '=a' at line 1 +SELECT * FROM t1 JOIN t1=a; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '=a' at line 1 +UPDATE t1=a SET i=0; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '=a SET i=0' at line 1 +DROP TABLE t1; +# +# Bug #22320942: ODBC OUTER JOIN ESCAPE SEQUENCE SYNTAX IS BROKEN +# +CREATE TEMPORARY TABLE t1 (i INT); +CREATE TEMPORARY TABLE t2 (i INT); +SELECT * FROM { OJ t1 LEFT JOIN t2 ON TRUE }; +i i +SELECT * FROM { `OJ` t1 LEFT JOIN t2 ON TRUE }; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '`OJ` t1 LEFT JOIN t2 ON TRUE }' at line 1 +SELECT * FROM { random_identifier t1 LEFT JOIN t2 ON TRUE }; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'random_identifier t1 LEFT JOIN t2 ON TRUE }' at line 1 +DROP TABLE t1, t2; +# +# Bug #28997518: "COLLATE X GENERATED ALWAYS ... COLLATE Y": X HAS +# A PRIORITY OVER Y +# +CREATE TABLE t1 ( +x VARCHAR(10) +COLLATE ascii_bin +COLLATE ascii_bin +); +ERROR 42000: Multiple COLLATE clauses near 'ascii_bin +)' at line 4 +CREATE TABLE t2 ( +x VARCHAR(10) +COLLATE ascii_bin +COLLATE ascii_general_ci +); +ERROR 42000: Multiple COLLATE clauses near 'ascii_general_ci +)' at line 4 +CREATE TABLE t3 ( +x VARCHAR(10) +COLLATE ascii_bin +NOT NULL +COLLATE ascii_bin +); +ERROR 42000: Multiple COLLATE clauses near 'ascii_bin +)' at line 5 +CREATE TABLE t3 ( +x VARCHAR(10) +COLLATE ascii_bin +GENERATED ALWAYS AS(NULL) +COLLATE ascii_bin +); +ERROR 42000: Multiple COLLATE clauses near 'COLLATE ascii_bin +GENERATED ALWAYS AS(NULL) +COLLATE ascii_bin +)' at line 3 +CREATE TABLE t4 ( +x VARCHAR(10) +GENERATED ALWAYS AS(NULL) +COLLATE ascii_bin +COLLATE ascii_bin +); +ERROR 42000: Multiple COLLATE clauses near 'ascii_bin +)' at line 5 +# +# Bug#28961997: REMOVE PARENTHESES INFORMATION FROM AST +# +CREATE VIEW v1 AS (SELECT 1 ORDER BY 1) UNION (SELECT 3 ORDER BY 1) ORDER BY 1; +SHOW CREATE VIEW v1; +View Create View character_set_client collation_connection +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select 1 AS `1` union select 3 AS `3` order by `1` utf8mb4 utf8mb4_0900_ai_ci +DROP VIEW v1; +# +# Bug#29871803: REQUIRED PARENTHESES NO LONGER PRINTED FOR CERTAIN UNION +# STATEMENTS +# +CREATE TABLE t1(a INTEGER); +CREATE TABLE t2(a INTEGER); +CREATE TABLE t3(a INTEGER, b INTEGER, c INTEGER); +INSERT INTO t3 VALUES(1, 10, 100), (2, 20, 200), (3, 30, 300), (4, 40, 400); +ANALYZE TABLE t1, t2, t3; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +EXPLAIN (SELECT a FROM t1 ORDER BY a LIMIT 1) UNION SELECT a FROM t2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using filesort +2 UNION t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +NULL UNION RESULT NULL ALL NULL NULL NULL NULL NULL NULL Using temporary +Warnings: +Note 1003 (/* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` order by `test`.`t1`.`a` limit 1) union /* select#2 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` +EXPLAIN SELECT a FROM t1 UNION (SELECT a FROM t2 LIMIT 1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 UNION t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +NULL UNION RESULT NULL ALL NULL NULL NULL NULL NULL NULL Using temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` union (/* select#2 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` limit 1) +CREATE VIEW v1 as (SELECT a FROM t1 ORDER BY a LIMIT 1) UNION SELECT a FROM t2; +SHOW CREATE VIEW v1; +View Create View character_set_client collation_connection +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS (select `t1`.`a` AS `a` from `t1` order by `t1`.`a` limit 1) union select `t2`.`a` AS `a` from `t2` utf8mb4 utf8mb4_0900_ai_ci +CREATE VIEW v2 as SELECT a FROM t1 UNION (SELECT a FROM t2 ORDER BY a LIMIT 1); +SHOW CREATE VIEW v2; +View Create View character_set_client collation_connection +v2 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v2` AS select `t1`.`a` AS `a` from `t1` union (select `t2`.`a` AS `a` from `t2` order by `t2`.`a` limit 1) utf8mb4 utf8mb4_0900_ai_ci +EXPLAIN (SELECT * FROM t3 ORDER BY a LIMIT 3) ORDER BY b DESC LIMIT 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 4 100.00 Using filesort +Warnings: +Note 1003 (/* select#1 */ select `test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t3`.`c` AS `c` from `test`.`t3` order by `test`.`t3`.`a` limit 3) order by `b` desc limit 2 +EXPLAIN ((SELECT * FROM t3 ORDER BY a LIMIT 3) +ORDER BY b DESC LIMIT 2) +ORDER BY c LIMIT 1; +ERROR 42000: This version of MySQL doesn't yet support 'parenthesized query expression with more than one external level of ORDER/LIMIT operations' +DROP VIEW v1; +DROP VIEW v2; +DROP TABLE t1, t2, t3; +# +# Bug#30131161: SYNTAX ERROR WITH || WHEN USING PIPES_AS_CONCAT AFTER +# UPGRADING TO 8.0.17 +# +SET sql_mode=(SELECT CONCAT(@@sql_mode, ',PIPES_AS_CONCAT')); +SELECT 'ab' LIKE 'a%', 'ab' LIKE 'a' || '%'; +'ab' LIKE 'a%' 'ab' LIKE 'a' || '%' +1 1 +SELECT 'ab' NOT LIKE 'a%', 'ab' NOT LIKE 'a' || '%'; +'ab' NOT LIKE 'a%' 'ab' NOT LIKE 'a' || '%' +0 0 +SELECT 'ab' LIKE 'ac', 'ab' LIKE 'a' || 'c'; +'ab' LIKE 'ac' 'ab' LIKE 'a' || 'c' +0 0 +SELECT 'ab' NOT LIKE 'ac', 'ab' NOT LIKE 'a' || 'c'; +'ab' NOT LIKE 'ac' 'ab' NOT LIKE 'a' || 'c' +1 1 +SELECT 'a%' LIKE 'a!%' ESCAPE '!', 'a%' LIKE 'a!' || '%' ESCAPE '!'; +'a%' LIKE 'a!%' ESCAPE '!' 'a%' LIKE 'a!' || '%' ESCAPE '!' +1 1 +SELECT 'a%' NOT LIKE 'a!%' ESCAPE '!', 'a%' NOT LIKE 'a!' || '%' ESCAPE '!'; +'a%' NOT LIKE 'a!%' ESCAPE '!' 'a%' NOT LIKE 'a!' || '%' ESCAPE '!' +0 0 +SELECT 'a%' LIKE 'a!%' ESCAPE '$', 'a%' LIKE 'a!' || '%' ESCAPE '$'; +'a%' LIKE 'a!%' ESCAPE '$' 'a%' LIKE 'a!' || '%' ESCAPE '$' +0 0 +SELECT 'a%' NOT LIKE 'a!%' ESCAPE '$', 'a%' NOT LIKE 'a!' || '%' ESCAPE '$'; +'a%' NOT LIKE 'a!%' ESCAPE '$' 'a%' NOT LIKE 'a!' || '%' ESCAPE '$' +1 1 +SELECT 'a%' LIKE 'a!%' ESCAPE '!', 'a%' LIKE 'a!%' ESCAPE '' || '!'; +'a%' LIKE 'a!%' ESCAPE '!' 'a%' LIKE 'a!%' ESCAPE '' || '!' +1 1 +SELECT 'a%' NOT LIKE 'a!%' ESCAPE '!', 'a%' NOT LIKE 'a!%' ESCAPE '' || '!'; +'a%' NOT LIKE 'a!%' ESCAPE '!' 'a%' NOT LIKE 'a!%' ESCAPE '' || '!' +0 0 +SELECT 'a%' LIKE 'a!%' ESCAPE '' || '$', 'a%' LIKE 'a!%' ESCAPE '' || '$'; +'a%' LIKE 'a!%' ESCAPE '' || '$' 'a%' LIKE 'a!%' ESCAPE '' || '$' +0 0 +SELECT 'a%' NOT LIKE 'a!%' ESCAPE '' || '$', 'a%' NOT LIKE 'a!%' ESCAPE '' || '$'; +'a%' NOT LIKE 'a!%' ESCAPE '' || '$' 'a%' NOT LIKE 'a!%' ESCAPE '' || '$' +1 1 +SELECT 1 ^ 100, 1 ^ '10' || '0'; +1 ^ 100 1 ^ '10' || '0' +101 101 +SELECT -1 || '0'; +-1 || '0' +-10 +SET sql_mode=DEFAULT; +# +# WL#13559: Deprecate syntax: confusing combinations of UNION and INTO +# +# +# No warning expected: +# +SELECT 1 UNION SELECT 1 INTO @var; +(SELECT 1 UNION SELECT 1 INTO @var); +SELECT 1 UNION SELECT 1 FROM DUAL INTO @var; +(SELECT 1 UNION SELECT 1 FROM DUAL INTO @var); +SELECT 1 UNION SELECT 1 FROM DUAL FOR UPDATE INTO @var; +(SELECT 1 UNION SELECT 1 FROM DUAL FOR UPDATE INTO @var); +# +# Deprecation warning expected: +# +SELECT 1 UNION SELECT 1 INTO @var FROM DUAL; +Warnings: +Warning 3962 The INTO clause is deprecated inside query blocks of query expressions and will be removed in a future release. Please move the INTO clause to the end of statement instead. +SELECT 1 UNION (SELECT 1 INTO @var FROM DUAL); +Warnings: +Warning 3962 The INTO clause is deprecated inside query blocks of query expressions and will be removed in a future release. Please move the INTO clause to the end of statement instead. +SELECT 1 UNION SELECT 1 FROM DUAL INTO @var FOR UPDATE; +Warnings: +Warning 3962 The INTO clause is deprecated inside query blocks of query expressions and will be removed in a future release. Please move the INTO clause to the end of statement instead. +(SELECT 1 UNION SELECT 1 FROM DUAL INTO @var FOR UPDATE); +Warnings: +Warning 3962 The INTO clause is deprecated inside query blocks of query expressions and will be removed in a future release. Please move the INTO clause to the end of statement instead. +SELECT 1 UNION SELECT 1 INTO @var FOR UPDATE; +Warnings: +Warning 3962 The INTO clause is deprecated inside query blocks of query expressions and will be removed in a future release. Please move the INTO clause to the end of statement instead. +(SELECT 1 UNION SELECT 1 INTO @var FOR UPDATE); +Warnings: +Warning 3962 The INTO clause is deprecated inside query blocks of query expressions and will be removed in a future release. Please move the INTO clause to the end of statement instead. +# +# Syntax error expected: +# +SELECT 1 UNION (SELECT 1 FROM DUAL INTO @var); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'INTO @var)' at line 1 +# +# Bug#30871301: CTE CAN FAIL WITH A PARSE ERROR ON PSEUDO-COMMENTS +# +WITH cte AS (SELECT 0 /*! ) */ SELECT * FROM cte a, cte b; +0 0 +0 0 +WITH cte AS /*! ( */ SELECT 0) SELECT * FROM cte a, cte b; +0 0 +0 0 +# +# Bug#30528450: SPECIAL SYMBOL NAMED COLUMN NOT HONORED IN A SELECT +# +CREATE TABLE t1 (c1 INT, `*` INT, c3 INT); +INSERT INTO t1 VALUES (1, 2, 3); +SELECT `*` FROM t1; +* +2 +SELECT t1.`*`, t1.* FROM t1; +* c1 * c3 +2 1 2 3 +SELECT test.t1.`*`, test.t1.* FROM t1; +* c1 * c3 +2 1 2 3 +DROP TABLE t1; +# +# Bug#30592703: UNDOCUMENTED SYNTAX +# '('')' {LIMIT|ORDER [LIMIT]} INTO ... +# +(SELECT 1) LIMIT 1 INTO @var; +SELECT @var; +@var +1 +(SELECT 2 AS c) ORDER BY c INTO @var; +SELECT @var; +@var +2 +(SELECT 3 AS c) ORDER BY c LIMIT 1 INTO @var; +SELECT @var; +@var +3 +(SELECT 4) INTO @var; +SELECT @var; +@var +4 +# +# ) + optimizer uses index meets loss of the index +create table t1 (a int, b int, primary key(b),unique index t1_unq_idx(a)); +insert into t1 set a = 0, b = 0; +insert into t1 select a + 1, b + 1 from t1; +insert into t1 select a + 2, b + 2 from t1; +insert into t1 select a + 4, b + 4 from t1; +insert into t1 select a + 8, b + 8 from t1; +# Optimizer strategy: Possible keys = NULL , Extra = Parallel execute (1 workers) +prepare stmt from "select avg(a) from t1"; +execute stmt; +avg(a) +7.5000 +call p_verify_reprepare_count(0); +SUCCESS + +execute stmt; +avg(a) +7.5000 +call p_verify_reprepare_count(0); +SUCCESS + +alter table t1 drop index t1_unq_idx; +# Optimizer strategy: Possible keys = NULL , Extra = Parallel execute (1 workers) +execute stmt; +avg(a) +7.5000 +call p_verify_reprepare_count(1); +SUCCESS + +execute stmt; +avg(a) +7.5000 +call p_verify_reprepare_count(0); +SUCCESS + +# select AVG() + optimizer uses table scan meets a new index +alter table t1 add unique index t1_unq_idx(a); +# Optimizer strategy: Possible keys = NULL , Extra = Parallel execute (1 workers) +execute stmt; +avg(a) +7.5000 +call p_verify_reprepare_count(1); +SUCCESS + +execute stmt; +avg(a) +7.5000 +call p_verify_reprepare_count(0); +SUCCESS + +deallocate prepare stmt; +drop table t1; +# table replaced by not updatable view - Insert +create table t1 (a int); +prepare stmt from "insert into t1 values(1)"; +execute stmt; +call p_verify_reprepare_count(0); +SUCCESS + +drop table t1; +create view t1 as select 1; +execute stmt; +ERROR HY000: The target table t1 of the INSERT is not insertable-into +call p_verify_reprepare_count(1); +SUCCESS + +drop view t1; +create table t2 (a int); +create view t1 as select * from t2 with check option; +execute stmt; +call p_verify_reprepare_count(1); +SUCCESS + +execute stmt; +call p_verify_reprepare_count(0); +SUCCESS + +select * from t1; +a +1 +1 +deallocate prepare stmt; +drop view t1; +drop table t2; +===================================================================== +Some freestyle tests +===================================================================== +create temporary table t1 as select 1 as a; +create procedure p1() +begin +drop temporary table t1; +end| +create function f1() returns int +begin +call p1(); +return 1; +end| +prepare stmt from "select f1() as my_column, a from t1"; +execute stmt; +ERROR HY000: Can't reopen table: 't1' +call p_verify_reprepare_count(0); +SUCCESS + +select * from t1; +a +1 +prepare stmt from "select a, f1() as my_column from t1"; +execute stmt; +ERROR HY000: Can't reopen table: 't1' +call p_verify_reprepare_count(0); +SUCCESS + +select * from t1; +a +1 +prepare stmt from "select f1() as my_column, count(*) from t1"; +execute stmt; +ERROR HY000: Can't reopen table: 't1' +call p_verify_reprepare_count(0); +SUCCESS + +select * from t1; +a +1 +prepare stmt from "select count(*), f1() as my_column from t1"; +execute stmt; +ERROR HY000: Can't reopen table: 't1' +call p_verify_reprepare_count(0); +SUCCESS + +select * from t1; +a +1 +# Execute fails, no drop of temporary table +prepare stmt from "select 1 as my_column from (select 1) as t2 + where exists (select f1() from t1)"; +execute stmt; +my_column +1 +call p_verify_reprepare_count(0); +SUCCESS + +execute stmt; +my_column +1 +call p_verify_reprepare_count(0); +SUCCESS + +select * from t1; +a +1 +# Execute drops temporary table +prepare stmt from "select f1()"; +execute stmt; +f1() +1 +call p_verify_reprepare_count(0); +SUCCESS + +execute stmt; +ERROR 42S02: Unknown table 'test.t1' +call p_verify_reprepare_count(0); +SUCCESS + +drop function f1; +drop procedure p1; +deallocate prepare stmt; +# Execute fails, temporary table is not replaced by another +create temporary table t1 as select 1 as a; +create procedure p1() +begin +drop temporary table t1; +create temporary table t1 as select 'abc' as a; +end| +create function f1() returns int +begin +call p1(); +return 1; +end| +prepare stmt from "select count(*), f1() as my_column from t1"; +execute stmt; +ERROR HY000: Can't reopen table: 't1' +call p_verify_reprepare_count(0); +SUCCESS + +select * from t1; +a +1 +deallocate prepare stmt; +prepare stmt from "call p1"; +execute stmt; +drop procedure p1; +create schema mysqltest; +create procedure mysqltest.p1() +begin +drop schema mysqltest; +create schema mysqltest; +end| +execute stmt; +ERROR 42000: PROCEDURE test.p1 does not exist +call p_verify_reprepare_count(0); +SUCCESS + +execute stmt; +ERROR 42000: PROCEDURE test.p1 does not exist +call p_verify_reprepare_count(0); +SUCCESS + +deallocate prepare stmt; +drop schema mysqltest; +drop temporary table t1; +# Cleanup +# +drop temporary table if exists t1; +drop table if exists t1, t2; +drop procedure if exists p_verify_reprepare_count; +drop procedure if exists p1; +drop function if exists f1; +drop view if exists t1; +drop schema if exists mysqltest; diff --git a/mysql-test/r/row.result-pq b/mysql-test/r/row.result-pq new file mode 100644 index 000000000000..bbb3d4d83b01 --- /dev/null +++ b/mysql-test/r/row.result-pq @@ -0,0 +1,662 @@ +drop table if exists t1; +select (1,2,3) IN ((3,2,3), (1,2,3), (1,3,3)); +(1,2,3) IN ((3,2,3), (1,2,3), (1,3,3)) +1 +select row(10,2,3) IN (row(3,2,3), row(1,2,3), row(1,3,3)); +row(10,2,3) IN (row(3,2,3), row(1,2,3), row(1,3,3)) +0 +select row(1,2,3) IN (row(3,NULL,3), row(1,2,3), row(1,3,3)); +row(1,2,3) IN (row(3,NULL,3), row(1,2,3), row(1,3,3)) +1 +select row(10,2,3) IN (row(3,NULL,3), row(1,2,3), row(1,3,3)); +row(10,2,3) IN (row(3,NULL,3), row(1,2,3), row(1,3,3)) +0 +select row('a',1.5,3) IN (row(1,2,3), row('a',1.5,3), row('a','a','a')); +row('a',1.5,3) IN (row(1,2,3), row('a',1.5,3), row('a','a','a')) +1 +Warnings: +Warning 1292 Truncated incorrect DECIMAL value: 'a' +Warning 1292 Truncated incorrect INTEGER value: 'a' +select row('a',0,3) IN (row(3,2,3), row('a','a','3'), row(1,3,3)); +row('a',0,3) IN (row(3,2,3), row('a','a','3'), row(1,3,3)) +1 +Warnings: +Warning 1292 Truncated incorrect INTEGER value: 'a' +select row('a',0,3) IN (row(3,2,3), row('a','0','3'), row(1,3,3)); +row('a',0,3) IN (row(3,2,3), row('a','0','3'), row(1,3,3)) +1 +select row('a',1.5,3) IN (row(3,NULL,3), row('a',1.5,3), row(1,3,3)); +row('a',1.5,3) IN (row(3,NULL,3), row('a',1.5,3), row(1,3,3)) +1 +select row('b',1.5,3) IN (row(3,NULL,3), row('a',1.5,3), row(1,3,3)); +row('b',1.5,3) IN (row(3,NULL,3), row('a',1.5,3), row(1,3,3)) +0 +select row('b',1.5,3) IN (row('b',NULL,3), row('a',1.5,3), row(1,3,3)); +row('b',1.5,3) IN (row('b',NULL,3), row('a',1.5,3), row(1,3,3)) +NULL +select row('b',1.5,3) IN (row('b',NULL,4), row('a',1.5,3), row(1,3,3)); +row('b',1.5,3) IN (row('b',NULL,4), row('a',1.5,3), row(1,3,3)) +0 +select (1,2,(3,4)) IN ((3,2,(3,4)), (1,2,(3,4))); +(1,2,(3,4)) IN ((3,2,(3,4)), (1,2,(3,4))) +1 +select row(1,2,row(3,4)) IN (row(3,2,row(3,4)), row(1,2,4)); +ERROR 21000: Operand should contain 2 column(s) +select row(1,2,row(3,4)) IN (row(3,2,row(3,4)), row(1,2,row(3,NULL))); +row(1,2,row(3,4)) IN (row(3,2,row(3,4)), row(1,2,row(3,NULL))) +NULL +explain select row(1,2,row(3,4)) IN (row(3,2,row(3,4)), row(1,2,row(3,NULL))); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 /* select#1 */ select ((1,2,(3,4)) in ((3,2,(3,4)),(1,2,(3,NULL)))) AS `row(1,2,row(3,4)) IN (row(3,2,row(3,4)), row(1,2,row(3,NULL)))` +select row(1,2,row(3,null)) IN (row(3,2,row(3,4)), row(1,2,row(4,5))); +row(1,2,row(3,null)) IN (row(3,2,row(3,4)), row(1,2,row(4,5))) +0 +select row(1,2,row(3,null)) IN (row(3,2,row(3,4)), row(1,2,row(3,5))); +row(1,2,row(3,null)) IN (row(3,2,row(3,4)), row(1,2,row(3,5))) +NULL +SELECT (1,2,3)=(0,NULL,3); +(1,2,3)=(0,NULL,3) +0 +SELECT (1,2,3)=(1,NULL,3); +(1,2,3)=(1,NULL,3) +NULL +SELECT (1,2,3)=(1,NULL,0); +(1,2,3)=(1,NULL,0) +0 +SELECT ROW(1,2,3)=ROW(1,2,3); +ROW(1,2,3)=ROW(1,2,3) +1 +SELECT ROW(2,2,3)=ROW(1+1,2,3); +ROW(2,2,3)=ROW(1+1,2,3) +1 +SELECT ROW(1,2,3)=ROW(1+1,2,3); +ROW(1,2,3)=ROW(1+1,2,3) +0 +SELECT ROW(1,2,3)ROW(1+1,2,3); +ROW(1,2,3)>ROW(1+1,2,3) +0 +SELECT ROW(1,2,3)<=ROW(1+1,2,3); +ROW(1,2,3)<=ROW(1+1,2,3) +1 +SELECT ROW(1,2,3)>=ROW(1+1,2,3); +ROW(1,2,3)>=ROW(1+1,2,3) +0 +SELECT ROW(1,2,3)<>ROW(1+1,2,3); +ROW(1,2,3)<>ROW(1+1,2,3) +1 +SELECT ROW(NULL,2,3)=ROW(NULL,2,3); +ROW(NULL,2,3)=ROW(NULL,2,3) +NULL +SELECT ROW(NULL,2,3)<=>ROW(NULL,2,3); +ROW(NULL,2,3)<=>ROW(NULL,2,3) +1 +SELECT ROW(1,2,ROW(3,4,5))=ROW(1,2,ROW(3,4,5)); +ROW(1,2,ROW(3,4,5))=ROW(1,2,ROW(3,4,5)) +1 +SELECT ROW('test',2,3.33)=ROW('test',2,3.33); +ROW('test',2,3.33)=ROW('test',2,3.33) +1 +SELECT ROW('test',2,3.33)=ROW('test',2,3.33,4); +ERROR 21000: Operand should contain 3 column(s) +SELECT ROW('test',2,ROW(3,33))=ROW('test',2,ROW(3,33)); +ROW('test',2,ROW(3,33))=ROW('test',2,ROW(3,33)) +1 +SELECT ROW('test',2,ROW(3,33))=ROW('test',2,ROW(3,3)); +ROW('test',2,ROW(3,33))=ROW('test',2,ROW(3,3)) +0 +SELECT ROW('test',2,ROW(3,33))=ROW('test',2,ROW(3,NULL)); +ROW('test',2,ROW(3,33))=ROW('test',2,ROW(3,NULL)) +NULL +SELECT ROW('test',2,ROW(3,33))=ROW('test',2,4); +ERROR 21000: Operand should contain 2 column(s) +create table t1 ( a int, b int, c int); +insert into t1 values (1,2,3), (2,3,1), (3,2,1), (1,2,NULL); +select * from t1 where ROW(1,2,3)=ROW(a,b,c); +a b c +1 2 3 +select * from t1 where ROW(0,2,3)=ROW(a,b,c); +a b c +select * from t1 where ROW(1,2,3) ROW(3,4); +ROW(2,10) <=> ROW(3,4) +0 +SELECT ROW(NULL,10) <=> ROW(3,NULL); +ROW(NULL,10) <=> ROW(3,NULL) +0 +SELECT ROW(1,ROW(2,3)) IN (ROW(1,ROW(2,3)),ROW(1,1)); +ERROR 21000: Operand should contain 2 column(s) +SELECT ROW(1,ROW(2,3)) IN (ROW(1,ROW(2,3)),ROW(1,1),ROW(1,ROW(2,3))); +ERROR 21000: Operand should contain 2 column(s) +SELECT ROW(1,ROW(2,3)) IN (ROW(1,ROW(2,3)),ROW(1,ROW(2,2,2))); +ERROR 21000: Operand should contain 2 column(s) +SELECT ROW(1,ROW(2,3,4)) IN (ROW(1,ROW(2,3,4)),ROW(1,ROW(2,2))); +ERROR 21000: Operand should contain 3 column(s) +SELECT ROW(1,ROW(2,3)) IN (ROW(1,ROW(2,3)),(SELECT 1,1)); +ERROR 21000: Operand should contain 2 column(s) +SELECT ROW(1,ROW(2,3)) IN (ROW(1,ROW(2,3)),(SELECT 1,1),ROW(1,ROW(2,4))); +ERROR 21000: Operand should contain 2 column(s) +SELECT ROW(1,ROW(2,3)) IN ((SELECT 1,1),ROW(1,ROW(2,3))); +ERROR 21000: Operand should contain 2 column(s) +SELECT ROW(2,1) IN (ROW(21,2),ROW(ROW(1,1,3),0)); +ERROR 21000: Operand should contain 1 column(s) +SELECT ROW(2,1) IN (ROW(ROW(1,1,3),0),ROW(21,2)); +ERROR 21000: Operand should contain 1 column(s) +CREATE TABLE t1(a int, b int, c int); +INSERT INTO t1 VALUES (1, 2, 3), +(NULL, 2, 3 ), (1, NULL, 3 ), (1, 2, NULL), +(NULL, 2, 3+1), (1, NULL, 3+1), (1, 2+1, NULL), +(NULL, 2, 3-1), (1, NULL, 3-1), (1, 2-1, NULL); +SELECT (1,2,3) = (1, NULL, 3); +(1,2,3) = (1, NULL, 3) +NULL +SELECT (1,2,3) = (1+1, NULL, 3); +(1,2,3) = (1+1, NULL, 3) +0 +SELECT (1,2,3) = (1, NULL, 3+1); +(1,2,3) = (1, NULL, 3+1) +0 +SELECT * FROM t1 WHERE (a,b,c) = (1,2,3); +a b c +1 2 3 +SELECT (1,2,3) <> (1, NULL, 3); +(1,2,3) <> (1, NULL, 3) +NULL +SELECT (1,2,3) <> (1+1, NULL, 3); +(1,2,3) <> (1+1, NULL, 3) +1 +SELECT (1,2,3) <> (1, NULL, 3+1); +(1,2,3) <> (1, NULL, 3+1) +1 +SELECT * FROM t1 WHERE (a,b,c) <> (1,2,3); +a b c +NULL 2 4 +1 NULL 4 +1 3 NULL +NULL 2 2 +1 NULL 2 +1 1 NULL +SELECT (1,2,3) < (NULL, 2, 3); +(1,2,3) < (NULL, 2, 3) +NULL +SELECT (1,2,3) < (1, NULL, 3); +(1,2,3) < (1, NULL, 3) +NULL +SELECT (1,2,3) < (1-1, NULL, 3); +(1,2,3) < (1-1, NULL, 3) +0 +SELECT (1,2,3) < (1+1, NULL, 3); +(1,2,3) < (1+1, NULL, 3) +1 +SELECT * FROM t1 WHERE (a,b,c) < (1,2,3); +a b c +1 1 NULL +SELECT (1,2,3) <= (NULL, 2, 3); +(1,2,3) <= (NULL, 2, 3) +NULL +SELECT (1,2,3) <= (1, NULL, 3); +(1,2,3) <= (1, NULL, 3) +NULL +SELECT (1,2,3) <= (1-1, NULL, 3); +(1,2,3) <= (1-1, NULL, 3) +0 +SELECT (1,2,3) <= (1+1, NULL, 3); +(1,2,3) <= (1+1, NULL, 3) +1 +SELECT * FROM t1 WHERE (a,b,c) <= (1,2,3); +a b c +1 2 3 +1 1 NULL +SELECT (1,2,3) > (NULL, 2, 3); +(1,2,3) > (NULL, 2, 3) +NULL +SELECT (1,2,3) > (1, NULL, 3); +(1,2,3) > (1, NULL, 3) +NULL +SELECT (1,2,3) > (1-1, NULL, 3); +(1,2,3) > (1-1, NULL, 3) +1 +SELECT (1,2,3) > (1+1, NULL, 3); +(1,2,3) > (1+1, NULL, 3) +0 +SELECT * FROM t1 WHERE (a,b,c) > (1,2,3); +a b c +1 3 NULL +SELECT (1,2,3) >= (NULL, 2, 3); +(1,2,3) >= (NULL, 2, 3) +NULL +SELECT (1,2,3) >= (1, NULL, 3); +(1,2,3) >= (1, NULL, 3) +NULL +SELECT (1,2,3) >= (1-1, NULL, 3); +(1,2,3) >= (1-1, NULL, 3) +1 +SELECT (1,2,3) >= (1+1, NULL, 3); +(1,2,3) >= (1+1, NULL, 3) +0 +SELECT * FROM t1 WHERE (a,b,c) >= (1,2,3); +a b c +1 2 3 +1 3 NULL +DROP TABLE t1; +SELECT ROW(1,1,1) = ROW(1,1,1) as `1`, ROW(1,1,1) = ROW(1,2,1) as `0`, ROW(1,NULL,1) = ROW(2,2,1) as `0`, ROW(1,NULL,1) = ROW(1,2,2) as `0`, ROW(1,NULL,1) = ROW(1,2,1) as `null` ; +1 0 0 0 null +1 0 0 0 NULL +select row(NULL,1)=(2,0); +row(NULL,1)=(2,0) +0 +CREATE TABLE t1 (a int, b int, PRIMARY KEY (a,b)); +INSERT INTO t1 VALUES (1,1), (2,1), (3,1), (1,2), (3,2), (3,3); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT * FROM t1 WHERE a=3 AND b=2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL const PRIMARY PRIMARY 8 const,const 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select '3' AS `a`,'2' AS `b` from `test`.`t1` where true +EXPLAIN SELECT * FROM t1 WHERE (a,b)=(3,2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL const PRIMARY PRIMARY 8 const,const 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select '3' AS `a`,'2' AS `b` from `test`.`t1` where true +SELECT * FROM t1 WHERE a=3 and b=2; +a b +3 2 +SELECT * FROM t1 WHERE (a,b)=(3,2); +a b +3 2 +CREATE TABLE t2 (a int, b int, c int, PRIMARY KEY (a,b,c)); +INSERT INTO t2 VALUES +(1,1,2), (3,1,3), (1,2,2), (4,4,2), +(1,1,1), (3,1,1), (1,2,1); +ANALYZE TABLE t2; +Table Op Msg_type Msg_text +test.t2 analyze status OK +EXPLAIN SELECT * FROM t1,t2 WHERE t1.a=t2.a AND t1.b=t2.b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL index PRIMARY PRIMARY 12 NULL 7 100.00 Using index +2 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 8 test.t2.a,test.t2.b 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c` from `test`.`t1` join `test`.`t2` where ((`test`.`t1`.`b` = `test`.`t2`.`b`) and (`test`.`t1`.`a` = `test`.`t2`.`a`)) +EXPLAIN FORMAT=tree SELECT * FROM t1,t2 WHERE t1.a=t2.a AND t1.b=t2.b; +EXPLAIN +-> Parallel scan on + -> Nested loop inner join (cost=3.40 rows=7) + -> PQblock scan on t2 using PRIMARY (cost=0.95 rows=7) + -> Single-row index lookup on t1 using PRIMARY (a=t2.a, b=t2.b) (cost=0.26 rows=1) + +EXPLAIN SELECT * FROM t1,t2 WHERE (t1.a,t1.b)=(t2.a,t2.b); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL index PRIMARY PRIMARY 12 NULL 7 100.00 Using index +2 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 8 test.t2.a,test.t2.b 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c` from `test`.`t1` join `test`.`t2` where ((`test`.`t1`.`b` = `test`.`t2`.`b`) and (`test`.`t1`.`a` = `test`.`t2`.`a`)) +EXPLAIN FORMAT=tree SELECT * FROM t1,t2 WHERE (t1.a,t1.b)=(t2.a,t2.b); +EXPLAIN +-> Parallel scan on + -> Nested loop inner join (cost=3.40 rows=7) + -> PQblock scan on t2 using PRIMARY (cost=0.95 rows=7) + -> Single-row index lookup on t1 using PRIMARY (a=t2.a, b=t2.b) (cost=0.26 rows=1) + +SELECT * FROM t1,t2 WHERE t1.a=t2.a and t1.b=t2.b; +a b a b c +1 1 1 1 1 +1 1 1 1 2 +1 2 1 2 1 +1 2 1 2 2 +3 1 3 1 1 +3 1 3 1 3 +SELECT * FROM t1,t2 WHERE (t1.a,t1.b)=(t2.a,t2.b); +a b a b c +1 1 1 1 1 +1 1 1 1 2 +1 2 1 2 1 +1 2 1 2 2 +3 1 3 1 1 +3 1 3 1 3 +EXPLAIN SELECT * FROM t1,t2 WHERE t1.a=t2.a AND t1.b=2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 6 16.67 Parallel execute (1 workers) +2 SIMPLE t1 NULL index PRIMARY PRIMARY 8 NULL 6 16.67 Using where; Using index +2 SIMPLE t2 NULL ref PRIMARY PRIMARY 4 test.t1.a 2 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c` from `test`.`t1` join `test`.`t2` where ((`test`.`t1`.`b` = 2) and (`test`.`t2`.`a` = `test`.`t1`.`a`)) +EXPLAIN SELECT * FROM t1,t2 WHERE (t1.a,t1.b)=(t2.a,2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 6 16.67 Parallel execute (1 workers) +2 SIMPLE t1 NULL index PRIMARY PRIMARY 8 NULL 6 16.67 Using where; Using index +2 SIMPLE t2 NULL ref PRIMARY PRIMARY 4 test.t1.a 2 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c` from `test`.`t1` join `test`.`t2` where ((`test`.`t1`.`b` = 2) and (`test`.`t2`.`a` = `test`.`t1`.`a`)) +SELECT * FROM t1,t2 WHERE t1.a=1 and t1.b=t2.b; +a b a b c +1 1 1 1 1 +1 1 1 1 2 +1 1 3 1 1 +1 1 3 1 3 +1 2 1 2 1 +1 2 1 2 2 +SELECT * FROM t1,t2 WHERE (t1.a,t1.b)=(t2.a,2); +a b a b c +1 2 1 1 1 +1 2 1 1 2 +1 2 1 2 1 +1 2 1 2 2 +3 2 3 1 1 +3 2 3 1 3 +EXPLAIN SELECT * FROM t1,t2 WHERE (t1.a,t1.b)=(t2.a,t2.b+1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL index PRIMARY PRIMARY 12 NULL 7 100.00 Using index +2 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 8 test.t2.a,func 1 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c` from `test`.`t1` join `test`.`t2` where ((`test`.`t1`.`a` = `test`.`t2`.`a`) and (`test`.`t1`.`b` = (`test`.`t2`.`b` + 1))) +SELECT * FROM t1,t2 WHERE (t1.a,t1.b)=(t2.a,t2.b+1); +a b a b c +1 2 1 1 1 +1 2 1 1 2 +3 2 3 1 1 +3 2 3 1 3 +EXPLAIN SELECT * FROM t1,t2 WHERE (t1.a-1,t1.b)=(t2.a-1,t2.b+1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 6 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL PRIMARY 8 NULL 6 100.00 Using index +2 SIMPLE t2 NULL index NULL PRIMARY 12 NULL 7 100.00 Using where; Using index; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c` from `test`.`t1` join `test`.`t2` where (((`test`.`t1`.`a` - 1) = (`test`.`t2`.`a` - 1)) and (`test`.`t1`.`b` = (`test`.`t2`.`b` + 1))) +SELECT * FROM t1,t2 WHERE (t1.a-1,t1.b)=(t2.a-1,t2.b+1); +a b a b c +1 2 1 1 1 +1 2 1 1 2 +3 2 3 1 1 +3 2 3 1 3 +EXPLAIN SELECT * FROM t2 WHERE a=3 AND b=2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ref PRIMARY PRIMARY 8 const,const 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c` from `test`.`t2` where ((`test`.`t2`.`b` = 2) and (`test`.`t2`.`a` = 3)) +EXPLAIN SELECT * FROM t2 WHERE (a,b)=(3,2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ref PRIMARY PRIMARY 8 const,const 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c` from `test`.`t2` where ((`test`.`t2`.`b` = 2) and (`test`.`t2`.`a` = 3)) +SELECT * FROM t2 WHERE a=3 and b=2; +a b c +SELECT * FROM t2 WHERE (a,b)=(3,2); +a b c +EXPLAIN SELECT * FROM t1,t2 WHERE t2.a=t1.a AND t2.b=2 AND t2.c=1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 14.29 Parallel execute (1 workers) +2 SIMPLE t2 NULL index PRIMARY PRIMARY 12 NULL 7 14.29 Using where; Using index +2 SIMPLE t1 NULL ref PRIMARY PRIMARY 4 test.t2.a 2 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`c` = 1) and (`test`.`t2`.`b` = 2) and (`test`.`t1`.`a` = `test`.`t2`.`a`)) +EXPLAIN SELECT * FROM t1,t2 WHERE (t2.a,(t2.b,t2.c))=(t1.a,(2,1)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 14.29 Parallel execute (1 workers) +2 SIMPLE t2 NULL index PRIMARY PRIMARY 12 NULL 7 14.29 Using where; Using index +2 SIMPLE t1 NULL ref PRIMARY PRIMARY 4 test.t2.a 2 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`c` = 1) and (`test`.`t2`.`b` = 2) and (`test`.`t1`.`a` = `test`.`t2`.`a`)) +SELECT * FROM t1,t2 WHERE (t2.a,(t2.b,t2.c))=(t1.a,(2,1)); +a b a b c +1 1 1 2 1 +1 2 1 2 1 +EXPLAIN SELECT * FROM t1,t2 WHERE t2.a=t1.a AND (t2.b,t2.c)=(2,1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 14.29 Parallel execute (1 workers) +2 SIMPLE t2 NULL index PRIMARY PRIMARY 12 NULL 7 14.29 Using where; Using index +2 SIMPLE t1 NULL ref PRIMARY PRIMARY 4 test.t2.a 2 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`c` = 1) and (`test`.`t2`.`b` = 2) and (`test`.`t1`.`a` = `test`.`t2`.`a`)) +SELECT * FROM t1,t2 WHERE t2.a=t1.a AND (t2.b,t2.c)=(2,1); +a b a b c +1 1 1 2 1 +1 2 1 2 1 +DROP TABLE t1,t2; +CREATE TABLE t1( +a int, b int, c int, d int, e int, f int, g int, h int, +PRIMARY KEY (a,b,c,d,e,f,g) +); +INSERT INTO t1 VALUES (1,2,3,4,5,6,7,99); +SELECT h FROM t1 WHERE (a,b,c,d,e,f,g)=(1,2,3,4,5,6,7); +h +99 +SET @x:= (SELECT h FROM t1 WHERE (a,b,c,d,e,f,g)=(1,2,3,4,5,6,7)); +SELECT @x; +@x +99 +DROP TABLE t1; +CREATE TABLE t1 (a INT, b INT); +INSERT INTO t1 VALUES (1,1); +SELECT ROW(a, 1) IN (SELECT SUM(b), 1) FROM t1 GROUP BY a; +ROW(a, 1) IN (SELECT SUM(b), 1) +1 +SELECT ROW(a, 1) IN (SELECT SUM(b), 3) FROM t1 GROUP BY a; +ROW(a, 1) IN (SELECT SUM(b), 3) +0 +DROP TABLE t1; +create table t1 (a varchar(200), +b int unsigned not null primary key auto_increment) +default character set 'utf8'; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +create table t2 (c varchar(200), +d int unsigned not null primary key auto_increment) +default character set 'latin1'; +insert into t1 (a) values('abc'); +insert into t2 (c) values('abc'); +select * from t1,t2 where (a,b) = (c,d); +a b c d +abc 1 abc 1 +select host,user from mysql.user where (host,user) = ('localhost','test'); +host user +drop table t1,t2; +# +# Bug#52124 memory leaks like a sieve in datetime, timestamp, time, date fields + warnings +# +CREATE TABLE t1 (a TIME NOT NULL, b TINYINT); +INSERT IGNORE INTO t1 VALUES (0, 0),(0, 0); +SELECT 1 FROM t1 WHERE ROW(a, b) >= +ROW('1', (SELECT 1 FROM t1 WHERE a > '1234abc')); +1 +Warnings: +Warning 1292 Incorrect time value: '1234abc' for column 'a' at row 1 +DROP TABLE t1; +# +# Bug #54190: Comparison to row subquery produces incorrect result +# +SELECT ROW(1,2) = (SELECT 1,2 FROM DUAL WHERE 1 = 0); +ROW(1,2) = (SELECT 1,2 FROM DUAL WHERE 1 = 0) +NULL +SELECT ROW(1,2) = (SELECT 1,3 FROM DUAL WHERE 1 = 0); +ROW(1,2) = (SELECT 1,3 FROM DUAL WHERE 1 = 0) +NULL +CREATE TABLE t1 (i INT); +INSERT INTO t1 () VALUES (1), (2), (3); +SELECT ROW(1,2) = (SELECT 1,2 FROM t1 WHERE 1 = 0); +ROW(1,2) = (SELECT 1,2 FROM t1 WHERE 1 = 0) +NULL +SELECT ROW(1,2) = (SELECT 1,3 FROM t1 WHERE 1 = 0); +ROW(1,2) = (SELECT 1,3 FROM t1 WHERE 1 = 0) +NULL +SELECT i FROM t1 WHERE ROW(1,2) = (SELECT 1,2 FROM DUAL WHERE 1 = 0); +i +SELECT i FROM t1 WHERE ROW(1,2) = (SELECT 1,3 FROM DUAL WHERE 1 = 0); +i +DROP TABLE t1; +End of 5.1 tests +# +# Bug#18745214: ASSERTION FAILED: FALSE, FILE SQL_TMP_TABLE.CC OR +# MALFORMED PACKET +# +CREATE TABLE t1 ( a INT ) ENGINE = INNODB; +INSERT INTO t1 VALUES ( 1 ); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +SELECT row( 1, 1, 1 ) = row( 1, 1 ) FROM t1 GROUP BY a; +ERROR 21000: Operand should contain 3 column(s) +EXPLAIN SELECT row( min(a), 1 ) = row( a, 1 ) AS al FROM t1 GROUP BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using temporary +Warnings: +Note 1003 /* select#1 */ select ((min(`min(t1.a)`) = `test`.`t1`.`a`) and (1 = 1)) AS `al` from `test`.`t1` group by `test`.`t1`.`a` +SELECT row( min(a), 1 ) = row( a, 1 ) AS al FROM t1 GROUP BY a; +al +1 +EXPLAIN SELECT row( min(a), 1 ) <> row( a, 1 ) AS al FROM t1 GROUP BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using temporary +Warnings: +Note 1003 /* select#1 */ select ((min(`min(t1.a)`) <> `test`.`t1`.`a`) or (1 <> 1)) AS `al` from `test`.`t1` group by `test`.`t1`.`a` +SELECT row( min(a), 1 ) <> row( a, 1 ) AS al FROM t1 GROUP BY a; +al +0 +EXPLAIN SELECT row( min(a), 1 ) <=> row( a, 1 ) AS al FROM t1 GROUP BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using temporary +Warnings: +Note 1003 /* select#1 */ select ((min(`min(t1.a)`) <=> `test`.`t1`.`a`) and (1 <=> 1)) AS `al` from `test`.`t1` group by `test`.`t1`.`a` +SELECT row( min(a), 1 ) <=> row( a, 1 ) AS al FROM t1 GROUP BY a; +al +1 +EXPLAIN SELECT row( min(a), 1 ) > row( a, 1 ) AS al FROM t1 GROUP BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using temporary +Warnings: +Note 1003 /* select#1 */ select ((min(`min(t1.a)`),1) > (`test`.`t1`.`a`,1)) AS `al` from `test`.`t1` group by `test`.`t1`.`a` +SELECT row( min(a), 1 ) > row( a, 1 ) AS al FROM t1 GROUP BY a; +al +0 +EXPLAIN SELECT row( min(a), 1 ) >= row( a, 1 ) AS al FROM t1 GROUP BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using temporary +Warnings: +Note 1003 /* select#1 */ select ((min(`min(t1.a)`),1) >= (`test`.`t1`.`a`,1)) AS `al` from `test`.`t1` group by `test`.`t1`.`a` +SELECT row( min(a), 1 ) >= row( a, 1 ) AS al FROM t1 GROUP BY a; +al +1 +EXPLAIN SELECT row( min(a), 1 ) < row( a, 1 ) AS al FROM t1 GROUP BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using temporary +Warnings: +Note 1003 /* select#1 */ select ((min(`min(t1.a)`),1) < (`test`.`t1`.`a`,1)) AS `al` from `test`.`t1` group by `test`.`t1`.`a` +SELECT row( min(a), 1 ) < row( a, 1 ) AS al FROM t1 GROUP BY a; +al +0 +EXPLAIN SELECT row( min(a), 1 ) <= row( a, 1 ) AS al FROM t1 GROUP BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using temporary +Warnings: +Note 1003 /* select#1 */ select ((min(`min(t1.a)`),1) <= (`test`.`t1`.`a`,1)) AS `al` from `test`.`t1` group by `test`.`t1`.`a` +SELECT row( min(a), 1 ) <= row( a, 1 ) AS al FROM t1 GROUP BY a; +al +1 +EXPLAIN SELECT row( row( min(a), 1 ), 1 ) = row( row( a, 1 ), 1 ) AS al +FROM t1 GROUP BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using temporary +Warnings: +Note 1003 /* select#1 */ select ((min(`min(t1.a)`) = `test`.`t1`.`a`) and (1 = 1) and (1 = 1)) AS `al` from `test`.`t1` group by `test`.`t1`.`a` +SELECT row( row( min(a), 1 ), 1 ) = row( row( a, 1 ), 1 ) AS al +FROM t1 GROUP BY a; +al +1 +# Test of manually thrown error. +SELECT 1 <=>ALL (SELECT 1); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '<=>ALL (SELECT 1)' at line 1 +DROP TABLE t1; +# +# Bug #22299664 REGRESSION, ASSERTION FAILED: !THD->IS_ERROR() WITH +# ROW() + SPATIAL FUNCTIONS +# +SELECT ROW(ST_Intersection(POINT(1, 1), 1), (SELECT 1)); +ERROR 22023: Invalid GIS data provided to function st_intersection. +SELECT ROW(1, ST_Intersection(POINT(1, 1), 1), (SELECT 1)); +ERROR 22023: Invalid GIS data provided to function st_intersection. +SELECT ROW(POW(1000, 1000), (SELECT 1)); +ERROR 22003: DOUBLE value is out of range in 'pow(1000,1000)' +SELECT ROW(1, 2, POW(1000, 1000), (SELECT 1)); +ERROR 22003: DOUBLE value is out of range in 'pow(1000,1000)' +# Bug#31590301: Another MySQL 8.0.20 assert over Linux-5.4.0-39-generic +# using X86_64 +CREATE TABLE v0(v1 DEC, v2 INT); +INSERT INTO v0 VALUES (64, 93); +CREATE ALGORITHM = TEMPTABLE VIEW v3 AS +SELECT * +FROM v0 +WHERE (v1, FALSE) IN +((-1, EXISTS (SELECT (-128, 'x', 72) <= (76, 'x', -1))), (-1, 'x')); +DROP VIEW v3; +DROP TABLE v0; diff --git a/mysql-test/r/select_count.result-pq b/mysql-test/r/select_count.result-pq new file mode 100644 index 000000000000..3ce1f07d179f --- /dev/null +++ b/mysql-test/r/select_count.result-pq @@ -0,0 +1,578 @@ +CREATE TABLE t_innodb(c1 INT NOT NULL PRIMARY KEY, +c2 INT NOT NULL, +c3 char(20), +KEY c3_idx(c3))ENGINE=INNODB; +INSERT INTO t_innodb VALUES (1, 1, 'a'), (2,2,'a'), (3,3,'a'); +ANALYZE TABLE t_innodb; +Table Op Msg_type Msg_text +test.t_innodb analyze status OK +CREATE TABLE t_myisam(c1 INT NOT NULL PRIMARY KEY, +c2 INT NOT NULL DEFAULT 1, +c3 char(20), +KEY c3_idx(c3)) ENGINE=MYISAM; +INSERT INTO t_myisam(c1) VALUES (1), (2); +ANALYZE TABLE t_myisam; +Table Op Msg_type Msg_text +test.t_myisam analyze status OK +EXPLAIN SELECT COUNT(*) FROM t_innodb; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t_innodb NULL index NULL c3_idx 81 NULL 3 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t_innodb` +EXPLAIN SELECT COUNT(*) FROM t_myisam; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Select tables optimized away +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t_myisam` +EXPLAIN SELECT COUNT(*) FROM t_myisam, t_innodb; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t_myisam NULL index NULL PRIMARY 4 NULL 2 100.00 Using index +1 SIMPLE t_innodb NULL index NULL c3_idx 81 NULL 3 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t_myisam` join `test`.`t_innodb` +EXPLAIN SELECT MIN(c2), COUNT(*), MAX(c1) FROM t_innodb; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t_innodb NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select min(`test`.`t_innodb`.`c2`) AS `MIN(c2)`,count(0) AS `COUNT(*)`,max(`test`.`t_innodb`.`c1`) AS `MAX(c1)` from `test`.`t_innodb` +EXPLAIN SELECT MIN(c3), COUNT(*) FROM t_innodb; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t_innodb NULL index NULL c3_idx 81 NULL 3 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select min(`test`.`t_innodb`.`c3`) AS `MIN(c3)`,count(0) AS `COUNT(*)` from `test`.`t_innodb` +FLUSH STATUS; +SELECT COUNT(*) FROM t_innodb; +COUNT(*) +3 +SHOW STATUS LIKE 'Handler_%'; +Variable_name Value +Handler_commit 1 +Handler_delete 0 +Handler_discover 0 +Handler_external_lock 2 +Handler_mrr_init 0 +Handler_prepare 0 +Handler_read_first 0 +Handler_read_key 0 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +Handler_rollback 0 +Handler_savepoint 0 +Handler_savepoint_rollback 0 +Handler_update 0 +Handler_write 0 +FLUSH STATUS; +SELECT COUNT(*) FROM t_myisam; +COUNT(*) +2 +SHOW STATUS LIKE 'Handler_%'; +Variable_name Value +Handler_commit 0 +Handler_delete 0 +Handler_discover 0 +Handler_external_lock 2 +Handler_mrr_init 0 +Handler_prepare 0 +Handler_read_first 0 +Handler_read_key 0 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +Handler_rollback 0 +Handler_savepoint 0 +Handler_savepoint_rollback 0 +Handler_update 0 +Handler_write 0 +FLUSH STATUS; +SELECT COUNT(*) FROM t_myisam, t_innodb; +COUNT(*) +6 +SHOW STATUS LIKE 'Handler_%'; +Variable_name Value +Handler_commit 1 +Handler_delete 0 +Handler_discover 0 +Handler_external_lock 4 +Handler_mrr_init 0 +Handler_prepare 0 +Handler_read_first 0 +Handler_read_key 0 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +Handler_rollback 0 +Handler_savepoint 0 +Handler_savepoint_rollback 0 +Handler_update 0 +Handler_write 0 +FLUSH STATUS; +SELECT MIN(c2), COUNT(*), MAX(c1) FROM t_innodb; +MIN(c2) COUNT(*) MAX(c1) +1 3 3 +SHOW STATUS LIKE 'Handler_%'; +Variable_name Value +Handler_commit 1 +Handler_delete 0 +Handler_discover 0 +Handler_external_lock 2 +Handler_mrr_init 0 +Handler_prepare 0 +Handler_read_first 1 +Handler_read_key 2 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 4 +Handler_rollback 0 +Handler_savepoint 0 +Handler_savepoint_rollback 0 +Handler_update 0 +Handler_write 0 +FLUSH STATUS; +SELECT MIN(c3), COUNT(*) FROM t_innodb; +MIN(c3) COUNT(*) +a 3 +SHOW STATUS LIKE 'Handler_%'; +Variable_name Value +Handler_commit 1 +Handler_delete 0 +Handler_discover 0 +Handler_external_lock 2 +Handler_mrr_init 0 +Handler_prepare 0 +Handler_read_first 0 +Handler_read_key 1 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +Handler_rollback 0 +Handler_savepoint 0 +Handler_savepoint_rollback 0 +Handler_update 0 +Handler_write 0 +CREATE TABLE t_nopk(c1 INT NOT NULL , c2 INT NOT NULL)ENGINE=INNODB; +INSERT INTO t_nopk SELECT c1, c2 FROM t_innodb; +ANALYZE TABLE t_nopk; +Table Op Msg_type Msg_text +test.t_nopk analyze status OK +SHOW CREATE TABLE t_nopk; +Table Create Table +t_nopk CREATE TABLE `t_nopk` ( + `c1` int NOT NULL, + `c2` int NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +EXPLAIN SELECT COUNT(*) FROM t_nopk; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t_nopk NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t_nopk` +FLUSH STATUS; +SELECT COUNT(*) FROM t_nopk; +COUNT(*) +3 +SHOW STATUS LIKE 'Handler_%'; +Variable_name Value +Handler_commit 1 +Handler_delete 0 +Handler_discover 0 +Handler_external_lock 2 +Handler_mrr_init 0 +Handler_prepare 0 +Handler_read_first 0 +Handler_read_key 0 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +Handler_rollback 0 +Handler_savepoint 0 +Handler_savepoint_rollback 0 +Handler_update 0 +Handler_write 0 +CREATE INDEX c2_idx on t_nopk(c2); +SHOW CREATE TABLE t_nopk; +Table Create Table +t_nopk CREATE TABLE `t_nopk` ( + `c1` int NOT NULL, + `c2` int NOT NULL, + KEY `c2_idx` (`c2`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +EXPLAIN SELECT COUNT(*) FROM t_nopk; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t_nopk NULL index NULL c2_idx 4 NULL 3 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t_nopk` +FLUSH STATUS; +SELECT COUNT(*) FROM t_nopk; +COUNT(*) +3 +SHOW STATUS LIKE 'Handler_%'; +Variable_name Value +Handler_commit 1 +Handler_delete 0 +Handler_discover 0 +Handler_external_lock 2 +Handler_mrr_init 0 +Handler_prepare 0 +Handler_read_first 0 +Handler_read_key 0 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +Handler_rollback 0 +Handler_savepoint 0 +Handler_savepoint_rollback 0 +Handler_update 0 +Handler_write 0 +DROP TABLE t_nopk; +CREATE TABLE t_innodb_nopk_sk(c1 INT NOT NULL, +c2 INT NOT NULL, KEY c2_idx(c2))ENGINE=INNODB; +CREATE TABLE t_innodb_pk_nosk(c1 INT NOT NULL PRIMARY KEY, +c2 INT NOT NULL)ENGINE=INNODB; +CREATE TABLE t_innodb_nopk_nosk(c1 INT NOT NULL, +c2 INT NOT NULL)ENGINE=INNODB; +INSERT INTO t_innodb_nopk_sk(c1,c2) VALUES (1, 1), (2,2), (3,3); +INSERT INTO t_innodb_pk_nosk(c1,c2) SELECT * FROM t_innodb_nopk_sk; +INSERT INTO t_innodb_nopk_nosk(c1,c2) SELECT * FROM t_innodb_nopk_sk; +ANALYZE TABLE t_innodb_nopk_sk, t_innodb_pk_nosk, t_innodb_nopk_nosk; +Table Op Msg_type Msg_text +test.t_innodb_nopk_sk analyze status OK +test.t_innodb_pk_nosk analyze status OK +test.t_innodb_nopk_nosk analyze status OK +EXPLAIN SELECT COUNT(*) FROM t_innodb_nopk_sk; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t_innodb_nopk_sk NULL index NULL c2_idx 4 NULL 3 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t_innodb_nopk_sk` +EXPLAIN SELECT COUNT(*) FROM t_innodb_pk_nosk; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t_innodb_pk_nosk NULL index NULL PRIMARY 4 NULL 3 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t_innodb_pk_nosk` +EXPLAIN SELECT COUNT(*) FROM t_innodb_nopk_nosk; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t_innodb_nopk_nosk NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t_innodb_nopk_nosk` +FLUSH STATUS; +SELECT COUNT(*) FROM t_innodb_nopk_sk; +COUNT(*) +3 +SHOW STATUS LIKE 'Handler_%'; +Variable_name Value +Handler_commit 1 +Handler_delete 0 +Handler_discover 0 +Handler_external_lock 2 +Handler_mrr_init 0 +Handler_prepare 0 +Handler_read_first 0 +Handler_read_key 0 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +Handler_rollback 0 +Handler_savepoint 0 +Handler_savepoint_rollback 0 +Handler_update 0 +Handler_write 0 +FLUSH STATUS; +SELECT COUNT(*) FROM t_innodb_pk_nosk; +COUNT(*) +3 +SHOW STATUS LIKE 'Handler_%'; +Variable_name Value +Handler_commit 1 +Handler_delete 0 +Handler_discover 0 +Handler_external_lock 2 +Handler_mrr_init 0 +Handler_prepare 0 +Handler_read_first 0 +Handler_read_key 0 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +Handler_rollback 0 +Handler_savepoint 0 +Handler_savepoint_rollback 0 +Handler_update 0 +Handler_write 0 +FLUSH STATUS; +SELECT COUNT(*) FROM t_innodb_nopk_nosk; +COUNT(*) +3 +SHOW STATUS LIKE 'Handler_%'; +Variable_name Value +Handler_commit 1 +Handler_delete 0 +Handler_discover 0 +Handler_external_lock 2 +Handler_mrr_init 0 +Handler_prepare 0 +Handler_read_first 0 +Handler_read_key 0 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +Handler_rollback 0 +Handler_savepoint 0 +Handler_savepoint_rollback 0 +Handler_update 0 +Handler_write 0 +DROP TABLE t_innodb_pk_nosk, t_innodb_nopk_sk, t_innodb_nopk_nosk; +CREATE TABLE t_heap(c1 INT NOT NULL PRIMARY KEY, +c2 INT NOT NULL, +c3 char(20)) ENGINE=HEAP; +CREATE TABLE t_archive(c1 INT NOT NULL, c2 char(20)) ENGINE=ARCHIVE; +INSERT INTO t_heap SELECT * FROM t_innodb WHERE c1 > 1; +INSERT INTO t_archive SELECT c1, c3 FROM t_innodb WHERE c1 > 1; +EXPLAIN SELECT COUNT(*) FROM t_heap; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Select tables optimized away +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t_heap` +EXPLAIN SELECT COUNT(*) FROM t_innodb, t_heap; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t_heap NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t_innodb NULL index NULL c3_idx 81 NULL 3 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t_innodb` join `test`.`t_heap` +EXPLAIN SELECT COUNT(*) FROM t_archive; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Select tables optimized away +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t_archive` +EXPLAIN SELECT COUNT(*) FROM t_innodb, t_archive; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t_archive NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t_innodb NULL index NULL c3_idx 81 NULL 3 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t_innodb` join `test`.`t_archive` +FLUSH STATUS; +SELECT COUNT(*) FROM t_heap; +COUNT(*) +2 +SHOW STATUS LIKE 'Handler_%'; +Variable_name Value +Handler_commit 0 +Handler_delete 0 +Handler_discover 0 +Handler_external_lock 2 +Handler_mrr_init 0 +Handler_prepare 0 +Handler_read_first 0 +Handler_read_key 0 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +Handler_rollback 0 +Handler_savepoint 0 +Handler_savepoint_rollback 0 +Handler_update 0 +Handler_write 0 +FLUSH STATUS; +SELECT COUNT(*) FROM t_innodb, t_heap; +COUNT(*) +6 +SHOW STATUS LIKE 'Handler_%'; +Variable_name Value +Handler_commit 1 +Handler_delete 0 +Handler_discover 0 +Handler_external_lock 4 +Handler_mrr_init 0 +Handler_prepare 0 +Handler_read_first 0 +Handler_read_key 0 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +Handler_rollback 0 +Handler_savepoint 0 +Handler_savepoint_rollback 0 +Handler_update 0 +Handler_write 0 +FLUSH STATUS; +SELECT COUNT(*) FROM t_archive; +COUNT(*) +2 +SHOW STATUS LIKE 'Handler_%'; +Variable_name Value +Handler_commit 0 +Handler_delete 0 +Handler_discover 0 +Handler_external_lock 2 +Handler_mrr_init 0 +Handler_prepare 0 +Handler_read_first 0 +Handler_read_key 0 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +Handler_rollback 0 +Handler_savepoint 0 +Handler_savepoint_rollback 0 +Handler_update 0 +Handler_write 0 +FLUSH STATUS; +SELECT COUNT(*) FROM t_innodb, t_archive; +COUNT(*) +6 +SHOW STATUS LIKE 'Handler_%'; +Variable_name Value +Handler_commit 1 +Handler_delete 0 +Handler_discover 0 +Handler_external_lock 4 +Handler_mrr_init 0 +Handler_prepare 0 +Handler_read_first 0 +Handler_read_key 0 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +Handler_rollback 0 +Handler_savepoint 0 +Handler_savepoint_rollback 0 +Handler_update 0 +Handler_write 0 +DROP TABLE t_archive, t_heap; +EXPLAIN SELECT COUNT(*) FROM t_innodb FORCE INDEX(c3_idx); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t_innodb NULL index NULL c3_idx 81 NULL 3 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t_innodb` FORCE INDEX (`c3_idx`) +EXPLAIN SELECT COUNT(*) FROM t_myisam FORCE INDEX(c3_idx); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t_myisam NULL index NULL c3_idx 81 NULL 2 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t_myisam` FORCE INDEX (`c3_idx`) +FLUSH STATUS; +SELECT COUNT(*) FROM t_innodb FORCE INDEX(c3_idx); +COUNT(*) +3 +SHOW STATUS LIKE 'Handler_%'; +Variable_name Value +Handler_commit 1 +Handler_delete 0 +Handler_discover 0 +Handler_external_lock 2 +Handler_mrr_init 0 +Handler_prepare 0 +Handler_read_first 0 +Handler_read_key 0 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +Handler_rollback 0 +Handler_savepoint 0 +Handler_savepoint_rollback 0 +Handler_update 0 +Handler_write 0 +FLUSH STATUS; +SELECT COUNT(*) FROM t_myisam FORCE INDEX(c3_idx); +COUNT(*) +2 +SHOW STATUS LIKE 'Handler_%'; +Variable_name Value +Handler_commit 0 +Handler_delete 0 +Handler_discover 0 +Handler_external_lock 2 +Handler_mrr_init 0 +Handler_prepare 0 +Handler_read_first 0 +Handler_read_key 0 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +Handler_rollback 0 +Handler_savepoint 0 +Handler_savepoint_rollback 0 +Handler_update 0 +Handler_write 0 +SELECT COUNT(*) FROM (SELECT DISTINCT c1 FROM t_myisam) dt, t_myisam; +COUNT(*) +4 +SET @s =1; +SELECT @s, COUNT(*) FROM t_innodb; +@s COUNT(*) +1 3 +set sql_mode=''; +SELECT 1 AS c1, (SELECT COUNT(*) FROM t_innodb HAVING c1 > 0) FROM DUAL; +c1 (SELECT COUNT(*) FROM t_innodb HAVING c1 > 0) +1 3 +SELECT 1 FROM t_innodb HAVING COUNT(*) > 1; +1 +1 +SELECT COUNT(*) c FROM t_innodb HAVING c > 1; +c +3 +SELECT COUNT(*) c FROM t_innodb HAVING c > 7; +c +EXPLAIN FORMAT=tree SELECT COUNT(*) c FROM t_innodb HAVING c > 7; +EXPLAIN +-> Filter: (c > 7) + -> Count rows in t_innodb + +EXPLAIN FORMAT=tree SELECT COUNT(*) c FROM t_myisam HAVING c > 7; +EXPLAIN +-> Filter: (c > 7) + -> Rows fetched before execution (cost=0.00 rows=1) + +SELECT COUNT(*) c FROM t_innodb LIMIT 10 OFFSET 5; +c +set sql_mode=default; +SELECT SQL_BIG_RESULT COUNT(*) FROM t_innodb; +COUNT(*) +3 +SELECT SQL_BIG_RESULT COUNT(*) FROM t_innodb, t_myisam; +COUNT(*) +6 +SELECT /*+ BNL(t2) */ -(t1.c1 + t2.c1) FROM t_innodb t1, t_innodb t2 +UNION ALL SELECT COUNT(*) FROM t_innodb; +-(t1.c1 + t2.c1) +-2 +-3 +-3 +-4 +-4 +-4 +-5 +-5 +-6 +3 +DROP TABLE t_innodb, t_myisam; diff --git a/mysql-test/r/skip_scan.result-pq b/mysql-test/r/skip_scan.result-pq new file mode 100644 index 000000000000..dfc35cfc33ec --- /dev/null +++ b/mysql-test/r/skip_scan.result-pq @@ -0,0 +1,1739 @@ +CREATE TABLE t (a INT, b INT, c INT, d INT, e INT, PRIMARY KEY(a, b, c, d), KEY(b, d)) ENGINE=innodb; +# Since ANALYZE TABLE only reads a subset of the data, the statistics for +# table t depends on the row order. And since the INSERT INTO ... SELECT +# may be executed using different execution plans, we've added ORDER BY +# to ensure that we rows has the same order every time. If not, the +# estimated number of rows in EXPLAIN may change on different platforms. +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +set optimizer_switch = 'skip_scan=on'; +EXPLAIN SELECT b, d FROM t WHERE d < 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range PRIMARY,b b 8 NULL 833 100.00 Using where; Using index for skip scan +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`b` AS `b`,`test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` < 2) +FLUSH STATUS; +SELECT b, d FROM t WHERE d < 2; +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 1 +Handler_read_key 11 +Handler_read_last 0 +Handler_read_next 250 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +set optimizer_switch = 'skip_scan=off'; +EXPLAIN SELECT b, d FROM t WHERE d < 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2500 33.33 Parallel execute (4 workers) +2 SIMPLE t NULL index NULL b 8 NULL 2500 33.33 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`b` AS `b`,`test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` < 2) +FLUSH STATUS; +SELECT b, d FROM t WHERE d < 2; +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 1 +Handler_read_key 1 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 2504 +include/diff_tables.inc [test.skip_scan, test.no_skip_scan] +EXPLAIN SELECT /*+ SKIP_SCAN(t) */ b, d FROM t WHERE d < 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range PRIMARY,b b 8 NULL 833 100.00 Using where; Using index for skip scan +Warnings: +Note 1003 /* select#1 */ select /*+ SKIP_SCAN(`t`@`select#1`) */ `test`.`t`.`b` AS `b`,`test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` < 2) +FLUSH STATUS; +SELECT /*+ SKIP_SCAN(t) */ b, d FROM t WHERE d < 2; +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 1 +Handler_read_key 11 +Handler_read_last 0 +Handler_read_next 250 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.hint_skip_scan, test.no_skip_scan] +set optimizer_switch = 'skip_scan=on'; +EXPLAIN SELECT b, d FROM t WHERE d > 4; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range PRIMARY,b b 8 NULL 833 100.00 Using where; Using index for skip scan +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`b` AS `b`,`test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` > 4) +FLUSH STATUS; +SELECT b, d FROM t WHERE d > 4; +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 1 +Handler_read_key 11 +Handler_read_last 0 +Handler_read_next 1500 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +set optimizer_switch = 'skip_scan=off'; +EXPLAIN SELECT b, d FROM t WHERE d > 4; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2500 33.33 Parallel execute (4 workers) +2 SIMPLE t NULL index NULL b 8 NULL 2500 33.33 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`b` AS `b`,`test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` > 4) +FLUSH STATUS; +SELECT b, d FROM t WHERE d > 4; +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 1 +Handler_read_key 1 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 2504 +include/diff_tables.inc [test.skip_scan, test.no_skip_scan] +EXPLAIN SELECT /*+ SKIP_SCAN(t) */ b, d FROM t WHERE d > 4; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range PRIMARY,b b 8 NULL 833 100.00 Using where; Using index for skip scan +Warnings: +Note 1003 /* select#1 */ select /*+ SKIP_SCAN(`t`@`select#1`) */ `test`.`t`.`b` AS `b`,`test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` > 4) +FLUSH STATUS; +SELECT /*+ SKIP_SCAN(t) */ b, d FROM t WHERE d > 4; +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 1 +Handler_read_key 11 +Handler_read_last 0 +Handler_read_next 1500 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.hint_skip_scan, test.no_skip_scan] +set optimizer_switch = 'skip_scan=on'; +EXPLAIN SELECT a, b, c, d FROM t WHERE a = 5 AND d <= 3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 250 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ref PRIMARY,b PRIMARY 4 const 250 33.33 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,`test`.`t`.`c` AS `c`,`test`.`t`.`d` AS `d` from `test`.`t` where ((`test`.`t`.`a` = 5) and (`test`.`t`.`d` <= 3)) +FLUSH STATUS; +SELECT a, b, c, d FROM t WHERE a = 5 AND d <= 3; +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 3 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 251 +set optimizer_switch = 'skip_scan=off'; +EXPLAIN SELECT a, b, c, d FROM t WHERE a = 5 AND d <= 3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 250 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ref PRIMARY PRIMARY 4 const 250 33.33 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,`test`.`t`.`c` AS `c`,`test`.`t`.`d` AS `d` from `test`.`t` where ((`test`.`t`.`a` = 5) and (`test`.`t`.`d` <= 3)) +FLUSH STATUS; +SELECT a, b, c, d FROM t WHERE a = 5 AND d <= 3; +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 3 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 251 +include/diff_tables.inc [test.skip_scan, test.no_skip_scan] +EXPLAIN SELECT /*+ SKIP_SCAN(t) */ a, b, c, d FROM t WHERE a = 5 AND d <= 3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range PRIMARY,b PRIMARY 16 NULL 83 100.00 Using where; Using index for skip scan +Warnings: +Note 1003 /* select#1 */ select /*+ SKIP_SCAN(`t`@`select#1`) */ `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,`test`.`t`.`c` AS `c`,`test`.`t`.`d` AS `d` from `test`.`t` where ((`test`.`t`.`a` = 5) and (`test`.`t`.`d` <= 3)) +FLUSH STATUS; +SELECT /*+ SKIP_SCAN(t) */ a, b, c, d FROM t WHERE a = 5 AND d <= 3; +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 51 +Handler_read_last 0 +Handler_read_next 75 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.hint_skip_scan, test.no_skip_scan] +set optimizer_switch = 'skip_scan=on'; +EXPLAIN SELECT a, b, c, d FROM t WHERE a = 5 AND d >= 98; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 250 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ref PRIMARY,b PRIMARY 4 const 250 33.33 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,`test`.`t`.`c` AS `c`,`test`.`t`.`d` AS `d` from `test`.`t` where ((`test`.`t`.`a` = 5) and (`test`.`t`.`d` >= 98)) +FLUSH STATUS; +SELECT a, b, c, d FROM t WHERE a = 5 AND d >= 98; +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 3 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 251 +set optimizer_switch = 'skip_scan=off'; +EXPLAIN SELECT a, b, c, d FROM t WHERE a = 5 AND d >= 98; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 250 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ref PRIMARY PRIMARY 4 const 250 33.33 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,`test`.`t`.`c` AS `c`,`test`.`t`.`d` AS `d` from `test`.`t` where ((`test`.`t`.`a` = 5) and (`test`.`t`.`d` >= 98)) +FLUSH STATUS; +SELECT a, b, c, d FROM t WHERE a = 5 AND d >= 98; +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 3 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 251 +include/diff_tables.inc [test.skip_scan, test.no_skip_scan] +EXPLAIN SELECT /*+ SKIP_SCAN(t) */ a, b, c, d FROM t WHERE a = 5 AND d >= 98; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range PRIMARY,b PRIMARY 16 NULL 83 100.00 Using where; Using index for skip scan +Warnings: +Note 1003 /* select#1 */ select /*+ SKIP_SCAN(`t`@`select#1`) */ `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,`test`.`t`.`c` AS `c`,`test`.`t`.`d` AS `d` from `test`.`t` where ((`test`.`t`.`a` = 5) and (`test`.`t`.`d` >= 98)) +FLUSH STATUS; +SELECT /*+ SKIP_SCAN(t) */ a, b, c, d FROM t WHERE a = 5 AND d >= 98; +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 51 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.hint_skip_scan, test.no_skip_scan] +set optimizer_switch = 'skip_scan=on'; +EXPLAIN SELECT a, b, c, d FROM t WHERE a IN (1, 5) AND d >= 98; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 500 33.33 Parallel execute (3 workers) +2 SIMPLE t NULL range PRIMARY,b PRIMARY 4 NULL 500 33.33 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,`test`.`t`.`c` AS `c`,`test`.`t`.`d` AS `d` from `test`.`t` where ((`test`.`t`.`a` in (1,5)) and (`test`.`t`.`d` >= 98)) +FLUSH STATUS; +SELECT a, b, c, d FROM t WHERE a IN (1, 5) AND d >= 98; +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 4 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 503 +set optimizer_switch = 'skip_scan=off'; +EXPLAIN SELECT a, b, c, d FROM t WHERE a IN (1, 5) AND d >= 98; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 500 33.33 Parallel execute (3 workers) +2 SIMPLE t NULL range PRIMARY PRIMARY 4 NULL 500 33.33 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,`test`.`t`.`c` AS `c`,`test`.`t`.`d` AS `d` from `test`.`t` where ((`test`.`t`.`a` in (1,5)) and (`test`.`t`.`d` >= 98)) +FLUSH STATUS; +SELECT a, b, c, d FROM t WHERE a IN (1, 5) AND d >= 98; +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 4 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 503 +include/diff_tables.inc [test.skip_scan, test.no_skip_scan] +EXPLAIN SELECT /*+ SKIP_SCAN(t) */ a, b, c, d FROM t WHERE a IN (1, 5) AND d >= 98; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range PRIMARY,b PRIMARY 16 NULL 166 100.00 Using where; Using index for skip scan +Warnings: +Note 1003 /* select#1 */ select /*+ SKIP_SCAN(`t`@`select#1`) */ `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,`test`.`t`.`c` AS `c`,`test`.`t`.`d` AS `d` from `test`.`t` where ((`test`.`t`.`a` in (1,5)) and (`test`.`t`.`d` >= 98)) +FLUSH STATUS; +SELECT /*+ SKIP_SCAN(t) */ a, b, c, d FROM t WHERE a IN (1, 5) AND d >= 98; +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 102 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.hint_skip_scan, test.no_skip_scan] +set optimizer_switch = 'skip_scan=on'; +EXPLAIN SELECT a, b, c, d FROM t WHERE a IN (1, 3, 5) AND d >= 98; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 750 33.33 Parallel execute (4 workers) +2 SIMPLE t NULL range PRIMARY,b PRIMARY 4 NULL 750 33.33 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,`test`.`t`.`c` AS `c`,`test`.`t`.`d` AS `d` from `test`.`t` where ((`test`.`t`.`a` in (1,3,5)) and (`test`.`t`.`d` >= 98)) +FLUSH STATUS; +SELECT a, b, c, d FROM t WHERE a IN (1, 3, 5) AND d >= 98; +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 6 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 754 +set optimizer_switch = 'skip_scan=off'; +EXPLAIN SELECT a, b, c, d FROM t WHERE a IN (1, 3, 5) AND d >= 98; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 750 33.33 Parallel execute (4 workers) +2 SIMPLE t NULL range PRIMARY PRIMARY 4 NULL 750 33.33 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,`test`.`t`.`c` AS `c`,`test`.`t`.`d` AS `d` from `test`.`t` where ((`test`.`t`.`a` in (1,3,5)) and (`test`.`t`.`d` >= 98)) +FLUSH STATUS; +SELECT a, b, c, d FROM t WHERE a IN (1, 3, 5) AND d >= 98; +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 6 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 754 +include/diff_tables.inc [test.skip_scan, test.no_skip_scan] +EXPLAIN SELECT /*+ SKIP_SCAN(t) */ a, b, c, d FROM t WHERE a IN (1, 3, 5) AND d >= 98; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range PRIMARY,b PRIMARY 16 NULL 249 100.00 Using where; Using index for skip scan +Warnings: +Note 1003 /* select#1 */ select /*+ SKIP_SCAN(`t`@`select#1`) */ `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,`test`.`t`.`c` AS `c`,`test`.`t`.`d` AS `d` from `test`.`t` where ((`test`.`t`.`a` in (1,3,5)) and (`test`.`t`.`d` >= 98)) +FLUSH STATUS; +SELECT /*+ SKIP_SCAN(t) */ a, b, c, d FROM t WHERE a IN (1, 3, 5) AND d >= 98; +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 153 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.hint_skip_scan, test.no_skip_scan] +set optimizer_switch = 'skip_scan=on'; +EXPLAIN SELECT a, b, c, d FROM t WHERE a IN (1, 5) AND b IN (1, 2) AND d >= 98; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 20.00 Parallel execute (2 workers) +2 SIMPLE t NULL range PRIMARY,b b 12 NULL 2 20.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,`test`.`t`.`c` AS `c`,`test`.`t`.`d` AS `d` from `test`.`t` where ((`test`.`t`.`a` in (1,5)) and (`test`.`t`.`b` in (1,2)) and (`test`.`t`.`d` >= 98)) +FLUSH STATUS; +SELECT a, b, c, d FROM t WHERE a IN (1, 5) AND b IN (1, 2) AND d >= 98; +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 4 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 2 +set optimizer_switch = 'skip_scan=off'; +EXPLAIN SELECT a, b, c, d FROM t WHERE a IN (1, 5) AND b IN (1, 2) AND d >= 98; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 20.00 Parallel execute (2 workers) +2 SIMPLE t NULL range PRIMARY,b b 12 NULL 2 20.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,`test`.`t`.`c` AS `c`,`test`.`t`.`d` AS `d` from `test`.`t` where ((`test`.`t`.`a` in (1,5)) and (`test`.`t`.`b` in (1,2)) and (`test`.`t`.`d` >= 98)) +FLUSH STATUS; +SELECT a, b, c, d FROM t WHERE a IN (1, 5) AND b IN (1, 2) AND d >= 98; +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 4 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 2 +include/diff_tables.inc [test.skip_scan, test.no_skip_scan] +EXPLAIN SELECT /*+ SKIP_SCAN(t) */ a, b, c, d FROM t WHERE a IN (1, 5) AND b IN (1, 2) AND d >= 98; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range PRIMARY,b PRIMARY 16 NULL 66 100.00 Using where; Using index for skip scan +Warnings: +Note 1003 /* select#1 */ select /*+ SKIP_SCAN(`t`@`select#1`) */ `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,`test`.`t`.`c` AS `c`,`test`.`t`.`d` AS `d` from `test`.`t` where ((`test`.`t`.`a` in (1,5)) and (`test`.`t`.`b` in (1,2)) and (`test`.`t`.`d` >= 98)) +FLUSH STATUS; +SELECT /*+ SKIP_SCAN(t) */ a, b, c, d FROM t WHERE a IN (1, 5) AND b IN (1, 2) AND d >= 98; +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 44 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.hint_skip_scan, test.no_skip_scan] +set optimizer_switch = 'skip_scan=on'; +EXPLAIN SELECT a, b, c, d FROM t WHERE a IN (1, 2, 3, 4, 5) AND b IN (1, 2, 3) AND d >= 98; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 50.00 Parallel execute (3 workers) +2 SIMPLE t NULL range PRIMARY,b b 12 NULL 3 50.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,`test`.`t`.`c` AS `c`,`test`.`t`.`d` AS `d` from `test`.`t` where ((`test`.`t`.`a` in (1,2,3,4,5)) and (`test`.`t`.`b` in (1,2,3)) and (`test`.`t`.`d` >= 98)) +FLUSH STATUS; +SELECT a, b, c, d FROM t WHERE a IN (1, 2, 3, 4, 5) AND b IN (1, 2, 3) AND d >= 98; +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 6 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 3 +set optimizer_switch = 'skip_scan=off'; +EXPLAIN SELECT a, b, c, d FROM t WHERE a IN (1, 2, 3, 4, 5) AND b IN (1, 2, 3) AND d >= 98; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 50.00 Parallel execute (3 workers) +2 SIMPLE t NULL range PRIMARY,b b 12 NULL 3 50.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,`test`.`t`.`c` AS `c`,`test`.`t`.`d` AS `d` from `test`.`t` where ((`test`.`t`.`a` in (1,2,3,4,5)) and (`test`.`t`.`b` in (1,2,3)) and (`test`.`t`.`d` >= 98)) +FLUSH STATUS; +SELECT a, b, c, d FROM t WHERE a IN (1, 2, 3, 4, 5) AND b IN (1, 2, 3) AND d >= 98; +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 6 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 3 +include/diff_tables.inc [test.skip_scan, test.no_skip_scan] +EXPLAIN SELECT /*+ SKIP_SCAN(t) */ a, b, c, d FROM t WHERE a IN (1, 2, 3, 4, 5) AND b IN (1, 2, 3) AND d >= 98; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range PRIMARY,b PRIMARY 16 NULL 249 100.00 Using where; Using index for skip scan +Warnings: +Note 1003 /* select#1 */ select /*+ SKIP_SCAN(`t`@`select#1`) */ `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,`test`.`t`.`c` AS `c`,`test`.`t`.`d` AS `d` from `test`.`t` where ((`test`.`t`.`a` in (1,2,3,4,5)) and (`test`.`t`.`b` in (1,2,3)) and (`test`.`t`.`d` >= 98)) +FLUSH STATUS; +SELECT /*+ SKIP_SCAN(t) */ a, b, c, d FROM t WHERE a IN (1, 2, 3, 4, 5) AND b IN (1, 2, 3) AND d >= 98; +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 165 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.hint_skip_scan, test.no_skip_scan] +set optimizer_switch = 'skip_scan=on'; +EXPLAIN SELECT a, b, c, d FROM t WHERE a = 5 AND b = 2 AND d >= 98; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 10.00 Parallel execute (1 workers) +2 SIMPLE t NULL range PRIMARY,b b 12 NULL 1 10.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,`test`.`t`.`c` AS `c`,`test`.`t`.`d` AS `d` from `test`.`t` where ((`test`.`t`.`b` = 2) and (`test`.`t`.`a` = 5) and (`test`.`t`.`d` >= 98)) +FLUSH STATUS; +SELECT a, b, c, d FROM t WHERE a = 5 AND b = 2 AND d >= 98; +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 2 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 1 +set optimizer_switch = 'skip_scan=off'; +EXPLAIN SELECT a, b, c, d FROM t WHERE a = 5 AND b = 2 AND d >= 98; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 10.00 Parallel execute (1 workers) +2 SIMPLE t NULL range PRIMARY,b b 12 NULL 1 10.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,`test`.`t`.`c` AS `c`,`test`.`t`.`d` AS `d` from `test`.`t` where ((`test`.`t`.`b` = 2) and (`test`.`t`.`a` = 5) and (`test`.`t`.`d` >= 98)) +FLUSH STATUS; +SELECT a, b, c, d FROM t WHERE a = 5 AND b = 2 AND d >= 98; +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 2 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 1 +include/diff_tables.inc [test.skip_scan, test.no_skip_scan] +EXPLAIN SELECT /*+ SKIP_SCAN(t) */ a, b, c, d FROM t WHERE a = 5 AND b = 2 AND d >= 98; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range PRIMARY,b PRIMARY 16 NULL 16 100.00 Using where; Using index for skip scan +Warnings: +Note 1003 /* select#1 */ select /*+ SKIP_SCAN(`t`@`select#1`) */ `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,`test`.`t`.`c` AS `c`,`test`.`t`.`d` AS `d` from `test`.`t` where ((`test`.`t`.`b` = 2) and (`test`.`t`.`a` = 5) and (`test`.`t`.`d` >= 98)) +FLUSH STATUS; +SELECT /*+ SKIP_SCAN(t) */ a, b, c, d FROM t WHERE a = 5 AND b = 2 AND d >= 98; +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 11 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.hint_skip_scan, test.no_skip_scan] +set optimizer_switch = 'skip_scan=on'; +EXPLAIN SELECT a+1, b, c, d FROM t WHERE a = 5 AND d < 3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 250 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ref PRIMARY,b PRIMARY 4 const 250 33.33 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select (`test`.`t`.`a` + 1) AS `a+1`,`test`.`t`.`b` AS `b`,`test`.`t`.`c` AS `c`,`test`.`t`.`d` AS `d` from `test`.`t` where ((`test`.`t`.`a` = 5) and (`test`.`t`.`d` < 3)) +FLUSH STATUS; +SELECT a+1, b, c, d FROM t WHERE a = 5 AND d < 3; +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 3 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 251 +set optimizer_switch = 'skip_scan=off'; +EXPLAIN SELECT a+1, b, c, d FROM t WHERE a = 5 AND d < 3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 250 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ref PRIMARY PRIMARY 4 const 250 33.33 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select (`test`.`t`.`a` + 1) AS `a+1`,`test`.`t`.`b` AS `b`,`test`.`t`.`c` AS `c`,`test`.`t`.`d` AS `d` from `test`.`t` where ((`test`.`t`.`a` = 5) and (`test`.`t`.`d` < 3)) +FLUSH STATUS; +SELECT a+1, b, c, d FROM t WHERE a = 5 AND d < 3; +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 3 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 251 +include/diff_tables.inc [test.skip_scan, test.no_skip_scan] +EXPLAIN SELECT /*+ SKIP_SCAN(t) */ a+1, b, c, d FROM t WHERE a = 5 AND d < 3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range PRIMARY,b PRIMARY 16 NULL 83 100.00 Using where; Using index for skip scan +Warnings: +Note 1003 /* select#1 */ select /*+ SKIP_SCAN(`t`@`select#1`) */ (`test`.`t`.`a` + 1) AS `a+1`,`test`.`t`.`b` AS `b`,`test`.`t`.`c` AS `c`,`test`.`t`.`d` AS `d` from `test`.`t` where ((`test`.`t`.`a` = 5) and (`test`.`t`.`d` < 3)) +FLUSH STATUS; +SELECT /*+ SKIP_SCAN(t) */ a+1, b, c, d FROM t WHERE a = 5 AND d < 3; +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 51 +Handler_read_last 0 +Handler_read_next 50 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.hint_skip_scan, test.no_skip_scan] +set optimizer_switch = 'skip_scan=on'; +EXPLAIN SELECT b, c, d FROM t WHERE a = 5 AND d < 3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 250 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ref PRIMARY,b PRIMARY 4 const 250 33.33 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`b` AS `b`,`test`.`t`.`c` AS `c`,`test`.`t`.`d` AS `d` from `test`.`t` where ((`test`.`t`.`a` = 5) and (`test`.`t`.`d` < 3)) +FLUSH STATUS; +SELECT b, c, d FROM t WHERE a = 5 AND d < 3; +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 3 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 251 +set optimizer_switch = 'skip_scan=off'; +EXPLAIN SELECT b, c, d FROM t WHERE a = 5 AND d < 3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 250 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ref PRIMARY PRIMARY 4 const 250 33.33 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`b` AS `b`,`test`.`t`.`c` AS `c`,`test`.`t`.`d` AS `d` from `test`.`t` where ((`test`.`t`.`a` = 5) and (`test`.`t`.`d` < 3)) +FLUSH STATUS; +SELECT b, c, d FROM t WHERE a = 5 AND d < 3; +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 3 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 251 +include/diff_tables.inc [test.skip_scan, test.no_skip_scan] +EXPLAIN SELECT /*+ SKIP_SCAN(t) */ b, c, d FROM t WHERE a = 5 AND d < 3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range PRIMARY,b PRIMARY 16 NULL 83 100.00 Using where; Using index for skip scan +Warnings: +Note 1003 /* select#1 */ select /*+ SKIP_SCAN(`t`@`select#1`) */ `test`.`t`.`b` AS `b`,`test`.`t`.`c` AS `c`,`test`.`t`.`d` AS `d` from `test`.`t` where ((`test`.`t`.`a` = 5) and (`test`.`t`.`d` < 3)) +FLUSH STATUS; +SELECT /*+ SKIP_SCAN(t) */ b, c, d FROM t WHERE a = 5 AND d < 3; +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 51 +Handler_read_last 0 +Handler_read_next 50 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.hint_skip_scan, test.no_skip_scan] +set optimizer_switch = 'skip_scan=on'; +EXPLAIN SELECT a, b, c, d FROM t WHERE a = b AND d >= 98; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range PRIMARY,b b 8 NULL 833 10.00 Using where; Using index for skip scan +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,`test`.`t`.`c` AS `c`,`test`.`t`.`d` AS `d` from `test`.`t` where ((`test`.`t`.`b` = `test`.`t`.`a`) and (`test`.`t`.`d` >= 98)) +FLUSH STATUS; +SELECT a, b, c, d FROM t WHERE a = b AND d >= 98; +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 1 +Handler_read_key 11 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +set optimizer_switch = 'skip_scan=off'; +EXPLAIN SELECT a, b, c, d FROM t WHERE a = b AND d >= 98; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2500 33.33 Parallel execute (4 workers) +2 SIMPLE t NULL index NULL b 8 NULL 2500 33.33 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,`test`.`t`.`c` AS `c`,`test`.`t`.`d` AS `d` from `test`.`t` where ((`test`.`t`.`b` = `test`.`t`.`a`) and (`test`.`t`.`d` >= 98)) +FLUSH STATUS; +SELECT a, b, c, d FROM t WHERE a = b AND d >= 98; +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 1 +Handler_read_key 1 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 2504 +include/diff_tables.inc [test.skip_scan, test.no_skip_scan] +EXPLAIN SELECT /*+ SKIP_SCAN(t) */ a, b, c, d FROM t WHERE a = b AND d >= 98; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range PRIMARY,b b 8 NULL 833 10.00 Using where; Using index for skip scan +Warnings: +Note 1003 /* select#1 */ select /*+ SKIP_SCAN(`t`@`select#1`) */ `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,`test`.`t`.`c` AS `c`,`test`.`t`.`d` AS `d` from `test`.`t` where ((`test`.`t`.`b` = `test`.`t`.`a`) and (`test`.`t`.`d` >= 98)) +FLUSH STATUS; +SELECT /*+ SKIP_SCAN(t) */ a, b, c, d FROM t WHERE a = b AND d >= 98; +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 1 +Handler_read_key 11 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.hint_skip_scan, test.no_skip_scan] +set optimizer_switch = 'skip_scan=on'; +EXPLAIN SELECT b, c, d FROM t WHERE a = 5 AND c > 10 AND d < 3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range PRIMARY,b PRIMARY 12 NULL 83 33.33 Using where; Using index for skip scan +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`b` AS `b`,`test`.`t`.`c` AS `c`,`test`.`t`.`d` AS `d` from `test`.`t` where ((`test`.`t`.`a` = 5) and (`test`.`t`.`c` > 10) and (`test`.`t`.`d` < 3)) +FLUSH STATUS; +SELECT b, c, d FROM t WHERE a = 5 AND c > 10 AND d < 3; +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 11 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +set optimizer_switch = 'skip_scan=off'; +EXPLAIN SELECT b, c, d FROM t WHERE a = 5 AND c > 10 AND d < 3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 250 11.11 Parallel execute (1 workers) +2 SIMPLE t NULL ref PRIMARY PRIMARY 4 const 250 11.11 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`b` AS `b`,`test`.`t`.`c` AS `c`,`test`.`t`.`d` AS `d` from `test`.`t` where ((`test`.`t`.`a` = 5) and (`test`.`t`.`c` > 10) and (`test`.`t`.`d` < 3)) +FLUSH STATUS; +SELECT b, c, d FROM t WHERE a = 5 AND c > 10 AND d < 3; +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 3 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 251 +include/diff_tables.inc [test.skip_scan, test.no_skip_scan] +EXPLAIN SELECT /*+ SKIP_SCAN(t) */ b, c, d FROM t WHERE a = 5 AND c > 10 AND d < 3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range PRIMARY,b PRIMARY 12 NULL 83 33.33 Using where; Using index for skip scan +Warnings: +Note 1003 /* select#1 */ select /*+ SKIP_SCAN(`t`@`select#1`) */ `test`.`t`.`b` AS `b`,`test`.`t`.`c` AS `c`,`test`.`t`.`d` AS `d` from `test`.`t` where ((`test`.`t`.`a` = 5) and (`test`.`t`.`c` > 10) and (`test`.`t`.`d` < 3)) +FLUSH STATUS; +SELECT /*+ SKIP_SCAN(t) */ b, c, d FROM t WHERE a = 5 AND c > 10 AND d < 3; +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 11 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.hint_skip_scan, test.no_skip_scan] +set optimizer_switch = 'skip_scan=on'; +EXPLAIN SELECT b, c, d FROM t WHERE a = 5 AND c > 10 AND d < 3 ORDER BY d, c; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range PRIMARY,b PRIMARY 12 NULL 83 33.33 Using where; Using index for skip scan; Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`b` AS `b`,`test`.`t`.`c` AS `c`,`test`.`t`.`d` AS `d` from `test`.`t` where ((`test`.`t`.`a` = 5) and (`test`.`t`.`c` > 10) and (`test`.`t`.`d` < 3)) order by `test`.`t`.`d`,`test`.`t`.`c` +FLUSH STATUS; +SELECT b, c, d FROM t WHERE a = 5 AND c > 10 AND d < 3 ORDER BY d, c; +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 11 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +set optimizer_switch = 'skip_scan=off'; +EXPLAIN SELECT b, c, d FROM t WHERE a = 5 AND c > 10 AND d < 3 ORDER BY d, c; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 250 11.11 Parallel execute (1 workers) +2 SIMPLE t NULL ref PRIMARY PRIMARY 4 const 250 11.11 Using where; Using index; Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`b` AS `b`,`test`.`t`.`c` AS `c`,`test`.`t`.`d` AS `d` from `test`.`t` where ((`test`.`t`.`a` = 5) and (`test`.`t`.`c` > 10) and (`test`.`t`.`d` < 3)) order by `test`.`t`.`d`,`test`.`t`.`c` +FLUSH STATUS; +SELECT b, c, d FROM t WHERE a = 5 AND c > 10 AND d < 3 ORDER BY d, c; +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 3 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 251 +include/diff_tables.inc [test.skip_scan, test.no_skip_scan] +EXPLAIN SELECT /*+ SKIP_SCAN(t) */ b, c, d FROM t WHERE a = 5 AND c > 10 AND d < 3 ORDER BY d, c; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range PRIMARY,b PRIMARY 12 NULL 83 33.33 Using where; Using index for skip scan; Using filesort +Warnings: +Note 1003 /* select#1 */ select /*+ SKIP_SCAN(`t`@`select#1`) */ `test`.`t`.`b` AS `b`,`test`.`t`.`c` AS `c`,`test`.`t`.`d` AS `d` from `test`.`t` where ((`test`.`t`.`a` = 5) and (`test`.`t`.`c` > 10) and (`test`.`t`.`d` < 3)) order by `test`.`t`.`d`,`test`.`t`.`c` +FLUSH STATUS; +SELECT /*+ SKIP_SCAN(t) */ b, c, d FROM t WHERE a = 5 AND c > 10 AND d < 3 ORDER BY d, c; +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 11 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.hint_skip_scan, test.no_skip_scan] +set optimizer_switch = 'skip_scan=on'; +EXPLAIN SELECT b, c, d FROM t WHERE a = 5 AND c > 1 AND d < 3 ORDER BY d, c * -1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range PRIMARY,b PRIMARY 12 NULL 83 33.33 Using where; Using index for skip scan; Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`b` AS `b`,`test`.`t`.`c` AS `c`,`test`.`t`.`d` AS `d` from `test`.`t` where ((`test`.`t`.`a` = 5) and (`test`.`t`.`c` > 1) and (`test`.`t`.`d` < 3)) order by `test`.`t`.`d`,(`test`.`t`.`c` * -(1)) +FLUSH STATUS; +SELECT b, c, d FROM t WHERE a = 5 AND c > 1 AND d < 3 ORDER BY d, c * -1; +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 11 +Handler_read_last 0 +Handler_read_next 200 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +set optimizer_switch = 'skip_scan=off'; +EXPLAIN SELECT b, c, d FROM t WHERE a = 5 AND c > 1 AND d < 3 ORDER BY d, c * -1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 250 11.11 Parallel execute (1 workers) +2 SIMPLE t NULL ref PRIMARY PRIMARY 4 const 250 11.11 Using where; Using index; Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`b` AS `b`,`test`.`t`.`c` AS `c`,`test`.`t`.`d` AS `d` from `test`.`t` where ((`test`.`t`.`a` = 5) and (`test`.`t`.`c` > 1) and (`test`.`t`.`d` < 3)) order by `test`.`t`.`d`,`(t.c * -(1))` +FLUSH STATUS; +SELECT b, c, d FROM t WHERE a = 5 AND c > 1 AND d < 3 ORDER BY d, c * -1; +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 3 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 251 +include/diff_tables.inc [test.skip_scan, test.no_skip_scan] +EXPLAIN SELECT /*+ SKIP_SCAN(t) */ b, c, d FROM t WHERE a = 5 AND c > 1 AND d < 3 ORDER BY d, c * -1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range PRIMARY,b PRIMARY 12 NULL 83 33.33 Using where; Using index for skip scan; Using filesort +Warnings: +Note 1003 /* select#1 */ select /*+ SKIP_SCAN(`t`@`select#1`) */ `test`.`t`.`b` AS `b`,`test`.`t`.`c` AS `c`,`test`.`t`.`d` AS `d` from `test`.`t` where ((`test`.`t`.`a` = 5) and (`test`.`t`.`c` > 1) and (`test`.`t`.`d` < 3)) order by `test`.`t`.`d`,(`test`.`t`.`c` * -(1)) +FLUSH STATUS; +SELECT /*+ SKIP_SCAN(t) */ b, c, d FROM t WHERE a = 5 AND c > 1 AND d < 3 ORDER BY d, c * -1; +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 11 +Handler_read_last 0 +Handler_read_next 200 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.hint_skip_scan, test.no_skip_scan] +set optimizer_switch = 'skip_scan=on'; +EXPLAIN SELECT e FROM t WHERE a = 5 AND d <= 3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 250 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ref PRIMARY PRIMARY 4 const 250 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`e` AS `e` from `test`.`t` where ((`test`.`t`.`a` = 5) and (`test`.`t`.`d` <= 3)) +FLUSH STATUS; +SELECT e FROM t WHERE a = 5 AND d <= 3; +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 3 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 251 +set optimizer_switch = 'skip_scan=off'; +EXPLAIN SELECT e FROM t WHERE a = 5 AND d <= 3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 250 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ref PRIMARY PRIMARY 4 const 250 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`e` AS `e` from `test`.`t` where ((`test`.`t`.`a` = 5) and (`test`.`t`.`d` <= 3)) +FLUSH STATUS; +SELECT e FROM t WHERE a = 5 AND d <= 3; +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 3 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 251 +include/diff_tables.inc [test.skip_scan, test.no_skip_scan] +EXPLAIN SELECT /*+ SKIP_SCAN(t) */ e FROM t WHERE a = 5 AND d <= 3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 250 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ref PRIMARY PRIMARY 4 const 250 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select /*+ SKIP_SCAN(`t`@`select#1`) */ `test`.`t`.`e` AS `e` from `test`.`t` where ((`test`.`t`.`a` = 5) and (`test`.`t`.`d` <= 3)) +FLUSH STATUS; +SELECT /*+ SKIP_SCAN(t) */ e FROM t WHERE a = 5 AND d <= 3; +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 3 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 251 +include/diff_tables.inc [test.hint_skip_scan, test.no_skip_scan] +set optimizer_switch = 'skip_scan=on'; +EXPLAIN SELECT b, c, d FROM t WHERE a = 5 AND c > 10 AND d < 3 ORDER BY d, c, e; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 250 11.11 Parallel execute (1 workers) +2 SIMPLE t NULL ref PRIMARY PRIMARY 4 const 250 11.11 Using where; Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`b` AS `b`,`test`.`t`.`c` AS `c`,`test`.`t`.`d` AS `d` from `test`.`t` where ((`test`.`t`.`a` = 5) and (`test`.`t`.`c` > 10) and (`test`.`t`.`d` < 3)) order by `test`.`t`.`d`,`test`.`t`.`c`,`test`.`t`.`e` +FLUSH STATUS; +SELECT b, c, d FROM t WHERE a = 5 AND c > 10 AND d < 3 ORDER BY d, c, e; +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 3 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 251 +set optimizer_switch = 'skip_scan=off'; +EXPLAIN SELECT b, c, d FROM t WHERE a = 5 AND c > 10 AND d < 3 ORDER BY d, c, e; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 250 11.11 Parallel execute (1 workers) +2 SIMPLE t NULL ref PRIMARY PRIMARY 4 const 250 11.11 Using where; Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`b` AS `b`,`test`.`t`.`c` AS `c`,`test`.`t`.`d` AS `d` from `test`.`t` where ((`test`.`t`.`a` = 5) and (`test`.`t`.`c` > 10) and (`test`.`t`.`d` < 3)) order by `test`.`t`.`d`,`test`.`t`.`c`,`test`.`t`.`e` +FLUSH STATUS; +SELECT b, c, d FROM t WHERE a = 5 AND c > 10 AND d < 3 ORDER BY d, c, e; +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 3 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 251 +include/diff_tables.inc [test.skip_scan, test.no_skip_scan] +EXPLAIN SELECT /*+ SKIP_SCAN(t) */ b, c, d FROM t WHERE a = 5 AND c > 10 AND d < 3 ORDER BY d, c, e; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 250 11.11 Parallel execute (1 workers) +2 SIMPLE t NULL ref PRIMARY PRIMARY 4 const 250 11.11 Using where; Using filesort +Warnings: +Note 1003 /* select#1 */ select /*+ SKIP_SCAN(`t`@`select#1`) */ `test`.`t`.`b` AS `b`,`test`.`t`.`c` AS `c`,`test`.`t`.`d` AS `d` from `test`.`t` where ((`test`.`t`.`a` = 5) and (`test`.`t`.`c` > 10) and (`test`.`t`.`d` < 3)) order by `test`.`t`.`d`,`test`.`t`.`c`,`test`.`t`.`e` +FLUSH STATUS; +SELECT /*+ SKIP_SCAN(t) */ b, c, d FROM t WHERE a = 5 AND c > 10 AND d < 3 ORDER BY d, c, e; +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 3 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 251 +include/diff_tables.inc [test.hint_skip_scan, test.no_skip_scan] +set optimizer_switch = 'skip_scan=on'; +EXPLAIN SELECT count(a), count(b), count(c) FROM t WHERE a = 5 AND c > 10 AND d < 3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range PRIMARY,b PRIMARY 12 NULL 83 33.33 Using where; Using index for skip scan +Warnings: +Note 1003 /* select#1 */ select count(`test`.`t`.`a`) AS `count(a)`,count(`test`.`t`.`b`) AS `count(b)`,count(`test`.`t`.`c`) AS `count(c)` from `test`.`t` where ((`test`.`t`.`a` = 5) and (`test`.`t`.`c` > 10) and (`test`.`t`.`d` < 3)) +FLUSH STATUS; +SELECT count(a), count(b), count(c) FROM t WHERE a = 5 AND c > 10 AND d < 3; +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 11 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +set optimizer_switch = 'skip_scan=off'; +EXPLAIN SELECT count(a), count(b), count(c) FROM t WHERE a = 5 AND c > 10 AND d < 3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 250 11.11 Parallel execute (1 workers) +2 SIMPLE t NULL ref PRIMARY PRIMARY 4 const 250 11.11 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select count(`test`.`t`.`a`) AS `count(a)`,count(`test`.`t`.`b`) AS `count(b)`,count(`test`.`t`.`c`) AS `count(c)` from `test`.`t` where ((`test`.`t`.`a` = 5) and (`test`.`t`.`c` > 10) and (`test`.`t`.`d` < 3)) +FLUSH STATUS; +SELECT count(a), count(b), count(c) FROM t WHERE a = 5 AND c > 10 AND d < 3; +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 3 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 251 +include/diff_tables.inc [test.skip_scan, test.no_skip_scan] +EXPLAIN SELECT /*+ SKIP_SCAN(t) */ count(a), count(b), count(c) FROM t WHERE a = 5 AND c > 10 AND d < 3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range PRIMARY,b PRIMARY 12 NULL 83 33.33 Using where; Using index for skip scan +Warnings: +Note 1003 /* select#1 */ select /*+ SKIP_SCAN(`t`@`select#1`) */ count(`test`.`t`.`a`) AS `count(a)`,count(`test`.`t`.`b`) AS `count(b)`,count(`test`.`t`.`c`) AS `count(c)` from `test`.`t` where ((`test`.`t`.`a` = 5) and (`test`.`t`.`c` > 10) and (`test`.`t`.`d` < 3)) +FLUSH STATUS; +SELECT /*+ SKIP_SCAN(t) */ count(a), count(b), count(c) FROM t WHERE a = 5 AND c > 10 AND d < 3; +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 11 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.hint_skip_scan, test.no_skip_scan] +set optimizer_switch = 'skip_scan=on'; +EXPLAIN SELECT min(a), max(b), min(c) FROM t WHERE a = 5 AND c > 10 AND d < 3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range PRIMARY,b PRIMARY 12 NULL 83 33.33 Using where; Using index for skip scan +Warnings: +Note 1003 /* select#1 */ select min(`test`.`t`.`a`) AS `min(a)`,max(`test`.`t`.`b`) AS `max(b)`,min(`test`.`t`.`c`) AS `min(c)` from `test`.`t` where ((`test`.`t`.`a` = 5) and (`test`.`t`.`c` > 10) and (`test`.`t`.`d` < 3)) +FLUSH STATUS; +SELECT min(a), max(b), min(c) FROM t WHERE a = 5 AND c > 10 AND d < 3; +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 11 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +set optimizer_switch = 'skip_scan=off'; +EXPLAIN SELECT min(a), max(b), min(c) FROM t WHERE a = 5 AND c > 10 AND d < 3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 250 11.11 Parallel execute (1 workers) +2 SIMPLE t NULL ref PRIMARY PRIMARY 4 const 250 11.11 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select min(`test`.`t`.`a`) AS `min(a)`,max(`test`.`t`.`b`) AS `max(b)`,min(`test`.`t`.`c`) AS `min(c)` from `test`.`t` where ((`test`.`t`.`a` = 5) and (`test`.`t`.`c` > 10) and (`test`.`t`.`d` < 3)) +FLUSH STATUS; +SELECT min(a), max(b), min(c) FROM t WHERE a = 5 AND c > 10 AND d < 3; +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 3 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 251 +include/diff_tables.inc [test.skip_scan, test.no_skip_scan] +EXPLAIN SELECT /*+ SKIP_SCAN(t) */ min(a), max(b), min(c) FROM t WHERE a = 5 AND c > 10 AND d < 3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range PRIMARY,b PRIMARY 12 NULL 83 33.33 Using where; Using index for skip scan +Warnings: +Note 1003 /* select#1 */ select /*+ SKIP_SCAN(`t`@`select#1`) */ min(`test`.`t`.`a`) AS `min(a)`,max(`test`.`t`.`b`) AS `max(b)`,min(`test`.`t`.`c`) AS `min(c)` from `test`.`t` where ((`test`.`t`.`a` = 5) and (`test`.`t`.`c` > 10) and (`test`.`t`.`d` < 3)) +FLUSH STATUS; +SELECT /*+ SKIP_SCAN(t) */ min(a), max(b), min(c) FROM t WHERE a = 5 AND c > 10 AND d < 3; +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 11 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.hint_skip_scan, test.no_skip_scan] +set optimizer_switch = 'skip_scan=on'; +EXPLAIN SELECT sum(a), sum(b), sum(c) FROM t WHERE a = 5 AND c > 10 AND d < 3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range PRIMARY,b PRIMARY 12 NULL 83 33.33 Using where; Using index for skip scan +Warnings: +Note 1003 /* select#1 */ select sum(`test`.`t`.`a`) AS `sum(a)`,sum(`test`.`t`.`b`) AS `sum(b)`,sum(`test`.`t`.`c`) AS `sum(c)` from `test`.`t` where ((`test`.`t`.`a` = 5) and (`test`.`t`.`c` > 10) and (`test`.`t`.`d` < 3)) +FLUSH STATUS; +SELECT sum(a), sum(b), sum(c) FROM t WHERE a = 5 AND c > 10 AND d < 3; +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 11 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +set optimizer_switch = 'skip_scan=off'; +EXPLAIN SELECT sum(a), sum(b), sum(c) FROM t WHERE a = 5 AND c > 10 AND d < 3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 250 11.11 Parallel execute (1 workers) +2 SIMPLE t NULL ref PRIMARY PRIMARY 4 const 250 11.11 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select sum(`test`.`t`.`a`) AS `sum(a)`,sum(`test`.`t`.`b`) AS `sum(b)`,sum(`test`.`t`.`c`) AS `sum(c)` from `test`.`t` where ((`test`.`t`.`a` = 5) and (`test`.`t`.`c` > 10) and (`test`.`t`.`d` < 3)) +FLUSH STATUS; +SELECT sum(a), sum(b), sum(c) FROM t WHERE a = 5 AND c > 10 AND d < 3; +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 3 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 251 +include/diff_tables.inc [test.skip_scan, test.no_skip_scan] +EXPLAIN SELECT /*+ SKIP_SCAN(t) */ sum(a), avg(b), sum(c) FROM t WHERE a = 5 AND c > 10 AND d < 3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range PRIMARY,b PRIMARY 12 NULL 83 33.33 Using where; Using index for skip scan +Warnings: +Note 1003 /* select#1 */ select /*+ SKIP_SCAN(`t`@`select#1`) */ sum(`test`.`t`.`a`) AS `sum(a)`,avg(`test`.`t`.`b`) AS `avg(b)`,sum(`test`.`t`.`c`) AS `sum(c)` from `test`.`t` where ((`test`.`t`.`a` = 5) and (`test`.`t`.`c` > 10) and (`test`.`t`.`d` < 3)) +FLUSH STATUS; +SELECT /*+ SKIP_SCAN(t) */ sum(a), avg(b), sum(c) FROM t WHERE a = 5 AND c > 10 AND d < 3; +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 11 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.hint_skip_scan, test.no_skip_scan] +set optimizer_switch = 'skip_scan=on'; +EXPLAIN SELECT count(*) FROM t WHERE d < 2;; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range PRIMARY,b b 8 NULL 833 100.00 Using where; Using index for skip scan +Warnings: +Note 1003 /* select#1 */ select count(0) AS `count(*)` from `test`.`t` where (`test`.`t`.`d` < 2) +FLUSH STATUS; +SELECT count(*) FROM t WHERE d < 2;; +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 1 +Handler_read_key 11 +Handler_read_last 0 +Handler_read_next 250 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +set optimizer_switch = 'skip_scan=off'; +EXPLAIN SELECT count(*) FROM t WHERE d < 2;; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2500 33.33 Parallel execute (4 workers) +2 SIMPLE t NULL index NULL b 8 NULL 2500 33.33 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select count(0) AS `count(*)` from `test`.`t` where (`test`.`t`.`d` < 2) +FLUSH STATUS; +SELECT count(*) FROM t WHERE d < 2;; +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 1 +Handler_read_key 1 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 2504 +include/diff_tables.inc [test.skip_scan, test.no_skip_scan] +EXPLAIN SELECT /*+ SKIP_SCAN(t) */ count(*) FROM t WHERE d < 2;; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range PRIMARY,b b 8 NULL 833 100.00 Using where; Using index for skip scan +Warnings: +Note 1003 /* select#1 */ select /*+ SKIP_SCAN(`t`@`select#1`) */ count(0) AS `count(*)` from `test`.`t` where (`test`.`t`.`d` < 2) +FLUSH STATUS; +SELECT /*+ SKIP_SCAN(t) */ count(*) FROM t WHERE d < 2;; +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 1 +Handler_read_key 11 +Handler_read_last 0 +Handler_read_next 250 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.hint_skip_scan, test.no_skip_scan] +Testing DESC index with skip scan. +ALTER TABLE t DROP PRIMARY KEY; +ALTER TABLE t DROP KEY b; +ALTER TABLE t ADD PRIMARY KEY(a DESC, b, c DESC, d); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +set optimizer_switch = 'skip_scan=on'; +EXPLAIN SELECT b, c, d FROM t WHERE a = 5 AND c > 3 AND d < 3;; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range PRIMARY PRIMARY 12 NULL 83 33.33 Using where; Using index for skip scan +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`b` AS `b`,`test`.`t`.`c` AS `c`,`test`.`t`.`d` AS `d` from `test`.`t` where ((`test`.`t`.`a` = 5) and (`test`.`t`.`c` > 3) and (`test`.`t`.`d` < 3)) +FLUSH STATUS; +SELECT b, c, d FROM t WHERE a = 5 AND c > 3 AND d < 3;; +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 11 +Handler_read_last 0 +Handler_read_next 100 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +set optimizer_switch = 'skip_scan=off'; +EXPLAIN SELECT b, c, d FROM t WHERE a = 5 AND c > 3 AND d < 3;; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 250 11.11 Parallel execute (1 workers) +2 SIMPLE t NULL ref PRIMARY PRIMARY 4 const 250 11.11 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`b` AS `b`,`test`.`t`.`c` AS `c`,`test`.`t`.`d` AS `d` from `test`.`t` where ((`test`.`t`.`a` = 5) and (`test`.`t`.`c` > 3) and (`test`.`t`.`d` < 3)) +FLUSH STATUS; +SELECT b, c, d FROM t WHERE a = 5 AND c > 3 AND d < 3;; +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 3 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 251 +include/diff_tables.inc [test.skip_scan, test.no_skip_scan] +EXPLAIN SELECT /*+ SKIP_SCAN(t) */ b, c, d FROM t WHERE a = 5 AND c > 3 AND d < 3;; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range PRIMARY PRIMARY 12 NULL 83 33.33 Using where; Using index for skip scan +Warnings: +Note 1003 /* select#1 */ select /*+ SKIP_SCAN(`t`@`select#1`) */ `test`.`t`.`b` AS `b`,`test`.`t`.`c` AS `c`,`test`.`t`.`d` AS `d` from `test`.`t` where ((`test`.`t`.`a` = 5) and (`test`.`t`.`c` > 3) and (`test`.`t`.`d` < 3)) +FLUSH STATUS; +SELECT /*+ SKIP_SCAN(t) */ b, c, d FROM t WHERE a = 5 AND c > 3 AND d < 3;; +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 11 +Handler_read_last 0 +Handler_read_next 100 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.hint_skip_scan, test.no_skip_scan] +set optimizer_switch = 'skip_scan=on'; +EXPLAIN SELECT b, c, d FROM t WHERE a = 5 AND c < 3 AND d < 3;; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range PRIMARY PRIMARY 12 NULL 83 33.33 Using where; Using index for skip scan +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`b` AS `b`,`test`.`t`.`c` AS `c`,`test`.`t`.`d` AS `d` from `test`.`t` where ((`test`.`t`.`a` = 5) and (`test`.`t`.`c` < 3) and (`test`.`t`.`d` < 3)) +FLUSH STATUS; +SELECT b, c, d FROM t WHERE a = 5 AND c < 3 AND d < 3;; +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 11 +Handler_read_last 0 +Handler_read_next 100 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +set optimizer_switch = 'skip_scan=off'; +EXPLAIN SELECT b, c, d FROM t WHERE a = 5 AND c < 3 AND d < 3;; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 250 11.11 Parallel execute (1 workers) +2 SIMPLE t NULL ref PRIMARY PRIMARY 4 const 250 11.11 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`b` AS `b`,`test`.`t`.`c` AS `c`,`test`.`t`.`d` AS `d` from `test`.`t` where ((`test`.`t`.`a` = 5) and (`test`.`t`.`c` < 3) and (`test`.`t`.`d` < 3)) +FLUSH STATUS; +SELECT b, c, d FROM t WHERE a = 5 AND c < 3 AND d < 3;; +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 3 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 251 +include/diff_tables.inc [test.skip_scan, test.no_skip_scan] +EXPLAIN SELECT /*+ SKIP_SCAN(t) */ b, c, d FROM t WHERE a = 5 AND c < 3 AND d < 3;; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range PRIMARY PRIMARY 12 NULL 83 33.33 Using where; Using index for skip scan +Warnings: +Note 1003 /* select#1 */ select /*+ SKIP_SCAN(`t`@`select#1`) */ `test`.`t`.`b` AS `b`,`test`.`t`.`c` AS `c`,`test`.`t`.`d` AS `d` from `test`.`t` where ((`test`.`t`.`a` = 5) and (`test`.`t`.`c` < 3) and (`test`.`t`.`d` < 3)) +FLUSH STATUS; +SELECT /*+ SKIP_SCAN(t) */ b, c, d FROM t WHERE a = 5 AND c < 3 AND d < 3;; +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 11 +Handler_read_last 0 +Handler_read_next 100 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.hint_skip_scan, test.no_skip_scan] +set optimizer_switch = 'skip_scan=on'; +EXPLAIN SELECT b, c, d FROM t WHERE a = 5 AND c = 3 AND d < 3;; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range PRIMARY PRIMARY 12 NULL 50 33.33 Using where; Using index for skip scan +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`b` AS `b`,`test`.`t`.`c` AS `c`,`test`.`t`.`d` AS `d` from `test`.`t` where ((`test`.`t`.`c` = 3) and (`test`.`t`.`a` = 5) and (`test`.`t`.`d` < 3)) +FLUSH STATUS; +SELECT b, c, d FROM t WHERE a = 5 AND c = 3 AND d < 3;; +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 11 +Handler_read_last 0 +Handler_read_next 50 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +set optimizer_switch = 'skip_scan=off'; +EXPLAIN SELECT b, c, d FROM t WHERE a = 5 AND c = 3 AND d < 3;; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 250 3.33 Parallel execute (1 workers) +2 SIMPLE t NULL ref PRIMARY PRIMARY 4 const 250 3.33 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`b` AS `b`,`test`.`t`.`c` AS `c`,`test`.`t`.`d` AS `d` from `test`.`t` where ((`test`.`t`.`c` = 3) and (`test`.`t`.`a` = 5) and (`test`.`t`.`d` < 3)) +FLUSH STATUS; +SELECT b, c, d FROM t WHERE a = 5 AND c = 3 AND d < 3;; +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 3 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 251 +include/diff_tables.inc [test.skip_scan, test.no_skip_scan] +EXPLAIN SELECT /*+ SKIP_SCAN(t) */ b, c, d FROM t WHERE a = 5 AND c = 3 AND d < 3;; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range PRIMARY PRIMARY 12 NULL 50 33.33 Using where; Using index for skip scan +Warnings: +Note 1003 /* select#1 */ select /*+ SKIP_SCAN(`t`@`select#1`) */ `test`.`t`.`b` AS `b`,`test`.`t`.`c` AS `c`,`test`.`t`.`d` AS `d` from `test`.`t` where ((`test`.`t`.`c` = 3) and (`test`.`t`.`a` = 5) and (`test`.`t`.`d` < 3)) +FLUSH STATUS; +SELECT /*+ SKIP_SCAN(t) */ b, c, d FROM t WHERE a = 5 AND c = 3 AND d < 3;; +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 11 +Handler_read_last 0 +Handler_read_next 50 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.hint_skip_scan, test.no_skip_scan] +set optimizer_switch = 'skip_scan=on'; +EXPLAIN SELECT b, c, d FROM t WHERE a = 5 AND c BETWEEN 3 AND 5 AND d < 3;; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range PRIMARY PRIMARY 12 NULL 50 33.33 Using where; Using index for skip scan +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`b` AS `b`,`test`.`t`.`c` AS `c`,`test`.`t`.`d` AS `d` from `test`.`t` where ((`test`.`t`.`a` = 5) and (`test`.`t`.`c` between 3 and 5) and (`test`.`t`.`d` < 3)) +FLUSH STATUS; +SELECT b, c, d FROM t WHERE a = 5 AND c BETWEEN 3 AND 5 AND d < 3;; +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 11 +Handler_read_last 0 +Handler_read_next 150 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +set optimizer_switch = 'skip_scan=off'; +EXPLAIN SELECT b, c, d FROM t WHERE a = 5 AND c BETWEEN 3 AND 5 AND d < 3;; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 250 3.70 Parallel execute (1 workers) +2 SIMPLE t NULL ref PRIMARY PRIMARY 4 const 250 3.70 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`b` AS `b`,`test`.`t`.`c` AS `c`,`test`.`t`.`d` AS `d` from `test`.`t` where ((`test`.`t`.`a` = 5) and (`test`.`t`.`c` between 3 and 5) and (`test`.`t`.`d` < 3)) +FLUSH STATUS; +SELECT b, c, d FROM t WHERE a = 5 AND c BETWEEN 3 AND 5 AND d < 3;; +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 3 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 251 +include/diff_tables.inc [test.skip_scan, test.no_skip_scan] +EXPLAIN SELECT /*+ SKIP_SCAN(t) */ b, c, d FROM t WHERE a = 5 AND c BETWEEN 3 AND 5 AND d < 3;; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range PRIMARY PRIMARY 12 NULL 50 33.33 Using where; Using index for skip scan +Warnings: +Note 1003 /* select#1 */ select /*+ SKIP_SCAN(`t`@`select#1`) */ `test`.`t`.`b` AS `b`,`test`.`t`.`c` AS `c`,`test`.`t`.`d` AS `d` from `test`.`t` where ((`test`.`t`.`a` = 5) and (`test`.`t`.`c` between 3 and 5) and (`test`.`t`.`d` < 3)) +FLUSH STATUS; +SELECT /*+ SKIP_SCAN(t) */ b, c, d FROM t WHERE a = 5 AND c BETWEEN 3 AND 5 AND d < 3;; +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 11 +Handler_read_last 0 +Handler_read_next 150 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.hint_skip_scan, test.no_skip_scan] +set optimizer_switch = 'skip_scan=on'; +EXPLAIN SELECT b, c, d FROM t WHERE c BETWEEN 3 AND 5 AND d < 3;; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range PRIMARY PRIMARY 12 NULL 500 33.33 Using where; Using index for skip scan +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`b` AS `b`,`test`.`t`.`c` AS `c`,`test`.`t`.`d` AS `d` from `test`.`t` where ((`test`.`t`.`c` between 3 and 5) and (`test`.`t`.`d` < 3)) +FLUSH STATUS; +SELECT b, c, d FROM t WHERE c BETWEEN 3 AND 5 AND d < 3;; +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 1 +Handler_read_key 101 +Handler_read_last 0 +Handler_read_next 1500 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +set optimizer_switch = 'skip_scan=off'; +EXPLAIN SELECT b, c, d FROM t WHERE c BETWEEN 3 AND 5 AND d < 3;; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2500 3.70 Parallel execute (4 workers) +2 SIMPLE t NULL index NULL PRIMARY 16 NULL 2500 3.70 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`b` AS `b`,`test`.`t`.`c` AS `c`,`test`.`t`.`d` AS `d` from `test`.`t` where ((`test`.`t`.`c` between 3 and 5) and (`test`.`t`.`d` < 3)) +FLUSH STATUS; +SELECT b, c, d FROM t WHERE c BETWEEN 3 AND 5 AND d < 3;; +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 1 +Handler_read_key 1 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 2504 +include/diff_tables.inc [test.skip_scan, test.no_skip_scan] +EXPLAIN SELECT /*+ SKIP_SCAN(t) */ b, c, d FROM t WHERE c BETWEEN 3 AND 5 AND d < 3;; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range PRIMARY PRIMARY 12 NULL 500 33.33 Using where; Using index for skip scan +Warnings: +Note 1003 /* select#1 */ select /*+ SKIP_SCAN(`t`@`select#1`) */ `test`.`t`.`b` AS `b`,`test`.`t`.`c` AS `c`,`test`.`t`.`d` AS `d` from `test`.`t` where ((`test`.`t`.`c` between 3 and 5) and (`test`.`t`.`d` < 3)) +FLUSH STATUS; +SELECT /*+ SKIP_SCAN(t) */ b, c, d FROM t WHERE c BETWEEN 3 AND 5 AND d < 3;; +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 1 +Handler_read_key 101 +Handler_read_last 0 +Handler_read_next 1500 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.hint_skip_scan, test.no_skip_scan] +set optimizer_switch = 'skip_scan=on'; +EXPLAIN SELECT b, c, d FROM t WHERE d < 3;; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2500 33.33 Parallel execute (4 workers) +2 SIMPLE t NULL index PRIMARY PRIMARY 16 NULL 2500 33.33 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`b` AS `b`,`test`.`t`.`c` AS `c`,`test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` < 3) +FLUSH STATUS; +SELECT b, c, d FROM t WHERE d < 3;; +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 1 +Handler_read_key 1 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 2504 +set optimizer_switch = 'skip_scan=off'; +EXPLAIN SELECT b, c, d FROM t WHERE d < 3;; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2500 33.33 Parallel execute (4 workers) +2 SIMPLE t NULL index NULL PRIMARY 16 NULL 2500 33.33 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`b` AS `b`,`test`.`t`.`c` AS `c`,`test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` < 3) +FLUSH STATUS; +SELECT b, c, d FROM t WHERE d < 3;; +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 1 +Handler_read_key 1 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 2504 +include/diff_tables.inc [test.skip_scan, test.no_skip_scan] +EXPLAIN SELECT /*+ SKIP_SCAN(t) */ b, c, d FROM t WHERE d < 3;; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range PRIMARY PRIMARY 16 NULL 833 100.00 Using where; Using index for skip scan +Warnings: +Note 1003 /* select#1 */ select /*+ SKIP_SCAN(`t`@`select#1`) */ `test`.`t`.`b` AS `b`,`test`.`t`.`c` AS `c`,`test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` < 3) +FLUSH STATUS; +SELECT /*+ SKIP_SCAN(t) */ b, c, d FROM t WHERE d < 3;; +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 1 +Handler_read_key 501 +Handler_read_last 0 +Handler_read_next 500 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.hint_skip_scan, test.no_skip_scan] +set optimizer_switch = 'skip_scan=on'; +EXPLAIN SELECT a, b, c, d FROM t WHERE a IN (1, 3, 5) AND d >= 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 750 33.33 Parallel execute (4 workers) +2 SIMPLE t NULL range PRIMARY PRIMARY 4 NULL 750 33.33 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,`test`.`t`.`c` AS `c`,`test`.`t`.`d` AS `d` from `test`.`t` where ((`test`.`t`.`a` in (1,3,5)) and (`test`.`t`.`d` >= 5)) +FLUSH STATUS; +SELECT a, b, c, d FROM t WHERE a IN (1, 3, 5) AND d >= 5; +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 7 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 754 +set optimizer_switch = 'skip_scan=off'; +EXPLAIN SELECT a, b, c, d FROM t WHERE a IN (1, 3, 5) AND d >= 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 750 33.33 Parallel execute (4 workers) +2 SIMPLE t NULL range PRIMARY PRIMARY 4 NULL 750 33.33 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,`test`.`t`.`c` AS `c`,`test`.`t`.`d` AS `d` from `test`.`t` where ((`test`.`t`.`a` in (1,3,5)) and (`test`.`t`.`d` >= 5)) +FLUSH STATUS; +SELECT a, b, c, d FROM t WHERE a IN (1, 3, 5) AND d >= 5; +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 7 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 754 +include/diff_tables.inc [test.skip_scan, test.no_skip_scan] +EXPLAIN SELECT /*+ SKIP_SCAN(t) */ a, b, c, d FROM t WHERE a IN (1, 3, 5) AND d >= 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range PRIMARY PRIMARY 16 NULL 249 100.00 Using where; Using index for skip scan +Warnings: +Note 1003 /* select#1 */ select /*+ SKIP_SCAN(`t`@`select#1`) */ `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,`test`.`t`.`c` AS `c`,`test`.`t`.`d` AS `d` from `test`.`t` where ((`test`.`t`.`a` in (1,3,5)) and (`test`.`t`.`d` >= 5)) +FLUSH STATUS; +SELECT /*+ SKIP_SCAN(t) */ a, b, c, d FROM t WHERE a IN (1, 3, 5) AND d >= 5; +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 153 +Handler_read_last 0 +Handler_read_next 450 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.hint_skip_scan, test.no_skip_scan] +set optimizer_switch = 'skip_scan=on'; +EXPLAIN SELECT a, b, c, d FROM t WHERE a IN (1, 5, 3) AND b IN (1, 2) AND d >= 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 300 33.33 Parallel execute (4 workers) +2 SIMPLE t NULL range PRIMARY PRIMARY 8 NULL 300 33.33 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,`test`.`t`.`c` AS `c`,`test`.`t`.`d` AS `d` from `test`.`t` where ((`test`.`t`.`a` in (1,5,3)) and (`test`.`t`.`b` in (1,2)) and (`test`.`t`.`d` >= 5)) +FLUSH STATUS; +SELECT a, b, c, d FROM t WHERE a IN (1, 5, 3) AND b IN (1, 2) AND d >= 5; +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 12 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 304 +set optimizer_switch = 'skip_scan=off'; +EXPLAIN SELECT a, b, c, d FROM t WHERE a IN (1, 5, 3) AND b IN (1, 2) AND d >= 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 300 33.33 Parallel execute (4 workers) +2 SIMPLE t NULL range PRIMARY PRIMARY 8 NULL 300 33.33 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,`test`.`t`.`c` AS `c`,`test`.`t`.`d` AS `d` from `test`.`t` where ((`test`.`t`.`a` in (1,5,3)) and (`test`.`t`.`b` in (1,2)) and (`test`.`t`.`d` >= 5)) +FLUSH STATUS; +SELECT a, b, c, d FROM t WHERE a IN (1, 5, 3) AND b IN (1, 2) AND d >= 5; +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 12 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 304 +include/diff_tables.inc [test.skip_scan, test.no_skip_scan] +EXPLAIN SELECT /*+ SKIP_SCAN(t) */ a, b, c, d FROM t WHERE a IN (1, 5, 3) AND b in (1, 2) AND d >= 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range PRIMARY PRIMARY 16 NULL 99 100.00 Using where; Using index for skip scan +Warnings: +Note 1003 /* select#1 */ select /*+ SKIP_SCAN(`t`@`select#1`) */ `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,`test`.`t`.`c` AS `c`,`test`.`t`.`d` AS `d` from `test`.`t` where ((`test`.`t`.`a` in (1,5,3)) and (`test`.`t`.`b` in (1,2)) and (`test`.`t`.`d` >= 5)) +FLUSH STATUS; +SELECT /*+ SKIP_SCAN(t) */ a, b, c, d FROM t WHERE a IN (1, 5, 3) AND b in (1, 2) AND d >= 5; +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 66 +Handler_read_last 0 +Handler_read_next 180 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.hint_skip_scan, test.no_skip_scan] +set optimizer_switch = default; +DROP TABLE t; +Testing DESC index with skip scan and NULL range. +CREATE TABLE t1 (a INT, b INT, c INT, d INT, e INT); +INSERT INTO t1 VALUES +(NULL, 1, 1, 3, 4), (NULL, 2, 1, 4, 5), +(1, 2, 1, 3, 4), (2, 2, 1, 4, 5), +(5, 2, 3, 3, 4), (2, 2, 1, 4, 11), +(8, 2, 1, 3, 4), (7, 2, 1, 4, 9); +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +ALTER TABLE t1 ADD KEY k1(a DESC, b, c DESC, d, e DESC); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +set optimizer_switch = 'skip_scan=on'; +EXPLAIN SELECT a, b, c, d FROM t1 WHERE (a IN (1, 5) or a IS NULL) AND b in (1, 2) AND d BETWEEN 2 AND 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 34 11.11 Parallel execute (4 workers) +2 SIMPLE t1 NULL range k1 k1 10 NULL 34 11.11 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c`,`test`.`t1`.`d` AS `d` from `test`.`t1` where (((`test`.`t1`.`a` in (1,5)) or (`test`.`t1`.`a` is null)) and (`test`.`t1`.`b` in (1,2)) and (`test`.`t1`.`d` between 2 and 5)) +FLUSH STATUS; +SELECT a, b, c, d FROM t1 WHERE (a IN (1, 5) or a IS NULL) AND b in (1, 2) AND d BETWEEN 2 AND 5; +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 13 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 36 +set optimizer_switch = 'skip_scan=off'; +EXPLAIN SELECT a, b, c, d FROM t1 WHERE (a IN (1, 5) or a IS NULL) AND b in (1, 2) AND d BETWEEN 2 AND 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 34 11.11 Parallel execute (4 workers) +2 SIMPLE t1 NULL range k1 k1 10 NULL 34 11.11 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c`,`test`.`t1`.`d` AS `d` from `test`.`t1` where (((`test`.`t1`.`a` in (1,5)) or (`test`.`t1`.`a` is null)) and (`test`.`t1`.`b` in (1,2)) and (`test`.`t1`.`d` between 2 and 5)) +FLUSH STATUS; +SELECT a, b, c, d FROM t1 WHERE (a IN (1, 5) or a IS NULL) AND b in (1, 2) AND d BETWEEN 2 AND 5; +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 13 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 36 +include/diff_tables.inc [test.skip_scan, test.no_skip_scan] +EXPLAIN SELECT /*+ SKIP_SCAN(t1) */ a, b, c, d FROM t1 WHERE (a IN (1, 5) or a IS NULL) AND b in (1, 2) AND d BETWEEN 2 AND 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range k1 k1 20 NULL 34 100.00 Using where; Using index for skip scan +Warnings: +Note 1003 /* select#1 */ select /*+ SKIP_SCAN(`t1`@`select#1`) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c`,`test`.`t1`.`d` AS `d` from `test`.`t1` where (((`test`.`t1`.`a` in (1,5)) or (`test`.`t1`.`a` is null)) and (`test`.`t1`.`b` in (1,2)) and (`test`.`t1`.`d` between 2 and 5)) +FLUSH STATUS; +SELECT /*+ SKIP_SCAN(t1) */ a, b, c, d FROM t1 WHERE (a IN (1, 5) or a IS NULL) AND b in (1, 2) AND d BETWEEN 2 AND 5; +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 14 +Handler_read_last 0 +Handler_read_next 32 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.hint_skip_scan, test.no_skip_scan] +ALTER TABLE t1 DROP KEY k1; +ALTER TABLE t1 ADD KEY k1(a, b DESC, c, d DESC, e); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +set optimizer_switch = 'skip_scan=on'; +EXPLAIN SELECT a, b, c, d FROM t1 WHERE (a IN (1, 5) or a IS NULL) AND b in (1, 2) AND d BETWEEN 2 AND 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 34 11.11 Parallel execute (4 workers) +2 SIMPLE t1 NULL range k1 k1 10 NULL 34 11.11 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c`,`test`.`t1`.`d` AS `d` from `test`.`t1` where (((`test`.`t1`.`a` in (1,5)) or (`test`.`t1`.`a` is null)) and (`test`.`t1`.`b` in (1,2)) and (`test`.`t1`.`d` between 2 and 5)) +FLUSH STATUS; +SELECT a, b, c, d FROM t1 WHERE (a IN (1, 5) or a IS NULL) AND b in (1, 2) AND d BETWEEN 2 AND 5; +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 12 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 36 +set optimizer_switch = 'skip_scan=off'; +EXPLAIN SELECT a, b, c, d FROM t1 WHERE (a IN (1, 5) or a IS NULL) AND b in (1, 2) AND d BETWEEN 2 AND 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 34 11.11 Parallel execute (4 workers) +2 SIMPLE t1 NULL range k1 k1 10 NULL 34 11.11 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c`,`test`.`t1`.`d` AS `d` from `test`.`t1` where (((`test`.`t1`.`a` in (1,5)) or (`test`.`t1`.`a` is null)) and (`test`.`t1`.`b` in (1,2)) and (`test`.`t1`.`d` between 2 and 5)) +FLUSH STATUS; +SELECT a, b, c, d FROM t1 WHERE (a IN (1, 5) or a IS NULL) AND b in (1, 2) AND d BETWEEN 2 AND 5; +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 12 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 36 +include/diff_tables.inc [test.skip_scan, test.no_skip_scan] +EXPLAIN SELECT /*+ SKIP_SCAN(t1) */ a, b, c, d FROM t1 WHERE (a IN (1, 5) or a IS NULL) AND b in (1, 2) AND d BETWEEN 2 AND 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range k1 k1 20 NULL 34 100.00 Using where; Using index for skip scan +Warnings: +Note 1003 /* select#1 */ select /*+ SKIP_SCAN(`t1`@`select#1`) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c`,`test`.`t1`.`d` AS `d` from `test`.`t1` where (((`test`.`t1`.`a` in (1,5)) or (`test`.`t1`.`a` is null)) and (`test`.`t1`.`b` in (1,2)) and (`test`.`t1`.`d` between 2 and 5)) +FLUSH STATUS; +SELECT /*+ SKIP_SCAN(t1) */ a, b, c, d FROM t1 WHERE (a IN (1, 5) or a IS NULL) AND b in (1, 2) AND d BETWEEN 2 AND 5; +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 14 +Handler_read_last 0 +Handler_read_next 32 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.hint_skip_scan, test.no_skip_scan] +set optimizer_switch = default; +DROP TABLE t1; +# +# Bug#28089360 WL#11322: SIG11 AT QEP_SHARED_OWNER::JOIN | SQL/SQL_OPT_EXEC_SHARED.H:458 +# +CREATE TABLE t1 (f1 INT(11), f2 VARCHAR(1), KEY k1 (f2, f1)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (-682212662,'c'), (-1974921822,'C'), (1260604936,'9'); +CREATE TABLE t2 (f1 INT(11)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (824388284), (1186821161); +CREATE VIEW v1 AS select f1, f2 from t1; +DELETE FROM t2 WHERE (f1, f1) IN (SELECT f1,f2 FROM v1 WHERE f1 >= 2); +DROP VIEW v1; +DROP TABLE t1, t2; +# +# Bug #29602393 ASSERTION `BITMAP_IS_SET(KEY_INFO->TABLE->READ_SET, +# KEY_INFO->KEY_PART.*FAILED +# +CREATE TABLE t1(f1 INT, f2 VARCHAR(64) NOT NULL, PRIMARY KEY (f1)) +PARTITION BY RANGE(f1) +( +PARTITION p1 VALUES LESS THAN (3), +PARTITION p2 VALUES LESS THAN (maxvalue) +); +INSERT INTO t1 VALUES (1, 'abcde'), (2, 'abcde'), (3, 'abcde'); +CREATE INDEX idx1 ON t1(f2); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT /*+ SKIP_SCAN(t1 idx1) */ count(*) FROM t1 WHERE f1 <= 3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 p1,p2 range PRIMARY,idx1 idx1 262 NULL 1 100.00 Using where; Using index for skip scan +Warnings: +Note 1003 /* select#1 */ select /*+ SKIP_SCAN(`t1`@`select#1` `idx1`) */ count(0) AS `count(*)` from `test`.`t1` where (`test`.`t1`.`f1` <= 3) +SELECT /*+ SKIP_SCAN(t1 idx1) */ count(*) FROM t1 WHERE f1 <= 3; +count(*) +3 +DROP TABLE t1; diff --git a/mysql-test/r/slow_log_extra-big.result-pq b/mysql-test/r/slow_log_extra-big.result-pq new file mode 100644 index 000000000000..ad022c3542ef --- /dev/null +++ b/mysql-test/r/slow_log_extra-big.result-pq @@ -0,0 +1,37 @@ +SET @my_slow_logname = @@global.slow_query_log_file; +SET @my_lqt = @@global.long_query_time; +SET GLOBAL slow_query_log_file= '.../my_extra_big.log'; +SET SESSION long_query_time = 20; +SET GLOBAL long_query_time = 0; +SELECT COUNT(*) FROM big_table_slow; +COUNT(*) +200 +SELECT COUNT(*) FROM big_table_slow; +COUNT(*) +200 +SELECT COUNT(*) FROM big_table_slow WHERE id>100 AND id<200; +COUNT(*) +49 +SELECT * FROM big_table_slow WHERE id=2; +id v t +2 v bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbba +SELECT COUNT(*) FROM big_table_slow WHERE id>100; +COUNT(*) +150 +SELECT COUNT(*) FROM big_table_slow WHERE id<100; +COUNT(*) +49 +# Cleanup +SET GLOBAL long_query_time=@my_lqt; +SET GLOBAL slow_query_log_file = @my_slow_logname; +DROP TABLE big_table_slow; +# +# This is a hack to check the log result. +# We strip off time related fields (non-deterministic) and verify the rest are correct. +# +Rows_sent: 1 Rows_examined: 0 Errno: 0 Killed: 0 Bytes_received: 0 Bytes_sent: 58 Read_first: 0 Read_last: 0 Read_key: 0 Read_next: 0 Read_prev: 0 Read_rnd: 0 Read_rnd_next: 0 Sort_merge_passes: 0 Sort_range_count: 0 Sort_rows: 0 Sort_scan_count: 0 Created_tmp_disk_tables: 0 Created_tmp_tables: 0 +Rows_sent: 1 Rows_examined: 0 Errno: 0 Killed: 0 Bytes_received: 0 Bytes_sent: 58 Read_first: 0 Read_last: 0 Read_key: 0 Read_next: 0 Read_prev: 0 Read_rnd: 0 Read_rnd_next: 0 Sort_merge_passes: 0 Sort_range_count: 0 Sort_rows: 0 Sort_scan_count: 0 Created_tmp_disk_tables: 0 Created_tmp_tables: 0 +Rows_sent: 1 Rows_examined: 49 Errno: 0 Killed: 0 Bytes_received: 0 Bytes_sent: 57 Read_first: 0 Read_last: 0 Read_key: 2 Read_next: 0 Read_prev: 0 Read_rnd: 0 Read_rnd_next: 53 Sort_merge_passes: 0 Sort_range_count: 0 Sort_rows: 0 Sort_scan_count: 0 Created_tmp_disk_tables: 0 Created_tmp_tables: 0 +Rows_sent: 1 Rows_examined: 1 Errno: 0 Killed: 0 Bytes_received: 0 Bytes_sent: 307 Read_first: 0 Read_last: 0 Read_key: 1 Read_next: 0 Read_prev: 0 Read_rnd: 0 Read_rnd_next: 0 Sort_merge_passes: 0 Sort_range_count: 0 Sort_rows: 0 Sort_scan_count: 0 Created_tmp_disk_tables: 0 Created_tmp_tables: 0 +Rows_sent: 1 Rows_examined: 150 Errno: 0 Killed: 0 Bytes_received: 0 Bytes_sent: 58 Read_first: 0 Read_last: 1 Read_key: 2 Read_next: 0 Read_prev: 0 Read_rnd: 0 Read_rnd_next: 154 Sort_merge_passes: 0 Sort_range_count: 0 Sort_rows: 0 Sort_scan_count: 0 Created_tmp_disk_tables: 0 Created_tmp_tables: 0 +Rows_sent: 1 Rows_examined: 49 Errno: 0 Killed: 0 Bytes_received: 0 Bytes_sent: 57 Read_first: 0 Read_last: 0 Read_key: 1 Read_next: 0 Read_prev: 0 Read_rnd: 0 Read_rnd_next: 53 Sort_merge_passes: 0 Sort_range_count: 0 Sort_rows: 0 Sort_scan_count: 0 Created_tmp_disk_tables: 0 Created_tmp_tables: 0 diff --git a/mysql-test/r/sp.result-pq b/mysql-test/r/sp.result-pq new file mode 100644 index 000000000000..58f73bd9fdfe --- /dev/null +++ b/mysql-test/r/sp.result-pq @@ -0,0 +1,8587 @@ +use test; +drop table if exists t1,t2,t3,t4; +drop view if exists v1; +drop procedure if exists p1; +drop procedure if exists p2; +drop function if exists f1; +drop function if exists f2; +create table t1 ( +id char(16) not null default '', +data int not null +) engine=myisam; +create table t2 ( +s char(16), +i int, +d double +) engine=myisam; +drop procedure if exists foo42; +create procedure foo42() +insert into test.t1 values ("foo", 42); +call foo42(); +select * from t1; +id data +foo 42 +delete from t1; +drop procedure foo42; +drop procedure if exists bar; +create procedure bar(x char(16), y int) +insert into test.t1 values (x, y); +call bar("bar", 666); +select * from t1; +id data +bar 666 +delete from t1; +drop procedure if exists `empty`| +create procedure `empty`() +begin +end| +call `empty`()| +drop procedure `empty`| +drop procedure if exists scope| +create procedure scope(a int, b float) +begin +declare b int; +declare c float; +begin +declare c int; +end; +end| +drop procedure scope| +drop procedure if exists two| +create procedure two(x1 char(16), x2 char(16), y int) +begin +insert into test.t1 values (x1, y); +insert into test.t1 values (x2, y); +end| +call two("one", "two", 3)| +select * from t1| +id data +one 3 +two 3 +delete from t1| +drop procedure two| +drop procedure if exists locset| +create procedure locset(x char(16), y int) +begin +declare z1, z2 int; +set z1 = y; +set z2 = z1+2; +insert into test.t1 values (x, z2); +end| +call locset("locset", 19)| +select * from t1| +id data +locset 21 +delete from t1| +drop procedure locset| +drop procedure if exists setcontext| +create procedure setcontext() +begin +declare data int default 2; +insert into t1 (id, data) values ("foo", 1); +replace t1 set data = data, id = "bar"; +update t1 set id = "kaka", data = 3 where t1.data = data; +end| +call setcontext()| +select * from t1 order by data| +id data +foo 1 +kaka 3 +delete from t1| +drop procedure setcontext| +create table t3 ( d date, i int, f double, s varchar(32) )| +drop procedure if exists nullset| +create procedure nullset() +begin +declare ld date; +declare li int; +declare lf double; +declare ls varchar(32); +set ld = null, li = null, lf = null, ls = null; +insert into t3 values (ld, li, lf, ls); +insert into t3 (i, f, s) values ((ld is null), 1, "ld is null"), +((li is null), 1, "li is null"), +((li = 0), null, "li = 0"), +((lf is null), 1, "lf is null"), +((lf = 0), null, "lf = 0"), +((ls is null), 1, "ls is null"); +end| +call nullset()| +select * from t3| +d i f s +NULL NULL NULL NULL +NULL 1 1 ld is null +NULL 1 1 li is null +NULL NULL NULL li = 0 +NULL 1 1 lf is null +NULL NULL NULL lf = 0 +NULL 1 1 ls is null +drop table t3| +drop procedure nullset| +drop procedure if exists mixset| +create procedure mixset(x char(16), y int) +begin +declare z int; +set @z = y, z = 666; +insert into test.t1 values (x, z); +end| +call mixset("mixset", 19)| +show variables like 'max_join_size'| +Variable_name Value +max_join_size 18446744073709551615 +select id,data,@z from t1| +id data @z +mixset 666 19 +delete from t1| +drop procedure mixset| +drop procedure if exists zip| +create procedure zip(x char(16), y int) +begin +declare z int; +call zap(y, z); +call bar(x, z); +end| +drop procedure if exists zap| +create procedure zap(x int, out y int) +begin +declare z int; +set z = x+1, y = z; +end| +call zip("zip", 99)| +select * from t1| +id data +zip 100 +delete from t1| +drop procedure zip| +drop procedure bar| +call zap(7, @zap)| +select @zap| +@zap +8 +drop procedure zap| +drop procedure if exists c1| +create procedure c1(x int) +call c2("c", x)| +drop procedure if exists c2| +create procedure c2(s char(16), x int) +call c3(x, s)| +drop procedure if exists c3| +create procedure c3(x int, s char(16)) +call c4("level", x, s)| +drop procedure if exists c4| +create procedure c4(l char(8), x int, s char(16)) +insert into t1 values (concat(l,s), x)| +call c1(42)| +select * from t1| +id data +levelc 42 +delete from t1| +drop procedure c1| +drop procedure c2| +drop procedure c3| +drop procedure c4| +drop procedure if exists iotest| +create procedure iotest(x1 char(16), x2 char(16), y int) +begin +call inc2(x2, y); +insert into test.t1 values (x1, y); +end| +drop procedure if exists inc2| +create procedure inc2(x char(16), y int) +begin +call inc(y); +insert into test.t1 values (x, y); +end| +drop procedure if exists inc| +create procedure inc(inout io int) +set io = io + 1| +call iotest("io1", "io2", 1)| +select * from t1 order by data desc| +id data +io2 2 +io1 1 +delete from t1| +drop procedure iotest| +drop procedure inc2| +drop procedure if exists incr| +create procedure incr(inout x int) +call inc(x)| +select @zap| +@zap +8 +call incr(@zap)| +select @zap| +@zap +9 +drop procedure inc| +drop procedure incr| +drop procedure if exists cbv1| +create procedure cbv1() +begin +declare y int default 3; +call cbv2(y+1, y); +insert into test.t1 values ("cbv1", y); +end| +drop procedure if exists cbv2| +create procedure cbv2(y1 int, inout y2 int) +begin +set y2 = 4711; +insert into test.t1 values ("cbv2", y1); +end| +call cbv1()| +select * from t1 order by data| +id data +cbv2 4 +cbv1 4711 +delete from t1| +drop procedure cbv1| +drop procedure cbv2| +insert into t2 values ("a", 1, 1.1), ("b", 2, 1.2), ("c", 3, 1.3)| +drop procedure if exists sub1| +create procedure sub1(id char(16), x int) +insert into test.t1 values (id, x)| +drop procedure if exists sub2| +create procedure sub2(id char(16)) +begin +declare x int; +set x = (select sum(t.i) from test.t2 t); +insert into test.t1 values (id, x); +end| +drop procedure if exists sub3| +create function sub3(i int) returns int deterministic +return i+1| +call sub1("sub1a", (select 7))| +call sub1("sub1b", (select max(i) from t2))| +call sub1("sub1c", (select i,d from t2 limit 1))| +ERROR 21000: Operand should contain 1 column(s) +call sub1("sub1d", (select 1 from (select 1) a))| +call sub2("sub2")| +select * from t1 order by id| +id data +sub1a 7 +sub1b 3 +sub1d 1 +sub2 6 +select sub3((select max(i) from t2))| +sub3((select max(i) from t2)) +4 +drop procedure sub1| +drop procedure sub2| +drop function sub3| +delete from t1| +delete from t2| +drop procedure if exists a0| +create procedure a0(x int) +while x do +set x = x-1; +insert into test.t1 values ("a0", x); +end while| +call a0(3)| +select * from t1 order by data desc| +id data +a0 2 +a0 1 +a0 0 +delete from t1| +drop procedure a0| +drop procedure if exists a| +create procedure a(x int) +while x > 0 do +set x = x-1; +insert into test.t1 values ("a", x); +end while| +call a(3)| +select * from t1 order by data desc| +id data +a 2 +a 1 +a 0 +delete from t1| +drop procedure a| +drop procedure if exists b| +create procedure b(x int) +repeat +insert into test.t1 values (repeat("b",3), x); +set x = x-1; +until x = 0 end repeat| +call b(3)| +select * from t1 order by data desc| +id data +bbb 3 +bbb 2 +bbb 1 +delete from t1| +drop procedure b| +drop procedure if exists b2| +create procedure b2(x int) +repeat +select 1 into outfile 'b2'; +insert into test.t1 values (repeat("b2",3), x); +set x = x-1; +until x = 0 end repeat| +drop procedure b2| +drop procedure if exists c| +create procedure c(x int) +hmm: while x > 0 do +insert into test.t1 values ("c", x); +set x = x-1; +iterate hmm; +insert into test.t1 values ("x", x); +end while hmm| +call c(3)| +select * from t1 order by data desc| +id data +c 3 +c 2 +c 1 +delete from t1| +drop procedure c| +drop procedure if exists d| +create procedure d(x int) +hmm: while x > 0 do +insert into test.t1 values ("d", x); +set x = x-1; +leave hmm; +insert into test.t1 values ("x", x); +end while| +call d(3)| +select * from t1| +id data +d 3 +delete from t1| +drop procedure d| +drop procedure if exists e| +create procedure e(x int) +foo: loop +if x = 0 then +leave foo; +end if; +insert into test.t1 values ("e", x); +set x = x-1; +end loop foo| +call e(3)| +select * from t1 order by data desc| +id data +e 3 +e 2 +e 1 +delete from t1| +drop procedure e| +drop procedure if exists f| +create procedure f(x int) +if x < 0 then +insert into test.t1 values ("f", 0); +elseif x = 0 then +insert into test.t1 values ("f", 1); +else +insert into test.t1 values ("f", 2); +end if| +call f(-2)| +call f(0)| +call f(4)| +select * from t1 order by data| +id data +f 0 +f 1 +f 2 +delete from t1| +drop procedure f| +drop procedure if exists g| +create procedure g(x int) +case +when x < 0 then +insert into test.t1 values ("g", 0); +when x = 0 then +insert into test.t1 values ("g", 1); +else +insert into test.t1 values ("g", 2); +end case| +call g(-42)| +call g(0)| +call g(1)| +select * from t1 order by data| +id data +g 0 +g 1 +g 2 +delete from t1| +drop procedure g| +drop procedure if exists h| +create procedure h(x int) +case x +when 0 then +insert into test.t1 values ("h0", x); +when 1 then +insert into test.t1 values ("h1", x); +else +insert into test.t1 values ("h?", x); +end case| +call h(0)| +call h(1)| +call h(17)| +select * from t1 order by data| +id data +h0 0 +h1 1 +h? 17 +delete from t1| +drop procedure h| +drop procedure if exists i| +create procedure i(x int) +foo: +begin +if x = 0 then +leave foo; +end if; +insert into test.t1 values ("i", x); +end foo| +call i(0)| +call i(3)| +select * from t1| +id data +i 3 +delete from t1| +drop procedure i| +insert into t1 values ("foo", 3), ("bar", 19)| +insert into t2 values ("x", 9, 4.1), ("y", -1, 19.2), ("z", 3, 2.2)| +drop procedure if exists sel1| +create procedure sel1() +begin +select * from t1 order by data; +end| +call sel1()| +id data +foo 3 +bar 19 +drop procedure sel1| +drop procedure if exists sel2| +create procedure sel2() +begin +select * from t1 order by data; +select * from t2 order by s; +end| +call sel2()| +id data +foo 3 +bar 19 +s i d +x 9 4.1 +y -1 19.2 +z 3 2.2 +drop procedure sel2| +delete from t1| +delete from t2| +drop procedure if exists into_test| +create procedure into_test(x char(16), y int) +begin +insert into test.t1 values (x, y); +select id,data into x,y from test.t1 limit 1; +insert into test.t1 values (concat(x, "2"), y+2); +end| +call into_test("into", 100)| +select * from t1 order by data| +id data +into 100 +into2 102 +delete from t1| +drop procedure into_test| +drop procedure if exists into_tes2| +create procedure into_test2(x char(16), y int) +begin +insert into test.t1 values (x, y); +select id,data into x,@z from test.t1 limit 1; +insert into test.t1 values (concat(x, "2"), y+2); +end| +call into_test2("into", 100)| +select id,data,@z from t1 order by data| +id data @z +into 100 100 +into2 102 100 +delete from t1| +drop procedure into_test2| +drop procedure if exists into_test3| +create procedure into_test3() +begin +declare x char(16); +declare y int; +select * into x,y from test.t1 limit 1; +insert into test.t2 values (x, y, 0.0); +end| +insert into t1 values ("into3", 19)| +call into_test3()| +call into_test3()| +select * from t2| +s i d +into3 19 0 +into3 19 0 +delete from t1| +delete from t2| +drop procedure into_test3| +drop procedure if exists into_test4| +create procedure into_test4() +begin +declare x int; +select data into x from test.t1 limit 1; +insert into test.t3 values ("into4", x); +end| +delete from t1| +create table t3 ( s char(16), d int)| +call into_test4()| +select * from t3| +s d +into4 NULL +insert into t1 values ("i4", 77)| +call into_test4()| +select * from t3| +s d +into4 NULL +into4 77 +delete from t1| +drop table t3| +drop procedure into_test4| +drop procedure if exists into_outfile| +create procedure into_outfile(x char(16), y int) +begin +insert into test.t1 values (x, y); +select * into outfile "MYSQLTEST_VARDIR/tmp/spout" from test.t1; +insert into test.t1 values (concat(x, "2"), y+2); +end| +call into_outfile("ofile", 1)| +delete from t1| +drop procedure into_outfile| +drop procedure if exists into_dumpfile| +create procedure into_dumpfile(x char(16), y int) +begin +insert into test.t1 values (x, y); +select * into dumpfile "MYSQLTEST_VARDIR/tmp/spdump" from test.t1 limit 1; +insert into test.t1 values (concat(x, "2"), y+2); +end| +call into_dumpfile("dfile", 1)| +delete from t1| +drop procedure into_dumpfile| +drop procedure if exists create_select| +create procedure create_select(x char(16), y int) +begin +insert into test.t1 values (x, y); +create temporary table test.t3 select * from test.t1; +insert into test.t3 values (concat(x, "2"), y+2); +end| +call create_select("cs", 90)| +select * from t1, t3| +id data id data +cs 90 cs 90 +cs 90 cs2 92 +drop table t3| +delete from t1| +drop procedure create_select| +drop function if exists e| +create function e() returns double +return 2.7182818284590452354| +set @e = e()| +select e(), @e| +e() @e +2.718281828459045 2.718281828459045 +drop function if exists inc| +create function inc(i int) returns int +return i+1| +select inc(1), inc(99), inc(-71)| +inc(1) inc(99) inc(-71) +2 100 -70 +drop function if exists mul| +create function mul(x int, y int) returns int +return x*y| +select mul(1,1), mul(3,5), mul(4711, 666)| +mul(1,1) mul(3,5) mul(4711, 666) +1 15 3137526 +drop function if exists append| +create function append(s1 char(8), s2 char(8)) returns char(16) +return concat(s1, s2)| +select append("foo", "bar")| +append("foo", "bar") +foobar +drop function if exists fac| +create function fac(n int unsigned) returns bigint unsigned +begin +declare f bigint unsigned default 1; +while n > 1 do +set f = f * n; +set n = n - 1; +end while; +return f; +end| +select fac(1), fac(2), fac(5), fac(10)| +fac(1) fac(2) fac(5) fac(10) +1 2 120 3628800 +drop function if exists fun| +create function fun(d double, i int, u int unsigned) returns double +return mul(inc(i), fac(u)) / e()| +select fun(2.3, 3, 5)| +fun(2.3, 3, 5) +176.58213176229233 +insert into t2 values (append("xxx", "yyy"), mul(4,3), e())| +insert into t2 values (append("a", "b"), mul(2,mul(3,4)), fun(1.7, 4, 6))| +select * from t2 where s = append("a", "b")| +s i d +ab 24 1324.3659882171924 +select * from t2 where i = mul(4,3) or i = mul(mul(3,4),2) order by i| +s i d +xxxyyy 12 2.718281828459045 +ab 24 1324.3659882171924 +select * from t2 where d = e()| +s i d +xxxyyy 12 2.718281828459045 +select * from t2 order by i| +s i d +xxxyyy 12 2.718281828459045 +ab 24 1324.3659882171924 +delete from t2| +drop function e| +drop function inc| +drop function mul| +drop function append| +drop function fun| +drop procedure if exists hndlr1| +create procedure hndlr1(val int) +begin +declare x int default 0; +declare foo condition for 1136; +declare bar condition for sqlstate '42S98'; # Just for testing syntax +declare zip condition for sqlstate value '42S99'; # Just for testing syntax +declare continue handler for foo set x = 1; +insert into test.t1 values ("hndlr1", val, 2); # Too many values +if (x) then +insert into test.t1 values ("hndlr1", val); # This instead then +end if; +end| +call hndlr1(42)| +select * from t1| +id data +hndlr1 42 +delete from t1| +drop procedure hndlr1| +drop procedure if exists hndlr2| +create procedure hndlr2(val int) +begin +declare x int default 0; +begin +declare exit handler for sqlstate '21S01' set x = 1; +insert into test.t1 values ("hndlr2", val, 2); # Too many values +end; +insert into test.t1 values ("hndlr2", x); +end| +call hndlr2(42)| +select * from t1| +id data +hndlr2 1 +delete from t1| +drop procedure hndlr2| +drop procedure if exists hndlr3| +create procedure hndlr3(val int) +begin +declare x int default 0; +declare continue handler for sqlexception # Any error +begin +declare z int; +set z = 2 * val; +set x = 1; +end; +if val < 10 then +begin +declare y int; +set y = val + 10; +insert into test.t1 values ("hndlr3", y, 2); # Too many values +if x then +insert into test.t1 values ("hndlr3", y); +end if; +end; +end if; +end| +call hndlr3(3)| +select * from t1| +id data +hndlr3 13 +delete from t1| +drop procedure hndlr3| +create table t3 ( id char(16), data int )| +drop procedure if exists hndlr4| +create procedure hndlr4() +begin +declare x int default 0; +declare val int; # No default +declare continue handler for sqlstate '02000' set x=1; +select data into val from test.t3 where id='z' limit 1; # No hits +insert into test.t3 values ('z', val); +end| +call hndlr4()| +select * from t3| +id data +z NULL +drop table t3| +drop procedure hndlr4| +drop procedure if exists cur1| +create procedure cur1() +begin +declare a char(16); +declare b int; +declare c double; +declare done int default 0; +declare c cursor for select * from test.t2; +declare continue handler for sqlstate '02000' set done = 1; +open c; +repeat +fetch c into a, b, c; +if not done then +insert into test.t1 values (a, b+c); +end if; +until done end repeat; +close c; +end| +insert into t2 values ("foo", 42, -1.9), ("bar", 3, 12.1), ("zap", 666, -3.14)| +call cur1()| +select * from t1| +id data +foo 40 +bar 15 +zap 663 +drop procedure cur1| +create table t3 ( s char(16), i int )| +drop procedure if exists cur2| +create procedure cur2() +begin +declare done int default 0; +declare c1 cursor for select id,data from test.t1 order by id,data; +declare c2 cursor for select i from test.t2 order by i; +declare continue handler for sqlstate '02000' set done = 1; +open c1; +open c2; +repeat +begin +declare a char(16); +declare b,c int; +fetch from c1 into a, b; +fetch next from c2 into c; +if not done then +if b < c then +insert into test.t3 values (a, b); +else +insert into test.t3 values (a, c); +end if; +end if; +end; +until done end repeat; +close c1; +close c2; +end| +call cur2()| +select * from t3 order by i,s| +s i +bar 3 +foo 40 +zap 663 +delete from t1| +delete from t2| +drop table t3| +drop procedure cur2| +drop procedure if exists chistics| +create procedure chistics() +language sql +modifies sql data +not deterministic +sql security definer +comment 'Characteristics procedure test' + insert into t1 values ("chistics", 1)| +show create procedure chistics| +Procedure sql_mode Create Procedure character_set_client collation_connection Database Collation +chistics ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION CREATE DEFINER=`root`@`localhost` PROCEDURE `chistics`() + MODIFIES SQL DATA + COMMENT 'Characteristics procedure test' +insert into t1 values ("chistics", 1) utf8mb4 utf8mb4_0900_ai_ci utf8mb4_0900_ai_ci +call chistics()| +select * from t1| +id data +chistics 1 +delete from t1| +alter procedure chistics sql security invoker| +show create procedure chistics| +Procedure sql_mode Create Procedure character_set_client collation_connection Database Collation +chistics ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION CREATE DEFINER=`root`@`localhost` PROCEDURE `chistics`() + MODIFIES SQL DATA + SQL SECURITY INVOKER + COMMENT 'Characteristics procedure test' +insert into t1 values ("chistics", 1) utf8mb4 utf8mb4_0900_ai_ci utf8mb4_0900_ai_ci +drop procedure chistics| +drop function if exists chistics| +create function chistics() returns int +language sql +deterministic +sql security invoker +comment 'Characteristics procedure test' + return 42| +show create function chistics| +Function sql_mode Create Function character_set_client collation_connection Database Collation +chistics ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION CREATE DEFINER=`root`@`localhost` FUNCTION `chistics`() RETURNS int + DETERMINISTIC + SQL SECURITY INVOKER + COMMENT 'Characteristics procedure test' +return 42 utf8mb4 utf8mb4_0900_ai_ci utf8mb4_0900_ai_ci +select chistics()| +chistics() +42 +alter function chistics +no sql +comment 'Characteristics function test'| +show create function chistics| +Function sql_mode Create Function character_set_client collation_connection Database Collation +chistics ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION CREATE DEFINER=`root`@`localhost` FUNCTION `chistics`() RETURNS int + NO SQL + DETERMINISTIC + SQL SECURITY INVOKER + COMMENT 'Characteristics function test' +return 42 utf8mb4 utf8mb4_0900_ai_ci utf8mb4_0900_ai_ci +drop function chistics| +insert into t1 values ("foo", 1), ("bar", 2), ("zip", 3)| +set @@sql_mode = 'ANSI'| +drop procedure if exists modes$ +create procedure modes(out c1 int, out c2 int) +begin +declare done int default 0; +declare x int; +declare c cursor for select data from t1; +declare continue handler for sqlstate '02000' set done = 1; +select 1 || 2 into c1; +set c2 = 0; +open c; +repeat +fetch c into x; +if not done then +set c2 = c2 + 1; +end if; +until done end repeat; +close c; +end$ +set @@sql_mode = ''| +set sql_select_limit = 1| +call modes(@c1, @c2)| +set sql_select_limit = default| +select @c1, @c2| +@c1 @c2 +12 3 +delete from t1| +drop procedure modes| +create database sp_db1| +drop database sp_db1| +create database sp_db2| +use sp_db2| +create table t3 ( s char(4), t int )| +insert into t3 values ("abcd", 42), ("dcba", 666)| +use test| +drop database sp_db2| +create database sp_db3| +use sp_db3| +drop procedure if exists dummy| +create procedure dummy(out x int) +set x = 42| +use test| +drop database sp_db3| +select routine_type, routine_schema, routine_name from information_schema.routines where routine_schema = 'sp_db3'| +ROUTINE_TYPE ROUTINE_SCHEMA ROUTINE_NAME +drop procedure if exists rc| +create procedure rc() +begin +delete from t1; +insert into t1 values ("a", 1), ("b", 2), ("c", 3); +end| +call rc()| +select row_count()| +row_count() +3 +update t1 set data=42 where id = "b"; +select row_count()| +row_count() +1 +delete from t1| +select row_count()| +row_count() +3 +delete from t1| +select row_count()| +row_count() +0 +select * from t1| +id data +select row_count()| +row_count() +-1 +drop procedure rc| +drop function if exists f0| +drop function if exists f1| +drop function if exists f2| +drop function if exists f3| +drop function if exists f4| +drop function if exists f5| +drop function if exists f6| +drop function if exists f7| +drop function if exists f8| +drop function if exists f9| +drop function if exists f10| +drop function if exists f11| +drop function if exists f12_1| +drop function if exists f12_2| +drop view if exists v0| +drop view if exists v1| +drop view if exists v2| +delete from t1| +delete from t2| +insert into t1 values ("a", 1), ("b", 2) | +insert into t2 values ("a", 1, 1.0), ("b", 2, 2.0), ("c", 3, 3.0) | +create function f1() returns int +return (select sum(data) from t1)| +select f1()| +f1() +3 +select id, f1() from t1 order by id| +id f1() +a 3 +b 3 +create function f2() returns int +return (select data from t1 where data <= (select sum(data) from t1) order by data limit 1)| +select f2()| +f2() +1 +select id, f2() from t1 order by id| +id f2() +a 1 +b 1 +create function f3() returns int +begin +declare n int; +declare m int; +set n:= (select min(data) from t1); +set m:= (select max(data) from t1); +return n < m; +end| +select f3()| +f3() +1 +select id, f3() from t1 order by id| +id f3() +a 1 +b 1 +select f1(), f3()| +f1() f3() +3 1 +select id, f1(), f3() from t1 order by id| +id f1() f3() +a 3 1 +b 3 1 +create function f4() returns double +return (select d from t1, t2 where t1.data = t2.i and t1.id= "b")| +select f4()| +f4() +2 +select s, f4() from t2 order by s| +s f4() +a 2 +b 2 +c 2 +create function f5(i int) returns int +begin +if i <= 0 then +return 0; +elseif i = 1 then +return (select count(*) from t1 where data = i); +else +return (select count(*) + f5( i - 1) from t1 where data = i); +end if; +end| +select f5(1)| +f5(1) +1 +select f5(2)| +ERROR HY000: Recursive stored functions and triggers are not allowed. +select f5(3)| +ERROR HY000: Recursive stored functions and triggers are not allowed. +create function f6() returns int +begin +declare n int; +set n:= f1(); +return (select count(*) from t1 where data <= f7() and data <= n); +end| +create function f7() returns int +return (select sum(data) from t1 where data <= f1())| +select f6()| +f6() +2 +select id, f6() from t1 order by id| +id f6() +a 2 +b 2 +create view v1 (a) as select f1()| +select * from v1| +a +3 +select id, a from t1, v1 order by id| +id a +a 3 +b 3 +select * from v1, v1 as v| +a a +3 3 +create view v2 (a) as select a*10 from v1| +select * from v2| +a +30 +select id, a from t1, v2 order by id| +id a +a 30 +b 30 +select * from v1, v2| +a a +3 30 +create function f8 () returns int +return (select count(*) from v2)| +select *, f8() from v1| +a f8() +3 1 +drop function f1| +select * from v1| +ERROR HY000: View 'test.v1' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +create function f1() returns int +return (select sum(data) from t1) + (select sum(a) from v1)| +select f1()| +ERROR HY000: Recursive stored functions and triggers are not allowed. +select * from v1| +ERROR HY000: Recursive stored functions and triggers are not allowed. +select * from v2| +ERROR HY000: Recursive stored functions and triggers are not allowed. +drop function f1| +create function f1() returns int +return (select sum(data) from t1)| +create function f0() returns int +return (select * from (select 100) as r)| +select f0()| +f0() +100 +select *, f0() from (select 1) as t| +1 f0() +1 100 +create view v0 as select f0()| +select * from v0| +f0() +100 +select *, f0() from v0| +f0() f0() +100 100 +lock tables t1 read, t1 as t11 read| +select f3()| +f3() +1 +select id, f3() from t1 as t11 order by id| +id f3() +a 1 +b 1 +select f0()| +f0() +100 +select * from v0| +ERROR HY000: Table 'v0' was not locked with LOCK TABLES +select *, f0() from v0, (select 123) as d1| +ERROR HY000: Table 'v0' was not locked with LOCK TABLES +select id, f3() from t1| +ERROR HY000: Table 't1' was not locked with LOCK TABLES +select f4()| +ERROR HY000: Table 't2' was not locked with LOCK TABLES +unlock tables| +create function f9() returns int +begin +declare a, b int; +drop temporary table if exists t3; +create temporary table t3 (id int); +insert into t3 values (1), (2), (3); +set a:= (select count(*) from t3); +set b:= (select count(*) from t3 t3_alias); +return a + b; +end| +select f9()| +f9() +6 +select f9() from t1 limit 1| +f9() +6 +create function f10() returns int +begin +drop temporary table if exists t3; +create temporary table t3 (id int); +insert into t3 select id from t4; +return (select count(*) from t3); +end| +select f10()| +ERROR 42S02: Table 'test.t4' doesn't exist +create table t4 as select 1 as id| +select f10()| +f10() +1 +create function f11() returns int +begin +drop temporary table if exists t3; +create temporary table t3 (id int); +insert into t3 values (1), (2), (3); +return (select count(*) from t3 as a, t3 as b); +end| +select f11()| +ERROR HY000: Can't reopen table: 'a' +select f11() from t1| +ERROR HY000: Can't reopen table: 'a' +create function f12_1() returns int +begin +drop temporary table if exists t3; +create temporary table t3 (id int); +insert into t3 values (1), (2), (3); +return f12_2(); +end| +create function f12_2() returns int +return (select count(*) from t3)| +drop temporary table t3| +select f12_1()| +f12_1() +3 +select f12_1() from t1 limit 1| +f12_1() +3 +drop function f0| +drop function f1| +drop function f2| +drop function f3| +drop function f4| +drop function f5| +drop function f6| +drop function f7| +drop function f8| +drop function f9| +drop function f10| +drop function f11| +drop function f12_1| +drop function f12_2| +drop view v0| +drop view v1| +drop view v2| +truncate table t1 | +truncate table t2 | +drop table t4| +drop table if exists t3| +create table t3 (n int unsigned not null primary key, f bigint unsigned)| +drop procedure if exists ifac| +create procedure ifac(n int unsigned) +begin +declare i int unsigned default 1; +if n > 20 then +set n = 20; # bigint overflow otherwise +end if; +while i <= n do +begin +insert into test.t3 values (i, fac(i)); +set i = i + 1; +end; +end while; +end| +call ifac(20)| +select * from t3| +n f +1 1 +10 3628800 +11 39916800 +12 479001600 +13 6227020800 +14 87178291200 +15 1307674368000 +16 20922789888000 +17 355687428096000 +18 6402373705728000 +19 121645100408832000 +2 2 +20 2432902008176640000 +3 6 +4 24 +5 120 +6 720 +7 5040 +8 40320 +9 362880 +drop table t3| +show function status like '%fac'| +Db Name Type Definer Modified Created Security_type Comment character_set_client collation_connection Database Collation +test fac FUNCTION root@localhost 0000-00-00 00:00:00 0000-00-00 00:00:00 DEFINER utf8mb4 utf8mb4_0900_ai_ci utf8mb4_0900_ai_ci +drop procedure ifac| +drop function fac| +show function status like '%fac'| +Db Name Type Definer Modified Created Security_type Comment character_set_client collation_connection Database Collation +drop table if exists t3| +create table t3 ( +i int unsigned not null primary key, +p bigint unsigned not null +)| +insert into t3 values +( 0, 3), ( 1, 5), ( 2, 7), ( 3, 11), ( 4, 13), +( 5, 17), ( 6, 19), ( 7, 23), ( 8, 29), ( 9, 31), +(10, 37), (11, 41), (12, 43), (13, 47), (14, 53), +(15, 59), (16, 61), (17, 67), (18, 71), (19, 73), +(20, 79), (21, 83), (22, 89), (23, 97), (24, 101), +(25, 103), (26, 107), (27, 109), (28, 113), (29, 127), +(30, 131), (31, 137), (32, 139), (33, 149), (34, 151), +(35, 157), (36, 163), (37, 167), (38, 173), (39, 179), +(40, 181), (41, 191), (42, 193), (43, 197), (44, 199)| +drop procedure if exists opp| +create procedure opp(n bigint unsigned, out pp bool) +begin +declare r double; +declare b, s bigint unsigned default 0; +set r = sqrt(n); +again: +loop +if s = 45 then +set b = b+200, s = 0; +else +begin +declare p bigint unsigned; +select t.p into p from test.t3 t where t.i = s; +if b+p > r then +set pp = 1; +leave again; +end if; +if mod(n, b+p) = 0 then +set pp = 0; +leave again; +end if; +set s = s+1; +end; +end if; +end loop; +end| +drop procedure if exists ip| +create procedure ip(m int unsigned) +begin +declare p bigint unsigned; +declare i int unsigned; +set i=45, p=201; +while i < m do +begin +declare pp bool default 0; +call opp(p, pp); +if pp then +insert into test.t3 values (i, p); +set i = i+1; +end if; +set p = p+2; +end; +end while; +end| +show create procedure opp| +Procedure sql_mode Create Procedure character_set_client collation_connection Database Collation +opp CREATE DEFINER=`root`@`localhost` PROCEDURE `opp`(n bigint unsigned, out pp bool) +begin +declare r double; +declare b, s bigint unsigned default 0; +set r = sqrt(n); +again: +loop +if s = 45 then +set b = b+200, s = 0; +else +begin +declare p bigint unsigned; +select t.p into p from test.t3 t where t.i = s; +if b+p > r then +set pp = 1; +leave again; +end if; +if mod(n, b+p) = 0 then +set pp = 0; +leave again; +end if; +set s = s+1; +end; +end if; +end loop; +end utf8mb4 utf8mb4_0900_ai_ci utf8mb4_0900_ai_ci +show procedure status where name like '%p%' and db='test'| +Db Name Type Definer Modified Created Security_type Comment character_set_client collation_connection Database Collation +test ip PROCEDURE root@localhost 0000-00-00 00:00:00 0000-00-00 00:00:00 DEFINER utf8mb4 utf8mb4_0900_ai_ci utf8mb4_0900_ai_ci +test opp PROCEDURE root@localhost 0000-00-00 00:00:00 0000-00-00 00:00:00 DEFINER utf8mb4 utf8mb4_0900_ai_ci utf8mb4_0900_ai_ci +call ip(200)| +select * from t3 where i=45 or i=100 or i=199| +i p +45 211 +100 557 +199 1229 +drop table t3| +drop procedure opp| +drop procedure ip| +show procedure status where name like '%p%' and db='test'| +Db Name Type Definer Modified Created Security_type Comment character_set_client collation_connection Database Collation +drop procedure if exists bar| +create procedure bar(x char(16), y int) +comment "111111111111" sql security invoker +insert into test.t1 values (x, y)| +show procedure status like 'bar'| +Db Name Type Definer Modified Created Security_type Comment character_set_client collation_connection Database Collation +test bar PROCEDURE root@localhost 0000-00-00 00:00:00 0000-00-00 00:00:00 INVOKER 111111111111 utf8mb4 utf8mb4_0900_ai_ci utf8mb4_0900_ai_ci +alter procedure bar comment "2222222222" sql security definer| +alter procedure bar comment "3333333333"| +alter procedure bar| +show create procedure bar| +Procedure sql_mode Create Procedure character_set_client collation_connection Database Collation +bar CREATE DEFINER=`root`@`localhost` PROCEDURE `bar`(x char(16), y int) + COMMENT '3333333333' +insert into test.t1 values (x, y) utf8mb4 utf8mb4_0900_ai_ci utf8mb4_0900_ai_ci +show procedure status like 'bar'| +Db Name Type Definer Modified Created Security_type Comment character_set_client collation_connection Database Collation +test bar PROCEDURE root@localhost 0000-00-00 00:00:00 0000-00-00 00:00:00 DEFINER 3333333333 utf8mb4 utf8mb4_0900_ai_ci utf8mb4_0900_ai_ci +drop procedure bar| +drop procedure if exists p1| +create procedure p1 () +select (select s1 from t3) from t3| +create table t3 (s1 int)| +call p1()| +(select s1 from t3) +insert into t3 values (1)| +call p1()| +(select s1 from t3) +1 +drop procedure p1| +drop table t3| +drop function if exists foo| +create function `foo` () returns int +return 5| +select `foo` ()| +`foo` () +5 +drop function `foo`| +drop function if exists t1max| +create function t1max() returns int +begin +declare x int; +select max(data) into x from t1; +return x; +end| +insert into t1 values ("foo", 3), ("bar", 2), ("zip", 5), ("zap", 1)| +select t1max()| +t1max() +5 +drop function t1max| +create table t3 ( +v char(16) not null primary key, +c int unsigned not null +)| +create function getcount(s char(16)) returns int +begin +declare x int; +select count(*) into x from t3 where v = s; +if x = 0 then +insert into t3 values (s, 1); +else +update t3 set c = c+1 where v = s; +end if; +return x; +end| +select * from t1 where data = getcount("bar")| +id data +zap 1 +select * from t3| +v c +bar 4 +select getcount("zip")| +getcount("zip") +0 +select getcount("zip")| +getcount("zip") +1 +select * from t3| +v c +bar 4 +zip 2 +select getcount(id) from t1 where data = 3| +getcount(id) +0 +select getcount(id) from t1 where data = 5| +getcount(id) +1 +select * from t3| +v c +bar 4 +foo 1 +zip 3 +drop table t3| +drop function getcount| +drop table if exists t3| +drop procedure if exists h_ee| +drop procedure if exists h_es| +drop procedure if exists h_en| +drop procedure if exists h_ew| +drop procedure if exists h_ex| +drop procedure if exists h_se| +drop procedure if exists h_ss| +drop procedure if exists h_sn| +drop procedure if exists h_sw| +drop procedure if exists h_sx| +drop procedure if exists h_ne| +drop procedure if exists h_ns| +drop procedure if exists h_nn| +drop procedure if exists h_we| +drop procedure if exists h_ws| +drop procedure if exists h_ww| +drop procedure if exists h_xe| +drop procedure if exists h_xs| +drop procedure if exists h_xx| +create table t3 (a smallint primary key)| +insert into t3 (a) values (1)| +create procedure h_ee() +deterministic +begin +declare continue handler for 1062 -- ER_DUP_ENTRY +select 'Outer (bad)' as 'h_ee'; +begin +declare continue handler for 1062 -- ER_DUP_ENTRY +select 'Inner (good)' as 'h_ee'; +insert into t3 values (1); +end; +end| +create procedure h_es() +deterministic +begin +declare continue handler for 1062 -- ER_DUP_ENTRY +select 'Outer (bad)' as 'h_es'; +begin +-- integrity constraint violation +declare continue handler for sqlstate '23000' + select 'Inner (good)' as 'h_es'; +insert into t3 values (1); +end; +end| +create procedure h_en() +deterministic +begin +declare continue handler for 1329 -- ER_SP_FETCH_NO_DATA +select 'Outer (bad)' as 'h_en'; +begin +declare x int; +declare continue handler for sqlstate '02000' -- no data +select 'Inner (good)' as 'h_en'; +select a into x from t3 where a = 42; +end; +end| +create procedure h_ew() +deterministic +begin +declare continue handler for 1264 -- ER_WARN_DATA_OUT_OF_RANGE +select 'Outer (bad)' as 'h_ew'; +begin +declare continue handler for sqlwarning +select 'Inner (good)' as 'h_ew'; +insert into t3 values (123456789012); +end; +delete from t3; +insert into t3 values (1); +end| +create procedure h_ex() +deterministic +begin +declare continue handler for 1062 -- ER_DUP_ENTRY +select 'Outer (bad)' as 'h_ex'; +begin +declare continue handler for sqlexception +select 'Inner (good)' as 'h_ex'; +insert into t3 values (1); +end; +end| +create procedure h_se() +deterministic +begin +-- integrity constraint violation +declare continue handler for sqlstate '23000' +select 'Outer (bad)' as 'h_se'; +begin +declare continue handler for 1062 -- ER_DUP_ENTRY +select 'Inner (good)' as 'h_se'; +insert into t3 values (1); +end; +end| +create procedure h_ss() +deterministic +begin +-- integrity constraint violation +declare continue handler for sqlstate '23000' +select 'Outer (bad)' as 'h_ss'; +begin +-- integrity constraint violation +declare continue handler for sqlstate '23000' +select 'Inner (good)' as 'h_ss'; +insert into t3 values (1); +end; +end| +create procedure h_sn() +deterministic +begin +-- Note: '02000' is more specific than NOT FOUND ; +-- there might be other not found states +declare continue handler for sqlstate '02000' -- no data +select 'Outer (bad)' as 'h_sn'; +begin +declare x int; +declare continue handler for not found +select 'Inner (good)' as 'h_sn'; +select a into x from t3 where a = 42; +end; +end| +create procedure h_sw() +deterministic +begin +-- data exception - numeric value out of range +declare continue handler for sqlstate '22003' + select 'Outer (bad)' as 'h_sw'; +begin +declare continue handler for sqlwarning +select 'Inner (good)' as 'h_sw'; +insert into t3 values (123456789012); +end; +delete from t3; +insert into t3 values (1); +end| +create procedure h_sx() +deterministic +begin +-- integrity constraint violation +declare continue handler for sqlstate '23000' +select 'Outer (bad)' as 'h_sx'; +begin +declare continue handler for sqlexception +select 'Inner (good)' as 'h_sx'; +insert into t3 values (1); +end; +end| +create procedure h_ne() +deterministic +begin +declare continue handler for not found +select 'Outer (bad)' as 'h_ne'; +begin +declare x int; +declare continue handler for 1329 -- ER_SP_FETCH_NO_DATA +select 'Inner (good)' as 'h_ne'; +select a into x from t3 where a = 42; +end; +end| +create procedure h_ns() +deterministic +begin +declare continue handler for not found +select 'Outer (bad)' as 'h_ns'; +begin +declare x int; +declare continue handler for sqlstate '02000' -- no data +select 'Inner (good)' as 'h_ns'; +select a into x from t3 where a = 42; +end; +end| +create procedure h_nn() +deterministic +begin +declare continue handler for not found +select 'Outer (bad)' as 'h_nn'; +begin +declare x int; +declare continue handler for not found +select 'Inner (good)' as 'h_nn'; +select a into x from t3 where a = 42; +end; +end| +create procedure h_we() +deterministic +begin +declare continue handler for sqlwarning +select 'Outer (bad)' as 'h_we'; +begin +declare continue handler for 1264 -- ER_WARN_DATA_OUT_OF_RANGE +select 'Inner (good)' as 'h_we'; +insert into t3 values (123456789012); +end; +delete from t3; +insert into t3 values (1); +end| +create procedure h_ws() +deterministic +begin +declare continue handler for sqlwarning +select 'Outer (bad)' as 'h_ws'; +begin +-- data exception - numeric value out of range +declare continue handler for sqlstate '22003' + select 'Inner (good)' as 'h_ws'; +insert into t3 values (123456789012); +end; +delete from t3; +insert into t3 values (1); +end| +create procedure h_ww() +deterministic +begin +declare continue handler for sqlwarning +select 'Outer (bad)' as 'h_ww'; +begin +declare continue handler for sqlwarning +select 'Inner (good)' as 'h_ww'; +insert into t3 values (123456789012); +end; +delete from t3; +insert into t3 values (1); +end| +create procedure h_xe() +deterministic +begin +declare continue handler for sqlexception +select 'Outer (bad)' as 'h_xe'; +begin +declare continue handler for 1062 -- ER_DUP_ENTRY +select 'Inner (good)' as 'h_xe'; +insert into t3 values (1); +end; +end| +create procedure h_xs() +deterministic +begin +declare continue handler for sqlexception +select 'Outer (bad)' as 'h_xs'; +begin +-- integrity constraint violation +declare continue handler for sqlstate '23000' + select 'Inner (good)' as 'h_xs'; +insert into t3 values (1); +end; +end| +create procedure h_xx() +deterministic +begin +declare continue handler for sqlexception +select 'Outer (bad)' as 'h_xx'; +begin +declare continue handler for sqlexception +select 'Inner (good)' as 'h_xx'; +insert into t3 values (1); +end; +end| +call h_ee()| +h_ee +Inner (good) +call h_es()| +h_es +Inner (good) +call h_en()| +h_en +Inner (good) +call h_ew()| +h_ew +Inner (good) +call h_ex()| +h_ex +Inner (good) +call h_se()| +h_se +Inner (good) +call h_ss()| +h_ss +Inner (good) +call h_sn()| +h_sn +Inner (good) +call h_sw()| +h_sw +Inner (good) +call h_sx()| +h_sx +Inner (good) +call h_ne()| +h_ne +Inner (good) +call h_ns()| +h_ns +Inner (good) +call h_nn()| +h_nn +Inner (good) +call h_we()| +h_we +Inner (good) +call h_ws()| +h_ws +Inner (good) +call h_ww()| +h_ww +Inner (good) +call h_xe()| +h_xe +Inner (good) +call h_xs()| +h_xs +Inner (good) +call h_xx()| +h_xx +Inner (good) +drop table t3| +drop procedure h_ee| +drop procedure h_es| +drop procedure h_en| +drop procedure h_ew| +drop procedure h_ex| +drop procedure h_se| +drop procedure h_ss| +drop procedure h_sn| +drop procedure h_sw| +drop procedure h_sx| +drop procedure h_ne| +drop procedure h_ns| +drop procedure h_nn| +drop procedure h_we| +drop procedure h_ws| +drop procedure h_ww| +drop procedure h_xe| +drop procedure h_xs| +drop procedure h_xx| +drop procedure if exists bug822| +create procedure bug822(a_id char(16), a_data int) +begin +declare n int; +select count(*) into n from t1 where id = a_id and data = a_data; +if n = 0 then +insert into t1 (id, data) values (a_id, a_data); +end if; +end| +delete from t1| +call bug822('foo', 42)| +call bug822('foo', 42)| +call bug822('bar', 666)| +select * from t1 order by data| +id data +foo 42 +bar 666 +delete from t1| +drop procedure bug822| +drop procedure if exists bug1495| +create procedure bug1495() +begin +declare x int; +select data into x from t1 order by id limit 1; +if x > 10 then +insert into t1 values ("less", x-10); +else +insert into t1 values ("more", x+10); +end if; +end| +insert into t1 values ('foo', 12)| +call bug1495()| +delete from t1 where id='foo'| +insert into t1 values ('bar', 7)| +call bug1495()| +delete from t1 where id='bar'| +select * from t1 order by data| +id data +less 2 +more 17 +delete from t1| +drop procedure bug1495| +drop procedure if exists bug1547| +create procedure bug1547(s char(16)) +begin +declare x int; +select data into x from t1 where s = id limit 1; +if x > 10 then +insert into t1 values ("less", x-10); +else +insert into t1 values ("more", x+10); +end if; +end| +insert into t1 values ("foo", 12), ("bar", 7)| +call bug1547("foo")| +call bug1547("bar")| +select * from t1 order by id| +id data +bar 7 +foo 12 +less 2 +more 17 +delete from t1| +drop procedure bug1547| +drop table if exists t70| +create table t70 (s1 int,s2 int)| +insert into t70 values (1,2)| +drop procedure if exists bug1656| +create procedure bug1656(out p1 int, out p2 int) +select * into p1, p1 from t70| +call bug1656(@1, @2)| +select @1, @2| +@1 @2 +2 NULL +drop table t70| +drop procedure bug1656| +create table t3(a int)| +drop procedure if exists bug1862| +create procedure bug1862() +begin +insert into t3 values(2); +flush tables; +end| +call bug1862()| +call bug1862()| +select * from t3| +a +2 +2 +drop table t3| +drop procedure bug1862| +drop procedure if exists bug1874| +create procedure bug1874() +begin +declare x int; +declare y double; +select max(data) into x from t1; +insert into t2 values ("max", x, 0); +select min(data) into x from t1; +insert into t2 values ("min", x, 0); +select sum(data) into x from t1; +insert into t2 values ("sum", x, 0); +select avg(data) into y from t1; +insert into t2 values ("avg", 0, y); +end| +insert into t1 (data) values (3), (1), (5), (9), (4)| +call bug1874()| +select * from t2 order by i| +s i d +avg 0 4.4 +min 1 0 +max 9 0 +sum 22 0 +delete from t1| +delete from t2| +drop procedure bug1874| +drop procedure if exists bug2260| +create procedure bug2260() +begin +declare v1 int; +declare c1 cursor for select data from t1; +declare continue handler for not found set @x2 = 1; +open c1; +fetch c1 into v1; +set @x2 = 2; +close c1; +end| +call bug2260()| +select @x2| +@x2 +2 +drop procedure bug2260| +drop procedure if exists bug2267_1| +create procedure bug2267_1() +begin +show procedure status where db='test'; +end| +drop procedure if exists bug2267_2| +create procedure bug2267_2() +begin +show function status where db='test'; +end| +drop procedure if exists bug2267_3| +create procedure bug2267_3() +begin +show create procedure bug2267_1; +end| +drop procedure if exists bug2267_4| +drop function if exists bug2267_4| +create procedure bug2267_4() +begin +show create function bug2267_4; +end| +create function bug2267_4() returns int return 100| +call bug2267_1()| +Db Name Type Definer Modified Created Security_type Comment character_set_client collation_connection Database Collation +test bug2267_1 PROCEDURE root@localhost 0000-00-00 00:00:00 0000-00-00 00:00:00 DEFINER utf8mb4 utf8mb4_0900_ai_ci utf8mb4_0900_ai_ci +test bug2267_2 PROCEDURE root@localhost 0000-00-00 00:00:00 0000-00-00 00:00:00 DEFINER utf8mb4 utf8mb4_0900_ai_ci utf8mb4_0900_ai_ci +test bug2267_3 PROCEDURE root@localhost 0000-00-00 00:00:00 0000-00-00 00:00:00 DEFINER utf8mb4 utf8mb4_0900_ai_ci utf8mb4_0900_ai_ci +test bug2267_4 PROCEDURE root@localhost 0000-00-00 00:00:00 0000-00-00 00:00:00 DEFINER utf8mb4 utf8mb4_0900_ai_ci utf8mb4_0900_ai_ci +call bug2267_2()| +Db Name Type Definer Modified Created Security_type Comment character_set_client collation_connection Database Collation +test bug2267_4 FUNCTION root@localhost 0000-00-00 00:00:00 0000-00-00 00:00:00 DEFINER utf8mb4 utf8mb4_0900_ai_ci utf8mb4_0900_ai_ci +call bug2267_3()| +Procedure sql_mode Create Procedure character_set_client collation_connection Database Collation +bug2267_1 CREATE DEFINER=`root`@`localhost` PROCEDURE `bug2267_1`() +begin +show procedure status where db='test'; +end utf8mb4 utf8mb4_0900_ai_ci utf8mb4_0900_ai_ci +call bug2267_4()| +Function sql_mode Create Function character_set_client collation_connection Database Collation +bug2267_4 CREATE DEFINER=`root`@`localhost` FUNCTION `bug2267_4`() RETURNS int +return 100 utf8mb4 utf8mb4_0900_ai_ci utf8mb4_0900_ai_ci +drop procedure bug2267_1| +drop procedure bug2267_2| +drop procedure bug2267_3| +drop procedure bug2267_4| +drop function bug2267_4| +drop procedure if exists bug2227| +create procedure bug2227(x int) +begin +declare y float default 2.6; +declare z char(16) default "zzz"; +select 1.3, x, y, 42, z; +end| +call bug2227(9)| +1.3 x y 42 z +1.3 9 2.6 42 zzz +drop procedure bug2227| +drop procedure if exists bug2614| +create procedure bug2614() +begin +drop table if exists t3; +create table t3 (id int default '0' not null); +insert into t3 select 12; +insert into t3 select * from t3; +end| +call bug2614()| +call bug2614()| +drop table t3| +drop procedure bug2614| +drop function if exists bug2674| +create function bug2674() returns int +return @@sort_buffer_size| +set @osbs = @@sort_buffer_size| +set @@sort_buffer_size = 262000| +select bug2674()| +bug2674() +262000 +drop function bug2674| +set @@sort_buffer_size = @osbs| +drop procedure if exists bug3259_1 | +create procedure bug3259_1 () begin end| +drop procedure if exists BUG3259_2 | +create procedure BUG3259_2 () begin end| +drop procedure if exists Bug3259_3 | +create procedure Bug3259_3 () begin end| +call BUG3259_1()| +call BUG3259_1()| +call bug3259_2()| +call Bug3259_2()| +call bug3259_3()| +call bUG3259_3()| +drop procedure bUg3259_1| +drop procedure BuG3259_2| +drop procedure BUG3259_3| +drop function if exists bug2772| +create function bug2772() returns char(10) character set latin2 +return 'a'| +select bug2772()| +bug2772() +a +drop function bug2772| +create table t3 (s1 smallint)| +insert into t3 values (123456789012)| +Warnings: +Warning 1264 Out of range value for column 's1' at row 1 +drop procedure if exists bug2780| +create procedure bug2780() +begin +declare exit handler for sqlwarning set @x = 1; +set @x = 0; +insert into t3 values (123456789012); +insert into t3 values (0); +end| +call bug2780()| +select @x| +@x +1 +select * from t3| +s1 +32767 +32767 +drop procedure bug2780| +drop table t3| +create table t3 (content varchar(10) )| +insert into t3 values ("test1")| +insert into t3 values ("test2")| +create table t4 (f1 int, rc int, t3 int)| +drop procedure if exists bug1863| +create procedure bug1863(in1 int) +begin +declare ind int default 0; +declare t1 int; +declare t2 int; +declare t3 int; +declare rc int default 0; +declare continue handler for 1065 set rc = 1; +drop temporary table if exists temp_t1; +create temporary table temp_t1 ( +f1 int auto_increment, f2 varchar(20), primary key (f1) +); +insert into temp_t1 (f2) select content from t3; +select f2 into t3 from temp_t1 where f1 = 10; +if (rc) then +insert into t4 values (1, rc, t3); +end if; +insert into t4 values (2, rc, t3); +end| +call bug1863(10)| +call bug1863(10)| +select * from t4| +f1 rc t3 +2 0 NULL +2 0 NULL +drop procedure bug1863| +drop temporary table temp_t1; +drop table t3, t4| +create table t3 ( +OrderID int not null, +MarketID int, +primary key (OrderID) +)| +create table t4 ( +MarketID int not null, +Market varchar(60), +Status char(1), +primary key (MarketID) +)| +insert t3 (OrderID,MarketID) values (1,1)| +insert t3 (OrderID,MarketID) values (2,2)| +insert t4 (MarketID,Market,Status) values (1,"MarketID One","A")| +insert t4 (MarketID,Market,Status) values (2,"MarketID Two","A")| +drop procedure if exists bug2656_1| +create procedure bug2656_1() +begin +select +m.Market +from t4 m JOIN t3 o +ON o.MarketID != 1 and o.MarketID = m.MarketID; +end | +drop procedure if exists bug2656_2| +create procedure bug2656_2() +begin +select +m.Market +from +t4 m, t3 o +where +m.MarketID != 1 and m.MarketID = o.MarketID; +end | +call bug2656_1()| +Market +MarketID Two +call bug2656_1()| +Market +MarketID Two +call bug2656_2()| +Market +MarketID Two +call bug2656_2()| +Market +MarketID Two +drop procedure bug2656_1| +drop procedure bug2656_2| +drop table t3, t4| +drop procedure if exists bug3426| +create procedure bug3426(in_time int unsigned, out x int) +begin +if in_time is null then +set @stamped_time=10; +set x=1; +else +set @stamped_time=in_time; +set x=2; +end if; +end| +set time_zone='+03:00'; +call bug3426(1000, @i)| +select @i, from_unixtime(@stamped_time, '%d-%m-%Y %h:%i:%s') as time| +@i time +2 01-01-1970 03:16:40 +call bug3426(NULL, @i)| +select @i, from_unixtime(@stamped_time, '%d-%m-%Y %h:%i:%s') as time| +@i time +1 01-01-1970 03:00:10 +alter procedure bug3426 sql security invoker| +call bug3426(NULL, @i)| +select @i, from_unixtime(@stamped_time, '%d-%m-%Y %h:%i:%s') as time| +@i time +1 01-01-1970 03:00:10 +call bug3426(1000, @i)| +select @i, from_unixtime(@stamped_time, '%d-%m-%Y %h:%i:%s') as time| +@i time +2 01-01-1970 03:16:40 +drop procedure bug3426| +create table t3 ( +id int unsigned auto_increment not null primary key, +title VARCHAR(200), +body text, +fulltext (title,body) +)| +insert into t3 (title,body) values +('MySQL Tutorial','DBMS stands for DataBase ...'), +('How To Use MySQL Well','After you went through a ...'), +('Optimizing MySQL','In this tutorial we will show ...'), +('1001 MySQL Tricks','1. Never run mysqld as root. 2. ...'), +('MySQL vs. YourSQL','In the following database comparison ...'), +('MySQL Security','When configured properly, MySQL ...')| +drop procedure if exists bug3734 | +create procedure bug3734 (param1 varchar(100)) +select * from t3 where match (title,body) against (param1)| +call bug3734('database')| +id title body +1 MySQL Tutorial DBMS stands for DataBase ... +5 MySQL vs. YourSQL In the following database comparison ... +call bug3734('Security')| +id title body +6 MySQL Security When configured properly, MySQL ... +drop procedure bug3734| +drop table t3| +drop procedure if exists bug3863| +create procedure bug3863() +begin +set @a = 0; +while @a < 5 do +set @a = @a + 1; +end while; +end| +call bug3863()| +select @a| +@a +5 +call bug3863()| +select @a| +@a +5 +drop procedure bug3863| +create table t3 ( +id int(10) unsigned not null default 0, +rid int(10) unsigned not null default 0, +msg text not null, +primary key (id), +unique key rid (rid, id) +)| +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +drop procedure if exists bug2460_1| +create procedure bug2460_1(in v int) +begin +( select n0.id from t3 as n0 where n0.id = v ) +union +( select n0.id from t3 as n0, t3 as n1 +where n0.id = n1.rid and n1.id = v ) +union +( select n0.id from t3 as n0, t3 as n1, t3 as n2 +where n0.id = n1.rid and n1.id = n2.rid and n2.id = v ); +end| +call bug2460_1(2)| +id +call bug2460_1(2)| +id +insert into t3 values (1, 1, 'foo'), (2, 1, 'bar'), (3, 1, 'zip zap')| +call bug2460_1(2)| +id +2 +1 +call bug2460_1(2)| +id +2 +1 +drop procedure if exists bug2460_2| +create procedure bug2460_2() +begin +drop table if exists t3; +create temporary table t3 (s1 int); +insert into t3 select 1 union select 1; +end| +call bug2460_2()| +call bug2460_2()| +select * from t3| +s1 +1 +drop procedure bug2460_1| +drop procedure bug2460_2| +drop table t3| +set @@sql_mode = ''| +drop procedure if exists bug2564_1| +create procedure bug2564_1() +comment 'Joe''s procedure' + insert into `t1` values ("foo", 1)| +set @@sql_mode = 'ANSI_QUOTES'| +drop procedure if exists bug2564_2| +create procedure bug2564_2() +insert into "t1" values ('foo', 1)| +set @@sql_mode = ''$ +drop function if exists bug2564_3$ +create function bug2564_3(x int, y int) returns int +return x || y$ +Warnings: +Warning 1287 '|| as a synonym for OR' is deprecated and will be removed in a future release. Please use OR instead +set @@sql_mode = 'ANSI'$ +drop function if exists bug2564_4$ +create function bug2564_4(x int, y int) returns int +return x || y$ +set @@sql_mode = ''| +show create procedure bug2564_1| +Procedure sql_mode Create Procedure character_set_client collation_connection Database Collation +bug2564_1 CREATE DEFINER=`root`@`localhost` PROCEDURE `bug2564_1`() + COMMENT 'Joe''s procedure' +insert into `t1` values ("foo", 1) utf8mb4 utf8mb4_0900_ai_ci utf8mb4_0900_ai_ci +show create procedure bug2564_2| +Procedure sql_mode Create Procedure character_set_client collation_connection Database Collation +bug2564_2 ANSI_QUOTES CREATE DEFINER="root"@"localhost" PROCEDURE "bug2564_2"() +insert into "t1" values ('foo', 1) utf8mb4 utf8mb4_0900_ai_ci utf8mb4_0900_ai_ci +show create function bug2564_3| +Function sql_mode Create Function character_set_client collation_connection Database Collation +bug2564_3 CREATE DEFINER=`root`@`localhost` FUNCTION `bug2564_3`(x int, y int) RETURNS int +return x || y utf8mb4 utf8mb4_0900_ai_ci utf8mb4_0900_ai_ci +show create function bug2564_4| +Function sql_mode Create Function character_set_client collation_connection Database Collation +bug2564_4 REAL_AS_FLOAT,PIPES_AS_CONCAT,ANSI_QUOTES,IGNORE_SPACE,ONLY_FULL_GROUP_BY,ANSI CREATE DEFINER="root"@"localhost" FUNCTION "bug2564_4"(x int, y int) RETURNS int +return x || y utf8mb4 utf8mb4_0900_ai_ci utf8mb4_0900_ai_ci +drop procedure bug2564_1| +drop procedure bug2564_2| +drop function bug2564_3| +drop function bug2564_4| +drop function if exists bug3132| +create function bug3132(s char(20)) returns char(50) +return concat('Hello, ', s, '!')| +select bug3132('Bob') union all select bug3132('Judy')| +bug3132('Bob') +Hello, Bob! +Hello, Judy! +drop function bug3132| +drop procedure if exists bug3843| +create procedure bug3843() +analyze table t1| +call bug3843()| +Table Op Msg_type Msg_text +test.t1 analyze status OK +call bug3843()| +Table Op Msg_type Msg_text +test.t1 analyze status Table is already up to date +select 1+2| +1+2 +3 +drop procedure bug3843| +create table t3 ( s1 char(10) )| +insert into t3 values ('a'), ('b')| +drop procedure if exists bug3368| +create procedure bug3368(v char(10)) +begin +select group_concat(v) from t3; +end| +call bug3368('x')| +group_concat(v) +x,x +call bug3368('yz')| +group_concat(v) +yz,yz +drop procedure bug3368| +drop table t3| +create table t3 (f1 int, f2 int)| +insert into t3 values (1,1)| +drop procedure if exists bug4579_1| +create procedure bug4579_1 () +begin +declare sf1 int; +select f1 into sf1 from t3 where f1=1 and f2=1; +update t3 set f2 = f2 + 1 where f1=1 and f2=1; +call bug4579_2(); +end| +drop procedure if exists bug4579_2| +create procedure bug4579_2 () +begin +end| +call bug4579_1()| +call bug4579_1()| +call bug4579_1()| +drop procedure bug4579_1| +drop procedure bug4579_2| +drop table t3| +drop procedure if exists bug2773| +create function bug2773() returns int return null| +create table t3 as select bug2773()| +show create table t3| +Table Create Table +t3 CREATE TABLE `t3` ( + `bug2773()` int DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t3| +drop function bug2773| +drop procedure if exists bug3788| +create function bug3788() returns date return cast("2005-03-04" as date)| +select bug3788()| +bug3788() +2005-03-04 +drop function bug3788| +create function bug3788() returns binary(1) return 5| +select bug3788()| +bug3788() +5 +drop function bug3788| +create table t3 (f1 int, f2 int, f3 int)| +insert into t3 values (1,1,1)| +drop procedure if exists bug4726| +create procedure bug4726() +begin +declare tmp_o_id INT; +declare tmp_d_id INT default 1; +while tmp_d_id <= 2 do +begin +select f1 into tmp_o_id from t3 where f2=1 and f3=1; +set tmp_d_id = tmp_d_id + 1; +end; +end while; +end| +call bug4726()| +call bug4726()| +call bug4726()| +drop procedure bug4726| +drop table t3| +drop procedure if exists bug4902| +set SQL_BIG_SELECTS=1| +create procedure bug4902() +begin +show charset like 'foo'; +show collation like 'foo'; +show create table t1; +show create database test; +show databases like 'foo'; +show errors; +show columns from t1; +show keys from t1; +show open tables like 'foo'; +#show privileges need to be commented as its output differs on different platform +#show privileges; +show status like 'foo'; +show tables like 'foo'; +show variables like 'foo'; +show warnings; +end| +call bug4902()| +Charset Description Default collation Maxlen +Collation Charset Id Default Compiled Sortlen Pad_attribute +Table Create Table +t1 CREATE TABLE `t1` ( + `id` char(16) NOT NULL DEFAULT '', + `data` int NOT NULL +) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +Database Create Database +test CREATE DATABASE `test` /*!40100 DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci */ /*!80016 DEFAULT ENCRYPTION='N' */ +Database (foo) +Level Code Message +Field Type Null Key Default Extra +id char(16) NO +data int NO NULL +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible Expression +Database Table In_use Name_locked +Variable_name Value +Tables_in_test (foo) +Variable_name Value +Level Code Message +call bug4902()| +Charset Description Default collation Maxlen +Collation Charset Id Default Compiled Sortlen Pad_attribute +Table Create Table +t1 CREATE TABLE `t1` ( + `id` char(16) NOT NULL DEFAULT '', + `data` int NOT NULL +) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +Database Create Database +test CREATE DATABASE `test` /*!40100 DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci */ /*!80016 DEFAULT ENCRYPTION='N' */ +Database (foo) +Level Code Message +Field Type Null Key Default Extra +id char(16) NO +data int NO NULL +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible Expression +Database Table In_use Name_locked +Variable_name Value +Tables_in_test (foo) +Variable_name Value +Level Code Message +drop procedure bug4902| +drop procedure if exists bug4904| +create procedure bug4904() +begin +declare continue handler for sqlstate 'HY000' begin end; +create table t2 as select * from t3; +end| +call bug4904()| +ERROR 42S02: Table 'test.t3' doesn't exist +drop procedure bug4904| +create table t3 (s1 char character set latin1, s2 char character set latin2)| +drop procedure if exists bug4904| +create procedure bug4904 () +begin +declare continue handler for sqlstate 'HY000' begin end; +select s1 from t3 union select s2 from t3; +end| +call bug4904()| +drop procedure bug4904| +drop table t3| +drop procedure if exists bug336| +create procedure bug336(out y int) +begin +declare x int; +set x = (select sum(t.data) from test.t1 t); +set y = x; +end| +insert into t1 values ("a", 2), ("b", 3)| +call bug336(@y)| +select @y| +@y +5 +delete from t1| +drop procedure bug336| +drop procedure if exists bug3157| +create procedure bug3157() +begin +if exists(select * from t1) then +set @n= @n + 1; +end if; +if (select count(*) from t1) then +set @n= @n + 1; +end if; +end| +set @n = 0| +insert into t1 values ("a", 1)| +call bug3157()| +select @n| +@n +2 +delete from t1| +drop procedure bug3157| +drop procedure if exists bug5251| +create procedure bug5251() +begin +end| +select created into @c1 from information_schema.routines +where routine_schema='test' and routine_name='bug5251'| +alter procedure bug5251 comment 'foobar'| +select count(*) from information_schema.routines +where routine_schema='test' and routine_name='bug5251' and created = @c1| +count(*) +1 +drop procedure bug5251| +drop procedure if exists bug5251| +create procedure bug5251() +checksum table t1| +call bug5251()| +Table Checksum +test.t1 0 +call bug5251()| +Table Checksum +test.t1 0 +drop procedure bug5251| +drop procedure if exists bug5287| +create procedure bug5287(param1 int) +label1: +begin +declare c cursor for select 5; +loop +if param1 >= 0 then +leave label1; +end if; +end loop; +end| +call bug5287(1)| +drop procedure bug5287| +drop procedure if exists bug5307| +create procedure bug5307() +begin +end; set @x = 3| +call bug5307()| +select @x| +@x +3 +drop procedure bug5307| +drop procedure if exists bug5258| +create procedure bug5258() +begin +end| +drop procedure if exists bug5258_aux| +create procedure bug5258_aux() +begin +declare c, m char(19); +select created,last_altered into c,m from information_schema.routines where routine_name = 'bug5258'; +if c = m then +select 'Ok'; +else +select c, m; +end if; +end| +call bug5258_aux()| +Ok +Ok +drop procedure bug5258| +drop procedure bug5258_aux| +drop function if exists bug4487| +create function bug4487() returns char +begin +declare v char; +return v; +end| +select bug4487()| +bug4487() +NULL +drop function bug4487| +drop procedure if exists bug4941| +drop procedure if exists bug4941| +create procedure bug4941(out x int) +begin +declare c cursor for select i from t2 limit 1; +open c; +fetch c into x; +close c; +end| +insert into t2 values (null, null, null)| +set @x = 42| +call bug4941(@x)| +select @x| +@x +NULL +delete from t1| +drop procedure bug4941| +drop procedure if exists bug4905| +create table t3 (s1 int,primary key (s1))| +drop procedure if exists bug4905| +create procedure bug4905() +begin +declare v int; +declare continue handler for sqlstate '23000' set v = 5; +insert into t3 values (1); +end| +call bug4905()| +select row_count()| +row_count() +1 +call bug4905()| +select row_count()| +row_count() +0 +call bug4905()| +select row_count()| +row_count() +0 +select * from t3| +s1 +1 +drop procedure bug4905| +drop table t3| +drop procedure if exists bug6029| +drop procedure if exists bug6029| +create procedure bug6029() +begin +declare exit handler for 1136 select '1136'; +declare exit handler for sqlstate '23000' select 'sqlstate 23000'; +declare continue handler for sqlexception select 'sqlexception'; +insert into t3 values (1); +insert into t3 values (1,2); +end| +create table t3 (s1 int, primary key (s1))| +insert into t3 values (1)| +call bug6029()| +sqlstate 23000 +sqlstate 23000 +delete from t3| +call bug6029()| +1136 +1136 +drop procedure bug6029| +drop table t3| +drop procedure if exists bug8540| +create procedure bug8540() +begin +declare x int default 1; +select x as y, x+0 as z; +end| +call bug8540()| +y z +1 1 +drop procedure bug8540| +create table t3 (s1 int)| +drop procedure if exists bug6642| +create procedure bug6642() +select abs(count(s1)) from t3| +call bug6642()| +abs(count(s1)) +0 +call bug6642()| +abs(count(s1)) +0 +drop procedure bug6642| +insert into t3 values (0),(1)| +drop procedure if exists bug7013| +create procedure bug7013() +select s1,count(s1) from t3 group by s1 with rollup| +call bug7013()| +s1 count(s1) +0 1 +1 1 +NULL 2 +call bug7013()| +s1 count(s1) +0 1 +1 1 +NULL 2 +drop procedure bug7013| +drop table if exists t4| +create table t4 ( +a mediumint(8) unsigned not null auto_increment, +b smallint(5) unsigned not null, +c char(32) not null, +primary key (a) +) engine=myisam default charset=latin1| +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t4 values (1, 2, 'oneword')| +insert into t4 values (2, 2, 'anotherword')| +drop procedure if exists bug7743| +create procedure bug7743 ( searchstring char(28) ) +begin +declare var mediumint(8) unsigned; +select a into var from t4 where b = 2 and c = binary searchstring limit 1; +show warnings; +select var; +end| +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +call bug7743("oneword")| +Level Code Message +var +1 +call bug7743("OneWord")| +Level Code Message +Warning 1329 No data - zero rows fetched, selected, or processed +var +NULL +call bug7743("anotherword")| +Level Code Message +var +2 +call bug7743("AnotherWord")| +Level Code Message +Warning 1329 No data - zero rows fetched, selected, or processed +var +NULL +drop procedure bug7743| +drop table t4| +delete from t3| +insert into t3 values(1)| +drop procedure if exists bug7992_1| +Warnings: +Note 1305 PROCEDURE test.bug7992_1 does not exist +drop procedure if exists bug7992_2| +Warnings: +Note 1305 PROCEDURE test.bug7992_2 does not exist +create procedure bug7992_1() +begin +declare i int; +select max(s1)+1 into i from t3; +end| +create procedure bug7992_2() +insert into t3 (s1) select max(t4.s1)+1 from t3 as t4| +call bug7992_1()| +call bug7992_1()| +call bug7992_2()| +call bug7992_2()| +drop procedure bug7992_1| +drop procedure bug7992_2| +drop table t3| +create table t3 ( userid bigint(20) not null default 0 )| +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +drop procedure if exists bug8116| +create procedure bug8116(in _userid int) +select * from t3 where userid = _userid| +call bug8116(42)| +userid +call bug8116(42)| +userid +drop procedure bug8116| +drop table t3| +drop procedure if exists bug6857| +create procedure bug6857() +begin +declare t0, t1 int; +declare plus bool default 0; +set t0 = unix_timestamp(); +select sleep(1.1); +set t1 = unix_timestamp(); +if t1 > t0 then +set plus = 1; +end if; +select plus; +end| +call bug6857()| +sleep(1.1) +0 +plus +1 +drop procedure bug6857| +drop procedure if exists bug8757| +create procedure bug8757() +begin +declare x int; +declare c1 cursor for select data from t1 limit 1; +begin +declare y int; +declare c2 cursor for select i from t2 limit 1; +open c2; +fetch c2 into y; +close c2; +select 2,y; +end; +open c1; +fetch c1 into x; +close c1; +select 1,x; +end| +delete from t1| +delete from t2| +insert into t1 values ("x", 1)| +insert into t2 values ("y", 2, 0.0)| +call bug8757()| +2 y +2 2 +1 x +1 1 +delete from t1| +delete from t2| +drop procedure bug8757| +drop procedure if exists bug8762| +drop procedure if exists bug8762; create procedure bug8762() begin end| +drop procedure if exists bug8762; create procedure bug8762() begin end| +drop procedure bug8762| +drop function if exists bug5240| +create function bug5240 () returns int +begin +declare x int; +declare c cursor for select data from t1 limit 1; +open c; +fetch c into x; +close c; +return x; +end| +delete from t1| +insert into t1 values ("answer", 42)| +select id, bug5240() from t1| +id bug5240() +answer 42 +drop function bug5240| +drop procedure if exists p1| +create table t3(id int)| +insert into t3 values(1)| +create procedure bug7992() +begin +declare i int; +select max(id)+1 into i from t3; +end| +call bug7992()| +call bug7992()| +drop procedure bug7992| +drop table t3| +create table t3 ( +lpitnumber int(11) default null, +lrecordtype int(11) default null +)| +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +create table t4 ( +lbsiid int(11) not null default '0', +ltradingmodeid int(11) not null default '0', +ltradingareaid int(11) not null default '0', +csellingprice decimal(19,4) default null, +primary key (lbsiid,ltradingmodeid,ltradingareaid) +)| +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +create table t5 ( +lbsiid int(11) not null default '0', +ltradingareaid int(11) not null default '0', +primary key (lbsiid,ltradingareaid) +)| +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +drop procedure if exists bug8849| +create procedure bug8849() +begin +insert into t5 +( +t5.lbsiid, +t5.ltradingareaid +) +select distinct t3.lpitnumber, t4.ltradingareaid +from +t4 join t3 on +t3.lpitnumber = t4.lbsiid +and t3.lrecordtype = 1 +left join t4 as price01 on +price01.lbsiid = t4.lbsiid and +price01.ltradingmodeid = 1 and +t4.ltradingareaid = price01.ltradingareaid; +end| +call bug8849()| +call bug8849()| +call bug8849()| +drop procedure bug8849| +drop tables t3,t4,t5| +drop procedure if exists bug8937| +create procedure bug8937() +begin +declare s,x,y,z int; +declare a float; +select sum(data),avg(data),min(data),max(data) into s,x,y,z from t1; +select s,x,y,z; +select avg(data) into a from t1; +select a; +end| +delete from t1| +insert into t1 (data) values (1), (2), (3), (4), (6)| +call bug8937()| +s x y z +16 3 1 6 +a +3.2 +drop procedure bug8937| +delete from t1| +drop procedure if exists bug6900| +drop procedure if exists bug9074| +drop procedure if exists bug6900_9074| +create table t3 (w char unique, x char)| +insert into t3 values ('a', 'b')| +create procedure bug6900() +begin +declare exit handler for sqlexception select '1'; +begin +declare exit handler for sqlexception select '2'; +insert into t3 values ('x', 'y', 'z'); +end; +end| +create procedure bug9074() +begin +declare x1, x2, x3, x4, x5, x6 int default 0; +begin +declare continue handler for sqlstate '23000' set x5 = 1; +insert into t3 values ('a', 'b'); +set x6 = 1; +end; +begin1_label: +begin +declare continue handler for sqlstate '23000' set x1 = 1; +insert into t3 values ('a', 'b'); +set x2 = 1; +begin2_label: +begin +declare exit handler for sqlstate '23000' set x3 = 1; +set x4= 1; +insert into t3 values ('a','b'); +set x4= 0; +end begin2_label; +end begin1_label; +select x1, x2, x3, x4, x5, x6; +end| +create procedure bug6900_9074(z int) +begin +declare exit handler for sqlstate '23000' select '23000'; +begin +declare exit handler for sqlexception select 'sqlexception'; +if z = 1 then +insert into t3 values ('a', 'b'); +else +insert into t3 values ('x', 'y', 'z'); +end if; +end; +end| +call bug6900()| +2 +2 +call bug9074()| +x1 x2 x3 x4 x5 x6 +1 1 1 1 1 1 +call bug6900_9074(0)| +sqlexception +sqlexception +call bug6900_9074(1)| +sqlexception +sqlexception +drop procedure bug6900| +drop procedure bug9074| +drop procedure bug6900_9074| +drop table t3| +drop procedure if exists avg| +create procedure avg () +begin +end| +call avg ()| +drop procedure avg| +drop procedure if exists bug6129| +set @old_mode= @@sql_mode; +set @@sql_mode= "ERROR_FOR_DIVISION_BY_ZERO"; +create procedure bug6129() +select @@sql_mode| +call bug6129()| +@@sql_mode +ERROR_FOR_DIVISION_BY_ZERO +set @@sql_mode= "STRICT_ALL_TABLES,NO_ZERO_DATE"| +Warnings: +Warning 3135 'NO_ZERO_DATE', 'NO_ZERO_IN_DATE' and 'ERROR_FOR_DIVISION_BY_ZERO' sql modes should be used with strict mode. They will be merged with strict mode in a future release. +call bug6129()| +@@sql_mode +ERROR_FOR_DIVISION_BY_ZERO +set @@sql_mode= "NO_ZERO_IN_DATE"| +Warnings: +Warning 3135 'NO_ZERO_DATE', 'NO_ZERO_IN_DATE' and 'ERROR_FOR_DIVISION_BY_ZERO' sql modes should be used with strict mode. They will be merged with strict mode in a future release. +call bug6129()| +@@sql_mode +ERROR_FOR_DIVISION_BY_ZERO +set @@sql_mode=@old_mode; +drop procedure bug6129| +drop procedure if exists bug9856| +create procedure bug9856() +begin +declare v int; +declare c cursor for select data from t1; +declare exit handler for sqlexception, not found select '16'; +open c; +fetch c into v; +select v; +end| +delete from t1| +call bug9856()| +16 +16 +call bug9856()| +16 +16 +drop procedure bug9856| +drop procedure if exists bug9674_1| +drop procedure if exists bug9674_2| +create procedure bug9674_1(out arg int) +begin +declare temp_in1 int default 0; +declare temp_fl1 int default 0; +set temp_in1 = 100; +set temp_fl1 = temp_in1/10; +set arg = temp_fl1; +end| +create procedure bug9674_2() +begin +declare v int default 100; +select v/10; +end| +call bug9674_1(@sptmp)| +call bug9674_1(@sptmp)| +select @sptmp| +@sptmp +10 +call bug9674_2()| +v/10 +10.0000 +call bug9674_2()| +v/10 +10.0000 +drop procedure bug9674_1| +drop procedure bug9674_2| +drop procedure if exists bug9598_1| +drop procedure if exists bug9598_2| +create procedure bug9598_1(in var_1 char(16), +out var_2 integer, out var_3 integer) +begin +set var_2 = 50; +set var_3 = 60; +end| +create procedure bug9598_2(in v1 char(16), +in v2 integer, +in v3 integer, +in v4 integer, +in v5 integer) +begin +select v1,v2,v3,v4,v5; +call bug9598_1(v1,@tmp1,@tmp2); +select v1,v2,v3,v4,v5; +end| +call bug9598_2('Test',2,3,4,5)| +v1 v2 v3 v4 v5 +Test 2 3 4 5 +v1 v2 v3 v4 v5 +Test 2 3 4 5 +select @tmp1, @tmp2| +@tmp1 @tmp2 +50 60 +drop procedure bug9598_1| +drop procedure bug9598_2| +drop function if exists bug9102| +create function bug9102() returns blob return 'a'| +select bug9102()| +bug9102() +a +drop function bug9102| +drop function if exists bug7648| +create function bug7648() returns bit(8) return 'a'| +select bug7648()| +bug7648() +a +drop function bug7648| +drop function if exists bug9775| +create function bug9775(v1 char(1)) returns enum('a','b') return v1| +select bug9775('a'),bug9775('b'),bug9775('c')| +bug9775('a') bug9775('b') bug9775('c') +a b +Warnings: +Warning 1265 Data truncated for column 'bug9775('c')' at row 1 +drop function bug9775| +create function bug9775(v1 int) returns enum('a','b') return v1| +select bug9775(1),bug9775(2),bug9775(3)| +bug9775(1) bug9775(2) bug9775(3) +a b +Warnings: +Warning 1265 Data truncated for column 'bug9775(3)' at row 1 +drop function bug9775| +create function bug9775(v1 char(1)) returns set('a','b') return v1| +select bug9775('a'),bug9775('b'),bug9775('a,b'),bug9775('c')| +bug9775('a') bug9775('b') bug9775('a,b') bug9775('c') +a b a +Warnings: +Warning 1265 Data truncated for column 'v1' at row 1 +Warning 1265 Data truncated for column 'bug9775('c')' at row 1 +drop function bug9775| +create function bug9775(v1 int) returns set('a','b') return v1| +select bug9775(1),bug9775(2),bug9775(3),bug9775(4)| +bug9775(1) bug9775(2) bug9775(3) bug9775(4) +a b a,b +Warnings: +Warning 1265 Data truncated for column 'bug9775(4)' at row 1 +drop function bug9775| +drop function if exists bug8861| +create function bug8861(v1 int) returns year return v1| +select bug8861(05)| +bug8861(05) +2005 +set @x = bug8861(05)| +select @x| +@x +2005 +drop function bug8861| +drop procedure if exists bug9004_1| +drop procedure if exists bug9004_2| +create procedure bug9004_1(x char(16)) +begin +insert into t1 values (x, 42); +insert into t1 values (x, 17); +end| +create procedure bug9004_2(x char(16)) +call bug9004_1(x)| +call bug9004_1('12345678901234567')| +Warnings: +Warning 1265 Data truncated for column 'x' at row 1 +call bug9004_2('12345678901234567890')| +Warnings: +Warning 1265 Data truncated for column 'x' at row 1 +delete from t1| +drop procedure bug9004_1| +drop procedure bug9004_2| +drop procedure if exists bug7293| +insert into t1 values ('secret', 0)| +create procedure bug7293(p1 varchar(100)) +begin +if exists (select id from t1 where soundex(p1)=soundex(id)) then +select 'yes'; +end if; +end;| +call bug7293('secret')| +yes +yes +call bug7293 ('secrete')| +yes +yes +drop procedure bug7293| +delete from t1| +drop procedure if exists bug9841| +drop view if exists v1| +create view v1 as select * from t1, t2 where id = s| +create procedure bug9841 () +update v1 set data = 10| +call bug9841()| +drop view v1| +drop procedure bug9841| +drop procedure if exists bug5963| +create procedure bug5963_1 () begin declare v int; set v = (select s1 from t3); select v; end;| +create table t3 (s1 int)| +insert into t3 values (5)| +call bug5963_1()| +v +5 +call bug5963_1()| +v +5 +drop procedure bug5963_1| +drop table t3| +create procedure bug5963_2 (cfk_value int) +begin +if cfk_value in (select cpk from t3) then +set @x = 5; +end if; +end; +| +create table t3 (cpk int)| +insert into t3 values (1)| +call bug5963_2(1)| +call bug5963_2(1)| +drop procedure bug5963_2| +drop table t3| +drop function if exists bug9559| +create function bug9559() +returns int +begin +set @y = -6/2; +return @y; +end| +select bug9559()| +bug9559() +-3 +drop function bug9559| +drop procedure if exists bug10961| +create procedure bug10961() +begin +declare v char; +declare x int; +declare c cursor for select * from dual; +declare continue handler for sqlexception select x; +set x = 1; +open c; +set x = 2; +fetch c into v; +set x = 3; +close c; +end| +call bug10961()| +x +1 +x +2 +x +3 +call bug10961()| +x +1 +x +2 +x +3 +drop procedure bug10961| +DROP PROCEDURE IF EXISTS bug6866| +DROP VIEW IF EXISTS tv| +Warnings: +Note 1051 Unknown table 'test.tv' +DROP TABLE IF EXISTS tt1,tt2,tt3| +Warnings: +Note 1051 Unknown table 'test.tt1' +Note 1051 Unknown table 'test.tt2' +Note 1051 Unknown table 'test.tt3' +CREATE TABLE tt1 (a1 int, a2 int, a3 int, data varchar(10))| +CREATE TABLE tt2 (a2 int, data2 varchar(10))| +CREATE TABLE tt3 (a3 int, data3 varchar(10))| +INSERT INTO tt1 VALUES (1, 1, 4, 'xx')| +INSERT INTO tt2 VALUES (1, 'a')| +INSERT INTO tt2 VALUES (2, 'b')| +INSERT INTO tt2 VALUES (3, 'c')| +INSERT INTO tt3 VALUES (4, 'd')| +INSERT INTO tt3 VALUES (5, 'e')| +INSERT INTO tt3 VALUES (6, 'f')| +CREATE VIEW tv AS +SELECT tt1.*, tt2.data2, tt3.data3 +FROM tt1 INNER JOIN tt2 ON tt1.a2 = tt2.a2 +LEFT JOIN tt3 ON tt1.a3 = tt3.a3 +ORDER BY tt1.a1, tt2.a2, tt3.a3| +CREATE PROCEDURE bug6866 (_a1 int) +BEGIN +SELECT * FROM tv WHERE a1 = _a1; +END| +CALL bug6866(1)| +a1 a2 a3 data data2 data3 +1 1 4 xx a d +CALL bug6866(1)| +a1 a2 a3 data data2 data3 +1 1 4 xx a d +CALL bug6866(1)| +a1 a2 a3 data data2 data3 +1 1 4 xx a d +DROP PROCEDURE bug6866; +DROP VIEW tv| +DROP TABLE tt1, tt2, tt3| +DROP PROCEDURE IF EXISTS bug10136| +create table t3 ( name char(5) not null primary key, val float not null)| +insert into t3 values ('aaaaa', 1), ('bbbbb', 2), ('ccccc', 3)| +create procedure bug10136() +begin +declare done int default 3; +repeat +select * from t3; +set done = done - 1; +until done <= 0 end repeat; +end| +call bug10136()| +name val +aaaaa 1 +bbbbb 2 +ccccc 3 +name val +aaaaa 1 +bbbbb 2 +ccccc 3 +name val +aaaaa 1 +bbbbb 2 +ccccc 3 +call bug10136()| +name val +aaaaa 1 +bbbbb 2 +ccccc 3 +name val +aaaaa 1 +bbbbb 2 +ccccc 3 +name val +aaaaa 1 +bbbbb 2 +ccccc 3 +call bug10136()| +name val +aaaaa 1 +bbbbb 2 +ccccc 3 +name val +aaaaa 1 +bbbbb 2 +ccccc 3 +name val +aaaaa 1 +bbbbb 2 +ccccc 3 +drop procedure bug10136| +drop table t3| +drop procedure if exists bug11529| +create procedure bug11529() +begin +declare c cursor for select id, data from t1 where data in (10,13); +open c; +begin +declare vid char(16); +declare vdata int; +declare exit handler for not found begin end; +while true do +fetch c into vid, vdata; +end while; +end; +close c; +end| +insert into t1 values +('Name1', 10), +('Name2', 11), +('Name3', 12), +('Name4', 13), +('Name5', 14)| +call bug11529()| +call bug11529()| +delete from t1| +drop procedure bug11529| +set character set utf8| +drop procedure if exists bug6063| +drop procedure if exists bug7088_1| +drop procedure if exists bug7088_2| +create procedure bug6063() +begin +lâbel: begin end; +label: begin end; +label1: begin end; +end| +create procedure bug7088_1() +label1: begin end label1| +create procedure bug7088_2() +läbel1: begin end| +call bug6063()| +call bug7088_1()| +call bug7088_2()| +set character set default| +show create procedure bug6063| +Procedure sql_mode Create Procedure character_set_client collation_connection Database Collation +bug6063 CREATE DEFINER=`root`@`localhost` PROCEDURE `bug6063`() +begin +lâbel: begin end; +label: begin end; +label1: begin end; +end utf8 utf8mb4_0900_ai_ci utf8mb4_0900_ai_ci +show create procedure bug7088_1| +Procedure sql_mode Create Procedure character_set_client collation_connection Database Collation +bug7088_1 CREATE DEFINER=`root`@`localhost` PROCEDURE `bug7088_1`() +label1: begin end label1 utf8 utf8mb4_0900_ai_ci utf8mb4_0900_ai_ci +show create procedure bug7088_2| +Procedure sql_mode Create Procedure character_set_client collation_connection Database Collation +bug7088_2 CREATE DEFINER=`root`@`localhost` PROCEDURE `bug7088_2`() +läbel1: begin end utf8 utf8mb4_0900_ai_ci utf8mb4_0900_ai_ci +drop procedure bug6063| +drop procedure bug7088_1| +drop procedure bug7088_2| +drop procedure if exists bug9565_sub| +drop procedure if exists bug9565| +create procedure bug9565_sub() +begin +select * from t1; +end| +create procedure bug9565() +begin +insert into t1 values ("one", 1); +call bug9565_sub(); +end| +call bug9565()| +id data +one 1 +delete from t1| +drop procedure bug9565_sub| +drop procedure bug9565| +drop procedure if exists bug9538| +create procedure bug9538() +set @@sort_buffer_size = 1000000| +set @x = @@sort_buffer_size| +set @@sort_buffer_size = 2000000| +select @@sort_buffer_size| +@@sort_buffer_size +2000000 +call bug9538()| +select @@sort_buffer_size| +@@sort_buffer_size +1000000 +set @@sort_buffer_size = @x| +drop procedure bug9538| +drop procedure if exists bug8692| +create table t3 (c1 varchar(5), c2 char(5), c3 enum('one','two'), c4 text, c5 blob, c6 char(5), c7 varchar(5))| +insert into t3 values ('', '', '', '', '', '', NULL)| +Warnings: +Warning 1265 Data truncated for column 'c3' at row 1 +create procedure bug8692() +begin +declare v1 VARCHAR(10); +declare v2 VARCHAR(10); +declare v3 VARCHAR(10); +declare v4 VARCHAR(10); +declare v5 VARCHAR(10); +declare v6 VARCHAR(10); +declare v7 VARCHAR(10); +declare c8692 cursor for select c1,c2,c3,c4,c5,c6,c7 from t3; +open c8692; +fetch c8692 into v1,v2,v3,v4,v5,v6,v7; +select v1, v2, v3, v4, v5, v6, v7; +end| +call bug8692()| +v1 v2 v3 v4 v5 v6 v7 + NULL +drop procedure bug8692| +drop table t3| +drop function if exists bug10055| +create function bug10055(v char(255)) returns char(255) return lower(v)| +select t.column_name, bug10055(t.column_name) +from information_schema.columns as t +where t.table_schema = 'test' and t.table_name = 't1' +order by t.column_name| +COLUMN_NAME bug10055(t.column_name) +data data +id id +drop function bug10055| +drop procedure if exists bug12297| +create procedure bug12297(lim int) +begin +set @x = 0; +repeat +insert into t1(id,data) +values('aa', @x); +set @x = @x + 1; +until @x >= lim +end repeat; +end| +call bug12297(10)| +drop procedure bug12297| +drop function if exists f_bug11247| +drop procedure if exists p_bug11247| +create function f_bug11247(param int) +returns int +return param + 1| +create procedure p_bug11247(lim int) +begin +declare v int default 0; +while v < lim do +set v= f_bug11247(v); +end while; +end| +call p_bug11247(10)| +drop function f_bug11247| +drop procedure p_bug11247| +drop procedure if exists bug12168| +drop table if exists t3, t4| +create table t3 (a int)| +insert into t3 values (1),(2),(3),(4)| +create table t4 (a int)| +create procedure bug12168(arg1 char(1)) +begin +declare b, c integer; +if arg1 = 'a' then +begin +declare c1 cursor for select a from t3 where a % 2; +declare continue handler for not found set b = 1; +set b = 0; +open c1; +c1_repeat: repeat +fetch c1 into c; +if (b = 1) then +leave c1_repeat; +end if; +insert into t4 values (c); +until b = 1 +end repeat; +end; +end if; +if arg1 = 'b' then +begin +declare c2 cursor for select a from t3 where not a % 2; +declare continue handler for not found set b = 1; +set b = 0; +open c2; +c2_repeat: repeat +fetch c2 into c; +if (b = 1) then +leave c2_repeat; +end if; +insert into t4 values (c); +until b = 1 +end repeat; +end; +end if; +end| +call bug12168('a')| +select * from t4| +a +1 +3 +truncate t4| +call bug12168('b')| +select * from t4| +a +2 +4 +truncate t4| +call bug12168('a')| +select * from t4| +a +1 +3 +truncate t4| +call bug12168('b')| +select * from t4| +a +2 +4 +truncate t4| +drop table t3, t4| +drop procedure if exists bug12168| +drop table if exists t3| +drop procedure if exists bug11333| +create table t3 (c1 char(128))| +insert into t3 values +('AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA')| +create procedure bug11333(i int) +begin +declare tmp varchar(128); +set @x = 0; +repeat +select c1 into tmp from t3 +where c1 = 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA'; +set @x = @x + 1; +until @x >= i +end repeat; +end| +call bug11333(10)| +drop procedure bug11333| +drop table t3| +drop function if exists bug9048| +create function bug9048(f1 char binary) returns char +begin +set f1= concat( 'hello', f1 ); +return f1; +end| +Warnings: +Warning 1287 'BINARY as attribute of a type' is deprecated and will be removed in a future release. Please use a CHARACTER SET clause with _bin collation instead +drop function bug9048| +create function bug9048(f1 char binary) returns char binary +begin +set f1= concat( 'hello', f1 ); +return f1; +end| +ERROR 42000: This version of MySQL doesn't yet support 'return value collation' +drop procedure if exists bug12849_1| +create procedure bug12849_1(inout x char) select x into x| +set @var='a'| +call bug12849_1(@var)| +select @var| +@var +a +drop procedure bug12849_1| +drop procedure if exists bug12849_2| +create procedure bug12849_2(inout foo varchar(15)) +begin +select concat(foo, foo) INTO foo; +end| +set @var='abcd'| +call bug12849_2(@var)| +select @var| +@var +abcdabcd +drop procedure bug12849_2| +drop procedure if exists bug131333| +drop function if exists bug131333| +create procedure bug131333() +begin +begin +declare a int; +select a; +set a = 1; +select a; +end; +begin +declare b int; +select b; +end; +end| +create function bug131333() +returns int +begin +begin +declare a int; +set a = 1; +end; +begin +declare b int; +return b; +end; +end| +call bug131333()| +a +NULL +a +1 +b +NULL +select bug131333()| +bug131333() +NULL +drop procedure bug131333| +drop function bug131333| +drop function if exists bug12379| +drop procedure if exists bug12379_1| +drop procedure if exists bug12379_2| +drop procedure if exists bug12379_3| +drop table if exists t3| +create table t3 (c1 char(1) primary key not null)| +create function bug12379() +returns integer +begin +insert into t3 values('X'); +insert into t3 values('X'); +return 0; +end| +create procedure bug12379_1() +begin +declare exit handler for sqlexception select 42; +select bug12379(); +END| +create procedure bug12379_2() +begin +declare exit handler for sqlexception begin end; +select bug12379(); +end| +create procedure bug12379_3() +begin +select bug12379(); +end| +select bug12379()| +ERROR 23000: Duplicate entry 'X' for key 't3.PRIMARY' +select 1| +1 +1 +call bug12379_1()| +bug12379() +42 +42 +select 2| +2 +2 +call bug12379_2()| +bug12379() +select 3| +3 +3 +call bug12379_3()| +ERROR 23000: Duplicate entry 'X' for key 't3.PRIMARY' +select 4| +4 +4 +drop function bug12379| +drop procedure bug12379_1| +drop procedure bug12379_2| +drop procedure bug12379_3| +drop table t3| +drop procedure if exists bug13124| +create procedure bug13124() +begin +declare y integer; +set @x=y; +end| +call bug13124()| +drop procedure bug13124| +drop procedure if exists bug12979_1| +create procedure bug12979_1(inout d decimal(5)) set d = d / 2| +set @bug12979_user_var = NULL| +call bug12979_1(@bug12979_user_var)| +drop procedure bug12979_1| +drop procedure if exists bug12979_2| +create procedure bug12979_2() +begin +declare internal_var decimal(5); +set internal_var= internal_var / 2; +select internal_var; +end| +call bug12979_2()| +internal_var +NULL +drop procedure bug12979_2| +drop table if exists t3| +drop procedure if exists bug6127| +create table t3 (s1 int unique)| +set @sm=@@sql_mode| +set sql_mode='traditional'| +create procedure bug6127() +begin +declare continue handler for sqlstate '23000' + begin +declare continue handler for sqlstate '22003' + insert into t3 values (0); +insert into t3 values (1000000000000000); +end; +insert into t3 values (1); +insert into t3 values (1); +end| +call bug6127()| +select * from t3| +s1 +0 +1 +call bug6127()| +ERROR 23000: Duplicate entry '0' for key 't3.s1' +select * from t3| +s1 +0 +1 +set sql_mode=@sm| +drop table t3| +drop procedure bug6127| +drop procedure if exists bug12589_1| +drop procedure if exists bug12589_2| +drop procedure if exists bug12589_3| +create procedure bug12589_1() +begin +declare spv1 decimal(3,3); +set spv1= 123.456; +set spv1 = 'test'; +create temporary table tm1 as select spv1; +show create table tm1; +drop temporary table tm1; +end| +create procedure bug12589_2() +begin +declare spv1 decimal(6,3); +set spv1= 123.456; +create temporary table tm1 as select spv1; +show create table tm1; +drop temporary table tm1; +end| +create procedure bug12589_3() +begin +declare spv1 decimal(6,3); +set spv1= -123.456; +create temporary table tm1 as select spv1; +show create table tm1; +drop temporary table tm1; +end| +call bug12589_1()| +Table Create Table +tm1 CREATE TEMPORARY TABLE `tm1` ( + `spv1` decimal(3,3) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +call bug12589_2()| +Table Create Table +tm1 CREATE TEMPORARY TABLE `tm1` ( + `spv1` decimal(6,3) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +call bug12589_3()| +Table Create Table +tm1 CREATE TEMPORARY TABLE `tm1` ( + `spv1` decimal(6,3) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop procedure bug12589_1| +drop procedure bug12589_2| +drop procedure bug12589_3| +drop table if exists t3| +drop procedure if exists bug7049_1| +drop procedure if exists bug7049_2| +drop procedure if exists bug7049_3| +drop procedure if exists bug7049_4| +drop function if exists bug7049_1| +drop function if exists bug7049_2| +create table t3 ( x int unique )| +create procedure bug7049_1() +begin +insert into t3 values (42); +insert into t3 values (42); +end| +create procedure bug7049_2() +begin +declare exit handler for sqlexception +select 'Caught it' as 'Result'; +call bug7049_1(); +select 'Missed it' as 'Result'; +end| +create procedure bug7049_3() +call bug7049_1()| +create procedure bug7049_4() +begin +declare exit handler for sqlexception +select 'Caught it' as 'Result'; +call bug7049_3(); +select 'Missed it' as 'Result'; +end| +create function bug7049_1() +returns int +begin +insert into t3 values (42); +insert into t3 values (42); +return 42; +end| +create function bug7049_2() +returns int +begin +declare x int default 0; +declare continue handler for sqlexception +set x = 1; +set x = bug7049_1(); +return x; +end| +call bug7049_2()| +Result +Caught it +select * from t3| +x +42 +delete from t3| +call bug7049_4()| +Result +Caught it +select * from t3| +x +42 +select bug7049_2()| +bug7049_2() +1 +drop table t3| +drop procedure bug7049_1| +drop procedure bug7049_2| +drop procedure bug7049_3| +drop procedure bug7049_4| +drop function bug7049_1| +drop function bug7049_2| +drop function if exists bug13941| +drop procedure if exists bug13941| +create function bug13941(p_input_str text) +returns text +begin +declare p_output_str text; +set p_output_str = p_input_str; +set p_output_str = replace(p_output_str, 'xyzzy', 'plugh'); +set p_output_str = replace(p_output_str, 'test', 'prova'); +set p_output_str = replace(p_output_str, 'this', 'questo'); +set p_output_str = replace(p_output_str, ' a ', 'una '); +set p_output_str = replace(p_output_str, 'is', ''); +return p_output_str; +end| +create procedure bug13941(out sout varchar(128)) +begin +set sout = 'Local'; +set sout = ifnull(sout, 'DEF'); +end| +select bug13941('this is a test')| +bug13941('this is a test') +questo una prova +call bug13941(@a)| +select @a| +@a +Local +drop function bug13941| +drop procedure bug13941| +DROP PROCEDURE IF EXISTS bug13095; +DROP TABLE IF EXISTS bug13095_t1; +DROP VIEW IF EXISTS bug13095_v1; +CREATE PROCEDURE bug13095(tbl_name varchar(32)) +BEGIN +SET @str = +CONCAT("CREATE TABLE ", tbl_name, "(stuff char(15))"); +SELECT @str; +PREPARE stmt FROM @str; +EXECUTE stmt; +SET @str = +CONCAT("INSERT INTO ", tbl_name, " VALUES('row1'),('row2'),('row3')" ); +SELECT @str; +PREPARE stmt FROM @str; +EXECUTE stmt; +SET @str = +CONCAT("CREATE VIEW bug13095_v1(c1) AS SELECT stuff FROM ", tbl_name); +SELECT @str; +PREPARE stmt FROM @str; +EXECUTE stmt; +SELECT * FROM bug13095_v1; +SET @str = +"DROP VIEW bug13095_v1"; +SELECT @str; +PREPARE stmt FROM @str; +EXECUTE stmt; +END| +CALL bug13095('bug13095_t1'); +@str +CREATE TABLE bug13095_t1(stuff char(15)) +@str +INSERT INTO bug13095_t1 VALUES('row1'),('row2'),('row3') +@str +CREATE VIEW bug13095_v1(c1) AS SELECT stuff FROM bug13095_t1 +c1 +row1 +row2 +row3 +@str +DROP VIEW bug13095_v1 +DROP PROCEDURE IF EXISTS bug13095; +DROP VIEW IF EXISTS bug13095_v1; +DROP TABLE IF EXISTS bug13095_t1; +drop function if exists bug14723| +drop procedure if exists bug14723| +/*!50003 create function bug14723() +returns bigint(20) +main_loop: begin +return 42; +end */;; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +show create function bug14723;; +Function sql_mode Create Function character_set_client collation_connection Database Collation +bug14723 CREATE DEFINER=`root`@`localhost` FUNCTION `bug14723`() RETURNS bigint +main_loop: begin +return 42; +end utf8mb4 utf8mb4_0900_ai_ci utf8mb4_0900_ai_ci +select bug14723();; +bug14723() +42 +/*!50003 create procedure bug14723() +main_loop: begin +select 42; +end */;; +show create procedure bug14723;; +Procedure sql_mode Create Procedure character_set_client collation_connection Database Collation +bug14723 CREATE DEFINER=`root`@`localhost` PROCEDURE `bug14723`() +main_loop: begin +select 42; +end utf8mb4 utf8mb4_0900_ai_ci utf8mb4_0900_ai_ci +call bug14723();; +42 +42 +drop function bug14723| +drop procedure bug14723| +create procedure bug14845() +begin +declare a char(255); +declare done int default 0; +declare c cursor for select count(*) from t1 where 1 = 0; +declare continue handler for sqlstate '02000' set done = 1; +open c; +repeat +fetch c into a; +if not done then +select a; +end if; +until done end repeat; +close c; +end| +call bug14845()| +a +0 +drop procedure bug14845| +drop procedure if exists bug13549_1| +drop procedure if exists bug13549_2| +CREATE PROCEDURE `bug13549_2`() +begin +call bug13549_1(); +end| +CREATE PROCEDURE `bug13549_1`() +begin +declare done int default 0; +set done= not done; +end| +CALL bug13549_2()| +drop procedure bug13549_2| +drop procedure bug13549_1| +drop function if exists bug10100f| +drop procedure if exists bug10100p| +drop procedure if exists bug10100t| +drop procedure if exists bug10100pt| +drop procedure if exists bug10100pv| +drop procedure if exists bug10100pd| +drop procedure if exists bug10100pc| +create function bug10100f(prm int) returns int +begin +if prm > 1 then +return prm * bug10100f(prm - 1); +end if; +return 1; +end| +create procedure bug10100p(prm int, inout res int) +begin +set res = res * prm; +if prm > 1 then +call bug10100p(prm - 1, res); +end if; +end| +create procedure bug10100t(prm int) +begin +declare res int; +set res = 1; +call bug10100p(prm, res); +select res; +end| +create table t3 (a int)| +insert into t3 values (0)| +create view v1 as select a from t3| +create procedure bug10100pt(level int, lim int) +begin +if level < lim then +update t3 set a=level; +FLUSH TABLES; +call bug10100pt(level+1, lim); +else +select * from t3; +end if; +end| +create procedure bug10100pv(level int, lim int) +begin +if level < lim then +update v1 set a=level; +FLUSH TABLES; +call bug10100pv(level+1, lim); +else +select * from v1; +end if; +end| +prepare stmt2 from "select * from t3;"| +create procedure bug10100pd(level int, lim int) +begin +if level < lim then +select level; +prepare stmt1 from "update t3 set a=a+2"; +execute stmt1; +FLUSH TABLES; +execute stmt1; +FLUSH TABLES; +execute stmt1; +FLUSH TABLES; +deallocate prepare stmt1; +execute stmt2; +select * from t3; +call bug10100pd(level+1, lim); +else +execute stmt2; +end if; +end| +create procedure bug10100pc(level int, lim int) +begin +declare lv int; +declare c cursor for select a from t3; +open c; +if level < lim then +select level; +fetch c into lv; +select lv; +update t3 set a=level+lv; +FLUSH TABLES; +call bug10100pc(level+1, lim); +else +select * from t3; +end if; +close c; +end| +set @@max_sp_recursion_depth=4| +select @@max_sp_recursion_depth| +@@max_sp_recursion_depth +4 +select bug10100f(3)| +ERROR HY000: Recursive stored functions and triggers are not allowed. +select bug10100f(6)| +ERROR HY000: Recursive stored functions and triggers are not allowed. +call bug10100t(5)| +res +120 +call bug10100pt(1,5)| +a +4 +call bug10100pv(1,5)| +a +4 +update t3 set a=1| +call bug10100pd(1,5)| +level +1 +a +7 +a +7 +level +2 +a +13 +a +13 +level +3 +a +19 +a +19 +level +4 +a +25 +a +25 +a +25 +select * from t3| +a +25 +update t3 set a=1| +call bug10100pc(1,5)| +level +1 +lv +1 +level +2 +lv +2 +level +3 +lv +4 +level +4 +lv +7 +a +11 +select * from t3| +a +11 +set @@max_sp_recursion_depth=0| +select @@max_sp_recursion_depth| +@@max_sp_recursion_depth +0 +select bug10100f(5)| +ERROR HY000: Recursive stored functions and triggers are not allowed. +call bug10100t(5)| +ERROR HY000: Recursive limit 0 (as set by the max_sp_recursion_depth variable) was exceeded for routine bug10100p +deallocate prepare stmt2| +drop function bug10100f| +drop procedure bug10100p| +drop procedure bug10100t| +drop procedure bug10100pt| +drop procedure bug10100pv| +drop procedure bug10100pd| +drop procedure bug10100pc| +drop view v1| +drop procedure if exists bug13729| +drop table if exists t3| +create table t3 (s1 int, primary key (s1))| +insert into t3 values (1),(2)| +create procedure bug13729() +begin +declare continue handler for sqlexception select 55; +update t3 set s1 = 1; +end| +call bug13729()| +55 +55 +select * from t3| +s1 +1 +2 +drop procedure bug13729| +drop table t3| +drop procedure if exists bug14643_1| +drop procedure if exists bug14643_2| +create procedure bug14643_1() +begin +declare continue handler for sqlexception select 'boo' as 'Handler'; +begin +declare v int default undefined_var; +if v = 1 then +select 1; +else +select v, isnull(v); +end if; +end; +end| +create procedure bug14643_2() +begin +declare continue handler for sqlexception select 'boo' as 'Handler'; +case undefined_var +when 1 then +select 1; +else +select 2; +end case; +select undefined_var; +end| +call bug14643_1()| +Handler +boo +v isnull(v) +NULL 1 +call bug14643_2()| +Handler +boo +Handler +boo +drop procedure bug14643_1| +drop procedure bug14643_2| +drop procedure if exists bug14304| +drop table if exists t3, t4| +create table t3(a int primary key auto_increment)| +create table t4(a int primary key auto_increment)| +create procedure bug14304() +begin +insert into t3 set a=null; +insert into t4 set a=null; +insert into t4 set a=null; +insert into t4 set a=null; +insert into t4 set a=null; +insert into t4 set a=null; +insert into t4 select null as a; +insert into t3 set a=null; +insert into t3 set a=null; +select * from t3; +end| +call bug14304()| +a +1 +2 +3 +drop procedure bug14304| +drop table t3, t4| +drop procedure if exists bug14376| +create procedure bug14376() +begin +declare x int default x; +end| +call bug14376()| +ERROR 42S22: Unknown column 'x' in 'field list' +drop procedure bug14376| +create procedure bug14376() +begin +declare x int default 42; +begin +declare x int default x; +select x; +end; +end| +call bug14376()| +x +42 +drop procedure bug14376| +create procedure bug14376(x int) +begin +declare x int default x; +select x; +end| +call bug14376(4711)| +x +4711 +drop procedure bug14376| +drop procedure if exists bug5967| +drop table if exists t3| +create table t3 (a varchar(255)) engine=myisam| +insert into t3 (a) values ("a - table column")| +create procedure bug5967(a varchar(255)) +begin +declare i varchar(255); +declare c cursor for select a from t3; +select a; +select a from t3 into i; +select i as 'Parameter takes precedence over table column'; open c; +fetch c into i; +close c; +select i as 'Parameter takes precedence over table column in cursors'; +begin +declare a varchar(255) default 'a - local variable'; +declare c1 cursor for select a from t3; +select a as 'A local variable takes precedence over parameter'; +open c1; +fetch c1 into i; +close c1; +select i as 'A local variable takes precedence over parameter in cursors'; +begin +declare a varchar(255) default 'a - local variable in a nested compound statement'; +declare c2 cursor for select a from t3; +select a as 'A local variable in a nested compound statement takes precedence over a local variable in the outer statement'; +select a from t3 into i; +select i as 'A local variable in a nested compound statement takes precedence over table column'; +open c2; +fetch c2 into i; +close c2; +select i as 'A local variable in a nested compound statement takes precedence over table column in cursors'; +end; +end; +end| +call bug5967("a - stored procedure parameter")| +a +a - stored procedure parameter +Parameter takes precedence over table column +a - stored procedure parameter +Parameter takes precedence over table column in cursors +a - stored procedure parameter +A local variable takes precedence over parameter +a - local variable +A local variable takes precedence over parameter in cursors +a - local variable +A local variable in a nested compound statement takes precedence over a local variable in the outer statement +a - local variable in a nested compound statement +A local variable in a nested compound statement takes precedence over table column +a - local variable in a nested compound statement +A local variable in a nested compound statement takes precedence over table column in cursors +a - local variable in a nested compound statement +drop procedure bug5967| +drop procedure if exists bug13012| +create procedure bug13012() +BEGIN +REPAIR TABLE t1; +END| +call bug13012()| +Table Op Msg_type Msg_text +test.t1 repair status OK +drop procedure bug13012| +create view v1 as select * from t1| +create procedure bug13012() +BEGIN +REPAIR TABLE t1,t2,t3,v1; +OPTIMIZE TABLE t1,t2,t3,v1; +ANALYZE TABLE t1,t2,t3,v1; +END| +call bug13012()| +Table Op Msg_type Msg_text +test.t1 repair status OK +test.t2 repair status OK +test.t3 repair status OK +test.v1 repair Error 'test.v1' is not BASE TABLE +test.v1 repair status Operation failed +Table Op Msg_type Msg_text +test.t1 optimize status OK +test.t2 optimize status OK +test.t3 optimize status OK +test.v1 optimize Error 'test.v1' is not BASE TABLE +test.v1 optimize status Operation failed +Table Op Msg_type Msg_text +test.t1 analyze status Table is already up to date +test.t2 analyze status Table is already up to date +test.t3 analyze status Table is already up to date +test.v1 analyze Error 'test.v1' is not BASE TABLE +test.v1 analyze status Operation failed +call bug13012()| +Table Op Msg_type Msg_text +test.t1 repair status OK +test.t2 repair status OK +test.t3 repair status OK +test.v1 repair Error 'test.v1' is not BASE TABLE +test.v1 repair status Operation failed +Table Op Msg_type Msg_text +test.t1 optimize status OK +test.t2 optimize status OK +test.t3 optimize status OK +test.v1 optimize Error 'test.v1' is not BASE TABLE +test.v1 optimize status Operation failed +Table Op Msg_type Msg_text +test.t1 analyze status Table is already up to date +test.t2 analyze status Table is already up to date +test.t3 analyze status Table is already up to date +test.v1 analyze Error 'test.v1' is not BASE TABLE +test.v1 analyze status Operation failed +call bug13012()| +Table Op Msg_type Msg_text +test.t1 repair status OK +test.t2 repair status OK +test.t3 repair status OK +test.v1 repair Error 'test.v1' is not BASE TABLE +test.v1 repair status Operation failed +Table Op Msg_type Msg_text +test.t1 optimize status OK +test.t2 optimize status OK +test.t3 optimize status OK +test.v1 optimize Error 'test.v1' is not BASE TABLE +test.v1 optimize status Operation failed +Table Op Msg_type Msg_text +test.t1 analyze status Table is already up to date +test.t2 analyze status Table is already up to date +test.t3 analyze status Table is already up to date +test.v1 analyze Error 'test.v1' is not BASE TABLE +test.v1 analyze status Operation failed +drop procedure bug13012| +drop view v1| +select * from t1 order by data| +id data +aa 0 +aa 1 +aa 2 +aa 3 +aa 4 +aa 5 +aa 6 +aa 7 +aa 8 +aa 9 +drop schema if exists mysqltest1| +Warnings: +Note 1008 Can't drop database 'mysqltest1'; database doesn't exist +drop schema if exists mysqltest2| +Warnings: +Note 1008 Can't drop database 'mysqltest2'; database doesn't exist +drop schema if exists mysqltest3| +Warnings: +Note 1008 Can't drop database 'mysqltest3'; database doesn't exist +create schema mysqltest1| +create schema mysqltest2| +create schema mysqltest3| +use mysqltest3| +create procedure mysqltest1.p1 (out prequestid varchar(100)) +begin +call mysqltest2.p2('call mysqltest3.p3(1, 2)'); +end| +create procedure mysqltest2.p2(in psql text) +begin +declare lsql text; +set @lsql= psql; +prepare lstatement from @lsql; +execute lstatement; +deallocate prepare lstatement; +end| +create procedure mysqltest3.p3(in p1 int) +begin +select p1; +end| +call mysqltest1.p1(@rs)| +ERROR 42000: Incorrect number of arguments for PROCEDURE mysqltest3.p3; expected 1, got 2 +call mysqltest1.p1(@rs)| +ERROR 42000: Incorrect number of arguments for PROCEDURE mysqltest3.p3; expected 1, got 2 +call mysqltest1.p1(@rs)| +ERROR 42000: Incorrect number of arguments for PROCEDURE mysqltest3.p3; expected 1, got 2 +drop schema if exists mysqltest1| +drop schema if exists mysqltest2| +drop schema if exists mysqltest3| +use test| +drop table if exists t3| +drop procedure if exists bug15441| +create table t3 (id int not null primary key, county varchar(25))| +insert into t3 (id, county) values (1, 'York')| +create procedure bug15441(c varchar(25)) +begin +update t3 set id=2, county=values(c); +end| +call bug15441('county')| +ERROR 42S22: Unknown column 'c' in 'field list' +drop procedure bug15441| +create procedure bug15441(county varchar(25)) +begin +declare c varchar(25) default "hello"; +insert into t3 (id, county) values (1, county) +on duplicate key update county= values(county); +select * from t3; +update t3 set id=2, county=values(id); +select * from t3; +end| +call bug15441('Yale')| +id county +1 Yale +id county +2 NULL +drop table t3| +drop procedure bug15441| +drop procedure if exists bug14498_1| +drop procedure if exists bug14498_2| +drop procedure if exists bug14498_3| +drop procedure if exists bug14498_4| +drop procedure if exists bug14498_5| +create procedure bug14498_1() +begin +declare continue handler for sqlexception select 'error' as 'Handler'; +if v then +select 'yes' as 'v'; +else +select 'no' as 'v'; +end if; +select 'done' as 'End'; +end| +create procedure bug14498_2() +begin +declare continue handler for sqlexception select 'error' as 'Handler'; +while v do +select 'yes' as 'v'; +end while; +select 'done' as 'End'; +end| +create procedure bug14498_3() +begin +declare continue handler for sqlexception select 'error' as 'Handler'; +repeat +select 'maybe' as 'v'; +until v end repeat; +select 'done' as 'End'; +end| +create procedure bug14498_4() +begin +declare continue handler for sqlexception select 'error' as 'Handler'; +case v +when 1 then +select '1' as 'v'; +when 2 then +select '2' as 'v'; +else +select '?' as 'v'; +end case; +select 'done' as 'End'; +end| +create procedure bug14498_5() +begin +declare continue handler for sqlexception select 'error' as 'Handler'; +case +when v = 1 then +select '1' as 'v'; +when v = 2 then +select '2' as 'v'; +else +select '?' as 'v'; +end case; +select 'done' as 'End'; +end| +call bug14498_1()| +Handler +error +End +done +call bug14498_2()| +Handler +error +End +done +call bug14498_3()| +v +maybe +Handler +error +End +done +call bug14498_4()| +Handler +error +End +done +call bug14498_5()| +Handler +error +End +done +drop procedure bug14498_1| +drop procedure bug14498_2| +drop procedure bug14498_3| +drop procedure bug14498_4| +drop procedure bug14498_5| +drop table if exists t3| +drop procedure if exists bug15231_1| +drop procedure if exists bug15231_2| +drop procedure if exists bug15231_3| +drop procedure if exists bug15231_4| +drop procedure if exists bug15231_5| +drop procedure if exists bug15231_6| +create table t3 (id int not null)| +create procedure bug15231_1() +begin +declare xid integer; +declare xdone integer default 0; +declare continue handler for not found set xdone = 1; +set xid=null; +call bug15231_2(xid); +select xid, xdone; +end| +create procedure bug15231_2(inout ioid integer) +begin +select "Before NOT FOUND condition is triggered" as '1'; +select id into ioid from t3 where id=ioid; +select "After NOT FOUND condtition is triggered" as '2'; +if ioid is null then +set ioid=1; +end if; +end| +create procedure bug15231_3() +begin +declare exit handler for sqlwarning +select 'Caught it (correct)' as 'Result'; +call bug15231_4(); +end| +create procedure bug15231_4() +begin +declare x decimal(2,1); +set x = 'zap'; +select 'Missed it (correct)' as 'Result'; +show warnings; +end| +create procedure bug15231_5() +begin +declare exit handler for sqlwarning +select 'Caught it (wrong)' as 'Result'; +call bug15231_6(); +end| +create procedure bug15231_6() +begin +declare x decimal(2,1); +set x = 'zap'; +select 'Missed it (correct)' as 'Result'; +select id from t3; +end| +call bug15231_1()| +1 +Before NOT FOUND condition is triggered +2 +After NOT FOUND condtition is triggered +xid xdone +1 0 +call bug15231_3()| +Result +Missed it (correct) +Level Code Message +call bug15231_5()| +Result +Missed it (correct) +id +drop table t3| +drop procedure bug15231_1| +drop procedure bug15231_2| +drop procedure bug15231_3| +drop procedure bug15231_4| +drop procedure bug15231_5| +drop procedure bug15231_6| +drop procedure if exists bug15011| +create table t3 (c1 int primary key)| +insert into t3 values (1)| +create procedure bug15011() +deterministic +begin +declare continue handler for 1062 +select 'Outer' as 'Handler'; +begin +declare continue handler for 1062 +select 'Inner' as 'Handler'; +insert into t3 values (1); +end; +end| +call bug15011()| +Handler +Inner +drop procedure bug15011| +drop table t3| +drop procedure if exists bug17476| +create table t3 ( d date )| +insert into t3 values +( '2005-01-01' ), ( '2005-01-02' ), ( '2005-01-03' ), +( '2005-01-04' ), ( '2005-02-01' ), ( '2005-02-02' )| +create procedure bug17476(pDateFormat varchar(10)) +select date_format(t3.d, pDateFormat), count(*) +from t3 +group by date_format(t3.d, pDateFormat)| +call bug17476('%Y-%m')| +date_format(t3.d, pDateFormat) count(*) +2005-01 4 +2005-02 2 +call bug17476('%Y-%m')| +date_format(t3.d, pDateFormat) count(*) +2005-01 4 +2005-02 2 +drop table t3| +drop procedure bug17476| +drop table if exists t3| +drop procedure if exists bug16887| +create table t3 ( c varchar(1) )| +insert into t3 values +(' '),('.'),(';'),(','),('-'),('_'),('('),(')'),('/'),('\\')| +create procedure bug16887() +begin +declare i int default 10; +again: +while i > 0 do +begin +declare breakchar varchar(1); +declare done int default 0; +declare t3_cursor cursor for select c from t3; +declare continue handler for not found set done = 1; +set i = i - 1; +select i; +if i = 3 then +iterate again; +end if; +open t3_cursor; +loop +fetch t3_cursor into breakchar; +if done = 1 then +begin +close t3_cursor; +iterate again; +end; +end if; +end loop; +end; +end while; +end| +call bug16887()| +i +9 +i +8 +i +7 +i +6 +i +5 +i +4 +i +3 +i +2 +i +1 +i +0 +drop table t3| +drop procedure bug16887| +drop procedure if exists bug16474_1| +drop procedure if exists bug16474_2| +delete from t1| +insert into t1 values ('c', 2), ('b', 3), ('a', 1)| +create procedure bug16474_1() +begin +declare x int; +select id from t1 order by x, id; +end| +drop procedure if exists bug14945| +create table t3 (id int not null auto_increment primary key)| +create procedure bug14945() deterministic truncate t3| +insert into t3 values (null)| +call bug14945()| +insert into t3 values (null)| +select * from t3| +id +1 +drop table t3| +drop procedure bug14945| +create procedure bug16474_2(x int) +select id from t1 order by x, id| +call bug16474_1()| +id +a +b +c +call bug16474_2(1)| +id +a +b +c +call bug16474_2(2)| +id +a +b +c +drop procedure bug16474_1| +drop procedure bug16474_2| +set @x = 2| +select * from t1 order by @x, data| +id data +a 1 +c 2 +b 3 +delete from t1| +drop function if exists bug15728| +drop table if exists t3| +create table t3 ( +id int not null auto_increment, +primary key (id) +)| +create function bug15728() returns int(11) +return last_insert_id()| +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t3 values (0)| +select last_insert_id()| +last_insert_id() +1 +select bug15728()| +bug15728() +1 +drop function bug15728| +drop table t3| +drop procedure if exists bug18787| +create procedure bug18787() +begin +declare continue handler for sqlexception begin end; +select no_such_function(); +end| +call bug18787()| +drop procedure bug18787| +create database bug18344_012345678901| +use bug18344_012345678901| +create procedure bug18344() begin end| +create procedure bug18344_2() begin end| +create database bug18344_0123456789012| +use bug18344_0123456789012| +create procedure bug18344() begin end| +create procedure bug18344_2() begin end| +use test| +select schema_name from information_schema.schemata where +schema_name like 'bug18344%'| +SCHEMA_NAME +bug18344_012345678901 +bug18344_0123456789012 +select routine_name,routine_schema from information_schema.routines where +routine_schema like 'bug18344%'| +ROUTINE_NAME ROUTINE_SCHEMA +bug18344 bug18344_012345678901 +bug18344 bug18344_0123456789012 +bug18344_2 bug18344_012345678901 +bug18344_2 bug18344_0123456789012 +drop database bug18344_012345678901| +drop database bug18344_0123456789012| +select schema_name from information_schema.schemata where +schema_name like 'bug18344%'| +SCHEMA_NAME +select routine_name,routine_schema from information_schema.routines where +routine_schema like 'bug18344%'| +ROUTINE_NAME ROUTINE_SCHEMA +drop function if exists bug12472| +create function bug12472() returns int return (select count(*) from t1)| +create table t3 as select bug12472() as i| +show create table t3| +Table Create Table +t3 CREATE TABLE `t3` ( + `i` int DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +select * from t3| +i +0 +drop table t3| +create view v1 as select bug12472() as j| +create table t3 as select * from v1| +show create table t3| +Table Create Table +t3 CREATE TABLE `t3` ( + `j` int DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +select * from t3| +j +0 +drop table t3| +drop view v1| +drop function bug12472| +DROP FUNCTION IF EXISTS bug18589_f1| +DROP PROCEDURE IF EXISTS bug18589_p1| +DROP PROCEDURE IF EXISTS bug18589_p2| +CREATE FUNCTION bug18589_f1(arg TEXT) RETURNS TEXT +BEGIN +RETURN CONCAT(arg, ""); +END| +CREATE PROCEDURE bug18589_p1(arg TEXT, OUT ret TEXT) +BEGIN +SET ret = CONCAT(arg, ""); +END| +CREATE PROCEDURE bug18589_p2(arg TEXT) +BEGIN +DECLARE v TEXT; +CALL bug18589_p1(arg, v); +SELECT v; +END| +SELECT bug18589_f1(REPEAT("a", 767))| +bug18589_f1(REPEAT("a", 767)) +aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa +SET @bug18589_v1 = ""| +CALL bug18589_p1(REPEAT("a", 767), @bug18589_v1)| +SELECT @bug18589_v1| +@bug18589_v1 +aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa +CALL bug18589_p2(REPEAT("a", 767))| +v +aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa +DROP FUNCTION bug18589_f1| +DROP PROCEDURE bug18589_p1| +DROP PROCEDURE bug18589_p2| +DROP FUNCTION IF EXISTS bug18037_f1| +DROP PROCEDURE IF EXISTS bug18037_p1| +DROP PROCEDURE IF EXISTS bug18037_p2| +CREATE FUNCTION bug18037_f1() RETURNS INT +BEGIN +RETURN @@server_id; +END| +CREATE PROCEDURE bug18037_p1() +BEGIN +DECLARE v INT DEFAULT @@server_id; +END| +CREATE PROCEDURE bug18037_p2() +BEGIN +CASE @@server_id +WHEN -1 THEN +SELECT 0; +ELSE +SELECT 1; +END CASE; +END| +SELECT bug18037_f1()| +bug18037_f1() +1 +CALL bug18037_p1()| +CALL bug18037_p2()| +1 +1 +DROP FUNCTION bug18037_f1| +DROP PROCEDURE bug18037_p1| +DROP PROCEDURE bug18037_p2| +use test| +create table t3 (i int)| +insert into t3 values (1), (2)| +create database mysqltest1| +use mysqltest1| +create function bug17199() returns varchar(2) deterministic return 'ok'| +use test| +select *, mysqltest1.bug17199() from t3| +i mysqltest1.bug17199() +1 ok +2 ok +use mysqltest1| +create function bug18444(i int) returns int no sql deterministic return i + 1| +use test| +select mysqltest1.bug18444(i) from t3| +mysqltest1.bug18444(i) +2 +3 +drop database mysqltest1| +create database mysqltest1 charset=utf8| +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +create database mysqltest2 charset=utf8| +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +create procedure mysqltest1.p1() +begin +-- alters the default collation of database test +alter database character set koi8r; +end| +use mysqltest1| +call p1()| +show create database mysqltest1| +Database Create Database +mysqltest1 CREATE DATABASE `mysqltest1` /*!40100 DEFAULT CHARACTER SET koi8r */ /*!80016 DEFAULT ENCRYPTION='N' */ +show create database mysqltest2| +Database Create Database +mysqltest2 CREATE DATABASE `mysqltest2` /*!40100 DEFAULT CHARACTER SET utf8 */ /*!80016 DEFAULT ENCRYPTION='N' */ +alter database mysqltest1 character set utf8| +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +use mysqltest2| +call mysqltest1.p1()| +show create database mysqltest1| +Database Create Database +mysqltest1 CREATE DATABASE `mysqltest1` /*!40100 DEFAULT CHARACTER SET koi8r */ /*!80016 DEFAULT ENCRYPTION='N' */ +show create database mysqltest2| +Database Create Database +mysqltest2 CREATE DATABASE `mysqltest2` /*!40100 DEFAULT CHARACTER SET utf8 */ /*!80016 DEFAULT ENCRYPTION='N' */ +drop database mysqltest1| +drop database mysqltest2| +use test| +drop table if exists t3| +drop procedure if exists bug15217| +create table t3 as select 1| +create procedure bug15217() +begin +declare var1 char(255); +declare cur1 cursor for select * from t3; +open cur1; +fetch cur1 into var1; +select concat('data was: /', var1, '/'); +close cur1; +end | +call bug15217()| +concat('data was: /', var1, '/') +data was: /1/ +flush tables | +call bug15217()| +concat('data was: /', var1, '/') +data was: /1/ +drop table t3| +drop procedure bug15217| +DROP PROCEDURE IF EXISTS bug21013 | +CREATE PROCEDURE bug21013(IN lim INT) +BEGIN +DECLARE i INT DEFAULT 0; +WHILE (i < lim) DO +SET @b = LOCATE(_latin1'b', @a, 1); +SET i = i + 1; +END WHILE; +END | +SET @a = _latin2"aaaaaaaaaa" | +CALL bug21013(10) | +DROP PROCEDURE bug21013 | +DROP DATABASE IF EXISTS mysqltest1| +DROP DATABASE IF EXISTS mysqltest2| +CREATE DATABASE mysqltest1 DEFAULT CHARACTER SET utf8| +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +CREATE DATABASE mysqltest2 DEFAULT CHARACTER SET utf8| +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +use mysqltest1| +CREATE FUNCTION bug16211_f1() RETURNS CHAR(10) +RETURN ""| +CREATE FUNCTION bug16211_f2() RETURNS CHAR(10) CHARSET koi8r +RETURN ""| +CREATE FUNCTION mysqltest2.bug16211_f3() RETURNS CHAR(10) +RETURN ""| +CREATE FUNCTION mysqltest2.bug16211_f4() RETURNS CHAR(10) CHARSET koi8r +RETURN ""| +SHOW CREATE FUNCTION bug16211_f1| +Function sql_mode Create Function character_set_client collation_connection Database Collation +bug16211_f1 CREATE DEFINER=`root`@`localhost` FUNCTION `bug16211_f1`() RETURNS char(10) CHARSET utf8 +RETURN "" utf8mb4 utf8mb4_0900_ai_ci utf8_general_ci +SHOW CREATE FUNCTION bug16211_f2| +Function sql_mode Create Function character_set_client collation_connection Database Collation +bug16211_f2 CREATE DEFINER=`root`@`localhost` FUNCTION `bug16211_f2`() RETURNS char(10) CHARSET koi8r +RETURN "" utf8mb4 utf8mb4_0900_ai_ci utf8_general_ci +SHOW CREATE FUNCTION mysqltest2.bug16211_f3| +Function sql_mode Create Function character_set_client collation_connection Database Collation +bug16211_f3 CREATE DEFINER=`root`@`localhost` FUNCTION `bug16211_f3`() RETURNS char(10) CHARSET utf8 +RETURN "" utf8mb4 utf8mb4_0900_ai_ci utf8_general_ci +SHOW CREATE FUNCTION mysqltest2.bug16211_f4| +Function sql_mode Create Function character_set_client collation_connection Database Collation +bug16211_f4 CREATE DEFINER=`root`@`localhost` FUNCTION `bug16211_f4`() RETURNS char(10) CHARSET koi8r +RETURN "" utf8mb4 utf8mb4_0900_ai_ci utf8_general_ci +SELECT dtd_identifier +FROM INFORMATION_SCHEMA.ROUTINES +WHERE ROUTINE_SCHEMA = "mysqltest1" AND ROUTINE_NAME = "bug16211_f1"| +DTD_IDENTIFIER +char(10) +SELECT dtd_identifier +FROM INFORMATION_SCHEMA.ROUTINES +WHERE ROUTINE_SCHEMA = "mysqltest1" AND ROUTINE_NAME = "bug16211_f2"| +DTD_IDENTIFIER +char(10) +SELECT dtd_identifier +FROM INFORMATION_SCHEMA.ROUTINES +WHERE ROUTINE_SCHEMA = "mysqltest2" AND ROUTINE_NAME = "bug16211_f3"| +DTD_IDENTIFIER +char(10) +SELECT dtd_identifier +FROM INFORMATION_SCHEMA.ROUTINES +WHERE ROUTINE_SCHEMA = "mysqltest2" AND ROUTINE_NAME = "bug16211_f4"| +DTD_IDENTIFIER +char(10) +SELECT CHARSET(bug16211_f1())| +CHARSET(bug16211_f1()) +utf8mb3 +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +SELECT CHARSET(bug16211_f2())| +CHARSET(bug16211_f2()) +koi8r +SELECT CHARSET(mysqltest2.bug16211_f3())| +CHARSET(mysqltest2.bug16211_f3()) +utf8mb3 +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +SELECT CHARSET(mysqltest2.bug16211_f4())| +CHARSET(mysqltest2.bug16211_f4()) +koi8r +ALTER DATABASE mysqltest1 CHARACTER SET cp1251| +ALTER DATABASE mysqltest2 CHARACTER SET cp1251| +SHOW CREATE FUNCTION bug16211_f1| +Function sql_mode Create Function character_set_client collation_connection Database Collation +bug16211_f1 CREATE DEFINER=`root`@`localhost` FUNCTION `bug16211_f1`() RETURNS char(10) CHARSET utf8 +RETURN "" utf8mb4 utf8mb4_0900_ai_ci utf8_general_ci +SHOW CREATE FUNCTION bug16211_f2| +Function sql_mode Create Function character_set_client collation_connection Database Collation +bug16211_f2 CREATE DEFINER=`root`@`localhost` FUNCTION `bug16211_f2`() RETURNS char(10) CHARSET koi8r +RETURN "" utf8mb4 utf8mb4_0900_ai_ci utf8_general_ci +SHOW CREATE FUNCTION mysqltest2.bug16211_f3| +Function sql_mode Create Function character_set_client collation_connection Database Collation +bug16211_f3 CREATE DEFINER=`root`@`localhost` FUNCTION `bug16211_f3`() RETURNS char(10) CHARSET utf8 +RETURN "" utf8mb4 utf8mb4_0900_ai_ci utf8_general_ci +SHOW CREATE FUNCTION mysqltest2.bug16211_f4| +Function sql_mode Create Function character_set_client collation_connection Database Collation +bug16211_f4 CREATE DEFINER=`root`@`localhost` FUNCTION `bug16211_f4`() RETURNS char(10) CHARSET koi8r +RETURN "" utf8mb4 utf8mb4_0900_ai_ci utf8_general_ci +SELECT dtd_identifier +FROM INFORMATION_SCHEMA.ROUTINES +WHERE ROUTINE_SCHEMA = "mysqltest1" AND ROUTINE_NAME = "bug16211_f1"| +DTD_IDENTIFIER +char(10) +SELECT dtd_identifier +FROM INFORMATION_SCHEMA.ROUTINES +WHERE ROUTINE_SCHEMA = "mysqltest1" AND ROUTINE_NAME = "bug16211_f2"| +DTD_IDENTIFIER +char(10) +SELECT dtd_identifier +FROM INFORMATION_SCHEMA.ROUTINES +WHERE ROUTINE_SCHEMA = "mysqltest2" AND ROUTINE_NAME = "bug16211_f3"| +DTD_IDENTIFIER +char(10) +SELECT dtd_identifier +FROM INFORMATION_SCHEMA.ROUTINES +WHERE ROUTINE_SCHEMA = "mysqltest2" AND ROUTINE_NAME = "bug16211_f4"| +DTD_IDENTIFIER +char(10) +SELECT CHARSET(bug16211_f1())| +CHARSET(bug16211_f1()) +utf8mb3 +SELECT CHARSET(bug16211_f2())| +CHARSET(bug16211_f2()) +koi8r +SELECT CHARSET(mysqltest2.bug16211_f3())| +CHARSET(mysqltest2.bug16211_f3()) +utf8mb3 +SELECT CHARSET(mysqltest2.bug16211_f4())| +CHARSET(mysqltest2.bug16211_f4()) +koi8r +use test| +DROP DATABASE mysqltest1| +DROP DATABASE mysqltest2| +CREATE DATABASE mysqltest1 DEFAULT CHARACTER SET utf8| +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +use mysqltest1| +CREATE PROCEDURE bug16676_p1( +IN p1 CHAR(10), +INOUT p2 CHAR(10), +OUT p3 CHAR(10)) +BEGIN +SELECT CHARSET(p1), COLLATION(p1); +SELECT CHARSET(p2), COLLATION(p2); +SELECT CHARSET(p3), COLLATION(p3); +END| +CREATE PROCEDURE bug16676_p2( +IN p1 CHAR(10) CHARSET koi8r, +INOUT p2 CHAR(10) CHARSET cp1251, +OUT p3 CHAR(10) CHARSET greek) +BEGIN +SELECT CHARSET(p1), COLLATION(p1); +SELECT CHARSET(p2), COLLATION(p2); +SELECT CHARSET(p3), COLLATION(p3); +END| +SET @v2 = 'b'| +SET @v3 = 'c'| +CALL bug16676_p1('a', @v2, @v3)| +CHARSET(p1) COLLATION(p1) +utf8mb3 utf8_general_ci +CHARSET(p2) COLLATION(p2) +utf8mb3 utf8_general_ci +CHARSET(p3) COLLATION(p3) +utf8mb3 utf8_general_ci +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +CALL bug16676_p2('a', @v2, @v3)| +CHARSET(p1) COLLATION(p1) +koi8r koi8r_general_ci +CHARSET(p2) COLLATION(p2) +cp1251 cp1251_general_ci +CHARSET(p3) COLLATION(p3) +greek greek_general_ci +use test| +DROP DATABASE mysqltest1| +drop table if exists t3| +drop table if exists t4| +drop procedure if exists bug8153_subselect| +drop procedure if exists bug8153_subselect_a| +drop procedure if exists bug8153_subselect_b| +drop procedure if exists bug8153_proc_a| +drop procedure if exists bug8153_proc_b| +create table t3 (a int)| +create table t4 (a int)| +insert into t3 values (1), (1), (2), (3)| +insert into t4 values (1), (1)| +create procedure bug8153_subselect() +begin +declare continue handler for sqlexception +begin +select 'statement failed'; +end; +update t3 set a=a+1 where (select a from t4 where a=1) is null; +select 'statement after update'; +end| +call bug8153_subselect()| +statement failed +statement failed +statement after update +statement after update +select * from t3| +a +1 +1 +2 +3 +call bug8153_subselect()| +statement failed +statement failed +statement after update +statement after update +select * from t3| +a +1 +1 +2 +3 +drop procedure bug8153_subselect| +create procedure bug8153_subselect_a() +begin +declare continue handler for sqlexception +begin +select 'in continue handler'; +end; +select 'reachable code a1'; +call bug8153_subselect_b(); +select 'reachable code a2'; +end| +create procedure bug8153_subselect_b() +begin +select 'reachable code b1'; +update t3 set a=a+1 where (select a from t4 where a=1) is null; +select 'unreachable code b2'; +end| +call bug8153_subselect_a()| +reachable code a1 +reachable code a1 +reachable code b1 +reachable code b1 +in continue handler +in continue handler +reachable code a2 +reachable code a2 +select * from t3| +a +1 +1 +2 +3 +call bug8153_subselect_a()| +reachable code a1 +reachable code a1 +reachable code b1 +reachable code b1 +in continue handler +in continue handler +reachable code a2 +reachable code a2 +select * from t3| +a +1 +1 +2 +3 +drop procedure bug8153_subselect_a| +drop procedure bug8153_subselect_b| +create procedure bug8153_proc_a() +begin +declare continue handler for sqlexception +begin +select 'in continue handler'; +end; +select 'reachable code a1'; +call bug8153_proc_b(); +select 'reachable code a2'; +end| +create procedure bug8153_proc_b() +begin +select 'reachable code b1'; +select no_such_function(); +select 'unreachable code b2'; +end| +call bug8153_proc_a()| +reachable code a1 +reachable code a1 +reachable code b1 +reachable code b1 +in continue handler +in continue handler +reachable code a2 +reachable code a2 +drop procedure bug8153_proc_a| +drop procedure bug8153_proc_b| +drop table t3| +drop table t4| +drop procedure if exists bug19862| +CREATE TABLE t11 (a INT)| +CREATE TABLE t12 (a INT)| +CREATE FUNCTION bug19862(x INT) RETURNS INT +BEGIN +INSERT INTO t11 VALUES (x); +RETURN x+1; +END| +INSERT INTO t12 VALUES (1), (2)| +SELECT bug19862(a) FROM t12 ORDER BY 1| +bug19862(a) +2 +3 +SELECT * FROM t11| +a +1 +2 +DROP TABLE t11, t12| +DROP FUNCTION bug19862| +drop table if exists t3| +drop database if exists mysqltest1| +create table t3 (a int)| +insert into t3 (a) values (1), (2)| +create database mysqltest1| +use mysqltest1| +drop database mysqltest1| +select database()| +database() +NULL +select * from (select 1 as a) as t1 natural join (select * from test.t3) as t2| +a +1 +use test| +drop table t3| +DROP PROCEDURE IF EXISTS bug16899_p1| +DROP FUNCTION IF EXISTS bug16899_f1| +CREATE DEFINER=1234567890abcdefGHIKLsdafdsjakfhkshfkshsndvkjsddngjhasdkjghskahfdksjhcnsndkhjkghskjfjsdhfkhskfdhksjdhfkjshfksh@localhost PROCEDURE bug16899_p1() +BEGIN +SET @a = 1; +END| +ERROR HY000: String '1234567890abcdefGHIKLsdafdsjakfhkshfkshsndvkjsddngjhasdkjghskahfdksjhc' is too long for user name (should be no longer than 32) +CREATE DEFINER=some_user_name@host_1234567890abcdefghij1234567890abcdefghij1234567890abcdefghij1234567890abcdefghij1234567890abcdefghij1234567890abcdefghij1234567890abcdefghij1234567890abcdefghij1234567890abcdefghij1234567890abcdefghij1234567890abcdefghij1234567890abcdefghij1234567890X +FUNCTION bug16899_f1() RETURNS INT +BEGIN +RETURN 1; +END| +ERROR HY000: String 'host_1234567890abcdefghij1234567890abcdefghij1234567890abcdefghij12345' is too long for host name (should be no longer than 255) +drop procedure if exists bug21416| +create procedure bug21416() show create procedure bug21416| +call bug21416()| +Procedure sql_mode Create Procedure character_set_client collation_connection Database Collation +bug21416 CREATE DEFINER=`root`@`localhost` PROCEDURE `bug21416`() +show create procedure bug21416 utf8mb4 utf8mb4_0900_ai_ci utf8mb4_0900_ai_ci +drop procedure bug21416| +DROP PROCEDURE IF EXISTS bug21414| +CREATE PROCEDURE bug21414() SELECT 1| +FLUSH TABLES WITH READ LOCK| +DROP PROCEDURE bug21414| +ERROR HY000: Can't execute the query because you have a conflicting read lock +UNLOCK TABLES| +The following should succeed. +DROP PROCEDURE bug21414| +CREATE TABLE t3 ( +Member_ID varchar(15) NOT NULL, +PRIMARY KEY (Member_ID) +)| +CREATE TABLE t4 ( +ID int(10) unsigned NOT NULL auto_increment, +Member_ID varchar(15) NOT NULL default '', +Action varchar(12) NOT NULL, +Action_Date datetime NOT NULL, +Track varchar(15) default NULL, +User varchar(12) default NULL, +Date_Updated timestamp NOT NULL default CURRENT_TIMESTAMP on update +CURRENT_TIMESTAMP, +PRIMARY KEY (ID), +KEY Action (Action), +KEY Action_Date (Action_Date) +)| +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t3(Member_ID) VALUES +('111111'), ('222222'), ('333333'), ('444444'), ('555555'), ('666666')| +INSERT INTO t4(Member_ID, Action, Action_Date, Track) VALUES +('111111', 'Disenrolled', '2006-03-01', 'CAD' ), +('111111', 'Enrolled', '2006-03-01', 'CAD' ), +('111111', 'Disenrolled', '2006-07-03', 'CAD' ), +('222222', 'Enrolled', '2006-03-07', 'CAD' ), +('222222', 'Enrolled', '2006-03-07', 'CHF' ), +('222222', 'Disenrolled', '2006-08-02', 'CHF' ), +('333333', 'Enrolled', '2006-03-01', 'CAD' ), +('333333', 'Disenrolled', '2006-03-01', 'CAD' ), +('444444', 'Enrolled', '2006-03-01', 'CAD' ), +('555555', 'Disenrolled', '2006-03-01', 'CAD' ), +('555555', 'Enrolled', '2006-07-21', 'CAD' ), +('555555', 'Disenrolled', '2006-03-01', 'CHF' ), +('666666', 'Enrolled', '2006-02-09', 'CAD' ), +('666666', 'Enrolled', '2006-05-12', 'CHF' ), +('666666', 'Disenrolled', '2006-06-01', 'CAD' )| +DROP FUNCTION IF EXISTS bug21493| +CREATE FUNCTION bug21493(paramMember VARCHAR(15)) RETURNS varchar(45) +BEGIN +DECLARE tracks VARCHAR(45); +SELECT GROUP_CONCAT(Track SEPARATOR ', ') INTO tracks FROM t4 +WHERE Member_ID=paramMember AND Action='Enrolled' AND +(Track,Action_Date) IN (SELECT Track, MAX(Action_Date) FROM t4 +WHERE Member_ID=paramMember GROUP BY Track); +RETURN tracks; +END| +SELECT bug21493('111111')| +bug21493('111111') +NULL +SELECT bug21493('222222')| +bug21493('222222') +CAD +SELECT bug21493(Member_ID) FROM t3| +bug21493(Member_ID) +NULL +CAD +CAD +CAD +CAD +CHF +DROP FUNCTION bug21493| +DROP TABLE t3,t4| +drop function if exists func_20028_a| +drop function if exists func_20028_b| +drop function if exists func_20028_c| +drop procedure if exists proc_20028_a| +drop procedure if exists proc_20028_b| +drop procedure if exists proc_20028_c| +drop table if exists table_20028| +create table table_20028 (i int)| +SET @save_sql_mode=@@sql_mode| +SET sql_mode=''| +create function func_20028_a() returns integer +begin +declare temp integer; +select i into temp from table_20028 limit 1; +return ifnull(temp, 0); +end| +create function func_20028_b() returns integer +begin +return func_20028_a(); +end| +create function func_20028_c() returns integer +begin +declare div_zero integer; +set SQL_MODE='TRADITIONAL'; +select 1/0 into div_zero; +return div_zero; +end| +create procedure proc_20028_a() +begin +declare temp integer; +select i into temp from table_20028 limit 1; +end| +create procedure proc_20028_b() +begin +call proc_20028_a(); +end| +create procedure proc_20028_c() +begin +declare div_zero integer; +set SQL_MODE='TRADITIONAL'; +select 1/0 into div_zero; +end| +select func_20028_a()| +func_20028_a() +0 +select func_20028_b()| +func_20028_b() +0 +select func_20028_c()| +ERROR 22012: Division by 0 +call proc_20028_a()| +Warnings: +Warning 1329 No data - zero rows fetched, selected, or processed +call proc_20028_b()| +Warnings: +Warning 1329 No data - zero rows fetched, selected, or processed +call proc_20028_c()| +ERROR 22012: Division by 0 +SET sql_mode='TRADITIONAL'| +drop function func_20028_a| +drop function func_20028_b| +drop function func_20028_c| +drop procedure proc_20028_a| +drop procedure proc_20028_b| +drop procedure proc_20028_c| +create function func_20028_a() returns integer +begin +declare temp integer; +select i into temp from table_20028 limit 1; +return ifnull(temp, 0); +end| +create function func_20028_b() returns integer +begin +return func_20028_a(); +end| +create function func_20028_c() returns integer +begin +declare div_zero integer; +set SQL_MODE=''; +select 1/0 into div_zero; +return div_zero; +end| +create procedure proc_20028_a() +begin +declare temp integer; +select i into temp from table_20028 limit 1; +end| +create procedure proc_20028_b() +begin +call proc_20028_a(); +end| +create procedure proc_20028_c() +begin +declare div_zero integer; +set SQL_MODE=''; +select 1/0 into div_zero; +end| +select func_20028_a()| +func_20028_a() +0 +select func_20028_b()| +func_20028_b() +0 +select func_20028_c()| +func_20028_c() +NULL +call proc_20028_a()| +Warnings: +Warning 1329 No data - zero rows fetched, selected, or processed +call proc_20028_b()| +Warnings: +Warning 1329 No data - zero rows fetched, selected, or processed +call proc_20028_c()| +SET @@sql_mode=@save_sql_mode| +drop function func_20028_a| +drop function func_20028_b| +drop function func_20028_c| +drop procedure proc_20028_a| +drop procedure proc_20028_b| +drop procedure proc_20028_c| +drop table table_20028| +drop procedure if exists proc_21462_a| +drop procedure if exists proc_21462_b| +create procedure proc_21462_a() +begin +select "Called A"; +end| +create procedure proc_21462_b(x int) +begin +select "Called B"; +end| +call proc_21462_a| +Called A +Called A +call proc_21462_a()| +Called A +Called A +call proc_21462_a(1)| +ERROR 42000: Incorrect number of arguments for PROCEDURE test.proc_21462_a; expected 0, got 1 +call proc_21462_b| +ERROR 42000: Incorrect number of arguments for PROCEDURE test.proc_21462_b; expected 1, got 0 +call proc_21462_b()| +ERROR 42000: Incorrect number of arguments for PROCEDURE test.proc_21462_b; expected 1, got 0 +call proc_21462_b(1)| +Called B +Called B +drop procedure proc_21462_a| +drop procedure proc_21462_b| +drop table if exists t3| +drop procedure if exists proc_bug19733| +create table t3 (s1 int)| +create procedure proc_bug19733() +begin +declare v int default 0; +while v < 100 do +create index i on t3 (s1); +drop index i on t3; +set v = v + 1; +end while; +end| +call proc_bug19733()| +call proc_bug19733()| +call proc_bug19733()| +drop procedure proc_bug19733| +drop table t3| +DROP PROCEDURE IF EXISTS p1| +DROP VIEW IF EXISTS v1, v2| +DROP TABLE IF EXISTS t3, t4| +CREATE TABLE t3 (t3_id INT)| +INSERT INTO t3 VALUES (0)| +INSERT INTO t3 VALUES (1)| +CREATE TABLE t4 (t4_id INT)| +INSERT INTO t4 VALUES (2)| +CREATE VIEW v1 AS +SELECT t3.t3_id, t4.t4_id +FROM t3 JOIN t4 ON t3.t3_id = 0| +CREATE VIEW v2 AS +SELECT t3.t3_id AS t3_id_1, v1.t3_id AS t3_id_2, v1.t4_id +FROM t3 LEFT JOIN v1 ON t3.t3_id = 0| +CREATE PROCEDURE p1() SELECT * FROM v2| +CALL p1()| +t3_id_1 t3_id_2 t4_id +0 0 2 +1 NULL NULL +CALL p1()| +t3_id_1 t3_id_2 t4_id +0 0 2 +1 NULL NULL +DROP PROCEDURE p1| +DROP VIEW v1, v2| +DROP TABLE t3, t4| +End of 5.0 tests +Begin of 5.1 tests +drop function if exists pi; +create function pi() returns varchar(50) +return "pie, my favorite desert."; +Warnings: +Note 1585 This function 'pi' has the same name as a native function +SET @save_sql_mode=@@sql_mode; +SET SQL_MODE='IGNORE_SPACE'; +select pi(), pi (); +pi() pi () +3.141593 3.141593 +select test.pi(), test.pi (); +test.pi() test.pi () +pie, my favorite desert. pie, my favorite desert. +SET SQL_MODE=''; +select pi(), pi (); +pi() pi () +3.141593 3.141593 +select test.pi(), test.pi (); +test.pi() test.pi () +pie, my favorite desert. pie, my favorite desert. +SET @@sql_mode=@save_sql_mode; +drop function pi; +drop function if exists test.database; +drop function if exists test.current_user; +drop function if exists test.md5; +create database nowhere; +use nowhere; +drop database nowhere; +SET @save_sql_mode=@@sql_mode; +SET SQL_MODE='IGNORE_SPACE'; +select database(), database (); +database() database () +NULL NULL +select current_user(), current_user (); +current_user() current_user () +root@localhost root@localhost +select md5("aaa"), md5 ("aaa"); +md5("aaa") md5 ("aaa") +47bce5c74f589f4867dbd57e9ca9f808 47bce5c74f589f4867dbd57e9ca9f808 +SET SQL_MODE=''; +select database(), database (); +database() database () +NULL NULL +select current_user(), current_user (); +current_user() current_user () +root@localhost root@localhost +select md5("aaa"), md5 ("aaa"); +md5("aaa") md5 ("aaa") +47bce5c74f589f4867dbd57e9ca9f808 47bce5c74f589f4867dbd57e9ca9f808 +use test; +create function `database`() returns varchar(50) +return "Stored function database"; +Warnings: +Note 1585 This function 'database' has the same name as a native function +create function `current_user`() returns varchar(50) +return "Stored function current_user"; +Warnings: +Note 1585 This function 'current_user' has the same name as a native function +create function md5(x varchar(50)) returns varchar(50) +return "Stored function md5"; +Warnings: +Note 1585 This function 'md5' has the same name as a native function +SET SQL_MODE='IGNORE_SPACE'; +select database(), database (); +database() database () +test test +select current_user(), current_user (); +current_user() current_user () +root@localhost root@localhost +select md5("aaa"), md5 ("aaa"); +md5("aaa") md5 ("aaa") +47bce5c74f589f4867dbd57e9ca9f808 47bce5c74f589f4867dbd57e9ca9f808 +select test.database(), test.database (); +test.database() test.database () +Stored function database Stored function database +select test.current_user(), test.current_user (); +test.current_user() test.current_user () +Stored function current_user Stored function current_user +select test.md5("aaa"), test.md5 ("aaa"); +test.md5("aaa") test.md5 ("aaa") +Stored function md5 Stored function md5 +SET SQL_MODE=''; +select database(), database (); +database() database () +test test +select current_user(), current_user (); +current_user() current_user () +root@localhost root@localhost +select md5("aaa"), md5 ("aaa"); +md5("aaa") md5 ("aaa") +47bce5c74f589f4867dbd57e9ca9f808 47bce5c74f589f4867dbd57e9ca9f808 +select test.database(), test.database (); +test.database() test.database () +Stored function database Stored function database +select test.current_user(), test.current_user (); +test.current_user() test.current_user () +Stored function current_user Stored function current_user +select test.md5("aaa"), test.md5 ("aaa"); +test.md5("aaa") test.md5 ("aaa") +Stored function md5 Stored function md5 +SET @@sql_mode=@save_sql_mode; +drop function test.database; +drop function test.current_user; +drop function md5; +use test; +End of 5.1 tests +DROP TABLE IF EXISTS bug23760| +DROP TABLE IF EXISTS bug23760_log| +DROP PROCEDURE IF EXISTS bug23760_update_log| +DROP PROCEDURE IF EXISTS bug23760_test_row_count| +DROP FUNCTION IF EXISTS bug23760_rc_test| +CREATE TABLE bug23760 ( +id INT NOT NULL AUTO_INCREMENT , +num INT NOT NULL , +PRIMARY KEY ( id ) +)| +CREATE TABLE bug23760_log ( +id INT NOT NULL AUTO_INCREMENT , +reason VARCHAR(50)NULL , +ammount INT NOT NULL , +PRIMARY KEY ( id ) +)| +CREATE PROCEDURE bug23760_update_log(r Varchar(50), a INT) +BEGIN +INSERT INTO bug23760_log (reason, ammount) VALUES(r, a); +END| +CREATE PROCEDURE bug23760_test_row_count() +BEGIN +UPDATE bug23760 SET num = num + 1; +CALL bug23760_update_log('Test is working', ROW_COUNT()); +UPDATE bug23760 SET num = num - 1; +END| +CREATE PROCEDURE bug23760_test_row_count2(level INT) +BEGIN +IF level THEN +UPDATE bug23760 SET num = num + 1; +CALL bug23760_update_log('Test2 is working', ROW_COUNT()); +CALL bug23760_test_row_count2(level - 1); +END IF; +END| +CREATE FUNCTION bug23760_rc_test(in_var INT) RETURNS INT RETURN in_var| +INSERT INTO bug23760 (num) VALUES (0), (1), (1), (2), (3), (5), (8)| +SELECT ROW_COUNT()| +ROW_COUNT() +7 +CALL bug23760_test_row_count()| +SELECT * FROM bug23760_log ORDER BY id| +id reason ammount +1 Test is working 7 +SET @save_max_sp_recursion= @@max_sp_recursion_depth| +SELECT @save_max_sp_recursion| +@save_max_sp_recursion +0 +SET max_sp_recursion_depth= 5| +SELECT @@max_sp_recursion_depth| +@@max_sp_recursion_depth +5 +CALL bug23760_test_row_count2(2)| +SELECT ROW_COUNT()| +ROW_COUNT() +1 +SELECT * FROM bug23760_log ORDER BY id| +id reason ammount +1 Test is working 7 +2 Test2 is working 7 +3 Test2 is working 7 +SELECT * FROM bug23760 ORDER by ID| +id num +1 2 +2 3 +3 3 +4 4 +5 5 +6 7 +7 10 +SET max_sp_recursion_depth= @save_max_sp_recursion| +SELECT bug23760_rc_test(123)| +bug23760_rc_test(123) +123 +INSERT INTO bug23760 (num) VALUES (13), (21), (34), (55)| +SELECT bug23760_rc_test(ROW_COUNT())| +bug23760_rc_test(ROW_COUNT()) +4 +DROP TABLE bug23760, bug23760_log| +DROP PROCEDURE bug23760_update_log| +DROP PROCEDURE bug23760_test_row_count| +DROP PROCEDURE bug23760_test_row_count2| +DROP FUNCTION bug23760_rc_test| +DROP PROCEDURE IF EXISTS bug24117| +DROP TABLE IF EXISTS t3| +CREATE TABLE t3(c1 ENUM('abc'))| +INSERT INTO t3 VALUES('abc')| +CREATE PROCEDURE bug24117() +BEGIN +DECLARE t3c1 ENUM('abc'); +DECLARE mycursor CURSOR FOR SELECT c1 FROM t3; +OPEN mycursor; +FLUSH TABLES; +FETCH mycursor INTO t3c1; +CLOSE mycursor; +END| +CALL bug24117()| +DROP PROCEDURE bug24117| +DROP TABLE t3| +drop function if exists func_8407_a| +drop function if exists func_8407_b| +create function func_8407_a() returns int +begin +declare x int; +declare continue handler for sqlexception +begin +end; +select 1 from no_such_view limit 1 into x; +return x; +end| +create function func_8407_b() returns int +begin +declare x int default 0; +declare continue handler for sqlstate '42S02' + begin +set x:= x+1000; +end; +case (select 1 from no_such_view limit 1) +when 1 then set x:= x+1; +when 2 then set x:= x+2; +else set x:= x+100; +end case; +set x:=x + 500; +return x; +end| +select func_8407_a()| +func_8407_a() +NULL +select func_8407_b()| +func_8407_b() +1500 +drop function func_8407_a| +drop function func_8407_b| +drop table if exists table_26503| +drop procedure if exists proc_26503_ok_1| +drop procedure if exists proc_26503_ok_2| +drop procedure if exists proc_26503_ok_3| +drop procedure if exists proc_26503_ok_4| +create table table_26503(a int unique)| +create procedure proc_26503_ok_1(v int) +begin +declare i int default 5; +declare continue handler for sqlexception +begin +select 'caught something'; +retry: +while i > 0 do +begin +set i = i - 1; +select 'looping', i; +iterate retry; +select 'dead code'; +end; +end while retry; +select 'leaving handler'; +end; +select 'do something'; +insert into table_26503 values (v); +select 'do something again'; +insert into table_26503 values (v); +end| +create procedure proc_26503_ok_2(v int) +begin +declare i int default 5; +declare continue handler for sqlexception +begin +select 'caught something'; +retry: +while i > 0 do +begin +set i = i - 1; +select 'looping', i; +leave retry; +select 'dead code'; +end; +end while; +select 'leaving handler'; +end; +select 'do something'; +insert into table_26503 values (v); +select 'do something again'; +insert into table_26503 values (v); +end| +create procedure proc_26503_ok_3(v int) +begin +declare i int default 5; +retry: +begin +declare continue handler for sqlexception +begin +select 'caught something'; +retry: +while i > 0 do +begin +set i = i - 1; +select 'looping', i; +iterate retry; +select 'dead code'; +end; +end while retry; +select 'leaving handler'; +end; +select 'do something'; +insert into table_26503 values (v); +select 'do something again'; +insert into table_26503 values (v); +end; +end| +create procedure proc_26503_ok_4(v int) +begin +declare i int default 5; +retry: +begin +declare continue handler for sqlexception +begin +select 'caught something'; +retry: +while i > 0 do +begin +set i = i - 1; +select 'looping', i; +leave retry; +select 'dead code'; +end; +end while; +select 'leaving handler'; +end; +select 'do something'; +insert into table_26503 values (v); +select 'do something again'; +insert into table_26503 values (v); +end; +end| +call proc_26503_ok_1(1)| +do something +do something +do something again +do something again +caught something +caught something +looping i +looping 4 +looping i +looping 3 +looping i +looping 2 +looping i +looping 1 +looping i +looping 0 +leaving handler +leaving handler +call proc_26503_ok_2(2)| +do something +do something +do something again +do something again +caught something +caught something +looping i +looping 4 +leaving handler +leaving handler +call proc_26503_ok_3(3)| +do something +do something +do something again +do something again +caught something +caught something +looping i +looping 4 +looping i +looping 3 +looping i +looping 2 +looping i +looping 1 +looping i +looping 0 +leaving handler +leaving handler +call proc_26503_ok_4(4)| +do something +do something +do something again +do something again +caught something +caught something +looping i +looping 4 +leaving handler +leaving handler +drop table table_26503| +drop procedure proc_26503_ok_1| +drop procedure proc_26503_ok_2| +drop procedure proc_26503_ok_3| +drop procedure proc_26503_ok_4| +DROP FUNCTION IF EXISTS bug25373| +CREATE FUNCTION bug25373(p1 INTEGER) RETURNS INTEGER +LANGUAGE SQL DETERMINISTIC +RETURN p1;| +CREATE TABLE t3 (f1 INT, f2 FLOAT)| +INSERT INTO t3 VALUES (1, 3.4), (1, 2), (1, 0.9), (2, 8), (2, 7)| +SELECT SUM(f2), bug25373(f1) FROM t3 GROUP BY bug25373(f1) WITH ROLLUP| +SUM(f2) bug25373(f1) +6.300000071525574 1 +15 2 +21.300000071525574 NULL +DROP FUNCTION bug25373| +DROP TABLE t3| +DROP DATABASE IF EXISTS mysqltest1| +DROP DATABASE IF EXISTS mysqltest2| +CREATE DATABASE mysqltest1| +CREATE DATABASE mysqltest2| +CREATE PROCEDURE mysqltest1.p1() +DROP DATABASE mysqltest2| +use mysqltest2| +CALL mysqltest1.p1()| +Warnings: +Note 1049 Unknown database 'mysqltest2' +SELECT DATABASE()| +DATABASE() +NULL +DROP DATABASE mysqltest1| +use test| +drop function if exists bug20777| +drop table if exists examplebug20777| +create function bug20777(f1 bigint unsigned) returns bigint unsigned +begin +set f1 = (f1 - 10); set f1 = (f1 + 10); +return f1; +end| +select bug20777(9223372036854775803) as '9223372036854775803 2**63-5'; +9223372036854775803 2**63-5 +9223372036854775803 +select bug20777(9223372036854775804) as '9223372036854775804 2**63-4'; +9223372036854775804 2**63-4 +9223372036854775804 +select bug20777(9223372036854775805) as '9223372036854775805 2**63-3'; +9223372036854775805 2**63-3 +9223372036854775805 +select bug20777(9223372036854775806) as '9223372036854775806 2**63-2'; +9223372036854775806 2**63-2 +9223372036854775806 +select bug20777(9223372036854775807) as '9223372036854775807 2**63-1'; +9223372036854775807 2**63-1 +9223372036854775807 +select bug20777(9223372036854775808) as '9223372036854775808 2**63+0'; +9223372036854775808 2**63+0 +9223372036854775808 +select bug20777(9223372036854775809) as '9223372036854775809 2**63+1'; +9223372036854775809 2**63+1 +9223372036854775809 +select bug20777(9223372036854775810) as '9223372036854775810 2**63+2'; +9223372036854775810 2**63+2 +9223372036854775810 +select bug20777(-9223372036854775808) as 'lower bounds signed bigint'; +ERROR 22003: BIGINT UNSIGNED value is out of range in '(f1@0 - 10)' +select bug20777(9223372036854775807) as 'upper bounds signed bigint'; +upper bounds signed bigint +9223372036854775807 +select bug20777(0) as 'lower bounds unsigned bigint'; +ERROR 22003: BIGINT UNSIGNED value is out of range in '(f1@0 - 10)' +select bug20777(18446744073709551615) as 'upper bounds unsigned bigint'; +upper bounds unsigned bigint +18446744073709551615 +select bug20777(18446744073709551616) as 'upper bounds unsigned bigint + 1'; +upper bounds unsigned bigint + 1 +18446744073709551615 +Warnings: +Warning 1264 Out of range value for column 'f1' at row 1 +select bug20777(-1) as 'lower bounds unsigned bigint - 1'; +ERROR 22003: BIGINT UNSIGNED value is out of range in '(f1@0 - 10)' +create table examplebug20777 as select +0 as 'i', +bug20777(9223372036854775806) as '2**63-2', +bug20777(9223372036854775807) as '2**63-1', +bug20777(9223372036854775808) as '2**63', +bug20777(9223372036854775809) as '2**63+1', +bug20777(18446744073709551614) as '2**64-2', +bug20777(18446744073709551615) as '2**64-1', +bug20777(18446744073709551616) as '2**64'; +Warnings: +Warning 1264 Out of range value for column 'f1' at row 1 +insert into examplebug20777 values (1, 9223372036854775806, 9223372036854775807, 223372036854775808, 9223372036854775809, 18446744073709551614, 18446744073709551615, 8446744073709551616); +show create table examplebug20777; +Table Create Table +examplebug20777 CREATE TABLE `examplebug20777` ( + `i` int NOT NULL DEFAULT '0', + `2**63-2` bigint unsigned DEFAULT NULL, + `2**63-1` bigint unsigned DEFAULT NULL, + `2**63` bigint unsigned DEFAULT NULL, + `2**63+1` bigint unsigned DEFAULT NULL, + `2**64-2` bigint unsigned DEFAULT NULL, + `2**64-1` bigint unsigned DEFAULT NULL, + `2**64` bigint unsigned DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +select * from examplebug20777 order by i; +i 2**63-2 2**63-1 2**63 2**63+1 2**64-2 2**64-1 2**64 +0 9223372036854775806 9223372036854775807 9223372036854775808 9223372036854775809 18446744073709551614 18446744073709551615 18446744073709551615 +1 9223372036854775806 9223372036854775807 223372036854775808 9223372036854775809 18446744073709551614 18446744073709551615 8446744073709551616 +drop table examplebug20777; +select bug20777(18446744073709551613)+1; +bug20777(18446744073709551613)+1 +18446744073709551614 +drop function bug20777; +DROP FUNCTION IF EXISTS bug5274_f1| +DROP FUNCTION IF EXISTS bug5274_f2| +CREATE FUNCTION bug5274_f1(p1 CHAR) RETURNS CHAR +RETURN CONCAT(p1, p1)| +CREATE FUNCTION bug5274_f2() RETURNS CHAR +BEGIN +DECLARE v1 INT DEFAULT 0; +DECLARE v2 CHAR DEFAULT 'x'; +WHILE v1 < 30 DO +SET v1 = v1 + 1; +SET v2 = bug5274_f1(v2); +END WHILE; +RETURN v2; +END| +SELECT bug5274_f2()| +bug5274_f2() +x +DROP FUNCTION bug5274_f1| +DROP FUNCTION bug5274_f2| +drop procedure if exists proc_21513| +create procedure proc_21513()`my_label`:BEGIN END| +show create procedure proc_21513| +Procedure sql_mode Create Procedure character_set_client collation_connection Database Collation +proc_21513 CREATE DEFINER=`root`@`localhost` PROCEDURE `proc_21513`() +`my_label`:BEGIN END utf8mb4 utf8mb4_0900_ai_ci utf8mb4_0900_ai_ci +drop procedure proc_21513| +End of 5.0 tests. +drop table t1,t2; +CREATE TABLE t1 (a int auto_increment primary key) engine=MyISAM; +CREATE TABLE t2 (a int auto_increment primary key, b int) engine=innodb; +set @a=0; +CREATE function bug27354() RETURNS int not deterministic +begin +insert into t1 values (null); +set @a=@a+1; +return @a; +end| +update t2 set b=1 where a=bug27354(); +select count(t_1.a),count(t_2.a) from t1 as t_1, t2 as t_2 /* must be 0,0 */; +count(t_1.a) count(t_2.a) +0 0 +insert into t2 values (1,1),(2,2),(3,3); +update t2 set b=-b where a=bug27354(); +select * from t2 /* must return 1,-1 ... */; +a b +1 -1 +2 -2 +3 -3 +select count(*) from t1 /* must be 3 */; +count(*) +3 +drop table t1,t2; +drop function bug27354; +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1),(2); +CREATE FUNCTION metered(a INT) RETURNS INT RETURN 12; +CREATE VIEW v1 AS SELECT test.metered(a) as metered FROM t1; +SHOW CREATE VIEW v1; +View Create View character_set_client collation_connection +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `test`.`metered`(`t1`.`a`) AS `metered` from `t1` utf8mb4 utf8mb4_0900_ai_ci +DROP VIEW v1; +DROP FUNCTION metered; +DROP TABLE t1; +SET @p1_p2_cnt= 2; +CREATE TABLE t1 (c1 INT); +CREATE VIEW v1 AS SELECT * FROM t1; +PREPARE s1 FROM 'SELECT c1 FROM v1'; +EXECUTE s1; +c1 +EXECUTE s1; +c1 +CREATE PROCEDURE p1(IN loops BIGINT(19) UNSIGNED) +BEGIN +WHILE loops > 0 DO +SELECT c1 FROM v1; +SET loops = loops - 1; +END WHILE; +END| +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE PROCEDURE p2(IN loops BIGINT(19) UNSIGNED) +BEGIN +WHILE loops > 0 DO +SELECT c1 FROM v1; +CALL p1(@p1_p2_cnt); +SET loops = loops - 1; +END WHILE; +END| +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE FUNCTION f1(loops INT UNSIGNED) +RETURNS INT +BEGIN +DECLARE tmp INT; +WHILE loops > 0 DO +SELECT c1 INTO tmp FROM v1; +SET loops = loops - 1; +END WHILE; +RETURN loops; +END| +CALL p1(2); +c1 +c1 +CALL p2(2); +c1 +c1 +c1 +c1 +c1 +c1 +SELECT f1(2); +f1(2) +0 +PREPARE s1 FROM 'SELECT f1(2)'; +EXECUTE s1; +f1(2) +0 +EXECUTE s1; +f1(2) +0 +DROP PROCEDURE p1; +DROP PROCEDURE p2; +DROP FUNCTION f1; +DROP VIEW v1; +DROP TABLE t1; +create database mysqltest_db1; +create procedure mysqltest_db1.sp_bug28551() begin end; +call mysqltest_db1.sp_bug28551(); +show warnings; +Level Code Message +drop database mysqltest_db1; +drop database if exists mysqltest_db1; +drop table if exists test.t1; +create database mysqltest_db1; +use mysqltest_db1; +drop database mysqltest_db1; +create table test.t1 (id int); +insert into test.t1 (id) values (1); +create procedure test.sp_bug29050() begin select * from t1; end// +show warnings; +Level Code Message +call test.sp_bug29050(); +id +1 +show warnings; +Level Code Message +use test; +drop procedure sp_bug29050; +drop table t1; +SET NAMES latin1; +CREATE PROCEDURE p1() +BEGIN +DECLARE áâä INT; +SELECT áâä; +END| +CALL p1(); +áâä +NULL +SET NAMES default; +DROP PROCEDURE p1; +drop procedure if exists proc_25411_a; +drop procedure if exists proc_25411_b; +drop procedure if exists proc_25411_c; +create procedure proc_25411_a() +begin +/* real comment */ +select 1; +/*! select 2; */ +select 3; +/*!00000 select 4; */ +/*!99999 select 5; */ +end +$$ +create procedure proc_25411_b( +/* real comment */ +/*! p1 int, */ +/*!00000 p2 int */ +/*!99999 ,p3 int */ +) +begin +select p1, p2; +end +$$ +create procedure proc_25411_c() +begin +select 1/*!,2*//*!00000,3*//*!99999,4*/; +select 1/*! ,2*//*!00000 ,3*//*!99999 ,4*/; +select 1/*!,2 *//*!00000,3 *//*!99999,4 */; +select 1/*! ,2 *//*!00000 ,3 *//*!99999 ,4 */; +select 1 /*!,2*/ /*!00000,3*/ /*!99999,4*/ ; +end +$$ +show create procedure proc_25411_a; +Procedure sql_mode Create Procedure character_set_client collation_connection Database Collation +proc_25411_a CREATE DEFINER=`root`@`localhost` PROCEDURE `proc_25411_a`() +begin +/* real comment */ +select 1; + select 2; +select 3; + select 4; + +end utf8mb4 utf8mb4_0900_ai_ci utf8mb4_0900_ai_ci +call proc_25411_a(); +1 +1 +2 +2 +3 +3 +4 +4 +show create procedure proc_25411_b; +Procedure sql_mode Create Procedure character_set_client collation_connection Database Collation +proc_25411_b CREATE DEFINER=`root`@`localhost` PROCEDURE `proc_25411_b`( +/* real comment */ + p1 int, + p2 int + +) +begin +select p1, p2; +end utf8mb4 utf8mb4_0900_ai_ci utf8mb4_0900_ai_ci +select routine_name, routine_definition from information_schema.routines where routine_name like '%25411%'; +ROUTINE_NAME ROUTINE_DEFINITION + + select 2; + select 4; +/* real comment */ +end +end +end +proc_25411_a begin +proc_25411_b begin +proc_25411_c begin +select 1 ,2 ,3 ; +select 1 ,2 ,3 ; +select 1 ,2 ,3 ; +select 1,2 ,3 ; +select 1,2 ,3 ; +select 1; +select 3; +select p1, p2; +select parameter_name from information_schema.parameters where SPECIFIC_NAME= '%25411%'; +PARAMETER_NAME +call proc_25411_b(10, 20); +p1 p2 +10 20 +show create procedure proc_25411_c; +Procedure sql_mode Create Procedure character_set_client collation_connection Database Collation +proc_25411_c CREATE DEFINER=`root`@`localhost` PROCEDURE `proc_25411_c`() +begin +select 1,2 ,3 ; +select 1 ,2 ,3 ; +select 1,2 ,3 ; +select 1 ,2 ,3 ; +select 1 ,2 ,3 ; +end utf8mb4 utf8mb4_0900_ai_ci utf8mb4_0900_ai_ci +call proc_25411_c(); +1 2 3 +1 2 3 +1 2 3 +1 2 3 +1 2 3 +1 2 3 +1 2 3 +1 2 3 +1 2 3 +1 2 3 +drop procedure proc_25411_a; +drop procedure proc_25411_b; +drop procedure proc_25411_c; +drop procedure if exists proc_26302; +create procedure proc_26302() +select 1 /* testing */; +show create procedure proc_26302; +Procedure sql_mode Create Procedure character_set_client collation_connection Database Collation +proc_26302 CREATE DEFINER=`root`@`localhost` PROCEDURE `proc_26302`() +select 1 /* testing */ utf8mb4 utf8mb4_0900_ai_ci utf8mb4_0900_ai_ci +select ROUTINE_NAME, ROUTINE_DEFINITION from information_schema.ROUTINES +where ROUTINE_NAME = "proc_26302"; +ROUTINE_NAME ROUTINE_DEFINITION +proc_26302 select 1 /* testing */ +drop procedure proc_26302; +CREATE FUNCTION f1() RETURNS INT DETERMINISTIC RETURN 2; +CREATE FUNCTION f2(I INT) RETURNS INT DETERMINISTIC RETURN 3; +CREATE TABLE t1 (c1 INT, INDEX(c1)); +INSERT INTO t1 VALUES (1), (2), (3), (4), (5); +CREATE VIEW v1 AS SELECT c1 FROM t1; +analyze table t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT * FROM t1 WHERE c1=1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref c1 c1 5 const 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c1` AS `c1` from `test`.`t1` where (`test`.`t1`.`c1` = 1) +EXPLAIN SELECT * FROM t1 WHERE c1=f1(); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ref c1 c1 5 const 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c1` AS `c1` from `test`.`t1` where (`test`.`t1`.`c1` = `f1`()) +EXPLAIN SELECT * FROM v1 WHERE c1=1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ref c1 c1 5 const 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c1` AS `c1` from `test`.`t1` where (`test`.`t1`.`c1` = 1) +EXPLAIN SELECT * FROM v1 WHERE c1=f1(); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ref c1 c1 5 const 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c1` AS `c1` from `test`.`t1` where (`test`.`t1`.`c1` = `f1`()) +EXPLAIN SELECT * FROM t1 WHERE c1=f2(10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ref c1 c1 5 const 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c1` AS `c1` from `test`.`t1` where (`test`.`t1`.`c1` = `f2`(10)) +EXPLAIN SELECT * FROM t1 WHERE c1=f2(c1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index NULL c1 5 NULL 5 20.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c1` AS `c1` from `test`.`t1` where (`test`.`t1`.`c1` = `f2`(`test`.`t1`.`c1`)) +EXPLAIN SELECT * FROM t1 WHERE c1=f2(rand()); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index NULL c1 5 NULL 5 20.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c1` AS `c1` from `test`.`t1` where (`test`.`t1`.`c1` = `f2`(rand())) +DROP VIEW v1; +DROP FUNCTION f1; +DROP FUNCTION f2; +DROP TABLE t1; +create function f1() +returns int(11) +not deterministic +contains sql +sql security definer +comment '' +begin +declare x int(11); +set x=-1; +return x; +end| +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +create view v1 as select 1 as one, f1() as days; +show create view test.v1; +View Create View character_set_client collation_connection +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `test`.`v1` AS select 1 AS `one`,`f1`() AS `days` utf8mb4 utf8mb4_0900_ai_ci +select column_name from information_schema.columns +where table_name='v1' and table_schema='test' order by column_name; +COLUMN_NAME +days +one +drop view v1; +drop function f1; + +# Bug#13675. + +DROP PROCEDURE IF EXISTS p1; +DROP PROCEDURE IF EXISTS p2; +DROP TABLE IF EXISTS t1; + +CREATE PROCEDURE p1(v DATETIME) CREATE TABLE t1 SELECT v; +CREATE PROCEDURE p2(v INT) CREATE TABLE t1 SELECT v; + +CALL p1(NOW()); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `v` datetime DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci + +DROP TABLE t1; + +CALL p1('text'); +Warnings: +Warning 1265 Data truncated for column 'v' at row 1 +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `v` datetime DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci + +DROP TABLE t1; + +CALL p2(10); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `v` bigint DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci + +DROP TABLE t1; + +CALL p2('text'); +Warnings: +Warning 1366 Incorrect integer value: 'text' for column 'v' at row 1 +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `v` bigint DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci + +DROP TABLE t1; + +DROP PROCEDURE p1; +DROP PROCEDURE p2; + +# +# Bug#31035. +# + +# +# - Prepare. +# + +DROP TABLE IF EXISTS t1; +DROP FUNCTION IF EXISTS f1; +DROP FUNCTION IF EXISTS f2; +DROP FUNCTION IF EXISTS f3; +DROP FUNCTION IF EXISTS f4; + +# +# - Create required objects. +# + +CREATE TABLE t1(c1 INT); + +INSERT INTO t1 VALUES (1), (2), (3); + +CREATE FUNCTION f1() +RETURNS INT +NOT DETERMINISTIC +RETURN 1; + +CREATE FUNCTION f2(p INT) +RETURNS INT +NOT DETERMINISTIC +RETURN 1; + +CREATE FUNCTION f3() +RETURNS INT +DETERMINISTIC +RETURN 1; + +CREATE FUNCTION f4(p INT) +RETURNS INT +DETERMINISTIC +RETURN 1; + +# +# - Check. +# + +SELECT f1() AS a FROM t1 GROUP BY a; +a +1 + +SELECT f2(@a) AS a FROM t1 GROUP BY a; +a +1 + +SELECT f3() AS a FROM t1 GROUP BY a; +a +1 + +SELECT f4(0) AS a FROM t1 GROUP BY a; +a +1 + +SELECT f4(@a) AS a FROM t1 GROUP BY a; +a +1 + +# +# - Cleanup. +# + +DROP TABLE t1; +DROP FUNCTION f1; +DROP FUNCTION f2; +DROP FUNCTION f3; +DROP FUNCTION f4; + +# +# Bug#31191. +# + +# +# - Prepare. +# + +DROP TABLE IF EXISTS t1; +DROP TABLE IF EXISTS t2; +DROP FUNCTION IF EXISTS f1; + +# +# - Create required objects. +# + +CREATE TABLE t1 ( +id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, +barcode INT(8) UNSIGNED ZEROFILL nOT NULL, +PRIMARY KEY (id), +UNIQUE KEY barcode (barcode) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +Warning 1681 Integer display width is deprecated and will be removed in a future release. + +INSERT INTO t1 (id, barcode) VALUES (1, 12345678); +INSERT INTO t1 (id, barcode) VALUES (2, 12345679); + +CREATE TABLE test.t2 ( +id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, +barcode BIGINT(11) UNSIGNED ZEROFILL NOT NULL, +PRIMARY KEY (id) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +Warning 1681 Integer display width is deprecated and will be removed in a future release. + +INSERT INTO test.t2 (id, barcode) VALUES (1, 12345106708); +INSERT INTO test.t2 (id, barcode) VALUES (2, 12345106709); + +CREATE FUNCTION f1(p INT(8)) +RETURNS BIGINT(11) UNSIGNED +READS SQL DATA +RETURN FLOOR(p/1000)*1000000 + 100000 + FLOOR((p MOD 1000)/10)*100 + (p MOD 10); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. + +# +# - Check. +# + +SELECT DISTINCT t1.barcode, f1(t1.barcode) +FROM t1 +INNER JOIN t2 +ON f1(t1.barcode) = t2.barcode +WHERE t1.barcode=12345678; +barcode f1(t1.barcode) +12345678 12345106708 + +# +# - Cleanup. +# + +DROP TABLE t1; +DROP TABLE t2; +DROP FUNCTION f1; + +# +# Bug#31226. +# + +# +# - Prepare. +# + +DROP TABLE IF EXISTS t1; +DROP FUNCTION IF EXISTS f1; + +# +# - Create required objects. +# + +CREATE TABLE t1(id INT); + +INSERT INTO t1 VALUES (1), (2), (3); + +CREATE FUNCTION f1() +RETURNS DATETIME +NOT DETERMINISTIC NO SQL +RETURN NOW(); + +# +# - Check. +# + +SELECT f1() FROM t1 GROUP BY 1; +f1() + + +# +# - Cleanup. +# + +DROP TABLE t1; +DROP FUNCTION f1; + +DROP PROCEDURE IF EXISTS db28318_a.t1; +DROP PROCEDURE IF EXISTS db28318_b.t2; +DROP DATABASE IF EXISTS db28318_a; +DROP DATABASE IF EXISTS db28318_b; +CREATE DATABASE db28318_a; +CREATE DATABASE db28318_b; +CREATE PROCEDURE db28318_a.t1() SELECT "db28318_a.t1"; +CREATE PROCEDURE db28318_b.t2() CALL t1(); +use db28318_a; +CALL db28318_b.t2(); +ERROR 42000: PROCEDURE db28318_b.t1 does not exist +DROP PROCEDURE db28318_a.t1; +DROP PROCEDURE db28318_b.t2; +DROP DATABASE db28318_a; +DROP DATABASE db28318_b; +use test; +DROP TABLE IF EXISTS t1; +DROP PROCEDURE IF EXISTS bug29770; +CREATE TABLE t1(a int); +CREATE PROCEDURE bug29770() +BEGIN +DECLARE CONTINUE HANDLER FOR SQLSTATE '42S22' SET @state:= 'run'; +DECLARE CONTINUE HANDLER FOR SQLEXCEPTION SET @exception:= 'run'; +SELECT x FROM t1; +END| +CALL bug29770(); +SELECT @state, @exception; +@state @exception +run NULL +DROP TABLE t1; +DROP PROCEDURE bug29770; +use test; +drop table if exists t_33618; +drop procedure if exists proc_33618; +create table t_33618 (`a` int, unique(`a`), `b` varchar(30)) engine=myisam; +insert into t_33618 (`a`,`b`) values (1,'1'),(2,'2'); +create procedure proc_33618(num int) +begin +declare count1 int default '0'; +declare vb varchar(30); +declare last_row int; +while(num>=1) do +set num=num-1; +begin +declare cur1 cursor for select `a` from t_33618; +declare continue handler for not found set last_row = 1; +set last_row:=0; +open cur1; +rep1: +repeat +begin +declare exit handler for 1062 begin end; +fetch cur1 into vb; +if (last_row = 1) then +leave rep1; +end if; +end; +until last_row=1 +end repeat; +close cur1; +end; +end while; +end// +call proc_33618(20); +drop table t_33618; +drop procedure proc_33618; +# +# Bug#30787: Stored function ignores user defined alias. +# +use test; +drop function if exists func30787; +create table t1(f1 int); +insert into t1 values(1),(2); +create function func30787(p1 int) returns int +begin +return p1; +end | +select (select func30787(f1)) as ttt from t1; +ttt +1 +2 +drop function func30787; +drop table t1; +CREATE TABLE t1 (id INT); +INSERT INTO t1 VALUES (1),(2),(3),(4); +CREATE PROCEDURE test_sp() +SELECT t1.* FROM t1 RIGHT JOIN t1 t2 ON t1.id=t2.id; +CALL test_sp(); +id +1 +2 +3 +4 +CALL test_sp(); +id +1 +2 +3 +4 +DROP PROCEDURE test_sp; +DROP TABLE t1; +create table t1(c1 INT); +create function f1(p1 int) returns varchar(32) +return 'aaa'; +create view v1 as select f1(c1) as parent_control_name from t1; +create procedure p1() +begin +select parent_control_name as c1 from v1; +end // +call p1(); +c1 +call p1(); +c1 +drop procedure p1; +drop function f1; +drop view v1; +drop table t1; +drop procedure if exists `p2` $ +create procedure `p2`(in `a` text charset utf8) +begin +declare `pos` int default 1; +declare `str` text charset utf8; +set `str` := `a`; +select substr(`str`, `pos`+ 1 ) into `str`; +end $ +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +call `p2`('s s s s s s'); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +drop procedure `p2`; +drop table if exists t1; +drop procedure if exists p1; +create procedure p1() begin select * from t1; end$ +call p1$ +ERROR 42S02: Table 'test.t1' doesn't exist +create table t1 (a integer)$ +call p1$ +a +alter table t1 add b integer; +call p1$ +a b +drop table t1; +drop procedure p1; +# ------------------------------------------------------------------ +# -- End of 5.0 tests +# ------------------------------------------------------------------ + +# +# Bug#20550. +# + +# +# - Prepare. +# + +DROP VIEW IF EXISTS v1; +DROP VIEW IF EXISTS v2; +DROP FUNCTION IF EXISTS f1; +DROP FUNCTION IF EXISTS f2; + +# +# - Create required objects. +# + +CREATE FUNCTION f1() RETURNS VARCHAR(65525) RETURN 'Hello'; +Warnings: +Note 1246 Converting column '' from VARCHAR to TEXT + +CREATE FUNCTION f2() RETURNS TINYINT RETURN 1; + +CREATE VIEW v1 AS SELECT f1(); + +CREATE VIEW v2 AS SELECT f2(); + +# +# - Check. +# + +SELECT DATA_TYPE FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'v1'; +DATA_TYPE +mediumtext + +SELECT DATA_TYPE FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'v2'; +DATA_TYPE +tinyint + +# +# - Cleanup. +# + +DROP FUNCTION f1; +DROP FUNCTION f2; +DROP VIEW v1; +DROP VIEW v2; + +# +# - Bug#24923: prepare. +# + +DROP FUNCTION IF EXISTS f1; + +# +# - Bug#24923: create required objects. +# + +CREATE FUNCTION f1(p INT) +RETURNS ENUM ('Very_long_enum_element_identifier', +'Another_very_long_enum_element_identifier') +BEGIN +CASE p +WHEN 1 THEN +RETURN 'Very_long_enum_element_identifier'; +ELSE +RETURN 'Another_very_long_enum_element_identifier'; +END CASE; +END| + +# +# - Bug#24923: check. +# + +SELECT f1(1); +f1(1) +Very_long_enum_element_identifier + +SELECT f1(2); +f1(2) +Another_very_long_enum_element_identifier + +SHOW CREATE FUNCTION f1; +Function sql_mode Create Function character_set_client collation_connection Database Collation +f1 CREATE DEFINER=`root`@`localhost` FUNCTION `f1`(p INT) RETURNS enum('Very_long_enum_element_identifier','Another_very_long_enum_element_identifier') CHARSET utf8mb4 +BEGIN +CASE p +WHEN 1 THEN +RETURN 'Very_long_enum_element_identifier'; +ELSE +RETURN 'Another_very_long_enum_element_identifier'; +END CASE; +END utf8mb4 utf8mb4_0900_ai_ci utf8mb4_0900_ai_ci +# +# - Bug#24923: cleanup. +# + +DROP FUNCTION f1; + +drop procedure if exists p; +set @old_mode= @@sql_mode; +set @@sql_mode= cast(pow(2,33)-1 as unsigned integer) & ~0x1003ff00; +Warnings: +Warning 3090 Changing sql mode 'PAD_CHAR_TO_FULL_LENGTH' is deprecated. It will be removed in a future release. +select @@sql_mode into @full_mode; +create procedure p() begin end; +call p(); +set @@sql_mode= @old_mode; +select routine_name from information_schema.routines where routine_name = 'p' and sql_mode = @full_mode; +ROUTINE_NAME +p +drop procedure p; +CREATE DEFINER = 'root'@'localhost' PROCEDURE p1() +NOT DETERMINISTIC +CONTAINS SQL +SQL SECURITY DEFINER +COMMENT '' +BEGIN +SHOW TABLE STATUS like 't1'; +END;// +CREATE TABLE t1 (f1 INT); +CALL p1(); +CALL p1(); +CALL p1(); +CALL p1(); +DROP PROCEDURE p1; +DROP TABLE t1; +CREATE TABLE t1 ( f1 integer, primary key (f1)); +CREATE TABLE t2 LIKE t1; +CREATE TEMPORARY TABLE t3 LIKE t1; +CREATE PROCEDURE p1 () BEGIN SELECT f1 FROM t3 AS A WHERE A.f1 IN ( SELECT f1 FROM t3 ) ; +END| +CALL p1; +ERROR HY000: Can't reopen table: 'A' +CREATE VIEW t3 AS SELECT f1 FROM t2 A WHERE A.f1 IN ( SELECT f1 FROM t2 ); +DROP TABLE t3; +CALL p1; +f1 +CALL p1; +f1 +DROP PROCEDURE p1; +DROP TABLE t1, t2; +DROP VIEW t3; +# +# Bug #46629: Item_in_subselect::val_int(): Assertion `0' +# on subquery inside a SP +# +CREATE TABLE t1(a INT); +CREATE TABLE t2(a INT, b INT PRIMARY KEY); +CREATE PROCEDURE p1 () +BEGIN +SELECT a FROM t1 A WHERE A.b IN (SELECT b FROM t2 AS B); +END| +CALL p1; +ERROR 42S22: Unknown column 'A.b' in 'IN/ALL/ANY subquery' +CALL p1; +ERROR 42S22: Unknown column 'A.b' in 'IN/ALL/ANY subquery' +DROP PROCEDURE p1; +DROP TABLE t1, t2; +# +# Bug#47627: SET @@{global.session}.local_variable in stored routine causes crash +# Bug#48626: Crash or lost connection using SET for declared variables with @@ +# +DROP PROCEDURE IF EXISTS p1; +DROP PROCEDURE IF EXISTS p2; +DROP PROCEDURE IF EXISTS p3; +CREATE PROCEDURE p1() +BEGIN +DECLARE v INT DEFAULT 0; +SET @@SESSION.v= 10; +END// +ERROR HY000: Unknown system variable 'v' +CREATE PROCEDURE p2() +BEGIN +DECLARE v INT DEFAULT 0; +SET v= 10; +END// +call p2()// +CREATE PROCEDURE p3() +BEGIN +DECLARE v INT DEFAULT 0; +SELECT @@SESSION.v; +END// +ERROR HY000: Unknown system variable 'v' +CREATE PROCEDURE p4() +BEGIN +DECLARE v INT DEFAULT 0; +SET @@GLOBAL.v= 10; +END// +ERROR HY000: Unknown system variable 'v' +CREATE PROCEDURE p5() +BEGIN +DECLARE init_connect INT DEFAULT 0; +SET init_connect= 10; +SET @@GLOBAL.init_connect= 'SELECT 1'; +SET @@SESSION.IDENTITY= 1; +SELECT @@SESSION.IDENTITY; +SELECT @@GLOBAL.init_connect; +SELECT init_connect; +END// +CREATE PROCEDURE p6() +BEGIN +DECLARE v INT DEFAULT 0; +SET @@v= 0; +END// +ERROR HY000: Unknown system variable 'v' +SET @old_init_connect= @@GLOBAL.init_connect; +CALL p5(); +@@SESSION.IDENTITY +1 +@@GLOBAL.init_connect +SELECT 1 +init_connect +10 +SET @@GLOBAL.init_connect= @old_init_connect; +DROP PROCEDURE p2; +DROP PROCEDURE p5; +# +# Bug#11840395 (formerly known as bug#60347): +# The string "versiondata" seems +# to be 'leaking' into the schema name space +# +CREATE DATABASE mixedCaseDbName; +CREATE PROCEDURE mixedCaseDbName.tryMyProc() begin end| +CREATE FUNCTION mixedCaseDbName.tryMyFunc() returns text begin return 'IT WORKS'; end +| +call mixedCaseDbName.tryMyProc(); +select mixedCaseDbName.tryMyFunc(); +mixedCaseDbName.tryMyFunc() +IT WORKS +DROP DATABASE mixedCaseDbName; +# +# Bug#11766594 59736: SELECT DISTINCT.. INCORRECT RESULT WITH DETERMINISTIC FUNCTION IN WHERE C +# +CREATE TABLE t1 (a INT, b INT, KEY(b)); +CREATE TABLE t2 (c INT, d INT, KEY(c)); +INSERT INTO t1 VALUES (1,1),(1,1),(1,2); +INSERT INTO t2 VALUES (1,1),(1,2); +CREATE FUNCTION f1() RETURNS INT DETERMINISTIC +BEGIN +DECLARE a int; +-- SQL statement inside +SELECT 1 INTO a; +RETURN a; +END $ +SELECT COUNT(DISTINCT d) FROM t1, t2 WHERE a = c AND b = f1(); +COUNT(DISTINCT d) +2 +DROP FUNCTION f1; +DROP TABLE t1, t2; +# ------------------------------------------------------------------ +# -- End of 5.1 tests +# ------------------------------------------------------------------ +DROP FUNCTION IF EXISTS f1; +DROP TABLE IF EXISTS t_non_existing; +DROP TABLE IF EXISTS t1; +CREATE FUNCTION f1() RETURNS INT +BEGIN +DECLARE v INT; +SELECT a INTO v FROM t_non_existing; +RETURN 1; +END| +CREATE TABLE t1 (a INT) ENGINE = myisam; +INSERT INTO t1 VALUES (1); +SELECT * FROM t1 WHERE a = f1(); +ERROR 42S02: Table 'test.t_non_existing' doesn't exist +DROP FUNCTION f1; +DROP TABLE t1; +DROP PROCEDURE IF EXISTS p1; +CREATE PROCEDURE p1(a INT, b CHAR) +BEGIN +IF a > 0 THEN +CALL p1(a-1, 'ab'); +ELSE +SELECT 1; +END IF; +END| +SET @save_max_sp_recursion= @@max_sp_recursion_depth; +SET @@max_sp_recursion_depth= 5; +CALL p1(4, 'a'); +1 +1 +Warnings: +Warning 1265 Data truncated for column 'b' at row 1 +Warning 1265 Data truncated for column 'b' at row 1 +Warning 1265 Data truncated for column 'b' at row 1 +Warning 1265 Data truncated for column 'b' at row 1 +SET @@max_sp_recursion_depth= @save_max_sp_recursion; +DROP PROCEDURE p1; +DROP PROCEDURE IF EXISTS p1; +CREATE PROCEDURE p1(a CHAR) +BEGIN +SELECT 1; +SELECT CAST('10x' as UNSIGNED INTEGER); +END| +CALL p1('data truncated parameter'); +1 +1 +CAST('10x' as UNSIGNED INTEGER) +10 +Warnings: +Warning 1265 Data truncated for column 'a' at row 1 +Warning 1292 Truncated incorrect INTEGER value: '10x' +DROP PROCEDURE p1; +DROP PROCEDURE IF EXISTS p1; +DROP PROCEDURE IF EXISTS p2; +DROP PROCEDURE IF EXISTS p3; +DROP PROCEDURE IF EXISTS p4; +CREATE PROCEDURE p1() +CALL p2()| +CREATE PROCEDURE p2() +CALL p3()| +CREATE PROCEDURE p3() +CALL p4()| +CREATE PROCEDURE p4() +BEGIN +SELECT 1; +SELECT CAST('10x' as UNSIGNED INTEGER); +END| +CALL p1(); +1 +1 +CAST('10x' as UNSIGNED INTEGER) +10 +Warnings: +Warning 1292 Truncated incorrect INTEGER value: '10x' +DROP PROCEDURE p1; +DROP PROCEDURE p2; +DROP PROCEDURE p3; +DROP PROCEDURE p4; +DROP FUNCTION IF EXISTS f1; +DROP FUNCTION IF EXISTS f2; +DROP FUNCTION IF EXISTS f3; +DROP FUNCTION IF EXISTS f4; +DROP TABLE IF EXISTS t1; +CREATE TABLE t1 (a CHAR(2)); +INSERT INTO t1 VALUES ('aa'); +CREATE FUNCTION f1() RETURNS CHAR +RETURN (SELECT f2())| +CREATE FUNCTION f2() RETURNS CHAR +RETURN (SELECT f3())| +CREATE FUNCTION f3() RETURNS CHAR +RETURN (SELECT f4())| +CREATE FUNCTION f4() RETURNS CHAR +BEGIN +RETURN (SELECT a FROM t1); +END| +SELECT f1(); +f1() +a +Warnings: +Warning 1265 Data truncated for column 'f4()' at row 2 +DROP FUNCTION f1; +DROP FUNCTION f2; +DROP FUNCTION f3; +DROP FUNCTION f4; +DROP TABLE t1; +# +# Bug#34197: CREATE PROCEDURE fails when COMMENT truncated in non +# strict SQL mode +# +DROP PROCEDURE IF EXISTS p1; +CREATE PROCEDURE p1 () +COMMENT +'12345678901234567890123456789012345678901234567890123456789012345678901234567890' +BEGIN +END; +SELECT routine_comment FROM information_schema.routines WHERE routine_name = "p1"; +ROUTINE_COMMENT +12345678901234567890123456789012345678901234567890123456789012345678901234567890 +DROP PROCEDURE p1; +# +# Bug #47313 assert in check_key_in_view during CALL procedure +# +DROP TABLE IF EXISTS t1; +DROP VIEW IF EXISTS t1, t2_unrelated; +DROP PROCEDURE IF EXISTS p1; +CREATE PROCEDURE p1(IN x INT) INSERT INTO t1 VALUES (x); +CREATE VIEW t1 AS SELECT 10 AS f1; +# t1 refers to the view +CALL p1(1); +ERROR HY000: The target table t1 of the INSERT is not insertable-into +CREATE TEMPORARY TABLE t1 (f1 INT); +# Since last call to p1 was unsuccessful, the query will be reparsed +# and the procedure will refer to the temporary table +CALL p1(2); +DROP VIEW t1; +# t1 still refers to the temporary table +CALL p1(3); +# Check which values were inserted into the temp table. +SELECT * FROM t1; +f1 +2 +3 +DROP TEMPORARY TABLE t1; +DROP PROCEDURE p1; +# Now test what happens if the sp cache is invalidated. +CREATE PROCEDURE p1(IN x INT) INSERT INTO t1 VALUES (x); +CREATE VIEW t1 AS SELECT 10 AS f1; +CREATE VIEW v2_unrelated AS SELECT 1 AS r1; +# Load the procedure into the sp cache +CALL p1(4); +ERROR HY000: The target table t1 of the INSERT is not insertable-into +CREATE TEMPORARY TABLE t1 (f1 int); +ALTER VIEW v2_unrelated AS SELECT 2 AS r1; +# Alter view causes the sp cache to be invalidated. +# Now t1 refers to the temporary table, not the view. +CALL p1(5); +# Check which values were inserted into the temp table. +SELECT * FROM t1; +f1 +5 +DROP TEMPORARY TABLE t1; +DROP VIEW t1, v2_unrelated; +DROP PROCEDURE p1; +CREATE PROCEDURE p1(IN x INT) INSERT INTO t1 VALUES (x); +CREATE TEMPORARY TABLE t1 (f1 INT); +# t1 refers to the temporary table +CALL p1(6); +CREATE VIEW t1 AS SELECT 10 AS f1; +# Create view causes the sp cache to be invalidated. +# t1 still refers to the temporary table since it shadows the view. +CALL p1(7); +DROP VIEW t1; +# Check which values were inserted into the temp table. +SELECT * FROM t1; +f1 +6 +7 +DROP TEMPORARY TABLE t1; +DROP PROCEDURE p1; +# +# Bug #11918 Can't use a declared variable in LIMIT clause +# +drop table if exists t1; +drop procedure if exists p1; +create table t1 (c1 int); +insert into t1 (c1) values (1), (2), (3), (4), (5); +create procedure p1() +begin +declare a integer; +declare b integer; +select * from t1 limit a, b; +end| +# How do we handle NULL limit values? +call p1(); +c1 +drop table t1; +create table t1 (a int); +insert into t1 (a) values (1), (2), (3), (4), (5); +# +# Do we correctly resolve identifiers in LIMIT? +# +call p1(); +a +drop table t1; +create table t1 (c1 int); +insert into t1 (c1) values (1), (2), (3), (4), (5); +drop procedure p1; +# Try to create a procedure that +# refers to non-existing variables. +create procedure p1(p1 integer, p2 integer) +select * from t1 limit a, b; +ERROR 42000: Undeclared variable: a +# +# Try to use data types not allowed in LIMIT +# +create procedure p1(p1 date, p2 date) select * from t1 limit p1, p2; +ERROR 42000: The variable "p1" has a non-integer based type near 'p1, p2' at line 1 +create procedure p1(p1 integer, p2 float) select * from t1 limit p1, p2; +ERROR 42000: The variable "p2" has a non-integer based type near 'p2' at line 1 +create procedure p1(p1 integer, p2 char(1)) select * from t1 limit p1, p2; +ERROR 42000: The variable "p2" has a non-integer based type near 'p2' at line 1 +create procedure p1(p1 varchar(5), p2 char(1)) select * from t1 limit p1, p2; +ERROR 42000: The variable "p1" has a non-integer based type near 'p1, p2' at line 1 +create procedure p1(p1 decimal, p2 decimal) select * from t1 limit p1, p2; +ERROR 42000: The variable "p1" has a non-integer based type near 'p1, p2' at line 1 +create procedure p1(p1 double, p2 double) select * from t1 limit p1, p2; +ERROR 42000: The variable "p1" has a non-integer based type near 'p1, p2' at line 1 +# +# Finally, test the valid case. +# +create procedure p1(p1 integer, p2 integer) +select * from t1 limit p1, p2; +call p1(NULL, NULL); +c1 +call p1(0, 0); +c1 +call p1(0, -1); +c1 +1 +2 +3 +4 +5 +call p1(-1, 0); +c1 +call p1(-1, -1); +c1 +call p1(0, 1); +c1 +1 +call p1(1, 0); +c1 +call p1(1, 5); +c1 +2 +3 +4 +5 +call p1(3, 2); +c1 +4 +5 +# Try to create a function that +# refers to non-existing variables. +create function f1(p1 integer, p2 integer) +returns int +begin +declare a int; +set a = (select count(*) from t1 limit a, b); +return a; +end| +ERROR 42000: Undeclared variable: b +create function f1() +returns int +begin +declare a, b, c int; +set a = (select count(*) from t1 limit b, c); +return a; +end| +# How do we handle NULL limit values? +select f1(); +f1() +NULL +drop function f1; +# +# Try to use data types not allowed in LIMIT +# +create function f1(p1 date, p2 date) +returns int +begin +declare a int; +set a = (select count(*) from t1 limit p1, p2); +return a; +end| +ERROR 42000: The variable "p1" has a non-integer based type near 'p1, p2); +return a; +end' at line 5 +create function f1(p1 integer, p2 float) +returns int +begin +declare a int; +set a = (select count(*) from t1 limit p1, p2); +return a; +end| +ERROR 42000: The variable "p2" has a non-integer based type near 'p2); +return a; +end' at line 5 +create function f1(p1 integer, p2 char(1)) +returns int +begin +declare a int; +set a = (select count(*) from t1 limit p1, p2); +return a; +end| +ERROR 42000: The variable "p2" has a non-integer based type near 'p2); +return a; +end' at line 5 +create function f1(p1 varchar(5), p2 char(1)) +returns int +begin +declare a int; +set a = (select count(*) from t1 limit p1, p2); +return a; +end| +ERROR 42000: The variable "p1" has a non-integer based type near 'p1, p2); +return a; +end' at line 5 +create function f1(p1 decimal, p2 decimal) +returns int +begin +declare a int; +set a = (select count(*) from t1 limit p1, p2); +return a; +end| +ERROR 42000: The variable "p1" has a non-integer based type near 'p1, p2); +return a; +end' at line 5 +create function f1(p1 double, p2 double) +returns int +begin +declare a int; +set a = (select count(*) from t1 limit p1, p2); +return a; +end| +ERROR 42000: The variable "p1" has a non-integer based type near 'p1, p2); +return a; +end' at line 5 +# +# Finally, test the valid case. +# +create function f1(p1 integer, p2 integer) +returns int +begin +declare count int; +set count= (select count(*) from (select * from t1 limit p1, p2) t_1); +return count; +end| +select f1(0, 0); +f1(0, 0) +0 +select f1(0, -1); +f1(0, -1) +5 +select f1(-1, 0); +f1(-1, 0) +0 +select f1(-1, -1); +f1(-1, -1) +0 +select f1(0, 1); +f1(0, 1) +1 +select f1(1, 0); +f1(1, 0) +0 +select f1(1, 5); +f1(1, 5) +4 +select f1(3, 2); +f1(3, 2) +2 +# Cleanup +drop table t1; +drop procedure p1; +drop function f1; +# +# BUG#11766234: 59299: ASSERT (TABLE_REF->TABLE || TABLE_REF->VIEW) +# FAILS IN SET_FIELD_ITERATOR +# +CREATE TABLE t1 (a INT); +CREATE TABLE t2 (a INT); +CREATE VIEW v1 AS SELECT a FROM t2; +CREATE PROCEDURE proc() SELECT * FROM t1 NATURAL JOIN v1; +ALTER TABLE t2 CHANGE COLUMN a b CHAR; + +CALL proc(); +ERROR HY000: View 'test.v1' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +CALL proc(); +ERROR HY000: View 'test.v1' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them + +DROP TABLE t1,t2; +DROP VIEW v1; +DROP PROCEDURE proc; + +# -- +# -- Bug 11765684 - 58674: SP-cache does not detect changes in +# -- pre-locking list caused by triggers +# --- +DROP TABLE IF EXISTS t1; +DROP TABLE IF EXISTS t2; +DROP TABLE IF EXISTS t3; +DROP PROCEDURE IF EXISTS p1; +CREATE TABLE t1(a INT); +CREATE TABLE t2(a INT); +CREATE TABLE t3(a INT); +CREATE PROCEDURE p1() +INSERT INTO t1(a) VALUES (1); + +CREATE TRIGGER t1_ai AFTER INSERT ON t1 +FOR EACH ROW +INSERT INTO t2(a) VALUES (new.a); + +CALL p1(); + +CREATE TRIGGER t1_bi BEFORE INSERT ON t1 +FOR EACH ROW +INSERT INTO t3(a) VALUES (new.a); + +CALL p1(); + +DROP TABLE t1, t2, t3; +DROP PROCEDURE p1; + + +# -- +# -- Bug#12652769 - 61470: case operator in stored routine retains old +# -- value of input parameter +# --- +DROP TABLE IF EXISTS t1; +DROP PROCEDURE IF EXISTS p1; +CREATE TABLE t1 (s1 CHAR(5) CHARACTER SET utf8); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES ('a'); +CREATE PROCEDURE p1(dt DATETIME, i INT) +BEGIN +SELECT +CASE +WHEN i = 1 THEN 2 +ELSE dt +END AS x1; +SELECT +CASE _latin1'a' + WHEN _utf8'a' THEN 'A' + END AS x2; +SELECT +CASE _utf8'a' + WHEN _latin1'a' THEN _utf8'A' + END AS x3; +SELECT +CASE s1 +WHEN _latin1'a' THEN _latin1'b' + ELSE _latin1'c' + END AS x4 +FROM t1; +END| +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. + +CALL p1('2011-04-03 05:14:10', 1); +x1 +2 +x2 +A +x3 +A +x4 +b +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +CALL p1('2011-04-03 05:14:11', 2); +x1 +2011-04-03 05:14:11 +x2 +A +x3 +A +x4 +b +CALL p1('2011-04-03 05:14:12', 2); +x1 +2011-04-03 05:14:12 +x2 +A +x3 +A +x4 +b +CALL p1('2011-04-03 05:14:13', 2); +x1 +2011-04-03 05:14:13 +x2 +A +x3 +A +x4 +b + +DROP TABLE t1; +DROP PROCEDURE p1; + +# +# Bug#12621017 - Crash if a sp variable is used in the +# limit clause of a set statement +# +DROP TABLE IF EXISTS t1; +DROP PROCEDURE IF EXISTS p1; +DROP PROCEDURE IF EXISTS p2; +CREATE TABLE t1 (c1 INT); +INSERT INTO t1 VALUES (1); +CREATE PROCEDURE p1() +BEGIN +DECLARE foo, cnt INT UNSIGNED DEFAULT 1; +SET foo = (SELECT MIN(c1) FROM t1 LIMIT cnt); +END| +CREATE PROCEDURE p2() +BEGIN +DECLARE iLimit INT; +DECLARE iVal INT; +DECLARE cur1 CURSOR FOR +SELECT c1 FROM t1 +LIMIT iLimit; +SET iLimit=1; +OPEN cur1; +FETCH cur1 INTO iVal; +END| +CALL p1(); +CALL p2(); +DROP PROCEDURE p1; +DROP PROCEDURE p2; +DROP TABLE t1; + +# Bug#13805127: Stored program cache produces wrong result in same THD + +CREATE PROCEDURE p1(x INT UNSIGNED) +BEGIN +SELECT c1, t2.c2, count(c3) +FROM +( +SELECT 3 as c2 FROM dual WHERE x = 1 +UNION +SELECT 2 FROM dual WHERE x = 1 OR x = 2 +) AS t1, +( +SELECT '2012-03-01 01:00:00' AS c1, 3 as c2, 1 as c3 FROM dual +UNION +SELECT '2012-03-01 02:00:00', 3, 2 FROM dual +UNION +SELECT '2012-03-01 01:00:00', 2, 1 FROM dual +) AS t2 +WHERE t2.c2 = t1.c2 +GROUP BY c1 , c2 +ORDER BY c1 , c2 +; +END| + +CALL p1(1); +c1 c2 count(c3) +2012-03-01 01:00:00 2 1 +2012-03-01 01:00:00 3 1 +2012-03-01 02:00:00 3 1 +CALL p1(2); +c1 c2 count(c3) +2012-03-01 01:00:00 2 1 +CALL p1(1); +c1 c2 count(c3) +2012-03-01 01:00:00 2 1 +2012-03-01 01:00:00 3 1 +2012-03-01 02:00:00 3 1 +DROP PROCEDURE p1; +# End of 5.5 test +# +# Bug#12663165 SP DEAD CODE REMOVAL DOESN'T UNDERSTAND CONTINUE HANDLERS +# +DROP FUNCTION IF EXISTS f1; +CREATE FUNCTION f1() RETURNS INT +BEGIN +DECLARE CONTINUE HANDLER FOR SQLEXCEPTION BEGIN END; +BEGIN +DECLARE CONTINUE HANDLER FOR SQLEXCEPTION RETURN f1(); +BEGIN +DECLARE CONTINUE HANDLER FOR SQLEXCEPTION RETURN f1(); +RETURN f1(); +END; +END; +RETURN 1; +END $ +SELECT f1(); +f1() +1 +DROP FUNCTION f1; +# +# Bug#12577230 +# RERUN OF STORED FUNCTION CAUSES SEGFAULT IN MAKE_JOIN_SELECT +# +CREATE TABLE t1 (a INT) ENGINE=myisam; +INSERT INTO t1 VALUES (1); +CREATE VIEW v1 AS SELECT a FROM t1; +CREATE PROCEDURE p1() +SELECT 1 FROM v1 JOIN t1 ON v1.a +WHERE (SELECT 1 FROM t1 WHERE v1.a) +; +CALL p1(); +1 +1 +CALL p1(); +1 +1 +DROP PROCEDURE p1; +prepare s from 'select 1 from `v1` join `t1` on `v1`.`a` +where (select 1 from `t1` where `v1`.`a`)'; +execute s; +1 +1 +execute s; +1 +1 +prepare s from 'select 1 from `v1` join `t1` on `v1`.`a`'; +execute s; +1 +1 +execute s; +1 +1 +prepare s from 'select 1 from `v1` join `t1` on `v1`.`a` join t1 as t2 +on v1.a'; +execute s; +1 +1 +execute s; +1 +1 +create view v2 as select 0 as a from t1; +prepare s from 'select 1 from `v2` join `t1` on `v2`.`a` join v1 on `v1`.`a`'; +execute s; +1 +execute s; +1 +prepare s from 'select 1 from `v2` join `t1` on `v2`.`a`, v1 where `v1`.`a`'; +execute s; +1 +execute s; +1 +DROP TABLE t1; +DROP VIEW v1,v2; +# +# WL#2111: Add non-reserved ROW_COUNT keyword. +# +DROP PROCEDURE IF EXISTS p1; +CREATE PROCEDURE p1() +BEGIN +DECLARE row_count INT DEFAULT 1; +SELECT row_count; +SELECT row_count(); +ROW_COUNT: WHILE row_count > 0 DO +SET row_count = row_count - 1; +END WHILE ROW_COUNT; +SELECT ROW_COUNT; +END| +CALL p1(); +row_count +1 +row_count() +-1 +ROW_COUNT +0 +DROP PROCEDURE p1; +# +# BUG #11748187 - 35410: STORED FUNCTION: CONFUSING 'ORDER CLAUSE' IN ERROR MESSAGE +# +DROP FUNCTION if exists f1; +CREATE FUNCTION f1 (p_value INT) RETURNS INT DETERMINISTIC RETURN x; +SELECT f1(1); +ERROR 42S22: Unknown column 'x' in 'field list' +DROP FUNCTION f1; +# +# BUG #12872824 (formerly known as 62125): testing stored function +# result for null incorrectly yields 1292 warning. +DROP FUNCTION IF EXISTS f1; +DROP FUNCTION IF EXISTS f2; +DROP FUNCTION IF EXISTS f3; +DROP FUNCTION IF EXISTS f4; +CREATE FUNCTION f1() RETURNS VARCHAR(1) +BEGIN RETURN 'X'; END;/ +CREATE FUNCTION f2() RETURNS CHAR(1) +BEGIN RETURN 'X'; END;/ +CREATE FUNCTION f3() RETURNS VARCHAR(1) +BEGIN RETURN NULL; END;/ +CREATE FUNCTION f4() RETURNS CHAR(1) +BEGIN RETURN NULL; END;/ +SELECT f1() IS NULL; +f1() IS NULL +0 +SELECT f2() IS NULL; +f2() IS NULL +0 +SELECT f3() IS NULL; +f3() IS NULL +1 +SELECT f4() IS NULL; +f4() IS NULL +1 +DROP FUNCTION f1; +DROP FUNCTION f2; +DROP FUNCTION f3; +DROP FUNCTION f4; +# +# +# WL#6230: Remove 'SET = DEFAULT' +# +CREATE TABLE t1(a INT); +CREATE PROCEDURE p(p INT) +SET p = DEFAULT| +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DEFAULT' at line 2 +CREATE PROCEDURE p() +BEGIN +DECLARE v INT; +SET v = DEFAULT; +END| +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DEFAULT; +END' at line 4 +CREATE PROCEDURE p() +BEGIN +DECLARE v INT DEFAULT 1; +SET v = DEFAULT; +END| +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DEFAULT; +END' at line 4 +CREATE PROCEDURE p() +BEGIN +DECLARE v INT DEFAULT (SELECT * FROM t1); +SET v = DEFAULT; +END| +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DEFAULT; +END' at line 4 +CREATE TRIGGER t1_bu BEFORE UPDATE ON t1 FOR EACH ROW +BEGIN +SET NEW.a = DEFAULT; +END| +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DEFAULT; +END' at line 3 + +# Check that setting system variables to DEFAULT still works in SP. + +CREATE PROCEDURE p1() +SET @@default_storage_engine = DEFAULT; +SET @default_storage_engine_saved = @@default_storage_engine; +SELECT @@default_storage_engine; +@@default_storage_engine +InnoDB +SET @@default_storage_engine = InnoDB; +SELECT @@default_storage_engine; +@@default_storage_engine +InnoDB +CALL p1(); +SELECT @@default_storage_engine; +@@default_storage_engine +InnoDB +SET @@default_storage_engine = @default_storage_engine_saved; +DROP PROCEDURE p1; +DROP TABLE t1; +# End of 5.6 tests +# +# BUG 18484649 - STRICT MODE + CURSOR FETCH INTO WRONG TYPE, ASSERTION +# IN PROTOCOL::END_STATEMENT +# +SET @org_mode= @@sql_mode; +SET sql_mode= 'STRICT_TRANS_TABLES'; +Warnings: +Warning 3135 'NO_ZERO_DATE', 'NO_ZERO_IN_DATE' and 'ERROR_FOR_DIVISION_BY_ZERO' sql modes should be used with strict mode. They will be merged with strict mode in a future release. +CREATE TABLE t1(a INT) ENGINE= InnoDB; +INSERT INTO t1 VALUES (123456); +CREATE PROCEDURE p1() +BEGIN +DECLARE `v` TINYINT; +DECLARE `c` CURSOR FOR SELECT a FROM t1; +BEGIN +OPEN c; +FETCH c INTO v; +CLOSE c; +END; +END $ +# With the fix, Call to p1 will result in error as the routine was +# created in STRICT MODE. +CALL p1(); +ERROR 22003: Out of range value for column 'v' at row 1 +# Clean-up +SET sql_mode= @org_mode; +DROP PROCEDURE p1; +DROP TABLE t1; +# +# Bug#20583321: CRASH ON PS_THREAD_INFO / SYS USAGE +# +SET sql_mode = 'only_full_group_by'; +CREATE TABLE t1 ( a INT, b INT ); +CREATE TABLE t2 ( a INT ); +CREATE PROCEDURE p1 () +BEGIN +DECLARE output INT; +SET output = ( SELECT b FROM t1 LEFT JOIN t2 USING ( a ) GROUP BY t1.a ); +END $$ +CALL p1(); +ERROR 42000: Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'test.t1.b' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +CALL p1(); +ERROR 42000: Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'test.t1.b' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +DROP PROCEDURE p1; +PREPARE s FROM +'SET @x = ( SELECT b FROM t1 LEFT JOIN t2 USING ( a ) GROUP BY t1.a )'; +ERROR 42000: Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'test.t1.b' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +DROP TABLE t1, t2; +SET sql_mode = DEFAULT; +# +# ASSERTION FAILED: FALSE IN CREATE_TMP_FIELD WITH UNKNOWN OUTER FIELD +# +CREATE TABLE t1 ( a INT ); +SET @v = 1; +PREPARE stmt FROM 'SELECT 1 FROM ( SELECT ? FROM t1 GROUP BY a ) al;'; +EXECUTE stmt USING @v; +1 +PREPARE stmt FROM 'CREATE TABLE t2 AS SELECT ? FROM t1'; +EXECUTE stmt USING @v; +DROP TABLE t1, t2; +# +# Bug #18599181: CALLING A ROUTINE WITHOUT SPECIFYING DATABASE PREFIX +# MAY RETURN ERROR 1370 +# +CREATE DATABASE db1; +CREATE FUNCTION f1() RETURNS INT RETURN 1; +CREATE FUNCTION db1.f2() RETURNS INT RETURN test.f1(); +CREATE USER myuser@'localhost'; +GRANT ALL ON db1.* TO myuser@'localhost'; +SELECT f2(); +f2() +1 +SELECT f2(); +f2() +1 +DROP DATABASE db1; +DROP USER myuser@localhost; +DROP FUNCTION f1; +# +# WL#7897 -- Use DD API for Stored Routines. +# Basic test to verify: +# i) The table mysql.proc does not exists any more. +# ii) Stored routine metadata is still available with the +# information_schema tables "routines" and "parameters". +# These tables are filled from the new DD tables mysql.routine +# and mysql.parameter. +# iii) Basic test to cover "READS SQL DATA" in ALTER operation. +# +CREATE FUNCTION f1(a INT) RETURNS INT return 1; +CREATE PROCEDURE p1(IN a INT, INOUT b INT, OUT c INT) select 1; +# The table mysql.proc does not exists any more. +SELECT * FROM mysql.proc; +ERROR 42S02: Table 'mysql.proc' doesn't exist +# Metadata of stored function f1. +SELECT * FROM INFORMATION_SCHEMA.ROUTINES WHERE ROUTINE_NAME = 'f1'; +SPECIFIC_NAME ROUTINE_CATALOG ROUTINE_SCHEMA ROUTINE_NAME ROUTINE_TYPE DATA_TYPE CHARACTER_MAXIMUM_LENGTH CHARACTER_OCTET_LENGTH NUMERIC_PRECISION NUMERIC_SCALE DATETIME_PRECISION CHARACTER_SET_NAME COLLATION_NAME DTD_IDENTIFIER ROUTINE_BODY ROUTINE_DEFINITION EXTERNAL_NAME EXTERNAL_LANGUAGE PARAMETER_STYLE IS_DETERMINISTIC SQL_DATA_ACCESS SQL_PATH SECURITY_TYPE CREATED LAST_ALTERED SQL_MODE ROUTINE_COMMENT DEFINER CHARACTER_SET_CLIENT COLLATION_CONNECTION DATABASE_COLLATION +f1 def test f1 FUNCTION int NULL NULL 10 0 NULL NULL NULL int SQL return 1 NULL SQL SQL NO CONTAINS SQL NULL DEFINER ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION root@localhost utf8mb4 utf8mb4_0900_ai_ci utf8mb4_0900_ai_ci +SELECT * FROM INFORMATION_SCHEMA.PARAMETERS WHERE SPECIFIC_NAME = 'f1'; +SPECIFIC_CATALOG SPECIFIC_SCHEMA SPECIFIC_NAME ORDINAL_POSITION PARAMETER_MODE PARAMETER_NAME DATA_TYPE CHARACTER_MAXIMUM_LENGTH CHARACTER_OCTET_LENGTH NUMERIC_PRECISION NUMERIC_SCALE DATETIME_PRECISION CHARACTER_SET_NAME COLLATION_NAME DTD_IDENTIFIER ROUTINE_TYPE +def test f1 0 NULL NULL int NULL NULL 10 0 NULL NULL NULL int FUNCTION +def test f1 1 IN a int NULL NULL 10 0 NULL NULL NULL int FUNCTION +# Metadata of stored procedure p1. +SELECT * FROM INFORMATION_SCHEMA.ROUTINES WHERE ROUTINE_NAME = 'p1'; +SPECIFIC_NAME ROUTINE_CATALOG ROUTINE_SCHEMA ROUTINE_NAME ROUTINE_TYPE DATA_TYPE CHARACTER_MAXIMUM_LENGTH CHARACTER_OCTET_LENGTH NUMERIC_PRECISION NUMERIC_SCALE DATETIME_PRECISION CHARACTER_SET_NAME COLLATION_NAME DTD_IDENTIFIER ROUTINE_BODY ROUTINE_DEFINITION EXTERNAL_NAME EXTERNAL_LANGUAGE PARAMETER_STYLE IS_DETERMINISTIC SQL_DATA_ACCESS SQL_PATH SECURITY_TYPE CREATED LAST_ALTERED SQL_MODE ROUTINE_COMMENT DEFINER CHARACTER_SET_CLIENT COLLATION_CONNECTION DATABASE_COLLATION +p1 def test p1 PROCEDURE NULL NULL NULL NULL NULL NULL NULL NULL SQL select 1 NULL SQL SQL NO CONTAINS SQL NULL DEFINER ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION root@localhost utf8mb4 utf8mb4_0900_ai_ci utf8mb4_0900_ai_ci +SELECT * FROM INFORMATION_SCHEMA.PARAMETERS WHERE SPECIFIC_NAME = 'p1'; +SPECIFIC_CATALOG SPECIFIC_SCHEMA SPECIFIC_NAME ORDINAL_POSITION PARAMETER_MODE PARAMETER_NAME DATA_TYPE CHARACTER_MAXIMUM_LENGTH CHARACTER_OCTET_LENGTH NUMERIC_PRECISION NUMERIC_SCALE DATETIME_PRECISION CHARACTER_SET_NAME COLLATION_NAME DTD_IDENTIFIER ROUTINE_TYPE +def test p1 1 IN a int NULL NULL 10 0 NULL NULL NULL int PROCEDURE +def test p1 2 INOUT b int NULL NULL 10 0 NULL NULL NULL int PROCEDURE +def test p1 3 OUT c int NULL NULL 10 0 NULL NULL NULL int PROCEDURE +# Basic test to cover "READS SQL DATA" in ALTER operation. +ALTER FUNCTION f1 READS SQL DATA; +DROP FUNCTION f1; +DROP PROCEDURE p1; +# +# WL#9262: All system tables should support 32 character length user names +# +#This should just work with username + hostname of length 93 as DEFINER +CREATE USER user_name_robert_golebiowski1234@oh_my_gosh_this_is_a_long_hostname_look_at_it_it_has_60_char; +#For procedure +CREATE DEFINER=user_name_robert_golebiowski1234@oh_my_gosh_this_is_a_long_hostname_look_at_it_it_has_60_char PROCEDURE test.proc_test() SELECT CURRENT_USER(); +#and for function +CREATE DEFINER=user_name_robert_golebiowski1234@oh_my_gosh_this_is_a_long_hostname_look_at_it_it_has_60_char FUNCTION test.f_test() RETURNS INT RETURN 1; +SHOW PROCEDURE STATUS LIKE 'proc_test'; +Db Name Type Definer Modified Created Security_type Comment character_set_client collation_connection Database Collation +test proc_test PROCEDURE user_name_robert_golebiowski1234@oh_my_gosh_this_is_a_long_hostname_look_at_it_it_has_60_char # # DEFINER utf8mb4 utf8mb4_0900_ai_ci utf8mb4_0900_ai_ci +DROP PROCEDURE test.proc_test; +SHOW FUNCTION STATUS LIKE 'f_test'; +Db Name Type Definer Modified Created Security_type Comment character_set_client collation_connection Database Collation +test f_test FUNCTION user_name_robert_golebiowski1234@oh_my_gosh_this_is_a_long_hostname_look_at_it_it_has_60_char # # DEFINER utf8mb4 utf8mb4_0900_ai_ci utf8mb4_0900_ai_ci +DROP FUNCTION test.f_test; +DROP USER user_name_robert_golebiowski1234@oh_my_gosh_this_is_a_long_hostname_look_at_it_it_has_60_char; +set @old_concurrent_insert= @@global.concurrent_insert; +set @@global.concurrent_insert= 0; +drop table if exists t1,t3; +drop procedure if exists bug4902| +create procedure bug4902() +begin +show grants for 'root'@'localhost'; +end| +call bug4902()| +Grants for root@localhost +GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, RELOAD, SHUTDOWN, PROCESS, FILE, REFERENCES, INDEX, ALTER, SHOW DATABASES, SUPER, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, REPLICATION SLAVE, REPLICATION CLIENT, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, CREATE USER, EVENT, TRIGGER, CREATE TABLESPACE, CREATE ROLE, DROP ROLE ON *.* TO `root`@`localhost` WITH GRANT OPTION +GRANT APPLICATION_PASSWORD_ADMIN,AUDIT_ADMIN,BACKUP_ADMIN,BINLOG_ADMIN,BINLOG_ENCRYPTION_ADMIN,CLONE_ADMIN,CONNECTION_ADMIN,ENCRYPTION_KEY_ADMIN,FLUSH_OPTIMIZER_COSTS,FLUSH_STATUS,FLUSH_TABLES,FLUSH_USER_RESOURCES,GROUP_REPLICATION_ADMIN,INNODB_REDO_LOG_ARCHIVE,INNODB_REDO_LOG_ENABLE,PERSIST_RO_VARIABLES_ADMIN,REPLICATION_APPLIER,REPLICATION_SLAVE_ADMIN,RESOURCE_GROUP_ADMIN,RESOURCE_GROUP_USER,ROLE_ADMIN,SERVICE_CONNECTION_ADMIN,SESSION_VARIABLES_ADMIN,SET_USER_ID,SHOW_ROUTINE,SYSTEM_USER,SYSTEM_VARIABLES_ADMIN,TABLE_ENCRYPTION_ADMIN,XA_RECOVER_ADMIN ON *.* TO `root`@`localhost` WITH GRANT OPTION +GRANT PROXY ON ''@'' TO 'root'@'localhost' WITH GRANT OPTION +call bug4902()| +Grants for root@localhost +GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, RELOAD, SHUTDOWN, PROCESS, FILE, REFERENCES, INDEX, ALTER, SHOW DATABASES, SUPER, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, REPLICATION SLAVE, REPLICATION CLIENT, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, CREATE USER, EVENT, TRIGGER, CREATE TABLESPACE, CREATE ROLE, DROP ROLE ON *.* TO `root`@`localhost` WITH GRANT OPTION +GRANT APPLICATION_PASSWORD_ADMIN,AUDIT_ADMIN,BACKUP_ADMIN,BINLOG_ADMIN,BINLOG_ENCRYPTION_ADMIN,CLONE_ADMIN,CONNECTION_ADMIN,ENCRYPTION_KEY_ADMIN,FLUSH_OPTIMIZER_COSTS,FLUSH_STATUS,FLUSH_TABLES,FLUSH_USER_RESOURCES,GROUP_REPLICATION_ADMIN,INNODB_REDO_LOG_ARCHIVE,INNODB_REDO_LOG_ENABLE,PERSIST_RO_VARIABLES_ADMIN,REPLICATION_APPLIER,REPLICATION_SLAVE_ADMIN,RESOURCE_GROUP_ADMIN,RESOURCE_GROUP_USER,ROLE_ADMIN,SERVICE_CONNECTION_ADMIN,SESSION_VARIABLES_ADMIN,SET_USER_ID,SHOW_ROUTINE,SYSTEM_USER,SYSTEM_VARIABLES_ADMIN,TABLE_ENCRYPTION_ADMIN,XA_RECOVER_ADMIN ON *.* TO `root`@`localhost` WITH GRANT OPTION +GRANT PROXY ON ''@'' TO 'root'@'localhost' WITH GRANT OPTION +drop procedure bug4902| +drop procedure if exists bug4902_2| +create procedure bug4902_2() +begin +show processlist; +end| +call bug4902_2()| +show warnings| +Level Code Message +call bug4902_2()| +show warnings| +Level Code Message +drop procedure bug4902_2| +drop procedure if exists bug6807| +create procedure bug6807() +begin +declare id int; +set id = connection_id(); +kill query id; +select 'Not reached'; +end| +call bug6807()| +ERROR 70100: Query execution was interrupted +call bug6807()| +ERROR 70100: Query execution was interrupted +drop procedure bug6807| +SET sql_mode = 'NO_ENGINE_SUBSTITUTION'| +drop function if exists bug10100f| +drop procedure if exists bug10100p| +drop procedure if exists bug10100t| +drop procedure if exists bug10100pt| +drop procedure if exists bug10100pv| +drop procedure if exists bug10100pd| +drop procedure if exists bug10100pc| +create function bug10100f(prm int) returns int +begin +if prm > 1 then +return prm * bug10100f(prm - 1); +end if; +return 1; +end| +create procedure bug10100p(prm int, inout res int) +begin +set res = res * prm; +if prm > 1 then +call bug10100p(prm - 1, res); +end if; +end| +create procedure bug10100t(prm int) +begin +declare res int; +set res = 1; +call bug10100p(prm, res); +select res; +end| +create table t3 (a int)| +insert into t3 values (0)| +create view v1 as select a from t3; +create procedure bug10100pt(level int, lim int) +begin +if level < lim then +update t3 set a=level; +FLUSH TABLES; +call bug10100pt(level+1, lim); +else +select * from t3; +end if; +end| +create procedure bug10100pv(level int, lim int) +begin +if level < lim then +update v1 set a=level; +FLUSH TABLES; +call bug10100pv(level+1, lim); +else +select * from v1; +end if; +end| +prepare stmt2 from "select * from t3;"; +create procedure bug10100pd(level int, lim int) +begin +if level < lim then +select level; +prepare stmt1 from "update t3 set a=a+2"; +execute stmt1; +FLUSH TABLES; +execute stmt1; +FLUSH TABLES; +execute stmt1; +FLUSH TABLES; +deallocate prepare stmt1; +execute stmt2; +select * from t3; +call bug10100pd(level+1, lim); +else +execute stmt2; +end if; +end| +create procedure bug10100pc(level int, lim int) +begin +declare lv int; +declare c cursor for select a from t3; +open c; +if level < lim then +select level; +fetch c into lv; +select lv; +update t3 set a=level+lv; +FLUSH TABLES; +call bug10100pc(level+1, lim); +else +select * from t3; +end if; +close c; +end| +set @@max_sp_recursion_depth=255| +set @var=1| +call bug10100p(255, @var)| +call bug10100pt(1,255)| +call bug10100pv(1,255)| +call bug10100pd(1,255)| +call bug10100pc(1,255)| +set @@max_sp_recursion_depth=0| +deallocate prepare stmt2| +drop function bug10100f| +drop procedure bug10100p| +drop procedure bug10100t| +drop procedure bug10100pt| +drop procedure bug10100pv| +drop procedure bug10100pd| +drop procedure bug10100pc| +drop view v1| +drop table t3| +SET sql_mode = default; +drop procedure if exists bug15298_1; +drop procedure if exists bug15298_2; +create user 'mysqltest_1'@'localhost'; +grant all privileges on test.* to 'mysqltest_1'@'localhost'; +create procedure 15298_1 () sql security definer show grants for current_user; +create procedure 15298_2 () sql security definer show grants; +call 15298_1(); +Grants for root@localhost +GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, RELOAD, SHUTDOWN, PROCESS, FILE, REFERENCES, INDEX, ALTER, SHOW DATABASES, SUPER, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, REPLICATION SLAVE, REPLICATION CLIENT, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, CREATE USER, EVENT, TRIGGER, CREATE TABLESPACE, CREATE ROLE, DROP ROLE ON *.* TO `root`@`localhost` WITH GRANT OPTION +GRANT APPLICATION_PASSWORD_ADMIN,AUDIT_ADMIN,BACKUP_ADMIN,BINLOG_ADMIN,BINLOG_ENCRYPTION_ADMIN,CLONE_ADMIN,CONNECTION_ADMIN,ENCRYPTION_KEY_ADMIN,FLUSH_OPTIMIZER_COSTS,FLUSH_STATUS,FLUSH_TABLES,FLUSH_USER_RESOURCES,GROUP_REPLICATION_ADMIN,INNODB_REDO_LOG_ARCHIVE,INNODB_REDO_LOG_ENABLE,PERSIST_RO_VARIABLES_ADMIN,REPLICATION_APPLIER,REPLICATION_SLAVE_ADMIN,RESOURCE_GROUP_ADMIN,RESOURCE_GROUP_USER,ROLE_ADMIN,SERVICE_CONNECTION_ADMIN,SESSION_VARIABLES_ADMIN,SET_USER_ID,SHOW_ROUTINE,SYSTEM_USER,SYSTEM_VARIABLES_ADMIN,TABLE_ENCRYPTION_ADMIN,XA_RECOVER_ADMIN ON *.* TO `root`@`localhost` WITH GRANT OPTION +GRANT PROXY ON ''@'' TO 'root'@'localhost' WITH GRANT OPTION +call 15298_2(); +Grants for root@localhost +GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, RELOAD, SHUTDOWN, PROCESS, FILE, REFERENCES, INDEX, ALTER, SHOW DATABASES, SUPER, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, REPLICATION SLAVE, REPLICATION CLIENT, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, CREATE USER, EVENT, TRIGGER, CREATE TABLESPACE, CREATE ROLE, DROP ROLE ON *.* TO `root`@`localhost` WITH GRANT OPTION +GRANT APPLICATION_PASSWORD_ADMIN,AUDIT_ADMIN,BACKUP_ADMIN,BINLOG_ADMIN,BINLOG_ENCRYPTION_ADMIN,CLONE_ADMIN,CONNECTION_ADMIN,ENCRYPTION_KEY_ADMIN,FLUSH_OPTIMIZER_COSTS,FLUSH_STATUS,FLUSH_TABLES,FLUSH_USER_RESOURCES,GROUP_REPLICATION_ADMIN,INNODB_REDO_LOG_ARCHIVE,INNODB_REDO_LOG_ENABLE,PERSIST_RO_VARIABLES_ADMIN,REPLICATION_APPLIER,REPLICATION_SLAVE_ADMIN,RESOURCE_GROUP_ADMIN,RESOURCE_GROUP_USER,ROLE_ADMIN,SERVICE_CONNECTION_ADMIN,SESSION_VARIABLES_ADMIN,SET_USER_ID,SHOW_ROUTINE,SYSTEM_USER,SYSTEM_VARIABLES_ADMIN,TABLE_ENCRYPTION_ADMIN,XA_RECOVER_ADMIN ON *.* TO `root`@`localhost` WITH GRANT OPTION +GRANT PROXY ON ''@'' TO 'root'@'localhost' WITH GRANT OPTION +drop user mysqltest_1@localhost; +drop procedure 15298_1; +drop procedure 15298_2; +drop table if exists t1; +drop procedure if exists p1; +create table t1 (value varchar(15)) engine=Myisam; +create procedure p1() update t1 set value='updated' where value='old'; +call p1(); +insert into t1 (value) values ("old"); +select get_lock('b26162',120); +get_lock('b26162',120) +1 +select 'rl_acquirer', value from t1 where get_lock('b26162',120);; +set session low_priority_updates=on; +call p1();; +select 'rl_contender', value from t1; +rl_contender value +rl_contender old +select release_lock('b26162'); +release_lock('b26162') +1 +rl_acquirer value +rl_acquirer old +drop procedure p1; +drop table t1; +set session low_priority_updates=default; +INSERT INTO mysql.user (Host, User, Select_priv, Insert_priv, Update_priv, +Delete_priv, Create_priv, Drop_priv, Reload_priv, Shutdown_priv, Process_priv, File_priv, +Grant_priv, References_priv, Index_priv, Alter_priv, Show_db_priv, Super_priv, +Create_tmp_table_priv, Lock_tables_priv, Execute_priv, Repl_slave_priv, Repl_client_priv, +Create_view_priv, Show_view_priv, Create_routine_priv, Alter_routine_priv, +Create_user_priv, ssl_type, ssl_cipher, x509_issuer, x509_subject, max_questions, +max_updates, max_connections, max_user_connections) +VALUES('%', 'mysqltest_1', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'N', 'N', 'N', +'N', 'N', 'N', 'Y', 'Y', 'N', 'N', 'Y', 'Y', 'N', 'N', 'N', 'N', 'N', 'Y', 'Y', 'N', '', +'', '', '', '0', '0', '0', '0'); +FLUSH PRIVILEGES; +CREATE PROCEDURE p1(i INT) BEGIN END; +DROP PROCEDURE p1; +DELETE FROM mysql.user WHERE User='mysqltest_1'; +FLUSH PRIVILEGES; +# +# Bug#44521 Prepared Statement: CALL p() - crashes: `! thd->main_da.is_sent' failed et.al. +# +SELECT GET_LOCK('Bug44521', 0); +GET_LOCK('Bug44521', 0) +1 +** Connection con1 +CREATE PROCEDURE p() +BEGIN +SELECT 1; +SELECT GET_LOCK('Bug44521', 100); +SELECT 2; +END$ +CALL p();; +** Default connection +SELECT RELEASE_LOCK('Bug44521'); +RELEASE_LOCK('Bug44521') +1 +DROP PROCEDURE p; +CREATE TABLE t1(a int); +INSERT INTO t1 VALUES (1); +CREATE FUNCTION f1 (inp TEXT) RETURNS INT NO SQL RETURN GET_LOCK('Bug47736', 200); +CREATE VIEW v1 AS SELECT f1('a') FROM t1; +SELECT GET_LOCK('Bug47736', 0); +GET_LOCK('Bug47736', 0) +1 +SELECT * FROM v1;; +KILL QUERY ID; +ERROR 70100: Query execution was interrupted +DROP VIEW v1; +DROP TABLE t1; +DROP FUNCTION f1; +# ------------------------------------------------------------------ +# -- End of 5.1 tests +# ------------------------------------------------------------------ +# +# Test for bug#11763757 "56510: ERROR 42000: FUNCTION DOES NOT EXIST +# IF NOT-PRIV USER RECONNECTS ". +# +# The real problem was that server was unable handle properly stored +# functions in databases which names contained dot. +# +DROP DATABASE IF EXISTS `my.db`; +create database `my.db`; +use `my.db`; +CREATE FUNCTION f1(a int) RETURNS INT RETURN a; +# Create new connection. +USE `my.db`; +SELECT f1(1); +f1(1) +1 +SELECT `my.db`.f1(2); +`my.db`.f1(2) +2 +# Switching to default connection. +DROP DATABASE `my.db`; +USE test; +# +# Bug#11763507 - 56224: FUNCTION NAME IS CASE-SENSITIVE +# +SET @@SQL_MODE = ''; +CREATE EVENT teste_bug11763507 ON SCHEDULE AT CURRENT_TIMESTAMP + INTERVAL 1 HOUR +DO SELECT 1 $ +SHOW EVENTS LIKE 'teste_bug11763507'; +Db Name Definer Time zone Type Execute at Interval value Interval field Starts Ends Status Originator character_set_client collation_connection Database Collation +test teste_bug11763507 root@localhost SYSTEM ONE TIME # # # # NULL ENABLED 1 utf8mb4 utf8mb4_0900_ai_ci DATABASE_COLLATION +SHOW EVENTS LIKE 'TESTE_bug11763507'; +Db Name Definer Time zone Type Execute at Interval value Interval field Starts Ends Status Originator character_set_client collation_connection Database Collation +test teste_bug11763507 root@localhost SYSTEM ONE TIME # # # # NULL ENABLED 1 utf8mb4 utf8mb4_0900_ai_ci DATABASE_COLLATION +SHOW CREATE EVENT teste_bug11763507; +Event sql_mode time_zone Create Event character_set_client collation_connection Database Collation +teste_bug11763507 SYSTEM # utf8mb4 utf8mb4_0900_ai_ci DATABASE_COLLATION +SHOW CREATE EVENT TESTE_bug11763507; +Event sql_mode time_zone Create Event character_set_client collation_connection Database Collation +teste_bug11763507 SYSTEM # utf8mb4 utf8mb4_0900_ai_ci DATABASE_COLLATION +DROP EVENT teste_bug11763507; +#END OF BUG#11763507 test. + +# WL#4179: Stored programs: validation of stored program statements +# +# Test handle of metadata changes with events. + +CREATE TABLE t1 (a INT, b INT); +CREATE TABLE t2 (a INT, b INT); +CREATE TABLE t3 (a INT); +INSERT INTO t1 VALUES (1, 2); +SELECT COUNT(*) = 1 FROM information_schema.processlist +WHERE user = 'event_scheduler' AND command = 'Daemon'; +COUNT(*) = 1 +1 +SELECT GET_LOCK('e1_lock', 60); +GET_LOCK('e1_lock', 60) +1 +CREATE EVENT e1 ON SCHEDULE EVERY 1 SECOND STARTS NOW() DO +BEGIN +DECLARE EXIT HANDLER FOR 1136 BEGIN +INSERT INTO t3 VALUES (1); +END; -- ER_WRONG_VALUE_COUNT_ON_ROW +SELECT GET_LOCK('e1_lock', 60); +SELECT RELEASE_LOCK('e1_lock'); +INSERT INTO t2 SELECT * FROM t1; +END| +SELECT RELEASE_LOCK('e1_lock'); +RELEASE_LOCK('e1_lock') +1 +SELECT GET_LOCK('e1_lock', 60); +GET_LOCK('e1_lock', 60) +1 +ALTER TABLE t1 ADD COLUMN (c INT); +SELECT RELEASE_LOCK('e1_lock'); +RELEASE_LOCK('e1_lock') +1 +# Wait for new rows in t3. That means, the even has been executed, +# and INSERT INTO t2 failed because now t1 has 3 columns. +DROP EVENT e1; +DROP TABLE t1, t2, t3; +set @@global.concurrent_insert= @old_concurrent_insert; +# +# WL#2284: Increase the length of a user name +# +CREATE DATABASE test1; +CREATE TABLE test1.t1 ( +int_field INTEGER UNSIGNED NOT NULL, +char_field CHAR(10), +INDEX(`int_field`) +); +CREATE USER user_name_len_16@localhost; +CREATE USER user_name_len_22_01234@localhost; +CREATE USER user_name_len_32_012345678901234@localhost; +REVOKE ALL PRIVILEGES, GRANT OPTION FROM user_name_len_16@localhost; +REVOKE ALL PRIVILEGES, GRANT OPTION FROM user_name_len_22_01234@localhost; +# Check that user_name_len16 has no SELECT permission ON t1 +SELECT * FROM test1.t1; +ERROR 42000: SELECT command denied to user 'user_name_len_16'@'localhost' for table 't1' +# Check that user_name_len_22_01234 has no SELECT permission ON t1 +SELECT * FROM test1.t1; +ERROR 42000: SELECT command denied to user 'user_name_len_22_01234'@'localhost' for table 't1' +GRANT SELECT ON test1.t1 TO user_name_len_22_01234@localhost; +# Check that user_name_len_22_01234 has *now* SELECT permission ON t1 +SELECT * FROM test1.t1; +int_field char_field +CREATE DEFINER=user_name_len_22_01234@localhost PROCEDURE test1.p1_len22() +SELECT * FROM test1.t1; +GRANT EXECUTE ON PROCEDURE test1.p1_len22 TO user_name_len_22_01234@localhost; +GRANT EXECUTE ON PROCEDURE test1.p1_len22 TO user_name_len_16@localhost; +# Now user_name_len_16 should be able to SELECT FROM t1 by calling +# p1_len22 procedure +CALL test1.p1_len22(); +int_field char_field +CREATE DEFINER=user_name_len_33_0123456789012345@localhost PROCEDURE test1.p1_len33() +SELECT * FROM test1.t1; +ERROR HY000: String 'user_name_len_33_0123456789012345' is too long for user name (should be no longer than 32) +# REVOKE the SELECT permission from user_name_len_22_01234 +REVOKE SELECT ON test1.t1 FROM user_name_len_22_01234@localhost; +# and GRANT it to user_name_len_32_012345678901234 +GRANT SELECT ON test1.t1 TO user_name_len_32_012345678901234@localhost; +CREATE DEFINER = user_name_len_32_012345678901234@localhost FUNCTION test1.f1_len32() RETURNS INT +RETURN (SELECT COUNT(*) FROM test1.t1); +GRANT EXECUTE ON FUNCTION test1.f1_len32 TO user_name_len_32_012345678901234@localhost; +GRANT EXECUTE ON FUNCTION test1.f1_len32 TO user_name_len_22_01234@localhost; +GRANT SELECT ON test1.t1 TO user_name_len_22_01234@localhost; +# Now user_name_len_22_01234 should be able to SELECT COUNT(*) FROM t1 +# by calling f1_len32 function +SELECT test1.f1_len32(); +test1.f1_len32() +0 +# Recreate test1.p1_len22, this time with Security Context set to INVOKER +DROP PROCEDURE test1.p1_len22; +# Make sure user_name_len_22_01234 has SELECT privileges on test.t1 +SELECT * FROM test1.t1; +int_field char_field +CREATE DEFINER=user_name_len_22_01234@localhost PROCEDURE test1.p1_len22() +SQL SECURITY INVOKER +SELECT * FROM test1.t1; +GRANT EXECUTE ON PROCEDURE test1.p1_len22 TO user_name_len_22_01234@localhost; +GRANT EXECUTE ON PROCEDURE test1.p1_len22 TO user_name_len_16@localhost; +# Now user_name_len_16 should *NOT* be able to SELECT COUNT(*) FROM t1 +# by calling f1_len22 function as this function is using the INVOKER +# security context +CALL test1.p1_len22(); +ERROR 42000: SELECT command denied to user 'user_name_len_16'@'localhost' for table 't1' +CREATE DEFINER=user_name_len_33_0123456789012345@localhost FUNCTION test1.f1_len33() RETURNS INT +RETURN (SELECT COUNT(*) FROM test1.t1); +ERROR HY000: String 'user_name_len_33_0123456789012345' is too long for user name (should be no longer than 32) +DROP DATABASE test1; +DROP USER user_name_len_16@localhost; +DROP USER user_name_len_22_01234@localhost; +DROP USER user_name_len_32_012345678901234@localhost; +# +# BUG#28156802 - MYSQL 8 SERVICE GOES DOWN ON EXECUTING ONE PROCEDURE. +# +CREATE TABLE t1(y INT); +INSERT INTO t1 VALUES (5),(7),(9),(11),(15); +CREATE PROCEDURE `v1`(_limit_val BIGINT, _offset_val BIGINT) +BEGIN +CREATE TEMPORARY TABLE n1 AS (SELECT * FROM t1 LIMIT _limit_val OFFSET _offset_val); +SELECT * FROM n1; +END $$ +CALL v1(3,2); +y +9 +11 +15 +DROP PROCEDURE v1; +DROP TABLE t1; +# Cursor over union of two tables +CREATE TABLE t1(a INTEGER, b INTEGER); +INSERT INTO t1 VALUES(1, 10); +CREATE TABLE t2(c INTEGER, d INTEGER); +INSERT INTO t2 VALUES(2, 20); +CREATE PROCEDURE cursor_over_union(OUT sum_a INTEGER, OUT sum_b INTEGER) +BEGIN +DECLARE a INTEGER; +DECLARE b INTEGER; +DECLARE done INTEGER DEFAULT 0; +DECLARE c1 CURSOR FOR +SELECT t1.a, t1.b FROM t1 +UNION DISTINCT +SELECT t2.c, t2.d FROM t2; +DECLARE c2 CURSOR FOR +SELECT t1.a, t1.b FROM t1 +UNION ALL +SELECT t2.c, t2.d FROM t2; +DECLARE CONTINUE HANDLER FOR SQLSTATE '02000' SET done = 1; +SET sum_a = 0; +SET sum_b = 0; +OPEN c1; +REPEAT +FETCH c1 INTO a, b; +if NOT done THEN +SET sum_a = sum_a + a; +SET sum_b = sum_b + b; +END IF; +UNTIL done END REPEAT; +CLOSE c1; +SET done = 0; +OPEN c2; +REPEAT +FETCH c2 INTO a, b; +if NOT done THEN +SET sum_a = sum_a + a; +SET sum_b = sum_b + b; +END IF; +UNTIL done END REPEAT; +CLOSE c2; +end // +SET @sa = 0; +SET @sb = 0; +CALL cursor_over_union(@sa, @sb); +SELECT @sa, @sb; +@sa @sb +6 60 +DROP PROCEDURE cursor_over_union; +DROP TABLE t1, t2; +# +# Bug#30520714 - MYSQL SERVER RETURNS UNEXPECTED ROWS WHEN USING STORED +# FUNCTIONS IN WHERE CLAUSE +# +CREATE TABLE t1( f1 INT NOT NULL PRIMARY KEY, f2 INT); +INSERT INTO t1 VALUES (1, 1); +CREATE FUNCTION ReturnFalse() RETURNS BOOL +DETERMINISTIC +BEGIN +DECLARE result BOOL; +SET result = FALSE; +RETURN result; +END$$ +SELECT IF (COUNT(*) > 0, 'affected', 'not affected') FROM t1 +WHERE f1 = 1 AND f2 AND ReturnFalse(); +IF (COUNT(*) > 0, 'affected', 'not affected') +not affected +DROP FUNCTION ReturnFalse; +DROP TABLE t1; +# Bug#31691060: Assertion `!is_open()' in Materialized_cursor::~Materialized_cursor +CREATE TABLE t1(a INTEGER); +CREATE TABLE t2(a INTEGER, b INTEGER); +INSERT INTO t1 VALUES(0), (1), (2); +INSERT INTO t2 VALUES(1, 10), (2, 20), (2, 21); +CREATE PROCEDURE pc(val INTEGER) +BEGIN +DECLARE finished, col_a, col_b INTEGER DEFAULT 0; +DECLARE c CURSOR FOR +SELECT a, (SELECT b FROM t2 WHERE t1.a=t2.a) FROM t1 WHERE a = val; +DECLARE CONTINUE HANDLER FOR NOT FOUND SET finished = 1; +SET finished = 0; +OPEN c; +loop1: LOOP +FETCH c INTO col_a, col_b; +IF finished = 1 THEN +LEAVE loop1; +END IF; +END LOOP loop1; +CLOSE c; +END // +CREATE PROCEDURE pc_with_flush() +BEGIN +DECLARE finished, col_a, col_b INTEGER DEFAULT 0; +DECLARE val INTEGER DEFAULT 0; +DECLARE c CURSOR FOR +SELECT a, (SELECT b FROM t2 WHERE t1.a=t2.a) FROM t1 WHERE a = val; +DECLARE CONTINUE HANDLER FOR NOT FOUND SET finished = 1; +SET finished = 0; +OPEN c; +loop1: LOOP +FETCH c INTO col_a, col_b; +IF finished = 1 THEN +LEAVE loop1; +END IF; +END LOOP loop1; +CLOSE c; +FLUSH TABLES; +SET finished = 0; +SET val = 1; +OPEN c; +loop2: LOOP +FETCH c INTO col_a, col_b; +IF finished = 1 THEN +LEAVE loop2; +END IF; +END LOOP loop2; +CLOSE c; +FLUSH TABLES; +SET val = 2; +SET finished = 0; +OPEN c; +loop3: LOOP +FETCH c INTO col_a, col_b; +IF finished = 1 THEN +LEAVE loop3; +END IF; +END LOOP loop3; +CLOSE c; +END // +CALL pc(1); +CALL pc(2); +ERROR 21000: Subquery returns more than 1 row +FLUSH TABLES; +CALL pc(1); +CALL pc(2); +ERROR 21000: Subquery returns more than 1 row +FLUSH TABLES; +CALL pc(2); +ERROR 21000: Subquery returns more than 1 row +CALL pc(1); +CALL pc_with_flush(); +ERROR 21000: Subquery returns more than 1 row +DROP PROCEDURE pc; +DROP PROCEDURE pc_with_flush; +DROP TABLE t1, t2; +# Bug#32078387: Incorrect caching of information_schema variables in procedure +CREATE TABLE foo ( +id INTEGER NOT NULL AUTO_INCREMENT, +fld INTEGER NOT NULL, +PRIMARY KEY(id), +UNIQUE KEY fld(fld) +); +CREATE PROCEDURE test() BEGIN +SET @exist := (SELECT COUNT(*) FROM information_schema.statistics +WHERE table_name = 'foo' and +table_schema = database() and +index_name = 'fld'); +SELECT @exist; +END; +// +CALL test(); +@exist +1 +CALL test(); +@exist +1 +CALL test(); +@exist +1 +DROP PROCEDURE test; +DROP TABLE foo; +# Bug#31731334: m_sp != nullptr' at Item_func_sp::bind_fields in sql/item_func.cc +CREATE FUNCTION f1 (i INTEGER) RETURNS INTEGER +BEGIN +IF i = 0 THEN +RETURN 0; +END IF; +RETURN f2(); +END // +CREATE FUNCTION f2 () RETURNS INTEGER +RETURN f1(0) // +SELECT f2(); +f2() +0 +SELECT f1(1); +ERROR HY000: Recursive stored functions and triggers are not allowed. +DROP FUNCTION f1; +DROP FUNCTION f2; diff --git a/mysql-test/r/status.result-pq b/mysql-test/r/status.result-pq new file mode 100644 index 000000000000..ad14ef6cbf4b --- /dev/null +++ b/mysql-test/r/status.result-pq @@ -0,0 +1,521 @@ +set @old_concurrent_insert= @@global.concurrent_insert; +set @@global.concurrent_insert= 0; +SET @old_log_output = @@global.log_output; +SET GLOBAL LOG_OUTPUT = 'FILE'; +flush status; +show status like 'Table_lock%'; +Variable_name Value +Table_locks_immediate 1 +Table_locks_waited 0 +select * from performance_schema.session_status where variable_name like 'Table_lock%'; +VARIABLE_NAME VARIABLE_VALUE +Table_locks_immediate 2 +Table_locks_waited 0 +set sql_log_bin=0; +set @old_general_log = @@global.general_log; +set global general_log = 'OFF'; +drop table if exists t1; +create table t1(n int); +insert into t1 values(1); +select get_lock('mysqltest_lock', 100); +get_lock('mysqltest_lock', 100) +1 +# Switched to connection: con2 +# Sending: +update t1 set n = get_lock('mysqltest_lock', 100) ; +# Switched to connection: con1 +# Wait for the first UPDATE to get blocked. +# Sending: +update t1 set n = 3; +# Switched to connection: default +# wait for the second UPDATE to get blocked +Timeout in wait_condition.inc for select 1 from INFORMATION_SCHEMA.PROCESSLIST +where ID = (select connection_id()) and STATE = "Waiting for table level lock" +select release_lock('mysqltest_lock'); +release_lock('mysqltest_lock') +1 +# Switched to connection: con2 +# Reaping first UPDATE +select release_lock('mysqltest_lock'); +release_lock('mysqltest_lock') +1 +# Switched to connection: con1 +# Reaping second UPDATE +show status like 'Table_locks_waited'; +Variable_name Value +Table_locks_waited 0 +# Switched to connection: default +drop table t1; +set global general_log = @old_general_log; +select 1; +1 +1 +show status like 'last_query_cost'; +Variable_name Value +Last_query_cost 0.000000 +create table t1 (a int); +insert into t1 values (1),(2),(3),(4),(5),(6),(7),(8),(9),(10); +insert into t1 values (1),(2),(3),(4),(5),(6),(7),(8),(9),(10); +insert into t1 values (1),(2),(3),(4),(5),(6),(7),(8),(9),(10); +insert into t1 values (1),(2),(3),(4),(5),(6),(7),(8),(9),(10); +insert into t1 values (1),(2),(3),(4),(5),(6),(7),(8),(9),(10); +analyze table t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +select * from t1 where a=6; +a +6 +6 +6 +6 +6 +show status like 'last_query_cost'; +Variable_name Value +Last_query_cost 5.249000 +show status like 'last_query_cost'; +Variable_name Value +Last_query_cost 5.249000 +select 1; +1 +1 +show status like 'last_query_cost'; +Variable_name Value +Last_query_cost 0.000000 +drop table t1; +FLUSH STATUS; +SHOW STATUS LIKE 'max_used_connections'; +Variable_name Value +Max_used_connections 1 +SELECT * FROM performance_schema.session_status WHERE VARIABLE_NAME LIKE 'max_used_connections'; +VARIABLE_NAME VARIABLE_VALUE +Max_used_connections 1 +SET @save_thread_cache_size=@@thread_cache_size; +SET GLOBAL thread_cache_size=3; +SHOW STATUS LIKE 'max_used_connections'; +Variable_name Value +Max_used_connections 3 +SELECT * FROM performance_schema.session_status WHERE VARIABLE_NAME LIKE 'max_used_connections'; +VARIABLE_NAME VARIABLE_VALUE +Max_used_connections 3 +FLUSH STATUS; +SHOW STATUS LIKE 'max_used_connections'; +Variable_name Value +Max_used_connections 2 +SELECT * FROM performance_schema.session_status WHERE VARIABLE_NAME LIKE 'max_used_connections'; +VARIABLE_NAME VARIABLE_VALUE +Max_used_connections 2 +SHOW STATUS LIKE 'max_used_connections'; +Variable_name Value +Max_used_connections 3 +SELECT * FROM performance_schema.session_status WHERE VARIABLE_NAME LIKE 'max_used_connections'; +VARIABLE_NAME VARIABLE_VALUE +Max_used_connections 3 +SHOW STATUS LIKE 'max_used_connections'; +Variable_name Value +Max_used_connections 4 +SELECT * FROM performance_schema.session_status WHERE VARIABLE_NAME LIKE 'max_used_connections'; +VARIABLE_NAME VARIABLE_VALUE +Max_used_connections 4 +SET GLOBAL thread_cache_size=@save_thread_cache_size; +CREATE TABLE t1 ( a INT ); +INSERT INTO t1 VALUES (1), (2); +analyze table t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +SELECT a FROM t1 LIMIT 1; +a +1 +SHOW SESSION STATUS LIKE 'Last_query_cost'; +Variable_name Value +Last_query_cost 0.449000 +EXPLAIN SELECT a FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` +SHOW SESSION STATUS LIKE 'Last_query_cost'; +Variable_name Value +Last_query_cost 0.449000 +SELECT a FROM t1 UNION SELECT a FROM t1 ORDER BY a; +a +1 +2 +SHOW SESSION STATUS LIKE 'Last_query_cost'; +Variable_name Value +Last_query_cost 0.898000 +EXPLAIN SELECT a FROM t1 UNION SELECT a FROM t1 ORDER BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 UNION t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +NULL UNION RESULT NULL ALL NULL NULL NULL NULL NULL NULL Using temporary; Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` union /* select#2 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` order by `a` +SHOW SESSION STATUS LIKE 'Last_query_cost'; +Variable_name Value +Last_query_cost 0.898000 +SELECT a IN (SELECT a FROM t1) FROM t1 LIMIT 1; +a IN (SELECT a FROM t1) +1 +SHOW SESSION STATUS LIKE 'Last_query_cost'; +Variable_name Value +Last_query_cost 0.898000 +SELECT (SELECT a FROM t1 LIMIT 1) x FROM t1 LIMIT 1; +x +1 +SHOW SESSION STATUS LIKE 'Last_query_cost'; +Variable_name Value +Last_query_cost 0.898000 +SELECT * FROM t1 a, t1 b ORDER BY a.a, b.a LIMIT 1; +a a +1 1 +SHOW SESSION STATUS LIKE 'Last_query_cost'; +Variable_name Value +Last_query_cost 1.099010 +DROP TABLE t1; +flush status; +show status like 'Com%function'; +Variable_name Value +Com_alter_function 0 +Com_create_function 0 +Com_drop_function 0 +create function f1 (x INTEGER) returns integer +begin +declare ret integer; +set ret = x * 10; +return ret; +end // +drop function f1; +show status like 'Com%function'; +Variable_name Value +Com_alter_function 0 +Com_create_function 1 +Com_drop_function 1 +create database db37908; +create table db37908.t1(f1 int); +insert into db37908.t1 values(1); +create user mysqltest_1@localhost; +grant usage,execute on test.* to mysqltest_1@localhost; +create procedure proc37908() begin select 1; end | +create function func37908() returns int sql security invoker +return (select * from db37908.t1 limit 1)| +select * from db37908.t1; +ERROR 42000: SELECT command denied to user 'mysqltest_1'@'localhost' for table 't1' +show status where variable_name ='uptime' and 2 in (select * from db37908.t1); +ERROR 42000: SELECT command denied to user 'mysqltest_1'@'localhost' for table 't1' +show procedure status where name ='proc37908' and 1 in (select f1 from db37908.t1); +ERROR 42000: SELECT command denied to user 'mysqltest_1'@'localhost' for table 't1' +show function status where name ='func37908' and 1 in (select func37908()); +ERROR 42000: SELECT command denied to user 'mysqltest_1'@'localhost' for table 't1' +drop database db37908; +drop procedure proc37908; +drop function func37908; +REVOKE ALL PRIVILEGES, GRANT OPTION FROM mysqltest_1@localhost; +DROP USER mysqltest_1@localhost; +DROP PROCEDURE IF EXISTS p1; +DROP FUNCTION IF EXISTS f1; +CREATE FUNCTION f1() RETURNS INTEGER +BEGIN +DECLARE foo INTEGER; +DECLARE bar INTEGER; +SET foo=1; +SET bar=2; +RETURN foo; +END $$ +CREATE PROCEDURE p1() +BEGIN +SELECT 1; +END $$ +SELECT f1(); +f1() +1 +CALL p1(); +1 +1 +SELECT 9; +9 +9 +DROP PROCEDURE p1; +DROP FUNCTION f1; +# +# Test coverage for status variables which were introduced by +# WL#5772 "Add partitioned Table Definition Cache to avoid +# using LOCK_open and its derivatives in DML queries". +# +create table t1 (i int); +create table t2 (j int); +create table t3 (k int); +# Flush table cache to ensure that it is empty and reset status +# variables. Since to test cache overflow we will need to reduce +# its size, also save original table cache size. +flush tables; +flush status; +set @old_table_open_cache= @@table_open_cache; +# Check that after reset all status variables are zero. +show status like 'table_open_cache_%'; +Variable_name Value +Table_open_cache_hits 0 +Table_open_cache_misses 0 +Table_open_cache_overflows 0 +# The first statement accessing t1 after flush should result +# in table cache miss. +select * from t1; +i +show status like 'table_open_cache_%'; +Variable_name Value +Table_open_cache_hits 1 +Table_open_cache_misses 16 +Table_open_cache_overflows 0 +# The second statement accessing the same table should +# result in table cache hit. +select * from t1; +i +show status like 'table_open_cache_%'; +Variable_name Value +Table_open_cache_hits 2 +Table_open_cache_misses 16 +Table_open_cache_overflows 0 +# Again table cache miss if accessing different table. +select * from t2; +j +show status like 'table_open_cache_%'; +Variable_name Value +Table_open_cache_hits 18 +Table_open_cache_misses 17 +Table_open_cache_overflows 0 +# And cache hit then accessing it second time. +select * from t2; +j +show status like 'table_open_cache_%'; +Variable_name Value +Table_open_cache_hits 19 +Table_open_cache_misses 17 +Table_open_cache_overflows 0 +# The below statement should result in 2 cache hits and +# 4 cache misses since it needs 6 table instances in total. +select * from t1 as a, t2 as b, t1 as c, t2 as d, t1 as e, t2 as f; +i j i j i j +show status like 'table_open_cache_%'; +Variable_name Value +Table_open_cache_hits 25 +Table_open_cache_misses 17 +Table_open_cache_overflows 0 +# Reduce size of table cache to check that status +# variable tracking cache overflows works. +set @@global.table_open_cache= 4; +# The below statement should result in table cache hit, but +# as a side effect it should result in trimming of table +# cache by 2 TABLE instances, meaning that overflow counter +# will get increased by 2. +select * from t1; +i +show status like 'table_open_cache_%'; +Variable_name Value +Table_open_cache_hits 26 +Table_open_cache_misses 17 +Table_open_cache_overflows 0 +# This statement should result in 4 cache hits, 2 cache misses/ +# overflows. +select * from t1 as a, t2 as b, t1 as c, t2 as d, t1 as e, t2 as f; +i j i j i j +show status like 'table_open_cache_%'; +Variable_name Value +Table_open_cache_hits 28 +Table_open_cache_misses 21 +Table_open_cache_overflows 4 +# Finally, the below statement should result in 1 cache miss +# and 1 overflow since it accesses table which is not yet in +# cache and table cache is full. +select * from t3; +k +show status like 'table_open_cache_%'; +Variable_name Value +Table_open_cache_hits 28 +Table_open_cache_misses 38 +Table_open_cache_overflows 21 +# Cleanup +set @@global.table_open_cache= @old_table_open_cache; +drop tables t1, t2, t3; +SHOW STATUS LIKE 'max_used_connections_time'; +Variable_name Value +Max_used_connections_time DTVALUE +# Should report 4 +SHOW STATUS LIKE 'max_used_connections'; +Variable_name Value +Max_used_connections 4 +# Should report 4 +SHOW STATUS LIKE 'max_used_connections'; +Variable_name Value +Max_used_connections 4 +# This should report 0 as it must have the same value as above +TIMESTAMPDIFF(SECOND,'DTVALUE','DTVALUE') <> 0 +0 +# This should report 0 as timestamp is updated only when connection count strictly exceeds the previos highest value +TIMESTAMPDIFF(SECOND,'DTVALUE','DTVALUE') <> 0 +0 +FLUSH STATUS; +# This should not report 0 as FLUSH STATUS is called. +TIMESTAMPDIFF(SECOND,'DTVALUE','DTVALUE') <> 0 +1 +set @@global.concurrent_insert= @old_concurrent_insert; +SET GLOBAL log_output = @old_log_output; +# +# Bug#28786951 SET LAST_QUERY_COST FOR QUERIES WITH SUBQUERIES AND UNIONS +# +CREATE TABLE t1(x INT, y INT); +INSERT INTO t1 VALUES (1, 2), (3, 4), (5, 6); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT * FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`x` AS `x`,`test`.`t1`.`y` AS `y` from `test`.`t1` +SHOW STATUS LIKE 'Last_query_cost'; +Variable_name Value +Last_query_cost 0.549000 +EXPLAIN SELECT (SELECT MAX(x) FROM t1) FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 SUBQUERY t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select (/* select#2 */ select max(`test`.`t1`.`x`) from `test`.`t1`) AS `(SELECT MAX(x) FROM t1)` from `test`.`t1` +SHOW STATUS LIKE 'Last_query_cost'; +Variable_name Value +Last_query_cost 1.098000 +EXPLAIN SELECT * FROM t1 WHERE x IN (SELECT MAX(x) FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`x` AS `x`,`test`.`t1`.`y` AS `y` from `test`.`t1` where (`test`.`t1`.`x`,(/* select#2 */ select max(`test`.`t1`.`x`) from `test`.`t1` having ((`test`.`t1`.`x`) = (max(`test`.`t1`.`x`))))) +SHOW STATUS LIKE 'Last_query_cost'; +Variable_name Value +Last_query_cost 2.196000 +EXPLAIN SELECT /*+ NO_MERGE(a) */ * FROM (SELECT * FROM t1) a, t1 b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY b NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DERIVED t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select /*+ NO_MERGE(`a`@`select#1`) */ `a`.`x` AS `x`,`a`.`y` AS `y`,`test`.`b`.`x` AS `x`,`test`.`b`.`y` AS `y` from (/* select#2 */ select `test`.`t1`.`x` AS `x`,`test`.`t1`.`y` AS `y` from `test`.`t1`) `a` join `test`.`t1` `b` +SHOW STATUS LIKE 'Last_query_cost'; +Variable_name Value +Last_query_cost 4.535526 +EXPLAIN SELECT * FROM t1 WHERE x > 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`x` AS `x`,`test`.`t1`.`y` AS `y` from `test`.`t1` where (`test`.`t1`.`x` > 0) +SHOW STATUS LIKE 'Last_query_cost'; +Variable_name Value +Last_query_cost 0.549000 +EXPLAIN SELECT * FROM t1 WHERE y > 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`x` AS `x`,`test`.`t1`.`y` AS `y` from `test`.`t1` where (`test`.`t1`.`y` > 0) +SHOW STATUS LIKE 'Last_query_cost'; +Variable_name Value +Last_query_cost 0.549000 +EXPLAIN SELECT * FROM t1 WHERE x > 0 +UNION ALL +SELECT * FROM t1 WHERE y > 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +2 UNION t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`x` AS `x`,`test`.`t1`.`y` AS `y` from `test`.`t1` where (`test`.`t1`.`x` > 0) union all /* select#2 */ select `test`.`t1`.`x` AS `x`,`test`.`t1`.`y` AS `y` from `test`.`t1` where (`test`.`t1`.`y` > 0) +SHOW STATUS LIKE 'Last_query_cost'; +Variable_name Value +Last_query_cost 1.098000 +EXPLAIN SELECT * FROM t1 WHERE x > 0 +UNION DISTINCT +SELECT * FROM t1 WHERE y > 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +2 UNION t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +NULL UNION RESULT NULL ALL NULL NULL NULL NULL NULL NULL Using temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`x` AS `x`,`test`.`t1`.`y` AS `y` from `test`.`t1` where (`test`.`t1`.`x` > 0) union /* select#2 */ select `test`.`t1`.`x` AS `x`,`test`.`t1`.`y` AS `y` from `test`.`t1` where (`test`.`t1`.`y` > 0) +SHOW STATUS LIKE 'Last_query_cost'; +Variable_name Value +Last_query_cost 1.098000 +EXPLAIN INSERT INTO t1 SELECT * FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 INSERT t1 NULL ALL NULL NULL NULL NULL NULL NULL NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using temporary +Warnings: +Note 1003 insert into `test`.`t1` /* select#1 */ select sql_buffer_result `test`.`t1`.`x` AS `x`,`test`.`t1`.`y` AS `y` from `test`.`t1` +SHOW STATUS LIKE 'Last_query_cost'; +Variable_name Value +Last_query_cost 0.549000 +EXPLAIN INSERT INTO t1 +SELECT * FROM t1 WHERE x > 0 +UNION ALL +SELECT * FROM t1 WHERE y > 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 INSERT t1 NULL ALL NULL NULL NULL NULL NULL NULL NULL +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +2 UNION t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +NULL UNION RESULT NULL ALL NULL NULL NULL NULL NULL NULL Using temporary +Warnings: +Note 1003 insert into `test`.`t1` /* select#1 */ select `test`.`t1`.`x` AS `x`,`test`.`t1`.`y` AS `y` from `test`.`t1` where (`test`.`t1`.`x` > 0) union all /* select#2 */ select `test`.`t1`.`x` AS `x`,`test`.`t1`.`y` AS `y` from `test`.`t1` where (`test`.`t1`.`y` > 0) +SHOW STATUS LIKE 'Last_query_cost'; +Variable_name Value +Last_query_cost 1.098000 +EXPLAIN INSERT INTO t1 +SELECT * FROM t1 WHERE x > 0 +UNION DISTINCT +SELECT * FROM t1 WHERE y > 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 INSERT t1 NULL ALL NULL NULL NULL NULL NULL NULL NULL +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +2 UNION t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +NULL UNION RESULT NULL ALL NULL NULL NULL NULL NULL NULL Using temporary +Warnings: +Note 1003 insert into `test`.`t1` /* select#1 */ select `test`.`t1`.`x` AS `x`,`test`.`t1`.`y` AS `y` from `test`.`t1` where (`test`.`t1`.`x` > 0) union /* select#2 */ select `test`.`t1`.`x` AS `x`,`test`.`t1`.`y` AS `y` from `test`.`t1` where (`test`.`t1`.`y` > 0) +SHOW STATUS LIKE 'Last_query_cost'; +Variable_name Value +Last_query_cost 1.098000 +DROP TABLE t1; +# +# Bug#28884359: LAST_QUERY_COST IS NEGATIVE AFTER ORDER BY/LIMIT QUERY +# +CREATE TABLE t1 (pk INTEGER PRIMARY KEY, +i1 INTEGER, +i2 INTEGER NOT NULL, +INDEX k1 (i1), +INDEX k2 (i1, i2)); +INSERT INTO t1 VALUES +(1, NULL, 43), (11, NULL, 103), (10, 32,50), (9, 12, 43), +(8, NULL, 13), (7, 48, 90), (6, 56, 90), (5, 87, 84), +(4, 58, 98), (3, 30, 82), (2, 54, 57), (12, 232, 43), +(13, 43, 103), (14, 32, 45), (15, 12, 43), (16, 89, 23), +(17, 48, 90), (18, 56, 90), (19, 87, 84); +CREATE TABLE t2 (pk INTEGER PRIMARY KEY, +i1 INTEGER NOT NULL, +INDEX k1 (i1)); +INSERT INTO t2 VALUES +(3, 89), (4, 98), (5, 84), (6, 8), (7, 99), (8, 110), +(9, 84), (10, 98), (11, 103), (12, 50), (13, 84), +(14, 57), (15, 82), (16, 103), (2, 98), (1, 90); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN SELECT * FROM t1, t2 WHERE t1.i1 = t2.i1 ORDER BY t1.i1 LIMIT 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index k1,k2 k2 9 NULL 10 100.00 Using where; Using index +2 SIMPLE t2 NULL ref k1 k1 4 test.t1.i1 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`i1` AS `i1`,`test`.`t1`.`i2` AS `i2`,`test`.`t2`.`pk` AS `pk`,`test`.`t2`.`i1` AS `i1` from `test`.`t1` join `test`.`t2` where (`test`.`t2`.`i1` = `test`.`t1`.`i1`) order by `test`.`t1`.`i1` limit 10 +SHOW STATUS LIKE 'Last_query_cost'; +Variable_name Value +Last_query_cost 9.664743 +DROP TABLE t1, t2; diff --git a/mysql-test/r/subquery_antijoin.result-pq b/mysql-test/r/subquery_antijoin.result-pq new file mode 100644 index 000000000000..06079ac3a4f6 --- /dev/null +++ b/mysql-test/r/subquery_antijoin.result-pq @@ -0,0 +1,1155 @@ +CREATE TABLE t1( +pk INTEGER PRIMARY KEY, +uk INTEGER UNIQUE, +ukn INTEGER UNIQUE NOT NULL, +ik INTEGER, +d INTEGER, +INDEX ik(ik)); +INSERT INTO t1 VALUES +(0, NULL, 0, NULL, NULL), +(1, 10, 20, 30, 40), +(2, 20, 40, 60, 80); +CREATE TABLE t2( +pk INTEGER PRIMARY KEY); +INSERT INTO t2 VALUES +(1), (2), (3), (4), (5), (6), (7), (8), (9),(10), +(11),(12),(13),(14),(15),(16),(17),(18),(19),(20), +(21),(22),(23),(24),(25),(26),(27),(28),(29),(30), +(31),(32),(33),(34),(35),(36),(37),(38),(39),(40), +(41),(42),(43),(44),(45),(46),(47),(48),(49),(50), +(51),(52),(53),(54),(55),(56),(57),(58),(59),(60), +(61),(62),(63),(64),(65),(66),(67),(68),(69),(70), +(71),(72),(73),(74),(75),(76),(77),(78),(79),(80); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +set optimizer_switch="firstmatch=on,materialization=off"; +select @@optimizer_switch; +@@optimizer_switch +index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,engine_condition_pushdown=on,index_condition_pushdown=on,mrr=on,mrr_cost_based=on,block_nested_loop=on,batched_key_access=off,materialization=off,semijoin=on,loosescan=on,firstmatch=on,duplicateweedout=on,subquery_materialization_cost_based=on,use_index_extensions=on,condition_fanout_filter=on,derived_merge=on,use_invisible_indexes=off,skip_scan=on,hash_join=on,subquery_to_derived=off,prefer_ordering_index=on,hypergraph_optimizer=off,derived_condition_pushdown=on +EXPLAIN SELECT 1 as a FROM dual +WHERE NOT EXISTS (SELECT * FROM t1 AS it); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +2 SUBQUERY it NULL index NULL ukn 4 NULL 3 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select 1 AS `a` from DUAL where false +SELECT 1 as a FROM dual +WHERE NOT EXISTS (SELECT * FROM t1 AS it); +a +EXPLAIN SELECT 1 as a FROM t2 as ot +WHERE NOT EXISTS (SELECT * FROM t1 AS it); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +2 SUBQUERY it NULL index NULL ukn 4 NULL 3 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select 1 AS `a` from `test`.`t2` `ot` where false +SELECT 1 as a FROM t2 as ot +WHERE NOT EXISTS (SELECT * FROM t1 AS it); +a +EXPLAIN SELECT pk FROM t2 as ot +WHERE NOT EXISTS (SELECT * FROM t1 AS it WHERE it.uk=ot.pk) +AND ot.pk<25; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 24 100.00 Parallel execute (1 workers) +2 SIMPLE ot NULL range PRIMARY PRIMARY 4 NULL 24 100.00 Using where; Using index +2 SIMPLE it NULL eq_ref uk uk 5 test.ot.pk 1 100.00 Using where; Not exists; Using index +Warnings: +Note 1276 Field or reference 'test.ot.pk' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`ot`.`pk` AS `pk` from `test`.`t2` `ot` anti join (`test`.`t1` `it`) on((`test`.`it`.`uk` = `test`.`ot`.`pk`)) where (`test`.`ot`.`pk` < 25) +EXPLAIN FORMAT=JSON SELECT pk FROM t2 as ot +WHERE NOT EXISTS (SELECT * FROM t1 AS it WHERE it.uk=ot.pk) +AND ot.pk<25; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost: # + "query_cost: # + }, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 24, + "rows_produced_per_join": 24, + "filtered": "100.00", + "parallel_execute": "1 workers", + "cost: # + "read_cost: # + "eval_cost: # + "prefix_cost: # + "data_read_per_join": "384" + }, + "used_columns": [ + "pk" + ], + "query_block": { + "cost: # + "query_cost: # + }, + "nested_loop": [ + { + "table": { + "select_id": 2, + "table_name": "ot", + "access_type": "range", + "possible_keys": [ + "PRIMARY" + ], + "key": "PRIMARY", + "used_key_parts": [ + "pk" + ], + "key_length": "4", + "rows_examined_per_scan": 24, + "rows_produced_per_join": 24, + "filtered": "100.00", + "using_index": true, + "cost: # + "read_cost: # + "eval_cost: # + "prefix_cost: # + "data_read_per_join": "192" + }, + "used_columns": [ + "pk" + ], + "attached_condition": "(`test`.`ot`.`pk` < 25)" + } + }, + { + "table": { + "select_id": 2, + "table_name": "it", + "access_type": "eq_ref", + "possible_keys": [ + "uk" + ], + "key": "uk", + "used_key_parts": [ + "uk" + ], + "key_length": "5", + "ref": [ + "test.ot.pk" + ], + "rows_examined_per_scan": 1, + "rows_produced_per_join": 24, + "filtered": "100.00", + "not_exists": true, + "using_index": true, + "cost: # + "read_cost: # + "eval_cost: # + "prefix_cost: # + "data_read_per_join": "576" + }, + "used_columns": [ + "uk" + ], + "attached_condition": "(is_not_null_compl(it), (found_match(it), false, true), true)" + } + } + ] + } + } + } +} +Warnings: +Note 1276 Field or reference 'test.ot.pk' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`ot`.`pk` AS `pk` from `test`.`t2` `ot` anti join (`test`.`t1` `it`) on((`test`.`it`.`uk` = `test`.`ot`.`pk`)) where (`test`.`ot`.`pk` < 25) +SELECT pk FROM t2 as ot +WHERE NOT EXISTS (SELECT * FROM t1 AS it WHERE it.uk=ot.pk) +AND ot.pk<25; +pk +1 +2 +3 +4 +5 +6 +7 +8 +9 +11 +12 +13 +14 +15 +16 +17 +18 +19 +21 +22 +23 +24 +set optimizer_switch="firstmatch=off,materialization=on"; +select @@optimizer_switch; +@@optimizer_switch +index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,engine_condition_pushdown=on,index_condition_pushdown=on,mrr=on,mrr_cost_based=on,block_nested_loop=on,batched_key_access=off,materialization=on,semijoin=on,loosescan=on,firstmatch=off,duplicateweedout=on,subquery_materialization_cost_based=on,use_index_extensions=on,condition_fanout_filter=on,derived_merge=on,use_invisible_indexes=off,skip_scan=on,hash_join=on,subquery_to_derived=off,prefer_ordering_index=on,hypergraph_optimizer=off,derived_condition_pushdown=on +EXPLAIN SELECT 1 as a FROM dual +WHERE NOT EXISTS (SELECT * FROM t1 AS it); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +2 SUBQUERY it NULL index NULL ukn 4 NULL 3 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select 1 AS `a` from DUAL where false +SELECT 1 as a FROM dual +WHERE NOT EXISTS (SELECT * FROM t1 AS it); +a +EXPLAIN SELECT 1 as a FROM t2 as ot +WHERE NOT EXISTS (SELECT * FROM t1 AS it); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +2 SUBQUERY it NULL index NULL ukn 4 NULL 3 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select 1 AS `a` from `test`.`t2` `ot` where false +SELECT 1 as a FROM t2 as ot +WHERE NOT EXISTS (SELECT * FROM t1 AS it); +a +EXPLAIN SELECT pk FROM t2 as ot +WHERE NOT EXISTS (SELECT * FROM t1 AS it WHERE it.uk=ot.pk) +AND ot.pk<25; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot NULL range PRIMARY PRIMARY 4 NULL 24 100.00 Using where; Using index +1 SIMPLE NULL eq_ref 5 test.ot.pk 1 100.00 Using where; Not exists +2 MATERIALIZED it NULL index uk uk 5 NULL 3 100.00 Using index +Warnings: +Note 1276 Field or reference 'test.ot.pk' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`ot`.`pk` AS `pk` from `test`.`t2` `ot` anti join (`test`.`t1` `it`) on((``.`uk` = `test`.`ot`.`pk`)) where (`test`.`ot`.`pk` < 25) +EXPLAIN FORMAT=JSON SELECT pk FROM t2 as ot +WHERE NOT EXISTS (SELECT * FROM t1 AS it WHERE it.uk=ot.pk) +AND ot.pk<25; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost: # + "query_cost: # + }, + "nested_loop": [ + { + "table": { + "table_name": "ot", + "access_type": "range", + "possible_keys": [ + "PRIMARY" + ], + "key": "PRIMARY", + "used_key_parts": [ + "pk" + ], + "key_length": "4", + "rows_examined_per_scan": 24, + "rows_produced_per_join": 24, + "filtered": "100.00", + "using_index": true, + "cost: # + "read_cost: # + "eval_cost: # + "prefix_cost: # + "data_read_per_join": "192" + }, + "used_columns": [ + "pk" + ], + "attached_condition": "(`test`.`ot`.`pk` < 25)" + } + }, + { + "table": { + "table_name": "", + "access_type": "eq_ref", + "key": "", + "key_length": "5", + "ref": [ + "test.ot.pk" + ], + "rows_examined_per_scan": 1, + "not_exists": true, + "attached_condition": "(is_not_null_compl(), (found_match(), false, true), true)", + "materialized_from_subquery": { + "using_temporary_table": true, + "query_block": { + "table": { + "table_name": "it", + "access_type": "index", + "possible_keys": [ + "uk" + ], + "key": "uk", + "used_key_parts": [ + "uk" + ], + "key_length": "5", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "using_index": true, + "cost: # + "read_cost: # + "eval_cost: # + "prefix_cost: # + "data_read_per_join": "72" + }, + "used_columns": [ + "uk" + ] + } + } + } + } + } + ] + } +} +Warnings: +Note 1276 Field or reference 'test.ot.pk' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`ot`.`pk` AS `pk` from `test`.`t2` `ot` anti join (`test`.`t1` `it`) on((``.`uk` = `test`.`ot`.`pk`)) where (`test`.`ot`.`pk` < 25) +SELECT pk FROM t2 as ot +WHERE NOT EXISTS (SELECT * FROM t1 AS it WHERE it.uk=ot.pk) +AND ot.pk<25; +pk +1 +2 +3 +4 +5 +6 +7 +8 +9 +11 +12 +13 +14 +15 +16 +17 +18 +19 +21 +22 +23 +24 +DROP TABLE t1,t2; +CREATE TABLE t1(a INT, b INT); +INSERT INTO t1 VALUES(1,1),(2,2),(3,3); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN FORMAT=JSON SELECT * FROM t1 LEFT JOIN t1 t2 +ON (t1.a IN +(SELECT /*+ NO_SEMIJOIN(FIRSTMATCH,LOOSESCAN,DUPSWEEDOUT) */ a FROM +t1 t3 WHERE a > 2)); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "3.85" + }, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.30", + "prefix_cost": "0.55", + "data_read_per_join": "48" + }, + "used_columns": [ + "a", + "b" + ] + } + }, + { + "table": { + "table_name": "", + "access_type": "eq_ref", + "key": "", + "key_length": "5", + "ref": [ + "test.t1.a" + ], + "rows_examined_per_scan": 1, + "materialized_from_subquery": { + "using_temporary_table": true, + "query_block": { + "table": { + "table_name": "t3", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.30", + "prefix_cost": "0.55", + "data_read_per_join": "48" + }, + "used_columns": [ + "a" + ], + "attached_condition": "(`test`.`t3`.`a` > 2)" + } + } + } + } + }, + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 9, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.90", + "prefix_cost": "3.85", + "data_read_per_join": "144" + }, + "used_columns": [ + "a", + "b" + ] + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select /*+ NO_SEMIJOIN(@`select#2` FIRSTMATCH, LOOSESCAN, DUPSWEEDOUT) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` left join (`test`.`t1` `t2` semi join (`test`.`t1` `t3`)) on(((``.`a` = `test`.`t1`.`a`) and (`test`.`t3`.`a` > 2))) where true +SELECT * FROM t1 LEFT JOIN t1 t2 +ON (t1.a IN +(SELECT /*+ NO_SEMIJOIN(FIRSTMATCH,LOOSESCAN,DUPSWEEDOUT) */ a FROM +t1 t3 WHERE a > 2)); +a b a b +1 1 NULL NULL +2 2 NULL NULL +3 3 1 1 +3 3 2 2 +3 3 3 3 +ALTER TABLE t1 MODIFY a INT NOT NULL; +EXPLAIN SELECT * FROM t1 WHERE t1.a NOT IN +(SELECT a FROM t1 t2 WHERE a NOT IN (SELECT a FROM t1 t3)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 SUBQUERY t2 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 SUBQUERY NULL eq_ref 5 test.t2.a 1 100.00 Using where; Not exists +3 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (`test`.`t1`.`a`,`test`.`t1`.`a` in ( (/* select#2 */ select `test`.`t2`.`a` from `test`.`t1` `t2` anti join (`test`.`t1` `t3`) on((``.`a` = `test`.`t2`.`a`)) where true ), (`test`.`t1`.`a` in on where ((`test`.`t1`.`a` = ``.`a`)))) is false) +EXPLAIN SELECT * FROM t1 WHERE t1.a IN +(SELECT a FROM t1 t2 WHERE a NOT IN (SELECT a FROM t1 t3)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 SUBQUERY t2 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 SUBQUERY NULL eq_ref 5 test.t2.a 1 100.00 Using where; Not exists +3 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (`test`.`t1`.`a`,`test`.`t1`.`a` in ( (/* select#2 */ select `test`.`t2`.`a` from `test`.`t1` `t2` anti join (`test`.`t1` `t3`) on((``.`a` = `test`.`t2`.`a`)) where true ), (`test`.`t1`.`a` in on where ((`test`.`t1`.`a` = ``.`a`))))) +EXPLAIN SELECT * FROM t1 JOIN t1 t2 ON t1.a>t2.a +AND NOT EXISTS(SELECT * FROM t1 t3, t1 t4 WHERE t3.a=t1.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +1 SIMPLE NULL eq_ref 5 test.t1.a 1 100.00 Using where; Not exists +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 MATERIALIZED t4 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` join `test`.`t1` `t2` anti join (`test`.`t1` `t3` join `test`.`t1` `t4`) on((``.`a` = `test`.`t1`.`a`)) where (`test`.`t1`.`a` > `test`.`t2`.`a`) +EXPLAIN SELECT * FROM t1 WHERE t1.a NOT IN (SELECT t3.a FROM t1 t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE NULL eq_ref 5 test.t1.a 1 100.00 Using where; Not exists +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` anti join (`test`.`t1` `t3`) on((``.`a` = `test`.`t1`.`a`)) where true +EXPLAIN SELECT * FROM t1 WHERE t1.a <> ALL (SELECT t3.a FROM t1 t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE NULL eq_ref 5 test.t1.a 1 100.00 Using where; Not exists +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` anti join (`test`.`t1` `t3`) on((``.`a` = `test`.`t1`.`a`)) where true +ALTER TABLE t1 MODIFY a INT NULL; +EXPLAIN SELECT * FROM t1 WHERE EXISTS(SELECT * FROM t1 t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL const 8 const 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t1` `t3`) where true +EXPLAIN SELECT * FROM t1 WHERE NOT EXISTS(SELECT * FROM t1 t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +2 SUBQUERY t3 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where false +EXPLAIN SELECT * FROM t1 WHERE EXISTS(SELECT * FROM t1 t3) IS TRUE; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL const 8 const 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t1` `t3`) where true +EXPLAIN SELECT * FROM t1 WHERE EXISTS(SELECT * FROM t1 t3) IS FALSE; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +2 SUBQUERY t3 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where false +EXPLAIN SELECT * FROM t1 WHERE EXISTS(SELECT * FROM t1 t3) IS UNKNOWN; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL NULL Not optimized, outer query is empty +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where false +EXPLAIN SELECT * FROM t1 WHERE EXISTS(SELECT * FROM t1 t3) IS NOT TRUE; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +2 SUBQUERY t3 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where false +EXPLAIN SELECT * FROM t1 WHERE EXISTS(SELECT * FROM t1 t3) IS NOT FALSE; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL const 8 const 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t1` `t3`) where true +EXPLAIN SELECT * FROM t1 WHERE EXISTS(SELECT * FROM t1 t3) IS NOT UNKNOWN; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 SUBQUERY t3 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where true +EXPLAIN SELECT * FROM t1 WHERE t1.a IN (SELECT t3.a FROM t1 t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE NULL eq_ref 5 test.t1.a 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t1` `t3`) where (``.`a` = `test`.`t1`.`a`) +EXPLAIN SELECT * FROM t1 WHERE t1.a NOT IN (SELECT t3.a FROM t1 t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t3 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (`test`.`t1`.`a`,(/* select#2 */ select `test`.`t3`.`a` from `test`.`t1` `t3` where (outer_field_is_not_null, (((`test`.`t1`.`a`) = `test`.`t3`.`a`) or (`test`.`t3`.`a` is null)), true) having (outer_field_is_not_null, (`test`.`t3`.`a`), true)) is false) +EXPLAIN SELECT * FROM t1 WHERE NOT EXISTS (SELECT t3.a FROM t1 t3 WHERE t3.a=t1.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE NULL eq_ref 5 test.t1.a 1 100.00 Using where; Not exists +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` anti join (`test`.`t1` `t3`) on((``.`a` = `test`.`t1`.`a`)) where true +EXPLAIN SELECT * FROM t1 WHERE (t1.a IN (SELECT t3.a FROM t1 t3)) IS TRUE; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE NULL eq_ref 5 test.t1.a 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t1` `t3`) where (``.`a` = `test`.`t1`.`a`) +EXPLAIN SELECT * FROM t1 WHERE (t1.a IN (SELECT t3.a FROM t1 t3)) IS FALSE; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t3 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (`test`.`t1`.`a`,(/* select#2 */ select `test`.`t3`.`a` from `test`.`t1` `t3` where (outer_field_is_not_null, (((`test`.`t1`.`a`) = `test`.`t3`.`a`) or (`test`.`t3`.`a` is null)), true) having (outer_field_is_not_null, (`test`.`t3`.`a`), true)) is false) +EXPLAIN SELECT * FROM t1 WHERE (t1.a IN (SELECT t3.a FROM t1 t3)) IS UNKNOWN; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t3 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`a`,(/* select#2 */ select `test`.`t3`.`a` from `test`.`t1` `t3` where (outer_field_is_not_null, (((`test`.`t1`.`a`) = `test`.`t3`.`a`) or (`test`.`t3`.`a` is null)), true) having (outer_field_is_not_null, (`test`.`t3`.`a`), true))) is null) +EXPLAIN SELECT * FROM t1 WHERE ISNULL(t1.a IN (SELECT t3.a FROM t1 t3)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t3 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`a`,(/* select#2 */ select `test`.`t3`.`a` from `test`.`t1` `t3` where (outer_field_is_not_null, (((`test`.`t1`.`a`) = `test`.`t3`.`a`) or (`test`.`t3`.`a` is null)), true) having (outer_field_is_not_null, (`test`.`t3`.`a`), true))) is null) +SELECT * FROM t1 WHERE ISNULL(t1.a IN (SELECT t3.a FROM t1 t3)); +a b +EXPLAIN SELECT * FROM t1 WHERE (t1.a IN (SELECT t3.a FROM t1 t3)) IS NOT TRUE; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE NULL eq_ref 5 test.t1.a 1 100.00 Using where; Not exists +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` anti join (`test`.`t1` `t3`) on((``.`a` = `test`.`t1`.`a`)) where true +EXPLAIN SELECT * FROM t1 WHERE (t1.a IN (SELECT t3.a FROM t1 t3)) IS NOT FALSE; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t3 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (`test`.`t1`.`a`,(/* select#2 */ select `test`.`t3`.`a` from `test`.`t1` `t3` where (outer_field_is_not_null, (((`test`.`t1`.`a`) = `test`.`t3`.`a`) or (`test`.`t3`.`a` is null)), true) having (outer_field_is_not_null, (`test`.`t3`.`a`), true)) is not false) +EXPLAIN SELECT * FROM t1 WHERE (t1.a IN (SELECT t3.a FROM t1 t3)) IS NOT UNKNOWN; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t3 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`a`,(/* select#2 */ select `test`.`t3`.`a` from `test`.`t1` `t3` where (outer_field_is_not_null, (((`test`.`t1`.`a`) = `test`.`t3`.`a`) or (`test`.`t3`.`a` is null)), true) having (outer_field_is_not_null, (`test`.`t3`.`a`), true))) is not null) +EXPLAIN SELECT * FROM t1 WHERE (NOT t1.a IN (SELECT t3.a FROM t1 t3)) IS TRUE; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t3 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (`test`.`t1`.`a`,(/* select#2 */ select `test`.`t3`.`a` from `test`.`t1` `t3` where (outer_field_is_not_null, (((`test`.`t1`.`a`) = `test`.`t3`.`a`) or (`test`.`t3`.`a` is null)), true) having (outer_field_is_not_null, (`test`.`t3`.`a`), true)) is false) +EXPLAIN SELECT * FROM t1 WHERE (NOT t1.a IN (SELECT t3.a FROM t1 t3)) IS FALSE; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE NULL eq_ref 5 test.t1.a 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t1` `t3`) where (``.`a` = `test`.`t1`.`a`) +EXPLAIN SELECT * FROM t1 WHERE (NOT t1.a IN (SELECT t3.a FROM t1 t3)) IS UNKNOWN; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t3 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`a`,not (/* select#2 */ select `test`.`t3`.`a` from `test`.`t1` `t3` where (outer_field_is_not_null, (((`test`.`t1`.`a`) = `test`.`t3`.`a`) or (`test`.`t3`.`a` is null)), true) having (outer_field_is_not_null, (`test`.`t3`.`a`), true))) is null) +EXPLAIN SELECT * FROM t1 WHERE (NOT t1.a IN (SELECT t3.a FROM t1 t3)) IS NOT TRUE; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t3 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (`test`.`t1`.`a`,(/* select#2 */ select `test`.`t3`.`a` from `test`.`t1` `t3` where (outer_field_is_not_null, (((`test`.`t1`.`a`) = `test`.`t3`.`a`) or (`test`.`t3`.`a` is null)), true) having (outer_field_is_not_null, (`test`.`t3`.`a`), true)) is not false) +EXPLAIN SELECT * FROM t1 WHERE (NOT t1.a IN (SELECT t3.a FROM t1 t3)) IS NOT FALSE; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE NULL eq_ref 5 test.t1.a 1 100.00 Using where; Not exists +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` anti join (`test`.`t1` `t3`) on((``.`a` = `test`.`t1`.`a`)) where true +EXPLAIN SELECT * FROM t1 WHERE (NOT t1.a IN (SELECT t3.a FROM t1 t3)) IS NOT UNKNOWN; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t3 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`a`,not (/* select#2 */ select `test`.`t3`.`a` from `test`.`t1` `t3` where (outer_field_is_not_null, (((`test`.`t1`.`a`) = `test`.`t3`.`a`) or (`test`.`t3`.`a` is null)), true) having (outer_field_is_not_null, (`test`.`t3`.`a`), true))) is not null) +EXPLAIN SELECT * FROM t1 WHERE (NOT t1.a IN (SELECT /*+ NO_SEMIJOIN() */ t3.a FROM t1 t3)) IS FALSE; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t3 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select /*+ NO_SEMIJOIN(@`select#2`) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (`test`.`t1`.`a`,(/* select#2 */ select `test`.`t3`.`a` from `test`.`t1` `t3` where ((`test`.`t1`.`a`) = `test`.`t3`.`a`)) is true) +EXPLAIN SELECT * FROM t1 WHERE NOT ((t1.a IN (SELECT /*+ NO_SEMIJOIN() */ t3.a FROM t1 t3)) IS TRUE); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t3 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select /*+ NO_SEMIJOIN(@`select#2`) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (`test`.`t1`.`a`,(/* select#2 */ select `test`.`t3`.`a` from `test`.`t1` `t3` where ((`test`.`t1`.`a`) = `test`.`t3`.`a`)) is not true) +DROP TABLE t1; +# +# Bug#29387313 WL#4245: SIG11 AT QEP_SHARED_OWNER::LAST_INNER() AT SQL/SQL_OPT_EXEC_SHARED.H +# +CREATE TABLE t1 ( +pk int NOT NULL, +col_varchar_key varchar(1), +PRIMARY KEY (pk), +KEY idx_cc_col_varchar_key (col_varchar_key) +); +INSERT INTO t1 VALUES (2,"a"); +CREATE TABLE t2 LIKE t1; +EXPLAIN SELECT col_varchar_key FROM t1 +WHERE NOT EXISTS +(SELECT /*+ NO_SEMIJOIN(FIRSTMATCH) */ +subquery2_t1.col_varchar_key AS subquery2_field1 +FROM t2 AS subquery2_t1 LEFT JOIN +t1 AS subquery2_t2 INNER JOIN t1 AS subquery2_t3 +ON TRUE +ON TRUE +WHERE subquery2_t2.col_varchar_key <> subquery2_t1. col_varchar_key OR +subquery2_t1.col_varchar_key >= '2' + ) AND +t1.pk IN (2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +2 SUBQUERY subquery2_t1 NULL index idx_cc_col_varchar_key idx_cc_col_varchar_key 7 NULL 1 100.00 Using index +2 SUBQUERY subquery2_t2 NULL index NULL idx_cc_col_varchar_key 7 NULL 1 100.00 Using where; Using index; Using join buffer (hash join) +2 SUBQUERY subquery2_t3 NULL index NULL idx_cc_col_varchar_key 7 NULL 1 100.00 Using index; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select /*+ NO_SEMIJOIN(@`select#2` FIRSTMATCH) */ 'a' AS `col_varchar_key` from `test`.`t1` where true +SELECT col_varchar_key FROM t1 +WHERE NOT EXISTS +(SELECT /*+ NO_SEMIJOIN(FIRSTMATCH) */ +subquery2_t1.col_varchar_key AS subquery2_field1 +FROM t2 AS subquery2_t1 LEFT JOIN +t1 AS subquery2_t2 INNER JOIN t1 AS subquery2_t3 +ON TRUE +ON TRUE +WHERE subquery2_t2.col_varchar_key <> subquery2_t1. col_varchar_key OR +subquery2_t1.col_varchar_key >= '2' + ) AND +t1.pk IN (2); +col_varchar_key +a +DROP TABLE t1, t2; +# +# Bug#29402512 WL#4245: SIG6 AT JOIN::MAKE_OUTERJOIN_INFO | SQL_OPTIMIZER.CC +# +CREATE TABLE t1 ( +pk int NOT NULL AUTO_INCREMENT, +col_int_key int, +PRIMARY KEY (pk), +KEY idx_cc_col_int_key (col_int_key)); +INSERT INTO t1 VALUES(1,1); +INSERT INTO t1 (col_int_key) SELECT col_int_key*2 from t1; +INSERT INTO t1 (col_int_key) SELECT col_int_key*2 from t1; +INSERT INTO t1 (col_int_key) SELECT col_int_key*2 from t1; +INSERT INTO t1 (col_int_key) SELECT col_int_key*2 from t1; +INSERT INTO t1 (col_int_key) SELECT col_int_key*2 from t1; +INSERT INTO t1 (col_int_key) SELECT col_int_key*2 from t1; +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT t1.col_int_key +FROM t1 AS t1 LEFT JOIN t1 AS t2 ON t1.pk NOT IN (SELECT 1 FROM t1 AS subq); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index NULL idx_cc_col_int_key 5 NULL 64 100.00 Using index +1 SIMPLE t2 NULL index NULL idx_cc_col_int_key 5 NULL 64 100.00 Using where; Using index +1 SIMPLE NULL eq_ref 4 test.t1.pk 1 100.00 Using where; Not exists +2 MATERIALIZED subq NULL index NULL idx_cc_col_int_key 5 NULL 64 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col_int_key` AS `col_int_key` from `test`.`t1` left join (`test`.`t1` `t2` anti join (`test`.`t1` `subq`) on((`test`.`t1`.`pk` = 1))) on(true) where true +DROP TABLE t1; +# +# Bug#29499458 WL#4245: SIG 6 AT JOIN::SETUP_SEMIJOIN_MATERIALIZED_TABLE +# +CREATE TABLE t1 ( +pk INT NOT NULL, +col_int INT NOT NULL, +PRIMARY KEY (pk) +); +EXPLAIN SELECT alias1.pk +FROM t1 AS alias1 LEFT JOIN +(SELECT alias2.* +FROM t1 LEFT JOIN t1 AS alias2 ON TRUE +WHERE NOT EXISTS (SELECT pk FROM t1 AS sj1) +) AS alias3 +ON alias3.pk = alias1.col_int AND +NOT EXISTS (SELECT * FROM t1 AS sj2 WHERE (SELECT 1) IS NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY alias1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 PRIMARY t1 NULL index NULL PRIMARY 4 NULL 1 100.00 Using where; Using index +1 PRIMARY alias2 NULL eq_ref PRIMARY PRIMARY 4 test.alias1.col_int 1 100.00 Using index +4 SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +3 SUBQUERY sj1 NULL index NULL PRIMARY 4 NULL 1 100.00 Using index +Warnings: +Note 1249 Select 5 was reduced during optimization +Note 1003 /* select#1 */ select `test`.`alias1`.`pk` AS `pk` from `test`.`t1` `alias1` left join (`test`.`t1` join `test`.`t1` `alias2`) on(((`test`.`alias2`.`pk` = `test`.`alias1`.`col_int`) and exists(/* select#4 */ select 1 from `test`.`t1` `sj2` where false) is false and exists(/* select#3 */ select `test`.`sj1`.`pk` from `test`.`t1` `sj1`) is false)) where true +SELECT alias1.pk +FROM t1 AS alias1 LEFT JOIN +(SELECT alias2.* +FROM t1 LEFT JOIN t1 AS alias2 ON TRUE +WHERE NOT EXISTS (SELECT pk FROM t1 AS sj1) +) AS alias3 +ON alias3.pk = alias1.col_int AND +NOT EXISTS (SELECT * FROM t1 AS sj2 WHERE (SELECT 1) IS NULL); +pk +DROP TABLE t1; +# +# Bug#29503228 WL#4245: SIG 6 AT JOIN::SET_SEMIJOIN_EMBEDDING +# +CREATE TABLE t1 ( +col_int INT NOT NULL, +col_int2 INT NOT NULL +); +SELECT * FROM +t1 AS alias1 LEFT JOIN t1 AS alias2 +ON NOT EXISTS +( SELECT * +FROM +( SELECT * FROM t1 +WHERE col_int NOT IN +( SELECT sq1_alias1 . col_int2 +FROM t1 AS sq1_alias1 ) +) AS alias3 +); +col_int col_int2 col_int col_int2 +DROP TABLE t1; +# +# Test index_subquery and subquery-materialization with +# surrounding NOT or IS TRUE/FALSE. +# +CREATE TABLE t1 ( +col_int INT, +col_int2 INT, +key(col_int) +); +INSERT INTO t1 VALUES(1,1),(2,2),(null,null); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +SET OPTIMIZER_SWITCH="semijoin=off"; +SET OPTIMIZER_SWITCH="materialization=off"; +EXPLAIN SELECT * FROM t1 WHERE +t1.col_int+1 IN (SELECT col_int FROM t1 t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t2 NULL index_subquery col_int col_int 5 func 1 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col_int` AS `col_int`,`test`.`t1`.`col_int2` AS `col_int2` from `test`.`t1` where ((`test`.`t1`.`col_int` + 1),((((`test`.`t1`.`col_int` + 1)) in t1 on col_int where (((`test`.`t1`.`col_int` + 1)) = `test`.`t2`.`col_int`)))) +SELECT * FROM t1 WHERE +t1.col_int+1 IN (SELECT col_int FROM t1 t2); +col_int col_int2 +1 1 +EXPLAIN SELECT * FROM t1 WHERE +t1.col_int+1 IN (SELECT col_int FROM t1 t2) IS TRUE; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t2 NULL index_subquery col_int col_int 5 func 1 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col_int` AS `col_int`,`test`.`t1`.`col_int2` AS `col_int2` from `test`.`t1` where ((`test`.`t1`.`col_int` + 1),((((`test`.`t1`.`col_int` + 1)) in t1 on col_int where (((`test`.`t1`.`col_int` + 1)) = `test`.`t2`.`col_int`))) is true) +SELECT * FROM t1 WHERE +t1.col_int+1 IN (SELECT col_int FROM t1 t2) IS TRUE; +col_int col_int2 +1 1 +EXPLAIN SELECT * FROM t1 WHERE +t1.col_int+1 IN (SELECT col_int FROM t1 t2) IS FALSE; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t2 NULL index_subquery col_int col_int 5 func 2 100.00 Using where; Using index; Full scan on NULL key +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col_int` AS `col_int`,`test`.`t1`.`col_int2` AS `col_int2` from `test`.`t1` where ((`test`.`t1`.`col_int` + 1),((((`test`.`t1`.`col_int` + 1)) in t1 on col_int checking NULL where (outer_field_is_not_null, ((((`test`.`t1`.`col_int` + 1)) = `test`.`t2`.`col_int`) or (`test`.`t2`.`col_int` is null)), true) having (outer_field_is_not_null, (`test`.`t2`.`col_int`), true))) is false) +SELECT * FROM t1 WHERE +t1.col_int+1 IN (SELECT col_int FROM t1 t2) IS FALSE; +col_int col_int2 +EXPLAIN SELECT * FROM t1 WHERE +t1.col_int+1 NOT IN (SELECT col_int FROM t1 t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t2 NULL index_subquery col_int col_int 5 func 2 100.00 Using where; Using index; Full scan on NULL key +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col_int` AS `col_int`,`test`.`t1`.`col_int2` AS `col_int2` from `test`.`t1` where ((`test`.`t1`.`col_int` + 1),((((`test`.`t1`.`col_int` + 1)) in t1 on col_int checking NULL where (outer_field_is_not_null, ((((`test`.`t1`.`col_int` + 1)) = `test`.`t2`.`col_int`) or (`test`.`t2`.`col_int` is null)), true) having (outer_field_is_not_null, (`test`.`t2`.`col_int`), true))) is false) +SELECT * FROM t1 WHERE +t1.col_int+1 NOT IN (SELECT col_int FROM t1 t2); +col_int col_int2 +EXPLAIN SELECT * FROM t1 WHERE +t1.col_int+1 IN (SELECT col_int FROM t1 t2) IS UNKNOWN; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t2 NULL index_subquery col_int col_int 5 func 2 100.00 Using where; Using index; Full scan on NULL key +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col_int` AS `col_int`,`test`.`t1`.`col_int2` AS `col_int2` from `test`.`t1` where (((`test`.`t1`.`col_int` + 1),((((`test`.`t1`.`col_int` + 1)) in t1 on col_int checking NULL where (outer_field_is_not_null, ((((`test`.`t1`.`col_int` + 1)) = `test`.`t2`.`col_int`) or (`test`.`t2`.`col_int` is null)), true) having (outer_field_is_not_null, (`test`.`t2`.`col_int`), true)))) is null) +SELECT * FROM t1 WHERE +t1.col_int+1 IN (SELECT col_int FROM t1 t2) IS UNKNOWN; +col_int col_int2 +2 2 +NULL NULL +SET OPTIMIZER_SWITCH="materialization=on,subquery_materialization_cost_based=off"; +EXPLAIN SELECT * FROM t1 WHERE +t1.col_int+1 IN (SELECT col_int FROM t1 t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 SUBQUERY t2 NULL index col_int col_int 5 NULL 3 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col_int` AS `col_int`,`test`.`t1`.`col_int2` AS `col_int2` from `test`.`t1` where ((`test`.`t1`.`col_int` + 1),(`test`.`t1`.`col_int` + 1) in ( (/* select#2 */ select `test`.`t2`.`col_int` from `test`.`t1` `t2` where true ), ((`test`.`t1`.`col_int` + 1) in on where (((`test`.`t1`.`col_int` + 1) = ``.`col_int`))))) +SELECT * FROM t1 WHERE +t1.col_int+1 IN (SELECT col_int FROM t1 t2); +col_int col_int2 +1 1 +EXPLAIN SELECT * FROM t1 WHERE +t1.col_int+1 IN (SELECT col_int FROM t1 t2) IS TRUE; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 SUBQUERY t2 NULL index col_int col_int 5 NULL 3 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col_int` AS `col_int`,`test`.`t1`.`col_int2` AS `col_int2` from `test`.`t1` where ((`test`.`t1`.`col_int` + 1),(`test`.`t1`.`col_int` + 1) in ( (/* select#2 */ select `test`.`t2`.`col_int` from `test`.`t1` `t2` where true ), ((`test`.`t1`.`col_int` + 1) in on where (((`test`.`t1`.`col_int` + 1) = ``.`col_int`)))) is true) +SELECT * FROM t1 WHERE +t1.col_int+1 IN (SELECT col_int FROM t1 t2) IS TRUE; +col_int col_int2 +1 1 +EXPLAIN SELECT * FROM t1 WHERE +t1.col_int+1 IN (SELECT col_int FROM t1 t2) IS FALSE; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 SUBQUERY t2 NULL index col_int col_int 5 NULL 3 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col_int` AS `col_int`,`test`.`t1`.`col_int2` AS `col_int2` from `test`.`t1` where ((`test`.`t1`.`col_int` + 1),(`test`.`t1`.`col_int` + 1) in ( (/* select#2 */ select `test`.`t2`.`col_int` from `test`.`t1` `t2` where true having true ), ((`test`.`t1`.`col_int` + 1) in on where (((`test`.`t1`.`col_int` + 1) = ``.`col_int`)))) is false) +SELECT * FROM t1 WHERE +t1.col_int+1 IN (SELECT col_int FROM t1 t2) IS FALSE; +col_int col_int2 +EXPLAIN SELECT * FROM t1 WHERE +t1.col_int+1 NOT IN (SELECT col_int FROM t1 t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 SUBQUERY t2 NULL index col_int col_int 5 NULL 3 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col_int` AS `col_int`,`test`.`t1`.`col_int2` AS `col_int2` from `test`.`t1` where ((`test`.`t1`.`col_int` + 1),(`test`.`t1`.`col_int` + 1) in ( (/* select#2 */ select `test`.`t2`.`col_int` from `test`.`t1` `t2` where true having true ), ((`test`.`t1`.`col_int` + 1) in on where (((`test`.`t1`.`col_int` + 1) = ``.`col_int`)))) is false) +SELECT * FROM t1 WHERE +t1.col_int+1 NOT IN (SELECT col_int FROM t1 t2); +col_int col_int2 +EXPLAIN SELECT * FROM t1 WHERE +t1.col_int+1 IN (SELECT col_int FROM t1 t2) IS UNKNOWN; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 SUBQUERY t2 NULL index col_int col_int 5 NULL 3 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col_int` AS `col_int`,`test`.`t1`.`col_int2` AS `col_int2` from `test`.`t1` where (((`test`.`t1`.`col_int` + 1),(`test`.`t1`.`col_int` + 1) in ( (/* select#2 */ select `test`.`t2`.`col_int` from `test`.`t1` `t2` where true having true ), ((`test`.`t1`.`col_int` + 1) in on where (((`test`.`t1`.`col_int` + 1) = ``.`col_int`))))) is null) +SELECT * FROM t1 WHERE +t1.col_int+1 IN (SELECT col_int FROM t1 t2) IS UNKNOWN; +col_int col_int2 +2 2 +NULL NULL +SET OPTIMIZER_SWITCH=DEFAULT; +DROP TABLE t1; +# +# Bug#29525549 WL#4245: SIG 6 AT JOIN::CREATE_ITERATORS() | SQL/SQL_EXECUTOR.CC +# +CREATE TABLE t1 ( +pk INT NOT NULL, +col_int INT NOT NULL, +PRIMARY KEY (pk) +) ; +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +SET OPTIMIZER_SWITCH="block_nested_loop=off,firstmatch=off"; +EXPLAIN SELECT * FROM t1 LEFT JOIN t1 AS t2 +ON 1 AND t1.col_int > ( SELECT @var FROM t1 as t3 ) AND +NOT EXISTS ( SELECT * FROM t1 as t4); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +3 SUBQUERY t4 NULL index NULL PRIMARY 4 NULL 1 100.00 Using index +2 UNCACHEABLE SUBQUERY t3 NULL index NULL PRIMARY 4 NULL 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`col_int` AS `col_int`,`test`.`t2`.`pk` AS `pk`,`test`.`t2`.`col_int` AS `col_int` from `test`.`t1` left join `test`.`t1` `t2` on(((`test`.`t1`.`col_int` > (/* select#2 */ select (@`var`) from `test`.`t1` `t3`)) and exists(/* select#3 */ select 1 from `test`.`t1` `t4`) is false)) where true +SELECT * FROM t1 LEFT JOIN t1 AS t2 +ON 1 AND t1.col_int > ( SELECT @var FROM t1 as t3 ) AND +NOT EXISTS ( SELECT * FROM t1 as t4); +pk col_int pk col_int +SELECT * FROM t1 LEFT JOIN (t1 AS t2 LEFT JOIN t1 AS sq ON 1=1) +ON 1 AND t1.col_int > ( SELECT @var FROM t1 AS t4 ) +WHERE sq.pk IS NULL; +pk col_int pk col_int pk col_int +SET OPTIMIZER_SWITCH=DEFAULT; +DROP TABLE t1; +# +# Bug#29533644 WL#4245: RESULT DIFFS WITH NOT IN (SUBQUERY) +# +CREATE TABLE t1(id INT); +INSERT INTO t1 VALUES(1),(2),(3),(4),(5); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT ID FROM t1 WHERE id IN ( SELECT 1 ); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 20.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 20.00 Using where +Warnings: +Note 1249 Select 2 was reduced during optimization +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `ID` from `test`.`t1` where (`test`.`t1`.`id` = 1) +SELECT ID FROM t1 WHERE id IN ( SELECT 1 ); +ID +1 +EXPLAIN SELECT ID FROM t1 WHERE id NOT IN ( SELECT 1 ); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 80.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 80.00 Using where +Warnings: +Note 1249 Select 2 was reduced during optimization +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `ID` from `test`.`t1` where (not((`test`.`t1`.`id` = 1))) +SELECT ID FROM t1 WHERE id NOT IN ( SELECT 1 ); +ID +2 +3 +4 +5 +EXPLAIN SELECT id, id IN (SELECT NULL) IS TRUE AS test FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +Warnings: +Note 1249 Select 2 was reduced during optimization +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,((`test`.`t1`.`id` = NULL) is true) AS `test` from `test`.`t1` +SELECT id, id IN (SELECT NULL) IS TRUE AS test FROM t1; +id test +1 0 +2 0 +3 0 +4 0 +5 0 +DROP TABLE t1; +# +# Bug#29540222 WL#4245 RESULT DIFFS WITH DUAL +# +CREATE TABLE t1 ( +pk int(11) NOT NULL AUTO_INCREMENT, +col_int int(11) NOT NULL, +col_int_key int(11) NOT NULL, +col_date date NOT NULL, +col_date_key date NOT NULL, +col_time time NOT NULL, +col_time_key time NOT NULL, +col_datetime datetime NOT NULL, +col_datetime_key datetime NOT NULL, +col_varchar varchar(1) NOT NULL, +col_varchar_key varchar(1) NOT NULL, +PRIMARY KEY (pk), +KEY idx_C_col_int_key (col_int_key), +KEY idx_C_col_date_key (col_date_key), +KEY idx_C_col_time_key (col_time_key), +KEY idx_C_col_datetime_key (col_datetime_key), +KEY idx_C_col_varchar_key (col_varchar_key) +) ENGINE=InnoDB AUTO_INCREMENT=21 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (1,1065483706,383929458,'1979-10-05','1976-08-21','22:00:27','23:05:58','1974-07-25 16:05:18','2015-12-02 10:01:50','k','9'),(2,-171723561,486531981,'1980-09-14','2027-01-15','00:57:31','00:12:08','2036-10-28 14:25:40','2010-09-04 08:25:26','M','Z'); +EXPLAIN SELECT alias1.col_int AS field1 , alias2.col_varchar_key AS field2 , +alias1.col_datetime_key AS field3 +FROM t1 AS alias1 LEFT JOIN t1 AS alias2 +ON NOT EXISTS ( SELECT * FROM t1 AS alias3 WHERE ( SELECT 1 FROM DUAL ) IS NULL ); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY alias1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 PRIMARY alias2 NULL index NULL idx_C_col_varchar_key 6 NULL 2 100.00 Using where; Using index; Using join buffer (hash join) +2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1249 Select 3 was reduced during optimization +Note 1003 /* select#1 */ select `test`.`alias1`.`col_int` AS `field1`,`test`.`alias2`.`col_varchar_key` AS `field2`,`test`.`alias1`.`col_datetime_key` AS `field3` from `test`.`t1` `alias1` left join `test`.`t1` `alias2` on(exists(/* select#2 */ select 1 from `test`.`t1` `alias3` where false) is false) where true +SELECT alias1.col_int AS field1 , alias2.col_varchar_key AS field2 , +alias1.col_datetime_key AS field3 +FROM t1 AS alias1 LEFT JOIN t1 AS alias2 +ON NOT EXISTS ( SELECT * FROM t1 AS alias3 WHERE ( SELECT 1 FROM DUAL ) IS NULL ); +field1 field2 field3 +-171723561 9 2010-09-04 08:25:26 +-171723561 Z 2010-09-04 08:25:26 +1065483706 9 2015-12-02 10:01:50 +1065483706 Z 2015-12-02 10:01:50 +DROP TABLE t1; +# +# Bug#29759277 ASSERTION FAILED: !"NO DERIVED TABLE FOUND!" +# +CREATE TABLE t1 (c1 INT, c2 INT); +EXPLAIN FORMAT=JSON +SELECT c1 FROM t1 +WHERE NOT EXISTS (SELECT /*+ NO_MERGE() */ c2 +FROM (SELECT c1 FROM t1) AS dt +WHERE FALSE); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.35" + }, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.10", + "prefix_cost": "0.35", + "data_read_per_join": "16" + }, + "used_columns": [ + "c1" + ], + "query_block": { + "cost_info": { + "query_cost": "0.35" + }, + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.10", + "prefix_cost": "0.35", + "data_read_per_join": "16" + }, + "used_columns": [ + "c1", + "c2" + ] + } + } + } + } +} +Warnings: +Note 1276 Field or reference 'test.t1.c2' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select /*+ NO_MERGE(@`select#2`) */ `test`.`t1`.`c1` AS `c1` from `test`.`t1` where true +DROP TABLE t1; +# +# Bug#30691682 MIN/MAX ISSUE WITH NOT EXISTS SUBQUERY +# +CREATE TABLE t1(a INT NOT NULL, index (a)); +CREATE TABLE t2(a INT NOT NULL); +INSERT INTO t1 VALUES(1),(2); +INSERT INTO t2 VALUES(2),(3); +explain SELECT MAX(t1.a) FROM t1 WHERE a NOT IN (SELECT a FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL a 4 NULL 2 100.00 Using index +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Not exists; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select max(`test`.`t1`.`a`) AS `MAX(t1.a)` from `test`.`t1` anti join (`test`.`t2`) on((`test`.`t2`.`a` = `test`.`t1`.`a`)) where true +SELECT MAX(t1.a) FROM t1 WHERE a NOT IN (SELECT a FROM t2); +MAX(t1.a) +1 +DROP TABLE t1, t2; +# +# Bug#31376809 PERFORMANCE REGRESSION FROM 5.7->8.0, DUE TO ANTIJOIN OF NOT EXISTS SUBQUERY +# +create table t(a int, b int); +insert into t values(1,1),(2,2),(3,3),(4,4),(5,5); +explain format=tree select a from t where (not exists (select b from t)); +EXPLAIN +-> Zero rows (Impossible WHERE) (cost=0.00..0.00 rows=0) + +select a from t where (not exists (select b from t)); +a +explain format=tree select a from t where 1 not in (select 1 from t); +EXPLAIN +-> Zero rows (Impossible WHERE) (cost=0.00..0.00 rows=0) + +select a from t where 1 not in (select 1 from t); +a +drop table t; +# +# Bug#31425664 RECENT REGRESSION: CRASH IN ITEM::SAVE_IN_FIELD +# +CREATE TABLE t (a TIME); +CREATE TABLE s (b INT); +INSERT INTO t VALUES('11:11:11.1111'),('22:22:22.2222'); +INSERT INTO t VALUES('11:11:11.1111'),('22:22:22.2222'); +INSERT INTO t VALUES('11:11:11.1111'),('22:22:22.2222'); +INSERT INTO s VALUES(1),(2),(3),(4); +SELECT 1 FROM t WHERE NOT EXISTS +( +SELECT 1 FROM s +WHERE a=FROM_UNIXTIME(1536999178) +); +1 +1 +1 +1 +1 +1 +1 +DROP TABLE t,s; diff --git a/mysql-test/r/subquery_bugs.result-pq b/mysql-test/r/subquery_bugs.result-pq new file mode 100644 index 000000000000..7bb01bb09659 --- /dev/null +++ b/mysql-test/r/subquery_bugs.result-pq @@ -0,0 +1,1887 @@ +# Bug#26436185 Assertion 'buf_is_inside_another(data_in_mysql_buf, ...) +CREATE TABLE t1 ( +pk int NOT NULL, +col_int_key int DEFAULT NULL, +col_int int DEFAULT NULL, +col_varchar varchar(1) DEFAULT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +); +INSERT INTO t1 VALUES (10,7,5,'l'), (12,7,4,'o'); +CREATE TABLE t2 ( +col_date_key date DEFAULT NULL, +col_datetime_key datetime DEFAULT NULL, +col_int_key int(11) DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar varchar(1) DEFAULT NULL, +col_time time DEFAULT NULL, +pk int NOT NULL, +col_date date DEFAULT NULL, +col_time_key time DEFAULT NULL, +col_datetime datetime DEFAULT NULL, +col_int int DEFAULT NULL, +PRIMARY KEY (pk), +KEY col_date_key (col_date_key), +KEY col_datetime_key (col_datetime_key), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key), +KEY col_time_key (col_time_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2(col_int_key,col_varchar_key,col_varchar,pk,col_int) VALUES +(8,'a','w',1,5), +(9,'y','f',7,0), +(9,'z','i',11,9), +(9,'r','s',12,3), +(7,'n','i',13,6), +(9,'j','v',17,9), +(240,'u','k',20,6); +CREATE TABLE t3 ( +col_int int DEFAULT NULL, +col_int_key int(11) DEFAULT NULL, +pk int NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t3 VALUES (8,4,1); +ANALYZE TABLE t1, t2, t3; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +EXPLAIN SELECT table2.col_int_key AS field1 +FROM (SELECT sq1_t1.* +FROM t1 AS sq1_t1 RIGHT OUTER JOIN t2 AS sq1_t2 +ON sq1_t2.col_varchar_key = sq1_t1.col_varchar +) AS table1 +LEFT JOIN t1 AS table2 +RIGHT JOIN t2 AS table3 +ON table3.pk = table2.col_int_key +ON table3.col_int_key = table2.col_int +WHERE table3.col_int_key >= ALL +(SELECT sq2_t1.col_int AS sq2_field1 +FROM t2 AS sq2_t1 STRAIGHT_JOIN t3 AS sq2_t2 +ON sq2_t2.col_int = sq2_t1.pk AND +sq2_t1.col_varchar IN +(SELECT sq21_t1.col_varchar AS sq21_field1 +FROM t2 AS sq21_t1 STRAIGHT_JOIN t1 AS sq21_t2 +ON sq21_t2.col_int_key = sq21_t1.pk +WHERE sq21_t1.pk = 7 +) +WHERE sq2_t2.col_int_key >= table2.col_int AND +sq2_t1.col_int_key <= table2.col_int_key +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY sq1_t2 NULL index NULL col_varchar_key 7 NULL 7 100.00 Using index +1 PRIMARY sq1_t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +1 PRIMARY table2 NULL ALL col_int_key NULL NULL NULL 2 100.00 NULL +1 PRIMARY table3 NULL eq_ref PRIMARY,col_int_key PRIMARY 4 test.table2.col_int_key 1 100.00 Using where +3 DEPENDENT SUBQUERY NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +3 DEPENDENT SUBQUERY sq2_t1 NULL ALL PRIMARY,col_int_key NULL NULL NULL 7 14.29 Range checked for each record (index map: 0x9) +3 DEPENDENT SUBQUERY sq2_t2 NULL ALL col_int_key NULL NULL NULL 1 100.00 Range checked for each record (index map: 0x2) +4 MATERIALIZED sq21_t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +4 MATERIALIZED sq21_t2 NULL ref col_int_key col_int_key 5 const 2 100.00 Using index +Warnings: +Note 1276 Field or reference 'test.table2.col_int' of SELECT #3 was resolved in SELECT #1 +Note 1276 Field or reference 'test.table2.col_int_key' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`table2`.`col_int_key` AS `field1` from `test`.`t2` `sq1_t2` left join `test`.`t1` `sq1_t1` on((`test`.`sq1_t1`.`col_varchar` = `test`.`sq1_t2`.`col_varchar_key`)) left join (`test`.`t2` `table3` join `test`.`t1` `table2`) on(((`test`.`table3`.`pk` = `test`.`table2`.`col_int_key`) and (`test`.`table3`.`col_int_key` = `test`.`table2`.`col_int`))) where ((`test`.`table3`.`col_int_key`,(/* select#3 */ select `test`.`sq2_t1`.`col_int` AS `sq2_field1` from `test`.`t2` `sq2_t1` straight_join `test`.`t3` `sq2_t2` semi join (`test`.`t2` `sq21_t1` straight_join `test`.`t1` `sq21_t2`) where ((`test`.`sq2_t2`.`col_int` = `test`.`sq2_t1`.`pk`) and (`test`.`sq2_t1`.`col_varchar` = ``.`sq21_field1`) and (`test`.`sq21_t1`.`pk` = 7) and (`test`.`sq21_t2`.`col_int_key` = 7) and (`test`.`sq2_t2`.`col_int_key` >= `test`.`table2`.`col_int`) and (`test`.`sq2_t1`.`col_int_key` <= `test`.`table2`.`col_int_key`) and (outer_field_is_not_null, (((`test`.`table3`.`col_int_key`) < `test`.`sq2_t1`.`col_int`) or (`test`.`sq2_t1`.`col_int` is null)), true)) having (outer_field_is_not_null, (`test`.`sq2_t1`.`col_int`), true)))) +SELECT table2.col_int_key AS field1 +FROM (SELECT sq1_t1.* +FROM t1 AS sq1_t1 RIGHT OUTER JOIN t2 AS sq1_t2 +ON sq1_t2.col_varchar_key = sq1_t1.col_varchar +) AS table1 +LEFT JOIN t1 AS table2 +RIGHT JOIN t2 AS table3 +ON table3.pk = table2.col_int_key +ON table3.col_int_key = table2.col_int +WHERE table3.col_int_key >= ALL +(SELECT sq2_t1.col_int AS sq2_field1 +FROM t2 AS sq2_t1 STRAIGHT_JOIN t3 AS sq2_t2 +ON sq2_t2.col_int = sq2_t1.pk AND +sq2_t1.col_varchar IN +(SELECT sq21_t1.col_varchar AS sq21_field1 +FROM t2 AS sq21_t1 STRAIGHT_JOIN t1 AS sq21_t2 +ON sq21_t2.col_int_key = sq21_t1.pk +WHERE sq21_t1.pk = 7 +) +WHERE sq2_t2.col_int_key >= table2.col_int AND +sq2_t1.col_int_key <= table2.col_int_key +); +field1 +NULL +NULL +NULL +NULL +NULL +NULL +NULL +DROP TABLE t1, t2, t3; +# +# Bug#24713879 ASSERTION `MAYBE_NULL' FAILED. HANDLE_FATAL_SIGNAL IN TEM_FUNC_CONCAT::VAL_STR +# +CREATE TABLE t1(k VARCHAR(10) PRIMARY KEY); +CREATE TABLE t2(k VARCHAR(10) PRIMARY KEY); +SET SQL_MODE=''; +EXPLAIN SELECT (SELECT 'X' FROM t2 +WHERE t2.k = CONCAT(t1.k, 'X')) = 'XXX' +FROM t1 +WHERE k ='X'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL NULL Not optimized, outer query is empty +Warnings: +Note 1276 Field or reference 'test.t1.k' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select ((/* select#2 */ select 'X' from `test`.`t2` where (`test`.`t2`.`k` = concat(NULL,'X'))) = 'XXX') AS `(SELECT 'X' FROM t2 +WHERE t2.k = CONCAT(t1.k, 'X')) = 'XXX'` from `test`.`t1` where multiple equal('X', NULL) +SELECT (SELECT 'X' FROM t2 +WHERE t2.k = CONCAT(t1.k, 'X')) = 'XXX' +FROM t1 +WHERE k ='X'; +(SELECT 'X' FROM t2 +WHERE t2.k = CONCAT(t1.k, 'X')) = 'XXX' +EXPLAIN SELECT (SELECT 'X' FROM t2 +WHERE t2.k = CONCAT(t1.k, 'X')) = 'XXX', +SUM(k) +FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL index NULL PRIMARY 42 NULL 1 100.00 Using index +2 DEPENDENT SUBQUERY t2 NULL eq_ref PRIMARY PRIMARY 42 func 1 100.00 Using where; Using index +Warnings: +Note 1276 Field or reference 'test.t1.k' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select ((/* select#2 */ select 'X' from `test`.`t2` where (`test`.`t2`.`k` = concat(`test`.`t1`.`k`,'X'))) = 'XXX') AS `(SELECT 'X' FROM t2 +WHERE t2.k = CONCAT(t1.k, 'X')) = 'XXX'`,sum(`test`.`t1`.`k`) AS `SUM(k)` from `test`.`t1` +SELECT (SELECT 'X' FROM t2 +WHERE t2.k = CONCAT(t1.k, 'X')) = 'XXX', +SUM(k) +FROM t1; +(SELECT 'X' FROM t2 +WHERE t2.k = CONCAT(t1.k, 'X')) = 'XXX' SUM(k) +NULL NULL +EXPLAIN SELECT SUM(k), k +FROM t1 +HAVING (SELECT 'X' FROM t2 +WHERE t2.k = CONCAT(t1.k, 'X')) = 'XXX'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL index NULL PRIMARY 42 NULL 1 100.00 Using index +2 DEPENDENT SUBQUERY t2 NULL eq_ref PRIMARY PRIMARY 42 func 1 100.00 Using where; Using index +Warnings: +Note 1276 Field or reference 'test.t1.k' of SELECT #2 was resolved in SELECT #1 +Note 1276 Field or reference 'test.t1.k' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select sum(`test`.`t1`.`k`) AS `SUM(k)`,`test`.`t1`.`k` AS `k` from `test`.`t1` having ((/* select#2 */ select 'X' from `test`.`t2` where (`test`.`t2`.`k` = concat(`test`.`t1`.`k`,'X'))) = 'XXX') +SELECT SUM(k), k +FROM t1 +HAVING (SELECT 'X' FROM t2 +WHERE t2.k = CONCAT(t1.k, 'X')) = 'XXX'; +SUM(k) k +EXPLAIN SELECT (SELECT 'X' FROM t2 +WHERE t2.k = CONCAT(t1.k, 'X') +AND SUM(t1.k)) = 'XXX' +FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL index NULL PRIMARY 42 NULL 1 100.00 Using index +2 DEPENDENT SUBQUERY t2 NULL eq_ref PRIMARY PRIMARY 42 func 1 100.00 Using where; Using index +Warnings: +Note 1276 Field or reference 'test.t1.k' of SELECT #2 was resolved in SELECT #1 +Note 1276 Field or reference 'test.t1.k' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select ((/* select#2 */ select 'X' from `test`.`t2` where ((`test`.`t2`.`k` = concat(`test`.`t1`.`k`,'X')) and (0 <> sum(`test`.`t1`.`k`)))) = 'XXX') AS `(SELECT 'X' FROM t2 +WHERE t2.k = CONCAT(t1.k, 'X') +AND SUM(t1.k)) = 'XXX'` from `test`.`t1` +SELECT (SELECT 'X' FROM t2 +WHERE t2.k = CONCAT(t1.k, 'X') +AND SUM(t1.k)) = 'XXX' +FROM t1; +(SELECT 'X' FROM t2 +WHERE t2.k = CONCAT(t1.k, 'X') +AND SUM(t1.k)) = 'XXX' +NULL +SET SQL_MODE=ONLY_FULL_GROUP_BY; +EXPLAIN SELECT (SELECT 'X' FROM t2 +WHERE t2.k = CONCAT(t1.k, 'X')) = 'XXX' +FROM t1 +WHERE k ='X'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL NULL Not optimized, outer query is empty +Warnings: +Note 1276 Field or reference 'test.t1.k' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select ((/* select#2 */ select 'X' from `test`.`t2` where (`test`.`t2`.`k` = concat(NULL,'X'))) = 'XXX') AS `(SELECT 'X' FROM t2 +WHERE t2.k = CONCAT(t1.k, 'X')) = 'XXX'` from `test`.`t1` where multiple equal('X', NULL) +SELECT (SELECT 'X' FROM t2 +WHERE t2.k = CONCAT(t1.k, 'X')) = 'XXX' +FROM t1 +WHERE k ='X'; +(SELECT 'X' FROM t2 +WHERE t2.k = CONCAT(t1.k, 'X')) = 'XXX' +EXPLAIN SELECT (SELECT 'X' FROM t2 +WHERE t2.k = CONCAT(t1.k, 'X')) = 'XXX', +SUM(k) +FROM t1; +ERROR 42000: In aggregated query without GROUP BY, expression #1 of SELECT list contains nonaggregated column 'test.t1.k'; this is incompatible with sql_mode=only_full_group_by +EXPLAIN SELECT SUM(k), k +FROM t1 +HAVING (SELECT 'X' FROM t2 +WHERE t2.k = CONCAT(t1.k, 'X')) = 'XXX'; +ERROR 42000: In aggregated query without GROUP BY, expression #2 of SELECT list contains nonaggregated column 'test.t1.k'; this is incompatible with sql_mode=only_full_group_by +EXPLAIN SELECT (SELECT 'X' FROM t2 +WHERE t2.k = CONCAT(t1.k, 'X') +AND SUM(t1.k)) = 'XXX' +FROM t1; +ERROR 42000: In aggregated query without GROUP BY, expression #1 of SELECT list contains nonaggregated column 'test.t1.k'; this is incompatible with sql_mode=only_full_group_by +SET SQL_MODE=STRICT_TRANS_TABLES; +Warnings: +Warning 3135 'NO_ZERO_DATE', 'NO_ZERO_IN_DATE' and 'ERROR_FOR_DIVISION_BY_ZERO' sql modes should be used with strict mode. They will be merged with strict mode in a future release. +EXPLAIN SELECT (SELECT 'X' FROM t2 +WHERE t2.k = CONCAT(t1.k, 'X')) = 'XXX' +FROM t1 +WHERE k ='X'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL NULL Not optimized, outer query is empty +Warnings: +Note 1276 Field or reference 'test.t1.k' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select ((/* select#2 */ select 'X' from `test`.`t2` where (`test`.`t2`.`k` = concat(NULL,'X'))) = 'XXX') AS `(SELECT 'X' FROM t2 +WHERE t2.k = CONCAT(t1.k, 'X')) = 'XXX'` from `test`.`t1` where multiple equal('X', NULL) +SELECT (SELECT 'X' FROM t2 +WHERE t2.k = CONCAT(t1.k, 'X')) = 'XXX' +FROM t1 +WHERE k ='X'; +(SELECT 'X' FROM t2 +WHERE t2.k = CONCAT(t1.k, 'X')) = 'XXX' +EXPLAIN SELECT (SELECT 'X' FROM t2 +WHERE t2.k = CONCAT(t1.k, 'X')) = 'XXX', +SUM(k) +FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL index NULL PRIMARY 42 NULL 1 100.00 Using index +2 DEPENDENT SUBQUERY t2 NULL eq_ref PRIMARY PRIMARY 42 func 1 100.00 Using where; Using index +Warnings: +Note 1276 Field or reference 'test.t1.k' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select ((/* select#2 */ select 'X' from `test`.`t2` where (`test`.`t2`.`k` = concat(`test`.`t1`.`k`,'X'))) = 'XXX') AS `(SELECT 'X' FROM t2 +WHERE t2.k = CONCAT(t1.k, 'X')) = 'XXX'`,sum(`test`.`t1`.`k`) AS `SUM(k)` from `test`.`t1` +SELECT (SELECT 'X' FROM t2 +WHERE t2.k = CONCAT(t1.k, 'X')) = 'XXX', +SUM(k) +FROM t1; +(SELECT 'X' FROM t2 +WHERE t2.k = CONCAT(t1.k, 'X')) = 'XXX' SUM(k) +NULL NULL +EXPLAIN SELECT SUM(k), k +FROM t1 +HAVING (SELECT 'X' FROM t2 +WHERE t2.k = CONCAT(t1.k, 'X')) = 'XXX'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL index NULL PRIMARY 42 NULL 1 100.00 Using index +2 DEPENDENT SUBQUERY t2 NULL eq_ref PRIMARY PRIMARY 42 func 1 100.00 Using where; Using index +Warnings: +Note 1276 Field or reference 'test.t1.k' of SELECT #2 was resolved in SELECT #1 +Note 1276 Field or reference 'test.t1.k' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select sum(`test`.`t1`.`k`) AS `SUM(k)`,`test`.`t1`.`k` AS `k` from `test`.`t1` having ((/* select#2 */ select 'X' from `test`.`t2` where (`test`.`t2`.`k` = concat(`test`.`t1`.`k`,'X'))) = 'XXX') +SELECT SUM(k), k +FROM t1 +HAVING (SELECT 'X' FROM t2 +WHERE t2.k = CONCAT(t1.k, 'X')) = 'XXX'; +SUM(k) k +EXPLAIN SELECT (SELECT 'X' FROM t2 +WHERE t2.k = CONCAT(t1.k, 'X') +AND SUM(t1.k)) = 'XXX' +FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL index NULL PRIMARY 42 NULL 1 100.00 Using index +2 DEPENDENT SUBQUERY t2 NULL eq_ref PRIMARY PRIMARY 42 func 1 100.00 Using where; Using index +Warnings: +Note 1276 Field or reference 'test.t1.k' of SELECT #2 was resolved in SELECT #1 +Note 1276 Field or reference 'test.t1.k' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select ((/* select#2 */ select 'X' from `test`.`t2` where ((`test`.`t2`.`k` = concat(`test`.`t1`.`k`,'X')) and (0 <> sum(`test`.`t1`.`k`)))) = 'XXX') AS `(SELECT 'X' FROM t2 +WHERE t2.k = CONCAT(t1.k, 'X') +AND SUM(t1.k)) = 'XXX'` from `test`.`t1` +SELECT (SELECT 'X' FROM t2 +WHERE t2.k = CONCAT(t1.k, 'X') +AND SUM(t1.k)) = 'XXX' +FROM t1; +(SELECT 'X' FROM t2 +WHERE t2.k = CONCAT(t1.k, 'X') +AND SUM(t1.k)) = 'XXX' +NULL +SET SQL_MODE=DEFAULT; +EXPLAIN SELECT (SELECT 'X' FROM t2 +WHERE t2.k = CONCAT(t1.k, 'X')) = 'XXX' +FROM t1 +WHERE k ='X'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL NULL Not optimized, outer query is empty +Warnings: +Note 1276 Field or reference 'test.t1.k' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select ((/* select#2 */ select 'X' from `test`.`t2` where (`test`.`t2`.`k` = concat(NULL,'X'))) = 'XXX') AS `(SELECT 'X' FROM t2 +WHERE t2.k = CONCAT(t1.k, 'X')) = 'XXX'` from `test`.`t1` where multiple equal('X', NULL) +SELECT (SELECT 'X' FROM t2 +WHERE t2.k = CONCAT(t1.k, 'X')) = 'XXX' +FROM t1 +WHERE k ='X'; +(SELECT 'X' FROM t2 +WHERE t2.k = CONCAT(t1.k, 'X')) = 'XXX' +EXPLAIN SELECT (SELECT 'X' FROM t2 +WHERE t2.k = CONCAT(t1.k, 'X')) = 'XXX', +SUM(k) +FROM t1; +ERROR 42000: In aggregated query without GROUP BY, expression #1 of SELECT list contains nonaggregated column 'test.t1.k'; this is incompatible with sql_mode=only_full_group_by +EXPLAIN SELECT SUM(k), k +FROM t1 +HAVING (SELECT 'X' FROM t2 +WHERE t2.k = CONCAT(t1.k, 'X')) = 'XXX'; +ERROR 42000: In aggregated query without GROUP BY, expression #2 of SELECT list contains nonaggregated column 'test.t1.k'; this is incompatible with sql_mode=only_full_group_by +EXPLAIN SELECT (SELECT 'X' FROM t2 +WHERE t2.k = CONCAT(t1.k, 'X') +AND SUM(t1.k)) = 'XXX' +FROM t1; +ERROR 42000: In aggregated query without GROUP BY, expression #1 of SELECT list contains nonaggregated column 'test.t1.k'; this is incompatible with sql_mode=only_full_group_by +DROP TABLE t1,t2; +# +# Bug#27665085 ASSERTION FAILED: JOIN == 0. +# +SET sql_mode=''; +CREATE TABLE a(d INT,e BIGINT, KEY(e)); +INSERT a VALUES (0,0); +CREATE TABLE b(f TIME); +INSERT b VALUES (null),(null),(null); +CREATE TABLE c(g DATETIME(6) NOT NULL); +INSERT c(g) VALUES (now()+interval 1 day); +INSERT c(g) VALUES (now()-interval 1 day); +SELECT 1 FROM a WHERE (SELECT f FROM b WHERE (SELECT 1 FROM c)) <=> e GROUP BY d; +ERROR 21000: Subquery returns more than 1 row +SET sql_mode=default; +DROP TABLES a, b, c; +# +# Bug#27182010 SUBQUERY INCORRECTLY SHOWS DUPLICATE VALUES ON SUBQUERIES +# +CREATE TABLE p (Id INT,PRIMARY KEY (Id)); +INSERT INTO p VALUES (1); +# Test UNIQUE KEY with NULL values +CREATE TABLE s (Id INT, u INT, UNIQUE KEY o(Id, u) ); +INSERT INTO s VALUES (1, NULL),(1, NULL); +ANALYZE TABLE s; +Table Op Msg_type Msg_text +test.s analyze status OK +EXPLAIN SELECT p.Id FROM (p) WHERE p.Id IN ( +SELECT s.Id FROM s WHERE Id=1 AND u IS NULL)ORDER BY Id DESC; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE p NULL const PRIMARY PRIMARY 4 const 1 100.00 Using index +1 SIMPLE s NULL ref o o 10 const,const 2 100.00 Using where; Using index; FirstMatch(p) +Warnings: +Note 1003 /* select#1 */ select '1' AS `Id` from `test`.`p` semi join (`test`.`s`) where ((`test`.`s`.`Id` = 1) and (`test`.`s`.`u` is null)) order by '1' desc +EXPLAIN SELECT p.Id FROM (p) WHERE p.Id IN ( +SELECT s.Id FROM s WHERE Id=1 AND u IS NOT NULL) ORDER BY Id DESC; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE p NULL const PRIMARY PRIMARY 4 const 1 100.00 Using index +1 SIMPLE s NULL range o o 10 NULL 1 100.00 Using where; Using index; FirstMatch(p) +Warnings: +Note 1003 /* select#1 */ select '1' AS `Id` from `test`.`p` semi join (`test`.`s`) where ((`test`.`s`.`Id` = 1) and (`test`.`s`.`u` is not null)) order by '1' desc +SELECT p.Id FROM (p) WHERE p.Id IN ( +SELECT s.Id FROM s WHERE Id=1 AND u IS NULL)ORDER BY Id DESC; +Id +1 +SELECT p.Id FROM (p) WHERE p.Id IN ( +SELECT s.Id FROM s WHERE Id=1 AND u IS NOT NULL) ORDER BY Id DESC; +Id +# UNIQUE KEY without NULL values +CREATE TABLE s1 (Id INT, u INT, UNIQUE KEY o(Id, u) ); +INSERT INTO s1 VALUES (1, 2),(1, 3); +ANALYZE TABLE s1; +Table Op Msg_type Msg_text +test.s1 analyze status OK +EXPLAIN SELECT p.Id FROM (p) WHERE p.Id IN ( +SELECT s1.Id FROM s1 WHERE Id=1 AND u IS NOT NULL) ORDER BY Id DESC; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE p NULL const PRIMARY PRIMARY 4 const 1 100.00 Using index +1 SIMPLE s1 NULL index o o 10 NULL 2 100.00 Using where; Using index; FirstMatch(p) +Warnings: +Note 1003 /* select#1 */ select '1' AS `Id` from `test`.`p` semi join (`test`.`s1`) where ((`test`.`s1`.`Id` = 1) and (`test`.`s1`.`u` is not null)) order by '1' desc +EXPLAIN SELECT p.Id FROM (p) WHERE p.Id IN ( +SELECT s1.Id FROM s1 WHERE Id=1 AND u != 1) ORDER BY Id DESC; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE p NULL const PRIMARY PRIMARY 4 const 1 100.00 Using index +1 SIMPLE s1 NULL index o o 10 NULL 2 100.00 Using where; Using index; FirstMatch(p) +Warnings: +Note 1003 /* select#1 */ select '1' AS `Id` from `test`.`p` semi join (`test`.`s1`) where ((`test`.`s1`.`Id` = 1) and (`test`.`s1`.`u` <> 1)) order by '1' desc +SELECT p.Id FROM (p) WHERE p.Id IN ( +SELECT s1.Id FROM s1 WHERE Id=1 AND u IS NOT NULL) ORDER BY Id DESC; +Id +1 +SELECT p.Id FROM (p) WHERE p.Id IN ( +SELECT s1.Id FROM s1 WHERE Id=1 AND u != 1) ORDER BY Id DESC; +Id +1 +# NON UNIQUE KEY Scenario +CREATE TABLE s2 (Id INT, u INT, KEY o(Id, u) ); +INSERT INTO s2 VALUES (1, NULL),(1, NULL); +ANALYZE TABLE s2; +Table Op Msg_type Msg_text +test.s2 analyze status OK +#UNIQUE KEY with NON NULL FIELDS +CREATE TABLE s3 (Id INT NOT NULL, u INT NOT NULL, UNIQUE KEY o(Id, u)); +INSERT INTO s3 VALUES (1, 2),(1, 3); +ANALYZE TABLE s3; +Table Op Msg_type Msg_text +test.s3 analyze status OK +EXPLAIN SELECT p.Id FROM (p) WHERE p.Id IN ( +SELECT s.Id FROM s2 s WHERE Id=1 AND u IS NULL) ORDER BY Id DESC; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE p NULL const PRIMARY PRIMARY 4 const 1 100.00 Using index +1 SIMPLE s NULL ref o o 10 const,const 2 100.00 Using where; Using index; FirstMatch(p) +Warnings: +Note 1003 /* select#1 */ select '1' AS `Id` from `test`.`p` semi join (`test`.`s2` `s`) where ((`test`.`s`.`Id` = 1) and (`test`.`s`.`u` is null)) order by '1' desc +EXPLAIN SELECT p.Id FROM (p) WHERE p.Id IN ( +SELECT s.Id FROM s3 s WHERE Id=1 AND u IS NOT NULL) +ORDER BY Id DESC; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE p NULL const PRIMARY PRIMARY 4 const 1 100.00 Using index +1 SIMPLE s NULL ref o o 4 const 2 100.00 Using index; FirstMatch(p) +Warnings: +Note 1003 /* select#1 */ select '1' AS `Id` from `test`.`p` semi join (`test`.`s3` `s`) where (`test`.`s`.`Id` = 1) order by '1' desc +SELECT p.Id FROM (p) WHERE p.Id IN ( +SELECT s.Id FROM s2 s WHERE Id=1 AND u IS NULL) ORDER BY Id DESC; +Id +1 +SELECT p.Id FROM (p) WHERE p.Id IN ( +SELECT s.Id FROM s3 s WHERE Id=1 AND u IS NOT NULL) +ORDER BY Id DESC; +Id +1 +DROP TABLE p, s, s1, s2, s3; +# +# Bug#28239008: WL#9571: SIG11 IN ITEM_FIELD::RESULT_TYPE() AT SQL/ITEM.H +# +CREATE TABLE t1 (f1 varchar(1) DEFAULT NULL); +INSERT INTO t1 VALUES ('5'); +CREATE TABLE t2 (f1 varchar(1) DEFAULT NULL); +INSERT INTO t2 VALUES ('Y'); +PREPARE prep_stmt FROM "SELECT t2.f1 FROM (t2 LEFT JOIN t1 + ON (1 = ANY (SELECT f1 FROM t1 WHERE 1 IS NULL)))" ; +EXECUTE prep_stmt ; +f1 +Y +DROP TABLE t1,t2; +CREATE TABLE t1 (f1 varchar(1) DEFAULT NULL); +INSERT INTO t1 VALUES ('Z') ; +CREATE TABLE t2 (f1 varchar(1) DEFAULT NULL); +INSERT INTO t2 VALUES ('Z') ; +PREPARE prep_stmt FROM " +SELECT t2.f1 FROM t2 LEFT OUTER JOIN +(SELECT * FROM t2 WHERE ('y',1) + IN (SELECT alias1.f1 , 0 FROM t1 AS alias1 LEFT JOIN t2 ON 0)) AS alias ON 0"; +EXECUTE prep_stmt ; +f1 +Z +PREPARE prep_stmt FROM " +SELECT t2.f1 FROM (t2 LEFT OUTER JOIN (SELECT * FROM t2 WHERE ('y',1) + IN (SELECT alias1.f1 , 0 FROM + (t1 INNER JOIN (t1 AS alias1 LEFT JOIN t2 ON 0) ON 0))) AS alias ON 0)"; +EXECUTE prep_stmt ; +f1 +Z +DROP TABLE t1,t2; +# +# Bug#28805105: Sig11 in calc_length_and_keyparts +# +CREATE TABLE t1 (cv VARCHAR(1) DEFAULT NULL); +INSERT INTO t1 VALUES ('h'), ('Q'), ('I'), ('q'), ('W'); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT cv +FROM t1 +WHERE EXISTS (SELECT alias1.cv AS field1 +FROM t1 AS alias1 RIGHT JOIN t1 AS alias2 +ON alias1.cv = alias2.cv +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +1 SIMPLE NULL const 8 const 1 100.00 NULL +2 MATERIALIZED alias2 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +2 MATERIALIZED alias1 NULL ALL NULL NULL NULL NULL 5 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`cv` AS `cv` from `test`.`t1` semi join (`test`.`t1` `alias2` left join `test`.`t1` `alias1` on((`test`.`alias1`.`cv` = `test`.`alias2`.`cv`))) where true +SELECT cv +FROM t1 +WHERE EXISTS (SELECT alias1.cv AS field1 +FROM t1 AS alias1 RIGHT JOIN t1 AS alias2 +ON alias1.cv = alias2.cv +); +cv +h +Q +I +q +W +DROP TABLE t1; +# Bug#28970261: Sig6 in decorrelate_equality() +CREATE TABLE t1 (col_varchar_key varchar(1) DEFAULT NULL); +EXPLAIN SELECT * +FROM t1 +WHERE col_varchar_key IN +(SELECT col_varchar_key +FROM t1 +WHERE col_varchar_key = +(SELECT col_varchar_key +FROM t1 +WHERE col_varchar_key > @var1 +) +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1); Using join buffer (hash join) +3 UNCACHEABLE SUBQUERY t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col_varchar_key` AS `col_varchar_key` from `test`.`t1` semi join (`test`.`t1`) where ((`test`.`t1`.`col_varchar_key` = `test`.`t1`.`col_varchar_key`) and (`test`.`t1`.`col_varchar_key` = (/* select#3 */ select `test`.`t1`.`col_varchar_key` from `test`.`t1` where (`test`.`t1`.`col_varchar_key` > ((@`var1`)))))) +SELECT * +FROM t1 +WHERE col_varchar_key IN +(SELECT col_varchar_key +FROM t1 +WHERE col_varchar_key = +(SELECT col_varchar_key +FROM t1 +WHERE col_varchar_key > @var1 +) +); +col_varchar_key +EXPLAIN SELECT * +FROM t1 +WHERE col_varchar_key IN +(SELECT col_varchar_key +FROM t1 +WHERE col_varchar_key = +(SELECT col_varchar_key +FROM t1 +WHERE col_varchar_key = RAND() +) +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1); Using join buffer (hash join) +3 UNCACHEABLE SUBQUERY t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col_varchar_key` AS `col_varchar_key` from `test`.`t1` semi join (`test`.`t1`) where ((`test`.`t1`.`col_varchar_key` = `test`.`t1`.`col_varchar_key`) and (`test`.`t1`.`col_varchar_key` = (/* select#3 */ select `test`.`t1`.`col_varchar_key` from `test`.`t1` where (cast(`test`.`t1`.`col_varchar_key` as double) = rand())))) +SELECT * +FROM t1 +WHERE col_varchar_key IN +(SELECT col_varchar_key +FROM t1 +WHERE col_varchar_key = +(SELECT col_varchar_key +FROM t1 +WHERE col_varchar_key = RAND() +) +); +col_varchar_key +DROP TABLE t1; +# +# Bug #29193761: WL#12470: SIG 11 IN MARKUNHANDLEDDUPLICATES() AT SQL/SQL_EXECUTOR.CC +# +CREATE TABLE t1 ( +pk integer NOT NULL PRIMARY KEY, +f1 varchar(1), +KEY k1 (f1) +); +CREATE TABLE t2 ( pk integer NOT NULL PRIMARY KEY ); +CREATE VIEW v2 AS select * FROM t2; +INSERT INTO t1 VALUES (1, 'G'); +INSERT INTO t1 VALUES (2, 'j'); +INSERT INTO t1 VALUES (3, 'K'); +INSERT INTO t1 VALUES (4, 'v'); +INSERT INTO t1 VALUES (5, 'E'); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN FORMAT=tree SELECT * FROM t1 WHERE pk IN ( SELECT pk FROM t1 LEFT JOIN v2 USING (pk) WHERE f1 >= 'o' ); +EXPLAIN +-> Nested loop inner join (cost=3.77 rows=1) + -> Table scan on (cost=2.51..2.51 rows=1) + -> Materialize with deduplication (cost=3.42..3.42 rows=1) + -> Nested loop left join (cost=0.81 rows=1) + -> Filter: (t1.f1 >= 'o') (cost=0.46 rows=1) + -> Index range scan on t1 using k1 (cost=0.46 rows=1) + -> Single-row index lookup on t2 using PRIMARY (pk=t1.pk) (cost=0.35 rows=1) + -> Single-row index lookup on t1 using PRIMARY (pk=``.pk) (cost=0.35 rows=1) + +DROP TABLE t1, t2; +DROP VIEW v2; +# +# Bug #29236241: WL#12470: SIG 6 IN TEMPTABLE::HANDLER::POSITION AT SRC/HANDLER.CC +# +CREATE TABLE t1 ( +f1 varchar(1), +KEY k1 (f1) +); +INSERT INTO t1 VALUES ('6'),('6'); +EXPLAIN FORMAT=tree SELECT 1 WHERE ( +SELECT 1 +FROM t1 LEFT JOIN t1 AS t2 ON 'f' IN ( SELECT f1 FROM t1 ) +WHERE EXISTS ( SELECT * FROM t1 LEFT JOIN t1 AS t3 ON t3.f1='a' ) +); +ERROR 21000: Subquery returns more than 1 row +DROP TABLE t1; +# +# Bug #29231551: WL#12470: SIG 6 QEP_TAB->LAST_INNER() == (-2) CONNECTJOINS()|SQL/SQL_EXECUTOR.CC +# +CREATE TABLE t1 ( +pk integer PRIMARY KEY, +f1 integer, +f2 varchar(1) +); +INSERT INTO t1 VALUES (1,100,'x'),(2,200,'y'); +CREATE TABLE t2 ( +f2 varchar(1) +); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN FORMAT=tree SELECT * FROM t1 LEFT JOIN t1 AS t3 ON t1.pk = t3.pk AND t1.f2 IN ( SELECT f2 FROM t2 ) +WHERE EXISTS ( SELECT * FROM t1 AS t4, t2 AS t5 ) AND t1.f1 = 80 AND t1.pk > t1.f1; +EXPLAIN +-> Parallel scan on + -> Nested loop left join (cost=0.91 rows=1) + -> Nested loop semijoin (cost=0.68 rows=1) + -> Filter: ((t1.f1 = 80) and (t1.pk > 80)) (cost=0.46 rows=0) + -> PQblock range scan on t1 using PRIMARY (cost=0.46 rows=1) + -> Nested loop inner join (cost=0.77 rows=2) + -> Table scan on t5 (cost=0.45 rows=1) + -> Index scan on t4 using PRIMARY (cost=1.30 rows=2) + -> Nested loop semijoin (cost=0.80 rows=1) + -> Single-row index lookup on t3 using PRIMARY (pk=t1.pk) (cost=0.45 rows=1) + -> Filter: (t2.f2 = t1.f2) (cost=0.70 rows=1) + -> Table scan on t2 (cost=0.70 rows=1) + +DROP TABLE t1, t2; +# +# Bug#29356132:OPTIMIZED-AWAY SUBQUERY IN PREPARED STATEMENT CAUSES ASSERT FAILURE IN EXECUTION +# +CREATE TABLE t1 (f1 varchar(1)); +INSERT INTO t1 VALUES ('5'); +CREATE TABLE t2 (f1 varchar(1)); +INSERT INTO t2 VALUES ('Y'); +PREPARE prep_stmt FROM "SELECT t2.f1 FROM (t2 LEFT JOIN t1 + ON 1 IN (SELECT f1 FROM t1 WHERE FALSE))" ; +EXECUTE prep_stmt ; +f1 +Y +DROP TABLE t1,t2; +# Bug#28955216: Assertion 'keyparts > 0' failed +set optimizer_switch='derived_merge=off'; +CREATE TABLE t1 ( +pk INTEGER, +col_int_key INTEGER, +col_datetime_gckey DATETIME, +col_time_gckey TIME, +col_varchar_key VARCHAR(15) +); +CREATE TABLE t2 ( +pk INTEGER, +col_int_key INTEGER, +col_varchar_key VARCHAR(15) +); +EXPLAIN SELECT alias1.col_time_gckey AS field1, +alias1.col_datetime_gckey AS field2 +FROM t1 AS alias1, +(SELECT DISTINCT sq1_alias2.* +FROM t1 AS sq1_alias1, t1 AS sq1_alias2 +) AS alias2, +(SELECT sq2_alias1.* +FROM t1 AS sq2_alias1 RIGHT OUTER JOIN +t1 AS sq2_alias2 INNER JOIN t2 AS sq2_alias3 +ON sq2_alias3.col_int_key = sq2_alias2.col_int_key +ON sq2_alias3.col_varchar_key = sq2_alias2.col_varchar_key +) AS alias3 +WHERE alias2.col_int_key = SOME +(WITH qn AS +(SELECT sq3_alias1.pk AS sq3_field1 +FROM t1 AS sq3_alias1 +WHERE sq3_alias1.col_int_key = alias3.pk +) +SELECT /*+ MERGE(qn) */ * FROM qn +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY alias1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 PRIMARY NULL ALL NULL NULL NULL NULL NULL 100.00 Using where; Using join buffer (hash join) +1 PRIMARY NULL ref 5 .sq3_field1 2 100.00 NULL +1 PRIMARY NULL ref 5 .col_int_key 2 100.00 NULL +4 MATERIALIZED sq3_alias1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +3 DERIVED sq2_alias2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +3 DERIVED sq2_alias3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +3 DERIVED sq2_alias1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +2 DERIVED sq1_alias1 NULL ALL NULL NULL NULL NULL 1 100.00 Using temporary +2 DERIVED sq1_alias2 NULL ALL NULL NULL NULL NULL 1 100.00 Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'alias3.pk' of SELECT #5 was resolved in SELECT #1 +Note 1003 /* select#1 */ select /*+ MERGE(`qn`@`select#4`) */ `test`.`alias1`.`col_time_gckey` AS `field1`,`test`.`alias1`.`col_datetime_gckey` AS `field2` from `test`.`t1` `alias1` join (/* select#2 */ select distinct `test`.`sq1_alias2`.`pk` AS `pk`,`test`.`sq1_alias2`.`col_int_key` AS `col_int_key`,`test`.`sq1_alias2`.`col_datetime_gckey` AS `col_datetime_gckey`,`test`.`sq1_alias2`.`col_time_gckey` AS `col_time_gckey`,`test`.`sq1_alias2`.`col_varchar_key` AS `col_varchar_key` from `test`.`t1` `sq1_alias1` join `test`.`t1` `sq1_alias2`) `alias2` join (/* select#3 */ select `test`.`sq2_alias1`.`pk` AS `pk`,`test`.`sq2_alias1`.`col_int_key` AS `col_int_key`,`test`.`sq2_alias1`.`col_datetime_gckey` AS `col_datetime_gckey`,`test`.`sq2_alias1`.`col_time_gckey` AS `col_time_gckey`,`test`.`sq2_alias1`.`col_varchar_key` AS `col_varchar_key` from `test`.`t1` `sq2_alias2` join `test`.`t2` `sq2_alias3` left join `test`.`t1` `sq2_alias1` on((`test`.`sq2_alias3`.`col_varchar_key` = `test`.`sq2_alias2`.`col_varchar_key`)) where (`test`.`sq2_alias3`.`col_int_key` = `test`.`sq2_alias2`.`col_int_key`)) `alias3` semi join (`test`.`t1` `sq3_alias1`) where ((`alias3`.`pk` = ``.`col_int_key`) and (`alias2`.`col_int_key` = ``.`sq3_field1`)) +SELECT alias1.col_time_gckey AS field1, +alias1.col_datetime_gckey AS field2 +FROM t1 AS alias1, +(SELECT DISTINCT sq1_alias2.* +FROM t1 AS sq1_alias1, t1 AS sq1_alias2 +) AS alias2, +(SELECT sq2_alias1.* +FROM t1 AS sq2_alias1 RIGHT OUTER JOIN +t1 AS sq2_alias2 INNER JOIN t2 AS sq2_alias3 +ON sq2_alias3.col_int_key = sq2_alias2.col_int_key +ON sq2_alias3.col_varchar_key = sq2_alias2.col_varchar_key +) AS alias3 +WHERE alias2.col_int_key = SOME +(WITH qn AS +(SELECT sq3_alias1.pk AS sq3_field1 +FROM t1 AS sq3_alias1 +WHERE sq3_alias1.col_int_key = alias3.pk +) +SELECT /*+ MERGE(qn) */ * FROM qn +); +field1 field2 +DROP TABLE t1, t2; +set optimizer_switch=default; +# +# Bug #29493026: INCORRECT RESULT FROM QUERY CONTAINING AN IN-SUBQUERY +# +CREATE TABLE t1 ( +pk INTEGER +); +INSERT INTO t1 VALUES (1); +CREATE TABLE t2 ( +pk INTEGER PRIMARY KEY +); +INSERT INTO t2 VALUES(1); +CREATE TABLE t3 ( +col_int_key INTEGER, +pk INTEGER +); +INSERT INTO t3 VALUES (31,4),(2,5),(17,3),(5,2),(17,1); +CREATE TABLE t4 ( +col_int_key INTEGER, +col_int_unique INTEGER, +UNIQUE KEY ix2 (col_int_key,col_int_unique) +); +INSERT INTO t4 VALUES (6,2),(34,3); +ANALYZE TABLE t1, t2, t3, t4; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +test.t4 analyze status OK +set optimizer_switch='firstmatch=off'; +EXPLAIN FORMAT=tree SELECT * FROM t1 WHERE pk IN ( +SELECT t2.pk FROM +t4 +RIGHT JOIN t3 ON t4.col_int_key = t3.pk +RIGHT JOIN t2 ON t3.col_int_key <> t2.pk +); +EXPLAIN +-> Nested loop inner join (cost=0.95 rows=5) + -> Filter: (t1.pk is not null) (cost=0.35 rows=1) + -> Table scan on t1 (cost=0.35 rows=1) + -> Single-row index lookup on using (pk=t1.pk) + -> Materialize with deduplication (cost=1.60..1.60 rows=5) + -> Nested loop left join (cost=1.10 rows=5) + -> Index scan on t2 using PRIMARY (cost=0.35 rows=1) + -> Nested loop left join (cost=2.50 rows=5) + -> Filter: (t3.col_int_key <> t2.pk) (cost=0.75 rows=5) + -> Table scan on t3 (cost=0.75 rows=5) + -> Index lookup on t4 using ix2 (col_int_key=t3.pk) (cost=0.27 rows=1) + +SELECT * FROM t1 WHERE pk IN ( +SELECT t2.pk FROM +t4 +RIGHT JOIN t3 ON t4.col_int_key = t3.pk +RIGHT JOIN t2 ON t3.col_int_key <> t2.pk +); +pk +1 +DROP TABLE t1, t2, t3, t4; +set optimizer_switch=default; +# +# Bug #29693294: ASSERTION FAILURE M_INDEX_CURSOR.IS_POSITIONED() | SRC/HANDLER.CC +# +CREATE TABLE t1 ( pk integer, f1 varchar(1) ); +INSERT INTO t1 VALUES (1,'D'), (20,'G'); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN FORMAT=TREE SELECT * FROM ( SELECT DISTINCT * FROM t1 ) AS d0 LEFT JOIN t1 ON d0.pk IN ( SELECT 1 FROM t1 ) ORDER BY d0.f1; +EXPLAIN +-> Sort: d0.f1 + -> Stream results (cost=6.95 rows=8) + -> Nested loop left join (cost=6.95 rows=8) + -> Table scan on d0 (cost=1.26..2.52 rows=2) + -> Materialize (cost=4.64..5.90 rows=2) + -> Table scan on (cost=1.26..2.52 rows=2) + -> Temporary table with deduplication (cost=1.91..3.17 rows=2) + -> Table scan on t1 (cost=0.45 rows=2) + -> Nested loop semijoin (cost=0.88 rows=4) + -> Filter: (d0.pk = 1) (cost=0.23 rows=2) + -> Table scan on t1 (cost=0.23 rows=2) + -> Table scan on t1 (cost=0.23 rows=2) + +SELECT * FROM ( SELECT DISTINCT * FROM t1 ) AS d0 LEFT JOIN t1 ON d0.pk IN ( SELECT 1 FROM t1 ) ORDER BY d0.f1; +pk f1 pk f1 +1 D 1 D +1 D 20 G +20 G NULL NULL +DROP TABLE t1; +# +# Bug#29664504 REGRESSION: CRASHING FROM ITEM_FUNC_AS_WKT::VAL_STR_ASCII() +# +CREATE TABLE t1(a TINYBLOB); +INSERT INTO t1 VALUES('aaa'),('bbb'),(''),('ccc'); +SELECT DISTINCT * FROM t1 +ORDER BY UUID_TO_BIN( +ST_ISEMPTY( +ST_POINTFROMTEXT( +ST_ASWKT( +NOT EXISTS( +SELECT 1 FROM t1 +WHERE IS_UUID(CAST(SHA(a>>0xA7FE1B22)AS JSON)) WINDOW w1 AS() +),'AXIS-ORDER=SRID-DEFINED' + ),1,'AXIS-ORDER=LONG-LAT' + ) +) +); +ERROR 22032: Invalid JSON text in argument 1 to function cast_as_json: "The document root must not be followed by other values." at position 4. +DROP TABLE t1; +# +# Bug#29669840 REGRESSION: CRASH IN DECIMAL_ADD() +# +CREATE TABLE t1(a DATETIME(2)); +INSERT INTO t1 VALUES(NOW(2)),(NOW(2)); +SELECT STD(IS_FREE_LOCK(0x2ADA5C38)),1 FROM t1 WHERE a+(EXISTS(SELECT 1)); +ERROR 42000: Incorrect user-level lock name '*\xDA\8'. +DROP TABLE t1; +# +# Bug#29668446 REGRESSION: CRASH IN DO_DIV_MOD() +# +CREATE TABLE t1(a INT); +INSERT INTO t1 VALUES(1),(2),(3); +SELECT 1 FROM t1 WHERE +(EXISTS(SELECT 1 FROM t1 WHERE (SELECT 1 FROM t1 WINDOW w1 AS())))/1; +ERROR 21000: Subquery returns more than 1 row +DROP TABLE t1; +# Bug#29525304 Sig 6 at Item_in_subselect::val_int() +CREATE TABLE t1 (vc varchar(1) NOT NULL); +CREATE VIEW v1 AS SELECT * FROM t1 WHERE 5 IN (SELECT 1) IS UNKNOWN; +DROP VIEW v1; +DROP TABLE t1; +# +# Bug #29889223: SIG 6 AT TEMPTABLE::HANDLER::UPDATE_ROW | SRC/HANDLER.CC +# +set optimizer_switch='block_nested_loop=off,batched_key_access=off'; +CREATE TABLE t1 ( +field1 integer +); +INSERT INTO t1 VALUES (13); +CREATE TABLE t2 ( +field2 integer +); +INSERT INTO t2 VALUES (18); +CREATE TABLE t3 ( +field3 integer +); +INSERT INTO t3 VALUES (1); +UPDATE t3 SET field3 = 9 WHERE field3 IN ( +SELECT 1 +FROM ( SELECT * FROM t2 ) AS alias1 +WHERE EXISTS ( SELECT * FROM t1 WHERE field1 <> alias1.field2 ) +); +DROP TABLE t1, t2, t3; +set optimizer_switch=default; +# +# Bug #29836364: WL#13000: SIG 11 AT COST_SKIP_SCAN() | SQL/OPT_RANGE.CC +# +CREATE TABLE t1 ( +f1 integer NOT NULL PRIMARY KEY, +f2 varchar(1), +KEY f2_idx (f2) +); +INSERT INTO t1 VALUES (20,'2'); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +explain format=tree SELECT ( +SELECT t2.f2 FROM t1 JOIN ( +t1 AS t2 LEFT JOIN t1 AS t3 USING (f2) +) ON t3.f2 = t2.f2 +WHERE t2.f1 > table1.f2 +) FROM t1 AS table1; +EXPLAIN +-> Index scan on table1 using f2_idx (cost=0.35 rows=1) +-> Select #2 (subquery in projection; dependent) + -> Nested loop inner join (cost=1.05 rows=1) + -> Nested loop inner join (cost=0.70 rows=1) + -> Index scan on t1 using f2_idx (cost=0.35 rows=1) + -> Filter: (cast(t2.f1 as double) > cast(table1.f2 as double)) (cost=0.35 rows=1) + -> Index range scan on t2 (re-planned for each iteration) (cost=0.35 rows=1) + -> Index lookup on t3 using f2_idx (f2=t2.f2) (cost=0.35 rows=1) + +Warnings: +Note 1276 Field or reference 'test.table1.f2' of SELECT #2 was resolved in SELECT #1 +SELECT ( +SELECT t2.f2 FROM t1 JOIN ( +t1 AS t2 LEFT JOIN t1 AS t3 USING (f2) +) ON t3.f2 = t2.f2 +WHERE t2.f1 > table1.f2 +) FROM t1 AS table1; +( +SELECT t2.f2 FROM t1 JOIN ( +t1 AS t2 LEFT JOIN t1 AS t3 USING (f2) +) ON t3.f2 = t2.f2 +WHERE t2.f1 > table1.f2 +) +2 +DROP TABLE t1; +# Bug#28941154: Executing query does not return a result the first time +CREATE TABLE t1 ( +pk int NOT NULL, +col_int int, +col_time_key time, +col_varchar_key varchar(1), +PRIMARY KEY (pk), +KEY idx_CC_col_time_key (col_time_key), +KEY idx_CC_col_varchar_key (col_varchar_key) +); +INSERT INTO t1 VALUES +(1,1244696008,'15:54:41','u'), +(2,893471119,'16:03:34','e'), +(3,462275345,'06:57:11','g'), +(4,2067212400,'06:56:19','E'), +(5,-270339471,'03:38:07','d'), +(6,-734590502,'03:18:29','Q'), +(7,-1230000720,'15:56:21','C'), +(8,-1086526061,'19:08:49','B'), +(9,-1620913518,'22:44:04','3'), +(10,1210237478,'11:18:51','i'), +(11,-886894023,'20:28:00','A'), +(12,-1490912666,'17:51:14','H'), +(13,149282252,'16:51:14','Z'), +(14,1451237940,'09:13:29','L'), +(15,1933327447,'11:14:05','2'), +(16,-693463421,'05:29:04','V'), +(17,333204980,'16:24:13','O'), +(18,279626907,'09:45:54','t'), +(19,-1372487638,'17:45:04','a'), +(20,-150563684,'15:32:40','D'); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +explain SELECT table2.col_time_key AS field1 +FROM t1 AS table1 LEFT JOIN t1 AS table2 +ON table1.col_varchar_key = table2.col_varchar_key +WHERE 1 IN (SELECT 1 FROM t1 AS subq +WHERE subq.pk <= (SELECT DISTINCT MIN(subq.col_int) +FROM t1 as alias1 +) +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY subq NULL ALL NULL NULL NULL NULL 20 100.00 Using where; FirstMatch +1 PRIMARY table1 NULL index NULL idx_CC_col_varchar_key 7 NULL 20 100.00 Using index; Using join buffer (hash join) +1 PRIMARY table2 NULL ref idx_CC_col_varchar_key idx_CC_col_varchar_key 7 test.table1.col_varchar_key 1 100.00 NULL +3 DEPENDENT SUBQUERY alias1 NULL index NULL idx_CC_col_time_key 4 NULL 20 100.00 Using index +Warnings: +Note 1276 Field or reference 'test.subq.col_int' of SELECT #3 was resolved in SELECT #2 +Note 1003 /* select#1 */ select `test`.`table2`.`col_time_key` AS `field1` from `test`.`t1` `table1` left join `test`.`t1` `table2` on((`test`.`table2`.`col_varchar_key` = `test`.`table1`.`col_varchar_key`)) semi join (`test`.`t1` `subq`) where (`test`.`subq`.`pk` <= (/* select#3 */ select min(`test`.`subq`.`col_int`) from `test`.`t1` `alias1`)) +SELECT table2.col_time_key AS field1 +FROM t1 AS table1 LEFT JOIN t1 AS table2 +ON table1.col_varchar_key = table2.col_varchar_key +WHERE 1 IN (SELECT 1 FROM t1 AS subq +WHERE subq.pk <= (SELECT DISTINCT MIN(subq.col_int) +FROM t1 as alias1 +) +); +field1 +03:18:29 +03:38:07 +03:38:07 +05:29:04 +06:56:19 +06:56:19 +06:57:11 +09:13:29 +09:45:54 +11:14:05 +11:18:51 +15:32:40 +15:32:40 +15:54:41 +15:56:21 +16:03:34 +16:03:34 +16:24:13 +16:51:14 +17:45:04 +17:45:04 +17:51:14 +19:08:49 +20:28:00 +20:28:00 +22:44:04 +DROP TABLE t1; +# Bug#28910365 Segfault at Item_cache::walk() on 2nd execution +CREATE TABLE t1 ( +pk int NOT NULL, +col_int int DEFAULT NULL +); +CREATE TABLE t2 ( +pk int NOT NULL, +col_int int DEFAULT NULL +); +INSERT INTO t2 VALUES (1, 2); +PREPARE st FROM +"DELETE outr1.* + FROM t1 AS outr1 RIGHT OUTER JOIN t2 AS outr2 + ON outr1.col_int = outr2.col_int + WHERE (0, 3) NOT IN (SELECT innr1.pk AS x, innr1.col_int AS y + FROM t2 AS innr1 + WHERE outr1.col_int = 25)"; +EXECUTE st; +EXECUTE st; +DEALLOCATE PREPARE st; +DROP TABLE t1, t2; +# +# Bug #30250091: CONDITIONS WITHIN MATERIALIZED SEMIJOINS ARE FLOATING UP +# +CREATE TABLE t1 ( +f1 INTEGER +); +INSERT INTO t1 VALUES (1), (2), (3); +CREATE TABLE t2 ( +f2 VARCHAR(10) +); +CREATE TABLE t3 ( +f3 INTEGER UNIQUE NOT NULL +); +CREATE TABLE t4 ( +f4 INTEGER +); +INSERT INTO t4 VALUES (13), (14), (NULL); +ANALYZE TABLE t1, t2, t3, t4; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +test.t4 analyze status OK +explain format=tree SELECT * FROM t1 +WHERE NOT EXISTS ( +SELECT * +FROM t4 LEFT JOIN t3 ON t4.f4 = t3.f3 +WHERE 'abc' IN ( +SELECT t2.f2 FROM t2 WHERE t3.f3 = 1 HAVING t2.f2 = 'xyz' + ) +); +EXPLAIN +-> Table scan on t1 (cost=0.55 rows=3) + +Warnings: +Note 1276 Field or reference 'test.t3.f3' of SELECT #3 was resolved in SELECT #2 +SELECT * FROM t1 +WHERE NOT EXISTS ( +SELECT * +FROM t4 LEFT JOIN t3 ON t4.f4 = t3.f3 +WHERE 'abc' IN ( +SELECT t2.f2 FROM t2 WHERE t3.f3 = 1 HAVING t2.f2 = 'xyz' + ) +); +f1 +1 +2 +3 +DROP TABLE t1, t2, t3, t4; +# +# Bug #30289052: MYSQL PRODUCES DIFFERENT RESULT FOR MATERIALIZED SUBQUERY IF INDEX EXISTS OR NOT +# +CREATE TABLE table_city (id int NOT NULL PRIMARY KEY); +CREATE TABLE table_user (id int NOT NULL PRIMARY KEY); +CREATE TABLE table_city_user (city int NOT NULL, user int NOT NULL, KEY city (city)); +INSERT INTO table_city (id) VALUES (1),(2),(3),(4),(5),(6); +INSERT INTO table_user (id) VALUES (1),(2),(3),(4),(5),(6),(7),(8); +INSERT INTO table_city_user (city, user) VALUES +(1,1),(1,1),(1,2),(1,3),(1,4),(1,5),(1,6),(1,7),(1,8),(2,1),(2,2),(2,3),(2,4), +(2,5),(3,2),(3,5),(4,5),(4,2),(4,3),(4,8),(4,1); +ANALYZE TABLE table_city, table_user, table_city_user; +Table Op Msg_type Msg_text +test.table_city analyze status OK +test.table_user analyze status OK +test.table_city_user analyze status OK +EXPLAIN FORMAT=tree SELECT id, ( +SELECT GROUP_CONCAT(id) FROM ( +SELECT table_user.id FROM table_user WHERE id IN ( +SELECT user FROM table_city_user WHERE table_city_user.city = table_city.id +) +GROUP BY table_user.id +) AS d +) AS users FROM table_city; +EXPLAIN +-> Index scan on table_city using PRIMARY (cost=0.85 rows=6) +-> Select #2 (subquery in projection; dependent) + -> Aggregate: group_concat(d.id separator ',') + -> Table scan on d (cost=0.51..2.56 rows=5) + -> Materialize (cost=5.85..7.90 rows=5) + -> Table scan on (cost=0.51..2.56 rows=5) + -> Temporary table with deduplication (cost=2.79..4.84 rows=5) + -> Nested loop inner join (cost=1.77 rows=5) + -> Filter: (table_city.id = ``.city) (cost=1.47..1.02 rows=5) + -> Table scan on (cost=0.49..2.56 rows=5) + -> Materialize with deduplication (cost=2.06..4.14 rows=5) + -> Index lookup on table_city_user using city (city=table_city.id) (cost=1.05 rows=5) + -> Single-row index lookup on table_user using PRIMARY (id=``.`user`) (cost=0.35 rows=1) + +Warnings: +Note 1276 Field or reference 'test.table_city.id' of SELECT #4 was resolved in SELECT #1 +SELECT id, ( +SELECT GROUP_CONCAT(id) FROM ( +SELECT table_user.id FROM table_user WHERE id IN ( +SELECT user FROM table_city_user WHERE table_city_user.city = table_city.id +) +GROUP BY table_user.id +) AS d +) AS users FROM table_city; +id users +1 1,2,3,4,5,6,7,8 +2 1,2,3,4,5 +3 2,5 +4 1,2,3,5,8 +5 NULL +6 NULL +DROP TABLE table_city, table_user, table_city_user; +# +# Bug#30267889 ASSERTION `M_INDEX_CURSOR.IS_POSITIONED()' FAILED | TEMPTABLE::HANDLER::POSITION +# +CREATE TABLE b (c INTEGER, KEY idx_b (c)); +CREATE TABLE c (c INTEGER, KEY idx_c (c)); +CREATE TABLE d (c INTEGER, KEY idx_d (c)); +INSERT INTO b VALUES (1), (2); +INSERT INTO c VALUES (1), (2); +INSERT INTO d VALUES (1), (2); +ANALYZE TABLE b, c, d; +Table Op Msg_type Msg_text +test.b analyze status OK +test.c analyze status OK +test.d analyze status OK +EXPLAIN FORMAT=tree SELECT /*+ JOIN_ORDER(b, c_inner, c_inner_inner, d, c) */ d.c +FROM d JOIN c +WHERE d.c IN ( +SELECT +b.c +FROM +b LEFT JOIN c AS c_inner ON c_inner.c = b.c +WHERE +EXISTS ( SELECT c FROM c AS c_inner_inner ) +) ORDER BY d.c; +EXPLAIN +-> Sort: d.c + -> Stream results (cost=1.55 rows=4) + -> Inner hash join (no condition) (cost=1.55 rows=4) + -> Index scan on c using idx_c (cost=0.45 rows=2) + -> Hash + -> Nested loop inner join (cost=0.90 rows=2) + -> Filter: (``.c is not null) (cost=1.20..0.20 rows=2) + -> Table scan on (cost=0.64..2.55 rows=4) + -> Materialize with deduplication (cost=2.84..4.75 rows=4) + -> Filter: (b.c is not null) (cost=1.80 rows=4) + -> Inner hash join (no condition) (cost=1.80 rows=4) + -> Index scan on c_inner_inner using idx_c (cost=0.23 rows=2) + -> Hash + -> Nested loop left join (cost=1.15 rows=2) + -> Index scan on b using idx_b (cost=0.45 rows=2) + -> Index lookup on c_inner using idx_c (c=b.c) (cost=0.30 rows=1) + -> Index lookup on d using idx_d (c=``.c) (cost=0.60 rows=1) + +SELECT /*+ JOIN_ORDER(b, c_inner, c_inner_inner, d, c) */ d.c +FROM d JOIN c +WHERE d.c IN ( +SELECT +b.c +FROM +b LEFT JOIN c AS c_inner ON c_inner.c = b.c +WHERE +EXISTS ( SELECT c FROM c AS c_inner_inner ) +) ORDER BY d.c; +c +1 +1 +2 +2 +DROP TABLE b, c, d; +CREATE TABLE t1(pk INT PRIMARY KEY, col_int_nokey INT); +INSERT INTO t1 VALUES(26, 12); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT /*+ JOIN_ORDER(t3,t1) */ * +FROM +t1 WHERE 3 IN (SELECT t3.col_int_nokey FROM t1 AS t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select /*+ JOIN_ORDER(@`select#1` `t3`,`t1`) */ `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`col_int_nokey` AS `col_int_nokey` from `test`.`t1` semi join (`test`.`t1` `t3`) where (`test`.`t3`.`col_int_nokey` = 3) +EXPLAIN FORMAT=TREE SELECT /*+ JOIN_ORDER(t3,t1) */ * +FROM +t1 WHERE 3 IN (SELECT t3.col_int_nokey FROM t1 AS t3); +EXPLAIN +-> Inner hash join (no condition) (cost=0.70 rows=1) + -> Table scan on t1 (cost=0.35 rows=1) + -> Hash + -> Limit: 1 row(s) (cost=0.35 rows=1) + -> Filter: (t3.col_int_nokey = 3) (cost=0.35 rows=1) + -> Table scan on t3 (cost=0.35 rows=1) + +EXPLAIN SELECT /*+ JOIN_ORDER(t1,t3,t2) */ * +FROM +t1 LEFT JOIN t1 AS t2 +ON 3 IN (SELECT t3.col_int_nokey FROM t1 AS t3) +WHERE t1.pk=26; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select /*+ JOIN_ORDER(@`select#1` `t1`,`t3`,`t2`) */ '26' AS `pk`,'12' AS `col_int_nokey`,`test`.`t2`.`pk` AS `pk`,`test`.`t2`.`col_int_nokey` AS `col_int_nokey` from `test`.`t1` left join (`test`.`t1` `t2` semi join (`test`.`t1` `t3`)) on(((`test`.`t3`.`col_int_nokey` = 3))) where true +EXPLAIN FORMAT=TREE SELECT /*+ JOIN_ORDER(t1,t3,t2) */ * +FROM +t1 LEFT JOIN t1 AS t2 +ON 3 IN (SELECT t3.col_int_nokey FROM t1 AS t3) +WHERE t1.pk=26; +EXPLAIN +-> Remove duplicate (t1, t2) rows using temporary table (weedout) + -> Nested loop left join (cost=0.35 rows=1) + -> Rows fetched before execution (cost=0.00..0.00 rows=1) + -> Nested loop inner join (cost=0.70 rows=1) + -> Filter: (t3.col_int_nokey = 3) (cost=0.35 rows=1) + -> Table scan on t3 (cost=0.35 rows=1) + -> Table scan on t2 (cost=0.35 rows=1) + +DROP TABLE t1; +# +# Bug#30273827: SIG6 IN SELECT_LEX_UNIT::EXCLUDE_LEVEL() AT +# SQL/SQL_LEX.CC +# +CREATE TABLE t1(f1 varchar(1)) ; +SELECT 1 FROM t1 AS table2 LEFT JOIN (SELECT 'c') AS table3(f1) +ON table3.f1 = table2.f1 WHERE table2.f1 +IN (SELECT 1 FROM (SELECT 1314830897) AS t1(pk) +WHERE t1.pk <= ANY(SELECT 5)) AND FALSE; +1 +DROP TABLE t1; +# Bug#30309982: Sig6 in Item_subselect::exec() +CREATE VIEW v1 AS +SELECT 1 +FROM (SELECT 1) AS table1(pk) JOIN +(SELECT 1) AS table2 +ON table1.pk = (SELECT 1) +WHERE table1.pk IN ((SELECT 1), 2); +SELECT * FROM v1; +1 +1 +DROP VIEW v1; +# +# Bug#30515233 DISTINCT INSIDE LATERAL DERIVED TABLE BREAKS IN ITERATOR EXECUTOR +# +CREATE TABLE t(a INT); +INSERT INTO t VALUES (1),(2),(3); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +SELECT * FROM +t AS upper JOIN LATERAL +(SELECT DISTINCT ROW_NUMBER() OVER () AS rn FROM t +WHERE (t.a > upper.a)) der ; +a rn +1 1 +1 2 +2 1 +DROP TABLE t; +# +# Verify that decorrelation works for WHERE outer_col=constant +# +CREATE TABLE t1 (a INTEGER, b INTEGER); +CREATE TABLE t2 (a INTEGER); +INSERT INTO t1 VALUES(1,10),(2,10),(3,30); +INSERT INTO t2 VALUES(2),(3),(2),(4); +ANALYZE TABLE t1,t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +set optimizer_switch='semijoin=on,materialization=on,loosescan=off,firstmatch=off,duplicateweedout=off'; +EXPLAIN SELECT * FROM t1 WHERE (t1.a,t1.b) IN (SELECT t2.a,10 FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +1 SIMPLE NULL eq_ref 9 test.t1.a,test.t1.b 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`b` = 10) and (``.`a` = `test`.`t1`.`a`)) +SELECT * FROM t1 WHERE (t1.a,t1.b) IN (SELECT t2.a,10 FROM t2); +a b +2 10 +EXPLAIN SELECT * FROM t1 WHERE t1.a IN (SELECT t2.a FROM t2 WHERE 10=t1.b); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +1 SIMPLE NULL eq_ref 9 test.t1.a,test.t1.b 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +Warnings: +Note 1276 Field or reference 'test.t1.b' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`b` = 10) and (``.`a` = `test`.`t1`.`a`)) +SELECT * FROM t1 WHERE t1.a IN (SELECT t2.a FROM t2 WHERE 10=t1.b); +a b +2 10 +EXPLAIN SELECT * FROM t1 WHERE EXISTS (SELECT * FROM t2 WHERE 10=t1.b AND t1.a=t2.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +1 SIMPLE NULL eq_ref 9 test.t1.b,test.t1.a 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +Warnings: +Note 1276 Field or reference 'test.t1.b' of SELECT #2 was resolved in SELECT #1 +Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t2`) where ((``.`a` = `test`.`t1`.`a`) and (`test`.`t1`.`b` = 10)) +SELECT * FROM t1 WHERE EXISTS (SELECT * FROM t2 WHERE 10=t1.b AND t1.a=t2.a); +a b +2 10 +DROP TABLE t1,t2; +set optimizer_switch=default; +# +# Bug #30717861: WL#13377 REGRESSION, ITEM REFS ARE SUBSTITUTED TO REFER TABLES NOT YET AVAILABLE +# +CREATE TABLE t1 ( +col_int INTEGER, +pk INTEGER +); +INSERT INTO t1 VALUES (6,24),(7,0),(8,2),(0,15); +CREATE TABLE t2 ( +pk INTEGER, +UNIQUE ( pk ) +); +INSERT INTO t2 VALUES (6),(27),(41); +CREATE TABLE t3 ( +pk INTEGER +); +INSERT INTO t3 VALUES (4),(40),(46); +CREATE TABLE t4 ( +col_int INTEGER +); +ANALYZE TABLE t1, t2, t3, t4; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +test.t4 analyze status OK +EXPLAIN FORMAT=tree +SELECT * FROM +t1 +JOIN t2 ON t1.pk = t2.pk +JOIN t3 ON t2.pk = t3.pk +WHERE (t1.col_int + t2.pk) IN ( SELECT col_int FROM t4 ); +EXPLAIN +-> Nested loop inner join (cost=5.51 rows=3) + -> Inner hash join (t1.pk = t3.pk), ((t1.col_int + t1.pk) = ``.col_int) (cost=4.96 rows=3) + -> Table scan on t1 (cost=0.12 rows=4) + -> Hash + -> Inner hash join (no condition) (cost=3.51 rows=3) + -> Filter: (t3.pk is not null) (cost=0.55 rows=3) + -> Table scan on t3 (cost=0.55 rows=3) + -> Hash + -> Table scan on (cost=2.51..2.51 rows=1) + -> Materialize with deduplication (cost=2.96..2.96 rows=1) + -> Filter: (t4.col_int is not null) (cost=0.35 rows=1) + -> Table scan on t4 (cost=0.35 rows=1) + -> Single-row index lookup on t2 using pk (pk=t3.pk) (cost=0.12 rows=1) + +DROP TABLE t1, t2, t3, t4; +CREATE TABLE t1 ( +col1 CHAR(16), +UNIQUE KEY col1_idx (col1) +); +CREATE TABLE t2 ( +col1 INTEGER, +col2 INTEGER, +UNIQUE KEY ix1 (col1) +); +CREATE TABLE t3 ( +col1 INTEGER, +col2 INTEGER NOT NULL, +UNIQUE KEY ix1 (col1) +); +ANALYZE TABLE t1,t2,t3; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +EXPLAIN FORMAT=tree +SELECT /*+ JOIN_ORDER(t3,t2,t1) */ * FROM t1 +WHERE t1.col1 = ANY ( +SELECT t1.col1 + t2.col2 +FROM t2 JOIN t3 ON t2.col2 = t3.col2 AND t2.col1 = t3.col1 +WHERE t2.col2 BETWEEN 2 AND 9 +); +EXPLAIN +-> Remove duplicate t1 rows using temporary table (weedout) (cost=1.05 rows=1) + -> Filter: (cast(t1.col1 as double) = (t1.col1 + t2.col2)) (cost=1.05 rows=1) + -> Inner hash join (no condition) (cost=1.05 rows=1) + -> Index scan on t1 using col1_idx (cost=0.35 rows=1) + -> Hash + -> Nested loop inner join (cost=0.70 rows=1) + -> Filter: ((t3.col2 between 2 and 9) and (t3.col1 is not null)) (cost=0.35 rows=1) + -> Table scan on t3 (cost=0.35 rows=1) + -> Filter: (t2.col2 = t3.col2) (cost=0.35 rows=1) + -> Single-row index lookup on t2 using ix1 (col1=t3.col1) (cost=0.35 rows=1) + +Warnings: +Note 1276 Field or reference 'test.t1.col1' of SELECT #2 was resolved in SELECT #1 +DROP TABLE t1, t2, t3; +# +# Bug#30659623 ASSERT IN SQL/ITEM_SUBSELECT.CC:3571: SUBSELECT_HASH_SJ_ENGINE::EXEC() +# +CREATE TABLE t1 (col_int_key INT); +INSERT INTO t1 VALUES (NULL); +CREATE TABLE t2 ( +col_int_key INT, col_int_unique INT, +UNIQUE KEY (col_int_unique), KEY (col_int_key) +); +INSERT INTO t2 VALUES (26,14),(3,46),(45,2),(18,30),(11,22),(19,8),(41,3),(1,5), +(1,9),(38,4),(13,38),(32,12),(11,7),(2,26),(5,10),(16,45); +CREATE TABLE t3 (pk INT NOT NULL PRIMARY KEY); +ANALYZE TABLE t1,t2,t3; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +explain format = tree SELECT * +FROM t1 +LEFT JOIN t2 ON t1.col_int_key = t2.col_int_key +JOIN t3 ON t1.col_int_key = t3.pk +WHERE t3.pk+6 NOT IN ( +SELECT /*+ subquery(materialization) */ +table1s.col_int_unique AS field4 FROM t2 AS table1s); +EXPLAIN +-> Nested loop left join (cost=1.10 rows=1) + -> Nested loop inner join (cost=0.70 rows=1) + -> Filter: (((t1.col_int_key + 6),(t1.col_int_key + 6) in (select #2) is false) and (t1.col_int_key is not null)) (cost=0.35 rows=1) + -> Table scan on t1 (cost=0.35 rows=1) + -> Select #2 (subquery in condition; run only once) + -> Filter: (((t1.col_int_key + 6) = ``.field4)) + -> Limit: 1 row(s) + -> Index lookup on using (field4=(t1.col_int_key + 6)) + -> Materialize with deduplication (cost=3.45..3.45 rows=16) + -> Index scan on table1s using col_int_unique (cost=1.85 rows=16) + -> Single-row index lookup on t3 using PRIMARY (pk=t1.col_int_key) (cost=0.35 rows=1) + -> Index lookup on t2 using col_int_key (col_int_key=t1.col_int_key) (cost=0.40 rows=1) + +SELECT * +FROM t1 +LEFT JOIN t2 ON t1.col_int_key = t2.col_int_key +JOIN t3 ON t1.col_int_key = t3.pk +WHERE t3.pk+6 NOT IN ( +SELECT /*+ subquery(materialization) */ +table1s.col_int_unique AS field4 FROM t2 AS table1s); +col_int_key col_int_key col_int_unique pk +DROP TABLE t1,t2,t3; +# Bug#30837240 Assertion 'item->is_bool_func()' failed +CREATE TABLE t1 ( +col_datetime datetime DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_char char(1) DEFAULT NULL, +col_char_key char(1) DEFAULT NULL, +col_tinyint tinyint DEFAULT NULL, +col_tinyint_key tinyint DEFAULT NULL +); +CREATE TABLE t2 ( +col_real_key double DEFAULT NULL, +col_mediumint mediumint DEFAULT NULL +); +CREATE TABLE t3 ( +col_varchar varchar(1) DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL +); +explain SELECT COUNT(table1.col_datetime) AS field1 +FROM t1 AS table1 RIGHT JOIN t1 AS table2 +ON table1.col_varchar_key = table2.col_char +WHERE table1.col_char_key IN +(SELECT sq2_t1.col_real_key +FROM t2 AS sq2_t1 JOIN +t3 AS sq2_t2 JOIN t1 AS sq2_t3 +ON INSTR(sq2_t3.col_tinyint, 'K') = sq2_t2.col_varchar +ON sq2_t3.col_varchar_key = sq2_t2.col_varchar_key +WHERE sq2_t1.col_mediumint IN +(SELECT sq1_t1.col_varchar_key +FROM t1 AS sq1_t1 JOIN t1 AS sq1_t2 +ON sq1_t2.col_tinyint_key = table1.col_tinyint_key +) +) OR +RTRIM(table1.col_tinyint_key) IS NOT NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY table2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 PRIMARY table1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +2 DEPENDENT SUBQUERY sq2_t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 DEPENDENT SUBQUERY sq2_t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY sq2_t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +2 DEPENDENT SUBQUERY sq1_t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 DEPENDENT SUBQUERY sq1_t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(sq2_t3) +Warnings: +Note 1276 Field or reference 'test.table1.col_tinyint_key' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select count(`test`.`table1`.`col_datetime`) AS `field1` from `test`.`t1` `table2` join `test`.`t1` `table1` where (((`test`.`table1`.`col_char_key`,(/* select#2 */ select `test`.`sq2_t1`.`col_real_key` from `test`.`t2` `sq2_t1` join `test`.`t3` `sq2_t2` join `test`.`t1` `sq2_t3` semi join (`test`.`t1` `sq1_t1` join `test`.`t1` `sq1_t2`) where ((`test`.`sq2_t3`.`col_varchar_key` = `test`.`sq2_t2`.`col_varchar_key`) and ((`test`.`table1`.`col_char_key`) = `test`.`sq2_t1`.`col_real_key`) and (cast(`test`.`sq2_t1`.`col_mediumint` as double) = cast(`test`.`sq1_t1`.`col_varchar_key` as double)) and (`test`.`table1`.`col_tinyint_key` = `test`.`sq1_t2`.`col_tinyint_key`) and (cast(locate('K',`test`.`sq2_t3`.`col_tinyint`) as double) = cast(`test`.`sq2_t2`.`col_varchar` as double))))) or (rtrim(`test`.`table1`.`col_tinyint_key`) is not null)) and (`test`.`table1`.`col_varchar_key` = `test`.`table2`.`col_char`)) +SELECT COUNT(table1.col_datetime) AS field1 +FROM t1 AS table1 RIGHT JOIN t1 AS table2 +ON table1.col_varchar_key = table2.col_char +WHERE table1.col_char_key IN +(SELECT sq2_t1.col_real_key +FROM t2 AS sq2_t1 JOIN +t3 AS sq2_t2 JOIN t1 AS sq2_t3 +ON INSTR(sq2_t3.col_tinyint, 'K') = sq2_t2.col_varchar +ON sq2_t3.col_varchar_key = sq2_t2.col_varchar_key +WHERE sq2_t1.col_mediumint IN +(SELECT sq1_t1.col_varchar_key +FROM t1 AS sq1_t1 JOIN t1 AS sq1_t2 +ON sq1_t2.col_tinyint_key = table1.col_tinyint_key +) +) OR +RTRIM(table1.col_tinyint_key) IS NOT NULL; +field1 +0 +DROP TABLE t1, t2, t3; +# +# Bug #30912972 ASSERTION KEYLEN == M_START_KEY.LENGTH FAILED|PARTITION_HANDLER.CC +# +CREATE TABLE t1 ( +col_int_key bigint DEFAULT NULL, +KEY(col_int_key) +) PARTITION BY KEY(col_int_key) PARTITIONS 10; +INSERT INTO t1 VALUES +(NULL); +SELECT 42 +WHERE 11 NOT IN +(SELECT col_int_key FROM t1); +42 +DROP TABLE t1; +# Bug#30753397 ASSERTION `!TR->DERIVED_WHERE_COND || TR->DERIVED_WHERE_COND->FIXED' FAILED. +# +CREATE TABLE t(a INT); +SELECT 1= +( +SELECT 1 FROM +( +SELECT 1 FROM t +LEFT JOIN +( +SELECT 1 FROM t +WHERE NOT EXISTS +( +SELECT 1 FROM t WINDOW w1 AS (PARTITION BY a) +) +) AS x +ON 1 > 2 +) AS z +); +1= +( +SELECT 1 FROM +( +SELECT 1 FROM t +LEFT JOIN +( +SELECT 1 FROM t +WHERE NOT EXISTS +( +SELECT 1 FROM t WINDOW w1 AS (PARTITION BY a) +) +) AS x +ON 1 > 2 +) AS z +) +NULL +DROP TABLE t; +# Bug#30899681 Mysqld got signal 11 at Item::walk() +CREATE TABLE t1 ( +col_varchar varchar(1), +col_varchar_key varchar (1), +key (col_varchar_key) +); +CREATE TABLE t2 ( +col_varchar varchar(1), +col_int_key int, +key (col_int_key) +); +INSERT INTO t2 VALUES ('t', 2); +CREATE TABLE t3 ( +pk integer auto_increment, +col_int int, +col_varchar_key varchar(1), +primary key (pk), +key (col_varchar_key) +); +INSERT INTO t3 (col_int, col_varchar_key) VALUES +(2, 'e'), (NULL, 'n'), (2, NULL), (0, 'a'), (NULL, 'd'), (1, 's'), +(NULL, 'v'), (7, 'l'), (118, NULL), (NULL, 'l'), (8, 'c'), (4, 'a'), +(8, 'r'), (1, 'q'), (3, 'o'), (NULL, 'q'), (2, 'j'), (6, 'f'), +(5, 'e'), (7, 'p'); +CREATE TABLE t4 ( +col_int_key int, +col_varchar varchar(1), +key (col_int_key) +); +INSERT INTO t4 VALUES +(5, 'k'), (5, 'g'), (5, 'k'), (1, 'e'), (9, 'b'), (NULL, 'b'), +(141, 'w'), (0, 'i'), (240, 'x'), (1, 'h'), (NULL, 'p'), (201, 'v'), +(5, 'e'), (NULL, 'e'), (2, 'a'), (3, 'r'), (NULL, 'f'), (8, 's'), +(7, 'k'), (6, 'k'); +CREATE TABLE t5 ( +col_int int, +col_varchar_key varchar(1), +pk integer auto_increment, +primary key(pk) +); +INSERT INTO t5 (col_int, col_varchar_key) VALUES +(9, 'g'), (8, 'c'), (2, 'k'), (3, 'g'), (NULL, 'm'), (2, 'c'), +(1, 'o'), (NULL, 'r'), (0, 'u'), (7, 'z'), (4, 'd'), (1, 'q'), +(3, 't'), (NULL, 'x'), (1, 'g'), (8, 'e'), (2, 'f'), (9, NULL), +(229, 't'), (2, 'i'), (127, 'x'), (75, 'u'), (4, 'r'), (4, 'y'), +(NULL, 'y'), (7, 'n'), (8, 'h'), (0, 'e'), (9, 'h'), (4, 'v'), +(4, 'o'), (0, 'w'), (9, NULL), (7, NULL), (7, 'd'), (74, 's'), +(1, 'j'), (9, 'k'), (5, 'g'), (3, 'o'), (5, 'b'), (1, 'l'), +(3, 'u'), (0, 'v'), (7, 'y'), (9, 'g'), (6, 'i'), (9, 'f'), +(3, 'u'), (4, 'q'), (NULL, NULL), (0, 'k'), (NULL, 'l'), (2, 'q'), +(7, 'r'), (5, 't'), (2, 'h'), (2, NULL), (NULL, 'z'), (7, 'c'), +(NULL, 'd'), (242, 'h'), (7, 'e'), (5, 'e'), (7, 's'), (9, 'u'), +(250, 'z'), (9, 'n'), (7, 'j'), (3, 's'), (8, 'e'), (6, NULL), +(NULL, 'i'), (1, 'n'), (3, 'k'), (7, 'n'), (1, 'w'), (8, 'x'), +(1, 'b'), (9, NULL), (4, 'o'), (3, 'i'), (9, 'n'), (91, 'c'), +(5, 'j'), (8, 'g'), (7, 'c'), (9, NULL), (8, 'd'), (NULL, 'h'), +(4, 'k'), (1, 'r'), (33, 'k'), (8, 'n'), (4, 'h'), (2, 'q'), +(9, 'p'), (1, NULL), (8, 'n'), (0, 'j'); +SET @var1 = 'h', @var2 = 66 ; +PREPARE ps FROM ' +SELECT (SELECT SUM(sq1_t1.col_int) AS sq1_field1 + FROM t3 AS sq1_t1 INNER JOIN t1 AS sq1_t2 + ON sq1_t2.col_varchar_key = sq1_t1.col_varchar_key + WHERE sq1_t2.col_varchar < sq1_t2.col_varchar OR + sq1_t2.col_varchar <> ? + ) AS field1 +FROM t5 AS table1 LEFT OUTER JOIN t4 AS table2 + ON table2.col_int_key = table1.col_int +WHERE table1.pk > ANY + (SELECT sq2_t1.pk AS sq2_field1 + FROM t3 AS sq2_t1 STRAIGHT_JOIN t2 AS sq2_t2 + ON sq2_t2.col_int_key = sq2_t1.pk + WHERE sq2_t2.col_varchar >= table2.col_varchar AND + sq2_t2.col_varchar <= table1.col_varchar_key + ) AND + table1.pk = ?'; +EXECUTE ps USING @var1, @var2; +field1 +NULL +EXECUTE ps USING @var1, @var2; +field1 +NULL +DROP TABLE t1, t2, t3, t4, t5; +Bug#31119132 Semijoin with condition of type column=constant breaks +if different character sets +CREATE TABLE t1( +pk INTEGER, +col_int INTEGER, +col_varchar VARCHAR(1), +col_int_key INTEGER, +col_datetime_key DATETIME, +col_varchar_key VARCHAR(1) +) DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci; +CREATE PROCEDURE p1() LANGUAGE SQL +SELECT DISTINCT MIN(outr.col_varchar) AS x +FROM t1 AS outr2 LEFT JOIN t1 AS outr +ON outr2.col_int_key <> outr.pk +WHERE outr.col_int IN +(SELECT innr.col_int_key AS y +FROM t1 AS innr +WHERE outr.col_varchar_key = 'z') AND +outr.col_datetime_key = '2003-12-04' +ORDER BY outr.pk, outr.pk; +CALL p1; +x +NULL +CALL p1; +x +NULL +DROP PROCEDURE p1; +DROP TABLE t1; +# +# Bug#31359965 ASSERTION `!TABLE || (!TABLE->READ_SET || BITMAP_IS_SET(TABLE->READ_SET, FIELD_INDEX))' FAILED. IN FIELD_NEW_DECIMAL::VAL_DECIMAL +# +CREATE TABLE t (a DECIMAL(61,14),KEY(a)); +INSERT INTO t VALUES(0),(-1); +SELECT +( +SELECT 1 FROM +( +SELECT a FROM (SELECT 1) u +) z +) +FROM t GROUP BY 1; +( +SELECT 1 FROM +( +SELECT a FROM (SELECT 1) u +) z +) +1 +DROP TABLE t; +# +# Bug #31530529: SERVER CRASH SEEN - (MY_PRINT_STACKTRACE(UNSIGNED CHAR CONST*, UNSIGNED LONG) +# +CREATE TABLE t1 ( +pk INTEGER NOT NULL, +a VARCHAR(1), +PRIMARY KEY (pk) +); +INSERT INTO t1 VALUES (3,'N'); +INSERT INTO t1 VALUES (4,'e'); +INSERT INTO t1 VALUES (5,'7'); +INSERT INTO t1 VALUES (6,'7'); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +SELECT * FROM t1 AS table1, t1 AS table2 +WHERE table1.pk = 6 +HAVING table1.a IN (SELECT a FROM t1); +pk a pk a +6 7 3 N +6 7 4 e +6 7 5 7 +6 7 6 7 +DROP TABLE t1; +# Bug#20794575: Assertion failed: bit < map->n_bits +SET optimizer_switch="semijoin=off"; +CREATE TABLE t1(a INTEGER, b INTEGER); +CREATE TABLE t2(c INTEGER); +SELECT b FROM t1 HAVING 1 IN +(SELECT b FROM t2 WHERE c = 1); +b +SET optimizer_switch=DEFAULT; +DROP TABLE t1, t2; +# Bug#30753397: Assertion `!tr->derived_where_cond || tr->derived_where_cond->fixed' failed +CREATE TABLE t(a INTEGER); +INSERT INTO t VALUES(1),(2),(3); +SELECT 1 = (SELECT 1 +FROM (SELECT 1 +FROM t LEFT JOIN +(SELECT 1 +FROM t +WHERE NOT EXISTS (SELECT 1 +FROM t +WINDOW w1 AS(PARTITION BY a) +) +) AS x +ON 1 > 2 +) AS z +); +ERROR 21000: Subquery returns more than 1 row +DROP TABLE t; +# +# Bug #31559978: REGRESSION: HEAP BUFFER OVERFLOW & ASSERTION FAILURE: ROW0SEL.CC:5574:PREBUILT->CAN_PREFETCH_RECORDS() || RECORD_BUFFER == NULLPTR +# +CREATE TABLE t1 ( +a INTEGER, +d VARCHAR(255) NOT NULL, +PRIMARY KEY (d) +); +INSERT INTO t1 VALUES (1,'1'), (2,'2'); +EXPLAIN FORMAT=tree SELECT 1 FROM t1 WHERE d IN (SELECT a FROM t1); +EXPLAIN +-> Remove duplicate t1 rows using temporary table (weedout) (cost=1.10 rows=2) + -> Inner hash join (cast(t1.d as double) = cast(t1.a as double)) (cost=1.10 rows=2) + -> Index scan on t1 using PRIMARY (cost=0.35 rows=2) + -> Hash + -> Table scan on t1 (cost=0.45 rows=2) + +Warnings: +Warning 1739 Cannot use ref access on index 'PRIMARY' due to type or collation conversion on field 'd' +Warning 1739 Cannot use range access on index 'PRIMARY' due to type or collation conversion on field 'd' +SELECT 1 FROM t1 WHERE d IN (SELECT a FROM t1); +1 +1 +1 +DROP TABLE t1; +# +# Bug#31096309 - 8.0.16+ DIFFERENT RESULTSET THAN 5.7 AND <=8.0.15 +# +CREATE TABLE t1 (c1 int, c2 char(10)); +INSERT INTO t1 VALUES (1, 'name1'); +INSERT INTO t1 VALUES (2, 'name2'); +SET optimizer_switch='semijoin=on'; +explain format = tree SELECT a.c2 FROM t1 AS a WHERE +EXISTS (SELECT 1 FROM t1 AS b WHERE b.c2 = a.c2 LIMIT 1,1); +EXPLAIN +-> Filter: exists(select #2) (cost=0.45 rows=2) + -> Table scan on a (cost=0.45 rows=2) + -> Select #2 (subquery in condition; dependent) + -> Limit/Offset: 1/1 row(s) (cost=0.35 rows=0) + -> Filter: (b.c2 = a.c2) (cost=0.35 rows=1) + -> Table scan on b (cost=0.35 rows=2) + +Warnings: +Note 1276 Field or reference 'test.a.c2' of SELECT #2 was resolved in SELECT #1 +SELECT a.c2 FROM t1 AS a WHERE +EXISTS (SELECT 1 FROM t1 AS b WHERE b.c2 = a.c2 LIMIT 1,1); +c2 +explain format=tree SELECT a.c2 FROM t1 AS a WHERE +EXISTS (SELECT 1 FROM t1 AS b WHERE b.c2 = a.c2 LIMIT 0,1); +EXPLAIN +-> Parallel scan on + -> Hash semijoin (b.c2 = a.c2) (cost=0.83 rows=2) + -> PQblock scan on a (cost=0.45 rows=2) + -> Hash + -> Table scan on b (cost=0.18 rows=2) + +Warnings: +Note 1276 Field or reference 'test.a.c2' of SELECT #2 was resolved in SELECT #1 +SELECT a.c2 FROM t1 AS a WHERE +EXISTS (SELECT 1 FROM t1 AS b WHERE b.c2 = a.c2 LIMIT 0,1); +c2 +name1 +name2 +SET @offset_value=0; +PREPARE explain_stmt FROM "EXPLAIN format = tree SELECT a.c2 FROM t1 AS a WHERE +EXISTS (SELECT 1 FROM t1 AS b WHERE b.c2 = a.c2 LIMIT ?,1)"; +Warnings: +Note 1276 Field or reference 'test.a.c2' of SELECT #2 was resolved in SELECT #1 +EXECUTE explain_stmt USING @offset_value; +EXPLAIN +-> Filter: exists(select #2) (cost=0.45 rows=2) + -> Table scan on a (cost=0.45 rows=2) + -> Select #2 (subquery in condition; dependent) + -> Limit: 1 row(s) (cost=0.35 rows=1) + -> Filter: (b.c2 = a.c2) (cost=0.35 rows=1) + -> Table scan on b (cost=0.35 rows=2) + +PREPARE stmt FROM "SELECT a.c2 FROM t1 AS a WHERE +EXISTS (SELECT 1 FROM t1 AS b WHERE b.c2 = a.c2 LIMIT ?,1)"; +EXECUTE stmt USING @offset_value; +c2 +name1 +name2 +explain format = tree SELECT a.c2 FROM t1 AS a WHERE +EXISTS (SELECT 1 FROM t1 AS b WHERE b.c2 = a.c2 LIMIT 0,0); +EXPLAIN +-> Filter: exists(select #2) (cost=0.45 rows=2) + -> Table scan on a (cost=0.45 rows=2) + -> Select #2 (subquery in condition; dependent) + -> Zero rows (Zero limit) (cost=0.00..0.00 rows=0) + +Warnings: +Note 1276 Field or reference 'test.a.c2' of SELECT #2 was resolved in SELECT #1 +SELECT a.c2 FROM t1 AS a WHERE +EXISTS (SELECT 1 FROM t1 AS b WHERE b.c2 = a.c2 LIMIT 0,0); +c2 +DROP TABLE t1; +SET optimizer_switch=default; +# +# Bug #31586937: REGRESSION: CRASH IN FILESORT::MAKE_SORTORDER +# +CREATE TABLE t1 (a INTEGER); +CREATE TABLE t2 (b INTEGER); +SELECT ( SELECT b FROM t2 ORDER BY a, MIN(a) LIMIT 1 ) FROM t1 GROUP BY a; +( SELECT b FROM t2 ORDER BY a, MIN(a) LIMIT 1 ) +DROP TABLE t1, t2; diff --git a/mysql-test/r/subquery_exists.result-pq b/mysql-test/r/subquery_exists.result-pq new file mode 100644 index 000000000000..23d69fe2b22f --- /dev/null +++ b/mysql-test/r/subquery_exists.result-pq @@ -0,0 +1,541 @@ +CREATE TABLE t1( +pk INTEGER PRIMARY KEY, +uk INTEGER UNIQUE, +ukn INTEGER UNIQUE NOT NULL, +ik INTEGER, +d INTEGER, +INDEX ik(ik)); +INSERT INTO t1 VALUES +(0, NULL, 0, NULL, NULL), +(1, 10, 20, 30, 40), +(2, 20, 40, 60, 80); +CREATE TABLE t2( +pk INTEGER PRIMARY KEY); +INSERT INTO t2 VALUES +(1), (2), (3), (4), (5), (6), (7), (8), (9),(10), +(11),(12),(13),(14),(15),(16),(17),(18),(19),(20), +(21),(22),(23),(24),(25),(26),(27),(28),(29),(30), +(31),(32),(33),(34),(35),(36),(37),(38),(39),(40), +(41),(42),(43),(44),(45),(46),(47),(48),(49),(50), +(51),(52),(53),(54),(55),(56),(57),(58),(59),(60), +(61),(62),(63),(64),(65),(66),(67),(68),(69),(70), +(71),(72),(73),(74),(75),(76),(77),(78),(79),(80); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN SELECT 1 FROM dual +WHERE EXISTS (SELECT * FROM t1 AS it); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +2 SUBQUERY it NULL index NULL ukn 4 NULL 3 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from DUAL where true +SELECT 1 FROM dual +WHERE EXISTS (SELECT * FROM t1 AS it); +1 +1 +EXPLAIN SELECT * FROM t1 AS ot +WHERE EXISTS (SELECT 1 FROM dual); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY ot NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 /* select#1 */ select `test`.`ot`.`pk` AS `pk`,`test`.`ot`.`uk` AS `uk`,`test`.`ot`.`ukn` AS `ukn`,`test`.`ot`.`ik` AS `ik`,`test`.`ot`.`d` AS `d` from `test`.`t1` `ot` where true +SELECT * FROM t1 AS ot +WHERE EXISTS (SELECT 1 FROM dual); +pk uk ukn ik d +0 NULL 0 NULL NULL +1 10 20 30 40 +2 20 40 60 80 +EXPLAIN SELECT * FROM t1 AS ot +WHERE EXISTS (SELECT 1 FROM dual WHERE FALSE); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`ot`.`pk` AS `pk`,`test`.`ot`.`uk` AS `uk`,`test`.`ot`.`ukn` AS `ukn`,`test`.`ot`.`ik` AS `ik`,`test`.`ot`.`d` AS `d` from `test`.`t1` `ot` where false +SELECT * FROM t1 AS ot +WHERE EXISTS (SELECT 1 FROM dual WHERE FALSE); +pk uk ukn ik d +EXPLAIN SELECT * FROM t1 AS ot +WHERE EXISTS (SELECT * FROM t1 AS it); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE it NULL index NULL ukn 4 NULL 3 100.00 Using index; FirstMatch +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot`.`pk` AS `pk`,`test`.`ot`.`uk` AS `uk`,`test`.`ot`.`ukn` AS `ukn`,`test`.`ot`.`ik` AS `ik`,`test`.`ot`.`d` AS `d` from `test`.`t1` `ot` semi join (`test`.`t1` `it`) where true +SELECT * FROM t1 AS ot +WHERE EXISTS (SELECT * FROM t1 AS it); +pk uk ukn ik d +0 NULL 0 NULL NULL +1 10 20 30 40 +2 20 40 60 80 +EXPLAIN SELECT * FROM t1 AS ot +WHERE EXISTS (SELECT * FROM t1 AS it WHERE it.pk = 1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE it NULL const PRIMARY PRIMARY 4 const 1 100.00 Using index +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE it NULL const PRIMARY PRIMARY 4 const 1 100.00 Using index +2 SIMPLE ot NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot`.`pk` AS `pk`,`test`.`ot`.`uk` AS `uk`,`test`.`ot`.`ukn` AS `ukn`,`test`.`ot`.`ik` AS `ik`,`test`.`ot`.`d` AS `d` from `test`.`t1` `it` join `test`.`t1` `ot` where true +SELECT * FROM t1 AS ot +WHERE EXISTS (SELECT * FROM t1 AS it WHERE it.pk = 1); +pk uk ukn ik d +0 NULL 0 NULL NULL +1 10 20 30 40 +2 20 40 60 80 +EXPLAIN SELECT * FROM t1 AS ot +WHERE EXISTS (SELECT * FROM t1 AS it WHERE it.uk = 1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`ot`.`pk` AS `pk`,`test`.`ot`.`uk` AS `uk`,`test`.`ot`.`ukn` AS `ukn`,`test`.`ot`.`ik` AS `ik`,`test`.`ot`.`d` AS `d` from `test`.`t1` `it` join `test`.`t1` `ot` where multiple equal(1, NULL) +SELECT * FROM t1 AS ot +WHERE EXISTS (SELECT * FROM t1 AS it WHERE it.uk = 1); +pk uk ukn ik d +EXPLAIN SELECT * FROM t1 AS ot +WHERE EXISTS (SELECT * FROM t1 AS it WHERE it.ukn = 1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`ot`.`pk` AS `pk`,`test`.`ot`.`uk` AS `uk`,`test`.`ot`.`ukn` AS `ukn`,`test`.`ot`.`ik` AS `ik`,`test`.`ot`.`d` AS `d` from `test`.`t1` `it` join `test`.`t1` `ot` where multiple equal(1, NULL) +SELECT * FROM t1 AS ot +WHERE EXISTS (SELECT * FROM t1 AS it WHERE it.ukn = 1); +pk uk ukn ik d +EXPLAIN SELECT * FROM t1 AS ot +WHERE EXISTS (SELECT * FROM t1 AS it WHERE it.ik = 1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE it NULL ref ik ik 5 const 1 100.00 Using index; FirstMatch +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot`.`pk` AS `pk`,`test`.`ot`.`uk` AS `uk`,`test`.`ot`.`ukn` AS `ukn`,`test`.`ot`.`ik` AS `ik`,`test`.`ot`.`d` AS `d` from `test`.`t1` `ot` semi join (`test`.`t1` `it`) where (`test`.`it`.`ik` = 1) +SELECT * FROM t1 AS ot +WHERE EXISTS (SELECT * FROM t1 AS it WHERE it.ik = 1); +pk uk ukn ik d +EXPLAIN SELECT * FROM t1 AS ot +WHERE EXISTS (SELECT * FROM t1 AS it WHERE it.d = 1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE it NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot`.`pk` AS `pk`,`test`.`ot`.`uk` AS `uk`,`test`.`ot`.`ukn` AS `ukn`,`test`.`ot`.`ik` AS `ik`,`test`.`ot`.`d` AS `d` from `test`.`t1` `ot` semi join (`test`.`t1` `it`) where (`test`.`it`.`d` = 1) +SELECT * FROM t1 AS ot +WHERE EXISTS (SELECT * FROM t1 AS it WHERE it.d = 1); +pk uk ukn ik d +EXPLAIN SELECT * FROM t1 AS ot +WHERE EXISTS (SELECT * FROM t1 AS it WHERE it.pk = ot.pk); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE ot NULL ALL PRIMARY NULL NULL NULL 3 100.00 NULL +2 SIMPLE it NULL eq_ref PRIMARY PRIMARY 4 test.ot.pk 1 100.00 Using index +Warnings: +Note 1276 Field or reference 'test.ot.pk' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`ot`.`pk` AS `pk`,`test`.`ot`.`uk` AS `uk`,`test`.`ot`.`ukn` AS `ukn`,`test`.`ot`.`ik` AS `ik`,`test`.`ot`.`d` AS `d` from `test`.`t1` `it` join `test`.`t1` `ot` where (`test`.`it`.`pk` = `test`.`ot`.`pk`) +SELECT * FROM t1 AS ot +WHERE EXISTS (SELECT * FROM t1 AS it WHERE it.pk = ot.pk); +pk uk ukn ik d +0 NULL 0 NULL NULL +1 10 20 30 40 +2 20 40 60 80 +EXPLAIN SELECT * FROM t1 AS ot +WHERE EXISTS (SELECT * FROM t1 AS it WHERE it.uk = ot.uk); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE ot NULL ALL uk NULL NULL NULL 3 100.00 Using where +2 SIMPLE it NULL eq_ref uk uk 5 test.ot.uk 1 100.00 Using index +Warnings: +Note 1276 Field or reference 'test.ot.uk' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`ot`.`pk` AS `pk`,`test`.`ot`.`uk` AS `uk`,`test`.`ot`.`ukn` AS `ukn`,`test`.`ot`.`ik` AS `ik`,`test`.`ot`.`d` AS `d` from `test`.`t1` `it` join `test`.`t1` `ot` where (`test`.`it`.`uk` = `test`.`ot`.`uk`) +SELECT * FROM t1 AS ot +WHERE EXISTS (SELECT * FROM t1 AS it WHERE it.uk = ot.uk); +pk uk ukn ik d +1 10 20 30 40 +2 20 40 60 80 +EXPLAIN SELECT * FROM t1 AS ot +WHERE EXISTS (SELECT * FROM t1 AS it WHERE it.ukn = ot.ukn); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE ot NULL ALL ukn NULL NULL NULL 3 100.00 NULL +2 SIMPLE it NULL eq_ref ukn ukn 4 test.ot.ukn 1 100.00 Using index +Warnings: +Note 1276 Field or reference 'test.ot.ukn' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`ot`.`pk` AS `pk`,`test`.`ot`.`uk` AS `uk`,`test`.`ot`.`ukn` AS `ukn`,`test`.`ot`.`ik` AS `ik`,`test`.`ot`.`d` AS `d` from `test`.`t1` `it` join `test`.`t1` `ot` where (`test`.`it`.`ukn` = `test`.`ot`.`ukn`) +SELECT * FROM t1 AS ot +WHERE EXISTS (SELECT * FROM t1 AS it WHERE it.ukn = ot.ukn); +pk uk ukn ik d +0 NULL 0 NULL NULL +1 10 20 30 40 +2 20 40 60 80 +EXPLAIN SELECT * FROM t1 AS ot +WHERE EXISTS (SELECT * FROM t1 AS it WHERE it.ik = ot.ik); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE ot NULL ALL ik NULL NULL NULL 3 100.00 Using where +2 SIMPLE it NULL ref ik ik 5 test.ot.ik 1 100.00 Using index; FirstMatch(ot) +Warnings: +Note 1276 Field or reference 'test.ot.ik' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`ot`.`pk` AS `pk`,`test`.`ot`.`uk` AS `uk`,`test`.`ot`.`ukn` AS `ukn`,`test`.`ot`.`ik` AS `ik`,`test`.`ot`.`d` AS `d` from `test`.`t1` `ot` semi join (`test`.`t1` `it`) where (`test`.`it`.`ik` = `test`.`ot`.`ik`) +SELECT * FROM t1 AS ot +WHERE EXISTS (SELECT * FROM t1 AS it WHERE it.ik = ot.ik); +pk uk ukn ik d +1 10 20 30 40 +2 20 40 60 80 +EXPLAIN SELECT * FROM t1 AS ot +WHERE EXISTS (SELECT * FROM t1 AS it WHERE it.d = ot.d); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE ot NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 SIMPLE it NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(ot); Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.ot.d' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`ot`.`pk` AS `pk`,`test`.`ot`.`uk` AS `uk`,`test`.`ot`.`ukn` AS `ukn`,`test`.`ot`.`ik` AS `ik`,`test`.`ot`.`d` AS `d` from `test`.`t1` `ot` semi join (`test`.`t1` `it`) where (`test`.`it`.`d` = `test`.`ot`.`d`) +SELECT * FROM t1 AS ot +WHERE EXISTS (SELECT * FROM t1 AS it WHERE it.d = ot.d); +pk uk ukn ik d +1 10 20 30 40 +2 20 40 60 80 +EXPLAIN SELECT * FROM t1 AS ot +WHERE EXISTS (SELECT * FROM t1 AS it WHERE it.pk > ot.pk); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE ot NULL ALL PRIMARY NULL NULL NULL 3 100.00 NULL +2 SIMPLE it NULL ALL PRIMARY NULL NULL NULL 3 33.33 Range checked for each record (index map: 0x1); FirstMatch(ot) +Warnings: +Note 1276 Field or reference 'test.ot.pk' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`ot`.`pk` AS `pk`,`test`.`ot`.`uk` AS `uk`,`test`.`ot`.`ukn` AS `ukn`,`test`.`ot`.`ik` AS `ik`,`test`.`ot`.`d` AS `d` from `test`.`t1` `ot` semi join (`test`.`t1` `it`) where (`test`.`it`.`pk` > `test`.`ot`.`pk`) +SELECT * FROM t1 AS ot +WHERE EXISTS (SELECT * FROM t1 AS it WHERE it.pk > ot.pk); +pk uk ukn ik d +0 NULL 0 NULL NULL +1 10 20 30 40 +EXPLAIN SELECT * FROM t1 AS ot +WHERE EXISTS (SELECT * FROM t1 AS it WHERE it.uk > ot.uk); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE ot NULL ALL uk NULL NULL NULL 3 100.00 NULL +2 SIMPLE it NULL ALL uk NULL NULL NULL 3 33.33 Range checked for each record (index map: 0x4); FirstMatch(ot) +Warnings: +Note 1276 Field or reference 'test.ot.uk' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`ot`.`pk` AS `pk`,`test`.`ot`.`uk` AS `uk`,`test`.`ot`.`ukn` AS `ukn`,`test`.`ot`.`ik` AS `ik`,`test`.`ot`.`d` AS `d` from `test`.`t1` `ot` semi join (`test`.`t1` `it`) where (`test`.`it`.`uk` > `test`.`ot`.`uk`) +SELECT * FROM t1 AS ot +WHERE EXISTS (SELECT * FROM t1 AS it WHERE it.uk > ot.uk); +pk uk ukn ik d +1 10 20 30 40 +EXPLAIN SELECT * FROM t1 AS ot +WHERE EXISTS (SELECT * FROM t1 AS it WHERE it.ukn > ot.ukn); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE ot NULL ALL ukn NULL NULL NULL 3 100.00 NULL +2 SIMPLE it NULL ALL ukn NULL NULL NULL 3 33.33 Range checked for each record (index map: 0x2); FirstMatch(ot) +Warnings: +Note 1276 Field or reference 'test.ot.ukn' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`ot`.`pk` AS `pk`,`test`.`ot`.`uk` AS `uk`,`test`.`ot`.`ukn` AS `ukn`,`test`.`ot`.`ik` AS `ik`,`test`.`ot`.`d` AS `d` from `test`.`t1` `ot` semi join (`test`.`t1` `it`) where (`test`.`it`.`ukn` > `test`.`ot`.`ukn`) +SELECT * FROM t1 AS ot +WHERE EXISTS (SELECT * FROM t1 AS it WHERE it.ukn > ot.ukn); +pk uk ukn ik d +0 NULL 0 NULL NULL +1 10 20 30 40 +EXPLAIN SELECT * FROM t1 AS ot +WHERE EXISTS (SELECT * FROM t1 AS it WHERE it.ik > ot.ik); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE ot NULL ALL ik NULL NULL NULL 3 100.00 NULL +2 SIMPLE it NULL ALL ik NULL NULL NULL 3 33.33 Range checked for each record (index map: 0x8); FirstMatch(ot) +Warnings: +Note 1276 Field or reference 'test.ot.ik' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`ot`.`pk` AS `pk`,`test`.`ot`.`uk` AS `uk`,`test`.`ot`.`ukn` AS `ukn`,`test`.`ot`.`ik` AS `ik`,`test`.`ot`.`d` AS `d` from `test`.`t1` `ot` semi join (`test`.`t1` `it`) where (`test`.`it`.`ik` > `test`.`ot`.`ik`) +SELECT * FROM t1 AS ot +WHERE EXISTS (SELECT * FROM t1 AS it WHERE it.ik > ot.ik); +pk uk ukn ik d +1 10 20 30 40 +EXPLAIN SELECT * FROM t1 AS ot +WHERE EXISTS (SELECT * FROM t1 AS it WHERE it.d > ot.d); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE ot NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 SIMPLE it NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(ot); Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.ot.d' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`ot`.`pk` AS `pk`,`test`.`ot`.`uk` AS `uk`,`test`.`ot`.`ukn` AS `ukn`,`test`.`ot`.`ik` AS `ik`,`test`.`ot`.`d` AS `d` from `test`.`t1` `ot` semi join (`test`.`t1` `it`) where (`test`.`it`.`d` > `test`.`ot`.`d`) +SELECT * FROM t1 AS ot +WHERE EXISTS (SELECT * FROM t1 AS it WHERE it.d > ot.d); +pk uk ukn ik d +1 10 20 30 40 +EXPLAIN SELECT * FROM t2 AS ot +WHERE EXISTS (SELECT * FROM t1 AS it WHERE it.ik = ot.pk); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE it NULL index ik ik 5 NULL 3 100.00 Using where; Using index; LooseScan +1 SIMPLE ot NULL eq_ref PRIMARY PRIMARY 4 test.it.ik 1 100.00 Using index +Warnings: +Note 1276 Field or reference 'test.ot.pk' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`ot`.`pk` AS `pk` from `test`.`t2` `ot` semi join (`test`.`t1` `it`) where (`test`.`ot`.`pk` = `test`.`it`.`ik`) +SELECT * FROM t2 AS ot +WHERE EXISTS (SELECT * FROM t1 AS it WHERE it.ik = ot.pk); +pk +30 +60 +EXPLAIN SELECT * FROM t2 AS ot +WHERE EXISTS (SELECT * FROM t1 AS it WHERE it.pk = ot.pk); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE it NULL index PRIMARY ukn 4 NULL 3 100.00 Using index +2 SIMPLE ot NULL eq_ref PRIMARY PRIMARY 4 test.it.pk 1 100.00 Using index +Warnings: +Note 1276 Field or reference 'test.ot.pk' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`ot`.`pk` AS `pk` from `test`.`t1` `it` join `test`.`t2` `ot` where (`test`.`ot`.`pk` = `test`.`it`.`pk`) +SELECT * FROM t2 AS ot +WHERE EXISTS (SELECT * FROM t1 AS it WHERE it.pk = ot.pk); +pk +1 +2 +EXPLAIN SELECT * FROM t2 AS ot +WHERE EXISTS (SELECT * FROM t1 AS it WHERE it.uk = ot.pk); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE it NULL index uk uk 5 NULL 3 100.00 Using where; Using index +2 SIMPLE ot NULL eq_ref PRIMARY PRIMARY 4 test.it.uk 1 100.00 Using index +Warnings: +Note 1276 Field or reference 'test.ot.pk' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`ot`.`pk` AS `pk` from `test`.`t1` `it` join `test`.`t2` `ot` where (`test`.`ot`.`pk` = `test`.`it`.`uk`) +SELECT * FROM t2 AS ot +WHERE EXISTS (SELECT * FROM t1 AS it WHERE it.uk = ot.pk); +pk +10 +20 +EXPLAIN SELECT * FROM t2 AS ot +WHERE EXISTS (SELECT * FROM t1 AS it WHERE it.ukn = ot.pk); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE it NULL index ukn ukn 4 NULL 3 100.00 Using index +2 SIMPLE ot NULL eq_ref PRIMARY PRIMARY 4 test.it.ukn 1 100.00 Using index +Warnings: +Note 1276 Field or reference 'test.ot.pk' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`ot`.`pk` AS `pk` from `test`.`t1` `it` join `test`.`t2` `ot` where (`test`.`ot`.`pk` = `test`.`it`.`ukn`) +SELECT * FROM t2 AS ot +WHERE EXISTS (SELECT * FROM t1 AS it WHERE it.ukn = ot.pk); +pk +20 +40 +EXPLAIN SELECT * FROM t2 AS ot +WHERE EXISTS (SELECT * FROM t1 AS it WHERE it.d = ot.pk); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using where +1 SIMPLE ot NULL eq_ref PRIMARY PRIMARY 4 .d 1 100.00 Using index +2 MATERIALIZED it NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1276 Field or reference 'test.ot.pk' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`ot`.`pk` AS `pk` from `test`.`t2` `ot` semi join (`test`.`t1` `it`) where (`test`.`ot`.`pk` = ``.`d`) +SELECT * FROM t2 AS ot +WHERE EXISTS (SELECT * FROM t1 AS it WHERE it.d = ot.pk); +pk +40 +80 +EXPLAIN SELECT * FROM t1 AS ot +WHERE EXISTS (SELECT * FROM t2 AS it WHERE ot.d = it.pk - 1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE NULL eq_ref 8 test.ot.d 1 100.00 Using where +2 MATERIALIZED it NULL index NULL PRIMARY 4 NULL 80 100.00 Using index +Warnings: +Note 1276 Field or reference 'test.ot.d' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`ot`.`pk` AS `pk`,`test`.`ot`.`uk` AS `uk`,`test`.`ot`.`ukn` AS `ukn`,`test`.`ot`.`ik` AS `ik`,`test`.`ot`.`d` AS `d` from `test`.`t1` `ot` semi join (`test`.`t2` `it`) where (`test`.`ot`.`d` = ``.`(it.pk - 1)`) +SELECT * FROM t1 AS ot +WHERE EXISTS (SELECT * FROM t2 AS it WHERE ot.d = it.pk - 1); +pk uk ukn ik d +1 10 20 30 40 +EXPLAIN SELECT * FROM t1 AS ot +WHERE EXISTS (SELECT * FROM t1 AS it1 JOIN t2 AS it2 ON it1.pk > it2.pk +WHERE ot.d = it2.pk); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE ot NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 SIMPLE it2 NULL eq_ref PRIMARY PRIMARY 4 test.ot.d 1 100.00 Using index +2 SIMPLE it1 NULL ALL PRIMARY NULL NULL NULL 3 33.33 Range checked for each record (index map: 0x1); FirstMatch(it2) +Warnings: +Note 1276 Field or reference 'test.ot.d' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`ot`.`pk` AS `pk`,`test`.`ot`.`uk` AS `uk`,`test`.`ot`.`ukn` AS `ukn`,`test`.`ot`.`ik` AS `ik`,`test`.`ot`.`d` AS `d` from `test`.`t2` `it2` join `test`.`t1` `ot` semi join (`test`.`t1` `it1`) where ((`test`.`it2`.`pk` = `test`.`ot`.`d`) and (`test`.`it1`.`pk` > `test`.`ot`.`d`)) +SELECT * FROM t1 AS ot +WHERE EXISTS (SELECT * FROM t1 AS it1 JOIN t2 AS it2 ON it1.pk > it2.pk +WHERE ot.d = it2.pk); +pk uk ukn ik d +DROP TABLE t1, t2; +# Bug#28957660 Regression: Crash in select_lex::flatten_subqueries +CREATE TABLE t1 (a INTEGER); +explain SELECT * FROM t1 WHERE EXISTS (SELECT * FROM t1 WHERE 127 = 55); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where false +SELECT * FROM t1 WHERE EXISTS (SELECT * FROM t1 WHERE 127 = 55); +a +explain SELECT * FROM t1 +WHERE EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 FirstMatch(t1); Using join buffer (hash join) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 FirstMatch(t1); Using join buffer (hash join) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 FirstMatch(t1); Using join buffer (hash join) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 FirstMatch(t1); Using join buffer (hash join) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 FirstMatch(t1); Using join buffer (hash join) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 FirstMatch(t1); Using join buffer (hash join) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 FirstMatch(t1); Using join buffer (hash join) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 FirstMatch(t1); Using join buffer (hash join) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 FirstMatch(t1); Using join buffer (hash join) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 FirstMatch(t1); Using join buffer (hash join) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 FirstMatch(t1); Using join buffer (hash join) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 FirstMatch(t1); Using join buffer (hash join) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 FirstMatch(t1); Using join buffer (hash join) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 FirstMatch(t1); Using join buffer (hash join) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 FirstMatch(t1); Using join buffer (hash join) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 FirstMatch(t1); Using join buffer (hash join) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 FirstMatch(t1); Using join buffer (hash join) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 FirstMatch(t1); Using join buffer (hash join) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 FirstMatch(t1); Using join buffer (hash join) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 FirstMatch(t1); Using join buffer (hash join) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 FirstMatch(t1); Using join buffer (hash join) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 FirstMatch(t1); Using join buffer (hash join) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 FirstMatch(t1); Using join buffer (hash join) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 FirstMatch(t1); Using join buffer (hash join) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 FirstMatch(t1); Using join buffer (hash join) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 FirstMatch(t1); Using join buffer (hash join) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 FirstMatch(t1); Using join buffer (hash join) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 FirstMatch(t1); Using join buffer (hash join) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 FirstMatch(t1); Using join buffer (hash join) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 FirstMatch(t1); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t1`) semi join (`test`.`t1`) semi join (`test`.`t1`) semi join (`test`.`t1`) semi join (`test`.`t1`) semi join (`test`.`t1`) semi join (`test`.`t1`) semi join (`test`.`t1`) semi join (`test`.`t1`) semi join (`test`.`t1`) semi join (`test`.`t1`) semi join (`test`.`t1`) semi join (`test`.`t1`) semi join (`test`.`t1`) semi join (`test`.`t1`) semi join (`test`.`t1`) semi join (`test`.`t1`) semi join (`test`.`t1`) semi join (`test`.`t1`) semi join (`test`.`t1`) semi join (`test`.`t1`) semi join (`test`.`t1`) semi join (`test`.`t1`) semi join (`test`.`t1`) semi join (`test`.`t1`) semi join (`test`.`t1`) semi join (`test`.`t1`) semi join (`test`.`t1`) semi join (`test`.`t1`) semi join (`test`.`t1`) where true +SELECT * FROM t1 +WHERE EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1); +a +explain SELECT * FROM t1 +WHERE EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +32 SUBQUERY t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t1`) semi join (`test`.`t1`) semi join (`test`.`t1`) semi join (`test`.`t1`) semi join (`test`.`t1`) semi join (`test`.`t1`) semi join (`test`.`t1`) semi join (`test`.`t1`) semi join (`test`.`t1`) semi join (`test`.`t1`) semi join (`test`.`t1`) semi join (`test`.`t1`) semi join (`test`.`t1`) semi join (`test`.`t1`) semi join (`test`.`t1`) semi join (`test`.`t1`) semi join (`test`.`t1`) semi join (`test`.`t1`) semi join (`test`.`t1`) semi join (`test`.`t1`) semi join (`test`.`t1`) semi join (`test`.`t1`) semi join (`test`.`t1`) semi join (`test`.`t1`) semi join (`test`.`t1`) semi join (`test`.`t1`) semi join (`test`.`t1`) semi join (`test`.`t1`) semi join (`test`.`t1`) semi join (`test`.`t1`) where false +SELECT * FROM t1 +WHERE EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1); +a +DROP TABLE t1; diff --git a/mysql-test/r/subquery_mat_mixed_types.result-pq b/mysql-test/r/subquery_mat_mixed_types.result-pq new file mode 100644 index 000000000000..555a36327912 --- /dev/null +++ b/mysql-test/r/subquery_mat_mixed_types.result-pq @@ -0,0 +1,10135 @@ +# +# Bug#13960580 SUBQUERY MATERIALIZATION IS TOO RESTRICTIVE ON DATA TYPES +# +CREATE TABLE t1 (c1 INT, KEY(c1)); +CREATE TABLE t2 (c1 BIGINT, KEY(c1)); +CREATE TABLE t3 (c1 DECIMAL(10,2), KEY(c1)); +CREATE TABLE t4 (c1 FLOAT, KEY(c1)); +CREATE TABLE t5 (c1 DOUBLE, KEY(c1)); +CREATE TABLE t6 (c1 CHAR(60), KEY(c1)); +CREATE TABLE t7 (c1 VARCHAR(60), KEY(c1)); +CREATE TABLE t8 (c1 TIME, KEY(c1)); +CREATE TABLE t9 (c1 TIMESTAMP, KEY(c1)); +CREATE TABLE t10 (c1 DATE, KEY(c1)); +CREATE TABLE t11 (c1 DATETIME, KEY(c1)); +CREATE TABLE t12 (c1 CHAR(10) CHARACTER SET UTF16, KEY(c1)); +CREATE TABLE t13 (c1 BIGINT UNSIGNED, KEY(c1)); +INSERT INTO t1 VALUES (19910113), (20010514), (19930513), (19970416), (19960416), +(19950414); +INSERT INTO t2 VALUES (19930513), (19990419), (19950414), (-1), (-19950414); +INSERT INTO t3 VALUES (19930513.3), (19990519), (19950414.0), (19950414.1); +INSERT INTO t4 VALUES (19930513.3), (19990419.2), (19950414e0), (19950414.1e0); +INSERT INTO t5 VALUES (19930513.3), (19990419.2), (19950414e0), (19950414.1e0); +INSERT INTO t6 VALUES ('19910111'), ('20010513'), ('19930513'), ('19950414'), +('19950414.1'); +INSERT INTO t7 VALUES ('19910111'), ('20010513'), ('19930513'), ('19950414'), +('19950414.1'); +INSERT INTO t8 VALUES ('10:22:33'), ('12:34:56'), ('33:22:33'); +INSERT INTO t9 VALUES (20150413102233), (19990102123456); +INSERT INTO t10 VALUES ('1998-01-01'), ('2015-04-13'); +INSERT INTO t11 VALUES ('1999-08-14 01:00:00'), ('2015-04-13 10:22:33'), +('2015-04-14 09:22:33'); +INSERT INTO t12 VALUES ('19910111'), ('19930513'), ('20010513'), ('19950414') +, ('19950414.1'); +INSERT INTO t13 VALUES (19950414),(18446744073709551615); +ANALYZE TABLE t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +test.t4 analyze status OK +test.t5 analyze status OK +test.t6 analyze status OK +test.t7 analyze status OK +test.t8 analyze status OK +test.t9 analyze status OK +test.t10 analyze status OK +test.t11 analyze status OK +test.t12 analyze status OK +test.t13 analyze status OK +set optimizer_switch='semijoin=off,materialization=on,subquery_materialization_cost_based=off'; +SET TIMESTAMP=UNIX_TIMESTAMP(20150413000000); +EXPLAIN SELECT * FROM t1 STRAIGHT_JOIN t2 WHERE t1.c1=t2.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t1 STRAIGHT_JOIN t2 WHERE t1.c1=t2.c1; +c1 c1 +19930513 19930513 +19950414 19950414 +EXPLAIN SELECT * FROM t1 WHERE c1 IN (SELECT c1 FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t1 WHERE c1 IN (SELECT c1 FROM t2); +c1 +19930513 +19950414 +EXPLAIN SELECT * FROM t1 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t1 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t2); +c1 +19930513 +19950414 +EXPLAIN SELECT 1 FROM t1 WHERE (SELECT 1 FROM t1 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t2 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t1 WHERE (SELECT 1 FROM t1 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t2 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t1 STRAIGHT_JOIN t3 WHERE t1.c1=t3.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t1 STRAIGHT_JOIN t3 WHERE t1.c1=t3.c1; +c1 c1 +19950414 19950414.00 +EXPLAIN SELECT * FROM t1 WHERE c1 IN (SELECT c1 FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t1 WHERE c1 IN (SELECT c1 FROM t3); +c1 +19950414 +EXPLAIN SELECT * FROM t1 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t1 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t3); +c1 +19950414 +EXPLAIN SELECT 1 FROM t1 WHERE (SELECT 1 FROM t1 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t3 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t1 WHERE (SELECT 1 FROM t1 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t3 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t1 STRAIGHT_JOIN t4 WHERE t1.c1=t4.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t1 STRAIGHT_JOIN t4 WHERE t1.c1=t4.c1; +c1 c1 +19950414 19950400 +19950414 19950400 +EXPLAIN SELECT * FROM t1 WHERE c1 IN (SELECT c1 FROM t4); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t1 WHERE c1 IN (SELECT c1 FROM t4); +c1 +19950414 +EXPLAIN SELECT * FROM t1 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t4); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t1 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t4); +c1 +19950414 +EXPLAIN SELECT 1 FROM t1 WHERE (SELECT 1 FROM t1 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t4 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t1 WHERE (SELECT 1 FROM t1 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t4 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t1 STRAIGHT_JOIN t5 WHERE t1.c1=t5.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t1 STRAIGHT_JOIN t5 WHERE t1.c1=t5.c1; +c1 c1 +19950414 19950414 +EXPLAIN SELECT * FROM t1 WHERE c1 IN (SELECT c1 FROM t5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t1 WHERE c1 IN (SELECT c1 FROM t5); +c1 +19950414 +EXPLAIN SELECT * FROM t1 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t1 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t5); +c1 +19950414 +EXPLAIN SELECT 1 FROM t1 WHERE (SELECT 1 FROM t1 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t5 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t1 WHERE (SELECT 1 FROM t1 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t5 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t1 STRAIGHT_JOIN t6 WHERE t1.c1=t6.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t1 STRAIGHT_JOIN t6 WHERE t1.c1=t6.c1; +c1 c1 +19930513 19930513 +19950414 19950414 +EXPLAIN SELECT * FROM t1 WHERE c1 IN (SELECT c1 FROM t6); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t1 WHERE c1 IN (SELECT c1 FROM t6); +c1 +19930513 +19950414 +EXPLAIN SELECT * FROM t1 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t6); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t1 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t6); +c1 +19930513 +19950414 +EXPLAIN SELECT 1 FROM t1 WHERE (SELECT 1 FROM t1 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t6 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t1 WHERE (SELECT 1 FROM t1 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t6 WHERE ASCII(c1) = 50); +1 +1 +1 +1 +1 +1 +1 +EXPLAIN SELECT * FROM t1 STRAIGHT_JOIN t7 WHERE t1.c1=t7.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t1 STRAIGHT_JOIN t7 WHERE t1.c1=t7.c1; +c1 c1 +19930513 19930513 +19950414 19950414 +EXPLAIN SELECT * FROM t1 WHERE c1 IN (SELECT c1 FROM t7); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t1 WHERE c1 IN (SELECT c1 FROM t7); +c1 +19930513 +19950414 +EXPLAIN SELECT * FROM t1 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t7); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t1 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t7); +c1 +19930513 +19950414 +EXPLAIN SELECT 1 FROM t1 WHERE (SELECT 1 FROM t1 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t7 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t1 WHERE (SELECT 1 FROM t1 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t7 WHERE ASCII(c1) = 50); +1 +1 +1 +1 +1 +1 +1 +EXPLAIN SELECT * FROM t1 STRAIGHT_JOIN t8 WHERE t1.c1=t8.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t1 STRAIGHT_JOIN t8 WHERE t1.c1=t8.c1; +c1 c1 +EXPLAIN SELECT * FROM t1 WHERE c1 IN (SELECT c1 FROM t8); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t1 WHERE c1 IN (SELECT c1 FROM t8); +c1 +EXPLAIN SELECT * FROM t1 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t8); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t1 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t8); +c1 +EXPLAIN SELECT 1 FROM t1 WHERE (SELECT 1 FROM t1 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t8 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t1 WHERE (SELECT 1 FROM t1 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t8 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t1 STRAIGHT_JOIN t9 WHERE t1.c1=t9.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t1 STRAIGHT_JOIN t9 WHERE t1.c1=t9.c1; +c1 c1 +EXPLAIN SELECT * FROM t1 WHERE c1 IN (SELECT c1 FROM t9); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t1 WHERE c1 IN (SELECT c1 FROM t9); +c1 +EXPLAIN SELECT * FROM t1 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t9); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t1 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t9); +c1 +EXPLAIN SELECT 1 FROM t1 WHERE (SELECT 1 FROM t1 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t9 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t1 WHERE (SELECT 1 FROM t1 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t9 WHERE ASCII(c1) = 50); +1 +1 +1 +1 +1 +1 +1 +EXPLAIN SELECT * FROM t1 STRAIGHT_JOIN t10 WHERE t1.c1=t10.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t1 STRAIGHT_JOIN t10 WHERE t1.c1=t10.c1; +c1 c1 +EXPLAIN SELECT * FROM t1 WHERE c1 IN (SELECT c1 FROM t10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t1 WHERE c1 IN (SELECT c1 FROM t10); +c1 +EXPLAIN SELECT * FROM t1 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t1 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t10); +c1 +EXPLAIN SELECT 1 FROM t1 WHERE (SELECT 1 FROM t1 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t10 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t1 WHERE (SELECT 1 FROM t1 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t10 WHERE ASCII(c1) = 50); +1 +1 +1 +1 +1 +1 +1 +EXPLAIN SELECT * FROM t1 STRAIGHT_JOIN t11 WHERE t1.c1=t11.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t1 STRAIGHT_JOIN t11 WHERE t1.c1=t11.c1; +c1 c1 +EXPLAIN SELECT * FROM t1 WHERE c1 IN (SELECT c1 FROM t11); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t1 WHERE c1 IN (SELECT c1 FROM t11); +c1 +EXPLAIN SELECT * FROM t1 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t11); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t1 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t11); +c1 +EXPLAIN SELECT 1 FROM t1 WHERE (SELECT 1 FROM t1 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t11 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t1 WHERE (SELECT 1 FROM t1 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t11 WHERE ASCII(c1) = 50); +1 +1 +1 +1 +1 +1 +1 +EXPLAIN SELECT * FROM t1 STRAIGHT_JOIN t12 WHERE t1.c1=t12.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t1 STRAIGHT_JOIN t12 WHERE t1.c1=t12.c1; +c1 c1 +19930513 19930513 +19950414 19950414 +EXPLAIN SELECT * FROM t1 WHERE c1 IN (SELECT c1 FROM t12); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t1 WHERE c1 IN (SELECT c1 FROM t12); +c1 +19930513 +19950414 +EXPLAIN SELECT * FROM t1 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t12); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t1 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t12); +c1 +19930513 +19950414 +EXPLAIN SELECT 1 FROM t1 WHERE (SELECT 1 FROM t1 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t12 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t1 WHERE (SELECT 1 FROM t1 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t12 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t1 STRAIGHT_JOIN t13 WHERE t1.c1=t13.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t1 STRAIGHT_JOIN t13 WHERE t1.c1=t13.c1; +c1 c1 +19950414 19950414 +EXPLAIN SELECT * FROM t1 WHERE c1 IN (SELECT c1 FROM t13); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t1 WHERE c1 IN (SELECT c1 FROM t13); +c1 +19950414 +EXPLAIN SELECT * FROM t1 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t13); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t1 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t13); +c1 +19950414 +EXPLAIN SELECT 1 FROM t1 WHERE (SELECT 1 FROM t1 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t13 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t1 WHERE (SELECT 1 FROM t1 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t13 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t2 STRAIGHT_JOIN t1 WHERE t2.c1=t1.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t2 STRAIGHT_JOIN t1 WHERE t2.c1=t1.c1; +c1 c1 +19930513 19930513 +19950414 19950414 +EXPLAIN SELECT * FROM t2 WHERE c1 IN (SELECT c1 FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t2 WHERE c1 IN (SELECT c1 FROM t1); +c1 +19930513 +19950414 +EXPLAIN SELECT * FROM t2 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t2 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t1); +c1 +19930513 +19950414 +EXPLAIN SELECT 1 FROM t2 WHERE (SELECT 1 FROM t2 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t1 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t2 WHERE (SELECT 1 FROM t2 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t1 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t2 STRAIGHT_JOIN t3 WHERE t2.c1=t3.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t2 STRAIGHT_JOIN t3 WHERE t2.c1=t3.c1; +c1 c1 +19950414 19950414.00 +EXPLAIN SELECT * FROM t2 WHERE c1 IN (SELECT c1 FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t2 WHERE c1 IN (SELECT c1 FROM t3); +c1 +19950414 +EXPLAIN SELECT * FROM t2 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t2 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t3); +c1 +19950414 +EXPLAIN SELECT 1 FROM t2 WHERE (SELECT 1 FROM t2 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t3 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t2 WHERE (SELECT 1 FROM t2 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t3 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t2 STRAIGHT_JOIN t4 WHERE t2.c1=t4.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t2 STRAIGHT_JOIN t4 WHERE t2.c1=t4.c1; +c1 c1 +19950414 19950400 +19950414 19950400 +EXPLAIN SELECT * FROM t2 WHERE c1 IN (SELECT c1 FROM t4); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t2 WHERE c1 IN (SELECT c1 FROM t4); +c1 +19950414 +EXPLAIN SELECT * FROM t2 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t4); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t2 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t4); +c1 +19950414 +EXPLAIN SELECT 1 FROM t2 WHERE (SELECT 1 FROM t2 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t4 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t2 WHERE (SELECT 1 FROM t2 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t4 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t2 STRAIGHT_JOIN t5 WHERE t2.c1=t5.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t2 STRAIGHT_JOIN t5 WHERE t2.c1=t5.c1; +c1 c1 +19950414 19950414 +EXPLAIN SELECT * FROM t2 WHERE c1 IN (SELECT c1 FROM t5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t2 WHERE c1 IN (SELECT c1 FROM t5); +c1 +19950414 +EXPLAIN SELECT * FROM t2 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t2 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t5); +c1 +19950414 +EXPLAIN SELECT 1 FROM t2 WHERE (SELECT 1 FROM t2 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t5 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t2 WHERE (SELECT 1 FROM t2 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t5 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t2 STRAIGHT_JOIN t6 WHERE t2.c1=t6.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t2 STRAIGHT_JOIN t6 WHERE t2.c1=t6.c1; +c1 c1 +19930513 19930513 +19950414 19950414 +EXPLAIN SELECT * FROM t2 WHERE c1 IN (SELECT c1 FROM t6); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t2 WHERE c1 IN (SELECT c1 FROM t6); +c1 +19930513 +19950414 +EXPLAIN SELECT * FROM t2 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t6); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t2 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t6); +c1 +19930513 +19950414 +EXPLAIN SELECT 1 FROM t2 WHERE (SELECT 1 FROM t2 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t6 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t2 WHERE (SELECT 1 FROM t2 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t6 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t2 STRAIGHT_JOIN t7 WHERE t2.c1=t7.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t2 STRAIGHT_JOIN t7 WHERE t2.c1=t7.c1; +c1 c1 +19930513 19930513 +19950414 19950414 +EXPLAIN SELECT * FROM t2 WHERE c1 IN (SELECT c1 FROM t7); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t2 WHERE c1 IN (SELECT c1 FROM t7); +c1 +19930513 +19950414 +EXPLAIN SELECT * FROM t2 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t7); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t2 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t7); +c1 +19930513 +19950414 +EXPLAIN SELECT 1 FROM t2 WHERE (SELECT 1 FROM t2 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t7 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t2 WHERE (SELECT 1 FROM t2 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t7 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t2 STRAIGHT_JOIN t8 WHERE t2.c1=t8.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t2 STRAIGHT_JOIN t8 WHERE t2.c1=t8.c1; +c1 c1 +EXPLAIN SELECT * FROM t2 WHERE c1 IN (SELECT c1 FROM t8); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t2 WHERE c1 IN (SELECT c1 FROM t8); +c1 +EXPLAIN SELECT * FROM t2 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t8); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t2 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t8); +c1 +EXPLAIN SELECT 1 FROM t2 WHERE (SELECT 1 FROM t2 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t8 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t2 WHERE (SELECT 1 FROM t2 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t8 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t2 STRAIGHT_JOIN t9 WHERE t2.c1=t9.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t2 STRAIGHT_JOIN t9 WHERE t2.c1=t9.c1; +c1 c1 +EXPLAIN SELECT * FROM t2 WHERE c1 IN (SELECT c1 FROM t9); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t2 WHERE c1 IN (SELECT c1 FROM t9); +c1 +EXPLAIN SELECT * FROM t2 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t9); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t2 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t9); +c1 +EXPLAIN SELECT 1 FROM t2 WHERE (SELECT 1 FROM t2 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t9 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t2 WHERE (SELECT 1 FROM t2 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t9 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t2 STRAIGHT_JOIN t10 WHERE t2.c1=t10.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t2 STRAIGHT_JOIN t10 WHERE t2.c1=t10.c1; +c1 c1 +EXPLAIN SELECT * FROM t2 WHERE c1 IN (SELECT c1 FROM t10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t2 WHERE c1 IN (SELECT c1 FROM t10); +c1 +EXPLAIN SELECT * FROM t2 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t2 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t10); +c1 +EXPLAIN SELECT 1 FROM t2 WHERE (SELECT 1 FROM t2 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t10 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t2 WHERE (SELECT 1 FROM t2 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t10 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t2 STRAIGHT_JOIN t11 WHERE t2.c1=t11.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t2 STRAIGHT_JOIN t11 WHERE t2.c1=t11.c1; +c1 c1 +EXPLAIN SELECT * FROM t2 WHERE c1 IN (SELECT c1 FROM t11); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t2 WHERE c1 IN (SELECT c1 FROM t11); +c1 +EXPLAIN SELECT * FROM t2 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t11); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t2 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t11); +c1 +EXPLAIN SELECT 1 FROM t2 WHERE (SELECT 1 FROM t2 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t11 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t2 WHERE (SELECT 1 FROM t2 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t11 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t2 STRAIGHT_JOIN t12 WHERE t2.c1=t12.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t2 STRAIGHT_JOIN t12 WHERE t2.c1=t12.c1; +c1 c1 +19930513 19930513 +19950414 19950414 +EXPLAIN SELECT * FROM t2 WHERE c1 IN (SELECT c1 FROM t12); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t2 WHERE c1 IN (SELECT c1 FROM t12); +c1 +19930513 +19950414 +EXPLAIN SELECT * FROM t2 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t12); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t2 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t12); +c1 +19930513 +19950414 +EXPLAIN SELECT 1 FROM t2 WHERE (SELECT 1 FROM t2 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t12 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t2 WHERE (SELECT 1 FROM t2 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t12 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t2 STRAIGHT_JOIN t13 WHERE t2.c1=t13.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t2 STRAIGHT_JOIN t13 WHERE t2.c1=t13.c1; +c1 c1 +19950414 19950414 +EXPLAIN SELECT * FROM t2 WHERE c1 IN (SELECT c1 FROM t13); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t2 WHERE c1 IN (SELECT c1 FROM t13); +c1 +19950414 +EXPLAIN SELECT * FROM t2 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t13); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t2 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t13); +c1 +19950414 +EXPLAIN SELECT 1 FROM t2 WHERE (SELECT 1 FROM t2 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t13 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t2 WHERE (SELECT 1 FROM t2 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t13 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t3 STRAIGHT_JOIN t1 WHERE t3.c1=t1.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t3 STRAIGHT_JOIN t1 WHERE t3.c1=t1.c1; +c1 c1 +19950414.00 19950414 +EXPLAIN SELECT * FROM t3 WHERE c1 IN (SELECT c1 FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t3 WHERE c1 IN (SELECT c1 FROM t1); +c1 +19950414.00 +EXPLAIN SELECT * FROM t3 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t3 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t1); +c1 +19950414.00 +EXPLAIN SELECT 1 FROM t3 WHERE (SELECT 1 FROM t3 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t1 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t3 WHERE (SELECT 1 FROM t3 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t1 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t3 STRAIGHT_JOIN t2 WHERE t3.c1=t2.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t3 STRAIGHT_JOIN t2 WHERE t3.c1=t2.c1; +c1 c1 +19950414.00 19950414 +EXPLAIN SELECT * FROM t3 WHERE c1 IN (SELECT c1 FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t3 WHERE c1 IN (SELECT c1 FROM t2); +c1 +19950414.00 +EXPLAIN SELECT * FROM t3 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t3 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t2); +c1 +19950414.00 +EXPLAIN SELECT 1 FROM t3 WHERE (SELECT 1 FROM t3 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t2 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t3 WHERE (SELECT 1 FROM t3 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t2 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t3 STRAIGHT_JOIN t4 WHERE t3.c1=t4.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t3 STRAIGHT_JOIN t4 WHERE t3.c1=t4.c1; +c1 c1 +19950414.00 19950400 +19950414.00 19950400 +EXPLAIN SELECT * FROM t3 WHERE c1 IN (SELECT c1 FROM t4); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t3 WHERE c1 IN (SELECT c1 FROM t4); +c1 +19950414.00 +EXPLAIN SELECT * FROM t3 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t4); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t3 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t4); +c1 +19950414.00 +EXPLAIN SELECT 1 FROM t3 WHERE (SELECT 1 FROM t3 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t4 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t3 WHERE (SELECT 1 FROM t3 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t4 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t3 STRAIGHT_JOIN t5 WHERE t3.c1=t5.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t3 STRAIGHT_JOIN t5 WHERE t3.c1=t5.c1; +c1 c1 +19930513.30 19930513.3 +19950414.00 19950414 +19950414.10 19950414.1 +EXPLAIN SELECT * FROM t3 WHERE c1 IN (SELECT c1 FROM t5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t3 WHERE c1 IN (SELECT c1 FROM t5); +c1 +19930513.30 +19950414.00 +19950414.10 +EXPLAIN SELECT * FROM t3 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t3 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t5); +c1 +19930513.30 +19950414.00 +19950414.10 +EXPLAIN SELECT 1 FROM t3 WHERE (SELECT 1 FROM t3 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t5 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t3 WHERE (SELECT 1 FROM t3 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t5 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t3 STRAIGHT_JOIN t6 WHERE t3.c1=t6.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t3 STRAIGHT_JOIN t6 WHERE t3.c1=t6.c1; +c1 c1 +19950414.00 19950414 +19950414.10 19950414.1 +EXPLAIN SELECT * FROM t3 WHERE c1 IN (SELECT c1 FROM t6); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t3 WHERE c1 IN (SELECT c1 FROM t6); +c1 +19950414.00 +19950414.10 +EXPLAIN SELECT * FROM t3 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t6); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t3 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t6); +c1 +19950414.00 +19950414.10 +EXPLAIN SELECT 1 FROM t3 WHERE (SELECT 1 FROM t3 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t6 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t3 WHERE (SELECT 1 FROM t3 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t6 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t3 STRAIGHT_JOIN t7 WHERE t3.c1=t7.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t3 STRAIGHT_JOIN t7 WHERE t3.c1=t7.c1; +c1 c1 +19950414.00 19950414 +19950414.10 19950414.1 +EXPLAIN SELECT * FROM t3 WHERE c1 IN (SELECT c1 FROM t7); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t3 WHERE c1 IN (SELECT c1 FROM t7); +c1 +19950414.00 +19950414.10 +EXPLAIN SELECT * FROM t3 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t7); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t3 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t7); +c1 +19950414.00 +19950414.10 +EXPLAIN SELECT 1 FROM t3 WHERE (SELECT 1 FROM t3 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t7 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t3 WHERE (SELECT 1 FROM t3 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t7 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t3 STRAIGHT_JOIN t8 WHERE t3.c1=t8.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t3 STRAIGHT_JOIN t8 WHERE t3.c1=t8.c1; +c1 c1 +EXPLAIN SELECT * FROM t3 WHERE c1 IN (SELECT c1 FROM t8); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t3 WHERE c1 IN (SELECT c1 FROM t8); +c1 +EXPLAIN SELECT * FROM t3 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t8); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t3 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t8); +c1 +EXPLAIN SELECT 1 FROM t3 WHERE (SELECT 1 FROM t3 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t8 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t3 WHERE (SELECT 1 FROM t3 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t8 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t3 STRAIGHT_JOIN t9 WHERE t3.c1=t9.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t3 STRAIGHT_JOIN t9 WHERE t3.c1=t9.c1; +c1 c1 +EXPLAIN SELECT * FROM t3 WHERE c1 IN (SELECT c1 FROM t9); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t3 WHERE c1 IN (SELECT c1 FROM t9); +c1 +EXPLAIN SELECT * FROM t3 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t9); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t3 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t9); +c1 +EXPLAIN SELECT 1 FROM t3 WHERE (SELECT 1 FROM t3 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t9 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t3 WHERE (SELECT 1 FROM t3 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t9 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t3 STRAIGHT_JOIN t10 WHERE t3.c1=t10.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t3 STRAIGHT_JOIN t10 WHERE t3.c1=t10.c1; +c1 c1 +EXPLAIN SELECT * FROM t3 WHERE c1 IN (SELECT c1 FROM t10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t3 WHERE c1 IN (SELECT c1 FROM t10); +c1 +EXPLAIN SELECT * FROM t3 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t3 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t10); +c1 +EXPLAIN SELECT 1 FROM t3 WHERE (SELECT 1 FROM t3 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t10 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t3 WHERE (SELECT 1 FROM t3 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t10 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t3 STRAIGHT_JOIN t11 WHERE t3.c1=t11.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t3 STRAIGHT_JOIN t11 WHERE t3.c1=t11.c1; +c1 c1 +EXPLAIN SELECT * FROM t3 WHERE c1 IN (SELECT c1 FROM t11); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t3 WHERE c1 IN (SELECT c1 FROM t11); +c1 +EXPLAIN SELECT * FROM t3 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t11); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t3 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t11); +c1 +EXPLAIN SELECT 1 FROM t3 WHERE (SELECT 1 FROM t3 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t11 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t3 WHERE (SELECT 1 FROM t3 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t11 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t3 STRAIGHT_JOIN t12 WHERE t3.c1=t12.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t3 STRAIGHT_JOIN t12 WHERE t3.c1=t12.c1; +c1 c1 +19950414.00 19950414 +19950414.10 19950414.1 +EXPLAIN SELECT * FROM t3 WHERE c1 IN (SELECT c1 FROM t12); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t3 WHERE c1 IN (SELECT c1 FROM t12); +c1 +19950414.00 +19950414.10 +EXPLAIN SELECT * FROM t3 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t12); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t3 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t12); +c1 +19950414.00 +19950414.10 +EXPLAIN SELECT 1 FROM t3 WHERE (SELECT 1 FROM t3 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t12 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t3 WHERE (SELECT 1 FROM t3 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t12 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t3 STRAIGHT_JOIN t13 WHERE t3.c1=t13.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t3 STRAIGHT_JOIN t13 WHERE t3.c1=t13.c1; +c1 c1 +19950414.00 19950414 +EXPLAIN SELECT * FROM t3 WHERE c1 IN (SELECT c1 FROM t13); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t3 WHERE c1 IN (SELECT c1 FROM t13); +c1 +19950414.00 +EXPLAIN SELECT * FROM t3 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t13); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t3 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t13); +c1 +19950414.00 +EXPLAIN SELECT 1 FROM t3 WHERE (SELECT 1 FROM t3 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t13 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t3 WHERE (SELECT 1 FROM t3 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t13 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t4 STRAIGHT_JOIN t1 WHERE t4.c1=t1.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t4 STRAIGHT_JOIN t1 WHERE t4.c1=t1.c1; +c1 c1 +19950400 19950414 +19950400 19950414 +EXPLAIN SELECT * FROM t4 WHERE c1 IN (SELECT c1 FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t4 WHERE c1 IN (SELECT c1 FROM t1); +c1 +19950400 +19950400 +EXPLAIN SELECT * FROM t4 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t4 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t1); +c1 +19950400 +EXPLAIN SELECT 1 FROM t4 WHERE (SELECT 1 FROM t4 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t1 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t4 WHERE (SELECT 1 FROM t4 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t1 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t4 STRAIGHT_JOIN t2 WHERE t4.c1=t2.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t4 STRAIGHT_JOIN t2 WHERE t4.c1=t2.c1; +c1 c1 +19950400 19950414 +19950400 19950414 +EXPLAIN SELECT * FROM t4 WHERE c1 IN (SELECT c1 FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t4 WHERE c1 IN (SELECT c1 FROM t2); +c1 +19950400 +19950400 +EXPLAIN SELECT * FROM t4 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t4 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t2); +c1 +19950400 +EXPLAIN SELECT 1 FROM t4 WHERE (SELECT 1 FROM t4 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t2 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t4 WHERE (SELECT 1 FROM t4 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t2 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t4 STRAIGHT_JOIN t3 WHERE t4.c1=t3.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t4 STRAIGHT_JOIN t3 WHERE t4.c1=t3.c1; +c1 c1 +19950400 19950414.00 +19950400 19950414.00 +EXPLAIN SELECT * FROM t4 WHERE c1 IN (SELECT c1 FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t4 WHERE c1 IN (SELECT c1 FROM t3); +c1 +19950400 +19950400 +EXPLAIN SELECT * FROM t4 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t4 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t3); +c1 +19950400 +EXPLAIN SELECT 1 FROM t4 WHERE (SELECT 1 FROM t4 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t3 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t4 WHERE (SELECT 1 FROM t4 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t3 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t4 STRAIGHT_JOIN t5 WHERE t4.c1=t5.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t4 STRAIGHT_JOIN t5 WHERE t4.c1=t5.c1; +c1 c1 +19950400 19950414 +19950400 19950414 +EXPLAIN SELECT * FROM t4 WHERE c1 IN (SELECT c1 FROM t5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t4 WHERE c1 IN (SELECT c1 FROM t5); +c1 +19950400 +19950400 +EXPLAIN SELECT * FROM t4 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t4 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t5); +c1 +19950400 +EXPLAIN SELECT 1 FROM t4 WHERE (SELECT 1 FROM t4 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t5 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t4 WHERE (SELECT 1 FROM t4 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t5 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t4 STRAIGHT_JOIN t6 WHERE t4.c1=t6.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t4 STRAIGHT_JOIN t6 WHERE t4.c1=t6.c1; +c1 c1 +19950400 19950414 +19950400 19950414 +EXPLAIN SELECT * FROM t4 WHERE c1 IN (SELECT c1 FROM t6); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t4 WHERE c1 IN (SELECT c1 FROM t6); +c1 +19950400 +19950400 +EXPLAIN SELECT * FROM t4 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t6); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t4 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t6); +c1 +19950400 +EXPLAIN SELECT 1 FROM t4 WHERE (SELECT 1 FROM t4 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t6 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t4 WHERE (SELECT 1 FROM t4 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t6 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t4 STRAIGHT_JOIN t7 WHERE t4.c1=t7.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t4 STRAIGHT_JOIN t7 WHERE t4.c1=t7.c1; +c1 c1 +19950400 19950414 +19950400 19950414 +EXPLAIN SELECT * FROM t4 WHERE c1 IN (SELECT c1 FROM t7); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t4 WHERE c1 IN (SELECT c1 FROM t7); +c1 +19950400 +19950400 +EXPLAIN SELECT * FROM t4 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t7); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t4 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t7); +c1 +19950400 +EXPLAIN SELECT 1 FROM t4 WHERE (SELECT 1 FROM t4 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t7 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t4 WHERE (SELECT 1 FROM t4 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t7 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t4 STRAIGHT_JOIN t8 WHERE t4.c1=t8.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t4 STRAIGHT_JOIN t8 WHERE t4.c1=t8.c1; +c1 c1 +EXPLAIN SELECT * FROM t4 WHERE c1 IN (SELECT c1 FROM t8); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t4 WHERE c1 IN (SELECT c1 FROM t8); +c1 +EXPLAIN SELECT * FROM t4 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t8); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t4 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t8); +c1 +EXPLAIN SELECT 1 FROM t4 WHERE (SELECT 1 FROM t4 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t8 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t4 WHERE (SELECT 1 FROM t4 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t8 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t4 STRAIGHT_JOIN t9 WHERE t4.c1=t9.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t4 STRAIGHT_JOIN t9 WHERE t4.c1=t9.c1; +c1 c1 +EXPLAIN SELECT * FROM t4 WHERE c1 IN (SELECT c1 FROM t9); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t4 WHERE c1 IN (SELECT c1 FROM t9); +c1 +EXPLAIN SELECT * FROM t4 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t9); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t4 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t9); +c1 +EXPLAIN SELECT 1 FROM t4 WHERE (SELECT 1 FROM t4 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t9 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t4 WHERE (SELECT 1 FROM t4 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t9 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t4 STRAIGHT_JOIN t10 WHERE t4.c1=t10.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t4 STRAIGHT_JOIN t10 WHERE t4.c1=t10.c1; +c1 c1 +EXPLAIN SELECT * FROM t4 WHERE c1 IN (SELECT c1 FROM t10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t4 WHERE c1 IN (SELECT c1 FROM t10); +c1 +EXPLAIN SELECT * FROM t4 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t4 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t10); +c1 +EXPLAIN SELECT 1 FROM t4 WHERE (SELECT 1 FROM t4 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t10 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t4 WHERE (SELECT 1 FROM t4 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t10 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t4 STRAIGHT_JOIN t11 WHERE t4.c1=t11.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t4 STRAIGHT_JOIN t11 WHERE t4.c1=t11.c1; +c1 c1 +EXPLAIN SELECT * FROM t4 WHERE c1 IN (SELECT c1 FROM t11); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t4 WHERE c1 IN (SELECT c1 FROM t11); +c1 +EXPLAIN SELECT * FROM t4 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t11); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t4 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t11); +c1 +EXPLAIN SELECT 1 FROM t4 WHERE (SELECT 1 FROM t4 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t11 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t4 WHERE (SELECT 1 FROM t4 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t11 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t4 STRAIGHT_JOIN t12 WHERE t4.c1=t12.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t4 STRAIGHT_JOIN t12 WHERE t4.c1=t12.c1; +c1 c1 +19950400 19950414 +19950400 19950414 +EXPLAIN SELECT * FROM t4 WHERE c1 IN (SELECT c1 FROM t12); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t4 WHERE c1 IN (SELECT c1 FROM t12); +c1 +19950400 +19950400 +EXPLAIN SELECT * FROM t4 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t12); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t4 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t12); +c1 +19950400 +EXPLAIN SELECT 1 FROM t4 WHERE (SELECT 1 FROM t4 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t12 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t4 WHERE (SELECT 1 FROM t4 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t12 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t4 STRAIGHT_JOIN t13 WHERE t4.c1=t13.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t4 STRAIGHT_JOIN t13 WHERE t4.c1=t13.c1; +c1 c1 +19950400 19950414 +19950400 19950414 +EXPLAIN SELECT * FROM t4 WHERE c1 IN (SELECT c1 FROM t13); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t4 WHERE c1 IN (SELECT c1 FROM t13); +c1 +19950400 +19950400 +EXPLAIN SELECT * FROM t4 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t13); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t4 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t13); +c1 +19950400 +EXPLAIN SELECT 1 FROM t4 WHERE (SELECT 1 FROM t4 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t13 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t4 WHERE (SELECT 1 FROM t4 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t13 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t5 STRAIGHT_JOIN t1 WHERE t5.c1=t1.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t5 STRAIGHT_JOIN t1 WHERE t5.c1=t1.c1; +c1 c1 +19950414 19950414 +EXPLAIN SELECT * FROM t5 WHERE c1 IN (SELECT c1 FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t5 WHERE c1 IN (SELECT c1 FROM t1); +c1 +19950414 +EXPLAIN SELECT * FROM t5 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t5 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t1); +c1 +19950414 +EXPLAIN SELECT 1 FROM t5 WHERE (SELECT 1 FROM t5 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t1 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t5 WHERE (SELECT 1 FROM t5 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t1 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t5 STRAIGHT_JOIN t2 WHERE t5.c1=t2.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t5 STRAIGHT_JOIN t2 WHERE t5.c1=t2.c1; +c1 c1 +19950414 19950414 +EXPLAIN SELECT * FROM t5 WHERE c1 IN (SELECT c1 FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t5 WHERE c1 IN (SELECT c1 FROM t2); +c1 +19950414 +EXPLAIN SELECT * FROM t5 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t5 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t2); +c1 +19950414 +EXPLAIN SELECT 1 FROM t5 WHERE (SELECT 1 FROM t5 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t2 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t5 WHERE (SELECT 1 FROM t5 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t2 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t5 STRAIGHT_JOIN t3 WHERE t5.c1=t3.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t5 STRAIGHT_JOIN t3 WHERE t5.c1=t3.c1; +c1 c1 +19930513.3 19930513.30 +19950414 19950414.00 +19950414.1 19950414.10 +EXPLAIN SELECT * FROM t5 WHERE c1 IN (SELECT c1 FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t5 WHERE c1 IN (SELECT c1 FROM t3); +c1 +19930513.3 +19950414 +19950414.1 +EXPLAIN SELECT * FROM t5 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t5 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t3); +c1 +19930513.3 +19950414 +19950414.1 +EXPLAIN SELECT 1 FROM t5 WHERE (SELECT 1 FROM t5 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t3 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t5 WHERE (SELECT 1 FROM t5 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t3 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t5 STRAIGHT_JOIN t4 WHERE t5.c1=t4.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t5 STRAIGHT_JOIN t4 WHERE t5.c1=t4.c1; +c1 c1 +19950414 19950400 +19950414 19950400 +EXPLAIN SELECT * FROM t5 WHERE c1 IN (SELECT c1 FROM t4); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t5 WHERE c1 IN (SELECT c1 FROM t4); +c1 +19950414 +EXPLAIN SELECT * FROM t5 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t4); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t5 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t4); +c1 +19950414 +EXPLAIN SELECT 1 FROM t5 WHERE (SELECT 1 FROM t5 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t4 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t5 WHERE (SELECT 1 FROM t5 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t4 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t5 STRAIGHT_JOIN t6 WHERE t5.c1=t6.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t5 STRAIGHT_JOIN t6 WHERE t5.c1=t6.c1; +c1 c1 +19950414 19950414 +19950414.1 19950414.1 +EXPLAIN SELECT * FROM t5 WHERE c1 IN (SELECT c1 FROM t6); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t5 WHERE c1 IN (SELECT c1 FROM t6); +c1 +19950414 +19950414.1 +EXPLAIN SELECT * FROM t5 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t6); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t5 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t6); +c1 +19950414 +19950414.1 +EXPLAIN SELECT 1 FROM t5 WHERE (SELECT 1 FROM t5 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t6 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t5 WHERE (SELECT 1 FROM t5 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t6 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t5 STRAIGHT_JOIN t7 WHERE t5.c1=t7.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t5 STRAIGHT_JOIN t7 WHERE t5.c1=t7.c1; +c1 c1 +19950414 19950414 +19950414.1 19950414.1 +EXPLAIN SELECT * FROM t5 WHERE c1 IN (SELECT c1 FROM t7); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t5 WHERE c1 IN (SELECT c1 FROM t7); +c1 +19950414 +19950414.1 +EXPLAIN SELECT * FROM t5 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t7); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t5 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t7); +c1 +19950414 +19950414.1 +EXPLAIN SELECT 1 FROM t5 WHERE (SELECT 1 FROM t5 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t7 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t5 WHERE (SELECT 1 FROM t5 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t7 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t5 STRAIGHT_JOIN t8 WHERE t5.c1=t8.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t5 STRAIGHT_JOIN t8 WHERE t5.c1=t8.c1; +c1 c1 +EXPLAIN SELECT * FROM t5 WHERE c1 IN (SELECT c1 FROM t8); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t5 WHERE c1 IN (SELECT c1 FROM t8); +c1 +EXPLAIN SELECT * FROM t5 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t8); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t5 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t8); +c1 +EXPLAIN SELECT 1 FROM t5 WHERE (SELECT 1 FROM t5 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t8 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t5 WHERE (SELECT 1 FROM t5 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t8 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t5 STRAIGHT_JOIN t9 WHERE t5.c1=t9.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t5 STRAIGHT_JOIN t9 WHERE t5.c1=t9.c1; +c1 c1 +EXPLAIN SELECT * FROM t5 WHERE c1 IN (SELECT c1 FROM t9); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t5 WHERE c1 IN (SELECT c1 FROM t9); +c1 +EXPLAIN SELECT * FROM t5 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t9); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t5 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t9); +c1 +EXPLAIN SELECT 1 FROM t5 WHERE (SELECT 1 FROM t5 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t9 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t5 WHERE (SELECT 1 FROM t5 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t9 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t5 STRAIGHT_JOIN t10 WHERE t5.c1=t10.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t5 STRAIGHT_JOIN t10 WHERE t5.c1=t10.c1; +c1 c1 +EXPLAIN SELECT * FROM t5 WHERE c1 IN (SELECT c1 FROM t10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t5 WHERE c1 IN (SELECT c1 FROM t10); +c1 +EXPLAIN SELECT * FROM t5 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t5 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t10); +c1 +EXPLAIN SELECT 1 FROM t5 WHERE (SELECT 1 FROM t5 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t10 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t5 WHERE (SELECT 1 FROM t5 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t10 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t5 STRAIGHT_JOIN t11 WHERE t5.c1=t11.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t5 STRAIGHT_JOIN t11 WHERE t5.c1=t11.c1; +c1 c1 +EXPLAIN SELECT * FROM t5 WHERE c1 IN (SELECT c1 FROM t11); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t5 WHERE c1 IN (SELECT c1 FROM t11); +c1 +EXPLAIN SELECT * FROM t5 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t11); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t5 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t11); +c1 +EXPLAIN SELECT 1 FROM t5 WHERE (SELECT 1 FROM t5 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t11 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t5 WHERE (SELECT 1 FROM t5 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t11 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t5 STRAIGHT_JOIN t12 WHERE t5.c1=t12.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t5 STRAIGHT_JOIN t12 WHERE t5.c1=t12.c1; +c1 c1 +19950414 19950414 +19950414.1 19950414.1 +EXPLAIN SELECT * FROM t5 WHERE c1 IN (SELECT c1 FROM t12); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t5 WHERE c1 IN (SELECT c1 FROM t12); +c1 +19950414 +19950414.1 +EXPLAIN SELECT * FROM t5 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t12); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t5 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t12); +c1 +19950414 +19950414.1 +EXPLAIN SELECT 1 FROM t5 WHERE (SELECT 1 FROM t5 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t12 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t5 WHERE (SELECT 1 FROM t5 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t12 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t5 STRAIGHT_JOIN t13 WHERE t5.c1=t13.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t5 STRAIGHT_JOIN t13 WHERE t5.c1=t13.c1; +c1 c1 +19950414 19950414 +EXPLAIN SELECT * FROM t5 WHERE c1 IN (SELECT c1 FROM t13); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t5 WHERE c1 IN (SELECT c1 FROM t13); +c1 +19950414 +EXPLAIN SELECT * FROM t5 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t13); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t5 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t13); +c1 +19950414 +EXPLAIN SELECT 1 FROM t5 WHERE (SELECT 1 FROM t5 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t13 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t5 WHERE (SELECT 1 FROM t5 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t13 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t6 STRAIGHT_JOIN t1 WHERE t6.c1=t1.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t6 STRAIGHT_JOIN t1 WHERE t6.c1=t1.c1; +c1 c1 +19930513 19930513 +19950414 19950414 +EXPLAIN SELECT * FROM t6 WHERE c1 IN (SELECT c1 FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t6 WHERE c1 IN (SELECT c1 FROM t1); +c1 +19930513 +19950414 +EXPLAIN SELECT * FROM t6 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t6 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t1); +c1 +19930513 +19950414 +EXPLAIN SELECT 1 FROM t6 WHERE (SELECT 1 FROM t6 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t1 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t6 WHERE (SELECT 1 FROM t6 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t1 WHERE ASCII(c1) = 50); +1 +1 +1 +1 +1 +1 +EXPLAIN SELECT * FROM t6 STRAIGHT_JOIN t2 WHERE t6.c1=t2.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t6 STRAIGHT_JOIN t2 WHERE t6.c1=t2.c1; +c1 c1 +19930513 19930513 +19950414 19950414 +EXPLAIN SELECT * FROM t6 WHERE c1 IN (SELECT c1 FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t6 WHERE c1 IN (SELECT c1 FROM t2); +c1 +19930513 +19950414 +EXPLAIN SELECT * FROM t6 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t6 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t2); +c1 +19930513 +19950414 +EXPLAIN SELECT 1 FROM t6 WHERE (SELECT 1 FROM t6 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t2 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t6 WHERE (SELECT 1 FROM t6 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t2 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t6 STRAIGHT_JOIN t3 WHERE t6.c1=t3.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t6 STRAIGHT_JOIN t3 WHERE t6.c1=t3.c1; +c1 c1 +19950414 19950414.00 +19950414.1 19950414.10 +EXPLAIN SELECT * FROM t6 WHERE c1 IN (SELECT c1 FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t6 WHERE c1 IN (SELECT c1 FROM t3); +c1 +19950414 +19950414.1 +EXPLAIN SELECT * FROM t6 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t6 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t3); +c1 +19950414 +19950414.1 +EXPLAIN SELECT 1 FROM t6 WHERE (SELECT 1 FROM t6 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t3 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t6 WHERE (SELECT 1 FROM t6 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t3 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t6 STRAIGHT_JOIN t4 WHERE t6.c1=t4.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t6 STRAIGHT_JOIN t4 WHERE t6.c1=t4.c1; +c1 c1 +19950414 19950400 +19950414 19950400 +EXPLAIN SELECT * FROM t6 WHERE c1 IN (SELECT c1 FROM t4); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t6 WHERE c1 IN (SELECT c1 FROM t4); +c1 +19950414 +EXPLAIN SELECT * FROM t6 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t4); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t6 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t4); +c1 +19950414 +EXPLAIN SELECT 1 FROM t6 WHERE (SELECT 1 FROM t6 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t4 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t6 WHERE (SELECT 1 FROM t6 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t4 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t6 STRAIGHT_JOIN t5 WHERE t6.c1=t5.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t6 STRAIGHT_JOIN t5 WHERE t6.c1=t5.c1; +c1 c1 +19950414 19950414 +19950414.1 19950414.1 +EXPLAIN SELECT * FROM t6 WHERE c1 IN (SELECT c1 FROM t5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t6 WHERE c1 IN (SELECT c1 FROM t5); +c1 +19950414 +19950414.1 +EXPLAIN SELECT * FROM t6 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t6 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t5); +c1 +19950414 +19950414.1 +EXPLAIN SELECT 1 FROM t6 WHERE (SELECT 1 FROM t6 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t5 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t6 WHERE (SELECT 1 FROM t6 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t5 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t6 STRAIGHT_JOIN t7 WHERE t6.c1=t7.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t6 STRAIGHT_JOIN t7 WHERE t6.c1=t7.c1; +c1 c1 +19910111 19910111 +19930513 19930513 +19950414 19950414 +19950414.1 19950414.1 +20010513 20010513 +EXPLAIN SELECT * FROM t6 WHERE c1 IN (SELECT c1 FROM t7); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t6 WHERE c1 IN (SELECT c1 FROM t7); +c1 +19910111 +19930513 +19950414 +19950414.1 +20010513 +EXPLAIN SELECT * FROM t6 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t7); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t6 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t7); +c1 +19910111 +19930513 +19950414 +19950414.1 +20010513 +EXPLAIN SELECT 1 FROM t6 WHERE (SELECT 1 FROM t6 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t7 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t6 WHERE (SELECT 1 FROM t6 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t7 WHERE ASCII(c1) = 50); +1 +1 +1 +1 +1 +1 +EXPLAIN SELECT * FROM t6 STRAIGHT_JOIN t8 WHERE t6.c1=t8.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t6 STRAIGHT_JOIN t8 WHERE t6.c1=t8.c1; +c1 c1 +EXPLAIN SELECT * FROM t6 WHERE c1 IN (SELECT c1 FROM t8); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t6 WHERE c1 IN (SELECT c1 FROM t8); +c1 +EXPLAIN SELECT * FROM t6 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t8); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t6 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t8); +c1 +EXPLAIN SELECT 1 FROM t6 WHERE (SELECT 1 FROM t6 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t8 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t6 WHERE (SELECT 1 FROM t6 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t8 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t6 STRAIGHT_JOIN t9 WHERE t6.c1=t9.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t6 STRAIGHT_JOIN t9 WHERE t6.c1=t9.c1; +c1 c1 +EXPLAIN SELECT * FROM t6 WHERE c1 IN (SELECT c1 FROM t9); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t6 WHERE c1 IN (SELECT c1 FROM t9); +c1 +EXPLAIN SELECT * FROM t6 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t9); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t6 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t9); +c1 +EXPLAIN SELECT 1 FROM t6 WHERE (SELECT 1 FROM t6 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t9 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t6 WHERE (SELECT 1 FROM t6 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t9 WHERE ASCII(c1) = 50); +1 +1 +1 +1 +1 +1 +EXPLAIN SELECT * FROM t6 STRAIGHT_JOIN t10 WHERE t6.c1=t10.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t6 STRAIGHT_JOIN t10 WHERE t6.c1=t10.c1; +c1 c1 +EXPLAIN SELECT * FROM t6 WHERE c1 IN (SELECT c1 FROM t10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t6 WHERE c1 IN (SELECT c1 FROM t10); +c1 +EXPLAIN SELECT * FROM t6 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t6 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t10); +c1 +EXPLAIN SELECT 1 FROM t6 WHERE (SELECT 1 FROM t6 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t10 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t6 WHERE (SELECT 1 FROM t6 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t10 WHERE ASCII(c1) = 50); +1 +1 +1 +1 +1 +1 +EXPLAIN SELECT * FROM t6 STRAIGHT_JOIN t11 WHERE t6.c1=t11.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t6 STRAIGHT_JOIN t11 WHERE t6.c1=t11.c1; +c1 c1 +EXPLAIN SELECT * FROM t6 WHERE c1 IN (SELECT c1 FROM t11); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t6 WHERE c1 IN (SELECT c1 FROM t11); +c1 +EXPLAIN SELECT * FROM t6 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t11); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t6 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t11); +c1 +EXPLAIN SELECT 1 FROM t6 WHERE (SELECT 1 FROM t6 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t11 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t6 WHERE (SELECT 1 FROM t6 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t11 WHERE ASCII(c1) = 50); +1 +1 +1 +1 +1 +1 +EXPLAIN SELECT * FROM t6 STRAIGHT_JOIN t12 WHERE t6.c1=t12.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t6 STRAIGHT_JOIN t12 WHERE t6.c1=t12.c1; +c1 c1 +19910111 19910111 +19930513 19930513 +19950414 19950414 +19950414.1 19950414.1 +20010513 20010513 +EXPLAIN SELECT * FROM t6 WHERE c1 IN (SELECT c1 FROM t12); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t6 WHERE c1 IN (SELECT c1 FROM t12); +c1 +19910111 +19930513 +19950414 +19950414.1 +20010513 +EXPLAIN SELECT * FROM t6 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t12); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t6 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t12); +c1 +19910111 +19930513 +19950414 +19950414.1 +20010513 +EXPLAIN SELECT 1 FROM t6 WHERE (SELECT 1 FROM t6 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t12 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t6 WHERE (SELECT 1 FROM t6 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t12 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t6 STRAIGHT_JOIN t13 WHERE t6.c1=t13.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t6 STRAIGHT_JOIN t13 WHERE t6.c1=t13.c1; +c1 c1 +19950414 19950414 +EXPLAIN SELECT * FROM t6 WHERE c1 IN (SELECT c1 FROM t13); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t6 WHERE c1 IN (SELECT c1 FROM t13); +c1 +19950414 +EXPLAIN SELECT * FROM t6 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t13); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t6 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t13); +c1 +19950414 +EXPLAIN SELECT 1 FROM t6 WHERE (SELECT 1 FROM t6 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t13 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t6 WHERE (SELECT 1 FROM t6 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t13 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t7 STRAIGHT_JOIN t1 WHERE t7.c1=t1.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t7 STRAIGHT_JOIN t1 WHERE t7.c1=t1.c1; +c1 c1 +19930513 19930513 +19950414 19950414 +EXPLAIN SELECT * FROM t7 WHERE c1 IN (SELECT c1 FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t7 WHERE c1 IN (SELECT c1 FROM t1); +c1 +19930513 +19950414 +EXPLAIN SELECT * FROM t7 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t7 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t1); +c1 +19930513 +19950414 +EXPLAIN SELECT 1 FROM t7 WHERE (SELECT 1 FROM t7 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t1 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t7 WHERE (SELECT 1 FROM t7 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t1 WHERE ASCII(c1) = 50); +1 +1 +1 +1 +1 +1 +EXPLAIN SELECT * FROM t7 STRAIGHT_JOIN t2 WHERE t7.c1=t2.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t7 STRAIGHT_JOIN t2 WHERE t7.c1=t2.c1; +c1 c1 +19930513 19930513 +19950414 19950414 +EXPLAIN SELECT * FROM t7 WHERE c1 IN (SELECT c1 FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t7 WHERE c1 IN (SELECT c1 FROM t2); +c1 +19930513 +19950414 +EXPLAIN SELECT * FROM t7 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t7 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t2); +c1 +19930513 +19950414 +EXPLAIN SELECT 1 FROM t7 WHERE (SELECT 1 FROM t7 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t2 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t7 WHERE (SELECT 1 FROM t7 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t2 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t7 STRAIGHT_JOIN t3 WHERE t7.c1=t3.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t7 STRAIGHT_JOIN t3 WHERE t7.c1=t3.c1; +c1 c1 +19950414 19950414.00 +19950414.1 19950414.10 +EXPLAIN SELECT * FROM t7 WHERE c1 IN (SELECT c1 FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t7 WHERE c1 IN (SELECT c1 FROM t3); +c1 +19950414 +19950414.1 +EXPLAIN SELECT * FROM t7 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t7 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t3); +c1 +19950414 +19950414.1 +EXPLAIN SELECT 1 FROM t7 WHERE (SELECT 1 FROM t7 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t3 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t7 WHERE (SELECT 1 FROM t7 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t3 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t7 STRAIGHT_JOIN t4 WHERE t7.c1=t4.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t7 STRAIGHT_JOIN t4 WHERE t7.c1=t4.c1; +c1 c1 +19950414 19950400 +19950414 19950400 +EXPLAIN SELECT * FROM t7 WHERE c1 IN (SELECT c1 FROM t4); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t7 WHERE c1 IN (SELECT c1 FROM t4); +c1 +19950414 +EXPLAIN SELECT * FROM t7 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t4); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t7 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t4); +c1 +19950414 +EXPLAIN SELECT 1 FROM t7 WHERE (SELECT 1 FROM t7 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t4 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t7 WHERE (SELECT 1 FROM t7 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t4 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t7 STRAIGHT_JOIN t5 WHERE t7.c1=t5.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t7 STRAIGHT_JOIN t5 WHERE t7.c1=t5.c1; +c1 c1 +19950414 19950414 +19950414.1 19950414.1 +EXPLAIN SELECT * FROM t7 WHERE c1 IN (SELECT c1 FROM t5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t7 WHERE c1 IN (SELECT c1 FROM t5); +c1 +19950414 +19950414.1 +EXPLAIN SELECT * FROM t7 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t7 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t5); +c1 +19950414 +19950414.1 +EXPLAIN SELECT 1 FROM t7 WHERE (SELECT 1 FROM t7 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t5 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t7 WHERE (SELECT 1 FROM t7 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t5 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t7 STRAIGHT_JOIN t6 WHERE t7.c1=t6.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t7 STRAIGHT_JOIN t6 WHERE t7.c1=t6.c1; +c1 c1 +19910111 19910111 +19930513 19930513 +19950414 19950414 +19950414.1 19950414.1 +20010513 20010513 +EXPLAIN SELECT * FROM t7 WHERE c1 IN (SELECT c1 FROM t6); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t7 WHERE c1 IN (SELECT c1 FROM t6); +c1 +19910111 +19930513 +19950414 +19950414.1 +20010513 +EXPLAIN SELECT * FROM t7 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t6); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t7 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t6); +c1 +19910111 +19930513 +19950414 +19950414.1 +20010513 +EXPLAIN SELECT 1 FROM t7 WHERE (SELECT 1 FROM t7 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t6 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t7 WHERE (SELECT 1 FROM t7 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t6 WHERE ASCII(c1) = 50); +1 +1 +1 +1 +1 +1 +EXPLAIN SELECT * FROM t7 STRAIGHT_JOIN t8 WHERE t7.c1=t8.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t7 STRAIGHT_JOIN t8 WHERE t7.c1=t8.c1; +c1 c1 +EXPLAIN SELECT * FROM t7 WHERE c1 IN (SELECT c1 FROM t8); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t7 WHERE c1 IN (SELECT c1 FROM t8); +c1 +EXPLAIN SELECT * FROM t7 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t8); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t7 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t8); +c1 +EXPLAIN SELECT 1 FROM t7 WHERE (SELECT 1 FROM t7 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t8 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t7 WHERE (SELECT 1 FROM t7 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t8 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t7 STRAIGHT_JOIN t9 WHERE t7.c1=t9.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t7 STRAIGHT_JOIN t9 WHERE t7.c1=t9.c1; +c1 c1 +EXPLAIN SELECT * FROM t7 WHERE c1 IN (SELECT c1 FROM t9); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t7 WHERE c1 IN (SELECT c1 FROM t9); +c1 +EXPLAIN SELECT * FROM t7 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t9); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t7 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t9); +c1 +EXPLAIN SELECT 1 FROM t7 WHERE (SELECT 1 FROM t7 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t9 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t7 WHERE (SELECT 1 FROM t7 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t9 WHERE ASCII(c1) = 50); +1 +1 +1 +1 +1 +1 +EXPLAIN SELECT * FROM t7 STRAIGHT_JOIN t10 WHERE t7.c1=t10.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t7 STRAIGHT_JOIN t10 WHERE t7.c1=t10.c1; +c1 c1 +EXPLAIN SELECT * FROM t7 WHERE c1 IN (SELECT c1 FROM t10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t7 WHERE c1 IN (SELECT c1 FROM t10); +c1 +EXPLAIN SELECT * FROM t7 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t7 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t10); +c1 +EXPLAIN SELECT 1 FROM t7 WHERE (SELECT 1 FROM t7 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t10 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t7 WHERE (SELECT 1 FROM t7 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t10 WHERE ASCII(c1) = 50); +1 +1 +1 +1 +1 +1 +EXPLAIN SELECT * FROM t7 STRAIGHT_JOIN t11 WHERE t7.c1=t11.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t7 STRAIGHT_JOIN t11 WHERE t7.c1=t11.c1; +c1 c1 +EXPLAIN SELECT * FROM t7 WHERE c1 IN (SELECT c1 FROM t11); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t7 WHERE c1 IN (SELECT c1 FROM t11); +c1 +EXPLAIN SELECT * FROM t7 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t11); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t7 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t11); +c1 +EXPLAIN SELECT 1 FROM t7 WHERE (SELECT 1 FROM t7 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t11 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t7 WHERE (SELECT 1 FROM t7 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t11 WHERE ASCII(c1) = 50); +1 +1 +1 +1 +1 +1 +EXPLAIN SELECT * FROM t7 STRAIGHT_JOIN t12 WHERE t7.c1=t12.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t7 STRAIGHT_JOIN t12 WHERE t7.c1=t12.c1; +c1 c1 +19910111 19910111 +19930513 19930513 +19950414 19950414 +19950414.1 19950414.1 +20010513 20010513 +EXPLAIN SELECT * FROM t7 WHERE c1 IN (SELECT c1 FROM t12); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t7 WHERE c1 IN (SELECT c1 FROM t12); +c1 +19910111 +19930513 +19950414 +19950414.1 +20010513 +EXPLAIN SELECT * FROM t7 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t12); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t7 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t12); +c1 +19910111 +19930513 +19950414 +19950414.1 +20010513 +EXPLAIN SELECT 1 FROM t7 WHERE (SELECT 1 FROM t7 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t12 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t7 WHERE (SELECT 1 FROM t7 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t12 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t7 STRAIGHT_JOIN t13 WHERE t7.c1=t13.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t7 STRAIGHT_JOIN t13 WHERE t7.c1=t13.c1; +c1 c1 +19950414 19950414 +EXPLAIN SELECT * FROM t7 WHERE c1 IN (SELECT c1 FROM t13); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t7 WHERE c1 IN (SELECT c1 FROM t13); +c1 +19950414 +EXPLAIN SELECT * FROM t7 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t13); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t7 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t13); +c1 +19950414 +EXPLAIN SELECT 1 FROM t7 WHERE (SELECT 1 FROM t7 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t13 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t7 WHERE (SELECT 1 FROM t7 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t13 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t8 STRAIGHT_JOIN t1 WHERE t8.c1=t1.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t8 STRAIGHT_JOIN t1 WHERE t8.c1=t1.c1; +c1 c1 +EXPLAIN SELECT * FROM t8 WHERE c1 IN (SELECT c1 FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t8 WHERE c1 IN (SELECT c1 FROM t1); +c1 +EXPLAIN SELECT * FROM t8 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t8 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t1); +c1 +EXPLAIN SELECT 1 FROM t8 WHERE (SELECT 1 FROM t8 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t1 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t8 WHERE (SELECT 1 FROM t8 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t1 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t8 STRAIGHT_JOIN t2 WHERE t8.c1=t2.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t8 STRAIGHT_JOIN t2 WHERE t8.c1=t2.c1; +c1 c1 +EXPLAIN SELECT * FROM t8 WHERE c1 IN (SELECT c1 FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t8 WHERE c1 IN (SELECT c1 FROM t2); +c1 +EXPLAIN SELECT * FROM t8 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t8 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t2); +c1 +EXPLAIN SELECT 1 FROM t8 WHERE (SELECT 1 FROM t8 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t2 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t8 WHERE (SELECT 1 FROM t8 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t2 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t8 STRAIGHT_JOIN t3 WHERE t8.c1=t3.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t8 STRAIGHT_JOIN t3 WHERE t8.c1=t3.c1; +c1 c1 +EXPLAIN SELECT * FROM t8 WHERE c1 IN (SELECT c1 FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t8 WHERE c1 IN (SELECT c1 FROM t3); +c1 +EXPLAIN SELECT * FROM t8 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t8 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t3); +c1 +EXPLAIN SELECT 1 FROM t8 WHERE (SELECT 1 FROM t8 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t3 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t8 WHERE (SELECT 1 FROM t8 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t3 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t8 STRAIGHT_JOIN t4 WHERE t8.c1=t4.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t8 STRAIGHT_JOIN t4 WHERE t8.c1=t4.c1; +c1 c1 +EXPLAIN SELECT * FROM t8 WHERE c1 IN (SELECT c1 FROM t4); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t8 WHERE c1 IN (SELECT c1 FROM t4); +c1 +EXPLAIN SELECT * FROM t8 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t4); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t8 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t4); +c1 +EXPLAIN SELECT 1 FROM t8 WHERE (SELECT 1 FROM t8 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t4 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t8 WHERE (SELECT 1 FROM t8 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t4 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t8 STRAIGHT_JOIN t5 WHERE t8.c1=t5.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t8 STRAIGHT_JOIN t5 WHERE t8.c1=t5.c1; +c1 c1 +EXPLAIN SELECT * FROM t8 WHERE c1 IN (SELECT c1 FROM t5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t8 WHERE c1 IN (SELECT c1 FROM t5); +c1 +EXPLAIN SELECT * FROM t8 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t8 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t5); +c1 +EXPLAIN SELECT 1 FROM t8 WHERE (SELECT 1 FROM t8 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t5 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t8 WHERE (SELECT 1 FROM t8 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t5 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t8 STRAIGHT_JOIN t6 WHERE t8.c1=t6.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t8 STRAIGHT_JOIN t6 WHERE t8.c1=t6.c1; +c1 c1 +EXPLAIN SELECT * FROM t8 WHERE c1 IN (SELECT c1 FROM t6); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t8 WHERE c1 IN (SELECT c1 FROM t6); +c1 +EXPLAIN SELECT * FROM t8 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t6); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t8 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t6); +c1 +EXPLAIN SELECT 1 FROM t8 WHERE (SELECT 1 FROM t8 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t6 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t8 WHERE (SELECT 1 FROM t8 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t6 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t8 STRAIGHT_JOIN t7 WHERE t8.c1=t7.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t8 STRAIGHT_JOIN t7 WHERE t8.c1=t7.c1; +c1 c1 +EXPLAIN SELECT * FROM t8 WHERE c1 IN (SELECT c1 FROM t7); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t8 WHERE c1 IN (SELECT c1 FROM t7); +c1 +EXPLAIN SELECT * FROM t8 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t7); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t8 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t7); +c1 +EXPLAIN SELECT 1 FROM t8 WHERE (SELECT 1 FROM t8 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t7 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t8 WHERE (SELECT 1 FROM t8 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t7 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t8 STRAIGHT_JOIN t9 WHERE t8.c1=t9.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t8 STRAIGHT_JOIN t9 WHERE t8.c1=t9.c1; +c1 c1 +10:22:33 2015-04-13 10:22:33 +EXPLAIN SELECT * FROM t8 WHERE c1 IN (SELECT c1 FROM t9); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t8 WHERE c1 IN (SELECT c1 FROM t9); +c1 +10:22:33 +EXPLAIN SELECT * FROM t8 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t9); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t8 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t9); +c1 +10:22:33 +EXPLAIN SELECT 1 FROM t8 WHERE (SELECT 1 FROM t8 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t9 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t8 WHERE (SELECT 1 FROM t8 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t9 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t8 STRAIGHT_JOIN t10 WHERE t8.c1=t10.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t8 STRAIGHT_JOIN t10 WHERE t8.c1=t10.c1; +c1 c1 +EXPLAIN SELECT * FROM t8 WHERE c1 IN (SELECT c1 FROM t10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t8 WHERE c1 IN (SELECT c1 FROM t10); +c1 +EXPLAIN SELECT * FROM t8 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t8 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t10); +c1 +EXPLAIN SELECT 1 FROM t8 WHERE (SELECT 1 FROM t8 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t10 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t8 WHERE (SELECT 1 FROM t8 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t10 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t8 STRAIGHT_JOIN t11 WHERE t8.c1=t11.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t8 STRAIGHT_JOIN t11 WHERE t8.c1=t11.c1; +c1 c1 +10:22:33 2015-04-13 10:22:33 +33:22:33 2015-04-14 09:22:33 +EXPLAIN SELECT * FROM t8 WHERE c1 IN (SELECT c1 FROM t11); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t8 WHERE c1 IN (SELECT c1 FROM t11); +c1 +10:22:33 +33:22:33 +EXPLAIN SELECT * FROM t8 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t11); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t8 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t11); +c1 +10:22:33 +33:22:33 +EXPLAIN SELECT 1 FROM t8 WHERE (SELECT 1 FROM t8 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t11 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t8 WHERE (SELECT 1 FROM t8 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t11 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t8 STRAIGHT_JOIN t12 WHERE t8.c1=t12.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t8 STRAIGHT_JOIN t12 WHERE t8.c1=t12.c1; +c1 c1 +EXPLAIN SELECT * FROM t8 WHERE c1 IN (SELECT c1 FROM t12); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t8 WHERE c1 IN (SELECT c1 FROM t12); +c1 +EXPLAIN SELECT * FROM t8 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t12); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t8 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t12); +c1 +EXPLAIN SELECT 1 FROM t8 WHERE (SELECT 1 FROM t8 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t12 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t8 WHERE (SELECT 1 FROM t8 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t12 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t8 STRAIGHT_JOIN t13 WHERE t8.c1=t13.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t8 STRAIGHT_JOIN t13 WHERE t8.c1=t13.c1; +c1 c1 +EXPLAIN SELECT * FROM t8 WHERE c1 IN (SELECT c1 FROM t13); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t8 WHERE c1 IN (SELECT c1 FROM t13); +c1 +EXPLAIN SELECT * FROM t8 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t13); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t8 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t13); +c1 +EXPLAIN SELECT 1 FROM t8 WHERE (SELECT 1 FROM t8 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t13 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t8 WHERE (SELECT 1 FROM t8 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t13 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t9 STRAIGHT_JOIN t1 WHERE t9.c1=t1.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t9 STRAIGHT_JOIN t1 WHERE t9.c1=t1.c1; +c1 c1 +EXPLAIN SELECT * FROM t9 WHERE c1 IN (SELECT c1 FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t9 WHERE c1 IN (SELECT c1 FROM t1); +c1 +EXPLAIN SELECT * FROM t9 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t9 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t1); +c1 +EXPLAIN SELECT 1 FROM t9 WHERE (SELECT 1 FROM t9 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t1 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t9 WHERE (SELECT 1 FROM t9 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t1 WHERE ASCII(c1) = 50); +1 +1 +1 +EXPLAIN SELECT * FROM t9 STRAIGHT_JOIN t2 WHERE t9.c1=t2.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t9 STRAIGHT_JOIN t2 WHERE t9.c1=t2.c1; +c1 c1 +EXPLAIN SELECT * FROM t9 WHERE c1 IN (SELECT c1 FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t9 WHERE c1 IN (SELECT c1 FROM t2); +c1 +EXPLAIN SELECT * FROM t9 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t9 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t2); +c1 +EXPLAIN SELECT 1 FROM t9 WHERE (SELECT 1 FROM t9 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t2 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t9 WHERE (SELECT 1 FROM t9 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t2 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t9 STRAIGHT_JOIN t3 WHERE t9.c1=t3.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t9 STRAIGHT_JOIN t3 WHERE t9.c1=t3.c1; +c1 c1 +EXPLAIN SELECT * FROM t9 WHERE c1 IN (SELECT c1 FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t9 WHERE c1 IN (SELECT c1 FROM t3); +c1 +EXPLAIN SELECT * FROM t9 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t9 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t3); +c1 +EXPLAIN SELECT 1 FROM t9 WHERE (SELECT 1 FROM t9 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t3 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t9 WHERE (SELECT 1 FROM t9 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t3 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t9 STRAIGHT_JOIN t4 WHERE t9.c1=t4.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t9 STRAIGHT_JOIN t4 WHERE t9.c1=t4.c1; +c1 c1 +EXPLAIN SELECT * FROM t9 WHERE c1 IN (SELECT c1 FROM t4); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t9 WHERE c1 IN (SELECT c1 FROM t4); +c1 +EXPLAIN SELECT * FROM t9 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t4); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t9 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t4); +c1 +EXPLAIN SELECT 1 FROM t9 WHERE (SELECT 1 FROM t9 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t4 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t9 WHERE (SELECT 1 FROM t9 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t4 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t9 STRAIGHT_JOIN t5 WHERE t9.c1=t5.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t9 STRAIGHT_JOIN t5 WHERE t9.c1=t5.c1; +c1 c1 +EXPLAIN SELECT * FROM t9 WHERE c1 IN (SELECT c1 FROM t5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t9 WHERE c1 IN (SELECT c1 FROM t5); +c1 +EXPLAIN SELECT * FROM t9 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t9 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t5); +c1 +EXPLAIN SELECT 1 FROM t9 WHERE (SELECT 1 FROM t9 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t5 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t9 WHERE (SELECT 1 FROM t9 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t5 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t9 STRAIGHT_JOIN t6 WHERE t9.c1=t6.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t9 STRAIGHT_JOIN t6 WHERE t9.c1=t6.c1; +c1 c1 +EXPLAIN SELECT * FROM t9 WHERE c1 IN (SELECT c1 FROM t6); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t9 WHERE c1 IN (SELECT c1 FROM t6); +c1 +EXPLAIN SELECT * FROM t9 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t6); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t9 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t6); +c1 +EXPLAIN SELECT 1 FROM t9 WHERE (SELECT 1 FROM t9 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t6 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t9 WHERE (SELECT 1 FROM t9 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t6 WHERE ASCII(c1) = 50); +1 +1 +1 +EXPLAIN SELECT * FROM t9 STRAIGHT_JOIN t7 WHERE t9.c1=t7.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t9 STRAIGHT_JOIN t7 WHERE t9.c1=t7.c1; +c1 c1 +EXPLAIN SELECT * FROM t9 WHERE c1 IN (SELECT c1 FROM t7); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t9 WHERE c1 IN (SELECT c1 FROM t7); +c1 +EXPLAIN SELECT * FROM t9 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t7); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t9 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t7); +c1 +EXPLAIN SELECT 1 FROM t9 WHERE (SELECT 1 FROM t9 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t7 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t9 WHERE (SELECT 1 FROM t9 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t7 WHERE ASCII(c1) = 50); +1 +1 +1 +EXPLAIN SELECT * FROM t9 STRAIGHT_JOIN t8 WHERE t9.c1=t8.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t9 STRAIGHT_JOIN t8 WHERE t9.c1=t8.c1; +c1 c1 +2015-04-13 10:22:33 10:22:33 +EXPLAIN SELECT * FROM t9 WHERE c1 IN (SELECT c1 FROM t8); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t9 WHERE c1 IN (SELECT c1 FROM t8); +c1 +2015-04-13 10:22:33 +EXPLAIN SELECT * FROM t9 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t8); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t9 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t8); +c1 +2015-04-13 10:22:33 +EXPLAIN SELECT 1 FROM t9 WHERE (SELECT 1 FROM t9 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t8 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t9 WHERE (SELECT 1 FROM t9 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t8 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t9 STRAIGHT_JOIN t10 WHERE t9.c1=t10.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t9 STRAIGHT_JOIN t10 WHERE t9.c1=t10.c1; +c1 c1 +EXPLAIN SELECT * FROM t9 WHERE c1 IN (SELECT c1 FROM t10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t9 WHERE c1 IN (SELECT c1 FROM t10); +c1 +EXPLAIN SELECT * FROM t9 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t9 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t10); +c1 +EXPLAIN SELECT 1 FROM t9 WHERE (SELECT 1 FROM t9 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t10 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t9 WHERE (SELECT 1 FROM t9 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t10 WHERE ASCII(c1) = 50); +1 +1 +1 +EXPLAIN SELECT * FROM t9 STRAIGHT_JOIN t11 WHERE t9.c1=t11.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t9 STRAIGHT_JOIN t11 WHERE t9.c1=t11.c1; +c1 c1 +2015-04-13 10:22:33 2015-04-13 10:22:33 +EXPLAIN SELECT * FROM t9 WHERE c1 IN (SELECT c1 FROM t11); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t9 WHERE c1 IN (SELECT c1 FROM t11); +c1 +2015-04-13 10:22:33 +EXPLAIN SELECT * FROM t9 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t11); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t9 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t11); +c1 +2015-04-13 10:22:33 +EXPLAIN SELECT 1 FROM t9 WHERE (SELECT 1 FROM t9 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t11 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t9 WHERE (SELECT 1 FROM t9 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t11 WHERE ASCII(c1) = 50); +1 +1 +1 +EXPLAIN SELECT * FROM t9 STRAIGHT_JOIN t12 WHERE t9.c1=t12.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t9 STRAIGHT_JOIN t12 WHERE t9.c1=t12.c1; +c1 c1 +EXPLAIN SELECT * FROM t9 WHERE c1 IN (SELECT c1 FROM t12); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t9 WHERE c1 IN (SELECT c1 FROM t12); +c1 +EXPLAIN SELECT * FROM t9 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t12); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t9 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t12); +c1 +EXPLAIN SELECT 1 FROM t9 WHERE (SELECT 1 FROM t9 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t12 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t9 WHERE (SELECT 1 FROM t9 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t12 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t9 STRAIGHT_JOIN t13 WHERE t9.c1=t13.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t9 STRAIGHT_JOIN t13 WHERE t9.c1=t13.c1; +c1 c1 +EXPLAIN SELECT * FROM t9 WHERE c1 IN (SELECT c1 FROM t13); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t9 WHERE c1 IN (SELECT c1 FROM t13); +c1 +EXPLAIN SELECT * FROM t9 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t13); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t9 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t13); +c1 +EXPLAIN SELECT 1 FROM t9 WHERE (SELECT 1 FROM t9 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t13 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t9 WHERE (SELECT 1 FROM t9 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t13 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t10 STRAIGHT_JOIN t1 WHERE t10.c1=t1.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t10 STRAIGHT_JOIN t1 WHERE t10.c1=t1.c1; +c1 c1 +EXPLAIN SELECT * FROM t10 WHERE c1 IN (SELECT c1 FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t10 WHERE c1 IN (SELECT c1 FROM t1); +c1 +EXPLAIN SELECT * FROM t10 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t10 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t1); +c1 +EXPLAIN SELECT 1 FROM t10 WHERE (SELECT 1 FROM t10 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t1 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t10 WHERE (SELECT 1 FROM t10 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t1 WHERE ASCII(c1) = 50); +1 +1 +1 +EXPLAIN SELECT * FROM t10 STRAIGHT_JOIN t2 WHERE t10.c1=t2.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t10 STRAIGHT_JOIN t2 WHERE t10.c1=t2.c1; +c1 c1 +EXPLAIN SELECT * FROM t10 WHERE c1 IN (SELECT c1 FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t10 WHERE c1 IN (SELECT c1 FROM t2); +c1 +EXPLAIN SELECT * FROM t10 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t10 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t2); +c1 +EXPLAIN SELECT 1 FROM t10 WHERE (SELECT 1 FROM t10 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t2 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t10 WHERE (SELECT 1 FROM t10 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t2 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t10 STRAIGHT_JOIN t3 WHERE t10.c1=t3.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t10 STRAIGHT_JOIN t3 WHERE t10.c1=t3.c1; +c1 c1 +EXPLAIN SELECT * FROM t10 WHERE c1 IN (SELECT c1 FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t10 WHERE c1 IN (SELECT c1 FROM t3); +c1 +EXPLAIN SELECT * FROM t10 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t10 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t3); +c1 +EXPLAIN SELECT 1 FROM t10 WHERE (SELECT 1 FROM t10 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t3 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t10 WHERE (SELECT 1 FROM t10 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t3 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t10 STRAIGHT_JOIN t4 WHERE t10.c1=t4.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t10 STRAIGHT_JOIN t4 WHERE t10.c1=t4.c1; +c1 c1 +EXPLAIN SELECT * FROM t10 WHERE c1 IN (SELECT c1 FROM t4); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t10 WHERE c1 IN (SELECT c1 FROM t4); +c1 +EXPLAIN SELECT * FROM t10 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t4); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t10 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t4); +c1 +EXPLAIN SELECT 1 FROM t10 WHERE (SELECT 1 FROM t10 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t4 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t10 WHERE (SELECT 1 FROM t10 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t4 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t10 STRAIGHT_JOIN t5 WHERE t10.c1=t5.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t10 STRAIGHT_JOIN t5 WHERE t10.c1=t5.c1; +c1 c1 +EXPLAIN SELECT * FROM t10 WHERE c1 IN (SELECT c1 FROM t5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t10 WHERE c1 IN (SELECT c1 FROM t5); +c1 +EXPLAIN SELECT * FROM t10 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t10 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t5); +c1 +EXPLAIN SELECT 1 FROM t10 WHERE (SELECT 1 FROM t10 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t5 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t10 WHERE (SELECT 1 FROM t10 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t5 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t10 STRAIGHT_JOIN t6 WHERE t10.c1=t6.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t10 STRAIGHT_JOIN t6 WHERE t10.c1=t6.c1; +c1 c1 +EXPLAIN SELECT * FROM t10 WHERE c1 IN (SELECT c1 FROM t6); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t10 WHERE c1 IN (SELECT c1 FROM t6); +c1 +EXPLAIN SELECT * FROM t10 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t6); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t10 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t6); +c1 +EXPLAIN SELECT 1 FROM t10 WHERE (SELECT 1 FROM t10 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t6 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t10 WHERE (SELECT 1 FROM t10 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t6 WHERE ASCII(c1) = 50); +1 +1 +1 +EXPLAIN SELECT * FROM t10 STRAIGHT_JOIN t7 WHERE t10.c1=t7.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t10 STRAIGHT_JOIN t7 WHERE t10.c1=t7.c1; +c1 c1 +EXPLAIN SELECT * FROM t10 WHERE c1 IN (SELECT c1 FROM t7); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t10 WHERE c1 IN (SELECT c1 FROM t7); +c1 +EXPLAIN SELECT * FROM t10 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t7); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t10 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t7); +c1 +EXPLAIN SELECT 1 FROM t10 WHERE (SELECT 1 FROM t10 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t7 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t10 WHERE (SELECT 1 FROM t10 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t7 WHERE ASCII(c1) = 50); +1 +1 +1 +EXPLAIN SELECT * FROM t10 STRAIGHT_JOIN t8 WHERE t10.c1=t8.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t10 STRAIGHT_JOIN t8 WHERE t10.c1=t8.c1; +c1 c1 +EXPLAIN SELECT * FROM t10 WHERE c1 IN (SELECT c1 FROM t8); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t10 WHERE c1 IN (SELECT c1 FROM t8); +c1 +EXPLAIN SELECT * FROM t10 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t8); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t10 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t8); +c1 +EXPLAIN SELECT 1 FROM t10 WHERE (SELECT 1 FROM t10 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t8 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t10 WHERE (SELECT 1 FROM t10 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t8 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t10 STRAIGHT_JOIN t9 WHERE t10.c1=t9.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t10 STRAIGHT_JOIN t9 WHERE t10.c1=t9.c1; +c1 c1 +EXPLAIN SELECT * FROM t10 WHERE c1 IN (SELECT c1 FROM t9); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t10 WHERE c1 IN (SELECT c1 FROM t9); +c1 +EXPLAIN SELECT * FROM t10 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t9); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t10 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t9); +c1 +EXPLAIN SELECT 1 FROM t10 WHERE (SELECT 1 FROM t10 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t9 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t10 WHERE (SELECT 1 FROM t10 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t9 WHERE ASCII(c1) = 50); +1 +1 +1 +EXPLAIN SELECT * FROM t10 STRAIGHT_JOIN t11 WHERE t10.c1=t11.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t10 STRAIGHT_JOIN t11 WHERE t10.c1=t11.c1; +c1 c1 +EXPLAIN SELECT * FROM t10 WHERE c1 IN (SELECT c1 FROM t11); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t10 WHERE c1 IN (SELECT c1 FROM t11); +c1 +EXPLAIN SELECT * FROM t10 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t11); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t10 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t11); +c1 +EXPLAIN SELECT 1 FROM t10 WHERE (SELECT 1 FROM t10 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t11 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t10 WHERE (SELECT 1 FROM t10 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t11 WHERE ASCII(c1) = 50); +1 +1 +1 +EXPLAIN SELECT * FROM t10 STRAIGHT_JOIN t12 WHERE t10.c1=t12.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t10 STRAIGHT_JOIN t12 WHERE t10.c1=t12.c1; +c1 c1 +EXPLAIN SELECT * FROM t10 WHERE c1 IN (SELECT c1 FROM t12); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t10 WHERE c1 IN (SELECT c1 FROM t12); +c1 +EXPLAIN SELECT * FROM t10 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t12); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t10 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t12); +c1 +EXPLAIN SELECT 1 FROM t10 WHERE (SELECT 1 FROM t10 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t12 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t10 WHERE (SELECT 1 FROM t10 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t12 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t10 STRAIGHT_JOIN t13 WHERE t10.c1=t13.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t10 STRAIGHT_JOIN t13 WHERE t10.c1=t13.c1; +c1 c1 +EXPLAIN SELECT * FROM t10 WHERE c1 IN (SELECT c1 FROM t13); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t10 WHERE c1 IN (SELECT c1 FROM t13); +c1 +EXPLAIN SELECT * FROM t10 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t13); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t10 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t13); +c1 +EXPLAIN SELECT 1 FROM t10 WHERE (SELECT 1 FROM t10 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t13 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t10 WHERE (SELECT 1 FROM t10 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t13 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t11 STRAIGHT_JOIN t1 WHERE t11.c1=t1.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t11 STRAIGHT_JOIN t1 WHERE t11.c1=t1.c1; +c1 c1 +EXPLAIN SELECT * FROM t11 WHERE c1 IN (SELECT c1 FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t11 WHERE c1 IN (SELECT c1 FROM t1); +c1 +EXPLAIN SELECT * FROM t11 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t11 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t1); +c1 +DELETE FROM t11 WHERE c1='2015-04-14 09:22:33'; +ANALYZE TABLE t11; +Table Op Msg_type Msg_text +test.t11 analyze status OK +EXPLAIN SELECT 1 FROM t11 WHERE (SELECT 1 FROM t11 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t1 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t11 WHERE (SELECT 1 FROM t11 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t1 WHERE ASCII(c1) = 50); +1 +1 +1 +INSERT INTO t11 SET c1='2015-04-14 09:22:33'; +ANALYZE TABLE t11; +Table Op Msg_type Msg_text +test.t11 analyze status OK +EXPLAIN SELECT * FROM t11 STRAIGHT_JOIN t2 WHERE t11.c1=t2.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t11 STRAIGHT_JOIN t2 WHERE t11.c1=t2.c1; +c1 c1 +EXPLAIN SELECT * FROM t11 WHERE c1 IN (SELECT c1 FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t11 WHERE c1 IN (SELECT c1 FROM t2); +c1 +EXPLAIN SELECT * FROM t11 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t11 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t2); +c1 +DELETE FROM t11 WHERE c1='2015-04-14 09:22:33'; +ANALYZE TABLE t11; +Table Op Msg_type Msg_text +test.t11 analyze status OK +EXPLAIN SELECT 1 FROM t11 WHERE (SELECT 1 FROM t11 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t2 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t11 WHERE (SELECT 1 FROM t11 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t2 WHERE ASCII(c1) = 50); +1 +INSERT INTO t11 SET c1='2015-04-14 09:22:33'; +ANALYZE TABLE t11; +Table Op Msg_type Msg_text +test.t11 analyze status OK +EXPLAIN SELECT * FROM t11 STRAIGHT_JOIN t3 WHERE t11.c1=t3.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t11 STRAIGHT_JOIN t3 WHERE t11.c1=t3.c1; +c1 c1 +EXPLAIN SELECT * FROM t11 WHERE c1 IN (SELECT c1 FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t11 WHERE c1 IN (SELECT c1 FROM t3); +c1 +EXPLAIN SELECT * FROM t11 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t11 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t3); +c1 +DELETE FROM t11 WHERE c1='2015-04-14 09:22:33'; +ANALYZE TABLE t11; +Table Op Msg_type Msg_text +test.t11 analyze status OK +EXPLAIN SELECT 1 FROM t11 WHERE (SELECT 1 FROM t11 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t3 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t11 WHERE (SELECT 1 FROM t11 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t3 WHERE ASCII(c1) = 50); +1 +INSERT INTO t11 SET c1='2015-04-14 09:22:33'; +ANALYZE TABLE t11; +Table Op Msg_type Msg_text +test.t11 analyze status OK +EXPLAIN SELECT * FROM t11 STRAIGHT_JOIN t4 WHERE t11.c1=t4.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t11 STRAIGHT_JOIN t4 WHERE t11.c1=t4.c1; +c1 c1 +EXPLAIN SELECT * FROM t11 WHERE c1 IN (SELECT c1 FROM t4); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t11 WHERE c1 IN (SELECT c1 FROM t4); +c1 +EXPLAIN SELECT * FROM t11 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t4); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t11 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t4); +c1 +DELETE FROM t11 WHERE c1='2015-04-14 09:22:33'; +ANALYZE TABLE t11; +Table Op Msg_type Msg_text +test.t11 analyze status OK +EXPLAIN SELECT 1 FROM t11 WHERE (SELECT 1 FROM t11 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t4 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t11 WHERE (SELECT 1 FROM t11 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t4 WHERE ASCII(c1) = 50); +1 +INSERT INTO t11 SET c1='2015-04-14 09:22:33'; +ANALYZE TABLE t11; +Table Op Msg_type Msg_text +test.t11 analyze status OK +EXPLAIN SELECT * FROM t11 STRAIGHT_JOIN t5 WHERE t11.c1=t5.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t11 STRAIGHT_JOIN t5 WHERE t11.c1=t5.c1; +c1 c1 +EXPLAIN SELECT * FROM t11 WHERE c1 IN (SELECT c1 FROM t5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t11 WHERE c1 IN (SELECT c1 FROM t5); +c1 +EXPLAIN SELECT * FROM t11 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t11 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t5); +c1 +DELETE FROM t11 WHERE c1='2015-04-14 09:22:33'; +ANALYZE TABLE t11; +Table Op Msg_type Msg_text +test.t11 analyze status OK +EXPLAIN SELECT 1 FROM t11 WHERE (SELECT 1 FROM t11 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t5 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t11 WHERE (SELECT 1 FROM t11 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t5 WHERE ASCII(c1) = 50); +1 +INSERT INTO t11 SET c1='2015-04-14 09:22:33'; +ANALYZE TABLE t11; +Table Op Msg_type Msg_text +test.t11 analyze status OK +EXPLAIN SELECT * FROM t11 STRAIGHT_JOIN t6 WHERE t11.c1=t6.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t11 STRAIGHT_JOIN t6 WHERE t11.c1=t6.c1; +c1 c1 +EXPLAIN SELECT * FROM t11 WHERE c1 IN (SELECT c1 FROM t6); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t11 WHERE c1 IN (SELECT c1 FROM t6); +c1 +EXPLAIN SELECT * FROM t11 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t6); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t11 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t6); +c1 +DELETE FROM t11 WHERE c1='2015-04-14 09:22:33'; +ANALYZE TABLE t11; +Table Op Msg_type Msg_text +test.t11 analyze status OK +EXPLAIN SELECT 1 FROM t11 WHERE (SELECT 1 FROM t11 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t6 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t11 WHERE (SELECT 1 FROM t11 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t6 WHERE ASCII(c1) = 50); +1 +1 +1 +INSERT INTO t11 SET c1='2015-04-14 09:22:33'; +ANALYZE TABLE t11; +Table Op Msg_type Msg_text +test.t11 analyze status OK +EXPLAIN SELECT * FROM t11 STRAIGHT_JOIN t7 WHERE t11.c1=t7.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t11 STRAIGHT_JOIN t7 WHERE t11.c1=t7.c1; +c1 c1 +EXPLAIN SELECT * FROM t11 WHERE c1 IN (SELECT c1 FROM t7); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t11 WHERE c1 IN (SELECT c1 FROM t7); +c1 +EXPLAIN SELECT * FROM t11 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t7); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t11 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t7); +c1 +DELETE FROM t11 WHERE c1='2015-04-14 09:22:33'; +ANALYZE TABLE t11; +Table Op Msg_type Msg_text +test.t11 analyze status OK +EXPLAIN SELECT 1 FROM t11 WHERE (SELECT 1 FROM t11 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t7 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t11 WHERE (SELECT 1 FROM t11 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t7 WHERE ASCII(c1) = 50); +1 +1 +1 +INSERT INTO t11 SET c1='2015-04-14 09:22:33'; +ANALYZE TABLE t11; +Table Op Msg_type Msg_text +test.t11 analyze status OK +EXPLAIN SELECT * FROM t11 STRAIGHT_JOIN t8 WHERE t11.c1=t8.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t11 STRAIGHT_JOIN t8 WHERE t11.c1=t8.c1; +c1 c1 +2015-04-13 10:22:33 10:22:33 +2015-04-14 09:22:33 33:22:33 +EXPLAIN SELECT * FROM t11 WHERE c1 IN (SELECT c1 FROM t8); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t11 WHERE c1 IN (SELECT c1 FROM t8); +c1 +2015-04-13 10:22:33 +2015-04-14 09:22:33 +EXPLAIN SELECT * FROM t11 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t8); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t11 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t8); +c1 +2015-04-13 10:22:33 +2015-04-14 09:22:33 +DELETE FROM t11 WHERE c1='2015-04-14 09:22:33'; +ANALYZE TABLE t11; +Table Op Msg_type Msg_text +test.t11 analyze status OK +EXPLAIN SELECT 1 FROM t11 WHERE (SELECT 1 FROM t11 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t8 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t11 WHERE (SELECT 1 FROM t11 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t8 WHERE ASCII(c1) = 50); +1 +INSERT INTO t11 SET c1='2015-04-14 09:22:33'; +ANALYZE TABLE t11; +Table Op Msg_type Msg_text +test.t11 analyze status OK +EXPLAIN SELECT * FROM t11 STRAIGHT_JOIN t9 WHERE t11.c1=t9.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t11 STRAIGHT_JOIN t9 WHERE t11.c1=t9.c1; +c1 c1 +2015-04-13 10:22:33 2015-04-13 10:22:33 +EXPLAIN SELECT * FROM t11 WHERE c1 IN (SELECT c1 FROM t9); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t11 WHERE c1 IN (SELECT c1 FROM t9); +c1 +2015-04-13 10:22:33 +EXPLAIN SELECT * FROM t11 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t9); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t11 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t9); +c1 +2015-04-13 10:22:33 +DELETE FROM t11 WHERE c1='2015-04-14 09:22:33'; +ANALYZE TABLE t11; +Table Op Msg_type Msg_text +test.t11 analyze status OK +EXPLAIN SELECT 1 FROM t11 WHERE (SELECT 1 FROM t11 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t9 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t11 WHERE (SELECT 1 FROM t11 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t9 WHERE ASCII(c1) = 50); +1 +1 +1 +INSERT INTO t11 SET c1='2015-04-14 09:22:33'; +ANALYZE TABLE t11; +Table Op Msg_type Msg_text +test.t11 analyze status OK +EXPLAIN SELECT * FROM t11 STRAIGHT_JOIN t10 WHERE t11.c1=t10.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t11 STRAIGHT_JOIN t10 WHERE t11.c1=t10.c1; +c1 c1 +EXPLAIN SELECT * FROM t11 WHERE c1 IN (SELECT c1 FROM t10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t11 WHERE c1 IN (SELECT c1 FROM t10); +c1 +EXPLAIN SELECT * FROM t11 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t11 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t10); +c1 +DELETE FROM t11 WHERE c1='2015-04-14 09:22:33'; +ANALYZE TABLE t11; +Table Op Msg_type Msg_text +test.t11 analyze status OK +EXPLAIN SELECT 1 FROM t11 WHERE (SELECT 1 FROM t11 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t10 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t11 WHERE (SELECT 1 FROM t11 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t10 WHERE ASCII(c1) = 50); +1 +1 +1 +INSERT INTO t11 SET c1='2015-04-14 09:22:33'; +ANALYZE TABLE t11; +Table Op Msg_type Msg_text +test.t11 analyze status OK +EXPLAIN SELECT * FROM t11 STRAIGHT_JOIN t12 WHERE t11.c1=t12.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t11 STRAIGHT_JOIN t12 WHERE t11.c1=t12.c1; +c1 c1 +EXPLAIN SELECT * FROM t11 WHERE c1 IN (SELECT c1 FROM t12); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t11 WHERE c1 IN (SELECT c1 FROM t12); +c1 +EXPLAIN SELECT * FROM t11 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t12); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t11 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t12); +c1 +DELETE FROM t11 WHERE c1='2015-04-14 09:22:33'; +ANALYZE TABLE t11; +Table Op Msg_type Msg_text +test.t11 analyze status OK +EXPLAIN SELECT 1 FROM t11 WHERE (SELECT 1 FROM t11 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t12 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t11 WHERE (SELECT 1 FROM t11 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t12 WHERE ASCII(c1) = 50); +1 +INSERT INTO t11 SET c1='2015-04-14 09:22:33'; +ANALYZE TABLE t11; +Table Op Msg_type Msg_text +test.t11 analyze status OK +EXPLAIN SELECT * FROM t11 STRAIGHT_JOIN t13 WHERE t11.c1=t13.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t11 STRAIGHT_JOIN t13 WHERE t11.c1=t13.c1; +c1 c1 +EXPLAIN SELECT * FROM t11 WHERE c1 IN (SELECT c1 FROM t13); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t11 WHERE c1 IN (SELECT c1 FROM t13); +c1 +EXPLAIN SELECT * FROM t11 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t13); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t11 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t13); +c1 +DELETE FROM t11 WHERE c1='2015-04-14 09:22:33'; +ANALYZE TABLE t11; +Table Op Msg_type Msg_text +test.t11 analyze status OK +EXPLAIN SELECT 1 FROM t11 WHERE (SELECT 1 FROM t11 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t13 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t11 WHERE (SELECT 1 FROM t11 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t13 WHERE ASCII(c1) = 50); +1 +INSERT INTO t11 SET c1='2015-04-14 09:22:33'; +ANALYZE TABLE t11; +Table Op Msg_type Msg_text +test.t11 analyze status OK +EXPLAIN SELECT * FROM t12 STRAIGHT_JOIN t1 WHERE t12.c1=t1.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t12 STRAIGHT_JOIN t1 WHERE t12.c1=t1.c1; +c1 c1 +19930513 19930513 +19950414 19950414 +EXPLAIN SELECT * FROM t12 WHERE c1 IN (SELECT c1 FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t12 WHERE c1 IN (SELECT c1 FROM t1); +c1 +19930513 +19950414 +EXPLAIN SELECT * FROM t12 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t12 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t1); +c1 +19930513 +19950414 +EXPLAIN SELECT 1 FROM t12 WHERE (SELECT 1 FROM t12 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t1 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t12 WHERE (SELECT 1 FROM t12 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t1 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t12 STRAIGHT_JOIN t2 WHERE t12.c1=t2.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t12 STRAIGHT_JOIN t2 WHERE t12.c1=t2.c1; +c1 c1 +19930513 19930513 +19950414 19950414 +EXPLAIN SELECT * FROM t12 WHERE c1 IN (SELECT c1 FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t12 WHERE c1 IN (SELECT c1 FROM t2); +c1 +19930513 +19950414 +EXPLAIN SELECT * FROM t12 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t12 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t2); +c1 +19930513 +19950414 +EXPLAIN SELECT 1 FROM t12 WHERE (SELECT 1 FROM t12 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t2 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t12 WHERE (SELECT 1 FROM t12 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t2 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t12 STRAIGHT_JOIN t3 WHERE t12.c1=t3.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t12 STRAIGHT_JOIN t3 WHERE t12.c1=t3.c1; +c1 c1 +19950414 19950414.00 +19950414.1 19950414.10 +EXPLAIN SELECT * FROM t12 WHERE c1 IN (SELECT c1 FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t12 WHERE c1 IN (SELECT c1 FROM t3); +c1 +19950414 +19950414.1 +EXPLAIN SELECT * FROM t12 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t12 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t3); +c1 +19950414 +19950414.1 +EXPLAIN SELECT 1 FROM t12 WHERE (SELECT 1 FROM t12 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t3 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t12 WHERE (SELECT 1 FROM t12 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t3 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t12 STRAIGHT_JOIN t4 WHERE t12.c1=t4.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t12 STRAIGHT_JOIN t4 WHERE t12.c1=t4.c1; +c1 c1 +19950414 19950400 +19950414 19950400 +EXPLAIN SELECT * FROM t12 WHERE c1 IN (SELECT c1 FROM t4); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t12 WHERE c1 IN (SELECT c1 FROM t4); +c1 +19950414 +EXPLAIN SELECT * FROM t12 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t4); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t12 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t4); +c1 +19950414 +EXPLAIN SELECT 1 FROM t12 WHERE (SELECT 1 FROM t12 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t4 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t12 WHERE (SELECT 1 FROM t12 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t4 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t12 STRAIGHT_JOIN t5 WHERE t12.c1=t5.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t12 STRAIGHT_JOIN t5 WHERE t12.c1=t5.c1; +c1 c1 +19950414 19950414 +19950414.1 19950414.1 +EXPLAIN SELECT * FROM t12 WHERE c1 IN (SELECT c1 FROM t5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t12 WHERE c1 IN (SELECT c1 FROM t5); +c1 +19950414 +19950414.1 +EXPLAIN SELECT * FROM t12 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t12 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t5); +c1 +19950414 +19950414.1 +EXPLAIN SELECT 1 FROM t12 WHERE (SELECT 1 FROM t12 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t5 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t12 WHERE (SELECT 1 FROM t12 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t5 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t12 STRAIGHT_JOIN t6 WHERE t12.c1=t6.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t12 STRAIGHT_JOIN t6 WHERE t12.c1=t6.c1; +c1 c1 +19910111 19910111 +19930513 19930513 +19950414 19950414 +19950414.1 19950414.1 +20010513 20010513 +EXPLAIN SELECT * FROM t12 WHERE c1 IN (SELECT c1 FROM t6); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t12 WHERE c1 IN (SELECT c1 FROM t6); +c1 +19910111 +19930513 +19950414 +19950414.1 +20010513 +EXPLAIN SELECT * FROM t12 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t6); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t12 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t6); +c1 +19910111 +19930513 +19950414 +19950414.1 +20010513 +EXPLAIN SELECT 1 FROM t12 WHERE (SELECT 1 FROM t12 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t6 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t12 WHERE (SELECT 1 FROM t12 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t6 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t12 STRAIGHT_JOIN t7 WHERE t12.c1=t7.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t12 STRAIGHT_JOIN t7 WHERE t12.c1=t7.c1; +c1 c1 +19910111 19910111 +19930513 19930513 +19950414 19950414 +19950414.1 19950414.1 +20010513 20010513 +EXPLAIN SELECT * FROM t12 WHERE c1 IN (SELECT c1 FROM t7); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t12 WHERE c1 IN (SELECT c1 FROM t7); +c1 +19910111 +19930513 +19950414 +19950414.1 +20010513 +EXPLAIN SELECT * FROM t12 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t7); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t12 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t7); +c1 +19910111 +19930513 +19950414 +19950414.1 +20010513 +EXPLAIN SELECT 1 FROM t12 WHERE (SELECT 1 FROM t12 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t7 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t12 WHERE (SELECT 1 FROM t12 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t7 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t12 STRAIGHT_JOIN t8 WHERE t12.c1=t8.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t12 STRAIGHT_JOIN t8 WHERE t12.c1=t8.c1; +c1 c1 +EXPLAIN SELECT * FROM t12 WHERE c1 IN (SELECT c1 FROM t8); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t12 WHERE c1 IN (SELECT c1 FROM t8); +c1 +EXPLAIN SELECT * FROM t12 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t8); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t12 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t8); +c1 +EXPLAIN SELECT 1 FROM t12 WHERE (SELECT 1 FROM t12 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t8 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t12 WHERE (SELECT 1 FROM t12 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t8 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t12 STRAIGHT_JOIN t9 WHERE t12.c1=t9.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t12 STRAIGHT_JOIN t9 WHERE t12.c1=t9.c1; +c1 c1 +EXPLAIN SELECT * FROM t12 WHERE c1 IN (SELECT c1 FROM t9); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t12 WHERE c1 IN (SELECT c1 FROM t9); +c1 +EXPLAIN SELECT * FROM t12 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t9); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t12 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t9); +c1 +EXPLAIN SELECT 1 FROM t12 WHERE (SELECT 1 FROM t12 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t9 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t12 WHERE (SELECT 1 FROM t12 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t9 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t12 STRAIGHT_JOIN t10 WHERE t12.c1=t10.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t12 STRAIGHT_JOIN t10 WHERE t12.c1=t10.c1; +c1 c1 +EXPLAIN SELECT * FROM t12 WHERE c1 IN (SELECT c1 FROM t10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t12 WHERE c1 IN (SELECT c1 FROM t10); +c1 +EXPLAIN SELECT * FROM t12 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t12 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t10); +c1 +EXPLAIN SELECT 1 FROM t12 WHERE (SELECT 1 FROM t12 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t10 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t12 WHERE (SELECT 1 FROM t12 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t10 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t12 STRAIGHT_JOIN t11 WHERE t12.c1=t11.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t12 STRAIGHT_JOIN t11 WHERE t12.c1=t11.c1; +c1 c1 +EXPLAIN SELECT * FROM t12 WHERE c1 IN (SELECT c1 FROM t11); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t12 WHERE c1 IN (SELECT c1 FROM t11); +c1 +EXPLAIN SELECT * FROM t12 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t11); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t12 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t11); +c1 +EXPLAIN SELECT 1 FROM t12 WHERE (SELECT 1 FROM t12 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t11 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t12 WHERE (SELECT 1 FROM t12 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t11 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t12 STRAIGHT_JOIN t13 WHERE t12.c1=t13.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t12 STRAIGHT_JOIN t13 WHERE t12.c1=t13.c1; +c1 c1 +19950414 19950414 +EXPLAIN SELECT * FROM t12 WHERE c1 IN (SELECT c1 FROM t13); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t12 WHERE c1 IN (SELECT c1 FROM t13); +c1 +19950414 +EXPLAIN SELECT * FROM t12 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t13); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t12 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t13); +c1 +19950414 +EXPLAIN SELECT 1 FROM t12 WHERE (SELECT 1 FROM t12 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t13 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t12 WHERE (SELECT 1 FROM t12 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t13 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t13 STRAIGHT_JOIN t1 WHERE t13.c1=t1.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t13 STRAIGHT_JOIN t1 WHERE t13.c1=t1.c1; +c1 c1 +19950414 19950414 +EXPLAIN SELECT * FROM t13 WHERE c1 IN (SELECT c1 FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t13 WHERE c1 IN (SELECT c1 FROM t1); +c1 +19950414 +EXPLAIN SELECT * FROM t13 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t13 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t1); +c1 +19950414 +EXPLAIN SELECT 1 FROM t13 WHERE (SELECT 1 FROM t13 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t1 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t13 WHERE (SELECT 1 FROM t13 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t1 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t13 STRAIGHT_JOIN t2 WHERE t13.c1=t2.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t13 STRAIGHT_JOIN t2 WHERE t13.c1=t2.c1; +c1 c1 +19950414 19950414 +EXPLAIN SELECT * FROM t13 WHERE c1 IN (SELECT c1 FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t13 WHERE c1 IN (SELECT c1 FROM t2); +c1 +19950414 +EXPLAIN SELECT * FROM t13 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t13 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t2); +c1 +19950414 +EXPLAIN SELECT 1 FROM t13 WHERE (SELECT 1 FROM t13 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t2 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t13 WHERE (SELECT 1 FROM t13 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t2 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t13 STRAIGHT_JOIN t3 WHERE t13.c1=t3.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t13 STRAIGHT_JOIN t3 WHERE t13.c1=t3.c1; +c1 c1 +19950414 19950414.00 +EXPLAIN SELECT * FROM t13 WHERE c1 IN (SELECT c1 FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t13 WHERE c1 IN (SELECT c1 FROM t3); +c1 +19950414 +EXPLAIN SELECT * FROM t13 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t13 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t3); +c1 +19950414 +EXPLAIN SELECT 1 FROM t13 WHERE (SELECT 1 FROM t13 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t3 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t13 WHERE (SELECT 1 FROM t13 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t3 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t13 STRAIGHT_JOIN t4 WHERE t13.c1=t4.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t13 STRAIGHT_JOIN t4 WHERE t13.c1=t4.c1; +c1 c1 +19950414 19950400 +19950414 19950400 +EXPLAIN SELECT * FROM t13 WHERE c1 IN (SELECT c1 FROM t4); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t13 WHERE c1 IN (SELECT c1 FROM t4); +c1 +19950414 +EXPLAIN SELECT * FROM t13 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t4); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t13 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t4); +c1 +19950414 +EXPLAIN SELECT 1 FROM t13 WHERE (SELECT 1 FROM t13 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t4 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t13 WHERE (SELECT 1 FROM t13 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t4 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t13 STRAIGHT_JOIN t5 WHERE t13.c1=t5.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t13 STRAIGHT_JOIN t5 WHERE t13.c1=t5.c1; +c1 c1 +19950414 19950414 +EXPLAIN SELECT * FROM t13 WHERE c1 IN (SELECT c1 FROM t5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t13 WHERE c1 IN (SELECT c1 FROM t5); +c1 +19950414 +EXPLAIN SELECT * FROM t13 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t13 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t5); +c1 +19950414 +EXPLAIN SELECT 1 FROM t13 WHERE (SELECT 1 FROM t13 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t5 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t13 WHERE (SELECT 1 FROM t13 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t5 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t13 STRAIGHT_JOIN t6 WHERE t13.c1=t6.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t13 STRAIGHT_JOIN t6 WHERE t13.c1=t6.c1; +c1 c1 +19950414 19950414 +EXPLAIN SELECT * FROM t13 WHERE c1 IN (SELECT c1 FROM t6); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t13 WHERE c1 IN (SELECT c1 FROM t6); +c1 +19950414 +EXPLAIN SELECT * FROM t13 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t6); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t13 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t6); +c1 +19950414 +EXPLAIN SELECT 1 FROM t13 WHERE (SELECT 1 FROM t13 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t6 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t13 WHERE (SELECT 1 FROM t13 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t6 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t13 STRAIGHT_JOIN t7 WHERE t13.c1=t7.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t13 STRAIGHT_JOIN t7 WHERE t13.c1=t7.c1; +c1 c1 +19950414 19950414 +EXPLAIN SELECT * FROM t13 WHERE c1 IN (SELECT c1 FROM t7); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t13 WHERE c1 IN (SELECT c1 FROM t7); +c1 +19950414 +EXPLAIN SELECT * FROM t13 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t7); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t13 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t7); +c1 +19950414 +EXPLAIN SELECT 1 FROM t13 WHERE (SELECT 1 FROM t13 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t7 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t13 WHERE (SELECT 1 FROM t13 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t7 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t13 STRAIGHT_JOIN t8 WHERE t13.c1=t8.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t13 STRAIGHT_JOIN t8 WHERE t13.c1=t8.c1; +c1 c1 +EXPLAIN SELECT * FROM t13 WHERE c1 IN (SELECT c1 FROM t8); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t13 WHERE c1 IN (SELECT c1 FROM t8); +c1 +EXPLAIN SELECT * FROM t13 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t8); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t13 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t8); +c1 +EXPLAIN SELECT 1 FROM t13 WHERE (SELECT 1 FROM t13 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t8 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t13 WHERE (SELECT 1 FROM t13 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t8 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t13 STRAIGHT_JOIN t9 WHERE t13.c1=t9.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t13 STRAIGHT_JOIN t9 WHERE t13.c1=t9.c1; +c1 c1 +EXPLAIN SELECT * FROM t13 WHERE c1 IN (SELECT c1 FROM t9); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t13 WHERE c1 IN (SELECT c1 FROM t9); +c1 +EXPLAIN SELECT * FROM t13 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t9); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t13 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t9); +c1 +EXPLAIN SELECT 1 FROM t13 WHERE (SELECT 1 FROM t13 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t9 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t13 WHERE (SELECT 1 FROM t13 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t9 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t13 STRAIGHT_JOIN t10 WHERE t13.c1=t10.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t13 STRAIGHT_JOIN t10 WHERE t13.c1=t10.c1; +c1 c1 +EXPLAIN SELECT * FROM t13 WHERE c1 IN (SELECT c1 FROM t10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t13 WHERE c1 IN (SELECT c1 FROM t10); +c1 +EXPLAIN SELECT * FROM t13 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t13 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t10); +c1 +EXPLAIN SELECT 1 FROM t13 WHERE (SELECT 1 FROM t13 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t10 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t13 WHERE (SELECT 1 FROM t13 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t10 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t13 STRAIGHT_JOIN t11 WHERE t13.c1=t11.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t13 STRAIGHT_JOIN t11 WHERE t13.c1=t11.c1; +c1 c1 +EXPLAIN SELECT * FROM t13 WHERE c1 IN (SELECT c1 FROM t11); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t13 WHERE c1 IN (SELECT c1 FROM t11); +c1 +EXPLAIN SELECT * FROM t13 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t11); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t13 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t11); +c1 +EXPLAIN SELECT 1 FROM t13 WHERE (SELECT 1 FROM t13 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t11 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t13 WHERE (SELECT 1 FROM t13 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t11 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t13 STRAIGHT_JOIN t12 WHERE t13.c1=t12.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t13 STRAIGHT_JOIN t12 WHERE t13.c1=t12.c1; +c1 c1 +19950414 19950414 +EXPLAIN SELECT * FROM t13 WHERE c1 IN (SELECT c1 FROM t12); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t13 WHERE c1 IN (SELECT c1 FROM t12); +c1 +19950414 +EXPLAIN SELECT * FROM t13 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t12); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t13 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t12); +c1 +19950414 +EXPLAIN SELECT 1 FROM t13 WHERE (SELECT 1 FROM t13 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t12 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t13 WHERE (SELECT 1 FROM t13 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t12 WHERE ASCII(c1) = 50); +1 +SET TIMESTAMP=UNIX_TIMESTAMP(20140413000000); +EXPLAIN SELECT * FROM t8 STRAIGHT_JOIN t9 WHERE t8.c1=t9.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t8 STRAIGHT_JOIN t9 WHERE t8.c1=t9.c1; +c1 c1 +EXPLAIN SELECT * FROM t8 WHERE c1 IN (SELECT c1 FROM t9); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t8 WHERE c1 IN (SELECT c1 FROM t9); +c1 +EXPLAIN SELECT * FROM t9 STRAIGHT_JOIN t8 WHERE t9.c1=t8.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t9 STRAIGHT_JOIN t8 WHERE t9.c1=t8.c1; +c1 c1 +EXPLAIN SELECT * FROM t9 WHERE c1 IN (SELECT c1 FROM t8); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t9 WHERE c1 IN (SELECT c1 FROM t8); +c1 +set optimizer_switch='semijoin=on,firstmatch=off,loosescan=off,duplicateweedout=off,materialization=on,subquery_materialization_cost_based=off'; +SET TIMESTAMP=UNIX_TIMESTAMP(20150413000000); +EXPLAIN SELECT * FROM t1 STRAIGHT_JOIN t2 WHERE t1.c1=t2.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t1 STRAIGHT_JOIN t2 WHERE t1.c1=t2.c1; +c1 c1 +19930513 19930513 +19950414 19950414 +EXPLAIN SELECT * FROM t1 WHERE c1 IN (SELECT c1 FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# MATERIALIZED # # # # # # # # # # +SELECT * FROM t1 WHERE c1 IN (SELECT c1 FROM t2); +c1 +19930513 +19950414 +EXPLAIN SELECT * FROM t1 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t1 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t2); +c1 +19930513 +19950414 +EXPLAIN SELECT 1 FROM t1 WHERE (SELECT 1 FROM t1 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t2 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t1 WHERE (SELECT 1 FROM t1 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t2 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t1 STRAIGHT_JOIN t3 WHERE t1.c1=t3.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t1 STRAIGHT_JOIN t3 WHERE t1.c1=t3.c1; +c1 c1 +19950414 19950414.00 +EXPLAIN SELECT * FROM t1 WHERE c1 IN (SELECT c1 FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# MATERIALIZED # # # # # # # # # # +SELECT * FROM t1 WHERE c1 IN (SELECT c1 FROM t3); +c1 +19950414 +EXPLAIN SELECT * FROM t1 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t1 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t3); +c1 +19950414 +EXPLAIN SELECT 1 FROM t1 WHERE (SELECT 1 FROM t1 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t3 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t1 WHERE (SELECT 1 FROM t1 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t3 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t1 STRAIGHT_JOIN t4 WHERE t1.c1=t4.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t1 STRAIGHT_JOIN t4 WHERE t1.c1=t4.c1; +c1 c1 +19950414 19950400 +19950414 19950400 +EXPLAIN SELECT * FROM t1 WHERE c1 IN (SELECT c1 FROM t4); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# MATERIALIZED # # # # # # # # # # +SELECT * FROM t1 WHERE c1 IN (SELECT c1 FROM t4); +c1 +19950414 +EXPLAIN SELECT * FROM t1 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t4); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t1 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t4); +c1 +19950414 +EXPLAIN SELECT 1 FROM t1 WHERE (SELECT 1 FROM t1 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t4 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t1 WHERE (SELECT 1 FROM t1 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t4 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t1 STRAIGHT_JOIN t5 WHERE t1.c1=t5.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t1 STRAIGHT_JOIN t5 WHERE t1.c1=t5.c1; +c1 c1 +19950414 19950414 +EXPLAIN SELECT * FROM t1 WHERE c1 IN (SELECT c1 FROM t5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# MATERIALIZED # # # # # # # # # # +SELECT * FROM t1 WHERE c1 IN (SELECT c1 FROM t5); +c1 +19950414 +EXPLAIN SELECT * FROM t1 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t1 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t5); +c1 +19950414 +EXPLAIN SELECT 1 FROM t1 WHERE (SELECT 1 FROM t1 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t5 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t1 WHERE (SELECT 1 FROM t1 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t5 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t1 STRAIGHT_JOIN t6 WHERE t1.c1=t6.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t1 STRAIGHT_JOIN t6 WHERE t1.c1=t6.c1; +c1 c1 +19930513 19930513 +19950414 19950414 +EXPLAIN SELECT * FROM t1 WHERE c1 IN (SELECT c1 FROM t6); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t1 WHERE c1 IN (SELECT c1 FROM t6); +c1 +19930513 +19950414 +EXPLAIN SELECT * FROM t1 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t6); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t1 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t6); +c1 +19930513 +19950414 +EXPLAIN SELECT 1 FROM t1 WHERE (SELECT 1 FROM t1 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t6 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t1 WHERE (SELECT 1 FROM t1 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t6 WHERE ASCII(c1) = 50); +1 +1 +1 +1 +1 +1 +1 +EXPLAIN SELECT * FROM t1 STRAIGHT_JOIN t7 WHERE t1.c1=t7.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t1 STRAIGHT_JOIN t7 WHERE t1.c1=t7.c1; +c1 c1 +19930513 19930513 +19950414 19950414 +EXPLAIN SELECT * FROM t1 WHERE c1 IN (SELECT c1 FROM t7); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t1 WHERE c1 IN (SELECT c1 FROM t7); +c1 +19930513 +19950414 +EXPLAIN SELECT * FROM t1 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t7); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t1 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t7); +c1 +19930513 +19950414 +EXPLAIN SELECT 1 FROM t1 WHERE (SELECT 1 FROM t1 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t7 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t1 WHERE (SELECT 1 FROM t1 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t7 WHERE ASCII(c1) = 50); +1 +1 +1 +1 +1 +1 +1 +EXPLAIN SELECT * FROM t1 STRAIGHT_JOIN t8 WHERE t1.c1=t8.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t1 STRAIGHT_JOIN t8 WHERE t1.c1=t8.c1; +c1 c1 +EXPLAIN SELECT * FROM t1 WHERE c1 IN (SELECT c1 FROM t8); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t1 WHERE c1 IN (SELECT c1 FROM t8); +c1 +EXPLAIN SELECT * FROM t1 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t8); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t1 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t8); +c1 +EXPLAIN SELECT 1 FROM t1 WHERE (SELECT 1 FROM t1 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t8 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t1 WHERE (SELECT 1 FROM t1 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t8 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t1 STRAIGHT_JOIN t9 WHERE t1.c1=t9.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t1 STRAIGHT_JOIN t9 WHERE t1.c1=t9.c1; +c1 c1 +EXPLAIN SELECT * FROM t1 WHERE c1 IN (SELECT c1 FROM t9); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t1 WHERE c1 IN (SELECT c1 FROM t9); +c1 +EXPLAIN SELECT * FROM t1 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t9); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t1 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t9); +c1 +EXPLAIN SELECT 1 FROM t1 WHERE (SELECT 1 FROM t1 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t9 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t1 WHERE (SELECT 1 FROM t1 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t9 WHERE ASCII(c1) = 50); +1 +1 +1 +1 +1 +1 +1 +EXPLAIN SELECT * FROM t1 STRAIGHT_JOIN t10 WHERE t1.c1=t10.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t1 STRAIGHT_JOIN t10 WHERE t1.c1=t10.c1; +c1 c1 +EXPLAIN SELECT * FROM t1 WHERE c1 IN (SELECT c1 FROM t10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t1 WHERE c1 IN (SELECT c1 FROM t10); +c1 +EXPLAIN SELECT * FROM t1 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t1 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t10); +c1 +EXPLAIN SELECT 1 FROM t1 WHERE (SELECT 1 FROM t1 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t10 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t1 WHERE (SELECT 1 FROM t1 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t10 WHERE ASCII(c1) = 50); +1 +1 +1 +1 +1 +1 +1 +EXPLAIN SELECT * FROM t1 STRAIGHT_JOIN t11 WHERE t1.c1=t11.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t1 STRAIGHT_JOIN t11 WHERE t1.c1=t11.c1; +c1 c1 +EXPLAIN SELECT * FROM t1 WHERE c1 IN (SELECT c1 FROM t11); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t1 WHERE c1 IN (SELECT c1 FROM t11); +c1 +EXPLAIN SELECT * FROM t1 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t11); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t1 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t11); +c1 +EXPLAIN SELECT 1 FROM t1 WHERE (SELECT 1 FROM t1 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t11 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t1 WHERE (SELECT 1 FROM t1 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t11 WHERE ASCII(c1) = 50); +1 +1 +1 +1 +1 +1 +1 +EXPLAIN SELECT * FROM t1 STRAIGHT_JOIN t12 WHERE t1.c1=t12.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t1 STRAIGHT_JOIN t12 WHERE t1.c1=t12.c1; +c1 c1 +19930513 19930513 +19950414 19950414 +EXPLAIN SELECT * FROM t1 WHERE c1 IN (SELECT c1 FROM t12); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t1 WHERE c1 IN (SELECT c1 FROM t12); +c1 +19930513 +19950414 +EXPLAIN SELECT * FROM t1 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t12); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t1 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t12); +c1 +19930513 +19950414 +EXPLAIN SELECT 1 FROM t1 WHERE (SELECT 1 FROM t1 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t12 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t1 WHERE (SELECT 1 FROM t1 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t12 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t1 STRAIGHT_JOIN t13 WHERE t1.c1=t13.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t1 STRAIGHT_JOIN t13 WHERE t1.c1=t13.c1; +c1 c1 +19950414 19950414 +EXPLAIN SELECT * FROM t1 WHERE c1 IN (SELECT c1 FROM t13); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# MATERIALIZED # # # # # # # # # # +SELECT * FROM t1 WHERE c1 IN (SELECT c1 FROM t13); +c1 +19950414 +EXPLAIN SELECT * FROM t1 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t13); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t1 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t13); +c1 +19950414 +EXPLAIN SELECT 1 FROM t1 WHERE (SELECT 1 FROM t1 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t13 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t1 WHERE (SELECT 1 FROM t1 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t13 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t2 STRAIGHT_JOIN t1 WHERE t2.c1=t1.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t2 STRAIGHT_JOIN t1 WHERE t2.c1=t1.c1; +c1 c1 +19930513 19930513 +19950414 19950414 +EXPLAIN SELECT * FROM t2 WHERE c1 IN (SELECT c1 FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# MATERIALIZED # # # # # # # # # # +SELECT * FROM t2 WHERE c1 IN (SELECT c1 FROM t1); +c1 +19930513 +19950414 +EXPLAIN SELECT * FROM t2 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t2 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t1); +c1 +19930513 +19950414 +EXPLAIN SELECT 1 FROM t2 WHERE (SELECT 1 FROM t2 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t1 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t2 WHERE (SELECT 1 FROM t2 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t1 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t2 STRAIGHT_JOIN t3 WHERE t2.c1=t3.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t2 STRAIGHT_JOIN t3 WHERE t2.c1=t3.c1; +c1 c1 +19950414 19950414.00 +EXPLAIN SELECT * FROM t2 WHERE c1 IN (SELECT c1 FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# MATERIALIZED # # # # # # # # # # +SELECT * FROM t2 WHERE c1 IN (SELECT c1 FROM t3); +c1 +19950414 +EXPLAIN SELECT * FROM t2 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t2 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t3); +c1 +19950414 +EXPLAIN SELECT 1 FROM t2 WHERE (SELECT 1 FROM t2 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t3 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t2 WHERE (SELECT 1 FROM t2 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t3 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t2 STRAIGHT_JOIN t4 WHERE t2.c1=t4.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t2 STRAIGHT_JOIN t4 WHERE t2.c1=t4.c1; +c1 c1 +19950414 19950400 +19950414 19950400 +EXPLAIN SELECT * FROM t2 WHERE c1 IN (SELECT c1 FROM t4); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# MATERIALIZED # # # # # # # # # # +SELECT * FROM t2 WHERE c1 IN (SELECT c1 FROM t4); +c1 +19950414 +EXPLAIN SELECT * FROM t2 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t4); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t2 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t4); +c1 +19950414 +EXPLAIN SELECT 1 FROM t2 WHERE (SELECT 1 FROM t2 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t4 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t2 WHERE (SELECT 1 FROM t2 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t4 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t2 STRAIGHT_JOIN t5 WHERE t2.c1=t5.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t2 STRAIGHT_JOIN t5 WHERE t2.c1=t5.c1; +c1 c1 +19950414 19950414 +EXPLAIN SELECT * FROM t2 WHERE c1 IN (SELECT c1 FROM t5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# MATERIALIZED # # # # # # # # # # +SELECT * FROM t2 WHERE c1 IN (SELECT c1 FROM t5); +c1 +19950414 +EXPLAIN SELECT * FROM t2 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t2 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t5); +c1 +19950414 +EXPLAIN SELECT 1 FROM t2 WHERE (SELECT 1 FROM t2 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t5 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t2 WHERE (SELECT 1 FROM t2 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t5 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t2 STRAIGHT_JOIN t6 WHERE t2.c1=t6.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t2 STRAIGHT_JOIN t6 WHERE t2.c1=t6.c1; +c1 c1 +19930513 19930513 +19950414 19950414 +EXPLAIN SELECT * FROM t2 WHERE c1 IN (SELECT c1 FROM t6); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t2 WHERE c1 IN (SELECT c1 FROM t6); +c1 +19930513 +19950414 +EXPLAIN SELECT * FROM t2 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t6); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t2 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t6); +c1 +19930513 +19950414 +EXPLAIN SELECT 1 FROM t2 WHERE (SELECT 1 FROM t2 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t6 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t2 WHERE (SELECT 1 FROM t2 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t6 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t2 STRAIGHT_JOIN t7 WHERE t2.c1=t7.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t2 STRAIGHT_JOIN t7 WHERE t2.c1=t7.c1; +c1 c1 +19930513 19930513 +19950414 19950414 +EXPLAIN SELECT * FROM t2 WHERE c1 IN (SELECT c1 FROM t7); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t2 WHERE c1 IN (SELECT c1 FROM t7); +c1 +19930513 +19950414 +EXPLAIN SELECT * FROM t2 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t7); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t2 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t7); +c1 +19930513 +19950414 +EXPLAIN SELECT 1 FROM t2 WHERE (SELECT 1 FROM t2 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t7 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t2 WHERE (SELECT 1 FROM t2 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t7 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t2 STRAIGHT_JOIN t8 WHERE t2.c1=t8.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t2 STRAIGHT_JOIN t8 WHERE t2.c1=t8.c1; +c1 c1 +EXPLAIN SELECT * FROM t2 WHERE c1 IN (SELECT c1 FROM t8); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t2 WHERE c1 IN (SELECT c1 FROM t8); +c1 +EXPLAIN SELECT * FROM t2 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t8); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t2 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t8); +c1 +EXPLAIN SELECT 1 FROM t2 WHERE (SELECT 1 FROM t2 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t8 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t2 WHERE (SELECT 1 FROM t2 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t8 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t2 STRAIGHT_JOIN t9 WHERE t2.c1=t9.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t2 STRAIGHT_JOIN t9 WHERE t2.c1=t9.c1; +c1 c1 +EXPLAIN SELECT * FROM t2 WHERE c1 IN (SELECT c1 FROM t9); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t2 WHERE c1 IN (SELECT c1 FROM t9); +c1 +EXPLAIN SELECT * FROM t2 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t9); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t2 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t9); +c1 +EXPLAIN SELECT 1 FROM t2 WHERE (SELECT 1 FROM t2 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t9 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t2 WHERE (SELECT 1 FROM t2 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t9 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t2 STRAIGHT_JOIN t10 WHERE t2.c1=t10.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t2 STRAIGHT_JOIN t10 WHERE t2.c1=t10.c1; +c1 c1 +EXPLAIN SELECT * FROM t2 WHERE c1 IN (SELECT c1 FROM t10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t2 WHERE c1 IN (SELECT c1 FROM t10); +c1 +EXPLAIN SELECT * FROM t2 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t2 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t10); +c1 +EXPLAIN SELECT 1 FROM t2 WHERE (SELECT 1 FROM t2 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t10 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t2 WHERE (SELECT 1 FROM t2 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t10 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t2 STRAIGHT_JOIN t11 WHERE t2.c1=t11.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t2 STRAIGHT_JOIN t11 WHERE t2.c1=t11.c1; +c1 c1 +EXPLAIN SELECT * FROM t2 WHERE c1 IN (SELECT c1 FROM t11); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t2 WHERE c1 IN (SELECT c1 FROM t11); +c1 +EXPLAIN SELECT * FROM t2 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t11); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t2 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t11); +c1 +EXPLAIN SELECT 1 FROM t2 WHERE (SELECT 1 FROM t2 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t11 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t2 WHERE (SELECT 1 FROM t2 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t11 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t2 STRAIGHT_JOIN t12 WHERE t2.c1=t12.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t2 STRAIGHT_JOIN t12 WHERE t2.c1=t12.c1; +c1 c1 +19930513 19930513 +19950414 19950414 +EXPLAIN SELECT * FROM t2 WHERE c1 IN (SELECT c1 FROM t12); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t2 WHERE c1 IN (SELECT c1 FROM t12); +c1 +19930513 +19950414 +EXPLAIN SELECT * FROM t2 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t12); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t2 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t12); +c1 +19930513 +19950414 +EXPLAIN SELECT 1 FROM t2 WHERE (SELECT 1 FROM t2 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t12 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t2 WHERE (SELECT 1 FROM t2 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t12 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t2 STRAIGHT_JOIN t13 WHERE t2.c1=t13.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t2 STRAIGHT_JOIN t13 WHERE t2.c1=t13.c1; +c1 c1 +19950414 19950414 +EXPLAIN SELECT * FROM t2 WHERE c1 IN (SELECT c1 FROM t13); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# MATERIALIZED # # # # # # # # # # +SELECT * FROM t2 WHERE c1 IN (SELECT c1 FROM t13); +c1 +19950414 +EXPLAIN SELECT * FROM t2 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t13); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t2 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t13); +c1 +19950414 +EXPLAIN SELECT 1 FROM t2 WHERE (SELECT 1 FROM t2 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t13 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t2 WHERE (SELECT 1 FROM t2 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t13 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t3 STRAIGHT_JOIN t1 WHERE t3.c1=t1.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t3 STRAIGHT_JOIN t1 WHERE t3.c1=t1.c1; +c1 c1 +19950414.00 19950414 +EXPLAIN SELECT * FROM t3 WHERE c1 IN (SELECT c1 FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# MATERIALIZED # # # # # # # # # # +SELECT * FROM t3 WHERE c1 IN (SELECT c1 FROM t1); +c1 +19950414.00 +EXPLAIN SELECT * FROM t3 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t3 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t1); +c1 +19950414.00 +EXPLAIN SELECT 1 FROM t3 WHERE (SELECT 1 FROM t3 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t1 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t3 WHERE (SELECT 1 FROM t3 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t1 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t3 STRAIGHT_JOIN t2 WHERE t3.c1=t2.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t3 STRAIGHT_JOIN t2 WHERE t3.c1=t2.c1; +c1 c1 +19950414.00 19950414 +EXPLAIN SELECT * FROM t3 WHERE c1 IN (SELECT c1 FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# MATERIALIZED # # # # # # # # # # +SELECT * FROM t3 WHERE c1 IN (SELECT c1 FROM t2); +c1 +19950414.00 +EXPLAIN SELECT * FROM t3 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t3 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t2); +c1 +19950414.00 +EXPLAIN SELECT 1 FROM t3 WHERE (SELECT 1 FROM t3 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t2 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t3 WHERE (SELECT 1 FROM t3 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t2 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t3 STRAIGHT_JOIN t4 WHERE t3.c1=t4.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t3 STRAIGHT_JOIN t4 WHERE t3.c1=t4.c1; +c1 c1 +19950414.00 19950400 +19950414.00 19950400 +EXPLAIN SELECT * FROM t3 WHERE c1 IN (SELECT c1 FROM t4); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# MATERIALIZED # # # # # # # # # # +SELECT * FROM t3 WHERE c1 IN (SELECT c1 FROM t4); +c1 +19950414.00 +EXPLAIN SELECT * FROM t3 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t4); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t3 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t4); +c1 +19950414.00 +EXPLAIN SELECT 1 FROM t3 WHERE (SELECT 1 FROM t3 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t4 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t3 WHERE (SELECT 1 FROM t3 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t4 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t3 STRAIGHT_JOIN t5 WHERE t3.c1=t5.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t3 STRAIGHT_JOIN t5 WHERE t3.c1=t5.c1; +c1 c1 +19930513.30 19930513.3 +19950414.00 19950414 +19950414.10 19950414.1 +EXPLAIN SELECT * FROM t3 WHERE c1 IN (SELECT c1 FROM t5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# MATERIALIZED # # # # # # # # # # +SELECT * FROM t3 WHERE c1 IN (SELECT c1 FROM t5); +c1 +19930513.30 +19950414.00 +19950414.10 +EXPLAIN SELECT * FROM t3 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t3 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t5); +c1 +19930513.30 +19950414.00 +19950414.10 +EXPLAIN SELECT 1 FROM t3 WHERE (SELECT 1 FROM t3 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t5 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t3 WHERE (SELECT 1 FROM t3 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t5 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t3 STRAIGHT_JOIN t6 WHERE t3.c1=t6.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t3 STRAIGHT_JOIN t6 WHERE t3.c1=t6.c1; +c1 c1 +19950414.00 19950414 +19950414.10 19950414.1 +EXPLAIN SELECT * FROM t3 WHERE c1 IN (SELECT c1 FROM t6); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t3 WHERE c1 IN (SELECT c1 FROM t6); +c1 +19950414.00 +19950414.10 +EXPLAIN SELECT * FROM t3 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t6); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t3 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t6); +c1 +19950414.00 +19950414.10 +EXPLAIN SELECT 1 FROM t3 WHERE (SELECT 1 FROM t3 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t6 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t3 WHERE (SELECT 1 FROM t3 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t6 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t3 STRAIGHT_JOIN t7 WHERE t3.c1=t7.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t3 STRAIGHT_JOIN t7 WHERE t3.c1=t7.c1; +c1 c1 +19950414.00 19950414 +19950414.10 19950414.1 +EXPLAIN SELECT * FROM t3 WHERE c1 IN (SELECT c1 FROM t7); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t3 WHERE c1 IN (SELECT c1 FROM t7); +c1 +19950414.00 +19950414.10 +EXPLAIN SELECT * FROM t3 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t7); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t3 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t7); +c1 +19950414.00 +19950414.10 +EXPLAIN SELECT 1 FROM t3 WHERE (SELECT 1 FROM t3 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t7 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t3 WHERE (SELECT 1 FROM t3 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t7 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t3 STRAIGHT_JOIN t8 WHERE t3.c1=t8.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t3 STRAIGHT_JOIN t8 WHERE t3.c1=t8.c1; +c1 c1 +EXPLAIN SELECT * FROM t3 WHERE c1 IN (SELECT c1 FROM t8); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t3 WHERE c1 IN (SELECT c1 FROM t8); +c1 +EXPLAIN SELECT * FROM t3 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t8); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t3 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t8); +c1 +EXPLAIN SELECT 1 FROM t3 WHERE (SELECT 1 FROM t3 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t8 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t3 WHERE (SELECT 1 FROM t3 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t8 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t3 STRAIGHT_JOIN t9 WHERE t3.c1=t9.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t3 STRAIGHT_JOIN t9 WHERE t3.c1=t9.c1; +c1 c1 +EXPLAIN SELECT * FROM t3 WHERE c1 IN (SELECT c1 FROM t9); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t3 WHERE c1 IN (SELECT c1 FROM t9); +c1 +EXPLAIN SELECT * FROM t3 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t9); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t3 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t9); +c1 +EXPLAIN SELECT 1 FROM t3 WHERE (SELECT 1 FROM t3 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t9 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t3 WHERE (SELECT 1 FROM t3 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t9 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t3 STRAIGHT_JOIN t10 WHERE t3.c1=t10.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t3 STRAIGHT_JOIN t10 WHERE t3.c1=t10.c1; +c1 c1 +EXPLAIN SELECT * FROM t3 WHERE c1 IN (SELECT c1 FROM t10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t3 WHERE c1 IN (SELECT c1 FROM t10); +c1 +EXPLAIN SELECT * FROM t3 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t3 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t10); +c1 +EXPLAIN SELECT 1 FROM t3 WHERE (SELECT 1 FROM t3 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t10 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t3 WHERE (SELECT 1 FROM t3 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t10 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t3 STRAIGHT_JOIN t11 WHERE t3.c1=t11.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t3 STRAIGHT_JOIN t11 WHERE t3.c1=t11.c1; +c1 c1 +EXPLAIN SELECT * FROM t3 WHERE c1 IN (SELECT c1 FROM t11); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t3 WHERE c1 IN (SELECT c1 FROM t11); +c1 +EXPLAIN SELECT * FROM t3 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t11); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t3 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t11); +c1 +EXPLAIN SELECT 1 FROM t3 WHERE (SELECT 1 FROM t3 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t11 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t3 WHERE (SELECT 1 FROM t3 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t11 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t3 STRAIGHT_JOIN t12 WHERE t3.c1=t12.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t3 STRAIGHT_JOIN t12 WHERE t3.c1=t12.c1; +c1 c1 +19950414.00 19950414 +19950414.10 19950414.1 +EXPLAIN SELECT * FROM t3 WHERE c1 IN (SELECT c1 FROM t12); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t3 WHERE c1 IN (SELECT c1 FROM t12); +c1 +19950414.00 +19950414.10 +EXPLAIN SELECT * FROM t3 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t12); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t3 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t12); +c1 +19950414.00 +19950414.10 +EXPLAIN SELECT 1 FROM t3 WHERE (SELECT 1 FROM t3 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t12 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t3 WHERE (SELECT 1 FROM t3 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t12 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t3 STRAIGHT_JOIN t13 WHERE t3.c1=t13.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t3 STRAIGHT_JOIN t13 WHERE t3.c1=t13.c1; +c1 c1 +19950414.00 19950414 +EXPLAIN SELECT * FROM t3 WHERE c1 IN (SELECT c1 FROM t13); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# MATERIALIZED # # # # # # # # # # +SELECT * FROM t3 WHERE c1 IN (SELECT c1 FROM t13); +c1 +19950414.00 +EXPLAIN SELECT * FROM t3 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t13); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t3 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t13); +c1 +19950414.00 +EXPLAIN SELECT 1 FROM t3 WHERE (SELECT 1 FROM t3 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t13 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t3 WHERE (SELECT 1 FROM t3 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t13 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t4 STRAIGHT_JOIN t1 WHERE t4.c1=t1.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t4 STRAIGHT_JOIN t1 WHERE t4.c1=t1.c1; +c1 c1 +19950400 19950414 +19950400 19950414 +EXPLAIN SELECT * FROM t4 WHERE c1 IN (SELECT c1 FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# MATERIALIZED # # # # # # # # # # +SELECT * FROM t4 WHERE c1 IN (SELECT c1 FROM t1); +c1 +19950400 +19950400 +EXPLAIN SELECT * FROM t4 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t4 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t1); +c1 +19950400 +EXPLAIN SELECT 1 FROM t4 WHERE (SELECT 1 FROM t4 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t1 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t4 WHERE (SELECT 1 FROM t4 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t1 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t4 STRAIGHT_JOIN t2 WHERE t4.c1=t2.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t4 STRAIGHT_JOIN t2 WHERE t4.c1=t2.c1; +c1 c1 +19950400 19950414 +19950400 19950414 +EXPLAIN SELECT * FROM t4 WHERE c1 IN (SELECT c1 FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# MATERIALIZED # # # # # # # # # # +SELECT * FROM t4 WHERE c1 IN (SELECT c1 FROM t2); +c1 +19950400 +19950400 +EXPLAIN SELECT * FROM t4 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t4 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t2); +c1 +19950400 +EXPLAIN SELECT 1 FROM t4 WHERE (SELECT 1 FROM t4 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t2 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t4 WHERE (SELECT 1 FROM t4 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t2 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t4 STRAIGHT_JOIN t3 WHERE t4.c1=t3.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t4 STRAIGHT_JOIN t3 WHERE t4.c1=t3.c1; +c1 c1 +19950400 19950414.00 +19950400 19950414.00 +EXPLAIN SELECT * FROM t4 WHERE c1 IN (SELECT c1 FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# MATERIALIZED # # # # # # # # # # +SELECT * FROM t4 WHERE c1 IN (SELECT c1 FROM t3); +c1 +19950400 +19950400 +EXPLAIN SELECT * FROM t4 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t4 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t3); +c1 +19950400 +EXPLAIN SELECT 1 FROM t4 WHERE (SELECT 1 FROM t4 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t3 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t4 WHERE (SELECT 1 FROM t4 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t3 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t4 STRAIGHT_JOIN t5 WHERE t4.c1=t5.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t4 STRAIGHT_JOIN t5 WHERE t4.c1=t5.c1; +c1 c1 +19950400 19950414 +19950400 19950414 +EXPLAIN SELECT * FROM t4 WHERE c1 IN (SELECT c1 FROM t5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# MATERIALIZED # # # # # # # # # # +SELECT * FROM t4 WHERE c1 IN (SELECT c1 FROM t5); +c1 +19950400 +19950400 +EXPLAIN SELECT * FROM t4 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t4 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t5); +c1 +19950400 +EXPLAIN SELECT 1 FROM t4 WHERE (SELECT 1 FROM t4 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t5 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t4 WHERE (SELECT 1 FROM t4 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t5 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t4 STRAIGHT_JOIN t6 WHERE t4.c1=t6.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t4 STRAIGHT_JOIN t6 WHERE t4.c1=t6.c1; +c1 c1 +19950400 19950414 +19950400 19950414 +EXPLAIN SELECT * FROM t4 WHERE c1 IN (SELECT c1 FROM t6); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t4 WHERE c1 IN (SELECT c1 FROM t6); +c1 +19950400 +19950400 +EXPLAIN SELECT * FROM t4 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t6); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t4 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t6); +c1 +19950400 +EXPLAIN SELECT 1 FROM t4 WHERE (SELECT 1 FROM t4 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t6 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t4 WHERE (SELECT 1 FROM t4 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t6 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t4 STRAIGHT_JOIN t7 WHERE t4.c1=t7.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t4 STRAIGHT_JOIN t7 WHERE t4.c1=t7.c1; +c1 c1 +19950400 19950414 +19950400 19950414 +EXPLAIN SELECT * FROM t4 WHERE c1 IN (SELECT c1 FROM t7); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t4 WHERE c1 IN (SELECT c1 FROM t7); +c1 +19950400 +19950400 +EXPLAIN SELECT * FROM t4 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t7); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t4 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t7); +c1 +19950400 +EXPLAIN SELECT 1 FROM t4 WHERE (SELECT 1 FROM t4 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t7 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t4 WHERE (SELECT 1 FROM t4 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t7 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t4 STRAIGHT_JOIN t8 WHERE t4.c1=t8.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t4 STRAIGHT_JOIN t8 WHERE t4.c1=t8.c1; +c1 c1 +EXPLAIN SELECT * FROM t4 WHERE c1 IN (SELECT c1 FROM t8); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t4 WHERE c1 IN (SELECT c1 FROM t8); +c1 +EXPLAIN SELECT * FROM t4 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t8); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t4 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t8); +c1 +EXPLAIN SELECT 1 FROM t4 WHERE (SELECT 1 FROM t4 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t8 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t4 WHERE (SELECT 1 FROM t4 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t8 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t4 STRAIGHT_JOIN t9 WHERE t4.c1=t9.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t4 STRAIGHT_JOIN t9 WHERE t4.c1=t9.c1; +c1 c1 +EXPLAIN SELECT * FROM t4 WHERE c1 IN (SELECT c1 FROM t9); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t4 WHERE c1 IN (SELECT c1 FROM t9); +c1 +EXPLAIN SELECT * FROM t4 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t9); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t4 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t9); +c1 +EXPLAIN SELECT 1 FROM t4 WHERE (SELECT 1 FROM t4 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t9 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t4 WHERE (SELECT 1 FROM t4 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t9 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t4 STRAIGHT_JOIN t10 WHERE t4.c1=t10.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t4 STRAIGHT_JOIN t10 WHERE t4.c1=t10.c1; +c1 c1 +EXPLAIN SELECT * FROM t4 WHERE c1 IN (SELECT c1 FROM t10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t4 WHERE c1 IN (SELECT c1 FROM t10); +c1 +EXPLAIN SELECT * FROM t4 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t4 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t10); +c1 +EXPLAIN SELECT 1 FROM t4 WHERE (SELECT 1 FROM t4 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t10 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t4 WHERE (SELECT 1 FROM t4 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t10 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t4 STRAIGHT_JOIN t11 WHERE t4.c1=t11.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t4 STRAIGHT_JOIN t11 WHERE t4.c1=t11.c1; +c1 c1 +EXPLAIN SELECT * FROM t4 WHERE c1 IN (SELECT c1 FROM t11); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t4 WHERE c1 IN (SELECT c1 FROM t11); +c1 +EXPLAIN SELECT * FROM t4 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t11); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t4 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t11); +c1 +EXPLAIN SELECT 1 FROM t4 WHERE (SELECT 1 FROM t4 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t11 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t4 WHERE (SELECT 1 FROM t4 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t11 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t4 STRAIGHT_JOIN t12 WHERE t4.c1=t12.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t4 STRAIGHT_JOIN t12 WHERE t4.c1=t12.c1; +c1 c1 +19950400 19950414 +19950400 19950414 +EXPLAIN SELECT * FROM t4 WHERE c1 IN (SELECT c1 FROM t12); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t4 WHERE c1 IN (SELECT c1 FROM t12); +c1 +19950400 +19950400 +EXPLAIN SELECT * FROM t4 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t12); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t4 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t12); +c1 +19950400 +EXPLAIN SELECT 1 FROM t4 WHERE (SELECT 1 FROM t4 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t12 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t4 WHERE (SELECT 1 FROM t4 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t12 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t4 STRAIGHT_JOIN t13 WHERE t4.c1=t13.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t4 STRAIGHT_JOIN t13 WHERE t4.c1=t13.c1; +c1 c1 +19950400 19950414 +19950400 19950414 +EXPLAIN SELECT * FROM t4 WHERE c1 IN (SELECT c1 FROM t13); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# MATERIALIZED # # # # # # # # # # +SELECT * FROM t4 WHERE c1 IN (SELECT c1 FROM t13); +c1 +19950400 +19950400 +EXPLAIN SELECT * FROM t4 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t13); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t4 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t13); +c1 +19950400 +EXPLAIN SELECT 1 FROM t4 WHERE (SELECT 1 FROM t4 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t13 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t4 WHERE (SELECT 1 FROM t4 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t13 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t5 STRAIGHT_JOIN t1 WHERE t5.c1=t1.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t5 STRAIGHT_JOIN t1 WHERE t5.c1=t1.c1; +c1 c1 +19950414 19950414 +EXPLAIN SELECT * FROM t5 WHERE c1 IN (SELECT c1 FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# MATERIALIZED # # # # # # # # # # +SELECT * FROM t5 WHERE c1 IN (SELECT c1 FROM t1); +c1 +19950414 +EXPLAIN SELECT * FROM t5 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t5 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t1); +c1 +19950414 +EXPLAIN SELECT 1 FROM t5 WHERE (SELECT 1 FROM t5 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t1 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t5 WHERE (SELECT 1 FROM t5 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t1 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t5 STRAIGHT_JOIN t2 WHERE t5.c1=t2.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t5 STRAIGHT_JOIN t2 WHERE t5.c1=t2.c1; +c1 c1 +19950414 19950414 +EXPLAIN SELECT * FROM t5 WHERE c1 IN (SELECT c1 FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# MATERIALIZED # # # # # # # # # # +SELECT * FROM t5 WHERE c1 IN (SELECT c1 FROM t2); +c1 +19950414 +EXPLAIN SELECT * FROM t5 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t5 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t2); +c1 +19950414 +EXPLAIN SELECT 1 FROM t5 WHERE (SELECT 1 FROM t5 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t2 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t5 WHERE (SELECT 1 FROM t5 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t2 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t5 STRAIGHT_JOIN t3 WHERE t5.c1=t3.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t5 STRAIGHT_JOIN t3 WHERE t5.c1=t3.c1; +c1 c1 +19930513.3 19930513.30 +19950414 19950414.00 +19950414.1 19950414.10 +EXPLAIN SELECT * FROM t5 WHERE c1 IN (SELECT c1 FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# MATERIALIZED # # # # # # # # # # +SELECT * FROM t5 WHERE c1 IN (SELECT c1 FROM t3); +c1 +19930513.3 +19950414 +19950414.1 +EXPLAIN SELECT * FROM t5 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t5 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t3); +c1 +19930513.3 +19950414 +19950414.1 +EXPLAIN SELECT 1 FROM t5 WHERE (SELECT 1 FROM t5 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t3 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t5 WHERE (SELECT 1 FROM t5 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t3 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t5 STRAIGHT_JOIN t4 WHERE t5.c1=t4.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t5 STRAIGHT_JOIN t4 WHERE t5.c1=t4.c1; +c1 c1 +19950414 19950400 +19950414 19950400 +EXPLAIN SELECT * FROM t5 WHERE c1 IN (SELECT c1 FROM t4); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# MATERIALIZED # # # # # # # # # # +SELECT * FROM t5 WHERE c1 IN (SELECT c1 FROM t4); +c1 +19950414 +EXPLAIN SELECT * FROM t5 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t4); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t5 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t4); +c1 +19950414 +EXPLAIN SELECT 1 FROM t5 WHERE (SELECT 1 FROM t5 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t4 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t5 WHERE (SELECT 1 FROM t5 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t4 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t5 STRAIGHT_JOIN t6 WHERE t5.c1=t6.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t5 STRAIGHT_JOIN t6 WHERE t5.c1=t6.c1; +c1 c1 +19950414 19950414 +19950414.1 19950414.1 +EXPLAIN SELECT * FROM t5 WHERE c1 IN (SELECT c1 FROM t6); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t5 WHERE c1 IN (SELECT c1 FROM t6); +c1 +19950414 +19950414.1 +EXPLAIN SELECT * FROM t5 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t6); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t5 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t6); +c1 +19950414 +19950414.1 +EXPLAIN SELECT 1 FROM t5 WHERE (SELECT 1 FROM t5 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t6 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t5 WHERE (SELECT 1 FROM t5 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t6 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t5 STRAIGHT_JOIN t7 WHERE t5.c1=t7.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t5 STRAIGHT_JOIN t7 WHERE t5.c1=t7.c1; +c1 c1 +19950414 19950414 +19950414.1 19950414.1 +EXPLAIN SELECT * FROM t5 WHERE c1 IN (SELECT c1 FROM t7); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t5 WHERE c1 IN (SELECT c1 FROM t7); +c1 +19950414 +19950414.1 +EXPLAIN SELECT * FROM t5 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t7); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t5 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t7); +c1 +19950414 +19950414.1 +EXPLAIN SELECT 1 FROM t5 WHERE (SELECT 1 FROM t5 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t7 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t5 WHERE (SELECT 1 FROM t5 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t7 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t5 STRAIGHT_JOIN t8 WHERE t5.c1=t8.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t5 STRAIGHT_JOIN t8 WHERE t5.c1=t8.c1; +c1 c1 +EXPLAIN SELECT * FROM t5 WHERE c1 IN (SELECT c1 FROM t8); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t5 WHERE c1 IN (SELECT c1 FROM t8); +c1 +EXPLAIN SELECT * FROM t5 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t8); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t5 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t8); +c1 +EXPLAIN SELECT 1 FROM t5 WHERE (SELECT 1 FROM t5 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t8 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t5 WHERE (SELECT 1 FROM t5 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t8 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t5 STRAIGHT_JOIN t9 WHERE t5.c1=t9.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t5 STRAIGHT_JOIN t9 WHERE t5.c1=t9.c1; +c1 c1 +EXPLAIN SELECT * FROM t5 WHERE c1 IN (SELECT c1 FROM t9); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t5 WHERE c1 IN (SELECT c1 FROM t9); +c1 +EXPLAIN SELECT * FROM t5 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t9); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t5 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t9); +c1 +EXPLAIN SELECT 1 FROM t5 WHERE (SELECT 1 FROM t5 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t9 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t5 WHERE (SELECT 1 FROM t5 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t9 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t5 STRAIGHT_JOIN t10 WHERE t5.c1=t10.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t5 STRAIGHT_JOIN t10 WHERE t5.c1=t10.c1; +c1 c1 +EXPLAIN SELECT * FROM t5 WHERE c1 IN (SELECT c1 FROM t10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t5 WHERE c1 IN (SELECT c1 FROM t10); +c1 +EXPLAIN SELECT * FROM t5 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t5 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t10); +c1 +EXPLAIN SELECT 1 FROM t5 WHERE (SELECT 1 FROM t5 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t10 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t5 WHERE (SELECT 1 FROM t5 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t10 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t5 STRAIGHT_JOIN t11 WHERE t5.c1=t11.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t5 STRAIGHT_JOIN t11 WHERE t5.c1=t11.c1; +c1 c1 +EXPLAIN SELECT * FROM t5 WHERE c1 IN (SELECT c1 FROM t11); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t5 WHERE c1 IN (SELECT c1 FROM t11); +c1 +EXPLAIN SELECT * FROM t5 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t11); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t5 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t11); +c1 +EXPLAIN SELECT 1 FROM t5 WHERE (SELECT 1 FROM t5 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t11 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t5 WHERE (SELECT 1 FROM t5 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t11 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t5 STRAIGHT_JOIN t12 WHERE t5.c1=t12.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t5 STRAIGHT_JOIN t12 WHERE t5.c1=t12.c1; +c1 c1 +19950414 19950414 +19950414.1 19950414.1 +EXPLAIN SELECT * FROM t5 WHERE c1 IN (SELECT c1 FROM t12); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t5 WHERE c1 IN (SELECT c1 FROM t12); +c1 +19950414 +19950414.1 +EXPLAIN SELECT * FROM t5 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t12); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t5 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t12); +c1 +19950414 +19950414.1 +EXPLAIN SELECT 1 FROM t5 WHERE (SELECT 1 FROM t5 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t12 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t5 WHERE (SELECT 1 FROM t5 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t12 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t5 STRAIGHT_JOIN t13 WHERE t5.c1=t13.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t5 STRAIGHT_JOIN t13 WHERE t5.c1=t13.c1; +c1 c1 +19950414 19950414 +EXPLAIN SELECT * FROM t5 WHERE c1 IN (SELECT c1 FROM t13); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# MATERIALIZED # # # # # # # # # # +SELECT * FROM t5 WHERE c1 IN (SELECT c1 FROM t13); +c1 +19950414 +EXPLAIN SELECT * FROM t5 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t13); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t5 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t13); +c1 +19950414 +EXPLAIN SELECT 1 FROM t5 WHERE (SELECT 1 FROM t5 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t13 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t5 WHERE (SELECT 1 FROM t5 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t13 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t6 STRAIGHT_JOIN t1 WHERE t6.c1=t1.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t6 STRAIGHT_JOIN t1 WHERE t6.c1=t1.c1; +c1 c1 +19930513 19930513 +19950414 19950414 +EXPLAIN SELECT * FROM t6 WHERE c1 IN (SELECT c1 FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# MATERIALIZED # # # # # # # # # # +SELECT * FROM t6 WHERE c1 IN (SELECT c1 FROM t1); +c1 +19930513 +19950414 +EXPLAIN SELECT * FROM t6 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t6 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t1); +c1 +19930513 +19950414 +EXPLAIN SELECT 1 FROM t6 WHERE (SELECT 1 FROM t6 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t1 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t6 WHERE (SELECT 1 FROM t6 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t1 WHERE ASCII(c1) = 50); +1 +1 +1 +1 +1 +1 +EXPLAIN SELECT * FROM t6 STRAIGHT_JOIN t2 WHERE t6.c1=t2.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t6 STRAIGHT_JOIN t2 WHERE t6.c1=t2.c1; +c1 c1 +19930513 19930513 +19950414 19950414 +EXPLAIN SELECT * FROM t6 WHERE c1 IN (SELECT c1 FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# MATERIALIZED # # # # # # # # # # +SELECT * FROM t6 WHERE c1 IN (SELECT c1 FROM t2); +c1 +19930513 +19950414 +EXPLAIN SELECT * FROM t6 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t6 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t2); +c1 +19930513 +19950414 +EXPLAIN SELECT 1 FROM t6 WHERE (SELECT 1 FROM t6 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t2 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t6 WHERE (SELECT 1 FROM t6 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t2 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t6 STRAIGHT_JOIN t3 WHERE t6.c1=t3.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t6 STRAIGHT_JOIN t3 WHERE t6.c1=t3.c1; +c1 c1 +19950414 19950414.00 +19950414.1 19950414.10 +EXPLAIN SELECT * FROM t6 WHERE c1 IN (SELECT c1 FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# MATERIALIZED # # # # # # # # # # +SELECT * FROM t6 WHERE c1 IN (SELECT c1 FROM t3); +c1 +19950414 +19950414.1 +EXPLAIN SELECT * FROM t6 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t6 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t3); +c1 +19950414 +19950414.1 +EXPLAIN SELECT 1 FROM t6 WHERE (SELECT 1 FROM t6 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t3 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t6 WHERE (SELECT 1 FROM t6 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t3 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t6 STRAIGHT_JOIN t4 WHERE t6.c1=t4.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t6 STRAIGHT_JOIN t4 WHERE t6.c1=t4.c1; +c1 c1 +19950414 19950400 +19950414 19950400 +EXPLAIN SELECT * FROM t6 WHERE c1 IN (SELECT c1 FROM t4); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# MATERIALIZED # # # # # # # # # # +SELECT * FROM t6 WHERE c1 IN (SELECT c1 FROM t4); +c1 +19950414 +EXPLAIN SELECT * FROM t6 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t4); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t6 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t4); +c1 +19950414 +EXPLAIN SELECT 1 FROM t6 WHERE (SELECT 1 FROM t6 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t4 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t6 WHERE (SELECT 1 FROM t6 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t4 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t6 STRAIGHT_JOIN t5 WHERE t6.c1=t5.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t6 STRAIGHT_JOIN t5 WHERE t6.c1=t5.c1; +c1 c1 +19950414 19950414 +19950414.1 19950414.1 +EXPLAIN SELECT * FROM t6 WHERE c1 IN (SELECT c1 FROM t5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# MATERIALIZED # # # # # # # # # # +SELECT * FROM t6 WHERE c1 IN (SELECT c1 FROM t5); +c1 +19950414 +19950414.1 +EXPLAIN SELECT * FROM t6 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t6 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t5); +c1 +19950414 +19950414.1 +EXPLAIN SELECT 1 FROM t6 WHERE (SELECT 1 FROM t6 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t5 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t6 WHERE (SELECT 1 FROM t6 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t5 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t6 STRAIGHT_JOIN t7 WHERE t6.c1=t7.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t6 STRAIGHT_JOIN t7 WHERE t6.c1=t7.c1; +c1 c1 +19910111 19910111 +19930513 19930513 +19950414 19950414 +19950414.1 19950414.1 +20010513 20010513 +EXPLAIN SELECT * FROM t6 WHERE c1 IN (SELECT c1 FROM t7); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# MATERIALIZED # # # # # # # # # # +SELECT * FROM t6 WHERE c1 IN (SELECT c1 FROM t7); +c1 +19910111 +19930513 +19950414 +19950414.1 +20010513 +EXPLAIN SELECT * FROM t6 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t7); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t6 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t7); +c1 +19910111 +19930513 +19950414 +19950414.1 +20010513 +EXPLAIN SELECT 1 FROM t6 WHERE (SELECT 1 FROM t6 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t7 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t6 WHERE (SELECT 1 FROM t6 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t7 WHERE ASCII(c1) = 50); +1 +1 +1 +1 +1 +1 +EXPLAIN SELECT * FROM t6 STRAIGHT_JOIN t8 WHERE t6.c1=t8.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t6 STRAIGHT_JOIN t8 WHERE t6.c1=t8.c1; +c1 c1 +EXPLAIN SELECT * FROM t6 WHERE c1 IN (SELECT c1 FROM t8); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t6 WHERE c1 IN (SELECT c1 FROM t8); +c1 +EXPLAIN SELECT * FROM t6 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t8); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t6 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t8); +c1 +EXPLAIN SELECT 1 FROM t6 WHERE (SELECT 1 FROM t6 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t8 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t6 WHERE (SELECT 1 FROM t6 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t8 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t6 STRAIGHT_JOIN t9 WHERE t6.c1=t9.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t6 STRAIGHT_JOIN t9 WHERE t6.c1=t9.c1; +c1 c1 +EXPLAIN SELECT * FROM t6 WHERE c1 IN (SELECT c1 FROM t9); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t6 WHERE c1 IN (SELECT c1 FROM t9); +c1 +EXPLAIN SELECT * FROM t6 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t9); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t6 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t9); +c1 +EXPLAIN SELECT 1 FROM t6 WHERE (SELECT 1 FROM t6 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t9 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t6 WHERE (SELECT 1 FROM t6 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t9 WHERE ASCII(c1) = 50); +1 +1 +1 +1 +1 +1 +EXPLAIN SELECT * FROM t6 STRAIGHT_JOIN t10 WHERE t6.c1=t10.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t6 STRAIGHT_JOIN t10 WHERE t6.c1=t10.c1; +c1 c1 +EXPLAIN SELECT * FROM t6 WHERE c1 IN (SELECT c1 FROM t10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t6 WHERE c1 IN (SELECT c1 FROM t10); +c1 +EXPLAIN SELECT * FROM t6 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t6 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t10); +c1 +EXPLAIN SELECT 1 FROM t6 WHERE (SELECT 1 FROM t6 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t10 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t6 WHERE (SELECT 1 FROM t6 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t10 WHERE ASCII(c1) = 50); +1 +1 +1 +1 +1 +1 +EXPLAIN SELECT * FROM t6 STRAIGHT_JOIN t11 WHERE t6.c1=t11.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t6 STRAIGHT_JOIN t11 WHERE t6.c1=t11.c1; +c1 c1 +EXPLAIN SELECT * FROM t6 WHERE c1 IN (SELECT c1 FROM t11); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t6 WHERE c1 IN (SELECT c1 FROM t11); +c1 +EXPLAIN SELECT * FROM t6 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t11); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t6 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t11); +c1 +EXPLAIN SELECT 1 FROM t6 WHERE (SELECT 1 FROM t6 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t11 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t6 WHERE (SELECT 1 FROM t6 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t11 WHERE ASCII(c1) = 50); +1 +1 +1 +1 +1 +1 +EXPLAIN SELECT * FROM t6 STRAIGHT_JOIN t12 WHERE t6.c1=t12.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t6 STRAIGHT_JOIN t12 WHERE t6.c1=t12.c1; +c1 c1 +19910111 19910111 +19930513 19930513 +19950414 19950414 +19950414.1 19950414.1 +20010513 20010513 +EXPLAIN SELECT * FROM t6 WHERE c1 IN (SELECT c1 FROM t12); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t6 WHERE c1 IN (SELECT c1 FROM t12); +c1 +19910111 +19930513 +19950414 +19950414.1 +20010513 +EXPLAIN SELECT * FROM t6 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t12); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t6 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t12); +c1 +19910111 +19930513 +19950414 +19950414.1 +20010513 +EXPLAIN SELECT 1 FROM t6 WHERE (SELECT 1 FROM t6 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t12 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t6 WHERE (SELECT 1 FROM t6 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t12 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t6 STRAIGHT_JOIN t13 WHERE t6.c1=t13.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t6 STRAIGHT_JOIN t13 WHERE t6.c1=t13.c1; +c1 c1 +19950414 19950414 +EXPLAIN SELECT * FROM t6 WHERE c1 IN (SELECT c1 FROM t13); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# MATERIALIZED # # # # # # # # # # +SELECT * FROM t6 WHERE c1 IN (SELECT c1 FROM t13); +c1 +19950414 +EXPLAIN SELECT * FROM t6 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t13); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t6 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t13); +c1 +19950414 +EXPLAIN SELECT 1 FROM t6 WHERE (SELECT 1 FROM t6 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t13 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t6 WHERE (SELECT 1 FROM t6 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t13 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t7 STRAIGHT_JOIN t1 WHERE t7.c1=t1.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t7 STRAIGHT_JOIN t1 WHERE t7.c1=t1.c1; +c1 c1 +19930513 19930513 +19950414 19950414 +EXPLAIN SELECT * FROM t7 WHERE c1 IN (SELECT c1 FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# MATERIALIZED # # # # # # # # # # +SELECT * FROM t7 WHERE c1 IN (SELECT c1 FROM t1); +c1 +19930513 +19950414 +EXPLAIN SELECT * FROM t7 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t7 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t1); +c1 +19930513 +19950414 +EXPLAIN SELECT 1 FROM t7 WHERE (SELECT 1 FROM t7 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t1 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t7 WHERE (SELECT 1 FROM t7 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t1 WHERE ASCII(c1) = 50); +1 +1 +1 +1 +1 +1 +EXPLAIN SELECT * FROM t7 STRAIGHT_JOIN t2 WHERE t7.c1=t2.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t7 STRAIGHT_JOIN t2 WHERE t7.c1=t2.c1; +c1 c1 +19930513 19930513 +19950414 19950414 +EXPLAIN SELECT * FROM t7 WHERE c1 IN (SELECT c1 FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# MATERIALIZED # # # # # # # # # # +SELECT * FROM t7 WHERE c1 IN (SELECT c1 FROM t2); +c1 +19930513 +19950414 +EXPLAIN SELECT * FROM t7 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t7 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t2); +c1 +19930513 +19950414 +EXPLAIN SELECT 1 FROM t7 WHERE (SELECT 1 FROM t7 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t2 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t7 WHERE (SELECT 1 FROM t7 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t2 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t7 STRAIGHT_JOIN t3 WHERE t7.c1=t3.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t7 STRAIGHT_JOIN t3 WHERE t7.c1=t3.c1; +c1 c1 +19950414 19950414.00 +19950414.1 19950414.10 +EXPLAIN SELECT * FROM t7 WHERE c1 IN (SELECT c1 FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# MATERIALIZED # # # # # # # # # # +SELECT * FROM t7 WHERE c1 IN (SELECT c1 FROM t3); +c1 +19950414 +19950414.1 +EXPLAIN SELECT * FROM t7 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t7 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t3); +c1 +19950414 +19950414.1 +EXPLAIN SELECT 1 FROM t7 WHERE (SELECT 1 FROM t7 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t3 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t7 WHERE (SELECT 1 FROM t7 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t3 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t7 STRAIGHT_JOIN t4 WHERE t7.c1=t4.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t7 STRAIGHT_JOIN t4 WHERE t7.c1=t4.c1; +c1 c1 +19950414 19950400 +19950414 19950400 +EXPLAIN SELECT * FROM t7 WHERE c1 IN (SELECT c1 FROM t4); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# MATERIALIZED # # # # # # # # # # +SELECT * FROM t7 WHERE c1 IN (SELECT c1 FROM t4); +c1 +19950414 +EXPLAIN SELECT * FROM t7 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t4); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t7 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t4); +c1 +19950414 +EXPLAIN SELECT 1 FROM t7 WHERE (SELECT 1 FROM t7 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t4 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t7 WHERE (SELECT 1 FROM t7 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t4 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t7 STRAIGHT_JOIN t5 WHERE t7.c1=t5.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t7 STRAIGHT_JOIN t5 WHERE t7.c1=t5.c1; +c1 c1 +19950414 19950414 +19950414.1 19950414.1 +EXPLAIN SELECT * FROM t7 WHERE c1 IN (SELECT c1 FROM t5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# MATERIALIZED # # # # # # # # # # +SELECT * FROM t7 WHERE c1 IN (SELECT c1 FROM t5); +c1 +19950414 +19950414.1 +EXPLAIN SELECT * FROM t7 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t7 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t5); +c1 +19950414 +19950414.1 +EXPLAIN SELECT 1 FROM t7 WHERE (SELECT 1 FROM t7 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t5 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t7 WHERE (SELECT 1 FROM t7 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t5 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t7 STRAIGHT_JOIN t6 WHERE t7.c1=t6.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t7 STRAIGHT_JOIN t6 WHERE t7.c1=t6.c1; +c1 c1 +19910111 19910111 +19930513 19930513 +19950414 19950414 +19950414.1 19950414.1 +20010513 20010513 +EXPLAIN SELECT * FROM t7 WHERE c1 IN (SELECT c1 FROM t6); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# MATERIALIZED # # # # # # # # # # +SELECT * FROM t7 WHERE c1 IN (SELECT c1 FROM t6); +c1 +19910111 +19930513 +19950414 +19950414.1 +20010513 +EXPLAIN SELECT * FROM t7 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t6); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t7 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t6); +c1 +19910111 +19930513 +19950414 +19950414.1 +20010513 +EXPLAIN SELECT 1 FROM t7 WHERE (SELECT 1 FROM t7 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t6 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t7 WHERE (SELECT 1 FROM t7 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t6 WHERE ASCII(c1) = 50); +1 +1 +1 +1 +1 +1 +EXPLAIN SELECT * FROM t7 STRAIGHT_JOIN t8 WHERE t7.c1=t8.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t7 STRAIGHT_JOIN t8 WHERE t7.c1=t8.c1; +c1 c1 +EXPLAIN SELECT * FROM t7 WHERE c1 IN (SELECT c1 FROM t8); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t7 WHERE c1 IN (SELECT c1 FROM t8); +c1 +EXPLAIN SELECT * FROM t7 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t8); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t7 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t8); +c1 +EXPLAIN SELECT 1 FROM t7 WHERE (SELECT 1 FROM t7 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t8 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t7 WHERE (SELECT 1 FROM t7 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t8 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t7 STRAIGHT_JOIN t9 WHERE t7.c1=t9.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t7 STRAIGHT_JOIN t9 WHERE t7.c1=t9.c1; +c1 c1 +EXPLAIN SELECT * FROM t7 WHERE c1 IN (SELECT c1 FROM t9); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t7 WHERE c1 IN (SELECT c1 FROM t9); +c1 +EXPLAIN SELECT * FROM t7 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t9); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t7 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t9); +c1 +EXPLAIN SELECT 1 FROM t7 WHERE (SELECT 1 FROM t7 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t9 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t7 WHERE (SELECT 1 FROM t7 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t9 WHERE ASCII(c1) = 50); +1 +1 +1 +1 +1 +1 +EXPLAIN SELECT * FROM t7 STRAIGHT_JOIN t10 WHERE t7.c1=t10.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t7 STRAIGHT_JOIN t10 WHERE t7.c1=t10.c1; +c1 c1 +EXPLAIN SELECT * FROM t7 WHERE c1 IN (SELECT c1 FROM t10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t7 WHERE c1 IN (SELECT c1 FROM t10); +c1 +EXPLAIN SELECT * FROM t7 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t7 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t10); +c1 +EXPLAIN SELECT 1 FROM t7 WHERE (SELECT 1 FROM t7 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t10 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t7 WHERE (SELECT 1 FROM t7 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t10 WHERE ASCII(c1) = 50); +1 +1 +1 +1 +1 +1 +EXPLAIN SELECT * FROM t7 STRAIGHT_JOIN t11 WHERE t7.c1=t11.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t7 STRAIGHT_JOIN t11 WHERE t7.c1=t11.c1; +c1 c1 +EXPLAIN SELECT * FROM t7 WHERE c1 IN (SELECT c1 FROM t11); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t7 WHERE c1 IN (SELECT c1 FROM t11); +c1 +EXPLAIN SELECT * FROM t7 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t11); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t7 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t11); +c1 +EXPLAIN SELECT 1 FROM t7 WHERE (SELECT 1 FROM t7 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t11 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t7 WHERE (SELECT 1 FROM t7 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t11 WHERE ASCII(c1) = 50); +1 +1 +1 +1 +1 +1 +EXPLAIN SELECT * FROM t7 STRAIGHT_JOIN t12 WHERE t7.c1=t12.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t7 STRAIGHT_JOIN t12 WHERE t7.c1=t12.c1; +c1 c1 +19910111 19910111 +19930513 19930513 +19950414 19950414 +19950414.1 19950414.1 +20010513 20010513 +EXPLAIN SELECT * FROM t7 WHERE c1 IN (SELECT c1 FROM t12); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t7 WHERE c1 IN (SELECT c1 FROM t12); +c1 +19910111 +19930513 +19950414 +19950414.1 +20010513 +EXPLAIN SELECT * FROM t7 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t12); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t7 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t12); +c1 +19910111 +19930513 +19950414 +19950414.1 +20010513 +EXPLAIN SELECT 1 FROM t7 WHERE (SELECT 1 FROM t7 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t12 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t7 WHERE (SELECT 1 FROM t7 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t12 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t7 STRAIGHT_JOIN t13 WHERE t7.c1=t13.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t7 STRAIGHT_JOIN t13 WHERE t7.c1=t13.c1; +c1 c1 +19950414 19950414 +EXPLAIN SELECT * FROM t7 WHERE c1 IN (SELECT c1 FROM t13); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# MATERIALIZED # # # # # # # # # # +SELECT * FROM t7 WHERE c1 IN (SELECT c1 FROM t13); +c1 +19950414 +EXPLAIN SELECT * FROM t7 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t13); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t7 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t13); +c1 +19950414 +EXPLAIN SELECT 1 FROM t7 WHERE (SELECT 1 FROM t7 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t13 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t7 WHERE (SELECT 1 FROM t7 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t13 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t8 STRAIGHT_JOIN t1 WHERE t8.c1=t1.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t8 STRAIGHT_JOIN t1 WHERE t8.c1=t1.c1; +c1 c1 +EXPLAIN SELECT * FROM t8 WHERE c1 IN (SELECT c1 FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# MATERIALIZED # # # # # # # # # # +SELECT * FROM t8 WHERE c1 IN (SELECT c1 FROM t1); +c1 +EXPLAIN SELECT * FROM t8 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t8 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t1); +c1 +EXPLAIN SELECT 1 FROM t8 WHERE (SELECT 1 FROM t8 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t1 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t8 WHERE (SELECT 1 FROM t8 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t1 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t8 STRAIGHT_JOIN t2 WHERE t8.c1=t2.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t8 STRAIGHT_JOIN t2 WHERE t8.c1=t2.c1; +c1 c1 +EXPLAIN SELECT * FROM t8 WHERE c1 IN (SELECT c1 FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# MATERIALIZED # # # # # # # # # # +SELECT * FROM t8 WHERE c1 IN (SELECT c1 FROM t2); +c1 +EXPLAIN SELECT * FROM t8 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t8 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t2); +c1 +EXPLAIN SELECT 1 FROM t8 WHERE (SELECT 1 FROM t8 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t2 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t8 WHERE (SELECT 1 FROM t8 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t2 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t8 STRAIGHT_JOIN t3 WHERE t8.c1=t3.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t8 STRAIGHT_JOIN t3 WHERE t8.c1=t3.c1; +c1 c1 +EXPLAIN SELECT * FROM t8 WHERE c1 IN (SELECT c1 FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# MATERIALIZED # # # # # # # # # # +SELECT * FROM t8 WHERE c1 IN (SELECT c1 FROM t3); +c1 +EXPLAIN SELECT * FROM t8 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t8 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t3); +c1 +EXPLAIN SELECT 1 FROM t8 WHERE (SELECT 1 FROM t8 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t3 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t8 WHERE (SELECT 1 FROM t8 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t3 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t8 STRAIGHT_JOIN t4 WHERE t8.c1=t4.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t8 STRAIGHT_JOIN t4 WHERE t8.c1=t4.c1; +c1 c1 +EXPLAIN SELECT * FROM t8 WHERE c1 IN (SELECT c1 FROM t4); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# MATERIALIZED # # # # # # # # # # +SELECT * FROM t8 WHERE c1 IN (SELECT c1 FROM t4); +c1 +EXPLAIN SELECT * FROM t8 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t4); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t8 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t4); +c1 +EXPLAIN SELECT 1 FROM t8 WHERE (SELECT 1 FROM t8 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t4 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t8 WHERE (SELECT 1 FROM t8 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t4 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t8 STRAIGHT_JOIN t5 WHERE t8.c1=t5.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t8 STRAIGHT_JOIN t5 WHERE t8.c1=t5.c1; +c1 c1 +EXPLAIN SELECT * FROM t8 WHERE c1 IN (SELECT c1 FROM t5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# MATERIALIZED # # # # # # # # # # +SELECT * FROM t8 WHERE c1 IN (SELECT c1 FROM t5); +c1 +EXPLAIN SELECT * FROM t8 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t8 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t5); +c1 +EXPLAIN SELECT 1 FROM t8 WHERE (SELECT 1 FROM t8 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t5 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t8 WHERE (SELECT 1 FROM t8 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t5 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t8 STRAIGHT_JOIN t6 WHERE t8.c1=t6.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t8 STRAIGHT_JOIN t6 WHERE t8.c1=t6.c1; +c1 c1 +EXPLAIN SELECT * FROM t8 WHERE c1 IN (SELECT c1 FROM t6); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t8 WHERE c1 IN (SELECT c1 FROM t6); +c1 +EXPLAIN SELECT * FROM t8 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t6); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t8 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t6); +c1 +EXPLAIN SELECT 1 FROM t8 WHERE (SELECT 1 FROM t8 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t6 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t8 WHERE (SELECT 1 FROM t8 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t6 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t8 STRAIGHT_JOIN t7 WHERE t8.c1=t7.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t8 STRAIGHT_JOIN t7 WHERE t8.c1=t7.c1; +c1 c1 +EXPLAIN SELECT * FROM t8 WHERE c1 IN (SELECT c1 FROM t7); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t8 WHERE c1 IN (SELECT c1 FROM t7); +c1 +EXPLAIN SELECT * FROM t8 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t7); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t8 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t7); +c1 +EXPLAIN SELECT 1 FROM t8 WHERE (SELECT 1 FROM t8 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t7 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t8 WHERE (SELECT 1 FROM t8 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t7 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t8 STRAIGHT_JOIN t9 WHERE t8.c1=t9.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t8 STRAIGHT_JOIN t9 WHERE t8.c1=t9.c1; +c1 c1 +10:22:33 2015-04-13 10:22:33 +EXPLAIN SELECT * FROM t8 WHERE c1 IN (SELECT c1 FROM t9); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# MATERIALIZED # # # # # # # # # # +SELECT * FROM t8 WHERE c1 IN (SELECT c1 FROM t9); +c1 +10:22:33 +EXPLAIN SELECT * FROM t8 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t9); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t8 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t9); +c1 +10:22:33 +EXPLAIN SELECT 1 FROM t8 WHERE (SELECT 1 FROM t8 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t9 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t8 WHERE (SELECT 1 FROM t8 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t9 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t8 STRAIGHT_JOIN t10 WHERE t8.c1=t10.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t8 STRAIGHT_JOIN t10 WHERE t8.c1=t10.c1; +c1 c1 +EXPLAIN SELECT * FROM t8 WHERE c1 IN (SELECT c1 FROM t10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# MATERIALIZED # # # # # # # # # # +SELECT * FROM t8 WHERE c1 IN (SELECT c1 FROM t10); +c1 +EXPLAIN SELECT * FROM t8 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t8 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t10); +c1 +EXPLAIN SELECT 1 FROM t8 WHERE (SELECT 1 FROM t8 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t10 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t8 WHERE (SELECT 1 FROM t8 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t10 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t8 STRAIGHT_JOIN t11 WHERE t8.c1=t11.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t8 STRAIGHT_JOIN t11 WHERE t8.c1=t11.c1; +c1 c1 +10:22:33 2015-04-13 10:22:33 +33:22:33 2015-04-14 09:22:33 +EXPLAIN SELECT * FROM t8 WHERE c1 IN (SELECT c1 FROM t11); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# MATERIALIZED # # # # # # # # # # +SELECT * FROM t8 WHERE c1 IN (SELECT c1 FROM t11); +c1 +10:22:33 +33:22:33 +EXPLAIN SELECT * FROM t8 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t11); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t8 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t11); +c1 +10:22:33 +33:22:33 +EXPLAIN SELECT 1 FROM t8 WHERE (SELECT 1 FROM t8 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t11 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t8 WHERE (SELECT 1 FROM t8 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t11 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t8 STRAIGHT_JOIN t12 WHERE t8.c1=t12.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t8 STRAIGHT_JOIN t12 WHERE t8.c1=t12.c1; +c1 c1 +EXPLAIN SELECT * FROM t8 WHERE c1 IN (SELECT c1 FROM t12); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t8 WHERE c1 IN (SELECT c1 FROM t12); +c1 +EXPLAIN SELECT * FROM t8 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t12); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t8 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t12); +c1 +EXPLAIN SELECT 1 FROM t8 WHERE (SELECT 1 FROM t8 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t12 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t8 WHERE (SELECT 1 FROM t8 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t12 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t8 STRAIGHT_JOIN t13 WHERE t8.c1=t13.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t8 STRAIGHT_JOIN t13 WHERE t8.c1=t13.c1; +c1 c1 +EXPLAIN SELECT * FROM t8 WHERE c1 IN (SELECT c1 FROM t13); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# MATERIALIZED # # # # # # # # # # +SELECT * FROM t8 WHERE c1 IN (SELECT c1 FROM t13); +c1 +EXPLAIN SELECT * FROM t8 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t13); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t8 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t13); +c1 +EXPLAIN SELECT 1 FROM t8 WHERE (SELECT 1 FROM t8 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t13 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t8 WHERE (SELECT 1 FROM t8 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t13 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t9 STRAIGHT_JOIN t1 WHERE t9.c1=t1.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t9 STRAIGHT_JOIN t1 WHERE t9.c1=t1.c1; +c1 c1 +EXPLAIN SELECT * FROM t9 WHERE c1 IN (SELECT c1 FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# MATERIALIZED # # # # # # # # # # +SELECT * FROM t9 WHERE c1 IN (SELECT c1 FROM t1); +c1 +EXPLAIN SELECT * FROM t9 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t9 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t1); +c1 +EXPLAIN SELECT 1 FROM t9 WHERE (SELECT 1 FROM t9 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t1 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t9 WHERE (SELECT 1 FROM t9 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t1 WHERE ASCII(c1) = 50); +1 +1 +1 +EXPLAIN SELECT * FROM t9 STRAIGHT_JOIN t2 WHERE t9.c1=t2.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t9 STRAIGHT_JOIN t2 WHERE t9.c1=t2.c1; +c1 c1 +EXPLAIN SELECT * FROM t9 WHERE c1 IN (SELECT c1 FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# MATERIALIZED # # # # # # # # # # +SELECT * FROM t9 WHERE c1 IN (SELECT c1 FROM t2); +c1 +EXPLAIN SELECT * FROM t9 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t9 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t2); +c1 +EXPLAIN SELECT 1 FROM t9 WHERE (SELECT 1 FROM t9 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t2 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t9 WHERE (SELECT 1 FROM t9 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t2 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t9 STRAIGHT_JOIN t3 WHERE t9.c1=t3.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t9 STRAIGHT_JOIN t3 WHERE t9.c1=t3.c1; +c1 c1 +EXPLAIN SELECT * FROM t9 WHERE c1 IN (SELECT c1 FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# MATERIALIZED # # # # # # # # # # +SELECT * FROM t9 WHERE c1 IN (SELECT c1 FROM t3); +c1 +EXPLAIN SELECT * FROM t9 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t9 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t3); +c1 +EXPLAIN SELECT 1 FROM t9 WHERE (SELECT 1 FROM t9 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t3 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t9 WHERE (SELECT 1 FROM t9 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t3 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t9 STRAIGHT_JOIN t4 WHERE t9.c1=t4.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t9 STRAIGHT_JOIN t4 WHERE t9.c1=t4.c1; +c1 c1 +EXPLAIN SELECT * FROM t9 WHERE c1 IN (SELECT c1 FROM t4); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# MATERIALIZED # # # # # # # # # # +SELECT * FROM t9 WHERE c1 IN (SELECT c1 FROM t4); +c1 +EXPLAIN SELECT * FROM t9 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t4); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t9 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t4); +c1 +EXPLAIN SELECT 1 FROM t9 WHERE (SELECT 1 FROM t9 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t4 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t9 WHERE (SELECT 1 FROM t9 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t4 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t9 STRAIGHT_JOIN t5 WHERE t9.c1=t5.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t9 STRAIGHT_JOIN t5 WHERE t9.c1=t5.c1; +c1 c1 +EXPLAIN SELECT * FROM t9 WHERE c1 IN (SELECT c1 FROM t5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# MATERIALIZED # # # # # # # # # # +SELECT * FROM t9 WHERE c1 IN (SELECT c1 FROM t5); +c1 +EXPLAIN SELECT * FROM t9 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t9 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t5); +c1 +EXPLAIN SELECT 1 FROM t9 WHERE (SELECT 1 FROM t9 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t5 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t9 WHERE (SELECT 1 FROM t9 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t5 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t9 STRAIGHT_JOIN t6 WHERE t9.c1=t6.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t9 STRAIGHT_JOIN t6 WHERE t9.c1=t6.c1; +c1 c1 +EXPLAIN SELECT * FROM t9 WHERE c1 IN (SELECT c1 FROM t6); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t9 WHERE c1 IN (SELECT c1 FROM t6); +c1 +EXPLAIN SELECT * FROM t9 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t6); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t9 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t6); +c1 +EXPLAIN SELECT 1 FROM t9 WHERE (SELECT 1 FROM t9 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t6 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t9 WHERE (SELECT 1 FROM t9 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t6 WHERE ASCII(c1) = 50); +1 +1 +1 +EXPLAIN SELECT * FROM t9 STRAIGHT_JOIN t7 WHERE t9.c1=t7.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t9 STRAIGHT_JOIN t7 WHERE t9.c1=t7.c1; +c1 c1 +EXPLAIN SELECT * FROM t9 WHERE c1 IN (SELECT c1 FROM t7); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t9 WHERE c1 IN (SELECT c1 FROM t7); +c1 +EXPLAIN SELECT * FROM t9 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t7); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t9 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t7); +c1 +EXPLAIN SELECT 1 FROM t9 WHERE (SELECT 1 FROM t9 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t7 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t9 WHERE (SELECT 1 FROM t9 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t7 WHERE ASCII(c1) = 50); +1 +1 +1 +EXPLAIN SELECT * FROM t9 STRAIGHT_JOIN t8 WHERE t9.c1=t8.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t9 STRAIGHT_JOIN t8 WHERE t9.c1=t8.c1; +c1 c1 +2015-04-13 10:22:33 10:22:33 +EXPLAIN SELECT * FROM t9 WHERE c1 IN (SELECT c1 FROM t8); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t9 WHERE c1 IN (SELECT c1 FROM t8); +c1 +2015-04-13 10:22:33 +EXPLAIN SELECT * FROM t9 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t8); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t9 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t8); +c1 +2015-04-13 10:22:33 +EXPLAIN SELECT 1 FROM t9 WHERE (SELECT 1 FROM t9 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t8 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t9 WHERE (SELECT 1 FROM t9 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t8 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t9 STRAIGHT_JOIN t10 WHERE t9.c1=t10.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t9 STRAIGHT_JOIN t10 WHERE t9.c1=t10.c1; +c1 c1 +EXPLAIN SELECT * FROM t9 WHERE c1 IN (SELECT c1 FROM t10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# MATERIALIZED # # # # # # # # # # +SELECT * FROM t9 WHERE c1 IN (SELECT c1 FROM t10); +c1 +EXPLAIN SELECT * FROM t9 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t9 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t10); +c1 +EXPLAIN SELECT 1 FROM t9 WHERE (SELECT 1 FROM t9 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t10 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t9 WHERE (SELECT 1 FROM t9 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t10 WHERE ASCII(c1) = 50); +1 +1 +1 +EXPLAIN SELECT * FROM t9 STRAIGHT_JOIN t11 WHERE t9.c1=t11.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t9 STRAIGHT_JOIN t11 WHERE t9.c1=t11.c1; +c1 c1 +2015-04-13 10:22:33 2015-04-13 10:22:33 +EXPLAIN SELECT * FROM t9 WHERE c1 IN (SELECT c1 FROM t11); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# MATERIALIZED # # # # # # # # # # +SELECT * FROM t9 WHERE c1 IN (SELECT c1 FROM t11); +c1 +2015-04-13 10:22:33 +EXPLAIN SELECT * FROM t9 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t11); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t9 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t11); +c1 +2015-04-13 10:22:33 +EXPLAIN SELECT 1 FROM t9 WHERE (SELECT 1 FROM t9 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t11 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t9 WHERE (SELECT 1 FROM t9 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t11 WHERE ASCII(c1) = 50); +1 +1 +1 +EXPLAIN SELECT * FROM t9 STRAIGHT_JOIN t12 WHERE t9.c1=t12.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t9 STRAIGHT_JOIN t12 WHERE t9.c1=t12.c1; +c1 c1 +EXPLAIN SELECT * FROM t9 WHERE c1 IN (SELECT c1 FROM t12); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t9 WHERE c1 IN (SELECT c1 FROM t12); +c1 +EXPLAIN SELECT * FROM t9 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t12); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t9 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t12); +c1 +EXPLAIN SELECT 1 FROM t9 WHERE (SELECT 1 FROM t9 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t12 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t9 WHERE (SELECT 1 FROM t9 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t12 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t9 STRAIGHT_JOIN t13 WHERE t9.c1=t13.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t9 STRAIGHT_JOIN t13 WHERE t9.c1=t13.c1; +c1 c1 +EXPLAIN SELECT * FROM t9 WHERE c1 IN (SELECT c1 FROM t13); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# MATERIALIZED # # # # # # # # # # +SELECT * FROM t9 WHERE c1 IN (SELECT c1 FROM t13); +c1 +EXPLAIN SELECT * FROM t9 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t13); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t9 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t13); +c1 +EXPLAIN SELECT 1 FROM t9 WHERE (SELECT 1 FROM t9 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t13 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t9 WHERE (SELECT 1 FROM t9 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t13 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t10 STRAIGHT_JOIN t1 WHERE t10.c1=t1.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t10 STRAIGHT_JOIN t1 WHERE t10.c1=t1.c1; +c1 c1 +EXPLAIN SELECT * FROM t10 WHERE c1 IN (SELECT c1 FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# MATERIALIZED # # # # # # # # # # +SELECT * FROM t10 WHERE c1 IN (SELECT c1 FROM t1); +c1 +EXPLAIN SELECT * FROM t10 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t10 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t1); +c1 +EXPLAIN SELECT 1 FROM t10 WHERE (SELECT 1 FROM t10 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t1 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t10 WHERE (SELECT 1 FROM t10 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t1 WHERE ASCII(c1) = 50); +1 +1 +1 +EXPLAIN SELECT * FROM t10 STRAIGHT_JOIN t2 WHERE t10.c1=t2.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t10 STRAIGHT_JOIN t2 WHERE t10.c1=t2.c1; +c1 c1 +EXPLAIN SELECT * FROM t10 WHERE c1 IN (SELECT c1 FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# MATERIALIZED # # # # # # # # # # +SELECT * FROM t10 WHERE c1 IN (SELECT c1 FROM t2); +c1 +EXPLAIN SELECT * FROM t10 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t10 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t2); +c1 +EXPLAIN SELECT 1 FROM t10 WHERE (SELECT 1 FROM t10 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t2 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t10 WHERE (SELECT 1 FROM t10 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t2 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t10 STRAIGHT_JOIN t3 WHERE t10.c1=t3.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t10 STRAIGHT_JOIN t3 WHERE t10.c1=t3.c1; +c1 c1 +EXPLAIN SELECT * FROM t10 WHERE c1 IN (SELECT c1 FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# MATERIALIZED # # # # # # # # # # +SELECT * FROM t10 WHERE c1 IN (SELECT c1 FROM t3); +c1 +EXPLAIN SELECT * FROM t10 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t10 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t3); +c1 +EXPLAIN SELECT 1 FROM t10 WHERE (SELECT 1 FROM t10 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t3 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t10 WHERE (SELECT 1 FROM t10 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t3 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t10 STRAIGHT_JOIN t4 WHERE t10.c1=t4.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t10 STRAIGHT_JOIN t4 WHERE t10.c1=t4.c1; +c1 c1 +EXPLAIN SELECT * FROM t10 WHERE c1 IN (SELECT c1 FROM t4); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# MATERIALIZED # # # # # # # # # # +SELECT * FROM t10 WHERE c1 IN (SELECT c1 FROM t4); +c1 +EXPLAIN SELECT * FROM t10 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t4); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t10 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t4); +c1 +EXPLAIN SELECT 1 FROM t10 WHERE (SELECT 1 FROM t10 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t4 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t10 WHERE (SELECT 1 FROM t10 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t4 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t10 STRAIGHT_JOIN t5 WHERE t10.c1=t5.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t10 STRAIGHT_JOIN t5 WHERE t10.c1=t5.c1; +c1 c1 +EXPLAIN SELECT * FROM t10 WHERE c1 IN (SELECT c1 FROM t5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# MATERIALIZED # # # # # # # # # # +SELECT * FROM t10 WHERE c1 IN (SELECT c1 FROM t5); +c1 +EXPLAIN SELECT * FROM t10 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t10 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t5); +c1 +EXPLAIN SELECT 1 FROM t10 WHERE (SELECT 1 FROM t10 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t5 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t10 WHERE (SELECT 1 FROM t10 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t5 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t10 STRAIGHT_JOIN t6 WHERE t10.c1=t6.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t10 STRAIGHT_JOIN t6 WHERE t10.c1=t6.c1; +c1 c1 +EXPLAIN SELECT * FROM t10 WHERE c1 IN (SELECT c1 FROM t6); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t10 WHERE c1 IN (SELECT c1 FROM t6); +c1 +EXPLAIN SELECT * FROM t10 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t6); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t10 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t6); +c1 +EXPLAIN SELECT 1 FROM t10 WHERE (SELECT 1 FROM t10 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t6 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t10 WHERE (SELECT 1 FROM t10 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t6 WHERE ASCII(c1) = 50); +1 +1 +1 +EXPLAIN SELECT * FROM t10 STRAIGHT_JOIN t7 WHERE t10.c1=t7.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t10 STRAIGHT_JOIN t7 WHERE t10.c1=t7.c1; +c1 c1 +EXPLAIN SELECT * FROM t10 WHERE c1 IN (SELECT c1 FROM t7); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t10 WHERE c1 IN (SELECT c1 FROM t7); +c1 +EXPLAIN SELECT * FROM t10 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t7); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t10 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t7); +c1 +EXPLAIN SELECT 1 FROM t10 WHERE (SELECT 1 FROM t10 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t7 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t10 WHERE (SELECT 1 FROM t10 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t7 WHERE ASCII(c1) = 50); +1 +1 +1 +EXPLAIN SELECT * FROM t10 STRAIGHT_JOIN t8 WHERE t10.c1=t8.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t10 STRAIGHT_JOIN t8 WHERE t10.c1=t8.c1; +c1 c1 +EXPLAIN SELECT * FROM t10 WHERE c1 IN (SELECT c1 FROM t8); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t10 WHERE c1 IN (SELECT c1 FROM t8); +c1 +EXPLAIN SELECT * FROM t10 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t8); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t10 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t8); +c1 +EXPLAIN SELECT 1 FROM t10 WHERE (SELECT 1 FROM t10 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t8 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t10 WHERE (SELECT 1 FROM t10 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t8 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t10 STRAIGHT_JOIN t9 WHERE t10.c1=t9.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t10 STRAIGHT_JOIN t9 WHERE t10.c1=t9.c1; +c1 c1 +EXPLAIN SELECT * FROM t10 WHERE c1 IN (SELECT c1 FROM t9); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# MATERIALIZED # # # # # # # # # # +SELECT * FROM t10 WHERE c1 IN (SELECT c1 FROM t9); +c1 +EXPLAIN SELECT * FROM t10 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t9); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t10 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t9); +c1 +EXPLAIN SELECT 1 FROM t10 WHERE (SELECT 1 FROM t10 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t9 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t10 WHERE (SELECT 1 FROM t10 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t9 WHERE ASCII(c1) = 50); +1 +1 +1 +EXPLAIN SELECT * FROM t10 STRAIGHT_JOIN t11 WHERE t10.c1=t11.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t10 STRAIGHT_JOIN t11 WHERE t10.c1=t11.c1; +c1 c1 +EXPLAIN SELECT * FROM t10 WHERE c1 IN (SELECT c1 FROM t11); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# MATERIALIZED # # # # # # # # # # +SELECT * FROM t10 WHERE c1 IN (SELECT c1 FROM t11); +c1 +EXPLAIN SELECT * FROM t10 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t11); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t10 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t11); +c1 +EXPLAIN SELECT 1 FROM t10 WHERE (SELECT 1 FROM t10 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t11 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t10 WHERE (SELECT 1 FROM t10 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t11 WHERE ASCII(c1) = 50); +1 +1 +1 +EXPLAIN SELECT * FROM t10 STRAIGHT_JOIN t12 WHERE t10.c1=t12.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t10 STRAIGHT_JOIN t12 WHERE t10.c1=t12.c1; +c1 c1 +EXPLAIN SELECT * FROM t10 WHERE c1 IN (SELECT c1 FROM t12); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t10 WHERE c1 IN (SELECT c1 FROM t12); +c1 +EXPLAIN SELECT * FROM t10 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t12); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t10 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t12); +c1 +EXPLAIN SELECT 1 FROM t10 WHERE (SELECT 1 FROM t10 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t12 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t10 WHERE (SELECT 1 FROM t10 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t12 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t10 STRAIGHT_JOIN t13 WHERE t10.c1=t13.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t10 STRAIGHT_JOIN t13 WHERE t10.c1=t13.c1; +c1 c1 +EXPLAIN SELECT * FROM t10 WHERE c1 IN (SELECT c1 FROM t13); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# MATERIALIZED # # # # # # # # # # +SELECT * FROM t10 WHERE c1 IN (SELECT c1 FROM t13); +c1 +EXPLAIN SELECT * FROM t10 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t13); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t10 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t13); +c1 +EXPLAIN SELECT 1 FROM t10 WHERE (SELECT 1 FROM t10 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t13 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t10 WHERE (SELECT 1 FROM t10 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t13 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t11 STRAIGHT_JOIN t1 WHERE t11.c1=t1.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t11 STRAIGHT_JOIN t1 WHERE t11.c1=t1.c1; +c1 c1 +EXPLAIN SELECT * FROM t11 WHERE c1 IN (SELECT c1 FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# MATERIALIZED # # # # # # # # # # +SELECT * FROM t11 WHERE c1 IN (SELECT c1 FROM t1); +c1 +EXPLAIN SELECT * FROM t11 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t11 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t1); +c1 +DELETE FROM t11 WHERE c1='2015-04-14 09:22:33'; +ANALYZE TABLE t11; +Table Op Msg_type Msg_text +test.t11 analyze status OK +EXPLAIN SELECT 1 FROM t11 WHERE (SELECT 1 FROM t11 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t1 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t11 WHERE (SELECT 1 FROM t11 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t1 WHERE ASCII(c1) = 50); +1 +1 +1 +INSERT INTO t11 SET c1='2015-04-14 09:22:33'; +ANALYZE TABLE t11; +Table Op Msg_type Msg_text +test.t11 analyze status OK +EXPLAIN SELECT * FROM t11 STRAIGHT_JOIN t2 WHERE t11.c1=t2.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t11 STRAIGHT_JOIN t2 WHERE t11.c1=t2.c1; +c1 c1 +EXPLAIN SELECT * FROM t11 WHERE c1 IN (SELECT c1 FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# MATERIALIZED # # # # # # # # # # +SELECT * FROM t11 WHERE c1 IN (SELECT c1 FROM t2); +c1 +EXPLAIN SELECT * FROM t11 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t11 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t2); +c1 +DELETE FROM t11 WHERE c1='2015-04-14 09:22:33'; +ANALYZE TABLE t11; +Table Op Msg_type Msg_text +test.t11 analyze status OK +EXPLAIN SELECT 1 FROM t11 WHERE (SELECT 1 FROM t11 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t2 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t11 WHERE (SELECT 1 FROM t11 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t2 WHERE ASCII(c1) = 50); +1 +INSERT INTO t11 SET c1='2015-04-14 09:22:33'; +ANALYZE TABLE t11; +Table Op Msg_type Msg_text +test.t11 analyze status OK +EXPLAIN SELECT * FROM t11 STRAIGHT_JOIN t3 WHERE t11.c1=t3.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t11 STRAIGHT_JOIN t3 WHERE t11.c1=t3.c1; +c1 c1 +EXPLAIN SELECT * FROM t11 WHERE c1 IN (SELECT c1 FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# MATERIALIZED # # # # # # # # # # +SELECT * FROM t11 WHERE c1 IN (SELECT c1 FROM t3); +c1 +EXPLAIN SELECT * FROM t11 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t11 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t3); +c1 +DELETE FROM t11 WHERE c1='2015-04-14 09:22:33'; +ANALYZE TABLE t11; +Table Op Msg_type Msg_text +test.t11 analyze status OK +EXPLAIN SELECT 1 FROM t11 WHERE (SELECT 1 FROM t11 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t3 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t11 WHERE (SELECT 1 FROM t11 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t3 WHERE ASCII(c1) = 50); +1 +INSERT INTO t11 SET c1='2015-04-14 09:22:33'; +ANALYZE TABLE t11; +Table Op Msg_type Msg_text +test.t11 analyze status OK +EXPLAIN SELECT * FROM t11 STRAIGHT_JOIN t4 WHERE t11.c1=t4.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t11 STRAIGHT_JOIN t4 WHERE t11.c1=t4.c1; +c1 c1 +EXPLAIN SELECT * FROM t11 WHERE c1 IN (SELECT c1 FROM t4); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# MATERIALIZED # # # # # # # # # # +SELECT * FROM t11 WHERE c1 IN (SELECT c1 FROM t4); +c1 +EXPLAIN SELECT * FROM t11 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t4); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t11 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t4); +c1 +DELETE FROM t11 WHERE c1='2015-04-14 09:22:33'; +ANALYZE TABLE t11; +Table Op Msg_type Msg_text +test.t11 analyze status OK +EXPLAIN SELECT 1 FROM t11 WHERE (SELECT 1 FROM t11 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t4 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t11 WHERE (SELECT 1 FROM t11 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t4 WHERE ASCII(c1) = 50); +1 +INSERT INTO t11 SET c1='2015-04-14 09:22:33'; +ANALYZE TABLE t11; +Table Op Msg_type Msg_text +test.t11 analyze status OK +EXPLAIN SELECT * FROM t11 STRAIGHT_JOIN t5 WHERE t11.c1=t5.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t11 STRAIGHT_JOIN t5 WHERE t11.c1=t5.c1; +c1 c1 +EXPLAIN SELECT * FROM t11 WHERE c1 IN (SELECT c1 FROM t5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# MATERIALIZED # # # # # # # # # # +SELECT * FROM t11 WHERE c1 IN (SELECT c1 FROM t5); +c1 +EXPLAIN SELECT * FROM t11 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t11 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t5); +c1 +DELETE FROM t11 WHERE c1='2015-04-14 09:22:33'; +ANALYZE TABLE t11; +Table Op Msg_type Msg_text +test.t11 analyze status OK +EXPLAIN SELECT 1 FROM t11 WHERE (SELECT 1 FROM t11 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t5 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t11 WHERE (SELECT 1 FROM t11 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t5 WHERE ASCII(c1) = 50); +1 +INSERT INTO t11 SET c1='2015-04-14 09:22:33'; +ANALYZE TABLE t11; +Table Op Msg_type Msg_text +test.t11 analyze status OK +EXPLAIN SELECT * FROM t11 STRAIGHT_JOIN t6 WHERE t11.c1=t6.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t11 STRAIGHT_JOIN t6 WHERE t11.c1=t6.c1; +c1 c1 +EXPLAIN SELECT * FROM t11 WHERE c1 IN (SELECT c1 FROM t6); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t11 WHERE c1 IN (SELECT c1 FROM t6); +c1 +EXPLAIN SELECT * FROM t11 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t6); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t11 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t6); +c1 +DELETE FROM t11 WHERE c1='2015-04-14 09:22:33'; +ANALYZE TABLE t11; +Table Op Msg_type Msg_text +test.t11 analyze status OK +EXPLAIN SELECT 1 FROM t11 WHERE (SELECT 1 FROM t11 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t6 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t11 WHERE (SELECT 1 FROM t11 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t6 WHERE ASCII(c1) = 50); +1 +1 +1 +INSERT INTO t11 SET c1='2015-04-14 09:22:33'; +ANALYZE TABLE t11; +Table Op Msg_type Msg_text +test.t11 analyze status OK +EXPLAIN SELECT * FROM t11 STRAIGHT_JOIN t7 WHERE t11.c1=t7.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t11 STRAIGHT_JOIN t7 WHERE t11.c1=t7.c1; +c1 c1 +EXPLAIN SELECT * FROM t11 WHERE c1 IN (SELECT c1 FROM t7); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t11 WHERE c1 IN (SELECT c1 FROM t7); +c1 +EXPLAIN SELECT * FROM t11 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t7); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t11 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t7); +c1 +DELETE FROM t11 WHERE c1='2015-04-14 09:22:33'; +ANALYZE TABLE t11; +Table Op Msg_type Msg_text +test.t11 analyze status OK +EXPLAIN SELECT 1 FROM t11 WHERE (SELECT 1 FROM t11 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t7 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t11 WHERE (SELECT 1 FROM t11 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t7 WHERE ASCII(c1) = 50); +1 +1 +1 +INSERT INTO t11 SET c1='2015-04-14 09:22:33'; +ANALYZE TABLE t11; +Table Op Msg_type Msg_text +test.t11 analyze status OK +EXPLAIN SELECT * FROM t11 STRAIGHT_JOIN t8 WHERE t11.c1=t8.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t11 STRAIGHT_JOIN t8 WHERE t11.c1=t8.c1; +c1 c1 +2015-04-13 10:22:33 10:22:33 +2015-04-14 09:22:33 33:22:33 +EXPLAIN SELECT * FROM t11 WHERE c1 IN (SELECT c1 FROM t8); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t11 WHERE c1 IN (SELECT c1 FROM t8); +c1 +2015-04-13 10:22:33 +2015-04-14 09:22:33 +EXPLAIN SELECT * FROM t11 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t8); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t11 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t8); +c1 +2015-04-13 10:22:33 +2015-04-14 09:22:33 +DELETE FROM t11 WHERE c1='2015-04-14 09:22:33'; +ANALYZE TABLE t11; +Table Op Msg_type Msg_text +test.t11 analyze status OK +EXPLAIN SELECT 1 FROM t11 WHERE (SELECT 1 FROM t11 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t8 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t11 WHERE (SELECT 1 FROM t11 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t8 WHERE ASCII(c1) = 50); +1 +INSERT INTO t11 SET c1='2015-04-14 09:22:33'; +ANALYZE TABLE t11; +Table Op Msg_type Msg_text +test.t11 analyze status OK +EXPLAIN SELECT * FROM t11 STRAIGHT_JOIN t9 WHERE t11.c1=t9.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t11 STRAIGHT_JOIN t9 WHERE t11.c1=t9.c1; +c1 c1 +2015-04-13 10:22:33 2015-04-13 10:22:33 +EXPLAIN SELECT * FROM t11 WHERE c1 IN (SELECT c1 FROM t9); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# MATERIALIZED # # # # # # # # # # +SELECT * FROM t11 WHERE c1 IN (SELECT c1 FROM t9); +c1 +2015-04-13 10:22:33 +EXPLAIN SELECT * FROM t11 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t9); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t11 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t9); +c1 +2015-04-13 10:22:33 +DELETE FROM t11 WHERE c1='2015-04-14 09:22:33'; +ANALYZE TABLE t11; +Table Op Msg_type Msg_text +test.t11 analyze status OK +EXPLAIN SELECT 1 FROM t11 WHERE (SELECT 1 FROM t11 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t9 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t11 WHERE (SELECT 1 FROM t11 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t9 WHERE ASCII(c1) = 50); +1 +1 +1 +INSERT INTO t11 SET c1='2015-04-14 09:22:33'; +ANALYZE TABLE t11; +Table Op Msg_type Msg_text +test.t11 analyze status OK +EXPLAIN SELECT * FROM t11 STRAIGHT_JOIN t10 WHERE t11.c1=t10.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t11 STRAIGHT_JOIN t10 WHERE t11.c1=t10.c1; +c1 c1 +EXPLAIN SELECT * FROM t11 WHERE c1 IN (SELECT c1 FROM t10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# MATERIALIZED # # # # # # # # # # +SELECT * FROM t11 WHERE c1 IN (SELECT c1 FROM t10); +c1 +EXPLAIN SELECT * FROM t11 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t11 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t10); +c1 +DELETE FROM t11 WHERE c1='2015-04-14 09:22:33'; +ANALYZE TABLE t11; +Table Op Msg_type Msg_text +test.t11 analyze status OK +EXPLAIN SELECT 1 FROM t11 WHERE (SELECT 1 FROM t11 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t10 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t11 WHERE (SELECT 1 FROM t11 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t10 WHERE ASCII(c1) = 50); +1 +1 +1 +INSERT INTO t11 SET c1='2015-04-14 09:22:33'; +ANALYZE TABLE t11; +Table Op Msg_type Msg_text +test.t11 analyze status OK +EXPLAIN SELECT * FROM t11 STRAIGHT_JOIN t12 WHERE t11.c1=t12.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t11 STRAIGHT_JOIN t12 WHERE t11.c1=t12.c1; +c1 c1 +EXPLAIN SELECT * FROM t11 WHERE c1 IN (SELECT c1 FROM t12); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t11 WHERE c1 IN (SELECT c1 FROM t12); +c1 +EXPLAIN SELECT * FROM t11 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t12); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t11 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t12); +c1 +DELETE FROM t11 WHERE c1='2015-04-14 09:22:33'; +ANALYZE TABLE t11; +Table Op Msg_type Msg_text +test.t11 analyze status OK +EXPLAIN SELECT 1 FROM t11 WHERE (SELECT 1 FROM t11 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t12 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t11 WHERE (SELECT 1 FROM t11 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t12 WHERE ASCII(c1) = 50); +1 +INSERT INTO t11 SET c1='2015-04-14 09:22:33'; +ANALYZE TABLE t11; +Table Op Msg_type Msg_text +test.t11 analyze status OK +EXPLAIN SELECT * FROM t11 STRAIGHT_JOIN t13 WHERE t11.c1=t13.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t11 STRAIGHT_JOIN t13 WHERE t11.c1=t13.c1; +c1 c1 +EXPLAIN SELECT * FROM t11 WHERE c1 IN (SELECT c1 FROM t13); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# MATERIALIZED # # # # # # # # # # +SELECT * FROM t11 WHERE c1 IN (SELECT c1 FROM t13); +c1 +EXPLAIN SELECT * FROM t11 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t13); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t11 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t13); +c1 +DELETE FROM t11 WHERE c1='2015-04-14 09:22:33'; +ANALYZE TABLE t11; +Table Op Msg_type Msg_text +test.t11 analyze status OK +EXPLAIN SELECT 1 FROM t11 WHERE (SELECT 1 FROM t11 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t13 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t11 WHERE (SELECT 1 FROM t11 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t13 WHERE ASCII(c1) = 50); +1 +INSERT INTO t11 SET c1='2015-04-14 09:22:33'; +ANALYZE TABLE t11; +Table Op Msg_type Msg_text +test.t11 analyze status OK +EXPLAIN SELECT * FROM t12 STRAIGHT_JOIN t1 WHERE t12.c1=t1.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t12 STRAIGHT_JOIN t1 WHERE t12.c1=t1.c1; +c1 c1 +19930513 19930513 +19950414 19950414 +EXPLAIN SELECT * FROM t12 WHERE c1 IN (SELECT c1 FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# MATERIALIZED # # # # # # # # # # +SELECT * FROM t12 WHERE c1 IN (SELECT c1 FROM t1); +c1 +19930513 +19950414 +EXPLAIN SELECT * FROM t12 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t12 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t1); +c1 +19930513 +19950414 +EXPLAIN SELECT 1 FROM t12 WHERE (SELECT 1 FROM t12 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t1 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t12 WHERE (SELECT 1 FROM t12 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t1 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t12 STRAIGHT_JOIN t2 WHERE t12.c1=t2.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t12 STRAIGHT_JOIN t2 WHERE t12.c1=t2.c1; +c1 c1 +19930513 19930513 +19950414 19950414 +EXPLAIN SELECT * FROM t12 WHERE c1 IN (SELECT c1 FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# MATERIALIZED # # # # # # # # # # +SELECT * FROM t12 WHERE c1 IN (SELECT c1 FROM t2); +c1 +19930513 +19950414 +EXPLAIN SELECT * FROM t12 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t12 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t2); +c1 +19930513 +19950414 +EXPLAIN SELECT 1 FROM t12 WHERE (SELECT 1 FROM t12 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t2 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t12 WHERE (SELECT 1 FROM t12 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t2 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t12 STRAIGHT_JOIN t3 WHERE t12.c1=t3.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t12 STRAIGHT_JOIN t3 WHERE t12.c1=t3.c1; +c1 c1 +19950414 19950414.00 +19950414.1 19950414.10 +EXPLAIN SELECT * FROM t12 WHERE c1 IN (SELECT c1 FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# MATERIALIZED # # # # # # # # # # +SELECT * FROM t12 WHERE c1 IN (SELECT c1 FROM t3); +c1 +19950414 +19950414.1 +EXPLAIN SELECT * FROM t12 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t12 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t3); +c1 +19950414 +19950414.1 +EXPLAIN SELECT 1 FROM t12 WHERE (SELECT 1 FROM t12 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t3 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t12 WHERE (SELECT 1 FROM t12 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t3 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t12 STRAIGHT_JOIN t4 WHERE t12.c1=t4.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t12 STRAIGHT_JOIN t4 WHERE t12.c1=t4.c1; +c1 c1 +19950414 19950400 +19950414 19950400 +EXPLAIN SELECT * FROM t12 WHERE c1 IN (SELECT c1 FROM t4); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# MATERIALIZED # # # # # # # # # # +SELECT * FROM t12 WHERE c1 IN (SELECT c1 FROM t4); +c1 +19950414 +EXPLAIN SELECT * FROM t12 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t4); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t12 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t4); +c1 +19950414 +EXPLAIN SELECT 1 FROM t12 WHERE (SELECT 1 FROM t12 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t4 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t12 WHERE (SELECT 1 FROM t12 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t4 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t12 STRAIGHT_JOIN t5 WHERE t12.c1=t5.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t12 STRAIGHT_JOIN t5 WHERE t12.c1=t5.c1; +c1 c1 +19950414 19950414 +19950414.1 19950414.1 +EXPLAIN SELECT * FROM t12 WHERE c1 IN (SELECT c1 FROM t5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# MATERIALIZED # # # # # # # # # # +SELECT * FROM t12 WHERE c1 IN (SELECT c1 FROM t5); +c1 +19950414 +19950414.1 +EXPLAIN SELECT * FROM t12 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t12 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t5); +c1 +19950414 +19950414.1 +EXPLAIN SELECT 1 FROM t12 WHERE (SELECT 1 FROM t12 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t5 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t12 WHERE (SELECT 1 FROM t12 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t5 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t12 STRAIGHT_JOIN t6 WHERE t12.c1=t6.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t12 STRAIGHT_JOIN t6 WHERE t12.c1=t6.c1; +c1 c1 +19910111 19910111 +19930513 19930513 +19950414 19950414 +19950414.1 19950414.1 +20010513 20010513 +EXPLAIN SELECT * FROM t12 WHERE c1 IN (SELECT c1 FROM t6); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t12 WHERE c1 IN (SELECT c1 FROM t6); +c1 +19910111 +19930513 +19950414 +19950414.1 +20010513 +EXPLAIN SELECT * FROM t12 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t6); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t12 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t6); +c1 +19910111 +19930513 +19950414 +19950414.1 +20010513 +EXPLAIN SELECT 1 FROM t12 WHERE (SELECT 1 FROM t12 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t6 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t12 WHERE (SELECT 1 FROM t12 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t6 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t12 STRAIGHT_JOIN t7 WHERE t12.c1=t7.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t12 STRAIGHT_JOIN t7 WHERE t12.c1=t7.c1; +c1 c1 +19910111 19910111 +19930513 19930513 +19950414 19950414 +19950414.1 19950414.1 +20010513 20010513 +EXPLAIN SELECT * FROM t12 WHERE c1 IN (SELECT c1 FROM t7); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t12 WHERE c1 IN (SELECT c1 FROM t7); +c1 +19910111 +19930513 +19950414 +19950414.1 +20010513 +EXPLAIN SELECT * FROM t12 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t7); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t12 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t7); +c1 +19910111 +19930513 +19950414 +19950414.1 +20010513 +EXPLAIN SELECT 1 FROM t12 WHERE (SELECT 1 FROM t12 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t7 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t12 WHERE (SELECT 1 FROM t12 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t7 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t12 STRAIGHT_JOIN t8 WHERE t12.c1=t8.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t12 STRAIGHT_JOIN t8 WHERE t12.c1=t8.c1; +c1 c1 +EXPLAIN SELECT * FROM t12 WHERE c1 IN (SELECT c1 FROM t8); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t12 WHERE c1 IN (SELECT c1 FROM t8); +c1 +EXPLAIN SELECT * FROM t12 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t8); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t12 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t8); +c1 +EXPLAIN SELECT 1 FROM t12 WHERE (SELECT 1 FROM t12 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t8 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t12 WHERE (SELECT 1 FROM t12 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t8 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t12 STRAIGHT_JOIN t9 WHERE t12.c1=t9.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t12 STRAIGHT_JOIN t9 WHERE t12.c1=t9.c1; +c1 c1 +EXPLAIN SELECT * FROM t12 WHERE c1 IN (SELECT c1 FROM t9); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t12 WHERE c1 IN (SELECT c1 FROM t9); +c1 +EXPLAIN SELECT * FROM t12 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t9); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t12 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t9); +c1 +EXPLAIN SELECT 1 FROM t12 WHERE (SELECT 1 FROM t12 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t9 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t12 WHERE (SELECT 1 FROM t12 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t9 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t12 STRAIGHT_JOIN t10 WHERE t12.c1=t10.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t12 STRAIGHT_JOIN t10 WHERE t12.c1=t10.c1; +c1 c1 +EXPLAIN SELECT * FROM t12 WHERE c1 IN (SELECT c1 FROM t10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t12 WHERE c1 IN (SELECT c1 FROM t10); +c1 +EXPLAIN SELECT * FROM t12 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t12 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t10); +c1 +EXPLAIN SELECT 1 FROM t12 WHERE (SELECT 1 FROM t12 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t10 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t12 WHERE (SELECT 1 FROM t12 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t10 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t12 STRAIGHT_JOIN t11 WHERE t12.c1=t11.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t12 STRAIGHT_JOIN t11 WHERE t12.c1=t11.c1; +c1 c1 +EXPLAIN SELECT * FROM t12 WHERE c1 IN (SELECT c1 FROM t11); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t12 WHERE c1 IN (SELECT c1 FROM t11); +c1 +EXPLAIN SELECT * FROM t12 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t11); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t12 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t11); +c1 +EXPLAIN SELECT 1 FROM t12 WHERE (SELECT 1 FROM t12 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t11 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t12 WHERE (SELECT 1 FROM t12 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t11 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t12 STRAIGHT_JOIN t13 WHERE t12.c1=t13.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t12 STRAIGHT_JOIN t13 WHERE t12.c1=t13.c1; +c1 c1 +19950414 19950414 +EXPLAIN SELECT * FROM t12 WHERE c1 IN (SELECT c1 FROM t13); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# MATERIALIZED # # # # # # # # # # +SELECT * FROM t12 WHERE c1 IN (SELECT c1 FROM t13); +c1 +19950414 +EXPLAIN SELECT * FROM t12 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t13); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t12 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t13); +c1 +19950414 +EXPLAIN SELECT 1 FROM t12 WHERE (SELECT 1 FROM t12 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t13 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t12 WHERE (SELECT 1 FROM t12 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t13 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t13 STRAIGHT_JOIN t1 WHERE t13.c1=t1.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t13 STRAIGHT_JOIN t1 WHERE t13.c1=t1.c1; +c1 c1 +19950414 19950414 +EXPLAIN SELECT * FROM t13 WHERE c1 IN (SELECT c1 FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# MATERIALIZED # # # # # # # # # # +SELECT * FROM t13 WHERE c1 IN (SELECT c1 FROM t1); +c1 +19950414 +EXPLAIN SELECT * FROM t13 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t13 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t1); +c1 +19950414 +EXPLAIN SELECT 1 FROM t13 WHERE (SELECT 1 FROM t13 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t1 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t13 WHERE (SELECT 1 FROM t13 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t1 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t13 STRAIGHT_JOIN t2 WHERE t13.c1=t2.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t13 STRAIGHT_JOIN t2 WHERE t13.c1=t2.c1; +c1 c1 +19950414 19950414 +EXPLAIN SELECT * FROM t13 WHERE c1 IN (SELECT c1 FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# MATERIALIZED # # # # # # # # # # +SELECT * FROM t13 WHERE c1 IN (SELECT c1 FROM t2); +c1 +19950414 +EXPLAIN SELECT * FROM t13 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t13 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t2); +c1 +19950414 +EXPLAIN SELECT 1 FROM t13 WHERE (SELECT 1 FROM t13 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t2 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t13 WHERE (SELECT 1 FROM t13 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t2 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t13 STRAIGHT_JOIN t3 WHERE t13.c1=t3.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t13 STRAIGHT_JOIN t3 WHERE t13.c1=t3.c1; +c1 c1 +19950414 19950414.00 +EXPLAIN SELECT * FROM t13 WHERE c1 IN (SELECT c1 FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# MATERIALIZED # # # # # # # # # # +SELECT * FROM t13 WHERE c1 IN (SELECT c1 FROM t3); +c1 +19950414 +EXPLAIN SELECT * FROM t13 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t13 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t3); +c1 +19950414 +EXPLAIN SELECT 1 FROM t13 WHERE (SELECT 1 FROM t13 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t3 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t13 WHERE (SELECT 1 FROM t13 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t3 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t13 STRAIGHT_JOIN t4 WHERE t13.c1=t4.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t13 STRAIGHT_JOIN t4 WHERE t13.c1=t4.c1; +c1 c1 +19950414 19950400 +19950414 19950400 +EXPLAIN SELECT * FROM t13 WHERE c1 IN (SELECT c1 FROM t4); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# MATERIALIZED # # # # # # # # # # +SELECT * FROM t13 WHERE c1 IN (SELECT c1 FROM t4); +c1 +19950414 +EXPLAIN SELECT * FROM t13 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t4); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t13 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t4); +c1 +19950414 +EXPLAIN SELECT 1 FROM t13 WHERE (SELECT 1 FROM t13 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t4 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t13 WHERE (SELECT 1 FROM t13 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t4 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t13 STRAIGHT_JOIN t5 WHERE t13.c1=t5.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t13 STRAIGHT_JOIN t5 WHERE t13.c1=t5.c1; +c1 c1 +19950414 19950414 +EXPLAIN SELECT * FROM t13 WHERE c1 IN (SELECT c1 FROM t5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# MATERIALIZED # # # # # # # # # # +SELECT * FROM t13 WHERE c1 IN (SELECT c1 FROM t5); +c1 +19950414 +EXPLAIN SELECT * FROM t13 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t13 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t5); +c1 +19950414 +EXPLAIN SELECT 1 FROM t13 WHERE (SELECT 1 FROM t13 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t5 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t13 WHERE (SELECT 1 FROM t13 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t5 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t13 STRAIGHT_JOIN t6 WHERE t13.c1=t6.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t13 STRAIGHT_JOIN t6 WHERE t13.c1=t6.c1; +c1 c1 +19950414 19950414 +EXPLAIN SELECT * FROM t13 WHERE c1 IN (SELECT c1 FROM t6); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t13 WHERE c1 IN (SELECT c1 FROM t6); +c1 +19950414 +EXPLAIN SELECT * FROM t13 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t6); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t13 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t6); +c1 +19950414 +EXPLAIN SELECT 1 FROM t13 WHERE (SELECT 1 FROM t13 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t6 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t13 WHERE (SELECT 1 FROM t13 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t6 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t13 STRAIGHT_JOIN t7 WHERE t13.c1=t7.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t13 STRAIGHT_JOIN t7 WHERE t13.c1=t7.c1; +c1 c1 +19950414 19950414 +EXPLAIN SELECT * FROM t13 WHERE c1 IN (SELECT c1 FROM t7); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t13 WHERE c1 IN (SELECT c1 FROM t7); +c1 +19950414 +EXPLAIN SELECT * FROM t13 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t7); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t13 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t7); +c1 +19950414 +EXPLAIN SELECT 1 FROM t13 WHERE (SELECT 1 FROM t13 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t7 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t13 WHERE (SELECT 1 FROM t13 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t7 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t13 STRAIGHT_JOIN t8 WHERE t13.c1=t8.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t13 STRAIGHT_JOIN t8 WHERE t13.c1=t8.c1; +c1 c1 +EXPLAIN SELECT * FROM t13 WHERE c1 IN (SELECT c1 FROM t8); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t13 WHERE c1 IN (SELECT c1 FROM t8); +c1 +EXPLAIN SELECT * FROM t13 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t8); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t13 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t8); +c1 +EXPLAIN SELECT 1 FROM t13 WHERE (SELECT 1 FROM t13 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t8 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t13 WHERE (SELECT 1 FROM t13 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t8 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t13 STRAIGHT_JOIN t9 WHERE t13.c1=t9.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t13 STRAIGHT_JOIN t9 WHERE t13.c1=t9.c1; +c1 c1 +EXPLAIN SELECT * FROM t13 WHERE c1 IN (SELECT c1 FROM t9); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t13 WHERE c1 IN (SELECT c1 FROM t9); +c1 +EXPLAIN SELECT * FROM t13 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t9); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t13 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t9); +c1 +EXPLAIN SELECT 1 FROM t13 WHERE (SELECT 1 FROM t13 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t9 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t13 WHERE (SELECT 1 FROM t13 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t9 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t13 STRAIGHT_JOIN t10 WHERE t13.c1=t10.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t13 STRAIGHT_JOIN t10 WHERE t13.c1=t10.c1; +c1 c1 +EXPLAIN SELECT * FROM t13 WHERE c1 IN (SELECT c1 FROM t10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t13 WHERE c1 IN (SELECT c1 FROM t10); +c1 +EXPLAIN SELECT * FROM t13 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t13 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t10); +c1 +EXPLAIN SELECT 1 FROM t13 WHERE (SELECT 1 FROM t13 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t10 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t13 WHERE (SELECT 1 FROM t13 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t10 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t13 STRAIGHT_JOIN t11 WHERE t13.c1=t11.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t13 STRAIGHT_JOIN t11 WHERE t13.c1=t11.c1; +c1 c1 +EXPLAIN SELECT * FROM t13 WHERE c1 IN (SELECT c1 FROM t11); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t13 WHERE c1 IN (SELECT c1 FROM t11); +c1 +EXPLAIN SELECT * FROM t13 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t11); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t13 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t11); +c1 +EXPLAIN SELECT 1 FROM t13 WHERE (SELECT 1 FROM t13 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t11 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t13 WHERE (SELECT 1 FROM t13 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t11 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t13 STRAIGHT_JOIN t12 WHERE t13.c1=t12.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t13 STRAIGHT_JOIN t12 WHERE t13.c1=t12.c1; +c1 c1 +19950414 19950414 +EXPLAIN SELECT * FROM t13 WHERE c1 IN (SELECT c1 FROM t12); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t13 WHERE c1 IN (SELECT c1 FROM t12); +c1 +19950414 +EXPLAIN SELECT * FROM t13 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t12); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t13 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t12); +c1 +19950414 +EXPLAIN SELECT 1 FROM t13 WHERE (SELECT 1 FROM t13 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t12 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t13 WHERE (SELECT 1 FROM t13 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t12 WHERE ASCII(c1) = 50); +1 +SET TIMESTAMP=UNIX_TIMESTAMP(20140413000000); +EXPLAIN SELECT * FROM t8 STRAIGHT_JOIN t9 WHERE t8.c1=t9.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t8 STRAIGHT_JOIN t9 WHERE t8.c1=t9.c1; +c1 c1 +EXPLAIN SELECT * FROM t8 WHERE c1 IN (SELECT c1 FROM t9); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# MATERIALIZED # # # # # # # # # # +SELECT * FROM t8 WHERE c1 IN (SELECT c1 FROM t9); +c1 +EXPLAIN SELECT * FROM t9 STRAIGHT_JOIN t8 WHERE t9.c1=t8.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t9 STRAIGHT_JOIN t8 WHERE t9.c1=t8.c1; +c1 c1 +EXPLAIN SELECT * FROM t9 WHERE c1 IN (SELECT c1 FROM t8); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t9 WHERE c1 IN (SELECT c1 FROM t8); +c1 +DROP TABLE t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13; diff --git a/mysql-test/r/subquery_sj_all.result-pq b/mysql-test/r/subquery_sj_all.result-pq new file mode 100644 index 000000000000..6bec0530015e --- /dev/null +++ b/mysql-test/r/subquery_sj_all.result-pq @@ -0,0 +1,12993 @@ +set optimizer_switch='semijoin=on,materialization=on,firstmatch=on,loosescan=on,index_condition_pushdown=on,mrr=on,mrr_cost_based=off'; +set @old_opt_switch=@@optimizer_switch; +set optimizer_switch='subquery_materialization_cost_based=off'; +drop table if exists t0, t1, t2, t10, t11, t12; +create table t1 (a int not null, b int, primary key (a)); +create table t2 (a int not null, primary key (a)); +create table t3 (a int not null, b int, primary key (a)); +insert into t1 values (1,10), (2,20), (3,30), (4,40); +insert into t2 values (2), (3), (4), (5); +insert into t3 values (10,3), (20,4), (30,5); +select * from t2 where t2.a in (select a from t1); +a +2 +3 +4 +explain select * from t2 where t2.a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index PRIMARY PRIMARY 4 NULL 4 100.00 Using index +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t1` join `test`.`t2` where (`test`.`t1`.`a` = `test`.`t2`.`a`) +select * from t2 where t2.a in (select a from t1 where t1.b <> 30); +a +2 +4 +explain select * from t2 where t2.a in (select a from t1 where t1.b <> 30); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL PRIMARY NULL NULL NULL 4 75.00 Using where +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`a` = `test`.`t1`.`a`) and (`test`.`t1`.`b` <> 30)) +select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a); +a +2 +3 +explain select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL index PRIMARY PRIMARY 4 NULL 3 100.00 Using index +1 SIMPLE t1 NULL ALL PRIMARY NULL NULL NULL 4 25.00 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t1` join `test`.`t3` join `test`.`t2` where ((`test`.`t2`.`a` = `test`.`t1`.`a`) and (`test`.`t1`.`b` = `test`.`t3`.`a`)) +drop table t1, t2, t3; +create table t1 (a int, b int, index a (a,b)); +create table t2 (a int, index a (a)); +create table t3 (a int, b int, index a (a)); +insert into t1 values (1,10), (2,20), (3,30), (4,40); +create table t0(a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +insert into t1 +select rand()*100000+200,rand()*100000 from t0 A, t0 B, t0 C, t0 D; +insert into t2 values (2), (3), (4), (5); +insert into t3 values (10,3), (20,4), (30,5); +select * from t2 where t2.a in (select a from t1); +a +2 +3 +4 +explain select * from t2 where t2.a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index a a 5 NULL 4 100.00 Using where; Using index +1 SIMPLE t1 NULL ref a a 5 test.t2.a 101 100.00 Using index; FirstMatch(t2) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1`) where (`test`.`t1`.`a` = `test`.`t2`.`a`) +select * from t2 where t2.a in (select a from t1 where t1.b <> 30); +a +2 +4 +explain select * from t2 where t2.a in (select a from t1 where t1.b <> 30); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index a a 5 NULL 4 100.00 Using where; Using index +1 SIMPLE t1 NULL ref a a 5 test.t2.a 101 90.00 Using where; Using index; FirstMatch(t2) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1`) where ((`test`.`t1`.`a` = `test`.`t2`.`a`) and (`test`.`t1`.`b` <> 30)) +select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a); +a +2 +3 +explain select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index a a 5 NULL 4 100.00 Using where; Using index +1 SIMPLE t3 NULL index a a 5 NULL 3 100.00 Using where; Using index +1 SIMPLE t1 NULL ref a a 10 test.t2.a,test.t3.a 116 100.00 Using index; FirstMatch(t2) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1` join `test`.`t3`) where ((`test`.`t1`.`a` = `test`.`t2`.`a`) and (`test`.`t1`.`b` = `test`.`t3`.`a`)) +insert into t1 values (3,31); +select * from t2 where t2.a in (select a from t1 where t1.b <> 30); +a +2 +3 +4 +select * from t2 where t2.a in (select a from t1 where t1.b <> 30 and t1.b <> 31); +a +2 +4 +explain select * from t2 where t2.a in (select a from t1 where t1.b <> 30); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index a a 5 NULL 4 100.00 Using where; Using index +1 SIMPLE t1 NULL ref a a 5 test.t2.a 101 90.00 Using where; Using index; FirstMatch(t2) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1`) where ((`test`.`t1`.`a` = `test`.`t2`.`a`) and (`test`.`t1`.`b` <> 30)) +drop table t0, t1, t2, t3; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1(a int, b int); +insert into t1 values (0,0),(1,1),(2,2); +create table t2 as select * from t1; +create table t11(a int, b int); +create table t10 (pk int, a int, primary key(pk)); +insert into t10 select a,a from t0; +create table t12 like t10; +insert into t12 select * from t10; +Flattened because of dependency, t10=func(t1) +explain select * from t1 where a in (select pk from t10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t1` where (`test`.`t10`.`pk` = `test`.`t1`.`a`) +select * from t1 where a in (select pk from t10); +a b +0 0 +1 1 +2 2 +A confluent case of dependency +explain select * from t1 where a in (select a from t10 where pk=12); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t1` where (multiple equal(12, NULL) and multiple equal(`test`.`t1`.`a`, NULL)) +select * from t1 where a in (select a from t10 where pk=12); +a b +explain select * from t1 where a in (select a from t10 where pk=9); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t10 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t1` where ((`test`.`t1`.`a` = '9')) +select * from t1 where a in (select a from t10 where pk=9); +a b +An empty table inside +explain select * from t1 where a in (select a from t11); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 0.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +2 MATERIALIZED t11 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t11`) where (`test`.`t1`.`a` = ``.`a`) +select * from t1 where a in (select a from t11); +a b +explain select * from t1 where a in (select pk from t10) and b in (select pk from t10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using index +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.t1.b 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t10` join `test`.`t1` where ((`test`.`t10`.`pk` = `test`.`t1`.`b`) and (`test`.`t10`.`pk` = `test`.`t1`.`a`)) +select * from t1 where a in (select pk from t10) and b in (select pk from t10); +a b +0 0 +1 1 +2 2 +flattening a nested subquery +explain select * from t1 where a in (select pk from t10 where t10.a in (select pk from t12)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using where +1 SIMPLE t12 NULL eq_ref PRIMARY PRIMARY 4 test.t10.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t12` join `test`.`t1` where ((`test`.`t10`.`pk` = `test`.`t1`.`a`) and (`test`.`t12`.`pk` = `test`.`t10`.`a`)) +select * from t1 where a in (select pk from t10 where t10.a in (select pk from t12)); +a b +0 0 +1 1 +2 2 +flattening subquery w/ several tables +explain select * from t1 where a in (select t10.pk from t10, t12 where t12.pk=t10.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using where +1 SIMPLE t12 NULL eq_ref PRIMARY PRIMARY 4 test.t10.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t12` join `test`.`t1` where ((`test`.`t10`.`pk` = `test`.`t1`.`a`) and (`test`.`t12`.`pk` = `test`.`t10`.`a`)) +subqueries within outer joins go into ON expr. +explain +select * from t1 left join (t2 A, t2 B) on ( A.A= t1.A and B.A in (select pk from t10)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE A NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE B NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.B.A 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`A` AS `A`,`test`.`t1`.`B` AS `B`,`test`.`A`.`A` AS `A`,`test`.`A`.`B` AS `B`,`test`.`B`.`A` AS `A`,`test`.`B`.`B` AS `B` from `test`.`t1` left join (`test`.`t10` join `test`.`t2` `A` join `test`.`t2` `B`) on(((`test`.`t10`.`pk` = `test`.`B`.`A`) and (`test`.`A`.`A` = `test`.`t1`.`A`))) where true +t2 should be wrapped into OJ-nest, so we have "t1 LJ (t2 J t10)" +explain +select * from t1 left join t2 on (t2.A= t1.A and t2.A in (select pk from t10)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.t1.A 1 100.00 Using index +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`A` AS `A`,`test`.`t1`.`B` AS `B`,`test`.`t2`.`A` AS `A`,`test`.`t2`.`B` AS `B` from `test`.`t1` left join (`test`.`t10` join `test`.`t2`) on(((`test`.`t10`.`pk` = `test`.`t1`.`A`) and (`test`.`t2`.`A` = `test`.`t1`.`A`))) where true +we shouldn't flatten if we're going to get a join of > MAX_TABLES. +explain select * from +t1 s00, t1 s01, t1 s02, t1 s03, t1 s04,t1 s05,t1 s06,t1 s07,t1 s08,t1 s09, +t1 s10, t1 s11, t1 s12, t1 s13, t1 s14,t1 s15,t1 s16,t1 s17,t1 s18,t1 s19, +t1 s20, t1 s21, t1 s22, t1 s23, t1 s24,t1 s25,t1 s26,t1 s27,t1 s28,t1 s29, +t1 s30, t1 s31, t1 s32, t1 s33, t1 s34,t1 s35,t1 s36,t1 s37,t1 s38,t1 s39, +t1 s40, t1 s41, t1 s42, t1 s43, t1 s44,t1 s45,t1 s46,t1 s47,t1 s48,t1 s49 +where +s00.a in ( +select m00.a from +t1 m00, t1 m01, t1 m02, t1 m03, t1 m04,t1 m05,t1 m06,t1 m07,t1 m08,t1 m09, +t1 m10, t1 m11, t1 m12, t1 m13, t1 m14,t1 m15,t1 m16,t1 m17,t1 m18,t1 m19 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY s00 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 PRIMARY s01 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s02 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s03 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s04 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s05 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s06 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s07 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s08 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s09 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s10 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s11 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s12 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s13 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s14 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s15 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s16 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s17 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s18 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s19 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s20 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s21 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s22 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s23 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s24 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s25 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s26 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s27 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s28 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s29 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s30 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s31 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s32 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s33 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s34 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s35 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s36 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s37 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s38 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s39 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s40 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s41 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s42 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s43 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s44 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s45 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s46 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s47 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s48 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s49 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 SUBQUERY m00 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 SUBQUERY m01 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 SUBQUERY m02 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 SUBQUERY m03 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 SUBQUERY m04 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 SUBQUERY m05 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 SUBQUERY m06 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 SUBQUERY m07 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 SUBQUERY m08 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 SUBQUERY m09 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 SUBQUERY m10 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 SUBQUERY m11 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 SUBQUERY m12 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 SUBQUERY m13 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 SUBQUERY m14 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 SUBQUERY m15 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 SUBQUERY m16 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 SUBQUERY m17 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 SUBQUERY m18 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 SUBQUERY m19 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`s00`.`a` AS `a`,`test`.`s00`.`b` AS `b`,`test`.`s01`.`a` AS `a`,`test`.`s01`.`b` AS `b`,`test`.`s02`.`a` AS `a`,`test`.`s02`.`b` AS `b`,`test`.`s03`.`a` AS `a`,`test`.`s03`.`b` AS `b`,`test`.`s04`.`a` AS `a`,`test`.`s04`.`b` AS `b`,`test`.`s05`.`a` AS `a`,`test`.`s05`.`b` AS `b`,`test`.`s06`.`a` AS `a`,`test`.`s06`.`b` AS `b`,`test`.`s07`.`a` AS `a`,`test`.`s07`.`b` AS `b`,`test`.`s08`.`a` AS `a`,`test`.`s08`.`b` AS `b`,`test`.`s09`.`a` AS `a`,`test`.`s09`.`b` AS `b`,`test`.`s10`.`a` AS `a`,`test`.`s10`.`b` AS `b`,`test`.`s11`.`a` AS `a`,`test`.`s11`.`b` AS `b`,`test`.`s12`.`a` AS `a`,`test`.`s12`.`b` AS `b`,`test`.`s13`.`a` AS `a`,`test`.`s13`.`b` AS `b`,`test`.`s14`.`a` AS `a`,`test`.`s14`.`b` AS `b`,`test`.`s15`.`a` AS `a`,`test`.`s15`.`b` AS `b`,`test`.`s16`.`a` AS `a`,`test`.`s16`.`b` AS `b`,`test`.`s17`.`a` AS `a`,`test`.`s17`.`b` AS `b`,`test`.`s18`.`a` AS `a`,`test`.`s18`.`b` AS `b`,`test`.`s19`.`a` AS `a`,`test`.`s19`.`b` AS `b`,`test`.`s20`.`a` AS `a`,`test`.`s20`.`b` AS `b`,`test`.`s21`.`a` AS `a`,`test`.`s21`.`b` AS `b`,`test`.`s22`.`a` AS `a`,`test`.`s22`.`b` AS `b`,`test`.`s23`.`a` AS `a`,`test`.`s23`.`b` AS `b`,`test`.`s24`.`a` AS `a`,`test`.`s24`.`b` AS `b`,`test`.`s25`.`a` AS `a`,`test`.`s25`.`b` AS `b`,`test`.`s26`.`a` AS `a`,`test`.`s26`.`b` AS `b`,`test`.`s27`.`a` AS `a`,`test`.`s27`.`b` AS `b`,`test`.`s28`.`a` AS `a`,`test`.`s28`.`b` AS `b`,`test`.`s29`.`a` AS `a`,`test`.`s29`.`b` AS `b`,`test`.`s30`.`a` AS `a`,`test`.`s30`.`b` AS `b`,`test`.`s31`.`a` AS `a`,`test`.`s31`.`b` AS `b`,`test`.`s32`.`a` AS `a`,`test`.`s32`.`b` AS `b`,`test`.`s33`.`a` AS `a`,`test`.`s33`.`b` AS `b`,`test`.`s34`.`a` AS `a`,`test`.`s34`.`b` AS `b`,`test`.`s35`.`a` AS `a`,`test`.`s35`.`b` AS `b`,`test`.`s36`.`a` AS `a`,`test`.`s36`.`b` AS `b`,`test`.`s37`.`a` AS `a`,`test`.`s37`.`b` AS `b`,`test`.`s38`.`a` AS `a`,`test`.`s38`.`b` AS `b`,`test`.`s39`.`a` AS `a`,`test`.`s39`.`b` AS `b`,`test`.`s40`.`a` AS `a`,`test`.`s40`.`b` AS `b`,`test`.`s41`.`a` AS `a`,`test`.`s41`.`b` AS `b`,`test`.`s42`.`a` AS `a`,`test`.`s42`.`b` AS `b`,`test`.`s43`.`a` AS `a`,`test`.`s43`.`b` AS `b`,`test`.`s44`.`a` AS `a`,`test`.`s44`.`b` AS `b`,`test`.`s45`.`a` AS `a`,`test`.`s45`.`b` AS `b`,`test`.`s46`.`a` AS `a`,`test`.`s46`.`b` AS `b`,`test`.`s47`.`a` AS `a`,`test`.`s47`.`b` AS `b`,`test`.`s48`.`a` AS `a`,`test`.`s48`.`b` AS `b`,`test`.`s49`.`a` AS `a`,`test`.`s49`.`b` AS `b` from `test`.`t1` `s00` join `test`.`t1` `s01` join `test`.`t1` `s02` join `test`.`t1` `s03` join `test`.`t1` `s04` join `test`.`t1` `s05` join `test`.`t1` `s06` join `test`.`t1` `s07` join `test`.`t1` `s08` join `test`.`t1` `s09` join `test`.`t1` `s10` join `test`.`t1` `s11` join `test`.`t1` `s12` join `test`.`t1` `s13` join `test`.`t1` `s14` join `test`.`t1` `s15` join `test`.`t1` `s16` join `test`.`t1` `s17` join `test`.`t1` `s18` join `test`.`t1` `s19` join `test`.`t1` `s20` join `test`.`t1` `s21` join `test`.`t1` `s22` join `test`.`t1` `s23` join `test`.`t1` `s24` join `test`.`t1` `s25` join `test`.`t1` `s26` join `test`.`t1` `s27` join `test`.`t1` `s28` join `test`.`t1` `s29` join `test`.`t1` `s30` join `test`.`t1` `s31` join `test`.`t1` `s32` join `test`.`t1` `s33` join `test`.`t1` `s34` join `test`.`t1` `s35` join `test`.`t1` `s36` join `test`.`t1` `s37` join `test`.`t1` `s38` join `test`.`t1` `s39` join `test`.`t1` `s40` join `test`.`t1` `s41` join `test`.`t1` `s42` join `test`.`t1` `s43` join `test`.`t1` `s44` join `test`.`t1` `s45` join `test`.`t1` `s46` join `test`.`t1` `s47` join `test`.`t1` `s48` join `test`.`t1` `s49` where (`test`.`s00`.`a`,`test`.`s00`.`a` in ( (/* select#2 */ select `test`.`m00`.`a` from `test`.`t1` `m00` join `test`.`t1` `m01` join `test`.`t1` `m02` join `test`.`t1` `m03` join `test`.`t1` `m04` join `test`.`t1` `m05` join `test`.`t1` `m06` join `test`.`t1` `m07` join `test`.`t1` `m08` join `test`.`t1` `m09` join `test`.`t1` `m10` join `test`.`t1` `m11` join `test`.`t1` `m12` join `test`.`t1` `m13` join `test`.`t1` `m14` join `test`.`t1` `m15` join `test`.`t1` `m16` join `test`.`t1` `m17` join `test`.`t1` `m18` join `test`.`t1` `m19` where true ), (`test`.`s00`.`a` in on where ((`test`.`s00`.`a` = ``.`a`))))) +select * from +t1 left join t2 on (t2.a= t1.a and t2.a in (select pk from t10)) +where t1.a < 5; +a b a b +0 0 0 0 +1 1 1 1 +2 2 2 2 +prepare s1 from +' select * from + t1 left join t2 on (t2.a= t1.a and t2.a in (select pk from t10)) + where t1.a < 5'; +execute s1; +a b a b +0 0 0 0 +1 1 1 1 +2 2 2 2 +execute s1; +a b a b +0 0 0 0 +1 1 1 1 +2 2 2 2 +insert into t1 select (A.a + 10 * B.a),1 from t0 A, t0 B; +explain select * from t1 where a in (select pk from t10 where pk<3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t10 NULL range PRIMARY PRIMARY 4 NULL 4 100.00 Using where; Using index +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 103 10.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t1` where ((`test`.`t1`.`a` = `test`.`t10`.`pk`) and (`test`.`t10`.`pk` < 3)) +drop table t0, t1, t2; +drop table t10, t11, t12; +# +# Check that subqueries with outer joins or straight_join work for +# different permutations of const and non-const tables. (Ref. Bug#46692) +# +CREATE TABLE t1 (i INTEGER); +CREATE TABLE t2 (i INTEGER); +CREATE TABLE t3 (i INTEGER); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 0 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 0 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 0 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 1 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 1 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 1 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 2 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 2 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 2 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (0); +DELETE FROM t2; +INSERT INTO t1 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 0 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 0 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 0 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 1 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 1 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 1 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 2 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 2 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 2 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (0); +DELETE FROM t2; +INSERT INTO t1 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 0 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 0.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = ``.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 0.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = ``.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 0.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = ``.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 0.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 0.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t1`.`i` = ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 0 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = ``.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = ``.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = ``.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t1`.`i` = ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 0 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t2`.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t2`.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t2`.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +1 +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = `test`.`t1`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 1 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 0.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = ``.`i`) and (`test`.`t2`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 0.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = ``.`i`) and (`test`.`t2`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 0.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = ``.`i`) and (`test`.`t2`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 0.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 0.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t1`.`i` = ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 1 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = `test`.`t2`.`i`) and (`test`.`t1`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = `test`.`t2`.`i`) and (`test`.`t1`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = `test`.`t2`.`i`) and (`test`.`t1`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 1 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t2`.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t2`.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t2`.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +1 +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = `test`.`t1`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +1 +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 2 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t3`.`i`) and (`test`.`t2`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t3`.`i`) and (`test`.`t2`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t3`.`i`) and (`test`.`t2`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 0.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t1`.`i` = ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 2 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t3`.`i`) and (`test`.`t2`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t3`.`i`) and (`test`.`t2`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t3`.`i`) and (`test`.`t2`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t1`.`i` = ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 2 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = `test`.`t1`.`i`) and (`test`.`t3`.`i` = `test`.`t1`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +1 +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +1 +2 + +EXECUTE stmt; +i +1 +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = `test`.`t1`.`i`) and (`test`.`t3`.`i` = `test`.`t1`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +1 +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = `test`.`t1`.`i`) and (`test`.`t3`.`i` = `test`.`t1`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +1 +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +1 +2 + +EXECUTE stmt; +i +1 +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = `test`.`t1`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +1 +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE NULL eq_ref 5 test.t1.i 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (``.`i` = `test`.`t1`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +1 +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (0); +DELETE FROM t2; +INSERT INTO t1 VALUES (0); +DROP TABLE t1, t2, t3; +create table x1(k int primary key, d1 int, d2 int); +create table x2(k int primary key, d1 int, d2 int); +insert into x1 values +(10, 10, 10), +(20, 20, 20), +(21, 20, null), +(30, null, 30), +(40, 40, 40); +insert into x2 values +(10, 10, 10), +(20, 20, 20), +(21, 20, null), +(30, null, 30); +select * +from x1 +where (d1, d2) in (select d1, d2 +from x2); +k d1 d2 +10 10 10 +20 20 20 +select * +from x1 +where (d1, d2) in (select d1, d2 +from x2) is true; +k d1 d2 +10 10 10 +20 20 20 +select * +from x1 +where (d1, d2) in (select d1, d2 +from x2) is false; +k d1 d2 +40 40 40 +select * +from x1 +where (d1, d2) in (select d1, d2 +from x2) is unknown; +k d1 d2 +21 20 NULL +30 NULL 30 +select * +from x1 +where d1 in (select d1 +from x2 +where x1.d2=x2.d2); +k d1 d2 +10 10 10 +20 20 20 +select * +from x1 +where d1 in (select d1 +from x2 +where x1.d2=x2.d2) is true; +k d1 d2 +10 10 10 +20 20 20 +select * +from x1 +where d1 in (select d1 +from x2 +where x1.d2=x2.d2) is false; +k d1 d2 +21 20 NULL +40 40 40 +select * +from x1 +where d1 in (select d1 +from x2 +where x1.d2=x2.d2) is unknown; +k d1 d2 +30 NULL 30 +select * +from x1 +where 1 in (select 1 +from x2 +where x1.d1=x2.d1 and x1.d2=x2.d2); +k d1 d2 +10 10 10 +20 20 20 +select * +from x1 +where 1 in (select 1 +from x2 +where x1.d1=x2.d1 and x1.d2=x2.d2) is true; +k d1 d2 +10 10 10 +20 20 20 +select * +from x1 +where 1 in (select 1 +from x2 +where x1.d1=x2.d1 and x1.d2=x2.d2) is false; +k d1 d2 +21 20 NULL +30 NULL 30 +40 40 40 +select * +from x1 +where 1 in (select 1 +from x2 +where x1.d1=x2.d1 and x1.d2=x2.d2) is unknown; +k d1 d2 +select * +from x1 +where exists (select * +from x2 +where x1.d1=x2.d1 and x1.d2=x2.d2); +k d1 d2 +10 10 10 +20 20 20 +drop table x1; +drop table x2; +CREATE TABLE t1 ( +a int(11) NOT NULL, +b int(11) NOT NULL, +c datetime default NULL, +PRIMARY KEY (a), +KEY idx_bc (b,c) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES +(406989,67,'2006-02-23 17:08:46'), (150078,67,'2005-10-26 11:17:45'), +(406993,67,'2006-02-27 11:20:57'), (245655,67,'2005-12-08 15:59:08'), +(406994,67,'2006-02-27 11:26:46'), (256,67,NULL), +(398341,67,'2006-02-20 04:48:44'), (254,67,NULL),(1120,67,NULL), +(406988,67,'2006-02-23 17:07:22'), (255,67,NULL), +(398340,67,'2006-02-20 04:38:53'),(406631,67,'2006-02-23 10:49:42'), +(245653,67,'2005-12-08 15:59:07'),(406992,67,'2006-02-24 16:47:18'), +(245654,67,'2005-12-08 15:59:08'),(406995,67,'2006-02-28 11:55:00'), +(127261,67,'2005-10-13 12:17:58'),(406991,67,'2006-02-24 16:42:32'), +(245652,67,'2005-12-08 15:58:27'),(398545,67,'2006-02-20 04:53:13'), +(154504,67,'2005-10-28 11:53:01'),(9199,67,NULL),(1,67,'2006-02-23 15:01:35'), +(223456,67,NULL),(4101,67,NULL),(1133,67,NULL), +(406990,67,'2006-02-23 18:01:45'),(148815,67,'2005-10-25 15:34:17'), +(148812,67,'2005-10-25 15:30:01'),(245651,67,'2005-12-08 15:58:27'), +(154503,67,'2005-10-28 11:52:38'); +create table t11 select * from t1 where b = 67 AND (c IS NULL OR c > NOW()) order by 3 asc; +create table t12 select * from t1 where b = 67 AND (c IS NULL OR c > NOW()) order by 3 desc; +create table t21 select * from t1 where b = 67 AND (c IS NULL OR c > '2005-12-08') order by 3 asc; +create table t22 select * from t1 where b = 67 AND (c IS NULL OR c > '2005-12-08') order by 3 desc; +update t22 set c = '2005-12-08 15:58:27' where a = 255; +explain select t21.* from t21,t22 where t21.a = t22.a and +t22.a in (select t12.a from t11, t12 where t11.a in(255,256) and t11.a = t12.a and t11.c is null) and t22.c is null order by t21.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using temporary; Using filesort +1 SIMPLE t22 NULL ALL NULL NULL NULL NULL 26 3.85 Using where; Using join buffer (hash join) +1 SIMPLE t21 NULL ALL NULL NULL NULL NULL 26 10.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t11 NULL ALL NULL NULL NULL NULL 8 12.50 Using where +2 MATERIALIZED t12 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t21`.`a` AS `a`,`test`.`t21`.`b` AS `b`,`test`.`t21`.`c` AS `c` from `test`.`t21` join `test`.`t22` semi join (`test`.`t11` join `test`.`t12`) where ((`test`.`t22`.`a` = ``.`a`) and (`test`.`t21`.`a` = ``.`a`) and (`test`.`t12`.`a` = `test`.`t11`.`a`) and (`test`.`t22`.`c` is null) and (`test`.`t11`.`a` in (255,256)) and (`test`.`t11`.`c` is null)) order by `test`.`t21`.`a` +explain format=json select * from t1 where a in (select a from t11); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "6.71" + }, + "nested_loop": [ + { + "table": { + "table_name": "", + "access_type": "ALL", + "materialized_from_subquery": { + "using_temporary_table": true, + "query_block": { + "table": { + "table_name": "t11", + "access_type": "ALL", + "rows_examined_per_scan": 8, + "rows_produced_per_join": 8, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "0.80", + "prefix_cost": "1.31", + "data_read_per_join": "128" + }, + "used_columns": [ + "a" + ] + } + } + } + } + }, + { + "table": { + "table_name": "t1", + "access_type": "eq_ref", + "possible_keys": [ + "PRIMARY" + ], + "key": "PRIMARY", + "used_key_parts": [ + "a" + ], + "key_length": "4", + "ref": [ + ".a" + ], + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.10", + "prefix_cost": "6.71", + "data_read_per_join": "16" + }, + "used_columns": [ + "a", + "b", + "c" + ] + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` semi join (`test`.`t11`) where (`test`.`t1`.`a` = ``.`a`) +select t21.* from t21,t22 where t21.a = t22.a and +t22.a in (select t12.a from t11, t12 where t11.a in(255,256) and t11.a = t12.a and t11.c is null) and t22.c is null order by t21.a; +a b c +256 67 NULL +drop table t1, t11, t12, t21, t22; +create table t1(a int); +insert into t1 values (0),(1); +explain +select (select max(y.a) from t1 y where a in (select a from t1 z) and a < x.a) as subq from t1 x; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY x NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DEPENDENT SUBQUERY y NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 DEPENDENT SUBQUERY z NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(y); Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.x.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select (/* select#2 */ select max(`test`.`y`.`a`) from `test`.`t1` `y` semi join (`test`.`t1` `z`) where ((`test`.`z`.`a` = `test`.`y`.`a`) and (`test`.`y`.`a` < `test`.`x`.`a`))) AS `subq` from `test`.`t1` `x` +select (select max(y.a) from t1 y where a in (select a from t1 z) and a < x.a) as subq from t1 x; +subq +NULL +0 +drop table t1; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 as select * from t0; +insert into t1 select a+10 from t0; +insert into t0 values(2); +explain select * from t1 where 2 in (select a from t0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 11 10.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 20 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t0`) where (`test`.`t0`.`a` = 2) +select * from t1 where 2 in (select a from t0); +a +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +explain select * from (select a from t0) x where a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 11 100.00 NULL +1 SIMPLE NULL eq_ref 5 func 1 100.00 Using where +3 MATERIALIZED t1 NULL ALL NULL NULL NULL NULL 20 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a` from `test`.`t0` semi join (`test`.`t1`) where (``.`a` = `test`.`t0`.`a`) +explain format=json select * from (select a from t0) x where a in (select a from t1); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "8.21" + }, + "nested_loop": [ + { + "table": { + "table_name": "t0", + "access_type": "ALL", + "rows_examined_per_scan": 11, + "rows_produced_per_join": 11, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "1.10", + "prefix_cost": "1.60", + "data_read_per_join": "88" + }, + "used_columns": [ + "a" + ] + } + }, + { + "table": { + "table_name": "", + "access_type": "eq_ref", + "key": "", + "key_length": "5", + "ref": [ + "func" + ], + "rows_examined_per_scan": 1, + "attached_condition": "(``.`a` = `test`.`t0`.`a`)", + "materialized_from_subquery": { + "using_temporary_table": true, + "query_block": { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 20, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "2.00", + "prefix_cost": "2.51", + "data_read_per_join": "160" + }, + "used_columns": [ + "a" + ] + } + } + } + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a` from `test`.`t0` semi join (`test`.`t1`) where (``.`a` = `test`.`t0`.`a`) +drop table t0, t1; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (kp1 int, kp2 int, c int, filler char(100), key(kp1, kp2)); +insert into t1 select A.a+10*(B.a+10*C.a), 0, 0, 'filler' from t0 A, t0 B, t0 C; +insert into t1 select * from t1 where kp1 < 20; +create table t3 (a int); +insert into t3 select A.a + 10*B.a from t0 A, t0 B; +explain select * from t3 where a in (select kp1 from t1 where kp1<20); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 100 100.00 Using where +1 SIMPLE NULL eq_ref 5 test.t3.a 1 100.00 NULL +2 MATERIALIZED t1 NULL range kp1 kp1 5 NULL 48 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a` from `test`.`t3` semi join (`test`.`t1`) where ((``.`kp1` = `test`.`t3`.`a`) and (`test`.`t1`.`kp1` < 20)) +select * from t3 where a in (select kp1 from t1 where kp1<20); +a +0 +1 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +2 +3 +4 +5 +6 +7 +8 +9 +explain select * from t3 where a in (select kp1 from t1 where kp1<20) and a<20; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 100 33.33 Using where +1 SIMPLE t1 NULL ref kp1 kp1 5 test.t3.a 1 100.00 Using index; FirstMatch(t3) +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a` from `test`.`t3` semi join (`test`.`t1`) where ((`test`.`t1`.`kp1` = `test`.`t3`.`a`) and (`test`.`t3`.`a` < 20) and (`test`.`t3`.`a` < 20)) +select * from t3 where a in (select kp1 from t1 where kp1<20) and a<20; +a +0 +1 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +2 +3 +4 +5 +6 +7 +8 +9 +create table t4 (pk int primary key); +insert into t4 select a from t3; +explain select * from t3 where a in +(select t1.kp1 from t1,t4 where kp1<20 and t4.pk=t1.c); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 100 100.00 Using where +1 SIMPLE NULL eq_ref 5 test.t3.a 1 100.00 NULL +2 MATERIALIZED t1 NULL range kp1 kp1 5 NULL 48 100.00 Using index condition; Using where; Using MRR +2 MATERIALIZED t4 NULL eq_ref PRIMARY PRIMARY 4 test.t1.c 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a` from `test`.`t3` semi join (`test`.`t1` join `test`.`t4`) where ((``.`kp1` = `test`.`t3`.`a`) and (`test`.`t4`.`pk` = `test`.`t1`.`c`) and (`test`.`t1`.`kp1` < 20)) +explain format=tree select * from t3 where a in +(select t1.kp1 from t1,t4 where kp1<20 and t4.pk=t1.c); +EXPLAIN +-> Nested loop inner join (cost=500.54 rows=4800) + -> Filter: (t3.a is not null) (cost=10.54 rows=100) + -> Table scan on t3 (cost=10.54 rows=100) + -> Single-row index lookup on using (kp1=t3.a) + -> Materialize with deduplication (cost=42.80..42.80 rows=48) + -> Filter: (t1.kp1 is not null) (cost=38.00 rows=48) + -> Nested loop inner join (cost=38.00 rows=48) + -> Filter: (t1.c is not null) (cost=21.20 rows=48) + -> Index range scan on t1 using kp1, with index condition: (t1.kp1 < 20) (cost=21.20 rows=48) + -> Single-row index lookup on t4 using PRIMARY (pk=t1.c) (cost=0.25 rows=1) + +select * from t3 where a in +(select t1.kp1 from t1,t4 where kp1<20 and t4.pk=t1.c); +a +0 +1 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +2 +3 +4 +5 +6 +7 +8 +9 +drop table t1, t3, t4; +create table t1 (a int); +insert into t1 values (0),(0),(0),(1),(1),(1),(2),(2),(2),(3),(3),(3); +set session internal_tmp_mem_storage_engine='memory'; +set @save_max_heap_table_size=@@max_heap_table_size; +set @@max_heap_table_size= 16384; +# Attempt to make one test that overflows the heap table when a +# non-duplicate row is inserted and one test that overflows the +# heap table when a duplicate record is inserted. Debugging showed +# that these situations occurred with max_heap_table_size=16384 +# and optimizer_join_cache_level equals 1 and 0, respectively. +# Finally execute a test that does not overflow the heap table. +explain +select count(*) from t0 a, t0 b, t0 c +where c.a in (select a from t1 d); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE a NULL ALL NULL NULL NULL NULL 10 100.00 NULL +1 SIMPLE b NULL ALL NULL NULL NULL NULL 10 100.00 Using join buffer (hash join) +1 SIMPLE c NULL ALL NULL NULL NULL NULL 10 100.00 Using where; Using join buffer (hash join) +1 SIMPLE NULL eq_ref 5 test.c.a 1 100.00 NULL +2 MATERIALIZED d NULL ALL NULL NULL NULL NULL 12 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select count(0) AS `count(*)` from `test`.`t0` `a` join `test`.`t0` `b` join `test`.`t0` `c` semi join (`test`.`t1` `d`) where (``.`a` = `test`.`c`.`a`) +flush status; +select count(*) from t0 a, t0 b, t0 c +where c.a in (select a from t1 d); +count(*) +400 +show status like 'Created_tmp_disk_tables'; +Variable_name Value +Created_tmp_disk_tables 0 +set @@max_heap_table_size= @save_max_heap_table_size; +set session internal_tmp_mem_storage_engine=default; +flush status; +select count(*) from t0 a, t0 b, t0 c +where c.a in (select a from t1 d); +count(*) +400 +show status like 'Created_tmp_disk_tables'; +Variable_name Value +Created_tmp_disk_tables 0 +drop table t0, t1; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t2(a int); +insert into t2 values (1),(2); +create table t3 ( a int , filler char(100), key(a)); +insert into t3 select A.a + 10*B.a, 'filler' from t0 A, t0 B; +explain select * from t3 where a in (select a from t2) and (a > 5 or a < 10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using where +1 SIMPLE t3 NULL ref a a 5 .a 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a`,`test`.`t3`.`filler` AS `filler` from `test`.`t3` semi join (`test`.`t2`) where ((`test`.`t3`.`a` = ``.`a`) and ((``.`a` > 5) or (``.`a` < 10))) +select * from t3 where a in (select a from t2); +a filler +1 filler +2 filler +drop table t0, t2, t3; +create table t1 (a date); +insert into t1 values ('2008-01-01'),('2008-01-01'),('2008-02-01'),('2008-02-01'); +create table t2 (a int); +insert into t2 values (1),(2); +create table t3 (a char(10)); +insert into t3 select * from t1; +insert into t3 values (1),(2); +explain select * from t2 where a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; FirstMatch(t2); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1`) where (cast(`test`.`t2`.`a` as double) = cast(`test`.`t1`.`a` as double)) +explain select * from t2 where a in (select a from t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t2); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t2`) where (`test`.`t2`.`a` = `test`.`t2`.`a`) +explain select * from t2 where a in (select a from t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; FirstMatch(t2); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t3`) where (cast(`test`.`t2`.`a` as double) = cast(`test`.`t3`.`a` as double)) +explain select * from t1 where a in (select a from t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; FirstMatch(t1); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t3`) where (`test`.`t1`.`a` = cast(`test`.`t3`.`a` as date)) +drop table t1, t2, t3; +create table t1 (a decimal); +insert into t1 values (1),(2); +explain select * from t1 where a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t1`) where (`test`.`t1`.`a` = `test`.`t1`.`a`) +drop table t1; +create table t1 (a int); +insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t2 as select * from t1; +create table t3 (a int, b int, filler char(100), key(a)) charset utf8mb4; +insert into t3 select A.a + 10*B.a, A.a + 10*B.a, 'filler' from t1 A, t1 B, t1 C; +explain select * from t1, t3 where t3.a in (select a from t2) and (t3.a < 10 or t3.a >30) and t1.a =3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 10.00 Using where +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ref a a 5 .a 10 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 10 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t3`.`filler` AS `filler` from `test`.`t1` join `test`.`t3` semi join (`test`.`t2`) where ((`test`.`t3`.`a` = ``.`a`) and (`test`.`t1`.`a` = 3) and ((``.`a` < 10) or (``.`a` > 30))) +explain format=json select * from t1, t3 where t3.a in (select a from t2) and (t3.a < 10 or t3.a >30) and t1.a =3; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "41.01" + }, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 10, + "rows_produced_per_join": 1, + "filtered": "10.00", + "cost_info": { + "read_cost": "1.40", + "eval_cost": "0.10", + "prefix_cost": "1.50", + "data_read_per_join": "8" + }, + "used_columns": [ + "a" + ], + "attached_condition": "(`test`.`t1`.`a` = 3)" + } + }, + { + "table": { + "table_name": "", + "access_type": "ALL", + "using_join_buffer": "hash join", + "attached_condition": "(((``.`a` < 10) or (``.`a` > 30)) and (``.`a` is not null))", + "materialized_from_subquery": { + "using_temporary_table": true, + "query_block": { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 10, + "rows_produced_per_join": 10, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "1.00", + "prefix_cost": "1.50", + "data_read_per_join": "80" + }, + "used_columns": [ + "a" + ] + } + } + } + } + }, + { + "table": { + "table_name": "t3", + "access_type": "ref", + "possible_keys": [ + "a" + ], + "key": "a", + "used_key_parts": [ + "a" + ], + "key_length": "5", + "ref": [ + ".a" + ], + "rows_examined_per_scan": 10, + "rows_produced_per_join": 10, + "filtered": "100.00", + "cost_info": { + "read_cost": "25.00", + "eval_cost": "1.00", + "prefix_cost": "41.01", + "data_read_per_join": "4K" + }, + "used_columns": [ + "a", + "b", + "filler" + ] + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t3`.`filler` AS `filler` from `test`.`t1` join `test`.`t3` semi join (`test`.`t2`) where ((`test`.`t3`.`a` = ``.`a`) and (`test`.`t1`.`a` = 3) and ((``.`a` < 10) or (``.`a` > 30))) +explain select straight_join * from t1 a, t1 b where a.a in (select a from t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY a NULL ALL NULL NULL NULL NULL 10 100.00 Using where +1 PRIMARY b NULL ALL NULL NULL NULL NULL 10 100.00 Using join buffer (hash join) +2 SUBQUERY t2 NULL ALL NULL NULL NULL NULL 10 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select straight_join `test`.`a`.`a` AS `a`,`test`.`b`.`a` AS `a` from `test`.`t1` `a` join `test`.`t1` `b` where (`test`.`a`.`a`,`test`.`a`.`a` in ( (/* select#2 */ select `test`.`t2`.`a` from `test`.`t2` where true ), (`test`.`a`.`a` in on where ((`test`.`a`.`a` = ``.`a`))))) +explain select * from t2 where a in (select straight_join a.a from t1 a, t1 b); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 10 100.00 Using where +2 SUBQUERY a NULL ALL NULL NULL NULL NULL 10 100.00 NULL +2 SUBQUERY b NULL ALL NULL NULL NULL NULL 10 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` where (`test`.`t2`.`a`,`test`.`t2`.`a` in ( (/* select#2 */ select straight_join `test`.`a`.`a` from `test`.`t1` `a` join `test`.`t1` `b` where true ), (`test`.`t2`.`a` in on where ((`test`.`t2`.`a` = ``.`a`))))) +explain select * from t2 where a in (select straight_join a.a from t1 a, t1 b); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 10 100.00 Using where +2 SUBQUERY a NULL ALL NULL NULL NULL NULL 10 100.00 NULL +2 SUBQUERY b NULL ALL NULL NULL NULL NULL 10 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` where (`test`.`t2`.`a`,`test`.`t2`.`a` in ( (/* select#2 */ select straight_join `test`.`a`.`a` from `test`.`t1` `a` join `test`.`t1` `b` where true ), (`test`.`t2`.`a` in on where ((`test`.`t2`.`a` = ``.`a`))))) +explain select straight_join * from t2 x, t2 y +where x.a in (select straight_join a.a from t1 a, t1 b); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY x NULL ALL NULL NULL NULL NULL 10 100.00 Using where +1 PRIMARY y NULL ALL NULL NULL NULL NULL 10 100.00 Using join buffer (hash join) +2 SUBQUERY a NULL ALL NULL NULL NULL NULL 10 100.00 NULL +2 SUBQUERY b NULL ALL NULL NULL NULL NULL 10 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select straight_join `test`.`x`.`a` AS `a`,`test`.`y`.`a` AS `a` from `test`.`t2` `x` join `test`.`t2` `y` where (`test`.`x`.`a`,`test`.`x`.`a` in ( (/* select#2 */ select straight_join `test`.`a`.`a` from `test`.`t1` `a` join `test`.`t1` `b` where true ), (`test`.`x`.`a` in on where ((`test`.`x`.`a` = ``.`a`))))) +create table t0 (a int, b int); +insert into t0 values(1,1); +explain select * from t0, t3 where t3.a in (select a from t2) and (t3.a < 10 or t3.a >30); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using where +1 SIMPLE t3 NULL ref a a 5 .a 10 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 10 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select '1' AS `a`,'1' AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t3`.`filler` AS `filler` from `test`.`t3` semi join (`test`.`t2`) where ((`test`.`t3`.`a` = ``.`a`) and ((``.`a` < 10) or (``.`a` > 30))) +create table t4 as select a as x, a as y from t1; +explain select * from t0, t3 where (t3.a, t3.b) in (select x,y from t4) and (t3.a < 10 or t3.a >30); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using where +1 SIMPLE t3 NULL ref a a 5 .x 10 10.00 Using where +2 MATERIALIZED t4 NULL ALL NULL NULL NULL NULL 10 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select '1' AS `a`,'1' AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t3`.`filler` AS `filler` from `test`.`t3` semi join (`test`.`t4`) where ((`test`.`t3`.`b` = ``.`y`) and (`test`.`t3`.`a` = ``.`x`) and ((``.`x` < 10) or (``.`x` > 30))) +drop table t0,t1,t2,t3,t4; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (a int, b int, filler char(100), key(a,b)); +insert into t1 select A.a, B.a, 'filler' from t0 A, t0 B; +create table t2 as select * from t1; +explain select * from t2 where a in (select b from t1 where a=3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 100 100.00 Using where +1 SIMPLE NULL eq_ref 5 test.t2.a 1 100.00 NULL +2 MATERIALIZED t1 NULL ref a a 5 const 8 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`filler` AS `filler` from `test`.`t2` semi join (`test`.`t1`) where ((``.`b` = `test`.`t2`.`a`) and (`test`.`t1`.`a` = 3)) +explain select * from t2 where (b,a) in (select a,b from t1 where a=3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 100 10.00 Using where +1 SIMPLE t1 NULL ref a a 10 const,test.t2.a 1 100.00 Using index; FirstMatch(t2) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`filler` AS `filler` from `test`.`t2` semi join (`test`.`t1`) where ((`test`.`t1`.`b` = `test`.`t2`.`a`) and (`test`.`t2`.`b` = 3) and (`test`.`t1`.`a` = 3)) +drop table t1,t2; +create table t1 (a int, b int); +insert into t1 select a,a from t0; +create table t2 (a int, b int); +insert into t2 select A.a + 10*B.a, A.a + 10*B.a from t0 A, t0 B; +explain select * from t1 where (a,b) in (select a,b from t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 100.00 Using where +1 SIMPLE NULL eq_ref 10 test.t1.a,test.t1.b 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 100 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t2`) where ((``.`b` = `test`.`t1`.`b`) and (``.`a` = `test`.`t1`.`a`)) +drop table t0, t1, t2; +# +# Bug#19695490: CRASH IN CREATE_REF_FOR_KEY ON SELECT + JOIN + UTF8 COLUMN +# + DATETIME INDEX. +# +CREATE TABLE t1 ( +field1 varchar(255) CHARACTER SET utf8, +field2 varchar(255) CHARACTER SET utf8 +); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES +('time','time'), +('lpjdzvkp','lpjdzvkp'), +('dzvkpai', 'dzvkpai'); +CREATE TABLE t2 ( col_varchar varchar(10)); +CREATE TABLE t3 ( +pk int(11) NOT NULL, +col_varchar_255_utf8_key varchar(255) CHARACTER SET utf8, +col_varchar_10_utf8_key varchar(10) CHARACTER SET utf8, +PRIMARY KEY (pk) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t3 VALUES (22,'come','h'), +(23,'time','aaa'), +(24,'lpjdzvkp','ababa'), +(25,'d','GGDD'); +SELECT * FROM t1 WHERE (field1, field2) IN ( +SELECT table1.col_varchar_255_utf8_key AS field1, +table1.col_varchar_255_utf8_key AS field2 +FROM t3 AS table1 LEFT JOIN t2 AS table2 +ON table1.col_varchar_10_utf8_key <= +table2.col_varchar +WHERE table1.pk >= 6); +field1 field2 +time time +lpjdzvkp lpjdzvkp +DROP TABLE t1,t2,t3; +create table t0 (a decimal(4,2)); +insert into t0 values (10.24), (22.11); +create table t1 as select * from t0; +insert into t1 select * from t0; +explain select * from t0 where a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; FirstMatch(t0); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a` from `test`.`t0` semi join (`test`.`t1`) where (`test`.`t1`.`a` = `test`.`t0`.`a`) +select * from t0 where a in (select a from t1); +a +10.24 +22.11 +drop table t0, t1; +create table t0(a date); +insert into t0 values ('2008-01-01'),('2008-02-02'); +create table t1 as select * from t0; +insert into t1 select * from t0; +explain select * from t0 where a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; FirstMatch(t0); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a` from `test`.`t0` semi join (`test`.`t1`) where (`test`.`t1`.`a` = `test`.`t0`.`a`) +select * from t0 where a in (select a from t1); +a +2008-01-01 +2008-02-02 +drop table t0, t1; +create table t0(a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 as select a as a, a as b, a as c from t0 where a < 3; +create table t2 as select a as a, a as b from t0 where a < 3; +insert into t2 select * from t2; +explain select * from t1 where (a,b,c) in (select x.a, y.a, z.a from t2 x, t2 y, t2 z where x.b=33); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE x NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +1 SIMPLE y NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Using join buffer (hash join) +1 SIMPLE z NULL ALL NULL NULL NULL NULL 6 16.67 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` semi join (`test`.`t2` `x` join `test`.`t2` `y` join `test`.`t2` `z`) where ((`test`.`z`.`a` = `test`.`t1`.`c`) and (`test`.`y`.`a` = `test`.`t1`.`b`) and (`test`.`t1`.`a` = `test`.`x`.`a`) and (`test`.`x`.`b` = 33)) +drop table t0,t1,t2; +set @save_join_buffer_size = @@join_buffer_size; +set join_buffer_size= 8192; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (a int, filler1 binary(200), filler2 binary(200)); +insert into t1 select a, 'filler123456', 'filler123456' from t0; +insert into t1 select a+10, 'filler123456', 'filler123456' from t0; +create table t2 as select * from t1; +insert into t1 select a+20, 'filler123456', 'filler123456' from t0; +insert into t1 values (2, 'duplicate ok', 'duplicate ok'); +insert into t1 values (18, 'duplicate ok', 'duplicate ok'); +insert into t2 values (3, 'duplicate ok', 'duplicate ok'); +insert into t2 values (19, 'duplicate ok', 'duplicate ok'); +explain select +a, mid(filler1, 1,10), length(filler1)=length(filler2) as z +from t1 ot where a in (select a from t2 it); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 32 10.00 Using where; Using join buffer (hash join) +2 MATERIALIZED it NULL ALL NULL NULL NULL NULL 22 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot`.`a` AS `a`,substr(`test`.`ot`.`filler1`,1,10) AS `mid(filler1, 1,10)`,(length(`test`.`ot`.`filler1`) = length(`test`.`ot`.`filler2`)) AS `z` from `test`.`t1` `ot` semi join (`test`.`t2` `it`) where (`test`.`ot`.`a` = ``.`a`) +select +a, mid(filler1, 1,10), length(filler1)=length(filler2) as z +from t1 ot where a in (select a from t2 it); +a mid(filler1, 1,10) z +0 filler1234 1 +1 filler1234 1 +10 filler1234 1 +11 filler1234 1 +12 filler1234 1 +13 filler1234 1 +14 filler1234 1 +15 filler1234 1 +16 filler1234 1 +17 filler1234 1 +18 duplicate 1 +18 filler1234 1 +19 filler1234 1 +2 duplicate 1 +2 filler1234 1 +3 filler1234 1 +4 filler1234 1 +5 filler1234 1 +6 filler1234 1 +7 filler1234 1 +8 filler1234 1 +9 filler1234 1 +explain select +a, mid(filler1, 1,10), length(filler1)=length(filler2) +from t2 ot where a in (select a from t1 it); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 22 100.00 Using where +1 SIMPLE NULL eq_ref 5 test.ot.a 1 100.00 NULL +2 MATERIALIZED it NULL ALL NULL NULL NULL NULL 32 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot`.`a` AS `a`,substr(`test`.`ot`.`filler1`,1,10) AS `mid(filler1, 1,10)`,(length(`test`.`ot`.`filler1`) = length(`test`.`ot`.`filler2`)) AS `length(filler1)=length(filler2)` from `test`.`t2` `ot` semi join (`test`.`t1` `it`) where (``.`a` = `test`.`ot`.`a`) +select +a, mid(filler1, 1,10), length(filler1)=length(filler2) +from t2 ot where a in (select a from t1 it); +a mid(filler1, 1,10) length(filler1)=length(filler2) +0 filler1234 1 +1 filler1234 1 +10 filler1234 1 +11 filler1234 1 +12 filler1234 1 +13 filler1234 1 +14 filler1234 1 +15 filler1234 1 +16 filler1234 1 +17 filler1234 1 +18 filler1234 1 +19 duplicate 1 +19 filler1234 1 +2 filler1234 1 +3 duplicate 1 +3 filler1234 1 +4 filler1234 1 +5 filler1234 1 +6 filler1234 1 +7 filler1234 1 +8 filler1234 1 +9 filler1234 1 +insert into t1 select a+20, 'filler123456', 'filler123456' from t0; +insert into t1 select a+20, 'filler123456', 'filler123456' from t0; +explain select +a, mid(filler1, 1,10), length(filler1)=length(filler2) as z +from t1 ot where a in (select a from t2 it); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 52 10.00 Using where; Using join buffer (hash join) +2 MATERIALIZED it NULL ALL NULL NULL NULL NULL 22 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot`.`a` AS `a`,substr(`test`.`ot`.`filler1`,1,10) AS `mid(filler1, 1,10)`,(length(`test`.`ot`.`filler1`) = length(`test`.`ot`.`filler2`)) AS `z` from `test`.`t1` `ot` semi join (`test`.`t2` `it`) where (`test`.`ot`.`a` = ``.`a`) +select +a, mid(filler1, 1,10), length(filler1)=length(filler2) as z +from t1 ot where a in (select a from t2 it); +a mid(filler1, 1,10) z +0 filler1234 1 +1 filler1234 1 +10 filler1234 1 +11 filler1234 1 +12 filler1234 1 +13 filler1234 1 +14 filler1234 1 +15 filler1234 1 +16 filler1234 1 +17 filler1234 1 +18 duplicate 1 +18 filler1234 1 +19 filler1234 1 +2 duplicate 1 +2 filler1234 1 +3 filler1234 1 +4 filler1234 1 +5 filler1234 1 +6 filler1234 1 +7 filler1234 1 +8 filler1234 1 +9 filler1234 1 +explain select +a, mid(filler1, 1,10), length(filler1)=length(filler2) +from t2 ot where a in (select a from t1 it); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 22 100.00 Using where +1 SIMPLE NULL eq_ref 5 test.ot.a 1 100.00 NULL +2 MATERIALIZED it NULL ALL NULL NULL NULL NULL 52 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot`.`a` AS `a`,substr(`test`.`ot`.`filler1`,1,10) AS `mid(filler1, 1,10)`,(length(`test`.`ot`.`filler1`) = length(`test`.`ot`.`filler2`)) AS `length(filler1)=length(filler2)` from `test`.`t2` `ot` semi join (`test`.`t1` `it`) where (``.`a` = `test`.`ot`.`a`) +select +a, mid(filler1, 1,10), length(filler1)=length(filler2) +from t2 ot where a in (select a from t1 it); +a mid(filler1, 1,10) length(filler1)=length(filler2) +0 filler1234 1 +1 filler1234 1 +10 filler1234 1 +11 filler1234 1 +12 filler1234 1 +13 filler1234 1 +14 filler1234 1 +15 filler1234 1 +16 filler1234 1 +17 filler1234 1 +18 filler1234 1 +19 duplicate 1 +19 filler1234 1 +2 filler1234 1 +3 duplicate 1 +3 filler1234 1 +4 filler1234 1 +5 filler1234 1 +6 filler1234 1 +7 filler1234 1 +8 filler1234 1 +9 filler1234 1 +set @@join_buffer_size = @save_join_buffer_size; +drop table t1, t2; +create table t1 (a int, b int, key(a)); +create table t2 (a int, b int, key(a)); +create table t3 (a int, b int, key(a)); +insert into t1 select a,a from t0; +insert into t2 select a,a from t0; +insert into t3 select a,a from t0; +t2 and t3 must be use 'ref', not 'ALL': +explain select * +from t0 where a in +(select t2.a+t3.a from t1 left join (t2 join t3) on t2.a=t1.a and t3.a=t1.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 10 100.00 Using where +1 SIMPLE NULL eq_ref 9 test.t0.a 1 100.00 Using where +2 MATERIALIZED t1 NULL index a a 5 NULL 10 100.00 Using index +2 MATERIALIZED t2 NULL ref a a 5 test.t1.a 1 100.00 Using index +2 MATERIALIZED t3 NULL ref a a 5 test.t1.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a` from `test`.`t0` semi join (`test`.`t1` join `test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`a` = `test`.`t1`.`a`) and (`test`.`t3`.`a` = `test`.`t1`.`a`) and (`test`.`t0`.`a` = ``.`t2.a+t3.a`)) +drop table t0, t1,t2,t3; + +Test that neither MaterializeLookup strategy for semijoin, +nor subquery materialization is used when BLOBs are involved +(except when arguments of some functions). + +set @prefix_len = 6; +set @blob_len = 16; +set @suffix_len = @blob_len - @prefix_len; +create table t1_16 (a1 blob(16), a2 blob(16)); +create table t2_16 (b1 blob(16), b2 blob(16)); +create table t3_16 (c1 blob(16), c2 blob(16)); +insert into t1_16 values +(concat('1 - 00', repeat('x', @suffix_len)), concat('2 - 00', repeat('x', @suffix_len))); +insert into t1_16 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t1_16 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_16 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t2_16 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_16 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_16 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t3_16 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t3_16 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_16 values +(concat('1 - 04', repeat('x', @suffix_len)), concat('2 - 04', repeat('x', @suffix_len))); +explain select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select b1 from t2_16 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1_16 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t2_16 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(t1_16); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_16`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_16`.`a2`,7) AS `left(a2,7)` from `test`.`t1_16` semi join (`test`.`t2_16`) where ((`test`.`t2_16`.`b1` = `test`.`t1_16`.`a1`) and (`test`.`t1_16`.`a1` > '0')) +select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select b1 from t2_16 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_16 +where (a1,a2) in (select b1, b2 from t2_16 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1_16 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t2_16 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(t1_16); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_16`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_16`.`a2`,7) AS `left(a2,7)` from `test`.`t1_16` semi join (`test`.`t2_16`) where ((`test`.`t2_16`.`b2` = `test`.`t1_16`.`a2`) and (`test`.`t2_16`.`b1` = `test`.`t1_16`.`a1`) and (`test`.`t1_16`.`a1` > '0')) +select left(a1,7), left(a2,7) +from t1_16 +where (a1,a2) in (select b1, b2 from t2_16 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select substring(b1,1,16) from t2_16 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1_16 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE t2_16 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(t1_16); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_16`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_16`.`a2`,7) AS `left(a2,7)` from `test`.`t1_16` semi join (`test`.`t2_16`) where ((`test`.`t2_16`.`b1` > '0') and (`test`.`t1_16`.`a1` = substr(`test`.`t2_16`.`b1`,1,16))) +select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select substring(b1,1,16) from t2_16 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select group_concat(b1) from t2_16 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_16 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t2_16 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_16`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_16`.`a2`,7) AS `left(a2,7)` from `test`.`t1_16` where (`test`.`t1_16`.`a1`,(/* select#2 */ select group_concat(`test`.`t2_16`.`b1` separator ',') from `test`.`t2_16` group by `test`.`t2_16`.`b2` having ((`test`.`t1_16`.`a1`) = (group_concat(`test`.`t2_16`.`b1` separator ','))))) +select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select group_concat(b1) from t2_16 group by b2); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +set @@group_concat_max_len = 256; +explain select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select group_concat(b1) from t2_16 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_16 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 SUBQUERY t2_16 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_16`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_16`.`a2`,7) AS `left(a2,7)` from `test`.`t1_16` where (`test`.`t1_16`.`a1`,`test`.`t1_16`.`a1` in ( (/* select#2 */ select group_concat(`test`.`t2_16`.`b1` separator ',') from `test`.`t2_16` group by `test`.`t2_16`.`b2` having true ), (`test`.`t1_16`.`a1` in on where ((`test`.`t1_16`.`a1` = ``.`group_concat(b1)`))))) +select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select group_concat(b1) from t2_16 group by b2); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +create table t1 (a1 char(8), a2 char(8)) charset latin1; +create table t2 (b1 char(8), b2 char(8)) charset latin1; +create table t3 (c1 char(8), c2 char(8)) charset latin1; +insert into t1 values ('1 - 00', '2 - 00'); +insert into t1 values ('1 - 01', '2 - 01'); +insert into t1 values ('1 - 02', '2 - 02'); +insert into t2 values ('1 - 01', '2 - 01'); +insert into t2 values ('1 - 01', '2 - 01'); +insert into t2 values ('1 - 02', '2 - 02'); +insert into t2 values ('1 - 02', '2 - 02'); +insert into t2 values ('1 - 03', '2 - 03'); +insert into t3 values ('1 - 01', '2 - 01'); +insert into t3 values ('1 - 02', '2 - 02'); +insert into t3 values ('1 - 03', '2 - 03'); +insert into t3 values ('1 - 04', '2 - 04'); +insert into t3 values ('1 - 05', '2 - 05'); +insert into t3 values ('1 - 06', '2 - 06'); +insert into t3 values ('1 - 07', '2 - 07'); +insert into t3 values ('1 - 08', '2 - 08'); +explain +select * from t1 +where concat(a1,'x') IN +(select left(a1,8) from t1_16 +where (a1, a2) IN +(select t2_16.b1, t2_16.b2 from t2_16, t2 +where t2.b2 = substring(t2_16.b2,1,6) and +t2.b1 IN (select c1 from t3 where c2 > '0'))); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Start temporary +1 SIMPLE t1_16 NULL ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t2_16 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 5 20.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` semi join (`test`.`t1_16` join `test`.`t2_16` join `test`.`t2` join `test`.`t3`) where ((`test`.`t2_16`.`b2` = `test`.`t1_16`.`a2`) and (`test`.`t2_16`.`b1` = `test`.`t1_16`.`a1`) and (`test`.`t3`.`c1` = `test`.`t2`.`b1`) and (`test`.`t2`.`b2` = substr(`test`.`t2_16`.`b2`,1,6)) and (`test`.`t3`.`c2` > '0') and (concat(`test`.`t1`.`a1`,'x') = left(`test`.`t1_16`.`a1`,8))) +drop table t1_16, t2_16, t3_16, t1, t2, t3; +set @blob_len = 512; +set @suffix_len = @blob_len - @prefix_len; +create table t1_512 (a1 blob(512), a2 blob(512)); +create table t2_512 (b1 blob(512), b2 blob(512)); +create table t3_512 (c1 blob(512), c2 blob(512)); +insert into t1_512 values +(concat('1 - 00', repeat('x', @suffix_len)), concat('2 - 00', repeat('x', @suffix_len))); +insert into t1_512 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t1_512 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_512 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t2_512 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_512 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_512 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t3_512 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t3_512 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_512 values +(concat('1 - 04', repeat('x', @suffix_len)), concat('2 - 04', repeat('x', @suffix_len))); +explain select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select b1 from t2_512 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1_512 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t2_512 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(t1_512); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_512`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_512`.`a2`,7) AS `left(a2,7)` from `test`.`t1_512` semi join (`test`.`t2_512`) where ((`test`.`t2_512`.`b1` = `test`.`t1_512`.`a1`) and (`test`.`t1_512`.`a1` > '0')) +select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select b1 from t2_512 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_512 +where (a1,a2) in (select b1, b2 from t2_512 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1_512 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t2_512 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(t1_512); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_512`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_512`.`a2`,7) AS `left(a2,7)` from `test`.`t1_512` semi join (`test`.`t2_512`) where ((`test`.`t2_512`.`b2` = `test`.`t1_512`.`a2`) and (`test`.`t2_512`.`b1` = `test`.`t1_512`.`a1`) and (`test`.`t1_512`.`a1` > '0')) +select left(a1,7), left(a2,7) +from t1_512 +where (a1,a2) in (select b1, b2 from t2_512 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select substring(b1,1,512) from t2_512 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1_512 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE t2_512 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(t1_512); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_512`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_512`.`a2`,7) AS `left(a2,7)` from `test`.`t1_512` semi join (`test`.`t2_512`) where ((`test`.`t2_512`.`b1` > '0') and (`test`.`t1_512`.`a1` = substr(`test`.`t2_512`.`b1`,1,512))) +select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select substring(b1,1,512) from t2_512 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select group_concat(b1) from t2_512 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_512 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 SUBQUERY t2_512 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_512`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_512`.`a2`,7) AS `left(a2,7)` from `test`.`t1_512` where (`test`.`t1_512`.`a1`,`test`.`t1_512`.`a1` in ( (/* select#2 */ select group_concat(`test`.`t2_512`.`b1` separator ',') from `test`.`t2_512` group by `test`.`t2_512`.`b2` having true ), (`test`.`t1_512`.`a1` in on where ((`test`.`t1_512`.`a1` = ``.`group_concat(b1)`))))) +select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select group_concat(b1) from t2_512 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +set @@group_concat_max_len = 256; +explain select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select group_concat(b1) from t2_512 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_512 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 SUBQUERY t2_512 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_512`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_512`.`a2`,7) AS `left(a2,7)` from `test`.`t1_512` where (`test`.`t1_512`.`a1`,`test`.`t1_512`.`a1` in ( (/* select#2 */ select group_concat(`test`.`t2_512`.`b1` separator ',') from `test`.`t2_512` group by `test`.`t2_512`.`b2` having true ), (`test`.`t1_512`.`a1` in on where ((`test`.`t1_512`.`a1` = ``.`group_concat(b1)`))))) +select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select group_concat(b1) from t2_512 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +drop table t1_512, t2_512, t3_512; +set @blob_len = 513; +set @suffix_len = @blob_len - @prefix_len; +create table t1_513 (a1 blob(513), a2 blob(513)); +create table t2_513 (b1 blob(513), b2 blob(513)); +create table t3_513 (c1 blob(513), c2 blob(513)); +insert into t1_513 values +(concat('1 - 00', repeat('x', @suffix_len)), concat('2 - 00', repeat('x', @suffix_len))); +insert into t1_513 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t1_513 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_513 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t2_513 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_513 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_513 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t3_513 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t3_513 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_513 values +(concat('1 - 04', repeat('x', @suffix_len)), concat('2 - 04', repeat('x', @suffix_len))); +explain select left(a1,7), left(a2,7) +from t1_513 +where a1 in (select b1 from t2_513 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1_513 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t2_513 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(t1_513); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_513`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_513`.`a2`,7) AS `left(a2,7)` from `test`.`t1_513` semi join (`test`.`t2_513`) where ((`test`.`t2_513`.`b1` = `test`.`t1_513`.`a1`) and (`test`.`t1_513`.`a1` > '0')) +select left(a1,7), left(a2,7) +from t1_513 +where a1 in (select b1 from t2_513 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_513 +where (a1,a2) in (select b1, b2 from t2_513 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1_513 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t2_513 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(t1_513); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_513`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_513`.`a2`,7) AS `left(a2,7)` from `test`.`t1_513` semi join (`test`.`t2_513`) where ((`test`.`t2_513`.`b2` = `test`.`t1_513`.`a2`) and (`test`.`t2_513`.`b1` = `test`.`t1_513`.`a1`) and (`test`.`t1_513`.`a1` > '0')) +select left(a1,7), left(a2,7) +from t1_513 +where (a1,a2) in (select b1, b2 from t2_513 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_513 +where a1 in (select substring(b1,1,513) from t2_513 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1_513 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE t2_513 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(t1_513); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_513`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_513`.`a2`,7) AS `left(a2,7)` from `test`.`t1_513` semi join (`test`.`t2_513`) where ((`test`.`t2_513`.`b1` > '0') and (`test`.`t1_513`.`a1` = substr(`test`.`t2_513`.`b1`,1,513))) +select left(a1,7), left(a2,7) +from t1_513 +where a1 in (select substring(b1,1,513) from t2_513 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_513 +where a1 in (select group_concat(b1) from t2_513 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_513 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 SUBQUERY t2_513 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_513`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_513`.`a2`,7) AS `left(a2,7)` from `test`.`t1_513` where (`test`.`t1_513`.`a1`,`test`.`t1_513`.`a1` in ( (/* select#2 */ select group_concat(`test`.`t2_513`.`b1` separator ',') from `test`.`t2_513` group by `test`.`t2_513`.`b2` having true ), (`test`.`t1_513`.`a1` in on where ((`test`.`t1_513`.`a1` = ``.`group_concat(b1)`))))) +select left(a1,7), left(a2,7) +from t1_513 +where a1 in (select group_concat(b1) from t2_513 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +drop table t1_513, t2_513, t3_513; +set @blob_len = 1024; +set @suffix_len = @blob_len - @prefix_len; +create table t1_1024 (a1 blob(1024), a2 blob(1024)); +create table t2_1024 (b1 blob(1024), b2 blob(1024)); +create table t3_1024 (c1 blob(1024), c2 blob(1024)); +insert into t1_1024 values +(concat('1 - 00', repeat('x', @suffix_len)), concat('2 - 00', repeat('x', @suffix_len))); +insert into t1_1024 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t1_1024 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_1024 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t2_1024 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_1024 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_1024 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t3_1024 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t3_1024 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_1024 values +(concat('1 - 04', repeat('x', @suffix_len)), concat('2 - 04', repeat('x', @suffix_len))); +explain select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select b1 from t2_1024 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1_1024 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t2_1024 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(t1_1024); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1024`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1024`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1024` semi join (`test`.`t2_1024`) where ((`test`.`t2_1024`.`b1` = `test`.`t1_1024`.`a1`) and (`test`.`t1_1024`.`a1` > '0')) +select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select b1 from t2_1024 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_1024 +where (a1,a2) in (select b1, b2 from t2_1024 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1_1024 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t2_1024 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(t1_1024); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1024`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1024`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1024` semi join (`test`.`t2_1024`) where ((`test`.`t2_1024`.`b2` = `test`.`t1_1024`.`a2`) and (`test`.`t2_1024`.`b1` = `test`.`t1_1024`.`a1`) and (`test`.`t1_1024`.`a1` > '0')) +select left(a1,7), left(a2,7) +from t1_1024 +where (a1,a2) in (select b1, b2 from t2_1024 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select substring(b1,1,1024) from t2_1024 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1_1024 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE t2_1024 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(t1_1024); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1024`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1024`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1024` semi join (`test`.`t2_1024`) where ((`test`.`t2_1024`.`b1` > '0') and (`test`.`t1_1024`.`a1` = substr(`test`.`t2_1024`.`b1`,1,1024))) +select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select substring(b1,1,1024) from t2_1024 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select group_concat(b1) from t2_1024 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_1024 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 SUBQUERY t2_1024 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1024`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1024`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1024` where (`test`.`t1_1024`.`a1`,`test`.`t1_1024`.`a1` in ( (/* select#2 */ select group_concat(`test`.`t2_1024`.`b1` separator ',') from `test`.`t2_1024` group by `test`.`t2_1024`.`b2` having true ), (`test`.`t1_1024`.`a1` in on where ((`test`.`t1_1024`.`a1` = ``.`group_concat(b1)`))))) +select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select group_concat(b1) from t2_1024 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +set @@group_concat_max_len = 256; +explain select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select group_concat(b1) from t2_1024 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_1024 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 SUBQUERY t2_1024 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1024`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1024`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1024` where (`test`.`t1_1024`.`a1`,`test`.`t1_1024`.`a1` in ( (/* select#2 */ select group_concat(`test`.`t2_1024`.`b1` separator ',') from `test`.`t2_1024` group by `test`.`t2_1024`.`b2` having true ), (`test`.`t1_1024`.`a1` in on where ((`test`.`t1_1024`.`a1` = ``.`group_concat(b1)`))))) +select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select group_concat(b1) from t2_1024 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +drop table t1_1024, t2_1024, t3_1024; +set @blob_len = 1025; +set @suffix_len = @blob_len - @prefix_len; +create table t1_1025 (a1 blob(1025), a2 blob(1025)); +create table t2_1025 (b1 blob(1025), b2 blob(1025)); +create table t3_1025 (c1 blob(1025), c2 blob(1025)); +insert into t1_1025 values +(concat('1 - 00', repeat('x', @suffix_len)), concat('2 - 00', repeat('x', @suffix_len))); +insert into t1_1025 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t1_1025 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_1025 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t2_1025 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_1025 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_1025 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t3_1025 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t3_1025 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_1025 values +(concat('1 - 04', repeat('x', @suffix_len)), concat('2 - 04', repeat('x', @suffix_len))); +explain select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select b1 from t2_1025 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1_1025 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t2_1025 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(t1_1025); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1025`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1025`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1025` semi join (`test`.`t2_1025`) where ((`test`.`t2_1025`.`b1` = `test`.`t1_1025`.`a1`) and (`test`.`t1_1025`.`a1` > '0')) +select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select b1 from t2_1025 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_1025 +where (a1,a2) in (select b1, b2 from t2_1025 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1_1025 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t2_1025 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(t1_1025); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1025`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1025`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1025` semi join (`test`.`t2_1025`) where ((`test`.`t2_1025`.`b2` = `test`.`t1_1025`.`a2`) and (`test`.`t2_1025`.`b1` = `test`.`t1_1025`.`a1`) and (`test`.`t1_1025`.`a1` > '0')) +select left(a1,7), left(a2,7) +from t1_1025 +where (a1,a2) in (select b1, b2 from t2_1025 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select substring(b1,1,1025) from t2_1025 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1_1025 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE t2_1025 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(t1_1025); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1025`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1025`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1025` semi join (`test`.`t2_1025`) where ((`test`.`t2_1025`.`b1` > '0') and (`test`.`t1_1025`.`a1` = substr(`test`.`t2_1025`.`b1`,1,1025))) +select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select substring(b1,1,1025) from t2_1025 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select group_concat(b1) from t2_1025 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_1025 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 SUBQUERY t2_1025 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1025`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1025`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1025` where (`test`.`t1_1025`.`a1`,`test`.`t1_1025`.`a1` in ( (/* select#2 */ select group_concat(`test`.`t2_1025`.`b1` separator ',') from `test`.`t2_1025` group by `test`.`t2_1025`.`b2` having true ), (`test`.`t1_1025`.`a1` in on where ((`test`.`t1_1025`.`a1` = ``.`group_concat(b1)`))))) +select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select group_concat(b1) from t2_1025 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +set @@group_concat_max_len = 256; +explain select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select group_concat(b1) from t2_1025 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_1025 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 SUBQUERY t2_1025 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1025`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1025`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1025` where (`test`.`t1_1025`.`a1`,`test`.`t1_1025`.`a1` in ( (/* select#2 */ select group_concat(`test`.`t2_1025`.`b1` separator ',') from `test`.`t2_1025` group by `test`.`t2_1025`.`b2` having true ), (`test`.`t1_1025`.`a1` in on where ((`test`.`t1_1025`.`a1` = ``.`group_concat(b1)`))))) +select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select group_concat(b1) from t2_1025 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +drop table t1_1025, t2_1025, t3_1025; +# +# WL#5561: Enable semi join transformation with outer join. +# +CREATE TABLE ot1(a INT); +CREATE TABLE ot2(a INT); +CREATE TABLE ot3(a INT); +CREATE TABLE it1(a INT); +CREATE TABLE it2(a INT); +CREATE TABLE it3(a INT); +INSERT INTO ot1 VALUES(0),(1),(2),(3),(4),(5),(6),(7); +INSERT INTO ot2 VALUES(0),(2),(4),(6); +INSERT INTO ot3 VALUES(0),(3),(6); +INSERT INTO it1 VALUES(0),(1),(2),(3),(4),(5),(6),(7); +INSERT INTO it2 VALUES(0),(2),(4),(6); +INSERT INTO it3 VALUES(0),(3),(6); +# Test cases, Subquery Pattern 1 +# Example SQ1.1: +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE ot1.a IN (SELECT a FROM it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE it3 NULL ALL NULL NULL NULL NULL 3 100.00 Start temporary +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; End temporary; Using join buffer (hash join) +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` left join `test`.`ot2` on((`test`.`ot2`.`a` = `test`.`it3`.`a`)) semi join (`test`.`it3`) where (`test`.`ot1`.`a` = `test`.`it3`.`a`) +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE ot1.a IN (SELECT a FROM it3); +a a +0 0 +3 NULL +6 6 +# Example SQ1.2: +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE COALESCE(ot2.a,0) IN (SELECT a FROM it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 Using join buffer (hash join) +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (hash join) +2 MATERIALIZED it3 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` left join `test`.`ot2` on((`test`.`ot2`.`a` = `test`.`ot1`.`a`)) semi join (`test`.`it3`) where (coalesce(`test`.`ot2`.`a`,0) = ``.`a`) +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE COALESCE(ot2.a,0) IN (SELECT a FROM it3); +a a +0 0 +1 NULL +3 NULL +5 NULL +6 6 +7 NULL +# Example SQ1.3: +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE (ot1.a,ot2.a) IN (SELECT a, a FROM it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE it3 NULL ALL NULL NULL NULL NULL 3 100.00 Start temporary +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; Using join buffer (hash join) +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` join `test`.`ot2` semi join (`test`.`it3`) where ((`test`.`ot2`.`a` = `test`.`it3`.`a`) and (`test`.`ot1`.`a` = `test`.`it3`.`a`)) +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE (ot1.a,ot2.a) IN (SELECT a, a FROM it3); +a a +0 0 +6 6 +# More test cases +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 +WHERE ot1.a IN (SELECT a FROM it3); +a a +0 0 +3 NULL +6 6 +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 +WHERE ot1.a IN (SELECT a+0 FROM it3); +a a +0 0 +3 NULL +6 6 +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 +WHERE COALESCE(ot2.a,0) IN (SELECT a FROM it3); +a a +0 0 +1 NULL +3 NULL +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE COALESCE(ot2.a,0) IN (SELECT a+0 FROM it3); +a a +0 0 +1 NULL +3 NULL +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 +WHERE (ot1.a,ot2.a) IN (SELECT a, a FROM it3); +a a +0 0 +6 6 +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +LEFT JOIN ot3 ON ot1.a=ot3.a +WHERE ot1.a IN (SELECT a FROM it3); +a a a +0 0 0 +3 NULL 3 +6 6 6 +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +LEFT JOIN ot3 ON ot1.a=ot3.a +WHERE COALESCE(ot2.a,0) IN (SELECT a FROM it3); +a a a +0 0 0 +1 NULL NULL +3 NULL 3 +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +LEFT JOIN ot3 ON ot1.a=ot3.a +WHERE COALESCE(ot3.a,0) IN (SELECT a FROM it3); +a a a +0 0 0 +1 NULL NULL +2 2 NULL +3 NULL 3 +4 4 NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +LEFT JOIN ot3 ON ot2.a=ot3.a +WHERE ot1.a IN (SELECT a FROM it3); +a a a +0 0 0 +3 NULL NULL +6 6 6 +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +LEFT JOIN ot3 ON ot2.a=ot3.a +WHERE COALESCE(ot2.a,0) IN (SELECT a FROM it3); +a a a +0 0 0 +1 NULL NULL +3 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +LEFT JOIN ot3 ON ot2.a=ot3.a +WHERE COALESCE(ot3.a,0) IN (SELECT a FROM it3); +a a a +0 0 0 +1 NULL NULL +2 2 NULL +3 NULL NULL +4 4 NULL +5 NULL NULL +6 6 6 +7 NULL NULL +# Test cases, Subquery Pattern 2 +# Example SQ2.1: +explain SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE it3 NULL ALL NULL NULL NULL NULL 3 100.00 Start temporary +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; End temporary; Using join buffer (hash join) +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` join `test`.`ot2` semi join (`test`.`it3`) where ((`test`.`ot1`.`a` = `test`.`it3`.`a`) and (`test`.`ot2`.`a` = `test`.`it3`.`a`)) +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3); +a a +0 0 +6 6 +# Example SQ2.2: +explain SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it2) +AND ot2.a IN (SELECT a FROM it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE it3 NULL ALL NULL NULL NULL NULL 3 100.00 Start temporary +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; Using join buffer (hash join) +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; End temporary; Using join buffer (hash join) +1 SIMPLE it2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; FirstMatch(ot2); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` join `test`.`ot2` semi join (`test`.`it2`) semi join (`test`.`it3`) where ((`test`.`ot1`.`a` = `test`.`it3`.`a`) and (`test`.`ot2`.`a` = `test`.`it3`.`a`) and (`test`.`it2`.`a` = `test`.`it3`.`a`)) +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it2) +AND ot2.a IN (SELECT a FROM it3); +a a +0 0 +6 6 +# More test cases +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it3); +a a +0 0 +6 6 +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it3); +a a +0 0 +6 6 +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a+0 AND ot2.a IN (SELECT a FROM it3); +a a +0 0 +6 6 +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot2.a IN (SELECT a+0 FROM it3); +a a +0 0 +6 6 +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it2) +AND ot2.a IN (SELECT a+0 FROM it3); +a a +0 0 +6 6 +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3) +JOIN ot3 ON ot2.a=ot3.a AND ot3.a IN (SELECT a FROM it3); +a a a +0 0 0 +6 6 6 +# Test cases, Subquery Pattern 3 +# Example SQ3.1: +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +1 SIMPLE NULL eq_ref 5 test.ot1.a 1 100.00 NULL +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +2 MATERIALIZED it3 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` semi join (`test`.`it3`)) on(((``.`a` = `test`.`ot1`.`a`) and (`test`.`ot2`.`a` = `test`.`ot1`.`a`))) where true +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3); +a a +0 0 +1 NULL +2 NULL +3 NULL +4 NULL +5 NULL +6 6 +7 NULL +# Example SQ3.2: +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot2.a IN (SELECT a FROM it2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +1 SIMPLE NULL eq_ref 5 test.ot2.a 1 100.00 Using where +2 MATERIALIZED it2 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` semi join (`test`.`it2`)) on(((`test`.`ot2`.`a` = `test`.`ot1`.`a`) and (``.`a` = `test`.`ot1`.`a`))) where true +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot2.a IN (SELECT a FROM it2); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +# Example SQ3.3 +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1) +AND ot2.a IN (SELECT a FROM it2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +1 SIMPLE NULL eq_ref 5 test.ot1.a 1 100.00 NULL +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +1 SIMPLE NULL eq_ref 5 test.ot2.a 1 100.00 Using where +2 MATERIALIZED it1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +3 MATERIALIZED it2 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` semi join (`test`.`it1`) semi join (`test`.`it2`)) on(((``.`a` = `test`.`ot1`.`a`) and (`test`.`ot2`.`a` = `test`.`ot1`.`a`) and (``.`a` = `test`.`ot1`.`a`))) where true +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1) +AND ot2.a IN (SELECT a FROM it2); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +# Example SQ3.4 +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND +(ot1.a, ot2.a) IN (SELECT it1.a, it2.a +FROM it1 JOIN it2 ON it1.a=it2.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +1 SIMPLE NULL eq_ref 10 test.ot1.a,test.ot2.a 1 100.00 Using where +2 MATERIALIZED it2 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +2 MATERIALIZED it1 NULL ALL NULL NULL NULL NULL 8 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` semi join (`test`.`it1` join `test`.`it2`)) on(((`test`.`ot2`.`a` = `test`.`ot1`.`a`) and (``.`a` = `test`.`ot1`.`a`) and (``.`a` = `test`.`ot1`.`a`) and (`test`.`it1`.`a` = `test`.`it2`.`a`))) where true +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND +(ot1.a, ot2.a) IN (SELECT it1.a, it2.a +FROM it1 JOIN it2 ON it1.a=it2.a); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +# More test cases +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it3); +a a +0 0 +1 NULL +2 NULL +3 NULL +4 NULL +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it3); +a a +0 0 +1 NULL +2 NULL +3 NULL +4 NULL +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 AND ot2.a IN (SELECT a FROM it2); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot2.a IN (SELECT a+0 FROM it2); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a+0 FROM it1) +AND ot2.a IN (SELECT a+0 FROM it2); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 AND +(ot1.a, ot2.a) IN (SELECT it1.a+0, it2.a+0 +FROM it1 JOIN it2 ON it1.a=it2.a); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +EXPLAIN FORMAT=tree SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3) +LEFT JOIN ot3 ON ot2.a=ot3.a AND ot3.a IN (SELECT a FROM it3); +EXPLAIN +-> Nested loop left join (cost=41.01 rows=288) + -> Nested loop left join (cost=11.70 rows=96) + -> Table scan on ot1 (cost=1.30 rows=8) + -> Nested loop inner join (cost=2.80 rows=12) + -> Single-row index lookup on using (a=ot1.a) + -> Materialize with deduplication (cost=1.10..1.10 rows=3) + -> Filter: (it3.a is not null) (cost=0.80 rows=3) + -> Table scan on it3 (cost=0.80 rows=3) + -> Filter: (ot2.a = ot1.a) (cost=0.11 rows=4) + -> Table scan on ot2 (cost=0.11 rows=4) + -> Nested loop inner join (cost=9.93 rows=3) + -> Filter: (ot3.a = ot2.a) (cost=0.03 rows=3) + -> Table scan on ot3 (cost=0.03 rows=3) + -> Filter: (``.a = ot2.a) (cost=3.23..3.23 rows=1) + -> Single-row index lookup on using (a=ot3.a) + -> Materialize with deduplication (cost=1.10..1.10 rows=3) + -> Filter: (it3.a is not null) (cost=0.80 rows=3) + -> Table scan on it3 (cost=0.80 rows=3) + +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3) +LEFT JOIN ot3 ON ot2.a=ot3.a AND ot3.a IN (SELECT a FROM it3); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it3) +LEFT JOIN ot3 ON ot2.a=ot3.a+0 AND ot3.a IN (SELECT a FROM it3); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +# Test cases, Subquery Pattern 4 +# Example SQ4.1: +explain SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +1 SIMPLE NULL eq_ref 5 test.ot1.a 1 100.00 NULL +1 SIMPLE ot3 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +2 MATERIALIZED it1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a`,`test`.`ot3`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` join `test`.`ot3` semi join (`test`.`it1`)) on(((``.`a` = `test`.`ot1`.`a`) and (`test`.`ot3`.`a` = `test`.`ot1`.`a`) and (`test`.`ot2`.`a` = `test`.`ot1`.`a`))) where true +SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +# Example SQ4.2: +explain SELECT * +FROM ot1 +JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot3 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; Using join buffer (hash join) +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; Using join buffer (hash join) +1 SIMPLE it1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; FirstMatch(ot1); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a`,`test`.`ot3`.`a` AS `a` from `test`.`ot1` join `test`.`ot2` join `test`.`ot3` semi join (`test`.`it1`) where ((`test`.`ot2`.`a` = `test`.`ot3`.`a`) and (`test`.`ot1`.`a` = `test`.`ot3`.`a`) and (`test`.`it1`.`a` = `test`.`ot3`.`a`)) +SELECT * +FROM ot1 +JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +6 6 6 +# Example SQ4.3: +explain SELECT * +FROM ot1 +JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; Using join buffer (hash join) +1 SIMPLE NULL eq_ref 5 test.ot2.a 1 100.00 NULL +1 SIMPLE ot3 NULL ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (hash join) +2 MATERIALIZED it1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a`,`test`.`ot3`.`a` AS `a` from `test`.`ot1` join `test`.`ot2` left join `test`.`ot3` on((`test`.`ot3`.`a` = `test`.`ot2`.`a`)) semi join (`test`.`it1`) where ((`test`.`ot1`.`a` = `test`.`ot2`.`a`) and (``.`a` = `test`.`ot2`.`a`)) +SELECT * +FROM ot1 +JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +2 2 NULL +4 4 NULL +6 6 6 +# Example SQ4.4: +explain SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +1 SIMPLE NULL eq_ref 5 test.ot1.a 1 100.00 NULL +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +1 SIMPLE ot3 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 MATERIALIZED it1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a`,`test`.`ot3`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` left join `test`.`ot3` on((`test`.`ot3`.`a` = `test`.`ot1`.`a`)) semi join (`test`.`it1`)) on(((``.`a` = `test`.`ot1`.`a`) and (`test`.`ot2`.`a` = `test`.`ot1`.`a`))) where true +SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +1 NULL NULL +2 2 NULL +3 NULL NULL +4 4 NULL +5 NULL NULL +6 6 6 +7 NULL NULL +# More test cases +SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a+0) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it1); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 +JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a+0) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +6 6 6 +SELECT * +FROM ot1 +JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +6 6 6 +SELECT * +FROM ot1 +JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it1); +a a a +0 0 0 +6 6 6 +SELECT * +FROM ot1 +JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a+0) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +2 2 NULL +4 4 NULL +6 6 6 +SELECT * +FROM ot1 +JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +2 2 NULL +4 4 NULL +6 6 6 +SELECT * +FROM ot1 +JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it1); +a a a +0 0 0 +2 2 NULL +4 4 NULL +6 6 6 +SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a+0) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +1 NULL NULL +2 2 NULL +3 NULL NULL +4 4 NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +1 NULL NULL +2 2 NULL +3 NULL NULL +4 4 NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it1); +a a a +0 0 0 +1 NULL NULL +2 2 NULL +3 NULL NULL +4 4 NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1) +LEFT JOIN +ot1 AS ot4 +ON ot2.a=ot4.a; +a a a a +0 0 0 0 +1 NULL NULL NULL +2 2 NULL 2 +3 NULL NULL NULL +4 4 NULL 4 +5 NULL NULL NULL +6 6 6 6 +7 NULL NULL NULL +SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a +LEFT JOIN ot1 AS ot4 ON ot3.a=ot4.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a a +0 0 0 0 +1 NULL NULL NULL +2 2 NULL NULL +3 NULL NULL NULL +4 4 NULL NULL +5 NULL NULL NULL +6 6 6 6 +7 NULL NULL NULL +DROP TABLE ot1,ot2,ot3,it1,it2,it3; +CREATE TABLE t ( +a INTEGER DEFAULT NULL +) ENGINE=InnoDB; +INSERT INTO t VALUES (1); +CREATE TABLE t2 ( +a INTEGER DEFAULT NULL +) ENGINE=InnoDB; +INSERT INTO t2 VALUES (1),(1); +CREATE TABLE t4 ( +a INTEGER DEFAULT NULL +) ENGINE=InnoDB; +INSERT INTO t4 VALUES (1),(1); +CREATE TABLE v ( +a INTEGER DEFAULT NULL +) ENGINE=InnoDB; +INSERT INTO v VALUES (1),(1); +explain SELECT * +FROM t AS t1 +LEFT JOIN +(t2 +LEFT JOIN t AS t3 +ON t3.a IN (SELECT a FROM t AS it) +JOIN t4 +ON t4.a=100 +) +ON TRUE +WHERE t1.a IN (SELECT * FROM v AS it2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE it2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1); Using join buffer (hash join) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE it NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t3) +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t4`.`a` AS `a` from `test`.`t` `t1` left join (`test`.`t2` left join (`test`.`t` `t3` semi join (`test`.`t` `it`)) on(((`test`.`it`.`a` = `test`.`t3`.`a`))) join `test`.`t4`) on(((`test`.`t4`.`a` = 100))) semi join (`test`.`v` `it2`) where (`test`.`it2`.`a` = `test`.`t1`.`a`) +SELECT * +FROM t AS t1 +LEFT JOIN +(t2 +LEFT JOIN t AS t3 +ON t3.a IN (SELECT a FROM t AS it) +JOIN t4 +ON t4.a=100 +) +ON TRUE +WHERE t1.a IN (SELECT * FROM v AS it2); +a a a a +1 NULL NULL NULL +DROP TABLE t,t2,t4,v; +# End of WL#5561 +# +# Bug#48868: Left outer join in subquery causes segmentation fault in +# make_join_select. +# +CREATE TABLE t1 (i INTEGER); +INSERT INTO t1 VALUES (1); +INSERT INTO t1 VALUES (2); +CREATE TABLE t2 (i INTEGER); +INSERT INTO t2 VALUES(1); +CREATE TABLE t3 (i INTEGER); +INSERT INTO t3 VALUES (1); +INSERT INTO t3 VALUES (2); +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t2.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +1 +DROP TABLE t1, t2, t3; + +Bug#37899: Wrongly checked optimization prerequisite caused failed +assertion. + +CREATE TABLE t1 ( +`pk` int(11), +`varchar_nokey` varchar(5) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES +(1,'qk'),(2,'j'),(3,'aew'); +SELECT * +FROM t1 +WHERE varchar_nokey IN ( +SELECT +varchar_nokey +FROM +t1 +) XOR pk = 30; +pk varchar_nokey +1 qk +2 j +3 aew +drop table t1; +# +# BUG#41842: Semi-join materialization strategy crashes when the upper query has HAVING +# +CREATE TABLE t1 ( +pk int(11) NOT NULL AUTO_INCREMENT, +int_nokey int(11) NOT NULL, +time_key time NOT NULL, +datetime_key datetime NOT NULL, +datetime_nokey datetime NOT NULL, +varchar_key varchar(1) NOT NULL, +varchar_nokey varchar(1) NOT NULL, +PRIMARY KEY (pk), +KEY time_key (time_key), +KEY datetime_key (datetime_key), +KEY varchar_key (varchar_key) +) ENGINE=MyISaM; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES +(1,0, '00:16:10','2008-09-03 14:25:40','2008-09-03 14:25:40','h','h'), +(2,7, '00:00:00','2001-01-13 00:00:00','2001-01-13 00:00:00','',''), +(3,0, '00:00:00','0000-00-00 00:00:00','0000-00-00 00:00:00','x','x'), +(4,2, '16:29:24','2000-10-16 01:39:08','2000-10-16 01:39:08','w','w'), +(5,1, '09:23:32','0000-00-00 00:00:00','0000-00-00 00:00:00','p','p'), +(6,3, '00:00:00','2007-12-02 00:00:00','2007-12-02 00:00:00','o','o'), +(7,3, '00:00:00','2008-09-11 00:00:00','2008-09-11 00:00:00','',''), +(8,0, '13:59:04','0000-00-00 00:00:00','0000-00-00 00:00:00','s','s'), +(9,7, '09:01:06','0000-00-00 00:00:00','0000-00-00 00:00:00','d','d'), +(10,5,'00:00:00','0000-00-00 00:00:00','0000-00-00 00:00:00','n','n'), +(11,0,'21:06:46','0000-00-00 00:00:00','0000-00-00 00:00:00','o','o'), +(12,2,'00:00:00','0000-00-00 00:00:00','0000-00-00 00:00:00','',''), +(13,6,'14:45:34','2003-07-28 02:34:08','2003-07-28 02:34:08','w','w'), +(14,1,'15:04:12','0000-00-00 00:00:00','0000-00-00 00:00:00','o','o'), +(15,0,'00:00:00','0000-00-00 00:00:00','0000-00-00 00:00:00','x','x'), +(16,0,'15:55:23','2004-03-17 00:32:27','2004-03-17 00:32:27','p','p'), +(17,1,'16:30:00','2004-12-27 19:20:00','2004-12-27 19:20:00','d','d'), +(18,0,'00:00:00','0000-00-00 00:00:00','0000-00-00 00:00:00','h','h'), +(19,0,'14:13:26','2008-11-09 05:53:48','2008-11-09 05:53:48','o','o'), +(20,0,'00:00:00','2009-10-11 06:58:04','2009-10-11 06:58:04','k','k'); +Warnings: +Warning 1264 Out of range value for column 'datetime_key' at row 3 +Warning 1264 Out of range value for column 'datetime_nokey' at row 3 +Warning 1264 Out of range value for column 'datetime_key' at row 5 +Warning 1264 Out of range value for column 'datetime_nokey' at row 5 +Warning 1264 Out of range value for column 'datetime_key' at row 8 +Warning 1264 Out of range value for column 'datetime_nokey' at row 8 +Warning 1264 Out of range value for column 'datetime_key' at row 9 +Warning 1264 Out of range value for column 'datetime_nokey' at row 9 +Warning 1264 Out of range value for column 'datetime_key' at row 10 +Warning 1264 Out of range value for column 'datetime_nokey' at row 10 +Warning 1264 Out of range value for column 'datetime_key' at row 11 +Warning 1264 Out of range value for column 'datetime_nokey' at row 11 +Warning 1264 Out of range value for column 'datetime_key' at row 12 +Warning 1264 Out of range value for column 'datetime_nokey' at row 12 +Warning 1264 Out of range value for column 'datetime_key' at row 14 +Warning 1264 Out of range value for column 'datetime_nokey' at row 14 +Warning 1264 Out of range value for column 'datetime_key' at row 15 +Warning 1264 Out of range value for column 'datetime_nokey' at row 15 +Warning 1264 Out of range value for column 'datetime_key' at row 18 +Warning 1264 Out of range value for column 'datetime_nokey' at row 18 +CREATE TABLE t2 ( +pk int(11) NOT NULL AUTO_INCREMENT, +int_nokey int(11) NOT NULL, +time_key time NOT NULL, +datetime_key datetime NOT NULL, +datetime_nokey datetime NOT NULL, +varchar_key varchar(1) NOT NULL, +varchar_nokey varchar(1) NOT NULL, +PRIMARY KEY (pk), +KEY time_key (time_key), +KEY datetime_key (datetime_key), +KEY varchar_key (varchar_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT IGNORE INTO t2 VALUES +(10,0,'19:39:13','0000-00-00 00:00:00','0000-00-00 00:00:00','g','g'), +(11,8,'03:43:53','0000-00-00 00:00:00','0000-00-00 00:00:00','b','b'); +Warnings: +Warning 1264 Out of range value for column 'datetime_key' at row 1 +Warning 1264 Out of range value for column 'datetime_nokey' at row 1 +Warning 1264 Out of range value for column 'datetime_key' at row 2 +Warning 1264 Out of range value for column 'datetime_nokey' at row 2 +SELECT OUTR.datetime_nokey AS X FROM t1 AS OUTR +WHERE +OUTR.varchar_nokey IN (SELECT +INNR . varchar_nokey AS Y +FROM t2 AS INNR +WHERE +INNR . datetime_key >= INNR . time_key OR +INNR . pk = INNR . int_nokey +) +AND OUTR . varchar_nokey <= 'w' +HAVING X > '2012-12-12'; +X +drop table t1, t2; + +Bug#46797 "Crash in fix_semijoin_strategies_for_picked_join_order +with semijoin=on" + +CREATE TABLE t1 ( +varchar_key varchar(1) DEFAULT NULL, +KEY varchar_key (varchar_key) +); +CREATE TABLE t2 ( +varchar_key varchar(1) DEFAULT NULL, +KEY varchar_key (varchar_key) +); +INSERT INTO t2 VALUES +(NULL),(NULL),(NULL),(NULL),('a'),('a'),('a'),('b'),('b'),('b'),('b'),('c'), +('c'),('c'),('c'),('c'),('c'),('c'),('d'),('d'),('d'),('d'),('d'),('d'),('e'), +('e'),('e'),('e'),('e'),('e'),('f'),('f'),('f'),('g'),('g'),('h'),('h'),('h'), +('h'),('i'),('j'),('j'),('j'),('k'),('k'),('l'),('l'),('m'),('m'),('m'),('m'), +('n'),('n'),('n'),('o'),('o'),('o'),('p'),('p'),('p'),('q'),('q'),('q'),('r'), +('r'),('r'),('r'),('s'),('s'),('s'),('s'),('t'),('t'),('t'),('t'),('u'),('u'), +('u'),('u'),('v'),('v'),('v'),('v'),('w'),('w'),('w'),('w'),('w'),('w'),('x'), +('x'),('x'),('y'),('y'),('y'),('y'),('z'),('z'),('z'),('z'); +CREATE TABLE t3 ( +varchar_key varchar(1) DEFAULT NULL, +KEY varchar_key (varchar_key) +) ENGINE=MyISAM DEFAULT CHARSET=latin1; +INSERT INTO t3 VALUES +(NULL),('c'),('d'),('e'),('f'),('h'),('j'),('k'),('k'),('m'),('m'),('m'), +('n'),('o'),('r'),('t'),('t'),('u'),('w'),('y'); +SELECT varchar_key FROM t3 +WHERE (SELECT varchar_key FROM t3 +WHERE (varchar_key,varchar_key) +IN (SELECT t1.varchar_key, t2 .varchar_key +FROM t1 RIGHT JOIN t2 ON t1.varchar_key +) +); +varchar_key +DROP TABLE t1, t2, t3; +# +# Bug#46556 Returning incorrect, empty results for some IN subqueries +# w/semijoin=on +# +CREATE TABLE t0 ( +pk INTEGER, +vkey VARCHAR(1), +vnokey VARCHAR(1), +PRIMARY KEY (pk), +KEY vkey(vkey) +) charset utf8mb4; +INSERT INTO t0 +VALUES (1,'g','g'), (2,'v','v'), (3,'t','t'), (4,'u','u'), (5,'n','n'); +EXPLAIN SELECT vkey FROM t0 WHERE pk IN +(SELECT t1.pk FROM t0 t1 JOIN t0 t2 ON t2.vkey = t1.vnokey); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL ALL PRIMARY NULL NULL NULL 5 100.00 NULL +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t0.pk 1 100.00 Using where +1 SIMPLE t2 NULL ref vkey vkey 7 test.t1.vnokey 2 100.00 Using index; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`vkey` AS `vkey` from `test`.`t0` `t1` join `test`.`t0` semi join (`test`.`t0` `t2`) where ((`test`.`t2`.`vkey` = `test`.`t1`.`vnokey`) and (`test`.`t1`.`pk` = `test`.`t0`.`pk`)) +SELECT vkey FROM t0 WHERE pk IN +(SELECT t1.pk FROM t0 t1 JOIN t0 t2 ON t2.vkey = t1.vnokey); +vkey +g +n +t +u +v +DROP TABLE t0; +# End of bug#46556 + +Bug#48834: Procedure with view + subquery + semijoin=on +crashes on second call. + +CREATE TABLE t1 ( t1field integer, primary key (t1field)); +CREATE TABLE t2 ( t2field integer, primary key (t2field)); +CREATE VIEW v1 AS +SELECT t1field as v1field +FROM t1 A +WHERE A.t1field IN (SELECT t1field FROM t2 ); +CREATE VIEW v2 AS +SELECT t2field as v2field +FROM t2 A +WHERE A.t2field IN (SELECT t2field FROM t2 ); +CREATE PROCEDURE p1 () +BEGIN +SELECT v1field +FROM v1 +WHERE v1field IN ( SELECT v2field as vf_inner FROM v2 ); +END| +INSERT INTO t1 VALUES (1),(2),(3); +INSERT INTO t2 VALUES (2),(3),(4); +CALL p1; +v1field +2 +3 +CALL p1; +v1field +2 +3 +DROP TABLE t1,t2; +DROP VIEW v1,v2; +DROP PROCEDURE p1; +# End of BUG#48834 +# +# Bug#46692 "Crash occurring on queries with nested FROM subqueries +# using materialization." +# +CREATE TABLE t1 ( +pk INTEGER PRIMARY KEY, +int_key INTEGER, +KEY int_key(int_key) +); +INSERT INTO t1 VALUES (10,186),(11,NULL),(12,2),(13,3),(14,0),(15,133),(16,1); +CREATE TABLE t2 ( +pk INTEGER PRIMARY KEY, +int_key INTEGER, +KEY int_key(int_key) +); +INSERT INTO t2 VALUES (1,7),(2,2); +SELECT * FROM t1 WHERE (140, 4) IN +(SELECT t2.int_key, t2 .pk FROM t2 STRAIGHT_JOIN t1 ON t2.int_key); +pk int_key +DROP TABLE t1, t2; +# +# Bug#42353 "SELECT ... WHERE oe IN (SELECT w/ LEFT JOIN) query +# causes crash." +# +CREATE TABLE t1 ( +pk INTEGER PRIMARY KEY, +int_nokey INTEGER, +int_key INTEGER, +date_key DATE, +datetime_nokey DATETIME, +varchar_nokey VARCHAR(1) +); +CREATE TABLE t2 ( +date_nokey DATE +); +CREATE TABLE t3 ( +pk INTEGER PRIMARY KEY, +int_nokey INTEGER, +date_key date, +varchar_key VARCHAR(1), +varchar_nokey VARCHAR(1), +KEY date_key (date_key) +); +SELECT date_key FROM t1 +WHERE (int_key, int_nokey) +IN (SELECT t3.int_nokey, t3.pk +FROM t2 LEFT JOIN t3 ON (t2.date_nokey < t3.date_key) +WHERE t3.varchar_key <= t3.varchar_nokey OR t3.int_nokey <= t3.pk +) +AND (varchar_nokey <> 'f' OR NOT int_key < 7); +date_key +# +# Bug#45933 "Crash in optimize_semijoin_nests on JOIN in subquery +# + AND in outer query". +# +INSERT INTO t1 VALUES (10,7,5,'2009-06-16','2002-04-10 14:25:30','w'), +(11,7,0,'0000-00-00','0000-00-00 00:00:00','s'), +(12,4,0,'2003-07-14','2006-09-14 04:01:02','y'), +(13,0,4,'2002-07-25','0000-00-00 00:00:00','c'), +(14,1,8,'2007-07-03','0000-00-00 00:00:00','q'), +(15,6,5,'2001-11-12','0000-00-00 00:00:00',''), +(16,2,9,'0000-00-00','0000-00-00 00:00:00','j'), +(29,9,1,'0000-00-00','2003-08-11 00:00:00','m'); +Warnings: +Warning 1264 Out of range value for column 'date_key' at row 2 +Warning 1264 Out of range value for column 'datetime_nokey' at row 2 +Warning 1264 Out of range value for column 'datetime_nokey' at row 4 +Warning 1264 Out of range value for column 'datetime_nokey' at row 5 +Warning 1264 Out of range value for column 'datetime_nokey' at row 6 +Warning 1264 Out of range value for column 'date_key' at row 7 +Warning 1264 Out of range value for column 'datetime_nokey' at row 7 +Warning 1264 Out of range value for column 'date_key' at row 8 +INSERT IGNORE INTO t3 VALUES (1,9,'0000-00-00','b','b'), +(2,2,'2002-09-17','h','h'); +Warnings: +Warning 1264 Out of range value for column 'date_key' at row 1 +SELECT t1.varchar_nokey FROM t1 JOIN t3 ON t1.datetime_nokey +WHERE t1.varchar_nokey +IN (SELECT varchar_nokey FROM t1 +WHERE (pk) +IN (SELECT t3.int_nokey +FROM t3 LEFT JOIN t1 ON t1.varchar_nokey +WHERE t3.date_key BETWEEN '2008-06-07' AND '2006-06-26' + ) +); +varchar_nokey +DROP TABLE t1, t2, t3; +# +# Bug#45219 "Crash on SELECT DISTINCT query containing a +# LEFT JOIN in subquery" +# +CREATE TABLE t1 ( +pk INTEGER NOT NULL, +int_nokey INTEGER NOT NULL, +datetime_key DATETIME NOT NULL, +varchar_key VARCHAR(1) NOT NULL, +PRIMARY KEY (pk), +KEY datetime_key (datetime_key), +KEY varchar_key (varchar_key) +); +INSERT IGNORE INTO t1 VALUES +(1,9,'0000-00-00 00:00:00','p'),(2,0,'2002-02-09 07:38:13','v'), +(3,8,'2001-05-03 12:08:14','t'),(4,3,'0000-00-00 00:00:00','u'), +(5,7,'2009-07-28 03:43:30','n'),(6,0,'2009-08-04 00:00:00','l'), +(7,1,'0000-00-00 00:00:00','h'),(8,9,'0000-00-00 00:00:00','u'), +(9,0,'2005-08-02 17:16:54','n'),(10,9,'2002-12-21 00:00:00','j'), +(11,0,'2005-08-15 12:37:35','k'),(12,5,'0000-00-00 00:00:00','e'), +(13,0,'2006-03-10 00:00:00','i'),(14,8,'2005-05-16 11:02:36','u'), +(15,8,'2008-11-02 00:00:00','n'),(16,5,'2006-03-15 00:00:00','b'), +(17,1,'0000-00-00 00:00:00','x'),(18,7,'0000-00-00 00:00:00',''), +(19,0,'2008-12-17 20:15:40','q'),(20,9,'0000-00-00 00:00:00','u'); +Warnings: +Warning 1264 Out of range value for column 'datetime_key' at row 1 +Warning 1264 Out of range value for column 'datetime_key' at row 4 +Warning 1264 Out of range value for column 'datetime_key' at row 7 +Warning 1264 Out of range value for column 'datetime_key' at row 8 +Warning 1264 Out of range value for column 'datetime_key' at row 12 +Warning 1264 Out of range value for column 'datetime_key' at row 17 +Warning 1264 Out of range value for column 'datetime_key' at row 18 +Warning 1264 Out of range value for column 'datetime_key' at row 20 +CREATE TABLE t2 LIKE t1; +INSERT INTO t2 VALUES +(10,0,'2006-07-07 07:26:28','q'),(11,5,'2002-09-23 00:00:00','m'), +(12,7,'0000-00-00 00:00:00','j'),(13,1,'2006-06-07 00:00:00','z'), +(14,8,'2000-09-16 12:15:34','a'),(15,2,'2007-08-05 15:47:52',''), +(16,1,'0000-00-00 00:00:00','e'),(17,8,'2005-12-02 19:34:26','t'), +(18,5,'0000-00-00 00:00:00','q'),(19,4,'0000-00-00 00:00:00','b'), +(20,5,'2007-12-28 00:00:00','w'),(21,3,'2004-08-02 11:48:43','m'), +(22,0,'0000-00-00 00:00:00','x'),(23,8,'2004-04-19 12:18:43',''), +(24,0,'2009-04-27 00:00:00','w'),(25,4,'2006-10-20 14:52:15','x'), +(26,0,'0000-00-00 00:00:00','e'),(27,0,'2002-03-22 11:48:37','e'), +(28,2,'0000-00-00 00:00:00','p'),(29,0,'2001-01-04 03:55:07','x'); +Warnings: +Warning 1264 Out of range value for column 'datetime_key' at row 3 +Warning 1264 Out of range value for column 'datetime_key' at row 7 +Warning 1264 Out of range value for column 'datetime_key' at row 9 +Warning 1264 Out of range value for column 'datetime_key' at row 10 +Warning 1264 Out of range value for column 'datetime_key' at row 13 +Warning 1264 Out of range value for column 'datetime_key' at row 17 +Warning 1264 Out of range value for column 'datetime_key' at row 19 +CREATE TABLE t3 LIKE t1; +INSERT INTO t3 VALUES +(10,8,'2007-08-19 08:08:38','i'),(11,0,'2000-05-21 03:51:51',''); +SELECT DISTINCT datetime_key FROM t1 +WHERE (int_nokey, pk) +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#46550 Azalea returning duplicate results for some IN subqueries +# w/ semijoin=on +# +DROP TABLE IF EXISTS t0, t1, t2; +CREATE TABLE t0 ( +int_key int(11) DEFAULT NULL, +varchar_key varchar(1) DEFAULT NULL, +varchar_nokey varchar(1) DEFAULT NULL, +KEY int_key (int_key), +KEY varchar_key (varchar_key,int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t0 VALUES +(1,'m','m'), +(40,'h','h'), +(1,'r','r'), +(1,'h','h'), +(9,'x','x'), +(NULL,'q','q'), +(NULL,'k','k'), +(7,'l','l'), +(182,'k','k'), +(202,'a','a'), +(7,'x','x'), +(6,'j','j'), +(119,'z','z'), +(4,'d','d'), +(5,'h','h'), +(1,'u','u'), +(3,'q','q'), +(7,'a','a'), +(3,'e','e'), +(6,'l','l'); +CREATE TABLE t1 ( +int_key int(11) DEFAULT NULL, +varchar_key varchar(1) DEFAULT NULL, +varchar_nokey varchar(1) DEFAULT NULL, +KEY int_key (int_key), +KEY varchar_key (varchar_key,int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (7,NULL,NULL),(4,'x','x'); +CREATE TABLE t2 ( +int_key int(11) DEFAULT NULL, +varchar_key varchar(1) DEFAULT NULL, +varchar_nokey varchar(1) DEFAULT NULL, +KEY int_key (int_key), +KEY varchar_key (varchar_key,int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (123,NULL,NULL); +SELECT int_key +FROM t0 +WHERE varchar_nokey IN ( +SELECT t1 .varchar_key from t1 +); +int_key +7 +9 +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 +7 +9 +EXPLAIN +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 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1_1 NULL index varchar_key varchar_key 12 NULL 2 50.00 Using where; Using index; LooseScan +1 SIMPLE t1_2 NULL index NULL int_key 5 NULL 2 100.00 Using index; FirstMatch(t1_1) +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 20 10.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`int_key` AS `int_key` from `test`.`t0` semi join (`test`.`t1` `t1_1` join `test`.`t1` `t1_2`) where ((`test`.`t0`.`varchar_nokey` = `test`.`t1_1`.`varchar_key`) and (0 <> `test`.`t1_1`.`int_key`)) +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 +7 +9 +EXPLAIN +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 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t1_1 NULL index varchar_key varchar_key 12 NULL 2 50.00 Using where; Using index; LooseScan +1 SIMPLE t1_2 NULL index NULL int_key 5 NULL 2 100.00 Using index; FirstMatch(t1_1) +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 20 10.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`int_key` AS `int_key` from `test`.`t0` semi join (`test`.`t1` `t1_1` join `test`.`t1` `t1_2`) where ((`test`.`t0`.`varchar_nokey` = `test`.`t1_1`.`varchar_key`) and (0 <> `test`.`t1_1`.`int_key`)) +DROP TABLE t0, t1, t2; +# End of bug#46550 + +Bug #48073 Subquery on char columns from view crashes Mysql + +DROP TABLE IF EXISTS t1, t2; +DROP VIEW IF EXISTS v1; +CREATE TABLE t1 ( +city VARCHAR(50) NOT NULL, +country_id SMALLINT UNSIGNED NOT NULL +); +INSERT INTO t1 VALUES +('Batna',2), +('Bchar',2), +('Skikda',2), +('Tafuna',3), +('Algeria',2) ; +CREATE TABLE t2 ( +country_id SMALLINT UNSIGNED NOT NULL, +country VARCHAR(50) NOT NULL +); +INSERT INTO t2 VALUES +(2,'Algeria'), +(3,'American Samoa') ; +CREATE VIEW v1 AS +SELECT country_id, country +FROM t2 +WHERE LEFT(country,1) = "A" +; +SELECT city, country_id +FROM t1 +WHERE city IN ( +SELECT country +FROM t2 +WHERE LEFT(country, 1) = "A" +); +city country_id +Algeria 2 +SELECT city, country_id +FROM t1 +WHERE city IN ( +SELECT country +FROM v1 +); +city country_id +Algeria 2 +drop table t1, t2; +drop view v1; +# End of bug#48073 + +Bug#49097 subquery with view generates wrong result with +non-prepared statement + +DROP TABLE IF EXISTS t1, t2; +DROP VIEW IF EXISTS v1; +CREATE TABLE t1 ( +city VARCHAR(50) NOT NULL, +country_id SMALLINT UNSIGNED NOT NULL +); +INSERT INTO t1 VALUES +('Batna',2), +('Bchar',2), +('Skikda',2), +('Tafuna',3), +('Algeria',2) ; +CREATE TABLE t2 ( +country_id SMALLINT UNSIGNED NOT NULL, +country VARCHAR(50) NOT NULL +); +INSERT INTO t2 VALUES +(2,'Algeria'), +(3,'XAmerican Samoa') ; +CREATE VIEW v1 AS +SELECT country_id, country +FROM t2 +WHERE LEFT(country,1) = "A" +; +SELECT city, country_id +FROM t1 +WHERE country_id IN ( +SELECT country_id +FROM t2 +WHERE LEFT(country,1) = "A" +); +city country_id +Algeria 2 +Batna 2 +Bchar 2 +Skikda 2 +SELECT city, country_id +FROM t1 +WHERE country_id IN ( +SELECT country_id +FROM v1 +); +city country_id +Algeria 2 +Batna 2 +Bchar 2 +Skikda 2 +PREPARE stmt FROM +" +SELECT city, country_id +FROM t1 +WHERE country_id IN ( + SELECT country_id + FROM v1 +); +"; +execute stmt; +city country_id +Algeria 2 +Batna 2 +Bchar 2 +Skikda 2 +deallocate prepare stmt; +drop table t1, t2; +drop view v1; +# End of Bug#49097 +# +# Bug#49198 Wrong result for second call of procedure +# with view in subselect. +# +CREATE TABLE t1 (t1field integer, primary key (t1field)); +CREATE TABLE t2 (t2field integer, primary key (t2field)); +CREATE TABLE t3 (t3field integer, primary key (t3field)); +CREATE VIEW v2 AS SELECT * FROM t2; +CREATE VIEW v3 AS SELECT * FROM t3; +INSERT INTO t1 VALUES(1),(2); +INSERT INTO t2 VALUES(1),(2); +INSERT INTO t3 VALUES(1),(2); +PREPARE stmt FROM +" +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT * FROM v2); +"; +EXECUTE stmt; +t1field +1 +2 + +EXECUTE stmt; +t1field +1 +2 +PREPARE stmt FROM +" +EXPLAIN +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT * FROM v2) + AND t1field IN (SELECT * FROM v3) +"; +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index PRIMARY PRIMARY 4 NULL 2 100.00 Using index +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +1 SIMPLE t3 NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`t1field` AS `t1field` from `test`.`t2` join `test`.`t3` join `test`.`t1` where ((`test`.`t2`.`t2field` = `test`.`t1`.`t1field`) and (`test`.`t3`.`t3field` = `test`.`t1`.`t1field`)) + +This line is only in place to help --skip_if_hypergraph diffing some more. + +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index PRIMARY PRIMARY 4 NULL 2 100.00 Using index +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +1 SIMPLE t3 NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`t1field` AS `t1field` from `test`.`t2` join `test`.`t3` join `test`.`t1` where ((`test`.`t2`.`t2field` = `test`.`t1`.`t1field`) and (`test`.`t3`.`t3field` = `test`.`t1`.`t1field`)) +DROP TABLE t1, t2, t3; +DROP VIEW v2, v3; +# End of Bug#49198 +# +# Bug#48623 Multiple subqueries are optimized incorrectly +# +CREATE TABLE ot(val VARCHAR(10)) charset utf8mb4; +CREATE TABLE it1(val VARCHAR(10)) charset utf8mb4; +CREATE TABLE it2(val VARCHAR(10)) charset utf8mb4; +INSERT INTO ot VALUES('aaa'), ('bbb'), ('eee'), ('mmm'), ('ppp'); +INSERT INTO it1 VALUES('aaa'), ('aaa'), ('bbb'), ('eee'), ('mmm'), ('ppp'); +INSERT INTO it2 VALUES('aaa'), ('bbb'), ('eee'), ('mmm'), ('ppp'); +EXPLAIN +SELECT * +FROM ot +WHERE ot.val IN (SELECT it1.val FROM it1 +WHERE it1.val LIKE 'a%' OR it1.val LIKE 'e%') +AND ot.val IN (SELECT it2.val FROM it2 +WHERE it2.val LIKE 'a%' OR it2.val LIKE 'e%'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 5 100.00 NULL +1 SIMPLE it2 NULL ALL NULL NULL NULL NULL 5 20.00 Using where; FirstMatch(ot); Using join buffer (hash join) +1 SIMPLE it1 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; FirstMatch(it2); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot`.`val` AS `val` from `test`.`ot` semi join (`test`.`it1`) semi join (`test`.`it2`) where ((`test`.`it2`.`val` = `test`.`ot`.`val`) and (`test`.`it1`.`val` = `test`.`ot`.`val`) and ((`test`.`it1`.`val` like 'a%') or (`test`.`it1`.`val` like 'e%')) and ((`test`.`it2`.`val` like 'a%') or (`test`.`it2`.`val` like 'e%'))) +SELECT * +FROM ot +WHERE ot.val IN (SELECT it1.val FROM it1 +WHERE it1.val LIKE 'a%' OR it1.val LIKE 'e%') +AND ot.val IN (SELECT it2.val FROM it2 +WHERE it2.val LIKE 'a%' OR it2.val LIKE 'e%'); +val +aaa +eee +DROP TABLE ot; +DROP TABLE it1; +DROP TABLE it2; +# End of Bug#48623 +# +# Bug #51487 Assertion failure when semi-join flattening occurs +# for a subquery in HAVING +# +CREATE TABLE t1 (a INT, b INT); +INSERT INTO t1 VALUES (1,10),(2,11),(1,13); +CREATE TABLE t2 AS SELECT * FROM t1; +CREATE TABLE t3 AS SELECT * FROM t1; +SELECT COUNT(*) FROM t1 +GROUP BY t1.a +HAVING t1.a IN (SELECT t3.a FROM t3 +WHERE t3.b IN (SELECT b FROM t2 WHERE t2.a=t1.a)); +COUNT(*) +2 +1 +DROP TABLE t1, t2, t3; +# End of Bug#51487 +# +# BUG#38075: Wrong result: rows matching a subquery with outer join not returned +# +DROP TABLE IF EXISTS ot1, it1, it2; +CREATE TABLE it2 ( +int_key int(11) NOT NULL, +datetime_key datetime NOT NULL, +KEY int_key (int_key), +KEY datetime_key (datetime_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO it2 VALUES +(5,'2002-04-10 14:25:30'), (0,'0000-00-00 00:00:00'), +(0,'2006-09-14 04:01:02'), (4,'0000-00-00 00:00:00'), +(8,'0000-00-00 00:00:00'), (5,'0000-00-00 00:00:00'), +(9,'0000-00-00 00:00:00'), (8,'2007-04-01 11:04:17'), +(1,'0000-00-00 00:00:00'), (7,'2009-01-12 00:00:00'), +(0,'2009-06-05 00:00:00'), (3,'2006-02-14 18:06:35'), +(5,'2006-02-21 07:08:16'), (0,'0000-00-00 00:00:00'), +(7,'0000-00-00 00:00:00'), (0,'0000-00-00 00:00:00'), +(0,'2007-02-13 00:00:00'), (1,'0000-00-00 00:00:00'), +(0,'0000-00-00 00:00:00'), (1,'2003-08-11 00:00:00'); +Warnings: +Warning 1264 Out of range value for column 'datetime_key' at row 2 +Warning 1264 Out of range value for column 'datetime_key' at row 4 +Warning 1264 Out of range value for column 'datetime_key' at row 5 +Warning 1264 Out of range value for column 'datetime_key' at row 6 +Warning 1264 Out of range value for column 'datetime_key' at row 7 +Warning 1264 Out of range value for column 'datetime_key' at row 9 +Warning 1264 Out of range value for column 'datetime_key' at row 14 +Warning 1264 Out of range value for column 'datetime_key' at row 15 +Warning 1264 Out of range value for column 'datetime_key' at row 16 +Warning 1264 Out of range value for column 'datetime_key' at row 18 +Warning 1264 Out of range value for column 'datetime_key' at row 19 +CREATE TABLE ot1 ( +int_nokey int(11) NOT NULL, +int_key int(11) NOT NULL, +KEY int_key (int_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO ot1 VALUES +(5,0), (3,0), (0,2), (3,0), (1,3), (0,0), (1,7), (7,0), (1,7), (0,7), +(0,9), (8,2), (4,4), (9,3), (0,9), (2,5), (0,5), (8,0), (5,8), (1,5); +CREATE TABLE it1 ( +int_nokey int(11) NOT NULL, +int_key int(11) NOT NULL, +KEY int_key (int_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO it1 VALUES +(9,5), (0,4); +SELECT int_key FROM ot1 +WHERE int_nokey IN (SELECT it2.int_key +FROM it1 LEFT JOIN it2 ON it2.datetime_key); +int_key +0 +0 +0 +0 +0 +0 +2 +2 +3 +5 +5 +7 +7 +7 +8 +9 +9 +EXPLAIN +SELECT int_key FROM ot1 +WHERE int_nokey IN (SELECT it2.int_key +FROM it1 LEFT JOIN it2 ON it2.datetime_key); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE it1 NULL index NULL int_key 4 NULL 2 100.00 Using index; Start temporary +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 20 100.00 Using join buffer (hash join) +1 SIMPLE it2 NULL ref int_key int_key 4 test.ot1.int_nokey 2 90.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`int_key` AS `int_key` from `test`.`ot1` semi join (`test`.`it1` join `test`.`it2`) where ((`test`.`it2`.`int_key` = `test`.`ot1`.`int_nokey`) and (TIMESTAMP'0000-00-00 00:00:00' <> `test`.`it2`.`datetime_key`)) +DROP TABLE ot1, it1, it2; +# End of BUG#38075 +# +# BUG#50089: Second call of procedure with view in subselect crashes server +# +CREATE TABLE t1(t1field INTEGER, PRIMARY KEY(t1field)); +CREATE VIEW v1 AS +SELECT t1field AS v1field +FROM t1 a +WHERE a.t1field IN (SELECT t1field FROM t1); +INSERT INTO t1 VALUES(1),(2); +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT v1field FROM v1); +t1field +1 +2 +EXPLAIN +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT v1field FROM v1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index PRIMARY PRIMARY 4 NULL 2 100.00 Using index +1 SIMPLE a NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `t1`.`t1field` AS `t1field` from `test`.`t1` `a` join `test`.`t1` join `test`.`t1` where ((`test`.`a`.`t1field` = `t1`.`t1field`) and (`test`.`t1`.`t1field` = `t1`.`t1field`)) +SELECT t1.t1field +FROM t1 LEFT JOIN t1 AS t2 ON t1.t1field IN (SELECT v1field FROM v1); +t1field +1 +1 +2 +2 +EXPLAIN +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT v1field FROM v1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index PRIMARY PRIMARY 4 NULL 2 100.00 Using index +1 SIMPLE a NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `t1`.`t1field` AS `t1field` from `test`.`t1` `a` join `test`.`t1` join `test`.`t1` where ((`test`.`a`.`t1field` = `t1`.`t1field`) and (`test`.`t1`.`t1field` = `t1`.`t1field`)) +CREATE PROCEDURE p1() +BEGIN +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT v1field FROM v1); +END| +CALL p1; +t1field +1 +2 +CALL p1; +t1field +1 +2 +PREPARE stmt FROM +" +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT v1field FROM v1); +"; +EXECUTE stmt; +t1field +1 +2 + +EXECUTE stmt; +t1field +1 +2 +DROP PROCEDURE p1; +DROP VIEW v1; +DROP TABLE t1; +# End of BUG#50089 +# +# Bug#45191: Incorrectly initialized semi-join led to a wrong result. +# +CREATE TABLE staff (EMPNUM CHAR(3) NOT NULL, +EMPNAME CHAR(20), GRADE DECIMAL(4), CITY CHAR(15)) charset latin1; +CREATE TABLE proj (PNUM CHAR(3) NOT NULL, +PNAME CHAR(20), PTYPE CHAR(6), +BUDGET DECIMAL(9), +CITY CHAR(15)) charset latin1; +CREATE TABLE works (EMPNUM CHAR(3) NOT NULL, +PNUM CHAR(3) NOT NULL, HOURS DECIMAL(5)) charset latin1; +INSERT INTO staff VALUES ('E1','Alice',12,'Deale'); +INSERT INTO staff VALUES ('E2','Betty',10,'Vienna'); +INSERT INTO staff VALUES ('E3','Carmen',13,'Vienna'); +INSERT INTO staff VALUES ('E4','Don',12,'Deale'); +INSERT INTO staff VALUES ('E5','Ed',13,'Akron'); +INSERT INTO proj VALUES ('P1','MXSS','Design',10000,'Deale'); +INSERT INTO proj VALUES ('P2','CALM','Code',30000,'Vienna'); +INSERT INTO proj VALUES ('P3','SDP','Test',30000,'Tampa'); +INSERT INTO proj VALUES ('P4','SDP','Design',20000,'Deale'); +INSERT INTO proj VALUES ('P5','IRM','Test',10000,'Vienna'); +INSERT INTO proj VALUES ('P6','PAYR','Design',50000,'Deale'); +INSERT INTO works VALUES ('E1','P1',40); +INSERT INTO works VALUES ('E1','P2',20); +INSERT INTO works VALUES ('E1','P3',80); +INSERT INTO works VALUES ('E1','P4',20); +INSERT INTO works VALUES ('E1','P5',12); +INSERT INTO works VALUES ('E1','P6',12); +INSERT INTO works VALUES ('E2','P1',40); +INSERT INTO works VALUES ('E2','P2',80); +INSERT INTO works VALUES ('E3','P2',20); +INSERT INTO works VALUES ('E4','P2',20); +INSERT INTO works VALUES ('E4','P4',40); +INSERT INTO works VALUES ('E4','P5',80); +explain SELECT EMPNUM, EMPNAME +FROM staff +WHERE EMPNUM IN +(SELECT EMPNUM FROM works +WHERE PNUM IN +(SELECT PNUM FROM proj)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE staff NULL ALL NULL NULL NULL NULL 5 100.00 NULL +1 SIMPLE NULL eq_ref 3 test.staff.EMPNUM 1 100.00 NULL +2 MATERIALIZED proj NULL ALL NULL NULL NULL NULL 6 100.00 NULL +2 MATERIALIZED works NULL ALL NULL NULL NULL NULL 12 10.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`staff`.`EMPNUM` AS `EMPNUM`,`test`.`staff`.`EMPNAME` AS `EMPNAME` from `test`.`staff` semi join (`test`.`works` join `test`.`proj`) where ((``.`EMPNUM` = `test`.`staff`.`EMPNUM`) and (`test`.`works`.`PNUM` = `test`.`proj`.`PNUM`)) +SELECT EMPNUM, EMPNAME +FROM staff +WHERE EMPNUM IN +(SELECT EMPNUM FROM works +WHERE PNUM IN +(SELECT PNUM FROM proj)); +EMPNUM EMPNAME +E1 Alice +E2 Betty +E3 Carmen +E4 Don +drop table staff,works,proj; +# End of bug#45191 +# +# BUG#36896: Server crash on SELECT FROM DUAL +# +create table t1 (a int); +select 1 as res from dual where (1) in (select * from t1); +res +drop table t1; + +BUG#40118 Crash when running Batched Key Access and requiring one match for each key + +create table t0(a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (a int, key(a)); +insert into t1 select * from t0; +alter table t1 add b int not null, add filler char(200); +insert into t1 select * from t1; +insert into t1 select * from t1; +select * from t0 where t0.a in (select t1.a from t1 where t1.b=0); +a +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +drop table t0, t1; +# +# BUG#32665 Query with dependent subquery is too slow +# +create table t1 ( +idIndividual int primary key +); +insert into t1 values (1),(2); +create table t2 ( +idContact int primary key, +contactType int, +idObj int +); +insert into t2 values (1,1,1),(2,2,2),(3,3,3); +create table t3 ( +idAddress int primary key, +idContact int, +postalStripped varchar(100) +); +insert into t3 values (1,1, 'foo'), (2,2,'bar'); +The following must be converted to a semi-join: +explain SELECT a.idIndividual FROM t1 a +WHERE a.idIndividual IN +( SELECT c.idObj FROM t3 cona +INNER JOIN t2 c ON c.idContact=cona.idContact +WHERE cona.postalStripped='T2H3B2' + ); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE a NULL index PRIMARY PRIMARY 4 NULL 2 100.00 Using index +1 SIMPLE cona NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE c NULL eq_ref PRIMARY PRIMARY 4 test.cona.idContact 1 33.33 Using where; FirstMatch(a) +Warnings: +Note 1003 /* select#1 */ select `test`.`a`.`idIndividual` AS `idIndividual` from `test`.`t1` `a` semi join (`test`.`t3` `cona` join `test`.`t2` `c`) where ((`test`.`c`.`idContact` = `test`.`cona`.`idContact`) and (`test`.`c`.`idObj` = `test`.`a`.`idIndividual`) and (`test`.`cona`.`postalStripped` = 'T2H3B2')) +drop table t1,t2,t3; +CREATE TABLE t1 (one int, two int, flag char(1)); +CREATE TABLE t2 (one int, two int, flag char(1)); +INSERT INTO t1 VALUES(1,2,'Y'),(2,3,'Y'),(3,4,'Y'),(5,6,'N'),(7,8,'N'); +INSERT INTO t2 VALUES(1,2,'Y'),(2,3,'Y'),(3,4,'Y'),(5,6,'N'),(7,8,'N'); +SELECT * FROM t1 +WHERE ROW(one,two) IN (SELECT DISTINCT one,two FROM t2 WHERE flag = 'N'); +one two flag +5 6 N +7 8 N +SELECT * FROM t1 +WHERE ROW(one,two) IN (SELECT DISTINCT one,two FROM t1 WHERE flag = 'N'); +one two flag +5 6 N +7 8 N +insert into t2 values (null,null,'N'); +insert into t2 values (null,3,'0'); +insert into t2 values (null,5,'0'); +insert into t2 values (10,null,'0'); +insert into t1 values (10,3,'0'); +insert into t1 values (10,5,'0'); +insert into t1 values (10,10,'0'); +SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = 'N') as 'test' from t1; +one two test +1 2 NULL +2 3 NULL +3 4 NULL +5 6 1 +7 8 1 +10 3 NULL +10 5 NULL +10 10 NULL +SELECT one,two from t1 where ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = 'N'); +one two +5 6 +7 8 +SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = 'N' group by one,two) as 'test' from t1; +one two test +1 2 NULL +2 3 NULL +3 4 NULL +5 6 1 +7 8 1 +10 3 NULL +10 5 NULL +10 10 NULL +SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = '0') as 'test' from t1; +one two test +1 2 0 +2 3 NULL +3 4 0 +5 6 0 +7 8 0 +10 3 NULL +10 5 NULL +10 10 NULL +SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = '0' group by one,two) as 'test' from t1; +one two test +1 2 0 +2 3 NULL +3 4 0 +5 6 0 +7 8 0 +10 3 NULL +10 5 NULL +10 10 NULL +explain SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = '0') as 'test' from t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 9 11.11 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`one` AS `one`,`test`.`t1`.`two` AS `two`,((`test`.`t1`.`one`,`test`.`t1`.`two`),(/* select#2 */ select `test`.`t2`.`one`,`test`.`t2`.`two` from `test`.`t2` where ((`test`.`t2`.`flag` = '0') and (outer_field_is_not_null, (((`test`.`t1`.`one`) = `test`.`t2`.`one`) or (`test`.`t2`.`one` is null)), true) and (outer_field_is_not_null, (((`test`.`t1`.`two`) = `test`.`t2`.`two`) or (`test`.`t2`.`two` is null)), true)) having ((outer_field_is_not_null, (`test`.`t2`.`one`), true) and (outer_field_is_not_null, (`test`.`t2`.`two`), true)))) AS `test` from `test`.`t1` +explain SELECT one,two from t1 where ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = 'N'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 9 11.11 Using where; FirstMatch(t1); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`one` AS `one`,`test`.`t1`.`two` AS `two` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`two` = `test`.`t1`.`two`) and (`test`.`t2`.`one` = `test`.`t1`.`one`) and (`test`.`t2`.`flag` = 'N')) +explain SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = '0' group by one,two) as 'test' from t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 9 11.11 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`one` AS `one`,`test`.`t1`.`two` AS `two`,((`test`.`t1`.`one`,`test`.`t1`.`two`),(/* select#2 */ select `test`.`t2`.`one`,`test`.`t2`.`two` from `test`.`t2` where ((`test`.`t2`.`flag` = '0') and (outer_field_is_not_null, (((`test`.`t1`.`one`) = `test`.`t2`.`one`) or (`test`.`t2`.`one` is null)), true) and (outer_field_is_not_null, (((`test`.`t1`.`two`) = `test`.`t2`.`two`) or (`test`.`t2`.`two` is null)), true)) having ((outer_field_is_not_null, (`test`.`t2`.`one`), true) and (outer_field_is_not_null, (`test`.`t2`.`two`), true)))) AS `test` from `test`.`t1` +DROP TABLE t1,t2; +CREATE TABLE t1 (a char(5), b char(5)); +INSERT INTO t1 VALUES (NULL,'aaa'), ('aaa','aaa'); +SELECT * FROM t1 WHERE (a,b) IN (('aaa','aaa'), ('aaa','bbb')); +a b +aaa aaa +DROP TABLE t1; +CREATE TABLE t1 (a CHAR(1), b VARCHAR(10)) charset utf8mb4; +INSERT INTO t1 VALUES ('a', 'aa'); +INSERT INTO t1 VALUES ('a', 'aaa'); +SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1); +a b +CREATE INDEX I1 ON t1 (a); +CREATE INDEX I2 ON t1 (b); +EXPLAIN SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index I1 I1 5 NULL 2 100.00 Using index; LooseScan +1 SIMPLE t1 NULL ALL I2 NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t1`) where (`test`.`t1`.`b` = `test`.`t1`.`a`) +SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1); +a b +CREATE TABLE t2 (a VARCHAR(1), b VARCHAR(10)) charset utf8mb4; +INSERT INTO t2 SELECT * FROM t1; +CREATE INDEX I1 ON t2 (a); +CREATE INDEX I2 ON t2 (b); +EXPLAIN SELECT a,b FROM t2 WHERE b IN (SELECT a FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index I1 I1 7 NULL 2 100.00 Using index; LooseScan +1 SIMPLE t2 NULL ALL I2 NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t2` semi join (`test`.`t2`) where (`test`.`t2`.`b` = `test`.`t2`.`a`) +SELECT a,b FROM t2 WHERE b IN (SELECT a FROM t2); +a b +EXPLAIN +SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1 WHERE LENGTH(a)<500); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index I1 I1 5 NULL 2 100.00 Using where; Using index; LooseScan +1 SIMPLE t1 NULL ALL I2 NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t1`) where ((length(`test`.`t1`.`a`) < 500) and (`test`.`t1`.`b` = `test`.`t1`.`a`)) +SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1 WHERE LENGTH(a)<500); +a b +DROP TABLE t1,t2; +# +# BUG#45928 "Differing query results depending on MRR and +# engine_condition_pushdown settings" +# +CREATE TABLE `t1` ( +`pk` int(11) NOT NULL AUTO_INCREMENT, +`time_nokey` time NOT NULL, +`varchar_key` varchar(1) NOT NULL, +`varchar_nokey` varchar(1) NOT NULL, +PRIMARY KEY (`pk`), +KEY `varchar_key` (`varchar_key`) +) AUTO_INCREMENT=12 DEFAULT CHARSET=latin1; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO `t1` VALUES (10,'00:00:00','i','i'),(11,'00:00:00','',''); +SELECT `time_nokey` G1 FROM t1 WHERE ( `varchar_nokey` , `varchar_key` ) IN ( +SELECT `varchar_nokey` , `varchar_nokey` ) AND `varchar_key` >= 'c' HAVING G1 ORDER +BY `pk` ; +G1 +DROP TABLE t1; +# +# BUG#45863 "Assertion failed: (fixed == 0), function fix_fields(), +# file item.cc, line 4448" +# +DROP TABLE IF EXISTS C, BB; +CREATE TABLE C ( +varchar_nokey varchar(1) NOT NULL +); +INSERT INTO C VALUES +('k'),('a'),(''),('u'),('e'),('v'),('i'), +('t'),('u'),('f'),('u'),('m'),('j'),('f'), +('v'),('j'),('g'),('e'),('h'),('z'); +CREATE TABLE BB ( +varchar_nokey varchar(1) NOT NULL +); +INSERT INTO BB VALUES ('i'),('t'); +SELECT varchar_nokey FROM C +WHERE (varchar_nokey, OUTR) IN (SELECT varchar_nokey +FROM BB); +ERROR 42S22: Unknown column 'OUTR' in 'IN/ALL/ANY subquery' +SELECT varchar_nokey FROM C +WHERE (varchar_nokey, OUTR) IN (SELECT varchar_nokey, varchar_nokey +FROM BB); +ERROR 42S22: Unknown column 'OUTR' in 'IN/ALL/ANY subquery' +DROP TABLE C,BB; +# +# During work with BUG#45863 I had problems with a query that was +# optimized differently in regular and prepared mode. +# Because there was a bug in one of the selected strategies, I became +# aware of the problem. Adding an EXPLAIN query to catch this. +DROP TABLE IF EXISTS t1, t2, t3; +CREATE TABLE t1 +(EMPNUM CHAR(3) NOT NULL, +EMPNAME CHAR(20), +GRADE DECIMAL(4), +CITY CHAR(15)) charset latin1; +CREATE TABLE t2 +(PNUM CHAR(3) NOT NULL, +PNAME CHAR(20), +PTYPE CHAR(6), +BUDGET DECIMAL(9), +CITY CHAR(15)) charset latin1; +CREATE TABLE t3 +(EMPNUM CHAR(3) NOT NULL, +PNUM CHAR(3) NOT NULL, +HOURS DECIMAL(5)) charset latin1; +INSERT INTO t1 VALUES ('E1','Alice',12,'Deale'); +INSERT INTO t1 VALUES ('E2','Betty',10,'Vienna'); +INSERT INTO t1 VALUES ('E3','Carmen',13,'Vienna'); +INSERT INTO t1 VALUES ('E4','Don',12,'Deale'); +INSERT INTO t1 VALUES ('E5','Ed',13,'Akron'); +INSERT INTO t2 VALUES ('P1','MXSS','Design',10000,'Deale'); +INSERT INTO t2 VALUES ('P2','CALM','Code',30000,'Vienna'); +INSERT INTO t2 VALUES ('P3','SDP','Test',30000,'Tampa'); +INSERT INTO t2 VALUES ('P4','SDP','Design',20000,'Deale'); +INSERT INTO t2 VALUES ('P5','IRM','Test',10000,'Vienna'); +INSERT INTO t2 VALUES ('P6','PAYR','Design',50000,'Deale'); +INSERT INTO t3 VALUES ('E1','P1',40); +INSERT INTO t3 VALUES ('E1','P2',20); +INSERT INTO t3 VALUES ('E1','P3',80); +INSERT INTO t3 VALUES ('E1','P4',20); +INSERT INTO t3 VALUES ('E1','P5',12); +INSERT INTO t3 VALUES ('E1','P6',12); +INSERT INTO t3 VALUES ('E2','P1',40); +INSERT INTO t3 VALUES ('E2','P2',80); +INSERT INTO t3 VALUES ('E3','P2',20); +INSERT INTO t3 VALUES ('E4','P2',20); +INSERT INTO t3 VALUES ('E4','P4',40); +INSERT INTO t3 VALUES ('E4','P5',80); +CREATE UNIQUE INDEX t1_IDX ON t1(EMPNUM); +EXPLAIN SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN +(SELECT EMPNUM +FROM t3 +WHERE PNUM IN +(SELECT PNUM +FROM t2 +WHERE PTYPE = 'Design')); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL eq_ref t1_IDX t1_IDX 3 .EMPNUM 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = ``.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) +PREPARE stmt FROM "EXPLAIN SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN + (SELECT EMPNUM + FROM t3 + WHERE PNUM IN + (SELECT PNUM + FROM t2 + WHERE PTYPE = 'Design'))"; +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL eq_ref t1_IDX t1_IDX 3 .EMPNUM 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = ``.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) + +This line is only in place to help --skip_if_hypergraph diffing some more. + +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL eq_ref t1_IDX t1_IDX 3 .EMPNUM 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = ``.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) +DEALLOCATE PREPARE stmt; +DROP INDEX t1_IDX ON t1; +CREATE INDEX t1_IDX ON t1(EMPNUM); +EXPLAIN SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN +(SELECT EMPNUM +FROM t3 +WHERE PNUM IN +(SELECT PNUM +FROM t2 +WHERE PTYPE = 'Design')); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ref t1_IDX t1_IDX 3 .EMPNUM 2 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = ``.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) +PREPARE stmt FROM "EXPLAIN SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN + (SELECT EMPNUM + FROM t3 + WHERE PNUM IN + (SELECT PNUM + FROM t2 + WHERE PTYPE = 'Design'))"; +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ref t1_IDX t1_IDX 3 .EMPNUM 2 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = ``.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) + +This line is only in place to help --skip_if_hypergraph diffing some more. + +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ref t1_IDX t1_IDX 3 .EMPNUM 2 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = ``.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) +DEALLOCATE PREPARE stmt; +DROP INDEX t1_IDX ON t1; +EXPLAIN SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN +(SELECT EMPNUM +FROM t3 +WHERE PNUM IN +(SELECT PNUM +FROM t2 +WHERE PTYPE = 'Design')); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 20.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = `test`.`t3`.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) +PREPARE stmt FROM "EXPLAIN SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN + (SELECT EMPNUM + FROM t3 + WHERE PNUM IN + (SELECT PNUM + FROM t2 + WHERE PTYPE = 'Design'))"; +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 20.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = `test`.`t3`.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) + +This line is only in place to help --skip_if_hypergraph diffing some more. + +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 20.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = `test`.`t3`.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) +DEALLOCATE PREPARE stmt; +DROP TABLE t1, t2, t3; +# +# BUG#45221 Query SELECT pk FROM C WHERE pk IN (SELECT int_key) failing +# +CREATE TABLE t1 ( +i1_key INT, +i2 INT, +i3 INT, +KEY i1_index (i1_key) +); +INSERT INTO t1 VALUES (9,1,2), (9,2,1); +CREATE TABLE t2 ( +pk INT NOT NULL, +i1 INT, +PRIMARY KEY (pk) +); +INSERT INTO t2 VALUES (9,1); +SELECT pk +FROM t2 +WHERE +pk IN ( +SELECT i1_key +FROM t1 +WHERE t1.i2 < t1.i3 XOR t2.i1 > 1 +ORDER BY t1.i2 desc); +pk +9 +DROP TABLE t1,t2; +# BUG#50361 Doublenested noncorrelated subquery with FirstMatch and join cache wrong result +# +CREATE TABLE t1( +id INTEGER +); +INSERT INTO t1 VALUES(10),(20); +create table t2 select * from t1; +create table t3 select * from t1; +SELECT * +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t2 +WHERE 1 IN(SELECT 1 +FROM t3)); +id +10 +20 +explain SELECT * +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t2 +WHERE 1 IN(SELECT 1 +FROM t3)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE NULL const 4 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where true +delete from t2; +delete from t3; +INSERT INTO t1 VALUES(30),(40),(50),(60),(70),(80),(90); +insert into t2 select * from t1; +insert into t3 select * from t1; +create table t4 select * from t1; +SELECT * +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t2 +WHERE 1 IN(SELECT 1 +FROM t3 +WHERE 1 IN(SELECT 1 +FROM t4))); +id +10 +20 +30 +40 +50 +60 +70 +80 +90 +explain SELECT * +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t2 +WHERE 1 IN(SELECT 1 +FROM t3 +WHERE 1 IN(SELECT 1 +FROM t4))); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 9 100.00 NULL +1 SIMPLE NULL const 4 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 9 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 9 100.00 Using join buffer (hash join) +2 MATERIALIZED t4 NULL ALL NULL NULL NULL NULL 9 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3` join `test`.`t4`) where true +SELECT * +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t1))); +id +10 +20 +30 +40 +50 +60 +70 +80 +90 +drop table t1,t2,t3,t4; +# +# Bug#53236 Segfault in DTCollation::set(DTCollation&) +# +CREATE TABLE t1 ( +pk INTEGER AUTO_INCREMENT, +col_varchar VARCHAR(1), +PRIMARY KEY (pk) +) +; +INSERT INTO t1 (col_varchar) +VALUES +('w'), +('m') +; +SELECT table1.pk +FROM ( t1 AS table1 JOIN t1 AS table2 ON (table1.col_varchar = +table2.col_varchar) ) +WHERE ( 1, 2 ) IN ( SELECT SUBQUERY1_t1.pk AS SUBQUERY1_field1, +SUBQUERY1_t1.pk AS SUBQUERY1_field2 +FROM ( t1 AS SUBQUERY1_t1 JOIN t1 AS SUBQUERY1_t2 +ON (SUBQUERY1_t2.col_varchar = +SUBQUERY1_t1.col_varchar) ) ) +; +pk +drop table t1; +# +# BUG#53298 "wrong result with semijoin (no semijoin strategy chosen)" +# +create table t1 (uid int, fid int); +insert into t1 values (1,1), (3,1); +create table t2 (uid int, name varchar(128)); +insert into t2 values (1, "A"), (2, "B"); +create table t3 (uid int, fid int, index(uid)); +insert into t3 values (1,3), (1,3); +create table t4 (uid int); +insert into t4 values (3); +explain select t2.uid from t2, t1 +where t1.uid in (select t4.uid from t4, t3 where t3.uid=1 and t4.uid=t3.fid) +and t2.uid=t1.fid; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 0.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t4 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 MATERIALIZED t3 NULL ref uid uid 5 const 1 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`uid` AS `uid` from `test`.`t2` join `test`.`t1` semi join (`test`.`t4` join `test`.`t3`) where ((`test`.`t1`.`uid` = ``.`uid`) and (`test`.`t3`.`fid` = `test`.`t4`.`uid`) and (`test`.`t3`.`uid` = 1) and (`test`.`t1`.`fid` = `test`.`t2`.`uid`)) +select t2.uid from t2, t1 +where t1.uid in (select t4.uid from t4, t3 where t3.uid=1 and t4.uid=t3.fid) +and t2.uid=t1.fid; +uid +1 +drop table t1,t2,t3,t4; +CREATE TABLE t1 ( +pk int, +a varchar(1), +b varchar(4), +c varchar(4), +d varchar(4), +PRIMARY KEY (pk) +) charset utf8mb4; +INSERT INTO t1 VALUES (1,'o','ffff','ffff','ffoo'),(2,'f','ffff','ffff','ffff'); +CREATE TABLE t2 LIKE t1; +INSERT INTO t2 VALUES (1,'i','iiii','iiii','iiii'),(2,'f','ffff','ffff','ffff'); +EXPLAIN SELECT pk FROM t1 WHERE (a) IN (SELECT a FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using index condition; Using where; Using MRR; FirstMatch(t1); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`a` = `test`.`t1`.`a`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (a) IN (SELECT a FROM t2 WHERE pk > 0); +pk +2 +SELECT pk FROM t1 WHERE (b,c,d) IN (SELECT b,c,d FROM t2 WHERE pk > 0); +pk +2 +DROP TABLE t1, t2; +CREATE TABLE t1 (f1 INT, f2 DECIMAL(5,3)) ENGINE=MyISAM; +INSERT INTO t1 (f1, f2) VALUES (1, 1.789); +INSERT INTO t1 (f1, f2) VALUES (13, 1.454); +INSERT INTO t1 (f1, f2) VALUES (10, 1.668); +CREATE TABLE t2 LIKE t1; +INSERT INTO t2 VALUES (1, 1.789); +INSERT INTO t2 VALUES (13, 1.454); +EXPLAIN SELECT COUNT(*) FROM t1 WHERE (f1,f2) IN (SELECT f1,f2 FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`f2` = `test`.`t2`.`f2`) and (`test`.`t1`.`f1` = `test`.`t2`.`f1`)) +SELECT COUNT(*) FROM t1 WHERE (f1,f2) IN (SELECT f1,f2 FROM t2); +COUNT(*) +2 +DROP TABLE t1, t2; +CREATE TABLE t1 ( +ID int(11) NOT NULL auto_increment, +Name char(35) NOT NULL default '', +Country char(3) NOT NULL default '', +Population int(11) NOT NULL default '0', +PRIMARY KEY (ID), +INDEX (Population), +INDEX (Country) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t2 ( +Code char(3) NOT NULL default '', +Name char(52) NOT NULL default '', +SurfaceArea float(10,2) NOT NULL default '0.00', +Population int(11) NOT NULL default '0', +Capital int(11) default NULL, +PRIMARY KEY (Code), +UNIQUE INDEX (Name), +INDEX (Population) +) charset utf8mb4; +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t3 ( +Country char(3) NOT NULL default '', +Language char(30) NOT NULL default '', +Percentage float(3,1) NOT NULL default '0.0', +PRIMARY KEY (Country, Language), +INDEX (Percentage) +) charset utf8mb4; +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +EXPLAIN SELECT Name FROM t2 +WHERE t2.Code IN (SELECT Country FROM t1 WHERE Population > 5000000) +AND +t2.Code IN (SELECT Country FROM t3 +WHERE Language='English' AND Percentage > 10 AND +t2.Population > 100000); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range Population,Country Population 4 NULL 1 100.00 Using index condition; Using MRR; Start temporary +1 SIMPLE t2 NULL eq_ref PRIMARY,Population PRIMARY 12 test.t1.Country 1 75.00 Using where +1 SIMPLE t3 NULL eq_ref PRIMARY,Percentage PRIMARY 132 test.t1.Country,const 1 95.45 Using index condition; Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t2.Population' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t2`.`Name` AS `Name` from `test`.`t3` join `test`.`t2` semi join (`test`.`t1`) where ((`test`.`t2`.`Code` = `test`.`t1`.`Country`) and (`test`.`t3`.`Country` = `test`.`t1`.`Country`) and (`test`.`t3`.`Language` = 'English') and (`test`.`t3`.`Percentage` > 10) and (`test`.`t2`.`Population` > 100000) and (`test`.`t1`.`Population` > 5000000)) +EXPLAIN FORMAT=JSON SELECT Name FROM t2 +WHERE t2.Code IN (SELECT Country FROM t1 WHERE Population > 5000000) +AND +t2.Code IN (SELECT Country FROM t3 +WHERE Language='English' AND Percentage > 10 AND +t2.Population > 100000); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "2.45" + }, + "duplicates_removal": { + "using_temporary_table": true, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "range", + "possible_keys": [ + "Population", + "Country" + ], + "key": "Population", + "used_key_parts": [ + "Population" + ], + "key_length": "4", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "index_condition": "(`test`.`t1`.`Population` > 5000000)", + "using_MRR": true, + "cost_info": { + "read_cost": "0.60", + "eval_cost": "0.10", + "prefix_cost": "0.70", + "data_read_per_join": "168" + }, + "used_columns": [ + "Country", + "Population" + ] + } + }, + { + "table": { + "table_name": "t2", + "access_type": "eq_ref", + "possible_keys": [ + "PRIMARY", + "Population" + ], + "key": "PRIMARY", + "used_key_parts": [ + "Code" + ], + "key_length": "12", + "ref": [ + "test.t1.Country" + ], + "rows_examined_per_scan": 1, + "rows_produced_per_join": 0, + "filtered": "75.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.08", + "prefix_cost": "2.20", + "data_read_per_join": "180" + }, + "used_columns": [ + "Code", + "Name", + "Population" + ], + "attached_condition": "(`test`.`t2`.`Population` > 100000)" + } + }, + { + "table": { + "table_name": "t3", + "access_type": "eq_ref", + "possible_keys": [ + "PRIMARY", + "Percentage" + ], + "key": "PRIMARY", + "used_key_parts": [ + "Country", + "Language" + ], + "key_length": "132", + "ref": [ + "test.t1.Country", + "const" + ], + "rows_examined_per_scan": 1, + "rows_produced_per_join": 0, + "filtered": "95.45", + "index_condition": "(`test`.`t3`.`Language` = 'English')", + "cost_info": { + "read_cost": "0.19", + "eval_cost": "0.07", + "prefix_cost": "2.46", + "data_read_per_join": "103" + }, + "used_columns": [ + "Country", + "Language", + "Percentage" + ], + "attached_condition": "(`test`.`t3`.`Percentage` > 10)" + } + } + ] + } + } +} +Warnings: +Note 1276 Field or reference 'test.t2.Population' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t2`.`Name` AS `Name` from `test`.`t3` join `test`.`t2` semi join (`test`.`t1`) where ((`test`.`t2`.`Code` = `test`.`t1`.`Country`) and (`test`.`t3`.`Country` = `test`.`t1`.`Country`) and (`test`.`t3`.`Language` = 'English') and (`test`.`t3`.`Percentage` > 10) and (`test`.`t2`.`Population` > 100000) and (`test`.`t1`.`Population` > 5000000)) +DROP TABLE t1,t2,t3; +CREATE TABLE t1 ( +Code char(3) NOT NULL DEFAULT '', +Name char(52) NOT NULL DEFAULT '', +Continent enum('Asia','Europe','North America','Africa','Oceania','Antarctica','South America') NOT NULL DEFAULT 'Asia', +Region char(26) NOT NULL DEFAULT '', +SurfaceArea float(10,2) NOT NULL DEFAULT '0.00', +IndepYear smallint(6) DEFAULT NULL, +Population int(11) NOT NULL DEFAULT '0', +LifeExpectancy float(3,1) DEFAULT NULL, +GNP float(10,2) DEFAULT NULL, +GNPOld float(10,2) DEFAULT NULL, +LocalName char(45) NOT NULL DEFAULT '', +GovernmentForm char(45) NOT NULL DEFAULT '', +HeadOfState char(60) DEFAULT NULL, +Capital int(11) DEFAULT NULL, +Code2 char(2) NOT NULL DEFAULT '', +PRIMARY KEY (Code) +) charset utf8mb4; +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t2 ( +ID int(11) NOT NULL AUTO_INCREMENT, +Name char(35) NOT NULL DEFAULT '', +CountryCode char(3) NOT NULL DEFAULT '', +District char(20) NOT NULL DEFAULT '', +Population int(11) NOT NULL DEFAULT '0', +PRIMARY KEY (ID), +KEY CountryCode (CountryCode) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +set names latin1; +Fill the table with test data +This must not use LooseScan: +EXPLAIN SELECT Name FROM t1 +WHERE t1.Code IN ( +SELECT t2.CountryCode FROM t2 WHERE Population > 5000000); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL PRIMARY NULL NULL NULL 31 100.00 NULL +1 SIMPLE NULL eq_ref 12 test.t1.Code 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL CountryCode NULL NULL NULL 545 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`Name` AS `Name` from `test`.`t1` semi join (`test`.`t2`) where ((``.`CountryCode` = `test`.`t1`.`Code`) and (`test`.`t2`.`Population` > 5000000)) +SELECT Name FROM t1 +WHERE t1.Code IN ( +SELECT t2.CountryCode FROM t2 WHERE Population > 5000000); +Name +Austria +Canada +China +Czech Republic +drop table t1, t2; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4); +create table t1 (a int, b int, key(a)); +insert into t1 select a,a from t0; +create table t2 (a int, b int, primary key(a)); +insert into t2 select * from t1; +Table t2, unlike table t1, should be displayed as pulled out +explain select * from t0 +where t0.a in ( select t1.a from t1,t2 where t2.a=t0.a and +t1.b=t2.b); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 5 100.00 Using where +1 SIMPLE t1 NULL ref a a 5 test.t0.a 1 100.00 Start temporary +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t0.a 1 20.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t0.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a` from `test`.`t2` join `test`.`t0` semi join (`test`.`t1`) where ((`test`.`t1`.`a` = `test`.`t0`.`a`) and (`test`.`t2`.`a` = `test`.`t0`.`a`) and (`test`.`t2`.`b` = `test`.`t1`.`b`)) +update t1 set a=3, b=11 where a=4; +update t2 set b=11 where a=3; +select * from t0 where t0.a in (select t1.a from t1, t2 where t2.a=t0.a and t1.b=t2.b); +a +0 +1 +2 +3 +drop table t0, t1, t2; +CREATE TABLE t1 ( +id int(11) NOT NULL, +PRIMARY KEY (id)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t2 ( +id int(11) NOT NULL, +fid int(11) NOT NULL, +PRIMARY KEY (id)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t1 values(1); +insert into t2 values(1,7503),(2,1); +explain select count(*) +from t1 +where fid IN (select fid from t2 where (id between 7502 and 8420) order by fid ); +ERROR 42S22: Unknown column 'fid' in 'IN/ALL/ANY subquery' +drop table t1, t2; +create table t1 (a int, b int, key (a), key (b)); +insert into t1 values (2,4),(2,4),(2,4); +select t1.a from t1 +where +t1.a in (select 1 from t1 where t1.a in (select 1 from t1) group by t1.a); +a +drop table t1; +create table t1(a int,b int,key(a),key(b)); +insert into t1 values (1,1),(2,2),(3,3); +select 1 from t1 +where t1.a not in (select 1 from t1 +where t1.a in (select 1 from t1) +group by t1.b); +1 +1 +1 +drop table t1; +CREATE TABLE t1 +(EMPNUM CHAR(3) NOT NULL, +EMPNAME CHAR(20), +GRADE DECIMAL(4), +CITY CHAR(15)); +CREATE TABLE t2 +(PNUM CHAR(3) NOT NULL, +PNAME CHAR(20), +PTYPE CHAR(6), +BUDGET DECIMAL(9), +CITY CHAR(15)); +CREATE TABLE t3 +(EMPNUM CHAR(3) NOT NULL, +PNUM CHAR(3) NOT NULL, +HOURS DECIMAL(5)); +INSERT INTO t1 VALUES ('E1','Alice',12,'Deale'); +INSERT INTO t1 VALUES ('E2','Betty',10,'Vienna'); +INSERT INTO t1 VALUES ('E3','Carmen',13,'Vienna'); +INSERT INTO t1 VALUES ('E4','Don',12,'Deale'); +INSERT INTO t1 VALUES ('E5','Ed',13,'Akron'); +INSERT INTO t2 VALUES ('P1','MXSS','Design',10000,'Deale'); +INSERT INTO t2 VALUES ('P2','CALM','Code',30000,'Vienna'); +INSERT INTO t2 VALUES ('P3','SDP','Test',30000,'Tampa'); +INSERT INTO t2 VALUES ('P4','SDP','Design',20000,'Deale'); +INSERT INTO t2 VALUES ('P5','IRM','Test',10000,'Vienna'); +INSERT INTO t2 VALUES ('P6','PAYR','Design',50000,'Deale'); +INSERT INTO t3 VALUES ('E1','P1',40); +INSERT INTO t3 VALUES ('E1','P2',20); +INSERT INTO t3 VALUES ('E1','P3',80); +INSERT INTO t3 VALUES ('E1','P4',20); +INSERT INTO t3 VALUES ('E1','P5',12); +INSERT INTO t3 VALUES ('E1','P6',12); +INSERT INTO t3 VALUES ('E2','P1',40); +INSERT INTO t3 VALUES ('E2','P2',80); +INSERT INTO t3 VALUES ('E3','P2',20); +INSERT INTO t3 VALUES ('E4','P2',20); +INSERT INTO t3 VALUES ('E4','P4',40); +INSERT INTO t3 VALUES ('E4','P5',80); +SELECT * FROM t1; +EMPNUM EMPNAME GRADE CITY +E1 Alice 12 Deale +E2 Betty 10 Vienna +E3 Carmen 13 Vienna +E4 Don 12 Deale +E5 Ed 13 Akron +CREATE UNIQUE INDEX t1_IDX ON t1(EMPNUM); +SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN +(SELECT EMPNUM +FROM t3 +WHERE PNUM IN +(SELECT PNUM +FROM t2 +WHERE PTYPE = 'Design')); +EMPNAME +Alice +Betty +Don +DROP INDEX t1_IDX ON t1; +CREATE INDEX t1_IDX ON t1(EMPNUM); +SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN +(SELECT EMPNUM +FROM t3 +WHERE PNUM IN +(SELECT PNUM +FROM t2 +WHERE PTYPE = 'Design')); +EMPNAME +Alice +Betty +Don +DROP INDEX t1_IDX ON t1; +SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN +(SELECT EMPNUM +FROM t3 +WHERE PNUM IN +(SELECT PNUM +FROM t2 +WHERE PTYPE = 'Design')); +EMPNAME +Alice +Betty +Don +DROP TABLE t1, t2, t3; +CREATE TABLE t1 (f1 INT NOT NULL); +CREATE VIEW v1 (a) AS SELECT f1 IN (SELECT f1 FROM t1) FROM t1; +SELECT * FROM v1; +a +drop view v1; +drop table t1; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1(a int, b int); +insert into t1 values (0,0),(1,1),(2,2); +create table t2 as select * from t1; +create table t3 (pk int, a int, primary key(pk)); +insert into t3 select a,a from t0; +explain +select * from t1 left join t2 on (t2.a= t1.a and t2.a in (select pk from t3)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE t3 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using index +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` left join (`test`.`t3` join `test`.`t2`) on(((`test`.`t3`.`pk` = `test`.`t1`.`a`) and (`test`.`t2`.`a` = `test`.`t1`.`a`))) where true +drop table t0, t1, t2, t3; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (a int) as select A.a + 10 *(B.a + 10*C.a) as a from t0 A, t0 B, t0 C; +create table t2 (id int, a int, primary key(id), key(a)) charset utf8mb4 as select a as id, a as a from t1; +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `id` int NOT NULL, + `a` int DEFAULT NULL, + PRIMARY KEY (`id`), + KEY `a` (`a`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +set @a=0; +create table t3 as select * from t2 limit 0; +insert into t3 select @a:=@a+1, t2.a from t2, t0; +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +insert into t3 select @a:=@a+1, t2.a from t2, t0; +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +insert into t3 select @a:=@a+1, t2.a from t2, t0; +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +alter table t3 add primary key(id), add 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); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index a a 5 NULL 1000 100.00 Using where; Using index +1 SIMPLE t3 NULL ref a a 5 test.t2.a 30 100.00 Using index; FirstMatch(t2) +Warnings: +Note 1003 /* select#1 */ select count(`test`.`t2`.`a`) AS `count(a)` from `test`.`t2` semi join (`test`.`t3`) where (`test`.`t3`.`a` = `test`.`t2`.`a`) +select count(a) from t2 where a in ( SELECT a FROM t3); +count(a) +1000 +drop table t0,t1,t2,t3; +# +# Bug#33062: subquery in stored routine cause crash +# +CREATE TABLE t1(a INT); +CREATE TABLE t2(c INT); +CREATE PROCEDURE p1(v1 int) +BEGIN +SELECT 1 FROM t1 WHERE a = v1 AND a IN (SELECT c FROM t2); +END +// +CREATE PROCEDURE p2(v1 int) +BEGIN +SELECT 1 FROM t1 WHERE a IN (SELECT c FROM t2); +END +// +CREATE PROCEDURE p3(v1 int) +BEGIN +SELECT 1 +FROM +t1 t01,t1 t02,t1 t03,t1 t04,t1 t05,t1 t06,t1 t07,t1 t08, +t1 t09,t1 t10,t1 t11,t1 t12,t1 t13,t1 t14,t1 t15,t1 t16, +t1 t17,t1 t18,t1 t19,t1 t20,t1 t21,t1 t22,t1 t23,t1 t24, +t1 t25,t1 t26,t1 t27,t1 t28,t1 t29,t1 t30,t1 t31,t1 t32, +t1 t33,t1 t34,t1 t35,t1 t36,t1 t37,t1 t38,t1 t39,t1 t40, +t1 t41,t1 t42,t1 t43,t1 t44,t1 t45,t1 t46,t1 t47,t1 t48, +t1 t49,t1 t50,t1 t51,t1 t52,t1 t53,t1 t54,t1 t55,t1 t56, +t1 t57,t1 t58,t1 t59,t1 t60 +WHERE t01.a IN (SELECT c FROM t2); +END +// +CREATE PROCEDURE p4(v1 int) +BEGIN +SELECT 1 +FROM +t1 t01,t1 t02,t1 t03,t1 t04,t1 t05,t1 t06,t1 t07,t1 t08, +t1 t09,t1 t10,t1 t11,t1 t12,t1 t13,t1 t14,t1 t15,t1 t16, +t1 t17,t1 t18,t1 t19,t1 t20,t1 t21,t1 t22,t1 t23,t1 t24, +t1 t25,t1 t26,t1 t27,t1 t28,t1 t29,t1 t30,t1 t31,t1 t32, +t1 t33,t1 t34,t1 t35,t1 t36,t1 t37,t1 t38,t1 t39,t1 t40, +t1 t41,t1 t42,t1 t43,t1 t44,t1 t45,t1 t46,t1 t47,t1 t48, +t1 t49,t1 t50,t1 t51,t1 t52,t1 t53,t1 t54,t1 t55,t1 t56, +t1 t57,t1 t58,t1 t59,t1 t60 +WHERE t01.a = v1 AND t01.a IN (SELECT c FROM t2); +END +// +CALL p1(1); +1 +CALL p2(1); +1 +CALL p3(1); +1 +CALL p4(1); +1 +DROP TABLE t1, t2; +DROP PROCEDURE p1; +DROP PROCEDURE p2; +DROP PROCEDURE p3; +DROP PROCEDURE p4; +# +# Bug#48213 Materialized subselect crashes if using GEOMETRY type +# +CREATE TABLE t1 ( +pk int, +a varchar(1), +b varchar(4), +c tinyblob, +d blob, +e mediumblob, +f longblob, +g tinytext, +h text, +i mediumtext, +j longtext, +k geometry, +PRIMARY KEY (pk) +) charset utf8mb4; +INSERT INTO t1 VALUES (1,'o','ffff','ffff','ffoo','ffff','ffff','ffff','ffff','ffff','ffff',ST_GeomFromText('POLYGON((0 0, 0 2, 2 2, 2 0, 0 0))')), (2,'f','ffff','ffff','ffff', 'ffff','ffff','ffff','ffff','ffff','ffff',ST_GeomFromText('POLYGON((0 0, 0 2, 2 2, 2 0, 0 0))')); +CREATE TABLE t2 LIKE t1; +INSERT INTO t2 VALUES (1,'i','iiii','iiii','iiii','iiii','ffff','ffff','ffff','ffff','ffff',ST_GeomFromText('POLYGON((0 0, 0 2, 2 2, 2 0, 0 0))')), (2,'f','ffff','ffff','ffff','ffff','ffff','ffff','ffff','ffff','ffff',ST_GeomFromText('POLYGON((0 0, 0 2, 2 2, 2 0, 0 0))')); +EXPLAIN SELECT pk FROM t1 WHERE (a, b) IN (SELECT a, b FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using index condition; Using where; Using MRR; FirstMatch(t1); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ 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); +pk +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, c) IN (SELECT b, c FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using index condition; Using where; Using MRR; FirstMatch(t1); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`c` = `test`.`t1`.`c`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, c) IN (SELECT b, c FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, d) IN (SELECT b, d FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using index condition; Using where; Using MRR; FirstMatch(t1); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`d` = `test`.`t1`.`d`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, d) IN (SELECT b, d FROM t2 WHERE pk > 0); +pk +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, e) IN (SELECT b, e FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using index condition; Using where; Using MRR; FirstMatch(t1); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`e` = `test`.`t1`.`e`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, e) IN (SELECT b, e FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, f) IN (SELECT b, f FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using index condition; Using where; Using MRR; FirstMatch(t1); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`f` = `test`.`t1`.`f`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, f) IN (SELECT b, f FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, g) IN (SELECT b, g FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using index condition; Using where; Using MRR; FirstMatch(t1); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`g` = `test`.`t1`.`g`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, g) IN (SELECT b, g FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, h) IN (SELECT b, h FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using index condition; Using where; Using MRR; FirstMatch(t1); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`h` = `test`.`t1`.`h`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, h) IN (SELECT b, h FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, i) IN (SELECT b, i FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using index condition; Using where; Using MRR; FirstMatch(t1); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`i` = `test`.`t1`.`i`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, i) IN (SELECT b, i FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, j) IN (SELECT b, j FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using index condition; Using where; Using MRR; FirstMatch(t1); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`j` = `test`.`t1`.`j`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, j) IN (SELECT b, j FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, k) IN (SELECT b, k FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using index condition; Using where; Using MRR; FirstMatch(t1); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`k` = `test`.`t1`.`k`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, k) IN (SELECT b, k FROM t2 WHERE pk > 0); +pk +1 +2 +DROP TABLE t1, t2; +# End of Bug#48213 +# +# BUG#53060: LooseScan semijoin strategy does not return all rows +# +CREATE TABLE t1 (i INTEGER); +INSERT INTO t1 VALUES (1), (2), (3), (4), (5); +CREATE TABLE t2 (i INTEGER, j INTEGER, KEY k(i, j)); +INSERT INTO t2 VALUES (1, 0), (1, 1), (2, 0), (2, 1); +EXPLAIN +SELECT * FROM t1 WHERE (i) IN (SELECT i FROM t2 where j > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index k k 10 NULL 4 33.33 Using where; Using index; LooseScan +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 20.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`i` = `test`.`t2`.`i`) and (`test`.`t2`.`j` > 0)) +SELECT * FROM t1 WHERE (i) IN (SELECT i FROM t2 where j > 0); +i +1 +2 +DROP TABLE t1, t2; +# End of BUG#53060 +# +# Bug#53305 "Duplicate weedout + join buffer (join cache --level=7,8) loses rows" +# +create table t1 (uid int, fid int, index(uid)); +insert into t1 values +(1,1), (1,2), (1,3), (1,4), +(2,5), (2,6), (2,7), (2,8), +(3,1), (3,2), (3,9); +create table t2 (uid int primary key, name varchar(128), index(name)); +insert into t2 values +(1, "A"), (2, "B"), (3, "C"), (4, "D"), (5, "E"), +(6, "F"), (7, "G"), (8, "H"), (9, "I"); +create table t3 (uid int, fid int, index(uid)); +insert into t3 values +(1,1), (1,2), (1,3),(1,4), +(2,5), (2,6), (2,7), (2,8), +(3,1), (3,2), (3,9); +create table t4 (uid int primary key, name varchar(128), index(name)); +insert into t4 values +(1, "A"), (2, "B"), (3, "C"), (4, "D"), (5, "E"), +(6, "F"), (7, "G"), (8, "H"), (9, "I"); +explain select name from t2, t1 +where t1.uid in (select t4.uid from t4, t3 where t3.uid=1 and t4.uid=t3.fid) +and t2.uid=t1.fid; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ref uid uid 5 const 4 100.00 Using where; Start temporary +1 SIMPLE t4 NULL eq_ref PRIMARY PRIMARY 4 test.t3.fid 1 100.00 Using index +1 SIMPLE t1 NULL ref uid uid 5 test.t3.fid 2 100.00 Using where +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.fid 1 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`name` AS `name` from `test`.`t4` join `test`.`t2` join `test`.`t1` semi join (`test`.`t3`) where ((`test`.`t4`.`uid` = `test`.`t3`.`fid`) and (`test`.`t1`.`uid` = `test`.`t3`.`fid`) and (`test`.`t3`.`uid` = 1) and (`test`.`t2`.`uid` = `test`.`t1`.`fid`)) +select name from t2, t1 +where t1.uid in (select t4.uid from t4, t3 where t3.uid=1 and t4.uid=t3.fid) +and t2.uid=t1.fid; +name +A +A +B +B +C +D +E +F +G +H +I +drop table t1,t2,t3,t4; +# +# Bug#43768 Prepared query with nested subqueries core dump on second execution +# +CREATE TABLE t1 ( +id INT PRIMARY KEY, +partner_id VARCHAR(35) +) charset utf8mb4; +INSERT INTO t1 VALUES +(1, 'partner1'), (2, 'partner2'), +(3, 'partner3'), (4, 'partner4'); +CREATE TABLE t2 ( +id INT NOT NULL, +t1_line_id INT, +article_id VARCHAR(20), +PRIMARY KEY(id, t1_line_id) +) charset utf8mb4; +INSERT INTO t2 VALUES +(1, 1, 'sup'), (2, 1, 'sup'), +(2, 2, 'sup'), (2, 3, 'sup'), +(2, 4, 'imp'), (3, 1, 'sup'), +(4, 1, 'sup'); +CREATE TABLE t3 ( +user_id VARCHAR(50), +article_id VARCHAR(20) NOT NULL, +PRIMARY KEY(user_id) +) charset utf8mb4; +INSERT INTO t3 VALUES('nicke', 'imp'); +EXPLAIN +SELECT t1.partner_id +FROM t1 +WHERE t1.id IN ( +SELECT t2.id +FROM t2 +WHERE article_id IN ( +SELECT article_id FROM t3 +WHERE user_id = 'nicke' + ) +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL system PRIMARY NULL NULL NULL 1 100.00 NULL +1 SIMPLE t1 NULL ALL PRIMARY NULL NULL NULL 4 100.00 NULL +1 SIMPLE t2 NULL ref PRIMARY PRIMARY 4 test.t1.id 1 14.29 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`partner_id` AS `partner_id` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`id` = `test`.`t1`.`id`) and (`test`.`t2`.`article_id` = 'imp')) +SELECT t1.partner_id +FROM t1 +WHERE t1.id IN ( +SELECT t2.id +FROM t2 +WHERE article_id IN ( +SELECT article_id FROM t3 +WHERE user_id = 'nicke' + ) +); +partner_id +partner2 +PREPARE stmt FROM +'EXPLAIN SELECT t1.partner_id +FROM t1 +WHERE t1.id IN ( + SELECT t2.id + FROM t2 + WHERE article_id IN ( + SELECT article_id FROM t3 + WHERE user_id = \'nicke\' + ) + )'; +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL system PRIMARY NULL NULL NULL 1 100.00 NULL +1 SIMPLE t1 NULL ALL PRIMARY NULL NULL NULL 4 100.00 NULL +1 SIMPLE t2 NULL ref PRIMARY PRIMARY 4 test.t1.id 1 14.29 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`partner_id` AS `partner_id` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`id` = `test`.`t1`.`id`) and (`test`.`t2`.`article_id` = 'imp')) + +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL system PRIMARY NULL NULL NULL 1 100.00 NULL +1 SIMPLE t1 NULL ALL PRIMARY NULL NULL NULL 4 100.00 NULL +1 SIMPLE t2 NULL ref PRIMARY PRIMARY 4 test.t1.id 1 14.29 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`partner_id` AS `partner_id` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`id` = `test`.`t1`.`id`) and (`test`.`t2`.`article_id` = 'imp')) +PREPARE stmt FROM +'SELECT t1.partner_id +FROM t1 +WHERE t1.id IN ( + SELECT t2.id + FROM t2 + WHERE article_id IN ( + SELECT article_id FROM t3 + WHERE user_id = \'nicke\' + ) + )'; +EXECUTE stmt; +partner_id +partner2 + +EXECUTE stmt; +partner_id +partner2 +DROP TABLE t1,t2,t3; +# End of Bug#43768 +# +# Bug#53058 - semijoin execution of subquery with outerjoin yields wrong result +# +CREATE TABLE t1 (i INTEGER); +CREATE TABLE t2 (i INTEGER); +CREATE TABLE t3 (i INTEGER); +INSERT INTO t1 VALUES (1), (2); +INSERT INTO t2 VALUES (6); +INSERT INTO t3 VALUES (1), (2); +explain SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t3 LEFT JOIN t2 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t3 LEFT JOIN t2 ON t2.i=t3.i); +i +1 +2 +drop table t1,t2,t3; +# +# BUG#49453: re-execution of prepared statement with view +# and semijoin crashes +# +CREATE TABLE t1 (city VARCHAR(50), country_id INT); +CREATE TABLE t2 (country_id INT, country VARCHAR(50)); +INSERT INTO t1 VALUES +('Batna',2),('Bchar',2),('Skikda',2),('Tafuna',3),('Algeria',2) ; +INSERT INTO t2 VALUES (2,'Algeria'),(2,'AlgeriaDup'),(3,'XAmerican Samoa'); +CREATE VIEW v1 AS +SELECT country_id as vf_country_id +FROM t2 +WHERE LEFT(country,1) = "A"; +PREPARE stmt FROM " +SELECT city, country_id +FROM t1 +WHERE country_id IN (SELECT vf_country_id FROM v1); +"; + +EXECUTE stmt; +city country_id +Algeria 2 +Batna 2 +Bchar 2 +Skikda 2 + +EXECUTE stmt; +city country_id +Algeria 2 +Batna 2 +Bchar 2 +Skikda 2 +DROP TABLE t1,t2; +DROP VIEW v1; +# +# Bug#54437 Extra rows with LEFT JOIN + semijoin (firstmatch +# and duplicates weedout) +# +create table t1 (a int); +create table t2 (a int); +create table t3 (a int); +insert into t1 values(1),(1); +insert into t2 values(1),(1),(1),(1); +insert into t3 values(2),(2); +explain select * from t1 where t1.a in (select t2.a from t2 left join t3 on t2.a=t3.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t2` left join `test`.`t3` on((`test`.`t2`.`a` = `test`.`t3`.`a`))) where (`test`.`t2`.`a` = `test`.`t1`.`a`) +select * from t1 where t1.a in (select t2.a from t2 left join t3 on t2.a=t3.a); +a +1 +1 +drop table t1,t2,t3; +# +# Bug#55955: crash in MEMORY engine with IN(LEFT JOIN (JOIN)) +# +CREATE TABLE t1 (a INT); +CREATE TABLE t2 (a INT); +CREATE TABLE t3 (a INT); +INSERT INTO t1 VALUES(1),(1); +INSERT INTO t2 VALUES(1),(1); +INSERT INTO t3 VALUES(2),(2); +explain SELECT * FROM t1 +WHERE t1.a IN (SELECT t2.a +FROM t2 LEFT JOIN (t2 AS t2inner, t3) ON t2.a=t3.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE NULL eq_ref 5 test.t1.a 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t2inner NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t2` left join (`test`.`t2` `t2inner` join `test`.`t3`) on((`test`.`t2`.`a` = `test`.`t3`.`a`))) where (``.`a` = `test`.`t1`.`a`) +SELECT * FROM t1 +WHERE t1.a IN (SELECT t2.a +FROM t2 LEFT JOIN (t2 AS t2inner, t3) ON t2.a=t3.a); +a +1 +1 +DROP TABLE t1,t2,t3; +# +# BUG#52329 - Wrong result: subquery materialization, IN, +# non-null field followed by nullable +# +CREATE TABLE t1 (a1 CHAR(8) NOT NULL, a2 char(8) NOT NULL); +CREATE TABLE t2a (b1 char(8), b2 char(8)); +CREATE TABLE t2b (b1 CHAR(8), b2 char(8) NOT NULL); +CREATE TABLE t2c (b1 CHAR(8) NOT NULL, b2 char(8)); +INSERT INTO t1 VALUES ('1 - 12', '2 - 22'); +INSERT INTO t2a VALUES ('1 - 11', '2 - 21'), +('1 - 11', '2 - 21'), +('1 - 12', '2 - 22'), +('1 - 12', '2 - 22'), +('1 - 13', '2 - 23'); +INSERT INTO t2b SELECT * FROM t2a; +INSERT INTO t2c SELECT * FROM t2a; +SELECT * FROM t1 +WHERE (a1, a2) IN ( +SELECT b1, b2 FROM t2c WHERE b1 > '0' GROUP BY b1, b2); +a1 a2 +1 - 12 2 - 22 +SELECT * FROM t1 +WHERE (a1, a2) IN ( +SELECT b1, b2 FROM t2a WHERE b1 > '0'); +a1 a2 +1 - 12 2 - 22 +SELECT * FROM t1 +WHERE (a1, a2) IN ( +SELECT b1, b2 FROM t2b WHERE b1 > '0'); +a1 a2 +1 - 12 2 - 22 +SELECT * FROM t1 +WHERE (a1, a2) IN ( +SELECT b1, b2 FROM t2c WHERE b1 > '0'); +a1 a2 +1 - 12 2 - 22 +DROP TABLE t1,t2a,t2b,t2c; +# End BUG#52329 +# +# Bug#45174: Incorrectly applied equality propagation caused wrong +# result on a query with a materialized semi-join. +# +CREATE TABLE t1 ( +varchar_nokey varchar(1) NOT NULL +) charset utf8mb4; +INSERT INTO t1 VALUES +('v'), ('u'), ('n'), ('l'), ('h'), ('u'), ('n'), ('j'), ('k'), +('e'), ('i'), ('u'), ('n'), ('b'), ('x'), (''), ('q'), ('u'); +CREATE TABLE t2 ( +pk int NOT NULL, +varchar_key varchar(1) NOT NULL, +varchar_nokey varchar(1) NOT NULL, +PRIMARY KEY(pk), +KEY varchar_key(varchar_key) +) charset utf8mb4; +INSERT INTO t2 VALUES +(11,'m','m'), (12,'j','j'), (13,'z','z'), (14,'a','a'), (15,'',''), +(16,'e','e'), (17,'t','t'), (19,'b','b'), (20,'w','w'), (21,'m','m'), +(23,'',''), (24,'w','w'), (26,'e','e'), (27,'e','e'), (28,'p','p'); +SELECT varchar_nokey +FROM t1 +WHERE (varchar_nokey, varchar_nokey) IN (SELECT varchar_key, varchar_nokey +FROM t2 +WHERE varchar_nokey < 'n' XOR pk); +varchar_nokey +explain SELECT varchar_nokey +FROM t1 +WHERE (varchar_nokey, varchar_nokey) IN (SELECT varchar_key, varchar_nokey +FROM t2 +WHERE varchar_nokey < 'n' XOR pk); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 18 100.00 NULL +1 SIMPLE NULL eq_ref 12 test.t1.varchar_nokey,test.t1.varchar_nokey 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL varchar_key NULL NULL NULL 15 63.34 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`varchar_nokey` AS `varchar_nokey` from `test`.`t1` semi join (`test`.`t2`) where ((``.`varchar_key` = `test`.`t1`.`varchar_nokey`) and (``.`varchar_nokey` = `test`.`t1`.`varchar_nokey`) and (`test`.`t2`.`varchar_nokey` = `test`.`t2`.`varchar_key`) and ((`test`.`t2`.`varchar_nokey` < 'n') xor (0 <> `test`.`t2`.`pk`))) +DROP TABLE t1, t2; +# End of the test for bug#45174. +# +# Bug#50019: Wrong result for IN-query with materialization +# +CREATE TABLE t1(i INT); +INSERT INTO t1 VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10); +CREATE TABLE t2(i INT); +INSERT INTO t2 VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10); +CREATE TABLE t3(i INT); +INSERT INTO t3 VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10); +SELECT * FROM t1 WHERE t1.i IN (SELECT t2.i +FROM t2 JOIN t3 +WHERE t2.i + t3.i = 5); +i +1 +2 +3 +4 +explain SELECT * FROM t1 WHERE t1.i IN (SELECT t2.i +FROM t2 JOIN t3 +WHERE t2.i + t3.i = 5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 100.00 Using where +1 SIMPLE NULL eq_ref 5 test.t1.i 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 10 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 10 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = `test`.`t1`.`i`) and ((`test`.`t2`.`i` + `test`.`t3`.`i`) = 5)) +DROP TABLE t1,t2,t3; +# End of the test for bug#50019. +# +# Bug#52068: Optimizer generates invalid semijoin materialization plan +# +CREATE TABLE ot1(a INTEGER); +INSERT INTO ot1 VALUES(5), (8); +CREATE TABLE it2(a INTEGER); +INSERT INTO it2 VALUES(9), (5), (1), (8); +CREATE TABLE it3(a INTEGER); +INSERT INTO it3 VALUES(7), (1), (0), (5), (1), (4); +CREATE TABLE ot4(a INTEGER); +INSERT INTO ot4 VALUES(1), (3), (5), (7), (9), (7), (3), (1); +SELECT * FROM ot1,ot4 +WHERE (ot1.a,ot4.a) IN (SELECT it2.a,it3.a +FROM it2,it3); +a a +5 1 +5 1 +5 5 +5 7 +5 7 +8 1 +8 1 +8 5 +8 7 +8 7 +explain SELECT * FROM ot1,ot4 +WHERE (ot1.a,ot4.a) IN (SELECT it2.a,it3.a +FROM it2,it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE it2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; Using join buffer (hash join) +1 SIMPLE it3 NULL ALL NULL NULL NULL NULL 6 100.00 Using join buffer (hash join) +1 SIMPLE ot4 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot4`.`a` AS `a` from `test`.`ot1` join `test`.`ot4` semi join (`test`.`it2` join `test`.`it3`) where ((`test`.`ot4`.`a` = `test`.`it3`.`a`) and (`test`.`it2`.`a` = `test`.`ot1`.`a`)) +DROP TABLE IF EXISTS ot1, ot4, it2, it3; +# End of the test for bug#52068. +# +# Bug#57623: subquery within before insert trigger causes crash (sj=on) +# +CREATE TABLE ot1(a INT); +CREATE TABLE ot2(a INT); +CREATE TABLE ot3(a INT); +CREATE TABLE it1(a INT); +INSERT INTO ot1 VALUES(0),(1),(2),(3),(4),(5),(6),(7); +INSERT INTO ot2 VALUES(0),(2),(4),(6); +INSERT INTO ot3 VALUES(0),(3),(6); +INSERT INTO it1 VALUES(0),(1),(2),(3),(4),(5),(6),(7); +explain SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 on ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a from it1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +1 SIMPLE NULL eq_ref 5 test.ot1.a 1 100.00 NULL +1 SIMPLE ot3 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +2 MATERIALIZED it1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a`,`test`.`ot3`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` join `test`.`ot3` semi join (`test`.`it1`)) on(((``.`a` = `test`.`ot1`.`a`) and (`test`.`ot3`.`a` = `test`.`ot1`.`a`) and (`test`.`ot2`.`a` = `test`.`ot1`.`a`))) where true +SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 on ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a from it1); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +prepare s from 'SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 on ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a from it1)'; +execute s; +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +execute s; +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +deallocate prepare s; +DROP TABLE ot1, ot2, ot3, it1; +# End of the test for bug#57623. +# +# Bug#11766739: Crash in tmp_table_param::init() with semijoin=on +# +CREATE TABLE t1 (f1 INTEGER) ENGINE=MyISAM; +CREATE TABLE t2 (f1 INTEGER, f2 INTEGER) ENGINE=MyISAM; +INSERT INTO t1 VALUES (1); +INSERT INTO t2 VALUES (1,1), (2,1); +EXPLAIN SELECT * FROM t2 +WHERE f2 IN (SELECT t1.f1 +FROM t1 LEFT OUTER JOIN (t2 AS b1 JOIN t2 AS b2 ON TRUE) ON TRUE); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE b1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +1 SIMPLE b2 NULL ALL NULL NULL NULL NULL 2 100.00 End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`f1` AS `f1`,`test`.`t2`.`f2` AS `f2` from `test`.`t2` semi join (`test`.`t1` left join (`test`.`t2` `b1` join `test`.`t2` `b2`) on((true))) where (`test`.`t2`.`f2` = `test`.`t1`.`f1`) +SELECT * FROM t2 +WHERE f2 IN (SELECT t1.f1 +FROM t1 LEFT OUTER JOIN (t2 AS b1 JOIN t2 AS b2 ON TRUE) ON TRUE); +f1 f2 +1 1 +2 1 +DROP TABLE t1, t2; +# End of the test for bug#11766739. +# +# Bug#11766642: crash in Item_field::register_field_in_read_map with view +# +CREATE TABLE t1(a INT); +CREATE VIEW v1 AS SELECT a FROM t1; +INSERT INTO t1 VALUES (0),(1),(2); +SELECT a FROM t1 WHERE a IN +(SELECT a XOR a FROM v1) +ORDER BY a; +a +0 +DROP TABLE t1; +DROP VIEW v1; +# +# Bug#12546542 MISSING ROW WHEN USING OPTIMIZER_JOIN_CACHE_LEVEL>=3 +# +CREATE TABLE t1 ( +f2 varchar(1024) +); +INSERT INTO t1 VALUES ('v'),('we'); +CREATE TABLE t2 ( +col_varchar_1024_utf8 varchar(1024) CHARACTER SET utf8 DEFAULT NULL, +col_int_key int, +col_int int +); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t2 VALUES ('we',4,NULL),('v',1305673728,6); +CREATE TABLE t3 ( +col_int_key int, +col_int int +); +INSERT INTO t3 VALUES (4,4); +SELECT * +FROM t1 +WHERE f2 IN (SELECT a1.col_varchar_1024_utf8 AS f2 +FROM t2 AS a1 LEFT JOIN t3 AS a2 +ON a1.col_int_key = a2.col_int_key +WHERE a1.col_int BETWEEN 1 AND 10 OR a2.col_int IS NOT NULL); +f2 +v +we +DROP TABLE t1,t2,t3; +# +# BUG#12616344 - JCL: DIFFERENT RESULT SET AND DIFFERENT AMOUNT +# OF ROWS WHEN JCL>=3 +# +CREATE TABLE t1 (col_int_nokey int, col_int_key int, col_varchar_key varchar(1)); +INSERT INTO t1 VALUES (0,4,'c'),(1,6,'u'); +CREATE TABLE t2 (pk int, col_int_nokey int, col_varchar_nokey varchar(1)); +INSERT INTO t2 VALUES (1,4,'b'),(94,6,'u'); +CREATE TABLE t3 (pk int, col_int_nokey int, col_varchar_key varchar(1)); +INSERT INTO t3 VALUES (1,4,'j'),(2,6,'v'); +SELECT table2.col_int_key +from t3 as table1 join t1 as table2 on table2.col_int_nokey +where table1.col_int_nokey in +( +select subquery2_t2.col_int_nokey +from t3 as subquery2_t1 +right join +t2 as subquery2_t2 +join t1 as subquery2_t3 +on subquery2_t3.col_int_key = subquery2_t2.col_int_nokey +on subquery2_t3.col_varchar_key = subquery2_t2.col_varchar_nokey +where subquery2_t1.col_varchar_key != table1.col_varchar_key +or subquery2_t2.pk <= table1.pk +); +col_int_key +6 +6 +DROP TABLE t1,t2,t3; +# +# Bug#12608157: ASSERT IN FIELD_LONG::VAL_INT WHEN USING MEMORY ENGINE +# +CREATE TABLE t1 (i1 int); +INSERT INTO t1 VALUES (1); +CREATE TABLE t2 (i1 int, i2 int) ENGINE=memory; +INSERT INTO t2 VALUES (1, 2),(7, 3); +SELECT GRANDPARENT1.i1 +FROM t2 AS GRANDPARENT1 +WHERE GRANDPARENT1.i2 +IN ( SELECT PARENT1.i2 +FROM t2 AS PARENT1 JOIN t1 AS PARENT2 ON (PARENT1.i1 = PARENT2.i1) +WHERE +GRANDPARENT1.i1 IN ( SELECT CHILD1.i1 FROM t2 AS CHILD1 ) +ORDER BY PARENT1.i1) +ORDER BY GRANDPARENT1.i2 ; +i1 +1 +DROP TABLE t1,t2; +# +# Bug#12640083: Same query executed as WHERE subquery gives different +# results on IN() compare +# +CREATE TABLE t1 ( +pk int NOT NULL, +col_varchar_1024_utf8_key varchar(1024) CHARACTER SET utf8 DEFAULT NULL, +col_varchar_10_latin1_key varchar(10) DEFAULT NULL, +PRIMARY KEY (pk), +KEY col_varchar_1024_utf8_key(col_varchar_1024_utf8_key(333)), +KEY col_varchar_10_latin1_key(col_varchar_10_latin1_key) +) charset utf8mb4; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES +(1, 'a', 'a'), +(2, 'ab', 'ab'), +(3, 'abc', 'abc'), +(4, 'abcd', 'abcd'); +CREATE TABLE t2 ( +pk int NOT NULL AUTO_INCREMENT, +PRIMARY KEY (pk) +) charset utf8mb4 ENGINE=Innodb; +CREATE TABLE t3 charset utf8mb4 +SELECT alias1.col_varchar_10_latin1_key +FROM t1 AS alias1 +LEFT JOIN t1 AS alias2 +JOIN t2 AS alias3 +ON alias2.col_varchar_10_latin1_key +ON alias1.col_varchar_1024_utf8_key +WHERE alias1.pk AND alias1.pk < 3 OR alias1.pk AND alias3.pk; +EXPLAIN SELECT * +FROM t3 +WHERE col_varchar_10_latin1_key IN ( +SELECT alias1.col_varchar_10_latin1_key +FROM t1 AS alias1 +LEFT JOIN t1 AS alias2 +JOIN t2 AS alias3 +ON alias2.col_varchar_10_latin1_key +ON alias1.col_varchar_1024_utf8_key +WHERE alias1.pk AND alias1.pk < 3 OR alias1.pk AND alias3.pk); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE alias1 NULL ref PRIMARY,col_varchar_10_latin1_key col_varchar_10_latin1_key 43 test.t3.col_varchar_10_latin1_key 2 100.00 Using where +1 SIMPLE alias3 NULL index NULL PRIMARY 4 NULL 1 100.00 Using where; Using index +1 SIMPLE alias2 NULL index NULL col_varchar_10_latin1_key 43 NULL 4 100.00 Using where; Using index; FirstMatch(t3) +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`col_varchar_10_latin1_key` AS `col_varchar_10_latin1_key` from `test`.`t3` semi join (`test`.`t1` `alias1` left join (`test`.`t1` `alias2` join `test`.`t2` `alias3`) on(((0 <> `test`.`alias1`.`col_varchar_1024_utf8_key`) and (0 <> `test`.`alias2`.`col_varchar_10_latin1_key`)))) where ((`test`.`alias1`.`col_varchar_10_latin1_key` = `test`.`t3`.`col_varchar_10_latin1_key`) and (((0 <> `test`.`alias1`.`pk`) and (`test`.`alias1`.`pk` < 3)) or ((0 <> `test`.`alias1`.`pk`) and (0 <> `test`.`alias3`.`pk`)))) +SELECT * +FROM t3 +WHERE col_varchar_10_latin1_key IN ( +SELECT alias1.col_varchar_10_latin1_key +FROM t1 AS alias1 +LEFT JOIN t1 AS alias2 +JOIN t2 AS alias3 +ON alias2.col_varchar_10_latin1_key +ON alias1.col_varchar_1024_utf8_key +WHERE alias1.pk AND alias1.pk < 3 OR alias1.pk AND alias3.pk); +col_varchar_10_latin1_key +a +ab +DROP TABLE t1, t2, t3; +# End of the test for bug#12640083. +# +# Bug#12603200 - Assert in QUICK_INDEX_MERGE_SELECT::need_sorted_output +# +CREATE TABLE t1 ( +pk int NOT NULL, +col_int_key int NOT NULL, +col_varchar_nokey varchar(1) NOT NULL, +col_varchar_key varchar(1) NOT NULL, +PRIMARY KEY(pk), +KEY col_int_key(col_int_key), +KEY col_varchar_key(col_varchar_key, col_int_key) +) charset utf8mb4 engine=innodb; +INSERT INTO t1 VALUES +(1,7,'a','a'), +(2,0,'v','v'), +(3,9,'c','c'), +(4,3,'m','m'), +(5,2,'a','a'), +(6,1,'d','d'), +(7,8,'y','y'), +(8,6,'t','t'), +(11,7,'a','x'), +(12,0,'v','v'), +(13,9,'c','c'), +(14,3,'m','m'), +(15,2,'a','x'), +(16,1,'d','d'), +(17,8,'y','y'), +(18,6,'t','u'), +(19,6,'t','u'); +CREATE TABLE t2 ( +pk int NOT NULL, +col_int_key int NOT NULL, +col_varchar_key varchar(1) NOT NULL, +PRIMARY KEY(pk), +KEY col_varchar_key(col_varchar_key, col_int_key) +) charset utf8mb4 engine=innodb; +INSERT INTO t2(pk,col_int_key,col_varchar_key) VALUES +(8,7,'c'), +(11,4,'l'), +(12,7,'b'), +(13,0,'c'), +(14,2,'i'), +(15,9,'h'), +(16,4,'q'), +(17,1,'m'), +(18,9,'b'), +(19,2,'e'), +(20,1,'c'), +(21,7,'z'), +(22,4,'l'), +(23,7,'z'), +(24,0,'c'), +(25,2,'i'), +(26,9,'h'), +(27,4,'q'), +(28,0,'a'), +(29,1,'d'); +EXPLAIN SELECT outr.col_varchar_key AS x, outr.pk AS y +FROM t1 AS outr +WHERE outr.col_varchar_key IN (SELECT innr.col_varchar_key +FROM t2 AS innr +WHERE innr.col_varchar_key = 'a' OR innr.pk = 8) +AND outr.col_varchar_nokey < 't' +ORDER BY outr.col_varchar_key, outr.pk; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE innr NULL index_merge PRIMARY,col_varchar_key col_varchar_key,PRIMARY 6,4 NULL 2 100.00 Using sort_union(col_varchar_key,PRIMARY); Using where; Using temporary; Using filesort; Start temporary +1 SIMPLE outr NULL ref col_varchar_key col_varchar_key 6 test.innr.col_varchar_key 1 33.33 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`outr`.`col_varchar_key` AS `x`,`test`.`outr`.`pk` AS `y` from `test`.`t1` `outr` semi join (`test`.`t2` `innr`) where ((`test`.`outr`.`col_varchar_key` = `test`.`innr`.`col_varchar_key`) and (`test`.`outr`.`col_varchar_nokey` < 't') and ((`test`.`innr`.`col_varchar_key` = 'a') or (`test`.`innr`.`pk` = 8))) order by `test`.`outr`.`col_varchar_key`,`test`.`outr`.`pk` +SELECT outr.col_varchar_key AS x, outr.pk AS y +FROM t1 AS outr +WHERE outr.col_varchar_key IN (SELECT innr.col_varchar_key +FROM t2 AS innr +WHERE innr.col_varchar_key = 'a' OR innr.pk = 8) +AND outr.col_varchar_nokey < 't' +ORDER BY outr.col_varchar_key, outr.pk; +x y +a 1 +a 5 +c 3 +c 13 +DROP TABLE t1, t2; +# End of bug#12603200 +# +# Bug#12603183: Segfault in hp_movelink +# +CREATE TABLE t1 ( +col_varchar_key varchar(1) , +col_varchar_nokey varchar(1) , +KEY col_varchar_key(col_varchar_key) +) charset latin1; +INSERT INTO t1 VALUES +('i','i'), +('h','h'), +('q','q'), +('a','a'), +('v','v'), +('u','u'), +('s','s'), +('y','y'), +('z','z'), +('h','h'), +('p','p'), +('e','e'), +('i','i'), +('y','y'), +('w','w'); +CREATE TABLE t2 ( +col_varchar_nokey varchar(1) +) charset latin1; +INSERT INTO t2 VALUES +('b'); +EXPLAIN SELECT grandparent1.col_varchar_nokey +FROM t1 AS grandparent1 LEFT JOIN t2 AS grandparent2 USING (col_varchar_nokey) +WHERE (grandparent1.col_varchar_key) IN +(SELECT parent1.col_varchar_nokey +FROM t1 AS parent1 +WHERE parent1.col_varchar_key IN +(SELECT child1.col_varchar_nokey AS c1 +FROM t1 AS child1 LEFT JOIN t2 AS child2 +ON (child1.col_varchar_key > child2.col_varchar_nokey))); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using where +1 SIMPLE grandparent1 NULL ref col_varchar_key col_varchar_key 4 .col_varchar_nokey 2 100.00 NULL +1 SIMPLE grandparent2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +2 MATERIALIZED child1 NULL ALL NULL NULL NULL NULL 15 100.00 Using where +2 MATERIALIZED child2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +2 MATERIALIZED parent1 NULL ref col_varchar_key col_varchar_key 4 test.child1.col_varchar_nokey 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`grandparent1`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t1` `grandparent1` left join `test`.`t2` `grandparent2` on((`test`.`grandparent2`.`col_varchar_nokey` = `test`.`grandparent1`.`col_varchar_nokey`)) semi join (`test`.`t1` `parent1` join `test`.`t1` `child1` left join `test`.`t2` `child2` on((`test`.`child1`.`col_varchar_key` > `test`.`child2`.`col_varchar_nokey`))) where ((`test`.`grandparent1`.`col_varchar_key` = ``.`col_varchar_nokey`) and (`test`.`parent1`.`col_varchar_key` = `test`.`child1`.`col_varchar_nokey`)) +SELECT grandparent1.col_varchar_nokey +FROM t1 AS grandparent1 LEFT JOIN t2 AS grandparent2 USING (col_varchar_nokey) +WHERE (grandparent1.col_varchar_key) IN +(SELECT parent1.col_varchar_nokey +FROM t1 AS parent1 +WHERE parent1.col_varchar_key IN +(SELECT child1.col_varchar_nokey AS c1 +FROM t1 AS child1 LEFT JOIN t2 AS child2 +ON (child1.col_varchar_key > child2.col_varchar_nokey))); +col_varchar_nokey +a +e +h +h +i +i +p +q +s +u +v +w +y +y +z +DROP TABLE t1, t2; +# End of test for bug#12603183. +# +# Bug#12818569: Diff nr of rows returned when using IN/ALL+subquery +# +CREATE TABLE t1 ( +col_int_key INT NOT NULL, +col_datetime_key DATETIME NOT NULL, +col_varchar_key VARCHAR(1) NOT NULL, +KEY col_int_key (col_int_key), +KEY col_datetime_key(col_datetime_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t1 VALUES +(7,'2004-06-06 04:22:12','v'), (0,'2005-11-13 01:12:31','s'), +(9,'2002-05-04 01:50:00','l'), (3,'2004-10-27 10:28:45','y'), +(4,'2006-07-22 05:24:23','c'), (2,'2002-05-16 21:34:03','i'), +(5,'2008-04-17 10:45:30','h'), (3,'2009-04-21 02:58:02','q'), +(1,'2008-01-11 11:01:51','a'), (3,'1900-01-01 00:00:00','v'), +(6,'2007-05-17 18:24:57','u'), (7,'2007-08-07 00:00:00','s'), +(5,'2001-08-28 00:00:00','y'), (1,'2004-04-16 00:27:28','z'), +(204,'2005-05-03 07:06:22','h'), (224,'2009-03-11 17:09:50','p'), +(9,'2007-12-08 01:54:28','e'), (5,'2009-07-28 18:19:54','i'), +(0,'2008-06-08 00:00:00','y'), (3,'2005-02-09 09:20:26','w'); +CREATE TABLE t2 ( +col_varchar_nokey VARCHAR(1) NOT NULL +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t2 VALUES ('v'), ('y'), ('j'), ('c'), ('d'), ('r'); +explain SELECT col_varchar_key +FROM t1 +WHERE col_varchar_key IN (SELECT col_varchar_nokey +FROM t2) +ORDER BY col_datetime_key LIMIT 4; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL col_varchar_key NULL NULL NULL 20 100.00 Using filesort +1 SIMPLE NULL eq_ref 6 test.t1.col_varchar_key 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 6 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col_varchar_key` AS `col_varchar_key` from `test`.`t1` semi join (`test`.`t2`) where (``.`col_varchar_nokey` = `test`.`t1`.`col_varchar_key`) order by `test`.`t1`.`col_datetime_key` limit 4 +SELECT col_varchar_key +FROM t1 +WHERE col_varchar_key IN (SELECT col_varchar_nokey +FROM t2) +ORDER BY col_datetime_key LIMIT 4; +col_varchar_key +v +y +v +y +DROP TABLE t1, t2; +# End of test for bug#12818569. +# +# Bug#12803439: Assert in replace_subcondition() on update query +# +CREATE TABLE t1(a INTEGER); +INSERT INTO t1 values(1), (2); +CREATE TABLE t2(a INTEGER); +INSERT INTO t2 VALUES(1), (3); +SELECT * +FROM t1 +WHERE a IN (SELECT a +FROM t2 +HAVING a IN (SELECT a +FROM t2) +) +HAVING a IN (SELECT a +FROM t2); +a +1 +DROP TABLE t1, t2; +# End of test for bug#12803439. +# +# Bug#12797534: Segfault in hp_movelink still exists +# +CREATE TABLE t1 ( +g1 VARCHAR(1) NOT NULL +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t1 VALUES ('d'), ('s'); +CREATE TABLE t2 ( +pk INT NOT NULL, +col_int_key INT NOT NULL, +col_varchar_key VARCHAR(1) NOT NULL, +col_varchar_nokey VARCHAR(1) NOT NULL, +PRIMARY KEY (pk), +KEY col_varchar_key(col_varchar_key, col_int_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t2 VALUES +(1,4,'j','j'), (2,6,'v','v'), (3,3,'c','c'), (4,5,'m','m'), +(5,3,'d','d'), (6,246,'d','d'), (7,2,'y','y'), (8,9,'t','t'), +(9,3,'d','d'), (10,8,'s','s'), (11,1,'r','r'), (12,8,'m','m'), +(13,8,'b','b'), (14,5,'x','x'), (15,7,'g','g'), (16,5,'p','p'), +(17,1,'q','q'), (18,6,'w','w'), (19,2,'d','d'), (20,9,'e','e'); +CREATE TABLE t3 ( +pk INTEGER NOT NULL, +PRIMARY KEY (pk) +) ENGINE=InnoDB; +INSERT INTO t3 VALUES (10); +EXPLAIN SELECT * +FROM t1 +WHERE g1 NOT IN +(SELECT grandparent1.col_varchar_nokey AS g1 +FROM t2 AS grandparent1 +WHERE grandparent1.col_varchar_key IN +(SELECT parent1.col_varchar_nokey AS p1 +FROM t2 AS parent1 LEFT JOIN t3 AS parent2 USING (pk) +) +AND grandparent1.col_varchar_key IS NOT NULL +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE NULL eq_ref 7 test.t1.g1 1 100.00 Using where; Not exists +2 MATERIALIZED parent1 NULL ALL NULL NULL NULL NULL 20 100.00 NULL +2 MATERIALIZED parent2 NULL eq_ref PRIMARY PRIMARY 4 test.parent1.pk 1 100.00 Using index +2 MATERIALIZED grandparent1 NULL ref col_varchar_key col_varchar_key 6 test.parent1.col_varchar_nokey 1 100.00 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`g1` AS `g1` from `test`.`t1` anti join (`test`.`t2` `grandparent1` join `test`.`t2` `parent1` left join `test`.`t3` `parent2` on((`test`.`parent2`.`pk` = `test`.`parent1`.`pk`))) on(((``.`g1` = `test`.`t1`.`g1`) and (`test`.`grandparent1`.`col_varchar_key` = `test`.`parent1`.`col_varchar_nokey`) and (`test`.`grandparent1`.`col_varchar_key` is not null))) where true +SELECT * +FROM t1 +WHERE g1 NOT IN +(SELECT grandparent1.col_varchar_nokey AS g1 +FROM t2 AS grandparent1 +WHERE grandparent1.col_varchar_key IN +(SELECT parent1.col_varchar_nokey AS p1 +FROM t2 AS parent1 LEFT JOIN t3 AS parent2 USING (pk) +) +AND grandparent1.col_varchar_key IS NOT NULL +); +g1 +DROP TABLE t1, t2, t3; +CREATE TABLE t1 ( +pk INTEGER AUTO_INCREMENT, +col_int_key INTEGER , +col_varchar_key VARCHAR(1) , +col_varchar_nokey VARCHAR(1) , +PRIMARY KEY (pk), +KEY (col_varchar_key,col_int_key) +) ENGINE=INNODB; +INSERT INTO t1 (col_int_key,col_varchar_key,col_varchar_nokey) VALUES +(0,'x','x'), (1,'j','j'), (1,'r','r'), (9,'v','v'), (5,'r','r'); +CREATE TABLE t2 ( +pk INTEGER AUTO_INCREMENT, +col_int_key INTEGER , +col_varchar_key VARCHAR(1) , +col_varchar_nokey VARCHAR(1) , +PRIMARY KEY (pk), +KEY (col_int_key), +KEY (col_varchar_key,col_int_key) +) AUTO_INCREMENT=10 ENGINE=INNODB; +INSERT INTO t2 (col_int_key, col_varchar_key, col_varchar_nokey) VALUES +(NULL,'x','x'), (NULL,'j','j'), (8,'c','c'); +CREATE TABLE t3 +SELECT outr.col_varchar_nokey AS x +FROM t1 AS outr +WHERE outr.col_varchar_nokey IN +(SELECT innr.col_varchar_nokey AS y +FROM t2 AS innr +WHERE innr.col_int_key IS NULL) +AND outr.col_varchar_nokey IS NOT NULL +AND NOT col_varchar_key IS NULL; +SELECT * +FROM t3 +WHERE x NOT IN +(SELECT outr.col_varchar_nokey AS x +FROM t1 AS outr +WHERE outr.col_varchar_nokey IN +(SELECT innr.col_varchar_nokey AS y +FROM t2 AS innr +WHERE innr.col_int_key IS NULL) +AND outr.col_varchar_nokey IS NOT NULL +AND NOT col_varchar_key IS NULL); +x +DROP TABLE t1, t2, t3; +# End of test for bug#12797534. +# +# Bug#12714094: Assert in optimize_semijoin_nests() +# +CREATE TABLE it ( +pk int NOT NULL, +col_varchar VARCHAR(10) DEFAULT NULL, +PRIMARY KEY (pk) +) ENGINE=MyISAM; +INSERT INTO it VALUES (1, 'g'); +CREATE TABLE ot +SELECT alias1.pk AS field1 +FROM it AS alias1 +LEFT JOIN it AS alias2 +ON alias1.col_varchar = alias2.col_varchar +; +SELECT * +FROM ot +WHERE field1 IN ( +SELECT alias1.pk +FROM it AS alias1 +LEFT JOIN it AS alias2 +ON alias1.col_varchar = alias2.col_varchar +); +field1 +1 +DROP TABLE it, ot; +# End of test for bug#12714094 +# +# Bug#12867557: Valgrind: conditional jump/move at key_cmp +# +CREATE TABLE t1 ( +pk INTEGER AUTO_INCREMENT, +col_int_key INTEGER, +PRIMARY KEY (pk), +KEY (col_int_key) +) AUTO_INCREMENT=10; +INSERT INTO t1 (col_int_key) VALUES (8); +CREATE TABLE t2 ( +pk INTEGER AUTO_INCREMENT, +col_int_key INTEGER, +col_time_key TIME, +PRIMARY KEY (pk), +KEY (col_int_key), +KEY (col_time_key) +) AUTO_INCREMENT=10; +INSERT INTO t2 (col_int_key, col_time_key) +VALUES +(8, '22:55:23.019225'), (7, '10:19:31.050677'), (1, '14:40:36.038608'), +(7, '04:37:47.062416'), (9, '19:34:06.054514'), (NULL,'20:35:33.022996'), +(1, NULL), (9, '14:43:37.057393'), (2, '02:23:09.043438'), +(9, '01:22:45.041064'), (2, '00:00:00'), (4, '00:13:25.038482'), +(0, '03:47:16.042671'), (4, '01:41:48.007423'), (8, '00:00:00'), +(NULL, '22:32:04.047407'), (NULL, '16:44:14.028443'), (0, '17:38:37.059754'), +(NULL, '08:46:48.042388'), (8, '14:11:27.044095'); +CREATE TABLE t0 +SELECT DISTINCT grandparent1.col_time_key AS g1 +FROM t2 AS grandparent1 +WHERE grandparent1.col_int_key IN +(SELECT parent1.col_int_key AS p1 +FROM t1 AS parent1) +AND grandparent1.pk > 9; +UPDATE t0 +SET g1 = g1 +WHERE g1 IN +(SELECT grandparent1.col_time_key AS g1 +FROM t2 AS grandparent1 +WHERE grandparent1.col_int_key IN +(SELECT parent1.col_int_key AS p1 +FROM t1 AS parent1) +AND grandparent1.pk > 9); +DROP TABLE t0, t1, t2; +# End of test for bug#12867557 +# +# Bug#12711441: crash in fix_after_pullout +# +CREATE TABLE t1 ( +pk int NOT NULL, +col_int_nokey int DEFAULT NULL, +col_int_key int DEFAULT NULL, +col_time_key time DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +PRIMARY KEY (pk) +); +CREATE VIEW v1 AS SELECT * FROM t1; +CREATE TABLE t2 ( +col_int_key int DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +KEY col_varchar_key(col_varchar_key, col_int_key) +); +CREATE TABLE t3 ( +pk int NOT NULL, +col_int_key INT DEFAULT NULL, +PRIMARY KEY (pk) +); +CREATE TABLE t4 ( +col_int_nokey INT DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +KEY col_varchar_key(col_varchar_key) +); +CREATE TABLE ts +SELECT alias1.col_time_key AS field1 +FROM v1 AS alias1 +RIGHT JOIN t3 AS alias2 +ON alias2.col_int_key = alias1.col_int_nokey +WHERE alias1.pk >= SOME( +SELECT SQ1_alias1.pk AS SQ1_field1 +FROM t3 AS SQ1_alias1 +INNER JOIN (t2 AS SQ1_alias2 +INNER JOIN t4 AS SQ1_alias3 +ON SQ1_alias3.col_varchar_key = SQ1_alias2.col_varchar_nokey) +ON SQ1_alias3.col_int_nokey = SQ1_alias2.col_int_key +WHERE SQ1_alias2.col_varchar_key <= alias1.col_varchar_key +AND SQ1_alias3.col_varchar_nokey <> alias1.col_varchar_key) +; +SELECT * FROM ts WHERE field1 IN ( +SELECT alias1.col_time_key AS field1 +FROM v1 AS alias1 +RIGHT JOIN t3 AS alias2 +ON alias2.col_int_key = alias1.col_int_nokey +WHERE alias1.pk >= SOME( +SELECT SQ1_alias1.pk AS SQ1_field1 +FROM t3 AS SQ1_alias1 +INNER JOIN (t2 AS SQ1_alias2 +INNER JOIN t4 AS SQ1_alias3 +ON SQ1_alias3.col_varchar_key = SQ1_alias2.col_varchar_nokey) +ON SQ1_alias3.col_int_nokey = SQ1_alias2.col_int_key +WHERE SQ1_alias2.col_varchar_key <= alias1.col_varchar_key +AND SQ1_alias3.col_varchar_nokey <> alias1.col_varchar_key) +); +field1 +DROP TABLE t1, t2, t3, t4, ts; +DROP VIEW v1; +# End of test for bug#12711441. +# +# Bug#12664936: Same query executed as where subquery ... +# +CREATE TABLE t1 ( +col_varchar_key VARCHAR(1), +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4; +INSERT INTO t1 VALUES +('o'), ('w'), ('m'), ('q'), +('f'), ('p'), ('j'), ('c'); +CREATE TABLE t2 ( +col_int_nokey INTEGER, +col_int_key INTEGER, +col_varchar_key varchar(1), +KEY col_int_key (col_int_key) +) charset utf8mb4; +INSERT INTO t2 VALUES +(8,5,'u'),(4,5,'p'),(8,1,'o'),(NULL,7,'v'), +(1,2,'g'),(2,1,'q'),(NULL,7,'l'),(3,1,'n'); +CREATE TABLE t4 +SELECT t2.col_int_nokey, t2.col_varchar_key +FROM t1 JOIN t2 ON t2.col_varchar_key = t1.col_varchar_key +WHERE t2.col_int_key = 1; +EXPLAIN SELECT * +FROM t4 +WHERE (col_int_nokey, col_varchar_key) IN +(SELECT t2.col_int_nokey, t2.col_varchar_key +FROM t1 JOIN t2 ON t2.col_varchar_key = t1.col_varchar_key +WHERE t2.col_int_key = 1 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t4 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE t2 NULL ref col_int_key col_int_key 5 const 3 12.50 Using where +1 SIMPLE t1 NULL ref col_varchar_key col_varchar_key 7 test.t4.col_varchar_key 2 100.00 Using index; FirstMatch(t4) +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`col_int_nokey` AS `col_int_nokey`,`test`.`t4`.`col_varchar_key` AS `col_varchar_key` from `test`.`t4` semi join (`test`.`t1` join `test`.`t2`) where ((`test`.`t2`.`col_varchar_key` = `test`.`t4`.`col_varchar_key`) and (`test`.`t1`.`col_varchar_key` = `test`.`t4`.`col_varchar_key`) and (`test`.`t2`.`col_int_nokey` = `test`.`t4`.`col_int_nokey`) and (`test`.`t2`.`col_int_key` = 1)) +SELECT * +FROM t4 +WHERE (col_int_nokey, col_varchar_key) IN +(SELECT t2.col_int_nokey, t2.col_varchar_key +FROM t1 JOIN t2 ON t2.col_varchar_key = t1.col_varchar_key +WHERE t2.col_int_key = 1 +); +col_int_nokey col_varchar_key +8 o +2 q +DROP TABLE t1, t2, t4; +# End of test for bug#12664936. +# +# Bug#13340270: assertion table->sort.record_pointers == __null +# +CREATE TABLE t1 ( +pk int NOT NULL, +col_int_key int DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key, col_int_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t1 VALUES +(10,8,'x','x'), +(11,7,'d','d'), +(12,1,'r','r'), +(13,7,'f','f'), +(14,9,'y','y'), +(15,NULL,'u','u'), +(16,1,'m','m'), +(17,9,NULL,NULL), +(18,2,'o','o'), +(19,9,'w','w'), +(20,2,'m','m'), +(21,4,'q','q'); +CREATE TABLE t2 +SELECT alias1.col_varchar_nokey AS field1 +FROM t1 AS alias1 JOIN t1 AS alias2 +ON alias2.col_int_key = alias1.pk OR +alias2.col_int_key = alias1.col_int_key +WHERE alias1.pk = 58 OR alias1.col_varchar_key = 'o' + +; +EXPLAIN SELECT * +FROM t2 +WHERE (field1) IN (SELECT alias1.col_varchar_nokey AS field1 +FROM t1 AS alias1 JOIN t1 AS alias2 +ON alias2.col_int_key = alias1.pk OR +alias2.col_int_key = alias1.col_int_key +WHERE alias1.pk = 58 OR alias1.col_varchar_key = 'o' +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE alias1 NULL index_merge PRIMARY,col_int_key,col_varchar_key col_varchar_key,PRIMARY 7,4 NULL 2 10.00 Using sort_union(col_varchar_key,PRIMARY); Using where +1 SIMPLE alias2 NULL ALL col_int_key NULL NULL NULL 12 19.00 Range checked for each record (index map: 0x2); FirstMatch(t2) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`field1` AS `field1` from `test`.`t2` semi join (`test`.`t1` `alias1` join `test`.`t1` `alias2`) where ((`test`.`alias1`.`col_varchar_nokey` = `test`.`t2`.`field1`) and ((`test`.`alias1`.`pk` = 58) or (`test`.`alias1`.`col_varchar_key` = 'o')) and ((`test`.`alias2`.`col_int_key` = `test`.`alias1`.`pk`) or (`test`.`alias2`.`col_int_key` = `test`.`alias1`.`col_int_key`))) +SELECT * +FROM t2 +WHERE (field1) IN (SELECT alias1.col_varchar_nokey AS field1 +FROM t1 AS alias1 JOIN t1 AS alias2 +ON alias2.col_int_key = alias1.pk OR +alias2.col_int_key = alias1.col_int_key +WHERE alias1.pk = 58 OR alias1.col_varchar_key = 'o' +); +field1 +o +o +DROP TABLE t1, t2; +# End of test for bug#13340270. +# +# Bug#13335319: Seg fault when analyzing FirstMatch semi-join strategy +# +CREATE TABLE ot1(a INTEGER); +INSERT INTO ot1 VALUES(1), (2), (3); +CREATE TABLE ot2(a INTEGER); +INSERT INTO ot2 VALUES(1), (2), (4), (6), (8), (10); +CREATE TABLE it1(a INTEGER); +INSERT INTO it1 VALUES(1), (3), (5), (7); +CREATE TABLE it2(a INTEGER); +INSERT INTO it2 VALUES(1), (3), (5), (7), (9); +explain SELECT ot1.a, ot2.a +FROM ot1, ot2 +WHERE ot1.a IN (SELECT a FROM it1) AND +ot2.a IN (SELECT a FROM it2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE it1 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; FirstMatch(ot1); Using join buffer (hash join) +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using join buffer (hash join) +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Using join buffer (hash join) +3 MATERIALIZED it2 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` join `test`.`ot2` semi join (`test`.`it1`) semi join (`test`.`it2`) where ((`test`.`ot2`.`a` = ``.`a`) and (`test`.`it1`.`a` = `test`.`ot1`.`a`)) +SELECT ot1.a, ot2.a +FROM ot1, ot2 +WHERE ot1.a IN (SELECT a FROM it1) AND +ot2.a IN (SELECT a FROM it2); +a a +1 1 +3 1 +DROP TABLE ot1, ot2, it1, it2; +# End of test for bug#13335319. +# +# Bug#13334882: Assertion keypart_map failed in MyIsam function +# +CREATE TABLE t1 ( +pk int NOT NULL, +col_int_nokey INT NOT NULL, +col_int_key INT NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +) ENGINE=MyISAM; +INSERT INTO t1 VALUES +(1,4,0), +(2,6,8), +(3,3,1), +(7,2,6), +(8,9,1), +(9,3,6), +(10,8,2), +(11,1,4), +(12,8,8), +(13,8,4), +(14,5,4); +CREATE TABLE t2 ( +pk int NOT NULL, +col_int_nokey int NOT NULL, +col_int_key int NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +) ENGINE=MyISAM; +INSERT INTO t2 VALUES +(10,8,7); +CREATE TABLE t3 +SELECT grandparent1.col_int_nokey AS g1 +FROM t1 AS grandparent1 +WHERE (grandparent1.col_int_nokey, grandparent1.col_int_key) IN +(SELECT parent1.col_int_key AS p1, +parent1.col_int_key AS p2 +FROM t1 AS parent1 +LEFT JOIN t2 AS parent2 +ON parent1.col_int_nokey = parent2.col_int_key +) +AND grandparent1.col_int_key <> 3 +; +explain SELECT * FROM t3 +WHERE g1 NOT IN +(SELECT grandparent1.col_int_nokey AS g1 +FROM t1 AS grandparent1 +WHERE (grandparent1.col_int_nokey, grandparent1.col_int_key) IN +(SELECT parent1.col_int_key AS p1, +parent1.col_int_key AS p2 +FROM t1 AS parent1 +LEFT JOIN t2 AS parent2 +ON parent1.col_int_nokey = parent2.col_int_key +) +AND grandparent1.col_int_key <> 3 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE grandparent1 NULL ref col_int_key col_int_key 4 const 1 100.00 Using where; Not exists +1 SIMPLE parent1 NULL ref col_int_key col_int_key 4 test.grandparent1.col_int_nokey 1 100.00 Using where +1 SIMPLE parent2 NULL ref col_int_key col_int_key 4 test.parent1.col_int_nokey 2 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select '8' AS `g1` from anti join (`test`.`t1` `grandparent1` join `test`.`t1` `parent1` left join `test`.`t2` `parent2` on((`test`.`parent2`.`col_int_key` = `test`.`parent1`.`col_int_nokey`))) on(((`test`.`grandparent1`.`col_int_nokey` = '8') and (`test`.`grandparent1`.`col_int_key` = '8') and (`test`.`parent1`.`col_int_key` = '8') and ('8' <> 3))) where true +explain format=json SELECT * FROM t3 +WHERE g1 NOT IN +(SELECT grandparent1.col_int_nokey AS g1 +FROM t1 AS grandparent1 +WHERE (grandparent1.col_int_nokey, grandparent1.col_int_key) IN +(SELECT parent1.col_int_key AS p1, +parent1.col_int_key AS p2 +FROM t1 AS parent1 +LEFT JOIN t2 AS parent2 +ON parent1.col_int_nokey = parent2.col_int_key +) +AND grandparent1.col_int_key <> 3 +); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.36" + }, + "nested_loop": [ + { + "table": { + "table_name": "t3", + "access_type": "system", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.00", + "eval_cost": "0.10", + "prefix_cost": "0.00", + "data_read_per_join": "8" + }, + "used_columns": [ + "g1" + ] + } + }, + { + "table": { + "table_name": "grandparent1", + "access_type": "ref", + "possible_keys": [ + "col_int_key" + ], + "key": "col_int_key", + "used_key_parts": [ + "col_int_key" + ], + "key_length": "4", + "ref": [ + "const" + ], + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "not_exists": true, + "cost_info": { + "read_cost": "0.28", + "eval_cost": "0.11", + "prefix_cost": "0.39", + "data_read_per_join": "17" + }, + "used_columns": [ + "col_int_nokey", + "col_int_key" + ], + "attached_condition": "(((is_not_null_compl(grandparent1..parent2), (found_match(grandparent1..parent2), false, true), true) and (is_not_null_compl(grandparent1..parent2), (('8' <> 3)), true)) and (is_not_null_compl(grandparent1..parent2), (`test`.`grandparent1`.`col_int_nokey` = '8'), true))" + } + }, + { + "table": { + "table_name": "parent1", + "access_type": "ref", + "possible_keys": [ + "col_int_key" + ], + "key": "col_int_key", + "used_key_parts": [ + "col_int_key" + ], + "key_length": "4", + "ref": [ + "test.grandparent1.col_int_nokey" + ], + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.30", + "eval_cost": "0.12", + "prefix_cost": "0.81", + "data_read_per_join": "19" + }, + "used_columns": [ + "col_int_nokey", + "col_int_key" + ], + "attached_condition": "(is_not_null_compl(grandparent1..parent2), (`test`.`parent1`.`col_int_key` = '8'), true)" + } + }, + { + "table": { + "table_name": "parent2", + "access_type": "ref", + "possible_keys": [ + "col_int_key" + ], + "key": "col_int_key", + "used_key_parts": [ + "col_int_key" + ], + "key_length": "4", + "ref": [ + "test.parent1.col_int_nokey" + ], + "rows_examined_per_scan": 2, + "rows_produced_per_join": 1, + "filtered": "100.00", + "using_index": true, + "cost_info": { + "read_cost": "0.31", + "eval_cost": "0.10", + "prefix_cost": "1.36", + "data_read_per_join": "16" + }, + "used_columns": [ + "col_int_key" + ] + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select '8' AS `g1` from anti join (`test`.`t1` `grandparent1` join `test`.`t1` `parent1` left join `test`.`t2` `parent2` on((`test`.`parent2`.`col_int_key` = `test`.`parent1`.`col_int_nokey`))) on(((`test`.`grandparent1`.`col_int_nokey` = '8') and (`test`.`grandparent1`.`col_int_key` = '8') and (`test`.`parent1`.`col_int_key` = '8') and ('8' <> 3))) where true +SELECT * FROM t3 +WHERE g1 NOT IN +(SELECT grandparent1.col_int_nokey AS g1 +FROM t1 AS grandparent1 +WHERE (grandparent1.col_int_nokey, grandparent1.col_int_key) IN +(SELECT parent1.col_int_key AS p1, +parent1.col_int_key AS p2 +FROM t1 AS parent1 +LEFT JOIN t2 AS parent2 +ON parent1.col_int_nokey = parent2.col_int_key +) +AND grandparent1.col_int_key <> 3 +); +g1 +DROP TABLE t1, t2, t3; +# End of test for bug#13334882. +# +# Bug#13339643: Assertion on JOIN::flatten_subqueries on second execution +# +CREATE TABLE t1 ( +col_int_nokey INT, +col_varchar_nokey VARCHAR(1) +) charset utf8mb4; +INSERT INTO t1 VALUES +(1,'o'), +(2,'t'); +CREATE TABLE t2 LIKE t1; +INSERT INTO t2 VALUES +(1,'o'), +(4,'f'); +CREATE VIEW v_t2 AS SELECT * FROM t2; +CREATE TABLE t3 LIKE t1; +INSERT INTO t3 VALUES +(1,'o'), +(4,'f'); +explain SELECT alias1.col_varchar_nokey +FROM t1 AS alias1 +INNER JOIN v_t2 AS alias2 +ON alias2.col_int_nokey = alias1.col_int_nokey AND +'o' IN (SELECT col_varchar_nokey +FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch +1 SIMPLE alias1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`alias1`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t1` `alias1` join `test`.`t2` semi join (`test`.`t3`) where ((`test`.`t3`.`col_varchar_nokey` = 'o') and (`test`.`t2`.`col_int_nokey` = `test`.`alias1`.`col_int_nokey`)) +SELECT alias1.col_varchar_nokey +FROM t1 AS alias1 +INNER JOIN v_t2 AS alias2 +ON alias2.col_int_nokey = alias1.col_int_nokey AND +'o' IN (SELECT col_varchar_nokey +FROM t3); +col_varchar_nokey +o +PREPARE stmt FROM "SELECT alias1.col_varchar_nokey +FROM t1 AS alias1 +INNER JOIN v_t2 AS alias2 +ON alias2.col_int_nokey = alias1.col_int_nokey AND +'o' IN (SELECT col_varchar_nokey +FROM t3)"; +EXECUTE stmt; +col_varchar_nokey +o +DROP VIEW v_t2; +DROP TABLE t1, t2, t3; +# End of test for bug#13339643. +# +# Bug#13424134: Wrong result on JOIN + nested WHERE ... IN clauses +# +CREATE TABLE t1 ( +pk int NOT NULL, +col_int_nokey int NOT NULL, +col_int_key int NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +) ENGINE=MyIsam; +INSERT INTO t1 VALUES +(10,1,7), (13,7,3), (18,0,1), (23,8,1); +CREATE TABLE t2 ( +pk int NOT NULL, +col_int_key int NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +) ENGINE=MyIsam; +INSERT INTO t2 VALUES (1,7); +EXPLAIN SELECT t1a.* +FROM t1 AS t1a +JOIN t1 AS t1b USING ( col_int_nokey ) +WHERE t1a.col_int_key IN ( +SELECT pk +FROM t2 +WHERE col_int_key IN ( +SELECT col_int_nokey +FROM t1 +) +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL system PRIMARY,col_int_key NULL NULL NULL 1 100.00 NULL +1 SIMPLE t1a NULL ref col_int_key col_int_key 4 const 1 100.00 NULL +1 SIMPLE t1b NULL ALL NULL NULL NULL NULL 4 25.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; FirstMatch(t1b); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1a`.`pk` AS `pk`,`test`.`t1a`.`col_int_nokey` AS `col_int_nokey`,`test`.`t1a`.`col_int_key` AS `col_int_key` from `test`.`t1` `t1a` join `test`.`t1` `t1b` semi join (`test`.`t1`) where ((`test`.`t1b`.`col_int_nokey` = `test`.`t1a`.`col_int_nokey`) and (`test`.`t1a`.`col_int_key` = '1') and (`test`.`t1`.`col_int_nokey` = '7')) +SELECT t1a.* +FROM t1 AS t1a +JOIN t1 AS t1b USING ( col_int_nokey ) +WHERE t1a.col_int_key IN ( +SELECT pk +FROM t2 +WHERE col_int_key IN ( +SELECT col_int_nokey +FROM t1 +) +); +pk col_int_nokey col_int_key +18 0 1 +23 8 1 +ALTER TABLE t1 ENGINE=Innodb; +ALTER TABLE t2 ENGINE=Innodb; +SELECT t1a.* +FROM t1 AS t1a +JOIN t1 AS t1b USING ( col_int_nokey ) +WHERE t1a.col_int_key IN ( +SELECT pk +FROM t2 +WHERE col_int_key IN ( +SELECT col_int_nokey +FROM t1 +) +); +pk col_int_nokey col_int_key +18 0 1 +23 8 1 +DROP TABLE t1, t2; +# End of test for bug#13424134. +# +# Bug#13414014: Extra rows in result on semijoin query with where ... +# +CREATE TABLE t1 ( +c INT, +d INT, +a VARCHAR(1), +b VARCHAR(1), +KEY a (a) +) charset utf8mb4; +INSERT INTO t1 VALUES +(NULL,8,'x','x'), (7,4,'q','q'), (6,8,'c','c'); +CREATE TABLE t2 ( +a VARCHAR(1), +KEY a (a) +) charset utf8mb4; +INSERT INTO t2 VALUES +('c'), (NULL), ('x'), ('q'); +explain SELECT * +FROM t2 AS ot +WHERE (a, a) IN +(SELECT a, b +FROM t1 AS it +WHERE it.a = 'x' OR it.c > it.d +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using where +1 SIMPLE ot NULL ref a a 7 .a 2 100.00 Using index +2 MATERIALIZED it NULL ALL a NULL NULL NULL 3 40.74 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`ot`.`a` AS `a` from `test`.`t2` `ot` semi join (`test`.`t1` `it`) where ((``.`b` = ``.`a`) and (`test`.`ot`.`a` = ``.`a`) and (`test`.`it`.`b` = `test`.`it`.`a`) and (((``.`a` = 'x') and (`test`.`it`.`a` = 'x') and (`test`.`it`.`b` = 'x')) or (`test`.`it`.`c` > `test`.`it`.`d`))) +SELECT * +FROM t2 AS ot +WHERE (a, a) IN +(SELECT a, b +FROM t1 AS it +WHERE it.a = 'x' OR it.c > it.d +) +; +a +q +x +DROP TABLE t1, t2; +# End of test for bug#13414014. +# +# Bug#13545215: Missing rows on nested in-subquery with materialization +# +CREATE TABLE t1 ( +col_int_key int, +col_varchar_key varchar(1), +col_varchar_nokey varchar(1), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +INSERT INTO t1 VALUES +(8,'x','x'), (0,'p','p'), (8,'c','c'); +CREATE TABLE t2 ( +pk int NOT NULL, +col_varchar_key varchar(1), +col_varchar_nokey varchar(1), +PRIMARY KEY (pk), +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4; +INSERT INTO t2 VALUES +(1,'v','v'), (2,'v','v'), (3,'c','c'), (4,NULL,NULL), +(5,'x','x'), (6,'i','i'), (7,'e','e'), (8,'p','p'); +CREATE TABLE t3 ( +col_int_nokey int +); +INSERT INTO t3 VALUES (7); +explain SELECT grandparent1.col_varchar_nokey +FROM t1 AS grandparent1 JOIN t1 AS grandparent2 USING (col_int_key) +WHERE grandparent1.col_varchar_key IN ( +SELECT col_varchar_nokey +FROM t2 AS parent1 +WHERE col_varchar_key IN ( +SELECT child1.col_varchar_nokey +FROM t2 AS child1 LEFT JOIN t3 AS child2 +ON child1.pk < child2.col_int_nokey +) +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE grandparent1 NULL ALL col_int_key,col_varchar_key NULL NULL NULL 3 100.00 Using where; Start temporary +1 SIMPLE parent1 NULL ALL col_varchar_key NULL NULL NULL 8 12.50 Using where; Using join buffer (hash join) +1 SIMPLE child1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; Using join buffer (hash join) +1 SIMPLE child2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +1 SIMPLE grandparent2 NULL ref col_int_key col_int_key 5 test.grandparent1.col_int_key 2 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`grandparent1`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t1` `grandparent1` join `test`.`t1` `grandparent2` semi join (`test`.`t2` `parent1` join `test`.`t2` `child1` left join `test`.`t3` `child2` on((`test`.`child1`.`pk` < `test`.`child2`.`col_int_nokey`))) where ((`test`.`grandparent2`.`col_int_key` = `test`.`grandparent1`.`col_int_key`) and (`test`.`parent1`.`col_varchar_nokey` = `test`.`grandparent1`.`col_varchar_key`) and (`test`.`child1`.`col_varchar_nokey` = `test`.`parent1`.`col_varchar_key`)) +SELECT grandparent1.col_varchar_nokey +FROM t1 AS grandparent1 JOIN t1 AS grandparent2 USING (col_int_key) +WHERE grandparent1.col_varchar_key IN ( +SELECT col_varchar_nokey +FROM t2 AS parent1 +WHERE col_varchar_key IN ( +SELECT child1.col_varchar_nokey +FROM t2 AS child1 LEFT JOIN t3 AS child2 +ON child1.pk < child2.col_int_nokey +) +); +col_varchar_nokey +c +c +p +x +x +DROP TABLE t1, t2, t3; +# End of test for bug#13545215. +# +# BUG#13553211 - MISSING ROWS ON SELECT WITH IN-SUBQUERY AND +# MATERIALIZATION + SEMIJOIN ON +# +CREATE TABLE t1 ( +col_int_key int(11) DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (4,'v','v'); +INSERT INTO t1 VALUES (62,'v','v'); +INSERT INTO t1 VALUES (7,'c','c'); +INSERT INTO t1 VALUES (1,NULL,NULL); +EXPLAIN SELECT +alias1.col_varchar_nokey AS a1_nokey, +alias1.col_varchar_key AS a1_key, +alias2.col_varchar_nokey AS a2_nokey +FROM +t1 AS alias1, t1 AS alias2 +WHERE +(alias1.col_varchar_nokey,alias2.col_varchar_nokey) +IN +( +SELECT +sq2_alias2.col_varchar_nokey, sq2_alias1.col_varchar_key +FROM +t1 AS sq2_alias1, t1 AS sq2_alias2 +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE alias1 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +1 SIMPLE alias2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (hash join) +1 SIMPLE NULL eq_ref 14 test.alias1.col_varchar_nokey,test.alias2.col_varchar_nokey 1 100.00 NULL +2 MATERIALIZED sq2_alias1 NULL index col_varchar_key col_varchar_key 12 NULL 4 100.00 Using index +2 MATERIALIZED sq2_alias2 NULL ALL NULL NULL NULL NULL 4 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`alias1`.`col_varchar_nokey` AS `a1_nokey`,`test`.`alias1`.`col_varchar_key` AS `a1_key`,`test`.`alias2`.`col_varchar_nokey` AS `a2_nokey` from `test`.`t1` `alias1` join `test`.`t1` `alias2` semi join (`test`.`t1` `sq2_alias1` join `test`.`t1` `sq2_alias2`) where ((``.`col_varchar_key` = `test`.`alias2`.`col_varchar_nokey`) and (``.`col_varchar_nokey` = `test`.`alias1`.`col_varchar_nokey`)) +SELECT +alias1.col_varchar_nokey AS a1_nokey, +alias1.col_varchar_key AS a1_key, +alias2.col_varchar_nokey AS a2_nokey +FROM +t1 AS alias1, t1 AS alias2 +WHERE +(alias1.col_varchar_nokey,alias2.col_varchar_nokey) +IN +( +SELECT +sq2_alias2.col_varchar_nokey, sq2_alias1.col_varchar_key +FROM +t1 AS sq2_alias1, t1 AS sq2_alias2 +) +; +a1_nokey a1_key a2_nokey +c c c +c c v +c c v +v v c +v v c +v v v +v v v +v v v +v v v +DROP TABLE t1; +# +# Bug#13541406: Wrong result with loosescan on select .. where .. in +# +CREATE TABLE t1 ( +col_int_key INT NOT NULL, +col_varchar_nokey VARCHAR(1) NOT NULL, +KEY col_int_key (col_int_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t1 VALUES +(7,'v'), (0,'s'), (9,'l'), (3,'y'), (4,'c'), (2,'i'), (5,'h'), (3,'q'), +(1,'a'), (3,'v'), (6,'u'), (7,'s'), (5,'y'), (1,'z'), (204,'h'), (224,'p'), +(9,'e'), (5,'i'), (0,'y'), (3,'w'); +CREATE TABLE t2 ( +pk INT NOT NULL, +col_int_key INT NOT NULL, +col_varchar_key VARCHAR(1) NOT NULL, +col_varchar_nokey VARCHAR(1) NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t2 VALUES +(1,0,'j','j'), (2,8,'v','v'), (3,1,'c','c'), (4,8,'m','m'), +(5,9,'d','d'), (6,24,'d','d'), (7,6,'y','y'), (8,1,'t','t'), +(9,6,'d','d'), (10,2,'s','s'), (11,4,'r','r'), (12,8,'m','m'), +(13,4,'b','b'), (14,4,'x','x'), (15,7,'g','g'), (16,4,'p','p'), +(17,1,'q','q'), (18,9,'w','w'), (19,4,'d','d'), (20,8,'e','e'); +# This query should never use a LooseScan strategy +explain SELECT ot1.col_int_key AS field1 +FROM t2 AS ot1, t2 AS ot2 +WHERE (ot1.col_varchar_key, ot2.col_varchar_nokey) IN ( +SELECT it2.col_varchar_nokey, it1.col_varchar_key +FROM t2 AS it1 JOIN t1 AS it2 ON it2.col_int_key = it1.pk); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 20 100.00 Parallel execute (1 workers) +2 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 20 100.00 NULL +2 SIMPLE it1 NULL ref PRIMARY,col_varchar_key col_varchar_key 6 test.ot2.col_varchar_nokey 1 100.00 Using index; Start temporary +2 SIMPLE it2 NULL ref col_int_key col_int_key 4 test.it1.pk 1 100.00 NULL +2 SIMPLE ot1 NULL ref col_varchar_key col_varchar_key 6 test.it2.col_varchar_nokey 1 100.00 Using index; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`col_int_key` AS `field1` from `test`.`t2` `ot1` join `test`.`t2` `ot2` semi join (`test`.`t2` `it1` join `test`.`t1` `it2`) where ((`test`.`it2`.`col_int_key` = `test`.`it1`.`pk`) and (`test`.`it1`.`col_varchar_key` = `test`.`ot2`.`col_varchar_nokey`) and (`test`.`ot1`.`col_varchar_key` = `test`.`it2`.`col_varchar_nokey`)) +SELECT ot1.col_int_key AS field1 +FROM t2 AS ot1, t2 AS ot2 +WHERE (ot1.col_varchar_key, ot2.col_varchar_nokey) IN ( +SELECT it2.col_varchar_nokey, it1.col_varchar_key +FROM t2 AS it1 JOIN t1 AS it2 ON it2.col_int_key = it1.pk); +field1 +1 +1 +1 +2 +6 +6 +6 +6 +6 +8 +8 +8 +8 +8 +8 +9 +DROP TABLE t1, t2; +# End of test for bug#13541406. +# +# Bug#13576391: Missing rows on select with in-subquery and +# batched-key-access=on and semijoin +# +CREATE TABLE t1 ( +col_int_nokey int NOT NULL, +col_varchar_key varchar(1) NOT NULL, +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4 engine=InnoDB; +INSERT INTO t1 VALUES +(1,'v'), (7,'s'), (4,'l'), (7,'y'), (0,'c'), (2,'i'), (9,'h'), (4,'q'), +(0,'a'), (9,'v'), (1,'u'), (3,'s'), (8,'y'), (8,'z'), (18,'h'), (84,'p'), +(6,'e'), (3,'i'), (6,'y'), (6,'w'); +CREATE TABLE t2 ( +col_int_nokey int NOT NULL, +col_varchar_nokey varchar(1) NOT NULL +) charset utf8mb4 engine=InnoDB; +INSERT INTO t2 VALUES +(4,'j'), (6,'v'), (3,'c'), (5,'m'), (3,'d'), (246,'d'), (2,'y'), (9,'t'), +(3,'d'), (8,'s'), (1,'r'), (8,'m'), (8,'b'), (5,'x'), (7,'g'), (5,'p'), +(1,'q'), (6,'w'), (2,'d'), (9,'e'); +explain SELECT col_varchar_nokey +FROM t2 AS ot +WHERE col_varchar_nokey IN ( +SELECT col_varchar_key +FROM t1 AS it +WHERE it.col_int_nokey <= it.col_int_nokey +AND NOT ot.col_int_nokey < 2 +) +ORDER BY col_varchar_nokey; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 20 33.33 Parallel execute (1 workers) +2 SIMPLE ot NULL ALL NULL NULL NULL NULL 20 33.33 Using where; Using filesort +2 SIMPLE it NULL ref col_varchar_key col_varchar_key 6 test.ot.col_varchar_nokey 1 100.00 FirstMatch(ot) +Warnings: +Note 1276 Field or reference 'test.ot.col_int_nokey' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`ot`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t2` `ot` semi join (`test`.`t1` `it`) where ((`test`.`it`.`col_varchar_key` = `test`.`ot`.`col_varchar_nokey`) and (`test`.`ot`.`col_int_nokey` >= 2)) order by `test`.`ot`.`col_varchar_nokey` +SELECT col_varchar_nokey +FROM t2 AS ot +WHERE col_varchar_nokey IN ( +SELECT col_varchar_key +FROM t1 AS it +WHERE it.col_int_nokey <= it.col_int_nokey +AND NOT ot.col_int_nokey < 2 +) +ORDER BY col_varchar_nokey; +col_varchar_nokey +c +e +p +s +v +w +y +ALTER TABLE t1 ENGINE=MyISAM; +ALTER TABLE t2 ENGINE=MyISAM; +explain SELECT col_varchar_nokey +FROM t2 AS ot +WHERE col_varchar_nokey IN ( +SELECT col_varchar_key +FROM t1 AS it +WHERE it.col_int_nokey <= it.col_int_nokey +AND NOT ot.col_int_nokey < 2 +) +ORDER BY col_varchar_nokey; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 20 33.33 Using where; Using filesort +1 SIMPLE it NULL ref col_varchar_key col_varchar_key 6 test.ot.col_varchar_nokey 2 100.00 FirstMatch(ot) +Warnings: +Note 1276 Field or reference 'test.ot.col_int_nokey' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`ot`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t2` `ot` semi join (`test`.`t1` `it`) where ((`test`.`it`.`col_varchar_key` = `test`.`ot`.`col_varchar_nokey`) and (`test`.`ot`.`col_int_nokey` >= 2)) order by `test`.`ot`.`col_varchar_nokey` +SELECT col_varchar_nokey +FROM t2 AS ot +WHERE col_varchar_nokey IN ( +SELECT col_varchar_key +FROM t1 AS it +WHERE it.col_int_nokey <= it.col_int_nokey +AND NOT ot.col_int_nokey < 2 +) +ORDER BY col_varchar_nokey; +col_varchar_nokey +c +e +p +s +v +w +y +ALTER TABLE t1 ENGINE=Memory; +ALTER TABLE t2 ENGINE=Memory; +explain SELECT col_varchar_nokey +FROM t2 AS ot +WHERE col_varchar_nokey IN ( +SELECT col_varchar_key +FROM t1 AS it +WHERE it.col_int_nokey <= it.col_int_nokey +AND NOT ot.col_int_nokey < 2 +) +ORDER BY col_varchar_nokey; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 20 33.33 Using where; Using filesort +1 SIMPLE it NULL ref col_varchar_key col_varchar_key 6 test.ot.col_varchar_nokey 2 100.00 FirstMatch(ot) +Warnings: +Note 1276 Field or reference 'test.ot.col_int_nokey' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`ot`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t2` `ot` semi join (`test`.`t1` `it`) where ((`test`.`it`.`col_varchar_key` = `test`.`ot`.`col_varchar_nokey`) and (`test`.`ot`.`col_int_nokey` >= 2)) order by `test`.`ot`.`col_varchar_nokey` +SELECT col_varchar_nokey +FROM t2 AS ot +WHERE col_varchar_nokey IN ( +SELECT col_varchar_key +FROM t1 AS it +WHERE it.col_int_nokey <= it.col_int_nokey +AND NOT ot.col_int_nokey < 2 +) +ORDER BY col_varchar_nokey; +col_varchar_nokey +c +e +p +s +v +w +y +DROP TABLE t1, t2; +# End of test for bug#13576391. +# +# Bug #13589848 "MISSING ROW ON SELECT WITH NESTED IN CLAUSES WHEN LOOSESCAN=ON" +# +CREATE TABLE t1 ( +id INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +KEY (col_varchar_key) +) charset utf8mb4; +INSERT INTO t1 VALUES (100,'m','m'), +(200,'b','b'), (300,'x','x'); +CREATE TABLE t2 ( +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +KEY (col_varchar_key) +) charset utf8mb4; +INSERT INTO t2 VALUES ('b','b'); +CREATE TABLE t3 ( +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +KEY (col_varchar_key) +) charset utf8mb4; +INSERT INTO t3 VALUES ('k','k'); +EXPLAIN SELECT gp1.id +FROM t1 AS gp1 JOIN t3 AS gp2 +ON gp2.col_varchar_key <> gp1.col_varchar_nokey +WHERE (gp1.col_varchar_nokey, gp1.col_varchar_nokey) +IN ( +SELECT col_varchar_nokey, col_varchar_nokey +FROM t1 +WHERE col_varchar_nokey +IN ( SELECT col_varchar_key +FROM t2 LEFT JOIN t3 USING (col_varchar_key) ) +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE gp2 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL index col_varchar_key col_varchar_key 7 NULL 1 100.00 Using where; Using index; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +1 SIMPLE gp1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ref col_varchar_key col_varchar_key 7 test.t2.col_varchar_key 2 100.00 Using index; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`gp1`.`id` AS `id` from `test`.`t1` `gp1` semi join (`test`.`t1` join `test`.`t2` left join `test`.`t3` on((`test`.`t2`.`col_varchar_key` = `test`.`t3`.`col_varchar_key`))) where ((`test`.`t1`.`col_varchar_nokey` = `test`.`t2`.`col_varchar_key`) and (`test`.`gp1`.`col_varchar_nokey` = `test`.`t2`.`col_varchar_key`) and ('k' <> `test`.`t2`.`col_varchar_key`)) +SELECT gp1.id +FROM t1 AS gp1 JOIN t3 AS gp2 +ON gp2.col_varchar_key <> gp1.col_varchar_nokey +WHERE (gp1.col_varchar_nokey, gp1.col_varchar_nokey) +IN ( +SELECT col_varchar_nokey, col_varchar_nokey +FROM t1 +WHERE col_varchar_nokey +IN ( SELECT col_varchar_key +FROM t2 LEFT JOIN t3 USING (col_varchar_key) ) +) +; +id +200 +DROP TABLE t1,t2,t3; +# +# Bug #13596176: Missing row on select with nested in clause when +# matr=on and bnl=off + MyISAM +# +CREATE TABLE t1 ( +int_key int DEFAULT NULL, +vc_key varchar(1) DEFAULT NULL, +vc_nokey varchar(1) DEFAULT NULL, +KEY int_key (int_key), +KEY vc_key (vc_key, int_key) +) charset utf8mb4 ENGINE=MyISAM; +INSERT INTO t1 VALUES +(8,'x','x'), (7,'d','d'), (1,'r','r'), (7,'f','f'), +(9,'y','y'), (NULL,'u','u'), (1,'m','m'), (9,NULL,NULL), +(2,'o','o'), (9,'w','w'), (2,'m','m'), (4,'q','q'), +(0,NULL,NULL), (4,'d','d'), (8,'g','g'), (NULL,'x','x'), +(NULL,'f','f'), (0,'p','p'), (NULL,'j','j'), (8,'c','c'); +CREATE TABLE t2 ( +int_key int DEFAULT NULL, +vc_key varchar(1) DEFAULT NULL, +KEY int_key (int_key), +KEY vc_key (vc_key, int_key) +) charset utf8mb4 ENGINE=MyISAM; +INSERT INTO t2 VALUES (8,'g'); +explain SELECT vc_key +FROM t1 as outr +WHERE (vc_nokey, vc_key ) IN +(SELECT vc_nokey, vc_nokey +FROM t1 middle +WHERE vc_nokey IN +(SELECT child1.vc_key +FROM t2 AS child1 JOIN t1 AS child2 USING (int_key) +) +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE child1 NULL index int_key,vc_key vc_key 12 NULL 1 100.00 Using where; Using index; Start temporary +1 SIMPLE outr NULL ref vc_key vc_key 7 test.child1.vc_key 3 10.00 Using where +1 SIMPLE middle NULL ALL NULL NULL NULL NULL 20 10.00 Using where; Using join buffer (hash join) +1 SIMPLE child2 NULL ref int_key int_key 5 test.child1.int_key 3 100.00 Using index; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`outr`.`vc_key` AS `vc_key` from `test`.`t1` `outr` semi join (`test`.`t1` `middle` join `test`.`t2` `child1` join `test`.`t1` `child2`) where ((`test`.`child2`.`int_key` = `test`.`child1`.`int_key`) and (`test`.`outr`.`vc_nokey` = `test`.`child1`.`vc_key`) and (`test`.`outr`.`vc_key` = `test`.`child1`.`vc_key`) and (`test`.`middle`.`vc_nokey` = `test`.`child1`.`vc_key`)) +SELECT vc_key +FROM t1 as outr +WHERE (vc_nokey, vc_key ) IN +(SELECT vc_nokey, vc_nokey +FROM t1 middle +WHERE vc_nokey IN +(SELECT child1.vc_key +FROM t2 AS child1 JOIN t1 AS child2 USING (int_key) +) +); +vc_key +g +DROP TABLE t1, t2; +# End of test for bug#13596176. +# +# BUG#11754478: MAX/MIN + SUBQUERY + AND FAILS TO RETURN ANY ROWS +# BUG#13599013: MAX/MIN + SUBQUERY IN WHERE CLAUSE MATCHING NO +# ROWS + INDEX DOES NOT RETURN NULL +# +CREATE TABLE t1 ( +pk int(11) PRIMARY KEY, +int_key int(11), +KEY int_key (int_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (1,0),(2,0),(3,2),(4,0),(5,3),(6,0); +SELECT MIN(int_key) FROM t1 WHERE (4, 4) IN (SELECT 1, 2); +MIN(int_key) +NULL +SELECT MIN(int_key) FROM t1 WHERE (4, 4) IN (SELECT 4, 4); +MIN(int_key) +0 +SELECT MIN(pk) FROM t1 WHERE pk IN (SELECT int_key FROM t1) AND pk = 6; +MIN(pk) +NULL +DROP TABLE t1; +# BUG#13726217: Crash in Item_ident::fix_after_pullout() +CREATE TABLE t1(a INTEGER) engine=innodb; +INSERT INTO t1 VALUES (0); +SELECT 0 +FROM t1 +WHERE 0 IN +(SELECT 0 +FROM t1 +WHERE 0 LIKE +(SELECT elt(a, 0) AS b +FROM t1 +GROUP BY a +HAVING b +) +); +0 +DROP TABLE t1; +# End of test for bug#13726217. +# BUG#13773979: Missing rows on second execution of prepared statement +CREATE TABLE t1 ( +col_int_nokey INT, +col_int_key INT, +col_varchar_key VARCHAR(1) +); +INSERT INTO t1 VALUES +(1,7,'v'), (7,0,'s'), (4,9,'l'), (7,3,'y'), +(2,2,'i'), (9,5,'h'), (0,1,'a'), (9,3,'v'); +CREATE VIEW v1 AS SELECT * FROM t1; +SELECT * +FROM t1 +WHERE col_int_key IN ( +SELECT alias1.col_int_nokey AS field1 +FROM v1 AS alias1 +WHERE alias1.col_varchar_key < 'v' +); +col_int_nokey col_int_key col_varchar_key +1 7 v +2 2 i +4 9 l +7 0 s +prepare stmt FROM "SELECT * +FROM t1 +WHERE col_int_key IN ( +SELECT alias1.col_int_nokey AS field1 +FROM v1 AS alias1 +WHERE alias1.col_varchar_key < 'v' +)"; +execute stmt; +col_int_nokey col_int_key col_varchar_key +1 7 v +2 2 i +4 9 l +7 0 s +execute stmt; +col_int_nokey col_int_key col_varchar_key +1 7 v +2 2 i +4 9 l +7 0 s +DEALLOCATE PREPARE stmt; +DROP VIEW v1; +DROP TABLE t1; +# End of test for bug#13773979. +# +# BUG#13685026 ASSERTION CUR_SJ_INNER_TABLES == 0 IN +# --OPTIMIZE_TABLE_ORDER::CHOOSE_TABLE_ORDER +# +CREATE TABLE t1 ( +col_int_key INT(11) NOT NULL, +col_datetime_key DATETIME NOT NULL, +col_varchar_key VARCHAR(1) NOT NULL, +col_varchar_nokey VARCHAR(1) NOT NULL, +KEY col_int_key (col_int_key), +KEY col_datetime_key (col_datetime_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (0,'2002-02-13 17:30:06','j','j'); +INSERT INTO t1 VALUES (8,'2008-09-27 00:34:58','v','v'); +CREATE TABLE t2 ( +col_int_key INT(11) NOT NULL, +col_datetime_key DATETIME NOT NULL, +col_varchar_key VARCHAR(1) NOT NULL, +col_varchar_nokey VARCHAR(1) NOT NULL, +KEY col_int_key (col_int_key), +KEY col_datetime_key (col_datetime_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (7,'2003-08-21 00:00:00','b','b'); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +SET @old_depth=@@optimizer_search_depth; +SET optimizer_search_depth=4; +EXPLAIN SELECT col_datetime_key +FROM t1 as outr +WHERE col_datetime_key IN ( +SELECT alias1.col_datetime_key +FROM t1 AS alias1 +LEFT JOIN t1 as alias3 +STRAIGHT_JOIN ( t2 AS alias4 +JOIN t1 AS alias5 +ON alias5.col_varchar_key <= alias4.col_varchar_nokey ) +ON alias5.col_int_key < alias4.col_int_key +ON alias5.col_varchar_key = alias4.col_varchar_key +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE outr NULL index col_datetime_key col_datetime_key 5 NULL 2 100.00 Using index +1 SIMPLE alias1 NULL ref col_datetime_key col_datetime_key 5 test.outr.col_datetime_key 1 100.00 Using index +1 SIMPLE alias4 NULL ALL col_int_key,col_varchar_key NULL NULL NULL 1 100.00 NULL +1 SIMPLE alias5 NULL ref col_int_key,col_varchar_key col_varchar_key 6 test.alias4.col_varchar_key 1 100.00 Using where; Using index +1 SIMPLE alias3 NULL index NULL col_int_key 4 NULL 2 100.00 Using index; FirstMatch(outr) +Warnings: +Note 1003 /* select#1 */ select `test`.`outr`.`col_datetime_key` AS `col_datetime_key` from `test`.`t1` `outr` semi join (`test`.`t1` `alias1` left join (`test`.`t1` `alias3` join `test`.`t2` `alias4` join `test`.`t1` `alias5`) on(((`test`.`alias5`.`col_varchar_key` = `test`.`alias4`.`col_varchar_key`) and (`test`.`alias5`.`col_int_key` < `test`.`alias4`.`col_int_key`) and (`test`.`alias5`.`col_varchar_key` <= `test`.`alias4`.`col_varchar_nokey`)))) where (`test`.`alias1`.`col_datetime_key` = `test`.`outr`.`col_datetime_key`) +SELECT col_datetime_key +FROM t1 as outr +WHERE col_datetime_key IN ( +SELECT alias1.col_datetime_key +FROM t1 AS alias1 +LEFT JOIN t1 as alias3 +STRAIGHT_JOIN ( t2 AS alias4 +JOIN t1 AS alias5 +ON alias5.col_varchar_key <= alias4.col_varchar_nokey ) +ON alias5.col_int_key < alias4.col_int_key +ON alias5.col_varchar_key = alias4.col_varchar_key +); +col_datetime_key +2002-02-13 17:30:06 +2008-09-27 00:34:58 +DROP TABLE t1,t2; +SET @@optimizer_search_depth=@old_depth; +# +# BUG#13848789: SEGFAULT IN JOIN_READ_NEXT_SAME AT +# SQL/SQL_EXECUTOR.CC ON HAVING...IN...JOIN +# +CREATE TABLE t1 ( +col_int_key INT, +col_varchar_key VARCHAR(1), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4; +INSERT INTO t1 VALUES (8,'x'); +CREATE TABLE t2 ( +col_varchar_key VARCHAR(1), +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4; +INSERT INTO t2 VALUES ('x'), ('y'); +explain SELECT MIN(col_int_key) +FROM t1 as t1_outer +HAVING (1, 2) IN ( +SELECT t1_inner.col_int_key, MAX(t1_inner.col_int_key) +FROM t1 as t1_inner JOIN t2 +ON t2.col_varchar_key = t1_inner.col_varchar_key +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible HAVING +2 SUBQUERY t1_inner NULL system col_varchar_key NULL NULL NULL 1 100.00 NULL +2 SUBQUERY t2 NULL ref col_varchar_key col_varchar_key 7 const 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select min(`test`.`t1_outer`.`col_int_key`) AS `MIN(col_int_key)` from `test`.`t1` `t1_outer` having false +SELECT MIN(col_int_key) +FROM t1 as t1_outer +HAVING (1, 2) IN ( +SELECT t1_inner.col_int_key, MAX(t1_inner.col_int_key) +FROM t1 as t1_inner JOIN t2 +ON t2.col_varchar_key = t1_inner.col_varchar_key +); +MIN(col_int_key) +DROP TABLE t1,t2; +# Bug#13838810: Segfault in evaluate_null_complemented_join_record +CREATE TABLE t1 ( +pk int NOT NULL, +col_int_nokey int DEFAULT NULL, +col_int_key int DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t1 VALUES (10,NULL,8,'x'); +CREATE TABLE t2 ( +pk int NOT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +PRIMARY KEY (pk) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t2 VALUES (1,'x'); +CREATE TABLE t3 ( +pk int NOT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +PRIMARY KEY (pk), +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t3 VALUES +(1,'v','v'), (2,'v','v'), (3,'c','c'), (4,NULL,NULL); +EXPLAIN SELECT table1.pk,table2.pk, table3.pk +FROM t2 AS table1 +LEFT JOIN t1 AS table2 +LEFT JOIN t1 AS table3 +ON table3.col_int_key = table2.col_int_key +ON table3.pk = table2.col_int_nokey AND +table1.col_varchar_nokey IN ( +SELECT subquery3_t1.col_varchar_nokey +FROM t3 AS subquery3_t1 +LEFT JOIN t1 AS subquery3_t2 +ON subquery3_t2.col_varchar_key = subquery3_t1.col_varchar_key +WHERE subquery3_t2.col_int_nokey <> 9 +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE table1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE table2 NULL ALL col_int_key NULL NULL NULL 1 100.00 NULL +2 SIMPLE table3 NULL eq_ref PRIMARY,col_int_key PRIMARY 4 test.table2.col_int_nokey 1 100.00 Using where +2 SIMPLE subquery3_t2 NULL ALL col_varchar_key NULL NULL NULL 1 100.00 Using where +2 SIMPLE subquery3_t1 NULL ref col_varchar_key col_varchar_key 7 test.subquery3_t2.col_varchar_key 1 100.00 Using where; FirstMatch(table3) +Warnings: +Note 1003 /* select#1 */ select `test`.`table1`.`pk` AS `pk`,`test`.`table2`.`pk` AS `pk`,`test`.`table3`.`pk` AS `pk` from `test`.`t2` `table1` left join (`test`.`t1` `table2` join `test`.`t1` `table3` semi join (`test`.`t3` `subquery3_t1` join `test`.`t1` `subquery3_t2`)) on(((`test`.`table3`.`col_int_key` = `test`.`table2`.`col_int_key`) and (`test`.`subquery3_t1`.`col_varchar_key` = `test`.`subquery3_t2`.`col_varchar_key`) and (`test`.`subquery3_t1`.`col_varchar_nokey` = `test`.`table1`.`col_varchar_nokey`) and (`test`.`table3`.`pk` = `test`.`table2`.`col_int_nokey`) and (`test`.`subquery3_t2`.`col_int_nokey` <> 9))) where true +SELECT table1.pk,table2.pk, table3.pk +FROM t2 AS table1 +LEFT JOIN t1 AS table2 +LEFT JOIN t1 AS table3 +ON table3.col_int_key = table2.col_int_key +ON table3.pk = table2.col_int_nokey AND +table1.col_varchar_nokey IN ( +SELECT subquery3_t1.col_varchar_nokey +FROM t3 AS subquery3_t1 +LEFT JOIN t1 AS subquery3_t2 +ON subquery3_t2.col_varchar_key = subquery3_t1.col_varchar_key +WHERE subquery3_t2.col_int_nokey <> 9 +) +; +pk pk pk +1 NULL NULL +DROP TABLE t1, t2, t3; +Extra test case for specific code coverage +CREATE TABLE t1(pk INTEGER); +INSERT INTO t1 VALUES(1), (2); +explain SELECT * +FROM t1 AS ot1 LEFT JOIN t1 AS ot2 +ON ot1.pk=ot2.pk AND +ot2.pk IN +(SELECT it1.pk +FROM t1 AS it1 LEFT JOIN t1 AS it2 ON it1.pk=it2.pk); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE NULL eq_ref 5 test.ot2.pk 1 100.00 Using where +2 MATERIALIZED it1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED it2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`pk` AS `pk`,`test`.`ot2`.`pk` AS `pk` from `test`.`t1` `ot1` left join (`test`.`t1` `ot2` semi join (`test`.`t1` `it1` left join `test`.`t1` `it2` on((`test`.`it1`.`pk` = `test`.`it2`.`pk`)))) on(((`test`.`ot2`.`pk` = `test`.`ot1`.`pk`) and (``.`pk` = `test`.`ot1`.`pk`))) where true +SELECT * +FROM t1 AS ot1 LEFT JOIN t1 AS ot2 +ON ot1.pk=ot2.pk AND +ot2.pk IN +(SELECT it1.pk +FROM t1 AS it1 LEFT JOIN t1 AS it2 ON it1.pk=it2.pk); +pk pk +1 1 +2 2 +DROP TABLE t1; +# End of test for bug#13838810. +# +# Bug#13845930: Segfault in st_join_table::and_with_condition +# +CREATE TABLE t1 ( +col_int INTEGER +); +CREATE TABLE t2 ( +col_varchar_1 VARCHAR(1), +col_varchar_2 VARCHAR(1) +); +INSERT INTO t2 VALUES ('x','x'), ('c','c'); +PREPARE stmt FROM ' +SELECT alias2.col_varchar_2 AS field1 +FROM t2 AS alias1 + JOIN + (t2 AS alias2 + LEFT JOIN t2 AS alias3 + ON (8, 92) IN + (SELECT sq1_alias1.col_int, + sq1_alias2.col_int + FROM t1 AS sq1_alias1 JOIN t1 AS sq1_alias2 + ) + ) + ON alias3.col_varchar_1 = alias2.col_varchar_2 +'; +EXECUTE stmt; +field1 + +EXECUTE stmt; +field1 +DEALLOCATE prepare stmt; +DROP TABLE t1, t2; +# End of test for bug#13845930. +# +# Bug#13855925: Assert 'prebuilt->search_tuple->n_fields > 0' +# in ha_innobase::index_read +# +CREATE TABLE t1 ( +pk INTEGER AUTO_INCREMENT, +col_int_nokey INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk), +KEY (col_varchar_key) +) charset utf8mb4 ENGINE=INNODB; +INSERT INTO t1 ( +col_int_key, col_int_nokey, +col_varchar_key, col_varchar_nokey +) VALUES +(4, 2, 'v','v'), (62, 150, 'v','v'), (7, NULL, 'c','c'), (1, 2, NULL, NULL), +(0, 5, 'x','x'), (7, 3, 'i','i'), (7, 1, 'e','e'), (1, 4, 'p','p'), +(7, NULL, 's','s'), (1, 2, 'j','j'), (5, 6, 'z','z'), (2, 6, 'c','c'), +(0, 8, 'a','a'), (1, 2, 'q','q'), (8, 6, 'y','y'), (1, 8, NULL, NULL), +(1, 3, 'r','r'), (9, 3, 'v','v'), (1, 9, NULL, NULL), (5, 6, 'r','r'); +CREATE TABLE t2 ( +pk INT AUTO_INCREMENT, +col_int_nokey INT, +col_int_key INT, +PRIMARY KEY (pk), +KEY (col_int_key) +) charset utf8mb4 AUTO_INCREMENT=10 ENGINE=INNODB; +INSERT INTO t2 (col_int_key, col_int_nokey) VALUES +(8, NULL), (7, 8), (1, 1), (7, 9), (9, 4), (NULL, 3), (1, 2), (9, NULL), +(2, 2), (9, NULL), (2, 6), (4, 7), (0, 2), (4, 5), (8, 7), (NULL, 6), +(NULL, 6), (0, 2), (NULL, 9), (8, 6); +CREATE TABLE t3 ( +pk INT AUTO_INCREMENT, +col_varchar_key VARCHAR(1), +PRIMARY KEY (pk), +KEY (col_varchar_key) +) charset utf8mb4 ENGINE=INNODB; +INSERT INTO t3 (col_varchar_key) VALUES +('c'), ('c'), ('q'), ('g'), ('e'), ('l'), (NULL), ('c'), ('h'), ('d'), +('c'), ('i'), ('t'), ('g'), ('q'), ('l'), ('n'), ('z'), ('n'), ('r'), ('p'); +CREATE VIEW v1 AS +SELECT table2.col_varchar_nokey AS field1 +FROM t2 AS table1 +INNER JOIN (t1 AS table2 +STRAIGHT_JOIN t2 AS table3 +ON table3.col_int_key = table2.pk AND +table3.col_int_nokey = ANY +(SELECT subquery1_t2.col_int_nokey AS subquery1_field1 +FROM t2 AS subquery1_t1 +RIGHT OUTER JOIN t1 AS subquery1_t2 +INNER JOIN t1 AS subquery1_t3 +ON subquery1_t3.col_int_key = subquery1_t2.pk +ON subquery1_t3.col_varchar_key=subquery1_t2.col_varchar_nokey +WHERE subquery1_t1.pk > 1 +) +) +ON table3.col_int_key IN +(SELECT subquery2_t1.col_int_key AS subquery2_field1 +FROM t2 AS subquery2_t1 +RIGHT OUTER JOIN t3 AS subquery2_t2 +LEFT OUTER JOIN t1 AS subquery2_t3 +ON subquery2_t3.col_varchar_key = subquery2_t2.col_varchar_key +ON subquery2_t3.pk = subquery2_t2.pk +) +; +explain SELECT * FROM v1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE table1 NULL index NULL col_int_key 5 NULL 20 100.00 Using index +1 SIMPLE table2 NULL ALL PRIMARY NULL NULL NULL 20 100.00 Using join buffer (hash join) +1 SIMPLE table3 NULL ref col_int_key col_int_key 5 test.table2.pk 2 100.00 Using where +1 SIMPLE NULL eq_ref 5 test.table3.col_int_nokey 1 100.00 NULL +1 SIMPLE NULL eq_ref 5 test.table2.pk 1 100.00 NULL +4 MATERIALIZED subquery1_t3 NULL ALL col_varchar_key NULL NULL NULL 20 100.00 Using where +4 MATERIALIZED subquery1_t2 NULL eq_ref PRIMARY PRIMARY 4 test.subquery1_t3.col_int_key 1 10.00 Using where +4 MATERIALIZED subquery1_t1 NULL index PRIMARY col_int_key 5 NULL 20 100.00 Using where; Using index; Using join buffer (hash join) +3 MATERIALIZED subquery2_t3 NULL index PRIMARY,col_varchar_key col_varchar_key 7 NULL 20 100.00 Using where; Using index +3 MATERIALIZED subquery2_t2 NULL eq_ref PRIMARY,col_varchar_key PRIMARY 4 test.subquery2_t3.pk 1 7.14 Using where +3 MATERIALIZED subquery2_t1 NULL index col_int_key col_int_key 5 NULL 20 100.00 Using index; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `table2`.`col_varchar_nokey` AS `field1` from `test`.`t2` `table1` join `test`.`t1` `table2` straight_join `test`.`t2` `table3` semi join (`test`.`t1` `subquery1_t2` join `test`.`t1` `subquery1_t3` join `test`.`t2` `subquery1_t1`) semi join (`test`.`t3` `subquery2_t2` join `test`.`t1` `subquery2_t3` join `test`.`t2` `subquery2_t1`) where ((`subquery1_t2`.`pk` = `subquery1_t3`.`col_int_key`) and (`subquery1_t2`.`col_varchar_nokey` = `subquery1_t3`.`col_varchar_key`) and (`subquery2_t2`.`col_varchar_key` = `subquery2_t3`.`col_varchar_key`) and (`subquery2_t2`.`pk` = `subquery2_t3`.`pk`) and (`table3`.`col_int_key` = `table2`.`pk`) and (``.`subquery2_field1` = `table2`.`pk`) and (``.`subquery1_field1` = `table3`.`col_int_nokey`) and (`subquery1_t1`.`pk` > 1)) +SELECT * FROM v1; +field1 +v +v +v +v +v +v +v +v +v +v +v +v +v +v +v +v +v +v +v +v +DROP VIEW v1; +DROP TABLE t1,t2,t3; +# End of test for bug#13855925. +# +# Bug#13897959: Segfault in setup_semijoin_dups_elimination() +# +CREATE TABLE t1 ( +col_datetime_key DATETIME DEFAULT NULL, +KEY col_datetime_key (col_datetime_key) +) ENGINE=MyISAM; +INSERT INTO t1 VALUES +('2001-04-18 00:00:00'), ('2008-12-18 19:39:55'), +('2000-08-01 12:19:39'), ('2004-09-25 21:29:06'), +('2009-09-20 09:11:48'), ('2004-03-27 09:32:04'); +CREATE TABLE t2 ( +col_date_nokey date DEFAULT NULL, +col_time_key time DEFAULT NULL, +col_datetime_key datetime DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +KEY col_time_key (col_time_key), +KEY col_datetime_key (col_datetime_key), +KEY col_varchar_key(col_varchar_key) +) ENGINE=MyISAM; +INSERT INTO t2 VALUES ('1900-01-01',NULL,'2001-11-04 19:07:55','x','x'); +SELECT grandparent1.col_varchar_nokey +FROM t2 AS grandparent1 LEFT JOIN t1 USING (col_datetime_key) +WHERE grandparent1.col_varchar_nokey IN ( +SELECT col_varchar_nokey +FROM t2 AS parent1 +WHERE parent1.col_time_key > grandparent1.col_date_nokey +); +col_varchar_nokey +DROP TABLE t1, t2; +# End of test for bug#13897959. +# +# Bug#13898625 ASSERT `(REMAINING_TABLES_AFTER != 0) ...' IN +# BEST_EXTENSION_BY_LIMITED_SEARCH +# +CREATE TABLE t1 ( +pk int(11) NOT NULL, +col_int_nokey INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (26,6,NULL,'f','f'); +INSERT INTO t1 VALUES (29,6,8,'c','c'); +CREATE TABLE t2 ( +pk INT NOT NULL, +col_int_nokey INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +INSERT INTO t2 VALUES (1,2,4,'v','v'); +INSERT INTO t2 VALUES (2,150,62,'v','v'); +INSERT INTO t2 VALUES (5,5,0,'x','x'); +INSERT INTO t2 VALUES (6,3,7,'i','i'); +INSERT INTO t2 VALUES (7,1,7,'e','e'); +CREATE VIEW view_c AS SELECT * FROM t2; +PREPARE prep_stmt_7430 FROM 'SELECT SUM( alias1.col_varchar_key ) AS field1 +FROM t1 AS alias1 +RIGHT JOIN t2 AS alias2 +INNER JOIN t1 AS alias3 +ON (alias3.col_varchar_key = alias2.col_varchar_key ) +ON ( "v" ) IN ( +SELECT sq1_alias1.col_varchar_nokey AS sq1_field1 +FROM t1 AS sq1_alias1 +) +WHERE alias3.pk IN ( +SELECT sq2_alias1.col_int_key AS sq2_field1 +FROM ( view_c AS sq2_alias1, t1 AS sq2_alias2 ) +) +'; +EXECUTE prep_stmt_7430; +field1 +NULL +EXECUTE prep_stmt_7430; +field1 +NULL +EXPLAIN SELECT SUM( alias1.col_varchar_key ) AS field1 +FROM t1 AS alias1 +RIGHT JOIN t2 AS alias2 +INNER JOIN t1 AS alias3 +ON (alias3.col_varchar_key = alias2.col_varchar_key ) +ON ( "v" ) IN ( +SELECT sq1_alias1.col_varchar_nokey AS sq1_field1 +FROM t1 AS sq1_alias1 +) +WHERE alias3.pk IN ( +SELECT sq2_alias1.col_int_key AS sq2_field1 +FROM ( view_c AS sq2_alias1, t1 AS sq2_alias2 ) +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE alias3 NULL ALL PRIMARY,col_varchar_key NULL NULL NULL 2 100.00 Using where +1 SIMPLE sq2_alias2 NULL index NULL PRIMARY 4 NULL 2 100.00 Using index +1 SIMPLE t2 NULL ref col_int_key col_int_key 5 test.alias3.pk 2 100.00 Using index; FirstMatch(alias3) +1 SIMPLE alias2 NULL ref col_varchar_key col_varchar_key 7 test.alias3.col_varchar_key 2 100.00 Using index +1 SIMPLE alias1 NULL index NULL col_varchar_key 12 NULL 2 100.00 Using index +1 SIMPLE sq1_alias1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch(alias1) +Warnings: +Note 1003 /* select#1 */ select sum(`test`.`alias1`.`col_varchar_key`) AS `field1` from `test`.`t2` `alias2` join `test`.`t1` `alias3` left join (`test`.`t1` `alias1` semi join (`test`.`t1` `sq1_alias1`)) on(((`test`.`sq1_alias1`.`col_varchar_nokey` = 'v'))) semi join (`test`.`t2` join `test`.`t1` `sq2_alias2`) where ((`test`.`alias2`.`col_varchar_key` = `test`.`alias3`.`col_varchar_key`) and (`test`.`t2`.`col_int_key` = `test`.`alias3`.`pk`)) +PREPARE prep_stmt_7430 FROM 'SELECT SUM( alias1.col_varchar_key ) AS field1 +FROM t1 AS alias1 +RIGHT JOIN t2 AS alias2 +INNER JOIN t1 AS alias3 +ON (alias3.col_varchar_key = alias2.col_varchar_key ) +ON ( "v" ) IN ( +SELECT sq1_alias1.col_varchar_nokey AS sq1_field1 +FROM t1 AS sq1_alias1 +) +WHERE alias3.pk IN ( +SELECT sq2_alias1.col_int_key AS sq2_field1 +FROM ( view_c AS sq2_alias1 , t1 AS sq2_alias2 ) +WHERE sq2_alias1.col_varchar_nokey <> alias2.col_varchar_key +AND sq2_alias1.col_varchar_key < "l" + ) +'; +EXECUTE prep_stmt_7430; +field1 +NULL +EXECUTE prep_stmt_7430; +field1 +NULL +EXPLAIN SELECT SUM( alias1.col_varchar_key ) AS field1 +FROM t1 AS alias1 +RIGHT JOIN t2 AS alias2 +INNER JOIN t1 AS alias3 +ON (alias3.col_varchar_key = alias2.col_varchar_key ) +ON ( "v" ) IN ( +SELECT sq1_alias1.col_varchar_nokey AS sq1_field1 +FROM t1 AS sq1_alias1 +) +WHERE alias3.pk IN ( +SELECT sq2_alias1.col_int_key AS sq2_field1 +FROM ( view_c AS sq2_alias1 , t1 AS sq2_alias2 ) +WHERE sq2_alias1.col_varchar_nokey <> alias2.col_varchar_key +AND sq2_alias1.col_varchar_key < "l" + ) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE alias3 NULL ALL PRIMARY,col_varchar_key NULL NULL NULL 2 100.00 Using where; Start temporary +1 SIMPLE t2 NULL ref col_int_key,col_varchar_key col_int_key 5 test.alias3.pk 2 40.00 Using where +1 SIMPLE alias2 NULL ref col_varchar_key col_varchar_key 7 test.alias3.col_varchar_key 2 100.00 Using index +1 SIMPLE sq2_alias2 NULL index NULL PRIMARY 4 NULL 2 100.00 Using index; End temporary; Using join buffer (hash join) +1 SIMPLE alias1 NULL index NULL col_varchar_key 12 NULL 2 100.00 Using index +1 SIMPLE sq1_alias1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch(alias1) +Warnings: +Note 1276 Field or reference 'test.alias2.col_varchar_key' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select sum(`test`.`alias1`.`col_varchar_key`) AS `field1` from `test`.`t2` `alias2` join `test`.`t1` `alias3` left join (`test`.`t1` `alias1` semi join (`test`.`t1` `sq1_alias1`)) on(((`test`.`sq1_alias1`.`col_varchar_nokey` = 'v'))) semi join (`test`.`t2` join `test`.`t1` `sq2_alias2`) where ((`test`.`alias2`.`col_varchar_key` = `test`.`alias3`.`col_varchar_key`) and (`test`.`t2`.`col_int_key` = `test`.`alias3`.`pk`) and (`test`.`t2`.`col_varchar_nokey` <> `test`.`alias3`.`col_varchar_key`) and (`test`.`t2`.`col_varchar_key` < 'l')) +DROP TABLE t1,t2; +DROP VIEW view_c; +# +# Bug#13902463 SEGFAULT IN BITMAP<64U>::MERGE OR ADD_KEY_FIELD +# ON SECOND EXEC OF PREP STMT +# +CREATE TABLE t1 ( +pk INT, +col_int_nokey INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +KEY col_varchar_key (col_varchar_key) +); +CREATE VIEW view_b AS SELECT * FROM t1; +PREPARE prep_stmt_20421 FROM 'SELECT alias2.col_varchar_nokey AS field1 +FROM t1 AS alias1 +INNER JOIN t1 AS alias2 +ON (alias1.col_varchar_key = alias2.col_varchar_nokey +AND ( alias1.col_int_key ) IN ( +SELECT t1.col_int_nokey +FROM t1 +) +) +WHERE alias1.col_varchar_key IN ( +SELECT sq2_alias2.col_varchar_nokey AS sq2_field1 +FROM view_b AS sq2_alias1 +INNER JOIN t1 AS sq2_alias2 +ON (sq2_alias2.col_varchar_key = sq2_alias1.col_varchar_key ) +WHERE sq2_alias1.pk > alias2.pk +) +'; +EXECUTE prep_stmt_20421; +field1 +EXECUTE prep_stmt_20421; +field1 +EXPLAIN SELECT alias2.col_varchar_nokey AS field1 +FROM t1 AS alias1 +INNER JOIN t1 AS alias2 +ON (alias1.col_varchar_key = alias2.col_varchar_nokey +AND ( alias1.col_int_key ) IN ( +SELECT t1.col_int_nokey +FROM t1 +) +) +WHERE alias1.col_varchar_key IN ( +SELECT sq2_alias2.col_varchar_nokey AS sq2_field1 +FROM view_b AS sq2_alias1 +INNER JOIN t1 AS sq2_alias2 +ON (sq2_alias2.col_varchar_key = sq2_alias1.col_varchar_key ) +WHERE sq2_alias1.pk > alias2.pk +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.alias2.pk' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `field1` from `test`.`t1` `alias1` join `test`.`t1` `alias2` semi join (`test`.`t1`) semi join (`test`.`t1` join `test`.`t1` `sq2_alias2`) where ((`test`.`t1`.`pk` > NULL) and multiple equal(NULL, `test`.`sq2_alias2`.`col_varchar_nokey`, NULL) and multiple equal(`test`.`sq2_alias2`.`col_varchar_key`, `test`.`t1`.`col_varchar_key`) and multiple equal(NULL, `test`.`t1`.`col_int_nokey`)) +ALTER TABLE t1 DROP INDEX col_varchar_key; +PREPARE prep_stmt_20421 FROM 'SELECT alias2.col_varchar_nokey AS field1 +FROM t1 AS alias1 +INNER JOIN t1 AS alias2 +ON (alias1.col_varchar_key = alias2.col_varchar_nokey +AND ( alias1.col_int_key ) IN ( +SELECT t1.col_int_nokey +FROM t1 +) +) +WHERE alias1.col_varchar_key IN ( +SELECT sq2_alias2.col_varchar_nokey AS sq2_field1 +FROM view_b AS sq2_alias1 +INNER JOIN t1 AS sq2_alias2 +ON (sq2_alias2.col_varchar_key = sq2_alias1.col_varchar_key ) +WHERE sq2_alias1.pk > alias2.pk +) +'; +EXECUTE prep_stmt_20421; +field1 +EXECUTE prep_stmt_20421; +field1 +EXPLAIN SELECT alias2.col_varchar_nokey AS field1 +FROM t1 AS alias1 +INNER JOIN t1 AS alias2 +ON (alias1.col_varchar_key = alias2.col_varchar_nokey +AND ( alias1.col_int_key ) IN ( +SELECT t1.col_int_nokey +FROM t1 +) +) +WHERE alias1.col_varchar_key IN ( +SELECT sq2_alias2.col_varchar_nokey AS sq2_field1 +FROM view_b AS sq2_alias1 +INNER JOIN t1 AS sq2_alias2 +ON (sq2_alias2.col_varchar_key = sq2_alias1.col_varchar_key ) +WHERE sq2_alias1.pk > alias2.pk +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.alias2.pk' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `field1` from `test`.`t1` `alias1` join `test`.`t1` `alias2` semi join (`test`.`t1`) semi join (`test`.`t1` join `test`.`t1` `sq2_alias2`) where ((`test`.`t1`.`pk` > NULL) and multiple equal(NULL, `test`.`sq2_alias2`.`col_varchar_nokey`, NULL) and multiple equal(`test`.`sq2_alias2`.`col_varchar_key`, `test`.`t1`.`col_varchar_key`) and multiple equal(NULL, `test`.`t1`.`col_int_nokey`)) +DROP TABLE t1; +DROP VIEW view_b; +# +# Bug#13907277: Segfault in evaluate_null_complemented_join_record +# +CREATE TABLE t1 ( +pk INTEGER, +col_varchar_nokey VARCHAR(1), +col_varchar_key VARCHAR(1), +PRIMARY KEY (pk) +); +INSERT INTO t1 VALUES (1, 'x', 'x'); +CREATE TABLE t2 ( +pk INTEGER, +PRIMARY KEY (pk) +); +INSERT INTO t2 VALUES (1); +CREATE TABLE t3 ( +pk INTEGER, +col_int_nokey INTEGER, +col_int_key INTEGER, +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk) +); +INSERT INTO t3 VALUES (1, 6, 5, 'r'); +explain SELECT outer_t1.pk, outer_t2.pk +FROM t3 AS outer_t1 +RIGHT JOIN t2 AS outer_t2 +ON outer_t1.col_int_nokey IN +(SELECT inner_t1.col_int_nokey +FROM t3 AS inner_t1 +LEFT JOIN t1 AS inner_t2 +INNER JOIN t1 AS inner_t3 +ON inner_t3.pk = inner_t2.pk +ON inner_t3.col_varchar_nokey = inner_t2.col_varchar_key +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE outer_t2 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE outer_t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE inner_t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE inner_t2 NULL ALL PRIMARY NULL NULL NULL 1 100.00 NULL +1 SIMPLE inner_t3 NULL eq_ref PRIMARY PRIMARY 4 test.inner_t2.pk 1 100.00 Using where; FirstMatch(outer_t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`outer_t1`.`pk` AS `pk`,'1' AS `pk` from left join (`test`.`t3` `outer_t1` semi join (`test`.`t3` `inner_t1` left join (`test`.`t1` `inner_t2` join `test`.`t1` `inner_t3`) on(((`test`.`inner_t3`.`col_varchar_nokey` = `test`.`inner_t2`.`col_varchar_key`) and (`test`.`inner_t3`.`pk` = `test`.`inner_t2`.`pk`))))) on(((`test`.`inner_t1`.`col_int_nokey` = `test`.`outer_t1`.`col_int_nokey`))) where true +SELECT outer_t1.pk, outer_t2.pk +FROM t3 AS outer_t1 +RIGHT JOIN t2 AS outer_t2 +ON outer_t1.col_int_nokey IN +(SELECT inner_t1.col_int_nokey +FROM t3 AS inner_t1 +LEFT JOIN t1 AS inner_t2 +INNER JOIN t1 AS inner_t3 +ON inner_t3.pk = inner_t2.pk +ON inner_t3.col_varchar_nokey = inner_t2.col_varchar_key +); +pk pk +1 1 +DROP TABLE t1, t2, t3; +# End of test for bug#13907277. +# +# Bug#13955713: Assert 'JOIN->best_read < ...' on second execution +# +CREATE TABLE t1 ( +pk INTEGER, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1) +); +PREPARE stmt FROM " +SELECT MIN(alias2.col_varchar_key) AS field1 +FROM t1 AS alias1 + INNER JOIN (t1 AS alias2 + INNER JOIN t1 AS alias3 + ON 8 IN + (SELECT sq1_alias1.pk AS sq1_field2 + FROM t1 AS sq1_alias1 + WHERE 9 IN + (SELECT SUM(t1_sq1_alias1.pk) AS t1_sq1_field2 + FROM t1 AS t1_sq1_alias1 + ) + ) + ) + ON alias3.col_varchar_nokey = alias2.col_varchar_key +WHERE EXISTS + (SELECT sq2_alias1.pk AS sq2_field1 + FROM t1 AS sq2_alias1 + WHERE sq2_alias1.col_varchar_key < alias1.col_varchar_nokey + ) +"; +EXECUTE stmt; +field1 +NULL + +EXECUTE stmt; +field1 +NULL +DEALLOCATE PREPARE stmt; +DROP TABLE t1; +# End of test for bug#13955713. +# +# Bug#13956813: Segfault in memcpy from Join_cache::write_record_data() +# +CREATE TABLE t1 ( +pk INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1) +) charset latin1; +CREATE TABLE t2 ( +pk INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1) +) charset latin1; +INSERT INTO t2 VALUES +(10,'j','j'), (11,'z','z'), (12,'c','c'), (13,'a','a'), +(14,'q','q'), (15,'y','y'), (16,NULL,NULL), (17,'r','r'), +(18,'v','v'), (19,NULL,NULL), (20,'r','r'); +CREATE TABLE t3 ( +pk INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +KEY col_int_key (col_int_key) +) charset latin1; +INSERT INTO t3 VALUES +(15,NULL,'u'), (16,1,'m'), (17,9,NULL), (18,2,'o'), +(19,9,'w'), (20,2,'m'), (21,4,'q'), (22,0,NULL), +(23,4,'d'), (24,8,'g'), (25,NULL,'x'), (26,NULL,'f'), +(27,0,'p'), (28,NULL,'j'), (29,8,'c'); +CREATE VIEW view_inline_0 AS +SELECT t1.* +FROM t1 INNER JOIN t3 +ON t1.pk = t3.pk; +CREATE VIEW view_inline_1 AS +SELECT sq2_alias2.col_varchar_key AS sq2_field1, +sq2_alias1.col_varchar_key AS sq2_field2 +FROM t3 AS sq2_alias1 LEFT OUTER JOIN t3 AS sq2_alias2 +ON sq2_alias1.pk = sq2_alias2.col_int_key; +CREATE VIEW view_inline_2 AS +SELECT 'p', 'p' UNION SELECT 'k', 's'; +SET @optimizer_switch_saved= @@optimizer_switch; +SET @@optimizer_switch="derived_merge=off"; +explain SELECT SUM(alias1.col_varchar_nokey) AS field2 +FROM t2 AS alias2 +LEFT JOIN (SELECT * FROM view_inline_0) AS alias1 +ON alias2.col_varchar_key = alias1.col_varchar_key AND +(alias2.col_varchar_nokey, alias2.col_varchar_key) IN +(SELECT * FROM view_inline_1 +) +WHERE (alias1.col_varchar_key, alias1.col_varchar_nokey) IN +(SELECT * FROM view_inline_2 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL 2 100.00 NULL +1 PRIMARY alias2 NULL ALL NULL NULL NULL NULL 11 10.00 Using where; Using join buffer (hash join) +1 PRIMARY NULL ref 8 test.alias2.col_varchar_nokey,test.view_inline_2.p 3 100.00 Using index; FirstMatch(alias2) +1 PRIMARY NULL ref 8 test.view_inline_2.p,test.view_inline_2.Name_exp_p 2 100.00 NULL +7 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +8 UNION NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +NULL UNION RESULT NULL ALL NULL NULL NULL NULL NULL NULL Using temporary +6 DERIVED sq2_alias1 NULL ALL NULL NULL NULL NULL 15 100.00 NULL +6 DERIVED sq2_alias2 NULL ref col_int_key col_int_key 5 test.sq2_alias1.pk 2 100.00 NULL +2 DERIVED NULL ALL NULL NULL NULL NULL 15 100.00 NULL +5 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select sum(`alias1`.`col_varchar_nokey`) AS `field2` from `test`.`view_inline_2` join `test`.`t2` `alias2` join (/* select#2 */ select `test`.`view_inline_0`.`pk` AS `pk`,`test`.`view_inline_0`.`col_varchar_key` AS `col_varchar_key`,`test`.`view_inline_0`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`view_inline_0`) `alias1` semi join (`test`.`view_inline_1`) where ((`test`.`view_inline_1`.`sq2_field1` = `test`.`alias2`.`col_varchar_nokey`) and (`alias1`.`col_varchar_nokey` = `test`.`view_inline_2`.`Name_exp_p`) and (`test`.`alias2`.`col_varchar_key` = `test`.`view_inline_2`.`p`) and (`test`.`view_inline_1`.`sq2_field2` = `test`.`view_inline_2`.`p`) and (`alias1`.`col_varchar_key` = `test`.`view_inline_2`.`p`)) +SELECT SUM(alias1.col_varchar_nokey) AS field2 +FROM t2 AS alias2 +LEFT JOIN (SELECT * FROM view_inline_0) AS alias1 +ON alias2.col_varchar_key = alias1.col_varchar_key AND +(alias2.col_varchar_nokey, alias2.col_varchar_key) IN +(SELECT * FROM view_inline_1 +) +WHERE (alias1.col_varchar_key, alias1.col_varchar_nokey) IN +(SELECT * FROM view_inline_2 +); +field2 +NULL +SET @@optimizer_switch= @optimizer_switch_saved; +DROP VIEW view_inline_0, view_inline_1, view_inline_2; +DROP TABLE t1, t2, t3; +# End of test for bug#13956813. +# +# Bug#13974177: Assert !(tab->table->regginfo.not_exists_optimize... +# +CREATE TABLE t1 ( +pk INTEGER AUTO_INCREMENT, +col_int_nokey INTEGER, +col_int_key INTEGER, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk), +KEY (col_int_key), +KEY (col_varchar_key, col_int_key) +); +INSERT INTO t1(col_int_key, col_int_nokey, col_varchar_key, col_varchar_nokey) +VALUES +(0, 4, 'j', 'j'), (8, 6, 'v', 'v'), (1, 3, 'c', 'c'), (8, 5, 'm', 'm'), +(9, 3, 'd', 'd'), (24, 246, 'd', 'd'), (6, 2, 'y', 'y'), (1, 9, 't', 't'), +(6, 3, 'd', 'd'), (2, 8, 's', 's'), (4, 1, 'r', 'r'), (8, 8, 'm', 'm'), +(4, 8, 'b', 'b'), (4, 5, 'x', 'x'), (7, 7, 'g', 'g'), (4, 5, 'p', 'p'), +(1, 1, 'q', 'q'), (9, 6, 'w', 'w'), (4, 2, 'd', 'd'), (8, 9, 'e', 'e'); +CREATE TABLE t2 ( +pk INTEGER AUTO_INCREMENT, +col_int_nokey INTEGER NOT NULL, +col_time_key TIME NOT NULL, +col_time_nokey TIME NOT NULL, +PRIMARY KEY (pk), +KEY (col_time_key) +) ENGINE=InnoDB; +INSERT INTO t2 (col_int_nokey, col_time_key, col_time_nokey) VALUES +(7, '00:00:00', '00:00:00'), (0, '00:00:00', '00:00:00'), +(9, '06:35:17', '06:35:17'), (3, '18:07:14', '18:07:14'), +(4, '20:36:52', '20:36:52'), (2, '21:29:07', '21:29:07'), +(5, '23:45:57', '23:45:57'), (3, '22:54:57', '22:54:57'), +(1, '18:45:09', '18:45:09'), (3, '14:30:46', '14:30:46'), +(6, '19:23:43', '19:23:43'), (7, '03:39:30', '03:39:30'), +(5, '23:37:52', '23:37:52'), (1, '16:59:30', '16:59:30'), +(204, '22:21:15', '22:21:15'), (224, '12:24:37', '12:24:37'), +(9, '15:02:08', '15:02:08'), (5, '23:59:59', '23:59:59'), +(0, '08:23:30', '08:23:30'), (3, '08:32:22', '08:32:22'); +explain SELECT ot1.col_int_key AS x +FROM t1 AS ot2 +LEFT JOIN t1 AS ot1 +ON ot2.col_varchar_nokey > ot1.col_varchar_key +WHERE (ot1.col_int_nokey, ot1.pk) IN +(SELECT it1.pk AS x, +it1.col_int_nokey AS y +FROM t2 AS it2 +LEFT JOIN t2 AS it1 +ON it2.col_time_nokey = it1.col_time_key +) AND ot1.pk IS NULL +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`col_int_key` AS `x` from `test`.`t2` `it1` join `test`.`t1` `ot2` join `test`.`t1` `ot1` semi join (`test`.`t2` `it2`) where ((`test`.`ot1`.`pk` is null) and (`test`.`ot2`.`col_varchar_nokey` > `test`.`ot1`.`col_varchar_key`) and multiple equal(`test`.`ot1`.`col_int_nokey`, `test`.`it1`.`pk`) and multiple equal(`test`.`ot1`.`pk`, `test`.`it1`.`col_int_nokey`) and multiple equal(`test`.`it2`.`col_time_nokey`, `test`.`it1`.`col_time_key`)) +SELECT ot1.col_int_key AS x +FROM t1 AS ot2 +LEFT JOIN t1 AS ot1 +ON ot2.col_varchar_nokey > ot1.col_varchar_key +WHERE (ot1.col_int_nokey, ot1.pk) IN +(SELECT it1.pk AS x, +it1.col_int_nokey AS y +FROM t2 AS it2 +LEFT JOIN t2 AS it1 +ON it2.col_time_nokey = it1.col_time_key +) AND ot1.pk IS NULL +; +x +DROP TABLE t1, t2; +# End of test for bug#13974177. +# +# Bug#13971022: Assert 'keyparts > 0' failed in create_ref_for_key... +# +CREATE TABLE t1 ( +pk INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +PRIMARY KEY (pk), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +CREATE TABLE t2 ( +pk INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk) +) charset utf8mb4 ENGINE=InnoDB; +CREATE TABLE t3 ( +i INT +); +SET @optimizer_switch_saved= @@optimizer_switch; +SET @@optimizer_switch="derived_merge=off"; +explain SELECT table1.pk AS field1 +FROM ( SELECT subquery1_t1. * +FROM t2 AS subquery1_t1 +JOIN t2 AS subquery1_t2 +ON subquery1_t2.pk = subquery1_t1.pk) AS table1 +STRAIGHT_JOIN t2 AS table2 +ON table1.col_int_key IN (SELECT 7 FROM t3) +WHERE table1.col_varchar_nokey IN +(SELECT subquery3_t1.col_varchar_key AS subquery3_field1 +FROM t1 AS subquery3_t1 +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY subquery3_t1 NULL index col_varchar_key col_varchar_key 12 NULL 0 0.00 Using where; Using index; LooseScan +1 PRIMARY NULL ref 7 test.subquery3_t1.col_varchar_key 2 100.00 NULL +1 PRIMARY t3 NULL ALL NULL NULL NULL NULL 0 0.00 FirstMatch(); Using join buffer (hash join) +1 PRIMARY table2 NULL index NULL PRIMARY 4 NULL 1 100.00 Using index; Using join buffer (hash join) +2 DERIVED subquery1_t1 NULL ALL PRIMARY NULL NULL NULL 1 100.00 Using where +2 DERIVED subquery1_t2 NULL eq_ref PRIMARY PRIMARY 4 test.subquery1_t1.pk 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `table1`.`pk` AS `field1` from (/* select#2 */ select `test`.`subquery1_t1`.`pk` AS `pk`,`test`.`subquery1_t1`.`col_int_key` AS `col_int_key`,`test`.`subquery1_t1`.`col_varchar_key` AS `col_varchar_key`,`test`.`subquery1_t1`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t2` `subquery1_t1` join `test`.`t2` `subquery1_t2` where ((`test`.`subquery1_t1`.`col_int_key` = 7) and (`test`.`subquery1_t2`.`pk` = `test`.`subquery1_t1`.`pk`))) `table1` straight_join `test`.`t2` `table2` semi join (`test`.`t3`) semi join (`test`.`t1` `subquery3_t1`) where (`table1`.`col_varchar_nokey` = `test`.`subquery3_t1`.`col_varchar_key`) +SELECT table1.pk AS field1 +FROM ( SELECT subquery1_t1. * +FROM t2 AS subquery1_t1 +JOIN t2 AS subquery1_t2 +ON subquery1_t2.pk = subquery1_t1.pk) AS table1 +STRAIGHT_JOIN t2 AS table2 +ON table1.col_int_key IN (SELECT 7 FROM t3) +WHERE table1.col_varchar_nokey IN +(SELECT subquery3_t1.col_varchar_key AS subquery3_field1 +FROM t1 AS subquery3_t1 +) +; +field1 +SET @@optimizer_switch= @optimizer_switch_saved; +DROP TABLE t1, t2, t3; +# End of test for bug#13971022. +# +# Bug#13623473 "MISSING ROWS ON SELECT AND JOIN WITH +# TIME/DATETIME COMPARE" - Subquery part of test. +# +SET TIMESTAMP=UNIX_TIMESTAMP('2012-01-31 10:14:35'); +CREATE TABLE t1 ( +pk INT NOT NULL, +col_int_nokey INT, +col_int_key INT NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +) ENGINE=InnoDB; +INSERT INTO t1 VALUES (10,1,7), (11,7,0), (12,4,9), (13,7,3), +(14,0,4), (15,2,2), (16,9,5), (17,4,3), (18,0,1), (19,9,3), (20,1,6), +(21,3,7), (22,8,5), (23,8,1), (24,18,204), (25,84,224), (26,6,9), +(27,3,5), (28,6,0), (29,6,3); +CREATE TABLE t2 ( +col_int_nokey INT NOT NULL, +col_datetime_key DATETIME NOT NULL, +col_varchar_key VARCHAR(1) NOT NULL, +KEY col_datetime_key (col_datetime_key), +KEY col_varchar_key (col_varchar_key) +) ENGINE=InnoDB; +INSERT INTO t2 VALUES (1,'2001-11-04 19:07:55','k'); +CREATE TABLE t3 ( +col_time_key TIME, +KEY col_time_key (col_time_key) +) ENGINE=InnoDB; +INSERT INTO t3 VALUES ('21:22:34'), ('10:50:38'), ('00:21:38'), +('04:08:02'), ('16:25:11'), ('10:14:58'), ('19:47:59'), ('11:14:24'), +('00:00:00'), ('00:00:00'), ('15:57:25'), ('07:05:51'), ('19:22:21'), +('03:53:16'), ('09:16:38'), ('15:37:26'), ('00:00:00'), ('05:03:03'), +('02:59:24'), ('00:01:58'); +EXPLAIN SELECT outr.col_int_nokey +FROM t2 as outr +STRAIGHT_JOIN t3 AS outr2 +ON outr2.col_time_key > outr.col_datetime_key +WHERE outr.col_int_nokey IN ( +SELECT col_int_key +FROM t1 AS innr +WHERE innr.pk >= innr.col_int_nokey +) AND ( +outr.col_int_nokey <= 6 +OR +outr.col_varchar_key IS NULL +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE outr NULL ALL col_datetime_key NULL NULL NULL 1 100.00 Using where +2 SIMPLE innr NULL ref col_int_key col_int_key 4 test.outr.col_int_nokey 1 33.33 Using where; FirstMatch(outr) +2 SIMPLE outr2 NULL index col_time_key col_time_key 4 NULL 20 33.33 Using where; Using index; Using join buffer (hash join) +Warnings: +Warning 1739 Cannot use range access on index 'col_time_key' due to type or collation conversion on field 'col_time_key' +Note 1003 /* select#1 */ select `test`.`outr`.`col_int_nokey` AS `col_int_nokey` from `test`.`t2` `outr` straight_join `test`.`t3` `outr2` semi join (`test`.`t1` `innr`) where ((`test`.`innr`.`col_int_key` = `test`.`outr`.`col_int_nokey`) and (`test`.`outr`.`col_int_nokey` <= 6) and (`test`.`innr`.`pk` >= `test`.`innr`.`col_int_nokey`) and (cast(`test`.`outr2`.`col_time_key` as datetime) > `test`.`outr`.`col_datetime_key`)) +SELECT outr.col_int_nokey +FROM t2 as outr +STRAIGHT_JOIN t3 AS outr2 +ON outr2.col_time_key > outr.col_datetime_key +WHERE outr.col_int_nokey IN ( +SELECT col_int_key +FROM t1 AS innr +WHERE innr.pk >= innr.col_int_nokey +) AND ( +outr.col_int_nokey <= 6 +OR +outr.col_varchar_key IS NULL +); +col_int_nokey +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +DROP TABLE t1,t2,t3; +SET TIMESTAMP = DEFAULT; +# End of test for bug#13623473. +# +# Bug#13980954: Missing data on left join + null value + where..in +# +CREATE TABLE t1 ( +ik INT, +vc varchar(1) +) charset utf8mb4; +INSERT INTO t1 VALUES (8, 'x'), (NULL, 'x'); +CREATE TABLE t2 ( +ik INT, +vc varchar(1) +) charset utf8mb4; +INSERT INTO t2 VALUES +(0, 'x'), (7, 'i'), (7, 'e'), (1, 'p'), (7, 's'), (1, 'j'); +explain format=json SELECT t2.vc, t2.ik AS t2_ik, t1.ik AS t1_ik +FROM t2 LEFT JOIN t1 ON t2.vc=t1.vc +WHERE t2.vc IN (SELECT vc FROM t2 AS t3); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "6.12" + }, + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 6, + "rows_produced_per_join": 6, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "0.60", + "prefix_cost": "1.11", + "data_read_per_join": "96" + }, + "used_columns": [ + "ik", + "vc" + ], + "attached_condition": "(`test`.`t2`.`vc` is not null)" + } + }, + { + "table": { + "table_name": "", + "access_type": "eq_ref", + "key": "", + "key_length": "7", + "ref": [ + "test.t2.vc" + ], + "rows_examined_per_scan": 1, + "materialized_from_subquery": { + "using_temporary_table": true, + "query_block": { + "table": { + "table_name": "t3", + "access_type": "ALL", + "rows_examined_per_scan": 6, + "rows_produced_per_join": 6, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "0.60", + "prefix_cost": "1.11", + "data_read_per_join": "96" + }, + "used_columns": [ + "vc" + ] + } + } + } + } + }, + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 12, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "1.20", + "prefix_cost": "6.12", + "data_read_per_join": "192" + }, + "used_columns": [ + "ik", + "vc" + ], + "attached_condition": "(is_not_null_compl(t1), (`test`.`t1`.`vc` = `test`.`t2`.`vc`), true)" + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`vc` AS `vc`,`test`.`t2`.`ik` AS `t2_ik`,`test`.`t1`.`ik` AS `t1_ik` from `test`.`t2` left join `test`.`t1` on((`test`.`t1`.`vc` = `test`.`t2`.`vc`)) semi join (`test`.`t2` `t3`) where (``.`vc` = `test`.`t2`.`vc`) +SELECT t2.vc, t2.ik AS t2_ik, t1.ik AS t1_ik +FROM t2 LEFT JOIN t1 ON t2.vc=t1.vc +WHERE t2.vc IN (SELECT vc FROM t2 AS t3); +vc t2_ik t1_ik +e 7 NULL +i 7 NULL +j 1 NULL +p 1 NULL +s 7 NULL +x 0 8 +x 0 NULL +DROP TABLE t1, t2; +# End of test for bug#13980954. +# +# Bug#14048292: Segfault in Item_field::result_type on 2nd execution +# of prep stmt with join of view +# +CREATE TABLE t1 ( +col_int INT +); +INSERT INTO t1 VALUES (0), (1); +CREATE VIEW view_t1 AS SELECT * FROM t1; +explain SELECT alias1.col_int +FROM t1 AS alias1 +LEFT JOIN view_t1 AS alias2 +ON alias1.col_int IN +(SELECT sq1_alias1.col_int +FROM t1 AS sq1_alias1 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE alias1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE sq1_alias1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`alias1`.`col_int` AS `col_int` from `test`.`t1` `alias1` left join (`test`.`t1` semi join (`test`.`t1` `sq1_alias1`)) on(((`test`.`sq1_alias1`.`col_int` = `test`.`alias1`.`col_int`))) where true +PREPARE stmt FROM "SELECT alias1.col_int +FROM t1 AS alias1 +LEFT JOIN view_t1 AS alias2 +ON alias1.col_int IN +(SELECT sq1_alias1.col_int +FROM t1 AS sq1_alias1 +)"; +EXECUTE stmt; +col_int +0 +0 +1 +1 + +EXECUTE stmt; +col_int +0 +0 +1 +1 +DEALLOCATE PREPARE stmt; +DROP VIEW view_t1; +DROP TABLE t1; +# End of test for bug#14048292. +# +# Bug#14064201: Missing data on join of derived table + WHERE .. IN +# with two operands +# +CREATE TABLE t1 ( +col_varchar_nokey VARCHAR(1) +) charset utf8mb4; +INSERT INTO t1 VALUES +('v'), ('s'), ('l'), ('y'), ('c'), ('i'), ('h'), ('q'), ('a'), ('v'), +('u'), ('s'), ('y'), ('z'), ('h'), ('p'), ('e'), ('i'), ('y'), ('w'); +CREATE TABLE t2 ( +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +KEY col_varchar_key(col_varchar_key) +) charset utf8mb4; +INSERT INTO t2 VALUES +('j','j'), ('v','v'), ('c','c'), ('m','m'), ('d','d'), ('d','d'), ('y','y'); +SET @optimizer_switch_saved= @@optimizer_switch; +SET @@optimizer_switch="derived_merge=off"; +explain format=json SELECT * +FROM (SELECT * FROM t2) AS derived1 +LEFT JOIN t1 +USING (col_varchar_nokey) +WHERE (col_varchar_nokey, col_varchar_nokey) IN +(SELECT col_varchar_nokey, col_varchar_key +FROM t2 AS derived2 +); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "13.03" + }, + "nested_loop": [ + { + "table": { + "table_name": "", + "access_type": "ALL", + "attached_condition": "((``.`col_varchar_key` = ``.`col_varchar_nokey`) and (``.`col_varchar_nokey` is not null))", + "materialized_from_subquery": { + "using_temporary_table": true, + "query_block": { + "table": { + "table_name": "derived2", + "access_type": "ALL", + "possible_keys": [ + "col_varchar_key" + ], + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "0.70", + "prefix_cost": "1.21", + "data_read_per_join": "112" + }, + "used_columns": [ + "col_varchar_key", + "col_varchar_nokey" + ], + "attached_condition": "(`test`.`derived2`.`col_varchar_key` = `test`.`derived2`.`col_varchar_nokey`)" + } + } + } + } + }, + { + "table": { + "table_name": "derived1", + "access_type": "ref", + "possible_keys": [ + "" + ], + "key": "", + "used_key_parts": [ + "col_varchar_nokey" + ], + "key_length": "7", + "ref": [ + ".col_varchar_nokey" + ], + "rows_examined_per_scan": 2, + "rows_produced_per_join": 2, + "filtered": "100.00", + "cost_info": { + "read_cost": "3.50", + "eval_cost": "0.20", + "prefix_cost": "8.51", + "data_read_per_join": "32" + }, + "used_columns": [ + "col_varchar_key", + "col_varchar_nokey" + ], + "materialized_from_subquery": { + "using_temporary_table": true, + "dependent": false, + "cacheable": true, + "query_block": { + "select_id": 2, + "cost_info": { + "query_cost": "1.21" + }, + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "0.70", + "prefix_cost": "1.21", + "data_read_per_join": "112" + }, + "used_columns": [ + "col_varchar_key", + "col_varchar_nokey" + ] + } + } + } + } + }, + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 40, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.52", + "eval_cost": "4.00", + "prefix_cost": "13.03", + "data_read_per_join": "320" + }, + "used_columns": [ + "col_varchar_nokey" + ], + "attached_condition": "(is_not_null_compl(t1), (`test`.`t1`.`col_varchar_nokey` = `derived1`.`col_varchar_nokey`), true)" + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select `derived1`.`col_varchar_nokey` AS `col_varchar_nokey`,`derived1`.`col_varchar_key` AS `col_varchar_key` from (/* select#2 */ select `test`.`t2`.`col_varchar_key` AS `col_varchar_key`,`test`.`t2`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t2`) `derived1` left join `test`.`t1` on(((`test`.`t1`.`col_varchar_nokey` = `derived1`.`col_varchar_nokey`) and (`test`.`derived2`.`col_varchar_nokey` = `test`.`derived2`.`col_varchar_key`))) semi join (`test`.`t2` `derived2`) where ((``.`col_varchar_key` = ``.`col_varchar_nokey`) and (`derived1`.`col_varchar_nokey` = ``.`col_varchar_nokey`) and (`test`.`derived2`.`col_varchar_key` = `test`.`derived2`.`col_varchar_nokey`)) +SELECT * +FROM (SELECT * FROM t2) AS derived1 +LEFT JOIN t1 +USING (col_varchar_nokey) +WHERE (col_varchar_nokey, col_varchar_nokey) IN +(SELECT col_varchar_nokey, col_varchar_key +FROM t2 AS derived2 +); +col_varchar_nokey col_varchar_key +c c +d d +d d +j j +m m +v v +v v +y y +y y +y y +SET @@optimizer_switch= @optimizer_switch_saved; +DROP TABLE t1, t2; +CREATE TABLE t1 ( +col_int_nokey int NOT NULL, +col_int_key int NOT NULL, +KEY col_int_key (col_int_key) +); +INSERT INTO t1 VALUES +(1,7), (7,0), (4,9), (7,3), (0,4), (2,2), (9,5), (4,3), (0,1), (9,3), +(1,6), (3,7), (8,5), (8,1), (18,204), (84,224), (6,9), (3,5), (6,0), (6,3); +CREATE TABLE t2 ( +col_int_nokey int NOT NULL, +col_int_key int NOT NULL, +KEY col_int_key (col_int_key) +); +INSERT INTO t2 VALUES +(4,0), (6,8), (3,1), (5,8), (3,9), (246,24), (2,6), (9,1), (3,6), (8,2), +(1,4), (8,8), (8,4), (5,4), (7,7), (5,4), (1,1), (6,9), (2,4), (9,8); +explain format=json SELECT grandparent1.* +FROM t1 AS grandparent1 +LEFT JOIN t1 USING (col_int_nokey) +WHERE (col_int_nokey, col_int_nokey) IN +(SELECT col_int_nokey, col_int_key +FROM t2 +); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "50.53" + }, + "nested_loop": [ + { + "table": { + "table_name": "grandparent1", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 20, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "2.00", + "prefix_cost": "2.51", + "data_read_per_join": "320" + }, + "used_columns": [ + "col_int_nokey", + "col_int_key" + ] + } + }, + { + "table": { + "table_name": "", + "access_type": "eq_ref", + "key": "", + "key_length": "8", + "ref": [ + "test.grandparent1.col_int_nokey", + "test.grandparent1.col_int_nokey" + ], + "rows_examined_per_scan": 1, + "materialized_from_subquery": { + "using_temporary_table": true, + "query_block": { + "table": { + "table_name": "t2", + "access_type": "ALL", + "possible_keys": [ + "col_int_key" + ], + "rows_examined_per_scan": 20, + "rows_produced_per_join": 20, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "2.00", + "prefix_cost": "2.51", + "data_read_per_join": "320" + }, + "used_columns": [ + "col_int_nokey", + "col_int_key" + ], + "attached_condition": "(`test`.`t2`.`col_int_key` = `test`.`t2`.`col_int_nokey`)" + } + } + } + } + }, + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 400, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "40.00", + "prefix_cost": "50.53", + "data_read_per_join": "6K" + }, + "used_columns": [ + "col_int_nokey" + ], + "attached_condition": "(is_not_null_compl(t1), (`test`.`t1`.`col_int_nokey` = `test`.`grandparent1`.`col_int_nokey`), true)" + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`grandparent1`.`col_int_nokey` AS `col_int_nokey`,`test`.`grandparent1`.`col_int_key` AS `col_int_key` from `test`.`t1` `grandparent1` left join `test`.`t1` on(((`test`.`t1`.`col_int_nokey` = `test`.`grandparent1`.`col_int_nokey`) and (`test`.`t2`.`col_int_nokey` = `test`.`t2`.`col_int_key`))) semi join (`test`.`t2`) where ((``.`col_int_nokey` = `test`.`grandparent1`.`col_int_nokey`) and (``.`col_int_key` = `test`.`grandparent1`.`col_int_nokey`) and (`test`.`t2`.`col_int_key` = `test`.`t2`.`col_int_nokey`)) +SELECT grandparent1.* +FROM t1 AS grandparent1 +LEFT JOIN t1 USING (col_int_nokey) +WHERE (col_int_nokey, col_int_nokey) IN +(SELECT col_int_nokey, col_int_key +FROM t2 +); +col_int_nokey col_int_key +1 6 +1 6 +1 7 +1 7 +7 0 +7 0 +7 3 +7 3 +8 1 +8 1 +8 5 +8 5 +DROP TABLE t1, t2; +CREATE TABLE t1 ( +pk int, +col_int_key int, +col_datetime_key datetime, +col_varchar_key varchar(1), +col_varchar_nokey varchar(1), +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_datetime_key (col_datetime_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4 engine=MyISAM; +INSERT INTO t1 VALUES +(10,7,'2004-06-06 04:22:12','v','v'), (11,0,'2005-11-13 01:12:31','s','s'), +(12,9,'2002-05-04 01:50:00','l','l'), (13,3,'2004-10-27 10:28:45','y','y'), +(14,4,'2006-07-22 05:24:23','c','c'), (15,2,'2002-05-16 21:34:03','i','i'), +(16,5,'2008-04-17 10:45:30','h','h'), (17,3,'2009-04-21 02:58:02','q','q'), +(18,1,'2008-01-11 11:01:51','a','a'), (19,3,'1900-01-01 00:00:00','v','v'), +(20,6,'2007-05-17 18:24:57','u','u'), (21,7,'2007-08-07 00:00:00','s','s'), +(22,5,'2001-08-28 00:00:00','y','y'), (23,1,'2004-04-16 00:27:28','z','z'), +(24,204,'2005-05-03 07:06:22','h','h'), (25,224,'2009-03-11 17:09:50','p','p'), +(26,9,'2007-12-08 01:54:28','e','e'), (27,5,'2009-07-28 18:19:54','i','i'), +(28,0,'2008-06-08 00:00:00','y','y'), (29,3,'2005-02-09 09:20:26','w','w'); +CREATE TABLE t2 ( +pk int, +col_int_key int, +col_datetime_key datetime, +col_varchar_key varchar(1), +col_varchar_nokey varchar(1), +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_datetime_key (col_datetime_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4 engine=MyISAM; +INSERT INTO t2 VALUES +(1,0,'2002-02-13 17:30:06','j','j'), (2,8,'2008-09-27 00:34:58','v','v'), +(3,1,'2007-05-28 00:00:00','c','c'), (4,8,'2009-07-25 09:21:20','m','m'), +(5,9,'2002-01-16 00:00:00','d','d'), (6,24,'2006-10-12 04:32:53','d','d'), +(7,6,'2001-02-15 03:08:38','y','y'), (8,1,'2004-10-02 20:31:15','t','t'), +(9,6,'2002-08-20 22:48:00','d','d'), (10,2,'1900-01-01 00:00:00','s','s'), +(11,4,'2005-08-15 00:00:00','r','r'), (12,8,'1900-01-01 00:00:00','m','m'), +(13,4,'2008-05-16 08:09:06','b','b'), (14,4,'2001-01-20 12:47:23','x','x'), +(15,7,'2008-07-02 00:00:00','g','g'), (16,4,'1900-01-01 00:00:00','p','p'), +(17,1,'2002-12-08 11:34:58','q','q'), (18,9,'1900-01-01 00:00:00','w','w'), +(19,4,'1900-01-01 00:00:00','d','d'), (20,8,'2002-08-25 20:35:06','e','e'); +SELECT alias1.col_datetime_key +FROM t2 AS alias1 +RIGHT JOIN t2 AS alias2 +JOIN t2 AS alias3 +ON alias3.pk = alias2.pk +ON alias3.col_varchar_nokey = alias2.col_varchar_key OR +alias2.col_varchar_nokey +WHERE (alias2.col_varchar_key, alias2.col_varchar_key) IN +(SELECT sq2_alias2.col_varchar_key, sq2_alias1.col_varchar_nokey +FROM t1 AS sq2_alias1, t1 AS sq2_alias2 +WHERE sq2_alias2.col_int_key < 2); +col_datetime_key +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +2001-01-20 12:47:23 +2001-01-20 12:47:23 +2001-02-15 03:08:38 +2001-02-15 03:08:38 +2002-01-16 00:00:00 +2002-01-16 00:00:00 +2002-02-13 17:30:06 +2002-02-13 17:30:06 +2002-08-20 22:48:00 +2002-08-20 22:48:00 +2002-08-25 20:35:06 +2002-08-25 20:35:06 +2002-12-08 11:34:58 +2002-12-08 11:34:58 +2004-10-02 20:31:15 +2004-10-02 20:31:15 +2005-08-15 00:00:00 +2005-08-15 00:00:00 +2006-10-12 04:32:53 +2006-10-12 04:32:53 +2007-05-28 00:00:00 +2007-05-28 00:00:00 +2008-05-16 08:09:06 +2008-05-16 08:09:06 +2008-07-02 00:00:00 +2008-07-02 00:00:00 +2008-09-27 00:34:58 +2008-09-27 00:34:58 +2009-07-25 09:21:20 +2009-07-25 09:21:20 +ALTER TABLE t1 DISABLE KEYS; +ALTER TABLE t2 DISABLE KEYS; +explain format=json SELECT alias1.col_datetime_key +FROM t2 AS alias1 +RIGHT JOIN t2 AS alias2 +JOIN t2 AS alias3 +ON alias3.pk = alias2.pk +ON alias3.col_varchar_nokey = alias2.col_varchar_key OR +alias2.col_varchar_nokey +WHERE (alias2.col_varchar_key, alias2.col_varchar_key) IN +(SELECT sq2_alias2.col_varchar_key, sq2_alias1.col_varchar_nokey +FROM t1 AS sq2_alias1, t1 AS sq2_alias2 +WHERE sq2_alias2.col_int_key < 2); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "52.48" + }, + "nested_loop": [ + { + "table": { + "table_name": "", + "access_type": "ALL", + "attached_condition": "(``.`col_varchar_nokey` = ``.`col_varchar_key`)", + "materialized_from_subquery": { + "using_temporary_table": true, + "query_block": { + "nested_loop": [ + { + "table": { + "table_name": "sq2_alias2", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 6, + "filtered": "33.33", + "cost_info": { + "read_cost": "1.86", + "eval_cost": "0.67", + "prefix_cost": "2.53", + "data_read_per_join": "213" + }, + "used_columns": [ + "col_int_key", + "col_varchar_key" + ], + "attached_condition": "(`test`.`sq2_alias2`.`col_int_key` < 2)" + } + }, + { + "table": { + "table_name": "sq2_alias1", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 13, + "filtered": "10.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.53", + "eval_cost": "1.33", + "prefix_cost": "16.39", + "data_read_per_join": "426" + }, + "used_columns": [ + "col_varchar_nokey" + ], + "attached_condition": "(`test`.`sq2_alias1`.`col_varchar_nokey` = `test`.`sq2_alias2`.`col_varchar_key`)" + } + } + ] + } + } + } + }, + { + "table": { + "table_name": "alias2", + "access_type": "ALL", + "possible_keys": [ + "PRIMARY" + ], + "rows_examined_per_scan": 20, + "rows_produced_per_join": 2, + "filtered": "10.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.53", + "eval_cost": "0.20", + "prefix_cost": "47.25", + "data_read_per_join": "64" + }, + "used_columns": [ + "pk", + "col_varchar_key", + "col_varchar_nokey" + ], + "attached_condition": "(`test`.`alias2`.`col_varchar_key` = ``.`col_varchar_key`)" + } + }, + { + "table": { + "table_name": "alias3", + "access_type": "eq_ref", + "possible_keys": [ + "PRIMARY" + ], + "key": "PRIMARY", + "used_key_parts": [ + "pk" + ], + "key_length": "4", + "ref": [ + "test.alias2.pk" + ], + "rows_examined_per_scan": 1, + "rows_produced_per_join": 2, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.20", + "prefix_cost": "47.95", + "data_read_per_join": "64" + }, + "used_columns": [ + "pk", + "col_varchar_nokey" + ] + } + }, + { + "table": { + "table_name": "alias1", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 40, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.53", + "eval_cost": "4.00", + "prefix_cost": "52.48", + "data_read_per_join": "1K" + }, + "used_columns": [ + "col_datetime_key" + ], + "attached_condition": "(is_not_null_compl(alias1), ((`test`.`alias3`.`col_varchar_nokey` = `test`.`alias2`.`col_varchar_key`) or (0 <> `test`.`alias2`.`col_varchar_nokey`)), true)" + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`alias1`.`col_datetime_key` AS `col_datetime_key` from `test`.`t2` `alias2` join `test`.`t2` `alias3` left join `test`.`t2` `alias1` on((((`test`.`alias3`.`col_varchar_nokey` = `test`.`alias2`.`col_varchar_key`) and (`test`.`sq2_alias1`.`col_varchar_nokey` = `test`.`sq2_alias2`.`col_varchar_key`)) or (0 <> `test`.`alias2`.`col_varchar_nokey`))) semi join (`test`.`t1` `sq2_alias1` join `test`.`t1` `sq2_alias2`) where ((`test`.`alias3`.`pk` = `test`.`alias2`.`pk`) and (``.`col_varchar_nokey` = ``.`col_varchar_key`) and (`test`.`alias2`.`col_varchar_key` = ``.`col_varchar_key`) and (`test`.`sq2_alias1`.`col_varchar_nokey` = `test`.`sq2_alias2`.`col_varchar_key`) and (`test`.`sq2_alias2`.`col_int_key` < 2)) +SELECT alias1.col_datetime_key +FROM t2 AS alias1 +RIGHT JOIN t2 AS alias2 +JOIN t2 AS alias3 +ON alias3.pk = alias2.pk +ON alias3.col_varchar_nokey = alias2.col_varchar_key OR +alias2.col_varchar_nokey +WHERE (alias2.col_varchar_key, alias2.col_varchar_key) IN +(SELECT sq2_alias2.col_varchar_key, sq2_alias1.col_varchar_nokey +FROM t1 AS sq2_alias1, t1 AS sq2_alias2 +WHERE sq2_alias2.col_int_key < 2); +col_datetime_key +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +2001-01-20 12:47:23 +2001-01-20 12:47:23 +2001-02-15 03:08:38 +2001-02-15 03:08:38 +2002-01-16 00:00:00 +2002-01-16 00:00:00 +2002-02-13 17:30:06 +2002-02-13 17:30:06 +2002-08-20 22:48:00 +2002-08-20 22:48:00 +2002-08-25 20:35:06 +2002-08-25 20:35:06 +2002-12-08 11:34:58 +2002-12-08 11:34:58 +2004-10-02 20:31:15 +2004-10-02 20:31:15 +2005-08-15 00:00:00 +2005-08-15 00:00:00 +2006-10-12 04:32:53 +2006-10-12 04:32:53 +2007-05-28 00:00:00 +2007-05-28 00:00:00 +2008-05-16 08:09:06 +2008-05-16 08:09:06 +2008-07-02 00:00:00 +2008-07-02 00:00:00 +2008-09-27 00:34:58 +2008-09-27 00:34:58 +2009-07-25 09:21:20 +2009-07-25 09:21:20 +DROP TABLE t1, t2; +# End of test for bug#14064201. +# +# Bug#18223655:ASSERTION FAILED: (INT)IDX >= 0 +# && IDX < PARENT_JOIN->TABLES +# +CREATE TABLE b (d INT); +CREATE TABLE c (a INT, b INT,c INT,d BLOB NOT NULL); +SELECT(SELECT 1 +FROM b WHERE(SELECT 1 IN (SELECT 1 FROM b WHERE 1 NOT BETWEEN d AND 1) +FROM b) IN (SELECT d FROM c)) as cc FROM b; +cc +INSERT INTO b VALUE(1); +INSERT INTO c VALUES(1,2,3,'1'),(2,3,4,'1'),(3,4,5,'C'); +SELECT(SELECT d FROM b WHERE(SELECT d IN +(SELECT d FROM b WHERE 1 NOT BETWEEN d AND 1) FROM b) IN +(SELECT d FROM c)) as cc FROM c; +cc +1 +1 +1 +DROP TABLE b,c; +# +# Bug#18447874:WRONG RESULT COMING FROM SEMI-JOIN +# +CREATE TABLE b ( +d INT(11) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE c ( +d BLOB +) ; +CREATE TABLE d ( +b INT(11) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO b VALUES(1),(2),(4); +INSERT INTO c VALUES(1),(2),(3); +SELECT 1 FROM b WHERE (SELECT 1 FROM d ) IN (SELECT d FROM c) ; +1 +INSERT INTO d VALUES(2); +SELECT 1 FROM b WHERE (SELECT 1 FROM d ) IN (SELECT d FROM c) ; +1 +1 +1 +1 +DROP TABLE b,c,d; +# +# Bug#17292723:INCORRECT RESULT FOR (SELECT...) IN (SELECT...) STATEMENT +# +CREATE TABLE t1 ( +ID int(11) NOT NULL AUTO_INCREMENT, +id2 int(11) DEFAULT NULL, +id3 int(11) DEFAULT NULL, +id4 varchar(150) COLLATE utf8_spanish_ci NOT NULL, +id5 int(11) DEFAULT NULL, +PRIMARY KEY (ID), +KEY id2 (id2), +KEY id3 (id3), +KEY id5 (id5) +) ENGINE=InnoDB; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 3778 'utf8_spanish_ci' is a collation of the deprecated character set UTF8MB3. Please consider using UTF8MB4 with an appropriate collation instead. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES +(123,1,1,'1',NULL), +(124,1,1,'2',NULL), +(125,1,1,'4',NULL), +(126,1,1,'3',NULL), +(127,1,1,'6',NULL), +(128,1,1,'8',NULL); +CREATE TABLE t2 ( +id6 int(11) NOT NULL, +id7 int(11) NOT NULL, +PRIMARY KEY (id6,id7), +KEY id7 (id7) +) ENGINE=InnoDB; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (126,123),(130,123),(135,123); +SELECT ID +FROM t1 p0 +WHERE p0.id3=1 +AND ( (SELECT p1.id FROM t1 p1 WHERE p1.id=123) IN (SELECT p3.id FROM t2 +p2, t1 p3 WHERE p0.id=p2.id6 AND p2.id7=p3.id)); +ID +126 +DROP TABLE t1,t2; +set @@optimizer_switch=@old_opt_switch; +# End of 5.6 tests +# +# Bug#19336348 DEBUG CRASH AT SETUP_SEMIJOIN_DUPS_ELIMINATION IN SQL/SQL_SELECT.CC +# +CREATE TABLE t1 ( +col_varchar_nokey varchar(1) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t1 VALUES ('c'),(NULL),('x'); +CREATE TABLE t2 ( +pk int, +col_varchar_key varchar(1), +PRIMARY KEY (pk), +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t2 VALUES (10,'l'),(11,'p'); +ANALYZE TABLE t1,t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN SELECT 1 +FROM t1 AS outr +WHERE outr.col_varchar_nokey IN +( +SELECT innr.col_varchar_key +FROM t2 AS innr +WHERE innr.pk <= 7 +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE innr NULL index PRIMARY,col_varchar_key col_varchar_key 7 NULL 2 100.00 Using where; Using index; LooseScan +1 SIMPLE outr NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` `outr` semi join (`test`.`t2` `innr`) where ((`test`.`outr`.`col_varchar_nokey` = `test`.`innr`.`col_varchar_key`) and (`test`.`innr`.`pk` <= 7)) +SELECT 1 +FROM t1 AS outr +WHERE outr.col_varchar_nokey IN +( +SELECT innr.col_varchar_key +FROM t2 AS innr +WHERE innr.pk <= 7 +) +; +1 +DROP TABLE t1,t2; +# +# Bug#18174394 BLOBS: CRASH AFTER UNINITIALIZED VALUES IN ITEM_FIELD::STR_RESULT +# +CREATE TABLE t1(d BLOB, b BLOB); +INSERT INTO t1(d,b) VALUES ('aaaa',''),('bnbb',''); +SELECT 1 FROM t1 +WHERE (SELECT b FROM t1) IN (SELECT (d>=1) FROM t1); +ERROR 21000: Subquery returns more than 1 row +DROP TABLE t1; +# +# Bug#19779600: ASSERT FAILED IN REPLACE_SUBCONDITION WITH IN +# PREDICATE INSIDE IN PREDICATE +# +CREATE TABLE t(X INT) ENGINE=InnoDB; +INSERT INTO t VALUES (1); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +EXPLAIN SELECT 1 FROM t WHERE (1 IN (SELECT 1 FROM t)) IN (SELECT 1 FROM t); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 PRIMARY t NULL ALL NULL NULL NULL NULL 1 100.00 FirstMatch(t); Using join buffer (hash join) +2 SUBQUERY t NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t` semi join (`test`.`t`) where true +SELECT 1 FROM t WHERE (1 IN (SELECT 1 FROM t)) IN (SELECT 1 FROM t); +1 +1 +DROP TABLE t; +# +# Bug#19465034 ASSERT ON SETUP_SEMIJOIN_DUPS_ELIMINATION IN SQL/SQL_SELECT.CC +# +CREATE TABLE t1 ( +pk INTEGER NOT NULL, +i1 INTEGER NOT NULL, +PRIMARY KEY (pk) +) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1,1); +CREATE TABLE t2 ( +pk INTEGER NOT NULL, +c1 VARCHAR(1) NOT NULL, +PRIMARY KEY (pk), +KEY c1_key (c1) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t2 VALUES (1,'j'),(2,'v'),(3,'c'); +CREATE TABLE t3 ( +pk INTEGER NOT NULL, +c1 VARCHAR(1) NOT NULL, +PRIMARY KEY (pk), +KEY c1_key (c1) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t3 VALUES (10,'v'),(11,'s'); +ANALYZE TABLE t1, t2, t3; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +EXPLAIN SELECT * +FROM t1 JOIN t2 ON t1.i1 >= t2.pk +WHERE t2.c1 IN ( +SELECT t3.c1 +FROM t3 +WHERE t3.pk < 3 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t3 NULL index PRIMARY,c1_key c1_key 6 NULL 2 100.00 Using where; Using index; LooseScan +2 SIMPLE t2 NULL ref PRIMARY,c1_key c1_key 6 test.t3.c1 1 33.33 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`i1` AS `i1`,`test`.`t2`.`pk` AS `pk`,`test`.`t2`.`c1` AS `c1` from `test`.`t1` join `test`.`t2` semi join (`test`.`t3`) where ((`test`.`t2`.`c1` = `test`.`t3`.`c1`) and (`test`.`t3`.`pk` < 3) and (`test`.`t1`.`i1` >= `test`.`t2`.`pk`)) +SELECT * +FROM t1 JOIN t2 ON t1.i1 >= t2.pk +WHERE t2.c1 IN ( +SELECT t3.c1 +FROM t3 +WHERE t3.pk < 3 +); +pk i1 pk c1 +DROP TABLE t1,t2,t3; +# +# Bug#19586047: CRASH IN ARG_COMPARATOR::SET_CMP_FUNC +# +CREATE TABLE t1(x INT) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT 1 FROM t1 WHERE EXISTS(SELECT 1) IN (SELECT 1 FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 1 100.00 FirstMatch(t1); Using join buffer (hash join) +2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` semi join (`test`.`t1`) where true +SELECT 1 FROM t1 WHERE EXISTS(SELECT 1) IN (SELECT 1 FROM t1); +1 +1 +EXPLAIN SELECT 1 FROM t1 WHERE (SELECT 1, 2 FROM t1) IN (SELECT 1, 2 FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 1 100.00 FirstMatch(t1); Using join buffer (hash join) +2 SUBQUERY t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` semi join (`test`.`t1`) where true +SELECT 1 FROM t1 WHERE (SELECT 1, 2 FROM t1) IN (SELECT 1, 2 FROM t1); +1 +1 +EXPLAIN SELECT 1 FROM t1 WHERE +(SELECT 1, 2 FROM t1 WHERE x = 2) IN (SELECT 1, 2 FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +2 SUBQUERY t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` semi join (`test`.`t1`) where false +SELECT 1 FROM t1 WHERE +(SELECT 1, 2 FROM t1 WHERE x = 2) IN (SELECT 1, 2 FROM t1); +1 +DROP TABLE t1; +# +#Bug#20119743 ASSERTIONQEP_TAB->USE_ORDER() IN ENUM_NESTED_LOOP_STATE +# EVALUATE_JOIN_RECORD +# +CREATE TABLE t1 ( +pk int(11) NOT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +PRIMARY KEY (pk) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (1,'x'); +CREATE TABLE t2 ( +col_date_key date DEFAULT NULL, +col_int_key int(11) DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +KEY col_int_key (col_int_key), +KEY col_date_key (col_date_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES ('2000-12-03', 8, 'x', 'x'),('2008-05-03', 7, 'd', 'd'), +('2005-12-06', 1, 'r', 'r'),('2000-04-10', 7, 'f', 'f'), +('2002-11-05', 9, 'y', 'y'),('2000-09-06', NULL, 'u', 'u'), +(NULL, 1, 'm', 'm'),('2007-06-14', 9, NULL, NULL), +('2007-11-17', 2, 'o', 'o'),('2009-02-23', 9, 'w', 'w'), +('2007-01-08', 2, 'm', 'm'), ('2008-06-10', 4, 'q', 'q'), +('2002-10-20', 0, NULL, NULL),('2008-09-12', 4, 'd', 'd'), +('2006-06-16', 8, 'g', 'g'),('2004-09-18', NULL, 'x', 'x'), +('1900-01-01', NULL, 'f', 'f'),('2005-09-13', 0, 'p', 'p'), +('2007-04-09', NULL, 'j', 'j'),('2000-09-20', 8, 'c', 'c'); +CREATE TABLE t3 ( +pk int(11) NOT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +PRIMARY KEY (pk) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t3 VALUES (1, 'c'),(2, 'c'),(3, 'q'),(4, 'g'),(5, 'e'),(6, 'l'), +(7, NULL),(8, 'v'),(9, 'c'),(10, 'u'),(11, 'x'),(12, 'x'),(13, 'x'),(14, 'l'), +(15, 'e'),(16, 's'),(17, 'k'),(18, 'm'),(19, 'x'),(20, 's'); +ANALYZE TABLE t1,t2,t3; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +EXPLAIN SELECT r1.col_date_key +FROM t2 AS r1 +WHERE r1.col_int_key NOT IN +(SELECT ir2.pk +FROM t2 AS ir1 STRAIGHT_JOIN t1 AS ir2 +ON ir2.col_varchar_nokey = ir1.col_varchar_key +WHERE ir2.col_varchar_nokey > r1.col_varchar_nokey +AND ir2.pk IN +(SELECT iir2.pk +FROM t2 AS iir1 RIGHT JOIN t3 AS iir2 +ON iir2.col_varchar_nokey = iir1.col_varchar_key)) +ORDER BY r1.col_date_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY r1 NULL ALL NULL NULL NULL NULL 20 100.00 Using where; Using filesort +2 DEPENDENT SUBQUERY NULL ALL NULL NULL NULL NULL NULL 100.00 Using where +2 DEPENDENT SUBQUERY ir1 NULL index col_varchar_key col_varchar_key 12 NULL 20 100.00 Using where; Using index; Using join buffer (hash join) +2 DEPENDENT SUBQUERY ir2 NULL eq_ref PRIMARY PRIMARY 4 func 1 100.00 Using where; Full scan on NULL key +3 MATERIALIZED iir2 NULL eq_ref PRIMARY PRIMARY 4 func 1 100.00 Full scan on NULL key +3 MATERIALIZED iir1 NULL ref col_varchar_key col_varchar_key 7 test.iir2.col_varchar_nokey 1 100.00 Using index +SELECT r1.col_date_key +FROM t2 AS r1 +WHERE r1.col_int_key NOT IN +(SELECT ir2.pk +FROM t2 AS ir1 STRAIGHT_JOIN t1 AS ir2 +ON ir2.col_varchar_nokey = ir1.col_varchar_key +WHERE ir2.col_varchar_nokey > r1.col_varchar_nokey +AND ir2.pk IN +(SELECT iir2.pk +FROM t2 AS iir1 RIGHT JOIN t3 AS iir2 +ON iir2.col_varchar_nokey = iir1.col_varchar_key)) +ORDER BY r1.col_date_key; +col_date_key +2000-04-10 +2000-09-20 +2000-12-03 +2002-10-20 +2002-11-05 +2004-09-18 +2005-09-13 +2006-06-16 +2007-01-08 +2007-06-14 +2007-11-17 +2008-05-03 +2008-06-10 +2008-09-12 +2009-02-23 +SELECT COUNT(r1.col_date_key) AS COUNT_NUM +FROM t2 AS r1 +WHERE r1.col_int_key NOT IN +(SELECT ir2.pk +FROM t2 AS ir1 STRAIGHT_JOIN t1 AS ir2 +ON ir2.col_varchar_nokey = ir1.col_varchar_key +WHERE ir2.col_varchar_nokey > r1.col_varchar_nokey +AND ir2.pk IN +(SELECT iir2.pk +FROM t2 AS iir1 RIGHT JOIN t3 AS iir2 +ON iir2.col_varchar_nokey = iir1.col_varchar_key +WHERE iir2.pk<3)); +COUNT_NUM +15 +DROP TABLE t1,t2,t3; +# +# Bug#20554585 ASSERT JOIN()->TABLES == 0... IN JOIN_TAB::GET_SJ_STRATEGY ON SUBQUERY + VAR +# +CREATE TABLE t1 ( +pk int NOT NULL, +PRIMARY KEY (pk) +); +CREATE TABLE t2 ( +pk int NOT NULL, +col_int_key int, +col_varchar_key varchar(1), +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key) +); +CREATE TABLE t3 ( +pk int NOT NULL, +col_int_key int, +col_varchar_key varchar(1), +col_varchar varchar(1), +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key) +); +INSERT INTO t3 VALUES (1,4,'c','g'),(20,1,'i','p'); +CREATE TABLE t4 ( +col_int int +); +CREATE TABLE t5 ( +col_varchar_key varchar(1), +pk int NOT NULL, +col_int int, +PRIMARY KEY (pk), +KEY col_varchar_key (col_varchar_key) +); +SELECT table1.col_varchar_key AS field1 +FROM (t3 AS table1 +INNER JOIN ( +SELECT SUBQUERY1_t1.* +FROM (t1 AS SUBQUERY1_t1 +RIGHT JOIN (t2 AS SUBQUERY1_t2 +INNER JOIN t3 AS SUBQUERY1_t3 +ON (SUBQUERY1_t3.col_varchar_key = SUBQUERY1_t2.col_varchar_key) +) ON (SUBQUERY1_t3.col_int_key = SUBQUERY1_t2.pk) +) +WHERE SUBQUERY1_t2.col_varchar_key >= ANY ( +SELECT CHILD_SUBQUERY1_t2.col_varchar AS CHILD_SUBQUERY1_field1 +FROM (t2 AS CHILD_SUBQUERY1_t1 +LEFT OUTER JOIN t3 AS CHILD_SUBQUERY1_t2 +ON (CHILD_SUBQUERY1_t2.col_int_key = CHILD_SUBQUERY1_t1.col_int_key) +) +WHERE CHILD_SUBQUERY1_t1.pk >= SUBQUERY1_t2.pk +) +) AS table2 +ON (table2.pk = table1.pk) +) +WHERE (EXISTS (( +SELECT DISTINCT SUBQUERY2_t2.col_int AS SUBQUERY2_field1 +FROM (t4 AS SUBQUERY2_t1 +LEFT OUTER JOIN t5 AS SUBQUERY2_t2 +ON (SUBQUERY2_t2.pk = SUBQUERY2_t1.col_int) +) +WHERE SUBQUERY2_t2.col_varchar_key != @var4 +))) +AND table1.col_int_key < (35 + 192) +ORDER BY field1 +; +field1 +DROP TABLE t1, t2, t3, t4, t5; +# +# Bug#18892055: MISSING DATA ON SELECT ... IN WITH JOINS AND INNODB +# ENGINE +# +CREATE TABLE t1 ( +col_int_key INT, +pk INT NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +) ENGINE = INNODB; +INSERT INTO t1 VALUES +( 0, 3 ), +( 0, 4 ), +( 3, 1 ), +( 900000000, 2 ), +( 1368719360, 5 ), +( 1922236416, 6 ), +( 8,7 ); +CREATE TABLE t2 ( +pk INT NOT NULL, +col_int INT, +PRIMARY KEY (pk) +) ENGINE = INNODB; +INSERT INTO t2 VALUES +( 1, 3 ), +( 2, 2 ), +( 3, 8 ), +( 4, 7 ); +CREATE TABLE t3 ( +col_int_key INT, +col_int INT, +KEY (col_int_key) +) ENGINE = INNODB; +INSERT INTO t3 VALUES +( 5, 1 ), +( -1, -1 ), +( 300000000, 1 ), +( 8, 1 ); +CREATE TABLE t4 ( col_int_key INT ) ENGINE = INNODB; +INSERT INTO t4 VALUES +(0), +(3), +(8), +(900000000), +(1368719360), +(1922236416); +ANALYZE TABLE t1, t2, t3, t4; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +test.t4 analyze status OK +explain SELECT * +FROM t4 +WHERE (col_int_key) IN ( +SELECT t1.col_int_key +FROM t1 LEFT JOIN ( t2 JOIN t3 ON t3.col_int_key = t2.col_int ) USING ( pk ) +WHERE t3.col_int IS NULL +) +ORDER BY col_int_key +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index col_int_key col_int_key 5 NULL 7 100.00 Using index; Using temporary; Using filesort; Start temporary +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.pk 1 100.00 NULL +1 SIMPLE t3 NULL ALL col_int_key NULL NULL NULL 4 25.00 Using where +1 SIMPLE t4 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`col_int_key` AS `col_int_key` from `test`.`t4` semi join (`test`.`t1` left join (`test`.`t2` join `test`.`t3`) on(((`test`.`t1`.`pk` = `test`.`t2`.`pk`) and (`test`.`t3`.`col_int_key` = `test`.`t2`.`col_int`)))) where ((`test`.`t4`.`col_int_key` = `test`.`t1`.`col_int_key`) and (`test`.`t3`.`col_int` is null)) order by `test`.`t4`.`col_int_key` +explain format=tree SELECT * +FROM t4 +WHERE (col_int_key) IN ( +SELECT t1.col_int_key +FROM t1 LEFT JOIN ( t2 JOIN t3 ON t3.col_int_key = t2.col_int ) USING ( pk ) +WHERE t3.col_int IS NULL +) +ORDER BY col_int_key +; +EXPLAIN +-> Sort: t4.col_int_key + -> Stream results (cost=7.85 rows=7) + -> Remove duplicate t4 rows using temporary table (weedout) (cost=7.85 rows=7) + -> Inner hash join (t4.col_int_key = t1.col_int_key) (cost=7.85 rows=7) + -> Table scan on t4 (cost=0.35 rows=6) + -> Hash + -> Filter: (t3.col_int is null) (cost=3.40 rows=7) + -> Nested loop left join (cost=3.40 rows=7) + -> Index scan on t1 using col_int_key (cost=0.95 rows=7) + -> Nested loop inner join (cost=1.21 rows=1) + -> Single-row index lookup on t2 using PRIMARY (pk=t1.pk) (cost=0.26 rows=1) + -> Filter: (t3.col_int_key = t2.col_int) (cost=0.09 rows=1) + -> Table scan on t3 (cost=0.09 rows=4) + +SELECT * +FROM t4 +WHERE (col_int_key) IN ( +SELECT t1.col_int_key +FROM t1 LEFT JOIN ( t2 JOIN t3 ON t3.col_int_key = t2.col_int ) USING ( pk ) +WHERE t3.col_int IS NULL +) +ORDER BY col_int_key +; +col_int_key +0 +3 +8 +900000000 +1368719360 +1922236416 +DROP TABLE t1, t2, t3, t4; +# +# Bug#20835095 CRASH AT CREATE_REF_FOR_KEY IN SQL/SQL_SELECT.CC +# +CREATE TABLE t1 ( +pk INTEGER, +var_10_latin1 VARCHAR(10) CHARACTER SET latin1, +var_255_utf8 VARCHAR(255) CHARACTER SET utf8, +var_255_latin1 VARCHAR(255) CHARACTER SET latin1, +var_10_utf8 VARCHAR(10) CHARACTER SET utf8, +PRIMARY KEY (pk) +); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +CREATE VIEW v1 AS SELECT * FROM t1; +INSERT INTO t1 VALUES +(1,'FROCJ','korrhrspki','UAYVL','BPZIS'), +(2,'him','a','CHYKN','OZZQT'), +(3,'WBITK','ULWBF','have','rhrh'), +(4,'or','right','up','it'), +(5,'GGDCP','x','who','as'), +(6,'j','i','e','w'); +CREATE TABLE tv +SELECT var_255_utf8 AS field1 +FROM t1; +EXPLAIN SELECT * FROM tv +WHERE field1 IN ( +SELECT tv1.var_255_utf8 +FROM v1 AS tv1 LEFT JOIN v1 AS tv2 ON tv1.var_10_latin1=tv2.var_10_utf8); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE tv NULL ALL NULL NULL NULL NULL 6 100.00 Using where +1 SIMPLE NULL eq_ref 768 test.tv.field1 1 100.00 NULL +2 MATERIALIZED t1 NULL ALL NULL NULL NULL NULL 6 100.00 NULL +2 MATERIALIZED t1 NULL ALL NULL NULL NULL NULL 6 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`tv`.`field1` AS `field1` from `test`.`tv` semi join (`test`.`t1` left join (`test`.`t1`) on((`test`.`t1`.`var_10_latin1` = `test`.`t1`.`var_10_utf8`))) where (``.`var_255_utf8` = `test`.`tv`.`field1`) +SELECT * FROM tv +WHERE field1 IN ( +SELECT tv1.var_255_utf8 +FROM v1 AS tv1 LEFT JOIN v1 AS tv2 ON tv1.var_10_latin1=tv2.var_10_utf8); +field1 +korrhrspki +a +ULWBF +right +x +i +DROP VIEW v1; +DROP TABLE t1, tv; +# 17832047 Crash in calculate_materialization_costs +CREATE TABLE t1(a INTEGER PRIMARY KEY); +INSERT INTO t1 VALUES (0),(1),(2); +SELECT 1 FROM t1 +WHERE 1 IN +(SELECT 1 BETWEEN (LENGTH(a) IN (SELECT 1 FROM t1)) AND 1 +FROM t1 +); +1 +1 +1 +1 +DROP TABLE t1; +# 17845989 Assertion failed: !(used_tables() & ... +CREATE TABLE a(b INTEGER) engine=innodb; +CREATE TABLE c(a INTEGER) engine=innodb; +SELECT 1 +FROM a +WHERE 1 IN (SELECT (a.b IS NULL) IN (SELECT 1 FROM c) FROM c) +; +1 +DROP TABLE a, c; +# +# Bug#18194196: OPTIMIZER EXECUTES STATEMENT INPERFORMANT +# +CREATE TABLE t1 (uid INTEGER, fid INTEGER, INDEX(uid)); +INSERT INTO t1 VALUES +(1,1), (1,2), (1,3), (1,4), +(2,5), (2,6), (2,7), (2,8), +(3,1), (3,2), (3,9); +CREATE TABLE t2 (uid INT PRIMARY KEY, name VARCHAR(128), INDEX(name)); +INSERT INTO t2 VALUES +(1, "A"), (2, "B"), (3, "C"), (4, "D"), (5, "E"), +(6, "F"), (7, "G"), (8, "H"), (9, "I"); +CREATE TABLE t3 (uid INT, fid INT, INDEX(uid)); +INSERT INTO t3 VALUES +(1,1), (1,2), (1,3),(1,4), +(2,5), (2,6), (2,7), (2,8), +(3,1), (3,2), (3,9); +CREATE TABLE t4 (uid INT PRIMARY KEY, name VARCHAR(128), INDEX(name)); +INSERT INTO t4 VALUES +(1, "A"), (2, "B"), (3, "C"), (4, "D"), (5, "E"), +(6, "F"), (7, "G"), (8, "H"), (9, "I"); +ANALYZE TABLE t1,t2,t3,t4; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +test.t4 analyze status OK +EXPLAIN SELECT name FROM t2, t1 +WHERE t1.uid IN (SELECT t4.uid FROM t4, t3 WHERE t3.uid=1 AND t4.uid=t3.fid) +AND t2.uid=t1.fid; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ref uid uid 5 const 4 100.00 Using where; Start temporary +1 SIMPLE t4 NULL eq_ref PRIMARY PRIMARY 4 test.t3.fid 1 100.00 Using index +1 SIMPLE t1 NULL ref uid uid 5 test.t3.fid 4 100.00 Using where +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.fid 1 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`name` AS `name` from `test`.`t4` join `test`.`t2` join `test`.`t1` semi join (`test`.`t3`) where ((`test`.`t4`.`uid` = `test`.`t3`.`fid`) and (`test`.`t1`.`uid` = `test`.`t3`.`fid`) and (`test`.`t3`.`uid` = 1) and (`test`.`t2`.`uid` = `test`.`t1`.`fid`)) +FLUSH STATUS; +SELECT name FROM t2, t1 +WHERE t1.uid IN (SELECT t4.uid FROM t4, t3 WHERE t3.uid=1 AND t4.uid=t3.fid) +AND t2.uid=t1.fid; +name +A +A +B +B +C +D +E +F +G +H +I +SHOW STATUS LIKE '%handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 20 +Handler_read_last 0 +Handler_read_next 15 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +DROP TABLE t1,t2,t3,t4; +# End of test for Bug#18194196 +# +# Bug#21184091 ASSERT `READ_ROWS >= 0.0' AT +# COST_MODEL_SERVER::TMPTABLE_READWRITE_COST() +# +CREATE TABLE t1 ( +pk INTEGER, +col_varchar varchar(1), +col_int INTEGER, +PRIMARY KEY (pk) +) ENGINE=MyISAM; +CREATE TABLE t2 ( +col_int INTEGER, +col_varchar varchar(1) +) ENGINE=MyISAM; +INSERT INTO t2 VALUES (7,'x'); +INSERT INTO t2 VALUES (4,'z'); +SELECT t2.col_varchar +FROM t2 STRAIGHT_JOIN t1 ON t2.col_varchar = t1.col_varchar +JOIN t2 AS table3 ON t1.pk = table3.col_int +WHERE t1.pk IN (SELECT col_int FROM t1); +col_varchar +DROP TABLE t1,t2; +# End of test for Bug#21184091 +# Bug#21139722: Assertion failed: !(used_tables() & ((table_map) 1) ... +CREATE TABLE t1(a INTEGER) engine=innodb; +CREATE TABLE t2(b INTEGER) engine=innodb; +explain SELECT 1 +FROM (SELECT 1 IN (SELECT 1 +FROM t1 +WHERE (SELECT 1 FROM t2 HAVING b) NOT IN (SELECT 1 FROM t2) +) +FROM t2 +) AS z; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DERIVED t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +3 DEPENDENT SUBQUERY t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +5 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +4 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1276 Field or reference 'b' of SELECT #4 was resolved in SELECT #2 +Note 1003 /* select#1 */ select 1 AS `1` from (/* select#2 */ select (1,(/* select#3 */ select 1 from `test`.`t1` where ((/* select#4 */ select 1 from `test`.`t2` having (0 <> `test`.`t2`.`b`)),(/* select#5 */ select 1 from `test`.`t2` where (outer_field_is_not_null, (((/* select#4 */ select 1 from `test`.`t2` having (0 <> `test`.`t2`.`b`))) = 1), true)) is false))) AS `1 IN (SELECT 1 +FROM t1 +WHERE (SELECT 1 FROM t2 HAVING b) NOT IN (SELECT 1 FROM t2) +)` from `test`.`t2`) `z` +SELECT 1 +FROM (SELECT 1 IN (SELECT 1 +FROM t1 +WHERE (SELECT 1 FROM t2 HAVING b) NOT IN (SELECT 1 FROM t2) +) +FROM t2 +) AS z; +1 +DROP TABLE t1, t2; +CREATE TABLE t1(a INTEGER) engine=innodb; +explain SELECT (SELECT a FROM t1 AS t2 +WHERE a IN (SELECT t1.a+t2.a FROM t1 AS t3)) +FROM t1 AS t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 DEPENDENT SUBQUERY t3 NULL ALL NULL NULL NULL NULL 1 100.00 FirstMatch(t2); Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #3 was resolved in SELECT #1 +Note 1276 Field or reference 'test.t2.a' of SELECT #3 was resolved in SELECT #2 +Note 1003 /* select#1 */ select (/* select#2 */ select `test`.`t2`.`a` from `test`.`t1` `t2` semi join (`test`.`t1` `t3`) where (`test`.`t2`.`a` = (`test`.`t1`.`a` + `test`.`t2`.`a`))) AS `(SELECT a FROM t1 AS t2 +WHERE a IN (SELECT t1.a+t2.a FROM t1 AS t3))` from `test`.`t1` +SELECT (SELECT a FROM t1 AS t2 +WHERE a IN (SELECT t1.a+t2.a FROM t1 AS t3)) +FROM t1 AS t1; +(SELECT a FROM t1 AS t2 +WHERE a IN (SELECT t1.a+t2.a FROM t1 AS t3)) +DROP TABLE t1; +# End of test for Bug#21139722 +SET DEFAULT_STORAGE_ENGINE=INNODB; +# +# Bug#21139402 ASSERTION FAILED: LENGTH > 0 && KEYPARTS != 0, CRASH IN JOIN::OPTIMIZE_KEYUSE +# +CREATE TABLE t1 (a INT, b INT, PRIMARY KEY(a)); +CREATE TABLE t2 (c INT PRIMARY KEY); +EXPLAIN SELECT 1 FROM t1 +WHERE 1 IN +(SELECT (c IS NULL) IN (SELECT a FROM t1 WHERE b) FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +3 SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` semi join (`test`.`t2`) where false +SELECT 1 FROM t1 +WHERE 1 IN +(SELECT (c IS NULL) IN (SELECT a FROM t1 WHERE b) FROM t2); +1 +DROP TABLE t1,t2; +# +# Bug#21619634 ACCESS OF DEALLOCATED ITEM_OUTER_REF CAUSES CRASH: PREPARED STMT +# +create table cc (i int) engine="innodb"; +insert into cc values (1); +select (select count(i) from cc as cc_alias +where (cc.i in (select cc_alias.i from cc))) +from cc group by i; +(select count(i) from cc as cc_alias +where (cc.i in (select cc_alias.i from cc))) +1 +prepare stmt from +"select (select count(i) from cc as cc_alias + where (cc.i in (select cc_alias.i from cc))) + from cc group by i"; +execute stmt; +(select count(i) from cc as cc_alias + where (cc.i in (select cc_alias.i from cc))) +1 +execute stmt; +(select count(i) from cc as cc_alias + where (cc.i in (select cc_alias.i from cc))) +1 +drop table cc; +# +# Bug #22305361: QUERY WITH MATERIALIZED TABLE RETURNS INCORRECT +# RESULTS IN 5.6 +# +CREATE TABLE t(a INT,b INT); +INSERT INTO t VALUES (1,0),(1,0),(1,0),(1,0),(1,1); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +EXPLAIN SELECT * +FROM t AS t1 +WHERE t1.a IN (SELECT t2.a +FROM t AS t2 +WHERE CONCAT(t2.a,'') NOT IN (SELECT t3.a +FROM t AS t3 +WHERE t3.b=1)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 5 100.00 Using where +1 PRIMARY NULL eq_ref 5 test.t1.a 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 5 100.00 Using where +3 SUBQUERY t3 NULL ALL NULL NULL NULL NULL 5 20.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t` `t1` semi join (`test`.`t` `t2`) where ((``.`a` = `test`.`t1`.`a`) and (concat(`test`.`t2`.`a`,''),concat(`test`.`t2`.`a`,'') in ( (/* select#3 */ select `test`.`t3`.`a` from `test`.`t` `t3` where (`test`.`t3`.`b` = 1) having true ), (concat(`test`.`t2`.`a`,'') in on where ((concat(`test`.`t2`.`a`,'') = ``.`a`)))) is false)) +SELECT * +FROM t AS t1 +WHERE t1.a IN (SELECT t2.a +FROM t AS t2 +WHERE CONCAT(t2.a,'') NOT IN (SELECT t3.a +FROM t AS t3 +WHERE t3.b=1)); +a b +DROP TABLE t; +# +# Bug#24287772 SUBQUERY RETURNS EMPTY LIST WHILE IDENTICAL QUERY +# WITH JOIN RETURNS RESULT +# +CREATE TABLE t SELECT 4096 c; +SELECT c FROM t WHERE 1 IN +(SELECT t.c = page_size FROM information_schema.innodb_cmpmem); +c +4096 +DROP TABLE t; +# +# Bug #29132639: WL#12470: SIG 6 IN CONNECTJOINS|SQL/SQL_EXECUTOR.C +# +CREATE TABLE t1 ( f1 TIME, f2 VARCHAR(1) ); +INSERT INTO t1 VALUES ('08:35:24', 'X'), ('14:51:13', 'S'), ('11:22:33', 'Q'); +CREATE TABLE t2 ( pk INTEGER ); +INSERT INTO t2 VALUES (1), (2); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN FORMAT=tree SELECT * FROM t1 WHERE EXISTS ( SELECT alias1.f2 FROM t2 LEFT JOIN t1 ON 1 LEFT JOIN t1 AS alias1 ON 1 ); +EXPLAIN +-> Remove duplicate t1 rows using temporary table (weedout) (cost=6.20 rows=54) + -> Left hash join (no condition) (cost=6.20 rows=54) + -> Left hash join (no condition) (cost=2.14 rows=18) + -> Inner hash join (no condition) (cost=1.30 rows=6) + -> Table scan on t1 (cost=0.28 rows=3) + -> Hash + -> Table scan on t2 (cost=0.45 rows=2) + -> Hash + -> Table scan on t1 (cost=0.09 rows=3) + -> Hash + -> Table scan on alias1 (cost=0.55 rows=3) + +SELECT * FROM t1 WHERE EXISTS ( SELECT alias1.f2 FROM t2 LEFT JOIN t1 ON 1 LEFT JOIN t1 AS alias1 ON 1 ); +f1 f2 +08:35:24 X +11:22:33 Q +14:51:13 S +DROP TABLE t1, t2; +set optimizer_switch=default; diff --git a/mysql-test/r/subquery_sj_all_bka.result-pq b/mysql-test/r/subquery_sj_all_bka.result-pq new file mode 100644 index 000000000000..aed59a46718d --- /dev/null +++ b/mysql-test/r/subquery_sj_all_bka.result-pq @@ -0,0 +1,13000 @@ +set optimizer_switch='batched_key_access=on,mrr_cost_based=off'; +set optimizer_switch='semijoin=on,materialization=on,firstmatch=on,loosescan=on,index_condition_pushdown=on,mrr=on,mrr_cost_based=off'; +set @old_opt_switch=@@optimizer_switch; +set optimizer_switch='subquery_materialization_cost_based=off'; +drop table if exists t0, t1, t2, t10, t11, t12; +create table t1 (a int not null, b int, primary key (a)); +create table t2 (a int not null, primary key (a)); +create table t3 (a int not null, b int, primary key (a)); +insert into t1 values (1,10), (2,20), (3,30), (4,40); +insert into t2 values (2), (3), (4), (5); +insert into t3 values (10,3), (20,4), (30,5); +select * from t2 where t2.a in (select a from t1); +a +2 +3 +4 +explain select * from t2 where t2.a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index PRIMARY PRIMARY 4 NULL 4 100.00 Using index +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t1` join `test`.`t2` where (`test`.`t1`.`a` = `test`.`t2`.`a`) +select * from t2 where t2.a in (select a from t1 where t1.b <> 30); +a +2 +4 +explain select * from t2 where t2.a in (select a from t1 where t1.b <> 30); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL PRIMARY NULL NULL NULL 4 75.00 Using where +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`a` = `test`.`t1`.`a`) and (`test`.`t1`.`b` <> 30)) +select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a); +a +2 +3 +explain select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL index PRIMARY PRIMARY 4 NULL 3 100.00 Using index +1 SIMPLE t1 NULL ALL PRIMARY NULL NULL NULL 4 25.00 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t1` join `test`.`t3` join `test`.`t2` where ((`test`.`t2`.`a` = `test`.`t1`.`a`) and (`test`.`t1`.`b` = `test`.`t3`.`a`)) +drop table t1, t2, t3; +create table t1 (a int, b int, index a (a,b)); +create table t2 (a int, index a (a)); +create table t3 (a int, b int, index a (a)); +insert into t1 values (1,10), (2,20), (3,30), (4,40); +create table t0(a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +insert into t1 +select rand()*100000+200,rand()*100000 from t0 A, t0 B, t0 C, t0 D; +insert into t2 values (2), (3), (4), (5); +insert into t3 values (10,3), (20,4), (30,5); +select * from t2 where t2.a in (select a from t1); +a +2 +3 +4 +explain select * from t2 where t2.a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index a a 5 NULL 4 100.00 Using where; Using index +1 SIMPLE t1 NULL ref a a 5 test.t2.a 101 100.00 Using index; FirstMatch(t2) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1`) where (`test`.`t1`.`a` = `test`.`t2`.`a`) +select * from t2 where t2.a in (select a from t1 where t1.b <> 30); +a +2 +4 +explain select * from t2 where t2.a in (select a from t1 where t1.b <> 30); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index a a 5 NULL 4 100.00 Using where; Using index +1 SIMPLE t1 NULL ref a a 5 test.t2.a 101 90.00 Using where; Using index; FirstMatch(t2) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1`) where ((`test`.`t1`.`a` = `test`.`t2`.`a`) and (`test`.`t1`.`b` <> 30)) +select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a); +a +2 +3 +explain select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index a a 5 NULL 4 100.00 Using where; Using index +1 SIMPLE t3 NULL index a a 5 NULL 3 100.00 Using where; Using index +1 SIMPLE t1 NULL ref a a 10 test.t2.a,test.t3.a 116 100.00 Using index; FirstMatch(t2) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1` join `test`.`t3`) where ((`test`.`t1`.`a` = `test`.`t2`.`a`) and (`test`.`t1`.`b` = `test`.`t3`.`a`)) +insert into t1 values (3,31); +select * from t2 where t2.a in (select a from t1 where t1.b <> 30); +a +2 +3 +4 +select * from t2 where t2.a in (select a from t1 where t1.b <> 30 and t1.b <> 31); +a +2 +4 +explain select * from t2 where t2.a in (select a from t1 where t1.b <> 30); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index a a 5 NULL 4 100.00 Using where; Using index +1 SIMPLE t1 NULL ref a a 5 test.t2.a 101 90.00 Using where; Using index; FirstMatch(t2) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1`) where ((`test`.`t1`.`a` = `test`.`t2`.`a`) and (`test`.`t1`.`b` <> 30)) +drop table t0, t1, t2, t3; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1(a int, b int); +insert into t1 values (0,0),(1,1),(2,2); +create table t2 as select * from t1; +create table t11(a int, b int); +create table t10 (pk int, a int, primary key(pk)); +insert into t10 select a,a from t0; +create table t12 like t10; +insert into t12 select * from t10; +Flattened because of dependency, t10=func(t1) +explain select * from t1 where a in (select pk from t10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t1` where (`test`.`t10`.`pk` = `test`.`t1`.`a`) +select * from t1 where a in (select pk from t10); +a b +0 0 +1 1 +2 2 +A confluent case of dependency +explain select * from t1 where a in (select a from t10 where pk=12); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t1` where (multiple equal(12, NULL) and multiple equal(`test`.`t1`.`a`, NULL)) +select * from t1 where a in (select a from t10 where pk=12); +a b +explain select * from t1 where a in (select a from t10 where pk=9); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t10 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t1` where ((`test`.`t1`.`a` = '9')) +select * from t1 where a in (select a from t10 where pk=9); +a b +An empty table inside +explain select * from t1 where a in (select a from t11); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 0.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +2 MATERIALIZED t11 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t11`) where (`test`.`t1`.`a` = ``.`a`) +select * from t1 where a in (select a from t11); +a b +explain select * from t1 where a in (select pk from t10) and b in (select pk from t10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using index +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.t1.b 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t10` join `test`.`t1` where ((`test`.`t10`.`pk` = `test`.`t1`.`b`) and (`test`.`t10`.`pk` = `test`.`t1`.`a`)) +select * from t1 where a in (select pk from t10) and b in (select pk from t10); +a b +0 0 +1 1 +2 2 +flattening a nested subquery +explain select * from t1 where a in (select pk from t10 where t10.a in (select pk from t12)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using where; Using join buffer (Batched Key Access) +1 SIMPLE t12 NULL eq_ref PRIMARY PRIMARY 4 test.t10.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t12` join `test`.`t1` where ((`test`.`t10`.`pk` = `test`.`t1`.`a`) and (`test`.`t12`.`pk` = `test`.`t10`.`a`)) +select * from t1 where a in (select pk from t10 where t10.a in (select pk from t12)); +a b +0 0 +1 1 +2 2 +flattening subquery w/ several tables +explain select * from t1 where a in (select t10.pk from t10, t12 where t12.pk=t10.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using where; Using join buffer (Batched Key Access) +1 SIMPLE t12 NULL eq_ref PRIMARY PRIMARY 4 test.t10.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t12` join `test`.`t1` where ((`test`.`t10`.`pk` = `test`.`t1`.`a`) and (`test`.`t12`.`pk` = `test`.`t10`.`a`)) +subqueries within outer joins go into ON expr. +explain +select * from t1 left join (t2 A, t2 B) on ( A.A= t1.A and B.A in (select pk from t10)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE A NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE B NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.B.A 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`A` AS `A`,`test`.`t1`.`B` AS `B`,`test`.`A`.`A` AS `A`,`test`.`A`.`B` AS `B`,`test`.`B`.`A` AS `A`,`test`.`B`.`B` AS `B` from `test`.`t1` left join (`test`.`t10` join `test`.`t2` `A` join `test`.`t2` `B`) on(((`test`.`t10`.`pk` = `test`.`B`.`A`) and (`test`.`A`.`A` = `test`.`t1`.`A`))) where true +t2 should be wrapped into OJ-nest, so we have "t1 LJ (t2 J t10)" +explain +select * from t1 left join t2 on (t2.A= t1.A and t2.A in (select pk from t10)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.t1.A 1 100.00 Using index +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`A` AS `A`,`test`.`t1`.`B` AS `B`,`test`.`t2`.`A` AS `A`,`test`.`t2`.`B` AS `B` from `test`.`t1` left join (`test`.`t10` join `test`.`t2`) on(((`test`.`t10`.`pk` = `test`.`t1`.`A`) and (`test`.`t2`.`A` = `test`.`t1`.`A`))) where true +we shouldn't flatten if we're going to get a join of > MAX_TABLES. +explain select * from +t1 s00, t1 s01, t1 s02, t1 s03, t1 s04,t1 s05,t1 s06,t1 s07,t1 s08,t1 s09, +t1 s10, t1 s11, t1 s12, t1 s13, t1 s14,t1 s15,t1 s16,t1 s17,t1 s18,t1 s19, +t1 s20, t1 s21, t1 s22, t1 s23, t1 s24,t1 s25,t1 s26,t1 s27,t1 s28,t1 s29, +t1 s30, t1 s31, t1 s32, t1 s33, t1 s34,t1 s35,t1 s36,t1 s37,t1 s38,t1 s39, +t1 s40, t1 s41, t1 s42, t1 s43, t1 s44,t1 s45,t1 s46,t1 s47,t1 s48,t1 s49 +where +s00.a in ( +select m00.a from +t1 m00, t1 m01, t1 m02, t1 m03, t1 m04,t1 m05,t1 m06,t1 m07,t1 m08,t1 m09, +t1 m10, t1 m11, t1 m12, t1 m13, t1 m14,t1 m15,t1 m16,t1 m17,t1 m18,t1 m19 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY s00 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 PRIMARY s01 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s02 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s03 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s04 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s05 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s06 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s07 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s08 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s09 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s10 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s11 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s12 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s13 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s14 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s15 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s16 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s17 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s18 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s19 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s20 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s21 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s22 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s23 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s24 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s25 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s26 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s27 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s28 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s29 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s30 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s31 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s32 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s33 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s34 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s35 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s36 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s37 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s38 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s39 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s40 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s41 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s42 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s43 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s44 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s45 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s46 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s47 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s48 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s49 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 SUBQUERY m00 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 SUBQUERY m01 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 SUBQUERY m02 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 SUBQUERY m03 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 SUBQUERY m04 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 SUBQUERY m05 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 SUBQUERY m06 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 SUBQUERY m07 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 SUBQUERY m08 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 SUBQUERY m09 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 SUBQUERY m10 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 SUBQUERY m11 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 SUBQUERY m12 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 SUBQUERY m13 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 SUBQUERY m14 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 SUBQUERY m15 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 SUBQUERY m16 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 SUBQUERY m17 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 SUBQUERY m18 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 SUBQUERY m19 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`s00`.`a` AS `a`,`test`.`s00`.`b` AS `b`,`test`.`s01`.`a` AS `a`,`test`.`s01`.`b` AS `b`,`test`.`s02`.`a` AS `a`,`test`.`s02`.`b` AS `b`,`test`.`s03`.`a` AS `a`,`test`.`s03`.`b` AS `b`,`test`.`s04`.`a` AS `a`,`test`.`s04`.`b` AS `b`,`test`.`s05`.`a` AS `a`,`test`.`s05`.`b` AS `b`,`test`.`s06`.`a` AS `a`,`test`.`s06`.`b` AS `b`,`test`.`s07`.`a` AS `a`,`test`.`s07`.`b` AS `b`,`test`.`s08`.`a` AS `a`,`test`.`s08`.`b` AS `b`,`test`.`s09`.`a` AS `a`,`test`.`s09`.`b` AS `b`,`test`.`s10`.`a` AS `a`,`test`.`s10`.`b` AS `b`,`test`.`s11`.`a` AS `a`,`test`.`s11`.`b` AS `b`,`test`.`s12`.`a` AS `a`,`test`.`s12`.`b` AS `b`,`test`.`s13`.`a` AS `a`,`test`.`s13`.`b` AS `b`,`test`.`s14`.`a` AS `a`,`test`.`s14`.`b` AS `b`,`test`.`s15`.`a` AS `a`,`test`.`s15`.`b` AS `b`,`test`.`s16`.`a` AS `a`,`test`.`s16`.`b` AS `b`,`test`.`s17`.`a` AS `a`,`test`.`s17`.`b` AS `b`,`test`.`s18`.`a` AS `a`,`test`.`s18`.`b` AS `b`,`test`.`s19`.`a` AS `a`,`test`.`s19`.`b` AS `b`,`test`.`s20`.`a` AS `a`,`test`.`s20`.`b` AS `b`,`test`.`s21`.`a` AS `a`,`test`.`s21`.`b` AS `b`,`test`.`s22`.`a` AS `a`,`test`.`s22`.`b` AS `b`,`test`.`s23`.`a` AS `a`,`test`.`s23`.`b` AS `b`,`test`.`s24`.`a` AS `a`,`test`.`s24`.`b` AS `b`,`test`.`s25`.`a` AS `a`,`test`.`s25`.`b` AS `b`,`test`.`s26`.`a` AS `a`,`test`.`s26`.`b` AS `b`,`test`.`s27`.`a` AS `a`,`test`.`s27`.`b` AS `b`,`test`.`s28`.`a` AS `a`,`test`.`s28`.`b` AS `b`,`test`.`s29`.`a` AS `a`,`test`.`s29`.`b` AS `b`,`test`.`s30`.`a` AS `a`,`test`.`s30`.`b` AS `b`,`test`.`s31`.`a` AS `a`,`test`.`s31`.`b` AS `b`,`test`.`s32`.`a` AS `a`,`test`.`s32`.`b` AS `b`,`test`.`s33`.`a` AS `a`,`test`.`s33`.`b` AS `b`,`test`.`s34`.`a` AS `a`,`test`.`s34`.`b` AS `b`,`test`.`s35`.`a` AS `a`,`test`.`s35`.`b` AS `b`,`test`.`s36`.`a` AS `a`,`test`.`s36`.`b` AS `b`,`test`.`s37`.`a` AS `a`,`test`.`s37`.`b` AS `b`,`test`.`s38`.`a` AS `a`,`test`.`s38`.`b` AS `b`,`test`.`s39`.`a` AS `a`,`test`.`s39`.`b` AS `b`,`test`.`s40`.`a` AS `a`,`test`.`s40`.`b` AS `b`,`test`.`s41`.`a` AS `a`,`test`.`s41`.`b` AS `b`,`test`.`s42`.`a` AS `a`,`test`.`s42`.`b` AS `b`,`test`.`s43`.`a` AS `a`,`test`.`s43`.`b` AS `b`,`test`.`s44`.`a` AS `a`,`test`.`s44`.`b` AS `b`,`test`.`s45`.`a` AS `a`,`test`.`s45`.`b` AS `b`,`test`.`s46`.`a` AS `a`,`test`.`s46`.`b` AS `b`,`test`.`s47`.`a` AS `a`,`test`.`s47`.`b` AS `b`,`test`.`s48`.`a` AS `a`,`test`.`s48`.`b` AS `b`,`test`.`s49`.`a` AS `a`,`test`.`s49`.`b` AS `b` from `test`.`t1` `s00` join `test`.`t1` `s01` join `test`.`t1` `s02` join `test`.`t1` `s03` join `test`.`t1` `s04` join `test`.`t1` `s05` join `test`.`t1` `s06` join `test`.`t1` `s07` join `test`.`t1` `s08` join `test`.`t1` `s09` join `test`.`t1` `s10` join `test`.`t1` `s11` join `test`.`t1` `s12` join `test`.`t1` `s13` join `test`.`t1` `s14` join `test`.`t1` `s15` join `test`.`t1` `s16` join `test`.`t1` `s17` join `test`.`t1` `s18` join `test`.`t1` `s19` join `test`.`t1` `s20` join `test`.`t1` `s21` join `test`.`t1` `s22` join `test`.`t1` `s23` join `test`.`t1` `s24` join `test`.`t1` `s25` join `test`.`t1` `s26` join `test`.`t1` `s27` join `test`.`t1` `s28` join `test`.`t1` `s29` join `test`.`t1` `s30` join `test`.`t1` `s31` join `test`.`t1` `s32` join `test`.`t1` `s33` join `test`.`t1` `s34` join `test`.`t1` `s35` join `test`.`t1` `s36` join `test`.`t1` `s37` join `test`.`t1` `s38` join `test`.`t1` `s39` join `test`.`t1` `s40` join `test`.`t1` `s41` join `test`.`t1` `s42` join `test`.`t1` `s43` join `test`.`t1` `s44` join `test`.`t1` `s45` join `test`.`t1` `s46` join `test`.`t1` `s47` join `test`.`t1` `s48` join `test`.`t1` `s49` where (`test`.`s00`.`a`,`test`.`s00`.`a` in ( (/* select#2 */ select `test`.`m00`.`a` from `test`.`t1` `m00` join `test`.`t1` `m01` join `test`.`t1` `m02` join `test`.`t1` `m03` join `test`.`t1` `m04` join `test`.`t1` `m05` join `test`.`t1` `m06` join `test`.`t1` `m07` join `test`.`t1` `m08` join `test`.`t1` `m09` join `test`.`t1` `m10` join `test`.`t1` `m11` join `test`.`t1` `m12` join `test`.`t1` `m13` join `test`.`t1` `m14` join `test`.`t1` `m15` join `test`.`t1` `m16` join `test`.`t1` `m17` join `test`.`t1` `m18` join `test`.`t1` `m19` where true ), (`test`.`s00`.`a` in on where ((`test`.`s00`.`a` = ``.`a`))))) +select * from +t1 left join t2 on (t2.a= t1.a and t2.a in (select pk from t10)) +where t1.a < 5; +a b a b +0 0 0 0 +1 1 1 1 +2 2 2 2 +prepare s1 from +' select * from + t1 left join t2 on (t2.a= t1.a and t2.a in (select pk from t10)) + where t1.a < 5'; +execute s1; +a b a b +0 0 0 0 +1 1 1 1 +2 2 2 2 +execute s1; +a b a b +0 0 0 0 +1 1 1 1 +2 2 2 2 +insert into t1 select (A.a + 10 * B.a),1 from t0 A, t0 B; +explain select * from t1 where a in (select pk from t10 where pk<3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t10 NULL range PRIMARY PRIMARY 4 NULL 4 100.00 Using where; Using index +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 103 10.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t1` where ((`test`.`t1`.`a` = `test`.`t10`.`pk`) and (`test`.`t10`.`pk` < 3)) +drop table t0, t1, t2; +drop table t10, t11, t12; +# +# Check that subqueries with outer joins or straight_join work for +# different permutations of const and non-const tables. (Ref. Bug#46692) +# +CREATE TABLE t1 (i INTEGER); +CREATE TABLE t2 (i INTEGER); +CREATE TABLE t3 (i INTEGER); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 0 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 0 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 0 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 1 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 1 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 1 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 2 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 2 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 2 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (0); +DELETE FROM t2; +INSERT INTO t1 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 0 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 0 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 0 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 1 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 1 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 1 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 2 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 2 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 2 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (0); +DELETE FROM t2; +INSERT INTO t1 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 0 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 0.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = ``.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 0.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = ``.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 0.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = ``.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 0.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 0.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t1`.`i` = ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 0 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = ``.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = ``.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = ``.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t1`.`i` = ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 0 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t2`.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t2`.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t2`.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +1 +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = `test`.`t1`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 1 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 0.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = ``.`i`) and (`test`.`t2`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 0.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = ``.`i`) and (`test`.`t2`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 0.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = ``.`i`) and (`test`.`t2`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 0.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 0.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t1`.`i` = ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 1 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = `test`.`t2`.`i`) and (`test`.`t1`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = `test`.`t2`.`i`) and (`test`.`t1`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = `test`.`t2`.`i`) and (`test`.`t1`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 1 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t2`.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t2`.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t2`.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +1 +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = `test`.`t1`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +1 +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 2 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t3`.`i`) and (`test`.`t2`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t3`.`i`) and (`test`.`t2`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t3`.`i`) and (`test`.`t2`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 0.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t1`.`i` = ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 2 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t3`.`i`) and (`test`.`t2`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t3`.`i`) and (`test`.`t2`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t3`.`i`) and (`test`.`t2`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t1`.`i` = ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 2 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = `test`.`t1`.`i`) and (`test`.`t3`.`i` = `test`.`t1`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +1 +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +1 +2 + +EXECUTE stmt; +i +1 +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = `test`.`t1`.`i`) and (`test`.`t3`.`i` = `test`.`t1`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +1 +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = `test`.`t1`.`i`) and (`test`.`t3`.`i` = `test`.`t1`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +1 +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +1 +2 + +EXECUTE stmt; +i +1 +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = `test`.`t1`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +1 +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE NULL eq_ref 5 test.t1.i 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (``.`i` = `test`.`t1`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +1 +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (0); +DELETE FROM t2; +INSERT INTO t1 VALUES (0); +DROP TABLE t1, t2, t3; +create table x1(k int primary key, d1 int, d2 int); +create table x2(k int primary key, d1 int, d2 int); +insert into x1 values +(10, 10, 10), +(20, 20, 20), +(21, 20, null), +(30, null, 30), +(40, 40, 40); +insert into x2 values +(10, 10, 10), +(20, 20, 20), +(21, 20, null), +(30, null, 30); +select * +from x1 +where (d1, d2) in (select d1, d2 +from x2); +k d1 d2 +10 10 10 +20 20 20 +select * +from x1 +where (d1, d2) in (select d1, d2 +from x2) is true; +k d1 d2 +10 10 10 +20 20 20 +select * +from x1 +where (d1, d2) in (select d1, d2 +from x2) is false; +k d1 d2 +40 40 40 +select * +from x1 +where (d1, d2) in (select d1, d2 +from x2) is unknown; +k d1 d2 +21 20 NULL +30 NULL 30 +select * +from x1 +where d1 in (select d1 +from x2 +where x1.d2=x2.d2); +k d1 d2 +10 10 10 +20 20 20 +select * +from x1 +where d1 in (select d1 +from x2 +where x1.d2=x2.d2) is true; +k d1 d2 +10 10 10 +20 20 20 +select * +from x1 +where d1 in (select d1 +from x2 +where x1.d2=x2.d2) is false; +k d1 d2 +21 20 NULL +40 40 40 +select * +from x1 +where d1 in (select d1 +from x2 +where x1.d2=x2.d2) is unknown; +k d1 d2 +30 NULL 30 +select * +from x1 +where 1 in (select 1 +from x2 +where x1.d1=x2.d1 and x1.d2=x2.d2); +k d1 d2 +10 10 10 +20 20 20 +select * +from x1 +where 1 in (select 1 +from x2 +where x1.d1=x2.d1 and x1.d2=x2.d2) is true; +k d1 d2 +10 10 10 +20 20 20 +select * +from x1 +where 1 in (select 1 +from x2 +where x1.d1=x2.d1 and x1.d2=x2.d2) is false; +k d1 d2 +21 20 NULL +30 NULL 30 +40 40 40 +select * +from x1 +where 1 in (select 1 +from x2 +where x1.d1=x2.d1 and x1.d2=x2.d2) is unknown; +k d1 d2 +select * +from x1 +where exists (select * +from x2 +where x1.d1=x2.d1 and x1.d2=x2.d2); +k d1 d2 +10 10 10 +20 20 20 +drop table x1; +drop table x2; +CREATE TABLE t1 ( +a int(11) NOT NULL, +b int(11) NOT NULL, +c datetime default NULL, +PRIMARY KEY (a), +KEY idx_bc (b,c) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES +(406989,67,'2006-02-23 17:08:46'), (150078,67,'2005-10-26 11:17:45'), +(406993,67,'2006-02-27 11:20:57'), (245655,67,'2005-12-08 15:59:08'), +(406994,67,'2006-02-27 11:26:46'), (256,67,NULL), +(398341,67,'2006-02-20 04:48:44'), (254,67,NULL),(1120,67,NULL), +(406988,67,'2006-02-23 17:07:22'), (255,67,NULL), +(398340,67,'2006-02-20 04:38:53'),(406631,67,'2006-02-23 10:49:42'), +(245653,67,'2005-12-08 15:59:07'),(406992,67,'2006-02-24 16:47:18'), +(245654,67,'2005-12-08 15:59:08'),(406995,67,'2006-02-28 11:55:00'), +(127261,67,'2005-10-13 12:17:58'),(406991,67,'2006-02-24 16:42:32'), +(245652,67,'2005-12-08 15:58:27'),(398545,67,'2006-02-20 04:53:13'), +(154504,67,'2005-10-28 11:53:01'),(9199,67,NULL),(1,67,'2006-02-23 15:01:35'), +(223456,67,NULL),(4101,67,NULL),(1133,67,NULL), +(406990,67,'2006-02-23 18:01:45'),(148815,67,'2005-10-25 15:34:17'), +(148812,67,'2005-10-25 15:30:01'),(245651,67,'2005-12-08 15:58:27'), +(154503,67,'2005-10-28 11:52:38'); +create table t11 select * from t1 where b = 67 AND (c IS NULL OR c > NOW()) order by 3 asc; +create table t12 select * from t1 where b = 67 AND (c IS NULL OR c > NOW()) order by 3 desc; +create table t21 select * from t1 where b = 67 AND (c IS NULL OR c > '2005-12-08') order by 3 asc; +create table t22 select * from t1 where b = 67 AND (c IS NULL OR c > '2005-12-08') order by 3 desc; +update t22 set c = '2005-12-08 15:58:27' where a = 255; +explain select t21.* from t21,t22 where t21.a = t22.a and +t22.a in (select t12.a from t11, t12 where t11.a in(255,256) and t11.a = t12.a and t11.c is null) and t22.c is null order by t21.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using temporary; Using filesort +1 SIMPLE t22 NULL ALL NULL NULL NULL NULL 26 3.85 Using where; Using join buffer (hash join) +1 SIMPLE t21 NULL ALL NULL NULL NULL NULL 26 10.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t11 NULL ALL NULL NULL NULL NULL 8 12.50 Using where +2 MATERIALIZED t12 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t21`.`a` AS `a`,`test`.`t21`.`b` AS `b`,`test`.`t21`.`c` AS `c` from `test`.`t21` join `test`.`t22` semi join (`test`.`t11` join `test`.`t12`) where ((`test`.`t22`.`a` = ``.`a`) and (`test`.`t21`.`a` = ``.`a`) and (`test`.`t12`.`a` = `test`.`t11`.`a`) and (`test`.`t22`.`c` is null) and (`test`.`t11`.`a` in (255,256)) and (`test`.`t11`.`c` is null)) order by `test`.`t21`.`a` +explain format=json select * from t1 where a in (select a from t11); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "6.71" + }, + "nested_loop": [ + { + "table": { + "table_name": "", + "access_type": "ALL", + "materialized_from_subquery": { + "using_temporary_table": true, + "query_block": { + "table": { + "table_name": "t11", + "access_type": "ALL", + "rows_examined_per_scan": 8, + "rows_produced_per_join": 8, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "0.80", + "prefix_cost": "1.31", + "data_read_per_join": "128" + }, + "used_columns": [ + "a" + ] + } + } + } + } + }, + { + "table": { + "table_name": "t1", + "access_type": "eq_ref", + "possible_keys": [ + "PRIMARY" + ], + "key": "PRIMARY", + "used_key_parts": [ + "a" + ], + "key_length": "4", + "ref": [ + ".a" + ], + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "using_join_buffer": "Batched Key Access", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.10", + "prefix_cost": "6.71", + "data_read_per_join": "16" + }, + "used_columns": [ + "a", + "b", + "c" + ] + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` semi join (`test`.`t11`) where (`test`.`t1`.`a` = ``.`a`) +select t21.* from t21,t22 where t21.a = t22.a and +t22.a in (select t12.a from t11, t12 where t11.a in(255,256) and t11.a = t12.a and t11.c is null) and t22.c is null order by t21.a; +a b c +256 67 NULL +drop table t1, t11, t12, t21, t22; +create table t1(a int); +insert into t1 values (0),(1); +explain +select (select max(y.a) from t1 y where a in (select a from t1 z) and a < x.a) as subq from t1 x; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY x NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DEPENDENT SUBQUERY y NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 DEPENDENT SUBQUERY z NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(y); Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.x.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select (/* select#2 */ select max(`test`.`y`.`a`) from `test`.`t1` `y` semi join (`test`.`t1` `z`) where ((`test`.`z`.`a` = `test`.`y`.`a`) and (`test`.`y`.`a` < `test`.`x`.`a`))) AS `subq` from `test`.`t1` `x` +select (select max(y.a) from t1 y where a in (select a from t1 z) and a < x.a) as subq from t1 x; +subq +NULL +0 +drop table t1; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 as select * from t0; +insert into t1 select a+10 from t0; +insert into t0 values(2); +explain select * from t1 where 2 in (select a from t0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 11 10.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 20 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t0`) where (`test`.`t0`.`a` = 2) +select * from t1 where 2 in (select a from t0); +a +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +explain select * from (select a from t0) x where a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 11 100.00 NULL +1 SIMPLE NULL eq_ref 5 func 1 100.00 Using where +3 MATERIALIZED t1 NULL ALL NULL NULL NULL NULL 20 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a` from `test`.`t0` semi join (`test`.`t1`) where (``.`a` = `test`.`t0`.`a`) +explain format=json select * from (select a from t0) x where a in (select a from t1); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "8.21" + }, + "nested_loop": [ + { + "table": { + "table_name": "t0", + "access_type": "ALL", + "rows_examined_per_scan": 11, + "rows_produced_per_join": 11, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "1.10", + "prefix_cost": "1.60", + "data_read_per_join": "88" + }, + "used_columns": [ + "a" + ] + } + }, + { + "table": { + "table_name": "", + "access_type": "eq_ref", + "key": "", + "key_length": "5", + "ref": [ + "func" + ], + "rows_examined_per_scan": 1, + "attached_condition": "(``.`a` = `test`.`t0`.`a`)", + "materialized_from_subquery": { + "using_temporary_table": true, + "query_block": { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 20, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "2.00", + "prefix_cost": "2.51", + "data_read_per_join": "160" + }, + "used_columns": [ + "a" + ] + } + } + } + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a` from `test`.`t0` semi join (`test`.`t1`) where (``.`a` = `test`.`t0`.`a`) +drop table t0, t1; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (kp1 int, kp2 int, c int, filler char(100), key(kp1, kp2)); +insert into t1 select A.a+10*(B.a+10*C.a), 0, 0, 'filler' from t0 A, t0 B, t0 C; +insert into t1 select * from t1 where kp1 < 20; +create table t3 (a int); +insert into t3 select A.a + 10*B.a from t0 A, t0 B; +explain select * from t3 where a in (select kp1 from t1 where kp1<20); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 100 100.00 Using where +1 SIMPLE NULL eq_ref 5 test.t3.a 1 100.00 NULL +2 MATERIALIZED t1 NULL range kp1 kp1 5 NULL 48 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a` from `test`.`t3` semi join (`test`.`t1`) where ((``.`kp1` = `test`.`t3`.`a`) and (`test`.`t1`.`kp1` < 20)) +select * from t3 where a in (select kp1 from t1 where kp1<20); +a +0 +1 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +2 +3 +4 +5 +6 +7 +8 +9 +explain select * from t3 where a in (select kp1 from t1 where kp1<20) and a<20; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 100 33.33 Using where +1 SIMPLE t1 NULL ref kp1 kp1 5 test.t3.a 1 100.00 Using index; FirstMatch(t3) +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a` from `test`.`t3` semi join (`test`.`t1`) where ((`test`.`t1`.`kp1` = `test`.`t3`.`a`) and (`test`.`t3`.`a` < 20) and (`test`.`t3`.`a` < 20)) +select * from t3 where a in (select kp1 from t1 where kp1<20) and a<20; +a +0 +1 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +2 +3 +4 +5 +6 +7 +8 +9 +create table t4 (pk int primary key); +insert into t4 select a from t3; +explain select * from t3 where a in +(select t1.kp1 from t1,t4 where kp1<20 and t4.pk=t1.c); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 100 100.00 Using where +1 SIMPLE NULL eq_ref 5 test.t3.a 1 100.00 NULL +2 MATERIALIZED t1 NULL range kp1 kp1 5 NULL 48 100.00 Using index condition; Using where; Using MRR +2 MATERIALIZED t4 NULL eq_ref PRIMARY PRIMARY 4 test.t1.c 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a` from `test`.`t3` semi join (`test`.`t1` join `test`.`t4`) where ((``.`kp1` = `test`.`t3`.`a`) and (`test`.`t4`.`pk` = `test`.`t1`.`c`) and (`test`.`t1`.`kp1` < 20)) +explain format=tree select * from t3 where a in +(select t1.kp1 from t1,t4 where kp1<20 and t4.pk=t1.c); +EXPLAIN +-> Nested loop inner join (cost=500.54 rows=4800) + -> Filter: (t3.a is not null) (cost=10.54 rows=100) + -> Table scan on t3 (cost=10.54 rows=100) + -> Single-row index lookup on using (kp1=t3.a) + -> Materialize with deduplication (cost=42.80..42.80 rows=48) + -> Filter: (t1.kp1 is not null) (cost=38.00 rows=48) + -> Nested loop inner join (cost=38.00 rows=48) + -> Filter: (t1.c is not null) (cost=21.20 rows=48) + -> Index range scan on t1 using kp1, with index condition: (t1.kp1 < 20) (cost=21.20 rows=48) + -> Single-row index lookup on t4 using PRIMARY (pk=t1.c) (cost=0.25 rows=1) + +select * from t3 where a in +(select t1.kp1 from t1,t4 where kp1<20 and t4.pk=t1.c); +a +0 +1 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +2 +3 +4 +5 +6 +7 +8 +9 +drop table t1, t3, t4; +create table t1 (a int); +insert into t1 values (0),(0),(0),(1),(1),(1),(2),(2),(2),(3),(3),(3); +set session internal_tmp_mem_storage_engine='memory'; +set @save_max_heap_table_size=@@max_heap_table_size; +set @@max_heap_table_size= 16384; +# Attempt to make one test that overflows the heap table when a +# non-duplicate row is inserted and one test that overflows the +# heap table when a duplicate record is inserted. Debugging showed +# that these situations occurred with max_heap_table_size=16384 +# and optimizer_join_cache_level equals 1 and 0, respectively. +# Finally execute a test that does not overflow the heap table. +explain +select count(*) from t0 a, t0 b, t0 c +where c.a in (select a from t1 d); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE a NULL ALL NULL NULL NULL NULL 10 100.00 NULL +1 SIMPLE b NULL ALL NULL NULL NULL NULL 10 100.00 Using join buffer (hash join) +1 SIMPLE c NULL ALL NULL NULL NULL NULL 10 100.00 Using where; Using join buffer (hash join) +1 SIMPLE NULL eq_ref 5 test.c.a 1 100.00 NULL +2 MATERIALIZED d NULL ALL NULL NULL NULL NULL 12 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select count(0) AS `count(*)` from `test`.`t0` `a` join `test`.`t0` `b` join `test`.`t0` `c` semi join (`test`.`t1` `d`) where (``.`a` = `test`.`c`.`a`) +flush status; +select count(*) from t0 a, t0 b, t0 c +where c.a in (select a from t1 d); +count(*) +400 +show status like 'Created_tmp_disk_tables'; +Variable_name Value +Created_tmp_disk_tables 0 +set @@max_heap_table_size= @save_max_heap_table_size; +set session internal_tmp_mem_storage_engine=default; +flush status; +select count(*) from t0 a, t0 b, t0 c +where c.a in (select a from t1 d); +count(*) +400 +show status like 'Created_tmp_disk_tables'; +Variable_name Value +Created_tmp_disk_tables 0 +drop table t0, t1; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t2(a int); +insert into t2 values (1),(2); +create table t3 ( a int , filler char(100), key(a)); +insert into t3 select A.a + 10*B.a, 'filler' from t0 A, t0 B; +explain select * from t3 where a in (select a from t2) and (a > 5 or a < 10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using where +1 SIMPLE t3 NULL ref a a 5 .a 1 100.00 Using join buffer (Batched Key Access) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a`,`test`.`t3`.`filler` AS `filler` from `test`.`t3` semi join (`test`.`t2`) where ((`test`.`t3`.`a` = ``.`a`) and ((``.`a` > 5) or (``.`a` < 10))) +select * from t3 where a in (select a from t2); +a filler +1 filler +2 filler +drop table t0, t2, t3; +create table t1 (a date); +insert into t1 values ('2008-01-01'),('2008-01-01'),('2008-02-01'),('2008-02-01'); +create table t2 (a int); +insert into t2 values (1),(2); +create table t3 (a char(10)); +insert into t3 select * from t1; +insert into t3 values (1),(2); +explain select * from t2 where a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; FirstMatch(t2); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1`) where (cast(`test`.`t2`.`a` as double) = cast(`test`.`t1`.`a` as double)) +explain select * from t2 where a in (select a from t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t2); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t2`) where (`test`.`t2`.`a` = `test`.`t2`.`a`) +explain select * from t2 where a in (select a from t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; FirstMatch(t2); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t3`) where (cast(`test`.`t2`.`a` as double) = cast(`test`.`t3`.`a` as double)) +explain select * from t1 where a in (select a from t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; FirstMatch(t1); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t3`) where (`test`.`t1`.`a` = cast(`test`.`t3`.`a` as date)) +drop table t1, t2, t3; +create table t1 (a decimal); +insert into t1 values (1),(2); +explain select * from t1 where a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t1`) where (`test`.`t1`.`a` = `test`.`t1`.`a`) +drop table t1; +create table t1 (a int); +insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t2 as select * from t1; +create table t3 (a int, b int, filler char(100), key(a)) charset utf8mb4; +insert into t3 select A.a + 10*B.a, A.a + 10*B.a, 'filler' from t1 A, t1 B, t1 C; +explain select * from t1, t3 where t3.a in (select a from t2) and (t3.a < 10 or t3.a >30) and t1.a =3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 10.00 Using where +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ref a a 5 .a 10 100.00 Using join buffer (Batched Key Access) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 10 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t3`.`filler` AS `filler` from `test`.`t1` join `test`.`t3` semi join (`test`.`t2`) where ((`test`.`t3`.`a` = ``.`a`) and (`test`.`t1`.`a` = 3) and ((``.`a` < 10) or (``.`a` > 30))) +explain format=json select * from t1, t3 where t3.a in (select a from t2) and (t3.a < 10 or t3.a >30) and t1.a =3; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "41.01" + }, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 10, + "rows_produced_per_join": 1, + "filtered": "10.00", + "cost_info": { + "read_cost": "1.40", + "eval_cost": "0.10", + "prefix_cost": "1.50", + "data_read_per_join": "8" + }, + "used_columns": [ + "a" + ], + "attached_condition": "(`test`.`t1`.`a` = 3)" + } + }, + { + "table": { + "table_name": "", + "access_type": "ALL", + "using_join_buffer": "hash join", + "attached_condition": "(((``.`a` < 10) or (``.`a` > 30)) and (``.`a` is not null))", + "materialized_from_subquery": { + "using_temporary_table": true, + "query_block": { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 10, + "rows_produced_per_join": 10, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "1.00", + "prefix_cost": "1.50", + "data_read_per_join": "80" + }, + "used_columns": [ + "a" + ] + } + } + } + } + }, + { + "table": { + "table_name": "t3", + "access_type": "ref", + "possible_keys": [ + "a" + ], + "key": "a", + "used_key_parts": [ + "a" + ], + "key_length": "5", + "ref": [ + ".a" + ], + "rows_examined_per_scan": 10, + "rows_produced_per_join": 10, + "filtered": "100.00", + "using_join_buffer": "Batched Key Access", + "cost_info": { + "read_cost": "25.00", + "eval_cost": "1.00", + "prefix_cost": "41.01", + "data_read_per_join": "4K" + }, + "used_columns": [ + "a", + "b", + "filler" + ] + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t3`.`filler` AS `filler` from `test`.`t1` join `test`.`t3` semi join (`test`.`t2`) where ((`test`.`t3`.`a` = ``.`a`) and (`test`.`t1`.`a` = 3) and ((``.`a` < 10) or (``.`a` > 30))) +explain select straight_join * from t1 a, t1 b where a.a in (select a from t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY a NULL ALL NULL NULL NULL NULL 10 100.00 Using where +1 PRIMARY b NULL ALL NULL NULL NULL NULL 10 100.00 Using join buffer (hash join) +2 SUBQUERY t2 NULL ALL NULL NULL NULL NULL 10 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select straight_join `test`.`a`.`a` AS `a`,`test`.`b`.`a` AS `a` from `test`.`t1` `a` join `test`.`t1` `b` where (`test`.`a`.`a`,`test`.`a`.`a` in ( (/* select#2 */ select `test`.`t2`.`a` from `test`.`t2` where true ), (`test`.`a`.`a` in on where ((`test`.`a`.`a` = ``.`a`))))) +explain select * from t2 where a in (select straight_join a.a from t1 a, t1 b); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 10 100.00 Using where +2 SUBQUERY a NULL ALL NULL NULL NULL NULL 10 100.00 NULL +2 SUBQUERY b NULL ALL NULL NULL NULL NULL 10 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` where (`test`.`t2`.`a`,`test`.`t2`.`a` in ( (/* select#2 */ select straight_join `test`.`a`.`a` from `test`.`t1` `a` join `test`.`t1` `b` where true ), (`test`.`t2`.`a` in on where ((`test`.`t2`.`a` = ``.`a`))))) +explain select * from t2 where a in (select straight_join a.a from t1 a, t1 b); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 10 100.00 Using where +2 SUBQUERY a NULL ALL NULL NULL NULL NULL 10 100.00 NULL +2 SUBQUERY b NULL ALL NULL NULL NULL NULL 10 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` where (`test`.`t2`.`a`,`test`.`t2`.`a` in ( (/* select#2 */ select straight_join `test`.`a`.`a` from `test`.`t1` `a` join `test`.`t1` `b` where true ), (`test`.`t2`.`a` in on where ((`test`.`t2`.`a` = ``.`a`))))) +explain select straight_join * from t2 x, t2 y +where x.a in (select straight_join a.a from t1 a, t1 b); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY x NULL ALL NULL NULL NULL NULL 10 100.00 Using where +1 PRIMARY y NULL ALL NULL NULL NULL NULL 10 100.00 Using join buffer (hash join) +2 SUBQUERY a NULL ALL NULL NULL NULL NULL 10 100.00 NULL +2 SUBQUERY b NULL ALL NULL NULL NULL NULL 10 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select straight_join `test`.`x`.`a` AS `a`,`test`.`y`.`a` AS `a` from `test`.`t2` `x` join `test`.`t2` `y` where (`test`.`x`.`a`,`test`.`x`.`a` in ( (/* select#2 */ select straight_join `test`.`a`.`a` from `test`.`t1` `a` join `test`.`t1` `b` where true ), (`test`.`x`.`a` in on where ((`test`.`x`.`a` = ``.`a`))))) +create table t0 (a int, b int); +insert into t0 values(1,1); +explain select * from t0, t3 where t3.a in (select a from t2) and (t3.a < 10 or t3.a >30); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using where +1 SIMPLE t3 NULL ref a a 5 .a 10 100.00 Using join buffer (Batched Key Access) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 10 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select '1' AS `a`,'1' AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t3`.`filler` AS `filler` from `test`.`t3` semi join (`test`.`t2`) where ((`test`.`t3`.`a` = ``.`a`) and ((``.`a` < 10) or (``.`a` > 30))) +create table t4 as select a as x, a as y from t1; +explain select * from t0, t3 where (t3.a, t3.b) in (select x,y from t4) and (t3.a < 10 or t3.a >30); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using where +1 SIMPLE t3 NULL ref a a 5 .x 10 10.00 Using where; Using join buffer (Batched Key Access) +2 MATERIALIZED t4 NULL ALL NULL NULL NULL NULL 10 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select '1' AS `a`,'1' AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t3`.`filler` AS `filler` from `test`.`t3` semi join (`test`.`t4`) where ((`test`.`t3`.`b` = ``.`y`) and (`test`.`t3`.`a` = ``.`x`) and ((``.`x` < 10) or (``.`x` > 30))) +drop table t0,t1,t2,t3,t4; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (a int, b int, filler char(100), key(a,b)); +insert into t1 select A.a, B.a, 'filler' from t0 A, t0 B; +create table t2 as select * from t1; +explain select * from t2 where a in (select b from t1 where a=3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 100 100.00 Using where +1 SIMPLE NULL eq_ref 5 test.t2.a 1 100.00 NULL +2 MATERIALIZED t1 NULL ref a a 5 const 8 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`filler` AS `filler` from `test`.`t2` semi join (`test`.`t1`) where ((``.`b` = `test`.`t2`.`a`) and (`test`.`t1`.`a` = 3)) +explain select * from t2 where (b,a) in (select a,b from t1 where a=3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 100 10.00 Using where +1 SIMPLE t1 NULL ref a a 10 const,test.t2.a 1 100.00 Using index; FirstMatch(t2) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`filler` AS `filler` from `test`.`t2` semi join (`test`.`t1`) where ((`test`.`t1`.`b` = `test`.`t2`.`a`) and (`test`.`t2`.`b` = 3) and (`test`.`t1`.`a` = 3)) +drop table t1,t2; +create table t1 (a int, b int); +insert into t1 select a,a from t0; +create table t2 (a int, b int); +insert into t2 select A.a + 10*B.a, A.a + 10*B.a from t0 A, t0 B; +explain select * from t1 where (a,b) in (select a,b from t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 100.00 Using where +1 SIMPLE NULL eq_ref 10 test.t1.a,test.t1.b 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 100 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t2`) where ((``.`b` = `test`.`t1`.`b`) and (``.`a` = `test`.`t1`.`a`)) +drop table t0, t1, t2; +# +# Bug#19695490: CRASH IN CREATE_REF_FOR_KEY ON SELECT + JOIN + UTF8 COLUMN +# + DATETIME INDEX. +# +CREATE TABLE t1 ( +field1 varchar(255) CHARACTER SET utf8, +field2 varchar(255) CHARACTER SET utf8 +); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES +('time','time'), +('lpjdzvkp','lpjdzvkp'), +('dzvkpai', 'dzvkpai'); +CREATE TABLE t2 ( col_varchar varchar(10)); +CREATE TABLE t3 ( +pk int(11) NOT NULL, +col_varchar_255_utf8_key varchar(255) CHARACTER SET utf8, +col_varchar_10_utf8_key varchar(10) CHARACTER SET utf8, +PRIMARY KEY (pk) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t3 VALUES (22,'come','h'), +(23,'time','aaa'), +(24,'lpjdzvkp','ababa'), +(25,'d','GGDD'); +SELECT * FROM t1 WHERE (field1, field2) IN ( +SELECT table1.col_varchar_255_utf8_key AS field1, +table1.col_varchar_255_utf8_key AS field2 +FROM t3 AS table1 LEFT JOIN t2 AS table2 +ON table1.col_varchar_10_utf8_key <= +table2.col_varchar +WHERE table1.pk >= 6); +field1 field2 +time time +lpjdzvkp lpjdzvkp +DROP TABLE t1,t2,t3; +create table t0 (a decimal(4,2)); +insert into t0 values (10.24), (22.11); +create table t1 as select * from t0; +insert into t1 select * from t0; +explain select * from t0 where a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; FirstMatch(t0); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a` from `test`.`t0` semi join (`test`.`t1`) where (`test`.`t1`.`a` = `test`.`t0`.`a`) +select * from t0 where a in (select a from t1); +a +10.24 +22.11 +drop table t0, t1; +create table t0(a date); +insert into t0 values ('2008-01-01'),('2008-02-02'); +create table t1 as select * from t0; +insert into t1 select * from t0; +explain select * from t0 where a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; FirstMatch(t0); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a` from `test`.`t0` semi join (`test`.`t1`) where (`test`.`t1`.`a` = `test`.`t0`.`a`) +select * from t0 where a in (select a from t1); +a +2008-01-01 +2008-02-02 +drop table t0, t1; +create table t0(a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 as select a as a, a as b, a as c from t0 where a < 3; +create table t2 as select a as a, a as b from t0 where a < 3; +insert into t2 select * from t2; +explain select * from t1 where (a,b,c) in (select x.a, y.a, z.a from t2 x, t2 y, t2 z where x.b=33); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE x NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +1 SIMPLE y NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Using join buffer (hash join) +1 SIMPLE z NULL ALL NULL NULL NULL NULL 6 16.67 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` semi join (`test`.`t2` `x` join `test`.`t2` `y` join `test`.`t2` `z`) where ((`test`.`z`.`a` = `test`.`t1`.`c`) and (`test`.`y`.`a` = `test`.`t1`.`b`) and (`test`.`t1`.`a` = `test`.`x`.`a`) and (`test`.`x`.`b` = 33)) +drop table t0,t1,t2; +set @save_join_buffer_size = @@join_buffer_size; +set join_buffer_size= 8192; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (a int, filler1 binary(200), filler2 binary(200)); +insert into t1 select a, 'filler123456', 'filler123456' from t0; +insert into t1 select a+10, 'filler123456', 'filler123456' from t0; +create table t2 as select * from t1; +insert into t1 select a+20, 'filler123456', 'filler123456' from t0; +insert into t1 values (2, 'duplicate ok', 'duplicate ok'); +insert into t1 values (18, 'duplicate ok', 'duplicate ok'); +insert into t2 values (3, 'duplicate ok', 'duplicate ok'); +insert into t2 values (19, 'duplicate ok', 'duplicate ok'); +explain select +a, mid(filler1, 1,10), length(filler1)=length(filler2) as z +from t1 ot where a in (select a from t2 it); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 32 10.00 Using where; Using join buffer (hash join) +2 MATERIALIZED it NULL ALL NULL NULL NULL NULL 22 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot`.`a` AS `a`,substr(`test`.`ot`.`filler1`,1,10) AS `mid(filler1, 1,10)`,(length(`test`.`ot`.`filler1`) = length(`test`.`ot`.`filler2`)) AS `z` from `test`.`t1` `ot` semi join (`test`.`t2` `it`) where (`test`.`ot`.`a` = ``.`a`) +select +a, mid(filler1, 1,10), length(filler1)=length(filler2) as z +from t1 ot where a in (select a from t2 it); +a mid(filler1, 1,10) z +0 filler1234 1 +1 filler1234 1 +10 filler1234 1 +11 filler1234 1 +12 filler1234 1 +13 filler1234 1 +14 filler1234 1 +15 filler1234 1 +16 filler1234 1 +17 filler1234 1 +18 duplicate 1 +18 filler1234 1 +19 filler1234 1 +2 duplicate 1 +2 filler1234 1 +3 filler1234 1 +4 filler1234 1 +5 filler1234 1 +6 filler1234 1 +7 filler1234 1 +8 filler1234 1 +9 filler1234 1 +explain select +a, mid(filler1, 1,10), length(filler1)=length(filler2) +from t2 ot where a in (select a from t1 it); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 22 100.00 Using where +1 SIMPLE NULL eq_ref 5 test.ot.a 1 100.00 NULL +2 MATERIALIZED it NULL ALL NULL NULL NULL NULL 32 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot`.`a` AS `a`,substr(`test`.`ot`.`filler1`,1,10) AS `mid(filler1, 1,10)`,(length(`test`.`ot`.`filler1`) = length(`test`.`ot`.`filler2`)) AS `length(filler1)=length(filler2)` from `test`.`t2` `ot` semi join (`test`.`t1` `it`) where (``.`a` = `test`.`ot`.`a`) +select +a, mid(filler1, 1,10), length(filler1)=length(filler2) +from t2 ot where a in (select a from t1 it); +a mid(filler1, 1,10) length(filler1)=length(filler2) +0 filler1234 1 +1 filler1234 1 +10 filler1234 1 +11 filler1234 1 +12 filler1234 1 +13 filler1234 1 +14 filler1234 1 +15 filler1234 1 +16 filler1234 1 +17 filler1234 1 +18 filler1234 1 +19 duplicate 1 +19 filler1234 1 +2 filler1234 1 +3 duplicate 1 +3 filler1234 1 +4 filler1234 1 +5 filler1234 1 +6 filler1234 1 +7 filler1234 1 +8 filler1234 1 +9 filler1234 1 +insert into t1 select a+20, 'filler123456', 'filler123456' from t0; +insert into t1 select a+20, 'filler123456', 'filler123456' from t0; +explain select +a, mid(filler1, 1,10), length(filler1)=length(filler2) as z +from t1 ot where a in (select a from t2 it); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 52 10.00 Using where; Using join buffer (hash join) +2 MATERIALIZED it NULL ALL NULL NULL NULL NULL 22 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot`.`a` AS `a`,substr(`test`.`ot`.`filler1`,1,10) AS `mid(filler1, 1,10)`,(length(`test`.`ot`.`filler1`) = length(`test`.`ot`.`filler2`)) AS `z` from `test`.`t1` `ot` semi join (`test`.`t2` `it`) where (`test`.`ot`.`a` = ``.`a`) +select +a, mid(filler1, 1,10), length(filler1)=length(filler2) as z +from t1 ot where a in (select a from t2 it); +a mid(filler1, 1,10) z +0 filler1234 1 +1 filler1234 1 +10 filler1234 1 +11 filler1234 1 +12 filler1234 1 +13 filler1234 1 +14 filler1234 1 +15 filler1234 1 +16 filler1234 1 +17 filler1234 1 +18 duplicate 1 +18 filler1234 1 +19 filler1234 1 +2 duplicate 1 +2 filler1234 1 +3 filler1234 1 +4 filler1234 1 +5 filler1234 1 +6 filler1234 1 +7 filler1234 1 +8 filler1234 1 +9 filler1234 1 +explain select +a, mid(filler1, 1,10), length(filler1)=length(filler2) +from t2 ot where a in (select a from t1 it); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 22 100.00 Using where +1 SIMPLE NULL eq_ref 5 test.ot.a 1 100.00 NULL +2 MATERIALIZED it NULL ALL NULL NULL NULL NULL 52 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot`.`a` AS `a`,substr(`test`.`ot`.`filler1`,1,10) AS `mid(filler1, 1,10)`,(length(`test`.`ot`.`filler1`) = length(`test`.`ot`.`filler2`)) AS `length(filler1)=length(filler2)` from `test`.`t2` `ot` semi join (`test`.`t1` `it`) where (``.`a` = `test`.`ot`.`a`) +select +a, mid(filler1, 1,10), length(filler1)=length(filler2) +from t2 ot where a in (select a from t1 it); +a mid(filler1, 1,10) length(filler1)=length(filler2) +0 filler1234 1 +1 filler1234 1 +10 filler1234 1 +11 filler1234 1 +12 filler1234 1 +13 filler1234 1 +14 filler1234 1 +15 filler1234 1 +16 filler1234 1 +17 filler1234 1 +18 filler1234 1 +19 duplicate 1 +19 filler1234 1 +2 filler1234 1 +3 duplicate 1 +3 filler1234 1 +4 filler1234 1 +5 filler1234 1 +6 filler1234 1 +7 filler1234 1 +8 filler1234 1 +9 filler1234 1 +set @@join_buffer_size = @save_join_buffer_size; +drop table t1, t2; +create table t1 (a int, b int, key(a)); +create table t2 (a int, b int, key(a)); +create table t3 (a int, b int, key(a)); +insert into t1 select a,a from t0; +insert into t2 select a,a from t0; +insert into t3 select a,a from t0; +t2 and t3 must be use 'ref', not 'ALL': +explain select * +from t0 where a in +(select t2.a+t3.a from t1 left join (t2 join t3) on t2.a=t1.a and t3.a=t1.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 10 100.00 Using where +1 SIMPLE NULL eq_ref 9 test.t0.a 1 100.00 Using where +2 MATERIALIZED t1 NULL index a a 5 NULL 10 100.00 Using index +2 MATERIALIZED t2 NULL ref a a 5 test.t1.a 1 100.00 Using index +2 MATERIALIZED t3 NULL ref a a 5 test.t1.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a` from `test`.`t0` semi join (`test`.`t1` join `test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`a` = `test`.`t1`.`a`) and (`test`.`t3`.`a` = `test`.`t1`.`a`) and (`test`.`t0`.`a` = ``.`t2.a+t3.a`)) +drop table t0, t1,t2,t3; + +Test that neither MaterializeLookup strategy for semijoin, +nor subquery materialization is used when BLOBs are involved +(except when arguments of some functions). + +set @prefix_len = 6; +set @blob_len = 16; +set @suffix_len = @blob_len - @prefix_len; +create table t1_16 (a1 blob(16), a2 blob(16)); +create table t2_16 (b1 blob(16), b2 blob(16)); +create table t3_16 (c1 blob(16), c2 blob(16)); +insert into t1_16 values +(concat('1 - 00', repeat('x', @suffix_len)), concat('2 - 00', repeat('x', @suffix_len))); +insert into t1_16 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t1_16 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_16 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t2_16 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_16 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_16 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t3_16 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t3_16 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_16 values +(concat('1 - 04', repeat('x', @suffix_len)), concat('2 - 04', repeat('x', @suffix_len))); +explain select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select b1 from t2_16 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1_16 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t2_16 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(t1_16); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_16`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_16`.`a2`,7) AS `left(a2,7)` from `test`.`t1_16` semi join (`test`.`t2_16`) where ((`test`.`t2_16`.`b1` = `test`.`t1_16`.`a1`) and (`test`.`t1_16`.`a1` > '0')) +select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select b1 from t2_16 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_16 +where (a1,a2) in (select b1, b2 from t2_16 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1_16 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t2_16 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(t1_16); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_16`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_16`.`a2`,7) AS `left(a2,7)` from `test`.`t1_16` semi join (`test`.`t2_16`) where ((`test`.`t2_16`.`b2` = `test`.`t1_16`.`a2`) and (`test`.`t2_16`.`b1` = `test`.`t1_16`.`a1`) and (`test`.`t1_16`.`a1` > '0')) +select left(a1,7), left(a2,7) +from t1_16 +where (a1,a2) in (select b1, b2 from t2_16 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select substring(b1,1,16) from t2_16 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1_16 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE t2_16 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(t1_16); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_16`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_16`.`a2`,7) AS `left(a2,7)` from `test`.`t1_16` semi join (`test`.`t2_16`) where ((`test`.`t2_16`.`b1` > '0') and (`test`.`t1_16`.`a1` = substr(`test`.`t2_16`.`b1`,1,16))) +select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select substring(b1,1,16) from t2_16 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select group_concat(b1) from t2_16 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_16 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t2_16 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_16`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_16`.`a2`,7) AS `left(a2,7)` from `test`.`t1_16` where (`test`.`t1_16`.`a1`,(/* select#2 */ select group_concat(`test`.`t2_16`.`b1` separator ',') from `test`.`t2_16` group by `test`.`t2_16`.`b2` having ((`test`.`t1_16`.`a1`) = (group_concat(`test`.`t2_16`.`b1` separator ','))))) +select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select group_concat(b1) from t2_16 group by b2); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +set @@group_concat_max_len = 256; +explain select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select group_concat(b1) from t2_16 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_16 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 SUBQUERY t2_16 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_16`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_16`.`a2`,7) AS `left(a2,7)` from `test`.`t1_16` where (`test`.`t1_16`.`a1`,`test`.`t1_16`.`a1` in ( (/* select#2 */ select group_concat(`test`.`t2_16`.`b1` separator ',') from `test`.`t2_16` group by `test`.`t2_16`.`b2` having true ), (`test`.`t1_16`.`a1` in on where ((`test`.`t1_16`.`a1` = ``.`group_concat(b1)`))))) +select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select group_concat(b1) from t2_16 group by b2); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +create table t1 (a1 char(8), a2 char(8)) charset latin1; +create table t2 (b1 char(8), b2 char(8)) charset latin1; +create table t3 (c1 char(8), c2 char(8)) charset latin1; +insert into t1 values ('1 - 00', '2 - 00'); +insert into t1 values ('1 - 01', '2 - 01'); +insert into t1 values ('1 - 02', '2 - 02'); +insert into t2 values ('1 - 01', '2 - 01'); +insert into t2 values ('1 - 01', '2 - 01'); +insert into t2 values ('1 - 02', '2 - 02'); +insert into t2 values ('1 - 02', '2 - 02'); +insert into t2 values ('1 - 03', '2 - 03'); +insert into t3 values ('1 - 01', '2 - 01'); +insert into t3 values ('1 - 02', '2 - 02'); +insert into t3 values ('1 - 03', '2 - 03'); +insert into t3 values ('1 - 04', '2 - 04'); +insert into t3 values ('1 - 05', '2 - 05'); +insert into t3 values ('1 - 06', '2 - 06'); +insert into t3 values ('1 - 07', '2 - 07'); +insert into t3 values ('1 - 08', '2 - 08'); +explain +select * from t1 +where concat(a1,'x') IN +(select left(a1,8) from t1_16 +where (a1, a2) IN +(select t2_16.b1, t2_16.b2 from t2_16, t2 +where t2.b2 = substring(t2_16.b2,1,6) and +t2.b1 IN (select c1 from t3 where c2 > '0'))); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Start temporary +1 SIMPLE t1_16 NULL ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t2_16 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 5 20.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` semi join (`test`.`t1_16` join `test`.`t2_16` join `test`.`t2` join `test`.`t3`) where ((`test`.`t2_16`.`b2` = `test`.`t1_16`.`a2`) and (`test`.`t2_16`.`b1` = `test`.`t1_16`.`a1`) and (`test`.`t3`.`c1` = `test`.`t2`.`b1`) and (`test`.`t2`.`b2` = substr(`test`.`t2_16`.`b2`,1,6)) and (`test`.`t3`.`c2` > '0') and (concat(`test`.`t1`.`a1`,'x') = left(`test`.`t1_16`.`a1`,8))) +drop table t1_16, t2_16, t3_16, t1, t2, t3; +set @blob_len = 512; +set @suffix_len = @blob_len - @prefix_len; +create table t1_512 (a1 blob(512), a2 blob(512)); +create table t2_512 (b1 blob(512), b2 blob(512)); +create table t3_512 (c1 blob(512), c2 blob(512)); +insert into t1_512 values +(concat('1 - 00', repeat('x', @suffix_len)), concat('2 - 00', repeat('x', @suffix_len))); +insert into t1_512 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t1_512 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_512 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t2_512 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_512 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_512 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t3_512 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t3_512 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_512 values +(concat('1 - 04', repeat('x', @suffix_len)), concat('2 - 04', repeat('x', @suffix_len))); +explain select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select b1 from t2_512 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1_512 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t2_512 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(t1_512); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_512`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_512`.`a2`,7) AS `left(a2,7)` from `test`.`t1_512` semi join (`test`.`t2_512`) where ((`test`.`t2_512`.`b1` = `test`.`t1_512`.`a1`) and (`test`.`t1_512`.`a1` > '0')) +select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select b1 from t2_512 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_512 +where (a1,a2) in (select b1, b2 from t2_512 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1_512 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t2_512 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(t1_512); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_512`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_512`.`a2`,7) AS `left(a2,7)` from `test`.`t1_512` semi join (`test`.`t2_512`) where ((`test`.`t2_512`.`b2` = `test`.`t1_512`.`a2`) and (`test`.`t2_512`.`b1` = `test`.`t1_512`.`a1`) and (`test`.`t1_512`.`a1` > '0')) +select left(a1,7), left(a2,7) +from t1_512 +where (a1,a2) in (select b1, b2 from t2_512 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select substring(b1,1,512) from t2_512 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1_512 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE t2_512 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(t1_512); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_512`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_512`.`a2`,7) AS `left(a2,7)` from `test`.`t1_512` semi join (`test`.`t2_512`) where ((`test`.`t2_512`.`b1` > '0') and (`test`.`t1_512`.`a1` = substr(`test`.`t2_512`.`b1`,1,512))) +select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select substring(b1,1,512) from t2_512 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select group_concat(b1) from t2_512 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_512 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 SUBQUERY t2_512 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_512`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_512`.`a2`,7) AS `left(a2,7)` from `test`.`t1_512` where (`test`.`t1_512`.`a1`,`test`.`t1_512`.`a1` in ( (/* select#2 */ select group_concat(`test`.`t2_512`.`b1` separator ',') from `test`.`t2_512` group by `test`.`t2_512`.`b2` having true ), (`test`.`t1_512`.`a1` in on where ((`test`.`t1_512`.`a1` = ``.`group_concat(b1)`))))) +select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select group_concat(b1) from t2_512 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +set @@group_concat_max_len = 256; +explain select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select group_concat(b1) from t2_512 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_512 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 SUBQUERY t2_512 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_512`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_512`.`a2`,7) AS `left(a2,7)` from `test`.`t1_512` where (`test`.`t1_512`.`a1`,`test`.`t1_512`.`a1` in ( (/* select#2 */ select group_concat(`test`.`t2_512`.`b1` separator ',') from `test`.`t2_512` group by `test`.`t2_512`.`b2` having true ), (`test`.`t1_512`.`a1` in on where ((`test`.`t1_512`.`a1` = ``.`group_concat(b1)`))))) +select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select group_concat(b1) from t2_512 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +drop table t1_512, t2_512, t3_512; +set @blob_len = 513; +set @suffix_len = @blob_len - @prefix_len; +create table t1_513 (a1 blob(513), a2 blob(513)); +create table t2_513 (b1 blob(513), b2 blob(513)); +create table t3_513 (c1 blob(513), c2 blob(513)); +insert into t1_513 values +(concat('1 - 00', repeat('x', @suffix_len)), concat('2 - 00', repeat('x', @suffix_len))); +insert into t1_513 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t1_513 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_513 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t2_513 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_513 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_513 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t3_513 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t3_513 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_513 values +(concat('1 - 04', repeat('x', @suffix_len)), concat('2 - 04', repeat('x', @suffix_len))); +explain select left(a1,7), left(a2,7) +from t1_513 +where a1 in (select b1 from t2_513 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1_513 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t2_513 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(t1_513); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_513`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_513`.`a2`,7) AS `left(a2,7)` from `test`.`t1_513` semi join (`test`.`t2_513`) where ((`test`.`t2_513`.`b1` = `test`.`t1_513`.`a1`) and (`test`.`t1_513`.`a1` > '0')) +select left(a1,7), left(a2,7) +from t1_513 +where a1 in (select b1 from t2_513 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_513 +where (a1,a2) in (select b1, b2 from t2_513 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1_513 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t2_513 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(t1_513); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_513`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_513`.`a2`,7) AS `left(a2,7)` from `test`.`t1_513` semi join (`test`.`t2_513`) where ((`test`.`t2_513`.`b2` = `test`.`t1_513`.`a2`) and (`test`.`t2_513`.`b1` = `test`.`t1_513`.`a1`) and (`test`.`t1_513`.`a1` > '0')) +select left(a1,7), left(a2,7) +from t1_513 +where (a1,a2) in (select b1, b2 from t2_513 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_513 +where a1 in (select substring(b1,1,513) from t2_513 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1_513 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE t2_513 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(t1_513); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_513`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_513`.`a2`,7) AS `left(a2,7)` from `test`.`t1_513` semi join (`test`.`t2_513`) where ((`test`.`t2_513`.`b1` > '0') and (`test`.`t1_513`.`a1` = substr(`test`.`t2_513`.`b1`,1,513))) +select left(a1,7), left(a2,7) +from t1_513 +where a1 in (select substring(b1,1,513) from t2_513 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_513 +where a1 in (select group_concat(b1) from t2_513 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_513 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 SUBQUERY t2_513 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_513`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_513`.`a2`,7) AS `left(a2,7)` from `test`.`t1_513` where (`test`.`t1_513`.`a1`,`test`.`t1_513`.`a1` in ( (/* select#2 */ select group_concat(`test`.`t2_513`.`b1` separator ',') from `test`.`t2_513` group by `test`.`t2_513`.`b2` having true ), (`test`.`t1_513`.`a1` in on where ((`test`.`t1_513`.`a1` = ``.`group_concat(b1)`))))) +select left(a1,7), left(a2,7) +from t1_513 +where a1 in (select group_concat(b1) from t2_513 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +drop table t1_513, t2_513, t3_513; +set @blob_len = 1024; +set @suffix_len = @blob_len - @prefix_len; +create table t1_1024 (a1 blob(1024), a2 blob(1024)); +create table t2_1024 (b1 blob(1024), b2 blob(1024)); +create table t3_1024 (c1 blob(1024), c2 blob(1024)); +insert into t1_1024 values +(concat('1 - 00', repeat('x', @suffix_len)), concat('2 - 00', repeat('x', @suffix_len))); +insert into t1_1024 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t1_1024 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_1024 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t2_1024 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_1024 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_1024 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t3_1024 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t3_1024 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_1024 values +(concat('1 - 04', repeat('x', @suffix_len)), concat('2 - 04', repeat('x', @suffix_len))); +explain select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select b1 from t2_1024 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1_1024 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t2_1024 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(t1_1024); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1024`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1024`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1024` semi join (`test`.`t2_1024`) where ((`test`.`t2_1024`.`b1` = `test`.`t1_1024`.`a1`) and (`test`.`t1_1024`.`a1` > '0')) +select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select b1 from t2_1024 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_1024 +where (a1,a2) in (select b1, b2 from t2_1024 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1_1024 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t2_1024 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(t1_1024); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1024`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1024`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1024` semi join (`test`.`t2_1024`) where ((`test`.`t2_1024`.`b2` = `test`.`t1_1024`.`a2`) and (`test`.`t2_1024`.`b1` = `test`.`t1_1024`.`a1`) and (`test`.`t1_1024`.`a1` > '0')) +select left(a1,7), left(a2,7) +from t1_1024 +where (a1,a2) in (select b1, b2 from t2_1024 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select substring(b1,1,1024) from t2_1024 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1_1024 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE t2_1024 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(t1_1024); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1024`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1024`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1024` semi join (`test`.`t2_1024`) where ((`test`.`t2_1024`.`b1` > '0') and (`test`.`t1_1024`.`a1` = substr(`test`.`t2_1024`.`b1`,1,1024))) +select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select substring(b1,1,1024) from t2_1024 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select group_concat(b1) from t2_1024 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_1024 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 SUBQUERY t2_1024 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1024`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1024`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1024` where (`test`.`t1_1024`.`a1`,`test`.`t1_1024`.`a1` in ( (/* select#2 */ select group_concat(`test`.`t2_1024`.`b1` separator ',') from `test`.`t2_1024` group by `test`.`t2_1024`.`b2` having true ), (`test`.`t1_1024`.`a1` in on where ((`test`.`t1_1024`.`a1` = ``.`group_concat(b1)`))))) +select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select group_concat(b1) from t2_1024 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +set @@group_concat_max_len = 256; +explain select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select group_concat(b1) from t2_1024 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_1024 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 SUBQUERY t2_1024 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1024`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1024`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1024` where (`test`.`t1_1024`.`a1`,`test`.`t1_1024`.`a1` in ( (/* select#2 */ select group_concat(`test`.`t2_1024`.`b1` separator ',') from `test`.`t2_1024` group by `test`.`t2_1024`.`b2` having true ), (`test`.`t1_1024`.`a1` in on where ((`test`.`t1_1024`.`a1` = ``.`group_concat(b1)`))))) +select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select group_concat(b1) from t2_1024 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +drop table t1_1024, t2_1024, t3_1024; +set @blob_len = 1025; +set @suffix_len = @blob_len - @prefix_len; +create table t1_1025 (a1 blob(1025), a2 blob(1025)); +create table t2_1025 (b1 blob(1025), b2 blob(1025)); +create table t3_1025 (c1 blob(1025), c2 blob(1025)); +insert into t1_1025 values +(concat('1 - 00', repeat('x', @suffix_len)), concat('2 - 00', repeat('x', @suffix_len))); +insert into t1_1025 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t1_1025 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_1025 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t2_1025 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_1025 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_1025 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t3_1025 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t3_1025 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_1025 values +(concat('1 - 04', repeat('x', @suffix_len)), concat('2 - 04', repeat('x', @suffix_len))); +explain select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select b1 from t2_1025 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1_1025 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t2_1025 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(t1_1025); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1025`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1025`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1025` semi join (`test`.`t2_1025`) where ((`test`.`t2_1025`.`b1` = `test`.`t1_1025`.`a1`) and (`test`.`t1_1025`.`a1` > '0')) +select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select b1 from t2_1025 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_1025 +where (a1,a2) in (select b1, b2 from t2_1025 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1_1025 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t2_1025 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(t1_1025); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1025`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1025`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1025` semi join (`test`.`t2_1025`) where ((`test`.`t2_1025`.`b2` = `test`.`t1_1025`.`a2`) and (`test`.`t2_1025`.`b1` = `test`.`t1_1025`.`a1`) and (`test`.`t1_1025`.`a1` > '0')) +select left(a1,7), left(a2,7) +from t1_1025 +where (a1,a2) in (select b1, b2 from t2_1025 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select substring(b1,1,1025) from t2_1025 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1_1025 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE t2_1025 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(t1_1025); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1025`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1025`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1025` semi join (`test`.`t2_1025`) where ((`test`.`t2_1025`.`b1` > '0') and (`test`.`t1_1025`.`a1` = substr(`test`.`t2_1025`.`b1`,1,1025))) +select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select substring(b1,1,1025) from t2_1025 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select group_concat(b1) from t2_1025 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_1025 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 SUBQUERY t2_1025 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1025`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1025`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1025` where (`test`.`t1_1025`.`a1`,`test`.`t1_1025`.`a1` in ( (/* select#2 */ select group_concat(`test`.`t2_1025`.`b1` separator ',') from `test`.`t2_1025` group by `test`.`t2_1025`.`b2` having true ), (`test`.`t1_1025`.`a1` in on where ((`test`.`t1_1025`.`a1` = ``.`group_concat(b1)`))))) +select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select group_concat(b1) from t2_1025 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +set @@group_concat_max_len = 256; +explain select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select group_concat(b1) from t2_1025 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_1025 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 SUBQUERY t2_1025 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1025`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1025`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1025` where (`test`.`t1_1025`.`a1`,`test`.`t1_1025`.`a1` in ( (/* select#2 */ select group_concat(`test`.`t2_1025`.`b1` separator ',') from `test`.`t2_1025` group by `test`.`t2_1025`.`b2` having true ), (`test`.`t1_1025`.`a1` in on where ((`test`.`t1_1025`.`a1` = ``.`group_concat(b1)`))))) +select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select group_concat(b1) from t2_1025 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +drop table t1_1025, t2_1025, t3_1025; +# +# WL#5561: Enable semi join transformation with outer join. +# +CREATE TABLE ot1(a INT); +CREATE TABLE ot2(a INT); +CREATE TABLE ot3(a INT); +CREATE TABLE it1(a INT); +CREATE TABLE it2(a INT); +CREATE TABLE it3(a INT); +INSERT INTO ot1 VALUES(0),(1),(2),(3),(4),(5),(6),(7); +INSERT INTO ot2 VALUES(0),(2),(4),(6); +INSERT INTO ot3 VALUES(0),(3),(6); +INSERT INTO it1 VALUES(0),(1),(2),(3),(4),(5),(6),(7); +INSERT INTO it2 VALUES(0),(2),(4),(6); +INSERT INTO it3 VALUES(0),(3),(6); +# Test cases, Subquery Pattern 1 +# Example SQ1.1: +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE ot1.a IN (SELECT a FROM it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE it3 NULL ALL NULL NULL NULL NULL 3 100.00 Start temporary +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; End temporary; Using join buffer (hash join) +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` left join `test`.`ot2` on((`test`.`ot2`.`a` = `test`.`it3`.`a`)) semi join (`test`.`it3`) where (`test`.`ot1`.`a` = `test`.`it3`.`a`) +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE ot1.a IN (SELECT a FROM it3); +a a +0 0 +3 NULL +6 6 +# Example SQ1.2: +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE COALESCE(ot2.a,0) IN (SELECT a FROM it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 Using join buffer (hash join) +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (hash join) +2 MATERIALIZED it3 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` left join `test`.`ot2` on((`test`.`ot2`.`a` = `test`.`ot1`.`a`)) semi join (`test`.`it3`) where (coalesce(`test`.`ot2`.`a`,0) = ``.`a`) +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE COALESCE(ot2.a,0) IN (SELECT a FROM it3); +a a +0 0 +1 NULL +3 NULL +5 NULL +6 6 +7 NULL +# Example SQ1.3: +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE (ot1.a,ot2.a) IN (SELECT a, a FROM it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE it3 NULL ALL NULL NULL NULL NULL 3 100.00 Start temporary +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; Using join buffer (hash join) +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` join `test`.`ot2` semi join (`test`.`it3`) where ((`test`.`ot2`.`a` = `test`.`it3`.`a`) and (`test`.`ot1`.`a` = `test`.`it3`.`a`)) +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE (ot1.a,ot2.a) IN (SELECT a, a FROM it3); +a a +0 0 +6 6 +# More test cases +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 +WHERE ot1.a IN (SELECT a FROM it3); +a a +0 0 +3 NULL +6 6 +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 +WHERE ot1.a IN (SELECT a+0 FROM it3); +a a +0 0 +3 NULL +6 6 +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 +WHERE COALESCE(ot2.a,0) IN (SELECT a FROM it3); +a a +0 0 +1 NULL +3 NULL +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE COALESCE(ot2.a,0) IN (SELECT a+0 FROM it3); +a a +0 0 +1 NULL +3 NULL +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 +WHERE (ot1.a,ot2.a) IN (SELECT a, a FROM it3); +a a +0 0 +6 6 +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +LEFT JOIN ot3 ON ot1.a=ot3.a +WHERE ot1.a IN (SELECT a FROM it3); +a a a +0 0 0 +3 NULL 3 +6 6 6 +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +LEFT JOIN ot3 ON ot1.a=ot3.a +WHERE COALESCE(ot2.a,0) IN (SELECT a FROM it3); +a a a +0 0 0 +1 NULL NULL +3 NULL 3 +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +LEFT JOIN ot3 ON ot1.a=ot3.a +WHERE COALESCE(ot3.a,0) IN (SELECT a FROM it3); +a a a +0 0 0 +1 NULL NULL +2 2 NULL +3 NULL 3 +4 4 NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +LEFT JOIN ot3 ON ot2.a=ot3.a +WHERE ot1.a IN (SELECT a FROM it3); +a a a +0 0 0 +3 NULL NULL +6 6 6 +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +LEFT JOIN ot3 ON ot2.a=ot3.a +WHERE COALESCE(ot2.a,0) IN (SELECT a FROM it3); +a a a +0 0 0 +1 NULL NULL +3 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +LEFT JOIN ot3 ON ot2.a=ot3.a +WHERE COALESCE(ot3.a,0) IN (SELECT a FROM it3); +a a a +0 0 0 +1 NULL NULL +2 2 NULL +3 NULL NULL +4 4 NULL +5 NULL NULL +6 6 6 +7 NULL NULL +# Test cases, Subquery Pattern 2 +# Example SQ2.1: +explain SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE it3 NULL ALL NULL NULL NULL NULL 3 100.00 Start temporary +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; End temporary; Using join buffer (hash join) +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` join `test`.`ot2` semi join (`test`.`it3`) where ((`test`.`ot1`.`a` = `test`.`it3`.`a`) and (`test`.`ot2`.`a` = `test`.`it3`.`a`)) +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3); +a a +0 0 +6 6 +# Example SQ2.2: +explain SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it2) +AND ot2.a IN (SELECT a FROM it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE it3 NULL ALL NULL NULL NULL NULL 3 100.00 Start temporary +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; Using join buffer (hash join) +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; End temporary; Using join buffer (hash join) +1 SIMPLE it2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; FirstMatch(ot2); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` join `test`.`ot2` semi join (`test`.`it2`) semi join (`test`.`it3`) where ((`test`.`ot1`.`a` = `test`.`it3`.`a`) and (`test`.`ot2`.`a` = `test`.`it3`.`a`) and (`test`.`it2`.`a` = `test`.`it3`.`a`)) +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it2) +AND ot2.a IN (SELECT a FROM it3); +a a +0 0 +6 6 +# More test cases +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it3); +a a +0 0 +6 6 +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it3); +a a +0 0 +6 6 +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a+0 AND ot2.a IN (SELECT a FROM it3); +a a +0 0 +6 6 +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot2.a IN (SELECT a+0 FROM it3); +a a +0 0 +6 6 +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it2) +AND ot2.a IN (SELECT a+0 FROM it3); +a a +0 0 +6 6 +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3) +JOIN ot3 ON ot2.a=ot3.a AND ot3.a IN (SELECT a FROM it3); +a a a +0 0 0 +6 6 6 +# Test cases, Subquery Pattern 3 +# Example SQ3.1: +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +1 SIMPLE NULL eq_ref 5 test.ot1.a 1 100.00 NULL +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +2 MATERIALIZED it3 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` semi join (`test`.`it3`)) on(((``.`a` = `test`.`ot1`.`a`) and (`test`.`ot2`.`a` = `test`.`ot1`.`a`))) where true +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3); +a a +0 0 +1 NULL +2 NULL +3 NULL +4 NULL +5 NULL +6 6 +7 NULL +# Example SQ3.2: +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot2.a IN (SELECT a FROM it2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +1 SIMPLE NULL eq_ref 5 test.ot2.a 1 100.00 Using where +2 MATERIALIZED it2 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` semi join (`test`.`it2`)) on(((`test`.`ot2`.`a` = `test`.`ot1`.`a`) and (``.`a` = `test`.`ot1`.`a`))) where true +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot2.a IN (SELECT a FROM it2); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +# Example SQ3.3 +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1) +AND ot2.a IN (SELECT a FROM it2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +1 SIMPLE NULL eq_ref 5 test.ot1.a 1 100.00 NULL +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +1 SIMPLE NULL eq_ref 5 test.ot2.a 1 100.00 Using where +2 MATERIALIZED it1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +3 MATERIALIZED it2 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` semi join (`test`.`it1`) semi join (`test`.`it2`)) on(((``.`a` = `test`.`ot1`.`a`) and (`test`.`ot2`.`a` = `test`.`ot1`.`a`) and (``.`a` = `test`.`ot1`.`a`))) where true +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1) +AND ot2.a IN (SELECT a FROM it2); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +# Example SQ3.4 +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND +(ot1.a, ot2.a) IN (SELECT it1.a, it2.a +FROM it1 JOIN it2 ON it1.a=it2.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +1 SIMPLE NULL eq_ref 10 test.ot1.a,test.ot2.a 1 100.00 Using where +2 MATERIALIZED it2 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +2 MATERIALIZED it1 NULL ALL NULL NULL NULL NULL 8 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` semi join (`test`.`it1` join `test`.`it2`)) on(((`test`.`ot2`.`a` = `test`.`ot1`.`a`) and (``.`a` = `test`.`ot1`.`a`) and (``.`a` = `test`.`ot1`.`a`) and (`test`.`it1`.`a` = `test`.`it2`.`a`))) where true +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND +(ot1.a, ot2.a) IN (SELECT it1.a, it2.a +FROM it1 JOIN it2 ON it1.a=it2.a); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +# More test cases +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it3); +a a +0 0 +1 NULL +2 NULL +3 NULL +4 NULL +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it3); +a a +0 0 +1 NULL +2 NULL +3 NULL +4 NULL +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 AND ot2.a IN (SELECT a FROM it2); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot2.a IN (SELECT a+0 FROM it2); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a+0 FROM it1) +AND ot2.a IN (SELECT a+0 FROM it2); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 AND +(ot1.a, ot2.a) IN (SELECT it1.a+0, it2.a+0 +FROM it1 JOIN it2 ON it1.a=it2.a); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +EXPLAIN FORMAT=tree SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3) +LEFT JOIN ot3 ON ot2.a=ot3.a AND ot3.a IN (SELECT a FROM it3); +EXPLAIN +-> Nested loop left join (cost=41.01 rows=288) + -> Nested loop left join (cost=11.70 rows=96) + -> Table scan on ot1 (cost=1.30 rows=8) + -> Nested loop inner join (cost=2.80 rows=12) + -> Single-row index lookup on using (a=ot1.a) + -> Materialize with deduplication (cost=1.10..1.10 rows=3) + -> Filter: (it3.a is not null) (cost=0.80 rows=3) + -> Table scan on it3 (cost=0.80 rows=3) + -> Filter: (ot2.a = ot1.a) (cost=0.11 rows=4) + -> Table scan on ot2 (cost=0.11 rows=4) + -> Nested loop inner join (cost=9.93 rows=3) + -> Filter: (ot3.a = ot2.a) (cost=0.03 rows=3) + -> Table scan on ot3 (cost=0.03 rows=3) + -> Filter: (``.a = ot2.a) (cost=3.23..3.23 rows=1) + -> Single-row index lookup on using (a=ot3.a) + -> Materialize with deduplication (cost=1.10..1.10 rows=3) + -> Filter: (it3.a is not null) (cost=0.80 rows=3) + -> Table scan on it3 (cost=0.80 rows=3) + +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3) +LEFT JOIN ot3 ON ot2.a=ot3.a AND ot3.a IN (SELECT a FROM it3); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it3) +LEFT JOIN ot3 ON ot2.a=ot3.a+0 AND ot3.a IN (SELECT a FROM it3); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +# Test cases, Subquery Pattern 4 +# Example SQ4.1: +explain SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +1 SIMPLE NULL eq_ref 5 test.ot1.a 1 100.00 NULL +1 SIMPLE ot3 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +2 MATERIALIZED it1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a`,`test`.`ot3`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` join `test`.`ot3` semi join (`test`.`it1`)) on(((``.`a` = `test`.`ot1`.`a`) and (`test`.`ot3`.`a` = `test`.`ot1`.`a`) and (`test`.`ot2`.`a` = `test`.`ot1`.`a`))) where true +SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +# Example SQ4.2: +explain SELECT * +FROM ot1 +JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot3 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; Using join buffer (hash join) +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; Using join buffer (hash join) +1 SIMPLE it1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; FirstMatch(ot1); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a`,`test`.`ot3`.`a` AS `a` from `test`.`ot1` join `test`.`ot2` join `test`.`ot3` semi join (`test`.`it1`) where ((`test`.`ot2`.`a` = `test`.`ot3`.`a`) and (`test`.`ot1`.`a` = `test`.`ot3`.`a`) and (`test`.`it1`.`a` = `test`.`ot3`.`a`)) +SELECT * +FROM ot1 +JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +6 6 6 +# Example SQ4.3: +explain SELECT * +FROM ot1 +JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; Using join buffer (hash join) +1 SIMPLE NULL eq_ref 5 test.ot2.a 1 100.00 NULL +1 SIMPLE ot3 NULL ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (hash join) +2 MATERIALIZED it1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a`,`test`.`ot3`.`a` AS `a` from `test`.`ot1` join `test`.`ot2` left join `test`.`ot3` on((`test`.`ot3`.`a` = `test`.`ot2`.`a`)) semi join (`test`.`it1`) where ((`test`.`ot1`.`a` = `test`.`ot2`.`a`) and (``.`a` = `test`.`ot2`.`a`)) +SELECT * +FROM ot1 +JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +2 2 NULL +4 4 NULL +6 6 6 +# Example SQ4.4: +explain SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +1 SIMPLE NULL eq_ref 5 test.ot1.a 1 100.00 NULL +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +1 SIMPLE ot3 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 MATERIALIZED it1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a`,`test`.`ot3`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` left join `test`.`ot3` on((`test`.`ot3`.`a` = `test`.`ot1`.`a`)) semi join (`test`.`it1`)) on(((``.`a` = `test`.`ot1`.`a`) and (`test`.`ot2`.`a` = `test`.`ot1`.`a`))) where true +SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +1 NULL NULL +2 2 NULL +3 NULL NULL +4 4 NULL +5 NULL NULL +6 6 6 +7 NULL NULL +# More test cases +SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a+0) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it1); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 +JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a+0) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +6 6 6 +SELECT * +FROM ot1 +JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +6 6 6 +SELECT * +FROM ot1 +JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it1); +a a a +0 0 0 +6 6 6 +SELECT * +FROM ot1 +JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a+0) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +2 2 NULL +4 4 NULL +6 6 6 +SELECT * +FROM ot1 +JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +2 2 NULL +4 4 NULL +6 6 6 +SELECT * +FROM ot1 +JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it1); +a a a +0 0 0 +2 2 NULL +4 4 NULL +6 6 6 +SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a+0) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +1 NULL NULL +2 2 NULL +3 NULL NULL +4 4 NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +1 NULL NULL +2 2 NULL +3 NULL NULL +4 4 NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it1); +a a a +0 0 0 +1 NULL NULL +2 2 NULL +3 NULL NULL +4 4 NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1) +LEFT JOIN +ot1 AS ot4 +ON ot2.a=ot4.a; +a a a a +0 0 0 0 +1 NULL NULL NULL +2 2 NULL 2 +3 NULL NULL NULL +4 4 NULL 4 +5 NULL NULL NULL +6 6 6 6 +7 NULL NULL NULL +SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a +LEFT JOIN ot1 AS ot4 ON ot3.a=ot4.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a a +0 0 0 0 +1 NULL NULL NULL +2 2 NULL NULL +3 NULL NULL NULL +4 4 NULL NULL +5 NULL NULL NULL +6 6 6 6 +7 NULL NULL NULL +DROP TABLE ot1,ot2,ot3,it1,it2,it3; +CREATE TABLE t ( +a INTEGER DEFAULT NULL +) ENGINE=InnoDB; +INSERT INTO t VALUES (1); +CREATE TABLE t2 ( +a INTEGER DEFAULT NULL +) ENGINE=InnoDB; +INSERT INTO t2 VALUES (1),(1); +CREATE TABLE t4 ( +a INTEGER DEFAULT NULL +) ENGINE=InnoDB; +INSERT INTO t4 VALUES (1),(1); +CREATE TABLE v ( +a INTEGER DEFAULT NULL +) ENGINE=InnoDB; +INSERT INTO v VALUES (1),(1); +explain SELECT * +FROM t AS t1 +LEFT JOIN +(t2 +LEFT JOIN t AS t3 +ON t3.a IN (SELECT a FROM t AS it) +JOIN t4 +ON t4.a=100 +) +ON TRUE +WHERE t1.a IN (SELECT * FROM v AS it2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE it2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1); Using join buffer (hash join) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE it NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t3) +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t4`.`a` AS `a` from `test`.`t` `t1` left join (`test`.`t2` left join (`test`.`t` `t3` semi join (`test`.`t` `it`)) on(((`test`.`it`.`a` = `test`.`t3`.`a`))) join `test`.`t4`) on(((`test`.`t4`.`a` = 100))) semi join (`test`.`v` `it2`) where (`test`.`it2`.`a` = `test`.`t1`.`a`) +SELECT * +FROM t AS t1 +LEFT JOIN +(t2 +LEFT JOIN t AS t3 +ON t3.a IN (SELECT a FROM t AS it) +JOIN t4 +ON t4.a=100 +) +ON TRUE +WHERE t1.a IN (SELECT * FROM v AS it2); +a a a a +1 NULL NULL NULL +DROP TABLE t,t2,t4,v; +# End of WL#5561 +# +# Bug#48868: Left outer join in subquery causes segmentation fault in +# make_join_select. +# +CREATE TABLE t1 (i INTEGER); +INSERT INTO t1 VALUES (1); +INSERT INTO t1 VALUES (2); +CREATE TABLE t2 (i INTEGER); +INSERT INTO t2 VALUES(1); +CREATE TABLE t3 (i INTEGER); +INSERT INTO t3 VALUES (1); +INSERT INTO t3 VALUES (2); +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t2.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +1 +DROP TABLE t1, t2, t3; + +Bug#37899: Wrongly checked optimization prerequisite caused failed +assertion. + +CREATE TABLE t1 ( +`pk` int(11), +`varchar_nokey` varchar(5) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES +(1,'qk'),(2,'j'),(3,'aew'); +SELECT * +FROM t1 +WHERE varchar_nokey IN ( +SELECT +varchar_nokey +FROM +t1 +) XOR pk = 30; +pk varchar_nokey +1 qk +2 j +3 aew +drop table t1; +# +# BUG#41842: Semi-join materialization strategy crashes when the upper query has HAVING +# +CREATE TABLE t1 ( +pk int(11) NOT NULL AUTO_INCREMENT, +int_nokey int(11) NOT NULL, +time_key time NOT NULL, +datetime_key datetime NOT NULL, +datetime_nokey datetime NOT NULL, +varchar_key varchar(1) NOT NULL, +varchar_nokey varchar(1) NOT NULL, +PRIMARY KEY (pk), +KEY time_key (time_key), +KEY datetime_key (datetime_key), +KEY varchar_key (varchar_key) +) ENGINE=MyISaM; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES +(1,0, '00:16:10','2008-09-03 14:25:40','2008-09-03 14:25:40','h','h'), +(2,7, '00:00:00','2001-01-13 00:00:00','2001-01-13 00:00:00','',''), +(3,0, '00:00:00','0000-00-00 00:00:00','0000-00-00 00:00:00','x','x'), +(4,2, '16:29:24','2000-10-16 01:39:08','2000-10-16 01:39:08','w','w'), +(5,1, '09:23:32','0000-00-00 00:00:00','0000-00-00 00:00:00','p','p'), +(6,3, '00:00:00','2007-12-02 00:00:00','2007-12-02 00:00:00','o','o'), +(7,3, '00:00:00','2008-09-11 00:00:00','2008-09-11 00:00:00','',''), +(8,0, '13:59:04','0000-00-00 00:00:00','0000-00-00 00:00:00','s','s'), +(9,7, '09:01:06','0000-00-00 00:00:00','0000-00-00 00:00:00','d','d'), +(10,5,'00:00:00','0000-00-00 00:00:00','0000-00-00 00:00:00','n','n'), +(11,0,'21:06:46','0000-00-00 00:00:00','0000-00-00 00:00:00','o','o'), +(12,2,'00:00:00','0000-00-00 00:00:00','0000-00-00 00:00:00','',''), +(13,6,'14:45:34','2003-07-28 02:34:08','2003-07-28 02:34:08','w','w'), +(14,1,'15:04:12','0000-00-00 00:00:00','0000-00-00 00:00:00','o','o'), +(15,0,'00:00:00','0000-00-00 00:00:00','0000-00-00 00:00:00','x','x'), +(16,0,'15:55:23','2004-03-17 00:32:27','2004-03-17 00:32:27','p','p'), +(17,1,'16:30:00','2004-12-27 19:20:00','2004-12-27 19:20:00','d','d'), +(18,0,'00:00:00','0000-00-00 00:00:00','0000-00-00 00:00:00','h','h'), +(19,0,'14:13:26','2008-11-09 05:53:48','2008-11-09 05:53:48','o','o'), +(20,0,'00:00:00','2009-10-11 06:58:04','2009-10-11 06:58:04','k','k'); +Warnings: +Warning 1264 Out of range value for column 'datetime_key' at row 3 +Warning 1264 Out of range value for column 'datetime_nokey' at row 3 +Warning 1264 Out of range value for column 'datetime_key' at row 5 +Warning 1264 Out of range value for column 'datetime_nokey' at row 5 +Warning 1264 Out of range value for column 'datetime_key' at row 8 +Warning 1264 Out of range value for column 'datetime_nokey' at row 8 +Warning 1264 Out of range value for column 'datetime_key' at row 9 +Warning 1264 Out of range value for column 'datetime_nokey' at row 9 +Warning 1264 Out of range value for column 'datetime_key' at row 10 +Warning 1264 Out of range value for column 'datetime_nokey' at row 10 +Warning 1264 Out of range value for column 'datetime_key' at row 11 +Warning 1264 Out of range value for column 'datetime_nokey' at row 11 +Warning 1264 Out of range value for column 'datetime_key' at row 12 +Warning 1264 Out of range value for column 'datetime_nokey' at row 12 +Warning 1264 Out of range value for column 'datetime_key' at row 14 +Warning 1264 Out of range value for column 'datetime_nokey' at row 14 +Warning 1264 Out of range value for column 'datetime_key' at row 15 +Warning 1264 Out of range value for column 'datetime_nokey' at row 15 +Warning 1264 Out of range value for column 'datetime_key' at row 18 +Warning 1264 Out of range value for column 'datetime_nokey' at row 18 +CREATE TABLE t2 ( +pk int(11) NOT NULL AUTO_INCREMENT, +int_nokey int(11) NOT NULL, +time_key time NOT NULL, +datetime_key datetime NOT NULL, +datetime_nokey datetime NOT NULL, +varchar_key varchar(1) NOT NULL, +varchar_nokey varchar(1) NOT NULL, +PRIMARY KEY (pk), +KEY time_key (time_key), +KEY datetime_key (datetime_key), +KEY varchar_key (varchar_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT IGNORE INTO t2 VALUES +(10,0,'19:39:13','0000-00-00 00:00:00','0000-00-00 00:00:00','g','g'), +(11,8,'03:43:53','0000-00-00 00:00:00','0000-00-00 00:00:00','b','b'); +Warnings: +Warning 1264 Out of range value for column 'datetime_key' at row 1 +Warning 1264 Out of range value for column 'datetime_nokey' at row 1 +Warning 1264 Out of range value for column 'datetime_key' at row 2 +Warning 1264 Out of range value for column 'datetime_nokey' at row 2 +SELECT OUTR.datetime_nokey AS X FROM t1 AS OUTR +WHERE +OUTR.varchar_nokey IN (SELECT +INNR . varchar_nokey AS Y +FROM t2 AS INNR +WHERE +INNR . datetime_key >= INNR . time_key OR +INNR . pk = INNR . int_nokey +) +AND OUTR . varchar_nokey <= 'w' +HAVING X > '2012-12-12'; +X +drop table t1, t2; + +Bug#46797 "Crash in fix_semijoin_strategies_for_picked_join_order +with semijoin=on" + +CREATE TABLE t1 ( +varchar_key varchar(1) DEFAULT NULL, +KEY varchar_key (varchar_key) +); +CREATE TABLE t2 ( +varchar_key varchar(1) DEFAULT NULL, +KEY varchar_key (varchar_key) +); +INSERT INTO t2 VALUES +(NULL),(NULL),(NULL),(NULL),('a'),('a'),('a'),('b'),('b'),('b'),('b'),('c'), +('c'),('c'),('c'),('c'),('c'),('c'),('d'),('d'),('d'),('d'),('d'),('d'),('e'), +('e'),('e'),('e'),('e'),('e'),('f'),('f'),('f'),('g'),('g'),('h'),('h'),('h'), +('h'),('i'),('j'),('j'),('j'),('k'),('k'),('l'),('l'),('m'),('m'),('m'),('m'), +('n'),('n'),('n'),('o'),('o'),('o'),('p'),('p'),('p'),('q'),('q'),('q'),('r'), +('r'),('r'),('r'),('s'),('s'),('s'),('s'),('t'),('t'),('t'),('t'),('u'),('u'), +('u'),('u'),('v'),('v'),('v'),('v'),('w'),('w'),('w'),('w'),('w'),('w'),('x'), +('x'),('x'),('y'),('y'),('y'),('y'),('z'),('z'),('z'),('z'); +CREATE TABLE t3 ( +varchar_key varchar(1) DEFAULT NULL, +KEY varchar_key (varchar_key) +) ENGINE=MyISAM DEFAULT CHARSET=latin1; +INSERT INTO t3 VALUES +(NULL),('c'),('d'),('e'),('f'),('h'),('j'),('k'),('k'),('m'),('m'),('m'), +('n'),('o'),('r'),('t'),('t'),('u'),('w'),('y'); +SELECT varchar_key FROM t3 +WHERE (SELECT varchar_key FROM t3 +WHERE (varchar_key,varchar_key) +IN (SELECT t1.varchar_key, t2 .varchar_key +FROM t1 RIGHT JOIN t2 ON t1.varchar_key +) +); +varchar_key +DROP TABLE t1, t2, t3; +# +# Bug#46556 Returning incorrect, empty results for some IN subqueries +# w/semijoin=on +# +CREATE TABLE t0 ( +pk INTEGER, +vkey VARCHAR(1), +vnokey VARCHAR(1), +PRIMARY KEY (pk), +KEY vkey(vkey) +) charset utf8mb4; +INSERT INTO t0 +VALUES (1,'g','g'), (2,'v','v'), (3,'t','t'), (4,'u','u'), (5,'n','n'); +EXPLAIN SELECT vkey FROM t0 WHERE pk IN +(SELECT t1.pk FROM t0 t1 JOIN t0 t2 ON t2.vkey = t1.vnokey); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL ALL PRIMARY NULL NULL NULL 5 100.00 NULL +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t0.pk 1 100.00 Using where; Using join buffer (Batched Key Access) +1 SIMPLE t2 NULL ref vkey vkey 7 test.t1.vnokey 2 100.00 Using index; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`vkey` AS `vkey` from `test`.`t0` `t1` join `test`.`t0` semi join (`test`.`t0` `t2`) where ((`test`.`t2`.`vkey` = `test`.`t1`.`vnokey`) and (`test`.`t1`.`pk` = `test`.`t0`.`pk`)) +SELECT vkey FROM t0 WHERE pk IN +(SELECT t1.pk FROM t0 t1 JOIN t0 t2 ON t2.vkey = t1.vnokey); +vkey +g +n +t +u +v +DROP TABLE t0; +# End of bug#46556 + +Bug#48834: Procedure with view + subquery + semijoin=on +crashes on second call. + +CREATE TABLE t1 ( t1field integer, primary key (t1field)); +CREATE TABLE t2 ( t2field integer, primary key (t2field)); +CREATE VIEW v1 AS +SELECT t1field as v1field +FROM t1 A +WHERE A.t1field IN (SELECT t1field FROM t2 ); +CREATE VIEW v2 AS +SELECT t2field as v2field +FROM t2 A +WHERE A.t2field IN (SELECT t2field FROM t2 ); +CREATE PROCEDURE p1 () +BEGIN +SELECT v1field +FROM v1 +WHERE v1field IN ( SELECT v2field as vf_inner FROM v2 ); +END| +INSERT INTO t1 VALUES (1),(2),(3); +INSERT INTO t2 VALUES (2),(3),(4); +CALL p1; +v1field +2 +3 +CALL p1; +v1field +2 +3 +DROP TABLE t1,t2; +DROP VIEW v1,v2; +DROP PROCEDURE p1; +# End of BUG#48834 +# +# Bug#46692 "Crash occurring on queries with nested FROM subqueries +# using materialization." +# +CREATE TABLE t1 ( +pk INTEGER PRIMARY KEY, +int_key INTEGER, +KEY int_key(int_key) +); +INSERT INTO t1 VALUES (10,186),(11,NULL),(12,2),(13,3),(14,0),(15,133),(16,1); +CREATE TABLE t2 ( +pk INTEGER PRIMARY KEY, +int_key INTEGER, +KEY int_key(int_key) +); +INSERT INTO t2 VALUES (1,7),(2,2); +SELECT * FROM t1 WHERE (140, 4) IN +(SELECT t2.int_key, t2 .pk FROM t2 STRAIGHT_JOIN t1 ON t2.int_key); +pk int_key +DROP TABLE t1, t2; +# +# Bug#42353 "SELECT ... WHERE oe IN (SELECT w/ LEFT JOIN) query +# causes crash." +# +CREATE TABLE t1 ( +pk INTEGER PRIMARY KEY, +int_nokey INTEGER, +int_key INTEGER, +date_key DATE, +datetime_nokey DATETIME, +varchar_nokey VARCHAR(1) +); +CREATE TABLE t2 ( +date_nokey DATE +); +CREATE TABLE t3 ( +pk INTEGER PRIMARY KEY, +int_nokey INTEGER, +date_key date, +varchar_key VARCHAR(1), +varchar_nokey VARCHAR(1), +KEY date_key (date_key) +); +SELECT date_key FROM t1 +WHERE (int_key, int_nokey) +IN (SELECT t3.int_nokey, t3.pk +FROM t2 LEFT JOIN t3 ON (t2.date_nokey < t3.date_key) +WHERE t3.varchar_key <= t3.varchar_nokey OR t3.int_nokey <= t3.pk +) +AND (varchar_nokey <> 'f' OR NOT int_key < 7); +date_key +# +# Bug#45933 "Crash in optimize_semijoin_nests on JOIN in subquery +# + AND in outer query". +# +INSERT INTO t1 VALUES (10,7,5,'2009-06-16','2002-04-10 14:25:30','w'), +(11,7,0,'0000-00-00','0000-00-00 00:00:00','s'), +(12,4,0,'2003-07-14','2006-09-14 04:01:02','y'), +(13,0,4,'2002-07-25','0000-00-00 00:00:00','c'), +(14,1,8,'2007-07-03','0000-00-00 00:00:00','q'), +(15,6,5,'2001-11-12','0000-00-00 00:00:00',''), +(16,2,9,'0000-00-00','0000-00-00 00:00:00','j'), +(29,9,1,'0000-00-00','2003-08-11 00:00:00','m'); +Warnings: +Warning 1264 Out of range value for column 'date_key' at row 2 +Warning 1264 Out of range value for column 'datetime_nokey' at row 2 +Warning 1264 Out of range value for column 'datetime_nokey' at row 4 +Warning 1264 Out of range value for column 'datetime_nokey' at row 5 +Warning 1264 Out of range value for column 'datetime_nokey' at row 6 +Warning 1264 Out of range value for column 'date_key' at row 7 +Warning 1264 Out of range value for column 'datetime_nokey' at row 7 +Warning 1264 Out of range value for column 'date_key' at row 8 +INSERT IGNORE INTO t3 VALUES (1,9,'0000-00-00','b','b'), +(2,2,'2002-09-17','h','h'); +Warnings: +Warning 1264 Out of range value for column 'date_key' at row 1 +SELECT t1.varchar_nokey FROM t1 JOIN t3 ON t1.datetime_nokey +WHERE t1.varchar_nokey +IN (SELECT varchar_nokey FROM t1 +WHERE (pk) +IN (SELECT t3.int_nokey +FROM t3 LEFT JOIN t1 ON t1.varchar_nokey +WHERE t3.date_key BETWEEN '2008-06-07' AND '2006-06-26' + ) +); +varchar_nokey +DROP TABLE t1, t2, t3; +# +# Bug#45219 "Crash on SELECT DISTINCT query containing a +# LEFT JOIN in subquery" +# +CREATE TABLE t1 ( +pk INTEGER NOT NULL, +int_nokey INTEGER NOT NULL, +datetime_key DATETIME NOT NULL, +varchar_key VARCHAR(1) NOT NULL, +PRIMARY KEY (pk), +KEY datetime_key (datetime_key), +KEY varchar_key (varchar_key) +); +INSERT IGNORE INTO t1 VALUES +(1,9,'0000-00-00 00:00:00','p'),(2,0,'2002-02-09 07:38:13','v'), +(3,8,'2001-05-03 12:08:14','t'),(4,3,'0000-00-00 00:00:00','u'), +(5,7,'2009-07-28 03:43:30','n'),(6,0,'2009-08-04 00:00:00','l'), +(7,1,'0000-00-00 00:00:00','h'),(8,9,'0000-00-00 00:00:00','u'), +(9,0,'2005-08-02 17:16:54','n'),(10,9,'2002-12-21 00:00:00','j'), +(11,0,'2005-08-15 12:37:35','k'),(12,5,'0000-00-00 00:00:00','e'), +(13,0,'2006-03-10 00:00:00','i'),(14,8,'2005-05-16 11:02:36','u'), +(15,8,'2008-11-02 00:00:00','n'),(16,5,'2006-03-15 00:00:00','b'), +(17,1,'0000-00-00 00:00:00','x'),(18,7,'0000-00-00 00:00:00',''), +(19,0,'2008-12-17 20:15:40','q'),(20,9,'0000-00-00 00:00:00','u'); +Warnings: +Warning 1264 Out of range value for column 'datetime_key' at row 1 +Warning 1264 Out of range value for column 'datetime_key' at row 4 +Warning 1264 Out of range value for column 'datetime_key' at row 7 +Warning 1264 Out of range value for column 'datetime_key' at row 8 +Warning 1264 Out of range value for column 'datetime_key' at row 12 +Warning 1264 Out of range value for column 'datetime_key' at row 17 +Warning 1264 Out of range value for column 'datetime_key' at row 18 +Warning 1264 Out of range value for column 'datetime_key' at row 20 +CREATE TABLE t2 LIKE t1; +INSERT INTO t2 VALUES +(10,0,'2006-07-07 07:26:28','q'),(11,5,'2002-09-23 00:00:00','m'), +(12,7,'0000-00-00 00:00:00','j'),(13,1,'2006-06-07 00:00:00','z'), +(14,8,'2000-09-16 12:15:34','a'),(15,2,'2007-08-05 15:47:52',''), +(16,1,'0000-00-00 00:00:00','e'),(17,8,'2005-12-02 19:34:26','t'), +(18,5,'0000-00-00 00:00:00','q'),(19,4,'0000-00-00 00:00:00','b'), +(20,5,'2007-12-28 00:00:00','w'),(21,3,'2004-08-02 11:48:43','m'), +(22,0,'0000-00-00 00:00:00','x'),(23,8,'2004-04-19 12:18:43',''), +(24,0,'2009-04-27 00:00:00','w'),(25,4,'2006-10-20 14:52:15','x'), +(26,0,'0000-00-00 00:00:00','e'),(27,0,'2002-03-22 11:48:37','e'), +(28,2,'0000-00-00 00:00:00','p'),(29,0,'2001-01-04 03:55:07','x'); +Warnings: +Warning 1264 Out of range value for column 'datetime_key' at row 3 +Warning 1264 Out of range value for column 'datetime_key' at row 7 +Warning 1264 Out of range value for column 'datetime_key' at row 9 +Warning 1264 Out of range value for column 'datetime_key' at row 10 +Warning 1264 Out of range value for column 'datetime_key' at row 13 +Warning 1264 Out of range value for column 'datetime_key' at row 17 +Warning 1264 Out of range value for column 'datetime_key' at row 19 +CREATE TABLE t3 LIKE t1; +INSERT INTO t3 VALUES +(10,8,'2007-08-19 08:08:38','i'),(11,0,'2000-05-21 03:51:51',''); +SELECT DISTINCT datetime_key FROM t1 +WHERE (int_nokey, pk) +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#46550 Azalea returning duplicate results for some IN subqueries +# w/ semijoin=on +# +DROP TABLE IF EXISTS t0, t1, t2; +CREATE TABLE t0 ( +int_key int(11) DEFAULT NULL, +varchar_key varchar(1) DEFAULT NULL, +varchar_nokey varchar(1) DEFAULT NULL, +KEY int_key (int_key), +KEY varchar_key (varchar_key,int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t0 VALUES +(1,'m','m'), +(40,'h','h'), +(1,'r','r'), +(1,'h','h'), +(9,'x','x'), +(NULL,'q','q'), +(NULL,'k','k'), +(7,'l','l'), +(182,'k','k'), +(202,'a','a'), +(7,'x','x'), +(6,'j','j'), +(119,'z','z'), +(4,'d','d'), +(5,'h','h'), +(1,'u','u'), +(3,'q','q'), +(7,'a','a'), +(3,'e','e'), +(6,'l','l'); +CREATE TABLE t1 ( +int_key int(11) DEFAULT NULL, +varchar_key varchar(1) DEFAULT NULL, +varchar_nokey varchar(1) DEFAULT NULL, +KEY int_key (int_key), +KEY varchar_key (varchar_key,int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (7,NULL,NULL),(4,'x','x'); +CREATE TABLE t2 ( +int_key int(11) DEFAULT NULL, +varchar_key varchar(1) DEFAULT NULL, +varchar_nokey varchar(1) DEFAULT NULL, +KEY int_key (int_key), +KEY varchar_key (varchar_key,int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (123,NULL,NULL); +SELECT int_key +FROM t0 +WHERE varchar_nokey IN ( +SELECT t1 .varchar_key from t1 +); +int_key +7 +9 +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 +7 +9 +EXPLAIN +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 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1_1 NULL index varchar_key varchar_key 12 NULL 2 50.00 Using where; Using index; LooseScan +1 SIMPLE t1_2 NULL index NULL int_key 5 NULL 2 100.00 Using index; FirstMatch(t1_1) +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 20 10.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`int_key` AS `int_key` from `test`.`t0` semi join (`test`.`t1` `t1_1` join `test`.`t1` `t1_2`) where ((`test`.`t0`.`varchar_nokey` = `test`.`t1_1`.`varchar_key`) and (0 <> `test`.`t1_1`.`int_key`)) +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 +7 +9 +EXPLAIN +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 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t1_1 NULL index varchar_key varchar_key 12 NULL 2 50.00 Using where; Using index; LooseScan +1 SIMPLE t1_2 NULL index NULL int_key 5 NULL 2 100.00 Using index; FirstMatch(t1_1) +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 20 10.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`int_key` AS `int_key` from `test`.`t0` semi join (`test`.`t1` `t1_1` join `test`.`t1` `t1_2`) where ((`test`.`t0`.`varchar_nokey` = `test`.`t1_1`.`varchar_key`) and (0 <> `test`.`t1_1`.`int_key`)) +DROP TABLE t0, t1, t2; +# End of bug#46550 + +Bug #48073 Subquery on char columns from view crashes Mysql + +DROP TABLE IF EXISTS t1, t2; +DROP VIEW IF EXISTS v1; +CREATE TABLE t1 ( +city VARCHAR(50) NOT NULL, +country_id SMALLINT UNSIGNED NOT NULL +); +INSERT INTO t1 VALUES +('Batna',2), +('Bchar',2), +('Skikda',2), +('Tafuna',3), +('Algeria',2) ; +CREATE TABLE t2 ( +country_id SMALLINT UNSIGNED NOT NULL, +country VARCHAR(50) NOT NULL +); +INSERT INTO t2 VALUES +(2,'Algeria'), +(3,'American Samoa') ; +CREATE VIEW v1 AS +SELECT country_id, country +FROM t2 +WHERE LEFT(country,1) = "A" +; +SELECT city, country_id +FROM t1 +WHERE city IN ( +SELECT country +FROM t2 +WHERE LEFT(country, 1) = "A" +); +city country_id +Algeria 2 +SELECT city, country_id +FROM t1 +WHERE city IN ( +SELECT country +FROM v1 +); +city country_id +Algeria 2 +drop table t1, t2; +drop view v1; +# End of bug#48073 + +Bug#49097 subquery with view generates wrong result with +non-prepared statement + +DROP TABLE IF EXISTS t1, t2; +DROP VIEW IF EXISTS v1; +CREATE TABLE t1 ( +city VARCHAR(50) NOT NULL, +country_id SMALLINT UNSIGNED NOT NULL +); +INSERT INTO t1 VALUES +('Batna',2), +('Bchar',2), +('Skikda',2), +('Tafuna',3), +('Algeria',2) ; +CREATE TABLE t2 ( +country_id SMALLINT UNSIGNED NOT NULL, +country VARCHAR(50) NOT NULL +); +INSERT INTO t2 VALUES +(2,'Algeria'), +(3,'XAmerican Samoa') ; +CREATE VIEW v1 AS +SELECT country_id, country +FROM t2 +WHERE LEFT(country,1) = "A" +; +SELECT city, country_id +FROM t1 +WHERE country_id IN ( +SELECT country_id +FROM t2 +WHERE LEFT(country,1) = "A" +); +city country_id +Algeria 2 +Batna 2 +Bchar 2 +Skikda 2 +SELECT city, country_id +FROM t1 +WHERE country_id IN ( +SELECT country_id +FROM v1 +); +city country_id +Algeria 2 +Batna 2 +Bchar 2 +Skikda 2 +PREPARE stmt FROM +" +SELECT city, country_id +FROM t1 +WHERE country_id IN ( + SELECT country_id + FROM v1 +); +"; +execute stmt; +city country_id +Algeria 2 +Batna 2 +Bchar 2 +Skikda 2 +deallocate prepare stmt; +drop table t1, t2; +drop view v1; +# End of Bug#49097 +# +# Bug#49198 Wrong result for second call of procedure +# with view in subselect. +# +CREATE TABLE t1 (t1field integer, primary key (t1field)); +CREATE TABLE t2 (t2field integer, primary key (t2field)); +CREATE TABLE t3 (t3field integer, primary key (t3field)); +CREATE VIEW v2 AS SELECT * FROM t2; +CREATE VIEW v3 AS SELECT * FROM t3; +INSERT INTO t1 VALUES(1),(2); +INSERT INTO t2 VALUES(1),(2); +INSERT INTO t3 VALUES(1),(2); +PREPARE stmt FROM +" +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT * FROM v2); +"; +EXECUTE stmt; +t1field +1 +2 + +EXECUTE stmt; +t1field +1 +2 +PREPARE stmt FROM +" +EXPLAIN +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT * FROM v2) + AND t1field IN (SELECT * FROM v3) +"; +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index PRIMARY PRIMARY 4 NULL 2 100.00 Using index +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +1 SIMPLE t3 NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`t1field` AS `t1field` from `test`.`t2` join `test`.`t3` join `test`.`t1` where ((`test`.`t2`.`t2field` = `test`.`t1`.`t1field`) and (`test`.`t3`.`t3field` = `test`.`t1`.`t1field`)) + +This line is only in place to help --skip_if_hypergraph diffing some more. + +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index PRIMARY PRIMARY 4 NULL 2 100.00 Using index +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +1 SIMPLE t3 NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`t1field` AS `t1field` from `test`.`t2` join `test`.`t3` join `test`.`t1` where ((`test`.`t2`.`t2field` = `test`.`t1`.`t1field`) and (`test`.`t3`.`t3field` = `test`.`t1`.`t1field`)) +DROP TABLE t1, t2, t3; +DROP VIEW v2, v3; +# End of Bug#49198 +# +# Bug#48623 Multiple subqueries are optimized incorrectly +# +CREATE TABLE ot(val VARCHAR(10)) charset utf8mb4; +CREATE TABLE it1(val VARCHAR(10)) charset utf8mb4; +CREATE TABLE it2(val VARCHAR(10)) charset utf8mb4; +INSERT INTO ot VALUES('aaa'), ('bbb'), ('eee'), ('mmm'), ('ppp'); +INSERT INTO it1 VALUES('aaa'), ('aaa'), ('bbb'), ('eee'), ('mmm'), ('ppp'); +INSERT INTO it2 VALUES('aaa'), ('bbb'), ('eee'), ('mmm'), ('ppp'); +EXPLAIN +SELECT * +FROM ot +WHERE ot.val IN (SELECT it1.val FROM it1 +WHERE it1.val LIKE 'a%' OR it1.val LIKE 'e%') +AND ot.val IN (SELECT it2.val FROM it2 +WHERE it2.val LIKE 'a%' OR it2.val LIKE 'e%'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 5 100.00 NULL +1 SIMPLE it2 NULL ALL NULL NULL NULL NULL 5 20.00 Using where; FirstMatch(ot); Using join buffer (hash join) +1 SIMPLE it1 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; FirstMatch(it2); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot`.`val` AS `val` from `test`.`ot` semi join (`test`.`it1`) semi join (`test`.`it2`) where ((`test`.`it2`.`val` = `test`.`ot`.`val`) and (`test`.`it1`.`val` = `test`.`ot`.`val`) and ((`test`.`it1`.`val` like 'a%') or (`test`.`it1`.`val` like 'e%')) and ((`test`.`it2`.`val` like 'a%') or (`test`.`it2`.`val` like 'e%'))) +SELECT * +FROM ot +WHERE ot.val IN (SELECT it1.val FROM it1 +WHERE it1.val LIKE 'a%' OR it1.val LIKE 'e%') +AND ot.val IN (SELECT it2.val FROM it2 +WHERE it2.val LIKE 'a%' OR it2.val LIKE 'e%'); +val +aaa +eee +DROP TABLE ot; +DROP TABLE it1; +DROP TABLE it2; +# End of Bug#48623 +# +# Bug #51487 Assertion failure when semi-join flattening occurs +# for a subquery in HAVING +# +CREATE TABLE t1 (a INT, b INT); +INSERT INTO t1 VALUES (1,10),(2,11),(1,13); +CREATE TABLE t2 AS SELECT * FROM t1; +CREATE TABLE t3 AS SELECT * FROM t1; +SELECT COUNT(*) FROM t1 +GROUP BY t1.a +HAVING t1.a IN (SELECT t3.a FROM t3 +WHERE t3.b IN (SELECT b FROM t2 WHERE t2.a=t1.a)); +COUNT(*) +2 +1 +DROP TABLE t1, t2, t3; +# End of Bug#51487 +# +# BUG#38075: Wrong result: rows matching a subquery with outer join not returned +# +DROP TABLE IF EXISTS ot1, it1, it2; +CREATE TABLE it2 ( +int_key int(11) NOT NULL, +datetime_key datetime NOT NULL, +KEY int_key (int_key), +KEY datetime_key (datetime_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO it2 VALUES +(5,'2002-04-10 14:25:30'), (0,'0000-00-00 00:00:00'), +(0,'2006-09-14 04:01:02'), (4,'0000-00-00 00:00:00'), +(8,'0000-00-00 00:00:00'), (5,'0000-00-00 00:00:00'), +(9,'0000-00-00 00:00:00'), (8,'2007-04-01 11:04:17'), +(1,'0000-00-00 00:00:00'), (7,'2009-01-12 00:00:00'), +(0,'2009-06-05 00:00:00'), (3,'2006-02-14 18:06:35'), +(5,'2006-02-21 07:08:16'), (0,'0000-00-00 00:00:00'), +(7,'0000-00-00 00:00:00'), (0,'0000-00-00 00:00:00'), +(0,'2007-02-13 00:00:00'), (1,'0000-00-00 00:00:00'), +(0,'0000-00-00 00:00:00'), (1,'2003-08-11 00:00:00'); +Warnings: +Warning 1264 Out of range value for column 'datetime_key' at row 2 +Warning 1264 Out of range value for column 'datetime_key' at row 4 +Warning 1264 Out of range value for column 'datetime_key' at row 5 +Warning 1264 Out of range value for column 'datetime_key' at row 6 +Warning 1264 Out of range value for column 'datetime_key' at row 7 +Warning 1264 Out of range value for column 'datetime_key' at row 9 +Warning 1264 Out of range value for column 'datetime_key' at row 14 +Warning 1264 Out of range value for column 'datetime_key' at row 15 +Warning 1264 Out of range value for column 'datetime_key' at row 16 +Warning 1264 Out of range value for column 'datetime_key' at row 18 +Warning 1264 Out of range value for column 'datetime_key' at row 19 +CREATE TABLE ot1 ( +int_nokey int(11) NOT NULL, +int_key int(11) NOT NULL, +KEY int_key (int_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO ot1 VALUES +(5,0), (3,0), (0,2), (3,0), (1,3), (0,0), (1,7), (7,0), (1,7), (0,7), +(0,9), (8,2), (4,4), (9,3), (0,9), (2,5), (0,5), (8,0), (5,8), (1,5); +CREATE TABLE it1 ( +int_nokey int(11) NOT NULL, +int_key int(11) NOT NULL, +KEY int_key (int_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO it1 VALUES +(9,5), (0,4); +SELECT int_key FROM ot1 +WHERE int_nokey IN (SELECT it2.int_key +FROM it1 LEFT JOIN it2 ON it2.datetime_key); +int_key +0 +0 +0 +0 +0 +0 +2 +2 +3 +5 +5 +7 +7 +7 +8 +9 +9 +EXPLAIN +SELECT int_key FROM ot1 +WHERE int_nokey IN (SELECT it2.int_key +FROM it1 LEFT JOIN it2 ON it2.datetime_key); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE it1 NULL index NULL int_key 4 NULL 2 100.00 Using index; Start temporary +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 20 100.00 Using join buffer (hash join) +1 SIMPLE it2 NULL ref int_key int_key 4 test.ot1.int_nokey 2 90.00 Using where; End temporary; Using join buffer (Batched Key Access) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`int_key` AS `int_key` from `test`.`ot1` semi join (`test`.`it1` join `test`.`it2`) where ((`test`.`it2`.`int_key` = `test`.`ot1`.`int_nokey`) and (TIMESTAMP'0000-00-00 00:00:00' <> `test`.`it2`.`datetime_key`)) +DROP TABLE ot1, it1, it2; +# End of BUG#38075 +# +# BUG#50089: Second call of procedure with view in subselect crashes server +# +CREATE TABLE t1(t1field INTEGER, PRIMARY KEY(t1field)); +CREATE VIEW v1 AS +SELECT t1field AS v1field +FROM t1 a +WHERE a.t1field IN (SELECT t1field FROM t1); +INSERT INTO t1 VALUES(1),(2); +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT v1field FROM v1); +t1field +1 +2 +EXPLAIN +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT v1field FROM v1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index PRIMARY PRIMARY 4 NULL 2 100.00 Using index +1 SIMPLE a NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `t1`.`t1field` AS `t1field` from `test`.`t1` `a` join `test`.`t1` join `test`.`t1` where ((`test`.`a`.`t1field` = `t1`.`t1field`) and (`test`.`t1`.`t1field` = `t1`.`t1field`)) +SELECT t1.t1field +FROM t1 LEFT JOIN t1 AS t2 ON t1.t1field IN (SELECT v1field FROM v1); +t1field +1 +1 +2 +2 +EXPLAIN +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT v1field FROM v1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index PRIMARY PRIMARY 4 NULL 2 100.00 Using index +1 SIMPLE a NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `t1`.`t1field` AS `t1field` from `test`.`t1` `a` join `test`.`t1` join `test`.`t1` where ((`test`.`a`.`t1field` = `t1`.`t1field`) and (`test`.`t1`.`t1field` = `t1`.`t1field`)) +CREATE PROCEDURE p1() +BEGIN +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT v1field FROM v1); +END| +CALL p1; +t1field +1 +2 +CALL p1; +t1field +1 +2 +PREPARE stmt FROM +" +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT v1field FROM v1); +"; +EXECUTE stmt; +t1field +1 +2 + +EXECUTE stmt; +t1field +1 +2 +DROP PROCEDURE p1; +DROP VIEW v1; +DROP TABLE t1; +# End of BUG#50089 +# +# Bug#45191: Incorrectly initialized semi-join led to a wrong result. +# +CREATE TABLE staff (EMPNUM CHAR(3) NOT NULL, +EMPNAME CHAR(20), GRADE DECIMAL(4), CITY CHAR(15)) charset latin1; +CREATE TABLE proj (PNUM CHAR(3) NOT NULL, +PNAME CHAR(20), PTYPE CHAR(6), +BUDGET DECIMAL(9), +CITY CHAR(15)) charset latin1; +CREATE TABLE works (EMPNUM CHAR(3) NOT NULL, +PNUM CHAR(3) NOT NULL, HOURS DECIMAL(5)) charset latin1; +INSERT INTO staff VALUES ('E1','Alice',12,'Deale'); +INSERT INTO staff VALUES ('E2','Betty',10,'Vienna'); +INSERT INTO staff VALUES ('E3','Carmen',13,'Vienna'); +INSERT INTO staff VALUES ('E4','Don',12,'Deale'); +INSERT INTO staff VALUES ('E5','Ed',13,'Akron'); +INSERT INTO proj VALUES ('P1','MXSS','Design',10000,'Deale'); +INSERT INTO proj VALUES ('P2','CALM','Code',30000,'Vienna'); +INSERT INTO proj VALUES ('P3','SDP','Test',30000,'Tampa'); +INSERT INTO proj VALUES ('P4','SDP','Design',20000,'Deale'); +INSERT INTO proj VALUES ('P5','IRM','Test',10000,'Vienna'); +INSERT INTO proj VALUES ('P6','PAYR','Design',50000,'Deale'); +INSERT INTO works VALUES ('E1','P1',40); +INSERT INTO works VALUES ('E1','P2',20); +INSERT INTO works VALUES ('E1','P3',80); +INSERT INTO works VALUES ('E1','P4',20); +INSERT INTO works VALUES ('E1','P5',12); +INSERT INTO works VALUES ('E1','P6',12); +INSERT INTO works VALUES ('E2','P1',40); +INSERT INTO works VALUES ('E2','P2',80); +INSERT INTO works VALUES ('E3','P2',20); +INSERT INTO works VALUES ('E4','P2',20); +INSERT INTO works VALUES ('E4','P4',40); +INSERT INTO works VALUES ('E4','P5',80); +explain SELECT EMPNUM, EMPNAME +FROM staff +WHERE EMPNUM IN +(SELECT EMPNUM FROM works +WHERE PNUM IN +(SELECT PNUM FROM proj)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE staff NULL ALL NULL NULL NULL NULL 5 100.00 NULL +1 SIMPLE NULL eq_ref 3 test.staff.EMPNUM 1 100.00 NULL +2 MATERIALIZED proj NULL ALL NULL NULL NULL NULL 6 100.00 NULL +2 MATERIALIZED works NULL ALL NULL NULL NULL NULL 12 10.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`staff`.`EMPNUM` AS `EMPNUM`,`test`.`staff`.`EMPNAME` AS `EMPNAME` from `test`.`staff` semi join (`test`.`works` join `test`.`proj`) where ((``.`EMPNUM` = `test`.`staff`.`EMPNUM`) and (`test`.`works`.`PNUM` = `test`.`proj`.`PNUM`)) +SELECT EMPNUM, EMPNAME +FROM staff +WHERE EMPNUM IN +(SELECT EMPNUM FROM works +WHERE PNUM IN +(SELECT PNUM FROM proj)); +EMPNUM EMPNAME +E1 Alice +E2 Betty +E3 Carmen +E4 Don +drop table staff,works,proj; +# End of bug#45191 +# +# BUG#36896: Server crash on SELECT FROM DUAL +# +create table t1 (a int); +select 1 as res from dual where (1) in (select * from t1); +res +drop table t1; + +BUG#40118 Crash when running Batched Key Access and requiring one match for each key + +create table t0(a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (a int, key(a)); +insert into t1 select * from t0; +alter table t1 add b int not null, add filler char(200); +insert into t1 select * from t1; +insert into t1 select * from t1; +select * from t0 where t0.a in (select t1.a from t1 where t1.b=0); +a +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +drop table t0, t1; +# +# BUG#32665 Query with dependent subquery is too slow +# +create table t1 ( +idIndividual int primary key +); +insert into t1 values (1),(2); +create table t2 ( +idContact int primary key, +contactType int, +idObj int +); +insert into t2 values (1,1,1),(2,2,2),(3,3,3); +create table t3 ( +idAddress int primary key, +idContact int, +postalStripped varchar(100) +); +insert into t3 values (1,1, 'foo'), (2,2,'bar'); +The following must be converted to a semi-join: +explain SELECT a.idIndividual FROM t1 a +WHERE a.idIndividual IN +( SELECT c.idObj FROM t3 cona +INNER JOIN t2 c ON c.idContact=cona.idContact +WHERE cona.postalStripped='T2H3B2' + ); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE a NULL index PRIMARY PRIMARY 4 NULL 2 100.00 Using index +1 SIMPLE cona NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE c NULL eq_ref PRIMARY PRIMARY 4 test.cona.idContact 1 33.33 Using where; FirstMatch(a) +Warnings: +Note 1003 /* select#1 */ select `test`.`a`.`idIndividual` AS `idIndividual` from `test`.`t1` `a` semi join (`test`.`t3` `cona` join `test`.`t2` `c`) where ((`test`.`c`.`idContact` = `test`.`cona`.`idContact`) and (`test`.`c`.`idObj` = `test`.`a`.`idIndividual`) and (`test`.`cona`.`postalStripped` = 'T2H3B2')) +drop table t1,t2,t3; +CREATE TABLE t1 (one int, two int, flag char(1)); +CREATE TABLE t2 (one int, two int, flag char(1)); +INSERT INTO t1 VALUES(1,2,'Y'),(2,3,'Y'),(3,4,'Y'),(5,6,'N'),(7,8,'N'); +INSERT INTO t2 VALUES(1,2,'Y'),(2,3,'Y'),(3,4,'Y'),(5,6,'N'),(7,8,'N'); +SELECT * FROM t1 +WHERE ROW(one,two) IN (SELECT DISTINCT one,two FROM t2 WHERE flag = 'N'); +one two flag +5 6 N +7 8 N +SELECT * FROM t1 +WHERE ROW(one,two) IN (SELECT DISTINCT one,two FROM t1 WHERE flag = 'N'); +one two flag +5 6 N +7 8 N +insert into t2 values (null,null,'N'); +insert into t2 values (null,3,'0'); +insert into t2 values (null,5,'0'); +insert into t2 values (10,null,'0'); +insert into t1 values (10,3,'0'); +insert into t1 values (10,5,'0'); +insert into t1 values (10,10,'0'); +SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = 'N') as 'test' from t1; +one two test +1 2 NULL +2 3 NULL +3 4 NULL +5 6 1 +7 8 1 +10 3 NULL +10 5 NULL +10 10 NULL +SELECT one,two from t1 where ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = 'N'); +one two +5 6 +7 8 +SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = 'N' group by one,two) as 'test' from t1; +one two test +1 2 NULL +2 3 NULL +3 4 NULL +5 6 1 +7 8 1 +10 3 NULL +10 5 NULL +10 10 NULL +SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = '0') as 'test' from t1; +one two test +1 2 0 +2 3 NULL +3 4 0 +5 6 0 +7 8 0 +10 3 NULL +10 5 NULL +10 10 NULL +SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = '0' group by one,two) as 'test' from t1; +one two test +1 2 0 +2 3 NULL +3 4 0 +5 6 0 +7 8 0 +10 3 NULL +10 5 NULL +10 10 NULL +explain SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = '0') as 'test' from t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 9 11.11 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`one` AS `one`,`test`.`t1`.`two` AS `two`,((`test`.`t1`.`one`,`test`.`t1`.`two`),(/* select#2 */ select `test`.`t2`.`one`,`test`.`t2`.`two` from `test`.`t2` where ((`test`.`t2`.`flag` = '0') and (outer_field_is_not_null, (((`test`.`t1`.`one`) = `test`.`t2`.`one`) or (`test`.`t2`.`one` is null)), true) and (outer_field_is_not_null, (((`test`.`t1`.`two`) = `test`.`t2`.`two`) or (`test`.`t2`.`two` is null)), true)) having ((outer_field_is_not_null, (`test`.`t2`.`one`), true) and (outer_field_is_not_null, (`test`.`t2`.`two`), true)))) AS `test` from `test`.`t1` +explain SELECT one,two from t1 where ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = 'N'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 9 11.11 Using where; FirstMatch(t1); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`one` AS `one`,`test`.`t1`.`two` AS `two` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`two` = `test`.`t1`.`two`) and (`test`.`t2`.`one` = `test`.`t1`.`one`) and (`test`.`t2`.`flag` = 'N')) +explain SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = '0' group by one,two) as 'test' from t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 9 11.11 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`one` AS `one`,`test`.`t1`.`two` AS `two`,((`test`.`t1`.`one`,`test`.`t1`.`two`),(/* select#2 */ select `test`.`t2`.`one`,`test`.`t2`.`two` from `test`.`t2` where ((`test`.`t2`.`flag` = '0') and (outer_field_is_not_null, (((`test`.`t1`.`one`) = `test`.`t2`.`one`) or (`test`.`t2`.`one` is null)), true) and (outer_field_is_not_null, (((`test`.`t1`.`two`) = `test`.`t2`.`two`) or (`test`.`t2`.`two` is null)), true)) having ((outer_field_is_not_null, (`test`.`t2`.`one`), true) and (outer_field_is_not_null, (`test`.`t2`.`two`), true)))) AS `test` from `test`.`t1` +DROP TABLE t1,t2; +CREATE TABLE t1 (a char(5), b char(5)); +INSERT INTO t1 VALUES (NULL,'aaa'), ('aaa','aaa'); +SELECT * FROM t1 WHERE (a,b) IN (('aaa','aaa'), ('aaa','bbb')); +a b +aaa aaa +DROP TABLE t1; +CREATE TABLE t1 (a CHAR(1), b VARCHAR(10)) charset utf8mb4; +INSERT INTO t1 VALUES ('a', 'aa'); +INSERT INTO t1 VALUES ('a', 'aaa'); +SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1); +a b +CREATE INDEX I1 ON t1 (a); +CREATE INDEX I2 ON t1 (b); +EXPLAIN SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index I1 I1 5 NULL 2 100.00 Using index; LooseScan +1 SIMPLE t1 NULL ALL I2 NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t1`) where (`test`.`t1`.`b` = `test`.`t1`.`a`) +SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1); +a b +CREATE TABLE t2 (a VARCHAR(1), b VARCHAR(10)) charset utf8mb4; +INSERT INTO t2 SELECT * FROM t1; +CREATE INDEX I1 ON t2 (a); +CREATE INDEX I2 ON t2 (b); +EXPLAIN SELECT a,b FROM t2 WHERE b IN (SELECT a FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index I1 I1 7 NULL 2 100.00 Using index; LooseScan +1 SIMPLE t2 NULL ALL I2 NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t2` semi join (`test`.`t2`) where (`test`.`t2`.`b` = `test`.`t2`.`a`) +SELECT a,b FROM t2 WHERE b IN (SELECT a FROM t2); +a b +EXPLAIN +SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1 WHERE LENGTH(a)<500); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index I1 I1 5 NULL 2 100.00 Using where; Using index; LooseScan +1 SIMPLE t1 NULL ALL I2 NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t1`) where ((length(`test`.`t1`.`a`) < 500) and (`test`.`t1`.`b` = `test`.`t1`.`a`)) +SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1 WHERE LENGTH(a)<500); +a b +DROP TABLE t1,t2; +# +# BUG#45928 "Differing query results depending on MRR and +# engine_condition_pushdown settings" +# +CREATE TABLE `t1` ( +`pk` int(11) NOT NULL AUTO_INCREMENT, +`time_nokey` time NOT NULL, +`varchar_key` varchar(1) NOT NULL, +`varchar_nokey` varchar(1) NOT NULL, +PRIMARY KEY (`pk`), +KEY `varchar_key` (`varchar_key`) +) AUTO_INCREMENT=12 DEFAULT CHARSET=latin1; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO `t1` VALUES (10,'00:00:00','i','i'),(11,'00:00:00','',''); +SELECT `time_nokey` G1 FROM t1 WHERE ( `varchar_nokey` , `varchar_key` ) IN ( +SELECT `varchar_nokey` , `varchar_nokey` ) AND `varchar_key` >= 'c' HAVING G1 ORDER +BY `pk` ; +G1 +DROP TABLE t1; +# +# BUG#45863 "Assertion failed: (fixed == 0), function fix_fields(), +# file item.cc, line 4448" +# +DROP TABLE IF EXISTS C, BB; +CREATE TABLE C ( +varchar_nokey varchar(1) NOT NULL +); +INSERT INTO C VALUES +('k'),('a'),(''),('u'),('e'),('v'),('i'), +('t'),('u'),('f'),('u'),('m'),('j'),('f'), +('v'),('j'),('g'),('e'),('h'),('z'); +CREATE TABLE BB ( +varchar_nokey varchar(1) NOT NULL +); +INSERT INTO BB VALUES ('i'),('t'); +SELECT varchar_nokey FROM C +WHERE (varchar_nokey, OUTR) IN (SELECT varchar_nokey +FROM BB); +ERROR 42S22: Unknown column 'OUTR' in 'IN/ALL/ANY subquery' +SELECT varchar_nokey FROM C +WHERE (varchar_nokey, OUTR) IN (SELECT varchar_nokey, varchar_nokey +FROM BB); +ERROR 42S22: Unknown column 'OUTR' in 'IN/ALL/ANY subquery' +DROP TABLE C,BB; +# +# During work with BUG#45863 I had problems with a query that was +# optimized differently in regular and prepared mode. +# Because there was a bug in one of the selected strategies, I became +# aware of the problem. Adding an EXPLAIN query to catch this. +DROP TABLE IF EXISTS t1, t2, t3; +CREATE TABLE t1 +(EMPNUM CHAR(3) NOT NULL, +EMPNAME CHAR(20), +GRADE DECIMAL(4), +CITY CHAR(15)) charset latin1; +CREATE TABLE t2 +(PNUM CHAR(3) NOT NULL, +PNAME CHAR(20), +PTYPE CHAR(6), +BUDGET DECIMAL(9), +CITY CHAR(15)) charset latin1; +CREATE TABLE t3 +(EMPNUM CHAR(3) NOT NULL, +PNUM CHAR(3) NOT NULL, +HOURS DECIMAL(5)) charset latin1; +INSERT INTO t1 VALUES ('E1','Alice',12,'Deale'); +INSERT INTO t1 VALUES ('E2','Betty',10,'Vienna'); +INSERT INTO t1 VALUES ('E3','Carmen',13,'Vienna'); +INSERT INTO t1 VALUES ('E4','Don',12,'Deale'); +INSERT INTO t1 VALUES ('E5','Ed',13,'Akron'); +INSERT INTO t2 VALUES ('P1','MXSS','Design',10000,'Deale'); +INSERT INTO t2 VALUES ('P2','CALM','Code',30000,'Vienna'); +INSERT INTO t2 VALUES ('P3','SDP','Test',30000,'Tampa'); +INSERT INTO t2 VALUES ('P4','SDP','Design',20000,'Deale'); +INSERT INTO t2 VALUES ('P5','IRM','Test',10000,'Vienna'); +INSERT INTO t2 VALUES ('P6','PAYR','Design',50000,'Deale'); +INSERT INTO t3 VALUES ('E1','P1',40); +INSERT INTO t3 VALUES ('E1','P2',20); +INSERT INTO t3 VALUES ('E1','P3',80); +INSERT INTO t3 VALUES ('E1','P4',20); +INSERT INTO t3 VALUES ('E1','P5',12); +INSERT INTO t3 VALUES ('E1','P6',12); +INSERT INTO t3 VALUES ('E2','P1',40); +INSERT INTO t3 VALUES ('E2','P2',80); +INSERT INTO t3 VALUES ('E3','P2',20); +INSERT INTO t3 VALUES ('E4','P2',20); +INSERT INTO t3 VALUES ('E4','P4',40); +INSERT INTO t3 VALUES ('E4','P5',80); +CREATE UNIQUE INDEX t1_IDX ON t1(EMPNUM); +EXPLAIN SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN +(SELECT EMPNUM +FROM t3 +WHERE PNUM IN +(SELECT PNUM +FROM t2 +WHERE PTYPE = 'Design')); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL eq_ref t1_IDX t1_IDX 3 .EMPNUM 1 100.00 Using join buffer (Batched Key Access) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = ``.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) +PREPARE stmt FROM "EXPLAIN SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN + (SELECT EMPNUM + FROM t3 + WHERE PNUM IN + (SELECT PNUM + FROM t2 + WHERE PTYPE = 'Design'))"; +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL eq_ref t1_IDX t1_IDX 3 .EMPNUM 1 100.00 Using join buffer (Batched Key Access) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = ``.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) + +This line is only in place to help --skip_if_hypergraph diffing some more. + +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL eq_ref t1_IDX t1_IDX 3 .EMPNUM 1 100.00 Using join buffer (Batched Key Access) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = ``.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) +DEALLOCATE PREPARE stmt; +DROP INDEX t1_IDX ON t1; +CREATE INDEX t1_IDX ON t1(EMPNUM); +EXPLAIN SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN +(SELECT EMPNUM +FROM t3 +WHERE PNUM IN +(SELECT PNUM +FROM t2 +WHERE PTYPE = 'Design')); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ref t1_IDX t1_IDX 3 .EMPNUM 2 100.00 Using join buffer (Batched Key Access) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = ``.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) +PREPARE stmt FROM "EXPLAIN SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN + (SELECT EMPNUM + FROM t3 + WHERE PNUM IN + (SELECT PNUM + FROM t2 + WHERE PTYPE = 'Design'))"; +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ref t1_IDX t1_IDX 3 .EMPNUM 2 100.00 Using join buffer (Batched Key Access) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = ``.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) + +This line is only in place to help --skip_if_hypergraph diffing some more. + +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ref t1_IDX t1_IDX 3 .EMPNUM 2 100.00 Using join buffer (Batched Key Access) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = ``.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) +DEALLOCATE PREPARE stmt; +DROP INDEX t1_IDX ON t1; +EXPLAIN SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN +(SELECT EMPNUM +FROM t3 +WHERE PNUM IN +(SELECT PNUM +FROM t2 +WHERE PTYPE = 'Design')); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 20.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = `test`.`t3`.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) +PREPARE stmt FROM "EXPLAIN SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN + (SELECT EMPNUM + FROM t3 + WHERE PNUM IN + (SELECT PNUM + FROM t2 + WHERE PTYPE = 'Design'))"; +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 20.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = `test`.`t3`.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) + +This line is only in place to help --skip_if_hypergraph diffing some more. + +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 20.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = `test`.`t3`.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) +DEALLOCATE PREPARE stmt; +DROP TABLE t1, t2, t3; +# +# BUG#45221 Query SELECT pk FROM C WHERE pk IN (SELECT int_key) failing +# +CREATE TABLE t1 ( +i1_key INT, +i2 INT, +i3 INT, +KEY i1_index (i1_key) +); +INSERT INTO t1 VALUES (9,1,2), (9,2,1); +CREATE TABLE t2 ( +pk INT NOT NULL, +i1 INT, +PRIMARY KEY (pk) +); +INSERT INTO t2 VALUES (9,1); +SELECT pk +FROM t2 +WHERE +pk IN ( +SELECT i1_key +FROM t1 +WHERE t1.i2 < t1.i3 XOR t2.i1 > 1 +ORDER BY t1.i2 desc); +pk +9 +DROP TABLE t1,t2; +# BUG#50361 Doublenested noncorrelated subquery with FirstMatch and join cache wrong result +# +CREATE TABLE t1( +id INTEGER +); +INSERT INTO t1 VALUES(10),(20); +create table t2 select * from t1; +create table t3 select * from t1; +SELECT * +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t2 +WHERE 1 IN(SELECT 1 +FROM t3)); +id +10 +20 +explain SELECT * +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t2 +WHERE 1 IN(SELECT 1 +FROM t3)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE NULL const 4 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where true +delete from t2; +delete from t3; +INSERT INTO t1 VALUES(30),(40),(50),(60),(70),(80),(90); +insert into t2 select * from t1; +insert into t3 select * from t1; +create table t4 select * from t1; +SELECT * +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t2 +WHERE 1 IN(SELECT 1 +FROM t3 +WHERE 1 IN(SELECT 1 +FROM t4))); +id +10 +20 +30 +40 +50 +60 +70 +80 +90 +explain SELECT * +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t2 +WHERE 1 IN(SELECT 1 +FROM t3 +WHERE 1 IN(SELECT 1 +FROM t4))); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 9 100.00 NULL +1 SIMPLE NULL const 4 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 9 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 9 100.00 Using join buffer (hash join) +2 MATERIALIZED t4 NULL ALL NULL NULL NULL NULL 9 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3` join `test`.`t4`) where true +SELECT * +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t1))); +id +10 +20 +30 +40 +50 +60 +70 +80 +90 +drop table t1,t2,t3,t4; +# +# Bug#53236 Segfault in DTCollation::set(DTCollation&) +# +CREATE TABLE t1 ( +pk INTEGER AUTO_INCREMENT, +col_varchar VARCHAR(1), +PRIMARY KEY (pk) +) +; +INSERT INTO t1 (col_varchar) +VALUES +('w'), +('m') +; +SELECT table1.pk +FROM ( t1 AS table1 JOIN t1 AS table2 ON (table1.col_varchar = +table2.col_varchar) ) +WHERE ( 1, 2 ) IN ( SELECT SUBQUERY1_t1.pk AS SUBQUERY1_field1, +SUBQUERY1_t1.pk AS SUBQUERY1_field2 +FROM ( t1 AS SUBQUERY1_t1 JOIN t1 AS SUBQUERY1_t2 +ON (SUBQUERY1_t2.col_varchar = +SUBQUERY1_t1.col_varchar) ) ) +; +pk +drop table t1; +# +# BUG#53298 "wrong result with semijoin (no semijoin strategy chosen)" +# +create table t1 (uid int, fid int); +insert into t1 values (1,1), (3,1); +create table t2 (uid int, name varchar(128)); +insert into t2 values (1, "A"), (2, "B"); +create table t3 (uid int, fid int, index(uid)); +insert into t3 values (1,3), (1,3); +create table t4 (uid int); +insert into t4 values (3); +explain select t2.uid from t2, t1 +where t1.uid in (select t4.uid from t4, t3 where t3.uid=1 and t4.uid=t3.fid) +and t2.uid=t1.fid; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 0.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t4 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 MATERIALIZED t3 NULL ref uid uid 5 const 1 50.00 Using where; Using join buffer (Batched Key Access) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`uid` AS `uid` from `test`.`t2` join `test`.`t1` semi join (`test`.`t4` join `test`.`t3`) where ((`test`.`t1`.`uid` = ``.`uid`) and (`test`.`t3`.`fid` = `test`.`t4`.`uid`) and (`test`.`t3`.`uid` = 1) and (`test`.`t1`.`fid` = `test`.`t2`.`uid`)) +select t2.uid from t2, t1 +where t1.uid in (select t4.uid from t4, t3 where t3.uid=1 and t4.uid=t3.fid) +and t2.uid=t1.fid; +uid +1 +drop table t1,t2,t3,t4; +CREATE TABLE t1 ( +pk int, +a varchar(1), +b varchar(4), +c varchar(4), +d varchar(4), +PRIMARY KEY (pk) +) charset utf8mb4; +INSERT INTO t1 VALUES (1,'o','ffff','ffff','ffoo'),(2,'f','ffff','ffff','ffff'); +CREATE TABLE t2 LIKE t1; +INSERT INTO t2 VALUES (1,'i','iiii','iiii','iiii'),(2,'f','ffff','ffff','ffff'); +EXPLAIN SELECT pk FROM t1 WHERE (a) IN (SELECT a FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using index condition; Using where; Using MRR; FirstMatch(t1); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`a` = `test`.`t1`.`a`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (a) IN (SELECT a FROM t2 WHERE pk > 0); +pk +2 +SELECT pk FROM t1 WHERE (b,c,d) IN (SELECT b,c,d FROM t2 WHERE pk > 0); +pk +2 +DROP TABLE t1, t2; +CREATE TABLE t1 (f1 INT, f2 DECIMAL(5,3)) ENGINE=MyISAM; +INSERT INTO t1 (f1, f2) VALUES (1, 1.789); +INSERT INTO t1 (f1, f2) VALUES (13, 1.454); +INSERT INTO t1 (f1, f2) VALUES (10, 1.668); +CREATE TABLE t2 LIKE t1; +INSERT INTO t2 VALUES (1, 1.789); +INSERT INTO t2 VALUES (13, 1.454); +EXPLAIN SELECT COUNT(*) FROM t1 WHERE (f1,f2) IN (SELECT f1,f2 FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`f2` = `test`.`t2`.`f2`) and (`test`.`t1`.`f1` = `test`.`t2`.`f1`)) +SELECT COUNT(*) FROM t1 WHERE (f1,f2) IN (SELECT f1,f2 FROM t2); +COUNT(*) +2 +DROP TABLE t1, t2; +CREATE TABLE t1 ( +ID int(11) NOT NULL auto_increment, +Name char(35) NOT NULL default '', +Country char(3) NOT NULL default '', +Population int(11) NOT NULL default '0', +PRIMARY KEY (ID), +INDEX (Population), +INDEX (Country) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t2 ( +Code char(3) NOT NULL default '', +Name char(52) NOT NULL default '', +SurfaceArea float(10,2) NOT NULL default '0.00', +Population int(11) NOT NULL default '0', +Capital int(11) default NULL, +PRIMARY KEY (Code), +UNIQUE INDEX (Name), +INDEX (Population) +) charset utf8mb4; +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t3 ( +Country char(3) NOT NULL default '', +Language char(30) NOT NULL default '', +Percentage float(3,1) NOT NULL default '0.0', +PRIMARY KEY (Country, Language), +INDEX (Percentage) +) charset utf8mb4; +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +EXPLAIN SELECT Name FROM t2 +WHERE t2.Code IN (SELECT Country FROM t1 WHERE Population > 5000000) +AND +t2.Code IN (SELECT Country FROM t3 +WHERE Language='English' AND Percentage > 10 AND +t2.Population > 100000); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range Population,Country Population 4 NULL 1 100.00 Using index condition; Using MRR; Start temporary +1 SIMPLE t2 NULL eq_ref PRIMARY,Population PRIMARY 12 test.t1.Country 1 75.00 Using where; Using join buffer (Batched Key Access) +1 SIMPLE t3 NULL eq_ref PRIMARY,Percentage PRIMARY 132 test.t1.Country,const 1 95.45 Using index condition; Using where; End temporary; Using join buffer (Batched Key Access) +Warnings: +Note 1276 Field or reference 'test.t2.Population' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t2`.`Name` AS `Name` from `test`.`t3` join `test`.`t2` semi join (`test`.`t1`) where ((`test`.`t2`.`Code` = `test`.`t1`.`Country`) and (`test`.`t3`.`Country` = `test`.`t1`.`Country`) and (`test`.`t3`.`Language` = 'English') and (`test`.`t3`.`Percentage` > 10) and (`test`.`t2`.`Population` > 100000) and (`test`.`t1`.`Population` > 5000000)) +EXPLAIN FORMAT=JSON SELECT Name FROM t2 +WHERE t2.Code IN (SELECT Country FROM t1 WHERE Population > 5000000) +AND +t2.Code IN (SELECT Country FROM t3 +WHERE Language='English' AND Percentage > 10 AND +t2.Population > 100000); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "2.45" + }, + "duplicates_removal": { + "using_temporary_table": true, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "range", + "possible_keys": [ + "Population", + "Country" + ], + "key": "Population", + "used_key_parts": [ + "Population" + ], + "key_length": "4", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "index_condition": "(`test`.`t1`.`Population` > 5000000)", + "using_MRR": true, + "cost_info": { + "read_cost": "0.60", + "eval_cost": "0.10", + "prefix_cost": "0.70", + "data_read_per_join": "168" + }, + "used_columns": [ + "Country", + "Population" + ] + } + }, + { + "table": { + "table_name": "t2", + "access_type": "eq_ref", + "possible_keys": [ + "PRIMARY", + "Population" + ], + "key": "PRIMARY", + "used_key_parts": [ + "Code" + ], + "key_length": "12", + "ref": [ + "test.t1.Country" + ], + "rows_examined_per_scan": 1, + "rows_produced_per_join": 0, + "filtered": "75.00", + "using_join_buffer": "Batched Key Access", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.08", + "prefix_cost": "2.20", + "data_read_per_join": "180" + }, + "used_columns": [ + "Code", + "Name", + "Population" + ], + "attached_condition": "(`test`.`t2`.`Population` > 100000)" + } + }, + { + "table": { + "table_name": "t3", + "access_type": "eq_ref", + "possible_keys": [ + "PRIMARY", + "Percentage" + ], + "key": "PRIMARY", + "used_key_parts": [ + "Country", + "Language" + ], + "key_length": "132", + "ref": [ + "test.t1.Country", + "const" + ], + "rows_examined_per_scan": 1, + "rows_produced_per_join": 0, + "filtered": "95.45", + "index_condition": "(`test`.`t3`.`Language` = 'English')", + "using_join_buffer": "Batched Key Access", + "cost_info": { + "read_cost": "0.19", + "eval_cost": "0.07", + "prefix_cost": "2.46", + "data_read_per_join": "103" + }, + "used_columns": [ + "Country", + "Language", + "Percentage" + ], + "attached_condition": "(`test`.`t3`.`Percentage` > 10)" + } + } + ] + } + } +} +Warnings: +Note 1276 Field or reference 'test.t2.Population' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t2`.`Name` AS `Name` from `test`.`t3` join `test`.`t2` semi join (`test`.`t1`) where ((`test`.`t2`.`Code` = `test`.`t1`.`Country`) and (`test`.`t3`.`Country` = `test`.`t1`.`Country`) and (`test`.`t3`.`Language` = 'English') and (`test`.`t3`.`Percentage` > 10) and (`test`.`t2`.`Population` > 100000) and (`test`.`t1`.`Population` > 5000000)) +DROP TABLE t1,t2,t3; +CREATE TABLE t1 ( +Code char(3) NOT NULL DEFAULT '', +Name char(52) NOT NULL DEFAULT '', +Continent enum('Asia','Europe','North America','Africa','Oceania','Antarctica','South America') NOT NULL DEFAULT 'Asia', +Region char(26) NOT NULL DEFAULT '', +SurfaceArea float(10,2) NOT NULL DEFAULT '0.00', +IndepYear smallint(6) DEFAULT NULL, +Population int(11) NOT NULL DEFAULT '0', +LifeExpectancy float(3,1) DEFAULT NULL, +GNP float(10,2) DEFAULT NULL, +GNPOld float(10,2) DEFAULT NULL, +LocalName char(45) NOT NULL DEFAULT '', +GovernmentForm char(45) NOT NULL DEFAULT '', +HeadOfState char(60) DEFAULT NULL, +Capital int(11) DEFAULT NULL, +Code2 char(2) NOT NULL DEFAULT '', +PRIMARY KEY (Code) +) charset utf8mb4; +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t2 ( +ID int(11) NOT NULL AUTO_INCREMENT, +Name char(35) NOT NULL DEFAULT '', +CountryCode char(3) NOT NULL DEFAULT '', +District char(20) NOT NULL DEFAULT '', +Population int(11) NOT NULL DEFAULT '0', +PRIMARY KEY (ID), +KEY CountryCode (CountryCode) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +set names latin1; +Fill the table with test data +This must not use LooseScan: +EXPLAIN SELECT Name FROM t1 +WHERE t1.Code IN ( +SELECT t2.CountryCode FROM t2 WHERE Population > 5000000); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL PRIMARY NULL NULL NULL 31 100.00 NULL +1 SIMPLE NULL eq_ref 12 test.t1.Code 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL CountryCode NULL NULL NULL 545 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`Name` AS `Name` from `test`.`t1` semi join (`test`.`t2`) where ((``.`CountryCode` = `test`.`t1`.`Code`) and (`test`.`t2`.`Population` > 5000000)) +SELECT Name FROM t1 +WHERE t1.Code IN ( +SELECT t2.CountryCode FROM t2 WHERE Population > 5000000); +Name +Austria +Canada +China +Czech Republic +drop table t1, t2; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4); +create table t1 (a int, b int, key(a)); +insert into t1 select a,a from t0; +create table t2 (a int, b int, primary key(a)); +insert into t2 select * from t1; +Table t2, unlike table t1, should be displayed as pulled out +explain select * from t0 +where t0.a in ( select t1.a from t1,t2 where t2.a=t0.a and +t1.b=t2.b); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 5 100.00 Using where; Start temporary +1 SIMPLE t1 NULL ref a a 5 test.t0.a 1 100.00 Using join buffer (Batched Key Access) +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t0.a 1 20.00 Using where; End temporary; Using join buffer (Batched Key Access) +Warnings: +Note 1276 Field or reference 'test.t0.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a` from `test`.`t2` join `test`.`t0` semi join (`test`.`t1`) where ((`test`.`t1`.`a` = `test`.`t0`.`a`) and (`test`.`t2`.`a` = `test`.`t0`.`a`) and (`test`.`t2`.`b` = `test`.`t1`.`b`)) +update t1 set a=3, b=11 where a=4; +update t2 set b=11 where a=3; +select * from t0 where t0.a in (select t1.a from t1, t2 where t2.a=t0.a and t1.b=t2.b); +a +0 +1 +2 +3 +drop table t0, t1, t2; +CREATE TABLE t1 ( +id int(11) NOT NULL, +PRIMARY KEY (id)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t2 ( +id int(11) NOT NULL, +fid int(11) NOT NULL, +PRIMARY KEY (id)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t1 values(1); +insert into t2 values(1,7503),(2,1); +explain select count(*) +from t1 +where fid IN (select fid from t2 where (id between 7502 and 8420) order by fid ); +ERROR 42S22: Unknown column 'fid' in 'IN/ALL/ANY subquery' +drop table t1, t2; +create table t1 (a int, b int, key (a), key (b)); +insert into t1 values (2,4),(2,4),(2,4); +select t1.a from t1 +where +t1.a in (select 1 from t1 where t1.a in (select 1 from t1) group by t1.a); +a +drop table t1; +create table t1(a int,b int,key(a),key(b)); +insert into t1 values (1,1),(2,2),(3,3); +select 1 from t1 +where t1.a not in (select 1 from t1 +where t1.a in (select 1 from t1) +group by t1.b); +1 +1 +1 +drop table t1; +CREATE TABLE t1 +(EMPNUM CHAR(3) NOT NULL, +EMPNAME CHAR(20), +GRADE DECIMAL(4), +CITY CHAR(15)); +CREATE TABLE t2 +(PNUM CHAR(3) NOT NULL, +PNAME CHAR(20), +PTYPE CHAR(6), +BUDGET DECIMAL(9), +CITY CHAR(15)); +CREATE TABLE t3 +(EMPNUM CHAR(3) NOT NULL, +PNUM CHAR(3) NOT NULL, +HOURS DECIMAL(5)); +INSERT INTO t1 VALUES ('E1','Alice',12,'Deale'); +INSERT INTO t1 VALUES ('E2','Betty',10,'Vienna'); +INSERT INTO t1 VALUES ('E3','Carmen',13,'Vienna'); +INSERT INTO t1 VALUES ('E4','Don',12,'Deale'); +INSERT INTO t1 VALUES ('E5','Ed',13,'Akron'); +INSERT INTO t2 VALUES ('P1','MXSS','Design',10000,'Deale'); +INSERT INTO t2 VALUES ('P2','CALM','Code',30000,'Vienna'); +INSERT INTO t2 VALUES ('P3','SDP','Test',30000,'Tampa'); +INSERT INTO t2 VALUES ('P4','SDP','Design',20000,'Deale'); +INSERT INTO t2 VALUES ('P5','IRM','Test',10000,'Vienna'); +INSERT INTO t2 VALUES ('P6','PAYR','Design',50000,'Deale'); +INSERT INTO t3 VALUES ('E1','P1',40); +INSERT INTO t3 VALUES ('E1','P2',20); +INSERT INTO t3 VALUES ('E1','P3',80); +INSERT INTO t3 VALUES ('E1','P4',20); +INSERT INTO t3 VALUES ('E1','P5',12); +INSERT INTO t3 VALUES ('E1','P6',12); +INSERT INTO t3 VALUES ('E2','P1',40); +INSERT INTO t3 VALUES ('E2','P2',80); +INSERT INTO t3 VALUES ('E3','P2',20); +INSERT INTO t3 VALUES ('E4','P2',20); +INSERT INTO t3 VALUES ('E4','P4',40); +INSERT INTO t3 VALUES ('E4','P5',80); +SELECT * FROM t1; +EMPNUM EMPNAME GRADE CITY +E1 Alice 12 Deale +E2 Betty 10 Vienna +E3 Carmen 13 Vienna +E4 Don 12 Deale +E5 Ed 13 Akron +CREATE UNIQUE INDEX t1_IDX ON t1(EMPNUM); +SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN +(SELECT EMPNUM +FROM t3 +WHERE PNUM IN +(SELECT PNUM +FROM t2 +WHERE PTYPE = 'Design')); +EMPNAME +Alice +Betty +Don +DROP INDEX t1_IDX ON t1; +CREATE INDEX t1_IDX ON t1(EMPNUM); +SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN +(SELECT EMPNUM +FROM t3 +WHERE PNUM IN +(SELECT PNUM +FROM t2 +WHERE PTYPE = 'Design')); +EMPNAME +Alice +Betty +Don +DROP INDEX t1_IDX ON t1; +SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN +(SELECT EMPNUM +FROM t3 +WHERE PNUM IN +(SELECT PNUM +FROM t2 +WHERE PTYPE = 'Design')); +EMPNAME +Alice +Betty +Don +DROP TABLE t1, t2, t3; +CREATE TABLE t1 (f1 INT NOT NULL); +CREATE VIEW v1 (a) AS SELECT f1 IN (SELECT f1 FROM t1) FROM t1; +SELECT * FROM v1; +a +drop view v1; +drop table t1; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1(a int, b int); +insert into t1 values (0,0),(1,1),(2,2); +create table t2 as select * from t1; +create table t3 (pk int, a int, primary key(pk)); +insert into t3 select a,a from t0; +explain +select * from t1 left join t2 on (t2.a= t1.a and t2.a in (select pk from t3)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE t3 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using index +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` left join (`test`.`t3` join `test`.`t2`) on(((`test`.`t3`.`pk` = `test`.`t1`.`a`) and (`test`.`t2`.`a` = `test`.`t1`.`a`))) where true +drop table t0, t1, t2, t3; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (a int) as select A.a + 10 *(B.a + 10*C.a) as a from t0 A, t0 B, t0 C; +create table t2 (id int, a int, primary key(id), key(a)) charset utf8mb4 as select a as id, a as a from t1; +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `id` int NOT NULL, + `a` int DEFAULT NULL, + PRIMARY KEY (`id`), + KEY `a` (`a`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +set @a=0; +create table t3 as select * from t2 limit 0; +insert into t3 select @a:=@a+1, t2.a from t2, t0; +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +insert into t3 select @a:=@a+1, t2.a from t2, t0; +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +insert into t3 select @a:=@a+1, t2.a from t2, t0; +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +alter table t3 add primary key(id), add 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); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index a a 5 NULL 1000 100.00 Using where; Using index +1 SIMPLE t3 NULL ref a a 5 test.t2.a 30 100.00 Using index; FirstMatch(t2) +Warnings: +Note 1003 /* select#1 */ select count(`test`.`t2`.`a`) AS `count(a)` from `test`.`t2` semi join (`test`.`t3`) where (`test`.`t3`.`a` = `test`.`t2`.`a`) +select count(a) from t2 where a in ( SELECT a FROM t3); +count(a) +1000 +drop table t0,t1,t2,t3; +# +# Bug#33062: subquery in stored routine cause crash +# +CREATE TABLE t1(a INT); +CREATE TABLE t2(c INT); +CREATE PROCEDURE p1(v1 int) +BEGIN +SELECT 1 FROM t1 WHERE a = v1 AND a IN (SELECT c FROM t2); +END +// +CREATE PROCEDURE p2(v1 int) +BEGIN +SELECT 1 FROM t1 WHERE a IN (SELECT c FROM t2); +END +// +CREATE PROCEDURE p3(v1 int) +BEGIN +SELECT 1 +FROM +t1 t01,t1 t02,t1 t03,t1 t04,t1 t05,t1 t06,t1 t07,t1 t08, +t1 t09,t1 t10,t1 t11,t1 t12,t1 t13,t1 t14,t1 t15,t1 t16, +t1 t17,t1 t18,t1 t19,t1 t20,t1 t21,t1 t22,t1 t23,t1 t24, +t1 t25,t1 t26,t1 t27,t1 t28,t1 t29,t1 t30,t1 t31,t1 t32, +t1 t33,t1 t34,t1 t35,t1 t36,t1 t37,t1 t38,t1 t39,t1 t40, +t1 t41,t1 t42,t1 t43,t1 t44,t1 t45,t1 t46,t1 t47,t1 t48, +t1 t49,t1 t50,t1 t51,t1 t52,t1 t53,t1 t54,t1 t55,t1 t56, +t1 t57,t1 t58,t1 t59,t1 t60 +WHERE t01.a IN (SELECT c FROM t2); +END +// +CREATE PROCEDURE p4(v1 int) +BEGIN +SELECT 1 +FROM +t1 t01,t1 t02,t1 t03,t1 t04,t1 t05,t1 t06,t1 t07,t1 t08, +t1 t09,t1 t10,t1 t11,t1 t12,t1 t13,t1 t14,t1 t15,t1 t16, +t1 t17,t1 t18,t1 t19,t1 t20,t1 t21,t1 t22,t1 t23,t1 t24, +t1 t25,t1 t26,t1 t27,t1 t28,t1 t29,t1 t30,t1 t31,t1 t32, +t1 t33,t1 t34,t1 t35,t1 t36,t1 t37,t1 t38,t1 t39,t1 t40, +t1 t41,t1 t42,t1 t43,t1 t44,t1 t45,t1 t46,t1 t47,t1 t48, +t1 t49,t1 t50,t1 t51,t1 t52,t1 t53,t1 t54,t1 t55,t1 t56, +t1 t57,t1 t58,t1 t59,t1 t60 +WHERE t01.a = v1 AND t01.a IN (SELECT c FROM t2); +END +// +CALL p1(1); +1 +CALL p2(1); +1 +CALL p3(1); +1 +CALL p4(1); +1 +DROP TABLE t1, t2; +DROP PROCEDURE p1; +DROP PROCEDURE p2; +DROP PROCEDURE p3; +DROP PROCEDURE p4; +# +# Bug#48213 Materialized subselect crashes if using GEOMETRY type +# +CREATE TABLE t1 ( +pk int, +a varchar(1), +b varchar(4), +c tinyblob, +d blob, +e mediumblob, +f longblob, +g tinytext, +h text, +i mediumtext, +j longtext, +k geometry, +PRIMARY KEY (pk) +) charset utf8mb4; +INSERT INTO t1 VALUES (1,'o','ffff','ffff','ffoo','ffff','ffff','ffff','ffff','ffff','ffff',ST_GeomFromText('POLYGON((0 0, 0 2, 2 2, 2 0, 0 0))')), (2,'f','ffff','ffff','ffff', 'ffff','ffff','ffff','ffff','ffff','ffff',ST_GeomFromText('POLYGON((0 0, 0 2, 2 2, 2 0, 0 0))')); +CREATE TABLE t2 LIKE t1; +INSERT INTO t2 VALUES (1,'i','iiii','iiii','iiii','iiii','ffff','ffff','ffff','ffff','ffff',ST_GeomFromText('POLYGON((0 0, 0 2, 2 2, 2 0, 0 0))')), (2,'f','ffff','ffff','ffff','ffff','ffff','ffff','ffff','ffff','ffff',ST_GeomFromText('POLYGON((0 0, 0 2, 2 2, 2 0, 0 0))')); +EXPLAIN SELECT pk FROM t1 WHERE (a, b) IN (SELECT a, b FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using index condition; Using where; Using MRR; FirstMatch(t1); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ 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); +pk +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, c) IN (SELECT b, c FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using index condition; Using where; Using MRR; FirstMatch(t1); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`c` = `test`.`t1`.`c`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, c) IN (SELECT b, c FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, d) IN (SELECT b, d FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using index condition; Using where; Using MRR; FirstMatch(t1); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`d` = `test`.`t1`.`d`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, d) IN (SELECT b, d FROM t2 WHERE pk > 0); +pk +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, e) IN (SELECT b, e FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using index condition; Using where; Using MRR; FirstMatch(t1); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`e` = `test`.`t1`.`e`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, e) IN (SELECT b, e FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, f) IN (SELECT b, f FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using index condition; Using where; Using MRR; FirstMatch(t1); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`f` = `test`.`t1`.`f`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, f) IN (SELECT b, f FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, g) IN (SELECT b, g FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using index condition; Using where; Using MRR; FirstMatch(t1); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`g` = `test`.`t1`.`g`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, g) IN (SELECT b, g FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, h) IN (SELECT b, h FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using index condition; Using where; Using MRR; FirstMatch(t1); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`h` = `test`.`t1`.`h`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, h) IN (SELECT b, h FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, i) IN (SELECT b, i FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using index condition; Using where; Using MRR; FirstMatch(t1); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`i` = `test`.`t1`.`i`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, i) IN (SELECT b, i FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, j) IN (SELECT b, j FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using index condition; Using where; Using MRR; FirstMatch(t1); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`j` = `test`.`t1`.`j`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, j) IN (SELECT b, j FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, k) IN (SELECT b, k FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using index condition; Using where; Using MRR; FirstMatch(t1); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`k` = `test`.`t1`.`k`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, k) IN (SELECT b, k FROM t2 WHERE pk > 0); +pk +1 +2 +DROP TABLE t1, t2; +# End of Bug#48213 +# +# BUG#53060: LooseScan semijoin strategy does not return all rows +# +CREATE TABLE t1 (i INTEGER); +INSERT INTO t1 VALUES (1), (2), (3), (4), (5); +CREATE TABLE t2 (i INTEGER, j INTEGER, KEY k(i, j)); +INSERT INTO t2 VALUES (1, 0), (1, 1), (2, 0), (2, 1); +EXPLAIN +SELECT * FROM t1 WHERE (i) IN (SELECT i FROM t2 where j > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index k k 10 NULL 4 33.33 Using where; Using index; LooseScan +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 20.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`i` = `test`.`t2`.`i`) and (`test`.`t2`.`j` > 0)) +SELECT * FROM t1 WHERE (i) IN (SELECT i FROM t2 where j > 0); +i +1 +2 +DROP TABLE t1, t2; +# End of BUG#53060 +# +# Bug#53305 "Duplicate weedout + join buffer (join cache --level=7,8) loses rows" +# +create table t1 (uid int, fid int, index(uid)); +insert into t1 values +(1,1), (1,2), (1,3), (1,4), +(2,5), (2,6), (2,7), (2,8), +(3,1), (3,2), (3,9); +create table t2 (uid int primary key, name varchar(128), index(name)); +insert into t2 values +(1, "A"), (2, "B"), (3, "C"), (4, "D"), (5, "E"), +(6, "F"), (7, "G"), (8, "H"), (9, "I"); +create table t3 (uid int, fid int, index(uid)); +insert into t3 values +(1,1), (1,2), (1,3),(1,4), +(2,5), (2,6), (2,7), (2,8), +(3,1), (3,2), (3,9); +create table t4 (uid int primary key, name varchar(128), index(name)); +insert into t4 values +(1, "A"), (2, "B"), (3, "C"), (4, "D"), (5, "E"), +(6, "F"), (7, "G"), (8, "H"), (9, "I"); +explain select name from t2, t1 +where t1.uid in (select t4.uid from t4, t3 where t3.uid=1 and t4.uid=t3.fid) +and t2.uid=t1.fid; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ref uid uid 5 const 4 100.00 Using where; Start temporary +1 SIMPLE t4 NULL eq_ref PRIMARY PRIMARY 4 test.t3.fid 1 100.00 Using index +1 SIMPLE t1 NULL ref uid uid 5 test.t3.fid 2 100.00 Using where; Using join buffer (Batched Key Access) +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.fid 1 100.00 End temporary; Using join buffer (Batched Key Access) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`name` AS `name` from `test`.`t4` join `test`.`t2` join `test`.`t1` semi join (`test`.`t3`) where ((`test`.`t4`.`uid` = `test`.`t3`.`fid`) and (`test`.`t1`.`uid` = `test`.`t3`.`fid`) and (`test`.`t3`.`uid` = 1) and (`test`.`t2`.`uid` = `test`.`t1`.`fid`)) +select name from t2, t1 +where t1.uid in (select t4.uid from t4, t3 where t3.uid=1 and t4.uid=t3.fid) +and t2.uid=t1.fid; +name +A +A +B +B +C +D +E +F +G +H +I +drop table t1,t2,t3,t4; +# +# Bug#43768 Prepared query with nested subqueries core dump on second execution +# +CREATE TABLE t1 ( +id INT PRIMARY KEY, +partner_id VARCHAR(35) +) charset utf8mb4; +INSERT INTO t1 VALUES +(1, 'partner1'), (2, 'partner2'), +(3, 'partner3'), (4, 'partner4'); +CREATE TABLE t2 ( +id INT NOT NULL, +t1_line_id INT, +article_id VARCHAR(20), +PRIMARY KEY(id, t1_line_id) +) charset utf8mb4; +INSERT INTO t2 VALUES +(1, 1, 'sup'), (2, 1, 'sup'), +(2, 2, 'sup'), (2, 3, 'sup'), +(2, 4, 'imp'), (3, 1, 'sup'), +(4, 1, 'sup'); +CREATE TABLE t3 ( +user_id VARCHAR(50), +article_id VARCHAR(20) NOT NULL, +PRIMARY KEY(user_id) +) charset utf8mb4; +INSERT INTO t3 VALUES('nicke', 'imp'); +EXPLAIN +SELECT t1.partner_id +FROM t1 +WHERE t1.id IN ( +SELECT t2.id +FROM t2 +WHERE article_id IN ( +SELECT article_id FROM t3 +WHERE user_id = 'nicke' + ) +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL system PRIMARY NULL NULL NULL 1 100.00 NULL +1 SIMPLE t1 NULL ALL PRIMARY NULL NULL NULL 4 100.00 NULL +1 SIMPLE t2 NULL ref PRIMARY PRIMARY 4 test.t1.id 1 14.29 Using where; FirstMatch(t1); Using join buffer (Batched Key Access) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`partner_id` AS `partner_id` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`id` = `test`.`t1`.`id`) and (`test`.`t2`.`article_id` = 'imp')) +SELECT t1.partner_id +FROM t1 +WHERE t1.id IN ( +SELECT t2.id +FROM t2 +WHERE article_id IN ( +SELECT article_id FROM t3 +WHERE user_id = 'nicke' + ) +); +partner_id +partner2 +PREPARE stmt FROM +'EXPLAIN SELECT t1.partner_id +FROM t1 +WHERE t1.id IN ( + SELECT t2.id + FROM t2 + WHERE article_id IN ( + SELECT article_id FROM t3 + WHERE user_id = \'nicke\' + ) + )'; +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL system PRIMARY NULL NULL NULL 1 100.00 NULL +1 SIMPLE t1 NULL ALL PRIMARY NULL NULL NULL 4 100.00 NULL +1 SIMPLE t2 NULL ref PRIMARY PRIMARY 4 test.t1.id 1 14.29 Using where; FirstMatch(t1); Using join buffer (Batched Key Access) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`partner_id` AS `partner_id` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`id` = `test`.`t1`.`id`) and (`test`.`t2`.`article_id` = 'imp')) + +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL system PRIMARY NULL NULL NULL 1 100.00 NULL +1 SIMPLE t1 NULL ALL PRIMARY NULL NULL NULL 4 100.00 NULL +1 SIMPLE t2 NULL ref PRIMARY PRIMARY 4 test.t1.id 1 14.29 Using where; FirstMatch(t1); Using join buffer (Batched Key Access) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`partner_id` AS `partner_id` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`id` = `test`.`t1`.`id`) and (`test`.`t2`.`article_id` = 'imp')) +PREPARE stmt FROM +'SELECT t1.partner_id +FROM t1 +WHERE t1.id IN ( + SELECT t2.id + FROM t2 + WHERE article_id IN ( + SELECT article_id FROM t3 + WHERE user_id = \'nicke\' + ) + )'; +EXECUTE stmt; +partner_id +partner2 + +EXECUTE stmt; +partner_id +partner2 +DROP TABLE t1,t2,t3; +# End of Bug#43768 +# +# Bug#53058 - semijoin execution of subquery with outerjoin yields wrong result +# +CREATE TABLE t1 (i INTEGER); +CREATE TABLE t2 (i INTEGER); +CREATE TABLE t3 (i INTEGER); +INSERT INTO t1 VALUES (1), (2); +INSERT INTO t2 VALUES (6); +INSERT INTO t3 VALUES (1), (2); +explain SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t3 LEFT JOIN t2 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t3 LEFT JOIN t2 ON t2.i=t3.i); +i +1 +2 +drop table t1,t2,t3; +# +# BUG#49453: re-execution of prepared statement with view +# and semijoin crashes +# +CREATE TABLE t1 (city VARCHAR(50), country_id INT); +CREATE TABLE t2 (country_id INT, country VARCHAR(50)); +INSERT INTO t1 VALUES +('Batna',2),('Bchar',2),('Skikda',2),('Tafuna',3),('Algeria',2) ; +INSERT INTO t2 VALUES (2,'Algeria'),(2,'AlgeriaDup'),(3,'XAmerican Samoa'); +CREATE VIEW v1 AS +SELECT country_id as vf_country_id +FROM t2 +WHERE LEFT(country,1) = "A"; +PREPARE stmt FROM " +SELECT city, country_id +FROM t1 +WHERE country_id IN (SELECT vf_country_id FROM v1); +"; + +EXECUTE stmt; +city country_id +Algeria 2 +Batna 2 +Bchar 2 +Skikda 2 + +EXECUTE stmt; +city country_id +Algeria 2 +Batna 2 +Bchar 2 +Skikda 2 +DROP TABLE t1,t2; +DROP VIEW v1; +# +# Bug#54437 Extra rows with LEFT JOIN + semijoin (firstmatch +# and duplicates weedout) +# +create table t1 (a int); +create table t2 (a int); +create table t3 (a int); +insert into t1 values(1),(1); +insert into t2 values(1),(1),(1),(1); +insert into t3 values(2),(2); +explain select * from t1 where t1.a in (select t2.a from t2 left join t3 on t2.a=t3.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t2` left join `test`.`t3` on((`test`.`t2`.`a` = `test`.`t3`.`a`))) where (`test`.`t2`.`a` = `test`.`t1`.`a`) +select * from t1 where t1.a in (select t2.a from t2 left join t3 on t2.a=t3.a); +a +1 +1 +drop table t1,t2,t3; +# +# Bug#55955: crash in MEMORY engine with IN(LEFT JOIN (JOIN)) +# +CREATE TABLE t1 (a INT); +CREATE TABLE t2 (a INT); +CREATE TABLE t3 (a INT); +INSERT INTO t1 VALUES(1),(1); +INSERT INTO t2 VALUES(1),(1); +INSERT INTO t3 VALUES(2),(2); +explain SELECT * FROM t1 +WHERE t1.a IN (SELECT t2.a +FROM t2 LEFT JOIN (t2 AS t2inner, t3) ON t2.a=t3.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE NULL eq_ref 5 test.t1.a 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t2inner NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t2` left join (`test`.`t2` `t2inner` join `test`.`t3`) on((`test`.`t2`.`a` = `test`.`t3`.`a`))) where (``.`a` = `test`.`t1`.`a`) +SELECT * FROM t1 +WHERE t1.a IN (SELECT t2.a +FROM t2 LEFT JOIN (t2 AS t2inner, t3) ON t2.a=t3.a); +a +1 +1 +DROP TABLE t1,t2,t3; +# +# BUG#52329 - Wrong result: subquery materialization, IN, +# non-null field followed by nullable +# +CREATE TABLE t1 (a1 CHAR(8) NOT NULL, a2 char(8) NOT NULL); +CREATE TABLE t2a (b1 char(8), b2 char(8)); +CREATE TABLE t2b (b1 CHAR(8), b2 char(8) NOT NULL); +CREATE TABLE t2c (b1 CHAR(8) NOT NULL, b2 char(8)); +INSERT INTO t1 VALUES ('1 - 12', '2 - 22'); +INSERT INTO t2a VALUES ('1 - 11', '2 - 21'), +('1 - 11', '2 - 21'), +('1 - 12', '2 - 22'), +('1 - 12', '2 - 22'), +('1 - 13', '2 - 23'); +INSERT INTO t2b SELECT * FROM t2a; +INSERT INTO t2c SELECT * FROM t2a; +SELECT * FROM t1 +WHERE (a1, a2) IN ( +SELECT b1, b2 FROM t2c WHERE b1 > '0' GROUP BY b1, b2); +a1 a2 +1 - 12 2 - 22 +SELECT * FROM t1 +WHERE (a1, a2) IN ( +SELECT b1, b2 FROM t2a WHERE b1 > '0'); +a1 a2 +1 - 12 2 - 22 +SELECT * FROM t1 +WHERE (a1, a2) IN ( +SELECT b1, b2 FROM t2b WHERE b1 > '0'); +a1 a2 +1 - 12 2 - 22 +SELECT * FROM t1 +WHERE (a1, a2) IN ( +SELECT b1, b2 FROM t2c WHERE b1 > '0'); +a1 a2 +1 - 12 2 - 22 +DROP TABLE t1,t2a,t2b,t2c; +# End BUG#52329 +# +# Bug#45174: Incorrectly applied equality propagation caused wrong +# result on a query with a materialized semi-join. +# +CREATE TABLE t1 ( +varchar_nokey varchar(1) NOT NULL +) charset utf8mb4; +INSERT INTO t1 VALUES +('v'), ('u'), ('n'), ('l'), ('h'), ('u'), ('n'), ('j'), ('k'), +('e'), ('i'), ('u'), ('n'), ('b'), ('x'), (''), ('q'), ('u'); +CREATE TABLE t2 ( +pk int NOT NULL, +varchar_key varchar(1) NOT NULL, +varchar_nokey varchar(1) NOT NULL, +PRIMARY KEY(pk), +KEY varchar_key(varchar_key) +) charset utf8mb4; +INSERT INTO t2 VALUES +(11,'m','m'), (12,'j','j'), (13,'z','z'), (14,'a','a'), (15,'',''), +(16,'e','e'), (17,'t','t'), (19,'b','b'), (20,'w','w'), (21,'m','m'), +(23,'',''), (24,'w','w'), (26,'e','e'), (27,'e','e'), (28,'p','p'); +SELECT varchar_nokey +FROM t1 +WHERE (varchar_nokey, varchar_nokey) IN (SELECT varchar_key, varchar_nokey +FROM t2 +WHERE varchar_nokey < 'n' XOR pk); +varchar_nokey +explain SELECT varchar_nokey +FROM t1 +WHERE (varchar_nokey, varchar_nokey) IN (SELECT varchar_key, varchar_nokey +FROM t2 +WHERE varchar_nokey < 'n' XOR pk); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 18 100.00 NULL +1 SIMPLE NULL eq_ref 12 test.t1.varchar_nokey,test.t1.varchar_nokey 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL varchar_key NULL NULL NULL 15 63.34 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`varchar_nokey` AS `varchar_nokey` from `test`.`t1` semi join (`test`.`t2`) where ((``.`varchar_key` = `test`.`t1`.`varchar_nokey`) and (``.`varchar_nokey` = `test`.`t1`.`varchar_nokey`) and (`test`.`t2`.`varchar_nokey` = `test`.`t2`.`varchar_key`) and ((`test`.`t2`.`varchar_nokey` < 'n') xor (0 <> `test`.`t2`.`pk`))) +DROP TABLE t1, t2; +# End of the test for bug#45174. +# +# Bug#50019: Wrong result for IN-query with materialization +# +CREATE TABLE t1(i INT); +INSERT INTO t1 VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10); +CREATE TABLE t2(i INT); +INSERT INTO t2 VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10); +CREATE TABLE t3(i INT); +INSERT INTO t3 VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10); +SELECT * FROM t1 WHERE t1.i IN (SELECT t2.i +FROM t2 JOIN t3 +WHERE t2.i + t3.i = 5); +i +1 +2 +3 +4 +explain SELECT * FROM t1 WHERE t1.i IN (SELECT t2.i +FROM t2 JOIN t3 +WHERE t2.i + t3.i = 5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 100.00 Using where +1 SIMPLE NULL eq_ref 5 test.t1.i 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 10 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 10 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = `test`.`t1`.`i`) and ((`test`.`t2`.`i` + `test`.`t3`.`i`) = 5)) +DROP TABLE t1,t2,t3; +# End of the test for bug#50019. +# +# Bug#52068: Optimizer generates invalid semijoin materialization plan +# +CREATE TABLE ot1(a INTEGER); +INSERT INTO ot1 VALUES(5), (8); +CREATE TABLE it2(a INTEGER); +INSERT INTO it2 VALUES(9), (5), (1), (8); +CREATE TABLE it3(a INTEGER); +INSERT INTO it3 VALUES(7), (1), (0), (5), (1), (4); +CREATE TABLE ot4(a INTEGER); +INSERT INTO ot4 VALUES(1), (3), (5), (7), (9), (7), (3), (1); +SELECT * FROM ot1,ot4 +WHERE (ot1.a,ot4.a) IN (SELECT it2.a,it3.a +FROM it2,it3); +a a +5 1 +5 1 +5 5 +5 7 +5 7 +8 1 +8 1 +8 5 +8 7 +8 7 +explain SELECT * FROM ot1,ot4 +WHERE (ot1.a,ot4.a) IN (SELECT it2.a,it3.a +FROM it2,it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE it2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; Using join buffer (hash join) +1 SIMPLE it3 NULL ALL NULL NULL NULL NULL 6 100.00 Using join buffer (hash join) +1 SIMPLE ot4 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot4`.`a` AS `a` from `test`.`ot1` join `test`.`ot4` semi join (`test`.`it2` join `test`.`it3`) where ((`test`.`ot4`.`a` = `test`.`it3`.`a`) and (`test`.`it2`.`a` = `test`.`ot1`.`a`)) +DROP TABLE IF EXISTS ot1, ot4, it2, it3; +# End of the test for bug#52068. +# +# Bug#57623: subquery within before insert trigger causes crash (sj=on) +# +CREATE TABLE ot1(a INT); +CREATE TABLE ot2(a INT); +CREATE TABLE ot3(a INT); +CREATE TABLE it1(a INT); +INSERT INTO ot1 VALUES(0),(1),(2),(3),(4),(5),(6),(7); +INSERT INTO ot2 VALUES(0),(2),(4),(6); +INSERT INTO ot3 VALUES(0),(3),(6); +INSERT INTO it1 VALUES(0),(1),(2),(3),(4),(5),(6),(7); +explain SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 on ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a from it1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +1 SIMPLE NULL eq_ref 5 test.ot1.a 1 100.00 NULL +1 SIMPLE ot3 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +2 MATERIALIZED it1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a`,`test`.`ot3`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` join `test`.`ot3` semi join (`test`.`it1`)) on(((``.`a` = `test`.`ot1`.`a`) and (`test`.`ot3`.`a` = `test`.`ot1`.`a`) and (`test`.`ot2`.`a` = `test`.`ot1`.`a`))) where true +SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 on ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a from it1); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +prepare s from 'SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 on ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a from it1)'; +execute s; +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +execute s; +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +deallocate prepare s; +DROP TABLE ot1, ot2, ot3, it1; +# End of the test for bug#57623. +# +# Bug#11766739: Crash in tmp_table_param::init() with semijoin=on +# +CREATE TABLE t1 (f1 INTEGER) ENGINE=MyISAM; +CREATE TABLE t2 (f1 INTEGER, f2 INTEGER) ENGINE=MyISAM; +INSERT INTO t1 VALUES (1); +INSERT INTO t2 VALUES (1,1), (2,1); +EXPLAIN SELECT * FROM t2 +WHERE f2 IN (SELECT t1.f1 +FROM t1 LEFT OUTER JOIN (t2 AS b1 JOIN t2 AS b2 ON TRUE) ON TRUE); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE b1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +1 SIMPLE b2 NULL ALL NULL NULL NULL NULL 2 100.00 End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`f1` AS `f1`,`test`.`t2`.`f2` AS `f2` from `test`.`t2` semi join (`test`.`t1` left join (`test`.`t2` `b1` join `test`.`t2` `b2`) on((true))) where (`test`.`t2`.`f2` = `test`.`t1`.`f1`) +SELECT * FROM t2 +WHERE f2 IN (SELECT t1.f1 +FROM t1 LEFT OUTER JOIN (t2 AS b1 JOIN t2 AS b2 ON TRUE) ON TRUE); +f1 f2 +1 1 +2 1 +DROP TABLE t1, t2; +# End of the test for bug#11766739. +# +# Bug#11766642: crash in Item_field::register_field_in_read_map with view +# +CREATE TABLE t1(a INT); +CREATE VIEW v1 AS SELECT a FROM t1; +INSERT INTO t1 VALUES (0),(1),(2); +SELECT a FROM t1 WHERE a IN +(SELECT a XOR a FROM v1) +ORDER BY a; +a +0 +DROP TABLE t1; +DROP VIEW v1; +# +# Bug#12546542 MISSING ROW WHEN USING OPTIMIZER_JOIN_CACHE_LEVEL>=3 +# +CREATE TABLE t1 ( +f2 varchar(1024) +); +INSERT INTO t1 VALUES ('v'),('we'); +CREATE TABLE t2 ( +col_varchar_1024_utf8 varchar(1024) CHARACTER SET utf8 DEFAULT NULL, +col_int_key int, +col_int int +); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t2 VALUES ('we',4,NULL),('v',1305673728,6); +CREATE TABLE t3 ( +col_int_key int, +col_int int +); +INSERT INTO t3 VALUES (4,4); +SELECT * +FROM t1 +WHERE f2 IN (SELECT a1.col_varchar_1024_utf8 AS f2 +FROM t2 AS a1 LEFT JOIN t3 AS a2 +ON a1.col_int_key = a2.col_int_key +WHERE a1.col_int BETWEEN 1 AND 10 OR a2.col_int IS NOT NULL); +f2 +v +we +DROP TABLE t1,t2,t3; +# +# BUG#12616344 - JCL: DIFFERENT RESULT SET AND DIFFERENT AMOUNT +# OF ROWS WHEN JCL>=3 +# +CREATE TABLE t1 (col_int_nokey int, col_int_key int, col_varchar_key varchar(1)); +INSERT INTO t1 VALUES (0,4,'c'),(1,6,'u'); +CREATE TABLE t2 (pk int, col_int_nokey int, col_varchar_nokey varchar(1)); +INSERT INTO t2 VALUES (1,4,'b'),(94,6,'u'); +CREATE TABLE t3 (pk int, col_int_nokey int, col_varchar_key varchar(1)); +INSERT INTO t3 VALUES (1,4,'j'),(2,6,'v'); +SELECT table2.col_int_key +from t3 as table1 join t1 as table2 on table2.col_int_nokey +where table1.col_int_nokey in +( +select subquery2_t2.col_int_nokey +from t3 as subquery2_t1 +right join +t2 as subquery2_t2 +join t1 as subquery2_t3 +on subquery2_t3.col_int_key = subquery2_t2.col_int_nokey +on subquery2_t3.col_varchar_key = subquery2_t2.col_varchar_nokey +where subquery2_t1.col_varchar_key != table1.col_varchar_key +or subquery2_t2.pk <= table1.pk +); +col_int_key +6 +6 +DROP TABLE t1,t2,t3; +# +# Bug#12608157: ASSERT IN FIELD_LONG::VAL_INT WHEN USING MEMORY ENGINE +# +CREATE TABLE t1 (i1 int); +INSERT INTO t1 VALUES (1); +CREATE TABLE t2 (i1 int, i2 int) ENGINE=memory; +INSERT INTO t2 VALUES (1, 2),(7, 3); +SELECT GRANDPARENT1.i1 +FROM t2 AS GRANDPARENT1 +WHERE GRANDPARENT1.i2 +IN ( SELECT PARENT1.i2 +FROM t2 AS PARENT1 JOIN t1 AS PARENT2 ON (PARENT1.i1 = PARENT2.i1) +WHERE +GRANDPARENT1.i1 IN ( SELECT CHILD1.i1 FROM t2 AS CHILD1 ) +ORDER BY PARENT1.i1) +ORDER BY GRANDPARENT1.i2 ; +i1 +1 +DROP TABLE t1,t2; +# +# Bug#12640083: Same query executed as WHERE subquery gives different +# results on IN() compare +# +CREATE TABLE t1 ( +pk int NOT NULL, +col_varchar_1024_utf8_key varchar(1024) CHARACTER SET utf8 DEFAULT NULL, +col_varchar_10_latin1_key varchar(10) DEFAULT NULL, +PRIMARY KEY (pk), +KEY col_varchar_1024_utf8_key(col_varchar_1024_utf8_key(333)), +KEY col_varchar_10_latin1_key(col_varchar_10_latin1_key) +) charset utf8mb4; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES +(1, 'a', 'a'), +(2, 'ab', 'ab'), +(3, 'abc', 'abc'), +(4, 'abcd', 'abcd'); +CREATE TABLE t2 ( +pk int NOT NULL AUTO_INCREMENT, +PRIMARY KEY (pk) +) charset utf8mb4 ENGINE=Innodb; +CREATE TABLE t3 charset utf8mb4 +SELECT alias1.col_varchar_10_latin1_key +FROM t1 AS alias1 +LEFT JOIN t1 AS alias2 +JOIN t2 AS alias3 +ON alias2.col_varchar_10_latin1_key +ON alias1.col_varchar_1024_utf8_key +WHERE alias1.pk AND alias1.pk < 3 OR alias1.pk AND alias3.pk; +EXPLAIN SELECT * +FROM t3 +WHERE col_varchar_10_latin1_key IN ( +SELECT alias1.col_varchar_10_latin1_key +FROM t1 AS alias1 +LEFT JOIN t1 AS alias2 +JOIN t2 AS alias3 +ON alias2.col_varchar_10_latin1_key +ON alias1.col_varchar_1024_utf8_key +WHERE alias1.pk AND alias1.pk < 3 OR alias1.pk AND alias3.pk); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE alias1 NULL ref PRIMARY,col_varchar_10_latin1_key col_varchar_10_latin1_key 43 test.t3.col_varchar_10_latin1_key 2 100.00 Using where +1 SIMPLE alias3 NULL index NULL PRIMARY 4 NULL 1 100.00 Using where; Using index +1 SIMPLE alias2 NULL index NULL col_varchar_10_latin1_key 43 NULL 4 100.00 Using where; Using index; FirstMatch(t3) +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`col_varchar_10_latin1_key` AS `col_varchar_10_latin1_key` from `test`.`t3` semi join (`test`.`t1` `alias1` left join (`test`.`t1` `alias2` join `test`.`t2` `alias3`) on(((0 <> `test`.`alias1`.`col_varchar_1024_utf8_key`) and (0 <> `test`.`alias2`.`col_varchar_10_latin1_key`)))) where ((`test`.`alias1`.`col_varchar_10_latin1_key` = `test`.`t3`.`col_varchar_10_latin1_key`) and (((0 <> `test`.`alias1`.`pk`) and (`test`.`alias1`.`pk` < 3)) or ((0 <> `test`.`alias1`.`pk`) and (0 <> `test`.`alias3`.`pk`)))) +SELECT * +FROM t3 +WHERE col_varchar_10_latin1_key IN ( +SELECT alias1.col_varchar_10_latin1_key +FROM t1 AS alias1 +LEFT JOIN t1 AS alias2 +JOIN t2 AS alias3 +ON alias2.col_varchar_10_latin1_key +ON alias1.col_varchar_1024_utf8_key +WHERE alias1.pk AND alias1.pk < 3 OR alias1.pk AND alias3.pk); +col_varchar_10_latin1_key +a +ab +DROP TABLE t1, t2, t3; +# End of the test for bug#12640083. +# +# Bug#12603200 - Assert in QUICK_INDEX_MERGE_SELECT::need_sorted_output +# +CREATE TABLE t1 ( +pk int NOT NULL, +col_int_key int NOT NULL, +col_varchar_nokey varchar(1) NOT NULL, +col_varchar_key varchar(1) NOT NULL, +PRIMARY KEY(pk), +KEY col_int_key(col_int_key), +KEY col_varchar_key(col_varchar_key, col_int_key) +) charset utf8mb4 engine=innodb; +INSERT INTO t1 VALUES +(1,7,'a','a'), +(2,0,'v','v'), +(3,9,'c','c'), +(4,3,'m','m'), +(5,2,'a','a'), +(6,1,'d','d'), +(7,8,'y','y'), +(8,6,'t','t'), +(11,7,'a','x'), +(12,0,'v','v'), +(13,9,'c','c'), +(14,3,'m','m'), +(15,2,'a','x'), +(16,1,'d','d'), +(17,8,'y','y'), +(18,6,'t','u'), +(19,6,'t','u'); +CREATE TABLE t2 ( +pk int NOT NULL, +col_int_key int NOT NULL, +col_varchar_key varchar(1) NOT NULL, +PRIMARY KEY(pk), +KEY col_varchar_key(col_varchar_key, col_int_key) +) charset utf8mb4 engine=innodb; +INSERT INTO t2(pk,col_int_key,col_varchar_key) VALUES +(8,7,'c'), +(11,4,'l'), +(12,7,'b'), +(13,0,'c'), +(14,2,'i'), +(15,9,'h'), +(16,4,'q'), +(17,1,'m'), +(18,9,'b'), +(19,2,'e'), +(20,1,'c'), +(21,7,'z'), +(22,4,'l'), +(23,7,'z'), +(24,0,'c'), +(25,2,'i'), +(26,9,'h'), +(27,4,'q'), +(28,0,'a'), +(29,1,'d'); +EXPLAIN SELECT outr.col_varchar_key AS x, outr.pk AS y +FROM t1 AS outr +WHERE outr.col_varchar_key IN (SELECT innr.col_varchar_key +FROM t2 AS innr +WHERE innr.col_varchar_key = 'a' OR innr.pk = 8) +AND outr.col_varchar_nokey < 't' +ORDER BY outr.col_varchar_key, outr.pk; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE innr NULL index_merge PRIMARY,col_varchar_key col_varchar_key,PRIMARY 6,4 NULL 2 100.00 Using sort_union(col_varchar_key,PRIMARY); Using where; Using temporary; Using filesort; Start temporary +1 SIMPLE outr NULL ref col_varchar_key col_varchar_key 6 test.innr.col_varchar_key 1 33.33 Using where; End temporary; Using join buffer (Batched Key Access) +Warnings: +Note 1003 /* select#1 */ select `test`.`outr`.`col_varchar_key` AS `x`,`test`.`outr`.`pk` AS `y` from `test`.`t1` `outr` semi join (`test`.`t2` `innr`) where ((`test`.`outr`.`col_varchar_key` = `test`.`innr`.`col_varchar_key`) and (`test`.`outr`.`col_varchar_nokey` < 't') and ((`test`.`innr`.`col_varchar_key` = 'a') or (`test`.`innr`.`pk` = 8))) order by `test`.`outr`.`col_varchar_key`,`test`.`outr`.`pk` +SELECT outr.col_varchar_key AS x, outr.pk AS y +FROM t1 AS outr +WHERE outr.col_varchar_key IN (SELECT innr.col_varchar_key +FROM t2 AS innr +WHERE innr.col_varchar_key = 'a' OR innr.pk = 8) +AND outr.col_varchar_nokey < 't' +ORDER BY outr.col_varchar_key, outr.pk; +x y +a 1 +a 5 +c 3 +c 13 +DROP TABLE t1, t2; +# End of bug#12603200 +# +# Bug#12603183: Segfault in hp_movelink +# +CREATE TABLE t1 ( +col_varchar_key varchar(1) , +col_varchar_nokey varchar(1) , +KEY col_varchar_key(col_varchar_key) +) charset latin1; +INSERT INTO t1 VALUES +('i','i'), +('h','h'), +('q','q'), +('a','a'), +('v','v'), +('u','u'), +('s','s'), +('y','y'), +('z','z'), +('h','h'), +('p','p'), +('e','e'), +('i','i'), +('y','y'), +('w','w'); +CREATE TABLE t2 ( +col_varchar_nokey varchar(1) +) charset latin1; +INSERT INTO t2 VALUES +('b'); +EXPLAIN SELECT grandparent1.col_varchar_nokey +FROM t1 AS grandparent1 LEFT JOIN t2 AS grandparent2 USING (col_varchar_nokey) +WHERE (grandparent1.col_varchar_key) IN +(SELECT parent1.col_varchar_nokey +FROM t1 AS parent1 +WHERE parent1.col_varchar_key IN +(SELECT child1.col_varchar_nokey AS c1 +FROM t1 AS child1 LEFT JOIN t2 AS child2 +ON (child1.col_varchar_key > child2.col_varchar_nokey))); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using where +1 SIMPLE grandparent1 NULL ref col_varchar_key col_varchar_key 4 .col_varchar_nokey 2 100.00 Using join buffer (Batched Key Access) +1 SIMPLE grandparent2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +2 MATERIALIZED child1 NULL ALL NULL NULL NULL NULL 15 100.00 Using where +2 MATERIALIZED child2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +2 MATERIALIZED parent1 NULL ref col_varchar_key col_varchar_key 4 test.child1.col_varchar_nokey 2 100.00 Using join buffer (Batched Key Access) +Warnings: +Note 1003 /* select#1 */ select `test`.`grandparent1`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t1` `grandparent1` left join `test`.`t2` `grandparent2` on((`test`.`grandparent2`.`col_varchar_nokey` = `test`.`grandparent1`.`col_varchar_nokey`)) semi join (`test`.`t1` `parent1` join `test`.`t1` `child1` left join `test`.`t2` `child2` on((`test`.`child1`.`col_varchar_key` > `test`.`child2`.`col_varchar_nokey`))) where ((`test`.`grandparent1`.`col_varchar_key` = ``.`col_varchar_nokey`) and (`test`.`parent1`.`col_varchar_key` = `test`.`child1`.`col_varchar_nokey`)) +SELECT grandparent1.col_varchar_nokey +FROM t1 AS grandparent1 LEFT JOIN t2 AS grandparent2 USING (col_varchar_nokey) +WHERE (grandparent1.col_varchar_key) IN +(SELECT parent1.col_varchar_nokey +FROM t1 AS parent1 +WHERE parent1.col_varchar_key IN +(SELECT child1.col_varchar_nokey AS c1 +FROM t1 AS child1 LEFT JOIN t2 AS child2 +ON (child1.col_varchar_key > child2.col_varchar_nokey))); +col_varchar_nokey +a +e +h +h +i +i +p +q +s +u +v +w +y +y +z +DROP TABLE t1, t2; +# End of test for bug#12603183. +# +# Bug#12818569: Diff nr of rows returned when using IN/ALL+subquery +# +CREATE TABLE t1 ( +col_int_key INT NOT NULL, +col_datetime_key DATETIME NOT NULL, +col_varchar_key VARCHAR(1) NOT NULL, +KEY col_int_key (col_int_key), +KEY col_datetime_key(col_datetime_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t1 VALUES +(7,'2004-06-06 04:22:12','v'), (0,'2005-11-13 01:12:31','s'), +(9,'2002-05-04 01:50:00','l'), (3,'2004-10-27 10:28:45','y'), +(4,'2006-07-22 05:24:23','c'), (2,'2002-05-16 21:34:03','i'), +(5,'2008-04-17 10:45:30','h'), (3,'2009-04-21 02:58:02','q'), +(1,'2008-01-11 11:01:51','a'), (3,'1900-01-01 00:00:00','v'), +(6,'2007-05-17 18:24:57','u'), (7,'2007-08-07 00:00:00','s'), +(5,'2001-08-28 00:00:00','y'), (1,'2004-04-16 00:27:28','z'), +(204,'2005-05-03 07:06:22','h'), (224,'2009-03-11 17:09:50','p'), +(9,'2007-12-08 01:54:28','e'), (5,'2009-07-28 18:19:54','i'), +(0,'2008-06-08 00:00:00','y'), (3,'2005-02-09 09:20:26','w'); +CREATE TABLE t2 ( +col_varchar_nokey VARCHAR(1) NOT NULL +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t2 VALUES ('v'), ('y'), ('j'), ('c'), ('d'), ('r'); +explain SELECT col_varchar_key +FROM t1 +WHERE col_varchar_key IN (SELECT col_varchar_nokey +FROM t2) +ORDER BY col_datetime_key LIMIT 4; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL col_varchar_key NULL NULL NULL 20 100.00 Using filesort +1 SIMPLE NULL eq_ref 6 test.t1.col_varchar_key 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 6 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col_varchar_key` AS `col_varchar_key` from `test`.`t1` semi join (`test`.`t2`) where (``.`col_varchar_nokey` = `test`.`t1`.`col_varchar_key`) order by `test`.`t1`.`col_datetime_key` limit 4 +SELECT col_varchar_key +FROM t1 +WHERE col_varchar_key IN (SELECT col_varchar_nokey +FROM t2) +ORDER BY col_datetime_key LIMIT 4; +col_varchar_key +v +y +v +y +DROP TABLE t1, t2; +# End of test for bug#12818569. +# +# Bug#12803439: Assert in replace_subcondition() on update query +# +CREATE TABLE t1(a INTEGER); +INSERT INTO t1 values(1), (2); +CREATE TABLE t2(a INTEGER); +INSERT INTO t2 VALUES(1), (3); +SELECT * +FROM t1 +WHERE a IN (SELECT a +FROM t2 +HAVING a IN (SELECT a +FROM t2) +) +HAVING a IN (SELECT a +FROM t2); +a +1 +DROP TABLE t1, t2; +# End of test for bug#12803439. +# +# Bug#12797534: Segfault in hp_movelink still exists +# +CREATE TABLE t1 ( +g1 VARCHAR(1) NOT NULL +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t1 VALUES ('d'), ('s'); +CREATE TABLE t2 ( +pk INT NOT NULL, +col_int_key INT NOT NULL, +col_varchar_key VARCHAR(1) NOT NULL, +col_varchar_nokey VARCHAR(1) NOT NULL, +PRIMARY KEY (pk), +KEY col_varchar_key(col_varchar_key, col_int_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t2 VALUES +(1,4,'j','j'), (2,6,'v','v'), (3,3,'c','c'), (4,5,'m','m'), +(5,3,'d','d'), (6,246,'d','d'), (7,2,'y','y'), (8,9,'t','t'), +(9,3,'d','d'), (10,8,'s','s'), (11,1,'r','r'), (12,8,'m','m'), +(13,8,'b','b'), (14,5,'x','x'), (15,7,'g','g'), (16,5,'p','p'), +(17,1,'q','q'), (18,6,'w','w'), (19,2,'d','d'), (20,9,'e','e'); +CREATE TABLE t3 ( +pk INTEGER NOT NULL, +PRIMARY KEY (pk) +) ENGINE=InnoDB; +INSERT INTO t3 VALUES (10); +EXPLAIN SELECT * +FROM t1 +WHERE g1 NOT IN +(SELECT grandparent1.col_varchar_nokey AS g1 +FROM t2 AS grandparent1 +WHERE grandparent1.col_varchar_key IN +(SELECT parent1.col_varchar_nokey AS p1 +FROM t2 AS parent1 LEFT JOIN t3 AS parent2 USING (pk) +) +AND grandparent1.col_varchar_key IS NOT NULL +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE NULL eq_ref 7 test.t1.g1 1 100.00 Using where; Not exists +2 MATERIALIZED parent1 NULL ALL NULL NULL NULL NULL 20 100.00 NULL +2 MATERIALIZED parent2 NULL eq_ref PRIMARY PRIMARY 4 test.parent1.pk 1 100.00 Using index +2 MATERIALIZED grandparent1 NULL ref col_varchar_key col_varchar_key 6 test.parent1.col_varchar_nokey 1 100.00 Using index condition; Using join buffer (Batched Key Access) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`g1` AS `g1` from `test`.`t1` anti join (`test`.`t2` `grandparent1` join `test`.`t2` `parent1` left join `test`.`t3` `parent2` on((`test`.`parent2`.`pk` = `test`.`parent1`.`pk`))) on(((``.`g1` = `test`.`t1`.`g1`) and (`test`.`grandparent1`.`col_varchar_key` = `test`.`parent1`.`col_varchar_nokey`) and (`test`.`grandparent1`.`col_varchar_key` is not null))) where true +SELECT * +FROM t1 +WHERE g1 NOT IN +(SELECT grandparent1.col_varchar_nokey AS g1 +FROM t2 AS grandparent1 +WHERE grandparent1.col_varchar_key IN +(SELECT parent1.col_varchar_nokey AS p1 +FROM t2 AS parent1 LEFT JOIN t3 AS parent2 USING (pk) +) +AND grandparent1.col_varchar_key IS NOT NULL +); +g1 +DROP TABLE t1, t2, t3; +CREATE TABLE t1 ( +pk INTEGER AUTO_INCREMENT, +col_int_key INTEGER , +col_varchar_key VARCHAR(1) , +col_varchar_nokey VARCHAR(1) , +PRIMARY KEY (pk), +KEY (col_varchar_key,col_int_key) +) ENGINE=INNODB; +INSERT INTO t1 (col_int_key,col_varchar_key,col_varchar_nokey) VALUES +(0,'x','x'), (1,'j','j'), (1,'r','r'), (9,'v','v'), (5,'r','r'); +CREATE TABLE t2 ( +pk INTEGER AUTO_INCREMENT, +col_int_key INTEGER , +col_varchar_key VARCHAR(1) , +col_varchar_nokey VARCHAR(1) , +PRIMARY KEY (pk), +KEY (col_int_key), +KEY (col_varchar_key,col_int_key) +) AUTO_INCREMENT=10 ENGINE=INNODB; +INSERT INTO t2 (col_int_key, col_varchar_key, col_varchar_nokey) VALUES +(NULL,'x','x'), (NULL,'j','j'), (8,'c','c'); +CREATE TABLE t3 +SELECT outr.col_varchar_nokey AS x +FROM t1 AS outr +WHERE outr.col_varchar_nokey IN +(SELECT innr.col_varchar_nokey AS y +FROM t2 AS innr +WHERE innr.col_int_key IS NULL) +AND outr.col_varchar_nokey IS NOT NULL +AND NOT col_varchar_key IS NULL; +SELECT * +FROM t3 +WHERE x NOT IN +(SELECT outr.col_varchar_nokey AS x +FROM t1 AS outr +WHERE outr.col_varchar_nokey IN +(SELECT innr.col_varchar_nokey AS y +FROM t2 AS innr +WHERE innr.col_int_key IS NULL) +AND outr.col_varchar_nokey IS NOT NULL +AND NOT col_varchar_key IS NULL); +x +DROP TABLE t1, t2, t3; +# End of test for bug#12797534. +# +# Bug#12714094: Assert in optimize_semijoin_nests() +# +CREATE TABLE it ( +pk int NOT NULL, +col_varchar VARCHAR(10) DEFAULT NULL, +PRIMARY KEY (pk) +) ENGINE=MyISAM; +INSERT INTO it VALUES (1, 'g'); +CREATE TABLE ot +SELECT alias1.pk AS field1 +FROM it AS alias1 +LEFT JOIN it AS alias2 +ON alias1.col_varchar = alias2.col_varchar +; +SELECT * +FROM ot +WHERE field1 IN ( +SELECT alias1.pk +FROM it AS alias1 +LEFT JOIN it AS alias2 +ON alias1.col_varchar = alias2.col_varchar +); +field1 +1 +DROP TABLE it, ot; +# End of test for bug#12714094 +# +# Bug#12867557: Valgrind: conditional jump/move at key_cmp +# +CREATE TABLE t1 ( +pk INTEGER AUTO_INCREMENT, +col_int_key INTEGER, +PRIMARY KEY (pk), +KEY (col_int_key) +) AUTO_INCREMENT=10; +INSERT INTO t1 (col_int_key) VALUES (8); +CREATE TABLE t2 ( +pk INTEGER AUTO_INCREMENT, +col_int_key INTEGER, +col_time_key TIME, +PRIMARY KEY (pk), +KEY (col_int_key), +KEY (col_time_key) +) AUTO_INCREMENT=10; +INSERT INTO t2 (col_int_key, col_time_key) +VALUES +(8, '22:55:23.019225'), (7, '10:19:31.050677'), (1, '14:40:36.038608'), +(7, '04:37:47.062416'), (9, '19:34:06.054514'), (NULL,'20:35:33.022996'), +(1, NULL), (9, '14:43:37.057393'), (2, '02:23:09.043438'), +(9, '01:22:45.041064'), (2, '00:00:00'), (4, '00:13:25.038482'), +(0, '03:47:16.042671'), (4, '01:41:48.007423'), (8, '00:00:00'), +(NULL, '22:32:04.047407'), (NULL, '16:44:14.028443'), (0, '17:38:37.059754'), +(NULL, '08:46:48.042388'), (8, '14:11:27.044095'); +CREATE TABLE t0 +SELECT DISTINCT grandparent1.col_time_key AS g1 +FROM t2 AS grandparent1 +WHERE grandparent1.col_int_key IN +(SELECT parent1.col_int_key AS p1 +FROM t1 AS parent1) +AND grandparent1.pk > 9; +UPDATE t0 +SET g1 = g1 +WHERE g1 IN +(SELECT grandparent1.col_time_key AS g1 +FROM t2 AS grandparent1 +WHERE grandparent1.col_int_key IN +(SELECT parent1.col_int_key AS p1 +FROM t1 AS parent1) +AND grandparent1.pk > 9); +DROP TABLE t0, t1, t2; +# End of test for bug#12867557 +# +# Bug#12711441: crash in fix_after_pullout +# +CREATE TABLE t1 ( +pk int NOT NULL, +col_int_nokey int DEFAULT NULL, +col_int_key int DEFAULT NULL, +col_time_key time DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +PRIMARY KEY (pk) +); +CREATE VIEW v1 AS SELECT * FROM t1; +CREATE TABLE t2 ( +col_int_key int DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +KEY col_varchar_key(col_varchar_key, col_int_key) +); +CREATE TABLE t3 ( +pk int NOT NULL, +col_int_key INT DEFAULT NULL, +PRIMARY KEY (pk) +); +CREATE TABLE t4 ( +col_int_nokey INT DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +KEY col_varchar_key(col_varchar_key) +); +CREATE TABLE ts +SELECT alias1.col_time_key AS field1 +FROM v1 AS alias1 +RIGHT JOIN t3 AS alias2 +ON alias2.col_int_key = alias1.col_int_nokey +WHERE alias1.pk >= SOME( +SELECT SQ1_alias1.pk AS SQ1_field1 +FROM t3 AS SQ1_alias1 +INNER JOIN (t2 AS SQ1_alias2 +INNER JOIN t4 AS SQ1_alias3 +ON SQ1_alias3.col_varchar_key = SQ1_alias2.col_varchar_nokey) +ON SQ1_alias3.col_int_nokey = SQ1_alias2.col_int_key +WHERE SQ1_alias2.col_varchar_key <= alias1.col_varchar_key +AND SQ1_alias3.col_varchar_nokey <> alias1.col_varchar_key) +; +SELECT * FROM ts WHERE field1 IN ( +SELECT alias1.col_time_key AS field1 +FROM v1 AS alias1 +RIGHT JOIN t3 AS alias2 +ON alias2.col_int_key = alias1.col_int_nokey +WHERE alias1.pk >= SOME( +SELECT SQ1_alias1.pk AS SQ1_field1 +FROM t3 AS SQ1_alias1 +INNER JOIN (t2 AS SQ1_alias2 +INNER JOIN t4 AS SQ1_alias3 +ON SQ1_alias3.col_varchar_key = SQ1_alias2.col_varchar_nokey) +ON SQ1_alias3.col_int_nokey = SQ1_alias2.col_int_key +WHERE SQ1_alias2.col_varchar_key <= alias1.col_varchar_key +AND SQ1_alias3.col_varchar_nokey <> alias1.col_varchar_key) +); +field1 +DROP TABLE t1, t2, t3, t4, ts; +DROP VIEW v1; +# End of test for bug#12711441. +# +# Bug#12664936: Same query executed as where subquery ... +# +CREATE TABLE t1 ( +col_varchar_key VARCHAR(1), +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4; +INSERT INTO t1 VALUES +('o'), ('w'), ('m'), ('q'), +('f'), ('p'), ('j'), ('c'); +CREATE TABLE t2 ( +col_int_nokey INTEGER, +col_int_key INTEGER, +col_varchar_key varchar(1), +KEY col_int_key (col_int_key) +) charset utf8mb4; +INSERT INTO t2 VALUES +(8,5,'u'),(4,5,'p'),(8,1,'o'),(NULL,7,'v'), +(1,2,'g'),(2,1,'q'),(NULL,7,'l'),(3,1,'n'); +CREATE TABLE t4 +SELECT t2.col_int_nokey, t2.col_varchar_key +FROM t1 JOIN t2 ON t2.col_varchar_key = t1.col_varchar_key +WHERE t2.col_int_key = 1; +EXPLAIN SELECT * +FROM t4 +WHERE (col_int_nokey, col_varchar_key) IN +(SELECT t2.col_int_nokey, t2.col_varchar_key +FROM t1 JOIN t2 ON t2.col_varchar_key = t1.col_varchar_key +WHERE t2.col_int_key = 1 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t4 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE t2 NULL ref col_int_key col_int_key 5 const 3 12.50 Using where +1 SIMPLE t1 NULL ref col_varchar_key col_varchar_key 7 test.t4.col_varchar_key 2 100.00 Using index; FirstMatch(t4) +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`col_int_nokey` AS `col_int_nokey`,`test`.`t4`.`col_varchar_key` AS `col_varchar_key` from `test`.`t4` semi join (`test`.`t1` join `test`.`t2`) where ((`test`.`t2`.`col_varchar_key` = `test`.`t4`.`col_varchar_key`) and (`test`.`t1`.`col_varchar_key` = `test`.`t4`.`col_varchar_key`) and (`test`.`t2`.`col_int_nokey` = `test`.`t4`.`col_int_nokey`) and (`test`.`t2`.`col_int_key` = 1)) +SELECT * +FROM t4 +WHERE (col_int_nokey, col_varchar_key) IN +(SELECT t2.col_int_nokey, t2.col_varchar_key +FROM t1 JOIN t2 ON t2.col_varchar_key = t1.col_varchar_key +WHERE t2.col_int_key = 1 +); +col_int_nokey col_varchar_key +8 o +2 q +DROP TABLE t1, t2, t4; +# End of test for bug#12664936. +# +# Bug#13340270: assertion table->sort.record_pointers == __null +# +CREATE TABLE t1 ( +pk int NOT NULL, +col_int_key int DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key, col_int_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t1 VALUES +(10,8,'x','x'), +(11,7,'d','d'), +(12,1,'r','r'), +(13,7,'f','f'), +(14,9,'y','y'), +(15,NULL,'u','u'), +(16,1,'m','m'), +(17,9,NULL,NULL), +(18,2,'o','o'), +(19,9,'w','w'), +(20,2,'m','m'), +(21,4,'q','q'); +CREATE TABLE t2 +SELECT alias1.col_varchar_nokey AS field1 +FROM t1 AS alias1 JOIN t1 AS alias2 +ON alias2.col_int_key = alias1.pk OR +alias2.col_int_key = alias1.col_int_key +WHERE alias1.pk = 58 OR alias1.col_varchar_key = 'o' + +; +EXPLAIN SELECT * +FROM t2 +WHERE (field1) IN (SELECT alias1.col_varchar_nokey AS field1 +FROM t1 AS alias1 JOIN t1 AS alias2 +ON alias2.col_int_key = alias1.pk OR +alias2.col_int_key = alias1.col_int_key +WHERE alias1.pk = 58 OR alias1.col_varchar_key = 'o' +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE alias1 NULL index_merge PRIMARY,col_int_key,col_varchar_key col_varchar_key,PRIMARY 7,4 NULL 2 10.00 Using sort_union(col_varchar_key,PRIMARY); Using where +1 SIMPLE alias2 NULL ALL col_int_key NULL NULL NULL 12 19.00 Range checked for each record (index map: 0x2); FirstMatch(t2) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`field1` AS `field1` from `test`.`t2` semi join (`test`.`t1` `alias1` join `test`.`t1` `alias2`) where ((`test`.`alias1`.`col_varchar_nokey` = `test`.`t2`.`field1`) and ((`test`.`alias1`.`pk` = 58) or (`test`.`alias1`.`col_varchar_key` = 'o')) and ((`test`.`alias2`.`col_int_key` = `test`.`alias1`.`pk`) or (`test`.`alias2`.`col_int_key` = `test`.`alias1`.`col_int_key`))) +SELECT * +FROM t2 +WHERE (field1) IN (SELECT alias1.col_varchar_nokey AS field1 +FROM t1 AS alias1 JOIN t1 AS alias2 +ON alias2.col_int_key = alias1.pk OR +alias2.col_int_key = alias1.col_int_key +WHERE alias1.pk = 58 OR alias1.col_varchar_key = 'o' +); +field1 +o +o +DROP TABLE t1, t2; +# End of test for bug#13340270. +# +# Bug#13335319: Seg fault when analyzing FirstMatch semi-join strategy +# +CREATE TABLE ot1(a INTEGER); +INSERT INTO ot1 VALUES(1), (2), (3); +CREATE TABLE ot2(a INTEGER); +INSERT INTO ot2 VALUES(1), (2), (4), (6), (8), (10); +CREATE TABLE it1(a INTEGER); +INSERT INTO it1 VALUES(1), (3), (5), (7); +CREATE TABLE it2(a INTEGER); +INSERT INTO it2 VALUES(1), (3), (5), (7), (9); +explain SELECT ot1.a, ot2.a +FROM ot1, ot2 +WHERE ot1.a IN (SELECT a FROM it1) AND +ot2.a IN (SELECT a FROM it2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE it1 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; FirstMatch(ot1); Using join buffer (hash join) +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using join buffer (hash join) +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Using join buffer (hash join) +3 MATERIALIZED it2 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` join `test`.`ot2` semi join (`test`.`it1`) semi join (`test`.`it2`) where ((`test`.`ot2`.`a` = ``.`a`) and (`test`.`it1`.`a` = `test`.`ot1`.`a`)) +SELECT ot1.a, ot2.a +FROM ot1, ot2 +WHERE ot1.a IN (SELECT a FROM it1) AND +ot2.a IN (SELECT a FROM it2); +a a +1 1 +3 1 +DROP TABLE ot1, ot2, it1, it2; +# End of test for bug#13335319. +# +# Bug#13334882: Assertion keypart_map failed in MyIsam function +# +CREATE TABLE t1 ( +pk int NOT NULL, +col_int_nokey INT NOT NULL, +col_int_key INT NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +) ENGINE=MyISAM; +INSERT INTO t1 VALUES +(1,4,0), +(2,6,8), +(3,3,1), +(7,2,6), +(8,9,1), +(9,3,6), +(10,8,2), +(11,1,4), +(12,8,8), +(13,8,4), +(14,5,4); +CREATE TABLE t2 ( +pk int NOT NULL, +col_int_nokey int NOT NULL, +col_int_key int NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +) ENGINE=MyISAM; +INSERT INTO t2 VALUES +(10,8,7); +CREATE TABLE t3 +SELECT grandparent1.col_int_nokey AS g1 +FROM t1 AS grandparent1 +WHERE (grandparent1.col_int_nokey, grandparent1.col_int_key) IN +(SELECT parent1.col_int_key AS p1, +parent1.col_int_key AS p2 +FROM t1 AS parent1 +LEFT JOIN t2 AS parent2 +ON parent1.col_int_nokey = parent2.col_int_key +) +AND grandparent1.col_int_key <> 3 +; +explain SELECT * FROM t3 +WHERE g1 NOT IN +(SELECT grandparent1.col_int_nokey AS g1 +FROM t1 AS grandparent1 +WHERE (grandparent1.col_int_nokey, grandparent1.col_int_key) IN +(SELECT parent1.col_int_key AS p1, +parent1.col_int_key AS p2 +FROM t1 AS parent1 +LEFT JOIN t2 AS parent2 +ON parent1.col_int_nokey = parent2.col_int_key +) +AND grandparent1.col_int_key <> 3 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE grandparent1 NULL ref col_int_key col_int_key 4 const 1 100.00 Using where; Not exists +1 SIMPLE parent1 NULL ref col_int_key col_int_key 4 test.grandparent1.col_int_nokey 1 100.00 Using where +1 SIMPLE parent2 NULL ref col_int_key col_int_key 4 test.parent1.col_int_nokey 2 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select '8' AS `g1` from anti join (`test`.`t1` `grandparent1` join `test`.`t1` `parent1` left join `test`.`t2` `parent2` on((`test`.`parent2`.`col_int_key` = `test`.`parent1`.`col_int_nokey`))) on(((`test`.`grandparent1`.`col_int_nokey` = '8') and (`test`.`grandparent1`.`col_int_key` = '8') and (`test`.`parent1`.`col_int_key` = '8') and ('8' <> 3))) where true +explain format=json SELECT * FROM t3 +WHERE g1 NOT IN +(SELECT grandparent1.col_int_nokey AS g1 +FROM t1 AS grandparent1 +WHERE (grandparent1.col_int_nokey, grandparent1.col_int_key) IN +(SELECT parent1.col_int_key AS p1, +parent1.col_int_key AS p2 +FROM t1 AS parent1 +LEFT JOIN t2 AS parent2 +ON parent1.col_int_nokey = parent2.col_int_key +) +AND grandparent1.col_int_key <> 3 +); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.36" + }, + "nested_loop": [ + { + "table": { + "table_name": "t3", + "access_type": "system", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.00", + "eval_cost": "0.10", + "prefix_cost": "0.00", + "data_read_per_join": "8" + }, + "used_columns": [ + "g1" + ] + } + }, + { + "table": { + "table_name": "grandparent1", + "access_type": "ref", + "possible_keys": [ + "col_int_key" + ], + "key": "col_int_key", + "used_key_parts": [ + "col_int_key" + ], + "key_length": "4", + "ref": [ + "const" + ], + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "not_exists": true, + "cost_info": { + "read_cost": "0.28", + "eval_cost": "0.11", + "prefix_cost": "0.39", + "data_read_per_join": "17" + }, + "used_columns": [ + "col_int_nokey", + "col_int_key" + ], + "attached_condition": "(((is_not_null_compl(grandparent1..parent2), (found_match(grandparent1..parent2), false, true), true) and (is_not_null_compl(grandparent1..parent2), (('8' <> 3)), true)) and (is_not_null_compl(grandparent1..parent2), (`test`.`grandparent1`.`col_int_nokey` = '8'), true))" + } + }, + { + "table": { + "table_name": "parent1", + "access_type": "ref", + "possible_keys": [ + "col_int_key" + ], + "key": "col_int_key", + "used_key_parts": [ + "col_int_key" + ], + "key_length": "4", + "ref": [ + "test.grandparent1.col_int_nokey" + ], + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.30", + "eval_cost": "0.12", + "prefix_cost": "0.81", + "data_read_per_join": "19" + }, + "used_columns": [ + "col_int_nokey", + "col_int_key" + ], + "attached_condition": "(is_not_null_compl(grandparent1..parent2), (`test`.`parent1`.`col_int_key` = '8'), true)" + } + }, + { + "table": { + "table_name": "parent2", + "access_type": "ref", + "possible_keys": [ + "col_int_key" + ], + "key": "col_int_key", + "used_key_parts": [ + "col_int_key" + ], + "key_length": "4", + "ref": [ + "test.parent1.col_int_nokey" + ], + "rows_examined_per_scan": 2, + "rows_produced_per_join": 1, + "filtered": "100.00", + "using_index": true, + "cost_info": { + "read_cost": "0.31", + "eval_cost": "0.10", + "prefix_cost": "1.36", + "data_read_per_join": "16" + }, + "used_columns": [ + "col_int_key" + ] + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select '8' AS `g1` from anti join (`test`.`t1` `grandparent1` join `test`.`t1` `parent1` left join `test`.`t2` `parent2` on((`test`.`parent2`.`col_int_key` = `test`.`parent1`.`col_int_nokey`))) on(((`test`.`grandparent1`.`col_int_nokey` = '8') and (`test`.`grandparent1`.`col_int_key` = '8') and (`test`.`parent1`.`col_int_key` = '8') and ('8' <> 3))) where true +SELECT * FROM t3 +WHERE g1 NOT IN +(SELECT grandparent1.col_int_nokey AS g1 +FROM t1 AS grandparent1 +WHERE (grandparent1.col_int_nokey, grandparent1.col_int_key) IN +(SELECT parent1.col_int_key AS p1, +parent1.col_int_key AS p2 +FROM t1 AS parent1 +LEFT JOIN t2 AS parent2 +ON parent1.col_int_nokey = parent2.col_int_key +) +AND grandparent1.col_int_key <> 3 +); +g1 +DROP TABLE t1, t2, t3; +# End of test for bug#13334882. +# +# Bug#13339643: Assertion on JOIN::flatten_subqueries on second execution +# +CREATE TABLE t1 ( +col_int_nokey INT, +col_varchar_nokey VARCHAR(1) +) charset utf8mb4; +INSERT INTO t1 VALUES +(1,'o'), +(2,'t'); +CREATE TABLE t2 LIKE t1; +INSERT INTO t2 VALUES +(1,'o'), +(4,'f'); +CREATE VIEW v_t2 AS SELECT * FROM t2; +CREATE TABLE t3 LIKE t1; +INSERT INTO t3 VALUES +(1,'o'), +(4,'f'); +explain SELECT alias1.col_varchar_nokey +FROM t1 AS alias1 +INNER JOIN v_t2 AS alias2 +ON alias2.col_int_nokey = alias1.col_int_nokey AND +'o' IN (SELECT col_varchar_nokey +FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch +1 SIMPLE alias1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`alias1`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t1` `alias1` join `test`.`t2` semi join (`test`.`t3`) where ((`test`.`t3`.`col_varchar_nokey` = 'o') and (`test`.`t2`.`col_int_nokey` = `test`.`alias1`.`col_int_nokey`)) +SELECT alias1.col_varchar_nokey +FROM t1 AS alias1 +INNER JOIN v_t2 AS alias2 +ON alias2.col_int_nokey = alias1.col_int_nokey AND +'o' IN (SELECT col_varchar_nokey +FROM t3); +col_varchar_nokey +o +PREPARE stmt FROM "SELECT alias1.col_varchar_nokey +FROM t1 AS alias1 +INNER JOIN v_t2 AS alias2 +ON alias2.col_int_nokey = alias1.col_int_nokey AND +'o' IN (SELECT col_varchar_nokey +FROM t3)"; +EXECUTE stmt; +col_varchar_nokey +o +DROP VIEW v_t2; +DROP TABLE t1, t2, t3; +# End of test for bug#13339643. +# +# Bug#13424134: Wrong result on JOIN + nested WHERE ... IN clauses +# +CREATE TABLE t1 ( +pk int NOT NULL, +col_int_nokey int NOT NULL, +col_int_key int NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +) ENGINE=MyIsam; +INSERT INTO t1 VALUES +(10,1,7), (13,7,3), (18,0,1), (23,8,1); +CREATE TABLE t2 ( +pk int NOT NULL, +col_int_key int NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +) ENGINE=MyIsam; +INSERT INTO t2 VALUES (1,7); +EXPLAIN SELECT t1a.* +FROM t1 AS t1a +JOIN t1 AS t1b USING ( col_int_nokey ) +WHERE t1a.col_int_key IN ( +SELECT pk +FROM t2 +WHERE col_int_key IN ( +SELECT col_int_nokey +FROM t1 +) +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL system PRIMARY,col_int_key NULL NULL NULL 1 100.00 NULL +1 SIMPLE t1a NULL ref col_int_key col_int_key 4 const 1 100.00 NULL +1 SIMPLE t1b NULL ALL NULL NULL NULL NULL 4 25.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; FirstMatch(t1b); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1a`.`pk` AS `pk`,`test`.`t1a`.`col_int_nokey` AS `col_int_nokey`,`test`.`t1a`.`col_int_key` AS `col_int_key` from `test`.`t1` `t1a` join `test`.`t1` `t1b` semi join (`test`.`t1`) where ((`test`.`t1b`.`col_int_nokey` = `test`.`t1a`.`col_int_nokey`) and (`test`.`t1a`.`col_int_key` = '1') and (`test`.`t1`.`col_int_nokey` = '7')) +SELECT t1a.* +FROM t1 AS t1a +JOIN t1 AS t1b USING ( col_int_nokey ) +WHERE t1a.col_int_key IN ( +SELECT pk +FROM t2 +WHERE col_int_key IN ( +SELECT col_int_nokey +FROM t1 +) +); +pk col_int_nokey col_int_key +18 0 1 +23 8 1 +ALTER TABLE t1 ENGINE=Innodb; +ALTER TABLE t2 ENGINE=Innodb; +SELECT t1a.* +FROM t1 AS t1a +JOIN t1 AS t1b USING ( col_int_nokey ) +WHERE t1a.col_int_key IN ( +SELECT pk +FROM t2 +WHERE col_int_key IN ( +SELECT col_int_nokey +FROM t1 +) +); +pk col_int_nokey col_int_key +18 0 1 +23 8 1 +DROP TABLE t1, t2; +# End of test for bug#13424134. +# +# Bug#13414014: Extra rows in result on semijoin query with where ... +# +CREATE TABLE t1 ( +c INT, +d INT, +a VARCHAR(1), +b VARCHAR(1), +KEY a (a) +) charset utf8mb4; +INSERT INTO t1 VALUES +(NULL,8,'x','x'), (7,4,'q','q'), (6,8,'c','c'); +CREATE TABLE t2 ( +a VARCHAR(1), +KEY a (a) +) charset utf8mb4; +INSERT INTO t2 VALUES +('c'), (NULL), ('x'), ('q'); +explain SELECT * +FROM t2 AS ot +WHERE (a, a) IN +(SELECT a, b +FROM t1 AS it +WHERE it.a = 'x' OR it.c > it.d +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using where +1 SIMPLE ot NULL ref a a 7 .a 2 100.00 Using index +2 MATERIALIZED it NULL ALL a NULL NULL NULL 3 40.74 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`ot`.`a` AS `a` from `test`.`t2` `ot` semi join (`test`.`t1` `it`) where ((``.`b` = ``.`a`) and (`test`.`ot`.`a` = ``.`a`) and (`test`.`it`.`b` = `test`.`it`.`a`) and (((``.`a` = 'x') and (`test`.`it`.`a` = 'x') and (`test`.`it`.`b` = 'x')) or (`test`.`it`.`c` > `test`.`it`.`d`))) +SELECT * +FROM t2 AS ot +WHERE (a, a) IN +(SELECT a, b +FROM t1 AS it +WHERE it.a = 'x' OR it.c > it.d +) +; +a +q +x +DROP TABLE t1, t2; +# End of test for bug#13414014. +# +# Bug#13545215: Missing rows on nested in-subquery with materialization +# +CREATE TABLE t1 ( +col_int_key int, +col_varchar_key varchar(1), +col_varchar_nokey varchar(1), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +INSERT INTO t1 VALUES +(8,'x','x'), (0,'p','p'), (8,'c','c'); +CREATE TABLE t2 ( +pk int NOT NULL, +col_varchar_key varchar(1), +col_varchar_nokey varchar(1), +PRIMARY KEY (pk), +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4; +INSERT INTO t2 VALUES +(1,'v','v'), (2,'v','v'), (3,'c','c'), (4,NULL,NULL), +(5,'x','x'), (6,'i','i'), (7,'e','e'), (8,'p','p'); +CREATE TABLE t3 ( +col_int_nokey int +); +INSERT INTO t3 VALUES (7); +explain SELECT grandparent1.col_varchar_nokey +FROM t1 AS grandparent1 JOIN t1 AS grandparent2 USING (col_int_key) +WHERE grandparent1.col_varchar_key IN ( +SELECT col_varchar_nokey +FROM t2 AS parent1 +WHERE col_varchar_key IN ( +SELECT child1.col_varchar_nokey +FROM t2 AS child1 LEFT JOIN t3 AS child2 +ON child1.pk < child2.col_int_nokey +) +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE grandparent1 NULL ALL col_int_key,col_varchar_key NULL NULL NULL 3 100.00 Using where; Start temporary +1 SIMPLE parent1 NULL ALL col_varchar_key NULL NULL NULL 8 12.50 Using where; Using join buffer (hash join) +1 SIMPLE child1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; Using join buffer (hash join) +1 SIMPLE child2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +1 SIMPLE grandparent2 NULL ref col_int_key col_int_key 5 test.grandparent1.col_int_key 2 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`grandparent1`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t1` `grandparent1` join `test`.`t1` `grandparent2` semi join (`test`.`t2` `parent1` join `test`.`t2` `child1` left join `test`.`t3` `child2` on((`test`.`child1`.`pk` < `test`.`child2`.`col_int_nokey`))) where ((`test`.`grandparent2`.`col_int_key` = `test`.`grandparent1`.`col_int_key`) and (`test`.`parent1`.`col_varchar_nokey` = `test`.`grandparent1`.`col_varchar_key`) and (`test`.`child1`.`col_varchar_nokey` = `test`.`parent1`.`col_varchar_key`)) +SELECT grandparent1.col_varchar_nokey +FROM t1 AS grandparent1 JOIN t1 AS grandparent2 USING (col_int_key) +WHERE grandparent1.col_varchar_key IN ( +SELECT col_varchar_nokey +FROM t2 AS parent1 +WHERE col_varchar_key IN ( +SELECT child1.col_varchar_nokey +FROM t2 AS child1 LEFT JOIN t3 AS child2 +ON child1.pk < child2.col_int_nokey +) +); +col_varchar_nokey +c +c +p +x +x +DROP TABLE t1, t2, t3; +# End of test for bug#13545215. +# +# BUG#13553211 - MISSING ROWS ON SELECT WITH IN-SUBQUERY AND +# MATERIALIZATION + SEMIJOIN ON +# +CREATE TABLE t1 ( +col_int_key int(11) DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (4,'v','v'); +INSERT INTO t1 VALUES (62,'v','v'); +INSERT INTO t1 VALUES (7,'c','c'); +INSERT INTO t1 VALUES (1,NULL,NULL); +EXPLAIN SELECT +alias1.col_varchar_nokey AS a1_nokey, +alias1.col_varchar_key AS a1_key, +alias2.col_varchar_nokey AS a2_nokey +FROM +t1 AS alias1, t1 AS alias2 +WHERE +(alias1.col_varchar_nokey,alias2.col_varchar_nokey) +IN +( +SELECT +sq2_alias2.col_varchar_nokey, sq2_alias1.col_varchar_key +FROM +t1 AS sq2_alias1, t1 AS sq2_alias2 +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE alias1 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +1 SIMPLE alias2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (hash join) +1 SIMPLE NULL eq_ref 14 test.alias1.col_varchar_nokey,test.alias2.col_varchar_nokey 1 100.00 NULL +2 MATERIALIZED sq2_alias1 NULL index col_varchar_key col_varchar_key 12 NULL 4 100.00 Using index +2 MATERIALIZED sq2_alias2 NULL ALL NULL NULL NULL NULL 4 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`alias1`.`col_varchar_nokey` AS `a1_nokey`,`test`.`alias1`.`col_varchar_key` AS `a1_key`,`test`.`alias2`.`col_varchar_nokey` AS `a2_nokey` from `test`.`t1` `alias1` join `test`.`t1` `alias2` semi join (`test`.`t1` `sq2_alias1` join `test`.`t1` `sq2_alias2`) where ((``.`col_varchar_key` = `test`.`alias2`.`col_varchar_nokey`) and (``.`col_varchar_nokey` = `test`.`alias1`.`col_varchar_nokey`)) +SELECT +alias1.col_varchar_nokey AS a1_nokey, +alias1.col_varchar_key AS a1_key, +alias2.col_varchar_nokey AS a2_nokey +FROM +t1 AS alias1, t1 AS alias2 +WHERE +(alias1.col_varchar_nokey,alias2.col_varchar_nokey) +IN +( +SELECT +sq2_alias2.col_varchar_nokey, sq2_alias1.col_varchar_key +FROM +t1 AS sq2_alias1, t1 AS sq2_alias2 +) +; +a1_nokey a1_key a2_nokey +c c c +c c v +c c v +v v c +v v c +v v v +v v v +v v v +v v v +DROP TABLE t1; +# +# Bug#13541406: Wrong result with loosescan on select .. where .. in +# +CREATE TABLE t1 ( +col_int_key INT NOT NULL, +col_varchar_nokey VARCHAR(1) NOT NULL, +KEY col_int_key (col_int_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t1 VALUES +(7,'v'), (0,'s'), (9,'l'), (3,'y'), (4,'c'), (2,'i'), (5,'h'), (3,'q'), +(1,'a'), (3,'v'), (6,'u'), (7,'s'), (5,'y'), (1,'z'), (204,'h'), (224,'p'), +(9,'e'), (5,'i'), (0,'y'), (3,'w'); +CREATE TABLE t2 ( +pk INT NOT NULL, +col_int_key INT NOT NULL, +col_varchar_key VARCHAR(1) NOT NULL, +col_varchar_nokey VARCHAR(1) NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t2 VALUES +(1,0,'j','j'), (2,8,'v','v'), (3,1,'c','c'), (4,8,'m','m'), +(5,9,'d','d'), (6,24,'d','d'), (7,6,'y','y'), (8,1,'t','t'), +(9,6,'d','d'), (10,2,'s','s'), (11,4,'r','r'), (12,8,'m','m'), +(13,4,'b','b'), (14,4,'x','x'), (15,7,'g','g'), (16,4,'p','p'), +(17,1,'q','q'), (18,9,'w','w'), (19,4,'d','d'), (20,8,'e','e'); +# This query should never use a LooseScan strategy +explain SELECT ot1.col_int_key AS field1 +FROM t2 AS ot1, t2 AS ot2 +WHERE (ot1.col_varchar_key, ot2.col_varchar_nokey) IN ( +SELECT it2.col_varchar_nokey, it1.col_varchar_key +FROM t2 AS it1 JOIN t1 AS it2 ON it2.col_int_key = it1.pk); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 20 100.00 Parallel execute (1 workers) +2 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 20 100.00 Start temporary +2 SIMPLE it1 NULL ref PRIMARY,col_varchar_key col_varchar_key 6 test.ot2.col_varchar_nokey 1 100.00 Using index +2 SIMPLE it2 NULL ref col_int_key col_int_key 4 test.it1.pk 1 100.00 Using join buffer (Batched Key Access) +2 SIMPLE ot1 NULL ref col_varchar_key col_varchar_key 6 test.it2.col_varchar_nokey 1 100.00 Using index; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`col_int_key` AS `field1` from `test`.`t2` `ot1` join `test`.`t2` `ot2` semi join (`test`.`t2` `it1` join `test`.`t1` `it2`) where ((`test`.`it2`.`col_int_key` = `test`.`it1`.`pk`) and (`test`.`it1`.`col_varchar_key` = `test`.`ot2`.`col_varchar_nokey`) and (`test`.`ot1`.`col_varchar_key` = `test`.`it2`.`col_varchar_nokey`)) +SELECT ot1.col_int_key AS field1 +FROM t2 AS ot1, t2 AS ot2 +WHERE (ot1.col_varchar_key, ot2.col_varchar_nokey) IN ( +SELECT it2.col_varchar_nokey, it1.col_varchar_key +FROM t2 AS it1 JOIN t1 AS it2 ON it2.col_int_key = it1.pk); +field1 +1 +1 +1 +2 +6 +6 +6 +6 +6 +8 +8 +8 +8 +8 +8 +9 +DROP TABLE t1, t2; +# End of test for bug#13541406. +# +# Bug#13576391: Missing rows on select with in-subquery and +# batched-key-access=on and semijoin +# +CREATE TABLE t1 ( +col_int_nokey int NOT NULL, +col_varchar_key varchar(1) NOT NULL, +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4 engine=InnoDB; +INSERT INTO t1 VALUES +(1,'v'), (7,'s'), (4,'l'), (7,'y'), (0,'c'), (2,'i'), (9,'h'), (4,'q'), +(0,'a'), (9,'v'), (1,'u'), (3,'s'), (8,'y'), (8,'z'), (18,'h'), (84,'p'), +(6,'e'), (3,'i'), (6,'y'), (6,'w'); +CREATE TABLE t2 ( +col_int_nokey int NOT NULL, +col_varchar_nokey varchar(1) NOT NULL +) charset utf8mb4 engine=InnoDB; +INSERT INTO t2 VALUES +(4,'j'), (6,'v'), (3,'c'), (5,'m'), (3,'d'), (246,'d'), (2,'y'), (9,'t'), +(3,'d'), (8,'s'), (1,'r'), (8,'m'), (8,'b'), (5,'x'), (7,'g'), (5,'p'), +(1,'q'), (6,'w'), (2,'d'), (9,'e'); +explain SELECT col_varchar_nokey +FROM t2 AS ot +WHERE col_varchar_nokey IN ( +SELECT col_varchar_key +FROM t1 AS it +WHERE it.col_int_nokey <= it.col_int_nokey +AND NOT ot.col_int_nokey < 2 +) +ORDER BY col_varchar_nokey; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 20 33.33 Parallel execute (1 workers) +2 SIMPLE ot NULL ALL NULL NULL NULL NULL 20 33.33 Using where; Using temporary; Using filesort +2 SIMPLE it NULL ref col_varchar_key col_varchar_key 6 test.ot.col_varchar_nokey 1 100.00 FirstMatch(ot); Using join buffer (Batched Key Access) +Warnings: +Note 1276 Field or reference 'test.ot.col_int_nokey' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`ot`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t2` `ot` semi join (`test`.`t1` `it`) where ((`test`.`it`.`col_varchar_key` = `test`.`ot`.`col_varchar_nokey`) and (`test`.`ot`.`col_int_nokey` >= 2)) order by `test`.`ot`.`col_varchar_nokey` +SELECT col_varchar_nokey +FROM t2 AS ot +WHERE col_varchar_nokey IN ( +SELECT col_varchar_key +FROM t1 AS it +WHERE it.col_int_nokey <= it.col_int_nokey +AND NOT ot.col_int_nokey < 2 +) +ORDER BY col_varchar_nokey; +col_varchar_nokey +c +e +p +s +v +w +y +ALTER TABLE t1 ENGINE=MyISAM; +ALTER TABLE t2 ENGINE=MyISAM; +explain SELECT col_varchar_nokey +FROM t2 AS ot +WHERE col_varchar_nokey IN ( +SELECT col_varchar_key +FROM t1 AS it +WHERE it.col_int_nokey <= it.col_int_nokey +AND NOT ot.col_int_nokey < 2 +) +ORDER BY col_varchar_nokey; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 20 33.33 Using where; Using temporary; Using filesort +1 SIMPLE it NULL ref col_varchar_key col_varchar_key 6 test.ot.col_varchar_nokey 2 100.00 FirstMatch(ot); Using join buffer (Batched Key Access) +Warnings: +Note 1276 Field or reference 'test.ot.col_int_nokey' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`ot`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t2` `ot` semi join (`test`.`t1` `it`) where ((`test`.`it`.`col_varchar_key` = `test`.`ot`.`col_varchar_nokey`) and (`test`.`ot`.`col_int_nokey` >= 2)) order by `test`.`ot`.`col_varchar_nokey` +SELECT col_varchar_nokey +FROM t2 AS ot +WHERE col_varchar_nokey IN ( +SELECT col_varchar_key +FROM t1 AS it +WHERE it.col_int_nokey <= it.col_int_nokey +AND NOT ot.col_int_nokey < 2 +) +ORDER BY col_varchar_nokey; +col_varchar_nokey +c +e +p +s +v +w +y +ALTER TABLE t1 ENGINE=Memory; +ALTER TABLE t2 ENGINE=Memory; +explain SELECT col_varchar_nokey +FROM t2 AS ot +WHERE col_varchar_nokey IN ( +SELECT col_varchar_key +FROM t1 AS it +WHERE it.col_int_nokey <= it.col_int_nokey +AND NOT ot.col_int_nokey < 2 +) +ORDER BY col_varchar_nokey; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 20 33.33 Using where; Using filesort +1 SIMPLE it NULL ref col_varchar_key col_varchar_key 6 test.ot.col_varchar_nokey 2 100.00 FirstMatch(ot) +Warnings: +Note 1276 Field or reference 'test.ot.col_int_nokey' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`ot`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t2` `ot` semi join (`test`.`t1` `it`) where ((`test`.`it`.`col_varchar_key` = `test`.`ot`.`col_varchar_nokey`) and (`test`.`ot`.`col_int_nokey` >= 2)) order by `test`.`ot`.`col_varchar_nokey` +SELECT col_varchar_nokey +FROM t2 AS ot +WHERE col_varchar_nokey IN ( +SELECT col_varchar_key +FROM t1 AS it +WHERE it.col_int_nokey <= it.col_int_nokey +AND NOT ot.col_int_nokey < 2 +) +ORDER BY col_varchar_nokey; +col_varchar_nokey +c +e +p +s +v +w +y +DROP TABLE t1, t2; +# End of test for bug#13576391. +# +# Bug #13589848 "MISSING ROW ON SELECT WITH NESTED IN CLAUSES WHEN LOOSESCAN=ON" +# +CREATE TABLE t1 ( +id INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +KEY (col_varchar_key) +) charset utf8mb4; +INSERT INTO t1 VALUES (100,'m','m'), +(200,'b','b'), (300,'x','x'); +CREATE TABLE t2 ( +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +KEY (col_varchar_key) +) charset utf8mb4; +INSERT INTO t2 VALUES ('b','b'); +CREATE TABLE t3 ( +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +KEY (col_varchar_key) +) charset utf8mb4; +INSERT INTO t3 VALUES ('k','k'); +EXPLAIN SELECT gp1.id +FROM t1 AS gp1 JOIN t3 AS gp2 +ON gp2.col_varchar_key <> gp1.col_varchar_nokey +WHERE (gp1.col_varchar_nokey, gp1.col_varchar_nokey) +IN ( +SELECT col_varchar_nokey, col_varchar_nokey +FROM t1 +WHERE col_varchar_nokey +IN ( SELECT col_varchar_key +FROM t2 LEFT JOIN t3 USING (col_varchar_key) ) +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE gp2 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL index col_varchar_key col_varchar_key 7 NULL 1 100.00 Using where; Using index; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +1 SIMPLE gp1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ref col_varchar_key col_varchar_key 7 test.t2.col_varchar_key 2 100.00 Using index; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`gp1`.`id` AS `id` from `test`.`t1` `gp1` semi join (`test`.`t1` join `test`.`t2` left join `test`.`t3` on((`test`.`t2`.`col_varchar_key` = `test`.`t3`.`col_varchar_key`))) where ((`test`.`t1`.`col_varchar_nokey` = `test`.`t2`.`col_varchar_key`) and (`test`.`gp1`.`col_varchar_nokey` = `test`.`t2`.`col_varchar_key`) and ('k' <> `test`.`t2`.`col_varchar_key`)) +SELECT gp1.id +FROM t1 AS gp1 JOIN t3 AS gp2 +ON gp2.col_varchar_key <> gp1.col_varchar_nokey +WHERE (gp1.col_varchar_nokey, gp1.col_varchar_nokey) +IN ( +SELECT col_varchar_nokey, col_varchar_nokey +FROM t1 +WHERE col_varchar_nokey +IN ( SELECT col_varchar_key +FROM t2 LEFT JOIN t3 USING (col_varchar_key) ) +) +; +id +200 +DROP TABLE t1,t2,t3; +# +# Bug #13596176: Missing row on select with nested in clause when +# matr=on and bnl=off + MyISAM +# +CREATE TABLE t1 ( +int_key int DEFAULT NULL, +vc_key varchar(1) DEFAULT NULL, +vc_nokey varchar(1) DEFAULT NULL, +KEY int_key (int_key), +KEY vc_key (vc_key, int_key) +) charset utf8mb4 ENGINE=MyISAM; +INSERT INTO t1 VALUES +(8,'x','x'), (7,'d','d'), (1,'r','r'), (7,'f','f'), +(9,'y','y'), (NULL,'u','u'), (1,'m','m'), (9,NULL,NULL), +(2,'o','o'), (9,'w','w'), (2,'m','m'), (4,'q','q'), +(0,NULL,NULL), (4,'d','d'), (8,'g','g'), (NULL,'x','x'), +(NULL,'f','f'), (0,'p','p'), (NULL,'j','j'), (8,'c','c'); +CREATE TABLE t2 ( +int_key int DEFAULT NULL, +vc_key varchar(1) DEFAULT NULL, +KEY int_key (int_key), +KEY vc_key (vc_key, int_key) +) charset utf8mb4 ENGINE=MyISAM; +INSERT INTO t2 VALUES (8,'g'); +explain SELECT vc_key +FROM t1 as outr +WHERE (vc_nokey, vc_key ) IN +(SELECT vc_nokey, vc_nokey +FROM t1 middle +WHERE vc_nokey IN +(SELECT child1.vc_key +FROM t2 AS child1 JOIN t1 AS child2 USING (int_key) +) +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE child1 NULL index int_key,vc_key vc_key 12 NULL 1 100.00 Using where; Using index; Start temporary +1 SIMPLE outr NULL ref vc_key vc_key 7 test.child1.vc_key 3 10.00 Using where; Using join buffer (Batched Key Access) +1 SIMPLE middle NULL ALL NULL NULL NULL NULL 20 10.00 Using where; Using join buffer (hash join) +1 SIMPLE child2 NULL ref int_key int_key 5 test.child1.int_key 3 100.00 Using index; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`outr`.`vc_key` AS `vc_key` from `test`.`t1` `outr` semi join (`test`.`t1` `middle` join `test`.`t2` `child1` join `test`.`t1` `child2`) where ((`test`.`child2`.`int_key` = `test`.`child1`.`int_key`) and (`test`.`outr`.`vc_nokey` = `test`.`child1`.`vc_key`) and (`test`.`outr`.`vc_key` = `test`.`child1`.`vc_key`) and (`test`.`middle`.`vc_nokey` = `test`.`child1`.`vc_key`)) +SELECT vc_key +FROM t1 as outr +WHERE (vc_nokey, vc_key ) IN +(SELECT vc_nokey, vc_nokey +FROM t1 middle +WHERE vc_nokey IN +(SELECT child1.vc_key +FROM t2 AS child1 JOIN t1 AS child2 USING (int_key) +) +); +vc_key +g +DROP TABLE t1, t2; +# End of test for bug#13596176. +# +# BUG#11754478: MAX/MIN + SUBQUERY + AND FAILS TO RETURN ANY ROWS +# BUG#13599013: MAX/MIN + SUBQUERY IN WHERE CLAUSE MATCHING NO +# ROWS + INDEX DOES NOT RETURN NULL +# +CREATE TABLE t1 ( +pk int(11) PRIMARY KEY, +int_key int(11), +KEY int_key (int_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (1,0),(2,0),(3,2),(4,0),(5,3),(6,0); +SELECT MIN(int_key) FROM t1 WHERE (4, 4) IN (SELECT 1, 2); +MIN(int_key) +NULL +SELECT MIN(int_key) FROM t1 WHERE (4, 4) IN (SELECT 4, 4); +MIN(int_key) +0 +SELECT MIN(pk) FROM t1 WHERE pk IN (SELECT int_key FROM t1) AND pk = 6; +MIN(pk) +NULL +DROP TABLE t1; +# BUG#13726217: Crash in Item_ident::fix_after_pullout() +CREATE TABLE t1(a INTEGER) engine=innodb; +INSERT INTO t1 VALUES (0); +SELECT 0 +FROM t1 +WHERE 0 IN +(SELECT 0 +FROM t1 +WHERE 0 LIKE +(SELECT elt(a, 0) AS b +FROM t1 +GROUP BY a +HAVING b +) +); +0 +DROP TABLE t1; +# End of test for bug#13726217. +# BUG#13773979: Missing rows on second execution of prepared statement +CREATE TABLE t1 ( +col_int_nokey INT, +col_int_key INT, +col_varchar_key VARCHAR(1) +); +INSERT INTO t1 VALUES +(1,7,'v'), (7,0,'s'), (4,9,'l'), (7,3,'y'), +(2,2,'i'), (9,5,'h'), (0,1,'a'), (9,3,'v'); +CREATE VIEW v1 AS SELECT * FROM t1; +SELECT * +FROM t1 +WHERE col_int_key IN ( +SELECT alias1.col_int_nokey AS field1 +FROM v1 AS alias1 +WHERE alias1.col_varchar_key < 'v' +); +col_int_nokey col_int_key col_varchar_key +1 7 v +2 2 i +4 9 l +7 0 s +prepare stmt FROM "SELECT * +FROM t1 +WHERE col_int_key IN ( +SELECT alias1.col_int_nokey AS field1 +FROM v1 AS alias1 +WHERE alias1.col_varchar_key < 'v' +)"; +execute stmt; +col_int_nokey col_int_key col_varchar_key +1 7 v +2 2 i +4 9 l +7 0 s +execute stmt; +col_int_nokey col_int_key col_varchar_key +1 7 v +2 2 i +4 9 l +7 0 s +DEALLOCATE PREPARE stmt; +DROP VIEW v1; +DROP TABLE t1; +# End of test for bug#13773979. +# +# BUG#13685026 ASSERTION CUR_SJ_INNER_TABLES == 0 IN +# --OPTIMIZE_TABLE_ORDER::CHOOSE_TABLE_ORDER +# +CREATE TABLE t1 ( +col_int_key INT(11) NOT NULL, +col_datetime_key DATETIME NOT NULL, +col_varchar_key VARCHAR(1) NOT NULL, +col_varchar_nokey VARCHAR(1) NOT NULL, +KEY col_int_key (col_int_key), +KEY col_datetime_key (col_datetime_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (0,'2002-02-13 17:30:06','j','j'); +INSERT INTO t1 VALUES (8,'2008-09-27 00:34:58','v','v'); +CREATE TABLE t2 ( +col_int_key INT(11) NOT NULL, +col_datetime_key DATETIME NOT NULL, +col_varchar_key VARCHAR(1) NOT NULL, +col_varchar_nokey VARCHAR(1) NOT NULL, +KEY col_int_key (col_int_key), +KEY col_datetime_key (col_datetime_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (7,'2003-08-21 00:00:00','b','b'); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +SET @old_depth=@@optimizer_search_depth; +SET optimizer_search_depth=4; +EXPLAIN SELECT col_datetime_key +FROM t1 as outr +WHERE col_datetime_key IN ( +SELECT alias1.col_datetime_key +FROM t1 AS alias1 +LEFT JOIN t1 as alias3 +STRAIGHT_JOIN ( t2 AS alias4 +JOIN t1 AS alias5 +ON alias5.col_varchar_key <= alias4.col_varchar_nokey ) +ON alias5.col_int_key < alias4.col_int_key +ON alias5.col_varchar_key = alias4.col_varchar_key +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE outr NULL index col_datetime_key col_datetime_key 5 NULL 2 100.00 Using index +1 SIMPLE alias1 NULL ref col_datetime_key col_datetime_key 5 test.outr.col_datetime_key 1 100.00 Using index +1 SIMPLE alias4 NULL ALL col_int_key,col_varchar_key NULL NULL NULL 1 100.00 NULL +1 SIMPLE alias5 NULL ref col_int_key,col_varchar_key col_varchar_key 6 test.alias4.col_varchar_key 1 100.00 Using where; Using index +1 SIMPLE alias3 NULL index NULL col_int_key 4 NULL 2 100.00 Using index; FirstMatch(outr) +Warnings: +Note 1003 /* select#1 */ select `test`.`outr`.`col_datetime_key` AS `col_datetime_key` from `test`.`t1` `outr` semi join (`test`.`t1` `alias1` left join (`test`.`t1` `alias3` join `test`.`t2` `alias4` join `test`.`t1` `alias5`) on(((`test`.`alias5`.`col_varchar_key` = `test`.`alias4`.`col_varchar_key`) and (`test`.`alias5`.`col_int_key` < `test`.`alias4`.`col_int_key`) and (`test`.`alias5`.`col_varchar_key` <= `test`.`alias4`.`col_varchar_nokey`)))) where (`test`.`alias1`.`col_datetime_key` = `test`.`outr`.`col_datetime_key`) +SELECT col_datetime_key +FROM t1 as outr +WHERE col_datetime_key IN ( +SELECT alias1.col_datetime_key +FROM t1 AS alias1 +LEFT JOIN t1 as alias3 +STRAIGHT_JOIN ( t2 AS alias4 +JOIN t1 AS alias5 +ON alias5.col_varchar_key <= alias4.col_varchar_nokey ) +ON alias5.col_int_key < alias4.col_int_key +ON alias5.col_varchar_key = alias4.col_varchar_key +); +col_datetime_key +2002-02-13 17:30:06 +2008-09-27 00:34:58 +DROP TABLE t1,t2; +SET @@optimizer_search_depth=@old_depth; +# +# BUG#13848789: SEGFAULT IN JOIN_READ_NEXT_SAME AT +# SQL/SQL_EXECUTOR.CC ON HAVING...IN...JOIN +# +CREATE TABLE t1 ( +col_int_key INT, +col_varchar_key VARCHAR(1), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4; +INSERT INTO t1 VALUES (8,'x'); +CREATE TABLE t2 ( +col_varchar_key VARCHAR(1), +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4; +INSERT INTO t2 VALUES ('x'), ('y'); +explain SELECT MIN(col_int_key) +FROM t1 as t1_outer +HAVING (1, 2) IN ( +SELECT t1_inner.col_int_key, MAX(t1_inner.col_int_key) +FROM t1 as t1_inner JOIN t2 +ON t2.col_varchar_key = t1_inner.col_varchar_key +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible HAVING +2 SUBQUERY t1_inner NULL system col_varchar_key NULL NULL NULL 1 100.00 NULL +2 SUBQUERY t2 NULL ref col_varchar_key col_varchar_key 7 const 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select min(`test`.`t1_outer`.`col_int_key`) AS `MIN(col_int_key)` from `test`.`t1` `t1_outer` having false +SELECT MIN(col_int_key) +FROM t1 as t1_outer +HAVING (1, 2) IN ( +SELECT t1_inner.col_int_key, MAX(t1_inner.col_int_key) +FROM t1 as t1_inner JOIN t2 +ON t2.col_varchar_key = t1_inner.col_varchar_key +); +MIN(col_int_key) +DROP TABLE t1,t2; +# Bug#13838810: Segfault in evaluate_null_complemented_join_record +CREATE TABLE t1 ( +pk int NOT NULL, +col_int_nokey int DEFAULT NULL, +col_int_key int DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t1 VALUES (10,NULL,8,'x'); +CREATE TABLE t2 ( +pk int NOT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +PRIMARY KEY (pk) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t2 VALUES (1,'x'); +CREATE TABLE t3 ( +pk int NOT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +PRIMARY KEY (pk), +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t3 VALUES +(1,'v','v'), (2,'v','v'), (3,'c','c'), (4,NULL,NULL); +EXPLAIN SELECT table1.pk,table2.pk, table3.pk +FROM t2 AS table1 +LEFT JOIN t1 AS table2 +LEFT JOIN t1 AS table3 +ON table3.col_int_key = table2.col_int_key +ON table3.pk = table2.col_int_nokey AND +table1.col_varchar_nokey IN ( +SELECT subquery3_t1.col_varchar_nokey +FROM t3 AS subquery3_t1 +LEFT JOIN t1 AS subquery3_t2 +ON subquery3_t2.col_varchar_key = subquery3_t1.col_varchar_key +WHERE subquery3_t2.col_int_nokey <> 9 +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE table1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE table2 NULL ALL col_int_key NULL NULL NULL 1 100.00 NULL +2 SIMPLE table3 NULL eq_ref PRIMARY,col_int_key PRIMARY 4 test.table2.col_int_nokey 1 100.00 Using where +2 SIMPLE subquery3_t2 NULL ALL col_varchar_key NULL NULL NULL 1 100.00 Using where +2 SIMPLE subquery3_t1 NULL ref col_varchar_key col_varchar_key 7 test.subquery3_t2.col_varchar_key 1 100.00 Using where; FirstMatch(table3) +Warnings: +Note 1003 /* select#1 */ select `test`.`table1`.`pk` AS `pk`,`test`.`table2`.`pk` AS `pk`,`test`.`table3`.`pk` AS `pk` from `test`.`t2` `table1` left join (`test`.`t1` `table2` join `test`.`t1` `table3` semi join (`test`.`t3` `subquery3_t1` join `test`.`t1` `subquery3_t2`)) on(((`test`.`table3`.`col_int_key` = `test`.`table2`.`col_int_key`) and (`test`.`subquery3_t1`.`col_varchar_key` = `test`.`subquery3_t2`.`col_varchar_key`) and (`test`.`subquery3_t1`.`col_varchar_nokey` = `test`.`table1`.`col_varchar_nokey`) and (`test`.`table3`.`pk` = `test`.`table2`.`col_int_nokey`) and (`test`.`subquery3_t2`.`col_int_nokey` <> 9))) where true +SELECT table1.pk,table2.pk, table3.pk +FROM t2 AS table1 +LEFT JOIN t1 AS table2 +LEFT JOIN t1 AS table3 +ON table3.col_int_key = table2.col_int_key +ON table3.pk = table2.col_int_nokey AND +table1.col_varchar_nokey IN ( +SELECT subquery3_t1.col_varchar_nokey +FROM t3 AS subquery3_t1 +LEFT JOIN t1 AS subquery3_t2 +ON subquery3_t2.col_varchar_key = subquery3_t1.col_varchar_key +WHERE subquery3_t2.col_int_nokey <> 9 +) +; +pk pk pk +1 NULL NULL +DROP TABLE t1, t2, t3; +Extra test case for specific code coverage +CREATE TABLE t1(pk INTEGER); +INSERT INTO t1 VALUES(1), (2); +explain SELECT * +FROM t1 AS ot1 LEFT JOIN t1 AS ot2 +ON ot1.pk=ot2.pk AND +ot2.pk IN +(SELECT it1.pk +FROM t1 AS it1 LEFT JOIN t1 AS it2 ON it1.pk=it2.pk); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE NULL eq_ref 5 test.ot2.pk 1 100.00 Using where +2 MATERIALIZED it1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED it2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`pk` AS `pk`,`test`.`ot2`.`pk` AS `pk` from `test`.`t1` `ot1` left join (`test`.`t1` `ot2` semi join (`test`.`t1` `it1` left join `test`.`t1` `it2` on((`test`.`it1`.`pk` = `test`.`it2`.`pk`)))) on(((`test`.`ot2`.`pk` = `test`.`ot1`.`pk`) and (``.`pk` = `test`.`ot1`.`pk`))) where true +SELECT * +FROM t1 AS ot1 LEFT JOIN t1 AS ot2 +ON ot1.pk=ot2.pk AND +ot2.pk IN +(SELECT it1.pk +FROM t1 AS it1 LEFT JOIN t1 AS it2 ON it1.pk=it2.pk); +pk pk +1 1 +2 2 +DROP TABLE t1; +# End of test for bug#13838810. +# +# Bug#13845930: Segfault in st_join_table::and_with_condition +# +CREATE TABLE t1 ( +col_int INTEGER +); +CREATE TABLE t2 ( +col_varchar_1 VARCHAR(1), +col_varchar_2 VARCHAR(1) +); +INSERT INTO t2 VALUES ('x','x'), ('c','c'); +PREPARE stmt FROM ' +SELECT alias2.col_varchar_2 AS field1 +FROM t2 AS alias1 + JOIN + (t2 AS alias2 + LEFT JOIN t2 AS alias3 + ON (8, 92) IN + (SELECT sq1_alias1.col_int, + sq1_alias2.col_int + FROM t1 AS sq1_alias1 JOIN t1 AS sq1_alias2 + ) + ) + ON alias3.col_varchar_1 = alias2.col_varchar_2 +'; +EXECUTE stmt; +field1 + +EXECUTE stmt; +field1 +DEALLOCATE prepare stmt; +DROP TABLE t1, t2; +# End of test for bug#13845930. +# +# Bug#13855925: Assert 'prebuilt->search_tuple->n_fields > 0' +# in ha_innobase::index_read +# +CREATE TABLE t1 ( +pk INTEGER AUTO_INCREMENT, +col_int_nokey INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk), +KEY (col_varchar_key) +) charset utf8mb4 ENGINE=INNODB; +INSERT INTO t1 ( +col_int_key, col_int_nokey, +col_varchar_key, col_varchar_nokey +) VALUES +(4, 2, 'v','v'), (62, 150, 'v','v'), (7, NULL, 'c','c'), (1, 2, NULL, NULL), +(0, 5, 'x','x'), (7, 3, 'i','i'), (7, 1, 'e','e'), (1, 4, 'p','p'), +(7, NULL, 's','s'), (1, 2, 'j','j'), (5, 6, 'z','z'), (2, 6, 'c','c'), +(0, 8, 'a','a'), (1, 2, 'q','q'), (8, 6, 'y','y'), (1, 8, NULL, NULL), +(1, 3, 'r','r'), (9, 3, 'v','v'), (1, 9, NULL, NULL), (5, 6, 'r','r'); +CREATE TABLE t2 ( +pk INT AUTO_INCREMENT, +col_int_nokey INT, +col_int_key INT, +PRIMARY KEY (pk), +KEY (col_int_key) +) charset utf8mb4 AUTO_INCREMENT=10 ENGINE=INNODB; +INSERT INTO t2 (col_int_key, col_int_nokey) VALUES +(8, NULL), (7, 8), (1, 1), (7, 9), (9, 4), (NULL, 3), (1, 2), (9, NULL), +(2, 2), (9, NULL), (2, 6), (4, 7), (0, 2), (4, 5), (8, 7), (NULL, 6), +(NULL, 6), (0, 2), (NULL, 9), (8, 6); +CREATE TABLE t3 ( +pk INT AUTO_INCREMENT, +col_varchar_key VARCHAR(1), +PRIMARY KEY (pk), +KEY (col_varchar_key) +) charset utf8mb4 ENGINE=INNODB; +INSERT INTO t3 (col_varchar_key) VALUES +('c'), ('c'), ('q'), ('g'), ('e'), ('l'), (NULL), ('c'), ('h'), ('d'), +('c'), ('i'), ('t'), ('g'), ('q'), ('l'), ('n'), ('z'), ('n'), ('r'), ('p'); +CREATE VIEW v1 AS +SELECT table2.col_varchar_nokey AS field1 +FROM t2 AS table1 +INNER JOIN (t1 AS table2 +STRAIGHT_JOIN t2 AS table3 +ON table3.col_int_key = table2.pk AND +table3.col_int_nokey = ANY +(SELECT subquery1_t2.col_int_nokey AS subquery1_field1 +FROM t2 AS subquery1_t1 +RIGHT OUTER JOIN t1 AS subquery1_t2 +INNER JOIN t1 AS subquery1_t3 +ON subquery1_t3.col_int_key = subquery1_t2.pk +ON subquery1_t3.col_varchar_key=subquery1_t2.col_varchar_nokey +WHERE subquery1_t1.pk > 1 +) +) +ON table3.col_int_key IN +(SELECT subquery2_t1.col_int_key AS subquery2_field1 +FROM t2 AS subquery2_t1 +RIGHT OUTER JOIN t3 AS subquery2_t2 +LEFT OUTER JOIN t1 AS subquery2_t3 +ON subquery2_t3.col_varchar_key = subquery2_t2.col_varchar_key +ON subquery2_t3.pk = subquery2_t2.pk +) +; +explain SELECT * FROM v1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE table1 NULL index NULL col_int_key 5 NULL 20 100.00 Using index +1 SIMPLE table2 NULL ALL PRIMARY NULL NULL NULL 20 100.00 Using join buffer (hash join) +1 SIMPLE table3 NULL ref col_int_key col_int_key 5 test.table2.pk 2 100.00 Using where; Using join buffer (Batched Key Access) +1 SIMPLE NULL eq_ref 5 test.table3.col_int_nokey 1 100.00 NULL +1 SIMPLE NULL eq_ref 5 test.table2.pk 1 100.00 NULL +4 MATERIALIZED subquery1_t3 NULL ALL col_varchar_key NULL NULL NULL 20 100.00 Using where +4 MATERIALIZED subquery1_t2 NULL eq_ref PRIMARY PRIMARY 4 test.subquery1_t3.col_int_key 1 10.00 Using where +4 MATERIALIZED subquery1_t1 NULL index PRIMARY col_int_key 5 NULL 20 100.00 Using where; Using index; Using join buffer (hash join) +3 MATERIALIZED subquery2_t3 NULL index PRIMARY,col_varchar_key col_varchar_key 7 NULL 20 100.00 Using where; Using index +3 MATERIALIZED subquery2_t2 NULL eq_ref PRIMARY,col_varchar_key PRIMARY 4 test.subquery2_t3.pk 1 7.14 Using where +3 MATERIALIZED subquery2_t1 NULL index col_int_key col_int_key 5 NULL 20 100.00 Using index; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `table2`.`col_varchar_nokey` AS `field1` from `test`.`t2` `table1` join `test`.`t1` `table2` straight_join `test`.`t2` `table3` semi join (`test`.`t1` `subquery1_t2` join `test`.`t1` `subquery1_t3` join `test`.`t2` `subquery1_t1`) semi join (`test`.`t3` `subquery2_t2` join `test`.`t1` `subquery2_t3` join `test`.`t2` `subquery2_t1`) where ((`subquery1_t2`.`pk` = `subquery1_t3`.`col_int_key`) and (`subquery1_t2`.`col_varchar_nokey` = `subquery1_t3`.`col_varchar_key`) and (`subquery2_t2`.`col_varchar_key` = `subquery2_t3`.`col_varchar_key`) and (`subquery2_t2`.`pk` = `subquery2_t3`.`pk`) and (`table3`.`col_int_key` = `table2`.`pk`) and (``.`subquery2_field1` = `table2`.`pk`) and (``.`subquery1_field1` = `table3`.`col_int_nokey`) and (`subquery1_t1`.`pk` > 1)) +SELECT * FROM v1; +field1 +v +v +v +v +v +v +v +v +v +v +v +v +v +v +v +v +v +v +v +v +DROP VIEW v1; +DROP TABLE t1,t2,t3; +# End of test for bug#13855925. +# +# Bug#13897959: Segfault in setup_semijoin_dups_elimination() +# +CREATE TABLE t1 ( +col_datetime_key DATETIME DEFAULT NULL, +KEY col_datetime_key (col_datetime_key) +) ENGINE=MyISAM; +INSERT INTO t1 VALUES +('2001-04-18 00:00:00'), ('2008-12-18 19:39:55'), +('2000-08-01 12:19:39'), ('2004-09-25 21:29:06'), +('2009-09-20 09:11:48'), ('2004-03-27 09:32:04'); +CREATE TABLE t2 ( +col_date_nokey date DEFAULT NULL, +col_time_key time DEFAULT NULL, +col_datetime_key datetime DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +KEY col_time_key (col_time_key), +KEY col_datetime_key (col_datetime_key), +KEY col_varchar_key(col_varchar_key) +) ENGINE=MyISAM; +INSERT INTO t2 VALUES ('1900-01-01',NULL,'2001-11-04 19:07:55','x','x'); +SELECT grandparent1.col_varchar_nokey +FROM t2 AS grandparent1 LEFT JOIN t1 USING (col_datetime_key) +WHERE grandparent1.col_varchar_nokey IN ( +SELECT col_varchar_nokey +FROM t2 AS parent1 +WHERE parent1.col_time_key > grandparent1.col_date_nokey +); +col_varchar_nokey +DROP TABLE t1, t2; +# End of test for bug#13897959. +# +# Bug#13898625 ASSERT `(REMAINING_TABLES_AFTER != 0) ...' IN +# BEST_EXTENSION_BY_LIMITED_SEARCH +# +CREATE TABLE t1 ( +pk int(11) NOT NULL, +col_int_nokey INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (26,6,NULL,'f','f'); +INSERT INTO t1 VALUES (29,6,8,'c','c'); +CREATE TABLE t2 ( +pk INT NOT NULL, +col_int_nokey INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +INSERT INTO t2 VALUES (1,2,4,'v','v'); +INSERT INTO t2 VALUES (2,150,62,'v','v'); +INSERT INTO t2 VALUES (5,5,0,'x','x'); +INSERT INTO t2 VALUES (6,3,7,'i','i'); +INSERT INTO t2 VALUES (7,1,7,'e','e'); +CREATE VIEW view_c AS SELECT * FROM t2; +PREPARE prep_stmt_7430 FROM 'SELECT SUM( alias1.col_varchar_key ) AS field1 +FROM t1 AS alias1 +RIGHT JOIN t2 AS alias2 +INNER JOIN t1 AS alias3 +ON (alias3.col_varchar_key = alias2.col_varchar_key ) +ON ( "v" ) IN ( +SELECT sq1_alias1.col_varchar_nokey AS sq1_field1 +FROM t1 AS sq1_alias1 +) +WHERE alias3.pk IN ( +SELECT sq2_alias1.col_int_key AS sq2_field1 +FROM ( view_c AS sq2_alias1, t1 AS sq2_alias2 ) +) +'; +EXECUTE prep_stmt_7430; +field1 +NULL +EXECUTE prep_stmt_7430; +field1 +NULL +EXPLAIN SELECT SUM( alias1.col_varchar_key ) AS field1 +FROM t1 AS alias1 +RIGHT JOIN t2 AS alias2 +INNER JOIN t1 AS alias3 +ON (alias3.col_varchar_key = alias2.col_varchar_key ) +ON ( "v" ) IN ( +SELECT sq1_alias1.col_varchar_nokey AS sq1_field1 +FROM t1 AS sq1_alias1 +) +WHERE alias3.pk IN ( +SELECT sq2_alias1.col_int_key AS sq2_field1 +FROM ( view_c AS sq2_alias1, t1 AS sq2_alias2 ) +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE alias3 NULL ALL PRIMARY,col_varchar_key NULL NULL NULL 2 100.00 Using where +1 SIMPLE sq2_alias2 NULL index NULL PRIMARY 4 NULL 2 100.00 Using index +1 SIMPLE t2 NULL ref col_int_key col_int_key 5 test.alias3.pk 2 100.00 Using index; FirstMatch(alias3) +1 SIMPLE alias2 NULL ref col_varchar_key col_varchar_key 7 test.alias3.col_varchar_key 2 100.00 Using index +1 SIMPLE alias1 NULL index NULL col_varchar_key 12 NULL 2 100.00 Using index +1 SIMPLE sq1_alias1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch(alias1) +Warnings: +Note 1003 /* select#1 */ select sum(`test`.`alias1`.`col_varchar_key`) AS `field1` from `test`.`t2` `alias2` join `test`.`t1` `alias3` left join (`test`.`t1` `alias1` semi join (`test`.`t1` `sq1_alias1`)) on(((`test`.`sq1_alias1`.`col_varchar_nokey` = 'v'))) semi join (`test`.`t2` join `test`.`t1` `sq2_alias2`) where ((`test`.`alias2`.`col_varchar_key` = `test`.`alias3`.`col_varchar_key`) and (`test`.`t2`.`col_int_key` = `test`.`alias3`.`pk`)) +PREPARE prep_stmt_7430 FROM 'SELECT SUM( alias1.col_varchar_key ) AS field1 +FROM t1 AS alias1 +RIGHT JOIN t2 AS alias2 +INNER JOIN t1 AS alias3 +ON (alias3.col_varchar_key = alias2.col_varchar_key ) +ON ( "v" ) IN ( +SELECT sq1_alias1.col_varchar_nokey AS sq1_field1 +FROM t1 AS sq1_alias1 +) +WHERE alias3.pk IN ( +SELECT sq2_alias1.col_int_key AS sq2_field1 +FROM ( view_c AS sq2_alias1 , t1 AS sq2_alias2 ) +WHERE sq2_alias1.col_varchar_nokey <> alias2.col_varchar_key +AND sq2_alias1.col_varchar_key < "l" + ) +'; +EXECUTE prep_stmt_7430; +field1 +NULL +EXECUTE prep_stmt_7430; +field1 +NULL +EXPLAIN SELECT SUM( alias1.col_varchar_key ) AS field1 +FROM t1 AS alias1 +RIGHT JOIN t2 AS alias2 +INNER JOIN t1 AS alias3 +ON (alias3.col_varchar_key = alias2.col_varchar_key ) +ON ( "v" ) IN ( +SELECT sq1_alias1.col_varchar_nokey AS sq1_field1 +FROM t1 AS sq1_alias1 +) +WHERE alias3.pk IN ( +SELECT sq2_alias1.col_int_key AS sq2_field1 +FROM ( view_c AS sq2_alias1 , t1 AS sq2_alias2 ) +WHERE sq2_alias1.col_varchar_nokey <> alias2.col_varchar_key +AND sq2_alias1.col_varchar_key < "l" + ) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE alias3 NULL ALL PRIMARY,col_varchar_key NULL NULL NULL 2 100.00 Using where; Start temporary +1 SIMPLE t2 NULL ref col_int_key,col_varchar_key col_int_key 5 test.alias3.pk 2 40.00 Using where; Using join buffer (Batched Key Access) +1 SIMPLE alias2 NULL ref col_varchar_key col_varchar_key 7 test.alias3.col_varchar_key 2 100.00 Using index +1 SIMPLE sq2_alias2 NULL index NULL PRIMARY 4 NULL 2 100.00 Using index; End temporary; Using join buffer (hash join) +1 SIMPLE alias1 NULL index NULL col_varchar_key 12 NULL 2 100.00 Using index +1 SIMPLE sq1_alias1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch(alias1) +Warnings: +Note 1276 Field or reference 'test.alias2.col_varchar_key' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select sum(`test`.`alias1`.`col_varchar_key`) AS `field1` from `test`.`t2` `alias2` join `test`.`t1` `alias3` left join (`test`.`t1` `alias1` semi join (`test`.`t1` `sq1_alias1`)) on(((`test`.`sq1_alias1`.`col_varchar_nokey` = 'v'))) semi join (`test`.`t2` join `test`.`t1` `sq2_alias2`) where ((`test`.`alias2`.`col_varchar_key` = `test`.`alias3`.`col_varchar_key`) and (`test`.`t2`.`col_int_key` = `test`.`alias3`.`pk`) and (`test`.`t2`.`col_varchar_nokey` <> `test`.`alias3`.`col_varchar_key`) and (`test`.`t2`.`col_varchar_key` < 'l')) +DROP TABLE t1,t2; +DROP VIEW view_c; +# +# Bug#13902463 SEGFAULT IN BITMAP<64U>::MERGE OR ADD_KEY_FIELD +# ON SECOND EXEC OF PREP STMT +# +CREATE TABLE t1 ( +pk INT, +col_int_nokey INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +KEY col_varchar_key (col_varchar_key) +); +CREATE VIEW view_b AS SELECT * FROM t1; +PREPARE prep_stmt_20421 FROM 'SELECT alias2.col_varchar_nokey AS field1 +FROM t1 AS alias1 +INNER JOIN t1 AS alias2 +ON (alias1.col_varchar_key = alias2.col_varchar_nokey +AND ( alias1.col_int_key ) IN ( +SELECT t1.col_int_nokey +FROM t1 +) +) +WHERE alias1.col_varchar_key IN ( +SELECT sq2_alias2.col_varchar_nokey AS sq2_field1 +FROM view_b AS sq2_alias1 +INNER JOIN t1 AS sq2_alias2 +ON (sq2_alias2.col_varchar_key = sq2_alias1.col_varchar_key ) +WHERE sq2_alias1.pk > alias2.pk +) +'; +EXECUTE prep_stmt_20421; +field1 +EXECUTE prep_stmt_20421; +field1 +EXPLAIN SELECT alias2.col_varchar_nokey AS field1 +FROM t1 AS alias1 +INNER JOIN t1 AS alias2 +ON (alias1.col_varchar_key = alias2.col_varchar_nokey +AND ( alias1.col_int_key ) IN ( +SELECT t1.col_int_nokey +FROM t1 +) +) +WHERE alias1.col_varchar_key IN ( +SELECT sq2_alias2.col_varchar_nokey AS sq2_field1 +FROM view_b AS sq2_alias1 +INNER JOIN t1 AS sq2_alias2 +ON (sq2_alias2.col_varchar_key = sq2_alias1.col_varchar_key ) +WHERE sq2_alias1.pk > alias2.pk +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.alias2.pk' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `field1` from `test`.`t1` `alias1` join `test`.`t1` `alias2` semi join (`test`.`t1`) semi join (`test`.`t1` join `test`.`t1` `sq2_alias2`) where ((`test`.`t1`.`pk` > NULL) and multiple equal(NULL, `test`.`sq2_alias2`.`col_varchar_nokey`, NULL) and multiple equal(`test`.`sq2_alias2`.`col_varchar_key`, `test`.`t1`.`col_varchar_key`) and multiple equal(NULL, `test`.`t1`.`col_int_nokey`)) +ALTER TABLE t1 DROP INDEX col_varchar_key; +PREPARE prep_stmt_20421 FROM 'SELECT alias2.col_varchar_nokey AS field1 +FROM t1 AS alias1 +INNER JOIN t1 AS alias2 +ON (alias1.col_varchar_key = alias2.col_varchar_nokey +AND ( alias1.col_int_key ) IN ( +SELECT t1.col_int_nokey +FROM t1 +) +) +WHERE alias1.col_varchar_key IN ( +SELECT sq2_alias2.col_varchar_nokey AS sq2_field1 +FROM view_b AS sq2_alias1 +INNER JOIN t1 AS sq2_alias2 +ON (sq2_alias2.col_varchar_key = sq2_alias1.col_varchar_key ) +WHERE sq2_alias1.pk > alias2.pk +) +'; +EXECUTE prep_stmt_20421; +field1 +EXECUTE prep_stmt_20421; +field1 +EXPLAIN SELECT alias2.col_varchar_nokey AS field1 +FROM t1 AS alias1 +INNER JOIN t1 AS alias2 +ON (alias1.col_varchar_key = alias2.col_varchar_nokey +AND ( alias1.col_int_key ) IN ( +SELECT t1.col_int_nokey +FROM t1 +) +) +WHERE alias1.col_varchar_key IN ( +SELECT sq2_alias2.col_varchar_nokey AS sq2_field1 +FROM view_b AS sq2_alias1 +INNER JOIN t1 AS sq2_alias2 +ON (sq2_alias2.col_varchar_key = sq2_alias1.col_varchar_key ) +WHERE sq2_alias1.pk > alias2.pk +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.alias2.pk' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `field1` from `test`.`t1` `alias1` join `test`.`t1` `alias2` semi join (`test`.`t1`) semi join (`test`.`t1` join `test`.`t1` `sq2_alias2`) where ((`test`.`t1`.`pk` > NULL) and multiple equal(NULL, `test`.`sq2_alias2`.`col_varchar_nokey`, NULL) and multiple equal(`test`.`sq2_alias2`.`col_varchar_key`, `test`.`t1`.`col_varchar_key`) and multiple equal(NULL, `test`.`t1`.`col_int_nokey`)) +DROP TABLE t1; +DROP VIEW view_b; +# +# Bug#13907277: Segfault in evaluate_null_complemented_join_record +# +CREATE TABLE t1 ( +pk INTEGER, +col_varchar_nokey VARCHAR(1), +col_varchar_key VARCHAR(1), +PRIMARY KEY (pk) +); +INSERT INTO t1 VALUES (1, 'x', 'x'); +CREATE TABLE t2 ( +pk INTEGER, +PRIMARY KEY (pk) +); +INSERT INTO t2 VALUES (1); +CREATE TABLE t3 ( +pk INTEGER, +col_int_nokey INTEGER, +col_int_key INTEGER, +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk) +); +INSERT INTO t3 VALUES (1, 6, 5, 'r'); +explain SELECT outer_t1.pk, outer_t2.pk +FROM t3 AS outer_t1 +RIGHT JOIN t2 AS outer_t2 +ON outer_t1.col_int_nokey IN +(SELECT inner_t1.col_int_nokey +FROM t3 AS inner_t1 +LEFT JOIN t1 AS inner_t2 +INNER JOIN t1 AS inner_t3 +ON inner_t3.pk = inner_t2.pk +ON inner_t3.col_varchar_nokey = inner_t2.col_varchar_key +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE outer_t2 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE outer_t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE inner_t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE inner_t2 NULL ALL PRIMARY NULL NULL NULL 1 100.00 NULL +1 SIMPLE inner_t3 NULL eq_ref PRIMARY PRIMARY 4 test.inner_t2.pk 1 100.00 Using where; FirstMatch(outer_t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`outer_t1`.`pk` AS `pk`,'1' AS `pk` from left join (`test`.`t3` `outer_t1` semi join (`test`.`t3` `inner_t1` left join (`test`.`t1` `inner_t2` join `test`.`t1` `inner_t3`) on(((`test`.`inner_t3`.`col_varchar_nokey` = `test`.`inner_t2`.`col_varchar_key`) and (`test`.`inner_t3`.`pk` = `test`.`inner_t2`.`pk`))))) on(((`test`.`inner_t1`.`col_int_nokey` = `test`.`outer_t1`.`col_int_nokey`))) where true +SELECT outer_t1.pk, outer_t2.pk +FROM t3 AS outer_t1 +RIGHT JOIN t2 AS outer_t2 +ON outer_t1.col_int_nokey IN +(SELECT inner_t1.col_int_nokey +FROM t3 AS inner_t1 +LEFT JOIN t1 AS inner_t2 +INNER JOIN t1 AS inner_t3 +ON inner_t3.pk = inner_t2.pk +ON inner_t3.col_varchar_nokey = inner_t2.col_varchar_key +); +pk pk +1 1 +DROP TABLE t1, t2, t3; +# End of test for bug#13907277. +# +# Bug#13955713: Assert 'JOIN->best_read < ...' on second execution +# +CREATE TABLE t1 ( +pk INTEGER, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1) +); +PREPARE stmt FROM " +SELECT MIN(alias2.col_varchar_key) AS field1 +FROM t1 AS alias1 + INNER JOIN (t1 AS alias2 + INNER JOIN t1 AS alias3 + ON 8 IN + (SELECT sq1_alias1.pk AS sq1_field2 + FROM t1 AS sq1_alias1 + WHERE 9 IN + (SELECT SUM(t1_sq1_alias1.pk) AS t1_sq1_field2 + FROM t1 AS t1_sq1_alias1 + ) + ) + ) + ON alias3.col_varchar_nokey = alias2.col_varchar_key +WHERE EXISTS + (SELECT sq2_alias1.pk AS sq2_field1 + FROM t1 AS sq2_alias1 + WHERE sq2_alias1.col_varchar_key < alias1.col_varchar_nokey + ) +"; +EXECUTE stmt; +field1 +NULL + +EXECUTE stmt; +field1 +NULL +DEALLOCATE PREPARE stmt; +DROP TABLE t1; +# End of test for bug#13955713. +# +# Bug#13956813: Segfault in memcpy from Join_cache::write_record_data() +# +CREATE TABLE t1 ( +pk INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1) +) charset latin1; +CREATE TABLE t2 ( +pk INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1) +) charset latin1; +INSERT INTO t2 VALUES +(10,'j','j'), (11,'z','z'), (12,'c','c'), (13,'a','a'), +(14,'q','q'), (15,'y','y'), (16,NULL,NULL), (17,'r','r'), +(18,'v','v'), (19,NULL,NULL), (20,'r','r'); +CREATE TABLE t3 ( +pk INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +KEY col_int_key (col_int_key) +) charset latin1; +INSERT INTO t3 VALUES +(15,NULL,'u'), (16,1,'m'), (17,9,NULL), (18,2,'o'), +(19,9,'w'), (20,2,'m'), (21,4,'q'), (22,0,NULL), +(23,4,'d'), (24,8,'g'), (25,NULL,'x'), (26,NULL,'f'), +(27,0,'p'), (28,NULL,'j'), (29,8,'c'); +CREATE VIEW view_inline_0 AS +SELECT t1.* +FROM t1 INNER JOIN t3 +ON t1.pk = t3.pk; +CREATE VIEW view_inline_1 AS +SELECT sq2_alias2.col_varchar_key AS sq2_field1, +sq2_alias1.col_varchar_key AS sq2_field2 +FROM t3 AS sq2_alias1 LEFT OUTER JOIN t3 AS sq2_alias2 +ON sq2_alias1.pk = sq2_alias2.col_int_key; +CREATE VIEW view_inline_2 AS +SELECT 'p', 'p' UNION SELECT 'k', 's'; +SET @optimizer_switch_saved= @@optimizer_switch; +SET @@optimizer_switch="derived_merge=off"; +explain SELECT SUM(alias1.col_varchar_nokey) AS field2 +FROM t2 AS alias2 +LEFT JOIN (SELECT * FROM view_inline_0) AS alias1 +ON alias2.col_varchar_key = alias1.col_varchar_key AND +(alias2.col_varchar_nokey, alias2.col_varchar_key) IN +(SELECT * FROM view_inline_1 +) +WHERE (alias1.col_varchar_key, alias1.col_varchar_nokey) IN +(SELECT * FROM view_inline_2 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL 2 100.00 NULL +1 PRIMARY alias2 NULL ALL NULL NULL NULL NULL 11 10.00 Using where; Using join buffer (hash join) +1 PRIMARY NULL ref 8 test.alias2.col_varchar_nokey,test.view_inline_2.p 3 100.00 Using index; FirstMatch(alias2) +1 PRIMARY NULL ref 8 test.view_inline_2.p,test.view_inline_2.Name_exp_p 2 100.00 NULL +7 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +8 UNION NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +NULL UNION RESULT NULL ALL NULL NULL NULL NULL NULL NULL Using temporary +6 DERIVED sq2_alias1 NULL ALL NULL NULL NULL NULL 15 100.00 NULL +6 DERIVED sq2_alias2 NULL ref col_int_key col_int_key 5 test.sq2_alias1.pk 2 100.00 Using join buffer (Batched Key Access) +2 DERIVED NULL ALL NULL NULL NULL NULL 15 100.00 NULL +5 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select sum(`alias1`.`col_varchar_nokey`) AS `field2` from `test`.`view_inline_2` join `test`.`t2` `alias2` join (/* select#2 */ select `test`.`view_inline_0`.`pk` AS `pk`,`test`.`view_inline_0`.`col_varchar_key` AS `col_varchar_key`,`test`.`view_inline_0`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`view_inline_0`) `alias1` semi join (`test`.`view_inline_1`) where ((`test`.`view_inline_1`.`sq2_field1` = `test`.`alias2`.`col_varchar_nokey`) and (`alias1`.`col_varchar_nokey` = `test`.`view_inline_2`.`Name_exp_p`) and (`test`.`alias2`.`col_varchar_key` = `test`.`view_inline_2`.`p`) and (`test`.`view_inline_1`.`sq2_field2` = `test`.`view_inline_2`.`p`) and (`alias1`.`col_varchar_key` = `test`.`view_inline_2`.`p`)) +SELECT SUM(alias1.col_varchar_nokey) AS field2 +FROM t2 AS alias2 +LEFT JOIN (SELECT * FROM view_inline_0) AS alias1 +ON alias2.col_varchar_key = alias1.col_varchar_key AND +(alias2.col_varchar_nokey, alias2.col_varchar_key) IN +(SELECT * FROM view_inline_1 +) +WHERE (alias1.col_varchar_key, alias1.col_varchar_nokey) IN +(SELECT * FROM view_inline_2 +); +field2 +NULL +SET @@optimizer_switch= @optimizer_switch_saved; +DROP VIEW view_inline_0, view_inline_1, view_inline_2; +DROP TABLE t1, t2, t3; +# End of test for bug#13956813. +# +# Bug#13974177: Assert !(tab->table->regginfo.not_exists_optimize... +# +CREATE TABLE t1 ( +pk INTEGER AUTO_INCREMENT, +col_int_nokey INTEGER, +col_int_key INTEGER, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk), +KEY (col_int_key), +KEY (col_varchar_key, col_int_key) +); +INSERT INTO t1(col_int_key, col_int_nokey, col_varchar_key, col_varchar_nokey) +VALUES +(0, 4, 'j', 'j'), (8, 6, 'v', 'v'), (1, 3, 'c', 'c'), (8, 5, 'm', 'm'), +(9, 3, 'd', 'd'), (24, 246, 'd', 'd'), (6, 2, 'y', 'y'), (1, 9, 't', 't'), +(6, 3, 'd', 'd'), (2, 8, 's', 's'), (4, 1, 'r', 'r'), (8, 8, 'm', 'm'), +(4, 8, 'b', 'b'), (4, 5, 'x', 'x'), (7, 7, 'g', 'g'), (4, 5, 'p', 'p'), +(1, 1, 'q', 'q'), (9, 6, 'w', 'w'), (4, 2, 'd', 'd'), (8, 9, 'e', 'e'); +CREATE TABLE t2 ( +pk INTEGER AUTO_INCREMENT, +col_int_nokey INTEGER NOT NULL, +col_time_key TIME NOT NULL, +col_time_nokey TIME NOT NULL, +PRIMARY KEY (pk), +KEY (col_time_key) +) ENGINE=InnoDB; +INSERT INTO t2 (col_int_nokey, col_time_key, col_time_nokey) VALUES +(7, '00:00:00', '00:00:00'), (0, '00:00:00', '00:00:00'), +(9, '06:35:17', '06:35:17'), (3, '18:07:14', '18:07:14'), +(4, '20:36:52', '20:36:52'), (2, '21:29:07', '21:29:07'), +(5, '23:45:57', '23:45:57'), (3, '22:54:57', '22:54:57'), +(1, '18:45:09', '18:45:09'), (3, '14:30:46', '14:30:46'), +(6, '19:23:43', '19:23:43'), (7, '03:39:30', '03:39:30'), +(5, '23:37:52', '23:37:52'), (1, '16:59:30', '16:59:30'), +(204, '22:21:15', '22:21:15'), (224, '12:24:37', '12:24:37'), +(9, '15:02:08', '15:02:08'), (5, '23:59:59', '23:59:59'), +(0, '08:23:30', '08:23:30'), (3, '08:32:22', '08:32:22'); +explain SELECT ot1.col_int_key AS x +FROM t1 AS ot2 +LEFT JOIN t1 AS ot1 +ON ot2.col_varchar_nokey > ot1.col_varchar_key +WHERE (ot1.col_int_nokey, ot1.pk) IN +(SELECT it1.pk AS x, +it1.col_int_nokey AS y +FROM t2 AS it2 +LEFT JOIN t2 AS it1 +ON it2.col_time_nokey = it1.col_time_key +) AND ot1.pk IS NULL +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`col_int_key` AS `x` from `test`.`t2` `it1` join `test`.`t1` `ot2` join `test`.`t1` `ot1` semi join (`test`.`t2` `it2`) where ((`test`.`ot1`.`pk` is null) and (`test`.`ot2`.`col_varchar_nokey` > `test`.`ot1`.`col_varchar_key`) and multiple equal(`test`.`ot1`.`col_int_nokey`, `test`.`it1`.`pk`) and multiple equal(`test`.`ot1`.`pk`, `test`.`it1`.`col_int_nokey`) and multiple equal(`test`.`it2`.`col_time_nokey`, `test`.`it1`.`col_time_key`)) +SELECT ot1.col_int_key AS x +FROM t1 AS ot2 +LEFT JOIN t1 AS ot1 +ON ot2.col_varchar_nokey > ot1.col_varchar_key +WHERE (ot1.col_int_nokey, ot1.pk) IN +(SELECT it1.pk AS x, +it1.col_int_nokey AS y +FROM t2 AS it2 +LEFT JOIN t2 AS it1 +ON it2.col_time_nokey = it1.col_time_key +) AND ot1.pk IS NULL +; +x +DROP TABLE t1, t2; +# End of test for bug#13974177. +# +# Bug#13971022: Assert 'keyparts > 0' failed in create_ref_for_key... +# +CREATE TABLE t1 ( +pk INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +PRIMARY KEY (pk), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +CREATE TABLE t2 ( +pk INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk) +) charset utf8mb4 ENGINE=InnoDB; +CREATE TABLE t3 ( +i INT +); +SET @optimizer_switch_saved= @@optimizer_switch; +SET @@optimizer_switch="derived_merge=off"; +explain SELECT table1.pk AS field1 +FROM ( SELECT subquery1_t1. * +FROM t2 AS subquery1_t1 +JOIN t2 AS subquery1_t2 +ON subquery1_t2.pk = subquery1_t1.pk) AS table1 +STRAIGHT_JOIN t2 AS table2 +ON table1.col_int_key IN (SELECT 7 FROM t3) +WHERE table1.col_varchar_nokey IN +(SELECT subquery3_t1.col_varchar_key AS subquery3_field1 +FROM t1 AS subquery3_t1 +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY subquery3_t1 NULL index col_varchar_key col_varchar_key 12 NULL 0 0.00 Using where; Using index; LooseScan +1 PRIMARY NULL ref 7 test.subquery3_t1.col_varchar_key 2 100.00 NULL +1 PRIMARY t3 NULL ALL NULL NULL NULL NULL 0 0.00 FirstMatch(); Using join buffer (hash join) +1 PRIMARY table2 NULL index NULL PRIMARY 4 NULL 1 100.00 Using index; Using join buffer (hash join) +2 DERIVED subquery1_t1 NULL ALL PRIMARY NULL NULL NULL 1 100.00 Using where +2 DERIVED subquery1_t2 NULL eq_ref PRIMARY PRIMARY 4 test.subquery1_t1.pk 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `table1`.`pk` AS `field1` from (/* select#2 */ select `test`.`subquery1_t1`.`pk` AS `pk`,`test`.`subquery1_t1`.`col_int_key` AS `col_int_key`,`test`.`subquery1_t1`.`col_varchar_key` AS `col_varchar_key`,`test`.`subquery1_t1`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t2` `subquery1_t1` join `test`.`t2` `subquery1_t2` where ((`test`.`subquery1_t1`.`col_int_key` = 7) and (`test`.`subquery1_t2`.`pk` = `test`.`subquery1_t1`.`pk`))) `table1` straight_join `test`.`t2` `table2` semi join (`test`.`t3`) semi join (`test`.`t1` `subquery3_t1`) where (`table1`.`col_varchar_nokey` = `test`.`subquery3_t1`.`col_varchar_key`) +SELECT table1.pk AS field1 +FROM ( SELECT subquery1_t1. * +FROM t2 AS subquery1_t1 +JOIN t2 AS subquery1_t2 +ON subquery1_t2.pk = subquery1_t1.pk) AS table1 +STRAIGHT_JOIN t2 AS table2 +ON table1.col_int_key IN (SELECT 7 FROM t3) +WHERE table1.col_varchar_nokey IN +(SELECT subquery3_t1.col_varchar_key AS subquery3_field1 +FROM t1 AS subquery3_t1 +) +; +field1 +SET @@optimizer_switch= @optimizer_switch_saved; +DROP TABLE t1, t2, t3; +# End of test for bug#13971022. +# +# Bug#13623473 "MISSING ROWS ON SELECT AND JOIN WITH +# TIME/DATETIME COMPARE" - Subquery part of test. +# +SET TIMESTAMP=UNIX_TIMESTAMP('2012-01-31 10:14:35'); +CREATE TABLE t1 ( +pk INT NOT NULL, +col_int_nokey INT, +col_int_key INT NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +) ENGINE=InnoDB; +INSERT INTO t1 VALUES (10,1,7), (11,7,0), (12,4,9), (13,7,3), +(14,0,4), (15,2,2), (16,9,5), (17,4,3), (18,0,1), (19,9,3), (20,1,6), +(21,3,7), (22,8,5), (23,8,1), (24,18,204), (25,84,224), (26,6,9), +(27,3,5), (28,6,0), (29,6,3); +CREATE TABLE t2 ( +col_int_nokey INT NOT NULL, +col_datetime_key DATETIME NOT NULL, +col_varchar_key VARCHAR(1) NOT NULL, +KEY col_datetime_key (col_datetime_key), +KEY col_varchar_key (col_varchar_key) +) ENGINE=InnoDB; +INSERT INTO t2 VALUES (1,'2001-11-04 19:07:55','k'); +CREATE TABLE t3 ( +col_time_key TIME, +KEY col_time_key (col_time_key) +) ENGINE=InnoDB; +INSERT INTO t3 VALUES ('21:22:34'), ('10:50:38'), ('00:21:38'), +('04:08:02'), ('16:25:11'), ('10:14:58'), ('19:47:59'), ('11:14:24'), +('00:00:00'), ('00:00:00'), ('15:57:25'), ('07:05:51'), ('19:22:21'), +('03:53:16'), ('09:16:38'), ('15:37:26'), ('00:00:00'), ('05:03:03'), +('02:59:24'), ('00:01:58'); +EXPLAIN SELECT outr.col_int_nokey +FROM t2 as outr +STRAIGHT_JOIN t3 AS outr2 +ON outr2.col_time_key > outr.col_datetime_key +WHERE outr.col_int_nokey IN ( +SELECT col_int_key +FROM t1 AS innr +WHERE innr.pk >= innr.col_int_nokey +) AND ( +outr.col_int_nokey <= 6 +OR +outr.col_varchar_key IS NULL +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE outr NULL ALL col_datetime_key NULL NULL NULL 1 100.00 Using where +2 SIMPLE innr NULL ref col_int_key col_int_key 4 test.outr.col_int_nokey 1 33.33 Using where; FirstMatch(outr); Using join buffer (Batched Key Access) +2 SIMPLE outr2 NULL index col_time_key col_time_key 4 NULL 20 33.33 Using where; Using index; Using join buffer (hash join) +Warnings: +Warning 1739 Cannot use range access on index 'col_time_key' due to type or collation conversion on field 'col_time_key' +Note 1003 /* select#1 */ select `test`.`outr`.`col_int_nokey` AS `col_int_nokey` from `test`.`t2` `outr` straight_join `test`.`t3` `outr2` semi join (`test`.`t1` `innr`) where ((`test`.`innr`.`col_int_key` = `test`.`outr`.`col_int_nokey`) and (`test`.`outr`.`col_int_nokey` <= 6) and (`test`.`innr`.`pk` >= `test`.`innr`.`col_int_nokey`) and (cast(`test`.`outr2`.`col_time_key` as datetime) > `test`.`outr`.`col_datetime_key`)) +SELECT outr.col_int_nokey +FROM t2 as outr +STRAIGHT_JOIN t3 AS outr2 +ON outr2.col_time_key > outr.col_datetime_key +WHERE outr.col_int_nokey IN ( +SELECT col_int_key +FROM t1 AS innr +WHERE innr.pk >= innr.col_int_nokey +) AND ( +outr.col_int_nokey <= 6 +OR +outr.col_varchar_key IS NULL +); +col_int_nokey +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +DROP TABLE t1,t2,t3; +SET TIMESTAMP = DEFAULT; +# End of test for bug#13623473. +# +# Bug#13980954: Missing data on left join + null value + where..in +# +CREATE TABLE t1 ( +ik INT, +vc varchar(1) +) charset utf8mb4; +INSERT INTO t1 VALUES (8, 'x'), (NULL, 'x'); +CREATE TABLE t2 ( +ik INT, +vc varchar(1) +) charset utf8mb4; +INSERT INTO t2 VALUES +(0, 'x'), (7, 'i'), (7, 'e'), (1, 'p'), (7, 's'), (1, 'j'); +explain format=json SELECT t2.vc, t2.ik AS t2_ik, t1.ik AS t1_ik +FROM t2 LEFT JOIN t1 ON t2.vc=t1.vc +WHERE t2.vc IN (SELECT vc FROM t2 AS t3); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "6.12" + }, + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 6, + "rows_produced_per_join": 6, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "0.60", + "prefix_cost": "1.11", + "data_read_per_join": "96" + }, + "used_columns": [ + "ik", + "vc" + ], + "attached_condition": "(`test`.`t2`.`vc` is not null)" + } + }, + { + "table": { + "table_name": "", + "access_type": "eq_ref", + "key": "", + "key_length": "7", + "ref": [ + "test.t2.vc" + ], + "rows_examined_per_scan": 1, + "materialized_from_subquery": { + "using_temporary_table": true, + "query_block": { + "table": { + "table_name": "t3", + "access_type": "ALL", + "rows_examined_per_scan": 6, + "rows_produced_per_join": 6, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "0.60", + "prefix_cost": "1.11", + "data_read_per_join": "96" + }, + "used_columns": [ + "vc" + ] + } + } + } + } + }, + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 12, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "1.20", + "prefix_cost": "6.12", + "data_read_per_join": "192" + }, + "used_columns": [ + "ik", + "vc" + ], + "attached_condition": "(is_not_null_compl(t1), (`test`.`t1`.`vc` = `test`.`t2`.`vc`), true)" + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`vc` AS `vc`,`test`.`t2`.`ik` AS `t2_ik`,`test`.`t1`.`ik` AS `t1_ik` from `test`.`t2` left join `test`.`t1` on((`test`.`t1`.`vc` = `test`.`t2`.`vc`)) semi join (`test`.`t2` `t3`) where (``.`vc` = `test`.`t2`.`vc`) +SELECT t2.vc, t2.ik AS t2_ik, t1.ik AS t1_ik +FROM t2 LEFT JOIN t1 ON t2.vc=t1.vc +WHERE t2.vc IN (SELECT vc FROM t2 AS t3); +vc t2_ik t1_ik +e 7 NULL +i 7 NULL +j 1 NULL +p 1 NULL +s 7 NULL +x 0 8 +x 0 NULL +DROP TABLE t1, t2; +# End of test for bug#13980954. +# +# Bug#14048292: Segfault in Item_field::result_type on 2nd execution +# of prep stmt with join of view +# +CREATE TABLE t1 ( +col_int INT +); +INSERT INTO t1 VALUES (0), (1); +CREATE VIEW view_t1 AS SELECT * FROM t1; +explain SELECT alias1.col_int +FROM t1 AS alias1 +LEFT JOIN view_t1 AS alias2 +ON alias1.col_int IN +(SELECT sq1_alias1.col_int +FROM t1 AS sq1_alias1 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE alias1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE sq1_alias1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`alias1`.`col_int` AS `col_int` from `test`.`t1` `alias1` left join (`test`.`t1` semi join (`test`.`t1` `sq1_alias1`)) on(((`test`.`sq1_alias1`.`col_int` = `test`.`alias1`.`col_int`))) where true +PREPARE stmt FROM "SELECT alias1.col_int +FROM t1 AS alias1 +LEFT JOIN view_t1 AS alias2 +ON alias1.col_int IN +(SELECT sq1_alias1.col_int +FROM t1 AS sq1_alias1 +)"; +EXECUTE stmt; +col_int +0 +0 +1 +1 + +EXECUTE stmt; +col_int +0 +0 +1 +1 +DEALLOCATE PREPARE stmt; +DROP VIEW view_t1; +DROP TABLE t1; +# End of test for bug#14048292. +# +# Bug#14064201: Missing data on join of derived table + WHERE .. IN +# with two operands +# +CREATE TABLE t1 ( +col_varchar_nokey VARCHAR(1) +) charset utf8mb4; +INSERT INTO t1 VALUES +('v'), ('s'), ('l'), ('y'), ('c'), ('i'), ('h'), ('q'), ('a'), ('v'), +('u'), ('s'), ('y'), ('z'), ('h'), ('p'), ('e'), ('i'), ('y'), ('w'); +CREATE TABLE t2 ( +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +KEY col_varchar_key(col_varchar_key) +) charset utf8mb4; +INSERT INTO t2 VALUES +('j','j'), ('v','v'), ('c','c'), ('m','m'), ('d','d'), ('d','d'), ('y','y'); +SET @optimizer_switch_saved= @@optimizer_switch; +SET @@optimizer_switch="derived_merge=off"; +explain format=json SELECT * +FROM (SELECT * FROM t2) AS derived1 +LEFT JOIN t1 +USING (col_varchar_nokey) +WHERE (col_varchar_nokey, col_varchar_nokey) IN +(SELECT col_varchar_nokey, col_varchar_key +FROM t2 AS derived2 +); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "13.03" + }, + "nested_loop": [ + { + "table": { + "table_name": "", + "access_type": "ALL", + "attached_condition": "((``.`col_varchar_key` = ``.`col_varchar_nokey`) and (``.`col_varchar_nokey` is not null))", + "materialized_from_subquery": { + "using_temporary_table": true, + "query_block": { + "table": { + "table_name": "derived2", + "access_type": "ALL", + "possible_keys": [ + "col_varchar_key" + ], + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "0.70", + "prefix_cost": "1.21", + "data_read_per_join": "112" + }, + "used_columns": [ + "col_varchar_key", + "col_varchar_nokey" + ], + "attached_condition": "(`test`.`derived2`.`col_varchar_key` = `test`.`derived2`.`col_varchar_nokey`)" + } + } + } + } + }, + { + "table": { + "table_name": "derived1", + "access_type": "ref", + "possible_keys": [ + "" + ], + "key": "", + "used_key_parts": [ + "col_varchar_nokey" + ], + "key_length": "7", + "ref": [ + ".col_varchar_nokey" + ], + "rows_examined_per_scan": 2, + "rows_produced_per_join": 2, + "filtered": "100.00", + "cost_info": { + "read_cost": "3.50", + "eval_cost": "0.20", + "prefix_cost": "8.51", + "data_read_per_join": "32" + }, + "used_columns": [ + "col_varchar_key", + "col_varchar_nokey" + ], + "materialized_from_subquery": { + "using_temporary_table": true, + "dependent": false, + "cacheable": true, + "query_block": { + "select_id": 2, + "cost_info": { + "query_cost": "1.21" + }, + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "0.70", + "prefix_cost": "1.21", + "data_read_per_join": "112" + }, + "used_columns": [ + "col_varchar_key", + "col_varchar_nokey" + ] + } + } + } + } + }, + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 40, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.52", + "eval_cost": "4.00", + "prefix_cost": "13.03", + "data_read_per_join": "320" + }, + "used_columns": [ + "col_varchar_nokey" + ], + "attached_condition": "(is_not_null_compl(t1), (`test`.`t1`.`col_varchar_nokey` = `derived1`.`col_varchar_nokey`), true)" + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select `derived1`.`col_varchar_nokey` AS `col_varchar_nokey`,`derived1`.`col_varchar_key` AS `col_varchar_key` from (/* select#2 */ select `test`.`t2`.`col_varchar_key` AS `col_varchar_key`,`test`.`t2`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t2`) `derived1` left join `test`.`t1` on(((`test`.`t1`.`col_varchar_nokey` = `derived1`.`col_varchar_nokey`) and (`test`.`derived2`.`col_varchar_nokey` = `test`.`derived2`.`col_varchar_key`))) semi join (`test`.`t2` `derived2`) where ((``.`col_varchar_key` = ``.`col_varchar_nokey`) and (`derived1`.`col_varchar_nokey` = ``.`col_varchar_nokey`) and (`test`.`derived2`.`col_varchar_key` = `test`.`derived2`.`col_varchar_nokey`)) +SELECT * +FROM (SELECT * FROM t2) AS derived1 +LEFT JOIN t1 +USING (col_varchar_nokey) +WHERE (col_varchar_nokey, col_varchar_nokey) IN +(SELECT col_varchar_nokey, col_varchar_key +FROM t2 AS derived2 +); +col_varchar_nokey col_varchar_key +c c +d d +d d +j j +m m +v v +v v +y y +y y +y y +SET @@optimizer_switch= @optimizer_switch_saved; +DROP TABLE t1, t2; +CREATE TABLE t1 ( +col_int_nokey int NOT NULL, +col_int_key int NOT NULL, +KEY col_int_key (col_int_key) +); +INSERT INTO t1 VALUES +(1,7), (7,0), (4,9), (7,3), (0,4), (2,2), (9,5), (4,3), (0,1), (9,3), +(1,6), (3,7), (8,5), (8,1), (18,204), (84,224), (6,9), (3,5), (6,0), (6,3); +CREATE TABLE t2 ( +col_int_nokey int NOT NULL, +col_int_key int NOT NULL, +KEY col_int_key (col_int_key) +); +INSERT INTO t2 VALUES +(4,0), (6,8), (3,1), (5,8), (3,9), (246,24), (2,6), (9,1), (3,6), (8,2), +(1,4), (8,8), (8,4), (5,4), (7,7), (5,4), (1,1), (6,9), (2,4), (9,8); +explain format=json SELECT grandparent1.* +FROM t1 AS grandparent1 +LEFT JOIN t1 USING (col_int_nokey) +WHERE (col_int_nokey, col_int_nokey) IN +(SELECT col_int_nokey, col_int_key +FROM t2 +); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "50.53" + }, + "nested_loop": [ + { + "table": { + "table_name": "grandparent1", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 20, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "2.00", + "prefix_cost": "2.51", + "data_read_per_join": "320" + }, + "used_columns": [ + "col_int_nokey", + "col_int_key" + ] + } + }, + { + "table": { + "table_name": "", + "access_type": "eq_ref", + "key": "", + "key_length": "8", + "ref": [ + "test.grandparent1.col_int_nokey", + "test.grandparent1.col_int_nokey" + ], + "rows_examined_per_scan": 1, + "materialized_from_subquery": { + "using_temporary_table": true, + "query_block": { + "table": { + "table_name": "t2", + "access_type": "ALL", + "possible_keys": [ + "col_int_key" + ], + "rows_examined_per_scan": 20, + "rows_produced_per_join": 20, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "2.00", + "prefix_cost": "2.51", + "data_read_per_join": "320" + }, + "used_columns": [ + "col_int_nokey", + "col_int_key" + ], + "attached_condition": "(`test`.`t2`.`col_int_key` = `test`.`t2`.`col_int_nokey`)" + } + } + } + } + }, + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 400, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "40.00", + "prefix_cost": "50.53", + "data_read_per_join": "6K" + }, + "used_columns": [ + "col_int_nokey" + ], + "attached_condition": "(is_not_null_compl(t1), (`test`.`t1`.`col_int_nokey` = `test`.`grandparent1`.`col_int_nokey`), true)" + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`grandparent1`.`col_int_nokey` AS `col_int_nokey`,`test`.`grandparent1`.`col_int_key` AS `col_int_key` from `test`.`t1` `grandparent1` left join `test`.`t1` on(((`test`.`t1`.`col_int_nokey` = `test`.`grandparent1`.`col_int_nokey`) and (`test`.`t2`.`col_int_nokey` = `test`.`t2`.`col_int_key`))) semi join (`test`.`t2`) where ((``.`col_int_nokey` = `test`.`grandparent1`.`col_int_nokey`) and (``.`col_int_key` = `test`.`grandparent1`.`col_int_nokey`) and (`test`.`t2`.`col_int_key` = `test`.`t2`.`col_int_nokey`)) +SELECT grandparent1.* +FROM t1 AS grandparent1 +LEFT JOIN t1 USING (col_int_nokey) +WHERE (col_int_nokey, col_int_nokey) IN +(SELECT col_int_nokey, col_int_key +FROM t2 +); +col_int_nokey col_int_key +1 6 +1 6 +1 7 +1 7 +7 0 +7 0 +7 3 +7 3 +8 1 +8 1 +8 5 +8 5 +DROP TABLE t1, t2; +CREATE TABLE t1 ( +pk int, +col_int_key int, +col_datetime_key datetime, +col_varchar_key varchar(1), +col_varchar_nokey varchar(1), +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_datetime_key (col_datetime_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4 engine=MyISAM; +INSERT INTO t1 VALUES +(10,7,'2004-06-06 04:22:12','v','v'), (11,0,'2005-11-13 01:12:31','s','s'), +(12,9,'2002-05-04 01:50:00','l','l'), (13,3,'2004-10-27 10:28:45','y','y'), +(14,4,'2006-07-22 05:24:23','c','c'), (15,2,'2002-05-16 21:34:03','i','i'), +(16,5,'2008-04-17 10:45:30','h','h'), (17,3,'2009-04-21 02:58:02','q','q'), +(18,1,'2008-01-11 11:01:51','a','a'), (19,3,'1900-01-01 00:00:00','v','v'), +(20,6,'2007-05-17 18:24:57','u','u'), (21,7,'2007-08-07 00:00:00','s','s'), +(22,5,'2001-08-28 00:00:00','y','y'), (23,1,'2004-04-16 00:27:28','z','z'), +(24,204,'2005-05-03 07:06:22','h','h'), (25,224,'2009-03-11 17:09:50','p','p'), +(26,9,'2007-12-08 01:54:28','e','e'), (27,5,'2009-07-28 18:19:54','i','i'), +(28,0,'2008-06-08 00:00:00','y','y'), (29,3,'2005-02-09 09:20:26','w','w'); +CREATE TABLE t2 ( +pk int, +col_int_key int, +col_datetime_key datetime, +col_varchar_key varchar(1), +col_varchar_nokey varchar(1), +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_datetime_key (col_datetime_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4 engine=MyISAM; +INSERT INTO t2 VALUES +(1,0,'2002-02-13 17:30:06','j','j'), (2,8,'2008-09-27 00:34:58','v','v'), +(3,1,'2007-05-28 00:00:00','c','c'), (4,8,'2009-07-25 09:21:20','m','m'), +(5,9,'2002-01-16 00:00:00','d','d'), (6,24,'2006-10-12 04:32:53','d','d'), +(7,6,'2001-02-15 03:08:38','y','y'), (8,1,'2004-10-02 20:31:15','t','t'), +(9,6,'2002-08-20 22:48:00','d','d'), (10,2,'1900-01-01 00:00:00','s','s'), +(11,4,'2005-08-15 00:00:00','r','r'), (12,8,'1900-01-01 00:00:00','m','m'), +(13,4,'2008-05-16 08:09:06','b','b'), (14,4,'2001-01-20 12:47:23','x','x'), +(15,7,'2008-07-02 00:00:00','g','g'), (16,4,'1900-01-01 00:00:00','p','p'), +(17,1,'2002-12-08 11:34:58','q','q'), (18,9,'1900-01-01 00:00:00','w','w'), +(19,4,'1900-01-01 00:00:00','d','d'), (20,8,'2002-08-25 20:35:06','e','e'); +SELECT alias1.col_datetime_key +FROM t2 AS alias1 +RIGHT JOIN t2 AS alias2 +JOIN t2 AS alias3 +ON alias3.pk = alias2.pk +ON alias3.col_varchar_nokey = alias2.col_varchar_key OR +alias2.col_varchar_nokey +WHERE (alias2.col_varchar_key, alias2.col_varchar_key) IN +(SELECT sq2_alias2.col_varchar_key, sq2_alias1.col_varchar_nokey +FROM t1 AS sq2_alias1, t1 AS sq2_alias2 +WHERE sq2_alias2.col_int_key < 2); +col_datetime_key +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +2001-01-20 12:47:23 +2001-01-20 12:47:23 +2001-02-15 03:08:38 +2001-02-15 03:08:38 +2002-01-16 00:00:00 +2002-01-16 00:00:00 +2002-02-13 17:30:06 +2002-02-13 17:30:06 +2002-08-20 22:48:00 +2002-08-20 22:48:00 +2002-08-25 20:35:06 +2002-08-25 20:35:06 +2002-12-08 11:34:58 +2002-12-08 11:34:58 +2004-10-02 20:31:15 +2004-10-02 20:31:15 +2005-08-15 00:00:00 +2005-08-15 00:00:00 +2006-10-12 04:32:53 +2006-10-12 04:32:53 +2007-05-28 00:00:00 +2007-05-28 00:00:00 +2008-05-16 08:09:06 +2008-05-16 08:09:06 +2008-07-02 00:00:00 +2008-07-02 00:00:00 +2008-09-27 00:34:58 +2008-09-27 00:34:58 +2009-07-25 09:21:20 +2009-07-25 09:21:20 +ALTER TABLE t1 DISABLE KEYS; +ALTER TABLE t2 DISABLE KEYS; +explain format=json SELECT alias1.col_datetime_key +FROM t2 AS alias1 +RIGHT JOIN t2 AS alias2 +JOIN t2 AS alias3 +ON alias3.pk = alias2.pk +ON alias3.col_varchar_nokey = alias2.col_varchar_key OR +alias2.col_varchar_nokey +WHERE (alias2.col_varchar_key, alias2.col_varchar_key) IN +(SELECT sq2_alias2.col_varchar_key, sq2_alias1.col_varchar_nokey +FROM t1 AS sq2_alias1, t1 AS sq2_alias2 +WHERE sq2_alias2.col_int_key < 2); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "52.48" + }, + "nested_loop": [ + { + "table": { + "table_name": "", + "access_type": "ALL", + "attached_condition": "(``.`col_varchar_nokey` = ``.`col_varchar_key`)", + "materialized_from_subquery": { + "using_temporary_table": true, + "query_block": { + "nested_loop": [ + { + "table": { + "table_name": "sq2_alias2", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 6, + "filtered": "33.33", + "cost_info": { + "read_cost": "1.86", + "eval_cost": "0.67", + "prefix_cost": "2.53", + "data_read_per_join": "213" + }, + "used_columns": [ + "col_int_key", + "col_varchar_key" + ], + "attached_condition": "(`test`.`sq2_alias2`.`col_int_key` < 2)" + } + }, + { + "table": { + "table_name": "sq2_alias1", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 13, + "filtered": "10.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.53", + "eval_cost": "1.33", + "prefix_cost": "16.39", + "data_read_per_join": "426" + }, + "used_columns": [ + "col_varchar_nokey" + ], + "attached_condition": "(`test`.`sq2_alias1`.`col_varchar_nokey` = `test`.`sq2_alias2`.`col_varchar_key`)" + } + } + ] + } + } + } + }, + { + "table": { + "table_name": "alias2", + "access_type": "ALL", + "possible_keys": [ + "PRIMARY" + ], + "rows_examined_per_scan": 20, + "rows_produced_per_join": 2, + "filtered": "10.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.53", + "eval_cost": "0.20", + "prefix_cost": "47.25", + "data_read_per_join": "64" + }, + "used_columns": [ + "pk", + "col_varchar_key", + "col_varchar_nokey" + ], + "attached_condition": "(`test`.`alias2`.`col_varchar_key` = ``.`col_varchar_key`)" + } + }, + { + "table": { + "table_name": "alias3", + "access_type": "eq_ref", + "possible_keys": [ + "PRIMARY" + ], + "key": "PRIMARY", + "used_key_parts": [ + "pk" + ], + "key_length": "4", + "ref": [ + "test.alias2.pk" + ], + "rows_examined_per_scan": 1, + "rows_produced_per_join": 2, + "filtered": "100.00", + "using_join_buffer": "Batched Key Access", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.20", + "prefix_cost": "47.95", + "data_read_per_join": "64" + }, + "used_columns": [ + "pk", + "col_varchar_nokey" + ] + } + }, + { + "table": { + "table_name": "alias1", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 40, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.53", + "eval_cost": "4.00", + "prefix_cost": "52.48", + "data_read_per_join": "1K" + }, + "used_columns": [ + "col_datetime_key" + ], + "attached_condition": "(is_not_null_compl(alias1), ((`test`.`alias3`.`col_varchar_nokey` = `test`.`alias2`.`col_varchar_key`) or (0 <> `test`.`alias2`.`col_varchar_nokey`)), true)" + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`alias1`.`col_datetime_key` AS `col_datetime_key` from `test`.`t2` `alias2` join `test`.`t2` `alias3` left join `test`.`t2` `alias1` on((((`test`.`alias3`.`col_varchar_nokey` = `test`.`alias2`.`col_varchar_key`) and (`test`.`sq2_alias1`.`col_varchar_nokey` = `test`.`sq2_alias2`.`col_varchar_key`)) or (0 <> `test`.`alias2`.`col_varchar_nokey`))) semi join (`test`.`t1` `sq2_alias1` join `test`.`t1` `sq2_alias2`) where ((`test`.`alias3`.`pk` = `test`.`alias2`.`pk`) and (``.`col_varchar_nokey` = ``.`col_varchar_key`) and (`test`.`alias2`.`col_varchar_key` = ``.`col_varchar_key`) and (`test`.`sq2_alias1`.`col_varchar_nokey` = `test`.`sq2_alias2`.`col_varchar_key`) and (`test`.`sq2_alias2`.`col_int_key` < 2)) +SELECT alias1.col_datetime_key +FROM t2 AS alias1 +RIGHT JOIN t2 AS alias2 +JOIN t2 AS alias3 +ON alias3.pk = alias2.pk +ON alias3.col_varchar_nokey = alias2.col_varchar_key OR +alias2.col_varchar_nokey +WHERE (alias2.col_varchar_key, alias2.col_varchar_key) IN +(SELECT sq2_alias2.col_varchar_key, sq2_alias1.col_varchar_nokey +FROM t1 AS sq2_alias1, t1 AS sq2_alias2 +WHERE sq2_alias2.col_int_key < 2); +col_datetime_key +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +2001-01-20 12:47:23 +2001-01-20 12:47:23 +2001-02-15 03:08:38 +2001-02-15 03:08:38 +2002-01-16 00:00:00 +2002-01-16 00:00:00 +2002-02-13 17:30:06 +2002-02-13 17:30:06 +2002-08-20 22:48:00 +2002-08-20 22:48:00 +2002-08-25 20:35:06 +2002-08-25 20:35:06 +2002-12-08 11:34:58 +2002-12-08 11:34:58 +2004-10-02 20:31:15 +2004-10-02 20:31:15 +2005-08-15 00:00:00 +2005-08-15 00:00:00 +2006-10-12 04:32:53 +2006-10-12 04:32:53 +2007-05-28 00:00:00 +2007-05-28 00:00:00 +2008-05-16 08:09:06 +2008-05-16 08:09:06 +2008-07-02 00:00:00 +2008-07-02 00:00:00 +2008-09-27 00:34:58 +2008-09-27 00:34:58 +2009-07-25 09:21:20 +2009-07-25 09:21:20 +DROP TABLE t1, t2; +# End of test for bug#14064201. +# +# Bug#18223655:ASSERTION FAILED: (INT)IDX >= 0 +# && IDX < PARENT_JOIN->TABLES +# +CREATE TABLE b (d INT); +CREATE TABLE c (a INT, b INT,c INT,d BLOB NOT NULL); +SELECT(SELECT 1 +FROM b WHERE(SELECT 1 IN (SELECT 1 FROM b WHERE 1 NOT BETWEEN d AND 1) +FROM b) IN (SELECT d FROM c)) as cc FROM b; +cc +INSERT INTO b VALUE(1); +INSERT INTO c VALUES(1,2,3,'1'),(2,3,4,'1'),(3,4,5,'C'); +SELECT(SELECT d FROM b WHERE(SELECT d IN +(SELECT d FROM b WHERE 1 NOT BETWEEN d AND 1) FROM b) IN +(SELECT d FROM c)) as cc FROM c; +cc +1 +1 +1 +DROP TABLE b,c; +# +# Bug#18447874:WRONG RESULT COMING FROM SEMI-JOIN +# +CREATE TABLE b ( +d INT(11) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE c ( +d BLOB +) ; +CREATE TABLE d ( +b INT(11) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO b VALUES(1),(2),(4); +INSERT INTO c VALUES(1),(2),(3); +SELECT 1 FROM b WHERE (SELECT 1 FROM d ) IN (SELECT d FROM c) ; +1 +INSERT INTO d VALUES(2); +SELECT 1 FROM b WHERE (SELECT 1 FROM d ) IN (SELECT d FROM c) ; +1 +1 +1 +1 +DROP TABLE b,c,d; +# +# Bug#17292723:INCORRECT RESULT FOR (SELECT...) IN (SELECT...) STATEMENT +# +CREATE TABLE t1 ( +ID int(11) NOT NULL AUTO_INCREMENT, +id2 int(11) DEFAULT NULL, +id3 int(11) DEFAULT NULL, +id4 varchar(150) COLLATE utf8_spanish_ci NOT NULL, +id5 int(11) DEFAULT NULL, +PRIMARY KEY (ID), +KEY id2 (id2), +KEY id3 (id3), +KEY id5 (id5) +) ENGINE=InnoDB; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 3778 'utf8_spanish_ci' is a collation of the deprecated character set UTF8MB3. Please consider using UTF8MB4 with an appropriate collation instead. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES +(123,1,1,'1',NULL), +(124,1,1,'2',NULL), +(125,1,1,'4',NULL), +(126,1,1,'3',NULL), +(127,1,1,'6',NULL), +(128,1,1,'8',NULL); +CREATE TABLE t2 ( +id6 int(11) NOT NULL, +id7 int(11) NOT NULL, +PRIMARY KEY (id6,id7), +KEY id7 (id7) +) ENGINE=InnoDB; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (126,123),(130,123),(135,123); +SELECT ID +FROM t1 p0 +WHERE p0.id3=1 +AND ( (SELECT p1.id FROM t1 p1 WHERE p1.id=123) IN (SELECT p3.id FROM t2 +p2, t1 p3 WHERE p0.id=p2.id6 AND p2.id7=p3.id)); +ID +126 +DROP TABLE t1,t2; +set @@optimizer_switch=@old_opt_switch; +# End of 5.6 tests +# +# Bug#19336348 DEBUG CRASH AT SETUP_SEMIJOIN_DUPS_ELIMINATION IN SQL/SQL_SELECT.CC +# +CREATE TABLE t1 ( +col_varchar_nokey varchar(1) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t1 VALUES ('c'),(NULL),('x'); +CREATE TABLE t2 ( +pk int, +col_varchar_key varchar(1), +PRIMARY KEY (pk), +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t2 VALUES (10,'l'),(11,'p'); +ANALYZE TABLE t1,t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN SELECT 1 +FROM t1 AS outr +WHERE outr.col_varchar_nokey IN +( +SELECT innr.col_varchar_key +FROM t2 AS innr +WHERE innr.pk <= 7 +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE innr NULL index PRIMARY,col_varchar_key col_varchar_key 7 NULL 2 100.00 Using where; Using index; LooseScan +1 SIMPLE outr NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` `outr` semi join (`test`.`t2` `innr`) where ((`test`.`outr`.`col_varchar_nokey` = `test`.`innr`.`col_varchar_key`) and (`test`.`innr`.`pk` <= 7)) +SELECT 1 +FROM t1 AS outr +WHERE outr.col_varchar_nokey IN +( +SELECT innr.col_varchar_key +FROM t2 AS innr +WHERE innr.pk <= 7 +) +; +1 +DROP TABLE t1,t2; +# +# Bug#18174394 BLOBS: CRASH AFTER UNINITIALIZED VALUES IN ITEM_FIELD::STR_RESULT +# +CREATE TABLE t1(d BLOB, b BLOB); +INSERT INTO t1(d,b) VALUES ('aaaa',''),('bnbb',''); +SELECT 1 FROM t1 +WHERE (SELECT b FROM t1) IN (SELECT (d>=1) FROM t1); +ERROR 21000: Subquery returns more than 1 row +DROP TABLE t1; +# +# Bug#19779600: ASSERT FAILED IN REPLACE_SUBCONDITION WITH IN +# PREDICATE INSIDE IN PREDICATE +# +CREATE TABLE t(X INT) ENGINE=InnoDB; +INSERT INTO t VALUES (1); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +EXPLAIN SELECT 1 FROM t WHERE (1 IN (SELECT 1 FROM t)) IN (SELECT 1 FROM t); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 PRIMARY t NULL ALL NULL NULL NULL NULL 1 100.00 FirstMatch(t); Using join buffer (hash join) +2 SUBQUERY t NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t` semi join (`test`.`t`) where true +SELECT 1 FROM t WHERE (1 IN (SELECT 1 FROM t)) IN (SELECT 1 FROM t); +1 +1 +DROP TABLE t; +# +# Bug#19465034 ASSERT ON SETUP_SEMIJOIN_DUPS_ELIMINATION IN SQL/SQL_SELECT.CC +# +CREATE TABLE t1 ( +pk INTEGER NOT NULL, +i1 INTEGER NOT NULL, +PRIMARY KEY (pk) +) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1,1); +CREATE TABLE t2 ( +pk INTEGER NOT NULL, +c1 VARCHAR(1) NOT NULL, +PRIMARY KEY (pk), +KEY c1_key (c1) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t2 VALUES (1,'j'),(2,'v'),(3,'c'); +CREATE TABLE t3 ( +pk INTEGER NOT NULL, +c1 VARCHAR(1) NOT NULL, +PRIMARY KEY (pk), +KEY c1_key (c1) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t3 VALUES (10,'v'),(11,'s'); +ANALYZE TABLE t1, t2, t3; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +EXPLAIN SELECT * +FROM t1 JOIN t2 ON t1.i1 >= t2.pk +WHERE t2.c1 IN ( +SELECT t3.c1 +FROM t3 +WHERE t3.pk < 3 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t3 NULL index PRIMARY,c1_key c1_key 6 NULL 2 100.00 Using where; Using index; LooseScan +2 SIMPLE t2 NULL ref PRIMARY,c1_key c1_key 6 test.t3.c1 1 33.33 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`i1` AS `i1`,`test`.`t2`.`pk` AS `pk`,`test`.`t2`.`c1` AS `c1` from `test`.`t1` join `test`.`t2` semi join (`test`.`t3`) where ((`test`.`t2`.`c1` = `test`.`t3`.`c1`) and (`test`.`t3`.`pk` < 3) and (`test`.`t1`.`i1` >= `test`.`t2`.`pk`)) +SELECT * +FROM t1 JOIN t2 ON t1.i1 >= t2.pk +WHERE t2.c1 IN ( +SELECT t3.c1 +FROM t3 +WHERE t3.pk < 3 +); +pk i1 pk c1 +DROP TABLE t1,t2,t3; +# +# Bug#19586047: CRASH IN ARG_COMPARATOR::SET_CMP_FUNC +# +CREATE TABLE t1(x INT) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT 1 FROM t1 WHERE EXISTS(SELECT 1) IN (SELECT 1 FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 1 100.00 FirstMatch(t1); Using join buffer (hash join) +2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` semi join (`test`.`t1`) where true +SELECT 1 FROM t1 WHERE EXISTS(SELECT 1) IN (SELECT 1 FROM t1); +1 +1 +EXPLAIN SELECT 1 FROM t1 WHERE (SELECT 1, 2 FROM t1) IN (SELECT 1, 2 FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 1 100.00 FirstMatch(t1); Using join buffer (hash join) +2 SUBQUERY t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` semi join (`test`.`t1`) where true +SELECT 1 FROM t1 WHERE (SELECT 1, 2 FROM t1) IN (SELECT 1, 2 FROM t1); +1 +1 +EXPLAIN SELECT 1 FROM t1 WHERE +(SELECT 1, 2 FROM t1 WHERE x = 2) IN (SELECT 1, 2 FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +2 SUBQUERY t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` semi join (`test`.`t1`) where false +SELECT 1 FROM t1 WHERE +(SELECT 1, 2 FROM t1 WHERE x = 2) IN (SELECT 1, 2 FROM t1); +1 +DROP TABLE t1; +# +#Bug#20119743 ASSERTIONQEP_TAB->USE_ORDER() IN ENUM_NESTED_LOOP_STATE +# EVALUATE_JOIN_RECORD +# +CREATE TABLE t1 ( +pk int(11) NOT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +PRIMARY KEY (pk) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (1,'x'); +CREATE TABLE t2 ( +col_date_key date DEFAULT NULL, +col_int_key int(11) DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +KEY col_int_key (col_int_key), +KEY col_date_key (col_date_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES ('2000-12-03', 8, 'x', 'x'),('2008-05-03', 7, 'd', 'd'), +('2005-12-06', 1, 'r', 'r'),('2000-04-10', 7, 'f', 'f'), +('2002-11-05', 9, 'y', 'y'),('2000-09-06', NULL, 'u', 'u'), +(NULL, 1, 'm', 'm'),('2007-06-14', 9, NULL, NULL), +('2007-11-17', 2, 'o', 'o'),('2009-02-23', 9, 'w', 'w'), +('2007-01-08', 2, 'm', 'm'), ('2008-06-10', 4, 'q', 'q'), +('2002-10-20', 0, NULL, NULL),('2008-09-12', 4, 'd', 'd'), +('2006-06-16', 8, 'g', 'g'),('2004-09-18', NULL, 'x', 'x'), +('1900-01-01', NULL, 'f', 'f'),('2005-09-13', 0, 'p', 'p'), +('2007-04-09', NULL, 'j', 'j'),('2000-09-20', 8, 'c', 'c'); +CREATE TABLE t3 ( +pk int(11) NOT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +PRIMARY KEY (pk) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t3 VALUES (1, 'c'),(2, 'c'),(3, 'q'),(4, 'g'),(5, 'e'),(6, 'l'), +(7, NULL),(8, 'v'),(9, 'c'),(10, 'u'),(11, 'x'),(12, 'x'),(13, 'x'),(14, 'l'), +(15, 'e'),(16, 's'),(17, 'k'),(18, 'm'),(19, 'x'),(20, 's'); +ANALYZE TABLE t1,t2,t3; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +EXPLAIN SELECT r1.col_date_key +FROM t2 AS r1 +WHERE r1.col_int_key NOT IN +(SELECT ir2.pk +FROM t2 AS ir1 STRAIGHT_JOIN t1 AS ir2 +ON ir2.col_varchar_nokey = ir1.col_varchar_key +WHERE ir2.col_varchar_nokey > r1.col_varchar_nokey +AND ir2.pk IN +(SELECT iir2.pk +FROM t2 AS iir1 RIGHT JOIN t3 AS iir2 +ON iir2.col_varchar_nokey = iir1.col_varchar_key)) +ORDER BY r1.col_date_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY r1 NULL ALL NULL NULL NULL NULL 20 100.00 Using where; Using filesort +2 DEPENDENT SUBQUERY NULL ALL NULL NULL NULL NULL NULL 100.00 Using where +2 DEPENDENT SUBQUERY ir1 NULL index col_varchar_key col_varchar_key 12 NULL 20 100.00 Using where; Using index; Using join buffer (hash join) +2 DEPENDENT SUBQUERY ir2 NULL eq_ref PRIMARY PRIMARY 4 func 1 100.00 Using where; Full scan on NULL key +3 MATERIALIZED iir2 NULL eq_ref PRIMARY PRIMARY 4 func 1 100.00 Full scan on NULL key +3 MATERIALIZED iir1 NULL ref col_varchar_key col_varchar_key 7 test.iir2.col_varchar_nokey 1 100.00 Using index +SELECT r1.col_date_key +FROM t2 AS r1 +WHERE r1.col_int_key NOT IN +(SELECT ir2.pk +FROM t2 AS ir1 STRAIGHT_JOIN t1 AS ir2 +ON ir2.col_varchar_nokey = ir1.col_varchar_key +WHERE ir2.col_varchar_nokey > r1.col_varchar_nokey +AND ir2.pk IN +(SELECT iir2.pk +FROM t2 AS iir1 RIGHT JOIN t3 AS iir2 +ON iir2.col_varchar_nokey = iir1.col_varchar_key)) +ORDER BY r1.col_date_key; +col_date_key +2000-04-10 +2000-09-20 +2000-12-03 +2002-10-20 +2002-11-05 +2004-09-18 +2005-09-13 +2006-06-16 +2007-01-08 +2007-06-14 +2007-11-17 +2008-05-03 +2008-06-10 +2008-09-12 +2009-02-23 +SELECT COUNT(r1.col_date_key) AS COUNT_NUM +FROM t2 AS r1 +WHERE r1.col_int_key NOT IN +(SELECT ir2.pk +FROM t2 AS ir1 STRAIGHT_JOIN t1 AS ir2 +ON ir2.col_varchar_nokey = ir1.col_varchar_key +WHERE ir2.col_varchar_nokey > r1.col_varchar_nokey +AND ir2.pk IN +(SELECT iir2.pk +FROM t2 AS iir1 RIGHT JOIN t3 AS iir2 +ON iir2.col_varchar_nokey = iir1.col_varchar_key +WHERE iir2.pk<3)); +COUNT_NUM +15 +DROP TABLE t1,t2,t3; +# +# Bug#20554585 ASSERT JOIN()->TABLES == 0... IN JOIN_TAB::GET_SJ_STRATEGY ON SUBQUERY + VAR +# +CREATE TABLE t1 ( +pk int NOT NULL, +PRIMARY KEY (pk) +); +CREATE TABLE t2 ( +pk int NOT NULL, +col_int_key int, +col_varchar_key varchar(1), +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key) +); +CREATE TABLE t3 ( +pk int NOT NULL, +col_int_key int, +col_varchar_key varchar(1), +col_varchar varchar(1), +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key) +); +INSERT INTO t3 VALUES (1,4,'c','g'),(20,1,'i','p'); +CREATE TABLE t4 ( +col_int int +); +CREATE TABLE t5 ( +col_varchar_key varchar(1), +pk int NOT NULL, +col_int int, +PRIMARY KEY (pk), +KEY col_varchar_key (col_varchar_key) +); +SELECT table1.col_varchar_key AS field1 +FROM (t3 AS table1 +INNER JOIN ( +SELECT SUBQUERY1_t1.* +FROM (t1 AS SUBQUERY1_t1 +RIGHT JOIN (t2 AS SUBQUERY1_t2 +INNER JOIN t3 AS SUBQUERY1_t3 +ON (SUBQUERY1_t3.col_varchar_key = SUBQUERY1_t2.col_varchar_key) +) ON (SUBQUERY1_t3.col_int_key = SUBQUERY1_t2.pk) +) +WHERE SUBQUERY1_t2.col_varchar_key >= ANY ( +SELECT CHILD_SUBQUERY1_t2.col_varchar AS CHILD_SUBQUERY1_field1 +FROM (t2 AS CHILD_SUBQUERY1_t1 +LEFT OUTER JOIN t3 AS CHILD_SUBQUERY1_t2 +ON (CHILD_SUBQUERY1_t2.col_int_key = CHILD_SUBQUERY1_t1.col_int_key) +) +WHERE CHILD_SUBQUERY1_t1.pk >= SUBQUERY1_t2.pk +) +) AS table2 +ON (table2.pk = table1.pk) +) +WHERE (EXISTS (( +SELECT DISTINCT SUBQUERY2_t2.col_int AS SUBQUERY2_field1 +FROM (t4 AS SUBQUERY2_t1 +LEFT OUTER JOIN t5 AS SUBQUERY2_t2 +ON (SUBQUERY2_t2.pk = SUBQUERY2_t1.col_int) +) +WHERE SUBQUERY2_t2.col_varchar_key != @var4 +))) +AND table1.col_int_key < (35 + 192) +ORDER BY field1 +; +field1 +DROP TABLE t1, t2, t3, t4, t5; +# +# Bug#18892055: MISSING DATA ON SELECT ... IN WITH JOINS AND INNODB +# ENGINE +# +CREATE TABLE t1 ( +col_int_key INT, +pk INT NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +) ENGINE = INNODB; +INSERT INTO t1 VALUES +( 0, 3 ), +( 0, 4 ), +( 3, 1 ), +( 900000000, 2 ), +( 1368719360, 5 ), +( 1922236416, 6 ), +( 8,7 ); +CREATE TABLE t2 ( +pk INT NOT NULL, +col_int INT, +PRIMARY KEY (pk) +) ENGINE = INNODB; +INSERT INTO t2 VALUES +( 1, 3 ), +( 2, 2 ), +( 3, 8 ), +( 4, 7 ); +CREATE TABLE t3 ( +col_int_key INT, +col_int INT, +KEY (col_int_key) +) ENGINE = INNODB; +INSERT INTO t3 VALUES +( 5, 1 ), +( -1, -1 ), +( 300000000, 1 ), +( 8, 1 ); +CREATE TABLE t4 ( col_int_key INT ) ENGINE = INNODB; +INSERT INTO t4 VALUES +(0), +(3), +(8), +(900000000), +(1368719360), +(1922236416); +ANALYZE TABLE t1, t2, t3, t4; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +test.t4 analyze status OK +explain SELECT * +FROM t4 +WHERE (col_int_key) IN ( +SELECT t1.col_int_key +FROM t1 LEFT JOIN ( t2 JOIN t3 ON t3.col_int_key = t2.col_int ) USING ( pk ) +WHERE t3.col_int IS NULL +) +ORDER BY col_int_key +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index col_int_key col_int_key 5 NULL 7 100.00 Using index; Using temporary; Using filesort; Start temporary +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.pk 1 100.00 NULL +1 SIMPLE t3 NULL ALL col_int_key NULL NULL NULL 4 25.00 Using where +1 SIMPLE t4 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`col_int_key` AS `col_int_key` from `test`.`t4` semi join (`test`.`t1` left join (`test`.`t2` join `test`.`t3`) on(((`test`.`t1`.`pk` = `test`.`t2`.`pk`) and (`test`.`t3`.`col_int_key` = `test`.`t2`.`col_int`)))) where ((`test`.`t4`.`col_int_key` = `test`.`t1`.`col_int_key`) and (`test`.`t3`.`col_int` is null)) order by `test`.`t4`.`col_int_key` +explain format=tree SELECT * +FROM t4 +WHERE (col_int_key) IN ( +SELECT t1.col_int_key +FROM t1 LEFT JOIN ( t2 JOIN t3 ON t3.col_int_key = t2.col_int ) USING ( pk ) +WHERE t3.col_int IS NULL +) +ORDER BY col_int_key +; +EXPLAIN +-> Sort: t4.col_int_key + -> Stream results (cost=7.85 rows=7) + -> Remove duplicate t4 rows using temporary table (weedout) (cost=7.85 rows=7) + -> Inner hash join (t4.col_int_key = t1.col_int_key) (cost=7.85 rows=7) + -> Table scan on t4 (cost=0.35 rows=6) + -> Hash + -> Filter: (t3.col_int is null) (cost=3.40 rows=7) + -> Nested loop left join (cost=3.40 rows=7) + -> Index scan on t1 using col_int_key (cost=0.95 rows=7) + -> Nested loop inner join (cost=1.21 rows=1) + -> Single-row index lookup on t2 using PRIMARY (pk=t1.pk) (cost=0.26 rows=1) + -> Filter: (t3.col_int_key = t2.col_int) (cost=0.09 rows=1) + -> Table scan on t3 (cost=0.09 rows=4) + +SELECT * +FROM t4 +WHERE (col_int_key) IN ( +SELECT t1.col_int_key +FROM t1 LEFT JOIN ( t2 JOIN t3 ON t3.col_int_key = t2.col_int ) USING ( pk ) +WHERE t3.col_int IS NULL +) +ORDER BY col_int_key +; +col_int_key +0 +3 +8 +900000000 +1368719360 +1922236416 +DROP TABLE t1, t2, t3, t4; +# +# Bug#20835095 CRASH AT CREATE_REF_FOR_KEY IN SQL/SQL_SELECT.CC +# +CREATE TABLE t1 ( +pk INTEGER, +var_10_latin1 VARCHAR(10) CHARACTER SET latin1, +var_255_utf8 VARCHAR(255) CHARACTER SET utf8, +var_255_latin1 VARCHAR(255) CHARACTER SET latin1, +var_10_utf8 VARCHAR(10) CHARACTER SET utf8, +PRIMARY KEY (pk) +); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +CREATE VIEW v1 AS SELECT * FROM t1; +INSERT INTO t1 VALUES +(1,'FROCJ','korrhrspki','UAYVL','BPZIS'), +(2,'him','a','CHYKN','OZZQT'), +(3,'WBITK','ULWBF','have','rhrh'), +(4,'or','right','up','it'), +(5,'GGDCP','x','who','as'), +(6,'j','i','e','w'); +CREATE TABLE tv +SELECT var_255_utf8 AS field1 +FROM t1; +EXPLAIN SELECT * FROM tv +WHERE field1 IN ( +SELECT tv1.var_255_utf8 +FROM v1 AS tv1 LEFT JOIN v1 AS tv2 ON tv1.var_10_latin1=tv2.var_10_utf8); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE tv NULL ALL NULL NULL NULL NULL 6 100.00 Using where +1 SIMPLE NULL eq_ref 768 test.tv.field1 1 100.00 NULL +2 MATERIALIZED t1 NULL ALL NULL NULL NULL NULL 6 100.00 NULL +2 MATERIALIZED t1 NULL ALL NULL NULL NULL NULL 6 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`tv`.`field1` AS `field1` from `test`.`tv` semi join (`test`.`t1` left join (`test`.`t1`) on((`test`.`t1`.`var_10_latin1` = `test`.`t1`.`var_10_utf8`))) where (``.`var_255_utf8` = `test`.`tv`.`field1`) +SELECT * FROM tv +WHERE field1 IN ( +SELECT tv1.var_255_utf8 +FROM v1 AS tv1 LEFT JOIN v1 AS tv2 ON tv1.var_10_latin1=tv2.var_10_utf8); +field1 +korrhrspki +a +ULWBF +right +x +i +DROP VIEW v1; +DROP TABLE t1, tv; +# 17832047 Crash in calculate_materialization_costs +CREATE TABLE t1(a INTEGER PRIMARY KEY); +INSERT INTO t1 VALUES (0),(1),(2); +SELECT 1 FROM t1 +WHERE 1 IN +(SELECT 1 BETWEEN (LENGTH(a) IN (SELECT 1 FROM t1)) AND 1 +FROM t1 +); +1 +1 +1 +1 +DROP TABLE t1; +# 17845989 Assertion failed: !(used_tables() & ... +CREATE TABLE a(b INTEGER) engine=innodb; +CREATE TABLE c(a INTEGER) engine=innodb; +SELECT 1 +FROM a +WHERE 1 IN (SELECT (a.b IS NULL) IN (SELECT 1 FROM c) FROM c) +; +1 +DROP TABLE a, c; +# +# Bug#18194196: OPTIMIZER EXECUTES STATEMENT INPERFORMANT +# +CREATE TABLE t1 (uid INTEGER, fid INTEGER, INDEX(uid)); +INSERT INTO t1 VALUES +(1,1), (1,2), (1,3), (1,4), +(2,5), (2,6), (2,7), (2,8), +(3,1), (3,2), (3,9); +CREATE TABLE t2 (uid INT PRIMARY KEY, name VARCHAR(128), INDEX(name)); +INSERT INTO t2 VALUES +(1, "A"), (2, "B"), (3, "C"), (4, "D"), (5, "E"), +(6, "F"), (7, "G"), (8, "H"), (9, "I"); +CREATE TABLE t3 (uid INT, fid INT, INDEX(uid)); +INSERT INTO t3 VALUES +(1,1), (1,2), (1,3),(1,4), +(2,5), (2,6), (2,7), (2,8), +(3,1), (3,2), (3,9); +CREATE TABLE t4 (uid INT PRIMARY KEY, name VARCHAR(128), INDEX(name)); +INSERT INTO t4 VALUES +(1, "A"), (2, "B"), (3, "C"), (4, "D"), (5, "E"), +(6, "F"), (7, "G"), (8, "H"), (9, "I"); +ANALYZE TABLE t1,t2,t3,t4; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +test.t4 analyze status OK +EXPLAIN SELECT name FROM t2, t1 +WHERE t1.uid IN (SELECT t4.uid FROM t4, t3 WHERE t3.uid=1 AND t4.uid=t3.fid) +AND t2.uid=t1.fid; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ref uid uid 5 const 4 100.00 Using where; Start temporary +1 SIMPLE t4 NULL eq_ref PRIMARY PRIMARY 4 test.t3.fid 1 100.00 Using index +1 SIMPLE t1 NULL ref uid uid 5 test.t3.fid 4 100.00 Using where; Using join buffer (Batched Key Access) +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.fid 1 100.00 End temporary; Using join buffer (Batched Key Access) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`name` AS `name` from `test`.`t4` join `test`.`t2` join `test`.`t1` semi join (`test`.`t3`) where ((`test`.`t4`.`uid` = `test`.`t3`.`fid`) and (`test`.`t1`.`uid` = `test`.`t3`.`fid`) and (`test`.`t3`.`uid` = 1) and (`test`.`t2`.`uid` = `test`.`t1`.`fid`)) +FLUSH STATUS; +SELECT name FROM t2, t1 +WHERE t1.uid IN (SELECT t4.uid FROM t4, t3 WHERE t3.uid=1 AND t4.uid=t3.fid) +AND t2.uid=t1.fid; +name +A +A +B +B +C +D +E +F +G +H +I +SHOW STATUS LIKE '%handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 20 +Handler_read_last 0 +Handler_read_next 26 +Handler_read_prev 0 +Handler_read_rnd 22 +Handler_read_rnd_next 0 +DROP TABLE t1,t2,t3,t4; +# End of test for Bug#18194196 +# +# Bug#21184091 ASSERT `READ_ROWS >= 0.0' AT +# COST_MODEL_SERVER::TMPTABLE_READWRITE_COST() +# +CREATE TABLE t1 ( +pk INTEGER, +col_varchar varchar(1), +col_int INTEGER, +PRIMARY KEY (pk) +) ENGINE=MyISAM; +CREATE TABLE t2 ( +col_int INTEGER, +col_varchar varchar(1) +) ENGINE=MyISAM; +INSERT INTO t2 VALUES (7,'x'); +INSERT INTO t2 VALUES (4,'z'); +SELECT t2.col_varchar +FROM t2 STRAIGHT_JOIN t1 ON t2.col_varchar = t1.col_varchar +JOIN t2 AS table3 ON t1.pk = table3.col_int +WHERE t1.pk IN (SELECT col_int FROM t1); +col_varchar +DROP TABLE t1,t2; +# End of test for Bug#21184091 +# Bug#21139722: Assertion failed: !(used_tables() & ((table_map) 1) ... +CREATE TABLE t1(a INTEGER) engine=innodb; +CREATE TABLE t2(b INTEGER) engine=innodb; +explain SELECT 1 +FROM (SELECT 1 IN (SELECT 1 +FROM t1 +WHERE (SELECT 1 FROM t2 HAVING b) NOT IN (SELECT 1 FROM t2) +) +FROM t2 +) AS z; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DERIVED t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +3 DEPENDENT SUBQUERY t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +5 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +4 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1276 Field or reference 'b' of SELECT #4 was resolved in SELECT #2 +Note 1003 /* select#1 */ select 1 AS `1` from (/* select#2 */ select (1,(/* select#3 */ select 1 from `test`.`t1` where ((/* select#4 */ select 1 from `test`.`t2` having (0 <> `test`.`t2`.`b`)),(/* select#5 */ select 1 from `test`.`t2` where (outer_field_is_not_null, (((/* select#4 */ select 1 from `test`.`t2` having (0 <> `test`.`t2`.`b`))) = 1), true)) is false))) AS `1 IN (SELECT 1 +FROM t1 +WHERE (SELECT 1 FROM t2 HAVING b) NOT IN (SELECT 1 FROM t2) +)` from `test`.`t2`) `z` +SELECT 1 +FROM (SELECT 1 IN (SELECT 1 +FROM t1 +WHERE (SELECT 1 FROM t2 HAVING b) NOT IN (SELECT 1 FROM t2) +) +FROM t2 +) AS z; +1 +DROP TABLE t1, t2; +CREATE TABLE t1(a INTEGER) engine=innodb; +explain SELECT (SELECT a FROM t1 AS t2 +WHERE a IN (SELECT t1.a+t2.a FROM t1 AS t3)) +FROM t1 AS t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 DEPENDENT SUBQUERY t3 NULL ALL NULL NULL NULL NULL 1 100.00 FirstMatch(t2); Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #3 was resolved in SELECT #1 +Note 1276 Field or reference 'test.t2.a' of SELECT #3 was resolved in SELECT #2 +Note 1003 /* select#1 */ select (/* select#2 */ select `test`.`t2`.`a` from `test`.`t1` `t2` semi join (`test`.`t1` `t3`) where (`test`.`t2`.`a` = (`test`.`t1`.`a` + `test`.`t2`.`a`))) AS `(SELECT a FROM t1 AS t2 +WHERE a IN (SELECT t1.a+t2.a FROM t1 AS t3))` from `test`.`t1` +SELECT (SELECT a FROM t1 AS t2 +WHERE a IN (SELECT t1.a+t2.a FROM t1 AS t3)) +FROM t1 AS t1; +(SELECT a FROM t1 AS t2 +WHERE a IN (SELECT t1.a+t2.a FROM t1 AS t3)) +DROP TABLE t1; +# End of test for Bug#21139722 +SET DEFAULT_STORAGE_ENGINE=INNODB; +# +# Bug#21139402 ASSERTION FAILED: LENGTH > 0 && KEYPARTS != 0, CRASH IN JOIN::OPTIMIZE_KEYUSE +# +CREATE TABLE t1 (a INT, b INT, PRIMARY KEY(a)); +CREATE TABLE t2 (c INT PRIMARY KEY); +EXPLAIN SELECT 1 FROM t1 +WHERE 1 IN +(SELECT (c IS NULL) IN (SELECT a FROM t1 WHERE b) FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +3 SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` semi join (`test`.`t2`) where false +SELECT 1 FROM t1 +WHERE 1 IN +(SELECT (c IS NULL) IN (SELECT a FROM t1 WHERE b) FROM t2); +1 +DROP TABLE t1,t2; +# +# Bug#21619634 ACCESS OF DEALLOCATED ITEM_OUTER_REF CAUSES CRASH: PREPARED STMT +# +create table cc (i int) engine="innodb"; +insert into cc values (1); +select (select count(i) from cc as cc_alias +where (cc.i in (select cc_alias.i from cc))) +from cc group by i; +(select count(i) from cc as cc_alias +where (cc.i in (select cc_alias.i from cc))) +1 +prepare stmt from +"select (select count(i) from cc as cc_alias + where (cc.i in (select cc_alias.i from cc))) + from cc group by i"; +execute stmt; +(select count(i) from cc as cc_alias + where (cc.i in (select cc_alias.i from cc))) +1 +execute stmt; +(select count(i) from cc as cc_alias + where (cc.i in (select cc_alias.i from cc))) +1 +drop table cc; +# +# Bug #22305361: QUERY WITH MATERIALIZED TABLE RETURNS INCORRECT +# RESULTS IN 5.6 +# +CREATE TABLE t(a INT,b INT); +INSERT INTO t VALUES (1,0),(1,0),(1,0),(1,0),(1,1); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +EXPLAIN SELECT * +FROM t AS t1 +WHERE t1.a IN (SELECT t2.a +FROM t AS t2 +WHERE CONCAT(t2.a,'') NOT IN (SELECT t3.a +FROM t AS t3 +WHERE t3.b=1)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 5 100.00 Using where +1 PRIMARY NULL eq_ref 5 test.t1.a 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 5 100.00 Using where +3 SUBQUERY t3 NULL ALL NULL NULL NULL NULL 5 20.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t` `t1` semi join (`test`.`t` `t2`) where ((``.`a` = `test`.`t1`.`a`) and (concat(`test`.`t2`.`a`,''),concat(`test`.`t2`.`a`,'') in ( (/* select#3 */ select `test`.`t3`.`a` from `test`.`t` `t3` where (`test`.`t3`.`b` = 1) having true ), (concat(`test`.`t2`.`a`,'') in on where ((concat(`test`.`t2`.`a`,'') = ``.`a`)))) is false)) +SELECT * +FROM t AS t1 +WHERE t1.a IN (SELECT t2.a +FROM t AS t2 +WHERE CONCAT(t2.a,'') NOT IN (SELECT t3.a +FROM t AS t3 +WHERE t3.b=1)); +a b +DROP TABLE t; +# +# Bug#24287772 SUBQUERY RETURNS EMPTY LIST WHILE IDENTICAL QUERY +# WITH JOIN RETURNS RESULT +# +CREATE TABLE t SELECT 4096 c; +SELECT c FROM t WHERE 1 IN +(SELECT t.c = page_size FROM information_schema.innodb_cmpmem); +c +4096 +DROP TABLE t; +# +# Bug #29132639: WL#12470: SIG 6 IN CONNECTJOINS|SQL/SQL_EXECUTOR.C +# +CREATE TABLE t1 ( f1 TIME, f2 VARCHAR(1) ); +INSERT INTO t1 VALUES ('08:35:24', 'X'), ('14:51:13', 'S'), ('11:22:33', 'Q'); +CREATE TABLE t2 ( pk INTEGER ); +INSERT INTO t2 VALUES (1), (2); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN FORMAT=tree SELECT * FROM t1 WHERE EXISTS ( SELECT alias1.f2 FROM t2 LEFT JOIN t1 ON 1 LEFT JOIN t1 AS alias1 ON 1 ); +EXPLAIN +-> Remove duplicate t1 rows using temporary table (weedout) (cost=6.20 rows=54) + -> Left hash join (no condition) (cost=6.20 rows=54) + -> Left hash join (no condition) (cost=2.14 rows=18) + -> Inner hash join (no condition) (cost=1.30 rows=6) + -> Table scan on t1 (cost=0.28 rows=3) + -> Hash + -> Table scan on t2 (cost=0.45 rows=2) + -> Hash + -> Table scan on t1 (cost=0.09 rows=3) + -> Hash + -> Table scan on alias1 (cost=0.55 rows=3) + +SELECT * FROM t1 WHERE EXISTS ( SELECT alias1.f2 FROM t2 LEFT JOIN t1 ON 1 LEFT JOIN t1 AS alias1 ON 1 ); +f1 f2 +08:35:24 X +11:22:33 Q +14:51:13 S +DROP TABLE t1, t2; +set optimizer_switch=default; +set optimizer_switch=default; diff --git a/mysql-test/r/subquery_sj_all_bka_nobnl.result-pq b/mysql-test/r/subquery_sj_all_bka_nobnl.result-pq new file mode 100644 index 000000000000..2e409a053e74 --- /dev/null +++ b/mysql-test/r/subquery_sj_all_bka_nobnl.result-pq @@ -0,0 +1,13000 @@ +set optimizer_switch='batched_key_access=on,block_nested_loop=off,mrr_cost_based=off'; +set optimizer_switch='semijoin=on,materialization=on,firstmatch=on,loosescan=on,index_condition_pushdown=on,mrr=on,mrr_cost_based=off'; +set @old_opt_switch=@@optimizer_switch; +set optimizer_switch='subquery_materialization_cost_based=off'; +drop table if exists t0, t1, t2, t10, t11, t12; +create table t1 (a int not null, b int, primary key (a)); +create table t2 (a int not null, primary key (a)); +create table t3 (a int not null, b int, primary key (a)); +insert into t1 values (1,10), (2,20), (3,30), (4,40); +insert into t2 values (2), (3), (4), (5); +insert into t3 values (10,3), (20,4), (30,5); +select * from t2 where t2.a in (select a from t1); +a +2 +3 +4 +explain select * from t2 where t2.a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index PRIMARY PRIMARY 4 NULL 4 100.00 Using index +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t1` join `test`.`t2` where (`test`.`t1`.`a` = `test`.`t2`.`a`) +select * from t2 where t2.a in (select a from t1 where t1.b <> 30); +a +2 +4 +explain select * from t2 where t2.a in (select a from t1 where t1.b <> 30); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL PRIMARY NULL NULL NULL 4 75.00 Using where +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`a` = `test`.`t1`.`a`) and (`test`.`t1`.`b` <> 30)) +select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a); +a +2 +3 +explain select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index PRIMARY PRIMARY 4 NULL 4 100.00 Using index +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.a 1 100.00 Using where; Using join buffer (Batched Key Access) +1 SIMPLE t3 NULL eq_ref PRIMARY PRIMARY 4 test.t1.b 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t1` join `test`.`t3` join `test`.`t2` where ((`test`.`t1`.`a` = `test`.`t2`.`a`) and (`test`.`t3`.`a` = `test`.`t1`.`b`)) +drop table t1, t2, t3; +create table t1 (a int, b int, index a (a,b)); +create table t2 (a int, index a (a)); +create table t3 (a int, b int, index a (a)); +insert into t1 values (1,10), (2,20), (3,30), (4,40); +create table t0(a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +insert into t1 +select rand()*100000+200,rand()*100000 from t0 A, t0 B, t0 C, t0 D; +insert into t2 values (2), (3), (4), (5); +insert into t3 values (10,3), (20,4), (30,5); +select * from t2 where t2.a in (select a from t1); +a +2 +3 +4 +explain select * from t2 where t2.a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index a a 5 NULL 4 100.00 Using where; Using index +1 SIMPLE t1 NULL ref a a 5 test.t2.a 101 100.00 Using index; FirstMatch(t2) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1`) where (`test`.`t1`.`a` = `test`.`t2`.`a`) +select * from t2 where t2.a in (select a from t1 where t1.b <> 30); +a +2 +4 +explain select * from t2 where t2.a in (select a from t1 where t1.b <> 30); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index a a 5 NULL 4 100.00 Using where; Using index +1 SIMPLE t1 NULL ref a a 5 test.t2.a 101 90.00 Using where; Using index; FirstMatch(t2) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1`) where ((`test`.`t1`.`a` = `test`.`t2`.`a`) and (`test`.`t1`.`b` <> 30)) +select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a); +a +2 +3 +explain select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index a a 5 NULL 4 100.00 Using where; Using index +1 SIMPLE t3 NULL index a a 5 NULL 3 100.00 Using where; Using index +1 SIMPLE t1 NULL ref a a 10 test.t2.a,test.t3.a 116 100.00 Using index; FirstMatch(t2) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1` join `test`.`t3`) where ((`test`.`t1`.`a` = `test`.`t2`.`a`) and (`test`.`t1`.`b` = `test`.`t3`.`a`)) +insert into t1 values (3,31); +select * from t2 where t2.a in (select a from t1 where t1.b <> 30); +a +2 +3 +4 +select * from t2 where t2.a in (select a from t1 where t1.b <> 30 and t1.b <> 31); +a +2 +4 +explain select * from t2 where t2.a in (select a from t1 where t1.b <> 30); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index a a 5 NULL 4 100.00 Using where; Using index +1 SIMPLE t1 NULL ref a a 5 test.t2.a 101 90.00 Using where; Using index; FirstMatch(t2) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1`) where ((`test`.`t1`.`a` = `test`.`t2`.`a`) and (`test`.`t1`.`b` <> 30)) +drop table t0, t1, t2, t3; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1(a int, b int); +insert into t1 values (0,0),(1,1),(2,2); +create table t2 as select * from t1; +create table t11(a int, b int); +create table t10 (pk int, a int, primary key(pk)); +insert into t10 select a,a from t0; +create table t12 like t10; +insert into t12 select * from t10; +Flattened because of dependency, t10=func(t1) +explain select * from t1 where a in (select pk from t10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t1` where (`test`.`t10`.`pk` = `test`.`t1`.`a`) +select * from t1 where a in (select pk from t10); +a b +0 0 +1 1 +2 2 +A confluent case of dependency +explain select * from t1 where a in (select a from t10 where pk=12); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t1` where (multiple equal(12, NULL) and multiple equal(`test`.`t1`.`a`, NULL)) +select * from t1 where a in (select a from t10 where pk=12); +a b +explain select * from t1 where a in (select a from t10 where pk=9); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t10 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t1` where ((`test`.`t1`.`a` = '9')) +select * from t1 where a in (select a from t10 where pk=9); +a b +An empty table inside +explain select * from t1 where a in (select a from t11); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 0.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +2 MATERIALIZED t11 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t11`) where (`test`.`t1`.`a` = ``.`a`) +select * from t1 where a in (select a from t11); +a b +explain select * from t1 where a in (select pk from t10) and b in (select pk from t10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using index +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.t1.b 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t10` join `test`.`t1` where ((`test`.`t10`.`pk` = `test`.`t1`.`b`) and (`test`.`t10`.`pk` = `test`.`t1`.`a`)) +select * from t1 where a in (select pk from t10) and b in (select pk from t10); +a b +0 0 +1 1 +2 2 +flattening a nested subquery +explain select * from t1 where a in (select pk from t10 where t10.a in (select pk from t12)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using where; Using join buffer (Batched Key Access) +1 SIMPLE t12 NULL eq_ref PRIMARY PRIMARY 4 test.t10.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t12` join `test`.`t1` where ((`test`.`t10`.`pk` = `test`.`t1`.`a`) and (`test`.`t12`.`pk` = `test`.`t10`.`a`)) +select * from t1 where a in (select pk from t10 where t10.a in (select pk from t12)); +a b +0 0 +1 1 +2 2 +flattening subquery w/ several tables +explain select * from t1 where a in (select t10.pk from t10, t12 where t12.pk=t10.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using where; Using join buffer (Batched Key Access) +1 SIMPLE t12 NULL eq_ref PRIMARY PRIMARY 4 test.t10.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t12` join `test`.`t1` where ((`test`.`t10`.`pk` = `test`.`t1`.`a`) and (`test`.`t12`.`pk` = `test`.`t10`.`a`)) +subqueries within outer joins go into ON expr. +explain +select * from t1 left join (t2 A, t2 B) on ( A.A= t1.A and B.A in (select pk from t10)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE A NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE B NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.B.A 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`A` AS `A`,`test`.`t1`.`B` AS `B`,`test`.`A`.`A` AS `A`,`test`.`A`.`B` AS `B`,`test`.`B`.`A` AS `A`,`test`.`B`.`B` AS `B` from `test`.`t1` left join (`test`.`t10` join `test`.`t2` `A` join `test`.`t2` `B`) on(((`test`.`t10`.`pk` = `test`.`B`.`A`) and (`test`.`A`.`A` = `test`.`t1`.`A`))) where true +t2 should be wrapped into OJ-nest, so we have "t1 LJ (t2 J t10)" +explain +select * from t1 left join t2 on (t2.A= t1.A and t2.A in (select pk from t10)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.t1.A 1 100.00 Using index +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`A` AS `A`,`test`.`t1`.`B` AS `B`,`test`.`t2`.`A` AS `A`,`test`.`t2`.`B` AS `B` from `test`.`t1` left join (`test`.`t10` join `test`.`t2`) on(((`test`.`t10`.`pk` = `test`.`t1`.`A`) and (`test`.`t2`.`A` = `test`.`t1`.`A`))) where true +we shouldn't flatten if we're going to get a join of > MAX_TABLES. +explain select * from +t1 s00, t1 s01, t1 s02, t1 s03, t1 s04,t1 s05,t1 s06,t1 s07,t1 s08,t1 s09, +t1 s10, t1 s11, t1 s12, t1 s13, t1 s14,t1 s15,t1 s16,t1 s17,t1 s18,t1 s19, +t1 s20, t1 s21, t1 s22, t1 s23, t1 s24,t1 s25,t1 s26,t1 s27,t1 s28,t1 s29, +t1 s30, t1 s31, t1 s32, t1 s33, t1 s34,t1 s35,t1 s36,t1 s37,t1 s38,t1 s39, +t1 s40, t1 s41, t1 s42, t1 s43, t1 s44,t1 s45,t1 s46,t1 s47,t1 s48,t1 s49 +where +s00.a in ( +select m00.a from +t1 m00, t1 m01, t1 m02, t1 m03, t1 m04,t1 m05,t1 m06,t1 m07,t1 m08,t1 m09, +t1 m10, t1 m11, t1 m12, t1 m13, t1 m14,t1 m15,t1 m16,t1 m17,t1 m18,t1 m19 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY s00 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 PRIMARY s01 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s02 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s03 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s04 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s05 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s06 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s07 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s08 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s09 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s10 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s11 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s12 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s13 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s14 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s15 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s16 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s17 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s18 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s19 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s20 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s21 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s22 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s23 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s24 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s25 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s26 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s27 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s28 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s29 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s30 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s31 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s32 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s33 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s34 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s35 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s36 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s37 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s38 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s39 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s40 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s41 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s42 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s43 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s44 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s45 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s46 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s47 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s48 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s49 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 SUBQUERY m00 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 SUBQUERY m01 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 SUBQUERY m02 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 SUBQUERY m03 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 SUBQUERY m04 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 SUBQUERY m05 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 SUBQUERY m06 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 SUBQUERY m07 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 SUBQUERY m08 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 SUBQUERY m09 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 SUBQUERY m10 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 SUBQUERY m11 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 SUBQUERY m12 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 SUBQUERY m13 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 SUBQUERY m14 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 SUBQUERY m15 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 SUBQUERY m16 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 SUBQUERY m17 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 SUBQUERY m18 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 SUBQUERY m19 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`s00`.`a` AS `a`,`test`.`s00`.`b` AS `b`,`test`.`s01`.`a` AS `a`,`test`.`s01`.`b` AS `b`,`test`.`s02`.`a` AS `a`,`test`.`s02`.`b` AS `b`,`test`.`s03`.`a` AS `a`,`test`.`s03`.`b` AS `b`,`test`.`s04`.`a` AS `a`,`test`.`s04`.`b` AS `b`,`test`.`s05`.`a` AS `a`,`test`.`s05`.`b` AS `b`,`test`.`s06`.`a` AS `a`,`test`.`s06`.`b` AS `b`,`test`.`s07`.`a` AS `a`,`test`.`s07`.`b` AS `b`,`test`.`s08`.`a` AS `a`,`test`.`s08`.`b` AS `b`,`test`.`s09`.`a` AS `a`,`test`.`s09`.`b` AS `b`,`test`.`s10`.`a` AS `a`,`test`.`s10`.`b` AS `b`,`test`.`s11`.`a` AS `a`,`test`.`s11`.`b` AS `b`,`test`.`s12`.`a` AS `a`,`test`.`s12`.`b` AS `b`,`test`.`s13`.`a` AS `a`,`test`.`s13`.`b` AS `b`,`test`.`s14`.`a` AS `a`,`test`.`s14`.`b` AS `b`,`test`.`s15`.`a` AS `a`,`test`.`s15`.`b` AS `b`,`test`.`s16`.`a` AS `a`,`test`.`s16`.`b` AS `b`,`test`.`s17`.`a` AS `a`,`test`.`s17`.`b` AS `b`,`test`.`s18`.`a` AS `a`,`test`.`s18`.`b` AS `b`,`test`.`s19`.`a` AS `a`,`test`.`s19`.`b` AS `b`,`test`.`s20`.`a` AS `a`,`test`.`s20`.`b` AS `b`,`test`.`s21`.`a` AS `a`,`test`.`s21`.`b` AS `b`,`test`.`s22`.`a` AS `a`,`test`.`s22`.`b` AS `b`,`test`.`s23`.`a` AS `a`,`test`.`s23`.`b` AS `b`,`test`.`s24`.`a` AS `a`,`test`.`s24`.`b` AS `b`,`test`.`s25`.`a` AS `a`,`test`.`s25`.`b` AS `b`,`test`.`s26`.`a` AS `a`,`test`.`s26`.`b` AS `b`,`test`.`s27`.`a` AS `a`,`test`.`s27`.`b` AS `b`,`test`.`s28`.`a` AS `a`,`test`.`s28`.`b` AS `b`,`test`.`s29`.`a` AS `a`,`test`.`s29`.`b` AS `b`,`test`.`s30`.`a` AS `a`,`test`.`s30`.`b` AS `b`,`test`.`s31`.`a` AS `a`,`test`.`s31`.`b` AS `b`,`test`.`s32`.`a` AS `a`,`test`.`s32`.`b` AS `b`,`test`.`s33`.`a` AS `a`,`test`.`s33`.`b` AS `b`,`test`.`s34`.`a` AS `a`,`test`.`s34`.`b` AS `b`,`test`.`s35`.`a` AS `a`,`test`.`s35`.`b` AS `b`,`test`.`s36`.`a` AS `a`,`test`.`s36`.`b` AS `b`,`test`.`s37`.`a` AS `a`,`test`.`s37`.`b` AS `b`,`test`.`s38`.`a` AS `a`,`test`.`s38`.`b` AS `b`,`test`.`s39`.`a` AS `a`,`test`.`s39`.`b` AS `b`,`test`.`s40`.`a` AS `a`,`test`.`s40`.`b` AS `b`,`test`.`s41`.`a` AS `a`,`test`.`s41`.`b` AS `b`,`test`.`s42`.`a` AS `a`,`test`.`s42`.`b` AS `b`,`test`.`s43`.`a` AS `a`,`test`.`s43`.`b` AS `b`,`test`.`s44`.`a` AS `a`,`test`.`s44`.`b` AS `b`,`test`.`s45`.`a` AS `a`,`test`.`s45`.`b` AS `b`,`test`.`s46`.`a` AS `a`,`test`.`s46`.`b` AS `b`,`test`.`s47`.`a` AS `a`,`test`.`s47`.`b` AS `b`,`test`.`s48`.`a` AS `a`,`test`.`s48`.`b` AS `b`,`test`.`s49`.`a` AS `a`,`test`.`s49`.`b` AS `b` from `test`.`t1` `s00` join `test`.`t1` `s01` join `test`.`t1` `s02` join `test`.`t1` `s03` join `test`.`t1` `s04` join `test`.`t1` `s05` join `test`.`t1` `s06` join `test`.`t1` `s07` join `test`.`t1` `s08` join `test`.`t1` `s09` join `test`.`t1` `s10` join `test`.`t1` `s11` join `test`.`t1` `s12` join `test`.`t1` `s13` join `test`.`t1` `s14` join `test`.`t1` `s15` join `test`.`t1` `s16` join `test`.`t1` `s17` join `test`.`t1` `s18` join `test`.`t1` `s19` join `test`.`t1` `s20` join `test`.`t1` `s21` join `test`.`t1` `s22` join `test`.`t1` `s23` join `test`.`t1` `s24` join `test`.`t1` `s25` join `test`.`t1` `s26` join `test`.`t1` `s27` join `test`.`t1` `s28` join `test`.`t1` `s29` join `test`.`t1` `s30` join `test`.`t1` `s31` join `test`.`t1` `s32` join `test`.`t1` `s33` join `test`.`t1` `s34` join `test`.`t1` `s35` join `test`.`t1` `s36` join `test`.`t1` `s37` join `test`.`t1` `s38` join `test`.`t1` `s39` join `test`.`t1` `s40` join `test`.`t1` `s41` join `test`.`t1` `s42` join `test`.`t1` `s43` join `test`.`t1` `s44` join `test`.`t1` `s45` join `test`.`t1` `s46` join `test`.`t1` `s47` join `test`.`t1` `s48` join `test`.`t1` `s49` where (`test`.`s00`.`a`,`test`.`s00`.`a` in ( (/* select#2 */ select `test`.`m00`.`a` from `test`.`t1` `m00` join `test`.`t1` `m01` join `test`.`t1` `m02` join `test`.`t1` `m03` join `test`.`t1` `m04` join `test`.`t1` `m05` join `test`.`t1` `m06` join `test`.`t1` `m07` join `test`.`t1` `m08` join `test`.`t1` `m09` join `test`.`t1` `m10` join `test`.`t1` `m11` join `test`.`t1` `m12` join `test`.`t1` `m13` join `test`.`t1` `m14` join `test`.`t1` `m15` join `test`.`t1` `m16` join `test`.`t1` `m17` join `test`.`t1` `m18` join `test`.`t1` `m19` where true ), (`test`.`s00`.`a` in on where ((`test`.`s00`.`a` = ``.`a`))))) +select * from +t1 left join t2 on (t2.a= t1.a and t2.a in (select pk from t10)) +where t1.a < 5; +a b a b +0 0 0 0 +1 1 1 1 +2 2 2 2 +prepare s1 from +' select * from + t1 left join t2 on (t2.a= t1.a and t2.a in (select pk from t10)) + where t1.a < 5'; +execute s1; +a b a b +0 0 0 0 +1 1 1 1 +2 2 2 2 +execute s1; +a b a b +0 0 0 0 +1 1 1 1 +2 2 2 2 +insert into t1 select (A.a + 10 * B.a),1 from t0 A, t0 B; +explain select * from t1 where a in (select pk from t10 where pk<3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t10 NULL range PRIMARY PRIMARY 4 NULL 4 100.00 Using where; Using index +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 103 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t1` where ((`test`.`t1`.`a` = `test`.`t10`.`pk`) and (`test`.`t10`.`pk` < 3)) +drop table t0, t1, t2; +drop table t10, t11, t12; +# +# Check that subqueries with outer joins or straight_join work for +# different permutations of const and non-const tables. (Ref. Bug#46692) +# +CREATE TABLE t1 (i INTEGER); +CREATE TABLE t2 (i INTEGER); +CREATE TABLE t3 (i INTEGER); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 0 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 0 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 0 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 1 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 1 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 1 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 2 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 2 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 2 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (0); +DELETE FROM t2; +INSERT INTO t1 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 0 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 0 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 0 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 1 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 1 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 1 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 2 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 2 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 2 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (0); +DELETE FROM t2; +INSERT INTO t1 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 0 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 0.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = ``.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 0.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = ``.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 0.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = ``.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 0.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 0.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t1`.`i` = ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 0 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = `test`.`t2`.`i`) and (`test`.`t1`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = `test`.`t2`.`i`) and (`test`.`t1`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = `test`.`t2`.`i`) and (`test`.`t1`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 0 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t2`.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t2`.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t2`.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +1 +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = `test`.`t1`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 1 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 0.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = ``.`i`) and (`test`.`t2`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 0.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = ``.`i`) and (`test`.`t2`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 0.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = ``.`i`) and (`test`.`t2`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 0.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 0.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t1`.`i` = ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 1 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = `test`.`t2`.`i`) and (`test`.`t1`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = `test`.`t2`.`i`) and (`test`.`t1`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = `test`.`t2`.`i`) and (`test`.`t1`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 1 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t2`.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t2`.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t2`.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +1 +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = `test`.`t1`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +1 +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 2 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t3`.`i`) and (`test`.`t2`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t3`.`i`) and (`test`.`t2`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t3`.`i`) and (`test`.`t2`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 0.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t1`.`i` = ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 2 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t3`.`i`) and (`test`.`t2`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t3`.`i`) and (`test`.`t2`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t3`.`i`) and (`test`.`t2`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t1`.`i` = ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 2 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = `test`.`t1`.`i`) and (`test`.`t3`.`i` = `test`.`t1`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +1 +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +1 +2 + +EXECUTE stmt; +i +1 +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = `test`.`t1`.`i`) and (`test`.`t3`.`i` = `test`.`t1`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +1 +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = `test`.`t1`.`i`) and (`test`.`t3`.`i` = `test`.`t1`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +1 +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +1 +2 + +EXECUTE stmt; +i +1 +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = `test`.`t1`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +1 +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE NULL eq_ref 5 test.t1.i 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (``.`i` = `test`.`t1`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +1 +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (0); +DELETE FROM t2; +INSERT INTO t1 VALUES (0); +DROP TABLE t1, t2, t3; +create table x1(k int primary key, d1 int, d2 int); +create table x2(k int primary key, d1 int, d2 int); +insert into x1 values +(10, 10, 10), +(20, 20, 20), +(21, 20, null), +(30, null, 30), +(40, 40, 40); +insert into x2 values +(10, 10, 10), +(20, 20, 20), +(21, 20, null), +(30, null, 30); +select * +from x1 +where (d1, d2) in (select d1, d2 +from x2); +k d1 d2 +10 10 10 +20 20 20 +select * +from x1 +where (d1, d2) in (select d1, d2 +from x2) is true; +k d1 d2 +10 10 10 +20 20 20 +select * +from x1 +where (d1, d2) in (select d1, d2 +from x2) is false; +k d1 d2 +40 40 40 +select * +from x1 +where (d1, d2) in (select d1, d2 +from x2) is unknown; +k d1 d2 +21 20 NULL +30 NULL 30 +select * +from x1 +where d1 in (select d1 +from x2 +where x1.d2=x2.d2); +k d1 d2 +10 10 10 +20 20 20 +select * +from x1 +where d1 in (select d1 +from x2 +where x1.d2=x2.d2) is true; +k d1 d2 +10 10 10 +20 20 20 +select * +from x1 +where d1 in (select d1 +from x2 +where x1.d2=x2.d2) is false; +k d1 d2 +21 20 NULL +40 40 40 +select * +from x1 +where d1 in (select d1 +from x2 +where x1.d2=x2.d2) is unknown; +k d1 d2 +30 NULL 30 +select * +from x1 +where 1 in (select 1 +from x2 +where x1.d1=x2.d1 and x1.d2=x2.d2); +k d1 d2 +10 10 10 +20 20 20 +select * +from x1 +where 1 in (select 1 +from x2 +where x1.d1=x2.d1 and x1.d2=x2.d2) is true; +k d1 d2 +10 10 10 +20 20 20 +select * +from x1 +where 1 in (select 1 +from x2 +where x1.d1=x2.d1 and x1.d2=x2.d2) is false; +k d1 d2 +21 20 NULL +30 NULL 30 +40 40 40 +select * +from x1 +where 1 in (select 1 +from x2 +where x1.d1=x2.d1 and x1.d2=x2.d2) is unknown; +k d1 d2 +select * +from x1 +where exists (select * +from x2 +where x1.d1=x2.d1 and x1.d2=x2.d2); +k d1 d2 +10 10 10 +20 20 20 +drop table x1; +drop table x2; +CREATE TABLE t1 ( +a int(11) NOT NULL, +b int(11) NOT NULL, +c datetime default NULL, +PRIMARY KEY (a), +KEY idx_bc (b,c) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES +(406989,67,'2006-02-23 17:08:46'), (150078,67,'2005-10-26 11:17:45'), +(406993,67,'2006-02-27 11:20:57'), (245655,67,'2005-12-08 15:59:08'), +(406994,67,'2006-02-27 11:26:46'), (256,67,NULL), +(398341,67,'2006-02-20 04:48:44'), (254,67,NULL),(1120,67,NULL), +(406988,67,'2006-02-23 17:07:22'), (255,67,NULL), +(398340,67,'2006-02-20 04:38:53'),(406631,67,'2006-02-23 10:49:42'), +(245653,67,'2005-12-08 15:59:07'),(406992,67,'2006-02-24 16:47:18'), +(245654,67,'2005-12-08 15:59:08'),(406995,67,'2006-02-28 11:55:00'), +(127261,67,'2005-10-13 12:17:58'),(406991,67,'2006-02-24 16:42:32'), +(245652,67,'2005-12-08 15:58:27'),(398545,67,'2006-02-20 04:53:13'), +(154504,67,'2005-10-28 11:53:01'),(9199,67,NULL),(1,67,'2006-02-23 15:01:35'), +(223456,67,NULL),(4101,67,NULL),(1133,67,NULL), +(406990,67,'2006-02-23 18:01:45'),(148815,67,'2005-10-25 15:34:17'), +(148812,67,'2005-10-25 15:30:01'),(245651,67,'2005-12-08 15:58:27'), +(154503,67,'2005-10-28 11:52:38'); +create table t11 select * from t1 where b = 67 AND (c IS NULL OR c > NOW()) order by 3 asc; +create table t12 select * from t1 where b = 67 AND (c IS NULL OR c > NOW()) order by 3 desc; +create table t21 select * from t1 where b = 67 AND (c IS NULL OR c > '2005-12-08') order by 3 asc; +create table t22 select * from t1 where b = 67 AND (c IS NULL OR c > '2005-12-08') order by 3 desc; +update t22 set c = '2005-12-08 15:58:27' where a = 255; +explain select t21.* from t21,t22 where t21.a = t22.a and +t22.a in (select t12.a from t11, t12 where t11.a in(255,256) and t11.a = t12.a and t11.c is null) and t22.c is null order by t21.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using temporary; Using filesort +1 SIMPLE t22 NULL ALL NULL NULL NULL NULL 26 3.85 Using where +1 SIMPLE t21 NULL ALL NULL NULL NULL NULL 26 10.00 Using where +2 MATERIALIZED t11 NULL ALL NULL NULL NULL NULL 8 12.50 Using where +2 MATERIALIZED t12 NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t21`.`a` AS `a`,`test`.`t21`.`b` AS `b`,`test`.`t21`.`c` AS `c` from `test`.`t21` join `test`.`t22` semi join (`test`.`t11` join `test`.`t12`) where ((`test`.`t22`.`a` = ``.`a`) and (`test`.`t21`.`a` = ``.`a`) and (`test`.`t12`.`a` = `test`.`t11`.`a`) and (`test`.`t22`.`c` is null) and (`test`.`t11`.`a` in (255,256)) and (`test`.`t11`.`c` is null)) order by `test`.`t21`.`a` +explain format=json select * from t1 where a in (select a from t11); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "6.71" + }, + "nested_loop": [ + { + "table": { + "table_name": "", + "access_type": "ALL", + "materialized_from_subquery": { + "using_temporary_table": true, + "query_block": { + "table": { + "table_name": "t11", + "access_type": "ALL", + "rows_examined_per_scan": 8, + "rows_produced_per_join": 8, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "0.80", + "prefix_cost": "1.31", + "data_read_per_join": "128" + }, + "used_columns": [ + "a" + ] + } + } + } + } + }, + { + "table": { + "table_name": "t1", + "access_type": "eq_ref", + "possible_keys": [ + "PRIMARY" + ], + "key": "PRIMARY", + "used_key_parts": [ + "a" + ], + "key_length": "4", + "ref": [ + ".a" + ], + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "using_join_buffer": "Batched Key Access", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.10", + "prefix_cost": "6.71", + "data_read_per_join": "16" + }, + "used_columns": [ + "a", + "b", + "c" + ] + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` semi join (`test`.`t11`) where (`test`.`t1`.`a` = ``.`a`) +select t21.* from t21,t22 where t21.a = t22.a and +t22.a in (select t12.a from t11, t12 where t11.a in(255,256) and t11.a = t12.a and t11.c is null) and t22.c is null order by t21.a; +a b c +256 67 NULL +drop table t1, t11, t12, t21, t22; +create table t1(a int); +insert into t1 values (0),(1); +explain +select (select max(y.a) from t1 y where a in (select a from t1 z) and a < x.a) as subq from t1 x; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY x NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DEPENDENT SUBQUERY y NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 DEPENDENT SUBQUERY z NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(y) +Warnings: +Note 1276 Field or reference 'test.x.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select (/* select#2 */ select max(`test`.`y`.`a`) from `test`.`t1` `y` semi join (`test`.`t1` `z`) where ((`test`.`z`.`a` = `test`.`y`.`a`) and (`test`.`y`.`a` < `test`.`x`.`a`))) AS `subq` from `test`.`t1` `x` +select (select max(y.a) from t1 y where a in (select a from t1 z) and a < x.a) as subq from t1 x; +subq +NULL +0 +drop table t1; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 as select * from t0; +insert into t1 select a+10 from t0; +insert into t0 values(2); +explain select * from t1 where 2 in (select a from t0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 11 10.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 20 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t0`) where (`test`.`t0`.`a` = 2) +select * from t1 where 2 in (select a from t0); +a +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +explain select * from (select a from t0) x where a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 11 100.00 NULL +1 SIMPLE NULL eq_ref 5 func 1 100.00 Using where +3 MATERIALIZED t1 NULL ALL NULL NULL NULL NULL 20 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a` from `test`.`t0` semi join (`test`.`t1`) where (``.`a` = `test`.`t0`.`a`) +explain format=json select * from (select a from t0) x where a in (select a from t1); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "8.21" + }, + "nested_loop": [ + { + "table": { + "table_name": "t0", + "access_type": "ALL", + "rows_examined_per_scan": 11, + "rows_produced_per_join": 11, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "1.10", + "prefix_cost": "1.60", + "data_read_per_join": "88" + }, + "used_columns": [ + "a" + ] + } + }, + { + "table": { + "table_name": "", + "access_type": "eq_ref", + "key": "", + "key_length": "5", + "ref": [ + "func" + ], + "rows_examined_per_scan": 1, + "attached_condition": "(``.`a` = `test`.`t0`.`a`)", + "materialized_from_subquery": { + "using_temporary_table": true, + "query_block": { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 20, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "2.00", + "prefix_cost": "2.51", + "data_read_per_join": "160" + }, + "used_columns": [ + "a" + ] + } + } + } + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a` from `test`.`t0` semi join (`test`.`t1`) where (``.`a` = `test`.`t0`.`a`) +drop table t0, t1; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (kp1 int, kp2 int, c int, filler char(100), key(kp1, kp2)); +insert into t1 select A.a+10*(B.a+10*C.a), 0, 0, 'filler' from t0 A, t0 B, t0 C; +insert into t1 select * from t1 where kp1 < 20; +create table t3 (a int); +insert into t3 select A.a + 10*B.a from t0 A, t0 B; +explain select * from t3 where a in (select kp1 from t1 where kp1<20); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 100 100.00 Using where +1 SIMPLE NULL eq_ref 5 test.t3.a 1 100.00 NULL +2 MATERIALIZED t1 NULL range kp1 kp1 5 NULL 48 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a` from `test`.`t3` semi join (`test`.`t1`) where ((``.`kp1` = `test`.`t3`.`a`) and (`test`.`t1`.`kp1` < 20)) +select * from t3 where a in (select kp1 from t1 where kp1<20); +a +0 +1 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +2 +3 +4 +5 +6 +7 +8 +9 +explain select * from t3 where a in (select kp1 from t1 where kp1<20) and a<20; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 100 33.33 Using where +1 SIMPLE t1 NULL ref kp1 kp1 5 test.t3.a 1 100.00 Using index; FirstMatch(t3) +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a` from `test`.`t3` semi join (`test`.`t1`) where ((`test`.`t1`.`kp1` = `test`.`t3`.`a`) and (`test`.`t3`.`a` < 20) and (`test`.`t3`.`a` < 20)) +select * from t3 where a in (select kp1 from t1 where kp1<20) and a<20; +a +0 +1 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +2 +3 +4 +5 +6 +7 +8 +9 +create table t4 (pk int primary key); +insert into t4 select a from t3; +explain select * from t3 where a in +(select t1.kp1 from t1,t4 where kp1<20 and t4.pk=t1.c); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 100 100.00 Using where +1 SIMPLE NULL eq_ref 5 test.t3.a 1 100.00 NULL +2 MATERIALIZED t1 NULL range kp1 kp1 5 NULL 48 100.00 Using index condition; Using where; Using MRR +2 MATERIALIZED t4 NULL eq_ref PRIMARY PRIMARY 4 test.t1.c 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a` from `test`.`t3` semi join (`test`.`t1` join `test`.`t4`) where ((``.`kp1` = `test`.`t3`.`a`) and (`test`.`t4`.`pk` = `test`.`t1`.`c`) and (`test`.`t1`.`kp1` < 20)) +explain format=tree select * from t3 where a in +(select t1.kp1 from t1,t4 where kp1<20 and t4.pk=t1.c); +EXPLAIN +-> Nested loop inner join (cost=500.54 rows=4800) + -> Filter: (t3.a is not null) (cost=10.54 rows=100) + -> Table scan on t3 (cost=10.54 rows=100) + -> Single-row index lookup on using (kp1=t3.a) + -> Materialize with deduplication (cost=42.80..42.80 rows=48) + -> Filter: (t1.kp1 is not null) (cost=38.00 rows=48) + -> Nested loop inner join (cost=38.00 rows=48) + -> Filter: (t1.c is not null) (cost=21.20 rows=48) + -> Index range scan on t1 using kp1, with index condition: (t1.kp1 < 20) (cost=21.20 rows=48) + -> Single-row index lookup on t4 using PRIMARY (pk=t1.c) (cost=0.25 rows=1) + +select * from t3 where a in +(select t1.kp1 from t1,t4 where kp1<20 and t4.pk=t1.c); +a +0 +1 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +2 +3 +4 +5 +6 +7 +8 +9 +drop table t1, t3, t4; +create table t1 (a int); +insert into t1 values (0),(0),(0),(1),(1),(1),(2),(2),(2),(3),(3),(3); +set session internal_tmp_mem_storage_engine='memory'; +set @save_max_heap_table_size=@@max_heap_table_size; +set @@max_heap_table_size= 16384; +# Attempt to make one test that overflows the heap table when a +# non-duplicate row is inserted and one test that overflows the +# heap table when a duplicate record is inserted. Debugging showed +# that these situations occurred with max_heap_table_size=16384 +# and optimizer_join_cache_level equals 1 and 0, respectively. +# Finally execute a test that does not overflow the heap table. +explain +select count(*) from t0 a, t0 b, t0 c +where c.a in (select a from t1 d); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE a NULL ALL NULL NULL NULL NULL 10 100.00 NULL +1 SIMPLE b NULL ALL NULL NULL NULL NULL 10 100.00 NULL +1 SIMPLE c NULL ALL NULL NULL NULL NULL 10 100.00 Using where +1 SIMPLE NULL eq_ref 5 test.c.a 1 100.00 NULL +2 MATERIALIZED d NULL ALL NULL NULL NULL NULL 12 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select count(0) AS `count(*)` from `test`.`t0` `a` join `test`.`t0` `b` join `test`.`t0` `c` semi join (`test`.`t1` `d`) where (``.`a` = `test`.`c`.`a`) +flush status; +select count(*) from t0 a, t0 b, t0 c +where c.a in (select a from t1 d); +count(*) +400 +show status like 'Created_tmp_disk_tables'; +Variable_name Value +Created_tmp_disk_tables 0 +set @@max_heap_table_size= @save_max_heap_table_size; +set session internal_tmp_mem_storage_engine=default; +flush status; +select count(*) from t0 a, t0 b, t0 c +where c.a in (select a from t1 d); +count(*) +400 +show status like 'Created_tmp_disk_tables'; +Variable_name Value +Created_tmp_disk_tables 0 +drop table t0, t1; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t2(a int); +insert into t2 values (1),(2); +create table t3 ( a int , filler char(100), key(a)); +insert into t3 select A.a + 10*B.a, 'filler' from t0 A, t0 B; +explain select * from t3 where a in (select a from t2) and (a > 5 or a < 10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using where +1 SIMPLE t3 NULL ref a a 5 .a 1 100.00 Using join buffer (Batched Key Access) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a`,`test`.`t3`.`filler` AS `filler` from `test`.`t3` semi join (`test`.`t2`) where ((`test`.`t3`.`a` = ``.`a`) and ((``.`a` > 5) or (``.`a` < 10))) +select * from t3 where a in (select a from t2); +a filler +1 filler +2 filler +drop table t0, t2, t3; +create table t1 (a date); +insert into t1 values ('2008-01-01'),('2008-01-01'),('2008-02-01'),('2008-02-01'); +create table t2 (a int); +insert into t2 values (1),(2); +create table t3 (a char(10)); +insert into t3 select * from t1; +insert into t3 values (1),(2); +explain select * from t2 where a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; FirstMatch(t2) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1`) where (cast(`test`.`t2`.`a` as double) = cast(`test`.`t1`.`a` as double)) +explain select * from t2 where a in (select a from t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t2) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t2`) where (`test`.`t2`.`a` = `test`.`t2`.`a`) +explain select * from t2 where a in (select a from t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; FirstMatch(t2) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t3`) where (cast(`test`.`t2`.`a` as double) = cast(`test`.`t3`.`a` as double)) +explain select * from t1 where a in (select a from t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t3`) where (`test`.`t1`.`a` = cast(`test`.`t3`.`a` as date)) +drop table t1, t2, t3; +create table t1 (a decimal); +insert into t1 values (1),(2); +explain select * from t1 where a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t1`) where (`test`.`t1`.`a` = `test`.`t1`.`a`) +drop table t1; +create table t1 (a int); +insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t2 as select * from t1; +create table t3 (a int, b int, filler char(100), key(a)) charset utf8mb4; +insert into t3 select A.a + 10*B.a, A.a + 10*B.a, 'filler' from t1 A, t1 B, t1 C; +explain select * from t1, t3 where t3.a in (select a from t2) and (t3.a < 10 or t3.a >30) and t1.a =3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 10.00 Using where +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using where +1 SIMPLE t3 NULL ref a a 5 .a 10 100.00 Using join buffer (Batched Key Access) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 10 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t3`.`filler` AS `filler` from `test`.`t1` join `test`.`t3` semi join (`test`.`t2`) where ((`test`.`t3`.`a` = ``.`a`) and (`test`.`t1`.`a` = 3) and ((``.`a` < 10) or (``.`a` > 30))) +explain format=json select * from t1, t3 where t3.a in (select a from t2) and (t3.a < 10 or t3.a >30) and t1.a =3; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "41.01" + }, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 10, + "rows_produced_per_join": 1, + "filtered": "10.00", + "cost_info": { + "read_cost": "1.40", + "eval_cost": "0.10", + "prefix_cost": "1.50", + "data_read_per_join": "8" + }, + "used_columns": [ + "a" + ], + "attached_condition": "(`test`.`t1`.`a` = 3)" + } + }, + { + "table": { + "table_name": "", + "access_type": "ALL", + "attached_condition": "(((``.`a` < 10) or (``.`a` > 30)) and (``.`a` is not null))", + "materialized_from_subquery": { + "using_temporary_table": true, + "query_block": { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 10, + "rows_produced_per_join": 10, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "1.00", + "prefix_cost": "1.50", + "data_read_per_join": "80" + }, + "used_columns": [ + "a" + ] + } + } + } + } + }, + { + "table": { + "table_name": "t3", + "access_type": "ref", + "possible_keys": [ + "a" + ], + "key": "a", + "used_key_parts": [ + "a" + ], + "key_length": "5", + "ref": [ + ".a" + ], + "rows_examined_per_scan": 10, + "rows_produced_per_join": 10, + "filtered": "100.00", + "using_join_buffer": "Batched Key Access", + "cost_info": { + "read_cost": "25.00", + "eval_cost": "1.00", + "prefix_cost": "41.01", + "data_read_per_join": "4K" + }, + "used_columns": [ + "a", + "b", + "filler" + ] + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t3`.`filler` AS `filler` from `test`.`t1` join `test`.`t3` semi join (`test`.`t2`) where ((`test`.`t3`.`a` = ``.`a`) and (`test`.`t1`.`a` = 3) and ((``.`a` < 10) or (``.`a` > 30))) +explain select straight_join * from t1 a, t1 b where a.a in (select a from t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY a NULL ALL NULL NULL NULL NULL 10 100.00 Using where +1 PRIMARY b NULL ALL NULL NULL NULL NULL 10 100.00 NULL +2 SUBQUERY t2 NULL ALL NULL NULL NULL NULL 10 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select straight_join `test`.`a`.`a` AS `a`,`test`.`b`.`a` AS `a` from `test`.`t1` `a` join `test`.`t1` `b` where (`test`.`a`.`a`,`test`.`a`.`a` in ( (/* select#2 */ select `test`.`t2`.`a` from `test`.`t2` where true ), (`test`.`a`.`a` in on where ((`test`.`a`.`a` = ``.`a`))))) +explain select * from t2 where a in (select straight_join a.a from t1 a, t1 b); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 10 100.00 Using where +2 SUBQUERY a NULL ALL NULL NULL NULL NULL 10 100.00 NULL +2 SUBQUERY b NULL ALL NULL NULL NULL NULL 10 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` where (`test`.`t2`.`a`,`test`.`t2`.`a` in ( (/* select#2 */ select straight_join `test`.`a`.`a` from `test`.`t1` `a` join `test`.`t1` `b` where true ), (`test`.`t2`.`a` in on where ((`test`.`t2`.`a` = ``.`a`))))) +explain select * from t2 where a in (select straight_join a.a from t1 a, t1 b); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 10 100.00 Using where +2 SUBQUERY a NULL ALL NULL NULL NULL NULL 10 100.00 NULL +2 SUBQUERY b NULL ALL NULL NULL NULL NULL 10 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` where (`test`.`t2`.`a`,`test`.`t2`.`a` in ( (/* select#2 */ select straight_join `test`.`a`.`a` from `test`.`t1` `a` join `test`.`t1` `b` where true ), (`test`.`t2`.`a` in on where ((`test`.`t2`.`a` = ``.`a`))))) +explain select straight_join * from t2 x, t2 y +where x.a in (select straight_join a.a from t1 a, t1 b); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY x NULL ALL NULL NULL NULL NULL 10 100.00 Using where +1 PRIMARY y NULL ALL NULL NULL NULL NULL 10 100.00 NULL +2 SUBQUERY a NULL ALL NULL NULL NULL NULL 10 100.00 NULL +2 SUBQUERY b NULL ALL NULL NULL NULL NULL 10 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select straight_join `test`.`x`.`a` AS `a`,`test`.`y`.`a` AS `a` from `test`.`t2` `x` join `test`.`t2` `y` where (`test`.`x`.`a`,`test`.`x`.`a` in ( (/* select#2 */ select straight_join `test`.`a`.`a` from `test`.`t1` `a` join `test`.`t1` `b` where true ), (`test`.`x`.`a` in on where ((`test`.`x`.`a` = ``.`a`))))) +create table t0 (a int, b int); +insert into t0 values(1,1); +explain select * from t0, t3 where t3.a in (select a from t2) and (t3.a < 10 or t3.a >30); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using where +1 SIMPLE t3 NULL ref a a 5 .a 10 100.00 Using join buffer (Batched Key Access) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 10 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select '1' AS `a`,'1' AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t3`.`filler` AS `filler` from `test`.`t3` semi join (`test`.`t2`) where ((`test`.`t3`.`a` = ``.`a`) and ((``.`a` < 10) or (``.`a` > 30))) +create table t4 as select a as x, a as y from t1; +explain select * from t0, t3 where (t3.a, t3.b) in (select x,y from t4) and (t3.a < 10 or t3.a >30); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using where +1 SIMPLE t3 NULL ref a a 5 .x 10 10.00 Using where; Using join buffer (Batched Key Access) +2 MATERIALIZED t4 NULL ALL NULL NULL NULL NULL 10 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select '1' AS `a`,'1' AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t3`.`filler` AS `filler` from `test`.`t3` semi join (`test`.`t4`) where ((`test`.`t3`.`b` = ``.`y`) and (`test`.`t3`.`a` = ``.`x`) and ((``.`x` < 10) or (``.`x` > 30))) +drop table t0,t1,t2,t3,t4; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (a int, b int, filler char(100), key(a,b)); +insert into t1 select A.a, B.a, 'filler' from t0 A, t0 B; +create table t2 as select * from t1; +explain select * from t2 where a in (select b from t1 where a=3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 100 100.00 Using where +1 SIMPLE NULL eq_ref 5 test.t2.a 1 100.00 NULL +2 MATERIALIZED t1 NULL ref a a 5 const 8 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`filler` AS `filler` from `test`.`t2` semi join (`test`.`t1`) where ((``.`b` = `test`.`t2`.`a`) and (`test`.`t1`.`a` = 3)) +explain select * from t2 where (b,a) in (select a,b from t1 where a=3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 100 10.00 Using where +1 SIMPLE t1 NULL ref a a 10 const,test.t2.a 1 100.00 Using index; FirstMatch(t2) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`filler` AS `filler` from `test`.`t2` semi join (`test`.`t1`) where ((`test`.`t1`.`b` = `test`.`t2`.`a`) and (`test`.`t2`.`b` = 3) and (`test`.`t1`.`a` = 3)) +drop table t1,t2; +create table t1 (a int, b int); +insert into t1 select a,a from t0; +create table t2 (a int, b int); +insert into t2 select A.a + 10*B.a, A.a + 10*B.a from t0 A, t0 B; +explain select * from t1 where (a,b) in (select a,b from t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 100.00 Using where +1 SIMPLE NULL eq_ref 10 test.t1.a,test.t1.b 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 100 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t2`) where ((``.`b` = `test`.`t1`.`b`) and (``.`a` = `test`.`t1`.`a`)) +drop table t0, t1, t2; +# +# Bug#19695490: CRASH IN CREATE_REF_FOR_KEY ON SELECT + JOIN + UTF8 COLUMN +# + DATETIME INDEX. +# +CREATE TABLE t1 ( +field1 varchar(255) CHARACTER SET utf8, +field2 varchar(255) CHARACTER SET utf8 +); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES +('time','time'), +('lpjdzvkp','lpjdzvkp'), +('dzvkpai', 'dzvkpai'); +CREATE TABLE t2 ( col_varchar varchar(10)); +CREATE TABLE t3 ( +pk int(11) NOT NULL, +col_varchar_255_utf8_key varchar(255) CHARACTER SET utf8, +col_varchar_10_utf8_key varchar(10) CHARACTER SET utf8, +PRIMARY KEY (pk) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t3 VALUES (22,'come','h'), +(23,'time','aaa'), +(24,'lpjdzvkp','ababa'), +(25,'d','GGDD'); +SELECT * FROM t1 WHERE (field1, field2) IN ( +SELECT table1.col_varchar_255_utf8_key AS field1, +table1.col_varchar_255_utf8_key AS field2 +FROM t3 AS table1 LEFT JOIN t2 AS table2 +ON table1.col_varchar_10_utf8_key <= +table2.col_varchar +WHERE table1.pk >= 6); +field1 field2 +time time +lpjdzvkp lpjdzvkp +DROP TABLE t1,t2,t3; +create table t0 (a decimal(4,2)); +insert into t0 values (10.24), (22.11); +create table t1 as select * from t0; +insert into t1 select * from t0; +explain select * from t0 where a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; FirstMatch(t0) +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a` from `test`.`t0` semi join (`test`.`t1`) where (`test`.`t1`.`a` = `test`.`t0`.`a`) +select * from t0 where a in (select a from t1); +a +10.24 +22.11 +drop table t0, t1; +create table t0(a date); +insert into t0 values ('2008-01-01'),('2008-02-02'); +create table t1 as select * from t0; +insert into t1 select * from t0; +explain select * from t0 where a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; FirstMatch(t0) +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a` from `test`.`t0` semi join (`test`.`t1`) where (`test`.`t1`.`a` = `test`.`t0`.`a`) +select * from t0 where a in (select a from t1); +a +2008-01-01 +2008-02-02 +drop table t0, t1; +create table t0(a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 as select a as a, a as b, a as c from t0 where a < 3; +create table t2 as select a as a, a as b from t0 where a < 3; +insert into t2 select * from t2; +explain select * from t1 where (a,b,c) in (select x.a, y.a, z.a from t2 x, t2 y, t2 z where x.b=33); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE x NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +1 SIMPLE y NULL ALL NULL NULL NULL NULL 6 16.67 Using where +1 SIMPLE z NULL ALL NULL NULL NULL NULL 6 16.67 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` semi join (`test`.`t2` `x` join `test`.`t2` `y` join `test`.`t2` `z`) where ((`test`.`z`.`a` = `test`.`t1`.`c`) and (`test`.`y`.`a` = `test`.`t1`.`b`) and (`test`.`t1`.`a` = `test`.`x`.`a`) and (`test`.`x`.`b` = 33)) +drop table t0,t1,t2; +set @save_join_buffer_size = @@join_buffer_size; +set join_buffer_size= 8192; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (a int, filler1 binary(200), filler2 binary(200)); +insert into t1 select a, 'filler123456', 'filler123456' from t0; +insert into t1 select a+10, 'filler123456', 'filler123456' from t0; +create table t2 as select * from t1; +insert into t1 select a+20, 'filler123456', 'filler123456' from t0; +insert into t1 values (2, 'duplicate ok', 'duplicate ok'); +insert into t1 values (18, 'duplicate ok', 'duplicate ok'); +insert into t2 values (3, 'duplicate ok', 'duplicate ok'); +insert into t2 values (19, 'duplicate ok', 'duplicate ok'); +explain select +a, mid(filler1, 1,10), length(filler1)=length(filler2) as z +from t1 ot where a in (select a from t2 it); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 32 10.00 Using where +2 MATERIALIZED it NULL ALL NULL NULL NULL NULL 22 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot`.`a` AS `a`,substr(`test`.`ot`.`filler1`,1,10) AS `mid(filler1, 1,10)`,(length(`test`.`ot`.`filler1`) = length(`test`.`ot`.`filler2`)) AS `z` from `test`.`t1` `ot` semi join (`test`.`t2` `it`) where (`test`.`ot`.`a` = ``.`a`) +select +a, mid(filler1, 1,10), length(filler1)=length(filler2) as z +from t1 ot where a in (select a from t2 it); +a mid(filler1, 1,10) z +0 filler1234 1 +1 filler1234 1 +10 filler1234 1 +11 filler1234 1 +12 filler1234 1 +13 filler1234 1 +14 filler1234 1 +15 filler1234 1 +16 filler1234 1 +17 filler1234 1 +18 duplicate 1 +18 filler1234 1 +19 filler1234 1 +2 duplicate 1 +2 filler1234 1 +3 filler1234 1 +4 filler1234 1 +5 filler1234 1 +6 filler1234 1 +7 filler1234 1 +8 filler1234 1 +9 filler1234 1 +explain select +a, mid(filler1, 1,10), length(filler1)=length(filler2) +from t2 ot where a in (select a from t1 it); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 22 100.00 Using where +1 SIMPLE NULL eq_ref 5 test.ot.a 1 100.00 NULL +2 MATERIALIZED it NULL ALL NULL NULL NULL NULL 32 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot`.`a` AS `a`,substr(`test`.`ot`.`filler1`,1,10) AS `mid(filler1, 1,10)`,(length(`test`.`ot`.`filler1`) = length(`test`.`ot`.`filler2`)) AS `length(filler1)=length(filler2)` from `test`.`t2` `ot` semi join (`test`.`t1` `it`) where (``.`a` = `test`.`ot`.`a`) +select +a, mid(filler1, 1,10), length(filler1)=length(filler2) +from t2 ot where a in (select a from t1 it); +a mid(filler1, 1,10) length(filler1)=length(filler2) +0 filler1234 1 +1 filler1234 1 +10 filler1234 1 +11 filler1234 1 +12 filler1234 1 +13 filler1234 1 +14 filler1234 1 +15 filler1234 1 +16 filler1234 1 +17 filler1234 1 +18 filler1234 1 +19 duplicate 1 +19 filler1234 1 +2 filler1234 1 +3 duplicate 1 +3 filler1234 1 +4 filler1234 1 +5 filler1234 1 +6 filler1234 1 +7 filler1234 1 +8 filler1234 1 +9 filler1234 1 +insert into t1 select a+20, 'filler123456', 'filler123456' from t0; +insert into t1 select a+20, 'filler123456', 'filler123456' from t0; +explain select +a, mid(filler1, 1,10), length(filler1)=length(filler2) as z +from t1 ot where a in (select a from t2 it); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 52 10.00 Using where +2 MATERIALIZED it NULL ALL NULL NULL NULL NULL 22 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot`.`a` AS `a`,substr(`test`.`ot`.`filler1`,1,10) AS `mid(filler1, 1,10)`,(length(`test`.`ot`.`filler1`) = length(`test`.`ot`.`filler2`)) AS `z` from `test`.`t1` `ot` semi join (`test`.`t2` `it`) where (`test`.`ot`.`a` = ``.`a`) +select +a, mid(filler1, 1,10), length(filler1)=length(filler2) as z +from t1 ot where a in (select a from t2 it); +a mid(filler1, 1,10) z +0 filler1234 1 +1 filler1234 1 +10 filler1234 1 +11 filler1234 1 +12 filler1234 1 +13 filler1234 1 +14 filler1234 1 +15 filler1234 1 +16 filler1234 1 +17 filler1234 1 +18 duplicate 1 +18 filler1234 1 +19 filler1234 1 +2 duplicate 1 +2 filler1234 1 +3 filler1234 1 +4 filler1234 1 +5 filler1234 1 +6 filler1234 1 +7 filler1234 1 +8 filler1234 1 +9 filler1234 1 +explain select +a, mid(filler1, 1,10), length(filler1)=length(filler2) +from t2 ot where a in (select a from t1 it); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 22 100.00 Using where +1 SIMPLE NULL eq_ref 5 test.ot.a 1 100.00 NULL +2 MATERIALIZED it NULL ALL NULL NULL NULL NULL 52 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot`.`a` AS `a`,substr(`test`.`ot`.`filler1`,1,10) AS `mid(filler1, 1,10)`,(length(`test`.`ot`.`filler1`) = length(`test`.`ot`.`filler2`)) AS `length(filler1)=length(filler2)` from `test`.`t2` `ot` semi join (`test`.`t1` `it`) where (``.`a` = `test`.`ot`.`a`) +select +a, mid(filler1, 1,10), length(filler1)=length(filler2) +from t2 ot where a in (select a from t1 it); +a mid(filler1, 1,10) length(filler1)=length(filler2) +0 filler1234 1 +1 filler1234 1 +10 filler1234 1 +11 filler1234 1 +12 filler1234 1 +13 filler1234 1 +14 filler1234 1 +15 filler1234 1 +16 filler1234 1 +17 filler1234 1 +18 filler1234 1 +19 duplicate 1 +19 filler1234 1 +2 filler1234 1 +3 duplicate 1 +3 filler1234 1 +4 filler1234 1 +5 filler1234 1 +6 filler1234 1 +7 filler1234 1 +8 filler1234 1 +9 filler1234 1 +set @@join_buffer_size = @save_join_buffer_size; +drop table t1, t2; +create table t1 (a int, b int, key(a)); +create table t2 (a int, b int, key(a)); +create table t3 (a int, b int, key(a)); +insert into t1 select a,a from t0; +insert into t2 select a,a from t0; +insert into t3 select a,a from t0; +t2 and t3 must be use 'ref', not 'ALL': +explain select * +from t0 where a in +(select t2.a+t3.a from t1 left join (t2 join t3) on t2.a=t1.a and t3.a=t1.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 10 100.00 Using where +1 SIMPLE NULL eq_ref 9 test.t0.a 1 100.00 Using where +2 MATERIALIZED t1 NULL index a a 5 NULL 10 100.00 Using index +2 MATERIALIZED t2 NULL ref a a 5 test.t1.a 1 100.00 Using index +2 MATERIALIZED t3 NULL ref a a 5 test.t1.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a` from `test`.`t0` semi join (`test`.`t1` join `test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`a` = `test`.`t1`.`a`) and (`test`.`t3`.`a` = `test`.`t1`.`a`) and (`test`.`t0`.`a` = ``.`t2.a+t3.a`)) +drop table t0, t1,t2,t3; + +Test that neither MaterializeLookup strategy for semijoin, +nor subquery materialization is used when BLOBs are involved +(except when arguments of some functions). + +set @prefix_len = 6; +set @blob_len = 16; +set @suffix_len = @blob_len - @prefix_len; +create table t1_16 (a1 blob(16), a2 blob(16)); +create table t2_16 (b1 blob(16), b2 blob(16)); +create table t3_16 (c1 blob(16), c2 blob(16)); +insert into t1_16 values +(concat('1 - 00', repeat('x', @suffix_len)), concat('2 - 00', repeat('x', @suffix_len))); +insert into t1_16 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t1_16 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_16 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t2_16 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_16 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_16 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t3_16 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t3_16 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_16 values +(concat('1 - 04', repeat('x', @suffix_len)), concat('2 - 04', repeat('x', @suffix_len))); +explain select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select b1 from t2_16 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1_16 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +2 MATERIALIZED t2_16 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_16`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_16`.`a2`,7) AS `left(a2,7)` from `test`.`t1_16` semi join (`test`.`t2_16`) where ((`test`.`t1_16`.`a1` = ``.`b1`) and (`test`.`t2_16`.`b1` > '0')) +select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select b1 from t2_16 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_16 +where (a1,a2) in (select b1, b2 from t2_16 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1_16 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +2 MATERIALIZED t2_16 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_16`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_16`.`a2`,7) AS `left(a2,7)` from `test`.`t1_16` semi join (`test`.`t2_16`) where ((`test`.`t1_16`.`a2` = ``.`b2`) and (`test`.`t1_16`.`a1` = ``.`b1`) and (`test`.`t2_16`.`b1` > '0')) +select left(a1,7), left(a2,7) +from t1_16 +where (a1,a2) in (select b1, b2 from t2_16 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select substring(b1,1,16) from t2_16 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1_16 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +2 MATERIALIZED t2_16 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_16`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_16`.`a2`,7) AS `left(a2,7)` from `test`.`t1_16` semi join (`test`.`t2_16`) where ((`test`.`t2_16`.`b1` > '0') and (`test`.`t1_16`.`a1` = ``.`substring(b1,1,16)`)) +select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select substring(b1,1,16) from t2_16 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select group_concat(b1) from t2_16 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_16 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t2_16 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_16`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_16`.`a2`,7) AS `left(a2,7)` from `test`.`t1_16` where (`test`.`t1_16`.`a1`,(/* select#2 */ select group_concat(`test`.`t2_16`.`b1` separator ',') from `test`.`t2_16` group by `test`.`t2_16`.`b2` having ((`test`.`t1_16`.`a1`) = (group_concat(`test`.`t2_16`.`b1` separator ','))))) +select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select group_concat(b1) from t2_16 group by b2); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +set @@group_concat_max_len = 256; +explain select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select group_concat(b1) from t2_16 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_16 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 SUBQUERY t2_16 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_16`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_16`.`a2`,7) AS `left(a2,7)` from `test`.`t1_16` where (`test`.`t1_16`.`a1`,`test`.`t1_16`.`a1` in ( (/* select#2 */ select group_concat(`test`.`t2_16`.`b1` separator ',') from `test`.`t2_16` group by `test`.`t2_16`.`b2` having true ), (`test`.`t1_16`.`a1` in on where ((`test`.`t1_16`.`a1` = ``.`group_concat(b1)`))))) +select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select group_concat(b1) from t2_16 group by b2); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +create table t1 (a1 char(8), a2 char(8)) charset latin1; +create table t2 (b1 char(8), b2 char(8)) charset latin1; +create table t3 (c1 char(8), c2 char(8)) charset latin1; +insert into t1 values ('1 - 00', '2 - 00'); +insert into t1 values ('1 - 01', '2 - 01'); +insert into t1 values ('1 - 02', '2 - 02'); +insert into t2 values ('1 - 01', '2 - 01'); +insert into t2 values ('1 - 01', '2 - 01'); +insert into t2 values ('1 - 02', '2 - 02'); +insert into t2 values ('1 - 02', '2 - 02'); +insert into t2 values ('1 - 03', '2 - 03'); +insert into t3 values ('1 - 01', '2 - 01'); +insert into t3 values ('1 - 02', '2 - 02'); +insert into t3 values ('1 - 03', '2 - 03'); +insert into t3 values ('1 - 04', '2 - 04'); +insert into t3 values ('1 - 05', '2 - 05'); +insert into t3 values ('1 - 06', '2 - 06'); +insert into t3 values ('1 - 07', '2 - 07'); +insert into t3 values ('1 - 08', '2 - 08'); +explain +select * from t1 +where concat(a1,'x') IN +(select left(a1,8) from t1_16 +where (a1, a2) IN +(select t2_16.b1, t2_16.b2 from t2_16, t2 +where t2.b2 = substring(t2_16.b2,1,6) and +t2.b1 IN (select c1 from t3 where c2 > '0'))); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE t1_16 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t2_16 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 5 20.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` semi join (`test`.`t1_16` join `test`.`t2_16` join `test`.`t2` join `test`.`t3`) where ((`test`.`t2_16`.`b2` = `test`.`t1_16`.`a2`) and (`test`.`t2_16`.`b1` = `test`.`t1_16`.`a1`) and (`test`.`t3`.`c1` = `test`.`t2`.`b1`) and (`test`.`t2`.`b2` = substr(`test`.`t2_16`.`b2`,1,6)) and (`test`.`t3`.`c2` > '0') and (concat(`test`.`t1`.`a1`,'x') = left(`test`.`t1_16`.`a1`,8))) +drop table t1_16, t2_16, t3_16, t1, t2, t3; +set @blob_len = 512; +set @suffix_len = @blob_len - @prefix_len; +create table t1_512 (a1 blob(512), a2 blob(512)); +create table t2_512 (b1 blob(512), b2 blob(512)); +create table t3_512 (c1 blob(512), c2 blob(512)); +insert into t1_512 values +(concat('1 - 00', repeat('x', @suffix_len)), concat('2 - 00', repeat('x', @suffix_len))); +insert into t1_512 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t1_512 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_512 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t2_512 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_512 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_512 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t3_512 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t3_512 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_512 values +(concat('1 - 04', repeat('x', @suffix_len)), concat('2 - 04', repeat('x', @suffix_len))); +explain select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select b1 from t2_512 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1_512 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +2 MATERIALIZED t2_512 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_512`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_512`.`a2`,7) AS `left(a2,7)` from `test`.`t1_512` semi join (`test`.`t2_512`) where ((`test`.`t1_512`.`a1` = ``.`b1`) and (`test`.`t2_512`.`b1` > '0')) +select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select b1 from t2_512 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_512 +where (a1,a2) in (select b1, b2 from t2_512 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1_512 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +2 MATERIALIZED t2_512 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_512`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_512`.`a2`,7) AS `left(a2,7)` from `test`.`t1_512` semi join (`test`.`t2_512`) where ((`test`.`t1_512`.`a2` = ``.`b2`) and (`test`.`t1_512`.`a1` = ``.`b1`) and (`test`.`t2_512`.`b1` > '0')) +select left(a1,7), left(a2,7) +from t1_512 +where (a1,a2) in (select b1, b2 from t2_512 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select substring(b1,1,512) from t2_512 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1_512 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +2 MATERIALIZED t2_512 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_512`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_512`.`a2`,7) AS `left(a2,7)` from `test`.`t1_512` semi join (`test`.`t2_512`) where ((`test`.`t2_512`.`b1` > '0') and (`test`.`t1_512`.`a1` = ``.`substring(b1,1,512)`)) +select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select substring(b1,1,512) from t2_512 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select group_concat(b1) from t2_512 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_512 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 SUBQUERY t2_512 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_512`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_512`.`a2`,7) AS `left(a2,7)` from `test`.`t1_512` where (`test`.`t1_512`.`a1`,`test`.`t1_512`.`a1` in ( (/* select#2 */ select group_concat(`test`.`t2_512`.`b1` separator ',') from `test`.`t2_512` group by `test`.`t2_512`.`b2` having true ), (`test`.`t1_512`.`a1` in on where ((`test`.`t1_512`.`a1` = ``.`group_concat(b1)`))))) +select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select group_concat(b1) from t2_512 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +set @@group_concat_max_len = 256; +explain select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select group_concat(b1) from t2_512 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_512 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 SUBQUERY t2_512 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_512`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_512`.`a2`,7) AS `left(a2,7)` from `test`.`t1_512` where (`test`.`t1_512`.`a1`,`test`.`t1_512`.`a1` in ( (/* select#2 */ select group_concat(`test`.`t2_512`.`b1` separator ',') from `test`.`t2_512` group by `test`.`t2_512`.`b2` having true ), (`test`.`t1_512`.`a1` in on where ((`test`.`t1_512`.`a1` = ``.`group_concat(b1)`))))) +select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select group_concat(b1) from t2_512 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +drop table t1_512, t2_512, t3_512; +set @blob_len = 513; +set @suffix_len = @blob_len - @prefix_len; +create table t1_513 (a1 blob(513), a2 blob(513)); +create table t2_513 (b1 blob(513), b2 blob(513)); +create table t3_513 (c1 blob(513), c2 blob(513)); +insert into t1_513 values +(concat('1 - 00', repeat('x', @suffix_len)), concat('2 - 00', repeat('x', @suffix_len))); +insert into t1_513 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t1_513 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_513 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t2_513 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_513 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_513 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t3_513 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t3_513 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_513 values +(concat('1 - 04', repeat('x', @suffix_len)), concat('2 - 04', repeat('x', @suffix_len))); +explain select left(a1,7), left(a2,7) +from t1_513 +where a1 in (select b1 from t2_513 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1_513 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +2 MATERIALIZED t2_513 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_513`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_513`.`a2`,7) AS `left(a2,7)` from `test`.`t1_513` semi join (`test`.`t2_513`) where ((`test`.`t1_513`.`a1` = ``.`b1`) and (`test`.`t2_513`.`b1` > '0')) +select left(a1,7), left(a2,7) +from t1_513 +where a1 in (select b1 from t2_513 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_513 +where (a1,a2) in (select b1, b2 from t2_513 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1_513 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +2 MATERIALIZED t2_513 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_513`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_513`.`a2`,7) AS `left(a2,7)` from `test`.`t1_513` semi join (`test`.`t2_513`) where ((`test`.`t1_513`.`a2` = ``.`b2`) and (`test`.`t1_513`.`a1` = ``.`b1`) and (`test`.`t2_513`.`b1` > '0')) +select left(a1,7), left(a2,7) +from t1_513 +where (a1,a2) in (select b1, b2 from t2_513 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_513 +where a1 in (select substring(b1,1,513) from t2_513 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1_513 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +2 MATERIALIZED t2_513 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_513`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_513`.`a2`,7) AS `left(a2,7)` from `test`.`t1_513` semi join (`test`.`t2_513`) where ((`test`.`t2_513`.`b1` > '0') and (`test`.`t1_513`.`a1` = ``.`substring(b1,1,513)`)) +select left(a1,7), left(a2,7) +from t1_513 +where a1 in (select substring(b1,1,513) from t2_513 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_513 +where a1 in (select group_concat(b1) from t2_513 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_513 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 SUBQUERY t2_513 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_513`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_513`.`a2`,7) AS `left(a2,7)` from `test`.`t1_513` where (`test`.`t1_513`.`a1`,`test`.`t1_513`.`a1` in ( (/* select#2 */ select group_concat(`test`.`t2_513`.`b1` separator ',') from `test`.`t2_513` group by `test`.`t2_513`.`b2` having true ), (`test`.`t1_513`.`a1` in on where ((`test`.`t1_513`.`a1` = ``.`group_concat(b1)`))))) +select left(a1,7), left(a2,7) +from t1_513 +where a1 in (select group_concat(b1) from t2_513 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +drop table t1_513, t2_513, t3_513; +set @blob_len = 1024; +set @suffix_len = @blob_len - @prefix_len; +create table t1_1024 (a1 blob(1024), a2 blob(1024)); +create table t2_1024 (b1 blob(1024), b2 blob(1024)); +create table t3_1024 (c1 blob(1024), c2 blob(1024)); +insert into t1_1024 values +(concat('1 - 00', repeat('x', @suffix_len)), concat('2 - 00', repeat('x', @suffix_len))); +insert into t1_1024 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t1_1024 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_1024 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t2_1024 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_1024 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_1024 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t3_1024 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t3_1024 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_1024 values +(concat('1 - 04', repeat('x', @suffix_len)), concat('2 - 04', repeat('x', @suffix_len))); +explain select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select b1 from t2_1024 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1_1024 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +2 MATERIALIZED t2_1024 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1024`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1024`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1024` semi join (`test`.`t2_1024`) where ((`test`.`t1_1024`.`a1` = ``.`b1`) and (`test`.`t2_1024`.`b1` > '0')) +select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select b1 from t2_1024 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_1024 +where (a1,a2) in (select b1, b2 from t2_1024 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1_1024 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +2 MATERIALIZED t2_1024 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1024`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1024`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1024` semi join (`test`.`t2_1024`) where ((`test`.`t1_1024`.`a2` = ``.`b2`) and (`test`.`t1_1024`.`a1` = ``.`b1`) and (`test`.`t2_1024`.`b1` > '0')) +select left(a1,7), left(a2,7) +from t1_1024 +where (a1,a2) in (select b1, b2 from t2_1024 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select substring(b1,1,1024) from t2_1024 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1_1024 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +2 MATERIALIZED t2_1024 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1024`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1024`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1024` semi join (`test`.`t2_1024`) where ((`test`.`t2_1024`.`b1` > '0') and (`test`.`t1_1024`.`a1` = ``.`substring(b1,1,1024)`)) +select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select substring(b1,1,1024) from t2_1024 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select group_concat(b1) from t2_1024 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_1024 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 SUBQUERY t2_1024 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1024`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1024`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1024` where (`test`.`t1_1024`.`a1`,`test`.`t1_1024`.`a1` in ( (/* select#2 */ select group_concat(`test`.`t2_1024`.`b1` separator ',') from `test`.`t2_1024` group by `test`.`t2_1024`.`b2` having true ), (`test`.`t1_1024`.`a1` in on where ((`test`.`t1_1024`.`a1` = ``.`group_concat(b1)`))))) +select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select group_concat(b1) from t2_1024 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +set @@group_concat_max_len = 256; +explain select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select group_concat(b1) from t2_1024 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_1024 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 SUBQUERY t2_1024 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1024`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1024`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1024` where (`test`.`t1_1024`.`a1`,`test`.`t1_1024`.`a1` in ( (/* select#2 */ select group_concat(`test`.`t2_1024`.`b1` separator ',') from `test`.`t2_1024` group by `test`.`t2_1024`.`b2` having true ), (`test`.`t1_1024`.`a1` in on where ((`test`.`t1_1024`.`a1` = ``.`group_concat(b1)`))))) +select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select group_concat(b1) from t2_1024 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +drop table t1_1024, t2_1024, t3_1024; +set @blob_len = 1025; +set @suffix_len = @blob_len - @prefix_len; +create table t1_1025 (a1 blob(1025), a2 blob(1025)); +create table t2_1025 (b1 blob(1025), b2 blob(1025)); +create table t3_1025 (c1 blob(1025), c2 blob(1025)); +insert into t1_1025 values +(concat('1 - 00', repeat('x', @suffix_len)), concat('2 - 00', repeat('x', @suffix_len))); +insert into t1_1025 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t1_1025 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_1025 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t2_1025 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_1025 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_1025 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t3_1025 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t3_1025 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_1025 values +(concat('1 - 04', repeat('x', @suffix_len)), concat('2 - 04', repeat('x', @suffix_len))); +explain select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select b1 from t2_1025 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1_1025 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +2 MATERIALIZED t2_1025 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1025`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1025`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1025` semi join (`test`.`t2_1025`) where ((`test`.`t1_1025`.`a1` = ``.`b1`) and (`test`.`t2_1025`.`b1` > '0')) +select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select b1 from t2_1025 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_1025 +where (a1,a2) in (select b1, b2 from t2_1025 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1_1025 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +2 MATERIALIZED t2_1025 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1025`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1025`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1025` semi join (`test`.`t2_1025`) where ((`test`.`t1_1025`.`a2` = ``.`b2`) and (`test`.`t1_1025`.`a1` = ``.`b1`) and (`test`.`t2_1025`.`b1` > '0')) +select left(a1,7), left(a2,7) +from t1_1025 +where (a1,a2) in (select b1, b2 from t2_1025 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select substring(b1,1,1025) from t2_1025 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1_1025 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +2 MATERIALIZED t2_1025 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1025`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1025`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1025` semi join (`test`.`t2_1025`) where ((`test`.`t2_1025`.`b1` > '0') and (`test`.`t1_1025`.`a1` = ``.`substring(b1,1,1025)`)) +select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select substring(b1,1,1025) from t2_1025 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select group_concat(b1) from t2_1025 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_1025 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 SUBQUERY t2_1025 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1025`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1025`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1025` where (`test`.`t1_1025`.`a1`,`test`.`t1_1025`.`a1` in ( (/* select#2 */ select group_concat(`test`.`t2_1025`.`b1` separator ',') from `test`.`t2_1025` group by `test`.`t2_1025`.`b2` having true ), (`test`.`t1_1025`.`a1` in on where ((`test`.`t1_1025`.`a1` = ``.`group_concat(b1)`))))) +select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select group_concat(b1) from t2_1025 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +set @@group_concat_max_len = 256; +explain select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select group_concat(b1) from t2_1025 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_1025 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 SUBQUERY t2_1025 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1025`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1025`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1025` where (`test`.`t1_1025`.`a1`,`test`.`t1_1025`.`a1` in ( (/* select#2 */ select group_concat(`test`.`t2_1025`.`b1` separator ',') from `test`.`t2_1025` group by `test`.`t2_1025`.`b2` having true ), (`test`.`t1_1025`.`a1` in on where ((`test`.`t1_1025`.`a1` = ``.`group_concat(b1)`))))) +select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select group_concat(b1) from t2_1025 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +drop table t1_1025, t2_1025, t3_1025; +# +# WL#5561: Enable semi join transformation with outer join. +# +CREATE TABLE ot1(a INT); +CREATE TABLE ot2(a INT); +CREATE TABLE ot3(a INT); +CREATE TABLE it1(a INT); +CREATE TABLE it2(a INT); +CREATE TABLE it3(a INT); +INSERT INTO ot1 VALUES(0),(1),(2),(3),(4),(5),(6),(7); +INSERT INTO ot2 VALUES(0),(2),(4),(6); +INSERT INTO ot3 VALUES(0),(3),(6); +INSERT INTO it1 VALUES(0),(1),(2),(3),(4),(5),(6),(7); +INSERT INTO it2 VALUES(0),(2),(4),(6); +INSERT INTO it3 VALUES(0),(3),(6); +# Test cases, Subquery Pattern 1 +# Example SQ1.1: +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE ot1.a IN (SELECT a FROM it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE it3 NULL ALL NULL NULL NULL NULL 3 100.00 Start temporary +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; End temporary +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` left join `test`.`ot2` on((`test`.`ot2`.`a` = `test`.`it3`.`a`)) semi join (`test`.`it3`) where (`test`.`ot1`.`a` = `test`.`it3`.`a`) +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE ot1.a IN (SELECT a FROM it3); +a a +0 0 +3 NULL +6 6 +# Example SQ1.2: +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE COALESCE(ot2.a,0) IN (SELECT a FROM it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +2 MATERIALIZED it3 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` left join `test`.`ot2` on((`test`.`ot2`.`a` = `test`.`ot1`.`a`)) semi join (`test`.`it3`) where (coalesce(`test`.`ot2`.`a`,0) = ``.`a`) +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE COALESCE(ot2.a,0) IN (SELECT a FROM it3); +a a +0 0 +1 NULL +3 NULL +5 NULL +6 6 +7 NULL +# Example SQ1.3: +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE (ot1.a,ot2.a) IN (SELECT a, a FROM it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE it3 NULL ALL NULL NULL NULL NULL 3 100.00 Start temporary +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` join `test`.`ot2` semi join (`test`.`it3`) where ((`test`.`ot2`.`a` = `test`.`it3`.`a`) and (`test`.`ot1`.`a` = `test`.`it3`.`a`)) +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE (ot1.a,ot2.a) IN (SELECT a, a FROM it3); +a a +0 0 +6 6 +# More test cases +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 +WHERE ot1.a IN (SELECT a FROM it3); +a a +0 0 +3 NULL +6 6 +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 +WHERE ot1.a IN (SELECT a+0 FROM it3); +a a +0 0 +3 NULL +6 6 +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 +WHERE COALESCE(ot2.a,0) IN (SELECT a FROM it3); +a a +0 0 +1 NULL +3 NULL +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE COALESCE(ot2.a,0) IN (SELECT a+0 FROM it3); +a a +0 0 +1 NULL +3 NULL +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 +WHERE (ot1.a,ot2.a) IN (SELECT a, a FROM it3); +a a +0 0 +6 6 +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +LEFT JOIN ot3 ON ot1.a=ot3.a +WHERE ot1.a IN (SELECT a FROM it3); +a a a +0 0 0 +3 NULL 3 +6 6 6 +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +LEFT JOIN ot3 ON ot1.a=ot3.a +WHERE COALESCE(ot2.a,0) IN (SELECT a FROM it3); +a a a +0 0 0 +1 NULL NULL +3 NULL 3 +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +LEFT JOIN ot3 ON ot1.a=ot3.a +WHERE COALESCE(ot3.a,0) IN (SELECT a FROM it3); +a a a +0 0 0 +1 NULL NULL +2 2 NULL +3 NULL 3 +4 4 NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +LEFT JOIN ot3 ON ot2.a=ot3.a +WHERE ot1.a IN (SELECT a FROM it3); +a a a +0 0 0 +3 NULL NULL +6 6 6 +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +LEFT JOIN ot3 ON ot2.a=ot3.a +WHERE COALESCE(ot2.a,0) IN (SELECT a FROM it3); +a a a +0 0 0 +1 NULL NULL +3 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +LEFT JOIN ot3 ON ot2.a=ot3.a +WHERE COALESCE(ot3.a,0) IN (SELECT a FROM it3); +a a a +0 0 0 +1 NULL NULL +2 2 NULL +3 NULL NULL +4 4 NULL +5 NULL NULL +6 6 6 +7 NULL NULL +# Test cases, Subquery Pattern 2 +# Example SQ2.1: +explain SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE it3 NULL ALL NULL NULL NULL NULL 3 100.00 Start temporary +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; End temporary +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` join `test`.`ot2` semi join (`test`.`it3`) where ((`test`.`ot1`.`a` = `test`.`it3`.`a`) and (`test`.`ot2`.`a` = `test`.`it3`.`a`)) +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3); +a a +0 0 +6 6 +# Example SQ2.2: +explain SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it2) +AND ot2.a IN (SELECT a FROM it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE it3 NULL ALL NULL NULL NULL NULL 3 100.00 Start temporary +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where +1 SIMPLE it2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` join `test`.`ot2` semi join (`test`.`it2`) semi join (`test`.`it3`) where ((`test`.`ot2`.`a` = `test`.`it3`.`a`) and (`test`.`it2`.`a` = `test`.`it3`.`a`) and (`test`.`ot1`.`a` = `test`.`it3`.`a`)) +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it2) +AND ot2.a IN (SELECT a FROM it3); +a a +0 0 +6 6 +# More test cases +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it3); +a a +0 0 +6 6 +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it3); +a a +0 0 +6 6 +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a+0 AND ot2.a IN (SELECT a FROM it3); +a a +0 0 +6 6 +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot2.a IN (SELECT a+0 FROM it3); +a a +0 0 +6 6 +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it2) +AND ot2.a IN (SELECT a+0 FROM it3); +a a +0 0 +6 6 +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3) +JOIN ot3 ON ot2.a=ot3.a AND ot3.a IN (SELECT a FROM it3); +a a a +0 0 0 +6 6 6 +# Test cases, Subquery Pattern 3 +# Example SQ3.1: +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +1 SIMPLE NULL eq_ref 5 test.ot1.a 1 100.00 NULL +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +2 MATERIALIZED it3 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` semi join (`test`.`it3`)) on(((``.`a` = `test`.`ot1`.`a`) and (`test`.`ot2`.`a` = `test`.`ot1`.`a`))) where true +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3); +a a +0 0 +1 NULL +2 NULL +3 NULL +4 NULL +5 NULL +6 6 +7 NULL +# Example SQ3.2: +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot2.a IN (SELECT a FROM it2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +1 SIMPLE NULL eq_ref 5 test.ot2.a 1 100.00 Using where +2 MATERIALIZED it2 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` semi join (`test`.`it2`)) on(((`test`.`ot2`.`a` = `test`.`ot1`.`a`) and (``.`a` = `test`.`ot1`.`a`))) where true +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot2.a IN (SELECT a FROM it2); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +# Example SQ3.3 +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1) +AND ot2.a IN (SELECT a FROM it2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +1 SIMPLE NULL eq_ref 5 test.ot1.a 1 100.00 NULL +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +1 SIMPLE NULL eq_ref 5 test.ot2.a 1 100.00 Using where +2 MATERIALIZED it1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +3 MATERIALIZED it2 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` semi join (`test`.`it1`) semi join (`test`.`it2`)) on(((``.`a` = `test`.`ot1`.`a`) and (`test`.`ot2`.`a` = `test`.`ot1`.`a`) and (``.`a` = `test`.`ot1`.`a`))) where true +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1) +AND ot2.a IN (SELECT a FROM it2); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +# Example SQ3.4 +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND +(ot1.a, ot2.a) IN (SELECT it1.a, it2.a +FROM it1 JOIN it2 ON it1.a=it2.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +1 SIMPLE NULL eq_ref 10 test.ot1.a,test.ot2.a 1 100.00 Using where +2 MATERIALIZED it2 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +2 MATERIALIZED it1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` semi join (`test`.`it1` join `test`.`it2`)) on(((`test`.`ot2`.`a` = `test`.`ot1`.`a`) and (``.`a` = `test`.`ot1`.`a`) and (``.`a` = `test`.`ot1`.`a`) and (`test`.`it1`.`a` = `test`.`it2`.`a`))) where true +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND +(ot1.a, ot2.a) IN (SELECT it1.a, it2.a +FROM it1 JOIN it2 ON it1.a=it2.a); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +# More test cases +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it3); +a a +0 0 +1 NULL +2 NULL +3 NULL +4 NULL +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it3); +a a +0 0 +1 NULL +2 NULL +3 NULL +4 NULL +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 AND ot2.a IN (SELECT a FROM it2); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot2.a IN (SELECT a+0 FROM it2); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a+0 FROM it1) +AND ot2.a IN (SELECT a+0 FROM it2); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 AND +(ot1.a, ot2.a) IN (SELECT it1.a+0, it2.a+0 +FROM it1 JOIN it2 ON it1.a=it2.a); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +EXPLAIN FORMAT=tree SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3) +LEFT JOIN ot3 ON ot2.a=ot3.a AND ot3.a IN (SELECT a FROM it3); +EXPLAIN +-> Nested loop left join (cost=56.54 rows=288) + -> Nested loop left join (cost=11.70 rows=96) + -> Table scan on ot1 (cost=1.30 rows=8) + -> Nested loop inner join (cost=6.31 rows=12) + -> Single-row index lookup on using (a=ot1.a) + -> Materialize with deduplication (cost=1.10..1.10 rows=3) + -> Filter: (it3.a is not null) (cost=0.80 rows=3) + -> Table scan on it3 (cost=0.80 rows=3) + -> Filter: (ot2.a = ot1.a) (cost=0.55 rows=4) + -> Table scan on ot2 (cost=0.55 rows=4) + -> Nested loop inner join (cost=10.41 rows=3) + -> Filter: (ot3.a = ot2.a) (cost=0.51 rows=3) + -> Table scan on ot3 (cost=0.51 rows=3) + -> Filter: (``.a = ot2.a) (cost=3.23..3.23 rows=1) + -> Single-row index lookup on using (a=ot3.a) + -> Materialize with deduplication (cost=1.10..1.10 rows=3) + -> Filter: (it3.a is not null) (cost=0.80 rows=3) + -> Table scan on it3 (cost=0.80 rows=3) + +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3) +LEFT JOIN ot3 ON ot2.a=ot3.a AND ot3.a IN (SELECT a FROM it3); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it3) +LEFT JOIN ot3 ON ot2.a=ot3.a+0 AND ot3.a IN (SELECT a FROM it3); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +# Test cases, Subquery Pattern 4 +# Example SQ4.1: +explain SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +1 SIMPLE NULL eq_ref 5 test.ot1.a 1 100.00 NULL +1 SIMPLE ot3 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +2 MATERIALIZED it1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a`,`test`.`ot3`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` join `test`.`ot3` semi join (`test`.`it1`)) on(((``.`a` = `test`.`ot1`.`a`) and (`test`.`ot3`.`a` = `test`.`ot1`.`a`) and (`test`.`ot2`.`a` = `test`.`ot1`.`a`))) where true +SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +# Example SQ4.2: +explain SELECT * +FROM ot1 +JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot3 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where +1 SIMPLE NULL eq_ref 5 test.ot3.a 1 100.00 NULL +2 MATERIALIZED it1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a`,`test`.`ot3`.`a` AS `a` from `test`.`ot1` join `test`.`ot2` join `test`.`ot3` semi join (`test`.`it1`) where ((`test`.`ot2`.`a` = `test`.`ot3`.`a`) and (`test`.`ot1`.`a` = `test`.`ot3`.`a`) and (``.`a` = `test`.`ot3`.`a`)) +SELECT * +FROM ot1 +JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +6 6 6 +# Example SQ4.3: +explain SELECT * +FROM ot1 +JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where +1 SIMPLE NULL eq_ref 5 test.ot2.a 1 100.00 NULL +1 SIMPLE ot3 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 MATERIALIZED it1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a`,`test`.`ot3`.`a` AS `a` from `test`.`ot1` join `test`.`ot2` left join `test`.`ot3` on((`test`.`ot3`.`a` = `test`.`ot2`.`a`)) semi join (`test`.`it1`) where ((`test`.`ot1`.`a` = `test`.`ot2`.`a`) and (``.`a` = `test`.`ot2`.`a`)) +SELECT * +FROM ot1 +JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +2 2 NULL +4 4 NULL +6 6 6 +# Example SQ4.4: +explain SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +1 SIMPLE NULL eq_ref 5 test.ot1.a 1 100.00 NULL +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +1 SIMPLE ot3 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 MATERIALIZED it1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a`,`test`.`ot3`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` left join `test`.`ot3` on((`test`.`ot3`.`a` = `test`.`ot1`.`a`)) semi join (`test`.`it1`)) on(((``.`a` = `test`.`ot1`.`a`) and (`test`.`ot2`.`a` = `test`.`ot1`.`a`))) where true +SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +1 NULL NULL +2 2 NULL +3 NULL NULL +4 4 NULL +5 NULL NULL +6 6 6 +7 NULL NULL +# More test cases +SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a+0) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it1); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 +JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a+0) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +6 6 6 +SELECT * +FROM ot1 +JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +6 6 6 +SELECT * +FROM ot1 +JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it1); +a a a +0 0 0 +6 6 6 +SELECT * +FROM ot1 +JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a+0) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +2 2 NULL +4 4 NULL +6 6 6 +SELECT * +FROM ot1 +JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +2 2 NULL +4 4 NULL +6 6 6 +SELECT * +FROM ot1 +JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it1); +a a a +0 0 0 +2 2 NULL +4 4 NULL +6 6 6 +SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a+0) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +1 NULL NULL +2 2 NULL +3 NULL NULL +4 4 NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +1 NULL NULL +2 2 NULL +3 NULL NULL +4 4 NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it1); +a a a +0 0 0 +1 NULL NULL +2 2 NULL +3 NULL NULL +4 4 NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1) +LEFT JOIN +ot1 AS ot4 +ON ot2.a=ot4.a; +a a a a +0 0 0 0 +1 NULL NULL NULL +2 2 NULL 2 +3 NULL NULL NULL +4 4 NULL 4 +5 NULL NULL NULL +6 6 6 6 +7 NULL NULL NULL +SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a +LEFT JOIN ot1 AS ot4 ON ot3.a=ot4.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a a +0 0 0 0 +1 NULL NULL NULL +2 2 NULL NULL +3 NULL NULL NULL +4 4 NULL NULL +5 NULL NULL NULL +6 6 6 6 +7 NULL NULL NULL +DROP TABLE ot1,ot2,ot3,it1,it2,it3; +CREATE TABLE t ( +a INTEGER DEFAULT NULL +) ENGINE=InnoDB; +INSERT INTO t VALUES (1); +CREATE TABLE t2 ( +a INTEGER DEFAULT NULL +) ENGINE=InnoDB; +INSERT INTO t2 VALUES (1),(1); +CREATE TABLE t4 ( +a INTEGER DEFAULT NULL +) ENGINE=InnoDB; +INSERT INTO t4 VALUES (1),(1); +CREATE TABLE v ( +a INTEGER DEFAULT NULL +) ENGINE=InnoDB; +INSERT INTO v VALUES (1),(1); +explain SELECT * +FROM t AS t1 +LEFT JOIN +(t2 +LEFT JOIN t AS t3 +ON t3.a IN (SELECT a FROM t AS it) +JOIN t4 +ON t4.a=100 +) +ON TRUE +WHERE t1.a IN (SELECT * FROM v AS it2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE it2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE it NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t3) +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t4`.`a` AS `a` from `test`.`t` `t1` left join (`test`.`t2` left join (`test`.`t` `t3` semi join (`test`.`t` `it`)) on(((`test`.`it`.`a` = `test`.`t3`.`a`))) join `test`.`t4`) on(((`test`.`t4`.`a` = 100))) semi join (`test`.`v` `it2`) where (`test`.`it2`.`a` = `test`.`t1`.`a`) +SELECT * +FROM t AS t1 +LEFT JOIN +(t2 +LEFT JOIN t AS t3 +ON t3.a IN (SELECT a FROM t AS it) +JOIN t4 +ON t4.a=100 +) +ON TRUE +WHERE t1.a IN (SELECT * FROM v AS it2); +a a a a +1 NULL NULL NULL +DROP TABLE t,t2,t4,v; +# End of WL#5561 +# +# Bug#48868: Left outer join in subquery causes segmentation fault in +# make_join_select. +# +CREATE TABLE t1 (i INTEGER); +INSERT INTO t1 VALUES (1); +INSERT INTO t1 VALUES (2); +CREATE TABLE t2 (i INTEGER); +INSERT INTO t2 VALUES(1); +CREATE TABLE t3 (i INTEGER); +INSERT INTO t3 VALUES (1); +INSERT INTO t3 VALUES (2); +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t2.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +1 +DROP TABLE t1, t2, t3; + +Bug#37899: Wrongly checked optimization prerequisite caused failed +assertion. + +CREATE TABLE t1 ( +`pk` int(11), +`varchar_nokey` varchar(5) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES +(1,'qk'),(2,'j'),(3,'aew'); +SELECT * +FROM t1 +WHERE varchar_nokey IN ( +SELECT +varchar_nokey +FROM +t1 +) XOR pk = 30; +pk varchar_nokey +1 qk +2 j +3 aew +drop table t1; +# +# BUG#41842: Semi-join materialization strategy crashes when the upper query has HAVING +# +CREATE TABLE t1 ( +pk int(11) NOT NULL AUTO_INCREMENT, +int_nokey int(11) NOT NULL, +time_key time NOT NULL, +datetime_key datetime NOT NULL, +datetime_nokey datetime NOT NULL, +varchar_key varchar(1) NOT NULL, +varchar_nokey varchar(1) NOT NULL, +PRIMARY KEY (pk), +KEY time_key (time_key), +KEY datetime_key (datetime_key), +KEY varchar_key (varchar_key) +) ENGINE=MyISaM; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES +(1,0, '00:16:10','2008-09-03 14:25:40','2008-09-03 14:25:40','h','h'), +(2,7, '00:00:00','2001-01-13 00:00:00','2001-01-13 00:00:00','',''), +(3,0, '00:00:00','0000-00-00 00:00:00','0000-00-00 00:00:00','x','x'), +(4,2, '16:29:24','2000-10-16 01:39:08','2000-10-16 01:39:08','w','w'), +(5,1, '09:23:32','0000-00-00 00:00:00','0000-00-00 00:00:00','p','p'), +(6,3, '00:00:00','2007-12-02 00:00:00','2007-12-02 00:00:00','o','o'), +(7,3, '00:00:00','2008-09-11 00:00:00','2008-09-11 00:00:00','',''), +(8,0, '13:59:04','0000-00-00 00:00:00','0000-00-00 00:00:00','s','s'), +(9,7, '09:01:06','0000-00-00 00:00:00','0000-00-00 00:00:00','d','d'), +(10,5,'00:00:00','0000-00-00 00:00:00','0000-00-00 00:00:00','n','n'), +(11,0,'21:06:46','0000-00-00 00:00:00','0000-00-00 00:00:00','o','o'), +(12,2,'00:00:00','0000-00-00 00:00:00','0000-00-00 00:00:00','',''), +(13,6,'14:45:34','2003-07-28 02:34:08','2003-07-28 02:34:08','w','w'), +(14,1,'15:04:12','0000-00-00 00:00:00','0000-00-00 00:00:00','o','o'), +(15,0,'00:00:00','0000-00-00 00:00:00','0000-00-00 00:00:00','x','x'), +(16,0,'15:55:23','2004-03-17 00:32:27','2004-03-17 00:32:27','p','p'), +(17,1,'16:30:00','2004-12-27 19:20:00','2004-12-27 19:20:00','d','d'), +(18,0,'00:00:00','0000-00-00 00:00:00','0000-00-00 00:00:00','h','h'), +(19,0,'14:13:26','2008-11-09 05:53:48','2008-11-09 05:53:48','o','o'), +(20,0,'00:00:00','2009-10-11 06:58:04','2009-10-11 06:58:04','k','k'); +Warnings: +Warning 1264 Out of range value for column 'datetime_key' at row 3 +Warning 1264 Out of range value for column 'datetime_nokey' at row 3 +Warning 1264 Out of range value for column 'datetime_key' at row 5 +Warning 1264 Out of range value for column 'datetime_nokey' at row 5 +Warning 1264 Out of range value for column 'datetime_key' at row 8 +Warning 1264 Out of range value for column 'datetime_nokey' at row 8 +Warning 1264 Out of range value for column 'datetime_key' at row 9 +Warning 1264 Out of range value for column 'datetime_nokey' at row 9 +Warning 1264 Out of range value for column 'datetime_key' at row 10 +Warning 1264 Out of range value for column 'datetime_nokey' at row 10 +Warning 1264 Out of range value for column 'datetime_key' at row 11 +Warning 1264 Out of range value for column 'datetime_nokey' at row 11 +Warning 1264 Out of range value for column 'datetime_key' at row 12 +Warning 1264 Out of range value for column 'datetime_nokey' at row 12 +Warning 1264 Out of range value for column 'datetime_key' at row 14 +Warning 1264 Out of range value for column 'datetime_nokey' at row 14 +Warning 1264 Out of range value for column 'datetime_key' at row 15 +Warning 1264 Out of range value for column 'datetime_nokey' at row 15 +Warning 1264 Out of range value for column 'datetime_key' at row 18 +Warning 1264 Out of range value for column 'datetime_nokey' at row 18 +CREATE TABLE t2 ( +pk int(11) NOT NULL AUTO_INCREMENT, +int_nokey int(11) NOT NULL, +time_key time NOT NULL, +datetime_key datetime NOT NULL, +datetime_nokey datetime NOT NULL, +varchar_key varchar(1) NOT NULL, +varchar_nokey varchar(1) NOT NULL, +PRIMARY KEY (pk), +KEY time_key (time_key), +KEY datetime_key (datetime_key), +KEY varchar_key (varchar_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT IGNORE INTO t2 VALUES +(10,0,'19:39:13','0000-00-00 00:00:00','0000-00-00 00:00:00','g','g'), +(11,8,'03:43:53','0000-00-00 00:00:00','0000-00-00 00:00:00','b','b'); +Warnings: +Warning 1264 Out of range value for column 'datetime_key' at row 1 +Warning 1264 Out of range value for column 'datetime_nokey' at row 1 +Warning 1264 Out of range value for column 'datetime_key' at row 2 +Warning 1264 Out of range value for column 'datetime_nokey' at row 2 +SELECT OUTR.datetime_nokey AS X FROM t1 AS OUTR +WHERE +OUTR.varchar_nokey IN (SELECT +INNR . varchar_nokey AS Y +FROM t2 AS INNR +WHERE +INNR . datetime_key >= INNR . time_key OR +INNR . pk = INNR . int_nokey +) +AND OUTR . varchar_nokey <= 'w' +HAVING X > '2012-12-12'; +X +drop table t1, t2; + +Bug#46797 "Crash in fix_semijoin_strategies_for_picked_join_order +with semijoin=on" + +CREATE TABLE t1 ( +varchar_key varchar(1) DEFAULT NULL, +KEY varchar_key (varchar_key) +); +CREATE TABLE t2 ( +varchar_key varchar(1) DEFAULT NULL, +KEY varchar_key (varchar_key) +); +INSERT INTO t2 VALUES +(NULL),(NULL),(NULL),(NULL),('a'),('a'),('a'),('b'),('b'),('b'),('b'),('c'), +('c'),('c'),('c'),('c'),('c'),('c'),('d'),('d'),('d'),('d'),('d'),('d'),('e'), +('e'),('e'),('e'),('e'),('e'),('f'),('f'),('f'),('g'),('g'),('h'),('h'),('h'), +('h'),('i'),('j'),('j'),('j'),('k'),('k'),('l'),('l'),('m'),('m'),('m'),('m'), +('n'),('n'),('n'),('o'),('o'),('o'),('p'),('p'),('p'),('q'),('q'),('q'),('r'), +('r'),('r'),('r'),('s'),('s'),('s'),('s'),('t'),('t'),('t'),('t'),('u'),('u'), +('u'),('u'),('v'),('v'),('v'),('v'),('w'),('w'),('w'),('w'),('w'),('w'),('x'), +('x'),('x'),('y'),('y'),('y'),('y'),('z'),('z'),('z'),('z'); +CREATE TABLE t3 ( +varchar_key varchar(1) DEFAULT NULL, +KEY varchar_key (varchar_key) +) ENGINE=MyISAM DEFAULT CHARSET=latin1; +INSERT INTO t3 VALUES +(NULL),('c'),('d'),('e'),('f'),('h'),('j'),('k'),('k'),('m'),('m'),('m'), +('n'),('o'),('r'),('t'),('t'),('u'),('w'),('y'); +SELECT varchar_key FROM t3 +WHERE (SELECT varchar_key FROM t3 +WHERE (varchar_key,varchar_key) +IN (SELECT t1.varchar_key, t2 .varchar_key +FROM t1 RIGHT JOIN t2 ON t1.varchar_key +) +); +varchar_key +DROP TABLE t1, t2, t3; +# +# Bug#46556 Returning incorrect, empty results for some IN subqueries +# w/semijoin=on +# +CREATE TABLE t0 ( +pk INTEGER, +vkey VARCHAR(1), +vnokey VARCHAR(1), +PRIMARY KEY (pk), +KEY vkey(vkey) +) charset utf8mb4; +INSERT INTO t0 +VALUES (1,'g','g'), (2,'v','v'), (3,'t','t'), (4,'u','u'), (5,'n','n'); +EXPLAIN SELECT vkey FROM t0 WHERE pk IN +(SELECT t1.pk FROM t0 t1 JOIN t0 t2 ON t2.vkey = t1.vnokey); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL ALL PRIMARY NULL NULL NULL 5 100.00 NULL +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t0.pk 1 100.00 Using where; Using join buffer (Batched Key Access) +1 SIMPLE t2 NULL ref vkey vkey 7 test.t1.vnokey 2 100.00 Using index; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`vkey` AS `vkey` from `test`.`t0` `t1` join `test`.`t0` semi join (`test`.`t0` `t2`) where ((`test`.`t2`.`vkey` = `test`.`t1`.`vnokey`) and (`test`.`t1`.`pk` = `test`.`t0`.`pk`)) +SELECT vkey FROM t0 WHERE pk IN +(SELECT t1.pk FROM t0 t1 JOIN t0 t2 ON t2.vkey = t1.vnokey); +vkey +g +n +t +u +v +DROP TABLE t0; +# End of bug#46556 + +Bug#48834: Procedure with view + subquery + semijoin=on +crashes on second call. + +CREATE TABLE t1 ( t1field integer, primary key (t1field)); +CREATE TABLE t2 ( t2field integer, primary key (t2field)); +CREATE VIEW v1 AS +SELECT t1field as v1field +FROM t1 A +WHERE A.t1field IN (SELECT t1field FROM t2 ); +CREATE VIEW v2 AS +SELECT t2field as v2field +FROM t2 A +WHERE A.t2field IN (SELECT t2field FROM t2 ); +CREATE PROCEDURE p1 () +BEGIN +SELECT v1field +FROM v1 +WHERE v1field IN ( SELECT v2field as vf_inner FROM v2 ); +END| +INSERT INTO t1 VALUES (1),(2),(3); +INSERT INTO t2 VALUES (2),(3),(4); +CALL p1; +v1field +2 +3 +CALL p1; +v1field +2 +3 +DROP TABLE t1,t2; +DROP VIEW v1,v2; +DROP PROCEDURE p1; +# End of BUG#48834 +# +# Bug#46692 "Crash occurring on queries with nested FROM subqueries +# using materialization." +# +CREATE TABLE t1 ( +pk INTEGER PRIMARY KEY, +int_key INTEGER, +KEY int_key(int_key) +); +INSERT INTO t1 VALUES (10,186),(11,NULL),(12,2),(13,3),(14,0),(15,133),(16,1); +CREATE TABLE t2 ( +pk INTEGER PRIMARY KEY, +int_key INTEGER, +KEY int_key(int_key) +); +INSERT INTO t2 VALUES (1,7),(2,2); +SELECT * FROM t1 WHERE (140, 4) IN +(SELECT t2.int_key, t2 .pk FROM t2 STRAIGHT_JOIN t1 ON t2.int_key); +pk int_key +DROP TABLE t1, t2; +# +# Bug#42353 "SELECT ... WHERE oe IN (SELECT w/ LEFT JOIN) query +# causes crash." +# +CREATE TABLE t1 ( +pk INTEGER PRIMARY KEY, +int_nokey INTEGER, +int_key INTEGER, +date_key DATE, +datetime_nokey DATETIME, +varchar_nokey VARCHAR(1) +); +CREATE TABLE t2 ( +date_nokey DATE +); +CREATE TABLE t3 ( +pk INTEGER PRIMARY KEY, +int_nokey INTEGER, +date_key date, +varchar_key VARCHAR(1), +varchar_nokey VARCHAR(1), +KEY date_key (date_key) +); +SELECT date_key FROM t1 +WHERE (int_key, int_nokey) +IN (SELECT t3.int_nokey, t3.pk +FROM t2 LEFT JOIN t3 ON (t2.date_nokey < t3.date_key) +WHERE t3.varchar_key <= t3.varchar_nokey OR t3.int_nokey <= t3.pk +) +AND (varchar_nokey <> 'f' OR NOT int_key < 7); +date_key +# +# Bug#45933 "Crash in optimize_semijoin_nests on JOIN in subquery +# + AND in outer query". +# +INSERT INTO t1 VALUES (10,7,5,'2009-06-16','2002-04-10 14:25:30','w'), +(11,7,0,'0000-00-00','0000-00-00 00:00:00','s'), +(12,4,0,'2003-07-14','2006-09-14 04:01:02','y'), +(13,0,4,'2002-07-25','0000-00-00 00:00:00','c'), +(14,1,8,'2007-07-03','0000-00-00 00:00:00','q'), +(15,6,5,'2001-11-12','0000-00-00 00:00:00',''), +(16,2,9,'0000-00-00','0000-00-00 00:00:00','j'), +(29,9,1,'0000-00-00','2003-08-11 00:00:00','m'); +Warnings: +Warning 1264 Out of range value for column 'date_key' at row 2 +Warning 1264 Out of range value for column 'datetime_nokey' at row 2 +Warning 1264 Out of range value for column 'datetime_nokey' at row 4 +Warning 1264 Out of range value for column 'datetime_nokey' at row 5 +Warning 1264 Out of range value for column 'datetime_nokey' at row 6 +Warning 1264 Out of range value for column 'date_key' at row 7 +Warning 1264 Out of range value for column 'datetime_nokey' at row 7 +Warning 1264 Out of range value for column 'date_key' at row 8 +INSERT IGNORE INTO t3 VALUES (1,9,'0000-00-00','b','b'), +(2,2,'2002-09-17','h','h'); +Warnings: +Warning 1264 Out of range value for column 'date_key' at row 1 +SELECT t1.varchar_nokey FROM t1 JOIN t3 ON t1.datetime_nokey +WHERE t1.varchar_nokey +IN (SELECT varchar_nokey FROM t1 +WHERE (pk) +IN (SELECT t3.int_nokey +FROM t3 LEFT JOIN t1 ON t1.varchar_nokey +WHERE t3.date_key BETWEEN '2008-06-07' AND '2006-06-26' + ) +); +varchar_nokey +DROP TABLE t1, t2, t3; +# +# Bug#45219 "Crash on SELECT DISTINCT query containing a +# LEFT JOIN in subquery" +# +CREATE TABLE t1 ( +pk INTEGER NOT NULL, +int_nokey INTEGER NOT NULL, +datetime_key DATETIME NOT NULL, +varchar_key VARCHAR(1) NOT NULL, +PRIMARY KEY (pk), +KEY datetime_key (datetime_key), +KEY varchar_key (varchar_key) +); +INSERT IGNORE INTO t1 VALUES +(1,9,'0000-00-00 00:00:00','p'),(2,0,'2002-02-09 07:38:13','v'), +(3,8,'2001-05-03 12:08:14','t'),(4,3,'0000-00-00 00:00:00','u'), +(5,7,'2009-07-28 03:43:30','n'),(6,0,'2009-08-04 00:00:00','l'), +(7,1,'0000-00-00 00:00:00','h'),(8,9,'0000-00-00 00:00:00','u'), +(9,0,'2005-08-02 17:16:54','n'),(10,9,'2002-12-21 00:00:00','j'), +(11,0,'2005-08-15 12:37:35','k'),(12,5,'0000-00-00 00:00:00','e'), +(13,0,'2006-03-10 00:00:00','i'),(14,8,'2005-05-16 11:02:36','u'), +(15,8,'2008-11-02 00:00:00','n'),(16,5,'2006-03-15 00:00:00','b'), +(17,1,'0000-00-00 00:00:00','x'),(18,7,'0000-00-00 00:00:00',''), +(19,0,'2008-12-17 20:15:40','q'),(20,9,'0000-00-00 00:00:00','u'); +Warnings: +Warning 1264 Out of range value for column 'datetime_key' at row 1 +Warning 1264 Out of range value for column 'datetime_key' at row 4 +Warning 1264 Out of range value for column 'datetime_key' at row 7 +Warning 1264 Out of range value for column 'datetime_key' at row 8 +Warning 1264 Out of range value for column 'datetime_key' at row 12 +Warning 1264 Out of range value for column 'datetime_key' at row 17 +Warning 1264 Out of range value for column 'datetime_key' at row 18 +Warning 1264 Out of range value for column 'datetime_key' at row 20 +CREATE TABLE t2 LIKE t1; +INSERT INTO t2 VALUES +(10,0,'2006-07-07 07:26:28','q'),(11,5,'2002-09-23 00:00:00','m'), +(12,7,'0000-00-00 00:00:00','j'),(13,1,'2006-06-07 00:00:00','z'), +(14,8,'2000-09-16 12:15:34','a'),(15,2,'2007-08-05 15:47:52',''), +(16,1,'0000-00-00 00:00:00','e'),(17,8,'2005-12-02 19:34:26','t'), +(18,5,'0000-00-00 00:00:00','q'),(19,4,'0000-00-00 00:00:00','b'), +(20,5,'2007-12-28 00:00:00','w'),(21,3,'2004-08-02 11:48:43','m'), +(22,0,'0000-00-00 00:00:00','x'),(23,8,'2004-04-19 12:18:43',''), +(24,0,'2009-04-27 00:00:00','w'),(25,4,'2006-10-20 14:52:15','x'), +(26,0,'0000-00-00 00:00:00','e'),(27,0,'2002-03-22 11:48:37','e'), +(28,2,'0000-00-00 00:00:00','p'),(29,0,'2001-01-04 03:55:07','x'); +Warnings: +Warning 1264 Out of range value for column 'datetime_key' at row 3 +Warning 1264 Out of range value for column 'datetime_key' at row 7 +Warning 1264 Out of range value for column 'datetime_key' at row 9 +Warning 1264 Out of range value for column 'datetime_key' at row 10 +Warning 1264 Out of range value for column 'datetime_key' at row 13 +Warning 1264 Out of range value for column 'datetime_key' at row 17 +Warning 1264 Out of range value for column 'datetime_key' at row 19 +CREATE TABLE t3 LIKE t1; +INSERT INTO t3 VALUES +(10,8,'2007-08-19 08:08:38','i'),(11,0,'2000-05-21 03:51:51',''); +SELECT DISTINCT datetime_key FROM t1 +WHERE (int_nokey, pk) +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#46550 Azalea returning duplicate results for some IN subqueries +# w/ semijoin=on +# +DROP TABLE IF EXISTS t0, t1, t2; +CREATE TABLE t0 ( +int_key int(11) DEFAULT NULL, +varchar_key varchar(1) DEFAULT NULL, +varchar_nokey varchar(1) DEFAULT NULL, +KEY int_key (int_key), +KEY varchar_key (varchar_key,int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t0 VALUES +(1,'m','m'), +(40,'h','h'), +(1,'r','r'), +(1,'h','h'), +(9,'x','x'), +(NULL,'q','q'), +(NULL,'k','k'), +(7,'l','l'), +(182,'k','k'), +(202,'a','a'), +(7,'x','x'), +(6,'j','j'), +(119,'z','z'), +(4,'d','d'), +(5,'h','h'), +(1,'u','u'), +(3,'q','q'), +(7,'a','a'), +(3,'e','e'), +(6,'l','l'); +CREATE TABLE t1 ( +int_key int(11) DEFAULT NULL, +varchar_key varchar(1) DEFAULT NULL, +varchar_nokey varchar(1) DEFAULT NULL, +KEY int_key (int_key), +KEY varchar_key (varchar_key,int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (7,NULL,NULL),(4,'x','x'); +CREATE TABLE t2 ( +int_key int(11) DEFAULT NULL, +varchar_key varchar(1) DEFAULT NULL, +varchar_nokey varchar(1) DEFAULT NULL, +KEY int_key (int_key), +KEY varchar_key (varchar_key,int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (123,NULL,NULL); +SELECT int_key +FROM t0 +WHERE varchar_nokey IN ( +SELECT t1 .varchar_key from t1 +); +int_key +7 +9 +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 +7 +9 +EXPLAIN +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 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1_1 NULL index varchar_key varchar_key 12 NULL 2 50.00 Using where; Using index; LooseScan +1 SIMPLE t1_2 NULL index NULL int_key 5 NULL 2 100.00 Using index; FirstMatch(t1_1) +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 20 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`int_key` AS `int_key` from `test`.`t0` semi join (`test`.`t1` `t1_1` join `test`.`t1` `t1_2`) where ((`test`.`t0`.`varchar_nokey` = `test`.`t1_1`.`varchar_key`) and (0 <> `test`.`t1_1`.`int_key`)) +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 +7 +9 +EXPLAIN +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 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t1_1 NULL index varchar_key varchar_key 12 NULL 2 50.00 Using where; Using index; LooseScan +1 SIMPLE t1_2 NULL index NULL int_key 5 NULL 2 100.00 Using index; FirstMatch(t1_1) +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 20 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`int_key` AS `int_key` from `test`.`t0` semi join (`test`.`t1` `t1_1` join `test`.`t1` `t1_2`) where ((`test`.`t0`.`varchar_nokey` = `test`.`t1_1`.`varchar_key`) and (0 <> `test`.`t1_1`.`int_key`)) +DROP TABLE t0, t1, t2; +# End of bug#46550 + +Bug #48073 Subquery on char columns from view crashes Mysql + +DROP TABLE IF EXISTS t1, t2; +DROP VIEW IF EXISTS v1; +CREATE TABLE t1 ( +city VARCHAR(50) NOT NULL, +country_id SMALLINT UNSIGNED NOT NULL +); +INSERT INTO t1 VALUES +('Batna',2), +('Bchar',2), +('Skikda',2), +('Tafuna',3), +('Algeria',2) ; +CREATE TABLE t2 ( +country_id SMALLINT UNSIGNED NOT NULL, +country VARCHAR(50) NOT NULL +); +INSERT INTO t2 VALUES +(2,'Algeria'), +(3,'American Samoa') ; +CREATE VIEW v1 AS +SELECT country_id, country +FROM t2 +WHERE LEFT(country,1) = "A" +; +SELECT city, country_id +FROM t1 +WHERE city IN ( +SELECT country +FROM t2 +WHERE LEFT(country, 1) = "A" +); +city country_id +Algeria 2 +SELECT city, country_id +FROM t1 +WHERE city IN ( +SELECT country +FROM v1 +); +city country_id +Algeria 2 +drop table t1, t2; +drop view v1; +# End of bug#48073 + +Bug#49097 subquery with view generates wrong result with +non-prepared statement + +DROP TABLE IF EXISTS t1, t2; +DROP VIEW IF EXISTS v1; +CREATE TABLE t1 ( +city VARCHAR(50) NOT NULL, +country_id SMALLINT UNSIGNED NOT NULL +); +INSERT INTO t1 VALUES +('Batna',2), +('Bchar',2), +('Skikda',2), +('Tafuna',3), +('Algeria',2) ; +CREATE TABLE t2 ( +country_id SMALLINT UNSIGNED NOT NULL, +country VARCHAR(50) NOT NULL +); +INSERT INTO t2 VALUES +(2,'Algeria'), +(3,'XAmerican Samoa') ; +CREATE VIEW v1 AS +SELECT country_id, country +FROM t2 +WHERE LEFT(country,1) = "A" +; +SELECT city, country_id +FROM t1 +WHERE country_id IN ( +SELECT country_id +FROM t2 +WHERE LEFT(country,1) = "A" +); +city country_id +Algeria 2 +Batna 2 +Bchar 2 +Skikda 2 +SELECT city, country_id +FROM t1 +WHERE country_id IN ( +SELECT country_id +FROM v1 +); +city country_id +Algeria 2 +Batna 2 +Bchar 2 +Skikda 2 +PREPARE stmt FROM +" +SELECT city, country_id +FROM t1 +WHERE country_id IN ( + SELECT country_id + FROM v1 +); +"; +execute stmt; +city country_id +Algeria 2 +Batna 2 +Bchar 2 +Skikda 2 +deallocate prepare stmt; +drop table t1, t2; +drop view v1; +# End of Bug#49097 +# +# Bug#49198 Wrong result for second call of procedure +# with view in subselect. +# +CREATE TABLE t1 (t1field integer, primary key (t1field)); +CREATE TABLE t2 (t2field integer, primary key (t2field)); +CREATE TABLE t3 (t3field integer, primary key (t3field)); +CREATE VIEW v2 AS SELECT * FROM t2; +CREATE VIEW v3 AS SELECT * FROM t3; +INSERT INTO t1 VALUES(1),(2); +INSERT INTO t2 VALUES(1),(2); +INSERT INTO t3 VALUES(1),(2); +PREPARE stmt FROM +" +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT * FROM v2); +"; +EXECUTE stmt; +t1field +1 +2 + +EXECUTE stmt; +t1field +1 +2 +PREPARE stmt FROM +" +EXPLAIN +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT * FROM v2) + AND t1field IN (SELECT * FROM v3) +"; +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index PRIMARY PRIMARY 4 NULL 2 100.00 Using index +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +1 SIMPLE t3 NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`t1field` AS `t1field` from `test`.`t2` join `test`.`t3` join `test`.`t1` where ((`test`.`t2`.`t2field` = `test`.`t1`.`t1field`) and (`test`.`t3`.`t3field` = `test`.`t1`.`t1field`)) + +This line is only in place to help --skip_if_hypergraph diffing some more. + +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index PRIMARY PRIMARY 4 NULL 2 100.00 Using index +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +1 SIMPLE t3 NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`t1field` AS `t1field` from `test`.`t2` join `test`.`t3` join `test`.`t1` where ((`test`.`t2`.`t2field` = `test`.`t1`.`t1field`) and (`test`.`t3`.`t3field` = `test`.`t1`.`t1field`)) +DROP TABLE t1, t2, t3; +DROP VIEW v2, v3; +# End of Bug#49198 +# +# Bug#48623 Multiple subqueries are optimized incorrectly +# +CREATE TABLE ot(val VARCHAR(10)) charset utf8mb4; +CREATE TABLE it1(val VARCHAR(10)) charset utf8mb4; +CREATE TABLE it2(val VARCHAR(10)) charset utf8mb4; +INSERT INTO ot VALUES('aaa'), ('bbb'), ('eee'), ('mmm'), ('ppp'); +INSERT INTO it1 VALUES('aaa'), ('aaa'), ('bbb'), ('eee'), ('mmm'), ('ppp'); +INSERT INTO it2 VALUES('aaa'), ('bbb'), ('eee'), ('mmm'), ('ppp'); +EXPLAIN +SELECT * +FROM ot +WHERE ot.val IN (SELECT it1.val FROM it1 +WHERE it1.val LIKE 'a%' OR it1.val LIKE 'e%') +AND ot.val IN (SELECT it2.val FROM it2 +WHERE it2.val LIKE 'a%' OR it2.val LIKE 'e%'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE it2 NULL ALL NULL NULL NULL NULL 5 36.00 Using where; Start temporary +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 5 20.00 Using where; End temporary +1 SIMPLE it1 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; FirstMatch(ot) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot`.`val` AS `val` from `test`.`ot` semi join (`test`.`it1`) semi join (`test`.`it2`) where ((`test`.`ot`.`val` = `test`.`it2`.`val`) and (`test`.`it1`.`val` = `test`.`it2`.`val`) and ((`test`.`it1`.`val` like 'a%') or (`test`.`it1`.`val` like 'e%')) and ((`test`.`it2`.`val` like 'a%') or (`test`.`it2`.`val` like 'e%'))) +SELECT * +FROM ot +WHERE ot.val IN (SELECT it1.val FROM it1 +WHERE it1.val LIKE 'a%' OR it1.val LIKE 'e%') +AND ot.val IN (SELECT it2.val FROM it2 +WHERE it2.val LIKE 'a%' OR it2.val LIKE 'e%'); +val +aaa +eee +DROP TABLE ot; +DROP TABLE it1; +DROP TABLE it2; +# End of Bug#48623 +# +# Bug #51487 Assertion failure when semi-join flattening occurs +# for a subquery in HAVING +# +CREATE TABLE t1 (a INT, b INT); +INSERT INTO t1 VALUES (1,10),(2,11),(1,13); +CREATE TABLE t2 AS SELECT * FROM t1; +CREATE TABLE t3 AS SELECT * FROM t1; +SELECT COUNT(*) FROM t1 +GROUP BY t1.a +HAVING t1.a IN (SELECT t3.a FROM t3 +WHERE t3.b IN (SELECT b FROM t2 WHERE t2.a=t1.a)); +COUNT(*) +2 +1 +DROP TABLE t1, t2, t3; +# End of Bug#51487 +# +# BUG#38075: Wrong result: rows matching a subquery with outer join not returned +# +DROP TABLE IF EXISTS ot1, it1, it2; +CREATE TABLE it2 ( +int_key int(11) NOT NULL, +datetime_key datetime NOT NULL, +KEY int_key (int_key), +KEY datetime_key (datetime_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO it2 VALUES +(5,'2002-04-10 14:25:30'), (0,'0000-00-00 00:00:00'), +(0,'2006-09-14 04:01:02'), (4,'0000-00-00 00:00:00'), +(8,'0000-00-00 00:00:00'), (5,'0000-00-00 00:00:00'), +(9,'0000-00-00 00:00:00'), (8,'2007-04-01 11:04:17'), +(1,'0000-00-00 00:00:00'), (7,'2009-01-12 00:00:00'), +(0,'2009-06-05 00:00:00'), (3,'2006-02-14 18:06:35'), +(5,'2006-02-21 07:08:16'), (0,'0000-00-00 00:00:00'), +(7,'0000-00-00 00:00:00'), (0,'0000-00-00 00:00:00'), +(0,'2007-02-13 00:00:00'), (1,'0000-00-00 00:00:00'), +(0,'0000-00-00 00:00:00'), (1,'2003-08-11 00:00:00'); +Warnings: +Warning 1264 Out of range value for column 'datetime_key' at row 2 +Warning 1264 Out of range value for column 'datetime_key' at row 4 +Warning 1264 Out of range value for column 'datetime_key' at row 5 +Warning 1264 Out of range value for column 'datetime_key' at row 6 +Warning 1264 Out of range value for column 'datetime_key' at row 7 +Warning 1264 Out of range value for column 'datetime_key' at row 9 +Warning 1264 Out of range value for column 'datetime_key' at row 14 +Warning 1264 Out of range value for column 'datetime_key' at row 15 +Warning 1264 Out of range value for column 'datetime_key' at row 16 +Warning 1264 Out of range value for column 'datetime_key' at row 18 +Warning 1264 Out of range value for column 'datetime_key' at row 19 +CREATE TABLE ot1 ( +int_nokey int(11) NOT NULL, +int_key int(11) NOT NULL, +KEY int_key (int_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO ot1 VALUES +(5,0), (3,0), (0,2), (3,0), (1,3), (0,0), (1,7), (7,0), (1,7), (0,7), +(0,9), (8,2), (4,4), (9,3), (0,9), (2,5), (0,5), (8,0), (5,8), (1,5); +CREATE TABLE it1 ( +int_nokey int(11) NOT NULL, +int_key int(11) NOT NULL, +KEY int_key (int_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO it1 VALUES +(9,5), (0,4); +SELECT int_key FROM ot1 +WHERE int_nokey IN (SELECT it2.int_key +FROM it1 LEFT JOIN it2 ON it2.datetime_key); +int_key +0 +0 +0 +0 +0 +0 +2 +2 +3 +5 +5 +7 +7 +7 +8 +9 +9 +EXPLAIN +SELECT int_key FROM ot1 +WHERE int_nokey IN (SELECT it2.int_key +FROM it1 LEFT JOIN it2 ON it2.datetime_key); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE it1 NULL index NULL int_key 4 NULL 2 100.00 Using index; Start temporary +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 20 100.00 NULL +1 SIMPLE it2 NULL ref int_key int_key 4 test.ot1.int_nokey 2 90.00 Using where; End temporary; Using join buffer (Batched Key Access) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`int_key` AS `int_key` from `test`.`ot1` semi join (`test`.`it1` join `test`.`it2`) where ((`test`.`it2`.`int_key` = `test`.`ot1`.`int_nokey`) and (TIMESTAMP'0000-00-00 00:00:00' <> `test`.`it2`.`datetime_key`)) +DROP TABLE ot1, it1, it2; +# End of BUG#38075 +# +# BUG#50089: Second call of procedure with view in subselect crashes server +# +CREATE TABLE t1(t1field INTEGER, PRIMARY KEY(t1field)); +CREATE VIEW v1 AS +SELECT t1field AS v1field +FROM t1 a +WHERE a.t1field IN (SELECT t1field FROM t1); +INSERT INTO t1 VALUES(1),(2); +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT v1field FROM v1); +t1field +1 +2 +EXPLAIN +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT v1field FROM v1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index PRIMARY PRIMARY 4 NULL 2 100.00 Using index +1 SIMPLE a NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `t1`.`t1field` AS `t1field` from `test`.`t1` `a` join `test`.`t1` join `test`.`t1` where ((`test`.`a`.`t1field` = `t1`.`t1field`) and (`test`.`t1`.`t1field` = `t1`.`t1field`)) +SELECT t1.t1field +FROM t1 LEFT JOIN t1 AS t2 ON t1.t1field IN (SELECT v1field FROM v1); +t1field +1 +1 +2 +2 +EXPLAIN +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT v1field FROM v1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index PRIMARY PRIMARY 4 NULL 2 100.00 Using index +1 SIMPLE a NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `t1`.`t1field` AS `t1field` from `test`.`t1` `a` join `test`.`t1` join `test`.`t1` where ((`test`.`a`.`t1field` = `t1`.`t1field`) and (`test`.`t1`.`t1field` = `t1`.`t1field`)) +CREATE PROCEDURE p1() +BEGIN +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT v1field FROM v1); +END| +CALL p1; +t1field +1 +2 +CALL p1; +t1field +1 +2 +PREPARE stmt FROM +" +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT v1field FROM v1); +"; +EXECUTE stmt; +t1field +1 +2 + +EXECUTE stmt; +t1field +1 +2 +DROP PROCEDURE p1; +DROP VIEW v1; +DROP TABLE t1; +# End of BUG#50089 +# +# Bug#45191: Incorrectly initialized semi-join led to a wrong result. +# +CREATE TABLE staff (EMPNUM CHAR(3) NOT NULL, +EMPNAME CHAR(20), GRADE DECIMAL(4), CITY CHAR(15)) charset latin1; +CREATE TABLE proj (PNUM CHAR(3) NOT NULL, +PNAME CHAR(20), PTYPE CHAR(6), +BUDGET DECIMAL(9), +CITY CHAR(15)) charset latin1; +CREATE TABLE works (EMPNUM CHAR(3) NOT NULL, +PNUM CHAR(3) NOT NULL, HOURS DECIMAL(5)) charset latin1; +INSERT INTO staff VALUES ('E1','Alice',12,'Deale'); +INSERT INTO staff VALUES ('E2','Betty',10,'Vienna'); +INSERT INTO staff VALUES ('E3','Carmen',13,'Vienna'); +INSERT INTO staff VALUES ('E4','Don',12,'Deale'); +INSERT INTO staff VALUES ('E5','Ed',13,'Akron'); +INSERT INTO proj VALUES ('P1','MXSS','Design',10000,'Deale'); +INSERT INTO proj VALUES ('P2','CALM','Code',30000,'Vienna'); +INSERT INTO proj VALUES ('P3','SDP','Test',30000,'Tampa'); +INSERT INTO proj VALUES ('P4','SDP','Design',20000,'Deale'); +INSERT INTO proj VALUES ('P5','IRM','Test',10000,'Vienna'); +INSERT INTO proj VALUES ('P6','PAYR','Design',50000,'Deale'); +INSERT INTO works VALUES ('E1','P1',40); +INSERT INTO works VALUES ('E1','P2',20); +INSERT INTO works VALUES ('E1','P3',80); +INSERT INTO works VALUES ('E1','P4',20); +INSERT INTO works VALUES ('E1','P5',12); +INSERT INTO works VALUES ('E1','P6',12); +INSERT INTO works VALUES ('E2','P1',40); +INSERT INTO works VALUES ('E2','P2',80); +INSERT INTO works VALUES ('E3','P2',20); +INSERT INTO works VALUES ('E4','P2',20); +INSERT INTO works VALUES ('E4','P4',40); +INSERT INTO works VALUES ('E4','P5',80); +explain SELECT EMPNUM, EMPNAME +FROM staff +WHERE EMPNUM IN +(SELECT EMPNUM FROM works +WHERE PNUM IN +(SELECT PNUM FROM proj)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE staff NULL ALL NULL NULL NULL NULL 5 100.00 NULL +1 SIMPLE NULL eq_ref 3 test.staff.EMPNUM 1 100.00 NULL +2 MATERIALIZED proj NULL ALL NULL NULL NULL NULL 6 100.00 NULL +2 MATERIALIZED works NULL ALL NULL NULL NULL NULL 12 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`staff`.`EMPNUM` AS `EMPNUM`,`test`.`staff`.`EMPNAME` AS `EMPNAME` from `test`.`staff` semi join (`test`.`works` join `test`.`proj`) where ((``.`EMPNUM` = `test`.`staff`.`EMPNUM`) and (`test`.`works`.`PNUM` = `test`.`proj`.`PNUM`)) +SELECT EMPNUM, EMPNAME +FROM staff +WHERE EMPNUM IN +(SELECT EMPNUM FROM works +WHERE PNUM IN +(SELECT PNUM FROM proj)); +EMPNUM EMPNAME +E1 Alice +E2 Betty +E3 Carmen +E4 Don +drop table staff,works,proj; +# End of bug#45191 +# +# BUG#36896: Server crash on SELECT FROM DUAL +# +create table t1 (a int); +select 1 as res from dual where (1) in (select * from t1); +res +drop table t1; + +BUG#40118 Crash when running Batched Key Access and requiring one match for each key + +create table t0(a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (a int, key(a)); +insert into t1 select * from t0; +alter table t1 add b int not null, add filler char(200); +insert into t1 select * from t1; +insert into t1 select * from t1; +select * from t0 where t0.a in (select t1.a from t1 where t1.b=0); +a +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +drop table t0, t1; +# +# BUG#32665 Query with dependent subquery is too slow +# +create table t1 ( +idIndividual int primary key +); +insert into t1 values (1),(2); +create table t2 ( +idContact int primary key, +contactType int, +idObj int +); +insert into t2 values (1,1,1),(2,2,2),(3,3,3); +create table t3 ( +idAddress int primary key, +idContact int, +postalStripped varchar(100) +); +insert into t3 values (1,1, 'foo'), (2,2,'bar'); +The following must be converted to a semi-join: +explain SELECT a.idIndividual FROM t1 a +WHERE a.idIndividual IN +( SELECT c.idObj FROM t3 cona +INNER JOIN t2 c ON c.idContact=cona.idContact +WHERE cona.postalStripped='T2H3B2' + ); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE a NULL index PRIMARY PRIMARY 4 NULL 2 100.00 Using index +1 SIMPLE cona NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE c NULL eq_ref PRIMARY PRIMARY 4 test.cona.idContact 1 33.33 Using where; FirstMatch(a) +Warnings: +Note 1003 /* select#1 */ select `test`.`a`.`idIndividual` AS `idIndividual` from `test`.`t1` `a` semi join (`test`.`t3` `cona` join `test`.`t2` `c`) where ((`test`.`c`.`idContact` = `test`.`cona`.`idContact`) and (`test`.`c`.`idObj` = `test`.`a`.`idIndividual`) and (`test`.`cona`.`postalStripped` = 'T2H3B2')) +drop table t1,t2,t3; +CREATE TABLE t1 (one int, two int, flag char(1)); +CREATE TABLE t2 (one int, two int, flag char(1)); +INSERT INTO t1 VALUES(1,2,'Y'),(2,3,'Y'),(3,4,'Y'),(5,6,'N'),(7,8,'N'); +INSERT INTO t2 VALUES(1,2,'Y'),(2,3,'Y'),(3,4,'Y'),(5,6,'N'),(7,8,'N'); +SELECT * FROM t1 +WHERE ROW(one,two) IN (SELECT DISTINCT one,two FROM t2 WHERE flag = 'N'); +one two flag +5 6 N +7 8 N +SELECT * FROM t1 +WHERE ROW(one,two) IN (SELECT DISTINCT one,two FROM t1 WHERE flag = 'N'); +one two flag +5 6 N +7 8 N +insert into t2 values (null,null,'N'); +insert into t2 values (null,3,'0'); +insert into t2 values (null,5,'0'); +insert into t2 values (10,null,'0'); +insert into t1 values (10,3,'0'); +insert into t1 values (10,5,'0'); +insert into t1 values (10,10,'0'); +SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = 'N') as 'test' from t1; +one two test +1 2 NULL +2 3 NULL +3 4 NULL +5 6 1 +7 8 1 +10 3 NULL +10 5 NULL +10 10 NULL +SELECT one,two from t1 where ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = 'N'); +one two +5 6 +7 8 +SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = 'N' group by one,two) as 'test' from t1; +one two test +1 2 NULL +2 3 NULL +3 4 NULL +5 6 1 +7 8 1 +10 3 NULL +10 5 NULL +10 10 NULL +SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = '0') as 'test' from t1; +one two test +1 2 0 +2 3 NULL +3 4 0 +5 6 0 +7 8 0 +10 3 NULL +10 5 NULL +10 10 NULL +SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = '0' group by one,two) as 'test' from t1; +one two test +1 2 0 +2 3 NULL +3 4 0 +5 6 0 +7 8 0 +10 3 NULL +10 5 NULL +10 10 NULL +explain SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = '0') as 'test' from t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 9 11.11 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`one` AS `one`,`test`.`t1`.`two` AS `two`,((`test`.`t1`.`one`,`test`.`t1`.`two`),(/* select#2 */ select `test`.`t2`.`one`,`test`.`t2`.`two` from `test`.`t2` where ((`test`.`t2`.`flag` = '0') and (outer_field_is_not_null, (((`test`.`t1`.`one`) = `test`.`t2`.`one`) or (`test`.`t2`.`one` is null)), true) and (outer_field_is_not_null, (((`test`.`t1`.`two`) = `test`.`t2`.`two`) or (`test`.`t2`.`two` is null)), true)) having ((outer_field_is_not_null, (`test`.`t2`.`one`), true) and (outer_field_is_not_null, (`test`.`t2`.`two`), true)))) AS `test` from `test`.`t1` +explain SELECT one,two from t1 where ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = 'N'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 9 11.11 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`one` AS `one`,`test`.`t1`.`two` AS `two` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`two` = `test`.`t2`.`two`) and (`test`.`t1`.`one` = `test`.`t2`.`one`) and (`test`.`t2`.`flag` = 'N')) +explain SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = '0' group by one,two) as 'test' from t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 9 11.11 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`one` AS `one`,`test`.`t1`.`two` AS `two`,((`test`.`t1`.`one`,`test`.`t1`.`two`),(/* select#2 */ select `test`.`t2`.`one`,`test`.`t2`.`two` from `test`.`t2` where ((`test`.`t2`.`flag` = '0') and (outer_field_is_not_null, (((`test`.`t1`.`one`) = `test`.`t2`.`one`) or (`test`.`t2`.`one` is null)), true) and (outer_field_is_not_null, (((`test`.`t1`.`two`) = `test`.`t2`.`two`) or (`test`.`t2`.`two` is null)), true)) having ((outer_field_is_not_null, (`test`.`t2`.`one`), true) and (outer_field_is_not_null, (`test`.`t2`.`two`), true)))) AS `test` from `test`.`t1` +DROP TABLE t1,t2; +CREATE TABLE t1 (a char(5), b char(5)); +INSERT INTO t1 VALUES (NULL,'aaa'), ('aaa','aaa'); +SELECT * FROM t1 WHERE (a,b) IN (('aaa','aaa'), ('aaa','bbb')); +a b +aaa aaa +DROP TABLE t1; +CREATE TABLE t1 (a CHAR(1), b VARCHAR(10)) charset utf8mb4; +INSERT INTO t1 VALUES ('a', 'aa'); +INSERT INTO t1 VALUES ('a', 'aaa'); +SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1); +a b +CREATE INDEX I1 ON t1 (a); +CREATE INDEX I2 ON t1 (b); +EXPLAIN SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL I2 NULL NULL NULL 2 100.00 Using where +1 SIMPLE t1 NULL ref I1 I1 5 test.t1.b 2 100.00 Using where; Using index; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t1`) where (`test`.`t1`.`b` = `test`.`t1`.`a`) +SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1); +a b +CREATE TABLE t2 (a VARCHAR(1), b VARCHAR(10)) charset utf8mb4; +INSERT INTO t2 SELECT * FROM t1; +CREATE INDEX I1 ON t2 (a); +CREATE INDEX I2 ON t2 (b); +EXPLAIN SELECT a,b FROM t2 WHERE b IN (SELECT a FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL I2 NULL NULL NULL 2 100.00 Using where +1 SIMPLE t2 NULL ref I1 I1 7 test.t2.b 2 100.00 Using where; Using index; FirstMatch(t2) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t2` semi join (`test`.`t2`) where (`test`.`t2`.`b` = `test`.`t2`.`a`) +SELECT a,b FROM t2 WHERE b IN (SELECT a FROM t2); +a b +EXPLAIN +SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1 WHERE LENGTH(a)<500); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL I2 NULL NULL NULL 2 100.00 Using where +1 SIMPLE t1 NULL ref I1 I1 5 test.t1.b 2 100.00 Using where; Using index; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t1`) where ((length(`test`.`t1`.`a`) < 500) and (`test`.`t1`.`b` = `test`.`t1`.`a`)) +SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1 WHERE LENGTH(a)<500); +a b +DROP TABLE t1,t2; +# +# BUG#45928 "Differing query results depending on MRR and +# engine_condition_pushdown settings" +# +CREATE TABLE `t1` ( +`pk` int(11) NOT NULL AUTO_INCREMENT, +`time_nokey` time NOT NULL, +`varchar_key` varchar(1) NOT NULL, +`varchar_nokey` varchar(1) NOT NULL, +PRIMARY KEY (`pk`), +KEY `varchar_key` (`varchar_key`) +) AUTO_INCREMENT=12 DEFAULT CHARSET=latin1; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO `t1` VALUES (10,'00:00:00','i','i'),(11,'00:00:00','',''); +SELECT `time_nokey` G1 FROM t1 WHERE ( `varchar_nokey` , `varchar_key` ) IN ( +SELECT `varchar_nokey` , `varchar_nokey` ) AND `varchar_key` >= 'c' HAVING G1 ORDER +BY `pk` ; +G1 +DROP TABLE t1; +# +# BUG#45863 "Assertion failed: (fixed == 0), function fix_fields(), +# file item.cc, line 4448" +# +DROP TABLE IF EXISTS C, BB; +CREATE TABLE C ( +varchar_nokey varchar(1) NOT NULL +); +INSERT INTO C VALUES +('k'),('a'),(''),('u'),('e'),('v'),('i'), +('t'),('u'),('f'),('u'),('m'),('j'),('f'), +('v'),('j'),('g'),('e'),('h'),('z'); +CREATE TABLE BB ( +varchar_nokey varchar(1) NOT NULL +); +INSERT INTO BB VALUES ('i'),('t'); +SELECT varchar_nokey FROM C +WHERE (varchar_nokey, OUTR) IN (SELECT varchar_nokey +FROM BB); +ERROR 42S22: Unknown column 'OUTR' in 'IN/ALL/ANY subquery' +SELECT varchar_nokey FROM C +WHERE (varchar_nokey, OUTR) IN (SELECT varchar_nokey, varchar_nokey +FROM BB); +ERROR 42S22: Unknown column 'OUTR' in 'IN/ALL/ANY subquery' +DROP TABLE C,BB; +# +# During work with BUG#45863 I had problems with a query that was +# optimized differently in regular and prepared mode. +# Because there was a bug in one of the selected strategies, I became +# aware of the problem. Adding an EXPLAIN query to catch this. +DROP TABLE IF EXISTS t1, t2, t3; +CREATE TABLE t1 +(EMPNUM CHAR(3) NOT NULL, +EMPNAME CHAR(20), +GRADE DECIMAL(4), +CITY CHAR(15)) charset latin1; +CREATE TABLE t2 +(PNUM CHAR(3) NOT NULL, +PNAME CHAR(20), +PTYPE CHAR(6), +BUDGET DECIMAL(9), +CITY CHAR(15)) charset latin1; +CREATE TABLE t3 +(EMPNUM CHAR(3) NOT NULL, +PNUM CHAR(3) NOT NULL, +HOURS DECIMAL(5)) charset latin1; +INSERT INTO t1 VALUES ('E1','Alice',12,'Deale'); +INSERT INTO t1 VALUES ('E2','Betty',10,'Vienna'); +INSERT INTO t1 VALUES ('E3','Carmen',13,'Vienna'); +INSERT INTO t1 VALUES ('E4','Don',12,'Deale'); +INSERT INTO t1 VALUES ('E5','Ed',13,'Akron'); +INSERT INTO t2 VALUES ('P1','MXSS','Design',10000,'Deale'); +INSERT INTO t2 VALUES ('P2','CALM','Code',30000,'Vienna'); +INSERT INTO t2 VALUES ('P3','SDP','Test',30000,'Tampa'); +INSERT INTO t2 VALUES ('P4','SDP','Design',20000,'Deale'); +INSERT INTO t2 VALUES ('P5','IRM','Test',10000,'Vienna'); +INSERT INTO t2 VALUES ('P6','PAYR','Design',50000,'Deale'); +INSERT INTO t3 VALUES ('E1','P1',40); +INSERT INTO t3 VALUES ('E1','P2',20); +INSERT INTO t3 VALUES ('E1','P3',80); +INSERT INTO t3 VALUES ('E1','P4',20); +INSERT INTO t3 VALUES ('E1','P5',12); +INSERT INTO t3 VALUES ('E1','P6',12); +INSERT INTO t3 VALUES ('E2','P1',40); +INSERT INTO t3 VALUES ('E2','P2',80); +INSERT INTO t3 VALUES ('E3','P2',20); +INSERT INTO t3 VALUES ('E4','P2',20); +INSERT INTO t3 VALUES ('E4','P4',40); +INSERT INTO t3 VALUES ('E4','P5',80); +CREATE UNIQUE INDEX t1_IDX ON t1(EMPNUM); +EXPLAIN SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN +(SELECT EMPNUM +FROM t3 +WHERE PNUM IN +(SELECT PNUM +FROM t2 +WHERE PTYPE = 'Design')); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where +1 SIMPLE t1 NULL eq_ref t1_IDX t1_IDX 3 test.t3.EMPNUM 1 100.00 End temporary; Using join buffer (Batched Key Access) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = `test`.`t3`.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) +PREPARE stmt FROM "EXPLAIN SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN + (SELECT EMPNUM + FROM t3 + WHERE PNUM IN + (SELECT PNUM + FROM t2 + WHERE PTYPE = 'Design'))"; +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where +1 SIMPLE t1 NULL eq_ref t1_IDX t1_IDX 3 test.t3.EMPNUM 1 100.00 End temporary; Using join buffer (Batched Key Access) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = `test`.`t3`.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) + +This line is only in place to help --skip_if_hypergraph diffing some more. + +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where +1 SIMPLE t1 NULL eq_ref t1_IDX t1_IDX 3 test.t3.EMPNUM 1 100.00 End temporary; Using join buffer (Batched Key Access) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = `test`.`t3`.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) +DEALLOCATE PREPARE stmt; +DROP INDEX t1_IDX ON t1; +CREATE INDEX t1_IDX ON t1(EMPNUM); +EXPLAIN SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN +(SELECT EMPNUM +FROM t3 +WHERE PNUM IN +(SELECT PNUM +FROM t2 +WHERE PTYPE = 'Design')); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ref t1_IDX t1_IDX 3 .EMPNUM 2 100.00 Using join buffer (Batched Key Access) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = ``.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) +PREPARE stmt FROM "EXPLAIN SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN + (SELECT EMPNUM + FROM t3 + WHERE PNUM IN + (SELECT PNUM + FROM t2 + WHERE PTYPE = 'Design'))"; +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ref t1_IDX t1_IDX 3 .EMPNUM 2 100.00 Using join buffer (Batched Key Access) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = ``.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) + +This line is only in place to help --skip_if_hypergraph diffing some more. + +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ref t1_IDX t1_IDX 3 .EMPNUM 2 100.00 Using join buffer (Batched Key Access) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = ``.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) +DEALLOCATE PREPARE stmt; +DROP INDEX t1_IDX ON t1; +EXPLAIN SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN +(SELECT EMPNUM +FROM t3 +WHERE PNUM IN +(SELECT PNUM +FROM t2 +WHERE PTYPE = 'Design')); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 20.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = `test`.`t3`.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) +PREPARE stmt FROM "EXPLAIN SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN + (SELECT EMPNUM + FROM t3 + WHERE PNUM IN + (SELECT PNUM + FROM t2 + WHERE PTYPE = 'Design'))"; +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 20.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = `test`.`t3`.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) + +This line is only in place to help --skip_if_hypergraph diffing some more. + +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 20.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = `test`.`t3`.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) +DEALLOCATE PREPARE stmt; +DROP TABLE t1, t2, t3; +# +# BUG#45221 Query SELECT pk FROM C WHERE pk IN (SELECT int_key) failing +# +CREATE TABLE t1 ( +i1_key INT, +i2 INT, +i3 INT, +KEY i1_index (i1_key) +); +INSERT INTO t1 VALUES (9,1,2), (9,2,1); +CREATE TABLE t2 ( +pk INT NOT NULL, +i1 INT, +PRIMARY KEY (pk) +); +INSERT INTO t2 VALUES (9,1); +SELECT pk +FROM t2 +WHERE +pk IN ( +SELECT i1_key +FROM t1 +WHERE t1.i2 < t1.i3 XOR t2.i1 > 1 +ORDER BY t1.i2 desc); +pk +9 +DROP TABLE t1,t2; +# BUG#50361 Doublenested noncorrelated subquery with FirstMatch and join cache wrong result +# +CREATE TABLE t1( +id INTEGER +); +INSERT INTO t1 VALUES(10),(20); +create table t2 select * from t1; +create table t3 select * from t1; +SELECT * +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t2 +WHERE 1 IN(SELECT 1 +FROM t3)); +id +10 +20 +explain SELECT * +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t2 +WHERE 1 IN(SELECT 1 +FROM t3)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE NULL const 4 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where true +delete from t2; +delete from t3; +INSERT INTO t1 VALUES(30),(40),(50),(60),(70),(80),(90); +insert into t2 select * from t1; +insert into t3 select * from t1; +create table t4 select * from t1; +SELECT * +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t2 +WHERE 1 IN(SELECT 1 +FROM t3 +WHERE 1 IN(SELECT 1 +FROM t4))); +id +10 +20 +30 +40 +50 +60 +70 +80 +90 +explain SELECT * +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t2 +WHERE 1 IN(SELECT 1 +FROM t3 +WHERE 1 IN(SELECT 1 +FROM t4))); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 9 100.00 NULL +1 SIMPLE NULL const 4 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 9 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 9 100.00 NULL +2 MATERIALIZED t4 NULL ALL NULL NULL NULL NULL 9 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3` join `test`.`t4`) where true +SELECT * +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t1))); +id +10 +20 +30 +40 +50 +60 +70 +80 +90 +drop table t1,t2,t3,t4; +# +# Bug#53236 Segfault in DTCollation::set(DTCollation&) +# +CREATE TABLE t1 ( +pk INTEGER AUTO_INCREMENT, +col_varchar VARCHAR(1), +PRIMARY KEY (pk) +) +; +INSERT INTO t1 (col_varchar) +VALUES +('w'), +('m') +; +SELECT table1.pk +FROM ( t1 AS table1 JOIN t1 AS table2 ON (table1.col_varchar = +table2.col_varchar) ) +WHERE ( 1, 2 ) IN ( SELECT SUBQUERY1_t1.pk AS SUBQUERY1_field1, +SUBQUERY1_t1.pk AS SUBQUERY1_field2 +FROM ( t1 AS SUBQUERY1_t1 JOIN t1 AS SUBQUERY1_t2 +ON (SUBQUERY1_t2.col_varchar = +SUBQUERY1_t1.col_varchar) ) ) +; +pk +drop table t1; +# +# BUG#53298 "wrong result with semijoin (no semijoin strategy chosen)" +# +create table t1 (uid int, fid int); +insert into t1 values (1,1), (3,1); +create table t2 (uid int, name varchar(128)); +insert into t2 values (1, "A"), (2, "B"); +create table t3 (uid int, fid int, index(uid)); +insert into t3 values (1,3), (1,3); +create table t4 (uid int); +insert into t4 values (3); +explain select t2.uid from t2, t1 +where t1.uid in (select t4.uid from t4, t3 where t3.uid=1 and t4.uid=t3.fid) +and t2.uid=t1.fid; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 0.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 MATERIALIZED t4 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 MATERIALIZED t3 NULL ref uid uid 5 const 1 50.00 Using where; Using join buffer (Batched Key Access) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`uid` AS `uid` from `test`.`t2` join `test`.`t1` semi join (`test`.`t4` join `test`.`t3`) where ((`test`.`t1`.`uid` = ``.`uid`) and (`test`.`t3`.`fid` = `test`.`t4`.`uid`) and (`test`.`t3`.`uid` = 1) and (`test`.`t1`.`fid` = `test`.`t2`.`uid`)) +select t2.uid from t2, t1 +where t1.uid in (select t4.uid from t4, t3 where t3.uid=1 and t4.uid=t3.fid) +and t2.uid=t1.fid; +uid +1 +drop table t1,t2,t3,t4; +CREATE TABLE t1 ( +pk int, +a varchar(1), +b varchar(4), +c varchar(4), +d varchar(4), +PRIMARY KEY (pk) +) charset utf8mb4; +INSERT INTO t1 VALUES (1,'o','ffff','ffff','ffoo'),(2,'f','ffff','ffff','ffff'); +CREATE TABLE t2 LIKE t1; +INSERT INTO t2 VALUES (1,'i','iiii','iiii','iiii'),(2,'f','ffff','ffff','ffff'); +EXPLAIN SELECT pk FROM t1 WHERE (a) IN (SELECT a FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using index condition; Using where; Using MRR; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`a` = `test`.`t1`.`a`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (a) IN (SELECT a FROM t2 WHERE pk > 0); +pk +2 +SELECT pk FROM t1 WHERE (b,c,d) IN (SELECT b,c,d FROM t2 WHERE pk > 0); +pk +2 +DROP TABLE t1, t2; +CREATE TABLE t1 (f1 INT, f2 DECIMAL(5,3)) ENGINE=MyISAM; +INSERT INTO t1 (f1, f2) VALUES (1, 1.789); +INSERT INTO t1 (f1, f2) VALUES (13, 1.454); +INSERT INTO t1 (f1, f2) VALUES (10, 1.668); +CREATE TABLE t2 LIKE t1; +INSERT INTO t2 VALUES (1, 1.789); +INSERT INTO t2 VALUES (13, 1.454); +EXPLAIN SELECT COUNT(*) FROM t1 WHERE (f1,f2) IN (SELECT f1,f2 FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`f2` = `test`.`t2`.`f2`) and (`test`.`t1`.`f1` = `test`.`t2`.`f1`)) +SELECT COUNT(*) FROM t1 WHERE (f1,f2) IN (SELECT f1,f2 FROM t2); +COUNT(*) +2 +DROP TABLE t1, t2; +CREATE TABLE t1 ( +ID int(11) NOT NULL auto_increment, +Name char(35) NOT NULL default '', +Country char(3) NOT NULL default '', +Population int(11) NOT NULL default '0', +PRIMARY KEY (ID), +INDEX (Population), +INDEX (Country) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t2 ( +Code char(3) NOT NULL default '', +Name char(52) NOT NULL default '', +SurfaceArea float(10,2) NOT NULL default '0.00', +Population int(11) NOT NULL default '0', +Capital int(11) default NULL, +PRIMARY KEY (Code), +UNIQUE INDEX (Name), +INDEX (Population) +) charset utf8mb4; +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t3 ( +Country char(3) NOT NULL default '', +Language char(30) NOT NULL default '', +Percentage float(3,1) NOT NULL default '0.0', +PRIMARY KEY (Country, Language), +INDEX (Percentage) +) charset utf8mb4; +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +EXPLAIN SELECT Name FROM t2 +WHERE t2.Code IN (SELECT Country FROM t1 WHERE Population > 5000000) +AND +t2.Code IN (SELECT Country FROM t3 +WHERE Language='English' AND Percentage > 10 AND +t2.Population > 100000); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range Population,Country Population 4 NULL 1 100.00 Using index condition; Using MRR; Start temporary +1 SIMPLE t2 NULL eq_ref PRIMARY,Population PRIMARY 12 test.t1.Country 1 75.00 Using where; Using join buffer (Batched Key Access) +1 SIMPLE t3 NULL eq_ref PRIMARY,Percentage PRIMARY 132 test.t1.Country,const 1 95.45 Using index condition; Using where; End temporary; Using join buffer (Batched Key Access) +Warnings: +Note 1276 Field or reference 'test.t2.Population' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t2`.`Name` AS `Name` from `test`.`t3` join `test`.`t2` semi join (`test`.`t1`) where ((`test`.`t2`.`Code` = `test`.`t1`.`Country`) and (`test`.`t3`.`Country` = `test`.`t1`.`Country`) and (`test`.`t3`.`Language` = 'English') and (`test`.`t3`.`Percentage` > 10) and (`test`.`t2`.`Population` > 100000) and (`test`.`t1`.`Population` > 5000000)) +EXPLAIN FORMAT=JSON SELECT Name FROM t2 +WHERE t2.Code IN (SELECT Country FROM t1 WHERE Population > 5000000) +AND +t2.Code IN (SELECT Country FROM t3 +WHERE Language='English' AND Percentage > 10 AND +t2.Population > 100000); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "2.45" + }, + "duplicates_removal": { + "using_temporary_table": true, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "range", + "possible_keys": [ + "Population", + "Country" + ], + "key": "Population", + "used_key_parts": [ + "Population" + ], + "key_length": "4", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "index_condition": "(`test`.`t1`.`Population` > 5000000)", + "using_MRR": true, + "cost_info": { + "read_cost": "0.60", + "eval_cost": "0.10", + "prefix_cost": "0.70", + "data_read_per_join": "168" + }, + "used_columns": [ + "Country", + "Population" + ] + } + }, + { + "table": { + "table_name": "t2", + "access_type": "eq_ref", + "possible_keys": [ + "PRIMARY", + "Population" + ], + "key": "PRIMARY", + "used_key_parts": [ + "Code" + ], + "key_length": "12", + "ref": [ + "test.t1.Country" + ], + "rows_examined_per_scan": 1, + "rows_produced_per_join": 0, + "filtered": "75.00", + "using_join_buffer": "Batched Key Access", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.08", + "prefix_cost": "2.20", + "data_read_per_join": "180" + }, + "used_columns": [ + "Code", + "Name", + "Population" + ], + "attached_condition": "(`test`.`t2`.`Population` > 100000)" + } + }, + { + "table": { + "table_name": "t3", + "access_type": "eq_ref", + "possible_keys": [ + "PRIMARY", + "Percentage" + ], + "key": "PRIMARY", + "used_key_parts": [ + "Country", + "Language" + ], + "key_length": "132", + "ref": [ + "test.t1.Country", + "const" + ], + "rows_examined_per_scan": 1, + "rows_produced_per_join": 0, + "filtered": "95.45", + "index_condition": "(`test`.`t3`.`Language` = 'English')", + "using_join_buffer": "Batched Key Access", + "cost_info": { + "read_cost": "0.19", + "eval_cost": "0.07", + "prefix_cost": "2.46", + "data_read_per_join": "103" + }, + "used_columns": [ + "Country", + "Language", + "Percentage" + ], + "attached_condition": "(`test`.`t3`.`Percentage` > 10)" + } + } + ] + } + } +} +Warnings: +Note 1276 Field or reference 'test.t2.Population' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t2`.`Name` AS `Name` from `test`.`t3` join `test`.`t2` semi join (`test`.`t1`) where ((`test`.`t2`.`Code` = `test`.`t1`.`Country`) and (`test`.`t3`.`Country` = `test`.`t1`.`Country`) and (`test`.`t3`.`Language` = 'English') and (`test`.`t3`.`Percentage` > 10) and (`test`.`t2`.`Population` > 100000) and (`test`.`t1`.`Population` > 5000000)) +DROP TABLE t1,t2,t3; +CREATE TABLE t1 ( +Code char(3) NOT NULL DEFAULT '', +Name char(52) NOT NULL DEFAULT '', +Continent enum('Asia','Europe','North America','Africa','Oceania','Antarctica','South America') NOT NULL DEFAULT 'Asia', +Region char(26) NOT NULL DEFAULT '', +SurfaceArea float(10,2) NOT NULL DEFAULT '0.00', +IndepYear smallint(6) DEFAULT NULL, +Population int(11) NOT NULL DEFAULT '0', +LifeExpectancy float(3,1) DEFAULT NULL, +GNP float(10,2) DEFAULT NULL, +GNPOld float(10,2) DEFAULT NULL, +LocalName char(45) NOT NULL DEFAULT '', +GovernmentForm char(45) NOT NULL DEFAULT '', +HeadOfState char(60) DEFAULT NULL, +Capital int(11) DEFAULT NULL, +Code2 char(2) NOT NULL DEFAULT '', +PRIMARY KEY (Code) +) charset utf8mb4; +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t2 ( +ID int(11) NOT NULL AUTO_INCREMENT, +Name char(35) NOT NULL DEFAULT '', +CountryCode char(3) NOT NULL DEFAULT '', +District char(20) NOT NULL DEFAULT '', +Population int(11) NOT NULL DEFAULT '0', +PRIMARY KEY (ID), +KEY CountryCode (CountryCode) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +set names latin1; +Fill the table with test data +This must not use LooseScan: +EXPLAIN SELECT Name FROM t1 +WHERE t1.Code IN ( +SELECT t2.CountryCode FROM t2 WHERE Population > 5000000); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL PRIMARY NULL NULL NULL 31 100.00 NULL +1 SIMPLE NULL eq_ref 12 test.t1.Code 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL CountryCode NULL NULL NULL 545 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`Name` AS `Name` from `test`.`t1` semi join (`test`.`t2`) where ((``.`CountryCode` = `test`.`t1`.`Code`) and (`test`.`t2`.`Population` > 5000000)) +SELECT Name FROM t1 +WHERE t1.Code IN ( +SELECT t2.CountryCode FROM t2 WHERE Population > 5000000); +Name +Austria +Canada +China +Czech Republic +drop table t1, t2; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4); +create table t1 (a int, b int, key(a)); +insert into t1 select a,a from t0; +create table t2 (a int, b int, primary key(a)); +insert into t2 select * from t1; +Table t2, unlike table t1, should be displayed as pulled out +explain select * from t0 +where t0.a in ( select t1.a from t1,t2 where t2.a=t0.a and +t1.b=t2.b); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 5 100.00 Using where; Start temporary +1 SIMPLE t1 NULL ref a a 5 test.t0.a 1 100.00 Using join buffer (Batched Key Access) +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t0.a 1 20.00 Using where; End temporary; Using join buffer (Batched Key Access) +Warnings: +Note 1276 Field or reference 'test.t0.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a` from `test`.`t2` join `test`.`t0` semi join (`test`.`t1`) where ((`test`.`t1`.`a` = `test`.`t0`.`a`) and (`test`.`t2`.`a` = `test`.`t0`.`a`) and (`test`.`t2`.`b` = `test`.`t1`.`b`)) +update t1 set a=3, b=11 where a=4; +update t2 set b=11 where a=3; +select * from t0 where t0.a in (select t1.a from t1, t2 where t2.a=t0.a and t1.b=t2.b); +a +0 +1 +2 +3 +drop table t0, t1, t2; +CREATE TABLE t1 ( +id int(11) NOT NULL, +PRIMARY KEY (id)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t2 ( +id int(11) NOT NULL, +fid int(11) NOT NULL, +PRIMARY KEY (id)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t1 values(1); +insert into t2 values(1,7503),(2,1); +explain select count(*) +from t1 +where fid IN (select fid from t2 where (id between 7502 and 8420) order by fid ); +ERROR 42S22: Unknown column 'fid' in 'IN/ALL/ANY subquery' +drop table t1, t2; +create table t1 (a int, b int, key (a), key (b)); +insert into t1 values (2,4),(2,4),(2,4); +select t1.a from t1 +where +t1.a in (select 1 from t1 where t1.a in (select 1 from t1) group by t1.a); +a +drop table t1; +create table t1(a int,b int,key(a),key(b)); +insert into t1 values (1,1),(2,2),(3,3); +select 1 from t1 +where t1.a not in (select 1 from t1 +where t1.a in (select 1 from t1) +group by t1.b); +1 +1 +1 +drop table t1; +CREATE TABLE t1 +(EMPNUM CHAR(3) NOT NULL, +EMPNAME CHAR(20), +GRADE DECIMAL(4), +CITY CHAR(15)); +CREATE TABLE t2 +(PNUM CHAR(3) NOT NULL, +PNAME CHAR(20), +PTYPE CHAR(6), +BUDGET DECIMAL(9), +CITY CHAR(15)); +CREATE TABLE t3 +(EMPNUM CHAR(3) NOT NULL, +PNUM CHAR(3) NOT NULL, +HOURS DECIMAL(5)); +INSERT INTO t1 VALUES ('E1','Alice',12,'Deale'); +INSERT INTO t1 VALUES ('E2','Betty',10,'Vienna'); +INSERT INTO t1 VALUES ('E3','Carmen',13,'Vienna'); +INSERT INTO t1 VALUES ('E4','Don',12,'Deale'); +INSERT INTO t1 VALUES ('E5','Ed',13,'Akron'); +INSERT INTO t2 VALUES ('P1','MXSS','Design',10000,'Deale'); +INSERT INTO t2 VALUES ('P2','CALM','Code',30000,'Vienna'); +INSERT INTO t2 VALUES ('P3','SDP','Test',30000,'Tampa'); +INSERT INTO t2 VALUES ('P4','SDP','Design',20000,'Deale'); +INSERT INTO t2 VALUES ('P5','IRM','Test',10000,'Vienna'); +INSERT INTO t2 VALUES ('P6','PAYR','Design',50000,'Deale'); +INSERT INTO t3 VALUES ('E1','P1',40); +INSERT INTO t3 VALUES ('E1','P2',20); +INSERT INTO t3 VALUES ('E1','P3',80); +INSERT INTO t3 VALUES ('E1','P4',20); +INSERT INTO t3 VALUES ('E1','P5',12); +INSERT INTO t3 VALUES ('E1','P6',12); +INSERT INTO t3 VALUES ('E2','P1',40); +INSERT INTO t3 VALUES ('E2','P2',80); +INSERT INTO t3 VALUES ('E3','P2',20); +INSERT INTO t3 VALUES ('E4','P2',20); +INSERT INTO t3 VALUES ('E4','P4',40); +INSERT INTO t3 VALUES ('E4','P5',80); +SELECT * FROM t1; +EMPNUM EMPNAME GRADE CITY +E1 Alice 12 Deale +E2 Betty 10 Vienna +E3 Carmen 13 Vienna +E4 Don 12 Deale +E5 Ed 13 Akron +CREATE UNIQUE INDEX t1_IDX ON t1(EMPNUM); +SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN +(SELECT EMPNUM +FROM t3 +WHERE PNUM IN +(SELECT PNUM +FROM t2 +WHERE PTYPE = 'Design')); +EMPNAME +Alice +Betty +Don +DROP INDEX t1_IDX ON t1; +CREATE INDEX t1_IDX ON t1(EMPNUM); +SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN +(SELECT EMPNUM +FROM t3 +WHERE PNUM IN +(SELECT PNUM +FROM t2 +WHERE PTYPE = 'Design')); +EMPNAME +Alice +Betty +Don +DROP INDEX t1_IDX ON t1; +SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN +(SELECT EMPNUM +FROM t3 +WHERE PNUM IN +(SELECT PNUM +FROM t2 +WHERE PTYPE = 'Design')); +EMPNAME +Alice +Betty +Don +DROP TABLE t1, t2, t3; +CREATE TABLE t1 (f1 INT NOT NULL); +CREATE VIEW v1 (a) AS SELECT f1 IN (SELECT f1 FROM t1) FROM t1; +SELECT * FROM v1; +a +drop view v1; +drop table t1; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1(a int, b int); +insert into t1 values (0,0),(1,1),(2,2); +create table t2 as select * from t1; +create table t3 (pk int, a int, primary key(pk)); +insert into t3 select a,a from t0; +explain +select * from t1 left join t2 on (t2.a= t1.a and t2.a in (select pk from t3)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE t3 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using index +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` left join (`test`.`t3` join `test`.`t2`) on(((`test`.`t3`.`pk` = `test`.`t1`.`a`) and (`test`.`t2`.`a` = `test`.`t1`.`a`))) where true +drop table t0, t1, t2, t3; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (a int) as select A.a + 10 *(B.a + 10*C.a) as a from t0 A, t0 B, t0 C; +create table t2 (id int, a int, primary key(id), key(a)) charset utf8mb4 as select a as id, a as a from t1; +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `id` int NOT NULL, + `a` int DEFAULT NULL, + PRIMARY KEY (`id`), + KEY `a` (`a`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +set @a=0; +create table t3 as select * from t2 limit 0; +insert into t3 select @a:=@a+1, t2.a from t2, t0; +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +insert into t3 select @a:=@a+1, t2.a from t2, t0; +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +insert into t3 select @a:=@a+1, t2.a from t2, t0; +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +alter table t3 add primary key(id), add 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); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index a a 5 NULL 1000 100.00 Using where; Using index +1 SIMPLE t3 NULL ref a a 5 test.t2.a 30 100.00 Using index; FirstMatch(t2) +Warnings: +Note 1003 /* select#1 */ select count(`test`.`t2`.`a`) AS `count(a)` from `test`.`t2` semi join (`test`.`t3`) where (`test`.`t3`.`a` = `test`.`t2`.`a`) +select count(a) from t2 where a in ( SELECT a FROM t3); +count(a) +1000 +drop table t0,t1,t2,t3; +# +# Bug#33062: subquery in stored routine cause crash +# +CREATE TABLE t1(a INT); +CREATE TABLE t2(c INT); +CREATE PROCEDURE p1(v1 int) +BEGIN +SELECT 1 FROM t1 WHERE a = v1 AND a IN (SELECT c FROM t2); +END +// +CREATE PROCEDURE p2(v1 int) +BEGIN +SELECT 1 FROM t1 WHERE a IN (SELECT c FROM t2); +END +// +CREATE PROCEDURE p3(v1 int) +BEGIN +SELECT 1 +FROM +t1 t01,t1 t02,t1 t03,t1 t04,t1 t05,t1 t06,t1 t07,t1 t08, +t1 t09,t1 t10,t1 t11,t1 t12,t1 t13,t1 t14,t1 t15,t1 t16, +t1 t17,t1 t18,t1 t19,t1 t20,t1 t21,t1 t22,t1 t23,t1 t24, +t1 t25,t1 t26,t1 t27,t1 t28,t1 t29,t1 t30,t1 t31,t1 t32, +t1 t33,t1 t34,t1 t35,t1 t36,t1 t37,t1 t38,t1 t39,t1 t40, +t1 t41,t1 t42,t1 t43,t1 t44,t1 t45,t1 t46,t1 t47,t1 t48, +t1 t49,t1 t50,t1 t51,t1 t52,t1 t53,t1 t54,t1 t55,t1 t56, +t1 t57,t1 t58,t1 t59,t1 t60 +WHERE t01.a IN (SELECT c FROM t2); +END +// +CREATE PROCEDURE p4(v1 int) +BEGIN +SELECT 1 +FROM +t1 t01,t1 t02,t1 t03,t1 t04,t1 t05,t1 t06,t1 t07,t1 t08, +t1 t09,t1 t10,t1 t11,t1 t12,t1 t13,t1 t14,t1 t15,t1 t16, +t1 t17,t1 t18,t1 t19,t1 t20,t1 t21,t1 t22,t1 t23,t1 t24, +t1 t25,t1 t26,t1 t27,t1 t28,t1 t29,t1 t30,t1 t31,t1 t32, +t1 t33,t1 t34,t1 t35,t1 t36,t1 t37,t1 t38,t1 t39,t1 t40, +t1 t41,t1 t42,t1 t43,t1 t44,t1 t45,t1 t46,t1 t47,t1 t48, +t1 t49,t1 t50,t1 t51,t1 t52,t1 t53,t1 t54,t1 t55,t1 t56, +t1 t57,t1 t58,t1 t59,t1 t60 +WHERE t01.a = v1 AND t01.a IN (SELECT c FROM t2); +END +// +CALL p1(1); +1 +CALL p2(1); +1 +CALL p3(1); +1 +CALL p4(1); +1 +DROP TABLE t1, t2; +DROP PROCEDURE p1; +DROP PROCEDURE p2; +DROP PROCEDURE p3; +DROP PROCEDURE p4; +# +# Bug#48213 Materialized subselect crashes if using GEOMETRY type +# +CREATE TABLE t1 ( +pk int, +a varchar(1), +b varchar(4), +c tinyblob, +d blob, +e mediumblob, +f longblob, +g tinytext, +h text, +i mediumtext, +j longtext, +k geometry, +PRIMARY KEY (pk) +) charset utf8mb4; +INSERT INTO t1 VALUES (1,'o','ffff','ffff','ffoo','ffff','ffff','ffff','ffff','ffff','ffff',ST_GeomFromText('POLYGON((0 0, 0 2, 2 2, 2 0, 0 0))')), (2,'f','ffff','ffff','ffff', 'ffff','ffff','ffff','ffff','ffff','ffff',ST_GeomFromText('POLYGON((0 0, 0 2, 2 2, 2 0, 0 0))')); +CREATE TABLE t2 LIKE t1; +INSERT INTO t2 VALUES (1,'i','iiii','iiii','iiii','iiii','ffff','ffff','ffff','ffff','ffff',ST_GeomFromText('POLYGON((0 0, 0 2, 2 2, 2 0, 0 0))')), (2,'f','ffff','ffff','ffff','ffff','ffff','ffff','ffff','ffff','ffff',ST_GeomFromText('POLYGON((0 0, 0 2, 2 2, 2 0, 0 0))')); +EXPLAIN SELECT pk FROM t1 WHERE (a, b) IN (SELECT a, b FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using index condition; Using where; Using MRR; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ 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); +pk +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, c) IN (SELECT b, c FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using index condition; Using where; Using MRR; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`c` = `test`.`t1`.`c`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, c) IN (SELECT b, c FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, d) IN (SELECT b, d FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using index condition; Using where; Using MRR; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`d` = `test`.`t1`.`d`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, d) IN (SELECT b, d FROM t2 WHERE pk > 0); +pk +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, e) IN (SELECT b, e FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using index condition; Using where; Using MRR; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`e` = `test`.`t1`.`e`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, e) IN (SELECT b, e FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, f) IN (SELECT b, f FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using index condition; Using where; Using MRR; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`f` = `test`.`t1`.`f`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, f) IN (SELECT b, f FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, g) IN (SELECT b, g FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using index condition; Using where; Using MRR; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`g` = `test`.`t1`.`g`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, g) IN (SELECT b, g FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, h) IN (SELECT b, h FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using index condition; Using where; Using MRR; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`h` = `test`.`t1`.`h`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, h) IN (SELECT b, h FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, i) IN (SELECT b, i FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using index condition; Using where; Using MRR; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`i` = `test`.`t1`.`i`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, i) IN (SELECT b, i FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, j) IN (SELECT b, j FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using index condition; Using where; Using MRR; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`j` = `test`.`t1`.`j`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, j) IN (SELECT b, j FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, k) IN (SELECT b, k FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using index condition; Using where; Using MRR; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`k` = `test`.`t1`.`k`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, k) IN (SELECT b, k FROM t2 WHERE pk > 0); +pk +1 +2 +DROP TABLE t1, t2; +# End of Bug#48213 +# +# BUG#53060: LooseScan semijoin strategy does not return all rows +# +CREATE TABLE t1 (i INTEGER); +INSERT INTO t1 VALUES (1), (2), (3), (4), (5); +CREATE TABLE t2 (i INTEGER, j INTEGER, KEY k(i, j)); +INSERT INTO t2 VALUES (1, 0), (1, 1), (2, 0), (2, 1); +EXPLAIN +SELECT * FROM t1 WHERE (i) IN (SELECT i FROM t2 where j > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index k k 10 NULL 4 33.33 Using where; Using index; LooseScan +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 20.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`i` = `test`.`t2`.`i`) and (`test`.`t2`.`j` > 0)) +SELECT * FROM t1 WHERE (i) IN (SELECT i FROM t2 where j > 0); +i +1 +2 +DROP TABLE t1, t2; +# End of BUG#53060 +# +# Bug#53305 "Duplicate weedout + join buffer (join cache --level=7,8) loses rows" +# +create table t1 (uid int, fid int, index(uid)); +insert into t1 values +(1,1), (1,2), (1,3), (1,4), +(2,5), (2,6), (2,7), (2,8), +(3,1), (3,2), (3,9); +create table t2 (uid int primary key, name varchar(128), index(name)); +insert into t2 values +(1, "A"), (2, "B"), (3, "C"), (4, "D"), (5, "E"), +(6, "F"), (7, "G"), (8, "H"), (9, "I"); +create table t3 (uid int, fid int, index(uid)); +insert into t3 values +(1,1), (1,2), (1,3),(1,4), +(2,5), (2,6), (2,7), (2,8), +(3,1), (3,2), (3,9); +create table t4 (uid int primary key, name varchar(128), index(name)); +insert into t4 values +(1, "A"), (2, "B"), (3, "C"), (4, "D"), (5, "E"), +(6, "F"), (7, "G"), (8, "H"), (9, "I"); +explain select name from t2, t1 +where t1.uid in (select t4.uid from t4, t3 where t3.uid=1 and t4.uid=t3.fid) +and t2.uid=t1.fid; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ref uid uid 5 const 4 100.00 Using where; Start temporary +1 SIMPLE t4 NULL eq_ref PRIMARY PRIMARY 4 test.t3.fid 1 100.00 Using index +1 SIMPLE t1 NULL ref uid uid 5 test.t3.fid 2 100.00 Using where; Using join buffer (Batched Key Access) +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.fid 1 100.00 End temporary; Using join buffer (Batched Key Access) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`name` AS `name` from `test`.`t4` join `test`.`t2` join `test`.`t1` semi join (`test`.`t3`) where ((`test`.`t4`.`uid` = `test`.`t3`.`fid`) and (`test`.`t1`.`uid` = `test`.`t3`.`fid`) and (`test`.`t3`.`uid` = 1) and (`test`.`t2`.`uid` = `test`.`t1`.`fid`)) +select name from t2, t1 +where t1.uid in (select t4.uid from t4, t3 where t3.uid=1 and t4.uid=t3.fid) +and t2.uid=t1.fid; +name +A +A +B +B +C +D +E +F +G +H +I +drop table t1,t2,t3,t4; +# +# Bug#43768 Prepared query with nested subqueries core dump on second execution +# +CREATE TABLE t1 ( +id INT PRIMARY KEY, +partner_id VARCHAR(35) +) charset utf8mb4; +INSERT INTO t1 VALUES +(1, 'partner1'), (2, 'partner2'), +(3, 'partner3'), (4, 'partner4'); +CREATE TABLE t2 ( +id INT NOT NULL, +t1_line_id INT, +article_id VARCHAR(20), +PRIMARY KEY(id, t1_line_id) +) charset utf8mb4; +INSERT INTO t2 VALUES +(1, 1, 'sup'), (2, 1, 'sup'), +(2, 2, 'sup'), (2, 3, 'sup'), +(2, 4, 'imp'), (3, 1, 'sup'), +(4, 1, 'sup'); +CREATE TABLE t3 ( +user_id VARCHAR(50), +article_id VARCHAR(20) NOT NULL, +PRIMARY KEY(user_id) +) charset utf8mb4; +INSERT INTO t3 VALUES('nicke', 'imp'); +EXPLAIN +SELECT t1.partner_id +FROM t1 +WHERE t1.id IN ( +SELECT t2.id +FROM t2 +WHERE article_id IN ( +SELECT article_id FROM t3 +WHERE user_id = 'nicke' + ) +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL system PRIMARY NULL NULL NULL 1 100.00 NULL +1 SIMPLE t1 NULL ALL PRIMARY NULL NULL NULL 4 100.00 NULL +1 SIMPLE t2 NULL ref PRIMARY PRIMARY 4 test.t1.id 1 14.29 Using where; FirstMatch(t1); Using join buffer (Batched Key Access) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`partner_id` AS `partner_id` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`id` = `test`.`t1`.`id`) and (`test`.`t2`.`article_id` = 'imp')) +SELECT t1.partner_id +FROM t1 +WHERE t1.id IN ( +SELECT t2.id +FROM t2 +WHERE article_id IN ( +SELECT article_id FROM t3 +WHERE user_id = 'nicke' + ) +); +partner_id +partner2 +PREPARE stmt FROM +'EXPLAIN SELECT t1.partner_id +FROM t1 +WHERE t1.id IN ( + SELECT t2.id + FROM t2 + WHERE article_id IN ( + SELECT article_id FROM t3 + WHERE user_id = \'nicke\' + ) + )'; +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL system PRIMARY NULL NULL NULL 1 100.00 NULL +1 SIMPLE t1 NULL ALL PRIMARY NULL NULL NULL 4 100.00 NULL +1 SIMPLE t2 NULL ref PRIMARY PRIMARY 4 test.t1.id 1 14.29 Using where; FirstMatch(t1); Using join buffer (Batched Key Access) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`partner_id` AS `partner_id` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`id` = `test`.`t1`.`id`) and (`test`.`t2`.`article_id` = 'imp')) + +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL system PRIMARY NULL NULL NULL 1 100.00 NULL +1 SIMPLE t1 NULL ALL PRIMARY NULL NULL NULL 4 100.00 NULL +1 SIMPLE t2 NULL ref PRIMARY PRIMARY 4 test.t1.id 1 14.29 Using where; FirstMatch(t1); Using join buffer (Batched Key Access) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`partner_id` AS `partner_id` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`id` = `test`.`t1`.`id`) and (`test`.`t2`.`article_id` = 'imp')) +PREPARE stmt FROM +'SELECT t1.partner_id +FROM t1 +WHERE t1.id IN ( + SELECT t2.id + FROM t2 + WHERE article_id IN ( + SELECT article_id FROM t3 + WHERE user_id = \'nicke\' + ) + )'; +EXECUTE stmt; +partner_id +partner2 + +EXECUTE stmt; +partner_id +partner2 +DROP TABLE t1,t2,t3; +# End of Bug#43768 +# +# Bug#53058 - semijoin execution of subquery with outerjoin yields wrong result +# +CREATE TABLE t1 (i INTEGER); +CREATE TABLE t2 (i INTEGER); +CREATE TABLE t3 (i INTEGER); +INSERT INTO t1 VALUES (1), (2); +INSERT INTO t2 VALUES (6); +INSERT INTO t3 VALUES (1), (2); +explain SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t3 LEFT JOIN t2 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t3 LEFT JOIN t2 ON t2.i=t3.i); +i +1 +2 +drop table t1,t2,t3; +# +# BUG#49453: re-execution of prepared statement with view +# and semijoin crashes +# +CREATE TABLE t1 (city VARCHAR(50), country_id INT); +CREATE TABLE t2 (country_id INT, country VARCHAR(50)); +INSERT INTO t1 VALUES +('Batna',2),('Bchar',2),('Skikda',2),('Tafuna',3),('Algeria',2) ; +INSERT INTO t2 VALUES (2,'Algeria'),(2,'AlgeriaDup'),(3,'XAmerican Samoa'); +CREATE VIEW v1 AS +SELECT country_id as vf_country_id +FROM t2 +WHERE LEFT(country,1) = "A"; +PREPARE stmt FROM " +SELECT city, country_id +FROM t1 +WHERE country_id IN (SELECT vf_country_id FROM v1); +"; + +EXECUTE stmt; +city country_id +Algeria 2 +Batna 2 +Bchar 2 +Skikda 2 + +EXECUTE stmt; +city country_id +Algeria 2 +Batna 2 +Bchar 2 +Skikda 2 +DROP TABLE t1,t2; +DROP VIEW v1; +# +# Bug#54437 Extra rows with LEFT JOIN + semijoin (firstmatch +# and duplicates weedout) +# +create table t1 (a int); +create table t2 (a int); +create table t3 (a int); +insert into t1 values(1),(1); +insert into t2 values(1),(1),(1),(1); +insert into t3 values(2),(2); +explain select * from t1 where t1.a in (select t2.a from t2 left join t3 on t2.a=t3.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t2` left join `test`.`t3` on((`test`.`t2`.`a` = `test`.`t3`.`a`))) where (`test`.`t2`.`a` = `test`.`t1`.`a`) +select * from t1 where t1.a in (select t2.a from t2 left join t3 on t2.a=t3.a); +a +1 +1 +drop table t1,t2,t3; +# +# Bug#55955: crash in MEMORY engine with IN(LEFT JOIN (JOIN)) +# +CREATE TABLE t1 (a INT); +CREATE TABLE t2 (a INT); +CREATE TABLE t3 (a INT); +INSERT INTO t1 VALUES(1),(1); +INSERT INTO t2 VALUES(1),(1); +INSERT INTO t3 VALUES(2),(2); +explain SELECT * FROM t1 +WHERE t1.a IN (SELECT t2.a +FROM t2 LEFT JOIN (t2 AS t2inner, t3) ON t2.a=t3.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2inner NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t2` left join (`test`.`t2` `t2inner` join `test`.`t3`) on((`test`.`t2`.`a` = `test`.`t3`.`a`))) where (`test`.`t2`.`a` = `test`.`t1`.`a`) +SELECT * FROM t1 +WHERE t1.a IN (SELECT t2.a +FROM t2 LEFT JOIN (t2 AS t2inner, t3) ON t2.a=t3.a); +a +1 +1 +DROP TABLE t1,t2,t3; +# +# BUG#52329 - Wrong result: subquery materialization, IN, +# non-null field followed by nullable +# +CREATE TABLE t1 (a1 CHAR(8) NOT NULL, a2 char(8) NOT NULL); +CREATE TABLE t2a (b1 char(8), b2 char(8)); +CREATE TABLE t2b (b1 CHAR(8), b2 char(8) NOT NULL); +CREATE TABLE t2c (b1 CHAR(8) NOT NULL, b2 char(8)); +INSERT INTO t1 VALUES ('1 - 12', '2 - 22'); +INSERT INTO t2a VALUES ('1 - 11', '2 - 21'), +('1 - 11', '2 - 21'), +('1 - 12', '2 - 22'), +('1 - 12', '2 - 22'), +('1 - 13', '2 - 23'); +INSERT INTO t2b SELECT * FROM t2a; +INSERT INTO t2c SELECT * FROM t2a; +SELECT * FROM t1 +WHERE (a1, a2) IN ( +SELECT b1, b2 FROM t2c WHERE b1 > '0' GROUP BY b1, b2); +a1 a2 +1 - 12 2 - 22 +SELECT * FROM t1 +WHERE (a1, a2) IN ( +SELECT b1, b2 FROM t2a WHERE b1 > '0'); +a1 a2 +1 - 12 2 - 22 +SELECT * FROM t1 +WHERE (a1, a2) IN ( +SELECT b1, b2 FROM t2b WHERE b1 > '0'); +a1 a2 +1 - 12 2 - 22 +SELECT * FROM t1 +WHERE (a1, a2) IN ( +SELECT b1, b2 FROM t2c WHERE b1 > '0'); +a1 a2 +1 - 12 2 - 22 +DROP TABLE t1,t2a,t2b,t2c; +# End BUG#52329 +# +# Bug#45174: Incorrectly applied equality propagation caused wrong +# result on a query with a materialized semi-join. +# +CREATE TABLE t1 ( +varchar_nokey varchar(1) NOT NULL +) charset utf8mb4; +INSERT INTO t1 VALUES +('v'), ('u'), ('n'), ('l'), ('h'), ('u'), ('n'), ('j'), ('k'), +('e'), ('i'), ('u'), ('n'), ('b'), ('x'), (''), ('q'), ('u'); +CREATE TABLE t2 ( +pk int NOT NULL, +varchar_key varchar(1) NOT NULL, +varchar_nokey varchar(1) NOT NULL, +PRIMARY KEY(pk), +KEY varchar_key(varchar_key) +) charset utf8mb4; +INSERT INTO t2 VALUES +(11,'m','m'), (12,'j','j'), (13,'z','z'), (14,'a','a'), (15,'',''), +(16,'e','e'), (17,'t','t'), (19,'b','b'), (20,'w','w'), (21,'m','m'), +(23,'',''), (24,'w','w'), (26,'e','e'), (27,'e','e'), (28,'p','p'); +SELECT varchar_nokey +FROM t1 +WHERE (varchar_nokey, varchar_nokey) IN (SELECT varchar_key, varchar_nokey +FROM t2 +WHERE varchar_nokey < 'n' XOR pk); +varchar_nokey +explain SELECT varchar_nokey +FROM t1 +WHERE (varchar_nokey, varchar_nokey) IN (SELECT varchar_key, varchar_nokey +FROM t2 +WHERE varchar_nokey < 'n' XOR pk); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 18 100.00 NULL +1 SIMPLE NULL eq_ref 12 test.t1.varchar_nokey,test.t1.varchar_nokey 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL varchar_key NULL NULL NULL 15 63.34 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`varchar_nokey` AS `varchar_nokey` from `test`.`t1` semi join (`test`.`t2`) where ((``.`varchar_key` = `test`.`t1`.`varchar_nokey`) and (``.`varchar_nokey` = `test`.`t1`.`varchar_nokey`) and (`test`.`t2`.`varchar_nokey` = `test`.`t2`.`varchar_key`) and ((`test`.`t2`.`varchar_nokey` < 'n') xor (0 <> `test`.`t2`.`pk`))) +DROP TABLE t1, t2; +# End of the test for bug#45174. +# +# Bug#50019: Wrong result for IN-query with materialization +# +CREATE TABLE t1(i INT); +INSERT INTO t1 VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10); +CREATE TABLE t2(i INT); +INSERT INTO t2 VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10); +CREATE TABLE t3(i INT); +INSERT INTO t3 VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10); +SELECT * FROM t1 WHERE t1.i IN (SELECT t2.i +FROM t2 JOIN t3 +WHERE t2.i + t3.i = 5); +i +1 +2 +3 +4 +explain SELECT * FROM t1 WHERE t1.i IN (SELECT t2.i +FROM t2 JOIN t3 +WHERE t2.i + t3.i = 5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 100.00 Using where +1 SIMPLE NULL eq_ref 5 test.t1.i 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 10 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 10 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = `test`.`t1`.`i`) and ((`test`.`t2`.`i` + `test`.`t3`.`i`) = 5)) +DROP TABLE t1,t2,t3; +# End of the test for bug#50019. +# +# Bug#52068: Optimizer generates invalid semijoin materialization plan +# +CREATE TABLE ot1(a INTEGER); +INSERT INTO ot1 VALUES(5), (8); +CREATE TABLE it2(a INTEGER); +INSERT INTO it2 VALUES(9), (5), (1), (8); +CREATE TABLE it3(a INTEGER); +INSERT INTO it3 VALUES(7), (1), (0), (5), (1), (4); +CREATE TABLE ot4(a INTEGER); +INSERT INTO ot4 VALUES(1), (3), (5), (7), (9), (7), (3), (1); +SELECT * FROM ot1,ot4 +WHERE (ot1.a,ot4.a) IN (SELECT it2.a,it3.a +FROM it2,it3); +a a +5 1 +5 1 +5 5 +5 7 +5 7 +8 1 +8 1 +8 5 +8 7 +8 7 +explain SELECT * FROM ot1,ot4 +WHERE (ot1.a,ot4.a) IN (SELECT it2.a,it3.a +FROM it2,it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE it2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; Start temporary +1 SIMPLE it3 NULL ALL NULL NULL NULL NULL 6 100.00 NULL +1 SIMPLE ot4 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot4`.`a` AS `a` from `test`.`ot1` join `test`.`ot4` semi join (`test`.`it2` join `test`.`it3`) where ((`test`.`ot4`.`a` = `test`.`it3`.`a`) and (`test`.`it2`.`a` = `test`.`ot1`.`a`)) +DROP TABLE IF EXISTS ot1, ot4, it2, it3; +# End of the test for bug#52068. +# +# Bug#57623: subquery within before insert trigger causes crash (sj=on) +# +CREATE TABLE ot1(a INT); +CREATE TABLE ot2(a INT); +CREATE TABLE ot3(a INT); +CREATE TABLE it1(a INT); +INSERT INTO ot1 VALUES(0),(1),(2),(3),(4),(5),(6),(7); +INSERT INTO ot2 VALUES(0),(2),(4),(6); +INSERT INTO ot3 VALUES(0),(3),(6); +INSERT INTO it1 VALUES(0),(1),(2),(3),(4),(5),(6),(7); +explain SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 on ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a from it1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +1 SIMPLE NULL eq_ref 5 test.ot1.a 1 100.00 NULL +1 SIMPLE ot3 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +2 MATERIALIZED it1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a`,`test`.`ot3`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` join `test`.`ot3` semi join (`test`.`it1`)) on(((``.`a` = `test`.`ot1`.`a`) and (`test`.`ot3`.`a` = `test`.`ot1`.`a`) and (`test`.`ot2`.`a` = `test`.`ot1`.`a`))) where true +SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 on ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a from it1); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +prepare s from 'SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 on ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a from it1)'; +execute s; +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +execute s; +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +deallocate prepare s; +DROP TABLE ot1, ot2, ot3, it1; +# End of the test for bug#57623. +# +# Bug#11766739: Crash in tmp_table_param::init() with semijoin=on +# +CREATE TABLE t1 (f1 INTEGER) ENGINE=MyISAM; +CREATE TABLE t2 (f1 INTEGER, f2 INTEGER) ENGINE=MyISAM; +INSERT INTO t1 VALUES (1); +INSERT INTO t2 VALUES (1,1), (2,1); +EXPLAIN SELECT * FROM t2 +WHERE f2 IN (SELECT t1.f1 +FROM t1 LEFT OUTER JOIN (t2 AS b1 JOIN t2 AS b2 ON TRUE) ON TRUE); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE b1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE b2 NULL ALL NULL NULL NULL NULL 2 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`f1` AS `f1`,`test`.`t2`.`f2` AS `f2` from `test`.`t2` semi join (`test`.`t1` left join (`test`.`t2` `b1` join `test`.`t2` `b2`) on((true))) where (`test`.`t2`.`f2` = `test`.`t1`.`f1`) +SELECT * FROM t2 +WHERE f2 IN (SELECT t1.f1 +FROM t1 LEFT OUTER JOIN (t2 AS b1 JOIN t2 AS b2 ON TRUE) ON TRUE); +f1 f2 +1 1 +2 1 +DROP TABLE t1, t2; +# End of the test for bug#11766739. +# +# Bug#11766642: crash in Item_field::register_field_in_read_map with view +# +CREATE TABLE t1(a INT); +CREATE VIEW v1 AS SELECT a FROM t1; +INSERT INTO t1 VALUES (0),(1),(2); +SELECT a FROM t1 WHERE a IN +(SELECT a XOR a FROM v1) +ORDER BY a; +a +0 +DROP TABLE t1; +DROP VIEW v1; +# +# Bug#12546542 MISSING ROW WHEN USING OPTIMIZER_JOIN_CACHE_LEVEL>=3 +# +CREATE TABLE t1 ( +f2 varchar(1024) +); +INSERT INTO t1 VALUES ('v'),('we'); +CREATE TABLE t2 ( +col_varchar_1024_utf8 varchar(1024) CHARACTER SET utf8 DEFAULT NULL, +col_int_key int, +col_int int +); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t2 VALUES ('we',4,NULL),('v',1305673728,6); +CREATE TABLE t3 ( +col_int_key int, +col_int int +); +INSERT INTO t3 VALUES (4,4); +SELECT * +FROM t1 +WHERE f2 IN (SELECT a1.col_varchar_1024_utf8 AS f2 +FROM t2 AS a1 LEFT JOIN t3 AS a2 +ON a1.col_int_key = a2.col_int_key +WHERE a1.col_int BETWEEN 1 AND 10 OR a2.col_int IS NOT NULL); +f2 +v +we +DROP TABLE t1,t2,t3; +# +# BUG#12616344 - JCL: DIFFERENT RESULT SET AND DIFFERENT AMOUNT +# OF ROWS WHEN JCL>=3 +# +CREATE TABLE t1 (col_int_nokey int, col_int_key int, col_varchar_key varchar(1)); +INSERT INTO t1 VALUES (0,4,'c'),(1,6,'u'); +CREATE TABLE t2 (pk int, col_int_nokey int, col_varchar_nokey varchar(1)); +INSERT INTO t2 VALUES (1,4,'b'),(94,6,'u'); +CREATE TABLE t3 (pk int, col_int_nokey int, col_varchar_key varchar(1)); +INSERT INTO t3 VALUES (1,4,'j'),(2,6,'v'); +SELECT table2.col_int_key +from t3 as table1 join t1 as table2 on table2.col_int_nokey +where table1.col_int_nokey in +( +select subquery2_t2.col_int_nokey +from t3 as subquery2_t1 +right join +t2 as subquery2_t2 +join t1 as subquery2_t3 +on subquery2_t3.col_int_key = subquery2_t2.col_int_nokey +on subquery2_t3.col_varchar_key = subquery2_t2.col_varchar_nokey +where subquery2_t1.col_varchar_key != table1.col_varchar_key +or subquery2_t2.pk <= table1.pk +); +col_int_key +6 +6 +DROP TABLE t1,t2,t3; +# +# Bug#12608157: ASSERT IN FIELD_LONG::VAL_INT WHEN USING MEMORY ENGINE +# +CREATE TABLE t1 (i1 int); +INSERT INTO t1 VALUES (1); +CREATE TABLE t2 (i1 int, i2 int) ENGINE=memory; +INSERT INTO t2 VALUES (1, 2),(7, 3); +SELECT GRANDPARENT1.i1 +FROM t2 AS GRANDPARENT1 +WHERE GRANDPARENT1.i2 +IN ( SELECT PARENT1.i2 +FROM t2 AS PARENT1 JOIN t1 AS PARENT2 ON (PARENT1.i1 = PARENT2.i1) +WHERE +GRANDPARENT1.i1 IN ( SELECT CHILD1.i1 FROM t2 AS CHILD1 ) +ORDER BY PARENT1.i1) +ORDER BY GRANDPARENT1.i2 ; +i1 +1 +DROP TABLE t1,t2; +# +# Bug#12640083: Same query executed as WHERE subquery gives different +# results on IN() compare +# +CREATE TABLE t1 ( +pk int NOT NULL, +col_varchar_1024_utf8_key varchar(1024) CHARACTER SET utf8 DEFAULT NULL, +col_varchar_10_latin1_key varchar(10) DEFAULT NULL, +PRIMARY KEY (pk), +KEY col_varchar_1024_utf8_key(col_varchar_1024_utf8_key(333)), +KEY col_varchar_10_latin1_key(col_varchar_10_latin1_key) +) charset utf8mb4; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES +(1, 'a', 'a'), +(2, 'ab', 'ab'), +(3, 'abc', 'abc'), +(4, 'abcd', 'abcd'); +CREATE TABLE t2 ( +pk int NOT NULL AUTO_INCREMENT, +PRIMARY KEY (pk) +) charset utf8mb4 ENGINE=Innodb; +CREATE TABLE t3 charset utf8mb4 +SELECT alias1.col_varchar_10_latin1_key +FROM t1 AS alias1 +LEFT JOIN t1 AS alias2 +JOIN t2 AS alias3 +ON alias2.col_varchar_10_latin1_key +ON alias1.col_varchar_1024_utf8_key +WHERE alias1.pk AND alias1.pk < 3 OR alias1.pk AND alias3.pk; +EXPLAIN SELECT * +FROM t3 +WHERE col_varchar_10_latin1_key IN ( +SELECT alias1.col_varchar_10_latin1_key +FROM t1 AS alias1 +LEFT JOIN t1 AS alias2 +JOIN t2 AS alias3 +ON alias2.col_varchar_10_latin1_key +ON alias1.col_varchar_1024_utf8_key +WHERE alias1.pk AND alias1.pk < 3 OR alias1.pk AND alias3.pk); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE alias1 NULL ref PRIMARY,col_varchar_10_latin1_key col_varchar_10_latin1_key 43 test.t3.col_varchar_10_latin1_key 2 100.00 Using where +1 SIMPLE alias3 NULL index NULL PRIMARY 4 NULL 1 100.00 Using where; Using index +1 SIMPLE alias2 NULL index NULL col_varchar_10_latin1_key 43 NULL 4 100.00 Using where; Using index; FirstMatch(t3) +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`col_varchar_10_latin1_key` AS `col_varchar_10_latin1_key` from `test`.`t3` semi join (`test`.`t1` `alias1` left join (`test`.`t1` `alias2` join `test`.`t2` `alias3`) on(((0 <> `test`.`alias1`.`col_varchar_1024_utf8_key`) and (0 <> `test`.`alias2`.`col_varchar_10_latin1_key`)))) where ((`test`.`alias1`.`col_varchar_10_latin1_key` = `test`.`t3`.`col_varchar_10_latin1_key`) and (((0 <> `test`.`alias1`.`pk`) and (`test`.`alias1`.`pk` < 3)) or ((0 <> `test`.`alias1`.`pk`) and (0 <> `test`.`alias3`.`pk`)))) +SELECT * +FROM t3 +WHERE col_varchar_10_latin1_key IN ( +SELECT alias1.col_varchar_10_latin1_key +FROM t1 AS alias1 +LEFT JOIN t1 AS alias2 +JOIN t2 AS alias3 +ON alias2.col_varchar_10_latin1_key +ON alias1.col_varchar_1024_utf8_key +WHERE alias1.pk AND alias1.pk < 3 OR alias1.pk AND alias3.pk); +col_varchar_10_latin1_key +a +ab +DROP TABLE t1, t2, t3; +# End of the test for bug#12640083. +# +# Bug#12603200 - Assert in QUICK_INDEX_MERGE_SELECT::need_sorted_output +# +CREATE TABLE t1 ( +pk int NOT NULL, +col_int_key int NOT NULL, +col_varchar_nokey varchar(1) NOT NULL, +col_varchar_key varchar(1) NOT NULL, +PRIMARY KEY(pk), +KEY col_int_key(col_int_key), +KEY col_varchar_key(col_varchar_key, col_int_key) +) charset utf8mb4 engine=innodb; +INSERT INTO t1 VALUES +(1,7,'a','a'), +(2,0,'v','v'), +(3,9,'c','c'), +(4,3,'m','m'), +(5,2,'a','a'), +(6,1,'d','d'), +(7,8,'y','y'), +(8,6,'t','t'), +(11,7,'a','x'), +(12,0,'v','v'), +(13,9,'c','c'), +(14,3,'m','m'), +(15,2,'a','x'), +(16,1,'d','d'), +(17,8,'y','y'), +(18,6,'t','u'), +(19,6,'t','u'); +CREATE TABLE t2 ( +pk int NOT NULL, +col_int_key int NOT NULL, +col_varchar_key varchar(1) NOT NULL, +PRIMARY KEY(pk), +KEY col_varchar_key(col_varchar_key, col_int_key) +) charset utf8mb4 engine=innodb; +INSERT INTO t2(pk,col_int_key,col_varchar_key) VALUES +(8,7,'c'), +(11,4,'l'), +(12,7,'b'), +(13,0,'c'), +(14,2,'i'), +(15,9,'h'), +(16,4,'q'), +(17,1,'m'), +(18,9,'b'), +(19,2,'e'), +(20,1,'c'), +(21,7,'z'), +(22,4,'l'), +(23,7,'z'), +(24,0,'c'), +(25,2,'i'), +(26,9,'h'), +(27,4,'q'), +(28,0,'a'), +(29,1,'d'); +EXPLAIN SELECT outr.col_varchar_key AS x, outr.pk AS y +FROM t1 AS outr +WHERE outr.col_varchar_key IN (SELECT innr.col_varchar_key +FROM t2 AS innr +WHERE innr.col_varchar_key = 'a' OR innr.pk = 8) +AND outr.col_varchar_nokey < 't' +ORDER BY outr.col_varchar_key, outr.pk; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE innr NULL index_merge PRIMARY,col_varchar_key col_varchar_key,PRIMARY 6,4 NULL 2 100.00 Using sort_union(col_varchar_key,PRIMARY); Using where; Using temporary; Using filesort; Start temporary +1 SIMPLE outr NULL ref col_varchar_key col_varchar_key 6 test.innr.col_varchar_key 1 33.33 Using where; End temporary; Using join buffer (Batched Key Access) +Warnings: +Note 1003 /* select#1 */ select `test`.`outr`.`col_varchar_key` AS `x`,`test`.`outr`.`pk` AS `y` from `test`.`t1` `outr` semi join (`test`.`t2` `innr`) where ((`test`.`outr`.`col_varchar_key` = `test`.`innr`.`col_varchar_key`) and (`test`.`outr`.`col_varchar_nokey` < 't') and ((`test`.`innr`.`col_varchar_key` = 'a') or (`test`.`innr`.`pk` = 8))) order by `test`.`outr`.`col_varchar_key`,`test`.`outr`.`pk` +SELECT outr.col_varchar_key AS x, outr.pk AS y +FROM t1 AS outr +WHERE outr.col_varchar_key IN (SELECT innr.col_varchar_key +FROM t2 AS innr +WHERE innr.col_varchar_key = 'a' OR innr.pk = 8) +AND outr.col_varchar_nokey < 't' +ORDER BY outr.col_varchar_key, outr.pk; +x y +a 1 +a 5 +c 3 +c 13 +DROP TABLE t1, t2; +# End of bug#12603200 +# +# Bug#12603183: Segfault in hp_movelink +# +CREATE TABLE t1 ( +col_varchar_key varchar(1) , +col_varchar_nokey varchar(1) , +KEY col_varchar_key(col_varchar_key) +) charset latin1; +INSERT INTO t1 VALUES +('i','i'), +('h','h'), +('q','q'), +('a','a'), +('v','v'), +('u','u'), +('s','s'), +('y','y'), +('z','z'), +('h','h'), +('p','p'), +('e','e'), +('i','i'), +('y','y'), +('w','w'); +CREATE TABLE t2 ( +col_varchar_nokey varchar(1) +) charset latin1; +INSERT INTO t2 VALUES +('b'); +EXPLAIN SELECT grandparent1.col_varchar_nokey +FROM t1 AS grandparent1 LEFT JOIN t2 AS grandparent2 USING (col_varchar_nokey) +WHERE (grandparent1.col_varchar_key) IN +(SELECT parent1.col_varchar_nokey +FROM t1 AS parent1 +WHERE parent1.col_varchar_key IN +(SELECT child1.col_varchar_nokey AS c1 +FROM t1 AS child1 LEFT JOIN t2 AS child2 +ON (child1.col_varchar_key > child2.col_varchar_nokey))); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using where +1 SIMPLE grandparent1 NULL ref col_varchar_key col_varchar_key 4 .col_varchar_nokey 2 100.00 Using join buffer (Batched Key Access) +1 SIMPLE grandparent2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 MATERIALIZED child1 NULL ALL NULL NULL NULL NULL 15 100.00 Using where +2 MATERIALIZED child2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 MATERIALIZED parent1 NULL ref col_varchar_key col_varchar_key 4 test.child1.col_varchar_nokey 2 100.00 Using join buffer (Batched Key Access) +Warnings: +Note 1003 /* select#1 */ select `test`.`grandparent1`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t1` `grandparent1` left join `test`.`t2` `grandparent2` on((`test`.`grandparent2`.`col_varchar_nokey` = `test`.`grandparent1`.`col_varchar_nokey`)) semi join (`test`.`t1` `parent1` join `test`.`t1` `child1` left join `test`.`t2` `child2` on((`test`.`child1`.`col_varchar_key` > `test`.`child2`.`col_varchar_nokey`))) where ((`test`.`grandparent1`.`col_varchar_key` = ``.`col_varchar_nokey`) and (`test`.`parent1`.`col_varchar_key` = `test`.`child1`.`col_varchar_nokey`)) +SELECT grandparent1.col_varchar_nokey +FROM t1 AS grandparent1 LEFT JOIN t2 AS grandparent2 USING (col_varchar_nokey) +WHERE (grandparent1.col_varchar_key) IN +(SELECT parent1.col_varchar_nokey +FROM t1 AS parent1 +WHERE parent1.col_varchar_key IN +(SELECT child1.col_varchar_nokey AS c1 +FROM t1 AS child1 LEFT JOIN t2 AS child2 +ON (child1.col_varchar_key > child2.col_varchar_nokey))); +col_varchar_nokey +a +e +h +h +i +i +p +q +s +u +v +w +y +y +z +DROP TABLE t1, t2; +# End of test for bug#12603183. +# +# Bug#12818569: Diff nr of rows returned when using IN/ALL+subquery +# +CREATE TABLE t1 ( +col_int_key INT NOT NULL, +col_datetime_key DATETIME NOT NULL, +col_varchar_key VARCHAR(1) NOT NULL, +KEY col_int_key (col_int_key), +KEY col_datetime_key(col_datetime_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t1 VALUES +(7,'2004-06-06 04:22:12','v'), (0,'2005-11-13 01:12:31','s'), +(9,'2002-05-04 01:50:00','l'), (3,'2004-10-27 10:28:45','y'), +(4,'2006-07-22 05:24:23','c'), (2,'2002-05-16 21:34:03','i'), +(5,'2008-04-17 10:45:30','h'), (3,'2009-04-21 02:58:02','q'), +(1,'2008-01-11 11:01:51','a'), (3,'1900-01-01 00:00:00','v'), +(6,'2007-05-17 18:24:57','u'), (7,'2007-08-07 00:00:00','s'), +(5,'2001-08-28 00:00:00','y'), (1,'2004-04-16 00:27:28','z'), +(204,'2005-05-03 07:06:22','h'), (224,'2009-03-11 17:09:50','p'), +(9,'2007-12-08 01:54:28','e'), (5,'2009-07-28 18:19:54','i'), +(0,'2008-06-08 00:00:00','y'), (3,'2005-02-09 09:20:26','w'); +CREATE TABLE t2 ( +col_varchar_nokey VARCHAR(1) NOT NULL +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t2 VALUES ('v'), ('y'), ('j'), ('c'), ('d'), ('r'); +explain SELECT col_varchar_key +FROM t1 +WHERE col_varchar_key IN (SELECT col_varchar_nokey +FROM t2) +ORDER BY col_datetime_key LIMIT 4; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL col_varchar_key NULL NULL NULL 20 100.00 Using filesort +1 SIMPLE NULL eq_ref 6 test.t1.col_varchar_key 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 6 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col_varchar_key` AS `col_varchar_key` from `test`.`t1` semi join (`test`.`t2`) where (``.`col_varchar_nokey` = `test`.`t1`.`col_varchar_key`) order by `test`.`t1`.`col_datetime_key` limit 4 +SELECT col_varchar_key +FROM t1 +WHERE col_varchar_key IN (SELECT col_varchar_nokey +FROM t2) +ORDER BY col_datetime_key LIMIT 4; +col_varchar_key +v +y +v +y +DROP TABLE t1, t2; +# End of test for bug#12818569. +# +# Bug#12803439: Assert in replace_subcondition() on update query +# +CREATE TABLE t1(a INTEGER); +INSERT INTO t1 values(1), (2); +CREATE TABLE t2(a INTEGER); +INSERT INTO t2 VALUES(1), (3); +SELECT * +FROM t1 +WHERE a IN (SELECT a +FROM t2 +HAVING a IN (SELECT a +FROM t2) +) +HAVING a IN (SELECT a +FROM t2); +a +1 +DROP TABLE t1, t2; +# End of test for bug#12803439. +# +# Bug#12797534: Segfault in hp_movelink still exists +# +CREATE TABLE t1 ( +g1 VARCHAR(1) NOT NULL +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t1 VALUES ('d'), ('s'); +CREATE TABLE t2 ( +pk INT NOT NULL, +col_int_key INT NOT NULL, +col_varchar_key VARCHAR(1) NOT NULL, +col_varchar_nokey VARCHAR(1) NOT NULL, +PRIMARY KEY (pk), +KEY col_varchar_key(col_varchar_key, col_int_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t2 VALUES +(1,4,'j','j'), (2,6,'v','v'), (3,3,'c','c'), (4,5,'m','m'), +(5,3,'d','d'), (6,246,'d','d'), (7,2,'y','y'), (8,9,'t','t'), +(9,3,'d','d'), (10,8,'s','s'), (11,1,'r','r'), (12,8,'m','m'), +(13,8,'b','b'), (14,5,'x','x'), (15,7,'g','g'), (16,5,'p','p'), +(17,1,'q','q'), (18,6,'w','w'), (19,2,'d','d'), (20,9,'e','e'); +CREATE TABLE t3 ( +pk INTEGER NOT NULL, +PRIMARY KEY (pk) +) ENGINE=InnoDB; +INSERT INTO t3 VALUES (10); +EXPLAIN SELECT * +FROM t1 +WHERE g1 NOT IN +(SELECT grandparent1.col_varchar_nokey AS g1 +FROM t2 AS grandparent1 +WHERE grandparent1.col_varchar_key IN +(SELECT parent1.col_varchar_nokey AS p1 +FROM t2 AS parent1 LEFT JOIN t3 AS parent2 USING (pk) +) +AND grandparent1.col_varchar_key IS NOT NULL +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE NULL eq_ref 7 test.t1.g1 1 100.00 Using where; Not exists +2 MATERIALIZED parent1 NULL ALL NULL NULL NULL NULL 20 100.00 NULL +2 MATERIALIZED parent2 NULL eq_ref PRIMARY PRIMARY 4 test.parent1.pk 1 100.00 Using index +2 MATERIALIZED grandparent1 NULL ref col_varchar_key col_varchar_key 6 test.parent1.col_varchar_nokey 1 100.00 Using index condition; Using join buffer (Batched Key Access) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`g1` AS `g1` from `test`.`t1` anti join (`test`.`t2` `grandparent1` join `test`.`t2` `parent1` left join `test`.`t3` `parent2` on((`test`.`parent2`.`pk` = `test`.`parent1`.`pk`))) on(((``.`g1` = `test`.`t1`.`g1`) and (`test`.`grandparent1`.`col_varchar_key` = `test`.`parent1`.`col_varchar_nokey`) and (`test`.`grandparent1`.`col_varchar_key` is not null))) where true +SELECT * +FROM t1 +WHERE g1 NOT IN +(SELECT grandparent1.col_varchar_nokey AS g1 +FROM t2 AS grandparent1 +WHERE grandparent1.col_varchar_key IN +(SELECT parent1.col_varchar_nokey AS p1 +FROM t2 AS parent1 LEFT JOIN t3 AS parent2 USING (pk) +) +AND grandparent1.col_varchar_key IS NOT NULL +); +g1 +DROP TABLE t1, t2, t3; +CREATE TABLE t1 ( +pk INTEGER AUTO_INCREMENT, +col_int_key INTEGER , +col_varchar_key VARCHAR(1) , +col_varchar_nokey VARCHAR(1) , +PRIMARY KEY (pk), +KEY (col_varchar_key,col_int_key) +) ENGINE=INNODB; +INSERT INTO t1 (col_int_key,col_varchar_key,col_varchar_nokey) VALUES +(0,'x','x'), (1,'j','j'), (1,'r','r'), (9,'v','v'), (5,'r','r'); +CREATE TABLE t2 ( +pk INTEGER AUTO_INCREMENT, +col_int_key INTEGER , +col_varchar_key VARCHAR(1) , +col_varchar_nokey VARCHAR(1) , +PRIMARY KEY (pk), +KEY (col_int_key), +KEY (col_varchar_key,col_int_key) +) AUTO_INCREMENT=10 ENGINE=INNODB; +INSERT INTO t2 (col_int_key, col_varchar_key, col_varchar_nokey) VALUES +(NULL,'x','x'), (NULL,'j','j'), (8,'c','c'); +CREATE TABLE t3 +SELECT outr.col_varchar_nokey AS x +FROM t1 AS outr +WHERE outr.col_varchar_nokey IN +(SELECT innr.col_varchar_nokey AS y +FROM t2 AS innr +WHERE innr.col_int_key IS NULL) +AND outr.col_varchar_nokey IS NOT NULL +AND NOT col_varchar_key IS NULL; +SELECT * +FROM t3 +WHERE x NOT IN +(SELECT outr.col_varchar_nokey AS x +FROM t1 AS outr +WHERE outr.col_varchar_nokey IN +(SELECT innr.col_varchar_nokey AS y +FROM t2 AS innr +WHERE innr.col_int_key IS NULL) +AND outr.col_varchar_nokey IS NOT NULL +AND NOT col_varchar_key IS NULL); +x +DROP TABLE t1, t2, t3; +# End of test for bug#12797534. +# +# Bug#12714094: Assert in optimize_semijoin_nests() +# +CREATE TABLE it ( +pk int NOT NULL, +col_varchar VARCHAR(10) DEFAULT NULL, +PRIMARY KEY (pk) +) ENGINE=MyISAM; +INSERT INTO it VALUES (1, 'g'); +CREATE TABLE ot +SELECT alias1.pk AS field1 +FROM it AS alias1 +LEFT JOIN it AS alias2 +ON alias1.col_varchar = alias2.col_varchar +; +SELECT * +FROM ot +WHERE field1 IN ( +SELECT alias1.pk +FROM it AS alias1 +LEFT JOIN it AS alias2 +ON alias1.col_varchar = alias2.col_varchar +); +field1 +1 +DROP TABLE it, ot; +# End of test for bug#12714094 +# +# Bug#12867557: Valgrind: conditional jump/move at key_cmp +# +CREATE TABLE t1 ( +pk INTEGER AUTO_INCREMENT, +col_int_key INTEGER, +PRIMARY KEY (pk), +KEY (col_int_key) +) AUTO_INCREMENT=10; +INSERT INTO t1 (col_int_key) VALUES (8); +CREATE TABLE t2 ( +pk INTEGER AUTO_INCREMENT, +col_int_key INTEGER, +col_time_key TIME, +PRIMARY KEY (pk), +KEY (col_int_key), +KEY (col_time_key) +) AUTO_INCREMENT=10; +INSERT INTO t2 (col_int_key, col_time_key) +VALUES +(8, '22:55:23.019225'), (7, '10:19:31.050677'), (1, '14:40:36.038608'), +(7, '04:37:47.062416'), (9, '19:34:06.054514'), (NULL,'20:35:33.022996'), +(1, NULL), (9, '14:43:37.057393'), (2, '02:23:09.043438'), +(9, '01:22:45.041064'), (2, '00:00:00'), (4, '00:13:25.038482'), +(0, '03:47:16.042671'), (4, '01:41:48.007423'), (8, '00:00:00'), +(NULL, '22:32:04.047407'), (NULL, '16:44:14.028443'), (0, '17:38:37.059754'), +(NULL, '08:46:48.042388'), (8, '14:11:27.044095'); +CREATE TABLE t0 +SELECT DISTINCT grandparent1.col_time_key AS g1 +FROM t2 AS grandparent1 +WHERE grandparent1.col_int_key IN +(SELECT parent1.col_int_key AS p1 +FROM t1 AS parent1) +AND grandparent1.pk > 9; +UPDATE t0 +SET g1 = g1 +WHERE g1 IN +(SELECT grandparent1.col_time_key AS g1 +FROM t2 AS grandparent1 +WHERE grandparent1.col_int_key IN +(SELECT parent1.col_int_key AS p1 +FROM t1 AS parent1) +AND grandparent1.pk > 9); +DROP TABLE t0, t1, t2; +# End of test for bug#12867557 +# +# Bug#12711441: crash in fix_after_pullout +# +CREATE TABLE t1 ( +pk int NOT NULL, +col_int_nokey int DEFAULT NULL, +col_int_key int DEFAULT NULL, +col_time_key time DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +PRIMARY KEY (pk) +); +CREATE VIEW v1 AS SELECT * FROM t1; +CREATE TABLE t2 ( +col_int_key int DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +KEY col_varchar_key(col_varchar_key, col_int_key) +); +CREATE TABLE t3 ( +pk int NOT NULL, +col_int_key INT DEFAULT NULL, +PRIMARY KEY (pk) +); +CREATE TABLE t4 ( +col_int_nokey INT DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +KEY col_varchar_key(col_varchar_key) +); +CREATE TABLE ts +SELECT alias1.col_time_key AS field1 +FROM v1 AS alias1 +RIGHT JOIN t3 AS alias2 +ON alias2.col_int_key = alias1.col_int_nokey +WHERE alias1.pk >= SOME( +SELECT SQ1_alias1.pk AS SQ1_field1 +FROM t3 AS SQ1_alias1 +INNER JOIN (t2 AS SQ1_alias2 +INNER JOIN t4 AS SQ1_alias3 +ON SQ1_alias3.col_varchar_key = SQ1_alias2.col_varchar_nokey) +ON SQ1_alias3.col_int_nokey = SQ1_alias2.col_int_key +WHERE SQ1_alias2.col_varchar_key <= alias1.col_varchar_key +AND SQ1_alias3.col_varchar_nokey <> alias1.col_varchar_key) +; +SELECT * FROM ts WHERE field1 IN ( +SELECT alias1.col_time_key AS field1 +FROM v1 AS alias1 +RIGHT JOIN t3 AS alias2 +ON alias2.col_int_key = alias1.col_int_nokey +WHERE alias1.pk >= SOME( +SELECT SQ1_alias1.pk AS SQ1_field1 +FROM t3 AS SQ1_alias1 +INNER JOIN (t2 AS SQ1_alias2 +INNER JOIN t4 AS SQ1_alias3 +ON SQ1_alias3.col_varchar_key = SQ1_alias2.col_varchar_nokey) +ON SQ1_alias3.col_int_nokey = SQ1_alias2.col_int_key +WHERE SQ1_alias2.col_varchar_key <= alias1.col_varchar_key +AND SQ1_alias3.col_varchar_nokey <> alias1.col_varchar_key) +); +field1 +DROP TABLE t1, t2, t3, t4, ts; +DROP VIEW v1; +# End of test for bug#12711441. +# +# Bug#12664936: Same query executed as where subquery ... +# +CREATE TABLE t1 ( +col_varchar_key VARCHAR(1), +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4; +INSERT INTO t1 VALUES +('o'), ('w'), ('m'), ('q'), +('f'), ('p'), ('j'), ('c'); +CREATE TABLE t2 ( +col_int_nokey INTEGER, +col_int_key INTEGER, +col_varchar_key varchar(1), +KEY col_int_key (col_int_key) +) charset utf8mb4; +INSERT INTO t2 VALUES +(8,5,'u'),(4,5,'p'),(8,1,'o'),(NULL,7,'v'), +(1,2,'g'),(2,1,'q'),(NULL,7,'l'),(3,1,'n'); +CREATE TABLE t4 +SELECT t2.col_int_nokey, t2.col_varchar_key +FROM t1 JOIN t2 ON t2.col_varchar_key = t1.col_varchar_key +WHERE t2.col_int_key = 1; +EXPLAIN SELECT * +FROM t4 +WHERE (col_int_nokey, col_varchar_key) IN +(SELECT t2.col_int_nokey, t2.col_varchar_key +FROM t1 JOIN t2 ON t2.col_varchar_key = t1.col_varchar_key +WHERE t2.col_int_key = 1 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t4 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE t2 NULL ref col_int_key col_int_key 5 const 3 12.50 Using where +1 SIMPLE t1 NULL ref col_varchar_key col_varchar_key 7 test.t4.col_varchar_key 2 100.00 Using index; FirstMatch(t4) +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`col_int_nokey` AS `col_int_nokey`,`test`.`t4`.`col_varchar_key` AS `col_varchar_key` from `test`.`t4` semi join (`test`.`t1` join `test`.`t2`) where ((`test`.`t2`.`col_varchar_key` = `test`.`t4`.`col_varchar_key`) and (`test`.`t1`.`col_varchar_key` = `test`.`t4`.`col_varchar_key`) and (`test`.`t2`.`col_int_nokey` = `test`.`t4`.`col_int_nokey`) and (`test`.`t2`.`col_int_key` = 1)) +SELECT * +FROM t4 +WHERE (col_int_nokey, col_varchar_key) IN +(SELECT t2.col_int_nokey, t2.col_varchar_key +FROM t1 JOIN t2 ON t2.col_varchar_key = t1.col_varchar_key +WHERE t2.col_int_key = 1 +); +col_int_nokey col_varchar_key +8 o +2 q +DROP TABLE t1, t2, t4; +# End of test for bug#12664936. +# +# Bug#13340270: assertion table->sort.record_pointers == __null +# +CREATE TABLE t1 ( +pk int NOT NULL, +col_int_key int DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key, col_int_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t1 VALUES +(10,8,'x','x'), +(11,7,'d','d'), +(12,1,'r','r'), +(13,7,'f','f'), +(14,9,'y','y'), +(15,NULL,'u','u'), +(16,1,'m','m'), +(17,9,NULL,NULL), +(18,2,'o','o'), +(19,9,'w','w'), +(20,2,'m','m'), +(21,4,'q','q'); +CREATE TABLE t2 +SELECT alias1.col_varchar_nokey AS field1 +FROM t1 AS alias1 JOIN t1 AS alias2 +ON alias2.col_int_key = alias1.pk OR +alias2.col_int_key = alias1.col_int_key +WHERE alias1.pk = 58 OR alias1.col_varchar_key = 'o' + +; +EXPLAIN SELECT * +FROM t2 +WHERE (field1) IN (SELECT alias1.col_varchar_nokey AS field1 +FROM t1 AS alias1 JOIN t1 AS alias2 +ON alias2.col_int_key = alias1.pk OR +alias2.col_int_key = alias1.col_int_key +WHERE alias1.pk = 58 OR alias1.col_varchar_key = 'o' +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE alias1 NULL index_merge PRIMARY,col_int_key,col_varchar_key col_varchar_key,PRIMARY 7,4 NULL 2 10.00 Using sort_union(col_varchar_key,PRIMARY); Using where +1 SIMPLE alias2 NULL ALL col_int_key NULL NULL NULL 12 19.00 Range checked for each record (index map: 0x2); FirstMatch(t2) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`field1` AS `field1` from `test`.`t2` semi join (`test`.`t1` `alias1` join `test`.`t1` `alias2`) where ((`test`.`alias1`.`col_varchar_nokey` = `test`.`t2`.`field1`) and ((`test`.`alias1`.`pk` = 58) or (`test`.`alias1`.`col_varchar_key` = 'o')) and ((`test`.`alias2`.`col_int_key` = `test`.`alias1`.`pk`) or (`test`.`alias2`.`col_int_key` = `test`.`alias1`.`col_int_key`))) +SELECT * +FROM t2 +WHERE (field1) IN (SELECT alias1.col_varchar_nokey AS field1 +FROM t1 AS alias1 JOIN t1 AS alias2 +ON alias2.col_int_key = alias1.pk OR +alias2.col_int_key = alias1.col_int_key +WHERE alias1.pk = 58 OR alias1.col_varchar_key = 'o' +); +field1 +o +o +DROP TABLE t1, t2; +# End of test for bug#13340270. +# +# Bug#13335319: Seg fault when analyzing FirstMatch semi-join strategy +# +CREATE TABLE ot1(a INTEGER); +INSERT INTO ot1 VALUES(1), (2), (3); +CREATE TABLE ot2(a INTEGER); +INSERT INTO ot2 VALUES(1), (2), (4), (6), (8), (10); +CREATE TABLE it1(a INTEGER); +INSERT INTO it1 VALUES(1), (3), (5), (7); +CREATE TABLE it2(a INTEGER); +INSERT INTO it2 VALUES(1), (3), (5), (7), (9); +explain SELECT ot1.a, ot2.a +FROM ot1, ot2 +WHERE ot1.a IN (SELECT a FROM it1) AND +ot2.a IN (SELECT a FROM it2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE NULL eq_ref 5 test.ot1.a 1 100.00 NULL +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where +2 MATERIALIZED it1 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +3 MATERIALIZED it2 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` join `test`.`ot2` semi join (`test`.`it1`) semi join (`test`.`it2`) where ((`test`.`ot2`.`a` = ``.`a`) and (``.`a` = `test`.`ot1`.`a`)) +SELECT ot1.a, ot2.a +FROM ot1, ot2 +WHERE ot1.a IN (SELECT a FROM it1) AND +ot2.a IN (SELECT a FROM it2); +a a +1 1 +3 1 +DROP TABLE ot1, ot2, it1, it2; +# End of test for bug#13335319. +# +# Bug#13334882: Assertion keypart_map failed in MyIsam function +# +CREATE TABLE t1 ( +pk int NOT NULL, +col_int_nokey INT NOT NULL, +col_int_key INT NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +) ENGINE=MyISAM; +INSERT INTO t1 VALUES +(1,4,0), +(2,6,8), +(3,3,1), +(7,2,6), +(8,9,1), +(9,3,6), +(10,8,2), +(11,1,4), +(12,8,8), +(13,8,4), +(14,5,4); +CREATE TABLE t2 ( +pk int NOT NULL, +col_int_nokey int NOT NULL, +col_int_key int NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +) ENGINE=MyISAM; +INSERT INTO t2 VALUES +(10,8,7); +CREATE TABLE t3 +SELECT grandparent1.col_int_nokey AS g1 +FROM t1 AS grandparent1 +WHERE (grandparent1.col_int_nokey, grandparent1.col_int_key) IN +(SELECT parent1.col_int_key AS p1, +parent1.col_int_key AS p2 +FROM t1 AS parent1 +LEFT JOIN t2 AS parent2 +ON parent1.col_int_nokey = parent2.col_int_key +) +AND grandparent1.col_int_key <> 3 +; +explain SELECT * FROM t3 +WHERE g1 NOT IN +(SELECT grandparent1.col_int_nokey AS g1 +FROM t1 AS grandparent1 +WHERE (grandparent1.col_int_nokey, grandparent1.col_int_key) IN +(SELECT parent1.col_int_key AS p1, +parent1.col_int_key AS p2 +FROM t1 AS parent1 +LEFT JOIN t2 AS parent2 +ON parent1.col_int_nokey = parent2.col_int_key +) +AND grandparent1.col_int_key <> 3 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE grandparent1 NULL ref col_int_key col_int_key 4 const 1 100.00 Using where; Not exists +1 SIMPLE parent1 NULL ref col_int_key col_int_key 4 test.grandparent1.col_int_nokey 1 100.00 Using where +1 SIMPLE parent2 NULL ref col_int_key col_int_key 4 test.parent1.col_int_nokey 2 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select '8' AS `g1` from anti join (`test`.`t1` `grandparent1` join `test`.`t1` `parent1` left join `test`.`t2` `parent2` on((`test`.`parent2`.`col_int_key` = `test`.`parent1`.`col_int_nokey`))) on(((`test`.`grandparent1`.`col_int_nokey` = '8') and (`test`.`grandparent1`.`col_int_key` = '8') and (`test`.`parent1`.`col_int_key` = '8') and ('8' <> 3))) where true +explain format=json SELECT * FROM t3 +WHERE g1 NOT IN +(SELECT grandparent1.col_int_nokey AS g1 +FROM t1 AS grandparent1 +WHERE (grandparent1.col_int_nokey, grandparent1.col_int_key) IN +(SELECT parent1.col_int_key AS p1, +parent1.col_int_key AS p2 +FROM t1 AS parent1 +LEFT JOIN t2 AS parent2 +ON parent1.col_int_nokey = parent2.col_int_key +) +AND grandparent1.col_int_key <> 3 +); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.36" + }, + "nested_loop": [ + { + "table": { + "table_name": "t3", + "access_type": "system", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.00", + "eval_cost": "0.10", + "prefix_cost": "0.00", + "data_read_per_join": "8" + }, + "used_columns": [ + "g1" + ] + } + }, + { + "table": { + "table_name": "grandparent1", + "access_type": "ref", + "possible_keys": [ + "col_int_key" + ], + "key": "col_int_key", + "used_key_parts": [ + "col_int_key" + ], + "key_length": "4", + "ref": [ + "const" + ], + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "not_exists": true, + "cost_info": { + "read_cost": "0.28", + "eval_cost": "0.11", + "prefix_cost": "0.39", + "data_read_per_join": "17" + }, + "used_columns": [ + "col_int_nokey", + "col_int_key" + ], + "attached_condition": "(((is_not_null_compl(grandparent1..parent2), (found_match(grandparent1..parent2), false, true), true) and (is_not_null_compl(grandparent1..parent2), (('8' <> 3)), true)) and (is_not_null_compl(grandparent1..parent2), (`test`.`grandparent1`.`col_int_nokey` = '8'), true))" + } + }, + { + "table": { + "table_name": "parent1", + "access_type": "ref", + "possible_keys": [ + "col_int_key" + ], + "key": "col_int_key", + "used_key_parts": [ + "col_int_key" + ], + "key_length": "4", + "ref": [ + "test.grandparent1.col_int_nokey" + ], + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.30", + "eval_cost": "0.12", + "prefix_cost": "0.81", + "data_read_per_join": "19" + }, + "used_columns": [ + "col_int_nokey", + "col_int_key" + ], + "attached_condition": "(is_not_null_compl(grandparent1..parent2), (`test`.`parent1`.`col_int_key` = '8'), true)" + } + }, + { + "table": { + "table_name": "parent2", + "access_type": "ref", + "possible_keys": [ + "col_int_key" + ], + "key": "col_int_key", + "used_key_parts": [ + "col_int_key" + ], + "key_length": "4", + "ref": [ + "test.parent1.col_int_nokey" + ], + "rows_examined_per_scan": 2, + "rows_produced_per_join": 1, + "filtered": "100.00", + "using_index": true, + "cost_info": { + "read_cost": "0.31", + "eval_cost": "0.10", + "prefix_cost": "1.36", + "data_read_per_join": "16" + }, + "used_columns": [ + "col_int_key" + ] + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select '8' AS `g1` from anti join (`test`.`t1` `grandparent1` join `test`.`t1` `parent1` left join `test`.`t2` `parent2` on((`test`.`parent2`.`col_int_key` = `test`.`parent1`.`col_int_nokey`))) on(((`test`.`grandparent1`.`col_int_nokey` = '8') and (`test`.`grandparent1`.`col_int_key` = '8') and (`test`.`parent1`.`col_int_key` = '8') and ('8' <> 3))) where true +SELECT * FROM t3 +WHERE g1 NOT IN +(SELECT grandparent1.col_int_nokey AS g1 +FROM t1 AS grandparent1 +WHERE (grandparent1.col_int_nokey, grandparent1.col_int_key) IN +(SELECT parent1.col_int_key AS p1, +parent1.col_int_key AS p2 +FROM t1 AS parent1 +LEFT JOIN t2 AS parent2 +ON parent1.col_int_nokey = parent2.col_int_key +) +AND grandparent1.col_int_key <> 3 +); +g1 +DROP TABLE t1, t2, t3; +# End of test for bug#13334882. +# +# Bug#13339643: Assertion on JOIN::flatten_subqueries on second execution +# +CREATE TABLE t1 ( +col_int_nokey INT, +col_varchar_nokey VARCHAR(1) +) charset utf8mb4; +INSERT INTO t1 VALUES +(1,'o'), +(2,'t'); +CREATE TABLE t2 LIKE t1; +INSERT INTO t2 VALUES +(1,'o'), +(4,'f'); +CREATE VIEW v_t2 AS SELECT * FROM t2; +CREATE TABLE t3 LIKE t1; +INSERT INTO t3 VALUES +(1,'o'), +(4,'f'); +explain SELECT alias1.col_varchar_nokey +FROM t1 AS alias1 +INNER JOIN v_t2 AS alias2 +ON alias2.col_int_nokey = alias1.col_int_nokey AND +'o' IN (SELECT col_varchar_nokey +FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch +1 SIMPLE alias1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`alias1`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t1` `alias1` join `test`.`t2` semi join (`test`.`t3`) where ((`test`.`t3`.`col_varchar_nokey` = 'o') and (`test`.`t2`.`col_int_nokey` = `test`.`alias1`.`col_int_nokey`)) +SELECT alias1.col_varchar_nokey +FROM t1 AS alias1 +INNER JOIN v_t2 AS alias2 +ON alias2.col_int_nokey = alias1.col_int_nokey AND +'o' IN (SELECT col_varchar_nokey +FROM t3); +col_varchar_nokey +o +PREPARE stmt FROM "SELECT alias1.col_varchar_nokey +FROM t1 AS alias1 +INNER JOIN v_t2 AS alias2 +ON alias2.col_int_nokey = alias1.col_int_nokey AND +'o' IN (SELECT col_varchar_nokey +FROM t3)"; +EXECUTE stmt; +col_varchar_nokey +o +DROP VIEW v_t2; +DROP TABLE t1, t2, t3; +# End of test for bug#13339643. +# +# Bug#13424134: Wrong result on JOIN + nested WHERE ... IN clauses +# +CREATE TABLE t1 ( +pk int NOT NULL, +col_int_nokey int NOT NULL, +col_int_key int NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +) ENGINE=MyIsam; +INSERT INTO t1 VALUES +(10,1,7), (13,7,3), (18,0,1), (23,8,1); +CREATE TABLE t2 ( +pk int NOT NULL, +col_int_key int NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +) ENGINE=MyIsam; +INSERT INTO t2 VALUES (1,7); +EXPLAIN SELECT t1a.* +FROM t1 AS t1a +JOIN t1 AS t1b USING ( col_int_nokey ) +WHERE t1a.col_int_key IN ( +SELECT pk +FROM t2 +WHERE col_int_key IN ( +SELECT col_int_nokey +FROM t1 +) +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL system PRIMARY,col_int_key NULL NULL NULL 1 100.00 NULL +1 SIMPLE t1a NULL ref col_int_key col_int_key 4 const 1 100.00 NULL +1 SIMPLE t1b NULL ALL NULL NULL NULL NULL 4 25.00 Using where +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; FirstMatch(t1b) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1a`.`pk` AS `pk`,`test`.`t1a`.`col_int_nokey` AS `col_int_nokey`,`test`.`t1a`.`col_int_key` AS `col_int_key` from `test`.`t1` `t1a` join `test`.`t1` `t1b` semi join (`test`.`t1`) where ((`test`.`t1b`.`col_int_nokey` = `test`.`t1a`.`col_int_nokey`) and (`test`.`t1a`.`col_int_key` = '1') and (`test`.`t1`.`col_int_nokey` = '7')) +SELECT t1a.* +FROM t1 AS t1a +JOIN t1 AS t1b USING ( col_int_nokey ) +WHERE t1a.col_int_key IN ( +SELECT pk +FROM t2 +WHERE col_int_key IN ( +SELECT col_int_nokey +FROM t1 +) +); +pk col_int_nokey col_int_key +18 0 1 +23 8 1 +ALTER TABLE t1 ENGINE=Innodb; +ALTER TABLE t2 ENGINE=Innodb; +SELECT t1a.* +FROM t1 AS t1a +JOIN t1 AS t1b USING ( col_int_nokey ) +WHERE t1a.col_int_key IN ( +SELECT pk +FROM t2 +WHERE col_int_key IN ( +SELECT col_int_nokey +FROM t1 +) +); +pk col_int_nokey col_int_key +18 0 1 +23 8 1 +DROP TABLE t1, t2; +# End of test for bug#13424134. +# +# Bug#13414014: Extra rows in result on semijoin query with where ... +# +CREATE TABLE t1 ( +c INT, +d INT, +a VARCHAR(1), +b VARCHAR(1), +KEY a (a) +) charset utf8mb4; +INSERT INTO t1 VALUES +(NULL,8,'x','x'), (7,4,'q','q'), (6,8,'c','c'); +CREATE TABLE t2 ( +a VARCHAR(1), +KEY a (a) +) charset utf8mb4; +INSERT INTO t2 VALUES +('c'), (NULL), ('x'), ('q'); +explain SELECT * +FROM t2 AS ot +WHERE (a, a) IN +(SELECT a, b +FROM t1 AS it +WHERE it.a = 'x' OR it.c > it.d +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using where +1 SIMPLE ot NULL ref a a 7 .a 2 100.00 Using index +2 MATERIALIZED it NULL ALL a NULL NULL NULL 3 40.74 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`ot`.`a` AS `a` from `test`.`t2` `ot` semi join (`test`.`t1` `it`) where ((``.`b` = ``.`a`) and (`test`.`ot`.`a` = ``.`a`) and (`test`.`it`.`b` = `test`.`it`.`a`) and (((``.`a` = 'x') and (`test`.`it`.`a` = 'x') and (`test`.`it`.`b` = 'x')) or (`test`.`it`.`c` > `test`.`it`.`d`))) +SELECT * +FROM t2 AS ot +WHERE (a, a) IN +(SELECT a, b +FROM t1 AS it +WHERE it.a = 'x' OR it.c > it.d +) +; +a +q +x +DROP TABLE t1, t2; +# End of test for bug#13414014. +# +# Bug#13545215: Missing rows on nested in-subquery with materialization +# +CREATE TABLE t1 ( +col_int_key int, +col_varchar_key varchar(1), +col_varchar_nokey varchar(1), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +INSERT INTO t1 VALUES +(8,'x','x'), (0,'p','p'), (8,'c','c'); +CREATE TABLE t2 ( +pk int NOT NULL, +col_varchar_key varchar(1), +col_varchar_nokey varchar(1), +PRIMARY KEY (pk), +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4; +INSERT INTO t2 VALUES +(1,'v','v'), (2,'v','v'), (3,'c','c'), (4,NULL,NULL), +(5,'x','x'), (6,'i','i'), (7,'e','e'), (8,'p','p'); +CREATE TABLE t3 ( +col_int_nokey int +); +INSERT INTO t3 VALUES (7); +explain SELECT grandparent1.col_varchar_nokey +FROM t1 AS grandparent1 JOIN t1 AS grandparent2 USING (col_int_key) +WHERE grandparent1.col_varchar_key IN ( +SELECT col_varchar_nokey +FROM t2 AS parent1 +WHERE col_varchar_key IN ( +SELECT child1.col_varchar_nokey +FROM t2 AS child1 LEFT JOIN t3 AS child2 +ON child1.pk < child2.col_int_nokey +) +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE grandparent1 NULL ALL col_int_key,col_varchar_key NULL NULL NULL 3 100.00 Using where +1 SIMPLE parent1 NULL ALL col_varchar_key NULL NULL NULL 8 12.50 Using where +1 SIMPLE child1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where +1 SIMPLE child2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(grandparent1) +1 SIMPLE grandparent2 NULL ref col_int_key col_int_key 5 test.grandparent1.col_int_key 2 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`grandparent1`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t1` `grandparent1` join `test`.`t1` `grandparent2` semi join (`test`.`t2` `parent1` join `test`.`t2` `child1` left join `test`.`t3` `child2` on((`test`.`child1`.`pk` < `test`.`child2`.`col_int_nokey`))) where ((`test`.`grandparent2`.`col_int_key` = `test`.`grandparent1`.`col_int_key`) and (`test`.`parent1`.`col_varchar_nokey` = `test`.`grandparent1`.`col_varchar_key`) and (`test`.`child1`.`col_varchar_nokey` = `test`.`parent1`.`col_varchar_key`)) +SELECT grandparent1.col_varchar_nokey +FROM t1 AS grandparent1 JOIN t1 AS grandparent2 USING (col_int_key) +WHERE grandparent1.col_varchar_key IN ( +SELECT col_varchar_nokey +FROM t2 AS parent1 +WHERE col_varchar_key IN ( +SELECT child1.col_varchar_nokey +FROM t2 AS child1 LEFT JOIN t3 AS child2 +ON child1.pk < child2.col_int_nokey +) +); +col_varchar_nokey +c +c +p +x +x +DROP TABLE t1, t2, t3; +# End of test for bug#13545215. +# +# BUG#13553211 - MISSING ROWS ON SELECT WITH IN-SUBQUERY AND +# MATERIALIZATION + SEMIJOIN ON +# +CREATE TABLE t1 ( +col_int_key int(11) DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (4,'v','v'); +INSERT INTO t1 VALUES (62,'v','v'); +INSERT INTO t1 VALUES (7,'c','c'); +INSERT INTO t1 VALUES (1,NULL,NULL); +EXPLAIN SELECT +alias1.col_varchar_nokey AS a1_nokey, +alias1.col_varchar_key AS a1_key, +alias2.col_varchar_nokey AS a2_nokey +FROM +t1 AS alias1, t1 AS alias2 +WHERE +(alias1.col_varchar_nokey,alias2.col_varchar_nokey) +IN +( +SELECT +sq2_alias2.col_varchar_nokey, sq2_alias1.col_varchar_key +FROM +t1 AS sq2_alias1, t1 AS sq2_alias2 +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE alias1 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +1 SIMPLE alias2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +1 SIMPLE NULL eq_ref 14 test.alias1.col_varchar_nokey,test.alias2.col_varchar_nokey 1 100.00 NULL +2 MATERIALIZED sq2_alias1 NULL index col_varchar_key col_varchar_key 12 NULL 4 100.00 Using index +2 MATERIALIZED sq2_alias2 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`alias1`.`col_varchar_nokey` AS `a1_nokey`,`test`.`alias1`.`col_varchar_key` AS `a1_key`,`test`.`alias2`.`col_varchar_nokey` AS `a2_nokey` from `test`.`t1` `alias1` join `test`.`t1` `alias2` semi join (`test`.`t1` `sq2_alias1` join `test`.`t1` `sq2_alias2`) where ((``.`col_varchar_key` = `test`.`alias2`.`col_varchar_nokey`) and (``.`col_varchar_nokey` = `test`.`alias1`.`col_varchar_nokey`)) +SELECT +alias1.col_varchar_nokey AS a1_nokey, +alias1.col_varchar_key AS a1_key, +alias2.col_varchar_nokey AS a2_nokey +FROM +t1 AS alias1, t1 AS alias2 +WHERE +(alias1.col_varchar_nokey,alias2.col_varchar_nokey) +IN +( +SELECT +sq2_alias2.col_varchar_nokey, sq2_alias1.col_varchar_key +FROM +t1 AS sq2_alias1, t1 AS sq2_alias2 +) +; +a1_nokey a1_key a2_nokey +c c c +c c v +c c v +v v c +v v c +v v v +v v v +v v v +v v v +DROP TABLE t1; +# +# Bug#13541406: Wrong result with loosescan on select .. where .. in +# +CREATE TABLE t1 ( +col_int_key INT NOT NULL, +col_varchar_nokey VARCHAR(1) NOT NULL, +KEY col_int_key (col_int_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t1 VALUES +(7,'v'), (0,'s'), (9,'l'), (3,'y'), (4,'c'), (2,'i'), (5,'h'), (3,'q'), +(1,'a'), (3,'v'), (6,'u'), (7,'s'), (5,'y'), (1,'z'), (204,'h'), (224,'p'), +(9,'e'), (5,'i'), (0,'y'), (3,'w'); +CREATE TABLE t2 ( +pk INT NOT NULL, +col_int_key INT NOT NULL, +col_varchar_key VARCHAR(1) NOT NULL, +col_varchar_nokey VARCHAR(1) NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t2 VALUES +(1,0,'j','j'), (2,8,'v','v'), (3,1,'c','c'), (4,8,'m','m'), +(5,9,'d','d'), (6,24,'d','d'), (7,6,'y','y'), (8,1,'t','t'), +(9,6,'d','d'), (10,2,'s','s'), (11,4,'r','r'), (12,8,'m','m'), +(13,4,'b','b'), (14,4,'x','x'), (15,7,'g','g'), (16,4,'p','p'), +(17,1,'q','q'), (18,9,'w','w'), (19,4,'d','d'), (20,8,'e','e'); +# This query should never use a LooseScan strategy +explain SELECT ot1.col_int_key AS field1 +FROM t2 AS ot1, t2 AS ot2 +WHERE (ot1.col_varchar_key, ot2.col_varchar_nokey) IN ( +SELECT it2.col_varchar_nokey, it1.col_varchar_key +FROM t2 AS it1 JOIN t1 AS it2 ON it2.col_int_key = it1.pk); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 20 100.00 Parallel execute (1 workers) +2 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 20 100.00 Start temporary +2 SIMPLE it1 NULL ref PRIMARY,col_varchar_key col_varchar_key 6 test.ot2.col_varchar_nokey 1 100.00 Using index +2 SIMPLE it2 NULL ref col_int_key col_int_key 4 test.it1.pk 1 100.00 Using join buffer (Batched Key Access) +2 SIMPLE ot1 NULL ref col_varchar_key col_varchar_key 6 test.it2.col_varchar_nokey 1 100.00 Using index; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`col_int_key` AS `field1` from `test`.`t2` `ot1` join `test`.`t2` `ot2` semi join (`test`.`t2` `it1` join `test`.`t1` `it2`) where ((`test`.`it2`.`col_int_key` = `test`.`it1`.`pk`) and (`test`.`it1`.`col_varchar_key` = `test`.`ot2`.`col_varchar_nokey`) and (`test`.`ot1`.`col_varchar_key` = `test`.`it2`.`col_varchar_nokey`)) +SELECT ot1.col_int_key AS field1 +FROM t2 AS ot1, t2 AS ot2 +WHERE (ot1.col_varchar_key, ot2.col_varchar_nokey) IN ( +SELECT it2.col_varchar_nokey, it1.col_varchar_key +FROM t2 AS it1 JOIN t1 AS it2 ON it2.col_int_key = it1.pk); +field1 +1 +1 +1 +2 +6 +6 +6 +6 +6 +8 +8 +8 +8 +8 +8 +9 +DROP TABLE t1, t2; +# End of test for bug#13541406. +# +# Bug#13576391: Missing rows on select with in-subquery and +# batched-key-access=on and semijoin +# +CREATE TABLE t1 ( +col_int_nokey int NOT NULL, +col_varchar_key varchar(1) NOT NULL, +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4 engine=InnoDB; +INSERT INTO t1 VALUES +(1,'v'), (7,'s'), (4,'l'), (7,'y'), (0,'c'), (2,'i'), (9,'h'), (4,'q'), +(0,'a'), (9,'v'), (1,'u'), (3,'s'), (8,'y'), (8,'z'), (18,'h'), (84,'p'), +(6,'e'), (3,'i'), (6,'y'), (6,'w'); +CREATE TABLE t2 ( +col_int_nokey int NOT NULL, +col_varchar_nokey varchar(1) NOT NULL +) charset utf8mb4 engine=InnoDB; +INSERT INTO t2 VALUES +(4,'j'), (6,'v'), (3,'c'), (5,'m'), (3,'d'), (246,'d'), (2,'y'), (9,'t'), +(3,'d'), (8,'s'), (1,'r'), (8,'m'), (8,'b'), (5,'x'), (7,'g'), (5,'p'), +(1,'q'), (6,'w'), (2,'d'), (9,'e'); +explain SELECT col_varchar_nokey +FROM t2 AS ot +WHERE col_varchar_nokey IN ( +SELECT col_varchar_key +FROM t1 AS it +WHERE it.col_int_nokey <= it.col_int_nokey +AND NOT ot.col_int_nokey < 2 +) +ORDER BY col_varchar_nokey; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 20 33.33 Parallel execute (1 workers) +2 SIMPLE ot NULL ALL NULL NULL NULL NULL 20 33.33 Using where; Using temporary; Using filesort +2 SIMPLE it NULL ref col_varchar_key col_varchar_key 6 test.ot.col_varchar_nokey 1 100.00 FirstMatch(ot); Using join buffer (Batched Key Access) +Warnings: +Note 1276 Field or reference 'test.ot.col_int_nokey' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`ot`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t2` `ot` semi join (`test`.`t1` `it`) where ((`test`.`it`.`col_varchar_key` = `test`.`ot`.`col_varchar_nokey`) and (`test`.`ot`.`col_int_nokey` >= 2)) order by `test`.`ot`.`col_varchar_nokey` +SELECT col_varchar_nokey +FROM t2 AS ot +WHERE col_varchar_nokey IN ( +SELECT col_varchar_key +FROM t1 AS it +WHERE it.col_int_nokey <= it.col_int_nokey +AND NOT ot.col_int_nokey < 2 +) +ORDER BY col_varchar_nokey; +col_varchar_nokey +c +e +p +s +v +w +y +ALTER TABLE t1 ENGINE=MyISAM; +ALTER TABLE t2 ENGINE=MyISAM; +explain SELECT col_varchar_nokey +FROM t2 AS ot +WHERE col_varchar_nokey IN ( +SELECT col_varchar_key +FROM t1 AS it +WHERE it.col_int_nokey <= it.col_int_nokey +AND NOT ot.col_int_nokey < 2 +) +ORDER BY col_varchar_nokey; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 20 33.33 Using where; Using temporary; Using filesort +1 SIMPLE it NULL ref col_varchar_key col_varchar_key 6 test.ot.col_varchar_nokey 2 100.00 FirstMatch(ot); Using join buffer (Batched Key Access) +Warnings: +Note 1276 Field or reference 'test.ot.col_int_nokey' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`ot`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t2` `ot` semi join (`test`.`t1` `it`) where ((`test`.`it`.`col_varchar_key` = `test`.`ot`.`col_varchar_nokey`) and (`test`.`ot`.`col_int_nokey` >= 2)) order by `test`.`ot`.`col_varchar_nokey` +SELECT col_varchar_nokey +FROM t2 AS ot +WHERE col_varchar_nokey IN ( +SELECT col_varchar_key +FROM t1 AS it +WHERE it.col_int_nokey <= it.col_int_nokey +AND NOT ot.col_int_nokey < 2 +) +ORDER BY col_varchar_nokey; +col_varchar_nokey +c +e +p +s +v +w +y +ALTER TABLE t1 ENGINE=Memory; +ALTER TABLE t2 ENGINE=Memory; +explain SELECT col_varchar_nokey +FROM t2 AS ot +WHERE col_varchar_nokey IN ( +SELECT col_varchar_key +FROM t1 AS it +WHERE it.col_int_nokey <= it.col_int_nokey +AND NOT ot.col_int_nokey < 2 +) +ORDER BY col_varchar_nokey; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 20 33.33 Using where; Using filesort +1 SIMPLE it NULL ref col_varchar_key col_varchar_key 6 test.ot.col_varchar_nokey 2 100.00 FirstMatch(ot) +Warnings: +Note 1276 Field or reference 'test.ot.col_int_nokey' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`ot`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t2` `ot` semi join (`test`.`t1` `it`) where ((`test`.`it`.`col_varchar_key` = `test`.`ot`.`col_varchar_nokey`) and (`test`.`ot`.`col_int_nokey` >= 2)) order by `test`.`ot`.`col_varchar_nokey` +SELECT col_varchar_nokey +FROM t2 AS ot +WHERE col_varchar_nokey IN ( +SELECT col_varchar_key +FROM t1 AS it +WHERE it.col_int_nokey <= it.col_int_nokey +AND NOT ot.col_int_nokey < 2 +) +ORDER BY col_varchar_nokey; +col_varchar_nokey +c +e +p +s +v +w +y +DROP TABLE t1, t2; +# End of test for bug#13576391. +# +# Bug #13589848 "MISSING ROW ON SELECT WITH NESTED IN CLAUSES WHEN LOOSESCAN=ON" +# +CREATE TABLE t1 ( +id INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +KEY (col_varchar_key) +) charset utf8mb4; +INSERT INTO t1 VALUES (100,'m','m'), +(200,'b','b'), (300,'x','x'); +CREATE TABLE t2 ( +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +KEY (col_varchar_key) +) charset utf8mb4; +INSERT INTO t2 VALUES ('b','b'); +CREATE TABLE t3 ( +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +KEY (col_varchar_key) +) charset utf8mb4; +INSERT INTO t3 VALUES ('k','k'); +EXPLAIN SELECT gp1.id +FROM t1 AS gp1 JOIN t3 AS gp2 +ON gp2.col_varchar_key <> gp1.col_varchar_nokey +WHERE (gp1.col_varchar_nokey, gp1.col_varchar_nokey) +IN ( +SELECT col_varchar_nokey, col_varchar_nokey +FROM t1 +WHERE col_varchar_nokey +IN ( SELECT col_varchar_key +FROM t2 LEFT JOIN t3 USING (col_varchar_key) ) +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE gp2 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL index col_varchar_key col_varchar_key 7 NULL 1 100.00 Using where; Using index; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +1 SIMPLE gp1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +1 SIMPLE t3 NULL ref col_varchar_key col_varchar_key 7 test.t2.col_varchar_key 2 100.00 Using index; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`gp1`.`id` AS `id` from `test`.`t1` `gp1` semi join (`test`.`t1` join `test`.`t2` left join `test`.`t3` on((`test`.`t2`.`col_varchar_key` = `test`.`t3`.`col_varchar_key`))) where ((`test`.`t1`.`col_varchar_nokey` = `test`.`t2`.`col_varchar_key`) and (`test`.`gp1`.`col_varchar_nokey` = `test`.`t2`.`col_varchar_key`) and ('k' <> `test`.`t2`.`col_varchar_key`)) +SELECT gp1.id +FROM t1 AS gp1 JOIN t3 AS gp2 +ON gp2.col_varchar_key <> gp1.col_varchar_nokey +WHERE (gp1.col_varchar_nokey, gp1.col_varchar_nokey) +IN ( +SELECT col_varchar_nokey, col_varchar_nokey +FROM t1 +WHERE col_varchar_nokey +IN ( SELECT col_varchar_key +FROM t2 LEFT JOIN t3 USING (col_varchar_key) ) +) +; +id +200 +DROP TABLE t1,t2,t3; +# +# Bug #13596176: Missing row on select with nested in clause when +# matr=on and bnl=off + MyISAM +# +CREATE TABLE t1 ( +int_key int DEFAULT NULL, +vc_key varchar(1) DEFAULT NULL, +vc_nokey varchar(1) DEFAULT NULL, +KEY int_key (int_key), +KEY vc_key (vc_key, int_key) +) charset utf8mb4 ENGINE=MyISAM; +INSERT INTO t1 VALUES +(8,'x','x'), (7,'d','d'), (1,'r','r'), (7,'f','f'), +(9,'y','y'), (NULL,'u','u'), (1,'m','m'), (9,NULL,NULL), +(2,'o','o'), (9,'w','w'), (2,'m','m'), (4,'q','q'), +(0,NULL,NULL), (4,'d','d'), (8,'g','g'), (NULL,'x','x'), +(NULL,'f','f'), (0,'p','p'), (NULL,'j','j'), (8,'c','c'); +CREATE TABLE t2 ( +int_key int DEFAULT NULL, +vc_key varchar(1) DEFAULT NULL, +KEY int_key (int_key), +KEY vc_key (vc_key, int_key) +) charset utf8mb4 ENGINE=MyISAM; +INSERT INTO t2 VALUES (8,'g'); +explain SELECT vc_key +FROM t1 as outr +WHERE (vc_nokey, vc_key ) IN +(SELECT vc_nokey, vc_nokey +FROM t1 middle +WHERE vc_nokey IN +(SELECT child1.vc_key +FROM t2 AS child1 JOIN t1 AS child2 USING (int_key) +) +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE child1 NULL index int_key,vc_key vc_key 12 NULL 1 100.00 Using where; Using index; Start temporary +1 SIMPLE outr NULL ref vc_key vc_key 7 test.child1.vc_key 3 10.00 Using where; Using join buffer (Batched Key Access) +1 SIMPLE middle NULL ALL NULL NULL NULL NULL 20 10.00 Using where +1 SIMPLE child2 NULL ref int_key int_key 5 test.child1.int_key 3 100.00 Using index; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`outr`.`vc_key` AS `vc_key` from `test`.`t1` `outr` semi join (`test`.`t1` `middle` join `test`.`t2` `child1` join `test`.`t1` `child2`) where ((`test`.`child2`.`int_key` = `test`.`child1`.`int_key`) and (`test`.`outr`.`vc_nokey` = `test`.`child1`.`vc_key`) and (`test`.`outr`.`vc_key` = `test`.`child1`.`vc_key`) and (`test`.`middle`.`vc_nokey` = `test`.`child1`.`vc_key`)) +SELECT vc_key +FROM t1 as outr +WHERE (vc_nokey, vc_key ) IN +(SELECT vc_nokey, vc_nokey +FROM t1 middle +WHERE vc_nokey IN +(SELECT child1.vc_key +FROM t2 AS child1 JOIN t1 AS child2 USING (int_key) +) +); +vc_key +g +DROP TABLE t1, t2; +# End of test for bug#13596176. +# +# BUG#11754478: MAX/MIN + SUBQUERY + AND FAILS TO RETURN ANY ROWS +# BUG#13599013: MAX/MIN + SUBQUERY IN WHERE CLAUSE MATCHING NO +# ROWS + INDEX DOES NOT RETURN NULL +# +CREATE TABLE t1 ( +pk int(11) PRIMARY KEY, +int_key int(11), +KEY int_key (int_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (1,0),(2,0),(3,2),(4,0),(5,3),(6,0); +SELECT MIN(int_key) FROM t1 WHERE (4, 4) IN (SELECT 1, 2); +MIN(int_key) +NULL +SELECT MIN(int_key) FROM t1 WHERE (4, 4) IN (SELECT 4, 4); +MIN(int_key) +0 +SELECT MIN(pk) FROM t1 WHERE pk IN (SELECT int_key FROM t1) AND pk = 6; +MIN(pk) +NULL +DROP TABLE t1; +# BUG#13726217: Crash in Item_ident::fix_after_pullout() +CREATE TABLE t1(a INTEGER) engine=innodb; +INSERT INTO t1 VALUES (0); +SELECT 0 +FROM t1 +WHERE 0 IN +(SELECT 0 +FROM t1 +WHERE 0 LIKE +(SELECT elt(a, 0) AS b +FROM t1 +GROUP BY a +HAVING b +) +); +0 +DROP TABLE t1; +# End of test for bug#13726217. +# BUG#13773979: Missing rows on second execution of prepared statement +CREATE TABLE t1 ( +col_int_nokey INT, +col_int_key INT, +col_varchar_key VARCHAR(1) +); +INSERT INTO t1 VALUES +(1,7,'v'), (7,0,'s'), (4,9,'l'), (7,3,'y'), +(2,2,'i'), (9,5,'h'), (0,1,'a'), (9,3,'v'); +CREATE VIEW v1 AS SELECT * FROM t1; +SELECT * +FROM t1 +WHERE col_int_key IN ( +SELECT alias1.col_int_nokey AS field1 +FROM v1 AS alias1 +WHERE alias1.col_varchar_key < 'v' +); +col_int_nokey col_int_key col_varchar_key +1 7 v +2 2 i +4 9 l +7 0 s +prepare stmt FROM "SELECT * +FROM t1 +WHERE col_int_key IN ( +SELECT alias1.col_int_nokey AS field1 +FROM v1 AS alias1 +WHERE alias1.col_varchar_key < 'v' +)"; +execute stmt; +col_int_nokey col_int_key col_varchar_key +1 7 v +2 2 i +4 9 l +7 0 s +execute stmt; +col_int_nokey col_int_key col_varchar_key +1 7 v +2 2 i +4 9 l +7 0 s +DEALLOCATE PREPARE stmt; +DROP VIEW v1; +DROP TABLE t1; +# End of test for bug#13773979. +# +# BUG#13685026 ASSERTION CUR_SJ_INNER_TABLES == 0 IN +# --OPTIMIZE_TABLE_ORDER::CHOOSE_TABLE_ORDER +# +CREATE TABLE t1 ( +col_int_key INT(11) NOT NULL, +col_datetime_key DATETIME NOT NULL, +col_varchar_key VARCHAR(1) NOT NULL, +col_varchar_nokey VARCHAR(1) NOT NULL, +KEY col_int_key (col_int_key), +KEY col_datetime_key (col_datetime_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (0,'2002-02-13 17:30:06','j','j'); +INSERT INTO t1 VALUES (8,'2008-09-27 00:34:58','v','v'); +CREATE TABLE t2 ( +col_int_key INT(11) NOT NULL, +col_datetime_key DATETIME NOT NULL, +col_varchar_key VARCHAR(1) NOT NULL, +col_varchar_nokey VARCHAR(1) NOT NULL, +KEY col_int_key (col_int_key), +KEY col_datetime_key (col_datetime_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (7,'2003-08-21 00:00:00','b','b'); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +SET @old_depth=@@optimizer_search_depth; +SET optimizer_search_depth=4; +EXPLAIN SELECT col_datetime_key +FROM t1 as outr +WHERE col_datetime_key IN ( +SELECT alias1.col_datetime_key +FROM t1 AS alias1 +LEFT JOIN t1 as alias3 +STRAIGHT_JOIN ( t2 AS alias4 +JOIN t1 AS alias5 +ON alias5.col_varchar_key <= alias4.col_varchar_nokey ) +ON alias5.col_int_key < alias4.col_int_key +ON alias5.col_varchar_key = alias4.col_varchar_key +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE outr NULL index col_datetime_key col_datetime_key 5 NULL 2 100.00 Using index +1 SIMPLE alias1 NULL ref col_datetime_key col_datetime_key 5 test.outr.col_datetime_key 1 100.00 Using index +1 SIMPLE alias4 NULL ALL col_int_key,col_varchar_key NULL NULL NULL 1 100.00 NULL +1 SIMPLE alias5 NULL ref col_int_key,col_varchar_key col_varchar_key 6 test.alias4.col_varchar_key 1 100.00 Using where; Using index +1 SIMPLE alias3 NULL index NULL col_int_key 4 NULL 2 100.00 Using index; FirstMatch(outr) +Warnings: +Note 1003 /* select#1 */ select `test`.`outr`.`col_datetime_key` AS `col_datetime_key` from `test`.`t1` `outr` semi join (`test`.`t1` `alias1` left join (`test`.`t1` `alias3` join `test`.`t2` `alias4` join `test`.`t1` `alias5`) on(((`test`.`alias5`.`col_varchar_key` = `test`.`alias4`.`col_varchar_key`) and (`test`.`alias5`.`col_int_key` < `test`.`alias4`.`col_int_key`) and (`test`.`alias5`.`col_varchar_key` <= `test`.`alias4`.`col_varchar_nokey`)))) where (`test`.`alias1`.`col_datetime_key` = `test`.`outr`.`col_datetime_key`) +SELECT col_datetime_key +FROM t1 as outr +WHERE col_datetime_key IN ( +SELECT alias1.col_datetime_key +FROM t1 AS alias1 +LEFT JOIN t1 as alias3 +STRAIGHT_JOIN ( t2 AS alias4 +JOIN t1 AS alias5 +ON alias5.col_varchar_key <= alias4.col_varchar_nokey ) +ON alias5.col_int_key < alias4.col_int_key +ON alias5.col_varchar_key = alias4.col_varchar_key +); +col_datetime_key +2002-02-13 17:30:06 +2008-09-27 00:34:58 +DROP TABLE t1,t2; +SET @@optimizer_search_depth=@old_depth; +# +# BUG#13848789: SEGFAULT IN JOIN_READ_NEXT_SAME AT +# SQL/SQL_EXECUTOR.CC ON HAVING...IN...JOIN +# +CREATE TABLE t1 ( +col_int_key INT, +col_varchar_key VARCHAR(1), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4; +INSERT INTO t1 VALUES (8,'x'); +CREATE TABLE t2 ( +col_varchar_key VARCHAR(1), +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4; +INSERT INTO t2 VALUES ('x'), ('y'); +explain SELECT MIN(col_int_key) +FROM t1 as t1_outer +HAVING (1, 2) IN ( +SELECT t1_inner.col_int_key, MAX(t1_inner.col_int_key) +FROM t1 as t1_inner JOIN t2 +ON t2.col_varchar_key = t1_inner.col_varchar_key +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible HAVING +2 SUBQUERY t1_inner NULL system col_varchar_key NULL NULL NULL 1 100.00 NULL +2 SUBQUERY t2 NULL ref col_varchar_key col_varchar_key 7 const 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select min(`test`.`t1_outer`.`col_int_key`) AS `MIN(col_int_key)` from `test`.`t1` `t1_outer` having false +SELECT MIN(col_int_key) +FROM t1 as t1_outer +HAVING (1, 2) IN ( +SELECT t1_inner.col_int_key, MAX(t1_inner.col_int_key) +FROM t1 as t1_inner JOIN t2 +ON t2.col_varchar_key = t1_inner.col_varchar_key +); +MIN(col_int_key) +DROP TABLE t1,t2; +# Bug#13838810: Segfault in evaluate_null_complemented_join_record +CREATE TABLE t1 ( +pk int NOT NULL, +col_int_nokey int DEFAULT NULL, +col_int_key int DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t1 VALUES (10,NULL,8,'x'); +CREATE TABLE t2 ( +pk int NOT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +PRIMARY KEY (pk) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t2 VALUES (1,'x'); +CREATE TABLE t3 ( +pk int NOT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +PRIMARY KEY (pk), +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t3 VALUES +(1,'v','v'), (2,'v','v'), (3,'c','c'), (4,NULL,NULL); +EXPLAIN SELECT table1.pk,table2.pk, table3.pk +FROM t2 AS table1 +LEFT JOIN t1 AS table2 +LEFT JOIN t1 AS table3 +ON table3.col_int_key = table2.col_int_key +ON table3.pk = table2.col_int_nokey AND +table1.col_varchar_nokey IN ( +SELECT subquery3_t1.col_varchar_nokey +FROM t3 AS subquery3_t1 +LEFT JOIN t1 AS subquery3_t2 +ON subquery3_t2.col_varchar_key = subquery3_t1.col_varchar_key +WHERE subquery3_t2.col_int_nokey <> 9 +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE table1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE table2 NULL ALL col_int_key NULL NULL NULL 1 100.00 NULL +2 SIMPLE table3 NULL eq_ref PRIMARY,col_int_key PRIMARY 4 test.table2.col_int_nokey 1 100.00 Using where +2 SIMPLE subquery3_t2 NULL ALL col_varchar_key NULL NULL NULL 1 100.00 Using where +2 SIMPLE subquery3_t1 NULL ref col_varchar_key col_varchar_key 7 test.subquery3_t2.col_varchar_key 1 100.00 Using where; FirstMatch(table3) +Warnings: +Note 1003 /* select#1 */ select `test`.`table1`.`pk` AS `pk`,`test`.`table2`.`pk` AS `pk`,`test`.`table3`.`pk` AS `pk` from `test`.`t2` `table1` left join (`test`.`t1` `table2` join `test`.`t1` `table3` semi join (`test`.`t3` `subquery3_t1` join `test`.`t1` `subquery3_t2`)) on(((`test`.`table3`.`col_int_key` = `test`.`table2`.`col_int_key`) and (`test`.`subquery3_t1`.`col_varchar_key` = `test`.`subquery3_t2`.`col_varchar_key`) and (`test`.`subquery3_t1`.`col_varchar_nokey` = `test`.`table1`.`col_varchar_nokey`) and (`test`.`table3`.`pk` = `test`.`table2`.`col_int_nokey`) and (`test`.`subquery3_t2`.`col_int_nokey` <> 9))) where true +SELECT table1.pk,table2.pk, table3.pk +FROM t2 AS table1 +LEFT JOIN t1 AS table2 +LEFT JOIN t1 AS table3 +ON table3.col_int_key = table2.col_int_key +ON table3.pk = table2.col_int_nokey AND +table1.col_varchar_nokey IN ( +SELECT subquery3_t1.col_varchar_nokey +FROM t3 AS subquery3_t1 +LEFT JOIN t1 AS subquery3_t2 +ON subquery3_t2.col_varchar_key = subquery3_t1.col_varchar_key +WHERE subquery3_t2.col_int_nokey <> 9 +) +; +pk pk pk +1 NULL NULL +DROP TABLE t1, t2, t3; +Extra test case for specific code coverage +CREATE TABLE t1(pk INTEGER); +INSERT INTO t1 VALUES(1), (2); +explain SELECT * +FROM t1 AS ot1 LEFT JOIN t1 AS ot2 +ON ot1.pk=ot2.pk AND +ot2.pk IN +(SELECT it1.pk +FROM t1 AS it1 LEFT JOIN t1 AS it2 ON it1.pk=it2.pk); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE NULL eq_ref 5 test.ot2.pk 1 100.00 Using where +2 MATERIALIZED it1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED it2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`pk` AS `pk`,`test`.`ot2`.`pk` AS `pk` from `test`.`t1` `ot1` left join (`test`.`t1` `ot2` semi join (`test`.`t1` `it1` left join `test`.`t1` `it2` on((`test`.`it1`.`pk` = `test`.`it2`.`pk`)))) on(((`test`.`ot2`.`pk` = `test`.`ot1`.`pk`) and (``.`pk` = `test`.`ot1`.`pk`))) where true +SELECT * +FROM t1 AS ot1 LEFT JOIN t1 AS ot2 +ON ot1.pk=ot2.pk AND +ot2.pk IN +(SELECT it1.pk +FROM t1 AS it1 LEFT JOIN t1 AS it2 ON it1.pk=it2.pk); +pk pk +1 1 +2 2 +DROP TABLE t1; +# End of test for bug#13838810. +# +# Bug#13845930: Segfault in st_join_table::and_with_condition +# +CREATE TABLE t1 ( +col_int INTEGER +); +CREATE TABLE t2 ( +col_varchar_1 VARCHAR(1), +col_varchar_2 VARCHAR(1) +); +INSERT INTO t2 VALUES ('x','x'), ('c','c'); +PREPARE stmt FROM ' +SELECT alias2.col_varchar_2 AS field1 +FROM t2 AS alias1 + JOIN + (t2 AS alias2 + LEFT JOIN t2 AS alias3 + ON (8, 92) IN + (SELECT sq1_alias1.col_int, + sq1_alias2.col_int + FROM t1 AS sq1_alias1 JOIN t1 AS sq1_alias2 + ) + ) + ON alias3.col_varchar_1 = alias2.col_varchar_2 +'; +EXECUTE stmt; +field1 + +EXECUTE stmt; +field1 +DEALLOCATE prepare stmt; +DROP TABLE t1, t2; +# End of test for bug#13845930. +# +# Bug#13855925: Assert 'prebuilt->search_tuple->n_fields > 0' +# in ha_innobase::index_read +# +CREATE TABLE t1 ( +pk INTEGER AUTO_INCREMENT, +col_int_nokey INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk), +KEY (col_varchar_key) +) charset utf8mb4 ENGINE=INNODB; +INSERT INTO t1 ( +col_int_key, col_int_nokey, +col_varchar_key, col_varchar_nokey +) VALUES +(4, 2, 'v','v'), (62, 150, 'v','v'), (7, NULL, 'c','c'), (1, 2, NULL, NULL), +(0, 5, 'x','x'), (7, 3, 'i','i'), (7, 1, 'e','e'), (1, 4, 'p','p'), +(7, NULL, 's','s'), (1, 2, 'j','j'), (5, 6, 'z','z'), (2, 6, 'c','c'), +(0, 8, 'a','a'), (1, 2, 'q','q'), (8, 6, 'y','y'), (1, 8, NULL, NULL), +(1, 3, 'r','r'), (9, 3, 'v','v'), (1, 9, NULL, NULL), (5, 6, 'r','r'); +CREATE TABLE t2 ( +pk INT AUTO_INCREMENT, +col_int_nokey INT, +col_int_key INT, +PRIMARY KEY (pk), +KEY (col_int_key) +) charset utf8mb4 AUTO_INCREMENT=10 ENGINE=INNODB; +INSERT INTO t2 (col_int_key, col_int_nokey) VALUES +(8, NULL), (7, 8), (1, 1), (7, 9), (9, 4), (NULL, 3), (1, 2), (9, NULL), +(2, 2), (9, NULL), (2, 6), (4, 7), (0, 2), (4, 5), (8, 7), (NULL, 6), +(NULL, 6), (0, 2), (NULL, 9), (8, 6); +CREATE TABLE t3 ( +pk INT AUTO_INCREMENT, +col_varchar_key VARCHAR(1), +PRIMARY KEY (pk), +KEY (col_varchar_key) +) charset utf8mb4 ENGINE=INNODB; +INSERT INTO t3 (col_varchar_key) VALUES +('c'), ('c'), ('q'), ('g'), ('e'), ('l'), (NULL), ('c'), ('h'), ('d'), +('c'), ('i'), ('t'), ('g'), ('q'), ('l'), ('n'), ('z'), ('n'), ('r'), ('p'); +CREATE VIEW v1 AS +SELECT table2.col_varchar_nokey AS field1 +FROM t2 AS table1 +INNER JOIN (t1 AS table2 +STRAIGHT_JOIN t2 AS table3 +ON table3.col_int_key = table2.pk AND +table3.col_int_nokey = ANY +(SELECT subquery1_t2.col_int_nokey AS subquery1_field1 +FROM t2 AS subquery1_t1 +RIGHT OUTER JOIN t1 AS subquery1_t2 +INNER JOIN t1 AS subquery1_t3 +ON subquery1_t3.col_int_key = subquery1_t2.pk +ON subquery1_t3.col_varchar_key=subquery1_t2.col_varchar_nokey +WHERE subquery1_t1.pk > 1 +) +) +ON table3.col_int_key IN +(SELECT subquery2_t1.col_int_key AS subquery2_field1 +FROM t2 AS subquery2_t1 +RIGHT OUTER JOIN t3 AS subquery2_t2 +LEFT OUTER JOIN t1 AS subquery2_t3 +ON subquery2_t3.col_varchar_key = subquery2_t2.col_varchar_key +ON subquery2_t3.pk = subquery2_t2.pk +) +; +explain SELECT * FROM v1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE table1 NULL index NULL col_int_key 5 NULL 20 100.00 Using index +1 SIMPLE table2 NULL ALL PRIMARY NULL NULL NULL 20 100.00 NULL +1 SIMPLE table3 NULL ref col_int_key col_int_key 5 test.table2.pk 2 100.00 Using where; Using join buffer (Batched Key Access) +1 SIMPLE NULL eq_ref 5 test.table3.col_int_nokey 1 100.00 NULL +1 SIMPLE NULL eq_ref 5 test.table2.pk 1 100.00 NULL +4 MATERIALIZED subquery1_t3 NULL ALL col_varchar_key NULL NULL NULL 20 100.00 Using where +4 MATERIALIZED subquery1_t2 NULL eq_ref PRIMARY PRIMARY 4 test.subquery1_t3.col_int_key 1 10.00 Using where +4 MATERIALIZED subquery1_t1 NULL index PRIMARY col_int_key 5 NULL 20 100.00 Using where; Using index +3 MATERIALIZED subquery2_t3 NULL index PRIMARY,col_varchar_key col_varchar_key 7 NULL 20 100.00 Using where; Using index +3 MATERIALIZED subquery2_t2 NULL eq_ref PRIMARY,col_varchar_key PRIMARY 4 test.subquery2_t3.pk 1 7.14 Using where +3 MATERIALIZED subquery2_t1 NULL index col_int_key col_int_key 5 NULL 20 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `table2`.`col_varchar_nokey` AS `field1` from `test`.`t2` `table1` join `test`.`t1` `table2` straight_join `test`.`t2` `table3` semi join (`test`.`t1` `subquery1_t2` join `test`.`t1` `subquery1_t3` join `test`.`t2` `subquery1_t1`) semi join (`test`.`t3` `subquery2_t2` join `test`.`t1` `subquery2_t3` join `test`.`t2` `subquery2_t1`) where ((`subquery1_t2`.`pk` = `subquery1_t3`.`col_int_key`) and (`subquery1_t2`.`col_varchar_nokey` = `subquery1_t3`.`col_varchar_key`) and (`subquery2_t2`.`col_varchar_key` = `subquery2_t3`.`col_varchar_key`) and (`subquery2_t2`.`pk` = `subquery2_t3`.`pk`) and (`table3`.`col_int_key` = `table2`.`pk`) and (``.`subquery2_field1` = `table2`.`pk`) and (``.`subquery1_field1` = `table3`.`col_int_nokey`) and (`subquery1_t1`.`pk` > 1)) +SELECT * FROM v1; +field1 +v +v +v +v +v +v +v +v +v +v +v +v +v +v +v +v +v +v +v +v +DROP VIEW v1; +DROP TABLE t1,t2,t3; +# End of test for bug#13855925. +# +# Bug#13897959: Segfault in setup_semijoin_dups_elimination() +# +CREATE TABLE t1 ( +col_datetime_key DATETIME DEFAULT NULL, +KEY col_datetime_key (col_datetime_key) +) ENGINE=MyISAM; +INSERT INTO t1 VALUES +('2001-04-18 00:00:00'), ('2008-12-18 19:39:55'), +('2000-08-01 12:19:39'), ('2004-09-25 21:29:06'), +('2009-09-20 09:11:48'), ('2004-03-27 09:32:04'); +CREATE TABLE t2 ( +col_date_nokey date DEFAULT NULL, +col_time_key time DEFAULT NULL, +col_datetime_key datetime DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +KEY col_time_key (col_time_key), +KEY col_datetime_key (col_datetime_key), +KEY col_varchar_key(col_varchar_key) +) ENGINE=MyISAM; +INSERT INTO t2 VALUES ('1900-01-01',NULL,'2001-11-04 19:07:55','x','x'); +SELECT grandparent1.col_varchar_nokey +FROM t2 AS grandparent1 LEFT JOIN t1 USING (col_datetime_key) +WHERE grandparent1.col_varchar_nokey IN ( +SELECT col_varchar_nokey +FROM t2 AS parent1 +WHERE parent1.col_time_key > grandparent1.col_date_nokey +); +col_varchar_nokey +DROP TABLE t1, t2; +# End of test for bug#13897959. +# +# Bug#13898625 ASSERT `(REMAINING_TABLES_AFTER != 0) ...' IN +# BEST_EXTENSION_BY_LIMITED_SEARCH +# +CREATE TABLE t1 ( +pk int(11) NOT NULL, +col_int_nokey INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (26,6,NULL,'f','f'); +INSERT INTO t1 VALUES (29,6,8,'c','c'); +CREATE TABLE t2 ( +pk INT NOT NULL, +col_int_nokey INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +INSERT INTO t2 VALUES (1,2,4,'v','v'); +INSERT INTO t2 VALUES (2,150,62,'v','v'); +INSERT INTO t2 VALUES (5,5,0,'x','x'); +INSERT INTO t2 VALUES (6,3,7,'i','i'); +INSERT INTO t2 VALUES (7,1,7,'e','e'); +CREATE VIEW view_c AS SELECT * FROM t2; +PREPARE prep_stmt_7430 FROM 'SELECT SUM( alias1.col_varchar_key ) AS field1 +FROM t1 AS alias1 +RIGHT JOIN t2 AS alias2 +INNER JOIN t1 AS alias3 +ON (alias3.col_varchar_key = alias2.col_varchar_key ) +ON ( "v" ) IN ( +SELECT sq1_alias1.col_varchar_nokey AS sq1_field1 +FROM t1 AS sq1_alias1 +) +WHERE alias3.pk IN ( +SELECT sq2_alias1.col_int_key AS sq2_field1 +FROM ( view_c AS sq2_alias1, t1 AS sq2_alias2 ) +) +'; +EXECUTE prep_stmt_7430; +field1 +NULL +EXECUTE prep_stmt_7430; +field1 +NULL +EXPLAIN SELECT SUM( alias1.col_varchar_key ) AS field1 +FROM t1 AS alias1 +RIGHT JOIN t2 AS alias2 +INNER JOIN t1 AS alias3 +ON (alias3.col_varchar_key = alias2.col_varchar_key ) +ON ( "v" ) IN ( +SELECT sq1_alias1.col_varchar_nokey AS sq1_field1 +FROM t1 AS sq1_alias1 +) +WHERE alias3.pk IN ( +SELECT sq2_alias1.col_int_key AS sq2_field1 +FROM ( view_c AS sq2_alias1, t1 AS sq2_alias2 ) +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE alias3 NULL range PRIMARY,col_varchar_key col_varchar_key 7 NULL 2 50.00 Using index condition; Using where; Using MRR +1 SIMPLE alias2 NULL ref col_varchar_key col_varchar_key 7 test.alias3.col_varchar_key 2 100.00 Using index +1 SIMPLE alias1 NULL index NULL col_varchar_key 12 NULL 2 100.00 Using index +1 SIMPLE sq1_alias1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch(alias1) +3 MATERIALIZED sq2_alias2 NULL index NULL PRIMARY 4 NULL 2 100.00 Using index +3 MATERIALIZED t2 NULL index col_int_key col_int_key 5 NULL 5 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select sum(`test`.`alias1`.`col_varchar_key`) AS `field1` from `test`.`t2` `alias2` join `test`.`t1` `alias3` left join (`test`.`t1` `alias1` semi join (`test`.`t1` `sq1_alias1`)) on(((`test`.`sq1_alias1`.`col_varchar_nokey` = 'v'))) semi join (`test`.`t2` join `test`.`t1` `sq2_alias2`) where ((`test`.`alias2`.`col_varchar_key` = `test`.`alias3`.`col_varchar_key`) and (`test`.`alias3`.`pk` = ``.`sq2_field1`)) +PREPARE prep_stmt_7430 FROM 'SELECT SUM( alias1.col_varchar_key ) AS field1 +FROM t1 AS alias1 +RIGHT JOIN t2 AS alias2 +INNER JOIN t1 AS alias3 +ON (alias3.col_varchar_key = alias2.col_varchar_key ) +ON ( "v" ) IN ( +SELECT sq1_alias1.col_varchar_nokey AS sq1_field1 +FROM t1 AS sq1_alias1 +) +WHERE alias3.pk IN ( +SELECT sq2_alias1.col_int_key AS sq2_field1 +FROM ( view_c AS sq2_alias1 , t1 AS sq2_alias2 ) +WHERE sq2_alias1.col_varchar_nokey <> alias2.col_varchar_key +AND sq2_alias1.col_varchar_key < "l" + ) +'; +EXECUTE prep_stmt_7430; +field1 +NULL +EXECUTE prep_stmt_7430; +field1 +NULL +EXPLAIN SELECT SUM( alias1.col_varchar_key ) AS field1 +FROM t1 AS alias1 +RIGHT JOIN t2 AS alias2 +INNER JOIN t1 AS alias3 +ON (alias3.col_varchar_key = alias2.col_varchar_key ) +ON ( "v" ) IN ( +SELECT sq1_alias1.col_varchar_nokey AS sq1_field1 +FROM t1 AS sq1_alias1 +) +WHERE alias3.pk IN ( +SELECT sq2_alias1.col_int_key AS sq2_field1 +FROM ( view_c AS sq2_alias1 , t1 AS sq2_alias2 ) +WHERE sq2_alias1.col_varchar_nokey <> alias2.col_varchar_key +AND sq2_alias1.col_varchar_key < "l" + ) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE alias3 NULL ALL PRIMARY,col_varchar_key NULL NULL NULL 2 100.00 Using where; Start temporary +1 SIMPLE t2 NULL ref col_int_key,col_varchar_key col_int_key 5 test.alias3.pk 2 40.00 Using where; Using join buffer (Batched Key Access) +1 SIMPLE alias2 NULL ref col_varchar_key col_varchar_key 7 test.alias3.col_varchar_key 2 100.00 Using index +1 SIMPLE sq2_alias2 NULL index NULL PRIMARY 4 NULL 2 100.00 Using index +1 SIMPLE sq1_alias1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE alias1 NULL index NULL col_varchar_key 12 NULL 2 100.00 Using index; End temporary +Warnings: +Note 1276 Field or reference 'test.alias2.col_varchar_key' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select sum(`test`.`alias1`.`col_varchar_key`) AS `field1` from `test`.`t2` `alias2` join `test`.`t1` `alias3` left join (`test`.`t1` `alias1` semi join (`test`.`t1` `sq1_alias1`)) on(((`test`.`sq1_alias1`.`col_varchar_nokey` = 'v'))) semi join (`test`.`t2` join `test`.`t1` `sq2_alias2`) where ((`test`.`alias2`.`col_varchar_key` = `test`.`alias3`.`col_varchar_key`) and (`test`.`t2`.`col_int_key` = `test`.`alias3`.`pk`) and (`test`.`t2`.`col_varchar_nokey` <> `test`.`alias3`.`col_varchar_key`) and (`test`.`t2`.`col_varchar_key` < 'l')) +DROP TABLE t1,t2; +DROP VIEW view_c; +# +# Bug#13902463 SEGFAULT IN BITMAP<64U>::MERGE OR ADD_KEY_FIELD +# ON SECOND EXEC OF PREP STMT +# +CREATE TABLE t1 ( +pk INT, +col_int_nokey INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +KEY col_varchar_key (col_varchar_key) +); +CREATE VIEW view_b AS SELECT * FROM t1; +PREPARE prep_stmt_20421 FROM 'SELECT alias2.col_varchar_nokey AS field1 +FROM t1 AS alias1 +INNER JOIN t1 AS alias2 +ON (alias1.col_varchar_key = alias2.col_varchar_nokey +AND ( alias1.col_int_key ) IN ( +SELECT t1.col_int_nokey +FROM t1 +) +) +WHERE alias1.col_varchar_key IN ( +SELECT sq2_alias2.col_varchar_nokey AS sq2_field1 +FROM view_b AS sq2_alias1 +INNER JOIN t1 AS sq2_alias2 +ON (sq2_alias2.col_varchar_key = sq2_alias1.col_varchar_key ) +WHERE sq2_alias1.pk > alias2.pk +) +'; +EXECUTE prep_stmt_20421; +field1 +EXECUTE prep_stmt_20421; +field1 +EXPLAIN SELECT alias2.col_varchar_nokey AS field1 +FROM t1 AS alias1 +INNER JOIN t1 AS alias2 +ON (alias1.col_varchar_key = alias2.col_varchar_nokey +AND ( alias1.col_int_key ) IN ( +SELECT t1.col_int_nokey +FROM t1 +) +) +WHERE alias1.col_varchar_key IN ( +SELECT sq2_alias2.col_varchar_nokey AS sq2_field1 +FROM view_b AS sq2_alias1 +INNER JOIN t1 AS sq2_alias2 +ON (sq2_alias2.col_varchar_key = sq2_alias1.col_varchar_key ) +WHERE sq2_alias1.pk > alias2.pk +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.alias2.pk' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `field1` from `test`.`t1` `alias1` join `test`.`t1` `alias2` semi join (`test`.`t1`) semi join (`test`.`t1` join `test`.`t1` `sq2_alias2`) where ((`test`.`t1`.`pk` > NULL) and multiple equal(NULL, `test`.`sq2_alias2`.`col_varchar_nokey`, NULL) and multiple equal(`test`.`sq2_alias2`.`col_varchar_key`, `test`.`t1`.`col_varchar_key`) and multiple equal(NULL, `test`.`t1`.`col_int_nokey`)) +ALTER TABLE t1 DROP INDEX col_varchar_key; +PREPARE prep_stmt_20421 FROM 'SELECT alias2.col_varchar_nokey AS field1 +FROM t1 AS alias1 +INNER JOIN t1 AS alias2 +ON (alias1.col_varchar_key = alias2.col_varchar_nokey +AND ( alias1.col_int_key ) IN ( +SELECT t1.col_int_nokey +FROM t1 +) +) +WHERE alias1.col_varchar_key IN ( +SELECT sq2_alias2.col_varchar_nokey AS sq2_field1 +FROM view_b AS sq2_alias1 +INNER JOIN t1 AS sq2_alias2 +ON (sq2_alias2.col_varchar_key = sq2_alias1.col_varchar_key ) +WHERE sq2_alias1.pk > alias2.pk +) +'; +EXECUTE prep_stmt_20421; +field1 +EXECUTE prep_stmt_20421; +field1 +EXPLAIN SELECT alias2.col_varchar_nokey AS field1 +FROM t1 AS alias1 +INNER JOIN t1 AS alias2 +ON (alias1.col_varchar_key = alias2.col_varchar_nokey +AND ( alias1.col_int_key ) IN ( +SELECT t1.col_int_nokey +FROM t1 +) +) +WHERE alias1.col_varchar_key IN ( +SELECT sq2_alias2.col_varchar_nokey AS sq2_field1 +FROM view_b AS sq2_alias1 +INNER JOIN t1 AS sq2_alias2 +ON (sq2_alias2.col_varchar_key = sq2_alias1.col_varchar_key ) +WHERE sq2_alias1.pk > alias2.pk +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.alias2.pk' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `field1` from `test`.`t1` `alias1` join `test`.`t1` `alias2` semi join (`test`.`t1`) semi join (`test`.`t1` join `test`.`t1` `sq2_alias2`) where ((`test`.`t1`.`pk` > NULL) and multiple equal(NULL, `test`.`sq2_alias2`.`col_varchar_nokey`, NULL) and multiple equal(`test`.`sq2_alias2`.`col_varchar_key`, `test`.`t1`.`col_varchar_key`) and multiple equal(NULL, `test`.`t1`.`col_int_nokey`)) +DROP TABLE t1; +DROP VIEW view_b; +# +# Bug#13907277: Segfault in evaluate_null_complemented_join_record +# +CREATE TABLE t1 ( +pk INTEGER, +col_varchar_nokey VARCHAR(1), +col_varchar_key VARCHAR(1), +PRIMARY KEY (pk) +); +INSERT INTO t1 VALUES (1, 'x', 'x'); +CREATE TABLE t2 ( +pk INTEGER, +PRIMARY KEY (pk) +); +INSERT INTO t2 VALUES (1); +CREATE TABLE t3 ( +pk INTEGER, +col_int_nokey INTEGER, +col_int_key INTEGER, +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk) +); +INSERT INTO t3 VALUES (1, 6, 5, 'r'); +explain SELECT outer_t1.pk, outer_t2.pk +FROM t3 AS outer_t1 +RIGHT JOIN t2 AS outer_t2 +ON outer_t1.col_int_nokey IN +(SELECT inner_t1.col_int_nokey +FROM t3 AS inner_t1 +LEFT JOIN t1 AS inner_t2 +INNER JOIN t1 AS inner_t3 +ON inner_t3.pk = inner_t2.pk +ON inner_t3.col_varchar_nokey = inner_t2.col_varchar_key +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE outer_t2 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE outer_t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE inner_t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE inner_t2 NULL ALL PRIMARY NULL NULL NULL 1 100.00 NULL +1 SIMPLE inner_t3 NULL eq_ref PRIMARY PRIMARY 4 test.inner_t2.pk 1 100.00 Using where; FirstMatch(outer_t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`outer_t1`.`pk` AS `pk`,'1' AS `pk` from left join (`test`.`t3` `outer_t1` semi join (`test`.`t3` `inner_t1` left join (`test`.`t1` `inner_t2` join `test`.`t1` `inner_t3`) on(((`test`.`inner_t3`.`col_varchar_nokey` = `test`.`inner_t2`.`col_varchar_key`) and (`test`.`inner_t3`.`pk` = `test`.`inner_t2`.`pk`))))) on(((`test`.`inner_t1`.`col_int_nokey` = `test`.`outer_t1`.`col_int_nokey`))) where true +SELECT outer_t1.pk, outer_t2.pk +FROM t3 AS outer_t1 +RIGHT JOIN t2 AS outer_t2 +ON outer_t1.col_int_nokey IN +(SELECT inner_t1.col_int_nokey +FROM t3 AS inner_t1 +LEFT JOIN t1 AS inner_t2 +INNER JOIN t1 AS inner_t3 +ON inner_t3.pk = inner_t2.pk +ON inner_t3.col_varchar_nokey = inner_t2.col_varchar_key +); +pk pk +1 1 +DROP TABLE t1, t2, t3; +# End of test for bug#13907277. +# +# Bug#13955713: Assert 'JOIN->best_read < ...' on second execution +# +CREATE TABLE t1 ( +pk INTEGER, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1) +); +PREPARE stmt FROM " +SELECT MIN(alias2.col_varchar_key) AS field1 +FROM t1 AS alias1 + INNER JOIN (t1 AS alias2 + INNER JOIN t1 AS alias3 + ON 8 IN + (SELECT sq1_alias1.pk AS sq1_field2 + FROM t1 AS sq1_alias1 + WHERE 9 IN + (SELECT SUM(t1_sq1_alias1.pk) AS t1_sq1_field2 + FROM t1 AS t1_sq1_alias1 + ) + ) + ) + ON alias3.col_varchar_nokey = alias2.col_varchar_key +WHERE EXISTS + (SELECT sq2_alias1.pk AS sq2_field1 + FROM t1 AS sq2_alias1 + WHERE sq2_alias1.col_varchar_key < alias1.col_varchar_nokey + ) +"; +EXECUTE stmt; +field1 +NULL + +EXECUTE stmt; +field1 +NULL +DEALLOCATE PREPARE stmt; +DROP TABLE t1; +# End of test for bug#13955713. +# +# Bug#13956813: Segfault in memcpy from Join_cache::write_record_data() +# +CREATE TABLE t1 ( +pk INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1) +) charset latin1; +CREATE TABLE t2 ( +pk INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1) +) charset latin1; +INSERT INTO t2 VALUES +(10,'j','j'), (11,'z','z'), (12,'c','c'), (13,'a','a'), +(14,'q','q'), (15,'y','y'), (16,NULL,NULL), (17,'r','r'), +(18,'v','v'), (19,NULL,NULL), (20,'r','r'); +CREATE TABLE t3 ( +pk INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +KEY col_int_key (col_int_key) +) charset latin1; +INSERT INTO t3 VALUES +(15,NULL,'u'), (16,1,'m'), (17,9,NULL), (18,2,'o'), +(19,9,'w'), (20,2,'m'), (21,4,'q'), (22,0,NULL), +(23,4,'d'), (24,8,'g'), (25,NULL,'x'), (26,NULL,'f'), +(27,0,'p'), (28,NULL,'j'), (29,8,'c'); +CREATE VIEW view_inline_0 AS +SELECT t1.* +FROM t1 INNER JOIN t3 +ON t1.pk = t3.pk; +CREATE VIEW view_inline_1 AS +SELECT sq2_alias2.col_varchar_key AS sq2_field1, +sq2_alias1.col_varchar_key AS sq2_field2 +FROM t3 AS sq2_alias1 LEFT OUTER JOIN t3 AS sq2_alias2 +ON sq2_alias1.pk = sq2_alias2.col_int_key; +CREATE VIEW view_inline_2 AS +SELECT 'p', 'p' UNION SELECT 'k', 's'; +SET @optimizer_switch_saved= @@optimizer_switch; +SET @@optimizer_switch="derived_merge=off"; +explain SELECT SUM(alias1.col_varchar_nokey) AS field2 +FROM t2 AS alias2 +LEFT JOIN (SELECT * FROM view_inline_0) AS alias1 +ON alias2.col_varchar_key = alias1.col_varchar_key AND +(alias2.col_varchar_nokey, alias2.col_varchar_key) IN +(SELECT * FROM view_inline_1 +) +WHERE (alias1.col_varchar_key, alias1.col_varchar_nokey) IN +(SELECT * FROM view_inline_2 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL 2 100.00 NULL +1 PRIMARY alias2 NULL ALL NULL NULL NULL NULL 11 10.00 Using where +1 PRIMARY NULL ref 8 test.alias2.col_varchar_nokey,test.view_inline_2.p 3 100.00 Using index; FirstMatch(alias2) +1 PRIMARY NULL ref 8 test.view_inline_2.p,test.view_inline_2.Name_exp_p 2 100.00 NULL +7 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +8 UNION NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +NULL UNION RESULT NULL ALL NULL NULL NULL NULL NULL NULL Using temporary +6 DERIVED sq2_alias1 NULL ALL NULL NULL NULL NULL 15 100.00 NULL +6 DERIVED sq2_alias2 NULL ref col_int_key col_int_key 5 test.sq2_alias1.pk 2 100.00 Using join buffer (Batched Key Access) +2 DERIVED NULL ALL NULL NULL NULL NULL 15 100.00 NULL +5 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select sum(`alias1`.`col_varchar_nokey`) AS `field2` from `test`.`view_inline_2` join `test`.`t2` `alias2` join (/* select#2 */ select `test`.`view_inline_0`.`pk` AS `pk`,`test`.`view_inline_0`.`col_varchar_key` AS `col_varchar_key`,`test`.`view_inline_0`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`view_inline_0`) `alias1` semi join (`test`.`view_inline_1`) where ((`test`.`view_inline_1`.`sq2_field1` = `test`.`alias2`.`col_varchar_nokey`) and (`alias1`.`col_varchar_nokey` = `test`.`view_inline_2`.`Name_exp_p`) and (`test`.`alias2`.`col_varchar_key` = `test`.`view_inline_2`.`p`) and (`test`.`view_inline_1`.`sq2_field2` = `test`.`view_inline_2`.`p`) and (`alias1`.`col_varchar_key` = `test`.`view_inline_2`.`p`)) +SELECT SUM(alias1.col_varchar_nokey) AS field2 +FROM t2 AS alias2 +LEFT JOIN (SELECT * FROM view_inline_0) AS alias1 +ON alias2.col_varchar_key = alias1.col_varchar_key AND +(alias2.col_varchar_nokey, alias2.col_varchar_key) IN +(SELECT * FROM view_inline_1 +) +WHERE (alias1.col_varchar_key, alias1.col_varchar_nokey) IN +(SELECT * FROM view_inline_2 +); +field2 +NULL +SET @@optimizer_switch= @optimizer_switch_saved; +DROP VIEW view_inline_0, view_inline_1, view_inline_2; +DROP TABLE t1, t2, t3; +# End of test for bug#13956813. +# +# Bug#13974177: Assert !(tab->table->regginfo.not_exists_optimize... +# +CREATE TABLE t1 ( +pk INTEGER AUTO_INCREMENT, +col_int_nokey INTEGER, +col_int_key INTEGER, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk), +KEY (col_int_key), +KEY (col_varchar_key, col_int_key) +); +INSERT INTO t1(col_int_key, col_int_nokey, col_varchar_key, col_varchar_nokey) +VALUES +(0, 4, 'j', 'j'), (8, 6, 'v', 'v'), (1, 3, 'c', 'c'), (8, 5, 'm', 'm'), +(9, 3, 'd', 'd'), (24, 246, 'd', 'd'), (6, 2, 'y', 'y'), (1, 9, 't', 't'), +(6, 3, 'd', 'd'), (2, 8, 's', 's'), (4, 1, 'r', 'r'), (8, 8, 'm', 'm'), +(4, 8, 'b', 'b'), (4, 5, 'x', 'x'), (7, 7, 'g', 'g'), (4, 5, 'p', 'p'), +(1, 1, 'q', 'q'), (9, 6, 'w', 'w'), (4, 2, 'd', 'd'), (8, 9, 'e', 'e'); +CREATE TABLE t2 ( +pk INTEGER AUTO_INCREMENT, +col_int_nokey INTEGER NOT NULL, +col_time_key TIME NOT NULL, +col_time_nokey TIME NOT NULL, +PRIMARY KEY (pk), +KEY (col_time_key) +) ENGINE=InnoDB; +INSERT INTO t2 (col_int_nokey, col_time_key, col_time_nokey) VALUES +(7, '00:00:00', '00:00:00'), (0, '00:00:00', '00:00:00'), +(9, '06:35:17', '06:35:17'), (3, '18:07:14', '18:07:14'), +(4, '20:36:52', '20:36:52'), (2, '21:29:07', '21:29:07'), +(5, '23:45:57', '23:45:57'), (3, '22:54:57', '22:54:57'), +(1, '18:45:09', '18:45:09'), (3, '14:30:46', '14:30:46'), +(6, '19:23:43', '19:23:43'), (7, '03:39:30', '03:39:30'), +(5, '23:37:52', '23:37:52'), (1, '16:59:30', '16:59:30'), +(204, '22:21:15', '22:21:15'), (224, '12:24:37', '12:24:37'), +(9, '15:02:08', '15:02:08'), (5, '23:59:59', '23:59:59'), +(0, '08:23:30', '08:23:30'), (3, '08:32:22', '08:32:22'); +explain SELECT ot1.col_int_key AS x +FROM t1 AS ot2 +LEFT JOIN t1 AS ot1 +ON ot2.col_varchar_nokey > ot1.col_varchar_key +WHERE (ot1.col_int_nokey, ot1.pk) IN +(SELECT it1.pk AS x, +it1.col_int_nokey AS y +FROM t2 AS it2 +LEFT JOIN t2 AS it1 +ON it2.col_time_nokey = it1.col_time_key +) AND ot1.pk IS NULL +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`col_int_key` AS `x` from `test`.`t2` `it1` join `test`.`t1` `ot2` join `test`.`t1` `ot1` semi join (`test`.`t2` `it2`) where ((`test`.`ot1`.`pk` is null) and (`test`.`ot2`.`col_varchar_nokey` > `test`.`ot1`.`col_varchar_key`) and multiple equal(`test`.`ot1`.`col_int_nokey`, `test`.`it1`.`pk`) and multiple equal(`test`.`ot1`.`pk`, `test`.`it1`.`col_int_nokey`) and multiple equal(`test`.`it2`.`col_time_nokey`, `test`.`it1`.`col_time_key`)) +SELECT ot1.col_int_key AS x +FROM t1 AS ot2 +LEFT JOIN t1 AS ot1 +ON ot2.col_varchar_nokey > ot1.col_varchar_key +WHERE (ot1.col_int_nokey, ot1.pk) IN +(SELECT it1.pk AS x, +it1.col_int_nokey AS y +FROM t2 AS it2 +LEFT JOIN t2 AS it1 +ON it2.col_time_nokey = it1.col_time_key +) AND ot1.pk IS NULL +; +x +DROP TABLE t1, t2; +# End of test for bug#13974177. +# +# Bug#13971022: Assert 'keyparts > 0' failed in create_ref_for_key... +# +CREATE TABLE t1 ( +pk INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +PRIMARY KEY (pk), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +CREATE TABLE t2 ( +pk INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk) +) charset utf8mb4 ENGINE=InnoDB; +CREATE TABLE t3 ( +i INT +); +SET @optimizer_switch_saved= @@optimizer_switch; +SET @@optimizer_switch="derived_merge=off"; +explain SELECT table1.pk AS field1 +FROM ( SELECT subquery1_t1. * +FROM t2 AS subquery1_t1 +JOIN t2 AS subquery1_t2 +ON subquery1_t2.pk = subquery1_t1.pk) AS table1 +STRAIGHT_JOIN t2 AS table2 +ON table1.col_int_key IN (SELECT 7 FROM t3) +WHERE table1.col_varchar_nokey IN +(SELECT subquery3_t1.col_varchar_key AS subquery3_field1 +FROM t1 AS subquery3_t1 +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY subquery3_t1 NULL index col_varchar_key col_varchar_key 12 NULL 0 0.00 Using where; Using index; LooseScan +1 PRIMARY NULL ref 7 test.subquery3_t1.col_varchar_key 2 100.00 NULL +1 PRIMARY t3 NULL ALL NULL NULL NULL NULL 0 0.00 FirstMatch() +1 PRIMARY table2 NULL index NULL PRIMARY 4 NULL 1 100.00 Using index +2 DERIVED subquery1_t1 NULL ALL PRIMARY NULL NULL NULL 1 100.00 Using where +2 DERIVED subquery1_t2 NULL eq_ref PRIMARY PRIMARY 4 test.subquery1_t1.pk 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `table1`.`pk` AS `field1` from (/* select#2 */ select `test`.`subquery1_t1`.`pk` AS `pk`,`test`.`subquery1_t1`.`col_int_key` AS `col_int_key`,`test`.`subquery1_t1`.`col_varchar_key` AS `col_varchar_key`,`test`.`subquery1_t1`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t2` `subquery1_t1` join `test`.`t2` `subquery1_t2` where ((`test`.`subquery1_t1`.`col_int_key` = 7) and (`test`.`subquery1_t2`.`pk` = `test`.`subquery1_t1`.`pk`))) `table1` straight_join `test`.`t2` `table2` semi join (`test`.`t3`) semi join (`test`.`t1` `subquery3_t1`) where (`table1`.`col_varchar_nokey` = `test`.`subquery3_t1`.`col_varchar_key`) +SELECT table1.pk AS field1 +FROM ( SELECT subquery1_t1. * +FROM t2 AS subquery1_t1 +JOIN t2 AS subquery1_t2 +ON subquery1_t2.pk = subquery1_t1.pk) AS table1 +STRAIGHT_JOIN t2 AS table2 +ON table1.col_int_key IN (SELECT 7 FROM t3) +WHERE table1.col_varchar_nokey IN +(SELECT subquery3_t1.col_varchar_key AS subquery3_field1 +FROM t1 AS subquery3_t1 +) +; +field1 +SET @@optimizer_switch= @optimizer_switch_saved; +DROP TABLE t1, t2, t3; +# End of test for bug#13971022. +# +# Bug#13623473 "MISSING ROWS ON SELECT AND JOIN WITH +# TIME/DATETIME COMPARE" - Subquery part of test. +# +SET TIMESTAMP=UNIX_TIMESTAMP('2012-01-31 10:14:35'); +CREATE TABLE t1 ( +pk INT NOT NULL, +col_int_nokey INT, +col_int_key INT NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +) ENGINE=InnoDB; +INSERT INTO t1 VALUES (10,1,7), (11,7,0), (12,4,9), (13,7,3), +(14,0,4), (15,2,2), (16,9,5), (17,4,3), (18,0,1), (19,9,3), (20,1,6), +(21,3,7), (22,8,5), (23,8,1), (24,18,204), (25,84,224), (26,6,9), +(27,3,5), (28,6,0), (29,6,3); +CREATE TABLE t2 ( +col_int_nokey INT NOT NULL, +col_datetime_key DATETIME NOT NULL, +col_varchar_key VARCHAR(1) NOT NULL, +KEY col_datetime_key (col_datetime_key), +KEY col_varchar_key (col_varchar_key) +) ENGINE=InnoDB; +INSERT INTO t2 VALUES (1,'2001-11-04 19:07:55','k'); +CREATE TABLE t3 ( +col_time_key TIME, +KEY col_time_key (col_time_key) +) ENGINE=InnoDB; +INSERT INTO t3 VALUES ('21:22:34'), ('10:50:38'), ('00:21:38'), +('04:08:02'), ('16:25:11'), ('10:14:58'), ('19:47:59'), ('11:14:24'), +('00:00:00'), ('00:00:00'), ('15:57:25'), ('07:05:51'), ('19:22:21'), +('03:53:16'), ('09:16:38'), ('15:37:26'), ('00:00:00'), ('05:03:03'), +('02:59:24'), ('00:01:58'); +EXPLAIN SELECT outr.col_int_nokey +FROM t2 as outr +STRAIGHT_JOIN t3 AS outr2 +ON outr2.col_time_key > outr.col_datetime_key +WHERE outr.col_int_nokey IN ( +SELECT col_int_key +FROM t1 AS innr +WHERE innr.pk >= innr.col_int_nokey +) AND ( +outr.col_int_nokey <= 6 +OR +outr.col_varchar_key IS NULL +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE outr NULL ALL col_datetime_key NULL NULL NULL 1 100.00 Using where +2 SIMPLE innr NULL ref col_int_key col_int_key 4 test.outr.col_int_nokey 1 33.33 Using where; FirstMatch(outr); Using join buffer (Batched Key Access) +2 SIMPLE outr2 NULL index col_time_key col_time_key 4 NULL 20 33.33 Using where; Using index +Warnings: +Warning 1739 Cannot use range access on index 'col_time_key' due to type or collation conversion on field 'col_time_key' +Note 1003 /* select#1 */ select `test`.`outr`.`col_int_nokey` AS `col_int_nokey` from `test`.`t2` `outr` straight_join `test`.`t3` `outr2` semi join (`test`.`t1` `innr`) where ((`test`.`innr`.`col_int_key` = `test`.`outr`.`col_int_nokey`) and (`test`.`outr`.`col_int_nokey` <= 6) and (`test`.`innr`.`pk` >= `test`.`innr`.`col_int_nokey`) and (cast(`test`.`outr2`.`col_time_key` as datetime) > `test`.`outr`.`col_datetime_key`)) +SELECT outr.col_int_nokey +FROM t2 as outr +STRAIGHT_JOIN t3 AS outr2 +ON outr2.col_time_key > outr.col_datetime_key +WHERE outr.col_int_nokey IN ( +SELECT col_int_key +FROM t1 AS innr +WHERE innr.pk >= innr.col_int_nokey +) AND ( +outr.col_int_nokey <= 6 +OR +outr.col_varchar_key IS NULL +); +col_int_nokey +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +DROP TABLE t1,t2,t3; +SET TIMESTAMP = DEFAULT; +# End of test for bug#13623473. +# +# Bug#13980954: Missing data on left join + null value + where..in +# +CREATE TABLE t1 ( +ik INT, +vc varchar(1) +) charset utf8mb4; +INSERT INTO t1 VALUES (8, 'x'), (NULL, 'x'); +CREATE TABLE t2 ( +ik INT, +vc varchar(1) +) charset utf8mb4; +INSERT INTO t2 VALUES +(0, 'x'), (7, 'i'), (7, 'e'), (1, 'p'), (7, 's'), (1, 'j'); +explain format=json SELECT t2.vc, t2.ik AS t2_ik, t1.ik AS t1_ik +FROM t2 LEFT JOIN t1 ON t2.vc=t1.vc +WHERE t2.vc IN (SELECT vc FROM t2 AS t3); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "8.63" + }, + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 6, + "rows_produced_per_join": 6, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "0.60", + "prefix_cost": "1.11", + "data_read_per_join": "96" + }, + "used_columns": [ + "ik", + "vc" + ], + "attached_condition": "(`test`.`t2`.`vc` is not null)" + } + }, + { + "table": { + "table_name": "", + "access_type": "eq_ref", + "key": "", + "key_length": "7", + "ref": [ + "test.t2.vc" + ], + "rows_examined_per_scan": 1, + "materialized_from_subquery": { + "using_temporary_table": true, + "query_block": { + "table": { + "table_name": "t3", + "access_type": "ALL", + "rows_examined_per_scan": 6, + "rows_produced_per_join": 6, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "0.60", + "prefix_cost": "1.11", + "data_read_per_join": "96" + }, + "used_columns": [ + "vc" + ] + } + } + } + } + }, + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 12, + "filtered": "100.00", + "cost_info": { + "read_cost": "3.01", + "eval_cost": "1.20", + "prefix_cost": "8.63", + "data_read_per_join": "192" + }, + "used_columns": [ + "ik", + "vc" + ], + "attached_condition": "(is_not_null_compl(t1), (`test`.`t1`.`vc` = `test`.`t2`.`vc`), true)" + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`vc` AS `vc`,`test`.`t2`.`ik` AS `t2_ik`,`test`.`t1`.`ik` AS `t1_ik` from `test`.`t2` left join `test`.`t1` on((`test`.`t1`.`vc` = `test`.`t2`.`vc`)) semi join (`test`.`t2` `t3`) where (``.`vc` = `test`.`t2`.`vc`) +SELECT t2.vc, t2.ik AS t2_ik, t1.ik AS t1_ik +FROM t2 LEFT JOIN t1 ON t2.vc=t1.vc +WHERE t2.vc IN (SELECT vc FROM t2 AS t3); +vc t2_ik t1_ik +e 7 NULL +i 7 NULL +j 1 NULL +p 1 NULL +s 7 NULL +x 0 8 +x 0 NULL +DROP TABLE t1, t2; +# End of test for bug#13980954. +# +# Bug#14048292: Segfault in Item_field::result_type on 2nd execution +# of prep stmt with join of view +# +CREATE TABLE t1 ( +col_int INT +); +INSERT INTO t1 VALUES (0), (1); +CREATE VIEW view_t1 AS SELECT * FROM t1; +explain SELECT alias1.col_int +FROM t1 AS alias1 +LEFT JOIN view_t1 AS alias2 +ON alias1.col_int IN +(SELECT sq1_alias1.col_int +FROM t1 AS sq1_alias1 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE alias1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE NULL eq_ref 5 test.alias1.col_int 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED sq1_alias1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`alias1`.`col_int` AS `col_int` from `test`.`t1` `alias1` left join (`test`.`t1` semi join (`test`.`t1` `sq1_alias1`)) on(((``.`col_int` = `test`.`alias1`.`col_int`))) where true +PREPARE stmt FROM "SELECT alias1.col_int +FROM t1 AS alias1 +LEFT JOIN view_t1 AS alias2 +ON alias1.col_int IN +(SELECT sq1_alias1.col_int +FROM t1 AS sq1_alias1 +)"; +EXECUTE stmt; +col_int +0 +0 +1 +1 + +EXECUTE stmt; +col_int +0 +0 +1 +1 +DEALLOCATE PREPARE stmt; +DROP VIEW view_t1; +DROP TABLE t1; +# End of test for bug#14048292. +# +# Bug#14064201: Missing data on join of derived table + WHERE .. IN +# with two operands +# +CREATE TABLE t1 ( +col_varchar_nokey VARCHAR(1) +) charset utf8mb4; +INSERT INTO t1 VALUES +('v'), ('s'), ('l'), ('y'), ('c'), ('i'), ('h'), ('q'), ('a'), ('v'), +('u'), ('s'), ('y'), ('z'), ('h'), ('p'), ('e'), ('i'), ('y'), ('w'); +CREATE TABLE t2 ( +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +KEY col_varchar_key(col_varchar_key) +) charset utf8mb4; +INSERT INTO t2 VALUES +('j','j'), ('v','v'), ('c','c'), ('m','m'), ('d','d'), ('d','d'), ('y','y'); +SET @optimizer_switch_saved= @@optimizer_switch; +SET @@optimizer_switch="derived_merge=off"; +explain format=json SELECT * +FROM (SELECT * FROM t2) AS derived1 +LEFT JOIN t1 +USING (col_varchar_nokey) +WHERE (col_varchar_nokey, col_varchar_nokey) IN +(SELECT col_varchar_nokey, col_varchar_key +FROM t2 AS derived2 +); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "13.56" + }, + "nested_loop": [ + { + "table": { + "table_name": "", + "access_type": "ALL", + "attached_condition": "((``.`col_varchar_key` = ``.`col_varchar_nokey`) and (``.`col_varchar_nokey` is not null))", + "materialized_from_subquery": { + "using_temporary_table": true, + "query_block": { + "table": { + "table_name": "derived2", + "access_type": "ALL", + "possible_keys": [ + "col_varchar_key" + ], + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "0.70", + "prefix_cost": "1.21", + "data_read_per_join": "112" + }, + "used_columns": [ + "col_varchar_key", + "col_varchar_nokey" + ], + "attached_condition": "(`test`.`derived2`.`col_varchar_key` = `test`.`derived2`.`col_varchar_nokey`)" + } + } + } + } + }, + { + "table": { + "table_name": "derived1", + "access_type": "ref", + "possible_keys": [ + "" + ], + "key": "", + "used_key_parts": [ + "col_varchar_nokey" + ], + "key_length": "7", + "ref": [ + ".col_varchar_nokey" + ], + "rows_examined_per_scan": 2, + "rows_produced_per_join": 2, + "filtered": "100.00", + "cost_info": { + "read_cost": "3.50", + "eval_cost": "0.20", + "prefix_cost": "8.51", + "data_read_per_join": "32" + }, + "used_columns": [ + "col_varchar_key", + "col_varchar_nokey" + ], + "materialized_from_subquery": { + "using_temporary_table": true, + "dependent": false, + "cacheable": true, + "query_block": { + "select_id": 2, + "cost_info": { + "query_cost": "1.21" + }, + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "0.70", + "prefix_cost": "1.21", + "data_read_per_join": "112" + }, + "used_columns": [ + "col_varchar_key", + "col_varchar_nokey" + ] + } + } + } + } + }, + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 40, + "filtered": "100.00", + "cost_info": { + "read_cost": "1.05", + "eval_cost": "4.00", + "prefix_cost": "13.56", + "data_read_per_join": "320" + }, + "used_columns": [ + "col_varchar_nokey" + ], + "attached_condition": "(is_not_null_compl(t1), (`test`.`t1`.`col_varchar_nokey` = `derived1`.`col_varchar_nokey`), true)" + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select `derived1`.`col_varchar_nokey` AS `col_varchar_nokey`,`derived1`.`col_varchar_key` AS `col_varchar_key` from (/* select#2 */ select `test`.`t2`.`col_varchar_key` AS `col_varchar_key`,`test`.`t2`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t2`) `derived1` left join `test`.`t1` on(((`test`.`t1`.`col_varchar_nokey` = `derived1`.`col_varchar_nokey`) and (`test`.`derived2`.`col_varchar_nokey` = `test`.`derived2`.`col_varchar_key`))) semi join (`test`.`t2` `derived2`) where ((``.`col_varchar_key` = ``.`col_varchar_nokey`) and (`derived1`.`col_varchar_nokey` = ``.`col_varchar_nokey`) and (`test`.`derived2`.`col_varchar_key` = `test`.`derived2`.`col_varchar_nokey`)) +SELECT * +FROM (SELECT * FROM t2) AS derived1 +LEFT JOIN t1 +USING (col_varchar_nokey) +WHERE (col_varchar_nokey, col_varchar_nokey) IN +(SELECT col_varchar_nokey, col_varchar_key +FROM t2 AS derived2 +); +col_varchar_nokey col_varchar_key +c c +d d +d d +j j +m m +v v +v v +y y +y y +y y +SET @@optimizer_switch= @optimizer_switch_saved; +DROP TABLE t1, t2; +CREATE TABLE t1 ( +col_int_nokey int NOT NULL, +col_int_key int NOT NULL, +KEY col_int_key (col_int_key) +); +INSERT INTO t1 VALUES +(1,7), (7,0), (4,9), (7,3), (0,4), (2,2), (9,5), (4,3), (0,1), (9,3), +(1,6), (3,7), (8,5), (8,1), (18,204), (84,224), (6,9), (3,5), (6,0), (6,3); +CREATE TABLE t2 ( +col_int_nokey int NOT NULL, +col_int_key int NOT NULL, +KEY col_int_key (col_int_key) +); +INSERT INTO t2 VALUES +(4,0), (6,8), (3,1), (5,8), (3,9), (246,24), (2,6), (9,1), (3,6), (8,2), +(1,4), (8,8), (8,4), (5,4), (7,7), (5,4), (1,1), (6,9), (2,4), (9,8); +explain format=json SELECT grandparent1.* +FROM t1 AS grandparent1 +LEFT JOIN t1 USING (col_int_nokey) +WHERE (col_int_nokey, col_int_nokey) IN +(SELECT col_int_nokey, col_int_key +FROM t2 +); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "60.24" + }, + "nested_loop": [ + { + "table": { + "table_name": "grandparent1", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 20, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "2.00", + "prefix_cost": "2.51", + "data_read_per_join": "320" + }, + "used_columns": [ + "col_int_nokey", + "col_int_key" + ] + } + }, + { + "table": { + "table_name": "", + "access_type": "eq_ref", + "key": "", + "key_length": "8", + "ref": [ + "test.grandparent1.col_int_nokey", + "test.grandparent1.col_int_nokey" + ], + "rows_examined_per_scan": 1, + "materialized_from_subquery": { + "using_temporary_table": true, + "query_block": { + "table": { + "table_name": "t2", + "access_type": "ALL", + "possible_keys": [ + "col_int_key" + ], + "rows_examined_per_scan": 20, + "rows_produced_per_join": 20, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "2.00", + "prefix_cost": "2.51", + "data_read_per_join": "320" + }, + "used_columns": [ + "col_int_nokey", + "col_int_key" + ], + "attached_condition": "(`test`.`t2`.`col_int_key` = `test`.`t2`.`col_int_nokey`)" + } + } + } + } + }, + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 400, + "filtered": "100.00", + "cost_info": { + "read_cost": "10.22", + "eval_cost": "40.00", + "prefix_cost": "60.24", + "data_read_per_join": "6K" + }, + "used_columns": [ + "col_int_nokey" + ], + "attached_condition": "(is_not_null_compl(t1), (`test`.`t1`.`col_int_nokey` = `test`.`grandparent1`.`col_int_nokey`), true)" + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`grandparent1`.`col_int_nokey` AS `col_int_nokey`,`test`.`grandparent1`.`col_int_key` AS `col_int_key` from `test`.`t1` `grandparent1` left join `test`.`t1` on(((`test`.`t1`.`col_int_nokey` = `test`.`grandparent1`.`col_int_nokey`) and (`test`.`t2`.`col_int_nokey` = `test`.`t2`.`col_int_key`))) semi join (`test`.`t2`) where ((``.`col_int_nokey` = `test`.`grandparent1`.`col_int_nokey`) and (``.`col_int_key` = `test`.`grandparent1`.`col_int_nokey`) and (`test`.`t2`.`col_int_key` = `test`.`t2`.`col_int_nokey`)) +SELECT grandparent1.* +FROM t1 AS grandparent1 +LEFT JOIN t1 USING (col_int_nokey) +WHERE (col_int_nokey, col_int_nokey) IN +(SELECT col_int_nokey, col_int_key +FROM t2 +); +col_int_nokey col_int_key +1 6 +1 6 +1 7 +1 7 +7 0 +7 0 +7 3 +7 3 +8 1 +8 1 +8 5 +8 5 +DROP TABLE t1, t2; +CREATE TABLE t1 ( +pk int, +col_int_key int, +col_datetime_key datetime, +col_varchar_key varchar(1), +col_varchar_nokey varchar(1), +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_datetime_key (col_datetime_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4 engine=MyISAM; +INSERT INTO t1 VALUES +(10,7,'2004-06-06 04:22:12','v','v'), (11,0,'2005-11-13 01:12:31','s','s'), +(12,9,'2002-05-04 01:50:00','l','l'), (13,3,'2004-10-27 10:28:45','y','y'), +(14,4,'2006-07-22 05:24:23','c','c'), (15,2,'2002-05-16 21:34:03','i','i'), +(16,5,'2008-04-17 10:45:30','h','h'), (17,3,'2009-04-21 02:58:02','q','q'), +(18,1,'2008-01-11 11:01:51','a','a'), (19,3,'1900-01-01 00:00:00','v','v'), +(20,6,'2007-05-17 18:24:57','u','u'), (21,7,'2007-08-07 00:00:00','s','s'), +(22,5,'2001-08-28 00:00:00','y','y'), (23,1,'2004-04-16 00:27:28','z','z'), +(24,204,'2005-05-03 07:06:22','h','h'), (25,224,'2009-03-11 17:09:50','p','p'), +(26,9,'2007-12-08 01:54:28','e','e'), (27,5,'2009-07-28 18:19:54','i','i'), +(28,0,'2008-06-08 00:00:00','y','y'), (29,3,'2005-02-09 09:20:26','w','w'); +CREATE TABLE t2 ( +pk int, +col_int_key int, +col_datetime_key datetime, +col_varchar_key varchar(1), +col_varchar_nokey varchar(1), +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_datetime_key (col_datetime_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4 engine=MyISAM; +INSERT INTO t2 VALUES +(1,0,'2002-02-13 17:30:06','j','j'), (2,8,'2008-09-27 00:34:58','v','v'), +(3,1,'2007-05-28 00:00:00','c','c'), (4,8,'2009-07-25 09:21:20','m','m'), +(5,9,'2002-01-16 00:00:00','d','d'), (6,24,'2006-10-12 04:32:53','d','d'), +(7,6,'2001-02-15 03:08:38','y','y'), (8,1,'2004-10-02 20:31:15','t','t'), +(9,6,'2002-08-20 22:48:00','d','d'), (10,2,'1900-01-01 00:00:00','s','s'), +(11,4,'2005-08-15 00:00:00','r','r'), (12,8,'1900-01-01 00:00:00','m','m'), +(13,4,'2008-05-16 08:09:06','b','b'), (14,4,'2001-01-20 12:47:23','x','x'), +(15,7,'2008-07-02 00:00:00','g','g'), (16,4,'1900-01-01 00:00:00','p','p'), +(17,1,'2002-12-08 11:34:58','q','q'), (18,9,'1900-01-01 00:00:00','w','w'), +(19,4,'1900-01-01 00:00:00','d','d'), (20,8,'2002-08-25 20:35:06','e','e'); +SELECT alias1.col_datetime_key +FROM t2 AS alias1 +RIGHT JOIN t2 AS alias2 +JOIN t2 AS alias3 +ON alias3.pk = alias2.pk +ON alias3.col_varchar_nokey = alias2.col_varchar_key OR +alias2.col_varchar_nokey +WHERE (alias2.col_varchar_key, alias2.col_varchar_key) IN +(SELECT sq2_alias2.col_varchar_key, sq2_alias1.col_varchar_nokey +FROM t1 AS sq2_alias1, t1 AS sq2_alias2 +WHERE sq2_alias2.col_int_key < 2); +col_datetime_key +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +2001-01-20 12:47:23 +2001-01-20 12:47:23 +2001-02-15 03:08:38 +2001-02-15 03:08:38 +2002-01-16 00:00:00 +2002-01-16 00:00:00 +2002-02-13 17:30:06 +2002-02-13 17:30:06 +2002-08-20 22:48:00 +2002-08-20 22:48:00 +2002-08-25 20:35:06 +2002-08-25 20:35:06 +2002-12-08 11:34:58 +2002-12-08 11:34:58 +2004-10-02 20:31:15 +2004-10-02 20:31:15 +2005-08-15 00:00:00 +2005-08-15 00:00:00 +2006-10-12 04:32:53 +2006-10-12 04:32:53 +2007-05-28 00:00:00 +2007-05-28 00:00:00 +2008-05-16 08:09:06 +2008-05-16 08:09:06 +2008-07-02 00:00:00 +2008-07-02 00:00:00 +2008-09-27 00:34:58 +2008-09-27 00:34:58 +2009-07-25 09:21:20 +2009-07-25 09:21:20 +ALTER TABLE t1 DISABLE KEYS; +ALTER TABLE t2 DISABLE KEYS; +explain format=json SELECT alias1.col_datetime_key +FROM t2 AS alias1 +RIGHT JOIN t2 AS alias2 +JOIN t2 AS alias3 +ON alias3.pk = alias2.pk +ON alias3.col_varchar_nokey = alias2.col_varchar_key OR +alias2.col_varchar_nokey +WHERE (alias2.col_varchar_key, alias2.col_varchar_key) IN +(SELECT sq2_alias2.col_varchar_key, sq2_alias1.col_varchar_nokey +FROM t1 AS sq2_alias1, t1 AS sq2_alias2 +WHERE sq2_alias2.col_int_key < 2); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "62.53" + }, + "nested_loop": [ + { + "table": { + "table_name": "", + "access_type": "ALL", + "attached_condition": "(``.`col_varchar_nokey` = ``.`col_varchar_key`)", + "materialized_from_subquery": { + "using_temporary_table": true, + "query_block": { + "nested_loop": [ + { + "table": { + "table_name": "sq2_alias2", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 6, + "filtered": "33.33", + "cost_info": { + "read_cost": "1.86", + "eval_cost": "0.67", + "prefix_cost": "2.53", + "data_read_per_join": "213" + }, + "used_columns": [ + "col_int_key", + "col_varchar_key" + ], + "attached_condition": "(`test`.`sq2_alias2`.`col_int_key` < 2)" + } + }, + { + "table": { + "table_name": "sq2_alias1", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 13, + "filtered": "10.00", + "cost_info": { + "read_cost": "3.53", + "eval_cost": "1.33", + "prefix_cost": "19.39", + "data_read_per_join": "426" + }, + "used_columns": [ + "col_varchar_nokey" + ], + "attached_condition": "(`test`.`sq2_alias1`.`col_varchar_nokey` = `test`.`sq2_alias2`.`col_varchar_key`)" + } + } + ] + } + } + } + }, + { + "table": { + "table_name": "alias2", + "access_type": "ALL", + "possible_keys": [ + "PRIMARY" + ], + "rows_examined_per_scan": 20, + "rows_produced_per_join": 2, + "filtered": "10.00", + "cost_info": { + "read_cost": "7.05", + "eval_cost": "0.20", + "prefix_cost": "56.77", + "data_read_per_join": "64" + }, + "used_columns": [ + "pk", + "col_varchar_key", + "col_varchar_nokey" + ], + "attached_condition": "(`test`.`alias2`.`col_varchar_key` = ``.`col_varchar_key`)" + } + }, + { + "table": { + "table_name": "alias3", + "access_type": "eq_ref", + "possible_keys": [ + "PRIMARY" + ], + "key": "PRIMARY", + "used_key_parts": [ + "pk" + ], + "key_length": "4", + "ref": [ + "test.alias2.pk" + ], + "rows_examined_per_scan": 1, + "rows_produced_per_join": 2, + "filtered": "100.00", + "using_join_buffer": "Batched Key Access", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.20", + "prefix_cost": "57.47", + "data_read_per_join": "64" + }, + "used_columns": [ + "pk", + "col_varchar_nokey" + ] + } + }, + { + "table": { + "table_name": "alias1", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 40, + "filtered": "100.00", + "cost_info": { + "read_cost": "1.06", + "eval_cost": "4.00", + "prefix_cost": "62.53", + "data_read_per_join": "1K" + }, + "used_columns": [ + "col_datetime_key" + ], + "attached_condition": "(is_not_null_compl(alias1), ((`test`.`alias3`.`col_varchar_nokey` = `test`.`alias2`.`col_varchar_key`) or (0 <> `test`.`alias2`.`col_varchar_nokey`)), true)" + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`alias1`.`col_datetime_key` AS `col_datetime_key` from `test`.`t2` `alias2` join `test`.`t2` `alias3` left join `test`.`t2` `alias1` on((((`test`.`alias3`.`col_varchar_nokey` = `test`.`alias2`.`col_varchar_key`) and (`test`.`sq2_alias1`.`col_varchar_nokey` = `test`.`sq2_alias2`.`col_varchar_key`)) or (0 <> `test`.`alias2`.`col_varchar_nokey`))) semi join (`test`.`t1` `sq2_alias1` join `test`.`t1` `sq2_alias2`) where ((`test`.`alias3`.`pk` = `test`.`alias2`.`pk`) and (``.`col_varchar_nokey` = ``.`col_varchar_key`) and (`test`.`alias2`.`col_varchar_key` = ``.`col_varchar_key`) and (`test`.`sq2_alias1`.`col_varchar_nokey` = `test`.`sq2_alias2`.`col_varchar_key`) and (`test`.`sq2_alias2`.`col_int_key` < 2)) +SELECT alias1.col_datetime_key +FROM t2 AS alias1 +RIGHT JOIN t2 AS alias2 +JOIN t2 AS alias3 +ON alias3.pk = alias2.pk +ON alias3.col_varchar_nokey = alias2.col_varchar_key OR +alias2.col_varchar_nokey +WHERE (alias2.col_varchar_key, alias2.col_varchar_key) IN +(SELECT sq2_alias2.col_varchar_key, sq2_alias1.col_varchar_nokey +FROM t1 AS sq2_alias1, t1 AS sq2_alias2 +WHERE sq2_alias2.col_int_key < 2); +col_datetime_key +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +2001-01-20 12:47:23 +2001-01-20 12:47:23 +2001-02-15 03:08:38 +2001-02-15 03:08:38 +2002-01-16 00:00:00 +2002-01-16 00:00:00 +2002-02-13 17:30:06 +2002-02-13 17:30:06 +2002-08-20 22:48:00 +2002-08-20 22:48:00 +2002-08-25 20:35:06 +2002-08-25 20:35:06 +2002-12-08 11:34:58 +2002-12-08 11:34:58 +2004-10-02 20:31:15 +2004-10-02 20:31:15 +2005-08-15 00:00:00 +2005-08-15 00:00:00 +2006-10-12 04:32:53 +2006-10-12 04:32:53 +2007-05-28 00:00:00 +2007-05-28 00:00:00 +2008-05-16 08:09:06 +2008-05-16 08:09:06 +2008-07-02 00:00:00 +2008-07-02 00:00:00 +2008-09-27 00:34:58 +2008-09-27 00:34:58 +2009-07-25 09:21:20 +2009-07-25 09:21:20 +DROP TABLE t1, t2; +# End of test for bug#14064201. +# +# Bug#18223655:ASSERTION FAILED: (INT)IDX >= 0 +# && IDX < PARENT_JOIN->TABLES +# +CREATE TABLE b (d INT); +CREATE TABLE c (a INT, b INT,c INT,d BLOB NOT NULL); +SELECT(SELECT 1 +FROM b WHERE(SELECT 1 IN (SELECT 1 FROM b WHERE 1 NOT BETWEEN d AND 1) +FROM b) IN (SELECT d FROM c)) as cc FROM b; +cc +INSERT INTO b VALUE(1); +INSERT INTO c VALUES(1,2,3,'1'),(2,3,4,'1'),(3,4,5,'C'); +SELECT(SELECT d FROM b WHERE(SELECT d IN +(SELECT d FROM b WHERE 1 NOT BETWEEN d AND 1) FROM b) IN +(SELECT d FROM c)) as cc FROM c; +cc +1 +1 +1 +DROP TABLE b,c; +# +# Bug#18447874:WRONG RESULT COMING FROM SEMI-JOIN +# +CREATE TABLE b ( +d INT(11) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE c ( +d BLOB +) ; +CREATE TABLE d ( +b INT(11) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO b VALUES(1),(2),(4); +INSERT INTO c VALUES(1),(2),(3); +SELECT 1 FROM b WHERE (SELECT 1 FROM d ) IN (SELECT d FROM c) ; +1 +INSERT INTO d VALUES(2); +SELECT 1 FROM b WHERE (SELECT 1 FROM d ) IN (SELECT d FROM c) ; +1 +1 +1 +1 +DROP TABLE b,c,d; +# +# Bug#17292723:INCORRECT RESULT FOR (SELECT...) IN (SELECT...) STATEMENT +# +CREATE TABLE t1 ( +ID int(11) NOT NULL AUTO_INCREMENT, +id2 int(11) DEFAULT NULL, +id3 int(11) DEFAULT NULL, +id4 varchar(150) COLLATE utf8_spanish_ci NOT NULL, +id5 int(11) DEFAULT NULL, +PRIMARY KEY (ID), +KEY id2 (id2), +KEY id3 (id3), +KEY id5 (id5) +) ENGINE=InnoDB; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 3778 'utf8_spanish_ci' is a collation of the deprecated character set UTF8MB3. Please consider using UTF8MB4 with an appropriate collation instead. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES +(123,1,1,'1',NULL), +(124,1,1,'2',NULL), +(125,1,1,'4',NULL), +(126,1,1,'3',NULL), +(127,1,1,'6',NULL), +(128,1,1,'8',NULL); +CREATE TABLE t2 ( +id6 int(11) NOT NULL, +id7 int(11) NOT NULL, +PRIMARY KEY (id6,id7), +KEY id7 (id7) +) ENGINE=InnoDB; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (126,123),(130,123),(135,123); +SELECT ID +FROM t1 p0 +WHERE p0.id3=1 +AND ( (SELECT p1.id FROM t1 p1 WHERE p1.id=123) IN (SELECT p3.id FROM t2 +p2, t1 p3 WHERE p0.id=p2.id6 AND p2.id7=p3.id)); +ID +126 +DROP TABLE t1,t2; +set @@optimizer_switch=@old_opt_switch; +# End of 5.6 tests +# +# Bug#19336348 DEBUG CRASH AT SETUP_SEMIJOIN_DUPS_ELIMINATION IN SQL/SQL_SELECT.CC +# +CREATE TABLE t1 ( +col_varchar_nokey varchar(1) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t1 VALUES ('c'),(NULL),('x'); +CREATE TABLE t2 ( +pk int, +col_varchar_key varchar(1), +PRIMARY KEY (pk), +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t2 VALUES (10,'l'),(11,'p'); +ANALYZE TABLE t1,t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN SELECT 1 +FROM t1 AS outr +WHERE outr.col_varchar_nokey IN +( +SELECT innr.col_varchar_key +FROM t2 AS innr +WHERE innr.pk <= 7 +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE innr NULL index PRIMARY,col_varchar_key col_varchar_key 7 NULL 2 100.00 Using where; Using index; LooseScan +1 SIMPLE outr NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` `outr` semi join (`test`.`t2` `innr`) where ((`test`.`outr`.`col_varchar_nokey` = `test`.`innr`.`col_varchar_key`) and (`test`.`innr`.`pk` <= 7)) +SELECT 1 +FROM t1 AS outr +WHERE outr.col_varchar_nokey IN +( +SELECT innr.col_varchar_key +FROM t2 AS innr +WHERE innr.pk <= 7 +) +; +1 +DROP TABLE t1,t2; +# +# Bug#18174394 BLOBS: CRASH AFTER UNINITIALIZED VALUES IN ITEM_FIELD::STR_RESULT +# +CREATE TABLE t1(d BLOB, b BLOB); +INSERT INTO t1(d,b) VALUES ('aaaa',''),('bnbb',''); +SELECT 1 FROM t1 +WHERE (SELECT b FROM t1) IN (SELECT (d>=1) FROM t1); +ERROR 21000: Subquery returns more than 1 row +DROP TABLE t1; +# +# Bug#19779600: ASSERT FAILED IN REPLACE_SUBCONDITION WITH IN +# PREDICATE INSIDE IN PREDICATE +# +CREATE TABLE t(X INT) ENGINE=InnoDB; +INSERT INTO t VALUES (1); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +EXPLAIN SELECT 1 FROM t WHERE (1 IN (SELECT 1 FROM t)) IN (SELECT 1 FROM t); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 PRIMARY t NULL ALL NULL NULL NULL NULL 1 100.00 FirstMatch(t) +2 SUBQUERY t NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t` semi join (`test`.`t`) where true +SELECT 1 FROM t WHERE (1 IN (SELECT 1 FROM t)) IN (SELECT 1 FROM t); +1 +1 +DROP TABLE t; +# +# Bug#19465034 ASSERT ON SETUP_SEMIJOIN_DUPS_ELIMINATION IN SQL/SQL_SELECT.CC +# +CREATE TABLE t1 ( +pk INTEGER NOT NULL, +i1 INTEGER NOT NULL, +PRIMARY KEY (pk) +) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1,1); +CREATE TABLE t2 ( +pk INTEGER NOT NULL, +c1 VARCHAR(1) NOT NULL, +PRIMARY KEY (pk), +KEY c1_key (c1) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t2 VALUES (1,'j'),(2,'v'),(3,'c'); +CREATE TABLE t3 ( +pk INTEGER NOT NULL, +c1 VARCHAR(1) NOT NULL, +PRIMARY KEY (pk), +KEY c1_key (c1) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t3 VALUES (10,'v'),(11,'s'); +ANALYZE TABLE t1, t2, t3; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +EXPLAIN SELECT * +FROM t1 JOIN t2 ON t1.i1 >= t2.pk +WHERE t2.c1 IN ( +SELECT t3.c1 +FROM t3 +WHERE t3.pk < 3 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t3 NULL index PRIMARY,c1_key c1_key 6 NULL 2 100.00 Using where; Using index; LooseScan +2 SIMPLE t2 NULL ref PRIMARY,c1_key c1_key 6 test.t3.c1 1 33.33 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`i1` AS `i1`,`test`.`t2`.`pk` AS `pk`,`test`.`t2`.`c1` AS `c1` from `test`.`t1` join `test`.`t2` semi join (`test`.`t3`) where ((`test`.`t2`.`c1` = `test`.`t3`.`c1`) and (`test`.`t3`.`pk` < 3) and (`test`.`t1`.`i1` >= `test`.`t2`.`pk`)) +SELECT * +FROM t1 JOIN t2 ON t1.i1 >= t2.pk +WHERE t2.c1 IN ( +SELECT t3.c1 +FROM t3 +WHERE t3.pk < 3 +); +pk i1 pk c1 +DROP TABLE t1,t2,t3; +# +# Bug#19586047: CRASH IN ARG_COMPARATOR::SET_CMP_FUNC +# +CREATE TABLE t1(x INT) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT 1 FROM t1 WHERE EXISTS(SELECT 1) IN (SELECT 1 FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 1 100.00 FirstMatch(t1) +2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` semi join (`test`.`t1`) where true +SELECT 1 FROM t1 WHERE EXISTS(SELECT 1) IN (SELECT 1 FROM t1); +1 +1 +EXPLAIN SELECT 1 FROM t1 WHERE (SELECT 1, 2 FROM t1) IN (SELECT 1, 2 FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 1 100.00 FirstMatch(t1) +2 SUBQUERY t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` semi join (`test`.`t1`) where true +SELECT 1 FROM t1 WHERE (SELECT 1, 2 FROM t1) IN (SELECT 1, 2 FROM t1); +1 +1 +EXPLAIN SELECT 1 FROM t1 WHERE +(SELECT 1, 2 FROM t1 WHERE x = 2) IN (SELECT 1, 2 FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +2 SUBQUERY t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` semi join (`test`.`t1`) where false +SELECT 1 FROM t1 WHERE +(SELECT 1, 2 FROM t1 WHERE x = 2) IN (SELECT 1, 2 FROM t1); +1 +DROP TABLE t1; +# +#Bug#20119743 ASSERTIONQEP_TAB->USE_ORDER() IN ENUM_NESTED_LOOP_STATE +# EVALUATE_JOIN_RECORD +# +CREATE TABLE t1 ( +pk int(11) NOT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +PRIMARY KEY (pk) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (1,'x'); +CREATE TABLE t2 ( +col_date_key date DEFAULT NULL, +col_int_key int(11) DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +KEY col_int_key (col_int_key), +KEY col_date_key (col_date_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES ('2000-12-03', 8, 'x', 'x'),('2008-05-03', 7, 'd', 'd'), +('2005-12-06', 1, 'r', 'r'),('2000-04-10', 7, 'f', 'f'), +('2002-11-05', 9, 'y', 'y'),('2000-09-06', NULL, 'u', 'u'), +(NULL, 1, 'm', 'm'),('2007-06-14', 9, NULL, NULL), +('2007-11-17', 2, 'o', 'o'),('2009-02-23', 9, 'w', 'w'), +('2007-01-08', 2, 'm', 'm'), ('2008-06-10', 4, 'q', 'q'), +('2002-10-20', 0, NULL, NULL),('2008-09-12', 4, 'd', 'd'), +('2006-06-16', 8, 'g', 'g'),('2004-09-18', NULL, 'x', 'x'), +('1900-01-01', NULL, 'f', 'f'),('2005-09-13', 0, 'p', 'p'), +('2007-04-09', NULL, 'j', 'j'),('2000-09-20', 8, 'c', 'c'); +CREATE TABLE t3 ( +pk int(11) NOT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +PRIMARY KEY (pk) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t3 VALUES (1, 'c'),(2, 'c'),(3, 'q'),(4, 'g'),(5, 'e'),(6, 'l'), +(7, NULL),(8, 'v'),(9, 'c'),(10, 'u'),(11, 'x'),(12, 'x'),(13, 'x'),(14, 'l'), +(15, 'e'),(16, 's'),(17, 'k'),(18, 'm'),(19, 'x'),(20, 's'); +ANALYZE TABLE t1,t2,t3; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +EXPLAIN SELECT r1.col_date_key +FROM t2 AS r1 +WHERE r1.col_int_key NOT IN +(SELECT ir2.pk +FROM t2 AS ir1 STRAIGHT_JOIN t1 AS ir2 +ON ir2.col_varchar_nokey = ir1.col_varchar_key +WHERE ir2.col_varchar_nokey > r1.col_varchar_nokey +AND ir2.pk IN +(SELECT iir2.pk +FROM t2 AS iir1 RIGHT JOIN t3 AS iir2 +ON iir2.col_varchar_nokey = iir1.col_varchar_key)) +ORDER BY r1.col_date_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY r1 NULL ALL NULL NULL NULL NULL 20 100.00 Using where; Using filesort +2 DEPENDENT SUBQUERY NULL ALL NULL NULL NULL NULL NULL 100.00 Using where +2 DEPENDENT SUBQUERY ir1 NULL index col_varchar_key col_varchar_key 12 NULL 20 100.00 Using where; Using index +2 DEPENDENT SUBQUERY ir2 NULL eq_ref PRIMARY PRIMARY 4 func 1 100.00 Using where; Full scan on NULL key +3 MATERIALIZED iir2 NULL eq_ref PRIMARY PRIMARY 4 func 1 100.00 Full scan on NULL key +3 MATERIALIZED iir1 NULL ref col_varchar_key col_varchar_key 7 test.iir2.col_varchar_nokey 1 100.00 Using index +SELECT r1.col_date_key +FROM t2 AS r1 +WHERE r1.col_int_key NOT IN +(SELECT ir2.pk +FROM t2 AS ir1 STRAIGHT_JOIN t1 AS ir2 +ON ir2.col_varchar_nokey = ir1.col_varchar_key +WHERE ir2.col_varchar_nokey > r1.col_varchar_nokey +AND ir2.pk IN +(SELECT iir2.pk +FROM t2 AS iir1 RIGHT JOIN t3 AS iir2 +ON iir2.col_varchar_nokey = iir1.col_varchar_key)) +ORDER BY r1.col_date_key; +col_date_key +2000-04-10 +2000-09-20 +2000-12-03 +2002-10-20 +2002-11-05 +2004-09-18 +2005-09-13 +2006-06-16 +2007-01-08 +2007-06-14 +2007-11-17 +2008-05-03 +2008-06-10 +2008-09-12 +2009-02-23 +SELECT COUNT(r1.col_date_key) AS COUNT_NUM +FROM t2 AS r1 +WHERE r1.col_int_key NOT IN +(SELECT ir2.pk +FROM t2 AS ir1 STRAIGHT_JOIN t1 AS ir2 +ON ir2.col_varchar_nokey = ir1.col_varchar_key +WHERE ir2.col_varchar_nokey > r1.col_varchar_nokey +AND ir2.pk IN +(SELECT iir2.pk +FROM t2 AS iir1 RIGHT JOIN t3 AS iir2 +ON iir2.col_varchar_nokey = iir1.col_varchar_key +WHERE iir2.pk<3)); +COUNT_NUM +15 +DROP TABLE t1,t2,t3; +# +# Bug#20554585 ASSERT JOIN()->TABLES == 0... IN JOIN_TAB::GET_SJ_STRATEGY ON SUBQUERY + VAR +# +CREATE TABLE t1 ( +pk int NOT NULL, +PRIMARY KEY (pk) +); +CREATE TABLE t2 ( +pk int NOT NULL, +col_int_key int, +col_varchar_key varchar(1), +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key) +); +CREATE TABLE t3 ( +pk int NOT NULL, +col_int_key int, +col_varchar_key varchar(1), +col_varchar varchar(1), +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key) +); +INSERT INTO t3 VALUES (1,4,'c','g'),(20,1,'i','p'); +CREATE TABLE t4 ( +col_int int +); +CREATE TABLE t5 ( +col_varchar_key varchar(1), +pk int NOT NULL, +col_int int, +PRIMARY KEY (pk), +KEY col_varchar_key (col_varchar_key) +); +SELECT table1.col_varchar_key AS field1 +FROM (t3 AS table1 +INNER JOIN ( +SELECT SUBQUERY1_t1.* +FROM (t1 AS SUBQUERY1_t1 +RIGHT JOIN (t2 AS SUBQUERY1_t2 +INNER JOIN t3 AS SUBQUERY1_t3 +ON (SUBQUERY1_t3.col_varchar_key = SUBQUERY1_t2.col_varchar_key) +) ON (SUBQUERY1_t3.col_int_key = SUBQUERY1_t2.pk) +) +WHERE SUBQUERY1_t2.col_varchar_key >= ANY ( +SELECT CHILD_SUBQUERY1_t2.col_varchar AS CHILD_SUBQUERY1_field1 +FROM (t2 AS CHILD_SUBQUERY1_t1 +LEFT OUTER JOIN t3 AS CHILD_SUBQUERY1_t2 +ON (CHILD_SUBQUERY1_t2.col_int_key = CHILD_SUBQUERY1_t1.col_int_key) +) +WHERE CHILD_SUBQUERY1_t1.pk >= SUBQUERY1_t2.pk +) +) AS table2 +ON (table2.pk = table1.pk) +) +WHERE (EXISTS (( +SELECT DISTINCT SUBQUERY2_t2.col_int AS SUBQUERY2_field1 +FROM (t4 AS SUBQUERY2_t1 +LEFT OUTER JOIN t5 AS SUBQUERY2_t2 +ON (SUBQUERY2_t2.pk = SUBQUERY2_t1.col_int) +) +WHERE SUBQUERY2_t2.col_varchar_key != @var4 +))) +AND table1.col_int_key < (35 + 192) +ORDER BY field1 +; +field1 +DROP TABLE t1, t2, t3, t4, t5; +# +# Bug#18892055: MISSING DATA ON SELECT ... IN WITH JOINS AND INNODB +# ENGINE +# +CREATE TABLE t1 ( +col_int_key INT, +pk INT NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +) ENGINE = INNODB; +INSERT INTO t1 VALUES +( 0, 3 ), +( 0, 4 ), +( 3, 1 ), +( 900000000, 2 ), +( 1368719360, 5 ), +( 1922236416, 6 ), +( 8,7 ); +CREATE TABLE t2 ( +pk INT NOT NULL, +col_int INT, +PRIMARY KEY (pk) +) ENGINE = INNODB; +INSERT INTO t2 VALUES +( 1, 3 ), +( 2, 2 ), +( 3, 8 ), +( 4, 7 ); +CREATE TABLE t3 ( +col_int_key INT, +col_int INT, +KEY (col_int_key) +) ENGINE = INNODB; +INSERT INTO t3 VALUES +( 5, 1 ), +( -1, -1 ), +( 300000000, 1 ), +( 8, 1 ); +CREATE TABLE t4 ( col_int_key INT ) ENGINE = INNODB; +INSERT INTO t4 VALUES +(0), +(3), +(8), +(900000000), +(1368719360), +(1922236416); +ANALYZE TABLE t1, t2, t3, t4; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +test.t4 analyze status OK +explain SELECT * +FROM t4 +WHERE (col_int_key) IN ( +SELECT t1.col_int_key +FROM t1 LEFT JOIN ( t2 JOIN t3 ON t3.col_int_key = t2.col_int ) USING ( pk ) +WHERE t3.col_int IS NULL +) +ORDER BY col_int_key +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index col_int_key col_int_key 5 NULL 7 100.00 Using index; Using temporary; Using filesort; Start temporary +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.pk 1 100.00 NULL +1 SIMPLE t3 NULL ref col_int_key col_int_key 5 test.t2.col_int 1 25.00 Using where +1 SIMPLE t4 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`col_int_key` AS `col_int_key` from `test`.`t4` semi join (`test`.`t1` left join (`test`.`t2` join `test`.`t3`) on(((`test`.`t1`.`pk` = `test`.`t2`.`pk`) and (`test`.`t3`.`col_int_key` = `test`.`t2`.`col_int`)))) where ((`test`.`t4`.`col_int_key` = `test`.`t1`.`col_int_key`) and (`test`.`t3`.`col_int` is null)) order by `test`.`t4`.`col_int_key` +explain format=tree SELECT * +FROM t4 +WHERE (col_int_key) IN ( +SELECT t1.col_int_key +FROM t1 LEFT JOIN ( t2 JOIN t3 ON t3.col_int_key = t2.col_int ) USING ( pk ) +WHERE t3.col_int IS NULL +) +ORDER BY col_int_key +; +EXPLAIN +-> Sort: t4.col_int_key + -> Stream results (cost=8.04 rows=7) + -> Remove duplicate t4 rows using temporary table (weedout) (cost=8.04 rows=7) + -> Nested loop inner join (cost=8.04 rows=7) + -> Filter: (t3.col_int is null) (cost=3.40 rows=7) + -> Nested loop left join (cost=3.40 rows=7) + -> Index scan on t1 using col_int_key (cost=0.95 rows=7) + -> Nested loop inner join (cost=2.41 rows=1) + -> Single-row index lookup on t2 using PRIMARY (pk=t1.pk) (cost=0.26 rows=1) + -> Index lookup on t3 using col_int_key (col_int_key=t2.col_int) (cost=0.25 rows=1) + -> Filter: (t4.col_int_key = t1.col_int_key) (cost=0.54 rows=1) + -> Table scan on t4 (cost=0.54 rows=6) + +SELECT * +FROM t4 +WHERE (col_int_key) IN ( +SELECT t1.col_int_key +FROM t1 LEFT JOIN ( t2 JOIN t3 ON t3.col_int_key = t2.col_int ) USING ( pk ) +WHERE t3.col_int IS NULL +) +ORDER BY col_int_key +; +col_int_key +0 +3 +8 +900000000 +1368719360 +1922236416 +DROP TABLE t1, t2, t3, t4; +# +# Bug#20835095 CRASH AT CREATE_REF_FOR_KEY IN SQL/SQL_SELECT.CC +# +CREATE TABLE t1 ( +pk INTEGER, +var_10_latin1 VARCHAR(10) CHARACTER SET latin1, +var_255_utf8 VARCHAR(255) CHARACTER SET utf8, +var_255_latin1 VARCHAR(255) CHARACTER SET latin1, +var_10_utf8 VARCHAR(10) CHARACTER SET utf8, +PRIMARY KEY (pk) +); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +CREATE VIEW v1 AS SELECT * FROM t1; +INSERT INTO t1 VALUES +(1,'FROCJ','korrhrspki','UAYVL','BPZIS'), +(2,'him','a','CHYKN','OZZQT'), +(3,'WBITK','ULWBF','have','rhrh'), +(4,'or','right','up','it'), +(5,'GGDCP','x','who','as'), +(6,'j','i','e','w'); +CREATE TABLE tv +SELECT var_255_utf8 AS field1 +FROM t1; +EXPLAIN SELECT * FROM tv +WHERE field1 IN ( +SELECT tv1.var_255_utf8 +FROM v1 AS tv1 LEFT JOIN v1 AS tv2 ON tv1.var_10_latin1=tv2.var_10_utf8); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE tv NULL ALL NULL NULL NULL NULL 6 100.00 Using where +1 SIMPLE NULL eq_ref 768 test.tv.field1 1 100.00 NULL +2 MATERIALIZED t1 NULL ALL NULL NULL NULL NULL 6 100.00 NULL +2 MATERIALIZED t1 NULL ALL NULL NULL NULL NULL 6 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tv`.`field1` AS `field1` from `test`.`tv` semi join (`test`.`t1` left join (`test`.`t1`) on((`test`.`t1`.`var_10_latin1` = `test`.`t1`.`var_10_utf8`))) where (``.`var_255_utf8` = `test`.`tv`.`field1`) +SELECT * FROM tv +WHERE field1 IN ( +SELECT tv1.var_255_utf8 +FROM v1 AS tv1 LEFT JOIN v1 AS tv2 ON tv1.var_10_latin1=tv2.var_10_utf8); +field1 +korrhrspki +a +ULWBF +right +x +i +DROP VIEW v1; +DROP TABLE t1, tv; +# 17832047 Crash in calculate_materialization_costs +CREATE TABLE t1(a INTEGER PRIMARY KEY); +INSERT INTO t1 VALUES (0),(1),(2); +SELECT 1 FROM t1 +WHERE 1 IN +(SELECT 1 BETWEEN (LENGTH(a) IN (SELECT 1 FROM t1)) AND 1 +FROM t1 +); +1 +1 +1 +1 +DROP TABLE t1; +# 17845989 Assertion failed: !(used_tables() & ... +CREATE TABLE a(b INTEGER) engine=innodb; +CREATE TABLE c(a INTEGER) engine=innodb; +SELECT 1 +FROM a +WHERE 1 IN (SELECT (a.b IS NULL) IN (SELECT 1 FROM c) FROM c) +; +1 +DROP TABLE a, c; +# +# Bug#18194196: OPTIMIZER EXECUTES STATEMENT INPERFORMANT +# +CREATE TABLE t1 (uid INTEGER, fid INTEGER, INDEX(uid)); +INSERT INTO t1 VALUES +(1,1), (1,2), (1,3), (1,4), +(2,5), (2,6), (2,7), (2,8), +(3,1), (3,2), (3,9); +CREATE TABLE t2 (uid INT PRIMARY KEY, name VARCHAR(128), INDEX(name)); +INSERT INTO t2 VALUES +(1, "A"), (2, "B"), (3, "C"), (4, "D"), (5, "E"), +(6, "F"), (7, "G"), (8, "H"), (9, "I"); +CREATE TABLE t3 (uid INT, fid INT, INDEX(uid)); +INSERT INTO t3 VALUES +(1,1), (1,2), (1,3),(1,4), +(2,5), (2,6), (2,7), (2,8), +(3,1), (3,2), (3,9); +CREATE TABLE t4 (uid INT PRIMARY KEY, name VARCHAR(128), INDEX(name)); +INSERT INTO t4 VALUES +(1, "A"), (2, "B"), (3, "C"), (4, "D"), (5, "E"), +(6, "F"), (7, "G"), (8, "H"), (9, "I"); +ANALYZE TABLE t1,t2,t3,t4; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +test.t4 analyze status OK +EXPLAIN SELECT name FROM t2, t1 +WHERE t1.uid IN (SELECT t4.uid FROM t4, t3 WHERE t3.uid=1 AND t4.uid=t3.fid) +AND t2.uid=t1.fid; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ref uid uid 5 const 4 100.00 Using where; Start temporary +1 SIMPLE t4 NULL eq_ref PRIMARY PRIMARY 4 test.t3.fid 1 100.00 Using index +1 SIMPLE t1 NULL ref uid uid 5 test.t3.fid 4 100.00 Using where; Using join buffer (Batched Key Access) +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.fid 1 100.00 End temporary; Using join buffer (Batched Key Access) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`name` AS `name` from `test`.`t4` join `test`.`t2` join `test`.`t1` semi join (`test`.`t3`) where ((`test`.`t4`.`uid` = `test`.`t3`.`fid`) and (`test`.`t1`.`uid` = `test`.`t3`.`fid`) and (`test`.`t3`.`uid` = 1) and (`test`.`t2`.`uid` = `test`.`t1`.`fid`)) +FLUSH STATUS; +SELECT name FROM t2, t1 +WHERE t1.uid IN (SELECT t4.uid FROM t4, t3 WHERE t3.uid=1 AND t4.uid=t3.fid) +AND t2.uid=t1.fid; +name +A +A +B +B +C +D +E +F +G +H +I +SHOW STATUS LIKE '%handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 20 +Handler_read_last 0 +Handler_read_next 26 +Handler_read_prev 0 +Handler_read_rnd 22 +Handler_read_rnd_next 0 +DROP TABLE t1,t2,t3,t4; +# End of test for Bug#18194196 +# +# Bug#21184091 ASSERT `READ_ROWS >= 0.0' AT +# COST_MODEL_SERVER::TMPTABLE_READWRITE_COST() +# +CREATE TABLE t1 ( +pk INTEGER, +col_varchar varchar(1), +col_int INTEGER, +PRIMARY KEY (pk) +) ENGINE=MyISAM; +CREATE TABLE t2 ( +col_int INTEGER, +col_varchar varchar(1) +) ENGINE=MyISAM; +INSERT INTO t2 VALUES (7,'x'); +INSERT INTO t2 VALUES (4,'z'); +SELECT t2.col_varchar +FROM t2 STRAIGHT_JOIN t1 ON t2.col_varchar = t1.col_varchar +JOIN t2 AS table3 ON t1.pk = table3.col_int +WHERE t1.pk IN (SELECT col_int FROM t1); +col_varchar +DROP TABLE t1,t2; +# End of test for Bug#21184091 +# Bug#21139722: Assertion failed: !(used_tables() & ((table_map) 1) ... +CREATE TABLE t1(a INTEGER) engine=innodb; +CREATE TABLE t2(b INTEGER) engine=innodb; +explain SELECT 1 +FROM (SELECT 1 IN (SELECT 1 +FROM t1 +WHERE (SELECT 1 FROM t2 HAVING b) NOT IN (SELECT 1 FROM t2) +) +FROM t2 +) AS z; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DERIVED t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +3 DEPENDENT SUBQUERY t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +5 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +4 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1276 Field or reference 'b' of SELECT #4 was resolved in SELECT #2 +Note 1003 /* select#1 */ select 1 AS `1` from (/* select#2 */ select (1,(/* select#3 */ select 1 from `test`.`t1` where ((/* select#4 */ select 1 from `test`.`t2` having (0 <> `test`.`t2`.`b`)),(/* select#5 */ select 1 from `test`.`t2` where (outer_field_is_not_null, (((/* select#4 */ select 1 from `test`.`t2` having (0 <> `test`.`t2`.`b`))) = 1), true)) is false))) AS `1 IN (SELECT 1 +FROM t1 +WHERE (SELECT 1 FROM t2 HAVING b) NOT IN (SELECT 1 FROM t2) +)` from `test`.`t2`) `z` +SELECT 1 +FROM (SELECT 1 IN (SELECT 1 +FROM t1 +WHERE (SELECT 1 FROM t2 HAVING b) NOT IN (SELECT 1 FROM t2) +) +FROM t2 +) AS z; +1 +DROP TABLE t1, t2; +CREATE TABLE t1(a INTEGER) engine=innodb; +explain SELECT (SELECT a FROM t1 AS t2 +WHERE a IN (SELECT t1.a+t2.a FROM t1 AS t3)) +FROM t1 AS t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 DEPENDENT SUBQUERY t3 NULL ALL NULL NULL NULL NULL 1 100.00 FirstMatch(t2) +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #3 was resolved in SELECT #1 +Note 1276 Field or reference 'test.t2.a' of SELECT #3 was resolved in SELECT #2 +Note 1003 /* select#1 */ select (/* select#2 */ select `test`.`t2`.`a` from `test`.`t1` `t2` semi join (`test`.`t1` `t3`) where (`test`.`t2`.`a` = (`test`.`t1`.`a` + `test`.`t2`.`a`))) AS `(SELECT a FROM t1 AS t2 +WHERE a IN (SELECT t1.a+t2.a FROM t1 AS t3))` from `test`.`t1` +SELECT (SELECT a FROM t1 AS t2 +WHERE a IN (SELECT t1.a+t2.a FROM t1 AS t3)) +FROM t1 AS t1; +(SELECT a FROM t1 AS t2 +WHERE a IN (SELECT t1.a+t2.a FROM t1 AS t3)) +DROP TABLE t1; +# End of test for Bug#21139722 +SET DEFAULT_STORAGE_ENGINE=INNODB; +# +# Bug#21139402 ASSERTION FAILED: LENGTH > 0 && KEYPARTS != 0, CRASH IN JOIN::OPTIMIZE_KEYUSE +# +CREATE TABLE t1 (a INT, b INT, PRIMARY KEY(a)); +CREATE TABLE t2 (c INT PRIMARY KEY); +EXPLAIN SELECT 1 FROM t1 +WHERE 1 IN +(SELECT (c IS NULL) IN (SELECT a FROM t1 WHERE b) FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +3 SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` semi join (`test`.`t2`) where false +SELECT 1 FROM t1 +WHERE 1 IN +(SELECT (c IS NULL) IN (SELECT a FROM t1 WHERE b) FROM t2); +1 +DROP TABLE t1,t2; +# +# Bug#21619634 ACCESS OF DEALLOCATED ITEM_OUTER_REF CAUSES CRASH: PREPARED STMT +# +create table cc (i int) engine="innodb"; +insert into cc values (1); +select (select count(i) from cc as cc_alias +where (cc.i in (select cc_alias.i from cc))) +from cc group by i; +(select count(i) from cc as cc_alias +where (cc.i in (select cc_alias.i from cc))) +1 +prepare stmt from +"select (select count(i) from cc as cc_alias + where (cc.i in (select cc_alias.i from cc))) + from cc group by i"; +execute stmt; +(select count(i) from cc as cc_alias + where (cc.i in (select cc_alias.i from cc))) +1 +execute stmt; +(select count(i) from cc as cc_alias + where (cc.i in (select cc_alias.i from cc))) +1 +drop table cc; +# +# Bug #22305361: QUERY WITH MATERIALIZED TABLE RETURNS INCORRECT +# RESULTS IN 5.6 +# +CREATE TABLE t(a INT,b INT); +INSERT INTO t VALUES (1,0),(1,0),(1,0),(1,0),(1,1); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +EXPLAIN SELECT * +FROM t AS t1 +WHERE t1.a IN (SELECT t2.a +FROM t AS t2 +WHERE CONCAT(t2.a,'') NOT IN (SELECT t3.a +FROM t AS t3 +WHERE t3.b=1)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 5 100.00 Using where +1 PRIMARY NULL eq_ref 5 test.t1.a 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 5 100.00 Using where +3 SUBQUERY t3 NULL ALL NULL NULL NULL NULL 5 20.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t` `t1` semi join (`test`.`t` `t2`) where ((``.`a` = `test`.`t1`.`a`) and (concat(`test`.`t2`.`a`,''),concat(`test`.`t2`.`a`,'') in ( (/* select#3 */ select `test`.`t3`.`a` from `test`.`t` `t3` where (`test`.`t3`.`b` = 1) having true ), (concat(`test`.`t2`.`a`,'') in on where ((concat(`test`.`t2`.`a`,'') = ``.`a`)))) is false)) +SELECT * +FROM t AS t1 +WHERE t1.a IN (SELECT t2.a +FROM t AS t2 +WHERE CONCAT(t2.a,'') NOT IN (SELECT t3.a +FROM t AS t3 +WHERE t3.b=1)); +a b +DROP TABLE t; +# +# Bug#24287772 SUBQUERY RETURNS EMPTY LIST WHILE IDENTICAL QUERY +# WITH JOIN RETURNS RESULT +# +CREATE TABLE t SELECT 4096 c; +SELECT c FROM t WHERE 1 IN +(SELECT t.c = page_size FROM information_schema.innodb_cmpmem); +c +4096 +DROP TABLE t; +# +# Bug #29132639: WL#12470: SIG 6 IN CONNECTJOINS|SQL/SQL_EXECUTOR.C +# +CREATE TABLE t1 ( f1 TIME, f2 VARCHAR(1) ); +INSERT INTO t1 VALUES ('08:35:24', 'X'), ('14:51:13', 'S'), ('11:22:33', 'Q'); +CREATE TABLE t2 ( pk INTEGER ); +INSERT INTO t2 VALUES (1), (2); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN FORMAT=tree SELECT * FROM t1 WHERE EXISTS ( SELECT alias1.f2 FROM t2 LEFT JOIN t1 ON 1 LEFT JOIN t1 AS alias1 ON 1 ); +EXPLAIN +-> Remove duplicate t1 rows using temporary table (weedout) (cost=14.75 rows=54) + -> Nested loop left join (cost=14.75 rows=54) + -> Nested loop left join (cost=4.85 rows=18) + -> Nested loop inner join (cost=1.55 rows=6) + -> Table scan on t2 (cost=0.45 rows=2) + -> Table scan on t1 (cost=0.40 rows=3) + -> Table scan on t1 (cost=0.30 rows=3) + -> Table scan on alias1 (cost=4.80 rows=3) + +SELECT * FROM t1 WHERE EXISTS ( SELECT alias1.f2 FROM t2 LEFT JOIN t1 ON 1 LEFT JOIN t1 AS alias1 ON 1 ); +f1 f2 +08:35:24 X +11:22:33 Q +14:51:13 S +DROP TABLE t1, t2; +set optimizer_switch=default; +set optimizer_switch=default; diff --git a/mysql-test/r/subquery_sj_dupsweed.result-pq b/mysql-test/r/subquery_sj_dupsweed.result-pq new file mode 100644 index 000000000000..cf20eb0d215f --- /dev/null +++ b/mysql-test/r/subquery_sj_dupsweed.result-pq @@ -0,0 +1,12919 @@ +set @old_opt_switch=@@optimizer_switch; +set optimizer_switch='subquery_materialization_cost_based=off'; +drop table if exists t0, t1, t2, t10, t11, t12; +create table t1 (a int not null, b int, primary key (a)); +create table t2 (a int not null, primary key (a)); +create table t3 (a int not null, b int, primary key (a)); +insert into t1 values (1,10), (2,20), (3,30), (4,40); +insert into t2 values (2), (3), (4), (5); +insert into t3 values (10,3), (20,4), (30,5); +select * from t2 where t2.a in (select a from t1); +a +2 +3 +4 +explain select * from t2 where t2.a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index PRIMARY PRIMARY 4 NULL 4 100.00 Using index +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t1` join `test`.`t2` where (`test`.`t1`.`a` = `test`.`t2`.`a`) +select * from t2 where t2.a in (select a from t1 where t1.b <> 30); +a +2 +4 +explain select * from t2 where t2.a in (select a from t1 where t1.b <> 30); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL PRIMARY NULL NULL NULL 4 75.00 Using where +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`a` = `test`.`t1`.`a`) and (`test`.`t1`.`b` <> 30)) +select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a); +a +2 +3 +explain select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL index PRIMARY PRIMARY 4 NULL 3 100.00 Using index +1 SIMPLE t1 NULL ALL PRIMARY NULL NULL NULL 4 25.00 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t1` join `test`.`t3` join `test`.`t2` where ((`test`.`t2`.`a` = `test`.`t1`.`a`) and (`test`.`t1`.`b` = `test`.`t3`.`a`)) +drop table t1, t2, t3; +create table t1 (a int, b int, index a (a,b)); +create table t2 (a int, index a (a)); +create table t3 (a int, b int, index a (a)); +insert into t1 values (1,10), (2,20), (3,30), (4,40); +create table t0(a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +insert into t1 +select rand()*100000+200,rand()*100000 from t0 A, t0 B, t0 C, t0 D; +insert into t2 values (2), (3), (4), (5); +insert into t3 values (10,3), (20,4), (30,5); +select * from t2 where t2.a in (select a from t1); +a +2 +3 +4 +explain select * from t2 where t2.a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index a a 5 NULL 4 100.00 Using where; Using index +1 SIMPLE t1 NULL ref a a 5 test.t2.a 101 100.00 Using index; Start temporary; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1`) where (`test`.`t1`.`a` = `test`.`t2`.`a`) +select * from t2 where t2.a in (select a from t1 where t1.b <> 30); +a +2 +4 +explain select * from t2 where t2.a in (select a from t1 where t1.b <> 30); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index a a 5 NULL 4 100.00 Using where; Using index +1 SIMPLE t1 NULL ref a a 5 test.t2.a 101 90.00 Using where; Using index; Start temporary; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1`) where ((`test`.`t1`.`a` = `test`.`t2`.`a`) and (`test`.`t1`.`b` <> 30)) +select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a); +a +2 +3 +explain select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index a a 5 NULL 4 100.00 Using where; Using index; Start temporary +1 SIMPLE t1 NULL ref a a 5 test.t2.a 101 100.00 Using index +1 SIMPLE t3 NULL index a a 5 NULL 3 33.33 Using where; Using index; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1` join `test`.`t3`) where ((`test`.`t1`.`a` = `test`.`t2`.`a`) and (`test`.`t3`.`a` = `test`.`t1`.`b`)) +insert into t1 values (3,31); +select * from t2 where t2.a in (select a from t1 where t1.b <> 30); +a +2 +3 +4 +select * from t2 where t2.a in (select a from t1 where t1.b <> 30 and t1.b <> 31); +a +2 +4 +explain select * from t2 where t2.a in (select a from t1 where t1.b <> 30); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index a a 5 NULL 4 100.00 Using where; Using index +1 SIMPLE t1 NULL ref a a 5 test.t2.a 101 90.00 Using where; Using index; Start temporary; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1`) where ((`test`.`t1`.`a` = `test`.`t2`.`a`) and (`test`.`t1`.`b` <> 30)) +drop table t0, t1, t2, t3; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1(a int, b int); +insert into t1 values (0,0),(1,1),(2,2); +create table t2 as select * from t1; +create table t11(a int, b int); +create table t10 (pk int, a int, primary key(pk)); +insert into t10 select a,a from t0; +create table t12 like t10; +insert into t12 select * from t10; +Flattened because of dependency, t10=func(t1) +explain select * from t1 where a in (select pk from t10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t1` where (`test`.`t10`.`pk` = `test`.`t1`.`a`) +select * from t1 where a in (select pk from t10); +a b +0 0 +1 1 +2 2 +A confluent case of dependency +explain select * from t1 where a in (select a from t10 where pk=12); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t1` where (multiple equal(12, NULL) and multiple equal(`test`.`t1`.`a`, NULL)) +select * from t1 where a in (select a from t10 where pk=12); +a b +explain select * from t1 where a in (select a from t10 where pk=9); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t10 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t1` where ((`test`.`t1`.`a` = '9')) +select * from t1 where a in (select a from t10 where pk=9); +a b +An empty table inside +explain select * from t1 where a in (select a from t11); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t11 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t11`) where (`test`.`t1`.`a` = `test`.`t11`.`a`) +select * from t1 where a in (select a from t11); +a b +explain select * from t1 where a in (select pk from t10) and b in (select pk from t10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using index +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.t1.b 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t10` join `test`.`t1` where ((`test`.`t10`.`pk` = `test`.`t1`.`b`) and (`test`.`t10`.`pk` = `test`.`t1`.`a`)) +select * from t1 where a in (select pk from t10) and b in (select pk from t10); +a b +0 0 +1 1 +2 2 +flattening a nested subquery +explain select * from t1 where a in (select pk from t10 where t10.a in (select pk from t12)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using where +1 SIMPLE t12 NULL eq_ref PRIMARY PRIMARY 4 test.t10.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t12` join `test`.`t1` where ((`test`.`t10`.`pk` = `test`.`t1`.`a`) and (`test`.`t12`.`pk` = `test`.`t10`.`a`)) +select * from t1 where a in (select pk from t10 where t10.a in (select pk from t12)); +a b +0 0 +1 1 +2 2 +flattening subquery w/ several tables +explain select * from t1 where a in (select t10.pk from t10, t12 where t12.pk=t10.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using where +1 SIMPLE t12 NULL eq_ref PRIMARY PRIMARY 4 test.t10.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t12` join `test`.`t1` where ((`test`.`t10`.`pk` = `test`.`t1`.`a`) and (`test`.`t12`.`pk` = `test`.`t10`.`a`)) +subqueries within outer joins go into ON expr. +explain +select * from t1 left join (t2 A, t2 B) on ( A.A= t1.A and B.A in (select pk from t10)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE A NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE B NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.B.A 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`A` AS `A`,`test`.`t1`.`B` AS `B`,`test`.`A`.`A` AS `A`,`test`.`A`.`B` AS `B`,`test`.`B`.`A` AS `A`,`test`.`B`.`B` AS `B` from `test`.`t1` left join (`test`.`t10` join `test`.`t2` `A` join `test`.`t2` `B`) on(((`test`.`t10`.`pk` = `test`.`B`.`A`) and (`test`.`A`.`A` = `test`.`t1`.`A`))) where true +t2 should be wrapped into OJ-nest, so we have "t1 LJ (t2 J t10)" +explain +select * from t1 left join t2 on (t2.A= t1.A and t2.A in (select pk from t10)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.t1.A 1 100.00 Using index +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`A` AS `A`,`test`.`t1`.`B` AS `B`,`test`.`t2`.`A` AS `A`,`test`.`t2`.`B` AS `B` from `test`.`t1` left join (`test`.`t10` join `test`.`t2`) on(((`test`.`t10`.`pk` = `test`.`t1`.`A`) and (`test`.`t2`.`A` = `test`.`t1`.`A`))) where true +we shouldn't flatten if we're going to get a join of > MAX_TABLES. +explain select * from +t1 s00, t1 s01, t1 s02, t1 s03, t1 s04,t1 s05,t1 s06,t1 s07,t1 s08,t1 s09, +t1 s10, t1 s11, t1 s12, t1 s13, t1 s14,t1 s15,t1 s16,t1 s17,t1 s18,t1 s19, +t1 s20, t1 s21, t1 s22, t1 s23, t1 s24,t1 s25,t1 s26,t1 s27,t1 s28,t1 s29, +t1 s30, t1 s31, t1 s32, t1 s33, t1 s34,t1 s35,t1 s36,t1 s37,t1 s38,t1 s39, +t1 s40, t1 s41, t1 s42, t1 s43, t1 s44,t1 s45,t1 s46,t1 s47,t1 s48,t1 s49 +where +s00.a in ( +select m00.a from +t1 m00, t1 m01, t1 m02, t1 m03, t1 m04,t1 m05,t1 m06,t1 m07,t1 m08,t1 m09, +t1 m10, t1 m11, t1 m12, t1 m13, t1 m14,t1 m15,t1 m16,t1 m17,t1 m18,t1 m19 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY s00 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 PRIMARY s01 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s02 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s03 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s04 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s05 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s06 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s07 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s08 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s09 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s10 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s11 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s12 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s13 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s14 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s15 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s16 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s17 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s18 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s19 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s20 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s21 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s22 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s23 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s24 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s25 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s26 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s27 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s28 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s29 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s30 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s31 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s32 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s33 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s34 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s35 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s36 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s37 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s38 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s39 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s40 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s41 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s42 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s43 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s44 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s45 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s46 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s47 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s48 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s49 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m00 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +2 DEPENDENT SUBQUERY m01 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m02 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m03 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m04 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m05 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m06 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m07 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m08 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m09 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m10 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m11 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m12 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m13 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m14 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m15 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m16 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m17 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m18 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m19 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`s00`.`a` AS `a`,`test`.`s00`.`b` AS `b`,`test`.`s01`.`a` AS `a`,`test`.`s01`.`b` AS `b`,`test`.`s02`.`a` AS `a`,`test`.`s02`.`b` AS `b`,`test`.`s03`.`a` AS `a`,`test`.`s03`.`b` AS `b`,`test`.`s04`.`a` AS `a`,`test`.`s04`.`b` AS `b`,`test`.`s05`.`a` AS `a`,`test`.`s05`.`b` AS `b`,`test`.`s06`.`a` AS `a`,`test`.`s06`.`b` AS `b`,`test`.`s07`.`a` AS `a`,`test`.`s07`.`b` AS `b`,`test`.`s08`.`a` AS `a`,`test`.`s08`.`b` AS `b`,`test`.`s09`.`a` AS `a`,`test`.`s09`.`b` AS `b`,`test`.`s10`.`a` AS `a`,`test`.`s10`.`b` AS `b`,`test`.`s11`.`a` AS `a`,`test`.`s11`.`b` AS `b`,`test`.`s12`.`a` AS `a`,`test`.`s12`.`b` AS `b`,`test`.`s13`.`a` AS `a`,`test`.`s13`.`b` AS `b`,`test`.`s14`.`a` AS `a`,`test`.`s14`.`b` AS `b`,`test`.`s15`.`a` AS `a`,`test`.`s15`.`b` AS `b`,`test`.`s16`.`a` AS `a`,`test`.`s16`.`b` AS `b`,`test`.`s17`.`a` AS `a`,`test`.`s17`.`b` AS `b`,`test`.`s18`.`a` AS `a`,`test`.`s18`.`b` AS `b`,`test`.`s19`.`a` AS `a`,`test`.`s19`.`b` AS `b`,`test`.`s20`.`a` AS `a`,`test`.`s20`.`b` AS `b`,`test`.`s21`.`a` AS `a`,`test`.`s21`.`b` AS `b`,`test`.`s22`.`a` AS `a`,`test`.`s22`.`b` AS `b`,`test`.`s23`.`a` AS `a`,`test`.`s23`.`b` AS `b`,`test`.`s24`.`a` AS `a`,`test`.`s24`.`b` AS `b`,`test`.`s25`.`a` AS `a`,`test`.`s25`.`b` AS `b`,`test`.`s26`.`a` AS `a`,`test`.`s26`.`b` AS `b`,`test`.`s27`.`a` AS `a`,`test`.`s27`.`b` AS `b`,`test`.`s28`.`a` AS `a`,`test`.`s28`.`b` AS `b`,`test`.`s29`.`a` AS `a`,`test`.`s29`.`b` AS `b`,`test`.`s30`.`a` AS `a`,`test`.`s30`.`b` AS `b`,`test`.`s31`.`a` AS `a`,`test`.`s31`.`b` AS `b`,`test`.`s32`.`a` AS `a`,`test`.`s32`.`b` AS `b`,`test`.`s33`.`a` AS `a`,`test`.`s33`.`b` AS `b`,`test`.`s34`.`a` AS `a`,`test`.`s34`.`b` AS `b`,`test`.`s35`.`a` AS `a`,`test`.`s35`.`b` AS `b`,`test`.`s36`.`a` AS `a`,`test`.`s36`.`b` AS `b`,`test`.`s37`.`a` AS `a`,`test`.`s37`.`b` AS `b`,`test`.`s38`.`a` AS `a`,`test`.`s38`.`b` AS `b`,`test`.`s39`.`a` AS `a`,`test`.`s39`.`b` AS `b`,`test`.`s40`.`a` AS `a`,`test`.`s40`.`b` AS `b`,`test`.`s41`.`a` AS `a`,`test`.`s41`.`b` AS `b`,`test`.`s42`.`a` AS `a`,`test`.`s42`.`b` AS `b`,`test`.`s43`.`a` AS `a`,`test`.`s43`.`b` AS `b`,`test`.`s44`.`a` AS `a`,`test`.`s44`.`b` AS `b`,`test`.`s45`.`a` AS `a`,`test`.`s45`.`b` AS `b`,`test`.`s46`.`a` AS `a`,`test`.`s46`.`b` AS `b`,`test`.`s47`.`a` AS `a`,`test`.`s47`.`b` AS `b`,`test`.`s48`.`a` AS `a`,`test`.`s48`.`b` AS `b`,`test`.`s49`.`a` AS `a`,`test`.`s49`.`b` AS `b` from `test`.`t1` `s00` join `test`.`t1` `s01` join `test`.`t1` `s02` join `test`.`t1` `s03` join `test`.`t1` `s04` join `test`.`t1` `s05` join `test`.`t1` `s06` join `test`.`t1` `s07` join `test`.`t1` `s08` join `test`.`t1` `s09` join `test`.`t1` `s10` join `test`.`t1` `s11` join `test`.`t1` `s12` join `test`.`t1` `s13` join `test`.`t1` `s14` join `test`.`t1` `s15` join `test`.`t1` `s16` join `test`.`t1` `s17` join `test`.`t1` `s18` join `test`.`t1` `s19` join `test`.`t1` `s20` join `test`.`t1` `s21` join `test`.`t1` `s22` join `test`.`t1` `s23` join `test`.`t1` `s24` join `test`.`t1` `s25` join `test`.`t1` `s26` join `test`.`t1` `s27` join `test`.`t1` `s28` join `test`.`t1` `s29` join `test`.`t1` `s30` join `test`.`t1` `s31` join `test`.`t1` `s32` join `test`.`t1` `s33` join `test`.`t1` `s34` join `test`.`t1` `s35` join `test`.`t1` `s36` join `test`.`t1` `s37` join `test`.`t1` `s38` join `test`.`t1` `s39` join `test`.`t1` `s40` join `test`.`t1` `s41` join `test`.`t1` `s42` join `test`.`t1` `s43` join `test`.`t1` `s44` join `test`.`t1` `s45` join `test`.`t1` `s46` join `test`.`t1` `s47` join `test`.`t1` `s48` join `test`.`t1` `s49` where (`test`.`s00`.`a`,(/* select#2 */ select `test`.`m00`.`a` from `test`.`t1` `m00` join `test`.`t1` `m01` join `test`.`t1` `m02` join `test`.`t1` `m03` join `test`.`t1` `m04` join `test`.`t1` `m05` join `test`.`t1` `m06` join `test`.`t1` `m07` join `test`.`t1` `m08` join `test`.`t1` `m09` join `test`.`t1` `m10` join `test`.`t1` `m11` join `test`.`t1` `m12` join `test`.`t1` `m13` join `test`.`t1` `m14` join `test`.`t1` `m15` join `test`.`t1` `m16` join `test`.`t1` `m17` join `test`.`t1` `m18` join `test`.`t1` `m19` where ((`test`.`s00`.`a`) = `test`.`m00`.`a`))) +select * from +t1 left join t2 on (t2.a= t1.a and t2.a in (select pk from t10)) +where t1.a < 5; +a b a b +0 0 0 0 +1 1 1 1 +2 2 2 2 +prepare s1 from +' select * from + t1 left join t2 on (t2.a= t1.a and t2.a in (select pk from t10)) + where t1.a < 5'; +execute s1; +a b a b +0 0 0 0 +1 1 1 1 +2 2 2 2 +execute s1; +a b a b +0 0 0 0 +1 1 1 1 +2 2 2 2 +insert into t1 select (A.a + 10 * B.a),1 from t0 A, t0 B; +explain select * from t1 where a in (select pk from t10 where pk<3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t10 NULL range PRIMARY PRIMARY 4 NULL 4 100.00 Using where; Using index +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 103 10.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t1` where ((`test`.`t1`.`a` = `test`.`t10`.`pk`) and (`test`.`t10`.`pk` < 3)) +drop table t0, t1, t2; +drop table t10, t11, t12; +# +# Check that subqueries with outer joins or straight_join work for +# different permutations of const and non-const tables. (Ref. Bug#46692) +# +CREATE TABLE t1 (i INTEGER); +CREATE TABLE t2 (i INTEGER); +CREATE TABLE t3 (i INTEGER); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 0 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 0 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 0 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 1 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 1 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 1 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 2 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 2 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 2 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (0); +DELETE FROM t2; +INSERT INTO t1 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 0 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 0 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 0 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 1 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 1 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 1 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 2 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 2 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 2 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (0); +DELETE FROM t2; +INSERT INTO t1 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 0 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = `test`.`t2`.`i`) and (`test`.`t1`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = `test`.`t2`.`i`) and (`test`.`t1`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = `test`.`t2`.`i`) and (`test`.`t1`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 0 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = `test`.`t2`.`i`) and (`test`.`t1`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = `test`.`t2`.`i`) and (`test`.`t1`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = `test`.`t2`.`i`) and (`test`.`t1`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 0 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t2`.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t2`.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t2`.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = `test`.`t1`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +1 +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = `test`.`t1`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 1 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = `test`.`t3`.`i`) and (`test`.`t1`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = `test`.`t3`.`i`) and (`test`.`t1`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = `test`.`t3`.`i`) and (`test`.`t1`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 1 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = `test`.`t2`.`i`) and (`test`.`t1`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = `test`.`t2`.`i`) and (`test`.`t1`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = `test`.`t2`.`i`) and (`test`.`t1`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 1 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t2`.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t2`.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t2`.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = `test`.`t1`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +1 +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = `test`.`t1`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +1 +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 2 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t3`.`i`) and (`test`.`t2`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t3`.`i`) and (`test`.`t2`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t3`.`i`) and (`test`.`t2`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = `test`.`t1`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 2 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t3`.`i`) and (`test`.`t2`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t3`.`i`) and (`test`.`t2`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t3`.`i`) and (`test`.`t2`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = `test`.`t1`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 2 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = `test`.`t1`.`i`) and (`test`.`t3`.`i` = `test`.`t1`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +1 +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +1 +2 + +EXECUTE stmt; +i +1 +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = `test`.`t1`.`i`) and (`test`.`t3`.`i` = `test`.`t1`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +1 +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = `test`.`t1`.`i`) and (`test`.`t3`.`i` = `test`.`t1`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +1 +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +1 +2 + +EXECUTE stmt; +i +1 +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = `test`.`t1`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +1 +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = `test`.`t1`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +1 +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (0); +DELETE FROM t2; +INSERT INTO t1 VALUES (0); +DROP TABLE t1, t2, t3; +create table x1(k int primary key, d1 int, d2 int); +create table x2(k int primary key, d1 int, d2 int); +insert into x1 values +(10, 10, 10), +(20, 20, 20), +(21, 20, null), +(30, null, 30), +(40, 40, 40); +insert into x2 values +(10, 10, 10), +(20, 20, 20), +(21, 20, null), +(30, null, 30); +select * +from x1 +where (d1, d2) in (select d1, d2 +from x2); +k d1 d2 +10 10 10 +20 20 20 +select * +from x1 +where (d1, d2) in (select d1, d2 +from x2) is true; +k d1 d2 +10 10 10 +20 20 20 +select * +from x1 +where (d1, d2) in (select d1, d2 +from x2) is false; +k d1 d2 +40 40 40 +select * +from x1 +where (d1, d2) in (select d1, d2 +from x2) is unknown; +k d1 d2 +21 20 NULL +30 NULL 30 +select * +from x1 +where d1 in (select d1 +from x2 +where x1.d2=x2.d2); +k d1 d2 +10 10 10 +20 20 20 +select * +from x1 +where d1 in (select d1 +from x2 +where x1.d2=x2.d2) is true; +k d1 d2 +10 10 10 +20 20 20 +select * +from x1 +where d1 in (select d1 +from x2 +where x1.d2=x2.d2) is false; +k d1 d2 +21 20 NULL +40 40 40 +select * +from x1 +where d1 in (select d1 +from x2 +where x1.d2=x2.d2) is unknown; +k d1 d2 +30 NULL 30 +select * +from x1 +where 1 in (select 1 +from x2 +where x1.d1=x2.d1 and x1.d2=x2.d2); +k d1 d2 +10 10 10 +20 20 20 +select * +from x1 +where 1 in (select 1 +from x2 +where x1.d1=x2.d1 and x1.d2=x2.d2) is true; +k d1 d2 +10 10 10 +20 20 20 +select * +from x1 +where 1 in (select 1 +from x2 +where x1.d1=x2.d1 and x1.d2=x2.d2) is false; +k d1 d2 +21 20 NULL +30 NULL 30 +40 40 40 +select * +from x1 +where 1 in (select 1 +from x2 +where x1.d1=x2.d1 and x1.d2=x2.d2) is unknown; +k d1 d2 +select * +from x1 +where exists (select * +from x2 +where x1.d1=x2.d1 and x1.d2=x2.d2); +k d1 d2 +10 10 10 +20 20 20 +drop table x1; +drop table x2; +CREATE TABLE t1 ( +a int(11) NOT NULL, +b int(11) NOT NULL, +c datetime default NULL, +PRIMARY KEY (a), +KEY idx_bc (b,c) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES +(406989,67,'2006-02-23 17:08:46'), (150078,67,'2005-10-26 11:17:45'), +(406993,67,'2006-02-27 11:20:57'), (245655,67,'2005-12-08 15:59:08'), +(406994,67,'2006-02-27 11:26:46'), (256,67,NULL), +(398341,67,'2006-02-20 04:48:44'), (254,67,NULL),(1120,67,NULL), +(406988,67,'2006-02-23 17:07:22'), (255,67,NULL), +(398340,67,'2006-02-20 04:38:53'),(406631,67,'2006-02-23 10:49:42'), +(245653,67,'2005-12-08 15:59:07'),(406992,67,'2006-02-24 16:47:18'), +(245654,67,'2005-12-08 15:59:08'),(406995,67,'2006-02-28 11:55:00'), +(127261,67,'2005-10-13 12:17:58'),(406991,67,'2006-02-24 16:42:32'), +(245652,67,'2005-12-08 15:58:27'),(398545,67,'2006-02-20 04:53:13'), +(154504,67,'2005-10-28 11:53:01'),(9199,67,NULL),(1,67,'2006-02-23 15:01:35'), +(223456,67,NULL),(4101,67,NULL),(1133,67,NULL), +(406990,67,'2006-02-23 18:01:45'),(148815,67,'2005-10-25 15:34:17'), +(148812,67,'2005-10-25 15:30:01'),(245651,67,'2005-12-08 15:58:27'), +(154503,67,'2005-10-28 11:52:38'); +create table t11 select * from t1 where b = 67 AND (c IS NULL OR c > NOW()) order by 3 asc; +create table t12 select * from t1 where b = 67 AND (c IS NULL OR c > NOW()) order by 3 desc; +create table t21 select * from t1 where b = 67 AND (c IS NULL OR c > '2005-12-08') order by 3 asc; +create table t22 select * from t1 where b = 67 AND (c IS NULL OR c > '2005-12-08') order by 3 desc; +update t22 set c = '2005-12-08 15:58:27' where a = 255; +explain select t21.* from t21,t22 where t21.a = t22.a and +t22.a in (select t12.a from t11, t12 where t11.a in(255,256) and t11.a = t12.a and t11.c is null) and t22.c is null order by t21.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t11 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; Using temporary; Using filesort; Start temporary +1 SIMPLE t12 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; Using join buffer (hash join) +1 SIMPLE t22 NULL ALL NULL NULL NULL NULL 26 3.85 Using where; End temporary; Using join buffer (hash join) +1 SIMPLE t21 NULL ALL NULL NULL NULL NULL 26 10.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t21`.`a` AS `a`,`test`.`t21`.`b` AS `b`,`test`.`t21`.`c` AS `c` from `test`.`t21` join `test`.`t22` semi join (`test`.`t11` join `test`.`t12`) where ((`test`.`t12`.`a` = `test`.`t11`.`a`) and (`test`.`t22`.`a` = `test`.`t11`.`a`) and (`test`.`t21`.`a` = `test`.`t11`.`a`) and (`test`.`t22`.`c` is null) and (`test`.`t11`.`a` in (255,256)) and (`test`.`t11`.`c` is null)) order by `test`.`t21`.`a` +explain format=json select * from t1 where a in (select a from t11); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "6.71" + }, + "duplicates_removal": { + "using_temporary_table": true, + "nested_loop": [ + { + "table": { + "table_name": "t11", + "access_type": "ALL", + "rows_examined_per_scan": 8, + "rows_produced_per_join": 8, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "0.80", + "prefix_cost": "1.31", + "data_read_per_join": "128" + }, + "used_columns": [ + "a" + ] + } + }, + { + "table": { + "table_name": "t1", + "access_type": "eq_ref", + "possible_keys": [ + "PRIMARY" + ], + "key": "PRIMARY", + "used_key_parts": [ + "a" + ], + "key_length": "4", + "ref": [ + "test.t11.a" + ], + "rows_examined_per_scan": 1, + "rows_produced_per_join": 8, + "filtered": "100.00", + "cost_info": { + "read_cost": "2.00", + "eval_cost": "0.80", + "prefix_cost": "6.71", + "data_read_per_join": "128" + }, + "used_columns": [ + "a", + "b", + "c" + ] + } + } + ] + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` semi join (`test`.`t11`) where (`test`.`t1`.`a` = `test`.`t11`.`a`) +select t21.* from t21,t22 where t21.a = t22.a and +t22.a in (select t12.a from t11, t12 where t11.a in(255,256) and t11.a = t12.a and t11.c is null) and t22.c is null order by t21.a; +a b c +256 67 NULL +drop table t1, t11, t12, t21, t22; +create table t1(a int); +insert into t1 values (0),(1); +explain +select (select max(y.a) from t1 y where a in (select a from t1 z) and a < x.a) as subq from t1 x; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY x NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DEPENDENT SUBQUERY y NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +2 DEPENDENT SUBQUERY z NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.x.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select (/* select#2 */ select max(`test`.`y`.`a`) from `test`.`t1` `y` semi join (`test`.`t1` `z`) where ((`test`.`z`.`a` = `test`.`y`.`a`) and (`test`.`y`.`a` < `test`.`x`.`a`))) AS `subq` from `test`.`t1` `x` +select (select max(y.a) from t1 y where a in (select a from t1 z) and a < x.a) as subq from t1 x; +subq +NULL +0 +drop table t1; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 as select * from t0; +insert into t1 select a+10 from t0; +insert into t0 values(2); +explain select * from t1 where 2 in (select a from t0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 11 10.00 Using where; Start temporary; End temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 20 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t0`) where (`test`.`t0`.`a` = 2) +select * from t1 where 2 in (select a from t0); +a +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +explain select * from (select a from t0) x where a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 11 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 20 10.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a` from `test`.`t0` semi join (`test`.`t1`) where (`test`.`t1`.`a` = `test`.`t0`.`a`) +explain format=json select * from (select a from t0) x where a in (select a from t1); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "28.41" + }, + "duplicates_removal": { + "using_temporary_table": true, + "nested_loop": [ + { + "table": { + "table_name": "t0", + "access_type": "ALL", + "rows_examined_per_scan": 11, + "rows_produced_per_join": 11, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "1.10", + "prefix_cost": "1.60", + "data_read_per_join": "88" + }, + "used_columns": [ + "a" + ] + } + }, + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 11, + "filtered": "10.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "1.10", + "prefix_cost": "28.41", + "data_read_per_join": "88" + }, + "used_columns": [ + "a" + ], + "attached_condition": "(`test`.`t1`.`a` = `test`.`t0`.`a`)" + } + } + ] + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a` from `test`.`t0` semi join (`test`.`t1`) where (`test`.`t1`.`a` = `test`.`t0`.`a`) +drop table t0, t1; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (kp1 int, kp2 int, c int, filler char(100), key(kp1, kp2)); +insert into t1 select A.a+10*(B.a+10*C.a), 0, 0, 'filler' from t0 A, t0 B, t0 C; +insert into t1 select * from t1 where kp1 < 20; +create table t3 (a int); +insert into t3 select A.a + 10*B.a from t0 A, t0 B; +explain select * from t3 where a in (select kp1 from t1 where kp1<20); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 100 100.00 Using where +1 SIMPLE t1 NULL ref kp1 kp1 5 test.t3.a 1 100.00 Using index; Start temporary; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a` from `test`.`t3` semi join (`test`.`t1`) where ((`test`.`t1`.`kp1` = `test`.`t3`.`a`) and (`test`.`t3`.`a` < 20)) +select * from t3 where a in (select kp1 from t1 where kp1<20); +a +0 +1 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +2 +3 +4 +5 +6 +7 +8 +9 +explain select * from t3 where a in (select kp1 from t1 where kp1<20) and a<20; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 100 33.33 Using where +1 SIMPLE t1 NULL ref kp1 kp1 5 test.t3.a 1 100.00 Using index; Start temporary; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a` from `test`.`t3` semi join (`test`.`t1`) where ((`test`.`t1`.`kp1` = `test`.`t3`.`a`) and (`test`.`t3`.`a` < 20) and (`test`.`t3`.`a` < 20)) +select * from t3 where a in (select kp1 from t1 where kp1<20) and a<20; +a +0 +1 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +2 +3 +4 +5 +6 +7 +8 +9 +create table t4 (pk int primary key); +insert into t4 select a from t3; +explain select * from t3 where a in +(select t1.kp1 from t1,t4 where kp1<20 and t4.pk=t1.c); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 100 100.00 Using where +1 SIMPLE t1 NULL ref kp1 kp1 5 test.t3.a 1 100.00 Using where; Start temporary +1 SIMPLE t4 NULL eq_ref PRIMARY PRIMARY 4 test.t1.c 1 100.00 Using index; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a` from `test`.`t3` semi join (`test`.`t1` join `test`.`t4`) where ((`test`.`t1`.`kp1` = `test`.`t3`.`a`) and (`test`.`t4`.`pk` = `test`.`t1`.`c`) and (`test`.`t3`.`a` < 20)) +explain format=tree select * from t3 where a in +(select t1.kp1 from t1,t4 where kp1<20 and t4.pk=t1.c); +EXPLAIN +-> Nested loop inner join (cost=45.54 rows=100) + -> Filter: ((t3.a < 20) and (t3.a is not null)) (cost=10.54 rows=100) + -> Table scan on t3 (cost=10.54 rows=100) + -> Limit: 1 row(s) (cost=25.35 rows=1) + -> Nested loop inner join (cost=25.35 rows=1) + -> Filter: (t1.c is not null) (cost=0.25 rows=1) + -> Index lookup on t1 using kp1 (kp1=t3.a) (cost=0.25 rows=1) + -> Single-row index lookup on t4 using PRIMARY (pk=t1.c) (cost=0.25 rows=1) + +select * from t3 where a in +(select t1.kp1 from t1,t4 where kp1<20 and t4.pk=t1.c); +a +0 +1 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +2 +3 +4 +5 +6 +7 +8 +9 +drop table t1, t3, t4; +create table t1 (a int); +insert into t1 values (0),(0),(0),(1),(1),(1),(2),(2),(2),(3),(3),(3); +set session internal_tmp_mem_storage_engine='memory'; +set @save_max_heap_table_size=@@max_heap_table_size; +set @@max_heap_table_size= 16384; +# Attempt to make one test that overflows the heap table when a +# non-duplicate row is inserted and one test that overflows the +# heap table when a duplicate record is inserted. Debugging showed +# that these situations occurred with max_heap_table_size=16384 +# and optimizer_join_cache_level equals 1 and 0, respectively. +# Finally execute a test that does not overflow the heap table. +explain +select count(*) from t0 a, t0 b, t0 c +where c.a in (select a from t1 d); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE a NULL ALL NULL NULL NULL NULL 10 100.00 Start temporary +1 SIMPLE b NULL ALL NULL NULL NULL NULL 10 100.00 Using join buffer (hash join) +1 SIMPLE c NULL ALL NULL NULL NULL NULL 10 100.00 Using join buffer (hash join) +1 SIMPLE d NULL ALL NULL NULL NULL NULL 12 10.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select count(0) AS `count(*)` from `test`.`t0` `a` join `test`.`t0` `b` join `test`.`t0` `c` semi join (`test`.`t1` `d`) where (`test`.`d`.`a` = `test`.`c`.`a`) +flush status; +select count(*) from t0 a, t0 b, t0 c +where c.a in (select a from t1 d); +count(*) +400 +show status like 'Created_tmp_disk_tables'; +Variable_name Value +Created_tmp_disk_tables 1 +set @@max_heap_table_size= @save_max_heap_table_size; +set session internal_tmp_mem_storage_engine=default; +flush status; +select count(*) from t0 a, t0 b, t0 c +where c.a in (select a from t1 d); +count(*) +400 +show status like 'Created_tmp_disk_tables'; +Variable_name Value +Created_tmp_disk_tables 0 +drop table t0, t1; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t2(a int); +insert into t2 values (1),(2); +create table t3 ( a int , filler char(100), key(a)); +insert into t3 select A.a + 10*B.a, 'filler' from t0 A, t0 B; +explain select * from t3 where a in (select a from t2) and (a > 5 or a < 10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ref a a 5 test.t2.a 1 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a`,`test`.`t3`.`filler` AS `filler` from `test`.`t3` semi join (`test`.`t2`) where ((`test`.`t3`.`a` = `test`.`t2`.`a`) and ((`test`.`t2`.`a` > 5) or (`test`.`t2`.`a` < 10))) +select * from t3 where a in (select a from t2); +a filler +1 filler +2 filler +drop table t0, t2, t3; +create table t1 (a date); +insert into t1 values ('2008-01-01'),('2008-01-01'),('2008-02-01'),('2008-02-01'); +create table t2 (a int); +insert into t2 values (1),(2); +create table t3 (a char(10)); +insert into t3 select * from t1; +insert into t3 values (1),(2); +explain select * from t2 where a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1`) where (cast(`test`.`t2`.`a` as double) = cast(`test`.`t1`.`a` as double)) +explain select * from t2 where a in (select a from t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t2`) where (`test`.`t2`.`a` = `test`.`t2`.`a`) +explain select * from t2 where a in (select a from t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t3`) where (cast(`test`.`t2`.`a` as double) = cast(`test`.`t3`.`a` as double)) +explain select * from t1 where a in (select a from t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t3`) where (`test`.`t1`.`a` = cast(`test`.`t3`.`a` as date)) +drop table t1, t2, t3; +create table t1 (a decimal); +insert into t1 values (1),(2); +explain select * from t1 where a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t1`) where (`test`.`t1`.`a` = `test`.`t1`.`a`) +drop table t1; +create table t1 (a int); +insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t2 as select * from t1; +create table t3 (a int, b int, filler char(100), key(a)) charset utf8mb4; +insert into t3 select A.a + 10*B.a, A.a + 10*B.a, 'filler' from t1 A, t1 B, t1 C; +explain select * from t1, t3 where t3.a in (select a from t2) and (t3.a < 10 or t3.a >30) and t1.a =3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 10.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 10 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ref a a 5 test.t2.a 10 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t3`.`filler` AS `filler` from `test`.`t1` join `test`.`t3` semi join (`test`.`t2`) where ((`test`.`t3`.`a` = `test`.`t2`.`a`) and (`test`.`t1`.`a` = 3) and ((`test`.`t2`.`a` < 10) or (`test`.`t2`.`a` > 30))) +explain format=json select * from t1, t3 where t3.a in (select a from t2) and (t3.a < 10 or t3.a >30) and t1.a =3; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "59.01" + }, + "duplicates_removal": { + "using_temporary_table": true, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 10, + "rows_produced_per_join": 1, + "filtered": "10.00", + "cost_info": { + "read_cost": "1.40", + "eval_cost": "0.10", + "prefix_cost": "1.50", + "data_read_per_join": "8" + }, + "used_columns": [ + "a" + ], + "attached_condition": "(`test`.`t1`.`a` = 3)" + } + }, + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 10, + "rows_produced_per_join": 10, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "1.00", + "prefix_cost": "3.01", + "data_read_per_join": "80" + }, + "used_columns": [ + "a" + ], + "attached_condition": "(((`test`.`t2`.`a` < 10) or (`test`.`t2`.`a` > 30)) and (`test`.`t2`.`a` is not null))" + } + }, + { + "table": { + "table_name": "t3", + "access_type": "ref", + "possible_keys": [ + "a" + ], + "key": "a", + "used_key_parts": [ + "a" + ], + "key_length": "5", + "ref": [ + "test.t2.a" + ], + "rows_examined_per_scan": 10, + "rows_produced_per_join": 100, + "filtered": "100.00", + "cost_info": { + "read_cost": "25.00", + "eval_cost": "10.00", + "prefix_cost": "59.01", + "data_read_per_join": "40K" + }, + "used_columns": [ + "a", + "b", + "filler" + ] + } + } + ] + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t3`.`filler` AS `filler` from `test`.`t1` join `test`.`t3` semi join (`test`.`t2`) where ((`test`.`t3`.`a` = `test`.`t2`.`a`) and (`test`.`t1`.`a` = 3) and ((`test`.`t2`.`a` < 10) or (`test`.`t2`.`a` > 30))) +explain select straight_join * from t1 a, t1 b where a.a in (select a from t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY a NULL ALL NULL NULL NULL NULL 10 100.00 Using where +1 PRIMARY b NULL ALL NULL NULL NULL NULL 10 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select straight_join `test`.`a`.`a` AS `a`,`test`.`b`.`a` AS `a` from `test`.`t1` `a` join `test`.`t1` `b` where (`test`.`a`.`a`,(/* select#2 */ select `test`.`t2`.`a` from `test`.`t2` where ((`test`.`a`.`a`) = `test`.`t2`.`a`))) +explain select * from t2 where a in (select straight_join a.a from t1 a, t1 b); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 10 100.00 Using where +2 DEPENDENT SUBQUERY a NULL ALL NULL NULL NULL NULL 10 10.00 Using where +2 DEPENDENT SUBQUERY b NULL ALL NULL NULL NULL NULL 10 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` where (`test`.`t2`.`a`,(/* select#2 */ select straight_join `test`.`a`.`a` from `test`.`t1` `a` join `test`.`t1` `b` where ((`test`.`t2`.`a`) = `test`.`a`.`a`))) +explain select * from t2 where a in (select straight_join a.a from t1 a, t1 b); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 10 100.00 Using where +2 DEPENDENT SUBQUERY a NULL ALL NULL NULL NULL NULL 10 10.00 Using where +2 DEPENDENT SUBQUERY b NULL ALL NULL NULL NULL NULL 10 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` where (`test`.`t2`.`a`,(/* select#2 */ select straight_join `test`.`a`.`a` from `test`.`t1` `a` join `test`.`t1` `b` where ((`test`.`t2`.`a`) = `test`.`a`.`a`))) +explain select straight_join * from t2 x, t2 y +where x.a in (select straight_join a.a from t1 a, t1 b); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY x NULL ALL NULL NULL NULL NULL 10 100.00 Using where +1 PRIMARY y NULL ALL NULL NULL NULL NULL 10 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY a NULL ALL NULL NULL NULL NULL 10 10.00 Using where +2 DEPENDENT SUBQUERY b NULL ALL NULL NULL NULL NULL 10 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select straight_join `test`.`x`.`a` AS `a`,`test`.`y`.`a` AS `a` from `test`.`t2` `x` join `test`.`t2` `y` where (`test`.`x`.`a`,(/* select#2 */ select straight_join `test`.`a`.`a` from `test`.`t1` `a` join `test`.`t1` `b` where ((`test`.`x`.`a`) = `test`.`a`.`a`))) +create table t0 (a int, b int); +insert into t0 values(1,1); +explain select * from t0, t3 where t3.a in (select a from t2) and (t3.a < 10 or t3.a >30); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 10 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ref a a 5 test.t2.a 10 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select '1' AS `a`,'1' AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t3`.`filler` AS `filler` from `test`.`t3` semi join (`test`.`t2`) where ((`test`.`t3`.`a` = `test`.`t2`.`a`) and ((`test`.`t2`.`a` < 10) or (`test`.`t2`.`a` > 30))) +create table t4 as select a as x, a as y from t1; +explain select * from t0, t3 where (t3.a, t3.b) in (select x,y from t4) and (t3.a < 10 or t3.a >30); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t4 NULL ALL NULL NULL NULL NULL 10 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ref a a 5 test.t4.x 10 10.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '1' AS `a`,'1' AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t3`.`filler` AS `filler` from `test`.`t3` semi join (`test`.`t4`) where ((`test`.`t3`.`b` = `test`.`t4`.`y`) and (`test`.`t3`.`a` = `test`.`t4`.`x`) and ((`test`.`t4`.`x` < 10) or (`test`.`t4`.`x` > 30))) +drop table t0,t1,t2,t3,t4; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (a int, b int, filler char(100), key(a,b)); +insert into t1 select A.a, B.a, 'filler' from t0 A, t0 B; +create table t2 as select * from t1; +explain select * from t2 where a in (select b from t1 where a=3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 100 100.00 Using where +1 SIMPLE t1 NULL ref a a 10 const,test.t2.a 1 100.00 Using index; Start temporary; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`filler` AS `filler` from `test`.`t2` semi join (`test`.`t1`) where ((`test`.`t1`.`b` = `test`.`t2`.`a`) and (`test`.`t1`.`a` = 3)) +explain select * from t2 where (b,a) in (select a,b from t1 where a=3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 100 10.00 Using where +1 SIMPLE t1 NULL ref a a 10 const,test.t2.a 1 100.00 Using index; Start temporary; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`filler` AS `filler` from `test`.`t2` semi join (`test`.`t1`) where ((`test`.`t1`.`b` = `test`.`t2`.`a`) and (`test`.`t2`.`b` = 3) and (`test`.`t1`.`a` = 3)) +drop table t1,t2; +create table t1 (a int, b int); +insert into t1 select a,a from t0; +create table t2 (a int, b int); +insert into t2 select A.a + 10*B.a, A.a + 10*B.a from t0 A, t0 B; +explain select * from t1 where (a,b) in (select a,b from t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 100.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 100 1.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`a` = `test`.`t1`.`a`)) +drop table t0, t1, t2; +# +# Bug#19695490: CRASH IN CREATE_REF_FOR_KEY ON SELECT + JOIN + UTF8 COLUMN +# + DATETIME INDEX. +# +CREATE TABLE t1 ( +field1 varchar(255) CHARACTER SET utf8, +field2 varchar(255) CHARACTER SET utf8 +); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES +('time','time'), +('lpjdzvkp','lpjdzvkp'), +('dzvkpai', 'dzvkpai'); +CREATE TABLE t2 ( col_varchar varchar(10)); +CREATE TABLE t3 ( +pk int(11) NOT NULL, +col_varchar_255_utf8_key varchar(255) CHARACTER SET utf8, +col_varchar_10_utf8_key varchar(10) CHARACTER SET utf8, +PRIMARY KEY (pk) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t3 VALUES (22,'come','h'), +(23,'time','aaa'), +(24,'lpjdzvkp','ababa'), +(25,'d','GGDD'); +SELECT * FROM t1 WHERE (field1, field2) IN ( +SELECT table1.col_varchar_255_utf8_key AS field1, +table1.col_varchar_255_utf8_key AS field2 +FROM t3 AS table1 LEFT JOIN t2 AS table2 +ON table1.col_varchar_10_utf8_key <= +table2.col_varchar +WHERE table1.pk >= 6); +field1 field2 +time time +lpjdzvkp lpjdzvkp +DROP TABLE t1,t2,t3; +create table t0 (a decimal(4,2)); +insert into t0 values (10.24), (22.11); +create table t1 as select * from t0; +insert into t1 select * from t0; +explain select * from t0 where a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a` from `test`.`t0` semi join (`test`.`t1`) where (`test`.`t1`.`a` = `test`.`t0`.`a`) +select * from t0 where a in (select a from t1); +a +10.24 +22.11 +drop table t0, t1; +create table t0(a date); +insert into t0 values ('2008-01-01'),('2008-02-02'); +create table t1 as select * from t0; +insert into t1 select * from t0; +explain select * from t0 where a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a` from `test`.`t0` semi join (`test`.`t1`) where (`test`.`t1`.`a` = `test`.`t0`.`a`) +select * from t0 where a in (select a from t1); +a +2008-01-01 +2008-02-02 +drop table t0, t1; +create table t0(a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 as select a as a, a as b, a as c from t0 where a < 3; +create table t2 as select a as a, a as b from t0 where a < 3; +insert into t2 select * from t2; +explain select * from t1 where (a,b,c) in (select x.a, y.a, z.a from t2 x, t2 y, t2 z where x.b=33); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE x NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +1 SIMPLE y NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Using join buffer (hash join) +1 SIMPLE z NULL ALL NULL NULL NULL NULL 6 16.67 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` semi join (`test`.`t2` `x` join `test`.`t2` `y` join `test`.`t2` `z`) where ((`test`.`z`.`a` = `test`.`t1`.`c`) and (`test`.`y`.`a` = `test`.`t1`.`b`) and (`test`.`t1`.`a` = `test`.`x`.`a`) and (`test`.`x`.`b` = 33)) +drop table t0,t1,t2; +set @save_join_buffer_size = @@join_buffer_size; +set join_buffer_size= 8192; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (a int, filler1 binary(200), filler2 binary(200)); +insert into t1 select a, 'filler123456', 'filler123456' from t0; +insert into t1 select a+10, 'filler123456', 'filler123456' from t0; +create table t2 as select * from t1; +insert into t1 select a+20, 'filler123456', 'filler123456' from t0; +insert into t1 values (2, 'duplicate ok', 'duplicate ok'); +insert into t1 values (18, 'duplicate ok', 'duplicate ok'); +insert into t2 values (3, 'duplicate ok', 'duplicate ok'); +insert into t2 values (19, 'duplicate ok', 'duplicate ok'); +explain select +a, mid(filler1, 1,10), length(filler1)=length(filler2) as z +from t1 ot where a in (select a from t2 it); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE it NULL ALL NULL NULL NULL NULL 22 100.00 Start temporary +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 32 10.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot`.`a` AS `a`,substr(`test`.`ot`.`filler1`,1,10) AS `mid(filler1, 1,10)`,(length(`test`.`ot`.`filler1`) = length(`test`.`ot`.`filler2`)) AS `z` from `test`.`t1` `ot` semi join (`test`.`t2` `it`) where (`test`.`ot`.`a` = `test`.`it`.`a`) +select +a, mid(filler1, 1,10), length(filler1)=length(filler2) as z +from t1 ot where a in (select a from t2 it); +a mid(filler1, 1,10) z +0 filler1234 1 +1 filler1234 1 +10 filler1234 1 +11 filler1234 1 +12 filler1234 1 +13 filler1234 1 +14 filler1234 1 +15 filler1234 1 +16 filler1234 1 +17 filler1234 1 +18 duplicate 1 +18 filler1234 1 +19 filler1234 1 +2 duplicate 1 +2 filler1234 1 +3 filler1234 1 +4 filler1234 1 +5 filler1234 1 +6 filler1234 1 +7 filler1234 1 +8 filler1234 1 +9 filler1234 1 +explain select +a, mid(filler1, 1,10), length(filler1)=length(filler2) +from t2 ot where a in (select a from t1 it); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 22 100.00 Start temporary +1 SIMPLE it NULL ALL NULL NULL NULL NULL 32 10.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot`.`a` AS `a`,substr(`test`.`ot`.`filler1`,1,10) AS `mid(filler1, 1,10)`,(length(`test`.`ot`.`filler1`) = length(`test`.`ot`.`filler2`)) AS `length(filler1)=length(filler2)` from `test`.`t2` `ot` semi join (`test`.`t1` `it`) where (`test`.`it`.`a` = `test`.`ot`.`a`) +select +a, mid(filler1, 1,10), length(filler1)=length(filler2) +from t2 ot where a in (select a from t1 it); +a mid(filler1, 1,10) length(filler1)=length(filler2) +0 filler1234 1 +1 filler1234 1 +10 filler1234 1 +11 filler1234 1 +12 filler1234 1 +13 filler1234 1 +14 filler1234 1 +15 filler1234 1 +16 filler1234 1 +17 filler1234 1 +18 filler1234 1 +19 duplicate 1 +19 filler1234 1 +2 filler1234 1 +3 duplicate 1 +3 filler1234 1 +4 filler1234 1 +5 filler1234 1 +6 filler1234 1 +7 filler1234 1 +8 filler1234 1 +9 filler1234 1 +insert into t1 select a+20, 'filler123456', 'filler123456' from t0; +insert into t1 select a+20, 'filler123456', 'filler123456' from t0; +explain select +a, mid(filler1, 1,10), length(filler1)=length(filler2) as z +from t1 ot where a in (select a from t2 it); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE it NULL ALL NULL NULL NULL NULL 22 100.00 Start temporary +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 52 10.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot`.`a` AS `a`,substr(`test`.`ot`.`filler1`,1,10) AS `mid(filler1, 1,10)`,(length(`test`.`ot`.`filler1`) = length(`test`.`ot`.`filler2`)) AS `z` from `test`.`t1` `ot` semi join (`test`.`t2` `it`) where (`test`.`ot`.`a` = `test`.`it`.`a`) +select +a, mid(filler1, 1,10), length(filler1)=length(filler2) as z +from t1 ot where a in (select a from t2 it); +a mid(filler1, 1,10) z +0 filler1234 1 +1 filler1234 1 +10 filler1234 1 +11 filler1234 1 +12 filler1234 1 +13 filler1234 1 +14 filler1234 1 +15 filler1234 1 +16 filler1234 1 +17 filler1234 1 +18 duplicate 1 +18 filler1234 1 +19 filler1234 1 +2 duplicate 1 +2 filler1234 1 +3 filler1234 1 +4 filler1234 1 +5 filler1234 1 +6 filler1234 1 +7 filler1234 1 +8 filler1234 1 +9 filler1234 1 +explain select +a, mid(filler1, 1,10), length(filler1)=length(filler2) +from t2 ot where a in (select a from t1 it); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 22 100.00 Start temporary +1 SIMPLE it NULL ALL NULL NULL NULL NULL 52 10.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot`.`a` AS `a`,substr(`test`.`ot`.`filler1`,1,10) AS `mid(filler1, 1,10)`,(length(`test`.`ot`.`filler1`) = length(`test`.`ot`.`filler2`)) AS `length(filler1)=length(filler2)` from `test`.`t2` `ot` semi join (`test`.`t1` `it`) where (`test`.`it`.`a` = `test`.`ot`.`a`) +select +a, mid(filler1, 1,10), length(filler1)=length(filler2) +from t2 ot where a in (select a from t1 it); +a mid(filler1, 1,10) length(filler1)=length(filler2) +0 filler1234 1 +1 filler1234 1 +10 filler1234 1 +11 filler1234 1 +12 filler1234 1 +13 filler1234 1 +14 filler1234 1 +15 filler1234 1 +16 filler1234 1 +17 filler1234 1 +18 filler1234 1 +19 duplicate 1 +19 filler1234 1 +2 filler1234 1 +3 duplicate 1 +3 filler1234 1 +4 filler1234 1 +5 filler1234 1 +6 filler1234 1 +7 filler1234 1 +8 filler1234 1 +9 filler1234 1 +set @@join_buffer_size = @save_join_buffer_size; +drop table t1, t2; +create table t1 (a int, b int, key(a)); +create table t2 (a int, b int, key(a)); +create table t3 (a int, b int, key(a)); +insert into t1 select a,a from t0; +insert into t2 select a,a from t0; +insert into t3 select a,a from t0; +t2 and t3 must be use 'ref', not 'ALL': +explain select * +from t0 where a in +(select t2.a+t3.a from t1 left join (t2 join t3) on t2.a=t1.a and t3.a=t1.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 10 100.00 Start temporary +1 SIMPLE t1 NULL index a a 5 NULL 10 100.00 Using where; Using index; Using join buffer (hash join) +1 SIMPLE t2 NULL ref a a 5 test.t1.a 1 100.00 Using index +1 SIMPLE t3 NULL ref a a 5 test.t1.a 1 100.00 Using index; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a` from `test`.`t0` semi join (`test`.`t1` join `test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`a` = `test`.`t1`.`a`) and (`test`.`t3`.`a` = `test`.`t1`.`a`) and (`test`.`t0`.`a` = (`test`.`t1`.`a` + `test`.`t1`.`a`))) +drop table t0, t1,t2,t3; + +Test that neither MaterializeLookup strategy for semijoin, +nor subquery materialization is used when BLOBs are involved +(except when arguments of some functions). + +set @prefix_len = 6; +set @blob_len = 16; +set @suffix_len = @blob_len - @prefix_len; +create table t1_16 (a1 blob(16), a2 blob(16)); +create table t2_16 (b1 blob(16), b2 blob(16)); +create table t3_16 (c1 blob(16), c2 blob(16)); +insert into t1_16 values +(concat('1 - 00', repeat('x', @suffix_len)), concat('2 - 00', repeat('x', @suffix_len))); +insert into t1_16 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t1_16 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_16 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t2_16 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_16 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_16 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t3_16 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t3_16 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_16 values +(concat('1 - 04', repeat('x', @suffix_len)), concat('2 - 04', repeat('x', @suffix_len))); +explain select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select b1 from t2_16 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2_16 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Start temporary +1 SIMPLE t1_16 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_16`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_16`.`a2`,7) AS `left(a2,7)` from `test`.`t1_16` semi join (`test`.`t2_16`) where ((`test`.`t1_16`.`a1` = `test`.`t2_16`.`b1`) and (`test`.`t2_16`.`b1` > '0')) +select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select b1 from t2_16 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_16 +where (a1,a2) in (select b1, b2 from t2_16 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2_16 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Start temporary +1 SIMPLE t1_16 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_16`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_16`.`a2`,7) AS `left(a2,7)` from `test`.`t1_16` semi join (`test`.`t2_16`) where ((`test`.`t1_16`.`a2` = `test`.`t2_16`.`b2`) and (`test`.`t1_16`.`a1` = `test`.`t2_16`.`b1`) and (`test`.`t2_16`.`b1` > '0')) +select left(a1,7), left(a2,7) +from t1_16 +where (a1,a2) in (select b1, b2 from t2_16 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select substring(b1,1,16) from t2_16 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2_16 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Start temporary +1 SIMPLE t1_16 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_16`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_16`.`a2`,7) AS `left(a2,7)` from `test`.`t1_16` semi join (`test`.`t2_16`) where ((`test`.`t2_16`.`b1` > '0') and (`test`.`t1_16`.`a1` = substr(`test`.`t2_16`.`b1`,1,16))) +select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select substring(b1,1,16) from t2_16 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select group_concat(b1) from t2_16 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_16 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t2_16 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_16`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_16`.`a2`,7) AS `left(a2,7)` from `test`.`t1_16` where (`test`.`t1_16`.`a1`,(/* select#2 */ select group_concat(`test`.`t2_16`.`b1` separator ',') from `test`.`t2_16` group by `test`.`t2_16`.`b2` having ((`test`.`t1_16`.`a1`) = (group_concat(`test`.`t2_16`.`b1` separator ','))))) +select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select group_concat(b1) from t2_16 group by b2); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +set @@group_concat_max_len = 256; +explain select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select group_concat(b1) from t2_16 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_16 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t2_16 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_16`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_16`.`a2`,7) AS `left(a2,7)` from `test`.`t1_16` where (`test`.`t1_16`.`a1`,(/* select#2 */ select group_concat(`test`.`t2_16`.`b1` separator ',') from `test`.`t2_16` group by `test`.`t2_16`.`b2` having ((`test`.`t1_16`.`a1`) = (group_concat(`test`.`t2_16`.`b1` separator ','))))) +select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select group_concat(b1) from t2_16 group by b2); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +create table t1 (a1 char(8), a2 char(8)) charset latin1; +create table t2 (b1 char(8), b2 char(8)) charset latin1; +create table t3 (c1 char(8), c2 char(8)) charset latin1; +insert into t1 values ('1 - 00', '2 - 00'); +insert into t1 values ('1 - 01', '2 - 01'); +insert into t1 values ('1 - 02', '2 - 02'); +insert into t2 values ('1 - 01', '2 - 01'); +insert into t2 values ('1 - 01', '2 - 01'); +insert into t2 values ('1 - 02', '2 - 02'); +insert into t2 values ('1 - 02', '2 - 02'); +insert into t2 values ('1 - 03', '2 - 03'); +insert into t3 values ('1 - 01', '2 - 01'); +insert into t3 values ('1 - 02', '2 - 02'); +insert into t3 values ('1 - 03', '2 - 03'); +insert into t3 values ('1 - 04', '2 - 04'); +insert into t3 values ('1 - 05', '2 - 05'); +insert into t3 values ('1 - 06', '2 - 06'); +insert into t3 values ('1 - 07', '2 - 07'); +insert into t3 values ('1 - 08', '2 - 08'); +explain +select * from t1 +where concat(a1,'x') IN +(select left(a1,8) from t1_16 +where (a1, a2) IN +(select t2_16.b1, t2_16.b2 from t2_16, t2 +where t2.b2 = substring(t2_16.b2,1,6) and +t2.b1 IN (select c1 from t3 where c2 > '0'))); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Start temporary +1 SIMPLE t1_16 NULL ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t2_16 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 5 20.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` semi join (`test`.`t1_16` join `test`.`t2_16` join `test`.`t2` join `test`.`t3`) where ((`test`.`t2_16`.`b2` = `test`.`t1_16`.`a2`) and (`test`.`t2_16`.`b1` = `test`.`t1_16`.`a1`) and (`test`.`t3`.`c1` = `test`.`t2`.`b1`) and (`test`.`t2`.`b2` = substr(`test`.`t2_16`.`b2`,1,6)) and (`test`.`t3`.`c2` > '0') and (concat(`test`.`t1`.`a1`,'x') = left(`test`.`t1_16`.`a1`,8))) +drop table t1_16, t2_16, t3_16, t1, t2, t3; +set @blob_len = 512; +set @suffix_len = @blob_len - @prefix_len; +create table t1_512 (a1 blob(512), a2 blob(512)); +create table t2_512 (b1 blob(512), b2 blob(512)); +create table t3_512 (c1 blob(512), c2 blob(512)); +insert into t1_512 values +(concat('1 - 00', repeat('x', @suffix_len)), concat('2 - 00', repeat('x', @suffix_len))); +insert into t1_512 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t1_512 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_512 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t2_512 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_512 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_512 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t3_512 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t3_512 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_512 values +(concat('1 - 04', repeat('x', @suffix_len)), concat('2 - 04', repeat('x', @suffix_len))); +explain select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select b1 from t2_512 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2_512 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Start temporary +1 SIMPLE t1_512 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_512`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_512`.`a2`,7) AS `left(a2,7)` from `test`.`t1_512` semi join (`test`.`t2_512`) where ((`test`.`t1_512`.`a1` = `test`.`t2_512`.`b1`) and (`test`.`t2_512`.`b1` > '0')) +select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select b1 from t2_512 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_512 +where (a1,a2) in (select b1, b2 from t2_512 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2_512 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Start temporary +1 SIMPLE t1_512 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_512`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_512`.`a2`,7) AS `left(a2,7)` from `test`.`t1_512` semi join (`test`.`t2_512`) where ((`test`.`t1_512`.`a2` = `test`.`t2_512`.`b2`) and (`test`.`t1_512`.`a1` = `test`.`t2_512`.`b1`) and (`test`.`t2_512`.`b1` > '0')) +select left(a1,7), left(a2,7) +from t1_512 +where (a1,a2) in (select b1, b2 from t2_512 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select substring(b1,1,512) from t2_512 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2_512 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Start temporary +1 SIMPLE t1_512 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_512`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_512`.`a2`,7) AS `left(a2,7)` from `test`.`t1_512` semi join (`test`.`t2_512`) where ((`test`.`t2_512`.`b1` > '0') and (`test`.`t1_512`.`a1` = substr(`test`.`t2_512`.`b1`,1,512))) +select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select substring(b1,1,512) from t2_512 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select group_concat(b1) from t2_512 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_512 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t2_512 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_512`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_512`.`a2`,7) AS `left(a2,7)` from `test`.`t1_512` where (`test`.`t1_512`.`a1`,(/* select#2 */ select group_concat(`test`.`t2_512`.`b1` separator ',') from `test`.`t2_512` group by `test`.`t2_512`.`b2` having ((`test`.`t1_512`.`a1`) = (group_concat(`test`.`t2_512`.`b1` separator ','))))) +select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select group_concat(b1) from t2_512 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +Warning 1260 Row 4 was cut by GROUP_CONCAT() +Warning 1260 Row 5 was cut by GROUP_CONCAT() +Warning 1260 Row 6 was cut by GROUP_CONCAT() +Warning 1260 Row 7 was cut by GROUP_CONCAT() +Warning 1260 Row 8 was cut by GROUP_CONCAT() +Warning 1260 Row 9 was cut by GROUP_CONCAT() +set @@group_concat_max_len = 256; +explain select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select group_concat(b1) from t2_512 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_512 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t2_512 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_512`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_512`.`a2`,7) AS `left(a2,7)` from `test`.`t1_512` where (`test`.`t1_512`.`a1`,(/* select#2 */ select group_concat(`test`.`t2_512`.`b1` separator ',') from `test`.`t2_512` group by `test`.`t2_512`.`b2` having ((`test`.`t1_512`.`a1`) = (group_concat(`test`.`t2_512`.`b1` separator ','))))) +select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select group_concat(b1) from t2_512 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +Warning 1260 Row 4 was cut by GROUP_CONCAT() +Warning 1260 Row 5 was cut by GROUP_CONCAT() +Warning 1260 Row 6 was cut by GROUP_CONCAT() +Warning 1260 Row 7 was cut by GROUP_CONCAT() +Warning 1260 Row 8 was cut by GROUP_CONCAT() +Warning 1260 Row 9 was cut by GROUP_CONCAT() +drop table t1_512, t2_512, t3_512; +set @blob_len = 513; +set @suffix_len = @blob_len - @prefix_len; +create table t1_513 (a1 blob(513), a2 blob(513)); +create table t2_513 (b1 blob(513), b2 blob(513)); +create table t3_513 (c1 blob(513), c2 blob(513)); +insert into t1_513 values +(concat('1 - 00', repeat('x', @suffix_len)), concat('2 - 00', repeat('x', @suffix_len))); +insert into t1_513 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t1_513 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_513 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t2_513 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_513 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_513 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t3_513 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t3_513 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_513 values +(concat('1 - 04', repeat('x', @suffix_len)), concat('2 - 04', repeat('x', @suffix_len))); +explain select left(a1,7), left(a2,7) +from t1_513 +where a1 in (select b1 from t2_513 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2_513 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Start temporary +1 SIMPLE t1_513 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_513`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_513`.`a2`,7) AS `left(a2,7)` from `test`.`t1_513` semi join (`test`.`t2_513`) where ((`test`.`t1_513`.`a1` = `test`.`t2_513`.`b1`) and (`test`.`t2_513`.`b1` > '0')) +select left(a1,7), left(a2,7) +from t1_513 +where a1 in (select b1 from t2_513 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_513 +where (a1,a2) in (select b1, b2 from t2_513 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2_513 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Start temporary +1 SIMPLE t1_513 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_513`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_513`.`a2`,7) AS `left(a2,7)` from `test`.`t1_513` semi join (`test`.`t2_513`) where ((`test`.`t1_513`.`a2` = `test`.`t2_513`.`b2`) and (`test`.`t1_513`.`a1` = `test`.`t2_513`.`b1`) and (`test`.`t2_513`.`b1` > '0')) +select left(a1,7), left(a2,7) +from t1_513 +where (a1,a2) in (select b1, b2 from t2_513 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_513 +where a1 in (select substring(b1,1,513) from t2_513 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2_513 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Start temporary +1 SIMPLE t1_513 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_513`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_513`.`a2`,7) AS `left(a2,7)` from `test`.`t1_513` semi join (`test`.`t2_513`) where ((`test`.`t2_513`.`b1` > '0') and (`test`.`t1_513`.`a1` = substr(`test`.`t2_513`.`b1`,1,513))) +select left(a1,7), left(a2,7) +from t1_513 +where a1 in (select substring(b1,1,513) from t2_513 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_513 +where a1 in (select group_concat(b1) from t2_513 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_513 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t2_513 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_513`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_513`.`a2`,7) AS `left(a2,7)` from `test`.`t1_513` where (`test`.`t1_513`.`a1`,(/* select#2 */ select group_concat(`test`.`t2_513`.`b1` separator ',') from `test`.`t2_513` group by `test`.`t2_513`.`b2` having ((`test`.`t1_513`.`a1`) = (group_concat(`test`.`t2_513`.`b1` separator ','))))) +select left(a1,7), left(a2,7) +from t1_513 +where a1 in (select group_concat(b1) from t2_513 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +Warning 1260 Row 4 was cut by GROUP_CONCAT() +Warning 1260 Row 5 was cut by GROUP_CONCAT() +Warning 1260 Row 6 was cut by GROUP_CONCAT() +Warning 1260 Row 7 was cut by GROUP_CONCAT() +Warning 1260 Row 8 was cut by GROUP_CONCAT() +Warning 1260 Row 9 was cut by GROUP_CONCAT() +drop table t1_513, t2_513, t3_513; +set @blob_len = 1024; +set @suffix_len = @blob_len - @prefix_len; +create table t1_1024 (a1 blob(1024), a2 blob(1024)); +create table t2_1024 (b1 blob(1024), b2 blob(1024)); +create table t3_1024 (c1 blob(1024), c2 blob(1024)); +insert into t1_1024 values +(concat('1 - 00', repeat('x', @suffix_len)), concat('2 - 00', repeat('x', @suffix_len))); +insert into t1_1024 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t1_1024 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_1024 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t2_1024 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_1024 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_1024 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t3_1024 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t3_1024 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_1024 values +(concat('1 - 04', repeat('x', @suffix_len)), concat('2 - 04', repeat('x', @suffix_len))); +explain select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select b1 from t2_1024 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2_1024 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Start temporary +1 SIMPLE t1_1024 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1024`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1024`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1024` semi join (`test`.`t2_1024`) where ((`test`.`t1_1024`.`a1` = `test`.`t2_1024`.`b1`) and (`test`.`t2_1024`.`b1` > '0')) +select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select b1 from t2_1024 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_1024 +where (a1,a2) in (select b1, b2 from t2_1024 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2_1024 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Start temporary +1 SIMPLE t1_1024 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1024`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1024`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1024` semi join (`test`.`t2_1024`) where ((`test`.`t1_1024`.`a2` = `test`.`t2_1024`.`b2`) and (`test`.`t1_1024`.`a1` = `test`.`t2_1024`.`b1`) and (`test`.`t2_1024`.`b1` > '0')) +select left(a1,7), left(a2,7) +from t1_1024 +where (a1,a2) in (select b1, b2 from t2_1024 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select substring(b1,1,1024) from t2_1024 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2_1024 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Start temporary +1 SIMPLE t1_1024 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1024`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1024`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1024` semi join (`test`.`t2_1024`) where ((`test`.`t2_1024`.`b1` > '0') and (`test`.`t1_1024`.`a1` = substr(`test`.`t2_1024`.`b1`,1,1024))) +select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select substring(b1,1,1024) from t2_1024 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select group_concat(b1) from t2_1024 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_1024 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t2_1024 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1024`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1024`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1024` where (`test`.`t1_1024`.`a1`,(/* select#2 */ select group_concat(`test`.`t2_1024`.`b1` separator ',') from `test`.`t2_1024` group by `test`.`t2_1024`.`b2` having ((`test`.`t1_1024`.`a1`) = (group_concat(`test`.`t2_1024`.`b1` separator ','))))) +select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select group_concat(b1) from t2_1024 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +Warning 1260 Row 4 was cut by GROUP_CONCAT() +Warning 1260 Row 5 was cut by GROUP_CONCAT() +Warning 1260 Row 6 was cut by GROUP_CONCAT() +Warning 1260 Row 7 was cut by GROUP_CONCAT() +Warning 1260 Row 8 was cut by GROUP_CONCAT() +Warning 1260 Row 9 was cut by GROUP_CONCAT() +set @@group_concat_max_len = 256; +explain select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select group_concat(b1) from t2_1024 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_1024 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t2_1024 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1024`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1024`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1024` where (`test`.`t1_1024`.`a1`,(/* select#2 */ select group_concat(`test`.`t2_1024`.`b1` separator ',') from `test`.`t2_1024` group by `test`.`t2_1024`.`b2` having ((`test`.`t1_1024`.`a1`) = (group_concat(`test`.`t2_1024`.`b1` separator ','))))) +select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select group_concat(b1) from t2_1024 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +Warning 1260 Row 4 was cut by GROUP_CONCAT() +Warning 1260 Row 5 was cut by GROUP_CONCAT() +Warning 1260 Row 6 was cut by GROUP_CONCAT() +Warning 1260 Row 7 was cut by GROUP_CONCAT() +Warning 1260 Row 8 was cut by GROUP_CONCAT() +Warning 1260 Row 9 was cut by GROUP_CONCAT() +drop table t1_1024, t2_1024, t3_1024; +set @blob_len = 1025; +set @suffix_len = @blob_len - @prefix_len; +create table t1_1025 (a1 blob(1025), a2 blob(1025)); +create table t2_1025 (b1 blob(1025), b2 blob(1025)); +create table t3_1025 (c1 blob(1025), c2 blob(1025)); +insert into t1_1025 values +(concat('1 - 00', repeat('x', @suffix_len)), concat('2 - 00', repeat('x', @suffix_len))); +insert into t1_1025 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t1_1025 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_1025 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t2_1025 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_1025 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_1025 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t3_1025 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t3_1025 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_1025 values +(concat('1 - 04', repeat('x', @suffix_len)), concat('2 - 04', repeat('x', @suffix_len))); +explain select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select b1 from t2_1025 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2_1025 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Start temporary +1 SIMPLE t1_1025 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1025`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1025`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1025` semi join (`test`.`t2_1025`) where ((`test`.`t1_1025`.`a1` = `test`.`t2_1025`.`b1`) and (`test`.`t2_1025`.`b1` > '0')) +select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select b1 from t2_1025 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_1025 +where (a1,a2) in (select b1, b2 from t2_1025 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2_1025 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Start temporary +1 SIMPLE t1_1025 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1025`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1025`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1025` semi join (`test`.`t2_1025`) where ((`test`.`t1_1025`.`a2` = `test`.`t2_1025`.`b2`) and (`test`.`t1_1025`.`a1` = `test`.`t2_1025`.`b1`) and (`test`.`t2_1025`.`b1` > '0')) +select left(a1,7), left(a2,7) +from t1_1025 +where (a1,a2) in (select b1, b2 from t2_1025 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select substring(b1,1,1025) from t2_1025 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2_1025 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Start temporary +1 SIMPLE t1_1025 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1025`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1025`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1025` semi join (`test`.`t2_1025`) where ((`test`.`t2_1025`.`b1` > '0') and (`test`.`t1_1025`.`a1` = substr(`test`.`t2_1025`.`b1`,1,1025))) +select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select substring(b1,1,1025) from t2_1025 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select group_concat(b1) from t2_1025 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_1025 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t2_1025 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1025`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1025`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1025` where (`test`.`t1_1025`.`a1`,(/* select#2 */ select group_concat(`test`.`t2_1025`.`b1` separator ',') from `test`.`t2_1025` group by `test`.`t2_1025`.`b2` having ((`test`.`t1_1025`.`a1`) = (group_concat(`test`.`t2_1025`.`b1` separator ','))))) +select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select group_concat(b1) from t2_1025 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +Warning 1260 Row 4 was cut by GROUP_CONCAT() +Warning 1260 Row 5 was cut by GROUP_CONCAT() +Warning 1260 Row 6 was cut by GROUP_CONCAT() +Warning 1260 Row 7 was cut by GROUP_CONCAT() +Warning 1260 Row 8 was cut by GROUP_CONCAT() +Warning 1260 Row 9 was cut by GROUP_CONCAT() +set @@group_concat_max_len = 256; +explain select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select group_concat(b1) from t2_1025 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_1025 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t2_1025 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1025`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1025`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1025` where (`test`.`t1_1025`.`a1`,(/* select#2 */ select group_concat(`test`.`t2_1025`.`b1` separator ',') from `test`.`t2_1025` group by `test`.`t2_1025`.`b2` having ((`test`.`t1_1025`.`a1`) = (group_concat(`test`.`t2_1025`.`b1` separator ','))))) +select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select group_concat(b1) from t2_1025 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +Warning 1260 Row 4 was cut by GROUP_CONCAT() +Warning 1260 Row 5 was cut by GROUP_CONCAT() +Warning 1260 Row 6 was cut by GROUP_CONCAT() +Warning 1260 Row 7 was cut by GROUP_CONCAT() +Warning 1260 Row 8 was cut by GROUP_CONCAT() +Warning 1260 Row 9 was cut by GROUP_CONCAT() +drop table t1_1025, t2_1025, t3_1025; +# +# WL#5561: Enable semi join transformation with outer join. +# +CREATE TABLE ot1(a INT); +CREATE TABLE ot2(a INT); +CREATE TABLE ot3(a INT); +CREATE TABLE it1(a INT); +CREATE TABLE it2(a INT); +CREATE TABLE it3(a INT); +INSERT INTO ot1 VALUES(0),(1),(2),(3),(4),(5),(6),(7); +INSERT INTO ot2 VALUES(0),(2),(4),(6); +INSERT INTO ot3 VALUES(0),(3),(6); +INSERT INTO it1 VALUES(0),(1),(2),(3),(4),(5),(6),(7); +INSERT INTO it2 VALUES(0),(2),(4),(6); +INSERT INTO it3 VALUES(0),(3),(6); +# Test cases, Subquery Pattern 1 +# Example SQ1.1: +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE ot1.a IN (SELECT a FROM it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE it3 NULL ALL NULL NULL NULL NULL 3 100.00 Start temporary +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; End temporary; Using join buffer (hash join) +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` left join `test`.`ot2` on((`test`.`ot2`.`a` = `test`.`it3`.`a`)) semi join (`test`.`it3`) where (`test`.`ot1`.`a` = `test`.`it3`.`a`) +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE ot1.a IN (SELECT a FROM it3); +a a +0 0 +3 NULL +6 6 +# Example SQ1.2: +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE COALESCE(ot2.a,0) IN (SELECT a FROM it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE it3 NULL ALL NULL NULL NULL NULL 3 100.00 Start temporary +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 Using join buffer (hash join) +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` left join `test`.`ot2` on((`test`.`ot2`.`a` = `test`.`ot1`.`a`)) semi join (`test`.`it3`) where (coalesce(`test`.`ot2`.`a`,0) = `test`.`it3`.`a`) +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE COALESCE(ot2.a,0) IN (SELECT a FROM it3); +a a +0 0 +1 NULL +3 NULL +5 NULL +6 6 +7 NULL +# Example SQ1.3: +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE (ot1.a,ot2.a) IN (SELECT a, a FROM it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE it3 NULL ALL NULL NULL NULL NULL 3 100.00 Start temporary +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; Using join buffer (hash join) +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` join `test`.`ot2` semi join (`test`.`it3`) where ((`test`.`ot2`.`a` = `test`.`it3`.`a`) and (`test`.`ot1`.`a` = `test`.`it3`.`a`)) +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE (ot1.a,ot2.a) IN (SELECT a, a FROM it3); +a a +0 0 +6 6 +# More test cases +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 +WHERE ot1.a IN (SELECT a FROM it3); +a a +0 0 +3 NULL +6 6 +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 +WHERE ot1.a IN (SELECT a+0 FROM it3); +a a +0 0 +3 NULL +6 6 +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 +WHERE COALESCE(ot2.a,0) IN (SELECT a FROM it3); +a a +0 0 +1 NULL +3 NULL +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE COALESCE(ot2.a,0) IN (SELECT a+0 FROM it3); +a a +0 0 +1 NULL +3 NULL +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 +WHERE (ot1.a,ot2.a) IN (SELECT a, a FROM it3); +a a +0 0 +6 6 +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +LEFT JOIN ot3 ON ot1.a=ot3.a +WHERE ot1.a IN (SELECT a FROM it3); +a a a +0 0 0 +3 NULL 3 +6 6 6 +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +LEFT JOIN ot3 ON ot1.a=ot3.a +WHERE COALESCE(ot2.a,0) IN (SELECT a FROM it3); +a a a +0 0 0 +1 NULL NULL +3 NULL 3 +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +LEFT JOIN ot3 ON ot1.a=ot3.a +WHERE COALESCE(ot3.a,0) IN (SELECT a FROM it3); +a a a +0 0 0 +1 NULL NULL +2 2 NULL +3 NULL 3 +4 4 NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +LEFT JOIN ot3 ON ot2.a=ot3.a +WHERE ot1.a IN (SELECT a FROM it3); +a a a +0 0 0 +3 NULL NULL +6 6 6 +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +LEFT JOIN ot3 ON ot2.a=ot3.a +WHERE COALESCE(ot2.a,0) IN (SELECT a FROM it3); +a a a +0 0 0 +1 NULL NULL +3 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +LEFT JOIN ot3 ON ot2.a=ot3.a +WHERE COALESCE(ot3.a,0) IN (SELECT a FROM it3); +a a a +0 0 0 +1 NULL NULL +2 2 NULL +3 NULL NULL +4 4 NULL +5 NULL NULL +6 6 6 +7 NULL NULL +# Test cases, Subquery Pattern 2 +# Example SQ2.1: +explain SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE it3 NULL ALL NULL NULL NULL NULL 3 100.00 Start temporary +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; End temporary; Using join buffer (hash join) +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` join `test`.`ot2` semi join (`test`.`it3`) where ((`test`.`ot1`.`a` = `test`.`it3`.`a`) and (`test`.`ot2`.`a` = `test`.`it3`.`a`)) +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3); +a a +0 0 +6 6 +# Example SQ2.2: +explain SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it2) +AND ot2.a IN (SELECT a FROM it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE it3 NULL ALL NULL NULL NULL NULL 3 100.00 Start temporary +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; Using join buffer (hash join) +1 SIMPLE it2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; Using join buffer (hash join) +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` join `test`.`ot2` semi join (`test`.`it2`) semi join (`test`.`it3`) where ((`test`.`ot2`.`a` = `test`.`it3`.`a`) and (`test`.`it2`.`a` = `test`.`it3`.`a`) and (`test`.`ot1`.`a` = `test`.`it3`.`a`)) +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it2) +AND ot2.a IN (SELECT a FROM it3); +a a +0 0 +6 6 +# More test cases +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it3); +a a +0 0 +6 6 +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it3); +a a +0 0 +6 6 +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a+0 AND ot2.a IN (SELECT a FROM it3); +a a +0 0 +6 6 +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot2.a IN (SELECT a+0 FROM it3); +a a +0 0 +6 6 +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it2) +AND ot2.a IN (SELECT a+0 FROM it3); +a a +0 0 +6 6 +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3) +JOIN ot3 ON ot2.a=ot3.a AND ot3.a IN (SELECT a FROM it3); +a a a +0 0 0 +6 6 6 +# Test cases, Subquery Pattern 3 +# Example SQ3.1: +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 Start temporary +1 SIMPLE it3 NULL ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (hash join) +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` semi join (`test`.`it3`)) on(((`test`.`it3`.`a` = `test`.`ot1`.`a`) and (`test`.`ot2`.`a` = `test`.`ot1`.`a`))) where true +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3); +a a +0 0 +1 NULL +2 NULL +3 NULL +4 NULL +5 NULL +6 6 +7 NULL +# Example SQ3.2: +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot2.a IN (SELECT a FROM it2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 Start temporary +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (hash join) +1 SIMPLE it2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` semi join (`test`.`it2`)) on(((`test`.`ot2`.`a` = `test`.`ot1`.`a`) and (`test`.`it2`.`a` = `test`.`ot1`.`a`))) where true +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot2.a IN (SELECT a FROM it2); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +# Example SQ3.3 +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1) +AND ot2.a IN (SELECT a FROM it2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 Start temporary +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (hash join) +1 SIMPLE it2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (hash join) +1 SIMPLE it1 NULL ALL NULL NULL NULL NULL 8 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` semi join (`test`.`it1`) semi join (`test`.`it2`)) on(((`test`.`ot2`.`a` = `test`.`ot1`.`a`) and (`test`.`it2`.`a` = `test`.`ot1`.`a`) and (`test`.`it1`.`a` = `test`.`ot1`.`a`))) where true +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1) +AND ot2.a IN (SELECT a FROM it2); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +# Example SQ3.4 +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND +(ot1.a, ot2.a) IN (SELECT it1.a, it2.a +FROM it1 JOIN it2 ON it1.a=it2.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 Start temporary +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (hash join) +1 SIMPLE it2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (hash join) +1 SIMPLE it1 NULL ALL NULL NULL NULL NULL 8 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` semi join (`test`.`it1` join `test`.`it2`)) on(((`test`.`ot2`.`a` = `test`.`ot1`.`a`) and (`test`.`it2`.`a` = `test`.`ot1`.`a`) and (`test`.`it1`.`a` = `test`.`ot1`.`a`))) where true +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND +(ot1.a, ot2.a) IN (SELECT it1.a, it2.a +FROM it1 JOIN it2 ON it1.a=it2.a); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +# More test cases +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it3); +a a +0 0 +1 NULL +2 NULL +3 NULL +4 NULL +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it3); +a a +0 0 +1 NULL +2 NULL +3 NULL +4 NULL +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 AND ot2.a IN (SELECT a FROM it2); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot2.a IN (SELECT a+0 FROM it2); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a+0 FROM it1) +AND ot2.a IN (SELECT a+0 FROM it2); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 AND +(ot1.a, ot2.a) IN (SELECT it1.a+0, it2.a+0 +FROM it1 JOIN it2 ON it1.a=it2.a); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +EXPLAIN FORMAT=tree SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3) +LEFT JOIN ot3 ON ot2.a=ot3.a AND ot3.a IN (SELECT a FROM it3); +EXPLAIN +-> Remove duplicate (ot1, ot2, ot3) rows using temporary table (weedout) (cost=88.33 rows=864) + -> Left hash join (ot3.a = ot2.a), (it3.a = ot2.a) (cost=88.33 rows=864) + -> Left hash join (it3.a = ot1.a), (ot2.a = ot1.a) (cost=12.10 rows=96) + -> Table scan on ot1 (cost=1.30 rows=8) + -> Hash + -> Inner hash join (no condition) (cost=2.00 rows=12) + -> Table scan on ot2 (cost=0.11 rows=4) + -> Hash + -> Table scan on it3 (cost=0.30 rows=3) + -> Hash + -> Inner hash join (no condition) (cost=1.43 rows=9) + -> Table scan on it3 (cost=0.03 rows=3) + -> Hash + -> Table scan on ot3 (cost=0.03 rows=3) + +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3) +LEFT JOIN ot3 ON ot2.a=ot3.a AND ot3.a IN (SELECT a FROM it3); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it3) +LEFT JOIN ot3 ON ot2.a=ot3.a+0 AND ot3.a IN (SELECT a FROM it3); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +# Test cases, Subquery Pattern 4 +# Example SQ4.1: +explain SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 Start temporary +1 SIMPLE it1 NULL ALL NULL NULL NULL NULL 8 100.00 Using where; Using join buffer (hash join) +1 SIMPLE ot3 NULL ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (hash join) +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a`,`test`.`ot3`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` join `test`.`ot3` semi join (`test`.`it1`)) on(((`test`.`it1`.`a` = `test`.`ot1`.`a`) and (`test`.`ot3`.`a` = `test`.`ot1`.`a`) and (`test`.`ot2`.`a` = `test`.`ot1`.`a`))) where true +SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +# Example SQ4.2: +explain SELECT * +FROM ot1 +JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot3 NULL ALL NULL NULL NULL NULL 3 100.00 Start temporary +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; Using join buffer (hash join) +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; Using join buffer (hash join) +1 SIMPLE it1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a`,`test`.`ot3`.`a` AS `a` from `test`.`ot1` join `test`.`ot2` join `test`.`ot3` semi join (`test`.`it1`) where ((`test`.`ot2`.`a` = `test`.`ot3`.`a`) and (`test`.`ot1`.`a` = `test`.`ot3`.`a`) and (`test`.`it1`.`a` = `test`.`ot3`.`a`)) +SELECT * +FROM ot1 +JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +6 6 6 +# Example SQ4.3: +explain SELECT * +FROM ot1 +JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Start temporary +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; Using join buffer (hash join) +1 SIMPLE it1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; End temporary; Using join buffer (hash join) +1 SIMPLE ot3 NULL ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a`,`test`.`ot3`.`a` AS `a` from `test`.`ot1` join `test`.`ot2` left join `test`.`ot3` on((`test`.`ot3`.`a` = `test`.`ot2`.`a`)) semi join (`test`.`it1`) where ((`test`.`ot1`.`a` = `test`.`ot2`.`a`) and (`test`.`it1`.`a` = `test`.`ot2`.`a`)) +SELECT * +FROM ot1 +JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +2 2 NULL +4 4 NULL +6 6 6 +# Example SQ4.4: +explain SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 Start temporary +1 SIMPLE it1 NULL ALL NULL NULL NULL NULL 8 100.00 Using where; Using join buffer (hash join) +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (hash join) +1 SIMPLE ot3 NULL ALL NULL NULL NULL NULL 3 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a`,`test`.`ot3`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` left join `test`.`ot3` on((`test`.`ot3`.`a` = `test`.`it1`.`a`)) semi join (`test`.`it1`)) on(((`test`.`it1`.`a` = `test`.`ot1`.`a`) and (`test`.`ot2`.`a` = `test`.`ot1`.`a`))) where true +SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +1 NULL NULL +2 2 NULL +3 NULL NULL +4 4 NULL +5 NULL NULL +6 6 6 +7 NULL NULL +# More test cases +SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a+0) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it1); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 +JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a+0) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +6 6 6 +SELECT * +FROM ot1 +JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +6 6 6 +SELECT * +FROM ot1 +JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it1); +a a a +0 0 0 +6 6 6 +SELECT * +FROM ot1 +JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a+0) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +2 2 NULL +4 4 NULL +6 6 6 +SELECT * +FROM ot1 +JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +2 2 NULL +4 4 NULL +6 6 6 +SELECT * +FROM ot1 +JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it1); +a a a +0 0 0 +2 2 NULL +4 4 NULL +6 6 6 +SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a+0) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +1 NULL NULL +2 2 NULL +3 NULL NULL +4 4 NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +1 NULL NULL +2 2 NULL +3 NULL NULL +4 4 NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it1); +a a a +0 0 0 +1 NULL NULL +2 2 NULL +3 NULL NULL +4 4 NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1) +LEFT JOIN +ot1 AS ot4 +ON ot2.a=ot4.a; +a a a a +0 0 0 0 +1 NULL NULL NULL +2 2 NULL 2 +3 NULL NULL NULL +4 4 NULL 4 +5 NULL NULL NULL +6 6 6 6 +7 NULL NULL NULL +SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a +LEFT JOIN ot1 AS ot4 ON ot3.a=ot4.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a a +0 0 0 0 +1 NULL NULL NULL +2 2 NULL NULL +3 NULL NULL NULL +4 4 NULL NULL +5 NULL NULL NULL +6 6 6 6 +7 NULL NULL NULL +DROP TABLE ot1,ot2,ot3,it1,it2,it3; +CREATE TABLE t ( +a INTEGER DEFAULT NULL +) ENGINE=InnoDB; +INSERT INTO t VALUES (1); +CREATE TABLE t2 ( +a INTEGER DEFAULT NULL +) ENGINE=InnoDB; +INSERT INTO t2 VALUES (1),(1); +CREATE TABLE t4 ( +a INTEGER DEFAULT NULL +) ENGINE=InnoDB; +INSERT INTO t4 VALUES (1),(1); +CREATE TABLE v ( +a INTEGER DEFAULT NULL +) ENGINE=InnoDB; +INSERT INTO v VALUES (1),(1); +explain SELECT * +FROM t AS t1 +LEFT JOIN +(t2 +LEFT JOIN t AS t3 +ON t3.a IN (SELECT a FROM t AS it) +JOIN t4 +ON t4.a=100 +) +ON TRUE +WHERE t1.a IN (SELECT * FROM v AS it2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +2 SIMPLE it2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using join buffer (hash join) +2 SIMPLE it NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t4`.`a` AS `a` from `test`.`t` `t1` left join (`test`.`t2` left join (`test`.`t` `t3` semi join (`test`.`t` `it`)) on(((`test`.`it`.`a` = `test`.`t3`.`a`))) join `test`.`t4`) on(((`test`.`t4`.`a` = 100))) semi join (`test`.`v` `it2`) where (`test`.`it2`.`a` = `test`.`t1`.`a`) +SELECT * +FROM t AS t1 +LEFT JOIN +(t2 +LEFT JOIN t AS t3 +ON t3.a IN (SELECT a FROM t AS it) +JOIN t4 +ON t4.a=100 +) +ON TRUE +WHERE t1.a IN (SELECT * FROM v AS it2); +a a a a +1 NULL NULL NULL +DROP TABLE t,t2,t4,v; +# End of WL#5561 +# +# Bug#48868: Left outer join in subquery causes segmentation fault in +# make_join_select. +# +CREATE TABLE t1 (i INTEGER); +INSERT INTO t1 VALUES (1); +INSERT INTO t1 VALUES (2); +CREATE TABLE t2 (i INTEGER); +INSERT INTO t2 VALUES(1); +CREATE TABLE t3 (i INTEGER); +INSERT INTO t3 VALUES (1); +INSERT INTO t3 VALUES (2); +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t2.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +1 +DROP TABLE t1, t2, t3; + +Bug#37899: Wrongly checked optimization prerequisite caused failed +assertion. + +CREATE TABLE t1 ( +`pk` int(11), +`varchar_nokey` varchar(5) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES +(1,'qk'),(2,'j'),(3,'aew'); +SELECT * +FROM t1 +WHERE varchar_nokey IN ( +SELECT +varchar_nokey +FROM +t1 +) XOR pk = 30; +pk varchar_nokey +1 qk +2 j +3 aew +drop table t1; +# +# BUG#41842: Semi-join materialization strategy crashes when the upper query has HAVING +# +CREATE TABLE t1 ( +pk int(11) NOT NULL AUTO_INCREMENT, +int_nokey int(11) NOT NULL, +time_key time NOT NULL, +datetime_key datetime NOT NULL, +datetime_nokey datetime NOT NULL, +varchar_key varchar(1) NOT NULL, +varchar_nokey varchar(1) NOT NULL, +PRIMARY KEY (pk), +KEY time_key (time_key), +KEY datetime_key (datetime_key), +KEY varchar_key (varchar_key) +) ENGINE=MyISaM; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES +(1,0, '00:16:10','2008-09-03 14:25:40','2008-09-03 14:25:40','h','h'), +(2,7, '00:00:00','2001-01-13 00:00:00','2001-01-13 00:00:00','',''), +(3,0, '00:00:00','0000-00-00 00:00:00','0000-00-00 00:00:00','x','x'), +(4,2, '16:29:24','2000-10-16 01:39:08','2000-10-16 01:39:08','w','w'), +(5,1, '09:23:32','0000-00-00 00:00:00','0000-00-00 00:00:00','p','p'), +(6,3, '00:00:00','2007-12-02 00:00:00','2007-12-02 00:00:00','o','o'), +(7,3, '00:00:00','2008-09-11 00:00:00','2008-09-11 00:00:00','',''), +(8,0, '13:59:04','0000-00-00 00:00:00','0000-00-00 00:00:00','s','s'), +(9,7, '09:01:06','0000-00-00 00:00:00','0000-00-00 00:00:00','d','d'), +(10,5,'00:00:00','0000-00-00 00:00:00','0000-00-00 00:00:00','n','n'), +(11,0,'21:06:46','0000-00-00 00:00:00','0000-00-00 00:00:00','o','o'), +(12,2,'00:00:00','0000-00-00 00:00:00','0000-00-00 00:00:00','',''), +(13,6,'14:45:34','2003-07-28 02:34:08','2003-07-28 02:34:08','w','w'), +(14,1,'15:04:12','0000-00-00 00:00:00','0000-00-00 00:00:00','o','o'), +(15,0,'00:00:00','0000-00-00 00:00:00','0000-00-00 00:00:00','x','x'), +(16,0,'15:55:23','2004-03-17 00:32:27','2004-03-17 00:32:27','p','p'), +(17,1,'16:30:00','2004-12-27 19:20:00','2004-12-27 19:20:00','d','d'), +(18,0,'00:00:00','0000-00-00 00:00:00','0000-00-00 00:00:00','h','h'), +(19,0,'14:13:26','2008-11-09 05:53:48','2008-11-09 05:53:48','o','o'), +(20,0,'00:00:00','2009-10-11 06:58:04','2009-10-11 06:58:04','k','k'); +Warnings: +Warning 1264 Out of range value for column 'datetime_key' at row 3 +Warning 1264 Out of range value for column 'datetime_nokey' at row 3 +Warning 1264 Out of range value for column 'datetime_key' at row 5 +Warning 1264 Out of range value for column 'datetime_nokey' at row 5 +Warning 1264 Out of range value for column 'datetime_key' at row 8 +Warning 1264 Out of range value for column 'datetime_nokey' at row 8 +Warning 1264 Out of range value for column 'datetime_key' at row 9 +Warning 1264 Out of range value for column 'datetime_nokey' at row 9 +Warning 1264 Out of range value for column 'datetime_key' at row 10 +Warning 1264 Out of range value for column 'datetime_nokey' at row 10 +Warning 1264 Out of range value for column 'datetime_key' at row 11 +Warning 1264 Out of range value for column 'datetime_nokey' at row 11 +Warning 1264 Out of range value for column 'datetime_key' at row 12 +Warning 1264 Out of range value for column 'datetime_nokey' at row 12 +Warning 1264 Out of range value for column 'datetime_key' at row 14 +Warning 1264 Out of range value for column 'datetime_nokey' at row 14 +Warning 1264 Out of range value for column 'datetime_key' at row 15 +Warning 1264 Out of range value for column 'datetime_nokey' at row 15 +Warning 1264 Out of range value for column 'datetime_key' at row 18 +Warning 1264 Out of range value for column 'datetime_nokey' at row 18 +CREATE TABLE t2 ( +pk int(11) NOT NULL AUTO_INCREMENT, +int_nokey int(11) NOT NULL, +time_key time NOT NULL, +datetime_key datetime NOT NULL, +datetime_nokey datetime NOT NULL, +varchar_key varchar(1) NOT NULL, +varchar_nokey varchar(1) NOT NULL, +PRIMARY KEY (pk), +KEY time_key (time_key), +KEY datetime_key (datetime_key), +KEY varchar_key (varchar_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT IGNORE INTO t2 VALUES +(10,0,'19:39:13','0000-00-00 00:00:00','0000-00-00 00:00:00','g','g'), +(11,8,'03:43:53','0000-00-00 00:00:00','0000-00-00 00:00:00','b','b'); +Warnings: +Warning 1264 Out of range value for column 'datetime_key' at row 1 +Warning 1264 Out of range value for column 'datetime_nokey' at row 1 +Warning 1264 Out of range value for column 'datetime_key' at row 2 +Warning 1264 Out of range value for column 'datetime_nokey' at row 2 +SELECT OUTR.datetime_nokey AS X FROM t1 AS OUTR +WHERE +OUTR.varchar_nokey IN (SELECT +INNR . varchar_nokey AS Y +FROM t2 AS INNR +WHERE +INNR . datetime_key >= INNR . time_key OR +INNR . pk = INNR . int_nokey +) +AND OUTR . varchar_nokey <= 'w' +HAVING X > '2012-12-12'; +X +drop table t1, t2; + +Bug#46797 "Crash in fix_semijoin_strategies_for_picked_join_order +with semijoin=on" + +CREATE TABLE t1 ( +varchar_key varchar(1) DEFAULT NULL, +KEY varchar_key (varchar_key) +); +CREATE TABLE t2 ( +varchar_key varchar(1) DEFAULT NULL, +KEY varchar_key (varchar_key) +); +INSERT INTO t2 VALUES +(NULL),(NULL),(NULL),(NULL),('a'),('a'),('a'),('b'),('b'),('b'),('b'),('c'), +('c'),('c'),('c'),('c'),('c'),('c'),('d'),('d'),('d'),('d'),('d'),('d'),('e'), +('e'),('e'),('e'),('e'),('e'),('f'),('f'),('f'),('g'),('g'),('h'),('h'),('h'), +('h'),('i'),('j'),('j'),('j'),('k'),('k'),('l'),('l'),('m'),('m'),('m'),('m'), +('n'),('n'),('n'),('o'),('o'),('o'),('p'),('p'),('p'),('q'),('q'),('q'),('r'), +('r'),('r'),('r'),('s'),('s'),('s'),('s'),('t'),('t'),('t'),('t'),('u'),('u'), +('u'),('u'),('v'),('v'),('v'),('v'),('w'),('w'),('w'),('w'),('w'),('w'),('x'), +('x'),('x'),('y'),('y'),('y'),('y'),('z'),('z'),('z'),('z'); +CREATE TABLE t3 ( +varchar_key varchar(1) DEFAULT NULL, +KEY varchar_key (varchar_key) +) ENGINE=MyISAM DEFAULT CHARSET=latin1; +INSERT INTO t3 VALUES +(NULL),('c'),('d'),('e'),('f'),('h'),('j'),('k'),('k'),('m'),('m'),('m'), +('n'),('o'),('r'),('t'),('t'),('u'),('w'),('y'); +SELECT varchar_key FROM t3 +WHERE (SELECT varchar_key FROM t3 +WHERE (varchar_key,varchar_key) +IN (SELECT t1.varchar_key, t2 .varchar_key +FROM t1 RIGHT JOIN t2 ON t1.varchar_key +) +); +varchar_key +DROP TABLE t1, t2, t3; +# +# Bug#46556 Returning incorrect, empty results for some IN subqueries +# w/semijoin=on +# +CREATE TABLE t0 ( +pk INTEGER, +vkey VARCHAR(1), +vnokey VARCHAR(1), +PRIMARY KEY (pk), +KEY vkey(vkey) +) charset utf8mb4; +INSERT INTO t0 +VALUES (1,'g','g'), (2,'v','v'), (3,'t','t'), (4,'u','u'), (5,'n','n'); +EXPLAIN SELECT vkey FROM t0 WHERE pk IN +(SELECT t1.pk FROM t0 t1 JOIN t0 t2 ON t2.vkey = t1.vnokey); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index vkey vkey 7 NULL 5 100.00 Using index; Start temporary +1 SIMPLE t1 NULL ALL PRIMARY NULL NULL NULL 5 20.00 Using where; Using join buffer (hash join) +1 SIMPLE t0 NULL eq_ref PRIMARY PRIMARY 4 test.t1.pk 1 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`vkey` AS `vkey` from `test`.`t0` `t1` join `test`.`t0` semi join (`test`.`t0` `t2`) where ((`test`.`t1`.`vnokey` = `test`.`t2`.`vkey`) and (`test`.`t0`.`pk` = `test`.`t1`.`pk`)) +SELECT vkey FROM t0 WHERE pk IN +(SELECT t1.pk FROM t0 t1 JOIN t0 t2 ON t2.vkey = t1.vnokey); +vkey +g +n +t +u +v +DROP TABLE t0; +# End of bug#46556 + +Bug#48834: Procedure with view + subquery + semijoin=on +crashes on second call. + +CREATE TABLE t1 ( t1field integer, primary key (t1field)); +CREATE TABLE t2 ( t2field integer, primary key (t2field)); +CREATE VIEW v1 AS +SELECT t1field as v1field +FROM t1 A +WHERE A.t1field IN (SELECT t1field FROM t2 ); +CREATE VIEW v2 AS +SELECT t2field as v2field +FROM t2 A +WHERE A.t2field IN (SELECT t2field FROM t2 ); +CREATE PROCEDURE p1 () +BEGIN +SELECT v1field +FROM v1 +WHERE v1field IN ( SELECT v2field as vf_inner FROM v2 ); +END| +INSERT INTO t1 VALUES (1),(2),(3); +INSERT INTO t2 VALUES (2),(3),(4); +CALL p1; +v1field +2 +3 +CALL p1; +v1field +2 +3 +DROP TABLE t1,t2; +DROP VIEW v1,v2; +DROP PROCEDURE p1; +# End of BUG#48834 +# +# Bug#46692 "Crash occurring on queries with nested FROM subqueries +# using materialization." +# +CREATE TABLE t1 ( +pk INTEGER PRIMARY KEY, +int_key INTEGER, +KEY int_key(int_key) +); +INSERT INTO t1 VALUES (10,186),(11,NULL),(12,2),(13,3),(14,0),(15,133),(16,1); +CREATE TABLE t2 ( +pk INTEGER PRIMARY KEY, +int_key INTEGER, +KEY int_key(int_key) +); +INSERT INTO t2 VALUES (1,7),(2,2); +SELECT * FROM t1 WHERE (140, 4) IN +(SELECT t2.int_key, t2 .pk FROM t2 STRAIGHT_JOIN t1 ON t2.int_key); +pk int_key +DROP TABLE t1, t2; +# +# Bug#42353 "SELECT ... WHERE oe IN (SELECT w/ LEFT JOIN) query +# causes crash." +# +CREATE TABLE t1 ( +pk INTEGER PRIMARY KEY, +int_nokey INTEGER, +int_key INTEGER, +date_key DATE, +datetime_nokey DATETIME, +varchar_nokey VARCHAR(1) +); +CREATE TABLE t2 ( +date_nokey DATE +); +CREATE TABLE t3 ( +pk INTEGER PRIMARY KEY, +int_nokey INTEGER, +date_key date, +varchar_key VARCHAR(1), +varchar_nokey VARCHAR(1), +KEY date_key (date_key) +); +SELECT date_key FROM t1 +WHERE (int_key, int_nokey) +IN (SELECT t3.int_nokey, t3.pk +FROM t2 LEFT JOIN t3 ON (t2.date_nokey < t3.date_key) +WHERE t3.varchar_key <= t3.varchar_nokey OR t3.int_nokey <= t3.pk +) +AND (varchar_nokey <> 'f' OR NOT int_key < 7); +date_key +# +# Bug#45933 "Crash in optimize_semijoin_nests on JOIN in subquery +# + AND in outer query". +# +INSERT INTO t1 VALUES (10,7,5,'2009-06-16','2002-04-10 14:25:30','w'), +(11,7,0,'0000-00-00','0000-00-00 00:00:00','s'), +(12,4,0,'2003-07-14','2006-09-14 04:01:02','y'), +(13,0,4,'2002-07-25','0000-00-00 00:00:00','c'), +(14,1,8,'2007-07-03','0000-00-00 00:00:00','q'), +(15,6,5,'2001-11-12','0000-00-00 00:00:00',''), +(16,2,9,'0000-00-00','0000-00-00 00:00:00','j'), +(29,9,1,'0000-00-00','2003-08-11 00:00:00','m'); +Warnings: +Warning 1264 Out of range value for column 'date_key' at row 2 +Warning 1264 Out of range value for column 'datetime_nokey' at row 2 +Warning 1264 Out of range value for column 'datetime_nokey' at row 4 +Warning 1264 Out of range value for column 'datetime_nokey' at row 5 +Warning 1264 Out of range value for column 'datetime_nokey' at row 6 +Warning 1264 Out of range value for column 'date_key' at row 7 +Warning 1264 Out of range value for column 'datetime_nokey' at row 7 +Warning 1264 Out of range value for column 'date_key' at row 8 +INSERT IGNORE INTO t3 VALUES (1,9,'0000-00-00','b','b'), +(2,2,'2002-09-17','h','h'); +Warnings: +Warning 1264 Out of range value for column 'date_key' at row 1 +SELECT t1.varchar_nokey FROM t1 JOIN t3 ON t1.datetime_nokey +WHERE t1.varchar_nokey +IN (SELECT varchar_nokey FROM t1 +WHERE (pk) +IN (SELECT t3.int_nokey +FROM t3 LEFT JOIN t1 ON t1.varchar_nokey +WHERE t3.date_key BETWEEN '2008-06-07' AND '2006-06-26' + ) +); +varchar_nokey +DROP TABLE t1, t2, t3; +# +# Bug#45219 "Crash on SELECT DISTINCT query containing a +# LEFT JOIN in subquery" +# +CREATE TABLE t1 ( +pk INTEGER NOT NULL, +int_nokey INTEGER NOT NULL, +datetime_key DATETIME NOT NULL, +varchar_key VARCHAR(1) NOT NULL, +PRIMARY KEY (pk), +KEY datetime_key (datetime_key), +KEY varchar_key (varchar_key) +); +INSERT IGNORE INTO t1 VALUES +(1,9,'0000-00-00 00:00:00','p'),(2,0,'2002-02-09 07:38:13','v'), +(3,8,'2001-05-03 12:08:14','t'),(4,3,'0000-00-00 00:00:00','u'), +(5,7,'2009-07-28 03:43:30','n'),(6,0,'2009-08-04 00:00:00','l'), +(7,1,'0000-00-00 00:00:00','h'),(8,9,'0000-00-00 00:00:00','u'), +(9,0,'2005-08-02 17:16:54','n'),(10,9,'2002-12-21 00:00:00','j'), +(11,0,'2005-08-15 12:37:35','k'),(12,5,'0000-00-00 00:00:00','e'), +(13,0,'2006-03-10 00:00:00','i'),(14,8,'2005-05-16 11:02:36','u'), +(15,8,'2008-11-02 00:00:00','n'),(16,5,'2006-03-15 00:00:00','b'), +(17,1,'0000-00-00 00:00:00','x'),(18,7,'0000-00-00 00:00:00',''), +(19,0,'2008-12-17 20:15:40','q'),(20,9,'0000-00-00 00:00:00','u'); +Warnings: +Warning 1264 Out of range value for column 'datetime_key' at row 1 +Warning 1264 Out of range value for column 'datetime_key' at row 4 +Warning 1264 Out of range value for column 'datetime_key' at row 7 +Warning 1264 Out of range value for column 'datetime_key' at row 8 +Warning 1264 Out of range value for column 'datetime_key' at row 12 +Warning 1264 Out of range value for column 'datetime_key' at row 17 +Warning 1264 Out of range value for column 'datetime_key' at row 18 +Warning 1264 Out of range value for column 'datetime_key' at row 20 +CREATE TABLE t2 LIKE t1; +INSERT INTO t2 VALUES +(10,0,'2006-07-07 07:26:28','q'),(11,5,'2002-09-23 00:00:00','m'), +(12,7,'0000-00-00 00:00:00','j'),(13,1,'2006-06-07 00:00:00','z'), +(14,8,'2000-09-16 12:15:34','a'),(15,2,'2007-08-05 15:47:52',''), +(16,1,'0000-00-00 00:00:00','e'),(17,8,'2005-12-02 19:34:26','t'), +(18,5,'0000-00-00 00:00:00','q'),(19,4,'0000-00-00 00:00:00','b'), +(20,5,'2007-12-28 00:00:00','w'),(21,3,'2004-08-02 11:48:43','m'), +(22,0,'0000-00-00 00:00:00','x'),(23,8,'2004-04-19 12:18:43',''), +(24,0,'2009-04-27 00:00:00','w'),(25,4,'2006-10-20 14:52:15','x'), +(26,0,'0000-00-00 00:00:00','e'),(27,0,'2002-03-22 11:48:37','e'), +(28,2,'0000-00-00 00:00:00','p'),(29,0,'2001-01-04 03:55:07','x'); +Warnings: +Warning 1264 Out of range value for column 'datetime_key' at row 3 +Warning 1264 Out of range value for column 'datetime_key' at row 7 +Warning 1264 Out of range value for column 'datetime_key' at row 9 +Warning 1264 Out of range value for column 'datetime_key' at row 10 +Warning 1264 Out of range value for column 'datetime_key' at row 13 +Warning 1264 Out of range value for column 'datetime_key' at row 17 +Warning 1264 Out of range value for column 'datetime_key' at row 19 +CREATE TABLE t3 LIKE t1; +INSERT INTO t3 VALUES +(10,8,'2007-08-19 08:08:38','i'),(11,0,'2000-05-21 03:51:51',''); +SELECT DISTINCT datetime_key FROM t1 +WHERE (int_nokey, pk) +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#46550 Azalea returning duplicate results for some IN subqueries +# w/ semijoin=on +# +DROP TABLE IF EXISTS t0, t1, t2; +CREATE TABLE t0 ( +int_key int(11) DEFAULT NULL, +varchar_key varchar(1) DEFAULT NULL, +varchar_nokey varchar(1) DEFAULT NULL, +KEY int_key (int_key), +KEY varchar_key (varchar_key,int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t0 VALUES +(1,'m','m'), +(40,'h','h'), +(1,'r','r'), +(1,'h','h'), +(9,'x','x'), +(NULL,'q','q'), +(NULL,'k','k'), +(7,'l','l'), +(182,'k','k'), +(202,'a','a'), +(7,'x','x'), +(6,'j','j'), +(119,'z','z'), +(4,'d','d'), +(5,'h','h'), +(1,'u','u'), +(3,'q','q'), +(7,'a','a'), +(3,'e','e'), +(6,'l','l'); +CREATE TABLE t1 ( +int_key int(11) DEFAULT NULL, +varchar_key varchar(1) DEFAULT NULL, +varchar_nokey varchar(1) DEFAULT NULL, +KEY int_key (int_key), +KEY varchar_key (varchar_key,int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (7,NULL,NULL),(4,'x','x'); +CREATE TABLE t2 ( +int_key int(11) DEFAULT NULL, +varchar_key varchar(1) DEFAULT NULL, +varchar_nokey varchar(1) DEFAULT NULL, +KEY int_key (int_key), +KEY varchar_key (varchar_key,int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (123,NULL,NULL); +SELECT int_key +FROM t0 +WHERE varchar_nokey IN ( +SELECT t1 .varchar_key from t1 +); +int_key +7 +9 +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 +7 +9 +EXPLAIN +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 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1_1 NULL index varchar_key varchar_key 12 NULL 2 50.00 Using where; Using index; Start temporary +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 20 10.00 Using where; Using join buffer (hash join) +1 SIMPLE t1_2 NULL index NULL int_key 5 NULL 2 100.00 Using index; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`int_key` AS `int_key` from `test`.`t0` semi join (`test`.`t1` `t1_1` join `test`.`t1` `t1_2`) where ((`test`.`t0`.`varchar_nokey` = `test`.`t1_1`.`varchar_key`) and (0 <> `test`.`t1_1`.`int_key`)) +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 +7 +9 +EXPLAIN +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 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t1_1 NULL index varchar_key varchar_key 12 NULL 2 50.00 Using where; Using index; Start temporary +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 20 10.00 Using where; Using join buffer (hash join) +1 SIMPLE t1_2 NULL index NULL int_key 5 NULL 2 100.00 Using index; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`int_key` AS `int_key` from `test`.`t0` semi join (`test`.`t1` `t1_1` join `test`.`t1` `t1_2`) where ((`test`.`t0`.`varchar_nokey` = `test`.`t1_1`.`varchar_key`) and (0 <> `test`.`t1_1`.`int_key`)) +DROP TABLE t0, t1, t2; +# End of bug#46550 + +Bug #48073 Subquery on char columns from view crashes Mysql + +DROP TABLE IF EXISTS t1, t2; +DROP VIEW IF EXISTS v1; +CREATE TABLE t1 ( +city VARCHAR(50) NOT NULL, +country_id SMALLINT UNSIGNED NOT NULL +); +INSERT INTO t1 VALUES +('Batna',2), +('Bchar',2), +('Skikda',2), +('Tafuna',3), +('Algeria',2) ; +CREATE TABLE t2 ( +country_id SMALLINT UNSIGNED NOT NULL, +country VARCHAR(50) NOT NULL +); +INSERT INTO t2 VALUES +(2,'Algeria'), +(3,'American Samoa') ; +CREATE VIEW v1 AS +SELECT country_id, country +FROM t2 +WHERE LEFT(country,1) = "A" +; +SELECT city, country_id +FROM t1 +WHERE city IN ( +SELECT country +FROM t2 +WHERE LEFT(country, 1) = "A" +); +city country_id +Algeria 2 +SELECT city, country_id +FROM t1 +WHERE city IN ( +SELECT country +FROM v1 +); +city country_id +Algeria 2 +drop table t1, t2; +drop view v1; +# End of bug#48073 + +Bug#49097 subquery with view generates wrong result with +non-prepared statement + +DROP TABLE IF EXISTS t1, t2; +DROP VIEW IF EXISTS v1; +CREATE TABLE t1 ( +city VARCHAR(50) NOT NULL, +country_id SMALLINT UNSIGNED NOT NULL +); +INSERT INTO t1 VALUES +('Batna',2), +('Bchar',2), +('Skikda',2), +('Tafuna',3), +('Algeria',2) ; +CREATE TABLE t2 ( +country_id SMALLINT UNSIGNED NOT NULL, +country VARCHAR(50) NOT NULL +); +INSERT INTO t2 VALUES +(2,'Algeria'), +(3,'XAmerican Samoa') ; +CREATE VIEW v1 AS +SELECT country_id, country +FROM t2 +WHERE LEFT(country,1) = "A" +; +SELECT city, country_id +FROM t1 +WHERE country_id IN ( +SELECT country_id +FROM t2 +WHERE LEFT(country,1) = "A" +); +city country_id +Algeria 2 +Batna 2 +Bchar 2 +Skikda 2 +SELECT city, country_id +FROM t1 +WHERE country_id IN ( +SELECT country_id +FROM v1 +); +city country_id +Algeria 2 +Batna 2 +Bchar 2 +Skikda 2 +PREPARE stmt FROM +" +SELECT city, country_id +FROM t1 +WHERE country_id IN ( + SELECT country_id + FROM v1 +); +"; +execute stmt; +city country_id +Algeria 2 +Batna 2 +Bchar 2 +Skikda 2 +deallocate prepare stmt; +drop table t1, t2; +drop view v1; +# End of Bug#49097 +# +# Bug#49198 Wrong result for second call of procedure +# with view in subselect. +# +CREATE TABLE t1 (t1field integer, primary key (t1field)); +CREATE TABLE t2 (t2field integer, primary key (t2field)); +CREATE TABLE t3 (t3field integer, primary key (t3field)); +CREATE VIEW v2 AS SELECT * FROM t2; +CREATE VIEW v3 AS SELECT * FROM t3; +INSERT INTO t1 VALUES(1),(2); +INSERT INTO t2 VALUES(1),(2); +INSERT INTO t3 VALUES(1),(2); +PREPARE stmt FROM +" +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT * FROM v2); +"; +EXECUTE stmt; +t1field +1 +2 + +EXECUTE stmt; +t1field +1 +2 +PREPARE stmt FROM +" +EXPLAIN +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT * FROM v2) + AND t1field IN (SELECT * FROM v3) +"; +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index PRIMARY PRIMARY 4 NULL 2 100.00 Using index +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +1 SIMPLE t3 NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`t1field` AS `t1field` from `test`.`t2` join `test`.`t3` join `test`.`t1` where ((`test`.`t2`.`t2field` = `test`.`t1`.`t1field`) and (`test`.`t3`.`t3field` = `test`.`t1`.`t1field`)) + +This line is only in place to help --skip_if_hypergraph diffing some more. + +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index PRIMARY PRIMARY 4 NULL 2 100.00 Using index +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +1 SIMPLE t3 NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`t1field` AS `t1field` from `test`.`t2` join `test`.`t3` join `test`.`t1` where ((`test`.`t2`.`t2field` = `test`.`t1`.`t1field`) and (`test`.`t3`.`t3field` = `test`.`t1`.`t1field`)) +DROP TABLE t1, t2, t3; +DROP VIEW v2, v3; +# End of Bug#49198 +# +# Bug#48623 Multiple subqueries are optimized incorrectly +# +CREATE TABLE ot(val VARCHAR(10)) charset utf8mb4; +CREATE TABLE it1(val VARCHAR(10)) charset utf8mb4; +CREATE TABLE it2(val VARCHAR(10)) charset utf8mb4; +INSERT INTO ot VALUES('aaa'), ('bbb'), ('eee'), ('mmm'), ('ppp'); +INSERT INTO it1 VALUES('aaa'), ('aaa'), ('bbb'), ('eee'), ('mmm'), ('ppp'); +INSERT INTO it2 VALUES('aaa'), ('bbb'), ('eee'), ('mmm'), ('ppp'); +EXPLAIN +SELECT * +FROM ot +WHERE ot.val IN (SELECT it1.val FROM it1 +WHERE it1.val LIKE 'a%' OR it1.val LIKE 'e%') +AND ot.val IN (SELECT it2.val FROM it2 +WHERE it2.val LIKE 'a%' OR it2.val LIKE 'e%'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE it2 NULL ALL NULL NULL NULL NULL 5 36.00 Using where; Start temporary +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 5 20.00 Using where; Using join buffer (hash join) +1 SIMPLE it1 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot`.`val` AS `val` from `test`.`ot` semi join (`test`.`it1`) semi join (`test`.`it2`) where ((`test`.`ot`.`val` = `test`.`it2`.`val`) and (`test`.`it1`.`val` = `test`.`it2`.`val`) and ((`test`.`it1`.`val` like 'a%') or (`test`.`it1`.`val` like 'e%')) and ((`test`.`it2`.`val` like 'a%') or (`test`.`it2`.`val` like 'e%'))) +SELECT * +FROM ot +WHERE ot.val IN (SELECT it1.val FROM it1 +WHERE it1.val LIKE 'a%' OR it1.val LIKE 'e%') +AND ot.val IN (SELECT it2.val FROM it2 +WHERE it2.val LIKE 'a%' OR it2.val LIKE 'e%'); +val +aaa +eee +DROP TABLE ot; +DROP TABLE it1; +DROP TABLE it2; +# End of Bug#48623 +# +# Bug #51487 Assertion failure when semi-join flattening occurs +# for a subquery in HAVING +# +CREATE TABLE t1 (a INT, b INT); +INSERT INTO t1 VALUES (1,10),(2,11),(1,13); +CREATE TABLE t2 AS SELECT * FROM t1; +CREATE TABLE t3 AS SELECT * FROM t1; +SELECT COUNT(*) FROM t1 +GROUP BY t1.a +HAVING t1.a IN (SELECT t3.a FROM t3 +WHERE t3.b IN (SELECT b FROM t2 WHERE t2.a=t1.a)); +COUNT(*) +2 +1 +DROP TABLE t1, t2, t3; +# End of Bug#51487 +# +# BUG#38075: Wrong result: rows matching a subquery with outer join not returned +# +DROP TABLE IF EXISTS ot1, it1, it2; +CREATE TABLE it2 ( +int_key int(11) NOT NULL, +datetime_key datetime NOT NULL, +KEY int_key (int_key), +KEY datetime_key (datetime_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO it2 VALUES +(5,'2002-04-10 14:25:30'), (0,'0000-00-00 00:00:00'), +(0,'2006-09-14 04:01:02'), (4,'0000-00-00 00:00:00'), +(8,'0000-00-00 00:00:00'), (5,'0000-00-00 00:00:00'), +(9,'0000-00-00 00:00:00'), (8,'2007-04-01 11:04:17'), +(1,'0000-00-00 00:00:00'), (7,'2009-01-12 00:00:00'), +(0,'2009-06-05 00:00:00'), (3,'2006-02-14 18:06:35'), +(5,'2006-02-21 07:08:16'), (0,'0000-00-00 00:00:00'), +(7,'0000-00-00 00:00:00'), (0,'0000-00-00 00:00:00'), +(0,'2007-02-13 00:00:00'), (1,'0000-00-00 00:00:00'), +(0,'0000-00-00 00:00:00'), (1,'2003-08-11 00:00:00'); +Warnings: +Warning 1264 Out of range value for column 'datetime_key' at row 2 +Warning 1264 Out of range value for column 'datetime_key' at row 4 +Warning 1264 Out of range value for column 'datetime_key' at row 5 +Warning 1264 Out of range value for column 'datetime_key' at row 6 +Warning 1264 Out of range value for column 'datetime_key' at row 7 +Warning 1264 Out of range value for column 'datetime_key' at row 9 +Warning 1264 Out of range value for column 'datetime_key' at row 14 +Warning 1264 Out of range value for column 'datetime_key' at row 15 +Warning 1264 Out of range value for column 'datetime_key' at row 16 +Warning 1264 Out of range value for column 'datetime_key' at row 18 +Warning 1264 Out of range value for column 'datetime_key' at row 19 +CREATE TABLE ot1 ( +int_nokey int(11) NOT NULL, +int_key int(11) NOT NULL, +KEY int_key (int_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO ot1 VALUES +(5,0), (3,0), (0,2), (3,0), (1,3), (0,0), (1,7), (7,0), (1,7), (0,7), +(0,9), (8,2), (4,4), (9,3), (0,9), (2,5), (0,5), (8,0), (5,8), (1,5); +CREATE TABLE it1 ( +int_nokey int(11) NOT NULL, +int_key int(11) NOT NULL, +KEY int_key (int_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO it1 VALUES +(9,5), (0,4); +SELECT int_key FROM ot1 +WHERE int_nokey IN (SELECT it2.int_key +FROM it1 LEFT JOIN it2 ON it2.datetime_key); +int_key +0 +0 +0 +0 +0 +0 +2 +2 +3 +5 +5 +7 +7 +7 +8 +9 +9 +EXPLAIN +SELECT int_key FROM ot1 +WHERE int_nokey IN (SELECT it2.int_key +FROM it1 LEFT JOIN it2 ON it2.datetime_key); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE it1 NULL index NULL int_key 4 NULL 2 100.00 Using index; Start temporary +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 20 100.00 Using join buffer (hash join) +1 SIMPLE it2 NULL ref int_key int_key 4 test.ot1.int_nokey 2 90.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`int_key` AS `int_key` from `test`.`ot1` semi join (`test`.`it1` join `test`.`it2`) where ((`test`.`it2`.`int_key` = `test`.`ot1`.`int_nokey`) and (TIMESTAMP'0000-00-00 00:00:00' <> `test`.`it2`.`datetime_key`)) +DROP TABLE ot1, it1, it2; +# End of BUG#38075 +# +# BUG#50089: Second call of procedure with view in subselect crashes server +# +CREATE TABLE t1(t1field INTEGER, PRIMARY KEY(t1field)); +CREATE VIEW v1 AS +SELECT t1field AS v1field +FROM t1 a +WHERE a.t1field IN (SELECT t1field FROM t1); +INSERT INTO t1 VALUES(1),(2); +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT v1field FROM v1); +t1field +1 +2 +EXPLAIN +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT v1field FROM v1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index PRIMARY PRIMARY 4 NULL 2 100.00 Using index +1 SIMPLE a NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `t1`.`t1field` AS `t1field` from `test`.`t1` `a` join `test`.`t1` join `test`.`t1` where ((`test`.`a`.`t1field` = `t1`.`t1field`) and (`test`.`t1`.`t1field` = `t1`.`t1field`)) +SELECT t1.t1field +FROM t1 LEFT JOIN t1 AS t2 ON t1.t1field IN (SELECT v1field FROM v1); +t1field +1 +1 +2 +2 +EXPLAIN +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT v1field FROM v1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index PRIMARY PRIMARY 4 NULL 2 100.00 Using index +1 SIMPLE a NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `t1`.`t1field` AS `t1field` from `test`.`t1` `a` join `test`.`t1` join `test`.`t1` where ((`test`.`a`.`t1field` = `t1`.`t1field`) and (`test`.`t1`.`t1field` = `t1`.`t1field`)) +CREATE PROCEDURE p1() +BEGIN +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT v1field FROM v1); +END| +CALL p1; +t1field +1 +2 +CALL p1; +t1field +1 +2 +PREPARE stmt FROM +" +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT v1field FROM v1); +"; +EXECUTE stmt; +t1field +1 +2 + +EXECUTE stmt; +t1field +1 +2 +DROP PROCEDURE p1; +DROP VIEW v1; +DROP TABLE t1; +# End of BUG#50089 +# +# Bug#45191: Incorrectly initialized semi-join led to a wrong result. +# +CREATE TABLE staff (EMPNUM CHAR(3) NOT NULL, +EMPNAME CHAR(20), GRADE DECIMAL(4), CITY CHAR(15)) charset latin1; +CREATE TABLE proj (PNUM CHAR(3) NOT NULL, +PNAME CHAR(20), PTYPE CHAR(6), +BUDGET DECIMAL(9), +CITY CHAR(15)) charset latin1; +CREATE TABLE works (EMPNUM CHAR(3) NOT NULL, +PNUM CHAR(3) NOT NULL, HOURS DECIMAL(5)) charset latin1; +INSERT INTO staff VALUES ('E1','Alice',12,'Deale'); +INSERT INTO staff VALUES ('E2','Betty',10,'Vienna'); +INSERT INTO staff VALUES ('E3','Carmen',13,'Vienna'); +INSERT INTO staff VALUES ('E4','Don',12,'Deale'); +INSERT INTO staff VALUES ('E5','Ed',13,'Akron'); +INSERT INTO proj VALUES ('P1','MXSS','Design',10000,'Deale'); +INSERT INTO proj VALUES ('P2','CALM','Code',30000,'Vienna'); +INSERT INTO proj VALUES ('P3','SDP','Test',30000,'Tampa'); +INSERT INTO proj VALUES ('P4','SDP','Design',20000,'Deale'); +INSERT INTO proj VALUES ('P5','IRM','Test',10000,'Vienna'); +INSERT INTO proj VALUES ('P6','PAYR','Design',50000,'Deale'); +INSERT INTO works VALUES ('E1','P1',40); +INSERT INTO works VALUES ('E1','P2',20); +INSERT INTO works VALUES ('E1','P3',80); +INSERT INTO works VALUES ('E1','P4',20); +INSERT INTO works VALUES ('E1','P5',12); +INSERT INTO works VALUES ('E1','P6',12); +INSERT INTO works VALUES ('E2','P1',40); +INSERT INTO works VALUES ('E2','P2',80); +INSERT INTO works VALUES ('E3','P2',20); +INSERT INTO works VALUES ('E4','P2',20); +INSERT INTO works VALUES ('E4','P4',40); +INSERT INTO works VALUES ('E4','P5',80); +explain SELECT EMPNUM, EMPNAME +FROM staff +WHERE EMPNUM IN +(SELECT EMPNUM FROM works +WHERE PNUM IN +(SELECT PNUM FROM proj)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE staff NULL ALL NULL NULL NULL NULL 5 100.00 Start temporary +1 SIMPLE works NULL ALL NULL NULL NULL NULL 12 10.00 Using where; Using join buffer (hash join) +1 SIMPLE proj NULL ALL NULL NULL NULL NULL 6 16.67 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`staff`.`EMPNUM` AS `EMPNUM`,`test`.`staff`.`EMPNAME` AS `EMPNAME` from `test`.`staff` semi join (`test`.`works` join `test`.`proj`) where ((`test`.`works`.`EMPNUM` = `test`.`staff`.`EMPNUM`) and (`test`.`proj`.`PNUM` = `test`.`works`.`PNUM`)) +SELECT EMPNUM, EMPNAME +FROM staff +WHERE EMPNUM IN +(SELECT EMPNUM FROM works +WHERE PNUM IN +(SELECT PNUM FROM proj)); +EMPNUM EMPNAME +E1 Alice +E2 Betty +E3 Carmen +E4 Don +drop table staff,works,proj; +# End of bug#45191 +# +# BUG#36896: Server crash on SELECT FROM DUAL +# +create table t1 (a int); +select 1 as res from dual where (1) in (select * from t1); +res +drop table t1; + +BUG#40118 Crash when running Batched Key Access and requiring one match for each key + +create table t0(a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (a int, key(a)); +insert into t1 select * from t0; +alter table t1 add b int not null, add filler char(200); +insert into t1 select * from t1; +insert into t1 select * from t1; +select * from t0 where t0.a in (select t1.a from t1 where t1.b=0); +a +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +drop table t0, t1; +# +# BUG#32665 Query with dependent subquery is too slow +# +create table t1 ( +idIndividual int primary key +); +insert into t1 values (1),(2); +create table t2 ( +idContact int primary key, +contactType int, +idObj int +); +insert into t2 values (1,1,1),(2,2,2),(3,3,3); +create table t3 ( +idAddress int primary key, +idContact int, +postalStripped varchar(100) +); +insert into t3 values (1,1, 'foo'), (2,2,'bar'); +The following must be converted to a semi-join: +explain SELECT a.idIndividual FROM t1 a +WHERE a.idIndividual IN +( SELECT c.idObj FROM t3 cona +INNER JOIN t2 c ON c.idContact=cona.idContact +WHERE cona.postalStripped='T2H3B2' + ); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE cona NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE c NULL eq_ref PRIMARY PRIMARY 4 test.cona.idContact 1 100.00 Using where +1 SIMPLE a NULL eq_ref PRIMARY PRIMARY 4 test.c.idObj 1 100.00 Using index; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`a`.`idIndividual` AS `idIndividual` from `test`.`t1` `a` semi join (`test`.`t3` `cona` join `test`.`t2` `c`) where ((`test`.`c`.`idContact` = `test`.`cona`.`idContact`) and (`test`.`a`.`idIndividual` = `test`.`c`.`idObj`) and (`test`.`cona`.`postalStripped` = 'T2H3B2')) +drop table t1,t2,t3; +CREATE TABLE t1 (one int, two int, flag char(1)); +CREATE TABLE t2 (one int, two int, flag char(1)); +INSERT INTO t1 VALUES(1,2,'Y'),(2,3,'Y'),(3,4,'Y'),(5,6,'N'),(7,8,'N'); +INSERT INTO t2 VALUES(1,2,'Y'),(2,3,'Y'),(3,4,'Y'),(5,6,'N'),(7,8,'N'); +SELECT * FROM t1 +WHERE ROW(one,two) IN (SELECT DISTINCT one,two FROM t2 WHERE flag = 'N'); +one two flag +5 6 N +7 8 N +SELECT * FROM t1 +WHERE ROW(one,two) IN (SELECT DISTINCT one,two FROM t1 WHERE flag = 'N'); +one two flag +5 6 N +7 8 N +insert into t2 values (null,null,'N'); +insert into t2 values (null,3,'0'); +insert into t2 values (null,5,'0'); +insert into t2 values (10,null,'0'); +insert into t1 values (10,3,'0'); +insert into t1 values (10,5,'0'); +insert into t1 values (10,10,'0'); +SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = 'N') as 'test' from t1; +one two test +1 2 NULL +2 3 NULL +3 4 NULL +5 6 1 +7 8 1 +10 3 NULL +10 5 NULL +10 10 NULL +SELECT one,two from t1 where ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = 'N'); +one two +5 6 +7 8 +SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = 'N' group by one,two) as 'test' from t1; +one two test +1 2 NULL +2 3 NULL +3 4 NULL +5 6 1 +7 8 1 +10 3 NULL +10 5 NULL +10 10 NULL +SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = '0') as 'test' from t1; +one two test +1 2 0 +2 3 NULL +3 4 0 +5 6 0 +7 8 0 +10 3 NULL +10 5 NULL +10 10 NULL +SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = '0' group by one,two) as 'test' from t1; +one two test +1 2 0 +2 3 NULL +3 4 0 +5 6 0 +7 8 0 +10 3 NULL +10 5 NULL +10 10 NULL +explain SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = '0') as 'test' from t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 9 11.11 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`one` AS `one`,`test`.`t1`.`two` AS `two`,((`test`.`t1`.`one`,`test`.`t1`.`two`),(/* select#2 */ select `test`.`t2`.`one`,`test`.`t2`.`two` from `test`.`t2` where ((`test`.`t2`.`flag` = '0') and (outer_field_is_not_null, (((`test`.`t1`.`one`) = `test`.`t2`.`one`) or (`test`.`t2`.`one` is null)), true) and (outer_field_is_not_null, (((`test`.`t1`.`two`) = `test`.`t2`.`two`) or (`test`.`t2`.`two` is null)), true)) having ((outer_field_is_not_null, (`test`.`t2`.`one`), true) and (outer_field_is_not_null, (`test`.`t2`.`two`), true)))) AS `test` from `test`.`t1` +explain SELECT one,two from t1 where ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = 'N'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 9 11.11 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`one` AS `one`,`test`.`t1`.`two` AS `two` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`two` = `test`.`t2`.`two`) and (`test`.`t1`.`one` = `test`.`t2`.`one`) and (`test`.`t2`.`flag` = 'N')) +explain SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = '0' group by one,two) as 'test' from t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 9 11.11 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`one` AS `one`,`test`.`t1`.`two` AS `two`,((`test`.`t1`.`one`,`test`.`t1`.`two`),(/* select#2 */ select `test`.`t2`.`one`,`test`.`t2`.`two` from `test`.`t2` where ((`test`.`t2`.`flag` = '0') and (outer_field_is_not_null, (((`test`.`t1`.`one`) = `test`.`t2`.`one`) or (`test`.`t2`.`one` is null)), true) and (outer_field_is_not_null, (((`test`.`t1`.`two`) = `test`.`t2`.`two`) or (`test`.`t2`.`two` is null)), true)) having ((outer_field_is_not_null, (`test`.`t2`.`one`), true) and (outer_field_is_not_null, (`test`.`t2`.`two`), true)))) AS `test` from `test`.`t1` +DROP TABLE t1,t2; +CREATE TABLE t1 (a char(5), b char(5)); +INSERT INTO t1 VALUES (NULL,'aaa'), ('aaa','aaa'); +SELECT * FROM t1 WHERE (a,b) IN (('aaa','aaa'), ('aaa','bbb')); +a b +aaa aaa +DROP TABLE t1; +CREATE TABLE t1 (a CHAR(1), b VARCHAR(10)) charset utf8mb4; +INSERT INTO t1 VALUES ('a', 'aa'); +INSERT INTO t1 VALUES ('a', 'aaa'); +SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1); +a b +CREATE INDEX I1 ON t1 (a); +CREATE INDEX I2 ON t1 (b); +EXPLAIN SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index I1 I1 5 NULL 2 100.00 Using index; Start temporary +1 SIMPLE t1 NULL ALL I2 NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t1`) where (`test`.`t1`.`b` = `test`.`t1`.`a`) +SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1); +a b +CREATE TABLE t2 (a VARCHAR(1), b VARCHAR(10)) charset utf8mb4; +INSERT INTO t2 SELECT * FROM t1; +CREATE INDEX I1 ON t2 (a); +CREATE INDEX I2 ON t2 (b); +EXPLAIN SELECT a,b FROM t2 WHERE b IN (SELECT a FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index I1 I1 7 NULL 2 100.00 Using index; Start temporary +1 SIMPLE t2 NULL ALL I2 NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t2` semi join (`test`.`t2`) where (`test`.`t2`.`b` = `test`.`t2`.`a`) +SELECT a,b FROM t2 WHERE b IN (SELECT a FROM t2); +a b +EXPLAIN +SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1 WHERE LENGTH(a)<500); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index I1 I1 5 NULL 2 100.00 Using where; Using index; Start temporary +1 SIMPLE t1 NULL ALL I2 NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t1`) where ((length(`test`.`t1`.`a`) < 500) and (`test`.`t1`.`b` = `test`.`t1`.`a`)) +SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1 WHERE LENGTH(a)<500); +a b +DROP TABLE t1,t2; +# +# BUG#45928 "Differing query results depending on MRR and +# engine_condition_pushdown settings" +# +CREATE TABLE `t1` ( +`pk` int(11) NOT NULL AUTO_INCREMENT, +`time_nokey` time NOT NULL, +`varchar_key` varchar(1) NOT NULL, +`varchar_nokey` varchar(1) NOT NULL, +PRIMARY KEY (`pk`), +KEY `varchar_key` (`varchar_key`) +) AUTO_INCREMENT=12 DEFAULT CHARSET=latin1; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO `t1` VALUES (10,'00:00:00','i','i'),(11,'00:00:00','',''); +SELECT `time_nokey` G1 FROM t1 WHERE ( `varchar_nokey` , `varchar_key` ) IN ( +SELECT `varchar_nokey` , `varchar_nokey` ) AND `varchar_key` >= 'c' HAVING G1 ORDER +BY `pk` ; +G1 +DROP TABLE t1; +# +# BUG#45863 "Assertion failed: (fixed == 0), function fix_fields(), +# file item.cc, line 4448" +# +DROP TABLE IF EXISTS C, BB; +CREATE TABLE C ( +varchar_nokey varchar(1) NOT NULL +); +INSERT INTO C VALUES +('k'),('a'),(''),('u'),('e'),('v'),('i'), +('t'),('u'),('f'),('u'),('m'),('j'),('f'), +('v'),('j'),('g'),('e'),('h'),('z'); +CREATE TABLE BB ( +varchar_nokey varchar(1) NOT NULL +); +INSERT INTO BB VALUES ('i'),('t'); +SELECT varchar_nokey FROM C +WHERE (varchar_nokey, OUTR) IN (SELECT varchar_nokey +FROM BB); +ERROR 42S22: Unknown column 'OUTR' in 'IN/ALL/ANY subquery' +SELECT varchar_nokey FROM C +WHERE (varchar_nokey, OUTR) IN (SELECT varchar_nokey, varchar_nokey +FROM BB); +ERROR 42S22: Unknown column 'OUTR' in 'IN/ALL/ANY subquery' +DROP TABLE C,BB; +# +# During work with BUG#45863 I had problems with a query that was +# optimized differently in regular and prepared mode. +# Because there was a bug in one of the selected strategies, I became +# aware of the problem. Adding an EXPLAIN query to catch this. +DROP TABLE IF EXISTS t1, t2, t3; +CREATE TABLE t1 +(EMPNUM CHAR(3) NOT NULL, +EMPNAME CHAR(20), +GRADE DECIMAL(4), +CITY CHAR(15)) charset latin1; +CREATE TABLE t2 +(PNUM CHAR(3) NOT NULL, +PNAME CHAR(20), +PTYPE CHAR(6), +BUDGET DECIMAL(9), +CITY CHAR(15)) charset latin1; +CREATE TABLE t3 +(EMPNUM CHAR(3) NOT NULL, +PNUM CHAR(3) NOT NULL, +HOURS DECIMAL(5)) charset latin1; +INSERT INTO t1 VALUES ('E1','Alice',12,'Deale'); +INSERT INTO t1 VALUES ('E2','Betty',10,'Vienna'); +INSERT INTO t1 VALUES ('E3','Carmen',13,'Vienna'); +INSERT INTO t1 VALUES ('E4','Don',12,'Deale'); +INSERT INTO t1 VALUES ('E5','Ed',13,'Akron'); +INSERT INTO t2 VALUES ('P1','MXSS','Design',10000,'Deale'); +INSERT INTO t2 VALUES ('P2','CALM','Code',30000,'Vienna'); +INSERT INTO t2 VALUES ('P3','SDP','Test',30000,'Tampa'); +INSERT INTO t2 VALUES ('P4','SDP','Design',20000,'Deale'); +INSERT INTO t2 VALUES ('P5','IRM','Test',10000,'Vienna'); +INSERT INTO t2 VALUES ('P6','PAYR','Design',50000,'Deale'); +INSERT INTO t3 VALUES ('E1','P1',40); +INSERT INTO t3 VALUES ('E1','P2',20); +INSERT INTO t3 VALUES ('E1','P3',80); +INSERT INTO t3 VALUES ('E1','P4',20); +INSERT INTO t3 VALUES ('E1','P5',12); +INSERT INTO t3 VALUES ('E1','P6',12); +INSERT INTO t3 VALUES ('E2','P1',40); +INSERT INTO t3 VALUES ('E2','P2',80); +INSERT INTO t3 VALUES ('E3','P2',20); +INSERT INTO t3 VALUES ('E4','P2',20); +INSERT INTO t3 VALUES ('E4','P4',40); +INSERT INTO t3 VALUES ('E4','P5',80); +CREATE UNIQUE INDEX t1_IDX ON t1(EMPNUM); +EXPLAIN SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN +(SELECT EMPNUM +FROM t3 +WHERE PNUM IN +(SELECT PNUM +FROM t2 +WHERE PTYPE = 'Design')); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL eq_ref t1_IDX t1_IDX 3 test.t3.EMPNUM 1 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = `test`.`t3`.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) +PREPARE stmt FROM "EXPLAIN SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN + (SELECT EMPNUM + FROM t3 + WHERE PNUM IN + (SELECT PNUM + FROM t2 + WHERE PTYPE = 'Design'))"; +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL eq_ref t1_IDX t1_IDX 3 test.t3.EMPNUM 1 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = `test`.`t3`.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) + +This line is only in place to help --skip_if_hypergraph diffing some more. + +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL eq_ref t1_IDX t1_IDX 3 test.t3.EMPNUM 1 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = `test`.`t3`.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) +DEALLOCATE PREPARE stmt; +DROP INDEX t1_IDX ON t1; +CREATE INDEX t1_IDX ON t1(EMPNUM); +EXPLAIN SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN +(SELECT EMPNUM +FROM t3 +WHERE PNUM IN +(SELECT PNUM +FROM t2 +WHERE PTYPE = 'Design')); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ref t1_IDX t1_IDX 3 test.t3.EMPNUM 2 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = `test`.`t3`.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) +PREPARE stmt FROM "EXPLAIN SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN + (SELECT EMPNUM + FROM t3 + WHERE PNUM IN + (SELECT PNUM + FROM t2 + WHERE PTYPE = 'Design'))"; +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ref t1_IDX t1_IDX 3 test.t3.EMPNUM 2 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = `test`.`t3`.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) + +This line is only in place to help --skip_if_hypergraph diffing some more. + +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ref t1_IDX t1_IDX 3 test.t3.EMPNUM 2 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = `test`.`t3`.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) +DEALLOCATE PREPARE stmt; +DROP INDEX t1_IDX ON t1; +EXPLAIN SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN +(SELECT EMPNUM +FROM t3 +WHERE PNUM IN +(SELECT PNUM +FROM t2 +WHERE PTYPE = 'Design')); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 20.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = `test`.`t3`.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) +PREPARE stmt FROM "EXPLAIN SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN + (SELECT EMPNUM + FROM t3 + WHERE PNUM IN + (SELECT PNUM + FROM t2 + WHERE PTYPE = 'Design'))"; +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 20.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = `test`.`t3`.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) + +This line is only in place to help --skip_if_hypergraph diffing some more. + +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 20.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = `test`.`t3`.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) +DEALLOCATE PREPARE stmt; +DROP TABLE t1, t2, t3; +# +# BUG#45221 Query SELECT pk FROM C WHERE pk IN (SELECT int_key) failing +# +CREATE TABLE t1 ( +i1_key INT, +i2 INT, +i3 INT, +KEY i1_index (i1_key) +); +INSERT INTO t1 VALUES (9,1,2), (9,2,1); +CREATE TABLE t2 ( +pk INT NOT NULL, +i1 INT, +PRIMARY KEY (pk) +); +INSERT INTO t2 VALUES (9,1); +SELECT pk +FROM t2 +WHERE +pk IN ( +SELECT i1_key +FROM t1 +WHERE t1.i2 < t1.i3 XOR t2.i1 > 1 +ORDER BY t1.i2 desc); +pk +9 +DROP TABLE t1,t2; +# BUG#50361 Doublenested noncorrelated subquery with FirstMatch and join cache wrong result +# +CREATE TABLE t1( +id INTEGER +); +INSERT INTO t1 VALUES(10),(20); +create table t2 select * from t1; +create table t3 select * from t1; +SELECT * +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t2 +WHERE 1 IN(SELECT 1 +FROM t3)); +id +10 +20 +explain SELECT * +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t2 +WHERE 1 IN(SELECT 1 +FROM t3)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where true +delete from t2; +delete from t3; +INSERT INTO t1 VALUES(30),(40),(50),(60),(70),(80),(90); +insert into t2 select * from t1; +insert into t3 select * from t1; +create table t4 select * from t1; +SELECT * +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t2 +WHERE 1 IN(SELECT 1 +FROM t3 +WHERE 1 IN(SELECT 1 +FROM t4))); +id +10 +20 +30 +40 +50 +60 +70 +80 +90 +explain SELECT * +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t2 +WHERE 1 IN(SELECT 1 +FROM t3 +WHERE 1 IN(SELECT 1 +FROM t4))); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 9 100.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 9 100.00 Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 9 100.00 Using join buffer (hash join) +1 SIMPLE t4 NULL ALL NULL NULL NULL NULL 9 100.00 End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3` join `test`.`t4`) where true +SELECT * +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t1))); +id +10 +20 +30 +40 +50 +60 +70 +80 +90 +drop table t1,t2,t3,t4; +# +# Bug#53236 Segfault in DTCollation::set(DTCollation&) +# +CREATE TABLE t1 ( +pk INTEGER AUTO_INCREMENT, +col_varchar VARCHAR(1), +PRIMARY KEY (pk) +) +; +INSERT INTO t1 (col_varchar) +VALUES +('w'), +('m') +; +SELECT table1.pk +FROM ( t1 AS table1 JOIN t1 AS table2 ON (table1.col_varchar = +table2.col_varchar) ) +WHERE ( 1, 2 ) IN ( SELECT SUBQUERY1_t1.pk AS SUBQUERY1_field1, +SUBQUERY1_t1.pk AS SUBQUERY1_field2 +FROM ( t1 AS SUBQUERY1_t1 JOIN t1 AS SUBQUERY1_t2 +ON (SUBQUERY1_t2.col_varchar = +SUBQUERY1_t1.col_varchar) ) ) +; +pk +drop table t1; +# +# BUG#53298 "wrong result with semijoin (no semijoin strategy chosen)" +# +create table t1 (uid int, fid int); +insert into t1 values (1,1), (3,1); +create table t2 (uid int, name varchar(128)); +insert into t2 values (1, "A"), (2, "B"); +create table t3 (uid int, fid int, index(uid)); +insert into t3 values (1,3), (1,3); +create table t4 (uid int); +insert into t4 values (3); +explain select t2.uid from t2, t1 +where t1.uid in (select t4.uid from t4, t3 where t3.uid=1 and t4.uid=t3.fid) +and t2.uid=t1.fid; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t4 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ref uid uid 5 const 1 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`uid` AS `uid` from `test`.`t2` join `test`.`t1` semi join (`test`.`t4` join `test`.`t3`) where ((`test`.`t3`.`fid` = `test`.`t4`.`uid`) and (`test`.`t1`.`uid` = `test`.`t4`.`uid`) and (`test`.`t3`.`uid` = 1) and (`test`.`t1`.`fid` = `test`.`t2`.`uid`)) +select t2.uid from t2, t1 +where t1.uid in (select t4.uid from t4, t3 where t3.uid=1 and t4.uid=t3.fid) +and t2.uid=t1.fid; +uid +1 +drop table t1,t2,t3,t4; +CREATE TABLE t1 ( +pk int, +a varchar(1), +b varchar(4), +c varchar(4), +d varchar(4), +PRIMARY KEY (pk) +) charset utf8mb4; +INSERT INTO t1 VALUES (1,'o','ffff','ffff','ffoo'),(2,'f','ffff','ffff','ffff'); +CREATE TABLE t2 LIKE t1; +INSERT INTO t2 VALUES (1,'i','iiii','iiii','iiii'),(2,'f','ffff','ffff','ffff'); +EXPLAIN SELECT pk FROM t1 WHERE (a) IN (SELECT a FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`a` = `test`.`t1`.`a`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (a) IN (SELECT a FROM t2 WHERE pk > 0); +pk +2 +SELECT pk FROM t1 WHERE (b,c,d) IN (SELECT b,c,d FROM t2 WHERE pk > 0); +pk +2 +DROP TABLE t1, t2; +CREATE TABLE t1 (f1 INT, f2 DECIMAL(5,3)) ENGINE=MyISAM; +INSERT INTO t1 (f1, f2) VALUES (1, 1.789); +INSERT INTO t1 (f1, f2) VALUES (13, 1.454); +INSERT INTO t1 (f1, f2) VALUES (10, 1.668); +CREATE TABLE t2 LIKE t1; +INSERT INTO t2 VALUES (1, 1.789); +INSERT INTO t2 VALUES (13, 1.454); +EXPLAIN SELECT COUNT(*) FROM t1 WHERE (f1,f2) IN (SELECT f1,f2 FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`f2` = `test`.`t2`.`f2`) and (`test`.`t1`.`f1` = `test`.`t2`.`f1`)) +SELECT COUNT(*) FROM t1 WHERE (f1,f2) IN (SELECT f1,f2 FROM t2); +COUNT(*) +2 +DROP TABLE t1, t2; +CREATE TABLE t1 ( +ID int(11) NOT NULL auto_increment, +Name char(35) NOT NULL default '', +Country char(3) NOT NULL default '', +Population int(11) NOT NULL default '0', +PRIMARY KEY (ID), +INDEX (Population), +INDEX (Country) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t2 ( +Code char(3) NOT NULL default '', +Name char(52) NOT NULL default '', +SurfaceArea float(10,2) NOT NULL default '0.00', +Population int(11) NOT NULL default '0', +Capital int(11) default NULL, +PRIMARY KEY (Code), +UNIQUE INDEX (Name), +INDEX (Population) +) charset utf8mb4; +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t3 ( +Country char(3) NOT NULL default '', +Language char(30) NOT NULL default '', +Percentage float(3,1) NOT NULL default '0.0', +PRIMARY KEY (Country, Language), +INDEX (Percentage) +) charset utf8mb4; +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +EXPLAIN SELECT Name FROM t2 +WHERE t2.Code IN (SELECT Country FROM t1 WHERE Population > 5000000) +AND +t2.Code IN (SELECT Country FROM t3 +WHERE Language='English' AND Percentage > 10 AND +t2.Population > 100000); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range Population,Country Population 4 NULL 1 100.00 Using where; Start temporary +1 SIMPLE t2 NULL eq_ref PRIMARY,Population PRIMARY 12 test.t1.Country 1 75.00 Using where +1 SIMPLE t3 NULL eq_ref PRIMARY,Percentage PRIMARY 132 test.t1.Country,const 1 95.45 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t2.Population' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t2`.`Name` AS `Name` from `test`.`t3` join `test`.`t2` semi join (`test`.`t1`) where ((`test`.`t2`.`Code` = `test`.`t1`.`Country`) and (`test`.`t3`.`Country` = `test`.`t1`.`Country`) and (`test`.`t3`.`Language` = 'English') and (`test`.`t3`.`Percentage` > 10) and (`test`.`t2`.`Population` > 100000) and (`test`.`t1`.`Population` > 5000000)) +EXPLAIN FORMAT=JSON SELECT Name FROM t2 +WHERE t2.Code IN (SELECT Country FROM t1 WHERE Population > 5000000) +AND +t2.Code IN (SELECT Country FROM t3 +WHERE Language='English' AND Percentage > 10 AND +t2.Population > 100000); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "2.46" + }, + "duplicates_removal": { + "using_temporary_table": true, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "range", + "possible_keys": [ + "Population", + "Country" + ], + "key": "Population", + "used_key_parts": [ + "Population" + ], + "key_length": "4", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.61", + "eval_cost": "0.10", + "prefix_cost": "0.71", + "data_read_per_join": "168" + }, + "used_columns": [ + "Country", + "Population" + ], + "attached_condition": "(`test`.`t1`.`Population` > 5000000)" + } + }, + { + "table": { + "table_name": "t2", + "access_type": "eq_ref", + "possible_keys": [ + "PRIMARY", + "Population" + ], + "key": "PRIMARY", + "used_key_parts": [ + "Code" + ], + "key_length": "12", + "ref": [ + "test.t1.Country" + ], + "rows_examined_per_scan": 1, + "rows_produced_per_join": 0, + "filtered": "75.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.08", + "prefix_cost": "2.21", + "data_read_per_join": "180" + }, + "used_columns": [ + "Code", + "Name", + "Population" + ], + "attached_condition": "(`test`.`t2`.`Population` > 100000)" + } + }, + { + "table": { + "table_name": "t3", + "access_type": "eq_ref", + "possible_keys": [ + "PRIMARY", + "Percentage" + ], + "key": "PRIMARY", + "used_key_parts": [ + "Country", + "Language" + ], + "key_length": "132", + "ref": [ + "test.t1.Country", + "const" + ], + "rows_examined_per_scan": 1, + "rows_produced_per_join": 0, + "filtered": "95.45", + "cost_info": { + "read_cost": "0.19", + "eval_cost": "0.07", + "prefix_cost": "2.47", + "data_read_per_join": "103" + }, + "used_columns": [ + "Country", + "Language", + "Percentage" + ], + "attached_condition": "((`test`.`t3`.`Language` = 'English') and (`test`.`t3`.`Percentage` > 10))" + } + } + ] + } + } +} +Warnings: +Note 1276 Field or reference 'test.t2.Population' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t2`.`Name` AS `Name` from `test`.`t3` join `test`.`t2` semi join (`test`.`t1`) where ((`test`.`t2`.`Code` = `test`.`t1`.`Country`) and (`test`.`t3`.`Country` = `test`.`t1`.`Country`) and (`test`.`t3`.`Language` = 'English') and (`test`.`t3`.`Percentage` > 10) and (`test`.`t2`.`Population` > 100000) and (`test`.`t1`.`Population` > 5000000)) +DROP TABLE t1,t2,t3; +CREATE TABLE t1 ( +Code char(3) NOT NULL DEFAULT '', +Name char(52) NOT NULL DEFAULT '', +Continent enum('Asia','Europe','North America','Africa','Oceania','Antarctica','South America') NOT NULL DEFAULT 'Asia', +Region char(26) NOT NULL DEFAULT '', +SurfaceArea float(10,2) NOT NULL DEFAULT '0.00', +IndepYear smallint(6) DEFAULT NULL, +Population int(11) NOT NULL DEFAULT '0', +LifeExpectancy float(3,1) DEFAULT NULL, +GNP float(10,2) DEFAULT NULL, +GNPOld float(10,2) DEFAULT NULL, +LocalName char(45) NOT NULL DEFAULT '', +GovernmentForm char(45) NOT NULL DEFAULT '', +HeadOfState char(60) DEFAULT NULL, +Capital int(11) DEFAULT NULL, +Code2 char(2) NOT NULL DEFAULT '', +PRIMARY KEY (Code) +) charset utf8mb4; +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t2 ( +ID int(11) NOT NULL AUTO_INCREMENT, +Name char(35) NOT NULL DEFAULT '', +CountryCode char(3) NOT NULL DEFAULT '', +District char(20) NOT NULL DEFAULT '', +Population int(11) NOT NULL DEFAULT '0', +PRIMARY KEY (ID), +KEY CountryCode (CountryCode) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +set names latin1; +Fill the table with test data +This must not use LooseScan: +EXPLAIN SELECT Name FROM t1 +WHERE t1.Code IN ( +SELECT t2.CountryCode FROM t2 WHERE Population > 5000000); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL CountryCode NULL NULL NULL 545 33.33 Using where; Start temporary +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 12 test.t2.CountryCode 1 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`Name` AS `Name` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`Code` = `test`.`t2`.`CountryCode`) and (`test`.`t2`.`Population` > 5000000)) +SELECT Name FROM t1 +WHERE t1.Code IN ( +SELECT t2.CountryCode FROM t2 WHERE Population > 5000000); +Name +Austria +Canada +China +Czech Republic +drop table t1, t2; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4); +create table t1 (a int, b int, key(a)); +insert into t1 select a,a from t0; +create table t2 (a int, b int, primary key(a)); +insert into t2 select * from t1; +Table t2, unlike table t1, should be displayed as pulled out +explain select * from t0 +where t0.a in ( select t1.a from t1,t2 where t2.a=t0.a and +t1.b=t2.b); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 5 100.00 Using where +1 SIMPLE t1 NULL ref a a 5 test.t0.a 1 100.00 Start temporary +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t0.a 1 20.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t0.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a` from `test`.`t2` join `test`.`t0` semi join (`test`.`t1`) where ((`test`.`t1`.`a` = `test`.`t0`.`a`) and (`test`.`t2`.`a` = `test`.`t0`.`a`) and (`test`.`t2`.`b` = `test`.`t1`.`b`)) +update t1 set a=3, b=11 where a=4; +update t2 set b=11 where a=3; +select * from t0 where t0.a in (select t1.a from t1, t2 where t2.a=t0.a and t1.b=t2.b); +a +0 +1 +2 +3 +drop table t0, t1, t2; +CREATE TABLE t1 ( +id int(11) NOT NULL, +PRIMARY KEY (id)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t2 ( +id int(11) NOT NULL, +fid int(11) NOT NULL, +PRIMARY KEY (id)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t1 values(1); +insert into t2 values(1,7503),(2,1); +explain select count(*) +from t1 +where fid IN (select fid from t2 where (id between 7502 and 8420) order by fid ); +ERROR 42S22: Unknown column 'fid' in 'IN/ALL/ANY subquery' +drop table t1, t2; +create table t1 (a int, b int, key (a), key (b)); +insert into t1 values (2,4),(2,4),(2,4); +select t1.a from t1 +where +t1.a in (select 1 from t1 where t1.a in (select 1 from t1) group by t1.a); +a +drop table t1; +create table t1(a int,b int,key(a),key(b)); +insert into t1 values (1,1),(2,2),(3,3); +select 1 from t1 +where t1.a not in (select 1 from t1 +where t1.a in (select 1 from t1) +group by t1.b); +1 +1 +1 +drop table t1; +CREATE TABLE t1 +(EMPNUM CHAR(3) NOT NULL, +EMPNAME CHAR(20), +GRADE DECIMAL(4), +CITY CHAR(15)); +CREATE TABLE t2 +(PNUM CHAR(3) NOT NULL, +PNAME CHAR(20), +PTYPE CHAR(6), +BUDGET DECIMAL(9), +CITY CHAR(15)); +CREATE TABLE t3 +(EMPNUM CHAR(3) NOT NULL, +PNUM CHAR(3) NOT NULL, +HOURS DECIMAL(5)); +INSERT INTO t1 VALUES ('E1','Alice',12,'Deale'); +INSERT INTO t1 VALUES ('E2','Betty',10,'Vienna'); +INSERT INTO t1 VALUES ('E3','Carmen',13,'Vienna'); +INSERT INTO t1 VALUES ('E4','Don',12,'Deale'); +INSERT INTO t1 VALUES ('E5','Ed',13,'Akron'); +INSERT INTO t2 VALUES ('P1','MXSS','Design',10000,'Deale'); +INSERT INTO t2 VALUES ('P2','CALM','Code',30000,'Vienna'); +INSERT INTO t2 VALUES ('P3','SDP','Test',30000,'Tampa'); +INSERT INTO t2 VALUES ('P4','SDP','Design',20000,'Deale'); +INSERT INTO t2 VALUES ('P5','IRM','Test',10000,'Vienna'); +INSERT INTO t2 VALUES ('P6','PAYR','Design',50000,'Deale'); +INSERT INTO t3 VALUES ('E1','P1',40); +INSERT INTO t3 VALUES ('E1','P2',20); +INSERT INTO t3 VALUES ('E1','P3',80); +INSERT INTO t3 VALUES ('E1','P4',20); +INSERT INTO t3 VALUES ('E1','P5',12); +INSERT INTO t3 VALUES ('E1','P6',12); +INSERT INTO t3 VALUES ('E2','P1',40); +INSERT INTO t3 VALUES ('E2','P2',80); +INSERT INTO t3 VALUES ('E3','P2',20); +INSERT INTO t3 VALUES ('E4','P2',20); +INSERT INTO t3 VALUES ('E4','P4',40); +INSERT INTO t3 VALUES ('E4','P5',80); +SELECT * FROM t1; +EMPNUM EMPNAME GRADE CITY +E1 Alice 12 Deale +E2 Betty 10 Vienna +E3 Carmen 13 Vienna +E4 Don 12 Deale +E5 Ed 13 Akron +CREATE UNIQUE INDEX t1_IDX ON t1(EMPNUM); +SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN +(SELECT EMPNUM +FROM t3 +WHERE PNUM IN +(SELECT PNUM +FROM t2 +WHERE PTYPE = 'Design')); +EMPNAME +Alice +Betty +Don +DROP INDEX t1_IDX ON t1; +CREATE INDEX t1_IDX ON t1(EMPNUM); +SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN +(SELECT EMPNUM +FROM t3 +WHERE PNUM IN +(SELECT PNUM +FROM t2 +WHERE PTYPE = 'Design')); +EMPNAME +Alice +Betty +Don +DROP INDEX t1_IDX ON t1; +SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN +(SELECT EMPNUM +FROM t3 +WHERE PNUM IN +(SELECT PNUM +FROM t2 +WHERE PTYPE = 'Design')); +EMPNAME +Alice +Betty +Don +DROP TABLE t1, t2, t3; +CREATE TABLE t1 (f1 INT NOT NULL); +CREATE VIEW v1 (a) AS SELECT f1 IN (SELECT f1 FROM t1) FROM t1; +SELECT * FROM v1; +a +drop view v1; +drop table t1; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1(a int, b int); +insert into t1 values (0,0),(1,1),(2,2); +create table t2 as select * from t1; +create table t3 (pk int, a int, primary key(pk)); +insert into t3 select a,a from t0; +explain +select * from t1 left join t2 on (t2.a= t1.a and t2.a in (select pk from t3)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE t3 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using index +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` left join (`test`.`t3` join `test`.`t2`) on(((`test`.`t3`.`pk` = `test`.`t1`.`a`) and (`test`.`t2`.`a` = `test`.`t1`.`a`))) where true +drop table t0, t1, t2, t3; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (a int) as select A.a + 10 *(B.a + 10*C.a) as a from t0 A, t0 B, t0 C; +create table t2 (id int, a int, primary key(id), key(a)) charset utf8mb4 as select a as id, a as a from t1; +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `id` int NOT NULL, + `a` int DEFAULT NULL, + PRIMARY KEY (`id`), + KEY `a` (`a`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +set @a=0; +create table t3 as select * from t2 limit 0; +insert into t3 select @a:=@a+1, t2.a from t2, t0; +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +insert into t3 select @a:=@a+1, t2.a from t2, t0; +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +insert into t3 select @a:=@a+1, t2.a from t2, t0; +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +alter table t3 add primary key(id), add 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); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index a a 5 NULL 1000 100.00 Using where; Using index +1 SIMPLE t3 NULL ref a a 5 test.t2.a 30 100.00 Using index; Start temporary; End temporary +Warnings: +Note 1003 /* select#1 */ select count(`test`.`t2`.`a`) AS `count(a)` from `test`.`t2` semi join (`test`.`t3`) where (`test`.`t3`.`a` = `test`.`t2`.`a`) +select count(a) from t2 where a in ( SELECT a FROM t3); +count(a) +1000 +drop table t0,t1,t2,t3; +# +# Bug#33062: subquery in stored routine cause crash +# +CREATE TABLE t1(a INT); +CREATE TABLE t2(c INT); +CREATE PROCEDURE p1(v1 int) +BEGIN +SELECT 1 FROM t1 WHERE a = v1 AND a IN (SELECT c FROM t2); +END +// +CREATE PROCEDURE p2(v1 int) +BEGIN +SELECT 1 FROM t1 WHERE a IN (SELECT c FROM t2); +END +// +CREATE PROCEDURE p3(v1 int) +BEGIN +SELECT 1 +FROM +t1 t01,t1 t02,t1 t03,t1 t04,t1 t05,t1 t06,t1 t07,t1 t08, +t1 t09,t1 t10,t1 t11,t1 t12,t1 t13,t1 t14,t1 t15,t1 t16, +t1 t17,t1 t18,t1 t19,t1 t20,t1 t21,t1 t22,t1 t23,t1 t24, +t1 t25,t1 t26,t1 t27,t1 t28,t1 t29,t1 t30,t1 t31,t1 t32, +t1 t33,t1 t34,t1 t35,t1 t36,t1 t37,t1 t38,t1 t39,t1 t40, +t1 t41,t1 t42,t1 t43,t1 t44,t1 t45,t1 t46,t1 t47,t1 t48, +t1 t49,t1 t50,t1 t51,t1 t52,t1 t53,t1 t54,t1 t55,t1 t56, +t1 t57,t1 t58,t1 t59,t1 t60 +WHERE t01.a IN (SELECT c FROM t2); +END +// +CREATE PROCEDURE p4(v1 int) +BEGIN +SELECT 1 +FROM +t1 t01,t1 t02,t1 t03,t1 t04,t1 t05,t1 t06,t1 t07,t1 t08, +t1 t09,t1 t10,t1 t11,t1 t12,t1 t13,t1 t14,t1 t15,t1 t16, +t1 t17,t1 t18,t1 t19,t1 t20,t1 t21,t1 t22,t1 t23,t1 t24, +t1 t25,t1 t26,t1 t27,t1 t28,t1 t29,t1 t30,t1 t31,t1 t32, +t1 t33,t1 t34,t1 t35,t1 t36,t1 t37,t1 t38,t1 t39,t1 t40, +t1 t41,t1 t42,t1 t43,t1 t44,t1 t45,t1 t46,t1 t47,t1 t48, +t1 t49,t1 t50,t1 t51,t1 t52,t1 t53,t1 t54,t1 t55,t1 t56, +t1 t57,t1 t58,t1 t59,t1 t60 +WHERE t01.a = v1 AND t01.a IN (SELECT c FROM t2); +END +// +CALL p1(1); +1 +CALL p2(1); +1 +CALL p3(1); +1 +CALL p4(1); +1 +DROP TABLE t1, t2; +DROP PROCEDURE p1; +DROP PROCEDURE p2; +DROP PROCEDURE p3; +DROP PROCEDURE p4; +# +# Bug#48213 Materialized subselect crashes if using GEOMETRY type +# +CREATE TABLE t1 ( +pk int, +a varchar(1), +b varchar(4), +c tinyblob, +d blob, +e mediumblob, +f longblob, +g tinytext, +h text, +i mediumtext, +j longtext, +k geometry, +PRIMARY KEY (pk) +) charset utf8mb4; +INSERT INTO t1 VALUES (1,'o','ffff','ffff','ffoo','ffff','ffff','ffff','ffff','ffff','ffff',ST_GeomFromText('POLYGON((0 0, 0 2, 2 2, 2 0, 0 0))')), (2,'f','ffff','ffff','ffff', 'ffff','ffff','ffff','ffff','ffff','ffff',ST_GeomFromText('POLYGON((0 0, 0 2, 2 2, 2 0, 0 0))')); +CREATE TABLE t2 LIKE t1; +INSERT INTO t2 VALUES (1,'i','iiii','iiii','iiii','iiii','ffff','ffff','ffff','ffff','ffff',ST_GeomFromText('POLYGON((0 0, 0 2, 2 2, 2 0, 0 0))')), (2,'f','ffff','ffff','ffff','ffff','ffff','ffff','ffff','ffff','ffff',ST_GeomFromText('POLYGON((0 0, 0 2, 2 2, 2 0, 0 0))')); +EXPLAIN SELECT pk FROM t1 WHERE (a, b) IN (SELECT a, b FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ 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); +pk +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, c) IN (SELECT b, c FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`c` = `test`.`t1`.`c`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, c) IN (SELECT b, c FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, d) IN (SELECT b, d FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`d` = `test`.`t1`.`d`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, d) IN (SELECT b, d FROM t2 WHERE pk > 0); +pk +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, e) IN (SELECT b, e FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`e` = `test`.`t1`.`e`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, e) IN (SELECT b, e FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, f) IN (SELECT b, f FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`f` = `test`.`t1`.`f`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, f) IN (SELECT b, f FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, g) IN (SELECT b, g FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`g` = `test`.`t1`.`g`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, g) IN (SELECT b, g FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, h) IN (SELECT b, h FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`h` = `test`.`t1`.`h`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, h) IN (SELECT b, h FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, i) IN (SELECT b, i FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`i` = `test`.`t1`.`i`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, i) IN (SELECT b, i FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, j) IN (SELECT b, j FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`j` = `test`.`t1`.`j`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, j) IN (SELECT b, j FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, k) IN (SELECT b, k FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`k` = `test`.`t1`.`k`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, k) IN (SELECT b, k FROM t2 WHERE pk > 0); +pk +1 +2 +DROP TABLE t1, t2; +# End of Bug#48213 +# +# BUG#53060: LooseScan semijoin strategy does not return all rows +# +CREATE TABLE t1 (i INTEGER); +INSERT INTO t1 VALUES (1), (2), (3), (4), (5); +CREATE TABLE t2 (i INTEGER, j INTEGER, KEY k(i, j)); +INSERT INTO t2 VALUES (1, 0), (1, 1), (2, 0), (2, 1); +EXPLAIN +SELECT * FROM t1 WHERE (i) IN (SELECT i FROM t2 where j > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index k k 10 NULL 4 33.33 Using where; Using index; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 20.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`i` = `test`.`t2`.`i`) and (`test`.`t2`.`j` > 0)) +SELECT * FROM t1 WHERE (i) IN (SELECT i FROM t2 where j > 0); +i +1 +2 +DROP TABLE t1, t2; +# End of BUG#53060 +# +# Bug#53305 "Duplicate weedout + join buffer (join cache --level=7,8) loses rows" +# +create table t1 (uid int, fid int, index(uid)); +insert into t1 values +(1,1), (1,2), (1,3), (1,4), +(2,5), (2,6), (2,7), (2,8), +(3,1), (3,2), (3,9); +create table t2 (uid int primary key, name varchar(128), index(name)); +insert into t2 values +(1, "A"), (2, "B"), (3, "C"), (4, "D"), (5, "E"), +(6, "F"), (7, "G"), (8, "H"), (9, "I"); +create table t3 (uid int, fid int, index(uid)); +insert into t3 values +(1,1), (1,2), (1,3),(1,4), +(2,5), (2,6), (2,7), (2,8), +(3,1), (3,2), (3,9); +create table t4 (uid int primary key, name varchar(128), index(name)); +insert into t4 values +(1, "A"), (2, "B"), (3, "C"), (4, "D"), (5, "E"), +(6, "F"), (7, "G"), (8, "H"), (9, "I"); +explain select name from t2, t1 +where t1.uid in (select t4.uid from t4, t3 where t3.uid=1 and t4.uid=t3.fid) +and t2.uid=t1.fid; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ref uid uid 5 const 4 100.00 Using where; Start temporary +1 SIMPLE t4 NULL eq_ref PRIMARY PRIMARY 4 test.t3.fid 1 100.00 Using index +1 SIMPLE t1 NULL ref uid uid 5 test.t3.fid 2 100.00 Using where +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.fid 1 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`name` AS `name` from `test`.`t4` join `test`.`t2` join `test`.`t1` semi join (`test`.`t3`) where ((`test`.`t4`.`uid` = `test`.`t3`.`fid`) and (`test`.`t1`.`uid` = `test`.`t3`.`fid`) and (`test`.`t3`.`uid` = 1) and (`test`.`t2`.`uid` = `test`.`t1`.`fid`)) +select name from t2, t1 +where t1.uid in (select t4.uid from t4, t3 where t3.uid=1 and t4.uid=t3.fid) +and t2.uid=t1.fid; +name +A +A +B +B +C +D +E +F +G +H +I +drop table t1,t2,t3,t4; +# +# Bug#43768 Prepared query with nested subqueries core dump on second execution +# +CREATE TABLE t1 ( +id INT PRIMARY KEY, +partner_id VARCHAR(35) +) charset utf8mb4; +INSERT INTO t1 VALUES +(1, 'partner1'), (2, 'partner2'), +(3, 'partner3'), (4, 'partner4'); +CREATE TABLE t2 ( +id INT NOT NULL, +t1_line_id INT, +article_id VARCHAR(20), +PRIMARY KEY(id, t1_line_id) +) charset utf8mb4; +INSERT INTO t2 VALUES +(1, 1, 'sup'), (2, 1, 'sup'), +(2, 2, 'sup'), (2, 3, 'sup'), +(2, 4, 'imp'), (3, 1, 'sup'), +(4, 1, 'sup'); +CREATE TABLE t3 ( +user_id VARCHAR(50), +article_id VARCHAR(20) NOT NULL, +PRIMARY KEY(user_id) +) charset utf8mb4; +INSERT INTO t3 VALUES('nicke', 'imp'); +EXPLAIN +SELECT t1.partner_id +FROM t1 +WHERE t1.id IN ( +SELECT t2.id +FROM t2 +WHERE article_id IN ( +SELECT article_id FROM t3 +WHERE user_id = 'nicke' + ) +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL system PRIMARY NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL PRIMARY NULL NULL NULL 7 14.29 Using where; Start temporary +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.id 1 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`partner_id` AS `partner_id` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`id` = `test`.`t2`.`id`) and (`test`.`t2`.`article_id` = 'imp')) +SELECT t1.partner_id +FROM t1 +WHERE t1.id IN ( +SELECT t2.id +FROM t2 +WHERE article_id IN ( +SELECT article_id FROM t3 +WHERE user_id = 'nicke' + ) +); +partner_id +partner2 +PREPARE stmt FROM +'EXPLAIN SELECT t1.partner_id +FROM t1 +WHERE t1.id IN ( + SELECT t2.id + FROM t2 + WHERE article_id IN ( + SELECT article_id FROM t3 + WHERE user_id = \'nicke\' + ) + )'; +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL system PRIMARY NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL PRIMARY NULL NULL NULL 7 14.29 Using where; Start temporary +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.id 1 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`partner_id` AS `partner_id` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`id` = `test`.`t2`.`id`) and (`test`.`t2`.`article_id` = 'imp')) + +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL system PRIMARY NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL PRIMARY NULL NULL NULL 7 14.29 Using where; Start temporary +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.id 1 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`partner_id` AS `partner_id` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`id` = `test`.`t2`.`id`) and (`test`.`t2`.`article_id` = 'imp')) +PREPARE stmt FROM +'SELECT t1.partner_id +FROM t1 +WHERE t1.id IN ( + SELECT t2.id + FROM t2 + WHERE article_id IN ( + SELECT article_id FROM t3 + WHERE user_id = \'nicke\' + ) + )'; +EXECUTE stmt; +partner_id +partner2 + +EXECUTE stmt; +partner_id +partner2 +DROP TABLE t1,t2,t3; +# End of Bug#43768 +# +# Bug#53058 - semijoin execution of subquery with outerjoin yields wrong result +# +CREATE TABLE t1 (i INTEGER); +CREATE TABLE t2 (i INTEGER); +CREATE TABLE t3 (i INTEGER); +INSERT INTO t1 VALUES (1), (2); +INSERT INTO t2 VALUES (6); +INSERT INTO t3 VALUES (1), (2); +explain SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t3 LEFT JOIN t2 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = `test`.`t1`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t3 LEFT JOIN t2 ON t2.i=t3.i); +i +1 +2 +drop table t1,t2,t3; +# +# BUG#49453: re-execution of prepared statement with view +# and semijoin crashes +# +CREATE TABLE t1 (city VARCHAR(50), country_id INT); +CREATE TABLE t2 (country_id INT, country VARCHAR(50)); +INSERT INTO t1 VALUES +('Batna',2),('Bchar',2),('Skikda',2),('Tafuna',3),('Algeria',2) ; +INSERT INTO t2 VALUES (2,'Algeria'),(2,'AlgeriaDup'),(3,'XAmerican Samoa'); +CREATE VIEW v1 AS +SELECT country_id as vf_country_id +FROM t2 +WHERE LEFT(country,1) = "A"; +PREPARE stmt FROM " +SELECT city, country_id +FROM t1 +WHERE country_id IN (SELECT vf_country_id FROM v1); +"; + +EXECUTE stmt; +city country_id +Algeria 2 +Batna 2 +Bchar 2 +Skikda 2 + +EXECUTE stmt; +city country_id +Algeria 2 +Batna 2 +Bchar 2 +Skikda 2 +DROP TABLE t1,t2; +DROP VIEW v1; +# +# Bug#54437 Extra rows with LEFT JOIN + semijoin (firstmatch +# and duplicates weedout) +# +create table t1 (a int); +create table t2 (a int); +create table t3 (a int); +insert into t1 values(1),(1); +insert into t2 values(1),(1),(1),(1); +insert into t3 values(2),(2); +explain select * from t1 where t1.a in (select t2.a from t2 left join t3 on t2.a=t3.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t2` left join `test`.`t3` on((`test`.`t2`.`a` = `test`.`t3`.`a`))) where (`test`.`t2`.`a` = `test`.`t1`.`a`) +select * from t1 where t1.a in (select t2.a from t2 left join t3 on t2.a=t3.a); +a +1 +1 +drop table t1,t2,t3; +# +# Bug#55955: crash in MEMORY engine with IN(LEFT JOIN (JOIN)) +# +CREATE TABLE t1 (a INT); +CREATE TABLE t2 (a INT); +CREATE TABLE t3 (a INT); +INSERT INTO t1 VALUES(1),(1); +INSERT INTO t2 VALUES(1),(1); +INSERT INTO t3 VALUES(2),(2); +explain SELECT * FROM t1 +WHERE t1.a IN (SELECT t2.a +FROM t2 LEFT JOIN (t2 AS t2inner, t3) ON t2.a=t3.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t2inner NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t2` left join (`test`.`t2` `t2inner` join `test`.`t3`) on((`test`.`t2`.`a` = `test`.`t3`.`a`))) where (`test`.`t2`.`a` = `test`.`t1`.`a`) +SELECT * FROM t1 +WHERE t1.a IN (SELECT t2.a +FROM t2 LEFT JOIN (t2 AS t2inner, t3) ON t2.a=t3.a); +a +1 +1 +DROP TABLE t1,t2,t3; +# +# BUG#52329 - Wrong result: subquery materialization, IN, +# non-null field followed by nullable +# +CREATE TABLE t1 (a1 CHAR(8) NOT NULL, a2 char(8) NOT NULL); +CREATE TABLE t2a (b1 char(8), b2 char(8)); +CREATE TABLE t2b (b1 CHAR(8), b2 char(8) NOT NULL); +CREATE TABLE t2c (b1 CHAR(8) NOT NULL, b2 char(8)); +INSERT INTO t1 VALUES ('1 - 12', '2 - 22'); +INSERT INTO t2a VALUES ('1 - 11', '2 - 21'), +('1 - 11', '2 - 21'), +('1 - 12', '2 - 22'), +('1 - 12', '2 - 22'), +('1 - 13', '2 - 23'); +INSERT INTO t2b SELECT * FROM t2a; +INSERT INTO t2c SELECT * FROM t2a; +SELECT * FROM t1 +WHERE (a1, a2) IN ( +SELECT b1, b2 FROM t2c WHERE b1 > '0' GROUP BY b1, b2); +a1 a2 +1 - 12 2 - 22 +SELECT * FROM t1 +WHERE (a1, a2) IN ( +SELECT b1, b2 FROM t2a WHERE b1 > '0'); +a1 a2 +1 - 12 2 - 22 +SELECT * FROM t1 +WHERE (a1, a2) IN ( +SELECT b1, b2 FROM t2b WHERE b1 > '0'); +a1 a2 +1 - 12 2 - 22 +SELECT * FROM t1 +WHERE (a1, a2) IN ( +SELECT b1, b2 FROM t2c WHERE b1 > '0'); +a1 a2 +1 - 12 2 - 22 +DROP TABLE t1,t2a,t2b,t2c; +# End BUG#52329 +# +# Bug#45174: Incorrectly applied equality propagation caused wrong +# result on a query with a materialized semi-join. +# +CREATE TABLE t1 ( +varchar_nokey varchar(1) NOT NULL +) charset utf8mb4; +INSERT INTO t1 VALUES +('v'), ('u'), ('n'), ('l'), ('h'), ('u'), ('n'), ('j'), ('k'), +('e'), ('i'), ('u'), ('n'), ('b'), ('x'), (''), ('q'), ('u'); +CREATE TABLE t2 ( +pk int NOT NULL, +varchar_key varchar(1) NOT NULL, +varchar_nokey varchar(1) NOT NULL, +PRIMARY KEY(pk), +KEY varchar_key(varchar_key) +) charset utf8mb4; +INSERT INTO t2 VALUES +(11,'m','m'), (12,'j','j'), (13,'z','z'), (14,'a','a'), (15,'',''), +(16,'e','e'), (17,'t','t'), (19,'b','b'), (20,'w','w'), (21,'m','m'), +(23,'',''), (24,'w','w'), (26,'e','e'), (27,'e','e'), (28,'p','p'); +SELECT varchar_nokey +FROM t1 +WHERE (varchar_nokey, varchar_nokey) IN (SELECT varchar_key, varchar_nokey +FROM t2 +WHERE varchar_nokey < 'n' XOR pk); +varchar_nokey +explain SELECT varchar_nokey +FROM t1 +WHERE (varchar_nokey, varchar_nokey) IN (SELECT varchar_key, varchar_nokey +FROM t2 +WHERE varchar_nokey < 'n' XOR pk); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 18 100.00 NULL +1 SIMPLE t2 NULL ref varchar_key varchar_key 6 test.t1.varchar_nokey 2 6.67 Using where; Start temporary; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`varchar_nokey` AS `varchar_nokey` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`varchar_key` = `test`.`t1`.`varchar_nokey`) and (`test`.`t2`.`varchar_nokey` = `test`.`t1`.`varchar_nokey`) and ((`test`.`t2`.`varchar_nokey` < 'n') xor (0 <> `test`.`t2`.`pk`))) +DROP TABLE t1, t2; +# End of the test for bug#45174. +# +# Bug#50019: Wrong result for IN-query with materialization +# +CREATE TABLE t1(i INT); +INSERT INTO t1 VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10); +CREATE TABLE t2(i INT); +INSERT INTO t2 VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10); +CREATE TABLE t3(i INT); +INSERT INTO t3 VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10); +SELECT * FROM t1 WHERE t1.i IN (SELECT t2.i +FROM t2 JOIN t3 +WHERE t2.i + t3.i = 5); +i +1 +2 +3 +4 +explain SELECT * FROM t1 WHERE t1.i IN (SELECT t2.i +FROM t2 JOIN t3 +WHERE t2.i + t3.i = 5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 100.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 10 10.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 10 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = `test`.`t1`.`i`) and ((`test`.`t1`.`i` + `test`.`t3`.`i`) = 5)) +DROP TABLE t1,t2,t3; +# End of the test for bug#50019. +# +# Bug#52068: Optimizer generates invalid semijoin materialization plan +# +CREATE TABLE ot1(a INTEGER); +INSERT INTO ot1 VALUES(5), (8); +CREATE TABLE it2(a INTEGER); +INSERT INTO it2 VALUES(9), (5), (1), (8); +CREATE TABLE it3(a INTEGER); +INSERT INTO it3 VALUES(7), (1), (0), (5), (1), (4); +CREATE TABLE ot4(a INTEGER); +INSERT INTO ot4 VALUES(1), (3), (5), (7), (9), (7), (3), (1); +SELECT * FROM ot1,ot4 +WHERE (ot1.a,ot4.a) IN (SELECT it2.a,it3.a +FROM it2,it3); +a a +5 1 +5 1 +5 5 +5 7 +5 7 +8 1 +8 1 +8 5 +8 7 +8 7 +explain SELECT * FROM ot1,ot4 +WHERE (ot1.a,ot4.a) IN (SELECT it2.a,it3.a +FROM it2,it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE it2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; Using join buffer (hash join) +1 SIMPLE it3 NULL ALL NULL NULL NULL NULL 6 100.00 Using join buffer (hash join) +1 SIMPLE ot4 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot4`.`a` AS `a` from `test`.`ot1` join `test`.`ot4` semi join (`test`.`it2` join `test`.`it3`) where ((`test`.`ot4`.`a` = `test`.`it3`.`a`) and (`test`.`it2`.`a` = `test`.`ot1`.`a`)) +DROP TABLE IF EXISTS ot1, ot4, it2, it3; +# End of the test for bug#52068. +# +# Bug#57623: subquery within before insert trigger causes crash (sj=on) +# +CREATE TABLE ot1(a INT); +CREATE TABLE ot2(a INT); +CREATE TABLE ot3(a INT); +CREATE TABLE it1(a INT); +INSERT INTO ot1 VALUES(0),(1),(2),(3),(4),(5),(6),(7); +INSERT INTO ot2 VALUES(0),(2),(4),(6); +INSERT INTO ot3 VALUES(0),(3),(6); +INSERT INTO it1 VALUES(0),(1),(2),(3),(4),(5),(6),(7); +explain SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 on ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a from it1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 Start temporary +1 SIMPLE it1 NULL ALL NULL NULL NULL NULL 8 100.00 Using where; Using join buffer (hash join) +1 SIMPLE ot3 NULL ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (hash join) +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a`,`test`.`ot3`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` join `test`.`ot3` semi join (`test`.`it1`)) on(((`test`.`it1`.`a` = `test`.`ot1`.`a`) and (`test`.`ot3`.`a` = `test`.`ot1`.`a`) and (`test`.`ot2`.`a` = `test`.`ot1`.`a`))) where true +SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 on ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a from it1); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +prepare s from 'SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 on ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a from it1)'; +execute s; +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +execute s; +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +deallocate prepare s; +DROP TABLE ot1, ot2, ot3, it1; +# End of the test for bug#57623. +# +# Bug#11766739: Crash in tmp_table_param::init() with semijoin=on +# +CREATE TABLE t1 (f1 INTEGER) ENGINE=MyISAM; +CREATE TABLE t2 (f1 INTEGER, f2 INTEGER) ENGINE=MyISAM; +INSERT INTO t1 VALUES (1); +INSERT INTO t2 VALUES (1,1), (2,1); +EXPLAIN SELECT * FROM t2 +WHERE f2 IN (SELECT t1.f1 +FROM t1 LEFT OUTER JOIN (t2 AS b1 JOIN t2 AS b2 ON TRUE) ON TRUE); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE b1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +1 SIMPLE b2 NULL ALL NULL NULL NULL NULL 2 100.00 End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`f1` AS `f1`,`test`.`t2`.`f2` AS `f2` from `test`.`t2` semi join (`test`.`t1` left join (`test`.`t2` `b1` join `test`.`t2` `b2`) on((true))) where (`test`.`t2`.`f2` = `test`.`t1`.`f1`) +SELECT * FROM t2 +WHERE f2 IN (SELECT t1.f1 +FROM t1 LEFT OUTER JOIN (t2 AS b1 JOIN t2 AS b2 ON TRUE) ON TRUE); +f1 f2 +1 1 +2 1 +DROP TABLE t1, t2; +# End of the test for bug#11766739. +# +# Bug#11766642: crash in Item_field::register_field_in_read_map with view +# +CREATE TABLE t1(a INT); +CREATE VIEW v1 AS SELECT a FROM t1; +INSERT INTO t1 VALUES (0),(1),(2); +SELECT a FROM t1 WHERE a IN +(SELECT a XOR a FROM v1) +ORDER BY a; +a +0 +DROP TABLE t1; +DROP VIEW v1; +# +# Bug#12546542 MISSING ROW WHEN USING OPTIMIZER_JOIN_CACHE_LEVEL>=3 +# +CREATE TABLE t1 ( +f2 varchar(1024) +); +INSERT INTO t1 VALUES ('v'),('we'); +CREATE TABLE t2 ( +col_varchar_1024_utf8 varchar(1024) CHARACTER SET utf8 DEFAULT NULL, +col_int_key int, +col_int int +); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t2 VALUES ('we',4,NULL),('v',1305673728,6); +CREATE TABLE t3 ( +col_int_key int, +col_int int +); +INSERT INTO t3 VALUES (4,4); +SELECT * +FROM t1 +WHERE f2 IN (SELECT a1.col_varchar_1024_utf8 AS f2 +FROM t2 AS a1 LEFT JOIN t3 AS a2 +ON a1.col_int_key = a2.col_int_key +WHERE a1.col_int BETWEEN 1 AND 10 OR a2.col_int IS NOT NULL); +f2 +v +we +DROP TABLE t1,t2,t3; +# +# BUG#12616344 - JCL: DIFFERENT RESULT SET AND DIFFERENT AMOUNT +# OF ROWS WHEN JCL>=3 +# +CREATE TABLE t1 (col_int_nokey int, col_int_key int, col_varchar_key varchar(1)); +INSERT INTO t1 VALUES (0,4,'c'),(1,6,'u'); +CREATE TABLE t2 (pk int, col_int_nokey int, col_varchar_nokey varchar(1)); +INSERT INTO t2 VALUES (1,4,'b'),(94,6,'u'); +CREATE TABLE t3 (pk int, col_int_nokey int, col_varchar_key varchar(1)); +INSERT INTO t3 VALUES (1,4,'j'),(2,6,'v'); +SELECT table2.col_int_key +from t3 as table1 join t1 as table2 on table2.col_int_nokey +where table1.col_int_nokey in +( +select subquery2_t2.col_int_nokey +from t3 as subquery2_t1 +right join +t2 as subquery2_t2 +join t1 as subquery2_t3 +on subquery2_t3.col_int_key = subquery2_t2.col_int_nokey +on subquery2_t3.col_varchar_key = subquery2_t2.col_varchar_nokey +where subquery2_t1.col_varchar_key != table1.col_varchar_key +or subquery2_t2.pk <= table1.pk +); +col_int_key +6 +6 +DROP TABLE t1,t2,t3; +# +# Bug#12608157: ASSERT IN FIELD_LONG::VAL_INT WHEN USING MEMORY ENGINE +# +CREATE TABLE t1 (i1 int); +INSERT INTO t1 VALUES (1); +CREATE TABLE t2 (i1 int, i2 int) ENGINE=memory; +INSERT INTO t2 VALUES (1, 2),(7, 3); +SELECT GRANDPARENT1.i1 +FROM t2 AS GRANDPARENT1 +WHERE GRANDPARENT1.i2 +IN ( SELECT PARENT1.i2 +FROM t2 AS PARENT1 JOIN t1 AS PARENT2 ON (PARENT1.i1 = PARENT2.i1) +WHERE +GRANDPARENT1.i1 IN ( SELECT CHILD1.i1 FROM t2 AS CHILD1 ) +ORDER BY PARENT1.i1) +ORDER BY GRANDPARENT1.i2 ; +i1 +1 +DROP TABLE t1,t2; +# +# Bug#12640083: Same query executed as WHERE subquery gives different +# results on IN() compare +# +CREATE TABLE t1 ( +pk int NOT NULL, +col_varchar_1024_utf8_key varchar(1024) CHARACTER SET utf8 DEFAULT NULL, +col_varchar_10_latin1_key varchar(10) DEFAULT NULL, +PRIMARY KEY (pk), +KEY col_varchar_1024_utf8_key(col_varchar_1024_utf8_key(333)), +KEY col_varchar_10_latin1_key(col_varchar_10_latin1_key) +) charset utf8mb4; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES +(1, 'a', 'a'), +(2, 'ab', 'ab'), +(3, 'abc', 'abc'), +(4, 'abcd', 'abcd'); +CREATE TABLE t2 ( +pk int NOT NULL AUTO_INCREMENT, +PRIMARY KEY (pk) +) charset utf8mb4 ENGINE=Innodb; +CREATE TABLE t3 charset utf8mb4 +SELECT alias1.col_varchar_10_latin1_key +FROM t1 AS alias1 +LEFT JOIN t1 AS alias2 +JOIN t2 AS alias3 +ON alias2.col_varchar_10_latin1_key +ON alias1.col_varchar_1024_utf8_key +WHERE alias1.pk AND alias1.pk < 3 OR alias1.pk AND alias3.pk; +EXPLAIN SELECT * +FROM t3 +WHERE col_varchar_10_latin1_key IN ( +SELECT alias1.col_varchar_10_latin1_key +FROM t1 AS alias1 +LEFT JOIN t1 AS alias2 +JOIN t2 AS alias3 +ON alias2.col_varchar_10_latin1_key +ON alias1.col_varchar_1024_utf8_key +WHERE alias1.pk AND alias1.pk < 3 OR alias1.pk AND alias3.pk); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Start temporary +1 SIMPLE alias1 NULL ref PRIMARY,col_varchar_10_latin1_key col_varchar_10_latin1_key 43 test.t3.col_varchar_10_latin1_key 2 100.00 Using where +1 SIMPLE alias3 NULL index NULL PRIMARY 4 NULL 1 100.00 Using where; Using index; Using join buffer (hash join) +1 SIMPLE alias2 NULL index NULL col_varchar_10_latin1_key 43 NULL 4 100.00 Using where; Using index; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`col_varchar_10_latin1_key` AS `col_varchar_10_latin1_key` from `test`.`t3` semi join (`test`.`t1` `alias1` left join (`test`.`t1` `alias2` join `test`.`t2` `alias3`) on(((0 <> `test`.`alias1`.`col_varchar_1024_utf8_key`) and (0 <> `test`.`alias2`.`col_varchar_10_latin1_key`)))) where ((`test`.`alias1`.`col_varchar_10_latin1_key` = `test`.`t3`.`col_varchar_10_latin1_key`) and (((0 <> `test`.`alias1`.`pk`) and (`test`.`alias1`.`pk` < 3)) or ((0 <> `test`.`alias1`.`pk`) and (0 <> `test`.`alias3`.`pk`)))) +SELECT * +FROM t3 +WHERE col_varchar_10_latin1_key IN ( +SELECT alias1.col_varchar_10_latin1_key +FROM t1 AS alias1 +LEFT JOIN t1 AS alias2 +JOIN t2 AS alias3 +ON alias2.col_varchar_10_latin1_key +ON alias1.col_varchar_1024_utf8_key +WHERE alias1.pk AND alias1.pk < 3 OR alias1.pk AND alias3.pk); +col_varchar_10_latin1_key +a +ab +DROP TABLE t1, t2, t3; +# End of the test for bug#12640083. +# +# Bug#12603200 - Assert in QUICK_INDEX_MERGE_SELECT::need_sorted_output +# +CREATE TABLE t1 ( +pk int NOT NULL, +col_int_key int NOT NULL, +col_varchar_nokey varchar(1) NOT NULL, +col_varchar_key varchar(1) NOT NULL, +PRIMARY KEY(pk), +KEY col_int_key(col_int_key), +KEY col_varchar_key(col_varchar_key, col_int_key) +) charset utf8mb4 engine=innodb; +INSERT INTO t1 VALUES +(1,7,'a','a'), +(2,0,'v','v'), +(3,9,'c','c'), +(4,3,'m','m'), +(5,2,'a','a'), +(6,1,'d','d'), +(7,8,'y','y'), +(8,6,'t','t'), +(11,7,'a','x'), +(12,0,'v','v'), +(13,9,'c','c'), +(14,3,'m','m'), +(15,2,'a','x'), +(16,1,'d','d'), +(17,8,'y','y'), +(18,6,'t','u'), +(19,6,'t','u'); +CREATE TABLE t2 ( +pk int NOT NULL, +col_int_key int NOT NULL, +col_varchar_key varchar(1) NOT NULL, +PRIMARY KEY(pk), +KEY col_varchar_key(col_varchar_key, col_int_key) +) charset utf8mb4 engine=innodb; +INSERT INTO t2(pk,col_int_key,col_varchar_key) VALUES +(8,7,'c'), +(11,4,'l'), +(12,7,'b'), +(13,0,'c'), +(14,2,'i'), +(15,9,'h'), +(16,4,'q'), +(17,1,'m'), +(18,9,'b'), +(19,2,'e'), +(20,1,'c'), +(21,7,'z'), +(22,4,'l'), +(23,7,'z'), +(24,0,'c'), +(25,2,'i'), +(26,9,'h'), +(27,4,'q'), +(28,0,'a'), +(29,1,'d'); +EXPLAIN SELECT outr.col_varchar_key AS x, outr.pk AS y +FROM t1 AS outr +WHERE outr.col_varchar_key IN (SELECT innr.col_varchar_key +FROM t2 AS innr +WHERE innr.col_varchar_key = 'a' OR innr.pk = 8) +AND outr.col_varchar_nokey < 't' +ORDER BY outr.col_varchar_key, outr.pk; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE innr NULL index_merge PRIMARY,col_varchar_key col_varchar_key,PRIMARY 6,4 NULL 2 100.00 Using sort_union(col_varchar_key,PRIMARY); Using where; Using temporary; Using filesort; Start temporary +1 SIMPLE outr NULL ref col_varchar_key col_varchar_key 6 test.innr.col_varchar_key 1 33.33 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`outr`.`col_varchar_key` AS `x`,`test`.`outr`.`pk` AS `y` from `test`.`t1` `outr` semi join (`test`.`t2` `innr`) where ((`test`.`outr`.`col_varchar_key` = `test`.`innr`.`col_varchar_key`) and (`test`.`outr`.`col_varchar_nokey` < 't') and ((`test`.`innr`.`col_varchar_key` = 'a') or (`test`.`innr`.`pk` = 8))) order by `test`.`outr`.`col_varchar_key`,`test`.`outr`.`pk` +SELECT outr.col_varchar_key AS x, outr.pk AS y +FROM t1 AS outr +WHERE outr.col_varchar_key IN (SELECT innr.col_varchar_key +FROM t2 AS innr +WHERE innr.col_varchar_key = 'a' OR innr.pk = 8) +AND outr.col_varchar_nokey < 't' +ORDER BY outr.col_varchar_key, outr.pk; +x y +a 1 +a 5 +c 3 +c 13 +DROP TABLE t1, t2; +# End of bug#12603200 +# +# Bug#12603183: Segfault in hp_movelink +# +CREATE TABLE t1 ( +col_varchar_key varchar(1) , +col_varchar_nokey varchar(1) , +KEY col_varchar_key(col_varchar_key) +) charset latin1; +INSERT INTO t1 VALUES +('i','i'), +('h','h'), +('q','q'), +('a','a'), +('v','v'), +('u','u'), +('s','s'), +('y','y'), +('z','z'), +('h','h'), +('p','p'), +('e','e'), +('i','i'), +('y','y'), +('w','w'); +CREATE TABLE t2 ( +col_varchar_nokey varchar(1) +) charset latin1; +INSERT INTO t2 VALUES +('b'); +EXPLAIN SELECT grandparent1.col_varchar_nokey +FROM t1 AS grandparent1 LEFT JOIN t2 AS grandparent2 USING (col_varchar_nokey) +WHERE (grandparent1.col_varchar_key) IN +(SELECT parent1.col_varchar_nokey +FROM t1 AS parent1 +WHERE parent1.col_varchar_key IN +(SELECT child1.col_varchar_nokey AS c1 +FROM t1 AS child1 LEFT JOIN t2 AS child2 +ON (child1.col_varchar_key > child2.col_varchar_nokey))); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE child1 NULL ALL NULL NULL NULL NULL 15 100.00 Using where; Start temporary +1 SIMPLE child2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE parent1 NULL ref col_varchar_key col_varchar_key 4 test.child1.col_varchar_nokey 2 100.00 Using where +1 SIMPLE grandparent1 NULL ref col_varchar_key col_varchar_key 4 test.parent1.col_varchar_nokey 2 100.00 End temporary +1 SIMPLE grandparent2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`grandparent1`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t1` `grandparent1` left join `test`.`t2` `grandparent2` on((`test`.`grandparent2`.`col_varchar_nokey` = `test`.`grandparent1`.`col_varchar_nokey`)) semi join (`test`.`t1` `parent1` join `test`.`t1` `child1` left join `test`.`t2` `child2` on((`test`.`child1`.`col_varchar_key` > `test`.`child2`.`col_varchar_nokey`))) where ((`test`.`grandparent1`.`col_varchar_key` = `test`.`parent1`.`col_varchar_nokey`) and (`test`.`parent1`.`col_varchar_key` = `test`.`child1`.`col_varchar_nokey`)) +SELECT grandparent1.col_varchar_nokey +FROM t1 AS grandparent1 LEFT JOIN t2 AS grandparent2 USING (col_varchar_nokey) +WHERE (grandparent1.col_varchar_key) IN +(SELECT parent1.col_varchar_nokey +FROM t1 AS parent1 +WHERE parent1.col_varchar_key IN +(SELECT child1.col_varchar_nokey AS c1 +FROM t1 AS child1 LEFT JOIN t2 AS child2 +ON (child1.col_varchar_key > child2.col_varchar_nokey))); +col_varchar_nokey +a +e +h +h +i +i +p +q +s +u +v +w +y +y +z +DROP TABLE t1, t2; +# End of test for bug#12603183. +# +# Bug#12818569: Diff nr of rows returned when using IN/ALL+subquery +# +CREATE TABLE t1 ( +col_int_key INT NOT NULL, +col_datetime_key DATETIME NOT NULL, +col_varchar_key VARCHAR(1) NOT NULL, +KEY col_int_key (col_int_key), +KEY col_datetime_key(col_datetime_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t1 VALUES +(7,'2004-06-06 04:22:12','v'), (0,'2005-11-13 01:12:31','s'), +(9,'2002-05-04 01:50:00','l'), (3,'2004-10-27 10:28:45','y'), +(4,'2006-07-22 05:24:23','c'), (2,'2002-05-16 21:34:03','i'), +(5,'2008-04-17 10:45:30','h'), (3,'2009-04-21 02:58:02','q'), +(1,'2008-01-11 11:01:51','a'), (3,'1900-01-01 00:00:00','v'), +(6,'2007-05-17 18:24:57','u'), (7,'2007-08-07 00:00:00','s'), +(5,'2001-08-28 00:00:00','y'), (1,'2004-04-16 00:27:28','z'), +(204,'2005-05-03 07:06:22','h'), (224,'2009-03-11 17:09:50','p'), +(9,'2007-12-08 01:54:28','e'), (5,'2009-07-28 18:19:54','i'), +(0,'2008-06-08 00:00:00','y'), (3,'2005-02-09 09:20:26','w'); +CREATE TABLE t2 ( +col_varchar_nokey VARCHAR(1) NOT NULL +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t2 VALUES ('v'), ('y'), ('j'), ('c'), ('d'), ('r'); +explain SELECT col_varchar_key +FROM t1 +WHERE col_varchar_key IN (SELECT col_varchar_nokey +FROM t2) +ORDER BY col_datetime_key LIMIT 4; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 100.00 Using temporary; Using filesort; Start temporary +1 SIMPLE t1 NULL ref col_varchar_key col_varchar_key 6 test.t2.col_varchar_nokey 1 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col_varchar_key` AS `col_varchar_key` from `test`.`t1` semi join (`test`.`t2`) where (`test`.`t1`.`col_varchar_key` = `test`.`t2`.`col_varchar_nokey`) order by `test`.`t1`.`col_datetime_key` limit 4 +SELECT col_varchar_key +FROM t1 +WHERE col_varchar_key IN (SELECT col_varchar_nokey +FROM t2) +ORDER BY col_datetime_key LIMIT 4; +col_varchar_key +v +y +v +y +DROP TABLE t1, t2; +# End of test for bug#12818569. +# +# Bug#12803439: Assert in replace_subcondition() on update query +# +CREATE TABLE t1(a INTEGER); +INSERT INTO t1 values(1), (2); +CREATE TABLE t2(a INTEGER); +INSERT INTO t2 VALUES(1), (3); +SELECT * +FROM t1 +WHERE a IN (SELECT a +FROM t2 +HAVING a IN (SELECT a +FROM t2) +) +HAVING a IN (SELECT a +FROM t2); +a +1 +DROP TABLE t1, t2; +# End of test for bug#12803439. +# +# Bug#12797534: Segfault in hp_movelink still exists +# +CREATE TABLE t1 ( +g1 VARCHAR(1) NOT NULL +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t1 VALUES ('d'), ('s'); +CREATE TABLE t2 ( +pk INT NOT NULL, +col_int_key INT NOT NULL, +col_varchar_key VARCHAR(1) NOT NULL, +col_varchar_nokey VARCHAR(1) NOT NULL, +PRIMARY KEY (pk), +KEY col_varchar_key(col_varchar_key, col_int_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t2 VALUES +(1,4,'j','j'), (2,6,'v','v'), (3,3,'c','c'), (4,5,'m','m'), +(5,3,'d','d'), (6,246,'d','d'), (7,2,'y','y'), (8,9,'t','t'), +(9,3,'d','d'), (10,8,'s','s'), (11,1,'r','r'), (12,8,'m','m'), +(13,8,'b','b'), (14,5,'x','x'), (15,7,'g','g'), (16,5,'p','p'), +(17,1,'q','q'), (18,6,'w','w'), (19,2,'d','d'), (20,9,'e','e'); +CREATE TABLE t3 ( +pk INTEGER NOT NULL, +PRIMARY KEY (pk) +) ENGINE=InnoDB; +INSERT INTO t3 VALUES (10); +EXPLAIN SELECT * +FROM t1 +WHERE g1 NOT IN +(SELECT grandparent1.col_varchar_nokey AS g1 +FROM t2 AS grandparent1 +WHERE grandparent1.col_varchar_key IN +(SELECT parent1.col_varchar_nokey AS p1 +FROM t2 AS parent1 LEFT JOIN t3 AS parent2 USING (pk) +) +AND grandparent1.col_varchar_key IS NOT NULL +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 SIMPLE parent1 NULL ALL NULL NULL NULL NULL 20 100.00 Using where; Not exists; Start temporary +2 SIMPLE parent2 NULL eq_ref PRIMARY PRIMARY 4 test.parent1.pk 1 100.00 Using index +2 SIMPLE grandparent1 NULL ref col_varchar_key col_varchar_key 6 test.parent1.col_varchar_nokey 1 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`g1` AS `g1` from `test`.`t1` anti join (`test`.`t2` `grandparent1` join `test`.`t2` `parent1` left join `test`.`t3` `parent2` on((`test`.`parent2`.`pk` = `test`.`parent1`.`pk`))) on(((`test`.`grandparent1`.`col_varchar_nokey` = `test`.`t1`.`g1`) and (`test`.`grandparent1`.`col_varchar_key` = `test`.`parent1`.`col_varchar_nokey`) and (`test`.`grandparent1`.`col_varchar_key` is not null))) where true +SELECT * +FROM t1 +WHERE g1 NOT IN +(SELECT grandparent1.col_varchar_nokey AS g1 +FROM t2 AS grandparent1 +WHERE grandparent1.col_varchar_key IN +(SELECT parent1.col_varchar_nokey AS p1 +FROM t2 AS parent1 LEFT JOIN t3 AS parent2 USING (pk) +) +AND grandparent1.col_varchar_key IS NOT NULL +); +g1 +DROP TABLE t1, t2, t3; +CREATE TABLE t1 ( +pk INTEGER AUTO_INCREMENT, +col_int_key INTEGER , +col_varchar_key VARCHAR(1) , +col_varchar_nokey VARCHAR(1) , +PRIMARY KEY (pk), +KEY (col_varchar_key,col_int_key) +) ENGINE=INNODB; +INSERT INTO t1 (col_int_key,col_varchar_key,col_varchar_nokey) VALUES +(0,'x','x'), (1,'j','j'), (1,'r','r'), (9,'v','v'), (5,'r','r'); +CREATE TABLE t2 ( +pk INTEGER AUTO_INCREMENT, +col_int_key INTEGER , +col_varchar_key VARCHAR(1) , +col_varchar_nokey VARCHAR(1) , +PRIMARY KEY (pk), +KEY (col_int_key), +KEY (col_varchar_key,col_int_key) +) AUTO_INCREMENT=10 ENGINE=INNODB; +INSERT INTO t2 (col_int_key, col_varchar_key, col_varchar_nokey) VALUES +(NULL,'x','x'), (NULL,'j','j'), (8,'c','c'); +CREATE TABLE t3 +SELECT outr.col_varchar_nokey AS x +FROM t1 AS outr +WHERE outr.col_varchar_nokey IN +(SELECT innr.col_varchar_nokey AS y +FROM t2 AS innr +WHERE innr.col_int_key IS NULL) +AND outr.col_varchar_nokey IS NOT NULL +AND NOT col_varchar_key IS NULL; +SELECT * +FROM t3 +WHERE x NOT IN +(SELECT outr.col_varchar_nokey AS x +FROM t1 AS outr +WHERE outr.col_varchar_nokey IN +(SELECT innr.col_varchar_nokey AS y +FROM t2 AS innr +WHERE innr.col_int_key IS NULL) +AND outr.col_varchar_nokey IS NOT NULL +AND NOT col_varchar_key IS NULL); +x +DROP TABLE t1, t2, t3; +# End of test for bug#12797534. +# +# Bug#12714094: Assert in optimize_semijoin_nests() +# +CREATE TABLE it ( +pk int NOT NULL, +col_varchar VARCHAR(10) DEFAULT NULL, +PRIMARY KEY (pk) +) ENGINE=MyISAM; +INSERT INTO it VALUES (1, 'g'); +CREATE TABLE ot +SELECT alias1.pk AS field1 +FROM it AS alias1 +LEFT JOIN it AS alias2 +ON alias1.col_varchar = alias2.col_varchar +; +SELECT * +FROM ot +WHERE field1 IN ( +SELECT alias1.pk +FROM it AS alias1 +LEFT JOIN it AS alias2 +ON alias1.col_varchar = alias2.col_varchar +); +field1 +1 +DROP TABLE it, ot; +# End of test for bug#12714094 +# +# Bug#12867557: Valgrind: conditional jump/move at key_cmp +# +CREATE TABLE t1 ( +pk INTEGER AUTO_INCREMENT, +col_int_key INTEGER, +PRIMARY KEY (pk), +KEY (col_int_key) +) AUTO_INCREMENT=10; +INSERT INTO t1 (col_int_key) VALUES (8); +CREATE TABLE t2 ( +pk INTEGER AUTO_INCREMENT, +col_int_key INTEGER, +col_time_key TIME, +PRIMARY KEY (pk), +KEY (col_int_key), +KEY (col_time_key) +) AUTO_INCREMENT=10; +INSERT INTO t2 (col_int_key, col_time_key) +VALUES +(8, '22:55:23.019225'), (7, '10:19:31.050677'), (1, '14:40:36.038608'), +(7, '04:37:47.062416'), (9, '19:34:06.054514'), (NULL,'20:35:33.022996'), +(1, NULL), (9, '14:43:37.057393'), (2, '02:23:09.043438'), +(9, '01:22:45.041064'), (2, '00:00:00'), (4, '00:13:25.038482'), +(0, '03:47:16.042671'), (4, '01:41:48.007423'), (8, '00:00:00'), +(NULL, '22:32:04.047407'), (NULL, '16:44:14.028443'), (0, '17:38:37.059754'), +(NULL, '08:46:48.042388'), (8, '14:11:27.044095'); +CREATE TABLE t0 +SELECT DISTINCT grandparent1.col_time_key AS g1 +FROM t2 AS grandparent1 +WHERE grandparent1.col_int_key IN +(SELECT parent1.col_int_key AS p1 +FROM t1 AS parent1) +AND grandparent1.pk > 9; +UPDATE t0 +SET g1 = g1 +WHERE g1 IN +(SELECT grandparent1.col_time_key AS g1 +FROM t2 AS grandparent1 +WHERE grandparent1.col_int_key IN +(SELECT parent1.col_int_key AS p1 +FROM t1 AS parent1) +AND grandparent1.pk > 9); +DROP TABLE t0, t1, t2; +# End of test for bug#12867557 +# +# Bug#12711441: crash in fix_after_pullout +# +CREATE TABLE t1 ( +pk int NOT NULL, +col_int_nokey int DEFAULT NULL, +col_int_key int DEFAULT NULL, +col_time_key time DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +PRIMARY KEY (pk) +); +CREATE VIEW v1 AS SELECT * FROM t1; +CREATE TABLE t2 ( +col_int_key int DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +KEY col_varchar_key(col_varchar_key, col_int_key) +); +CREATE TABLE t3 ( +pk int NOT NULL, +col_int_key INT DEFAULT NULL, +PRIMARY KEY (pk) +); +CREATE TABLE t4 ( +col_int_nokey INT DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +KEY col_varchar_key(col_varchar_key) +); +CREATE TABLE ts +SELECT alias1.col_time_key AS field1 +FROM v1 AS alias1 +RIGHT JOIN t3 AS alias2 +ON alias2.col_int_key = alias1.col_int_nokey +WHERE alias1.pk >= SOME( +SELECT SQ1_alias1.pk AS SQ1_field1 +FROM t3 AS SQ1_alias1 +INNER JOIN (t2 AS SQ1_alias2 +INNER JOIN t4 AS SQ1_alias3 +ON SQ1_alias3.col_varchar_key = SQ1_alias2.col_varchar_nokey) +ON SQ1_alias3.col_int_nokey = SQ1_alias2.col_int_key +WHERE SQ1_alias2.col_varchar_key <= alias1.col_varchar_key +AND SQ1_alias3.col_varchar_nokey <> alias1.col_varchar_key) +; +SELECT * FROM ts WHERE field1 IN ( +SELECT alias1.col_time_key AS field1 +FROM v1 AS alias1 +RIGHT JOIN t3 AS alias2 +ON alias2.col_int_key = alias1.col_int_nokey +WHERE alias1.pk >= SOME( +SELECT SQ1_alias1.pk AS SQ1_field1 +FROM t3 AS SQ1_alias1 +INNER JOIN (t2 AS SQ1_alias2 +INNER JOIN t4 AS SQ1_alias3 +ON SQ1_alias3.col_varchar_key = SQ1_alias2.col_varchar_nokey) +ON SQ1_alias3.col_int_nokey = SQ1_alias2.col_int_key +WHERE SQ1_alias2.col_varchar_key <= alias1.col_varchar_key +AND SQ1_alias3.col_varchar_nokey <> alias1.col_varchar_key) +); +field1 +DROP TABLE t1, t2, t3, t4, ts; +DROP VIEW v1; +# End of test for bug#12711441. +# +# Bug#12664936: Same query executed as where subquery ... +# +CREATE TABLE t1 ( +col_varchar_key VARCHAR(1), +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4; +INSERT INTO t1 VALUES +('o'), ('w'), ('m'), ('q'), +('f'), ('p'), ('j'), ('c'); +CREATE TABLE t2 ( +col_int_nokey INTEGER, +col_int_key INTEGER, +col_varchar_key varchar(1), +KEY col_int_key (col_int_key) +) charset utf8mb4; +INSERT INTO t2 VALUES +(8,5,'u'),(4,5,'p'),(8,1,'o'),(NULL,7,'v'), +(1,2,'g'),(2,1,'q'),(NULL,7,'l'),(3,1,'n'); +CREATE TABLE t4 +SELECT t2.col_int_nokey, t2.col_varchar_key +FROM t1 JOIN t2 ON t2.col_varchar_key = t1.col_varchar_key +WHERE t2.col_int_key = 1; +EXPLAIN SELECT * +FROM t4 +WHERE (col_int_nokey, col_varchar_key) IN +(SELECT t2.col_int_nokey, t2.col_varchar_key +FROM t1 JOIN t2 ON t2.col_varchar_key = t1.col_varchar_key +WHERE t2.col_int_key = 1 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t4 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE t2 NULL ref col_int_key col_int_key 5 const 3 12.50 Using where; Start temporary +1 SIMPLE t1 NULL ref col_varchar_key col_varchar_key 7 test.t4.col_varchar_key 2 100.00 Using index; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`col_int_nokey` AS `col_int_nokey`,`test`.`t4`.`col_varchar_key` AS `col_varchar_key` from `test`.`t4` semi join (`test`.`t1` join `test`.`t2`) where ((`test`.`t2`.`col_varchar_key` = `test`.`t4`.`col_varchar_key`) and (`test`.`t1`.`col_varchar_key` = `test`.`t4`.`col_varchar_key`) and (`test`.`t2`.`col_int_nokey` = `test`.`t4`.`col_int_nokey`) and (`test`.`t2`.`col_int_key` = 1)) +SELECT * +FROM t4 +WHERE (col_int_nokey, col_varchar_key) IN +(SELECT t2.col_int_nokey, t2.col_varchar_key +FROM t1 JOIN t2 ON t2.col_varchar_key = t1.col_varchar_key +WHERE t2.col_int_key = 1 +); +col_int_nokey col_varchar_key +8 o +2 q +DROP TABLE t1, t2, t4; +# End of test for bug#12664936. +# +# Bug#13340270: assertion table->sort.record_pointers == __null +# +CREATE TABLE t1 ( +pk int NOT NULL, +col_int_key int DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key, col_int_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t1 VALUES +(10,8,'x','x'), +(11,7,'d','d'), +(12,1,'r','r'), +(13,7,'f','f'), +(14,9,'y','y'), +(15,NULL,'u','u'), +(16,1,'m','m'), +(17,9,NULL,NULL), +(18,2,'o','o'), +(19,9,'w','w'), +(20,2,'m','m'), +(21,4,'q','q'); +CREATE TABLE t2 +SELECT alias1.col_varchar_nokey AS field1 +FROM t1 AS alias1 JOIN t1 AS alias2 +ON alias2.col_int_key = alias1.pk OR +alias2.col_int_key = alias1.col_int_key +WHERE alias1.pk = 58 OR alias1.col_varchar_key = 'o' + +; +EXPLAIN SELECT * +FROM t2 +WHERE (field1) IN (SELECT alias1.col_varchar_nokey AS field1 +FROM t1 AS alias1 JOIN t1 AS alias2 +ON alias2.col_int_key = alias1.pk OR +alias2.col_int_key = alias1.col_int_key +WHERE alias1.pk = 58 OR alias1.col_varchar_key = 'o' +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE alias1 NULL index_merge PRIMARY,col_int_key,col_varchar_key col_varchar_key,PRIMARY 7,4 NULL 2 10.00 Using sort_union(col_varchar_key,PRIMARY); Using where; Using join buffer (hash join) +1 SIMPLE alias2 NULL ALL col_int_key NULL NULL NULL 12 19.00 Range checked for each record (index map: 0x2); End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`field1` AS `field1` from `test`.`t2` semi join (`test`.`t1` `alias1` join `test`.`t1` `alias2`) where ((`test`.`alias1`.`col_varchar_nokey` = `test`.`t2`.`field1`) and ((`test`.`alias1`.`pk` = 58) or (`test`.`alias1`.`col_varchar_key` = 'o')) and ((`test`.`alias2`.`col_int_key` = `test`.`alias1`.`pk`) or (`test`.`alias2`.`col_int_key` = `test`.`alias1`.`col_int_key`))) +SELECT * +FROM t2 +WHERE (field1) IN (SELECT alias1.col_varchar_nokey AS field1 +FROM t1 AS alias1 JOIN t1 AS alias2 +ON alias2.col_int_key = alias1.pk OR +alias2.col_int_key = alias1.col_int_key +WHERE alias1.pk = 58 OR alias1.col_varchar_key = 'o' +); +field1 +o +o +DROP TABLE t1, t2; +# End of test for bug#13340270. +# +# Bug#13335319: Seg fault when analyzing FirstMatch semi-join strategy +# +CREATE TABLE ot1(a INTEGER); +INSERT INTO ot1 VALUES(1), (2), (3); +CREATE TABLE ot2(a INTEGER); +INSERT INTO ot2 VALUES(1), (2), (4), (6), (8), (10); +CREATE TABLE it1(a INTEGER); +INSERT INTO it1 VALUES(1), (3), (5), (7); +CREATE TABLE it2(a INTEGER); +INSERT INTO it2 VALUES(1), (3), (5), (7), (9); +explain SELECT ot1.a, ot2.a +FROM ot1, ot2 +WHERE ot1.a IN (SELECT a FROM it1) AND +ot2.a IN (SELECT a FROM it2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 3 100.00 Start temporary +1 SIMPLE it1 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; Using join buffer (hash join) +1 SIMPLE it2 NULL ALL NULL NULL NULL NULL 5 100.00 Using join buffer (hash join) +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` join `test`.`ot2` semi join (`test`.`it1`) semi join (`test`.`it2`) where ((`test`.`ot2`.`a` = `test`.`it2`.`a`) and (`test`.`it1`.`a` = `test`.`ot1`.`a`)) +SELECT ot1.a, ot2.a +FROM ot1, ot2 +WHERE ot1.a IN (SELECT a FROM it1) AND +ot2.a IN (SELECT a FROM it2); +a a +1 1 +3 1 +DROP TABLE ot1, ot2, it1, it2; +# End of test for bug#13335319. +# +# Bug#13334882: Assertion keypart_map failed in MyIsam function +# +CREATE TABLE t1 ( +pk int NOT NULL, +col_int_nokey INT NOT NULL, +col_int_key INT NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +) ENGINE=MyISAM; +INSERT INTO t1 VALUES +(1,4,0), +(2,6,8), +(3,3,1), +(7,2,6), +(8,9,1), +(9,3,6), +(10,8,2), +(11,1,4), +(12,8,8), +(13,8,4), +(14,5,4); +CREATE TABLE t2 ( +pk int NOT NULL, +col_int_nokey int NOT NULL, +col_int_key int NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +) ENGINE=MyISAM; +INSERT INTO t2 VALUES +(10,8,7); +CREATE TABLE t3 +SELECT grandparent1.col_int_nokey AS g1 +FROM t1 AS grandparent1 +WHERE (grandparent1.col_int_nokey, grandparent1.col_int_key) IN +(SELECT parent1.col_int_key AS p1, +parent1.col_int_key AS p2 +FROM t1 AS parent1 +LEFT JOIN t2 AS parent2 +ON parent1.col_int_nokey = parent2.col_int_key +) +AND grandparent1.col_int_key <> 3 +; +explain SELECT * FROM t3 +WHERE g1 NOT IN +(SELECT grandparent1.col_int_nokey AS g1 +FROM t1 AS grandparent1 +WHERE (grandparent1.col_int_nokey, grandparent1.col_int_key) IN +(SELECT parent1.col_int_key AS p1, +parent1.col_int_key AS p2 +FROM t1 AS parent1 +LEFT JOIN t2 AS parent2 +ON parent1.col_int_nokey = parent2.col_int_key +) +AND grandparent1.col_int_key <> 3 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE grandparent1 NULL ref col_int_key col_int_key 4 const 1 100.00 Using where; Not exists; Start temporary +1 SIMPLE parent1 NULL ref col_int_key col_int_key 4 test.grandparent1.col_int_nokey 1 100.00 Using where +1 SIMPLE parent2 NULL ref col_int_key col_int_key 4 test.parent1.col_int_nokey 2 100.00 Using index; End temporary +Warnings: +Note 1003 /* select#1 */ select '8' AS `g1` from anti join (`test`.`t1` `grandparent1` join `test`.`t1` `parent1` left join `test`.`t2` `parent2` on((`test`.`parent2`.`col_int_key` = `test`.`parent1`.`col_int_nokey`))) on(((`test`.`grandparent1`.`col_int_nokey` = '8') and (`test`.`grandparent1`.`col_int_key` = '8') and (`test`.`parent1`.`col_int_key` = '8') and ('8' <> 3))) where true +explain format=json SELECT * FROM t3 +WHERE g1 NOT IN +(SELECT grandparent1.col_int_nokey AS g1 +FROM t1 AS grandparent1 +WHERE (grandparent1.col_int_nokey, grandparent1.col_int_key) IN +(SELECT parent1.col_int_key AS p1, +parent1.col_int_key AS p2 +FROM t1 AS parent1 +LEFT JOIN t2 AS parent2 +ON parent1.col_int_nokey = parent2.col_int_key +) +AND grandparent1.col_int_key <> 3 +); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "2.70" + }, + "nested_loop": [ + { + "table": { + "table_name": "t3", + "access_type": "system", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.00", + "eval_cost": "0.10", + "prefix_cost": "0.00", + "data_read_per_join": "8" + }, + "used_columns": [ + "g1" + ] + } + }, + { + "duplicates_removal": { + "using_temporary_table": true, + "nested_loop": [ + { + "table": { + "table_name": "grandparent1", + "access_type": "ref", + "possible_keys": [ + "col_int_key" + ], + "key": "col_int_key", + "used_key_parts": [ + "col_int_key" + ], + "key_length": "4", + "ref": [ + "const" + ], + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "not_exists": true, + "cost_info": { + "read_cost": "0.28", + "eval_cost": "0.11", + "prefix_cost": "0.39", + "data_read_per_join": "17" + }, + "used_columns": [ + "col_int_nokey", + "col_int_key" + ], + "attached_condition": "(((is_not_null_compl(grandparent1..parent2), (found_match(grandparent1..parent2), false, true), true) and (is_not_null_compl(grandparent1..parent2), (('8' <> 3)), true)) and (is_not_null_compl(grandparent1..parent2), (`test`.`grandparent1`.`col_int_nokey` = '8'), true))" + } + }, + { + "table": { + "table_name": "parent1", + "access_type": "ref", + "possible_keys": [ + "col_int_key" + ], + "key": "col_int_key", + "used_key_parts": [ + "col_int_key" + ], + "key_length": "4", + "ref": [ + "test.grandparent1.col_int_nokey" + ], + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.30", + "eval_cost": "0.12", + "prefix_cost": "0.81", + "data_read_per_join": "19" + }, + "used_columns": [ + "col_int_nokey", + "col_int_key" + ], + "attached_condition": "(is_not_null_compl(grandparent1..parent2), (`test`.`parent1`.`col_int_key` = '8'), true)" + } + }, + { + "table": { + "table_name": "parent2", + "access_type": "ref", + "possible_keys": [ + "col_int_key" + ], + "key": "col_int_key", + "used_key_parts": [ + "col_int_key" + ], + "key_length": "4", + "ref": [ + "test.parent1.col_int_nokey" + ], + "rows_examined_per_scan": 2, + "rows_produced_per_join": 1, + "filtered": "100.00", + "using_index": true, + "cost_info": { + "read_cost": "0.31", + "eval_cost": "0.10", + "prefix_cost": "2.70", + "data_read_per_join": "16" + }, + "used_columns": [ + "col_int_key" + ] + } + } + ] + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select '8' AS `g1` from anti join (`test`.`t1` `grandparent1` join `test`.`t1` `parent1` left join `test`.`t2` `parent2` on((`test`.`parent2`.`col_int_key` = `test`.`parent1`.`col_int_nokey`))) on(((`test`.`grandparent1`.`col_int_nokey` = '8') and (`test`.`grandparent1`.`col_int_key` = '8') and (`test`.`parent1`.`col_int_key` = '8') and ('8' <> 3))) where true +SELECT * FROM t3 +WHERE g1 NOT IN +(SELECT grandparent1.col_int_nokey AS g1 +FROM t1 AS grandparent1 +WHERE (grandparent1.col_int_nokey, grandparent1.col_int_key) IN +(SELECT parent1.col_int_key AS p1, +parent1.col_int_key AS p2 +FROM t1 AS parent1 +LEFT JOIN t2 AS parent2 +ON parent1.col_int_nokey = parent2.col_int_key +) +AND grandparent1.col_int_key <> 3 +); +g1 +DROP TABLE t1, t2, t3; +# End of test for bug#13334882. +# +# Bug#13339643: Assertion on JOIN::flatten_subqueries on second execution +# +CREATE TABLE t1 ( +col_int_nokey INT, +col_varchar_nokey VARCHAR(1) +) charset utf8mb4; +INSERT INTO t1 VALUES +(1,'o'), +(2,'t'); +CREATE TABLE t2 LIKE t1; +INSERT INTO t2 VALUES +(1,'o'), +(4,'f'); +CREATE VIEW v_t2 AS SELECT * FROM t2; +CREATE TABLE t3 LIKE t1; +INSERT INTO t3 VALUES +(1,'o'), +(4,'f'); +explain SELECT alias1.col_varchar_nokey +FROM t1 AS alias1 +INNER JOIN v_t2 AS alias2 +ON alias2.col_int_nokey = alias1.col_int_nokey AND +'o' IN (SELECT col_varchar_nokey +FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary; End temporary +1 SIMPLE alias1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`alias1`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t1` `alias1` join `test`.`t2` semi join (`test`.`t3`) where ((`test`.`t3`.`col_varchar_nokey` = 'o') and (`test`.`t2`.`col_int_nokey` = `test`.`alias1`.`col_int_nokey`)) +SELECT alias1.col_varchar_nokey +FROM t1 AS alias1 +INNER JOIN v_t2 AS alias2 +ON alias2.col_int_nokey = alias1.col_int_nokey AND +'o' IN (SELECT col_varchar_nokey +FROM t3); +col_varchar_nokey +o +PREPARE stmt FROM "SELECT alias1.col_varchar_nokey +FROM t1 AS alias1 +INNER JOIN v_t2 AS alias2 +ON alias2.col_int_nokey = alias1.col_int_nokey AND +'o' IN (SELECT col_varchar_nokey +FROM t3)"; +EXECUTE stmt; +col_varchar_nokey +o +DROP VIEW v_t2; +DROP TABLE t1, t2, t3; +# End of test for bug#13339643. +# +# Bug#13424134: Wrong result on JOIN + nested WHERE ... IN clauses +# +CREATE TABLE t1 ( +pk int NOT NULL, +col_int_nokey int NOT NULL, +col_int_key int NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +) ENGINE=MyIsam; +INSERT INTO t1 VALUES +(10,1,7), (13,7,3), (18,0,1), (23,8,1); +CREATE TABLE t2 ( +pk int NOT NULL, +col_int_key int NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +) ENGINE=MyIsam; +INSERT INTO t2 VALUES (1,7); +EXPLAIN SELECT t1a.* +FROM t1 AS t1a +JOIN t1 AS t1b USING ( col_int_nokey ) +WHERE t1a.col_int_key IN ( +SELECT pk +FROM t2 +WHERE col_int_key IN ( +SELECT col_int_nokey +FROM t1 +) +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL system PRIMARY,col_int_key NULL NULL NULL 1 100.00 NULL +1 SIMPLE t1a NULL ref col_int_key col_int_key 4 const 1 100.00 Start temporary +1 SIMPLE t1b NULL ALL NULL NULL NULL NULL 4 25.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1a`.`pk` AS `pk`,`test`.`t1a`.`col_int_nokey` AS `col_int_nokey`,`test`.`t1a`.`col_int_key` AS `col_int_key` from `test`.`t1` `t1a` join `test`.`t1` `t1b` semi join (`test`.`t1`) where ((`test`.`t1b`.`col_int_nokey` = `test`.`t1a`.`col_int_nokey`) and (`test`.`t1a`.`col_int_key` = '1') and (`test`.`t1`.`col_int_nokey` = '7')) +SELECT t1a.* +FROM t1 AS t1a +JOIN t1 AS t1b USING ( col_int_nokey ) +WHERE t1a.col_int_key IN ( +SELECT pk +FROM t2 +WHERE col_int_key IN ( +SELECT col_int_nokey +FROM t1 +) +); +pk col_int_nokey col_int_key +18 0 1 +23 8 1 +ALTER TABLE t1 ENGINE=Innodb; +ALTER TABLE t2 ENGINE=Innodb; +SELECT t1a.* +FROM t1 AS t1a +JOIN t1 AS t1b USING ( col_int_nokey ) +WHERE t1a.col_int_key IN ( +SELECT pk +FROM t2 +WHERE col_int_key IN ( +SELECT col_int_nokey +FROM t1 +) +); +pk col_int_nokey col_int_key +18 0 1 +23 8 1 +DROP TABLE t1, t2; +# End of test for bug#13424134. +# +# Bug#13414014: Extra rows in result on semijoin query with where ... +# +CREATE TABLE t1 ( +c INT, +d INT, +a VARCHAR(1), +b VARCHAR(1), +KEY a (a) +) charset utf8mb4; +INSERT INTO t1 VALUES +(NULL,8,'x','x'), (7,4,'q','q'), (6,8,'c','c'); +CREATE TABLE t2 ( +a VARCHAR(1), +KEY a (a) +) charset utf8mb4; +INSERT INTO t2 VALUES +('c'), (NULL), ('x'), ('q'); +explain SELECT * +FROM t2 AS ot +WHERE (a, a) IN +(SELECT a, b +FROM t1 AS it +WHERE it.a = 'x' OR it.c > it.d +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE it NULL ALL a NULL NULL NULL 3 40.74 Using where; Start temporary +1 SIMPLE ot NULL ref a a 7 test.it.a 2 100.00 Using index; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`ot`.`a` AS `a` from `test`.`t2` `ot` semi join (`test`.`t1` `it`) where ((`test`.`it`.`b` = `test`.`it`.`a`) and (`test`.`ot`.`a` = `test`.`it`.`a`) and ((`test`.`it`.`a` = 'x') or (`test`.`it`.`c` > `test`.`it`.`d`))) +SELECT * +FROM t2 AS ot +WHERE (a, a) IN +(SELECT a, b +FROM t1 AS it +WHERE it.a = 'x' OR it.c > it.d +) +; +a +q +x +DROP TABLE t1, t2; +# End of test for bug#13414014. +# +# Bug#13545215: Missing rows on nested in-subquery with materialization +# +CREATE TABLE t1 ( +col_int_key int, +col_varchar_key varchar(1), +col_varchar_nokey varchar(1), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +INSERT INTO t1 VALUES +(8,'x','x'), (0,'p','p'), (8,'c','c'); +CREATE TABLE t2 ( +pk int NOT NULL, +col_varchar_key varchar(1), +col_varchar_nokey varchar(1), +PRIMARY KEY (pk), +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4; +INSERT INTO t2 VALUES +(1,'v','v'), (2,'v','v'), (3,'c','c'), (4,NULL,NULL), +(5,'x','x'), (6,'i','i'), (7,'e','e'), (8,'p','p'); +CREATE TABLE t3 ( +col_int_nokey int +); +INSERT INTO t3 VALUES (7); +explain SELECT grandparent1.col_varchar_nokey +FROM t1 AS grandparent1 JOIN t1 AS grandparent2 USING (col_int_key) +WHERE grandparent1.col_varchar_key IN ( +SELECT col_varchar_nokey +FROM t2 AS parent1 +WHERE col_varchar_key IN ( +SELECT child1.col_varchar_nokey +FROM t2 AS child1 LEFT JOIN t3 AS child2 +ON child1.pk < child2.col_int_nokey +) +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE grandparent1 NULL ALL col_int_key,col_varchar_key NULL NULL NULL 3 100.00 Using where; Start temporary +1 SIMPLE parent1 NULL ALL col_varchar_key NULL NULL NULL 8 12.50 Using where; Using join buffer (hash join) +1 SIMPLE child1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; Using join buffer (hash join) +1 SIMPLE child2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +1 SIMPLE grandparent2 NULL ref col_int_key col_int_key 5 test.grandparent1.col_int_key 2 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`grandparent1`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t1` `grandparent1` join `test`.`t1` `grandparent2` semi join (`test`.`t2` `parent1` join `test`.`t2` `child1` left join `test`.`t3` `child2` on((`test`.`child1`.`pk` < `test`.`child2`.`col_int_nokey`))) where ((`test`.`grandparent2`.`col_int_key` = `test`.`grandparent1`.`col_int_key`) and (`test`.`parent1`.`col_varchar_nokey` = `test`.`grandparent1`.`col_varchar_key`) and (`test`.`child1`.`col_varchar_nokey` = `test`.`parent1`.`col_varchar_key`)) +SELECT grandparent1.col_varchar_nokey +FROM t1 AS grandparent1 JOIN t1 AS grandparent2 USING (col_int_key) +WHERE grandparent1.col_varchar_key IN ( +SELECT col_varchar_nokey +FROM t2 AS parent1 +WHERE col_varchar_key IN ( +SELECT child1.col_varchar_nokey +FROM t2 AS child1 LEFT JOIN t3 AS child2 +ON child1.pk < child2.col_int_nokey +) +); +col_varchar_nokey +c +c +p +x +x +DROP TABLE t1, t2, t3; +# End of test for bug#13545215. +# +# BUG#13553211 - MISSING ROWS ON SELECT WITH IN-SUBQUERY AND +# MATERIALIZATION + SEMIJOIN ON +# +CREATE TABLE t1 ( +col_int_key int(11) DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (4,'v','v'); +INSERT INTO t1 VALUES (62,'v','v'); +INSERT INTO t1 VALUES (7,'c','c'); +INSERT INTO t1 VALUES (1,NULL,NULL); +EXPLAIN SELECT +alias1.col_varchar_nokey AS a1_nokey, +alias1.col_varchar_key AS a1_key, +alias2.col_varchar_nokey AS a2_nokey +FROM +t1 AS alias1, t1 AS alias2 +WHERE +(alias1.col_varchar_nokey,alias2.col_varchar_nokey) +IN +( +SELECT +sq2_alias2.col_varchar_nokey, sq2_alias1.col_varchar_key +FROM +t1 AS sq2_alias1, t1 AS sq2_alias2 +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE alias1 NULL ALL NULL NULL NULL NULL 4 100.00 Start temporary +1 SIMPLE sq2_alias2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; Using join buffer (hash join) +1 SIMPLE alias2 NULL ALL NULL NULL NULL NULL 4 100.00 Using join buffer (hash join) +1 SIMPLE sq2_alias1 NULL index col_varchar_key col_varchar_key 12 NULL 4 25.00 Using where; Using index; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`alias1`.`col_varchar_nokey` AS `a1_nokey`,`test`.`alias1`.`col_varchar_key` AS `a1_key`,`test`.`alias2`.`col_varchar_nokey` AS `a2_nokey` from `test`.`t1` `alias1` join `test`.`t1` `alias2` semi join (`test`.`t1` `sq2_alias1` join `test`.`t1` `sq2_alias2`) where ((`test`.`sq2_alias1`.`col_varchar_key` = `test`.`alias2`.`col_varchar_nokey`) and (`test`.`sq2_alias2`.`col_varchar_nokey` = `test`.`alias1`.`col_varchar_nokey`)) +SELECT +alias1.col_varchar_nokey AS a1_nokey, +alias1.col_varchar_key AS a1_key, +alias2.col_varchar_nokey AS a2_nokey +FROM +t1 AS alias1, t1 AS alias2 +WHERE +(alias1.col_varchar_nokey,alias2.col_varchar_nokey) +IN +( +SELECT +sq2_alias2.col_varchar_nokey, sq2_alias1.col_varchar_key +FROM +t1 AS sq2_alias1, t1 AS sq2_alias2 +) +; +a1_nokey a1_key a2_nokey +c c c +c c v +c c v +v v c +v v c +v v v +v v v +v v v +v v v +DROP TABLE t1; +# +# Bug#13541406: Wrong result with loosescan on select .. where .. in +# +CREATE TABLE t1 ( +col_int_key INT NOT NULL, +col_varchar_nokey VARCHAR(1) NOT NULL, +KEY col_int_key (col_int_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t1 VALUES +(7,'v'), (0,'s'), (9,'l'), (3,'y'), (4,'c'), (2,'i'), (5,'h'), (3,'q'), +(1,'a'), (3,'v'), (6,'u'), (7,'s'), (5,'y'), (1,'z'), (204,'h'), (224,'p'), +(9,'e'), (5,'i'), (0,'y'), (3,'w'); +CREATE TABLE t2 ( +pk INT NOT NULL, +col_int_key INT NOT NULL, +col_varchar_key VARCHAR(1) NOT NULL, +col_varchar_nokey VARCHAR(1) NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t2 VALUES +(1,0,'j','j'), (2,8,'v','v'), (3,1,'c','c'), (4,8,'m','m'), +(5,9,'d','d'), (6,24,'d','d'), (7,6,'y','y'), (8,1,'t','t'), +(9,6,'d','d'), (10,2,'s','s'), (11,4,'r','r'), (12,8,'m','m'), +(13,4,'b','b'), (14,4,'x','x'), (15,7,'g','g'), (16,4,'p','p'), +(17,1,'q','q'), (18,9,'w','w'), (19,4,'d','d'), (20,8,'e','e'); +# This query should never use a LooseScan strategy +explain SELECT ot1.col_int_key AS field1 +FROM t2 AS ot1, t2 AS ot2 +WHERE (ot1.col_varchar_key, ot2.col_varchar_nokey) IN ( +SELECT it2.col_varchar_nokey, it1.col_varchar_key +FROM t2 AS it1 JOIN t1 AS it2 ON it2.col_int_key = it1.pk); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 20 100.00 Parallel execute (1 workers) +2 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 20 100.00 NULL +2 SIMPLE it1 NULL ref PRIMARY,col_varchar_key col_varchar_key 6 test.ot2.col_varchar_nokey 1 100.00 Using index; Start temporary +2 SIMPLE it2 NULL ref col_int_key col_int_key 4 test.it1.pk 1 100.00 NULL +2 SIMPLE ot1 NULL ref col_varchar_key col_varchar_key 6 test.it2.col_varchar_nokey 1 100.00 Using index; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`col_int_key` AS `field1` from `test`.`t2` `ot1` join `test`.`t2` `ot2` semi join (`test`.`t2` `it1` join `test`.`t1` `it2`) where ((`test`.`it2`.`col_int_key` = `test`.`it1`.`pk`) and (`test`.`it1`.`col_varchar_key` = `test`.`ot2`.`col_varchar_nokey`) and (`test`.`ot1`.`col_varchar_key` = `test`.`it2`.`col_varchar_nokey`)) +SELECT ot1.col_int_key AS field1 +FROM t2 AS ot1, t2 AS ot2 +WHERE (ot1.col_varchar_key, ot2.col_varchar_nokey) IN ( +SELECT it2.col_varchar_nokey, it1.col_varchar_key +FROM t2 AS it1 JOIN t1 AS it2 ON it2.col_int_key = it1.pk); +field1 +1 +1 +1 +2 +6 +6 +6 +6 +6 +8 +8 +8 +8 +8 +8 +9 +DROP TABLE t1, t2; +# End of test for bug#13541406. +# +# Bug#13576391: Missing rows on select with in-subquery and +# batched-key-access=on and semijoin +# +CREATE TABLE t1 ( +col_int_nokey int NOT NULL, +col_varchar_key varchar(1) NOT NULL, +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4 engine=InnoDB; +INSERT INTO t1 VALUES +(1,'v'), (7,'s'), (4,'l'), (7,'y'), (0,'c'), (2,'i'), (9,'h'), (4,'q'), +(0,'a'), (9,'v'), (1,'u'), (3,'s'), (8,'y'), (8,'z'), (18,'h'), (84,'p'), +(6,'e'), (3,'i'), (6,'y'), (6,'w'); +CREATE TABLE t2 ( +col_int_nokey int NOT NULL, +col_varchar_nokey varchar(1) NOT NULL +) charset utf8mb4 engine=InnoDB; +INSERT INTO t2 VALUES +(4,'j'), (6,'v'), (3,'c'), (5,'m'), (3,'d'), (246,'d'), (2,'y'), (9,'t'), +(3,'d'), (8,'s'), (1,'r'), (8,'m'), (8,'b'), (5,'x'), (7,'g'), (5,'p'), +(1,'q'), (6,'w'), (2,'d'), (9,'e'); +explain SELECT col_varchar_nokey +FROM t2 AS ot +WHERE col_varchar_nokey IN ( +SELECT col_varchar_key +FROM t1 AS it +WHERE it.col_int_nokey <= it.col_int_nokey +AND NOT ot.col_int_nokey < 2 +) +ORDER BY col_varchar_nokey; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 20 33.33 Parallel execute (1 workers) +2 SIMPLE ot NULL ALL NULL NULL NULL NULL 20 33.33 Using where; Using filesort +2 SIMPLE it NULL ref col_varchar_key col_varchar_key 6 test.ot.col_varchar_nokey 1 100.00 Start temporary; End temporary +Warnings: +Note 1276 Field or reference 'test.ot.col_int_nokey' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`ot`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t2` `ot` semi join (`test`.`t1` `it`) where ((`test`.`it`.`col_varchar_key` = `test`.`ot`.`col_varchar_nokey`) and (`test`.`ot`.`col_int_nokey` >= 2)) order by `test`.`ot`.`col_varchar_nokey` +SELECT col_varchar_nokey +FROM t2 AS ot +WHERE col_varchar_nokey IN ( +SELECT col_varchar_key +FROM t1 AS it +WHERE it.col_int_nokey <= it.col_int_nokey +AND NOT ot.col_int_nokey < 2 +) +ORDER BY col_varchar_nokey; +col_varchar_nokey +c +e +p +s +v +w +y +ALTER TABLE t1 ENGINE=MyISAM; +ALTER TABLE t2 ENGINE=MyISAM; +explain SELECT col_varchar_nokey +FROM t2 AS ot +WHERE col_varchar_nokey IN ( +SELECT col_varchar_key +FROM t1 AS it +WHERE it.col_int_nokey <= it.col_int_nokey +AND NOT ot.col_int_nokey < 2 +) +ORDER BY col_varchar_nokey; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 20 33.33 Using where; Using filesort +1 SIMPLE it NULL ref col_varchar_key col_varchar_key 6 test.ot.col_varchar_nokey 2 100.00 Start temporary; End temporary +Warnings: +Note 1276 Field or reference 'test.ot.col_int_nokey' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`ot`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t2` `ot` semi join (`test`.`t1` `it`) where ((`test`.`it`.`col_varchar_key` = `test`.`ot`.`col_varchar_nokey`) and (`test`.`ot`.`col_int_nokey` >= 2)) order by `test`.`ot`.`col_varchar_nokey` +SELECT col_varchar_nokey +FROM t2 AS ot +WHERE col_varchar_nokey IN ( +SELECT col_varchar_key +FROM t1 AS it +WHERE it.col_int_nokey <= it.col_int_nokey +AND NOT ot.col_int_nokey < 2 +) +ORDER BY col_varchar_nokey; +col_varchar_nokey +c +e +p +s +v +w +y +ALTER TABLE t1 ENGINE=Memory; +ALTER TABLE t2 ENGINE=Memory; +explain SELECT col_varchar_nokey +FROM t2 AS ot +WHERE col_varchar_nokey IN ( +SELECT col_varchar_key +FROM t1 AS it +WHERE it.col_int_nokey <= it.col_int_nokey +AND NOT ot.col_int_nokey < 2 +) +ORDER BY col_varchar_nokey; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 20 33.33 Using where; Using filesort +1 SIMPLE it NULL ref col_varchar_key col_varchar_key 6 test.ot.col_varchar_nokey 2 100.00 Start temporary; End temporary +Warnings: +Note 1276 Field or reference 'test.ot.col_int_nokey' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`ot`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t2` `ot` semi join (`test`.`t1` `it`) where ((`test`.`it`.`col_varchar_key` = `test`.`ot`.`col_varchar_nokey`) and (`test`.`ot`.`col_int_nokey` >= 2)) order by `test`.`ot`.`col_varchar_nokey` +SELECT col_varchar_nokey +FROM t2 AS ot +WHERE col_varchar_nokey IN ( +SELECT col_varchar_key +FROM t1 AS it +WHERE it.col_int_nokey <= it.col_int_nokey +AND NOT ot.col_int_nokey < 2 +) +ORDER BY col_varchar_nokey; +col_varchar_nokey +c +e +p +s +v +w +y +DROP TABLE t1, t2; +# End of test for bug#13576391. +# +# Bug #13589848 "MISSING ROW ON SELECT WITH NESTED IN CLAUSES WHEN LOOSESCAN=ON" +# +CREATE TABLE t1 ( +id INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +KEY (col_varchar_key) +) charset utf8mb4; +INSERT INTO t1 VALUES (100,'m','m'), +(200,'b','b'), (300,'x','x'); +CREATE TABLE t2 ( +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +KEY (col_varchar_key) +) charset utf8mb4; +INSERT INTO t2 VALUES ('b','b'); +CREATE TABLE t3 ( +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +KEY (col_varchar_key) +) charset utf8mb4; +INSERT INTO t3 VALUES ('k','k'); +EXPLAIN SELECT gp1.id +FROM t1 AS gp1 JOIN t3 AS gp2 +ON gp2.col_varchar_key <> gp1.col_varchar_nokey +WHERE (gp1.col_varchar_nokey, gp1.col_varchar_nokey) +IN ( +SELECT col_varchar_nokey, col_varchar_nokey +FROM t1 +WHERE col_varchar_nokey +IN ( SELECT col_varchar_key +FROM t2 LEFT JOIN t3 USING (col_varchar_key) ) +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE gp2 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL index col_varchar_key col_varchar_key 7 NULL 1 100.00 Using where; Using index; Start temporary +1 SIMPLE gp1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ref col_varchar_key col_varchar_key 7 test.t2.col_varchar_key 2 100.00 Using index; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`gp1`.`id` AS `id` from `test`.`t1` `gp1` semi join (`test`.`t1` join `test`.`t2` left join `test`.`t3` on((`test`.`t2`.`col_varchar_key` = `test`.`t3`.`col_varchar_key`))) where ((`test`.`gp1`.`col_varchar_nokey` = `test`.`t2`.`col_varchar_key`) and (`test`.`t1`.`col_varchar_nokey` = `test`.`t2`.`col_varchar_key`) and ('k' <> `test`.`t2`.`col_varchar_key`)) +SELECT gp1.id +FROM t1 AS gp1 JOIN t3 AS gp2 +ON gp2.col_varchar_key <> gp1.col_varchar_nokey +WHERE (gp1.col_varchar_nokey, gp1.col_varchar_nokey) +IN ( +SELECT col_varchar_nokey, col_varchar_nokey +FROM t1 +WHERE col_varchar_nokey +IN ( SELECT col_varchar_key +FROM t2 LEFT JOIN t3 USING (col_varchar_key) ) +) +; +id +200 +DROP TABLE t1,t2,t3; +# +# Bug #13596176: Missing row on select with nested in clause when +# matr=on and bnl=off + MyISAM +# +CREATE TABLE t1 ( +int_key int DEFAULT NULL, +vc_key varchar(1) DEFAULT NULL, +vc_nokey varchar(1) DEFAULT NULL, +KEY int_key (int_key), +KEY vc_key (vc_key, int_key) +) charset utf8mb4 ENGINE=MyISAM; +INSERT INTO t1 VALUES +(8,'x','x'), (7,'d','d'), (1,'r','r'), (7,'f','f'), +(9,'y','y'), (NULL,'u','u'), (1,'m','m'), (9,NULL,NULL), +(2,'o','o'), (9,'w','w'), (2,'m','m'), (4,'q','q'), +(0,NULL,NULL), (4,'d','d'), (8,'g','g'), (NULL,'x','x'), +(NULL,'f','f'), (0,'p','p'), (NULL,'j','j'), (8,'c','c'); +CREATE TABLE t2 ( +int_key int DEFAULT NULL, +vc_key varchar(1) DEFAULT NULL, +KEY int_key (int_key), +KEY vc_key (vc_key, int_key) +) charset utf8mb4 ENGINE=MyISAM; +INSERT INTO t2 VALUES (8,'g'); +explain SELECT vc_key +FROM t1 as outr +WHERE (vc_nokey, vc_key ) IN +(SELECT vc_nokey, vc_nokey +FROM t1 middle +WHERE vc_nokey IN +(SELECT child1.vc_key +FROM t2 AS child1 JOIN t1 AS child2 USING (int_key) +) +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE child1 NULL index int_key,vc_key vc_key 12 NULL 1 100.00 Using where; Using index; Start temporary +1 SIMPLE outr NULL ref vc_key vc_key 7 test.child1.vc_key 3 10.00 Using where +1 SIMPLE middle NULL ALL NULL NULL NULL NULL 20 10.00 Using where; Using join buffer (hash join) +1 SIMPLE child2 NULL ref int_key int_key 5 test.child1.int_key 3 100.00 Using index; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`outr`.`vc_key` AS `vc_key` from `test`.`t1` `outr` semi join (`test`.`t1` `middle` join `test`.`t2` `child1` join `test`.`t1` `child2`) where ((`test`.`child2`.`int_key` = `test`.`child1`.`int_key`) and (`test`.`outr`.`vc_nokey` = `test`.`child1`.`vc_key`) and (`test`.`outr`.`vc_key` = `test`.`child1`.`vc_key`) and (`test`.`middle`.`vc_nokey` = `test`.`child1`.`vc_key`)) +SELECT vc_key +FROM t1 as outr +WHERE (vc_nokey, vc_key ) IN +(SELECT vc_nokey, vc_nokey +FROM t1 middle +WHERE vc_nokey IN +(SELECT child1.vc_key +FROM t2 AS child1 JOIN t1 AS child2 USING (int_key) +) +); +vc_key +g +DROP TABLE t1, t2; +# End of test for bug#13596176. +# +# BUG#11754478: MAX/MIN + SUBQUERY + AND FAILS TO RETURN ANY ROWS +# BUG#13599013: MAX/MIN + SUBQUERY IN WHERE CLAUSE MATCHING NO +# ROWS + INDEX DOES NOT RETURN NULL +# +CREATE TABLE t1 ( +pk int(11) PRIMARY KEY, +int_key int(11), +KEY int_key (int_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (1,0),(2,0),(3,2),(4,0),(5,3),(6,0); +SELECT MIN(int_key) FROM t1 WHERE (4, 4) IN (SELECT 1, 2); +MIN(int_key) +NULL +SELECT MIN(int_key) FROM t1 WHERE (4, 4) IN (SELECT 4, 4); +MIN(int_key) +0 +SELECT MIN(pk) FROM t1 WHERE pk IN (SELECT int_key FROM t1) AND pk = 6; +MIN(pk) +NULL +DROP TABLE t1; +# BUG#13726217: Crash in Item_ident::fix_after_pullout() +CREATE TABLE t1(a INTEGER) engine=innodb; +INSERT INTO t1 VALUES (0); +SELECT 0 +FROM t1 +WHERE 0 IN +(SELECT 0 +FROM t1 +WHERE 0 LIKE +(SELECT elt(a, 0) AS b +FROM t1 +GROUP BY a +HAVING b +) +); +0 +DROP TABLE t1; +# End of test for bug#13726217. +# BUG#13773979: Missing rows on second execution of prepared statement +CREATE TABLE t1 ( +col_int_nokey INT, +col_int_key INT, +col_varchar_key VARCHAR(1) +); +INSERT INTO t1 VALUES +(1,7,'v'), (7,0,'s'), (4,9,'l'), (7,3,'y'), +(2,2,'i'), (9,5,'h'), (0,1,'a'), (9,3,'v'); +CREATE VIEW v1 AS SELECT * FROM t1; +SELECT * +FROM t1 +WHERE col_int_key IN ( +SELECT alias1.col_int_nokey AS field1 +FROM v1 AS alias1 +WHERE alias1.col_varchar_key < 'v' +); +col_int_nokey col_int_key col_varchar_key +1 7 v +2 2 i +4 9 l +7 0 s +prepare stmt FROM "SELECT * +FROM t1 +WHERE col_int_key IN ( +SELECT alias1.col_int_nokey AS field1 +FROM v1 AS alias1 +WHERE alias1.col_varchar_key < 'v' +)"; +execute stmt; +col_int_nokey col_int_key col_varchar_key +1 7 v +2 2 i +4 9 l +7 0 s +execute stmt; +col_int_nokey col_int_key col_varchar_key +1 7 v +2 2 i +4 9 l +7 0 s +DEALLOCATE PREPARE stmt; +DROP VIEW v1; +DROP TABLE t1; +# End of test for bug#13773979. +# +# BUG#13685026 ASSERTION CUR_SJ_INNER_TABLES == 0 IN +# --OPTIMIZE_TABLE_ORDER::CHOOSE_TABLE_ORDER +# +CREATE TABLE t1 ( +col_int_key INT(11) NOT NULL, +col_datetime_key DATETIME NOT NULL, +col_varchar_key VARCHAR(1) NOT NULL, +col_varchar_nokey VARCHAR(1) NOT NULL, +KEY col_int_key (col_int_key), +KEY col_datetime_key (col_datetime_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (0,'2002-02-13 17:30:06','j','j'); +INSERT INTO t1 VALUES (8,'2008-09-27 00:34:58','v','v'); +CREATE TABLE t2 ( +col_int_key INT(11) NOT NULL, +col_datetime_key DATETIME NOT NULL, +col_varchar_key VARCHAR(1) NOT NULL, +col_varchar_nokey VARCHAR(1) NOT NULL, +KEY col_int_key (col_int_key), +KEY col_datetime_key (col_datetime_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (7,'2003-08-21 00:00:00','b','b'); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +SET @old_depth=@@optimizer_search_depth; +SET optimizer_search_depth=4; +EXPLAIN SELECT col_datetime_key +FROM t1 as outr +WHERE col_datetime_key IN ( +SELECT alias1.col_datetime_key +FROM t1 AS alias1 +LEFT JOIN t1 as alias3 +STRAIGHT_JOIN ( t2 AS alias4 +JOIN t1 AS alias5 +ON alias5.col_varchar_key <= alias4.col_varchar_nokey ) +ON alias5.col_int_key < alias4.col_int_key +ON alias5.col_varchar_key = alias4.col_varchar_key +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE outr NULL index col_datetime_key col_datetime_key 5 NULL 2 100.00 Using index +1 SIMPLE alias1 NULL ref col_datetime_key col_datetime_key 5 test.outr.col_datetime_key 1 100.00 Using index; Start temporary +1 SIMPLE alias4 NULL ALL col_int_key,col_varchar_key NULL NULL NULL 1 100.00 NULL +1 SIMPLE alias5 NULL ref col_int_key,col_varchar_key col_varchar_key 6 test.alias4.col_varchar_key 1 100.00 Using where; Using index +1 SIMPLE alias3 NULL index NULL col_int_key 4 NULL 2 100.00 Using index; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`outr`.`col_datetime_key` AS `col_datetime_key` from `test`.`t1` `outr` semi join (`test`.`t1` `alias1` left join (`test`.`t1` `alias3` join `test`.`t2` `alias4` join `test`.`t1` `alias5`) on(((`test`.`alias5`.`col_varchar_key` = `test`.`alias4`.`col_varchar_key`) and (`test`.`alias5`.`col_int_key` < `test`.`alias4`.`col_int_key`) and (`test`.`alias5`.`col_varchar_key` <= `test`.`alias4`.`col_varchar_nokey`)))) where (`test`.`alias1`.`col_datetime_key` = `test`.`outr`.`col_datetime_key`) +SELECT col_datetime_key +FROM t1 as outr +WHERE col_datetime_key IN ( +SELECT alias1.col_datetime_key +FROM t1 AS alias1 +LEFT JOIN t1 as alias3 +STRAIGHT_JOIN ( t2 AS alias4 +JOIN t1 AS alias5 +ON alias5.col_varchar_key <= alias4.col_varchar_nokey ) +ON alias5.col_int_key < alias4.col_int_key +ON alias5.col_varchar_key = alias4.col_varchar_key +); +col_datetime_key +2002-02-13 17:30:06 +2008-09-27 00:34:58 +DROP TABLE t1,t2; +SET @@optimizer_search_depth=@old_depth; +# +# BUG#13848789: SEGFAULT IN JOIN_READ_NEXT_SAME AT +# SQL/SQL_EXECUTOR.CC ON HAVING...IN...JOIN +# +CREATE TABLE t1 ( +col_int_key INT, +col_varchar_key VARCHAR(1), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4; +INSERT INTO t1 VALUES (8,'x'); +CREATE TABLE t2 ( +col_varchar_key VARCHAR(1), +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4; +INSERT INTO t2 VALUES ('x'), ('y'); +explain SELECT MIN(col_int_key) +FROM t1 as t1_outer +HAVING (1, 2) IN ( +SELECT t1_inner.col_int_key, MAX(t1_inner.col_int_key) +FROM t1 as t1_inner JOIN t2 +ON t2.col_varchar_key = t1_inner.col_varchar_key +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible HAVING +2 SUBQUERY t1_inner NULL system col_varchar_key NULL NULL NULL 1 100.00 NULL +2 SUBQUERY t2 NULL ref col_varchar_key col_varchar_key 7 const 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select min(`test`.`t1_outer`.`col_int_key`) AS `MIN(col_int_key)` from `test`.`t1` `t1_outer` having false +SELECT MIN(col_int_key) +FROM t1 as t1_outer +HAVING (1, 2) IN ( +SELECT t1_inner.col_int_key, MAX(t1_inner.col_int_key) +FROM t1 as t1_inner JOIN t2 +ON t2.col_varchar_key = t1_inner.col_varchar_key +); +MIN(col_int_key) +DROP TABLE t1,t2; +# Bug#13838810: Segfault in evaluate_null_complemented_join_record +CREATE TABLE t1 ( +pk int NOT NULL, +col_int_nokey int DEFAULT NULL, +col_int_key int DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t1 VALUES (10,NULL,8,'x'); +CREATE TABLE t2 ( +pk int NOT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +PRIMARY KEY (pk) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t2 VALUES (1,'x'); +CREATE TABLE t3 ( +pk int NOT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +PRIMARY KEY (pk), +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t3 VALUES +(1,'v','v'), (2,'v','v'), (3,'c','c'), (4,NULL,NULL); +EXPLAIN SELECT table1.pk,table2.pk, table3.pk +FROM t2 AS table1 +LEFT JOIN t1 AS table2 +LEFT JOIN t1 AS table3 +ON table3.col_int_key = table2.col_int_key +ON table3.pk = table2.col_int_nokey AND +table1.col_varchar_nokey IN ( +SELECT subquery3_t1.col_varchar_nokey +FROM t3 AS subquery3_t1 +LEFT JOIN t1 AS subquery3_t2 +ON subquery3_t2.col_varchar_key = subquery3_t1.col_varchar_key +WHERE subquery3_t2.col_int_nokey <> 9 +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE table1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE table2 NULL ALL col_int_key NULL NULL NULL 1 100.00 NULL +2 SIMPLE table3 NULL eq_ref PRIMARY,col_int_key PRIMARY 4 test.table2.col_int_nokey 1 100.00 Using where +2 SIMPLE subquery3_t2 NULL ALL col_varchar_key NULL NULL NULL 1 100.00 Using where; Start temporary +2 SIMPLE subquery3_t1 NULL ref col_varchar_key col_varchar_key 7 test.subquery3_t2.col_varchar_key 1 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`table1`.`pk` AS `pk`,`test`.`table2`.`pk` AS `pk`,`test`.`table3`.`pk` AS `pk` from `test`.`t2` `table1` left join (`test`.`t1` `table2` join `test`.`t1` `table3` semi join (`test`.`t3` `subquery3_t1` join `test`.`t1` `subquery3_t2`)) on(((`test`.`table3`.`col_int_key` = `test`.`table2`.`col_int_key`) and (`test`.`subquery3_t1`.`col_varchar_key` = `test`.`subquery3_t2`.`col_varchar_key`) and (`test`.`subquery3_t1`.`col_varchar_nokey` = `test`.`table1`.`col_varchar_nokey`) and (`test`.`table3`.`pk` = `test`.`table2`.`col_int_nokey`) and (`test`.`subquery3_t2`.`col_int_nokey` <> 9))) where true +SELECT table1.pk,table2.pk, table3.pk +FROM t2 AS table1 +LEFT JOIN t1 AS table2 +LEFT JOIN t1 AS table3 +ON table3.col_int_key = table2.col_int_key +ON table3.pk = table2.col_int_nokey AND +table1.col_varchar_nokey IN ( +SELECT subquery3_t1.col_varchar_nokey +FROM t3 AS subquery3_t1 +LEFT JOIN t1 AS subquery3_t2 +ON subquery3_t2.col_varchar_key = subquery3_t1.col_varchar_key +WHERE subquery3_t2.col_int_nokey <> 9 +) +; +pk pk pk +1 NULL NULL +DROP TABLE t1, t2, t3; +Extra test case for specific code coverage +CREATE TABLE t1(pk INTEGER); +INSERT INTO t1 VALUES(1), (2); +explain SELECT * +FROM t1 AS ot1 LEFT JOIN t1 AS ot2 +ON ot1.pk=ot2.pk AND +ot2.pk IN +(SELECT it1.pk +FROM t1 AS it1 LEFT JOIN t1 AS it2 ON it1.pk=it2.pk); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +1 SIMPLE it1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +1 SIMPLE it2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`pk` AS `pk`,`test`.`ot2`.`pk` AS `pk` from `test`.`t1` `ot1` left join (`test`.`t1` `ot2` semi join (`test`.`t1` `it1` left join `test`.`t1` `it2` on((`test`.`it1`.`pk` = `test`.`it2`.`pk`)))) on(((`test`.`ot2`.`pk` = `test`.`ot1`.`pk`) and (`test`.`it1`.`pk` = `test`.`ot1`.`pk`))) where true +SELECT * +FROM t1 AS ot1 LEFT JOIN t1 AS ot2 +ON ot1.pk=ot2.pk AND +ot2.pk IN +(SELECT it1.pk +FROM t1 AS it1 LEFT JOIN t1 AS it2 ON it1.pk=it2.pk); +pk pk +1 1 +2 2 +DROP TABLE t1; +# End of test for bug#13838810. +# +# Bug#13845930: Segfault in st_join_table::and_with_condition +# +CREATE TABLE t1 ( +col_int INTEGER +); +CREATE TABLE t2 ( +col_varchar_1 VARCHAR(1), +col_varchar_2 VARCHAR(1) +); +INSERT INTO t2 VALUES ('x','x'), ('c','c'); +PREPARE stmt FROM ' +SELECT alias2.col_varchar_2 AS field1 +FROM t2 AS alias1 + JOIN + (t2 AS alias2 + LEFT JOIN t2 AS alias3 + ON (8, 92) IN + (SELECT sq1_alias1.col_int, + sq1_alias2.col_int + FROM t1 AS sq1_alias1 JOIN t1 AS sq1_alias2 + ) + ) + ON alias3.col_varchar_1 = alias2.col_varchar_2 +'; +EXECUTE stmt; +field1 + +EXECUTE stmt; +field1 +DEALLOCATE prepare stmt; +DROP TABLE t1, t2; +# End of test for bug#13845930. +# +# Bug#13855925: Assert 'prebuilt->search_tuple->n_fields > 0' +# in ha_innobase::index_read +# +CREATE TABLE t1 ( +pk INTEGER AUTO_INCREMENT, +col_int_nokey INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk), +KEY (col_varchar_key) +) charset utf8mb4 ENGINE=INNODB; +INSERT INTO t1 ( +col_int_key, col_int_nokey, +col_varchar_key, col_varchar_nokey +) VALUES +(4, 2, 'v','v'), (62, 150, 'v','v'), (7, NULL, 'c','c'), (1, 2, NULL, NULL), +(0, 5, 'x','x'), (7, 3, 'i','i'), (7, 1, 'e','e'), (1, 4, 'p','p'), +(7, NULL, 's','s'), (1, 2, 'j','j'), (5, 6, 'z','z'), (2, 6, 'c','c'), +(0, 8, 'a','a'), (1, 2, 'q','q'), (8, 6, 'y','y'), (1, 8, NULL, NULL), +(1, 3, 'r','r'), (9, 3, 'v','v'), (1, 9, NULL, NULL), (5, 6, 'r','r'); +CREATE TABLE t2 ( +pk INT AUTO_INCREMENT, +col_int_nokey INT, +col_int_key INT, +PRIMARY KEY (pk), +KEY (col_int_key) +) charset utf8mb4 AUTO_INCREMENT=10 ENGINE=INNODB; +INSERT INTO t2 (col_int_key, col_int_nokey) VALUES +(8, NULL), (7, 8), (1, 1), (7, 9), (9, 4), (NULL, 3), (1, 2), (9, NULL), +(2, 2), (9, NULL), (2, 6), (4, 7), (0, 2), (4, 5), (8, 7), (NULL, 6), +(NULL, 6), (0, 2), (NULL, 9), (8, 6); +CREATE TABLE t3 ( +pk INT AUTO_INCREMENT, +col_varchar_key VARCHAR(1), +PRIMARY KEY (pk), +KEY (col_varchar_key) +) charset utf8mb4 ENGINE=INNODB; +INSERT INTO t3 (col_varchar_key) VALUES +('c'), ('c'), ('q'), ('g'), ('e'), ('l'), (NULL), ('c'), ('h'), ('d'), +('c'), ('i'), ('t'), ('g'), ('q'), ('l'), ('n'), ('z'), ('n'), ('r'), ('p'); +CREATE VIEW v1 AS +SELECT table2.col_varchar_nokey AS field1 +FROM t2 AS table1 +INNER JOIN (t1 AS table2 +STRAIGHT_JOIN t2 AS table3 +ON table3.col_int_key = table2.pk AND +table3.col_int_nokey = ANY +(SELECT subquery1_t2.col_int_nokey AS subquery1_field1 +FROM t2 AS subquery1_t1 +RIGHT OUTER JOIN t1 AS subquery1_t2 +INNER JOIN t1 AS subquery1_t3 +ON subquery1_t3.col_int_key = subquery1_t2.pk +ON subquery1_t3.col_varchar_key=subquery1_t2.col_varchar_nokey +WHERE subquery1_t1.pk > 1 +) +) +ON table3.col_int_key IN +(SELECT subquery2_t1.col_int_key AS subquery2_field1 +FROM t2 AS subquery2_t1 +RIGHT OUTER JOIN t3 AS subquery2_t2 +LEFT OUTER JOIN t1 AS subquery2_t3 +ON subquery2_t3.col_varchar_key = subquery2_t2.col_varchar_key +ON subquery2_t3.pk = subquery2_t2.pk +) +; +explain SELECT * FROM v1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE table1 NULL index NULL col_int_key 5 NULL 20 100.00 Using index; Start temporary +1 SIMPLE subquery1_t3 NULL ALL col_varchar_key NULL NULL NULL 20 100.00 Using where; Using join buffer (hash join) +1 SIMPLE subquery1_t2 NULL eq_ref PRIMARY PRIMARY 4 test.subquery1_t3.col_int_key 1 10.00 Using where +1 SIMPLE table2 NULL ALL PRIMARY NULL NULL NULL 20 100.00 Using join buffer (hash join) +1 SIMPLE table3 NULL ref col_int_key col_int_key 5 test.table2.pk 2 10.00 Using where +1 SIMPLE subquery2_t3 NULL index PRIMARY,col_varchar_key col_varchar_key 7 NULL 20 100.00 Using where; Using index; Using join buffer (hash join) +1 SIMPLE subquery2_t2 NULL eq_ref PRIMARY,col_varchar_key PRIMARY 4 test.subquery2_t3.pk 1 7.14 Using where +1 SIMPLE subquery2_t1 NULL ref col_int_key col_int_key 5 test.table2.pk 2 100.00 Using index +1 SIMPLE subquery1_t1 NULL index PRIMARY col_int_key 5 NULL 20 100.00 Using where; Using index; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `table2`.`col_varchar_nokey` AS `field1` from `test`.`t2` `table1` join `test`.`t1` `table2` straight_join `test`.`t2` `table3` semi join (`test`.`t1` `subquery1_t2` join `test`.`t1` `subquery1_t3` join `test`.`t2` `subquery1_t1`) semi join (`test`.`t3` `subquery2_t2` join `test`.`t1` `subquery2_t3` join `test`.`t2` `subquery2_t1`) where ((`subquery1_t2`.`pk` = `subquery1_t3`.`col_int_key`) and (`subquery1_t2`.`col_varchar_nokey` = `subquery1_t3`.`col_varchar_key`) and (`subquery2_t2`.`col_varchar_key` = `subquery2_t3`.`col_varchar_key`) and (`subquery2_t2`.`pk` = `subquery2_t3`.`pk`) and (`table3`.`col_int_key` = `table2`.`pk`) and (`subquery2_t1`.`col_int_key` = `table2`.`pk`) and (`table3`.`col_int_nokey` = `subquery1_t2`.`col_int_nokey`) and (`subquery1_t1`.`pk` > 1)) +SELECT * FROM v1; +field1 +v +v +v +v +v +v +v +v +v +v +v +v +v +v +v +v +v +v +v +v +DROP VIEW v1; +DROP TABLE t1,t2,t3; +# End of test for bug#13855925. +# +# Bug#13897959: Segfault in setup_semijoin_dups_elimination() +# +CREATE TABLE t1 ( +col_datetime_key DATETIME DEFAULT NULL, +KEY col_datetime_key (col_datetime_key) +) ENGINE=MyISAM; +INSERT INTO t1 VALUES +('2001-04-18 00:00:00'), ('2008-12-18 19:39:55'), +('2000-08-01 12:19:39'), ('2004-09-25 21:29:06'), +('2009-09-20 09:11:48'), ('2004-03-27 09:32:04'); +CREATE TABLE t2 ( +col_date_nokey date DEFAULT NULL, +col_time_key time DEFAULT NULL, +col_datetime_key datetime DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +KEY col_time_key (col_time_key), +KEY col_datetime_key (col_datetime_key), +KEY col_varchar_key(col_varchar_key) +) ENGINE=MyISAM; +INSERT INTO t2 VALUES ('1900-01-01',NULL,'2001-11-04 19:07:55','x','x'); +SELECT grandparent1.col_varchar_nokey +FROM t2 AS grandparent1 LEFT JOIN t1 USING (col_datetime_key) +WHERE grandparent1.col_varchar_nokey IN ( +SELECT col_varchar_nokey +FROM t2 AS parent1 +WHERE parent1.col_time_key > grandparent1.col_date_nokey +); +col_varchar_nokey +DROP TABLE t1, t2; +# End of test for bug#13897959. +# +# Bug#13898625 ASSERT `(REMAINING_TABLES_AFTER != 0) ...' IN +# BEST_EXTENSION_BY_LIMITED_SEARCH +# +CREATE TABLE t1 ( +pk int(11) NOT NULL, +col_int_nokey INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (26,6,NULL,'f','f'); +INSERT INTO t1 VALUES (29,6,8,'c','c'); +CREATE TABLE t2 ( +pk INT NOT NULL, +col_int_nokey INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +INSERT INTO t2 VALUES (1,2,4,'v','v'); +INSERT INTO t2 VALUES (2,150,62,'v','v'); +INSERT INTO t2 VALUES (5,5,0,'x','x'); +INSERT INTO t2 VALUES (6,3,7,'i','i'); +INSERT INTO t2 VALUES (7,1,7,'e','e'); +CREATE VIEW view_c AS SELECT * FROM t2; +PREPARE prep_stmt_7430 FROM 'SELECT SUM( alias1.col_varchar_key ) AS field1 +FROM t1 AS alias1 +RIGHT JOIN t2 AS alias2 +INNER JOIN t1 AS alias3 +ON (alias3.col_varchar_key = alias2.col_varchar_key ) +ON ( "v" ) IN ( +SELECT sq1_alias1.col_varchar_nokey AS sq1_field1 +FROM t1 AS sq1_alias1 +) +WHERE alias3.pk IN ( +SELECT sq2_alias1.col_int_key AS sq2_field1 +FROM ( view_c AS sq2_alias1, t1 AS sq2_alias2 ) +) +'; +EXECUTE prep_stmt_7430; +field1 +NULL +EXECUTE prep_stmt_7430; +field1 +NULL +EXPLAIN SELECT SUM( alias1.col_varchar_key ) AS field1 +FROM t1 AS alias1 +RIGHT JOIN t2 AS alias2 +INNER JOIN t1 AS alias3 +ON (alias3.col_varchar_key = alias2.col_varchar_key ) +ON ( "v" ) IN ( +SELECT sq1_alias1.col_varchar_nokey AS sq1_field1 +FROM t1 AS sq1_alias1 +) +WHERE alias3.pk IN ( +SELECT sq2_alias1.col_int_key AS sq2_field1 +FROM ( view_c AS sq2_alias1, t1 AS sq2_alias2 ) +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE alias3 NULL ALL PRIMARY,col_varchar_key NULL NULL NULL 2 100.00 Using where; Start temporary +1 SIMPLE sq2_alias2 NULL index NULL PRIMARY 4 NULL 2 100.00 Using index; Using join buffer (hash join) +1 SIMPLE alias2 NULL ref col_varchar_key col_varchar_key 7 test.alias3.col_varchar_key 2 100.00 Using index +1 SIMPLE t2 NULL ref col_int_key col_int_key 5 test.alias3.pk 2 100.00 Using index +1 SIMPLE sq1_alias1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +1 SIMPLE alias1 NULL index NULL col_varchar_key 12 NULL 2 100.00 Using index; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select sum(`test`.`alias1`.`col_varchar_key`) AS `field1` from `test`.`t2` `alias2` join `test`.`t1` `alias3` left join (`test`.`t1` `alias1` semi join (`test`.`t1` `sq1_alias1`)) on(((`test`.`sq1_alias1`.`col_varchar_nokey` = 'v'))) semi join (`test`.`t2` join `test`.`t1` `sq2_alias2`) where ((`test`.`alias2`.`col_varchar_key` = `test`.`alias3`.`col_varchar_key`) and (`test`.`t2`.`col_int_key` = `test`.`alias3`.`pk`)) +PREPARE prep_stmt_7430 FROM 'SELECT SUM( alias1.col_varchar_key ) AS field1 +FROM t1 AS alias1 +RIGHT JOIN t2 AS alias2 +INNER JOIN t1 AS alias3 +ON (alias3.col_varchar_key = alias2.col_varchar_key ) +ON ( "v" ) IN ( +SELECT sq1_alias1.col_varchar_nokey AS sq1_field1 +FROM t1 AS sq1_alias1 +) +WHERE alias3.pk IN ( +SELECT sq2_alias1.col_int_key AS sq2_field1 +FROM ( view_c AS sq2_alias1 , t1 AS sq2_alias2 ) +WHERE sq2_alias1.col_varchar_nokey <> alias2.col_varchar_key +AND sq2_alias1.col_varchar_key < "l" + ) +'; +EXECUTE prep_stmt_7430; +field1 +NULL +EXECUTE prep_stmt_7430; +field1 +NULL +EXPLAIN SELECT SUM( alias1.col_varchar_key ) AS field1 +FROM t1 AS alias1 +RIGHT JOIN t2 AS alias2 +INNER JOIN t1 AS alias3 +ON (alias3.col_varchar_key = alias2.col_varchar_key ) +ON ( "v" ) IN ( +SELECT sq1_alias1.col_varchar_nokey AS sq1_field1 +FROM t1 AS sq1_alias1 +) +WHERE alias3.pk IN ( +SELECT sq2_alias1.col_int_key AS sq2_field1 +FROM ( view_c AS sq2_alias1 , t1 AS sq2_alias2 ) +WHERE sq2_alias1.col_varchar_nokey <> alias2.col_varchar_key +AND sq2_alias1.col_varchar_key < "l" + ) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE alias3 NULL ALL PRIMARY,col_varchar_key NULL NULL NULL 2 100.00 Using where; Start temporary +1 SIMPLE t2 NULL ref col_int_key,col_varchar_key col_int_key 5 test.alias3.pk 2 40.00 Using where +1 SIMPLE alias2 NULL ref col_varchar_key col_varchar_key 7 test.alias3.col_varchar_key 2 100.00 Using index +1 SIMPLE sq2_alias2 NULL index NULL PRIMARY 4 NULL 2 100.00 Using index; Using join buffer (hash join) +1 SIMPLE sq1_alias1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +1 SIMPLE alias1 NULL index NULL col_varchar_key 12 NULL 2 100.00 Using index; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.alias2.col_varchar_key' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select sum(`test`.`alias1`.`col_varchar_key`) AS `field1` from `test`.`t2` `alias2` join `test`.`t1` `alias3` left join (`test`.`t1` `alias1` semi join (`test`.`t1` `sq1_alias1`)) on(((`test`.`sq1_alias1`.`col_varchar_nokey` = 'v'))) semi join (`test`.`t2` join `test`.`t1` `sq2_alias2`) where ((`test`.`alias2`.`col_varchar_key` = `test`.`alias3`.`col_varchar_key`) and (`test`.`t2`.`col_int_key` = `test`.`alias3`.`pk`) and (`test`.`t2`.`col_varchar_nokey` <> `test`.`alias3`.`col_varchar_key`) and (`test`.`t2`.`col_varchar_key` < 'l')) +DROP TABLE t1,t2; +DROP VIEW view_c; +# +# Bug#13902463 SEGFAULT IN BITMAP<64U>::MERGE OR ADD_KEY_FIELD +# ON SECOND EXEC OF PREP STMT +# +CREATE TABLE t1 ( +pk INT, +col_int_nokey INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +KEY col_varchar_key (col_varchar_key) +); +CREATE VIEW view_b AS SELECT * FROM t1; +PREPARE prep_stmt_20421 FROM 'SELECT alias2.col_varchar_nokey AS field1 +FROM t1 AS alias1 +INNER JOIN t1 AS alias2 +ON (alias1.col_varchar_key = alias2.col_varchar_nokey +AND ( alias1.col_int_key ) IN ( +SELECT t1.col_int_nokey +FROM t1 +) +) +WHERE alias1.col_varchar_key IN ( +SELECT sq2_alias2.col_varchar_nokey AS sq2_field1 +FROM view_b AS sq2_alias1 +INNER JOIN t1 AS sq2_alias2 +ON (sq2_alias2.col_varchar_key = sq2_alias1.col_varchar_key ) +WHERE sq2_alias1.pk > alias2.pk +) +'; +EXECUTE prep_stmt_20421; +field1 +EXECUTE prep_stmt_20421; +field1 +EXPLAIN SELECT alias2.col_varchar_nokey AS field1 +FROM t1 AS alias1 +INNER JOIN t1 AS alias2 +ON (alias1.col_varchar_key = alias2.col_varchar_nokey +AND ( alias1.col_int_key ) IN ( +SELECT t1.col_int_nokey +FROM t1 +) +) +WHERE alias1.col_varchar_key IN ( +SELECT sq2_alias2.col_varchar_nokey AS sq2_field1 +FROM view_b AS sq2_alias1 +INNER JOIN t1 AS sq2_alias2 +ON (sq2_alias2.col_varchar_key = sq2_alias1.col_varchar_key ) +WHERE sq2_alias1.pk > alias2.pk +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.alias2.pk' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `field1` from `test`.`t1` `alias1` join `test`.`t1` `alias2` semi join (`test`.`t1`) semi join (`test`.`t1` join `test`.`t1` `sq2_alias2`) where ((`test`.`t1`.`pk` > NULL) and multiple equal(NULL, `test`.`sq2_alias2`.`col_varchar_nokey`, NULL) and multiple equal(`test`.`sq2_alias2`.`col_varchar_key`, `test`.`t1`.`col_varchar_key`) and multiple equal(NULL, `test`.`t1`.`col_int_nokey`)) +ALTER TABLE t1 DROP INDEX col_varchar_key; +PREPARE prep_stmt_20421 FROM 'SELECT alias2.col_varchar_nokey AS field1 +FROM t1 AS alias1 +INNER JOIN t1 AS alias2 +ON (alias1.col_varchar_key = alias2.col_varchar_nokey +AND ( alias1.col_int_key ) IN ( +SELECT t1.col_int_nokey +FROM t1 +) +) +WHERE alias1.col_varchar_key IN ( +SELECT sq2_alias2.col_varchar_nokey AS sq2_field1 +FROM view_b AS sq2_alias1 +INNER JOIN t1 AS sq2_alias2 +ON (sq2_alias2.col_varchar_key = sq2_alias1.col_varchar_key ) +WHERE sq2_alias1.pk > alias2.pk +) +'; +EXECUTE prep_stmt_20421; +field1 +EXECUTE prep_stmt_20421; +field1 +EXPLAIN SELECT alias2.col_varchar_nokey AS field1 +FROM t1 AS alias1 +INNER JOIN t1 AS alias2 +ON (alias1.col_varchar_key = alias2.col_varchar_nokey +AND ( alias1.col_int_key ) IN ( +SELECT t1.col_int_nokey +FROM t1 +) +) +WHERE alias1.col_varchar_key IN ( +SELECT sq2_alias2.col_varchar_nokey AS sq2_field1 +FROM view_b AS sq2_alias1 +INNER JOIN t1 AS sq2_alias2 +ON (sq2_alias2.col_varchar_key = sq2_alias1.col_varchar_key ) +WHERE sq2_alias1.pk > alias2.pk +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.alias2.pk' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `field1` from `test`.`t1` `alias1` join `test`.`t1` `alias2` semi join (`test`.`t1`) semi join (`test`.`t1` join `test`.`t1` `sq2_alias2`) where ((`test`.`t1`.`pk` > NULL) and multiple equal(NULL, `test`.`sq2_alias2`.`col_varchar_nokey`, NULL) and multiple equal(`test`.`sq2_alias2`.`col_varchar_key`, `test`.`t1`.`col_varchar_key`) and multiple equal(NULL, `test`.`t1`.`col_int_nokey`)) +DROP TABLE t1; +DROP VIEW view_b; +# +# Bug#13907277: Segfault in evaluate_null_complemented_join_record +# +CREATE TABLE t1 ( +pk INTEGER, +col_varchar_nokey VARCHAR(1), +col_varchar_key VARCHAR(1), +PRIMARY KEY (pk) +); +INSERT INTO t1 VALUES (1, 'x', 'x'); +CREATE TABLE t2 ( +pk INTEGER, +PRIMARY KEY (pk) +); +INSERT INTO t2 VALUES (1); +CREATE TABLE t3 ( +pk INTEGER, +col_int_nokey INTEGER, +col_int_key INTEGER, +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk) +); +INSERT INTO t3 VALUES (1, 6, 5, 'r'); +explain SELECT outer_t1.pk, outer_t2.pk +FROM t3 AS outer_t1 +RIGHT JOIN t2 AS outer_t2 +ON outer_t1.col_int_nokey IN +(SELECT inner_t1.col_int_nokey +FROM t3 AS inner_t1 +LEFT JOIN t1 AS inner_t2 +INNER JOIN t1 AS inner_t3 +ON inner_t3.pk = inner_t2.pk +ON inner_t3.col_varchar_nokey = inner_t2.col_varchar_key +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE outer_t2 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE outer_t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE inner_t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE inner_t2 NULL ALL PRIMARY NULL NULL NULL 1 100.00 NULL +1 SIMPLE inner_t3 NULL eq_ref PRIMARY PRIMARY 4 test.inner_t2.pk 1 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`outer_t1`.`pk` AS `pk`,'1' AS `pk` from left join (`test`.`t3` `outer_t1` semi join (`test`.`t3` `inner_t1` left join (`test`.`t1` `inner_t2` join `test`.`t1` `inner_t3`) on(((`test`.`inner_t3`.`col_varchar_nokey` = `test`.`inner_t2`.`col_varchar_key`) and (`test`.`inner_t3`.`pk` = `test`.`inner_t2`.`pk`))))) on(((`test`.`inner_t1`.`col_int_nokey` = `test`.`outer_t1`.`col_int_nokey`))) where true +SELECT outer_t1.pk, outer_t2.pk +FROM t3 AS outer_t1 +RIGHT JOIN t2 AS outer_t2 +ON outer_t1.col_int_nokey IN +(SELECT inner_t1.col_int_nokey +FROM t3 AS inner_t1 +LEFT JOIN t1 AS inner_t2 +INNER JOIN t1 AS inner_t3 +ON inner_t3.pk = inner_t2.pk +ON inner_t3.col_varchar_nokey = inner_t2.col_varchar_key +); +pk pk +1 1 +DROP TABLE t1, t2, t3; +# End of test for bug#13907277. +# +# Bug#13955713: Assert 'JOIN->best_read < ...' on second execution +# +CREATE TABLE t1 ( +pk INTEGER, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1) +); +PREPARE stmt FROM " +SELECT MIN(alias2.col_varchar_key) AS field1 +FROM t1 AS alias1 + INNER JOIN (t1 AS alias2 + INNER JOIN t1 AS alias3 + ON 8 IN + (SELECT sq1_alias1.pk AS sq1_field2 + FROM t1 AS sq1_alias1 + WHERE 9 IN + (SELECT SUM(t1_sq1_alias1.pk) AS t1_sq1_field2 + FROM t1 AS t1_sq1_alias1 + ) + ) + ) + ON alias3.col_varchar_nokey = alias2.col_varchar_key +WHERE EXISTS + (SELECT sq2_alias1.pk AS sq2_field1 + FROM t1 AS sq2_alias1 + WHERE sq2_alias1.col_varchar_key < alias1.col_varchar_nokey + ) +"; +EXECUTE stmt; +field1 +NULL + +EXECUTE stmt; +field1 +NULL +DEALLOCATE PREPARE stmt; +DROP TABLE t1; +# End of test for bug#13955713. +# +# Bug#13956813: Segfault in memcpy from Join_cache::write_record_data() +# +CREATE TABLE t1 ( +pk INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1) +) charset latin1; +CREATE TABLE t2 ( +pk INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1) +) charset latin1; +INSERT INTO t2 VALUES +(10,'j','j'), (11,'z','z'), (12,'c','c'), (13,'a','a'), +(14,'q','q'), (15,'y','y'), (16,NULL,NULL), (17,'r','r'), +(18,'v','v'), (19,NULL,NULL), (20,'r','r'); +CREATE TABLE t3 ( +pk INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +KEY col_int_key (col_int_key) +) charset latin1; +INSERT INTO t3 VALUES +(15,NULL,'u'), (16,1,'m'), (17,9,NULL), (18,2,'o'), +(19,9,'w'), (20,2,'m'), (21,4,'q'), (22,0,NULL), +(23,4,'d'), (24,8,'g'), (25,NULL,'x'), (26,NULL,'f'), +(27,0,'p'), (28,NULL,'j'), (29,8,'c'); +CREATE VIEW view_inline_0 AS +SELECT t1.* +FROM t1 INNER JOIN t3 +ON t1.pk = t3.pk; +CREATE VIEW view_inline_1 AS +SELECT sq2_alias2.col_varchar_key AS sq2_field1, +sq2_alias1.col_varchar_key AS sq2_field2 +FROM t3 AS sq2_alias1 LEFT OUTER JOIN t3 AS sq2_alias2 +ON sq2_alias1.pk = sq2_alias2.col_int_key; +CREATE VIEW view_inline_2 AS +SELECT 'p', 'p' UNION SELECT 'k', 's'; +SET @optimizer_switch_saved= @@optimizer_switch; +SET @@optimizer_switch="derived_merge=off"; +explain SELECT SUM(alias1.col_varchar_nokey) AS field2 +FROM t2 AS alias2 +LEFT JOIN (SELECT * FROM view_inline_0) AS alias1 +ON alias2.col_varchar_key = alias1.col_varchar_key AND +(alias2.col_varchar_nokey, alias2.col_varchar_key) IN +(SELECT * FROM view_inline_1 +) +WHERE (alias1.col_varchar_key, alias1.col_varchar_nokey) IN +(SELECT * FROM view_inline_2 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL 2 100.00 NULL +1 PRIMARY alias2 NULL ALL NULL NULL NULL NULL 11 10.00 Using where; Using join buffer (hash join) +1 PRIMARY NULL ref 8 test.alias2.col_varchar_nokey,test.view_inline_2.p 3 100.00 Using index; Start temporary; End temporary +1 PRIMARY NULL ref 8 test.view_inline_2.p,test.view_inline_2.Name_exp_p 2 100.00 NULL +7 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +8 UNION NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +NULL UNION RESULT NULL ALL NULL NULL NULL NULL NULL NULL Using temporary +6 DERIVED sq2_alias1 NULL ALL NULL NULL NULL NULL 15 100.00 NULL +6 DERIVED sq2_alias2 NULL ref col_int_key col_int_key 5 test.sq2_alias1.pk 2 100.00 NULL +2 DERIVED NULL ALL NULL NULL NULL NULL 15 100.00 NULL +5 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select sum(`alias1`.`col_varchar_nokey`) AS `field2` from `test`.`view_inline_2` join `test`.`t2` `alias2` join (/* select#2 */ select `test`.`view_inline_0`.`pk` AS `pk`,`test`.`view_inline_0`.`col_varchar_key` AS `col_varchar_key`,`test`.`view_inline_0`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`view_inline_0`) `alias1` semi join (`test`.`view_inline_1`) where ((`test`.`view_inline_1`.`sq2_field1` = `test`.`alias2`.`col_varchar_nokey`) and (`alias1`.`col_varchar_nokey` = `test`.`view_inline_2`.`Name_exp_p`) and (`test`.`alias2`.`col_varchar_key` = `test`.`view_inline_2`.`p`) and (`test`.`view_inline_1`.`sq2_field2` = `test`.`view_inline_2`.`p`) and (`alias1`.`col_varchar_key` = `test`.`view_inline_2`.`p`)) +SELECT SUM(alias1.col_varchar_nokey) AS field2 +FROM t2 AS alias2 +LEFT JOIN (SELECT * FROM view_inline_0) AS alias1 +ON alias2.col_varchar_key = alias1.col_varchar_key AND +(alias2.col_varchar_nokey, alias2.col_varchar_key) IN +(SELECT * FROM view_inline_1 +) +WHERE (alias1.col_varchar_key, alias1.col_varchar_nokey) IN +(SELECT * FROM view_inline_2 +); +field2 +NULL +SET @@optimizer_switch= @optimizer_switch_saved; +DROP VIEW view_inline_0, view_inline_1, view_inline_2; +DROP TABLE t1, t2, t3; +# End of test for bug#13956813. +# +# Bug#13974177: Assert !(tab->table->regginfo.not_exists_optimize... +# +CREATE TABLE t1 ( +pk INTEGER AUTO_INCREMENT, +col_int_nokey INTEGER, +col_int_key INTEGER, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk), +KEY (col_int_key), +KEY (col_varchar_key, col_int_key) +); +INSERT INTO t1(col_int_key, col_int_nokey, col_varchar_key, col_varchar_nokey) +VALUES +(0, 4, 'j', 'j'), (8, 6, 'v', 'v'), (1, 3, 'c', 'c'), (8, 5, 'm', 'm'), +(9, 3, 'd', 'd'), (24, 246, 'd', 'd'), (6, 2, 'y', 'y'), (1, 9, 't', 't'), +(6, 3, 'd', 'd'), (2, 8, 's', 's'), (4, 1, 'r', 'r'), (8, 8, 'm', 'm'), +(4, 8, 'b', 'b'), (4, 5, 'x', 'x'), (7, 7, 'g', 'g'), (4, 5, 'p', 'p'), +(1, 1, 'q', 'q'), (9, 6, 'w', 'w'), (4, 2, 'd', 'd'), (8, 9, 'e', 'e'); +CREATE TABLE t2 ( +pk INTEGER AUTO_INCREMENT, +col_int_nokey INTEGER NOT NULL, +col_time_key TIME NOT NULL, +col_time_nokey TIME NOT NULL, +PRIMARY KEY (pk), +KEY (col_time_key) +) ENGINE=InnoDB; +INSERT INTO t2 (col_int_nokey, col_time_key, col_time_nokey) VALUES +(7, '00:00:00', '00:00:00'), (0, '00:00:00', '00:00:00'), +(9, '06:35:17', '06:35:17'), (3, '18:07:14', '18:07:14'), +(4, '20:36:52', '20:36:52'), (2, '21:29:07', '21:29:07'), +(5, '23:45:57', '23:45:57'), (3, '22:54:57', '22:54:57'), +(1, '18:45:09', '18:45:09'), (3, '14:30:46', '14:30:46'), +(6, '19:23:43', '19:23:43'), (7, '03:39:30', '03:39:30'), +(5, '23:37:52', '23:37:52'), (1, '16:59:30', '16:59:30'), +(204, '22:21:15', '22:21:15'), (224, '12:24:37', '12:24:37'), +(9, '15:02:08', '15:02:08'), (5, '23:59:59', '23:59:59'), +(0, '08:23:30', '08:23:30'), (3, '08:32:22', '08:32:22'); +explain SELECT ot1.col_int_key AS x +FROM t1 AS ot2 +LEFT JOIN t1 AS ot1 +ON ot2.col_varchar_nokey > ot1.col_varchar_key +WHERE (ot1.col_int_nokey, ot1.pk) IN +(SELECT it1.pk AS x, +it1.col_int_nokey AS y +FROM t2 AS it2 +LEFT JOIN t2 AS it1 +ON it2.col_time_nokey = it1.col_time_key +) AND ot1.pk IS NULL +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`col_int_key` AS `x` from `test`.`t2` `it1` join `test`.`t1` `ot2` join `test`.`t1` `ot1` semi join (`test`.`t2` `it2`) where ((`test`.`ot1`.`pk` is null) and (`test`.`ot2`.`col_varchar_nokey` > `test`.`ot1`.`col_varchar_key`) and multiple equal(`test`.`ot1`.`col_int_nokey`, `test`.`it1`.`pk`) and multiple equal(`test`.`ot1`.`pk`, `test`.`it1`.`col_int_nokey`) and multiple equal(`test`.`it2`.`col_time_nokey`, `test`.`it1`.`col_time_key`)) +SELECT ot1.col_int_key AS x +FROM t1 AS ot2 +LEFT JOIN t1 AS ot1 +ON ot2.col_varchar_nokey > ot1.col_varchar_key +WHERE (ot1.col_int_nokey, ot1.pk) IN +(SELECT it1.pk AS x, +it1.col_int_nokey AS y +FROM t2 AS it2 +LEFT JOIN t2 AS it1 +ON it2.col_time_nokey = it1.col_time_key +) AND ot1.pk IS NULL +; +x +DROP TABLE t1, t2; +# End of test for bug#13974177. +# +# Bug#13971022: Assert 'keyparts > 0' failed in create_ref_for_key... +# +CREATE TABLE t1 ( +pk INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +PRIMARY KEY (pk), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +CREATE TABLE t2 ( +pk INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk) +) charset utf8mb4 ENGINE=InnoDB; +CREATE TABLE t3 ( +i INT +); +SET @optimizer_switch_saved= @@optimizer_switch; +SET @@optimizer_switch="derived_merge=off"; +explain SELECT table1.pk AS field1 +FROM ( SELECT subquery1_t1. * +FROM t2 AS subquery1_t1 +JOIN t2 AS subquery1_t2 +ON subquery1_t2.pk = subquery1_t1.pk) AS table1 +STRAIGHT_JOIN t2 AS table2 +ON table1.col_int_key IN (SELECT 7 FROM t3) +WHERE table1.col_varchar_nokey IN +(SELECT subquery3_t1.col_varchar_key AS subquery3_field1 +FROM t1 AS subquery3_t1 +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY subquery3_t1 NULL index col_varchar_key col_varchar_key 12 NULL 0 0.00 Using where; Using index; Start temporary +1 PRIMARY t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using join buffer (hash join) +1 PRIMARY NULL ref 7 test.subquery3_t1.col_varchar_key 2 100.00 NULL +1 PRIMARY table2 NULL index NULL PRIMARY 4 NULL 1 100.00 Using index; End temporary; Using join buffer (hash join) +2 DERIVED subquery1_t1 NULL ALL PRIMARY NULL NULL NULL 1 100.00 Using where +2 DERIVED subquery1_t2 NULL eq_ref PRIMARY PRIMARY 4 test.subquery1_t1.pk 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `table1`.`pk` AS `field1` from (/* select#2 */ select `test`.`subquery1_t1`.`pk` AS `pk`,`test`.`subquery1_t1`.`col_int_key` AS `col_int_key`,`test`.`subquery1_t1`.`col_varchar_key` AS `col_varchar_key`,`test`.`subquery1_t1`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t2` `subquery1_t1` join `test`.`t2` `subquery1_t2` where ((`test`.`subquery1_t1`.`col_int_key` = 7) and (`test`.`subquery1_t2`.`pk` = `test`.`subquery1_t1`.`pk`))) `table1` straight_join `test`.`t2` `table2` semi join (`test`.`t3`) semi join (`test`.`t1` `subquery3_t1`) where (`table1`.`col_varchar_nokey` = `test`.`subquery3_t1`.`col_varchar_key`) +SELECT table1.pk AS field1 +FROM ( SELECT subquery1_t1. * +FROM t2 AS subquery1_t1 +JOIN t2 AS subquery1_t2 +ON subquery1_t2.pk = subquery1_t1.pk) AS table1 +STRAIGHT_JOIN t2 AS table2 +ON table1.col_int_key IN (SELECT 7 FROM t3) +WHERE table1.col_varchar_nokey IN +(SELECT subquery3_t1.col_varchar_key AS subquery3_field1 +FROM t1 AS subquery3_t1 +) +; +field1 +SET @@optimizer_switch= @optimizer_switch_saved; +DROP TABLE t1, t2, t3; +# End of test for bug#13971022. +# +# Bug#13623473 "MISSING ROWS ON SELECT AND JOIN WITH +# TIME/DATETIME COMPARE" - Subquery part of test. +# +SET TIMESTAMP=UNIX_TIMESTAMP('2012-01-31 10:14:35'); +CREATE TABLE t1 ( +pk INT NOT NULL, +col_int_nokey INT, +col_int_key INT NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +) ENGINE=InnoDB; +INSERT INTO t1 VALUES (10,1,7), (11,7,0), (12,4,9), (13,7,3), +(14,0,4), (15,2,2), (16,9,5), (17,4,3), (18,0,1), (19,9,3), (20,1,6), +(21,3,7), (22,8,5), (23,8,1), (24,18,204), (25,84,224), (26,6,9), +(27,3,5), (28,6,0), (29,6,3); +CREATE TABLE t2 ( +col_int_nokey INT NOT NULL, +col_datetime_key DATETIME NOT NULL, +col_varchar_key VARCHAR(1) NOT NULL, +KEY col_datetime_key (col_datetime_key), +KEY col_varchar_key (col_varchar_key) +) ENGINE=InnoDB; +INSERT INTO t2 VALUES (1,'2001-11-04 19:07:55','k'); +CREATE TABLE t3 ( +col_time_key TIME, +KEY col_time_key (col_time_key) +) ENGINE=InnoDB; +INSERT INTO t3 VALUES ('21:22:34'), ('10:50:38'), ('00:21:38'), +('04:08:02'), ('16:25:11'), ('10:14:58'), ('19:47:59'), ('11:14:24'), +('00:00:00'), ('00:00:00'), ('15:57:25'), ('07:05:51'), ('19:22:21'), +('03:53:16'), ('09:16:38'), ('15:37:26'), ('00:00:00'), ('05:03:03'), +('02:59:24'), ('00:01:58'); +EXPLAIN SELECT outr.col_int_nokey +FROM t2 as outr +STRAIGHT_JOIN t3 AS outr2 +ON outr2.col_time_key > outr.col_datetime_key +WHERE outr.col_int_nokey IN ( +SELECT col_int_key +FROM t1 AS innr +WHERE innr.pk >= innr.col_int_nokey +) AND ( +outr.col_int_nokey <= 6 +OR +outr.col_varchar_key IS NULL +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE outr NULL ALL col_datetime_key NULL NULL NULL 1 100.00 Using where +2 SIMPLE innr NULL ref col_int_key col_int_key 4 test.outr.col_int_nokey 1 33.33 Using where; Start temporary; End temporary +2 SIMPLE outr2 NULL index col_time_key col_time_key 4 NULL 20 33.33 Using where; Using index; Using join buffer (hash join) +Warnings: +Warning 1739 Cannot use range access on index 'col_time_key' due to type or collation conversion on field 'col_time_key' +Note 1003 /* select#1 */ select `test`.`outr`.`col_int_nokey` AS `col_int_nokey` from `test`.`t2` `outr` straight_join `test`.`t3` `outr2` semi join (`test`.`t1` `innr`) where ((`test`.`innr`.`col_int_key` = `test`.`outr`.`col_int_nokey`) and (`test`.`outr`.`col_int_nokey` <= 6) and (`test`.`innr`.`pk` >= `test`.`innr`.`col_int_nokey`) and (cast(`test`.`outr2`.`col_time_key` as datetime) > `test`.`outr`.`col_datetime_key`)) +SELECT outr.col_int_nokey +FROM t2 as outr +STRAIGHT_JOIN t3 AS outr2 +ON outr2.col_time_key > outr.col_datetime_key +WHERE outr.col_int_nokey IN ( +SELECT col_int_key +FROM t1 AS innr +WHERE innr.pk >= innr.col_int_nokey +) AND ( +outr.col_int_nokey <= 6 +OR +outr.col_varchar_key IS NULL +); +col_int_nokey +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +DROP TABLE t1,t2,t3; +SET TIMESTAMP = DEFAULT; +# End of test for bug#13623473. +# +# Bug#13980954: Missing data on left join + null value + where..in +# +CREATE TABLE t1 ( +ik INT, +vc varchar(1) +) charset utf8mb4; +INSERT INTO t1 VALUES (8, 'x'), (NULL, 'x'); +CREATE TABLE t2 ( +ik INT, +vc varchar(1) +) charset utf8mb4; +INSERT INTO t2 VALUES +(0, 'x'), (7, 'i'), (7, 'e'), (1, 'p'), (7, 's'), (1, 'j'); +explain format=json SELECT t2.vc, t2.ik AS t2_ik, t1.ik AS t1_ik +FROM t2 LEFT JOIN t1 ON t2.vc=t1.vc +WHERE t2.vc IN (SELECT vc FROM t2 AS t3); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "9.12" + }, + "nested_loop": [ + { + "duplicates_removal": { + "using_temporary_table": true, + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 6, + "rows_produced_per_join": 6, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "0.60", + "prefix_cost": "1.11", + "data_read_per_join": "96" + }, + "used_columns": [ + "ik", + "vc" + ] + } + }, + { + "table": { + "table_name": "t3", + "access_type": "ALL", + "rows_examined_per_scan": 6, + "rows_produced_per_join": 6, + "filtered": "16.67", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "0.60", + "prefix_cost": "7.41", + "data_read_per_join": "96" + }, + "used_columns": [ + "vc" + ], + "attached_condition": "(`test`.`t3`.`vc` = `test`.`t2`.`vc`)" + } + } + ] + } + }, + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 12, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "1.20", + "prefix_cost": "9.12", + "data_read_per_join": "192" + }, + "used_columns": [ + "ik", + "vc" + ], + "attached_condition": "(is_not_null_compl(t1), (`test`.`t1`.`vc` = `test`.`t2`.`vc`), true)" + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`vc` AS `vc`,`test`.`t2`.`ik` AS `t2_ik`,`test`.`t1`.`ik` AS `t1_ik` from `test`.`t2` left join `test`.`t1` on((`test`.`t1`.`vc` = `test`.`t2`.`vc`)) semi join (`test`.`t2` `t3`) where (`test`.`t3`.`vc` = `test`.`t2`.`vc`) +SELECT t2.vc, t2.ik AS t2_ik, t1.ik AS t1_ik +FROM t2 LEFT JOIN t1 ON t2.vc=t1.vc +WHERE t2.vc IN (SELECT vc FROM t2 AS t3); +vc t2_ik t1_ik +e 7 NULL +i 7 NULL +j 1 NULL +p 1 NULL +s 7 NULL +x 0 8 +x 0 NULL +DROP TABLE t1, t2; +# End of test for bug#13980954. +# +# Bug#14048292: Segfault in Item_field::result_type on 2nd execution +# of prep stmt with join of view +# +CREATE TABLE t1 ( +col_int INT +); +INSERT INTO t1 VALUES (0), (1); +CREATE VIEW view_t1 AS SELECT * FROM t1; +explain SELECT alias1.col_int +FROM t1 AS alias1 +LEFT JOIN view_t1 AS alias2 +ON alias1.col_int IN +(SELECT sq1_alias1.col_int +FROM t1 AS sq1_alias1 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE alias1 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE sq1_alias1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`alias1`.`col_int` AS `col_int` from `test`.`t1` `alias1` left join (`test`.`t1` semi join (`test`.`t1` `sq1_alias1`)) on(((`test`.`sq1_alias1`.`col_int` = `test`.`alias1`.`col_int`))) where true +PREPARE stmt FROM "SELECT alias1.col_int +FROM t1 AS alias1 +LEFT JOIN view_t1 AS alias2 +ON alias1.col_int IN +(SELECT sq1_alias1.col_int +FROM t1 AS sq1_alias1 +)"; +EXECUTE stmt; +col_int +0 +0 +1 +1 + +EXECUTE stmt; +col_int +0 +0 +1 +1 +DEALLOCATE PREPARE stmt; +DROP VIEW view_t1; +DROP TABLE t1; +# End of test for bug#14048292. +# +# Bug#14064201: Missing data on join of derived table + WHERE .. IN +# with two operands +# +CREATE TABLE t1 ( +col_varchar_nokey VARCHAR(1) +) charset utf8mb4; +INSERT INTO t1 VALUES +('v'), ('s'), ('l'), ('y'), ('c'), ('i'), ('h'), ('q'), ('a'), ('v'), +('u'), ('s'), ('y'), ('z'), ('h'), ('p'), ('e'), ('i'), ('y'), ('w'); +CREATE TABLE t2 ( +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +KEY col_varchar_key(col_varchar_key) +) charset utf8mb4; +INSERT INTO t2 VALUES +('j','j'), ('v','v'), ('c','c'), ('m','m'), ('d','d'), ('d','d'), ('y','y'); +SET @optimizer_switch_saved= @@optimizer_switch; +SET @@optimizer_switch="derived_merge=off"; +explain format=json SELECT * +FROM (SELECT * FROM t2) AS derived1 +LEFT JOIN t1 +USING (col_varchar_nokey) +WHERE (col_varchar_nokey, col_varchar_nokey) IN +(SELECT col_varchar_nokey, col_varchar_key +FROM t2 AS derived2 +); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "23.73" + }, + "nested_loop": [ + { + "duplicates_removal": { + "using_temporary_table": true, + "nested_loop": [ + { + "table": { + "table_name": "derived2", + "access_type": "ALL", + "possible_keys": [ + "col_varchar_key" + ], + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "0.70", + "prefix_cost": "1.21", + "data_read_per_join": "112" + }, + "used_columns": [ + "col_varchar_key", + "col_varchar_nokey" + ], + "attached_condition": "((`test`.`derived2`.`col_varchar_key` = `test`.`derived2`.`col_varchar_nokey`) and (`test`.`derived2`.`col_varchar_nokey` is not null))" + } + }, + { + "table": { + "table_name": "derived1", + "access_type": "ref", + "possible_keys": [ + "" + ], + "key": "", + "used_key_parts": [ + "col_varchar_nokey" + ], + "key_length": "7", + "ref": [ + "test.derived2.col_varchar_nokey" + ], + "rows_examined_per_scan": 2, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "3.50", + "eval_cost": "0.70", + "prefix_cost": "9.21", + "data_read_per_join": "112" + }, + "used_columns": [ + "col_varchar_key", + "col_varchar_nokey" + ], + "materialized_from_subquery": { + "using_temporary_table": true, + "dependent": false, + "cacheable": true, + "query_block": { + "select_id": 2, + "cost_info": { + "query_cost": "1.21" + }, + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "0.70", + "prefix_cost": "1.21", + "data_read_per_join": "112" + }, + "used_columns": [ + "col_varchar_key", + "col_varchar_nokey" + ] + } + } + } + } + } + ] + } + }, + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 140, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.52", + "eval_cost": "14.00", + "prefix_cost": "23.73", + "data_read_per_join": "1K" + }, + "used_columns": [ + "col_varchar_nokey" + ], + "attached_condition": "(is_not_null_compl(t1), (`test`.`t1`.`col_varchar_nokey` = `test`.`derived2`.`col_varchar_nokey`), true)" + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select `derived1`.`col_varchar_nokey` AS `col_varchar_nokey`,`derived1`.`col_varchar_key` AS `col_varchar_key` from (/* select#2 */ select `test`.`t2`.`col_varchar_key` AS `col_varchar_key`,`test`.`t2`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t2`) `derived1` left join `test`.`t1` on((`test`.`t1`.`col_varchar_nokey` = `test`.`derived2`.`col_varchar_nokey`)) semi join (`test`.`t2` `derived2`) where ((`test`.`derived2`.`col_varchar_key` = `test`.`derived2`.`col_varchar_nokey`) and (`derived1`.`col_varchar_nokey` = `test`.`derived2`.`col_varchar_nokey`)) +SELECT * +FROM (SELECT * FROM t2) AS derived1 +LEFT JOIN t1 +USING (col_varchar_nokey) +WHERE (col_varchar_nokey, col_varchar_nokey) IN +(SELECT col_varchar_nokey, col_varchar_key +FROM t2 AS derived2 +); +col_varchar_nokey col_varchar_key +c c +d d +d d +j j +m m +v v +v v +y y +y y +y y +SET @@optimizer_switch= @optimizer_switch_saved; +DROP TABLE t1, t2; +CREATE TABLE t1 ( +col_int_nokey int NOT NULL, +col_int_key int NOT NULL, +KEY col_int_key (col_int_key) +); +INSERT INTO t1 VALUES +(1,7), (7,0), (4,9), (7,3), (0,4), (2,2), (9,5), (4,3), (0,1), (9,3), +(1,6), (3,7), (8,5), (8,1), (18,204), (84,224), (6,9), (3,5), (6,0), (6,3); +CREATE TABLE t2 ( +col_int_nokey int NOT NULL, +col_int_key int NOT NULL, +KEY col_int_key (col_int_key) +); +INSERT INTO t2 VALUES +(4,0), (6,8), (3,1), (5,8), (3,9), (246,24), (2,6), (9,1), (3,6), (8,2), +(1,4), (8,8), (8,4), (5,4), (7,7), (5,4), (1,1), (6,9), (2,4), (9,8); +explain format=json SELECT grandparent1.* +FROM t1 AS grandparent1 +LEFT JOIN t1 USING (col_int_nokey) +WHERE (col_int_nokey, col_int_nokey) IN +(SELECT col_int_nokey, col_int_key +FROM t2 +); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "61.30" + }, + "nested_loop": [ + { + "table": { + "table_name": "grandparent1", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 20, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "2.00", + "prefix_cost": "2.51", + "data_read_per_join": "320" + }, + "used_columns": [ + "col_int_nokey", + "col_int_key" + ] + } + }, + { + "duplicates_removal": { + "using_temporary_table": true, + "table": { + "table_name": "t2", + "access_type": "ref", + "possible_keys": [ + "col_int_key" + ], + "key": "col_int_key", + "used_key_parts": [ + "col_int_key" + ], + "key_length": "4", + "ref": [ + "test.grandparent1.col_int_nokey" + ], + "rows_examined_per_scan": 2, + "rows_produced_per_join": 20, + "filtered": "10.00", + "cost_info": { + "read_cost": "10.00", + "eval_cost": "2.00", + "prefix_cost": "20.79", + "data_read_per_join": "320" + }, + "used_columns": [ + "col_int_nokey", + "col_int_key" + ], + "attached_condition": "(`test`.`t2`.`col_int_nokey` = `test`.`grandparent1`.`col_int_nokey`)" + } + } + }, + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 400, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "40.00", + "prefix_cost": "61.30", + "data_read_per_join": "6K" + }, + "used_columns": [ + "col_int_nokey" + ], + "attached_condition": "(is_not_null_compl(t1), (`test`.`t1`.`col_int_nokey` = `test`.`grandparent1`.`col_int_nokey`), true)" + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`grandparent1`.`col_int_nokey` AS `col_int_nokey`,`test`.`grandparent1`.`col_int_key` AS `col_int_key` from `test`.`t1` `grandparent1` left join `test`.`t1` on((`test`.`t1`.`col_int_nokey` = `test`.`grandparent1`.`col_int_nokey`)) semi join (`test`.`t2`) where ((`test`.`t2`.`col_int_nokey` = `test`.`grandparent1`.`col_int_nokey`) and (`test`.`t2`.`col_int_key` = `test`.`grandparent1`.`col_int_nokey`)) +SELECT grandparent1.* +FROM t1 AS grandparent1 +LEFT JOIN t1 USING (col_int_nokey) +WHERE (col_int_nokey, col_int_nokey) IN +(SELECT col_int_nokey, col_int_key +FROM t2 +); +col_int_nokey col_int_key +1 6 +1 6 +1 7 +1 7 +7 0 +7 0 +7 3 +7 3 +8 1 +8 1 +8 5 +8 5 +DROP TABLE t1, t2; +CREATE TABLE t1 ( +pk int, +col_int_key int, +col_datetime_key datetime, +col_varchar_key varchar(1), +col_varchar_nokey varchar(1), +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_datetime_key (col_datetime_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4 engine=MyISAM; +INSERT INTO t1 VALUES +(10,7,'2004-06-06 04:22:12','v','v'), (11,0,'2005-11-13 01:12:31','s','s'), +(12,9,'2002-05-04 01:50:00','l','l'), (13,3,'2004-10-27 10:28:45','y','y'), +(14,4,'2006-07-22 05:24:23','c','c'), (15,2,'2002-05-16 21:34:03','i','i'), +(16,5,'2008-04-17 10:45:30','h','h'), (17,3,'2009-04-21 02:58:02','q','q'), +(18,1,'2008-01-11 11:01:51','a','a'), (19,3,'1900-01-01 00:00:00','v','v'), +(20,6,'2007-05-17 18:24:57','u','u'), (21,7,'2007-08-07 00:00:00','s','s'), +(22,5,'2001-08-28 00:00:00','y','y'), (23,1,'2004-04-16 00:27:28','z','z'), +(24,204,'2005-05-03 07:06:22','h','h'), (25,224,'2009-03-11 17:09:50','p','p'), +(26,9,'2007-12-08 01:54:28','e','e'), (27,5,'2009-07-28 18:19:54','i','i'), +(28,0,'2008-06-08 00:00:00','y','y'), (29,3,'2005-02-09 09:20:26','w','w'); +CREATE TABLE t2 ( +pk int, +col_int_key int, +col_datetime_key datetime, +col_varchar_key varchar(1), +col_varchar_nokey varchar(1), +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_datetime_key (col_datetime_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4 engine=MyISAM; +INSERT INTO t2 VALUES +(1,0,'2002-02-13 17:30:06','j','j'), (2,8,'2008-09-27 00:34:58','v','v'), +(3,1,'2007-05-28 00:00:00','c','c'), (4,8,'2009-07-25 09:21:20','m','m'), +(5,9,'2002-01-16 00:00:00','d','d'), (6,24,'2006-10-12 04:32:53','d','d'), +(7,6,'2001-02-15 03:08:38','y','y'), (8,1,'2004-10-02 20:31:15','t','t'), +(9,6,'2002-08-20 22:48:00','d','d'), (10,2,'1900-01-01 00:00:00','s','s'), +(11,4,'2005-08-15 00:00:00','r','r'), (12,8,'1900-01-01 00:00:00','m','m'), +(13,4,'2008-05-16 08:09:06','b','b'), (14,4,'2001-01-20 12:47:23','x','x'), +(15,7,'2008-07-02 00:00:00','g','g'), (16,4,'1900-01-01 00:00:00','p','p'), +(17,1,'2002-12-08 11:34:58','q','q'), (18,9,'1900-01-01 00:00:00','w','w'), +(19,4,'1900-01-01 00:00:00','d','d'), (20,8,'2002-08-25 20:35:06','e','e'); +SELECT alias1.col_datetime_key +FROM t2 AS alias1 +RIGHT JOIN t2 AS alias2 +JOIN t2 AS alias3 +ON alias3.pk = alias2.pk +ON alias3.col_varchar_nokey = alias2.col_varchar_key OR +alias2.col_varchar_nokey +WHERE (alias2.col_varchar_key, alias2.col_varchar_key) IN +(SELECT sq2_alias2.col_varchar_key, sq2_alias1.col_varchar_nokey +FROM t1 AS sq2_alias1, t1 AS sq2_alias2 +WHERE sq2_alias2.col_int_key < 2); +col_datetime_key +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +2001-01-20 12:47:23 +2001-01-20 12:47:23 +2001-02-15 03:08:38 +2001-02-15 03:08:38 +2002-01-16 00:00:00 +2002-01-16 00:00:00 +2002-02-13 17:30:06 +2002-02-13 17:30:06 +2002-08-20 22:48:00 +2002-08-20 22:48:00 +2002-08-25 20:35:06 +2002-08-25 20:35:06 +2002-12-08 11:34:58 +2002-12-08 11:34:58 +2004-10-02 20:31:15 +2004-10-02 20:31:15 +2005-08-15 00:00:00 +2005-08-15 00:00:00 +2006-10-12 04:32:53 +2006-10-12 04:32:53 +2007-05-28 00:00:00 +2007-05-28 00:00:00 +2008-05-16 08:09:06 +2008-05-16 08:09:06 +2008-07-02 00:00:00 +2008-07-02 00:00:00 +2008-09-27 00:34:58 +2008-09-27 00:34:58 +2009-07-25 09:21:20 +2009-07-25 09:21:20 +ALTER TABLE t1 DISABLE KEYS; +ALTER TABLE t2 DISABLE KEYS; +explain format=json SELECT alias1.col_datetime_key +FROM t2 AS alias1 +RIGHT JOIN t2 AS alias2 +JOIN t2 AS alias3 +ON alias3.pk = alias2.pk +ON alias3.col_varchar_nokey = alias2.col_varchar_key OR +alias2.col_varchar_nokey +WHERE (alias2.col_varchar_key, alias2.col_varchar_key) IN +(SELECT sq2_alias2.col_varchar_key, sq2_alias1.col_varchar_nokey +FROM t1 AS sq2_alias1, t1 AS sq2_alias2 +WHERE sq2_alias2.col_int_key < 2); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "52.68" + }, + "nested_loop": [ + { + "duplicates_removal": { + "using_temporary_table": true, + "nested_loop": [ + { + "table": { + "table_name": "sq2_alias2", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 6, + "filtered": "33.33", + "cost_info": { + "read_cost": "1.86", + "eval_cost": "0.67", + "prefix_cost": "2.53", + "data_read_per_join": "213" + }, + "used_columns": [ + "col_int_key", + "col_varchar_key" + ], + "attached_condition": "(`test`.`sq2_alias2`.`col_int_key` < 2)" + } + }, + { + "table": { + "table_name": "alias2", + "access_type": "ALL", + "possible_keys": [ + "PRIMARY" + ], + "rows_examined_per_scan": 20, + "rows_produced_per_join": 13, + "filtered": "10.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.53", + "eval_cost": "1.33", + "prefix_cost": "16.39", + "data_read_per_join": "426" + }, + "used_columns": [ + "pk", + "col_varchar_key", + "col_varchar_nokey" + ], + "attached_condition": "(`test`.`alias2`.`col_varchar_key` = `test`.`sq2_alias2`.`col_varchar_key`)" + } + }, + { + "table": { + "table_name": "sq2_alias1", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 2, + "filtered": "10.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.53", + "eval_cost": "0.20", + "prefix_cost": "47.45", + "data_read_per_join": "64" + }, + "used_columns": [ + "col_varchar_nokey" + ], + "attached_condition": "(`test`.`sq2_alias1`.`col_varchar_nokey` = `test`.`sq2_alias2`.`col_varchar_key`)" + } + } + ] + } + }, + { + "table": { + "table_name": "alias3", + "access_type": "eq_ref", + "possible_keys": [ + "PRIMARY" + ], + "key": "PRIMARY", + "used_key_parts": [ + "pk" + ], + "key_length": "4", + "ref": [ + "test.alias2.pk" + ], + "rows_examined_per_scan": 1, + "rows_produced_per_join": 2, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.20", + "prefix_cost": "48.15", + "data_read_per_join": "64" + }, + "used_columns": [ + "pk", + "col_varchar_nokey" + ] + } + }, + { + "table": { + "table_name": "alias1", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 40, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.53", + "eval_cost": "4.00", + "prefix_cost": "52.68", + "data_read_per_join": "1K" + }, + "used_columns": [ + "col_datetime_key" + ], + "attached_condition": "(is_not_null_compl(alias1), (((`test`.`alias2`.`col_varchar_key` = `test`.`sq2_alias2`.`col_varchar_key`) and (`test`.`sq2_alias1`.`col_varchar_nokey` = `test`.`sq2_alias2`.`col_varchar_key`) and (`test`.`alias3`.`col_varchar_nokey` = `test`.`sq2_alias2`.`col_varchar_key`)) or (0 <> `test`.`alias2`.`col_varchar_nokey`)), true)" + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`alias1`.`col_datetime_key` AS `col_datetime_key` from `test`.`t2` `alias2` join `test`.`t2` `alias3` left join `test`.`t2` `alias1` on((((`test`.`alias2`.`col_varchar_key` = `test`.`sq2_alias2`.`col_varchar_key`) and (`test`.`sq2_alias1`.`col_varchar_nokey` = `test`.`sq2_alias2`.`col_varchar_key`) and (`test`.`alias3`.`col_varchar_nokey` = `test`.`sq2_alias2`.`col_varchar_key`)) or (0 <> `test`.`alias2`.`col_varchar_nokey`))) semi join (`test`.`t1` `sq2_alias1` join `test`.`t1` `sq2_alias2`) where ((`test`.`alias3`.`pk` = `test`.`alias2`.`pk`) and (`test`.`alias2`.`col_varchar_key` = `test`.`sq2_alias2`.`col_varchar_key`) and (`test`.`sq2_alias1`.`col_varchar_nokey` = `test`.`sq2_alias2`.`col_varchar_key`) and (`test`.`sq2_alias2`.`col_int_key` < 2)) +SELECT alias1.col_datetime_key +FROM t2 AS alias1 +RIGHT JOIN t2 AS alias2 +JOIN t2 AS alias3 +ON alias3.pk = alias2.pk +ON alias3.col_varchar_nokey = alias2.col_varchar_key OR +alias2.col_varchar_nokey +WHERE (alias2.col_varchar_key, alias2.col_varchar_key) IN +(SELECT sq2_alias2.col_varchar_key, sq2_alias1.col_varchar_nokey +FROM t1 AS sq2_alias1, t1 AS sq2_alias2 +WHERE sq2_alias2.col_int_key < 2); +col_datetime_key +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +2001-01-20 12:47:23 +2001-01-20 12:47:23 +2001-02-15 03:08:38 +2001-02-15 03:08:38 +2002-01-16 00:00:00 +2002-01-16 00:00:00 +2002-02-13 17:30:06 +2002-02-13 17:30:06 +2002-08-20 22:48:00 +2002-08-20 22:48:00 +2002-08-25 20:35:06 +2002-08-25 20:35:06 +2002-12-08 11:34:58 +2002-12-08 11:34:58 +2004-10-02 20:31:15 +2004-10-02 20:31:15 +2005-08-15 00:00:00 +2005-08-15 00:00:00 +2006-10-12 04:32:53 +2006-10-12 04:32:53 +2007-05-28 00:00:00 +2007-05-28 00:00:00 +2008-05-16 08:09:06 +2008-05-16 08:09:06 +2008-07-02 00:00:00 +2008-07-02 00:00:00 +2008-09-27 00:34:58 +2008-09-27 00:34:58 +2009-07-25 09:21:20 +2009-07-25 09:21:20 +DROP TABLE t1, t2; +# End of test for bug#14064201. +# +# Bug#18223655:ASSERTION FAILED: (INT)IDX >= 0 +# && IDX < PARENT_JOIN->TABLES +# +CREATE TABLE b (d INT); +CREATE TABLE c (a INT, b INT,c INT,d BLOB NOT NULL); +SELECT(SELECT 1 +FROM b WHERE(SELECT 1 IN (SELECT 1 FROM b WHERE 1 NOT BETWEEN d AND 1) +FROM b) IN (SELECT d FROM c)) as cc FROM b; +cc +INSERT INTO b VALUE(1); +INSERT INTO c VALUES(1,2,3,'1'),(2,3,4,'1'),(3,4,5,'C'); +SELECT(SELECT d FROM b WHERE(SELECT d IN +(SELECT d FROM b WHERE 1 NOT BETWEEN d AND 1) FROM b) IN +(SELECT d FROM c)) as cc FROM c; +cc +1 +1 +1 +DROP TABLE b,c; +# +# Bug#18447874:WRONG RESULT COMING FROM SEMI-JOIN +# +CREATE TABLE b ( +d INT(11) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE c ( +d BLOB +) ; +CREATE TABLE d ( +b INT(11) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO b VALUES(1),(2),(4); +INSERT INTO c VALUES(1),(2),(3); +SELECT 1 FROM b WHERE (SELECT 1 FROM d ) IN (SELECT d FROM c) ; +1 +INSERT INTO d VALUES(2); +SELECT 1 FROM b WHERE (SELECT 1 FROM d ) IN (SELECT d FROM c) ; +1 +1 +1 +1 +DROP TABLE b,c,d; +# +# Bug#17292723:INCORRECT RESULT FOR (SELECT...) IN (SELECT...) STATEMENT +# +CREATE TABLE t1 ( +ID int(11) NOT NULL AUTO_INCREMENT, +id2 int(11) DEFAULT NULL, +id3 int(11) DEFAULT NULL, +id4 varchar(150) COLLATE utf8_spanish_ci NOT NULL, +id5 int(11) DEFAULT NULL, +PRIMARY KEY (ID), +KEY id2 (id2), +KEY id3 (id3), +KEY id5 (id5) +) ENGINE=InnoDB; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 3778 'utf8_spanish_ci' is a collation of the deprecated character set UTF8MB3. Please consider using UTF8MB4 with an appropriate collation instead. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES +(123,1,1,'1',NULL), +(124,1,1,'2',NULL), +(125,1,1,'4',NULL), +(126,1,1,'3',NULL), +(127,1,1,'6',NULL), +(128,1,1,'8',NULL); +CREATE TABLE t2 ( +id6 int(11) NOT NULL, +id7 int(11) NOT NULL, +PRIMARY KEY (id6,id7), +KEY id7 (id7) +) ENGINE=InnoDB; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (126,123),(130,123),(135,123); +SELECT ID +FROM t1 p0 +WHERE p0.id3=1 +AND ( (SELECT p1.id FROM t1 p1 WHERE p1.id=123) IN (SELECT p3.id FROM t2 +p2, t1 p3 WHERE p0.id=p2.id6 AND p2.id7=p3.id)); +ID +126 +DROP TABLE t1,t2; +set @@optimizer_switch=@old_opt_switch; +# End of 5.6 tests +# +# Bug#19336348 DEBUG CRASH AT SETUP_SEMIJOIN_DUPS_ELIMINATION IN SQL/SQL_SELECT.CC +# +CREATE TABLE t1 ( +col_varchar_nokey varchar(1) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t1 VALUES ('c'),(NULL),('x'); +CREATE TABLE t2 ( +pk int, +col_varchar_key varchar(1), +PRIMARY KEY (pk), +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t2 VALUES (10,'l'),(11,'p'); +ANALYZE TABLE t1,t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN SELECT 1 +FROM t1 AS outr +WHERE outr.col_varchar_nokey IN +( +SELECT innr.col_varchar_key +FROM t2 AS innr +WHERE innr.pk <= 7 +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE innr NULL range PRIMARY,col_varchar_key PRIMARY 4 NULL 1 100.00 Using where; Start temporary +1 SIMPLE outr NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` `outr` semi join (`test`.`t2` `innr`) where ((`test`.`outr`.`col_varchar_nokey` = `test`.`innr`.`col_varchar_key`) and (`test`.`innr`.`pk` <= 7)) +SELECT 1 +FROM t1 AS outr +WHERE outr.col_varchar_nokey IN +( +SELECT innr.col_varchar_key +FROM t2 AS innr +WHERE innr.pk <= 7 +) +; +1 +DROP TABLE t1,t2; +# +# Bug#18174394 BLOBS: CRASH AFTER UNINITIALIZED VALUES IN ITEM_FIELD::STR_RESULT +# +CREATE TABLE t1(d BLOB, b BLOB); +INSERT INTO t1(d,b) VALUES ('aaaa',''),('bnbb',''); +SELECT 1 FROM t1 +WHERE (SELECT b FROM t1) IN (SELECT (d>=1) FROM t1); +ERROR 21000: Subquery returns more than 1 row +DROP TABLE t1; +# +# Bug#19779600: ASSERT FAILED IN REPLACE_SUBCONDITION WITH IN +# PREDICATE INSIDE IN PREDICATE +# +CREATE TABLE t(X INT) ENGINE=InnoDB; +INSERT INTO t VALUES (1); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +EXPLAIN SELECT 1 FROM t WHERE (1 IN (SELECT 1 FROM t)) IN (SELECT 1 FROM t); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 PRIMARY t NULL ALL NULL NULL NULL NULL 1 100.00 End temporary; Using join buffer (hash join) +2 SUBQUERY t NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t` semi join (`test`.`t`) where true +SELECT 1 FROM t WHERE (1 IN (SELECT 1 FROM t)) IN (SELECT 1 FROM t); +1 +1 +DROP TABLE t; +# +# Bug#19465034 ASSERT ON SETUP_SEMIJOIN_DUPS_ELIMINATION IN SQL/SQL_SELECT.CC +# +CREATE TABLE t1 ( +pk INTEGER NOT NULL, +i1 INTEGER NOT NULL, +PRIMARY KEY (pk) +) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1,1); +CREATE TABLE t2 ( +pk INTEGER NOT NULL, +c1 VARCHAR(1) NOT NULL, +PRIMARY KEY (pk), +KEY c1_key (c1) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t2 VALUES (1,'j'),(2,'v'),(3,'c'); +CREATE TABLE t3 ( +pk INTEGER NOT NULL, +c1 VARCHAR(1) NOT NULL, +PRIMARY KEY (pk), +KEY c1_key (c1) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t3 VALUES (10,'v'),(11,'s'); +ANALYZE TABLE t1, t2, t3; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +EXPLAIN SELECT * +FROM t1 JOIN t2 ON t1.i1 >= t2.pk +WHERE t2.c1 IN ( +SELECT t3.c1 +FROM t3 +WHERE t3.pk < 3 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +2 SIMPLE t3 NULL range PRIMARY,c1_key PRIMARY 4 NULL 1 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t2 NULL ref PRIMARY,c1_key c1_key 6 test.t3.c1 1 33.33 Using where; Using index; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`i1` AS `i1`,`test`.`t2`.`pk` AS `pk`,`test`.`t2`.`c1` AS `c1` from `test`.`t1` join `test`.`t2` semi join (`test`.`t3`) where ((`test`.`t2`.`c1` = `test`.`t3`.`c1`) and (`test`.`t3`.`pk` < 3) and (`test`.`t1`.`i1` >= `test`.`t2`.`pk`)) +SELECT * +FROM t1 JOIN t2 ON t1.i1 >= t2.pk +WHERE t2.c1 IN ( +SELECT t3.c1 +FROM t3 +WHERE t3.pk < 3 +); +pk i1 pk c1 +DROP TABLE t1,t2,t3; +# +# Bug#19586047: CRASH IN ARG_COMPARATOR::SET_CMP_FUNC +# +CREATE TABLE t1(x INT) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT 1 FROM t1 WHERE EXISTS(SELECT 1) IN (SELECT 1 FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 1 100.00 End temporary; Using join buffer (hash join) +2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` semi join (`test`.`t1`) where true +SELECT 1 FROM t1 WHERE EXISTS(SELECT 1) IN (SELECT 1 FROM t1); +1 +1 +EXPLAIN SELECT 1 FROM t1 WHERE (SELECT 1, 2 FROM t1) IN (SELECT 1, 2 FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 1 100.00 End temporary; Using join buffer (hash join) +2 SUBQUERY t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` semi join (`test`.`t1`) where true +SELECT 1 FROM t1 WHERE (SELECT 1, 2 FROM t1) IN (SELECT 1, 2 FROM t1); +1 +1 +EXPLAIN SELECT 1 FROM t1 WHERE +(SELECT 1, 2 FROM t1 WHERE x = 2) IN (SELECT 1, 2 FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +2 SUBQUERY t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` semi join (`test`.`t1`) where false +SELECT 1 FROM t1 WHERE +(SELECT 1, 2 FROM t1 WHERE x = 2) IN (SELECT 1, 2 FROM t1); +1 +DROP TABLE t1; +# +#Bug#20119743 ASSERTIONQEP_TAB->USE_ORDER() IN ENUM_NESTED_LOOP_STATE +# EVALUATE_JOIN_RECORD +# +CREATE TABLE t1 ( +pk int(11) NOT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +PRIMARY KEY (pk) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (1,'x'); +CREATE TABLE t2 ( +col_date_key date DEFAULT NULL, +col_int_key int(11) DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +KEY col_int_key (col_int_key), +KEY col_date_key (col_date_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES ('2000-12-03', 8, 'x', 'x'),('2008-05-03', 7, 'd', 'd'), +('2005-12-06', 1, 'r', 'r'),('2000-04-10', 7, 'f', 'f'), +('2002-11-05', 9, 'y', 'y'),('2000-09-06', NULL, 'u', 'u'), +(NULL, 1, 'm', 'm'),('2007-06-14', 9, NULL, NULL), +('2007-11-17', 2, 'o', 'o'),('2009-02-23', 9, 'w', 'w'), +('2007-01-08', 2, 'm', 'm'), ('2008-06-10', 4, 'q', 'q'), +('2002-10-20', 0, NULL, NULL),('2008-09-12', 4, 'd', 'd'), +('2006-06-16', 8, 'g', 'g'),('2004-09-18', NULL, 'x', 'x'), +('1900-01-01', NULL, 'f', 'f'),('2005-09-13', 0, 'p', 'p'), +('2007-04-09', NULL, 'j', 'j'),('2000-09-20', 8, 'c', 'c'); +CREATE TABLE t3 ( +pk int(11) NOT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +PRIMARY KEY (pk) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t3 VALUES (1, 'c'),(2, 'c'),(3, 'q'),(4, 'g'),(5, 'e'),(6, 'l'), +(7, NULL),(8, 'v'),(9, 'c'),(10, 'u'),(11, 'x'),(12, 'x'),(13, 'x'),(14, 'l'), +(15, 'e'),(16, 's'),(17, 'k'),(18, 'm'),(19, 'x'),(20, 's'); +ANALYZE TABLE t1,t2,t3; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +EXPLAIN SELECT r1.col_date_key +FROM t2 AS r1 +WHERE r1.col_int_key NOT IN +(SELECT ir2.pk +FROM t2 AS ir1 STRAIGHT_JOIN t1 AS ir2 +ON ir2.col_varchar_nokey = ir1.col_varchar_key +WHERE ir2.col_varchar_nokey > r1.col_varchar_nokey +AND ir2.pk IN +(SELECT iir2.pk +FROM t2 AS iir1 RIGHT JOIN t3 AS iir2 +ON iir2.col_varchar_nokey = iir1.col_varchar_key)) +ORDER BY r1.col_date_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY r1 NULL ALL NULL NULL NULL NULL 20 100.00 Using where; Using filesort +2 DEPENDENT SUBQUERY iir2 NULL eq_ref PRIMARY PRIMARY 4 func 1 100.00 Using where; Start temporary; Full scan on NULL key +2 DEPENDENT SUBQUERY iir1 NULL ref col_varchar_key col_varchar_key 7 test.iir2.col_varchar_nokey 1 100.00 Using index +2 DEPENDENT SUBQUERY ir1 NULL index col_varchar_key col_varchar_key 12 NULL 20 100.00 Using where; Using index; Using join buffer (hash join) +2 DEPENDENT SUBQUERY ir2 NULL eq_ref PRIMARY PRIMARY 4 func 1 100.00 Using where; End temporary; Full scan on NULL key +SELECT r1.col_date_key +FROM t2 AS r1 +WHERE r1.col_int_key NOT IN +(SELECT ir2.pk +FROM t2 AS ir1 STRAIGHT_JOIN t1 AS ir2 +ON ir2.col_varchar_nokey = ir1.col_varchar_key +WHERE ir2.col_varchar_nokey > r1.col_varchar_nokey +AND ir2.pk IN +(SELECT iir2.pk +FROM t2 AS iir1 RIGHT JOIN t3 AS iir2 +ON iir2.col_varchar_nokey = iir1.col_varchar_key)) +ORDER BY r1.col_date_key; +col_date_key +2000-04-10 +2000-09-20 +2000-12-03 +2002-10-20 +2002-11-05 +2004-09-18 +2005-09-13 +2006-06-16 +2007-01-08 +2007-06-14 +2007-11-17 +2008-05-03 +2008-06-10 +2008-09-12 +2009-02-23 +SELECT COUNT(r1.col_date_key) AS COUNT_NUM +FROM t2 AS r1 +WHERE r1.col_int_key NOT IN +(SELECT ir2.pk +FROM t2 AS ir1 STRAIGHT_JOIN t1 AS ir2 +ON ir2.col_varchar_nokey = ir1.col_varchar_key +WHERE ir2.col_varchar_nokey > r1.col_varchar_nokey +AND ir2.pk IN +(SELECT iir2.pk +FROM t2 AS iir1 RIGHT JOIN t3 AS iir2 +ON iir2.col_varchar_nokey = iir1.col_varchar_key +WHERE iir2.pk<3)); +COUNT_NUM +15 +DROP TABLE t1,t2,t3; +# +# Bug#20554585 ASSERT JOIN()->TABLES == 0... IN JOIN_TAB::GET_SJ_STRATEGY ON SUBQUERY + VAR +# +CREATE TABLE t1 ( +pk int NOT NULL, +PRIMARY KEY (pk) +); +CREATE TABLE t2 ( +pk int NOT NULL, +col_int_key int, +col_varchar_key varchar(1), +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key) +); +CREATE TABLE t3 ( +pk int NOT NULL, +col_int_key int, +col_varchar_key varchar(1), +col_varchar varchar(1), +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key) +); +INSERT INTO t3 VALUES (1,4,'c','g'),(20,1,'i','p'); +CREATE TABLE t4 ( +col_int int +); +CREATE TABLE t5 ( +col_varchar_key varchar(1), +pk int NOT NULL, +col_int int, +PRIMARY KEY (pk), +KEY col_varchar_key (col_varchar_key) +); +SELECT table1.col_varchar_key AS field1 +FROM (t3 AS table1 +INNER JOIN ( +SELECT SUBQUERY1_t1.* +FROM (t1 AS SUBQUERY1_t1 +RIGHT JOIN (t2 AS SUBQUERY1_t2 +INNER JOIN t3 AS SUBQUERY1_t3 +ON (SUBQUERY1_t3.col_varchar_key = SUBQUERY1_t2.col_varchar_key) +) ON (SUBQUERY1_t3.col_int_key = SUBQUERY1_t2.pk) +) +WHERE SUBQUERY1_t2.col_varchar_key >= ANY ( +SELECT CHILD_SUBQUERY1_t2.col_varchar AS CHILD_SUBQUERY1_field1 +FROM (t2 AS CHILD_SUBQUERY1_t1 +LEFT OUTER JOIN t3 AS CHILD_SUBQUERY1_t2 +ON (CHILD_SUBQUERY1_t2.col_int_key = CHILD_SUBQUERY1_t1.col_int_key) +) +WHERE CHILD_SUBQUERY1_t1.pk >= SUBQUERY1_t2.pk +) +) AS table2 +ON (table2.pk = table1.pk) +) +WHERE (EXISTS (( +SELECT DISTINCT SUBQUERY2_t2.col_int AS SUBQUERY2_field1 +FROM (t4 AS SUBQUERY2_t1 +LEFT OUTER JOIN t5 AS SUBQUERY2_t2 +ON (SUBQUERY2_t2.pk = SUBQUERY2_t1.col_int) +) +WHERE SUBQUERY2_t2.col_varchar_key != @var4 +))) +AND table1.col_int_key < (35 + 192) +ORDER BY field1 +; +field1 +DROP TABLE t1, t2, t3, t4, t5; +# +# Bug#18892055: MISSING DATA ON SELECT ... IN WITH JOINS AND INNODB +# ENGINE +# +CREATE TABLE t1 ( +col_int_key INT, +pk INT NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +) ENGINE = INNODB; +INSERT INTO t1 VALUES +( 0, 3 ), +( 0, 4 ), +( 3, 1 ), +( 900000000, 2 ), +( 1368719360, 5 ), +( 1922236416, 6 ), +( 8,7 ); +CREATE TABLE t2 ( +pk INT NOT NULL, +col_int INT, +PRIMARY KEY (pk) +) ENGINE = INNODB; +INSERT INTO t2 VALUES +( 1, 3 ), +( 2, 2 ), +( 3, 8 ), +( 4, 7 ); +CREATE TABLE t3 ( +col_int_key INT, +col_int INT, +KEY (col_int_key) +) ENGINE = INNODB; +INSERT INTO t3 VALUES +( 5, 1 ), +( -1, -1 ), +( 300000000, 1 ), +( 8, 1 ); +CREATE TABLE t4 ( col_int_key INT ) ENGINE = INNODB; +INSERT INTO t4 VALUES +(0), +(3), +(8), +(900000000), +(1368719360), +(1922236416); +ANALYZE TABLE t1, t2, t3, t4; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +test.t4 analyze status OK +explain SELECT * +FROM t4 +WHERE (col_int_key) IN ( +SELECT t1.col_int_key +FROM t1 LEFT JOIN ( t2 JOIN t3 ON t3.col_int_key = t2.col_int ) USING ( pk ) +WHERE t3.col_int IS NULL +) +ORDER BY col_int_key +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 6 100.00 Parallel execute (1 workers) +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 6 100.00 Using where; Using filesort +2 SIMPLE t1 NULL ref col_int_key col_int_key 5 test.t4.col_int_key 1 100.00 Using index; Start temporary +2 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.pk 1 100.00 NULL +2 SIMPLE t3 NULL ALL col_int_key NULL NULL NULL 4 25.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`col_int_key` AS `col_int_key` from `test`.`t4` semi join (`test`.`t1` left join (`test`.`t2` join `test`.`t3`) on(((`test`.`t1`.`pk` = `test`.`t2`.`pk`) and (`test`.`t3`.`col_int_key` = `test`.`t2`.`col_int`)))) where ((`test`.`t1`.`col_int_key` = `test`.`t4`.`col_int_key`) and (`test`.`t3`.`col_int` is null)) order by `test`.`t4`.`col_int_key` +explain format=tree SELECT * +FROM t4 +WHERE (col_int_key) IN ( +SELECT t1.col_int_key +FROM t1 LEFT JOIN ( t2 JOIN t3 ON t3.col_int_key = t2.col_int ) USING ( pk ) +WHERE t3.col_int IS NULL +) +ORDER BY col_int_key +; +EXPLAIN +-> Parallel scan on + -> Nested loop inner join (cost=3.05 rows=7) + -> Sort: t4.col_int_key (cost=0.85 rows=6) + -> Filter: (t4.col_int_key is not null) + -> PQblock scan on t4 + -> Limit: 1 row(s) (cost=2.14 rows=1) + -> Filter: (t3.col_int is null) (cost=2.14 rows=1) + -> Nested loop left join (cost=2.14 rows=1) + -> Index lookup on t1 using col_int_key (col_int_key=t4.col_int_key) (cost=0.27 rows=1) + -> Nested loop inner join (cost=1.21 rows=1) + -> Single-row index lookup on t2 using PRIMARY (pk=t1.pk) (cost=0.26 rows=1) + -> Filter: (t3.col_int_key = t2.col_int) (cost=0.11 rows=1) + -> Table scan on t3 (cost=0.11 rows=4) + +SELECT * +FROM t4 +WHERE (col_int_key) IN ( +SELECT t1.col_int_key +FROM t1 LEFT JOIN ( t2 JOIN t3 ON t3.col_int_key = t2.col_int ) USING ( pk ) +WHERE t3.col_int IS NULL +) +ORDER BY col_int_key +; +col_int_key +0 +3 +8 +900000000 +1368719360 +1922236416 +DROP TABLE t1, t2, t3, t4; +# +# Bug#20835095 CRASH AT CREATE_REF_FOR_KEY IN SQL/SQL_SELECT.CC +# +CREATE TABLE t1 ( +pk INTEGER, +var_10_latin1 VARCHAR(10) CHARACTER SET latin1, +var_255_utf8 VARCHAR(255) CHARACTER SET utf8, +var_255_latin1 VARCHAR(255) CHARACTER SET latin1, +var_10_utf8 VARCHAR(10) CHARACTER SET utf8, +PRIMARY KEY (pk) +); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +CREATE VIEW v1 AS SELECT * FROM t1; +INSERT INTO t1 VALUES +(1,'FROCJ','korrhrspki','UAYVL','BPZIS'), +(2,'him','a','CHYKN','OZZQT'), +(3,'WBITK','ULWBF','have','rhrh'), +(4,'or','right','up','it'), +(5,'GGDCP','x','who','as'), +(6,'j','i','e','w'); +CREATE TABLE tv +SELECT var_255_utf8 AS field1 +FROM t1; +EXPLAIN SELECT * FROM tv +WHERE field1 IN ( +SELECT tv1.var_255_utf8 +FROM v1 AS tv1 LEFT JOIN v1 AS tv2 ON tv1.var_10_latin1=tv2.var_10_utf8); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE tv NULL ALL NULL NULL NULL NULL 6 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 6 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`tv`.`field1` AS `field1` from `test`.`tv` semi join (`test`.`t1` left join (`test`.`t1`) on((`test`.`t1`.`var_10_latin1` = `test`.`t1`.`var_10_utf8`))) where (`test`.`t1`.`var_255_utf8` = `test`.`tv`.`field1`) +SELECT * FROM tv +WHERE field1 IN ( +SELECT tv1.var_255_utf8 +FROM v1 AS tv1 LEFT JOIN v1 AS tv2 ON tv1.var_10_latin1=tv2.var_10_utf8); +field1 +korrhrspki +a +ULWBF +right +x +i +DROP VIEW v1; +DROP TABLE t1, tv; +# 17832047 Crash in calculate_materialization_costs +CREATE TABLE t1(a INTEGER PRIMARY KEY); +INSERT INTO t1 VALUES (0),(1),(2); +SELECT 1 FROM t1 +WHERE 1 IN +(SELECT 1 BETWEEN (LENGTH(a) IN (SELECT 1 FROM t1)) AND 1 +FROM t1 +); +1 +1 +1 +1 +DROP TABLE t1; +# 17845989 Assertion failed: !(used_tables() & ... +CREATE TABLE a(b INTEGER) engine=innodb; +CREATE TABLE c(a INTEGER) engine=innodb; +SELECT 1 +FROM a +WHERE 1 IN (SELECT (a.b IS NULL) IN (SELECT 1 FROM c) FROM c) +; +1 +DROP TABLE a, c; +# +# Bug#18194196: OPTIMIZER EXECUTES STATEMENT INPERFORMANT +# +CREATE TABLE t1 (uid INTEGER, fid INTEGER, INDEX(uid)); +INSERT INTO t1 VALUES +(1,1), (1,2), (1,3), (1,4), +(2,5), (2,6), (2,7), (2,8), +(3,1), (3,2), (3,9); +CREATE TABLE t2 (uid INT PRIMARY KEY, name VARCHAR(128), INDEX(name)); +INSERT INTO t2 VALUES +(1, "A"), (2, "B"), (3, "C"), (4, "D"), (5, "E"), +(6, "F"), (7, "G"), (8, "H"), (9, "I"); +CREATE TABLE t3 (uid INT, fid INT, INDEX(uid)); +INSERT INTO t3 VALUES +(1,1), (1,2), (1,3),(1,4), +(2,5), (2,6), (2,7), (2,8), +(3,1), (3,2), (3,9); +CREATE TABLE t4 (uid INT PRIMARY KEY, name VARCHAR(128), INDEX(name)); +INSERT INTO t4 VALUES +(1, "A"), (2, "B"), (3, "C"), (4, "D"), (5, "E"), +(6, "F"), (7, "G"), (8, "H"), (9, "I"); +ANALYZE TABLE t1,t2,t3,t4; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +test.t4 analyze status OK +EXPLAIN SELECT name FROM t2, t1 +WHERE t1.uid IN (SELECT t4.uid FROM t4, t3 WHERE t3.uid=1 AND t4.uid=t3.fid) +AND t2.uid=t1.fid; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ref uid uid 5 const 4 100.00 Using where; Start temporary +1 SIMPLE t4 NULL eq_ref PRIMARY PRIMARY 4 test.t3.fid 1 100.00 Using index +1 SIMPLE t1 NULL ref uid uid 5 test.t3.fid 4 100.00 Using where +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.fid 1 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`name` AS `name` from `test`.`t4` join `test`.`t2` join `test`.`t1` semi join (`test`.`t3`) where ((`test`.`t4`.`uid` = `test`.`t3`.`fid`) and (`test`.`t1`.`uid` = `test`.`t3`.`fid`) and (`test`.`t3`.`uid` = 1) and (`test`.`t2`.`uid` = `test`.`t1`.`fid`)) +FLUSH STATUS; +SELECT name FROM t2, t1 +WHERE t1.uid IN (SELECT t4.uid FROM t4, t3 WHERE t3.uid=1 AND t4.uid=t3.fid) +AND t2.uid=t1.fid; +name +A +A +B +B +C +D +E +F +G +H +I +SHOW STATUS LIKE '%handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 20 +Handler_read_last 0 +Handler_read_next 15 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +DROP TABLE t1,t2,t3,t4; +# End of test for Bug#18194196 +# +# Bug#21184091 ASSERT `READ_ROWS >= 0.0' AT +# COST_MODEL_SERVER::TMPTABLE_READWRITE_COST() +# +CREATE TABLE t1 ( +pk INTEGER, +col_varchar varchar(1), +col_int INTEGER, +PRIMARY KEY (pk) +) ENGINE=MyISAM; +CREATE TABLE t2 ( +col_int INTEGER, +col_varchar varchar(1) +) ENGINE=MyISAM; +INSERT INTO t2 VALUES (7,'x'); +INSERT INTO t2 VALUES (4,'z'); +SELECT t2.col_varchar +FROM t2 STRAIGHT_JOIN t1 ON t2.col_varchar = t1.col_varchar +JOIN t2 AS table3 ON t1.pk = table3.col_int +WHERE t1.pk IN (SELECT col_int FROM t1); +col_varchar +DROP TABLE t1,t2; +# End of test for Bug#21184091 +# Bug#21139722: Assertion failed: !(used_tables() & ((table_map) 1) ... +CREATE TABLE t1(a INTEGER) engine=innodb; +CREATE TABLE t2(b INTEGER) engine=innodb; +explain SELECT 1 +FROM (SELECT 1 IN (SELECT 1 +FROM t1 +WHERE (SELECT 1 FROM t2 HAVING b) NOT IN (SELECT 1 FROM t2) +) +FROM t2 +) AS z; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DERIVED t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +3 DEPENDENT SUBQUERY t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +5 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +4 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1276 Field or reference 'b' of SELECT #4 was resolved in SELECT #2 +Note 1003 /* select#1 */ select 1 AS `1` from (/* select#2 */ select (1,(/* select#3 */ select 1 from `test`.`t1` where ((/* select#4 */ select 1 from `test`.`t2` having (0 <> `test`.`t2`.`b`)),(/* select#5 */ select 1 from `test`.`t2` where (outer_field_is_not_null, (((/* select#4 */ select 1 from `test`.`t2` having (0 <> `test`.`t2`.`b`))) = 1), true)) is false))) AS `1 IN (SELECT 1 +FROM t1 +WHERE (SELECT 1 FROM t2 HAVING b) NOT IN (SELECT 1 FROM t2) +)` from `test`.`t2`) `z` +SELECT 1 +FROM (SELECT 1 IN (SELECT 1 +FROM t1 +WHERE (SELECT 1 FROM t2 HAVING b) NOT IN (SELECT 1 FROM t2) +) +FROM t2 +) AS z; +1 +DROP TABLE t1, t2; +CREATE TABLE t1(a INTEGER) engine=innodb; +explain SELECT (SELECT a FROM t1 AS t2 +WHERE a IN (SELECT t1.a+t2.a FROM t1 AS t3)) +FROM t1 AS t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +2 DEPENDENT SUBQUERY t3 NULL ALL NULL NULL NULL NULL 1 100.00 End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #3 was resolved in SELECT #1 +Note 1276 Field or reference 'test.t2.a' of SELECT #3 was resolved in SELECT #2 +Note 1003 /* select#1 */ select (/* select#2 */ select `test`.`t2`.`a` from `test`.`t1` `t2` semi join (`test`.`t1` `t3`) where (`test`.`t2`.`a` = (`test`.`t1`.`a` + `test`.`t2`.`a`))) AS `(SELECT a FROM t1 AS t2 +WHERE a IN (SELECT t1.a+t2.a FROM t1 AS t3))` from `test`.`t1` +SELECT (SELECT a FROM t1 AS t2 +WHERE a IN (SELECT t1.a+t2.a FROM t1 AS t3)) +FROM t1 AS t1; +(SELECT a FROM t1 AS t2 +WHERE a IN (SELECT t1.a+t2.a FROM t1 AS t3)) +DROP TABLE t1; +# End of test for Bug#21139722 +SET DEFAULT_STORAGE_ENGINE=INNODB; +# +# Bug#21139402 ASSERTION FAILED: LENGTH > 0 && KEYPARTS != 0, CRASH IN JOIN::OPTIMIZE_KEYUSE +# +CREATE TABLE t1 (a INT, b INT, PRIMARY KEY(a)); +CREATE TABLE t2 (c INT PRIMARY KEY); +EXPLAIN SELECT 1 FROM t1 +WHERE 1 IN +(SELECT (c IS NULL) IN (SELECT a FROM t1 WHERE b) FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +3 SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` semi join (`test`.`t2`) where false +SELECT 1 FROM t1 +WHERE 1 IN +(SELECT (c IS NULL) IN (SELECT a FROM t1 WHERE b) FROM t2); +1 +DROP TABLE t1,t2; +# +# Bug#21619634 ACCESS OF DEALLOCATED ITEM_OUTER_REF CAUSES CRASH: PREPARED STMT +# +create table cc (i int) engine="innodb"; +insert into cc values (1); +select (select count(i) from cc as cc_alias +where (cc.i in (select cc_alias.i from cc))) +from cc group by i; +(select count(i) from cc as cc_alias +where (cc.i in (select cc_alias.i from cc))) +1 +prepare stmt from +"select (select count(i) from cc as cc_alias + where (cc.i in (select cc_alias.i from cc))) + from cc group by i"; +execute stmt; +(select count(i) from cc as cc_alias + where (cc.i in (select cc_alias.i from cc))) +1 +execute stmt; +(select count(i) from cc as cc_alias + where (cc.i in (select cc_alias.i from cc))) +1 +drop table cc; +# +# Bug #22305361: QUERY WITH MATERIALIZED TABLE RETURNS INCORRECT +# RESULTS IN 5.6 +# +CREATE TABLE t(a INT,b INT); +INSERT INTO t VALUES (1,0),(1,0),(1,0),(1,0),(1,1); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +EXPLAIN SELECT * +FROM t AS t1 +WHERE t1.a IN (SELECT t2.a +FROM t AS t2 +WHERE CONCAT(t2.a,'') NOT IN (SELECT t3.a +FROM t AS t3 +WHERE t3.b=1)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 5 100.00 Start temporary +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 5 20.00 Using where; End temporary; Using join buffer (hash join) +3 DEPENDENT SUBQUERY t3 NULL ALL NULL NULL NULL NULL 5 20.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t` `t1` semi join (`test`.`t` `t2`) where ((`test`.`t2`.`a` = `test`.`t1`.`a`) and (concat(`test`.`t1`.`a`,''),(/* select#3 */ select `test`.`t3`.`a` from `test`.`t` `t3` where ((`test`.`t3`.`b` = 1) and (outer_field_is_not_null, (((concat(`test`.`t1`.`a`,'')) = `test`.`t3`.`a`) or (`test`.`t3`.`a` is null)), true)) having (outer_field_is_not_null, (`test`.`t3`.`a`), true)) is false)) +SELECT * +FROM t AS t1 +WHERE t1.a IN (SELECT t2.a +FROM t AS t2 +WHERE CONCAT(t2.a,'') NOT IN (SELECT t3.a +FROM t AS t3 +WHERE t3.b=1)); +a b +DROP TABLE t; +# +# Bug#24287772 SUBQUERY RETURNS EMPTY LIST WHILE IDENTICAL QUERY +# WITH JOIN RETURNS RESULT +# +CREATE TABLE t SELECT 4096 c; +SELECT c FROM t WHERE 1 IN +(SELECT t.c = page_size FROM information_schema.innodb_cmpmem); +c +4096 +DROP TABLE t; +# +# Bug #29132639: WL#12470: SIG 6 IN CONNECTJOINS|SQL/SQL_EXECUTOR.C +# +CREATE TABLE t1 ( f1 TIME, f2 VARCHAR(1) ); +INSERT INTO t1 VALUES ('08:35:24', 'X'), ('14:51:13', 'S'), ('11:22:33', 'Q'); +CREATE TABLE t2 ( pk INTEGER ); +INSERT INTO t2 VALUES (1), (2); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN FORMAT=tree SELECT * FROM t1 WHERE EXISTS ( SELECT alias1.f2 FROM t2 LEFT JOIN t1 ON 1 LEFT JOIN t1 AS alias1 ON 1 ); +EXPLAIN +-> Remove duplicate t1 rows using temporary table (weedout) (cost=6.20 rows=54) + -> Left hash join (no condition) (cost=6.20 rows=54) + -> Left hash join (no condition) (cost=2.14 rows=18) + -> Inner hash join (no condition) (cost=1.30 rows=6) + -> Table scan on t1 (cost=0.28 rows=3) + -> Hash + -> Table scan on t2 (cost=0.45 rows=2) + -> Hash + -> Table scan on t1 (cost=0.09 rows=3) + -> Hash + -> Table scan on alias1 (cost=0.55 rows=3) + +SELECT * FROM t1 WHERE EXISTS ( SELECT alias1.f2 FROM t2 LEFT JOIN t1 ON 1 LEFT JOIN t1 AS alias1 ON 1 ); +f1 f2 +08:35:24 X +11:22:33 Q +14:51:13 S +DROP TABLE t1, t2; +set optimizer_switch=default; diff --git a/mysql-test/r/subquery_sj_dupsweed_bka.result-pq b/mysql-test/r/subquery_sj_dupsweed_bka.result-pq new file mode 100644 index 000000000000..b74503b904c0 --- /dev/null +++ b/mysql-test/r/subquery_sj_dupsweed_bka.result-pq @@ -0,0 +1,12921 @@ +set optimizer_switch='batched_key_access=on,mrr_cost_based=off'; +set @old_opt_switch=@@optimizer_switch; +set optimizer_switch='subquery_materialization_cost_based=off'; +drop table if exists t0, t1, t2, t10, t11, t12; +create table t1 (a int not null, b int, primary key (a)); +create table t2 (a int not null, primary key (a)); +create table t3 (a int not null, b int, primary key (a)); +insert into t1 values (1,10), (2,20), (3,30), (4,40); +insert into t2 values (2), (3), (4), (5); +insert into t3 values (10,3), (20,4), (30,5); +select * from t2 where t2.a in (select a from t1); +a +2 +3 +4 +explain select * from t2 where t2.a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index PRIMARY PRIMARY 4 NULL 4 100.00 Using index +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t1` join `test`.`t2` where (`test`.`t1`.`a` = `test`.`t2`.`a`) +select * from t2 where t2.a in (select a from t1 where t1.b <> 30); +a +2 +4 +explain select * from t2 where t2.a in (select a from t1 where t1.b <> 30); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL PRIMARY NULL NULL NULL 4 75.00 Using where +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`a` = `test`.`t1`.`a`) and (`test`.`t1`.`b` <> 30)) +select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a); +a +2 +3 +explain select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL index PRIMARY PRIMARY 4 NULL 3 100.00 Using index +1 SIMPLE t1 NULL ALL PRIMARY NULL NULL NULL 4 25.00 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t1` join `test`.`t3` join `test`.`t2` where ((`test`.`t2`.`a` = `test`.`t1`.`a`) and (`test`.`t1`.`b` = `test`.`t3`.`a`)) +drop table t1, t2, t3; +create table t1 (a int, b int, index a (a,b)); +create table t2 (a int, index a (a)); +create table t3 (a int, b int, index a (a)); +insert into t1 values (1,10), (2,20), (3,30), (4,40); +create table t0(a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +insert into t1 +select rand()*100000+200,rand()*100000 from t0 A, t0 B, t0 C, t0 D; +insert into t2 values (2), (3), (4), (5); +insert into t3 values (10,3), (20,4), (30,5); +select * from t2 where t2.a in (select a from t1); +a +2 +3 +4 +explain select * from t2 where t2.a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index a a 5 NULL 4 100.00 Using where; Using index +1 SIMPLE t1 NULL ref a a 5 test.t2.a 101 100.00 Using index; Start temporary; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1`) where (`test`.`t1`.`a` = `test`.`t2`.`a`) +select * from t2 where t2.a in (select a from t1 where t1.b <> 30); +a +2 +4 +explain select * from t2 where t2.a in (select a from t1 where t1.b <> 30); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index a a 5 NULL 4 100.00 Using where; Using index +1 SIMPLE t1 NULL ref a a 5 test.t2.a 101 90.00 Using where; Using index; Start temporary; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1`) where ((`test`.`t1`.`a` = `test`.`t2`.`a`) and (`test`.`t1`.`b` <> 30)) +select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a); +a +2 +3 +explain select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index a a 5 NULL 4 100.00 Using where; Using index; Start temporary +1 SIMPLE t1 NULL ref a a 5 test.t2.a 101 100.00 Using index +1 SIMPLE t3 NULL index a a 5 NULL 3 33.33 Using where; Using index; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1` join `test`.`t3`) where ((`test`.`t1`.`a` = `test`.`t2`.`a`) and (`test`.`t3`.`a` = `test`.`t1`.`b`)) +insert into t1 values (3,31); +select * from t2 where t2.a in (select a from t1 where t1.b <> 30); +a +2 +3 +4 +select * from t2 where t2.a in (select a from t1 where t1.b <> 30 and t1.b <> 31); +a +2 +4 +explain select * from t2 where t2.a in (select a from t1 where t1.b <> 30); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index a a 5 NULL 4 100.00 Using where; Using index +1 SIMPLE t1 NULL ref a a 5 test.t2.a 101 90.00 Using where; Using index; Start temporary; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1`) where ((`test`.`t1`.`a` = `test`.`t2`.`a`) and (`test`.`t1`.`b` <> 30)) +drop table t0, t1, t2, t3; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1(a int, b int); +insert into t1 values (0,0),(1,1),(2,2); +create table t2 as select * from t1; +create table t11(a int, b int); +create table t10 (pk int, a int, primary key(pk)); +insert into t10 select a,a from t0; +create table t12 like t10; +insert into t12 select * from t10; +Flattened because of dependency, t10=func(t1) +explain select * from t1 where a in (select pk from t10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t1` where (`test`.`t10`.`pk` = `test`.`t1`.`a`) +select * from t1 where a in (select pk from t10); +a b +0 0 +1 1 +2 2 +A confluent case of dependency +explain select * from t1 where a in (select a from t10 where pk=12); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t1` where (multiple equal(12, NULL) and multiple equal(`test`.`t1`.`a`, NULL)) +select * from t1 where a in (select a from t10 where pk=12); +a b +explain select * from t1 where a in (select a from t10 where pk=9); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t10 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t1` where ((`test`.`t1`.`a` = '9')) +select * from t1 where a in (select a from t10 where pk=9); +a b +An empty table inside +explain select * from t1 where a in (select a from t11); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t11 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t11`) where (`test`.`t1`.`a` = `test`.`t11`.`a`) +select * from t1 where a in (select a from t11); +a b +explain select * from t1 where a in (select pk from t10) and b in (select pk from t10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using index +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.t1.b 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t10` join `test`.`t1` where ((`test`.`t10`.`pk` = `test`.`t1`.`b`) and (`test`.`t10`.`pk` = `test`.`t1`.`a`)) +select * from t1 where a in (select pk from t10) and b in (select pk from t10); +a b +0 0 +1 1 +2 2 +flattening a nested subquery +explain select * from t1 where a in (select pk from t10 where t10.a in (select pk from t12)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using where +1 SIMPLE t12 NULL eq_ref PRIMARY PRIMARY 4 test.t10.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t12` join `test`.`t1` where ((`test`.`t10`.`pk` = `test`.`t1`.`a`) and (`test`.`t12`.`pk` = `test`.`t10`.`a`)) +select * from t1 where a in (select pk from t10 where t10.a in (select pk from t12)); +a b +0 0 +1 1 +2 2 +flattening subquery w/ several tables +explain select * from t1 where a in (select t10.pk from t10, t12 where t12.pk=t10.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using where +1 SIMPLE t12 NULL eq_ref PRIMARY PRIMARY 4 test.t10.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t12` join `test`.`t1` where ((`test`.`t10`.`pk` = `test`.`t1`.`a`) and (`test`.`t12`.`pk` = `test`.`t10`.`a`)) +subqueries within outer joins go into ON expr. +explain +select * from t1 left join (t2 A, t2 B) on ( A.A= t1.A and B.A in (select pk from t10)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE A NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE B NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.B.A 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`A` AS `A`,`test`.`t1`.`B` AS `B`,`test`.`A`.`A` AS `A`,`test`.`A`.`B` AS `B`,`test`.`B`.`A` AS `A`,`test`.`B`.`B` AS `B` from `test`.`t1` left join (`test`.`t10` join `test`.`t2` `A` join `test`.`t2` `B`) on(((`test`.`t10`.`pk` = `test`.`B`.`A`) and (`test`.`A`.`A` = `test`.`t1`.`A`))) where true +t2 should be wrapped into OJ-nest, so we have "t1 LJ (t2 J t10)" +explain +select * from t1 left join t2 on (t2.A= t1.A and t2.A in (select pk from t10)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.t1.A 1 100.00 Using index +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`A` AS `A`,`test`.`t1`.`B` AS `B`,`test`.`t2`.`A` AS `A`,`test`.`t2`.`B` AS `B` from `test`.`t1` left join (`test`.`t10` join `test`.`t2`) on(((`test`.`t10`.`pk` = `test`.`t1`.`A`) and (`test`.`t2`.`A` = `test`.`t1`.`A`))) where true +we shouldn't flatten if we're going to get a join of > MAX_TABLES. +explain select * from +t1 s00, t1 s01, t1 s02, t1 s03, t1 s04,t1 s05,t1 s06,t1 s07,t1 s08,t1 s09, +t1 s10, t1 s11, t1 s12, t1 s13, t1 s14,t1 s15,t1 s16,t1 s17,t1 s18,t1 s19, +t1 s20, t1 s21, t1 s22, t1 s23, t1 s24,t1 s25,t1 s26,t1 s27,t1 s28,t1 s29, +t1 s30, t1 s31, t1 s32, t1 s33, t1 s34,t1 s35,t1 s36,t1 s37,t1 s38,t1 s39, +t1 s40, t1 s41, t1 s42, t1 s43, t1 s44,t1 s45,t1 s46,t1 s47,t1 s48,t1 s49 +where +s00.a in ( +select m00.a from +t1 m00, t1 m01, t1 m02, t1 m03, t1 m04,t1 m05,t1 m06,t1 m07,t1 m08,t1 m09, +t1 m10, t1 m11, t1 m12, t1 m13, t1 m14,t1 m15,t1 m16,t1 m17,t1 m18,t1 m19 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY s00 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 PRIMARY s01 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s02 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s03 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s04 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s05 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s06 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s07 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s08 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s09 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s10 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s11 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s12 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s13 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s14 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s15 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s16 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s17 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s18 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s19 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s20 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s21 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s22 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s23 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s24 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s25 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s26 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s27 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s28 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s29 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s30 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s31 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s32 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s33 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s34 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s35 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s36 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s37 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s38 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s39 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s40 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s41 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s42 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s43 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s44 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s45 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s46 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s47 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s48 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s49 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m00 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +2 DEPENDENT SUBQUERY m01 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m02 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m03 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m04 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m05 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m06 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m07 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m08 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m09 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m10 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m11 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m12 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m13 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m14 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m15 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m16 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m17 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m18 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m19 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`s00`.`a` AS `a`,`test`.`s00`.`b` AS `b`,`test`.`s01`.`a` AS `a`,`test`.`s01`.`b` AS `b`,`test`.`s02`.`a` AS `a`,`test`.`s02`.`b` AS `b`,`test`.`s03`.`a` AS `a`,`test`.`s03`.`b` AS `b`,`test`.`s04`.`a` AS `a`,`test`.`s04`.`b` AS `b`,`test`.`s05`.`a` AS `a`,`test`.`s05`.`b` AS `b`,`test`.`s06`.`a` AS `a`,`test`.`s06`.`b` AS `b`,`test`.`s07`.`a` AS `a`,`test`.`s07`.`b` AS `b`,`test`.`s08`.`a` AS `a`,`test`.`s08`.`b` AS `b`,`test`.`s09`.`a` AS `a`,`test`.`s09`.`b` AS `b`,`test`.`s10`.`a` AS `a`,`test`.`s10`.`b` AS `b`,`test`.`s11`.`a` AS `a`,`test`.`s11`.`b` AS `b`,`test`.`s12`.`a` AS `a`,`test`.`s12`.`b` AS `b`,`test`.`s13`.`a` AS `a`,`test`.`s13`.`b` AS `b`,`test`.`s14`.`a` AS `a`,`test`.`s14`.`b` AS `b`,`test`.`s15`.`a` AS `a`,`test`.`s15`.`b` AS `b`,`test`.`s16`.`a` AS `a`,`test`.`s16`.`b` AS `b`,`test`.`s17`.`a` AS `a`,`test`.`s17`.`b` AS `b`,`test`.`s18`.`a` AS `a`,`test`.`s18`.`b` AS `b`,`test`.`s19`.`a` AS `a`,`test`.`s19`.`b` AS `b`,`test`.`s20`.`a` AS `a`,`test`.`s20`.`b` AS `b`,`test`.`s21`.`a` AS `a`,`test`.`s21`.`b` AS `b`,`test`.`s22`.`a` AS `a`,`test`.`s22`.`b` AS `b`,`test`.`s23`.`a` AS `a`,`test`.`s23`.`b` AS `b`,`test`.`s24`.`a` AS `a`,`test`.`s24`.`b` AS `b`,`test`.`s25`.`a` AS `a`,`test`.`s25`.`b` AS `b`,`test`.`s26`.`a` AS `a`,`test`.`s26`.`b` AS `b`,`test`.`s27`.`a` AS `a`,`test`.`s27`.`b` AS `b`,`test`.`s28`.`a` AS `a`,`test`.`s28`.`b` AS `b`,`test`.`s29`.`a` AS `a`,`test`.`s29`.`b` AS `b`,`test`.`s30`.`a` AS `a`,`test`.`s30`.`b` AS `b`,`test`.`s31`.`a` AS `a`,`test`.`s31`.`b` AS `b`,`test`.`s32`.`a` AS `a`,`test`.`s32`.`b` AS `b`,`test`.`s33`.`a` AS `a`,`test`.`s33`.`b` AS `b`,`test`.`s34`.`a` AS `a`,`test`.`s34`.`b` AS `b`,`test`.`s35`.`a` AS `a`,`test`.`s35`.`b` AS `b`,`test`.`s36`.`a` AS `a`,`test`.`s36`.`b` AS `b`,`test`.`s37`.`a` AS `a`,`test`.`s37`.`b` AS `b`,`test`.`s38`.`a` AS `a`,`test`.`s38`.`b` AS `b`,`test`.`s39`.`a` AS `a`,`test`.`s39`.`b` AS `b`,`test`.`s40`.`a` AS `a`,`test`.`s40`.`b` AS `b`,`test`.`s41`.`a` AS `a`,`test`.`s41`.`b` AS `b`,`test`.`s42`.`a` AS `a`,`test`.`s42`.`b` AS `b`,`test`.`s43`.`a` AS `a`,`test`.`s43`.`b` AS `b`,`test`.`s44`.`a` AS `a`,`test`.`s44`.`b` AS `b`,`test`.`s45`.`a` AS `a`,`test`.`s45`.`b` AS `b`,`test`.`s46`.`a` AS `a`,`test`.`s46`.`b` AS `b`,`test`.`s47`.`a` AS `a`,`test`.`s47`.`b` AS `b`,`test`.`s48`.`a` AS `a`,`test`.`s48`.`b` AS `b`,`test`.`s49`.`a` AS `a`,`test`.`s49`.`b` AS `b` from `test`.`t1` `s00` join `test`.`t1` `s01` join `test`.`t1` `s02` join `test`.`t1` `s03` join `test`.`t1` `s04` join `test`.`t1` `s05` join `test`.`t1` `s06` join `test`.`t1` `s07` join `test`.`t1` `s08` join `test`.`t1` `s09` join `test`.`t1` `s10` join `test`.`t1` `s11` join `test`.`t1` `s12` join `test`.`t1` `s13` join `test`.`t1` `s14` join `test`.`t1` `s15` join `test`.`t1` `s16` join `test`.`t1` `s17` join `test`.`t1` `s18` join `test`.`t1` `s19` join `test`.`t1` `s20` join `test`.`t1` `s21` join `test`.`t1` `s22` join `test`.`t1` `s23` join `test`.`t1` `s24` join `test`.`t1` `s25` join `test`.`t1` `s26` join `test`.`t1` `s27` join `test`.`t1` `s28` join `test`.`t1` `s29` join `test`.`t1` `s30` join `test`.`t1` `s31` join `test`.`t1` `s32` join `test`.`t1` `s33` join `test`.`t1` `s34` join `test`.`t1` `s35` join `test`.`t1` `s36` join `test`.`t1` `s37` join `test`.`t1` `s38` join `test`.`t1` `s39` join `test`.`t1` `s40` join `test`.`t1` `s41` join `test`.`t1` `s42` join `test`.`t1` `s43` join `test`.`t1` `s44` join `test`.`t1` `s45` join `test`.`t1` `s46` join `test`.`t1` `s47` join `test`.`t1` `s48` join `test`.`t1` `s49` where (`test`.`s00`.`a`,(/* select#2 */ select `test`.`m00`.`a` from `test`.`t1` `m00` join `test`.`t1` `m01` join `test`.`t1` `m02` join `test`.`t1` `m03` join `test`.`t1` `m04` join `test`.`t1` `m05` join `test`.`t1` `m06` join `test`.`t1` `m07` join `test`.`t1` `m08` join `test`.`t1` `m09` join `test`.`t1` `m10` join `test`.`t1` `m11` join `test`.`t1` `m12` join `test`.`t1` `m13` join `test`.`t1` `m14` join `test`.`t1` `m15` join `test`.`t1` `m16` join `test`.`t1` `m17` join `test`.`t1` `m18` join `test`.`t1` `m19` where ((`test`.`s00`.`a`) = `test`.`m00`.`a`))) +select * from +t1 left join t2 on (t2.a= t1.a and t2.a in (select pk from t10)) +where t1.a < 5; +a b a b +0 0 0 0 +1 1 1 1 +2 2 2 2 +prepare s1 from +' select * from + t1 left join t2 on (t2.a= t1.a and t2.a in (select pk from t10)) + where t1.a < 5'; +execute s1; +a b a b +0 0 0 0 +1 1 1 1 +2 2 2 2 +execute s1; +a b a b +0 0 0 0 +1 1 1 1 +2 2 2 2 +insert into t1 select (A.a + 10 * B.a),1 from t0 A, t0 B; +explain select * from t1 where a in (select pk from t10 where pk<3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t10 NULL range PRIMARY PRIMARY 4 NULL 4 100.00 Using where; Using index +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 103 10.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t1` where ((`test`.`t1`.`a` = `test`.`t10`.`pk`) and (`test`.`t10`.`pk` < 3)) +drop table t0, t1, t2; +drop table t10, t11, t12; +# +# Check that subqueries with outer joins or straight_join work for +# different permutations of const and non-const tables. (Ref. Bug#46692) +# +CREATE TABLE t1 (i INTEGER); +CREATE TABLE t2 (i INTEGER); +CREATE TABLE t3 (i INTEGER); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 0 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 0 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 0 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 1 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 1 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 1 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 2 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 2 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 2 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (0); +DELETE FROM t2; +INSERT INTO t1 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 0 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 0 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 0 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 1 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 1 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 1 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 2 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 2 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 2 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (0); +DELETE FROM t2; +INSERT INTO t1 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 0 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = `test`.`t2`.`i`) and (`test`.`t1`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = `test`.`t2`.`i`) and (`test`.`t1`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = `test`.`t2`.`i`) and (`test`.`t1`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 0 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = `test`.`t2`.`i`) and (`test`.`t1`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = `test`.`t2`.`i`) and (`test`.`t1`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = `test`.`t2`.`i`) and (`test`.`t1`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 0 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t2`.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t2`.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t2`.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = `test`.`t1`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +1 +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = `test`.`t1`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 1 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = `test`.`t3`.`i`) and (`test`.`t1`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = `test`.`t3`.`i`) and (`test`.`t1`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = `test`.`t3`.`i`) and (`test`.`t1`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 1 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = `test`.`t2`.`i`) and (`test`.`t1`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = `test`.`t2`.`i`) and (`test`.`t1`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = `test`.`t2`.`i`) and (`test`.`t1`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 1 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t2`.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t2`.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t2`.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = `test`.`t1`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +1 +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = `test`.`t1`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +1 +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 2 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t3`.`i`) and (`test`.`t2`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t3`.`i`) and (`test`.`t2`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t3`.`i`) and (`test`.`t2`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = `test`.`t1`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 2 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t3`.`i`) and (`test`.`t2`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t3`.`i`) and (`test`.`t2`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t3`.`i`) and (`test`.`t2`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = `test`.`t1`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 2 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = `test`.`t1`.`i`) and (`test`.`t3`.`i` = `test`.`t1`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +1 +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +1 +2 + +EXECUTE stmt; +i +1 +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = `test`.`t1`.`i`) and (`test`.`t3`.`i` = `test`.`t1`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +1 +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = `test`.`t1`.`i`) and (`test`.`t3`.`i` = `test`.`t1`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +1 +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +1 +2 + +EXECUTE stmt; +i +1 +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = `test`.`t1`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +1 +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = `test`.`t1`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +1 +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (0); +DELETE FROM t2; +INSERT INTO t1 VALUES (0); +DROP TABLE t1, t2, t3; +create table x1(k int primary key, d1 int, d2 int); +create table x2(k int primary key, d1 int, d2 int); +insert into x1 values +(10, 10, 10), +(20, 20, 20), +(21, 20, null), +(30, null, 30), +(40, 40, 40); +insert into x2 values +(10, 10, 10), +(20, 20, 20), +(21, 20, null), +(30, null, 30); +select * +from x1 +where (d1, d2) in (select d1, d2 +from x2); +k d1 d2 +10 10 10 +20 20 20 +select * +from x1 +where (d1, d2) in (select d1, d2 +from x2) is true; +k d1 d2 +10 10 10 +20 20 20 +select * +from x1 +where (d1, d2) in (select d1, d2 +from x2) is false; +k d1 d2 +40 40 40 +select * +from x1 +where (d1, d2) in (select d1, d2 +from x2) is unknown; +k d1 d2 +21 20 NULL +30 NULL 30 +select * +from x1 +where d1 in (select d1 +from x2 +where x1.d2=x2.d2); +k d1 d2 +10 10 10 +20 20 20 +select * +from x1 +where d1 in (select d1 +from x2 +where x1.d2=x2.d2) is true; +k d1 d2 +10 10 10 +20 20 20 +select * +from x1 +where d1 in (select d1 +from x2 +where x1.d2=x2.d2) is false; +k d1 d2 +21 20 NULL +40 40 40 +select * +from x1 +where d1 in (select d1 +from x2 +where x1.d2=x2.d2) is unknown; +k d1 d2 +30 NULL 30 +select * +from x1 +where 1 in (select 1 +from x2 +where x1.d1=x2.d1 and x1.d2=x2.d2); +k d1 d2 +10 10 10 +20 20 20 +select * +from x1 +where 1 in (select 1 +from x2 +where x1.d1=x2.d1 and x1.d2=x2.d2) is true; +k d1 d2 +10 10 10 +20 20 20 +select * +from x1 +where 1 in (select 1 +from x2 +where x1.d1=x2.d1 and x1.d2=x2.d2) is false; +k d1 d2 +21 20 NULL +30 NULL 30 +40 40 40 +select * +from x1 +where 1 in (select 1 +from x2 +where x1.d1=x2.d1 and x1.d2=x2.d2) is unknown; +k d1 d2 +select * +from x1 +where exists (select * +from x2 +where x1.d1=x2.d1 and x1.d2=x2.d2); +k d1 d2 +10 10 10 +20 20 20 +drop table x1; +drop table x2; +CREATE TABLE t1 ( +a int(11) NOT NULL, +b int(11) NOT NULL, +c datetime default NULL, +PRIMARY KEY (a), +KEY idx_bc (b,c) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES +(406989,67,'2006-02-23 17:08:46'), (150078,67,'2005-10-26 11:17:45'), +(406993,67,'2006-02-27 11:20:57'), (245655,67,'2005-12-08 15:59:08'), +(406994,67,'2006-02-27 11:26:46'), (256,67,NULL), +(398341,67,'2006-02-20 04:48:44'), (254,67,NULL),(1120,67,NULL), +(406988,67,'2006-02-23 17:07:22'), (255,67,NULL), +(398340,67,'2006-02-20 04:38:53'),(406631,67,'2006-02-23 10:49:42'), +(245653,67,'2005-12-08 15:59:07'),(406992,67,'2006-02-24 16:47:18'), +(245654,67,'2005-12-08 15:59:08'),(406995,67,'2006-02-28 11:55:00'), +(127261,67,'2005-10-13 12:17:58'),(406991,67,'2006-02-24 16:42:32'), +(245652,67,'2005-12-08 15:58:27'),(398545,67,'2006-02-20 04:53:13'), +(154504,67,'2005-10-28 11:53:01'),(9199,67,NULL),(1,67,'2006-02-23 15:01:35'), +(223456,67,NULL),(4101,67,NULL),(1133,67,NULL), +(406990,67,'2006-02-23 18:01:45'),(148815,67,'2005-10-25 15:34:17'), +(148812,67,'2005-10-25 15:30:01'),(245651,67,'2005-12-08 15:58:27'), +(154503,67,'2005-10-28 11:52:38'); +create table t11 select * from t1 where b = 67 AND (c IS NULL OR c > NOW()) order by 3 asc; +create table t12 select * from t1 where b = 67 AND (c IS NULL OR c > NOW()) order by 3 desc; +create table t21 select * from t1 where b = 67 AND (c IS NULL OR c > '2005-12-08') order by 3 asc; +create table t22 select * from t1 where b = 67 AND (c IS NULL OR c > '2005-12-08') order by 3 desc; +update t22 set c = '2005-12-08 15:58:27' where a = 255; +explain select t21.* from t21,t22 where t21.a = t22.a and +t22.a in (select t12.a from t11, t12 where t11.a in(255,256) and t11.a = t12.a and t11.c is null) and t22.c is null order by t21.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t11 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; Using temporary; Using filesort; Start temporary +1 SIMPLE t12 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; Using join buffer (hash join) +1 SIMPLE t22 NULL ALL NULL NULL NULL NULL 26 3.85 Using where; End temporary; Using join buffer (hash join) +1 SIMPLE t21 NULL ALL NULL NULL NULL NULL 26 10.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t21`.`a` AS `a`,`test`.`t21`.`b` AS `b`,`test`.`t21`.`c` AS `c` from `test`.`t21` join `test`.`t22` semi join (`test`.`t11` join `test`.`t12`) where ((`test`.`t12`.`a` = `test`.`t11`.`a`) and (`test`.`t22`.`a` = `test`.`t11`.`a`) and (`test`.`t21`.`a` = `test`.`t11`.`a`) and (`test`.`t22`.`c` is null) and (`test`.`t11`.`a` in (255,256)) and (`test`.`t11`.`c` is null)) order by `test`.`t21`.`a` +explain format=json select * from t1 where a in (select a from t11); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "6.71" + }, + "duplicates_removal": { + "using_temporary_table": true, + "nested_loop": [ + { + "table": { + "table_name": "t11", + "access_type": "ALL", + "rows_examined_per_scan": 8, + "rows_produced_per_join": 8, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "0.80", + "prefix_cost": "1.31", + "data_read_per_join": "128" + }, + "used_columns": [ + "a" + ] + } + }, + { + "table": { + "table_name": "t1", + "access_type": "eq_ref", + "possible_keys": [ + "PRIMARY" + ], + "key": "PRIMARY", + "used_key_parts": [ + "a" + ], + "key_length": "4", + "ref": [ + "test.t11.a" + ], + "rows_examined_per_scan": 1, + "rows_produced_per_join": 8, + "filtered": "100.00", + "cost_info": { + "read_cost": "2.00", + "eval_cost": "0.80", + "prefix_cost": "6.71", + "data_read_per_join": "128" + }, + "used_columns": [ + "a", + "b", + "c" + ] + } + } + ] + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` semi join (`test`.`t11`) where (`test`.`t1`.`a` = `test`.`t11`.`a`) +select t21.* from t21,t22 where t21.a = t22.a and +t22.a in (select t12.a from t11, t12 where t11.a in(255,256) and t11.a = t12.a and t11.c is null) and t22.c is null order by t21.a; +a b c +256 67 NULL +drop table t1, t11, t12, t21, t22; +create table t1(a int); +insert into t1 values (0),(1); +explain +select (select max(y.a) from t1 y where a in (select a from t1 z) and a < x.a) as subq from t1 x; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY x NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DEPENDENT SUBQUERY y NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +2 DEPENDENT SUBQUERY z NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.x.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select (/* select#2 */ select max(`test`.`y`.`a`) from `test`.`t1` `y` semi join (`test`.`t1` `z`) where ((`test`.`z`.`a` = `test`.`y`.`a`) and (`test`.`y`.`a` < `test`.`x`.`a`))) AS `subq` from `test`.`t1` `x` +select (select max(y.a) from t1 y where a in (select a from t1 z) and a < x.a) as subq from t1 x; +subq +NULL +0 +drop table t1; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 as select * from t0; +insert into t1 select a+10 from t0; +insert into t0 values(2); +explain select * from t1 where 2 in (select a from t0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 11 10.00 Using where; Start temporary; End temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 20 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t0`) where (`test`.`t0`.`a` = 2) +select * from t1 where 2 in (select a from t0); +a +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +explain select * from (select a from t0) x where a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 11 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 20 10.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a` from `test`.`t0` semi join (`test`.`t1`) where (`test`.`t1`.`a` = `test`.`t0`.`a`) +explain format=json select * from (select a from t0) x where a in (select a from t1); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "28.41" + }, + "duplicates_removal": { + "using_temporary_table": true, + "nested_loop": [ + { + "table": { + "table_name": "t0", + "access_type": "ALL", + "rows_examined_per_scan": 11, + "rows_produced_per_join": 11, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "1.10", + "prefix_cost": "1.60", + "data_read_per_join": "88" + }, + "used_columns": [ + "a" + ] + } + }, + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 11, + "filtered": "10.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "1.10", + "prefix_cost": "28.41", + "data_read_per_join": "88" + }, + "used_columns": [ + "a" + ], + "attached_condition": "(`test`.`t1`.`a` = `test`.`t0`.`a`)" + } + } + ] + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a` from `test`.`t0` semi join (`test`.`t1`) where (`test`.`t1`.`a` = `test`.`t0`.`a`) +drop table t0, t1; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (kp1 int, kp2 int, c int, filler char(100), key(kp1, kp2)); +insert into t1 select A.a+10*(B.a+10*C.a), 0, 0, 'filler' from t0 A, t0 B, t0 C; +insert into t1 select * from t1 where kp1 < 20; +create table t3 (a int); +insert into t3 select A.a + 10*B.a from t0 A, t0 B; +explain select * from t3 where a in (select kp1 from t1 where kp1<20); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 100 100.00 Using where +1 SIMPLE t1 NULL ref kp1 kp1 5 test.t3.a 1 100.00 Using index; Start temporary; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a` from `test`.`t3` semi join (`test`.`t1`) where ((`test`.`t1`.`kp1` = `test`.`t3`.`a`) and (`test`.`t3`.`a` < 20)) +select * from t3 where a in (select kp1 from t1 where kp1<20); +a +0 +1 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +2 +3 +4 +5 +6 +7 +8 +9 +explain select * from t3 where a in (select kp1 from t1 where kp1<20) and a<20; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 100 33.33 Using where +1 SIMPLE t1 NULL ref kp1 kp1 5 test.t3.a 1 100.00 Using index; Start temporary; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a` from `test`.`t3` semi join (`test`.`t1`) where ((`test`.`t1`.`kp1` = `test`.`t3`.`a`) and (`test`.`t3`.`a` < 20) and (`test`.`t3`.`a` < 20)) +select * from t3 where a in (select kp1 from t1 where kp1<20) and a<20; +a +0 +1 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +2 +3 +4 +5 +6 +7 +8 +9 +create table t4 (pk int primary key); +insert into t4 select a from t3; +explain select * from t3 where a in +(select t1.kp1 from t1,t4 where kp1<20 and t4.pk=t1.c); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 100 100.00 Using where +1 SIMPLE t1 NULL ref kp1 kp1 5 test.t3.a 1 100.00 Using where; Start temporary +1 SIMPLE t4 NULL eq_ref PRIMARY PRIMARY 4 test.t1.c 1 100.00 Using index; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a` from `test`.`t3` semi join (`test`.`t1` join `test`.`t4`) where ((`test`.`t1`.`kp1` = `test`.`t3`.`a`) and (`test`.`t4`.`pk` = `test`.`t1`.`c`) and (`test`.`t3`.`a` < 20)) +explain format=tree select * from t3 where a in +(select t1.kp1 from t1,t4 where kp1<20 and t4.pk=t1.c); +EXPLAIN +-> Nested loop inner join (cost=45.54 rows=100) + -> Filter: ((t3.a < 20) and (t3.a is not null)) (cost=10.54 rows=100) + -> Table scan on t3 (cost=10.54 rows=100) + -> Limit: 1 row(s) (cost=25.35 rows=1) + -> Nested loop inner join (cost=25.35 rows=1) + -> Filter: (t1.c is not null) (cost=0.25 rows=1) + -> Index lookup on t1 using kp1 (kp1=t3.a) (cost=0.25 rows=1) + -> Single-row index lookup on t4 using PRIMARY (pk=t1.c) (cost=0.25 rows=1) + +select * from t3 where a in +(select t1.kp1 from t1,t4 where kp1<20 and t4.pk=t1.c); +a +0 +1 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +2 +3 +4 +5 +6 +7 +8 +9 +drop table t1, t3, t4; +create table t1 (a int); +insert into t1 values (0),(0),(0),(1),(1),(1),(2),(2),(2),(3),(3),(3); +set session internal_tmp_mem_storage_engine='memory'; +set @save_max_heap_table_size=@@max_heap_table_size; +set @@max_heap_table_size= 16384; +# Attempt to make one test that overflows the heap table when a +# non-duplicate row is inserted and one test that overflows the +# heap table when a duplicate record is inserted. Debugging showed +# that these situations occurred with max_heap_table_size=16384 +# and optimizer_join_cache_level equals 1 and 0, respectively. +# Finally execute a test that does not overflow the heap table. +explain +select count(*) from t0 a, t0 b, t0 c +where c.a in (select a from t1 d); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE a NULL ALL NULL NULL NULL NULL 10 100.00 Start temporary +1 SIMPLE b NULL ALL NULL NULL NULL NULL 10 100.00 Using join buffer (hash join) +1 SIMPLE c NULL ALL NULL NULL NULL NULL 10 100.00 Using join buffer (hash join) +1 SIMPLE d NULL ALL NULL NULL NULL NULL 12 10.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select count(0) AS `count(*)` from `test`.`t0` `a` join `test`.`t0` `b` join `test`.`t0` `c` semi join (`test`.`t1` `d`) where (`test`.`d`.`a` = `test`.`c`.`a`) +flush status; +select count(*) from t0 a, t0 b, t0 c +where c.a in (select a from t1 d); +count(*) +400 +show status like 'Created_tmp_disk_tables'; +Variable_name Value +Created_tmp_disk_tables 1 +set @@max_heap_table_size= @save_max_heap_table_size; +set session internal_tmp_mem_storage_engine=default; +flush status; +select count(*) from t0 a, t0 b, t0 c +where c.a in (select a from t1 d); +count(*) +400 +show status like 'Created_tmp_disk_tables'; +Variable_name Value +Created_tmp_disk_tables 0 +drop table t0, t1; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t2(a int); +insert into t2 values (1),(2); +create table t3 ( a int , filler char(100), key(a)); +insert into t3 select A.a + 10*B.a, 'filler' from t0 A, t0 B; +explain select * from t3 where a in (select a from t2) and (a > 5 or a < 10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ref a a 5 test.t2.a 1 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a`,`test`.`t3`.`filler` AS `filler` from `test`.`t3` semi join (`test`.`t2`) where ((`test`.`t3`.`a` = `test`.`t2`.`a`) and ((`test`.`t2`.`a` > 5) or (`test`.`t2`.`a` < 10))) +select * from t3 where a in (select a from t2); +a filler +1 filler +2 filler +drop table t0, t2, t3; +create table t1 (a date); +insert into t1 values ('2008-01-01'),('2008-01-01'),('2008-02-01'),('2008-02-01'); +create table t2 (a int); +insert into t2 values (1),(2); +create table t3 (a char(10)); +insert into t3 select * from t1; +insert into t3 values (1),(2); +explain select * from t2 where a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1`) where (cast(`test`.`t2`.`a` as double) = cast(`test`.`t1`.`a` as double)) +explain select * from t2 where a in (select a from t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t2`) where (`test`.`t2`.`a` = `test`.`t2`.`a`) +explain select * from t2 where a in (select a from t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t3`) where (cast(`test`.`t2`.`a` as double) = cast(`test`.`t3`.`a` as double)) +explain select * from t1 where a in (select a from t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t3`) where (`test`.`t1`.`a` = cast(`test`.`t3`.`a` as date)) +drop table t1, t2, t3; +create table t1 (a decimal); +insert into t1 values (1),(2); +explain select * from t1 where a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t1`) where (`test`.`t1`.`a` = `test`.`t1`.`a`) +drop table t1; +create table t1 (a int); +insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t2 as select * from t1; +create table t3 (a int, b int, filler char(100), key(a)) charset utf8mb4; +insert into t3 select A.a + 10*B.a, A.a + 10*B.a, 'filler' from t1 A, t1 B, t1 C; +explain select * from t1, t3 where t3.a in (select a from t2) and (t3.a < 10 or t3.a >30) and t1.a =3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 10.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 10 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ref a a 5 test.t2.a 10 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t3`.`filler` AS `filler` from `test`.`t1` join `test`.`t3` semi join (`test`.`t2`) where ((`test`.`t3`.`a` = `test`.`t2`.`a`) and (`test`.`t1`.`a` = 3) and ((`test`.`t2`.`a` < 10) or (`test`.`t2`.`a` > 30))) +explain format=json select * from t1, t3 where t3.a in (select a from t2) and (t3.a < 10 or t3.a >30) and t1.a =3; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "59.01" + }, + "duplicates_removal": { + "using_temporary_table": true, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 10, + "rows_produced_per_join": 1, + "filtered": "10.00", + "cost_info": { + "read_cost": "1.40", + "eval_cost": "0.10", + "prefix_cost": "1.50", + "data_read_per_join": "8" + }, + "used_columns": [ + "a" + ], + "attached_condition": "(`test`.`t1`.`a` = 3)" + } + }, + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 10, + "rows_produced_per_join": 10, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "1.00", + "prefix_cost": "3.01", + "data_read_per_join": "80" + }, + "used_columns": [ + "a" + ], + "attached_condition": "(((`test`.`t2`.`a` < 10) or (`test`.`t2`.`a` > 30)) and (`test`.`t2`.`a` is not null))" + } + }, + { + "table": { + "table_name": "t3", + "access_type": "ref", + "possible_keys": [ + "a" + ], + "key": "a", + "used_key_parts": [ + "a" + ], + "key_length": "5", + "ref": [ + "test.t2.a" + ], + "rows_examined_per_scan": 10, + "rows_produced_per_join": 100, + "filtered": "100.00", + "cost_info": { + "read_cost": "25.00", + "eval_cost": "10.00", + "prefix_cost": "59.01", + "data_read_per_join": "40K" + }, + "used_columns": [ + "a", + "b", + "filler" + ] + } + } + ] + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t3`.`filler` AS `filler` from `test`.`t1` join `test`.`t3` semi join (`test`.`t2`) where ((`test`.`t3`.`a` = `test`.`t2`.`a`) and (`test`.`t1`.`a` = 3) and ((`test`.`t2`.`a` < 10) or (`test`.`t2`.`a` > 30))) +explain select straight_join * from t1 a, t1 b where a.a in (select a from t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY a NULL ALL NULL NULL NULL NULL 10 100.00 Using where +1 PRIMARY b NULL ALL NULL NULL NULL NULL 10 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select straight_join `test`.`a`.`a` AS `a`,`test`.`b`.`a` AS `a` from `test`.`t1` `a` join `test`.`t1` `b` where (`test`.`a`.`a`,(/* select#2 */ select `test`.`t2`.`a` from `test`.`t2` where ((`test`.`a`.`a`) = `test`.`t2`.`a`))) +explain select * from t2 where a in (select straight_join a.a from t1 a, t1 b); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 10 100.00 Using where +2 DEPENDENT SUBQUERY a NULL ALL NULL NULL NULL NULL 10 10.00 Using where +2 DEPENDENT SUBQUERY b NULL ALL NULL NULL NULL NULL 10 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` where (`test`.`t2`.`a`,(/* select#2 */ select straight_join `test`.`a`.`a` from `test`.`t1` `a` join `test`.`t1` `b` where ((`test`.`t2`.`a`) = `test`.`a`.`a`))) +explain select * from t2 where a in (select straight_join a.a from t1 a, t1 b); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 10 100.00 Using where +2 DEPENDENT SUBQUERY a NULL ALL NULL NULL NULL NULL 10 10.00 Using where +2 DEPENDENT SUBQUERY b NULL ALL NULL NULL NULL NULL 10 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` where (`test`.`t2`.`a`,(/* select#2 */ select straight_join `test`.`a`.`a` from `test`.`t1` `a` join `test`.`t1` `b` where ((`test`.`t2`.`a`) = `test`.`a`.`a`))) +explain select straight_join * from t2 x, t2 y +where x.a in (select straight_join a.a from t1 a, t1 b); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY x NULL ALL NULL NULL NULL NULL 10 100.00 Using where +1 PRIMARY y NULL ALL NULL NULL NULL NULL 10 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY a NULL ALL NULL NULL NULL NULL 10 10.00 Using where +2 DEPENDENT SUBQUERY b NULL ALL NULL NULL NULL NULL 10 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select straight_join `test`.`x`.`a` AS `a`,`test`.`y`.`a` AS `a` from `test`.`t2` `x` join `test`.`t2` `y` where (`test`.`x`.`a`,(/* select#2 */ select straight_join `test`.`a`.`a` from `test`.`t1` `a` join `test`.`t1` `b` where ((`test`.`x`.`a`) = `test`.`a`.`a`))) +create table t0 (a int, b int); +insert into t0 values(1,1); +explain select * from t0, t3 where t3.a in (select a from t2) and (t3.a < 10 or t3.a >30); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 10 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ref a a 5 test.t2.a 10 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select '1' AS `a`,'1' AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t3`.`filler` AS `filler` from `test`.`t3` semi join (`test`.`t2`) where ((`test`.`t3`.`a` = `test`.`t2`.`a`) and ((`test`.`t2`.`a` < 10) or (`test`.`t2`.`a` > 30))) +create table t4 as select a as x, a as y from t1; +explain select * from t0, t3 where (t3.a, t3.b) in (select x,y from t4) and (t3.a < 10 or t3.a >30); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t4 NULL ALL NULL NULL NULL NULL 10 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ref a a 5 test.t4.x 10 10.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '1' AS `a`,'1' AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t3`.`filler` AS `filler` from `test`.`t3` semi join (`test`.`t4`) where ((`test`.`t3`.`b` = `test`.`t4`.`y`) and (`test`.`t3`.`a` = `test`.`t4`.`x`) and ((`test`.`t4`.`x` < 10) or (`test`.`t4`.`x` > 30))) +drop table t0,t1,t2,t3,t4; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (a int, b int, filler char(100), key(a,b)); +insert into t1 select A.a, B.a, 'filler' from t0 A, t0 B; +create table t2 as select * from t1; +explain select * from t2 where a in (select b from t1 where a=3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 100 100.00 Using where +1 SIMPLE t1 NULL ref a a 10 const,test.t2.a 1 100.00 Using index; Start temporary; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`filler` AS `filler` from `test`.`t2` semi join (`test`.`t1`) where ((`test`.`t1`.`b` = `test`.`t2`.`a`) and (`test`.`t1`.`a` = 3)) +explain select * from t2 where (b,a) in (select a,b from t1 where a=3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 100 10.00 Using where +1 SIMPLE t1 NULL ref a a 10 const,test.t2.a 1 100.00 Using index; Start temporary; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`filler` AS `filler` from `test`.`t2` semi join (`test`.`t1`) where ((`test`.`t1`.`b` = `test`.`t2`.`a`) and (`test`.`t2`.`b` = 3) and (`test`.`t1`.`a` = 3)) +drop table t1,t2; +create table t1 (a int, b int); +insert into t1 select a,a from t0; +create table t2 (a int, b int); +insert into t2 select A.a + 10*B.a, A.a + 10*B.a from t0 A, t0 B; +explain select * from t1 where (a,b) in (select a,b from t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 100.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 100 1.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`a` = `test`.`t1`.`a`)) +drop table t0, t1, t2; +# +# Bug#19695490: CRASH IN CREATE_REF_FOR_KEY ON SELECT + JOIN + UTF8 COLUMN +# + DATETIME INDEX. +# +CREATE TABLE t1 ( +field1 varchar(255) CHARACTER SET utf8, +field2 varchar(255) CHARACTER SET utf8 +); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES +('time','time'), +('lpjdzvkp','lpjdzvkp'), +('dzvkpai', 'dzvkpai'); +CREATE TABLE t2 ( col_varchar varchar(10)); +CREATE TABLE t3 ( +pk int(11) NOT NULL, +col_varchar_255_utf8_key varchar(255) CHARACTER SET utf8, +col_varchar_10_utf8_key varchar(10) CHARACTER SET utf8, +PRIMARY KEY (pk) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t3 VALUES (22,'come','h'), +(23,'time','aaa'), +(24,'lpjdzvkp','ababa'), +(25,'d','GGDD'); +SELECT * FROM t1 WHERE (field1, field2) IN ( +SELECT table1.col_varchar_255_utf8_key AS field1, +table1.col_varchar_255_utf8_key AS field2 +FROM t3 AS table1 LEFT JOIN t2 AS table2 +ON table1.col_varchar_10_utf8_key <= +table2.col_varchar +WHERE table1.pk >= 6); +field1 field2 +time time +lpjdzvkp lpjdzvkp +DROP TABLE t1,t2,t3; +create table t0 (a decimal(4,2)); +insert into t0 values (10.24), (22.11); +create table t1 as select * from t0; +insert into t1 select * from t0; +explain select * from t0 where a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a` from `test`.`t0` semi join (`test`.`t1`) where (`test`.`t1`.`a` = `test`.`t0`.`a`) +select * from t0 where a in (select a from t1); +a +10.24 +22.11 +drop table t0, t1; +create table t0(a date); +insert into t0 values ('2008-01-01'),('2008-02-02'); +create table t1 as select * from t0; +insert into t1 select * from t0; +explain select * from t0 where a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a` from `test`.`t0` semi join (`test`.`t1`) where (`test`.`t1`.`a` = `test`.`t0`.`a`) +select * from t0 where a in (select a from t1); +a +2008-01-01 +2008-02-02 +drop table t0, t1; +create table t0(a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 as select a as a, a as b, a as c from t0 where a < 3; +create table t2 as select a as a, a as b from t0 where a < 3; +insert into t2 select * from t2; +explain select * from t1 where (a,b,c) in (select x.a, y.a, z.a from t2 x, t2 y, t2 z where x.b=33); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE x NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +1 SIMPLE y NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Using join buffer (hash join) +1 SIMPLE z NULL ALL NULL NULL NULL NULL 6 16.67 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` semi join (`test`.`t2` `x` join `test`.`t2` `y` join `test`.`t2` `z`) where ((`test`.`z`.`a` = `test`.`t1`.`c`) and (`test`.`y`.`a` = `test`.`t1`.`b`) and (`test`.`t1`.`a` = `test`.`x`.`a`) and (`test`.`x`.`b` = 33)) +drop table t0,t1,t2; +set @save_join_buffer_size = @@join_buffer_size; +set join_buffer_size= 8192; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (a int, filler1 binary(200), filler2 binary(200)); +insert into t1 select a, 'filler123456', 'filler123456' from t0; +insert into t1 select a+10, 'filler123456', 'filler123456' from t0; +create table t2 as select * from t1; +insert into t1 select a+20, 'filler123456', 'filler123456' from t0; +insert into t1 values (2, 'duplicate ok', 'duplicate ok'); +insert into t1 values (18, 'duplicate ok', 'duplicate ok'); +insert into t2 values (3, 'duplicate ok', 'duplicate ok'); +insert into t2 values (19, 'duplicate ok', 'duplicate ok'); +explain select +a, mid(filler1, 1,10), length(filler1)=length(filler2) as z +from t1 ot where a in (select a from t2 it); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE it NULL ALL NULL NULL NULL NULL 22 100.00 Start temporary +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 32 10.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot`.`a` AS `a`,substr(`test`.`ot`.`filler1`,1,10) AS `mid(filler1, 1,10)`,(length(`test`.`ot`.`filler1`) = length(`test`.`ot`.`filler2`)) AS `z` from `test`.`t1` `ot` semi join (`test`.`t2` `it`) where (`test`.`ot`.`a` = `test`.`it`.`a`) +select +a, mid(filler1, 1,10), length(filler1)=length(filler2) as z +from t1 ot where a in (select a from t2 it); +a mid(filler1, 1,10) z +0 filler1234 1 +1 filler1234 1 +10 filler1234 1 +11 filler1234 1 +12 filler1234 1 +13 filler1234 1 +14 filler1234 1 +15 filler1234 1 +16 filler1234 1 +17 filler1234 1 +18 duplicate 1 +18 filler1234 1 +19 filler1234 1 +2 duplicate 1 +2 filler1234 1 +3 filler1234 1 +4 filler1234 1 +5 filler1234 1 +6 filler1234 1 +7 filler1234 1 +8 filler1234 1 +9 filler1234 1 +explain select +a, mid(filler1, 1,10), length(filler1)=length(filler2) +from t2 ot where a in (select a from t1 it); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 22 100.00 Start temporary +1 SIMPLE it NULL ALL NULL NULL NULL NULL 32 10.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot`.`a` AS `a`,substr(`test`.`ot`.`filler1`,1,10) AS `mid(filler1, 1,10)`,(length(`test`.`ot`.`filler1`) = length(`test`.`ot`.`filler2`)) AS `length(filler1)=length(filler2)` from `test`.`t2` `ot` semi join (`test`.`t1` `it`) where (`test`.`it`.`a` = `test`.`ot`.`a`) +select +a, mid(filler1, 1,10), length(filler1)=length(filler2) +from t2 ot where a in (select a from t1 it); +a mid(filler1, 1,10) length(filler1)=length(filler2) +0 filler1234 1 +1 filler1234 1 +10 filler1234 1 +11 filler1234 1 +12 filler1234 1 +13 filler1234 1 +14 filler1234 1 +15 filler1234 1 +16 filler1234 1 +17 filler1234 1 +18 filler1234 1 +19 duplicate 1 +19 filler1234 1 +2 filler1234 1 +3 duplicate 1 +3 filler1234 1 +4 filler1234 1 +5 filler1234 1 +6 filler1234 1 +7 filler1234 1 +8 filler1234 1 +9 filler1234 1 +insert into t1 select a+20, 'filler123456', 'filler123456' from t0; +insert into t1 select a+20, 'filler123456', 'filler123456' from t0; +explain select +a, mid(filler1, 1,10), length(filler1)=length(filler2) as z +from t1 ot where a in (select a from t2 it); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE it NULL ALL NULL NULL NULL NULL 22 100.00 Start temporary +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 52 10.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot`.`a` AS `a`,substr(`test`.`ot`.`filler1`,1,10) AS `mid(filler1, 1,10)`,(length(`test`.`ot`.`filler1`) = length(`test`.`ot`.`filler2`)) AS `z` from `test`.`t1` `ot` semi join (`test`.`t2` `it`) where (`test`.`ot`.`a` = `test`.`it`.`a`) +select +a, mid(filler1, 1,10), length(filler1)=length(filler2) as z +from t1 ot where a in (select a from t2 it); +a mid(filler1, 1,10) z +0 filler1234 1 +1 filler1234 1 +10 filler1234 1 +11 filler1234 1 +12 filler1234 1 +13 filler1234 1 +14 filler1234 1 +15 filler1234 1 +16 filler1234 1 +17 filler1234 1 +18 duplicate 1 +18 filler1234 1 +19 filler1234 1 +2 duplicate 1 +2 filler1234 1 +3 filler1234 1 +4 filler1234 1 +5 filler1234 1 +6 filler1234 1 +7 filler1234 1 +8 filler1234 1 +9 filler1234 1 +explain select +a, mid(filler1, 1,10), length(filler1)=length(filler2) +from t2 ot where a in (select a from t1 it); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 22 100.00 Start temporary +1 SIMPLE it NULL ALL NULL NULL NULL NULL 52 10.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot`.`a` AS `a`,substr(`test`.`ot`.`filler1`,1,10) AS `mid(filler1, 1,10)`,(length(`test`.`ot`.`filler1`) = length(`test`.`ot`.`filler2`)) AS `length(filler1)=length(filler2)` from `test`.`t2` `ot` semi join (`test`.`t1` `it`) where (`test`.`it`.`a` = `test`.`ot`.`a`) +select +a, mid(filler1, 1,10), length(filler1)=length(filler2) +from t2 ot where a in (select a from t1 it); +a mid(filler1, 1,10) length(filler1)=length(filler2) +0 filler1234 1 +1 filler1234 1 +10 filler1234 1 +11 filler1234 1 +12 filler1234 1 +13 filler1234 1 +14 filler1234 1 +15 filler1234 1 +16 filler1234 1 +17 filler1234 1 +18 filler1234 1 +19 duplicate 1 +19 filler1234 1 +2 filler1234 1 +3 duplicate 1 +3 filler1234 1 +4 filler1234 1 +5 filler1234 1 +6 filler1234 1 +7 filler1234 1 +8 filler1234 1 +9 filler1234 1 +set @@join_buffer_size = @save_join_buffer_size; +drop table t1, t2; +create table t1 (a int, b int, key(a)); +create table t2 (a int, b int, key(a)); +create table t3 (a int, b int, key(a)); +insert into t1 select a,a from t0; +insert into t2 select a,a from t0; +insert into t3 select a,a from t0; +t2 and t3 must be use 'ref', not 'ALL': +explain select * +from t0 where a in +(select t2.a+t3.a from t1 left join (t2 join t3) on t2.a=t1.a and t3.a=t1.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 10 100.00 Start temporary +1 SIMPLE t1 NULL index a a 5 NULL 10 100.00 Using where; Using index; Using join buffer (hash join) +1 SIMPLE t2 NULL ref a a 5 test.t1.a 1 100.00 Using index +1 SIMPLE t3 NULL ref a a 5 test.t1.a 1 100.00 Using index; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a` from `test`.`t0` semi join (`test`.`t1` join `test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`a` = `test`.`t1`.`a`) and (`test`.`t3`.`a` = `test`.`t1`.`a`) and (`test`.`t0`.`a` = (`test`.`t1`.`a` + `test`.`t1`.`a`))) +drop table t0, t1,t2,t3; + +Test that neither MaterializeLookup strategy for semijoin, +nor subquery materialization is used when BLOBs are involved +(except when arguments of some functions). + +set @prefix_len = 6; +set @blob_len = 16; +set @suffix_len = @blob_len - @prefix_len; +create table t1_16 (a1 blob(16), a2 blob(16)); +create table t2_16 (b1 blob(16), b2 blob(16)); +create table t3_16 (c1 blob(16), c2 blob(16)); +insert into t1_16 values +(concat('1 - 00', repeat('x', @suffix_len)), concat('2 - 00', repeat('x', @suffix_len))); +insert into t1_16 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t1_16 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_16 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t2_16 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_16 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_16 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t3_16 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t3_16 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_16 values +(concat('1 - 04', repeat('x', @suffix_len)), concat('2 - 04', repeat('x', @suffix_len))); +explain select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select b1 from t2_16 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2_16 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Start temporary +1 SIMPLE t1_16 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_16`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_16`.`a2`,7) AS `left(a2,7)` from `test`.`t1_16` semi join (`test`.`t2_16`) where ((`test`.`t1_16`.`a1` = `test`.`t2_16`.`b1`) and (`test`.`t2_16`.`b1` > '0')) +select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select b1 from t2_16 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_16 +where (a1,a2) in (select b1, b2 from t2_16 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2_16 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Start temporary +1 SIMPLE t1_16 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_16`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_16`.`a2`,7) AS `left(a2,7)` from `test`.`t1_16` semi join (`test`.`t2_16`) where ((`test`.`t1_16`.`a2` = `test`.`t2_16`.`b2`) and (`test`.`t1_16`.`a1` = `test`.`t2_16`.`b1`) and (`test`.`t2_16`.`b1` > '0')) +select left(a1,7), left(a2,7) +from t1_16 +where (a1,a2) in (select b1, b2 from t2_16 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select substring(b1,1,16) from t2_16 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2_16 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Start temporary +1 SIMPLE t1_16 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_16`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_16`.`a2`,7) AS `left(a2,7)` from `test`.`t1_16` semi join (`test`.`t2_16`) where ((`test`.`t2_16`.`b1` > '0') and (`test`.`t1_16`.`a1` = substr(`test`.`t2_16`.`b1`,1,16))) +select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select substring(b1,1,16) from t2_16 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select group_concat(b1) from t2_16 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_16 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t2_16 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_16`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_16`.`a2`,7) AS `left(a2,7)` from `test`.`t1_16` where (`test`.`t1_16`.`a1`,(/* select#2 */ select group_concat(`test`.`t2_16`.`b1` separator ',') from `test`.`t2_16` group by `test`.`t2_16`.`b2` having ((`test`.`t1_16`.`a1`) = (group_concat(`test`.`t2_16`.`b1` separator ','))))) +select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select group_concat(b1) from t2_16 group by b2); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +set @@group_concat_max_len = 256; +explain select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select group_concat(b1) from t2_16 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_16 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t2_16 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_16`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_16`.`a2`,7) AS `left(a2,7)` from `test`.`t1_16` where (`test`.`t1_16`.`a1`,(/* select#2 */ select group_concat(`test`.`t2_16`.`b1` separator ',') from `test`.`t2_16` group by `test`.`t2_16`.`b2` having ((`test`.`t1_16`.`a1`) = (group_concat(`test`.`t2_16`.`b1` separator ','))))) +select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select group_concat(b1) from t2_16 group by b2); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +create table t1 (a1 char(8), a2 char(8)) charset latin1; +create table t2 (b1 char(8), b2 char(8)) charset latin1; +create table t3 (c1 char(8), c2 char(8)) charset latin1; +insert into t1 values ('1 - 00', '2 - 00'); +insert into t1 values ('1 - 01', '2 - 01'); +insert into t1 values ('1 - 02', '2 - 02'); +insert into t2 values ('1 - 01', '2 - 01'); +insert into t2 values ('1 - 01', '2 - 01'); +insert into t2 values ('1 - 02', '2 - 02'); +insert into t2 values ('1 - 02', '2 - 02'); +insert into t2 values ('1 - 03', '2 - 03'); +insert into t3 values ('1 - 01', '2 - 01'); +insert into t3 values ('1 - 02', '2 - 02'); +insert into t3 values ('1 - 03', '2 - 03'); +insert into t3 values ('1 - 04', '2 - 04'); +insert into t3 values ('1 - 05', '2 - 05'); +insert into t3 values ('1 - 06', '2 - 06'); +insert into t3 values ('1 - 07', '2 - 07'); +insert into t3 values ('1 - 08', '2 - 08'); +explain +select * from t1 +where concat(a1,'x') IN +(select left(a1,8) from t1_16 +where (a1, a2) IN +(select t2_16.b1, t2_16.b2 from t2_16, t2 +where t2.b2 = substring(t2_16.b2,1,6) and +t2.b1 IN (select c1 from t3 where c2 > '0'))); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Start temporary +1 SIMPLE t1_16 NULL ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t2_16 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 5 20.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` semi join (`test`.`t1_16` join `test`.`t2_16` join `test`.`t2` join `test`.`t3`) where ((`test`.`t2_16`.`b2` = `test`.`t1_16`.`a2`) and (`test`.`t2_16`.`b1` = `test`.`t1_16`.`a1`) and (`test`.`t3`.`c1` = `test`.`t2`.`b1`) and (`test`.`t2`.`b2` = substr(`test`.`t2_16`.`b2`,1,6)) and (`test`.`t3`.`c2` > '0') and (concat(`test`.`t1`.`a1`,'x') = left(`test`.`t1_16`.`a1`,8))) +drop table t1_16, t2_16, t3_16, t1, t2, t3; +set @blob_len = 512; +set @suffix_len = @blob_len - @prefix_len; +create table t1_512 (a1 blob(512), a2 blob(512)); +create table t2_512 (b1 blob(512), b2 blob(512)); +create table t3_512 (c1 blob(512), c2 blob(512)); +insert into t1_512 values +(concat('1 - 00', repeat('x', @suffix_len)), concat('2 - 00', repeat('x', @suffix_len))); +insert into t1_512 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t1_512 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_512 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t2_512 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_512 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_512 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t3_512 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t3_512 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_512 values +(concat('1 - 04', repeat('x', @suffix_len)), concat('2 - 04', repeat('x', @suffix_len))); +explain select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select b1 from t2_512 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2_512 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Start temporary +1 SIMPLE t1_512 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_512`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_512`.`a2`,7) AS `left(a2,7)` from `test`.`t1_512` semi join (`test`.`t2_512`) where ((`test`.`t1_512`.`a1` = `test`.`t2_512`.`b1`) and (`test`.`t2_512`.`b1` > '0')) +select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select b1 from t2_512 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_512 +where (a1,a2) in (select b1, b2 from t2_512 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2_512 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Start temporary +1 SIMPLE t1_512 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_512`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_512`.`a2`,7) AS `left(a2,7)` from `test`.`t1_512` semi join (`test`.`t2_512`) where ((`test`.`t1_512`.`a2` = `test`.`t2_512`.`b2`) and (`test`.`t1_512`.`a1` = `test`.`t2_512`.`b1`) and (`test`.`t2_512`.`b1` > '0')) +select left(a1,7), left(a2,7) +from t1_512 +where (a1,a2) in (select b1, b2 from t2_512 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select substring(b1,1,512) from t2_512 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2_512 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Start temporary +1 SIMPLE t1_512 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_512`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_512`.`a2`,7) AS `left(a2,7)` from `test`.`t1_512` semi join (`test`.`t2_512`) where ((`test`.`t2_512`.`b1` > '0') and (`test`.`t1_512`.`a1` = substr(`test`.`t2_512`.`b1`,1,512))) +select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select substring(b1,1,512) from t2_512 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select group_concat(b1) from t2_512 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_512 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t2_512 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_512`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_512`.`a2`,7) AS `left(a2,7)` from `test`.`t1_512` where (`test`.`t1_512`.`a1`,(/* select#2 */ select group_concat(`test`.`t2_512`.`b1` separator ',') from `test`.`t2_512` group by `test`.`t2_512`.`b2` having ((`test`.`t1_512`.`a1`) = (group_concat(`test`.`t2_512`.`b1` separator ','))))) +select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select group_concat(b1) from t2_512 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +Warning 1260 Row 4 was cut by GROUP_CONCAT() +Warning 1260 Row 5 was cut by GROUP_CONCAT() +Warning 1260 Row 6 was cut by GROUP_CONCAT() +Warning 1260 Row 7 was cut by GROUP_CONCAT() +Warning 1260 Row 8 was cut by GROUP_CONCAT() +Warning 1260 Row 9 was cut by GROUP_CONCAT() +set @@group_concat_max_len = 256; +explain select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select group_concat(b1) from t2_512 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_512 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t2_512 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_512`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_512`.`a2`,7) AS `left(a2,7)` from `test`.`t1_512` where (`test`.`t1_512`.`a1`,(/* select#2 */ select group_concat(`test`.`t2_512`.`b1` separator ',') from `test`.`t2_512` group by `test`.`t2_512`.`b2` having ((`test`.`t1_512`.`a1`) = (group_concat(`test`.`t2_512`.`b1` separator ','))))) +select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select group_concat(b1) from t2_512 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +Warning 1260 Row 4 was cut by GROUP_CONCAT() +Warning 1260 Row 5 was cut by GROUP_CONCAT() +Warning 1260 Row 6 was cut by GROUP_CONCAT() +Warning 1260 Row 7 was cut by GROUP_CONCAT() +Warning 1260 Row 8 was cut by GROUP_CONCAT() +Warning 1260 Row 9 was cut by GROUP_CONCAT() +drop table t1_512, t2_512, t3_512; +set @blob_len = 513; +set @suffix_len = @blob_len - @prefix_len; +create table t1_513 (a1 blob(513), a2 blob(513)); +create table t2_513 (b1 blob(513), b2 blob(513)); +create table t3_513 (c1 blob(513), c2 blob(513)); +insert into t1_513 values +(concat('1 - 00', repeat('x', @suffix_len)), concat('2 - 00', repeat('x', @suffix_len))); +insert into t1_513 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t1_513 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_513 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t2_513 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_513 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_513 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t3_513 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t3_513 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_513 values +(concat('1 - 04', repeat('x', @suffix_len)), concat('2 - 04', repeat('x', @suffix_len))); +explain select left(a1,7), left(a2,7) +from t1_513 +where a1 in (select b1 from t2_513 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2_513 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Start temporary +1 SIMPLE t1_513 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_513`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_513`.`a2`,7) AS `left(a2,7)` from `test`.`t1_513` semi join (`test`.`t2_513`) where ((`test`.`t1_513`.`a1` = `test`.`t2_513`.`b1`) and (`test`.`t2_513`.`b1` > '0')) +select left(a1,7), left(a2,7) +from t1_513 +where a1 in (select b1 from t2_513 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_513 +where (a1,a2) in (select b1, b2 from t2_513 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2_513 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Start temporary +1 SIMPLE t1_513 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_513`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_513`.`a2`,7) AS `left(a2,7)` from `test`.`t1_513` semi join (`test`.`t2_513`) where ((`test`.`t1_513`.`a2` = `test`.`t2_513`.`b2`) and (`test`.`t1_513`.`a1` = `test`.`t2_513`.`b1`) and (`test`.`t2_513`.`b1` > '0')) +select left(a1,7), left(a2,7) +from t1_513 +where (a1,a2) in (select b1, b2 from t2_513 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_513 +where a1 in (select substring(b1,1,513) from t2_513 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2_513 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Start temporary +1 SIMPLE t1_513 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_513`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_513`.`a2`,7) AS `left(a2,7)` from `test`.`t1_513` semi join (`test`.`t2_513`) where ((`test`.`t2_513`.`b1` > '0') and (`test`.`t1_513`.`a1` = substr(`test`.`t2_513`.`b1`,1,513))) +select left(a1,7), left(a2,7) +from t1_513 +where a1 in (select substring(b1,1,513) from t2_513 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_513 +where a1 in (select group_concat(b1) from t2_513 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_513 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t2_513 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_513`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_513`.`a2`,7) AS `left(a2,7)` from `test`.`t1_513` where (`test`.`t1_513`.`a1`,(/* select#2 */ select group_concat(`test`.`t2_513`.`b1` separator ',') from `test`.`t2_513` group by `test`.`t2_513`.`b2` having ((`test`.`t1_513`.`a1`) = (group_concat(`test`.`t2_513`.`b1` separator ','))))) +select left(a1,7), left(a2,7) +from t1_513 +where a1 in (select group_concat(b1) from t2_513 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +Warning 1260 Row 4 was cut by GROUP_CONCAT() +Warning 1260 Row 5 was cut by GROUP_CONCAT() +Warning 1260 Row 6 was cut by GROUP_CONCAT() +Warning 1260 Row 7 was cut by GROUP_CONCAT() +Warning 1260 Row 8 was cut by GROUP_CONCAT() +Warning 1260 Row 9 was cut by GROUP_CONCAT() +drop table t1_513, t2_513, t3_513; +set @blob_len = 1024; +set @suffix_len = @blob_len - @prefix_len; +create table t1_1024 (a1 blob(1024), a2 blob(1024)); +create table t2_1024 (b1 blob(1024), b2 blob(1024)); +create table t3_1024 (c1 blob(1024), c2 blob(1024)); +insert into t1_1024 values +(concat('1 - 00', repeat('x', @suffix_len)), concat('2 - 00', repeat('x', @suffix_len))); +insert into t1_1024 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t1_1024 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_1024 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t2_1024 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_1024 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_1024 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t3_1024 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t3_1024 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_1024 values +(concat('1 - 04', repeat('x', @suffix_len)), concat('2 - 04', repeat('x', @suffix_len))); +explain select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select b1 from t2_1024 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2_1024 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Start temporary +1 SIMPLE t1_1024 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1024`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1024`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1024` semi join (`test`.`t2_1024`) where ((`test`.`t1_1024`.`a1` = `test`.`t2_1024`.`b1`) and (`test`.`t2_1024`.`b1` > '0')) +select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select b1 from t2_1024 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_1024 +where (a1,a2) in (select b1, b2 from t2_1024 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2_1024 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Start temporary +1 SIMPLE t1_1024 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1024`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1024`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1024` semi join (`test`.`t2_1024`) where ((`test`.`t1_1024`.`a2` = `test`.`t2_1024`.`b2`) and (`test`.`t1_1024`.`a1` = `test`.`t2_1024`.`b1`) and (`test`.`t2_1024`.`b1` > '0')) +select left(a1,7), left(a2,7) +from t1_1024 +where (a1,a2) in (select b1, b2 from t2_1024 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select substring(b1,1,1024) from t2_1024 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2_1024 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Start temporary +1 SIMPLE t1_1024 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1024`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1024`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1024` semi join (`test`.`t2_1024`) where ((`test`.`t2_1024`.`b1` > '0') and (`test`.`t1_1024`.`a1` = substr(`test`.`t2_1024`.`b1`,1,1024))) +select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select substring(b1,1,1024) from t2_1024 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select group_concat(b1) from t2_1024 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_1024 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t2_1024 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1024`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1024`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1024` where (`test`.`t1_1024`.`a1`,(/* select#2 */ select group_concat(`test`.`t2_1024`.`b1` separator ',') from `test`.`t2_1024` group by `test`.`t2_1024`.`b2` having ((`test`.`t1_1024`.`a1`) = (group_concat(`test`.`t2_1024`.`b1` separator ','))))) +select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select group_concat(b1) from t2_1024 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +Warning 1260 Row 4 was cut by GROUP_CONCAT() +Warning 1260 Row 5 was cut by GROUP_CONCAT() +Warning 1260 Row 6 was cut by GROUP_CONCAT() +Warning 1260 Row 7 was cut by GROUP_CONCAT() +Warning 1260 Row 8 was cut by GROUP_CONCAT() +Warning 1260 Row 9 was cut by GROUP_CONCAT() +set @@group_concat_max_len = 256; +explain select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select group_concat(b1) from t2_1024 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_1024 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t2_1024 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1024`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1024`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1024` where (`test`.`t1_1024`.`a1`,(/* select#2 */ select group_concat(`test`.`t2_1024`.`b1` separator ',') from `test`.`t2_1024` group by `test`.`t2_1024`.`b2` having ((`test`.`t1_1024`.`a1`) = (group_concat(`test`.`t2_1024`.`b1` separator ','))))) +select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select group_concat(b1) from t2_1024 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +Warning 1260 Row 4 was cut by GROUP_CONCAT() +Warning 1260 Row 5 was cut by GROUP_CONCAT() +Warning 1260 Row 6 was cut by GROUP_CONCAT() +Warning 1260 Row 7 was cut by GROUP_CONCAT() +Warning 1260 Row 8 was cut by GROUP_CONCAT() +Warning 1260 Row 9 was cut by GROUP_CONCAT() +drop table t1_1024, t2_1024, t3_1024; +set @blob_len = 1025; +set @suffix_len = @blob_len - @prefix_len; +create table t1_1025 (a1 blob(1025), a2 blob(1025)); +create table t2_1025 (b1 blob(1025), b2 blob(1025)); +create table t3_1025 (c1 blob(1025), c2 blob(1025)); +insert into t1_1025 values +(concat('1 - 00', repeat('x', @suffix_len)), concat('2 - 00', repeat('x', @suffix_len))); +insert into t1_1025 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t1_1025 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_1025 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t2_1025 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_1025 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_1025 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t3_1025 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t3_1025 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_1025 values +(concat('1 - 04', repeat('x', @suffix_len)), concat('2 - 04', repeat('x', @suffix_len))); +explain select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select b1 from t2_1025 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2_1025 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Start temporary +1 SIMPLE t1_1025 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1025`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1025`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1025` semi join (`test`.`t2_1025`) where ((`test`.`t1_1025`.`a1` = `test`.`t2_1025`.`b1`) and (`test`.`t2_1025`.`b1` > '0')) +select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select b1 from t2_1025 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_1025 +where (a1,a2) in (select b1, b2 from t2_1025 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2_1025 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Start temporary +1 SIMPLE t1_1025 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1025`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1025`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1025` semi join (`test`.`t2_1025`) where ((`test`.`t1_1025`.`a2` = `test`.`t2_1025`.`b2`) and (`test`.`t1_1025`.`a1` = `test`.`t2_1025`.`b1`) and (`test`.`t2_1025`.`b1` > '0')) +select left(a1,7), left(a2,7) +from t1_1025 +where (a1,a2) in (select b1, b2 from t2_1025 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select substring(b1,1,1025) from t2_1025 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2_1025 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Start temporary +1 SIMPLE t1_1025 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1025`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1025`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1025` semi join (`test`.`t2_1025`) where ((`test`.`t2_1025`.`b1` > '0') and (`test`.`t1_1025`.`a1` = substr(`test`.`t2_1025`.`b1`,1,1025))) +select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select substring(b1,1,1025) from t2_1025 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select group_concat(b1) from t2_1025 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_1025 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t2_1025 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1025`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1025`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1025` where (`test`.`t1_1025`.`a1`,(/* select#2 */ select group_concat(`test`.`t2_1025`.`b1` separator ',') from `test`.`t2_1025` group by `test`.`t2_1025`.`b2` having ((`test`.`t1_1025`.`a1`) = (group_concat(`test`.`t2_1025`.`b1` separator ','))))) +select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select group_concat(b1) from t2_1025 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +Warning 1260 Row 4 was cut by GROUP_CONCAT() +Warning 1260 Row 5 was cut by GROUP_CONCAT() +Warning 1260 Row 6 was cut by GROUP_CONCAT() +Warning 1260 Row 7 was cut by GROUP_CONCAT() +Warning 1260 Row 8 was cut by GROUP_CONCAT() +Warning 1260 Row 9 was cut by GROUP_CONCAT() +set @@group_concat_max_len = 256; +explain select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select group_concat(b1) from t2_1025 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_1025 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t2_1025 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1025`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1025`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1025` where (`test`.`t1_1025`.`a1`,(/* select#2 */ select group_concat(`test`.`t2_1025`.`b1` separator ',') from `test`.`t2_1025` group by `test`.`t2_1025`.`b2` having ((`test`.`t1_1025`.`a1`) = (group_concat(`test`.`t2_1025`.`b1` separator ','))))) +select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select group_concat(b1) from t2_1025 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +Warning 1260 Row 4 was cut by GROUP_CONCAT() +Warning 1260 Row 5 was cut by GROUP_CONCAT() +Warning 1260 Row 6 was cut by GROUP_CONCAT() +Warning 1260 Row 7 was cut by GROUP_CONCAT() +Warning 1260 Row 8 was cut by GROUP_CONCAT() +Warning 1260 Row 9 was cut by GROUP_CONCAT() +drop table t1_1025, t2_1025, t3_1025; +# +# WL#5561: Enable semi join transformation with outer join. +# +CREATE TABLE ot1(a INT); +CREATE TABLE ot2(a INT); +CREATE TABLE ot3(a INT); +CREATE TABLE it1(a INT); +CREATE TABLE it2(a INT); +CREATE TABLE it3(a INT); +INSERT INTO ot1 VALUES(0),(1),(2),(3),(4),(5),(6),(7); +INSERT INTO ot2 VALUES(0),(2),(4),(6); +INSERT INTO ot3 VALUES(0),(3),(6); +INSERT INTO it1 VALUES(0),(1),(2),(3),(4),(5),(6),(7); +INSERT INTO it2 VALUES(0),(2),(4),(6); +INSERT INTO it3 VALUES(0),(3),(6); +# Test cases, Subquery Pattern 1 +# Example SQ1.1: +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE ot1.a IN (SELECT a FROM it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE it3 NULL ALL NULL NULL NULL NULL 3 100.00 Start temporary +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; End temporary; Using join buffer (hash join) +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` left join `test`.`ot2` on((`test`.`ot2`.`a` = `test`.`it3`.`a`)) semi join (`test`.`it3`) where (`test`.`ot1`.`a` = `test`.`it3`.`a`) +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE ot1.a IN (SELECT a FROM it3); +a a +0 0 +3 NULL +6 6 +# Example SQ1.2: +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE COALESCE(ot2.a,0) IN (SELECT a FROM it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE it3 NULL ALL NULL NULL NULL NULL 3 100.00 Start temporary +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 Using join buffer (hash join) +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` left join `test`.`ot2` on((`test`.`ot2`.`a` = `test`.`ot1`.`a`)) semi join (`test`.`it3`) where (coalesce(`test`.`ot2`.`a`,0) = `test`.`it3`.`a`) +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE COALESCE(ot2.a,0) IN (SELECT a FROM it3); +a a +0 0 +1 NULL +3 NULL +5 NULL +6 6 +7 NULL +# Example SQ1.3: +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE (ot1.a,ot2.a) IN (SELECT a, a FROM it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE it3 NULL ALL NULL NULL NULL NULL 3 100.00 Start temporary +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; Using join buffer (hash join) +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` join `test`.`ot2` semi join (`test`.`it3`) where ((`test`.`ot2`.`a` = `test`.`it3`.`a`) and (`test`.`ot1`.`a` = `test`.`it3`.`a`)) +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE (ot1.a,ot2.a) IN (SELECT a, a FROM it3); +a a +0 0 +6 6 +# More test cases +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 +WHERE ot1.a IN (SELECT a FROM it3); +a a +0 0 +3 NULL +6 6 +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 +WHERE ot1.a IN (SELECT a+0 FROM it3); +a a +0 0 +3 NULL +6 6 +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 +WHERE COALESCE(ot2.a,0) IN (SELECT a FROM it3); +a a +0 0 +1 NULL +3 NULL +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE COALESCE(ot2.a,0) IN (SELECT a+0 FROM it3); +a a +0 0 +1 NULL +3 NULL +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 +WHERE (ot1.a,ot2.a) IN (SELECT a, a FROM it3); +a a +0 0 +6 6 +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +LEFT JOIN ot3 ON ot1.a=ot3.a +WHERE ot1.a IN (SELECT a FROM it3); +a a a +0 0 0 +3 NULL 3 +6 6 6 +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +LEFT JOIN ot3 ON ot1.a=ot3.a +WHERE COALESCE(ot2.a,0) IN (SELECT a FROM it3); +a a a +0 0 0 +1 NULL NULL +3 NULL 3 +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +LEFT JOIN ot3 ON ot1.a=ot3.a +WHERE COALESCE(ot3.a,0) IN (SELECT a FROM it3); +a a a +0 0 0 +1 NULL NULL +2 2 NULL +3 NULL 3 +4 4 NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +LEFT JOIN ot3 ON ot2.a=ot3.a +WHERE ot1.a IN (SELECT a FROM it3); +a a a +0 0 0 +3 NULL NULL +6 6 6 +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +LEFT JOIN ot3 ON ot2.a=ot3.a +WHERE COALESCE(ot2.a,0) IN (SELECT a FROM it3); +a a a +0 0 0 +1 NULL NULL +3 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +LEFT JOIN ot3 ON ot2.a=ot3.a +WHERE COALESCE(ot3.a,0) IN (SELECT a FROM it3); +a a a +0 0 0 +1 NULL NULL +2 2 NULL +3 NULL NULL +4 4 NULL +5 NULL NULL +6 6 6 +7 NULL NULL +# Test cases, Subquery Pattern 2 +# Example SQ2.1: +explain SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE it3 NULL ALL NULL NULL NULL NULL 3 100.00 Start temporary +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; End temporary; Using join buffer (hash join) +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` join `test`.`ot2` semi join (`test`.`it3`) where ((`test`.`ot1`.`a` = `test`.`it3`.`a`) and (`test`.`ot2`.`a` = `test`.`it3`.`a`)) +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3); +a a +0 0 +6 6 +# Example SQ2.2: +explain SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it2) +AND ot2.a IN (SELECT a FROM it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE it3 NULL ALL NULL NULL NULL NULL 3 100.00 Start temporary +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; Using join buffer (hash join) +1 SIMPLE it2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; Using join buffer (hash join) +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` join `test`.`ot2` semi join (`test`.`it2`) semi join (`test`.`it3`) where ((`test`.`ot2`.`a` = `test`.`it3`.`a`) and (`test`.`it2`.`a` = `test`.`it3`.`a`) and (`test`.`ot1`.`a` = `test`.`it3`.`a`)) +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it2) +AND ot2.a IN (SELECT a FROM it3); +a a +0 0 +6 6 +# More test cases +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it3); +a a +0 0 +6 6 +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it3); +a a +0 0 +6 6 +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a+0 AND ot2.a IN (SELECT a FROM it3); +a a +0 0 +6 6 +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot2.a IN (SELECT a+0 FROM it3); +a a +0 0 +6 6 +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it2) +AND ot2.a IN (SELECT a+0 FROM it3); +a a +0 0 +6 6 +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3) +JOIN ot3 ON ot2.a=ot3.a AND ot3.a IN (SELECT a FROM it3); +a a a +0 0 0 +6 6 6 +# Test cases, Subquery Pattern 3 +# Example SQ3.1: +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 Start temporary +1 SIMPLE it3 NULL ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (hash join) +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` semi join (`test`.`it3`)) on(((`test`.`it3`.`a` = `test`.`ot1`.`a`) and (`test`.`ot2`.`a` = `test`.`ot1`.`a`))) where true +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3); +a a +0 0 +1 NULL +2 NULL +3 NULL +4 NULL +5 NULL +6 6 +7 NULL +# Example SQ3.2: +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot2.a IN (SELECT a FROM it2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 Start temporary +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (hash join) +1 SIMPLE it2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` semi join (`test`.`it2`)) on(((`test`.`ot2`.`a` = `test`.`ot1`.`a`) and (`test`.`it2`.`a` = `test`.`ot1`.`a`))) where true +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot2.a IN (SELECT a FROM it2); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +# Example SQ3.3 +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1) +AND ot2.a IN (SELECT a FROM it2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 Start temporary +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (hash join) +1 SIMPLE it2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (hash join) +1 SIMPLE it1 NULL ALL NULL NULL NULL NULL 8 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` semi join (`test`.`it1`) semi join (`test`.`it2`)) on(((`test`.`ot2`.`a` = `test`.`ot1`.`a`) and (`test`.`it2`.`a` = `test`.`ot1`.`a`) and (`test`.`it1`.`a` = `test`.`ot1`.`a`))) where true +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1) +AND ot2.a IN (SELECT a FROM it2); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +# Example SQ3.4 +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND +(ot1.a, ot2.a) IN (SELECT it1.a, it2.a +FROM it1 JOIN it2 ON it1.a=it2.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 Start temporary +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (hash join) +1 SIMPLE it2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (hash join) +1 SIMPLE it1 NULL ALL NULL NULL NULL NULL 8 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` semi join (`test`.`it1` join `test`.`it2`)) on(((`test`.`ot2`.`a` = `test`.`ot1`.`a`) and (`test`.`it2`.`a` = `test`.`ot1`.`a`) and (`test`.`it1`.`a` = `test`.`ot1`.`a`))) where true +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND +(ot1.a, ot2.a) IN (SELECT it1.a, it2.a +FROM it1 JOIN it2 ON it1.a=it2.a); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +# More test cases +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it3); +a a +0 0 +1 NULL +2 NULL +3 NULL +4 NULL +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it3); +a a +0 0 +1 NULL +2 NULL +3 NULL +4 NULL +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 AND ot2.a IN (SELECT a FROM it2); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot2.a IN (SELECT a+0 FROM it2); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a+0 FROM it1) +AND ot2.a IN (SELECT a+0 FROM it2); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 AND +(ot1.a, ot2.a) IN (SELECT it1.a+0, it2.a+0 +FROM it1 JOIN it2 ON it1.a=it2.a); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +EXPLAIN FORMAT=tree SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3) +LEFT JOIN ot3 ON ot2.a=ot3.a AND ot3.a IN (SELECT a FROM it3); +EXPLAIN +-> Remove duplicate (ot1, ot2, ot3) rows using temporary table (weedout) (cost=88.33 rows=864) + -> Left hash join (ot3.a = ot2.a), (it3.a = ot2.a) (cost=88.33 rows=864) + -> Left hash join (it3.a = ot1.a), (ot2.a = ot1.a) (cost=12.10 rows=96) + -> Table scan on ot1 (cost=1.30 rows=8) + -> Hash + -> Inner hash join (no condition) (cost=2.00 rows=12) + -> Table scan on ot2 (cost=0.11 rows=4) + -> Hash + -> Table scan on it3 (cost=0.30 rows=3) + -> Hash + -> Inner hash join (no condition) (cost=1.43 rows=9) + -> Table scan on it3 (cost=0.03 rows=3) + -> Hash + -> Table scan on ot3 (cost=0.03 rows=3) + +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3) +LEFT JOIN ot3 ON ot2.a=ot3.a AND ot3.a IN (SELECT a FROM it3); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it3) +LEFT JOIN ot3 ON ot2.a=ot3.a+0 AND ot3.a IN (SELECT a FROM it3); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +# Test cases, Subquery Pattern 4 +# Example SQ4.1: +explain SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 Start temporary +1 SIMPLE it1 NULL ALL NULL NULL NULL NULL 8 100.00 Using where; Using join buffer (hash join) +1 SIMPLE ot3 NULL ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (hash join) +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a`,`test`.`ot3`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` join `test`.`ot3` semi join (`test`.`it1`)) on(((`test`.`it1`.`a` = `test`.`ot1`.`a`) and (`test`.`ot3`.`a` = `test`.`ot1`.`a`) and (`test`.`ot2`.`a` = `test`.`ot1`.`a`))) where true +SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +# Example SQ4.2: +explain SELECT * +FROM ot1 +JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot3 NULL ALL NULL NULL NULL NULL 3 100.00 Start temporary +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; Using join buffer (hash join) +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; Using join buffer (hash join) +1 SIMPLE it1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a`,`test`.`ot3`.`a` AS `a` from `test`.`ot1` join `test`.`ot2` join `test`.`ot3` semi join (`test`.`it1`) where ((`test`.`ot2`.`a` = `test`.`ot3`.`a`) and (`test`.`ot1`.`a` = `test`.`ot3`.`a`) and (`test`.`it1`.`a` = `test`.`ot3`.`a`)) +SELECT * +FROM ot1 +JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +6 6 6 +# Example SQ4.3: +explain SELECT * +FROM ot1 +JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Start temporary +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; Using join buffer (hash join) +1 SIMPLE it1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; End temporary; Using join buffer (hash join) +1 SIMPLE ot3 NULL ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a`,`test`.`ot3`.`a` AS `a` from `test`.`ot1` join `test`.`ot2` left join `test`.`ot3` on((`test`.`ot3`.`a` = `test`.`ot2`.`a`)) semi join (`test`.`it1`) where ((`test`.`ot1`.`a` = `test`.`ot2`.`a`) and (`test`.`it1`.`a` = `test`.`ot2`.`a`)) +SELECT * +FROM ot1 +JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +2 2 NULL +4 4 NULL +6 6 6 +# Example SQ4.4: +explain SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 Start temporary +1 SIMPLE it1 NULL ALL NULL NULL NULL NULL 8 100.00 Using where; Using join buffer (hash join) +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (hash join) +1 SIMPLE ot3 NULL ALL NULL NULL NULL NULL 3 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a`,`test`.`ot3`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` left join `test`.`ot3` on((`test`.`ot3`.`a` = `test`.`it1`.`a`)) semi join (`test`.`it1`)) on(((`test`.`it1`.`a` = `test`.`ot1`.`a`) and (`test`.`ot2`.`a` = `test`.`ot1`.`a`))) where true +SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +1 NULL NULL +2 2 NULL +3 NULL NULL +4 4 NULL +5 NULL NULL +6 6 6 +7 NULL NULL +# More test cases +SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a+0) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it1); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 +JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a+0) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +6 6 6 +SELECT * +FROM ot1 +JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +6 6 6 +SELECT * +FROM ot1 +JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it1); +a a a +0 0 0 +6 6 6 +SELECT * +FROM ot1 +JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a+0) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +2 2 NULL +4 4 NULL +6 6 6 +SELECT * +FROM ot1 +JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +2 2 NULL +4 4 NULL +6 6 6 +SELECT * +FROM ot1 +JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it1); +a a a +0 0 0 +2 2 NULL +4 4 NULL +6 6 6 +SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a+0) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +1 NULL NULL +2 2 NULL +3 NULL NULL +4 4 NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +1 NULL NULL +2 2 NULL +3 NULL NULL +4 4 NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it1); +a a a +0 0 0 +1 NULL NULL +2 2 NULL +3 NULL NULL +4 4 NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1) +LEFT JOIN +ot1 AS ot4 +ON ot2.a=ot4.a; +a a a a +0 0 0 0 +1 NULL NULL NULL +2 2 NULL 2 +3 NULL NULL NULL +4 4 NULL 4 +5 NULL NULL NULL +6 6 6 6 +7 NULL NULL NULL +SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a +LEFT JOIN ot1 AS ot4 ON ot3.a=ot4.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a a +0 0 0 0 +1 NULL NULL NULL +2 2 NULL NULL +3 NULL NULL NULL +4 4 NULL NULL +5 NULL NULL NULL +6 6 6 6 +7 NULL NULL NULL +DROP TABLE ot1,ot2,ot3,it1,it2,it3; +CREATE TABLE t ( +a INTEGER DEFAULT NULL +) ENGINE=InnoDB; +INSERT INTO t VALUES (1); +CREATE TABLE t2 ( +a INTEGER DEFAULT NULL +) ENGINE=InnoDB; +INSERT INTO t2 VALUES (1),(1); +CREATE TABLE t4 ( +a INTEGER DEFAULT NULL +) ENGINE=InnoDB; +INSERT INTO t4 VALUES (1),(1); +CREATE TABLE v ( +a INTEGER DEFAULT NULL +) ENGINE=InnoDB; +INSERT INTO v VALUES (1),(1); +explain SELECT * +FROM t AS t1 +LEFT JOIN +(t2 +LEFT JOIN t AS t3 +ON t3.a IN (SELECT a FROM t AS it) +JOIN t4 +ON t4.a=100 +) +ON TRUE +WHERE t1.a IN (SELECT * FROM v AS it2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +2 SIMPLE it2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using join buffer (hash join) +2 SIMPLE it NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t4`.`a` AS `a` from `test`.`t` `t1` left join (`test`.`t2` left join (`test`.`t` `t3` semi join (`test`.`t` `it`)) on(((`test`.`it`.`a` = `test`.`t3`.`a`))) join `test`.`t4`) on(((`test`.`t4`.`a` = 100))) semi join (`test`.`v` `it2`) where (`test`.`it2`.`a` = `test`.`t1`.`a`) +SELECT * +FROM t AS t1 +LEFT JOIN +(t2 +LEFT JOIN t AS t3 +ON t3.a IN (SELECT a FROM t AS it) +JOIN t4 +ON t4.a=100 +) +ON TRUE +WHERE t1.a IN (SELECT * FROM v AS it2); +a a a a +1 NULL NULL NULL +DROP TABLE t,t2,t4,v; +# End of WL#5561 +# +# Bug#48868: Left outer join in subquery causes segmentation fault in +# make_join_select. +# +CREATE TABLE t1 (i INTEGER); +INSERT INTO t1 VALUES (1); +INSERT INTO t1 VALUES (2); +CREATE TABLE t2 (i INTEGER); +INSERT INTO t2 VALUES(1); +CREATE TABLE t3 (i INTEGER); +INSERT INTO t3 VALUES (1); +INSERT INTO t3 VALUES (2); +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t2.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +1 +DROP TABLE t1, t2, t3; + +Bug#37899: Wrongly checked optimization prerequisite caused failed +assertion. + +CREATE TABLE t1 ( +`pk` int(11), +`varchar_nokey` varchar(5) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES +(1,'qk'),(2,'j'),(3,'aew'); +SELECT * +FROM t1 +WHERE varchar_nokey IN ( +SELECT +varchar_nokey +FROM +t1 +) XOR pk = 30; +pk varchar_nokey +1 qk +2 j +3 aew +drop table t1; +# +# BUG#41842: Semi-join materialization strategy crashes when the upper query has HAVING +# +CREATE TABLE t1 ( +pk int(11) NOT NULL AUTO_INCREMENT, +int_nokey int(11) NOT NULL, +time_key time NOT NULL, +datetime_key datetime NOT NULL, +datetime_nokey datetime NOT NULL, +varchar_key varchar(1) NOT NULL, +varchar_nokey varchar(1) NOT NULL, +PRIMARY KEY (pk), +KEY time_key (time_key), +KEY datetime_key (datetime_key), +KEY varchar_key (varchar_key) +) ENGINE=MyISaM; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES +(1,0, '00:16:10','2008-09-03 14:25:40','2008-09-03 14:25:40','h','h'), +(2,7, '00:00:00','2001-01-13 00:00:00','2001-01-13 00:00:00','',''), +(3,0, '00:00:00','0000-00-00 00:00:00','0000-00-00 00:00:00','x','x'), +(4,2, '16:29:24','2000-10-16 01:39:08','2000-10-16 01:39:08','w','w'), +(5,1, '09:23:32','0000-00-00 00:00:00','0000-00-00 00:00:00','p','p'), +(6,3, '00:00:00','2007-12-02 00:00:00','2007-12-02 00:00:00','o','o'), +(7,3, '00:00:00','2008-09-11 00:00:00','2008-09-11 00:00:00','',''), +(8,0, '13:59:04','0000-00-00 00:00:00','0000-00-00 00:00:00','s','s'), +(9,7, '09:01:06','0000-00-00 00:00:00','0000-00-00 00:00:00','d','d'), +(10,5,'00:00:00','0000-00-00 00:00:00','0000-00-00 00:00:00','n','n'), +(11,0,'21:06:46','0000-00-00 00:00:00','0000-00-00 00:00:00','o','o'), +(12,2,'00:00:00','0000-00-00 00:00:00','0000-00-00 00:00:00','',''), +(13,6,'14:45:34','2003-07-28 02:34:08','2003-07-28 02:34:08','w','w'), +(14,1,'15:04:12','0000-00-00 00:00:00','0000-00-00 00:00:00','o','o'), +(15,0,'00:00:00','0000-00-00 00:00:00','0000-00-00 00:00:00','x','x'), +(16,0,'15:55:23','2004-03-17 00:32:27','2004-03-17 00:32:27','p','p'), +(17,1,'16:30:00','2004-12-27 19:20:00','2004-12-27 19:20:00','d','d'), +(18,0,'00:00:00','0000-00-00 00:00:00','0000-00-00 00:00:00','h','h'), +(19,0,'14:13:26','2008-11-09 05:53:48','2008-11-09 05:53:48','o','o'), +(20,0,'00:00:00','2009-10-11 06:58:04','2009-10-11 06:58:04','k','k'); +Warnings: +Warning 1264 Out of range value for column 'datetime_key' at row 3 +Warning 1264 Out of range value for column 'datetime_nokey' at row 3 +Warning 1264 Out of range value for column 'datetime_key' at row 5 +Warning 1264 Out of range value for column 'datetime_nokey' at row 5 +Warning 1264 Out of range value for column 'datetime_key' at row 8 +Warning 1264 Out of range value for column 'datetime_nokey' at row 8 +Warning 1264 Out of range value for column 'datetime_key' at row 9 +Warning 1264 Out of range value for column 'datetime_nokey' at row 9 +Warning 1264 Out of range value for column 'datetime_key' at row 10 +Warning 1264 Out of range value for column 'datetime_nokey' at row 10 +Warning 1264 Out of range value for column 'datetime_key' at row 11 +Warning 1264 Out of range value for column 'datetime_nokey' at row 11 +Warning 1264 Out of range value for column 'datetime_key' at row 12 +Warning 1264 Out of range value for column 'datetime_nokey' at row 12 +Warning 1264 Out of range value for column 'datetime_key' at row 14 +Warning 1264 Out of range value for column 'datetime_nokey' at row 14 +Warning 1264 Out of range value for column 'datetime_key' at row 15 +Warning 1264 Out of range value for column 'datetime_nokey' at row 15 +Warning 1264 Out of range value for column 'datetime_key' at row 18 +Warning 1264 Out of range value for column 'datetime_nokey' at row 18 +CREATE TABLE t2 ( +pk int(11) NOT NULL AUTO_INCREMENT, +int_nokey int(11) NOT NULL, +time_key time NOT NULL, +datetime_key datetime NOT NULL, +datetime_nokey datetime NOT NULL, +varchar_key varchar(1) NOT NULL, +varchar_nokey varchar(1) NOT NULL, +PRIMARY KEY (pk), +KEY time_key (time_key), +KEY datetime_key (datetime_key), +KEY varchar_key (varchar_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT IGNORE INTO t2 VALUES +(10,0,'19:39:13','0000-00-00 00:00:00','0000-00-00 00:00:00','g','g'), +(11,8,'03:43:53','0000-00-00 00:00:00','0000-00-00 00:00:00','b','b'); +Warnings: +Warning 1264 Out of range value for column 'datetime_key' at row 1 +Warning 1264 Out of range value for column 'datetime_nokey' at row 1 +Warning 1264 Out of range value for column 'datetime_key' at row 2 +Warning 1264 Out of range value for column 'datetime_nokey' at row 2 +SELECT OUTR.datetime_nokey AS X FROM t1 AS OUTR +WHERE +OUTR.varchar_nokey IN (SELECT +INNR . varchar_nokey AS Y +FROM t2 AS INNR +WHERE +INNR . datetime_key >= INNR . time_key OR +INNR . pk = INNR . int_nokey +) +AND OUTR . varchar_nokey <= 'w' +HAVING X > '2012-12-12'; +X +drop table t1, t2; + +Bug#46797 "Crash in fix_semijoin_strategies_for_picked_join_order +with semijoin=on" + +CREATE TABLE t1 ( +varchar_key varchar(1) DEFAULT NULL, +KEY varchar_key (varchar_key) +); +CREATE TABLE t2 ( +varchar_key varchar(1) DEFAULT NULL, +KEY varchar_key (varchar_key) +); +INSERT INTO t2 VALUES +(NULL),(NULL),(NULL),(NULL),('a'),('a'),('a'),('b'),('b'),('b'),('b'),('c'), +('c'),('c'),('c'),('c'),('c'),('c'),('d'),('d'),('d'),('d'),('d'),('d'),('e'), +('e'),('e'),('e'),('e'),('e'),('f'),('f'),('f'),('g'),('g'),('h'),('h'),('h'), +('h'),('i'),('j'),('j'),('j'),('k'),('k'),('l'),('l'),('m'),('m'),('m'),('m'), +('n'),('n'),('n'),('o'),('o'),('o'),('p'),('p'),('p'),('q'),('q'),('q'),('r'), +('r'),('r'),('r'),('s'),('s'),('s'),('s'),('t'),('t'),('t'),('t'),('u'),('u'), +('u'),('u'),('v'),('v'),('v'),('v'),('w'),('w'),('w'),('w'),('w'),('w'),('x'), +('x'),('x'),('y'),('y'),('y'),('y'),('z'),('z'),('z'),('z'); +CREATE TABLE t3 ( +varchar_key varchar(1) DEFAULT NULL, +KEY varchar_key (varchar_key) +) ENGINE=MyISAM DEFAULT CHARSET=latin1; +INSERT INTO t3 VALUES +(NULL),('c'),('d'),('e'),('f'),('h'),('j'),('k'),('k'),('m'),('m'),('m'), +('n'),('o'),('r'),('t'),('t'),('u'),('w'),('y'); +SELECT varchar_key FROM t3 +WHERE (SELECT varchar_key FROM t3 +WHERE (varchar_key,varchar_key) +IN (SELECT t1.varchar_key, t2 .varchar_key +FROM t1 RIGHT JOIN t2 ON t1.varchar_key +) +); +varchar_key +DROP TABLE t1, t2, t3; +# +# Bug#46556 Returning incorrect, empty results for some IN subqueries +# w/semijoin=on +# +CREATE TABLE t0 ( +pk INTEGER, +vkey VARCHAR(1), +vnokey VARCHAR(1), +PRIMARY KEY (pk), +KEY vkey(vkey) +) charset utf8mb4; +INSERT INTO t0 +VALUES (1,'g','g'), (2,'v','v'), (3,'t','t'), (4,'u','u'), (5,'n','n'); +EXPLAIN SELECT vkey FROM t0 WHERE pk IN +(SELECT t1.pk FROM t0 t1 JOIN t0 t2 ON t2.vkey = t1.vnokey); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index vkey vkey 7 NULL 5 100.00 Using index; Start temporary +1 SIMPLE t1 NULL ALL PRIMARY NULL NULL NULL 5 20.00 Using where; Using join buffer (hash join) +1 SIMPLE t0 NULL eq_ref PRIMARY PRIMARY 4 test.t1.pk 1 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`vkey` AS `vkey` from `test`.`t0` `t1` join `test`.`t0` semi join (`test`.`t0` `t2`) where ((`test`.`t1`.`vnokey` = `test`.`t2`.`vkey`) and (`test`.`t0`.`pk` = `test`.`t1`.`pk`)) +SELECT vkey FROM t0 WHERE pk IN +(SELECT t1.pk FROM t0 t1 JOIN t0 t2 ON t2.vkey = t1.vnokey); +vkey +g +n +t +u +v +DROP TABLE t0; +# End of bug#46556 + +Bug#48834: Procedure with view + subquery + semijoin=on +crashes on second call. + +CREATE TABLE t1 ( t1field integer, primary key (t1field)); +CREATE TABLE t2 ( t2field integer, primary key (t2field)); +CREATE VIEW v1 AS +SELECT t1field as v1field +FROM t1 A +WHERE A.t1field IN (SELECT t1field FROM t2 ); +CREATE VIEW v2 AS +SELECT t2field as v2field +FROM t2 A +WHERE A.t2field IN (SELECT t2field FROM t2 ); +CREATE PROCEDURE p1 () +BEGIN +SELECT v1field +FROM v1 +WHERE v1field IN ( SELECT v2field as vf_inner FROM v2 ); +END| +INSERT INTO t1 VALUES (1),(2),(3); +INSERT INTO t2 VALUES (2),(3),(4); +CALL p1; +v1field +2 +3 +CALL p1; +v1field +2 +3 +DROP TABLE t1,t2; +DROP VIEW v1,v2; +DROP PROCEDURE p1; +# End of BUG#48834 +# +# Bug#46692 "Crash occurring on queries with nested FROM subqueries +# using materialization." +# +CREATE TABLE t1 ( +pk INTEGER PRIMARY KEY, +int_key INTEGER, +KEY int_key(int_key) +); +INSERT INTO t1 VALUES (10,186),(11,NULL),(12,2),(13,3),(14,0),(15,133),(16,1); +CREATE TABLE t2 ( +pk INTEGER PRIMARY KEY, +int_key INTEGER, +KEY int_key(int_key) +); +INSERT INTO t2 VALUES (1,7),(2,2); +SELECT * FROM t1 WHERE (140, 4) IN +(SELECT t2.int_key, t2 .pk FROM t2 STRAIGHT_JOIN t1 ON t2.int_key); +pk int_key +DROP TABLE t1, t2; +# +# Bug#42353 "SELECT ... WHERE oe IN (SELECT w/ LEFT JOIN) query +# causes crash." +# +CREATE TABLE t1 ( +pk INTEGER PRIMARY KEY, +int_nokey INTEGER, +int_key INTEGER, +date_key DATE, +datetime_nokey DATETIME, +varchar_nokey VARCHAR(1) +); +CREATE TABLE t2 ( +date_nokey DATE +); +CREATE TABLE t3 ( +pk INTEGER PRIMARY KEY, +int_nokey INTEGER, +date_key date, +varchar_key VARCHAR(1), +varchar_nokey VARCHAR(1), +KEY date_key (date_key) +); +SELECT date_key FROM t1 +WHERE (int_key, int_nokey) +IN (SELECT t3.int_nokey, t3.pk +FROM t2 LEFT JOIN t3 ON (t2.date_nokey < t3.date_key) +WHERE t3.varchar_key <= t3.varchar_nokey OR t3.int_nokey <= t3.pk +) +AND (varchar_nokey <> 'f' OR NOT int_key < 7); +date_key +# +# Bug#45933 "Crash in optimize_semijoin_nests on JOIN in subquery +# + AND in outer query". +# +INSERT INTO t1 VALUES (10,7,5,'2009-06-16','2002-04-10 14:25:30','w'), +(11,7,0,'0000-00-00','0000-00-00 00:00:00','s'), +(12,4,0,'2003-07-14','2006-09-14 04:01:02','y'), +(13,0,4,'2002-07-25','0000-00-00 00:00:00','c'), +(14,1,8,'2007-07-03','0000-00-00 00:00:00','q'), +(15,6,5,'2001-11-12','0000-00-00 00:00:00',''), +(16,2,9,'0000-00-00','0000-00-00 00:00:00','j'), +(29,9,1,'0000-00-00','2003-08-11 00:00:00','m'); +Warnings: +Warning 1264 Out of range value for column 'date_key' at row 2 +Warning 1264 Out of range value for column 'datetime_nokey' at row 2 +Warning 1264 Out of range value for column 'datetime_nokey' at row 4 +Warning 1264 Out of range value for column 'datetime_nokey' at row 5 +Warning 1264 Out of range value for column 'datetime_nokey' at row 6 +Warning 1264 Out of range value for column 'date_key' at row 7 +Warning 1264 Out of range value for column 'datetime_nokey' at row 7 +Warning 1264 Out of range value for column 'date_key' at row 8 +INSERT IGNORE INTO t3 VALUES (1,9,'0000-00-00','b','b'), +(2,2,'2002-09-17','h','h'); +Warnings: +Warning 1264 Out of range value for column 'date_key' at row 1 +SELECT t1.varchar_nokey FROM t1 JOIN t3 ON t1.datetime_nokey +WHERE t1.varchar_nokey +IN (SELECT varchar_nokey FROM t1 +WHERE (pk) +IN (SELECT t3.int_nokey +FROM t3 LEFT JOIN t1 ON t1.varchar_nokey +WHERE t3.date_key BETWEEN '2008-06-07' AND '2006-06-26' + ) +); +varchar_nokey +DROP TABLE t1, t2, t3; +# +# Bug#45219 "Crash on SELECT DISTINCT query containing a +# LEFT JOIN in subquery" +# +CREATE TABLE t1 ( +pk INTEGER NOT NULL, +int_nokey INTEGER NOT NULL, +datetime_key DATETIME NOT NULL, +varchar_key VARCHAR(1) NOT NULL, +PRIMARY KEY (pk), +KEY datetime_key (datetime_key), +KEY varchar_key (varchar_key) +); +INSERT IGNORE INTO t1 VALUES +(1,9,'0000-00-00 00:00:00','p'),(2,0,'2002-02-09 07:38:13','v'), +(3,8,'2001-05-03 12:08:14','t'),(4,3,'0000-00-00 00:00:00','u'), +(5,7,'2009-07-28 03:43:30','n'),(6,0,'2009-08-04 00:00:00','l'), +(7,1,'0000-00-00 00:00:00','h'),(8,9,'0000-00-00 00:00:00','u'), +(9,0,'2005-08-02 17:16:54','n'),(10,9,'2002-12-21 00:00:00','j'), +(11,0,'2005-08-15 12:37:35','k'),(12,5,'0000-00-00 00:00:00','e'), +(13,0,'2006-03-10 00:00:00','i'),(14,8,'2005-05-16 11:02:36','u'), +(15,8,'2008-11-02 00:00:00','n'),(16,5,'2006-03-15 00:00:00','b'), +(17,1,'0000-00-00 00:00:00','x'),(18,7,'0000-00-00 00:00:00',''), +(19,0,'2008-12-17 20:15:40','q'),(20,9,'0000-00-00 00:00:00','u'); +Warnings: +Warning 1264 Out of range value for column 'datetime_key' at row 1 +Warning 1264 Out of range value for column 'datetime_key' at row 4 +Warning 1264 Out of range value for column 'datetime_key' at row 7 +Warning 1264 Out of range value for column 'datetime_key' at row 8 +Warning 1264 Out of range value for column 'datetime_key' at row 12 +Warning 1264 Out of range value for column 'datetime_key' at row 17 +Warning 1264 Out of range value for column 'datetime_key' at row 18 +Warning 1264 Out of range value for column 'datetime_key' at row 20 +CREATE TABLE t2 LIKE t1; +INSERT INTO t2 VALUES +(10,0,'2006-07-07 07:26:28','q'),(11,5,'2002-09-23 00:00:00','m'), +(12,7,'0000-00-00 00:00:00','j'),(13,1,'2006-06-07 00:00:00','z'), +(14,8,'2000-09-16 12:15:34','a'),(15,2,'2007-08-05 15:47:52',''), +(16,1,'0000-00-00 00:00:00','e'),(17,8,'2005-12-02 19:34:26','t'), +(18,5,'0000-00-00 00:00:00','q'),(19,4,'0000-00-00 00:00:00','b'), +(20,5,'2007-12-28 00:00:00','w'),(21,3,'2004-08-02 11:48:43','m'), +(22,0,'0000-00-00 00:00:00','x'),(23,8,'2004-04-19 12:18:43',''), +(24,0,'2009-04-27 00:00:00','w'),(25,4,'2006-10-20 14:52:15','x'), +(26,0,'0000-00-00 00:00:00','e'),(27,0,'2002-03-22 11:48:37','e'), +(28,2,'0000-00-00 00:00:00','p'),(29,0,'2001-01-04 03:55:07','x'); +Warnings: +Warning 1264 Out of range value for column 'datetime_key' at row 3 +Warning 1264 Out of range value for column 'datetime_key' at row 7 +Warning 1264 Out of range value for column 'datetime_key' at row 9 +Warning 1264 Out of range value for column 'datetime_key' at row 10 +Warning 1264 Out of range value for column 'datetime_key' at row 13 +Warning 1264 Out of range value for column 'datetime_key' at row 17 +Warning 1264 Out of range value for column 'datetime_key' at row 19 +CREATE TABLE t3 LIKE t1; +INSERT INTO t3 VALUES +(10,8,'2007-08-19 08:08:38','i'),(11,0,'2000-05-21 03:51:51',''); +SELECT DISTINCT datetime_key FROM t1 +WHERE (int_nokey, pk) +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#46550 Azalea returning duplicate results for some IN subqueries +# w/ semijoin=on +# +DROP TABLE IF EXISTS t0, t1, t2; +CREATE TABLE t0 ( +int_key int(11) DEFAULT NULL, +varchar_key varchar(1) DEFAULT NULL, +varchar_nokey varchar(1) DEFAULT NULL, +KEY int_key (int_key), +KEY varchar_key (varchar_key,int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t0 VALUES +(1,'m','m'), +(40,'h','h'), +(1,'r','r'), +(1,'h','h'), +(9,'x','x'), +(NULL,'q','q'), +(NULL,'k','k'), +(7,'l','l'), +(182,'k','k'), +(202,'a','a'), +(7,'x','x'), +(6,'j','j'), +(119,'z','z'), +(4,'d','d'), +(5,'h','h'), +(1,'u','u'), +(3,'q','q'), +(7,'a','a'), +(3,'e','e'), +(6,'l','l'); +CREATE TABLE t1 ( +int_key int(11) DEFAULT NULL, +varchar_key varchar(1) DEFAULT NULL, +varchar_nokey varchar(1) DEFAULT NULL, +KEY int_key (int_key), +KEY varchar_key (varchar_key,int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (7,NULL,NULL),(4,'x','x'); +CREATE TABLE t2 ( +int_key int(11) DEFAULT NULL, +varchar_key varchar(1) DEFAULT NULL, +varchar_nokey varchar(1) DEFAULT NULL, +KEY int_key (int_key), +KEY varchar_key (varchar_key,int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (123,NULL,NULL); +SELECT int_key +FROM t0 +WHERE varchar_nokey IN ( +SELECT t1 .varchar_key from t1 +); +int_key +7 +9 +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 +7 +9 +EXPLAIN +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 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1_1 NULL index varchar_key varchar_key 12 NULL 2 50.00 Using where; Using index; Start temporary +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 20 10.00 Using where; Using join buffer (hash join) +1 SIMPLE t1_2 NULL index NULL int_key 5 NULL 2 100.00 Using index; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`int_key` AS `int_key` from `test`.`t0` semi join (`test`.`t1` `t1_1` join `test`.`t1` `t1_2`) where ((`test`.`t0`.`varchar_nokey` = `test`.`t1_1`.`varchar_key`) and (0 <> `test`.`t1_1`.`int_key`)) +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 +7 +9 +EXPLAIN +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 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t1_1 NULL index varchar_key varchar_key 12 NULL 2 50.00 Using where; Using index; Start temporary +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 20 10.00 Using where; Using join buffer (hash join) +1 SIMPLE t1_2 NULL index NULL int_key 5 NULL 2 100.00 Using index; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`int_key` AS `int_key` from `test`.`t0` semi join (`test`.`t1` `t1_1` join `test`.`t1` `t1_2`) where ((`test`.`t0`.`varchar_nokey` = `test`.`t1_1`.`varchar_key`) and (0 <> `test`.`t1_1`.`int_key`)) +DROP TABLE t0, t1, t2; +# End of bug#46550 + +Bug #48073 Subquery on char columns from view crashes Mysql + +DROP TABLE IF EXISTS t1, t2; +DROP VIEW IF EXISTS v1; +CREATE TABLE t1 ( +city VARCHAR(50) NOT NULL, +country_id SMALLINT UNSIGNED NOT NULL +); +INSERT INTO t1 VALUES +('Batna',2), +('Bchar',2), +('Skikda',2), +('Tafuna',3), +('Algeria',2) ; +CREATE TABLE t2 ( +country_id SMALLINT UNSIGNED NOT NULL, +country VARCHAR(50) NOT NULL +); +INSERT INTO t2 VALUES +(2,'Algeria'), +(3,'American Samoa') ; +CREATE VIEW v1 AS +SELECT country_id, country +FROM t2 +WHERE LEFT(country,1) = "A" +; +SELECT city, country_id +FROM t1 +WHERE city IN ( +SELECT country +FROM t2 +WHERE LEFT(country, 1) = "A" +); +city country_id +Algeria 2 +SELECT city, country_id +FROM t1 +WHERE city IN ( +SELECT country +FROM v1 +); +city country_id +Algeria 2 +drop table t1, t2; +drop view v1; +# End of bug#48073 + +Bug#49097 subquery with view generates wrong result with +non-prepared statement + +DROP TABLE IF EXISTS t1, t2; +DROP VIEW IF EXISTS v1; +CREATE TABLE t1 ( +city VARCHAR(50) NOT NULL, +country_id SMALLINT UNSIGNED NOT NULL +); +INSERT INTO t1 VALUES +('Batna',2), +('Bchar',2), +('Skikda',2), +('Tafuna',3), +('Algeria',2) ; +CREATE TABLE t2 ( +country_id SMALLINT UNSIGNED NOT NULL, +country VARCHAR(50) NOT NULL +); +INSERT INTO t2 VALUES +(2,'Algeria'), +(3,'XAmerican Samoa') ; +CREATE VIEW v1 AS +SELECT country_id, country +FROM t2 +WHERE LEFT(country,1) = "A" +; +SELECT city, country_id +FROM t1 +WHERE country_id IN ( +SELECT country_id +FROM t2 +WHERE LEFT(country,1) = "A" +); +city country_id +Algeria 2 +Batna 2 +Bchar 2 +Skikda 2 +SELECT city, country_id +FROM t1 +WHERE country_id IN ( +SELECT country_id +FROM v1 +); +city country_id +Algeria 2 +Batna 2 +Bchar 2 +Skikda 2 +PREPARE stmt FROM +" +SELECT city, country_id +FROM t1 +WHERE country_id IN ( + SELECT country_id + FROM v1 +); +"; +execute stmt; +city country_id +Algeria 2 +Batna 2 +Bchar 2 +Skikda 2 +deallocate prepare stmt; +drop table t1, t2; +drop view v1; +# End of Bug#49097 +# +# Bug#49198 Wrong result for second call of procedure +# with view in subselect. +# +CREATE TABLE t1 (t1field integer, primary key (t1field)); +CREATE TABLE t2 (t2field integer, primary key (t2field)); +CREATE TABLE t3 (t3field integer, primary key (t3field)); +CREATE VIEW v2 AS SELECT * FROM t2; +CREATE VIEW v3 AS SELECT * FROM t3; +INSERT INTO t1 VALUES(1),(2); +INSERT INTO t2 VALUES(1),(2); +INSERT INTO t3 VALUES(1),(2); +PREPARE stmt FROM +" +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT * FROM v2); +"; +EXECUTE stmt; +t1field +1 +2 + +EXECUTE stmt; +t1field +1 +2 +PREPARE stmt FROM +" +EXPLAIN +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT * FROM v2) + AND t1field IN (SELECT * FROM v3) +"; +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index PRIMARY PRIMARY 4 NULL 2 100.00 Using index +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +1 SIMPLE t3 NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`t1field` AS `t1field` from `test`.`t2` join `test`.`t3` join `test`.`t1` where ((`test`.`t2`.`t2field` = `test`.`t1`.`t1field`) and (`test`.`t3`.`t3field` = `test`.`t1`.`t1field`)) + +This line is only in place to help --skip_if_hypergraph diffing some more. + +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index PRIMARY PRIMARY 4 NULL 2 100.00 Using index +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +1 SIMPLE t3 NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`t1field` AS `t1field` from `test`.`t2` join `test`.`t3` join `test`.`t1` where ((`test`.`t2`.`t2field` = `test`.`t1`.`t1field`) and (`test`.`t3`.`t3field` = `test`.`t1`.`t1field`)) +DROP TABLE t1, t2, t3; +DROP VIEW v2, v3; +# End of Bug#49198 +# +# Bug#48623 Multiple subqueries are optimized incorrectly +# +CREATE TABLE ot(val VARCHAR(10)) charset utf8mb4; +CREATE TABLE it1(val VARCHAR(10)) charset utf8mb4; +CREATE TABLE it2(val VARCHAR(10)) charset utf8mb4; +INSERT INTO ot VALUES('aaa'), ('bbb'), ('eee'), ('mmm'), ('ppp'); +INSERT INTO it1 VALUES('aaa'), ('aaa'), ('bbb'), ('eee'), ('mmm'), ('ppp'); +INSERT INTO it2 VALUES('aaa'), ('bbb'), ('eee'), ('mmm'), ('ppp'); +EXPLAIN +SELECT * +FROM ot +WHERE ot.val IN (SELECT it1.val FROM it1 +WHERE it1.val LIKE 'a%' OR it1.val LIKE 'e%') +AND ot.val IN (SELECT it2.val FROM it2 +WHERE it2.val LIKE 'a%' OR it2.val LIKE 'e%'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE it2 NULL ALL NULL NULL NULL NULL 5 36.00 Using where; Start temporary +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 5 20.00 Using where; Using join buffer (hash join) +1 SIMPLE it1 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot`.`val` AS `val` from `test`.`ot` semi join (`test`.`it1`) semi join (`test`.`it2`) where ((`test`.`ot`.`val` = `test`.`it2`.`val`) and (`test`.`it1`.`val` = `test`.`it2`.`val`) and ((`test`.`it1`.`val` like 'a%') or (`test`.`it1`.`val` like 'e%')) and ((`test`.`it2`.`val` like 'a%') or (`test`.`it2`.`val` like 'e%'))) +SELECT * +FROM ot +WHERE ot.val IN (SELECT it1.val FROM it1 +WHERE it1.val LIKE 'a%' OR it1.val LIKE 'e%') +AND ot.val IN (SELECT it2.val FROM it2 +WHERE it2.val LIKE 'a%' OR it2.val LIKE 'e%'); +val +aaa +eee +DROP TABLE ot; +DROP TABLE it1; +DROP TABLE it2; +# End of Bug#48623 +# +# Bug #51487 Assertion failure when semi-join flattening occurs +# for a subquery in HAVING +# +CREATE TABLE t1 (a INT, b INT); +INSERT INTO t1 VALUES (1,10),(2,11),(1,13); +CREATE TABLE t2 AS SELECT * FROM t1; +CREATE TABLE t3 AS SELECT * FROM t1; +SELECT COUNT(*) FROM t1 +GROUP BY t1.a +HAVING t1.a IN (SELECT t3.a FROM t3 +WHERE t3.b IN (SELECT b FROM t2 WHERE t2.a=t1.a)); +COUNT(*) +2 +1 +DROP TABLE t1, t2, t3; +# End of Bug#51487 +# +# BUG#38075: Wrong result: rows matching a subquery with outer join not returned +# +DROP TABLE IF EXISTS ot1, it1, it2; +CREATE TABLE it2 ( +int_key int(11) NOT NULL, +datetime_key datetime NOT NULL, +KEY int_key (int_key), +KEY datetime_key (datetime_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO it2 VALUES +(5,'2002-04-10 14:25:30'), (0,'0000-00-00 00:00:00'), +(0,'2006-09-14 04:01:02'), (4,'0000-00-00 00:00:00'), +(8,'0000-00-00 00:00:00'), (5,'0000-00-00 00:00:00'), +(9,'0000-00-00 00:00:00'), (8,'2007-04-01 11:04:17'), +(1,'0000-00-00 00:00:00'), (7,'2009-01-12 00:00:00'), +(0,'2009-06-05 00:00:00'), (3,'2006-02-14 18:06:35'), +(5,'2006-02-21 07:08:16'), (0,'0000-00-00 00:00:00'), +(7,'0000-00-00 00:00:00'), (0,'0000-00-00 00:00:00'), +(0,'2007-02-13 00:00:00'), (1,'0000-00-00 00:00:00'), +(0,'0000-00-00 00:00:00'), (1,'2003-08-11 00:00:00'); +Warnings: +Warning 1264 Out of range value for column 'datetime_key' at row 2 +Warning 1264 Out of range value for column 'datetime_key' at row 4 +Warning 1264 Out of range value for column 'datetime_key' at row 5 +Warning 1264 Out of range value for column 'datetime_key' at row 6 +Warning 1264 Out of range value for column 'datetime_key' at row 7 +Warning 1264 Out of range value for column 'datetime_key' at row 9 +Warning 1264 Out of range value for column 'datetime_key' at row 14 +Warning 1264 Out of range value for column 'datetime_key' at row 15 +Warning 1264 Out of range value for column 'datetime_key' at row 16 +Warning 1264 Out of range value for column 'datetime_key' at row 18 +Warning 1264 Out of range value for column 'datetime_key' at row 19 +CREATE TABLE ot1 ( +int_nokey int(11) NOT NULL, +int_key int(11) NOT NULL, +KEY int_key (int_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO ot1 VALUES +(5,0), (3,0), (0,2), (3,0), (1,3), (0,0), (1,7), (7,0), (1,7), (0,7), +(0,9), (8,2), (4,4), (9,3), (0,9), (2,5), (0,5), (8,0), (5,8), (1,5); +CREATE TABLE it1 ( +int_nokey int(11) NOT NULL, +int_key int(11) NOT NULL, +KEY int_key (int_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO it1 VALUES +(9,5), (0,4); +SELECT int_key FROM ot1 +WHERE int_nokey IN (SELECT it2.int_key +FROM it1 LEFT JOIN it2 ON it2.datetime_key); +int_key +0 +0 +0 +0 +0 +0 +2 +2 +3 +5 +5 +7 +7 +7 +8 +9 +9 +EXPLAIN +SELECT int_key FROM ot1 +WHERE int_nokey IN (SELECT it2.int_key +FROM it1 LEFT JOIN it2 ON it2.datetime_key); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE it1 NULL index NULL int_key 4 NULL 2 100.00 Using index; Start temporary +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 20 100.00 Using join buffer (hash join) +1 SIMPLE it2 NULL ref int_key int_key 4 test.ot1.int_nokey 2 90.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`int_key` AS `int_key` from `test`.`ot1` semi join (`test`.`it1` join `test`.`it2`) where ((`test`.`it2`.`int_key` = `test`.`ot1`.`int_nokey`) and (TIMESTAMP'0000-00-00 00:00:00' <> `test`.`it2`.`datetime_key`)) +DROP TABLE ot1, it1, it2; +# End of BUG#38075 +# +# BUG#50089: Second call of procedure with view in subselect crashes server +# +CREATE TABLE t1(t1field INTEGER, PRIMARY KEY(t1field)); +CREATE VIEW v1 AS +SELECT t1field AS v1field +FROM t1 a +WHERE a.t1field IN (SELECT t1field FROM t1); +INSERT INTO t1 VALUES(1),(2); +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT v1field FROM v1); +t1field +1 +2 +EXPLAIN +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT v1field FROM v1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index PRIMARY PRIMARY 4 NULL 2 100.00 Using index +1 SIMPLE a NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `t1`.`t1field` AS `t1field` from `test`.`t1` `a` join `test`.`t1` join `test`.`t1` where ((`test`.`a`.`t1field` = `t1`.`t1field`) and (`test`.`t1`.`t1field` = `t1`.`t1field`)) +SELECT t1.t1field +FROM t1 LEFT JOIN t1 AS t2 ON t1.t1field IN (SELECT v1field FROM v1); +t1field +1 +1 +2 +2 +EXPLAIN +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT v1field FROM v1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index PRIMARY PRIMARY 4 NULL 2 100.00 Using index +1 SIMPLE a NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `t1`.`t1field` AS `t1field` from `test`.`t1` `a` join `test`.`t1` join `test`.`t1` where ((`test`.`a`.`t1field` = `t1`.`t1field`) and (`test`.`t1`.`t1field` = `t1`.`t1field`)) +CREATE PROCEDURE p1() +BEGIN +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT v1field FROM v1); +END| +CALL p1; +t1field +1 +2 +CALL p1; +t1field +1 +2 +PREPARE stmt FROM +" +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT v1field FROM v1); +"; +EXECUTE stmt; +t1field +1 +2 + +EXECUTE stmt; +t1field +1 +2 +DROP PROCEDURE p1; +DROP VIEW v1; +DROP TABLE t1; +# End of BUG#50089 +# +# Bug#45191: Incorrectly initialized semi-join led to a wrong result. +# +CREATE TABLE staff (EMPNUM CHAR(3) NOT NULL, +EMPNAME CHAR(20), GRADE DECIMAL(4), CITY CHAR(15)) charset latin1; +CREATE TABLE proj (PNUM CHAR(3) NOT NULL, +PNAME CHAR(20), PTYPE CHAR(6), +BUDGET DECIMAL(9), +CITY CHAR(15)) charset latin1; +CREATE TABLE works (EMPNUM CHAR(3) NOT NULL, +PNUM CHAR(3) NOT NULL, HOURS DECIMAL(5)) charset latin1; +INSERT INTO staff VALUES ('E1','Alice',12,'Deale'); +INSERT INTO staff VALUES ('E2','Betty',10,'Vienna'); +INSERT INTO staff VALUES ('E3','Carmen',13,'Vienna'); +INSERT INTO staff VALUES ('E4','Don',12,'Deale'); +INSERT INTO staff VALUES ('E5','Ed',13,'Akron'); +INSERT INTO proj VALUES ('P1','MXSS','Design',10000,'Deale'); +INSERT INTO proj VALUES ('P2','CALM','Code',30000,'Vienna'); +INSERT INTO proj VALUES ('P3','SDP','Test',30000,'Tampa'); +INSERT INTO proj VALUES ('P4','SDP','Design',20000,'Deale'); +INSERT INTO proj VALUES ('P5','IRM','Test',10000,'Vienna'); +INSERT INTO proj VALUES ('P6','PAYR','Design',50000,'Deale'); +INSERT INTO works VALUES ('E1','P1',40); +INSERT INTO works VALUES ('E1','P2',20); +INSERT INTO works VALUES ('E1','P3',80); +INSERT INTO works VALUES ('E1','P4',20); +INSERT INTO works VALUES ('E1','P5',12); +INSERT INTO works VALUES ('E1','P6',12); +INSERT INTO works VALUES ('E2','P1',40); +INSERT INTO works VALUES ('E2','P2',80); +INSERT INTO works VALUES ('E3','P2',20); +INSERT INTO works VALUES ('E4','P2',20); +INSERT INTO works VALUES ('E4','P4',40); +INSERT INTO works VALUES ('E4','P5',80); +explain SELECT EMPNUM, EMPNAME +FROM staff +WHERE EMPNUM IN +(SELECT EMPNUM FROM works +WHERE PNUM IN +(SELECT PNUM FROM proj)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE staff NULL ALL NULL NULL NULL NULL 5 100.00 Start temporary +1 SIMPLE works NULL ALL NULL NULL NULL NULL 12 10.00 Using where; Using join buffer (hash join) +1 SIMPLE proj NULL ALL NULL NULL NULL NULL 6 16.67 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`staff`.`EMPNUM` AS `EMPNUM`,`test`.`staff`.`EMPNAME` AS `EMPNAME` from `test`.`staff` semi join (`test`.`works` join `test`.`proj`) where ((`test`.`works`.`EMPNUM` = `test`.`staff`.`EMPNUM`) and (`test`.`proj`.`PNUM` = `test`.`works`.`PNUM`)) +SELECT EMPNUM, EMPNAME +FROM staff +WHERE EMPNUM IN +(SELECT EMPNUM FROM works +WHERE PNUM IN +(SELECT PNUM FROM proj)); +EMPNUM EMPNAME +E1 Alice +E2 Betty +E3 Carmen +E4 Don +drop table staff,works,proj; +# End of bug#45191 +# +# BUG#36896: Server crash on SELECT FROM DUAL +# +create table t1 (a int); +select 1 as res from dual where (1) in (select * from t1); +res +drop table t1; + +BUG#40118 Crash when running Batched Key Access and requiring one match for each key + +create table t0(a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (a int, key(a)); +insert into t1 select * from t0; +alter table t1 add b int not null, add filler char(200); +insert into t1 select * from t1; +insert into t1 select * from t1; +select * from t0 where t0.a in (select t1.a from t1 where t1.b=0); +a +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +drop table t0, t1; +# +# BUG#32665 Query with dependent subquery is too slow +# +create table t1 ( +idIndividual int primary key +); +insert into t1 values (1),(2); +create table t2 ( +idContact int primary key, +contactType int, +idObj int +); +insert into t2 values (1,1,1),(2,2,2),(3,3,3); +create table t3 ( +idAddress int primary key, +idContact int, +postalStripped varchar(100) +); +insert into t3 values (1,1, 'foo'), (2,2,'bar'); +The following must be converted to a semi-join: +explain SELECT a.idIndividual FROM t1 a +WHERE a.idIndividual IN +( SELECT c.idObj FROM t3 cona +INNER JOIN t2 c ON c.idContact=cona.idContact +WHERE cona.postalStripped='T2H3B2' + ); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE cona NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE c NULL eq_ref PRIMARY PRIMARY 4 test.cona.idContact 1 100.00 Using where +1 SIMPLE a NULL eq_ref PRIMARY PRIMARY 4 test.c.idObj 1 100.00 Using index; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`a`.`idIndividual` AS `idIndividual` from `test`.`t1` `a` semi join (`test`.`t3` `cona` join `test`.`t2` `c`) where ((`test`.`c`.`idContact` = `test`.`cona`.`idContact`) and (`test`.`a`.`idIndividual` = `test`.`c`.`idObj`) and (`test`.`cona`.`postalStripped` = 'T2H3B2')) +drop table t1,t2,t3; +CREATE TABLE t1 (one int, two int, flag char(1)); +CREATE TABLE t2 (one int, two int, flag char(1)); +INSERT INTO t1 VALUES(1,2,'Y'),(2,3,'Y'),(3,4,'Y'),(5,6,'N'),(7,8,'N'); +INSERT INTO t2 VALUES(1,2,'Y'),(2,3,'Y'),(3,4,'Y'),(5,6,'N'),(7,8,'N'); +SELECT * FROM t1 +WHERE ROW(one,two) IN (SELECT DISTINCT one,two FROM t2 WHERE flag = 'N'); +one two flag +5 6 N +7 8 N +SELECT * FROM t1 +WHERE ROW(one,two) IN (SELECT DISTINCT one,two FROM t1 WHERE flag = 'N'); +one two flag +5 6 N +7 8 N +insert into t2 values (null,null,'N'); +insert into t2 values (null,3,'0'); +insert into t2 values (null,5,'0'); +insert into t2 values (10,null,'0'); +insert into t1 values (10,3,'0'); +insert into t1 values (10,5,'0'); +insert into t1 values (10,10,'0'); +SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = 'N') as 'test' from t1; +one two test +1 2 NULL +2 3 NULL +3 4 NULL +5 6 1 +7 8 1 +10 3 NULL +10 5 NULL +10 10 NULL +SELECT one,two from t1 where ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = 'N'); +one two +5 6 +7 8 +SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = 'N' group by one,two) as 'test' from t1; +one two test +1 2 NULL +2 3 NULL +3 4 NULL +5 6 1 +7 8 1 +10 3 NULL +10 5 NULL +10 10 NULL +SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = '0') as 'test' from t1; +one two test +1 2 0 +2 3 NULL +3 4 0 +5 6 0 +7 8 0 +10 3 NULL +10 5 NULL +10 10 NULL +SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = '0' group by one,two) as 'test' from t1; +one two test +1 2 0 +2 3 NULL +3 4 0 +5 6 0 +7 8 0 +10 3 NULL +10 5 NULL +10 10 NULL +explain SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = '0') as 'test' from t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 9 11.11 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`one` AS `one`,`test`.`t1`.`two` AS `two`,((`test`.`t1`.`one`,`test`.`t1`.`two`),(/* select#2 */ select `test`.`t2`.`one`,`test`.`t2`.`two` from `test`.`t2` where ((`test`.`t2`.`flag` = '0') and (outer_field_is_not_null, (((`test`.`t1`.`one`) = `test`.`t2`.`one`) or (`test`.`t2`.`one` is null)), true) and (outer_field_is_not_null, (((`test`.`t1`.`two`) = `test`.`t2`.`two`) or (`test`.`t2`.`two` is null)), true)) having ((outer_field_is_not_null, (`test`.`t2`.`one`), true) and (outer_field_is_not_null, (`test`.`t2`.`two`), true)))) AS `test` from `test`.`t1` +explain SELECT one,two from t1 where ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = 'N'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 9 11.11 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`one` AS `one`,`test`.`t1`.`two` AS `two` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`two` = `test`.`t2`.`two`) and (`test`.`t1`.`one` = `test`.`t2`.`one`) and (`test`.`t2`.`flag` = 'N')) +explain SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = '0' group by one,two) as 'test' from t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 9 11.11 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`one` AS `one`,`test`.`t1`.`two` AS `two`,((`test`.`t1`.`one`,`test`.`t1`.`two`),(/* select#2 */ select `test`.`t2`.`one`,`test`.`t2`.`two` from `test`.`t2` where ((`test`.`t2`.`flag` = '0') and (outer_field_is_not_null, (((`test`.`t1`.`one`) = `test`.`t2`.`one`) or (`test`.`t2`.`one` is null)), true) and (outer_field_is_not_null, (((`test`.`t1`.`two`) = `test`.`t2`.`two`) or (`test`.`t2`.`two` is null)), true)) having ((outer_field_is_not_null, (`test`.`t2`.`one`), true) and (outer_field_is_not_null, (`test`.`t2`.`two`), true)))) AS `test` from `test`.`t1` +DROP TABLE t1,t2; +CREATE TABLE t1 (a char(5), b char(5)); +INSERT INTO t1 VALUES (NULL,'aaa'), ('aaa','aaa'); +SELECT * FROM t1 WHERE (a,b) IN (('aaa','aaa'), ('aaa','bbb')); +a b +aaa aaa +DROP TABLE t1; +CREATE TABLE t1 (a CHAR(1), b VARCHAR(10)) charset utf8mb4; +INSERT INTO t1 VALUES ('a', 'aa'); +INSERT INTO t1 VALUES ('a', 'aaa'); +SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1); +a b +CREATE INDEX I1 ON t1 (a); +CREATE INDEX I2 ON t1 (b); +EXPLAIN SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index I1 I1 5 NULL 2 100.00 Using index; Start temporary +1 SIMPLE t1 NULL ALL I2 NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t1`) where (`test`.`t1`.`b` = `test`.`t1`.`a`) +SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1); +a b +CREATE TABLE t2 (a VARCHAR(1), b VARCHAR(10)) charset utf8mb4; +INSERT INTO t2 SELECT * FROM t1; +CREATE INDEX I1 ON t2 (a); +CREATE INDEX I2 ON t2 (b); +EXPLAIN SELECT a,b FROM t2 WHERE b IN (SELECT a FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index I1 I1 7 NULL 2 100.00 Using index; Start temporary +1 SIMPLE t2 NULL ALL I2 NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t2` semi join (`test`.`t2`) where (`test`.`t2`.`b` = `test`.`t2`.`a`) +SELECT a,b FROM t2 WHERE b IN (SELECT a FROM t2); +a b +EXPLAIN +SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1 WHERE LENGTH(a)<500); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index I1 I1 5 NULL 2 100.00 Using where; Using index; Start temporary +1 SIMPLE t1 NULL ALL I2 NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t1`) where ((length(`test`.`t1`.`a`) < 500) and (`test`.`t1`.`b` = `test`.`t1`.`a`)) +SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1 WHERE LENGTH(a)<500); +a b +DROP TABLE t1,t2; +# +# BUG#45928 "Differing query results depending on MRR and +# engine_condition_pushdown settings" +# +CREATE TABLE `t1` ( +`pk` int(11) NOT NULL AUTO_INCREMENT, +`time_nokey` time NOT NULL, +`varchar_key` varchar(1) NOT NULL, +`varchar_nokey` varchar(1) NOT NULL, +PRIMARY KEY (`pk`), +KEY `varchar_key` (`varchar_key`) +) AUTO_INCREMENT=12 DEFAULT CHARSET=latin1; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO `t1` VALUES (10,'00:00:00','i','i'),(11,'00:00:00','',''); +SELECT `time_nokey` G1 FROM t1 WHERE ( `varchar_nokey` , `varchar_key` ) IN ( +SELECT `varchar_nokey` , `varchar_nokey` ) AND `varchar_key` >= 'c' HAVING G1 ORDER +BY `pk` ; +G1 +DROP TABLE t1; +# +# BUG#45863 "Assertion failed: (fixed == 0), function fix_fields(), +# file item.cc, line 4448" +# +DROP TABLE IF EXISTS C, BB; +CREATE TABLE C ( +varchar_nokey varchar(1) NOT NULL +); +INSERT INTO C VALUES +('k'),('a'),(''),('u'),('e'),('v'),('i'), +('t'),('u'),('f'),('u'),('m'),('j'),('f'), +('v'),('j'),('g'),('e'),('h'),('z'); +CREATE TABLE BB ( +varchar_nokey varchar(1) NOT NULL +); +INSERT INTO BB VALUES ('i'),('t'); +SELECT varchar_nokey FROM C +WHERE (varchar_nokey, OUTR) IN (SELECT varchar_nokey +FROM BB); +ERROR 42S22: Unknown column 'OUTR' in 'IN/ALL/ANY subquery' +SELECT varchar_nokey FROM C +WHERE (varchar_nokey, OUTR) IN (SELECT varchar_nokey, varchar_nokey +FROM BB); +ERROR 42S22: Unknown column 'OUTR' in 'IN/ALL/ANY subquery' +DROP TABLE C,BB; +# +# During work with BUG#45863 I had problems with a query that was +# optimized differently in regular and prepared mode. +# Because there was a bug in one of the selected strategies, I became +# aware of the problem. Adding an EXPLAIN query to catch this. +DROP TABLE IF EXISTS t1, t2, t3; +CREATE TABLE t1 +(EMPNUM CHAR(3) NOT NULL, +EMPNAME CHAR(20), +GRADE DECIMAL(4), +CITY CHAR(15)) charset latin1; +CREATE TABLE t2 +(PNUM CHAR(3) NOT NULL, +PNAME CHAR(20), +PTYPE CHAR(6), +BUDGET DECIMAL(9), +CITY CHAR(15)) charset latin1; +CREATE TABLE t3 +(EMPNUM CHAR(3) NOT NULL, +PNUM CHAR(3) NOT NULL, +HOURS DECIMAL(5)) charset latin1; +INSERT INTO t1 VALUES ('E1','Alice',12,'Deale'); +INSERT INTO t1 VALUES ('E2','Betty',10,'Vienna'); +INSERT INTO t1 VALUES ('E3','Carmen',13,'Vienna'); +INSERT INTO t1 VALUES ('E4','Don',12,'Deale'); +INSERT INTO t1 VALUES ('E5','Ed',13,'Akron'); +INSERT INTO t2 VALUES ('P1','MXSS','Design',10000,'Deale'); +INSERT INTO t2 VALUES ('P2','CALM','Code',30000,'Vienna'); +INSERT INTO t2 VALUES ('P3','SDP','Test',30000,'Tampa'); +INSERT INTO t2 VALUES ('P4','SDP','Design',20000,'Deale'); +INSERT INTO t2 VALUES ('P5','IRM','Test',10000,'Vienna'); +INSERT INTO t2 VALUES ('P6','PAYR','Design',50000,'Deale'); +INSERT INTO t3 VALUES ('E1','P1',40); +INSERT INTO t3 VALUES ('E1','P2',20); +INSERT INTO t3 VALUES ('E1','P3',80); +INSERT INTO t3 VALUES ('E1','P4',20); +INSERT INTO t3 VALUES ('E1','P5',12); +INSERT INTO t3 VALUES ('E1','P6',12); +INSERT INTO t3 VALUES ('E2','P1',40); +INSERT INTO t3 VALUES ('E2','P2',80); +INSERT INTO t3 VALUES ('E3','P2',20); +INSERT INTO t3 VALUES ('E4','P2',20); +INSERT INTO t3 VALUES ('E4','P4',40); +INSERT INTO t3 VALUES ('E4','P5',80); +CREATE UNIQUE INDEX t1_IDX ON t1(EMPNUM); +EXPLAIN SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN +(SELECT EMPNUM +FROM t3 +WHERE PNUM IN +(SELECT PNUM +FROM t2 +WHERE PTYPE = 'Design')); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL eq_ref t1_IDX t1_IDX 3 test.t3.EMPNUM 1 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = `test`.`t3`.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) +PREPARE stmt FROM "EXPLAIN SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN + (SELECT EMPNUM + FROM t3 + WHERE PNUM IN + (SELECT PNUM + FROM t2 + WHERE PTYPE = 'Design'))"; +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL eq_ref t1_IDX t1_IDX 3 test.t3.EMPNUM 1 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = `test`.`t3`.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) + +This line is only in place to help --skip_if_hypergraph diffing some more. + +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL eq_ref t1_IDX t1_IDX 3 test.t3.EMPNUM 1 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = `test`.`t3`.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) +DEALLOCATE PREPARE stmt; +DROP INDEX t1_IDX ON t1; +CREATE INDEX t1_IDX ON t1(EMPNUM); +EXPLAIN SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN +(SELECT EMPNUM +FROM t3 +WHERE PNUM IN +(SELECT PNUM +FROM t2 +WHERE PTYPE = 'Design')); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ref t1_IDX t1_IDX 3 test.t3.EMPNUM 2 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = `test`.`t3`.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) +PREPARE stmt FROM "EXPLAIN SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN + (SELECT EMPNUM + FROM t3 + WHERE PNUM IN + (SELECT PNUM + FROM t2 + WHERE PTYPE = 'Design'))"; +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ref t1_IDX t1_IDX 3 test.t3.EMPNUM 2 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = `test`.`t3`.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) + +This line is only in place to help --skip_if_hypergraph diffing some more. + +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ref t1_IDX t1_IDX 3 test.t3.EMPNUM 2 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = `test`.`t3`.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) +DEALLOCATE PREPARE stmt; +DROP INDEX t1_IDX ON t1; +EXPLAIN SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN +(SELECT EMPNUM +FROM t3 +WHERE PNUM IN +(SELECT PNUM +FROM t2 +WHERE PTYPE = 'Design')); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 20.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = `test`.`t3`.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) +PREPARE stmt FROM "EXPLAIN SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN + (SELECT EMPNUM + FROM t3 + WHERE PNUM IN + (SELECT PNUM + FROM t2 + WHERE PTYPE = 'Design'))"; +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 20.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = `test`.`t3`.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) + +This line is only in place to help --skip_if_hypergraph diffing some more. + +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 20.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = `test`.`t3`.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) +DEALLOCATE PREPARE stmt; +DROP TABLE t1, t2, t3; +# +# BUG#45221 Query SELECT pk FROM C WHERE pk IN (SELECT int_key) failing +# +CREATE TABLE t1 ( +i1_key INT, +i2 INT, +i3 INT, +KEY i1_index (i1_key) +); +INSERT INTO t1 VALUES (9,1,2), (9,2,1); +CREATE TABLE t2 ( +pk INT NOT NULL, +i1 INT, +PRIMARY KEY (pk) +); +INSERT INTO t2 VALUES (9,1); +SELECT pk +FROM t2 +WHERE +pk IN ( +SELECT i1_key +FROM t1 +WHERE t1.i2 < t1.i3 XOR t2.i1 > 1 +ORDER BY t1.i2 desc); +pk +9 +DROP TABLE t1,t2; +# BUG#50361 Doublenested noncorrelated subquery with FirstMatch and join cache wrong result +# +CREATE TABLE t1( +id INTEGER +); +INSERT INTO t1 VALUES(10),(20); +create table t2 select * from t1; +create table t3 select * from t1; +SELECT * +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t2 +WHERE 1 IN(SELECT 1 +FROM t3)); +id +10 +20 +explain SELECT * +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t2 +WHERE 1 IN(SELECT 1 +FROM t3)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where true +delete from t2; +delete from t3; +INSERT INTO t1 VALUES(30),(40),(50),(60),(70),(80),(90); +insert into t2 select * from t1; +insert into t3 select * from t1; +create table t4 select * from t1; +SELECT * +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t2 +WHERE 1 IN(SELECT 1 +FROM t3 +WHERE 1 IN(SELECT 1 +FROM t4))); +id +10 +20 +30 +40 +50 +60 +70 +80 +90 +explain SELECT * +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t2 +WHERE 1 IN(SELECT 1 +FROM t3 +WHERE 1 IN(SELECT 1 +FROM t4))); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 9 100.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 9 100.00 Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 9 100.00 Using join buffer (hash join) +1 SIMPLE t4 NULL ALL NULL NULL NULL NULL 9 100.00 End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3` join `test`.`t4`) where true +SELECT * +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t1))); +id +10 +20 +30 +40 +50 +60 +70 +80 +90 +drop table t1,t2,t3,t4; +# +# Bug#53236 Segfault in DTCollation::set(DTCollation&) +# +CREATE TABLE t1 ( +pk INTEGER AUTO_INCREMENT, +col_varchar VARCHAR(1), +PRIMARY KEY (pk) +) +; +INSERT INTO t1 (col_varchar) +VALUES +('w'), +('m') +; +SELECT table1.pk +FROM ( t1 AS table1 JOIN t1 AS table2 ON (table1.col_varchar = +table2.col_varchar) ) +WHERE ( 1, 2 ) IN ( SELECT SUBQUERY1_t1.pk AS SUBQUERY1_field1, +SUBQUERY1_t1.pk AS SUBQUERY1_field2 +FROM ( t1 AS SUBQUERY1_t1 JOIN t1 AS SUBQUERY1_t2 +ON (SUBQUERY1_t2.col_varchar = +SUBQUERY1_t1.col_varchar) ) ) +; +pk +drop table t1; +# +# BUG#53298 "wrong result with semijoin (no semijoin strategy chosen)" +# +create table t1 (uid int, fid int); +insert into t1 values (1,1), (3,1); +create table t2 (uid int, name varchar(128)); +insert into t2 values (1, "A"), (2, "B"); +create table t3 (uid int, fid int, index(uid)); +insert into t3 values (1,3), (1,3); +create table t4 (uid int); +insert into t4 values (3); +explain select t2.uid from t2, t1 +where t1.uid in (select t4.uid from t4, t3 where t3.uid=1 and t4.uid=t3.fid) +and t2.uid=t1.fid; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t4 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ref uid uid 5 const 1 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`uid` AS `uid` from `test`.`t2` join `test`.`t1` semi join (`test`.`t4` join `test`.`t3`) where ((`test`.`t3`.`fid` = `test`.`t4`.`uid`) and (`test`.`t1`.`uid` = `test`.`t4`.`uid`) and (`test`.`t3`.`uid` = 1) and (`test`.`t1`.`fid` = `test`.`t2`.`uid`)) +select t2.uid from t2, t1 +where t1.uid in (select t4.uid from t4, t3 where t3.uid=1 and t4.uid=t3.fid) +and t2.uid=t1.fid; +uid +1 +drop table t1,t2,t3,t4; +CREATE TABLE t1 ( +pk int, +a varchar(1), +b varchar(4), +c varchar(4), +d varchar(4), +PRIMARY KEY (pk) +) charset utf8mb4; +INSERT INTO t1 VALUES (1,'o','ffff','ffff','ffoo'),(2,'f','ffff','ffff','ffff'); +CREATE TABLE t2 LIKE t1; +INSERT INTO t2 VALUES (1,'i','iiii','iiii','iiii'),(2,'f','ffff','ffff','ffff'); +EXPLAIN SELECT pk FROM t1 WHERE (a) IN (SELECT a FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`a` = `test`.`t1`.`a`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (a) IN (SELECT a FROM t2 WHERE pk > 0); +pk +2 +SELECT pk FROM t1 WHERE (b,c,d) IN (SELECT b,c,d FROM t2 WHERE pk > 0); +pk +2 +DROP TABLE t1, t2; +CREATE TABLE t1 (f1 INT, f2 DECIMAL(5,3)) ENGINE=MyISAM; +INSERT INTO t1 (f1, f2) VALUES (1, 1.789); +INSERT INTO t1 (f1, f2) VALUES (13, 1.454); +INSERT INTO t1 (f1, f2) VALUES (10, 1.668); +CREATE TABLE t2 LIKE t1; +INSERT INTO t2 VALUES (1, 1.789); +INSERT INTO t2 VALUES (13, 1.454); +EXPLAIN SELECT COUNT(*) FROM t1 WHERE (f1,f2) IN (SELECT f1,f2 FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`f2` = `test`.`t2`.`f2`) and (`test`.`t1`.`f1` = `test`.`t2`.`f1`)) +SELECT COUNT(*) FROM t1 WHERE (f1,f2) IN (SELECT f1,f2 FROM t2); +COUNT(*) +2 +DROP TABLE t1, t2; +CREATE TABLE t1 ( +ID int(11) NOT NULL auto_increment, +Name char(35) NOT NULL default '', +Country char(3) NOT NULL default '', +Population int(11) NOT NULL default '0', +PRIMARY KEY (ID), +INDEX (Population), +INDEX (Country) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t2 ( +Code char(3) NOT NULL default '', +Name char(52) NOT NULL default '', +SurfaceArea float(10,2) NOT NULL default '0.00', +Population int(11) NOT NULL default '0', +Capital int(11) default NULL, +PRIMARY KEY (Code), +UNIQUE INDEX (Name), +INDEX (Population) +) charset utf8mb4; +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t3 ( +Country char(3) NOT NULL default '', +Language char(30) NOT NULL default '', +Percentage float(3,1) NOT NULL default '0.0', +PRIMARY KEY (Country, Language), +INDEX (Percentage) +) charset utf8mb4; +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +EXPLAIN SELECT Name FROM t2 +WHERE t2.Code IN (SELECT Country FROM t1 WHERE Population > 5000000) +AND +t2.Code IN (SELECT Country FROM t3 +WHERE Language='English' AND Percentage > 10 AND +t2.Population > 100000); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range Population,Country Population 4 NULL 1 100.00 Using where; Start temporary +1 SIMPLE t2 NULL eq_ref PRIMARY,Population PRIMARY 12 test.t1.Country 1 75.00 Using where +1 SIMPLE t3 NULL eq_ref PRIMARY,Percentage PRIMARY 132 test.t1.Country,const 1 95.45 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t2.Population' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t2`.`Name` AS `Name` from `test`.`t3` join `test`.`t2` semi join (`test`.`t1`) where ((`test`.`t2`.`Code` = `test`.`t1`.`Country`) and (`test`.`t3`.`Country` = `test`.`t1`.`Country`) and (`test`.`t3`.`Language` = 'English') and (`test`.`t3`.`Percentage` > 10) and (`test`.`t2`.`Population` > 100000) and (`test`.`t1`.`Population` > 5000000)) +EXPLAIN FORMAT=JSON SELECT Name FROM t2 +WHERE t2.Code IN (SELECT Country FROM t1 WHERE Population > 5000000) +AND +t2.Code IN (SELECT Country FROM t3 +WHERE Language='English' AND Percentage > 10 AND +t2.Population > 100000); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "2.46" + }, + "duplicates_removal": { + "using_temporary_table": true, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "range", + "possible_keys": [ + "Population", + "Country" + ], + "key": "Population", + "used_key_parts": [ + "Population" + ], + "key_length": "4", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.61", + "eval_cost": "0.10", + "prefix_cost": "0.71", + "data_read_per_join": "168" + }, + "used_columns": [ + "Country", + "Population" + ], + "attached_condition": "(`test`.`t1`.`Population` > 5000000)" + } + }, + { + "table": { + "table_name": "t2", + "access_type": "eq_ref", + "possible_keys": [ + "PRIMARY", + "Population" + ], + "key": "PRIMARY", + "used_key_parts": [ + "Code" + ], + "key_length": "12", + "ref": [ + "test.t1.Country" + ], + "rows_examined_per_scan": 1, + "rows_produced_per_join": 0, + "filtered": "75.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.08", + "prefix_cost": "2.21", + "data_read_per_join": "180" + }, + "used_columns": [ + "Code", + "Name", + "Population" + ], + "attached_condition": "(`test`.`t2`.`Population` > 100000)" + } + }, + { + "table": { + "table_name": "t3", + "access_type": "eq_ref", + "possible_keys": [ + "PRIMARY", + "Percentage" + ], + "key": "PRIMARY", + "used_key_parts": [ + "Country", + "Language" + ], + "key_length": "132", + "ref": [ + "test.t1.Country", + "const" + ], + "rows_examined_per_scan": 1, + "rows_produced_per_join": 0, + "filtered": "95.45", + "cost_info": { + "read_cost": "0.19", + "eval_cost": "0.07", + "prefix_cost": "2.47", + "data_read_per_join": "103" + }, + "used_columns": [ + "Country", + "Language", + "Percentage" + ], + "attached_condition": "((`test`.`t3`.`Language` = 'English') and (`test`.`t3`.`Percentage` > 10))" + } + } + ] + } + } +} +Warnings: +Note 1276 Field or reference 'test.t2.Population' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t2`.`Name` AS `Name` from `test`.`t3` join `test`.`t2` semi join (`test`.`t1`) where ((`test`.`t2`.`Code` = `test`.`t1`.`Country`) and (`test`.`t3`.`Country` = `test`.`t1`.`Country`) and (`test`.`t3`.`Language` = 'English') and (`test`.`t3`.`Percentage` > 10) and (`test`.`t2`.`Population` > 100000) and (`test`.`t1`.`Population` > 5000000)) +DROP TABLE t1,t2,t3; +CREATE TABLE t1 ( +Code char(3) NOT NULL DEFAULT '', +Name char(52) NOT NULL DEFAULT '', +Continent enum('Asia','Europe','North America','Africa','Oceania','Antarctica','South America') NOT NULL DEFAULT 'Asia', +Region char(26) NOT NULL DEFAULT '', +SurfaceArea float(10,2) NOT NULL DEFAULT '0.00', +IndepYear smallint(6) DEFAULT NULL, +Population int(11) NOT NULL DEFAULT '0', +LifeExpectancy float(3,1) DEFAULT NULL, +GNP float(10,2) DEFAULT NULL, +GNPOld float(10,2) DEFAULT NULL, +LocalName char(45) NOT NULL DEFAULT '', +GovernmentForm char(45) NOT NULL DEFAULT '', +HeadOfState char(60) DEFAULT NULL, +Capital int(11) DEFAULT NULL, +Code2 char(2) NOT NULL DEFAULT '', +PRIMARY KEY (Code) +) charset utf8mb4; +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t2 ( +ID int(11) NOT NULL AUTO_INCREMENT, +Name char(35) NOT NULL DEFAULT '', +CountryCode char(3) NOT NULL DEFAULT '', +District char(20) NOT NULL DEFAULT '', +Population int(11) NOT NULL DEFAULT '0', +PRIMARY KEY (ID), +KEY CountryCode (CountryCode) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +set names latin1; +Fill the table with test data +This must not use LooseScan: +EXPLAIN SELECT Name FROM t1 +WHERE t1.Code IN ( +SELECT t2.CountryCode FROM t2 WHERE Population > 5000000); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL CountryCode NULL NULL NULL 545 33.33 Using where; Start temporary +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 12 test.t2.CountryCode 1 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`Name` AS `Name` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`Code` = `test`.`t2`.`CountryCode`) and (`test`.`t2`.`Population` > 5000000)) +SELECT Name FROM t1 +WHERE t1.Code IN ( +SELECT t2.CountryCode FROM t2 WHERE Population > 5000000); +Name +Austria +Canada +China +Czech Republic +drop table t1, t2; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4); +create table t1 (a int, b int, key(a)); +insert into t1 select a,a from t0; +create table t2 (a int, b int, primary key(a)); +insert into t2 select * from t1; +Table t2, unlike table t1, should be displayed as pulled out +explain select * from t0 +where t0.a in ( select t1.a from t1,t2 where t2.a=t0.a and +t1.b=t2.b); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 5 100.00 Using where +1 SIMPLE t1 NULL ref a a 5 test.t0.a 1 100.00 Start temporary +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t0.a 1 20.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t0.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a` from `test`.`t2` join `test`.`t0` semi join (`test`.`t1`) where ((`test`.`t1`.`a` = `test`.`t0`.`a`) and (`test`.`t2`.`a` = `test`.`t0`.`a`) and (`test`.`t2`.`b` = `test`.`t1`.`b`)) +update t1 set a=3, b=11 where a=4; +update t2 set b=11 where a=3; +select * from t0 where t0.a in (select t1.a from t1, t2 where t2.a=t0.a and t1.b=t2.b); +a +0 +1 +2 +3 +drop table t0, t1, t2; +CREATE TABLE t1 ( +id int(11) NOT NULL, +PRIMARY KEY (id)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t2 ( +id int(11) NOT NULL, +fid int(11) NOT NULL, +PRIMARY KEY (id)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t1 values(1); +insert into t2 values(1,7503),(2,1); +explain select count(*) +from t1 +where fid IN (select fid from t2 where (id between 7502 and 8420) order by fid ); +ERROR 42S22: Unknown column 'fid' in 'IN/ALL/ANY subquery' +drop table t1, t2; +create table t1 (a int, b int, key (a), key (b)); +insert into t1 values (2,4),(2,4),(2,4); +select t1.a from t1 +where +t1.a in (select 1 from t1 where t1.a in (select 1 from t1) group by t1.a); +a +drop table t1; +create table t1(a int,b int,key(a),key(b)); +insert into t1 values (1,1),(2,2),(3,3); +select 1 from t1 +where t1.a not in (select 1 from t1 +where t1.a in (select 1 from t1) +group by t1.b); +1 +1 +1 +drop table t1; +CREATE TABLE t1 +(EMPNUM CHAR(3) NOT NULL, +EMPNAME CHAR(20), +GRADE DECIMAL(4), +CITY CHAR(15)); +CREATE TABLE t2 +(PNUM CHAR(3) NOT NULL, +PNAME CHAR(20), +PTYPE CHAR(6), +BUDGET DECIMAL(9), +CITY CHAR(15)); +CREATE TABLE t3 +(EMPNUM CHAR(3) NOT NULL, +PNUM CHAR(3) NOT NULL, +HOURS DECIMAL(5)); +INSERT INTO t1 VALUES ('E1','Alice',12,'Deale'); +INSERT INTO t1 VALUES ('E2','Betty',10,'Vienna'); +INSERT INTO t1 VALUES ('E3','Carmen',13,'Vienna'); +INSERT INTO t1 VALUES ('E4','Don',12,'Deale'); +INSERT INTO t1 VALUES ('E5','Ed',13,'Akron'); +INSERT INTO t2 VALUES ('P1','MXSS','Design',10000,'Deale'); +INSERT INTO t2 VALUES ('P2','CALM','Code',30000,'Vienna'); +INSERT INTO t2 VALUES ('P3','SDP','Test',30000,'Tampa'); +INSERT INTO t2 VALUES ('P4','SDP','Design',20000,'Deale'); +INSERT INTO t2 VALUES ('P5','IRM','Test',10000,'Vienna'); +INSERT INTO t2 VALUES ('P6','PAYR','Design',50000,'Deale'); +INSERT INTO t3 VALUES ('E1','P1',40); +INSERT INTO t3 VALUES ('E1','P2',20); +INSERT INTO t3 VALUES ('E1','P3',80); +INSERT INTO t3 VALUES ('E1','P4',20); +INSERT INTO t3 VALUES ('E1','P5',12); +INSERT INTO t3 VALUES ('E1','P6',12); +INSERT INTO t3 VALUES ('E2','P1',40); +INSERT INTO t3 VALUES ('E2','P2',80); +INSERT INTO t3 VALUES ('E3','P2',20); +INSERT INTO t3 VALUES ('E4','P2',20); +INSERT INTO t3 VALUES ('E4','P4',40); +INSERT INTO t3 VALUES ('E4','P5',80); +SELECT * FROM t1; +EMPNUM EMPNAME GRADE CITY +E1 Alice 12 Deale +E2 Betty 10 Vienna +E3 Carmen 13 Vienna +E4 Don 12 Deale +E5 Ed 13 Akron +CREATE UNIQUE INDEX t1_IDX ON t1(EMPNUM); +SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN +(SELECT EMPNUM +FROM t3 +WHERE PNUM IN +(SELECT PNUM +FROM t2 +WHERE PTYPE = 'Design')); +EMPNAME +Alice +Betty +Don +DROP INDEX t1_IDX ON t1; +CREATE INDEX t1_IDX ON t1(EMPNUM); +SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN +(SELECT EMPNUM +FROM t3 +WHERE PNUM IN +(SELECT PNUM +FROM t2 +WHERE PTYPE = 'Design')); +EMPNAME +Alice +Betty +Don +DROP INDEX t1_IDX ON t1; +SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN +(SELECT EMPNUM +FROM t3 +WHERE PNUM IN +(SELECT PNUM +FROM t2 +WHERE PTYPE = 'Design')); +EMPNAME +Alice +Betty +Don +DROP TABLE t1, t2, t3; +CREATE TABLE t1 (f1 INT NOT NULL); +CREATE VIEW v1 (a) AS SELECT f1 IN (SELECT f1 FROM t1) FROM t1; +SELECT * FROM v1; +a +drop view v1; +drop table t1; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1(a int, b int); +insert into t1 values (0,0),(1,1),(2,2); +create table t2 as select * from t1; +create table t3 (pk int, a int, primary key(pk)); +insert into t3 select a,a from t0; +explain +select * from t1 left join t2 on (t2.a= t1.a and t2.a in (select pk from t3)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE t3 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using index +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` left join (`test`.`t3` join `test`.`t2`) on(((`test`.`t3`.`pk` = `test`.`t1`.`a`) and (`test`.`t2`.`a` = `test`.`t1`.`a`))) where true +drop table t0, t1, t2, t3; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (a int) as select A.a + 10 *(B.a + 10*C.a) as a from t0 A, t0 B, t0 C; +create table t2 (id int, a int, primary key(id), key(a)) charset utf8mb4 as select a as id, a as a from t1; +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `id` int NOT NULL, + `a` int DEFAULT NULL, + PRIMARY KEY (`id`), + KEY `a` (`a`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +set @a=0; +create table t3 as select * from t2 limit 0; +insert into t3 select @a:=@a+1, t2.a from t2, t0; +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +insert into t3 select @a:=@a+1, t2.a from t2, t0; +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +insert into t3 select @a:=@a+1, t2.a from t2, t0; +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +alter table t3 add primary key(id), add 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); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index a a 5 NULL 1000 100.00 Using where; Using index +1 SIMPLE t3 NULL ref a a 5 test.t2.a 30 100.00 Using index; Start temporary; End temporary +Warnings: +Note 1003 /* select#1 */ select count(`test`.`t2`.`a`) AS `count(a)` from `test`.`t2` semi join (`test`.`t3`) where (`test`.`t3`.`a` = `test`.`t2`.`a`) +select count(a) from t2 where a in ( SELECT a FROM t3); +count(a) +1000 +drop table t0,t1,t2,t3; +# +# Bug#33062: subquery in stored routine cause crash +# +CREATE TABLE t1(a INT); +CREATE TABLE t2(c INT); +CREATE PROCEDURE p1(v1 int) +BEGIN +SELECT 1 FROM t1 WHERE a = v1 AND a IN (SELECT c FROM t2); +END +// +CREATE PROCEDURE p2(v1 int) +BEGIN +SELECT 1 FROM t1 WHERE a IN (SELECT c FROM t2); +END +// +CREATE PROCEDURE p3(v1 int) +BEGIN +SELECT 1 +FROM +t1 t01,t1 t02,t1 t03,t1 t04,t1 t05,t1 t06,t1 t07,t1 t08, +t1 t09,t1 t10,t1 t11,t1 t12,t1 t13,t1 t14,t1 t15,t1 t16, +t1 t17,t1 t18,t1 t19,t1 t20,t1 t21,t1 t22,t1 t23,t1 t24, +t1 t25,t1 t26,t1 t27,t1 t28,t1 t29,t1 t30,t1 t31,t1 t32, +t1 t33,t1 t34,t1 t35,t1 t36,t1 t37,t1 t38,t1 t39,t1 t40, +t1 t41,t1 t42,t1 t43,t1 t44,t1 t45,t1 t46,t1 t47,t1 t48, +t1 t49,t1 t50,t1 t51,t1 t52,t1 t53,t1 t54,t1 t55,t1 t56, +t1 t57,t1 t58,t1 t59,t1 t60 +WHERE t01.a IN (SELECT c FROM t2); +END +// +CREATE PROCEDURE p4(v1 int) +BEGIN +SELECT 1 +FROM +t1 t01,t1 t02,t1 t03,t1 t04,t1 t05,t1 t06,t1 t07,t1 t08, +t1 t09,t1 t10,t1 t11,t1 t12,t1 t13,t1 t14,t1 t15,t1 t16, +t1 t17,t1 t18,t1 t19,t1 t20,t1 t21,t1 t22,t1 t23,t1 t24, +t1 t25,t1 t26,t1 t27,t1 t28,t1 t29,t1 t30,t1 t31,t1 t32, +t1 t33,t1 t34,t1 t35,t1 t36,t1 t37,t1 t38,t1 t39,t1 t40, +t1 t41,t1 t42,t1 t43,t1 t44,t1 t45,t1 t46,t1 t47,t1 t48, +t1 t49,t1 t50,t1 t51,t1 t52,t1 t53,t1 t54,t1 t55,t1 t56, +t1 t57,t1 t58,t1 t59,t1 t60 +WHERE t01.a = v1 AND t01.a IN (SELECT c FROM t2); +END +// +CALL p1(1); +1 +CALL p2(1); +1 +CALL p3(1); +1 +CALL p4(1); +1 +DROP TABLE t1, t2; +DROP PROCEDURE p1; +DROP PROCEDURE p2; +DROP PROCEDURE p3; +DROP PROCEDURE p4; +# +# Bug#48213 Materialized subselect crashes if using GEOMETRY type +# +CREATE TABLE t1 ( +pk int, +a varchar(1), +b varchar(4), +c tinyblob, +d blob, +e mediumblob, +f longblob, +g tinytext, +h text, +i mediumtext, +j longtext, +k geometry, +PRIMARY KEY (pk) +) charset utf8mb4; +INSERT INTO t1 VALUES (1,'o','ffff','ffff','ffoo','ffff','ffff','ffff','ffff','ffff','ffff',ST_GeomFromText('POLYGON((0 0, 0 2, 2 2, 2 0, 0 0))')), (2,'f','ffff','ffff','ffff', 'ffff','ffff','ffff','ffff','ffff','ffff',ST_GeomFromText('POLYGON((0 0, 0 2, 2 2, 2 0, 0 0))')); +CREATE TABLE t2 LIKE t1; +INSERT INTO t2 VALUES (1,'i','iiii','iiii','iiii','iiii','ffff','ffff','ffff','ffff','ffff',ST_GeomFromText('POLYGON((0 0, 0 2, 2 2, 2 0, 0 0))')), (2,'f','ffff','ffff','ffff','ffff','ffff','ffff','ffff','ffff','ffff',ST_GeomFromText('POLYGON((0 0, 0 2, 2 2, 2 0, 0 0))')); +EXPLAIN SELECT pk FROM t1 WHERE (a, b) IN (SELECT a, b FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ 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); +pk +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, c) IN (SELECT b, c FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`c` = `test`.`t1`.`c`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, c) IN (SELECT b, c FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, d) IN (SELECT b, d FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`d` = `test`.`t1`.`d`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, d) IN (SELECT b, d FROM t2 WHERE pk > 0); +pk +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, e) IN (SELECT b, e FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`e` = `test`.`t1`.`e`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, e) IN (SELECT b, e FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, f) IN (SELECT b, f FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`f` = `test`.`t1`.`f`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, f) IN (SELECT b, f FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, g) IN (SELECT b, g FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`g` = `test`.`t1`.`g`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, g) IN (SELECT b, g FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, h) IN (SELECT b, h FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`h` = `test`.`t1`.`h`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, h) IN (SELECT b, h FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, i) IN (SELECT b, i FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`i` = `test`.`t1`.`i`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, i) IN (SELECT b, i FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, j) IN (SELECT b, j FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`j` = `test`.`t1`.`j`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, j) IN (SELECT b, j FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, k) IN (SELECT b, k FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`k` = `test`.`t1`.`k`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, k) IN (SELECT b, k FROM t2 WHERE pk > 0); +pk +1 +2 +DROP TABLE t1, t2; +# End of Bug#48213 +# +# BUG#53060: LooseScan semijoin strategy does not return all rows +# +CREATE TABLE t1 (i INTEGER); +INSERT INTO t1 VALUES (1), (2), (3), (4), (5); +CREATE TABLE t2 (i INTEGER, j INTEGER, KEY k(i, j)); +INSERT INTO t2 VALUES (1, 0), (1, 1), (2, 0), (2, 1); +EXPLAIN +SELECT * FROM t1 WHERE (i) IN (SELECT i FROM t2 where j > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index k k 10 NULL 4 33.33 Using where; Using index; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 20.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`i` = `test`.`t2`.`i`) and (`test`.`t2`.`j` > 0)) +SELECT * FROM t1 WHERE (i) IN (SELECT i FROM t2 where j > 0); +i +1 +2 +DROP TABLE t1, t2; +# End of BUG#53060 +# +# Bug#53305 "Duplicate weedout + join buffer (join cache --level=7,8) loses rows" +# +create table t1 (uid int, fid int, index(uid)); +insert into t1 values +(1,1), (1,2), (1,3), (1,4), +(2,5), (2,6), (2,7), (2,8), +(3,1), (3,2), (3,9); +create table t2 (uid int primary key, name varchar(128), index(name)); +insert into t2 values +(1, "A"), (2, "B"), (3, "C"), (4, "D"), (5, "E"), +(6, "F"), (7, "G"), (8, "H"), (9, "I"); +create table t3 (uid int, fid int, index(uid)); +insert into t3 values +(1,1), (1,2), (1,3),(1,4), +(2,5), (2,6), (2,7), (2,8), +(3,1), (3,2), (3,9); +create table t4 (uid int primary key, name varchar(128), index(name)); +insert into t4 values +(1, "A"), (2, "B"), (3, "C"), (4, "D"), (5, "E"), +(6, "F"), (7, "G"), (8, "H"), (9, "I"); +explain select name from t2, t1 +where t1.uid in (select t4.uid from t4, t3 where t3.uid=1 and t4.uid=t3.fid) +and t2.uid=t1.fid; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ref uid uid 5 const 4 100.00 Using where; Start temporary +1 SIMPLE t4 NULL eq_ref PRIMARY PRIMARY 4 test.t3.fid 1 100.00 Using index +1 SIMPLE t1 NULL ref uid uid 5 test.t3.fid 2 100.00 Using where +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.fid 1 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`name` AS `name` from `test`.`t4` join `test`.`t2` join `test`.`t1` semi join (`test`.`t3`) where ((`test`.`t4`.`uid` = `test`.`t3`.`fid`) and (`test`.`t1`.`uid` = `test`.`t3`.`fid`) and (`test`.`t3`.`uid` = 1) and (`test`.`t2`.`uid` = `test`.`t1`.`fid`)) +select name from t2, t1 +where t1.uid in (select t4.uid from t4, t3 where t3.uid=1 and t4.uid=t3.fid) +and t2.uid=t1.fid; +name +A +A +B +B +C +D +E +F +G +H +I +drop table t1,t2,t3,t4; +# +# Bug#43768 Prepared query with nested subqueries core dump on second execution +# +CREATE TABLE t1 ( +id INT PRIMARY KEY, +partner_id VARCHAR(35) +) charset utf8mb4; +INSERT INTO t1 VALUES +(1, 'partner1'), (2, 'partner2'), +(3, 'partner3'), (4, 'partner4'); +CREATE TABLE t2 ( +id INT NOT NULL, +t1_line_id INT, +article_id VARCHAR(20), +PRIMARY KEY(id, t1_line_id) +) charset utf8mb4; +INSERT INTO t2 VALUES +(1, 1, 'sup'), (2, 1, 'sup'), +(2, 2, 'sup'), (2, 3, 'sup'), +(2, 4, 'imp'), (3, 1, 'sup'), +(4, 1, 'sup'); +CREATE TABLE t3 ( +user_id VARCHAR(50), +article_id VARCHAR(20) NOT NULL, +PRIMARY KEY(user_id) +) charset utf8mb4; +INSERT INTO t3 VALUES('nicke', 'imp'); +EXPLAIN +SELECT t1.partner_id +FROM t1 +WHERE t1.id IN ( +SELECT t2.id +FROM t2 +WHERE article_id IN ( +SELECT article_id FROM t3 +WHERE user_id = 'nicke' + ) +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL system PRIMARY NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL PRIMARY NULL NULL NULL 7 14.29 Using where; Start temporary +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.id 1 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`partner_id` AS `partner_id` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`id` = `test`.`t2`.`id`) and (`test`.`t2`.`article_id` = 'imp')) +SELECT t1.partner_id +FROM t1 +WHERE t1.id IN ( +SELECT t2.id +FROM t2 +WHERE article_id IN ( +SELECT article_id FROM t3 +WHERE user_id = 'nicke' + ) +); +partner_id +partner2 +PREPARE stmt FROM +'EXPLAIN SELECT t1.partner_id +FROM t1 +WHERE t1.id IN ( + SELECT t2.id + FROM t2 + WHERE article_id IN ( + SELECT article_id FROM t3 + WHERE user_id = \'nicke\' + ) + )'; +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL system PRIMARY NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL PRIMARY NULL NULL NULL 7 14.29 Using where; Start temporary +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.id 1 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`partner_id` AS `partner_id` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`id` = `test`.`t2`.`id`) and (`test`.`t2`.`article_id` = 'imp')) + +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL system PRIMARY NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL PRIMARY NULL NULL NULL 7 14.29 Using where; Start temporary +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.id 1 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`partner_id` AS `partner_id` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`id` = `test`.`t2`.`id`) and (`test`.`t2`.`article_id` = 'imp')) +PREPARE stmt FROM +'SELECT t1.partner_id +FROM t1 +WHERE t1.id IN ( + SELECT t2.id + FROM t2 + WHERE article_id IN ( + SELECT article_id FROM t3 + WHERE user_id = \'nicke\' + ) + )'; +EXECUTE stmt; +partner_id +partner2 + +EXECUTE stmt; +partner_id +partner2 +DROP TABLE t1,t2,t3; +# End of Bug#43768 +# +# Bug#53058 - semijoin execution of subquery with outerjoin yields wrong result +# +CREATE TABLE t1 (i INTEGER); +CREATE TABLE t2 (i INTEGER); +CREATE TABLE t3 (i INTEGER); +INSERT INTO t1 VALUES (1), (2); +INSERT INTO t2 VALUES (6); +INSERT INTO t3 VALUES (1), (2); +explain SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t3 LEFT JOIN t2 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = `test`.`t1`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t3 LEFT JOIN t2 ON t2.i=t3.i); +i +1 +2 +drop table t1,t2,t3; +# +# BUG#49453: re-execution of prepared statement with view +# and semijoin crashes +# +CREATE TABLE t1 (city VARCHAR(50), country_id INT); +CREATE TABLE t2 (country_id INT, country VARCHAR(50)); +INSERT INTO t1 VALUES +('Batna',2),('Bchar',2),('Skikda',2),('Tafuna',3),('Algeria',2) ; +INSERT INTO t2 VALUES (2,'Algeria'),(2,'AlgeriaDup'),(3,'XAmerican Samoa'); +CREATE VIEW v1 AS +SELECT country_id as vf_country_id +FROM t2 +WHERE LEFT(country,1) = "A"; +PREPARE stmt FROM " +SELECT city, country_id +FROM t1 +WHERE country_id IN (SELECT vf_country_id FROM v1); +"; + +EXECUTE stmt; +city country_id +Algeria 2 +Batna 2 +Bchar 2 +Skikda 2 + +EXECUTE stmt; +city country_id +Algeria 2 +Batna 2 +Bchar 2 +Skikda 2 +DROP TABLE t1,t2; +DROP VIEW v1; +# +# Bug#54437 Extra rows with LEFT JOIN + semijoin (firstmatch +# and duplicates weedout) +# +create table t1 (a int); +create table t2 (a int); +create table t3 (a int); +insert into t1 values(1),(1); +insert into t2 values(1),(1),(1),(1); +insert into t3 values(2),(2); +explain select * from t1 where t1.a in (select t2.a from t2 left join t3 on t2.a=t3.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t2` left join `test`.`t3` on((`test`.`t2`.`a` = `test`.`t3`.`a`))) where (`test`.`t2`.`a` = `test`.`t1`.`a`) +select * from t1 where t1.a in (select t2.a from t2 left join t3 on t2.a=t3.a); +a +1 +1 +drop table t1,t2,t3; +# +# Bug#55955: crash in MEMORY engine with IN(LEFT JOIN (JOIN)) +# +CREATE TABLE t1 (a INT); +CREATE TABLE t2 (a INT); +CREATE TABLE t3 (a INT); +INSERT INTO t1 VALUES(1),(1); +INSERT INTO t2 VALUES(1),(1); +INSERT INTO t3 VALUES(2),(2); +explain SELECT * FROM t1 +WHERE t1.a IN (SELECT t2.a +FROM t2 LEFT JOIN (t2 AS t2inner, t3) ON t2.a=t3.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t2inner NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t2` left join (`test`.`t2` `t2inner` join `test`.`t3`) on((`test`.`t2`.`a` = `test`.`t3`.`a`))) where (`test`.`t2`.`a` = `test`.`t1`.`a`) +SELECT * FROM t1 +WHERE t1.a IN (SELECT t2.a +FROM t2 LEFT JOIN (t2 AS t2inner, t3) ON t2.a=t3.a); +a +1 +1 +DROP TABLE t1,t2,t3; +# +# BUG#52329 - Wrong result: subquery materialization, IN, +# non-null field followed by nullable +# +CREATE TABLE t1 (a1 CHAR(8) NOT NULL, a2 char(8) NOT NULL); +CREATE TABLE t2a (b1 char(8), b2 char(8)); +CREATE TABLE t2b (b1 CHAR(8), b2 char(8) NOT NULL); +CREATE TABLE t2c (b1 CHAR(8) NOT NULL, b2 char(8)); +INSERT INTO t1 VALUES ('1 - 12', '2 - 22'); +INSERT INTO t2a VALUES ('1 - 11', '2 - 21'), +('1 - 11', '2 - 21'), +('1 - 12', '2 - 22'), +('1 - 12', '2 - 22'), +('1 - 13', '2 - 23'); +INSERT INTO t2b SELECT * FROM t2a; +INSERT INTO t2c SELECT * FROM t2a; +SELECT * FROM t1 +WHERE (a1, a2) IN ( +SELECT b1, b2 FROM t2c WHERE b1 > '0' GROUP BY b1, b2); +a1 a2 +1 - 12 2 - 22 +SELECT * FROM t1 +WHERE (a1, a2) IN ( +SELECT b1, b2 FROM t2a WHERE b1 > '0'); +a1 a2 +1 - 12 2 - 22 +SELECT * FROM t1 +WHERE (a1, a2) IN ( +SELECT b1, b2 FROM t2b WHERE b1 > '0'); +a1 a2 +1 - 12 2 - 22 +SELECT * FROM t1 +WHERE (a1, a2) IN ( +SELECT b1, b2 FROM t2c WHERE b1 > '0'); +a1 a2 +1 - 12 2 - 22 +DROP TABLE t1,t2a,t2b,t2c; +# End BUG#52329 +# +# Bug#45174: Incorrectly applied equality propagation caused wrong +# result on a query with a materialized semi-join. +# +CREATE TABLE t1 ( +varchar_nokey varchar(1) NOT NULL +) charset utf8mb4; +INSERT INTO t1 VALUES +('v'), ('u'), ('n'), ('l'), ('h'), ('u'), ('n'), ('j'), ('k'), +('e'), ('i'), ('u'), ('n'), ('b'), ('x'), (''), ('q'), ('u'); +CREATE TABLE t2 ( +pk int NOT NULL, +varchar_key varchar(1) NOT NULL, +varchar_nokey varchar(1) NOT NULL, +PRIMARY KEY(pk), +KEY varchar_key(varchar_key) +) charset utf8mb4; +INSERT INTO t2 VALUES +(11,'m','m'), (12,'j','j'), (13,'z','z'), (14,'a','a'), (15,'',''), +(16,'e','e'), (17,'t','t'), (19,'b','b'), (20,'w','w'), (21,'m','m'), +(23,'',''), (24,'w','w'), (26,'e','e'), (27,'e','e'), (28,'p','p'); +SELECT varchar_nokey +FROM t1 +WHERE (varchar_nokey, varchar_nokey) IN (SELECT varchar_key, varchar_nokey +FROM t2 +WHERE varchar_nokey < 'n' XOR pk); +varchar_nokey +explain SELECT varchar_nokey +FROM t1 +WHERE (varchar_nokey, varchar_nokey) IN (SELECT varchar_key, varchar_nokey +FROM t2 +WHERE varchar_nokey < 'n' XOR pk); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 18 100.00 NULL +1 SIMPLE t2 NULL ref varchar_key varchar_key 6 test.t1.varchar_nokey 2 6.67 Using where; Start temporary; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`varchar_nokey` AS `varchar_nokey` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`varchar_key` = `test`.`t1`.`varchar_nokey`) and (`test`.`t2`.`varchar_nokey` = `test`.`t1`.`varchar_nokey`) and ((`test`.`t2`.`varchar_nokey` < 'n') xor (0 <> `test`.`t2`.`pk`))) +DROP TABLE t1, t2; +# End of the test for bug#45174. +# +# Bug#50019: Wrong result for IN-query with materialization +# +CREATE TABLE t1(i INT); +INSERT INTO t1 VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10); +CREATE TABLE t2(i INT); +INSERT INTO t2 VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10); +CREATE TABLE t3(i INT); +INSERT INTO t3 VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10); +SELECT * FROM t1 WHERE t1.i IN (SELECT t2.i +FROM t2 JOIN t3 +WHERE t2.i + t3.i = 5); +i +1 +2 +3 +4 +explain SELECT * FROM t1 WHERE t1.i IN (SELECT t2.i +FROM t2 JOIN t3 +WHERE t2.i + t3.i = 5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 100.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 10 10.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 10 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = `test`.`t1`.`i`) and ((`test`.`t1`.`i` + `test`.`t3`.`i`) = 5)) +DROP TABLE t1,t2,t3; +# End of the test for bug#50019. +# +# Bug#52068: Optimizer generates invalid semijoin materialization plan +# +CREATE TABLE ot1(a INTEGER); +INSERT INTO ot1 VALUES(5), (8); +CREATE TABLE it2(a INTEGER); +INSERT INTO it2 VALUES(9), (5), (1), (8); +CREATE TABLE it3(a INTEGER); +INSERT INTO it3 VALUES(7), (1), (0), (5), (1), (4); +CREATE TABLE ot4(a INTEGER); +INSERT INTO ot4 VALUES(1), (3), (5), (7), (9), (7), (3), (1); +SELECT * FROM ot1,ot4 +WHERE (ot1.a,ot4.a) IN (SELECT it2.a,it3.a +FROM it2,it3); +a a +5 1 +5 1 +5 5 +5 7 +5 7 +8 1 +8 1 +8 5 +8 7 +8 7 +explain SELECT * FROM ot1,ot4 +WHERE (ot1.a,ot4.a) IN (SELECT it2.a,it3.a +FROM it2,it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE it2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; Using join buffer (hash join) +1 SIMPLE it3 NULL ALL NULL NULL NULL NULL 6 100.00 Using join buffer (hash join) +1 SIMPLE ot4 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot4`.`a` AS `a` from `test`.`ot1` join `test`.`ot4` semi join (`test`.`it2` join `test`.`it3`) where ((`test`.`ot4`.`a` = `test`.`it3`.`a`) and (`test`.`it2`.`a` = `test`.`ot1`.`a`)) +DROP TABLE IF EXISTS ot1, ot4, it2, it3; +# End of the test for bug#52068. +# +# Bug#57623: subquery within before insert trigger causes crash (sj=on) +# +CREATE TABLE ot1(a INT); +CREATE TABLE ot2(a INT); +CREATE TABLE ot3(a INT); +CREATE TABLE it1(a INT); +INSERT INTO ot1 VALUES(0),(1),(2),(3),(4),(5),(6),(7); +INSERT INTO ot2 VALUES(0),(2),(4),(6); +INSERT INTO ot3 VALUES(0),(3),(6); +INSERT INTO it1 VALUES(0),(1),(2),(3),(4),(5),(6),(7); +explain SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 on ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a from it1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 Start temporary +1 SIMPLE it1 NULL ALL NULL NULL NULL NULL 8 100.00 Using where; Using join buffer (hash join) +1 SIMPLE ot3 NULL ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (hash join) +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a`,`test`.`ot3`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` join `test`.`ot3` semi join (`test`.`it1`)) on(((`test`.`it1`.`a` = `test`.`ot1`.`a`) and (`test`.`ot3`.`a` = `test`.`ot1`.`a`) and (`test`.`ot2`.`a` = `test`.`ot1`.`a`))) where true +SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 on ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a from it1); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +prepare s from 'SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 on ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a from it1)'; +execute s; +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +execute s; +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +deallocate prepare s; +DROP TABLE ot1, ot2, ot3, it1; +# End of the test for bug#57623. +# +# Bug#11766739: Crash in tmp_table_param::init() with semijoin=on +# +CREATE TABLE t1 (f1 INTEGER) ENGINE=MyISAM; +CREATE TABLE t2 (f1 INTEGER, f2 INTEGER) ENGINE=MyISAM; +INSERT INTO t1 VALUES (1); +INSERT INTO t2 VALUES (1,1), (2,1); +EXPLAIN SELECT * FROM t2 +WHERE f2 IN (SELECT t1.f1 +FROM t1 LEFT OUTER JOIN (t2 AS b1 JOIN t2 AS b2 ON TRUE) ON TRUE); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE b1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +1 SIMPLE b2 NULL ALL NULL NULL NULL NULL 2 100.00 End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`f1` AS `f1`,`test`.`t2`.`f2` AS `f2` from `test`.`t2` semi join (`test`.`t1` left join (`test`.`t2` `b1` join `test`.`t2` `b2`) on((true))) where (`test`.`t2`.`f2` = `test`.`t1`.`f1`) +SELECT * FROM t2 +WHERE f2 IN (SELECT t1.f1 +FROM t1 LEFT OUTER JOIN (t2 AS b1 JOIN t2 AS b2 ON TRUE) ON TRUE); +f1 f2 +1 1 +2 1 +DROP TABLE t1, t2; +# End of the test for bug#11766739. +# +# Bug#11766642: crash in Item_field::register_field_in_read_map with view +# +CREATE TABLE t1(a INT); +CREATE VIEW v1 AS SELECT a FROM t1; +INSERT INTO t1 VALUES (0),(1),(2); +SELECT a FROM t1 WHERE a IN +(SELECT a XOR a FROM v1) +ORDER BY a; +a +0 +DROP TABLE t1; +DROP VIEW v1; +# +# Bug#12546542 MISSING ROW WHEN USING OPTIMIZER_JOIN_CACHE_LEVEL>=3 +# +CREATE TABLE t1 ( +f2 varchar(1024) +); +INSERT INTO t1 VALUES ('v'),('we'); +CREATE TABLE t2 ( +col_varchar_1024_utf8 varchar(1024) CHARACTER SET utf8 DEFAULT NULL, +col_int_key int, +col_int int +); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t2 VALUES ('we',4,NULL),('v',1305673728,6); +CREATE TABLE t3 ( +col_int_key int, +col_int int +); +INSERT INTO t3 VALUES (4,4); +SELECT * +FROM t1 +WHERE f2 IN (SELECT a1.col_varchar_1024_utf8 AS f2 +FROM t2 AS a1 LEFT JOIN t3 AS a2 +ON a1.col_int_key = a2.col_int_key +WHERE a1.col_int BETWEEN 1 AND 10 OR a2.col_int IS NOT NULL); +f2 +v +we +DROP TABLE t1,t2,t3; +# +# BUG#12616344 - JCL: DIFFERENT RESULT SET AND DIFFERENT AMOUNT +# OF ROWS WHEN JCL>=3 +# +CREATE TABLE t1 (col_int_nokey int, col_int_key int, col_varchar_key varchar(1)); +INSERT INTO t1 VALUES (0,4,'c'),(1,6,'u'); +CREATE TABLE t2 (pk int, col_int_nokey int, col_varchar_nokey varchar(1)); +INSERT INTO t2 VALUES (1,4,'b'),(94,6,'u'); +CREATE TABLE t3 (pk int, col_int_nokey int, col_varchar_key varchar(1)); +INSERT INTO t3 VALUES (1,4,'j'),(2,6,'v'); +SELECT table2.col_int_key +from t3 as table1 join t1 as table2 on table2.col_int_nokey +where table1.col_int_nokey in +( +select subquery2_t2.col_int_nokey +from t3 as subquery2_t1 +right join +t2 as subquery2_t2 +join t1 as subquery2_t3 +on subquery2_t3.col_int_key = subquery2_t2.col_int_nokey +on subquery2_t3.col_varchar_key = subquery2_t2.col_varchar_nokey +where subquery2_t1.col_varchar_key != table1.col_varchar_key +or subquery2_t2.pk <= table1.pk +); +col_int_key +6 +6 +DROP TABLE t1,t2,t3; +# +# Bug#12608157: ASSERT IN FIELD_LONG::VAL_INT WHEN USING MEMORY ENGINE +# +CREATE TABLE t1 (i1 int); +INSERT INTO t1 VALUES (1); +CREATE TABLE t2 (i1 int, i2 int) ENGINE=memory; +INSERT INTO t2 VALUES (1, 2),(7, 3); +SELECT GRANDPARENT1.i1 +FROM t2 AS GRANDPARENT1 +WHERE GRANDPARENT1.i2 +IN ( SELECT PARENT1.i2 +FROM t2 AS PARENT1 JOIN t1 AS PARENT2 ON (PARENT1.i1 = PARENT2.i1) +WHERE +GRANDPARENT1.i1 IN ( SELECT CHILD1.i1 FROM t2 AS CHILD1 ) +ORDER BY PARENT1.i1) +ORDER BY GRANDPARENT1.i2 ; +i1 +1 +DROP TABLE t1,t2; +# +# Bug#12640083: Same query executed as WHERE subquery gives different +# results on IN() compare +# +CREATE TABLE t1 ( +pk int NOT NULL, +col_varchar_1024_utf8_key varchar(1024) CHARACTER SET utf8 DEFAULT NULL, +col_varchar_10_latin1_key varchar(10) DEFAULT NULL, +PRIMARY KEY (pk), +KEY col_varchar_1024_utf8_key(col_varchar_1024_utf8_key(333)), +KEY col_varchar_10_latin1_key(col_varchar_10_latin1_key) +) charset utf8mb4; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES +(1, 'a', 'a'), +(2, 'ab', 'ab'), +(3, 'abc', 'abc'), +(4, 'abcd', 'abcd'); +CREATE TABLE t2 ( +pk int NOT NULL AUTO_INCREMENT, +PRIMARY KEY (pk) +) charset utf8mb4 ENGINE=Innodb; +CREATE TABLE t3 charset utf8mb4 +SELECT alias1.col_varchar_10_latin1_key +FROM t1 AS alias1 +LEFT JOIN t1 AS alias2 +JOIN t2 AS alias3 +ON alias2.col_varchar_10_latin1_key +ON alias1.col_varchar_1024_utf8_key +WHERE alias1.pk AND alias1.pk < 3 OR alias1.pk AND alias3.pk; +EXPLAIN SELECT * +FROM t3 +WHERE col_varchar_10_latin1_key IN ( +SELECT alias1.col_varchar_10_latin1_key +FROM t1 AS alias1 +LEFT JOIN t1 AS alias2 +JOIN t2 AS alias3 +ON alias2.col_varchar_10_latin1_key +ON alias1.col_varchar_1024_utf8_key +WHERE alias1.pk AND alias1.pk < 3 OR alias1.pk AND alias3.pk); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Start temporary +1 SIMPLE alias1 NULL ref PRIMARY,col_varchar_10_latin1_key col_varchar_10_latin1_key 43 test.t3.col_varchar_10_latin1_key 2 100.00 Using where +1 SIMPLE alias3 NULL index NULL PRIMARY 4 NULL 1 100.00 Using where; Using index; Using join buffer (hash join) +1 SIMPLE alias2 NULL index NULL col_varchar_10_latin1_key 43 NULL 4 100.00 Using where; Using index; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`col_varchar_10_latin1_key` AS `col_varchar_10_latin1_key` from `test`.`t3` semi join (`test`.`t1` `alias1` left join (`test`.`t1` `alias2` join `test`.`t2` `alias3`) on(((0 <> `test`.`alias1`.`col_varchar_1024_utf8_key`) and (0 <> `test`.`alias2`.`col_varchar_10_latin1_key`)))) where ((`test`.`alias1`.`col_varchar_10_latin1_key` = `test`.`t3`.`col_varchar_10_latin1_key`) and (((0 <> `test`.`alias1`.`pk`) and (`test`.`alias1`.`pk` < 3)) or ((0 <> `test`.`alias1`.`pk`) and (0 <> `test`.`alias3`.`pk`)))) +SELECT * +FROM t3 +WHERE col_varchar_10_latin1_key IN ( +SELECT alias1.col_varchar_10_latin1_key +FROM t1 AS alias1 +LEFT JOIN t1 AS alias2 +JOIN t2 AS alias3 +ON alias2.col_varchar_10_latin1_key +ON alias1.col_varchar_1024_utf8_key +WHERE alias1.pk AND alias1.pk < 3 OR alias1.pk AND alias3.pk); +col_varchar_10_latin1_key +a +ab +DROP TABLE t1, t2, t3; +# End of the test for bug#12640083. +# +# Bug#12603200 - Assert in QUICK_INDEX_MERGE_SELECT::need_sorted_output +# +CREATE TABLE t1 ( +pk int NOT NULL, +col_int_key int NOT NULL, +col_varchar_nokey varchar(1) NOT NULL, +col_varchar_key varchar(1) NOT NULL, +PRIMARY KEY(pk), +KEY col_int_key(col_int_key), +KEY col_varchar_key(col_varchar_key, col_int_key) +) charset utf8mb4 engine=innodb; +INSERT INTO t1 VALUES +(1,7,'a','a'), +(2,0,'v','v'), +(3,9,'c','c'), +(4,3,'m','m'), +(5,2,'a','a'), +(6,1,'d','d'), +(7,8,'y','y'), +(8,6,'t','t'), +(11,7,'a','x'), +(12,0,'v','v'), +(13,9,'c','c'), +(14,3,'m','m'), +(15,2,'a','x'), +(16,1,'d','d'), +(17,8,'y','y'), +(18,6,'t','u'), +(19,6,'t','u'); +CREATE TABLE t2 ( +pk int NOT NULL, +col_int_key int NOT NULL, +col_varchar_key varchar(1) NOT NULL, +PRIMARY KEY(pk), +KEY col_varchar_key(col_varchar_key, col_int_key) +) charset utf8mb4 engine=innodb; +INSERT INTO t2(pk,col_int_key,col_varchar_key) VALUES +(8,7,'c'), +(11,4,'l'), +(12,7,'b'), +(13,0,'c'), +(14,2,'i'), +(15,9,'h'), +(16,4,'q'), +(17,1,'m'), +(18,9,'b'), +(19,2,'e'), +(20,1,'c'), +(21,7,'z'), +(22,4,'l'), +(23,7,'z'), +(24,0,'c'), +(25,2,'i'), +(26,9,'h'), +(27,4,'q'), +(28,0,'a'), +(29,1,'d'); +EXPLAIN SELECT outr.col_varchar_key AS x, outr.pk AS y +FROM t1 AS outr +WHERE outr.col_varchar_key IN (SELECT innr.col_varchar_key +FROM t2 AS innr +WHERE innr.col_varchar_key = 'a' OR innr.pk = 8) +AND outr.col_varchar_nokey < 't' +ORDER BY outr.col_varchar_key, outr.pk; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE innr NULL index_merge PRIMARY,col_varchar_key col_varchar_key,PRIMARY 6,4 NULL 2 100.00 Using sort_union(col_varchar_key,PRIMARY); Using where; Using temporary; Using filesort; Start temporary +1 SIMPLE outr NULL ref col_varchar_key col_varchar_key 6 test.innr.col_varchar_key 1 33.33 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`outr`.`col_varchar_key` AS `x`,`test`.`outr`.`pk` AS `y` from `test`.`t1` `outr` semi join (`test`.`t2` `innr`) where ((`test`.`outr`.`col_varchar_key` = `test`.`innr`.`col_varchar_key`) and (`test`.`outr`.`col_varchar_nokey` < 't') and ((`test`.`innr`.`col_varchar_key` = 'a') or (`test`.`innr`.`pk` = 8))) order by `test`.`outr`.`col_varchar_key`,`test`.`outr`.`pk` +SELECT outr.col_varchar_key AS x, outr.pk AS y +FROM t1 AS outr +WHERE outr.col_varchar_key IN (SELECT innr.col_varchar_key +FROM t2 AS innr +WHERE innr.col_varchar_key = 'a' OR innr.pk = 8) +AND outr.col_varchar_nokey < 't' +ORDER BY outr.col_varchar_key, outr.pk; +x y +a 1 +a 5 +c 3 +c 13 +DROP TABLE t1, t2; +# End of bug#12603200 +# +# Bug#12603183: Segfault in hp_movelink +# +CREATE TABLE t1 ( +col_varchar_key varchar(1) , +col_varchar_nokey varchar(1) , +KEY col_varchar_key(col_varchar_key) +) charset latin1; +INSERT INTO t1 VALUES +('i','i'), +('h','h'), +('q','q'), +('a','a'), +('v','v'), +('u','u'), +('s','s'), +('y','y'), +('z','z'), +('h','h'), +('p','p'), +('e','e'), +('i','i'), +('y','y'), +('w','w'); +CREATE TABLE t2 ( +col_varchar_nokey varchar(1) +) charset latin1; +INSERT INTO t2 VALUES +('b'); +EXPLAIN SELECT grandparent1.col_varchar_nokey +FROM t1 AS grandparent1 LEFT JOIN t2 AS grandparent2 USING (col_varchar_nokey) +WHERE (grandparent1.col_varchar_key) IN +(SELECT parent1.col_varchar_nokey +FROM t1 AS parent1 +WHERE parent1.col_varchar_key IN +(SELECT child1.col_varchar_nokey AS c1 +FROM t1 AS child1 LEFT JOIN t2 AS child2 +ON (child1.col_varchar_key > child2.col_varchar_nokey))); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE child1 NULL ALL NULL NULL NULL NULL 15 100.00 Using where; Start temporary +1 SIMPLE child2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE parent1 NULL ref col_varchar_key col_varchar_key 4 test.child1.col_varchar_nokey 2 100.00 Using where +1 SIMPLE grandparent1 NULL ref col_varchar_key col_varchar_key 4 test.parent1.col_varchar_nokey 2 100.00 End temporary +1 SIMPLE grandparent2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`grandparent1`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t1` `grandparent1` left join `test`.`t2` `grandparent2` on((`test`.`grandparent2`.`col_varchar_nokey` = `test`.`grandparent1`.`col_varchar_nokey`)) semi join (`test`.`t1` `parent1` join `test`.`t1` `child1` left join `test`.`t2` `child2` on((`test`.`child1`.`col_varchar_key` > `test`.`child2`.`col_varchar_nokey`))) where ((`test`.`grandparent1`.`col_varchar_key` = `test`.`parent1`.`col_varchar_nokey`) and (`test`.`parent1`.`col_varchar_key` = `test`.`child1`.`col_varchar_nokey`)) +SELECT grandparent1.col_varchar_nokey +FROM t1 AS grandparent1 LEFT JOIN t2 AS grandparent2 USING (col_varchar_nokey) +WHERE (grandparent1.col_varchar_key) IN +(SELECT parent1.col_varchar_nokey +FROM t1 AS parent1 +WHERE parent1.col_varchar_key IN +(SELECT child1.col_varchar_nokey AS c1 +FROM t1 AS child1 LEFT JOIN t2 AS child2 +ON (child1.col_varchar_key > child2.col_varchar_nokey))); +col_varchar_nokey +a +e +h +h +i +i +p +q +s +u +v +w +y +y +z +DROP TABLE t1, t2; +# End of test for bug#12603183. +# +# Bug#12818569: Diff nr of rows returned when using IN/ALL+subquery +# +CREATE TABLE t1 ( +col_int_key INT NOT NULL, +col_datetime_key DATETIME NOT NULL, +col_varchar_key VARCHAR(1) NOT NULL, +KEY col_int_key (col_int_key), +KEY col_datetime_key(col_datetime_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t1 VALUES +(7,'2004-06-06 04:22:12','v'), (0,'2005-11-13 01:12:31','s'), +(9,'2002-05-04 01:50:00','l'), (3,'2004-10-27 10:28:45','y'), +(4,'2006-07-22 05:24:23','c'), (2,'2002-05-16 21:34:03','i'), +(5,'2008-04-17 10:45:30','h'), (3,'2009-04-21 02:58:02','q'), +(1,'2008-01-11 11:01:51','a'), (3,'1900-01-01 00:00:00','v'), +(6,'2007-05-17 18:24:57','u'), (7,'2007-08-07 00:00:00','s'), +(5,'2001-08-28 00:00:00','y'), (1,'2004-04-16 00:27:28','z'), +(204,'2005-05-03 07:06:22','h'), (224,'2009-03-11 17:09:50','p'), +(9,'2007-12-08 01:54:28','e'), (5,'2009-07-28 18:19:54','i'), +(0,'2008-06-08 00:00:00','y'), (3,'2005-02-09 09:20:26','w'); +CREATE TABLE t2 ( +col_varchar_nokey VARCHAR(1) NOT NULL +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t2 VALUES ('v'), ('y'), ('j'), ('c'), ('d'), ('r'); +explain SELECT col_varchar_key +FROM t1 +WHERE col_varchar_key IN (SELECT col_varchar_nokey +FROM t2) +ORDER BY col_datetime_key LIMIT 4; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 100.00 Using temporary; Using filesort; Start temporary +1 SIMPLE t1 NULL ref col_varchar_key col_varchar_key 6 test.t2.col_varchar_nokey 1 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col_varchar_key` AS `col_varchar_key` from `test`.`t1` semi join (`test`.`t2`) where (`test`.`t1`.`col_varchar_key` = `test`.`t2`.`col_varchar_nokey`) order by `test`.`t1`.`col_datetime_key` limit 4 +SELECT col_varchar_key +FROM t1 +WHERE col_varchar_key IN (SELECT col_varchar_nokey +FROM t2) +ORDER BY col_datetime_key LIMIT 4; +col_varchar_key +v +y +v +y +DROP TABLE t1, t2; +# End of test for bug#12818569. +# +# Bug#12803439: Assert in replace_subcondition() on update query +# +CREATE TABLE t1(a INTEGER); +INSERT INTO t1 values(1), (2); +CREATE TABLE t2(a INTEGER); +INSERT INTO t2 VALUES(1), (3); +SELECT * +FROM t1 +WHERE a IN (SELECT a +FROM t2 +HAVING a IN (SELECT a +FROM t2) +) +HAVING a IN (SELECT a +FROM t2); +a +1 +DROP TABLE t1, t2; +# End of test for bug#12803439. +# +# Bug#12797534: Segfault in hp_movelink still exists +# +CREATE TABLE t1 ( +g1 VARCHAR(1) NOT NULL +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t1 VALUES ('d'), ('s'); +CREATE TABLE t2 ( +pk INT NOT NULL, +col_int_key INT NOT NULL, +col_varchar_key VARCHAR(1) NOT NULL, +col_varchar_nokey VARCHAR(1) NOT NULL, +PRIMARY KEY (pk), +KEY col_varchar_key(col_varchar_key, col_int_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t2 VALUES +(1,4,'j','j'), (2,6,'v','v'), (3,3,'c','c'), (4,5,'m','m'), +(5,3,'d','d'), (6,246,'d','d'), (7,2,'y','y'), (8,9,'t','t'), +(9,3,'d','d'), (10,8,'s','s'), (11,1,'r','r'), (12,8,'m','m'), +(13,8,'b','b'), (14,5,'x','x'), (15,7,'g','g'), (16,5,'p','p'), +(17,1,'q','q'), (18,6,'w','w'), (19,2,'d','d'), (20,9,'e','e'); +CREATE TABLE t3 ( +pk INTEGER NOT NULL, +PRIMARY KEY (pk) +) ENGINE=InnoDB; +INSERT INTO t3 VALUES (10); +EXPLAIN SELECT * +FROM t1 +WHERE g1 NOT IN +(SELECT grandparent1.col_varchar_nokey AS g1 +FROM t2 AS grandparent1 +WHERE grandparent1.col_varchar_key IN +(SELECT parent1.col_varchar_nokey AS p1 +FROM t2 AS parent1 LEFT JOIN t3 AS parent2 USING (pk) +) +AND grandparent1.col_varchar_key IS NOT NULL +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 SIMPLE parent1 NULL ALL NULL NULL NULL NULL 20 100.00 Using where; Not exists; Start temporary +2 SIMPLE parent2 NULL eq_ref PRIMARY PRIMARY 4 test.parent1.pk 1 100.00 Using index +2 SIMPLE grandparent1 NULL ref col_varchar_key col_varchar_key 6 test.parent1.col_varchar_nokey 1 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`g1` AS `g1` from `test`.`t1` anti join (`test`.`t2` `grandparent1` join `test`.`t2` `parent1` left join `test`.`t3` `parent2` on((`test`.`parent2`.`pk` = `test`.`parent1`.`pk`))) on(((`test`.`grandparent1`.`col_varchar_nokey` = `test`.`t1`.`g1`) and (`test`.`grandparent1`.`col_varchar_key` = `test`.`parent1`.`col_varchar_nokey`) and (`test`.`grandparent1`.`col_varchar_key` is not null))) where true +SELECT * +FROM t1 +WHERE g1 NOT IN +(SELECT grandparent1.col_varchar_nokey AS g1 +FROM t2 AS grandparent1 +WHERE grandparent1.col_varchar_key IN +(SELECT parent1.col_varchar_nokey AS p1 +FROM t2 AS parent1 LEFT JOIN t3 AS parent2 USING (pk) +) +AND grandparent1.col_varchar_key IS NOT NULL +); +g1 +DROP TABLE t1, t2, t3; +CREATE TABLE t1 ( +pk INTEGER AUTO_INCREMENT, +col_int_key INTEGER , +col_varchar_key VARCHAR(1) , +col_varchar_nokey VARCHAR(1) , +PRIMARY KEY (pk), +KEY (col_varchar_key,col_int_key) +) ENGINE=INNODB; +INSERT INTO t1 (col_int_key,col_varchar_key,col_varchar_nokey) VALUES +(0,'x','x'), (1,'j','j'), (1,'r','r'), (9,'v','v'), (5,'r','r'); +CREATE TABLE t2 ( +pk INTEGER AUTO_INCREMENT, +col_int_key INTEGER , +col_varchar_key VARCHAR(1) , +col_varchar_nokey VARCHAR(1) , +PRIMARY KEY (pk), +KEY (col_int_key), +KEY (col_varchar_key,col_int_key) +) AUTO_INCREMENT=10 ENGINE=INNODB; +INSERT INTO t2 (col_int_key, col_varchar_key, col_varchar_nokey) VALUES +(NULL,'x','x'), (NULL,'j','j'), (8,'c','c'); +CREATE TABLE t3 +SELECT outr.col_varchar_nokey AS x +FROM t1 AS outr +WHERE outr.col_varchar_nokey IN +(SELECT innr.col_varchar_nokey AS y +FROM t2 AS innr +WHERE innr.col_int_key IS NULL) +AND outr.col_varchar_nokey IS NOT NULL +AND NOT col_varchar_key IS NULL; +SELECT * +FROM t3 +WHERE x NOT IN +(SELECT outr.col_varchar_nokey AS x +FROM t1 AS outr +WHERE outr.col_varchar_nokey IN +(SELECT innr.col_varchar_nokey AS y +FROM t2 AS innr +WHERE innr.col_int_key IS NULL) +AND outr.col_varchar_nokey IS NOT NULL +AND NOT col_varchar_key IS NULL); +x +DROP TABLE t1, t2, t3; +# End of test for bug#12797534. +# +# Bug#12714094: Assert in optimize_semijoin_nests() +# +CREATE TABLE it ( +pk int NOT NULL, +col_varchar VARCHAR(10) DEFAULT NULL, +PRIMARY KEY (pk) +) ENGINE=MyISAM; +INSERT INTO it VALUES (1, 'g'); +CREATE TABLE ot +SELECT alias1.pk AS field1 +FROM it AS alias1 +LEFT JOIN it AS alias2 +ON alias1.col_varchar = alias2.col_varchar +; +SELECT * +FROM ot +WHERE field1 IN ( +SELECT alias1.pk +FROM it AS alias1 +LEFT JOIN it AS alias2 +ON alias1.col_varchar = alias2.col_varchar +); +field1 +1 +DROP TABLE it, ot; +# End of test for bug#12714094 +# +# Bug#12867557: Valgrind: conditional jump/move at key_cmp +# +CREATE TABLE t1 ( +pk INTEGER AUTO_INCREMENT, +col_int_key INTEGER, +PRIMARY KEY (pk), +KEY (col_int_key) +) AUTO_INCREMENT=10; +INSERT INTO t1 (col_int_key) VALUES (8); +CREATE TABLE t2 ( +pk INTEGER AUTO_INCREMENT, +col_int_key INTEGER, +col_time_key TIME, +PRIMARY KEY (pk), +KEY (col_int_key), +KEY (col_time_key) +) AUTO_INCREMENT=10; +INSERT INTO t2 (col_int_key, col_time_key) +VALUES +(8, '22:55:23.019225'), (7, '10:19:31.050677'), (1, '14:40:36.038608'), +(7, '04:37:47.062416'), (9, '19:34:06.054514'), (NULL,'20:35:33.022996'), +(1, NULL), (9, '14:43:37.057393'), (2, '02:23:09.043438'), +(9, '01:22:45.041064'), (2, '00:00:00'), (4, '00:13:25.038482'), +(0, '03:47:16.042671'), (4, '01:41:48.007423'), (8, '00:00:00'), +(NULL, '22:32:04.047407'), (NULL, '16:44:14.028443'), (0, '17:38:37.059754'), +(NULL, '08:46:48.042388'), (8, '14:11:27.044095'); +CREATE TABLE t0 +SELECT DISTINCT grandparent1.col_time_key AS g1 +FROM t2 AS grandparent1 +WHERE grandparent1.col_int_key IN +(SELECT parent1.col_int_key AS p1 +FROM t1 AS parent1) +AND grandparent1.pk > 9; +UPDATE t0 +SET g1 = g1 +WHERE g1 IN +(SELECT grandparent1.col_time_key AS g1 +FROM t2 AS grandparent1 +WHERE grandparent1.col_int_key IN +(SELECT parent1.col_int_key AS p1 +FROM t1 AS parent1) +AND grandparent1.pk > 9); +DROP TABLE t0, t1, t2; +# End of test for bug#12867557 +# +# Bug#12711441: crash in fix_after_pullout +# +CREATE TABLE t1 ( +pk int NOT NULL, +col_int_nokey int DEFAULT NULL, +col_int_key int DEFAULT NULL, +col_time_key time DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +PRIMARY KEY (pk) +); +CREATE VIEW v1 AS SELECT * FROM t1; +CREATE TABLE t2 ( +col_int_key int DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +KEY col_varchar_key(col_varchar_key, col_int_key) +); +CREATE TABLE t3 ( +pk int NOT NULL, +col_int_key INT DEFAULT NULL, +PRIMARY KEY (pk) +); +CREATE TABLE t4 ( +col_int_nokey INT DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +KEY col_varchar_key(col_varchar_key) +); +CREATE TABLE ts +SELECT alias1.col_time_key AS field1 +FROM v1 AS alias1 +RIGHT JOIN t3 AS alias2 +ON alias2.col_int_key = alias1.col_int_nokey +WHERE alias1.pk >= SOME( +SELECT SQ1_alias1.pk AS SQ1_field1 +FROM t3 AS SQ1_alias1 +INNER JOIN (t2 AS SQ1_alias2 +INNER JOIN t4 AS SQ1_alias3 +ON SQ1_alias3.col_varchar_key = SQ1_alias2.col_varchar_nokey) +ON SQ1_alias3.col_int_nokey = SQ1_alias2.col_int_key +WHERE SQ1_alias2.col_varchar_key <= alias1.col_varchar_key +AND SQ1_alias3.col_varchar_nokey <> alias1.col_varchar_key) +; +SELECT * FROM ts WHERE field1 IN ( +SELECT alias1.col_time_key AS field1 +FROM v1 AS alias1 +RIGHT JOIN t3 AS alias2 +ON alias2.col_int_key = alias1.col_int_nokey +WHERE alias1.pk >= SOME( +SELECT SQ1_alias1.pk AS SQ1_field1 +FROM t3 AS SQ1_alias1 +INNER JOIN (t2 AS SQ1_alias2 +INNER JOIN t4 AS SQ1_alias3 +ON SQ1_alias3.col_varchar_key = SQ1_alias2.col_varchar_nokey) +ON SQ1_alias3.col_int_nokey = SQ1_alias2.col_int_key +WHERE SQ1_alias2.col_varchar_key <= alias1.col_varchar_key +AND SQ1_alias3.col_varchar_nokey <> alias1.col_varchar_key) +); +field1 +DROP TABLE t1, t2, t3, t4, ts; +DROP VIEW v1; +# End of test for bug#12711441. +# +# Bug#12664936: Same query executed as where subquery ... +# +CREATE TABLE t1 ( +col_varchar_key VARCHAR(1), +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4; +INSERT INTO t1 VALUES +('o'), ('w'), ('m'), ('q'), +('f'), ('p'), ('j'), ('c'); +CREATE TABLE t2 ( +col_int_nokey INTEGER, +col_int_key INTEGER, +col_varchar_key varchar(1), +KEY col_int_key (col_int_key) +) charset utf8mb4; +INSERT INTO t2 VALUES +(8,5,'u'),(4,5,'p'),(8,1,'o'),(NULL,7,'v'), +(1,2,'g'),(2,1,'q'),(NULL,7,'l'),(3,1,'n'); +CREATE TABLE t4 +SELECT t2.col_int_nokey, t2.col_varchar_key +FROM t1 JOIN t2 ON t2.col_varchar_key = t1.col_varchar_key +WHERE t2.col_int_key = 1; +EXPLAIN SELECT * +FROM t4 +WHERE (col_int_nokey, col_varchar_key) IN +(SELECT t2.col_int_nokey, t2.col_varchar_key +FROM t1 JOIN t2 ON t2.col_varchar_key = t1.col_varchar_key +WHERE t2.col_int_key = 1 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t4 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE t2 NULL ref col_int_key col_int_key 5 const 3 12.50 Using where; Start temporary +1 SIMPLE t1 NULL ref col_varchar_key col_varchar_key 7 test.t4.col_varchar_key 2 100.00 Using index; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`col_int_nokey` AS `col_int_nokey`,`test`.`t4`.`col_varchar_key` AS `col_varchar_key` from `test`.`t4` semi join (`test`.`t1` join `test`.`t2`) where ((`test`.`t2`.`col_varchar_key` = `test`.`t4`.`col_varchar_key`) and (`test`.`t1`.`col_varchar_key` = `test`.`t4`.`col_varchar_key`) and (`test`.`t2`.`col_int_nokey` = `test`.`t4`.`col_int_nokey`) and (`test`.`t2`.`col_int_key` = 1)) +SELECT * +FROM t4 +WHERE (col_int_nokey, col_varchar_key) IN +(SELECT t2.col_int_nokey, t2.col_varchar_key +FROM t1 JOIN t2 ON t2.col_varchar_key = t1.col_varchar_key +WHERE t2.col_int_key = 1 +); +col_int_nokey col_varchar_key +8 o +2 q +DROP TABLE t1, t2, t4; +# End of test for bug#12664936. +# +# Bug#13340270: assertion table->sort.record_pointers == __null +# +CREATE TABLE t1 ( +pk int NOT NULL, +col_int_key int DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key, col_int_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t1 VALUES +(10,8,'x','x'), +(11,7,'d','d'), +(12,1,'r','r'), +(13,7,'f','f'), +(14,9,'y','y'), +(15,NULL,'u','u'), +(16,1,'m','m'), +(17,9,NULL,NULL), +(18,2,'o','o'), +(19,9,'w','w'), +(20,2,'m','m'), +(21,4,'q','q'); +CREATE TABLE t2 +SELECT alias1.col_varchar_nokey AS field1 +FROM t1 AS alias1 JOIN t1 AS alias2 +ON alias2.col_int_key = alias1.pk OR +alias2.col_int_key = alias1.col_int_key +WHERE alias1.pk = 58 OR alias1.col_varchar_key = 'o' + +; +EXPLAIN SELECT * +FROM t2 +WHERE (field1) IN (SELECT alias1.col_varchar_nokey AS field1 +FROM t1 AS alias1 JOIN t1 AS alias2 +ON alias2.col_int_key = alias1.pk OR +alias2.col_int_key = alias1.col_int_key +WHERE alias1.pk = 58 OR alias1.col_varchar_key = 'o' +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE alias1 NULL index_merge PRIMARY,col_int_key,col_varchar_key col_varchar_key,PRIMARY 7,4 NULL 2 10.00 Using sort_union(col_varchar_key,PRIMARY); Using where; Using join buffer (hash join) +1 SIMPLE alias2 NULL ALL col_int_key NULL NULL NULL 12 19.00 Range checked for each record (index map: 0x2); End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`field1` AS `field1` from `test`.`t2` semi join (`test`.`t1` `alias1` join `test`.`t1` `alias2`) where ((`test`.`alias1`.`col_varchar_nokey` = `test`.`t2`.`field1`) and ((`test`.`alias1`.`pk` = 58) or (`test`.`alias1`.`col_varchar_key` = 'o')) and ((`test`.`alias2`.`col_int_key` = `test`.`alias1`.`pk`) or (`test`.`alias2`.`col_int_key` = `test`.`alias1`.`col_int_key`))) +SELECT * +FROM t2 +WHERE (field1) IN (SELECT alias1.col_varchar_nokey AS field1 +FROM t1 AS alias1 JOIN t1 AS alias2 +ON alias2.col_int_key = alias1.pk OR +alias2.col_int_key = alias1.col_int_key +WHERE alias1.pk = 58 OR alias1.col_varchar_key = 'o' +); +field1 +o +o +DROP TABLE t1, t2; +# End of test for bug#13340270. +# +# Bug#13335319: Seg fault when analyzing FirstMatch semi-join strategy +# +CREATE TABLE ot1(a INTEGER); +INSERT INTO ot1 VALUES(1), (2), (3); +CREATE TABLE ot2(a INTEGER); +INSERT INTO ot2 VALUES(1), (2), (4), (6), (8), (10); +CREATE TABLE it1(a INTEGER); +INSERT INTO it1 VALUES(1), (3), (5), (7); +CREATE TABLE it2(a INTEGER); +INSERT INTO it2 VALUES(1), (3), (5), (7), (9); +explain SELECT ot1.a, ot2.a +FROM ot1, ot2 +WHERE ot1.a IN (SELECT a FROM it1) AND +ot2.a IN (SELECT a FROM it2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 3 100.00 Start temporary +1 SIMPLE it1 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; Using join buffer (hash join) +1 SIMPLE it2 NULL ALL NULL NULL NULL NULL 5 100.00 Using join buffer (hash join) +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` join `test`.`ot2` semi join (`test`.`it1`) semi join (`test`.`it2`) where ((`test`.`ot2`.`a` = `test`.`it2`.`a`) and (`test`.`it1`.`a` = `test`.`ot1`.`a`)) +SELECT ot1.a, ot2.a +FROM ot1, ot2 +WHERE ot1.a IN (SELECT a FROM it1) AND +ot2.a IN (SELECT a FROM it2); +a a +1 1 +3 1 +DROP TABLE ot1, ot2, it1, it2; +# End of test for bug#13335319. +# +# Bug#13334882: Assertion keypart_map failed in MyIsam function +# +CREATE TABLE t1 ( +pk int NOT NULL, +col_int_nokey INT NOT NULL, +col_int_key INT NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +) ENGINE=MyISAM; +INSERT INTO t1 VALUES +(1,4,0), +(2,6,8), +(3,3,1), +(7,2,6), +(8,9,1), +(9,3,6), +(10,8,2), +(11,1,4), +(12,8,8), +(13,8,4), +(14,5,4); +CREATE TABLE t2 ( +pk int NOT NULL, +col_int_nokey int NOT NULL, +col_int_key int NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +) ENGINE=MyISAM; +INSERT INTO t2 VALUES +(10,8,7); +CREATE TABLE t3 +SELECT grandparent1.col_int_nokey AS g1 +FROM t1 AS grandparent1 +WHERE (grandparent1.col_int_nokey, grandparent1.col_int_key) IN +(SELECT parent1.col_int_key AS p1, +parent1.col_int_key AS p2 +FROM t1 AS parent1 +LEFT JOIN t2 AS parent2 +ON parent1.col_int_nokey = parent2.col_int_key +) +AND grandparent1.col_int_key <> 3 +; +explain SELECT * FROM t3 +WHERE g1 NOT IN +(SELECT grandparent1.col_int_nokey AS g1 +FROM t1 AS grandparent1 +WHERE (grandparent1.col_int_nokey, grandparent1.col_int_key) IN +(SELECT parent1.col_int_key AS p1, +parent1.col_int_key AS p2 +FROM t1 AS parent1 +LEFT JOIN t2 AS parent2 +ON parent1.col_int_nokey = parent2.col_int_key +) +AND grandparent1.col_int_key <> 3 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE grandparent1 NULL ref col_int_key col_int_key 4 const 1 100.00 Using where; Not exists; Start temporary +1 SIMPLE parent1 NULL ref col_int_key col_int_key 4 test.grandparent1.col_int_nokey 1 100.00 Using where +1 SIMPLE parent2 NULL ref col_int_key col_int_key 4 test.parent1.col_int_nokey 2 100.00 Using index; End temporary +Warnings: +Note 1003 /* select#1 */ select '8' AS `g1` from anti join (`test`.`t1` `grandparent1` join `test`.`t1` `parent1` left join `test`.`t2` `parent2` on((`test`.`parent2`.`col_int_key` = `test`.`parent1`.`col_int_nokey`))) on(((`test`.`grandparent1`.`col_int_nokey` = '8') and (`test`.`grandparent1`.`col_int_key` = '8') and (`test`.`parent1`.`col_int_key` = '8') and ('8' <> 3))) where true +explain format=json SELECT * FROM t3 +WHERE g1 NOT IN +(SELECT grandparent1.col_int_nokey AS g1 +FROM t1 AS grandparent1 +WHERE (grandparent1.col_int_nokey, grandparent1.col_int_key) IN +(SELECT parent1.col_int_key AS p1, +parent1.col_int_key AS p2 +FROM t1 AS parent1 +LEFT JOIN t2 AS parent2 +ON parent1.col_int_nokey = parent2.col_int_key +) +AND grandparent1.col_int_key <> 3 +); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "2.70" + }, + "nested_loop": [ + { + "table": { + "table_name": "t3", + "access_type": "system", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.00", + "eval_cost": "0.10", + "prefix_cost": "0.00", + "data_read_per_join": "8" + }, + "used_columns": [ + "g1" + ] + } + }, + { + "duplicates_removal": { + "using_temporary_table": true, + "nested_loop": [ + { + "table": { + "table_name": "grandparent1", + "access_type": "ref", + "possible_keys": [ + "col_int_key" + ], + "key": "col_int_key", + "used_key_parts": [ + "col_int_key" + ], + "key_length": "4", + "ref": [ + "const" + ], + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "not_exists": true, + "cost_info": { + "read_cost": "0.28", + "eval_cost": "0.11", + "prefix_cost": "0.39", + "data_read_per_join": "17" + }, + "used_columns": [ + "col_int_nokey", + "col_int_key" + ], + "attached_condition": "(((is_not_null_compl(grandparent1..parent2), (found_match(grandparent1..parent2), false, true), true) and (is_not_null_compl(grandparent1..parent2), (('8' <> 3)), true)) and (is_not_null_compl(grandparent1..parent2), (`test`.`grandparent1`.`col_int_nokey` = '8'), true))" + } + }, + { + "table": { + "table_name": "parent1", + "access_type": "ref", + "possible_keys": [ + "col_int_key" + ], + "key": "col_int_key", + "used_key_parts": [ + "col_int_key" + ], + "key_length": "4", + "ref": [ + "test.grandparent1.col_int_nokey" + ], + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.30", + "eval_cost": "0.12", + "prefix_cost": "0.81", + "data_read_per_join": "19" + }, + "used_columns": [ + "col_int_nokey", + "col_int_key" + ], + "attached_condition": "(is_not_null_compl(grandparent1..parent2), (`test`.`parent1`.`col_int_key` = '8'), true)" + } + }, + { + "table": { + "table_name": "parent2", + "access_type": "ref", + "possible_keys": [ + "col_int_key" + ], + "key": "col_int_key", + "used_key_parts": [ + "col_int_key" + ], + "key_length": "4", + "ref": [ + "test.parent1.col_int_nokey" + ], + "rows_examined_per_scan": 2, + "rows_produced_per_join": 1, + "filtered": "100.00", + "using_index": true, + "cost_info": { + "read_cost": "0.31", + "eval_cost": "0.10", + "prefix_cost": "2.70", + "data_read_per_join": "16" + }, + "used_columns": [ + "col_int_key" + ] + } + } + ] + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select '8' AS `g1` from anti join (`test`.`t1` `grandparent1` join `test`.`t1` `parent1` left join `test`.`t2` `parent2` on((`test`.`parent2`.`col_int_key` = `test`.`parent1`.`col_int_nokey`))) on(((`test`.`grandparent1`.`col_int_nokey` = '8') and (`test`.`grandparent1`.`col_int_key` = '8') and (`test`.`parent1`.`col_int_key` = '8') and ('8' <> 3))) where true +SELECT * FROM t3 +WHERE g1 NOT IN +(SELECT grandparent1.col_int_nokey AS g1 +FROM t1 AS grandparent1 +WHERE (grandparent1.col_int_nokey, grandparent1.col_int_key) IN +(SELECT parent1.col_int_key AS p1, +parent1.col_int_key AS p2 +FROM t1 AS parent1 +LEFT JOIN t2 AS parent2 +ON parent1.col_int_nokey = parent2.col_int_key +) +AND grandparent1.col_int_key <> 3 +); +g1 +DROP TABLE t1, t2, t3; +# End of test for bug#13334882. +# +# Bug#13339643: Assertion on JOIN::flatten_subqueries on second execution +# +CREATE TABLE t1 ( +col_int_nokey INT, +col_varchar_nokey VARCHAR(1) +) charset utf8mb4; +INSERT INTO t1 VALUES +(1,'o'), +(2,'t'); +CREATE TABLE t2 LIKE t1; +INSERT INTO t2 VALUES +(1,'o'), +(4,'f'); +CREATE VIEW v_t2 AS SELECT * FROM t2; +CREATE TABLE t3 LIKE t1; +INSERT INTO t3 VALUES +(1,'o'), +(4,'f'); +explain SELECT alias1.col_varchar_nokey +FROM t1 AS alias1 +INNER JOIN v_t2 AS alias2 +ON alias2.col_int_nokey = alias1.col_int_nokey AND +'o' IN (SELECT col_varchar_nokey +FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary; End temporary +1 SIMPLE alias1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`alias1`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t1` `alias1` join `test`.`t2` semi join (`test`.`t3`) where ((`test`.`t3`.`col_varchar_nokey` = 'o') and (`test`.`t2`.`col_int_nokey` = `test`.`alias1`.`col_int_nokey`)) +SELECT alias1.col_varchar_nokey +FROM t1 AS alias1 +INNER JOIN v_t2 AS alias2 +ON alias2.col_int_nokey = alias1.col_int_nokey AND +'o' IN (SELECT col_varchar_nokey +FROM t3); +col_varchar_nokey +o +PREPARE stmt FROM "SELECT alias1.col_varchar_nokey +FROM t1 AS alias1 +INNER JOIN v_t2 AS alias2 +ON alias2.col_int_nokey = alias1.col_int_nokey AND +'o' IN (SELECT col_varchar_nokey +FROM t3)"; +EXECUTE stmt; +col_varchar_nokey +o +DROP VIEW v_t2; +DROP TABLE t1, t2, t3; +# End of test for bug#13339643. +# +# Bug#13424134: Wrong result on JOIN + nested WHERE ... IN clauses +# +CREATE TABLE t1 ( +pk int NOT NULL, +col_int_nokey int NOT NULL, +col_int_key int NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +) ENGINE=MyIsam; +INSERT INTO t1 VALUES +(10,1,7), (13,7,3), (18,0,1), (23,8,1); +CREATE TABLE t2 ( +pk int NOT NULL, +col_int_key int NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +) ENGINE=MyIsam; +INSERT INTO t2 VALUES (1,7); +EXPLAIN SELECT t1a.* +FROM t1 AS t1a +JOIN t1 AS t1b USING ( col_int_nokey ) +WHERE t1a.col_int_key IN ( +SELECT pk +FROM t2 +WHERE col_int_key IN ( +SELECT col_int_nokey +FROM t1 +) +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL system PRIMARY,col_int_key NULL NULL NULL 1 100.00 NULL +1 SIMPLE t1a NULL ref col_int_key col_int_key 4 const 1 100.00 Start temporary +1 SIMPLE t1b NULL ALL NULL NULL NULL NULL 4 25.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1a`.`pk` AS `pk`,`test`.`t1a`.`col_int_nokey` AS `col_int_nokey`,`test`.`t1a`.`col_int_key` AS `col_int_key` from `test`.`t1` `t1a` join `test`.`t1` `t1b` semi join (`test`.`t1`) where ((`test`.`t1b`.`col_int_nokey` = `test`.`t1a`.`col_int_nokey`) and (`test`.`t1a`.`col_int_key` = '1') and (`test`.`t1`.`col_int_nokey` = '7')) +SELECT t1a.* +FROM t1 AS t1a +JOIN t1 AS t1b USING ( col_int_nokey ) +WHERE t1a.col_int_key IN ( +SELECT pk +FROM t2 +WHERE col_int_key IN ( +SELECT col_int_nokey +FROM t1 +) +); +pk col_int_nokey col_int_key +18 0 1 +23 8 1 +ALTER TABLE t1 ENGINE=Innodb; +ALTER TABLE t2 ENGINE=Innodb; +SELECT t1a.* +FROM t1 AS t1a +JOIN t1 AS t1b USING ( col_int_nokey ) +WHERE t1a.col_int_key IN ( +SELECT pk +FROM t2 +WHERE col_int_key IN ( +SELECT col_int_nokey +FROM t1 +) +); +pk col_int_nokey col_int_key +18 0 1 +23 8 1 +DROP TABLE t1, t2; +# End of test for bug#13424134. +# +# Bug#13414014: Extra rows in result on semijoin query with where ... +# +CREATE TABLE t1 ( +c INT, +d INT, +a VARCHAR(1), +b VARCHAR(1), +KEY a (a) +) charset utf8mb4; +INSERT INTO t1 VALUES +(NULL,8,'x','x'), (7,4,'q','q'), (6,8,'c','c'); +CREATE TABLE t2 ( +a VARCHAR(1), +KEY a (a) +) charset utf8mb4; +INSERT INTO t2 VALUES +('c'), (NULL), ('x'), ('q'); +explain SELECT * +FROM t2 AS ot +WHERE (a, a) IN +(SELECT a, b +FROM t1 AS it +WHERE it.a = 'x' OR it.c > it.d +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE it NULL ALL a NULL NULL NULL 3 40.74 Using where; Start temporary +1 SIMPLE ot NULL ref a a 7 test.it.a 2 100.00 Using index; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`ot`.`a` AS `a` from `test`.`t2` `ot` semi join (`test`.`t1` `it`) where ((`test`.`it`.`b` = `test`.`it`.`a`) and (`test`.`ot`.`a` = `test`.`it`.`a`) and ((`test`.`it`.`a` = 'x') or (`test`.`it`.`c` > `test`.`it`.`d`))) +SELECT * +FROM t2 AS ot +WHERE (a, a) IN +(SELECT a, b +FROM t1 AS it +WHERE it.a = 'x' OR it.c > it.d +) +; +a +q +x +DROP TABLE t1, t2; +# End of test for bug#13414014. +# +# Bug#13545215: Missing rows on nested in-subquery with materialization +# +CREATE TABLE t1 ( +col_int_key int, +col_varchar_key varchar(1), +col_varchar_nokey varchar(1), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +INSERT INTO t1 VALUES +(8,'x','x'), (0,'p','p'), (8,'c','c'); +CREATE TABLE t2 ( +pk int NOT NULL, +col_varchar_key varchar(1), +col_varchar_nokey varchar(1), +PRIMARY KEY (pk), +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4; +INSERT INTO t2 VALUES +(1,'v','v'), (2,'v','v'), (3,'c','c'), (4,NULL,NULL), +(5,'x','x'), (6,'i','i'), (7,'e','e'), (8,'p','p'); +CREATE TABLE t3 ( +col_int_nokey int +); +INSERT INTO t3 VALUES (7); +explain SELECT grandparent1.col_varchar_nokey +FROM t1 AS grandparent1 JOIN t1 AS grandparent2 USING (col_int_key) +WHERE grandparent1.col_varchar_key IN ( +SELECT col_varchar_nokey +FROM t2 AS parent1 +WHERE col_varchar_key IN ( +SELECT child1.col_varchar_nokey +FROM t2 AS child1 LEFT JOIN t3 AS child2 +ON child1.pk < child2.col_int_nokey +) +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE grandparent1 NULL ALL col_int_key,col_varchar_key NULL NULL NULL 3 100.00 Using where; Start temporary +1 SIMPLE parent1 NULL ALL col_varchar_key NULL NULL NULL 8 12.50 Using where; Using join buffer (hash join) +1 SIMPLE child1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; Using join buffer (hash join) +1 SIMPLE child2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +1 SIMPLE grandparent2 NULL ref col_int_key col_int_key 5 test.grandparent1.col_int_key 2 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`grandparent1`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t1` `grandparent1` join `test`.`t1` `grandparent2` semi join (`test`.`t2` `parent1` join `test`.`t2` `child1` left join `test`.`t3` `child2` on((`test`.`child1`.`pk` < `test`.`child2`.`col_int_nokey`))) where ((`test`.`grandparent2`.`col_int_key` = `test`.`grandparent1`.`col_int_key`) and (`test`.`parent1`.`col_varchar_nokey` = `test`.`grandparent1`.`col_varchar_key`) and (`test`.`child1`.`col_varchar_nokey` = `test`.`parent1`.`col_varchar_key`)) +SELECT grandparent1.col_varchar_nokey +FROM t1 AS grandparent1 JOIN t1 AS grandparent2 USING (col_int_key) +WHERE grandparent1.col_varchar_key IN ( +SELECT col_varchar_nokey +FROM t2 AS parent1 +WHERE col_varchar_key IN ( +SELECT child1.col_varchar_nokey +FROM t2 AS child1 LEFT JOIN t3 AS child2 +ON child1.pk < child2.col_int_nokey +) +); +col_varchar_nokey +c +c +p +x +x +DROP TABLE t1, t2, t3; +# End of test for bug#13545215. +# +# BUG#13553211 - MISSING ROWS ON SELECT WITH IN-SUBQUERY AND +# MATERIALIZATION + SEMIJOIN ON +# +CREATE TABLE t1 ( +col_int_key int(11) DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (4,'v','v'); +INSERT INTO t1 VALUES (62,'v','v'); +INSERT INTO t1 VALUES (7,'c','c'); +INSERT INTO t1 VALUES (1,NULL,NULL); +EXPLAIN SELECT +alias1.col_varchar_nokey AS a1_nokey, +alias1.col_varchar_key AS a1_key, +alias2.col_varchar_nokey AS a2_nokey +FROM +t1 AS alias1, t1 AS alias2 +WHERE +(alias1.col_varchar_nokey,alias2.col_varchar_nokey) +IN +( +SELECT +sq2_alias2.col_varchar_nokey, sq2_alias1.col_varchar_key +FROM +t1 AS sq2_alias1, t1 AS sq2_alias2 +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE alias1 NULL ALL NULL NULL NULL NULL 4 100.00 Start temporary +1 SIMPLE sq2_alias2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; Using join buffer (hash join) +1 SIMPLE alias2 NULL ALL NULL NULL NULL NULL 4 100.00 Using join buffer (hash join) +1 SIMPLE sq2_alias1 NULL index col_varchar_key col_varchar_key 12 NULL 4 25.00 Using where; Using index; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`alias1`.`col_varchar_nokey` AS `a1_nokey`,`test`.`alias1`.`col_varchar_key` AS `a1_key`,`test`.`alias2`.`col_varchar_nokey` AS `a2_nokey` from `test`.`t1` `alias1` join `test`.`t1` `alias2` semi join (`test`.`t1` `sq2_alias1` join `test`.`t1` `sq2_alias2`) where ((`test`.`sq2_alias1`.`col_varchar_key` = `test`.`alias2`.`col_varchar_nokey`) and (`test`.`sq2_alias2`.`col_varchar_nokey` = `test`.`alias1`.`col_varchar_nokey`)) +SELECT +alias1.col_varchar_nokey AS a1_nokey, +alias1.col_varchar_key AS a1_key, +alias2.col_varchar_nokey AS a2_nokey +FROM +t1 AS alias1, t1 AS alias2 +WHERE +(alias1.col_varchar_nokey,alias2.col_varchar_nokey) +IN +( +SELECT +sq2_alias2.col_varchar_nokey, sq2_alias1.col_varchar_key +FROM +t1 AS sq2_alias1, t1 AS sq2_alias2 +) +; +a1_nokey a1_key a2_nokey +c c c +c c v +c c v +v v c +v v c +v v v +v v v +v v v +v v v +DROP TABLE t1; +# +# Bug#13541406: Wrong result with loosescan on select .. where .. in +# +CREATE TABLE t1 ( +col_int_key INT NOT NULL, +col_varchar_nokey VARCHAR(1) NOT NULL, +KEY col_int_key (col_int_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t1 VALUES +(7,'v'), (0,'s'), (9,'l'), (3,'y'), (4,'c'), (2,'i'), (5,'h'), (3,'q'), +(1,'a'), (3,'v'), (6,'u'), (7,'s'), (5,'y'), (1,'z'), (204,'h'), (224,'p'), +(9,'e'), (5,'i'), (0,'y'), (3,'w'); +CREATE TABLE t2 ( +pk INT NOT NULL, +col_int_key INT NOT NULL, +col_varchar_key VARCHAR(1) NOT NULL, +col_varchar_nokey VARCHAR(1) NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t2 VALUES +(1,0,'j','j'), (2,8,'v','v'), (3,1,'c','c'), (4,8,'m','m'), +(5,9,'d','d'), (6,24,'d','d'), (7,6,'y','y'), (8,1,'t','t'), +(9,6,'d','d'), (10,2,'s','s'), (11,4,'r','r'), (12,8,'m','m'), +(13,4,'b','b'), (14,4,'x','x'), (15,7,'g','g'), (16,4,'p','p'), +(17,1,'q','q'), (18,9,'w','w'), (19,4,'d','d'), (20,8,'e','e'); +# This query should never use a LooseScan strategy +explain SELECT ot1.col_int_key AS field1 +FROM t2 AS ot1, t2 AS ot2 +WHERE (ot1.col_varchar_key, ot2.col_varchar_nokey) IN ( +SELECT it2.col_varchar_nokey, it1.col_varchar_key +FROM t2 AS it1 JOIN t1 AS it2 ON it2.col_int_key = it1.pk); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 20 100.00 Parallel execute (1 workers) +2 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 20 100.00 NULL +2 SIMPLE it1 NULL ref PRIMARY,col_varchar_key col_varchar_key 6 test.ot2.col_varchar_nokey 1 100.00 Using index; Start temporary +2 SIMPLE it2 NULL ref col_int_key col_int_key 4 test.it1.pk 1 100.00 NULL +2 SIMPLE ot1 NULL ref col_varchar_key col_varchar_key 6 test.it2.col_varchar_nokey 1 100.00 Using index; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`col_int_key` AS `field1` from `test`.`t2` `ot1` join `test`.`t2` `ot2` semi join (`test`.`t2` `it1` join `test`.`t1` `it2`) where ((`test`.`it2`.`col_int_key` = `test`.`it1`.`pk`) and (`test`.`it1`.`col_varchar_key` = `test`.`ot2`.`col_varchar_nokey`) and (`test`.`ot1`.`col_varchar_key` = `test`.`it2`.`col_varchar_nokey`)) +SELECT ot1.col_int_key AS field1 +FROM t2 AS ot1, t2 AS ot2 +WHERE (ot1.col_varchar_key, ot2.col_varchar_nokey) IN ( +SELECT it2.col_varchar_nokey, it1.col_varchar_key +FROM t2 AS it1 JOIN t1 AS it2 ON it2.col_int_key = it1.pk); +field1 +1 +1 +1 +2 +6 +6 +6 +6 +6 +8 +8 +8 +8 +8 +8 +9 +DROP TABLE t1, t2; +# End of test for bug#13541406. +# +# Bug#13576391: Missing rows on select with in-subquery and +# batched-key-access=on and semijoin +# +CREATE TABLE t1 ( +col_int_nokey int NOT NULL, +col_varchar_key varchar(1) NOT NULL, +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4 engine=InnoDB; +INSERT INTO t1 VALUES +(1,'v'), (7,'s'), (4,'l'), (7,'y'), (0,'c'), (2,'i'), (9,'h'), (4,'q'), +(0,'a'), (9,'v'), (1,'u'), (3,'s'), (8,'y'), (8,'z'), (18,'h'), (84,'p'), +(6,'e'), (3,'i'), (6,'y'), (6,'w'); +CREATE TABLE t2 ( +col_int_nokey int NOT NULL, +col_varchar_nokey varchar(1) NOT NULL +) charset utf8mb4 engine=InnoDB; +INSERT INTO t2 VALUES +(4,'j'), (6,'v'), (3,'c'), (5,'m'), (3,'d'), (246,'d'), (2,'y'), (9,'t'), +(3,'d'), (8,'s'), (1,'r'), (8,'m'), (8,'b'), (5,'x'), (7,'g'), (5,'p'), +(1,'q'), (6,'w'), (2,'d'), (9,'e'); +explain SELECT col_varchar_nokey +FROM t2 AS ot +WHERE col_varchar_nokey IN ( +SELECT col_varchar_key +FROM t1 AS it +WHERE it.col_int_nokey <= it.col_int_nokey +AND NOT ot.col_int_nokey < 2 +) +ORDER BY col_varchar_nokey; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 20 33.33 Parallel execute (1 workers) +2 SIMPLE ot NULL ALL NULL NULL NULL NULL 20 33.33 Using where; Using filesort +2 SIMPLE it NULL ref col_varchar_key col_varchar_key 6 test.ot.col_varchar_nokey 1 100.00 Start temporary; End temporary +Warnings: +Note 1276 Field or reference 'test.ot.col_int_nokey' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`ot`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t2` `ot` semi join (`test`.`t1` `it`) where ((`test`.`it`.`col_varchar_key` = `test`.`ot`.`col_varchar_nokey`) and (`test`.`ot`.`col_int_nokey` >= 2)) order by `test`.`ot`.`col_varchar_nokey` +SELECT col_varchar_nokey +FROM t2 AS ot +WHERE col_varchar_nokey IN ( +SELECT col_varchar_key +FROM t1 AS it +WHERE it.col_int_nokey <= it.col_int_nokey +AND NOT ot.col_int_nokey < 2 +) +ORDER BY col_varchar_nokey; +col_varchar_nokey +c +e +p +s +v +w +y +ALTER TABLE t1 ENGINE=MyISAM; +ALTER TABLE t2 ENGINE=MyISAM; +explain SELECT col_varchar_nokey +FROM t2 AS ot +WHERE col_varchar_nokey IN ( +SELECT col_varchar_key +FROM t1 AS it +WHERE it.col_int_nokey <= it.col_int_nokey +AND NOT ot.col_int_nokey < 2 +) +ORDER BY col_varchar_nokey; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 20 33.33 Using where; Using filesort +1 SIMPLE it NULL ref col_varchar_key col_varchar_key 6 test.ot.col_varchar_nokey 2 100.00 Start temporary; End temporary +Warnings: +Note 1276 Field or reference 'test.ot.col_int_nokey' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`ot`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t2` `ot` semi join (`test`.`t1` `it`) where ((`test`.`it`.`col_varchar_key` = `test`.`ot`.`col_varchar_nokey`) and (`test`.`ot`.`col_int_nokey` >= 2)) order by `test`.`ot`.`col_varchar_nokey` +SELECT col_varchar_nokey +FROM t2 AS ot +WHERE col_varchar_nokey IN ( +SELECT col_varchar_key +FROM t1 AS it +WHERE it.col_int_nokey <= it.col_int_nokey +AND NOT ot.col_int_nokey < 2 +) +ORDER BY col_varchar_nokey; +col_varchar_nokey +c +e +p +s +v +w +y +ALTER TABLE t1 ENGINE=Memory; +ALTER TABLE t2 ENGINE=Memory; +explain SELECT col_varchar_nokey +FROM t2 AS ot +WHERE col_varchar_nokey IN ( +SELECT col_varchar_key +FROM t1 AS it +WHERE it.col_int_nokey <= it.col_int_nokey +AND NOT ot.col_int_nokey < 2 +) +ORDER BY col_varchar_nokey; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 20 33.33 Using where; Using filesort +1 SIMPLE it NULL ref col_varchar_key col_varchar_key 6 test.ot.col_varchar_nokey 2 100.00 Start temporary; End temporary +Warnings: +Note 1276 Field or reference 'test.ot.col_int_nokey' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`ot`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t2` `ot` semi join (`test`.`t1` `it`) where ((`test`.`it`.`col_varchar_key` = `test`.`ot`.`col_varchar_nokey`) and (`test`.`ot`.`col_int_nokey` >= 2)) order by `test`.`ot`.`col_varchar_nokey` +SELECT col_varchar_nokey +FROM t2 AS ot +WHERE col_varchar_nokey IN ( +SELECT col_varchar_key +FROM t1 AS it +WHERE it.col_int_nokey <= it.col_int_nokey +AND NOT ot.col_int_nokey < 2 +) +ORDER BY col_varchar_nokey; +col_varchar_nokey +c +e +p +s +v +w +y +DROP TABLE t1, t2; +# End of test for bug#13576391. +# +# Bug #13589848 "MISSING ROW ON SELECT WITH NESTED IN CLAUSES WHEN LOOSESCAN=ON" +# +CREATE TABLE t1 ( +id INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +KEY (col_varchar_key) +) charset utf8mb4; +INSERT INTO t1 VALUES (100,'m','m'), +(200,'b','b'), (300,'x','x'); +CREATE TABLE t2 ( +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +KEY (col_varchar_key) +) charset utf8mb4; +INSERT INTO t2 VALUES ('b','b'); +CREATE TABLE t3 ( +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +KEY (col_varchar_key) +) charset utf8mb4; +INSERT INTO t3 VALUES ('k','k'); +EXPLAIN SELECT gp1.id +FROM t1 AS gp1 JOIN t3 AS gp2 +ON gp2.col_varchar_key <> gp1.col_varchar_nokey +WHERE (gp1.col_varchar_nokey, gp1.col_varchar_nokey) +IN ( +SELECT col_varchar_nokey, col_varchar_nokey +FROM t1 +WHERE col_varchar_nokey +IN ( SELECT col_varchar_key +FROM t2 LEFT JOIN t3 USING (col_varchar_key) ) +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE gp2 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL index col_varchar_key col_varchar_key 7 NULL 1 100.00 Using where; Using index; Start temporary +1 SIMPLE gp1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ref col_varchar_key col_varchar_key 7 test.t2.col_varchar_key 2 100.00 Using index; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`gp1`.`id` AS `id` from `test`.`t1` `gp1` semi join (`test`.`t1` join `test`.`t2` left join `test`.`t3` on((`test`.`t2`.`col_varchar_key` = `test`.`t3`.`col_varchar_key`))) where ((`test`.`gp1`.`col_varchar_nokey` = `test`.`t2`.`col_varchar_key`) and (`test`.`t1`.`col_varchar_nokey` = `test`.`t2`.`col_varchar_key`) and ('k' <> `test`.`t2`.`col_varchar_key`)) +SELECT gp1.id +FROM t1 AS gp1 JOIN t3 AS gp2 +ON gp2.col_varchar_key <> gp1.col_varchar_nokey +WHERE (gp1.col_varchar_nokey, gp1.col_varchar_nokey) +IN ( +SELECT col_varchar_nokey, col_varchar_nokey +FROM t1 +WHERE col_varchar_nokey +IN ( SELECT col_varchar_key +FROM t2 LEFT JOIN t3 USING (col_varchar_key) ) +) +; +id +200 +DROP TABLE t1,t2,t3; +# +# Bug #13596176: Missing row on select with nested in clause when +# matr=on and bnl=off + MyISAM +# +CREATE TABLE t1 ( +int_key int DEFAULT NULL, +vc_key varchar(1) DEFAULT NULL, +vc_nokey varchar(1) DEFAULT NULL, +KEY int_key (int_key), +KEY vc_key (vc_key, int_key) +) charset utf8mb4 ENGINE=MyISAM; +INSERT INTO t1 VALUES +(8,'x','x'), (7,'d','d'), (1,'r','r'), (7,'f','f'), +(9,'y','y'), (NULL,'u','u'), (1,'m','m'), (9,NULL,NULL), +(2,'o','o'), (9,'w','w'), (2,'m','m'), (4,'q','q'), +(0,NULL,NULL), (4,'d','d'), (8,'g','g'), (NULL,'x','x'), +(NULL,'f','f'), (0,'p','p'), (NULL,'j','j'), (8,'c','c'); +CREATE TABLE t2 ( +int_key int DEFAULT NULL, +vc_key varchar(1) DEFAULT NULL, +KEY int_key (int_key), +KEY vc_key (vc_key, int_key) +) charset utf8mb4 ENGINE=MyISAM; +INSERT INTO t2 VALUES (8,'g'); +explain SELECT vc_key +FROM t1 as outr +WHERE (vc_nokey, vc_key ) IN +(SELECT vc_nokey, vc_nokey +FROM t1 middle +WHERE vc_nokey IN +(SELECT child1.vc_key +FROM t2 AS child1 JOIN t1 AS child2 USING (int_key) +) +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE child1 NULL index int_key,vc_key vc_key 12 NULL 1 100.00 Using where; Using index; Start temporary +1 SIMPLE outr NULL ref vc_key vc_key 7 test.child1.vc_key 3 10.00 Using where +1 SIMPLE middle NULL ALL NULL NULL NULL NULL 20 10.00 Using where; Using join buffer (hash join) +1 SIMPLE child2 NULL ref int_key int_key 5 test.child1.int_key 3 100.00 Using index; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`outr`.`vc_key` AS `vc_key` from `test`.`t1` `outr` semi join (`test`.`t1` `middle` join `test`.`t2` `child1` join `test`.`t1` `child2`) where ((`test`.`child2`.`int_key` = `test`.`child1`.`int_key`) and (`test`.`outr`.`vc_nokey` = `test`.`child1`.`vc_key`) and (`test`.`outr`.`vc_key` = `test`.`child1`.`vc_key`) and (`test`.`middle`.`vc_nokey` = `test`.`child1`.`vc_key`)) +SELECT vc_key +FROM t1 as outr +WHERE (vc_nokey, vc_key ) IN +(SELECT vc_nokey, vc_nokey +FROM t1 middle +WHERE vc_nokey IN +(SELECT child1.vc_key +FROM t2 AS child1 JOIN t1 AS child2 USING (int_key) +) +); +vc_key +g +DROP TABLE t1, t2; +# End of test for bug#13596176. +# +# BUG#11754478: MAX/MIN + SUBQUERY + AND FAILS TO RETURN ANY ROWS +# BUG#13599013: MAX/MIN + SUBQUERY IN WHERE CLAUSE MATCHING NO +# ROWS + INDEX DOES NOT RETURN NULL +# +CREATE TABLE t1 ( +pk int(11) PRIMARY KEY, +int_key int(11), +KEY int_key (int_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (1,0),(2,0),(3,2),(4,0),(5,3),(6,0); +SELECT MIN(int_key) FROM t1 WHERE (4, 4) IN (SELECT 1, 2); +MIN(int_key) +NULL +SELECT MIN(int_key) FROM t1 WHERE (4, 4) IN (SELECT 4, 4); +MIN(int_key) +0 +SELECT MIN(pk) FROM t1 WHERE pk IN (SELECT int_key FROM t1) AND pk = 6; +MIN(pk) +NULL +DROP TABLE t1; +# BUG#13726217: Crash in Item_ident::fix_after_pullout() +CREATE TABLE t1(a INTEGER) engine=innodb; +INSERT INTO t1 VALUES (0); +SELECT 0 +FROM t1 +WHERE 0 IN +(SELECT 0 +FROM t1 +WHERE 0 LIKE +(SELECT elt(a, 0) AS b +FROM t1 +GROUP BY a +HAVING b +) +); +0 +DROP TABLE t1; +# End of test for bug#13726217. +# BUG#13773979: Missing rows on second execution of prepared statement +CREATE TABLE t1 ( +col_int_nokey INT, +col_int_key INT, +col_varchar_key VARCHAR(1) +); +INSERT INTO t1 VALUES +(1,7,'v'), (7,0,'s'), (4,9,'l'), (7,3,'y'), +(2,2,'i'), (9,5,'h'), (0,1,'a'), (9,3,'v'); +CREATE VIEW v1 AS SELECT * FROM t1; +SELECT * +FROM t1 +WHERE col_int_key IN ( +SELECT alias1.col_int_nokey AS field1 +FROM v1 AS alias1 +WHERE alias1.col_varchar_key < 'v' +); +col_int_nokey col_int_key col_varchar_key +1 7 v +2 2 i +4 9 l +7 0 s +prepare stmt FROM "SELECT * +FROM t1 +WHERE col_int_key IN ( +SELECT alias1.col_int_nokey AS field1 +FROM v1 AS alias1 +WHERE alias1.col_varchar_key < 'v' +)"; +execute stmt; +col_int_nokey col_int_key col_varchar_key +1 7 v +2 2 i +4 9 l +7 0 s +execute stmt; +col_int_nokey col_int_key col_varchar_key +1 7 v +2 2 i +4 9 l +7 0 s +DEALLOCATE PREPARE stmt; +DROP VIEW v1; +DROP TABLE t1; +# End of test for bug#13773979. +# +# BUG#13685026 ASSERTION CUR_SJ_INNER_TABLES == 0 IN +# --OPTIMIZE_TABLE_ORDER::CHOOSE_TABLE_ORDER +# +CREATE TABLE t1 ( +col_int_key INT(11) NOT NULL, +col_datetime_key DATETIME NOT NULL, +col_varchar_key VARCHAR(1) NOT NULL, +col_varchar_nokey VARCHAR(1) NOT NULL, +KEY col_int_key (col_int_key), +KEY col_datetime_key (col_datetime_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (0,'2002-02-13 17:30:06','j','j'); +INSERT INTO t1 VALUES (8,'2008-09-27 00:34:58','v','v'); +CREATE TABLE t2 ( +col_int_key INT(11) NOT NULL, +col_datetime_key DATETIME NOT NULL, +col_varchar_key VARCHAR(1) NOT NULL, +col_varchar_nokey VARCHAR(1) NOT NULL, +KEY col_int_key (col_int_key), +KEY col_datetime_key (col_datetime_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (7,'2003-08-21 00:00:00','b','b'); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +SET @old_depth=@@optimizer_search_depth; +SET optimizer_search_depth=4; +EXPLAIN SELECT col_datetime_key +FROM t1 as outr +WHERE col_datetime_key IN ( +SELECT alias1.col_datetime_key +FROM t1 AS alias1 +LEFT JOIN t1 as alias3 +STRAIGHT_JOIN ( t2 AS alias4 +JOIN t1 AS alias5 +ON alias5.col_varchar_key <= alias4.col_varchar_nokey ) +ON alias5.col_int_key < alias4.col_int_key +ON alias5.col_varchar_key = alias4.col_varchar_key +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE outr NULL index col_datetime_key col_datetime_key 5 NULL 2 100.00 Using index +1 SIMPLE alias1 NULL ref col_datetime_key col_datetime_key 5 test.outr.col_datetime_key 1 100.00 Using index; Start temporary +1 SIMPLE alias4 NULL ALL col_int_key,col_varchar_key NULL NULL NULL 1 100.00 NULL +1 SIMPLE alias5 NULL ref col_int_key,col_varchar_key col_varchar_key 6 test.alias4.col_varchar_key 1 100.00 Using where; Using index +1 SIMPLE alias3 NULL index NULL col_int_key 4 NULL 2 100.00 Using index; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`outr`.`col_datetime_key` AS `col_datetime_key` from `test`.`t1` `outr` semi join (`test`.`t1` `alias1` left join (`test`.`t1` `alias3` join `test`.`t2` `alias4` join `test`.`t1` `alias5`) on(((`test`.`alias5`.`col_varchar_key` = `test`.`alias4`.`col_varchar_key`) and (`test`.`alias5`.`col_int_key` < `test`.`alias4`.`col_int_key`) and (`test`.`alias5`.`col_varchar_key` <= `test`.`alias4`.`col_varchar_nokey`)))) where (`test`.`alias1`.`col_datetime_key` = `test`.`outr`.`col_datetime_key`) +SELECT col_datetime_key +FROM t1 as outr +WHERE col_datetime_key IN ( +SELECT alias1.col_datetime_key +FROM t1 AS alias1 +LEFT JOIN t1 as alias3 +STRAIGHT_JOIN ( t2 AS alias4 +JOIN t1 AS alias5 +ON alias5.col_varchar_key <= alias4.col_varchar_nokey ) +ON alias5.col_int_key < alias4.col_int_key +ON alias5.col_varchar_key = alias4.col_varchar_key +); +col_datetime_key +2002-02-13 17:30:06 +2008-09-27 00:34:58 +DROP TABLE t1,t2; +SET @@optimizer_search_depth=@old_depth; +# +# BUG#13848789: SEGFAULT IN JOIN_READ_NEXT_SAME AT +# SQL/SQL_EXECUTOR.CC ON HAVING...IN...JOIN +# +CREATE TABLE t1 ( +col_int_key INT, +col_varchar_key VARCHAR(1), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4; +INSERT INTO t1 VALUES (8,'x'); +CREATE TABLE t2 ( +col_varchar_key VARCHAR(1), +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4; +INSERT INTO t2 VALUES ('x'), ('y'); +explain SELECT MIN(col_int_key) +FROM t1 as t1_outer +HAVING (1, 2) IN ( +SELECT t1_inner.col_int_key, MAX(t1_inner.col_int_key) +FROM t1 as t1_inner JOIN t2 +ON t2.col_varchar_key = t1_inner.col_varchar_key +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible HAVING +2 SUBQUERY t1_inner NULL system col_varchar_key NULL NULL NULL 1 100.00 NULL +2 SUBQUERY t2 NULL ref col_varchar_key col_varchar_key 7 const 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select min(`test`.`t1_outer`.`col_int_key`) AS `MIN(col_int_key)` from `test`.`t1` `t1_outer` having false +SELECT MIN(col_int_key) +FROM t1 as t1_outer +HAVING (1, 2) IN ( +SELECT t1_inner.col_int_key, MAX(t1_inner.col_int_key) +FROM t1 as t1_inner JOIN t2 +ON t2.col_varchar_key = t1_inner.col_varchar_key +); +MIN(col_int_key) +DROP TABLE t1,t2; +# Bug#13838810: Segfault in evaluate_null_complemented_join_record +CREATE TABLE t1 ( +pk int NOT NULL, +col_int_nokey int DEFAULT NULL, +col_int_key int DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t1 VALUES (10,NULL,8,'x'); +CREATE TABLE t2 ( +pk int NOT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +PRIMARY KEY (pk) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t2 VALUES (1,'x'); +CREATE TABLE t3 ( +pk int NOT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +PRIMARY KEY (pk), +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t3 VALUES +(1,'v','v'), (2,'v','v'), (3,'c','c'), (4,NULL,NULL); +EXPLAIN SELECT table1.pk,table2.pk, table3.pk +FROM t2 AS table1 +LEFT JOIN t1 AS table2 +LEFT JOIN t1 AS table3 +ON table3.col_int_key = table2.col_int_key +ON table3.pk = table2.col_int_nokey AND +table1.col_varchar_nokey IN ( +SELECT subquery3_t1.col_varchar_nokey +FROM t3 AS subquery3_t1 +LEFT JOIN t1 AS subquery3_t2 +ON subquery3_t2.col_varchar_key = subquery3_t1.col_varchar_key +WHERE subquery3_t2.col_int_nokey <> 9 +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE table1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE table2 NULL ALL col_int_key NULL NULL NULL 1 100.00 NULL +2 SIMPLE table3 NULL eq_ref PRIMARY,col_int_key PRIMARY 4 test.table2.col_int_nokey 1 100.00 Using where +2 SIMPLE subquery3_t2 NULL ALL col_varchar_key NULL NULL NULL 1 100.00 Using where; Start temporary +2 SIMPLE subquery3_t1 NULL ref col_varchar_key col_varchar_key 7 test.subquery3_t2.col_varchar_key 1 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`table1`.`pk` AS `pk`,`test`.`table2`.`pk` AS `pk`,`test`.`table3`.`pk` AS `pk` from `test`.`t2` `table1` left join (`test`.`t1` `table2` join `test`.`t1` `table3` semi join (`test`.`t3` `subquery3_t1` join `test`.`t1` `subquery3_t2`)) on(((`test`.`table3`.`col_int_key` = `test`.`table2`.`col_int_key`) and (`test`.`subquery3_t1`.`col_varchar_key` = `test`.`subquery3_t2`.`col_varchar_key`) and (`test`.`subquery3_t1`.`col_varchar_nokey` = `test`.`table1`.`col_varchar_nokey`) and (`test`.`table3`.`pk` = `test`.`table2`.`col_int_nokey`) and (`test`.`subquery3_t2`.`col_int_nokey` <> 9))) where true +SELECT table1.pk,table2.pk, table3.pk +FROM t2 AS table1 +LEFT JOIN t1 AS table2 +LEFT JOIN t1 AS table3 +ON table3.col_int_key = table2.col_int_key +ON table3.pk = table2.col_int_nokey AND +table1.col_varchar_nokey IN ( +SELECT subquery3_t1.col_varchar_nokey +FROM t3 AS subquery3_t1 +LEFT JOIN t1 AS subquery3_t2 +ON subquery3_t2.col_varchar_key = subquery3_t1.col_varchar_key +WHERE subquery3_t2.col_int_nokey <> 9 +) +; +pk pk pk +1 NULL NULL +DROP TABLE t1, t2, t3; +Extra test case for specific code coverage +CREATE TABLE t1(pk INTEGER); +INSERT INTO t1 VALUES(1), (2); +explain SELECT * +FROM t1 AS ot1 LEFT JOIN t1 AS ot2 +ON ot1.pk=ot2.pk AND +ot2.pk IN +(SELECT it1.pk +FROM t1 AS it1 LEFT JOIN t1 AS it2 ON it1.pk=it2.pk); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +1 SIMPLE it1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +1 SIMPLE it2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`pk` AS `pk`,`test`.`ot2`.`pk` AS `pk` from `test`.`t1` `ot1` left join (`test`.`t1` `ot2` semi join (`test`.`t1` `it1` left join `test`.`t1` `it2` on((`test`.`it1`.`pk` = `test`.`it2`.`pk`)))) on(((`test`.`ot2`.`pk` = `test`.`ot1`.`pk`) and (`test`.`it1`.`pk` = `test`.`ot1`.`pk`))) where true +SELECT * +FROM t1 AS ot1 LEFT JOIN t1 AS ot2 +ON ot1.pk=ot2.pk AND +ot2.pk IN +(SELECT it1.pk +FROM t1 AS it1 LEFT JOIN t1 AS it2 ON it1.pk=it2.pk); +pk pk +1 1 +2 2 +DROP TABLE t1; +# End of test for bug#13838810. +# +# Bug#13845930: Segfault in st_join_table::and_with_condition +# +CREATE TABLE t1 ( +col_int INTEGER +); +CREATE TABLE t2 ( +col_varchar_1 VARCHAR(1), +col_varchar_2 VARCHAR(1) +); +INSERT INTO t2 VALUES ('x','x'), ('c','c'); +PREPARE stmt FROM ' +SELECT alias2.col_varchar_2 AS field1 +FROM t2 AS alias1 + JOIN + (t2 AS alias2 + LEFT JOIN t2 AS alias3 + ON (8, 92) IN + (SELECT sq1_alias1.col_int, + sq1_alias2.col_int + FROM t1 AS sq1_alias1 JOIN t1 AS sq1_alias2 + ) + ) + ON alias3.col_varchar_1 = alias2.col_varchar_2 +'; +EXECUTE stmt; +field1 + +EXECUTE stmt; +field1 +DEALLOCATE prepare stmt; +DROP TABLE t1, t2; +# End of test for bug#13845930. +# +# Bug#13855925: Assert 'prebuilt->search_tuple->n_fields > 0' +# in ha_innobase::index_read +# +CREATE TABLE t1 ( +pk INTEGER AUTO_INCREMENT, +col_int_nokey INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk), +KEY (col_varchar_key) +) charset utf8mb4 ENGINE=INNODB; +INSERT INTO t1 ( +col_int_key, col_int_nokey, +col_varchar_key, col_varchar_nokey +) VALUES +(4, 2, 'v','v'), (62, 150, 'v','v'), (7, NULL, 'c','c'), (1, 2, NULL, NULL), +(0, 5, 'x','x'), (7, 3, 'i','i'), (7, 1, 'e','e'), (1, 4, 'p','p'), +(7, NULL, 's','s'), (1, 2, 'j','j'), (5, 6, 'z','z'), (2, 6, 'c','c'), +(0, 8, 'a','a'), (1, 2, 'q','q'), (8, 6, 'y','y'), (1, 8, NULL, NULL), +(1, 3, 'r','r'), (9, 3, 'v','v'), (1, 9, NULL, NULL), (5, 6, 'r','r'); +CREATE TABLE t2 ( +pk INT AUTO_INCREMENT, +col_int_nokey INT, +col_int_key INT, +PRIMARY KEY (pk), +KEY (col_int_key) +) charset utf8mb4 AUTO_INCREMENT=10 ENGINE=INNODB; +INSERT INTO t2 (col_int_key, col_int_nokey) VALUES +(8, NULL), (7, 8), (1, 1), (7, 9), (9, 4), (NULL, 3), (1, 2), (9, NULL), +(2, 2), (9, NULL), (2, 6), (4, 7), (0, 2), (4, 5), (8, 7), (NULL, 6), +(NULL, 6), (0, 2), (NULL, 9), (8, 6); +CREATE TABLE t3 ( +pk INT AUTO_INCREMENT, +col_varchar_key VARCHAR(1), +PRIMARY KEY (pk), +KEY (col_varchar_key) +) charset utf8mb4 ENGINE=INNODB; +INSERT INTO t3 (col_varchar_key) VALUES +('c'), ('c'), ('q'), ('g'), ('e'), ('l'), (NULL), ('c'), ('h'), ('d'), +('c'), ('i'), ('t'), ('g'), ('q'), ('l'), ('n'), ('z'), ('n'), ('r'), ('p'); +CREATE VIEW v1 AS +SELECT table2.col_varchar_nokey AS field1 +FROM t2 AS table1 +INNER JOIN (t1 AS table2 +STRAIGHT_JOIN t2 AS table3 +ON table3.col_int_key = table2.pk AND +table3.col_int_nokey = ANY +(SELECT subquery1_t2.col_int_nokey AS subquery1_field1 +FROM t2 AS subquery1_t1 +RIGHT OUTER JOIN t1 AS subquery1_t2 +INNER JOIN t1 AS subquery1_t3 +ON subquery1_t3.col_int_key = subquery1_t2.pk +ON subquery1_t3.col_varchar_key=subquery1_t2.col_varchar_nokey +WHERE subquery1_t1.pk > 1 +) +) +ON table3.col_int_key IN +(SELECT subquery2_t1.col_int_key AS subquery2_field1 +FROM t2 AS subquery2_t1 +RIGHT OUTER JOIN t3 AS subquery2_t2 +LEFT OUTER JOIN t1 AS subquery2_t3 +ON subquery2_t3.col_varchar_key = subquery2_t2.col_varchar_key +ON subquery2_t3.pk = subquery2_t2.pk +) +; +explain SELECT * FROM v1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE table1 NULL index NULL col_int_key 5 NULL 20 100.00 Using index; Start temporary +1 SIMPLE subquery1_t3 NULL ALL col_varchar_key NULL NULL NULL 20 100.00 Using where; Using join buffer (hash join) +1 SIMPLE subquery1_t2 NULL eq_ref PRIMARY PRIMARY 4 test.subquery1_t3.col_int_key 1 10.00 Using where +1 SIMPLE table2 NULL ALL PRIMARY NULL NULL NULL 20 100.00 Using join buffer (hash join) +1 SIMPLE table3 NULL ref col_int_key col_int_key 5 test.table2.pk 2 10.00 Using where +1 SIMPLE subquery2_t3 NULL index PRIMARY,col_varchar_key col_varchar_key 7 NULL 20 100.00 Using where; Using index; Using join buffer (hash join) +1 SIMPLE subquery2_t2 NULL eq_ref PRIMARY,col_varchar_key PRIMARY 4 test.subquery2_t3.pk 1 7.14 Using where +1 SIMPLE subquery2_t1 NULL ref col_int_key col_int_key 5 test.table2.pk 2 100.00 Using index +1 SIMPLE subquery1_t1 NULL index PRIMARY col_int_key 5 NULL 20 100.00 Using where; Using index; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `table2`.`col_varchar_nokey` AS `field1` from `test`.`t2` `table1` join `test`.`t1` `table2` straight_join `test`.`t2` `table3` semi join (`test`.`t1` `subquery1_t2` join `test`.`t1` `subquery1_t3` join `test`.`t2` `subquery1_t1`) semi join (`test`.`t3` `subquery2_t2` join `test`.`t1` `subquery2_t3` join `test`.`t2` `subquery2_t1`) where ((`subquery1_t2`.`pk` = `subquery1_t3`.`col_int_key`) and (`subquery1_t2`.`col_varchar_nokey` = `subquery1_t3`.`col_varchar_key`) and (`subquery2_t2`.`col_varchar_key` = `subquery2_t3`.`col_varchar_key`) and (`subquery2_t2`.`pk` = `subquery2_t3`.`pk`) and (`table3`.`col_int_key` = `table2`.`pk`) and (`subquery2_t1`.`col_int_key` = `table2`.`pk`) and (`table3`.`col_int_nokey` = `subquery1_t2`.`col_int_nokey`) and (`subquery1_t1`.`pk` > 1)) +SELECT * FROM v1; +field1 +v +v +v +v +v +v +v +v +v +v +v +v +v +v +v +v +v +v +v +v +DROP VIEW v1; +DROP TABLE t1,t2,t3; +# End of test for bug#13855925. +# +# Bug#13897959: Segfault in setup_semijoin_dups_elimination() +# +CREATE TABLE t1 ( +col_datetime_key DATETIME DEFAULT NULL, +KEY col_datetime_key (col_datetime_key) +) ENGINE=MyISAM; +INSERT INTO t1 VALUES +('2001-04-18 00:00:00'), ('2008-12-18 19:39:55'), +('2000-08-01 12:19:39'), ('2004-09-25 21:29:06'), +('2009-09-20 09:11:48'), ('2004-03-27 09:32:04'); +CREATE TABLE t2 ( +col_date_nokey date DEFAULT NULL, +col_time_key time DEFAULT NULL, +col_datetime_key datetime DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +KEY col_time_key (col_time_key), +KEY col_datetime_key (col_datetime_key), +KEY col_varchar_key(col_varchar_key) +) ENGINE=MyISAM; +INSERT INTO t2 VALUES ('1900-01-01',NULL,'2001-11-04 19:07:55','x','x'); +SELECT grandparent1.col_varchar_nokey +FROM t2 AS grandparent1 LEFT JOIN t1 USING (col_datetime_key) +WHERE grandparent1.col_varchar_nokey IN ( +SELECT col_varchar_nokey +FROM t2 AS parent1 +WHERE parent1.col_time_key > grandparent1.col_date_nokey +); +col_varchar_nokey +DROP TABLE t1, t2; +# End of test for bug#13897959. +# +# Bug#13898625 ASSERT `(REMAINING_TABLES_AFTER != 0) ...' IN +# BEST_EXTENSION_BY_LIMITED_SEARCH +# +CREATE TABLE t1 ( +pk int(11) NOT NULL, +col_int_nokey INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (26,6,NULL,'f','f'); +INSERT INTO t1 VALUES (29,6,8,'c','c'); +CREATE TABLE t2 ( +pk INT NOT NULL, +col_int_nokey INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +INSERT INTO t2 VALUES (1,2,4,'v','v'); +INSERT INTO t2 VALUES (2,150,62,'v','v'); +INSERT INTO t2 VALUES (5,5,0,'x','x'); +INSERT INTO t2 VALUES (6,3,7,'i','i'); +INSERT INTO t2 VALUES (7,1,7,'e','e'); +CREATE VIEW view_c AS SELECT * FROM t2; +PREPARE prep_stmt_7430 FROM 'SELECT SUM( alias1.col_varchar_key ) AS field1 +FROM t1 AS alias1 +RIGHT JOIN t2 AS alias2 +INNER JOIN t1 AS alias3 +ON (alias3.col_varchar_key = alias2.col_varchar_key ) +ON ( "v" ) IN ( +SELECT sq1_alias1.col_varchar_nokey AS sq1_field1 +FROM t1 AS sq1_alias1 +) +WHERE alias3.pk IN ( +SELECT sq2_alias1.col_int_key AS sq2_field1 +FROM ( view_c AS sq2_alias1, t1 AS sq2_alias2 ) +) +'; +EXECUTE prep_stmt_7430; +field1 +NULL +EXECUTE prep_stmt_7430; +field1 +NULL +EXPLAIN SELECT SUM( alias1.col_varchar_key ) AS field1 +FROM t1 AS alias1 +RIGHT JOIN t2 AS alias2 +INNER JOIN t1 AS alias3 +ON (alias3.col_varchar_key = alias2.col_varchar_key ) +ON ( "v" ) IN ( +SELECT sq1_alias1.col_varchar_nokey AS sq1_field1 +FROM t1 AS sq1_alias1 +) +WHERE alias3.pk IN ( +SELECT sq2_alias1.col_int_key AS sq2_field1 +FROM ( view_c AS sq2_alias1, t1 AS sq2_alias2 ) +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE alias3 NULL ALL PRIMARY,col_varchar_key NULL NULL NULL 2 100.00 Using where; Start temporary +1 SIMPLE sq2_alias2 NULL index NULL PRIMARY 4 NULL 2 100.00 Using index; Using join buffer (hash join) +1 SIMPLE alias2 NULL ref col_varchar_key col_varchar_key 7 test.alias3.col_varchar_key 2 100.00 Using index +1 SIMPLE t2 NULL ref col_int_key col_int_key 5 test.alias3.pk 2 100.00 Using index +1 SIMPLE sq1_alias1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +1 SIMPLE alias1 NULL index NULL col_varchar_key 12 NULL 2 100.00 Using index; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select sum(`test`.`alias1`.`col_varchar_key`) AS `field1` from `test`.`t2` `alias2` join `test`.`t1` `alias3` left join (`test`.`t1` `alias1` semi join (`test`.`t1` `sq1_alias1`)) on(((`test`.`sq1_alias1`.`col_varchar_nokey` = 'v'))) semi join (`test`.`t2` join `test`.`t1` `sq2_alias2`) where ((`test`.`alias2`.`col_varchar_key` = `test`.`alias3`.`col_varchar_key`) and (`test`.`t2`.`col_int_key` = `test`.`alias3`.`pk`)) +PREPARE prep_stmt_7430 FROM 'SELECT SUM( alias1.col_varchar_key ) AS field1 +FROM t1 AS alias1 +RIGHT JOIN t2 AS alias2 +INNER JOIN t1 AS alias3 +ON (alias3.col_varchar_key = alias2.col_varchar_key ) +ON ( "v" ) IN ( +SELECT sq1_alias1.col_varchar_nokey AS sq1_field1 +FROM t1 AS sq1_alias1 +) +WHERE alias3.pk IN ( +SELECT sq2_alias1.col_int_key AS sq2_field1 +FROM ( view_c AS sq2_alias1 , t1 AS sq2_alias2 ) +WHERE sq2_alias1.col_varchar_nokey <> alias2.col_varchar_key +AND sq2_alias1.col_varchar_key < "l" + ) +'; +EXECUTE prep_stmt_7430; +field1 +NULL +EXECUTE prep_stmt_7430; +field1 +NULL +EXPLAIN SELECT SUM( alias1.col_varchar_key ) AS field1 +FROM t1 AS alias1 +RIGHT JOIN t2 AS alias2 +INNER JOIN t1 AS alias3 +ON (alias3.col_varchar_key = alias2.col_varchar_key ) +ON ( "v" ) IN ( +SELECT sq1_alias1.col_varchar_nokey AS sq1_field1 +FROM t1 AS sq1_alias1 +) +WHERE alias3.pk IN ( +SELECT sq2_alias1.col_int_key AS sq2_field1 +FROM ( view_c AS sq2_alias1 , t1 AS sq2_alias2 ) +WHERE sq2_alias1.col_varchar_nokey <> alias2.col_varchar_key +AND sq2_alias1.col_varchar_key < "l" + ) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE alias3 NULL ALL PRIMARY,col_varchar_key NULL NULL NULL 2 100.00 Using where; Start temporary +1 SIMPLE t2 NULL ref col_int_key,col_varchar_key col_int_key 5 test.alias3.pk 2 40.00 Using where +1 SIMPLE alias2 NULL ref col_varchar_key col_varchar_key 7 test.alias3.col_varchar_key 2 100.00 Using index +1 SIMPLE sq2_alias2 NULL index NULL PRIMARY 4 NULL 2 100.00 Using index; Using join buffer (hash join) +1 SIMPLE sq1_alias1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +1 SIMPLE alias1 NULL index NULL col_varchar_key 12 NULL 2 100.00 Using index; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.alias2.col_varchar_key' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select sum(`test`.`alias1`.`col_varchar_key`) AS `field1` from `test`.`t2` `alias2` join `test`.`t1` `alias3` left join (`test`.`t1` `alias1` semi join (`test`.`t1` `sq1_alias1`)) on(((`test`.`sq1_alias1`.`col_varchar_nokey` = 'v'))) semi join (`test`.`t2` join `test`.`t1` `sq2_alias2`) where ((`test`.`alias2`.`col_varchar_key` = `test`.`alias3`.`col_varchar_key`) and (`test`.`t2`.`col_int_key` = `test`.`alias3`.`pk`) and (`test`.`t2`.`col_varchar_nokey` <> `test`.`alias3`.`col_varchar_key`) and (`test`.`t2`.`col_varchar_key` < 'l')) +DROP TABLE t1,t2; +DROP VIEW view_c; +# +# Bug#13902463 SEGFAULT IN BITMAP<64U>::MERGE OR ADD_KEY_FIELD +# ON SECOND EXEC OF PREP STMT +# +CREATE TABLE t1 ( +pk INT, +col_int_nokey INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +KEY col_varchar_key (col_varchar_key) +); +CREATE VIEW view_b AS SELECT * FROM t1; +PREPARE prep_stmt_20421 FROM 'SELECT alias2.col_varchar_nokey AS field1 +FROM t1 AS alias1 +INNER JOIN t1 AS alias2 +ON (alias1.col_varchar_key = alias2.col_varchar_nokey +AND ( alias1.col_int_key ) IN ( +SELECT t1.col_int_nokey +FROM t1 +) +) +WHERE alias1.col_varchar_key IN ( +SELECT sq2_alias2.col_varchar_nokey AS sq2_field1 +FROM view_b AS sq2_alias1 +INNER JOIN t1 AS sq2_alias2 +ON (sq2_alias2.col_varchar_key = sq2_alias1.col_varchar_key ) +WHERE sq2_alias1.pk > alias2.pk +) +'; +EXECUTE prep_stmt_20421; +field1 +EXECUTE prep_stmt_20421; +field1 +EXPLAIN SELECT alias2.col_varchar_nokey AS field1 +FROM t1 AS alias1 +INNER JOIN t1 AS alias2 +ON (alias1.col_varchar_key = alias2.col_varchar_nokey +AND ( alias1.col_int_key ) IN ( +SELECT t1.col_int_nokey +FROM t1 +) +) +WHERE alias1.col_varchar_key IN ( +SELECT sq2_alias2.col_varchar_nokey AS sq2_field1 +FROM view_b AS sq2_alias1 +INNER JOIN t1 AS sq2_alias2 +ON (sq2_alias2.col_varchar_key = sq2_alias1.col_varchar_key ) +WHERE sq2_alias1.pk > alias2.pk +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.alias2.pk' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `field1` from `test`.`t1` `alias1` join `test`.`t1` `alias2` semi join (`test`.`t1`) semi join (`test`.`t1` join `test`.`t1` `sq2_alias2`) where ((`test`.`t1`.`pk` > NULL) and multiple equal(NULL, `test`.`sq2_alias2`.`col_varchar_nokey`, NULL) and multiple equal(`test`.`sq2_alias2`.`col_varchar_key`, `test`.`t1`.`col_varchar_key`) and multiple equal(NULL, `test`.`t1`.`col_int_nokey`)) +ALTER TABLE t1 DROP INDEX col_varchar_key; +PREPARE prep_stmt_20421 FROM 'SELECT alias2.col_varchar_nokey AS field1 +FROM t1 AS alias1 +INNER JOIN t1 AS alias2 +ON (alias1.col_varchar_key = alias2.col_varchar_nokey +AND ( alias1.col_int_key ) IN ( +SELECT t1.col_int_nokey +FROM t1 +) +) +WHERE alias1.col_varchar_key IN ( +SELECT sq2_alias2.col_varchar_nokey AS sq2_field1 +FROM view_b AS sq2_alias1 +INNER JOIN t1 AS sq2_alias2 +ON (sq2_alias2.col_varchar_key = sq2_alias1.col_varchar_key ) +WHERE sq2_alias1.pk > alias2.pk +) +'; +EXECUTE prep_stmt_20421; +field1 +EXECUTE prep_stmt_20421; +field1 +EXPLAIN SELECT alias2.col_varchar_nokey AS field1 +FROM t1 AS alias1 +INNER JOIN t1 AS alias2 +ON (alias1.col_varchar_key = alias2.col_varchar_nokey +AND ( alias1.col_int_key ) IN ( +SELECT t1.col_int_nokey +FROM t1 +) +) +WHERE alias1.col_varchar_key IN ( +SELECT sq2_alias2.col_varchar_nokey AS sq2_field1 +FROM view_b AS sq2_alias1 +INNER JOIN t1 AS sq2_alias2 +ON (sq2_alias2.col_varchar_key = sq2_alias1.col_varchar_key ) +WHERE sq2_alias1.pk > alias2.pk +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.alias2.pk' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `field1` from `test`.`t1` `alias1` join `test`.`t1` `alias2` semi join (`test`.`t1`) semi join (`test`.`t1` join `test`.`t1` `sq2_alias2`) where ((`test`.`t1`.`pk` > NULL) and multiple equal(NULL, `test`.`sq2_alias2`.`col_varchar_nokey`, NULL) and multiple equal(`test`.`sq2_alias2`.`col_varchar_key`, `test`.`t1`.`col_varchar_key`) and multiple equal(NULL, `test`.`t1`.`col_int_nokey`)) +DROP TABLE t1; +DROP VIEW view_b; +# +# Bug#13907277: Segfault in evaluate_null_complemented_join_record +# +CREATE TABLE t1 ( +pk INTEGER, +col_varchar_nokey VARCHAR(1), +col_varchar_key VARCHAR(1), +PRIMARY KEY (pk) +); +INSERT INTO t1 VALUES (1, 'x', 'x'); +CREATE TABLE t2 ( +pk INTEGER, +PRIMARY KEY (pk) +); +INSERT INTO t2 VALUES (1); +CREATE TABLE t3 ( +pk INTEGER, +col_int_nokey INTEGER, +col_int_key INTEGER, +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk) +); +INSERT INTO t3 VALUES (1, 6, 5, 'r'); +explain SELECT outer_t1.pk, outer_t2.pk +FROM t3 AS outer_t1 +RIGHT JOIN t2 AS outer_t2 +ON outer_t1.col_int_nokey IN +(SELECT inner_t1.col_int_nokey +FROM t3 AS inner_t1 +LEFT JOIN t1 AS inner_t2 +INNER JOIN t1 AS inner_t3 +ON inner_t3.pk = inner_t2.pk +ON inner_t3.col_varchar_nokey = inner_t2.col_varchar_key +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE outer_t2 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE outer_t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE inner_t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE inner_t2 NULL ALL PRIMARY NULL NULL NULL 1 100.00 NULL +1 SIMPLE inner_t3 NULL eq_ref PRIMARY PRIMARY 4 test.inner_t2.pk 1 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`outer_t1`.`pk` AS `pk`,'1' AS `pk` from left join (`test`.`t3` `outer_t1` semi join (`test`.`t3` `inner_t1` left join (`test`.`t1` `inner_t2` join `test`.`t1` `inner_t3`) on(((`test`.`inner_t3`.`col_varchar_nokey` = `test`.`inner_t2`.`col_varchar_key`) and (`test`.`inner_t3`.`pk` = `test`.`inner_t2`.`pk`))))) on(((`test`.`inner_t1`.`col_int_nokey` = `test`.`outer_t1`.`col_int_nokey`))) where true +SELECT outer_t1.pk, outer_t2.pk +FROM t3 AS outer_t1 +RIGHT JOIN t2 AS outer_t2 +ON outer_t1.col_int_nokey IN +(SELECT inner_t1.col_int_nokey +FROM t3 AS inner_t1 +LEFT JOIN t1 AS inner_t2 +INNER JOIN t1 AS inner_t3 +ON inner_t3.pk = inner_t2.pk +ON inner_t3.col_varchar_nokey = inner_t2.col_varchar_key +); +pk pk +1 1 +DROP TABLE t1, t2, t3; +# End of test for bug#13907277. +# +# Bug#13955713: Assert 'JOIN->best_read < ...' on second execution +# +CREATE TABLE t1 ( +pk INTEGER, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1) +); +PREPARE stmt FROM " +SELECT MIN(alias2.col_varchar_key) AS field1 +FROM t1 AS alias1 + INNER JOIN (t1 AS alias2 + INNER JOIN t1 AS alias3 + ON 8 IN + (SELECT sq1_alias1.pk AS sq1_field2 + FROM t1 AS sq1_alias1 + WHERE 9 IN + (SELECT SUM(t1_sq1_alias1.pk) AS t1_sq1_field2 + FROM t1 AS t1_sq1_alias1 + ) + ) + ) + ON alias3.col_varchar_nokey = alias2.col_varchar_key +WHERE EXISTS + (SELECT sq2_alias1.pk AS sq2_field1 + FROM t1 AS sq2_alias1 + WHERE sq2_alias1.col_varchar_key < alias1.col_varchar_nokey + ) +"; +EXECUTE stmt; +field1 +NULL + +EXECUTE stmt; +field1 +NULL +DEALLOCATE PREPARE stmt; +DROP TABLE t1; +# End of test for bug#13955713. +# +# Bug#13956813: Segfault in memcpy from Join_cache::write_record_data() +# +CREATE TABLE t1 ( +pk INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1) +) charset latin1; +CREATE TABLE t2 ( +pk INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1) +) charset latin1; +INSERT INTO t2 VALUES +(10,'j','j'), (11,'z','z'), (12,'c','c'), (13,'a','a'), +(14,'q','q'), (15,'y','y'), (16,NULL,NULL), (17,'r','r'), +(18,'v','v'), (19,NULL,NULL), (20,'r','r'); +CREATE TABLE t3 ( +pk INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +KEY col_int_key (col_int_key) +) charset latin1; +INSERT INTO t3 VALUES +(15,NULL,'u'), (16,1,'m'), (17,9,NULL), (18,2,'o'), +(19,9,'w'), (20,2,'m'), (21,4,'q'), (22,0,NULL), +(23,4,'d'), (24,8,'g'), (25,NULL,'x'), (26,NULL,'f'), +(27,0,'p'), (28,NULL,'j'), (29,8,'c'); +CREATE VIEW view_inline_0 AS +SELECT t1.* +FROM t1 INNER JOIN t3 +ON t1.pk = t3.pk; +CREATE VIEW view_inline_1 AS +SELECT sq2_alias2.col_varchar_key AS sq2_field1, +sq2_alias1.col_varchar_key AS sq2_field2 +FROM t3 AS sq2_alias1 LEFT OUTER JOIN t3 AS sq2_alias2 +ON sq2_alias1.pk = sq2_alias2.col_int_key; +CREATE VIEW view_inline_2 AS +SELECT 'p', 'p' UNION SELECT 'k', 's'; +SET @optimizer_switch_saved= @@optimizer_switch; +SET @@optimizer_switch="derived_merge=off"; +explain SELECT SUM(alias1.col_varchar_nokey) AS field2 +FROM t2 AS alias2 +LEFT JOIN (SELECT * FROM view_inline_0) AS alias1 +ON alias2.col_varchar_key = alias1.col_varchar_key AND +(alias2.col_varchar_nokey, alias2.col_varchar_key) IN +(SELECT * FROM view_inline_1 +) +WHERE (alias1.col_varchar_key, alias1.col_varchar_nokey) IN +(SELECT * FROM view_inline_2 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL 2 100.00 NULL +1 PRIMARY alias2 NULL ALL NULL NULL NULL NULL 11 10.00 Using where; Using join buffer (hash join) +1 PRIMARY NULL ref 8 test.alias2.col_varchar_nokey,test.view_inline_2.p 3 100.00 Using index; Start temporary; End temporary +1 PRIMARY NULL ref 8 test.view_inline_2.p,test.view_inline_2.Name_exp_p 2 100.00 NULL +7 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +8 UNION NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +NULL UNION RESULT NULL ALL NULL NULL NULL NULL NULL NULL Using temporary +6 DERIVED sq2_alias1 NULL ALL NULL NULL NULL NULL 15 100.00 NULL +6 DERIVED sq2_alias2 NULL ref col_int_key col_int_key 5 test.sq2_alias1.pk 2 100.00 NULL +2 DERIVED NULL ALL NULL NULL NULL NULL 15 100.00 NULL +5 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select sum(`alias1`.`col_varchar_nokey`) AS `field2` from `test`.`view_inline_2` join `test`.`t2` `alias2` join (/* select#2 */ select `test`.`view_inline_0`.`pk` AS `pk`,`test`.`view_inline_0`.`col_varchar_key` AS `col_varchar_key`,`test`.`view_inline_0`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`view_inline_0`) `alias1` semi join (`test`.`view_inline_1`) where ((`test`.`view_inline_1`.`sq2_field1` = `test`.`alias2`.`col_varchar_nokey`) and (`alias1`.`col_varchar_nokey` = `test`.`view_inline_2`.`Name_exp_p`) and (`test`.`alias2`.`col_varchar_key` = `test`.`view_inline_2`.`p`) and (`test`.`view_inline_1`.`sq2_field2` = `test`.`view_inline_2`.`p`) and (`alias1`.`col_varchar_key` = `test`.`view_inline_2`.`p`)) +SELECT SUM(alias1.col_varchar_nokey) AS field2 +FROM t2 AS alias2 +LEFT JOIN (SELECT * FROM view_inline_0) AS alias1 +ON alias2.col_varchar_key = alias1.col_varchar_key AND +(alias2.col_varchar_nokey, alias2.col_varchar_key) IN +(SELECT * FROM view_inline_1 +) +WHERE (alias1.col_varchar_key, alias1.col_varchar_nokey) IN +(SELECT * FROM view_inline_2 +); +field2 +NULL +SET @@optimizer_switch= @optimizer_switch_saved; +DROP VIEW view_inline_0, view_inline_1, view_inline_2; +DROP TABLE t1, t2, t3; +# End of test for bug#13956813. +# +# Bug#13974177: Assert !(tab->table->regginfo.not_exists_optimize... +# +CREATE TABLE t1 ( +pk INTEGER AUTO_INCREMENT, +col_int_nokey INTEGER, +col_int_key INTEGER, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk), +KEY (col_int_key), +KEY (col_varchar_key, col_int_key) +); +INSERT INTO t1(col_int_key, col_int_nokey, col_varchar_key, col_varchar_nokey) +VALUES +(0, 4, 'j', 'j'), (8, 6, 'v', 'v'), (1, 3, 'c', 'c'), (8, 5, 'm', 'm'), +(9, 3, 'd', 'd'), (24, 246, 'd', 'd'), (6, 2, 'y', 'y'), (1, 9, 't', 't'), +(6, 3, 'd', 'd'), (2, 8, 's', 's'), (4, 1, 'r', 'r'), (8, 8, 'm', 'm'), +(4, 8, 'b', 'b'), (4, 5, 'x', 'x'), (7, 7, 'g', 'g'), (4, 5, 'p', 'p'), +(1, 1, 'q', 'q'), (9, 6, 'w', 'w'), (4, 2, 'd', 'd'), (8, 9, 'e', 'e'); +CREATE TABLE t2 ( +pk INTEGER AUTO_INCREMENT, +col_int_nokey INTEGER NOT NULL, +col_time_key TIME NOT NULL, +col_time_nokey TIME NOT NULL, +PRIMARY KEY (pk), +KEY (col_time_key) +) ENGINE=InnoDB; +INSERT INTO t2 (col_int_nokey, col_time_key, col_time_nokey) VALUES +(7, '00:00:00', '00:00:00'), (0, '00:00:00', '00:00:00'), +(9, '06:35:17', '06:35:17'), (3, '18:07:14', '18:07:14'), +(4, '20:36:52', '20:36:52'), (2, '21:29:07', '21:29:07'), +(5, '23:45:57', '23:45:57'), (3, '22:54:57', '22:54:57'), +(1, '18:45:09', '18:45:09'), (3, '14:30:46', '14:30:46'), +(6, '19:23:43', '19:23:43'), (7, '03:39:30', '03:39:30'), +(5, '23:37:52', '23:37:52'), (1, '16:59:30', '16:59:30'), +(204, '22:21:15', '22:21:15'), (224, '12:24:37', '12:24:37'), +(9, '15:02:08', '15:02:08'), (5, '23:59:59', '23:59:59'), +(0, '08:23:30', '08:23:30'), (3, '08:32:22', '08:32:22'); +explain SELECT ot1.col_int_key AS x +FROM t1 AS ot2 +LEFT JOIN t1 AS ot1 +ON ot2.col_varchar_nokey > ot1.col_varchar_key +WHERE (ot1.col_int_nokey, ot1.pk) IN +(SELECT it1.pk AS x, +it1.col_int_nokey AS y +FROM t2 AS it2 +LEFT JOIN t2 AS it1 +ON it2.col_time_nokey = it1.col_time_key +) AND ot1.pk IS NULL +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`col_int_key` AS `x` from `test`.`t2` `it1` join `test`.`t1` `ot2` join `test`.`t1` `ot1` semi join (`test`.`t2` `it2`) where ((`test`.`ot1`.`pk` is null) and (`test`.`ot2`.`col_varchar_nokey` > `test`.`ot1`.`col_varchar_key`) and multiple equal(`test`.`ot1`.`col_int_nokey`, `test`.`it1`.`pk`) and multiple equal(`test`.`ot1`.`pk`, `test`.`it1`.`col_int_nokey`) and multiple equal(`test`.`it2`.`col_time_nokey`, `test`.`it1`.`col_time_key`)) +SELECT ot1.col_int_key AS x +FROM t1 AS ot2 +LEFT JOIN t1 AS ot1 +ON ot2.col_varchar_nokey > ot1.col_varchar_key +WHERE (ot1.col_int_nokey, ot1.pk) IN +(SELECT it1.pk AS x, +it1.col_int_nokey AS y +FROM t2 AS it2 +LEFT JOIN t2 AS it1 +ON it2.col_time_nokey = it1.col_time_key +) AND ot1.pk IS NULL +; +x +DROP TABLE t1, t2; +# End of test for bug#13974177. +# +# Bug#13971022: Assert 'keyparts > 0' failed in create_ref_for_key... +# +CREATE TABLE t1 ( +pk INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +PRIMARY KEY (pk), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +CREATE TABLE t2 ( +pk INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk) +) charset utf8mb4 ENGINE=InnoDB; +CREATE TABLE t3 ( +i INT +); +SET @optimizer_switch_saved= @@optimizer_switch; +SET @@optimizer_switch="derived_merge=off"; +explain SELECT table1.pk AS field1 +FROM ( SELECT subquery1_t1. * +FROM t2 AS subquery1_t1 +JOIN t2 AS subquery1_t2 +ON subquery1_t2.pk = subquery1_t1.pk) AS table1 +STRAIGHT_JOIN t2 AS table2 +ON table1.col_int_key IN (SELECT 7 FROM t3) +WHERE table1.col_varchar_nokey IN +(SELECT subquery3_t1.col_varchar_key AS subquery3_field1 +FROM t1 AS subquery3_t1 +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY subquery3_t1 NULL index col_varchar_key col_varchar_key 12 NULL 0 0.00 Using where; Using index; Start temporary +1 PRIMARY t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using join buffer (hash join) +1 PRIMARY NULL ref 7 test.subquery3_t1.col_varchar_key 2 100.00 NULL +1 PRIMARY table2 NULL index NULL PRIMARY 4 NULL 1 100.00 Using index; End temporary; Using join buffer (hash join) +2 DERIVED subquery1_t1 NULL ALL PRIMARY NULL NULL NULL 1 100.00 Using where +2 DERIVED subquery1_t2 NULL eq_ref PRIMARY PRIMARY 4 test.subquery1_t1.pk 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `table1`.`pk` AS `field1` from (/* select#2 */ select `test`.`subquery1_t1`.`pk` AS `pk`,`test`.`subquery1_t1`.`col_int_key` AS `col_int_key`,`test`.`subquery1_t1`.`col_varchar_key` AS `col_varchar_key`,`test`.`subquery1_t1`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t2` `subquery1_t1` join `test`.`t2` `subquery1_t2` where ((`test`.`subquery1_t1`.`col_int_key` = 7) and (`test`.`subquery1_t2`.`pk` = `test`.`subquery1_t1`.`pk`))) `table1` straight_join `test`.`t2` `table2` semi join (`test`.`t3`) semi join (`test`.`t1` `subquery3_t1`) where (`table1`.`col_varchar_nokey` = `test`.`subquery3_t1`.`col_varchar_key`) +SELECT table1.pk AS field1 +FROM ( SELECT subquery1_t1. * +FROM t2 AS subquery1_t1 +JOIN t2 AS subquery1_t2 +ON subquery1_t2.pk = subquery1_t1.pk) AS table1 +STRAIGHT_JOIN t2 AS table2 +ON table1.col_int_key IN (SELECT 7 FROM t3) +WHERE table1.col_varchar_nokey IN +(SELECT subquery3_t1.col_varchar_key AS subquery3_field1 +FROM t1 AS subquery3_t1 +) +; +field1 +SET @@optimizer_switch= @optimizer_switch_saved; +DROP TABLE t1, t2, t3; +# End of test for bug#13971022. +# +# Bug#13623473 "MISSING ROWS ON SELECT AND JOIN WITH +# TIME/DATETIME COMPARE" - Subquery part of test. +# +SET TIMESTAMP=UNIX_TIMESTAMP('2012-01-31 10:14:35'); +CREATE TABLE t1 ( +pk INT NOT NULL, +col_int_nokey INT, +col_int_key INT NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +) ENGINE=InnoDB; +INSERT INTO t1 VALUES (10,1,7), (11,7,0), (12,4,9), (13,7,3), +(14,0,4), (15,2,2), (16,9,5), (17,4,3), (18,0,1), (19,9,3), (20,1,6), +(21,3,7), (22,8,5), (23,8,1), (24,18,204), (25,84,224), (26,6,9), +(27,3,5), (28,6,0), (29,6,3); +CREATE TABLE t2 ( +col_int_nokey INT NOT NULL, +col_datetime_key DATETIME NOT NULL, +col_varchar_key VARCHAR(1) NOT NULL, +KEY col_datetime_key (col_datetime_key), +KEY col_varchar_key (col_varchar_key) +) ENGINE=InnoDB; +INSERT INTO t2 VALUES (1,'2001-11-04 19:07:55','k'); +CREATE TABLE t3 ( +col_time_key TIME, +KEY col_time_key (col_time_key) +) ENGINE=InnoDB; +INSERT INTO t3 VALUES ('21:22:34'), ('10:50:38'), ('00:21:38'), +('04:08:02'), ('16:25:11'), ('10:14:58'), ('19:47:59'), ('11:14:24'), +('00:00:00'), ('00:00:00'), ('15:57:25'), ('07:05:51'), ('19:22:21'), +('03:53:16'), ('09:16:38'), ('15:37:26'), ('00:00:00'), ('05:03:03'), +('02:59:24'), ('00:01:58'); +EXPLAIN SELECT outr.col_int_nokey +FROM t2 as outr +STRAIGHT_JOIN t3 AS outr2 +ON outr2.col_time_key > outr.col_datetime_key +WHERE outr.col_int_nokey IN ( +SELECT col_int_key +FROM t1 AS innr +WHERE innr.pk >= innr.col_int_nokey +) AND ( +outr.col_int_nokey <= 6 +OR +outr.col_varchar_key IS NULL +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE outr NULL ALL col_datetime_key NULL NULL NULL 1 100.00 Using where +2 SIMPLE innr NULL ref col_int_key col_int_key 4 test.outr.col_int_nokey 1 33.33 Using where; Start temporary; End temporary +2 SIMPLE outr2 NULL index col_time_key col_time_key 4 NULL 20 33.33 Using where; Using index; Using join buffer (hash join) +Warnings: +Warning 1739 Cannot use range access on index 'col_time_key' due to type or collation conversion on field 'col_time_key' +Note 1003 /* select#1 */ select `test`.`outr`.`col_int_nokey` AS `col_int_nokey` from `test`.`t2` `outr` straight_join `test`.`t3` `outr2` semi join (`test`.`t1` `innr`) where ((`test`.`innr`.`col_int_key` = `test`.`outr`.`col_int_nokey`) and (`test`.`outr`.`col_int_nokey` <= 6) and (`test`.`innr`.`pk` >= `test`.`innr`.`col_int_nokey`) and (cast(`test`.`outr2`.`col_time_key` as datetime) > `test`.`outr`.`col_datetime_key`)) +SELECT outr.col_int_nokey +FROM t2 as outr +STRAIGHT_JOIN t3 AS outr2 +ON outr2.col_time_key > outr.col_datetime_key +WHERE outr.col_int_nokey IN ( +SELECT col_int_key +FROM t1 AS innr +WHERE innr.pk >= innr.col_int_nokey +) AND ( +outr.col_int_nokey <= 6 +OR +outr.col_varchar_key IS NULL +); +col_int_nokey +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +DROP TABLE t1,t2,t3; +SET TIMESTAMP = DEFAULT; +# End of test for bug#13623473. +# +# Bug#13980954: Missing data on left join + null value + where..in +# +CREATE TABLE t1 ( +ik INT, +vc varchar(1) +) charset utf8mb4; +INSERT INTO t1 VALUES (8, 'x'), (NULL, 'x'); +CREATE TABLE t2 ( +ik INT, +vc varchar(1) +) charset utf8mb4; +INSERT INTO t2 VALUES +(0, 'x'), (7, 'i'), (7, 'e'), (1, 'p'), (7, 's'), (1, 'j'); +explain format=json SELECT t2.vc, t2.ik AS t2_ik, t1.ik AS t1_ik +FROM t2 LEFT JOIN t1 ON t2.vc=t1.vc +WHERE t2.vc IN (SELECT vc FROM t2 AS t3); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "9.12" + }, + "nested_loop": [ + { + "duplicates_removal": { + "using_temporary_table": true, + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 6, + "rows_produced_per_join": 6, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "0.60", + "prefix_cost": "1.11", + "data_read_per_join": "96" + }, + "used_columns": [ + "ik", + "vc" + ] + } + }, + { + "table": { + "table_name": "t3", + "access_type": "ALL", + "rows_examined_per_scan": 6, + "rows_produced_per_join": 6, + "filtered": "16.67", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "0.60", + "prefix_cost": "7.41", + "data_read_per_join": "96" + }, + "used_columns": [ + "vc" + ], + "attached_condition": "(`test`.`t3`.`vc` = `test`.`t2`.`vc`)" + } + } + ] + } + }, + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 12, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "1.20", + "prefix_cost": "9.12", + "data_read_per_join": "192" + }, + "used_columns": [ + "ik", + "vc" + ], + "attached_condition": "(is_not_null_compl(t1), (`test`.`t1`.`vc` = `test`.`t2`.`vc`), true)" + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`vc` AS `vc`,`test`.`t2`.`ik` AS `t2_ik`,`test`.`t1`.`ik` AS `t1_ik` from `test`.`t2` left join `test`.`t1` on((`test`.`t1`.`vc` = `test`.`t2`.`vc`)) semi join (`test`.`t2` `t3`) where (`test`.`t3`.`vc` = `test`.`t2`.`vc`) +SELECT t2.vc, t2.ik AS t2_ik, t1.ik AS t1_ik +FROM t2 LEFT JOIN t1 ON t2.vc=t1.vc +WHERE t2.vc IN (SELECT vc FROM t2 AS t3); +vc t2_ik t1_ik +e 7 NULL +i 7 NULL +j 1 NULL +p 1 NULL +s 7 NULL +x 0 8 +x 0 NULL +DROP TABLE t1, t2; +# End of test for bug#13980954. +# +# Bug#14048292: Segfault in Item_field::result_type on 2nd execution +# of prep stmt with join of view +# +CREATE TABLE t1 ( +col_int INT +); +INSERT INTO t1 VALUES (0), (1); +CREATE VIEW view_t1 AS SELECT * FROM t1; +explain SELECT alias1.col_int +FROM t1 AS alias1 +LEFT JOIN view_t1 AS alias2 +ON alias1.col_int IN +(SELECT sq1_alias1.col_int +FROM t1 AS sq1_alias1 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE alias1 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE sq1_alias1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`alias1`.`col_int` AS `col_int` from `test`.`t1` `alias1` left join (`test`.`t1` semi join (`test`.`t1` `sq1_alias1`)) on(((`test`.`sq1_alias1`.`col_int` = `test`.`alias1`.`col_int`))) where true +PREPARE stmt FROM "SELECT alias1.col_int +FROM t1 AS alias1 +LEFT JOIN view_t1 AS alias2 +ON alias1.col_int IN +(SELECT sq1_alias1.col_int +FROM t1 AS sq1_alias1 +)"; +EXECUTE stmt; +col_int +0 +0 +1 +1 + +EXECUTE stmt; +col_int +0 +0 +1 +1 +DEALLOCATE PREPARE stmt; +DROP VIEW view_t1; +DROP TABLE t1; +# End of test for bug#14048292. +# +# Bug#14064201: Missing data on join of derived table + WHERE .. IN +# with two operands +# +CREATE TABLE t1 ( +col_varchar_nokey VARCHAR(1) +) charset utf8mb4; +INSERT INTO t1 VALUES +('v'), ('s'), ('l'), ('y'), ('c'), ('i'), ('h'), ('q'), ('a'), ('v'), +('u'), ('s'), ('y'), ('z'), ('h'), ('p'), ('e'), ('i'), ('y'), ('w'); +CREATE TABLE t2 ( +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +KEY col_varchar_key(col_varchar_key) +) charset utf8mb4; +INSERT INTO t2 VALUES +('j','j'), ('v','v'), ('c','c'), ('m','m'), ('d','d'), ('d','d'), ('y','y'); +SET @optimizer_switch_saved= @@optimizer_switch; +SET @@optimizer_switch="derived_merge=off"; +explain format=json SELECT * +FROM (SELECT * FROM t2) AS derived1 +LEFT JOIN t1 +USING (col_varchar_nokey) +WHERE (col_varchar_nokey, col_varchar_nokey) IN +(SELECT col_varchar_nokey, col_varchar_key +FROM t2 AS derived2 +); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "23.73" + }, + "nested_loop": [ + { + "duplicates_removal": { + "using_temporary_table": true, + "nested_loop": [ + { + "table": { + "table_name": "derived2", + "access_type": "ALL", + "possible_keys": [ + "col_varchar_key" + ], + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "0.70", + "prefix_cost": "1.21", + "data_read_per_join": "112" + }, + "used_columns": [ + "col_varchar_key", + "col_varchar_nokey" + ], + "attached_condition": "((`test`.`derived2`.`col_varchar_key` = `test`.`derived2`.`col_varchar_nokey`) and (`test`.`derived2`.`col_varchar_nokey` is not null))" + } + }, + { + "table": { + "table_name": "derived1", + "access_type": "ref", + "possible_keys": [ + "" + ], + "key": "", + "used_key_parts": [ + "col_varchar_nokey" + ], + "key_length": "7", + "ref": [ + "test.derived2.col_varchar_nokey" + ], + "rows_examined_per_scan": 2, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "3.50", + "eval_cost": "0.70", + "prefix_cost": "9.21", + "data_read_per_join": "112" + }, + "used_columns": [ + "col_varchar_key", + "col_varchar_nokey" + ], + "materialized_from_subquery": { + "using_temporary_table": true, + "dependent": false, + "cacheable": true, + "query_block": { + "select_id": 2, + "cost_info": { + "query_cost": "1.21" + }, + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "0.70", + "prefix_cost": "1.21", + "data_read_per_join": "112" + }, + "used_columns": [ + "col_varchar_key", + "col_varchar_nokey" + ] + } + } + } + } + } + ] + } + }, + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 140, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.52", + "eval_cost": "14.00", + "prefix_cost": "23.73", + "data_read_per_join": "1K" + }, + "used_columns": [ + "col_varchar_nokey" + ], + "attached_condition": "(is_not_null_compl(t1), (`test`.`t1`.`col_varchar_nokey` = `test`.`derived2`.`col_varchar_nokey`), true)" + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select `derived1`.`col_varchar_nokey` AS `col_varchar_nokey`,`derived1`.`col_varchar_key` AS `col_varchar_key` from (/* select#2 */ select `test`.`t2`.`col_varchar_key` AS `col_varchar_key`,`test`.`t2`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t2`) `derived1` left join `test`.`t1` on((`test`.`t1`.`col_varchar_nokey` = `test`.`derived2`.`col_varchar_nokey`)) semi join (`test`.`t2` `derived2`) where ((`test`.`derived2`.`col_varchar_key` = `test`.`derived2`.`col_varchar_nokey`) and (`derived1`.`col_varchar_nokey` = `test`.`derived2`.`col_varchar_nokey`)) +SELECT * +FROM (SELECT * FROM t2) AS derived1 +LEFT JOIN t1 +USING (col_varchar_nokey) +WHERE (col_varchar_nokey, col_varchar_nokey) IN +(SELECT col_varchar_nokey, col_varchar_key +FROM t2 AS derived2 +); +col_varchar_nokey col_varchar_key +c c +d d +d d +j j +m m +v v +v v +y y +y y +y y +SET @@optimizer_switch= @optimizer_switch_saved; +DROP TABLE t1, t2; +CREATE TABLE t1 ( +col_int_nokey int NOT NULL, +col_int_key int NOT NULL, +KEY col_int_key (col_int_key) +); +INSERT INTO t1 VALUES +(1,7), (7,0), (4,9), (7,3), (0,4), (2,2), (9,5), (4,3), (0,1), (9,3), +(1,6), (3,7), (8,5), (8,1), (18,204), (84,224), (6,9), (3,5), (6,0), (6,3); +CREATE TABLE t2 ( +col_int_nokey int NOT NULL, +col_int_key int NOT NULL, +KEY col_int_key (col_int_key) +); +INSERT INTO t2 VALUES +(4,0), (6,8), (3,1), (5,8), (3,9), (246,24), (2,6), (9,1), (3,6), (8,2), +(1,4), (8,8), (8,4), (5,4), (7,7), (5,4), (1,1), (6,9), (2,4), (9,8); +explain format=json SELECT grandparent1.* +FROM t1 AS grandparent1 +LEFT JOIN t1 USING (col_int_nokey) +WHERE (col_int_nokey, col_int_nokey) IN +(SELECT col_int_nokey, col_int_key +FROM t2 +); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "61.30" + }, + "nested_loop": [ + { + "table": { + "table_name": "grandparent1", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 20, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "2.00", + "prefix_cost": "2.51", + "data_read_per_join": "320" + }, + "used_columns": [ + "col_int_nokey", + "col_int_key" + ] + } + }, + { + "duplicates_removal": { + "using_temporary_table": true, + "table": { + "table_name": "t2", + "access_type": "ref", + "possible_keys": [ + "col_int_key" + ], + "key": "col_int_key", + "used_key_parts": [ + "col_int_key" + ], + "key_length": "4", + "ref": [ + "test.grandparent1.col_int_nokey" + ], + "rows_examined_per_scan": 2, + "rows_produced_per_join": 20, + "filtered": "10.00", + "cost_info": { + "read_cost": "10.00", + "eval_cost": "2.00", + "prefix_cost": "20.79", + "data_read_per_join": "320" + }, + "used_columns": [ + "col_int_nokey", + "col_int_key" + ], + "attached_condition": "(`test`.`t2`.`col_int_nokey` = `test`.`grandparent1`.`col_int_nokey`)" + } + } + }, + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 400, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "40.00", + "prefix_cost": "61.30", + "data_read_per_join": "6K" + }, + "used_columns": [ + "col_int_nokey" + ], + "attached_condition": "(is_not_null_compl(t1), (`test`.`t1`.`col_int_nokey` = `test`.`grandparent1`.`col_int_nokey`), true)" + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`grandparent1`.`col_int_nokey` AS `col_int_nokey`,`test`.`grandparent1`.`col_int_key` AS `col_int_key` from `test`.`t1` `grandparent1` left join `test`.`t1` on((`test`.`t1`.`col_int_nokey` = `test`.`grandparent1`.`col_int_nokey`)) semi join (`test`.`t2`) where ((`test`.`t2`.`col_int_nokey` = `test`.`grandparent1`.`col_int_nokey`) and (`test`.`t2`.`col_int_key` = `test`.`grandparent1`.`col_int_nokey`)) +SELECT grandparent1.* +FROM t1 AS grandparent1 +LEFT JOIN t1 USING (col_int_nokey) +WHERE (col_int_nokey, col_int_nokey) IN +(SELECT col_int_nokey, col_int_key +FROM t2 +); +col_int_nokey col_int_key +1 6 +1 6 +1 7 +1 7 +7 0 +7 0 +7 3 +7 3 +8 1 +8 1 +8 5 +8 5 +DROP TABLE t1, t2; +CREATE TABLE t1 ( +pk int, +col_int_key int, +col_datetime_key datetime, +col_varchar_key varchar(1), +col_varchar_nokey varchar(1), +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_datetime_key (col_datetime_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4 engine=MyISAM; +INSERT INTO t1 VALUES +(10,7,'2004-06-06 04:22:12','v','v'), (11,0,'2005-11-13 01:12:31','s','s'), +(12,9,'2002-05-04 01:50:00','l','l'), (13,3,'2004-10-27 10:28:45','y','y'), +(14,4,'2006-07-22 05:24:23','c','c'), (15,2,'2002-05-16 21:34:03','i','i'), +(16,5,'2008-04-17 10:45:30','h','h'), (17,3,'2009-04-21 02:58:02','q','q'), +(18,1,'2008-01-11 11:01:51','a','a'), (19,3,'1900-01-01 00:00:00','v','v'), +(20,6,'2007-05-17 18:24:57','u','u'), (21,7,'2007-08-07 00:00:00','s','s'), +(22,5,'2001-08-28 00:00:00','y','y'), (23,1,'2004-04-16 00:27:28','z','z'), +(24,204,'2005-05-03 07:06:22','h','h'), (25,224,'2009-03-11 17:09:50','p','p'), +(26,9,'2007-12-08 01:54:28','e','e'), (27,5,'2009-07-28 18:19:54','i','i'), +(28,0,'2008-06-08 00:00:00','y','y'), (29,3,'2005-02-09 09:20:26','w','w'); +CREATE TABLE t2 ( +pk int, +col_int_key int, +col_datetime_key datetime, +col_varchar_key varchar(1), +col_varchar_nokey varchar(1), +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_datetime_key (col_datetime_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4 engine=MyISAM; +INSERT INTO t2 VALUES +(1,0,'2002-02-13 17:30:06','j','j'), (2,8,'2008-09-27 00:34:58','v','v'), +(3,1,'2007-05-28 00:00:00','c','c'), (4,8,'2009-07-25 09:21:20','m','m'), +(5,9,'2002-01-16 00:00:00','d','d'), (6,24,'2006-10-12 04:32:53','d','d'), +(7,6,'2001-02-15 03:08:38','y','y'), (8,1,'2004-10-02 20:31:15','t','t'), +(9,6,'2002-08-20 22:48:00','d','d'), (10,2,'1900-01-01 00:00:00','s','s'), +(11,4,'2005-08-15 00:00:00','r','r'), (12,8,'1900-01-01 00:00:00','m','m'), +(13,4,'2008-05-16 08:09:06','b','b'), (14,4,'2001-01-20 12:47:23','x','x'), +(15,7,'2008-07-02 00:00:00','g','g'), (16,4,'1900-01-01 00:00:00','p','p'), +(17,1,'2002-12-08 11:34:58','q','q'), (18,9,'1900-01-01 00:00:00','w','w'), +(19,4,'1900-01-01 00:00:00','d','d'), (20,8,'2002-08-25 20:35:06','e','e'); +SELECT alias1.col_datetime_key +FROM t2 AS alias1 +RIGHT JOIN t2 AS alias2 +JOIN t2 AS alias3 +ON alias3.pk = alias2.pk +ON alias3.col_varchar_nokey = alias2.col_varchar_key OR +alias2.col_varchar_nokey +WHERE (alias2.col_varchar_key, alias2.col_varchar_key) IN +(SELECT sq2_alias2.col_varchar_key, sq2_alias1.col_varchar_nokey +FROM t1 AS sq2_alias1, t1 AS sq2_alias2 +WHERE sq2_alias2.col_int_key < 2); +col_datetime_key +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +2001-01-20 12:47:23 +2001-01-20 12:47:23 +2001-02-15 03:08:38 +2001-02-15 03:08:38 +2002-01-16 00:00:00 +2002-01-16 00:00:00 +2002-02-13 17:30:06 +2002-02-13 17:30:06 +2002-08-20 22:48:00 +2002-08-20 22:48:00 +2002-08-25 20:35:06 +2002-08-25 20:35:06 +2002-12-08 11:34:58 +2002-12-08 11:34:58 +2004-10-02 20:31:15 +2004-10-02 20:31:15 +2005-08-15 00:00:00 +2005-08-15 00:00:00 +2006-10-12 04:32:53 +2006-10-12 04:32:53 +2007-05-28 00:00:00 +2007-05-28 00:00:00 +2008-05-16 08:09:06 +2008-05-16 08:09:06 +2008-07-02 00:00:00 +2008-07-02 00:00:00 +2008-09-27 00:34:58 +2008-09-27 00:34:58 +2009-07-25 09:21:20 +2009-07-25 09:21:20 +ALTER TABLE t1 DISABLE KEYS; +ALTER TABLE t2 DISABLE KEYS; +explain format=json SELECT alias1.col_datetime_key +FROM t2 AS alias1 +RIGHT JOIN t2 AS alias2 +JOIN t2 AS alias3 +ON alias3.pk = alias2.pk +ON alias3.col_varchar_nokey = alias2.col_varchar_key OR +alias2.col_varchar_nokey +WHERE (alias2.col_varchar_key, alias2.col_varchar_key) IN +(SELECT sq2_alias2.col_varchar_key, sq2_alias1.col_varchar_nokey +FROM t1 AS sq2_alias1, t1 AS sq2_alias2 +WHERE sq2_alias2.col_int_key < 2); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "52.68" + }, + "nested_loop": [ + { + "duplicates_removal": { + "using_temporary_table": true, + "nested_loop": [ + { + "table": { + "table_name": "sq2_alias2", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 6, + "filtered": "33.33", + "cost_info": { + "read_cost": "1.86", + "eval_cost": "0.67", + "prefix_cost": "2.53", + "data_read_per_join": "213" + }, + "used_columns": [ + "col_int_key", + "col_varchar_key" + ], + "attached_condition": "(`test`.`sq2_alias2`.`col_int_key` < 2)" + } + }, + { + "table": { + "table_name": "alias2", + "access_type": "ALL", + "possible_keys": [ + "PRIMARY" + ], + "rows_examined_per_scan": 20, + "rows_produced_per_join": 13, + "filtered": "10.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.53", + "eval_cost": "1.33", + "prefix_cost": "16.39", + "data_read_per_join": "426" + }, + "used_columns": [ + "pk", + "col_varchar_key", + "col_varchar_nokey" + ], + "attached_condition": "(`test`.`alias2`.`col_varchar_key` = `test`.`sq2_alias2`.`col_varchar_key`)" + } + }, + { + "table": { + "table_name": "sq2_alias1", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 2, + "filtered": "10.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.53", + "eval_cost": "0.20", + "prefix_cost": "47.45", + "data_read_per_join": "64" + }, + "used_columns": [ + "col_varchar_nokey" + ], + "attached_condition": "(`test`.`sq2_alias1`.`col_varchar_nokey` = `test`.`sq2_alias2`.`col_varchar_key`)" + } + } + ] + } + }, + { + "table": { + "table_name": "alias3", + "access_type": "eq_ref", + "possible_keys": [ + "PRIMARY" + ], + "key": "PRIMARY", + "used_key_parts": [ + "pk" + ], + "key_length": "4", + "ref": [ + "test.alias2.pk" + ], + "rows_examined_per_scan": 1, + "rows_produced_per_join": 2, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.20", + "prefix_cost": "48.15", + "data_read_per_join": "64" + }, + "used_columns": [ + "pk", + "col_varchar_nokey" + ] + } + }, + { + "table": { + "table_name": "alias1", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 40, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.53", + "eval_cost": "4.00", + "prefix_cost": "52.68", + "data_read_per_join": "1K" + }, + "used_columns": [ + "col_datetime_key" + ], + "attached_condition": "(is_not_null_compl(alias1), (((`test`.`alias2`.`col_varchar_key` = `test`.`sq2_alias2`.`col_varchar_key`) and (`test`.`sq2_alias1`.`col_varchar_nokey` = `test`.`sq2_alias2`.`col_varchar_key`) and (`test`.`alias3`.`col_varchar_nokey` = `test`.`sq2_alias2`.`col_varchar_key`)) or (0 <> `test`.`alias2`.`col_varchar_nokey`)), true)" + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`alias1`.`col_datetime_key` AS `col_datetime_key` from `test`.`t2` `alias2` join `test`.`t2` `alias3` left join `test`.`t2` `alias1` on((((`test`.`alias2`.`col_varchar_key` = `test`.`sq2_alias2`.`col_varchar_key`) and (`test`.`sq2_alias1`.`col_varchar_nokey` = `test`.`sq2_alias2`.`col_varchar_key`) and (`test`.`alias3`.`col_varchar_nokey` = `test`.`sq2_alias2`.`col_varchar_key`)) or (0 <> `test`.`alias2`.`col_varchar_nokey`))) semi join (`test`.`t1` `sq2_alias1` join `test`.`t1` `sq2_alias2`) where ((`test`.`alias3`.`pk` = `test`.`alias2`.`pk`) and (`test`.`alias2`.`col_varchar_key` = `test`.`sq2_alias2`.`col_varchar_key`) and (`test`.`sq2_alias1`.`col_varchar_nokey` = `test`.`sq2_alias2`.`col_varchar_key`) and (`test`.`sq2_alias2`.`col_int_key` < 2)) +SELECT alias1.col_datetime_key +FROM t2 AS alias1 +RIGHT JOIN t2 AS alias2 +JOIN t2 AS alias3 +ON alias3.pk = alias2.pk +ON alias3.col_varchar_nokey = alias2.col_varchar_key OR +alias2.col_varchar_nokey +WHERE (alias2.col_varchar_key, alias2.col_varchar_key) IN +(SELECT sq2_alias2.col_varchar_key, sq2_alias1.col_varchar_nokey +FROM t1 AS sq2_alias1, t1 AS sq2_alias2 +WHERE sq2_alias2.col_int_key < 2); +col_datetime_key +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +2001-01-20 12:47:23 +2001-01-20 12:47:23 +2001-02-15 03:08:38 +2001-02-15 03:08:38 +2002-01-16 00:00:00 +2002-01-16 00:00:00 +2002-02-13 17:30:06 +2002-02-13 17:30:06 +2002-08-20 22:48:00 +2002-08-20 22:48:00 +2002-08-25 20:35:06 +2002-08-25 20:35:06 +2002-12-08 11:34:58 +2002-12-08 11:34:58 +2004-10-02 20:31:15 +2004-10-02 20:31:15 +2005-08-15 00:00:00 +2005-08-15 00:00:00 +2006-10-12 04:32:53 +2006-10-12 04:32:53 +2007-05-28 00:00:00 +2007-05-28 00:00:00 +2008-05-16 08:09:06 +2008-05-16 08:09:06 +2008-07-02 00:00:00 +2008-07-02 00:00:00 +2008-09-27 00:34:58 +2008-09-27 00:34:58 +2009-07-25 09:21:20 +2009-07-25 09:21:20 +DROP TABLE t1, t2; +# End of test for bug#14064201. +# +# Bug#18223655:ASSERTION FAILED: (INT)IDX >= 0 +# && IDX < PARENT_JOIN->TABLES +# +CREATE TABLE b (d INT); +CREATE TABLE c (a INT, b INT,c INT,d BLOB NOT NULL); +SELECT(SELECT 1 +FROM b WHERE(SELECT 1 IN (SELECT 1 FROM b WHERE 1 NOT BETWEEN d AND 1) +FROM b) IN (SELECT d FROM c)) as cc FROM b; +cc +INSERT INTO b VALUE(1); +INSERT INTO c VALUES(1,2,3,'1'),(2,3,4,'1'),(3,4,5,'C'); +SELECT(SELECT d FROM b WHERE(SELECT d IN +(SELECT d FROM b WHERE 1 NOT BETWEEN d AND 1) FROM b) IN +(SELECT d FROM c)) as cc FROM c; +cc +1 +1 +1 +DROP TABLE b,c; +# +# Bug#18447874:WRONG RESULT COMING FROM SEMI-JOIN +# +CREATE TABLE b ( +d INT(11) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE c ( +d BLOB +) ; +CREATE TABLE d ( +b INT(11) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO b VALUES(1),(2),(4); +INSERT INTO c VALUES(1),(2),(3); +SELECT 1 FROM b WHERE (SELECT 1 FROM d ) IN (SELECT d FROM c) ; +1 +INSERT INTO d VALUES(2); +SELECT 1 FROM b WHERE (SELECT 1 FROM d ) IN (SELECT d FROM c) ; +1 +1 +1 +1 +DROP TABLE b,c,d; +# +# Bug#17292723:INCORRECT RESULT FOR (SELECT...) IN (SELECT...) STATEMENT +# +CREATE TABLE t1 ( +ID int(11) NOT NULL AUTO_INCREMENT, +id2 int(11) DEFAULT NULL, +id3 int(11) DEFAULT NULL, +id4 varchar(150) COLLATE utf8_spanish_ci NOT NULL, +id5 int(11) DEFAULT NULL, +PRIMARY KEY (ID), +KEY id2 (id2), +KEY id3 (id3), +KEY id5 (id5) +) ENGINE=InnoDB; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 3778 'utf8_spanish_ci' is a collation of the deprecated character set UTF8MB3. Please consider using UTF8MB4 with an appropriate collation instead. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES +(123,1,1,'1',NULL), +(124,1,1,'2',NULL), +(125,1,1,'4',NULL), +(126,1,1,'3',NULL), +(127,1,1,'6',NULL), +(128,1,1,'8',NULL); +CREATE TABLE t2 ( +id6 int(11) NOT NULL, +id7 int(11) NOT NULL, +PRIMARY KEY (id6,id7), +KEY id7 (id7) +) ENGINE=InnoDB; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (126,123),(130,123),(135,123); +SELECT ID +FROM t1 p0 +WHERE p0.id3=1 +AND ( (SELECT p1.id FROM t1 p1 WHERE p1.id=123) IN (SELECT p3.id FROM t2 +p2, t1 p3 WHERE p0.id=p2.id6 AND p2.id7=p3.id)); +ID +126 +DROP TABLE t1,t2; +set @@optimizer_switch=@old_opt_switch; +# End of 5.6 tests +# +# Bug#19336348 DEBUG CRASH AT SETUP_SEMIJOIN_DUPS_ELIMINATION IN SQL/SQL_SELECT.CC +# +CREATE TABLE t1 ( +col_varchar_nokey varchar(1) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t1 VALUES ('c'),(NULL),('x'); +CREATE TABLE t2 ( +pk int, +col_varchar_key varchar(1), +PRIMARY KEY (pk), +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t2 VALUES (10,'l'),(11,'p'); +ANALYZE TABLE t1,t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN SELECT 1 +FROM t1 AS outr +WHERE outr.col_varchar_nokey IN +( +SELECT innr.col_varchar_key +FROM t2 AS innr +WHERE innr.pk <= 7 +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE innr NULL range PRIMARY,col_varchar_key PRIMARY 4 NULL 1 100.00 Using where; Start temporary +1 SIMPLE outr NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` `outr` semi join (`test`.`t2` `innr`) where ((`test`.`outr`.`col_varchar_nokey` = `test`.`innr`.`col_varchar_key`) and (`test`.`innr`.`pk` <= 7)) +SELECT 1 +FROM t1 AS outr +WHERE outr.col_varchar_nokey IN +( +SELECT innr.col_varchar_key +FROM t2 AS innr +WHERE innr.pk <= 7 +) +; +1 +DROP TABLE t1,t2; +# +# Bug#18174394 BLOBS: CRASH AFTER UNINITIALIZED VALUES IN ITEM_FIELD::STR_RESULT +# +CREATE TABLE t1(d BLOB, b BLOB); +INSERT INTO t1(d,b) VALUES ('aaaa',''),('bnbb',''); +SELECT 1 FROM t1 +WHERE (SELECT b FROM t1) IN (SELECT (d>=1) FROM t1); +ERROR 21000: Subquery returns more than 1 row +DROP TABLE t1; +# +# Bug#19779600: ASSERT FAILED IN REPLACE_SUBCONDITION WITH IN +# PREDICATE INSIDE IN PREDICATE +# +CREATE TABLE t(X INT) ENGINE=InnoDB; +INSERT INTO t VALUES (1); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +EXPLAIN SELECT 1 FROM t WHERE (1 IN (SELECT 1 FROM t)) IN (SELECT 1 FROM t); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 PRIMARY t NULL ALL NULL NULL NULL NULL 1 100.00 End temporary; Using join buffer (hash join) +2 SUBQUERY t NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t` semi join (`test`.`t`) where true +SELECT 1 FROM t WHERE (1 IN (SELECT 1 FROM t)) IN (SELECT 1 FROM t); +1 +1 +DROP TABLE t; +# +# Bug#19465034 ASSERT ON SETUP_SEMIJOIN_DUPS_ELIMINATION IN SQL/SQL_SELECT.CC +# +CREATE TABLE t1 ( +pk INTEGER NOT NULL, +i1 INTEGER NOT NULL, +PRIMARY KEY (pk) +) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1,1); +CREATE TABLE t2 ( +pk INTEGER NOT NULL, +c1 VARCHAR(1) NOT NULL, +PRIMARY KEY (pk), +KEY c1_key (c1) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t2 VALUES (1,'j'),(2,'v'),(3,'c'); +CREATE TABLE t3 ( +pk INTEGER NOT NULL, +c1 VARCHAR(1) NOT NULL, +PRIMARY KEY (pk), +KEY c1_key (c1) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t3 VALUES (10,'v'),(11,'s'); +ANALYZE TABLE t1, t2, t3; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +EXPLAIN SELECT * +FROM t1 JOIN t2 ON t1.i1 >= t2.pk +WHERE t2.c1 IN ( +SELECT t3.c1 +FROM t3 +WHERE t3.pk < 3 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +2 SIMPLE t3 NULL range PRIMARY,c1_key PRIMARY 4 NULL 1 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t2 NULL ref PRIMARY,c1_key c1_key 6 test.t3.c1 1 33.33 Using where; Using index; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`i1` AS `i1`,`test`.`t2`.`pk` AS `pk`,`test`.`t2`.`c1` AS `c1` from `test`.`t1` join `test`.`t2` semi join (`test`.`t3`) where ((`test`.`t2`.`c1` = `test`.`t3`.`c1`) and (`test`.`t3`.`pk` < 3) and (`test`.`t1`.`i1` >= `test`.`t2`.`pk`)) +SELECT * +FROM t1 JOIN t2 ON t1.i1 >= t2.pk +WHERE t2.c1 IN ( +SELECT t3.c1 +FROM t3 +WHERE t3.pk < 3 +); +pk i1 pk c1 +DROP TABLE t1,t2,t3; +# +# Bug#19586047: CRASH IN ARG_COMPARATOR::SET_CMP_FUNC +# +CREATE TABLE t1(x INT) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT 1 FROM t1 WHERE EXISTS(SELECT 1) IN (SELECT 1 FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 1 100.00 End temporary; Using join buffer (hash join) +2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` semi join (`test`.`t1`) where true +SELECT 1 FROM t1 WHERE EXISTS(SELECT 1) IN (SELECT 1 FROM t1); +1 +1 +EXPLAIN SELECT 1 FROM t1 WHERE (SELECT 1, 2 FROM t1) IN (SELECT 1, 2 FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 1 100.00 End temporary; Using join buffer (hash join) +2 SUBQUERY t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` semi join (`test`.`t1`) where true +SELECT 1 FROM t1 WHERE (SELECT 1, 2 FROM t1) IN (SELECT 1, 2 FROM t1); +1 +1 +EXPLAIN SELECT 1 FROM t1 WHERE +(SELECT 1, 2 FROM t1 WHERE x = 2) IN (SELECT 1, 2 FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +2 SUBQUERY t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` semi join (`test`.`t1`) where false +SELECT 1 FROM t1 WHERE +(SELECT 1, 2 FROM t1 WHERE x = 2) IN (SELECT 1, 2 FROM t1); +1 +DROP TABLE t1; +# +#Bug#20119743 ASSERTIONQEP_TAB->USE_ORDER() IN ENUM_NESTED_LOOP_STATE +# EVALUATE_JOIN_RECORD +# +CREATE TABLE t1 ( +pk int(11) NOT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +PRIMARY KEY (pk) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (1,'x'); +CREATE TABLE t2 ( +col_date_key date DEFAULT NULL, +col_int_key int(11) DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +KEY col_int_key (col_int_key), +KEY col_date_key (col_date_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES ('2000-12-03', 8, 'x', 'x'),('2008-05-03', 7, 'd', 'd'), +('2005-12-06', 1, 'r', 'r'),('2000-04-10', 7, 'f', 'f'), +('2002-11-05', 9, 'y', 'y'),('2000-09-06', NULL, 'u', 'u'), +(NULL, 1, 'm', 'm'),('2007-06-14', 9, NULL, NULL), +('2007-11-17', 2, 'o', 'o'),('2009-02-23', 9, 'w', 'w'), +('2007-01-08', 2, 'm', 'm'), ('2008-06-10', 4, 'q', 'q'), +('2002-10-20', 0, NULL, NULL),('2008-09-12', 4, 'd', 'd'), +('2006-06-16', 8, 'g', 'g'),('2004-09-18', NULL, 'x', 'x'), +('1900-01-01', NULL, 'f', 'f'),('2005-09-13', 0, 'p', 'p'), +('2007-04-09', NULL, 'j', 'j'),('2000-09-20', 8, 'c', 'c'); +CREATE TABLE t3 ( +pk int(11) NOT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +PRIMARY KEY (pk) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t3 VALUES (1, 'c'),(2, 'c'),(3, 'q'),(4, 'g'),(5, 'e'),(6, 'l'), +(7, NULL),(8, 'v'),(9, 'c'),(10, 'u'),(11, 'x'),(12, 'x'),(13, 'x'),(14, 'l'), +(15, 'e'),(16, 's'),(17, 'k'),(18, 'm'),(19, 'x'),(20, 's'); +ANALYZE TABLE t1,t2,t3; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +EXPLAIN SELECT r1.col_date_key +FROM t2 AS r1 +WHERE r1.col_int_key NOT IN +(SELECT ir2.pk +FROM t2 AS ir1 STRAIGHT_JOIN t1 AS ir2 +ON ir2.col_varchar_nokey = ir1.col_varchar_key +WHERE ir2.col_varchar_nokey > r1.col_varchar_nokey +AND ir2.pk IN +(SELECT iir2.pk +FROM t2 AS iir1 RIGHT JOIN t3 AS iir2 +ON iir2.col_varchar_nokey = iir1.col_varchar_key)) +ORDER BY r1.col_date_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY r1 NULL ALL NULL NULL NULL NULL 20 100.00 Using where; Using filesort +2 DEPENDENT SUBQUERY iir2 NULL eq_ref PRIMARY PRIMARY 4 func 1 100.00 Using where; Start temporary; Full scan on NULL key +2 DEPENDENT SUBQUERY iir1 NULL ref col_varchar_key col_varchar_key 7 test.iir2.col_varchar_nokey 1 100.00 Using index +2 DEPENDENT SUBQUERY ir1 NULL index col_varchar_key col_varchar_key 12 NULL 20 100.00 Using where; Using index; Using join buffer (hash join) +2 DEPENDENT SUBQUERY ir2 NULL eq_ref PRIMARY PRIMARY 4 func 1 100.00 Using where; End temporary; Full scan on NULL key +SELECT r1.col_date_key +FROM t2 AS r1 +WHERE r1.col_int_key NOT IN +(SELECT ir2.pk +FROM t2 AS ir1 STRAIGHT_JOIN t1 AS ir2 +ON ir2.col_varchar_nokey = ir1.col_varchar_key +WHERE ir2.col_varchar_nokey > r1.col_varchar_nokey +AND ir2.pk IN +(SELECT iir2.pk +FROM t2 AS iir1 RIGHT JOIN t3 AS iir2 +ON iir2.col_varchar_nokey = iir1.col_varchar_key)) +ORDER BY r1.col_date_key; +col_date_key +2000-04-10 +2000-09-20 +2000-12-03 +2002-10-20 +2002-11-05 +2004-09-18 +2005-09-13 +2006-06-16 +2007-01-08 +2007-06-14 +2007-11-17 +2008-05-03 +2008-06-10 +2008-09-12 +2009-02-23 +SELECT COUNT(r1.col_date_key) AS COUNT_NUM +FROM t2 AS r1 +WHERE r1.col_int_key NOT IN +(SELECT ir2.pk +FROM t2 AS ir1 STRAIGHT_JOIN t1 AS ir2 +ON ir2.col_varchar_nokey = ir1.col_varchar_key +WHERE ir2.col_varchar_nokey > r1.col_varchar_nokey +AND ir2.pk IN +(SELECT iir2.pk +FROM t2 AS iir1 RIGHT JOIN t3 AS iir2 +ON iir2.col_varchar_nokey = iir1.col_varchar_key +WHERE iir2.pk<3)); +COUNT_NUM +15 +DROP TABLE t1,t2,t3; +# +# Bug#20554585 ASSERT JOIN()->TABLES == 0... IN JOIN_TAB::GET_SJ_STRATEGY ON SUBQUERY + VAR +# +CREATE TABLE t1 ( +pk int NOT NULL, +PRIMARY KEY (pk) +); +CREATE TABLE t2 ( +pk int NOT NULL, +col_int_key int, +col_varchar_key varchar(1), +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key) +); +CREATE TABLE t3 ( +pk int NOT NULL, +col_int_key int, +col_varchar_key varchar(1), +col_varchar varchar(1), +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key) +); +INSERT INTO t3 VALUES (1,4,'c','g'),(20,1,'i','p'); +CREATE TABLE t4 ( +col_int int +); +CREATE TABLE t5 ( +col_varchar_key varchar(1), +pk int NOT NULL, +col_int int, +PRIMARY KEY (pk), +KEY col_varchar_key (col_varchar_key) +); +SELECT table1.col_varchar_key AS field1 +FROM (t3 AS table1 +INNER JOIN ( +SELECT SUBQUERY1_t1.* +FROM (t1 AS SUBQUERY1_t1 +RIGHT JOIN (t2 AS SUBQUERY1_t2 +INNER JOIN t3 AS SUBQUERY1_t3 +ON (SUBQUERY1_t3.col_varchar_key = SUBQUERY1_t2.col_varchar_key) +) ON (SUBQUERY1_t3.col_int_key = SUBQUERY1_t2.pk) +) +WHERE SUBQUERY1_t2.col_varchar_key >= ANY ( +SELECT CHILD_SUBQUERY1_t2.col_varchar AS CHILD_SUBQUERY1_field1 +FROM (t2 AS CHILD_SUBQUERY1_t1 +LEFT OUTER JOIN t3 AS CHILD_SUBQUERY1_t2 +ON (CHILD_SUBQUERY1_t2.col_int_key = CHILD_SUBQUERY1_t1.col_int_key) +) +WHERE CHILD_SUBQUERY1_t1.pk >= SUBQUERY1_t2.pk +) +) AS table2 +ON (table2.pk = table1.pk) +) +WHERE (EXISTS (( +SELECT DISTINCT SUBQUERY2_t2.col_int AS SUBQUERY2_field1 +FROM (t4 AS SUBQUERY2_t1 +LEFT OUTER JOIN t5 AS SUBQUERY2_t2 +ON (SUBQUERY2_t2.pk = SUBQUERY2_t1.col_int) +) +WHERE SUBQUERY2_t2.col_varchar_key != @var4 +))) +AND table1.col_int_key < (35 + 192) +ORDER BY field1 +; +field1 +DROP TABLE t1, t2, t3, t4, t5; +# +# Bug#18892055: MISSING DATA ON SELECT ... IN WITH JOINS AND INNODB +# ENGINE +# +CREATE TABLE t1 ( +col_int_key INT, +pk INT NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +) ENGINE = INNODB; +INSERT INTO t1 VALUES +( 0, 3 ), +( 0, 4 ), +( 3, 1 ), +( 900000000, 2 ), +( 1368719360, 5 ), +( 1922236416, 6 ), +( 8,7 ); +CREATE TABLE t2 ( +pk INT NOT NULL, +col_int INT, +PRIMARY KEY (pk) +) ENGINE = INNODB; +INSERT INTO t2 VALUES +( 1, 3 ), +( 2, 2 ), +( 3, 8 ), +( 4, 7 ); +CREATE TABLE t3 ( +col_int_key INT, +col_int INT, +KEY (col_int_key) +) ENGINE = INNODB; +INSERT INTO t3 VALUES +( 5, 1 ), +( -1, -1 ), +( 300000000, 1 ), +( 8, 1 ); +CREATE TABLE t4 ( col_int_key INT ) ENGINE = INNODB; +INSERT INTO t4 VALUES +(0), +(3), +(8), +(900000000), +(1368719360), +(1922236416); +ANALYZE TABLE t1, t2, t3, t4; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +test.t4 analyze status OK +explain SELECT * +FROM t4 +WHERE (col_int_key) IN ( +SELECT t1.col_int_key +FROM t1 LEFT JOIN ( t2 JOIN t3 ON t3.col_int_key = t2.col_int ) USING ( pk ) +WHERE t3.col_int IS NULL +) +ORDER BY col_int_key +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 6 100.00 Parallel execute (1 workers) +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 6 100.00 Using where; Using filesort +2 SIMPLE t1 NULL ref col_int_key col_int_key 5 test.t4.col_int_key 1 100.00 Using index; Start temporary +2 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.pk 1 100.00 NULL +2 SIMPLE t3 NULL ALL col_int_key NULL NULL NULL 4 25.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`col_int_key` AS `col_int_key` from `test`.`t4` semi join (`test`.`t1` left join (`test`.`t2` join `test`.`t3`) on(((`test`.`t1`.`pk` = `test`.`t2`.`pk`) and (`test`.`t3`.`col_int_key` = `test`.`t2`.`col_int`)))) where ((`test`.`t1`.`col_int_key` = `test`.`t4`.`col_int_key`) and (`test`.`t3`.`col_int` is null)) order by `test`.`t4`.`col_int_key` +explain format=tree SELECT * +FROM t4 +WHERE (col_int_key) IN ( +SELECT t1.col_int_key +FROM t1 LEFT JOIN ( t2 JOIN t3 ON t3.col_int_key = t2.col_int ) USING ( pk ) +WHERE t3.col_int IS NULL +) +ORDER BY col_int_key +; +EXPLAIN +-> Parallel scan on + -> Nested loop inner join (cost=3.05 rows=7) + -> Sort: t4.col_int_key (cost=0.85 rows=6) + -> Filter: (t4.col_int_key is not null) + -> PQblock scan on t4 + -> Limit: 1 row(s) (cost=2.14 rows=1) + -> Filter: (t3.col_int is null) (cost=2.14 rows=1) + -> Nested loop left join (cost=2.14 rows=1) + -> Index lookup on t1 using col_int_key (col_int_key=t4.col_int_key) (cost=0.27 rows=1) + -> Nested loop inner join (cost=1.21 rows=1) + -> Single-row index lookup on t2 using PRIMARY (pk=t1.pk) (cost=0.26 rows=1) + -> Filter: (t3.col_int_key = t2.col_int) (cost=0.11 rows=1) + -> Table scan on t3 (cost=0.11 rows=4) + +SELECT * +FROM t4 +WHERE (col_int_key) IN ( +SELECT t1.col_int_key +FROM t1 LEFT JOIN ( t2 JOIN t3 ON t3.col_int_key = t2.col_int ) USING ( pk ) +WHERE t3.col_int IS NULL +) +ORDER BY col_int_key +; +col_int_key +0 +3 +8 +900000000 +1368719360 +1922236416 +DROP TABLE t1, t2, t3, t4; +# +# Bug#20835095 CRASH AT CREATE_REF_FOR_KEY IN SQL/SQL_SELECT.CC +# +CREATE TABLE t1 ( +pk INTEGER, +var_10_latin1 VARCHAR(10) CHARACTER SET latin1, +var_255_utf8 VARCHAR(255) CHARACTER SET utf8, +var_255_latin1 VARCHAR(255) CHARACTER SET latin1, +var_10_utf8 VARCHAR(10) CHARACTER SET utf8, +PRIMARY KEY (pk) +); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +CREATE VIEW v1 AS SELECT * FROM t1; +INSERT INTO t1 VALUES +(1,'FROCJ','korrhrspki','UAYVL','BPZIS'), +(2,'him','a','CHYKN','OZZQT'), +(3,'WBITK','ULWBF','have','rhrh'), +(4,'or','right','up','it'), +(5,'GGDCP','x','who','as'), +(6,'j','i','e','w'); +CREATE TABLE tv +SELECT var_255_utf8 AS field1 +FROM t1; +EXPLAIN SELECT * FROM tv +WHERE field1 IN ( +SELECT tv1.var_255_utf8 +FROM v1 AS tv1 LEFT JOIN v1 AS tv2 ON tv1.var_10_latin1=tv2.var_10_utf8); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE tv NULL ALL NULL NULL NULL NULL 6 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 6 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`tv`.`field1` AS `field1` from `test`.`tv` semi join (`test`.`t1` left join (`test`.`t1`) on((`test`.`t1`.`var_10_latin1` = `test`.`t1`.`var_10_utf8`))) where (`test`.`t1`.`var_255_utf8` = `test`.`tv`.`field1`) +SELECT * FROM tv +WHERE field1 IN ( +SELECT tv1.var_255_utf8 +FROM v1 AS tv1 LEFT JOIN v1 AS tv2 ON tv1.var_10_latin1=tv2.var_10_utf8); +field1 +korrhrspki +a +ULWBF +right +x +i +DROP VIEW v1; +DROP TABLE t1, tv; +# 17832047 Crash in calculate_materialization_costs +CREATE TABLE t1(a INTEGER PRIMARY KEY); +INSERT INTO t1 VALUES (0),(1),(2); +SELECT 1 FROM t1 +WHERE 1 IN +(SELECT 1 BETWEEN (LENGTH(a) IN (SELECT 1 FROM t1)) AND 1 +FROM t1 +); +1 +1 +1 +1 +DROP TABLE t1; +# 17845989 Assertion failed: !(used_tables() & ... +CREATE TABLE a(b INTEGER) engine=innodb; +CREATE TABLE c(a INTEGER) engine=innodb; +SELECT 1 +FROM a +WHERE 1 IN (SELECT (a.b IS NULL) IN (SELECT 1 FROM c) FROM c) +; +1 +DROP TABLE a, c; +# +# Bug#18194196: OPTIMIZER EXECUTES STATEMENT INPERFORMANT +# +CREATE TABLE t1 (uid INTEGER, fid INTEGER, INDEX(uid)); +INSERT INTO t1 VALUES +(1,1), (1,2), (1,3), (1,4), +(2,5), (2,6), (2,7), (2,8), +(3,1), (3,2), (3,9); +CREATE TABLE t2 (uid INT PRIMARY KEY, name VARCHAR(128), INDEX(name)); +INSERT INTO t2 VALUES +(1, "A"), (2, "B"), (3, "C"), (4, "D"), (5, "E"), +(6, "F"), (7, "G"), (8, "H"), (9, "I"); +CREATE TABLE t3 (uid INT, fid INT, INDEX(uid)); +INSERT INTO t3 VALUES +(1,1), (1,2), (1,3),(1,4), +(2,5), (2,6), (2,7), (2,8), +(3,1), (3,2), (3,9); +CREATE TABLE t4 (uid INT PRIMARY KEY, name VARCHAR(128), INDEX(name)); +INSERT INTO t4 VALUES +(1, "A"), (2, "B"), (3, "C"), (4, "D"), (5, "E"), +(6, "F"), (7, "G"), (8, "H"), (9, "I"); +ANALYZE TABLE t1,t2,t3,t4; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +test.t4 analyze status OK +EXPLAIN SELECT name FROM t2, t1 +WHERE t1.uid IN (SELECT t4.uid FROM t4, t3 WHERE t3.uid=1 AND t4.uid=t3.fid) +AND t2.uid=t1.fid; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ref uid uid 5 const 4 100.00 Using where; Start temporary +1 SIMPLE t4 NULL eq_ref PRIMARY PRIMARY 4 test.t3.fid 1 100.00 Using index +1 SIMPLE t1 NULL ref uid uid 5 test.t3.fid 4 100.00 Using where +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.fid 1 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`name` AS `name` from `test`.`t4` join `test`.`t2` join `test`.`t1` semi join (`test`.`t3`) where ((`test`.`t4`.`uid` = `test`.`t3`.`fid`) and (`test`.`t1`.`uid` = `test`.`t3`.`fid`) and (`test`.`t3`.`uid` = 1) and (`test`.`t2`.`uid` = `test`.`t1`.`fid`)) +FLUSH STATUS; +SELECT name FROM t2, t1 +WHERE t1.uid IN (SELECT t4.uid FROM t4, t3 WHERE t3.uid=1 AND t4.uid=t3.fid) +AND t2.uid=t1.fid; +name +A +A +B +B +C +D +E +F +G +H +I +SHOW STATUS LIKE '%handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 20 +Handler_read_last 0 +Handler_read_next 15 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +DROP TABLE t1,t2,t3,t4; +# End of test for Bug#18194196 +# +# Bug#21184091 ASSERT `READ_ROWS >= 0.0' AT +# COST_MODEL_SERVER::TMPTABLE_READWRITE_COST() +# +CREATE TABLE t1 ( +pk INTEGER, +col_varchar varchar(1), +col_int INTEGER, +PRIMARY KEY (pk) +) ENGINE=MyISAM; +CREATE TABLE t2 ( +col_int INTEGER, +col_varchar varchar(1) +) ENGINE=MyISAM; +INSERT INTO t2 VALUES (7,'x'); +INSERT INTO t2 VALUES (4,'z'); +SELECT t2.col_varchar +FROM t2 STRAIGHT_JOIN t1 ON t2.col_varchar = t1.col_varchar +JOIN t2 AS table3 ON t1.pk = table3.col_int +WHERE t1.pk IN (SELECT col_int FROM t1); +col_varchar +DROP TABLE t1,t2; +# End of test for Bug#21184091 +# Bug#21139722: Assertion failed: !(used_tables() & ((table_map) 1) ... +CREATE TABLE t1(a INTEGER) engine=innodb; +CREATE TABLE t2(b INTEGER) engine=innodb; +explain SELECT 1 +FROM (SELECT 1 IN (SELECT 1 +FROM t1 +WHERE (SELECT 1 FROM t2 HAVING b) NOT IN (SELECT 1 FROM t2) +) +FROM t2 +) AS z; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DERIVED t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +3 DEPENDENT SUBQUERY t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +5 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +4 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1276 Field or reference 'b' of SELECT #4 was resolved in SELECT #2 +Note 1003 /* select#1 */ select 1 AS `1` from (/* select#2 */ select (1,(/* select#3 */ select 1 from `test`.`t1` where ((/* select#4 */ select 1 from `test`.`t2` having (0 <> `test`.`t2`.`b`)),(/* select#5 */ select 1 from `test`.`t2` where (outer_field_is_not_null, (((/* select#4 */ select 1 from `test`.`t2` having (0 <> `test`.`t2`.`b`))) = 1), true)) is false))) AS `1 IN (SELECT 1 +FROM t1 +WHERE (SELECT 1 FROM t2 HAVING b) NOT IN (SELECT 1 FROM t2) +)` from `test`.`t2`) `z` +SELECT 1 +FROM (SELECT 1 IN (SELECT 1 +FROM t1 +WHERE (SELECT 1 FROM t2 HAVING b) NOT IN (SELECT 1 FROM t2) +) +FROM t2 +) AS z; +1 +DROP TABLE t1, t2; +CREATE TABLE t1(a INTEGER) engine=innodb; +explain SELECT (SELECT a FROM t1 AS t2 +WHERE a IN (SELECT t1.a+t2.a FROM t1 AS t3)) +FROM t1 AS t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +2 DEPENDENT SUBQUERY t3 NULL ALL NULL NULL NULL NULL 1 100.00 End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #3 was resolved in SELECT #1 +Note 1276 Field or reference 'test.t2.a' of SELECT #3 was resolved in SELECT #2 +Note 1003 /* select#1 */ select (/* select#2 */ select `test`.`t2`.`a` from `test`.`t1` `t2` semi join (`test`.`t1` `t3`) where (`test`.`t2`.`a` = (`test`.`t1`.`a` + `test`.`t2`.`a`))) AS `(SELECT a FROM t1 AS t2 +WHERE a IN (SELECT t1.a+t2.a FROM t1 AS t3))` from `test`.`t1` +SELECT (SELECT a FROM t1 AS t2 +WHERE a IN (SELECT t1.a+t2.a FROM t1 AS t3)) +FROM t1 AS t1; +(SELECT a FROM t1 AS t2 +WHERE a IN (SELECT t1.a+t2.a FROM t1 AS t3)) +DROP TABLE t1; +# End of test for Bug#21139722 +SET DEFAULT_STORAGE_ENGINE=INNODB; +# +# Bug#21139402 ASSERTION FAILED: LENGTH > 0 && KEYPARTS != 0, CRASH IN JOIN::OPTIMIZE_KEYUSE +# +CREATE TABLE t1 (a INT, b INT, PRIMARY KEY(a)); +CREATE TABLE t2 (c INT PRIMARY KEY); +EXPLAIN SELECT 1 FROM t1 +WHERE 1 IN +(SELECT (c IS NULL) IN (SELECT a FROM t1 WHERE b) FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +3 SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` semi join (`test`.`t2`) where false +SELECT 1 FROM t1 +WHERE 1 IN +(SELECT (c IS NULL) IN (SELECT a FROM t1 WHERE b) FROM t2); +1 +DROP TABLE t1,t2; +# +# Bug#21619634 ACCESS OF DEALLOCATED ITEM_OUTER_REF CAUSES CRASH: PREPARED STMT +# +create table cc (i int) engine="innodb"; +insert into cc values (1); +select (select count(i) from cc as cc_alias +where (cc.i in (select cc_alias.i from cc))) +from cc group by i; +(select count(i) from cc as cc_alias +where (cc.i in (select cc_alias.i from cc))) +1 +prepare stmt from +"select (select count(i) from cc as cc_alias + where (cc.i in (select cc_alias.i from cc))) + from cc group by i"; +execute stmt; +(select count(i) from cc as cc_alias + where (cc.i in (select cc_alias.i from cc))) +1 +execute stmt; +(select count(i) from cc as cc_alias + where (cc.i in (select cc_alias.i from cc))) +1 +drop table cc; +# +# Bug #22305361: QUERY WITH MATERIALIZED TABLE RETURNS INCORRECT +# RESULTS IN 5.6 +# +CREATE TABLE t(a INT,b INT); +INSERT INTO t VALUES (1,0),(1,0),(1,0),(1,0),(1,1); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +EXPLAIN SELECT * +FROM t AS t1 +WHERE t1.a IN (SELECT t2.a +FROM t AS t2 +WHERE CONCAT(t2.a,'') NOT IN (SELECT t3.a +FROM t AS t3 +WHERE t3.b=1)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 5 100.00 Start temporary +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 5 20.00 Using where; End temporary; Using join buffer (hash join) +3 DEPENDENT SUBQUERY t3 NULL ALL NULL NULL NULL NULL 5 20.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t` `t1` semi join (`test`.`t` `t2`) where ((`test`.`t2`.`a` = `test`.`t1`.`a`) and (concat(`test`.`t1`.`a`,''),(/* select#3 */ select `test`.`t3`.`a` from `test`.`t` `t3` where ((`test`.`t3`.`b` = 1) and (outer_field_is_not_null, (((concat(`test`.`t1`.`a`,'')) = `test`.`t3`.`a`) or (`test`.`t3`.`a` is null)), true)) having (outer_field_is_not_null, (`test`.`t3`.`a`), true)) is false)) +SELECT * +FROM t AS t1 +WHERE t1.a IN (SELECT t2.a +FROM t AS t2 +WHERE CONCAT(t2.a,'') NOT IN (SELECT t3.a +FROM t AS t3 +WHERE t3.b=1)); +a b +DROP TABLE t; +# +# Bug#24287772 SUBQUERY RETURNS EMPTY LIST WHILE IDENTICAL QUERY +# WITH JOIN RETURNS RESULT +# +CREATE TABLE t SELECT 4096 c; +SELECT c FROM t WHERE 1 IN +(SELECT t.c = page_size FROM information_schema.innodb_cmpmem); +c +4096 +DROP TABLE t; +# +# Bug #29132639: WL#12470: SIG 6 IN CONNECTJOINS|SQL/SQL_EXECUTOR.C +# +CREATE TABLE t1 ( f1 TIME, f2 VARCHAR(1) ); +INSERT INTO t1 VALUES ('08:35:24', 'X'), ('14:51:13', 'S'), ('11:22:33', 'Q'); +CREATE TABLE t2 ( pk INTEGER ); +INSERT INTO t2 VALUES (1), (2); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN FORMAT=tree SELECT * FROM t1 WHERE EXISTS ( SELECT alias1.f2 FROM t2 LEFT JOIN t1 ON 1 LEFT JOIN t1 AS alias1 ON 1 ); +EXPLAIN +-> Remove duplicate t1 rows using temporary table (weedout) (cost=6.20 rows=54) + -> Left hash join (no condition) (cost=6.20 rows=54) + -> Left hash join (no condition) (cost=2.14 rows=18) + -> Inner hash join (no condition) (cost=1.30 rows=6) + -> Table scan on t1 (cost=0.28 rows=3) + -> Hash + -> Table scan on t2 (cost=0.45 rows=2) + -> Hash + -> Table scan on t1 (cost=0.09 rows=3) + -> Hash + -> Table scan on alias1 (cost=0.55 rows=3) + +SELECT * FROM t1 WHERE EXISTS ( SELECT alias1.f2 FROM t2 LEFT JOIN t1 ON 1 LEFT JOIN t1 AS alias1 ON 1 ); +f1 f2 +08:35:24 X +11:22:33 Q +14:51:13 S +DROP TABLE t1, t2; +set optimizer_switch=default; +set optimizer_switch=default; diff --git a/mysql-test/r/subquery_sj_dupsweed_bka_nobnl.result-pq b/mysql-test/r/subquery_sj_dupsweed_bka_nobnl.result-pq new file mode 100644 index 000000000000..79488c9af697 --- /dev/null +++ b/mysql-test/r/subquery_sj_dupsweed_bka_nobnl.result-pq @@ -0,0 +1,12908 @@ +set optimizer_switch='batched_key_access=on,block_nested_loop=off,mrr_cost_based=off'; +set @old_opt_switch=@@optimizer_switch; +set optimizer_switch='subquery_materialization_cost_based=off'; +drop table if exists t0, t1, t2, t10, t11, t12; +create table t1 (a int not null, b int, primary key (a)); +create table t2 (a int not null, primary key (a)); +create table t3 (a int not null, b int, primary key (a)); +insert into t1 values (1,10), (2,20), (3,30), (4,40); +insert into t2 values (2), (3), (4), (5); +insert into t3 values (10,3), (20,4), (30,5); +select * from t2 where t2.a in (select a from t1); +a +2 +3 +4 +explain select * from t2 where t2.a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index PRIMARY PRIMARY 4 NULL 4 100.00 Using index +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t1` join `test`.`t2` where (`test`.`t1`.`a` = `test`.`t2`.`a`) +select * from t2 where t2.a in (select a from t1 where t1.b <> 30); +a +2 +4 +explain select * from t2 where t2.a in (select a from t1 where t1.b <> 30); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL PRIMARY NULL NULL NULL 4 75.00 Using where +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`a` = `test`.`t1`.`a`) and (`test`.`t1`.`b` <> 30)) +select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a); +a +2 +3 +explain select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index PRIMARY PRIMARY 4 NULL 4 100.00 Using index +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.a 1 100.00 Using where +1 SIMPLE t3 NULL eq_ref PRIMARY PRIMARY 4 test.t1.b 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t1` join `test`.`t3` join `test`.`t2` where ((`test`.`t1`.`a` = `test`.`t2`.`a`) and (`test`.`t3`.`a` = `test`.`t1`.`b`)) +drop table t1, t2, t3; +create table t1 (a int, b int, index a (a,b)); +create table t2 (a int, index a (a)); +create table t3 (a int, b int, index a (a)); +insert into t1 values (1,10), (2,20), (3,30), (4,40); +create table t0(a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +insert into t1 +select rand()*100000+200,rand()*100000 from t0 A, t0 B, t0 C, t0 D; +insert into t2 values (2), (3), (4), (5); +insert into t3 values (10,3), (20,4), (30,5); +select * from t2 where t2.a in (select a from t1); +a +2 +3 +4 +explain select * from t2 where t2.a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index a a 5 NULL 4 100.00 Using where; Using index +1 SIMPLE t1 NULL ref a a 5 test.t2.a 101 100.00 Using index; Start temporary; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1`) where (`test`.`t1`.`a` = `test`.`t2`.`a`) +select * from t2 where t2.a in (select a from t1 where t1.b <> 30); +a +2 +4 +explain select * from t2 where t2.a in (select a from t1 where t1.b <> 30); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index a a 5 NULL 4 100.00 Using where; Using index +1 SIMPLE t1 NULL ref a a 5 test.t2.a 101 90.00 Using where; Using index; Start temporary; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1`) where ((`test`.`t1`.`a` = `test`.`t2`.`a`) and (`test`.`t1`.`b` <> 30)) +select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a); +a +2 +3 +explain select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL index a a 5 NULL 3 100.00 Using where; Using index; Start temporary +1 SIMPLE t2 NULL index a a 5 NULL 4 100.00 Using where; Using index +1 SIMPLE t1 NULL ref a a 10 test.t2.a,test.t3.a 116 100.00 Using index; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1` join `test`.`t3`) where ((`test`.`t1`.`a` = `test`.`t2`.`a`) and (`test`.`t1`.`b` = `test`.`t3`.`a`)) +insert into t1 values (3,31); +select * from t2 where t2.a in (select a from t1 where t1.b <> 30); +a +2 +3 +4 +select * from t2 where t2.a in (select a from t1 where t1.b <> 30 and t1.b <> 31); +a +2 +4 +explain select * from t2 where t2.a in (select a from t1 where t1.b <> 30); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index a a 5 NULL 4 100.00 Using where; Using index +1 SIMPLE t1 NULL ref a a 5 test.t2.a 101 90.00 Using where; Using index; Start temporary; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1`) where ((`test`.`t1`.`a` = `test`.`t2`.`a`) and (`test`.`t1`.`b` <> 30)) +drop table t0, t1, t2, t3; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1(a int, b int); +insert into t1 values (0,0),(1,1),(2,2); +create table t2 as select * from t1; +create table t11(a int, b int); +create table t10 (pk int, a int, primary key(pk)); +insert into t10 select a,a from t0; +create table t12 like t10; +insert into t12 select * from t10; +Flattened because of dependency, t10=func(t1) +explain select * from t1 where a in (select pk from t10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t1` where (`test`.`t10`.`pk` = `test`.`t1`.`a`) +select * from t1 where a in (select pk from t10); +a b +0 0 +1 1 +2 2 +A confluent case of dependency +explain select * from t1 where a in (select a from t10 where pk=12); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t1` where (multiple equal(12, NULL) and multiple equal(`test`.`t1`.`a`, NULL)) +select * from t1 where a in (select a from t10 where pk=12); +a b +explain select * from t1 where a in (select a from t10 where pk=9); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t10 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t1` where ((`test`.`t1`.`a` = '9')) +select * from t1 where a in (select a from t10 where pk=9); +a b +An empty table inside +explain select * from t1 where a in (select a from t11); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t11 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t11`) where (`test`.`t1`.`a` = `test`.`t11`.`a`) +select * from t1 where a in (select a from t11); +a b +explain select * from t1 where a in (select pk from t10) and b in (select pk from t10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using index +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.t1.b 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t10` join `test`.`t1` where ((`test`.`t10`.`pk` = `test`.`t1`.`b`) and (`test`.`t10`.`pk` = `test`.`t1`.`a`)) +select * from t1 where a in (select pk from t10) and b in (select pk from t10); +a b +0 0 +1 1 +2 2 +flattening a nested subquery +explain select * from t1 where a in (select pk from t10 where t10.a in (select pk from t12)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using where +1 SIMPLE t12 NULL eq_ref PRIMARY PRIMARY 4 test.t10.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t12` join `test`.`t1` where ((`test`.`t10`.`pk` = `test`.`t1`.`a`) and (`test`.`t12`.`pk` = `test`.`t10`.`a`)) +select * from t1 where a in (select pk from t10 where t10.a in (select pk from t12)); +a b +0 0 +1 1 +2 2 +flattening subquery w/ several tables +explain select * from t1 where a in (select t10.pk from t10, t12 where t12.pk=t10.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using where +1 SIMPLE t12 NULL eq_ref PRIMARY PRIMARY 4 test.t10.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t12` join `test`.`t1` where ((`test`.`t10`.`pk` = `test`.`t1`.`a`) and (`test`.`t12`.`pk` = `test`.`t10`.`a`)) +subqueries within outer joins go into ON expr. +explain +select * from t1 left join (t2 A, t2 B) on ( A.A= t1.A and B.A in (select pk from t10)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE A NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE B NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.B.A 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`A` AS `A`,`test`.`t1`.`B` AS `B`,`test`.`A`.`A` AS `A`,`test`.`A`.`B` AS `B`,`test`.`B`.`A` AS `A`,`test`.`B`.`B` AS `B` from `test`.`t1` left join (`test`.`t10` join `test`.`t2` `A` join `test`.`t2` `B`) on(((`test`.`t10`.`pk` = `test`.`B`.`A`) and (`test`.`A`.`A` = `test`.`t1`.`A`))) where true +t2 should be wrapped into OJ-nest, so we have "t1 LJ (t2 J t10)" +explain +select * from t1 left join t2 on (t2.A= t1.A and t2.A in (select pk from t10)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.t1.A 1 100.00 Using index +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`A` AS `A`,`test`.`t1`.`B` AS `B`,`test`.`t2`.`A` AS `A`,`test`.`t2`.`B` AS `B` from `test`.`t1` left join (`test`.`t10` join `test`.`t2`) on(((`test`.`t10`.`pk` = `test`.`t1`.`A`) and (`test`.`t2`.`A` = `test`.`t1`.`A`))) where true +we shouldn't flatten if we're going to get a join of > MAX_TABLES. +explain select * from +t1 s00, t1 s01, t1 s02, t1 s03, t1 s04,t1 s05,t1 s06,t1 s07,t1 s08,t1 s09, +t1 s10, t1 s11, t1 s12, t1 s13, t1 s14,t1 s15,t1 s16,t1 s17,t1 s18,t1 s19, +t1 s20, t1 s21, t1 s22, t1 s23, t1 s24,t1 s25,t1 s26,t1 s27,t1 s28,t1 s29, +t1 s30, t1 s31, t1 s32, t1 s33, t1 s34,t1 s35,t1 s36,t1 s37,t1 s38,t1 s39, +t1 s40, t1 s41, t1 s42, t1 s43, t1 s44,t1 s45,t1 s46,t1 s47,t1 s48,t1 s49 +where +s00.a in ( +select m00.a from +t1 m00, t1 m01, t1 m02, t1 m03, t1 m04,t1 m05,t1 m06,t1 m07,t1 m08,t1 m09, +t1 m10, t1 m11, t1 m12, t1 m13, t1 m14,t1 m15,t1 m16,t1 m17,t1 m18,t1 m19 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY s00 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 PRIMARY s01 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s02 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s03 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s04 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s05 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s06 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s07 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s08 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s09 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s10 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s11 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s12 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s13 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s14 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s15 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s16 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s17 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s18 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s19 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s20 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s21 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s22 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s23 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s24 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s25 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s26 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s27 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s28 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s29 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s30 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s31 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s32 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s33 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s34 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s35 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s36 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s37 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s38 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s39 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s40 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s41 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s42 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s43 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s44 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s45 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s46 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s47 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s48 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s49 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 DEPENDENT SUBQUERY m00 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +2 DEPENDENT SUBQUERY m01 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 DEPENDENT SUBQUERY m02 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 DEPENDENT SUBQUERY m03 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 DEPENDENT SUBQUERY m04 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 DEPENDENT SUBQUERY m05 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 DEPENDENT SUBQUERY m06 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 DEPENDENT SUBQUERY m07 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 DEPENDENT SUBQUERY m08 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 DEPENDENT SUBQUERY m09 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 DEPENDENT SUBQUERY m10 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 DEPENDENT SUBQUERY m11 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 DEPENDENT SUBQUERY m12 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 DEPENDENT SUBQUERY m13 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 DEPENDENT SUBQUERY m14 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 DEPENDENT SUBQUERY m15 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 DEPENDENT SUBQUERY m16 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 DEPENDENT SUBQUERY m17 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 DEPENDENT SUBQUERY m18 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 DEPENDENT SUBQUERY m19 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`s00`.`a` AS `a`,`test`.`s00`.`b` AS `b`,`test`.`s01`.`a` AS `a`,`test`.`s01`.`b` AS `b`,`test`.`s02`.`a` AS `a`,`test`.`s02`.`b` AS `b`,`test`.`s03`.`a` AS `a`,`test`.`s03`.`b` AS `b`,`test`.`s04`.`a` AS `a`,`test`.`s04`.`b` AS `b`,`test`.`s05`.`a` AS `a`,`test`.`s05`.`b` AS `b`,`test`.`s06`.`a` AS `a`,`test`.`s06`.`b` AS `b`,`test`.`s07`.`a` AS `a`,`test`.`s07`.`b` AS `b`,`test`.`s08`.`a` AS `a`,`test`.`s08`.`b` AS `b`,`test`.`s09`.`a` AS `a`,`test`.`s09`.`b` AS `b`,`test`.`s10`.`a` AS `a`,`test`.`s10`.`b` AS `b`,`test`.`s11`.`a` AS `a`,`test`.`s11`.`b` AS `b`,`test`.`s12`.`a` AS `a`,`test`.`s12`.`b` AS `b`,`test`.`s13`.`a` AS `a`,`test`.`s13`.`b` AS `b`,`test`.`s14`.`a` AS `a`,`test`.`s14`.`b` AS `b`,`test`.`s15`.`a` AS `a`,`test`.`s15`.`b` AS `b`,`test`.`s16`.`a` AS `a`,`test`.`s16`.`b` AS `b`,`test`.`s17`.`a` AS `a`,`test`.`s17`.`b` AS `b`,`test`.`s18`.`a` AS `a`,`test`.`s18`.`b` AS `b`,`test`.`s19`.`a` AS `a`,`test`.`s19`.`b` AS `b`,`test`.`s20`.`a` AS `a`,`test`.`s20`.`b` AS `b`,`test`.`s21`.`a` AS `a`,`test`.`s21`.`b` AS `b`,`test`.`s22`.`a` AS `a`,`test`.`s22`.`b` AS `b`,`test`.`s23`.`a` AS `a`,`test`.`s23`.`b` AS `b`,`test`.`s24`.`a` AS `a`,`test`.`s24`.`b` AS `b`,`test`.`s25`.`a` AS `a`,`test`.`s25`.`b` AS `b`,`test`.`s26`.`a` AS `a`,`test`.`s26`.`b` AS `b`,`test`.`s27`.`a` AS `a`,`test`.`s27`.`b` AS `b`,`test`.`s28`.`a` AS `a`,`test`.`s28`.`b` AS `b`,`test`.`s29`.`a` AS `a`,`test`.`s29`.`b` AS `b`,`test`.`s30`.`a` AS `a`,`test`.`s30`.`b` AS `b`,`test`.`s31`.`a` AS `a`,`test`.`s31`.`b` AS `b`,`test`.`s32`.`a` AS `a`,`test`.`s32`.`b` AS `b`,`test`.`s33`.`a` AS `a`,`test`.`s33`.`b` AS `b`,`test`.`s34`.`a` AS `a`,`test`.`s34`.`b` AS `b`,`test`.`s35`.`a` AS `a`,`test`.`s35`.`b` AS `b`,`test`.`s36`.`a` AS `a`,`test`.`s36`.`b` AS `b`,`test`.`s37`.`a` AS `a`,`test`.`s37`.`b` AS `b`,`test`.`s38`.`a` AS `a`,`test`.`s38`.`b` AS `b`,`test`.`s39`.`a` AS `a`,`test`.`s39`.`b` AS `b`,`test`.`s40`.`a` AS `a`,`test`.`s40`.`b` AS `b`,`test`.`s41`.`a` AS `a`,`test`.`s41`.`b` AS `b`,`test`.`s42`.`a` AS `a`,`test`.`s42`.`b` AS `b`,`test`.`s43`.`a` AS `a`,`test`.`s43`.`b` AS `b`,`test`.`s44`.`a` AS `a`,`test`.`s44`.`b` AS `b`,`test`.`s45`.`a` AS `a`,`test`.`s45`.`b` AS `b`,`test`.`s46`.`a` AS `a`,`test`.`s46`.`b` AS `b`,`test`.`s47`.`a` AS `a`,`test`.`s47`.`b` AS `b`,`test`.`s48`.`a` AS `a`,`test`.`s48`.`b` AS `b`,`test`.`s49`.`a` AS `a`,`test`.`s49`.`b` AS `b` from `test`.`t1` `s00` join `test`.`t1` `s01` join `test`.`t1` `s02` join `test`.`t1` `s03` join `test`.`t1` `s04` join `test`.`t1` `s05` join `test`.`t1` `s06` join `test`.`t1` `s07` join `test`.`t1` `s08` join `test`.`t1` `s09` join `test`.`t1` `s10` join `test`.`t1` `s11` join `test`.`t1` `s12` join `test`.`t1` `s13` join `test`.`t1` `s14` join `test`.`t1` `s15` join `test`.`t1` `s16` join `test`.`t1` `s17` join `test`.`t1` `s18` join `test`.`t1` `s19` join `test`.`t1` `s20` join `test`.`t1` `s21` join `test`.`t1` `s22` join `test`.`t1` `s23` join `test`.`t1` `s24` join `test`.`t1` `s25` join `test`.`t1` `s26` join `test`.`t1` `s27` join `test`.`t1` `s28` join `test`.`t1` `s29` join `test`.`t1` `s30` join `test`.`t1` `s31` join `test`.`t1` `s32` join `test`.`t1` `s33` join `test`.`t1` `s34` join `test`.`t1` `s35` join `test`.`t1` `s36` join `test`.`t1` `s37` join `test`.`t1` `s38` join `test`.`t1` `s39` join `test`.`t1` `s40` join `test`.`t1` `s41` join `test`.`t1` `s42` join `test`.`t1` `s43` join `test`.`t1` `s44` join `test`.`t1` `s45` join `test`.`t1` `s46` join `test`.`t1` `s47` join `test`.`t1` `s48` join `test`.`t1` `s49` where (`test`.`s00`.`a`,(/* select#2 */ select `test`.`m00`.`a` from `test`.`t1` `m00` join `test`.`t1` `m01` join `test`.`t1` `m02` join `test`.`t1` `m03` join `test`.`t1` `m04` join `test`.`t1` `m05` join `test`.`t1` `m06` join `test`.`t1` `m07` join `test`.`t1` `m08` join `test`.`t1` `m09` join `test`.`t1` `m10` join `test`.`t1` `m11` join `test`.`t1` `m12` join `test`.`t1` `m13` join `test`.`t1` `m14` join `test`.`t1` `m15` join `test`.`t1` `m16` join `test`.`t1` `m17` join `test`.`t1` `m18` join `test`.`t1` `m19` where ((`test`.`s00`.`a`) = `test`.`m00`.`a`))) +select * from +t1 left join t2 on (t2.a= t1.a and t2.a in (select pk from t10)) +where t1.a < 5; +a b a b +0 0 0 0 +1 1 1 1 +2 2 2 2 +prepare s1 from +' select * from + t1 left join t2 on (t2.a= t1.a and t2.a in (select pk from t10)) + where t1.a < 5'; +execute s1; +a b a b +0 0 0 0 +1 1 1 1 +2 2 2 2 +execute s1; +a b a b +0 0 0 0 +1 1 1 1 +2 2 2 2 +insert into t1 select (A.a + 10 * B.a),1 from t0 A, t0 B; +explain select * from t1 where a in (select pk from t10 where pk<3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t10 NULL range PRIMARY PRIMARY 4 NULL 4 100.00 Using where; Using index +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 103 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t1` where ((`test`.`t1`.`a` = `test`.`t10`.`pk`) and (`test`.`t10`.`pk` < 3)) +drop table t0, t1, t2; +drop table t10, t11, t12; +# +# Check that subqueries with outer joins or straight_join work for +# different permutations of const and non-const tables. (Ref. Bug#46692) +# +CREATE TABLE t1 (i INTEGER); +CREATE TABLE t2 (i INTEGER); +CREATE TABLE t3 (i INTEGER); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 0 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 0 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 0 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 1 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 1 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 1 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 2 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 2 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 2 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (0); +DELETE FROM t2; +INSERT INTO t1 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 0 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 0 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 0 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 1 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 1 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 1 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 2 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 2 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 2 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (0); +DELETE FROM t2; +INSERT INTO t1 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 0 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = `test`.`t2`.`i`) and (`test`.`t1`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = `test`.`t2`.`i`) and (`test`.`t1`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = `test`.`t2`.`i`) and (`test`.`t1`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 0 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = `test`.`t2`.`i`) and (`test`.`t1`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = `test`.`t2`.`i`) and (`test`.`t1`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = `test`.`t2`.`i`) and (`test`.`t1`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 0 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t2`.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t2`.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t2`.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = `test`.`t1`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +1 +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = `test`.`t1`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 1 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = `test`.`t3`.`i`) and (`test`.`t1`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = `test`.`t3`.`i`) and (`test`.`t1`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = `test`.`t3`.`i`) and (`test`.`t1`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 1 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = `test`.`t2`.`i`) and (`test`.`t1`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = `test`.`t2`.`i`) and (`test`.`t1`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = `test`.`t2`.`i`) and (`test`.`t1`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 1 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t2`.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t2`.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t2`.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = `test`.`t1`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +1 +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = `test`.`t1`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +1 +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 2 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t3`.`i`) and (`test`.`t2`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t3`.`i`) and (`test`.`t2`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t3`.`i`) and (`test`.`t2`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = `test`.`t1`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 2 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t3`.`i`) and (`test`.`t2`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t3`.`i`) and (`test`.`t2`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t3`.`i`) and (`test`.`t2`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = `test`.`t1`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 2 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = `test`.`t1`.`i`) and (`test`.`t3`.`i` = `test`.`t1`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +1 +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +1 +2 + +EXECUTE stmt; +i +1 +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = `test`.`t1`.`i`) and (`test`.`t3`.`i` = `test`.`t1`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +1 +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = `test`.`t1`.`i`) and (`test`.`t3`.`i` = `test`.`t1`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +1 +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +1 +2 + +EXECUTE stmt; +i +1 +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = `test`.`t1`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +1 +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = `test`.`t1`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +1 +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (0); +DELETE FROM t2; +INSERT INTO t1 VALUES (0); +DROP TABLE t1, t2, t3; +create table x1(k int primary key, d1 int, d2 int); +create table x2(k int primary key, d1 int, d2 int); +insert into x1 values +(10, 10, 10), +(20, 20, 20), +(21, 20, null), +(30, null, 30), +(40, 40, 40); +insert into x2 values +(10, 10, 10), +(20, 20, 20), +(21, 20, null), +(30, null, 30); +select * +from x1 +where (d1, d2) in (select d1, d2 +from x2); +k d1 d2 +10 10 10 +20 20 20 +select * +from x1 +where (d1, d2) in (select d1, d2 +from x2) is true; +k d1 d2 +10 10 10 +20 20 20 +select * +from x1 +where (d1, d2) in (select d1, d2 +from x2) is false; +k d1 d2 +40 40 40 +select * +from x1 +where (d1, d2) in (select d1, d2 +from x2) is unknown; +k d1 d2 +21 20 NULL +30 NULL 30 +select * +from x1 +where d1 in (select d1 +from x2 +where x1.d2=x2.d2); +k d1 d2 +10 10 10 +20 20 20 +select * +from x1 +where d1 in (select d1 +from x2 +where x1.d2=x2.d2) is true; +k d1 d2 +10 10 10 +20 20 20 +select * +from x1 +where d1 in (select d1 +from x2 +where x1.d2=x2.d2) is false; +k d1 d2 +21 20 NULL +40 40 40 +select * +from x1 +where d1 in (select d1 +from x2 +where x1.d2=x2.d2) is unknown; +k d1 d2 +30 NULL 30 +select * +from x1 +where 1 in (select 1 +from x2 +where x1.d1=x2.d1 and x1.d2=x2.d2); +k d1 d2 +10 10 10 +20 20 20 +select * +from x1 +where 1 in (select 1 +from x2 +where x1.d1=x2.d1 and x1.d2=x2.d2) is true; +k d1 d2 +10 10 10 +20 20 20 +select * +from x1 +where 1 in (select 1 +from x2 +where x1.d1=x2.d1 and x1.d2=x2.d2) is false; +k d1 d2 +21 20 NULL +30 NULL 30 +40 40 40 +select * +from x1 +where 1 in (select 1 +from x2 +where x1.d1=x2.d1 and x1.d2=x2.d2) is unknown; +k d1 d2 +select * +from x1 +where exists (select * +from x2 +where x1.d1=x2.d1 and x1.d2=x2.d2); +k d1 d2 +10 10 10 +20 20 20 +drop table x1; +drop table x2; +CREATE TABLE t1 ( +a int(11) NOT NULL, +b int(11) NOT NULL, +c datetime default NULL, +PRIMARY KEY (a), +KEY idx_bc (b,c) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES +(406989,67,'2006-02-23 17:08:46'), (150078,67,'2005-10-26 11:17:45'), +(406993,67,'2006-02-27 11:20:57'), (245655,67,'2005-12-08 15:59:08'), +(406994,67,'2006-02-27 11:26:46'), (256,67,NULL), +(398341,67,'2006-02-20 04:48:44'), (254,67,NULL),(1120,67,NULL), +(406988,67,'2006-02-23 17:07:22'), (255,67,NULL), +(398340,67,'2006-02-20 04:38:53'),(406631,67,'2006-02-23 10:49:42'), +(245653,67,'2005-12-08 15:59:07'),(406992,67,'2006-02-24 16:47:18'), +(245654,67,'2005-12-08 15:59:08'),(406995,67,'2006-02-28 11:55:00'), +(127261,67,'2005-10-13 12:17:58'),(406991,67,'2006-02-24 16:42:32'), +(245652,67,'2005-12-08 15:58:27'),(398545,67,'2006-02-20 04:53:13'), +(154504,67,'2005-10-28 11:53:01'),(9199,67,NULL),(1,67,'2006-02-23 15:01:35'), +(223456,67,NULL),(4101,67,NULL),(1133,67,NULL), +(406990,67,'2006-02-23 18:01:45'),(148815,67,'2005-10-25 15:34:17'), +(148812,67,'2005-10-25 15:30:01'),(245651,67,'2005-12-08 15:58:27'), +(154503,67,'2005-10-28 11:52:38'); +create table t11 select * from t1 where b = 67 AND (c IS NULL OR c > NOW()) order by 3 asc; +create table t12 select * from t1 where b = 67 AND (c IS NULL OR c > NOW()) order by 3 desc; +create table t21 select * from t1 where b = 67 AND (c IS NULL OR c > '2005-12-08') order by 3 asc; +create table t22 select * from t1 where b = 67 AND (c IS NULL OR c > '2005-12-08') order by 3 desc; +update t22 set c = '2005-12-08 15:58:27' where a = 255; +explain select t21.* from t21,t22 where t21.a = t22.a and +t22.a in (select t12.a from t11, t12 where t11.a in(255,256) and t11.a = t12.a and t11.c is null) and t22.c is null order by t21.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t11 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; Using temporary; Using filesort; Start temporary +1 SIMPLE t12 NULL ALL NULL NULL NULL NULL 8 12.50 Using where +1 SIMPLE t22 NULL ALL NULL NULL NULL NULL 26 3.85 Using where; End temporary +1 SIMPLE t21 NULL ALL NULL NULL NULL NULL 26 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t21`.`a` AS `a`,`test`.`t21`.`b` AS `b`,`test`.`t21`.`c` AS `c` from `test`.`t21` join `test`.`t22` semi join (`test`.`t11` join `test`.`t12`) where ((`test`.`t12`.`a` = `test`.`t11`.`a`) and (`test`.`t22`.`a` = `test`.`t11`.`a`) and (`test`.`t21`.`a` = `test`.`t11`.`a`) and (`test`.`t22`.`c` is null) and (`test`.`t11`.`a` in (255,256)) and (`test`.`t11`.`c` is null)) order by `test`.`t21`.`a` +explain format=json select * from t1 where a in (select a from t11); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "6.71" + }, + "duplicates_removal": { + "using_temporary_table": true, + "nested_loop": [ + { + "table": { + "table_name": "t11", + "access_type": "ALL", + "rows_examined_per_scan": 8, + "rows_produced_per_join": 8, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "0.80", + "prefix_cost": "1.31", + "data_read_per_join": "128" + }, + "used_columns": [ + "a" + ] + } + }, + { + "table": { + "table_name": "t1", + "access_type": "eq_ref", + "possible_keys": [ + "PRIMARY" + ], + "key": "PRIMARY", + "used_key_parts": [ + "a" + ], + "key_length": "4", + "ref": [ + "test.t11.a" + ], + "rows_examined_per_scan": 1, + "rows_produced_per_join": 8, + "filtered": "100.00", + "cost_info": { + "read_cost": "2.00", + "eval_cost": "0.80", + "prefix_cost": "6.71", + "data_read_per_join": "128" + }, + "used_columns": [ + "a", + "b", + "c" + ] + } + } + ] + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` semi join (`test`.`t11`) where (`test`.`t1`.`a` = `test`.`t11`.`a`) +select t21.* from t21,t22 where t21.a = t22.a and +t22.a in (select t12.a from t11, t12 where t11.a in(255,256) and t11.a = t12.a and t11.c is null) and t22.c is null order by t21.a; +a b c +256 67 NULL +drop table t1, t11, t12, t21, t22; +create table t1(a int); +insert into t1 values (0),(1); +explain +select (select max(y.a) from t1 y where a in (select a from t1 z) and a < x.a) as subq from t1 x; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY x NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DEPENDENT SUBQUERY y NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 DEPENDENT SUBQUERY z NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary; End temporary +Warnings: +Note 1276 Field or reference 'test.x.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select (/* select#2 */ select max(`test`.`y`.`a`) from `test`.`t1` `y` semi join (`test`.`t1` `z`) where ((`test`.`z`.`a` = `test`.`y`.`a`) and (`test`.`y`.`a` < `test`.`x`.`a`))) AS `subq` from `test`.`t1` `x` +select (select max(y.a) from t1 y where a in (select a from t1 z) and a < x.a) as subq from t1 x; +subq +NULL +0 +drop table t1; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 as select * from t0; +insert into t1 select a+10 from t0; +insert into t0 values(2); +explain select * from t1 where 2 in (select a from t0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 11 10.00 Using where; Start temporary; End temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 20 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t0`) where (`test`.`t0`.`a` = 2) +select * from t1 where 2 in (select a from t0); +a +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +explain select * from (select a from t0) x where a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 11 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 20 10.00 Using where; Start temporary; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a` from `test`.`t0` semi join (`test`.`t1`) where (`test`.`t1`.`a` = `test`.`t0`.`a`) +explain format=json select * from (select a from t0) x where a in (select a from t1); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "33.50" + }, + "nested_loop": [ + { + "table": { + "table_name": "t0", + "access_type": "ALL", + "rows_examined_per_scan": 11, + "rows_produced_per_join": 11, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "1.10", + "prefix_cost": "1.60", + "data_read_per_join": "88" + }, + "used_columns": [ + "a" + ] + } + }, + { + "duplicates_removal": { + "using_temporary_table": true, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 11, + "filtered": "10.00", + "cost_info": { + "read_cost": "5.59", + "eval_cost": "1.10", + "prefix_cost": "33.50", + "data_read_per_join": "88" + }, + "used_columns": [ + "a" + ], + "attached_condition": "(`test`.`t1`.`a` = `test`.`t0`.`a`)" + } + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a` from `test`.`t0` semi join (`test`.`t1`) where (`test`.`t1`.`a` = `test`.`t0`.`a`) +drop table t0, t1; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (kp1 int, kp2 int, c int, filler char(100), key(kp1, kp2)); +insert into t1 select A.a+10*(B.a+10*C.a), 0, 0, 'filler' from t0 A, t0 B, t0 C; +insert into t1 select * from t1 where kp1 < 20; +create table t3 (a int); +insert into t3 select A.a + 10*B.a from t0 A, t0 B; +explain select * from t3 where a in (select kp1 from t1 where kp1<20); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 100 100.00 Using where +1 SIMPLE t1 NULL ref kp1 kp1 5 test.t3.a 1 100.00 Using index; Start temporary; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a` from `test`.`t3` semi join (`test`.`t1`) where ((`test`.`t1`.`kp1` = `test`.`t3`.`a`) and (`test`.`t3`.`a` < 20)) +select * from t3 where a in (select kp1 from t1 where kp1<20); +a +0 +1 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +2 +3 +4 +5 +6 +7 +8 +9 +explain select * from t3 where a in (select kp1 from t1 where kp1<20) and a<20; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 100 33.33 Using where +1 SIMPLE t1 NULL ref kp1 kp1 5 test.t3.a 1 100.00 Using index; Start temporary; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a` from `test`.`t3` semi join (`test`.`t1`) where ((`test`.`t1`.`kp1` = `test`.`t3`.`a`) and (`test`.`t3`.`a` < 20) and (`test`.`t3`.`a` < 20)) +select * from t3 where a in (select kp1 from t1 where kp1<20) and a<20; +a +0 +1 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +2 +3 +4 +5 +6 +7 +8 +9 +create table t4 (pk int primary key); +insert into t4 select a from t3; +explain select * from t3 where a in +(select t1.kp1 from t1,t4 where kp1<20 and t4.pk=t1.c); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 100 100.00 Using where +1 SIMPLE t1 NULL ref kp1 kp1 5 test.t3.a 1 100.00 Using where; Start temporary +1 SIMPLE t4 NULL eq_ref PRIMARY PRIMARY 4 test.t1.c 1 100.00 Using index; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a` from `test`.`t3` semi join (`test`.`t1` join `test`.`t4`) where ((`test`.`t1`.`kp1` = `test`.`t3`.`a`) and (`test`.`t4`.`pk` = `test`.`t1`.`c`) and (`test`.`t3`.`a` < 20)) +explain format=tree select * from t3 where a in +(select t1.kp1 from t1,t4 where kp1<20 and t4.pk=t1.c); +EXPLAIN +-> Nested loop inner join (cost=45.54 rows=100) + -> Filter: ((t3.a < 20) and (t3.a is not null)) (cost=10.54 rows=100) + -> Table scan on t3 (cost=10.54 rows=100) + -> Limit: 1 row(s) (cost=25.35 rows=1) + -> Nested loop inner join (cost=25.35 rows=1) + -> Filter: (t1.c is not null) (cost=0.25 rows=1) + -> Index lookup on t1 using kp1 (kp1=t3.a) (cost=0.25 rows=1) + -> Single-row index lookup on t4 using PRIMARY (pk=t1.c) (cost=0.25 rows=1) + +select * from t3 where a in +(select t1.kp1 from t1,t4 where kp1<20 and t4.pk=t1.c); +a +0 +1 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +2 +3 +4 +5 +6 +7 +8 +9 +drop table t1, t3, t4; +create table t1 (a int); +insert into t1 values (0),(0),(0),(1),(1),(1),(2),(2),(2),(3),(3),(3); +set session internal_tmp_mem_storage_engine='memory'; +set @save_max_heap_table_size=@@max_heap_table_size; +set @@max_heap_table_size= 16384; +# Attempt to make one test that overflows the heap table when a +# non-duplicate row is inserted and one test that overflows the +# heap table when a duplicate record is inserted. Debugging showed +# that these situations occurred with max_heap_table_size=16384 +# and optimizer_join_cache_level equals 1 and 0, respectively. +# Finally execute a test that does not overflow the heap table. +explain +select count(*) from t0 a, t0 b, t0 c +where c.a in (select a from t1 d); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE a NULL ALL NULL NULL NULL NULL 10 100.00 NULL +1 SIMPLE b NULL ALL NULL NULL NULL NULL 10 100.00 NULL +1 SIMPLE c NULL ALL NULL NULL NULL NULL 10 100.00 NULL +1 SIMPLE d NULL ALL NULL NULL NULL NULL 12 10.00 Using where; Start temporary; End temporary +Warnings: +Note 1003 /* select#1 */ select count(0) AS `count(*)` from `test`.`t0` `a` join `test`.`t0` `b` join `test`.`t0` `c` semi join (`test`.`t1` `d`) where (`test`.`d`.`a` = `test`.`c`.`a`) +flush status; +select count(*) from t0 a, t0 b, t0 c +where c.a in (select a from t1 d); +count(*) +400 +show status like 'Created_tmp_disk_tables'; +Variable_name Value +Created_tmp_disk_tables 0 +set @@max_heap_table_size= @save_max_heap_table_size; +set session internal_tmp_mem_storage_engine=default; +flush status; +select count(*) from t0 a, t0 b, t0 c +where c.a in (select a from t1 d); +count(*) +400 +show status like 'Created_tmp_disk_tables'; +Variable_name Value +Created_tmp_disk_tables 0 +drop table t0, t1; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t2(a int); +insert into t2 values (1),(2); +create table t3 ( a int , filler char(100), key(a)); +insert into t3 select A.a + 10*B.a, 'filler' from t0 A, t0 B; +explain select * from t3 where a in (select a from t2) and (a > 5 or a < 10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ref a a 5 test.t2.a 1 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a`,`test`.`t3`.`filler` AS `filler` from `test`.`t3` semi join (`test`.`t2`) where ((`test`.`t3`.`a` = `test`.`t2`.`a`) and ((`test`.`t2`.`a` > 5) or (`test`.`t2`.`a` < 10))) +select * from t3 where a in (select a from t2); +a filler +1 filler +2 filler +drop table t0, t2, t3; +create table t1 (a date); +insert into t1 values ('2008-01-01'),('2008-01-01'),('2008-02-01'),('2008-02-01'); +create table t2 (a int); +insert into t2 values (1),(2); +create table t3 (a char(10)); +insert into t3 select * from t1; +insert into t3 values (1),(2); +explain select * from t2 where a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; Start temporary; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1`) where (cast(`test`.`t2`.`a` as double) = cast(`test`.`t1`.`a` as double)) +explain select * from t2 where a in (select a from t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t2`) where (`test`.`t2`.`a` = `test`.`t2`.`a`) +explain select * from t2 where a in (select a from t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Start temporary; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t3`) where (cast(`test`.`t2`.`a` as double) = cast(`test`.`t3`.`a` as double)) +explain select * from t1 where a in (select a from t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Start temporary; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t3`) where (`test`.`t1`.`a` = cast(`test`.`t3`.`a` as date)) +drop table t1, t2, t3; +create table t1 (a decimal); +insert into t1 values (1),(2); +explain select * from t1 where a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t1`) where (`test`.`t1`.`a` = `test`.`t1`.`a`) +drop table t1; +create table t1 (a int); +insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t2 as select * from t1; +create table t3 (a int, b int, filler char(100), key(a)) charset utf8mb4; +insert into t3 select A.a + 10*B.a, A.a + 10*B.a, 'filler' from t1 A, t1 B, t1 C; +explain select * from t1, t3 where t3.a in (select a from t2) and (t3.a < 10 or t3.a >30) and t1.a =3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 10.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 10 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ref a a 5 test.t2.a 10 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t3`.`filler` AS `filler` from `test`.`t1` join `test`.`t3` semi join (`test`.`t2`) where ((`test`.`t3`.`a` = `test`.`t2`.`a`) and (`test`.`t1`.`a` = 3) and ((`test`.`t2`.`a` < 10) or (`test`.`t2`.`a` > 30))) +explain format=json select * from t1, t3 where t3.a in (select a from t2) and (t3.a < 10 or t3.a >30) and t1.a =3; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "59.01" + }, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 10, + "rows_produced_per_join": 1, + "filtered": "10.00", + "cost_info": { + "read_cost": "1.40", + "eval_cost": "0.10", + "prefix_cost": "1.50", + "data_read_per_join": "8" + }, + "used_columns": [ + "a" + ], + "attached_condition": "(`test`.`t1`.`a` = 3)" + } + }, + { + "duplicates_removal": { + "using_temporary_table": true, + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 10, + "rows_produced_per_join": 10, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "1.00", + "prefix_cost": "3.01", + "data_read_per_join": "80" + }, + "used_columns": [ + "a" + ], + "attached_condition": "(((`test`.`t2`.`a` < 10) or (`test`.`t2`.`a` > 30)) and (`test`.`t2`.`a` is not null))" + } + }, + { + "table": { + "table_name": "t3", + "access_type": "ref", + "possible_keys": [ + "a" + ], + "key": "a", + "used_key_parts": [ + "a" + ], + "key_length": "5", + "ref": [ + "test.t2.a" + ], + "rows_examined_per_scan": 10, + "rows_produced_per_join": 100, + "filtered": "100.00", + "cost_info": { + "read_cost": "25.00", + "eval_cost": "10.00", + "prefix_cost": "59.01", + "data_read_per_join": "40K" + }, + "used_columns": [ + "a", + "b", + "filler" + ] + } + } + ] + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t3`.`filler` AS `filler` from `test`.`t1` join `test`.`t3` semi join (`test`.`t2`) where ((`test`.`t3`.`a` = `test`.`t2`.`a`) and (`test`.`t1`.`a` = 3) and ((`test`.`t2`.`a` < 10) or (`test`.`t2`.`a` > 30))) +explain select straight_join * from t1 a, t1 b where a.a in (select a from t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY a NULL ALL NULL NULL NULL NULL 10 100.00 Using where +1 PRIMARY b NULL ALL NULL NULL NULL NULL 10 100.00 NULL +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select straight_join `test`.`a`.`a` AS `a`,`test`.`b`.`a` AS `a` from `test`.`t1` `a` join `test`.`t1` `b` where (`test`.`a`.`a`,(/* select#2 */ select `test`.`t2`.`a` from `test`.`t2` where ((`test`.`a`.`a`) = `test`.`t2`.`a`))) +explain select * from t2 where a in (select straight_join a.a from t1 a, t1 b); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 10 100.00 Using where +2 DEPENDENT SUBQUERY a NULL ALL NULL NULL NULL NULL 10 10.00 Using where +2 DEPENDENT SUBQUERY b NULL ALL NULL NULL NULL NULL 10 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` where (`test`.`t2`.`a`,(/* select#2 */ select straight_join `test`.`a`.`a` from `test`.`t1` `a` join `test`.`t1` `b` where ((`test`.`t2`.`a`) = `test`.`a`.`a`))) +explain select * from t2 where a in (select straight_join a.a from t1 a, t1 b); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 10 100.00 Using where +2 DEPENDENT SUBQUERY a NULL ALL NULL NULL NULL NULL 10 10.00 Using where +2 DEPENDENT SUBQUERY b NULL ALL NULL NULL NULL NULL 10 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` where (`test`.`t2`.`a`,(/* select#2 */ select straight_join `test`.`a`.`a` from `test`.`t1` `a` join `test`.`t1` `b` where ((`test`.`t2`.`a`) = `test`.`a`.`a`))) +explain select straight_join * from t2 x, t2 y +where x.a in (select straight_join a.a from t1 a, t1 b); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY x NULL ALL NULL NULL NULL NULL 10 100.00 Using where +1 PRIMARY y NULL ALL NULL NULL NULL NULL 10 100.00 NULL +2 DEPENDENT SUBQUERY a NULL ALL NULL NULL NULL NULL 10 10.00 Using where +2 DEPENDENT SUBQUERY b NULL ALL NULL NULL NULL NULL 10 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select straight_join `test`.`x`.`a` AS `a`,`test`.`y`.`a` AS `a` from `test`.`t2` `x` join `test`.`t2` `y` where (`test`.`x`.`a`,(/* select#2 */ select straight_join `test`.`a`.`a` from `test`.`t1` `a` join `test`.`t1` `b` where ((`test`.`x`.`a`) = `test`.`a`.`a`))) +create table t0 (a int, b int); +insert into t0 values(1,1); +explain select * from t0, t3 where t3.a in (select a from t2) and (t3.a < 10 or t3.a >30); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 10 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ref a a 5 test.t2.a 10 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select '1' AS `a`,'1' AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t3`.`filler` AS `filler` from `test`.`t3` semi join (`test`.`t2`) where ((`test`.`t3`.`a` = `test`.`t2`.`a`) and ((`test`.`t2`.`a` < 10) or (`test`.`t2`.`a` > 30))) +create table t4 as select a as x, a as y from t1; +explain select * from t0, t3 where (t3.a, t3.b) in (select x,y from t4) and (t3.a < 10 or t3.a >30); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t4 NULL ALL NULL NULL NULL NULL 10 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ref a a 5 test.t4.x 10 10.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '1' AS `a`,'1' AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t3`.`filler` AS `filler` from `test`.`t3` semi join (`test`.`t4`) where ((`test`.`t3`.`b` = `test`.`t4`.`y`) and (`test`.`t3`.`a` = `test`.`t4`.`x`) and ((`test`.`t4`.`x` < 10) or (`test`.`t4`.`x` > 30))) +drop table t0,t1,t2,t3,t4; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (a int, b int, filler char(100), key(a,b)); +insert into t1 select A.a, B.a, 'filler' from t0 A, t0 B; +create table t2 as select * from t1; +explain select * from t2 where a in (select b from t1 where a=3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 100 100.00 Using where +1 SIMPLE t1 NULL ref a a 10 const,test.t2.a 1 100.00 Using index; Start temporary; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`filler` AS `filler` from `test`.`t2` semi join (`test`.`t1`) where ((`test`.`t1`.`b` = `test`.`t2`.`a`) and (`test`.`t1`.`a` = 3)) +explain select * from t2 where (b,a) in (select a,b from t1 where a=3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 100 10.00 Using where +1 SIMPLE t1 NULL ref a a 10 const,test.t2.a 1 100.00 Using index; Start temporary; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`filler` AS `filler` from `test`.`t2` semi join (`test`.`t1`) where ((`test`.`t1`.`b` = `test`.`t2`.`a`) and (`test`.`t2`.`b` = 3) and (`test`.`t1`.`a` = 3)) +drop table t1,t2; +create table t1 (a int, b int); +insert into t1 select a,a from t0; +create table t2 (a int, b int); +insert into t2 select A.a + 10*B.a, A.a + 10*B.a from t0 A, t0 B; +explain select * from t1 where (a,b) in (select a,b from t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 100 1.00 Using where; Start temporary; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`a` = `test`.`t1`.`a`)) +drop table t0, t1, t2; +# +# Bug#19695490: CRASH IN CREATE_REF_FOR_KEY ON SELECT + JOIN + UTF8 COLUMN +# + DATETIME INDEX. +# +CREATE TABLE t1 ( +field1 varchar(255) CHARACTER SET utf8, +field2 varchar(255) CHARACTER SET utf8 +); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES +('time','time'), +('lpjdzvkp','lpjdzvkp'), +('dzvkpai', 'dzvkpai'); +CREATE TABLE t2 ( col_varchar varchar(10)); +CREATE TABLE t3 ( +pk int(11) NOT NULL, +col_varchar_255_utf8_key varchar(255) CHARACTER SET utf8, +col_varchar_10_utf8_key varchar(10) CHARACTER SET utf8, +PRIMARY KEY (pk) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t3 VALUES (22,'come','h'), +(23,'time','aaa'), +(24,'lpjdzvkp','ababa'), +(25,'d','GGDD'); +SELECT * FROM t1 WHERE (field1, field2) IN ( +SELECT table1.col_varchar_255_utf8_key AS field1, +table1.col_varchar_255_utf8_key AS field2 +FROM t3 AS table1 LEFT JOIN t2 AS table2 +ON table1.col_varchar_10_utf8_key <= +table2.col_varchar +WHERE table1.pk >= 6); +field1 field2 +time time +lpjdzvkp lpjdzvkp +DROP TABLE t1,t2,t3; +create table t0 (a decimal(4,2)); +insert into t0 values (10.24), (22.11); +create table t1 as select * from t0; +insert into t1 select * from t0; +explain select * from t0 where a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; Start temporary; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a` from `test`.`t0` semi join (`test`.`t1`) where (`test`.`t1`.`a` = `test`.`t0`.`a`) +select * from t0 where a in (select a from t1); +a +10.24 +22.11 +drop table t0, t1; +create table t0(a date); +insert into t0 values ('2008-01-01'),('2008-02-02'); +create table t1 as select * from t0; +insert into t1 select * from t0; +explain select * from t0 where a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; Start temporary; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a` from `test`.`t0` semi join (`test`.`t1`) where (`test`.`t1`.`a` = `test`.`t0`.`a`) +select * from t0 where a in (select a from t1); +a +2008-01-01 +2008-02-02 +drop table t0, t1; +create table t0(a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 as select a as a, a as b, a as c from t0 where a < 3; +create table t2 as select a as a, a as b from t0 where a < 3; +insert into t2 select * from t2; +explain select * from t1 where (a,b,c) in (select x.a, y.a, z.a from t2 x, t2 y, t2 z where x.b=33); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE x NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +1 SIMPLE y NULL ALL NULL NULL NULL NULL 6 16.67 Using where +1 SIMPLE z NULL ALL NULL NULL NULL NULL 6 16.67 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` semi join (`test`.`t2` `x` join `test`.`t2` `y` join `test`.`t2` `z`) where ((`test`.`z`.`a` = `test`.`t1`.`c`) and (`test`.`y`.`a` = `test`.`t1`.`b`) and (`test`.`t1`.`a` = `test`.`x`.`a`) and (`test`.`x`.`b` = 33)) +drop table t0,t1,t2; +set @save_join_buffer_size = @@join_buffer_size; +set join_buffer_size= 8192; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (a int, filler1 binary(200), filler2 binary(200)); +insert into t1 select a, 'filler123456', 'filler123456' from t0; +insert into t1 select a+10, 'filler123456', 'filler123456' from t0; +create table t2 as select * from t1; +insert into t1 select a+20, 'filler123456', 'filler123456' from t0; +insert into t1 values (2, 'duplicate ok', 'duplicate ok'); +insert into t1 values (18, 'duplicate ok', 'duplicate ok'); +insert into t2 values (3, 'duplicate ok', 'duplicate ok'); +insert into t2 values (19, 'duplicate ok', 'duplicate ok'); +explain select +a, mid(filler1, 1,10), length(filler1)=length(filler2) as z +from t1 ot where a in (select a from t2 it); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE it NULL ALL NULL NULL NULL NULL 22 100.00 Start temporary +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 32 10.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`ot`.`a` AS `a`,substr(`test`.`ot`.`filler1`,1,10) AS `mid(filler1, 1,10)`,(length(`test`.`ot`.`filler1`) = length(`test`.`ot`.`filler2`)) AS `z` from `test`.`t1` `ot` semi join (`test`.`t2` `it`) where (`test`.`ot`.`a` = `test`.`it`.`a`) +select +a, mid(filler1, 1,10), length(filler1)=length(filler2) as z +from t1 ot where a in (select a from t2 it); +a mid(filler1, 1,10) z +0 filler1234 1 +1 filler1234 1 +10 filler1234 1 +11 filler1234 1 +12 filler1234 1 +13 filler1234 1 +14 filler1234 1 +15 filler1234 1 +16 filler1234 1 +17 filler1234 1 +18 duplicate 1 +18 filler1234 1 +19 filler1234 1 +2 duplicate 1 +2 filler1234 1 +3 filler1234 1 +4 filler1234 1 +5 filler1234 1 +6 filler1234 1 +7 filler1234 1 +8 filler1234 1 +9 filler1234 1 +explain select +a, mid(filler1, 1,10), length(filler1)=length(filler2) +from t2 ot where a in (select a from t1 it); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 22 100.00 NULL +1 SIMPLE it NULL ALL NULL NULL NULL NULL 32 10.00 Using where; Start temporary; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`ot`.`a` AS `a`,substr(`test`.`ot`.`filler1`,1,10) AS `mid(filler1, 1,10)`,(length(`test`.`ot`.`filler1`) = length(`test`.`ot`.`filler2`)) AS `length(filler1)=length(filler2)` from `test`.`t2` `ot` semi join (`test`.`t1` `it`) where (`test`.`it`.`a` = `test`.`ot`.`a`) +select +a, mid(filler1, 1,10), length(filler1)=length(filler2) +from t2 ot where a in (select a from t1 it); +a mid(filler1, 1,10) length(filler1)=length(filler2) +0 filler1234 1 +1 filler1234 1 +10 filler1234 1 +11 filler1234 1 +12 filler1234 1 +13 filler1234 1 +14 filler1234 1 +15 filler1234 1 +16 filler1234 1 +17 filler1234 1 +18 filler1234 1 +19 duplicate 1 +19 filler1234 1 +2 filler1234 1 +3 duplicate 1 +3 filler1234 1 +4 filler1234 1 +5 filler1234 1 +6 filler1234 1 +7 filler1234 1 +8 filler1234 1 +9 filler1234 1 +insert into t1 select a+20, 'filler123456', 'filler123456' from t0; +insert into t1 select a+20, 'filler123456', 'filler123456' from t0; +explain select +a, mid(filler1, 1,10), length(filler1)=length(filler2) as z +from t1 ot where a in (select a from t2 it); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE it NULL ALL NULL NULL NULL NULL 22 100.00 Start temporary +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 52 10.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`ot`.`a` AS `a`,substr(`test`.`ot`.`filler1`,1,10) AS `mid(filler1, 1,10)`,(length(`test`.`ot`.`filler1`) = length(`test`.`ot`.`filler2`)) AS `z` from `test`.`t1` `ot` semi join (`test`.`t2` `it`) where (`test`.`ot`.`a` = `test`.`it`.`a`) +select +a, mid(filler1, 1,10), length(filler1)=length(filler2) as z +from t1 ot where a in (select a from t2 it); +a mid(filler1, 1,10) z +0 filler1234 1 +1 filler1234 1 +10 filler1234 1 +11 filler1234 1 +12 filler1234 1 +13 filler1234 1 +14 filler1234 1 +15 filler1234 1 +16 filler1234 1 +17 filler1234 1 +18 duplicate 1 +18 filler1234 1 +19 filler1234 1 +2 duplicate 1 +2 filler1234 1 +3 filler1234 1 +4 filler1234 1 +5 filler1234 1 +6 filler1234 1 +7 filler1234 1 +8 filler1234 1 +9 filler1234 1 +explain select +a, mid(filler1, 1,10), length(filler1)=length(filler2) +from t2 ot where a in (select a from t1 it); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 22 100.00 NULL +1 SIMPLE it NULL ALL NULL NULL NULL NULL 52 10.00 Using where; Start temporary; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`ot`.`a` AS `a`,substr(`test`.`ot`.`filler1`,1,10) AS `mid(filler1, 1,10)`,(length(`test`.`ot`.`filler1`) = length(`test`.`ot`.`filler2`)) AS `length(filler1)=length(filler2)` from `test`.`t2` `ot` semi join (`test`.`t1` `it`) where (`test`.`it`.`a` = `test`.`ot`.`a`) +select +a, mid(filler1, 1,10), length(filler1)=length(filler2) +from t2 ot where a in (select a from t1 it); +a mid(filler1, 1,10) length(filler1)=length(filler2) +0 filler1234 1 +1 filler1234 1 +10 filler1234 1 +11 filler1234 1 +12 filler1234 1 +13 filler1234 1 +14 filler1234 1 +15 filler1234 1 +16 filler1234 1 +17 filler1234 1 +18 filler1234 1 +19 duplicate 1 +19 filler1234 1 +2 filler1234 1 +3 duplicate 1 +3 filler1234 1 +4 filler1234 1 +5 filler1234 1 +6 filler1234 1 +7 filler1234 1 +8 filler1234 1 +9 filler1234 1 +set @@join_buffer_size = @save_join_buffer_size; +drop table t1, t2; +create table t1 (a int, b int, key(a)); +create table t2 (a int, b int, key(a)); +create table t3 (a int, b int, key(a)); +insert into t1 select a,a from t0; +insert into t2 select a,a from t0; +insert into t3 select a,a from t0; +t2 and t3 must be use 'ref', not 'ALL': +explain select * +from t0 where a in +(select t2.a+t3.a from t1 left join (t2 join t3) on t2.a=t1.a and t3.a=t1.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 10 100.00 NULL +1 SIMPLE t1 NULL index a a 5 NULL 10 100.00 Using where; Using index; Start temporary +1 SIMPLE t2 NULL ref a a 5 test.t1.a 1 100.00 Using index +1 SIMPLE t3 NULL ref a a 5 test.t1.a 1 100.00 Using index; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a` from `test`.`t0` semi join (`test`.`t1` join `test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`a` = `test`.`t1`.`a`) and (`test`.`t3`.`a` = `test`.`t1`.`a`) and (`test`.`t0`.`a` = (`test`.`t1`.`a` + `test`.`t1`.`a`))) +drop table t0, t1,t2,t3; + +Test that neither MaterializeLookup strategy for semijoin, +nor subquery materialization is used when BLOBs are involved +(except when arguments of some functions). + +set @prefix_len = 6; +set @blob_len = 16; +set @suffix_len = @blob_len - @prefix_len; +create table t1_16 (a1 blob(16), a2 blob(16)); +create table t2_16 (b1 blob(16), b2 blob(16)); +create table t3_16 (c1 blob(16), c2 blob(16)); +insert into t1_16 values +(concat('1 - 00', repeat('x', @suffix_len)), concat('2 - 00', repeat('x', @suffix_len))); +insert into t1_16 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t1_16 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_16 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t2_16 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_16 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_16 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t3_16 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t3_16 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_16 values +(concat('1 - 04', repeat('x', @suffix_len)), concat('2 - 04', repeat('x', @suffix_len))); +explain select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select b1 from t2_16 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2_16 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Start temporary +1 SIMPLE t1_16 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_16`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_16`.`a2`,7) AS `left(a2,7)` from `test`.`t1_16` semi join (`test`.`t2_16`) where ((`test`.`t1_16`.`a1` = `test`.`t2_16`.`b1`) and (`test`.`t2_16`.`b1` > '0')) +select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select b1 from t2_16 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_16 +where (a1,a2) in (select b1, b2 from t2_16 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2_16 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Start temporary +1 SIMPLE t1_16 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_16`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_16`.`a2`,7) AS `left(a2,7)` from `test`.`t1_16` semi join (`test`.`t2_16`) where ((`test`.`t1_16`.`a2` = `test`.`t2_16`.`b2`) and (`test`.`t1_16`.`a1` = `test`.`t2_16`.`b1`) and (`test`.`t2_16`.`b1` > '0')) +select left(a1,7), left(a2,7) +from t1_16 +where (a1,a2) in (select b1, b2 from t2_16 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select substring(b1,1,16) from t2_16 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2_16 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Start temporary +1 SIMPLE t1_16 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_16`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_16`.`a2`,7) AS `left(a2,7)` from `test`.`t1_16` semi join (`test`.`t2_16`) where ((`test`.`t2_16`.`b1` > '0') and (`test`.`t1_16`.`a1` = substr(`test`.`t2_16`.`b1`,1,16))) +select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select substring(b1,1,16) from t2_16 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select group_concat(b1) from t2_16 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_16 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t2_16 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_16`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_16`.`a2`,7) AS `left(a2,7)` from `test`.`t1_16` where (`test`.`t1_16`.`a1`,(/* select#2 */ select group_concat(`test`.`t2_16`.`b1` separator ',') from `test`.`t2_16` group by `test`.`t2_16`.`b2` having ((`test`.`t1_16`.`a1`) = (group_concat(`test`.`t2_16`.`b1` separator ','))))) +select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select group_concat(b1) from t2_16 group by b2); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +set @@group_concat_max_len = 256; +explain select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select group_concat(b1) from t2_16 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_16 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t2_16 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_16`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_16`.`a2`,7) AS `left(a2,7)` from `test`.`t1_16` where (`test`.`t1_16`.`a1`,(/* select#2 */ select group_concat(`test`.`t2_16`.`b1` separator ',') from `test`.`t2_16` group by `test`.`t2_16`.`b2` having ((`test`.`t1_16`.`a1`) = (group_concat(`test`.`t2_16`.`b1` separator ','))))) +select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select group_concat(b1) from t2_16 group by b2); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +create table t1 (a1 char(8), a2 char(8)) charset latin1; +create table t2 (b1 char(8), b2 char(8)) charset latin1; +create table t3 (c1 char(8), c2 char(8)) charset latin1; +insert into t1 values ('1 - 00', '2 - 00'); +insert into t1 values ('1 - 01', '2 - 01'); +insert into t1 values ('1 - 02', '2 - 02'); +insert into t2 values ('1 - 01', '2 - 01'); +insert into t2 values ('1 - 01', '2 - 01'); +insert into t2 values ('1 - 02', '2 - 02'); +insert into t2 values ('1 - 02', '2 - 02'); +insert into t2 values ('1 - 03', '2 - 03'); +insert into t3 values ('1 - 01', '2 - 01'); +insert into t3 values ('1 - 02', '2 - 02'); +insert into t3 values ('1 - 03', '2 - 03'); +insert into t3 values ('1 - 04', '2 - 04'); +insert into t3 values ('1 - 05', '2 - 05'); +insert into t3 values ('1 - 06', '2 - 06'); +insert into t3 values ('1 - 07', '2 - 07'); +insert into t3 values ('1 - 08', '2 - 08'); +explain +select * from t1 +where concat(a1,'x') IN +(select left(a1,8) from t1_16 +where (a1, a2) IN +(select t2_16.b1, t2_16.b2 from t2_16, t2 +where t2.b2 = substring(t2_16.b2,1,6) and +t2.b1 IN (select c1 from t3 where c2 > '0'))); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE t1_16 NULL ALL NULL NULL NULL NULL 3 100.00 Using where; Start temporary +1 SIMPLE t2_16 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 5 20.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` semi join (`test`.`t1_16` join `test`.`t2_16` join `test`.`t2` join `test`.`t3`) where ((`test`.`t2_16`.`b2` = `test`.`t1_16`.`a2`) and (`test`.`t2_16`.`b1` = `test`.`t1_16`.`a1`) and (`test`.`t3`.`c1` = `test`.`t2`.`b1`) and (`test`.`t2`.`b2` = substr(`test`.`t2_16`.`b2`,1,6)) and (`test`.`t3`.`c2` > '0') and (concat(`test`.`t1`.`a1`,'x') = left(`test`.`t1_16`.`a1`,8))) +drop table t1_16, t2_16, t3_16, t1, t2, t3; +set @blob_len = 512; +set @suffix_len = @blob_len - @prefix_len; +create table t1_512 (a1 blob(512), a2 blob(512)); +create table t2_512 (b1 blob(512), b2 blob(512)); +create table t3_512 (c1 blob(512), c2 blob(512)); +insert into t1_512 values +(concat('1 - 00', repeat('x', @suffix_len)), concat('2 - 00', repeat('x', @suffix_len))); +insert into t1_512 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t1_512 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_512 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t2_512 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_512 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_512 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t3_512 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t3_512 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_512 values +(concat('1 - 04', repeat('x', @suffix_len)), concat('2 - 04', repeat('x', @suffix_len))); +explain select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select b1 from t2_512 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2_512 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Start temporary +1 SIMPLE t1_512 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_512`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_512`.`a2`,7) AS `left(a2,7)` from `test`.`t1_512` semi join (`test`.`t2_512`) where ((`test`.`t1_512`.`a1` = `test`.`t2_512`.`b1`) and (`test`.`t2_512`.`b1` > '0')) +select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select b1 from t2_512 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_512 +where (a1,a2) in (select b1, b2 from t2_512 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2_512 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Start temporary +1 SIMPLE t1_512 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_512`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_512`.`a2`,7) AS `left(a2,7)` from `test`.`t1_512` semi join (`test`.`t2_512`) where ((`test`.`t1_512`.`a2` = `test`.`t2_512`.`b2`) and (`test`.`t1_512`.`a1` = `test`.`t2_512`.`b1`) and (`test`.`t2_512`.`b1` > '0')) +select left(a1,7), left(a2,7) +from t1_512 +where (a1,a2) in (select b1, b2 from t2_512 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select substring(b1,1,512) from t2_512 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2_512 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Start temporary +1 SIMPLE t1_512 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_512`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_512`.`a2`,7) AS `left(a2,7)` from `test`.`t1_512` semi join (`test`.`t2_512`) where ((`test`.`t2_512`.`b1` > '0') and (`test`.`t1_512`.`a1` = substr(`test`.`t2_512`.`b1`,1,512))) +select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select substring(b1,1,512) from t2_512 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select group_concat(b1) from t2_512 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_512 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t2_512 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_512`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_512`.`a2`,7) AS `left(a2,7)` from `test`.`t1_512` where (`test`.`t1_512`.`a1`,(/* select#2 */ select group_concat(`test`.`t2_512`.`b1` separator ',') from `test`.`t2_512` group by `test`.`t2_512`.`b2` having ((`test`.`t1_512`.`a1`) = (group_concat(`test`.`t2_512`.`b1` separator ','))))) +select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select group_concat(b1) from t2_512 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +Warning 1260 Row 4 was cut by GROUP_CONCAT() +Warning 1260 Row 5 was cut by GROUP_CONCAT() +Warning 1260 Row 6 was cut by GROUP_CONCAT() +Warning 1260 Row 7 was cut by GROUP_CONCAT() +Warning 1260 Row 8 was cut by GROUP_CONCAT() +Warning 1260 Row 9 was cut by GROUP_CONCAT() +set @@group_concat_max_len = 256; +explain select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select group_concat(b1) from t2_512 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_512 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t2_512 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_512`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_512`.`a2`,7) AS `left(a2,7)` from `test`.`t1_512` where (`test`.`t1_512`.`a1`,(/* select#2 */ select group_concat(`test`.`t2_512`.`b1` separator ',') from `test`.`t2_512` group by `test`.`t2_512`.`b2` having ((`test`.`t1_512`.`a1`) = (group_concat(`test`.`t2_512`.`b1` separator ','))))) +select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select group_concat(b1) from t2_512 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +Warning 1260 Row 4 was cut by GROUP_CONCAT() +Warning 1260 Row 5 was cut by GROUP_CONCAT() +Warning 1260 Row 6 was cut by GROUP_CONCAT() +Warning 1260 Row 7 was cut by GROUP_CONCAT() +Warning 1260 Row 8 was cut by GROUP_CONCAT() +Warning 1260 Row 9 was cut by GROUP_CONCAT() +drop table t1_512, t2_512, t3_512; +set @blob_len = 513; +set @suffix_len = @blob_len - @prefix_len; +create table t1_513 (a1 blob(513), a2 blob(513)); +create table t2_513 (b1 blob(513), b2 blob(513)); +create table t3_513 (c1 blob(513), c2 blob(513)); +insert into t1_513 values +(concat('1 - 00', repeat('x', @suffix_len)), concat('2 - 00', repeat('x', @suffix_len))); +insert into t1_513 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t1_513 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_513 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t2_513 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_513 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_513 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t3_513 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t3_513 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_513 values +(concat('1 - 04', repeat('x', @suffix_len)), concat('2 - 04', repeat('x', @suffix_len))); +explain select left(a1,7), left(a2,7) +from t1_513 +where a1 in (select b1 from t2_513 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2_513 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Start temporary +1 SIMPLE t1_513 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_513`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_513`.`a2`,7) AS `left(a2,7)` from `test`.`t1_513` semi join (`test`.`t2_513`) where ((`test`.`t1_513`.`a1` = `test`.`t2_513`.`b1`) and (`test`.`t2_513`.`b1` > '0')) +select left(a1,7), left(a2,7) +from t1_513 +where a1 in (select b1 from t2_513 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_513 +where (a1,a2) in (select b1, b2 from t2_513 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2_513 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Start temporary +1 SIMPLE t1_513 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_513`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_513`.`a2`,7) AS `left(a2,7)` from `test`.`t1_513` semi join (`test`.`t2_513`) where ((`test`.`t1_513`.`a2` = `test`.`t2_513`.`b2`) and (`test`.`t1_513`.`a1` = `test`.`t2_513`.`b1`) and (`test`.`t2_513`.`b1` > '0')) +select left(a1,7), left(a2,7) +from t1_513 +where (a1,a2) in (select b1, b2 from t2_513 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_513 +where a1 in (select substring(b1,1,513) from t2_513 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2_513 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Start temporary +1 SIMPLE t1_513 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_513`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_513`.`a2`,7) AS `left(a2,7)` from `test`.`t1_513` semi join (`test`.`t2_513`) where ((`test`.`t2_513`.`b1` > '0') and (`test`.`t1_513`.`a1` = substr(`test`.`t2_513`.`b1`,1,513))) +select left(a1,7), left(a2,7) +from t1_513 +where a1 in (select substring(b1,1,513) from t2_513 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_513 +where a1 in (select group_concat(b1) from t2_513 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_513 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t2_513 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_513`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_513`.`a2`,7) AS `left(a2,7)` from `test`.`t1_513` where (`test`.`t1_513`.`a1`,(/* select#2 */ select group_concat(`test`.`t2_513`.`b1` separator ',') from `test`.`t2_513` group by `test`.`t2_513`.`b2` having ((`test`.`t1_513`.`a1`) = (group_concat(`test`.`t2_513`.`b1` separator ','))))) +select left(a1,7), left(a2,7) +from t1_513 +where a1 in (select group_concat(b1) from t2_513 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +Warning 1260 Row 4 was cut by GROUP_CONCAT() +Warning 1260 Row 5 was cut by GROUP_CONCAT() +Warning 1260 Row 6 was cut by GROUP_CONCAT() +Warning 1260 Row 7 was cut by GROUP_CONCAT() +Warning 1260 Row 8 was cut by GROUP_CONCAT() +Warning 1260 Row 9 was cut by GROUP_CONCAT() +drop table t1_513, t2_513, t3_513; +set @blob_len = 1024; +set @suffix_len = @blob_len - @prefix_len; +create table t1_1024 (a1 blob(1024), a2 blob(1024)); +create table t2_1024 (b1 blob(1024), b2 blob(1024)); +create table t3_1024 (c1 blob(1024), c2 blob(1024)); +insert into t1_1024 values +(concat('1 - 00', repeat('x', @suffix_len)), concat('2 - 00', repeat('x', @suffix_len))); +insert into t1_1024 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t1_1024 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_1024 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t2_1024 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_1024 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_1024 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t3_1024 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t3_1024 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_1024 values +(concat('1 - 04', repeat('x', @suffix_len)), concat('2 - 04', repeat('x', @suffix_len))); +explain select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select b1 from t2_1024 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2_1024 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Start temporary +1 SIMPLE t1_1024 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1024`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1024`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1024` semi join (`test`.`t2_1024`) where ((`test`.`t1_1024`.`a1` = `test`.`t2_1024`.`b1`) and (`test`.`t2_1024`.`b1` > '0')) +select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select b1 from t2_1024 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_1024 +where (a1,a2) in (select b1, b2 from t2_1024 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2_1024 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Start temporary +1 SIMPLE t1_1024 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1024`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1024`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1024` semi join (`test`.`t2_1024`) where ((`test`.`t1_1024`.`a2` = `test`.`t2_1024`.`b2`) and (`test`.`t1_1024`.`a1` = `test`.`t2_1024`.`b1`) and (`test`.`t2_1024`.`b1` > '0')) +select left(a1,7), left(a2,7) +from t1_1024 +where (a1,a2) in (select b1, b2 from t2_1024 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select substring(b1,1,1024) from t2_1024 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2_1024 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Start temporary +1 SIMPLE t1_1024 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1024`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1024`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1024` semi join (`test`.`t2_1024`) where ((`test`.`t2_1024`.`b1` > '0') and (`test`.`t1_1024`.`a1` = substr(`test`.`t2_1024`.`b1`,1,1024))) +select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select substring(b1,1,1024) from t2_1024 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select group_concat(b1) from t2_1024 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_1024 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t2_1024 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1024`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1024`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1024` where (`test`.`t1_1024`.`a1`,(/* select#2 */ select group_concat(`test`.`t2_1024`.`b1` separator ',') from `test`.`t2_1024` group by `test`.`t2_1024`.`b2` having ((`test`.`t1_1024`.`a1`) = (group_concat(`test`.`t2_1024`.`b1` separator ','))))) +select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select group_concat(b1) from t2_1024 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +Warning 1260 Row 4 was cut by GROUP_CONCAT() +Warning 1260 Row 5 was cut by GROUP_CONCAT() +Warning 1260 Row 6 was cut by GROUP_CONCAT() +Warning 1260 Row 7 was cut by GROUP_CONCAT() +Warning 1260 Row 8 was cut by GROUP_CONCAT() +Warning 1260 Row 9 was cut by GROUP_CONCAT() +set @@group_concat_max_len = 256; +explain select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select group_concat(b1) from t2_1024 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_1024 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t2_1024 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1024`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1024`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1024` where (`test`.`t1_1024`.`a1`,(/* select#2 */ select group_concat(`test`.`t2_1024`.`b1` separator ',') from `test`.`t2_1024` group by `test`.`t2_1024`.`b2` having ((`test`.`t1_1024`.`a1`) = (group_concat(`test`.`t2_1024`.`b1` separator ','))))) +select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select group_concat(b1) from t2_1024 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +Warning 1260 Row 4 was cut by GROUP_CONCAT() +Warning 1260 Row 5 was cut by GROUP_CONCAT() +Warning 1260 Row 6 was cut by GROUP_CONCAT() +Warning 1260 Row 7 was cut by GROUP_CONCAT() +Warning 1260 Row 8 was cut by GROUP_CONCAT() +Warning 1260 Row 9 was cut by GROUP_CONCAT() +drop table t1_1024, t2_1024, t3_1024; +set @blob_len = 1025; +set @suffix_len = @blob_len - @prefix_len; +create table t1_1025 (a1 blob(1025), a2 blob(1025)); +create table t2_1025 (b1 blob(1025), b2 blob(1025)); +create table t3_1025 (c1 blob(1025), c2 blob(1025)); +insert into t1_1025 values +(concat('1 - 00', repeat('x', @suffix_len)), concat('2 - 00', repeat('x', @suffix_len))); +insert into t1_1025 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t1_1025 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_1025 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t2_1025 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_1025 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_1025 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t3_1025 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t3_1025 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_1025 values +(concat('1 - 04', repeat('x', @suffix_len)), concat('2 - 04', repeat('x', @suffix_len))); +explain select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select b1 from t2_1025 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2_1025 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Start temporary +1 SIMPLE t1_1025 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1025`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1025`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1025` semi join (`test`.`t2_1025`) where ((`test`.`t1_1025`.`a1` = `test`.`t2_1025`.`b1`) and (`test`.`t2_1025`.`b1` > '0')) +select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select b1 from t2_1025 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_1025 +where (a1,a2) in (select b1, b2 from t2_1025 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2_1025 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Start temporary +1 SIMPLE t1_1025 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1025`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1025`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1025` semi join (`test`.`t2_1025`) where ((`test`.`t1_1025`.`a2` = `test`.`t2_1025`.`b2`) and (`test`.`t1_1025`.`a1` = `test`.`t2_1025`.`b1`) and (`test`.`t2_1025`.`b1` > '0')) +select left(a1,7), left(a2,7) +from t1_1025 +where (a1,a2) in (select b1, b2 from t2_1025 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select substring(b1,1,1025) from t2_1025 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2_1025 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Start temporary +1 SIMPLE t1_1025 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1025`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1025`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1025` semi join (`test`.`t2_1025`) where ((`test`.`t2_1025`.`b1` > '0') and (`test`.`t1_1025`.`a1` = substr(`test`.`t2_1025`.`b1`,1,1025))) +select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select substring(b1,1,1025) from t2_1025 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select group_concat(b1) from t2_1025 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_1025 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t2_1025 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1025`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1025`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1025` where (`test`.`t1_1025`.`a1`,(/* select#2 */ select group_concat(`test`.`t2_1025`.`b1` separator ',') from `test`.`t2_1025` group by `test`.`t2_1025`.`b2` having ((`test`.`t1_1025`.`a1`) = (group_concat(`test`.`t2_1025`.`b1` separator ','))))) +select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select group_concat(b1) from t2_1025 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +Warning 1260 Row 4 was cut by GROUP_CONCAT() +Warning 1260 Row 5 was cut by GROUP_CONCAT() +Warning 1260 Row 6 was cut by GROUP_CONCAT() +Warning 1260 Row 7 was cut by GROUP_CONCAT() +Warning 1260 Row 8 was cut by GROUP_CONCAT() +Warning 1260 Row 9 was cut by GROUP_CONCAT() +set @@group_concat_max_len = 256; +explain select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select group_concat(b1) from t2_1025 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_1025 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t2_1025 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1025`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1025`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1025` where (`test`.`t1_1025`.`a1`,(/* select#2 */ select group_concat(`test`.`t2_1025`.`b1` separator ',') from `test`.`t2_1025` group by `test`.`t2_1025`.`b2` having ((`test`.`t1_1025`.`a1`) = (group_concat(`test`.`t2_1025`.`b1` separator ','))))) +select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select group_concat(b1) from t2_1025 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +Warning 1260 Row 4 was cut by GROUP_CONCAT() +Warning 1260 Row 5 was cut by GROUP_CONCAT() +Warning 1260 Row 6 was cut by GROUP_CONCAT() +Warning 1260 Row 7 was cut by GROUP_CONCAT() +Warning 1260 Row 8 was cut by GROUP_CONCAT() +Warning 1260 Row 9 was cut by GROUP_CONCAT() +drop table t1_1025, t2_1025, t3_1025; +# +# WL#5561: Enable semi join transformation with outer join. +# +CREATE TABLE ot1(a INT); +CREATE TABLE ot2(a INT); +CREATE TABLE ot3(a INT); +CREATE TABLE it1(a INT); +CREATE TABLE it2(a INT); +CREATE TABLE it3(a INT); +INSERT INTO ot1 VALUES(0),(1),(2),(3),(4),(5),(6),(7); +INSERT INTO ot2 VALUES(0),(2),(4),(6); +INSERT INTO ot3 VALUES(0),(3),(6); +INSERT INTO it1 VALUES(0),(1),(2),(3),(4),(5),(6),(7); +INSERT INTO it2 VALUES(0),(2),(4),(6); +INSERT INTO it3 VALUES(0),(3),(6); +# Test cases, Subquery Pattern 1 +# Example SQ1.1: +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE ot1.a IN (SELECT a FROM it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE it3 NULL ALL NULL NULL NULL NULL 3 100.00 Start temporary +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; End temporary +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` left join `test`.`ot2` on((`test`.`ot2`.`a` = `test`.`it3`.`a`)) semi join (`test`.`it3`) where (`test`.`ot1`.`a` = `test`.`it3`.`a`) +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE ot1.a IN (SELECT a FROM it3); +a a +0 0 +3 NULL +6 6 +# Example SQ1.2: +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE COALESCE(ot2.a,0) IN (SELECT a FROM it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE it3 NULL ALL NULL NULL NULL NULL 3 100.00 Start temporary +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` left join `test`.`ot2` on((`test`.`ot2`.`a` = `test`.`ot1`.`a`)) semi join (`test`.`it3`) where (coalesce(`test`.`ot2`.`a`,0) = `test`.`it3`.`a`) +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE COALESCE(ot2.a,0) IN (SELECT a FROM it3); +a a +0 0 +1 NULL +3 NULL +5 NULL +6 6 +7 NULL +# Example SQ1.3: +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE (ot1.a,ot2.a) IN (SELECT a, a FROM it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE it3 NULL ALL NULL NULL NULL NULL 3 100.00 Start temporary +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` join `test`.`ot2` semi join (`test`.`it3`) where ((`test`.`ot2`.`a` = `test`.`it3`.`a`) and (`test`.`ot1`.`a` = `test`.`it3`.`a`)) +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE (ot1.a,ot2.a) IN (SELECT a, a FROM it3); +a a +0 0 +6 6 +# More test cases +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 +WHERE ot1.a IN (SELECT a FROM it3); +a a +0 0 +3 NULL +6 6 +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 +WHERE ot1.a IN (SELECT a+0 FROM it3); +a a +0 0 +3 NULL +6 6 +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 +WHERE COALESCE(ot2.a,0) IN (SELECT a FROM it3); +a a +0 0 +1 NULL +3 NULL +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE COALESCE(ot2.a,0) IN (SELECT a+0 FROM it3); +a a +0 0 +1 NULL +3 NULL +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 +WHERE (ot1.a,ot2.a) IN (SELECT a, a FROM it3); +a a +0 0 +6 6 +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +LEFT JOIN ot3 ON ot1.a=ot3.a +WHERE ot1.a IN (SELECT a FROM it3); +a a a +0 0 0 +3 NULL 3 +6 6 6 +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +LEFT JOIN ot3 ON ot1.a=ot3.a +WHERE COALESCE(ot2.a,0) IN (SELECT a FROM it3); +a a a +0 0 0 +1 NULL NULL +3 NULL 3 +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +LEFT JOIN ot3 ON ot1.a=ot3.a +WHERE COALESCE(ot3.a,0) IN (SELECT a FROM it3); +a a a +0 0 0 +1 NULL NULL +2 2 NULL +3 NULL 3 +4 4 NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +LEFT JOIN ot3 ON ot2.a=ot3.a +WHERE ot1.a IN (SELECT a FROM it3); +a a a +0 0 0 +3 NULL NULL +6 6 6 +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +LEFT JOIN ot3 ON ot2.a=ot3.a +WHERE COALESCE(ot2.a,0) IN (SELECT a FROM it3); +a a a +0 0 0 +1 NULL NULL +3 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +LEFT JOIN ot3 ON ot2.a=ot3.a +WHERE COALESCE(ot3.a,0) IN (SELECT a FROM it3); +a a a +0 0 0 +1 NULL NULL +2 2 NULL +3 NULL NULL +4 4 NULL +5 NULL NULL +6 6 6 +7 NULL NULL +# Test cases, Subquery Pattern 2 +# Example SQ2.1: +explain SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE it3 NULL ALL NULL NULL NULL NULL 3 100.00 Start temporary +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; End temporary +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` join `test`.`ot2` semi join (`test`.`it3`) where ((`test`.`ot1`.`a` = `test`.`it3`.`a`) and (`test`.`ot2`.`a` = `test`.`it3`.`a`)) +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3); +a a +0 0 +6 6 +# Example SQ2.2: +explain SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it2) +AND ot2.a IN (SELECT a FROM it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE it3 NULL ALL NULL NULL NULL NULL 3 100.00 Start temporary +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where +1 SIMPLE it2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` join `test`.`ot2` semi join (`test`.`it2`) semi join (`test`.`it3`) where ((`test`.`ot2`.`a` = `test`.`it3`.`a`) and (`test`.`it2`.`a` = `test`.`it3`.`a`) and (`test`.`ot1`.`a` = `test`.`it3`.`a`)) +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it2) +AND ot2.a IN (SELECT a FROM it3); +a a +0 0 +6 6 +# More test cases +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it3); +a a +0 0 +6 6 +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it3); +a a +0 0 +6 6 +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a+0 AND ot2.a IN (SELECT a FROM it3); +a a +0 0 +6 6 +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot2.a IN (SELECT a+0 FROM it3); +a a +0 0 +6 6 +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it2) +AND ot2.a IN (SELECT a+0 FROM it3); +a a +0 0 +6 6 +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3) +JOIN ot3 ON ot2.a=ot3.a AND ot3.a IN (SELECT a FROM it3); +a a a +0 0 0 +6 6 6 +# Test cases, Subquery Pattern 3 +# Example SQ3.1: +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +1 SIMPLE it3 NULL ALL NULL NULL NULL NULL 3 100.00 Using where; Start temporary; End temporary +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` semi join (`test`.`it3`)) on(((`test`.`it3`.`a` = `test`.`ot1`.`a`) and (`test`.`ot2`.`a` = `test`.`ot1`.`a`))) where true +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3); +a a +0 0 +1 NULL +2 NULL +3 NULL +4 NULL +5 NULL +6 6 +7 NULL +# Example SQ3.2: +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot2.a IN (SELECT a FROM it2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +1 SIMPLE it2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where; Start temporary; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` semi join (`test`.`it2`)) on(((`test`.`ot2`.`a` = `test`.`ot1`.`a`) and (`test`.`it2`.`a` = `test`.`ot1`.`a`))) where true +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot2.a IN (SELECT a FROM it2); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +# Example SQ3.3 +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1) +AND ot2.a IN (SELECT a FROM it2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +1 SIMPLE it2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where; Start temporary +1 SIMPLE it1 NULL ALL NULL NULL NULL NULL 8 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` semi join (`test`.`it1`) semi join (`test`.`it2`)) on(((`test`.`ot2`.`a` = `test`.`ot1`.`a`) and (`test`.`it2`.`a` = `test`.`ot1`.`a`) and (`test`.`it1`.`a` = `test`.`ot1`.`a`))) where true +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1) +AND ot2.a IN (SELECT a FROM it2); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +# Example SQ3.4 +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND +(ot1.a, ot2.a) IN (SELECT it1.a, it2.a +FROM it1 JOIN it2 ON it1.a=it2.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +1 SIMPLE it2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where; Start temporary +1 SIMPLE it1 NULL ALL NULL NULL NULL NULL 8 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` semi join (`test`.`it1` join `test`.`it2`)) on(((`test`.`ot2`.`a` = `test`.`ot1`.`a`) and (`test`.`it2`.`a` = `test`.`ot1`.`a`) and (`test`.`it1`.`a` = `test`.`ot1`.`a`))) where true +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND +(ot1.a, ot2.a) IN (SELECT it1.a, it2.a +FROM it1 JOIN it2 ON it1.a=it2.a); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +# More test cases +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it3); +a a +0 0 +1 NULL +2 NULL +3 NULL +4 NULL +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it3); +a a +0 0 +1 NULL +2 NULL +3 NULL +4 NULL +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 AND ot2.a IN (SELECT a FROM it2); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot2.a IN (SELECT a+0 FROM it2); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a+0 FROM it1) +AND ot2.a IN (SELECT a+0 FROM it2); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 AND +(ot1.a, ot2.a) IN (SELECT it1.a+0, it2.a+0 +FROM it1 JOIN it2 ON it1.a=it2.a); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +EXPLAIN FORMAT=tree SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3) +LEFT JOIN ot3 ON ot2.a=ot3.a AND ot3.a IN (SELECT a FROM it3); +EXPLAIN +-> Remove duplicate (ot1, ot2, ot3) rows using temporary table (weedout) + -> Nested loop left join (cost=117.35 rows=864) + -> Nested loop left join (cost=14.91 rows=96) + -> Table scan on ot1 (cost=1.30 rows=8) + -> Nested loop inner join (cost=6.83 rows=12) + -> Filter: (it3.a = ot1.a) (cost=1.62 rows=3) + -> Table scan on it3 (cost=1.62 rows=3) + -> Filter: (ot2.a = ot1.a) (cost=0.55 rows=4) + -> Table scan on ot2 (cost=0.55 rows=4) + -> Nested loop inner join (cost=49.53 rows=9) + -> Filter: (ot3.a = ot2.a) (cost=0.51 rows=3) + -> Table scan on ot3 (cost=0.51 rows=3) + -> Filter: (it3.a = ot2.a) (cost=1.51 rows=3) + -> Table scan on it3 (cost=1.51 rows=3) + +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3) +LEFT JOIN ot3 ON ot2.a=ot3.a AND ot3.a IN (SELECT a FROM it3); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it3) +LEFT JOIN ot3 ON ot2.a=ot3.a+0 AND ot3.a IN (SELECT a FROM it3); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +# Test cases, Subquery Pattern 4 +# Example SQ4.1: +explain SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +1 SIMPLE it1 NULL ALL NULL NULL NULL NULL 8 100.00 Using where; Start temporary; End temporary +1 SIMPLE ot3 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a`,`test`.`ot3`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` join `test`.`ot3` semi join (`test`.`it1`)) on(((`test`.`it1`.`a` = `test`.`ot1`.`a`) and (`test`.`ot3`.`a` = `test`.`ot1`.`a`) and (`test`.`ot2`.`a` = `test`.`ot1`.`a`))) where true +SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +# Example SQ4.2: +explain SELECT * +FROM ot1 +JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot3 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where +1 SIMPLE it1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; Start temporary; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a`,`test`.`ot3`.`a` AS `a` from `test`.`ot1` join `test`.`ot2` join `test`.`ot3` semi join (`test`.`it1`) where ((`test`.`ot2`.`a` = `test`.`ot3`.`a`) and (`test`.`ot1`.`a` = `test`.`ot3`.`a`) and (`test`.`it1`.`a` = `test`.`ot3`.`a`)) +SELECT * +FROM ot1 +JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +6 6 6 +# Example SQ4.3: +explain SELECT * +FROM ot1 +JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where +1 SIMPLE it1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; Start temporary; End temporary +1 SIMPLE ot3 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a`,`test`.`ot3`.`a` AS `a` from `test`.`ot1` join `test`.`ot2` left join `test`.`ot3` on((`test`.`ot3`.`a` = `test`.`ot2`.`a`)) semi join (`test`.`it1`) where ((`test`.`ot1`.`a` = `test`.`ot2`.`a`) and (`test`.`it1`.`a` = `test`.`ot2`.`a`)) +SELECT * +FROM ot1 +JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +2 2 NULL +4 4 NULL +6 6 6 +# Example SQ4.4: +explain SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +1 SIMPLE it1 NULL ALL NULL NULL NULL NULL 8 100.00 Using where; Start temporary; End temporary +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +1 SIMPLE ot3 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a`,`test`.`ot3`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` left join `test`.`ot3` on((`test`.`ot3`.`a` = `test`.`ot1`.`a`)) semi join (`test`.`it1`)) on(((`test`.`it1`.`a` = `test`.`ot1`.`a`) and (`test`.`ot2`.`a` = `test`.`ot1`.`a`))) where true +SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +1 NULL NULL +2 2 NULL +3 NULL NULL +4 4 NULL +5 NULL NULL +6 6 6 +7 NULL NULL +# More test cases +SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a+0) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it1); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 +JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a+0) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +6 6 6 +SELECT * +FROM ot1 +JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +6 6 6 +SELECT * +FROM ot1 +JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it1); +a a a +0 0 0 +6 6 6 +SELECT * +FROM ot1 +JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a+0) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +2 2 NULL +4 4 NULL +6 6 6 +SELECT * +FROM ot1 +JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +2 2 NULL +4 4 NULL +6 6 6 +SELECT * +FROM ot1 +JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it1); +a a a +0 0 0 +2 2 NULL +4 4 NULL +6 6 6 +SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a+0) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +1 NULL NULL +2 2 NULL +3 NULL NULL +4 4 NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +1 NULL NULL +2 2 NULL +3 NULL NULL +4 4 NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it1); +a a a +0 0 0 +1 NULL NULL +2 2 NULL +3 NULL NULL +4 4 NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1) +LEFT JOIN +ot1 AS ot4 +ON ot2.a=ot4.a; +a a a a +0 0 0 0 +1 NULL NULL NULL +2 2 NULL 2 +3 NULL NULL NULL +4 4 NULL 4 +5 NULL NULL NULL +6 6 6 6 +7 NULL NULL NULL +SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a +LEFT JOIN ot1 AS ot4 ON ot3.a=ot4.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a a +0 0 0 0 +1 NULL NULL NULL +2 2 NULL NULL +3 NULL NULL NULL +4 4 NULL NULL +5 NULL NULL NULL +6 6 6 6 +7 NULL NULL NULL +DROP TABLE ot1,ot2,ot3,it1,it2,it3; +CREATE TABLE t ( +a INTEGER DEFAULT NULL +) ENGINE=InnoDB; +INSERT INTO t VALUES (1); +CREATE TABLE t2 ( +a INTEGER DEFAULT NULL +) ENGINE=InnoDB; +INSERT INTO t2 VALUES (1),(1); +CREATE TABLE t4 ( +a INTEGER DEFAULT NULL +) ENGINE=InnoDB; +INSERT INTO t4 VALUES (1),(1); +CREATE TABLE v ( +a INTEGER DEFAULT NULL +) ENGINE=InnoDB; +INSERT INTO v VALUES (1),(1); +explain SELECT * +FROM t AS t1 +LEFT JOIN +(t2 +LEFT JOIN t AS t3 +ON t3.a IN (SELECT a FROM t AS it) +JOIN t4 +ON t4.a=100 +) +ON TRUE +WHERE t1.a IN (SELECT * FROM v AS it2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE it2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE it NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t4`.`a` AS `a` from `test`.`t` `t1` left join (`test`.`t2` left join (`test`.`t` `t3` semi join (`test`.`t` `it`)) on(((`test`.`it`.`a` = `test`.`t3`.`a`))) join `test`.`t4`) on(((`test`.`t4`.`a` = 100))) semi join (`test`.`v` `it2`) where (`test`.`it2`.`a` = `test`.`t1`.`a`) +SELECT * +FROM t AS t1 +LEFT JOIN +(t2 +LEFT JOIN t AS t3 +ON t3.a IN (SELECT a FROM t AS it) +JOIN t4 +ON t4.a=100 +) +ON TRUE +WHERE t1.a IN (SELECT * FROM v AS it2); +a a a a +1 NULL NULL NULL +DROP TABLE t,t2,t4,v; +# End of WL#5561 +# +# Bug#48868: Left outer join in subquery causes segmentation fault in +# make_join_select. +# +CREATE TABLE t1 (i INTEGER); +INSERT INTO t1 VALUES (1); +INSERT INTO t1 VALUES (2); +CREATE TABLE t2 (i INTEGER); +INSERT INTO t2 VALUES(1); +CREATE TABLE t3 (i INTEGER); +INSERT INTO t3 VALUES (1); +INSERT INTO t3 VALUES (2); +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t2.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +1 +DROP TABLE t1, t2, t3; + +Bug#37899: Wrongly checked optimization prerequisite caused failed +assertion. + +CREATE TABLE t1 ( +`pk` int(11), +`varchar_nokey` varchar(5) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES +(1,'qk'),(2,'j'),(3,'aew'); +SELECT * +FROM t1 +WHERE varchar_nokey IN ( +SELECT +varchar_nokey +FROM +t1 +) XOR pk = 30; +pk varchar_nokey +1 qk +2 j +3 aew +drop table t1; +# +# BUG#41842: Semi-join materialization strategy crashes when the upper query has HAVING +# +CREATE TABLE t1 ( +pk int(11) NOT NULL AUTO_INCREMENT, +int_nokey int(11) NOT NULL, +time_key time NOT NULL, +datetime_key datetime NOT NULL, +datetime_nokey datetime NOT NULL, +varchar_key varchar(1) NOT NULL, +varchar_nokey varchar(1) NOT NULL, +PRIMARY KEY (pk), +KEY time_key (time_key), +KEY datetime_key (datetime_key), +KEY varchar_key (varchar_key) +) ENGINE=MyISaM; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES +(1,0, '00:16:10','2008-09-03 14:25:40','2008-09-03 14:25:40','h','h'), +(2,7, '00:00:00','2001-01-13 00:00:00','2001-01-13 00:00:00','',''), +(3,0, '00:00:00','0000-00-00 00:00:00','0000-00-00 00:00:00','x','x'), +(4,2, '16:29:24','2000-10-16 01:39:08','2000-10-16 01:39:08','w','w'), +(5,1, '09:23:32','0000-00-00 00:00:00','0000-00-00 00:00:00','p','p'), +(6,3, '00:00:00','2007-12-02 00:00:00','2007-12-02 00:00:00','o','o'), +(7,3, '00:00:00','2008-09-11 00:00:00','2008-09-11 00:00:00','',''), +(8,0, '13:59:04','0000-00-00 00:00:00','0000-00-00 00:00:00','s','s'), +(9,7, '09:01:06','0000-00-00 00:00:00','0000-00-00 00:00:00','d','d'), +(10,5,'00:00:00','0000-00-00 00:00:00','0000-00-00 00:00:00','n','n'), +(11,0,'21:06:46','0000-00-00 00:00:00','0000-00-00 00:00:00','o','o'), +(12,2,'00:00:00','0000-00-00 00:00:00','0000-00-00 00:00:00','',''), +(13,6,'14:45:34','2003-07-28 02:34:08','2003-07-28 02:34:08','w','w'), +(14,1,'15:04:12','0000-00-00 00:00:00','0000-00-00 00:00:00','o','o'), +(15,0,'00:00:00','0000-00-00 00:00:00','0000-00-00 00:00:00','x','x'), +(16,0,'15:55:23','2004-03-17 00:32:27','2004-03-17 00:32:27','p','p'), +(17,1,'16:30:00','2004-12-27 19:20:00','2004-12-27 19:20:00','d','d'), +(18,0,'00:00:00','0000-00-00 00:00:00','0000-00-00 00:00:00','h','h'), +(19,0,'14:13:26','2008-11-09 05:53:48','2008-11-09 05:53:48','o','o'), +(20,0,'00:00:00','2009-10-11 06:58:04','2009-10-11 06:58:04','k','k'); +Warnings: +Warning 1264 Out of range value for column 'datetime_key' at row 3 +Warning 1264 Out of range value for column 'datetime_nokey' at row 3 +Warning 1264 Out of range value for column 'datetime_key' at row 5 +Warning 1264 Out of range value for column 'datetime_nokey' at row 5 +Warning 1264 Out of range value for column 'datetime_key' at row 8 +Warning 1264 Out of range value for column 'datetime_nokey' at row 8 +Warning 1264 Out of range value for column 'datetime_key' at row 9 +Warning 1264 Out of range value for column 'datetime_nokey' at row 9 +Warning 1264 Out of range value for column 'datetime_key' at row 10 +Warning 1264 Out of range value for column 'datetime_nokey' at row 10 +Warning 1264 Out of range value for column 'datetime_key' at row 11 +Warning 1264 Out of range value for column 'datetime_nokey' at row 11 +Warning 1264 Out of range value for column 'datetime_key' at row 12 +Warning 1264 Out of range value for column 'datetime_nokey' at row 12 +Warning 1264 Out of range value for column 'datetime_key' at row 14 +Warning 1264 Out of range value for column 'datetime_nokey' at row 14 +Warning 1264 Out of range value for column 'datetime_key' at row 15 +Warning 1264 Out of range value for column 'datetime_nokey' at row 15 +Warning 1264 Out of range value for column 'datetime_key' at row 18 +Warning 1264 Out of range value for column 'datetime_nokey' at row 18 +CREATE TABLE t2 ( +pk int(11) NOT NULL AUTO_INCREMENT, +int_nokey int(11) NOT NULL, +time_key time NOT NULL, +datetime_key datetime NOT NULL, +datetime_nokey datetime NOT NULL, +varchar_key varchar(1) NOT NULL, +varchar_nokey varchar(1) NOT NULL, +PRIMARY KEY (pk), +KEY time_key (time_key), +KEY datetime_key (datetime_key), +KEY varchar_key (varchar_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT IGNORE INTO t2 VALUES +(10,0,'19:39:13','0000-00-00 00:00:00','0000-00-00 00:00:00','g','g'), +(11,8,'03:43:53','0000-00-00 00:00:00','0000-00-00 00:00:00','b','b'); +Warnings: +Warning 1264 Out of range value for column 'datetime_key' at row 1 +Warning 1264 Out of range value for column 'datetime_nokey' at row 1 +Warning 1264 Out of range value for column 'datetime_key' at row 2 +Warning 1264 Out of range value for column 'datetime_nokey' at row 2 +SELECT OUTR.datetime_nokey AS X FROM t1 AS OUTR +WHERE +OUTR.varchar_nokey IN (SELECT +INNR . varchar_nokey AS Y +FROM t2 AS INNR +WHERE +INNR . datetime_key >= INNR . time_key OR +INNR . pk = INNR . int_nokey +) +AND OUTR . varchar_nokey <= 'w' +HAVING X > '2012-12-12'; +X +drop table t1, t2; + +Bug#46797 "Crash in fix_semijoin_strategies_for_picked_join_order +with semijoin=on" + +CREATE TABLE t1 ( +varchar_key varchar(1) DEFAULT NULL, +KEY varchar_key (varchar_key) +); +CREATE TABLE t2 ( +varchar_key varchar(1) DEFAULT NULL, +KEY varchar_key (varchar_key) +); +INSERT INTO t2 VALUES +(NULL),(NULL),(NULL),(NULL),('a'),('a'),('a'),('b'),('b'),('b'),('b'),('c'), +('c'),('c'),('c'),('c'),('c'),('c'),('d'),('d'),('d'),('d'),('d'),('d'),('e'), +('e'),('e'),('e'),('e'),('e'),('f'),('f'),('f'),('g'),('g'),('h'),('h'),('h'), +('h'),('i'),('j'),('j'),('j'),('k'),('k'),('l'),('l'),('m'),('m'),('m'),('m'), +('n'),('n'),('n'),('o'),('o'),('o'),('p'),('p'),('p'),('q'),('q'),('q'),('r'), +('r'),('r'),('r'),('s'),('s'),('s'),('s'),('t'),('t'),('t'),('t'),('u'),('u'), +('u'),('u'),('v'),('v'),('v'),('v'),('w'),('w'),('w'),('w'),('w'),('w'),('x'), +('x'),('x'),('y'),('y'),('y'),('y'),('z'),('z'),('z'),('z'); +CREATE TABLE t3 ( +varchar_key varchar(1) DEFAULT NULL, +KEY varchar_key (varchar_key) +) ENGINE=MyISAM DEFAULT CHARSET=latin1; +INSERT INTO t3 VALUES +(NULL),('c'),('d'),('e'),('f'),('h'),('j'),('k'),('k'),('m'),('m'),('m'), +('n'),('o'),('r'),('t'),('t'),('u'),('w'),('y'); +SELECT varchar_key FROM t3 +WHERE (SELECT varchar_key FROM t3 +WHERE (varchar_key,varchar_key) +IN (SELECT t1.varchar_key, t2 .varchar_key +FROM t1 RIGHT JOIN t2 ON t1.varchar_key +) +); +varchar_key +DROP TABLE t1, t2, t3; +# +# Bug#46556 Returning incorrect, empty results for some IN subqueries +# w/semijoin=on +# +CREATE TABLE t0 ( +pk INTEGER, +vkey VARCHAR(1), +vnokey VARCHAR(1), +PRIMARY KEY (pk), +KEY vkey(vkey) +) charset utf8mb4; +INSERT INTO t0 +VALUES (1,'g','g'), (2,'v','v'), (3,'t','t'), (4,'u','u'), (5,'n','n'); +EXPLAIN SELECT vkey FROM t0 WHERE pk IN +(SELECT t1.pk FROM t0 t1 JOIN t0 t2 ON t2.vkey = t1.vnokey); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL ALL PRIMARY NULL NULL NULL 5 100.00 NULL +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t0.pk 1 100.00 Using where +1 SIMPLE t2 NULL ref vkey vkey 7 test.t1.vnokey 2 100.00 Using index; Start temporary; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`vkey` AS `vkey` from `test`.`t0` `t1` join `test`.`t0` semi join (`test`.`t0` `t2`) where ((`test`.`t2`.`vkey` = `test`.`t1`.`vnokey`) and (`test`.`t1`.`pk` = `test`.`t0`.`pk`)) +SELECT vkey FROM t0 WHERE pk IN +(SELECT t1.pk FROM t0 t1 JOIN t0 t2 ON t2.vkey = t1.vnokey); +vkey +g +n +t +u +v +DROP TABLE t0; +# End of bug#46556 + +Bug#48834: Procedure with view + subquery + semijoin=on +crashes on second call. + +CREATE TABLE t1 ( t1field integer, primary key (t1field)); +CREATE TABLE t2 ( t2field integer, primary key (t2field)); +CREATE VIEW v1 AS +SELECT t1field as v1field +FROM t1 A +WHERE A.t1field IN (SELECT t1field FROM t2 ); +CREATE VIEW v2 AS +SELECT t2field as v2field +FROM t2 A +WHERE A.t2field IN (SELECT t2field FROM t2 ); +CREATE PROCEDURE p1 () +BEGIN +SELECT v1field +FROM v1 +WHERE v1field IN ( SELECT v2field as vf_inner FROM v2 ); +END| +INSERT INTO t1 VALUES (1),(2),(3); +INSERT INTO t2 VALUES (2),(3),(4); +CALL p1; +v1field +2 +3 +CALL p1; +v1field +2 +3 +DROP TABLE t1,t2; +DROP VIEW v1,v2; +DROP PROCEDURE p1; +# End of BUG#48834 +# +# Bug#46692 "Crash occurring on queries with nested FROM subqueries +# using materialization." +# +CREATE TABLE t1 ( +pk INTEGER PRIMARY KEY, +int_key INTEGER, +KEY int_key(int_key) +); +INSERT INTO t1 VALUES (10,186),(11,NULL),(12,2),(13,3),(14,0),(15,133),(16,1); +CREATE TABLE t2 ( +pk INTEGER PRIMARY KEY, +int_key INTEGER, +KEY int_key(int_key) +); +INSERT INTO t2 VALUES (1,7),(2,2); +SELECT * FROM t1 WHERE (140, 4) IN +(SELECT t2.int_key, t2 .pk FROM t2 STRAIGHT_JOIN t1 ON t2.int_key); +pk int_key +DROP TABLE t1, t2; +# +# Bug#42353 "SELECT ... WHERE oe IN (SELECT w/ LEFT JOIN) query +# causes crash." +# +CREATE TABLE t1 ( +pk INTEGER PRIMARY KEY, +int_nokey INTEGER, +int_key INTEGER, +date_key DATE, +datetime_nokey DATETIME, +varchar_nokey VARCHAR(1) +); +CREATE TABLE t2 ( +date_nokey DATE +); +CREATE TABLE t3 ( +pk INTEGER PRIMARY KEY, +int_nokey INTEGER, +date_key date, +varchar_key VARCHAR(1), +varchar_nokey VARCHAR(1), +KEY date_key (date_key) +); +SELECT date_key FROM t1 +WHERE (int_key, int_nokey) +IN (SELECT t3.int_nokey, t3.pk +FROM t2 LEFT JOIN t3 ON (t2.date_nokey < t3.date_key) +WHERE t3.varchar_key <= t3.varchar_nokey OR t3.int_nokey <= t3.pk +) +AND (varchar_nokey <> 'f' OR NOT int_key < 7); +date_key +# +# Bug#45933 "Crash in optimize_semijoin_nests on JOIN in subquery +# + AND in outer query". +# +INSERT INTO t1 VALUES (10,7,5,'2009-06-16','2002-04-10 14:25:30','w'), +(11,7,0,'0000-00-00','0000-00-00 00:00:00','s'), +(12,4,0,'2003-07-14','2006-09-14 04:01:02','y'), +(13,0,4,'2002-07-25','0000-00-00 00:00:00','c'), +(14,1,8,'2007-07-03','0000-00-00 00:00:00','q'), +(15,6,5,'2001-11-12','0000-00-00 00:00:00',''), +(16,2,9,'0000-00-00','0000-00-00 00:00:00','j'), +(29,9,1,'0000-00-00','2003-08-11 00:00:00','m'); +Warnings: +Warning 1264 Out of range value for column 'date_key' at row 2 +Warning 1264 Out of range value for column 'datetime_nokey' at row 2 +Warning 1264 Out of range value for column 'datetime_nokey' at row 4 +Warning 1264 Out of range value for column 'datetime_nokey' at row 5 +Warning 1264 Out of range value for column 'datetime_nokey' at row 6 +Warning 1264 Out of range value for column 'date_key' at row 7 +Warning 1264 Out of range value for column 'datetime_nokey' at row 7 +Warning 1264 Out of range value for column 'date_key' at row 8 +INSERT IGNORE INTO t3 VALUES (1,9,'0000-00-00','b','b'), +(2,2,'2002-09-17','h','h'); +Warnings: +Warning 1264 Out of range value for column 'date_key' at row 1 +SELECT t1.varchar_nokey FROM t1 JOIN t3 ON t1.datetime_nokey +WHERE t1.varchar_nokey +IN (SELECT varchar_nokey FROM t1 +WHERE (pk) +IN (SELECT t3.int_nokey +FROM t3 LEFT JOIN t1 ON t1.varchar_nokey +WHERE t3.date_key BETWEEN '2008-06-07' AND '2006-06-26' + ) +); +varchar_nokey +DROP TABLE t1, t2, t3; +# +# Bug#45219 "Crash on SELECT DISTINCT query containing a +# LEFT JOIN in subquery" +# +CREATE TABLE t1 ( +pk INTEGER NOT NULL, +int_nokey INTEGER NOT NULL, +datetime_key DATETIME NOT NULL, +varchar_key VARCHAR(1) NOT NULL, +PRIMARY KEY (pk), +KEY datetime_key (datetime_key), +KEY varchar_key (varchar_key) +); +INSERT IGNORE INTO t1 VALUES +(1,9,'0000-00-00 00:00:00','p'),(2,0,'2002-02-09 07:38:13','v'), +(3,8,'2001-05-03 12:08:14','t'),(4,3,'0000-00-00 00:00:00','u'), +(5,7,'2009-07-28 03:43:30','n'),(6,0,'2009-08-04 00:00:00','l'), +(7,1,'0000-00-00 00:00:00','h'),(8,9,'0000-00-00 00:00:00','u'), +(9,0,'2005-08-02 17:16:54','n'),(10,9,'2002-12-21 00:00:00','j'), +(11,0,'2005-08-15 12:37:35','k'),(12,5,'0000-00-00 00:00:00','e'), +(13,0,'2006-03-10 00:00:00','i'),(14,8,'2005-05-16 11:02:36','u'), +(15,8,'2008-11-02 00:00:00','n'),(16,5,'2006-03-15 00:00:00','b'), +(17,1,'0000-00-00 00:00:00','x'),(18,7,'0000-00-00 00:00:00',''), +(19,0,'2008-12-17 20:15:40','q'),(20,9,'0000-00-00 00:00:00','u'); +Warnings: +Warning 1264 Out of range value for column 'datetime_key' at row 1 +Warning 1264 Out of range value for column 'datetime_key' at row 4 +Warning 1264 Out of range value for column 'datetime_key' at row 7 +Warning 1264 Out of range value for column 'datetime_key' at row 8 +Warning 1264 Out of range value for column 'datetime_key' at row 12 +Warning 1264 Out of range value for column 'datetime_key' at row 17 +Warning 1264 Out of range value for column 'datetime_key' at row 18 +Warning 1264 Out of range value for column 'datetime_key' at row 20 +CREATE TABLE t2 LIKE t1; +INSERT INTO t2 VALUES +(10,0,'2006-07-07 07:26:28','q'),(11,5,'2002-09-23 00:00:00','m'), +(12,7,'0000-00-00 00:00:00','j'),(13,1,'2006-06-07 00:00:00','z'), +(14,8,'2000-09-16 12:15:34','a'),(15,2,'2007-08-05 15:47:52',''), +(16,1,'0000-00-00 00:00:00','e'),(17,8,'2005-12-02 19:34:26','t'), +(18,5,'0000-00-00 00:00:00','q'),(19,4,'0000-00-00 00:00:00','b'), +(20,5,'2007-12-28 00:00:00','w'),(21,3,'2004-08-02 11:48:43','m'), +(22,0,'0000-00-00 00:00:00','x'),(23,8,'2004-04-19 12:18:43',''), +(24,0,'2009-04-27 00:00:00','w'),(25,4,'2006-10-20 14:52:15','x'), +(26,0,'0000-00-00 00:00:00','e'),(27,0,'2002-03-22 11:48:37','e'), +(28,2,'0000-00-00 00:00:00','p'),(29,0,'2001-01-04 03:55:07','x'); +Warnings: +Warning 1264 Out of range value for column 'datetime_key' at row 3 +Warning 1264 Out of range value for column 'datetime_key' at row 7 +Warning 1264 Out of range value for column 'datetime_key' at row 9 +Warning 1264 Out of range value for column 'datetime_key' at row 10 +Warning 1264 Out of range value for column 'datetime_key' at row 13 +Warning 1264 Out of range value for column 'datetime_key' at row 17 +Warning 1264 Out of range value for column 'datetime_key' at row 19 +CREATE TABLE t3 LIKE t1; +INSERT INTO t3 VALUES +(10,8,'2007-08-19 08:08:38','i'),(11,0,'2000-05-21 03:51:51',''); +SELECT DISTINCT datetime_key FROM t1 +WHERE (int_nokey, pk) +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#46550 Azalea returning duplicate results for some IN subqueries +# w/ semijoin=on +# +DROP TABLE IF EXISTS t0, t1, t2; +CREATE TABLE t0 ( +int_key int(11) DEFAULT NULL, +varchar_key varchar(1) DEFAULT NULL, +varchar_nokey varchar(1) DEFAULT NULL, +KEY int_key (int_key), +KEY varchar_key (varchar_key,int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t0 VALUES +(1,'m','m'), +(40,'h','h'), +(1,'r','r'), +(1,'h','h'), +(9,'x','x'), +(NULL,'q','q'), +(NULL,'k','k'), +(7,'l','l'), +(182,'k','k'), +(202,'a','a'), +(7,'x','x'), +(6,'j','j'), +(119,'z','z'), +(4,'d','d'), +(5,'h','h'), +(1,'u','u'), +(3,'q','q'), +(7,'a','a'), +(3,'e','e'), +(6,'l','l'); +CREATE TABLE t1 ( +int_key int(11) DEFAULT NULL, +varchar_key varchar(1) DEFAULT NULL, +varchar_nokey varchar(1) DEFAULT NULL, +KEY int_key (int_key), +KEY varchar_key (varchar_key,int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (7,NULL,NULL),(4,'x','x'); +CREATE TABLE t2 ( +int_key int(11) DEFAULT NULL, +varchar_key varchar(1) DEFAULT NULL, +varchar_nokey varchar(1) DEFAULT NULL, +KEY int_key (int_key), +KEY varchar_key (varchar_key,int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (123,NULL,NULL); +SELECT int_key +FROM t0 +WHERE varchar_nokey IN ( +SELECT t1 .varchar_key from t1 +); +int_key +7 +9 +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 +7 +9 +EXPLAIN +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 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1_1 NULL index varchar_key varchar_key 12 NULL 2 50.00 Using where; Using index; Start temporary +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 20 10.00 Using where +1 SIMPLE t1_2 NULL index NULL int_key 5 NULL 2 100.00 Using index; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`int_key` AS `int_key` from `test`.`t0` semi join (`test`.`t1` `t1_1` join `test`.`t1` `t1_2`) where ((`test`.`t0`.`varchar_nokey` = `test`.`t1_1`.`varchar_key`) and (0 <> `test`.`t1_1`.`int_key`)) +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 +7 +9 +EXPLAIN +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 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t1_1 NULL index varchar_key varchar_key 12 NULL 2 50.00 Using where; Using index; Start temporary +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 20 10.00 Using where +1 SIMPLE t1_2 NULL index NULL int_key 5 NULL 2 100.00 Using index; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`int_key` AS `int_key` from `test`.`t0` semi join (`test`.`t1` `t1_1` join `test`.`t1` `t1_2`) where ((`test`.`t0`.`varchar_nokey` = `test`.`t1_1`.`varchar_key`) and (0 <> `test`.`t1_1`.`int_key`)) +DROP TABLE t0, t1, t2; +# End of bug#46550 + +Bug #48073 Subquery on char columns from view crashes Mysql + +DROP TABLE IF EXISTS t1, t2; +DROP VIEW IF EXISTS v1; +CREATE TABLE t1 ( +city VARCHAR(50) NOT NULL, +country_id SMALLINT UNSIGNED NOT NULL +); +INSERT INTO t1 VALUES +('Batna',2), +('Bchar',2), +('Skikda',2), +('Tafuna',3), +('Algeria',2) ; +CREATE TABLE t2 ( +country_id SMALLINT UNSIGNED NOT NULL, +country VARCHAR(50) NOT NULL +); +INSERT INTO t2 VALUES +(2,'Algeria'), +(3,'American Samoa') ; +CREATE VIEW v1 AS +SELECT country_id, country +FROM t2 +WHERE LEFT(country,1) = "A" +; +SELECT city, country_id +FROM t1 +WHERE city IN ( +SELECT country +FROM t2 +WHERE LEFT(country, 1) = "A" +); +city country_id +Algeria 2 +SELECT city, country_id +FROM t1 +WHERE city IN ( +SELECT country +FROM v1 +); +city country_id +Algeria 2 +drop table t1, t2; +drop view v1; +# End of bug#48073 + +Bug#49097 subquery with view generates wrong result with +non-prepared statement + +DROP TABLE IF EXISTS t1, t2; +DROP VIEW IF EXISTS v1; +CREATE TABLE t1 ( +city VARCHAR(50) NOT NULL, +country_id SMALLINT UNSIGNED NOT NULL +); +INSERT INTO t1 VALUES +('Batna',2), +('Bchar',2), +('Skikda',2), +('Tafuna',3), +('Algeria',2) ; +CREATE TABLE t2 ( +country_id SMALLINT UNSIGNED NOT NULL, +country VARCHAR(50) NOT NULL +); +INSERT INTO t2 VALUES +(2,'Algeria'), +(3,'XAmerican Samoa') ; +CREATE VIEW v1 AS +SELECT country_id, country +FROM t2 +WHERE LEFT(country,1) = "A" +; +SELECT city, country_id +FROM t1 +WHERE country_id IN ( +SELECT country_id +FROM t2 +WHERE LEFT(country,1) = "A" +); +city country_id +Algeria 2 +Batna 2 +Bchar 2 +Skikda 2 +SELECT city, country_id +FROM t1 +WHERE country_id IN ( +SELECT country_id +FROM v1 +); +city country_id +Algeria 2 +Batna 2 +Bchar 2 +Skikda 2 +PREPARE stmt FROM +" +SELECT city, country_id +FROM t1 +WHERE country_id IN ( + SELECT country_id + FROM v1 +); +"; +execute stmt; +city country_id +Algeria 2 +Batna 2 +Bchar 2 +Skikda 2 +deallocate prepare stmt; +drop table t1, t2; +drop view v1; +# End of Bug#49097 +# +# Bug#49198 Wrong result for second call of procedure +# with view in subselect. +# +CREATE TABLE t1 (t1field integer, primary key (t1field)); +CREATE TABLE t2 (t2field integer, primary key (t2field)); +CREATE TABLE t3 (t3field integer, primary key (t3field)); +CREATE VIEW v2 AS SELECT * FROM t2; +CREATE VIEW v3 AS SELECT * FROM t3; +INSERT INTO t1 VALUES(1),(2); +INSERT INTO t2 VALUES(1),(2); +INSERT INTO t3 VALUES(1),(2); +PREPARE stmt FROM +" +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT * FROM v2); +"; +EXECUTE stmt; +t1field +1 +2 + +EXECUTE stmt; +t1field +1 +2 +PREPARE stmt FROM +" +EXPLAIN +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT * FROM v2) + AND t1field IN (SELECT * FROM v3) +"; +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index PRIMARY PRIMARY 4 NULL 2 100.00 Using index +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +1 SIMPLE t3 NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`t1field` AS `t1field` from `test`.`t2` join `test`.`t3` join `test`.`t1` where ((`test`.`t2`.`t2field` = `test`.`t1`.`t1field`) and (`test`.`t3`.`t3field` = `test`.`t1`.`t1field`)) + +This line is only in place to help --skip_if_hypergraph diffing some more. + +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index PRIMARY PRIMARY 4 NULL 2 100.00 Using index +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +1 SIMPLE t3 NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`t1field` AS `t1field` from `test`.`t2` join `test`.`t3` join `test`.`t1` where ((`test`.`t2`.`t2field` = `test`.`t1`.`t1field`) and (`test`.`t3`.`t3field` = `test`.`t1`.`t1field`)) +DROP TABLE t1, t2, t3; +DROP VIEW v2, v3; +# End of Bug#49198 +# +# Bug#48623 Multiple subqueries are optimized incorrectly +# +CREATE TABLE ot(val VARCHAR(10)) charset utf8mb4; +CREATE TABLE it1(val VARCHAR(10)) charset utf8mb4; +CREATE TABLE it2(val VARCHAR(10)) charset utf8mb4; +INSERT INTO ot VALUES('aaa'), ('bbb'), ('eee'), ('mmm'), ('ppp'); +INSERT INTO it1 VALUES('aaa'), ('aaa'), ('bbb'), ('eee'), ('mmm'), ('ppp'); +INSERT INTO it2 VALUES('aaa'), ('bbb'), ('eee'), ('mmm'), ('ppp'); +EXPLAIN +SELECT * +FROM ot +WHERE ot.val IN (SELECT it1.val FROM it1 +WHERE it1.val LIKE 'a%' OR it1.val LIKE 'e%') +AND ot.val IN (SELECT it2.val FROM it2 +WHERE it2.val LIKE 'a%' OR it2.val LIKE 'e%'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE it2 NULL ALL NULL NULL NULL NULL 5 36.00 Using where; Start temporary +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 5 20.00 Using where +1 SIMPLE it1 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`ot`.`val` AS `val` from `test`.`ot` semi join (`test`.`it1`) semi join (`test`.`it2`) where ((`test`.`ot`.`val` = `test`.`it2`.`val`) and (`test`.`it1`.`val` = `test`.`it2`.`val`) and ((`test`.`it1`.`val` like 'a%') or (`test`.`it1`.`val` like 'e%')) and ((`test`.`it2`.`val` like 'a%') or (`test`.`it2`.`val` like 'e%'))) +SELECT * +FROM ot +WHERE ot.val IN (SELECT it1.val FROM it1 +WHERE it1.val LIKE 'a%' OR it1.val LIKE 'e%') +AND ot.val IN (SELECT it2.val FROM it2 +WHERE it2.val LIKE 'a%' OR it2.val LIKE 'e%'); +val +aaa +eee +DROP TABLE ot; +DROP TABLE it1; +DROP TABLE it2; +# End of Bug#48623 +# +# Bug #51487 Assertion failure when semi-join flattening occurs +# for a subquery in HAVING +# +CREATE TABLE t1 (a INT, b INT); +INSERT INTO t1 VALUES (1,10),(2,11),(1,13); +CREATE TABLE t2 AS SELECT * FROM t1; +CREATE TABLE t3 AS SELECT * FROM t1; +SELECT COUNT(*) FROM t1 +GROUP BY t1.a +HAVING t1.a IN (SELECT t3.a FROM t3 +WHERE t3.b IN (SELECT b FROM t2 WHERE t2.a=t1.a)); +COUNT(*) +2 +1 +DROP TABLE t1, t2, t3; +# End of Bug#51487 +# +# BUG#38075: Wrong result: rows matching a subquery with outer join not returned +# +DROP TABLE IF EXISTS ot1, it1, it2; +CREATE TABLE it2 ( +int_key int(11) NOT NULL, +datetime_key datetime NOT NULL, +KEY int_key (int_key), +KEY datetime_key (datetime_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO it2 VALUES +(5,'2002-04-10 14:25:30'), (0,'0000-00-00 00:00:00'), +(0,'2006-09-14 04:01:02'), (4,'0000-00-00 00:00:00'), +(8,'0000-00-00 00:00:00'), (5,'0000-00-00 00:00:00'), +(9,'0000-00-00 00:00:00'), (8,'2007-04-01 11:04:17'), +(1,'0000-00-00 00:00:00'), (7,'2009-01-12 00:00:00'), +(0,'2009-06-05 00:00:00'), (3,'2006-02-14 18:06:35'), +(5,'2006-02-21 07:08:16'), (0,'0000-00-00 00:00:00'), +(7,'0000-00-00 00:00:00'), (0,'0000-00-00 00:00:00'), +(0,'2007-02-13 00:00:00'), (1,'0000-00-00 00:00:00'), +(0,'0000-00-00 00:00:00'), (1,'2003-08-11 00:00:00'); +Warnings: +Warning 1264 Out of range value for column 'datetime_key' at row 2 +Warning 1264 Out of range value for column 'datetime_key' at row 4 +Warning 1264 Out of range value for column 'datetime_key' at row 5 +Warning 1264 Out of range value for column 'datetime_key' at row 6 +Warning 1264 Out of range value for column 'datetime_key' at row 7 +Warning 1264 Out of range value for column 'datetime_key' at row 9 +Warning 1264 Out of range value for column 'datetime_key' at row 14 +Warning 1264 Out of range value for column 'datetime_key' at row 15 +Warning 1264 Out of range value for column 'datetime_key' at row 16 +Warning 1264 Out of range value for column 'datetime_key' at row 18 +Warning 1264 Out of range value for column 'datetime_key' at row 19 +CREATE TABLE ot1 ( +int_nokey int(11) NOT NULL, +int_key int(11) NOT NULL, +KEY int_key (int_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO ot1 VALUES +(5,0), (3,0), (0,2), (3,0), (1,3), (0,0), (1,7), (7,0), (1,7), (0,7), +(0,9), (8,2), (4,4), (9,3), (0,9), (2,5), (0,5), (8,0), (5,8), (1,5); +CREATE TABLE it1 ( +int_nokey int(11) NOT NULL, +int_key int(11) NOT NULL, +KEY int_key (int_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO it1 VALUES +(9,5), (0,4); +SELECT int_key FROM ot1 +WHERE int_nokey IN (SELECT it2.int_key +FROM it1 LEFT JOIN it2 ON it2.datetime_key); +int_key +0 +0 +0 +0 +0 +0 +2 +2 +3 +5 +5 +7 +7 +7 +8 +9 +9 +EXPLAIN +SELECT int_key FROM ot1 +WHERE int_nokey IN (SELECT it2.int_key +FROM it1 LEFT JOIN it2 ON it2.datetime_key); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE it1 NULL index NULL int_key 4 NULL 2 100.00 Using index; Start temporary +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 20 100.00 NULL +1 SIMPLE it2 NULL ref int_key int_key 4 test.ot1.int_nokey 2 90.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`int_key` AS `int_key` from `test`.`ot1` semi join (`test`.`it1` join `test`.`it2`) where ((`test`.`it2`.`int_key` = `test`.`ot1`.`int_nokey`) and (TIMESTAMP'0000-00-00 00:00:00' <> `test`.`it2`.`datetime_key`)) +DROP TABLE ot1, it1, it2; +# End of BUG#38075 +# +# BUG#50089: Second call of procedure with view in subselect crashes server +# +CREATE TABLE t1(t1field INTEGER, PRIMARY KEY(t1field)); +CREATE VIEW v1 AS +SELECT t1field AS v1field +FROM t1 a +WHERE a.t1field IN (SELECT t1field FROM t1); +INSERT INTO t1 VALUES(1),(2); +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT v1field FROM v1); +t1field +1 +2 +EXPLAIN +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT v1field FROM v1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index PRIMARY PRIMARY 4 NULL 2 100.00 Using index +1 SIMPLE a NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `t1`.`t1field` AS `t1field` from `test`.`t1` `a` join `test`.`t1` join `test`.`t1` where ((`test`.`a`.`t1field` = `t1`.`t1field`) and (`test`.`t1`.`t1field` = `t1`.`t1field`)) +SELECT t1.t1field +FROM t1 LEFT JOIN t1 AS t2 ON t1.t1field IN (SELECT v1field FROM v1); +t1field +1 +1 +2 +2 +EXPLAIN +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT v1field FROM v1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index PRIMARY PRIMARY 4 NULL 2 100.00 Using index +1 SIMPLE a NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `t1`.`t1field` AS `t1field` from `test`.`t1` `a` join `test`.`t1` join `test`.`t1` where ((`test`.`a`.`t1field` = `t1`.`t1field`) and (`test`.`t1`.`t1field` = `t1`.`t1field`)) +CREATE PROCEDURE p1() +BEGIN +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT v1field FROM v1); +END| +CALL p1; +t1field +1 +2 +CALL p1; +t1field +1 +2 +PREPARE stmt FROM +" +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT v1field FROM v1); +"; +EXECUTE stmt; +t1field +1 +2 + +EXECUTE stmt; +t1field +1 +2 +DROP PROCEDURE p1; +DROP VIEW v1; +DROP TABLE t1; +# End of BUG#50089 +# +# Bug#45191: Incorrectly initialized semi-join led to a wrong result. +# +CREATE TABLE staff (EMPNUM CHAR(3) NOT NULL, +EMPNAME CHAR(20), GRADE DECIMAL(4), CITY CHAR(15)) charset latin1; +CREATE TABLE proj (PNUM CHAR(3) NOT NULL, +PNAME CHAR(20), PTYPE CHAR(6), +BUDGET DECIMAL(9), +CITY CHAR(15)) charset latin1; +CREATE TABLE works (EMPNUM CHAR(3) NOT NULL, +PNUM CHAR(3) NOT NULL, HOURS DECIMAL(5)) charset latin1; +INSERT INTO staff VALUES ('E1','Alice',12,'Deale'); +INSERT INTO staff VALUES ('E2','Betty',10,'Vienna'); +INSERT INTO staff VALUES ('E3','Carmen',13,'Vienna'); +INSERT INTO staff VALUES ('E4','Don',12,'Deale'); +INSERT INTO staff VALUES ('E5','Ed',13,'Akron'); +INSERT INTO proj VALUES ('P1','MXSS','Design',10000,'Deale'); +INSERT INTO proj VALUES ('P2','CALM','Code',30000,'Vienna'); +INSERT INTO proj VALUES ('P3','SDP','Test',30000,'Tampa'); +INSERT INTO proj VALUES ('P4','SDP','Design',20000,'Deale'); +INSERT INTO proj VALUES ('P5','IRM','Test',10000,'Vienna'); +INSERT INTO proj VALUES ('P6','PAYR','Design',50000,'Deale'); +INSERT INTO works VALUES ('E1','P1',40); +INSERT INTO works VALUES ('E1','P2',20); +INSERT INTO works VALUES ('E1','P3',80); +INSERT INTO works VALUES ('E1','P4',20); +INSERT INTO works VALUES ('E1','P5',12); +INSERT INTO works VALUES ('E1','P6',12); +INSERT INTO works VALUES ('E2','P1',40); +INSERT INTO works VALUES ('E2','P2',80); +INSERT INTO works VALUES ('E3','P2',20); +INSERT INTO works VALUES ('E4','P2',20); +INSERT INTO works VALUES ('E4','P4',40); +INSERT INTO works VALUES ('E4','P5',80); +explain SELECT EMPNUM, EMPNAME +FROM staff +WHERE EMPNUM IN +(SELECT EMPNUM FROM works +WHERE PNUM IN +(SELECT PNUM FROM proj)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE staff NULL ALL NULL NULL NULL NULL 5 100.00 NULL +1 SIMPLE works NULL ALL NULL NULL NULL NULL 12 10.00 Using where; Start temporary +1 SIMPLE proj NULL ALL NULL NULL NULL NULL 6 16.67 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`staff`.`EMPNUM` AS `EMPNUM`,`test`.`staff`.`EMPNAME` AS `EMPNAME` from `test`.`staff` semi join (`test`.`works` join `test`.`proj`) where ((`test`.`works`.`EMPNUM` = `test`.`staff`.`EMPNUM`) and (`test`.`proj`.`PNUM` = `test`.`works`.`PNUM`)) +SELECT EMPNUM, EMPNAME +FROM staff +WHERE EMPNUM IN +(SELECT EMPNUM FROM works +WHERE PNUM IN +(SELECT PNUM FROM proj)); +EMPNUM EMPNAME +E1 Alice +E2 Betty +E3 Carmen +E4 Don +drop table staff,works,proj; +# End of bug#45191 +# +# BUG#36896: Server crash on SELECT FROM DUAL +# +create table t1 (a int); +select 1 as res from dual where (1) in (select * from t1); +res +drop table t1; + +BUG#40118 Crash when running Batched Key Access and requiring one match for each key + +create table t0(a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (a int, key(a)); +insert into t1 select * from t0; +alter table t1 add b int not null, add filler char(200); +insert into t1 select * from t1; +insert into t1 select * from t1; +select * from t0 where t0.a in (select t1.a from t1 where t1.b=0); +a +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +drop table t0, t1; +# +# BUG#32665 Query with dependent subquery is too slow +# +create table t1 ( +idIndividual int primary key +); +insert into t1 values (1),(2); +create table t2 ( +idContact int primary key, +contactType int, +idObj int +); +insert into t2 values (1,1,1),(2,2,2),(3,3,3); +create table t3 ( +idAddress int primary key, +idContact int, +postalStripped varchar(100) +); +insert into t3 values (1,1, 'foo'), (2,2,'bar'); +The following must be converted to a semi-join: +explain SELECT a.idIndividual FROM t1 a +WHERE a.idIndividual IN +( SELECT c.idObj FROM t3 cona +INNER JOIN t2 c ON c.idContact=cona.idContact +WHERE cona.postalStripped='T2H3B2' + ); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE cona NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE c NULL eq_ref PRIMARY PRIMARY 4 test.cona.idContact 1 100.00 Using where +1 SIMPLE a NULL eq_ref PRIMARY PRIMARY 4 test.c.idObj 1 100.00 Using index; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`a`.`idIndividual` AS `idIndividual` from `test`.`t1` `a` semi join (`test`.`t3` `cona` join `test`.`t2` `c`) where ((`test`.`c`.`idContact` = `test`.`cona`.`idContact`) and (`test`.`a`.`idIndividual` = `test`.`c`.`idObj`) and (`test`.`cona`.`postalStripped` = 'T2H3B2')) +drop table t1,t2,t3; +CREATE TABLE t1 (one int, two int, flag char(1)); +CREATE TABLE t2 (one int, two int, flag char(1)); +INSERT INTO t1 VALUES(1,2,'Y'),(2,3,'Y'),(3,4,'Y'),(5,6,'N'),(7,8,'N'); +INSERT INTO t2 VALUES(1,2,'Y'),(2,3,'Y'),(3,4,'Y'),(5,6,'N'),(7,8,'N'); +SELECT * FROM t1 +WHERE ROW(one,two) IN (SELECT DISTINCT one,two FROM t2 WHERE flag = 'N'); +one two flag +5 6 N +7 8 N +SELECT * FROM t1 +WHERE ROW(one,two) IN (SELECT DISTINCT one,two FROM t1 WHERE flag = 'N'); +one two flag +5 6 N +7 8 N +insert into t2 values (null,null,'N'); +insert into t2 values (null,3,'0'); +insert into t2 values (null,5,'0'); +insert into t2 values (10,null,'0'); +insert into t1 values (10,3,'0'); +insert into t1 values (10,5,'0'); +insert into t1 values (10,10,'0'); +SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = 'N') as 'test' from t1; +one two test +1 2 NULL +2 3 NULL +3 4 NULL +5 6 1 +7 8 1 +10 3 NULL +10 5 NULL +10 10 NULL +SELECT one,two from t1 where ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = 'N'); +one two +5 6 +7 8 +SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = 'N' group by one,two) as 'test' from t1; +one two test +1 2 NULL +2 3 NULL +3 4 NULL +5 6 1 +7 8 1 +10 3 NULL +10 5 NULL +10 10 NULL +SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = '0') as 'test' from t1; +one two test +1 2 0 +2 3 NULL +3 4 0 +5 6 0 +7 8 0 +10 3 NULL +10 5 NULL +10 10 NULL +SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = '0' group by one,two) as 'test' from t1; +one two test +1 2 0 +2 3 NULL +3 4 0 +5 6 0 +7 8 0 +10 3 NULL +10 5 NULL +10 10 NULL +explain SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = '0') as 'test' from t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 9 11.11 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`one` AS `one`,`test`.`t1`.`two` AS `two`,((`test`.`t1`.`one`,`test`.`t1`.`two`),(/* select#2 */ select `test`.`t2`.`one`,`test`.`t2`.`two` from `test`.`t2` where ((`test`.`t2`.`flag` = '0') and (outer_field_is_not_null, (((`test`.`t1`.`one`) = `test`.`t2`.`one`) or (`test`.`t2`.`one` is null)), true) and (outer_field_is_not_null, (((`test`.`t1`.`two`) = `test`.`t2`.`two`) or (`test`.`t2`.`two` is null)), true)) having ((outer_field_is_not_null, (`test`.`t2`.`one`), true) and (outer_field_is_not_null, (`test`.`t2`.`two`), true)))) AS `test` from `test`.`t1` +explain SELECT one,two from t1 where ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = 'N'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 9 11.11 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`one` AS `one`,`test`.`t1`.`two` AS `two` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`two` = `test`.`t2`.`two`) and (`test`.`t1`.`one` = `test`.`t2`.`one`) and (`test`.`t2`.`flag` = 'N')) +explain SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = '0' group by one,two) as 'test' from t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 9 11.11 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`one` AS `one`,`test`.`t1`.`two` AS `two`,((`test`.`t1`.`one`,`test`.`t1`.`two`),(/* select#2 */ select `test`.`t2`.`one`,`test`.`t2`.`two` from `test`.`t2` where ((`test`.`t2`.`flag` = '0') and (outer_field_is_not_null, (((`test`.`t1`.`one`) = `test`.`t2`.`one`) or (`test`.`t2`.`one` is null)), true) and (outer_field_is_not_null, (((`test`.`t1`.`two`) = `test`.`t2`.`two`) or (`test`.`t2`.`two` is null)), true)) having ((outer_field_is_not_null, (`test`.`t2`.`one`), true) and (outer_field_is_not_null, (`test`.`t2`.`two`), true)))) AS `test` from `test`.`t1` +DROP TABLE t1,t2; +CREATE TABLE t1 (a char(5), b char(5)); +INSERT INTO t1 VALUES (NULL,'aaa'), ('aaa','aaa'); +SELECT * FROM t1 WHERE (a,b) IN (('aaa','aaa'), ('aaa','bbb')); +a b +aaa aaa +DROP TABLE t1; +CREATE TABLE t1 (a CHAR(1), b VARCHAR(10)) charset utf8mb4; +INSERT INTO t1 VALUES ('a', 'aa'); +INSERT INTO t1 VALUES ('a', 'aaa'); +SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1); +a b +CREATE INDEX I1 ON t1 (a); +CREATE INDEX I2 ON t1 (b); +EXPLAIN SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL I2 NULL NULL NULL 2 100.00 Using where +1 SIMPLE t1 NULL ref I1 I1 5 test.t1.b 2 100.00 Using where; Using index; Start temporary; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t1`) where (`test`.`t1`.`b` = `test`.`t1`.`a`) +SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1); +a b +CREATE TABLE t2 (a VARCHAR(1), b VARCHAR(10)) charset utf8mb4; +INSERT INTO t2 SELECT * FROM t1; +CREATE INDEX I1 ON t2 (a); +CREATE INDEX I2 ON t2 (b); +EXPLAIN SELECT a,b FROM t2 WHERE b IN (SELECT a FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL I2 NULL NULL NULL 2 100.00 Using where +1 SIMPLE t2 NULL ref I1 I1 7 test.t2.b 2 100.00 Using where; Using index; Start temporary; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t2` semi join (`test`.`t2`) where (`test`.`t2`.`b` = `test`.`t2`.`a`) +SELECT a,b FROM t2 WHERE b IN (SELECT a FROM t2); +a b +EXPLAIN +SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1 WHERE LENGTH(a)<500); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL I2 NULL NULL NULL 2 100.00 Using where +1 SIMPLE t1 NULL ref I1 I1 5 test.t1.b 2 100.00 Using where; Using index; Start temporary; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t1`) where ((length(`test`.`t1`.`a`) < 500) and (`test`.`t1`.`b` = `test`.`t1`.`a`)) +SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1 WHERE LENGTH(a)<500); +a b +DROP TABLE t1,t2; +# +# BUG#45928 "Differing query results depending on MRR and +# engine_condition_pushdown settings" +# +CREATE TABLE `t1` ( +`pk` int(11) NOT NULL AUTO_INCREMENT, +`time_nokey` time NOT NULL, +`varchar_key` varchar(1) NOT NULL, +`varchar_nokey` varchar(1) NOT NULL, +PRIMARY KEY (`pk`), +KEY `varchar_key` (`varchar_key`) +) AUTO_INCREMENT=12 DEFAULT CHARSET=latin1; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO `t1` VALUES (10,'00:00:00','i','i'),(11,'00:00:00','',''); +SELECT `time_nokey` G1 FROM t1 WHERE ( `varchar_nokey` , `varchar_key` ) IN ( +SELECT `varchar_nokey` , `varchar_nokey` ) AND `varchar_key` >= 'c' HAVING G1 ORDER +BY `pk` ; +G1 +DROP TABLE t1; +# +# BUG#45863 "Assertion failed: (fixed == 0), function fix_fields(), +# file item.cc, line 4448" +# +DROP TABLE IF EXISTS C, BB; +CREATE TABLE C ( +varchar_nokey varchar(1) NOT NULL +); +INSERT INTO C VALUES +('k'),('a'),(''),('u'),('e'),('v'),('i'), +('t'),('u'),('f'),('u'),('m'),('j'),('f'), +('v'),('j'),('g'),('e'),('h'),('z'); +CREATE TABLE BB ( +varchar_nokey varchar(1) NOT NULL +); +INSERT INTO BB VALUES ('i'),('t'); +SELECT varchar_nokey FROM C +WHERE (varchar_nokey, OUTR) IN (SELECT varchar_nokey +FROM BB); +ERROR 42S22: Unknown column 'OUTR' in 'IN/ALL/ANY subquery' +SELECT varchar_nokey FROM C +WHERE (varchar_nokey, OUTR) IN (SELECT varchar_nokey, varchar_nokey +FROM BB); +ERROR 42S22: Unknown column 'OUTR' in 'IN/ALL/ANY subquery' +DROP TABLE C,BB; +# +# During work with BUG#45863 I had problems with a query that was +# optimized differently in regular and prepared mode. +# Because there was a bug in one of the selected strategies, I became +# aware of the problem. Adding an EXPLAIN query to catch this. +DROP TABLE IF EXISTS t1, t2, t3; +CREATE TABLE t1 +(EMPNUM CHAR(3) NOT NULL, +EMPNAME CHAR(20), +GRADE DECIMAL(4), +CITY CHAR(15)) charset latin1; +CREATE TABLE t2 +(PNUM CHAR(3) NOT NULL, +PNAME CHAR(20), +PTYPE CHAR(6), +BUDGET DECIMAL(9), +CITY CHAR(15)) charset latin1; +CREATE TABLE t3 +(EMPNUM CHAR(3) NOT NULL, +PNUM CHAR(3) NOT NULL, +HOURS DECIMAL(5)) charset latin1; +INSERT INTO t1 VALUES ('E1','Alice',12,'Deale'); +INSERT INTO t1 VALUES ('E2','Betty',10,'Vienna'); +INSERT INTO t1 VALUES ('E3','Carmen',13,'Vienna'); +INSERT INTO t1 VALUES ('E4','Don',12,'Deale'); +INSERT INTO t1 VALUES ('E5','Ed',13,'Akron'); +INSERT INTO t2 VALUES ('P1','MXSS','Design',10000,'Deale'); +INSERT INTO t2 VALUES ('P2','CALM','Code',30000,'Vienna'); +INSERT INTO t2 VALUES ('P3','SDP','Test',30000,'Tampa'); +INSERT INTO t2 VALUES ('P4','SDP','Design',20000,'Deale'); +INSERT INTO t2 VALUES ('P5','IRM','Test',10000,'Vienna'); +INSERT INTO t2 VALUES ('P6','PAYR','Design',50000,'Deale'); +INSERT INTO t3 VALUES ('E1','P1',40); +INSERT INTO t3 VALUES ('E1','P2',20); +INSERT INTO t3 VALUES ('E1','P3',80); +INSERT INTO t3 VALUES ('E1','P4',20); +INSERT INTO t3 VALUES ('E1','P5',12); +INSERT INTO t3 VALUES ('E1','P6',12); +INSERT INTO t3 VALUES ('E2','P1',40); +INSERT INTO t3 VALUES ('E2','P2',80); +INSERT INTO t3 VALUES ('E3','P2',20); +INSERT INTO t3 VALUES ('E4','P2',20); +INSERT INTO t3 VALUES ('E4','P4',40); +INSERT INTO t3 VALUES ('E4','P5',80); +CREATE UNIQUE INDEX t1_IDX ON t1(EMPNUM); +EXPLAIN SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN +(SELECT EMPNUM +FROM t3 +WHERE PNUM IN +(SELECT PNUM +FROM t2 +WHERE PTYPE = 'Design')); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where +1 SIMPLE t1 NULL eq_ref t1_IDX t1_IDX 3 test.t3.EMPNUM 1 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = `test`.`t3`.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) +PREPARE stmt FROM "EXPLAIN SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN + (SELECT EMPNUM + FROM t3 + WHERE PNUM IN + (SELECT PNUM + FROM t2 + WHERE PTYPE = 'Design'))"; +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where +1 SIMPLE t1 NULL eq_ref t1_IDX t1_IDX 3 test.t3.EMPNUM 1 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = `test`.`t3`.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) + +This line is only in place to help --skip_if_hypergraph diffing some more. + +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where +1 SIMPLE t1 NULL eq_ref t1_IDX t1_IDX 3 test.t3.EMPNUM 1 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = `test`.`t3`.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) +DEALLOCATE PREPARE stmt; +DROP INDEX t1_IDX ON t1; +CREATE INDEX t1_IDX ON t1(EMPNUM); +EXPLAIN SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN +(SELECT EMPNUM +FROM t3 +WHERE PNUM IN +(SELECT PNUM +FROM t2 +WHERE PTYPE = 'Design')); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where +1 SIMPLE t1 NULL ref t1_IDX t1_IDX 3 test.t3.EMPNUM 2 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = `test`.`t3`.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) +PREPARE stmt FROM "EXPLAIN SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN + (SELECT EMPNUM + FROM t3 + WHERE PNUM IN + (SELECT PNUM + FROM t2 + WHERE PTYPE = 'Design'))"; +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where +1 SIMPLE t1 NULL ref t1_IDX t1_IDX 3 test.t3.EMPNUM 2 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = `test`.`t3`.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) + +This line is only in place to help --skip_if_hypergraph diffing some more. + +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where +1 SIMPLE t1 NULL ref t1_IDX t1_IDX 3 test.t3.EMPNUM 2 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = `test`.`t3`.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) +DEALLOCATE PREPARE stmt; +DROP INDEX t1_IDX ON t1; +EXPLAIN SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN +(SELECT EMPNUM +FROM t3 +WHERE PNUM IN +(SELECT PNUM +FROM t2 +WHERE PTYPE = 'Design')); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 20.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = `test`.`t3`.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) +PREPARE stmt FROM "EXPLAIN SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN + (SELECT EMPNUM + FROM t3 + WHERE PNUM IN + (SELECT PNUM + FROM t2 + WHERE PTYPE = 'Design'))"; +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 20.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = `test`.`t3`.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) + +This line is only in place to help --skip_if_hypergraph diffing some more. + +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 20.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = `test`.`t3`.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) +DEALLOCATE PREPARE stmt; +DROP TABLE t1, t2, t3; +# +# BUG#45221 Query SELECT pk FROM C WHERE pk IN (SELECT int_key) failing +# +CREATE TABLE t1 ( +i1_key INT, +i2 INT, +i3 INT, +KEY i1_index (i1_key) +); +INSERT INTO t1 VALUES (9,1,2), (9,2,1); +CREATE TABLE t2 ( +pk INT NOT NULL, +i1 INT, +PRIMARY KEY (pk) +); +INSERT INTO t2 VALUES (9,1); +SELECT pk +FROM t2 +WHERE +pk IN ( +SELECT i1_key +FROM t1 +WHERE t1.i2 < t1.i3 XOR t2.i1 > 1 +ORDER BY t1.i2 desc); +pk +9 +DROP TABLE t1,t2; +# BUG#50361 Doublenested noncorrelated subquery with FirstMatch and join cache wrong result +# +CREATE TABLE t1( +id INTEGER +); +INSERT INTO t1 VALUES(10),(20); +create table t2 select * from t1; +create table t3 select * from t1; +SELECT * +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t2 +WHERE 1 IN(SELECT 1 +FROM t3)); +id +10 +20 +explain SELECT * +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t2 +WHERE 1 IN(SELECT 1 +FROM t3)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where true +delete from t2; +delete from t3; +INSERT INTO t1 VALUES(30),(40),(50),(60),(70),(80),(90); +insert into t2 select * from t1; +insert into t3 select * from t1; +create table t4 select * from t1; +SELECT * +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t2 +WHERE 1 IN(SELECT 1 +FROM t3 +WHERE 1 IN(SELECT 1 +FROM t4))); +id +10 +20 +30 +40 +50 +60 +70 +80 +90 +explain SELECT * +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t2 +WHERE 1 IN(SELECT 1 +FROM t3 +WHERE 1 IN(SELECT 1 +FROM t4))); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 9 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 9 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 9 100.00 NULL +1 SIMPLE t4 NULL ALL NULL NULL NULL NULL 9 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3` join `test`.`t4`) where true +SELECT * +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t1))); +id +10 +20 +30 +40 +50 +60 +70 +80 +90 +drop table t1,t2,t3,t4; +# +# Bug#53236 Segfault in DTCollation::set(DTCollation&) +# +CREATE TABLE t1 ( +pk INTEGER AUTO_INCREMENT, +col_varchar VARCHAR(1), +PRIMARY KEY (pk) +) +; +INSERT INTO t1 (col_varchar) +VALUES +('w'), +('m') +; +SELECT table1.pk +FROM ( t1 AS table1 JOIN t1 AS table2 ON (table1.col_varchar = +table2.col_varchar) ) +WHERE ( 1, 2 ) IN ( SELECT SUBQUERY1_t1.pk AS SUBQUERY1_field1, +SUBQUERY1_t1.pk AS SUBQUERY1_field2 +FROM ( t1 AS SUBQUERY1_t1 JOIN t1 AS SUBQUERY1_t2 +ON (SUBQUERY1_t2.col_varchar = +SUBQUERY1_t1.col_varchar) ) ) +; +pk +drop table t1; +# +# BUG#53298 "wrong result with semijoin (no semijoin strategy chosen)" +# +create table t1 (uid int, fid int); +insert into t1 values (1,1), (3,1); +create table t2 (uid int, name varchar(128)); +insert into t2 values (1, "A"), (2, "B"); +create table t3 (uid int, fid int, index(uid)); +insert into t3 values (1,3), (1,3); +create table t4 (uid int); +insert into t4 values (3); +explain select t2.uid from t2, t1 +where t1.uid in (select t4.uid from t4, t3 where t3.uid=1 and t4.uid=t3.fid) +and t2.uid=t1.fid; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t4 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ref uid uid 5 const 1 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`uid` AS `uid` from `test`.`t2` join `test`.`t1` semi join (`test`.`t4` join `test`.`t3`) where ((`test`.`t3`.`fid` = `test`.`t4`.`uid`) and (`test`.`t1`.`uid` = `test`.`t4`.`uid`) and (`test`.`t3`.`uid` = 1) and (`test`.`t1`.`fid` = `test`.`t2`.`uid`)) +select t2.uid from t2, t1 +where t1.uid in (select t4.uid from t4, t3 where t3.uid=1 and t4.uid=t3.fid) +and t2.uid=t1.fid; +uid +1 +drop table t1,t2,t3,t4; +CREATE TABLE t1 ( +pk int, +a varchar(1), +b varchar(4), +c varchar(4), +d varchar(4), +PRIMARY KEY (pk) +) charset utf8mb4; +INSERT INTO t1 VALUES (1,'o','ffff','ffff','ffoo'),(2,'f','ffff','ffff','ffff'); +CREATE TABLE t2 LIKE t1; +INSERT INTO t2 VALUES (1,'i','iiii','iiii','iiii'),(2,'f','ffff','ffff','ffff'); +EXPLAIN SELECT pk FROM t1 WHERE (a) IN (SELECT a FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using where; Start temporary; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`a` = `test`.`t1`.`a`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (a) IN (SELECT a FROM t2 WHERE pk > 0); +pk +2 +SELECT pk FROM t1 WHERE (b,c,d) IN (SELECT b,c,d FROM t2 WHERE pk > 0); +pk +2 +DROP TABLE t1, t2; +CREATE TABLE t1 (f1 INT, f2 DECIMAL(5,3)) ENGINE=MyISAM; +INSERT INTO t1 (f1, f2) VALUES (1, 1.789); +INSERT INTO t1 (f1, f2) VALUES (13, 1.454); +INSERT INTO t1 (f1, f2) VALUES (10, 1.668); +CREATE TABLE t2 LIKE t1; +INSERT INTO t2 VALUES (1, 1.789); +INSERT INTO t2 VALUES (13, 1.454); +EXPLAIN SELECT COUNT(*) FROM t1 WHERE (f1,f2) IN (SELECT f1,f2 FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`f2` = `test`.`t2`.`f2`) and (`test`.`t1`.`f1` = `test`.`t2`.`f1`)) +SELECT COUNT(*) FROM t1 WHERE (f1,f2) IN (SELECT f1,f2 FROM t2); +COUNT(*) +2 +DROP TABLE t1, t2; +CREATE TABLE t1 ( +ID int(11) NOT NULL auto_increment, +Name char(35) NOT NULL default '', +Country char(3) NOT NULL default '', +Population int(11) NOT NULL default '0', +PRIMARY KEY (ID), +INDEX (Population), +INDEX (Country) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t2 ( +Code char(3) NOT NULL default '', +Name char(52) NOT NULL default '', +SurfaceArea float(10,2) NOT NULL default '0.00', +Population int(11) NOT NULL default '0', +Capital int(11) default NULL, +PRIMARY KEY (Code), +UNIQUE INDEX (Name), +INDEX (Population) +) charset utf8mb4; +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t3 ( +Country char(3) NOT NULL default '', +Language char(30) NOT NULL default '', +Percentage float(3,1) NOT NULL default '0.0', +PRIMARY KEY (Country, Language), +INDEX (Percentage) +) charset utf8mb4; +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +EXPLAIN SELECT Name FROM t2 +WHERE t2.Code IN (SELECT Country FROM t1 WHERE Population > 5000000) +AND +t2.Code IN (SELECT Country FROM t3 +WHERE Language='English' AND Percentage > 10 AND +t2.Population > 100000); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range Population,Country Population 4 NULL 1 100.00 Using where; Start temporary +1 SIMPLE t2 NULL eq_ref PRIMARY,Population PRIMARY 12 test.t1.Country 1 75.00 Using where +1 SIMPLE t3 NULL eq_ref PRIMARY,Percentage PRIMARY 132 test.t1.Country,const 1 95.45 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t2.Population' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t2`.`Name` AS `Name` from `test`.`t3` join `test`.`t2` semi join (`test`.`t1`) where ((`test`.`t2`.`Code` = `test`.`t1`.`Country`) and (`test`.`t3`.`Country` = `test`.`t1`.`Country`) and (`test`.`t3`.`Language` = 'English') and (`test`.`t3`.`Percentage` > 10) and (`test`.`t2`.`Population` > 100000) and (`test`.`t1`.`Population` > 5000000)) +EXPLAIN FORMAT=JSON SELECT Name FROM t2 +WHERE t2.Code IN (SELECT Country FROM t1 WHERE Population > 5000000) +AND +t2.Code IN (SELECT Country FROM t3 +WHERE Language='English' AND Percentage > 10 AND +t2.Population > 100000); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "2.46" + }, + "duplicates_removal": { + "using_temporary_table": true, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "range", + "possible_keys": [ + "Population", + "Country" + ], + "key": "Population", + "used_key_parts": [ + "Population" + ], + "key_length": "4", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.61", + "eval_cost": "0.10", + "prefix_cost": "0.71", + "data_read_per_join": "168" + }, + "used_columns": [ + "Country", + "Population" + ], + "attached_condition": "(`test`.`t1`.`Population` > 5000000)" + } + }, + { + "table": { + "table_name": "t2", + "access_type": "eq_ref", + "possible_keys": [ + "PRIMARY", + "Population" + ], + "key": "PRIMARY", + "used_key_parts": [ + "Code" + ], + "key_length": "12", + "ref": [ + "test.t1.Country" + ], + "rows_examined_per_scan": 1, + "rows_produced_per_join": 0, + "filtered": "75.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.08", + "prefix_cost": "2.21", + "data_read_per_join": "180" + }, + "used_columns": [ + "Code", + "Name", + "Population" + ], + "attached_condition": "(`test`.`t2`.`Population` > 100000)" + } + }, + { + "table": { + "table_name": "t3", + "access_type": "eq_ref", + "possible_keys": [ + "PRIMARY", + "Percentage" + ], + "key": "PRIMARY", + "used_key_parts": [ + "Country", + "Language" + ], + "key_length": "132", + "ref": [ + "test.t1.Country", + "const" + ], + "rows_examined_per_scan": 1, + "rows_produced_per_join": 0, + "filtered": "95.45", + "cost_info": { + "read_cost": "0.19", + "eval_cost": "0.07", + "prefix_cost": "2.47", + "data_read_per_join": "103" + }, + "used_columns": [ + "Country", + "Language", + "Percentage" + ], + "attached_condition": "((`test`.`t3`.`Language` = 'English') and (`test`.`t3`.`Percentage` > 10))" + } + } + ] + } + } +} +Warnings: +Note 1276 Field or reference 'test.t2.Population' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t2`.`Name` AS `Name` from `test`.`t3` join `test`.`t2` semi join (`test`.`t1`) where ((`test`.`t2`.`Code` = `test`.`t1`.`Country`) and (`test`.`t3`.`Country` = `test`.`t1`.`Country`) and (`test`.`t3`.`Language` = 'English') and (`test`.`t3`.`Percentage` > 10) and (`test`.`t2`.`Population` > 100000) and (`test`.`t1`.`Population` > 5000000)) +DROP TABLE t1,t2,t3; +CREATE TABLE t1 ( +Code char(3) NOT NULL DEFAULT '', +Name char(52) NOT NULL DEFAULT '', +Continent enum('Asia','Europe','North America','Africa','Oceania','Antarctica','South America') NOT NULL DEFAULT 'Asia', +Region char(26) NOT NULL DEFAULT '', +SurfaceArea float(10,2) NOT NULL DEFAULT '0.00', +IndepYear smallint(6) DEFAULT NULL, +Population int(11) NOT NULL DEFAULT '0', +LifeExpectancy float(3,1) DEFAULT NULL, +GNP float(10,2) DEFAULT NULL, +GNPOld float(10,2) DEFAULT NULL, +LocalName char(45) NOT NULL DEFAULT '', +GovernmentForm char(45) NOT NULL DEFAULT '', +HeadOfState char(60) DEFAULT NULL, +Capital int(11) DEFAULT NULL, +Code2 char(2) NOT NULL DEFAULT '', +PRIMARY KEY (Code) +) charset utf8mb4; +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t2 ( +ID int(11) NOT NULL AUTO_INCREMENT, +Name char(35) NOT NULL DEFAULT '', +CountryCode char(3) NOT NULL DEFAULT '', +District char(20) NOT NULL DEFAULT '', +Population int(11) NOT NULL DEFAULT '0', +PRIMARY KEY (ID), +KEY CountryCode (CountryCode) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +set names latin1; +Fill the table with test data +This must not use LooseScan: +EXPLAIN SELECT Name FROM t1 +WHERE t1.Code IN ( +SELECT t2.CountryCode FROM t2 WHERE Population > 5000000); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL CountryCode NULL NULL NULL 545 33.33 Using where; Start temporary +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 12 test.t2.CountryCode 1 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`Name` AS `Name` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`Code` = `test`.`t2`.`CountryCode`) and (`test`.`t2`.`Population` > 5000000)) +SELECT Name FROM t1 +WHERE t1.Code IN ( +SELECT t2.CountryCode FROM t2 WHERE Population > 5000000); +Name +Austria +Canada +China +Czech Republic +drop table t1, t2; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4); +create table t1 (a int, b int, key(a)); +insert into t1 select a,a from t0; +create table t2 (a int, b int, primary key(a)); +insert into t2 select * from t1; +Table t2, unlike table t1, should be displayed as pulled out +explain select * from t0 +where t0.a in ( select t1.a from t1,t2 where t2.a=t0.a and +t1.b=t2.b); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 5 100.00 Using where +1 SIMPLE t1 NULL ref a a 5 test.t0.a 1 100.00 Start temporary +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t0.a 1 20.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t0.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a` from `test`.`t2` join `test`.`t0` semi join (`test`.`t1`) where ((`test`.`t1`.`a` = `test`.`t0`.`a`) and (`test`.`t2`.`a` = `test`.`t0`.`a`) and (`test`.`t2`.`b` = `test`.`t1`.`b`)) +update t1 set a=3, b=11 where a=4; +update t2 set b=11 where a=3; +select * from t0 where t0.a in (select t1.a from t1, t2 where t2.a=t0.a and t1.b=t2.b); +a +0 +1 +2 +3 +drop table t0, t1, t2; +CREATE TABLE t1 ( +id int(11) NOT NULL, +PRIMARY KEY (id)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t2 ( +id int(11) NOT NULL, +fid int(11) NOT NULL, +PRIMARY KEY (id)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t1 values(1); +insert into t2 values(1,7503),(2,1); +explain select count(*) +from t1 +where fid IN (select fid from t2 where (id between 7502 and 8420) order by fid ); +ERROR 42S22: Unknown column 'fid' in 'IN/ALL/ANY subquery' +drop table t1, t2; +create table t1 (a int, b int, key (a), key (b)); +insert into t1 values (2,4),(2,4),(2,4); +select t1.a from t1 +where +t1.a in (select 1 from t1 where t1.a in (select 1 from t1) group by t1.a); +a +drop table t1; +create table t1(a int,b int,key(a),key(b)); +insert into t1 values (1,1),(2,2),(3,3); +select 1 from t1 +where t1.a not in (select 1 from t1 +where t1.a in (select 1 from t1) +group by t1.b); +1 +1 +1 +drop table t1; +CREATE TABLE t1 +(EMPNUM CHAR(3) NOT NULL, +EMPNAME CHAR(20), +GRADE DECIMAL(4), +CITY CHAR(15)); +CREATE TABLE t2 +(PNUM CHAR(3) NOT NULL, +PNAME CHAR(20), +PTYPE CHAR(6), +BUDGET DECIMAL(9), +CITY CHAR(15)); +CREATE TABLE t3 +(EMPNUM CHAR(3) NOT NULL, +PNUM CHAR(3) NOT NULL, +HOURS DECIMAL(5)); +INSERT INTO t1 VALUES ('E1','Alice',12,'Deale'); +INSERT INTO t1 VALUES ('E2','Betty',10,'Vienna'); +INSERT INTO t1 VALUES ('E3','Carmen',13,'Vienna'); +INSERT INTO t1 VALUES ('E4','Don',12,'Deale'); +INSERT INTO t1 VALUES ('E5','Ed',13,'Akron'); +INSERT INTO t2 VALUES ('P1','MXSS','Design',10000,'Deale'); +INSERT INTO t2 VALUES ('P2','CALM','Code',30000,'Vienna'); +INSERT INTO t2 VALUES ('P3','SDP','Test',30000,'Tampa'); +INSERT INTO t2 VALUES ('P4','SDP','Design',20000,'Deale'); +INSERT INTO t2 VALUES ('P5','IRM','Test',10000,'Vienna'); +INSERT INTO t2 VALUES ('P6','PAYR','Design',50000,'Deale'); +INSERT INTO t3 VALUES ('E1','P1',40); +INSERT INTO t3 VALUES ('E1','P2',20); +INSERT INTO t3 VALUES ('E1','P3',80); +INSERT INTO t3 VALUES ('E1','P4',20); +INSERT INTO t3 VALUES ('E1','P5',12); +INSERT INTO t3 VALUES ('E1','P6',12); +INSERT INTO t3 VALUES ('E2','P1',40); +INSERT INTO t3 VALUES ('E2','P2',80); +INSERT INTO t3 VALUES ('E3','P2',20); +INSERT INTO t3 VALUES ('E4','P2',20); +INSERT INTO t3 VALUES ('E4','P4',40); +INSERT INTO t3 VALUES ('E4','P5',80); +SELECT * FROM t1; +EMPNUM EMPNAME GRADE CITY +E1 Alice 12 Deale +E2 Betty 10 Vienna +E3 Carmen 13 Vienna +E4 Don 12 Deale +E5 Ed 13 Akron +CREATE UNIQUE INDEX t1_IDX ON t1(EMPNUM); +SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN +(SELECT EMPNUM +FROM t3 +WHERE PNUM IN +(SELECT PNUM +FROM t2 +WHERE PTYPE = 'Design')); +EMPNAME +Alice +Betty +Don +DROP INDEX t1_IDX ON t1; +CREATE INDEX t1_IDX ON t1(EMPNUM); +SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN +(SELECT EMPNUM +FROM t3 +WHERE PNUM IN +(SELECT PNUM +FROM t2 +WHERE PTYPE = 'Design')); +EMPNAME +Alice +Betty +Don +DROP INDEX t1_IDX ON t1; +SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN +(SELECT EMPNUM +FROM t3 +WHERE PNUM IN +(SELECT PNUM +FROM t2 +WHERE PTYPE = 'Design')); +EMPNAME +Alice +Betty +Don +DROP TABLE t1, t2, t3; +CREATE TABLE t1 (f1 INT NOT NULL); +CREATE VIEW v1 (a) AS SELECT f1 IN (SELECT f1 FROM t1) FROM t1; +SELECT * FROM v1; +a +drop view v1; +drop table t1; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1(a int, b int); +insert into t1 values (0,0),(1,1),(2,2); +create table t2 as select * from t1; +create table t3 (pk int, a int, primary key(pk)); +insert into t3 select a,a from t0; +explain +select * from t1 left join t2 on (t2.a= t1.a and t2.a in (select pk from t3)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE t3 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using index +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` left join (`test`.`t3` join `test`.`t2`) on(((`test`.`t3`.`pk` = `test`.`t1`.`a`) and (`test`.`t2`.`a` = `test`.`t1`.`a`))) where true +drop table t0, t1, t2, t3; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (a int) as select A.a + 10 *(B.a + 10*C.a) as a from t0 A, t0 B, t0 C; +create table t2 (id int, a int, primary key(id), key(a)) charset utf8mb4 as select a as id, a as a from t1; +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `id` int NOT NULL, + `a` int DEFAULT NULL, + PRIMARY KEY (`id`), + KEY `a` (`a`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +set @a=0; +create table t3 as select * from t2 limit 0; +insert into t3 select @a:=@a+1, t2.a from t2, t0; +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +insert into t3 select @a:=@a+1, t2.a from t2, t0; +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +insert into t3 select @a:=@a+1, t2.a from t2, t0; +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +alter table t3 add primary key(id), add 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); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index a a 5 NULL 1000 100.00 Using where; Using index +1 SIMPLE t3 NULL ref a a 5 test.t2.a 30 100.00 Using index; Start temporary; End temporary +Warnings: +Note 1003 /* select#1 */ select count(`test`.`t2`.`a`) AS `count(a)` from `test`.`t2` semi join (`test`.`t3`) where (`test`.`t3`.`a` = `test`.`t2`.`a`) +select count(a) from t2 where a in ( SELECT a FROM t3); +count(a) +1000 +drop table t0,t1,t2,t3; +# +# Bug#33062: subquery in stored routine cause crash +# +CREATE TABLE t1(a INT); +CREATE TABLE t2(c INT); +CREATE PROCEDURE p1(v1 int) +BEGIN +SELECT 1 FROM t1 WHERE a = v1 AND a IN (SELECT c FROM t2); +END +// +CREATE PROCEDURE p2(v1 int) +BEGIN +SELECT 1 FROM t1 WHERE a IN (SELECT c FROM t2); +END +// +CREATE PROCEDURE p3(v1 int) +BEGIN +SELECT 1 +FROM +t1 t01,t1 t02,t1 t03,t1 t04,t1 t05,t1 t06,t1 t07,t1 t08, +t1 t09,t1 t10,t1 t11,t1 t12,t1 t13,t1 t14,t1 t15,t1 t16, +t1 t17,t1 t18,t1 t19,t1 t20,t1 t21,t1 t22,t1 t23,t1 t24, +t1 t25,t1 t26,t1 t27,t1 t28,t1 t29,t1 t30,t1 t31,t1 t32, +t1 t33,t1 t34,t1 t35,t1 t36,t1 t37,t1 t38,t1 t39,t1 t40, +t1 t41,t1 t42,t1 t43,t1 t44,t1 t45,t1 t46,t1 t47,t1 t48, +t1 t49,t1 t50,t1 t51,t1 t52,t1 t53,t1 t54,t1 t55,t1 t56, +t1 t57,t1 t58,t1 t59,t1 t60 +WHERE t01.a IN (SELECT c FROM t2); +END +// +CREATE PROCEDURE p4(v1 int) +BEGIN +SELECT 1 +FROM +t1 t01,t1 t02,t1 t03,t1 t04,t1 t05,t1 t06,t1 t07,t1 t08, +t1 t09,t1 t10,t1 t11,t1 t12,t1 t13,t1 t14,t1 t15,t1 t16, +t1 t17,t1 t18,t1 t19,t1 t20,t1 t21,t1 t22,t1 t23,t1 t24, +t1 t25,t1 t26,t1 t27,t1 t28,t1 t29,t1 t30,t1 t31,t1 t32, +t1 t33,t1 t34,t1 t35,t1 t36,t1 t37,t1 t38,t1 t39,t1 t40, +t1 t41,t1 t42,t1 t43,t1 t44,t1 t45,t1 t46,t1 t47,t1 t48, +t1 t49,t1 t50,t1 t51,t1 t52,t1 t53,t1 t54,t1 t55,t1 t56, +t1 t57,t1 t58,t1 t59,t1 t60 +WHERE t01.a = v1 AND t01.a IN (SELECT c FROM t2); +END +// +CALL p1(1); +1 +CALL p2(1); +1 +CALL p3(1); +1 +CALL p4(1); +1 +DROP TABLE t1, t2; +DROP PROCEDURE p1; +DROP PROCEDURE p2; +DROP PROCEDURE p3; +DROP PROCEDURE p4; +# +# Bug#48213 Materialized subselect crashes if using GEOMETRY type +# +CREATE TABLE t1 ( +pk int, +a varchar(1), +b varchar(4), +c tinyblob, +d blob, +e mediumblob, +f longblob, +g tinytext, +h text, +i mediumtext, +j longtext, +k geometry, +PRIMARY KEY (pk) +) charset utf8mb4; +INSERT INTO t1 VALUES (1,'o','ffff','ffff','ffoo','ffff','ffff','ffff','ffff','ffff','ffff',ST_GeomFromText('POLYGON((0 0, 0 2, 2 2, 2 0, 0 0))')), (2,'f','ffff','ffff','ffff', 'ffff','ffff','ffff','ffff','ffff','ffff',ST_GeomFromText('POLYGON((0 0, 0 2, 2 2, 2 0, 0 0))')); +CREATE TABLE t2 LIKE t1; +INSERT INTO t2 VALUES (1,'i','iiii','iiii','iiii','iiii','ffff','ffff','ffff','ffff','ffff',ST_GeomFromText('POLYGON((0 0, 0 2, 2 2, 2 0, 0 0))')), (2,'f','ffff','ffff','ffff','ffff','ffff','ffff','ffff','ffff','ffff',ST_GeomFromText('POLYGON((0 0, 0 2, 2 2, 2 0, 0 0))')); +EXPLAIN SELECT pk FROM t1 WHERE (a, b) IN (SELECT a, b FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using where; Start temporary; End temporary +Warnings: +Note 1003 /* select#1 */ 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); +pk +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, c) IN (SELECT b, c FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using where; Start temporary; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`c` = `test`.`t1`.`c`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, c) IN (SELECT b, c FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, d) IN (SELECT b, d FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using where; Start temporary; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`d` = `test`.`t1`.`d`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, d) IN (SELECT b, d FROM t2 WHERE pk > 0); +pk +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, e) IN (SELECT b, e FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using where; Start temporary; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`e` = `test`.`t1`.`e`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, e) IN (SELECT b, e FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, f) IN (SELECT b, f FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using where; Start temporary; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`f` = `test`.`t1`.`f`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, f) IN (SELECT b, f FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, g) IN (SELECT b, g FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using where; Start temporary; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`g` = `test`.`t1`.`g`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, g) IN (SELECT b, g FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, h) IN (SELECT b, h FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using where; Start temporary; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`h` = `test`.`t1`.`h`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, h) IN (SELECT b, h FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, i) IN (SELECT b, i FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using where; Start temporary; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`i` = `test`.`t1`.`i`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, i) IN (SELECT b, i FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, j) IN (SELECT b, j FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using where; Start temporary; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`j` = `test`.`t1`.`j`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, j) IN (SELECT b, j FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, k) IN (SELECT b, k FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using where; Start temporary; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`k` = `test`.`t1`.`k`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, k) IN (SELECT b, k FROM t2 WHERE pk > 0); +pk +1 +2 +DROP TABLE t1, t2; +# End of Bug#48213 +# +# BUG#53060: LooseScan semijoin strategy does not return all rows +# +CREATE TABLE t1 (i INTEGER); +INSERT INTO t1 VALUES (1), (2), (3), (4), (5); +CREATE TABLE t2 (i INTEGER, j INTEGER, KEY k(i, j)); +INSERT INTO t2 VALUES (1, 0), (1, 1), (2, 0), (2, 1); +EXPLAIN +SELECT * FROM t1 WHERE (i) IN (SELECT i FROM t2 where j > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index k k 10 NULL 4 33.33 Using where; Using index; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 20.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`i` = `test`.`t2`.`i`) and (`test`.`t2`.`j` > 0)) +SELECT * FROM t1 WHERE (i) IN (SELECT i FROM t2 where j > 0); +i +1 +2 +DROP TABLE t1, t2; +# End of BUG#53060 +# +# Bug#53305 "Duplicate weedout + join buffer (join cache --level=7,8) loses rows" +# +create table t1 (uid int, fid int, index(uid)); +insert into t1 values +(1,1), (1,2), (1,3), (1,4), +(2,5), (2,6), (2,7), (2,8), +(3,1), (3,2), (3,9); +create table t2 (uid int primary key, name varchar(128), index(name)); +insert into t2 values +(1, "A"), (2, "B"), (3, "C"), (4, "D"), (5, "E"), +(6, "F"), (7, "G"), (8, "H"), (9, "I"); +create table t3 (uid int, fid int, index(uid)); +insert into t3 values +(1,1), (1,2), (1,3),(1,4), +(2,5), (2,6), (2,7), (2,8), +(3,1), (3,2), (3,9); +create table t4 (uid int primary key, name varchar(128), index(name)); +insert into t4 values +(1, "A"), (2, "B"), (3, "C"), (4, "D"), (5, "E"), +(6, "F"), (7, "G"), (8, "H"), (9, "I"); +explain select name from t2, t1 +where t1.uid in (select t4.uid from t4, t3 where t3.uid=1 and t4.uid=t3.fid) +and t2.uid=t1.fid; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ref uid uid 5 const 4 100.00 Using where; Start temporary +1 SIMPLE t4 NULL eq_ref PRIMARY PRIMARY 4 test.t3.fid 1 100.00 Using index +1 SIMPLE t1 NULL ref uid uid 5 test.t3.fid 2 100.00 Using where +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.fid 1 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`name` AS `name` from `test`.`t4` join `test`.`t2` join `test`.`t1` semi join (`test`.`t3`) where ((`test`.`t4`.`uid` = `test`.`t3`.`fid`) and (`test`.`t1`.`uid` = `test`.`t3`.`fid`) and (`test`.`t3`.`uid` = 1) and (`test`.`t2`.`uid` = `test`.`t1`.`fid`)) +select name from t2, t1 +where t1.uid in (select t4.uid from t4, t3 where t3.uid=1 and t4.uid=t3.fid) +and t2.uid=t1.fid; +name +A +A +B +B +C +D +E +F +G +H +I +drop table t1,t2,t3,t4; +# +# Bug#43768 Prepared query with nested subqueries core dump on second execution +# +CREATE TABLE t1 ( +id INT PRIMARY KEY, +partner_id VARCHAR(35) +) charset utf8mb4; +INSERT INTO t1 VALUES +(1, 'partner1'), (2, 'partner2'), +(3, 'partner3'), (4, 'partner4'); +CREATE TABLE t2 ( +id INT NOT NULL, +t1_line_id INT, +article_id VARCHAR(20), +PRIMARY KEY(id, t1_line_id) +) charset utf8mb4; +INSERT INTO t2 VALUES +(1, 1, 'sup'), (2, 1, 'sup'), +(2, 2, 'sup'), (2, 3, 'sup'), +(2, 4, 'imp'), (3, 1, 'sup'), +(4, 1, 'sup'); +CREATE TABLE t3 ( +user_id VARCHAR(50), +article_id VARCHAR(20) NOT NULL, +PRIMARY KEY(user_id) +) charset utf8mb4; +INSERT INTO t3 VALUES('nicke', 'imp'); +EXPLAIN +SELECT t1.partner_id +FROM t1 +WHERE t1.id IN ( +SELECT t2.id +FROM t2 +WHERE article_id IN ( +SELECT article_id FROM t3 +WHERE user_id = 'nicke' + ) +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL system PRIMARY NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL PRIMARY NULL NULL NULL 7 14.29 Using where; Start temporary +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.id 1 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`partner_id` AS `partner_id` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`id` = `test`.`t2`.`id`) and (`test`.`t2`.`article_id` = 'imp')) +SELECT t1.partner_id +FROM t1 +WHERE t1.id IN ( +SELECT t2.id +FROM t2 +WHERE article_id IN ( +SELECT article_id FROM t3 +WHERE user_id = 'nicke' + ) +); +partner_id +partner2 +PREPARE stmt FROM +'EXPLAIN SELECT t1.partner_id +FROM t1 +WHERE t1.id IN ( + SELECT t2.id + FROM t2 + WHERE article_id IN ( + SELECT article_id FROM t3 + WHERE user_id = \'nicke\' + ) + )'; +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL system PRIMARY NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL PRIMARY NULL NULL NULL 7 14.29 Using where; Start temporary +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.id 1 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`partner_id` AS `partner_id` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`id` = `test`.`t2`.`id`) and (`test`.`t2`.`article_id` = 'imp')) + +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL system PRIMARY NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL PRIMARY NULL NULL NULL 7 14.29 Using where; Start temporary +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.id 1 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`partner_id` AS `partner_id` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`id` = `test`.`t2`.`id`) and (`test`.`t2`.`article_id` = 'imp')) +PREPARE stmt FROM +'SELECT t1.partner_id +FROM t1 +WHERE t1.id IN ( + SELECT t2.id + FROM t2 + WHERE article_id IN ( + SELECT article_id FROM t3 + WHERE user_id = \'nicke\' + ) + )'; +EXECUTE stmt; +partner_id +partner2 + +EXECUTE stmt; +partner_id +partner2 +DROP TABLE t1,t2,t3; +# End of Bug#43768 +# +# Bug#53058 - semijoin execution of subquery with outerjoin yields wrong result +# +CREATE TABLE t1 (i INTEGER); +CREATE TABLE t2 (i INTEGER); +CREATE TABLE t3 (i INTEGER); +INSERT INTO t1 VALUES (1), (2); +INSERT INTO t2 VALUES (6); +INSERT INTO t3 VALUES (1), (2); +explain SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t3 LEFT JOIN t2 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = `test`.`t1`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t3 LEFT JOIN t2 ON t2.i=t3.i); +i +1 +2 +drop table t1,t2,t3; +# +# BUG#49453: re-execution of prepared statement with view +# and semijoin crashes +# +CREATE TABLE t1 (city VARCHAR(50), country_id INT); +CREATE TABLE t2 (country_id INT, country VARCHAR(50)); +INSERT INTO t1 VALUES +('Batna',2),('Bchar',2),('Skikda',2),('Tafuna',3),('Algeria',2) ; +INSERT INTO t2 VALUES (2,'Algeria'),(2,'AlgeriaDup'),(3,'XAmerican Samoa'); +CREATE VIEW v1 AS +SELECT country_id as vf_country_id +FROM t2 +WHERE LEFT(country,1) = "A"; +PREPARE stmt FROM " +SELECT city, country_id +FROM t1 +WHERE country_id IN (SELECT vf_country_id FROM v1); +"; + +EXECUTE stmt; +city country_id +Algeria 2 +Batna 2 +Bchar 2 +Skikda 2 + +EXECUTE stmt; +city country_id +Algeria 2 +Batna 2 +Bchar 2 +Skikda 2 +DROP TABLE t1,t2; +DROP VIEW v1; +# +# Bug#54437 Extra rows with LEFT JOIN + semijoin (firstmatch +# and duplicates weedout) +# +create table t1 (a int); +create table t2 (a int); +create table t3 (a int); +insert into t1 values(1),(1); +insert into t2 values(1),(1),(1),(1); +insert into t3 values(2),(2); +explain select * from t1 where t1.a in (select t2.a from t2 left join t3 on t2.a=t3.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t2` left join `test`.`t3` on((`test`.`t2`.`a` = `test`.`t3`.`a`))) where (`test`.`t2`.`a` = `test`.`t1`.`a`) +select * from t1 where t1.a in (select t2.a from t2 left join t3 on t2.a=t3.a); +a +1 +1 +drop table t1,t2,t3; +# +# Bug#55955: crash in MEMORY engine with IN(LEFT JOIN (JOIN)) +# +CREATE TABLE t1 (a INT); +CREATE TABLE t2 (a INT); +CREATE TABLE t3 (a INT); +INSERT INTO t1 VALUES(1),(1); +INSERT INTO t2 VALUES(1),(1); +INSERT INTO t3 VALUES(2),(2); +explain SELECT * FROM t1 +WHERE t1.a IN (SELECT t2.a +FROM t2 LEFT JOIN (t2 AS t2inner, t3) ON t2.a=t3.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t2inner NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t2` left join (`test`.`t2` `t2inner` join `test`.`t3`) on((`test`.`t2`.`a` = `test`.`t3`.`a`))) where (`test`.`t2`.`a` = `test`.`t1`.`a`) +SELECT * FROM t1 +WHERE t1.a IN (SELECT t2.a +FROM t2 LEFT JOIN (t2 AS t2inner, t3) ON t2.a=t3.a); +a +1 +1 +DROP TABLE t1,t2,t3; +# +# BUG#52329 - Wrong result: subquery materialization, IN, +# non-null field followed by nullable +# +CREATE TABLE t1 (a1 CHAR(8) NOT NULL, a2 char(8) NOT NULL); +CREATE TABLE t2a (b1 char(8), b2 char(8)); +CREATE TABLE t2b (b1 CHAR(8), b2 char(8) NOT NULL); +CREATE TABLE t2c (b1 CHAR(8) NOT NULL, b2 char(8)); +INSERT INTO t1 VALUES ('1 - 12', '2 - 22'); +INSERT INTO t2a VALUES ('1 - 11', '2 - 21'), +('1 - 11', '2 - 21'), +('1 - 12', '2 - 22'), +('1 - 12', '2 - 22'), +('1 - 13', '2 - 23'); +INSERT INTO t2b SELECT * FROM t2a; +INSERT INTO t2c SELECT * FROM t2a; +SELECT * FROM t1 +WHERE (a1, a2) IN ( +SELECT b1, b2 FROM t2c WHERE b1 > '0' GROUP BY b1, b2); +a1 a2 +1 - 12 2 - 22 +SELECT * FROM t1 +WHERE (a1, a2) IN ( +SELECT b1, b2 FROM t2a WHERE b1 > '0'); +a1 a2 +1 - 12 2 - 22 +SELECT * FROM t1 +WHERE (a1, a2) IN ( +SELECT b1, b2 FROM t2b WHERE b1 > '0'); +a1 a2 +1 - 12 2 - 22 +SELECT * FROM t1 +WHERE (a1, a2) IN ( +SELECT b1, b2 FROM t2c WHERE b1 > '0'); +a1 a2 +1 - 12 2 - 22 +DROP TABLE t1,t2a,t2b,t2c; +# End BUG#52329 +# +# Bug#45174: Incorrectly applied equality propagation caused wrong +# result on a query with a materialized semi-join. +# +CREATE TABLE t1 ( +varchar_nokey varchar(1) NOT NULL +) charset utf8mb4; +INSERT INTO t1 VALUES +('v'), ('u'), ('n'), ('l'), ('h'), ('u'), ('n'), ('j'), ('k'), +('e'), ('i'), ('u'), ('n'), ('b'), ('x'), (''), ('q'), ('u'); +CREATE TABLE t2 ( +pk int NOT NULL, +varchar_key varchar(1) NOT NULL, +varchar_nokey varchar(1) NOT NULL, +PRIMARY KEY(pk), +KEY varchar_key(varchar_key) +) charset utf8mb4; +INSERT INTO t2 VALUES +(11,'m','m'), (12,'j','j'), (13,'z','z'), (14,'a','a'), (15,'',''), +(16,'e','e'), (17,'t','t'), (19,'b','b'), (20,'w','w'), (21,'m','m'), +(23,'',''), (24,'w','w'), (26,'e','e'), (27,'e','e'), (28,'p','p'); +SELECT varchar_nokey +FROM t1 +WHERE (varchar_nokey, varchar_nokey) IN (SELECT varchar_key, varchar_nokey +FROM t2 +WHERE varchar_nokey < 'n' XOR pk); +varchar_nokey +explain SELECT varchar_nokey +FROM t1 +WHERE (varchar_nokey, varchar_nokey) IN (SELECT varchar_key, varchar_nokey +FROM t2 +WHERE varchar_nokey < 'n' XOR pk); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 18 100.00 NULL +1 SIMPLE t2 NULL ref varchar_key varchar_key 6 test.t1.varchar_nokey 2 6.67 Using where; Start temporary; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`varchar_nokey` AS `varchar_nokey` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`varchar_key` = `test`.`t1`.`varchar_nokey`) and (`test`.`t2`.`varchar_nokey` = `test`.`t1`.`varchar_nokey`) and ((`test`.`t2`.`varchar_nokey` < 'n') xor (0 <> `test`.`t2`.`pk`))) +DROP TABLE t1, t2; +# End of the test for bug#45174. +# +# Bug#50019: Wrong result for IN-query with materialization +# +CREATE TABLE t1(i INT); +INSERT INTO t1 VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10); +CREATE TABLE t2(i INT); +INSERT INTO t2 VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10); +CREATE TABLE t3(i INT); +INSERT INTO t3 VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10); +SELECT * FROM t1 WHERE t1.i IN (SELECT t2.i +FROM t2 JOIN t3 +WHERE t2.i + t3.i = 5); +i +1 +2 +3 +4 +explain SELECT * FROM t1 WHERE t1.i IN (SELECT t2.i +FROM t2 JOIN t3 +WHERE t2.i + t3.i = 5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 10 10.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 10 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = `test`.`t1`.`i`) and ((`test`.`t1`.`i` + `test`.`t3`.`i`) = 5)) +DROP TABLE t1,t2,t3; +# End of the test for bug#50019. +# +# Bug#52068: Optimizer generates invalid semijoin materialization plan +# +CREATE TABLE ot1(a INTEGER); +INSERT INTO ot1 VALUES(5), (8); +CREATE TABLE it2(a INTEGER); +INSERT INTO it2 VALUES(9), (5), (1), (8); +CREATE TABLE it3(a INTEGER); +INSERT INTO it3 VALUES(7), (1), (0), (5), (1), (4); +CREATE TABLE ot4(a INTEGER); +INSERT INTO ot4 VALUES(1), (3), (5), (7), (9), (7), (3), (1); +SELECT * FROM ot1,ot4 +WHERE (ot1.a,ot4.a) IN (SELECT it2.a,it3.a +FROM it2,it3); +a a +5 1 +5 1 +5 5 +5 7 +5 7 +8 1 +8 1 +8 5 +8 7 +8 7 +explain SELECT * FROM ot1,ot4 +WHERE (ot1.a,ot4.a) IN (SELECT it2.a,it3.a +FROM it2,it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE it2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; Start temporary +1 SIMPLE it3 NULL ALL NULL NULL NULL NULL 6 100.00 NULL +1 SIMPLE ot4 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot4`.`a` AS `a` from `test`.`ot1` join `test`.`ot4` semi join (`test`.`it2` join `test`.`it3`) where ((`test`.`ot4`.`a` = `test`.`it3`.`a`) and (`test`.`it2`.`a` = `test`.`ot1`.`a`)) +DROP TABLE IF EXISTS ot1, ot4, it2, it3; +# End of the test for bug#52068. +# +# Bug#57623: subquery within before insert trigger causes crash (sj=on) +# +CREATE TABLE ot1(a INT); +CREATE TABLE ot2(a INT); +CREATE TABLE ot3(a INT); +CREATE TABLE it1(a INT); +INSERT INTO ot1 VALUES(0),(1),(2),(3),(4),(5),(6),(7); +INSERT INTO ot2 VALUES(0),(2),(4),(6); +INSERT INTO ot3 VALUES(0),(3),(6); +INSERT INTO it1 VALUES(0),(1),(2),(3),(4),(5),(6),(7); +explain SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 on ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a from it1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +1 SIMPLE it1 NULL ALL NULL NULL NULL NULL 8 100.00 Using where; Start temporary; End temporary +1 SIMPLE ot3 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a`,`test`.`ot3`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` join `test`.`ot3` semi join (`test`.`it1`)) on(((`test`.`it1`.`a` = `test`.`ot1`.`a`) and (`test`.`ot3`.`a` = `test`.`ot1`.`a`) and (`test`.`ot2`.`a` = `test`.`ot1`.`a`))) where true +SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 on ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a from it1); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +prepare s from 'SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 on ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a from it1)'; +execute s; +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +execute s; +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +deallocate prepare s; +DROP TABLE ot1, ot2, ot3, it1; +# End of the test for bug#57623. +# +# Bug#11766739: Crash in tmp_table_param::init() with semijoin=on +# +CREATE TABLE t1 (f1 INTEGER) ENGINE=MyISAM; +CREATE TABLE t2 (f1 INTEGER, f2 INTEGER) ENGINE=MyISAM; +INSERT INTO t1 VALUES (1); +INSERT INTO t2 VALUES (1,1), (2,1); +EXPLAIN SELECT * FROM t2 +WHERE f2 IN (SELECT t1.f1 +FROM t1 LEFT OUTER JOIN (t2 AS b1 JOIN t2 AS b2 ON TRUE) ON TRUE); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE b1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE b2 NULL ALL NULL NULL NULL NULL 2 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`f1` AS `f1`,`test`.`t2`.`f2` AS `f2` from `test`.`t2` semi join (`test`.`t1` left join (`test`.`t2` `b1` join `test`.`t2` `b2`) on((true))) where (`test`.`t2`.`f2` = `test`.`t1`.`f1`) +SELECT * FROM t2 +WHERE f2 IN (SELECT t1.f1 +FROM t1 LEFT OUTER JOIN (t2 AS b1 JOIN t2 AS b2 ON TRUE) ON TRUE); +f1 f2 +1 1 +2 1 +DROP TABLE t1, t2; +# End of the test for bug#11766739. +# +# Bug#11766642: crash in Item_field::register_field_in_read_map with view +# +CREATE TABLE t1(a INT); +CREATE VIEW v1 AS SELECT a FROM t1; +INSERT INTO t1 VALUES (0),(1),(2); +SELECT a FROM t1 WHERE a IN +(SELECT a XOR a FROM v1) +ORDER BY a; +a +0 +DROP TABLE t1; +DROP VIEW v1; +# +# Bug#12546542 MISSING ROW WHEN USING OPTIMIZER_JOIN_CACHE_LEVEL>=3 +# +CREATE TABLE t1 ( +f2 varchar(1024) +); +INSERT INTO t1 VALUES ('v'),('we'); +CREATE TABLE t2 ( +col_varchar_1024_utf8 varchar(1024) CHARACTER SET utf8 DEFAULT NULL, +col_int_key int, +col_int int +); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t2 VALUES ('we',4,NULL),('v',1305673728,6); +CREATE TABLE t3 ( +col_int_key int, +col_int int +); +INSERT INTO t3 VALUES (4,4); +SELECT * +FROM t1 +WHERE f2 IN (SELECT a1.col_varchar_1024_utf8 AS f2 +FROM t2 AS a1 LEFT JOIN t3 AS a2 +ON a1.col_int_key = a2.col_int_key +WHERE a1.col_int BETWEEN 1 AND 10 OR a2.col_int IS NOT NULL); +f2 +v +we +DROP TABLE t1,t2,t3; +# +# BUG#12616344 - JCL: DIFFERENT RESULT SET AND DIFFERENT AMOUNT +# OF ROWS WHEN JCL>=3 +# +CREATE TABLE t1 (col_int_nokey int, col_int_key int, col_varchar_key varchar(1)); +INSERT INTO t1 VALUES (0,4,'c'),(1,6,'u'); +CREATE TABLE t2 (pk int, col_int_nokey int, col_varchar_nokey varchar(1)); +INSERT INTO t2 VALUES (1,4,'b'),(94,6,'u'); +CREATE TABLE t3 (pk int, col_int_nokey int, col_varchar_key varchar(1)); +INSERT INTO t3 VALUES (1,4,'j'),(2,6,'v'); +SELECT table2.col_int_key +from t3 as table1 join t1 as table2 on table2.col_int_nokey +where table1.col_int_nokey in +( +select subquery2_t2.col_int_nokey +from t3 as subquery2_t1 +right join +t2 as subquery2_t2 +join t1 as subquery2_t3 +on subquery2_t3.col_int_key = subquery2_t2.col_int_nokey +on subquery2_t3.col_varchar_key = subquery2_t2.col_varchar_nokey +where subquery2_t1.col_varchar_key != table1.col_varchar_key +or subquery2_t2.pk <= table1.pk +); +col_int_key +6 +6 +DROP TABLE t1,t2,t3; +# +# Bug#12608157: ASSERT IN FIELD_LONG::VAL_INT WHEN USING MEMORY ENGINE +# +CREATE TABLE t1 (i1 int); +INSERT INTO t1 VALUES (1); +CREATE TABLE t2 (i1 int, i2 int) ENGINE=memory; +INSERT INTO t2 VALUES (1, 2),(7, 3); +SELECT GRANDPARENT1.i1 +FROM t2 AS GRANDPARENT1 +WHERE GRANDPARENT1.i2 +IN ( SELECT PARENT1.i2 +FROM t2 AS PARENT1 JOIN t1 AS PARENT2 ON (PARENT1.i1 = PARENT2.i1) +WHERE +GRANDPARENT1.i1 IN ( SELECT CHILD1.i1 FROM t2 AS CHILD1 ) +ORDER BY PARENT1.i1) +ORDER BY GRANDPARENT1.i2 ; +i1 +1 +DROP TABLE t1,t2; +# +# Bug#12640083: Same query executed as WHERE subquery gives different +# results on IN() compare +# +CREATE TABLE t1 ( +pk int NOT NULL, +col_varchar_1024_utf8_key varchar(1024) CHARACTER SET utf8 DEFAULT NULL, +col_varchar_10_latin1_key varchar(10) DEFAULT NULL, +PRIMARY KEY (pk), +KEY col_varchar_1024_utf8_key(col_varchar_1024_utf8_key(333)), +KEY col_varchar_10_latin1_key(col_varchar_10_latin1_key) +) charset utf8mb4; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES +(1, 'a', 'a'), +(2, 'ab', 'ab'), +(3, 'abc', 'abc'), +(4, 'abcd', 'abcd'); +CREATE TABLE t2 ( +pk int NOT NULL AUTO_INCREMENT, +PRIMARY KEY (pk) +) charset utf8mb4 ENGINE=Innodb; +CREATE TABLE t3 charset utf8mb4 +SELECT alias1.col_varchar_10_latin1_key +FROM t1 AS alias1 +LEFT JOIN t1 AS alias2 +JOIN t2 AS alias3 +ON alias2.col_varchar_10_latin1_key +ON alias1.col_varchar_1024_utf8_key +WHERE alias1.pk AND alias1.pk < 3 OR alias1.pk AND alias3.pk; +EXPLAIN SELECT * +FROM t3 +WHERE col_varchar_10_latin1_key IN ( +SELECT alias1.col_varchar_10_latin1_key +FROM t1 AS alias1 +LEFT JOIN t1 AS alias2 +JOIN t2 AS alias3 +ON alias2.col_varchar_10_latin1_key +ON alias1.col_varchar_1024_utf8_key +WHERE alias1.pk AND alias1.pk < 3 OR alias1.pk AND alias3.pk); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE alias1 NULL ref PRIMARY,col_varchar_10_latin1_key col_varchar_10_latin1_key 43 test.t3.col_varchar_10_latin1_key 2 100.00 Using where; Start temporary +1 SIMPLE alias3 NULL index NULL PRIMARY 4 NULL 1 100.00 Using where; Using index +1 SIMPLE alias2 NULL index NULL col_varchar_10_latin1_key 43 NULL 4 100.00 Using where; Using index; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`col_varchar_10_latin1_key` AS `col_varchar_10_latin1_key` from `test`.`t3` semi join (`test`.`t1` `alias1` left join (`test`.`t1` `alias2` join `test`.`t2` `alias3`) on(((0 <> `test`.`alias1`.`col_varchar_1024_utf8_key`) and (0 <> `test`.`alias2`.`col_varchar_10_latin1_key`)))) where ((`test`.`alias1`.`col_varchar_10_latin1_key` = `test`.`t3`.`col_varchar_10_latin1_key`) and (((0 <> `test`.`alias1`.`pk`) and (`test`.`alias1`.`pk` < 3)) or ((0 <> `test`.`alias1`.`pk`) and (0 <> `test`.`alias3`.`pk`)))) +SELECT * +FROM t3 +WHERE col_varchar_10_latin1_key IN ( +SELECT alias1.col_varchar_10_latin1_key +FROM t1 AS alias1 +LEFT JOIN t1 AS alias2 +JOIN t2 AS alias3 +ON alias2.col_varchar_10_latin1_key +ON alias1.col_varchar_1024_utf8_key +WHERE alias1.pk AND alias1.pk < 3 OR alias1.pk AND alias3.pk); +col_varchar_10_latin1_key +a +ab +DROP TABLE t1, t2, t3; +# End of the test for bug#12640083. +# +# Bug#12603200 - Assert in QUICK_INDEX_MERGE_SELECT::need_sorted_output +# +CREATE TABLE t1 ( +pk int NOT NULL, +col_int_key int NOT NULL, +col_varchar_nokey varchar(1) NOT NULL, +col_varchar_key varchar(1) NOT NULL, +PRIMARY KEY(pk), +KEY col_int_key(col_int_key), +KEY col_varchar_key(col_varchar_key, col_int_key) +) charset utf8mb4 engine=innodb; +INSERT INTO t1 VALUES +(1,7,'a','a'), +(2,0,'v','v'), +(3,9,'c','c'), +(4,3,'m','m'), +(5,2,'a','a'), +(6,1,'d','d'), +(7,8,'y','y'), +(8,6,'t','t'), +(11,7,'a','x'), +(12,0,'v','v'), +(13,9,'c','c'), +(14,3,'m','m'), +(15,2,'a','x'), +(16,1,'d','d'), +(17,8,'y','y'), +(18,6,'t','u'), +(19,6,'t','u'); +CREATE TABLE t2 ( +pk int NOT NULL, +col_int_key int NOT NULL, +col_varchar_key varchar(1) NOT NULL, +PRIMARY KEY(pk), +KEY col_varchar_key(col_varchar_key, col_int_key) +) charset utf8mb4 engine=innodb; +INSERT INTO t2(pk,col_int_key,col_varchar_key) VALUES +(8,7,'c'), +(11,4,'l'), +(12,7,'b'), +(13,0,'c'), +(14,2,'i'), +(15,9,'h'), +(16,4,'q'), +(17,1,'m'), +(18,9,'b'), +(19,2,'e'), +(20,1,'c'), +(21,7,'z'), +(22,4,'l'), +(23,7,'z'), +(24,0,'c'), +(25,2,'i'), +(26,9,'h'), +(27,4,'q'), +(28,0,'a'), +(29,1,'d'); +EXPLAIN SELECT outr.col_varchar_key AS x, outr.pk AS y +FROM t1 AS outr +WHERE outr.col_varchar_key IN (SELECT innr.col_varchar_key +FROM t2 AS innr +WHERE innr.col_varchar_key = 'a' OR innr.pk = 8) +AND outr.col_varchar_nokey < 't' +ORDER BY outr.col_varchar_key, outr.pk; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE innr NULL index_merge PRIMARY,col_varchar_key col_varchar_key,PRIMARY 6,4 NULL 2 100.00 Using sort_union(col_varchar_key,PRIMARY); Using where; Using temporary; Using filesort; Start temporary +1 SIMPLE outr NULL ref col_varchar_key col_varchar_key 6 test.innr.col_varchar_key 1 33.33 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`outr`.`col_varchar_key` AS `x`,`test`.`outr`.`pk` AS `y` from `test`.`t1` `outr` semi join (`test`.`t2` `innr`) where ((`test`.`outr`.`col_varchar_key` = `test`.`innr`.`col_varchar_key`) and (`test`.`outr`.`col_varchar_nokey` < 't') and ((`test`.`innr`.`col_varchar_key` = 'a') or (`test`.`innr`.`pk` = 8))) order by `test`.`outr`.`col_varchar_key`,`test`.`outr`.`pk` +SELECT outr.col_varchar_key AS x, outr.pk AS y +FROM t1 AS outr +WHERE outr.col_varchar_key IN (SELECT innr.col_varchar_key +FROM t2 AS innr +WHERE innr.col_varchar_key = 'a' OR innr.pk = 8) +AND outr.col_varchar_nokey < 't' +ORDER BY outr.col_varchar_key, outr.pk; +x y +a 1 +a 5 +c 3 +c 13 +DROP TABLE t1, t2; +# End of bug#12603200 +# +# Bug#12603183: Segfault in hp_movelink +# +CREATE TABLE t1 ( +col_varchar_key varchar(1) , +col_varchar_nokey varchar(1) , +KEY col_varchar_key(col_varchar_key) +) charset latin1; +INSERT INTO t1 VALUES +('i','i'), +('h','h'), +('q','q'), +('a','a'), +('v','v'), +('u','u'), +('s','s'), +('y','y'), +('z','z'), +('h','h'), +('p','p'), +('e','e'), +('i','i'), +('y','y'), +('w','w'); +CREATE TABLE t2 ( +col_varchar_nokey varchar(1) +) charset latin1; +INSERT INTO t2 VALUES +('b'); +EXPLAIN SELECT grandparent1.col_varchar_nokey +FROM t1 AS grandparent1 LEFT JOIN t2 AS grandparent2 USING (col_varchar_nokey) +WHERE (grandparent1.col_varchar_key) IN +(SELECT parent1.col_varchar_nokey +FROM t1 AS parent1 +WHERE parent1.col_varchar_key IN +(SELECT child1.col_varchar_nokey AS c1 +FROM t1 AS child1 LEFT JOIN t2 AS child2 +ON (child1.col_varchar_key > child2.col_varchar_nokey))); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE child1 NULL ALL NULL NULL NULL NULL 15 100.00 Using where; Start temporary +1 SIMPLE child2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE parent1 NULL ref col_varchar_key col_varchar_key 4 test.child1.col_varchar_nokey 2 100.00 Using where +1 SIMPLE grandparent1 NULL ref col_varchar_key col_varchar_key 4 test.parent1.col_varchar_nokey 2 100.00 End temporary +1 SIMPLE grandparent2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`grandparent1`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t1` `grandparent1` left join `test`.`t2` `grandparent2` on((`test`.`grandparent2`.`col_varchar_nokey` = `test`.`grandparent1`.`col_varchar_nokey`)) semi join (`test`.`t1` `parent1` join `test`.`t1` `child1` left join `test`.`t2` `child2` on((`test`.`child1`.`col_varchar_key` > `test`.`child2`.`col_varchar_nokey`))) where ((`test`.`grandparent1`.`col_varchar_key` = `test`.`parent1`.`col_varchar_nokey`) and (`test`.`parent1`.`col_varchar_key` = `test`.`child1`.`col_varchar_nokey`)) +SELECT grandparent1.col_varchar_nokey +FROM t1 AS grandparent1 LEFT JOIN t2 AS grandparent2 USING (col_varchar_nokey) +WHERE (grandparent1.col_varchar_key) IN +(SELECT parent1.col_varchar_nokey +FROM t1 AS parent1 +WHERE parent1.col_varchar_key IN +(SELECT child1.col_varchar_nokey AS c1 +FROM t1 AS child1 LEFT JOIN t2 AS child2 +ON (child1.col_varchar_key > child2.col_varchar_nokey))); +col_varchar_nokey +a +e +h +h +i +i +p +q +s +u +v +w +y +y +z +DROP TABLE t1, t2; +# End of test for bug#12603183. +# +# Bug#12818569: Diff nr of rows returned when using IN/ALL+subquery +# +CREATE TABLE t1 ( +col_int_key INT NOT NULL, +col_datetime_key DATETIME NOT NULL, +col_varchar_key VARCHAR(1) NOT NULL, +KEY col_int_key (col_int_key), +KEY col_datetime_key(col_datetime_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t1 VALUES +(7,'2004-06-06 04:22:12','v'), (0,'2005-11-13 01:12:31','s'), +(9,'2002-05-04 01:50:00','l'), (3,'2004-10-27 10:28:45','y'), +(4,'2006-07-22 05:24:23','c'), (2,'2002-05-16 21:34:03','i'), +(5,'2008-04-17 10:45:30','h'), (3,'2009-04-21 02:58:02','q'), +(1,'2008-01-11 11:01:51','a'), (3,'1900-01-01 00:00:00','v'), +(6,'2007-05-17 18:24:57','u'), (7,'2007-08-07 00:00:00','s'), +(5,'2001-08-28 00:00:00','y'), (1,'2004-04-16 00:27:28','z'), +(204,'2005-05-03 07:06:22','h'), (224,'2009-03-11 17:09:50','p'), +(9,'2007-12-08 01:54:28','e'), (5,'2009-07-28 18:19:54','i'), +(0,'2008-06-08 00:00:00','y'), (3,'2005-02-09 09:20:26','w'); +CREATE TABLE t2 ( +col_varchar_nokey VARCHAR(1) NOT NULL +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t2 VALUES ('v'), ('y'), ('j'), ('c'), ('d'), ('r'); +explain SELECT col_varchar_key +FROM t1 +WHERE col_varchar_key IN (SELECT col_varchar_nokey +FROM t2) +ORDER BY col_datetime_key LIMIT 4; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 100.00 Using temporary; Using filesort; Start temporary +1 SIMPLE t1 NULL ref col_varchar_key col_varchar_key 6 test.t2.col_varchar_nokey 1 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col_varchar_key` AS `col_varchar_key` from `test`.`t1` semi join (`test`.`t2`) where (`test`.`t1`.`col_varchar_key` = `test`.`t2`.`col_varchar_nokey`) order by `test`.`t1`.`col_datetime_key` limit 4 +SELECT col_varchar_key +FROM t1 +WHERE col_varchar_key IN (SELECT col_varchar_nokey +FROM t2) +ORDER BY col_datetime_key LIMIT 4; +col_varchar_key +v +y +v +y +DROP TABLE t1, t2; +# End of test for bug#12818569. +# +# Bug#12803439: Assert in replace_subcondition() on update query +# +CREATE TABLE t1(a INTEGER); +INSERT INTO t1 values(1), (2); +CREATE TABLE t2(a INTEGER); +INSERT INTO t2 VALUES(1), (3); +SELECT * +FROM t1 +WHERE a IN (SELECT a +FROM t2 +HAVING a IN (SELECT a +FROM t2) +) +HAVING a IN (SELECT a +FROM t2); +a +1 +DROP TABLE t1, t2; +# End of test for bug#12803439. +# +# Bug#12797534: Segfault in hp_movelink still exists +# +CREATE TABLE t1 ( +g1 VARCHAR(1) NOT NULL +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t1 VALUES ('d'), ('s'); +CREATE TABLE t2 ( +pk INT NOT NULL, +col_int_key INT NOT NULL, +col_varchar_key VARCHAR(1) NOT NULL, +col_varchar_nokey VARCHAR(1) NOT NULL, +PRIMARY KEY (pk), +KEY col_varchar_key(col_varchar_key, col_int_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t2 VALUES +(1,4,'j','j'), (2,6,'v','v'), (3,3,'c','c'), (4,5,'m','m'), +(5,3,'d','d'), (6,246,'d','d'), (7,2,'y','y'), (8,9,'t','t'), +(9,3,'d','d'), (10,8,'s','s'), (11,1,'r','r'), (12,8,'m','m'), +(13,8,'b','b'), (14,5,'x','x'), (15,7,'g','g'), (16,5,'p','p'), +(17,1,'q','q'), (18,6,'w','w'), (19,2,'d','d'), (20,9,'e','e'); +CREATE TABLE t3 ( +pk INTEGER NOT NULL, +PRIMARY KEY (pk) +) ENGINE=InnoDB; +INSERT INTO t3 VALUES (10); +EXPLAIN SELECT * +FROM t1 +WHERE g1 NOT IN +(SELECT grandparent1.col_varchar_nokey AS g1 +FROM t2 AS grandparent1 +WHERE grandparent1.col_varchar_key IN +(SELECT parent1.col_varchar_nokey AS p1 +FROM t2 AS parent1 LEFT JOIN t3 AS parent2 USING (pk) +) +AND grandparent1.col_varchar_key IS NOT NULL +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 SIMPLE parent1 NULL ALL NULL NULL NULL NULL 20 100.00 Using where; Not exists; Start temporary +2 SIMPLE parent2 NULL eq_ref PRIMARY PRIMARY 4 test.parent1.pk 1 100.00 Using index +2 SIMPLE grandparent1 NULL ref col_varchar_key col_varchar_key 6 test.parent1.col_varchar_nokey 1 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`g1` AS `g1` from `test`.`t1` anti join (`test`.`t2` `grandparent1` join `test`.`t2` `parent1` left join `test`.`t3` `parent2` on((`test`.`parent2`.`pk` = `test`.`parent1`.`pk`))) on(((`test`.`grandparent1`.`col_varchar_nokey` = `test`.`t1`.`g1`) and (`test`.`grandparent1`.`col_varchar_key` = `test`.`parent1`.`col_varchar_nokey`) and (`test`.`grandparent1`.`col_varchar_key` is not null))) where true +SELECT * +FROM t1 +WHERE g1 NOT IN +(SELECT grandparent1.col_varchar_nokey AS g1 +FROM t2 AS grandparent1 +WHERE grandparent1.col_varchar_key IN +(SELECT parent1.col_varchar_nokey AS p1 +FROM t2 AS parent1 LEFT JOIN t3 AS parent2 USING (pk) +) +AND grandparent1.col_varchar_key IS NOT NULL +); +g1 +DROP TABLE t1, t2, t3; +CREATE TABLE t1 ( +pk INTEGER AUTO_INCREMENT, +col_int_key INTEGER , +col_varchar_key VARCHAR(1) , +col_varchar_nokey VARCHAR(1) , +PRIMARY KEY (pk), +KEY (col_varchar_key,col_int_key) +) ENGINE=INNODB; +INSERT INTO t1 (col_int_key,col_varchar_key,col_varchar_nokey) VALUES +(0,'x','x'), (1,'j','j'), (1,'r','r'), (9,'v','v'), (5,'r','r'); +CREATE TABLE t2 ( +pk INTEGER AUTO_INCREMENT, +col_int_key INTEGER , +col_varchar_key VARCHAR(1) , +col_varchar_nokey VARCHAR(1) , +PRIMARY KEY (pk), +KEY (col_int_key), +KEY (col_varchar_key,col_int_key) +) AUTO_INCREMENT=10 ENGINE=INNODB; +INSERT INTO t2 (col_int_key, col_varchar_key, col_varchar_nokey) VALUES +(NULL,'x','x'), (NULL,'j','j'), (8,'c','c'); +CREATE TABLE t3 +SELECT outr.col_varchar_nokey AS x +FROM t1 AS outr +WHERE outr.col_varchar_nokey IN +(SELECT innr.col_varchar_nokey AS y +FROM t2 AS innr +WHERE innr.col_int_key IS NULL) +AND outr.col_varchar_nokey IS NOT NULL +AND NOT col_varchar_key IS NULL; +SELECT * +FROM t3 +WHERE x NOT IN +(SELECT outr.col_varchar_nokey AS x +FROM t1 AS outr +WHERE outr.col_varchar_nokey IN +(SELECT innr.col_varchar_nokey AS y +FROM t2 AS innr +WHERE innr.col_int_key IS NULL) +AND outr.col_varchar_nokey IS NOT NULL +AND NOT col_varchar_key IS NULL); +x +DROP TABLE t1, t2, t3; +# End of test for bug#12797534. +# +# Bug#12714094: Assert in optimize_semijoin_nests() +# +CREATE TABLE it ( +pk int NOT NULL, +col_varchar VARCHAR(10) DEFAULT NULL, +PRIMARY KEY (pk) +) ENGINE=MyISAM; +INSERT INTO it VALUES (1, 'g'); +CREATE TABLE ot +SELECT alias1.pk AS field1 +FROM it AS alias1 +LEFT JOIN it AS alias2 +ON alias1.col_varchar = alias2.col_varchar +; +SELECT * +FROM ot +WHERE field1 IN ( +SELECT alias1.pk +FROM it AS alias1 +LEFT JOIN it AS alias2 +ON alias1.col_varchar = alias2.col_varchar +); +field1 +1 +DROP TABLE it, ot; +# End of test for bug#12714094 +# +# Bug#12867557: Valgrind: conditional jump/move at key_cmp +# +CREATE TABLE t1 ( +pk INTEGER AUTO_INCREMENT, +col_int_key INTEGER, +PRIMARY KEY (pk), +KEY (col_int_key) +) AUTO_INCREMENT=10; +INSERT INTO t1 (col_int_key) VALUES (8); +CREATE TABLE t2 ( +pk INTEGER AUTO_INCREMENT, +col_int_key INTEGER, +col_time_key TIME, +PRIMARY KEY (pk), +KEY (col_int_key), +KEY (col_time_key) +) AUTO_INCREMENT=10; +INSERT INTO t2 (col_int_key, col_time_key) +VALUES +(8, '22:55:23.019225'), (7, '10:19:31.050677'), (1, '14:40:36.038608'), +(7, '04:37:47.062416'), (9, '19:34:06.054514'), (NULL,'20:35:33.022996'), +(1, NULL), (9, '14:43:37.057393'), (2, '02:23:09.043438'), +(9, '01:22:45.041064'), (2, '00:00:00'), (4, '00:13:25.038482'), +(0, '03:47:16.042671'), (4, '01:41:48.007423'), (8, '00:00:00'), +(NULL, '22:32:04.047407'), (NULL, '16:44:14.028443'), (0, '17:38:37.059754'), +(NULL, '08:46:48.042388'), (8, '14:11:27.044095'); +CREATE TABLE t0 +SELECT DISTINCT grandparent1.col_time_key AS g1 +FROM t2 AS grandparent1 +WHERE grandparent1.col_int_key IN +(SELECT parent1.col_int_key AS p1 +FROM t1 AS parent1) +AND grandparent1.pk > 9; +UPDATE t0 +SET g1 = g1 +WHERE g1 IN +(SELECT grandparent1.col_time_key AS g1 +FROM t2 AS grandparent1 +WHERE grandparent1.col_int_key IN +(SELECT parent1.col_int_key AS p1 +FROM t1 AS parent1) +AND grandparent1.pk > 9); +DROP TABLE t0, t1, t2; +# End of test for bug#12867557 +# +# Bug#12711441: crash in fix_after_pullout +# +CREATE TABLE t1 ( +pk int NOT NULL, +col_int_nokey int DEFAULT NULL, +col_int_key int DEFAULT NULL, +col_time_key time DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +PRIMARY KEY (pk) +); +CREATE VIEW v1 AS SELECT * FROM t1; +CREATE TABLE t2 ( +col_int_key int DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +KEY col_varchar_key(col_varchar_key, col_int_key) +); +CREATE TABLE t3 ( +pk int NOT NULL, +col_int_key INT DEFAULT NULL, +PRIMARY KEY (pk) +); +CREATE TABLE t4 ( +col_int_nokey INT DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +KEY col_varchar_key(col_varchar_key) +); +CREATE TABLE ts +SELECT alias1.col_time_key AS field1 +FROM v1 AS alias1 +RIGHT JOIN t3 AS alias2 +ON alias2.col_int_key = alias1.col_int_nokey +WHERE alias1.pk >= SOME( +SELECT SQ1_alias1.pk AS SQ1_field1 +FROM t3 AS SQ1_alias1 +INNER JOIN (t2 AS SQ1_alias2 +INNER JOIN t4 AS SQ1_alias3 +ON SQ1_alias3.col_varchar_key = SQ1_alias2.col_varchar_nokey) +ON SQ1_alias3.col_int_nokey = SQ1_alias2.col_int_key +WHERE SQ1_alias2.col_varchar_key <= alias1.col_varchar_key +AND SQ1_alias3.col_varchar_nokey <> alias1.col_varchar_key) +; +SELECT * FROM ts WHERE field1 IN ( +SELECT alias1.col_time_key AS field1 +FROM v1 AS alias1 +RIGHT JOIN t3 AS alias2 +ON alias2.col_int_key = alias1.col_int_nokey +WHERE alias1.pk >= SOME( +SELECT SQ1_alias1.pk AS SQ1_field1 +FROM t3 AS SQ1_alias1 +INNER JOIN (t2 AS SQ1_alias2 +INNER JOIN t4 AS SQ1_alias3 +ON SQ1_alias3.col_varchar_key = SQ1_alias2.col_varchar_nokey) +ON SQ1_alias3.col_int_nokey = SQ1_alias2.col_int_key +WHERE SQ1_alias2.col_varchar_key <= alias1.col_varchar_key +AND SQ1_alias3.col_varchar_nokey <> alias1.col_varchar_key) +); +field1 +DROP TABLE t1, t2, t3, t4, ts; +DROP VIEW v1; +# End of test for bug#12711441. +# +# Bug#12664936: Same query executed as where subquery ... +# +CREATE TABLE t1 ( +col_varchar_key VARCHAR(1), +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4; +INSERT INTO t1 VALUES +('o'), ('w'), ('m'), ('q'), +('f'), ('p'), ('j'), ('c'); +CREATE TABLE t2 ( +col_int_nokey INTEGER, +col_int_key INTEGER, +col_varchar_key varchar(1), +KEY col_int_key (col_int_key) +) charset utf8mb4; +INSERT INTO t2 VALUES +(8,5,'u'),(4,5,'p'),(8,1,'o'),(NULL,7,'v'), +(1,2,'g'),(2,1,'q'),(NULL,7,'l'),(3,1,'n'); +CREATE TABLE t4 +SELECT t2.col_int_nokey, t2.col_varchar_key +FROM t1 JOIN t2 ON t2.col_varchar_key = t1.col_varchar_key +WHERE t2.col_int_key = 1; +EXPLAIN SELECT * +FROM t4 +WHERE (col_int_nokey, col_varchar_key) IN +(SELECT t2.col_int_nokey, t2.col_varchar_key +FROM t1 JOIN t2 ON t2.col_varchar_key = t1.col_varchar_key +WHERE t2.col_int_key = 1 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t4 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE t2 NULL ref col_int_key col_int_key 5 const 3 12.50 Using where; Start temporary +1 SIMPLE t1 NULL ref col_varchar_key col_varchar_key 7 test.t4.col_varchar_key 2 100.00 Using index; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`col_int_nokey` AS `col_int_nokey`,`test`.`t4`.`col_varchar_key` AS `col_varchar_key` from `test`.`t4` semi join (`test`.`t1` join `test`.`t2`) where ((`test`.`t2`.`col_varchar_key` = `test`.`t4`.`col_varchar_key`) and (`test`.`t1`.`col_varchar_key` = `test`.`t4`.`col_varchar_key`) and (`test`.`t2`.`col_int_nokey` = `test`.`t4`.`col_int_nokey`) and (`test`.`t2`.`col_int_key` = 1)) +SELECT * +FROM t4 +WHERE (col_int_nokey, col_varchar_key) IN +(SELECT t2.col_int_nokey, t2.col_varchar_key +FROM t1 JOIN t2 ON t2.col_varchar_key = t1.col_varchar_key +WHERE t2.col_int_key = 1 +); +col_int_nokey col_varchar_key +8 o +2 q +DROP TABLE t1, t2, t4; +# End of test for bug#12664936. +# +# Bug#13340270: assertion table->sort.record_pointers == __null +# +CREATE TABLE t1 ( +pk int NOT NULL, +col_int_key int DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key, col_int_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t1 VALUES +(10,8,'x','x'), +(11,7,'d','d'), +(12,1,'r','r'), +(13,7,'f','f'), +(14,9,'y','y'), +(15,NULL,'u','u'), +(16,1,'m','m'), +(17,9,NULL,NULL), +(18,2,'o','o'), +(19,9,'w','w'), +(20,2,'m','m'), +(21,4,'q','q'); +CREATE TABLE t2 +SELECT alias1.col_varchar_nokey AS field1 +FROM t1 AS alias1 JOIN t1 AS alias2 +ON alias2.col_int_key = alias1.pk OR +alias2.col_int_key = alias1.col_int_key +WHERE alias1.pk = 58 OR alias1.col_varchar_key = 'o' + +; +EXPLAIN SELECT * +FROM t2 +WHERE (field1) IN (SELECT alias1.col_varchar_nokey AS field1 +FROM t1 AS alias1 JOIN t1 AS alias2 +ON alias2.col_int_key = alias1.pk OR +alias2.col_int_key = alias1.col_int_key +WHERE alias1.pk = 58 OR alias1.col_varchar_key = 'o' +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE alias1 NULL index_merge PRIMARY,col_int_key,col_varchar_key col_varchar_key,PRIMARY 7,4 NULL 2 10.00 Using sort_union(col_varchar_key,PRIMARY); Using where; Start temporary +1 SIMPLE alias2 NULL ALL col_int_key NULL NULL NULL 12 19.00 Range checked for each record (index map: 0x2); End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`field1` AS `field1` from `test`.`t2` semi join (`test`.`t1` `alias1` join `test`.`t1` `alias2`) where ((`test`.`alias1`.`col_varchar_nokey` = `test`.`t2`.`field1`) and ((`test`.`alias1`.`pk` = 58) or (`test`.`alias1`.`col_varchar_key` = 'o')) and ((`test`.`alias2`.`col_int_key` = `test`.`alias1`.`pk`) or (`test`.`alias2`.`col_int_key` = `test`.`alias1`.`col_int_key`))) +SELECT * +FROM t2 +WHERE (field1) IN (SELECT alias1.col_varchar_nokey AS field1 +FROM t1 AS alias1 JOIN t1 AS alias2 +ON alias2.col_int_key = alias1.pk OR +alias2.col_int_key = alias1.col_int_key +WHERE alias1.pk = 58 OR alias1.col_varchar_key = 'o' +); +field1 +o +o +DROP TABLE t1, t2; +# End of test for bug#13340270. +# +# Bug#13335319: Seg fault when analyzing FirstMatch semi-join strategy +# +CREATE TABLE ot1(a INTEGER); +INSERT INTO ot1 VALUES(1), (2), (3); +CREATE TABLE ot2(a INTEGER); +INSERT INTO ot2 VALUES(1), (2), (4), (6), (8), (10); +CREATE TABLE it1(a INTEGER); +INSERT INTO it1 VALUES(1), (3), (5), (7); +CREATE TABLE it2(a INTEGER); +INSERT INTO it2 VALUES(1), (3), (5), (7), (9); +explain SELECT ot1.a, ot2.a +FROM ot1, ot2 +WHERE ot1.a IN (SELECT a FROM it1) AND +ot2.a IN (SELECT a FROM it2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE it1 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; Start temporary +1 SIMPLE it2 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` join `test`.`ot2` semi join (`test`.`it1`) semi join (`test`.`it2`) where ((`test`.`ot2`.`a` = `test`.`it2`.`a`) and (`test`.`it1`.`a` = `test`.`ot1`.`a`)) +SELECT ot1.a, ot2.a +FROM ot1, ot2 +WHERE ot1.a IN (SELECT a FROM it1) AND +ot2.a IN (SELECT a FROM it2); +a a +1 1 +3 1 +DROP TABLE ot1, ot2, it1, it2; +# End of test for bug#13335319. +# +# Bug#13334882: Assertion keypart_map failed in MyIsam function +# +CREATE TABLE t1 ( +pk int NOT NULL, +col_int_nokey INT NOT NULL, +col_int_key INT NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +) ENGINE=MyISAM; +INSERT INTO t1 VALUES +(1,4,0), +(2,6,8), +(3,3,1), +(7,2,6), +(8,9,1), +(9,3,6), +(10,8,2), +(11,1,4), +(12,8,8), +(13,8,4), +(14,5,4); +CREATE TABLE t2 ( +pk int NOT NULL, +col_int_nokey int NOT NULL, +col_int_key int NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +) ENGINE=MyISAM; +INSERT INTO t2 VALUES +(10,8,7); +CREATE TABLE t3 +SELECT grandparent1.col_int_nokey AS g1 +FROM t1 AS grandparent1 +WHERE (grandparent1.col_int_nokey, grandparent1.col_int_key) IN +(SELECT parent1.col_int_key AS p1, +parent1.col_int_key AS p2 +FROM t1 AS parent1 +LEFT JOIN t2 AS parent2 +ON parent1.col_int_nokey = parent2.col_int_key +) +AND grandparent1.col_int_key <> 3 +; +explain SELECT * FROM t3 +WHERE g1 NOT IN +(SELECT grandparent1.col_int_nokey AS g1 +FROM t1 AS grandparent1 +WHERE (grandparent1.col_int_nokey, grandparent1.col_int_key) IN +(SELECT parent1.col_int_key AS p1, +parent1.col_int_key AS p2 +FROM t1 AS parent1 +LEFT JOIN t2 AS parent2 +ON parent1.col_int_nokey = parent2.col_int_key +) +AND grandparent1.col_int_key <> 3 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE grandparent1 NULL ref col_int_key col_int_key 4 const 1 100.00 Using where; Not exists; Start temporary +1 SIMPLE parent1 NULL ref col_int_key col_int_key 4 test.grandparent1.col_int_nokey 1 100.00 Using where +1 SIMPLE parent2 NULL ref col_int_key col_int_key 4 test.parent1.col_int_nokey 2 100.00 Using index; End temporary +Warnings: +Note 1003 /* select#1 */ select '8' AS `g1` from anti join (`test`.`t1` `grandparent1` join `test`.`t1` `parent1` left join `test`.`t2` `parent2` on((`test`.`parent2`.`col_int_key` = `test`.`parent1`.`col_int_nokey`))) on(((`test`.`grandparent1`.`col_int_nokey` = '8') and (`test`.`grandparent1`.`col_int_key` = '8') and (`test`.`parent1`.`col_int_key` = '8') and ('8' <> 3))) where true +explain format=json SELECT * FROM t3 +WHERE g1 NOT IN +(SELECT grandparent1.col_int_nokey AS g1 +FROM t1 AS grandparent1 +WHERE (grandparent1.col_int_nokey, grandparent1.col_int_key) IN +(SELECT parent1.col_int_key AS p1, +parent1.col_int_key AS p2 +FROM t1 AS parent1 +LEFT JOIN t2 AS parent2 +ON parent1.col_int_nokey = parent2.col_int_key +) +AND grandparent1.col_int_key <> 3 +); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "2.70" + }, + "nested_loop": [ + { + "table": { + "table_name": "t3", + "access_type": "system", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.00", + "eval_cost": "0.10", + "prefix_cost": "0.00", + "data_read_per_join": "8" + }, + "used_columns": [ + "g1" + ] + } + }, + { + "duplicates_removal": { + "using_temporary_table": true, + "nested_loop": [ + { + "table": { + "table_name": "grandparent1", + "access_type": "ref", + "possible_keys": [ + "col_int_key" + ], + "key": "col_int_key", + "used_key_parts": [ + "col_int_key" + ], + "key_length": "4", + "ref": [ + "const" + ], + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "not_exists": true, + "cost_info": { + "read_cost": "0.28", + "eval_cost": "0.11", + "prefix_cost": "0.39", + "data_read_per_join": "17" + }, + "used_columns": [ + "col_int_nokey", + "col_int_key" + ], + "attached_condition": "(((is_not_null_compl(grandparent1..parent2), (found_match(grandparent1..parent2), false, true), true) and (is_not_null_compl(grandparent1..parent2), (('8' <> 3)), true)) and (is_not_null_compl(grandparent1..parent2), (`test`.`grandparent1`.`col_int_nokey` = '8'), true))" + } + }, + { + "table": { + "table_name": "parent1", + "access_type": "ref", + "possible_keys": [ + "col_int_key" + ], + "key": "col_int_key", + "used_key_parts": [ + "col_int_key" + ], + "key_length": "4", + "ref": [ + "test.grandparent1.col_int_nokey" + ], + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.30", + "eval_cost": "0.12", + "prefix_cost": "0.81", + "data_read_per_join": "19" + }, + "used_columns": [ + "col_int_nokey", + "col_int_key" + ], + "attached_condition": "(is_not_null_compl(grandparent1..parent2), (`test`.`parent1`.`col_int_key` = '8'), true)" + } + }, + { + "table": { + "table_name": "parent2", + "access_type": "ref", + "possible_keys": [ + "col_int_key" + ], + "key": "col_int_key", + "used_key_parts": [ + "col_int_key" + ], + "key_length": "4", + "ref": [ + "test.parent1.col_int_nokey" + ], + "rows_examined_per_scan": 2, + "rows_produced_per_join": 1, + "filtered": "100.00", + "using_index": true, + "cost_info": { + "read_cost": "0.31", + "eval_cost": "0.10", + "prefix_cost": "2.70", + "data_read_per_join": "16" + }, + "used_columns": [ + "col_int_key" + ] + } + } + ] + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select '8' AS `g1` from anti join (`test`.`t1` `grandparent1` join `test`.`t1` `parent1` left join `test`.`t2` `parent2` on((`test`.`parent2`.`col_int_key` = `test`.`parent1`.`col_int_nokey`))) on(((`test`.`grandparent1`.`col_int_nokey` = '8') and (`test`.`grandparent1`.`col_int_key` = '8') and (`test`.`parent1`.`col_int_key` = '8') and ('8' <> 3))) where true +SELECT * FROM t3 +WHERE g1 NOT IN +(SELECT grandparent1.col_int_nokey AS g1 +FROM t1 AS grandparent1 +WHERE (grandparent1.col_int_nokey, grandparent1.col_int_key) IN +(SELECT parent1.col_int_key AS p1, +parent1.col_int_key AS p2 +FROM t1 AS parent1 +LEFT JOIN t2 AS parent2 +ON parent1.col_int_nokey = parent2.col_int_key +) +AND grandparent1.col_int_key <> 3 +); +g1 +DROP TABLE t1, t2, t3; +# End of test for bug#13334882. +# +# Bug#13339643: Assertion on JOIN::flatten_subqueries on second execution +# +CREATE TABLE t1 ( +col_int_nokey INT, +col_varchar_nokey VARCHAR(1) +) charset utf8mb4; +INSERT INTO t1 VALUES +(1,'o'), +(2,'t'); +CREATE TABLE t2 LIKE t1; +INSERT INTO t2 VALUES +(1,'o'), +(4,'f'); +CREATE VIEW v_t2 AS SELECT * FROM t2; +CREATE TABLE t3 LIKE t1; +INSERT INTO t3 VALUES +(1,'o'), +(4,'f'); +explain SELECT alias1.col_varchar_nokey +FROM t1 AS alias1 +INNER JOIN v_t2 AS alias2 +ON alias2.col_int_nokey = alias1.col_int_nokey AND +'o' IN (SELECT col_varchar_nokey +FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary; End temporary +1 SIMPLE alias1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`alias1`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t1` `alias1` join `test`.`t2` semi join (`test`.`t3`) where ((`test`.`t3`.`col_varchar_nokey` = 'o') and (`test`.`t2`.`col_int_nokey` = `test`.`alias1`.`col_int_nokey`)) +SELECT alias1.col_varchar_nokey +FROM t1 AS alias1 +INNER JOIN v_t2 AS alias2 +ON alias2.col_int_nokey = alias1.col_int_nokey AND +'o' IN (SELECT col_varchar_nokey +FROM t3); +col_varchar_nokey +o +PREPARE stmt FROM "SELECT alias1.col_varchar_nokey +FROM t1 AS alias1 +INNER JOIN v_t2 AS alias2 +ON alias2.col_int_nokey = alias1.col_int_nokey AND +'o' IN (SELECT col_varchar_nokey +FROM t3)"; +EXECUTE stmt; +col_varchar_nokey +o +DROP VIEW v_t2; +DROP TABLE t1, t2, t3; +# End of test for bug#13339643. +# +# Bug#13424134: Wrong result on JOIN + nested WHERE ... IN clauses +# +CREATE TABLE t1 ( +pk int NOT NULL, +col_int_nokey int NOT NULL, +col_int_key int NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +) ENGINE=MyIsam; +INSERT INTO t1 VALUES +(10,1,7), (13,7,3), (18,0,1), (23,8,1); +CREATE TABLE t2 ( +pk int NOT NULL, +col_int_key int NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +) ENGINE=MyIsam; +INSERT INTO t2 VALUES (1,7); +EXPLAIN SELECT t1a.* +FROM t1 AS t1a +JOIN t1 AS t1b USING ( col_int_nokey ) +WHERE t1a.col_int_key IN ( +SELECT pk +FROM t2 +WHERE col_int_key IN ( +SELECT col_int_nokey +FROM t1 +) +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL system PRIMARY,col_int_key NULL NULL NULL 1 100.00 NULL +1 SIMPLE t1a NULL ref col_int_key col_int_key 4 const 1 100.00 NULL +1 SIMPLE t1b NULL ALL NULL NULL NULL NULL 4 25.00 Using where +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; Start temporary; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1a`.`pk` AS `pk`,`test`.`t1a`.`col_int_nokey` AS `col_int_nokey`,`test`.`t1a`.`col_int_key` AS `col_int_key` from `test`.`t1` `t1a` join `test`.`t1` `t1b` semi join (`test`.`t1`) where ((`test`.`t1b`.`col_int_nokey` = `test`.`t1a`.`col_int_nokey`) and (`test`.`t1a`.`col_int_key` = '1') and (`test`.`t1`.`col_int_nokey` = '7')) +SELECT t1a.* +FROM t1 AS t1a +JOIN t1 AS t1b USING ( col_int_nokey ) +WHERE t1a.col_int_key IN ( +SELECT pk +FROM t2 +WHERE col_int_key IN ( +SELECT col_int_nokey +FROM t1 +) +); +pk col_int_nokey col_int_key +18 0 1 +23 8 1 +ALTER TABLE t1 ENGINE=Innodb; +ALTER TABLE t2 ENGINE=Innodb; +SELECT t1a.* +FROM t1 AS t1a +JOIN t1 AS t1b USING ( col_int_nokey ) +WHERE t1a.col_int_key IN ( +SELECT pk +FROM t2 +WHERE col_int_key IN ( +SELECT col_int_nokey +FROM t1 +) +); +pk col_int_nokey col_int_key +18 0 1 +23 8 1 +DROP TABLE t1, t2; +# End of test for bug#13424134. +# +# Bug#13414014: Extra rows in result on semijoin query with where ... +# +CREATE TABLE t1 ( +c INT, +d INT, +a VARCHAR(1), +b VARCHAR(1), +KEY a (a) +) charset utf8mb4; +INSERT INTO t1 VALUES +(NULL,8,'x','x'), (7,4,'q','q'), (6,8,'c','c'); +CREATE TABLE t2 ( +a VARCHAR(1), +KEY a (a) +) charset utf8mb4; +INSERT INTO t2 VALUES +('c'), (NULL), ('x'), ('q'); +explain SELECT * +FROM t2 AS ot +WHERE (a, a) IN +(SELECT a, b +FROM t1 AS it +WHERE it.a = 'x' OR it.c > it.d +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE it NULL ALL a NULL NULL NULL 3 40.74 Using where; Start temporary +1 SIMPLE ot NULL ref a a 7 test.it.a 2 100.00 Using index; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`ot`.`a` AS `a` from `test`.`t2` `ot` semi join (`test`.`t1` `it`) where ((`test`.`it`.`b` = `test`.`it`.`a`) and (`test`.`ot`.`a` = `test`.`it`.`a`) and ((`test`.`it`.`a` = 'x') or (`test`.`it`.`c` > `test`.`it`.`d`))) +SELECT * +FROM t2 AS ot +WHERE (a, a) IN +(SELECT a, b +FROM t1 AS it +WHERE it.a = 'x' OR it.c > it.d +) +; +a +q +x +DROP TABLE t1, t2; +# End of test for bug#13414014. +# +# Bug#13545215: Missing rows on nested in-subquery with materialization +# +CREATE TABLE t1 ( +col_int_key int, +col_varchar_key varchar(1), +col_varchar_nokey varchar(1), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +INSERT INTO t1 VALUES +(8,'x','x'), (0,'p','p'), (8,'c','c'); +CREATE TABLE t2 ( +pk int NOT NULL, +col_varchar_key varchar(1), +col_varchar_nokey varchar(1), +PRIMARY KEY (pk), +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4; +INSERT INTO t2 VALUES +(1,'v','v'), (2,'v','v'), (3,'c','c'), (4,NULL,NULL), +(5,'x','x'), (6,'i','i'), (7,'e','e'), (8,'p','p'); +CREATE TABLE t3 ( +col_int_nokey int +); +INSERT INTO t3 VALUES (7); +explain SELECT grandparent1.col_varchar_nokey +FROM t1 AS grandparent1 JOIN t1 AS grandparent2 USING (col_int_key) +WHERE grandparent1.col_varchar_key IN ( +SELECT col_varchar_nokey +FROM t2 AS parent1 +WHERE col_varchar_key IN ( +SELECT child1.col_varchar_nokey +FROM t2 AS child1 LEFT JOIN t3 AS child2 +ON child1.pk < child2.col_int_nokey +) +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE grandparent1 NULL ALL col_int_key,col_varchar_key NULL NULL NULL 3 100.00 Using where +1 SIMPLE parent1 NULL ALL col_varchar_key NULL NULL NULL 8 12.50 Using where; Start temporary +1 SIMPLE child1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where +1 SIMPLE child2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary +1 SIMPLE grandparent2 NULL ref col_int_key col_int_key 5 test.grandparent1.col_int_key 2 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`grandparent1`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t1` `grandparent1` join `test`.`t1` `grandparent2` semi join (`test`.`t2` `parent1` join `test`.`t2` `child1` left join `test`.`t3` `child2` on((`test`.`child1`.`pk` < `test`.`child2`.`col_int_nokey`))) where ((`test`.`grandparent2`.`col_int_key` = `test`.`grandparent1`.`col_int_key`) and (`test`.`parent1`.`col_varchar_nokey` = `test`.`grandparent1`.`col_varchar_key`) and (`test`.`child1`.`col_varchar_nokey` = `test`.`parent1`.`col_varchar_key`)) +SELECT grandparent1.col_varchar_nokey +FROM t1 AS grandparent1 JOIN t1 AS grandparent2 USING (col_int_key) +WHERE grandparent1.col_varchar_key IN ( +SELECT col_varchar_nokey +FROM t2 AS parent1 +WHERE col_varchar_key IN ( +SELECT child1.col_varchar_nokey +FROM t2 AS child1 LEFT JOIN t3 AS child2 +ON child1.pk < child2.col_int_nokey +) +); +col_varchar_nokey +c +c +p +x +x +DROP TABLE t1, t2, t3; +# End of test for bug#13545215. +# +# BUG#13553211 - MISSING ROWS ON SELECT WITH IN-SUBQUERY AND +# MATERIALIZATION + SEMIJOIN ON +# +CREATE TABLE t1 ( +col_int_key int(11) DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (4,'v','v'); +INSERT INTO t1 VALUES (62,'v','v'); +INSERT INTO t1 VALUES (7,'c','c'); +INSERT INTO t1 VALUES (1,NULL,NULL); +EXPLAIN SELECT +alias1.col_varchar_nokey AS a1_nokey, +alias1.col_varchar_key AS a1_key, +alias2.col_varchar_nokey AS a2_nokey +FROM +t1 AS alias1, t1 AS alias2 +WHERE +(alias1.col_varchar_nokey,alias2.col_varchar_nokey) +IN +( +SELECT +sq2_alias2.col_varchar_nokey, sq2_alias1.col_varchar_key +FROM +t1 AS sq2_alias1, t1 AS sq2_alias2 +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE alias1 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +1 SIMPLE sq2_alias2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; Start temporary +1 SIMPLE alias2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +1 SIMPLE sq2_alias1 NULL ref col_varchar_key col_varchar_key 7 test.alias2.col_varchar_nokey 2 100.00 Using index; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`alias1`.`col_varchar_nokey` AS `a1_nokey`,`test`.`alias1`.`col_varchar_key` AS `a1_key`,`test`.`alias2`.`col_varchar_nokey` AS `a2_nokey` from `test`.`t1` `alias1` join `test`.`t1` `alias2` semi join (`test`.`t1` `sq2_alias1` join `test`.`t1` `sq2_alias2`) where ((`test`.`sq2_alias1`.`col_varchar_key` = `test`.`alias2`.`col_varchar_nokey`) and (`test`.`sq2_alias2`.`col_varchar_nokey` = `test`.`alias1`.`col_varchar_nokey`)) +SELECT +alias1.col_varchar_nokey AS a1_nokey, +alias1.col_varchar_key AS a1_key, +alias2.col_varchar_nokey AS a2_nokey +FROM +t1 AS alias1, t1 AS alias2 +WHERE +(alias1.col_varchar_nokey,alias2.col_varchar_nokey) +IN +( +SELECT +sq2_alias2.col_varchar_nokey, sq2_alias1.col_varchar_key +FROM +t1 AS sq2_alias1, t1 AS sq2_alias2 +) +; +a1_nokey a1_key a2_nokey +c c c +c c v +c c v +v v c +v v c +v v v +v v v +v v v +v v v +DROP TABLE t1; +# +# Bug#13541406: Wrong result with loosescan on select .. where .. in +# +CREATE TABLE t1 ( +col_int_key INT NOT NULL, +col_varchar_nokey VARCHAR(1) NOT NULL, +KEY col_int_key (col_int_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t1 VALUES +(7,'v'), (0,'s'), (9,'l'), (3,'y'), (4,'c'), (2,'i'), (5,'h'), (3,'q'), +(1,'a'), (3,'v'), (6,'u'), (7,'s'), (5,'y'), (1,'z'), (204,'h'), (224,'p'), +(9,'e'), (5,'i'), (0,'y'), (3,'w'); +CREATE TABLE t2 ( +pk INT NOT NULL, +col_int_key INT NOT NULL, +col_varchar_key VARCHAR(1) NOT NULL, +col_varchar_nokey VARCHAR(1) NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t2 VALUES +(1,0,'j','j'), (2,8,'v','v'), (3,1,'c','c'), (4,8,'m','m'), +(5,9,'d','d'), (6,24,'d','d'), (7,6,'y','y'), (8,1,'t','t'), +(9,6,'d','d'), (10,2,'s','s'), (11,4,'r','r'), (12,8,'m','m'), +(13,4,'b','b'), (14,4,'x','x'), (15,7,'g','g'), (16,4,'p','p'), +(17,1,'q','q'), (18,9,'w','w'), (19,4,'d','d'), (20,8,'e','e'); +# This query should never use a LooseScan strategy +explain SELECT ot1.col_int_key AS field1 +FROM t2 AS ot1, t2 AS ot2 +WHERE (ot1.col_varchar_key, ot2.col_varchar_nokey) IN ( +SELECT it2.col_varchar_nokey, it1.col_varchar_key +FROM t2 AS it1 JOIN t1 AS it2 ON it2.col_int_key = it1.pk); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 20 100.00 Parallel execute (1 workers) +2 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 20 100.00 NULL +2 SIMPLE it1 NULL ref PRIMARY,col_varchar_key col_varchar_key 6 test.ot2.col_varchar_nokey 1 100.00 Using index; Start temporary +2 SIMPLE it2 NULL ref col_int_key col_int_key 4 test.it1.pk 1 100.00 NULL +2 SIMPLE ot1 NULL ref col_varchar_key col_varchar_key 6 test.it2.col_varchar_nokey 1 100.00 Using index; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`col_int_key` AS `field1` from `test`.`t2` `ot1` join `test`.`t2` `ot2` semi join (`test`.`t2` `it1` join `test`.`t1` `it2`) where ((`test`.`it2`.`col_int_key` = `test`.`it1`.`pk`) and (`test`.`it1`.`col_varchar_key` = `test`.`ot2`.`col_varchar_nokey`) and (`test`.`ot1`.`col_varchar_key` = `test`.`it2`.`col_varchar_nokey`)) +SELECT ot1.col_int_key AS field1 +FROM t2 AS ot1, t2 AS ot2 +WHERE (ot1.col_varchar_key, ot2.col_varchar_nokey) IN ( +SELECT it2.col_varchar_nokey, it1.col_varchar_key +FROM t2 AS it1 JOIN t1 AS it2 ON it2.col_int_key = it1.pk); +field1 +1 +1 +1 +2 +6 +6 +6 +6 +6 +8 +8 +8 +8 +8 +8 +9 +DROP TABLE t1, t2; +# End of test for bug#13541406. +# +# Bug#13576391: Missing rows on select with in-subquery and +# batched-key-access=on and semijoin +# +CREATE TABLE t1 ( +col_int_nokey int NOT NULL, +col_varchar_key varchar(1) NOT NULL, +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4 engine=InnoDB; +INSERT INTO t1 VALUES +(1,'v'), (7,'s'), (4,'l'), (7,'y'), (0,'c'), (2,'i'), (9,'h'), (4,'q'), +(0,'a'), (9,'v'), (1,'u'), (3,'s'), (8,'y'), (8,'z'), (18,'h'), (84,'p'), +(6,'e'), (3,'i'), (6,'y'), (6,'w'); +CREATE TABLE t2 ( +col_int_nokey int NOT NULL, +col_varchar_nokey varchar(1) NOT NULL +) charset utf8mb4 engine=InnoDB; +INSERT INTO t2 VALUES +(4,'j'), (6,'v'), (3,'c'), (5,'m'), (3,'d'), (246,'d'), (2,'y'), (9,'t'), +(3,'d'), (8,'s'), (1,'r'), (8,'m'), (8,'b'), (5,'x'), (7,'g'), (5,'p'), +(1,'q'), (6,'w'), (2,'d'), (9,'e'); +explain SELECT col_varchar_nokey +FROM t2 AS ot +WHERE col_varchar_nokey IN ( +SELECT col_varchar_key +FROM t1 AS it +WHERE it.col_int_nokey <= it.col_int_nokey +AND NOT ot.col_int_nokey < 2 +) +ORDER BY col_varchar_nokey; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 20 33.33 Parallel execute (1 workers) +2 SIMPLE ot NULL ALL NULL NULL NULL NULL 20 33.33 Using where; Using filesort +2 SIMPLE it NULL ref col_varchar_key col_varchar_key 6 test.ot.col_varchar_nokey 1 100.00 Start temporary; End temporary +Warnings: +Note 1276 Field or reference 'test.ot.col_int_nokey' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`ot`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t2` `ot` semi join (`test`.`t1` `it`) where ((`test`.`it`.`col_varchar_key` = `test`.`ot`.`col_varchar_nokey`) and (`test`.`ot`.`col_int_nokey` >= 2)) order by `test`.`ot`.`col_varchar_nokey` +SELECT col_varchar_nokey +FROM t2 AS ot +WHERE col_varchar_nokey IN ( +SELECT col_varchar_key +FROM t1 AS it +WHERE it.col_int_nokey <= it.col_int_nokey +AND NOT ot.col_int_nokey < 2 +) +ORDER BY col_varchar_nokey; +col_varchar_nokey +c +e +p +s +v +w +y +ALTER TABLE t1 ENGINE=MyISAM; +ALTER TABLE t2 ENGINE=MyISAM; +explain SELECT col_varchar_nokey +FROM t2 AS ot +WHERE col_varchar_nokey IN ( +SELECT col_varchar_key +FROM t1 AS it +WHERE it.col_int_nokey <= it.col_int_nokey +AND NOT ot.col_int_nokey < 2 +) +ORDER BY col_varchar_nokey; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 20 33.33 Using where; Using filesort +1 SIMPLE it NULL ref col_varchar_key col_varchar_key 6 test.ot.col_varchar_nokey 2 100.00 Start temporary; End temporary +Warnings: +Note 1276 Field or reference 'test.ot.col_int_nokey' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`ot`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t2` `ot` semi join (`test`.`t1` `it`) where ((`test`.`it`.`col_varchar_key` = `test`.`ot`.`col_varchar_nokey`) and (`test`.`ot`.`col_int_nokey` >= 2)) order by `test`.`ot`.`col_varchar_nokey` +SELECT col_varchar_nokey +FROM t2 AS ot +WHERE col_varchar_nokey IN ( +SELECT col_varchar_key +FROM t1 AS it +WHERE it.col_int_nokey <= it.col_int_nokey +AND NOT ot.col_int_nokey < 2 +) +ORDER BY col_varchar_nokey; +col_varchar_nokey +c +e +p +s +v +w +y +ALTER TABLE t1 ENGINE=Memory; +ALTER TABLE t2 ENGINE=Memory; +explain SELECT col_varchar_nokey +FROM t2 AS ot +WHERE col_varchar_nokey IN ( +SELECT col_varchar_key +FROM t1 AS it +WHERE it.col_int_nokey <= it.col_int_nokey +AND NOT ot.col_int_nokey < 2 +) +ORDER BY col_varchar_nokey; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 20 33.33 Using where; Using filesort +1 SIMPLE it NULL ref col_varchar_key col_varchar_key 6 test.ot.col_varchar_nokey 2 100.00 Start temporary; End temporary +Warnings: +Note 1276 Field or reference 'test.ot.col_int_nokey' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`ot`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t2` `ot` semi join (`test`.`t1` `it`) where ((`test`.`it`.`col_varchar_key` = `test`.`ot`.`col_varchar_nokey`) and (`test`.`ot`.`col_int_nokey` >= 2)) order by `test`.`ot`.`col_varchar_nokey` +SELECT col_varchar_nokey +FROM t2 AS ot +WHERE col_varchar_nokey IN ( +SELECT col_varchar_key +FROM t1 AS it +WHERE it.col_int_nokey <= it.col_int_nokey +AND NOT ot.col_int_nokey < 2 +) +ORDER BY col_varchar_nokey; +col_varchar_nokey +c +e +p +s +v +w +y +DROP TABLE t1, t2; +# End of test for bug#13576391. +# +# Bug #13589848 "MISSING ROW ON SELECT WITH NESTED IN CLAUSES WHEN LOOSESCAN=ON" +# +CREATE TABLE t1 ( +id INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +KEY (col_varchar_key) +) charset utf8mb4; +INSERT INTO t1 VALUES (100,'m','m'), +(200,'b','b'), (300,'x','x'); +CREATE TABLE t2 ( +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +KEY (col_varchar_key) +) charset utf8mb4; +INSERT INTO t2 VALUES ('b','b'); +CREATE TABLE t3 ( +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +KEY (col_varchar_key) +) charset utf8mb4; +INSERT INTO t3 VALUES ('k','k'); +EXPLAIN SELECT gp1.id +FROM t1 AS gp1 JOIN t3 AS gp2 +ON gp2.col_varchar_key <> gp1.col_varchar_nokey +WHERE (gp1.col_varchar_nokey, gp1.col_varchar_nokey) +IN ( +SELECT col_varchar_nokey, col_varchar_nokey +FROM t1 +WHERE col_varchar_nokey +IN ( SELECT col_varchar_key +FROM t2 LEFT JOIN t3 USING (col_varchar_key) ) +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE gp2 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL index col_varchar_key col_varchar_key 7 NULL 1 100.00 Using where; Using index; Start temporary +1 SIMPLE gp1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +1 SIMPLE t3 NULL ref col_varchar_key col_varchar_key 7 test.t2.col_varchar_key 2 100.00 Using index; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`gp1`.`id` AS `id` from `test`.`t1` `gp1` semi join (`test`.`t1` join `test`.`t2` left join `test`.`t3` on((`test`.`t2`.`col_varchar_key` = `test`.`t3`.`col_varchar_key`))) where ((`test`.`gp1`.`col_varchar_nokey` = `test`.`t2`.`col_varchar_key`) and (`test`.`t1`.`col_varchar_nokey` = `test`.`t2`.`col_varchar_key`) and ('k' <> `test`.`t2`.`col_varchar_key`)) +SELECT gp1.id +FROM t1 AS gp1 JOIN t3 AS gp2 +ON gp2.col_varchar_key <> gp1.col_varchar_nokey +WHERE (gp1.col_varchar_nokey, gp1.col_varchar_nokey) +IN ( +SELECT col_varchar_nokey, col_varchar_nokey +FROM t1 +WHERE col_varchar_nokey +IN ( SELECT col_varchar_key +FROM t2 LEFT JOIN t3 USING (col_varchar_key) ) +) +; +id +200 +DROP TABLE t1,t2,t3; +# +# Bug #13596176: Missing row on select with nested in clause when +# matr=on and bnl=off + MyISAM +# +CREATE TABLE t1 ( +int_key int DEFAULT NULL, +vc_key varchar(1) DEFAULT NULL, +vc_nokey varchar(1) DEFAULT NULL, +KEY int_key (int_key), +KEY vc_key (vc_key, int_key) +) charset utf8mb4 ENGINE=MyISAM; +INSERT INTO t1 VALUES +(8,'x','x'), (7,'d','d'), (1,'r','r'), (7,'f','f'), +(9,'y','y'), (NULL,'u','u'), (1,'m','m'), (9,NULL,NULL), +(2,'o','o'), (9,'w','w'), (2,'m','m'), (4,'q','q'), +(0,NULL,NULL), (4,'d','d'), (8,'g','g'), (NULL,'x','x'), +(NULL,'f','f'), (0,'p','p'), (NULL,'j','j'), (8,'c','c'); +CREATE TABLE t2 ( +int_key int DEFAULT NULL, +vc_key varchar(1) DEFAULT NULL, +KEY int_key (int_key), +KEY vc_key (vc_key, int_key) +) charset utf8mb4 ENGINE=MyISAM; +INSERT INTO t2 VALUES (8,'g'); +explain SELECT vc_key +FROM t1 as outr +WHERE (vc_nokey, vc_key ) IN +(SELECT vc_nokey, vc_nokey +FROM t1 middle +WHERE vc_nokey IN +(SELECT child1.vc_key +FROM t2 AS child1 JOIN t1 AS child2 USING (int_key) +) +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE child1 NULL index int_key,vc_key vc_key 12 NULL 1 100.00 Using where; Using index; Start temporary +1 SIMPLE outr NULL ref vc_key vc_key 7 test.child1.vc_key 3 10.00 Using where +1 SIMPLE middle NULL ALL NULL NULL NULL NULL 20 10.00 Using where +1 SIMPLE child2 NULL ref int_key int_key 5 test.child1.int_key 3 100.00 Using index; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`outr`.`vc_key` AS `vc_key` from `test`.`t1` `outr` semi join (`test`.`t1` `middle` join `test`.`t2` `child1` join `test`.`t1` `child2`) where ((`test`.`child2`.`int_key` = `test`.`child1`.`int_key`) and (`test`.`outr`.`vc_nokey` = `test`.`child1`.`vc_key`) and (`test`.`outr`.`vc_key` = `test`.`child1`.`vc_key`) and (`test`.`middle`.`vc_nokey` = `test`.`child1`.`vc_key`)) +SELECT vc_key +FROM t1 as outr +WHERE (vc_nokey, vc_key ) IN +(SELECT vc_nokey, vc_nokey +FROM t1 middle +WHERE vc_nokey IN +(SELECT child1.vc_key +FROM t2 AS child1 JOIN t1 AS child2 USING (int_key) +) +); +vc_key +g +DROP TABLE t1, t2; +# End of test for bug#13596176. +# +# BUG#11754478: MAX/MIN + SUBQUERY + AND FAILS TO RETURN ANY ROWS +# BUG#13599013: MAX/MIN + SUBQUERY IN WHERE CLAUSE MATCHING NO +# ROWS + INDEX DOES NOT RETURN NULL +# +CREATE TABLE t1 ( +pk int(11) PRIMARY KEY, +int_key int(11), +KEY int_key (int_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (1,0),(2,0),(3,2),(4,0),(5,3),(6,0); +SELECT MIN(int_key) FROM t1 WHERE (4, 4) IN (SELECT 1, 2); +MIN(int_key) +NULL +SELECT MIN(int_key) FROM t1 WHERE (4, 4) IN (SELECT 4, 4); +MIN(int_key) +0 +SELECT MIN(pk) FROM t1 WHERE pk IN (SELECT int_key FROM t1) AND pk = 6; +MIN(pk) +NULL +DROP TABLE t1; +# BUG#13726217: Crash in Item_ident::fix_after_pullout() +CREATE TABLE t1(a INTEGER) engine=innodb; +INSERT INTO t1 VALUES (0); +SELECT 0 +FROM t1 +WHERE 0 IN +(SELECT 0 +FROM t1 +WHERE 0 LIKE +(SELECT elt(a, 0) AS b +FROM t1 +GROUP BY a +HAVING b +) +); +0 +DROP TABLE t1; +# End of test for bug#13726217. +# BUG#13773979: Missing rows on second execution of prepared statement +CREATE TABLE t1 ( +col_int_nokey INT, +col_int_key INT, +col_varchar_key VARCHAR(1) +); +INSERT INTO t1 VALUES +(1,7,'v'), (7,0,'s'), (4,9,'l'), (7,3,'y'), +(2,2,'i'), (9,5,'h'), (0,1,'a'), (9,3,'v'); +CREATE VIEW v1 AS SELECT * FROM t1; +SELECT * +FROM t1 +WHERE col_int_key IN ( +SELECT alias1.col_int_nokey AS field1 +FROM v1 AS alias1 +WHERE alias1.col_varchar_key < 'v' +); +col_int_nokey col_int_key col_varchar_key +1 7 v +2 2 i +4 9 l +7 0 s +prepare stmt FROM "SELECT * +FROM t1 +WHERE col_int_key IN ( +SELECT alias1.col_int_nokey AS field1 +FROM v1 AS alias1 +WHERE alias1.col_varchar_key < 'v' +)"; +execute stmt; +col_int_nokey col_int_key col_varchar_key +1 7 v +2 2 i +4 9 l +7 0 s +execute stmt; +col_int_nokey col_int_key col_varchar_key +1 7 v +2 2 i +4 9 l +7 0 s +DEALLOCATE PREPARE stmt; +DROP VIEW v1; +DROP TABLE t1; +# End of test for bug#13773979. +# +# BUG#13685026 ASSERTION CUR_SJ_INNER_TABLES == 0 IN +# --OPTIMIZE_TABLE_ORDER::CHOOSE_TABLE_ORDER +# +CREATE TABLE t1 ( +col_int_key INT(11) NOT NULL, +col_datetime_key DATETIME NOT NULL, +col_varchar_key VARCHAR(1) NOT NULL, +col_varchar_nokey VARCHAR(1) NOT NULL, +KEY col_int_key (col_int_key), +KEY col_datetime_key (col_datetime_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (0,'2002-02-13 17:30:06','j','j'); +INSERT INTO t1 VALUES (8,'2008-09-27 00:34:58','v','v'); +CREATE TABLE t2 ( +col_int_key INT(11) NOT NULL, +col_datetime_key DATETIME NOT NULL, +col_varchar_key VARCHAR(1) NOT NULL, +col_varchar_nokey VARCHAR(1) NOT NULL, +KEY col_int_key (col_int_key), +KEY col_datetime_key (col_datetime_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (7,'2003-08-21 00:00:00','b','b'); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +SET @old_depth=@@optimizer_search_depth; +SET optimizer_search_depth=4; +EXPLAIN SELECT col_datetime_key +FROM t1 as outr +WHERE col_datetime_key IN ( +SELECT alias1.col_datetime_key +FROM t1 AS alias1 +LEFT JOIN t1 as alias3 +STRAIGHT_JOIN ( t2 AS alias4 +JOIN t1 AS alias5 +ON alias5.col_varchar_key <= alias4.col_varchar_nokey ) +ON alias5.col_int_key < alias4.col_int_key +ON alias5.col_varchar_key = alias4.col_varchar_key +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE outr NULL index col_datetime_key col_datetime_key 5 NULL 2 100.00 Using index +1 SIMPLE alias1 NULL ref col_datetime_key col_datetime_key 5 test.outr.col_datetime_key 1 100.00 Using index; Start temporary +1 SIMPLE alias4 NULL ALL col_int_key,col_varchar_key NULL NULL NULL 1 100.00 NULL +1 SIMPLE alias5 NULL ref col_int_key,col_varchar_key col_varchar_key 6 test.alias4.col_varchar_key 1 100.00 Using where; Using index +1 SIMPLE alias3 NULL index NULL col_int_key 4 NULL 2 100.00 Using index; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`outr`.`col_datetime_key` AS `col_datetime_key` from `test`.`t1` `outr` semi join (`test`.`t1` `alias1` left join (`test`.`t1` `alias3` join `test`.`t2` `alias4` join `test`.`t1` `alias5`) on(((`test`.`alias5`.`col_varchar_key` = `test`.`alias4`.`col_varchar_key`) and (`test`.`alias5`.`col_int_key` < `test`.`alias4`.`col_int_key`) and (`test`.`alias5`.`col_varchar_key` <= `test`.`alias4`.`col_varchar_nokey`)))) where (`test`.`alias1`.`col_datetime_key` = `test`.`outr`.`col_datetime_key`) +SELECT col_datetime_key +FROM t1 as outr +WHERE col_datetime_key IN ( +SELECT alias1.col_datetime_key +FROM t1 AS alias1 +LEFT JOIN t1 as alias3 +STRAIGHT_JOIN ( t2 AS alias4 +JOIN t1 AS alias5 +ON alias5.col_varchar_key <= alias4.col_varchar_nokey ) +ON alias5.col_int_key < alias4.col_int_key +ON alias5.col_varchar_key = alias4.col_varchar_key +); +col_datetime_key +2002-02-13 17:30:06 +2008-09-27 00:34:58 +DROP TABLE t1,t2; +SET @@optimizer_search_depth=@old_depth; +# +# BUG#13848789: SEGFAULT IN JOIN_READ_NEXT_SAME AT +# SQL/SQL_EXECUTOR.CC ON HAVING...IN...JOIN +# +CREATE TABLE t1 ( +col_int_key INT, +col_varchar_key VARCHAR(1), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4; +INSERT INTO t1 VALUES (8,'x'); +CREATE TABLE t2 ( +col_varchar_key VARCHAR(1), +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4; +INSERT INTO t2 VALUES ('x'), ('y'); +explain SELECT MIN(col_int_key) +FROM t1 as t1_outer +HAVING (1, 2) IN ( +SELECT t1_inner.col_int_key, MAX(t1_inner.col_int_key) +FROM t1 as t1_inner JOIN t2 +ON t2.col_varchar_key = t1_inner.col_varchar_key +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible HAVING +2 SUBQUERY t1_inner NULL system col_varchar_key NULL NULL NULL 1 100.00 NULL +2 SUBQUERY t2 NULL ref col_varchar_key col_varchar_key 7 const 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select min(`test`.`t1_outer`.`col_int_key`) AS `MIN(col_int_key)` from `test`.`t1` `t1_outer` having false +SELECT MIN(col_int_key) +FROM t1 as t1_outer +HAVING (1, 2) IN ( +SELECT t1_inner.col_int_key, MAX(t1_inner.col_int_key) +FROM t1 as t1_inner JOIN t2 +ON t2.col_varchar_key = t1_inner.col_varchar_key +); +MIN(col_int_key) +DROP TABLE t1,t2; +# Bug#13838810: Segfault in evaluate_null_complemented_join_record +CREATE TABLE t1 ( +pk int NOT NULL, +col_int_nokey int DEFAULT NULL, +col_int_key int DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t1 VALUES (10,NULL,8,'x'); +CREATE TABLE t2 ( +pk int NOT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +PRIMARY KEY (pk) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t2 VALUES (1,'x'); +CREATE TABLE t3 ( +pk int NOT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +PRIMARY KEY (pk), +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t3 VALUES +(1,'v','v'), (2,'v','v'), (3,'c','c'), (4,NULL,NULL); +EXPLAIN SELECT table1.pk,table2.pk, table3.pk +FROM t2 AS table1 +LEFT JOIN t1 AS table2 +LEFT JOIN t1 AS table3 +ON table3.col_int_key = table2.col_int_key +ON table3.pk = table2.col_int_nokey AND +table1.col_varchar_nokey IN ( +SELECT subquery3_t1.col_varchar_nokey +FROM t3 AS subquery3_t1 +LEFT JOIN t1 AS subquery3_t2 +ON subquery3_t2.col_varchar_key = subquery3_t1.col_varchar_key +WHERE subquery3_t2.col_int_nokey <> 9 +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE table1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE table2 NULL ALL col_int_key NULL NULL NULL 1 100.00 NULL +2 SIMPLE table3 NULL eq_ref PRIMARY,col_int_key PRIMARY 4 test.table2.col_int_nokey 1 100.00 Using where +2 SIMPLE subquery3_t2 NULL ALL col_varchar_key NULL NULL NULL 1 100.00 Using where; Start temporary +2 SIMPLE subquery3_t1 NULL ref col_varchar_key col_varchar_key 7 test.subquery3_t2.col_varchar_key 1 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`table1`.`pk` AS `pk`,`test`.`table2`.`pk` AS `pk`,`test`.`table3`.`pk` AS `pk` from `test`.`t2` `table1` left join (`test`.`t1` `table2` join `test`.`t1` `table3` semi join (`test`.`t3` `subquery3_t1` join `test`.`t1` `subquery3_t2`)) on(((`test`.`table3`.`col_int_key` = `test`.`table2`.`col_int_key`) and (`test`.`subquery3_t1`.`col_varchar_key` = `test`.`subquery3_t2`.`col_varchar_key`) and (`test`.`subquery3_t1`.`col_varchar_nokey` = `test`.`table1`.`col_varchar_nokey`) and (`test`.`table3`.`pk` = `test`.`table2`.`col_int_nokey`) and (`test`.`subquery3_t2`.`col_int_nokey` <> 9))) where true +SELECT table1.pk,table2.pk, table3.pk +FROM t2 AS table1 +LEFT JOIN t1 AS table2 +LEFT JOIN t1 AS table3 +ON table3.col_int_key = table2.col_int_key +ON table3.pk = table2.col_int_nokey AND +table1.col_varchar_nokey IN ( +SELECT subquery3_t1.col_varchar_nokey +FROM t3 AS subquery3_t1 +LEFT JOIN t1 AS subquery3_t2 +ON subquery3_t2.col_varchar_key = subquery3_t1.col_varchar_key +WHERE subquery3_t2.col_int_nokey <> 9 +) +; +pk pk pk +1 NULL NULL +DROP TABLE t1, t2, t3; +Extra test case for specific code coverage +CREATE TABLE t1(pk INTEGER); +INSERT INTO t1 VALUES(1), (2); +explain SELECT * +FROM t1 AS ot1 LEFT JOIN t1 AS ot2 +ON ot1.pk=ot2.pk AND +ot2.pk IN +(SELECT it1.pk +FROM t1 AS it1 LEFT JOIN t1 AS it2 ON it1.pk=it2.pk); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE it1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Start temporary +1 SIMPLE it2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`pk` AS `pk`,`test`.`ot2`.`pk` AS `pk` from `test`.`t1` `ot1` left join (`test`.`t1` `ot2` semi join (`test`.`t1` `it1` left join `test`.`t1` `it2` on((`test`.`it1`.`pk` = `test`.`it2`.`pk`)))) on(((`test`.`ot2`.`pk` = `test`.`ot1`.`pk`) and (`test`.`it1`.`pk` = `test`.`ot1`.`pk`))) where true +SELECT * +FROM t1 AS ot1 LEFT JOIN t1 AS ot2 +ON ot1.pk=ot2.pk AND +ot2.pk IN +(SELECT it1.pk +FROM t1 AS it1 LEFT JOIN t1 AS it2 ON it1.pk=it2.pk); +pk pk +1 1 +2 2 +DROP TABLE t1; +# End of test for bug#13838810. +# +# Bug#13845930: Segfault in st_join_table::and_with_condition +# +CREATE TABLE t1 ( +col_int INTEGER +); +CREATE TABLE t2 ( +col_varchar_1 VARCHAR(1), +col_varchar_2 VARCHAR(1) +); +INSERT INTO t2 VALUES ('x','x'), ('c','c'); +PREPARE stmt FROM ' +SELECT alias2.col_varchar_2 AS field1 +FROM t2 AS alias1 + JOIN + (t2 AS alias2 + LEFT JOIN t2 AS alias3 + ON (8, 92) IN + (SELECT sq1_alias1.col_int, + sq1_alias2.col_int + FROM t1 AS sq1_alias1 JOIN t1 AS sq1_alias2 + ) + ) + ON alias3.col_varchar_1 = alias2.col_varchar_2 +'; +EXECUTE stmt; +field1 + +EXECUTE stmt; +field1 +DEALLOCATE prepare stmt; +DROP TABLE t1, t2; +# End of test for bug#13845930. +# +# Bug#13855925: Assert 'prebuilt->search_tuple->n_fields > 0' +# in ha_innobase::index_read +# +CREATE TABLE t1 ( +pk INTEGER AUTO_INCREMENT, +col_int_nokey INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk), +KEY (col_varchar_key) +) charset utf8mb4 ENGINE=INNODB; +INSERT INTO t1 ( +col_int_key, col_int_nokey, +col_varchar_key, col_varchar_nokey +) VALUES +(4, 2, 'v','v'), (62, 150, 'v','v'), (7, NULL, 'c','c'), (1, 2, NULL, NULL), +(0, 5, 'x','x'), (7, 3, 'i','i'), (7, 1, 'e','e'), (1, 4, 'p','p'), +(7, NULL, 's','s'), (1, 2, 'j','j'), (5, 6, 'z','z'), (2, 6, 'c','c'), +(0, 8, 'a','a'), (1, 2, 'q','q'), (8, 6, 'y','y'), (1, 8, NULL, NULL), +(1, 3, 'r','r'), (9, 3, 'v','v'), (1, 9, NULL, NULL), (5, 6, 'r','r'); +CREATE TABLE t2 ( +pk INT AUTO_INCREMENT, +col_int_nokey INT, +col_int_key INT, +PRIMARY KEY (pk), +KEY (col_int_key) +) charset utf8mb4 AUTO_INCREMENT=10 ENGINE=INNODB; +INSERT INTO t2 (col_int_key, col_int_nokey) VALUES +(8, NULL), (7, 8), (1, 1), (7, 9), (9, 4), (NULL, 3), (1, 2), (9, NULL), +(2, 2), (9, NULL), (2, 6), (4, 7), (0, 2), (4, 5), (8, 7), (NULL, 6), +(NULL, 6), (0, 2), (NULL, 9), (8, 6); +CREATE TABLE t3 ( +pk INT AUTO_INCREMENT, +col_varchar_key VARCHAR(1), +PRIMARY KEY (pk), +KEY (col_varchar_key) +) charset utf8mb4 ENGINE=INNODB; +INSERT INTO t3 (col_varchar_key) VALUES +('c'), ('c'), ('q'), ('g'), ('e'), ('l'), (NULL), ('c'), ('h'), ('d'), +('c'), ('i'), ('t'), ('g'), ('q'), ('l'), ('n'), ('z'), ('n'), ('r'), ('p'); +CREATE VIEW v1 AS +SELECT table2.col_varchar_nokey AS field1 +FROM t2 AS table1 +INNER JOIN (t1 AS table2 +STRAIGHT_JOIN t2 AS table3 +ON table3.col_int_key = table2.pk AND +table3.col_int_nokey = ANY +(SELECT subquery1_t2.col_int_nokey AS subquery1_field1 +FROM t2 AS subquery1_t1 +RIGHT OUTER JOIN t1 AS subquery1_t2 +INNER JOIN t1 AS subquery1_t3 +ON subquery1_t3.col_int_key = subquery1_t2.pk +ON subquery1_t3.col_varchar_key=subquery1_t2.col_varchar_nokey +WHERE subquery1_t1.pk > 1 +) +) +ON table3.col_int_key IN +(SELECT subquery2_t1.col_int_key AS subquery2_field1 +FROM t2 AS subquery2_t1 +RIGHT OUTER JOIN t3 AS subquery2_t2 +LEFT OUTER JOIN t1 AS subquery2_t3 +ON subquery2_t3.col_varchar_key = subquery2_t2.col_varchar_key +ON subquery2_t3.pk = subquery2_t2.pk +) +; +explain SELECT * FROM v1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE table1 NULL index NULL col_int_key 5 NULL 20 100.00 Using index +1 SIMPLE subquery1_t3 NULL ALL col_varchar_key NULL NULL NULL 20 100.00 Using where; Start temporary +1 SIMPLE subquery1_t2 NULL eq_ref PRIMARY PRIMARY 4 test.subquery1_t3.col_int_key 1 10.00 Using where +1 SIMPLE table2 NULL ALL PRIMARY NULL NULL NULL 20 100.00 NULL +1 SIMPLE table3 NULL ref col_int_key col_int_key 5 test.table2.pk 2 10.00 Using where +1 SIMPLE subquery2_t3 NULL index PRIMARY,col_varchar_key col_varchar_key 7 NULL 20 100.00 Using where; Using index +1 SIMPLE subquery2_t2 NULL eq_ref PRIMARY,col_varchar_key PRIMARY 4 test.subquery2_t3.pk 1 7.14 Using where +1 SIMPLE subquery2_t1 NULL ref col_int_key col_int_key 5 test.table2.pk 2 100.00 Using index +1 SIMPLE subquery1_t1 NULL index PRIMARY col_int_key 5 NULL 20 100.00 Using where; Using index; End temporary +Warnings: +Note 1003 /* select#1 */ select `table2`.`col_varchar_nokey` AS `field1` from `test`.`t2` `table1` join `test`.`t1` `table2` straight_join `test`.`t2` `table3` semi join (`test`.`t1` `subquery1_t2` join `test`.`t1` `subquery1_t3` join `test`.`t2` `subquery1_t1`) semi join (`test`.`t3` `subquery2_t2` join `test`.`t1` `subquery2_t3` join `test`.`t2` `subquery2_t1`) where ((`subquery1_t2`.`pk` = `subquery1_t3`.`col_int_key`) and (`subquery1_t2`.`col_varchar_nokey` = `subquery1_t3`.`col_varchar_key`) and (`subquery2_t2`.`col_varchar_key` = `subquery2_t3`.`col_varchar_key`) and (`subquery2_t2`.`pk` = `subquery2_t3`.`pk`) and (`table3`.`col_int_key` = `table2`.`pk`) and (`subquery2_t1`.`col_int_key` = `table2`.`pk`) and (`table3`.`col_int_nokey` = `subquery1_t2`.`col_int_nokey`) and (`subquery1_t1`.`pk` > 1)) +SELECT * FROM v1; +field1 +v +v +v +v +v +v +v +v +v +v +v +v +v +v +v +v +v +v +v +v +DROP VIEW v1; +DROP TABLE t1,t2,t3; +# End of test for bug#13855925. +# +# Bug#13897959: Segfault in setup_semijoin_dups_elimination() +# +CREATE TABLE t1 ( +col_datetime_key DATETIME DEFAULT NULL, +KEY col_datetime_key (col_datetime_key) +) ENGINE=MyISAM; +INSERT INTO t1 VALUES +('2001-04-18 00:00:00'), ('2008-12-18 19:39:55'), +('2000-08-01 12:19:39'), ('2004-09-25 21:29:06'), +('2009-09-20 09:11:48'), ('2004-03-27 09:32:04'); +CREATE TABLE t2 ( +col_date_nokey date DEFAULT NULL, +col_time_key time DEFAULT NULL, +col_datetime_key datetime DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +KEY col_time_key (col_time_key), +KEY col_datetime_key (col_datetime_key), +KEY col_varchar_key(col_varchar_key) +) ENGINE=MyISAM; +INSERT INTO t2 VALUES ('1900-01-01',NULL,'2001-11-04 19:07:55','x','x'); +SELECT grandparent1.col_varchar_nokey +FROM t2 AS grandparent1 LEFT JOIN t1 USING (col_datetime_key) +WHERE grandparent1.col_varchar_nokey IN ( +SELECT col_varchar_nokey +FROM t2 AS parent1 +WHERE parent1.col_time_key > grandparent1.col_date_nokey +); +col_varchar_nokey +DROP TABLE t1, t2; +# End of test for bug#13897959. +# +# Bug#13898625 ASSERT `(REMAINING_TABLES_AFTER != 0) ...' IN +# BEST_EXTENSION_BY_LIMITED_SEARCH +# +CREATE TABLE t1 ( +pk int(11) NOT NULL, +col_int_nokey INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (26,6,NULL,'f','f'); +INSERT INTO t1 VALUES (29,6,8,'c','c'); +CREATE TABLE t2 ( +pk INT NOT NULL, +col_int_nokey INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +INSERT INTO t2 VALUES (1,2,4,'v','v'); +INSERT INTO t2 VALUES (2,150,62,'v','v'); +INSERT INTO t2 VALUES (5,5,0,'x','x'); +INSERT INTO t2 VALUES (6,3,7,'i','i'); +INSERT INTO t2 VALUES (7,1,7,'e','e'); +CREATE VIEW view_c AS SELECT * FROM t2; +PREPARE prep_stmt_7430 FROM 'SELECT SUM( alias1.col_varchar_key ) AS field1 +FROM t1 AS alias1 +RIGHT JOIN t2 AS alias2 +INNER JOIN t1 AS alias3 +ON (alias3.col_varchar_key = alias2.col_varchar_key ) +ON ( "v" ) IN ( +SELECT sq1_alias1.col_varchar_nokey AS sq1_field1 +FROM t1 AS sq1_alias1 +) +WHERE alias3.pk IN ( +SELECT sq2_alias1.col_int_key AS sq2_field1 +FROM ( view_c AS sq2_alias1, t1 AS sq2_alias2 ) +) +'; +EXECUTE prep_stmt_7430; +field1 +NULL +EXECUTE prep_stmt_7430; +field1 +NULL +EXPLAIN SELECT SUM( alias1.col_varchar_key ) AS field1 +FROM t1 AS alias1 +RIGHT JOIN t2 AS alias2 +INNER JOIN t1 AS alias3 +ON (alias3.col_varchar_key = alias2.col_varchar_key ) +ON ( "v" ) IN ( +SELECT sq1_alias1.col_varchar_nokey AS sq1_field1 +FROM t1 AS sq1_alias1 +) +WHERE alias3.pk IN ( +SELECT sq2_alias1.col_int_key AS sq2_field1 +FROM ( view_c AS sq2_alias1, t1 AS sq2_alias2 ) +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE alias3 NULL ALL PRIMARY,col_varchar_key NULL NULL NULL 2 100.00 Using where +1 SIMPLE alias2 NULL ref col_varchar_key col_varchar_key 7 test.alias3.col_varchar_key 2 100.00 Using index +1 SIMPLE sq2_alias2 NULL index NULL PRIMARY 4 NULL 2 100.00 Using index; Start temporary +1 SIMPLE t2 NULL ref col_int_key col_int_key 5 test.alias3.pk 2 100.00 Using index +1 SIMPLE sq1_alias1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE alias1 NULL index NULL col_varchar_key 12 NULL 2 100.00 Using index; End temporary +Warnings: +Note 1003 /* select#1 */ select sum(`test`.`alias1`.`col_varchar_key`) AS `field1` from `test`.`t2` `alias2` join `test`.`t1` `alias3` left join (`test`.`t1` `alias1` semi join (`test`.`t1` `sq1_alias1`)) on(((`test`.`sq1_alias1`.`col_varchar_nokey` = 'v'))) semi join (`test`.`t2` join `test`.`t1` `sq2_alias2`) where ((`test`.`alias2`.`col_varchar_key` = `test`.`alias3`.`col_varchar_key`) and (`test`.`t2`.`col_int_key` = `test`.`alias3`.`pk`)) +PREPARE prep_stmt_7430 FROM 'SELECT SUM( alias1.col_varchar_key ) AS field1 +FROM t1 AS alias1 +RIGHT JOIN t2 AS alias2 +INNER JOIN t1 AS alias3 +ON (alias3.col_varchar_key = alias2.col_varchar_key ) +ON ( "v" ) IN ( +SELECT sq1_alias1.col_varchar_nokey AS sq1_field1 +FROM t1 AS sq1_alias1 +) +WHERE alias3.pk IN ( +SELECT sq2_alias1.col_int_key AS sq2_field1 +FROM ( view_c AS sq2_alias1 , t1 AS sq2_alias2 ) +WHERE sq2_alias1.col_varchar_nokey <> alias2.col_varchar_key +AND sq2_alias1.col_varchar_key < "l" + ) +'; +EXECUTE prep_stmt_7430; +field1 +NULL +EXECUTE prep_stmt_7430; +field1 +NULL +EXPLAIN SELECT SUM( alias1.col_varchar_key ) AS field1 +FROM t1 AS alias1 +RIGHT JOIN t2 AS alias2 +INNER JOIN t1 AS alias3 +ON (alias3.col_varchar_key = alias2.col_varchar_key ) +ON ( "v" ) IN ( +SELECT sq1_alias1.col_varchar_nokey AS sq1_field1 +FROM t1 AS sq1_alias1 +) +WHERE alias3.pk IN ( +SELECT sq2_alias1.col_int_key AS sq2_field1 +FROM ( view_c AS sq2_alias1 , t1 AS sq2_alias2 ) +WHERE sq2_alias1.col_varchar_nokey <> alias2.col_varchar_key +AND sq2_alias1.col_varchar_key < "l" + ) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE alias3 NULL ALL PRIMARY,col_varchar_key NULL NULL NULL 2 100.00 Using where +1 SIMPLE t2 NULL ref col_int_key,col_varchar_key col_int_key 5 test.alias3.pk 2 40.00 Using where; Start temporary +1 SIMPLE alias2 NULL ref col_varchar_key col_varchar_key 7 test.alias3.col_varchar_key 2 100.00 Using index +1 SIMPLE sq2_alias2 NULL index NULL PRIMARY 4 NULL 2 100.00 Using index +1 SIMPLE sq1_alias1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE alias1 NULL index NULL col_varchar_key 12 NULL 2 100.00 Using index; End temporary +Warnings: +Note 1276 Field or reference 'test.alias2.col_varchar_key' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select sum(`test`.`alias1`.`col_varchar_key`) AS `field1` from `test`.`t2` `alias2` join `test`.`t1` `alias3` left join (`test`.`t1` `alias1` semi join (`test`.`t1` `sq1_alias1`)) on(((`test`.`sq1_alias1`.`col_varchar_nokey` = 'v'))) semi join (`test`.`t2` join `test`.`t1` `sq2_alias2`) where ((`test`.`alias2`.`col_varchar_key` = `test`.`alias3`.`col_varchar_key`) and (`test`.`t2`.`col_int_key` = `test`.`alias3`.`pk`) and (`test`.`t2`.`col_varchar_nokey` <> `test`.`alias3`.`col_varchar_key`) and (`test`.`t2`.`col_varchar_key` < 'l')) +DROP TABLE t1,t2; +DROP VIEW view_c; +# +# Bug#13902463 SEGFAULT IN BITMAP<64U>::MERGE OR ADD_KEY_FIELD +# ON SECOND EXEC OF PREP STMT +# +CREATE TABLE t1 ( +pk INT, +col_int_nokey INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +KEY col_varchar_key (col_varchar_key) +); +CREATE VIEW view_b AS SELECT * FROM t1; +PREPARE prep_stmt_20421 FROM 'SELECT alias2.col_varchar_nokey AS field1 +FROM t1 AS alias1 +INNER JOIN t1 AS alias2 +ON (alias1.col_varchar_key = alias2.col_varchar_nokey +AND ( alias1.col_int_key ) IN ( +SELECT t1.col_int_nokey +FROM t1 +) +) +WHERE alias1.col_varchar_key IN ( +SELECT sq2_alias2.col_varchar_nokey AS sq2_field1 +FROM view_b AS sq2_alias1 +INNER JOIN t1 AS sq2_alias2 +ON (sq2_alias2.col_varchar_key = sq2_alias1.col_varchar_key ) +WHERE sq2_alias1.pk > alias2.pk +) +'; +EXECUTE prep_stmt_20421; +field1 +EXECUTE prep_stmt_20421; +field1 +EXPLAIN SELECT alias2.col_varchar_nokey AS field1 +FROM t1 AS alias1 +INNER JOIN t1 AS alias2 +ON (alias1.col_varchar_key = alias2.col_varchar_nokey +AND ( alias1.col_int_key ) IN ( +SELECT t1.col_int_nokey +FROM t1 +) +) +WHERE alias1.col_varchar_key IN ( +SELECT sq2_alias2.col_varchar_nokey AS sq2_field1 +FROM view_b AS sq2_alias1 +INNER JOIN t1 AS sq2_alias2 +ON (sq2_alias2.col_varchar_key = sq2_alias1.col_varchar_key ) +WHERE sq2_alias1.pk > alias2.pk +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.alias2.pk' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `field1` from `test`.`t1` `alias1` join `test`.`t1` `alias2` semi join (`test`.`t1`) semi join (`test`.`t1` join `test`.`t1` `sq2_alias2`) where ((`test`.`t1`.`pk` > NULL) and multiple equal(NULL, `test`.`sq2_alias2`.`col_varchar_nokey`, NULL) and multiple equal(`test`.`sq2_alias2`.`col_varchar_key`, `test`.`t1`.`col_varchar_key`) and multiple equal(NULL, `test`.`t1`.`col_int_nokey`)) +ALTER TABLE t1 DROP INDEX col_varchar_key; +PREPARE prep_stmt_20421 FROM 'SELECT alias2.col_varchar_nokey AS field1 +FROM t1 AS alias1 +INNER JOIN t1 AS alias2 +ON (alias1.col_varchar_key = alias2.col_varchar_nokey +AND ( alias1.col_int_key ) IN ( +SELECT t1.col_int_nokey +FROM t1 +) +) +WHERE alias1.col_varchar_key IN ( +SELECT sq2_alias2.col_varchar_nokey AS sq2_field1 +FROM view_b AS sq2_alias1 +INNER JOIN t1 AS sq2_alias2 +ON (sq2_alias2.col_varchar_key = sq2_alias1.col_varchar_key ) +WHERE sq2_alias1.pk > alias2.pk +) +'; +EXECUTE prep_stmt_20421; +field1 +EXECUTE prep_stmt_20421; +field1 +EXPLAIN SELECT alias2.col_varchar_nokey AS field1 +FROM t1 AS alias1 +INNER JOIN t1 AS alias2 +ON (alias1.col_varchar_key = alias2.col_varchar_nokey +AND ( alias1.col_int_key ) IN ( +SELECT t1.col_int_nokey +FROM t1 +) +) +WHERE alias1.col_varchar_key IN ( +SELECT sq2_alias2.col_varchar_nokey AS sq2_field1 +FROM view_b AS sq2_alias1 +INNER JOIN t1 AS sq2_alias2 +ON (sq2_alias2.col_varchar_key = sq2_alias1.col_varchar_key ) +WHERE sq2_alias1.pk > alias2.pk +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.alias2.pk' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `field1` from `test`.`t1` `alias1` join `test`.`t1` `alias2` semi join (`test`.`t1`) semi join (`test`.`t1` join `test`.`t1` `sq2_alias2`) where ((`test`.`t1`.`pk` > NULL) and multiple equal(NULL, `test`.`sq2_alias2`.`col_varchar_nokey`, NULL) and multiple equal(`test`.`sq2_alias2`.`col_varchar_key`, `test`.`t1`.`col_varchar_key`) and multiple equal(NULL, `test`.`t1`.`col_int_nokey`)) +DROP TABLE t1; +DROP VIEW view_b; +# +# Bug#13907277: Segfault in evaluate_null_complemented_join_record +# +CREATE TABLE t1 ( +pk INTEGER, +col_varchar_nokey VARCHAR(1), +col_varchar_key VARCHAR(1), +PRIMARY KEY (pk) +); +INSERT INTO t1 VALUES (1, 'x', 'x'); +CREATE TABLE t2 ( +pk INTEGER, +PRIMARY KEY (pk) +); +INSERT INTO t2 VALUES (1); +CREATE TABLE t3 ( +pk INTEGER, +col_int_nokey INTEGER, +col_int_key INTEGER, +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk) +); +INSERT INTO t3 VALUES (1, 6, 5, 'r'); +explain SELECT outer_t1.pk, outer_t2.pk +FROM t3 AS outer_t1 +RIGHT JOIN t2 AS outer_t2 +ON outer_t1.col_int_nokey IN +(SELECT inner_t1.col_int_nokey +FROM t3 AS inner_t1 +LEFT JOIN t1 AS inner_t2 +INNER JOIN t1 AS inner_t3 +ON inner_t3.pk = inner_t2.pk +ON inner_t3.col_varchar_nokey = inner_t2.col_varchar_key +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE outer_t2 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE outer_t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE inner_t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE inner_t2 NULL ALL PRIMARY NULL NULL NULL 1 100.00 NULL +1 SIMPLE inner_t3 NULL eq_ref PRIMARY PRIMARY 4 test.inner_t2.pk 1 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`outer_t1`.`pk` AS `pk`,'1' AS `pk` from left join (`test`.`t3` `outer_t1` semi join (`test`.`t3` `inner_t1` left join (`test`.`t1` `inner_t2` join `test`.`t1` `inner_t3`) on(((`test`.`inner_t3`.`col_varchar_nokey` = `test`.`inner_t2`.`col_varchar_key`) and (`test`.`inner_t3`.`pk` = `test`.`inner_t2`.`pk`))))) on(((`test`.`inner_t1`.`col_int_nokey` = `test`.`outer_t1`.`col_int_nokey`))) where true +SELECT outer_t1.pk, outer_t2.pk +FROM t3 AS outer_t1 +RIGHT JOIN t2 AS outer_t2 +ON outer_t1.col_int_nokey IN +(SELECT inner_t1.col_int_nokey +FROM t3 AS inner_t1 +LEFT JOIN t1 AS inner_t2 +INNER JOIN t1 AS inner_t3 +ON inner_t3.pk = inner_t2.pk +ON inner_t3.col_varchar_nokey = inner_t2.col_varchar_key +); +pk pk +1 1 +DROP TABLE t1, t2, t3; +# End of test for bug#13907277. +# +# Bug#13955713: Assert 'JOIN->best_read < ...' on second execution +# +CREATE TABLE t1 ( +pk INTEGER, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1) +); +PREPARE stmt FROM " +SELECT MIN(alias2.col_varchar_key) AS field1 +FROM t1 AS alias1 + INNER JOIN (t1 AS alias2 + INNER JOIN t1 AS alias3 + ON 8 IN + (SELECT sq1_alias1.pk AS sq1_field2 + FROM t1 AS sq1_alias1 + WHERE 9 IN + (SELECT SUM(t1_sq1_alias1.pk) AS t1_sq1_field2 + FROM t1 AS t1_sq1_alias1 + ) + ) + ) + ON alias3.col_varchar_nokey = alias2.col_varchar_key +WHERE EXISTS + (SELECT sq2_alias1.pk AS sq2_field1 + FROM t1 AS sq2_alias1 + WHERE sq2_alias1.col_varchar_key < alias1.col_varchar_nokey + ) +"; +EXECUTE stmt; +field1 +NULL + +EXECUTE stmt; +field1 +NULL +DEALLOCATE PREPARE stmt; +DROP TABLE t1; +# End of test for bug#13955713. +# +# Bug#13956813: Segfault in memcpy from Join_cache::write_record_data() +# +CREATE TABLE t1 ( +pk INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1) +) charset latin1; +CREATE TABLE t2 ( +pk INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1) +) charset latin1; +INSERT INTO t2 VALUES +(10,'j','j'), (11,'z','z'), (12,'c','c'), (13,'a','a'), +(14,'q','q'), (15,'y','y'), (16,NULL,NULL), (17,'r','r'), +(18,'v','v'), (19,NULL,NULL), (20,'r','r'); +CREATE TABLE t3 ( +pk INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +KEY col_int_key (col_int_key) +) charset latin1; +INSERT INTO t3 VALUES +(15,NULL,'u'), (16,1,'m'), (17,9,NULL), (18,2,'o'), +(19,9,'w'), (20,2,'m'), (21,4,'q'), (22,0,NULL), +(23,4,'d'), (24,8,'g'), (25,NULL,'x'), (26,NULL,'f'), +(27,0,'p'), (28,NULL,'j'), (29,8,'c'); +CREATE VIEW view_inline_0 AS +SELECT t1.* +FROM t1 INNER JOIN t3 +ON t1.pk = t3.pk; +CREATE VIEW view_inline_1 AS +SELECT sq2_alias2.col_varchar_key AS sq2_field1, +sq2_alias1.col_varchar_key AS sq2_field2 +FROM t3 AS sq2_alias1 LEFT OUTER JOIN t3 AS sq2_alias2 +ON sq2_alias1.pk = sq2_alias2.col_int_key; +CREATE VIEW view_inline_2 AS +SELECT 'p', 'p' UNION SELECT 'k', 's'; +SET @optimizer_switch_saved= @@optimizer_switch; +SET @@optimizer_switch="derived_merge=off"; +explain SELECT SUM(alias1.col_varchar_nokey) AS field2 +FROM t2 AS alias2 +LEFT JOIN (SELECT * FROM view_inline_0) AS alias1 +ON alias2.col_varchar_key = alias1.col_varchar_key AND +(alias2.col_varchar_nokey, alias2.col_varchar_key) IN +(SELECT * FROM view_inline_1 +) +WHERE (alias1.col_varchar_key, alias1.col_varchar_nokey) IN +(SELECT * FROM view_inline_2 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL 2 100.00 NULL +1 PRIMARY alias2 NULL ALL NULL NULL NULL NULL 11 10.00 Using where +1 PRIMARY NULL ref 8 test.alias2.col_varchar_nokey,test.view_inline_2.p 3 100.00 Using index; Start temporary; End temporary +1 PRIMARY NULL ref 8 test.view_inline_2.p,test.view_inline_2.Name_exp_p 2 100.00 NULL +7 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +8 UNION NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +NULL UNION RESULT NULL ALL NULL NULL NULL NULL NULL NULL Using temporary +6 DERIVED sq2_alias1 NULL ALL NULL NULL NULL NULL 15 100.00 NULL +6 DERIVED sq2_alias2 NULL ref col_int_key col_int_key 5 test.sq2_alias1.pk 2 100.00 NULL +2 DERIVED NULL ALL NULL NULL NULL NULL 15 100.00 NULL +5 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select sum(`alias1`.`col_varchar_nokey`) AS `field2` from `test`.`view_inline_2` join `test`.`t2` `alias2` join (/* select#2 */ select `test`.`view_inline_0`.`pk` AS `pk`,`test`.`view_inline_0`.`col_varchar_key` AS `col_varchar_key`,`test`.`view_inline_0`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`view_inline_0`) `alias1` semi join (`test`.`view_inline_1`) where ((`test`.`view_inline_1`.`sq2_field1` = `test`.`alias2`.`col_varchar_nokey`) and (`alias1`.`col_varchar_nokey` = `test`.`view_inline_2`.`Name_exp_p`) and (`test`.`alias2`.`col_varchar_key` = `test`.`view_inline_2`.`p`) and (`test`.`view_inline_1`.`sq2_field2` = `test`.`view_inline_2`.`p`) and (`alias1`.`col_varchar_key` = `test`.`view_inline_2`.`p`)) +SELECT SUM(alias1.col_varchar_nokey) AS field2 +FROM t2 AS alias2 +LEFT JOIN (SELECT * FROM view_inline_0) AS alias1 +ON alias2.col_varchar_key = alias1.col_varchar_key AND +(alias2.col_varchar_nokey, alias2.col_varchar_key) IN +(SELECT * FROM view_inline_1 +) +WHERE (alias1.col_varchar_key, alias1.col_varchar_nokey) IN +(SELECT * FROM view_inline_2 +); +field2 +NULL +SET @@optimizer_switch= @optimizer_switch_saved; +DROP VIEW view_inline_0, view_inline_1, view_inline_2; +DROP TABLE t1, t2, t3; +# End of test for bug#13956813. +# +# Bug#13974177: Assert !(tab->table->regginfo.not_exists_optimize... +# +CREATE TABLE t1 ( +pk INTEGER AUTO_INCREMENT, +col_int_nokey INTEGER, +col_int_key INTEGER, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk), +KEY (col_int_key), +KEY (col_varchar_key, col_int_key) +); +INSERT INTO t1(col_int_key, col_int_nokey, col_varchar_key, col_varchar_nokey) +VALUES +(0, 4, 'j', 'j'), (8, 6, 'v', 'v'), (1, 3, 'c', 'c'), (8, 5, 'm', 'm'), +(9, 3, 'd', 'd'), (24, 246, 'd', 'd'), (6, 2, 'y', 'y'), (1, 9, 't', 't'), +(6, 3, 'd', 'd'), (2, 8, 's', 's'), (4, 1, 'r', 'r'), (8, 8, 'm', 'm'), +(4, 8, 'b', 'b'), (4, 5, 'x', 'x'), (7, 7, 'g', 'g'), (4, 5, 'p', 'p'), +(1, 1, 'q', 'q'), (9, 6, 'w', 'w'), (4, 2, 'd', 'd'), (8, 9, 'e', 'e'); +CREATE TABLE t2 ( +pk INTEGER AUTO_INCREMENT, +col_int_nokey INTEGER NOT NULL, +col_time_key TIME NOT NULL, +col_time_nokey TIME NOT NULL, +PRIMARY KEY (pk), +KEY (col_time_key) +) ENGINE=InnoDB; +INSERT INTO t2 (col_int_nokey, col_time_key, col_time_nokey) VALUES +(7, '00:00:00', '00:00:00'), (0, '00:00:00', '00:00:00'), +(9, '06:35:17', '06:35:17'), (3, '18:07:14', '18:07:14'), +(4, '20:36:52', '20:36:52'), (2, '21:29:07', '21:29:07'), +(5, '23:45:57', '23:45:57'), (3, '22:54:57', '22:54:57'), +(1, '18:45:09', '18:45:09'), (3, '14:30:46', '14:30:46'), +(6, '19:23:43', '19:23:43'), (7, '03:39:30', '03:39:30'), +(5, '23:37:52', '23:37:52'), (1, '16:59:30', '16:59:30'), +(204, '22:21:15', '22:21:15'), (224, '12:24:37', '12:24:37'), +(9, '15:02:08', '15:02:08'), (5, '23:59:59', '23:59:59'), +(0, '08:23:30', '08:23:30'), (3, '08:32:22', '08:32:22'); +explain SELECT ot1.col_int_key AS x +FROM t1 AS ot2 +LEFT JOIN t1 AS ot1 +ON ot2.col_varchar_nokey > ot1.col_varchar_key +WHERE (ot1.col_int_nokey, ot1.pk) IN +(SELECT it1.pk AS x, +it1.col_int_nokey AS y +FROM t2 AS it2 +LEFT JOIN t2 AS it1 +ON it2.col_time_nokey = it1.col_time_key +) AND ot1.pk IS NULL +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`col_int_key` AS `x` from `test`.`t2` `it1` join `test`.`t1` `ot2` join `test`.`t1` `ot1` semi join (`test`.`t2` `it2`) where ((`test`.`ot1`.`pk` is null) and (`test`.`ot2`.`col_varchar_nokey` > `test`.`ot1`.`col_varchar_key`) and multiple equal(`test`.`ot1`.`col_int_nokey`, `test`.`it1`.`pk`) and multiple equal(`test`.`ot1`.`pk`, `test`.`it1`.`col_int_nokey`) and multiple equal(`test`.`it2`.`col_time_nokey`, `test`.`it1`.`col_time_key`)) +SELECT ot1.col_int_key AS x +FROM t1 AS ot2 +LEFT JOIN t1 AS ot1 +ON ot2.col_varchar_nokey > ot1.col_varchar_key +WHERE (ot1.col_int_nokey, ot1.pk) IN +(SELECT it1.pk AS x, +it1.col_int_nokey AS y +FROM t2 AS it2 +LEFT JOIN t2 AS it1 +ON it2.col_time_nokey = it1.col_time_key +) AND ot1.pk IS NULL +; +x +DROP TABLE t1, t2; +# End of test for bug#13974177. +# +# Bug#13971022: Assert 'keyparts > 0' failed in create_ref_for_key... +# +CREATE TABLE t1 ( +pk INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +PRIMARY KEY (pk), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +CREATE TABLE t2 ( +pk INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk) +) charset utf8mb4 ENGINE=InnoDB; +CREATE TABLE t3 ( +i INT +); +SET @optimizer_switch_saved= @@optimizer_switch; +SET @@optimizer_switch="derived_merge=off"; +explain SELECT table1.pk AS field1 +FROM ( SELECT subquery1_t1. * +FROM t2 AS subquery1_t1 +JOIN t2 AS subquery1_t2 +ON subquery1_t2.pk = subquery1_t1.pk) AS table1 +STRAIGHT_JOIN t2 AS table2 +ON table1.col_int_key IN (SELECT 7 FROM t3) +WHERE table1.col_varchar_nokey IN +(SELECT subquery3_t1.col_varchar_key AS subquery3_field1 +FROM t1 AS subquery3_t1 +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY subquery3_t1 NULL index col_varchar_key col_varchar_key 12 NULL 0 0.00 Using where; Using index; Start temporary +1 PRIMARY t3 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +1 PRIMARY NULL ref 7 test.subquery3_t1.col_varchar_key 2 100.00 NULL +1 PRIMARY table2 NULL index NULL PRIMARY 4 NULL 1 100.00 Using index; End temporary +2 DERIVED subquery1_t1 NULL ALL PRIMARY NULL NULL NULL 1 100.00 Using where +2 DERIVED subquery1_t2 NULL eq_ref PRIMARY PRIMARY 4 test.subquery1_t1.pk 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `table1`.`pk` AS `field1` from (/* select#2 */ select `test`.`subquery1_t1`.`pk` AS `pk`,`test`.`subquery1_t1`.`col_int_key` AS `col_int_key`,`test`.`subquery1_t1`.`col_varchar_key` AS `col_varchar_key`,`test`.`subquery1_t1`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t2` `subquery1_t1` join `test`.`t2` `subquery1_t2` where ((`test`.`subquery1_t1`.`col_int_key` = 7) and (`test`.`subquery1_t2`.`pk` = `test`.`subquery1_t1`.`pk`))) `table1` straight_join `test`.`t2` `table2` semi join (`test`.`t3`) semi join (`test`.`t1` `subquery3_t1`) where (`table1`.`col_varchar_nokey` = `test`.`subquery3_t1`.`col_varchar_key`) +SELECT table1.pk AS field1 +FROM ( SELECT subquery1_t1. * +FROM t2 AS subquery1_t1 +JOIN t2 AS subquery1_t2 +ON subquery1_t2.pk = subquery1_t1.pk) AS table1 +STRAIGHT_JOIN t2 AS table2 +ON table1.col_int_key IN (SELECT 7 FROM t3) +WHERE table1.col_varchar_nokey IN +(SELECT subquery3_t1.col_varchar_key AS subquery3_field1 +FROM t1 AS subquery3_t1 +) +; +field1 +SET @@optimizer_switch= @optimizer_switch_saved; +DROP TABLE t1, t2, t3; +# End of test for bug#13971022. +# +# Bug#13623473 "MISSING ROWS ON SELECT AND JOIN WITH +# TIME/DATETIME COMPARE" - Subquery part of test. +# +SET TIMESTAMP=UNIX_TIMESTAMP('2012-01-31 10:14:35'); +CREATE TABLE t1 ( +pk INT NOT NULL, +col_int_nokey INT, +col_int_key INT NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +) ENGINE=InnoDB; +INSERT INTO t1 VALUES (10,1,7), (11,7,0), (12,4,9), (13,7,3), +(14,0,4), (15,2,2), (16,9,5), (17,4,3), (18,0,1), (19,9,3), (20,1,6), +(21,3,7), (22,8,5), (23,8,1), (24,18,204), (25,84,224), (26,6,9), +(27,3,5), (28,6,0), (29,6,3); +CREATE TABLE t2 ( +col_int_nokey INT NOT NULL, +col_datetime_key DATETIME NOT NULL, +col_varchar_key VARCHAR(1) NOT NULL, +KEY col_datetime_key (col_datetime_key), +KEY col_varchar_key (col_varchar_key) +) ENGINE=InnoDB; +INSERT INTO t2 VALUES (1,'2001-11-04 19:07:55','k'); +CREATE TABLE t3 ( +col_time_key TIME, +KEY col_time_key (col_time_key) +) ENGINE=InnoDB; +INSERT INTO t3 VALUES ('21:22:34'), ('10:50:38'), ('00:21:38'), +('04:08:02'), ('16:25:11'), ('10:14:58'), ('19:47:59'), ('11:14:24'), +('00:00:00'), ('00:00:00'), ('15:57:25'), ('07:05:51'), ('19:22:21'), +('03:53:16'), ('09:16:38'), ('15:37:26'), ('00:00:00'), ('05:03:03'), +('02:59:24'), ('00:01:58'); +EXPLAIN SELECT outr.col_int_nokey +FROM t2 as outr +STRAIGHT_JOIN t3 AS outr2 +ON outr2.col_time_key > outr.col_datetime_key +WHERE outr.col_int_nokey IN ( +SELECT col_int_key +FROM t1 AS innr +WHERE innr.pk >= innr.col_int_nokey +) AND ( +outr.col_int_nokey <= 6 +OR +outr.col_varchar_key IS NULL +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE outr NULL ALL col_datetime_key NULL NULL NULL 1 100.00 Using where +2 SIMPLE innr NULL ref col_int_key col_int_key 4 test.outr.col_int_nokey 1 33.33 Using where; Start temporary; End temporary +2 SIMPLE outr2 NULL index col_time_key col_time_key 4 NULL 20 33.33 Using where; Using index +Warnings: +Warning 1739 Cannot use range access on index 'col_time_key' due to type or collation conversion on field 'col_time_key' +Note 1003 /* select#1 */ select `test`.`outr`.`col_int_nokey` AS `col_int_nokey` from `test`.`t2` `outr` straight_join `test`.`t3` `outr2` semi join (`test`.`t1` `innr`) where ((`test`.`innr`.`col_int_key` = `test`.`outr`.`col_int_nokey`) and (`test`.`outr`.`col_int_nokey` <= 6) and (`test`.`innr`.`pk` >= `test`.`innr`.`col_int_nokey`) and (cast(`test`.`outr2`.`col_time_key` as datetime) > `test`.`outr`.`col_datetime_key`)) +SELECT outr.col_int_nokey +FROM t2 as outr +STRAIGHT_JOIN t3 AS outr2 +ON outr2.col_time_key > outr.col_datetime_key +WHERE outr.col_int_nokey IN ( +SELECT col_int_key +FROM t1 AS innr +WHERE innr.pk >= innr.col_int_nokey +) AND ( +outr.col_int_nokey <= 6 +OR +outr.col_varchar_key IS NULL +); +col_int_nokey +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +DROP TABLE t1,t2,t3; +SET TIMESTAMP = DEFAULT; +# End of test for bug#13623473. +# +# Bug#13980954: Missing data on left join + null value + where..in +# +CREATE TABLE t1 ( +ik INT, +vc varchar(1) +) charset utf8mb4; +INSERT INTO t1 VALUES (8, 'x'), (NULL, 'x'); +CREATE TABLE t2 ( +ik INT, +vc varchar(1) +) charset utf8mb4; +INSERT INTO t2 VALUES +(0, 'x'), (7, 'i'), (7, 'e'), (1, 'p'), (7, 's'), (1, 'j'); +explain format=json SELECT t2.vc, t2.ik AS t2_ik, t1.ik AS t1_ik +FROM t2 LEFT JOIN t1 ON t2.vc=t1.vc +WHERE t2.vc IN (SELECT vc FROM t2 AS t3); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "14.16" + }, + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 6, + "rows_produced_per_join": 6, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "0.60", + "prefix_cost": "1.11", + "data_read_per_join": "96" + }, + "used_columns": [ + "ik", + "vc" + ] + } + }, + { + "duplicates_removal": { + "using_temporary_table": true, + "table": { + "table_name": "t3", + "access_type": "ALL", + "rows_examined_per_scan": 6, + "rows_produced_per_join": 6, + "filtered": "16.67", + "cost_info": { + "read_cost": "3.04", + "eval_cost": "0.60", + "prefix_cost": "9.95", + "data_read_per_join": "96" + }, + "used_columns": [ + "vc" + ], + "attached_condition": "(`test`.`t3`.`vc` = `test`.`t2`.`vc`)" + } + } + }, + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 12, + "filtered": "100.00", + "cost_info": { + "read_cost": "3.01", + "eval_cost": "1.20", + "prefix_cost": "14.17", + "data_read_per_join": "192" + }, + "used_columns": [ + "ik", + "vc" + ], + "attached_condition": "(is_not_null_compl(t1), (`test`.`t1`.`vc` = `test`.`t2`.`vc`), true)" + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`vc` AS `vc`,`test`.`t2`.`ik` AS `t2_ik`,`test`.`t1`.`ik` AS `t1_ik` from `test`.`t2` left join `test`.`t1` on((`test`.`t1`.`vc` = `test`.`t2`.`vc`)) semi join (`test`.`t2` `t3`) where (`test`.`t3`.`vc` = `test`.`t2`.`vc`) +SELECT t2.vc, t2.ik AS t2_ik, t1.ik AS t1_ik +FROM t2 LEFT JOIN t1 ON t2.vc=t1.vc +WHERE t2.vc IN (SELECT vc FROM t2 AS t3); +vc t2_ik t1_ik +e 7 NULL +i 7 NULL +j 1 NULL +p 1 NULL +s 7 NULL +x 0 8 +x 0 NULL +DROP TABLE t1, t2; +# End of test for bug#13980954. +# +# Bug#14048292: Segfault in Item_field::result_type on 2nd execution +# of prep stmt with join of view +# +CREATE TABLE t1 ( +col_int INT +); +INSERT INTO t1 VALUES (0), (1); +CREATE VIEW view_t1 AS SELECT * FROM t1; +explain SELECT alias1.col_int +FROM t1 AS alias1 +LEFT JOIN view_t1 AS alias2 +ON alias1.col_int IN +(SELECT sq1_alias1.col_int +FROM t1 AS sq1_alias1 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE alias1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE sq1_alias1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Start temporary; End temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`alias1`.`col_int` AS `col_int` from `test`.`t1` `alias1` left join (`test`.`t1` semi join (`test`.`t1` `sq1_alias1`)) on(((`test`.`sq1_alias1`.`col_int` = `test`.`alias1`.`col_int`))) where true +PREPARE stmt FROM "SELECT alias1.col_int +FROM t1 AS alias1 +LEFT JOIN view_t1 AS alias2 +ON alias1.col_int IN +(SELECT sq1_alias1.col_int +FROM t1 AS sq1_alias1 +)"; +EXECUTE stmt; +col_int +0 +0 +1 +1 + +EXECUTE stmt; +col_int +0 +0 +1 +1 +DEALLOCATE PREPARE stmt; +DROP VIEW view_t1; +DROP TABLE t1; +# End of test for bug#14048292. +# +# Bug#14064201: Missing data on join of derived table + WHERE .. IN +# with two operands +# +CREATE TABLE t1 ( +col_varchar_nokey VARCHAR(1) +) charset utf8mb4; +INSERT INTO t1 VALUES +('v'), ('s'), ('l'), ('y'), ('c'), ('i'), ('h'), ('q'), ('a'), ('v'), +('u'), ('s'), ('y'), ('z'), ('h'), ('p'), ('e'), ('i'), ('y'), ('w'); +CREATE TABLE t2 ( +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +KEY col_varchar_key(col_varchar_key) +) charset utf8mb4; +INSERT INTO t2 VALUES +('j','j'), ('v','v'), ('c','c'), ('m','m'), ('d','d'), ('d','d'), ('y','y'); +SET @optimizer_switch_saved= @@optimizer_switch; +SET @@optimizer_switch="derived_merge=off"; +explain format=json SELECT * +FROM (SELECT * FROM t2) AS derived1 +LEFT JOIN t1 +USING (col_varchar_nokey) +WHERE (col_varchar_nokey, col_varchar_nokey) IN +(SELECT col_varchar_nokey, col_varchar_key +FROM t2 AS derived2 +); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "26.88" + }, + "nested_loop": [ + { + "duplicates_removal": { + "using_temporary_table": true, + "nested_loop": [ + { + "table": { + "table_name": "derived2", + "access_type": "ALL", + "possible_keys": [ + "col_varchar_key" + ], + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "0.70", + "prefix_cost": "1.21", + "data_read_per_join": "112" + }, + "used_columns": [ + "col_varchar_key", + "col_varchar_nokey" + ], + "attached_condition": "((`test`.`derived2`.`col_varchar_key` = `test`.`derived2`.`col_varchar_nokey`) and (`test`.`derived2`.`col_varchar_nokey` is not null))" + } + }, + { + "table": { + "table_name": "derived1", + "access_type": "ref", + "possible_keys": [ + "" + ], + "key": "", + "used_key_parts": [ + "col_varchar_nokey" + ], + "key_length": "7", + "ref": [ + "test.derived2.col_varchar_nokey" + ], + "rows_examined_per_scan": 2, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "3.50", + "eval_cost": "0.70", + "prefix_cost": "9.21", + "data_read_per_join": "112" + }, + "used_columns": [ + "col_varchar_key", + "col_varchar_nokey" + ], + "materialized_from_subquery": { + "using_temporary_table": true, + "dependent": false, + "cacheable": true, + "query_block": { + "select_id": 2, + "cost_info": { + "query_cost": "1.21" + }, + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "0.70", + "prefix_cost": "1.21", + "data_read_per_join": "112" + }, + "used_columns": [ + "col_varchar_key", + "col_varchar_nokey" + ] + } + } + } + } + } + ] + } + }, + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 140, + "filtered": "100.00", + "cost_info": { + "read_cost": "3.67", + "eval_cost": "14.00", + "prefix_cost": "26.88", + "data_read_per_join": "1K" + }, + "used_columns": [ + "col_varchar_nokey" + ], + "attached_condition": "(is_not_null_compl(t1), (`test`.`t1`.`col_varchar_nokey` = `test`.`derived2`.`col_varchar_nokey`), true)" + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select `derived1`.`col_varchar_nokey` AS `col_varchar_nokey`,`derived1`.`col_varchar_key` AS `col_varchar_key` from (/* select#2 */ select `test`.`t2`.`col_varchar_key` AS `col_varchar_key`,`test`.`t2`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t2`) `derived1` left join `test`.`t1` on((`test`.`t1`.`col_varchar_nokey` = `test`.`derived2`.`col_varchar_nokey`)) semi join (`test`.`t2` `derived2`) where ((`test`.`derived2`.`col_varchar_key` = `test`.`derived2`.`col_varchar_nokey`) and (`derived1`.`col_varchar_nokey` = `test`.`derived2`.`col_varchar_nokey`)) +SELECT * +FROM (SELECT * FROM t2) AS derived1 +LEFT JOIN t1 +USING (col_varchar_nokey) +WHERE (col_varchar_nokey, col_varchar_nokey) IN +(SELECT col_varchar_nokey, col_varchar_key +FROM t2 AS derived2 +); +col_varchar_nokey col_varchar_key +c c +d d +d d +j j +m m +v v +v v +y y +y y +y y +SET @@optimizer_switch= @optimizer_switch_saved; +DROP TABLE t1, t2; +CREATE TABLE t1 ( +col_int_nokey int NOT NULL, +col_int_key int NOT NULL, +KEY col_int_key (col_int_key) +); +INSERT INTO t1 VALUES +(1,7), (7,0), (4,9), (7,3), (0,4), (2,2), (9,5), (4,3), (0,1), (9,3), +(1,6), (3,7), (8,5), (8,1), (18,204), (84,224), (6,9), (3,5), (6,0), (6,3); +CREATE TABLE t2 ( +col_int_nokey int NOT NULL, +col_int_key int NOT NULL, +KEY col_int_key (col_int_key) +); +INSERT INTO t2 VALUES +(4,0), (6,8), (3,1), (5,8), (3,9), (246,24), (2,6), (9,1), (3,6), (8,2), +(1,4), (8,8), (8,4), (5,4), (7,7), (5,4), (1,1), (6,9), (2,4), (9,8); +explain format=json SELECT grandparent1.* +FROM t1 AS grandparent1 +LEFT JOIN t1 USING (col_int_nokey) +WHERE (col_int_nokey, col_int_nokey) IN +(SELECT col_int_nokey, col_int_key +FROM t2 +); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "71.01" + }, + "nested_loop": [ + { + "table": { + "table_name": "grandparent1", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 20, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "2.00", + "prefix_cost": "2.51", + "data_read_per_join": "320" + }, + "used_columns": [ + "col_int_nokey", + "col_int_key" + ] + } + }, + { + "duplicates_removal": { + "using_temporary_table": true, + "table": { + "table_name": "t2", + "access_type": "ref", + "possible_keys": [ + "col_int_key" + ], + "key": "col_int_key", + "used_key_parts": [ + "col_int_key" + ], + "key_length": "4", + "ref": [ + "test.grandparent1.col_int_nokey" + ], + "rows_examined_per_scan": 2, + "rows_produced_per_join": 20, + "filtered": "10.00", + "cost_info": { + "read_cost": "10.00", + "eval_cost": "2.00", + "prefix_cost": "20.79", + "data_read_per_join": "320" + }, + "used_columns": [ + "col_int_nokey", + "col_int_key" + ], + "attached_condition": "(`test`.`t2`.`col_int_nokey` = `test`.`grandparent1`.`col_int_nokey`)" + } + } + }, + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 400, + "filtered": "100.00", + "cost_info": { + "read_cost": "10.22", + "eval_cost": "40.00", + "prefix_cost": "71.01", + "data_read_per_join": "6K" + }, + "used_columns": [ + "col_int_nokey" + ], + "attached_condition": "(is_not_null_compl(t1), (`test`.`t1`.`col_int_nokey` = `test`.`grandparent1`.`col_int_nokey`), true)" + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`grandparent1`.`col_int_nokey` AS `col_int_nokey`,`test`.`grandparent1`.`col_int_key` AS `col_int_key` from `test`.`t1` `grandparent1` left join `test`.`t1` on((`test`.`t1`.`col_int_nokey` = `test`.`grandparent1`.`col_int_nokey`)) semi join (`test`.`t2`) where ((`test`.`t2`.`col_int_nokey` = `test`.`grandparent1`.`col_int_nokey`) and (`test`.`t2`.`col_int_key` = `test`.`grandparent1`.`col_int_nokey`)) +SELECT grandparent1.* +FROM t1 AS grandparent1 +LEFT JOIN t1 USING (col_int_nokey) +WHERE (col_int_nokey, col_int_nokey) IN +(SELECT col_int_nokey, col_int_key +FROM t2 +); +col_int_nokey col_int_key +1 6 +1 6 +1 7 +1 7 +7 0 +7 0 +7 3 +7 3 +8 1 +8 1 +8 5 +8 5 +DROP TABLE t1, t2; +CREATE TABLE t1 ( +pk int, +col_int_key int, +col_datetime_key datetime, +col_varchar_key varchar(1), +col_varchar_nokey varchar(1), +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_datetime_key (col_datetime_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4 engine=MyISAM; +INSERT INTO t1 VALUES +(10,7,'2004-06-06 04:22:12','v','v'), (11,0,'2005-11-13 01:12:31','s','s'), +(12,9,'2002-05-04 01:50:00','l','l'), (13,3,'2004-10-27 10:28:45','y','y'), +(14,4,'2006-07-22 05:24:23','c','c'), (15,2,'2002-05-16 21:34:03','i','i'), +(16,5,'2008-04-17 10:45:30','h','h'), (17,3,'2009-04-21 02:58:02','q','q'), +(18,1,'2008-01-11 11:01:51','a','a'), (19,3,'1900-01-01 00:00:00','v','v'), +(20,6,'2007-05-17 18:24:57','u','u'), (21,7,'2007-08-07 00:00:00','s','s'), +(22,5,'2001-08-28 00:00:00','y','y'), (23,1,'2004-04-16 00:27:28','z','z'), +(24,204,'2005-05-03 07:06:22','h','h'), (25,224,'2009-03-11 17:09:50','p','p'), +(26,9,'2007-12-08 01:54:28','e','e'), (27,5,'2009-07-28 18:19:54','i','i'), +(28,0,'2008-06-08 00:00:00','y','y'), (29,3,'2005-02-09 09:20:26','w','w'); +CREATE TABLE t2 ( +pk int, +col_int_key int, +col_datetime_key datetime, +col_varchar_key varchar(1), +col_varchar_nokey varchar(1), +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_datetime_key (col_datetime_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4 engine=MyISAM; +INSERT INTO t2 VALUES +(1,0,'2002-02-13 17:30:06','j','j'), (2,8,'2008-09-27 00:34:58','v','v'), +(3,1,'2007-05-28 00:00:00','c','c'), (4,8,'2009-07-25 09:21:20','m','m'), +(5,9,'2002-01-16 00:00:00','d','d'), (6,24,'2006-10-12 04:32:53','d','d'), +(7,6,'2001-02-15 03:08:38','y','y'), (8,1,'2004-10-02 20:31:15','t','t'), +(9,6,'2002-08-20 22:48:00','d','d'), (10,2,'1900-01-01 00:00:00','s','s'), +(11,4,'2005-08-15 00:00:00','r','r'), (12,8,'1900-01-01 00:00:00','m','m'), +(13,4,'2008-05-16 08:09:06','b','b'), (14,4,'2001-01-20 12:47:23','x','x'), +(15,7,'2008-07-02 00:00:00','g','g'), (16,4,'1900-01-01 00:00:00','p','p'), +(17,1,'2002-12-08 11:34:58','q','q'), (18,9,'1900-01-01 00:00:00','w','w'), +(19,4,'1900-01-01 00:00:00','d','d'), (20,8,'2002-08-25 20:35:06','e','e'); +SELECT alias1.col_datetime_key +FROM t2 AS alias1 +RIGHT JOIN t2 AS alias2 +JOIN t2 AS alias3 +ON alias3.pk = alias2.pk +ON alias3.col_varchar_nokey = alias2.col_varchar_key OR +alias2.col_varchar_nokey +WHERE (alias2.col_varchar_key, alias2.col_varchar_key) IN +(SELECT sq2_alias2.col_varchar_key, sq2_alias1.col_varchar_nokey +FROM t1 AS sq2_alias1, t1 AS sq2_alias2 +WHERE sq2_alias2.col_int_key < 2); +col_datetime_key +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +2001-01-20 12:47:23 +2001-01-20 12:47:23 +2001-02-15 03:08:38 +2001-02-15 03:08:38 +2002-01-16 00:00:00 +2002-01-16 00:00:00 +2002-02-13 17:30:06 +2002-02-13 17:30:06 +2002-08-20 22:48:00 +2002-08-20 22:48:00 +2002-08-25 20:35:06 +2002-08-25 20:35:06 +2002-12-08 11:34:58 +2002-12-08 11:34:58 +2004-10-02 20:31:15 +2004-10-02 20:31:15 +2005-08-15 00:00:00 +2005-08-15 00:00:00 +2006-10-12 04:32:53 +2006-10-12 04:32:53 +2007-05-28 00:00:00 +2007-05-28 00:00:00 +2008-05-16 08:09:06 +2008-05-16 08:09:06 +2008-07-02 00:00:00 +2008-07-02 00:00:00 +2008-09-27 00:34:58 +2008-09-27 00:34:58 +2009-07-25 09:21:20 +2009-07-25 09:21:20 +ALTER TABLE t1 DISABLE KEYS; +ALTER TABLE t2 DISABLE KEYS; +explain format=json SELECT alias1.col_datetime_key +FROM t2 AS alias1 +RIGHT JOIN t2 AS alias2 +JOIN t2 AS alias3 +ON alias3.pk = alias2.pk +ON alias3.col_varchar_nokey = alias2.col_varchar_key OR +alias2.col_varchar_nokey +WHERE (alias2.col_varchar_key, alias2.col_varchar_key) IN +(SELECT sq2_alias2.col_varchar_key, sq2_alias1.col_varchar_nokey +FROM t1 AS sq2_alias1, t1 AS sq2_alias2 +WHERE sq2_alias2.col_int_key < 2); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "62.73" + }, + "nested_loop": [ + { + "duplicates_removal": { + "using_temporary_table": true, + "nested_loop": [ + { + "table": { + "table_name": "sq2_alias2", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 6, + "filtered": "33.33", + "cost_info": { + "read_cost": "1.86", + "eval_cost": "0.67", + "prefix_cost": "2.53", + "data_read_per_join": "213" + }, + "used_columns": [ + "col_int_key", + "col_varchar_key" + ], + "attached_condition": "(`test`.`sq2_alias2`.`col_int_key` < 2)" + } + }, + { + "table": { + "table_name": "alias2", + "access_type": "ALL", + "possible_keys": [ + "PRIMARY" + ], + "rows_examined_per_scan": 20, + "rows_produced_per_join": 13, + "filtered": "10.00", + "cost_info": { + "read_cost": "3.53", + "eval_cost": "1.33", + "prefix_cost": "19.39", + "data_read_per_join": "426" + }, + "used_columns": [ + "pk", + "col_varchar_key", + "col_varchar_nokey" + ], + "attached_condition": "(`test`.`alias2`.`col_varchar_key` = `test`.`sq2_alias2`.`col_varchar_key`)" + } + }, + { + "table": { + "table_name": "sq2_alias1", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 2, + "filtered": "10.00", + "cost_info": { + "read_cost": "7.05", + "eval_cost": "0.20", + "prefix_cost": "56.97", + "data_read_per_join": "64" + }, + "used_columns": [ + "col_varchar_nokey" + ], + "attached_condition": "(`test`.`sq2_alias1`.`col_varchar_nokey` = `test`.`sq2_alias2`.`col_varchar_key`)" + } + } + ] + } + }, + { + "table": { + "table_name": "alias3", + "access_type": "eq_ref", + "possible_keys": [ + "PRIMARY" + ], + "key": "PRIMARY", + "used_key_parts": [ + "pk" + ], + "key_length": "4", + "ref": [ + "test.alias2.pk" + ], + "rows_examined_per_scan": 1, + "rows_produced_per_join": 2, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.20", + "prefix_cost": "57.67", + "data_read_per_join": "64" + }, + "used_columns": [ + "pk", + "col_varchar_nokey" + ] + } + }, + { + "table": { + "table_name": "alias1", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 40, + "filtered": "100.00", + "cost_info": { + "read_cost": "1.06", + "eval_cost": "4.00", + "prefix_cost": "62.73", + "data_read_per_join": "1K" + }, + "used_columns": [ + "col_datetime_key" + ], + "attached_condition": "(is_not_null_compl(alias1), (((`test`.`alias2`.`col_varchar_key` = `test`.`sq2_alias2`.`col_varchar_key`) and (`test`.`sq2_alias1`.`col_varchar_nokey` = `test`.`sq2_alias2`.`col_varchar_key`) and (`test`.`alias3`.`col_varchar_nokey` = `test`.`sq2_alias2`.`col_varchar_key`)) or (0 <> `test`.`alias2`.`col_varchar_nokey`)), true)" + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`alias1`.`col_datetime_key` AS `col_datetime_key` from `test`.`t2` `alias2` join `test`.`t2` `alias3` left join `test`.`t2` `alias1` on((((`test`.`alias2`.`col_varchar_key` = `test`.`sq2_alias2`.`col_varchar_key`) and (`test`.`sq2_alias1`.`col_varchar_nokey` = `test`.`sq2_alias2`.`col_varchar_key`) and (`test`.`alias3`.`col_varchar_nokey` = `test`.`sq2_alias2`.`col_varchar_key`)) or (0 <> `test`.`alias2`.`col_varchar_nokey`))) semi join (`test`.`t1` `sq2_alias1` join `test`.`t1` `sq2_alias2`) where ((`test`.`alias3`.`pk` = `test`.`alias2`.`pk`) and (`test`.`alias2`.`col_varchar_key` = `test`.`sq2_alias2`.`col_varchar_key`) and (`test`.`sq2_alias1`.`col_varchar_nokey` = `test`.`sq2_alias2`.`col_varchar_key`) and (`test`.`sq2_alias2`.`col_int_key` < 2)) +SELECT alias1.col_datetime_key +FROM t2 AS alias1 +RIGHT JOIN t2 AS alias2 +JOIN t2 AS alias3 +ON alias3.pk = alias2.pk +ON alias3.col_varchar_nokey = alias2.col_varchar_key OR +alias2.col_varchar_nokey +WHERE (alias2.col_varchar_key, alias2.col_varchar_key) IN +(SELECT sq2_alias2.col_varchar_key, sq2_alias1.col_varchar_nokey +FROM t1 AS sq2_alias1, t1 AS sq2_alias2 +WHERE sq2_alias2.col_int_key < 2); +col_datetime_key +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +2001-01-20 12:47:23 +2001-01-20 12:47:23 +2001-02-15 03:08:38 +2001-02-15 03:08:38 +2002-01-16 00:00:00 +2002-01-16 00:00:00 +2002-02-13 17:30:06 +2002-02-13 17:30:06 +2002-08-20 22:48:00 +2002-08-20 22:48:00 +2002-08-25 20:35:06 +2002-08-25 20:35:06 +2002-12-08 11:34:58 +2002-12-08 11:34:58 +2004-10-02 20:31:15 +2004-10-02 20:31:15 +2005-08-15 00:00:00 +2005-08-15 00:00:00 +2006-10-12 04:32:53 +2006-10-12 04:32:53 +2007-05-28 00:00:00 +2007-05-28 00:00:00 +2008-05-16 08:09:06 +2008-05-16 08:09:06 +2008-07-02 00:00:00 +2008-07-02 00:00:00 +2008-09-27 00:34:58 +2008-09-27 00:34:58 +2009-07-25 09:21:20 +2009-07-25 09:21:20 +DROP TABLE t1, t2; +# End of test for bug#14064201. +# +# Bug#18223655:ASSERTION FAILED: (INT)IDX >= 0 +# && IDX < PARENT_JOIN->TABLES +# +CREATE TABLE b (d INT); +CREATE TABLE c (a INT, b INT,c INT,d BLOB NOT NULL); +SELECT(SELECT 1 +FROM b WHERE(SELECT 1 IN (SELECT 1 FROM b WHERE 1 NOT BETWEEN d AND 1) +FROM b) IN (SELECT d FROM c)) as cc FROM b; +cc +INSERT INTO b VALUE(1); +INSERT INTO c VALUES(1,2,3,'1'),(2,3,4,'1'),(3,4,5,'C'); +SELECT(SELECT d FROM b WHERE(SELECT d IN +(SELECT d FROM b WHERE 1 NOT BETWEEN d AND 1) FROM b) IN +(SELECT d FROM c)) as cc FROM c; +cc +1 +1 +1 +DROP TABLE b,c; +# +# Bug#18447874:WRONG RESULT COMING FROM SEMI-JOIN +# +CREATE TABLE b ( +d INT(11) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE c ( +d BLOB +) ; +CREATE TABLE d ( +b INT(11) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO b VALUES(1),(2),(4); +INSERT INTO c VALUES(1),(2),(3); +SELECT 1 FROM b WHERE (SELECT 1 FROM d ) IN (SELECT d FROM c) ; +1 +INSERT INTO d VALUES(2); +SELECT 1 FROM b WHERE (SELECT 1 FROM d ) IN (SELECT d FROM c) ; +1 +1 +1 +1 +DROP TABLE b,c,d; +# +# Bug#17292723:INCORRECT RESULT FOR (SELECT...) IN (SELECT...) STATEMENT +# +CREATE TABLE t1 ( +ID int(11) NOT NULL AUTO_INCREMENT, +id2 int(11) DEFAULT NULL, +id3 int(11) DEFAULT NULL, +id4 varchar(150) COLLATE utf8_spanish_ci NOT NULL, +id5 int(11) DEFAULT NULL, +PRIMARY KEY (ID), +KEY id2 (id2), +KEY id3 (id3), +KEY id5 (id5) +) ENGINE=InnoDB; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 3778 'utf8_spanish_ci' is a collation of the deprecated character set UTF8MB3. Please consider using UTF8MB4 with an appropriate collation instead. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES +(123,1,1,'1',NULL), +(124,1,1,'2',NULL), +(125,1,1,'4',NULL), +(126,1,1,'3',NULL), +(127,1,1,'6',NULL), +(128,1,1,'8',NULL); +CREATE TABLE t2 ( +id6 int(11) NOT NULL, +id7 int(11) NOT NULL, +PRIMARY KEY (id6,id7), +KEY id7 (id7) +) ENGINE=InnoDB; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (126,123),(130,123),(135,123); +SELECT ID +FROM t1 p0 +WHERE p0.id3=1 +AND ( (SELECT p1.id FROM t1 p1 WHERE p1.id=123) IN (SELECT p3.id FROM t2 +p2, t1 p3 WHERE p0.id=p2.id6 AND p2.id7=p3.id)); +ID +126 +DROP TABLE t1,t2; +set @@optimizer_switch=@old_opt_switch; +# End of 5.6 tests +# +# Bug#19336348 DEBUG CRASH AT SETUP_SEMIJOIN_DUPS_ELIMINATION IN SQL/SQL_SELECT.CC +# +CREATE TABLE t1 ( +col_varchar_nokey varchar(1) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t1 VALUES ('c'),(NULL),('x'); +CREATE TABLE t2 ( +pk int, +col_varchar_key varchar(1), +PRIMARY KEY (pk), +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t2 VALUES (10,'l'),(11,'p'); +ANALYZE TABLE t1,t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN SELECT 1 +FROM t1 AS outr +WHERE outr.col_varchar_nokey IN +( +SELECT innr.col_varchar_key +FROM t2 AS innr +WHERE innr.pk <= 7 +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE innr NULL range PRIMARY,col_varchar_key PRIMARY 4 NULL 1 100.00 Using where; Start temporary +1 SIMPLE outr NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` `outr` semi join (`test`.`t2` `innr`) where ((`test`.`outr`.`col_varchar_nokey` = `test`.`innr`.`col_varchar_key`) and (`test`.`innr`.`pk` <= 7)) +SELECT 1 +FROM t1 AS outr +WHERE outr.col_varchar_nokey IN +( +SELECT innr.col_varchar_key +FROM t2 AS innr +WHERE innr.pk <= 7 +) +; +1 +DROP TABLE t1,t2; +# +# Bug#18174394 BLOBS: CRASH AFTER UNINITIALIZED VALUES IN ITEM_FIELD::STR_RESULT +# +CREATE TABLE t1(d BLOB, b BLOB); +INSERT INTO t1(d,b) VALUES ('aaaa',''),('bnbb',''); +SELECT 1 FROM t1 +WHERE (SELECT b FROM t1) IN (SELECT (d>=1) FROM t1); +ERROR 21000: Subquery returns more than 1 row +DROP TABLE t1; +# +# Bug#19779600: ASSERT FAILED IN REPLACE_SUBCONDITION WITH IN +# PREDICATE INSIDE IN PREDICATE +# +CREATE TABLE t(X INT) ENGINE=InnoDB; +INSERT INTO t VALUES (1); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +EXPLAIN SELECT 1 FROM t WHERE (1 IN (SELECT 1 FROM t)) IN (SELECT 1 FROM t); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 PRIMARY t NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary; End temporary +2 SUBQUERY t NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t` semi join (`test`.`t`) where true +SELECT 1 FROM t WHERE (1 IN (SELECT 1 FROM t)) IN (SELECT 1 FROM t); +1 +1 +DROP TABLE t; +# +# Bug#19465034 ASSERT ON SETUP_SEMIJOIN_DUPS_ELIMINATION IN SQL/SQL_SELECT.CC +# +CREATE TABLE t1 ( +pk INTEGER NOT NULL, +i1 INTEGER NOT NULL, +PRIMARY KEY (pk) +) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1,1); +CREATE TABLE t2 ( +pk INTEGER NOT NULL, +c1 VARCHAR(1) NOT NULL, +PRIMARY KEY (pk), +KEY c1_key (c1) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t2 VALUES (1,'j'),(2,'v'),(3,'c'); +CREATE TABLE t3 ( +pk INTEGER NOT NULL, +c1 VARCHAR(1) NOT NULL, +PRIMARY KEY (pk), +KEY c1_key (c1) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t3 VALUES (10,'v'),(11,'s'); +ANALYZE TABLE t1, t2, t3; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +EXPLAIN SELECT * +FROM t1 JOIN t2 ON t1.i1 >= t2.pk +WHERE t2.c1 IN ( +SELECT t3.c1 +FROM t3 +WHERE t3.pk < 3 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t3 NULL range PRIMARY,c1_key PRIMARY 4 NULL 1 100.00 Using where; Start temporary +2 SIMPLE t2 NULL ref PRIMARY,c1_key c1_key 6 test.t3.c1 1 33.33 Using where; Using index; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`i1` AS `i1`,`test`.`t2`.`pk` AS `pk`,`test`.`t2`.`c1` AS `c1` from `test`.`t1` join `test`.`t2` semi join (`test`.`t3`) where ((`test`.`t2`.`c1` = `test`.`t3`.`c1`) and (`test`.`t3`.`pk` < 3) and (`test`.`t1`.`i1` >= `test`.`t2`.`pk`)) +SELECT * +FROM t1 JOIN t2 ON t1.i1 >= t2.pk +WHERE t2.c1 IN ( +SELECT t3.c1 +FROM t3 +WHERE t3.pk < 3 +); +pk i1 pk c1 +DROP TABLE t1,t2,t3; +# +# Bug#19586047: CRASH IN ARG_COMPARATOR::SET_CMP_FUNC +# +CREATE TABLE t1(x INT) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT 1 FROM t1 WHERE EXISTS(SELECT 1) IN (SELECT 1 FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary; End temporary +2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` semi join (`test`.`t1`) where true +SELECT 1 FROM t1 WHERE EXISTS(SELECT 1) IN (SELECT 1 FROM t1); +1 +1 +EXPLAIN SELECT 1 FROM t1 WHERE (SELECT 1, 2 FROM t1) IN (SELECT 1, 2 FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary; End temporary +2 SUBQUERY t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` semi join (`test`.`t1`) where true +SELECT 1 FROM t1 WHERE (SELECT 1, 2 FROM t1) IN (SELECT 1, 2 FROM t1); +1 +1 +EXPLAIN SELECT 1 FROM t1 WHERE +(SELECT 1, 2 FROM t1 WHERE x = 2) IN (SELECT 1, 2 FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +2 SUBQUERY t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` semi join (`test`.`t1`) where false +SELECT 1 FROM t1 WHERE +(SELECT 1, 2 FROM t1 WHERE x = 2) IN (SELECT 1, 2 FROM t1); +1 +DROP TABLE t1; +# +#Bug#20119743 ASSERTIONQEP_TAB->USE_ORDER() IN ENUM_NESTED_LOOP_STATE +# EVALUATE_JOIN_RECORD +# +CREATE TABLE t1 ( +pk int(11) NOT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +PRIMARY KEY (pk) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (1,'x'); +CREATE TABLE t2 ( +col_date_key date DEFAULT NULL, +col_int_key int(11) DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +KEY col_int_key (col_int_key), +KEY col_date_key (col_date_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES ('2000-12-03', 8, 'x', 'x'),('2008-05-03', 7, 'd', 'd'), +('2005-12-06', 1, 'r', 'r'),('2000-04-10', 7, 'f', 'f'), +('2002-11-05', 9, 'y', 'y'),('2000-09-06', NULL, 'u', 'u'), +(NULL, 1, 'm', 'm'),('2007-06-14', 9, NULL, NULL), +('2007-11-17', 2, 'o', 'o'),('2009-02-23', 9, 'w', 'w'), +('2007-01-08', 2, 'm', 'm'), ('2008-06-10', 4, 'q', 'q'), +('2002-10-20', 0, NULL, NULL),('2008-09-12', 4, 'd', 'd'), +('2006-06-16', 8, 'g', 'g'),('2004-09-18', NULL, 'x', 'x'), +('1900-01-01', NULL, 'f', 'f'),('2005-09-13', 0, 'p', 'p'), +('2007-04-09', NULL, 'j', 'j'),('2000-09-20', 8, 'c', 'c'); +CREATE TABLE t3 ( +pk int(11) NOT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +PRIMARY KEY (pk) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t3 VALUES (1, 'c'),(2, 'c'),(3, 'q'),(4, 'g'),(5, 'e'),(6, 'l'), +(7, NULL),(8, 'v'),(9, 'c'),(10, 'u'),(11, 'x'),(12, 'x'),(13, 'x'),(14, 'l'), +(15, 'e'),(16, 's'),(17, 'k'),(18, 'm'),(19, 'x'),(20, 's'); +ANALYZE TABLE t1,t2,t3; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +EXPLAIN SELECT r1.col_date_key +FROM t2 AS r1 +WHERE r1.col_int_key NOT IN +(SELECT ir2.pk +FROM t2 AS ir1 STRAIGHT_JOIN t1 AS ir2 +ON ir2.col_varchar_nokey = ir1.col_varchar_key +WHERE ir2.col_varchar_nokey > r1.col_varchar_nokey +AND ir2.pk IN +(SELECT iir2.pk +FROM t2 AS iir1 RIGHT JOIN t3 AS iir2 +ON iir2.col_varchar_nokey = iir1.col_varchar_key)) +ORDER BY r1.col_date_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY r1 NULL ALL NULL NULL NULL NULL 20 100.00 Using where; Using filesort +2 DEPENDENT SUBQUERY iir2 NULL eq_ref PRIMARY PRIMARY 4 func 1 100.00 Using where; Start temporary; Full scan on NULL key +2 DEPENDENT SUBQUERY iir1 NULL ref col_varchar_key col_varchar_key 7 test.iir2.col_varchar_nokey 1 100.00 Using index +2 DEPENDENT SUBQUERY ir1 NULL index col_varchar_key col_varchar_key 12 NULL 20 100.00 Using where; Using index +2 DEPENDENT SUBQUERY ir2 NULL eq_ref PRIMARY PRIMARY 4 func 1 100.00 Using where; End temporary; Full scan on NULL key +SELECT r1.col_date_key +FROM t2 AS r1 +WHERE r1.col_int_key NOT IN +(SELECT ir2.pk +FROM t2 AS ir1 STRAIGHT_JOIN t1 AS ir2 +ON ir2.col_varchar_nokey = ir1.col_varchar_key +WHERE ir2.col_varchar_nokey > r1.col_varchar_nokey +AND ir2.pk IN +(SELECT iir2.pk +FROM t2 AS iir1 RIGHT JOIN t3 AS iir2 +ON iir2.col_varchar_nokey = iir1.col_varchar_key)) +ORDER BY r1.col_date_key; +col_date_key +2000-04-10 +2000-09-20 +2000-12-03 +2002-10-20 +2002-11-05 +2004-09-18 +2005-09-13 +2006-06-16 +2007-01-08 +2007-06-14 +2007-11-17 +2008-05-03 +2008-06-10 +2008-09-12 +2009-02-23 +SELECT COUNT(r1.col_date_key) AS COUNT_NUM +FROM t2 AS r1 +WHERE r1.col_int_key NOT IN +(SELECT ir2.pk +FROM t2 AS ir1 STRAIGHT_JOIN t1 AS ir2 +ON ir2.col_varchar_nokey = ir1.col_varchar_key +WHERE ir2.col_varchar_nokey > r1.col_varchar_nokey +AND ir2.pk IN +(SELECT iir2.pk +FROM t2 AS iir1 RIGHT JOIN t3 AS iir2 +ON iir2.col_varchar_nokey = iir1.col_varchar_key +WHERE iir2.pk<3)); +COUNT_NUM +15 +DROP TABLE t1,t2,t3; +# +# Bug#20554585 ASSERT JOIN()->TABLES == 0... IN JOIN_TAB::GET_SJ_STRATEGY ON SUBQUERY + VAR +# +CREATE TABLE t1 ( +pk int NOT NULL, +PRIMARY KEY (pk) +); +CREATE TABLE t2 ( +pk int NOT NULL, +col_int_key int, +col_varchar_key varchar(1), +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key) +); +CREATE TABLE t3 ( +pk int NOT NULL, +col_int_key int, +col_varchar_key varchar(1), +col_varchar varchar(1), +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key) +); +INSERT INTO t3 VALUES (1,4,'c','g'),(20,1,'i','p'); +CREATE TABLE t4 ( +col_int int +); +CREATE TABLE t5 ( +col_varchar_key varchar(1), +pk int NOT NULL, +col_int int, +PRIMARY KEY (pk), +KEY col_varchar_key (col_varchar_key) +); +SELECT table1.col_varchar_key AS field1 +FROM (t3 AS table1 +INNER JOIN ( +SELECT SUBQUERY1_t1.* +FROM (t1 AS SUBQUERY1_t1 +RIGHT JOIN (t2 AS SUBQUERY1_t2 +INNER JOIN t3 AS SUBQUERY1_t3 +ON (SUBQUERY1_t3.col_varchar_key = SUBQUERY1_t2.col_varchar_key) +) ON (SUBQUERY1_t3.col_int_key = SUBQUERY1_t2.pk) +) +WHERE SUBQUERY1_t2.col_varchar_key >= ANY ( +SELECT CHILD_SUBQUERY1_t2.col_varchar AS CHILD_SUBQUERY1_field1 +FROM (t2 AS CHILD_SUBQUERY1_t1 +LEFT OUTER JOIN t3 AS CHILD_SUBQUERY1_t2 +ON (CHILD_SUBQUERY1_t2.col_int_key = CHILD_SUBQUERY1_t1.col_int_key) +) +WHERE CHILD_SUBQUERY1_t1.pk >= SUBQUERY1_t2.pk +) +) AS table2 +ON (table2.pk = table1.pk) +) +WHERE (EXISTS (( +SELECT DISTINCT SUBQUERY2_t2.col_int AS SUBQUERY2_field1 +FROM (t4 AS SUBQUERY2_t1 +LEFT OUTER JOIN t5 AS SUBQUERY2_t2 +ON (SUBQUERY2_t2.pk = SUBQUERY2_t1.col_int) +) +WHERE SUBQUERY2_t2.col_varchar_key != @var4 +))) +AND table1.col_int_key < (35 + 192) +ORDER BY field1 +; +field1 +DROP TABLE t1, t2, t3, t4, t5; +# +# Bug#18892055: MISSING DATA ON SELECT ... IN WITH JOINS AND INNODB +# ENGINE +# +CREATE TABLE t1 ( +col_int_key INT, +pk INT NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +) ENGINE = INNODB; +INSERT INTO t1 VALUES +( 0, 3 ), +( 0, 4 ), +( 3, 1 ), +( 900000000, 2 ), +( 1368719360, 5 ), +( 1922236416, 6 ), +( 8,7 ); +CREATE TABLE t2 ( +pk INT NOT NULL, +col_int INT, +PRIMARY KEY (pk) +) ENGINE = INNODB; +INSERT INTO t2 VALUES +( 1, 3 ), +( 2, 2 ), +( 3, 8 ), +( 4, 7 ); +CREATE TABLE t3 ( +col_int_key INT, +col_int INT, +KEY (col_int_key) +) ENGINE = INNODB; +INSERT INTO t3 VALUES +( 5, 1 ), +( -1, -1 ), +( 300000000, 1 ), +( 8, 1 ); +CREATE TABLE t4 ( col_int_key INT ) ENGINE = INNODB; +INSERT INTO t4 VALUES +(0), +(3), +(8), +(900000000), +(1368719360), +(1922236416); +ANALYZE TABLE t1, t2, t3, t4; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +test.t4 analyze status OK +explain SELECT * +FROM t4 +WHERE (col_int_key) IN ( +SELECT t1.col_int_key +FROM t1 LEFT JOIN ( t2 JOIN t3 ON t3.col_int_key = t2.col_int ) USING ( pk ) +WHERE t3.col_int IS NULL +) +ORDER BY col_int_key +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 6 100.00 Parallel execute (1 workers) +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 6 100.00 Using where; Using filesort +2 SIMPLE t1 NULL ref col_int_key col_int_key 5 test.t4.col_int_key 1 100.00 Using index; Start temporary +2 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.pk 1 100.00 NULL +2 SIMPLE t3 NULL ref col_int_key col_int_key 5 test.t2.col_int 1 25.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`col_int_key` AS `col_int_key` from `test`.`t4` semi join (`test`.`t1` left join (`test`.`t2` join `test`.`t3`) on(((`test`.`t1`.`pk` = `test`.`t2`.`pk`) and (`test`.`t3`.`col_int_key` = `test`.`t2`.`col_int`)))) where ((`test`.`t1`.`col_int_key` = `test`.`t4`.`col_int_key`) and (`test`.`t3`.`col_int` is null)) order by `test`.`t4`.`col_int_key` +explain format=tree SELECT * +FROM t4 +WHERE (col_int_key) IN ( +SELECT t1.col_int_key +FROM t1 LEFT JOIN ( t2 JOIN t3 ON t3.col_int_key = t2.col_int ) USING ( pk ) +WHERE t3.col_int IS NULL +) +ORDER BY col_int_key +; +EXPLAIN +-> Parallel scan on + -> Nested loop inner join (cost=3.05 rows=7) + -> Sort: t4.col_int_key (cost=0.85 rows=6) + -> Filter: (t4.col_int_key is not null) + -> PQblock scan on t4 + -> Limit: 1 row(s) (cost=2.14 rows=1) + -> Filter: (t3.col_int is null) (cost=2.14 rows=1) + -> Nested loop left join (cost=2.14 rows=1) + -> Index lookup on t1 using col_int_key (col_int_key=t4.col_int_key) (cost=0.27 rows=1) + -> Nested loop inner join (cost=2.41 rows=1) + -> Single-row index lookup on t2 using PRIMARY (pk=t1.pk) (cost=0.26 rows=1) + -> Index lookup on t3 using col_int_key (col_int_key=t2.col_int) (cost=0.07 rows=1) + +SELECT * +FROM t4 +WHERE (col_int_key) IN ( +SELECT t1.col_int_key +FROM t1 LEFT JOIN ( t2 JOIN t3 ON t3.col_int_key = t2.col_int ) USING ( pk ) +WHERE t3.col_int IS NULL +) +ORDER BY col_int_key +; +col_int_key +0 +3 +8 +900000000 +1368719360 +1922236416 +DROP TABLE t1, t2, t3, t4; +# +# Bug#20835095 CRASH AT CREATE_REF_FOR_KEY IN SQL/SQL_SELECT.CC +# +CREATE TABLE t1 ( +pk INTEGER, +var_10_latin1 VARCHAR(10) CHARACTER SET latin1, +var_255_utf8 VARCHAR(255) CHARACTER SET utf8, +var_255_latin1 VARCHAR(255) CHARACTER SET latin1, +var_10_utf8 VARCHAR(10) CHARACTER SET utf8, +PRIMARY KEY (pk) +); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +CREATE VIEW v1 AS SELECT * FROM t1; +INSERT INTO t1 VALUES +(1,'FROCJ','korrhrspki','UAYVL','BPZIS'), +(2,'him','a','CHYKN','OZZQT'), +(3,'WBITK','ULWBF','have','rhrh'), +(4,'or','right','up','it'), +(5,'GGDCP','x','who','as'), +(6,'j','i','e','w'); +CREATE TABLE tv +SELECT var_255_utf8 AS field1 +FROM t1; +EXPLAIN SELECT * FROM tv +WHERE field1 IN ( +SELECT tv1.var_255_utf8 +FROM v1 AS tv1 LEFT JOIN v1 AS tv2 ON tv1.var_10_latin1=tv2.var_10_utf8); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE tv NULL ALL NULL NULL NULL NULL 6 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 6 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`tv`.`field1` AS `field1` from `test`.`tv` semi join (`test`.`t1` left join (`test`.`t1`) on((`test`.`t1`.`var_10_latin1` = `test`.`t1`.`var_10_utf8`))) where (`test`.`t1`.`var_255_utf8` = `test`.`tv`.`field1`) +SELECT * FROM tv +WHERE field1 IN ( +SELECT tv1.var_255_utf8 +FROM v1 AS tv1 LEFT JOIN v1 AS tv2 ON tv1.var_10_latin1=tv2.var_10_utf8); +field1 +korrhrspki +a +ULWBF +right +x +i +DROP VIEW v1; +DROP TABLE t1, tv; +# 17832047 Crash in calculate_materialization_costs +CREATE TABLE t1(a INTEGER PRIMARY KEY); +INSERT INTO t1 VALUES (0),(1),(2); +SELECT 1 FROM t1 +WHERE 1 IN +(SELECT 1 BETWEEN (LENGTH(a) IN (SELECT 1 FROM t1)) AND 1 +FROM t1 +); +1 +1 +1 +1 +DROP TABLE t1; +# 17845989 Assertion failed: !(used_tables() & ... +CREATE TABLE a(b INTEGER) engine=innodb; +CREATE TABLE c(a INTEGER) engine=innodb; +SELECT 1 +FROM a +WHERE 1 IN (SELECT (a.b IS NULL) IN (SELECT 1 FROM c) FROM c) +; +1 +DROP TABLE a, c; +# +# Bug#18194196: OPTIMIZER EXECUTES STATEMENT INPERFORMANT +# +CREATE TABLE t1 (uid INTEGER, fid INTEGER, INDEX(uid)); +INSERT INTO t1 VALUES +(1,1), (1,2), (1,3), (1,4), +(2,5), (2,6), (2,7), (2,8), +(3,1), (3,2), (3,9); +CREATE TABLE t2 (uid INT PRIMARY KEY, name VARCHAR(128), INDEX(name)); +INSERT INTO t2 VALUES +(1, "A"), (2, "B"), (3, "C"), (4, "D"), (5, "E"), +(6, "F"), (7, "G"), (8, "H"), (9, "I"); +CREATE TABLE t3 (uid INT, fid INT, INDEX(uid)); +INSERT INTO t3 VALUES +(1,1), (1,2), (1,3),(1,4), +(2,5), (2,6), (2,7), (2,8), +(3,1), (3,2), (3,9); +CREATE TABLE t4 (uid INT PRIMARY KEY, name VARCHAR(128), INDEX(name)); +INSERT INTO t4 VALUES +(1, "A"), (2, "B"), (3, "C"), (4, "D"), (5, "E"), +(6, "F"), (7, "G"), (8, "H"), (9, "I"); +ANALYZE TABLE t1,t2,t3,t4; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +test.t4 analyze status OK +EXPLAIN SELECT name FROM t2, t1 +WHERE t1.uid IN (SELECT t4.uid FROM t4, t3 WHERE t3.uid=1 AND t4.uid=t3.fid) +AND t2.uid=t1.fid; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ref uid uid 5 const 4 100.00 Using where; Start temporary +1 SIMPLE t4 NULL eq_ref PRIMARY PRIMARY 4 test.t3.fid 1 100.00 Using index +1 SIMPLE t1 NULL ref uid uid 5 test.t3.fid 4 100.00 Using where +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.fid 1 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`name` AS `name` from `test`.`t4` join `test`.`t2` join `test`.`t1` semi join (`test`.`t3`) where ((`test`.`t4`.`uid` = `test`.`t3`.`fid`) and (`test`.`t1`.`uid` = `test`.`t3`.`fid`) and (`test`.`t3`.`uid` = 1) and (`test`.`t2`.`uid` = `test`.`t1`.`fid`)) +FLUSH STATUS; +SELECT name FROM t2, t1 +WHERE t1.uid IN (SELECT t4.uid FROM t4, t3 WHERE t3.uid=1 AND t4.uid=t3.fid) +AND t2.uid=t1.fid; +name +A +A +B +B +C +D +E +F +G +H +I +SHOW STATUS LIKE '%handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 20 +Handler_read_last 0 +Handler_read_next 15 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +DROP TABLE t1,t2,t3,t4; +# End of test for Bug#18194196 +# +# Bug#21184091 ASSERT `READ_ROWS >= 0.0' AT +# COST_MODEL_SERVER::TMPTABLE_READWRITE_COST() +# +CREATE TABLE t1 ( +pk INTEGER, +col_varchar varchar(1), +col_int INTEGER, +PRIMARY KEY (pk) +) ENGINE=MyISAM; +CREATE TABLE t2 ( +col_int INTEGER, +col_varchar varchar(1) +) ENGINE=MyISAM; +INSERT INTO t2 VALUES (7,'x'); +INSERT INTO t2 VALUES (4,'z'); +SELECT t2.col_varchar +FROM t2 STRAIGHT_JOIN t1 ON t2.col_varchar = t1.col_varchar +JOIN t2 AS table3 ON t1.pk = table3.col_int +WHERE t1.pk IN (SELECT col_int FROM t1); +col_varchar +DROP TABLE t1,t2; +# End of test for Bug#21184091 +# Bug#21139722: Assertion failed: !(used_tables() & ((table_map) 1) ... +CREATE TABLE t1(a INTEGER) engine=innodb; +CREATE TABLE t2(b INTEGER) engine=innodb; +explain SELECT 1 +FROM (SELECT 1 IN (SELECT 1 +FROM t1 +WHERE (SELECT 1 FROM t2 HAVING b) NOT IN (SELECT 1 FROM t2) +) +FROM t2 +) AS z; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DERIVED t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +3 DEPENDENT SUBQUERY t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +5 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +4 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1276 Field or reference 'b' of SELECT #4 was resolved in SELECT #2 +Note 1003 /* select#1 */ select 1 AS `1` from (/* select#2 */ select (1,(/* select#3 */ select 1 from `test`.`t1` where ((/* select#4 */ select 1 from `test`.`t2` having (0 <> `test`.`t2`.`b`)),(/* select#5 */ select 1 from `test`.`t2` where (outer_field_is_not_null, (((/* select#4 */ select 1 from `test`.`t2` having (0 <> `test`.`t2`.`b`))) = 1), true)) is false))) AS `1 IN (SELECT 1 +FROM t1 +WHERE (SELECT 1 FROM t2 HAVING b) NOT IN (SELECT 1 FROM t2) +)` from `test`.`t2`) `z` +SELECT 1 +FROM (SELECT 1 IN (SELECT 1 +FROM t1 +WHERE (SELECT 1 FROM t2 HAVING b) NOT IN (SELECT 1 FROM t2) +) +FROM t2 +) AS z; +1 +DROP TABLE t1, t2; +CREATE TABLE t1(a INTEGER) engine=innodb; +explain SELECT (SELECT a FROM t1 AS t2 +WHERE a IN (SELECT t1.a+t2.a FROM t1 AS t3)) +FROM t1 AS t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 DEPENDENT SUBQUERY t3 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #3 was resolved in SELECT #1 +Note 1276 Field or reference 'test.t2.a' of SELECT #3 was resolved in SELECT #2 +Note 1003 /* select#1 */ select (/* select#2 */ select `test`.`t2`.`a` from `test`.`t1` `t2` semi join (`test`.`t1` `t3`) where (`test`.`t2`.`a` = (`test`.`t1`.`a` + `test`.`t2`.`a`))) AS `(SELECT a FROM t1 AS t2 +WHERE a IN (SELECT t1.a+t2.a FROM t1 AS t3))` from `test`.`t1` +SELECT (SELECT a FROM t1 AS t2 +WHERE a IN (SELECT t1.a+t2.a FROM t1 AS t3)) +FROM t1 AS t1; +(SELECT a FROM t1 AS t2 +WHERE a IN (SELECT t1.a+t2.a FROM t1 AS t3)) +DROP TABLE t1; +# End of test for Bug#21139722 +SET DEFAULT_STORAGE_ENGINE=INNODB; +# +# Bug#21139402 ASSERTION FAILED: LENGTH > 0 && KEYPARTS != 0, CRASH IN JOIN::OPTIMIZE_KEYUSE +# +CREATE TABLE t1 (a INT, b INT, PRIMARY KEY(a)); +CREATE TABLE t2 (c INT PRIMARY KEY); +EXPLAIN SELECT 1 FROM t1 +WHERE 1 IN +(SELECT (c IS NULL) IN (SELECT a FROM t1 WHERE b) FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +3 SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` semi join (`test`.`t2`) where false +SELECT 1 FROM t1 +WHERE 1 IN +(SELECT (c IS NULL) IN (SELECT a FROM t1 WHERE b) FROM t2); +1 +DROP TABLE t1,t2; +# +# Bug#21619634 ACCESS OF DEALLOCATED ITEM_OUTER_REF CAUSES CRASH: PREPARED STMT +# +create table cc (i int) engine="innodb"; +insert into cc values (1); +select (select count(i) from cc as cc_alias +where (cc.i in (select cc_alias.i from cc))) +from cc group by i; +(select count(i) from cc as cc_alias +where (cc.i in (select cc_alias.i from cc))) +1 +prepare stmt from +"select (select count(i) from cc as cc_alias + where (cc.i in (select cc_alias.i from cc))) + from cc group by i"; +execute stmt; +(select count(i) from cc as cc_alias + where (cc.i in (select cc_alias.i from cc))) +1 +execute stmt; +(select count(i) from cc as cc_alias + where (cc.i in (select cc_alias.i from cc))) +1 +drop table cc; +# +# Bug #22305361: QUERY WITH MATERIALIZED TABLE RETURNS INCORRECT +# RESULTS IN 5.6 +# +CREATE TABLE t(a INT,b INT); +INSERT INTO t VALUES (1,0),(1,0),(1,0),(1,0),(1,1); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +EXPLAIN SELECT * +FROM t AS t1 +WHERE t1.a IN (SELECT t2.a +FROM t AS t2 +WHERE CONCAT(t2.a,'') NOT IN (SELECT t3.a +FROM t AS t3 +WHERE t3.b=1)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 5 20.00 Using where; Start temporary; End temporary +3 DEPENDENT SUBQUERY t3 NULL ALL NULL NULL NULL NULL 5 20.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t` `t1` semi join (`test`.`t` `t2`) where ((`test`.`t2`.`a` = `test`.`t1`.`a`) and (concat(`test`.`t1`.`a`,''),(/* select#3 */ select `test`.`t3`.`a` from `test`.`t` `t3` where ((`test`.`t3`.`b` = 1) and (outer_field_is_not_null, (((concat(`test`.`t1`.`a`,'')) = `test`.`t3`.`a`) or (`test`.`t3`.`a` is null)), true)) having (outer_field_is_not_null, (`test`.`t3`.`a`), true)) is false)) +SELECT * +FROM t AS t1 +WHERE t1.a IN (SELECT t2.a +FROM t AS t2 +WHERE CONCAT(t2.a,'') NOT IN (SELECT t3.a +FROM t AS t3 +WHERE t3.b=1)); +a b +DROP TABLE t; +# +# Bug#24287772 SUBQUERY RETURNS EMPTY LIST WHILE IDENTICAL QUERY +# WITH JOIN RETURNS RESULT +# +CREATE TABLE t SELECT 4096 c; +SELECT c FROM t WHERE 1 IN +(SELECT t.c = page_size FROM information_schema.innodb_cmpmem); +c +4096 +DROP TABLE t; +# +# Bug #29132639: WL#12470: SIG 6 IN CONNECTJOINS|SQL/SQL_EXECUTOR.C +# +CREATE TABLE t1 ( f1 TIME, f2 VARCHAR(1) ); +INSERT INTO t1 VALUES ('08:35:24', 'X'), ('14:51:13', 'S'), ('11:22:33', 'Q'); +CREATE TABLE t2 ( pk INTEGER ); +INSERT INTO t2 VALUES (1), (2); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN FORMAT=tree SELECT * FROM t1 WHERE EXISTS ( SELECT alias1.f2 FROM t2 LEFT JOIN t1 ON 1 LEFT JOIN t1 AS alias1 ON 1 ); +EXPLAIN +-> Remove duplicate t1 rows using temporary table (weedout) (cost=14.75 rows=54) + -> Nested loop left join (cost=14.75 rows=54) + -> Nested loop left join (cost=4.85 rows=18) + -> Nested loop inner join (cost=1.55 rows=6) + -> Table scan on t2 (cost=0.45 rows=2) + -> Table scan on t1 (cost=0.40 rows=3) + -> Table scan on t1 (cost=0.30 rows=3) + -> Table scan on alias1 (cost=4.80 rows=3) + +SELECT * FROM t1 WHERE EXISTS ( SELECT alias1.f2 FROM t2 LEFT JOIN t1 ON 1 LEFT JOIN t1 AS alias1 ON 1 ); +f1 f2 +08:35:24 X +11:22:33 Q +14:51:13 S +DROP TABLE t1, t2; +set optimizer_switch=default; +set optimizer_switch=default; diff --git a/mysql-test/r/subquery_sj_firstmatch.result-pq b/mysql-test/r/subquery_sj_firstmatch.result-pq new file mode 100644 index 000000000000..2bb8f7e38bc7 --- /dev/null +++ b/mysql-test/r/subquery_sj_firstmatch.result-pq @@ -0,0 +1,12946 @@ +set optimizer_switch='semijoin=on,firstmatch=on'; +set @old_opt_switch=@@optimizer_switch; +set optimizer_switch='subquery_materialization_cost_based=off'; +drop table if exists t0, t1, t2, t10, t11, t12; +create table t1 (a int not null, b int, primary key (a)); +create table t2 (a int not null, primary key (a)); +create table t3 (a int not null, b int, primary key (a)); +insert into t1 values (1,10), (2,20), (3,30), (4,40); +insert into t2 values (2), (3), (4), (5); +insert into t3 values (10,3), (20,4), (30,5); +select * from t2 where t2.a in (select a from t1); +a +2 +3 +4 +explain select * from t2 where t2.a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index PRIMARY PRIMARY 4 NULL 4 100.00 Using index +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t1` join `test`.`t2` where (`test`.`t1`.`a` = `test`.`t2`.`a`) +select * from t2 where t2.a in (select a from t1 where t1.b <> 30); +a +2 +4 +explain select * from t2 where t2.a in (select a from t1 where t1.b <> 30); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL PRIMARY NULL NULL NULL 4 75.00 Using where +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`a` = `test`.`t1`.`a`) and (`test`.`t1`.`b` <> 30)) +select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a); +a +2 +3 +explain select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL index PRIMARY PRIMARY 4 NULL 3 100.00 Using index +1 SIMPLE t1 NULL ALL PRIMARY NULL NULL NULL 4 25.00 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t1` join `test`.`t3` join `test`.`t2` where ((`test`.`t2`.`a` = `test`.`t1`.`a`) and (`test`.`t1`.`b` = `test`.`t3`.`a`)) +drop table t1, t2, t3; +create table t1 (a int, b int, index a (a,b)); +create table t2 (a int, index a (a)); +create table t3 (a int, b int, index a (a)); +insert into t1 values (1,10), (2,20), (3,30), (4,40); +create table t0(a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +insert into t1 +select rand()*100000+200,rand()*100000 from t0 A, t0 B, t0 C, t0 D; +insert into t2 values (2), (3), (4), (5); +insert into t3 values (10,3), (20,4), (30,5); +select * from t2 where t2.a in (select a from t1); +a +2 +3 +4 +explain select * from t2 where t2.a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index a a 5 NULL 4 100.00 Using where; Using index +1 SIMPLE t1 NULL ref a a 5 test.t2.a 101 100.00 Using index; FirstMatch(t2) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1`) where (`test`.`t1`.`a` = `test`.`t2`.`a`) +select * from t2 where t2.a in (select a from t1 where t1.b <> 30); +a +2 +4 +explain select * from t2 where t2.a in (select a from t1 where t1.b <> 30); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index a a 5 NULL 4 100.00 Using where; Using index +1 SIMPLE t1 NULL ref a a 5 test.t2.a 101 90.00 Using where; Using index; FirstMatch(t2) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1`) where ((`test`.`t1`.`a` = `test`.`t2`.`a`) and (`test`.`t1`.`b` <> 30)) +select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a); +a +2 +3 +explain select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index a a 5 NULL 4 100.00 Using where; Using index +1 SIMPLE t3 NULL index a a 5 NULL 3 100.00 Using where; Using index +1 SIMPLE t1 NULL ref a a 10 test.t2.a,test.t3.a 116 100.00 Using index; FirstMatch(t2) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1` join `test`.`t3`) where ((`test`.`t1`.`a` = `test`.`t2`.`a`) and (`test`.`t1`.`b` = `test`.`t3`.`a`)) +insert into t1 values (3,31); +select * from t2 where t2.a in (select a from t1 where t1.b <> 30); +a +2 +3 +4 +select * from t2 where t2.a in (select a from t1 where t1.b <> 30 and t1.b <> 31); +a +2 +4 +explain select * from t2 where t2.a in (select a from t1 where t1.b <> 30); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index a a 5 NULL 4 100.00 Using where; Using index +1 SIMPLE t1 NULL ref a a 5 test.t2.a 101 90.00 Using where; Using index; FirstMatch(t2) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1`) where ((`test`.`t1`.`a` = `test`.`t2`.`a`) and (`test`.`t1`.`b` <> 30)) +drop table t0, t1, t2, t3; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1(a int, b int); +insert into t1 values (0,0),(1,1),(2,2); +create table t2 as select * from t1; +create table t11(a int, b int); +create table t10 (pk int, a int, primary key(pk)); +insert into t10 select a,a from t0; +create table t12 like t10; +insert into t12 select * from t10; +Flattened because of dependency, t10=func(t1) +explain select * from t1 where a in (select pk from t10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t1` where (`test`.`t10`.`pk` = `test`.`t1`.`a`) +select * from t1 where a in (select pk from t10); +a b +0 0 +1 1 +2 2 +A confluent case of dependency +explain select * from t1 where a in (select a from t10 where pk=12); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t1` where (multiple equal(12, NULL) and multiple equal(`test`.`t1`.`a`, NULL)) +select * from t1 where a in (select a from t10 where pk=12); +a b +explain select * from t1 where a in (select a from t10 where pk=9); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t10 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t1` where ((`test`.`t1`.`a` = '9')) +select * from t1 where a in (select a from t10 where pk=9); +a b +An empty table inside +explain select * from t1 where a in (select a from t11); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE t11 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t11`) where (`test`.`t11`.`a` = `test`.`t1`.`a`) +select * from t1 where a in (select a from t11); +a b +explain select * from t1 where a in (select pk from t10) and b in (select pk from t10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using index +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.t1.b 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t10` join `test`.`t1` where ((`test`.`t10`.`pk` = `test`.`t1`.`b`) and (`test`.`t10`.`pk` = `test`.`t1`.`a`)) +select * from t1 where a in (select pk from t10) and b in (select pk from t10); +a b +0 0 +1 1 +2 2 +flattening a nested subquery +explain select * from t1 where a in (select pk from t10 where t10.a in (select pk from t12)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using where +1 SIMPLE t12 NULL eq_ref PRIMARY PRIMARY 4 test.t10.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t12` join `test`.`t1` where ((`test`.`t10`.`pk` = `test`.`t1`.`a`) and (`test`.`t12`.`pk` = `test`.`t10`.`a`)) +select * from t1 where a in (select pk from t10 where t10.a in (select pk from t12)); +a b +0 0 +1 1 +2 2 +flattening subquery w/ several tables +explain select * from t1 where a in (select t10.pk from t10, t12 where t12.pk=t10.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using where +1 SIMPLE t12 NULL eq_ref PRIMARY PRIMARY 4 test.t10.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t12` join `test`.`t1` where ((`test`.`t10`.`pk` = `test`.`t1`.`a`) and (`test`.`t12`.`pk` = `test`.`t10`.`a`)) +subqueries within outer joins go into ON expr. +explain +select * from t1 left join (t2 A, t2 B) on ( A.A= t1.A and B.A in (select pk from t10)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE A NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE B NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.B.A 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`A` AS `A`,`test`.`t1`.`B` AS `B`,`test`.`A`.`A` AS `A`,`test`.`A`.`B` AS `B`,`test`.`B`.`A` AS `A`,`test`.`B`.`B` AS `B` from `test`.`t1` left join (`test`.`t10` join `test`.`t2` `A` join `test`.`t2` `B`) on(((`test`.`t10`.`pk` = `test`.`B`.`A`) and (`test`.`A`.`A` = `test`.`t1`.`A`))) where true +t2 should be wrapped into OJ-nest, so we have "t1 LJ (t2 J t10)" +explain +select * from t1 left join t2 on (t2.A= t1.A and t2.A in (select pk from t10)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.t1.A 1 100.00 Using index +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`A` AS `A`,`test`.`t1`.`B` AS `B`,`test`.`t2`.`A` AS `A`,`test`.`t2`.`B` AS `B` from `test`.`t1` left join (`test`.`t10` join `test`.`t2`) on(((`test`.`t10`.`pk` = `test`.`t1`.`A`) and (`test`.`t2`.`A` = `test`.`t1`.`A`))) where true +we shouldn't flatten if we're going to get a join of > MAX_TABLES. +explain select * from +t1 s00, t1 s01, t1 s02, t1 s03, t1 s04,t1 s05,t1 s06,t1 s07,t1 s08,t1 s09, +t1 s10, t1 s11, t1 s12, t1 s13, t1 s14,t1 s15,t1 s16,t1 s17,t1 s18,t1 s19, +t1 s20, t1 s21, t1 s22, t1 s23, t1 s24,t1 s25,t1 s26,t1 s27,t1 s28,t1 s29, +t1 s30, t1 s31, t1 s32, t1 s33, t1 s34,t1 s35,t1 s36,t1 s37,t1 s38,t1 s39, +t1 s40, t1 s41, t1 s42, t1 s43, t1 s44,t1 s45,t1 s46,t1 s47,t1 s48,t1 s49 +where +s00.a in ( +select m00.a from +t1 m00, t1 m01, t1 m02, t1 m03, t1 m04,t1 m05,t1 m06,t1 m07,t1 m08,t1 m09, +t1 m10, t1 m11, t1 m12, t1 m13, t1 m14,t1 m15,t1 m16,t1 m17,t1 m18,t1 m19 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY s00 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 PRIMARY s01 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s02 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s03 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s04 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s05 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s06 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s07 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s08 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s09 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s10 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s11 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s12 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s13 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s14 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s15 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s16 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s17 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s18 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s19 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s20 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s21 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s22 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s23 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s24 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s25 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s26 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s27 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s28 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s29 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s30 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s31 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s32 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s33 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s34 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s35 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s36 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s37 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s38 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s39 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s40 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s41 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s42 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s43 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s44 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s45 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s46 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s47 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s48 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s49 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m00 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +2 DEPENDENT SUBQUERY m01 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m02 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m03 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m04 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m05 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m06 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m07 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m08 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m09 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m10 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m11 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m12 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m13 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m14 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m15 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m16 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m17 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m18 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m19 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`s00`.`a` AS `a`,`test`.`s00`.`b` AS `b`,`test`.`s01`.`a` AS `a`,`test`.`s01`.`b` AS `b`,`test`.`s02`.`a` AS `a`,`test`.`s02`.`b` AS `b`,`test`.`s03`.`a` AS `a`,`test`.`s03`.`b` AS `b`,`test`.`s04`.`a` AS `a`,`test`.`s04`.`b` AS `b`,`test`.`s05`.`a` AS `a`,`test`.`s05`.`b` AS `b`,`test`.`s06`.`a` AS `a`,`test`.`s06`.`b` AS `b`,`test`.`s07`.`a` AS `a`,`test`.`s07`.`b` AS `b`,`test`.`s08`.`a` AS `a`,`test`.`s08`.`b` AS `b`,`test`.`s09`.`a` AS `a`,`test`.`s09`.`b` AS `b`,`test`.`s10`.`a` AS `a`,`test`.`s10`.`b` AS `b`,`test`.`s11`.`a` AS `a`,`test`.`s11`.`b` AS `b`,`test`.`s12`.`a` AS `a`,`test`.`s12`.`b` AS `b`,`test`.`s13`.`a` AS `a`,`test`.`s13`.`b` AS `b`,`test`.`s14`.`a` AS `a`,`test`.`s14`.`b` AS `b`,`test`.`s15`.`a` AS `a`,`test`.`s15`.`b` AS `b`,`test`.`s16`.`a` AS `a`,`test`.`s16`.`b` AS `b`,`test`.`s17`.`a` AS `a`,`test`.`s17`.`b` AS `b`,`test`.`s18`.`a` AS `a`,`test`.`s18`.`b` AS `b`,`test`.`s19`.`a` AS `a`,`test`.`s19`.`b` AS `b`,`test`.`s20`.`a` AS `a`,`test`.`s20`.`b` AS `b`,`test`.`s21`.`a` AS `a`,`test`.`s21`.`b` AS `b`,`test`.`s22`.`a` AS `a`,`test`.`s22`.`b` AS `b`,`test`.`s23`.`a` AS `a`,`test`.`s23`.`b` AS `b`,`test`.`s24`.`a` AS `a`,`test`.`s24`.`b` AS `b`,`test`.`s25`.`a` AS `a`,`test`.`s25`.`b` AS `b`,`test`.`s26`.`a` AS `a`,`test`.`s26`.`b` AS `b`,`test`.`s27`.`a` AS `a`,`test`.`s27`.`b` AS `b`,`test`.`s28`.`a` AS `a`,`test`.`s28`.`b` AS `b`,`test`.`s29`.`a` AS `a`,`test`.`s29`.`b` AS `b`,`test`.`s30`.`a` AS `a`,`test`.`s30`.`b` AS `b`,`test`.`s31`.`a` AS `a`,`test`.`s31`.`b` AS `b`,`test`.`s32`.`a` AS `a`,`test`.`s32`.`b` AS `b`,`test`.`s33`.`a` AS `a`,`test`.`s33`.`b` AS `b`,`test`.`s34`.`a` AS `a`,`test`.`s34`.`b` AS `b`,`test`.`s35`.`a` AS `a`,`test`.`s35`.`b` AS `b`,`test`.`s36`.`a` AS `a`,`test`.`s36`.`b` AS `b`,`test`.`s37`.`a` AS `a`,`test`.`s37`.`b` AS `b`,`test`.`s38`.`a` AS `a`,`test`.`s38`.`b` AS `b`,`test`.`s39`.`a` AS `a`,`test`.`s39`.`b` AS `b`,`test`.`s40`.`a` AS `a`,`test`.`s40`.`b` AS `b`,`test`.`s41`.`a` AS `a`,`test`.`s41`.`b` AS `b`,`test`.`s42`.`a` AS `a`,`test`.`s42`.`b` AS `b`,`test`.`s43`.`a` AS `a`,`test`.`s43`.`b` AS `b`,`test`.`s44`.`a` AS `a`,`test`.`s44`.`b` AS `b`,`test`.`s45`.`a` AS `a`,`test`.`s45`.`b` AS `b`,`test`.`s46`.`a` AS `a`,`test`.`s46`.`b` AS `b`,`test`.`s47`.`a` AS `a`,`test`.`s47`.`b` AS `b`,`test`.`s48`.`a` AS `a`,`test`.`s48`.`b` AS `b`,`test`.`s49`.`a` AS `a`,`test`.`s49`.`b` AS `b` from `test`.`t1` `s00` join `test`.`t1` `s01` join `test`.`t1` `s02` join `test`.`t1` `s03` join `test`.`t1` `s04` join `test`.`t1` `s05` join `test`.`t1` `s06` join `test`.`t1` `s07` join `test`.`t1` `s08` join `test`.`t1` `s09` join `test`.`t1` `s10` join `test`.`t1` `s11` join `test`.`t1` `s12` join `test`.`t1` `s13` join `test`.`t1` `s14` join `test`.`t1` `s15` join `test`.`t1` `s16` join `test`.`t1` `s17` join `test`.`t1` `s18` join `test`.`t1` `s19` join `test`.`t1` `s20` join `test`.`t1` `s21` join `test`.`t1` `s22` join `test`.`t1` `s23` join `test`.`t1` `s24` join `test`.`t1` `s25` join `test`.`t1` `s26` join `test`.`t1` `s27` join `test`.`t1` `s28` join `test`.`t1` `s29` join `test`.`t1` `s30` join `test`.`t1` `s31` join `test`.`t1` `s32` join `test`.`t1` `s33` join `test`.`t1` `s34` join `test`.`t1` `s35` join `test`.`t1` `s36` join `test`.`t1` `s37` join `test`.`t1` `s38` join `test`.`t1` `s39` join `test`.`t1` `s40` join `test`.`t1` `s41` join `test`.`t1` `s42` join `test`.`t1` `s43` join `test`.`t1` `s44` join `test`.`t1` `s45` join `test`.`t1` `s46` join `test`.`t1` `s47` join `test`.`t1` `s48` join `test`.`t1` `s49` where (`test`.`s00`.`a`,(/* select#2 */ select `test`.`m00`.`a` from `test`.`t1` `m00` join `test`.`t1` `m01` join `test`.`t1` `m02` join `test`.`t1` `m03` join `test`.`t1` `m04` join `test`.`t1` `m05` join `test`.`t1` `m06` join `test`.`t1` `m07` join `test`.`t1` `m08` join `test`.`t1` `m09` join `test`.`t1` `m10` join `test`.`t1` `m11` join `test`.`t1` `m12` join `test`.`t1` `m13` join `test`.`t1` `m14` join `test`.`t1` `m15` join `test`.`t1` `m16` join `test`.`t1` `m17` join `test`.`t1` `m18` join `test`.`t1` `m19` where ((`test`.`s00`.`a`) = `test`.`m00`.`a`))) +select * from +t1 left join t2 on (t2.a= t1.a and t2.a in (select pk from t10)) +where t1.a < 5; +a b a b +0 0 0 0 +1 1 1 1 +2 2 2 2 +prepare s1 from +' select * from + t1 left join t2 on (t2.a= t1.a and t2.a in (select pk from t10)) + where t1.a < 5'; +execute s1; +a b a b +0 0 0 0 +1 1 1 1 +2 2 2 2 +execute s1; +a b a b +0 0 0 0 +1 1 1 1 +2 2 2 2 +insert into t1 select (A.a + 10 * B.a),1 from t0 A, t0 B; +explain select * from t1 where a in (select pk from t10 where pk<3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t10 NULL range PRIMARY PRIMARY 4 NULL 4 100.00 Using where; Using index +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 103 10.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t1` where ((`test`.`t1`.`a` = `test`.`t10`.`pk`) and (`test`.`t10`.`pk` < 3)) +drop table t0, t1, t2; +drop table t10, t11, t12; +# +# Check that subqueries with outer joins or straight_join work for +# different permutations of const and non-const tables. (Ref. Bug#46692) +# +CREATE TABLE t1 (i INTEGER); +CREATE TABLE t2 (i INTEGER); +CREATE TABLE t3 (i INTEGER); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 0 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 0 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 0 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 1 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 1 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 1 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 2 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 2 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 2 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (0); +DELETE FROM t2; +INSERT INTO t1 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 0 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 0 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 0 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 1 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 1 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 1 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 2 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 2 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 2 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (0); +DELETE FROM t2; +INSERT INTO t1 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 0 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = `test`.`t1`.`i`) and (`test`.`t3`.`i` = `test`.`t1`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = `test`.`t1`.`i`) and (`test`.`t3`.`i` = `test`.`t1`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = `test`.`t1`.`i`) and (`test`.`t3`.`i` = `test`.`t1`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = `test`.`t1`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = `test`.`t1`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 0 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = `test`.`t1`.`i`) and (`test`.`t3`.`i` = `test`.`t1`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = `test`.`t1`.`i`) and (`test`.`t3`.`i` = `test`.`t1`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = `test`.`t1`.`i`) and (`test`.`t3`.`i` = `test`.`t1`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = `test`.`t1`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = `test`.`t1`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 0 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = `test`.`t1`.`i`) and (`test`.`t3`.`i` = `test`.`t1`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = `test`.`t1`.`i`) and (`test`.`t3`.`i` = `test`.`t1`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = `test`.`t1`.`i`) and (`test`.`t3`.`i` = `test`.`t1`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = `test`.`t1`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +1 +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = `test`.`t1`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 1 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = `test`.`t1`.`i`) and (`test`.`t2`.`i` = `test`.`t1`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = `test`.`t1`.`i`) and (`test`.`t2`.`i` = `test`.`t1`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = `test`.`t1`.`i`) and (`test`.`t2`.`i` = `test`.`t1`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = `test`.`t1`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = `test`.`t1`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 1 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = `test`.`t1`.`i`) and (`test`.`t3`.`i` = `test`.`t1`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = `test`.`t1`.`i`) and (`test`.`t3`.`i` = `test`.`t1`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = `test`.`t1`.`i`) and (`test`.`t3`.`i` = `test`.`t1`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = `test`.`t1`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = `test`.`t1`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 1 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = `test`.`t1`.`i`) and (`test`.`t3`.`i` = `test`.`t1`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = `test`.`t1`.`i`) and (`test`.`t3`.`i` = `test`.`t1`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = `test`.`t1`.`i`) and (`test`.`t3`.`i` = `test`.`t1`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = `test`.`t1`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +1 +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = `test`.`t1`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +1 +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 2 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = `test`.`t1`.`i`) and (`test`.`t2`.`i` = `test`.`t1`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = `test`.`t1`.`i`) and (`test`.`t2`.`i` = `test`.`t1`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = `test`.`t1`.`i`) and (`test`.`t2`.`i` = `test`.`t1`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = `test`.`t1`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = `test`.`t1`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 2 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = `test`.`t1`.`i`) and (`test`.`t2`.`i` = `test`.`t1`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = `test`.`t1`.`i`) and (`test`.`t2`.`i` = `test`.`t1`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = `test`.`t1`.`i`) and (`test`.`t2`.`i` = `test`.`t1`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = `test`.`t1`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = `test`.`t1`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 2 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = `test`.`t1`.`i`) and (`test`.`t3`.`i` = `test`.`t1`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +1 +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +1 +2 + +EXECUTE stmt; +i +1 +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = `test`.`t1`.`i`) and (`test`.`t3`.`i` = `test`.`t1`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +1 +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = `test`.`t1`.`i`) and (`test`.`t3`.`i` = `test`.`t1`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +1 +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +1 +2 + +EXECUTE stmt; +i +1 +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = `test`.`t1`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +1 +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = `test`.`t1`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +1 +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (0); +DELETE FROM t2; +INSERT INTO t1 VALUES (0); +DROP TABLE t1, t2, t3; +create table x1(k int primary key, d1 int, d2 int); +create table x2(k int primary key, d1 int, d2 int); +insert into x1 values +(10, 10, 10), +(20, 20, 20), +(21, 20, null), +(30, null, 30), +(40, 40, 40); +insert into x2 values +(10, 10, 10), +(20, 20, 20), +(21, 20, null), +(30, null, 30); +select * +from x1 +where (d1, d2) in (select d1, d2 +from x2); +k d1 d2 +10 10 10 +20 20 20 +select * +from x1 +where (d1, d2) in (select d1, d2 +from x2) is true; +k d1 d2 +10 10 10 +20 20 20 +select * +from x1 +where (d1, d2) in (select d1, d2 +from x2) is false; +k d1 d2 +40 40 40 +select * +from x1 +where (d1, d2) in (select d1, d2 +from x2) is unknown; +k d1 d2 +21 20 NULL +30 NULL 30 +select * +from x1 +where d1 in (select d1 +from x2 +where x1.d2=x2.d2); +k d1 d2 +10 10 10 +20 20 20 +select * +from x1 +where d1 in (select d1 +from x2 +where x1.d2=x2.d2) is true; +k d1 d2 +10 10 10 +20 20 20 +select * +from x1 +where d1 in (select d1 +from x2 +where x1.d2=x2.d2) is false; +k d1 d2 +21 20 NULL +40 40 40 +select * +from x1 +where d1 in (select d1 +from x2 +where x1.d2=x2.d2) is unknown; +k d1 d2 +30 NULL 30 +select * +from x1 +where 1 in (select 1 +from x2 +where x1.d1=x2.d1 and x1.d2=x2.d2); +k d1 d2 +10 10 10 +20 20 20 +select * +from x1 +where 1 in (select 1 +from x2 +where x1.d1=x2.d1 and x1.d2=x2.d2) is true; +k d1 d2 +10 10 10 +20 20 20 +select * +from x1 +where 1 in (select 1 +from x2 +where x1.d1=x2.d1 and x1.d2=x2.d2) is false; +k d1 d2 +21 20 NULL +30 NULL 30 +40 40 40 +select * +from x1 +where 1 in (select 1 +from x2 +where x1.d1=x2.d1 and x1.d2=x2.d2) is unknown; +k d1 d2 +select * +from x1 +where exists (select * +from x2 +where x1.d1=x2.d1 and x1.d2=x2.d2); +k d1 d2 +10 10 10 +20 20 20 +drop table x1; +drop table x2; +CREATE TABLE t1 ( +a int(11) NOT NULL, +b int(11) NOT NULL, +c datetime default NULL, +PRIMARY KEY (a), +KEY idx_bc (b,c) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES +(406989,67,'2006-02-23 17:08:46'), (150078,67,'2005-10-26 11:17:45'), +(406993,67,'2006-02-27 11:20:57'), (245655,67,'2005-12-08 15:59:08'), +(406994,67,'2006-02-27 11:26:46'), (256,67,NULL), +(398341,67,'2006-02-20 04:48:44'), (254,67,NULL),(1120,67,NULL), +(406988,67,'2006-02-23 17:07:22'), (255,67,NULL), +(398340,67,'2006-02-20 04:38:53'),(406631,67,'2006-02-23 10:49:42'), +(245653,67,'2005-12-08 15:59:07'),(406992,67,'2006-02-24 16:47:18'), +(245654,67,'2005-12-08 15:59:08'),(406995,67,'2006-02-28 11:55:00'), +(127261,67,'2005-10-13 12:17:58'),(406991,67,'2006-02-24 16:42:32'), +(245652,67,'2005-12-08 15:58:27'),(398545,67,'2006-02-20 04:53:13'), +(154504,67,'2005-10-28 11:53:01'),(9199,67,NULL),(1,67,'2006-02-23 15:01:35'), +(223456,67,NULL),(4101,67,NULL),(1133,67,NULL), +(406990,67,'2006-02-23 18:01:45'),(148815,67,'2005-10-25 15:34:17'), +(148812,67,'2005-10-25 15:30:01'),(245651,67,'2005-12-08 15:58:27'), +(154503,67,'2005-10-28 11:52:38'); +create table t11 select * from t1 where b = 67 AND (c IS NULL OR c > NOW()) order by 3 asc; +create table t12 select * from t1 where b = 67 AND (c IS NULL OR c > NOW()) order by 3 desc; +create table t21 select * from t1 where b = 67 AND (c IS NULL OR c > '2005-12-08') order by 3 asc; +create table t22 select * from t1 where b = 67 AND (c IS NULL OR c > '2005-12-08') order by 3 desc; +update t22 set c = '2005-12-08 15:58:27' where a = 255; +explain select t21.* from t21,t22 where t21.a = t22.a and +t22.a in (select t12.a from t11, t12 where t11.a in(255,256) and t11.a = t12.a and t11.c is null) and t22.c is null order by t21.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t21 NULL ALL NULL NULL NULL NULL 26 100.00 Using where; Using temporary; Using filesort +1 SIMPLE t22 NULL ALL NULL NULL NULL NULL 26 3.85 Using where; Using join buffer (hash join) +1 SIMPLE t11 NULL ALL NULL NULL NULL NULL 8 12.50 Using where +1 SIMPLE t12 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; FirstMatch(t22) +Warnings: +Note 1003 /* select#1 */ select `test`.`t21`.`a` AS `a`,`test`.`t21`.`b` AS `b`,`test`.`t21`.`c` AS `c` from `test`.`t21` join `test`.`t22` semi join (`test`.`t11` join `test`.`t12`) where ((`test`.`t22`.`a` = `test`.`t21`.`a`) and (`test`.`t11`.`a` = `test`.`t21`.`a`) and (`test`.`t12`.`a` = `test`.`t21`.`a`) and (`test`.`t22`.`c` is null) and (`test`.`t21`.`a` in (255,256)) and (`test`.`t11`.`c` is null)) order by `test`.`t21`.`a` +explain format=json select * from t1 where a in (select a from t11); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "29.83" + }, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "possible_keys": [ + "PRIMARY" + ], + "rows_examined_per_scan": 32, + "rows_produced_per_join": 32, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.53", + "eval_cost": "3.20", + "prefix_cost": "3.73", + "data_read_per_join": "512" + }, + "used_columns": [ + "a", + "b", + "c" + ] + } + }, + { + "table": { + "table_name": "t11", + "access_type": "ALL", + "rows_examined_per_scan": 8, + "rows_produced_per_join": 32, + "filtered": "12.50", + "first_match": "t1", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "3.20", + "prefix_cost": "29.84", + "data_read_per_join": "512" + }, + "used_columns": [ + "a" + ], + "attached_condition": "(`test`.`t11`.`a` = `test`.`t1`.`a`)" + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` semi join (`test`.`t11`) where (`test`.`t11`.`a` = `test`.`t1`.`a`) +select t21.* from t21,t22 where t21.a = t22.a and +t22.a in (select t12.a from t11, t12 where t11.a in(255,256) and t11.a = t12.a and t11.c is null) and t22.c is null order by t21.a; +a b c +256 67 NULL +drop table t1, t11, t12, t21, t22; +create table t1(a int); +insert into t1 values (0),(1); +explain +select (select max(y.a) from t1 y where a in (select a from t1 z) and a < x.a) as subq from t1 x; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY x NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DEPENDENT SUBQUERY y NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 DEPENDENT SUBQUERY z NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(y); Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.x.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select (/* select#2 */ select max(`test`.`y`.`a`) from `test`.`t1` `y` semi join (`test`.`t1` `z`) where ((`test`.`z`.`a` = `test`.`y`.`a`) and (`test`.`y`.`a` < `test`.`x`.`a`))) AS `subq` from `test`.`t1` `x` +select (select max(y.a) from t1 y where a in (select a from t1 z) and a < x.a) as subq from t1 x; +subq +NULL +0 +drop table t1; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 as select * from t0; +insert into t1 select a+10 from t0; +insert into t0 values(2); +explain select * from t1 where 2 in (select a from t0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 11 10.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 20 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t0`) where (`test`.`t0`.`a` = 2) +select * from t1 where 2 in (select a from t0); +a +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +explain select * from (select a from t0) x where a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 11 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 20 10.00 Using where; FirstMatch(t0); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a` from `test`.`t0` semi join (`test`.`t1`) where (`test`.`t1`.`a` = `test`.`t0`.`a`) +explain format=json select * from (select a from t0) x where a in (select a from t1); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "24.11" + }, + "nested_loop": [ + { + "table": { + "table_name": "t0", + "access_type": "ALL", + "rows_examined_per_scan": 11, + "rows_produced_per_join": 11, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "1.10", + "prefix_cost": "1.60", + "data_read_per_join": "88" + }, + "used_columns": [ + "a" + ] + } + }, + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 11, + "filtered": "10.00", + "first_match": "t0", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "1.10", + "prefix_cost": "24.11", + "data_read_per_join": "88" + }, + "used_columns": [ + "a" + ], + "attached_condition": "(`test`.`t1`.`a` = `test`.`t0`.`a`)" + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a` from `test`.`t0` semi join (`test`.`t1`) where (`test`.`t1`.`a` = `test`.`t0`.`a`) +drop table t0, t1; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (kp1 int, kp2 int, c int, filler char(100), key(kp1, kp2)); +insert into t1 select A.a+10*(B.a+10*C.a), 0, 0, 'filler' from t0 A, t0 B, t0 C; +insert into t1 select * from t1 where kp1 < 20; +create table t3 (a int); +insert into t3 select A.a + 10*B.a from t0 A, t0 B; +explain select * from t3 where a in (select kp1 from t1 where kp1<20); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 100 100.00 Using where +1 SIMPLE t1 NULL ref kp1 kp1 5 test.t3.a 1 100.00 Using index; FirstMatch(t3) +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a` from `test`.`t3` semi join (`test`.`t1`) where ((`test`.`t1`.`kp1` = `test`.`t3`.`a`) and (`test`.`t3`.`a` < 20)) +select * from t3 where a in (select kp1 from t1 where kp1<20); +a +0 +1 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +2 +3 +4 +5 +6 +7 +8 +9 +explain select * from t3 where a in (select kp1 from t1 where kp1<20) and a<20; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 100 33.33 Using where +1 SIMPLE t1 NULL ref kp1 kp1 5 test.t3.a 1 100.00 Using index; FirstMatch(t3) +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a` from `test`.`t3` semi join (`test`.`t1`) where ((`test`.`t1`.`kp1` = `test`.`t3`.`a`) and (`test`.`t3`.`a` < 20) and (`test`.`t3`.`a` < 20)) +select * from t3 where a in (select kp1 from t1 where kp1<20) and a<20; +a +0 +1 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +2 +3 +4 +5 +6 +7 +8 +9 +create table t4 (pk int primary key); +insert into t4 select a from t3; +explain select * from t3 where a in +(select t1.kp1 from t1,t4 where kp1<20 and t4.pk=t1.c); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 100 100.00 Using where +1 SIMPLE t1 NULL ref kp1 kp1 5 test.t3.a 1 100.00 Using where +1 SIMPLE t4 NULL eq_ref PRIMARY PRIMARY 4 test.t1.c 1 100.00 Using index; FirstMatch(t3) +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a` from `test`.`t3` semi join (`test`.`t1` join `test`.`t4`) where ((`test`.`t1`.`kp1` = `test`.`t3`.`a`) and (`test`.`t4`.`pk` = `test`.`t1`.`c`) and (`test`.`t3`.`a` < 20)) +explain format=tree select * from t3 where a in +(select t1.kp1 from t1,t4 where kp1<20 and t4.pk=t1.c); +EXPLAIN +-> Nested loop semijoin (cost=45.54 rows=100) + -> Filter: ((t3.a < 20) and (t3.a is not null)) (cost=10.54 rows=100) + -> Table scan on t3 (cost=10.54 rows=100) + -> Nested loop inner join (cost=25.35 rows=1) + -> Filter: (t1.c is not null) (cost=0.25 rows=1) + -> Index lookup on t1 using kp1 (kp1=t3.a) (cost=0.25 rows=1) + -> Single-row index lookup on t4 using PRIMARY (pk=t1.c) (cost=0.25 rows=1) + +select * from t3 where a in +(select t1.kp1 from t1,t4 where kp1<20 and t4.pk=t1.c); +a +0 +1 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +2 +3 +4 +5 +6 +7 +8 +9 +drop table t1, t3, t4; +create table t1 (a int); +insert into t1 values (0),(0),(0),(1),(1),(1),(2),(2),(2),(3),(3),(3); +set session internal_tmp_mem_storage_engine='memory'; +set @save_max_heap_table_size=@@max_heap_table_size; +set @@max_heap_table_size= 16384; +# Attempt to make one test that overflows the heap table when a +# non-duplicate row is inserted and one test that overflows the +# heap table when a duplicate record is inserted. Debugging showed +# that these situations occurred with max_heap_table_size=16384 +# and optimizer_join_cache_level equals 1 and 0, respectively. +# Finally execute a test that does not overflow the heap table. +explain +select count(*) from t0 a, t0 b, t0 c +where c.a in (select a from t1 d); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE a NULL ALL NULL NULL NULL NULL 10 100.00 NULL +1 SIMPLE b NULL ALL NULL NULL NULL NULL 10 100.00 Using join buffer (hash join) +1 SIMPLE c NULL ALL NULL NULL NULL NULL 10 100.00 Using join buffer (hash join) +1 SIMPLE d NULL ALL NULL NULL NULL NULL 12 10.00 Using where; FirstMatch(c); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select count(0) AS `count(*)` from `test`.`t0` `a` join `test`.`t0` `b` join `test`.`t0` `c` semi join (`test`.`t1` `d`) where (`test`.`d`.`a` = `test`.`c`.`a`) +flush status; +select count(*) from t0 a, t0 b, t0 c +where c.a in (select a from t1 d); +count(*) +400 +show status like 'Created_tmp_disk_tables'; +Variable_name Value +Created_tmp_disk_tables 0 +set @@max_heap_table_size= @save_max_heap_table_size; +set session internal_tmp_mem_storage_engine=default; +flush status; +select count(*) from t0 a, t0 b, t0 c +where c.a in (select a from t1 d); +count(*) +400 +show status like 'Created_tmp_disk_tables'; +Variable_name Value +Created_tmp_disk_tables 0 +drop table t0, t1; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t2(a int); +insert into t2 values (1),(2); +create table t3 ( a int , filler char(100), key(a)); +insert into t3 select A.a + 10*B.a, 'filler' from t0 A, t0 B; +explain select * from t3 where a in (select a from t2) and (a > 5 or a < 10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL a NULL NULL NULL 100 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t3); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a`,`test`.`t3`.`filler` AS `filler` from `test`.`t3` semi join (`test`.`t2`) where ((`test`.`t2`.`a` = `test`.`t3`.`a`) and ((`test`.`t3`.`a` > 5) or (`test`.`t3`.`a` < 10))) +select * from t3 where a in (select a from t2); +a filler +1 filler +2 filler +drop table t0, t2, t3; +create table t1 (a date); +insert into t1 values ('2008-01-01'),('2008-01-01'),('2008-02-01'),('2008-02-01'); +create table t2 (a int); +insert into t2 values (1),(2); +create table t3 (a char(10)); +insert into t3 select * from t1; +insert into t3 values (1),(2); +explain select * from t2 where a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; FirstMatch(t2); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1`) where (cast(`test`.`t2`.`a` as double) = cast(`test`.`t1`.`a` as double)) +explain select * from t2 where a in (select a from t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t2); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t2`) where (`test`.`t2`.`a` = `test`.`t2`.`a`) +explain select * from t2 where a in (select a from t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; FirstMatch(t2); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t3`) where (cast(`test`.`t2`.`a` as double) = cast(`test`.`t3`.`a` as double)) +explain select * from t1 where a in (select a from t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; FirstMatch(t1); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t3`) where (`test`.`t1`.`a` = cast(`test`.`t3`.`a` as date)) +drop table t1, t2, t3; +create table t1 (a decimal); +insert into t1 values (1),(2); +explain select * from t1 where a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t1`) where (`test`.`t1`.`a` = `test`.`t1`.`a`) +drop table t1; +create table t1 (a int); +insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t2 as select * from t1; +create table t3 (a int, b int, filler char(100), key(a)) charset utf8mb4; +insert into t3 select A.a + 10*B.a, A.a + 10*B.a, 'filler' from t1 A, t1 B, t1 C; +explain select * from t1, t3 where t3.a in (select a from t2) and (t3.a < 10 or t3.a >30) and t1.a =3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 10.00 Using where +1 SIMPLE t3 NULL ALL a NULL NULL NULL 1000 79.30 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 10 10.00 Using where; FirstMatch(t3); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t3`.`filler` AS `filler` from `test`.`t1` join `test`.`t3` semi join (`test`.`t2`) where ((`test`.`t2`.`a` = `test`.`t3`.`a`) and (`test`.`t1`.`a` = 3) and ((`test`.`t3`.`a` < 10) or (`test`.`t3`.`a` > 30))) +explain format=json select * from t1, t3 where t3.a in (select a from t2) and (t3.a < 10 or t3.a >30) and t1.a =3; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "921.10" + }, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 10, + "rows_produced_per_join": 1, + "filtered": "10.00", + "cost_info": { + "read_cost": "1.40", + "eval_cost": "0.10", + "prefix_cost": "1.50", + "data_read_per_join": "8" + }, + "used_columns": [ + "a" + ], + "attached_condition": "(`test`.`t1`.`a` = 3)" + } + }, + { + "table": { + "table_name": "t3", + "access_type": "ALL", + "possible_keys": [ + "a" + ], + "rows_examined_per_scan": 1000, + "rows_produced_per_join": 793, + "filtered": "79.30", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "46.16", + "eval_cost": "79.30", + "prefix_cost": "126.97", + "data_read_per_join": "322K" + }, + "used_columns": [ + "a", + "b", + "filler" + ], + "attached_condition": "((`test`.`t3`.`a` < 10) or (`test`.`t3`.`a` > 30))" + } + }, + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 10, + "rows_produced_per_join": 793, + "filtered": "10.00", + "first_match": "t3", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.52", + "eval_cost": "79.30", + "prefix_cost": "921.10", + "data_read_per_join": "6K" + }, + "used_columns": [ + "a" + ], + "attached_condition": "(`test`.`t2`.`a` = `test`.`t3`.`a`)" + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t3`.`filler` AS `filler` from `test`.`t1` join `test`.`t3` semi join (`test`.`t2`) where ((`test`.`t2`.`a` = `test`.`t3`.`a`) and (`test`.`t1`.`a` = 3) and ((`test`.`t3`.`a` < 10) or (`test`.`t3`.`a` > 30))) +explain select straight_join * from t1 a, t1 b where a.a in (select a from t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY a NULL ALL NULL NULL NULL NULL 10 100.00 Using where +1 PRIMARY b NULL ALL NULL NULL NULL NULL 10 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select straight_join `test`.`a`.`a` AS `a`,`test`.`b`.`a` AS `a` from `test`.`t1` `a` join `test`.`t1` `b` where (`test`.`a`.`a`,(/* select#2 */ select `test`.`t2`.`a` from `test`.`t2` where ((`test`.`a`.`a`) = `test`.`t2`.`a`))) +explain select * from t2 where a in (select straight_join a.a from t1 a, t1 b); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 10 100.00 Using where +2 DEPENDENT SUBQUERY a NULL ALL NULL NULL NULL NULL 10 10.00 Using where +2 DEPENDENT SUBQUERY b NULL ALL NULL NULL NULL NULL 10 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` where (`test`.`t2`.`a`,(/* select#2 */ select straight_join `test`.`a`.`a` from `test`.`t1` `a` join `test`.`t1` `b` where ((`test`.`t2`.`a`) = `test`.`a`.`a`))) +explain select * from t2 where a in (select straight_join a.a from t1 a, t1 b); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 10 100.00 Using where +2 DEPENDENT SUBQUERY a NULL ALL NULL NULL NULL NULL 10 10.00 Using where +2 DEPENDENT SUBQUERY b NULL ALL NULL NULL NULL NULL 10 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` where (`test`.`t2`.`a`,(/* select#2 */ select straight_join `test`.`a`.`a` from `test`.`t1` `a` join `test`.`t1` `b` where ((`test`.`t2`.`a`) = `test`.`a`.`a`))) +explain select straight_join * from t2 x, t2 y +where x.a in (select straight_join a.a from t1 a, t1 b); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY x NULL ALL NULL NULL NULL NULL 10 100.00 Using where +1 PRIMARY y NULL ALL NULL NULL NULL NULL 10 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY a NULL ALL NULL NULL NULL NULL 10 10.00 Using where +2 DEPENDENT SUBQUERY b NULL ALL NULL NULL NULL NULL 10 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select straight_join `test`.`x`.`a` AS `a`,`test`.`y`.`a` AS `a` from `test`.`t2` `x` join `test`.`t2` `y` where (`test`.`x`.`a`,(/* select#2 */ select straight_join `test`.`a`.`a` from `test`.`t1` `a` join `test`.`t1` `b` where ((`test`.`x`.`a`) = `test`.`a`.`a`))) +create table t0 (a int, b int); +insert into t0 values(1,1); +explain select * from t0, t3 where t3.a in (select a from t2) and (t3.a < 10 or t3.a >30); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL a NULL NULL NULL 1000 79.30 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 10 10.00 Using where; FirstMatch(t3); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '1' AS `a`,'1' AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t3`.`filler` AS `filler` from `test`.`t3` semi join (`test`.`t2`) where ((`test`.`t2`.`a` = `test`.`t3`.`a`) and ((`test`.`t3`.`a` < 10) or (`test`.`t3`.`a` > 30))) +create table t4 as select a as x, a as y from t1; +explain select * from t0, t3 where (t3.a, t3.b) in (select x,y from t4) and (t3.a < 10 or t3.a >30); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL a NULL NULL NULL 1000 79.30 Using where +1 SIMPLE t4 NULL ALL NULL NULL NULL NULL 10 10.00 Using where; FirstMatch(t3); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '1' AS `a`,'1' AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t3`.`filler` AS `filler` from `test`.`t3` semi join (`test`.`t4`) where ((`test`.`t4`.`y` = `test`.`t3`.`b`) and (`test`.`t4`.`x` = `test`.`t3`.`a`) and ((`test`.`t3`.`a` < 10) or (`test`.`t3`.`a` > 30))) +drop table t0,t1,t2,t3,t4; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (a int, b int, filler char(100), key(a,b)); +insert into t1 select A.a, B.a, 'filler' from t0 A, t0 B; +create table t2 as select * from t1; +explain select * from t2 where a in (select b from t1 where a=3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 100 100.00 Using where +1 SIMPLE t1 NULL ref a a 10 const,test.t2.a 1 100.00 Using index; FirstMatch(t2) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`filler` AS `filler` from `test`.`t2` semi join (`test`.`t1`) where ((`test`.`t1`.`b` = `test`.`t2`.`a`) and (`test`.`t1`.`a` = 3)) +explain select * from t2 where (b,a) in (select a,b from t1 where a=3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 100 10.00 Using where +1 SIMPLE t1 NULL ref a a 10 const,test.t2.a 1 100.00 Using index; FirstMatch(t2) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`filler` AS `filler` from `test`.`t2` semi join (`test`.`t1`) where ((`test`.`t1`.`b` = `test`.`t2`.`a`) and (`test`.`t2`.`b` = 3) and (`test`.`t1`.`a` = 3)) +drop table t1,t2; +create table t1 (a int, b int); +insert into t1 select a,a from t0; +create table t2 (a int, b int); +insert into t2 select A.a + 10*B.a, A.a + 10*B.a from t0 A, t0 B; +explain select * from t1 where (a,b) in (select a,b from t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 100 1.00 Using where; FirstMatch(t1); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`a` = `test`.`t1`.`a`)) +drop table t0, t1, t2; +# +# Bug#19695490: CRASH IN CREATE_REF_FOR_KEY ON SELECT + JOIN + UTF8 COLUMN +# + DATETIME INDEX. +# +CREATE TABLE t1 ( +field1 varchar(255) CHARACTER SET utf8, +field2 varchar(255) CHARACTER SET utf8 +); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES +('time','time'), +('lpjdzvkp','lpjdzvkp'), +('dzvkpai', 'dzvkpai'); +CREATE TABLE t2 ( col_varchar varchar(10)); +CREATE TABLE t3 ( +pk int(11) NOT NULL, +col_varchar_255_utf8_key varchar(255) CHARACTER SET utf8, +col_varchar_10_utf8_key varchar(10) CHARACTER SET utf8, +PRIMARY KEY (pk) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t3 VALUES (22,'come','h'), +(23,'time','aaa'), +(24,'lpjdzvkp','ababa'), +(25,'d','GGDD'); +SELECT * FROM t1 WHERE (field1, field2) IN ( +SELECT table1.col_varchar_255_utf8_key AS field1, +table1.col_varchar_255_utf8_key AS field2 +FROM t3 AS table1 LEFT JOIN t2 AS table2 +ON table1.col_varchar_10_utf8_key <= +table2.col_varchar +WHERE table1.pk >= 6); +field1 field2 +time time +lpjdzvkp lpjdzvkp +DROP TABLE t1,t2,t3; +create table t0 (a decimal(4,2)); +insert into t0 values (10.24), (22.11); +create table t1 as select * from t0; +insert into t1 select * from t0; +explain select * from t0 where a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; FirstMatch(t0); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a` from `test`.`t0` semi join (`test`.`t1`) where (`test`.`t1`.`a` = `test`.`t0`.`a`) +select * from t0 where a in (select a from t1); +a +10.24 +22.11 +drop table t0, t1; +create table t0(a date); +insert into t0 values ('2008-01-01'),('2008-02-02'); +create table t1 as select * from t0; +insert into t1 select * from t0; +explain select * from t0 where a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; FirstMatch(t0); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a` from `test`.`t0` semi join (`test`.`t1`) where (`test`.`t1`.`a` = `test`.`t0`.`a`) +select * from t0 where a in (select a from t1); +a +2008-01-01 +2008-02-02 +drop table t0, t1; +create table t0(a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 as select a as a, a as b, a as c from t0 where a < 3; +create table t2 as select a as a, a as b from t0 where a < 3; +insert into t2 select * from t2; +explain select * from t1 where (a,b,c) in (select x.a, y.a, z.a from t2 x, t2 y, t2 z where x.b=33); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE x NULL ALL NULL NULL NULL NULL 6 16.67 Using where +1 SIMPLE y NULL ALL NULL NULL NULL NULL 6 16.67 Using where +1 SIMPLE z NULL ALL NULL NULL NULL NULL 6 16.67 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` semi join (`test`.`t2` `x` join `test`.`t2` `y` join `test`.`t2` `z`) where ((`test`.`z`.`a` = `test`.`t1`.`c`) and (`test`.`y`.`a` = `test`.`t1`.`b`) and (`test`.`x`.`a` = `test`.`t1`.`a`) and (`test`.`x`.`b` = 33)) +drop table t0,t1,t2; +set @save_join_buffer_size = @@join_buffer_size; +set join_buffer_size= 8192; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (a int, filler1 binary(200), filler2 binary(200)); +insert into t1 select a, 'filler123456', 'filler123456' from t0; +insert into t1 select a+10, 'filler123456', 'filler123456' from t0; +create table t2 as select * from t1; +insert into t1 select a+20, 'filler123456', 'filler123456' from t0; +insert into t1 values (2, 'duplicate ok', 'duplicate ok'); +insert into t1 values (18, 'duplicate ok', 'duplicate ok'); +insert into t2 values (3, 'duplicate ok', 'duplicate ok'); +insert into t2 values (19, 'duplicate ok', 'duplicate ok'); +explain select +a, mid(filler1, 1,10), length(filler1)=length(filler2) as z +from t1 ot where a in (select a from t2 it); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 32 100.00 NULL +1 SIMPLE it NULL ALL NULL NULL NULL NULL 22 10.00 Using where; FirstMatch(ot); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot`.`a` AS `a`,substr(`test`.`ot`.`filler1`,1,10) AS `mid(filler1, 1,10)`,(length(`test`.`ot`.`filler1`) = length(`test`.`ot`.`filler2`)) AS `z` from `test`.`t1` `ot` semi join (`test`.`t2` `it`) where (`test`.`it`.`a` = `test`.`ot`.`a`) +select +a, mid(filler1, 1,10), length(filler1)=length(filler2) as z +from t1 ot where a in (select a from t2 it); +a mid(filler1, 1,10) z +0 filler1234 1 +1 filler1234 1 +10 filler1234 1 +11 filler1234 1 +12 filler1234 1 +13 filler1234 1 +14 filler1234 1 +15 filler1234 1 +16 filler1234 1 +17 filler1234 1 +18 duplicate 1 +18 filler1234 1 +19 filler1234 1 +2 duplicate 1 +2 filler1234 1 +3 filler1234 1 +4 filler1234 1 +5 filler1234 1 +6 filler1234 1 +7 filler1234 1 +8 filler1234 1 +9 filler1234 1 +explain select +a, mid(filler1, 1,10), length(filler1)=length(filler2) +from t2 ot where a in (select a from t1 it); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 22 100.00 NULL +1 SIMPLE it NULL ALL NULL NULL NULL NULL 32 10.00 Using where; FirstMatch(ot); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot`.`a` AS `a`,substr(`test`.`ot`.`filler1`,1,10) AS `mid(filler1, 1,10)`,(length(`test`.`ot`.`filler1`) = length(`test`.`ot`.`filler2`)) AS `length(filler1)=length(filler2)` from `test`.`t2` `ot` semi join (`test`.`t1` `it`) where (`test`.`it`.`a` = `test`.`ot`.`a`) +select +a, mid(filler1, 1,10), length(filler1)=length(filler2) +from t2 ot where a in (select a from t1 it); +a mid(filler1, 1,10) length(filler1)=length(filler2) +0 filler1234 1 +1 filler1234 1 +10 filler1234 1 +11 filler1234 1 +12 filler1234 1 +13 filler1234 1 +14 filler1234 1 +15 filler1234 1 +16 filler1234 1 +17 filler1234 1 +18 filler1234 1 +19 duplicate 1 +19 filler1234 1 +2 filler1234 1 +3 duplicate 1 +3 filler1234 1 +4 filler1234 1 +5 filler1234 1 +6 filler1234 1 +7 filler1234 1 +8 filler1234 1 +9 filler1234 1 +insert into t1 select a+20, 'filler123456', 'filler123456' from t0; +insert into t1 select a+20, 'filler123456', 'filler123456' from t0; +explain select +a, mid(filler1, 1,10), length(filler1)=length(filler2) as z +from t1 ot where a in (select a from t2 it); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 52 100.00 NULL +1 SIMPLE it NULL ALL NULL NULL NULL NULL 22 10.00 Using where; FirstMatch(ot); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot`.`a` AS `a`,substr(`test`.`ot`.`filler1`,1,10) AS `mid(filler1, 1,10)`,(length(`test`.`ot`.`filler1`) = length(`test`.`ot`.`filler2`)) AS `z` from `test`.`t1` `ot` semi join (`test`.`t2` `it`) where (`test`.`it`.`a` = `test`.`ot`.`a`) +select +a, mid(filler1, 1,10), length(filler1)=length(filler2) as z +from t1 ot where a in (select a from t2 it); +a mid(filler1, 1,10) z +0 filler1234 1 +1 filler1234 1 +10 filler1234 1 +11 filler1234 1 +12 filler1234 1 +13 filler1234 1 +14 filler1234 1 +15 filler1234 1 +16 filler1234 1 +17 filler1234 1 +18 duplicate 1 +18 filler1234 1 +19 filler1234 1 +2 duplicate 1 +2 filler1234 1 +3 filler1234 1 +4 filler1234 1 +5 filler1234 1 +6 filler1234 1 +7 filler1234 1 +8 filler1234 1 +9 filler1234 1 +explain select +a, mid(filler1, 1,10), length(filler1)=length(filler2) +from t2 ot where a in (select a from t1 it); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 22 100.00 NULL +1 SIMPLE it NULL ALL NULL NULL NULL NULL 52 10.00 Using where; FirstMatch(ot); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot`.`a` AS `a`,substr(`test`.`ot`.`filler1`,1,10) AS `mid(filler1, 1,10)`,(length(`test`.`ot`.`filler1`) = length(`test`.`ot`.`filler2`)) AS `length(filler1)=length(filler2)` from `test`.`t2` `ot` semi join (`test`.`t1` `it`) where (`test`.`it`.`a` = `test`.`ot`.`a`) +select +a, mid(filler1, 1,10), length(filler1)=length(filler2) +from t2 ot where a in (select a from t1 it); +a mid(filler1, 1,10) length(filler1)=length(filler2) +0 filler1234 1 +1 filler1234 1 +10 filler1234 1 +11 filler1234 1 +12 filler1234 1 +13 filler1234 1 +14 filler1234 1 +15 filler1234 1 +16 filler1234 1 +17 filler1234 1 +18 filler1234 1 +19 duplicate 1 +19 filler1234 1 +2 filler1234 1 +3 duplicate 1 +3 filler1234 1 +4 filler1234 1 +5 filler1234 1 +6 filler1234 1 +7 filler1234 1 +8 filler1234 1 +9 filler1234 1 +set @@join_buffer_size = @save_join_buffer_size; +drop table t1, t2; +create table t1 (a int, b int, key(a)); +create table t2 (a int, b int, key(a)); +create table t3 (a int, b int, key(a)); +insert into t1 select a,a from t0; +insert into t2 select a,a from t0; +insert into t3 select a,a from t0; +t2 and t3 must be use 'ref', not 'ALL': +explain select * +from t0 where a in +(select t2.a+t3.a from t1 left join (t2 join t3) on t2.a=t1.a and t3.a=t1.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 10 100.00 NULL +1 SIMPLE t1 NULL index a a 5 NULL 10 100.00 Using where; Using index +1 SIMPLE t2 NULL ref a a 5 test.t1.a 1 100.00 Using index +1 SIMPLE t3 NULL ref a a 5 test.t1.a 1 100.00 Using index; FirstMatch(t0) +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a` from `test`.`t0` semi join (`test`.`t1` join `test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`a` = `test`.`t1`.`a`) and (`test`.`t3`.`a` = `test`.`t1`.`a`) and (`test`.`t0`.`a` = (`test`.`t1`.`a` + `test`.`t1`.`a`))) +drop table t0, t1,t2,t3; + +Test that neither MaterializeLookup strategy for semijoin, +nor subquery materialization is used when BLOBs are involved +(except when arguments of some functions). + +set @prefix_len = 6; +set @blob_len = 16; +set @suffix_len = @blob_len - @prefix_len; +create table t1_16 (a1 blob(16), a2 blob(16)); +create table t2_16 (b1 blob(16), b2 blob(16)); +create table t3_16 (c1 blob(16), c2 blob(16)); +insert into t1_16 values +(concat('1 - 00', repeat('x', @suffix_len)), concat('2 - 00', repeat('x', @suffix_len))); +insert into t1_16 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t1_16 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_16 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t2_16 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_16 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_16 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t3_16 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t3_16 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_16 values +(concat('1 - 04', repeat('x', @suffix_len)), concat('2 - 04', repeat('x', @suffix_len))); +explain select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select b1 from t2_16 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1_16 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t2_16 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(t1_16); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_16`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_16`.`a2`,7) AS `left(a2,7)` from `test`.`t1_16` semi join (`test`.`t2_16`) where ((`test`.`t2_16`.`b1` = `test`.`t1_16`.`a1`) and (`test`.`t1_16`.`a1` > '0')) +select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select b1 from t2_16 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_16 +where (a1,a2) in (select b1, b2 from t2_16 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1_16 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t2_16 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(t1_16); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_16`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_16`.`a2`,7) AS `left(a2,7)` from `test`.`t1_16` semi join (`test`.`t2_16`) where ((`test`.`t2_16`.`b2` = `test`.`t1_16`.`a2`) and (`test`.`t2_16`.`b1` = `test`.`t1_16`.`a1`) and (`test`.`t1_16`.`a1` > '0')) +select left(a1,7), left(a2,7) +from t1_16 +where (a1,a2) in (select b1, b2 from t2_16 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select substring(b1,1,16) from t2_16 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1_16 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE t2_16 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(t1_16); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_16`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_16`.`a2`,7) AS `left(a2,7)` from `test`.`t1_16` semi join (`test`.`t2_16`) where ((`test`.`t2_16`.`b1` > '0') and (`test`.`t1_16`.`a1` = substr(`test`.`t2_16`.`b1`,1,16))) +select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select substring(b1,1,16) from t2_16 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select group_concat(b1) from t2_16 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_16 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t2_16 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_16`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_16`.`a2`,7) AS `left(a2,7)` from `test`.`t1_16` where (`test`.`t1_16`.`a1`,(/* select#2 */ select group_concat(`test`.`t2_16`.`b1` separator ',') from `test`.`t2_16` group by `test`.`t2_16`.`b2` having ((`test`.`t1_16`.`a1`) = (group_concat(`test`.`t2_16`.`b1` separator ','))))) +select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select group_concat(b1) from t2_16 group by b2); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +set @@group_concat_max_len = 256; +explain select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select group_concat(b1) from t2_16 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_16 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t2_16 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_16`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_16`.`a2`,7) AS `left(a2,7)` from `test`.`t1_16` where (`test`.`t1_16`.`a1`,(/* select#2 */ select group_concat(`test`.`t2_16`.`b1` separator ',') from `test`.`t2_16` group by `test`.`t2_16`.`b2` having ((`test`.`t1_16`.`a1`) = (group_concat(`test`.`t2_16`.`b1` separator ','))))) +select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select group_concat(b1) from t2_16 group by b2); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +create table t1 (a1 char(8), a2 char(8)) charset latin1; +create table t2 (b1 char(8), b2 char(8)) charset latin1; +create table t3 (c1 char(8), c2 char(8)) charset latin1; +insert into t1 values ('1 - 00', '2 - 00'); +insert into t1 values ('1 - 01', '2 - 01'); +insert into t1 values ('1 - 02', '2 - 02'); +insert into t2 values ('1 - 01', '2 - 01'); +insert into t2 values ('1 - 01', '2 - 01'); +insert into t2 values ('1 - 02', '2 - 02'); +insert into t2 values ('1 - 02', '2 - 02'); +insert into t2 values ('1 - 03', '2 - 03'); +insert into t3 values ('1 - 01', '2 - 01'); +insert into t3 values ('1 - 02', '2 - 02'); +insert into t3 values ('1 - 03', '2 - 03'); +insert into t3 values ('1 - 04', '2 - 04'); +insert into t3 values ('1 - 05', '2 - 05'); +insert into t3 values ('1 - 06', '2 - 06'); +insert into t3 values ('1 - 07', '2 - 07'); +insert into t3 values ('1 - 08', '2 - 08'); +explain +select * from t1 +where concat(a1,'x') IN +(select left(a1,8) from t1_16 +where (a1, a2) IN +(select t2_16.b1, t2_16.b2 from t2_16, t2 +where t2.b2 = substring(t2_16.b2,1,6) and +t2.b1 IN (select c1 from t3 where c2 > '0'))); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE t1_16 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t2_16 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 5 20.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` semi join (`test`.`t1_16` join `test`.`t2_16` join `test`.`t2` join `test`.`t3`) where ((`test`.`t2_16`.`b2` = `test`.`t1_16`.`a2`) and (`test`.`t2_16`.`b1` = `test`.`t1_16`.`a1`) and (`test`.`t3`.`c1` = `test`.`t2`.`b1`) and (`test`.`t2`.`b2` = substr(`test`.`t2_16`.`b2`,1,6)) and (`test`.`t3`.`c2` > '0') and (concat(`test`.`t1`.`a1`,'x') = left(`test`.`t1_16`.`a1`,8))) +drop table t1_16, t2_16, t3_16, t1, t2, t3; +set @blob_len = 512; +set @suffix_len = @blob_len - @prefix_len; +create table t1_512 (a1 blob(512), a2 blob(512)); +create table t2_512 (b1 blob(512), b2 blob(512)); +create table t3_512 (c1 blob(512), c2 blob(512)); +insert into t1_512 values +(concat('1 - 00', repeat('x', @suffix_len)), concat('2 - 00', repeat('x', @suffix_len))); +insert into t1_512 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t1_512 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_512 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t2_512 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_512 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_512 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t3_512 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t3_512 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_512 values +(concat('1 - 04', repeat('x', @suffix_len)), concat('2 - 04', repeat('x', @suffix_len))); +explain select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select b1 from t2_512 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1_512 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t2_512 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(t1_512); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_512`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_512`.`a2`,7) AS `left(a2,7)` from `test`.`t1_512` semi join (`test`.`t2_512`) where ((`test`.`t2_512`.`b1` = `test`.`t1_512`.`a1`) and (`test`.`t1_512`.`a1` > '0')) +select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select b1 from t2_512 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_512 +where (a1,a2) in (select b1, b2 from t2_512 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1_512 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t2_512 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(t1_512); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_512`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_512`.`a2`,7) AS `left(a2,7)` from `test`.`t1_512` semi join (`test`.`t2_512`) where ((`test`.`t2_512`.`b2` = `test`.`t1_512`.`a2`) and (`test`.`t2_512`.`b1` = `test`.`t1_512`.`a1`) and (`test`.`t1_512`.`a1` > '0')) +select left(a1,7), left(a2,7) +from t1_512 +where (a1,a2) in (select b1, b2 from t2_512 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select substring(b1,1,512) from t2_512 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1_512 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE t2_512 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(t1_512); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_512`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_512`.`a2`,7) AS `left(a2,7)` from `test`.`t1_512` semi join (`test`.`t2_512`) where ((`test`.`t2_512`.`b1` > '0') and (`test`.`t1_512`.`a1` = substr(`test`.`t2_512`.`b1`,1,512))) +select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select substring(b1,1,512) from t2_512 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select group_concat(b1) from t2_512 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_512 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t2_512 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_512`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_512`.`a2`,7) AS `left(a2,7)` from `test`.`t1_512` where (`test`.`t1_512`.`a1`,(/* select#2 */ select group_concat(`test`.`t2_512`.`b1` separator ',') from `test`.`t2_512` group by `test`.`t2_512`.`b2` having ((`test`.`t1_512`.`a1`) = (group_concat(`test`.`t2_512`.`b1` separator ','))))) +select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select group_concat(b1) from t2_512 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +Warning 1260 Row 4 was cut by GROUP_CONCAT() +Warning 1260 Row 5 was cut by GROUP_CONCAT() +Warning 1260 Row 6 was cut by GROUP_CONCAT() +Warning 1260 Row 7 was cut by GROUP_CONCAT() +Warning 1260 Row 8 was cut by GROUP_CONCAT() +Warning 1260 Row 9 was cut by GROUP_CONCAT() +set @@group_concat_max_len = 256; +explain select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select group_concat(b1) from t2_512 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_512 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t2_512 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_512`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_512`.`a2`,7) AS `left(a2,7)` from `test`.`t1_512` where (`test`.`t1_512`.`a1`,(/* select#2 */ select group_concat(`test`.`t2_512`.`b1` separator ',') from `test`.`t2_512` group by `test`.`t2_512`.`b2` having ((`test`.`t1_512`.`a1`) = (group_concat(`test`.`t2_512`.`b1` separator ','))))) +select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select group_concat(b1) from t2_512 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +Warning 1260 Row 4 was cut by GROUP_CONCAT() +Warning 1260 Row 5 was cut by GROUP_CONCAT() +Warning 1260 Row 6 was cut by GROUP_CONCAT() +Warning 1260 Row 7 was cut by GROUP_CONCAT() +Warning 1260 Row 8 was cut by GROUP_CONCAT() +Warning 1260 Row 9 was cut by GROUP_CONCAT() +drop table t1_512, t2_512, t3_512; +set @blob_len = 513; +set @suffix_len = @blob_len - @prefix_len; +create table t1_513 (a1 blob(513), a2 blob(513)); +create table t2_513 (b1 blob(513), b2 blob(513)); +create table t3_513 (c1 blob(513), c2 blob(513)); +insert into t1_513 values +(concat('1 - 00', repeat('x', @suffix_len)), concat('2 - 00', repeat('x', @suffix_len))); +insert into t1_513 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t1_513 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_513 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t2_513 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_513 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_513 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t3_513 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t3_513 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_513 values +(concat('1 - 04', repeat('x', @suffix_len)), concat('2 - 04', repeat('x', @suffix_len))); +explain select left(a1,7), left(a2,7) +from t1_513 +where a1 in (select b1 from t2_513 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1_513 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t2_513 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(t1_513); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_513`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_513`.`a2`,7) AS `left(a2,7)` from `test`.`t1_513` semi join (`test`.`t2_513`) where ((`test`.`t2_513`.`b1` = `test`.`t1_513`.`a1`) and (`test`.`t1_513`.`a1` > '0')) +select left(a1,7), left(a2,7) +from t1_513 +where a1 in (select b1 from t2_513 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_513 +where (a1,a2) in (select b1, b2 from t2_513 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1_513 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t2_513 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(t1_513); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_513`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_513`.`a2`,7) AS `left(a2,7)` from `test`.`t1_513` semi join (`test`.`t2_513`) where ((`test`.`t2_513`.`b2` = `test`.`t1_513`.`a2`) and (`test`.`t2_513`.`b1` = `test`.`t1_513`.`a1`) and (`test`.`t1_513`.`a1` > '0')) +select left(a1,7), left(a2,7) +from t1_513 +where (a1,a2) in (select b1, b2 from t2_513 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_513 +where a1 in (select substring(b1,1,513) from t2_513 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1_513 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE t2_513 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(t1_513); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_513`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_513`.`a2`,7) AS `left(a2,7)` from `test`.`t1_513` semi join (`test`.`t2_513`) where ((`test`.`t2_513`.`b1` > '0') and (`test`.`t1_513`.`a1` = substr(`test`.`t2_513`.`b1`,1,513))) +select left(a1,7), left(a2,7) +from t1_513 +where a1 in (select substring(b1,1,513) from t2_513 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_513 +where a1 in (select group_concat(b1) from t2_513 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_513 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t2_513 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_513`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_513`.`a2`,7) AS `left(a2,7)` from `test`.`t1_513` where (`test`.`t1_513`.`a1`,(/* select#2 */ select group_concat(`test`.`t2_513`.`b1` separator ',') from `test`.`t2_513` group by `test`.`t2_513`.`b2` having ((`test`.`t1_513`.`a1`) = (group_concat(`test`.`t2_513`.`b1` separator ','))))) +select left(a1,7), left(a2,7) +from t1_513 +where a1 in (select group_concat(b1) from t2_513 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +Warning 1260 Row 4 was cut by GROUP_CONCAT() +Warning 1260 Row 5 was cut by GROUP_CONCAT() +Warning 1260 Row 6 was cut by GROUP_CONCAT() +Warning 1260 Row 7 was cut by GROUP_CONCAT() +Warning 1260 Row 8 was cut by GROUP_CONCAT() +Warning 1260 Row 9 was cut by GROUP_CONCAT() +drop table t1_513, t2_513, t3_513; +set @blob_len = 1024; +set @suffix_len = @blob_len - @prefix_len; +create table t1_1024 (a1 blob(1024), a2 blob(1024)); +create table t2_1024 (b1 blob(1024), b2 blob(1024)); +create table t3_1024 (c1 blob(1024), c2 blob(1024)); +insert into t1_1024 values +(concat('1 - 00', repeat('x', @suffix_len)), concat('2 - 00', repeat('x', @suffix_len))); +insert into t1_1024 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t1_1024 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_1024 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t2_1024 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_1024 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_1024 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t3_1024 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t3_1024 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_1024 values +(concat('1 - 04', repeat('x', @suffix_len)), concat('2 - 04', repeat('x', @suffix_len))); +explain select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select b1 from t2_1024 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1_1024 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t2_1024 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(t1_1024); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1024`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1024`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1024` semi join (`test`.`t2_1024`) where ((`test`.`t2_1024`.`b1` = `test`.`t1_1024`.`a1`) and (`test`.`t1_1024`.`a1` > '0')) +select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select b1 from t2_1024 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_1024 +where (a1,a2) in (select b1, b2 from t2_1024 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1_1024 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t2_1024 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(t1_1024); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1024`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1024`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1024` semi join (`test`.`t2_1024`) where ((`test`.`t2_1024`.`b2` = `test`.`t1_1024`.`a2`) and (`test`.`t2_1024`.`b1` = `test`.`t1_1024`.`a1`) and (`test`.`t1_1024`.`a1` > '0')) +select left(a1,7), left(a2,7) +from t1_1024 +where (a1,a2) in (select b1, b2 from t2_1024 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select substring(b1,1,1024) from t2_1024 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1_1024 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE t2_1024 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(t1_1024); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1024`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1024`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1024` semi join (`test`.`t2_1024`) where ((`test`.`t2_1024`.`b1` > '0') and (`test`.`t1_1024`.`a1` = substr(`test`.`t2_1024`.`b1`,1,1024))) +select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select substring(b1,1,1024) from t2_1024 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select group_concat(b1) from t2_1024 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_1024 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t2_1024 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1024`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1024`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1024` where (`test`.`t1_1024`.`a1`,(/* select#2 */ select group_concat(`test`.`t2_1024`.`b1` separator ',') from `test`.`t2_1024` group by `test`.`t2_1024`.`b2` having ((`test`.`t1_1024`.`a1`) = (group_concat(`test`.`t2_1024`.`b1` separator ','))))) +select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select group_concat(b1) from t2_1024 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +Warning 1260 Row 4 was cut by GROUP_CONCAT() +Warning 1260 Row 5 was cut by GROUP_CONCAT() +Warning 1260 Row 6 was cut by GROUP_CONCAT() +Warning 1260 Row 7 was cut by GROUP_CONCAT() +Warning 1260 Row 8 was cut by GROUP_CONCAT() +Warning 1260 Row 9 was cut by GROUP_CONCAT() +set @@group_concat_max_len = 256; +explain select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select group_concat(b1) from t2_1024 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_1024 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t2_1024 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1024`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1024`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1024` where (`test`.`t1_1024`.`a1`,(/* select#2 */ select group_concat(`test`.`t2_1024`.`b1` separator ',') from `test`.`t2_1024` group by `test`.`t2_1024`.`b2` having ((`test`.`t1_1024`.`a1`) = (group_concat(`test`.`t2_1024`.`b1` separator ','))))) +select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select group_concat(b1) from t2_1024 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +Warning 1260 Row 4 was cut by GROUP_CONCAT() +Warning 1260 Row 5 was cut by GROUP_CONCAT() +Warning 1260 Row 6 was cut by GROUP_CONCAT() +Warning 1260 Row 7 was cut by GROUP_CONCAT() +Warning 1260 Row 8 was cut by GROUP_CONCAT() +Warning 1260 Row 9 was cut by GROUP_CONCAT() +drop table t1_1024, t2_1024, t3_1024; +set @blob_len = 1025; +set @suffix_len = @blob_len - @prefix_len; +create table t1_1025 (a1 blob(1025), a2 blob(1025)); +create table t2_1025 (b1 blob(1025), b2 blob(1025)); +create table t3_1025 (c1 blob(1025), c2 blob(1025)); +insert into t1_1025 values +(concat('1 - 00', repeat('x', @suffix_len)), concat('2 - 00', repeat('x', @suffix_len))); +insert into t1_1025 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t1_1025 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_1025 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t2_1025 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_1025 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_1025 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t3_1025 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t3_1025 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_1025 values +(concat('1 - 04', repeat('x', @suffix_len)), concat('2 - 04', repeat('x', @suffix_len))); +explain select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select b1 from t2_1025 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1_1025 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t2_1025 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(t1_1025); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1025`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1025`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1025` semi join (`test`.`t2_1025`) where ((`test`.`t2_1025`.`b1` = `test`.`t1_1025`.`a1`) and (`test`.`t1_1025`.`a1` > '0')) +select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select b1 from t2_1025 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_1025 +where (a1,a2) in (select b1, b2 from t2_1025 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1_1025 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t2_1025 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(t1_1025); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1025`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1025`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1025` semi join (`test`.`t2_1025`) where ((`test`.`t2_1025`.`b2` = `test`.`t1_1025`.`a2`) and (`test`.`t2_1025`.`b1` = `test`.`t1_1025`.`a1`) and (`test`.`t1_1025`.`a1` > '0')) +select left(a1,7), left(a2,7) +from t1_1025 +where (a1,a2) in (select b1, b2 from t2_1025 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select substring(b1,1,1025) from t2_1025 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1_1025 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE t2_1025 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(t1_1025); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1025`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1025`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1025` semi join (`test`.`t2_1025`) where ((`test`.`t2_1025`.`b1` > '0') and (`test`.`t1_1025`.`a1` = substr(`test`.`t2_1025`.`b1`,1,1025))) +select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select substring(b1,1,1025) from t2_1025 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select group_concat(b1) from t2_1025 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_1025 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t2_1025 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1025`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1025`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1025` where (`test`.`t1_1025`.`a1`,(/* select#2 */ select group_concat(`test`.`t2_1025`.`b1` separator ',') from `test`.`t2_1025` group by `test`.`t2_1025`.`b2` having ((`test`.`t1_1025`.`a1`) = (group_concat(`test`.`t2_1025`.`b1` separator ','))))) +select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select group_concat(b1) from t2_1025 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +Warning 1260 Row 4 was cut by GROUP_CONCAT() +Warning 1260 Row 5 was cut by GROUP_CONCAT() +Warning 1260 Row 6 was cut by GROUP_CONCAT() +Warning 1260 Row 7 was cut by GROUP_CONCAT() +Warning 1260 Row 8 was cut by GROUP_CONCAT() +Warning 1260 Row 9 was cut by GROUP_CONCAT() +set @@group_concat_max_len = 256; +explain select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select group_concat(b1) from t2_1025 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_1025 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t2_1025 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1025`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1025`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1025` where (`test`.`t1_1025`.`a1`,(/* select#2 */ select group_concat(`test`.`t2_1025`.`b1` separator ',') from `test`.`t2_1025` group by `test`.`t2_1025`.`b2` having ((`test`.`t1_1025`.`a1`) = (group_concat(`test`.`t2_1025`.`b1` separator ','))))) +select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select group_concat(b1) from t2_1025 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +Warning 1260 Row 4 was cut by GROUP_CONCAT() +Warning 1260 Row 5 was cut by GROUP_CONCAT() +Warning 1260 Row 6 was cut by GROUP_CONCAT() +Warning 1260 Row 7 was cut by GROUP_CONCAT() +Warning 1260 Row 8 was cut by GROUP_CONCAT() +Warning 1260 Row 9 was cut by GROUP_CONCAT() +drop table t1_1025, t2_1025, t3_1025; +# +# WL#5561: Enable semi join transformation with outer join. +# +CREATE TABLE ot1(a INT); +CREATE TABLE ot2(a INT); +CREATE TABLE ot3(a INT); +CREATE TABLE it1(a INT); +CREATE TABLE it2(a INT); +CREATE TABLE it3(a INT); +INSERT INTO ot1 VALUES(0),(1),(2),(3),(4),(5),(6),(7); +INSERT INTO ot2 VALUES(0),(2),(4),(6); +INSERT INTO ot3 VALUES(0),(3),(6); +INSERT INTO it1 VALUES(0),(1),(2),(3),(4),(5),(6),(7); +INSERT INTO it2 VALUES(0),(2),(4),(6); +INSERT INTO it3 VALUES(0),(3),(6); +# Test cases, Subquery Pattern 1 +# Example SQ1.1: +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE ot1.a IN (SELECT a FROM it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +1 SIMPLE it3 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(ot1); Using join buffer (hash join) +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` left join `test`.`ot2` on((`test`.`ot2`.`a` = `test`.`ot1`.`a`)) semi join (`test`.`it3`) where (`test`.`it3`.`a` = `test`.`ot1`.`a`) +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE ot1.a IN (SELECT a FROM it3); +a a +0 0 +3 NULL +6 6 +# Example SQ1.2: +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE COALESCE(ot2.a,0) IN (SELECT a FROM it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (hash join) +1 SIMPLE it3 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(ot2); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` left join `test`.`ot2` on((`test`.`ot2`.`a` = `test`.`ot1`.`a`)) semi join (`test`.`it3`) where (coalesce(`test`.`ot2`.`a`,0) = `test`.`it3`.`a`) +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE COALESCE(ot2.a,0) IN (SELECT a FROM it3); +a a +0 0 +1 NULL +3 NULL +5 NULL +6 6 +7 NULL +# Example SQ1.3: +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE (ot1.a,ot2.a) IN (SELECT a, a FROM it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; Using join buffer (hash join) +1 SIMPLE it3 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(ot1); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` join `test`.`ot2` semi join (`test`.`it3`) where ((`test`.`ot1`.`a` = `test`.`ot2`.`a`) and (`test`.`it3`.`a` = `test`.`ot2`.`a`)) +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE (ot1.a,ot2.a) IN (SELECT a, a FROM it3); +a a +0 0 +6 6 +# More test cases +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 +WHERE ot1.a IN (SELECT a FROM it3); +a a +0 0 +3 NULL +6 6 +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 +WHERE ot1.a IN (SELECT a+0 FROM it3); +a a +0 0 +3 NULL +6 6 +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 +WHERE COALESCE(ot2.a,0) IN (SELECT a FROM it3); +a a +0 0 +1 NULL +3 NULL +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE COALESCE(ot2.a,0) IN (SELECT a+0 FROM it3); +a a +0 0 +1 NULL +3 NULL +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 +WHERE (ot1.a,ot2.a) IN (SELECT a, a FROM it3); +a a +0 0 +6 6 +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +LEFT JOIN ot3 ON ot1.a=ot3.a +WHERE ot1.a IN (SELECT a FROM it3); +a a a +0 0 0 +3 NULL 3 +6 6 6 +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +LEFT JOIN ot3 ON ot1.a=ot3.a +WHERE COALESCE(ot2.a,0) IN (SELECT a FROM it3); +a a a +0 0 0 +1 NULL NULL +3 NULL 3 +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +LEFT JOIN ot3 ON ot1.a=ot3.a +WHERE COALESCE(ot3.a,0) IN (SELECT a FROM it3); +a a a +0 0 0 +1 NULL NULL +2 2 NULL +3 NULL 3 +4 4 NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +LEFT JOIN ot3 ON ot2.a=ot3.a +WHERE ot1.a IN (SELECT a FROM it3); +a a a +0 0 0 +3 NULL NULL +6 6 6 +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +LEFT JOIN ot3 ON ot2.a=ot3.a +WHERE COALESCE(ot2.a,0) IN (SELECT a FROM it3); +a a a +0 0 0 +1 NULL NULL +3 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +LEFT JOIN ot3 ON ot2.a=ot3.a +WHERE COALESCE(ot3.a,0) IN (SELECT a FROM it3); +a a a +0 0 0 +1 NULL NULL +2 2 NULL +3 NULL NULL +4 4 NULL +5 NULL NULL +6 6 6 +7 NULL NULL +# Test cases, Subquery Pattern 2 +# Example SQ2.1: +explain SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; Using join buffer (hash join) +1 SIMPLE it3 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(ot1); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` join `test`.`ot2` semi join (`test`.`it3`) where ((`test`.`ot1`.`a` = `test`.`ot2`.`a`) and (`test`.`it3`.`a` = `test`.`ot2`.`a`)) +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3); +a a +0 0 +6 6 +# Example SQ2.2: +explain SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it2) +AND ot2.a IN (SELECT a FROM it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +1 SIMPLE it3 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(ot2); Using join buffer (hash join) +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; Using join buffer (hash join) +1 SIMPLE it2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; FirstMatch(ot1); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` join `test`.`ot2` semi join (`test`.`it2`) semi join (`test`.`it3`) where ((`test`.`it3`.`a` = `test`.`ot2`.`a`) and (`test`.`ot1`.`a` = `test`.`ot2`.`a`) and (`test`.`it2`.`a` = `test`.`ot2`.`a`)) +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it2) +AND ot2.a IN (SELECT a FROM it3); +a a +0 0 +6 6 +# More test cases +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it3); +a a +0 0 +6 6 +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it3); +a a +0 0 +6 6 +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a+0 AND ot2.a IN (SELECT a FROM it3); +a a +0 0 +6 6 +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot2.a IN (SELECT a+0 FROM it3); +a a +0 0 +6 6 +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it2) +AND ot2.a IN (SELECT a+0 FROM it3); +a a +0 0 +6 6 +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3) +JOIN ot3 ON ot2.a=ot3.a AND ot3.a IN (SELECT a FROM it3); +a a a +0 0 0 +6 6 6 +# Test cases, Subquery Pattern 3 +# Example SQ3.1: +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +1 SIMPLE it3 NULL ALL NULL NULL NULL NULL 3 100.00 Using where; FirstMatch(ot2) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` semi join (`test`.`it3`)) on(((`test`.`ot2`.`a` = `test`.`ot1`.`a`) and (`test`.`it3`.`a` = `test`.`ot1`.`a`))) where true +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3); +a a +0 0 +1 NULL +2 NULL +3 NULL +4 NULL +5 NULL +6 6 +7 NULL +# Example SQ3.2: +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot2.a IN (SELECT a FROM it2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +1 SIMPLE it2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where; FirstMatch(ot2) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` semi join (`test`.`it2`)) on(((`test`.`ot2`.`a` = `test`.`ot1`.`a`) and (`test`.`it2`.`a` = `test`.`ot1`.`a`))) where true +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot2.a IN (SELECT a FROM it2); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +# Example SQ3.3 +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1) +AND ot2.a IN (SELECT a FROM it2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +1 SIMPLE it2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where; FirstMatch(ot2) +1 SIMPLE it1 NULL ALL NULL NULL NULL NULL 8 100.00 Using where; FirstMatch(it2) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` semi join (`test`.`it1`) semi join (`test`.`it2`)) on(((`test`.`ot2`.`a` = `test`.`ot1`.`a`) and (`test`.`it2`.`a` = `test`.`ot1`.`a`) and (`test`.`it1`.`a` = `test`.`ot1`.`a`))) where true +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1) +AND ot2.a IN (SELECT a FROM it2); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +# Example SQ3.4 +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND +(ot1.a, ot2.a) IN (SELECT it1.a, it2.a +FROM it1 JOIN it2 ON it1.a=it2.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +1 SIMPLE it2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +1 SIMPLE it1 NULL ALL NULL NULL NULL NULL 8 100.00 Using where; FirstMatch(ot2) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` semi join (`test`.`it1` join `test`.`it2`)) on(((`test`.`ot2`.`a` = `test`.`ot1`.`a`) and (`test`.`it2`.`a` = `test`.`ot1`.`a`) and (`test`.`it1`.`a` = `test`.`ot1`.`a`))) where true +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND +(ot1.a, ot2.a) IN (SELECT it1.a, it2.a +FROM it1 JOIN it2 ON it1.a=it2.a); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +# More test cases +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it3); +a a +0 0 +1 NULL +2 NULL +3 NULL +4 NULL +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it3); +a a +0 0 +1 NULL +2 NULL +3 NULL +4 NULL +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 AND ot2.a IN (SELECT a FROM it2); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot2.a IN (SELECT a+0 FROM it2); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a+0 FROM it1) +AND ot2.a IN (SELECT a+0 FROM it2); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 AND +(ot1.a, ot2.a) IN (SELECT it1.a+0, it2.a+0 +FROM it1 JOIN it2 ON it1.a=it2.a); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +EXPLAIN FORMAT=tree SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3) +LEFT JOIN ot3 ON ot2.a=ot3.a AND ot3.a IN (SELECT a FROM it3); +EXPLAIN +-> Nested loop left join (cost=98.31 rows=864) + -> Nested loop left join (cost=11.41 rows=96) + -> Table scan on ot1 (cost=1.30 rows=8) + -> Nested loop semijoin (cost=1.81 rows=12) + -> Filter: (ot2.a = ot1.a) (cost=0.11 rows=4) + -> Table scan on ot2 (cost=0.11 rows=4) + -> Filter: (it3.a = ot1.a) (cost=0.08 rows=3) + -> Table scan on it3 (cost=0.08 rows=3) + -> Nested loop semijoin (cost=1.43 rows=9) + -> Filter: (ot3.a = ot2.a) (cost=0.03 rows=3) + -> Table scan on ot3 (cost=0.03 rows=3) + -> Filter: (it3.a = ot2.a) (cost=0.03 rows=3) + -> Table scan on it3 (cost=0.03 rows=3) + +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3) +LEFT JOIN ot3 ON ot2.a=ot3.a AND ot3.a IN (SELECT a FROM it3); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it3) +LEFT JOIN ot3 ON ot2.a=ot3.a+0 AND ot3.a IN (SELECT a FROM it3); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +# Test cases, Subquery Pattern 4 +# Example SQ4.1: +explain SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +1 SIMPLE ot3 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE it1 NULL ALL NULL NULL NULL NULL 8 100.00 Using where; FirstMatch(ot3) +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a`,`test`.`ot3`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` join `test`.`ot3` semi join (`test`.`it1`)) on(((`test`.`ot3`.`a` = `test`.`ot1`.`a`) and (`test`.`it1`.`a` = `test`.`ot1`.`a`) and (`test`.`ot2`.`a` = `test`.`ot1`.`a`))) where true +SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +# Example SQ4.2: +explain SELECT * +FROM ot1 +JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot3 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; Using join buffer (hash join) +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; Using join buffer (hash join) +1 SIMPLE it1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; FirstMatch(ot1); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a`,`test`.`ot3`.`a` AS `a` from `test`.`ot1` join `test`.`ot2` join `test`.`ot3` semi join (`test`.`it1`) where ((`test`.`ot2`.`a` = `test`.`ot3`.`a`) and (`test`.`ot1`.`a` = `test`.`ot3`.`a`) and (`test`.`it1`.`a` = `test`.`ot3`.`a`)) +SELECT * +FROM ot1 +JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +6 6 6 +# Example SQ4.3: +explain SELECT * +FROM ot1 +JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; Using join buffer (hash join) +1 SIMPLE it1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; FirstMatch(ot1); Using join buffer (hash join) +1 SIMPLE ot3 NULL ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a`,`test`.`ot3`.`a` AS `a` from `test`.`ot1` join `test`.`ot2` left join `test`.`ot3` on((`test`.`ot3`.`a` = `test`.`ot2`.`a`)) semi join (`test`.`it1`) where ((`test`.`ot1`.`a` = `test`.`ot2`.`a`) and (`test`.`it1`.`a` = `test`.`ot2`.`a`)) +SELECT * +FROM ot1 +JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +2 2 NULL +4 4 NULL +6 6 6 +# Example SQ4.4: +explain SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +1 SIMPLE it1 NULL ALL NULL NULL NULL NULL 8 100.00 Using where; FirstMatch(ot2) +1 SIMPLE ot3 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a`,`test`.`ot3`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` left join `test`.`ot3` on((`test`.`ot3`.`a` = `test`.`ot1`.`a`)) semi join (`test`.`it1`)) on(((`test`.`ot2`.`a` = `test`.`ot1`.`a`) and (`test`.`it1`.`a` = `test`.`ot1`.`a`))) where true +SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +1 NULL NULL +2 2 NULL +3 NULL NULL +4 4 NULL +5 NULL NULL +6 6 6 +7 NULL NULL +# More test cases +SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a+0) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it1); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 +JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a+0) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +6 6 6 +SELECT * +FROM ot1 +JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +6 6 6 +SELECT * +FROM ot1 +JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it1); +a a a +0 0 0 +6 6 6 +SELECT * +FROM ot1 +JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a+0) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +2 2 NULL +4 4 NULL +6 6 6 +SELECT * +FROM ot1 +JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +2 2 NULL +4 4 NULL +6 6 6 +SELECT * +FROM ot1 +JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it1); +a a a +0 0 0 +2 2 NULL +4 4 NULL +6 6 6 +SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a+0) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +1 NULL NULL +2 2 NULL +3 NULL NULL +4 4 NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +1 NULL NULL +2 2 NULL +3 NULL NULL +4 4 NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it1); +a a a +0 0 0 +1 NULL NULL +2 2 NULL +3 NULL NULL +4 4 NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1) +LEFT JOIN +ot1 AS ot4 +ON ot2.a=ot4.a; +a a a a +0 0 0 0 +1 NULL NULL NULL +2 2 NULL 2 +3 NULL NULL NULL +4 4 NULL 4 +5 NULL NULL NULL +6 6 6 6 +7 NULL NULL NULL +SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a +LEFT JOIN ot1 AS ot4 ON ot3.a=ot4.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a a +0 0 0 0 +1 NULL NULL NULL +2 2 NULL NULL +3 NULL NULL NULL +4 4 NULL NULL +5 NULL NULL NULL +6 6 6 6 +7 NULL NULL NULL +DROP TABLE ot1,ot2,ot3,it1,it2,it3; +CREATE TABLE t ( +a INTEGER DEFAULT NULL +) ENGINE=InnoDB; +INSERT INTO t VALUES (1); +CREATE TABLE t2 ( +a INTEGER DEFAULT NULL +) ENGINE=InnoDB; +INSERT INTO t2 VALUES (1),(1); +CREATE TABLE t4 ( +a INTEGER DEFAULT NULL +) ENGINE=InnoDB; +INSERT INTO t4 VALUES (1),(1); +CREATE TABLE v ( +a INTEGER DEFAULT NULL +) ENGINE=InnoDB; +INSERT INTO v VALUES (1),(1); +explain SELECT * +FROM t AS t1 +LEFT JOIN +(t2 +LEFT JOIN t AS t3 +ON t3.a IN (SELECT a FROM t AS it) +JOIN t4 +ON t4.a=100 +) +ON TRUE +WHERE t1.a IN (SELECT * FROM v AS it2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE it2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1); Using join buffer (hash join) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE it NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t3) +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t4`.`a` AS `a` from `test`.`t` `t1` left join (`test`.`t2` left join (`test`.`t` `t3` semi join (`test`.`t` `it`)) on(((`test`.`it`.`a` = `test`.`t3`.`a`))) join `test`.`t4`) on(((`test`.`t4`.`a` = 100))) semi join (`test`.`v` `it2`) where (`test`.`it2`.`a` = `test`.`t1`.`a`) +SELECT * +FROM t AS t1 +LEFT JOIN +(t2 +LEFT JOIN t AS t3 +ON t3.a IN (SELECT a FROM t AS it) +JOIN t4 +ON t4.a=100 +) +ON TRUE +WHERE t1.a IN (SELECT * FROM v AS it2); +a a a a +1 NULL NULL NULL +DROP TABLE t,t2,t4,v; +# End of WL#5561 +# +# Bug#48868: Left outer join in subquery causes segmentation fault in +# make_join_select. +# +CREATE TABLE t1 (i INTEGER); +INSERT INTO t1 VALUES (1); +INSERT INTO t1 VALUES (2); +CREATE TABLE t2 (i INTEGER); +INSERT INTO t2 VALUES(1); +CREATE TABLE t3 (i INTEGER); +INSERT INTO t3 VALUES (1); +INSERT INTO t3 VALUES (2); +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t2.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +1 +DROP TABLE t1, t2, t3; + +Bug#37899: Wrongly checked optimization prerequisite caused failed +assertion. + +CREATE TABLE t1 ( +`pk` int(11), +`varchar_nokey` varchar(5) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES +(1,'qk'),(2,'j'),(3,'aew'); +SELECT * +FROM t1 +WHERE varchar_nokey IN ( +SELECT +varchar_nokey +FROM +t1 +) XOR pk = 30; +pk varchar_nokey +1 qk +2 j +3 aew +drop table t1; +# +# BUG#41842: Semi-join materialization strategy crashes when the upper query has HAVING +# +CREATE TABLE t1 ( +pk int(11) NOT NULL AUTO_INCREMENT, +int_nokey int(11) NOT NULL, +time_key time NOT NULL, +datetime_key datetime NOT NULL, +datetime_nokey datetime NOT NULL, +varchar_key varchar(1) NOT NULL, +varchar_nokey varchar(1) NOT NULL, +PRIMARY KEY (pk), +KEY time_key (time_key), +KEY datetime_key (datetime_key), +KEY varchar_key (varchar_key) +) ENGINE=MyISaM; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES +(1,0, '00:16:10','2008-09-03 14:25:40','2008-09-03 14:25:40','h','h'), +(2,7, '00:00:00','2001-01-13 00:00:00','2001-01-13 00:00:00','',''), +(3,0, '00:00:00','0000-00-00 00:00:00','0000-00-00 00:00:00','x','x'), +(4,2, '16:29:24','2000-10-16 01:39:08','2000-10-16 01:39:08','w','w'), +(5,1, '09:23:32','0000-00-00 00:00:00','0000-00-00 00:00:00','p','p'), +(6,3, '00:00:00','2007-12-02 00:00:00','2007-12-02 00:00:00','o','o'), +(7,3, '00:00:00','2008-09-11 00:00:00','2008-09-11 00:00:00','',''), +(8,0, '13:59:04','0000-00-00 00:00:00','0000-00-00 00:00:00','s','s'), +(9,7, '09:01:06','0000-00-00 00:00:00','0000-00-00 00:00:00','d','d'), +(10,5,'00:00:00','0000-00-00 00:00:00','0000-00-00 00:00:00','n','n'), +(11,0,'21:06:46','0000-00-00 00:00:00','0000-00-00 00:00:00','o','o'), +(12,2,'00:00:00','0000-00-00 00:00:00','0000-00-00 00:00:00','',''), +(13,6,'14:45:34','2003-07-28 02:34:08','2003-07-28 02:34:08','w','w'), +(14,1,'15:04:12','0000-00-00 00:00:00','0000-00-00 00:00:00','o','o'), +(15,0,'00:00:00','0000-00-00 00:00:00','0000-00-00 00:00:00','x','x'), +(16,0,'15:55:23','2004-03-17 00:32:27','2004-03-17 00:32:27','p','p'), +(17,1,'16:30:00','2004-12-27 19:20:00','2004-12-27 19:20:00','d','d'), +(18,0,'00:00:00','0000-00-00 00:00:00','0000-00-00 00:00:00','h','h'), +(19,0,'14:13:26','2008-11-09 05:53:48','2008-11-09 05:53:48','o','o'), +(20,0,'00:00:00','2009-10-11 06:58:04','2009-10-11 06:58:04','k','k'); +Warnings: +Warning 1264 Out of range value for column 'datetime_key' at row 3 +Warning 1264 Out of range value for column 'datetime_nokey' at row 3 +Warning 1264 Out of range value for column 'datetime_key' at row 5 +Warning 1264 Out of range value for column 'datetime_nokey' at row 5 +Warning 1264 Out of range value for column 'datetime_key' at row 8 +Warning 1264 Out of range value for column 'datetime_nokey' at row 8 +Warning 1264 Out of range value for column 'datetime_key' at row 9 +Warning 1264 Out of range value for column 'datetime_nokey' at row 9 +Warning 1264 Out of range value for column 'datetime_key' at row 10 +Warning 1264 Out of range value for column 'datetime_nokey' at row 10 +Warning 1264 Out of range value for column 'datetime_key' at row 11 +Warning 1264 Out of range value for column 'datetime_nokey' at row 11 +Warning 1264 Out of range value for column 'datetime_key' at row 12 +Warning 1264 Out of range value for column 'datetime_nokey' at row 12 +Warning 1264 Out of range value for column 'datetime_key' at row 14 +Warning 1264 Out of range value for column 'datetime_nokey' at row 14 +Warning 1264 Out of range value for column 'datetime_key' at row 15 +Warning 1264 Out of range value for column 'datetime_nokey' at row 15 +Warning 1264 Out of range value for column 'datetime_key' at row 18 +Warning 1264 Out of range value for column 'datetime_nokey' at row 18 +CREATE TABLE t2 ( +pk int(11) NOT NULL AUTO_INCREMENT, +int_nokey int(11) NOT NULL, +time_key time NOT NULL, +datetime_key datetime NOT NULL, +datetime_nokey datetime NOT NULL, +varchar_key varchar(1) NOT NULL, +varchar_nokey varchar(1) NOT NULL, +PRIMARY KEY (pk), +KEY time_key (time_key), +KEY datetime_key (datetime_key), +KEY varchar_key (varchar_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT IGNORE INTO t2 VALUES +(10,0,'19:39:13','0000-00-00 00:00:00','0000-00-00 00:00:00','g','g'), +(11,8,'03:43:53','0000-00-00 00:00:00','0000-00-00 00:00:00','b','b'); +Warnings: +Warning 1264 Out of range value for column 'datetime_key' at row 1 +Warning 1264 Out of range value for column 'datetime_nokey' at row 1 +Warning 1264 Out of range value for column 'datetime_key' at row 2 +Warning 1264 Out of range value for column 'datetime_nokey' at row 2 +SELECT OUTR.datetime_nokey AS X FROM t1 AS OUTR +WHERE +OUTR.varchar_nokey IN (SELECT +INNR . varchar_nokey AS Y +FROM t2 AS INNR +WHERE +INNR . datetime_key >= INNR . time_key OR +INNR . pk = INNR . int_nokey +) +AND OUTR . varchar_nokey <= 'w' +HAVING X > '2012-12-12'; +X +drop table t1, t2; + +Bug#46797 "Crash in fix_semijoin_strategies_for_picked_join_order +with semijoin=on" + +CREATE TABLE t1 ( +varchar_key varchar(1) DEFAULT NULL, +KEY varchar_key (varchar_key) +); +CREATE TABLE t2 ( +varchar_key varchar(1) DEFAULT NULL, +KEY varchar_key (varchar_key) +); +INSERT INTO t2 VALUES +(NULL),(NULL),(NULL),(NULL),('a'),('a'),('a'),('b'),('b'),('b'),('b'),('c'), +('c'),('c'),('c'),('c'),('c'),('c'),('d'),('d'),('d'),('d'),('d'),('d'),('e'), +('e'),('e'),('e'),('e'),('e'),('f'),('f'),('f'),('g'),('g'),('h'),('h'),('h'), +('h'),('i'),('j'),('j'),('j'),('k'),('k'),('l'),('l'),('m'),('m'),('m'),('m'), +('n'),('n'),('n'),('o'),('o'),('o'),('p'),('p'),('p'),('q'),('q'),('q'),('r'), +('r'),('r'),('r'),('s'),('s'),('s'),('s'),('t'),('t'),('t'),('t'),('u'),('u'), +('u'),('u'),('v'),('v'),('v'),('v'),('w'),('w'),('w'),('w'),('w'),('w'),('x'), +('x'),('x'),('y'),('y'),('y'),('y'),('z'),('z'),('z'),('z'); +CREATE TABLE t3 ( +varchar_key varchar(1) DEFAULT NULL, +KEY varchar_key (varchar_key) +) ENGINE=MyISAM DEFAULT CHARSET=latin1; +INSERT INTO t3 VALUES +(NULL),('c'),('d'),('e'),('f'),('h'),('j'),('k'),('k'),('m'),('m'),('m'), +('n'),('o'),('r'),('t'),('t'),('u'),('w'),('y'); +SELECT varchar_key FROM t3 +WHERE (SELECT varchar_key FROM t3 +WHERE (varchar_key,varchar_key) +IN (SELECT t1.varchar_key, t2 .varchar_key +FROM t1 RIGHT JOIN t2 ON t1.varchar_key +) +); +varchar_key +DROP TABLE t1, t2, t3; +# +# Bug#46556 Returning incorrect, empty results for some IN subqueries +# w/semijoin=on +# +CREATE TABLE t0 ( +pk INTEGER, +vkey VARCHAR(1), +vnokey VARCHAR(1), +PRIMARY KEY (pk), +KEY vkey(vkey) +) charset utf8mb4; +INSERT INTO t0 +VALUES (1,'g','g'), (2,'v','v'), (3,'t','t'), (4,'u','u'), (5,'n','n'); +EXPLAIN SELECT vkey FROM t0 WHERE pk IN +(SELECT t1.pk FROM t0 t1 JOIN t0 t2 ON t2.vkey = t1.vnokey); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL ALL PRIMARY NULL NULL NULL 5 100.00 NULL +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t0.pk 1 100.00 Using where +1 SIMPLE t2 NULL ref vkey vkey 7 test.t1.vnokey 2 100.00 Using index; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`vkey` AS `vkey` from `test`.`t0` `t1` join `test`.`t0` semi join (`test`.`t0` `t2`) where ((`test`.`t2`.`vkey` = `test`.`t1`.`vnokey`) and (`test`.`t1`.`pk` = `test`.`t0`.`pk`)) +SELECT vkey FROM t0 WHERE pk IN +(SELECT t1.pk FROM t0 t1 JOIN t0 t2 ON t2.vkey = t1.vnokey); +vkey +g +n +t +u +v +DROP TABLE t0; +# End of bug#46556 + +Bug#48834: Procedure with view + subquery + semijoin=on +crashes on second call. + +CREATE TABLE t1 ( t1field integer, primary key (t1field)); +CREATE TABLE t2 ( t2field integer, primary key (t2field)); +CREATE VIEW v1 AS +SELECT t1field as v1field +FROM t1 A +WHERE A.t1field IN (SELECT t1field FROM t2 ); +CREATE VIEW v2 AS +SELECT t2field as v2field +FROM t2 A +WHERE A.t2field IN (SELECT t2field FROM t2 ); +CREATE PROCEDURE p1 () +BEGIN +SELECT v1field +FROM v1 +WHERE v1field IN ( SELECT v2field as vf_inner FROM v2 ); +END| +INSERT INTO t1 VALUES (1),(2),(3); +INSERT INTO t2 VALUES (2),(3),(4); +CALL p1; +v1field +2 +3 +CALL p1; +v1field +2 +3 +DROP TABLE t1,t2; +DROP VIEW v1,v2; +DROP PROCEDURE p1; +# End of BUG#48834 +# +# Bug#46692 "Crash occurring on queries with nested FROM subqueries +# using materialization." +# +CREATE TABLE t1 ( +pk INTEGER PRIMARY KEY, +int_key INTEGER, +KEY int_key(int_key) +); +INSERT INTO t1 VALUES (10,186),(11,NULL),(12,2),(13,3),(14,0),(15,133),(16,1); +CREATE TABLE t2 ( +pk INTEGER PRIMARY KEY, +int_key INTEGER, +KEY int_key(int_key) +); +INSERT INTO t2 VALUES (1,7),(2,2); +SELECT * FROM t1 WHERE (140, 4) IN +(SELECT t2.int_key, t2 .pk FROM t2 STRAIGHT_JOIN t1 ON t2.int_key); +pk int_key +DROP TABLE t1, t2; +# +# Bug#42353 "SELECT ... WHERE oe IN (SELECT w/ LEFT JOIN) query +# causes crash." +# +CREATE TABLE t1 ( +pk INTEGER PRIMARY KEY, +int_nokey INTEGER, +int_key INTEGER, +date_key DATE, +datetime_nokey DATETIME, +varchar_nokey VARCHAR(1) +); +CREATE TABLE t2 ( +date_nokey DATE +); +CREATE TABLE t3 ( +pk INTEGER PRIMARY KEY, +int_nokey INTEGER, +date_key date, +varchar_key VARCHAR(1), +varchar_nokey VARCHAR(1), +KEY date_key (date_key) +); +SELECT date_key FROM t1 +WHERE (int_key, int_nokey) +IN (SELECT t3.int_nokey, t3.pk +FROM t2 LEFT JOIN t3 ON (t2.date_nokey < t3.date_key) +WHERE t3.varchar_key <= t3.varchar_nokey OR t3.int_nokey <= t3.pk +) +AND (varchar_nokey <> 'f' OR NOT int_key < 7); +date_key +# +# Bug#45933 "Crash in optimize_semijoin_nests on JOIN in subquery +# + AND in outer query". +# +INSERT INTO t1 VALUES (10,7,5,'2009-06-16','2002-04-10 14:25:30','w'), +(11,7,0,'0000-00-00','0000-00-00 00:00:00','s'), +(12,4,0,'2003-07-14','2006-09-14 04:01:02','y'), +(13,0,4,'2002-07-25','0000-00-00 00:00:00','c'), +(14,1,8,'2007-07-03','0000-00-00 00:00:00','q'), +(15,6,5,'2001-11-12','0000-00-00 00:00:00',''), +(16,2,9,'0000-00-00','0000-00-00 00:00:00','j'), +(29,9,1,'0000-00-00','2003-08-11 00:00:00','m'); +Warnings: +Warning 1264 Out of range value for column 'date_key' at row 2 +Warning 1264 Out of range value for column 'datetime_nokey' at row 2 +Warning 1264 Out of range value for column 'datetime_nokey' at row 4 +Warning 1264 Out of range value for column 'datetime_nokey' at row 5 +Warning 1264 Out of range value for column 'datetime_nokey' at row 6 +Warning 1264 Out of range value for column 'date_key' at row 7 +Warning 1264 Out of range value for column 'datetime_nokey' at row 7 +Warning 1264 Out of range value for column 'date_key' at row 8 +INSERT IGNORE INTO t3 VALUES (1,9,'0000-00-00','b','b'), +(2,2,'2002-09-17','h','h'); +Warnings: +Warning 1264 Out of range value for column 'date_key' at row 1 +SELECT t1.varchar_nokey FROM t1 JOIN t3 ON t1.datetime_nokey +WHERE t1.varchar_nokey +IN (SELECT varchar_nokey FROM t1 +WHERE (pk) +IN (SELECT t3.int_nokey +FROM t3 LEFT JOIN t1 ON t1.varchar_nokey +WHERE t3.date_key BETWEEN '2008-06-07' AND '2006-06-26' + ) +); +varchar_nokey +DROP TABLE t1, t2, t3; +# +# Bug#45219 "Crash on SELECT DISTINCT query containing a +# LEFT JOIN in subquery" +# +CREATE TABLE t1 ( +pk INTEGER NOT NULL, +int_nokey INTEGER NOT NULL, +datetime_key DATETIME NOT NULL, +varchar_key VARCHAR(1) NOT NULL, +PRIMARY KEY (pk), +KEY datetime_key (datetime_key), +KEY varchar_key (varchar_key) +); +INSERT IGNORE INTO t1 VALUES +(1,9,'0000-00-00 00:00:00','p'),(2,0,'2002-02-09 07:38:13','v'), +(3,8,'2001-05-03 12:08:14','t'),(4,3,'0000-00-00 00:00:00','u'), +(5,7,'2009-07-28 03:43:30','n'),(6,0,'2009-08-04 00:00:00','l'), +(7,1,'0000-00-00 00:00:00','h'),(8,9,'0000-00-00 00:00:00','u'), +(9,0,'2005-08-02 17:16:54','n'),(10,9,'2002-12-21 00:00:00','j'), +(11,0,'2005-08-15 12:37:35','k'),(12,5,'0000-00-00 00:00:00','e'), +(13,0,'2006-03-10 00:00:00','i'),(14,8,'2005-05-16 11:02:36','u'), +(15,8,'2008-11-02 00:00:00','n'),(16,5,'2006-03-15 00:00:00','b'), +(17,1,'0000-00-00 00:00:00','x'),(18,7,'0000-00-00 00:00:00',''), +(19,0,'2008-12-17 20:15:40','q'),(20,9,'0000-00-00 00:00:00','u'); +Warnings: +Warning 1264 Out of range value for column 'datetime_key' at row 1 +Warning 1264 Out of range value for column 'datetime_key' at row 4 +Warning 1264 Out of range value for column 'datetime_key' at row 7 +Warning 1264 Out of range value for column 'datetime_key' at row 8 +Warning 1264 Out of range value for column 'datetime_key' at row 12 +Warning 1264 Out of range value for column 'datetime_key' at row 17 +Warning 1264 Out of range value for column 'datetime_key' at row 18 +Warning 1264 Out of range value for column 'datetime_key' at row 20 +CREATE TABLE t2 LIKE t1; +INSERT INTO t2 VALUES +(10,0,'2006-07-07 07:26:28','q'),(11,5,'2002-09-23 00:00:00','m'), +(12,7,'0000-00-00 00:00:00','j'),(13,1,'2006-06-07 00:00:00','z'), +(14,8,'2000-09-16 12:15:34','a'),(15,2,'2007-08-05 15:47:52',''), +(16,1,'0000-00-00 00:00:00','e'),(17,8,'2005-12-02 19:34:26','t'), +(18,5,'0000-00-00 00:00:00','q'),(19,4,'0000-00-00 00:00:00','b'), +(20,5,'2007-12-28 00:00:00','w'),(21,3,'2004-08-02 11:48:43','m'), +(22,0,'0000-00-00 00:00:00','x'),(23,8,'2004-04-19 12:18:43',''), +(24,0,'2009-04-27 00:00:00','w'),(25,4,'2006-10-20 14:52:15','x'), +(26,0,'0000-00-00 00:00:00','e'),(27,0,'2002-03-22 11:48:37','e'), +(28,2,'0000-00-00 00:00:00','p'),(29,0,'2001-01-04 03:55:07','x'); +Warnings: +Warning 1264 Out of range value for column 'datetime_key' at row 3 +Warning 1264 Out of range value for column 'datetime_key' at row 7 +Warning 1264 Out of range value for column 'datetime_key' at row 9 +Warning 1264 Out of range value for column 'datetime_key' at row 10 +Warning 1264 Out of range value for column 'datetime_key' at row 13 +Warning 1264 Out of range value for column 'datetime_key' at row 17 +Warning 1264 Out of range value for column 'datetime_key' at row 19 +CREATE TABLE t3 LIKE t1; +INSERT INTO t3 VALUES +(10,8,'2007-08-19 08:08:38','i'),(11,0,'2000-05-21 03:51:51',''); +SELECT DISTINCT datetime_key FROM t1 +WHERE (int_nokey, pk) +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#46550 Azalea returning duplicate results for some IN subqueries +# w/ semijoin=on +# +DROP TABLE IF EXISTS t0, t1, t2; +CREATE TABLE t0 ( +int_key int(11) DEFAULT NULL, +varchar_key varchar(1) DEFAULT NULL, +varchar_nokey varchar(1) DEFAULT NULL, +KEY int_key (int_key), +KEY varchar_key (varchar_key,int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t0 VALUES +(1,'m','m'), +(40,'h','h'), +(1,'r','r'), +(1,'h','h'), +(9,'x','x'), +(NULL,'q','q'), +(NULL,'k','k'), +(7,'l','l'), +(182,'k','k'), +(202,'a','a'), +(7,'x','x'), +(6,'j','j'), +(119,'z','z'), +(4,'d','d'), +(5,'h','h'), +(1,'u','u'), +(3,'q','q'), +(7,'a','a'), +(3,'e','e'), +(6,'l','l'); +CREATE TABLE t1 ( +int_key int(11) DEFAULT NULL, +varchar_key varchar(1) DEFAULT NULL, +varchar_nokey varchar(1) DEFAULT NULL, +KEY int_key (int_key), +KEY varchar_key (varchar_key,int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (7,NULL,NULL),(4,'x','x'); +CREATE TABLE t2 ( +int_key int(11) DEFAULT NULL, +varchar_key varchar(1) DEFAULT NULL, +varchar_nokey varchar(1) DEFAULT NULL, +KEY int_key (int_key), +KEY varchar_key (varchar_key,int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (123,NULL,NULL); +SELECT int_key +FROM t0 +WHERE varchar_nokey IN ( +SELECT t1 .varchar_key from t1 +); +int_key +7 +9 +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 +7 +9 +EXPLAIN +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 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 20 100.00 Using where +1 SIMPLE t1_1 NULL ref varchar_key varchar_key 7 test.t0.varchar_nokey 2 50.00 Using where; Using index +1 SIMPLE t1_2 NULL index NULL int_key 5 NULL 2 100.00 Using index; FirstMatch(t0) +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`int_key` AS `int_key` from `test`.`t0` semi join (`test`.`t1` `t1_1` join `test`.`t1` `t1_2`) where ((`test`.`t1_1`.`varchar_key` = `test`.`t0`.`varchar_nokey`) and (0 <> `test`.`t1_1`.`int_key`)) +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 +7 +9 +EXPLAIN +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 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 20 100.00 Using where +1 SIMPLE t1_1 NULL ref varchar_key varchar_key 7 test.t0.varchar_nokey 2 50.00 Using where; Using index +1 SIMPLE t1_2 NULL index NULL int_key 5 NULL 2 100.00 Using index; FirstMatch(t0) +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`int_key` AS `int_key` from `test`.`t0` semi join (`test`.`t1` `t1_1` join `test`.`t1` `t1_2`) where ((`test`.`t1_1`.`varchar_key` = `test`.`t0`.`varchar_nokey`) and (0 <> `test`.`t1_1`.`int_key`)) +DROP TABLE t0, t1, t2; +# End of bug#46550 + +Bug #48073 Subquery on char columns from view crashes Mysql + +DROP TABLE IF EXISTS t1, t2; +DROP VIEW IF EXISTS v1; +CREATE TABLE t1 ( +city VARCHAR(50) NOT NULL, +country_id SMALLINT UNSIGNED NOT NULL +); +INSERT INTO t1 VALUES +('Batna',2), +('Bchar',2), +('Skikda',2), +('Tafuna',3), +('Algeria',2) ; +CREATE TABLE t2 ( +country_id SMALLINT UNSIGNED NOT NULL, +country VARCHAR(50) NOT NULL +); +INSERT INTO t2 VALUES +(2,'Algeria'), +(3,'American Samoa') ; +CREATE VIEW v1 AS +SELECT country_id, country +FROM t2 +WHERE LEFT(country,1) = "A" +; +SELECT city, country_id +FROM t1 +WHERE city IN ( +SELECT country +FROM t2 +WHERE LEFT(country, 1) = "A" +); +city country_id +Algeria 2 +SELECT city, country_id +FROM t1 +WHERE city IN ( +SELECT country +FROM v1 +); +city country_id +Algeria 2 +drop table t1, t2; +drop view v1; +# End of bug#48073 + +Bug#49097 subquery with view generates wrong result with +non-prepared statement + +DROP TABLE IF EXISTS t1, t2; +DROP VIEW IF EXISTS v1; +CREATE TABLE t1 ( +city VARCHAR(50) NOT NULL, +country_id SMALLINT UNSIGNED NOT NULL +); +INSERT INTO t1 VALUES +('Batna',2), +('Bchar',2), +('Skikda',2), +('Tafuna',3), +('Algeria',2) ; +CREATE TABLE t2 ( +country_id SMALLINT UNSIGNED NOT NULL, +country VARCHAR(50) NOT NULL +); +INSERT INTO t2 VALUES +(2,'Algeria'), +(3,'XAmerican Samoa') ; +CREATE VIEW v1 AS +SELECT country_id, country +FROM t2 +WHERE LEFT(country,1) = "A" +; +SELECT city, country_id +FROM t1 +WHERE country_id IN ( +SELECT country_id +FROM t2 +WHERE LEFT(country,1) = "A" +); +city country_id +Algeria 2 +Batna 2 +Bchar 2 +Skikda 2 +SELECT city, country_id +FROM t1 +WHERE country_id IN ( +SELECT country_id +FROM v1 +); +city country_id +Algeria 2 +Batna 2 +Bchar 2 +Skikda 2 +PREPARE stmt FROM +" +SELECT city, country_id +FROM t1 +WHERE country_id IN ( + SELECT country_id + FROM v1 +); +"; +execute stmt; +city country_id +Algeria 2 +Batna 2 +Bchar 2 +Skikda 2 +deallocate prepare stmt; +drop table t1, t2; +drop view v1; +# End of Bug#49097 +# +# Bug#49198 Wrong result for second call of procedure +# with view in subselect. +# +CREATE TABLE t1 (t1field integer, primary key (t1field)); +CREATE TABLE t2 (t2field integer, primary key (t2field)); +CREATE TABLE t3 (t3field integer, primary key (t3field)); +CREATE VIEW v2 AS SELECT * FROM t2; +CREATE VIEW v3 AS SELECT * FROM t3; +INSERT INTO t1 VALUES(1),(2); +INSERT INTO t2 VALUES(1),(2); +INSERT INTO t3 VALUES(1),(2); +PREPARE stmt FROM +" +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT * FROM v2); +"; +EXECUTE stmt; +t1field +1 +2 + +EXECUTE stmt; +t1field +1 +2 +PREPARE stmt FROM +" +EXPLAIN +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT * FROM v2) + AND t1field IN (SELECT * FROM v3) +"; +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index PRIMARY PRIMARY 4 NULL 2 100.00 Using index +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +1 SIMPLE t3 NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`t1field` AS `t1field` from `test`.`t2` join `test`.`t3` join `test`.`t1` where ((`test`.`t2`.`t2field` = `test`.`t1`.`t1field`) and (`test`.`t3`.`t3field` = `test`.`t1`.`t1field`)) + +This line is only in place to help --skip_if_hypergraph diffing some more. + +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index PRIMARY PRIMARY 4 NULL 2 100.00 Using index +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +1 SIMPLE t3 NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`t1field` AS `t1field` from `test`.`t2` join `test`.`t3` join `test`.`t1` where ((`test`.`t2`.`t2field` = `test`.`t1`.`t1field`) and (`test`.`t3`.`t3field` = `test`.`t1`.`t1field`)) +DROP TABLE t1, t2, t3; +DROP VIEW v2, v3; +# End of Bug#49198 +# +# Bug#48623 Multiple subqueries are optimized incorrectly +# +CREATE TABLE ot(val VARCHAR(10)) charset utf8mb4; +CREATE TABLE it1(val VARCHAR(10)) charset utf8mb4; +CREATE TABLE it2(val VARCHAR(10)) charset utf8mb4; +INSERT INTO ot VALUES('aaa'), ('bbb'), ('eee'), ('mmm'), ('ppp'); +INSERT INTO it1 VALUES('aaa'), ('aaa'), ('bbb'), ('eee'), ('mmm'), ('ppp'); +INSERT INTO it2 VALUES('aaa'), ('bbb'), ('eee'), ('mmm'), ('ppp'); +EXPLAIN +SELECT * +FROM ot +WHERE ot.val IN (SELECT it1.val FROM it1 +WHERE it1.val LIKE 'a%' OR it1.val LIKE 'e%') +AND ot.val IN (SELECT it2.val FROM it2 +WHERE it2.val LIKE 'a%' OR it2.val LIKE 'e%'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 5 100.00 NULL +1 SIMPLE it2 NULL ALL NULL NULL NULL NULL 5 20.00 Using where; FirstMatch(ot); Using join buffer (hash join) +1 SIMPLE it1 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; FirstMatch(it2); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot`.`val` AS `val` from `test`.`ot` semi join (`test`.`it1`) semi join (`test`.`it2`) where ((`test`.`it2`.`val` = `test`.`ot`.`val`) and (`test`.`it1`.`val` = `test`.`ot`.`val`) and ((`test`.`it1`.`val` like 'a%') or (`test`.`it1`.`val` like 'e%')) and ((`test`.`it2`.`val` like 'a%') or (`test`.`it2`.`val` like 'e%'))) +SELECT * +FROM ot +WHERE ot.val IN (SELECT it1.val FROM it1 +WHERE it1.val LIKE 'a%' OR it1.val LIKE 'e%') +AND ot.val IN (SELECT it2.val FROM it2 +WHERE it2.val LIKE 'a%' OR it2.val LIKE 'e%'); +val +aaa +eee +DROP TABLE ot; +DROP TABLE it1; +DROP TABLE it2; +# End of Bug#48623 +# +# Bug #51487 Assertion failure when semi-join flattening occurs +# for a subquery in HAVING +# +CREATE TABLE t1 (a INT, b INT); +INSERT INTO t1 VALUES (1,10),(2,11),(1,13); +CREATE TABLE t2 AS SELECT * FROM t1; +CREATE TABLE t3 AS SELECT * FROM t1; +SELECT COUNT(*) FROM t1 +GROUP BY t1.a +HAVING t1.a IN (SELECT t3.a FROM t3 +WHERE t3.b IN (SELECT b FROM t2 WHERE t2.a=t1.a)); +COUNT(*) +2 +1 +DROP TABLE t1, t2, t3; +# End of Bug#51487 +# +# BUG#38075: Wrong result: rows matching a subquery with outer join not returned +# +DROP TABLE IF EXISTS ot1, it1, it2; +CREATE TABLE it2 ( +int_key int(11) NOT NULL, +datetime_key datetime NOT NULL, +KEY int_key (int_key), +KEY datetime_key (datetime_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO it2 VALUES +(5,'2002-04-10 14:25:30'), (0,'0000-00-00 00:00:00'), +(0,'2006-09-14 04:01:02'), (4,'0000-00-00 00:00:00'), +(8,'0000-00-00 00:00:00'), (5,'0000-00-00 00:00:00'), +(9,'0000-00-00 00:00:00'), (8,'2007-04-01 11:04:17'), +(1,'0000-00-00 00:00:00'), (7,'2009-01-12 00:00:00'), +(0,'2009-06-05 00:00:00'), (3,'2006-02-14 18:06:35'), +(5,'2006-02-21 07:08:16'), (0,'0000-00-00 00:00:00'), +(7,'0000-00-00 00:00:00'), (0,'0000-00-00 00:00:00'), +(0,'2007-02-13 00:00:00'), (1,'0000-00-00 00:00:00'), +(0,'0000-00-00 00:00:00'), (1,'2003-08-11 00:00:00'); +Warnings: +Warning 1264 Out of range value for column 'datetime_key' at row 2 +Warning 1264 Out of range value for column 'datetime_key' at row 4 +Warning 1264 Out of range value for column 'datetime_key' at row 5 +Warning 1264 Out of range value for column 'datetime_key' at row 6 +Warning 1264 Out of range value for column 'datetime_key' at row 7 +Warning 1264 Out of range value for column 'datetime_key' at row 9 +Warning 1264 Out of range value for column 'datetime_key' at row 14 +Warning 1264 Out of range value for column 'datetime_key' at row 15 +Warning 1264 Out of range value for column 'datetime_key' at row 16 +Warning 1264 Out of range value for column 'datetime_key' at row 18 +Warning 1264 Out of range value for column 'datetime_key' at row 19 +CREATE TABLE ot1 ( +int_nokey int(11) NOT NULL, +int_key int(11) NOT NULL, +KEY int_key (int_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO ot1 VALUES +(5,0), (3,0), (0,2), (3,0), (1,3), (0,0), (1,7), (7,0), (1,7), (0,7), +(0,9), (8,2), (4,4), (9,3), (0,9), (2,5), (0,5), (8,0), (5,8), (1,5); +CREATE TABLE it1 ( +int_nokey int(11) NOT NULL, +int_key int(11) NOT NULL, +KEY int_key (int_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO it1 VALUES +(9,5), (0,4); +SELECT int_key FROM ot1 +WHERE int_nokey IN (SELECT it2.int_key +FROM it1 LEFT JOIN it2 ON it2.datetime_key); +int_key +0 +0 +0 +0 +0 +0 +2 +2 +3 +5 +5 +7 +7 +7 +8 +9 +9 +EXPLAIN +SELECT int_key FROM ot1 +WHERE int_nokey IN (SELECT it2.int_key +FROM it1 LEFT JOIN it2 ON it2.datetime_key); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 20 100.00 NULL +1 SIMPLE it1 NULL index NULL int_key 4 NULL 2 100.00 Using index +1 SIMPLE it2 NULL ref int_key int_key 4 test.ot1.int_nokey 2 90.00 Using where; FirstMatch(ot1) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`int_key` AS `int_key` from `test`.`ot1` semi join (`test`.`it1` join `test`.`it2`) where ((`test`.`it2`.`int_key` = `test`.`ot1`.`int_nokey`) and (TIMESTAMP'0000-00-00 00:00:00' <> `test`.`it2`.`datetime_key`)) +DROP TABLE ot1, it1, it2; +# End of BUG#38075 +# +# BUG#50089: Second call of procedure with view in subselect crashes server +# +CREATE TABLE t1(t1field INTEGER, PRIMARY KEY(t1field)); +CREATE VIEW v1 AS +SELECT t1field AS v1field +FROM t1 a +WHERE a.t1field IN (SELECT t1field FROM t1); +INSERT INTO t1 VALUES(1),(2); +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT v1field FROM v1); +t1field +1 +2 +EXPLAIN +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT v1field FROM v1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index PRIMARY PRIMARY 4 NULL 2 100.00 Using index +1 SIMPLE a NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `t1`.`t1field` AS `t1field` from `test`.`t1` `a` join `test`.`t1` join `test`.`t1` where ((`test`.`a`.`t1field` = `t1`.`t1field`) and (`test`.`t1`.`t1field` = `t1`.`t1field`)) +SELECT t1.t1field +FROM t1 LEFT JOIN t1 AS t2 ON t1.t1field IN (SELECT v1field FROM v1); +t1field +1 +1 +2 +2 +EXPLAIN +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT v1field FROM v1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index PRIMARY PRIMARY 4 NULL 2 100.00 Using index +1 SIMPLE a NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `t1`.`t1field` AS `t1field` from `test`.`t1` `a` join `test`.`t1` join `test`.`t1` where ((`test`.`a`.`t1field` = `t1`.`t1field`) and (`test`.`t1`.`t1field` = `t1`.`t1field`)) +CREATE PROCEDURE p1() +BEGIN +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT v1field FROM v1); +END| +CALL p1; +t1field +1 +2 +CALL p1; +t1field +1 +2 +PREPARE stmt FROM +" +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT v1field FROM v1); +"; +EXECUTE stmt; +t1field +1 +2 + +EXECUTE stmt; +t1field +1 +2 +DROP PROCEDURE p1; +DROP VIEW v1; +DROP TABLE t1; +# End of BUG#50089 +# +# Bug#45191: Incorrectly initialized semi-join led to a wrong result. +# +CREATE TABLE staff (EMPNUM CHAR(3) NOT NULL, +EMPNAME CHAR(20), GRADE DECIMAL(4), CITY CHAR(15)) charset latin1; +CREATE TABLE proj (PNUM CHAR(3) NOT NULL, +PNAME CHAR(20), PTYPE CHAR(6), +BUDGET DECIMAL(9), +CITY CHAR(15)) charset latin1; +CREATE TABLE works (EMPNUM CHAR(3) NOT NULL, +PNUM CHAR(3) NOT NULL, HOURS DECIMAL(5)) charset latin1; +INSERT INTO staff VALUES ('E1','Alice',12,'Deale'); +INSERT INTO staff VALUES ('E2','Betty',10,'Vienna'); +INSERT INTO staff VALUES ('E3','Carmen',13,'Vienna'); +INSERT INTO staff VALUES ('E4','Don',12,'Deale'); +INSERT INTO staff VALUES ('E5','Ed',13,'Akron'); +INSERT INTO proj VALUES ('P1','MXSS','Design',10000,'Deale'); +INSERT INTO proj VALUES ('P2','CALM','Code',30000,'Vienna'); +INSERT INTO proj VALUES ('P3','SDP','Test',30000,'Tampa'); +INSERT INTO proj VALUES ('P4','SDP','Design',20000,'Deale'); +INSERT INTO proj VALUES ('P5','IRM','Test',10000,'Vienna'); +INSERT INTO proj VALUES ('P6','PAYR','Design',50000,'Deale'); +INSERT INTO works VALUES ('E1','P1',40); +INSERT INTO works VALUES ('E1','P2',20); +INSERT INTO works VALUES ('E1','P3',80); +INSERT INTO works VALUES ('E1','P4',20); +INSERT INTO works VALUES ('E1','P5',12); +INSERT INTO works VALUES ('E1','P6',12); +INSERT INTO works VALUES ('E2','P1',40); +INSERT INTO works VALUES ('E2','P2',80); +INSERT INTO works VALUES ('E3','P2',20); +INSERT INTO works VALUES ('E4','P2',20); +INSERT INTO works VALUES ('E4','P4',40); +INSERT INTO works VALUES ('E4','P5',80); +explain SELECT EMPNUM, EMPNAME +FROM staff +WHERE EMPNUM IN +(SELECT EMPNUM FROM works +WHERE PNUM IN +(SELECT PNUM FROM proj)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE staff NULL ALL NULL NULL NULL NULL 5 100.00 NULL +1 SIMPLE works NULL ALL NULL NULL NULL NULL 12 10.00 Using where +1 SIMPLE proj NULL ALL NULL NULL NULL NULL 6 16.67 Using where; FirstMatch(staff) +Warnings: +Note 1003 /* select#1 */ select `test`.`staff`.`EMPNUM` AS `EMPNUM`,`test`.`staff`.`EMPNAME` AS `EMPNAME` from `test`.`staff` semi join (`test`.`works` join `test`.`proj`) where ((`test`.`works`.`EMPNUM` = `test`.`staff`.`EMPNUM`) and (`test`.`proj`.`PNUM` = `test`.`works`.`PNUM`)) +SELECT EMPNUM, EMPNAME +FROM staff +WHERE EMPNUM IN +(SELECT EMPNUM FROM works +WHERE PNUM IN +(SELECT PNUM FROM proj)); +EMPNUM EMPNAME +E1 Alice +E2 Betty +E3 Carmen +E4 Don +drop table staff,works,proj; +# End of bug#45191 +# +# BUG#36896: Server crash on SELECT FROM DUAL +# +create table t1 (a int); +select 1 as res from dual where (1) in (select * from t1); +res +drop table t1; + +BUG#40118 Crash when running Batched Key Access and requiring one match for each key + +create table t0(a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (a int, key(a)); +insert into t1 select * from t0; +alter table t1 add b int not null, add filler char(200); +insert into t1 select * from t1; +insert into t1 select * from t1; +select * from t0 where t0.a in (select t1.a from t1 where t1.b=0); +a +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +drop table t0, t1; +# +# BUG#32665 Query with dependent subquery is too slow +# +create table t1 ( +idIndividual int primary key +); +insert into t1 values (1),(2); +create table t2 ( +idContact int primary key, +contactType int, +idObj int +); +insert into t2 values (1,1,1),(2,2,2),(3,3,3); +create table t3 ( +idAddress int primary key, +idContact int, +postalStripped varchar(100) +); +insert into t3 values (1,1, 'foo'), (2,2,'bar'); +The following must be converted to a semi-join: +explain SELECT a.idIndividual FROM t1 a +WHERE a.idIndividual IN +( SELECT c.idObj FROM t3 cona +INNER JOIN t2 c ON c.idContact=cona.idContact +WHERE cona.postalStripped='T2H3B2' + ); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE a NULL index PRIMARY PRIMARY 4 NULL 2 100.00 Using index +1 SIMPLE cona NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE c NULL eq_ref PRIMARY PRIMARY 4 test.cona.idContact 1 33.33 Using where; FirstMatch(a) +Warnings: +Note 1003 /* select#1 */ select `test`.`a`.`idIndividual` AS `idIndividual` from `test`.`t1` `a` semi join (`test`.`t3` `cona` join `test`.`t2` `c`) where ((`test`.`c`.`idContact` = `test`.`cona`.`idContact`) and (`test`.`c`.`idObj` = `test`.`a`.`idIndividual`) and (`test`.`cona`.`postalStripped` = 'T2H3B2')) +drop table t1,t2,t3; +CREATE TABLE t1 (one int, two int, flag char(1)); +CREATE TABLE t2 (one int, two int, flag char(1)); +INSERT INTO t1 VALUES(1,2,'Y'),(2,3,'Y'),(3,4,'Y'),(5,6,'N'),(7,8,'N'); +INSERT INTO t2 VALUES(1,2,'Y'),(2,3,'Y'),(3,4,'Y'),(5,6,'N'),(7,8,'N'); +SELECT * FROM t1 +WHERE ROW(one,two) IN (SELECT DISTINCT one,two FROM t2 WHERE flag = 'N'); +one two flag +5 6 N +7 8 N +SELECT * FROM t1 +WHERE ROW(one,two) IN (SELECT DISTINCT one,two FROM t1 WHERE flag = 'N'); +one two flag +5 6 N +7 8 N +insert into t2 values (null,null,'N'); +insert into t2 values (null,3,'0'); +insert into t2 values (null,5,'0'); +insert into t2 values (10,null,'0'); +insert into t1 values (10,3,'0'); +insert into t1 values (10,5,'0'); +insert into t1 values (10,10,'0'); +SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = 'N') as 'test' from t1; +one two test +1 2 NULL +2 3 NULL +3 4 NULL +5 6 1 +7 8 1 +10 3 NULL +10 5 NULL +10 10 NULL +SELECT one,two from t1 where ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = 'N'); +one two +5 6 +7 8 +SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = 'N' group by one,two) as 'test' from t1; +one two test +1 2 NULL +2 3 NULL +3 4 NULL +5 6 1 +7 8 1 +10 3 NULL +10 5 NULL +10 10 NULL +SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = '0') as 'test' from t1; +one two test +1 2 0 +2 3 NULL +3 4 0 +5 6 0 +7 8 0 +10 3 NULL +10 5 NULL +10 10 NULL +SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = '0' group by one,two) as 'test' from t1; +one two test +1 2 0 +2 3 NULL +3 4 0 +5 6 0 +7 8 0 +10 3 NULL +10 5 NULL +10 10 NULL +explain SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = '0') as 'test' from t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 9 11.11 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`one` AS `one`,`test`.`t1`.`two` AS `two`,((`test`.`t1`.`one`,`test`.`t1`.`two`),(/* select#2 */ select `test`.`t2`.`one`,`test`.`t2`.`two` from `test`.`t2` where ((`test`.`t2`.`flag` = '0') and (outer_field_is_not_null, (((`test`.`t1`.`one`) = `test`.`t2`.`one`) or (`test`.`t2`.`one` is null)), true) and (outer_field_is_not_null, (((`test`.`t1`.`two`) = `test`.`t2`.`two`) or (`test`.`t2`.`two` is null)), true)) having ((outer_field_is_not_null, (`test`.`t2`.`one`), true) and (outer_field_is_not_null, (`test`.`t2`.`two`), true)))) AS `test` from `test`.`t1` +explain SELECT one,two from t1 where ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = 'N'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 9 11.11 Using where; FirstMatch(t1); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`one` AS `one`,`test`.`t1`.`two` AS `two` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`two` = `test`.`t1`.`two`) and (`test`.`t2`.`one` = `test`.`t1`.`one`) and (`test`.`t2`.`flag` = 'N')) +explain SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = '0' group by one,two) as 'test' from t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 9 11.11 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`one` AS `one`,`test`.`t1`.`two` AS `two`,((`test`.`t1`.`one`,`test`.`t1`.`two`),(/* select#2 */ select `test`.`t2`.`one`,`test`.`t2`.`two` from `test`.`t2` where ((`test`.`t2`.`flag` = '0') and (outer_field_is_not_null, (((`test`.`t1`.`one`) = `test`.`t2`.`one`) or (`test`.`t2`.`one` is null)), true) and (outer_field_is_not_null, (((`test`.`t1`.`two`) = `test`.`t2`.`two`) or (`test`.`t2`.`two` is null)), true)) having ((outer_field_is_not_null, (`test`.`t2`.`one`), true) and (outer_field_is_not_null, (`test`.`t2`.`two`), true)))) AS `test` from `test`.`t1` +DROP TABLE t1,t2; +CREATE TABLE t1 (a char(5), b char(5)); +INSERT INTO t1 VALUES (NULL,'aaa'), ('aaa','aaa'); +SELECT * FROM t1 WHERE (a,b) IN (('aaa','aaa'), ('aaa','bbb')); +a b +aaa aaa +DROP TABLE t1; +CREATE TABLE t1 (a CHAR(1), b VARCHAR(10)) charset utf8mb4; +INSERT INTO t1 VALUES ('a', 'aa'); +INSERT INTO t1 VALUES ('a', 'aaa'); +SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1); +a b +CREATE INDEX I1 ON t1 (a); +CREATE INDEX I2 ON t1 (b); +EXPLAIN SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL I2 NULL NULL NULL 2 100.00 NULL +1 SIMPLE t1 NULL index I1 I1 5 NULL 2 50.00 Using where; Using index; FirstMatch(t1); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t1`) where (`test`.`t1`.`b` = `test`.`t1`.`a`) +SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1); +a b +CREATE TABLE t2 (a VARCHAR(1), b VARCHAR(10)) charset utf8mb4; +INSERT INTO t2 SELECT * FROM t1; +CREATE INDEX I1 ON t2 (a); +CREATE INDEX I2 ON t2 (b); +EXPLAIN SELECT a,b FROM t2 WHERE b IN (SELECT a FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL I2 NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL index I1 I1 7 NULL 2 50.00 Using where; Using index; FirstMatch(t2); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t2` semi join (`test`.`t2`) where (`test`.`t2`.`b` = `test`.`t2`.`a`) +SELECT a,b FROM t2 WHERE b IN (SELECT a FROM t2); +a b +EXPLAIN +SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1 WHERE LENGTH(a)<500); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL I2 NULL NULL NULL 2 100.00 NULL +1 SIMPLE t1 NULL index I1 I1 5 NULL 2 50.00 Using where; Using index; FirstMatch(t1); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t1`) where ((length(`test`.`t1`.`a`) < 500) and (`test`.`t1`.`b` = `test`.`t1`.`a`)) +SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1 WHERE LENGTH(a)<500); +a b +DROP TABLE t1,t2; +# +# BUG#45928 "Differing query results depending on MRR and +# engine_condition_pushdown settings" +# +CREATE TABLE `t1` ( +`pk` int(11) NOT NULL AUTO_INCREMENT, +`time_nokey` time NOT NULL, +`varchar_key` varchar(1) NOT NULL, +`varchar_nokey` varchar(1) NOT NULL, +PRIMARY KEY (`pk`), +KEY `varchar_key` (`varchar_key`) +) AUTO_INCREMENT=12 DEFAULT CHARSET=latin1; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO `t1` VALUES (10,'00:00:00','i','i'),(11,'00:00:00','',''); +SELECT `time_nokey` G1 FROM t1 WHERE ( `varchar_nokey` , `varchar_key` ) IN ( +SELECT `varchar_nokey` , `varchar_nokey` ) AND `varchar_key` >= 'c' HAVING G1 ORDER +BY `pk` ; +G1 +DROP TABLE t1; +# +# BUG#45863 "Assertion failed: (fixed == 0), function fix_fields(), +# file item.cc, line 4448" +# +DROP TABLE IF EXISTS C, BB; +CREATE TABLE C ( +varchar_nokey varchar(1) NOT NULL +); +INSERT INTO C VALUES +('k'),('a'),(''),('u'),('e'),('v'),('i'), +('t'),('u'),('f'),('u'),('m'),('j'),('f'), +('v'),('j'),('g'),('e'),('h'),('z'); +CREATE TABLE BB ( +varchar_nokey varchar(1) NOT NULL +); +INSERT INTO BB VALUES ('i'),('t'); +SELECT varchar_nokey FROM C +WHERE (varchar_nokey, OUTR) IN (SELECT varchar_nokey +FROM BB); +ERROR 42S22: Unknown column 'OUTR' in 'IN/ALL/ANY subquery' +SELECT varchar_nokey FROM C +WHERE (varchar_nokey, OUTR) IN (SELECT varchar_nokey, varchar_nokey +FROM BB); +ERROR 42S22: Unknown column 'OUTR' in 'IN/ALL/ANY subquery' +DROP TABLE C,BB; +# +# During work with BUG#45863 I had problems with a query that was +# optimized differently in regular and prepared mode. +# Because there was a bug in one of the selected strategies, I became +# aware of the problem. Adding an EXPLAIN query to catch this. +DROP TABLE IF EXISTS t1, t2, t3; +CREATE TABLE t1 +(EMPNUM CHAR(3) NOT NULL, +EMPNAME CHAR(20), +GRADE DECIMAL(4), +CITY CHAR(15)) charset latin1; +CREATE TABLE t2 +(PNUM CHAR(3) NOT NULL, +PNAME CHAR(20), +PTYPE CHAR(6), +BUDGET DECIMAL(9), +CITY CHAR(15)) charset latin1; +CREATE TABLE t3 +(EMPNUM CHAR(3) NOT NULL, +PNUM CHAR(3) NOT NULL, +HOURS DECIMAL(5)) charset latin1; +INSERT INTO t1 VALUES ('E1','Alice',12,'Deale'); +INSERT INTO t1 VALUES ('E2','Betty',10,'Vienna'); +INSERT INTO t1 VALUES ('E3','Carmen',13,'Vienna'); +INSERT INTO t1 VALUES ('E4','Don',12,'Deale'); +INSERT INTO t1 VALUES ('E5','Ed',13,'Akron'); +INSERT INTO t2 VALUES ('P1','MXSS','Design',10000,'Deale'); +INSERT INTO t2 VALUES ('P2','CALM','Code',30000,'Vienna'); +INSERT INTO t2 VALUES ('P3','SDP','Test',30000,'Tampa'); +INSERT INTO t2 VALUES ('P4','SDP','Design',20000,'Deale'); +INSERT INTO t2 VALUES ('P5','IRM','Test',10000,'Vienna'); +INSERT INTO t2 VALUES ('P6','PAYR','Design',50000,'Deale'); +INSERT INTO t3 VALUES ('E1','P1',40); +INSERT INTO t3 VALUES ('E1','P2',20); +INSERT INTO t3 VALUES ('E1','P3',80); +INSERT INTO t3 VALUES ('E1','P4',20); +INSERT INTO t3 VALUES ('E1','P5',12); +INSERT INTO t3 VALUES ('E1','P6',12); +INSERT INTO t3 VALUES ('E2','P1',40); +INSERT INTO t3 VALUES ('E2','P2',80); +INSERT INTO t3 VALUES ('E3','P2',20); +INSERT INTO t3 VALUES ('E4','P2',20); +INSERT INTO t3 VALUES ('E4','P4',40); +INSERT INTO t3 VALUES ('E4','P5',80); +CREATE UNIQUE INDEX t1_IDX ON t1(EMPNUM); +EXPLAIN SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN +(SELECT EMPNUM +FROM t3 +WHERE PNUM IN +(SELECT PNUM +FROM t2 +WHERE PTYPE = 'Design')); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL t1_IDX NULL NULL NULL 5 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 12 8.33 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t3`.`EMPNUM` = `test`.`t1`.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) +PREPARE stmt FROM "EXPLAIN SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN + (SELECT EMPNUM + FROM t3 + WHERE PNUM IN + (SELECT PNUM + FROM t2 + WHERE PTYPE = 'Design'))"; +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL t1_IDX NULL NULL NULL 5 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 12 8.33 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t3`.`EMPNUM` = `test`.`t1`.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) + +This line is only in place to help --skip_if_hypergraph diffing some more. + +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL t1_IDX NULL NULL NULL 5 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 12 8.33 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t3`.`EMPNUM` = `test`.`t1`.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) +DEALLOCATE PREPARE stmt; +DROP INDEX t1_IDX ON t1; +CREATE INDEX t1_IDX ON t1(EMPNUM); +EXPLAIN SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN +(SELECT EMPNUM +FROM t3 +WHERE PNUM IN +(SELECT PNUM +FROM t2 +WHERE PTYPE = 'Design')); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL t1_IDX NULL NULL NULL 5 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 12 8.33 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t3`.`EMPNUM` = `test`.`t1`.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) +PREPARE stmt FROM "EXPLAIN SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN + (SELECT EMPNUM + FROM t3 + WHERE PNUM IN + (SELECT PNUM + FROM t2 + WHERE PTYPE = 'Design'))"; +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL t1_IDX NULL NULL NULL 5 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 12 8.33 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t3`.`EMPNUM` = `test`.`t1`.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) + +This line is only in place to help --skip_if_hypergraph diffing some more. + +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL t1_IDX NULL NULL NULL 5 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 12 8.33 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t3`.`EMPNUM` = `test`.`t1`.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) +DEALLOCATE PREPARE stmt; +DROP INDEX t1_IDX ON t1; +EXPLAIN SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN +(SELECT EMPNUM +FROM t3 +WHERE PNUM IN +(SELECT PNUM +FROM t2 +WHERE PTYPE = 'Design')); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 12 8.33 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t3`.`EMPNUM` = `test`.`t1`.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) +PREPARE stmt FROM "EXPLAIN SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN + (SELECT EMPNUM + FROM t3 + WHERE PNUM IN + (SELECT PNUM + FROM t2 + WHERE PTYPE = 'Design'))"; +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 12 8.33 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t3`.`EMPNUM` = `test`.`t1`.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) + +This line is only in place to help --skip_if_hypergraph diffing some more. + +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 12 8.33 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t3`.`EMPNUM` = `test`.`t1`.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) +DEALLOCATE PREPARE stmt; +DROP TABLE t1, t2, t3; +# +# BUG#45221 Query SELECT pk FROM C WHERE pk IN (SELECT int_key) failing +# +CREATE TABLE t1 ( +i1_key INT, +i2 INT, +i3 INT, +KEY i1_index (i1_key) +); +INSERT INTO t1 VALUES (9,1,2), (9,2,1); +CREATE TABLE t2 ( +pk INT NOT NULL, +i1 INT, +PRIMARY KEY (pk) +); +INSERT INTO t2 VALUES (9,1); +SELECT pk +FROM t2 +WHERE +pk IN ( +SELECT i1_key +FROM t1 +WHERE t1.i2 < t1.i3 XOR t2.i1 > 1 +ORDER BY t1.i2 desc); +pk +9 +DROP TABLE t1,t2; +# BUG#50361 Doublenested noncorrelated subquery with FirstMatch and join cache wrong result +# +CREATE TABLE t1( +id INTEGER +); +INSERT INTO t1 VALUES(10),(20); +create table t2 select * from t1; +create table t3 select * from t1; +SELECT * +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t2 +WHERE 1 IN(SELECT 1 +FROM t3)); +id +10 +20 +explain SELECT * +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t2 +WHERE 1 IN(SELECT 1 +FROM t3)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where true +delete from t2; +delete from t3; +INSERT INTO t1 VALUES(30),(40),(50),(60),(70),(80),(90); +insert into t2 select * from t1; +insert into t3 select * from t1; +create table t4 select * from t1; +SELECT * +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t2 +WHERE 1 IN(SELECT 1 +FROM t3 +WHERE 1 IN(SELECT 1 +FROM t4))); +id +10 +20 +30 +40 +50 +60 +70 +80 +90 +explain SELECT * +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t2 +WHERE 1 IN(SELECT 1 +FROM t3 +WHERE 1 IN(SELECT 1 +FROM t4))); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 9 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 9 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 9 100.00 NULL +1 SIMPLE t4 NULL ALL NULL NULL NULL NULL 9 100.00 FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3` join `test`.`t4`) where true +SELECT * +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t1))); +id +10 +20 +30 +40 +50 +60 +70 +80 +90 +drop table t1,t2,t3,t4; +# +# Bug#53236 Segfault in DTCollation::set(DTCollation&) +# +CREATE TABLE t1 ( +pk INTEGER AUTO_INCREMENT, +col_varchar VARCHAR(1), +PRIMARY KEY (pk) +) +; +INSERT INTO t1 (col_varchar) +VALUES +('w'), +('m') +; +SELECT table1.pk +FROM ( t1 AS table1 JOIN t1 AS table2 ON (table1.col_varchar = +table2.col_varchar) ) +WHERE ( 1, 2 ) IN ( SELECT SUBQUERY1_t1.pk AS SUBQUERY1_field1, +SUBQUERY1_t1.pk AS SUBQUERY1_field2 +FROM ( t1 AS SUBQUERY1_t1 JOIN t1 AS SUBQUERY1_t2 +ON (SUBQUERY1_t2.col_varchar = +SUBQUERY1_t1.col_varchar) ) ) +; +pk +drop table t1; +# +# BUG#53298 "wrong result with semijoin (no semijoin strategy chosen)" +# +create table t1 (uid int, fid int); +insert into t1 values (1,1), (3,1); +create table t2 (uid int, name varchar(128)); +insert into t2 values (1, "A"), (2, "B"); +create table t3 (uid int, fid int, index(uid)); +insert into t3 values (1,3), (1,3); +create table t4 (uid int); +insert into t4 values (3); +explain select t2.uid from t2, t1 +where t1.uid in (select t4.uid from t4, t3 where t3.uid=1 and t4.uid=t3.fid) +and t2.uid=t1.fid; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ref uid uid 5 const 1 50.00 Using where +1 SIMPLE t4 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`uid` AS `uid` from `test`.`t2` join `test`.`t1` semi join (`test`.`t4` join `test`.`t3`) where ((`test`.`t3`.`fid` = `test`.`t1`.`uid`) and (`test`.`t4`.`uid` = `test`.`t1`.`uid`) and (`test`.`t3`.`uid` = 1) and (`test`.`t1`.`fid` = `test`.`t2`.`uid`)) +select t2.uid from t2, t1 +where t1.uid in (select t4.uid from t4, t3 where t3.uid=1 and t4.uid=t3.fid) +and t2.uid=t1.fid; +uid +1 +drop table t1,t2,t3,t4; +CREATE TABLE t1 ( +pk int, +a varchar(1), +b varchar(4), +c varchar(4), +d varchar(4), +PRIMARY KEY (pk) +) charset utf8mb4; +INSERT INTO t1 VALUES (1,'o','ffff','ffff','ffoo'),(2,'f','ffff','ffff','ffff'); +CREATE TABLE t2 LIKE t1; +INSERT INTO t2 VALUES (1,'i','iiii','iiii','iiii'),(2,'f','ffff','ffff','ffff'); +EXPLAIN SELECT pk FROM t1 WHERE (a) IN (SELECT a FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using where; FirstMatch(t1); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`a` = `test`.`t1`.`a`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (a) IN (SELECT a FROM t2 WHERE pk > 0); +pk +2 +SELECT pk FROM t1 WHERE (b,c,d) IN (SELECT b,c,d FROM t2 WHERE pk > 0); +pk +2 +DROP TABLE t1, t2; +CREATE TABLE t1 (f1 INT, f2 DECIMAL(5,3)) ENGINE=MyISAM; +INSERT INTO t1 (f1, f2) VALUES (1, 1.789); +INSERT INTO t1 (f1, f2) VALUES (13, 1.454); +INSERT INTO t1 (f1, f2) VALUES (10, 1.668); +CREATE TABLE t2 LIKE t1; +INSERT INTO t2 VALUES (1, 1.789); +INSERT INTO t2 VALUES (13, 1.454); +EXPLAIN SELECT COUNT(*) FROM t1 WHERE (f1,f2) IN (SELECT f1,f2 FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`f2` = `test`.`t1`.`f2`) and (`test`.`t2`.`f1` = `test`.`t1`.`f1`)) +SELECT COUNT(*) FROM t1 WHERE (f1,f2) IN (SELECT f1,f2 FROM t2); +COUNT(*) +2 +DROP TABLE t1, t2; +CREATE TABLE t1 ( +ID int(11) NOT NULL auto_increment, +Name char(35) NOT NULL default '', +Country char(3) NOT NULL default '', +Population int(11) NOT NULL default '0', +PRIMARY KEY (ID), +INDEX (Population), +INDEX (Country) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t2 ( +Code char(3) NOT NULL default '', +Name char(52) NOT NULL default '', +SurfaceArea float(10,2) NOT NULL default '0.00', +Population int(11) NOT NULL default '0', +Capital int(11) default NULL, +PRIMARY KEY (Code), +UNIQUE INDEX (Name), +INDEX (Population) +) charset utf8mb4; +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t3 ( +Country char(3) NOT NULL default '', +Language char(30) NOT NULL default '', +Percentage float(3,1) NOT NULL default '0.0', +PRIMARY KEY (Country, Language), +INDEX (Percentage) +) charset utf8mb4; +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +EXPLAIN SELECT Name FROM t2 +WHERE t2.Code IN (SELECT Country FROM t1 WHERE Population > 5000000) +AND +t2.Code IN (SELECT Country FROM t3 +WHERE Language='English' AND Percentage > 10 AND +t2.Population > 100000); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL PRIMARY,Population NULL NULL NULL 16 75.00 Using where +1 SIMPLE t1 NULL range Population,Country Population 4 NULL 1 10.00 Using where; FirstMatch(t2); Using join buffer (hash join) +1 SIMPLE t3 NULL eq_ref PRIMARY,Percentage PRIMARY 132 test.t2.Code,const 1 95.45 Using where +Warnings: +Note 1276 Field or reference 'test.t2.Population' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t2`.`Name` AS `Name` from `test`.`t3` join `test`.`t2` semi join (`test`.`t1`) where ((`test`.`t1`.`Country` = `test`.`t2`.`Code`) and (`test`.`t3`.`Country` = `test`.`t2`.`Code`) and (`test`.`t3`.`Language` = 'English') and (`test`.`t3`.`Percentage` > 10) and (`test`.`t2`.`Population` > 100000) and (`test`.`t1`.`Population` > 5000000)) +EXPLAIN FORMAT=JSON SELECT Name FROM t2 +WHERE t2.Code IN (SELECT Country FROM t1 WHERE Population > 5000000) +AND +t2.Code IN (SELECT Country FROM t3 +WHERE Language='English' AND Percentage > 10 AND +t2.Population > 100000); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "12.07" + }, + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "possible_keys": [ + "PRIMARY", + "Population" + ], + "rows_examined_per_scan": 16, + "rows_produced_per_join": 12, + "filtered": "75.00", + "cost_info": { + "read_cost": "1.13", + "eval_cost": "1.20", + "prefix_cost": "2.33", + "data_read_per_join": "2K" + }, + "used_columns": [ + "Code", + "Name", + "Population" + ], + "attached_condition": "(`test`.`t2`.`Population` > 100000)" + } + }, + { + "table": { + "table_name": "t1", + "access_type": "range", + "possible_keys": [ + "Population", + "Country" + ], + "key": "Population", + "used_key_parts": [ + "Population" + ], + "key_length": "4", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 12, + "filtered": "10.00", + "first_match": "t2", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "7.32", + "eval_cost": "1.20", + "prefix_cost": "10.85", + "data_read_per_join": "1K" + }, + "used_columns": [ + "Country", + "Population" + ], + "attached_condition": "((`test`.`t1`.`Country` = `test`.`t2`.`Code`) and (`test`.`t1`.`Population` > 5000000))" + } + }, + { + "table": { + "table_name": "t3", + "access_type": "eq_ref", + "possible_keys": [ + "PRIMARY", + "Percentage" + ], + "key": "PRIMARY", + "used_key_parts": [ + "Country", + "Language" + ], + "key_length": "132", + "ref": [ + "test.t2.Code", + "const" + ], + "rows_examined_per_scan": 1, + "rows_produced_per_join": 11, + "filtered": "95.45", + "cost_info": { + "read_cost": "0.03", + "eval_cost": "1.15", + "prefix_cost": "12.07", + "data_read_per_join": "1K" + }, + "used_columns": [ + "Country", + "Language", + "Percentage" + ], + "attached_condition": "((`test`.`t3`.`Language` = 'English') and (`test`.`t3`.`Percentage` > 10))" + } + } + ] + } +} +Warnings: +Note 1276 Field or reference 'test.t2.Population' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t2`.`Name` AS `Name` from `test`.`t3` join `test`.`t2` semi join (`test`.`t1`) where ((`test`.`t1`.`Country` = `test`.`t2`.`Code`) and (`test`.`t3`.`Country` = `test`.`t2`.`Code`) and (`test`.`t3`.`Language` = 'English') and (`test`.`t3`.`Percentage` > 10) and (`test`.`t2`.`Population` > 100000) and (`test`.`t1`.`Population` > 5000000)) +DROP TABLE t1,t2,t3; +CREATE TABLE t1 ( +Code char(3) NOT NULL DEFAULT '', +Name char(52) NOT NULL DEFAULT '', +Continent enum('Asia','Europe','North America','Africa','Oceania','Antarctica','South America') NOT NULL DEFAULT 'Asia', +Region char(26) NOT NULL DEFAULT '', +SurfaceArea float(10,2) NOT NULL DEFAULT '0.00', +IndepYear smallint(6) DEFAULT NULL, +Population int(11) NOT NULL DEFAULT '0', +LifeExpectancy float(3,1) DEFAULT NULL, +GNP float(10,2) DEFAULT NULL, +GNPOld float(10,2) DEFAULT NULL, +LocalName char(45) NOT NULL DEFAULT '', +GovernmentForm char(45) NOT NULL DEFAULT '', +HeadOfState char(60) DEFAULT NULL, +Capital int(11) DEFAULT NULL, +Code2 char(2) NOT NULL DEFAULT '', +PRIMARY KEY (Code) +) charset utf8mb4; +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t2 ( +ID int(11) NOT NULL AUTO_INCREMENT, +Name char(35) NOT NULL DEFAULT '', +CountryCode char(3) NOT NULL DEFAULT '', +District char(20) NOT NULL DEFAULT '', +Population int(11) NOT NULL DEFAULT '0', +PRIMARY KEY (ID), +KEY CountryCode (CountryCode) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +set names latin1; +Fill the table with test data +This must not use LooseScan: +EXPLAIN SELECT Name FROM t1 +WHERE t1.Code IN ( +SELECT t2.CountryCode FROM t2 WHERE Population > 5000000); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL PRIMARY NULL NULL NULL 31 100.00 NULL +1 SIMPLE t2 NULL ref CountryCode CountryCode 12 test.t1.Code 18 33.33 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`Name` AS `Name` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`CountryCode` = `test`.`t1`.`Code`) and (`test`.`t2`.`Population` > 5000000)) +SELECT Name FROM t1 +WHERE t1.Code IN ( +SELECT t2.CountryCode FROM t2 WHERE Population > 5000000); +Name +Austria +Canada +China +Czech Republic +drop table t1, t2; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4); +create table t1 (a int, b int, key(a)); +insert into t1 select a,a from t0; +create table t2 (a int, b int, primary key(a)); +insert into t2 select * from t1; +Table t2, unlike table t1, should be displayed as pulled out +explain select * from t0 +where t0.a in ( select t1.a from t1,t2 where t2.a=t0.a and +t1.b=t2.b); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL PRIMARY NULL NULL NULL 5 100.00 NULL +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 5 20.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ref a a 5 test.t2.a 1 20.00 Using where; FirstMatch(t0) +Warnings: +Note 1276 Field or reference 'test.t0.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a` from `test`.`t2` join `test`.`t0` semi join (`test`.`t1`) where ((`test`.`t0`.`a` = `test`.`t2`.`a`) and (`test`.`t1`.`a` = `test`.`t2`.`a`) and (`test`.`t1`.`b` = `test`.`t2`.`b`)) +update t1 set a=3, b=11 where a=4; +update t2 set b=11 where a=3; +select * from t0 where t0.a in (select t1.a from t1, t2 where t2.a=t0.a and t1.b=t2.b); +a +0 +1 +2 +3 +drop table t0, t1, t2; +CREATE TABLE t1 ( +id int(11) NOT NULL, +PRIMARY KEY (id)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t2 ( +id int(11) NOT NULL, +fid int(11) NOT NULL, +PRIMARY KEY (id)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t1 values(1); +insert into t2 values(1,7503),(2,1); +explain select count(*) +from t1 +where fid IN (select fid from t2 where (id between 7502 and 8420) order by fid ); +ERROR 42S22: Unknown column 'fid' in 'IN/ALL/ANY subquery' +drop table t1, t2; +create table t1 (a int, b int, key (a), key (b)); +insert into t1 values (2,4),(2,4),(2,4); +select t1.a from t1 +where +t1.a in (select 1 from t1 where t1.a in (select 1 from t1) group by t1.a); +a +drop table t1; +create table t1(a int,b int,key(a),key(b)); +insert into t1 values (1,1),(2,2),(3,3); +select 1 from t1 +where t1.a not in (select 1 from t1 +where t1.a in (select 1 from t1) +group by t1.b); +1 +1 +1 +drop table t1; +CREATE TABLE t1 +(EMPNUM CHAR(3) NOT NULL, +EMPNAME CHAR(20), +GRADE DECIMAL(4), +CITY CHAR(15)); +CREATE TABLE t2 +(PNUM CHAR(3) NOT NULL, +PNAME CHAR(20), +PTYPE CHAR(6), +BUDGET DECIMAL(9), +CITY CHAR(15)); +CREATE TABLE t3 +(EMPNUM CHAR(3) NOT NULL, +PNUM CHAR(3) NOT NULL, +HOURS DECIMAL(5)); +INSERT INTO t1 VALUES ('E1','Alice',12,'Deale'); +INSERT INTO t1 VALUES ('E2','Betty',10,'Vienna'); +INSERT INTO t1 VALUES ('E3','Carmen',13,'Vienna'); +INSERT INTO t1 VALUES ('E4','Don',12,'Deale'); +INSERT INTO t1 VALUES ('E5','Ed',13,'Akron'); +INSERT INTO t2 VALUES ('P1','MXSS','Design',10000,'Deale'); +INSERT INTO t2 VALUES ('P2','CALM','Code',30000,'Vienna'); +INSERT INTO t2 VALUES ('P3','SDP','Test',30000,'Tampa'); +INSERT INTO t2 VALUES ('P4','SDP','Design',20000,'Deale'); +INSERT INTO t2 VALUES ('P5','IRM','Test',10000,'Vienna'); +INSERT INTO t2 VALUES ('P6','PAYR','Design',50000,'Deale'); +INSERT INTO t3 VALUES ('E1','P1',40); +INSERT INTO t3 VALUES ('E1','P2',20); +INSERT INTO t3 VALUES ('E1','P3',80); +INSERT INTO t3 VALUES ('E1','P4',20); +INSERT INTO t3 VALUES ('E1','P5',12); +INSERT INTO t3 VALUES ('E1','P6',12); +INSERT INTO t3 VALUES ('E2','P1',40); +INSERT INTO t3 VALUES ('E2','P2',80); +INSERT INTO t3 VALUES ('E3','P2',20); +INSERT INTO t3 VALUES ('E4','P2',20); +INSERT INTO t3 VALUES ('E4','P4',40); +INSERT INTO t3 VALUES ('E4','P5',80); +SELECT * FROM t1; +EMPNUM EMPNAME GRADE CITY +E1 Alice 12 Deale +E2 Betty 10 Vienna +E3 Carmen 13 Vienna +E4 Don 12 Deale +E5 Ed 13 Akron +CREATE UNIQUE INDEX t1_IDX ON t1(EMPNUM); +SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN +(SELECT EMPNUM +FROM t3 +WHERE PNUM IN +(SELECT PNUM +FROM t2 +WHERE PTYPE = 'Design')); +EMPNAME +Alice +Betty +Don +DROP INDEX t1_IDX ON t1; +CREATE INDEX t1_IDX ON t1(EMPNUM); +SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN +(SELECT EMPNUM +FROM t3 +WHERE PNUM IN +(SELECT PNUM +FROM t2 +WHERE PTYPE = 'Design')); +EMPNAME +Alice +Betty +Don +DROP INDEX t1_IDX ON t1; +SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN +(SELECT EMPNUM +FROM t3 +WHERE PNUM IN +(SELECT PNUM +FROM t2 +WHERE PTYPE = 'Design')); +EMPNAME +Alice +Betty +Don +DROP TABLE t1, t2, t3; +CREATE TABLE t1 (f1 INT NOT NULL); +CREATE VIEW v1 (a) AS SELECT f1 IN (SELECT f1 FROM t1) FROM t1; +SELECT * FROM v1; +a +drop view v1; +drop table t1; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1(a int, b int); +insert into t1 values (0,0),(1,1),(2,2); +create table t2 as select * from t1; +create table t3 (pk int, a int, primary key(pk)); +insert into t3 select a,a from t0; +explain +select * from t1 left join t2 on (t2.a= t1.a and t2.a in (select pk from t3)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE t3 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using index +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` left join (`test`.`t3` join `test`.`t2`) on(((`test`.`t3`.`pk` = `test`.`t1`.`a`) and (`test`.`t2`.`a` = `test`.`t1`.`a`))) where true +drop table t0, t1, t2, t3; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (a int) as select A.a + 10 *(B.a + 10*C.a) as a from t0 A, t0 B, t0 C; +create table t2 (id int, a int, primary key(id), key(a)) charset utf8mb4 as select a as id, a as a from t1; +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `id` int NOT NULL, + `a` int DEFAULT NULL, + PRIMARY KEY (`id`), + KEY `a` (`a`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +set @a=0; +create table t3 as select * from t2 limit 0; +insert into t3 select @a:=@a+1, t2.a from t2, t0; +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +insert into t3 select @a:=@a+1, t2.a from t2, t0; +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +insert into t3 select @a:=@a+1, t2.a from t2, t0; +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +alter table t3 add primary key(id), add 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); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index a a 5 NULL 1000 100.00 Using where; Using index +1 SIMPLE t3 NULL ref a a 5 test.t2.a 30 100.00 Using index; FirstMatch(t2) +Warnings: +Note 1003 /* select#1 */ select count(`test`.`t2`.`a`) AS `count(a)` from `test`.`t2` semi join (`test`.`t3`) where (`test`.`t3`.`a` = `test`.`t2`.`a`) +select count(a) from t2 where a in ( SELECT a FROM t3); +count(a) +1000 +drop table t0,t1,t2,t3; +# +# Bug#33062: subquery in stored routine cause crash +# +CREATE TABLE t1(a INT); +CREATE TABLE t2(c INT); +CREATE PROCEDURE p1(v1 int) +BEGIN +SELECT 1 FROM t1 WHERE a = v1 AND a IN (SELECT c FROM t2); +END +// +CREATE PROCEDURE p2(v1 int) +BEGIN +SELECT 1 FROM t1 WHERE a IN (SELECT c FROM t2); +END +// +CREATE PROCEDURE p3(v1 int) +BEGIN +SELECT 1 +FROM +t1 t01,t1 t02,t1 t03,t1 t04,t1 t05,t1 t06,t1 t07,t1 t08, +t1 t09,t1 t10,t1 t11,t1 t12,t1 t13,t1 t14,t1 t15,t1 t16, +t1 t17,t1 t18,t1 t19,t1 t20,t1 t21,t1 t22,t1 t23,t1 t24, +t1 t25,t1 t26,t1 t27,t1 t28,t1 t29,t1 t30,t1 t31,t1 t32, +t1 t33,t1 t34,t1 t35,t1 t36,t1 t37,t1 t38,t1 t39,t1 t40, +t1 t41,t1 t42,t1 t43,t1 t44,t1 t45,t1 t46,t1 t47,t1 t48, +t1 t49,t1 t50,t1 t51,t1 t52,t1 t53,t1 t54,t1 t55,t1 t56, +t1 t57,t1 t58,t1 t59,t1 t60 +WHERE t01.a IN (SELECT c FROM t2); +END +// +CREATE PROCEDURE p4(v1 int) +BEGIN +SELECT 1 +FROM +t1 t01,t1 t02,t1 t03,t1 t04,t1 t05,t1 t06,t1 t07,t1 t08, +t1 t09,t1 t10,t1 t11,t1 t12,t1 t13,t1 t14,t1 t15,t1 t16, +t1 t17,t1 t18,t1 t19,t1 t20,t1 t21,t1 t22,t1 t23,t1 t24, +t1 t25,t1 t26,t1 t27,t1 t28,t1 t29,t1 t30,t1 t31,t1 t32, +t1 t33,t1 t34,t1 t35,t1 t36,t1 t37,t1 t38,t1 t39,t1 t40, +t1 t41,t1 t42,t1 t43,t1 t44,t1 t45,t1 t46,t1 t47,t1 t48, +t1 t49,t1 t50,t1 t51,t1 t52,t1 t53,t1 t54,t1 t55,t1 t56, +t1 t57,t1 t58,t1 t59,t1 t60 +WHERE t01.a = v1 AND t01.a IN (SELECT c FROM t2); +END +// +CALL p1(1); +1 +CALL p2(1); +1 +CALL p3(1); +1 +CALL p4(1); +1 +DROP TABLE t1, t2; +DROP PROCEDURE p1; +DROP PROCEDURE p2; +DROP PROCEDURE p3; +DROP PROCEDURE p4; +# +# Bug#48213 Materialized subselect crashes if using GEOMETRY type +# +CREATE TABLE t1 ( +pk int, +a varchar(1), +b varchar(4), +c tinyblob, +d blob, +e mediumblob, +f longblob, +g tinytext, +h text, +i mediumtext, +j longtext, +k geometry, +PRIMARY KEY (pk) +) charset utf8mb4; +INSERT INTO t1 VALUES (1,'o','ffff','ffff','ffoo','ffff','ffff','ffff','ffff','ffff','ffff',ST_GeomFromText('POLYGON((0 0, 0 2, 2 2, 2 0, 0 0))')), (2,'f','ffff','ffff','ffff', 'ffff','ffff','ffff','ffff','ffff','ffff',ST_GeomFromText('POLYGON((0 0, 0 2, 2 2, 2 0, 0 0))')); +CREATE TABLE t2 LIKE t1; +INSERT INTO t2 VALUES (1,'i','iiii','iiii','iiii','iiii','ffff','ffff','ffff','ffff','ffff',ST_GeomFromText('POLYGON((0 0, 0 2, 2 2, 2 0, 0 0))')), (2,'f','ffff','ffff','ffff','ffff','ffff','ffff','ffff','ffff','ffff',ST_GeomFromText('POLYGON((0 0, 0 2, 2 2, 2 0, 0 0))')); +EXPLAIN SELECT pk FROM t1 WHERE (a, b) IN (SELECT a, b FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using where; FirstMatch(t1); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ 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); +pk +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, c) IN (SELECT b, c FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using where; FirstMatch(t1); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`c` = `test`.`t1`.`c`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, c) IN (SELECT b, c FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, d) IN (SELECT b, d FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using where; FirstMatch(t1); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`d` = `test`.`t1`.`d`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, d) IN (SELECT b, d FROM t2 WHERE pk > 0); +pk +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, e) IN (SELECT b, e FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using where; FirstMatch(t1); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`e` = `test`.`t1`.`e`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, e) IN (SELECT b, e FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, f) IN (SELECT b, f FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using where; FirstMatch(t1); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`f` = `test`.`t1`.`f`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, f) IN (SELECT b, f FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, g) IN (SELECT b, g FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using where; FirstMatch(t1); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`g` = `test`.`t1`.`g`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, g) IN (SELECT b, g FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, h) IN (SELECT b, h FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using where; FirstMatch(t1); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`h` = `test`.`t1`.`h`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, h) IN (SELECT b, h FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, i) IN (SELECT b, i FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using where; FirstMatch(t1); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`i` = `test`.`t1`.`i`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, i) IN (SELECT b, i FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, j) IN (SELECT b, j FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using where; FirstMatch(t1); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`j` = `test`.`t1`.`j`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, j) IN (SELECT b, j FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, k) IN (SELECT b, k FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using where; FirstMatch(t1); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`k` = `test`.`t1`.`k`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, k) IN (SELECT b, k FROM t2 WHERE pk > 0); +pk +1 +2 +DROP TABLE t1, t2; +# End of Bug#48213 +# +# BUG#53060: LooseScan semijoin strategy does not return all rows +# +CREATE TABLE t1 (i INTEGER); +INSERT INTO t1 VALUES (1), (2), (3), (4), (5); +CREATE TABLE t2 (i INTEGER, j INTEGER, KEY k(i, j)); +INSERT INTO t2 VALUES (1, 0), (1, 1), (2, 0), (2, 1); +EXPLAIN +SELECT * FROM t1 WHERE (i) IN (SELECT i FROM t2 where j > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +1 SIMPLE t2 NULL index k k 10 NULL 4 25.00 Using where; Using index; FirstMatch(t1); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`i` = `test`.`t1`.`i`) and (`test`.`t2`.`j` > 0)) +SELECT * FROM t1 WHERE (i) IN (SELECT i FROM t2 where j > 0); +i +1 +2 +DROP TABLE t1, t2; +# End of BUG#53060 +# +# Bug#53305 "Duplicate weedout + join buffer (join cache --level=7,8) loses rows" +# +create table t1 (uid int, fid int, index(uid)); +insert into t1 values +(1,1), (1,2), (1,3), (1,4), +(2,5), (2,6), (2,7), (2,8), +(3,1), (3,2), (3,9); +create table t2 (uid int primary key, name varchar(128), index(name)); +insert into t2 values +(1, "A"), (2, "B"), (3, "C"), (4, "D"), (5, "E"), +(6, "F"), (7, "G"), (8, "H"), (9, "I"); +create table t3 (uid int, fid int, index(uid)); +insert into t3 values +(1,1), (1,2), (1,3),(1,4), +(2,5), (2,6), (2,7), (2,8), +(3,1), (3,2), (3,9); +create table t4 (uid int primary key, name varchar(128), index(name)); +insert into t4 values +(1, "A"), (2, "B"), (3, "C"), (4, "D"), (5, "E"), +(6, "F"), (7, "G"), (8, "H"), (9, "I"); +explain select name from t2, t1 +where t1.uid in (select t4.uid from t4, t3 where t3.uid=1 and t4.uid=t3.fid) +and t2.uid=t1.fid; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL uid NULL NULL NULL 11 100.00 Using where +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.fid 1 100.00 NULL +1 SIMPLE t4 NULL eq_ref PRIMARY PRIMARY 4 test.t1.uid 1 100.00 Using index +1 SIMPLE t3 NULL ref uid uid 5 const 4 10.00 Using where; FirstMatch(t4) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`name` AS `name` from `test`.`t4` join `test`.`t2` join `test`.`t1` semi join (`test`.`t3`) where ((`test`.`t4`.`uid` = `test`.`t1`.`uid`) and (`test`.`t3`.`fid` = `test`.`t1`.`uid`) and (`test`.`t3`.`uid` = 1) and (`test`.`t2`.`uid` = `test`.`t1`.`fid`)) +select name from t2, t1 +where t1.uid in (select t4.uid from t4, t3 where t3.uid=1 and t4.uid=t3.fid) +and t2.uid=t1.fid; +name +A +A +B +B +C +D +E +F +G +H +I +drop table t1,t2,t3,t4; +# +# Bug#43768 Prepared query with nested subqueries core dump on second execution +# +CREATE TABLE t1 ( +id INT PRIMARY KEY, +partner_id VARCHAR(35) +) charset utf8mb4; +INSERT INTO t1 VALUES +(1, 'partner1'), (2, 'partner2'), +(3, 'partner3'), (4, 'partner4'); +CREATE TABLE t2 ( +id INT NOT NULL, +t1_line_id INT, +article_id VARCHAR(20), +PRIMARY KEY(id, t1_line_id) +) charset utf8mb4; +INSERT INTO t2 VALUES +(1, 1, 'sup'), (2, 1, 'sup'), +(2, 2, 'sup'), (2, 3, 'sup'), +(2, 4, 'imp'), (3, 1, 'sup'), +(4, 1, 'sup'); +CREATE TABLE t3 ( +user_id VARCHAR(50), +article_id VARCHAR(20) NOT NULL, +PRIMARY KEY(user_id) +) charset utf8mb4; +INSERT INTO t3 VALUES('nicke', 'imp'); +EXPLAIN +SELECT t1.partner_id +FROM t1 +WHERE t1.id IN ( +SELECT t2.id +FROM t2 +WHERE article_id IN ( +SELECT article_id FROM t3 +WHERE user_id = 'nicke' + ) +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL system PRIMARY NULL NULL NULL 1 100.00 NULL +1 SIMPLE t1 NULL ALL PRIMARY NULL NULL NULL 4 100.00 NULL +1 SIMPLE t2 NULL ref PRIMARY PRIMARY 4 test.t1.id 1 14.29 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`partner_id` AS `partner_id` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`id` = `test`.`t1`.`id`) and (`test`.`t2`.`article_id` = 'imp')) +SELECT t1.partner_id +FROM t1 +WHERE t1.id IN ( +SELECT t2.id +FROM t2 +WHERE article_id IN ( +SELECT article_id FROM t3 +WHERE user_id = 'nicke' + ) +); +partner_id +partner2 +PREPARE stmt FROM +'EXPLAIN SELECT t1.partner_id +FROM t1 +WHERE t1.id IN ( + SELECT t2.id + FROM t2 + WHERE article_id IN ( + SELECT article_id FROM t3 + WHERE user_id = \'nicke\' + ) + )'; +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL system PRIMARY NULL NULL NULL 1 100.00 NULL +1 SIMPLE t1 NULL ALL PRIMARY NULL NULL NULL 4 100.00 NULL +1 SIMPLE t2 NULL ref PRIMARY PRIMARY 4 test.t1.id 1 14.29 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`partner_id` AS `partner_id` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`id` = `test`.`t1`.`id`) and (`test`.`t2`.`article_id` = 'imp')) + +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL system PRIMARY NULL NULL NULL 1 100.00 NULL +1 SIMPLE t1 NULL ALL PRIMARY NULL NULL NULL 4 100.00 NULL +1 SIMPLE t2 NULL ref PRIMARY PRIMARY 4 test.t1.id 1 14.29 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`partner_id` AS `partner_id` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`id` = `test`.`t1`.`id`) and (`test`.`t2`.`article_id` = 'imp')) +PREPARE stmt FROM +'SELECT t1.partner_id +FROM t1 +WHERE t1.id IN ( + SELECT t2.id + FROM t2 + WHERE article_id IN ( + SELECT article_id FROM t3 + WHERE user_id = \'nicke\' + ) + )'; +EXECUTE stmt; +partner_id +partner2 + +EXECUTE stmt; +partner_id +partner2 +DROP TABLE t1,t2,t3; +# End of Bug#43768 +# +# Bug#53058 - semijoin execution of subquery with outerjoin yields wrong result +# +CREATE TABLE t1 (i INTEGER); +CREATE TABLE t2 (i INTEGER); +CREATE TABLE t3 (i INTEGER); +INSERT INTO t1 VALUES (1), (2); +INSERT INTO t2 VALUES (6); +INSERT INTO t3 VALUES (1), (2); +explain SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t3 LEFT JOIN t2 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = `test`.`t1`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t3 LEFT JOIN t2 ON t2.i=t3.i); +i +1 +2 +drop table t1,t2,t3; +# +# BUG#49453: re-execution of prepared statement with view +# and semijoin crashes +# +CREATE TABLE t1 (city VARCHAR(50), country_id INT); +CREATE TABLE t2 (country_id INT, country VARCHAR(50)); +INSERT INTO t1 VALUES +('Batna',2),('Bchar',2),('Skikda',2),('Tafuna',3),('Algeria',2) ; +INSERT INTO t2 VALUES (2,'Algeria'),(2,'AlgeriaDup'),(3,'XAmerican Samoa'); +CREATE VIEW v1 AS +SELECT country_id as vf_country_id +FROM t2 +WHERE LEFT(country,1) = "A"; +PREPARE stmt FROM " +SELECT city, country_id +FROM t1 +WHERE country_id IN (SELECT vf_country_id FROM v1); +"; + +EXECUTE stmt; +city country_id +Algeria 2 +Batna 2 +Bchar 2 +Skikda 2 + +EXECUTE stmt; +city country_id +Algeria 2 +Batna 2 +Bchar 2 +Skikda 2 +DROP TABLE t1,t2; +DROP VIEW v1; +# +# Bug#54437 Extra rows with LEFT JOIN + semijoin (firstmatch +# and duplicates weedout) +# +create table t1 (a int); +create table t2 (a int); +create table t3 (a int); +insert into t1 values(1),(1); +insert into t2 values(1),(1),(1),(1); +insert into t3 values(2),(2); +explain select * from t1 where t1.a in (select t2.a from t2 left join t3 on t2.a=t3.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t2` left join `test`.`t3` on((`test`.`t2`.`a` = `test`.`t3`.`a`))) where (`test`.`t2`.`a` = `test`.`t1`.`a`) +select * from t1 where t1.a in (select t2.a from t2 left join t3 on t2.a=t3.a); +a +1 +1 +drop table t1,t2,t3; +# +# Bug#55955: crash in MEMORY engine with IN(LEFT JOIN (JOIN)) +# +CREATE TABLE t1 (a INT); +CREATE TABLE t2 (a INT); +CREATE TABLE t3 (a INT); +INSERT INTO t1 VALUES(1),(1); +INSERT INTO t2 VALUES(1),(1); +INSERT INTO t3 VALUES(2),(2); +explain SELECT * FROM t1 +WHERE t1.a IN (SELECT t2.a +FROM t2 LEFT JOIN (t2 AS t2inner, t3) ON t2.a=t3.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2inner NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t2` left join (`test`.`t2` `t2inner` join `test`.`t3`) on((`test`.`t2`.`a` = `test`.`t3`.`a`))) where (`test`.`t2`.`a` = `test`.`t1`.`a`) +SELECT * FROM t1 +WHERE t1.a IN (SELECT t2.a +FROM t2 LEFT JOIN (t2 AS t2inner, t3) ON t2.a=t3.a); +a +1 +1 +DROP TABLE t1,t2,t3; +# +# BUG#52329 - Wrong result: subquery materialization, IN, +# non-null field followed by nullable +# +CREATE TABLE t1 (a1 CHAR(8) NOT NULL, a2 char(8) NOT NULL); +CREATE TABLE t2a (b1 char(8), b2 char(8)); +CREATE TABLE t2b (b1 CHAR(8), b2 char(8) NOT NULL); +CREATE TABLE t2c (b1 CHAR(8) NOT NULL, b2 char(8)); +INSERT INTO t1 VALUES ('1 - 12', '2 - 22'); +INSERT INTO t2a VALUES ('1 - 11', '2 - 21'), +('1 - 11', '2 - 21'), +('1 - 12', '2 - 22'), +('1 - 12', '2 - 22'), +('1 - 13', '2 - 23'); +INSERT INTO t2b SELECT * FROM t2a; +INSERT INTO t2c SELECT * FROM t2a; +SELECT * FROM t1 +WHERE (a1, a2) IN ( +SELECT b1, b2 FROM t2c WHERE b1 > '0' GROUP BY b1, b2); +a1 a2 +1 - 12 2 - 22 +SELECT * FROM t1 +WHERE (a1, a2) IN ( +SELECT b1, b2 FROM t2a WHERE b1 > '0'); +a1 a2 +1 - 12 2 - 22 +SELECT * FROM t1 +WHERE (a1, a2) IN ( +SELECT b1, b2 FROM t2b WHERE b1 > '0'); +a1 a2 +1 - 12 2 - 22 +SELECT * FROM t1 +WHERE (a1, a2) IN ( +SELECT b1, b2 FROM t2c WHERE b1 > '0'); +a1 a2 +1 - 12 2 - 22 +DROP TABLE t1,t2a,t2b,t2c; +# End BUG#52329 +# +# Bug#45174: Incorrectly applied equality propagation caused wrong +# result on a query with a materialized semi-join. +# +CREATE TABLE t1 ( +varchar_nokey varchar(1) NOT NULL +) charset utf8mb4; +INSERT INTO t1 VALUES +('v'), ('u'), ('n'), ('l'), ('h'), ('u'), ('n'), ('j'), ('k'), +('e'), ('i'), ('u'), ('n'), ('b'), ('x'), (''), ('q'), ('u'); +CREATE TABLE t2 ( +pk int NOT NULL, +varchar_key varchar(1) NOT NULL, +varchar_nokey varchar(1) NOT NULL, +PRIMARY KEY(pk), +KEY varchar_key(varchar_key) +) charset utf8mb4; +INSERT INTO t2 VALUES +(11,'m','m'), (12,'j','j'), (13,'z','z'), (14,'a','a'), (15,'',''), +(16,'e','e'), (17,'t','t'), (19,'b','b'), (20,'w','w'), (21,'m','m'), +(23,'',''), (24,'w','w'), (26,'e','e'), (27,'e','e'), (28,'p','p'); +SELECT varchar_nokey +FROM t1 +WHERE (varchar_nokey, varchar_nokey) IN (SELECT varchar_key, varchar_nokey +FROM t2 +WHERE varchar_nokey < 'n' XOR pk); +varchar_nokey +explain SELECT varchar_nokey +FROM t1 +WHERE (varchar_nokey, varchar_nokey) IN (SELECT varchar_key, varchar_nokey +FROM t2 +WHERE varchar_nokey < 'n' XOR pk); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 18 100.00 NULL +1 SIMPLE t2 NULL ref varchar_key varchar_key 6 test.t1.varchar_nokey 2 6.67 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`varchar_nokey` AS `varchar_nokey` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`varchar_key` = `test`.`t1`.`varchar_nokey`) and (`test`.`t2`.`varchar_nokey` = `test`.`t1`.`varchar_nokey`) and ((`test`.`t2`.`varchar_nokey` < 'n') xor (0 <> `test`.`t2`.`pk`))) +DROP TABLE t1, t2; +# End of the test for bug#45174. +# +# Bug#50019: Wrong result for IN-query with materialization +# +CREATE TABLE t1(i INT); +INSERT INTO t1 VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10); +CREATE TABLE t2(i INT); +INSERT INTO t2 VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10); +CREATE TABLE t3(i INT); +INSERT INTO t3 VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10); +SELECT * FROM t1 WHERE t1.i IN (SELECT t2.i +FROM t2 JOIN t3 +WHERE t2.i + t3.i = 5); +i +1 +2 +3 +4 +explain SELECT * FROM t1 WHERE t1.i IN (SELECT t2.i +FROM t2 JOIN t3 +WHERE t2.i + t3.i = 5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 10 10.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 10 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = `test`.`t1`.`i`) and ((`test`.`t1`.`i` + `test`.`t3`.`i`) = 5)) +DROP TABLE t1,t2,t3; +# End of the test for bug#50019. +# +# Bug#52068: Optimizer generates invalid semijoin materialization plan +# +CREATE TABLE ot1(a INTEGER); +INSERT INTO ot1 VALUES(5), (8); +CREATE TABLE it2(a INTEGER); +INSERT INTO it2 VALUES(9), (5), (1), (8); +CREATE TABLE it3(a INTEGER); +INSERT INTO it3 VALUES(7), (1), (0), (5), (1), (4); +CREATE TABLE ot4(a INTEGER); +INSERT INTO ot4 VALUES(1), (3), (5), (7), (9), (7), (3), (1); +SELECT * FROM ot1,ot4 +WHERE (ot1.a,ot4.a) IN (SELECT it2.a,it3.a +FROM it2,it3); +a a +5 1 +5 1 +5 5 +5 7 +5 7 +8 1 +8 1 +8 5 +8 7 +8 7 +explain SELECT * FROM ot1,ot4 +WHERE (ot1.a,ot4.a) IN (SELECT it2.a,it3.a +FROM it2,it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE ot4 NULL ALL NULL NULL NULL NULL 8 100.00 Using join buffer (hash join) +1 SIMPLE it2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where +1 SIMPLE it3 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; FirstMatch(ot4) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot4`.`a` AS `a` from `test`.`ot1` join `test`.`ot4` semi join (`test`.`it2` join `test`.`it3`) where ((`test`.`it3`.`a` = `test`.`ot4`.`a`) and (`test`.`it2`.`a` = `test`.`ot1`.`a`)) +DROP TABLE IF EXISTS ot1, ot4, it2, it3; +# End of the test for bug#52068. +# +# Bug#57623: subquery within before insert trigger causes crash (sj=on) +# +CREATE TABLE ot1(a INT); +CREATE TABLE ot2(a INT); +CREATE TABLE ot3(a INT); +CREATE TABLE it1(a INT); +INSERT INTO ot1 VALUES(0),(1),(2),(3),(4),(5),(6),(7); +INSERT INTO ot2 VALUES(0),(2),(4),(6); +INSERT INTO ot3 VALUES(0),(3),(6); +INSERT INTO it1 VALUES(0),(1),(2),(3),(4),(5),(6),(7); +explain SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 on ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a from it1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +1 SIMPLE ot3 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE it1 NULL ALL NULL NULL NULL NULL 8 100.00 Using where; FirstMatch(ot3) +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a`,`test`.`ot3`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` join `test`.`ot3` semi join (`test`.`it1`)) on(((`test`.`ot3`.`a` = `test`.`ot1`.`a`) and (`test`.`it1`.`a` = `test`.`ot1`.`a`) and (`test`.`ot2`.`a` = `test`.`ot1`.`a`))) where true +SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 on ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a from it1); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +prepare s from 'SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 on ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a from it1)'; +execute s; +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +execute s; +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +deallocate prepare s; +DROP TABLE ot1, ot2, ot3, it1; +# End of the test for bug#57623. +# +# Bug#11766739: Crash in tmp_table_param::init() with semijoin=on +# +CREATE TABLE t1 (f1 INTEGER) ENGINE=MyISAM; +CREATE TABLE t2 (f1 INTEGER, f2 INTEGER) ENGINE=MyISAM; +INSERT INTO t1 VALUES (1); +INSERT INTO t2 VALUES (1,1), (2,1); +EXPLAIN SELECT * FROM t2 +WHERE f2 IN (SELECT t1.f1 +FROM t1 LEFT OUTER JOIN (t2 AS b1 JOIN t2 AS b2 ON TRUE) ON TRUE); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE b1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE b2 NULL ALL NULL NULL NULL NULL 2 100.00 FirstMatch(t2) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`f1` AS `f1`,`test`.`t2`.`f2` AS `f2` from `test`.`t2` semi join (`test`.`t1` left join (`test`.`t2` `b1` join `test`.`t2` `b2`) on((true))) where (`test`.`t1`.`f1` = `test`.`t2`.`f2`) +SELECT * FROM t2 +WHERE f2 IN (SELECT t1.f1 +FROM t1 LEFT OUTER JOIN (t2 AS b1 JOIN t2 AS b2 ON TRUE) ON TRUE); +f1 f2 +1 1 +2 1 +DROP TABLE t1, t2; +# End of the test for bug#11766739. +# +# Bug#11766642: crash in Item_field::register_field_in_read_map with view +# +CREATE TABLE t1(a INT); +CREATE VIEW v1 AS SELECT a FROM t1; +INSERT INTO t1 VALUES (0),(1),(2); +SELECT a FROM t1 WHERE a IN +(SELECT a XOR a FROM v1) +ORDER BY a; +a +0 +DROP TABLE t1; +DROP VIEW v1; +# +# Bug#12546542 MISSING ROW WHEN USING OPTIMIZER_JOIN_CACHE_LEVEL>=3 +# +CREATE TABLE t1 ( +f2 varchar(1024) +); +INSERT INTO t1 VALUES ('v'),('we'); +CREATE TABLE t2 ( +col_varchar_1024_utf8 varchar(1024) CHARACTER SET utf8 DEFAULT NULL, +col_int_key int, +col_int int +); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t2 VALUES ('we',4,NULL),('v',1305673728,6); +CREATE TABLE t3 ( +col_int_key int, +col_int int +); +INSERT INTO t3 VALUES (4,4); +SELECT * +FROM t1 +WHERE f2 IN (SELECT a1.col_varchar_1024_utf8 AS f2 +FROM t2 AS a1 LEFT JOIN t3 AS a2 +ON a1.col_int_key = a2.col_int_key +WHERE a1.col_int BETWEEN 1 AND 10 OR a2.col_int IS NOT NULL); +f2 +v +we +DROP TABLE t1,t2,t3; +# +# BUG#12616344 - JCL: DIFFERENT RESULT SET AND DIFFERENT AMOUNT +# OF ROWS WHEN JCL>=3 +# +CREATE TABLE t1 (col_int_nokey int, col_int_key int, col_varchar_key varchar(1)); +INSERT INTO t1 VALUES (0,4,'c'),(1,6,'u'); +CREATE TABLE t2 (pk int, col_int_nokey int, col_varchar_nokey varchar(1)); +INSERT INTO t2 VALUES (1,4,'b'),(94,6,'u'); +CREATE TABLE t3 (pk int, col_int_nokey int, col_varchar_key varchar(1)); +INSERT INTO t3 VALUES (1,4,'j'),(2,6,'v'); +SELECT table2.col_int_key +from t3 as table1 join t1 as table2 on table2.col_int_nokey +where table1.col_int_nokey in +( +select subquery2_t2.col_int_nokey +from t3 as subquery2_t1 +right join +t2 as subquery2_t2 +join t1 as subquery2_t3 +on subquery2_t3.col_int_key = subquery2_t2.col_int_nokey +on subquery2_t3.col_varchar_key = subquery2_t2.col_varchar_nokey +where subquery2_t1.col_varchar_key != table1.col_varchar_key +or subquery2_t2.pk <= table1.pk +); +col_int_key +6 +6 +DROP TABLE t1,t2,t3; +# +# Bug#12608157: ASSERT IN FIELD_LONG::VAL_INT WHEN USING MEMORY ENGINE +# +CREATE TABLE t1 (i1 int); +INSERT INTO t1 VALUES (1); +CREATE TABLE t2 (i1 int, i2 int) ENGINE=memory; +INSERT INTO t2 VALUES (1, 2),(7, 3); +SELECT GRANDPARENT1.i1 +FROM t2 AS GRANDPARENT1 +WHERE GRANDPARENT1.i2 +IN ( SELECT PARENT1.i2 +FROM t2 AS PARENT1 JOIN t1 AS PARENT2 ON (PARENT1.i1 = PARENT2.i1) +WHERE +GRANDPARENT1.i1 IN ( SELECT CHILD1.i1 FROM t2 AS CHILD1 ) +ORDER BY PARENT1.i1) +ORDER BY GRANDPARENT1.i2 ; +i1 +1 +DROP TABLE t1,t2; +# +# Bug#12640083: Same query executed as WHERE subquery gives different +# results on IN() compare +# +CREATE TABLE t1 ( +pk int NOT NULL, +col_varchar_1024_utf8_key varchar(1024) CHARACTER SET utf8 DEFAULT NULL, +col_varchar_10_latin1_key varchar(10) DEFAULT NULL, +PRIMARY KEY (pk), +KEY col_varchar_1024_utf8_key(col_varchar_1024_utf8_key(333)), +KEY col_varchar_10_latin1_key(col_varchar_10_latin1_key) +) charset utf8mb4; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES +(1, 'a', 'a'), +(2, 'ab', 'ab'), +(3, 'abc', 'abc'), +(4, 'abcd', 'abcd'); +CREATE TABLE t2 ( +pk int NOT NULL AUTO_INCREMENT, +PRIMARY KEY (pk) +) charset utf8mb4 ENGINE=Innodb; +CREATE TABLE t3 charset utf8mb4 +SELECT alias1.col_varchar_10_latin1_key +FROM t1 AS alias1 +LEFT JOIN t1 AS alias2 +JOIN t2 AS alias3 +ON alias2.col_varchar_10_latin1_key +ON alias1.col_varchar_1024_utf8_key +WHERE alias1.pk AND alias1.pk < 3 OR alias1.pk AND alias3.pk; +EXPLAIN SELECT * +FROM t3 +WHERE col_varchar_10_latin1_key IN ( +SELECT alias1.col_varchar_10_latin1_key +FROM t1 AS alias1 +LEFT JOIN t1 AS alias2 +JOIN t2 AS alias3 +ON alias2.col_varchar_10_latin1_key +ON alias1.col_varchar_1024_utf8_key +WHERE alias1.pk AND alias1.pk < 3 OR alias1.pk AND alias3.pk); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE alias1 NULL ref PRIMARY,col_varchar_10_latin1_key col_varchar_10_latin1_key 43 test.t3.col_varchar_10_latin1_key 2 100.00 Using where +1 SIMPLE alias3 NULL index NULL PRIMARY 4 NULL 1 100.00 Using where; Using index +1 SIMPLE alias2 NULL index NULL col_varchar_10_latin1_key 43 NULL 4 100.00 Using where; Using index; FirstMatch(t3) +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`col_varchar_10_latin1_key` AS `col_varchar_10_latin1_key` from `test`.`t3` semi join (`test`.`t1` `alias1` left join (`test`.`t1` `alias2` join `test`.`t2` `alias3`) on(((0 <> `test`.`alias1`.`col_varchar_1024_utf8_key`) and (0 <> `test`.`alias2`.`col_varchar_10_latin1_key`)))) where ((`test`.`alias1`.`col_varchar_10_latin1_key` = `test`.`t3`.`col_varchar_10_latin1_key`) and (((0 <> `test`.`alias1`.`pk`) and (`test`.`alias1`.`pk` < 3)) or ((0 <> `test`.`alias1`.`pk`) and (0 <> `test`.`alias3`.`pk`)))) +SELECT * +FROM t3 +WHERE col_varchar_10_latin1_key IN ( +SELECT alias1.col_varchar_10_latin1_key +FROM t1 AS alias1 +LEFT JOIN t1 AS alias2 +JOIN t2 AS alias3 +ON alias2.col_varchar_10_latin1_key +ON alias1.col_varchar_1024_utf8_key +WHERE alias1.pk AND alias1.pk < 3 OR alias1.pk AND alias3.pk); +col_varchar_10_latin1_key +a +ab +DROP TABLE t1, t2, t3; +# End of the test for bug#12640083. +# +# Bug#12603200 - Assert in QUICK_INDEX_MERGE_SELECT::need_sorted_output +# +CREATE TABLE t1 ( +pk int NOT NULL, +col_int_key int NOT NULL, +col_varchar_nokey varchar(1) NOT NULL, +col_varchar_key varchar(1) NOT NULL, +PRIMARY KEY(pk), +KEY col_int_key(col_int_key), +KEY col_varchar_key(col_varchar_key, col_int_key) +) charset utf8mb4 engine=innodb; +INSERT INTO t1 VALUES +(1,7,'a','a'), +(2,0,'v','v'), +(3,9,'c','c'), +(4,3,'m','m'), +(5,2,'a','a'), +(6,1,'d','d'), +(7,8,'y','y'), +(8,6,'t','t'), +(11,7,'a','x'), +(12,0,'v','v'), +(13,9,'c','c'), +(14,3,'m','m'), +(15,2,'a','x'), +(16,1,'d','d'), +(17,8,'y','y'), +(18,6,'t','u'), +(19,6,'t','u'); +CREATE TABLE t2 ( +pk int NOT NULL, +col_int_key int NOT NULL, +col_varchar_key varchar(1) NOT NULL, +PRIMARY KEY(pk), +KEY col_varchar_key(col_varchar_key, col_int_key) +) charset utf8mb4 engine=innodb; +INSERT INTO t2(pk,col_int_key,col_varchar_key) VALUES +(8,7,'c'), +(11,4,'l'), +(12,7,'b'), +(13,0,'c'), +(14,2,'i'), +(15,9,'h'), +(16,4,'q'), +(17,1,'m'), +(18,9,'b'), +(19,2,'e'), +(20,1,'c'), +(21,7,'z'), +(22,4,'l'), +(23,7,'z'), +(24,0,'c'), +(25,2,'i'), +(26,9,'h'), +(27,4,'q'), +(28,0,'a'), +(29,1,'d'); +EXPLAIN SELECT outr.col_varchar_key AS x, outr.pk AS y +FROM t1 AS outr +WHERE outr.col_varchar_key IN (SELECT innr.col_varchar_key +FROM t2 AS innr +WHERE innr.col_varchar_key = 'a' OR innr.pk = 8) +AND outr.col_varchar_nokey < 't' +ORDER BY outr.col_varchar_key, outr.pk; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 17 33.33 Parallel execute (1 workers) +2 SIMPLE outr NULL ALL col_varchar_key NULL NULL NULL 17 33.33 Using where; Using filesort +2 SIMPLE innr NULL ref PRIMARY,col_varchar_key col_varchar_key 6 test.outr.col_varchar_key 1 100.00 Using where; Using index; FirstMatch(outr) +Warnings: +Note 1003 /* select#1 */ select `test`.`outr`.`col_varchar_key` AS `x`,`test`.`outr`.`pk` AS `y` from `test`.`t1` `outr` semi join (`test`.`t2` `innr`) where ((`test`.`innr`.`col_varchar_key` = `test`.`outr`.`col_varchar_key`) and (`test`.`outr`.`col_varchar_nokey` < 't') and ((`test`.`outr`.`col_varchar_key` = 'a') or (`test`.`innr`.`pk` = 8))) order by `test`.`outr`.`col_varchar_key`,`test`.`outr`.`pk` +SELECT outr.col_varchar_key AS x, outr.pk AS y +FROM t1 AS outr +WHERE outr.col_varchar_key IN (SELECT innr.col_varchar_key +FROM t2 AS innr +WHERE innr.col_varchar_key = 'a' OR innr.pk = 8) +AND outr.col_varchar_nokey < 't' +ORDER BY outr.col_varchar_key, outr.pk; +x y +a 1 +a 5 +c 3 +c 13 +DROP TABLE t1, t2; +# End of bug#12603200 +# +# Bug#12603183: Segfault in hp_movelink +# +CREATE TABLE t1 ( +col_varchar_key varchar(1) , +col_varchar_nokey varchar(1) , +KEY col_varchar_key(col_varchar_key) +) charset latin1; +INSERT INTO t1 VALUES +('i','i'), +('h','h'), +('q','q'), +('a','a'), +('v','v'), +('u','u'), +('s','s'), +('y','y'), +('z','z'), +('h','h'), +('p','p'), +('e','e'), +('i','i'), +('y','y'), +('w','w'); +CREATE TABLE t2 ( +col_varchar_nokey varchar(1) +) charset latin1; +INSERT INTO t2 VALUES +('b'); +EXPLAIN SELECT grandparent1.col_varchar_nokey +FROM t1 AS grandparent1 LEFT JOIN t2 AS grandparent2 USING (col_varchar_nokey) +WHERE (grandparent1.col_varchar_key) IN +(SELECT parent1.col_varchar_nokey +FROM t1 AS parent1 +WHERE parent1.col_varchar_key IN +(SELECT child1.col_varchar_nokey AS c1 +FROM t1 AS child1 LEFT JOIN t2 AS child2 +ON (child1.col_varchar_key > child2.col_varchar_nokey))); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE grandparent1 NULL ALL col_varchar_key NULL NULL NULL 15 100.00 NULL +1 SIMPLE grandparent2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE parent1 NULL ALL col_varchar_key NULL NULL NULL 15 10.00 Using where +1 SIMPLE child1 NULL ALL NULL NULL NULL NULL 15 10.00 Using where +1 SIMPLE child2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(grandparent2) +Warnings: +Note 1003 /* select#1 */ select `test`.`grandparent1`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t1` `grandparent1` left join `test`.`t2` `grandparent2` on((`test`.`grandparent2`.`col_varchar_nokey` = `test`.`grandparent1`.`col_varchar_nokey`)) semi join (`test`.`t1` `parent1` join `test`.`t1` `child1` left join `test`.`t2` `child2` on((`test`.`child1`.`col_varchar_key` > `test`.`child2`.`col_varchar_nokey`))) where ((`test`.`parent1`.`col_varchar_nokey` = `test`.`grandparent1`.`col_varchar_key`) and (`test`.`child1`.`col_varchar_nokey` = `test`.`parent1`.`col_varchar_key`)) +SELECT grandparent1.col_varchar_nokey +FROM t1 AS grandparent1 LEFT JOIN t2 AS grandparent2 USING (col_varchar_nokey) +WHERE (grandparent1.col_varchar_key) IN +(SELECT parent1.col_varchar_nokey +FROM t1 AS parent1 +WHERE parent1.col_varchar_key IN +(SELECT child1.col_varchar_nokey AS c1 +FROM t1 AS child1 LEFT JOIN t2 AS child2 +ON (child1.col_varchar_key > child2.col_varchar_nokey))); +col_varchar_nokey +a +e +h +h +i +i +p +q +s +u +v +w +y +y +z +DROP TABLE t1, t2; +# End of test for bug#12603183. +# +# Bug#12818569: Diff nr of rows returned when using IN/ALL+subquery +# +CREATE TABLE t1 ( +col_int_key INT NOT NULL, +col_datetime_key DATETIME NOT NULL, +col_varchar_key VARCHAR(1) NOT NULL, +KEY col_int_key (col_int_key), +KEY col_datetime_key(col_datetime_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t1 VALUES +(7,'2004-06-06 04:22:12','v'), (0,'2005-11-13 01:12:31','s'), +(9,'2002-05-04 01:50:00','l'), (3,'2004-10-27 10:28:45','y'), +(4,'2006-07-22 05:24:23','c'), (2,'2002-05-16 21:34:03','i'), +(5,'2008-04-17 10:45:30','h'), (3,'2009-04-21 02:58:02','q'), +(1,'2008-01-11 11:01:51','a'), (3,'1900-01-01 00:00:00','v'), +(6,'2007-05-17 18:24:57','u'), (7,'2007-08-07 00:00:00','s'), +(5,'2001-08-28 00:00:00','y'), (1,'2004-04-16 00:27:28','z'), +(204,'2005-05-03 07:06:22','h'), (224,'2009-03-11 17:09:50','p'), +(9,'2007-12-08 01:54:28','e'), (5,'2009-07-28 18:19:54','i'), +(0,'2008-06-08 00:00:00','y'), (3,'2005-02-09 09:20:26','w'); +CREATE TABLE t2 ( +col_varchar_nokey VARCHAR(1) NOT NULL +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t2 VALUES ('v'), ('y'), ('j'), ('c'), ('d'), ('r'); +explain SELECT col_varchar_key +FROM t1 +WHERE col_varchar_key IN (SELECT col_varchar_nokey +FROM t2) +ORDER BY col_datetime_key LIMIT 4; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 20 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL col_varchar_key NULL NULL NULL 20 100.00 Using temporary; Using filesort +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; FirstMatch(t1); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col_varchar_key` AS `col_varchar_key` from `test`.`t1` semi join (`test`.`t2`) where (`test`.`t2`.`col_varchar_nokey` = `test`.`t1`.`col_varchar_key`) order by `test`.`t1`.`col_datetime_key` limit 4 +SELECT col_varchar_key +FROM t1 +WHERE col_varchar_key IN (SELECT col_varchar_nokey +FROM t2) +ORDER BY col_datetime_key LIMIT 4; +col_varchar_key +v +y +v +y +DROP TABLE t1, t2; +# End of test for bug#12818569. +# +# Bug#12803439: Assert in replace_subcondition() on update query +# +CREATE TABLE t1(a INTEGER); +INSERT INTO t1 values(1), (2); +CREATE TABLE t2(a INTEGER); +INSERT INTO t2 VALUES(1), (3); +SELECT * +FROM t1 +WHERE a IN (SELECT a +FROM t2 +HAVING a IN (SELECT a +FROM t2) +) +HAVING a IN (SELECT a +FROM t2); +a +1 +DROP TABLE t1, t2; +# End of test for bug#12803439. +# +# Bug#12797534: Segfault in hp_movelink still exists +# +CREATE TABLE t1 ( +g1 VARCHAR(1) NOT NULL +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t1 VALUES ('d'), ('s'); +CREATE TABLE t2 ( +pk INT NOT NULL, +col_int_key INT NOT NULL, +col_varchar_key VARCHAR(1) NOT NULL, +col_varchar_nokey VARCHAR(1) NOT NULL, +PRIMARY KEY (pk), +KEY col_varchar_key(col_varchar_key, col_int_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t2 VALUES +(1,4,'j','j'), (2,6,'v','v'), (3,3,'c','c'), (4,5,'m','m'), +(5,3,'d','d'), (6,246,'d','d'), (7,2,'y','y'), (8,9,'t','t'), +(9,3,'d','d'), (10,8,'s','s'), (11,1,'r','r'), (12,8,'m','m'), +(13,8,'b','b'), (14,5,'x','x'), (15,7,'g','g'), (16,5,'p','p'), +(17,1,'q','q'), (18,6,'w','w'), (19,2,'d','d'), (20,9,'e','e'); +CREATE TABLE t3 ( +pk INTEGER NOT NULL, +PRIMARY KEY (pk) +) ENGINE=InnoDB; +INSERT INTO t3 VALUES (10); +EXPLAIN SELECT * +FROM t1 +WHERE g1 NOT IN +(SELECT grandparent1.col_varchar_nokey AS g1 +FROM t2 AS grandparent1 +WHERE grandparent1.col_varchar_key IN +(SELECT parent1.col_varchar_nokey AS p1 +FROM t2 AS parent1 LEFT JOIN t3 AS parent2 USING (pk) +) +AND grandparent1.col_varchar_key IS NOT NULL +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 SIMPLE parent1 NULL ALL NULL NULL NULL NULL 20 100.00 Using where; Not exists +2 SIMPLE parent2 NULL eq_ref PRIMARY PRIMARY 4 test.parent1.pk 1 100.00 Using index +2 SIMPLE grandparent1 NULL ref col_varchar_key col_varchar_key 6 test.parent1.col_varchar_nokey 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`g1` AS `g1` from `test`.`t1` anti join (`test`.`t2` `grandparent1` join `test`.`t2` `parent1` left join `test`.`t3` `parent2` on((`test`.`parent2`.`pk` = `test`.`parent1`.`pk`))) on(((`test`.`grandparent1`.`col_varchar_nokey` = `test`.`t1`.`g1`) and (`test`.`grandparent1`.`col_varchar_key` = `test`.`parent1`.`col_varchar_nokey`) and (`test`.`grandparent1`.`col_varchar_key` is not null))) where true +SELECT * +FROM t1 +WHERE g1 NOT IN +(SELECT grandparent1.col_varchar_nokey AS g1 +FROM t2 AS grandparent1 +WHERE grandparent1.col_varchar_key IN +(SELECT parent1.col_varchar_nokey AS p1 +FROM t2 AS parent1 LEFT JOIN t3 AS parent2 USING (pk) +) +AND grandparent1.col_varchar_key IS NOT NULL +); +g1 +DROP TABLE t1, t2, t3; +CREATE TABLE t1 ( +pk INTEGER AUTO_INCREMENT, +col_int_key INTEGER , +col_varchar_key VARCHAR(1) , +col_varchar_nokey VARCHAR(1) , +PRIMARY KEY (pk), +KEY (col_varchar_key,col_int_key) +) ENGINE=INNODB; +INSERT INTO t1 (col_int_key,col_varchar_key,col_varchar_nokey) VALUES +(0,'x','x'), (1,'j','j'), (1,'r','r'), (9,'v','v'), (5,'r','r'); +CREATE TABLE t2 ( +pk INTEGER AUTO_INCREMENT, +col_int_key INTEGER , +col_varchar_key VARCHAR(1) , +col_varchar_nokey VARCHAR(1) , +PRIMARY KEY (pk), +KEY (col_int_key), +KEY (col_varchar_key,col_int_key) +) AUTO_INCREMENT=10 ENGINE=INNODB; +INSERT INTO t2 (col_int_key, col_varchar_key, col_varchar_nokey) VALUES +(NULL,'x','x'), (NULL,'j','j'), (8,'c','c'); +CREATE TABLE t3 +SELECT outr.col_varchar_nokey AS x +FROM t1 AS outr +WHERE outr.col_varchar_nokey IN +(SELECT innr.col_varchar_nokey AS y +FROM t2 AS innr +WHERE innr.col_int_key IS NULL) +AND outr.col_varchar_nokey IS NOT NULL +AND NOT col_varchar_key IS NULL; +SELECT * +FROM t3 +WHERE x NOT IN +(SELECT outr.col_varchar_nokey AS x +FROM t1 AS outr +WHERE outr.col_varchar_nokey IN +(SELECT innr.col_varchar_nokey AS y +FROM t2 AS innr +WHERE innr.col_int_key IS NULL) +AND outr.col_varchar_nokey IS NOT NULL +AND NOT col_varchar_key IS NULL); +x +DROP TABLE t1, t2, t3; +# End of test for bug#12797534. +# +# Bug#12714094: Assert in optimize_semijoin_nests() +# +CREATE TABLE it ( +pk int NOT NULL, +col_varchar VARCHAR(10) DEFAULT NULL, +PRIMARY KEY (pk) +) ENGINE=MyISAM; +INSERT INTO it VALUES (1, 'g'); +CREATE TABLE ot +SELECT alias1.pk AS field1 +FROM it AS alias1 +LEFT JOIN it AS alias2 +ON alias1.col_varchar = alias2.col_varchar +; +SELECT * +FROM ot +WHERE field1 IN ( +SELECT alias1.pk +FROM it AS alias1 +LEFT JOIN it AS alias2 +ON alias1.col_varchar = alias2.col_varchar +); +field1 +1 +DROP TABLE it, ot; +# End of test for bug#12714094 +# +# Bug#12867557: Valgrind: conditional jump/move at key_cmp +# +CREATE TABLE t1 ( +pk INTEGER AUTO_INCREMENT, +col_int_key INTEGER, +PRIMARY KEY (pk), +KEY (col_int_key) +) AUTO_INCREMENT=10; +INSERT INTO t1 (col_int_key) VALUES (8); +CREATE TABLE t2 ( +pk INTEGER AUTO_INCREMENT, +col_int_key INTEGER, +col_time_key TIME, +PRIMARY KEY (pk), +KEY (col_int_key), +KEY (col_time_key) +) AUTO_INCREMENT=10; +INSERT INTO t2 (col_int_key, col_time_key) +VALUES +(8, '22:55:23.019225'), (7, '10:19:31.050677'), (1, '14:40:36.038608'), +(7, '04:37:47.062416'), (9, '19:34:06.054514'), (NULL,'20:35:33.022996'), +(1, NULL), (9, '14:43:37.057393'), (2, '02:23:09.043438'), +(9, '01:22:45.041064'), (2, '00:00:00'), (4, '00:13:25.038482'), +(0, '03:47:16.042671'), (4, '01:41:48.007423'), (8, '00:00:00'), +(NULL, '22:32:04.047407'), (NULL, '16:44:14.028443'), (0, '17:38:37.059754'), +(NULL, '08:46:48.042388'), (8, '14:11:27.044095'); +CREATE TABLE t0 +SELECT DISTINCT grandparent1.col_time_key AS g1 +FROM t2 AS grandparent1 +WHERE grandparent1.col_int_key IN +(SELECT parent1.col_int_key AS p1 +FROM t1 AS parent1) +AND grandparent1.pk > 9; +UPDATE t0 +SET g1 = g1 +WHERE g1 IN +(SELECT grandparent1.col_time_key AS g1 +FROM t2 AS grandparent1 +WHERE grandparent1.col_int_key IN +(SELECT parent1.col_int_key AS p1 +FROM t1 AS parent1) +AND grandparent1.pk > 9); +DROP TABLE t0, t1, t2; +# End of test for bug#12867557 +# +# Bug#12711441: crash in fix_after_pullout +# +CREATE TABLE t1 ( +pk int NOT NULL, +col_int_nokey int DEFAULT NULL, +col_int_key int DEFAULT NULL, +col_time_key time DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +PRIMARY KEY (pk) +); +CREATE VIEW v1 AS SELECT * FROM t1; +CREATE TABLE t2 ( +col_int_key int DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +KEY col_varchar_key(col_varchar_key, col_int_key) +); +CREATE TABLE t3 ( +pk int NOT NULL, +col_int_key INT DEFAULT NULL, +PRIMARY KEY (pk) +); +CREATE TABLE t4 ( +col_int_nokey INT DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +KEY col_varchar_key(col_varchar_key) +); +CREATE TABLE ts +SELECT alias1.col_time_key AS field1 +FROM v1 AS alias1 +RIGHT JOIN t3 AS alias2 +ON alias2.col_int_key = alias1.col_int_nokey +WHERE alias1.pk >= SOME( +SELECT SQ1_alias1.pk AS SQ1_field1 +FROM t3 AS SQ1_alias1 +INNER JOIN (t2 AS SQ1_alias2 +INNER JOIN t4 AS SQ1_alias3 +ON SQ1_alias3.col_varchar_key = SQ1_alias2.col_varchar_nokey) +ON SQ1_alias3.col_int_nokey = SQ1_alias2.col_int_key +WHERE SQ1_alias2.col_varchar_key <= alias1.col_varchar_key +AND SQ1_alias3.col_varchar_nokey <> alias1.col_varchar_key) +; +SELECT * FROM ts WHERE field1 IN ( +SELECT alias1.col_time_key AS field1 +FROM v1 AS alias1 +RIGHT JOIN t3 AS alias2 +ON alias2.col_int_key = alias1.col_int_nokey +WHERE alias1.pk >= SOME( +SELECT SQ1_alias1.pk AS SQ1_field1 +FROM t3 AS SQ1_alias1 +INNER JOIN (t2 AS SQ1_alias2 +INNER JOIN t4 AS SQ1_alias3 +ON SQ1_alias3.col_varchar_key = SQ1_alias2.col_varchar_nokey) +ON SQ1_alias3.col_int_nokey = SQ1_alias2.col_int_key +WHERE SQ1_alias2.col_varchar_key <= alias1.col_varchar_key +AND SQ1_alias3.col_varchar_nokey <> alias1.col_varchar_key) +); +field1 +DROP TABLE t1, t2, t3, t4, ts; +DROP VIEW v1; +# End of test for bug#12711441. +# +# Bug#12664936: Same query executed as where subquery ... +# +CREATE TABLE t1 ( +col_varchar_key VARCHAR(1), +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4; +INSERT INTO t1 VALUES +('o'), ('w'), ('m'), ('q'), +('f'), ('p'), ('j'), ('c'); +CREATE TABLE t2 ( +col_int_nokey INTEGER, +col_int_key INTEGER, +col_varchar_key varchar(1), +KEY col_int_key (col_int_key) +) charset utf8mb4; +INSERT INTO t2 VALUES +(8,5,'u'),(4,5,'p'),(8,1,'o'),(NULL,7,'v'), +(1,2,'g'),(2,1,'q'),(NULL,7,'l'),(3,1,'n'); +CREATE TABLE t4 +SELECT t2.col_int_nokey, t2.col_varchar_key +FROM t1 JOIN t2 ON t2.col_varchar_key = t1.col_varchar_key +WHERE t2.col_int_key = 1; +EXPLAIN SELECT * +FROM t4 +WHERE (col_int_nokey, col_varchar_key) IN +(SELECT t2.col_int_nokey, t2.col_varchar_key +FROM t1 JOIN t2 ON t2.col_varchar_key = t1.col_varchar_key +WHERE t2.col_int_key = 1 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t4 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE t2 NULL ref col_int_key col_int_key 5 const 3 12.50 Using where +1 SIMPLE t1 NULL ref col_varchar_key col_varchar_key 7 test.t4.col_varchar_key 2 100.00 Using index; FirstMatch(t4) +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`col_int_nokey` AS `col_int_nokey`,`test`.`t4`.`col_varchar_key` AS `col_varchar_key` from `test`.`t4` semi join (`test`.`t1` join `test`.`t2`) where ((`test`.`t2`.`col_varchar_key` = `test`.`t4`.`col_varchar_key`) and (`test`.`t1`.`col_varchar_key` = `test`.`t4`.`col_varchar_key`) and (`test`.`t2`.`col_int_nokey` = `test`.`t4`.`col_int_nokey`) and (`test`.`t2`.`col_int_key` = 1)) +SELECT * +FROM t4 +WHERE (col_int_nokey, col_varchar_key) IN +(SELECT t2.col_int_nokey, t2.col_varchar_key +FROM t1 JOIN t2 ON t2.col_varchar_key = t1.col_varchar_key +WHERE t2.col_int_key = 1 +); +col_int_nokey col_varchar_key +8 o +2 q +DROP TABLE t1, t2, t4; +# End of test for bug#12664936. +# +# Bug#13340270: assertion table->sort.record_pointers == __null +# +CREATE TABLE t1 ( +pk int NOT NULL, +col_int_key int DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key, col_int_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t1 VALUES +(10,8,'x','x'), +(11,7,'d','d'), +(12,1,'r','r'), +(13,7,'f','f'), +(14,9,'y','y'), +(15,NULL,'u','u'), +(16,1,'m','m'), +(17,9,NULL,NULL), +(18,2,'o','o'), +(19,9,'w','w'), +(20,2,'m','m'), +(21,4,'q','q'); +CREATE TABLE t2 +SELECT alias1.col_varchar_nokey AS field1 +FROM t1 AS alias1 JOIN t1 AS alias2 +ON alias2.col_int_key = alias1.pk OR +alias2.col_int_key = alias1.col_int_key +WHERE alias1.pk = 58 OR alias1.col_varchar_key = 'o' + +; +EXPLAIN SELECT * +FROM t2 +WHERE (field1) IN (SELECT alias1.col_varchar_nokey AS field1 +FROM t1 AS alias1 JOIN t1 AS alias2 +ON alias2.col_int_key = alias1.pk OR +alias2.col_int_key = alias1.col_int_key +WHERE alias1.pk = 58 OR alias1.col_varchar_key = 'o' +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE alias1 NULL index_merge PRIMARY,col_int_key,col_varchar_key col_varchar_key,PRIMARY 7,4 NULL 2 10.00 Using sort_union(col_varchar_key,PRIMARY); Using where +1 SIMPLE alias2 NULL ALL col_int_key NULL NULL NULL 12 19.00 Range checked for each record (index map: 0x2); FirstMatch(t2) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`field1` AS `field1` from `test`.`t2` semi join (`test`.`t1` `alias1` join `test`.`t1` `alias2`) where ((`test`.`alias1`.`col_varchar_nokey` = `test`.`t2`.`field1`) and ((`test`.`alias1`.`pk` = 58) or (`test`.`alias1`.`col_varchar_key` = 'o')) and ((`test`.`alias2`.`col_int_key` = `test`.`alias1`.`pk`) or (`test`.`alias2`.`col_int_key` = `test`.`alias1`.`col_int_key`))) +SELECT * +FROM t2 +WHERE (field1) IN (SELECT alias1.col_varchar_nokey AS field1 +FROM t1 AS alias1 JOIN t1 AS alias2 +ON alias2.col_int_key = alias1.pk OR +alias2.col_int_key = alias1.col_int_key +WHERE alias1.pk = 58 OR alias1.col_varchar_key = 'o' +); +field1 +o +o +DROP TABLE t1, t2; +# End of test for bug#13340270. +# +# Bug#13335319: Seg fault when analyzing FirstMatch semi-join strategy +# +CREATE TABLE ot1(a INTEGER); +INSERT INTO ot1 VALUES(1), (2), (3); +CREATE TABLE ot2(a INTEGER); +INSERT INTO ot2 VALUES(1), (2), (4), (6), (8), (10); +CREATE TABLE it1(a INTEGER); +INSERT INTO it1 VALUES(1), (3), (5), (7); +CREATE TABLE it2(a INTEGER); +INSERT INTO it2 VALUES(1), (3), (5), (7), (9); +explain SELECT ot1.a, ot2.a +FROM ot1, ot2 +WHERE ot1.a IN (SELECT a FROM it1) AND +ot2.a IN (SELECT a FROM it2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE it1 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; FirstMatch(ot1); Using join buffer (hash join) +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 6 100.00 Using join buffer (hash join) +1 SIMPLE it2 NULL ALL NULL NULL NULL NULL 5 20.00 Using where; FirstMatch(ot2); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` join `test`.`ot2` semi join (`test`.`it1`) semi join (`test`.`it2`) where ((`test`.`it2`.`a` = `test`.`ot2`.`a`) and (`test`.`it1`.`a` = `test`.`ot1`.`a`)) +SELECT ot1.a, ot2.a +FROM ot1, ot2 +WHERE ot1.a IN (SELECT a FROM it1) AND +ot2.a IN (SELECT a FROM it2); +a a +1 1 +3 1 +DROP TABLE ot1, ot2, it1, it2; +# End of test for bug#13335319. +# +# Bug#13334882: Assertion keypart_map failed in MyIsam function +# +CREATE TABLE t1 ( +pk int NOT NULL, +col_int_nokey INT NOT NULL, +col_int_key INT NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +) ENGINE=MyISAM; +INSERT INTO t1 VALUES +(1,4,0), +(2,6,8), +(3,3,1), +(7,2,6), +(8,9,1), +(9,3,6), +(10,8,2), +(11,1,4), +(12,8,8), +(13,8,4), +(14,5,4); +CREATE TABLE t2 ( +pk int NOT NULL, +col_int_nokey int NOT NULL, +col_int_key int NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +) ENGINE=MyISAM; +INSERT INTO t2 VALUES +(10,8,7); +CREATE TABLE t3 +SELECT grandparent1.col_int_nokey AS g1 +FROM t1 AS grandparent1 +WHERE (grandparent1.col_int_nokey, grandparent1.col_int_key) IN +(SELECT parent1.col_int_key AS p1, +parent1.col_int_key AS p2 +FROM t1 AS parent1 +LEFT JOIN t2 AS parent2 +ON parent1.col_int_nokey = parent2.col_int_key +) +AND grandparent1.col_int_key <> 3 +; +explain SELECT * FROM t3 +WHERE g1 NOT IN +(SELECT grandparent1.col_int_nokey AS g1 +FROM t1 AS grandparent1 +WHERE (grandparent1.col_int_nokey, grandparent1.col_int_key) IN +(SELECT parent1.col_int_key AS p1, +parent1.col_int_key AS p2 +FROM t1 AS parent1 +LEFT JOIN t2 AS parent2 +ON parent1.col_int_nokey = parent2.col_int_key +) +AND grandparent1.col_int_key <> 3 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE grandparent1 NULL ref col_int_key col_int_key 4 const 1 100.00 Using where; Not exists +1 SIMPLE parent1 NULL ref col_int_key col_int_key 4 test.grandparent1.col_int_nokey 1 100.00 Using where +1 SIMPLE parent2 NULL ref col_int_key col_int_key 4 test.parent1.col_int_nokey 2 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select '8' AS `g1` from anti join (`test`.`t1` `grandparent1` join `test`.`t1` `parent1` left join `test`.`t2` `parent2` on((`test`.`parent2`.`col_int_key` = `test`.`parent1`.`col_int_nokey`))) on(((`test`.`grandparent1`.`col_int_nokey` = '8') and (`test`.`grandparent1`.`col_int_key` = '8') and (`test`.`parent1`.`col_int_key` = '8') and ('8' <> 3))) where true +explain format=json SELECT * FROM t3 +WHERE g1 NOT IN +(SELECT grandparent1.col_int_nokey AS g1 +FROM t1 AS grandparent1 +WHERE (grandparent1.col_int_nokey, grandparent1.col_int_key) IN +(SELECT parent1.col_int_key AS p1, +parent1.col_int_key AS p2 +FROM t1 AS parent1 +LEFT JOIN t2 AS parent2 +ON parent1.col_int_nokey = parent2.col_int_key +) +AND grandparent1.col_int_key <> 3 +); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.36" + }, + "nested_loop": [ + { + "table": { + "table_name": "t3", + "access_type": "system", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.00", + "eval_cost": "0.10", + "prefix_cost": "0.00", + "data_read_per_join": "8" + }, + "used_columns": [ + "g1" + ] + } + }, + { + "table": { + "table_name": "grandparent1", + "access_type": "ref", + "possible_keys": [ + "col_int_key" + ], + "key": "col_int_key", + "used_key_parts": [ + "col_int_key" + ], + "key_length": "4", + "ref": [ + "const" + ], + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "not_exists": true, + "cost_info": { + "read_cost": "0.28", + "eval_cost": "0.11", + "prefix_cost": "0.39", + "data_read_per_join": "17" + }, + "used_columns": [ + "col_int_nokey", + "col_int_key" + ], + "attached_condition": "(((is_not_null_compl(grandparent1..parent2), (found_match(grandparent1..parent2), false, true), true) and (is_not_null_compl(grandparent1..parent2), (('8' <> 3)), true)) and (is_not_null_compl(grandparent1..parent2), (`test`.`grandparent1`.`col_int_nokey` = '8'), true))" + } + }, + { + "table": { + "table_name": "parent1", + "access_type": "ref", + "possible_keys": [ + "col_int_key" + ], + "key": "col_int_key", + "used_key_parts": [ + "col_int_key" + ], + "key_length": "4", + "ref": [ + "test.grandparent1.col_int_nokey" + ], + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.30", + "eval_cost": "0.12", + "prefix_cost": "0.81", + "data_read_per_join": "19" + }, + "used_columns": [ + "col_int_nokey", + "col_int_key" + ], + "attached_condition": "(is_not_null_compl(grandparent1..parent2), (`test`.`parent1`.`col_int_key` = '8'), true)" + } + }, + { + "table": { + "table_name": "parent2", + "access_type": "ref", + "possible_keys": [ + "col_int_key" + ], + "key": "col_int_key", + "used_key_parts": [ + "col_int_key" + ], + "key_length": "4", + "ref": [ + "test.parent1.col_int_nokey" + ], + "rows_examined_per_scan": 2, + "rows_produced_per_join": 1, + "filtered": "100.00", + "using_index": true, + "cost_info": { + "read_cost": "0.31", + "eval_cost": "0.10", + "prefix_cost": "1.36", + "data_read_per_join": "16" + }, + "used_columns": [ + "col_int_key" + ] + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select '8' AS `g1` from anti join (`test`.`t1` `grandparent1` join `test`.`t1` `parent1` left join `test`.`t2` `parent2` on((`test`.`parent2`.`col_int_key` = `test`.`parent1`.`col_int_nokey`))) on(((`test`.`grandparent1`.`col_int_nokey` = '8') and (`test`.`grandparent1`.`col_int_key` = '8') and (`test`.`parent1`.`col_int_key` = '8') and ('8' <> 3))) where true +SELECT * FROM t3 +WHERE g1 NOT IN +(SELECT grandparent1.col_int_nokey AS g1 +FROM t1 AS grandparent1 +WHERE (grandparent1.col_int_nokey, grandparent1.col_int_key) IN +(SELECT parent1.col_int_key AS p1, +parent1.col_int_key AS p2 +FROM t1 AS parent1 +LEFT JOIN t2 AS parent2 +ON parent1.col_int_nokey = parent2.col_int_key +) +AND grandparent1.col_int_key <> 3 +); +g1 +DROP TABLE t1, t2, t3; +# End of test for bug#13334882. +# +# Bug#13339643: Assertion on JOIN::flatten_subqueries on second execution +# +CREATE TABLE t1 ( +col_int_nokey INT, +col_varchar_nokey VARCHAR(1) +) charset utf8mb4; +INSERT INTO t1 VALUES +(1,'o'), +(2,'t'); +CREATE TABLE t2 LIKE t1; +INSERT INTO t2 VALUES +(1,'o'), +(4,'f'); +CREATE VIEW v_t2 AS SELECT * FROM t2; +CREATE TABLE t3 LIKE t1; +INSERT INTO t3 VALUES +(1,'o'), +(4,'f'); +explain SELECT alias1.col_varchar_nokey +FROM t1 AS alias1 +INNER JOIN v_t2 AS alias2 +ON alias2.col_int_nokey = alias1.col_int_nokey AND +'o' IN (SELECT col_varchar_nokey +FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch +1 SIMPLE alias1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`alias1`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t1` `alias1` join `test`.`t2` semi join (`test`.`t3`) where ((`test`.`t3`.`col_varchar_nokey` = 'o') and (`test`.`t2`.`col_int_nokey` = `test`.`alias1`.`col_int_nokey`)) +SELECT alias1.col_varchar_nokey +FROM t1 AS alias1 +INNER JOIN v_t2 AS alias2 +ON alias2.col_int_nokey = alias1.col_int_nokey AND +'o' IN (SELECT col_varchar_nokey +FROM t3); +col_varchar_nokey +o +PREPARE stmt FROM "SELECT alias1.col_varchar_nokey +FROM t1 AS alias1 +INNER JOIN v_t2 AS alias2 +ON alias2.col_int_nokey = alias1.col_int_nokey AND +'o' IN (SELECT col_varchar_nokey +FROM t3)"; +EXECUTE stmt; +col_varchar_nokey +o +DROP VIEW v_t2; +DROP TABLE t1, t2, t3; +# End of test for bug#13339643. +# +# Bug#13424134: Wrong result on JOIN + nested WHERE ... IN clauses +# +CREATE TABLE t1 ( +pk int NOT NULL, +col_int_nokey int NOT NULL, +col_int_key int NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +) ENGINE=MyIsam; +INSERT INTO t1 VALUES +(10,1,7), (13,7,3), (18,0,1), (23,8,1); +CREATE TABLE t2 ( +pk int NOT NULL, +col_int_key int NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +) ENGINE=MyIsam; +INSERT INTO t2 VALUES (1,7); +EXPLAIN SELECT t1a.* +FROM t1 AS t1a +JOIN t1 AS t1b USING ( col_int_nokey ) +WHERE t1a.col_int_key IN ( +SELECT pk +FROM t2 +WHERE col_int_key IN ( +SELECT col_int_nokey +FROM t1 +) +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL system PRIMARY,col_int_key NULL NULL NULL 1 100.00 NULL +1 SIMPLE t1a NULL ref col_int_key col_int_key 4 const 1 100.00 NULL +1 SIMPLE t1b NULL ALL NULL NULL NULL NULL 4 25.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; FirstMatch(t1b); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1a`.`pk` AS `pk`,`test`.`t1a`.`col_int_nokey` AS `col_int_nokey`,`test`.`t1a`.`col_int_key` AS `col_int_key` from `test`.`t1` `t1a` join `test`.`t1` `t1b` semi join (`test`.`t1`) where ((`test`.`t1b`.`col_int_nokey` = `test`.`t1a`.`col_int_nokey`) and (`test`.`t1a`.`col_int_key` = '1') and (`test`.`t1`.`col_int_nokey` = '7')) +SELECT t1a.* +FROM t1 AS t1a +JOIN t1 AS t1b USING ( col_int_nokey ) +WHERE t1a.col_int_key IN ( +SELECT pk +FROM t2 +WHERE col_int_key IN ( +SELECT col_int_nokey +FROM t1 +) +); +pk col_int_nokey col_int_key +18 0 1 +23 8 1 +ALTER TABLE t1 ENGINE=Innodb; +ALTER TABLE t2 ENGINE=Innodb; +SELECT t1a.* +FROM t1 AS t1a +JOIN t1 AS t1b USING ( col_int_nokey ) +WHERE t1a.col_int_key IN ( +SELECT pk +FROM t2 +WHERE col_int_key IN ( +SELECT col_int_nokey +FROM t1 +) +); +pk col_int_nokey col_int_key +18 0 1 +23 8 1 +DROP TABLE t1, t2; +# End of test for bug#13424134. +# +# Bug#13414014: Extra rows in result on semijoin query with where ... +# +CREATE TABLE t1 ( +c INT, +d INT, +a VARCHAR(1), +b VARCHAR(1), +KEY a (a) +) charset utf8mb4; +INSERT INTO t1 VALUES +(NULL,8,'x','x'), (7,4,'q','q'), (6,8,'c','c'); +CREATE TABLE t2 ( +a VARCHAR(1), +KEY a (a) +) charset utf8mb4; +INSERT INTO t2 VALUES +('c'), (NULL), ('x'), ('q'); +explain SELECT * +FROM t2 AS ot +WHERE (a, a) IN +(SELECT a, b +FROM t1 AS it +WHERE it.a = 'x' OR it.c > it.d +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot NULL index a a 7 NULL 4 100.00 Using index +1 SIMPLE it NULL ALL a NULL NULL NULL 3 33.33 Using where; FirstMatch(ot); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot`.`a` AS `a` from `test`.`t2` `ot` semi join (`test`.`t1` `it`) where ((`test`.`it`.`a` = `test`.`ot`.`a`) and (`test`.`it`.`b` = `test`.`ot`.`a`) and ((`test`.`ot`.`a` = 'x') or (`test`.`it`.`c` > `test`.`it`.`d`))) +SELECT * +FROM t2 AS ot +WHERE (a, a) IN +(SELECT a, b +FROM t1 AS it +WHERE it.a = 'x' OR it.c > it.d +) +; +a +q +x +DROP TABLE t1, t2; +# End of test for bug#13414014. +# +# Bug#13545215: Missing rows on nested in-subquery with materialization +# +CREATE TABLE t1 ( +col_int_key int, +col_varchar_key varchar(1), +col_varchar_nokey varchar(1), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +INSERT INTO t1 VALUES +(8,'x','x'), (0,'p','p'), (8,'c','c'); +CREATE TABLE t2 ( +pk int NOT NULL, +col_varchar_key varchar(1), +col_varchar_nokey varchar(1), +PRIMARY KEY (pk), +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4; +INSERT INTO t2 VALUES +(1,'v','v'), (2,'v','v'), (3,'c','c'), (4,NULL,NULL), +(5,'x','x'), (6,'i','i'), (7,'e','e'), (8,'p','p'); +CREATE TABLE t3 ( +col_int_nokey int +); +INSERT INTO t3 VALUES (7); +explain SELECT grandparent1.col_varchar_nokey +FROM t1 AS grandparent1 JOIN t1 AS grandparent2 USING (col_int_key) +WHERE grandparent1.col_varchar_key IN ( +SELECT col_varchar_nokey +FROM t2 AS parent1 +WHERE col_varchar_key IN ( +SELECT child1.col_varchar_nokey +FROM t2 AS child1 LEFT JOIN t3 AS child2 +ON child1.pk < child2.col_int_nokey +) +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE grandparent1 NULL ALL col_int_key,col_varchar_key NULL NULL NULL 3 100.00 Using where +1 SIMPLE parent1 NULL ALL col_varchar_key NULL NULL NULL 8 12.50 Using where +1 SIMPLE child1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where +1 SIMPLE child2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(grandparent1) +1 SIMPLE grandparent2 NULL ref col_int_key col_int_key 5 test.grandparent1.col_int_key 2 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`grandparent1`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t1` `grandparent1` join `test`.`t1` `grandparent2` semi join (`test`.`t2` `parent1` join `test`.`t2` `child1` left join `test`.`t3` `child2` on((`test`.`child1`.`pk` < `test`.`child2`.`col_int_nokey`))) where ((`test`.`grandparent2`.`col_int_key` = `test`.`grandparent1`.`col_int_key`) and (`test`.`parent1`.`col_varchar_nokey` = `test`.`grandparent1`.`col_varchar_key`) and (`test`.`child1`.`col_varchar_nokey` = `test`.`parent1`.`col_varchar_key`)) +SELECT grandparent1.col_varchar_nokey +FROM t1 AS grandparent1 JOIN t1 AS grandparent2 USING (col_int_key) +WHERE grandparent1.col_varchar_key IN ( +SELECT col_varchar_nokey +FROM t2 AS parent1 +WHERE col_varchar_key IN ( +SELECT child1.col_varchar_nokey +FROM t2 AS child1 LEFT JOIN t3 AS child2 +ON child1.pk < child2.col_int_nokey +) +); +col_varchar_nokey +c +c +p +x +x +DROP TABLE t1, t2, t3; +# End of test for bug#13545215. +# +# BUG#13553211 - MISSING ROWS ON SELECT WITH IN-SUBQUERY AND +# MATERIALIZATION + SEMIJOIN ON +# +CREATE TABLE t1 ( +col_int_key int(11) DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (4,'v','v'); +INSERT INTO t1 VALUES (62,'v','v'); +INSERT INTO t1 VALUES (7,'c','c'); +INSERT INTO t1 VALUES (1,NULL,NULL); +EXPLAIN SELECT +alias1.col_varchar_nokey AS a1_nokey, +alias1.col_varchar_key AS a1_key, +alias2.col_varchar_nokey AS a2_nokey +FROM +t1 AS alias1, t1 AS alias2 +WHERE +(alias1.col_varchar_nokey,alias2.col_varchar_nokey) +IN +( +SELECT +sq2_alias2.col_varchar_nokey, sq2_alias1.col_varchar_key +FROM +t1 AS sq2_alias1, t1 AS sq2_alias2 +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE alias1 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +1 SIMPLE alias2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (hash join) +1 SIMPLE sq2_alias1 NULL ref col_varchar_key col_varchar_key 7 test.alias2.col_varchar_nokey 2 100.00 Using index +1 SIMPLE sq2_alias2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; FirstMatch(alias2) +Warnings: +Note 1003 /* select#1 */ select `test`.`alias1`.`col_varchar_nokey` AS `a1_nokey`,`test`.`alias1`.`col_varchar_key` AS `a1_key`,`test`.`alias2`.`col_varchar_nokey` AS `a2_nokey` from `test`.`t1` `alias1` join `test`.`t1` `alias2` semi join (`test`.`t1` `sq2_alias1` join `test`.`t1` `sq2_alias2`) where ((`test`.`sq2_alias1`.`col_varchar_key` = `test`.`alias2`.`col_varchar_nokey`) and (`test`.`sq2_alias2`.`col_varchar_nokey` = `test`.`alias1`.`col_varchar_nokey`)) +SELECT +alias1.col_varchar_nokey AS a1_nokey, +alias1.col_varchar_key AS a1_key, +alias2.col_varchar_nokey AS a2_nokey +FROM +t1 AS alias1, t1 AS alias2 +WHERE +(alias1.col_varchar_nokey,alias2.col_varchar_nokey) +IN +( +SELECT +sq2_alias2.col_varchar_nokey, sq2_alias1.col_varchar_key +FROM +t1 AS sq2_alias1, t1 AS sq2_alias2 +) +; +a1_nokey a1_key a2_nokey +c c c +c c v +c c v +v v c +v v c +v v v +v v v +v v v +v v v +DROP TABLE t1; +# +# Bug#13541406: Wrong result with loosescan on select .. where .. in +# +CREATE TABLE t1 ( +col_int_key INT NOT NULL, +col_varchar_nokey VARCHAR(1) NOT NULL, +KEY col_int_key (col_int_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t1 VALUES +(7,'v'), (0,'s'), (9,'l'), (3,'y'), (4,'c'), (2,'i'), (5,'h'), (3,'q'), +(1,'a'), (3,'v'), (6,'u'), (7,'s'), (5,'y'), (1,'z'), (204,'h'), (224,'p'), +(9,'e'), (5,'i'), (0,'y'), (3,'w'); +CREATE TABLE t2 ( +pk INT NOT NULL, +col_int_key INT NOT NULL, +col_varchar_key VARCHAR(1) NOT NULL, +col_varchar_nokey VARCHAR(1) NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t2 VALUES +(1,0,'j','j'), (2,8,'v','v'), (3,1,'c','c'), (4,8,'m','m'), +(5,9,'d','d'), (6,24,'d','d'), (7,6,'y','y'), (8,1,'t','t'), +(9,6,'d','d'), (10,2,'s','s'), (11,4,'r','r'), (12,8,'m','m'), +(13,4,'b','b'), (14,4,'x','x'), (15,7,'g','g'), (16,4,'p','p'), +(17,1,'q','q'), (18,9,'w','w'), (19,4,'d','d'), (20,8,'e','e'); +# This query should never use a LooseScan strategy +explain SELECT ot1.col_int_key AS field1 +FROM t2 AS ot1, t2 AS ot2 +WHERE (ot1.col_varchar_key, ot2.col_varchar_nokey) IN ( +SELECT it2.col_varchar_nokey, it1.col_varchar_key +FROM t2 AS it1 JOIN t1 AS it2 ON it2.col_int_key = it1.pk); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 20 100.00 Parallel execute (1 workers) +2 SIMPLE ot1 NULL index col_varchar_key col_varchar_key 10 NULL 20 100.00 Using index +2 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 20 100.00 Using join buffer (hash join) +2 SIMPLE it1 NULL ref PRIMARY,col_varchar_key col_varchar_key 6 test.ot2.col_varchar_nokey 1 100.00 Using index +2 SIMPLE it2 NULL ref col_int_key col_int_key 4 test.it1.pk 1 10.00 Using where; FirstMatch(ot2) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`col_int_key` AS `field1` from `test`.`t2` `ot1` join `test`.`t2` `ot2` semi join (`test`.`t2` `it1` join `test`.`t1` `it2`) where ((`test`.`it2`.`col_int_key` = `test`.`it1`.`pk`) and (`test`.`it1`.`col_varchar_key` = `test`.`ot2`.`col_varchar_nokey`) and (`test`.`it2`.`col_varchar_nokey` = `test`.`ot1`.`col_varchar_key`)) +SELECT ot1.col_int_key AS field1 +FROM t2 AS ot1, t2 AS ot2 +WHERE (ot1.col_varchar_key, ot2.col_varchar_nokey) IN ( +SELECT it2.col_varchar_nokey, it1.col_varchar_key +FROM t2 AS it1 JOIN t1 AS it2 ON it2.col_int_key = it1.pk); +field1 +1 +1 +1 +2 +6 +6 +6 +6 +6 +8 +8 +8 +8 +8 +8 +9 +DROP TABLE t1, t2; +# End of test for bug#13541406. +# +# Bug#13576391: Missing rows on select with in-subquery and +# batched-key-access=on and semijoin +# +CREATE TABLE t1 ( +col_int_nokey int NOT NULL, +col_varchar_key varchar(1) NOT NULL, +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4 engine=InnoDB; +INSERT INTO t1 VALUES +(1,'v'), (7,'s'), (4,'l'), (7,'y'), (0,'c'), (2,'i'), (9,'h'), (4,'q'), +(0,'a'), (9,'v'), (1,'u'), (3,'s'), (8,'y'), (8,'z'), (18,'h'), (84,'p'), +(6,'e'), (3,'i'), (6,'y'), (6,'w'); +CREATE TABLE t2 ( +col_int_nokey int NOT NULL, +col_varchar_nokey varchar(1) NOT NULL +) charset utf8mb4 engine=InnoDB; +INSERT INTO t2 VALUES +(4,'j'), (6,'v'), (3,'c'), (5,'m'), (3,'d'), (246,'d'), (2,'y'), (9,'t'), +(3,'d'), (8,'s'), (1,'r'), (8,'m'), (8,'b'), (5,'x'), (7,'g'), (5,'p'), +(1,'q'), (6,'w'), (2,'d'), (9,'e'); +explain SELECT col_varchar_nokey +FROM t2 AS ot +WHERE col_varchar_nokey IN ( +SELECT col_varchar_key +FROM t1 AS it +WHERE it.col_int_nokey <= it.col_int_nokey +AND NOT ot.col_int_nokey < 2 +) +ORDER BY col_varchar_nokey; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 20 33.33 Parallel execute (1 workers) +2 SIMPLE ot NULL ALL NULL NULL NULL NULL 20 33.33 Using where; Using filesort +2 SIMPLE it NULL ref col_varchar_key col_varchar_key 6 test.ot.col_varchar_nokey 1 100.00 FirstMatch(ot) +Warnings: +Note 1276 Field or reference 'test.ot.col_int_nokey' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`ot`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t2` `ot` semi join (`test`.`t1` `it`) where ((`test`.`it`.`col_varchar_key` = `test`.`ot`.`col_varchar_nokey`) and (`test`.`ot`.`col_int_nokey` >= 2)) order by `test`.`ot`.`col_varchar_nokey` +SELECT col_varchar_nokey +FROM t2 AS ot +WHERE col_varchar_nokey IN ( +SELECT col_varchar_key +FROM t1 AS it +WHERE it.col_int_nokey <= it.col_int_nokey +AND NOT ot.col_int_nokey < 2 +) +ORDER BY col_varchar_nokey; +col_varchar_nokey +c +e +p +s +v +w +y +ALTER TABLE t1 ENGINE=MyISAM; +ALTER TABLE t2 ENGINE=MyISAM; +explain SELECT col_varchar_nokey +FROM t2 AS ot +WHERE col_varchar_nokey IN ( +SELECT col_varchar_key +FROM t1 AS it +WHERE it.col_int_nokey <= it.col_int_nokey +AND NOT ot.col_int_nokey < 2 +) +ORDER BY col_varchar_nokey; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 20 33.33 Using where; Using filesort +1 SIMPLE it NULL ref col_varchar_key col_varchar_key 6 test.ot.col_varchar_nokey 2 100.00 FirstMatch(ot) +Warnings: +Note 1276 Field or reference 'test.ot.col_int_nokey' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`ot`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t2` `ot` semi join (`test`.`t1` `it`) where ((`test`.`it`.`col_varchar_key` = `test`.`ot`.`col_varchar_nokey`) and (`test`.`ot`.`col_int_nokey` >= 2)) order by `test`.`ot`.`col_varchar_nokey` +SELECT col_varchar_nokey +FROM t2 AS ot +WHERE col_varchar_nokey IN ( +SELECT col_varchar_key +FROM t1 AS it +WHERE it.col_int_nokey <= it.col_int_nokey +AND NOT ot.col_int_nokey < 2 +) +ORDER BY col_varchar_nokey; +col_varchar_nokey +c +e +p +s +v +w +y +ALTER TABLE t1 ENGINE=Memory; +ALTER TABLE t2 ENGINE=Memory; +explain SELECT col_varchar_nokey +FROM t2 AS ot +WHERE col_varchar_nokey IN ( +SELECT col_varchar_key +FROM t1 AS it +WHERE it.col_int_nokey <= it.col_int_nokey +AND NOT ot.col_int_nokey < 2 +) +ORDER BY col_varchar_nokey; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 20 33.33 Using where; Using filesort +1 SIMPLE it NULL ref col_varchar_key col_varchar_key 6 test.ot.col_varchar_nokey 2 100.00 FirstMatch(ot) +Warnings: +Note 1276 Field or reference 'test.ot.col_int_nokey' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`ot`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t2` `ot` semi join (`test`.`t1` `it`) where ((`test`.`it`.`col_varchar_key` = `test`.`ot`.`col_varchar_nokey`) and (`test`.`ot`.`col_int_nokey` >= 2)) order by `test`.`ot`.`col_varchar_nokey` +SELECT col_varchar_nokey +FROM t2 AS ot +WHERE col_varchar_nokey IN ( +SELECT col_varchar_key +FROM t1 AS it +WHERE it.col_int_nokey <= it.col_int_nokey +AND NOT ot.col_int_nokey < 2 +) +ORDER BY col_varchar_nokey; +col_varchar_nokey +c +e +p +s +v +w +y +DROP TABLE t1, t2; +# End of test for bug#13576391. +# +# Bug #13589848 "MISSING ROW ON SELECT WITH NESTED IN CLAUSES WHEN LOOSESCAN=ON" +# +CREATE TABLE t1 ( +id INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +KEY (col_varchar_key) +) charset utf8mb4; +INSERT INTO t1 VALUES (100,'m','m'), +(200,'b','b'), (300,'x','x'); +CREATE TABLE t2 ( +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +KEY (col_varchar_key) +) charset utf8mb4; +INSERT INTO t2 VALUES ('b','b'); +CREATE TABLE t3 ( +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +KEY (col_varchar_key) +) charset utf8mb4; +INSERT INTO t3 VALUES ('k','k'); +EXPLAIN SELECT gp1.id +FROM t1 AS gp1 JOIN t3 AS gp2 +ON gp2.col_varchar_key <> gp1.col_varchar_nokey +WHERE (gp1.col_varchar_nokey, gp1.col_varchar_nokey) +IN ( +SELECT col_varchar_nokey, col_varchar_nokey +FROM t1 +WHERE col_varchar_nokey +IN ( SELECT col_varchar_key +FROM t2 LEFT JOIN t3 USING (col_varchar_key) ) +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE gp2 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE gp1 NULL ALL NULL NULL NULL NULL 3 66.67 Using where +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +1 SIMPLE t2 NULL ref col_varchar_key col_varchar_key 7 test.gp1.col_varchar_nokey 2 100.00 Using index +1 SIMPLE t3 NULL ref col_varchar_key col_varchar_key 7 test.gp1.col_varchar_nokey 2 100.00 Using where; Using index; FirstMatch(gp1) +Warnings: +Note 1003 /* select#1 */ select `test`.`gp1`.`id` AS `id` from `test`.`t1` `gp1` semi join (`test`.`t1` join `test`.`t2` left join `test`.`t3` on((`test`.`t2`.`col_varchar_key` = `test`.`t3`.`col_varchar_key`))) where ((`test`.`t1`.`col_varchar_nokey` = `test`.`gp1`.`col_varchar_nokey`) and (`test`.`t2`.`col_varchar_key` = `test`.`gp1`.`col_varchar_nokey`) and ('k' <> `test`.`gp1`.`col_varchar_nokey`)) +SELECT gp1.id +FROM t1 AS gp1 JOIN t3 AS gp2 +ON gp2.col_varchar_key <> gp1.col_varchar_nokey +WHERE (gp1.col_varchar_nokey, gp1.col_varchar_nokey) +IN ( +SELECT col_varchar_nokey, col_varchar_nokey +FROM t1 +WHERE col_varchar_nokey +IN ( SELECT col_varchar_key +FROM t2 LEFT JOIN t3 USING (col_varchar_key) ) +) +; +id +200 +DROP TABLE t1,t2,t3; +# +# Bug #13596176: Missing row on select with nested in clause when +# matr=on and bnl=off + MyISAM +# +CREATE TABLE t1 ( +int_key int DEFAULT NULL, +vc_key varchar(1) DEFAULT NULL, +vc_nokey varchar(1) DEFAULT NULL, +KEY int_key (int_key), +KEY vc_key (vc_key, int_key) +) charset utf8mb4 ENGINE=MyISAM; +INSERT INTO t1 VALUES +(8,'x','x'), (7,'d','d'), (1,'r','r'), (7,'f','f'), +(9,'y','y'), (NULL,'u','u'), (1,'m','m'), (9,NULL,NULL), +(2,'o','o'), (9,'w','w'), (2,'m','m'), (4,'q','q'), +(0,NULL,NULL), (4,'d','d'), (8,'g','g'), (NULL,'x','x'), +(NULL,'f','f'), (0,'p','p'), (NULL,'j','j'), (8,'c','c'); +CREATE TABLE t2 ( +int_key int DEFAULT NULL, +vc_key varchar(1) DEFAULT NULL, +KEY int_key (int_key), +KEY vc_key (vc_key, int_key) +) charset utf8mb4 ENGINE=MyISAM; +INSERT INTO t2 VALUES (8,'g'); +explain SELECT vc_key +FROM t1 as outr +WHERE (vc_nokey, vc_key ) IN +(SELECT vc_nokey, vc_nokey +FROM t1 middle +WHERE vc_nokey IN +(SELECT child1.vc_key +FROM t2 AS child1 JOIN t1 AS child2 USING (int_key) +) +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE outr NULL ALL vc_key NULL NULL NULL 20 100.00 Using where +1 SIMPLE middle NULL ALL NULL NULL NULL NULL 20 10.00 Using where +1 SIMPLE child1 NULL ref int_key,vc_key vc_key 7 test.outr.vc_nokey 2 100.00 Using where; Using index +1 SIMPLE child2 NULL ref int_key int_key 5 test.child1.int_key 3 100.00 Using index; FirstMatch(outr) +Warnings: +Note 1003 /* select#1 */ select `test`.`outr`.`vc_key` AS `vc_key` from `test`.`t1` `outr` semi join (`test`.`t1` `middle` join `test`.`t2` `child1` join `test`.`t1` `child2`) where ((`test`.`child2`.`int_key` = `test`.`child1`.`int_key`) and (`test`.`outr`.`vc_key` = `test`.`outr`.`vc_nokey`) and (`test`.`middle`.`vc_nokey` = `test`.`outr`.`vc_nokey`) and (`test`.`child1`.`vc_key` = `test`.`outr`.`vc_nokey`)) +SELECT vc_key +FROM t1 as outr +WHERE (vc_nokey, vc_key ) IN +(SELECT vc_nokey, vc_nokey +FROM t1 middle +WHERE vc_nokey IN +(SELECT child1.vc_key +FROM t2 AS child1 JOIN t1 AS child2 USING (int_key) +) +); +vc_key +g +DROP TABLE t1, t2; +# End of test for bug#13596176. +# +# BUG#11754478: MAX/MIN + SUBQUERY + AND FAILS TO RETURN ANY ROWS +# BUG#13599013: MAX/MIN + SUBQUERY IN WHERE CLAUSE MATCHING NO +# ROWS + INDEX DOES NOT RETURN NULL +# +CREATE TABLE t1 ( +pk int(11) PRIMARY KEY, +int_key int(11), +KEY int_key (int_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (1,0),(2,0),(3,2),(4,0),(5,3),(6,0); +SELECT MIN(int_key) FROM t1 WHERE (4, 4) IN (SELECT 1, 2); +MIN(int_key) +NULL +SELECT MIN(int_key) FROM t1 WHERE (4, 4) IN (SELECT 4, 4); +MIN(int_key) +0 +SELECT MIN(pk) FROM t1 WHERE pk IN (SELECT int_key FROM t1) AND pk = 6; +MIN(pk) +NULL +DROP TABLE t1; +# BUG#13726217: Crash in Item_ident::fix_after_pullout() +CREATE TABLE t1(a INTEGER) engine=innodb; +INSERT INTO t1 VALUES (0); +SELECT 0 +FROM t1 +WHERE 0 IN +(SELECT 0 +FROM t1 +WHERE 0 LIKE +(SELECT elt(a, 0) AS b +FROM t1 +GROUP BY a +HAVING b +) +); +0 +DROP TABLE t1; +# End of test for bug#13726217. +# BUG#13773979: Missing rows on second execution of prepared statement +CREATE TABLE t1 ( +col_int_nokey INT, +col_int_key INT, +col_varchar_key VARCHAR(1) +); +INSERT INTO t1 VALUES +(1,7,'v'), (7,0,'s'), (4,9,'l'), (7,3,'y'), +(2,2,'i'), (9,5,'h'), (0,1,'a'), (9,3,'v'); +CREATE VIEW v1 AS SELECT * FROM t1; +SELECT * +FROM t1 +WHERE col_int_key IN ( +SELECT alias1.col_int_nokey AS field1 +FROM v1 AS alias1 +WHERE alias1.col_varchar_key < 'v' +); +col_int_nokey col_int_key col_varchar_key +1 7 v +2 2 i +4 9 l +7 0 s +prepare stmt FROM "SELECT * +FROM t1 +WHERE col_int_key IN ( +SELECT alias1.col_int_nokey AS field1 +FROM v1 AS alias1 +WHERE alias1.col_varchar_key < 'v' +)"; +execute stmt; +col_int_nokey col_int_key col_varchar_key +1 7 v +2 2 i +4 9 l +7 0 s +execute stmt; +col_int_nokey col_int_key col_varchar_key +1 7 v +2 2 i +4 9 l +7 0 s +DEALLOCATE PREPARE stmt; +DROP VIEW v1; +DROP TABLE t1; +# End of test for bug#13773979. +# +# BUG#13685026 ASSERTION CUR_SJ_INNER_TABLES == 0 IN +# --OPTIMIZE_TABLE_ORDER::CHOOSE_TABLE_ORDER +# +CREATE TABLE t1 ( +col_int_key INT(11) NOT NULL, +col_datetime_key DATETIME NOT NULL, +col_varchar_key VARCHAR(1) NOT NULL, +col_varchar_nokey VARCHAR(1) NOT NULL, +KEY col_int_key (col_int_key), +KEY col_datetime_key (col_datetime_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (0,'2002-02-13 17:30:06','j','j'); +INSERT INTO t1 VALUES (8,'2008-09-27 00:34:58','v','v'); +CREATE TABLE t2 ( +col_int_key INT(11) NOT NULL, +col_datetime_key DATETIME NOT NULL, +col_varchar_key VARCHAR(1) NOT NULL, +col_varchar_nokey VARCHAR(1) NOT NULL, +KEY col_int_key (col_int_key), +KEY col_datetime_key (col_datetime_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (7,'2003-08-21 00:00:00','b','b'); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +SET @old_depth=@@optimizer_search_depth; +SET optimizer_search_depth=4; +EXPLAIN SELECT col_datetime_key +FROM t1 as outr +WHERE col_datetime_key IN ( +SELECT alias1.col_datetime_key +FROM t1 AS alias1 +LEFT JOIN t1 as alias3 +STRAIGHT_JOIN ( t2 AS alias4 +JOIN t1 AS alias5 +ON alias5.col_varchar_key <= alias4.col_varchar_nokey ) +ON alias5.col_int_key < alias4.col_int_key +ON alias5.col_varchar_key = alias4.col_varchar_key +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE outr NULL index col_datetime_key col_datetime_key 5 NULL 2 100.00 Using index +1 SIMPLE alias1 NULL ref col_datetime_key col_datetime_key 5 test.outr.col_datetime_key 1 100.00 Using index +1 SIMPLE alias4 NULL ALL col_int_key,col_varchar_key NULL NULL NULL 1 100.00 NULL +1 SIMPLE alias5 NULL ref col_int_key,col_varchar_key col_varchar_key 6 test.alias4.col_varchar_key 1 100.00 Using where; Using index +1 SIMPLE alias3 NULL index NULL col_int_key 4 NULL 2 100.00 Using index; FirstMatch(outr) +Warnings: +Note 1003 /* select#1 */ select `test`.`outr`.`col_datetime_key` AS `col_datetime_key` from `test`.`t1` `outr` semi join (`test`.`t1` `alias1` left join (`test`.`t1` `alias3` join `test`.`t2` `alias4` join `test`.`t1` `alias5`) on(((`test`.`alias5`.`col_varchar_key` = `test`.`alias4`.`col_varchar_key`) and (`test`.`alias5`.`col_int_key` < `test`.`alias4`.`col_int_key`) and (`test`.`alias5`.`col_varchar_key` <= `test`.`alias4`.`col_varchar_nokey`)))) where (`test`.`alias1`.`col_datetime_key` = `test`.`outr`.`col_datetime_key`) +SELECT col_datetime_key +FROM t1 as outr +WHERE col_datetime_key IN ( +SELECT alias1.col_datetime_key +FROM t1 AS alias1 +LEFT JOIN t1 as alias3 +STRAIGHT_JOIN ( t2 AS alias4 +JOIN t1 AS alias5 +ON alias5.col_varchar_key <= alias4.col_varchar_nokey ) +ON alias5.col_int_key < alias4.col_int_key +ON alias5.col_varchar_key = alias4.col_varchar_key +); +col_datetime_key +2002-02-13 17:30:06 +2008-09-27 00:34:58 +DROP TABLE t1,t2; +SET @@optimizer_search_depth=@old_depth; +# +# BUG#13848789: SEGFAULT IN JOIN_READ_NEXT_SAME AT +# SQL/SQL_EXECUTOR.CC ON HAVING...IN...JOIN +# +CREATE TABLE t1 ( +col_int_key INT, +col_varchar_key VARCHAR(1), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4; +INSERT INTO t1 VALUES (8,'x'); +CREATE TABLE t2 ( +col_varchar_key VARCHAR(1), +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4; +INSERT INTO t2 VALUES ('x'), ('y'); +explain SELECT MIN(col_int_key) +FROM t1 as t1_outer +HAVING (1, 2) IN ( +SELECT t1_inner.col_int_key, MAX(t1_inner.col_int_key) +FROM t1 as t1_inner JOIN t2 +ON t2.col_varchar_key = t1_inner.col_varchar_key +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible HAVING +2 SUBQUERY t1_inner NULL system col_varchar_key NULL NULL NULL 1 100.00 NULL +2 SUBQUERY t2 NULL ref col_varchar_key col_varchar_key 7 const 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select min(`test`.`t1_outer`.`col_int_key`) AS `MIN(col_int_key)` from `test`.`t1` `t1_outer` having false +SELECT MIN(col_int_key) +FROM t1 as t1_outer +HAVING (1, 2) IN ( +SELECT t1_inner.col_int_key, MAX(t1_inner.col_int_key) +FROM t1 as t1_inner JOIN t2 +ON t2.col_varchar_key = t1_inner.col_varchar_key +); +MIN(col_int_key) +DROP TABLE t1,t2; +# Bug#13838810: Segfault in evaluate_null_complemented_join_record +CREATE TABLE t1 ( +pk int NOT NULL, +col_int_nokey int DEFAULT NULL, +col_int_key int DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t1 VALUES (10,NULL,8,'x'); +CREATE TABLE t2 ( +pk int NOT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +PRIMARY KEY (pk) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t2 VALUES (1,'x'); +CREATE TABLE t3 ( +pk int NOT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +PRIMARY KEY (pk), +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t3 VALUES +(1,'v','v'), (2,'v','v'), (3,'c','c'), (4,NULL,NULL); +EXPLAIN SELECT table1.pk,table2.pk, table3.pk +FROM t2 AS table1 +LEFT JOIN t1 AS table2 +LEFT JOIN t1 AS table3 +ON table3.col_int_key = table2.col_int_key +ON table3.pk = table2.col_int_nokey AND +table1.col_varchar_nokey IN ( +SELECT subquery3_t1.col_varchar_nokey +FROM t3 AS subquery3_t1 +LEFT JOIN t1 AS subquery3_t2 +ON subquery3_t2.col_varchar_key = subquery3_t1.col_varchar_key +WHERE subquery3_t2.col_int_nokey <> 9 +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE table1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE table2 NULL ALL col_int_key NULL NULL NULL 1 100.00 NULL +2 SIMPLE table3 NULL eq_ref PRIMARY,col_int_key PRIMARY 4 test.table2.col_int_nokey 1 100.00 Using where +2 SIMPLE subquery3_t2 NULL ALL col_varchar_key NULL NULL NULL 1 100.00 Using where +2 SIMPLE subquery3_t1 NULL ref col_varchar_key col_varchar_key 7 test.subquery3_t2.col_varchar_key 1 100.00 Using where; FirstMatch(table3) +Warnings: +Note 1003 /* select#1 */ select `test`.`table1`.`pk` AS `pk`,`test`.`table2`.`pk` AS `pk`,`test`.`table3`.`pk` AS `pk` from `test`.`t2` `table1` left join (`test`.`t1` `table2` join `test`.`t1` `table3` semi join (`test`.`t3` `subquery3_t1` join `test`.`t1` `subquery3_t2`)) on(((`test`.`table3`.`col_int_key` = `test`.`table2`.`col_int_key`) and (`test`.`subquery3_t1`.`col_varchar_key` = `test`.`subquery3_t2`.`col_varchar_key`) and (`test`.`subquery3_t1`.`col_varchar_nokey` = `test`.`table1`.`col_varchar_nokey`) and (`test`.`table3`.`pk` = `test`.`table2`.`col_int_nokey`) and (`test`.`subquery3_t2`.`col_int_nokey` <> 9))) where true +SELECT table1.pk,table2.pk, table3.pk +FROM t2 AS table1 +LEFT JOIN t1 AS table2 +LEFT JOIN t1 AS table3 +ON table3.col_int_key = table2.col_int_key +ON table3.pk = table2.col_int_nokey AND +table1.col_varchar_nokey IN ( +SELECT subquery3_t1.col_varchar_nokey +FROM t3 AS subquery3_t1 +LEFT JOIN t1 AS subquery3_t2 +ON subquery3_t2.col_varchar_key = subquery3_t1.col_varchar_key +WHERE subquery3_t2.col_int_nokey <> 9 +) +; +pk pk pk +1 NULL NULL +DROP TABLE t1, t2, t3; +Extra test case for specific code coverage +CREATE TABLE t1(pk INTEGER); +INSERT INTO t1 VALUES(1), (2); +explain SELECT * +FROM t1 AS ot1 LEFT JOIN t1 AS ot2 +ON ot1.pk=ot2.pk AND +ot2.pk IN +(SELECT it1.pk +FROM t1 AS it1 LEFT JOIN t1 AS it2 ON it1.pk=it2.pk); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE it1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE it2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch(ot2) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`pk` AS `pk`,`test`.`ot2`.`pk` AS `pk` from `test`.`t1` `ot1` left join (`test`.`t1` `ot2` semi join (`test`.`t1` `it1` left join `test`.`t1` `it2` on((`test`.`it1`.`pk` = `test`.`it2`.`pk`)))) on(((`test`.`ot2`.`pk` = `test`.`ot1`.`pk`) and (`test`.`it1`.`pk` = `test`.`ot1`.`pk`))) where true +SELECT * +FROM t1 AS ot1 LEFT JOIN t1 AS ot2 +ON ot1.pk=ot2.pk AND +ot2.pk IN +(SELECT it1.pk +FROM t1 AS it1 LEFT JOIN t1 AS it2 ON it1.pk=it2.pk); +pk pk +1 1 +2 2 +DROP TABLE t1; +# End of test for bug#13838810. +# +# Bug#13845930: Segfault in st_join_table::and_with_condition +# +CREATE TABLE t1 ( +col_int INTEGER +); +CREATE TABLE t2 ( +col_varchar_1 VARCHAR(1), +col_varchar_2 VARCHAR(1) +); +INSERT INTO t2 VALUES ('x','x'), ('c','c'); +PREPARE stmt FROM ' +SELECT alias2.col_varchar_2 AS field1 +FROM t2 AS alias1 + JOIN + (t2 AS alias2 + LEFT JOIN t2 AS alias3 + ON (8, 92) IN + (SELECT sq1_alias1.col_int, + sq1_alias2.col_int + FROM t1 AS sq1_alias1 JOIN t1 AS sq1_alias2 + ) + ) + ON alias3.col_varchar_1 = alias2.col_varchar_2 +'; +EXECUTE stmt; +field1 + +EXECUTE stmt; +field1 +DEALLOCATE prepare stmt; +DROP TABLE t1, t2; +# End of test for bug#13845930. +# +# Bug#13855925: Assert 'prebuilt->search_tuple->n_fields > 0' +# in ha_innobase::index_read +# +CREATE TABLE t1 ( +pk INTEGER AUTO_INCREMENT, +col_int_nokey INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk), +KEY (col_varchar_key) +) charset utf8mb4 ENGINE=INNODB; +INSERT INTO t1 ( +col_int_key, col_int_nokey, +col_varchar_key, col_varchar_nokey +) VALUES +(4, 2, 'v','v'), (62, 150, 'v','v'), (7, NULL, 'c','c'), (1, 2, NULL, NULL), +(0, 5, 'x','x'), (7, 3, 'i','i'), (7, 1, 'e','e'), (1, 4, 'p','p'), +(7, NULL, 's','s'), (1, 2, 'j','j'), (5, 6, 'z','z'), (2, 6, 'c','c'), +(0, 8, 'a','a'), (1, 2, 'q','q'), (8, 6, 'y','y'), (1, 8, NULL, NULL), +(1, 3, 'r','r'), (9, 3, 'v','v'), (1, 9, NULL, NULL), (5, 6, 'r','r'); +CREATE TABLE t2 ( +pk INT AUTO_INCREMENT, +col_int_nokey INT, +col_int_key INT, +PRIMARY KEY (pk), +KEY (col_int_key) +) charset utf8mb4 AUTO_INCREMENT=10 ENGINE=INNODB; +INSERT INTO t2 (col_int_key, col_int_nokey) VALUES +(8, NULL), (7, 8), (1, 1), (7, 9), (9, 4), (NULL, 3), (1, 2), (9, NULL), +(2, 2), (9, NULL), (2, 6), (4, 7), (0, 2), (4, 5), (8, 7), (NULL, 6), +(NULL, 6), (0, 2), (NULL, 9), (8, 6); +CREATE TABLE t3 ( +pk INT AUTO_INCREMENT, +col_varchar_key VARCHAR(1), +PRIMARY KEY (pk), +KEY (col_varchar_key) +) charset utf8mb4 ENGINE=INNODB; +INSERT INTO t3 (col_varchar_key) VALUES +('c'), ('c'), ('q'), ('g'), ('e'), ('l'), (NULL), ('c'), ('h'), ('d'), +('c'), ('i'), ('t'), ('g'), ('q'), ('l'), ('n'), ('z'), ('n'), ('r'), ('p'); +CREATE VIEW v1 AS +SELECT table2.col_varchar_nokey AS field1 +FROM t2 AS table1 +INNER JOIN (t1 AS table2 +STRAIGHT_JOIN t2 AS table3 +ON table3.col_int_key = table2.pk AND +table3.col_int_nokey = ANY +(SELECT subquery1_t2.col_int_nokey AS subquery1_field1 +FROM t2 AS subquery1_t1 +RIGHT OUTER JOIN t1 AS subquery1_t2 +INNER JOIN t1 AS subquery1_t3 +ON subquery1_t3.col_int_key = subquery1_t2.pk +ON subquery1_t3.col_varchar_key=subquery1_t2.col_varchar_nokey +WHERE subquery1_t1.pk > 1 +) +) +ON table3.col_int_key IN +(SELECT subquery2_t1.col_int_key AS subquery2_field1 +FROM t2 AS subquery2_t1 +RIGHT OUTER JOIN t3 AS subquery2_t2 +LEFT OUTER JOIN t1 AS subquery2_t3 +ON subquery2_t3.col_varchar_key = subquery2_t2.col_varchar_key +ON subquery2_t3.pk = subquery2_t2.pk +) +; +explain SELECT * FROM v1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE table1 NULL index NULL col_int_key 5 NULL 20 100.00 Using index +1 SIMPLE table2 NULL ALL PRIMARY NULL NULL NULL 20 100.00 Using join buffer (hash join) +1 SIMPLE table3 NULL ref col_int_key col_int_key 5 test.table2.pk 2 100.00 NULL +1 SIMPLE subquery1_t2 NULL ALL PRIMARY NULL NULL NULL 20 10.00 Using where +1 SIMPLE subquery1_t3 NULL ref col_varchar_key col_varchar_key 7 test.subquery1_t2.col_varchar_nokey 1 10.00 Using where +1 SIMPLE subquery1_t1 NULL index PRIMARY col_int_key 5 NULL 20 100.00 Using where; Using index; FirstMatch(table3) +1 SIMPLE subquery2_t3 NULL index PRIMARY,col_varchar_key col_varchar_key 7 NULL 20 100.00 Using where; Using index +1 SIMPLE subquery2_t2 NULL eq_ref PRIMARY,col_varchar_key PRIMARY 4 test.subquery2_t3.pk 1 7.14 Using where +1 SIMPLE subquery2_t1 NULL ref col_int_key col_int_key 5 test.table2.pk 2 100.00 Using index; FirstMatch(subquery1_t1) +Warnings: +Note 1003 /* select#1 */ select `table2`.`col_varchar_nokey` AS `field1` from `test`.`t2` `table1` join `test`.`t1` `table2` straight_join `test`.`t2` `table3` semi join (`test`.`t1` `subquery1_t2` join `test`.`t1` `subquery1_t3` join `test`.`t2` `subquery1_t1`) semi join (`test`.`t3` `subquery2_t2` join `test`.`t1` `subquery2_t3` join `test`.`t2` `subquery2_t1`) where ((`subquery1_t3`.`col_int_key` = `subquery1_t2`.`pk`) and (`subquery1_t3`.`col_varchar_key` = `subquery1_t2`.`col_varchar_nokey`) and (`subquery2_t2`.`col_varchar_key` = `subquery2_t3`.`col_varchar_key`) and (`subquery2_t2`.`pk` = `subquery2_t3`.`pk`) and (`table3`.`col_int_key` = `table2`.`pk`) and (`subquery2_t1`.`col_int_key` = `table2`.`pk`) and (`subquery1_t2`.`col_int_nokey` = `table3`.`col_int_nokey`) and (`subquery1_t1`.`pk` > 1)) +SELECT * FROM v1; +field1 +v +v +v +v +v +v +v +v +v +v +v +v +v +v +v +v +v +v +v +v +DROP VIEW v1; +DROP TABLE t1,t2,t3; +# End of test for bug#13855925. +# +# Bug#13897959: Segfault in setup_semijoin_dups_elimination() +# +CREATE TABLE t1 ( +col_datetime_key DATETIME DEFAULT NULL, +KEY col_datetime_key (col_datetime_key) +) ENGINE=MyISAM; +INSERT INTO t1 VALUES +('2001-04-18 00:00:00'), ('2008-12-18 19:39:55'), +('2000-08-01 12:19:39'), ('2004-09-25 21:29:06'), +('2009-09-20 09:11:48'), ('2004-03-27 09:32:04'); +CREATE TABLE t2 ( +col_date_nokey date DEFAULT NULL, +col_time_key time DEFAULT NULL, +col_datetime_key datetime DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +KEY col_time_key (col_time_key), +KEY col_datetime_key (col_datetime_key), +KEY col_varchar_key(col_varchar_key) +) ENGINE=MyISAM; +INSERT INTO t2 VALUES ('1900-01-01',NULL,'2001-11-04 19:07:55','x','x'); +SELECT grandparent1.col_varchar_nokey +FROM t2 AS grandparent1 LEFT JOIN t1 USING (col_datetime_key) +WHERE grandparent1.col_varchar_nokey IN ( +SELECT col_varchar_nokey +FROM t2 AS parent1 +WHERE parent1.col_time_key > grandparent1.col_date_nokey +); +col_varchar_nokey +DROP TABLE t1, t2; +# End of test for bug#13897959. +# +# Bug#13898625 ASSERT `(REMAINING_TABLES_AFTER != 0) ...' IN +# BEST_EXTENSION_BY_LIMITED_SEARCH +# +CREATE TABLE t1 ( +pk int(11) NOT NULL, +col_int_nokey INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (26,6,NULL,'f','f'); +INSERT INTO t1 VALUES (29,6,8,'c','c'); +CREATE TABLE t2 ( +pk INT NOT NULL, +col_int_nokey INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +INSERT INTO t2 VALUES (1,2,4,'v','v'); +INSERT INTO t2 VALUES (2,150,62,'v','v'); +INSERT INTO t2 VALUES (5,5,0,'x','x'); +INSERT INTO t2 VALUES (6,3,7,'i','i'); +INSERT INTO t2 VALUES (7,1,7,'e','e'); +CREATE VIEW view_c AS SELECT * FROM t2; +PREPARE prep_stmt_7430 FROM 'SELECT SUM( alias1.col_varchar_key ) AS field1 +FROM t1 AS alias1 +RIGHT JOIN t2 AS alias2 +INNER JOIN t1 AS alias3 +ON (alias3.col_varchar_key = alias2.col_varchar_key ) +ON ( "v" ) IN ( +SELECT sq1_alias1.col_varchar_nokey AS sq1_field1 +FROM t1 AS sq1_alias1 +) +WHERE alias3.pk IN ( +SELECT sq2_alias1.col_int_key AS sq2_field1 +FROM ( view_c AS sq2_alias1, t1 AS sq2_alias2 ) +) +'; +EXECUTE prep_stmt_7430; +field1 +NULL +EXECUTE prep_stmt_7430; +field1 +NULL +EXPLAIN SELECT SUM( alias1.col_varchar_key ) AS field1 +FROM t1 AS alias1 +RIGHT JOIN t2 AS alias2 +INNER JOIN t1 AS alias3 +ON (alias3.col_varchar_key = alias2.col_varchar_key ) +ON ( "v" ) IN ( +SELECT sq1_alias1.col_varchar_nokey AS sq1_field1 +FROM t1 AS sq1_alias1 +) +WHERE alias3.pk IN ( +SELECT sq2_alias1.col_int_key AS sq2_field1 +FROM ( view_c AS sq2_alias1, t1 AS sq2_alias2 ) +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE alias3 NULL ALL PRIMARY,col_varchar_key NULL NULL NULL 2 100.00 Using where +1 SIMPLE sq2_alias2 NULL index NULL PRIMARY 4 NULL 2 100.00 Using index +1 SIMPLE t2 NULL ref col_int_key col_int_key 5 test.alias3.pk 2 100.00 Using index; FirstMatch(alias3) +1 SIMPLE alias2 NULL ref col_varchar_key col_varchar_key 7 test.alias3.col_varchar_key 2 100.00 Using index +1 SIMPLE alias1 NULL index NULL col_varchar_key 12 NULL 2 100.00 Using index +1 SIMPLE sq1_alias1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch(alias1) +Warnings: +Note 1003 /* select#1 */ select sum(`test`.`alias1`.`col_varchar_key`) AS `field1` from `test`.`t2` `alias2` join `test`.`t1` `alias3` left join (`test`.`t1` `alias1` semi join (`test`.`t1` `sq1_alias1`)) on(((`test`.`sq1_alias1`.`col_varchar_nokey` = 'v'))) semi join (`test`.`t2` join `test`.`t1` `sq2_alias2`) where ((`test`.`alias2`.`col_varchar_key` = `test`.`alias3`.`col_varchar_key`) and (`test`.`t2`.`col_int_key` = `test`.`alias3`.`pk`)) +PREPARE prep_stmt_7430 FROM 'SELECT SUM( alias1.col_varchar_key ) AS field1 +FROM t1 AS alias1 +RIGHT JOIN t2 AS alias2 +INNER JOIN t1 AS alias3 +ON (alias3.col_varchar_key = alias2.col_varchar_key ) +ON ( "v" ) IN ( +SELECT sq1_alias1.col_varchar_nokey AS sq1_field1 +FROM t1 AS sq1_alias1 +) +WHERE alias3.pk IN ( +SELECT sq2_alias1.col_int_key AS sq2_field1 +FROM ( view_c AS sq2_alias1 , t1 AS sq2_alias2 ) +WHERE sq2_alias1.col_varchar_nokey <> alias2.col_varchar_key +AND sq2_alias1.col_varchar_key < "l" + ) +'; +EXECUTE prep_stmt_7430; +field1 +NULL +EXECUTE prep_stmt_7430; +field1 +NULL +EXPLAIN SELECT SUM( alias1.col_varchar_key ) AS field1 +FROM t1 AS alias1 +RIGHT JOIN t2 AS alias2 +INNER JOIN t1 AS alias3 +ON (alias3.col_varchar_key = alias2.col_varchar_key ) +ON ( "v" ) IN ( +SELECT sq1_alias1.col_varchar_nokey AS sq1_field1 +FROM t1 AS sq1_alias1 +) +WHERE alias3.pk IN ( +SELECT sq2_alias1.col_int_key AS sq2_field1 +FROM ( view_c AS sq2_alias1 , t1 AS sq2_alias2 ) +WHERE sq2_alias1.col_varchar_nokey <> alias2.col_varchar_key +AND sq2_alias1.col_varchar_key < "l" + ) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE alias3 NULL ALL PRIMARY,col_varchar_key NULL NULL NULL 2 100.00 Using where +1 SIMPLE alias2 NULL ref col_varchar_key col_varchar_key 7 test.alias3.col_varchar_key 2 100.00 Using index +1 SIMPLE t2 NULL ref col_int_key,col_varchar_key col_int_key 5 test.alias3.pk 2 32.00 Using where +1 SIMPLE sq2_alias2 NULL index NULL PRIMARY 4 NULL 2 100.00 Using index; FirstMatch(alias2) +1 SIMPLE alias1 NULL index NULL col_varchar_key 12 NULL 2 100.00 Using index +1 SIMPLE sq1_alias1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch(alias1) +Warnings: +Note 1276 Field or reference 'test.alias2.col_varchar_key' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select sum(`test`.`alias1`.`col_varchar_key`) AS `field1` from `test`.`t2` `alias2` join `test`.`t1` `alias3` left join (`test`.`t1` `alias1` semi join (`test`.`t1` `sq1_alias1`)) on(((`test`.`sq1_alias1`.`col_varchar_nokey` = 'v'))) semi join (`test`.`t2` join `test`.`t1` `sq2_alias2`) where ((`test`.`alias2`.`col_varchar_key` = `test`.`alias3`.`col_varchar_key`) and (`test`.`t2`.`col_int_key` = `test`.`alias3`.`pk`) and (`test`.`t2`.`col_varchar_nokey` <> `test`.`alias3`.`col_varchar_key`) and (`test`.`t2`.`col_varchar_key` < 'l')) +DROP TABLE t1,t2; +DROP VIEW view_c; +# +# Bug#13902463 SEGFAULT IN BITMAP<64U>::MERGE OR ADD_KEY_FIELD +# ON SECOND EXEC OF PREP STMT +# +CREATE TABLE t1 ( +pk INT, +col_int_nokey INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +KEY col_varchar_key (col_varchar_key) +); +CREATE VIEW view_b AS SELECT * FROM t1; +PREPARE prep_stmt_20421 FROM 'SELECT alias2.col_varchar_nokey AS field1 +FROM t1 AS alias1 +INNER JOIN t1 AS alias2 +ON (alias1.col_varchar_key = alias2.col_varchar_nokey +AND ( alias1.col_int_key ) IN ( +SELECT t1.col_int_nokey +FROM t1 +) +) +WHERE alias1.col_varchar_key IN ( +SELECT sq2_alias2.col_varchar_nokey AS sq2_field1 +FROM view_b AS sq2_alias1 +INNER JOIN t1 AS sq2_alias2 +ON (sq2_alias2.col_varchar_key = sq2_alias1.col_varchar_key ) +WHERE sq2_alias1.pk > alias2.pk +) +'; +EXECUTE prep_stmt_20421; +field1 +EXECUTE prep_stmt_20421; +field1 +EXPLAIN SELECT alias2.col_varchar_nokey AS field1 +FROM t1 AS alias1 +INNER JOIN t1 AS alias2 +ON (alias1.col_varchar_key = alias2.col_varchar_nokey +AND ( alias1.col_int_key ) IN ( +SELECT t1.col_int_nokey +FROM t1 +) +) +WHERE alias1.col_varchar_key IN ( +SELECT sq2_alias2.col_varchar_nokey AS sq2_field1 +FROM view_b AS sq2_alias1 +INNER JOIN t1 AS sq2_alias2 +ON (sq2_alias2.col_varchar_key = sq2_alias1.col_varchar_key ) +WHERE sq2_alias1.pk > alias2.pk +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.alias2.pk' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `field1` from `test`.`t1` `alias1` join `test`.`t1` `alias2` semi join (`test`.`t1`) semi join (`test`.`t1` join `test`.`t1` `sq2_alias2`) where ((`test`.`t1`.`pk` > NULL) and multiple equal(NULL, `test`.`sq2_alias2`.`col_varchar_nokey`, NULL) and multiple equal(`test`.`sq2_alias2`.`col_varchar_key`, `test`.`t1`.`col_varchar_key`) and multiple equal(NULL, `test`.`t1`.`col_int_nokey`)) +ALTER TABLE t1 DROP INDEX col_varchar_key; +PREPARE prep_stmt_20421 FROM 'SELECT alias2.col_varchar_nokey AS field1 +FROM t1 AS alias1 +INNER JOIN t1 AS alias2 +ON (alias1.col_varchar_key = alias2.col_varchar_nokey +AND ( alias1.col_int_key ) IN ( +SELECT t1.col_int_nokey +FROM t1 +) +) +WHERE alias1.col_varchar_key IN ( +SELECT sq2_alias2.col_varchar_nokey AS sq2_field1 +FROM view_b AS sq2_alias1 +INNER JOIN t1 AS sq2_alias2 +ON (sq2_alias2.col_varchar_key = sq2_alias1.col_varchar_key ) +WHERE sq2_alias1.pk > alias2.pk +) +'; +EXECUTE prep_stmt_20421; +field1 +EXECUTE prep_stmt_20421; +field1 +EXPLAIN SELECT alias2.col_varchar_nokey AS field1 +FROM t1 AS alias1 +INNER JOIN t1 AS alias2 +ON (alias1.col_varchar_key = alias2.col_varchar_nokey +AND ( alias1.col_int_key ) IN ( +SELECT t1.col_int_nokey +FROM t1 +) +) +WHERE alias1.col_varchar_key IN ( +SELECT sq2_alias2.col_varchar_nokey AS sq2_field1 +FROM view_b AS sq2_alias1 +INNER JOIN t1 AS sq2_alias2 +ON (sq2_alias2.col_varchar_key = sq2_alias1.col_varchar_key ) +WHERE sq2_alias1.pk > alias2.pk +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.alias2.pk' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `field1` from `test`.`t1` `alias1` join `test`.`t1` `alias2` semi join (`test`.`t1`) semi join (`test`.`t1` join `test`.`t1` `sq2_alias2`) where ((`test`.`t1`.`pk` > NULL) and multiple equal(NULL, `test`.`sq2_alias2`.`col_varchar_nokey`, NULL) and multiple equal(`test`.`sq2_alias2`.`col_varchar_key`, `test`.`t1`.`col_varchar_key`) and multiple equal(NULL, `test`.`t1`.`col_int_nokey`)) +DROP TABLE t1; +DROP VIEW view_b; +# +# Bug#13907277: Segfault in evaluate_null_complemented_join_record +# +CREATE TABLE t1 ( +pk INTEGER, +col_varchar_nokey VARCHAR(1), +col_varchar_key VARCHAR(1), +PRIMARY KEY (pk) +); +INSERT INTO t1 VALUES (1, 'x', 'x'); +CREATE TABLE t2 ( +pk INTEGER, +PRIMARY KEY (pk) +); +INSERT INTO t2 VALUES (1); +CREATE TABLE t3 ( +pk INTEGER, +col_int_nokey INTEGER, +col_int_key INTEGER, +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk) +); +INSERT INTO t3 VALUES (1, 6, 5, 'r'); +explain SELECT outer_t1.pk, outer_t2.pk +FROM t3 AS outer_t1 +RIGHT JOIN t2 AS outer_t2 +ON outer_t1.col_int_nokey IN +(SELECT inner_t1.col_int_nokey +FROM t3 AS inner_t1 +LEFT JOIN t1 AS inner_t2 +INNER JOIN t1 AS inner_t3 +ON inner_t3.pk = inner_t2.pk +ON inner_t3.col_varchar_nokey = inner_t2.col_varchar_key +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE outer_t2 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE outer_t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE inner_t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE inner_t2 NULL ALL PRIMARY NULL NULL NULL 1 100.00 NULL +1 SIMPLE inner_t3 NULL eq_ref PRIMARY PRIMARY 4 test.inner_t2.pk 1 100.00 Using where; FirstMatch(outer_t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`outer_t1`.`pk` AS `pk`,'1' AS `pk` from left join (`test`.`t3` `outer_t1` semi join (`test`.`t3` `inner_t1` left join (`test`.`t1` `inner_t2` join `test`.`t1` `inner_t3`) on(((`test`.`inner_t3`.`col_varchar_nokey` = `test`.`inner_t2`.`col_varchar_key`) and (`test`.`inner_t3`.`pk` = `test`.`inner_t2`.`pk`))))) on(((`test`.`inner_t1`.`col_int_nokey` = `test`.`outer_t1`.`col_int_nokey`))) where true +SELECT outer_t1.pk, outer_t2.pk +FROM t3 AS outer_t1 +RIGHT JOIN t2 AS outer_t2 +ON outer_t1.col_int_nokey IN +(SELECT inner_t1.col_int_nokey +FROM t3 AS inner_t1 +LEFT JOIN t1 AS inner_t2 +INNER JOIN t1 AS inner_t3 +ON inner_t3.pk = inner_t2.pk +ON inner_t3.col_varchar_nokey = inner_t2.col_varchar_key +); +pk pk +1 1 +DROP TABLE t1, t2, t3; +# End of test for bug#13907277. +# +# Bug#13955713: Assert 'JOIN->best_read < ...' on second execution +# +CREATE TABLE t1 ( +pk INTEGER, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1) +); +PREPARE stmt FROM " +SELECT MIN(alias2.col_varchar_key) AS field1 +FROM t1 AS alias1 + INNER JOIN (t1 AS alias2 + INNER JOIN t1 AS alias3 + ON 8 IN + (SELECT sq1_alias1.pk AS sq1_field2 + FROM t1 AS sq1_alias1 + WHERE 9 IN + (SELECT SUM(t1_sq1_alias1.pk) AS t1_sq1_field2 + FROM t1 AS t1_sq1_alias1 + ) + ) + ) + ON alias3.col_varchar_nokey = alias2.col_varchar_key +WHERE EXISTS + (SELECT sq2_alias1.pk AS sq2_field1 + FROM t1 AS sq2_alias1 + WHERE sq2_alias1.col_varchar_key < alias1.col_varchar_nokey + ) +"; +EXECUTE stmt; +field1 +NULL + +EXECUTE stmt; +field1 +NULL +DEALLOCATE PREPARE stmt; +DROP TABLE t1; +# End of test for bug#13955713. +# +# Bug#13956813: Segfault in memcpy from Join_cache::write_record_data() +# +CREATE TABLE t1 ( +pk INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1) +) charset latin1; +CREATE TABLE t2 ( +pk INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1) +) charset latin1; +INSERT INTO t2 VALUES +(10,'j','j'), (11,'z','z'), (12,'c','c'), (13,'a','a'), +(14,'q','q'), (15,'y','y'), (16,NULL,NULL), (17,'r','r'), +(18,'v','v'), (19,NULL,NULL), (20,'r','r'); +CREATE TABLE t3 ( +pk INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +KEY col_int_key (col_int_key) +) charset latin1; +INSERT INTO t3 VALUES +(15,NULL,'u'), (16,1,'m'), (17,9,NULL), (18,2,'o'), +(19,9,'w'), (20,2,'m'), (21,4,'q'), (22,0,NULL), +(23,4,'d'), (24,8,'g'), (25,NULL,'x'), (26,NULL,'f'), +(27,0,'p'), (28,NULL,'j'), (29,8,'c'); +CREATE VIEW view_inline_0 AS +SELECT t1.* +FROM t1 INNER JOIN t3 +ON t1.pk = t3.pk; +CREATE VIEW view_inline_1 AS +SELECT sq2_alias2.col_varchar_key AS sq2_field1, +sq2_alias1.col_varchar_key AS sq2_field2 +FROM t3 AS sq2_alias1 LEFT OUTER JOIN t3 AS sq2_alias2 +ON sq2_alias1.pk = sq2_alias2.col_int_key; +CREATE VIEW view_inline_2 AS +SELECT 'p', 'p' UNION SELECT 'k', 's'; +SET @optimizer_switch_saved= @@optimizer_switch; +SET @@optimizer_switch="derived_merge=off"; +explain SELECT SUM(alias1.col_varchar_nokey) AS field2 +FROM t2 AS alias2 +LEFT JOIN (SELECT * FROM view_inline_0) AS alias1 +ON alias2.col_varchar_key = alias1.col_varchar_key AND +(alias2.col_varchar_nokey, alias2.col_varchar_key) IN +(SELECT * FROM view_inline_1 +) +WHERE (alias1.col_varchar_key, alias1.col_varchar_nokey) IN +(SELECT * FROM view_inline_2 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL 2 100.00 NULL +1 PRIMARY alias2 NULL ALL NULL NULL NULL NULL 11 10.00 Using where; Using join buffer (hash join) +1 PRIMARY NULL ref 8 test.alias2.col_varchar_nokey,test.view_inline_2.p 3 100.00 Using index; FirstMatch(alias2) +1 PRIMARY NULL ref 8 test.view_inline_2.p,test.view_inline_2.Name_exp_p 2 100.00 NULL +7 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +8 UNION NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +NULL UNION RESULT NULL ALL NULL NULL NULL NULL NULL NULL Using temporary +6 DERIVED sq2_alias1 NULL ALL NULL NULL NULL NULL 15 100.00 NULL +6 DERIVED sq2_alias2 NULL ref col_int_key col_int_key 5 test.sq2_alias1.pk 2 100.00 NULL +2 DERIVED NULL ALL NULL NULL NULL NULL 15 100.00 NULL +5 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select sum(`alias1`.`col_varchar_nokey`) AS `field2` from `test`.`view_inline_2` join `test`.`t2` `alias2` join (/* select#2 */ select `test`.`view_inline_0`.`pk` AS `pk`,`test`.`view_inline_0`.`col_varchar_key` AS `col_varchar_key`,`test`.`view_inline_0`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`view_inline_0`) `alias1` semi join (`test`.`view_inline_1`) where ((`test`.`view_inline_1`.`sq2_field1` = `test`.`alias2`.`col_varchar_nokey`) and (`alias1`.`col_varchar_nokey` = `test`.`view_inline_2`.`Name_exp_p`) and (`test`.`alias2`.`col_varchar_key` = `test`.`view_inline_2`.`p`) and (`test`.`view_inline_1`.`sq2_field2` = `test`.`view_inline_2`.`p`) and (`alias1`.`col_varchar_key` = `test`.`view_inline_2`.`p`)) +SELECT SUM(alias1.col_varchar_nokey) AS field2 +FROM t2 AS alias2 +LEFT JOIN (SELECT * FROM view_inline_0) AS alias1 +ON alias2.col_varchar_key = alias1.col_varchar_key AND +(alias2.col_varchar_nokey, alias2.col_varchar_key) IN +(SELECT * FROM view_inline_1 +) +WHERE (alias1.col_varchar_key, alias1.col_varchar_nokey) IN +(SELECT * FROM view_inline_2 +); +field2 +NULL +SET @@optimizer_switch= @optimizer_switch_saved; +DROP VIEW view_inline_0, view_inline_1, view_inline_2; +DROP TABLE t1, t2, t3; +# End of test for bug#13956813. +# +# Bug#13974177: Assert !(tab->table->regginfo.not_exists_optimize... +# +CREATE TABLE t1 ( +pk INTEGER AUTO_INCREMENT, +col_int_nokey INTEGER, +col_int_key INTEGER, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk), +KEY (col_int_key), +KEY (col_varchar_key, col_int_key) +); +INSERT INTO t1(col_int_key, col_int_nokey, col_varchar_key, col_varchar_nokey) +VALUES +(0, 4, 'j', 'j'), (8, 6, 'v', 'v'), (1, 3, 'c', 'c'), (8, 5, 'm', 'm'), +(9, 3, 'd', 'd'), (24, 246, 'd', 'd'), (6, 2, 'y', 'y'), (1, 9, 't', 't'), +(6, 3, 'd', 'd'), (2, 8, 's', 's'), (4, 1, 'r', 'r'), (8, 8, 'm', 'm'), +(4, 8, 'b', 'b'), (4, 5, 'x', 'x'), (7, 7, 'g', 'g'), (4, 5, 'p', 'p'), +(1, 1, 'q', 'q'), (9, 6, 'w', 'w'), (4, 2, 'd', 'd'), (8, 9, 'e', 'e'); +CREATE TABLE t2 ( +pk INTEGER AUTO_INCREMENT, +col_int_nokey INTEGER NOT NULL, +col_time_key TIME NOT NULL, +col_time_nokey TIME NOT NULL, +PRIMARY KEY (pk), +KEY (col_time_key) +) ENGINE=InnoDB; +INSERT INTO t2 (col_int_nokey, col_time_key, col_time_nokey) VALUES +(7, '00:00:00', '00:00:00'), (0, '00:00:00', '00:00:00'), +(9, '06:35:17', '06:35:17'), (3, '18:07:14', '18:07:14'), +(4, '20:36:52', '20:36:52'), (2, '21:29:07', '21:29:07'), +(5, '23:45:57', '23:45:57'), (3, '22:54:57', '22:54:57'), +(1, '18:45:09', '18:45:09'), (3, '14:30:46', '14:30:46'), +(6, '19:23:43', '19:23:43'), (7, '03:39:30', '03:39:30'), +(5, '23:37:52', '23:37:52'), (1, '16:59:30', '16:59:30'), +(204, '22:21:15', '22:21:15'), (224, '12:24:37', '12:24:37'), +(9, '15:02:08', '15:02:08'), (5, '23:59:59', '23:59:59'), +(0, '08:23:30', '08:23:30'), (3, '08:32:22', '08:32:22'); +explain SELECT ot1.col_int_key AS x +FROM t1 AS ot2 +LEFT JOIN t1 AS ot1 +ON ot2.col_varchar_nokey > ot1.col_varchar_key +WHERE (ot1.col_int_nokey, ot1.pk) IN +(SELECT it1.pk AS x, +it1.col_int_nokey AS y +FROM t2 AS it2 +LEFT JOIN t2 AS it1 +ON it2.col_time_nokey = it1.col_time_key +) AND ot1.pk IS NULL +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`col_int_key` AS `x` from `test`.`t2` `it1` join `test`.`t1` `ot2` join `test`.`t1` `ot1` semi join (`test`.`t2` `it2`) where ((`test`.`ot1`.`pk` is null) and (`test`.`ot2`.`col_varchar_nokey` > `test`.`ot1`.`col_varchar_key`) and multiple equal(`test`.`ot1`.`col_int_nokey`, `test`.`it1`.`pk`) and multiple equal(`test`.`ot1`.`pk`, `test`.`it1`.`col_int_nokey`) and multiple equal(`test`.`it2`.`col_time_nokey`, `test`.`it1`.`col_time_key`)) +SELECT ot1.col_int_key AS x +FROM t1 AS ot2 +LEFT JOIN t1 AS ot1 +ON ot2.col_varchar_nokey > ot1.col_varchar_key +WHERE (ot1.col_int_nokey, ot1.pk) IN +(SELECT it1.pk AS x, +it1.col_int_nokey AS y +FROM t2 AS it2 +LEFT JOIN t2 AS it1 +ON it2.col_time_nokey = it1.col_time_key +) AND ot1.pk IS NULL +; +x +DROP TABLE t1, t2; +# End of test for bug#13974177. +# +# Bug#13971022: Assert 'keyparts > 0' failed in create_ref_for_key... +# +CREATE TABLE t1 ( +pk INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +PRIMARY KEY (pk), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +CREATE TABLE t2 ( +pk INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk) +) charset utf8mb4 ENGINE=InnoDB; +CREATE TABLE t3 ( +i INT +); +SET @optimizer_switch_saved= @@optimizer_switch; +SET @@optimizer_switch="derived_merge=off"; +explain SELECT table1.pk AS field1 +FROM ( SELECT subquery1_t1. * +FROM t2 AS subquery1_t1 +JOIN t2 AS subquery1_t2 +ON subquery1_t2.pk = subquery1_t1.pk) AS table1 +STRAIGHT_JOIN t2 AS table2 +ON table1.col_int_key IN (SELECT 7 FROM t3) +WHERE table1.col_varchar_nokey IN +(SELECT subquery3_t1.col_varchar_key AS subquery3_field1 +FROM t1 AS subquery3_t1 +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 PRIMARY subquery3_t1 NULL ref col_varchar_key col_varchar_key 7 table1.col_varchar_nokey 0 0.00 Using index; FirstMatch() +1 PRIMARY t3 NULL ALL NULL NULL NULL NULL 0 0.00 FirstMatch(subquery3_t1); Using join buffer (hash join) +1 PRIMARY table2 NULL index NULL PRIMARY 4 NULL 1 100.00 Using index; Using join buffer (hash join) +2 DERIVED subquery1_t1 NULL ALL PRIMARY NULL NULL NULL 1 100.00 Using where +2 DERIVED subquery1_t2 NULL eq_ref PRIMARY PRIMARY 4 test.subquery1_t1.pk 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `table1`.`pk` AS `field1` from (/* select#2 */ select `test`.`subquery1_t1`.`pk` AS `pk`,`test`.`subquery1_t1`.`col_int_key` AS `col_int_key`,`test`.`subquery1_t1`.`col_varchar_key` AS `col_varchar_key`,`test`.`subquery1_t1`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t2` `subquery1_t1` join `test`.`t2` `subquery1_t2` where ((`test`.`subquery1_t1`.`col_int_key` = 7) and (`test`.`subquery1_t2`.`pk` = `test`.`subquery1_t1`.`pk`))) `table1` straight_join `test`.`t2` `table2` semi join (`test`.`t3`) semi join (`test`.`t1` `subquery3_t1`) where (`test`.`subquery3_t1`.`col_varchar_key` = `table1`.`col_varchar_nokey`) +SELECT table1.pk AS field1 +FROM ( SELECT subquery1_t1. * +FROM t2 AS subquery1_t1 +JOIN t2 AS subquery1_t2 +ON subquery1_t2.pk = subquery1_t1.pk) AS table1 +STRAIGHT_JOIN t2 AS table2 +ON table1.col_int_key IN (SELECT 7 FROM t3) +WHERE table1.col_varchar_nokey IN +(SELECT subquery3_t1.col_varchar_key AS subquery3_field1 +FROM t1 AS subquery3_t1 +) +; +field1 +SET @@optimizer_switch= @optimizer_switch_saved; +DROP TABLE t1, t2, t3; +# End of test for bug#13971022. +# +# Bug#13623473 "MISSING ROWS ON SELECT AND JOIN WITH +# TIME/DATETIME COMPARE" - Subquery part of test. +# +SET TIMESTAMP=UNIX_TIMESTAMP('2012-01-31 10:14:35'); +CREATE TABLE t1 ( +pk INT NOT NULL, +col_int_nokey INT, +col_int_key INT NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +) ENGINE=InnoDB; +INSERT INTO t1 VALUES (10,1,7), (11,7,0), (12,4,9), (13,7,3), +(14,0,4), (15,2,2), (16,9,5), (17,4,3), (18,0,1), (19,9,3), (20,1,6), +(21,3,7), (22,8,5), (23,8,1), (24,18,204), (25,84,224), (26,6,9), +(27,3,5), (28,6,0), (29,6,3); +CREATE TABLE t2 ( +col_int_nokey INT NOT NULL, +col_datetime_key DATETIME NOT NULL, +col_varchar_key VARCHAR(1) NOT NULL, +KEY col_datetime_key (col_datetime_key), +KEY col_varchar_key (col_varchar_key) +) ENGINE=InnoDB; +INSERT INTO t2 VALUES (1,'2001-11-04 19:07:55','k'); +CREATE TABLE t3 ( +col_time_key TIME, +KEY col_time_key (col_time_key) +) ENGINE=InnoDB; +INSERT INTO t3 VALUES ('21:22:34'), ('10:50:38'), ('00:21:38'), +('04:08:02'), ('16:25:11'), ('10:14:58'), ('19:47:59'), ('11:14:24'), +('00:00:00'), ('00:00:00'), ('15:57:25'), ('07:05:51'), ('19:22:21'), +('03:53:16'), ('09:16:38'), ('15:37:26'), ('00:00:00'), ('05:03:03'), +('02:59:24'), ('00:01:58'); +EXPLAIN SELECT outr.col_int_nokey +FROM t2 as outr +STRAIGHT_JOIN t3 AS outr2 +ON outr2.col_time_key > outr.col_datetime_key +WHERE outr.col_int_nokey IN ( +SELECT col_int_key +FROM t1 AS innr +WHERE innr.pk >= innr.col_int_nokey +) AND ( +outr.col_int_nokey <= 6 +OR +outr.col_varchar_key IS NULL +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE outr NULL ALL col_datetime_key NULL NULL NULL 1 100.00 Using where +2 SIMPLE innr NULL ref col_int_key col_int_key 4 test.outr.col_int_nokey 1 33.33 Using where; FirstMatch(outr) +2 SIMPLE outr2 NULL index col_time_key col_time_key 4 NULL 20 33.33 Using where; Using index; Using join buffer (hash join) +Warnings: +Warning 1739 Cannot use range access on index 'col_time_key' due to type or collation conversion on field 'col_time_key' +Note 1003 /* select#1 */ select `test`.`outr`.`col_int_nokey` AS `col_int_nokey` from `test`.`t2` `outr` straight_join `test`.`t3` `outr2` semi join (`test`.`t1` `innr`) where ((`test`.`innr`.`col_int_key` = `test`.`outr`.`col_int_nokey`) and (`test`.`outr`.`col_int_nokey` <= 6) and (`test`.`innr`.`pk` >= `test`.`innr`.`col_int_nokey`) and (cast(`test`.`outr2`.`col_time_key` as datetime) > `test`.`outr`.`col_datetime_key`)) +SELECT outr.col_int_nokey +FROM t2 as outr +STRAIGHT_JOIN t3 AS outr2 +ON outr2.col_time_key > outr.col_datetime_key +WHERE outr.col_int_nokey IN ( +SELECT col_int_key +FROM t1 AS innr +WHERE innr.pk >= innr.col_int_nokey +) AND ( +outr.col_int_nokey <= 6 +OR +outr.col_varchar_key IS NULL +); +col_int_nokey +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +DROP TABLE t1,t2,t3; +SET TIMESTAMP = DEFAULT; +# End of test for bug#13623473. +# +# Bug#13980954: Missing data on left join + null value + where..in +# +CREATE TABLE t1 ( +ik INT, +vc varchar(1) +) charset utf8mb4; +INSERT INTO t1 VALUES (8, 'x'), (NULL, 'x'); +CREATE TABLE t2 ( +ik INT, +vc varchar(1) +) charset utf8mb4; +INSERT INTO t2 VALUES +(0, 'x'), (7, 'i'), (7, 'e'), (1, 'p'), (7, 's'), (1, 'j'); +explain format=json SELECT t2.vc, t2.ik AS t2_ik, t1.ik AS t1_ik +FROM t2 LEFT JOIN t1 ON t2.vc=t1.vc +WHERE t2.vc IN (SELECT vc FROM t2 AS t3); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "6.92" + }, + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 6, + "rows_produced_per_join": 6, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "0.60", + "prefix_cost": "1.11", + "data_read_per_join": "96" + }, + "used_columns": [ + "ik", + "vc" + ] + } + }, + { + "table": { + "table_name": "t3", + "access_type": "ALL", + "rows_examined_per_scan": 6, + "rows_produced_per_join": 6, + "filtered": "16.67", + "first_match": "t2", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "0.60", + "prefix_cost": "5.21", + "data_read_per_join": "96" + }, + "used_columns": [ + "vc" + ], + "attached_condition": "(`test`.`t3`.`vc` = `test`.`t2`.`vc`)" + } + }, + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 12, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "1.20", + "prefix_cost": "6.92", + "data_read_per_join": "192" + }, + "used_columns": [ + "ik", + "vc" + ], + "attached_condition": "(is_not_null_compl(t1), (`test`.`t1`.`vc` = `test`.`t2`.`vc`), true)" + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`vc` AS `vc`,`test`.`t2`.`ik` AS `t2_ik`,`test`.`t1`.`ik` AS `t1_ik` from `test`.`t2` left join `test`.`t1` on((`test`.`t1`.`vc` = `test`.`t2`.`vc`)) semi join (`test`.`t2` `t3`) where (`test`.`t3`.`vc` = `test`.`t2`.`vc`) +SELECT t2.vc, t2.ik AS t2_ik, t1.ik AS t1_ik +FROM t2 LEFT JOIN t1 ON t2.vc=t1.vc +WHERE t2.vc IN (SELECT vc FROM t2 AS t3); +vc t2_ik t1_ik +e 7 NULL +i 7 NULL +j 1 NULL +p 1 NULL +s 7 NULL +x 0 8 +x 0 NULL +DROP TABLE t1, t2; +# End of test for bug#13980954. +# +# Bug#14048292: Segfault in Item_field::result_type on 2nd execution +# of prep stmt with join of view +# +CREATE TABLE t1 ( +col_int INT +); +INSERT INTO t1 VALUES (0), (1); +CREATE VIEW view_t1 AS SELECT * FROM t1; +explain SELECT alias1.col_int +FROM t1 AS alias1 +LEFT JOIN view_t1 AS alias2 +ON alias1.col_int IN +(SELECT sq1_alias1.col_int +FROM t1 AS sq1_alias1 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE alias1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE sq1_alias1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`alias1`.`col_int` AS `col_int` from `test`.`t1` `alias1` left join (`test`.`t1` semi join (`test`.`t1` `sq1_alias1`)) on(((`test`.`sq1_alias1`.`col_int` = `test`.`alias1`.`col_int`))) where true +PREPARE stmt FROM "SELECT alias1.col_int +FROM t1 AS alias1 +LEFT JOIN view_t1 AS alias2 +ON alias1.col_int IN +(SELECT sq1_alias1.col_int +FROM t1 AS sq1_alias1 +)"; +EXECUTE stmt; +col_int +0 +0 +1 +1 + +EXECUTE stmt; +col_int +0 +0 +1 +1 +DEALLOCATE PREPARE stmt; +DROP VIEW view_t1; +DROP TABLE t1; +# End of test for bug#14048292. +# +# Bug#14064201: Missing data on join of derived table + WHERE .. IN +# with two operands +# +CREATE TABLE t1 ( +col_varchar_nokey VARCHAR(1) +) charset utf8mb4; +INSERT INTO t1 VALUES +('v'), ('s'), ('l'), ('y'), ('c'), ('i'), ('h'), ('q'), ('a'), ('v'), +('u'), ('s'), ('y'), ('z'), ('h'), ('p'), ('e'), ('i'), ('y'), ('w'); +CREATE TABLE t2 ( +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +KEY col_varchar_key(col_varchar_key) +) charset utf8mb4; +INSERT INTO t2 VALUES +('j','j'), ('v','v'), ('c','c'), ('m','m'), ('d','d'), ('d','d'), ('y','y'); +SET @optimizer_switch_saved= @@optimizer_switch; +SET @@optimizer_switch="derived_merge=off"; +explain format=json SELECT * +FROM (SELECT * FROM t2) AS derived1 +LEFT JOIN t1 +USING (col_varchar_nokey) +WHERE (col_varchar_nokey, col_varchar_nokey) IN +(SELECT col_varchar_nokey, col_varchar_key +FROM t2 AS derived2 +); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "22.71" + }, + "nested_loop": [ + { + "table": { + "table_name": "derived1", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "2.59", + "eval_cost": "0.70", + "prefix_cost": "3.29", + "data_read_per_join": "112" + }, + "used_columns": [ + "col_varchar_key", + "col_varchar_nokey" + ], + "attached_condition": "(`derived1`.`col_varchar_nokey` is not null)", + "materialized_from_subquery": { + "using_temporary_table": true, + "dependent": false, + "cacheable": true, + "query_block": { + "select_id": 2, + "cost_info": { + "query_cost": "1.21" + }, + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "0.70", + "prefix_cost": "1.21", + "data_read_per_join": "112" + }, + "used_columns": [ + "col_varchar_key", + "col_varchar_nokey" + ] + } + } + } + } + }, + { + "table": { + "table_name": "derived2", + "access_type": "ref", + "possible_keys": [ + "col_varchar_key" + ], + "key": "col_varchar_key", + "used_key_parts": [ + "col_varchar_key" + ], + "key_length": "7", + "ref": [ + "derived1.col_varchar_nokey" + ], + "rows_examined_per_scan": 2, + "rows_produced_per_join": 7, + "filtered": "14.29", + "first_match": "derived1", + "cost_info": { + "read_cost": "3.50", + "eval_cost": "0.70", + "prefix_cost": "8.19", + "data_read_per_join": "112" + }, + "used_columns": [ + "col_varchar_key", + "col_varchar_nokey" + ], + "attached_condition": "(`test`.`derived2`.`col_varchar_nokey` = `derived1`.`col_varchar_nokey`)" + } + }, + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 140, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.52", + "eval_cost": "14.00", + "prefix_cost": "22.71", + "data_read_per_join": "1K" + }, + "used_columns": [ + "col_varchar_nokey" + ], + "attached_condition": "(is_not_null_compl(t1), (`test`.`t1`.`col_varchar_nokey` = `derived1`.`col_varchar_nokey`), true)" + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select `derived1`.`col_varchar_nokey` AS `col_varchar_nokey`,`derived1`.`col_varchar_key` AS `col_varchar_key` from (/* select#2 */ select `test`.`t2`.`col_varchar_key` AS `col_varchar_key`,`test`.`t2`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t2`) `derived1` left join `test`.`t1` on((`test`.`t1`.`col_varchar_nokey` = `derived1`.`col_varchar_nokey`)) semi join (`test`.`t2` `derived2`) where ((`test`.`derived2`.`col_varchar_nokey` = `derived1`.`col_varchar_nokey`) and (`test`.`derived2`.`col_varchar_key` = `derived1`.`col_varchar_nokey`)) +SELECT * +FROM (SELECT * FROM t2) AS derived1 +LEFT JOIN t1 +USING (col_varchar_nokey) +WHERE (col_varchar_nokey, col_varchar_nokey) IN +(SELECT col_varchar_nokey, col_varchar_key +FROM t2 AS derived2 +); +col_varchar_nokey col_varchar_key +c c +d d +d d +j j +m m +v v +v v +y y +y y +y y +SET @@optimizer_switch= @optimizer_switch_saved; +DROP TABLE t1, t2; +CREATE TABLE t1 ( +col_int_nokey int NOT NULL, +col_int_key int NOT NULL, +KEY col_int_key (col_int_key) +); +INSERT INTO t1 VALUES +(1,7), (7,0), (4,9), (7,3), (0,4), (2,2), (9,5), (4,3), (0,1), (9,3), +(1,6), (3,7), (8,5), (8,1), (18,204), (84,224), (6,9), (3,5), (6,0), (6,3); +CREATE TABLE t2 ( +col_int_nokey int NOT NULL, +col_int_key int NOT NULL, +KEY col_int_key (col_int_key) +); +INSERT INTO t2 VALUES +(4,0), (6,8), (3,1), (5,8), (3,9), (246,24), (2,6), (9,1), (3,6), (8,2), +(1,4), (8,8), (8,4), (5,4), (7,7), (5,4), (1,1), (6,9), (2,4), (9,8); +explain format=json SELECT grandparent1.* +FROM t1 AS grandparent1 +LEFT JOIN t1 USING (col_int_nokey) +WHERE (col_int_nokey, col_int_nokey) IN +(SELECT col_int_nokey, col_int_key +FROM t2 +); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "57.82" + }, + "nested_loop": [ + { + "table": { + "table_name": "grandparent1", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 20, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "2.00", + "prefix_cost": "2.51", + "data_read_per_join": "320" + }, + "used_columns": [ + "col_int_nokey", + "col_int_key" + ] + } + }, + { + "table": { + "table_name": "t2", + "access_type": "ref", + "possible_keys": [ + "col_int_key" + ], + "key": "col_int_key", + "used_key_parts": [ + "col_int_key" + ], + "key_length": "4", + "ref": [ + "test.grandparent1.col_int_nokey" + ], + "rows_examined_per_scan": 2, + "rows_produced_per_join": 20, + "filtered": "10.00", + "first_match": "grandparent1", + "cost_info": { + "read_cost": "10.00", + "eval_cost": "2.00", + "prefix_cost": "17.31", + "data_read_per_join": "320" + }, + "used_columns": [ + "col_int_nokey", + "col_int_key" + ], + "attached_condition": "(`test`.`t2`.`col_int_nokey` = `test`.`grandparent1`.`col_int_nokey`)" + } + }, + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 400, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "40.00", + "prefix_cost": "57.82", + "data_read_per_join": "6K" + }, + "used_columns": [ + "col_int_nokey" + ], + "attached_condition": "(is_not_null_compl(t1), (`test`.`t1`.`col_int_nokey` = `test`.`grandparent1`.`col_int_nokey`), true)" + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`grandparent1`.`col_int_nokey` AS `col_int_nokey`,`test`.`grandparent1`.`col_int_key` AS `col_int_key` from `test`.`t1` `grandparent1` left join `test`.`t1` on((`test`.`t1`.`col_int_nokey` = `test`.`grandparent1`.`col_int_nokey`)) semi join (`test`.`t2`) where ((`test`.`t2`.`col_int_nokey` = `test`.`grandparent1`.`col_int_nokey`) and (`test`.`t2`.`col_int_key` = `test`.`grandparent1`.`col_int_nokey`)) +SELECT grandparent1.* +FROM t1 AS grandparent1 +LEFT JOIN t1 USING (col_int_nokey) +WHERE (col_int_nokey, col_int_nokey) IN +(SELECT col_int_nokey, col_int_key +FROM t2 +); +col_int_nokey col_int_key +1 6 +1 6 +1 7 +1 7 +7 0 +7 0 +7 3 +7 3 +8 1 +8 1 +8 5 +8 5 +DROP TABLE t1, t2; +CREATE TABLE t1 ( +pk int, +col_int_key int, +col_datetime_key datetime, +col_varchar_key varchar(1), +col_varchar_nokey varchar(1), +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_datetime_key (col_datetime_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4 engine=MyISAM; +INSERT INTO t1 VALUES +(10,7,'2004-06-06 04:22:12','v','v'), (11,0,'2005-11-13 01:12:31','s','s'), +(12,9,'2002-05-04 01:50:00','l','l'), (13,3,'2004-10-27 10:28:45','y','y'), +(14,4,'2006-07-22 05:24:23','c','c'), (15,2,'2002-05-16 21:34:03','i','i'), +(16,5,'2008-04-17 10:45:30','h','h'), (17,3,'2009-04-21 02:58:02','q','q'), +(18,1,'2008-01-11 11:01:51','a','a'), (19,3,'1900-01-01 00:00:00','v','v'), +(20,6,'2007-05-17 18:24:57','u','u'), (21,7,'2007-08-07 00:00:00','s','s'), +(22,5,'2001-08-28 00:00:00','y','y'), (23,1,'2004-04-16 00:27:28','z','z'), +(24,204,'2005-05-03 07:06:22','h','h'), (25,224,'2009-03-11 17:09:50','p','p'), +(26,9,'2007-12-08 01:54:28','e','e'), (27,5,'2009-07-28 18:19:54','i','i'), +(28,0,'2008-06-08 00:00:00','y','y'), (29,3,'2005-02-09 09:20:26','w','w'); +CREATE TABLE t2 ( +pk int, +col_int_key int, +col_datetime_key datetime, +col_varchar_key varchar(1), +col_varchar_nokey varchar(1), +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_datetime_key (col_datetime_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4 engine=MyISAM; +INSERT INTO t2 VALUES +(1,0,'2002-02-13 17:30:06','j','j'), (2,8,'2008-09-27 00:34:58','v','v'), +(3,1,'2007-05-28 00:00:00','c','c'), (4,8,'2009-07-25 09:21:20','m','m'), +(5,9,'2002-01-16 00:00:00','d','d'), (6,24,'2006-10-12 04:32:53','d','d'), +(7,6,'2001-02-15 03:08:38','y','y'), (8,1,'2004-10-02 20:31:15','t','t'), +(9,6,'2002-08-20 22:48:00','d','d'), (10,2,'1900-01-01 00:00:00','s','s'), +(11,4,'2005-08-15 00:00:00','r','r'), (12,8,'1900-01-01 00:00:00','m','m'), +(13,4,'2008-05-16 08:09:06','b','b'), (14,4,'2001-01-20 12:47:23','x','x'), +(15,7,'2008-07-02 00:00:00','g','g'), (16,4,'1900-01-01 00:00:00','p','p'), +(17,1,'2002-12-08 11:34:58','q','q'), (18,9,'1900-01-01 00:00:00','w','w'), +(19,4,'1900-01-01 00:00:00','d','d'), (20,8,'2002-08-25 20:35:06','e','e'); +SELECT alias1.col_datetime_key +FROM t2 AS alias1 +RIGHT JOIN t2 AS alias2 +JOIN t2 AS alias3 +ON alias3.pk = alias2.pk +ON alias3.col_varchar_nokey = alias2.col_varchar_key OR +alias2.col_varchar_nokey +WHERE (alias2.col_varchar_key, alias2.col_varchar_key) IN +(SELECT sq2_alias2.col_varchar_key, sq2_alias1.col_varchar_nokey +FROM t1 AS sq2_alias1, t1 AS sq2_alias2 +WHERE sq2_alias2.col_int_key < 2); +col_datetime_key +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +2001-01-20 12:47:23 +2001-01-20 12:47:23 +2001-02-15 03:08:38 +2001-02-15 03:08:38 +2002-01-16 00:00:00 +2002-01-16 00:00:00 +2002-02-13 17:30:06 +2002-02-13 17:30:06 +2002-08-20 22:48:00 +2002-08-20 22:48:00 +2002-08-25 20:35:06 +2002-08-25 20:35:06 +2002-12-08 11:34:58 +2002-12-08 11:34:58 +2004-10-02 20:31:15 +2004-10-02 20:31:15 +2005-08-15 00:00:00 +2005-08-15 00:00:00 +2006-10-12 04:32:53 +2006-10-12 04:32:53 +2007-05-28 00:00:00 +2007-05-28 00:00:00 +2008-05-16 08:09:06 +2008-05-16 08:09:06 +2008-07-02 00:00:00 +2008-07-02 00:00:00 +2008-09-27 00:34:58 +2008-09-27 00:34:58 +2009-07-25 09:21:20 +2009-07-25 09:21:20 +ALTER TABLE t1 DISABLE KEYS; +ALTER TABLE t2 DISABLE KEYS; +explain format=json SELECT alias1.col_datetime_key +FROM t2 AS alias1 +RIGHT JOIN t2 AS alias2 +JOIN t2 AS alias3 +ON alias3.pk = alias2.pk +ON alias3.col_varchar_nokey = alias2.col_varchar_key OR +alias2.col_varchar_nokey +WHERE (alias2.col_varchar_key, alias2.col_varchar_key) IN +(SELECT sq2_alias2.col_varchar_key, sq2_alias1.col_varchar_nokey +FROM t1 AS sq2_alias1, t1 AS sq2_alias2 +WHERE sq2_alias2.col_int_key < 2); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "151.21" + }, + "nested_loop": [ + { + "table": { + "table_name": "alias2", + "access_type": "ALL", + "possible_keys": [ + "PRIMARY" + ], + "rows_examined_per_scan": 20, + "rows_produced_per_join": 20, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.53", + "eval_cost": "2.00", + "prefix_cost": "2.53", + "data_read_per_join": "640" + }, + "used_columns": [ + "pk", + "col_varchar_key", + "col_varchar_nokey" + ] + } + }, + { + "table": { + "table_name": "alias3", + "access_type": "eq_ref", + "possible_keys": [ + "PRIMARY" + ], + "key": "PRIMARY", + "used_key_parts": [ + "pk" + ], + "key_length": "4", + "ref": [ + "test.alias2.pk" + ], + "rows_examined_per_scan": 1, + "rows_produced_per_join": 20, + "filtered": "100.00", + "cost_info": { + "read_cost": "5.00", + "eval_cost": "2.00", + "prefix_cost": "9.53", + "data_read_per_join": "640" + }, + "used_columns": [ + "pk", + "col_varchar_nokey" + ] + } + }, + { + "table": { + "table_name": "sq2_alias2", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 20, + "filtered": "5.00", + "cost_info": { + "read_cost": "37.24", + "eval_cost": "2.00", + "prefix_cost": "24.73", + "data_read_per_join": "640" + }, + "used_columns": [ + "col_int_key", + "col_varchar_key" + ], + "attached_condition": "((`test`.`sq2_alias2`.`col_varchar_key` = `test`.`alias2`.`col_varchar_key`) and (`test`.`sq2_alias2`.`col_int_key` < 2))" + } + }, + { + "table": { + "table_name": "sq2_alias1", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 20, + "filtered": "10.00", + "first_match": "alias3", + "cost_info": { + "read_cost": "10.58", + "eval_cost": "2.00", + "prefix_cost": "110.68", + "data_read_per_join": "640" + }, + "used_columns": [ + "col_varchar_nokey" + ], + "attached_condition": "(`test`.`sq2_alias1`.`col_varchar_nokey` = `test`.`alias2`.`col_varchar_key`)" + } + }, + { + "table": { + "table_name": "alias1", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 400, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.53", + "eval_cost": "40.00", + "prefix_cost": "151.21", + "data_read_per_join": "12K" + }, + "used_columns": [ + "col_datetime_key" + ], + "attached_condition": "(is_not_null_compl(alias1), (((`test`.`alias3`.`col_varchar_nokey` = `test`.`alias2`.`col_varchar_key`) and (`test`.`sq2_alias2`.`col_varchar_key` = `test`.`alias2`.`col_varchar_key`) and (`test`.`sq2_alias1`.`col_varchar_nokey` = `test`.`alias2`.`col_varchar_key`)) or (0 <> `test`.`alias2`.`col_varchar_nokey`)), true)" + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`alias1`.`col_datetime_key` AS `col_datetime_key` from `test`.`t2` `alias2` join `test`.`t2` `alias3` left join `test`.`t2` `alias1` on((((`test`.`alias3`.`col_varchar_nokey` = `test`.`alias2`.`col_varchar_key`) and (`test`.`sq2_alias2`.`col_varchar_key` = `test`.`alias2`.`col_varchar_key`) and (`test`.`sq2_alias1`.`col_varchar_nokey` = `test`.`alias2`.`col_varchar_key`)) or (0 <> `test`.`alias2`.`col_varchar_nokey`))) semi join (`test`.`t1` `sq2_alias1` join `test`.`t1` `sq2_alias2`) where ((`test`.`alias3`.`pk` = `test`.`alias2`.`pk`) and (`test`.`sq2_alias2`.`col_varchar_key` = `test`.`alias2`.`col_varchar_key`) and (`test`.`sq2_alias1`.`col_varchar_nokey` = `test`.`alias2`.`col_varchar_key`) and (`test`.`sq2_alias2`.`col_int_key` < 2)) +SELECT alias1.col_datetime_key +FROM t2 AS alias1 +RIGHT JOIN t2 AS alias2 +JOIN t2 AS alias3 +ON alias3.pk = alias2.pk +ON alias3.col_varchar_nokey = alias2.col_varchar_key OR +alias2.col_varchar_nokey +WHERE (alias2.col_varchar_key, alias2.col_varchar_key) IN +(SELECT sq2_alias2.col_varchar_key, sq2_alias1.col_varchar_nokey +FROM t1 AS sq2_alias1, t1 AS sq2_alias2 +WHERE sq2_alias2.col_int_key < 2); +col_datetime_key +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +2001-01-20 12:47:23 +2001-01-20 12:47:23 +2001-02-15 03:08:38 +2001-02-15 03:08:38 +2002-01-16 00:00:00 +2002-01-16 00:00:00 +2002-02-13 17:30:06 +2002-02-13 17:30:06 +2002-08-20 22:48:00 +2002-08-20 22:48:00 +2002-08-25 20:35:06 +2002-08-25 20:35:06 +2002-12-08 11:34:58 +2002-12-08 11:34:58 +2004-10-02 20:31:15 +2004-10-02 20:31:15 +2005-08-15 00:00:00 +2005-08-15 00:00:00 +2006-10-12 04:32:53 +2006-10-12 04:32:53 +2007-05-28 00:00:00 +2007-05-28 00:00:00 +2008-05-16 08:09:06 +2008-05-16 08:09:06 +2008-07-02 00:00:00 +2008-07-02 00:00:00 +2008-09-27 00:34:58 +2008-09-27 00:34:58 +2009-07-25 09:21:20 +2009-07-25 09:21:20 +DROP TABLE t1, t2; +# End of test for bug#14064201. +# +# Bug#18223655:ASSERTION FAILED: (INT)IDX >= 0 +# && IDX < PARENT_JOIN->TABLES +# +CREATE TABLE b (d INT); +CREATE TABLE c (a INT, b INT,c INT,d BLOB NOT NULL); +SELECT(SELECT 1 +FROM b WHERE(SELECT 1 IN (SELECT 1 FROM b WHERE 1 NOT BETWEEN d AND 1) +FROM b) IN (SELECT d FROM c)) as cc FROM b; +cc +INSERT INTO b VALUE(1); +INSERT INTO c VALUES(1,2,3,'1'),(2,3,4,'1'),(3,4,5,'C'); +SELECT(SELECT d FROM b WHERE(SELECT d IN +(SELECT d FROM b WHERE 1 NOT BETWEEN d AND 1) FROM b) IN +(SELECT d FROM c)) as cc FROM c; +cc +1 +1 +1 +DROP TABLE b,c; +# +# Bug#18447874:WRONG RESULT COMING FROM SEMI-JOIN +# +CREATE TABLE b ( +d INT(11) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE c ( +d BLOB +) ; +CREATE TABLE d ( +b INT(11) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO b VALUES(1),(2),(4); +INSERT INTO c VALUES(1),(2),(3); +SELECT 1 FROM b WHERE (SELECT 1 FROM d ) IN (SELECT d FROM c) ; +1 +INSERT INTO d VALUES(2); +SELECT 1 FROM b WHERE (SELECT 1 FROM d ) IN (SELECT d FROM c) ; +1 +1 +1 +1 +DROP TABLE b,c,d; +# +# Bug#17292723:INCORRECT RESULT FOR (SELECT...) IN (SELECT...) STATEMENT +# +CREATE TABLE t1 ( +ID int(11) NOT NULL AUTO_INCREMENT, +id2 int(11) DEFAULT NULL, +id3 int(11) DEFAULT NULL, +id4 varchar(150) COLLATE utf8_spanish_ci NOT NULL, +id5 int(11) DEFAULT NULL, +PRIMARY KEY (ID), +KEY id2 (id2), +KEY id3 (id3), +KEY id5 (id5) +) ENGINE=InnoDB; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 3778 'utf8_spanish_ci' is a collation of the deprecated character set UTF8MB3. Please consider using UTF8MB4 with an appropriate collation instead. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES +(123,1,1,'1',NULL), +(124,1,1,'2',NULL), +(125,1,1,'4',NULL), +(126,1,1,'3',NULL), +(127,1,1,'6',NULL), +(128,1,1,'8',NULL); +CREATE TABLE t2 ( +id6 int(11) NOT NULL, +id7 int(11) NOT NULL, +PRIMARY KEY (id6,id7), +KEY id7 (id7) +) ENGINE=InnoDB; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (126,123),(130,123),(135,123); +SELECT ID +FROM t1 p0 +WHERE p0.id3=1 +AND ( (SELECT p1.id FROM t1 p1 WHERE p1.id=123) IN (SELECT p3.id FROM t2 +p2, t1 p3 WHERE p0.id=p2.id6 AND p2.id7=p3.id)); +ID +126 +DROP TABLE t1,t2; +set @@optimizer_switch=@old_opt_switch; +# End of 5.6 tests +# +# Bug#19336348 DEBUG CRASH AT SETUP_SEMIJOIN_DUPS_ELIMINATION IN SQL/SQL_SELECT.CC +# +CREATE TABLE t1 ( +col_varchar_nokey varchar(1) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t1 VALUES ('c'),(NULL),('x'); +CREATE TABLE t2 ( +pk int, +col_varchar_key varchar(1), +PRIMARY KEY (pk), +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t2 VALUES (10,'l'),(11,'p'); +ANALYZE TABLE t1,t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN SELECT 1 +FROM t1 AS outr +WHERE outr.col_varchar_nokey IN +( +SELECT innr.col_varchar_key +FROM t2 AS innr +WHERE innr.pk <= 7 +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE outr NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 SIMPLE innr NULL ref PRIMARY,col_varchar_key col_varchar_key 7 test.outr.col_varchar_nokey 1 50.00 Using where; Using index; FirstMatch(outr) +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` `outr` semi join (`test`.`t2` `innr`) where ((`test`.`innr`.`col_varchar_key` = `test`.`outr`.`col_varchar_nokey`) and (`test`.`innr`.`pk` <= 7)) +SELECT 1 +FROM t1 AS outr +WHERE outr.col_varchar_nokey IN +( +SELECT innr.col_varchar_key +FROM t2 AS innr +WHERE innr.pk <= 7 +) +; +1 +DROP TABLE t1,t2; +# +# Bug#18174394 BLOBS: CRASH AFTER UNINITIALIZED VALUES IN ITEM_FIELD::STR_RESULT +# +CREATE TABLE t1(d BLOB, b BLOB); +INSERT INTO t1(d,b) VALUES ('aaaa',''),('bnbb',''); +SELECT 1 FROM t1 +WHERE (SELECT b FROM t1) IN (SELECT (d>=1) FROM t1); +ERROR 21000: Subquery returns more than 1 row +DROP TABLE t1; +# +# Bug#19779600: ASSERT FAILED IN REPLACE_SUBCONDITION WITH IN +# PREDICATE INSIDE IN PREDICATE +# +CREATE TABLE t(X INT) ENGINE=InnoDB; +INSERT INTO t VALUES (1); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +EXPLAIN SELECT 1 FROM t WHERE (1 IN (SELECT 1 FROM t)) IN (SELECT 1 FROM t); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 PRIMARY t NULL ALL NULL NULL NULL NULL 1 100.00 FirstMatch(t); Using join buffer (hash join) +2 SUBQUERY t NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t` semi join (`test`.`t`) where true +SELECT 1 FROM t WHERE (1 IN (SELECT 1 FROM t)) IN (SELECT 1 FROM t); +1 +1 +DROP TABLE t; +# +# Bug#19465034 ASSERT ON SETUP_SEMIJOIN_DUPS_ELIMINATION IN SQL/SQL_SELECT.CC +# +CREATE TABLE t1 ( +pk INTEGER NOT NULL, +i1 INTEGER NOT NULL, +PRIMARY KEY (pk) +) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1,1); +CREATE TABLE t2 ( +pk INTEGER NOT NULL, +c1 VARCHAR(1) NOT NULL, +PRIMARY KEY (pk), +KEY c1_key (c1) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t2 VALUES (1,'j'),(2,'v'),(3,'c'); +CREATE TABLE t3 ( +pk INTEGER NOT NULL, +c1 VARCHAR(1) NOT NULL, +PRIMARY KEY (pk), +KEY c1_key (c1) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t3 VALUES (10,'v'),(11,'s'); +ANALYZE TABLE t1, t2, t3; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +EXPLAIN SELECT * +FROM t1 JOIN t2 ON t1.i1 >= t2.pk +WHERE t2.c1 IN ( +SELECT t3.c1 +FROM t3 +WHERE t3.pk < 3 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t2 NULL ALL PRIMARY,c1_key NULL NULL NULL 3 33.33 Range checked for each record (index map: 0x3) +2 SIMPLE t3 NULL ref PRIMARY,c1_key c1_key 6 test.t2.c1 1 50.00 Using where; Using index; FirstMatch(t2) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`i1` AS `i1`,`test`.`t2`.`pk` AS `pk`,`test`.`t2`.`c1` AS `c1` from `test`.`t1` join `test`.`t2` semi join (`test`.`t3`) where ((`test`.`t3`.`c1` = `test`.`t2`.`c1`) and (`test`.`t3`.`pk` < 3) and (`test`.`t1`.`i1` >= `test`.`t2`.`pk`)) +SELECT * +FROM t1 JOIN t2 ON t1.i1 >= t2.pk +WHERE t2.c1 IN ( +SELECT t3.c1 +FROM t3 +WHERE t3.pk < 3 +); +pk i1 pk c1 +DROP TABLE t1,t2,t3; +# +# Bug#19586047: CRASH IN ARG_COMPARATOR::SET_CMP_FUNC +# +CREATE TABLE t1(x INT) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT 1 FROM t1 WHERE EXISTS(SELECT 1) IN (SELECT 1 FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 1 100.00 FirstMatch(t1); Using join buffer (hash join) +2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` semi join (`test`.`t1`) where true +SELECT 1 FROM t1 WHERE EXISTS(SELECT 1) IN (SELECT 1 FROM t1); +1 +1 +EXPLAIN SELECT 1 FROM t1 WHERE (SELECT 1, 2 FROM t1) IN (SELECT 1, 2 FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 1 100.00 FirstMatch(t1); Using join buffer (hash join) +2 SUBQUERY t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` semi join (`test`.`t1`) where true +SELECT 1 FROM t1 WHERE (SELECT 1, 2 FROM t1) IN (SELECT 1, 2 FROM t1); +1 +1 +EXPLAIN SELECT 1 FROM t1 WHERE +(SELECT 1, 2 FROM t1 WHERE x = 2) IN (SELECT 1, 2 FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +2 SUBQUERY t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` semi join (`test`.`t1`) where false +SELECT 1 FROM t1 WHERE +(SELECT 1, 2 FROM t1 WHERE x = 2) IN (SELECT 1, 2 FROM t1); +1 +DROP TABLE t1; +# +#Bug#20119743 ASSERTIONQEP_TAB->USE_ORDER() IN ENUM_NESTED_LOOP_STATE +# EVALUATE_JOIN_RECORD +# +CREATE TABLE t1 ( +pk int(11) NOT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +PRIMARY KEY (pk) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (1,'x'); +CREATE TABLE t2 ( +col_date_key date DEFAULT NULL, +col_int_key int(11) DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +KEY col_int_key (col_int_key), +KEY col_date_key (col_date_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES ('2000-12-03', 8, 'x', 'x'),('2008-05-03', 7, 'd', 'd'), +('2005-12-06', 1, 'r', 'r'),('2000-04-10', 7, 'f', 'f'), +('2002-11-05', 9, 'y', 'y'),('2000-09-06', NULL, 'u', 'u'), +(NULL, 1, 'm', 'm'),('2007-06-14', 9, NULL, NULL), +('2007-11-17', 2, 'o', 'o'),('2009-02-23', 9, 'w', 'w'), +('2007-01-08', 2, 'm', 'm'), ('2008-06-10', 4, 'q', 'q'), +('2002-10-20', 0, NULL, NULL),('2008-09-12', 4, 'd', 'd'), +('2006-06-16', 8, 'g', 'g'),('2004-09-18', NULL, 'x', 'x'), +('1900-01-01', NULL, 'f', 'f'),('2005-09-13', 0, 'p', 'p'), +('2007-04-09', NULL, 'j', 'j'),('2000-09-20', 8, 'c', 'c'); +CREATE TABLE t3 ( +pk int(11) NOT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +PRIMARY KEY (pk) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t3 VALUES (1, 'c'),(2, 'c'),(3, 'q'),(4, 'g'),(5, 'e'),(6, 'l'), +(7, NULL),(8, 'v'),(9, 'c'),(10, 'u'),(11, 'x'),(12, 'x'),(13, 'x'),(14, 'l'), +(15, 'e'),(16, 's'),(17, 'k'),(18, 'm'),(19, 'x'),(20, 's'); +ANALYZE TABLE t1,t2,t3; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +EXPLAIN SELECT r1.col_date_key +FROM t2 AS r1 +WHERE r1.col_int_key NOT IN +(SELECT ir2.pk +FROM t2 AS ir1 STRAIGHT_JOIN t1 AS ir2 +ON ir2.col_varchar_nokey = ir1.col_varchar_key +WHERE ir2.col_varchar_nokey > r1.col_varchar_nokey +AND ir2.pk IN +(SELECT iir2.pk +FROM t2 AS iir1 RIGHT JOIN t3 AS iir2 +ON iir2.col_varchar_nokey = iir1.col_varchar_key)) +ORDER BY r1.col_date_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY r1 NULL ALL NULL NULL NULL NULL 20 100.00 Using where; Using filesort +2 DEPENDENT SUBQUERY ir1 NULL index col_varchar_key col_varchar_key 12 NULL 20 100.00 Using where; Using index +2 DEPENDENT SUBQUERY ir2 NULL eq_ref PRIMARY PRIMARY 4 func 1 100.00 Using where; Full scan on NULL key +2 DEPENDENT SUBQUERY iir2 NULL eq_ref PRIMARY PRIMARY 4 func 1 100.00 Using where; Full scan on NULL key +2 DEPENDENT SUBQUERY iir1 NULL ref col_varchar_key col_varchar_key 7 test.iir2.col_varchar_nokey 1 100.00 Using index; FirstMatch(ir2) +SELECT r1.col_date_key +FROM t2 AS r1 +WHERE r1.col_int_key NOT IN +(SELECT ir2.pk +FROM t2 AS ir1 STRAIGHT_JOIN t1 AS ir2 +ON ir2.col_varchar_nokey = ir1.col_varchar_key +WHERE ir2.col_varchar_nokey > r1.col_varchar_nokey +AND ir2.pk IN +(SELECT iir2.pk +FROM t2 AS iir1 RIGHT JOIN t3 AS iir2 +ON iir2.col_varchar_nokey = iir1.col_varchar_key)) +ORDER BY r1.col_date_key; +col_date_key +2000-04-10 +2000-09-20 +2000-12-03 +2002-10-20 +2002-11-05 +2004-09-18 +2005-09-13 +2006-06-16 +2007-01-08 +2007-06-14 +2007-11-17 +2008-05-03 +2008-06-10 +2008-09-12 +2009-02-23 +SELECT COUNT(r1.col_date_key) AS COUNT_NUM +FROM t2 AS r1 +WHERE r1.col_int_key NOT IN +(SELECT ir2.pk +FROM t2 AS ir1 STRAIGHT_JOIN t1 AS ir2 +ON ir2.col_varchar_nokey = ir1.col_varchar_key +WHERE ir2.col_varchar_nokey > r1.col_varchar_nokey +AND ir2.pk IN +(SELECT iir2.pk +FROM t2 AS iir1 RIGHT JOIN t3 AS iir2 +ON iir2.col_varchar_nokey = iir1.col_varchar_key +WHERE iir2.pk<3)); +COUNT_NUM +15 +DROP TABLE t1,t2,t3; +# +# Bug#20554585 ASSERT JOIN()->TABLES == 0... IN JOIN_TAB::GET_SJ_STRATEGY ON SUBQUERY + VAR +# +CREATE TABLE t1 ( +pk int NOT NULL, +PRIMARY KEY (pk) +); +CREATE TABLE t2 ( +pk int NOT NULL, +col_int_key int, +col_varchar_key varchar(1), +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key) +); +CREATE TABLE t3 ( +pk int NOT NULL, +col_int_key int, +col_varchar_key varchar(1), +col_varchar varchar(1), +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key) +); +INSERT INTO t3 VALUES (1,4,'c','g'),(20,1,'i','p'); +CREATE TABLE t4 ( +col_int int +); +CREATE TABLE t5 ( +col_varchar_key varchar(1), +pk int NOT NULL, +col_int int, +PRIMARY KEY (pk), +KEY col_varchar_key (col_varchar_key) +); +SELECT table1.col_varchar_key AS field1 +FROM (t3 AS table1 +INNER JOIN ( +SELECT SUBQUERY1_t1.* +FROM (t1 AS SUBQUERY1_t1 +RIGHT JOIN (t2 AS SUBQUERY1_t2 +INNER JOIN t3 AS SUBQUERY1_t3 +ON (SUBQUERY1_t3.col_varchar_key = SUBQUERY1_t2.col_varchar_key) +) ON (SUBQUERY1_t3.col_int_key = SUBQUERY1_t2.pk) +) +WHERE SUBQUERY1_t2.col_varchar_key >= ANY ( +SELECT CHILD_SUBQUERY1_t2.col_varchar AS CHILD_SUBQUERY1_field1 +FROM (t2 AS CHILD_SUBQUERY1_t1 +LEFT OUTER JOIN t3 AS CHILD_SUBQUERY1_t2 +ON (CHILD_SUBQUERY1_t2.col_int_key = CHILD_SUBQUERY1_t1.col_int_key) +) +WHERE CHILD_SUBQUERY1_t1.pk >= SUBQUERY1_t2.pk +) +) AS table2 +ON (table2.pk = table1.pk) +) +WHERE (EXISTS (( +SELECT DISTINCT SUBQUERY2_t2.col_int AS SUBQUERY2_field1 +FROM (t4 AS SUBQUERY2_t1 +LEFT OUTER JOIN t5 AS SUBQUERY2_t2 +ON (SUBQUERY2_t2.pk = SUBQUERY2_t1.col_int) +) +WHERE SUBQUERY2_t2.col_varchar_key != @var4 +))) +AND table1.col_int_key < (35 + 192) +ORDER BY field1 +; +field1 +DROP TABLE t1, t2, t3, t4, t5; +# +# Bug#18892055: MISSING DATA ON SELECT ... IN WITH JOINS AND INNODB +# ENGINE +# +CREATE TABLE t1 ( +col_int_key INT, +pk INT NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +) ENGINE = INNODB; +INSERT INTO t1 VALUES +( 0, 3 ), +( 0, 4 ), +( 3, 1 ), +( 900000000, 2 ), +( 1368719360, 5 ), +( 1922236416, 6 ), +( 8,7 ); +CREATE TABLE t2 ( +pk INT NOT NULL, +col_int INT, +PRIMARY KEY (pk) +) ENGINE = INNODB; +INSERT INTO t2 VALUES +( 1, 3 ), +( 2, 2 ), +( 3, 8 ), +( 4, 7 ); +CREATE TABLE t3 ( +col_int_key INT, +col_int INT, +KEY (col_int_key) +) ENGINE = INNODB; +INSERT INTO t3 VALUES +( 5, 1 ), +( -1, -1 ), +( 300000000, 1 ), +( 8, 1 ); +CREATE TABLE t4 ( col_int_key INT ) ENGINE = INNODB; +INSERT INTO t4 VALUES +(0), +(3), +(8), +(900000000), +(1368719360), +(1922236416); +ANALYZE TABLE t1, t2, t3, t4; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +test.t4 analyze status OK +explain SELECT * +FROM t4 +WHERE (col_int_key) IN ( +SELECT t1.col_int_key +FROM t1 LEFT JOIN ( t2 JOIN t3 ON t3.col_int_key = t2.col_int ) USING ( pk ) +WHERE t3.col_int IS NULL +) +ORDER BY col_int_key +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 6 100.00 Parallel execute (1 workers) +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 6 100.00 Using where; Using filesort +2 SIMPLE t1 NULL ref col_int_key col_int_key 5 test.t4.col_int_key 1 100.00 Using index +2 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.pk 1 100.00 NULL +2 SIMPLE t3 NULL ref col_int_key col_int_key 5 test.t2.col_int 1 25.00 Using where; FirstMatch(t4) +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`col_int_key` AS `col_int_key` from `test`.`t4` semi join (`test`.`t1` left join (`test`.`t2` join `test`.`t3`) on(((`test`.`t1`.`pk` = `test`.`t2`.`pk`) and (`test`.`t3`.`col_int_key` = `test`.`t2`.`col_int`)))) where ((`test`.`t1`.`col_int_key` = `test`.`t4`.`col_int_key`) and (`test`.`t3`.`col_int` is null)) order by `test`.`t4`.`col_int_key` +explain format=tree SELECT * +FROM t4 +WHERE (col_int_key) IN ( +SELECT t1.col_int_key +FROM t1 LEFT JOIN ( t2 JOIN t3 ON t3.col_int_key = t2.col_int ) USING ( pk ) +WHERE t3.col_int IS NULL +) +ORDER BY col_int_key +; +EXPLAIN +-> Parallel scan on + -> Nested loop semijoin (cost=3.05 rows=7) + -> Sort: t4.col_int_key (cost=0.85 rows=6) + -> Filter: (t4.col_int_key is not null) + -> PQblock scan on t4 + -> Filter: (t3.col_int is null) (cost=2.14 rows=1) + -> Nested loop left join (cost=2.14 rows=1) + -> Index lookup on t1 using col_int_key (col_int_key=t4.col_int_key) (cost=0.27 rows=1) + -> Nested loop inner join (cost=2.41 rows=1) + -> Single-row index lookup on t2 using PRIMARY (pk=t1.pk) (cost=0.26 rows=1) + -> Index lookup on t3 using col_int_key (col_int_key=t2.col_int) (cost=0.07 rows=1) + +SELECT * +FROM t4 +WHERE (col_int_key) IN ( +SELECT t1.col_int_key +FROM t1 LEFT JOIN ( t2 JOIN t3 ON t3.col_int_key = t2.col_int ) USING ( pk ) +WHERE t3.col_int IS NULL +) +ORDER BY col_int_key +; +col_int_key +0 +3 +8 +900000000 +1368719360 +1922236416 +DROP TABLE t1, t2, t3, t4; +# +# Bug#20835095 CRASH AT CREATE_REF_FOR_KEY IN SQL/SQL_SELECT.CC +# +CREATE TABLE t1 ( +pk INTEGER, +var_10_latin1 VARCHAR(10) CHARACTER SET latin1, +var_255_utf8 VARCHAR(255) CHARACTER SET utf8, +var_255_latin1 VARCHAR(255) CHARACTER SET latin1, +var_10_utf8 VARCHAR(10) CHARACTER SET utf8, +PRIMARY KEY (pk) +); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +CREATE VIEW v1 AS SELECT * FROM t1; +INSERT INTO t1 VALUES +(1,'FROCJ','korrhrspki','UAYVL','BPZIS'), +(2,'him','a','CHYKN','OZZQT'), +(3,'WBITK','ULWBF','have','rhrh'), +(4,'or','right','up','it'), +(5,'GGDCP','x','who','as'), +(6,'j','i','e','w'); +CREATE TABLE tv +SELECT var_255_utf8 AS field1 +FROM t1; +EXPLAIN SELECT * FROM tv +WHERE field1 IN ( +SELECT tv1.var_255_utf8 +FROM v1 AS tv1 LEFT JOIN v1 AS tv2 ON tv1.var_10_latin1=tv2.var_10_utf8); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE tv NULL ALL NULL NULL NULL NULL 6 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 6 16.67 Using where +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 6 100.00 Using where; FirstMatch(tv) +Warnings: +Note 1003 /* select#1 */ select `test`.`tv`.`field1` AS `field1` from `test`.`tv` semi join (`test`.`t1` left join (`test`.`t1`) on((`test`.`t1`.`var_10_latin1` = `test`.`t1`.`var_10_utf8`))) where (`test`.`t1`.`var_255_utf8` = `test`.`tv`.`field1`) +SELECT * FROM tv +WHERE field1 IN ( +SELECT tv1.var_255_utf8 +FROM v1 AS tv1 LEFT JOIN v1 AS tv2 ON tv1.var_10_latin1=tv2.var_10_utf8); +field1 +korrhrspki +a +ULWBF +right +x +i +DROP VIEW v1; +DROP TABLE t1, tv; +# 17832047 Crash in calculate_materialization_costs +CREATE TABLE t1(a INTEGER PRIMARY KEY); +INSERT INTO t1 VALUES (0),(1),(2); +SELECT 1 FROM t1 +WHERE 1 IN +(SELECT 1 BETWEEN (LENGTH(a) IN (SELECT 1 FROM t1)) AND 1 +FROM t1 +); +1 +1 +1 +1 +DROP TABLE t1; +# 17845989 Assertion failed: !(used_tables() & ... +CREATE TABLE a(b INTEGER) engine=innodb; +CREATE TABLE c(a INTEGER) engine=innodb; +SELECT 1 +FROM a +WHERE 1 IN (SELECT (a.b IS NULL) IN (SELECT 1 FROM c) FROM c) +; +1 +DROP TABLE a, c; +# +# Bug#18194196: OPTIMIZER EXECUTES STATEMENT INPERFORMANT +# +CREATE TABLE t1 (uid INTEGER, fid INTEGER, INDEX(uid)); +INSERT INTO t1 VALUES +(1,1), (1,2), (1,3), (1,4), +(2,5), (2,6), (2,7), (2,8), +(3,1), (3,2), (3,9); +CREATE TABLE t2 (uid INT PRIMARY KEY, name VARCHAR(128), INDEX(name)); +INSERT INTO t2 VALUES +(1, "A"), (2, "B"), (3, "C"), (4, "D"), (5, "E"), +(6, "F"), (7, "G"), (8, "H"), (9, "I"); +CREATE TABLE t3 (uid INT, fid INT, INDEX(uid)); +INSERT INTO t3 VALUES +(1,1), (1,2), (1,3),(1,4), +(2,5), (2,6), (2,7), (2,8), +(3,1), (3,2), (3,9); +CREATE TABLE t4 (uid INT PRIMARY KEY, name VARCHAR(128), INDEX(name)); +INSERT INTO t4 VALUES +(1, "A"), (2, "B"), (3, "C"), (4, "D"), (5, "E"), +(6, "F"), (7, "G"), (8, "H"), (9, "I"); +ANALYZE TABLE t1,t2,t3,t4; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +test.t4 analyze status OK +EXPLAIN SELECT name FROM t2, t1 +WHERE t1.uid IN (SELECT t4.uid FROM t4, t3 WHERE t3.uid=1 AND t4.uid=t3.fid) +AND t2.uid=t1.fid; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL uid NULL NULL NULL 11 100.00 Using where +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.fid 1 100.00 NULL +1 SIMPLE t4 NULL eq_ref PRIMARY PRIMARY 4 test.t1.uid 1 100.00 Using index +1 SIMPLE t3 NULL ref uid uid 5 const 4 10.00 Using where; FirstMatch(t4) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`name` AS `name` from `test`.`t4` join `test`.`t2` join `test`.`t1` semi join (`test`.`t3`) where ((`test`.`t4`.`uid` = `test`.`t1`.`uid`) and (`test`.`t3`.`fid` = `test`.`t1`.`uid`) and (`test`.`t3`.`uid` = 1) and (`test`.`t2`.`uid` = `test`.`t1`.`fid`)) +FLUSH STATUS; +SELECT name FROM t2, t1 +WHERE t1.uid IN (SELECT t4.uid FROM t4, t3 WHERE t3.uid=1 AND t4.uid=t3.fid) +AND t2.uid=t1.fid; +name +A +A +B +B +C +D +E +F +G +H +I +SHOW STATUS LIKE '%handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 25 +Handler_read_last 0 +Handler_read_next 10 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 12 +DROP TABLE t1,t2,t3,t4; +# End of test for Bug#18194196 +# +# Bug#21184091 ASSERT `READ_ROWS >= 0.0' AT +# COST_MODEL_SERVER::TMPTABLE_READWRITE_COST() +# +CREATE TABLE t1 ( +pk INTEGER, +col_varchar varchar(1), +col_int INTEGER, +PRIMARY KEY (pk) +) ENGINE=MyISAM; +CREATE TABLE t2 ( +col_int INTEGER, +col_varchar varchar(1) +) ENGINE=MyISAM; +INSERT INTO t2 VALUES (7,'x'); +INSERT INTO t2 VALUES (4,'z'); +SELECT t2.col_varchar +FROM t2 STRAIGHT_JOIN t1 ON t2.col_varchar = t1.col_varchar +JOIN t2 AS table3 ON t1.pk = table3.col_int +WHERE t1.pk IN (SELECT col_int FROM t1); +col_varchar +DROP TABLE t1,t2; +# End of test for Bug#21184091 +# Bug#21139722: Assertion failed: !(used_tables() & ((table_map) 1) ... +CREATE TABLE t1(a INTEGER) engine=innodb; +CREATE TABLE t2(b INTEGER) engine=innodb; +explain SELECT 1 +FROM (SELECT 1 IN (SELECT 1 +FROM t1 +WHERE (SELECT 1 FROM t2 HAVING b) NOT IN (SELECT 1 FROM t2) +) +FROM t2 +) AS z; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DERIVED t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +3 DEPENDENT SUBQUERY t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +5 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +4 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1276 Field or reference 'b' of SELECT #4 was resolved in SELECT #2 +Note 1003 /* select#1 */ select 1 AS `1` from (/* select#2 */ select (1,(/* select#3 */ select 1 from `test`.`t1` where ((/* select#4 */ select 1 from `test`.`t2` having (0 <> `test`.`t2`.`b`)),(/* select#5 */ select 1 from `test`.`t2` where (outer_field_is_not_null, (((/* select#4 */ select 1 from `test`.`t2` having (0 <> `test`.`t2`.`b`))) = 1), true)) is false))) AS `1 IN (SELECT 1 +FROM t1 +WHERE (SELECT 1 FROM t2 HAVING b) NOT IN (SELECT 1 FROM t2) +)` from `test`.`t2`) `z` +SELECT 1 +FROM (SELECT 1 IN (SELECT 1 +FROM t1 +WHERE (SELECT 1 FROM t2 HAVING b) NOT IN (SELECT 1 FROM t2) +) +FROM t2 +) AS z; +1 +DROP TABLE t1, t2; +CREATE TABLE t1(a INTEGER) engine=innodb; +explain SELECT (SELECT a FROM t1 AS t2 +WHERE a IN (SELECT t1.a+t2.a FROM t1 AS t3)) +FROM t1 AS t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 DEPENDENT SUBQUERY t3 NULL ALL NULL NULL NULL NULL 1 100.00 FirstMatch(t2); Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #3 was resolved in SELECT #1 +Note 1276 Field or reference 'test.t2.a' of SELECT #3 was resolved in SELECT #2 +Note 1003 /* select#1 */ select (/* select#2 */ select `test`.`t2`.`a` from `test`.`t1` `t2` semi join (`test`.`t1` `t3`) where (`test`.`t2`.`a` = (`test`.`t1`.`a` + `test`.`t2`.`a`))) AS `(SELECT a FROM t1 AS t2 +WHERE a IN (SELECT t1.a+t2.a FROM t1 AS t3))` from `test`.`t1` +SELECT (SELECT a FROM t1 AS t2 +WHERE a IN (SELECT t1.a+t2.a FROM t1 AS t3)) +FROM t1 AS t1; +(SELECT a FROM t1 AS t2 +WHERE a IN (SELECT t1.a+t2.a FROM t1 AS t3)) +DROP TABLE t1; +# End of test for Bug#21139722 +SET DEFAULT_STORAGE_ENGINE=INNODB; +# +# Bug#21139402 ASSERTION FAILED: LENGTH > 0 && KEYPARTS != 0, CRASH IN JOIN::OPTIMIZE_KEYUSE +# +CREATE TABLE t1 (a INT, b INT, PRIMARY KEY(a)); +CREATE TABLE t2 (c INT PRIMARY KEY); +EXPLAIN SELECT 1 FROM t1 +WHERE 1 IN +(SELECT (c IS NULL) IN (SELECT a FROM t1 WHERE b) FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +3 SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` semi join (`test`.`t2`) where false +SELECT 1 FROM t1 +WHERE 1 IN +(SELECT (c IS NULL) IN (SELECT a FROM t1 WHERE b) FROM t2); +1 +DROP TABLE t1,t2; +# +# Bug#21619634 ACCESS OF DEALLOCATED ITEM_OUTER_REF CAUSES CRASH: PREPARED STMT +# +create table cc (i int) engine="innodb"; +insert into cc values (1); +select (select count(i) from cc as cc_alias +where (cc.i in (select cc_alias.i from cc))) +from cc group by i; +(select count(i) from cc as cc_alias +where (cc.i in (select cc_alias.i from cc))) +1 +prepare stmt from +"select (select count(i) from cc as cc_alias + where (cc.i in (select cc_alias.i from cc))) + from cc group by i"; +execute stmt; +(select count(i) from cc as cc_alias + where (cc.i in (select cc_alias.i from cc))) +1 +execute stmt; +(select count(i) from cc as cc_alias + where (cc.i in (select cc_alias.i from cc))) +1 +drop table cc; +# +# Bug #22305361: QUERY WITH MATERIALIZED TABLE RETURNS INCORRECT +# RESULTS IN 5.6 +# +CREATE TABLE t(a INT,b INT); +INSERT INTO t VALUES (1,0),(1,0),(1,0),(1,0),(1,1); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +EXPLAIN SELECT * +FROM t AS t1 +WHERE t1.a IN (SELECT t2.a +FROM t AS t2 +WHERE CONCAT(t2.a,'') NOT IN (SELECT t3.a +FROM t AS t3 +WHERE t3.b=1)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 5 20.00 Using where; FirstMatch(t1); Using join buffer (hash join) +3 DEPENDENT SUBQUERY t3 NULL ALL NULL NULL NULL NULL 5 20.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t` `t1` semi join (`test`.`t` `t2`) where ((`test`.`t2`.`a` = `test`.`t1`.`a`) and (concat(`test`.`t1`.`a`,''),(/* select#3 */ select `test`.`t3`.`a` from `test`.`t` `t3` where ((`test`.`t3`.`b` = 1) and (outer_field_is_not_null, (((concat(`test`.`t1`.`a`,'')) = `test`.`t3`.`a`) or (`test`.`t3`.`a` is null)), true)) having (outer_field_is_not_null, (`test`.`t3`.`a`), true)) is false)) +SELECT * +FROM t AS t1 +WHERE t1.a IN (SELECT t2.a +FROM t AS t2 +WHERE CONCAT(t2.a,'') NOT IN (SELECT t3.a +FROM t AS t3 +WHERE t3.b=1)); +a b +DROP TABLE t; +# +# Bug#24287772 SUBQUERY RETURNS EMPTY LIST WHILE IDENTICAL QUERY +# WITH JOIN RETURNS RESULT +# +CREATE TABLE t SELECT 4096 c; +SELECT c FROM t WHERE 1 IN +(SELECT t.c = page_size FROM information_schema.innodb_cmpmem); +c +4096 +DROP TABLE t; +# +# Bug #29132639: WL#12470: SIG 6 IN CONNECTJOINS|SQL/SQL_EXECUTOR.C +# +CREATE TABLE t1 ( f1 TIME, f2 VARCHAR(1) ); +INSERT INTO t1 VALUES ('08:35:24', 'X'), ('14:51:13', 'S'), ('11:22:33', 'Q'); +CREATE TABLE t2 ( pk INTEGER ); +INSERT INTO t2 VALUES (1), (2); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN FORMAT=tree SELECT * FROM t1 WHERE EXISTS ( SELECT alias1.f2 FROM t2 LEFT JOIN t1 ON 1 LEFT JOIN t1 AS alias1 ON 1 ); +EXPLAIN +-> Inner hash join (no condition) (cost=5.40 rows=3) + -> Table scan on t1 (cost=0.55 rows=3) + -> Hash + -> Limit: 1 row(s) (cost=4.85 rows=1) + -> Nested loop left join (cost=4.85 rows=18) + -> Nested loop left join (cost=1.55 rows=6) + -> Table scan on t2 (cost=0.45 rows=2) + -> Table scan on t1 (cost=0.40 rows=3) + -> Table scan on alias1 (cost=5.40 rows=3) + +SELECT * FROM t1 WHERE EXISTS ( SELECT alias1.f2 FROM t2 LEFT JOIN t1 ON 1 LEFT JOIN t1 AS alias1 ON 1 ); +f1 f2 +08:35:24 X +11:22:33 Q +14:51:13 S +DROP TABLE t1, t2; +# +# Bug#51457 Firstmatch semijoin strategy gives wrong results for +# certain query plans +# +SET @@default_storage_engine='innodb'; +SET @@optimizer_switch='semijoin=on,materialization=off,firstmatch=on,loosescan=off,block_nested_loop=off,batched_key_access=off'; +CREATE TABLE t0(a INTEGER); +CREATE TABLE t1(a INTEGER); +INSERT INTO t1 VALUES(1); +CREATE TABLE t2(a INTEGER); +INSERT INTO t2 VALUES(5), (8); +CREATE TABLE t6(a INTEGER); +INSERT INTO t6 VALUES(7), (1), (0), (5), (1), (4); +CREATE TABLE t8(a INTEGER); +INSERT INTO t8 VALUES(1), (3), (5), (7), (9), (7), (3), (1); +EXPLAIN +SELECT * +FROM t2 AS nt2 +WHERE 1 IN (SELECT it1.a +FROM t1 AS it1 JOIN t6 AS it3 ON it1.a=it3.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE it1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE it3 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; FirstMatch +1 SIMPLE nt2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`nt2`.`a` AS `a` from `test`.`t2` `nt2` semi join (`test`.`t1` `it1` join `test`.`t6` `it3`) where ((`test`.`it1`.`a` = 1) and (`test`.`it3`.`a` = 1)) +SELECT * +FROM t2 AS nt2 +WHERE 1 IN (SELECT it1.a +FROM t1 AS it1 JOIN t6 AS it3 ON it1.a=it3.a); +a +5 +8 +EXPLAIN +SELECT * +FROM t2 AS nt2, t8 AS nt4 +WHERE 1 IN (SELECT it1.a +FROM t1 AS it1 JOIN t6 AS it3 ON it1.a=it3.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE it1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE it3 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; FirstMatch +1 SIMPLE nt2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE nt4 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`nt2`.`a` AS `a`,`test`.`nt4`.`a` AS `a` from `test`.`t2` `nt2` join `test`.`t8` `nt4` semi join (`test`.`t1` `it1` join `test`.`t6` `it3`) where ((`test`.`it1`.`a` = 1) and (`test`.`it3`.`a` = 1)) +SELECT * +FROM t2 AS nt2, t8 AS nt4 +WHERE 1 IN (SELECT it1.a +FROM t1 AS it1 JOIN t6 AS it3 ON it1.a=it3.a); +a a +5 1 +5 1 +5 3 +5 3 +5 5 +5 7 +5 7 +5 9 +8 1 +8 1 +8 3 +8 3 +8 5 +8 7 +8 7 +8 9 +EXPLAIN +SELECT * +FROM t0 AS ot1, t2 AS nt3 +WHERE ot1.a IN (SELECT it2.a +FROM t1 AS it2 JOIN t8 AS it4 ON it2.a=it4.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE it2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 SIMPLE it4 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; FirstMatch(ot1) +2 SIMPLE nt3 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`nt3`.`a` AS `a` from `test`.`t0` `ot1` join `test`.`t2` `nt3` semi join (`test`.`t1` `it2` join `test`.`t8` `it4`) where ((`test`.`it2`.`a` = `test`.`ot1`.`a`) and (`test`.`it4`.`a` = `test`.`ot1`.`a`)) +SELECT * +FROM t0 as ot1, t2 AS nt3 +WHERE ot1.a IN (SELECT it2.a +FROM t1 AS it2 JOIN t8 AS it4 ON it2.a=it4.a); +a a +DROP TABLE t0, t1, t2, t6, t8; +SET @@default_storage_engine=default; +SET @@optimizer_switch=default; +# End of bug#51457 +set optimizer_switch=default; diff --git a/mysql-test/r/subquery_sj_firstmatch_bka.result-pq b/mysql-test/r/subquery_sj_firstmatch_bka.result-pq new file mode 100644 index 000000000000..26f3e9af5c69 --- /dev/null +++ b/mysql-test/r/subquery_sj_firstmatch_bka.result-pq @@ -0,0 +1,12948 @@ +set optimizer_switch='batched_key_access=on,mrr_cost_based=off'; +set optimizer_switch='semijoin=on,firstmatch=on'; +set @old_opt_switch=@@optimizer_switch; +set optimizer_switch='subquery_materialization_cost_based=off'; +drop table if exists t0, t1, t2, t10, t11, t12; +create table t1 (a int not null, b int, primary key (a)); +create table t2 (a int not null, primary key (a)); +create table t3 (a int not null, b int, primary key (a)); +insert into t1 values (1,10), (2,20), (3,30), (4,40); +insert into t2 values (2), (3), (4), (5); +insert into t3 values (10,3), (20,4), (30,5); +select * from t2 where t2.a in (select a from t1); +a +2 +3 +4 +explain select * from t2 where t2.a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index PRIMARY PRIMARY 4 NULL 4 100.00 Using index +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t1` join `test`.`t2` where (`test`.`t1`.`a` = `test`.`t2`.`a`) +select * from t2 where t2.a in (select a from t1 where t1.b <> 30); +a +2 +4 +explain select * from t2 where t2.a in (select a from t1 where t1.b <> 30); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL PRIMARY NULL NULL NULL 4 75.00 Using where +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`a` = `test`.`t1`.`a`) and (`test`.`t1`.`b` <> 30)) +select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a); +a +2 +3 +explain select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL index PRIMARY PRIMARY 4 NULL 3 100.00 Using index +1 SIMPLE t1 NULL ALL PRIMARY NULL NULL NULL 4 25.00 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t1` join `test`.`t3` join `test`.`t2` where ((`test`.`t2`.`a` = `test`.`t1`.`a`) and (`test`.`t1`.`b` = `test`.`t3`.`a`)) +drop table t1, t2, t3; +create table t1 (a int, b int, index a (a,b)); +create table t2 (a int, index a (a)); +create table t3 (a int, b int, index a (a)); +insert into t1 values (1,10), (2,20), (3,30), (4,40); +create table t0(a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +insert into t1 +select rand()*100000+200,rand()*100000 from t0 A, t0 B, t0 C, t0 D; +insert into t2 values (2), (3), (4), (5); +insert into t3 values (10,3), (20,4), (30,5); +select * from t2 where t2.a in (select a from t1); +a +2 +3 +4 +explain select * from t2 where t2.a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index a a 5 NULL 4 100.00 Using where; Using index +1 SIMPLE t1 NULL ref a a 5 test.t2.a 101 100.00 Using index; FirstMatch(t2) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1`) where (`test`.`t1`.`a` = `test`.`t2`.`a`) +select * from t2 where t2.a in (select a from t1 where t1.b <> 30); +a +2 +4 +explain select * from t2 where t2.a in (select a from t1 where t1.b <> 30); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index a a 5 NULL 4 100.00 Using where; Using index +1 SIMPLE t1 NULL ref a a 5 test.t2.a 101 90.00 Using where; Using index; FirstMatch(t2) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1`) where ((`test`.`t1`.`a` = `test`.`t2`.`a`) and (`test`.`t1`.`b` <> 30)) +select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a); +a +2 +3 +explain select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index a a 5 NULL 4 100.00 Using where; Using index +1 SIMPLE t3 NULL index a a 5 NULL 3 100.00 Using where; Using index +1 SIMPLE t1 NULL ref a a 10 test.t2.a,test.t3.a 116 100.00 Using index; FirstMatch(t2) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1` join `test`.`t3`) where ((`test`.`t1`.`a` = `test`.`t2`.`a`) and (`test`.`t1`.`b` = `test`.`t3`.`a`)) +insert into t1 values (3,31); +select * from t2 where t2.a in (select a from t1 where t1.b <> 30); +a +2 +3 +4 +select * from t2 where t2.a in (select a from t1 where t1.b <> 30 and t1.b <> 31); +a +2 +4 +explain select * from t2 where t2.a in (select a from t1 where t1.b <> 30); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index a a 5 NULL 4 100.00 Using where; Using index +1 SIMPLE t1 NULL ref a a 5 test.t2.a 101 90.00 Using where; Using index; FirstMatch(t2) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1`) where ((`test`.`t1`.`a` = `test`.`t2`.`a`) and (`test`.`t1`.`b` <> 30)) +drop table t0, t1, t2, t3; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1(a int, b int); +insert into t1 values (0,0),(1,1),(2,2); +create table t2 as select * from t1; +create table t11(a int, b int); +create table t10 (pk int, a int, primary key(pk)); +insert into t10 select a,a from t0; +create table t12 like t10; +insert into t12 select * from t10; +Flattened because of dependency, t10=func(t1) +explain select * from t1 where a in (select pk from t10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t1` where (`test`.`t10`.`pk` = `test`.`t1`.`a`) +select * from t1 where a in (select pk from t10); +a b +0 0 +1 1 +2 2 +A confluent case of dependency +explain select * from t1 where a in (select a from t10 where pk=12); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t1` where (multiple equal(12, NULL) and multiple equal(`test`.`t1`.`a`, NULL)) +select * from t1 where a in (select a from t10 where pk=12); +a b +explain select * from t1 where a in (select a from t10 where pk=9); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t10 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t1` where ((`test`.`t1`.`a` = '9')) +select * from t1 where a in (select a from t10 where pk=9); +a b +An empty table inside +explain select * from t1 where a in (select a from t11); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE t11 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t11`) where (`test`.`t11`.`a` = `test`.`t1`.`a`) +select * from t1 where a in (select a from t11); +a b +explain select * from t1 where a in (select pk from t10) and b in (select pk from t10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using index +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.t1.b 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t10` join `test`.`t1` where ((`test`.`t10`.`pk` = `test`.`t1`.`b`) and (`test`.`t10`.`pk` = `test`.`t1`.`a`)) +select * from t1 where a in (select pk from t10) and b in (select pk from t10); +a b +0 0 +1 1 +2 2 +flattening a nested subquery +explain select * from t1 where a in (select pk from t10 where t10.a in (select pk from t12)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using where +1 SIMPLE t12 NULL eq_ref PRIMARY PRIMARY 4 test.t10.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t12` join `test`.`t1` where ((`test`.`t10`.`pk` = `test`.`t1`.`a`) and (`test`.`t12`.`pk` = `test`.`t10`.`a`)) +select * from t1 where a in (select pk from t10 where t10.a in (select pk from t12)); +a b +0 0 +1 1 +2 2 +flattening subquery w/ several tables +explain select * from t1 where a in (select t10.pk from t10, t12 where t12.pk=t10.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using where +1 SIMPLE t12 NULL eq_ref PRIMARY PRIMARY 4 test.t10.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t12` join `test`.`t1` where ((`test`.`t10`.`pk` = `test`.`t1`.`a`) and (`test`.`t12`.`pk` = `test`.`t10`.`a`)) +subqueries within outer joins go into ON expr. +explain +select * from t1 left join (t2 A, t2 B) on ( A.A= t1.A and B.A in (select pk from t10)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE A NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE B NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.B.A 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`A` AS `A`,`test`.`t1`.`B` AS `B`,`test`.`A`.`A` AS `A`,`test`.`A`.`B` AS `B`,`test`.`B`.`A` AS `A`,`test`.`B`.`B` AS `B` from `test`.`t1` left join (`test`.`t10` join `test`.`t2` `A` join `test`.`t2` `B`) on(((`test`.`t10`.`pk` = `test`.`B`.`A`) and (`test`.`A`.`A` = `test`.`t1`.`A`))) where true +t2 should be wrapped into OJ-nest, so we have "t1 LJ (t2 J t10)" +explain +select * from t1 left join t2 on (t2.A= t1.A and t2.A in (select pk from t10)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.t1.A 1 100.00 Using index +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`A` AS `A`,`test`.`t1`.`B` AS `B`,`test`.`t2`.`A` AS `A`,`test`.`t2`.`B` AS `B` from `test`.`t1` left join (`test`.`t10` join `test`.`t2`) on(((`test`.`t10`.`pk` = `test`.`t1`.`A`) and (`test`.`t2`.`A` = `test`.`t1`.`A`))) where true +we shouldn't flatten if we're going to get a join of > MAX_TABLES. +explain select * from +t1 s00, t1 s01, t1 s02, t1 s03, t1 s04,t1 s05,t1 s06,t1 s07,t1 s08,t1 s09, +t1 s10, t1 s11, t1 s12, t1 s13, t1 s14,t1 s15,t1 s16,t1 s17,t1 s18,t1 s19, +t1 s20, t1 s21, t1 s22, t1 s23, t1 s24,t1 s25,t1 s26,t1 s27,t1 s28,t1 s29, +t1 s30, t1 s31, t1 s32, t1 s33, t1 s34,t1 s35,t1 s36,t1 s37,t1 s38,t1 s39, +t1 s40, t1 s41, t1 s42, t1 s43, t1 s44,t1 s45,t1 s46,t1 s47,t1 s48,t1 s49 +where +s00.a in ( +select m00.a from +t1 m00, t1 m01, t1 m02, t1 m03, t1 m04,t1 m05,t1 m06,t1 m07,t1 m08,t1 m09, +t1 m10, t1 m11, t1 m12, t1 m13, t1 m14,t1 m15,t1 m16,t1 m17,t1 m18,t1 m19 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY s00 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 PRIMARY s01 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s02 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s03 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s04 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s05 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s06 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s07 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s08 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s09 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s10 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s11 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s12 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s13 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s14 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s15 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s16 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s17 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s18 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s19 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s20 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s21 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s22 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s23 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s24 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s25 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s26 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s27 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s28 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s29 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s30 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s31 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s32 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s33 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s34 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s35 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s36 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s37 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s38 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s39 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s40 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s41 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s42 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s43 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s44 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s45 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s46 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s47 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s48 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s49 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m00 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +2 DEPENDENT SUBQUERY m01 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m02 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m03 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m04 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m05 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m06 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m07 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m08 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m09 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m10 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m11 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m12 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m13 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m14 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m15 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m16 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m17 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m18 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m19 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`s00`.`a` AS `a`,`test`.`s00`.`b` AS `b`,`test`.`s01`.`a` AS `a`,`test`.`s01`.`b` AS `b`,`test`.`s02`.`a` AS `a`,`test`.`s02`.`b` AS `b`,`test`.`s03`.`a` AS `a`,`test`.`s03`.`b` AS `b`,`test`.`s04`.`a` AS `a`,`test`.`s04`.`b` AS `b`,`test`.`s05`.`a` AS `a`,`test`.`s05`.`b` AS `b`,`test`.`s06`.`a` AS `a`,`test`.`s06`.`b` AS `b`,`test`.`s07`.`a` AS `a`,`test`.`s07`.`b` AS `b`,`test`.`s08`.`a` AS `a`,`test`.`s08`.`b` AS `b`,`test`.`s09`.`a` AS `a`,`test`.`s09`.`b` AS `b`,`test`.`s10`.`a` AS `a`,`test`.`s10`.`b` AS `b`,`test`.`s11`.`a` AS `a`,`test`.`s11`.`b` AS `b`,`test`.`s12`.`a` AS `a`,`test`.`s12`.`b` AS `b`,`test`.`s13`.`a` AS `a`,`test`.`s13`.`b` AS `b`,`test`.`s14`.`a` AS `a`,`test`.`s14`.`b` AS `b`,`test`.`s15`.`a` AS `a`,`test`.`s15`.`b` AS `b`,`test`.`s16`.`a` AS `a`,`test`.`s16`.`b` AS `b`,`test`.`s17`.`a` AS `a`,`test`.`s17`.`b` AS `b`,`test`.`s18`.`a` AS `a`,`test`.`s18`.`b` AS `b`,`test`.`s19`.`a` AS `a`,`test`.`s19`.`b` AS `b`,`test`.`s20`.`a` AS `a`,`test`.`s20`.`b` AS `b`,`test`.`s21`.`a` AS `a`,`test`.`s21`.`b` AS `b`,`test`.`s22`.`a` AS `a`,`test`.`s22`.`b` AS `b`,`test`.`s23`.`a` AS `a`,`test`.`s23`.`b` AS `b`,`test`.`s24`.`a` AS `a`,`test`.`s24`.`b` AS `b`,`test`.`s25`.`a` AS `a`,`test`.`s25`.`b` AS `b`,`test`.`s26`.`a` AS `a`,`test`.`s26`.`b` AS `b`,`test`.`s27`.`a` AS `a`,`test`.`s27`.`b` AS `b`,`test`.`s28`.`a` AS `a`,`test`.`s28`.`b` AS `b`,`test`.`s29`.`a` AS `a`,`test`.`s29`.`b` AS `b`,`test`.`s30`.`a` AS `a`,`test`.`s30`.`b` AS `b`,`test`.`s31`.`a` AS `a`,`test`.`s31`.`b` AS `b`,`test`.`s32`.`a` AS `a`,`test`.`s32`.`b` AS `b`,`test`.`s33`.`a` AS `a`,`test`.`s33`.`b` AS `b`,`test`.`s34`.`a` AS `a`,`test`.`s34`.`b` AS `b`,`test`.`s35`.`a` AS `a`,`test`.`s35`.`b` AS `b`,`test`.`s36`.`a` AS `a`,`test`.`s36`.`b` AS `b`,`test`.`s37`.`a` AS `a`,`test`.`s37`.`b` AS `b`,`test`.`s38`.`a` AS `a`,`test`.`s38`.`b` AS `b`,`test`.`s39`.`a` AS `a`,`test`.`s39`.`b` AS `b`,`test`.`s40`.`a` AS `a`,`test`.`s40`.`b` AS `b`,`test`.`s41`.`a` AS `a`,`test`.`s41`.`b` AS `b`,`test`.`s42`.`a` AS `a`,`test`.`s42`.`b` AS `b`,`test`.`s43`.`a` AS `a`,`test`.`s43`.`b` AS `b`,`test`.`s44`.`a` AS `a`,`test`.`s44`.`b` AS `b`,`test`.`s45`.`a` AS `a`,`test`.`s45`.`b` AS `b`,`test`.`s46`.`a` AS `a`,`test`.`s46`.`b` AS `b`,`test`.`s47`.`a` AS `a`,`test`.`s47`.`b` AS `b`,`test`.`s48`.`a` AS `a`,`test`.`s48`.`b` AS `b`,`test`.`s49`.`a` AS `a`,`test`.`s49`.`b` AS `b` from `test`.`t1` `s00` join `test`.`t1` `s01` join `test`.`t1` `s02` join `test`.`t1` `s03` join `test`.`t1` `s04` join `test`.`t1` `s05` join `test`.`t1` `s06` join `test`.`t1` `s07` join `test`.`t1` `s08` join `test`.`t1` `s09` join `test`.`t1` `s10` join `test`.`t1` `s11` join `test`.`t1` `s12` join `test`.`t1` `s13` join `test`.`t1` `s14` join `test`.`t1` `s15` join `test`.`t1` `s16` join `test`.`t1` `s17` join `test`.`t1` `s18` join `test`.`t1` `s19` join `test`.`t1` `s20` join `test`.`t1` `s21` join `test`.`t1` `s22` join `test`.`t1` `s23` join `test`.`t1` `s24` join `test`.`t1` `s25` join `test`.`t1` `s26` join `test`.`t1` `s27` join `test`.`t1` `s28` join `test`.`t1` `s29` join `test`.`t1` `s30` join `test`.`t1` `s31` join `test`.`t1` `s32` join `test`.`t1` `s33` join `test`.`t1` `s34` join `test`.`t1` `s35` join `test`.`t1` `s36` join `test`.`t1` `s37` join `test`.`t1` `s38` join `test`.`t1` `s39` join `test`.`t1` `s40` join `test`.`t1` `s41` join `test`.`t1` `s42` join `test`.`t1` `s43` join `test`.`t1` `s44` join `test`.`t1` `s45` join `test`.`t1` `s46` join `test`.`t1` `s47` join `test`.`t1` `s48` join `test`.`t1` `s49` where (`test`.`s00`.`a`,(/* select#2 */ select `test`.`m00`.`a` from `test`.`t1` `m00` join `test`.`t1` `m01` join `test`.`t1` `m02` join `test`.`t1` `m03` join `test`.`t1` `m04` join `test`.`t1` `m05` join `test`.`t1` `m06` join `test`.`t1` `m07` join `test`.`t1` `m08` join `test`.`t1` `m09` join `test`.`t1` `m10` join `test`.`t1` `m11` join `test`.`t1` `m12` join `test`.`t1` `m13` join `test`.`t1` `m14` join `test`.`t1` `m15` join `test`.`t1` `m16` join `test`.`t1` `m17` join `test`.`t1` `m18` join `test`.`t1` `m19` where ((`test`.`s00`.`a`) = `test`.`m00`.`a`))) +select * from +t1 left join t2 on (t2.a= t1.a and t2.a in (select pk from t10)) +where t1.a < 5; +a b a b +0 0 0 0 +1 1 1 1 +2 2 2 2 +prepare s1 from +' select * from + t1 left join t2 on (t2.a= t1.a and t2.a in (select pk from t10)) + where t1.a < 5'; +execute s1; +a b a b +0 0 0 0 +1 1 1 1 +2 2 2 2 +execute s1; +a b a b +0 0 0 0 +1 1 1 1 +2 2 2 2 +insert into t1 select (A.a + 10 * B.a),1 from t0 A, t0 B; +explain select * from t1 where a in (select pk from t10 where pk<3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t10 NULL range PRIMARY PRIMARY 4 NULL 4 100.00 Using where; Using index +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 103 10.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t1` where ((`test`.`t1`.`a` = `test`.`t10`.`pk`) and (`test`.`t10`.`pk` < 3)) +drop table t0, t1, t2; +drop table t10, t11, t12; +# +# Check that subqueries with outer joins or straight_join work for +# different permutations of const and non-const tables. (Ref. Bug#46692) +# +CREATE TABLE t1 (i INTEGER); +CREATE TABLE t2 (i INTEGER); +CREATE TABLE t3 (i INTEGER); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 0 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 0 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 0 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 1 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 1 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 1 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 2 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 2 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 2 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (0); +DELETE FROM t2; +INSERT INTO t1 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 0 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 0 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 0 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 1 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 1 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 1 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 2 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 2 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 2 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (0); +DELETE FROM t2; +INSERT INTO t1 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 0 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = `test`.`t1`.`i`) and (`test`.`t3`.`i` = `test`.`t1`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = `test`.`t1`.`i`) and (`test`.`t3`.`i` = `test`.`t1`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = `test`.`t1`.`i`) and (`test`.`t3`.`i` = `test`.`t1`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = `test`.`t1`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = `test`.`t1`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 0 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = `test`.`t1`.`i`) and (`test`.`t3`.`i` = `test`.`t1`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = `test`.`t1`.`i`) and (`test`.`t3`.`i` = `test`.`t1`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = `test`.`t1`.`i`) and (`test`.`t3`.`i` = `test`.`t1`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = `test`.`t1`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = `test`.`t1`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 0 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = `test`.`t1`.`i`) and (`test`.`t3`.`i` = `test`.`t1`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = `test`.`t1`.`i`) and (`test`.`t3`.`i` = `test`.`t1`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = `test`.`t1`.`i`) and (`test`.`t3`.`i` = `test`.`t1`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = `test`.`t1`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +1 +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = `test`.`t1`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 1 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = `test`.`t1`.`i`) and (`test`.`t2`.`i` = `test`.`t1`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = `test`.`t1`.`i`) and (`test`.`t2`.`i` = `test`.`t1`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = `test`.`t1`.`i`) and (`test`.`t2`.`i` = `test`.`t1`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = `test`.`t1`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = `test`.`t1`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 1 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = `test`.`t1`.`i`) and (`test`.`t3`.`i` = `test`.`t1`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = `test`.`t1`.`i`) and (`test`.`t3`.`i` = `test`.`t1`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = `test`.`t1`.`i`) and (`test`.`t3`.`i` = `test`.`t1`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = `test`.`t1`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = `test`.`t1`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 1 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = `test`.`t1`.`i`) and (`test`.`t3`.`i` = `test`.`t1`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = `test`.`t1`.`i`) and (`test`.`t3`.`i` = `test`.`t1`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = `test`.`t1`.`i`) and (`test`.`t3`.`i` = `test`.`t1`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = `test`.`t1`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +1 +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = `test`.`t1`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +1 +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 2 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = `test`.`t1`.`i`) and (`test`.`t2`.`i` = `test`.`t1`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = `test`.`t1`.`i`) and (`test`.`t2`.`i` = `test`.`t1`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = `test`.`t1`.`i`) and (`test`.`t2`.`i` = `test`.`t1`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = `test`.`t1`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = `test`.`t1`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 2 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = `test`.`t1`.`i`) and (`test`.`t2`.`i` = `test`.`t1`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = `test`.`t1`.`i`) and (`test`.`t2`.`i` = `test`.`t1`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = `test`.`t1`.`i`) and (`test`.`t2`.`i` = `test`.`t1`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = `test`.`t1`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = `test`.`t1`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 2 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = `test`.`t1`.`i`) and (`test`.`t3`.`i` = `test`.`t1`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +1 +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +1 +2 + +EXECUTE stmt; +i +1 +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = `test`.`t1`.`i`) and (`test`.`t3`.`i` = `test`.`t1`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +1 +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = `test`.`t1`.`i`) and (`test`.`t3`.`i` = `test`.`t1`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +1 +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +1 +2 + +EXECUTE stmt; +i +1 +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = `test`.`t1`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +1 +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = `test`.`t1`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +1 +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (0); +DELETE FROM t2; +INSERT INTO t1 VALUES (0); +DROP TABLE t1, t2, t3; +create table x1(k int primary key, d1 int, d2 int); +create table x2(k int primary key, d1 int, d2 int); +insert into x1 values +(10, 10, 10), +(20, 20, 20), +(21, 20, null), +(30, null, 30), +(40, 40, 40); +insert into x2 values +(10, 10, 10), +(20, 20, 20), +(21, 20, null), +(30, null, 30); +select * +from x1 +where (d1, d2) in (select d1, d2 +from x2); +k d1 d2 +10 10 10 +20 20 20 +select * +from x1 +where (d1, d2) in (select d1, d2 +from x2) is true; +k d1 d2 +10 10 10 +20 20 20 +select * +from x1 +where (d1, d2) in (select d1, d2 +from x2) is false; +k d1 d2 +40 40 40 +select * +from x1 +where (d1, d2) in (select d1, d2 +from x2) is unknown; +k d1 d2 +21 20 NULL +30 NULL 30 +select * +from x1 +where d1 in (select d1 +from x2 +where x1.d2=x2.d2); +k d1 d2 +10 10 10 +20 20 20 +select * +from x1 +where d1 in (select d1 +from x2 +where x1.d2=x2.d2) is true; +k d1 d2 +10 10 10 +20 20 20 +select * +from x1 +where d1 in (select d1 +from x2 +where x1.d2=x2.d2) is false; +k d1 d2 +21 20 NULL +40 40 40 +select * +from x1 +where d1 in (select d1 +from x2 +where x1.d2=x2.d2) is unknown; +k d1 d2 +30 NULL 30 +select * +from x1 +where 1 in (select 1 +from x2 +where x1.d1=x2.d1 and x1.d2=x2.d2); +k d1 d2 +10 10 10 +20 20 20 +select * +from x1 +where 1 in (select 1 +from x2 +where x1.d1=x2.d1 and x1.d2=x2.d2) is true; +k d1 d2 +10 10 10 +20 20 20 +select * +from x1 +where 1 in (select 1 +from x2 +where x1.d1=x2.d1 and x1.d2=x2.d2) is false; +k d1 d2 +21 20 NULL +30 NULL 30 +40 40 40 +select * +from x1 +where 1 in (select 1 +from x2 +where x1.d1=x2.d1 and x1.d2=x2.d2) is unknown; +k d1 d2 +select * +from x1 +where exists (select * +from x2 +where x1.d1=x2.d1 and x1.d2=x2.d2); +k d1 d2 +10 10 10 +20 20 20 +drop table x1; +drop table x2; +CREATE TABLE t1 ( +a int(11) NOT NULL, +b int(11) NOT NULL, +c datetime default NULL, +PRIMARY KEY (a), +KEY idx_bc (b,c) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES +(406989,67,'2006-02-23 17:08:46'), (150078,67,'2005-10-26 11:17:45'), +(406993,67,'2006-02-27 11:20:57'), (245655,67,'2005-12-08 15:59:08'), +(406994,67,'2006-02-27 11:26:46'), (256,67,NULL), +(398341,67,'2006-02-20 04:48:44'), (254,67,NULL),(1120,67,NULL), +(406988,67,'2006-02-23 17:07:22'), (255,67,NULL), +(398340,67,'2006-02-20 04:38:53'),(406631,67,'2006-02-23 10:49:42'), +(245653,67,'2005-12-08 15:59:07'),(406992,67,'2006-02-24 16:47:18'), +(245654,67,'2005-12-08 15:59:08'),(406995,67,'2006-02-28 11:55:00'), +(127261,67,'2005-10-13 12:17:58'),(406991,67,'2006-02-24 16:42:32'), +(245652,67,'2005-12-08 15:58:27'),(398545,67,'2006-02-20 04:53:13'), +(154504,67,'2005-10-28 11:53:01'),(9199,67,NULL),(1,67,'2006-02-23 15:01:35'), +(223456,67,NULL),(4101,67,NULL),(1133,67,NULL), +(406990,67,'2006-02-23 18:01:45'),(148815,67,'2005-10-25 15:34:17'), +(148812,67,'2005-10-25 15:30:01'),(245651,67,'2005-12-08 15:58:27'), +(154503,67,'2005-10-28 11:52:38'); +create table t11 select * from t1 where b = 67 AND (c IS NULL OR c > NOW()) order by 3 asc; +create table t12 select * from t1 where b = 67 AND (c IS NULL OR c > NOW()) order by 3 desc; +create table t21 select * from t1 where b = 67 AND (c IS NULL OR c > '2005-12-08') order by 3 asc; +create table t22 select * from t1 where b = 67 AND (c IS NULL OR c > '2005-12-08') order by 3 desc; +update t22 set c = '2005-12-08 15:58:27' where a = 255; +explain select t21.* from t21,t22 where t21.a = t22.a and +t22.a in (select t12.a from t11, t12 where t11.a in(255,256) and t11.a = t12.a and t11.c is null) and t22.c is null order by t21.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t21 NULL ALL NULL NULL NULL NULL 26 100.00 Using where; Using temporary; Using filesort +1 SIMPLE t22 NULL ALL NULL NULL NULL NULL 26 3.85 Using where; Using join buffer (hash join) +1 SIMPLE t11 NULL ALL NULL NULL NULL NULL 8 12.50 Using where +1 SIMPLE t12 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; FirstMatch(t22) +Warnings: +Note 1003 /* select#1 */ select `test`.`t21`.`a` AS `a`,`test`.`t21`.`b` AS `b`,`test`.`t21`.`c` AS `c` from `test`.`t21` join `test`.`t22` semi join (`test`.`t11` join `test`.`t12`) where ((`test`.`t22`.`a` = `test`.`t21`.`a`) and (`test`.`t11`.`a` = `test`.`t21`.`a`) and (`test`.`t12`.`a` = `test`.`t21`.`a`) and (`test`.`t22`.`c` is null) and (`test`.`t21`.`a` in (255,256)) and (`test`.`t11`.`c` is null)) order by `test`.`t21`.`a` +explain format=json select * from t1 where a in (select a from t11); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "29.83" + }, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "possible_keys": [ + "PRIMARY" + ], + "rows_examined_per_scan": 32, + "rows_produced_per_join": 32, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.53", + "eval_cost": "3.20", + "prefix_cost": "3.73", + "data_read_per_join": "512" + }, + "used_columns": [ + "a", + "b", + "c" + ] + } + }, + { + "table": { + "table_name": "t11", + "access_type": "ALL", + "rows_examined_per_scan": 8, + "rows_produced_per_join": 32, + "filtered": "12.50", + "first_match": "t1", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "3.20", + "prefix_cost": "29.84", + "data_read_per_join": "512" + }, + "used_columns": [ + "a" + ], + "attached_condition": "(`test`.`t11`.`a` = `test`.`t1`.`a`)" + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` semi join (`test`.`t11`) where (`test`.`t11`.`a` = `test`.`t1`.`a`) +select t21.* from t21,t22 where t21.a = t22.a and +t22.a in (select t12.a from t11, t12 where t11.a in(255,256) and t11.a = t12.a and t11.c is null) and t22.c is null order by t21.a; +a b c +256 67 NULL +drop table t1, t11, t12, t21, t22; +create table t1(a int); +insert into t1 values (0),(1); +explain +select (select max(y.a) from t1 y where a in (select a from t1 z) and a < x.a) as subq from t1 x; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY x NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DEPENDENT SUBQUERY y NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 DEPENDENT SUBQUERY z NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(y); Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.x.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select (/* select#2 */ select max(`test`.`y`.`a`) from `test`.`t1` `y` semi join (`test`.`t1` `z`) where ((`test`.`z`.`a` = `test`.`y`.`a`) and (`test`.`y`.`a` < `test`.`x`.`a`))) AS `subq` from `test`.`t1` `x` +select (select max(y.a) from t1 y where a in (select a from t1 z) and a < x.a) as subq from t1 x; +subq +NULL +0 +drop table t1; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 as select * from t0; +insert into t1 select a+10 from t0; +insert into t0 values(2); +explain select * from t1 where 2 in (select a from t0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 11 10.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 20 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t0`) where (`test`.`t0`.`a` = 2) +select * from t1 where 2 in (select a from t0); +a +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +explain select * from (select a from t0) x where a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 11 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 20 10.00 Using where; FirstMatch(t0); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a` from `test`.`t0` semi join (`test`.`t1`) where (`test`.`t1`.`a` = `test`.`t0`.`a`) +explain format=json select * from (select a from t0) x where a in (select a from t1); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "24.11" + }, + "nested_loop": [ + { + "table": { + "table_name": "t0", + "access_type": "ALL", + "rows_examined_per_scan": 11, + "rows_produced_per_join": 11, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "1.10", + "prefix_cost": "1.60", + "data_read_per_join": "88" + }, + "used_columns": [ + "a" + ] + } + }, + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 11, + "filtered": "10.00", + "first_match": "t0", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "1.10", + "prefix_cost": "24.11", + "data_read_per_join": "88" + }, + "used_columns": [ + "a" + ], + "attached_condition": "(`test`.`t1`.`a` = `test`.`t0`.`a`)" + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a` from `test`.`t0` semi join (`test`.`t1`) where (`test`.`t1`.`a` = `test`.`t0`.`a`) +drop table t0, t1; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (kp1 int, kp2 int, c int, filler char(100), key(kp1, kp2)); +insert into t1 select A.a+10*(B.a+10*C.a), 0, 0, 'filler' from t0 A, t0 B, t0 C; +insert into t1 select * from t1 where kp1 < 20; +create table t3 (a int); +insert into t3 select A.a + 10*B.a from t0 A, t0 B; +explain select * from t3 where a in (select kp1 from t1 where kp1<20); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 100 100.00 Using where +1 SIMPLE t1 NULL ref kp1 kp1 5 test.t3.a 1 100.00 Using index; FirstMatch(t3) +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a` from `test`.`t3` semi join (`test`.`t1`) where ((`test`.`t1`.`kp1` = `test`.`t3`.`a`) and (`test`.`t3`.`a` < 20)) +select * from t3 where a in (select kp1 from t1 where kp1<20); +a +0 +1 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +2 +3 +4 +5 +6 +7 +8 +9 +explain select * from t3 where a in (select kp1 from t1 where kp1<20) and a<20; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 100 33.33 Using where +1 SIMPLE t1 NULL ref kp1 kp1 5 test.t3.a 1 100.00 Using index; FirstMatch(t3) +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a` from `test`.`t3` semi join (`test`.`t1`) where ((`test`.`t1`.`kp1` = `test`.`t3`.`a`) and (`test`.`t3`.`a` < 20) and (`test`.`t3`.`a` < 20)) +select * from t3 where a in (select kp1 from t1 where kp1<20) and a<20; +a +0 +1 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +2 +3 +4 +5 +6 +7 +8 +9 +create table t4 (pk int primary key); +insert into t4 select a from t3; +explain select * from t3 where a in +(select t1.kp1 from t1,t4 where kp1<20 and t4.pk=t1.c); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 100 100.00 Using where +1 SIMPLE t1 NULL ref kp1 kp1 5 test.t3.a 1 100.00 Using where +1 SIMPLE t4 NULL eq_ref PRIMARY PRIMARY 4 test.t1.c 1 100.00 Using index; FirstMatch(t3) +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a` from `test`.`t3` semi join (`test`.`t1` join `test`.`t4`) where ((`test`.`t1`.`kp1` = `test`.`t3`.`a`) and (`test`.`t4`.`pk` = `test`.`t1`.`c`) and (`test`.`t3`.`a` < 20)) +explain format=tree select * from t3 where a in +(select t1.kp1 from t1,t4 where kp1<20 and t4.pk=t1.c); +EXPLAIN +-> Nested loop semijoin (cost=45.54 rows=100) + -> Filter: ((t3.a < 20) and (t3.a is not null)) (cost=10.54 rows=100) + -> Table scan on t3 (cost=10.54 rows=100) + -> Nested loop inner join (cost=25.35 rows=1) + -> Filter: (t1.c is not null) (cost=0.25 rows=1) + -> Index lookup on t1 using kp1 (kp1=t3.a) (cost=0.25 rows=1) + -> Single-row index lookup on t4 using PRIMARY (pk=t1.c) (cost=0.25 rows=1) + +select * from t3 where a in +(select t1.kp1 from t1,t4 where kp1<20 and t4.pk=t1.c); +a +0 +1 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +2 +3 +4 +5 +6 +7 +8 +9 +drop table t1, t3, t4; +create table t1 (a int); +insert into t1 values (0),(0),(0),(1),(1),(1),(2),(2),(2),(3),(3),(3); +set session internal_tmp_mem_storage_engine='memory'; +set @save_max_heap_table_size=@@max_heap_table_size; +set @@max_heap_table_size= 16384; +# Attempt to make one test that overflows the heap table when a +# non-duplicate row is inserted and one test that overflows the +# heap table when a duplicate record is inserted. Debugging showed +# that these situations occurred with max_heap_table_size=16384 +# and optimizer_join_cache_level equals 1 and 0, respectively. +# Finally execute a test that does not overflow the heap table. +explain +select count(*) from t0 a, t0 b, t0 c +where c.a in (select a from t1 d); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE a NULL ALL NULL NULL NULL NULL 10 100.00 NULL +1 SIMPLE b NULL ALL NULL NULL NULL NULL 10 100.00 Using join buffer (hash join) +1 SIMPLE c NULL ALL NULL NULL NULL NULL 10 100.00 Using join buffer (hash join) +1 SIMPLE d NULL ALL NULL NULL NULL NULL 12 10.00 Using where; FirstMatch(c); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select count(0) AS `count(*)` from `test`.`t0` `a` join `test`.`t0` `b` join `test`.`t0` `c` semi join (`test`.`t1` `d`) where (`test`.`d`.`a` = `test`.`c`.`a`) +flush status; +select count(*) from t0 a, t0 b, t0 c +where c.a in (select a from t1 d); +count(*) +400 +show status like 'Created_tmp_disk_tables'; +Variable_name Value +Created_tmp_disk_tables 0 +set @@max_heap_table_size= @save_max_heap_table_size; +set session internal_tmp_mem_storage_engine=default; +flush status; +select count(*) from t0 a, t0 b, t0 c +where c.a in (select a from t1 d); +count(*) +400 +show status like 'Created_tmp_disk_tables'; +Variable_name Value +Created_tmp_disk_tables 0 +drop table t0, t1; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t2(a int); +insert into t2 values (1),(2); +create table t3 ( a int , filler char(100), key(a)); +insert into t3 select A.a + 10*B.a, 'filler' from t0 A, t0 B; +explain select * from t3 where a in (select a from t2) and (a > 5 or a < 10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL a NULL NULL NULL 100 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t3); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a`,`test`.`t3`.`filler` AS `filler` from `test`.`t3` semi join (`test`.`t2`) where ((`test`.`t2`.`a` = `test`.`t3`.`a`) and ((`test`.`t3`.`a` > 5) or (`test`.`t3`.`a` < 10))) +select * from t3 where a in (select a from t2); +a filler +1 filler +2 filler +drop table t0, t2, t3; +create table t1 (a date); +insert into t1 values ('2008-01-01'),('2008-01-01'),('2008-02-01'),('2008-02-01'); +create table t2 (a int); +insert into t2 values (1),(2); +create table t3 (a char(10)); +insert into t3 select * from t1; +insert into t3 values (1),(2); +explain select * from t2 where a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; FirstMatch(t2); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1`) where (cast(`test`.`t2`.`a` as double) = cast(`test`.`t1`.`a` as double)) +explain select * from t2 where a in (select a from t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t2); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t2`) where (`test`.`t2`.`a` = `test`.`t2`.`a`) +explain select * from t2 where a in (select a from t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; FirstMatch(t2); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t3`) where (cast(`test`.`t2`.`a` as double) = cast(`test`.`t3`.`a` as double)) +explain select * from t1 where a in (select a from t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; FirstMatch(t1); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t3`) where (`test`.`t1`.`a` = cast(`test`.`t3`.`a` as date)) +drop table t1, t2, t3; +create table t1 (a decimal); +insert into t1 values (1),(2); +explain select * from t1 where a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t1`) where (`test`.`t1`.`a` = `test`.`t1`.`a`) +drop table t1; +create table t1 (a int); +insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t2 as select * from t1; +create table t3 (a int, b int, filler char(100), key(a)) charset utf8mb4; +insert into t3 select A.a + 10*B.a, A.a + 10*B.a, 'filler' from t1 A, t1 B, t1 C; +explain select * from t1, t3 where t3.a in (select a from t2) and (t3.a < 10 or t3.a >30) and t1.a =3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 10.00 Using where +1 SIMPLE t3 NULL ALL a NULL NULL NULL 1000 79.30 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 10 10.00 Using where; FirstMatch(t3); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t3`.`filler` AS `filler` from `test`.`t1` join `test`.`t3` semi join (`test`.`t2`) where ((`test`.`t2`.`a` = `test`.`t3`.`a`) and (`test`.`t1`.`a` = 3) and ((`test`.`t3`.`a` < 10) or (`test`.`t3`.`a` > 30))) +explain format=json select * from t1, t3 where t3.a in (select a from t2) and (t3.a < 10 or t3.a >30) and t1.a =3; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "921.10" + }, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 10, + "rows_produced_per_join": 1, + "filtered": "10.00", + "cost_info": { + "read_cost": "1.40", + "eval_cost": "0.10", + "prefix_cost": "1.50", + "data_read_per_join": "8" + }, + "used_columns": [ + "a" + ], + "attached_condition": "(`test`.`t1`.`a` = 3)" + } + }, + { + "table": { + "table_name": "t3", + "access_type": "ALL", + "possible_keys": [ + "a" + ], + "rows_examined_per_scan": 1000, + "rows_produced_per_join": 793, + "filtered": "79.30", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "46.16", + "eval_cost": "79.30", + "prefix_cost": "126.97", + "data_read_per_join": "322K" + }, + "used_columns": [ + "a", + "b", + "filler" + ], + "attached_condition": "((`test`.`t3`.`a` < 10) or (`test`.`t3`.`a` > 30))" + } + }, + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 10, + "rows_produced_per_join": 793, + "filtered": "10.00", + "first_match": "t3", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.52", + "eval_cost": "79.30", + "prefix_cost": "921.10", + "data_read_per_join": "6K" + }, + "used_columns": [ + "a" + ], + "attached_condition": "(`test`.`t2`.`a` = `test`.`t3`.`a`)" + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t3`.`filler` AS `filler` from `test`.`t1` join `test`.`t3` semi join (`test`.`t2`) where ((`test`.`t2`.`a` = `test`.`t3`.`a`) and (`test`.`t1`.`a` = 3) and ((`test`.`t3`.`a` < 10) or (`test`.`t3`.`a` > 30))) +explain select straight_join * from t1 a, t1 b where a.a in (select a from t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY a NULL ALL NULL NULL NULL NULL 10 100.00 Using where +1 PRIMARY b NULL ALL NULL NULL NULL NULL 10 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select straight_join `test`.`a`.`a` AS `a`,`test`.`b`.`a` AS `a` from `test`.`t1` `a` join `test`.`t1` `b` where (`test`.`a`.`a`,(/* select#2 */ select `test`.`t2`.`a` from `test`.`t2` where ((`test`.`a`.`a`) = `test`.`t2`.`a`))) +explain select * from t2 where a in (select straight_join a.a from t1 a, t1 b); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 10 100.00 Using where +2 DEPENDENT SUBQUERY a NULL ALL NULL NULL NULL NULL 10 10.00 Using where +2 DEPENDENT SUBQUERY b NULL ALL NULL NULL NULL NULL 10 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` where (`test`.`t2`.`a`,(/* select#2 */ select straight_join `test`.`a`.`a` from `test`.`t1` `a` join `test`.`t1` `b` where ((`test`.`t2`.`a`) = `test`.`a`.`a`))) +explain select * from t2 where a in (select straight_join a.a from t1 a, t1 b); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 10 100.00 Using where +2 DEPENDENT SUBQUERY a NULL ALL NULL NULL NULL NULL 10 10.00 Using where +2 DEPENDENT SUBQUERY b NULL ALL NULL NULL NULL NULL 10 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` where (`test`.`t2`.`a`,(/* select#2 */ select straight_join `test`.`a`.`a` from `test`.`t1` `a` join `test`.`t1` `b` where ((`test`.`t2`.`a`) = `test`.`a`.`a`))) +explain select straight_join * from t2 x, t2 y +where x.a in (select straight_join a.a from t1 a, t1 b); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY x NULL ALL NULL NULL NULL NULL 10 100.00 Using where +1 PRIMARY y NULL ALL NULL NULL NULL NULL 10 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY a NULL ALL NULL NULL NULL NULL 10 10.00 Using where +2 DEPENDENT SUBQUERY b NULL ALL NULL NULL NULL NULL 10 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select straight_join `test`.`x`.`a` AS `a`,`test`.`y`.`a` AS `a` from `test`.`t2` `x` join `test`.`t2` `y` where (`test`.`x`.`a`,(/* select#2 */ select straight_join `test`.`a`.`a` from `test`.`t1` `a` join `test`.`t1` `b` where ((`test`.`x`.`a`) = `test`.`a`.`a`))) +create table t0 (a int, b int); +insert into t0 values(1,1); +explain select * from t0, t3 where t3.a in (select a from t2) and (t3.a < 10 or t3.a >30); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL a NULL NULL NULL 1000 79.30 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 10 10.00 Using where; FirstMatch(t3); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '1' AS `a`,'1' AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t3`.`filler` AS `filler` from `test`.`t3` semi join (`test`.`t2`) where ((`test`.`t2`.`a` = `test`.`t3`.`a`) and ((`test`.`t3`.`a` < 10) or (`test`.`t3`.`a` > 30))) +create table t4 as select a as x, a as y from t1; +explain select * from t0, t3 where (t3.a, t3.b) in (select x,y from t4) and (t3.a < 10 or t3.a >30); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL a NULL NULL NULL 1000 79.30 Using where +1 SIMPLE t4 NULL ALL NULL NULL NULL NULL 10 10.00 Using where; FirstMatch(t3); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '1' AS `a`,'1' AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t3`.`filler` AS `filler` from `test`.`t3` semi join (`test`.`t4`) where ((`test`.`t4`.`y` = `test`.`t3`.`b`) and (`test`.`t4`.`x` = `test`.`t3`.`a`) and ((`test`.`t3`.`a` < 10) or (`test`.`t3`.`a` > 30))) +drop table t0,t1,t2,t3,t4; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (a int, b int, filler char(100), key(a,b)); +insert into t1 select A.a, B.a, 'filler' from t0 A, t0 B; +create table t2 as select * from t1; +explain select * from t2 where a in (select b from t1 where a=3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 100 100.00 Using where +1 SIMPLE t1 NULL ref a a 10 const,test.t2.a 1 100.00 Using index; FirstMatch(t2) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`filler` AS `filler` from `test`.`t2` semi join (`test`.`t1`) where ((`test`.`t1`.`b` = `test`.`t2`.`a`) and (`test`.`t1`.`a` = 3)) +explain select * from t2 where (b,a) in (select a,b from t1 where a=3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 100 10.00 Using where +1 SIMPLE t1 NULL ref a a 10 const,test.t2.a 1 100.00 Using index; FirstMatch(t2) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`filler` AS `filler` from `test`.`t2` semi join (`test`.`t1`) where ((`test`.`t1`.`b` = `test`.`t2`.`a`) and (`test`.`t2`.`b` = 3) and (`test`.`t1`.`a` = 3)) +drop table t1,t2; +create table t1 (a int, b int); +insert into t1 select a,a from t0; +create table t2 (a int, b int); +insert into t2 select A.a + 10*B.a, A.a + 10*B.a from t0 A, t0 B; +explain select * from t1 where (a,b) in (select a,b from t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 100 1.00 Using where; FirstMatch(t1); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`a` = `test`.`t1`.`a`)) +drop table t0, t1, t2; +# +# Bug#19695490: CRASH IN CREATE_REF_FOR_KEY ON SELECT + JOIN + UTF8 COLUMN +# + DATETIME INDEX. +# +CREATE TABLE t1 ( +field1 varchar(255) CHARACTER SET utf8, +field2 varchar(255) CHARACTER SET utf8 +); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES +('time','time'), +('lpjdzvkp','lpjdzvkp'), +('dzvkpai', 'dzvkpai'); +CREATE TABLE t2 ( col_varchar varchar(10)); +CREATE TABLE t3 ( +pk int(11) NOT NULL, +col_varchar_255_utf8_key varchar(255) CHARACTER SET utf8, +col_varchar_10_utf8_key varchar(10) CHARACTER SET utf8, +PRIMARY KEY (pk) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t3 VALUES (22,'come','h'), +(23,'time','aaa'), +(24,'lpjdzvkp','ababa'), +(25,'d','GGDD'); +SELECT * FROM t1 WHERE (field1, field2) IN ( +SELECT table1.col_varchar_255_utf8_key AS field1, +table1.col_varchar_255_utf8_key AS field2 +FROM t3 AS table1 LEFT JOIN t2 AS table2 +ON table1.col_varchar_10_utf8_key <= +table2.col_varchar +WHERE table1.pk >= 6); +field1 field2 +time time +lpjdzvkp lpjdzvkp +DROP TABLE t1,t2,t3; +create table t0 (a decimal(4,2)); +insert into t0 values (10.24), (22.11); +create table t1 as select * from t0; +insert into t1 select * from t0; +explain select * from t0 where a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; FirstMatch(t0); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a` from `test`.`t0` semi join (`test`.`t1`) where (`test`.`t1`.`a` = `test`.`t0`.`a`) +select * from t0 where a in (select a from t1); +a +10.24 +22.11 +drop table t0, t1; +create table t0(a date); +insert into t0 values ('2008-01-01'),('2008-02-02'); +create table t1 as select * from t0; +insert into t1 select * from t0; +explain select * from t0 where a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; FirstMatch(t0); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a` from `test`.`t0` semi join (`test`.`t1`) where (`test`.`t1`.`a` = `test`.`t0`.`a`) +select * from t0 where a in (select a from t1); +a +2008-01-01 +2008-02-02 +drop table t0, t1; +create table t0(a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 as select a as a, a as b, a as c from t0 where a < 3; +create table t2 as select a as a, a as b from t0 where a < 3; +insert into t2 select * from t2; +explain select * from t1 where (a,b,c) in (select x.a, y.a, z.a from t2 x, t2 y, t2 z where x.b=33); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE x NULL ALL NULL NULL NULL NULL 6 16.67 Using where +1 SIMPLE y NULL ALL NULL NULL NULL NULL 6 16.67 Using where +1 SIMPLE z NULL ALL NULL NULL NULL NULL 6 16.67 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` semi join (`test`.`t2` `x` join `test`.`t2` `y` join `test`.`t2` `z`) where ((`test`.`z`.`a` = `test`.`t1`.`c`) and (`test`.`y`.`a` = `test`.`t1`.`b`) and (`test`.`x`.`a` = `test`.`t1`.`a`) and (`test`.`x`.`b` = 33)) +drop table t0,t1,t2; +set @save_join_buffer_size = @@join_buffer_size; +set join_buffer_size= 8192; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (a int, filler1 binary(200), filler2 binary(200)); +insert into t1 select a, 'filler123456', 'filler123456' from t0; +insert into t1 select a+10, 'filler123456', 'filler123456' from t0; +create table t2 as select * from t1; +insert into t1 select a+20, 'filler123456', 'filler123456' from t0; +insert into t1 values (2, 'duplicate ok', 'duplicate ok'); +insert into t1 values (18, 'duplicate ok', 'duplicate ok'); +insert into t2 values (3, 'duplicate ok', 'duplicate ok'); +insert into t2 values (19, 'duplicate ok', 'duplicate ok'); +explain select +a, mid(filler1, 1,10), length(filler1)=length(filler2) as z +from t1 ot where a in (select a from t2 it); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 32 100.00 NULL +1 SIMPLE it NULL ALL NULL NULL NULL NULL 22 10.00 Using where; FirstMatch(ot); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot`.`a` AS `a`,substr(`test`.`ot`.`filler1`,1,10) AS `mid(filler1, 1,10)`,(length(`test`.`ot`.`filler1`) = length(`test`.`ot`.`filler2`)) AS `z` from `test`.`t1` `ot` semi join (`test`.`t2` `it`) where (`test`.`it`.`a` = `test`.`ot`.`a`) +select +a, mid(filler1, 1,10), length(filler1)=length(filler2) as z +from t1 ot where a in (select a from t2 it); +a mid(filler1, 1,10) z +0 filler1234 1 +1 filler1234 1 +10 filler1234 1 +11 filler1234 1 +12 filler1234 1 +13 filler1234 1 +14 filler1234 1 +15 filler1234 1 +16 filler1234 1 +17 filler1234 1 +18 duplicate 1 +18 filler1234 1 +19 filler1234 1 +2 duplicate 1 +2 filler1234 1 +3 filler1234 1 +4 filler1234 1 +5 filler1234 1 +6 filler1234 1 +7 filler1234 1 +8 filler1234 1 +9 filler1234 1 +explain select +a, mid(filler1, 1,10), length(filler1)=length(filler2) +from t2 ot where a in (select a from t1 it); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 22 100.00 NULL +1 SIMPLE it NULL ALL NULL NULL NULL NULL 32 10.00 Using where; FirstMatch(ot); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot`.`a` AS `a`,substr(`test`.`ot`.`filler1`,1,10) AS `mid(filler1, 1,10)`,(length(`test`.`ot`.`filler1`) = length(`test`.`ot`.`filler2`)) AS `length(filler1)=length(filler2)` from `test`.`t2` `ot` semi join (`test`.`t1` `it`) where (`test`.`it`.`a` = `test`.`ot`.`a`) +select +a, mid(filler1, 1,10), length(filler1)=length(filler2) +from t2 ot where a in (select a from t1 it); +a mid(filler1, 1,10) length(filler1)=length(filler2) +0 filler1234 1 +1 filler1234 1 +10 filler1234 1 +11 filler1234 1 +12 filler1234 1 +13 filler1234 1 +14 filler1234 1 +15 filler1234 1 +16 filler1234 1 +17 filler1234 1 +18 filler1234 1 +19 duplicate 1 +19 filler1234 1 +2 filler1234 1 +3 duplicate 1 +3 filler1234 1 +4 filler1234 1 +5 filler1234 1 +6 filler1234 1 +7 filler1234 1 +8 filler1234 1 +9 filler1234 1 +insert into t1 select a+20, 'filler123456', 'filler123456' from t0; +insert into t1 select a+20, 'filler123456', 'filler123456' from t0; +explain select +a, mid(filler1, 1,10), length(filler1)=length(filler2) as z +from t1 ot where a in (select a from t2 it); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 52 100.00 NULL +1 SIMPLE it NULL ALL NULL NULL NULL NULL 22 10.00 Using where; FirstMatch(ot); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot`.`a` AS `a`,substr(`test`.`ot`.`filler1`,1,10) AS `mid(filler1, 1,10)`,(length(`test`.`ot`.`filler1`) = length(`test`.`ot`.`filler2`)) AS `z` from `test`.`t1` `ot` semi join (`test`.`t2` `it`) where (`test`.`it`.`a` = `test`.`ot`.`a`) +select +a, mid(filler1, 1,10), length(filler1)=length(filler2) as z +from t1 ot where a in (select a from t2 it); +a mid(filler1, 1,10) z +0 filler1234 1 +1 filler1234 1 +10 filler1234 1 +11 filler1234 1 +12 filler1234 1 +13 filler1234 1 +14 filler1234 1 +15 filler1234 1 +16 filler1234 1 +17 filler1234 1 +18 duplicate 1 +18 filler1234 1 +19 filler1234 1 +2 duplicate 1 +2 filler1234 1 +3 filler1234 1 +4 filler1234 1 +5 filler1234 1 +6 filler1234 1 +7 filler1234 1 +8 filler1234 1 +9 filler1234 1 +explain select +a, mid(filler1, 1,10), length(filler1)=length(filler2) +from t2 ot where a in (select a from t1 it); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 22 100.00 NULL +1 SIMPLE it NULL ALL NULL NULL NULL NULL 52 10.00 Using where; FirstMatch(ot); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot`.`a` AS `a`,substr(`test`.`ot`.`filler1`,1,10) AS `mid(filler1, 1,10)`,(length(`test`.`ot`.`filler1`) = length(`test`.`ot`.`filler2`)) AS `length(filler1)=length(filler2)` from `test`.`t2` `ot` semi join (`test`.`t1` `it`) where (`test`.`it`.`a` = `test`.`ot`.`a`) +select +a, mid(filler1, 1,10), length(filler1)=length(filler2) +from t2 ot where a in (select a from t1 it); +a mid(filler1, 1,10) length(filler1)=length(filler2) +0 filler1234 1 +1 filler1234 1 +10 filler1234 1 +11 filler1234 1 +12 filler1234 1 +13 filler1234 1 +14 filler1234 1 +15 filler1234 1 +16 filler1234 1 +17 filler1234 1 +18 filler1234 1 +19 duplicate 1 +19 filler1234 1 +2 filler1234 1 +3 duplicate 1 +3 filler1234 1 +4 filler1234 1 +5 filler1234 1 +6 filler1234 1 +7 filler1234 1 +8 filler1234 1 +9 filler1234 1 +set @@join_buffer_size = @save_join_buffer_size; +drop table t1, t2; +create table t1 (a int, b int, key(a)); +create table t2 (a int, b int, key(a)); +create table t3 (a int, b int, key(a)); +insert into t1 select a,a from t0; +insert into t2 select a,a from t0; +insert into t3 select a,a from t0; +t2 and t3 must be use 'ref', not 'ALL': +explain select * +from t0 where a in +(select t2.a+t3.a from t1 left join (t2 join t3) on t2.a=t1.a and t3.a=t1.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 10 100.00 NULL +1 SIMPLE t1 NULL index a a 5 NULL 10 100.00 Using where; Using index +1 SIMPLE t2 NULL ref a a 5 test.t1.a 1 100.00 Using index +1 SIMPLE t3 NULL ref a a 5 test.t1.a 1 100.00 Using index; FirstMatch(t0) +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a` from `test`.`t0` semi join (`test`.`t1` join `test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`a` = `test`.`t1`.`a`) and (`test`.`t3`.`a` = `test`.`t1`.`a`) and (`test`.`t0`.`a` = (`test`.`t1`.`a` + `test`.`t1`.`a`))) +drop table t0, t1,t2,t3; + +Test that neither MaterializeLookup strategy for semijoin, +nor subquery materialization is used when BLOBs are involved +(except when arguments of some functions). + +set @prefix_len = 6; +set @blob_len = 16; +set @suffix_len = @blob_len - @prefix_len; +create table t1_16 (a1 blob(16), a2 blob(16)); +create table t2_16 (b1 blob(16), b2 blob(16)); +create table t3_16 (c1 blob(16), c2 blob(16)); +insert into t1_16 values +(concat('1 - 00', repeat('x', @suffix_len)), concat('2 - 00', repeat('x', @suffix_len))); +insert into t1_16 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t1_16 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_16 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t2_16 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_16 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_16 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t3_16 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t3_16 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_16 values +(concat('1 - 04', repeat('x', @suffix_len)), concat('2 - 04', repeat('x', @suffix_len))); +explain select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select b1 from t2_16 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1_16 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t2_16 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(t1_16); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_16`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_16`.`a2`,7) AS `left(a2,7)` from `test`.`t1_16` semi join (`test`.`t2_16`) where ((`test`.`t2_16`.`b1` = `test`.`t1_16`.`a1`) and (`test`.`t1_16`.`a1` > '0')) +select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select b1 from t2_16 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_16 +where (a1,a2) in (select b1, b2 from t2_16 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1_16 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t2_16 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(t1_16); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_16`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_16`.`a2`,7) AS `left(a2,7)` from `test`.`t1_16` semi join (`test`.`t2_16`) where ((`test`.`t2_16`.`b2` = `test`.`t1_16`.`a2`) and (`test`.`t2_16`.`b1` = `test`.`t1_16`.`a1`) and (`test`.`t1_16`.`a1` > '0')) +select left(a1,7), left(a2,7) +from t1_16 +where (a1,a2) in (select b1, b2 from t2_16 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select substring(b1,1,16) from t2_16 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1_16 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE t2_16 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(t1_16); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_16`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_16`.`a2`,7) AS `left(a2,7)` from `test`.`t1_16` semi join (`test`.`t2_16`) where ((`test`.`t2_16`.`b1` > '0') and (`test`.`t1_16`.`a1` = substr(`test`.`t2_16`.`b1`,1,16))) +select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select substring(b1,1,16) from t2_16 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select group_concat(b1) from t2_16 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_16 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t2_16 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_16`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_16`.`a2`,7) AS `left(a2,7)` from `test`.`t1_16` where (`test`.`t1_16`.`a1`,(/* select#2 */ select group_concat(`test`.`t2_16`.`b1` separator ',') from `test`.`t2_16` group by `test`.`t2_16`.`b2` having ((`test`.`t1_16`.`a1`) = (group_concat(`test`.`t2_16`.`b1` separator ','))))) +select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select group_concat(b1) from t2_16 group by b2); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +set @@group_concat_max_len = 256; +explain select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select group_concat(b1) from t2_16 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_16 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t2_16 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_16`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_16`.`a2`,7) AS `left(a2,7)` from `test`.`t1_16` where (`test`.`t1_16`.`a1`,(/* select#2 */ select group_concat(`test`.`t2_16`.`b1` separator ',') from `test`.`t2_16` group by `test`.`t2_16`.`b2` having ((`test`.`t1_16`.`a1`) = (group_concat(`test`.`t2_16`.`b1` separator ','))))) +select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select group_concat(b1) from t2_16 group by b2); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +create table t1 (a1 char(8), a2 char(8)) charset latin1; +create table t2 (b1 char(8), b2 char(8)) charset latin1; +create table t3 (c1 char(8), c2 char(8)) charset latin1; +insert into t1 values ('1 - 00', '2 - 00'); +insert into t1 values ('1 - 01', '2 - 01'); +insert into t1 values ('1 - 02', '2 - 02'); +insert into t2 values ('1 - 01', '2 - 01'); +insert into t2 values ('1 - 01', '2 - 01'); +insert into t2 values ('1 - 02', '2 - 02'); +insert into t2 values ('1 - 02', '2 - 02'); +insert into t2 values ('1 - 03', '2 - 03'); +insert into t3 values ('1 - 01', '2 - 01'); +insert into t3 values ('1 - 02', '2 - 02'); +insert into t3 values ('1 - 03', '2 - 03'); +insert into t3 values ('1 - 04', '2 - 04'); +insert into t3 values ('1 - 05', '2 - 05'); +insert into t3 values ('1 - 06', '2 - 06'); +insert into t3 values ('1 - 07', '2 - 07'); +insert into t3 values ('1 - 08', '2 - 08'); +explain +select * from t1 +where concat(a1,'x') IN +(select left(a1,8) from t1_16 +where (a1, a2) IN +(select t2_16.b1, t2_16.b2 from t2_16, t2 +where t2.b2 = substring(t2_16.b2,1,6) and +t2.b1 IN (select c1 from t3 where c2 > '0'))); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE t1_16 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t2_16 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 5 20.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` semi join (`test`.`t1_16` join `test`.`t2_16` join `test`.`t2` join `test`.`t3`) where ((`test`.`t2_16`.`b2` = `test`.`t1_16`.`a2`) and (`test`.`t2_16`.`b1` = `test`.`t1_16`.`a1`) and (`test`.`t3`.`c1` = `test`.`t2`.`b1`) and (`test`.`t2`.`b2` = substr(`test`.`t2_16`.`b2`,1,6)) and (`test`.`t3`.`c2` > '0') and (concat(`test`.`t1`.`a1`,'x') = left(`test`.`t1_16`.`a1`,8))) +drop table t1_16, t2_16, t3_16, t1, t2, t3; +set @blob_len = 512; +set @suffix_len = @blob_len - @prefix_len; +create table t1_512 (a1 blob(512), a2 blob(512)); +create table t2_512 (b1 blob(512), b2 blob(512)); +create table t3_512 (c1 blob(512), c2 blob(512)); +insert into t1_512 values +(concat('1 - 00', repeat('x', @suffix_len)), concat('2 - 00', repeat('x', @suffix_len))); +insert into t1_512 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t1_512 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_512 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t2_512 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_512 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_512 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t3_512 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t3_512 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_512 values +(concat('1 - 04', repeat('x', @suffix_len)), concat('2 - 04', repeat('x', @suffix_len))); +explain select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select b1 from t2_512 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1_512 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t2_512 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(t1_512); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_512`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_512`.`a2`,7) AS `left(a2,7)` from `test`.`t1_512` semi join (`test`.`t2_512`) where ((`test`.`t2_512`.`b1` = `test`.`t1_512`.`a1`) and (`test`.`t1_512`.`a1` > '0')) +select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select b1 from t2_512 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_512 +where (a1,a2) in (select b1, b2 from t2_512 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1_512 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t2_512 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(t1_512); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_512`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_512`.`a2`,7) AS `left(a2,7)` from `test`.`t1_512` semi join (`test`.`t2_512`) where ((`test`.`t2_512`.`b2` = `test`.`t1_512`.`a2`) and (`test`.`t2_512`.`b1` = `test`.`t1_512`.`a1`) and (`test`.`t1_512`.`a1` > '0')) +select left(a1,7), left(a2,7) +from t1_512 +where (a1,a2) in (select b1, b2 from t2_512 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select substring(b1,1,512) from t2_512 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1_512 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE t2_512 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(t1_512); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_512`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_512`.`a2`,7) AS `left(a2,7)` from `test`.`t1_512` semi join (`test`.`t2_512`) where ((`test`.`t2_512`.`b1` > '0') and (`test`.`t1_512`.`a1` = substr(`test`.`t2_512`.`b1`,1,512))) +select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select substring(b1,1,512) from t2_512 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select group_concat(b1) from t2_512 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_512 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t2_512 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_512`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_512`.`a2`,7) AS `left(a2,7)` from `test`.`t1_512` where (`test`.`t1_512`.`a1`,(/* select#2 */ select group_concat(`test`.`t2_512`.`b1` separator ',') from `test`.`t2_512` group by `test`.`t2_512`.`b2` having ((`test`.`t1_512`.`a1`) = (group_concat(`test`.`t2_512`.`b1` separator ','))))) +select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select group_concat(b1) from t2_512 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +Warning 1260 Row 4 was cut by GROUP_CONCAT() +Warning 1260 Row 5 was cut by GROUP_CONCAT() +Warning 1260 Row 6 was cut by GROUP_CONCAT() +Warning 1260 Row 7 was cut by GROUP_CONCAT() +Warning 1260 Row 8 was cut by GROUP_CONCAT() +Warning 1260 Row 9 was cut by GROUP_CONCAT() +set @@group_concat_max_len = 256; +explain select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select group_concat(b1) from t2_512 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_512 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t2_512 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_512`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_512`.`a2`,7) AS `left(a2,7)` from `test`.`t1_512` where (`test`.`t1_512`.`a1`,(/* select#2 */ select group_concat(`test`.`t2_512`.`b1` separator ',') from `test`.`t2_512` group by `test`.`t2_512`.`b2` having ((`test`.`t1_512`.`a1`) = (group_concat(`test`.`t2_512`.`b1` separator ','))))) +select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select group_concat(b1) from t2_512 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +Warning 1260 Row 4 was cut by GROUP_CONCAT() +Warning 1260 Row 5 was cut by GROUP_CONCAT() +Warning 1260 Row 6 was cut by GROUP_CONCAT() +Warning 1260 Row 7 was cut by GROUP_CONCAT() +Warning 1260 Row 8 was cut by GROUP_CONCAT() +Warning 1260 Row 9 was cut by GROUP_CONCAT() +drop table t1_512, t2_512, t3_512; +set @blob_len = 513; +set @suffix_len = @blob_len - @prefix_len; +create table t1_513 (a1 blob(513), a2 blob(513)); +create table t2_513 (b1 blob(513), b2 blob(513)); +create table t3_513 (c1 blob(513), c2 blob(513)); +insert into t1_513 values +(concat('1 - 00', repeat('x', @suffix_len)), concat('2 - 00', repeat('x', @suffix_len))); +insert into t1_513 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t1_513 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_513 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t2_513 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_513 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_513 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t3_513 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t3_513 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_513 values +(concat('1 - 04', repeat('x', @suffix_len)), concat('2 - 04', repeat('x', @suffix_len))); +explain select left(a1,7), left(a2,7) +from t1_513 +where a1 in (select b1 from t2_513 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1_513 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t2_513 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(t1_513); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_513`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_513`.`a2`,7) AS `left(a2,7)` from `test`.`t1_513` semi join (`test`.`t2_513`) where ((`test`.`t2_513`.`b1` = `test`.`t1_513`.`a1`) and (`test`.`t1_513`.`a1` > '0')) +select left(a1,7), left(a2,7) +from t1_513 +where a1 in (select b1 from t2_513 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_513 +where (a1,a2) in (select b1, b2 from t2_513 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1_513 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t2_513 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(t1_513); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_513`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_513`.`a2`,7) AS `left(a2,7)` from `test`.`t1_513` semi join (`test`.`t2_513`) where ((`test`.`t2_513`.`b2` = `test`.`t1_513`.`a2`) and (`test`.`t2_513`.`b1` = `test`.`t1_513`.`a1`) and (`test`.`t1_513`.`a1` > '0')) +select left(a1,7), left(a2,7) +from t1_513 +where (a1,a2) in (select b1, b2 from t2_513 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_513 +where a1 in (select substring(b1,1,513) from t2_513 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1_513 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE t2_513 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(t1_513); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_513`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_513`.`a2`,7) AS `left(a2,7)` from `test`.`t1_513` semi join (`test`.`t2_513`) where ((`test`.`t2_513`.`b1` > '0') and (`test`.`t1_513`.`a1` = substr(`test`.`t2_513`.`b1`,1,513))) +select left(a1,7), left(a2,7) +from t1_513 +where a1 in (select substring(b1,1,513) from t2_513 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_513 +where a1 in (select group_concat(b1) from t2_513 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_513 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t2_513 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_513`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_513`.`a2`,7) AS `left(a2,7)` from `test`.`t1_513` where (`test`.`t1_513`.`a1`,(/* select#2 */ select group_concat(`test`.`t2_513`.`b1` separator ',') from `test`.`t2_513` group by `test`.`t2_513`.`b2` having ((`test`.`t1_513`.`a1`) = (group_concat(`test`.`t2_513`.`b1` separator ','))))) +select left(a1,7), left(a2,7) +from t1_513 +where a1 in (select group_concat(b1) from t2_513 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +Warning 1260 Row 4 was cut by GROUP_CONCAT() +Warning 1260 Row 5 was cut by GROUP_CONCAT() +Warning 1260 Row 6 was cut by GROUP_CONCAT() +Warning 1260 Row 7 was cut by GROUP_CONCAT() +Warning 1260 Row 8 was cut by GROUP_CONCAT() +Warning 1260 Row 9 was cut by GROUP_CONCAT() +drop table t1_513, t2_513, t3_513; +set @blob_len = 1024; +set @suffix_len = @blob_len - @prefix_len; +create table t1_1024 (a1 blob(1024), a2 blob(1024)); +create table t2_1024 (b1 blob(1024), b2 blob(1024)); +create table t3_1024 (c1 blob(1024), c2 blob(1024)); +insert into t1_1024 values +(concat('1 - 00', repeat('x', @suffix_len)), concat('2 - 00', repeat('x', @suffix_len))); +insert into t1_1024 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t1_1024 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_1024 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t2_1024 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_1024 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_1024 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t3_1024 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t3_1024 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_1024 values +(concat('1 - 04', repeat('x', @suffix_len)), concat('2 - 04', repeat('x', @suffix_len))); +explain select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select b1 from t2_1024 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1_1024 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t2_1024 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(t1_1024); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1024`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1024`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1024` semi join (`test`.`t2_1024`) where ((`test`.`t2_1024`.`b1` = `test`.`t1_1024`.`a1`) and (`test`.`t1_1024`.`a1` > '0')) +select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select b1 from t2_1024 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_1024 +where (a1,a2) in (select b1, b2 from t2_1024 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1_1024 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t2_1024 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(t1_1024); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1024`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1024`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1024` semi join (`test`.`t2_1024`) where ((`test`.`t2_1024`.`b2` = `test`.`t1_1024`.`a2`) and (`test`.`t2_1024`.`b1` = `test`.`t1_1024`.`a1`) and (`test`.`t1_1024`.`a1` > '0')) +select left(a1,7), left(a2,7) +from t1_1024 +where (a1,a2) in (select b1, b2 from t2_1024 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select substring(b1,1,1024) from t2_1024 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1_1024 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE t2_1024 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(t1_1024); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1024`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1024`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1024` semi join (`test`.`t2_1024`) where ((`test`.`t2_1024`.`b1` > '0') and (`test`.`t1_1024`.`a1` = substr(`test`.`t2_1024`.`b1`,1,1024))) +select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select substring(b1,1,1024) from t2_1024 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select group_concat(b1) from t2_1024 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_1024 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t2_1024 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1024`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1024`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1024` where (`test`.`t1_1024`.`a1`,(/* select#2 */ select group_concat(`test`.`t2_1024`.`b1` separator ',') from `test`.`t2_1024` group by `test`.`t2_1024`.`b2` having ((`test`.`t1_1024`.`a1`) = (group_concat(`test`.`t2_1024`.`b1` separator ','))))) +select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select group_concat(b1) from t2_1024 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +Warning 1260 Row 4 was cut by GROUP_CONCAT() +Warning 1260 Row 5 was cut by GROUP_CONCAT() +Warning 1260 Row 6 was cut by GROUP_CONCAT() +Warning 1260 Row 7 was cut by GROUP_CONCAT() +Warning 1260 Row 8 was cut by GROUP_CONCAT() +Warning 1260 Row 9 was cut by GROUP_CONCAT() +set @@group_concat_max_len = 256; +explain select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select group_concat(b1) from t2_1024 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_1024 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t2_1024 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1024`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1024`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1024` where (`test`.`t1_1024`.`a1`,(/* select#2 */ select group_concat(`test`.`t2_1024`.`b1` separator ',') from `test`.`t2_1024` group by `test`.`t2_1024`.`b2` having ((`test`.`t1_1024`.`a1`) = (group_concat(`test`.`t2_1024`.`b1` separator ','))))) +select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select group_concat(b1) from t2_1024 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +Warning 1260 Row 4 was cut by GROUP_CONCAT() +Warning 1260 Row 5 was cut by GROUP_CONCAT() +Warning 1260 Row 6 was cut by GROUP_CONCAT() +Warning 1260 Row 7 was cut by GROUP_CONCAT() +Warning 1260 Row 8 was cut by GROUP_CONCAT() +Warning 1260 Row 9 was cut by GROUP_CONCAT() +drop table t1_1024, t2_1024, t3_1024; +set @blob_len = 1025; +set @suffix_len = @blob_len - @prefix_len; +create table t1_1025 (a1 blob(1025), a2 blob(1025)); +create table t2_1025 (b1 blob(1025), b2 blob(1025)); +create table t3_1025 (c1 blob(1025), c2 blob(1025)); +insert into t1_1025 values +(concat('1 - 00', repeat('x', @suffix_len)), concat('2 - 00', repeat('x', @suffix_len))); +insert into t1_1025 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t1_1025 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_1025 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t2_1025 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_1025 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_1025 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t3_1025 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t3_1025 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_1025 values +(concat('1 - 04', repeat('x', @suffix_len)), concat('2 - 04', repeat('x', @suffix_len))); +explain select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select b1 from t2_1025 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1_1025 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t2_1025 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(t1_1025); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1025`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1025`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1025` semi join (`test`.`t2_1025`) where ((`test`.`t2_1025`.`b1` = `test`.`t1_1025`.`a1`) and (`test`.`t1_1025`.`a1` > '0')) +select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select b1 from t2_1025 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_1025 +where (a1,a2) in (select b1, b2 from t2_1025 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1_1025 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t2_1025 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(t1_1025); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1025`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1025`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1025` semi join (`test`.`t2_1025`) where ((`test`.`t2_1025`.`b2` = `test`.`t1_1025`.`a2`) and (`test`.`t2_1025`.`b1` = `test`.`t1_1025`.`a1`) and (`test`.`t1_1025`.`a1` > '0')) +select left(a1,7), left(a2,7) +from t1_1025 +where (a1,a2) in (select b1, b2 from t2_1025 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select substring(b1,1,1025) from t2_1025 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1_1025 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE t2_1025 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(t1_1025); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1025`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1025`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1025` semi join (`test`.`t2_1025`) where ((`test`.`t2_1025`.`b1` > '0') and (`test`.`t1_1025`.`a1` = substr(`test`.`t2_1025`.`b1`,1,1025))) +select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select substring(b1,1,1025) from t2_1025 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select group_concat(b1) from t2_1025 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_1025 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t2_1025 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1025`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1025`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1025` where (`test`.`t1_1025`.`a1`,(/* select#2 */ select group_concat(`test`.`t2_1025`.`b1` separator ',') from `test`.`t2_1025` group by `test`.`t2_1025`.`b2` having ((`test`.`t1_1025`.`a1`) = (group_concat(`test`.`t2_1025`.`b1` separator ','))))) +select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select group_concat(b1) from t2_1025 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +Warning 1260 Row 4 was cut by GROUP_CONCAT() +Warning 1260 Row 5 was cut by GROUP_CONCAT() +Warning 1260 Row 6 was cut by GROUP_CONCAT() +Warning 1260 Row 7 was cut by GROUP_CONCAT() +Warning 1260 Row 8 was cut by GROUP_CONCAT() +Warning 1260 Row 9 was cut by GROUP_CONCAT() +set @@group_concat_max_len = 256; +explain select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select group_concat(b1) from t2_1025 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_1025 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t2_1025 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1025`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1025`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1025` where (`test`.`t1_1025`.`a1`,(/* select#2 */ select group_concat(`test`.`t2_1025`.`b1` separator ',') from `test`.`t2_1025` group by `test`.`t2_1025`.`b2` having ((`test`.`t1_1025`.`a1`) = (group_concat(`test`.`t2_1025`.`b1` separator ','))))) +select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select group_concat(b1) from t2_1025 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +Warning 1260 Row 4 was cut by GROUP_CONCAT() +Warning 1260 Row 5 was cut by GROUP_CONCAT() +Warning 1260 Row 6 was cut by GROUP_CONCAT() +Warning 1260 Row 7 was cut by GROUP_CONCAT() +Warning 1260 Row 8 was cut by GROUP_CONCAT() +Warning 1260 Row 9 was cut by GROUP_CONCAT() +drop table t1_1025, t2_1025, t3_1025; +# +# WL#5561: Enable semi join transformation with outer join. +# +CREATE TABLE ot1(a INT); +CREATE TABLE ot2(a INT); +CREATE TABLE ot3(a INT); +CREATE TABLE it1(a INT); +CREATE TABLE it2(a INT); +CREATE TABLE it3(a INT); +INSERT INTO ot1 VALUES(0),(1),(2),(3),(4),(5),(6),(7); +INSERT INTO ot2 VALUES(0),(2),(4),(6); +INSERT INTO ot3 VALUES(0),(3),(6); +INSERT INTO it1 VALUES(0),(1),(2),(3),(4),(5),(6),(7); +INSERT INTO it2 VALUES(0),(2),(4),(6); +INSERT INTO it3 VALUES(0),(3),(6); +# Test cases, Subquery Pattern 1 +# Example SQ1.1: +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE ot1.a IN (SELECT a FROM it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +1 SIMPLE it3 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(ot1); Using join buffer (hash join) +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` left join `test`.`ot2` on((`test`.`ot2`.`a` = `test`.`ot1`.`a`)) semi join (`test`.`it3`) where (`test`.`it3`.`a` = `test`.`ot1`.`a`) +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE ot1.a IN (SELECT a FROM it3); +a a +0 0 +3 NULL +6 6 +# Example SQ1.2: +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE COALESCE(ot2.a,0) IN (SELECT a FROM it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (hash join) +1 SIMPLE it3 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(ot2); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` left join `test`.`ot2` on((`test`.`ot2`.`a` = `test`.`ot1`.`a`)) semi join (`test`.`it3`) where (coalesce(`test`.`ot2`.`a`,0) = `test`.`it3`.`a`) +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE COALESCE(ot2.a,0) IN (SELECT a FROM it3); +a a +0 0 +1 NULL +3 NULL +5 NULL +6 6 +7 NULL +# Example SQ1.3: +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE (ot1.a,ot2.a) IN (SELECT a, a FROM it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; Using join buffer (hash join) +1 SIMPLE it3 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(ot1); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` join `test`.`ot2` semi join (`test`.`it3`) where ((`test`.`ot1`.`a` = `test`.`ot2`.`a`) and (`test`.`it3`.`a` = `test`.`ot2`.`a`)) +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE (ot1.a,ot2.a) IN (SELECT a, a FROM it3); +a a +0 0 +6 6 +# More test cases +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 +WHERE ot1.a IN (SELECT a FROM it3); +a a +0 0 +3 NULL +6 6 +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 +WHERE ot1.a IN (SELECT a+0 FROM it3); +a a +0 0 +3 NULL +6 6 +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 +WHERE COALESCE(ot2.a,0) IN (SELECT a FROM it3); +a a +0 0 +1 NULL +3 NULL +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE COALESCE(ot2.a,0) IN (SELECT a+0 FROM it3); +a a +0 0 +1 NULL +3 NULL +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 +WHERE (ot1.a,ot2.a) IN (SELECT a, a FROM it3); +a a +0 0 +6 6 +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +LEFT JOIN ot3 ON ot1.a=ot3.a +WHERE ot1.a IN (SELECT a FROM it3); +a a a +0 0 0 +3 NULL 3 +6 6 6 +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +LEFT JOIN ot3 ON ot1.a=ot3.a +WHERE COALESCE(ot2.a,0) IN (SELECT a FROM it3); +a a a +0 0 0 +1 NULL NULL +3 NULL 3 +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +LEFT JOIN ot3 ON ot1.a=ot3.a +WHERE COALESCE(ot3.a,0) IN (SELECT a FROM it3); +a a a +0 0 0 +1 NULL NULL +2 2 NULL +3 NULL 3 +4 4 NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +LEFT JOIN ot3 ON ot2.a=ot3.a +WHERE ot1.a IN (SELECT a FROM it3); +a a a +0 0 0 +3 NULL NULL +6 6 6 +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +LEFT JOIN ot3 ON ot2.a=ot3.a +WHERE COALESCE(ot2.a,0) IN (SELECT a FROM it3); +a a a +0 0 0 +1 NULL NULL +3 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +LEFT JOIN ot3 ON ot2.a=ot3.a +WHERE COALESCE(ot3.a,0) IN (SELECT a FROM it3); +a a a +0 0 0 +1 NULL NULL +2 2 NULL +3 NULL NULL +4 4 NULL +5 NULL NULL +6 6 6 +7 NULL NULL +# Test cases, Subquery Pattern 2 +# Example SQ2.1: +explain SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; Using join buffer (hash join) +1 SIMPLE it3 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(ot1); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` join `test`.`ot2` semi join (`test`.`it3`) where ((`test`.`ot1`.`a` = `test`.`ot2`.`a`) and (`test`.`it3`.`a` = `test`.`ot2`.`a`)) +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3); +a a +0 0 +6 6 +# Example SQ2.2: +explain SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it2) +AND ot2.a IN (SELECT a FROM it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +1 SIMPLE it3 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(ot2); Using join buffer (hash join) +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; Using join buffer (hash join) +1 SIMPLE it2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; FirstMatch(ot1); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` join `test`.`ot2` semi join (`test`.`it2`) semi join (`test`.`it3`) where ((`test`.`it3`.`a` = `test`.`ot2`.`a`) and (`test`.`ot1`.`a` = `test`.`ot2`.`a`) and (`test`.`it2`.`a` = `test`.`ot2`.`a`)) +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it2) +AND ot2.a IN (SELECT a FROM it3); +a a +0 0 +6 6 +# More test cases +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it3); +a a +0 0 +6 6 +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it3); +a a +0 0 +6 6 +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a+0 AND ot2.a IN (SELECT a FROM it3); +a a +0 0 +6 6 +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot2.a IN (SELECT a+0 FROM it3); +a a +0 0 +6 6 +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it2) +AND ot2.a IN (SELECT a+0 FROM it3); +a a +0 0 +6 6 +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3) +JOIN ot3 ON ot2.a=ot3.a AND ot3.a IN (SELECT a FROM it3); +a a a +0 0 0 +6 6 6 +# Test cases, Subquery Pattern 3 +# Example SQ3.1: +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +1 SIMPLE it3 NULL ALL NULL NULL NULL NULL 3 100.00 Using where; FirstMatch(ot2) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` semi join (`test`.`it3`)) on(((`test`.`ot2`.`a` = `test`.`ot1`.`a`) and (`test`.`it3`.`a` = `test`.`ot1`.`a`))) where true +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3); +a a +0 0 +1 NULL +2 NULL +3 NULL +4 NULL +5 NULL +6 6 +7 NULL +# Example SQ3.2: +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot2.a IN (SELECT a FROM it2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +1 SIMPLE it2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where; FirstMatch(ot2) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` semi join (`test`.`it2`)) on(((`test`.`ot2`.`a` = `test`.`ot1`.`a`) and (`test`.`it2`.`a` = `test`.`ot1`.`a`))) where true +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot2.a IN (SELECT a FROM it2); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +# Example SQ3.3 +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1) +AND ot2.a IN (SELECT a FROM it2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +1 SIMPLE it2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where; FirstMatch(ot2) +1 SIMPLE it1 NULL ALL NULL NULL NULL NULL 8 100.00 Using where; FirstMatch(it2) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` semi join (`test`.`it1`) semi join (`test`.`it2`)) on(((`test`.`ot2`.`a` = `test`.`ot1`.`a`) and (`test`.`it2`.`a` = `test`.`ot1`.`a`) and (`test`.`it1`.`a` = `test`.`ot1`.`a`))) where true +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1) +AND ot2.a IN (SELECT a FROM it2); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +# Example SQ3.4 +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND +(ot1.a, ot2.a) IN (SELECT it1.a, it2.a +FROM it1 JOIN it2 ON it1.a=it2.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +1 SIMPLE it2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +1 SIMPLE it1 NULL ALL NULL NULL NULL NULL 8 100.00 Using where; FirstMatch(ot2) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` semi join (`test`.`it1` join `test`.`it2`)) on(((`test`.`ot2`.`a` = `test`.`ot1`.`a`) and (`test`.`it2`.`a` = `test`.`ot1`.`a`) and (`test`.`it1`.`a` = `test`.`ot1`.`a`))) where true +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND +(ot1.a, ot2.a) IN (SELECT it1.a, it2.a +FROM it1 JOIN it2 ON it1.a=it2.a); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +# More test cases +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it3); +a a +0 0 +1 NULL +2 NULL +3 NULL +4 NULL +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it3); +a a +0 0 +1 NULL +2 NULL +3 NULL +4 NULL +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 AND ot2.a IN (SELECT a FROM it2); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot2.a IN (SELECT a+0 FROM it2); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a+0 FROM it1) +AND ot2.a IN (SELECT a+0 FROM it2); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 AND +(ot1.a, ot2.a) IN (SELECT it1.a+0, it2.a+0 +FROM it1 JOIN it2 ON it1.a=it2.a); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +EXPLAIN FORMAT=tree SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3) +LEFT JOIN ot3 ON ot2.a=ot3.a AND ot3.a IN (SELECT a FROM it3); +EXPLAIN +-> Nested loop left join (cost=98.31 rows=864) + -> Nested loop left join (cost=11.41 rows=96) + -> Table scan on ot1 (cost=1.30 rows=8) + -> Nested loop semijoin (cost=1.81 rows=12) + -> Filter: (ot2.a = ot1.a) (cost=0.11 rows=4) + -> Table scan on ot2 (cost=0.11 rows=4) + -> Filter: (it3.a = ot1.a) (cost=0.08 rows=3) + -> Table scan on it3 (cost=0.08 rows=3) + -> Nested loop semijoin (cost=1.43 rows=9) + -> Filter: (ot3.a = ot2.a) (cost=0.03 rows=3) + -> Table scan on ot3 (cost=0.03 rows=3) + -> Filter: (it3.a = ot2.a) (cost=0.03 rows=3) + -> Table scan on it3 (cost=0.03 rows=3) + +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3) +LEFT JOIN ot3 ON ot2.a=ot3.a AND ot3.a IN (SELECT a FROM it3); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it3) +LEFT JOIN ot3 ON ot2.a=ot3.a+0 AND ot3.a IN (SELECT a FROM it3); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +# Test cases, Subquery Pattern 4 +# Example SQ4.1: +explain SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +1 SIMPLE ot3 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE it1 NULL ALL NULL NULL NULL NULL 8 100.00 Using where; FirstMatch(ot3) +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a`,`test`.`ot3`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` join `test`.`ot3` semi join (`test`.`it1`)) on(((`test`.`ot3`.`a` = `test`.`ot1`.`a`) and (`test`.`it1`.`a` = `test`.`ot1`.`a`) and (`test`.`ot2`.`a` = `test`.`ot1`.`a`))) where true +SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +# Example SQ4.2: +explain SELECT * +FROM ot1 +JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot3 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; Using join buffer (hash join) +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; Using join buffer (hash join) +1 SIMPLE it1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; FirstMatch(ot1); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a`,`test`.`ot3`.`a` AS `a` from `test`.`ot1` join `test`.`ot2` join `test`.`ot3` semi join (`test`.`it1`) where ((`test`.`ot2`.`a` = `test`.`ot3`.`a`) and (`test`.`ot1`.`a` = `test`.`ot3`.`a`) and (`test`.`it1`.`a` = `test`.`ot3`.`a`)) +SELECT * +FROM ot1 +JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +6 6 6 +# Example SQ4.3: +explain SELECT * +FROM ot1 +JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; Using join buffer (hash join) +1 SIMPLE it1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; FirstMatch(ot1); Using join buffer (hash join) +1 SIMPLE ot3 NULL ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a`,`test`.`ot3`.`a` AS `a` from `test`.`ot1` join `test`.`ot2` left join `test`.`ot3` on((`test`.`ot3`.`a` = `test`.`ot2`.`a`)) semi join (`test`.`it1`) where ((`test`.`ot1`.`a` = `test`.`ot2`.`a`) and (`test`.`it1`.`a` = `test`.`ot2`.`a`)) +SELECT * +FROM ot1 +JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +2 2 NULL +4 4 NULL +6 6 6 +# Example SQ4.4: +explain SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +1 SIMPLE it1 NULL ALL NULL NULL NULL NULL 8 100.00 Using where; FirstMatch(ot2) +1 SIMPLE ot3 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a`,`test`.`ot3`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` left join `test`.`ot3` on((`test`.`ot3`.`a` = `test`.`ot1`.`a`)) semi join (`test`.`it1`)) on(((`test`.`ot2`.`a` = `test`.`ot1`.`a`) and (`test`.`it1`.`a` = `test`.`ot1`.`a`))) where true +SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +1 NULL NULL +2 2 NULL +3 NULL NULL +4 4 NULL +5 NULL NULL +6 6 6 +7 NULL NULL +# More test cases +SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a+0) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it1); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 +JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a+0) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +6 6 6 +SELECT * +FROM ot1 +JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +6 6 6 +SELECT * +FROM ot1 +JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it1); +a a a +0 0 0 +6 6 6 +SELECT * +FROM ot1 +JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a+0) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +2 2 NULL +4 4 NULL +6 6 6 +SELECT * +FROM ot1 +JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +2 2 NULL +4 4 NULL +6 6 6 +SELECT * +FROM ot1 +JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it1); +a a a +0 0 0 +2 2 NULL +4 4 NULL +6 6 6 +SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a+0) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +1 NULL NULL +2 2 NULL +3 NULL NULL +4 4 NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +1 NULL NULL +2 2 NULL +3 NULL NULL +4 4 NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it1); +a a a +0 0 0 +1 NULL NULL +2 2 NULL +3 NULL NULL +4 4 NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1) +LEFT JOIN +ot1 AS ot4 +ON ot2.a=ot4.a; +a a a a +0 0 0 0 +1 NULL NULL NULL +2 2 NULL 2 +3 NULL NULL NULL +4 4 NULL 4 +5 NULL NULL NULL +6 6 6 6 +7 NULL NULL NULL +SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a +LEFT JOIN ot1 AS ot4 ON ot3.a=ot4.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a a +0 0 0 0 +1 NULL NULL NULL +2 2 NULL NULL +3 NULL NULL NULL +4 4 NULL NULL +5 NULL NULL NULL +6 6 6 6 +7 NULL NULL NULL +DROP TABLE ot1,ot2,ot3,it1,it2,it3; +CREATE TABLE t ( +a INTEGER DEFAULT NULL +) ENGINE=InnoDB; +INSERT INTO t VALUES (1); +CREATE TABLE t2 ( +a INTEGER DEFAULT NULL +) ENGINE=InnoDB; +INSERT INTO t2 VALUES (1),(1); +CREATE TABLE t4 ( +a INTEGER DEFAULT NULL +) ENGINE=InnoDB; +INSERT INTO t4 VALUES (1),(1); +CREATE TABLE v ( +a INTEGER DEFAULT NULL +) ENGINE=InnoDB; +INSERT INTO v VALUES (1),(1); +explain SELECT * +FROM t AS t1 +LEFT JOIN +(t2 +LEFT JOIN t AS t3 +ON t3.a IN (SELECT a FROM t AS it) +JOIN t4 +ON t4.a=100 +) +ON TRUE +WHERE t1.a IN (SELECT * FROM v AS it2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE it2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1); Using join buffer (hash join) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE it NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t3) +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t4`.`a` AS `a` from `test`.`t` `t1` left join (`test`.`t2` left join (`test`.`t` `t3` semi join (`test`.`t` `it`)) on(((`test`.`it`.`a` = `test`.`t3`.`a`))) join `test`.`t4`) on(((`test`.`t4`.`a` = 100))) semi join (`test`.`v` `it2`) where (`test`.`it2`.`a` = `test`.`t1`.`a`) +SELECT * +FROM t AS t1 +LEFT JOIN +(t2 +LEFT JOIN t AS t3 +ON t3.a IN (SELECT a FROM t AS it) +JOIN t4 +ON t4.a=100 +) +ON TRUE +WHERE t1.a IN (SELECT * FROM v AS it2); +a a a a +1 NULL NULL NULL +DROP TABLE t,t2,t4,v; +# End of WL#5561 +# +# Bug#48868: Left outer join in subquery causes segmentation fault in +# make_join_select. +# +CREATE TABLE t1 (i INTEGER); +INSERT INTO t1 VALUES (1); +INSERT INTO t1 VALUES (2); +CREATE TABLE t2 (i INTEGER); +INSERT INTO t2 VALUES(1); +CREATE TABLE t3 (i INTEGER); +INSERT INTO t3 VALUES (1); +INSERT INTO t3 VALUES (2); +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t2.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +1 +DROP TABLE t1, t2, t3; + +Bug#37899: Wrongly checked optimization prerequisite caused failed +assertion. + +CREATE TABLE t1 ( +`pk` int(11), +`varchar_nokey` varchar(5) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES +(1,'qk'),(2,'j'),(3,'aew'); +SELECT * +FROM t1 +WHERE varchar_nokey IN ( +SELECT +varchar_nokey +FROM +t1 +) XOR pk = 30; +pk varchar_nokey +1 qk +2 j +3 aew +drop table t1; +# +# BUG#41842: Semi-join materialization strategy crashes when the upper query has HAVING +# +CREATE TABLE t1 ( +pk int(11) NOT NULL AUTO_INCREMENT, +int_nokey int(11) NOT NULL, +time_key time NOT NULL, +datetime_key datetime NOT NULL, +datetime_nokey datetime NOT NULL, +varchar_key varchar(1) NOT NULL, +varchar_nokey varchar(1) NOT NULL, +PRIMARY KEY (pk), +KEY time_key (time_key), +KEY datetime_key (datetime_key), +KEY varchar_key (varchar_key) +) ENGINE=MyISaM; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES +(1,0, '00:16:10','2008-09-03 14:25:40','2008-09-03 14:25:40','h','h'), +(2,7, '00:00:00','2001-01-13 00:00:00','2001-01-13 00:00:00','',''), +(3,0, '00:00:00','0000-00-00 00:00:00','0000-00-00 00:00:00','x','x'), +(4,2, '16:29:24','2000-10-16 01:39:08','2000-10-16 01:39:08','w','w'), +(5,1, '09:23:32','0000-00-00 00:00:00','0000-00-00 00:00:00','p','p'), +(6,3, '00:00:00','2007-12-02 00:00:00','2007-12-02 00:00:00','o','o'), +(7,3, '00:00:00','2008-09-11 00:00:00','2008-09-11 00:00:00','',''), +(8,0, '13:59:04','0000-00-00 00:00:00','0000-00-00 00:00:00','s','s'), +(9,7, '09:01:06','0000-00-00 00:00:00','0000-00-00 00:00:00','d','d'), +(10,5,'00:00:00','0000-00-00 00:00:00','0000-00-00 00:00:00','n','n'), +(11,0,'21:06:46','0000-00-00 00:00:00','0000-00-00 00:00:00','o','o'), +(12,2,'00:00:00','0000-00-00 00:00:00','0000-00-00 00:00:00','',''), +(13,6,'14:45:34','2003-07-28 02:34:08','2003-07-28 02:34:08','w','w'), +(14,1,'15:04:12','0000-00-00 00:00:00','0000-00-00 00:00:00','o','o'), +(15,0,'00:00:00','0000-00-00 00:00:00','0000-00-00 00:00:00','x','x'), +(16,0,'15:55:23','2004-03-17 00:32:27','2004-03-17 00:32:27','p','p'), +(17,1,'16:30:00','2004-12-27 19:20:00','2004-12-27 19:20:00','d','d'), +(18,0,'00:00:00','0000-00-00 00:00:00','0000-00-00 00:00:00','h','h'), +(19,0,'14:13:26','2008-11-09 05:53:48','2008-11-09 05:53:48','o','o'), +(20,0,'00:00:00','2009-10-11 06:58:04','2009-10-11 06:58:04','k','k'); +Warnings: +Warning 1264 Out of range value for column 'datetime_key' at row 3 +Warning 1264 Out of range value for column 'datetime_nokey' at row 3 +Warning 1264 Out of range value for column 'datetime_key' at row 5 +Warning 1264 Out of range value for column 'datetime_nokey' at row 5 +Warning 1264 Out of range value for column 'datetime_key' at row 8 +Warning 1264 Out of range value for column 'datetime_nokey' at row 8 +Warning 1264 Out of range value for column 'datetime_key' at row 9 +Warning 1264 Out of range value for column 'datetime_nokey' at row 9 +Warning 1264 Out of range value for column 'datetime_key' at row 10 +Warning 1264 Out of range value for column 'datetime_nokey' at row 10 +Warning 1264 Out of range value for column 'datetime_key' at row 11 +Warning 1264 Out of range value for column 'datetime_nokey' at row 11 +Warning 1264 Out of range value for column 'datetime_key' at row 12 +Warning 1264 Out of range value for column 'datetime_nokey' at row 12 +Warning 1264 Out of range value for column 'datetime_key' at row 14 +Warning 1264 Out of range value for column 'datetime_nokey' at row 14 +Warning 1264 Out of range value for column 'datetime_key' at row 15 +Warning 1264 Out of range value for column 'datetime_nokey' at row 15 +Warning 1264 Out of range value for column 'datetime_key' at row 18 +Warning 1264 Out of range value for column 'datetime_nokey' at row 18 +CREATE TABLE t2 ( +pk int(11) NOT NULL AUTO_INCREMENT, +int_nokey int(11) NOT NULL, +time_key time NOT NULL, +datetime_key datetime NOT NULL, +datetime_nokey datetime NOT NULL, +varchar_key varchar(1) NOT NULL, +varchar_nokey varchar(1) NOT NULL, +PRIMARY KEY (pk), +KEY time_key (time_key), +KEY datetime_key (datetime_key), +KEY varchar_key (varchar_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT IGNORE INTO t2 VALUES +(10,0,'19:39:13','0000-00-00 00:00:00','0000-00-00 00:00:00','g','g'), +(11,8,'03:43:53','0000-00-00 00:00:00','0000-00-00 00:00:00','b','b'); +Warnings: +Warning 1264 Out of range value for column 'datetime_key' at row 1 +Warning 1264 Out of range value for column 'datetime_nokey' at row 1 +Warning 1264 Out of range value for column 'datetime_key' at row 2 +Warning 1264 Out of range value for column 'datetime_nokey' at row 2 +SELECT OUTR.datetime_nokey AS X FROM t1 AS OUTR +WHERE +OUTR.varchar_nokey IN (SELECT +INNR . varchar_nokey AS Y +FROM t2 AS INNR +WHERE +INNR . datetime_key >= INNR . time_key OR +INNR . pk = INNR . int_nokey +) +AND OUTR . varchar_nokey <= 'w' +HAVING X > '2012-12-12'; +X +drop table t1, t2; + +Bug#46797 "Crash in fix_semijoin_strategies_for_picked_join_order +with semijoin=on" + +CREATE TABLE t1 ( +varchar_key varchar(1) DEFAULT NULL, +KEY varchar_key (varchar_key) +); +CREATE TABLE t2 ( +varchar_key varchar(1) DEFAULT NULL, +KEY varchar_key (varchar_key) +); +INSERT INTO t2 VALUES +(NULL),(NULL),(NULL),(NULL),('a'),('a'),('a'),('b'),('b'),('b'),('b'),('c'), +('c'),('c'),('c'),('c'),('c'),('c'),('d'),('d'),('d'),('d'),('d'),('d'),('e'), +('e'),('e'),('e'),('e'),('e'),('f'),('f'),('f'),('g'),('g'),('h'),('h'),('h'), +('h'),('i'),('j'),('j'),('j'),('k'),('k'),('l'),('l'),('m'),('m'),('m'),('m'), +('n'),('n'),('n'),('o'),('o'),('o'),('p'),('p'),('p'),('q'),('q'),('q'),('r'), +('r'),('r'),('r'),('s'),('s'),('s'),('s'),('t'),('t'),('t'),('t'),('u'),('u'), +('u'),('u'),('v'),('v'),('v'),('v'),('w'),('w'),('w'),('w'),('w'),('w'),('x'), +('x'),('x'),('y'),('y'),('y'),('y'),('z'),('z'),('z'),('z'); +CREATE TABLE t3 ( +varchar_key varchar(1) DEFAULT NULL, +KEY varchar_key (varchar_key) +) ENGINE=MyISAM DEFAULT CHARSET=latin1; +INSERT INTO t3 VALUES +(NULL),('c'),('d'),('e'),('f'),('h'),('j'),('k'),('k'),('m'),('m'),('m'), +('n'),('o'),('r'),('t'),('t'),('u'),('w'),('y'); +SELECT varchar_key FROM t3 +WHERE (SELECT varchar_key FROM t3 +WHERE (varchar_key,varchar_key) +IN (SELECT t1.varchar_key, t2 .varchar_key +FROM t1 RIGHT JOIN t2 ON t1.varchar_key +) +); +varchar_key +DROP TABLE t1, t2, t3; +# +# Bug#46556 Returning incorrect, empty results for some IN subqueries +# w/semijoin=on +# +CREATE TABLE t0 ( +pk INTEGER, +vkey VARCHAR(1), +vnokey VARCHAR(1), +PRIMARY KEY (pk), +KEY vkey(vkey) +) charset utf8mb4; +INSERT INTO t0 +VALUES (1,'g','g'), (2,'v','v'), (3,'t','t'), (4,'u','u'), (5,'n','n'); +EXPLAIN SELECT vkey FROM t0 WHERE pk IN +(SELECT t1.pk FROM t0 t1 JOIN t0 t2 ON t2.vkey = t1.vnokey); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL ALL PRIMARY NULL NULL NULL 5 100.00 NULL +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t0.pk 1 100.00 Using where +1 SIMPLE t2 NULL ref vkey vkey 7 test.t1.vnokey 2 100.00 Using index; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`vkey` AS `vkey` from `test`.`t0` `t1` join `test`.`t0` semi join (`test`.`t0` `t2`) where ((`test`.`t2`.`vkey` = `test`.`t1`.`vnokey`) and (`test`.`t1`.`pk` = `test`.`t0`.`pk`)) +SELECT vkey FROM t0 WHERE pk IN +(SELECT t1.pk FROM t0 t1 JOIN t0 t2 ON t2.vkey = t1.vnokey); +vkey +g +n +t +u +v +DROP TABLE t0; +# End of bug#46556 + +Bug#48834: Procedure with view + subquery + semijoin=on +crashes on second call. + +CREATE TABLE t1 ( t1field integer, primary key (t1field)); +CREATE TABLE t2 ( t2field integer, primary key (t2field)); +CREATE VIEW v1 AS +SELECT t1field as v1field +FROM t1 A +WHERE A.t1field IN (SELECT t1field FROM t2 ); +CREATE VIEW v2 AS +SELECT t2field as v2field +FROM t2 A +WHERE A.t2field IN (SELECT t2field FROM t2 ); +CREATE PROCEDURE p1 () +BEGIN +SELECT v1field +FROM v1 +WHERE v1field IN ( SELECT v2field as vf_inner FROM v2 ); +END| +INSERT INTO t1 VALUES (1),(2),(3); +INSERT INTO t2 VALUES (2),(3),(4); +CALL p1; +v1field +2 +3 +CALL p1; +v1field +2 +3 +DROP TABLE t1,t2; +DROP VIEW v1,v2; +DROP PROCEDURE p1; +# End of BUG#48834 +# +# Bug#46692 "Crash occurring on queries with nested FROM subqueries +# using materialization." +# +CREATE TABLE t1 ( +pk INTEGER PRIMARY KEY, +int_key INTEGER, +KEY int_key(int_key) +); +INSERT INTO t1 VALUES (10,186),(11,NULL),(12,2),(13,3),(14,0),(15,133),(16,1); +CREATE TABLE t2 ( +pk INTEGER PRIMARY KEY, +int_key INTEGER, +KEY int_key(int_key) +); +INSERT INTO t2 VALUES (1,7),(2,2); +SELECT * FROM t1 WHERE (140, 4) IN +(SELECT t2.int_key, t2 .pk FROM t2 STRAIGHT_JOIN t1 ON t2.int_key); +pk int_key +DROP TABLE t1, t2; +# +# Bug#42353 "SELECT ... WHERE oe IN (SELECT w/ LEFT JOIN) query +# causes crash." +# +CREATE TABLE t1 ( +pk INTEGER PRIMARY KEY, +int_nokey INTEGER, +int_key INTEGER, +date_key DATE, +datetime_nokey DATETIME, +varchar_nokey VARCHAR(1) +); +CREATE TABLE t2 ( +date_nokey DATE +); +CREATE TABLE t3 ( +pk INTEGER PRIMARY KEY, +int_nokey INTEGER, +date_key date, +varchar_key VARCHAR(1), +varchar_nokey VARCHAR(1), +KEY date_key (date_key) +); +SELECT date_key FROM t1 +WHERE (int_key, int_nokey) +IN (SELECT t3.int_nokey, t3.pk +FROM t2 LEFT JOIN t3 ON (t2.date_nokey < t3.date_key) +WHERE t3.varchar_key <= t3.varchar_nokey OR t3.int_nokey <= t3.pk +) +AND (varchar_nokey <> 'f' OR NOT int_key < 7); +date_key +# +# Bug#45933 "Crash in optimize_semijoin_nests on JOIN in subquery +# + AND in outer query". +# +INSERT INTO t1 VALUES (10,7,5,'2009-06-16','2002-04-10 14:25:30','w'), +(11,7,0,'0000-00-00','0000-00-00 00:00:00','s'), +(12,4,0,'2003-07-14','2006-09-14 04:01:02','y'), +(13,0,4,'2002-07-25','0000-00-00 00:00:00','c'), +(14,1,8,'2007-07-03','0000-00-00 00:00:00','q'), +(15,6,5,'2001-11-12','0000-00-00 00:00:00',''), +(16,2,9,'0000-00-00','0000-00-00 00:00:00','j'), +(29,9,1,'0000-00-00','2003-08-11 00:00:00','m'); +Warnings: +Warning 1264 Out of range value for column 'date_key' at row 2 +Warning 1264 Out of range value for column 'datetime_nokey' at row 2 +Warning 1264 Out of range value for column 'datetime_nokey' at row 4 +Warning 1264 Out of range value for column 'datetime_nokey' at row 5 +Warning 1264 Out of range value for column 'datetime_nokey' at row 6 +Warning 1264 Out of range value for column 'date_key' at row 7 +Warning 1264 Out of range value for column 'datetime_nokey' at row 7 +Warning 1264 Out of range value for column 'date_key' at row 8 +INSERT IGNORE INTO t3 VALUES (1,9,'0000-00-00','b','b'), +(2,2,'2002-09-17','h','h'); +Warnings: +Warning 1264 Out of range value for column 'date_key' at row 1 +SELECT t1.varchar_nokey FROM t1 JOIN t3 ON t1.datetime_nokey +WHERE t1.varchar_nokey +IN (SELECT varchar_nokey FROM t1 +WHERE (pk) +IN (SELECT t3.int_nokey +FROM t3 LEFT JOIN t1 ON t1.varchar_nokey +WHERE t3.date_key BETWEEN '2008-06-07' AND '2006-06-26' + ) +); +varchar_nokey +DROP TABLE t1, t2, t3; +# +# Bug#45219 "Crash on SELECT DISTINCT query containing a +# LEFT JOIN in subquery" +# +CREATE TABLE t1 ( +pk INTEGER NOT NULL, +int_nokey INTEGER NOT NULL, +datetime_key DATETIME NOT NULL, +varchar_key VARCHAR(1) NOT NULL, +PRIMARY KEY (pk), +KEY datetime_key (datetime_key), +KEY varchar_key (varchar_key) +); +INSERT IGNORE INTO t1 VALUES +(1,9,'0000-00-00 00:00:00','p'),(2,0,'2002-02-09 07:38:13','v'), +(3,8,'2001-05-03 12:08:14','t'),(4,3,'0000-00-00 00:00:00','u'), +(5,7,'2009-07-28 03:43:30','n'),(6,0,'2009-08-04 00:00:00','l'), +(7,1,'0000-00-00 00:00:00','h'),(8,9,'0000-00-00 00:00:00','u'), +(9,0,'2005-08-02 17:16:54','n'),(10,9,'2002-12-21 00:00:00','j'), +(11,0,'2005-08-15 12:37:35','k'),(12,5,'0000-00-00 00:00:00','e'), +(13,0,'2006-03-10 00:00:00','i'),(14,8,'2005-05-16 11:02:36','u'), +(15,8,'2008-11-02 00:00:00','n'),(16,5,'2006-03-15 00:00:00','b'), +(17,1,'0000-00-00 00:00:00','x'),(18,7,'0000-00-00 00:00:00',''), +(19,0,'2008-12-17 20:15:40','q'),(20,9,'0000-00-00 00:00:00','u'); +Warnings: +Warning 1264 Out of range value for column 'datetime_key' at row 1 +Warning 1264 Out of range value for column 'datetime_key' at row 4 +Warning 1264 Out of range value for column 'datetime_key' at row 7 +Warning 1264 Out of range value for column 'datetime_key' at row 8 +Warning 1264 Out of range value for column 'datetime_key' at row 12 +Warning 1264 Out of range value for column 'datetime_key' at row 17 +Warning 1264 Out of range value for column 'datetime_key' at row 18 +Warning 1264 Out of range value for column 'datetime_key' at row 20 +CREATE TABLE t2 LIKE t1; +INSERT INTO t2 VALUES +(10,0,'2006-07-07 07:26:28','q'),(11,5,'2002-09-23 00:00:00','m'), +(12,7,'0000-00-00 00:00:00','j'),(13,1,'2006-06-07 00:00:00','z'), +(14,8,'2000-09-16 12:15:34','a'),(15,2,'2007-08-05 15:47:52',''), +(16,1,'0000-00-00 00:00:00','e'),(17,8,'2005-12-02 19:34:26','t'), +(18,5,'0000-00-00 00:00:00','q'),(19,4,'0000-00-00 00:00:00','b'), +(20,5,'2007-12-28 00:00:00','w'),(21,3,'2004-08-02 11:48:43','m'), +(22,0,'0000-00-00 00:00:00','x'),(23,8,'2004-04-19 12:18:43',''), +(24,0,'2009-04-27 00:00:00','w'),(25,4,'2006-10-20 14:52:15','x'), +(26,0,'0000-00-00 00:00:00','e'),(27,0,'2002-03-22 11:48:37','e'), +(28,2,'0000-00-00 00:00:00','p'),(29,0,'2001-01-04 03:55:07','x'); +Warnings: +Warning 1264 Out of range value for column 'datetime_key' at row 3 +Warning 1264 Out of range value for column 'datetime_key' at row 7 +Warning 1264 Out of range value for column 'datetime_key' at row 9 +Warning 1264 Out of range value for column 'datetime_key' at row 10 +Warning 1264 Out of range value for column 'datetime_key' at row 13 +Warning 1264 Out of range value for column 'datetime_key' at row 17 +Warning 1264 Out of range value for column 'datetime_key' at row 19 +CREATE TABLE t3 LIKE t1; +INSERT INTO t3 VALUES +(10,8,'2007-08-19 08:08:38','i'),(11,0,'2000-05-21 03:51:51',''); +SELECT DISTINCT datetime_key FROM t1 +WHERE (int_nokey, pk) +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#46550 Azalea returning duplicate results for some IN subqueries +# w/ semijoin=on +# +DROP TABLE IF EXISTS t0, t1, t2; +CREATE TABLE t0 ( +int_key int(11) DEFAULT NULL, +varchar_key varchar(1) DEFAULT NULL, +varchar_nokey varchar(1) DEFAULT NULL, +KEY int_key (int_key), +KEY varchar_key (varchar_key,int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t0 VALUES +(1,'m','m'), +(40,'h','h'), +(1,'r','r'), +(1,'h','h'), +(9,'x','x'), +(NULL,'q','q'), +(NULL,'k','k'), +(7,'l','l'), +(182,'k','k'), +(202,'a','a'), +(7,'x','x'), +(6,'j','j'), +(119,'z','z'), +(4,'d','d'), +(5,'h','h'), +(1,'u','u'), +(3,'q','q'), +(7,'a','a'), +(3,'e','e'), +(6,'l','l'); +CREATE TABLE t1 ( +int_key int(11) DEFAULT NULL, +varchar_key varchar(1) DEFAULT NULL, +varchar_nokey varchar(1) DEFAULT NULL, +KEY int_key (int_key), +KEY varchar_key (varchar_key,int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (7,NULL,NULL),(4,'x','x'); +CREATE TABLE t2 ( +int_key int(11) DEFAULT NULL, +varchar_key varchar(1) DEFAULT NULL, +varchar_nokey varchar(1) DEFAULT NULL, +KEY int_key (int_key), +KEY varchar_key (varchar_key,int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (123,NULL,NULL); +SELECT int_key +FROM t0 +WHERE varchar_nokey IN ( +SELECT t1 .varchar_key from t1 +); +int_key +7 +9 +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 +7 +9 +EXPLAIN +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 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 20 100.00 Using where +1 SIMPLE t1_1 NULL ref varchar_key varchar_key 7 test.t0.varchar_nokey 2 50.00 Using where; Using index +1 SIMPLE t1_2 NULL index NULL int_key 5 NULL 2 100.00 Using index; FirstMatch(t0) +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`int_key` AS `int_key` from `test`.`t0` semi join (`test`.`t1` `t1_1` join `test`.`t1` `t1_2`) where ((`test`.`t1_1`.`varchar_key` = `test`.`t0`.`varchar_nokey`) and (0 <> `test`.`t1_1`.`int_key`)) +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 +7 +9 +EXPLAIN +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 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 20 100.00 Using where +1 SIMPLE t1_1 NULL ref varchar_key varchar_key 7 test.t0.varchar_nokey 2 50.00 Using where; Using index +1 SIMPLE t1_2 NULL index NULL int_key 5 NULL 2 100.00 Using index; FirstMatch(t0) +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`int_key` AS `int_key` from `test`.`t0` semi join (`test`.`t1` `t1_1` join `test`.`t1` `t1_2`) where ((`test`.`t1_1`.`varchar_key` = `test`.`t0`.`varchar_nokey`) and (0 <> `test`.`t1_1`.`int_key`)) +DROP TABLE t0, t1, t2; +# End of bug#46550 + +Bug #48073 Subquery on char columns from view crashes Mysql + +DROP TABLE IF EXISTS t1, t2; +DROP VIEW IF EXISTS v1; +CREATE TABLE t1 ( +city VARCHAR(50) NOT NULL, +country_id SMALLINT UNSIGNED NOT NULL +); +INSERT INTO t1 VALUES +('Batna',2), +('Bchar',2), +('Skikda',2), +('Tafuna',3), +('Algeria',2) ; +CREATE TABLE t2 ( +country_id SMALLINT UNSIGNED NOT NULL, +country VARCHAR(50) NOT NULL +); +INSERT INTO t2 VALUES +(2,'Algeria'), +(3,'American Samoa') ; +CREATE VIEW v1 AS +SELECT country_id, country +FROM t2 +WHERE LEFT(country,1) = "A" +; +SELECT city, country_id +FROM t1 +WHERE city IN ( +SELECT country +FROM t2 +WHERE LEFT(country, 1) = "A" +); +city country_id +Algeria 2 +SELECT city, country_id +FROM t1 +WHERE city IN ( +SELECT country +FROM v1 +); +city country_id +Algeria 2 +drop table t1, t2; +drop view v1; +# End of bug#48073 + +Bug#49097 subquery with view generates wrong result with +non-prepared statement + +DROP TABLE IF EXISTS t1, t2; +DROP VIEW IF EXISTS v1; +CREATE TABLE t1 ( +city VARCHAR(50) NOT NULL, +country_id SMALLINT UNSIGNED NOT NULL +); +INSERT INTO t1 VALUES +('Batna',2), +('Bchar',2), +('Skikda',2), +('Tafuna',3), +('Algeria',2) ; +CREATE TABLE t2 ( +country_id SMALLINT UNSIGNED NOT NULL, +country VARCHAR(50) NOT NULL +); +INSERT INTO t2 VALUES +(2,'Algeria'), +(3,'XAmerican Samoa') ; +CREATE VIEW v1 AS +SELECT country_id, country +FROM t2 +WHERE LEFT(country,1) = "A" +; +SELECT city, country_id +FROM t1 +WHERE country_id IN ( +SELECT country_id +FROM t2 +WHERE LEFT(country,1) = "A" +); +city country_id +Algeria 2 +Batna 2 +Bchar 2 +Skikda 2 +SELECT city, country_id +FROM t1 +WHERE country_id IN ( +SELECT country_id +FROM v1 +); +city country_id +Algeria 2 +Batna 2 +Bchar 2 +Skikda 2 +PREPARE stmt FROM +" +SELECT city, country_id +FROM t1 +WHERE country_id IN ( + SELECT country_id + FROM v1 +); +"; +execute stmt; +city country_id +Algeria 2 +Batna 2 +Bchar 2 +Skikda 2 +deallocate prepare stmt; +drop table t1, t2; +drop view v1; +# End of Bug#49097 +# +# Bug#49198 Wrong result for second call of procedure +# with view in subselect. +# +CREATE TABLE t1 (t1field integer, primary key (t1field)); +CREATE TABLE t2 (t2field integer, primary key (t2field)); +CREATE TABLE t3 (t3field integer, primary key (t3field)); +CREATE VIEW v2 AS SELECT * FROM t2; +CREATE VIEW v3 AS SELECT * FROM t3; +INSERT INTO t1 VALUES(1),(2); +INSERT INTO t2 VALUES(1),(2); +INSERT INTO t3 VALUES(1),(2); +PREPARE stmt FROM +" +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT * FROM v2); +"; +EXECUTE stmt; +t1field +1 +2 + +EXECUTE stmt; +t1field +1 +2 +PREPARE stmt FROM +" +EXPLAIN +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT * FROM v2) + AND t1field IN (SELECT * FROM v3) +"; +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index PRIMARY PRIMARY 4 NULL 2 100.00 Using index +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +1 SIMPLE t3 NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`t1field` AS `t1field` from `test`.`t2` join `test`.`t3` join `test`.`t1` where ((`test`.`t2`.`t2field` = `test`.`t1`.`t1field`) and (`test`.`t3`.`t3field` = `test`.`t1`.`t1field`)) + +This line is only in place to help --skip_if_hypergraph diffing some more. + +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index PRIMARY PRIMARY 4 NULL 2 100.00 Using index +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +1 SIMPLE t3 NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`t1field` AS `t1field` from `test`.`t2` join `test`.`t3` join `test`.`t1` where ((`test`.`t2`.`t2field` = `test`.`t1`.`t1field`) and (`test`.`t3`.`t3field` = `test`.`t1`.`t1field`)) +DROP TABLE t1, t2, t3; +DROP VIEW v2, v3; +# End of Bug#49198 +# +# Bug#48623 Multiple subqueries are optimized incorrectly +# +CREATE TABLE ot(val VARCHAR(10)) charset utf8mb4; +CREATE TABLE it1(val VARCHAR(10)) charset utf8mb4; +CREATE TABLE it2(val VARCHAR(10)) charset utf8mb4; +INSERT INTO ot VALUES('aaa'), ('bbb'), ('eee'), ('mmm'), ('ppp'); +INSERT INTO it1 VALUES('aaa'), ('aaa'), ('bbb'), ('eee'), ('mmm'), ('ppp'); +INSERT INTO it2 VALUES('aaa'), ('bbb'), ('eee'), ('mmm'), ('ppp'); +EXPLAIN +SELECT * +FROM ot +WHERE ot.val IN (SELECT it1.val FROM it1 +WHERE it1.val LIKE 'a%' OR it1.val LIKE 'e%') +AND ot.val IN (SELECT it2.val FROM it2 +WHERE it2.val LIKE 'a%' OR it2.val LIKE 'e%'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 5 100.00 NULL +1 SIMPLE it2 NULL ALL NULL NULL NULL NULL 5 20.00 Using where; FirstMatch(ot); Using join buffer (hash join) +1 SIMPLE it1 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; FirstMatch(it2); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot`.`val` AS `val` from `test`.`ot` semi join (`test`.`it1`) semi join (`test`.`it2`) where ((`test`.`it2`.`val` = `test`.`ot`.`val`) and (`test`.`it1`.`val` = `test`.`ot`.`val`) and ((`test`.`it1`.`val` like 'a%') or (`test`.`it1`.`val` like 'e%')) and ((`test`.`it2`.`val` like 'a%') or (`test`.`it2`.`val` like 'e%'))) +SELECT * +FROM ot +WHERE ot.val IN (SELECT it1.val FROM it1 +WHERE it1.val LIKE 'a%' OR it1.val LIKE 'e%') +AND ot.val IN (SELECT it2.val FROM it2 +WHERE it2.val LIKE 'a%' OR it2.val LIKE 'e%'); +val +aaa +eee +DROP TABLE ot; +DROP TABLE it1; +DROP TABLE it2; +# End of Bug#48623 +# +# Bug #51487 Assertion failure when semi-join flattening occurs +# for a subquery in HAVING +# +CREATE TABLE t1 (a INT, b INT); +INSERT INTO t1 VALUES (1,10),(2,11),(1,13); +CREATE TABLE t2 AS SELECT * FROM t1; +CREATE TABLE t3 AS SELECT * FROM t1; +SELECT COUNT(*) FROM t1 +GROUP BY t1.a +HAVING t1.a IN (SELECT t3.a FROM t3 +WHERE t3.b IN (SELECT b FROM t2 WHERE t2.a=t1.a)); +COUNT(*) +2 +1 +DROP TABLE t1, t2, t3; +# End of Bug#51487 +# +# BUG#38075: Wrong result: rows matching a subquery with outer join not returned +# +DROP TABLE IF EXISTS ot1, it1, it2; +CREATE TABLE it2 ( +int_key int(11) NOT NULL, +datetime_key datetime NOT NULL, +KEY int_key (int_key), +KEY datetime_key (datetime_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO it2 VALUES +(5,'2002-04-10 14:25:30'), (0,'0000-00-00 00:00:00'), +(0,'2006-09-14 04:01:02'), (4,'0000-00-00 00:00:00'), +(8,'0000-00-00 00:00:00'), (5,'0000-00-00 00:00:00'), +(9,'0000-00-00 00:00:00'), (8,'2007-04-01 11:04:17'), +(1,'0000-00-00 00:00:00'), (7,'2009-01-12 00:00:00'), +(0,'2009-06-05 00:00:00'), (3,'2006-02-14 18:06:35'), +(5,'2006-02-21 07:08:16'), (0,'0000-00-00 00:00:00'), +(7,'0000-00-00 00:00:00'), (0,'0000-00-00 00:00:00'), +(0,'2007-02-13 00:00:00'), (1,'0000-00-00 00:00:00'), +(0,'0000-00-00 00:00:00'), (1,'2003-08-11 00:00:00'); +Warnings: +Warning 1264 Out of range value for column 'datetime_key' at row 2 +Warning 1264 Out of range value for column 'datetime_key' at row 4 +Warning 1264 Out of range value for column 'datetime_key' at row 5 +Warning 1264 Out of range value for column 'datetime_key' at row 6 +Warning 1264 Out of range value for column 'datetime_key' at row 7 +Warning 1264 Out of range value for column 'datetime_key' at row 9 +Warning 1264 Out of range value for column 'datetime_key' at row 14 +Warning 1264 Out of range value for column 'datetime_key' at row 15 +Warning 1264 Out of range value for column 'datetime_key' at row 16 +Warning 1264 Out of range value for column 'datetime_key' at row 18 +Warning 1264 Out of range value for column 'datetime_key' at row 19 +CREATE TABLE ot1 ( +int_nokey int(11) NOT NULL, +int_key int(11) NOT NULL, +KEY int_key (int_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO ot1 VALUES +(5,0), (3,0), (0,2), (3,0), (1,3), (0,0), (1,7), (7,0), (1,7), (0,7), +(0,9), (8,2), (4,4), (9,3), (0,9), (2,5), (0,5), (8,0), (5,8), (1,5); +CREATE TABLE it1 ( +int_nokey int(11) NOT NULL, +int_key int(11) NOT NULL, +KEY int_key (int_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO it1 VALUES +(9,5), (0,4); +SELECT int_key FROM ot1 +WHERE int_nokey IN (SELECT it2.int_key +FROM it1 LEFT JOIN it2 ON it2.datetime_key); +int_key +0 +0 +0 +0 +0 +0 +2 +2 +3 +5 +5 +7 +7 +7 +8 +9 +9 +EXPLAIN +SELECT int_key FROM ot1 +WHERE int_nokey IN (SELECT it2.int_key +FROM it1 LEFT JOIN it2 ON it2.datetime_key); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 20 100.00 NULL +1 SIMPLE it1 NULL index NULL int_key 4 NULL 2 100.00 Using index +1 SIMPLE it2 NULL ref int_key int_key 4 test.ot1.int_nokey 2 90.00 Using where; FirstMatch(ot1) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`int_key` AS `int_key` from `test`.`ot1` semi join (`test`.`it1` join `test`.`it2`) where ((`test`.`it2`.`int_key` = `test`.`ot1`.`int_nokey`) and (TIMESTAMP'0000-00-00 00:00:00' <> `test`.`it2`.`datetime_key`)) +DROP TABLE ot1, it1, it2; +# End of BUG#38075 +# +# BUG#50089: Second call of procedure with view in subselect crashes server +# +CREATE TABLE t1(t1field INTEGER, PRIMARY KEY(t1field)); +CREATE VIEW v1 AS +SELECT t1field AS v1field +FROM t1 a +WHERE a.t1field IN (SELECT t1field FROM t1); +INSERT INTO t1 VALUES(1),(2); +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT v1field FROM v1); +t1field +1 +2 +EXPLAIN +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT v1field FROM v1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index PRIMARY PRIMARY 4 NULL 2 100.00 Using index +1 SIMPLE a NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `t1`.`t1field` AS `t1field` from `test`.`t1` `a` join `test`.`t1` join `test`.`t1` where ((`test`.`a`.`t1field` = `t1`.`t1field`) and (`test`.`t1`.`t1field` = `t1`.`t1field`)) +SELECT t1.t1field +FROM t1 LEFT JOIN t1 AS t2 ON t1.t1field IN (SELECT v1field FROM v1); +t1field +1 +1 +2 +2 +EXPLAIN +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT v1field FROM v1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index PRIMARY PRIMARY 4 NULL 2 100.00 Using index +1 SIMPLE a NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `t1`.`t1field` AS `t1field` from `test`.`t1` `a` join `test`.`t1` join `test`.`t1` where ((`test`.`a`.`t1field` = `t1`.`t1field`) and (`test`.`t1`.`t1field` = `t1`.`t1field`)) +CREATE PROCEDURE p1() +BEGIN +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT v1field FROM v1); +END| +CALL p1; +t1field +1 +2 +CALL p1; +t1field +1 +2 +PREPARE stmt FROM +" +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT v1field FROM v1); +"; +EXECUTE stmt; +t1field +1 +2 + +EXECUTE stmt; +t1field +1 +2 +DROP PROCEDURE p1; +DROP VIEW v1; +DROP TABLE t1; +# End of BUG#50089 +# +# Bug#45191: Incorrectly initialized semi-join led to a wrong result. +# +CREATE TABLE staff (EMPNUM CHAR(3) NOT NULL, +EMPNAME CHAR(20), GRADE DECIMAL(4), CITY CHAR(15)) charset latin1; +CREATE TABLE proj (PNUM CHAR(3) NOT NULL, +PNAME CHAR(20), PTYPE CHAR(6), +BUDGET DECIMAL(9), +CITY CHAR(15)) charset latin1; +CREATE TABLE works (EMPNUM CHAR(3) NOT NULL, +PNUM CHAR(3) NOT NULL, HOURS DECIMAL(5)) charset latin1; +INSERT INTO staff VALUES ('E1','Alice',12,'Deale'); +INSERT INTO staff VALUES ('E2','Betty',10,'Vienna'); +INSERT INTO staff VALUES ('E3','Carmen',13,'Vienna'); +INSERT INTO staff VALUES ('E4','Don',12,'Deale'); +INSERT INTO staff VALUES ('E5','Ed',13,'Akron'); +INSERT INTO proj VALUES ('P1','MXSS','Design',10000,'Deale'); +INSERT INTO proj VALUES ('P2','CALM','Code',30000,'Vienna'); +INSERT INTO proj VALUES ('P3','SDP','Test',30000,'Tampa'); +INSERT INTO proj VALUES ('P4','SDP','Design',20000,'Deale'); +INSERT INTO proj VALUES ('P5','IRM','Test',10000,'Vienna'); +INSERT INTO proj VALUES ('P6','PAYR','Design',50000,'Deale'); +INSERT INTO works VALUES ('E1','P1',40); +INSERT INTO works VALUES ('E1','P2',20); +INSERT INTO works VALUES ('E1','P3',80); +INSERT INTO works VALUES ('E1','P4',20); +INSERT INTO works VALUES ('E1','P5',12); +INSERT INTO works VALUES ('E1','P6',12); +INSERT INTO works VALUES ('E2','P1',40); +INSERT INTO works VALUES ('E2','P2',80); +INSERT INTO works VALUES ('E3','P2',20); +INSERT INTO works VALUES ('E4','P2',20); +INSERT INTO works VALUES ('E4','P4',40); +INSERT INTO works VALUES ('E4','P5',80); +explain SELECT EMPNUM, EMPNAME +FROM staff +WHERE EMPNUM IN +(SELECT EMPNUM FROM works +WHERE PNUM IN +(SELECT PNUM FROM proj)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE staff NULL ALL NULL NULL NULL NULL 5 100.00 NULL +1 SIMPLE works NULL ALL NULL NULL NULL NULL 12 10.00 Using where +1 SIMPLE proj NULL ALL NULL NULL NULL NULL 6 16.67 Using where; FirstMatch(staff) +Warnings: +Note 1003 /* select#1 */ select `test`.`staff`.`EMPNUM` AS `EMPNUM`,`test`.`staff`.`EMPNAME` AS `EMPNAME` from `test`.`staff` semi join (`test`.`works` join `test`.`proj`) where ((`test`.`works`.`EMPNUM` = `test`.`staff`.`EMPNUM`) and (`test`.`proj`.`PNUM` = `test`.`works`.`PNUM`)) +SELECT EMPNUM, EMPNAME +FROM staff +WHERE EMPNUM IN +(SELECT EMPNUM FROM works +WHERE PNUM IN +(SELECT PNUM FROM proj)); +EMPNUM EMPNAME +E1 Alice +E2 Betty +E3 Carmen +E4 Don +drop table staff,works,proj; +# End of bug#45191 +# +# BUG#36896: Server crash on SELECT FROM DUAL +# +create table t1 (a int); +select 1 as res from dual where (1) in (select * from t1); +res +drop table t1; + +BUG#40118 Crash when running Batched Key Access and requiring one match for each key + +create table t0(a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (a int, key(a)); +insert into t1 select * from t0; +alter table t1 add b int not null, add filler char(200); +insert into t1 select * from t1; +insert into t1 select * from t1; +select * from t0 where t0.a in (select t1.a from t1 where t1.b=0); +a +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +drop table t0, t1; +# +# BUG#32665 Query with dependent subquery is too slow +# +create table t1 ( +idIndividual int primary key +); +insert into t1 values (1),(2); +create table t2 ( +idContact int primary key, +contactType int, +idObj int +); +insert into t2 values (1,1,1),(2,2,2),(3,3,3); +create table t3 ( +idAddress int primary key, +idContact int, +postalStripped varchar(100) +); +insert into t3 values (1,1, 'foo'), (2,2,'bar'); +The following must be converted to a semi-join: +explain SELECT a.idIndividual FROM t1 a +WHERE a.idIndividual IN +( SELECT c.idObj FROM t3 cona +INNER JOIN t2 c ON c.idContact=cona.idContact +WHERE cona.postalStripped='T2H3B2' + ); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE a NULL index PRIMARY PRIMARY 4 NULL 2 100.00 Using index +1 SIMPLE cona NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE c NULL eq_ref PRIMARY PRIMARY 4 test.cona.idContact 1 33.33 Using where; FirstMatch(a) +Warnings: +Note 1003 /* select#1 */ select `test`.`a`.`idIndividual` AS `idIndividual` from `test`.`t1` `a` semi join (`test`.`t3` `cona` join `test`.`t2` `c`) where ((`test`.`c`.`idContact` = `test`.`cona`.`idContact`) and (`test`.`c`.`idObj` = `test`.`a`.`idIndividual`) and (`test`.`cona`.`postalStripped` = 'T2H3B2')) +drop table t1,t2,t3; +CREATE TABLE t1 (one int, two int, flag char(1)); +CREATE TABLE t2 (one int, two int, flag char(1)); +INSERT INTO t1 VALUES(1,2,'Y'),(2,3,'Y'),(3,4,'Y'),(5,6,'N'),(7,8,'N'); +INSERT INTO t2 VALUES(1,2,'Y'),(2,3,'Y'),(3,4,'Y'),(5,6,'N'),(7,8,'N'); +SELECT * FROM t1 +WHERE ROW(one,two) IN (SELECT DISTINCT one,two FROM t2 WHERE flag = 'N'); +one two flag +5 6 N +7 8 N +SELECT * FROM t1 +WHERE ROW(one,two) IN (SELECT DISTINCT one,two FROM t1 WHERE flag = 'N'); +one two flag +5 6 N +7 8 N +insert into t2 values (null,null,'N'); +insert into t2 values (null,3,'0'); +insert into t2 values (null,5,'0'); +insert into t2 values (10,null,'0'); +insert into t1 values (10,3,'0'); +insert into t1 values (10,5,'0'); +insert into t1 values (10,10,'0'); +SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = 'N') as 'test' from t1; +one two test +1 2 NULL +2 3 NULL +3 4 NULL +5 6 1 +7 8 1 +10 3 NULL +10 5 NULL +10 10 NULL +SELECT one,two from t1 where ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = 'N'); +one two +5 6 +7 8 +SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = 'N' group by one,two) as 'test' from t1; +one two test +1 2 NULL +2 3 NULL +3 4 NULL +5 6 1 +7 8 1 +10 3 NULL +10 5 NULL +10 10 NULL +SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = '0') as 'test' from t1; +one two test +1 2 0 +2 3 NULL +3 4 0 +5 6 0 +7 8 0 +10 3 NULL +10 5 NULL +10 10 NULL +SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = '0' group by one,two) as 'test' from t1; +one two test +1 2 0 +2 3 NULL +3 4 0 +5 6 0 +7 8 0 +10 3 NULL +10 5 NULL +10 10 NULL +explain SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = '0') as 'test' from t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 9 11.11 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`one` AS `one`,`test`.`t1`.`two` AS `two`,((`test`.`t1`.`one`,`test`.`t1`.`two`),(/* select#2 */ select `test`.`t2`.`one`,`test`.`t2`.`two` from `test`.`t2` where ((`test`.`t2`.`flag` = '0') and (outer_field_is_not_null, (((`test`.`t1`.`one`) = `test`.`t2`.`one`) or (`test`.`t2`.`one` is null)), true) and (outer_field_is_not_null, (((`test`.`t1`.`two`) = `test`.`t2`.`two`) or (`test`.`t2`.`two` is null)), true)) having ((outer_field_is_not_null, (`test`.`t2`.`one`), true) and (outer_field_is_not_null, (`test`.`t2`.`two`), true)))) AS `test` from `test`.`t1` +explain SELECT one,two from t1 where ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = 'N'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 9 11.11 Using where; FirstMatch(t1); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`one` AS `one`,`test`.`t1`.`two` AS `two` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`two` = `test`.`t1`.`two`) and (`test`.`t2`.`one` = `test`.`t1`.`one`) and (`test`.`t2`.`flag` = 'N')) +explain SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = '0' group by one,two) as 'test' from t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 9 11.11 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`one` AS `one`,`test`.`t1`.`two` AS `two`,((`test`.`t1`.`one`,`test`.`t1`.`two`),(/* select#2 */ select `test`.`t2`.`one`,`test`.`t2`.`two` from `test`.`t2` where ((`test`.`t2`.`flag` = '0') and (outer_field_is_not_null, (((`test`.`t1`.`one`) = `test`.`t2`.`one`) or (`test`.`t2`.`one` is null)), true) and (outer_field_is_not_null, (((`test`.`t1`.`two`) = `test`.`t2`.`two`) or (`test`.`t2`.`two` is null)), true)) having ((outer_field_is_not_null, (`test`.`t2`.`one`), true) and (outer_field_is_not_null, (`test`.`t2`.`two`), true)))) AS `test` from `test`.`t1` +DROP TABLE t1,t2; +CREATE TABLE t1 (a char(5), b char(5)); +INSERT INTO t1 VALUES (NULL,'aaa'), ('aaa','aaa'); +SELECT * FROM t1 WHERE (a,b) IN (('aaa','aaa'), ('aaa','bbb')); +a b +aaa aaa +DROP TABLE t1; +CREATE TABLE t1 (a CHAR(1), b VARCHAR(10)) charset utf8mb4; +INSERT INTO t1 VALUES ('a', 'aa'); +INSERT INTO t1 VALUES ('a', 'aaa'); +SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1); +a b +CREATE INDEX I1 ON t1 (a); +CREATE INDEX I2 ON t1 (b); +EXPLAIN SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL I2 NULL NULL NULL 2 100.00 NULL +1 SIMPLE t1 NULL index I1 I1 5 NULL 2 50.00 Using where; Using index; FirstMatch(t1); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t1`) where (`test`.`t1`.`b` = `test`.`t1`.`a`) +SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1); +a b +CREATE TABLE t2 (a VARCHAR(1), b VARCHAR(10)) charset utf8mb4; +INSERT INTO t2 SELECT * FROM t1; +CREATE INDEX I1 ON t2 (a); +CREATE INDEX I2 ON t2 (b); +EXPLAIN SELECT a,b FROM t2 WHERE b IN (SELECT a FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL I2 NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL index I1 I1 7 NULL 2 50.00 Using where; Using index; FirstMatch(t2); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t2` semi join (`test`.`t2`) where (`test`.`t2`.`b` = `test`.`t2`.`a`) +SELECT a,b FROM t2 WHERE b IN (SELECT a FROM t2); +a b +EXPLAIN +SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1 WHERE LENGTH(a)<500); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL I2 NULL NULL NULL 2 100.00 NULL +1 SIMPLE t1 NULL index I1 I1 5 NULL 2 50.00 Using where; Using index; FirstMatch(t1); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t1`) where ((length(`test`.`t1`.`a`) < 500) and (`test`.`t1`.`b` = `test`.`t1`.`a`)) +SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1 WHERE LENGTH(a)<500); +a b +DROP TABLE t1,t2; +# +# BUG#45928 "Differing query results depending on MRR and +# engine_condition_pushdown settings" +# +CREATE TABLE `t1` ( +`pk` int(11) NOT NULL AUTO_INCREMENT, +`time_nokey` time NOT NULL, +`varchar_key` varchar(1) NOT NULL, +`varchar_nokey` varchar(1) NOT NULL, +PRIMARY KEY (`pk`), +KEY `varchar_key` (`varchar_key`) +) AUTO_INCREMENT=12 DEFAULT CHARSET=latin1; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO `t1` VALUES (10,'00:00:00','i','i'),(11,'00:00:00','',''); +SELECT `time_nokey` G1 FROM t1 WHERE ( `varchar_nokey` , `varchar_key` ) IN ( +SELECT `varchar_nokey` , `varchar_nokey` ) AND `varchar_key` >= 'c' HAVING G1 ORDER +BY `pk` ; +G1 +DROP TABLE t1; +# +# BUG#45863 "Assertion failed: (fixed == 0), function fix_fields(), +# file item.cc, line 4448" +# +DROP TABLE IF EXISTS C, BB; +CREATE TABLE C ( +varchar_nokey varchar(1) NOT NULL +); +INSERT INTO C VALUES +('k'),('a'),(''),('u'),('e'),('v'),('i'), +('t'),('u'),('f'),('u'),('m'),('j'),('f'), +('v'),('j'),('g'),('e'),('h'),('z'); +CREATE TABLE BB ( +varchar_nokey varchar(1) NOT NULL +); +INSERT INTO BB VALUES ('i'),('t'); +SELECT varchar_nokey FROM C +WHERE (varchar_nokey, OUTR) IN (SELECT varchar_nokey +FROM BB); +ERROR 42S22: Unknown column 'OUTR' in 'IN/ALL/ANY subquery' +SELECT varchar_nokey FROM C +WHERE (varchar_nokey, OUTR) IN (SELECT varchar_nokey, varchar_nokey +FROM BB); +ERROR 42S22: Unknown column 'OUTR' in 'IN/ALL/ANY subquery' +DROP TABLE C,BB; +# +# During work with BUG#45863 I had problems with a query that was +# optimized differently in regular and prepared mode. +# Because there was a bug in one of the selected strategies, I became +# aware of the problem. Adding an EXPLAIN query to catch this. +DROP TABLE IF EXISTS t1, t2, t3; +CREATE TABLE t1 +(EMPNUM CHAR(3) NOT NULL, +EMPNAME CHAR(20), +GRADE DECIMAL(4), +CITY CHAR(15)) charset latin1; +CREATE TABLE t2 +(PNUM CHAR(3) NOT NULL, +PNAME CHAR(20), +PTYPE CHAR(6), +BUDGET DECIMAL(9), +CITY CHAR(15)) charset latin1; +CREATE TABLE t3 +(EMPNUM CHAR(3) NOT NULL, +PNUM CHAR(3) NOT NULL, +HOURS DECIMAL(5)) charset latin1; +INSERT INTO t1 VALUES ('E1','Alice',12,'Deale'); +INSERT INTO t1 VALUES ('E2','Betty',10,'Vienna'); +INSERT INTO t1 VALUES ('E3','Carmen',13,'Vienna'); +INSERT INTO t1 VALUES ('E4','Don',12,'Deale'); +INSERT INTO t1 VALUES ('E5','Ed',13,'Akron'); +INSERT INTO t2 VALUES ('P1','MXSS','Design',10000,'Deale'); +INSERT INTO t2 VALUES ('P2','CALM','Code',30000,'Vienna'); +INSERT INTO t2 VALUES ('P3','SDP','Test',30000,'Tampa'); +INSERT INTO t2 VALUES ('P4','SDP','Design',20000,'Deale'); +INSERT INTO t2 VALUES ('P5','IRM','Test',10000,'Vienna'); +INSERT INTO t2 VALUES ('P6','PAYR','Design',50000,'Deale'); +INSERT INTO t3 VALUES ('E1','P1',40); +INSERT INTO t3 VALUES ('E1','P2',20); +INSERT INTO t3 VALUES ('E1','P3',80); +INSERT INTO t3 VALUES ('E1','P4',20); +INSERT INTO t3 VALUES ('E1','P5',12); +INSERT INTO t3 VALUES ('E1','P6',12); +INSERT INTO t3 VALUES ('E2','P1',40); +INSERT INTO t3 VALUES ('E2','P2',80); +INSERT INTO t3 VALUES ('E3','P2',20); +INSERT INTO t3 VALUES ('E4','P2',20); +INSERT INTO t3 VALUES ('E4','P4',40); +INSERT INTO t3 VALUES ('E4','P5',80); +CREATE UNIQUE INDEX t1_IDX ON t1(EMPNUM); +EXPLAIN SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN +(SELECT EMPNUM +FROM t3 +WHERE PNUM IN +(SELECT PNUM +FROM t2 +WHERE PTYPE = 'Design')); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL t1_IDX NULL NULL NULL 5 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 12 8.33 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t3`.`EMPNUM` = `test`.`t1`.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) +PREPARE stmt FROM "EXPLAIN SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN + (SELECT EMPNUM + FROM t3 + WHERE PNUM IN + (SELECT PNUM + FROM t2 + WHERE PTYPE = 'Design'))"; +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL t1_IDX NULL NULL NULL 5 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 12 8.33 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t3`.`EMPNUM` = `test`.`t1`.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) + +This line is only in place to help --skip_if_hypergraph diffing some more. + +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL t1_IDX NULL NULL NULL 5 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 12 8.33 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t3`.`EMPNUM` = `test`.`t1`.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) +DEALLOCATE PREPARE stmt; +DROP INDEX t1_IDX ON t1; +CREATE INDEX t1_IDX ON t1(EMPNUM); +EXPLAIN SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN +(SELECT EMPNUM +FROM t3 +WHERE PNUM IN +(SELECT PNUM +FROM t2 +WHERE PTYPE = 'Design')); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL t1_IDX NULL NULL NULL 5 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 12 8.33 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t3`.`EMPNUM` = `test`.`t1`.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) +PREPARE stmt FROM "EXPLAIN SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN + (SELECT EMPNUM + FROM t3 + WHERE PNUM IN + (SELECT PNUM + FROM t2 + WHERE PTYPE = 'Design'))"; +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL t1_IDX NULL NULL NULL 5 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 12 8.33 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t3`.`EMPNUM` = `test`.`t1`.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) + +This line is only in place to help --skip_if_hypergraph diffing some more. + +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL t1_IDX NULL NULL NULL 5 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 12 8.33 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t3`.`EMPNUM` = `test`.`t1`.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) +DEALLOCATE PREPARE stmt; +DROP INDEX t1_IDX ON t1; +EXPLAIN SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN +(SELECT EMPNUM +FROM t3 +WHERE PNUM IN +(SELECT PNUM +FROM t2 +WHERE PTYPE = 'Design')); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 12 8.33 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t3`.`EMPNUM` = `test`.`t1`.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) +PREPARE stmt FROM "EXPLAIN SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN + (SELECT EMPNUM + FROM t3 + WHERE PNUM IN + (SELECT PNUM + FROM t2 + WHERE PTYPE = 'Design'))"; +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 12 8.33 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t3`.`EMPNUM` = `test`.`t1`.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) + +This line is only in place to help --skip_if_hypergraph diffing some more. + +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 12 8.33 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t3`.`EMPNUM` = `test`.`t1`.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) +DEALLOCATE PREPARE stmt; +DROP TABLE t1, t2, t3; +# +# BUG#45221 Query SELECT pk FROM C WHERE pk IN (SELECT int_key) failing +# +CREATE TABLE t1 ( +i1_key INT, +i2 INT, +i3 INT, +KEY i1_index (i1_key) +); +INSERT INTO t1 VALUES (9,1,2), (9,2,1); +CREATE TABLE t2 ( +pk INT NOT NULL, +i1 INT, +PRIMARY KEY (pk) +); +INSERT INTO t2 VALUES (9,1); +SELECT pk +FROM t2 +WHERE +pk IN ( +SELECT i1_key +FROM t1 +WHERE t1.i2 < t1.i3 XOR t2.i1 > 1 +ORDER BY t1.i2 desc); +pk +9 +DROP TABLE t1,t2; +# BUG#50361 Doublenested noncorrelated subquery with FirstMatch and join cache wrong result +# +CREATE TABLE t1( +id INTEGER +); +INSERT INTO t1 VALUES(10),(20); +create table t2 select * from t1; +create table t3 select * from t1; +SELECT * +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t2 +WHERE 1 IN(SELECT 1 +FROM t3)); +id +10 +20 +explain SELECT * +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t2 +WHERE 1 IN(SELECT 1 +FROM t3)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where true +delete from t2; +delete from t3; +INSERT INTO t1 VALUES(30),(40),(50),(60),(70),(80),(90); +insert into t2 select * from t1; +insert into t3 select * from t1; +create table t4 select * from t1; +SELECT * +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t2 +WHERE 1 IN(SELECT 1 +FROM t3 +WHERE 1 IN(SELECT 1 +FROM t4))); +id +10 +20 +30 +40 +50 +60 +70 +80 +90 +explain SELECT * +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t2 +WHERE 1 IN(SELECT 1 +FROM t3 +WHERE 1 IN(SELECT 1 +FROM t4))); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 9 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 9 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 9 100.00 NULL +1 SIMPLE t4 NULL ALL NULL NULL NULL NULL 9 100.00 FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3` join `test`.`t4`) where true +SELECT * +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t1))); +id +10 +20 +30 +40 +50 +60 +70 +80 +90 +drop table t1,t2,t3,t4; +# +# Bug#53236 Segfault in DTCollation::set(DTCollation&) +# +CREATE TABLE t1 ( +pk INTEGER AUTO_INCREMENT, +col_varchar VARCHAR(1), +PRIMARY KEY (pk) +) +; +INSERT INTO t1 (col_varchar) +VALUES +('w'), +('m') +; +SELECT table1.pk +FROM ( t1 AS table1 JOIN t1 AS table2 ON (table1.col_varchar = +table2.col_varchar) ) +WHERE ( 1, 2 ) IN ( SELECT SUBQUERY1_t1.pk AS SUBQUERY1_field1, +SUBQUERY1_t1.pk AS SUBQUERY1_field2 +FROM ( t1 AS SUBQUERY1_t1 JOIN t1 AS SUBQUERY1_t2 +ON (SUBQUERY1_t2.col_varchar = +SUBQUERY1_t1.col_varchar) ) ) +; +pk +drop table t1; +# +# BUG#53298 "wrong result with semijoin (no semijoin strategy chosen)" +# +create table t1 (uid int, fid int); +insert into t1 values (1,1), (3,1); +create table t2 (uid int, name varchar(128)); +insert into t2 values (1, "A"), (2, "B"); +create table t3 (uid int, fid int, index(uid)); +insert into t3 values (1,3), (1,3); +create table t4 (uid int); +insert into t4 values (3); +explain select t2.uid from t2, t1 +where t1.uid in (select t4.uid from t4, t3 where t3.uid=1 and t4.uid=t3.fid) +and t2.uid=t1.fid; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ref uid uid 5 const 1 50.00 Using where +1 SIMPLE t4 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`uid` AS `uid` from `test`.`t2` join `test`.`t1` semi join (`test`.`t4` join `test`.`t3`) where ((`test`.`t3`.`fid` = `test`.`t1`.`uid`) and (`test`.`t4`.`uid` = `test`.`t1`.`uid`) and (`test`.`t3`.`uid` = 1) and (`test`.`t1`.`fid` = `test`.`t2`.`uid`)) +select t2.uid from t2, t1 +where t1.uid in (select t4.uid from t4, t3 where t3.uid=1 and t4.uid=t3.fid) +and t2.uid=t1.fid; +uid +1 +drop table t1,t2,t3,t4; +CREATE TABLE t1 ( +pk int, +a varchar(1), +b varchar(4), +c varchar(4), +d varchar(4), +PRIMARY KEY (pk) +) charset utf8mb4; +INSERT INTO t1 VALUES (1,'o','ffff','ffff','ffoo'),(2,'f','ffff','ffff','ffff'); +CREATE TABLE t2 LIKE t1; +INSERT INTO t2 VALUES (1,'i','iiii','iiii','iiii'),(2,'f','ffff','ffff','ffff'); +EXPLAIN SELECT pk FROM t1 WHERE (a) IN (SELECT a FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using where; FirstMatch(t1); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`a` = `test`.`t1`.`a`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (a) IN (SELECT a FROM t2 WHERE pk > 0); +pk +2 +SELECT pk FROM t1 WHERE (b,c,d) IN (SELECT b,c,d FROM t2 WHERE pk > 0); +pk +2 +DROP TABLE t1, t2; +CREATE TABLE t1 (f1 INT, f2 DECIMAL(5,3)) ENGINE=MyISAM; +INSERT INTO t1 (f1, f2) VALUES (1, 1.789); +INSERT INTO t1 (f1, f2) VALUES (13, 1.454); +INSERT INTO t1 (f1, f2) VALUES (10, 1.668); +CREATE TABLE t2 LIKE t1; +INSERT INTO t2 VALUES (1, 1.789); +INSERT INTO t2 VALUES (13, 1.454); +EXPLAIN SELECT COUNT(*) FROM t1 WHERE (f1,f2) IN (SELECT f1,f2 FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`f2` = `test`.`t1`.`f2`) and (`test`.`t2`.`f1` = `test`.`t1`.`f1`)) +SELECT COUNT(*) FROM t1 WHERE (f1,f2) IN (SELECT f1,f2 FROM t2); +COUNT(*) +2 +DROP TABLE t1, t2; +CREATE TABLE t1 ( +ID int(11) NOT NULL auto_increment, +Name char(35) NOT NULL default '', +Country char(3) NOT NULL default '', +Population int(11) NOT NULL default '0', +PRIMARY KEY (ID), +INDEX (Population), +INDEX (Country) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t2 ( +Code char(3) NOT NULL default '', +Name char(52) NOT NULL default '', +SurfaceArea float(10,2) NOT NULL default '0.00', +Population int(11) NOT NULL default '0', +Capital int(11) default NULL, +PRIMARY KEY (Code), +UNIQUE INDEX (Name), +INDEX (Population) +) charset utf8mb4; +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t3 ( +Country char(3) NOT NULL default '', +Language char(30) NOT NULL default '', +Percentage float(3,1) NOT NULL default '0.0', +PRIMARY KEY (Country, Language), +INDEX (Percentage) +) charset utf8mb4; +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +EXPLAIN SELECT Name FROM t2 +WHERE t2.Code IN (SELECT Country FROM t1 WHERE Population > 5000000) +AND +t2.Code IN (SELECT Country FROM t3 +WHERE Language='English' AND Percentage > 10 AND +t2.Population > 100000); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL PRIMARY,Population NULL NULL NULL 16 75.00 Using where +1 SIMPLE t1 NULL range Population,Country Population 4 NULL 1 10.00 Using where; FirstMatch(t2); Using join buffer (hash join) +1 SIMPLE t3 NULL eq_ref PRIMARY,Percentage PRIMARY 132 test.t2.Code,const 1 95.45 Using where +Warnings: +Note 1276 Field or reference 'test.t2.Population' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t2`.`Name` AS `Name` from `test`.`t3` join `test`.`t2` semi join (`test`.`t1`) where ((`test`.`t1`.`Country` = `test`.`t2`.`Code`) and (`test`.`t3`.`Country` = `test`.`t2`.`Code`) and (`test`.`t3`.`Language` = 'English') and (`test`.`t3`.`Percentage` > 10) and (`test`.`t2`.`Population` > 100000) and (`test`.`t1`.`Population` > 5000000)) +EXPLAIN FORMAT=JSON SELECT Name FROM t2 +WHERE t2.Code IN (SELECT Country FROM t1 WHERE Population > 5000000) +AND +t2.Code IN (SELECT Country FROM t3 +WHERE Language='English' AND Percentage > 10 AND +t2.Population > 100000); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "12.07" + }, + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "possible_keys": [ + "PRIMARY", + "Population" + ], + "rows_examined_per_scan": 16, + "rows_produced_per_join": 12, + "filtered": "75.00", + "cost_info": { + "read_cost": "1.13", + "eval_cost": "1.20", + "prefix_cost": "2.33", + "data_read_per_join": "2K" + }, + "used_columns": [ + "Code", + "Name", + "Population" + ], + "attached_condition": "(`test`.`t2`.`Population` > 100000)" + } + }, + { + "table": { + "table_name": "t1", + "access_type": "range", + "possible_keys": [ + "Population", + "Country" + ], + "key": "Population", + "used_key_parts": [ + "Population" + ], + "key_length": "4", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 12, + "filtered": "10.00", + "first_match": "t2", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "7.32", + "eval_cost": "1.20", + "prefix_cost": "10.85", + "data_read_per_join": "1K" + }, + "used_columns": [ + "Country", + "Population" + ], + "attached_condition": "((`test`.`t1`.`Country` = `test`.`t2`.`Code`) and (`test`.`t1`.`Population` > 5000000))" + } + }, + { + "table": { + "table_name": "t3", + "access_type": "eq_ref", + "possible_keys": [ + "PRIMARY", + "Percentage" + ], + "key": "PRIMARY", + "used_key_parts": [ + "Country", + "Language" + ], + "key_length": "132", + "ref": [ + "test.t2.Code", + "const" + ], + "rows_examined_per_scan": 1, + "rows_produced_per_join": 11, + "filtered": "95.45", + "cost_info": { + "read_cost": "0.03", + "eval_cost": "1.15", + "prefix_cost": "12.07", + "data_read_per_join": "1K" + }, + "used_columns": [ + "Country", + "Language", + "Percentage" + ], + "attached_condition": "((`test`.`t3`.`Language` = 'English') and (`test`.`t3`.`Percentage` > 10))" + } + } + ] + } +} +Warnings: +Note 1276 Field or reference 'test.t2.Population' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t2`.`Name` AS `Name` from `test`.`t3` join `test`.`t2` semi join (`test`.`t1`) where ((`test`.`t1`.`Country` = `test`.`t2`.`Code`) and (`test`.`t3`.`Country` = `test`.`t2`.`Code`) and (`test`.`t3`.`Language` = 'English') and (`test`.`t3`.`Percentage` > 10) and (`test`.`t2`.`Population` > 100000) and (`test`.`t1`.`Population` > 5000000)) +DROP TABLE t1,t2,t3; +CREATE TABLE t1 ( +Code char(3) NOT NULL DEFAULT '', +Name char(52) NOT NULL DEFAULT '', +Continent enum('Asia','Europe','North America','Africa','Oceania','Antarctica','South America') NOT NULL DEFAULT 'Asia', +Region char(26) NOT NULL DEFAULT '', +SurfaceArea float(10,2) NOT NULL DEFAULT '0.00', +IndepYear smallint(6) DEFAULT NULL, +Population int(11) NOT NULL DEFAULT '0', +LifeExpectancy float(3,1) DEFAULT NULL, +GNP float(10,2) DEFAULT NULL, +GNPOld float(10,2) DEFAULT NULL, +LocalName char(45) NOT NULL DEFAULT '', +GovernmentForm char(45) NOT NULL DEFAULT '', +HeadOfState char(60) DEFAULT NULL, +Capital int(11) DEFAULT NULL, +Code2 char(2) NOT NULL DEFAULT '', +PRIMARY KEY (Code) +) charset utf8mb4; +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t2 ( +ID int(11) NOT NULL AUTO_INCREMENT, +Name char(35) NOT NULL DEFAULT '', +CountryCode char(3) NOT NULL DEFAULT '', +District char(20) NOT NULL DEFAULT '', +Population int(11) NOT NULL DEFAULT '0', +PRIMARY KEY (ID), +KEY CountryCode (CountryCode) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +set names latin1; +Fill the table with test data +This must not use LooseScan: +EXPLAIN SELECT Name FROM t1 +WHERE t1.Code IN ( +SELECT t2.CountryCode FROM t2 WHERE Population > 5000000); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL PRIMARY NULL NULL NULL 31 100.00 NULL +1 SIMPLE t2 NULL ref CountryCode CountryCode 12 test.t1.Code 18 33.33 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`Name` AS `Name` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`CountryCode` = `test`.`t1`.`Code`) and (`test`.`t2`.`Population` > 5000000)) +SELECT Name FROM t1 +WHERE t1.Code IN ( +SELECT t2.CountryCode FROM t2 WHERE Population > 5000000); +Name +Austria +Canada +China +Czech Republic +drop table t1, t2; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4); +create table t1 (a int, b int, key(a)); +insert into t1 select a,a from t0; +create table t2 (a int, b int, primary key(a)); +insert into t2 select * from t1; +Table t2, unlike table t1, should be displayed as pulled out +explain select * from t0 +where t0.a in ( select t1.a from t1,t2 where t2.a=t0.a and +t1.b=t2.b); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL PRIMARY NULL NULL NULL 5 100.00 NULL +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 5 20.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ref a a 5 test.t2.a 1 20.00 Using where; FirstMatch(t0) +Warnings: +Note 1276 Field or reference 'test.t0.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a` from `test`.`t2` join `test`.`t0` semi join (`test`.`t1`) where ((`test`.`t0`.`a` = `test`.`t2`.`a`) and (`test`.`t1`.`a` = `test`.`t2`.`a`) and (`test`.`t1`.`b` = `test`.`t2`.`b`)) +update t1 set a=3, b=11 where a=4; +update t2 set b=11 where a=3; +select * from t0 where t0.a in (select t1.a from t1, t2 where t2.a=t0.a and t1.b=t2.b); +a +0 +1 +2 +3 +drop table t0, t1, t2; +CREATE TABLE t1 ( +id int(11) NOT NULL, +PRIMARY KEY (id)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t2 ( +id int(11) NOT NULL, +fid int(11) NOT NULL, +PRIMARY KEY (id)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t1 values(1); +insert into t2 values(1,7503),(2,1); +explain select count(*) +from t1 +where fid IN (select fid from t2 where (id between 7502 and 8420) order by fid ); +ERROR 42S22: Unknown column 'fid' in 'IN/ALL/ANY subquery' +drop table t1, t2; +create table t1 (a int, b int, key (a), key (b)); +insert into t1 values (2,4),(2,4),(2,4); +select t1.a from t1 +where +t1.a in (select 1 from t1 where t1.a in (select 1 from t1) group by t1.a); +a +drop table t1; +create table t1(a int,b int,key(a),key(b)); +insert into t1 values (1,1),(2,2),(3,3); +select 1 from t1 +where t1.a not in (select 1 from t1 +where t1.a in (select 1 from t1) +group by t1.b); +1 +1 +1 +drop table t1; +CREATE TABLE t1 +(EMPNUM CHAR(3) NOT NULL, +EMPNAME CHAR(20), +GRADE DECIMAL(4), +CITY CHAR(15)); +CREATE TABLE t2 +(PNUM CHAR(3) NOT NULL, +PNAME CHAR(20), +PTYPE CHAR(6), +BUDGET DECIMAL(9), +CITY CHAR(15)); +CREATE TABLE t3 +(EMPNUM CHAR(3) NOT NULL, +PNUM CHAR(3) NOT NULL, +HOURS DECIMAL(5)); +INSERT INTO t1 VALUES ('E1','Alice',12,'Deale'); +INSERT INTO t1 VALUES ('E2','Betty',10,'Vienna'); +INSERT INTO t1 VALUES ('E3','Carmen',13,'Vienna'); +INSERT INTO t1 VALUES ('E4','Don',12,'Deale'); +INSERT INTO t1 VALUES ('E5','Ed',13,'Akron'); +INSERT INTO t2 VALUES ('P1','MXSS','Design',10000,'Deale'); +INSERT INTO t2 VALUES ('P2','CALM','Code',30000,'Vienna'); +INSERT INTO t2 VALUES ('P3','SDP','Test',30000,'Tampa'); +INSERT INTO t2 VALUES ('P4','SDP','Design',20000,'Deale'); +INSERT INTO t2 VALUES ('P5','IRM','Test',10000,'Vienna'); +INSERT INTO t2 VALUES ('P6','PAYR','Design',50000,'Deale'); +INSERT INTO t3 VALUES ('E1','P1',40); +INSERT INTO t3 VALUES ('E1','P2',20); +INSERT INTO t3 VALUES ('E1','P3',80); +INSERT INTO t3 VALUES ('E1','P4',20); +INSERT INTO t3 VALUES ('E1','P5',12); +INSERT INTO t3 VALUES ('E1','P6',12); +INSERT INTO t3 VALUES ('E2','P1',40); +INSERT INTO t3 VALUES ('E2','P2',80); +INSERT INTO t3 VALUES ('E3','P2',20); +INSERT INTO t3 VALUES ('E4','P2',20); +INSERT INTO t3 VALUES ('E4','P4',40); +INSERT INTO t3 VALUES ('E4','P5',80); +SELECT * FROM t1; +EMPNUM EMPNAME GRADE CITY +E1 Alice 12 Deale +E2 Betty 10 Vienna +E3 Carmen 13 Vienna +E4 Don 12 Deale +E5 Ed 13 Akron +CREATE UNIQUE INDEX t1_IDX ON t1(EMPNUM); +SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN +(SELECT EMPNUM +FROM t3 +WHERE PNUM IN +(SELECT PNUM +FROM t2 +WHERE PTYPE = 'Design')); +EMPNAME +Alice +Betty +Don +DROP INDEX t1_IDX ON t1; +CREATE INDEX t1_IDX ON t1(EMPNUM); +SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN +(SELECT EMPNUM +FROM t3 +WHERE PNUM IN +(SELECT PNUM +FROM t2 +WHERE PTYPE = 'Design')); +EMPNAME +Alice +Betty +Don +DROP INDEX t1_IDX ON t1; +SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN +(SELECT EMPNUM +FROM t3 +WHERE PNUM IN +(SELECT PNUM +FROM t2 +WHERE PTYPE = 'Design')); +EMPNAME +Alice +Betty +Don +DROP TABLE t1, t2, t3; +CREATE TABLE t1 (f1 INT NOT NULL); +CREATE VIEW v1 (a) AS SELECT f1 IN (SELECT f1 FROM t1) FROM t1; +SELECT * FROM v1; +a +drop view v1; +drop table t1; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1(a int, b int); +insert into t1 values (0,0),(1,1),(2,2); +create table t2 as select * from t1; +create table t3 (pk int, a int, primary key(pk)); +insert into t3 select a,a from t0; +explain +select * from t1 left join t2 on (t2.a= t1.a and t2.a in (select pk from t3)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE t3 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using index +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` left join (`test`.`t3` join `test`.`t2`) on(((`test`.`t3`.`pk` = `test`.`t1`.`a`) and (`test`.`t2`.`a` = `test`.`t1`.`a`))) where true +drop table t0, t1, t2, t3; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (a int) as select A.a + 10 *(B.a + 10*C.a) as a from t0 A, t0 B, t0 C; +create table t2 (id int, a int, primary key(id), key(a)) charset utf8mb4 as select a as id, a as a from t1; +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `id` int NOT NULL, + `a` int DEFAULT NULL, + PRIMARY KEY (`id`), + KEY `a` (`a`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +set @a=0; +create table t3 as select * from t2 limit 0; +insert into t3 select @a:=@a+1, t2.a from t2, t0; +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +insert into t3 select @a:=@a+1, t2.a from t2, t0; +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +insert into t3 select @a:=@a+1, t2.a from t2, t0; +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +alter table t3 add primary key(id), add 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); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index a a 5 NULL 1000 100.00 Using where; Using index +1 SIMPLE t3 NULL ref a a 5 test.t2.a 30 100.00 Using index; FirstMatch(t2) +Warnings: +Note 1003 /* select#1 */ select count(`test`.`t2`.`a`) AS `count(a)` from `test`.`t2` semi join (`test`.`t3`) where (`test`.`t3`.`a` = `test`.`t2`.`a`) +select count(a) from t2 where a in ( SELECT a FROM t3); +count(a) +1000 +drop table t0,t1,t2,t3; +# +# Bug#33062: subquery in stored routine cause crash +# +CREATE TABLE t1(a INT); +CREATE TABLE t2(c INT); +CREATE PROCEDURE p1(v1 int) +BEGIN +SELECT 1 FROM t1 WHERE a = v1 AND a IN (SELECT c FROM t2); +END +// +CREATE PROCEDURE p2(v1 int) +BEGIN +SELECT 1 FROM t1 WHERE a IN (SELECT c FROM t2); +END +// +CREATE PROCEDURE p3(v1 int) +BEGIN +SELECT 1 +FROM +t1 t01,t1 t02,t1 t03,t1 t04,t1 t05,t1 t06,t1 t07,t1 t08, +t1 t09,t1 t10,t1 t11,t1 t12,t1 t13,t1 t14,t1 t15,t1 t16, +t1 t17,t1 t18,t1 t19,t1 t20,t1 t21,t1 t22,t1 t23,t1 t24, +t1 t25,t1 t26,t1 t27,t1 t28,t1 t29,t1 t30,t1 t31,t1 t32, +t1 t33,t1 t34,t1 t35,t1 t36,t1 t37,t1 t38,t1 t39,t1 t40, +t1 t41,t1 t42,t1 t43,t1 t44,t1 t45,t1 t46,t1 t47,t1 t48, +t1 t49,t1 t50,t1 t51,t1 t52,t1 t53,t1 t54,t1 t55,t1 t56, +t1 t57,t1 t58,t1 t59,t1 t60 +WHERE t01.a IN (SELECT c FROM t2); +END +// +CREATE PROCEDURE p4(v1 int) +BEGIN +SELECT 1 +FROM +t1 t01,t1 t02,t1 t03,t1 t04,t1 t05,t1 t06,t1 t07,t1 t08, +t1 t09,t1 t10,t1 t11,t1 t12,t1 t13,t1 t14,t1 t15,t1 t16, +t1 t17,t1 t18,t1 t19,t1 t20,t1 t21,t1 t22,t1 t23,t1 t24, +t1 t25,t1 t26,t1 t27,t1 t28,t1 t29,t1 t30,t1 t31,t1 t32, +t1 t33,t1 t34,t1 t35,t1 t36,t1 t37,t1 t38,t1 t39,t1 t40, +t1 t41,t1 t42,t1 t43,t1 t44,t1 t45,t1 t46,t1 t47,t1 t48, +t1 t49,t1 t50,t1 t51,t1 t52,t1 t53,t1 t54,t1 t55,t1 t56, +t1 t57,t1 t58,t1 t59,t1 t60 +WHERE t01.a = v1 AND t01.a IN (SELECT c FROM t2); +END +// +CALL p1(1); +1 +CALL p2(1); +1 +CALL p3(1); +1 +CALL p4(1); +1 +DROP TABLE t1, t2; +DROP PROCEDURE p1; +DROP PROCEDURE p2; +DROP PROCEDURE p3; +DROP PROCEDURE p4; +# +# Bug#48213 Materialized subselect crashes if using GEOMETRY type +# +CREATE TABLE t1 ( +pk int, +a varchar(1), +b varchar(4), +c tinyblob, +d blob, +e mediumblob, +f longblob, +g tinytext, +h text, +i mediumtext, +j longtext, +k geometry, +PRIMARY KEY (pk) +) charset utf8mb4; +INSERT INTO t1 VALUES (1,'o','ffff','ffff','ffoo','ffff','ffff','ffff','ffff','ffff','ffff',ST_GeomFromText('POLYGON((0 0, 0 2, 2 2, 2 0, 0 0))')), (2,'f','ffff','ffff','ffff', 'ffff','ffff','ffff','ffff','ffff','ffff',ST_GeomFromText('POLYGON((0 0, 0 2, 2 2, 2 0, 0 0))')); +CREATE TABLE t2 LIKE t1; +INSERT INTO t2 VALUES (1,'i','iiii','iiii','iiii','iiii','ffff','ffff','ffff','ffff','ffff',ST_GeomFromText('POLYGON((0 0, 0 2, 2 2, 2 0, 0 0))')), (2,'f','ffff','ffff','ffff','ffff','ffff','ffff','ffff','ffff','ffff',ST_GeomFromText('POLYGON((0 0, 0 2, 2 2, 2 0, 0 0))')); +EXPLAIN SELECT pk FROM t1 WHERE (a, b) IN (SELECT a, b FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using where; FirstMatch(t1); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ 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); +pk +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, c) IN (SELECT b, c FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using where; FirstMatch(t1); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`c` = `test`.`t1`.`c`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, c) IN (SELECT b, c FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, d) IN (SELECT b, d FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using where; FirstMatch(t1); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`d` = `test`.`t1`.`d`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, d) IN (SELECT b, d FROM t2 WHERE pk > 0); +pk +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, e) IN (SELECT b, e FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using where; FirstMatch(t1); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`e` = `test`.`t1`.`e`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, e) IN (SELECT b, e FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, f) IN (SELECT b, f FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using where; FirstMatch(t1); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`f` = `test`.`t1`.`f`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, f) IN (SELECT b, f FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, g) IN (SELECT b, g FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using where; FirstMatch(t1); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`g` = `test`.`t1`.`g`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, g) IN (SELECT b, g FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, h) IN (SELECT b, h FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using where; FirstMatch(t1); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`h` = `test`.`t1`.`h`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, h) IN (SELECT b, h FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, i) IN (SELECT b, i FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using where; FirstMatch(t1); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`i` = `test`.`t1`.`i`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, i) IN (SELECT b, i FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, j) IN (SELECT b, j FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using where; FirstMatch(t1); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`j` = `test`.`t1`.`j`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, j) IN (SELECT b, j FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, k) IN (SELECT b, k FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using where; FirstMatch(t1); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`k` = `test`.`t1`.`k`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, k) IN (SELECT b, k FROM t2 WHERE pk > 0); +pk +1 +2 +DROP TABLE t1, t2; +# End of Bug#48213 +# +# BUG#53060: LooseScan semijoin strategy does not return all rows +# +CREATE TABLE t1 (i INTEGER); +INSERT INTO t1 VALUES (1), (2), (3), (4), (5); +CREATE TABLE t2 (i INTEGER, j INTEGER, KEY k(i, j)); +INSERT INTO t2 VALUES (1, 0), (1, 1), (2, 0), (2, 1); +EXPLAIN +SELECT * FROM t1 WHERE (i) IN (SELECT i FROM t2 where j > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +1 SIMPLE t2 NULL index k k 10 NULL 4 25.00 Using where; Using index; FirstMatch(t1); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`i` = `test`.`t1`.`i`) and (`test`.`t2`.`j` > 0)) +SELECT * FROM t1 WHERE (i) IN (SELECT i FROM t2 where j > 0); +i +1 +2 +DROP TABLE t1, t2; +# End of BUG#53060 +# +# Bug#53305 "Duplicate weedout + join buffer (join cache --level=7,8) loses rows" +# +create table t1 (uid int, fid int, index(uid)); +insert into t1 values +(1,1), (1,2), (1,3), (1,4), +(2,5), (2,6), (2,7), (2,8), +(3,1), (3,2), (3,9); +create table t2 (uid int primary key, name varchar(128), index(name)); +insert into t2 values +(1, "A"), (2, "B"), (3, "C"), (4, "D"), (5, "E"), +(6, "F"), (7, "G"), (8, "H"), (9, "I"); +create table t3 (uid int, fid int, index(uid)); +insert into t3 values +(1,1), (1,2), (1,3),(1,4), +(2,5), (2,6), (2,7), (2,8), +(3,1), (3,2), (3,9); +create table t4 (uid int primary key, name varchar(128), index(name)); +insert into t4 values +(1, "A"), (2, "B"), (3, "C"), (4, "D"), (5, "E"), +(6, "F"), (7, "G"), (8, "H"), (9, "I"); +explain select name from t2, t1 +where t1.uid in (select t4.uid from t4, t3 where t3.uid=1 and t4.uid=t3.fid) +and t2.uid=t1.fid; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL uid NULL NULL NULL 11 100.00 Using where +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.fid 1 100.00 NULL +1 SIMPLE t4 NULL eq_ref PRIMARY PRIMARY 4 test.t1.uid 1 100.00 Using index +1 SIMPLE t3 NULL ref uid uid 5 const 4 10.00 Using where; FirstMatch(t4) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`name` AS `name` from `test`.`t4` join `test`.`t2` join `test`.`t1` semi join (`test`.`t3`) where ((`test`.`t4`.`uid` = `test`.`t1`.`uid`) and (`test`.`t3`.`fid` = `test`.`t1`.`uid`) and (`test`.`t3`.`uid` = 1) and (`test`.`t2`.`uid` = `test`.`t1`.`fid`)) +select name from t2, t1 +where t1.uid in (select t4.uid from t4, t3 where t3.uid=1 and t4.uid=t3.fid) +and t2.uid=t1.fid; +name +A +A +B +B +C +D +E +F +G +H +I +drop table t1,t2,t3,t4; +# +# Bug#43768 Prepared query with nested subqueries core dump on second execution +# +CREATE TABLE t1 ( +id INT PRIMARY KEY, +partner_id VARCHAR(35) +) charset utf8mb4; +INSERT INTO t1 VALUES +(1, 'partner1'), (2, 'partner2'), +(3, 'partner3'), (4, 'partner4'); +CREATE TABLE t2 ( +id INT NOT NULL, +t1_line_id INT, +article_id VARCHAR(20), +PRIMARY KEY(id, t1_line_id) +) charset utf8mb4; +INSERT INTO t2 VALUES +(1, 1, 'sup'), (2, 1, 'sup'), +(2, 2, 'sup'), (2, 3, 'sup'), +(2, 4, 'imp'), (3, 1, 'sup'), +(4, 1, 'sup'); +CREATE TABLE t3 ( +user_id VARCHAR(50), +article_id VARCHAR(20) NOT NULL, +PRIMARY KEY(user_id) +) charset utf8mb4; +INSERT INTO t3 VALUES('nicke', 'imp'); +EXPLAIN +SELECT t1.partner_id +FROM t1 +WHERE t1.id IN ( +SELECT t2.id +FROM t2 +WHERE article_id IN ( +SELECT article_id FROM t3 +WHERE user_id = 'nicke' + ) +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL system PRIMARY NULL NULL NULL 1 100.00 NULL +1 SIMPLE t1 NULL ALL PRIMARY NULL NULL NULL 4 100.00 NULL +1 SIMPLE t2 NULL ref PRIMARY PRIMARY 4 test.t1.id 1 14.29 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`partner_id` AS `partner_id` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`id` = `test`.`t1`.`id`) and (`test`.`t2`.`article_id` = 'imp')) +SELECT t1.partner_id +FROM t1 +WHERE t1.id IN ( +SELECT t2.id +FROM t2 +WHERE article_id IN ( +SELECT article_id FROM t3 +WHERE user_id = 'nicke' + ) +); +partner_id +partner2 +PREPARE stmt FROM +'EXPLAIN SELECT t1.partner_id +FROM t1 +WHERE t1.id IN ( + SELECT t2.id + FROM t2 + WHERE article_id IN ( + SELECT article_id FROM t3 + WHERE user_id = \'nicke\' + ) + )'; +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL system PRIMARY NULL NULL NULL 1 100.00 NULL +1 SIMPLE t1 NULL ALL PRIMARY NULL NULL NULL 4 100.00 NULL +1 SIMPLE t2 NULL ref PRIMARY PRIMARY 4 test.t1.id 1 14.29 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`partner_id` AS `partner_id` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`id` = `test`.`t1`.`id`) and (`test`.`t2`.`article_id` = 'imp')) + +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL system PRIMARY NULL NULL NULL 1 100.00 NULL +1 SIMPLE t1 NULL ALL PRIMARY NULL NULL NULL 4 100.00 NULL +1 SIMPLE t2 NULL ref PRIMARY PRIMARY 4 test.t1.id 1 14.29 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`partner_id` AS `partner_id` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`id` = `test`.`t1`.`id`) and (`test`.`t2`.`article_id` = 'imp')) +PREPARE stmt FROM +'SELECT t1.partner_id +FROM t1 +WHERE t1.id IN ( + SELECT t2.id + FROM t2 + WHERE article_id IN ( + SELECT article_id FROM t3 + WHERE user_id = \'nicke\' + ) + )'; +EXECUTE stmt; +partner_id +partner2 + +EXECUTE stmt; +partner_id +partner2 +DROP TABLE t1,t2,t3; +# End of Bug#43768 +# +# Bug#53058 - semijoin execution of subquery with outerjoin yields wrong result +# +CREATE TABLE t1 (i INTEGER); +CREATE TABLE t2 (i INTEGER); +CREATE TABLE t3 (i INTEGER); +INSERT INTO t1 VALUES (1), (2); +INSERT INTO t2 VALUES (6); +INSERT INTO t3 VALUES (1), (2); +explain SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t3 LEFT JOIN t2 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = `test`.`t1`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t3 LEFT JOIN t2 ON t2.i=t3.i); +i +1 +2 +drop table t1,t2,t3; +# +# BUG#49453: re-execution of prepared statement with view +# and semijoin crashes +# +CREATE TABLE t1 (city VARCHAR(50), country_id INT); +CREATE TABLE t2 (country_id INT, country VARCHAR(50)); +INSERT INTO t1 VALUES +('Batna',2),('Bchar',2),('Skikda',2),('Tafuna',3),('Algeria',2) ; +INSERT INTO t2 VALUES (2,'Algeria'),(2,'AlgeriaDup'),(3,'XAmerican Samoa'); +CREATE VIEW v1 AS +SELECT country_id as vf_country_id +FROM t2 +WHERE LEFT(country,1) = "A"; +PREPARE stmt FROM " +SELECT city, country_id +FROM t1 +WHERE country_id IN (SELECT vf_country_id FROM v1); +"; + +EXECUTE stmt; +city country_id +Algeria 2 +Batna 2 +Bchar 2 +Skikda 2 + +EXECUTE stmt; +city country_id +Algeria 2 +Batna 2 +Bchar 2 +Skikda 2 +DROP TABLE t1,t2; +DROP VIEW v1; +# +# Bug#54437 Extra rows with LEFT JOIN + semijoin (firstmatch +# and duplicates weedout) +# +create table t1 (a int); +create table t2 (a int); +create table t3 (a int); +insert into t1 values(1),(1); +insert into t2 values(1),(1),(1),(1); +insert into t3 values(2),(2); +explain select * from t1 where t1.a in (select t2.a from t2 left join t3 on t2.a=t3.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t2` left join `test`.`t3` on((`test`.`t2`.`a` = `test`.`t3`.`a`))) where (`test`.`t2`.`a` = `test`.`t1`.`a`) +select * from t1 where t1.a in (select t2.a from t2 left join t3 on t2.a=t3.a); +a +1 +1 +drop table t1,t2,t3; +# +# Bug#55955: crash in MEMORY engine with IN(LEFT JOIN (JOIN)) +# +CREATE TABLE t1 (a INT); +CREATE TABLE t2 (a INT); +CREATE TABLE t3 (a INT); +INSERT INTO t1 VALUES(1),(1); +INSERT INTO t2 VALUES(1),(1); +INSERT INTO t3 VALUES(2),(2); +explain SELECT * FROM t1 +WHERE t1.a IN (SELECT t2.a +FROM t2 LEFT JOIN (t2 AS t2inner, t3) ON t2.a=t3.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2inner NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t2` left join (`test`.`t2` `t2inner` join `test`.`t3`) on((`test`.`t2`.`a` = `test`.`t3`.`a`))) where (`test`.`t2`.`a` = `test`.`t1`.`a`) +SELECT * FROM t1 +WHERE t1.a IN (SELECT t2.a +FROM t2 LEFT JOIN (t2 AS t2inner, t3) ON t2.a=t3.a); +a +1 +1 +DROP TABLE t1,t2,t3; +# +# BUG#52329 - Wrong result: subquery materialization, IN, +# non-null field followed by nullable +# +CREATE TABLE t1 (a1 CHAR(8) NOT NULL, a2 char(8) NOT NULL); +CREATE TABLE t2a (b1 char(8), b2 char(8)); +CREATE TABLE t2b (b1 CHAR(8), b2 char(8) NOT NULL); +CREATE TABLE t2c (b1 CHAR(8) NOT NULL, b2 char(8)); +INSERT INTO t1 VALUES ('1 - 12', '2 - 22'); +INSERT INTO t2a VALUES ('1 - 11', '2 - 21'), +('1 - 11', '2 - 21'), +('1 - 12', '2 - 22'), +('1 - 12', '2 - 22'), +('1 - 13', '2 - 23'); +INSERT INTO t2b SELECT * FROM t2a; +INSERT INTO t2c SELECT * FROM t2a; +SELECT * FROM t1 +WHERE (a1, a2) IN ( +SELECT b1, b2 FROM t2c WHERE b1 > '0' GROUP BY b1, b2); +a1 a2 +1 - 12 2 - 22 +SELECT * FROM t1 +WHERE (a1, a2) IN ( +SELECT b1, b2 FROM t2a WHERE b1 > '0'); +a1 a2 +1 - 12 2 - 22 +SELECT * FROM t1 +WHERE (a1, a2) IN ( +SELECT b1, b2 FROM t2b WHERE b1 > '0'); +a1 a2 +1 - 12 2 - 22 +SELECT * FROM t1 +WHERE (a1, a2) IN ( +SELECT b1, b2 FROM t2c WHERE b1 > '0'); +a1 a2 +1 - 12 2 - 22 +DROP TABLE t1,t2a,t2b,t2c; +# End BUG#52329 +# +# Bug#45174: Incorrectly applied equality propagation caused wrong +# result on a query with a materialized semi-join. +# +CREATE TABLE t1 ( +varchar_nokey varchar(1) NOT NULL +) charset utf8mb4; +INSERT INTO t1 VALUES +('v'), ('u'), ('n'), ('l'), ('h'), ('u'), ('n'), ('j'), ('k'), +('e'), ('i'), ('u'), ('n'), ('b'), ('x'), (''), ('q'), ('u'); +CREATE TABLE t2 ( +pk int NOT NULL, +varchar_key varchar(1) NOT NULL, +varchar_nokey varchar(1) NOT NULL, +PRIMARY KEY(pk), +KEY varchar_key(varchar_key) +) charset utf8mb4; +INSERT INTO t2 VALUES +(11,'m','m'), (12,'j','j'), (13,'z','z'), (14,'a','a'), (15,'',''), +(16,'e','e'), (17,'t','t'), (19,'b','b'), (20,'w','w'), (21,'m','m'), +(23,'',''), (24,'w','w'), (26,'e','e'), (27,'e','e'), (28,'p','p'); +SELECT varchar_nokey +FROM t1 +WHERE (varchar_nokey, varchar_nokey) IN (SELECT varchar_key, varchar_nokey +FROM t2 +WHERE varchar_nokey < 'n' XOR pk); +varchar_nokey +explain SELECT varchar_nokey +FROM t1 +WHERE (varchar_nokey, varchar_nokey) IN (SELECT varchar_key, varchar_nokey +FROM t2 +WHERE varchar_nokey < 'n' XOR pk); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 18 100.00 NULL +1 SIMPLE t2 NULL ref varchar_key varchar_key 6 test.t1.varchar_nokey 2 6.67 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`varchar_nokey` AS `varchar_nokey` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`varchar_key` = `test`.`t1`.`varchar_nokey`) and (`test`.`t2`.`varchar_nokey` = `test`.`t1`.`varchar_nokey`) and ((`test`.`t2`.`varchar_nokey` < 'n') xor (0 <> `test`.`t2`.`pk`))) +DROP TABLE t1, t2; +# End of the test for bug#45174. +# +# Bug#50019: Wrong result for IN-query with materialization +# +CREATE TABLE t1(i INT); +INSERT INTO t1 VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10); +CREATE TABLE t2(i INT); +INSERT INTO t2 VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10); +CREATE TABLE t3(i INT); +INSERT INTO t3 VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10); +SELECT * FROM t1 WHERE t1.i IN (SELECT t2.i +FROM t2 JOIN t3 +WHERE t2.i + t3.i = 5); +i +1 +2 +3 +4 +explain SELECT * FROM t1 WHERE t1.i IN (SELECT t2.i +FROM t2 JOIN t3 +WHERE t2.i + t3.i = 5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 10 10.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 10 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = `test`.`t1`.`i`) and ((`test`.`t1`.`i` + `test`.`t3`.`i`) = 5)) +DROP TABLE t1,t2,t3; +# End of the test for bug#50019. +# +# Bug#52068: Optimizer generates invalid semijoin materialization plan +# +CREATE TABLE ot1(a INTEGER); +INSERT INTO ot1 VALUES(5), (8); +CREATE TABLE it2(a INTEGER); +INSERT INTO it2 VALUES(9), (5), (1), (8); +CREATE TABLE it3(a INTEGER); +INSERT INTO it3 VALUES(7), (1), (0), (5), (1), (4); +CREATE TABLE ot4(a INTEGER); +INSERT INTO ot4 VALUES(1), (3), (5), (7), (9), (7), (3), (1); +SELECT * FROM ot1,ot4 +WHERE (ot1.a,ot4.a) IN (SELECT it2.a,it3.a +FROM it2,it3); +a a +5 1 +5 1 +5 5 +5 7 +5 7 +8 1 +8 1 +8 5 +8 7 +8 7 +explain SELECT * FROM ot1,ot4 +WHERE (ot1.a,ot4.a) IN (SELECT it2.a,it3.a +FROM it2,it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE ot4 NULL ALL NULL NULL NULL NULL 8 100.00 Using join buffer (hash join) +1 SIMPLE it2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where +1 SIMPLE it3 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; FirstMatch(ot4) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot4`.`a` AS `a` from `test`.`ot1` join `test`.`ot4` semi join (`test`.`it2` join `test`.`it3`) where ((`test`.`it3`.`a` = `test`.`ot4`.`a`) and (`test`.`it2`.`a` = `test`.`ot1`.`a`)) +DROP TABLE IF EXISTS ot1, ot4, it2, it3; +# End of the test for bug#52068. +# +# Bug#57623: subquery within before insert trigger causes crash (sj=on) +# +CREATE TABLE ot1(a INT); +CREATE TABLE ot2(a INT); +CREATE TABLE ot3(a INT); +CREATE TABLE it1(a INT); +INSERT INTO ot1 VALUES(0),(1),(2),(3),(4),(5),(6),(7); +INSERT INTO ot2 VALUES(0),(2),(4),(6); +INSERT INTO ot3 VALUES(0),(3),(6); +INSERT INTO it1 VALUES(0),(1),(2),(3),(4),(5),(6),(7); +explain SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 on ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a from it1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +1 SIMPLE ot3 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE it1 NULL ALL NULL NULL NULL NULL 8 100.00 Using where; FirstMatch(ot3) +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a`,`test`.`ot3`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` join `test`.`ot3` semi join (`test`.`it1`)) on(((`test`.`ot3`.`a` = `test`.`ot1`.`a`) and (`test`.`it1`.`a` = `test`.`ot1`.`a`) and (`test`.`ot2`.`a` = `test`.`ot1`.`a`))) where true +SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 on ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a from it1); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +prepare s from 'SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 on ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a from it1)'; +execute s; +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +execute s; +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +deallocate prepare s; +DROP TABLE ot1, ot2, ot3, it1; +# End of the test for bug#57623. +# +# Bug#11766739: Crash in tmp_table_param::init() with semijoin=on +# +CREATE TABLE t1 (f1 INTEGER) ENGINE=MyISAM; +CREATE TABLE t2 (f1 INTEGER, f2 INTEGER) ENGINE=MyISAM; +INSERT INTO t1 VALUES (1); +INSERT INTO t2 VALUES (1,1), (2,1); +EXPLAIN SELECT * FROM t2 +WHERE f2 IN (SELECT t1.f1 +FROM t1 LEFT OUTER JOIN (t2 AS b1 JOIN t2 AS b2 ON TRUE) ON TRUE); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE b1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE b2 NULL ALL NULL NULL NULL NULL 2 100.00 FirstMatch(t2) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`f1` AS `f1`,`test`.`t2`.`f2` AS `f2` from `test`.`t2` semi join (`test`.`t1` left join (`test`.`t2` `b1` join `test`.`t2` `b2`) on((true))) where (`test`.`t1`.`f1` = `test`.`t2`.`f2`) +SELECT * FROM t2 +WHERE f2 IN (SELECT t1.f1 +FROM t1 LEFT OUTER JOIN (t2 AS b1 JOIN t2 AS b2 ON TRUE) ON TRUE); +f1 f2 +1 1 +2 1 +DROP TABLE t1, t2; +# End of the test for bug#11766739. +# +# Bug#11766642: crash in Item_field::register_field_in_read_map with view +# +CREATE TABLE t1(a INT); +CREATE VIEW v1 AS SELECT a FROM t1; +INSERT INTO t1 VALUES (0),(1),(2); +SELECT a FROM t1 WHERE a IN +(SELECT a XOR a FROM v1) +ORDER BY a; +a +0 +DROP TABLE t1; +DROP VIEW v1; +# +# Bug#12546542 MISSING ROW WHEN USING OPTIMIZER_JOIN_CACHE_LEVEL>=3 +# +CREATE TABLE t1 ( +f2 varchar(1024) +); +INSERT INTO t1 VALUES ('v'),('we'); +CREATE TABLE t2 ( +col_varchar_1024_utf8 varchar(1024) CHARACTER SET utf8 DEFAULT NULL, +col_int_key int, +col_int int +); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t2 VALUES ('we',4,NULL),('v',1305673728,6); +CREATE TABLE t3 ( +col_int_key int, +col_int int +); +INSERT INTO t3 VALUES (4,4); +SELECT * +FROM t1 +WHERE f2 IN (SELECT a1.col_varchar_1024_utf8 AS f2 +FROM t2 AS a1 LEFT JOIN t3 AS a2 +ON a1.col_int_key = a2.col_int_key +WHERE a1.col_int BETWEEN 1 AND 10 OR a2.col_int IS NOT NULL); +f2 +v +we +DROP TABLE t1,t2,t3; +# +# BUG#12616344 - JCL: DIFFERENT RESULT SET AND DIFFERENT AMOUNT +# OF ROWS WHEN JCL>=3 +# +CREATE TABLE t1 (col_int_nokey int, col_int_key int, col_varchar_key varchar(1)); +INSERT INTO t1 VALUES (0,4,'c'),(1,6,'u'); +CREATE TABLE t2 (pk int, col_int_nokey int, col_varchar_nokey varchar(1)); +INSERT INTO t2 VALUES (1,4,'b'),(94,6,'u'); +CREATE TABLE t3 (pk int, col_int_nokey int, col_varchar_key varchar(1)); +INSERT INTO t3 VALUES (1,4,'j'),(2,6,'v'); +SELECT table2.col_int_key +from t3 as table1 join t1 as table2 on table2.col_int_nokey +where table1.col_int_nokey in +( +select subquery2_t2.col_int_nokey +from t3 as subquery2_t1 +right join +t2 as subquery2_t2 +join t1 as subquery2_t3 +on subquery2_t3.col_int_key = subquery2_t2.col_int_nokey +on subquery2_t3.col_varchar_key = subquery2_t2.col_varchar_nokey +where subquery2_t1.col_varchar_key != table1.col_varchar_key +or subquery2_t2.pk <= table1.pk +); +col_int_key +6 +6 +DROP TABLE t1,t2,t3; +# +# Bug#12608157: ASSERT IN FIELD_LONG::VAL_INT WHEN USING MEMORY ENGINE +# +CREATE TABLE t1 (i1 int); +INSERT INTO t1 VALUES (1); +CREATE TABLE t2 (i1 int, i2 int) ENGINE=memory; +INSERT INTO t2 VALUES (1, 2),(7, 3); +SELECT GRANDPARENT1.i1 +FROM t2 AS GRANDPARENT1 +WHERE GRANDPARENT1.i2 +IN ( SELECT PARENT1.i2 +FROM t2 AS PARENT1 JOIN t1 AS PARENT2 ON (PARENT1.i1 = PARENT2.i1) +WHERE +GRANDPARENT1.i1 IN ( SELECT CHILD1.i1 FROM t2 AS CHILD1 ) +ORDER BY PARENT1.i1) +ORDER BY GRANDPARENT1.i2 ; +i1 +1 +DROP TABLE t1,t2; +# +# Bug#12640083: Same query executed as WHERE subquery gives different +# results on IN() compare +# +CREATE TABLE t1 ( +pk int NOT NULL, +col_varchar_1024_utf8_key varchar(1024) CHARACTER SET utf8 DEFAULT NULL, +col_varchar_10_latin1_key varchar(10) DEFAULT NULL, +PRIMARY KEY (pk), +KEY col_varchar_1024_utf8_key(col_varchar_1024_utf8_key(333)), +KEY col_varchar_10_latin1_key(col_varchar_10_latin1_key) +) charset utf8mb4; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES +(1, 'a', 'a'), +(2, 'ab', 'ab'), +(3, 'abc', 'abc'), +(4, 'abcd', 'abcd'); +CREATE TABLE t2 ( +pk int NOT NULL AUTO_INCREMENT, +PRIMARY KEY (pk) +) charset utf8mb4 ENGINE=Innodb; +CREATE TABLE t3 charset utf8mb4 +SELECT alias1.col_varchar_10_latin1_key +FROM t1 AS alias1 +LEFT JOIN t1 AS alias2 +JOIN t2 AS alias3 +ON alias2.col_varchar_10_latin1_key +ON alias1.col_varchar_1024_utf8_key +WHERE alias1.pk AND alias1.pk < 3 OR alias1.pk AND alias3.pk; +EXPLAIN SELECT * +FROM t3 +WHERE col_varchar_10_latin1_key IN ( +SELECT alias1.col_varchar_10_latin1_key +FROM t1 AS alias1 +LEFT JOIN t1 AS alias2 +JOIN t2 AS alias3 +ON alias2.col_varchar_10_latin1_key +ON alias1.col_varchar_1024_utf8_key +WHERE alias1.pk AND alias1.pk < 3 OR alias1.pk AND alias3.pk); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE alias1 NULL ref PRIMARY,col_varchar_10_latin1_key col_varchar_10_latin1_key 43 test.t3.col_varchar_10_latin1_key 2 100.00 Using where +1 SIMPLE alias3 NULL index NULL PRIMARY 4 NULL 1 100.00 Using where; Using index +1 SIMPLE alias2 NULL index NULL col_varchar_10_latin1_key 43 NULL 4 100.00 Using where; Using index; FirstMatch(t3) +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`col_varchar_10_latin1_key` AS `col_varchar_10_latin1_key` from `test`.`t3` semi join (`test`.`t1` `alias1` left join (`test`.`t1` `alias2` join `test`.`t2` `alias3`) on(((0 <> `test`.`alias1`.`col_varchar_1024_utf8_key`) and (0 <> `test`.`alias2`.`col_varchar_10_latin1_key`)))) where ((`test`.`alias1`.`col_varchar_10_latin1_key` = `test`.`t3`.`col_varchar_10_latin1_key`) and (((0 <> `test`.`alias1`.`pk`) and (`test`.`alias1`.`pk` < 3)) or ((0 <> `test`.`alias1`.`pk`) and (0 <> `test`.`alias3`.`pk`)))) +SELECT * +FROM t3 +WHERE col_varchar_10_latin1_key IN ( +SELECT alias1.col_varchar_10_latin1_key +FROM t1 AS alias1 +LEFT JOIN t1 AS alias2 +JOIN t2 AS alias3 +ON alias2.col_varchar_10_latin1_key +ON alias1.col_varchar_1024_utf8_key +WHERE alias1.pk AND alias1.pk < 3 OR alias1.pk AND alias3.pk); +col_varchar_10_latin1_key +a +ab +DROP TABLE t1, t2, t3; +# End of the test for bug#12640083. +# +# Bug#12603200 - Assert in QUICK_INDEX_MERGE_SELECT::need_sorted_output +# +CREATE TABLE t1 ( +pk int NOT NULL, +col_int_key int NOT NULL, +col_varchar_nokey varchar(1) NOT NULL, +col_varchar_key varchar(1) NOT NULL, +PRIMARY KEY(pk), +KEY col_int_key(col_int_key), +KEY col_varchar_key(col_varchar_key, col_int_key) +) charset utf8mb4 engine=innodb; +INSERT INTO t1 VALUES +(1,7,'a','a'), +(2,0,'v','v'), +(3,9,'c','c'), +(4,3,'m','m'), +(5,2,'a','a'), +(6,1,'d','d'), +(7,8,'y','y'), +(8,6,'t','t'), +(11,7,'a','x'), +(12,0,'v','v'), +(13,9,'c','c'), +(14,3,'m','m'), +(15,2,'a','x'), +(16,1,'d','d'), +(17,8,'y','y'), +(18,6,'t','u'), +(19,6,'t','u'); +CREATE TABLE t2 ( +pk int NOT NULL, +col_int_key int NOT NULL, +col_varchar_key varchar(1) NOT NULL, +PRIMARY KEY(pk), +KEY col_varchar_key(col_varchar_key, col_int_key) +) charset utf8mb4 engine=innodb; +INSERT INTO t2(pk,col_int_key,col_varchar_key) VALUES +(8,7,'c'), +(11,4,'l'), +(12,7,'b'), +(13,0,'c'), +(14,2,'i'), +(15,9,'h'), +(16,4,'q'), +(17,1,'m'), +(18,9,'b'), +(19,2,'e'), +(20,1,'c'), +(21,7,'z'), +(22,4,'l'), +(23,7,'z'), +(24,0,'c'), +(25,2,'i'), +(26,9,'h'), +(27,4,'q'), +(28,0,'a'), +(29,1,'d'); +EXPLAIN SELECT outr.col_varchar_key AS x, outr.pk AS y +FROM t1 AS outr +WHERE outr.col_varchar_key IN (SELECT innr.col_varchar_key +FROM t2 AS innr +WHERE innr.col_varchar_key = 'a' OR innr.pk = 8) +AND outr.col_varchar_nokey < 't' +ORDER BY outr.col_varchar_key, outr.pk; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 17 33.33 Parallel execute (1 workers) +2 SIMPLE outr NULL ALL col_varchar_key NULL NULL NULL 17 33.33 Using where; Using filesort +2 SIMPLE innr NULL ref PRIMARY,col_varchar_key col_varchar_key 6 test.outr.col_varchar_key 1 100.00 Using where; Using index; FirstMatch(outr) +Warnings: +Note 1003 /* select#1 */ select `test`.`outr`.`col_varchar_key` AS `x`,`test`.`outr`.`pk` AS `y` from `test`.`t1` `outr` semi join (`test`.`t2` `innr`) where ((`test`.`innr`.`col_varchar_key` = `test`.`outr`.`col_varchar_key`) and (`test`.`outr`.`col_varchar_nokey` < 't') and ((`test`.`outr`.`col_varchar_key` = 'a') or (`test`.`innr`.`pk` = 8))) order by `test`.`outr`.`col_varchar_key`,`test`.`outr`.`pk` +SELECT outr.col_varchar_key AS x, outr.pk AS y +FROM t1 AS outr +WHERE outr.col_varchar_key IN (SELECT innr.col_varchar_key +FROM t2 AS innr +WHERE innr.col_varchar_key = 'a' OR innr.pk = 8) +AND outr.col_varchar_nokey < 't' +ORDER BY outr.col_varchar_key, outr.pk; +x y +a 1 +a 5 +c 3 +c 13 +DROP TABLE t1, t2; +# End of bug#12603200 +# +# Bug#12603183: Segfault in hp_movelink +# +CREATE TABLE t1 ( +col_varchar_key varchar(1) , +col_varchar_nokey varchar(1) , +KEY col_varchar_key(col_varchar_key) +) charset latin1; +INSERT INTO t1 VALUES +('i','i'), +('h','h'), +('q','q'), +('a','a'), +('v','v'), +('u','u'), +('s','s'), +('y','y'), +('z','z'), +('h','h'), +('p','p'), +('e','e'), +('i','i'), +('y','y'), +('w','w'); +CREATE TABLE t2 ( +col_varchar_nokey varchar(1) +) charset latin1; +INSERT INTO t2 VALUES +('b'); +EXPLAIN SELECT grandparent1.col_varchar_nokey +FROM t1 AS grandparent1 LEFT JOIN t2 AS grandparent2 USING (col_varchar_nokey) +WHERE (grandparent1.col_varchar_key) IN +(SELECT parent1.col_varchar_nokey +FROM t1 AS parent1 +WHERE parent1.col_varchar_key IN +(SELECT child1.col_varchar_nokey AS c1 +FROM t1 AS child1 LEFT JOIN t2 AS child2 +ON (child1.col_varchar_key > child2.col_varchar_nokey))); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE grandparent1 NULL ALL col_varchar_key NULL NULL NULL 15 100.00 NULL +1 SIMPLE grandparent2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE parent1 NULL ALL col_varchar_key NULL NULL NULL 15 10.00 Using where +1 SIMPLE child1 NULL ALL NULL NULL NULL NULL 15 10.00 Using where +1 SIMPLE child2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(grandparent2) +Warnings: +Note 1003 /* select#1 */ select `test`.`grandparent1`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t1` `grandparent1` left join `test`.`t2` `grandparent2` on((`test`.`grandparent2`.`col_varchar_nokey` = `test`.`grandparent1`.`col_varchar_nokey`)) semi join (`test`.`t1` `parent1` join `test`.`t1` `child1` left join `test`.`t2` `child2` on((`test`.`child1`.`col_varchar_key` > `test`.`child2`.`col_varchar_nokey`))) where ((`test`.`parent1`.`col_varchar_nokey` = `test`.`grandparent1`.`col_varchar_key`) and (`test`.`child1`.`col_varchar_nokey` = `test`.`parent1`.`col_varchar_key`)) +SELECT grandparent1.col_varchar_nokey +FROM t1 AS grandparent1 LEFT JOIN t2 AS grandparent2 USING (col_varchar_nokey) +WHERE (grandparent1.col_varchar_key) IN +(SELECT parent1.col_varchar_nokey +FROM t1 AS parent1 +WHERE parent1.col_varchar_key IN +(SELECT child1.col_varchar_nokey AS c1 +FROM t1 AS child1 LEFT JOIN t2 AS child2 +ON (child1.col_varchar_key > child2.col_varchar_nokey))); +col_varchar_nokey +a +e +h +h +i +i +p +q +s +u +v +w +y +y +z +DROP TABLE t1, t2; +# End of test for bug#12603183. +# +# Bug#12818569: Diff nr of rows returned when using IN/ALL+subquery +# +CREATE TABLE t1 ( +col_int_key INT NOT NULL, +col_datetime_key DATETIME NOT NULL, +col_varchar_key VARCHAR(1) NOT NULL, +KEY col_int_key (col_int_key), +KEY col_datetime_key(col_datetime_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t1 VALUES +(7,'2004-06-06 04:22:12','v'), (0,'2005-11-13 01:12:31','s'), +(9,'2002-05-04 01:50:00','l'), (3,'2004-10-27 10:28:45','y'), +(4,'2006-07-22 05:24:23','c'), (2,'2002-05-16 21:34:03','i'), +(5,'2008-04-17 10:45:30','h'), (3,'2009-04-21 02:58:02','q'), +(1,'2008-01-11 11:01:51','a'), (3,'1900-01-01 00:00:00','v'), +(6,'2007-05-17 18:24:57','u'), (7,'2007-08-07 00:00:00','s'), +(5,'2001-08-28 00:00:00','y'), (1,'2004-04-16 00:27:28','z'), +(204,'2005-05-03 07:06:22','h'), (224,'2009-03-11 17:09:50','p'), +(9,'2007-12-08 01:54:28','e'), (5,'2009-07-28 18:19:54','i'), +(0,'2008-06-08 00:00:00','y'), (3,'2005-02-09 09:20:26','w'); +CREATE TABLE t2 ( +col_varchar_nokey VARCHAR(1) NOT NULL +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t2 VALUES ('v'), ('y'), ('j'), ('c'), ('d'), ('r'); +explain SELECT col_varchar_key +FROM t1 +WHERE col_varchar_key IN (SELECT col_varchar_nokey +FROM t2) +ORDER BY col_datetime_key LIMIT 4; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 20 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL col_varchar_key NULL NULL NULL 20 100.00 Using temporary; Using filesort +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; FirstMatch(t1); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col_varchar_key` AS `col_varchar_key` from `test`.`t1` semi join (`test`.`t2`) where (`test`.`t2`.`col_varchar_nokey` = `test`.`t1`.`col_varchar_key`) order by `test`.`t1`.`col_datetime_key` limit 4 +SELECT col_varchar_key +FROM t1 +WHERE col_varchar_key IN (SELECT col_varchar_nokey +FROM t2) +ORDER BY col_datetime_key LIMIT 4; +col_varchar_key +v +y +v +y +DROP TABLE t1, t2; +# End of test for bug#12818569. +# +# Bug#12803439: Assert in replace_subcondition() on update query +# +CREATE TABLE t1(a INTEGER); +INSERT INTO t1 values(1), (2); +CREATE TABLE t2(a INTEGER); +INSERT INTO t2 VALUES(1), (3); +SELECT * +FROM t1 +WHERE a IN (SELECT a +FROM t2 +HAVING a IN (SELECT a +FROM t2) +) +HAVING a IN (SELECT a +FROM t2); +a +1 +DROP TABLE t1, t2; +# End of test for bug#12803439. +# +# Bug#12797534: Segfault in hp_movelink still exists +# +CREATE TABLE t1 ( +g1 VARCHAR(1) NOT NULL +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t1 VALUES ('d'), ('s'); +CREATE TABLE t2 ( +pk INT NOT NULL, +col_int_key INT NOT NULL, +col_varchar_key VARCHAR(1) NOT NULL, +col_varchar_nokey VARCHAR(1) NOT NULL, +PRIMARY KEY (pk), +KEY col_varchar_key(col_varchar_key, col_int_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t2 VALUES +(1,4,'j','j'), (2,6,'v','v'), (3,3,'c','c'), (4,5,'m','m'), +(5,3,'d','d'), (6,246,'d','d'), (7,2,'y','y'), (8,9,'t','t'), +(9,3,'d','d'), (10,8,'s','s'), (11,1,'r','r'), (12,8,'m','m'), +(13,8,'b','b'), (14,5,'x','x'), (15,7,'g','g'), (16,5,'p','p'), +(17,1,'q','q'), (18,6,'w','w'), (19,2,'d','d'), (20,9,'e','e'); +CREATE TABLE t3 ( +pk INTEGER NOT NULL, +PRIMARY KEY (pk) +) ENGINE=InnoDB; +INSERT INTO t3 VALUES (10); +EXPLAIN SELECT * +FROM t1 +WHERE g1 NOT IN +(SELECT grandparent1.col_varchar_nokey AS g1 +FROM t2 AS grandparent1 +WHERE grandparent1.col_varchar_key IN +(SELECT parent1.col_varchar_nokey AS p1 +FROM t2 AS parent1 LEFT JOIN t3 AS parent2 USING (pk) +) +AND grandparent1.col_varchar_key IS NOT NULL +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 SIMPLE parent1 NULL ALL NULL NULL NULL NULL 20 100.00 Using where; Not exists +2 SIMPLE parent2 NULL eq_ref PRIMARY PRIMARY 4 test.parent1.pk 1 100.00 Using index +2 SIMPLE grandparent1 NULL ref col_varchar_key col_varchar_key 6 test.parent1.col_varchar_nokey 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`g1` AS `g1` from `test`.`t1` anti join (`test`.`t2` `grandparent1` join `test`.`t2` `parent1` left join `test`.`t3` `parent2` on((`test`.`parent2`.`pk` = `test`.`parent1`.`pk`))) on(((`test`.`grandparent1`.`col_varchar_nokey` = `test`.`t1`.`g1`) and (`test`.`grandparent1`.`col_varchar_key` = `test`.`parent1`.`col_varchar_nokey`) and (`test`.`grandparent1`.`col_varchar_key` is not null))) where true +SELECT * +FROM t1 +WHERE g1 NOT IN +(SELECT grandparent1.col_varchar_nokey AS g1 +FROM t2 AS grandparent1 +WHERE grandparent1.col_varchar_key IN +(SELECT parent1.col_varchar_nokey AS p1 +FROM t2 AS parent1 LEFT JOIN t3 AS parent2 USING (pk) +) +AND grandparent1.col_varchar_key IS NOT NULL +); +g1 +DROP TABLE t1, t2, t3; +CREATE TABLE t1 ( +pk INTEGER AUTO_INCREMENT, +col_int_key INTEGER , +col_varchar_key VARCHAR(1) , +col_varchar_nokey VARCHAR(1) , +PRIMARY KEY (pk), +KEY (col_varchar_key,col_int_key) +) ENGINE=INNODB; +INSERT INTO t1 (col_int_key,col_varchar_key,col_varchar_nokey) VALUES +(0,'x','x'), (1,'j','j'), (1,'r','r'), (9,'v','v'), (5,'r','r'); +CREATE TABLE t2 ( +pk INTEGER AUTO_INCREMENT, +col_int_key INTEGER , +col_varchar_key VARCHAR(1) , +col_varchar_nokey VARCHAR(1) , +PRIMARY KEY (pk), +KEY (col_int_key), +KEY (col_varchar_key,col_int_key) +) AUTO_INCREMENT=10 ENGINE=INNODB; +INSERT INTO t2 (col_int_key, col_varchar_key, col_varchar_nokey) VALUES +(NULL,'x','x'), (NULL,'j','j'), (8,'c','c'); +CREATE TABLE t3 +SELECT outr.col_varchar_nokey AS x +FROM t1 AS outr +WHERE outr.col_varchar_nokey IN +(SELECT innr.col_varchar_nokey AS y +FROM t2 AS innr +WHERE innr.col_int_key IS NULL) +AND outr.col_varchar_nokey IS NOT NULL +AND NOT col_varchar_key IS NULL; +SELECT * +FROM t3 +WHERE x NOT IN +(SELECT outr.col_varchar_nokey AS x +FROM t1 AS outr +WHERE outr.col_varchar_nokey IN +(SELECT innr.col_varchar_nokey AS y +FROM t2 AS innr +WHERE innr.col_int_key IS NULL) +AND outr.col_varchar_nokey IS NOT NULL +AND NOT col_varchar_key IS NULL); +x +DROP TABLE t1, t2, t3; +# End of test for bug#12797534. +# +# Bug#12714094: Assert in optimize_semijoin_nests() +# +CREATE TABLE it ( +pk int NOT NULL, +col_varchar VARCHAR(10) DEFAULT NULL, +PRIMARY KEY (pk) +) ENGINE=MyISAM; +INSERT INTO it VALUES (1, 'g'); +CREATE TABLE ot +SELECT alias1.pk AS field1 +FROM it AS alias1 +LEFT JOIN it AS alias2 +ON alias1.col_varchar = alias2.col_varchar +; +SELECT * +FROM ot +WHERE field1 IN ( +SELECT alias1.pk +FROM it AS alias1 +LEFT JOIN it AS alias2 +ON alias1.col_varchar = alias2.col_varchar +); +field1 +1 +DROP TABLE it, ot; +# End of test for bug#12714094 +# +# Bug#12867557: Valgrind: conditional jump/move at key_cmp +# +CREATE TABLE t1 ( +pk INTEGER AUTO_INCREMENT, +col_int_key INTEGER, +PRIMARY KEY (pk), +KEY (col_int_key) +) AUTO_INCREMENT=10; +INSERT INTO t1 (col_int_key) VALUES (8); +CREATE TABLE t2 ( +pk INTEGER AUTO_INCREMENT, +col_int_key INTEGER, +col_time_key TIME, +PRIMARY KEY (pk), +KEY (col_int_key), +KEY (col_time_key) +) AUTO_INCREMENT=10; +INSERT INTO t2 (col_int_key, col_time_key) +VALUES +(8, '22:55:23.019225'), (7, '10:19:31.050677'), (1, '14:40:36.038608'), +(7, '04:37:47.062416'), (9, '19:34:06.054514'), (NULL,'20:35:33.022996'), +(1, NULL), (9, '14:43:37.057393'), (2, '02:23:09.043438'), +(9, '01:22:45.041064'), (2, '00:00:00'), (4, '00:13:25.038482'), +(0, '03:47:16.042671'), (4, '01:41:48.007423'), (8, '00:00:00'), +(NULL, '22:32:04.047407'), (NULL, '16:44:14.028443'), (0, '17:38:37.059754'), +(NULL, '08:46:48.042388'), (8, '14:11:27.044095'); +CREATE TABLE t0 +SELECT DISTINCT grandparent1.col_time_key AS g1 +FROM t2 AS grandparent1 +WHERE grandparent1.col_int_key IN +(SELECT parent1.col_int_key AS p1 +FROM t1 AS parent1) +AND grandparent1.pk > 9; +UPDATE t0 +SET g1 = g1 +WHERE g1 IN +(SELECT grandparent1.col_time_key AS g1 +FROM t2 AS grandparent1 +WHERE grandparent1.col_int_key IN +(SELECT parent1.col_int_key AS p1 +FROM t1 AS parent1) +AND grandparent1.pk > 9); +DROP TABLE t0, t1, t2; +# End of test for bug#12867557 +# +# Bug#12711441: crash in fix_after_pullout +# +CREATE TABLE t1 ( +pk int NOT NULL, +col_int_nokey int DEFAULT NULL, +col_int_key int DEFAULT NULL, +col_time_key time DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +PRIMARY KEY (pk) +); +CREATE VIEW v1 AS SELECT * FROM t1; +CREATE TABLE t2 ( +col_int_key int DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +KEY col_varchar_key(col_varchar_key, col_int_key) +); +CREATE TABLE t3 ( +pk int NOT NULL, +col_int_key INT DEFAULT NULL, +PRIMARY KEY (pk) +); +CREATE TABLE t4 ( +col_int_nokey INT DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +KEY col_varchar_key(col_varchar_key) +); +CREATE TABLE ts +SELECT alias1.col_time_key AS field1 +FROM v1 AS alias1 +RIGHT JOIN t3 AS alias2 +ON alias2.col_int_key = alias1.col_int_nokey +WHERE alias1.pk >= SOME( +SELECT SQ1_alias1.pk AS SQ1_field1 +FROM t3 AS SQ1_alias1 +INNER JOIN (t2 AS SQ1_alias2 +INNER JOIN t4 AS SQ1_alias3 +ON SQ1_alias3.col_varchar_key = SQ1_alias2.col_varchar_nokey) +ON SQ1_alias3.col_int_nokey = SQ1_alias2.col_int_key +WHERE SQ1_alias2.col_varchar_key <= alias1.col_varchar_key +AND SQ1_alias3.col_varchar_nokey <> alias1.col_varchar_key) +; +SELECT * FROM ts WHERE field1 IN ( +SELECT alias1.col_time_key AS field1 +FROM v1 AS alias1 +RIGHT JOIN t3 AS alias2 +ON alias2.col_int_key = alias1.col_int_nokey +WHERE alias1.pk >= SOME( +SELECT SQ1_alias1.pk AS SQ1_field1 +FROM t3 AS SQ1_alias1 +INNER JOIN (t2 AS SQ1_alias2 +INNER JOIN t4 AS SQ1_alias3 +ON SQ1_alias3.col_varchar_key = SQ1_alias2.col_varchar_nokey) +ON SQ1_alias3.col_int_nokey = SQ1_alias2.col_int_key +WHERE SQ1_alias2.col_varchar_key <= alias1.col_varchar_key +AND SQ1_alias3.col_varchar_nokey <> alias1.col_varchar_key) +); +field1 +DROP TABLE t1, t2, t3, t4, ts; +DROP VIEW v1; +# End of test for bug#12711441. +# +# Bug#12664936: Same query executed as where subquery ... +# +CREATE TABLE t1 ( +col_varchar_key VARCHAR(1), +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4; +INSERT INTO t1 VALUES +('o'), ('w'), ('m'), ('q'), +('f'), ('p'), ('j'), ('c'); +CREATE TABLE t2 ( +col_int_nokey INTEGER, +col_int_key INTEGER, +col_varchar_key varchar(1), +KEY col_int_key (col_int_key) +) charset utf8mb4; +INSERT INTO t2 VALUES +(8,5,'u'),(4,5,'p'),(8,1,'o'),(NULL,7,'v'), +(1,2,'g'),(2,1,'q'),(NULL,7,'l'),(3,1,'n'); +CREATE TABLE t4 +SELECT t2.col_int_nokey, t2.col_varchar_key +FROM t1 JOIN t2 ON t2.col_varchar_key = t1.col_varchar_key +WHERE t2.col_int_key = 1; +EXPLAIN SELECT * +FROM t4 +WHERE (col_int_nokey, col_varchar_key) IN +(SELECT t2.col_int_nokey, t2.col_varchar_key +FROM t1 JOIN t2 ON t2.col_varchar_key = t1.col_varchar_key +WHERE t2.col_int_key = 1 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t4 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE t2 NULL ref col_int_key col_int_key 5 const 3 12.50 Using where +1 SIMPLE t1 NULL ref col_varchar_key col_varchar_key 7 test.t4.col_varchar_key 2 100.00 Using index; FirstMatch(t4) +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`col_int_nokey` AS `col_int_nokey`,`test`.`t4`.`col_varchar_key` AS `col_varchar_key` from `test`.`t4` semi join (`test`.`t1` join `test`.`t2`) where ((`test`.`t2`.`col_varchar_key` = `test`.`t4`.`col_varchar_key`) and (`test`.`t1`.`col_varchar_key` = `test`.`t4`.`col_varchar_key`) and (`test`.`t2`.`col_int_nokey` = `test`.`t4`.`col_int_nokey`) and (`test`.`t2`.`col_int_key` = 1)) +SELECT * +FROM t4 +WHERE (col_int_nokey, col_varchar_key) IN +(SELECT t2.col_int_nokey, t2.col_varchar_key +FROM t1 JOIN t2 ON t2.col_varchar_key = t1.col_varchar_key +WHERE t2.col_int_key = 1 +); +col_int_nokey col_varchar_key +8 o +2 q +DROP TABLE t1, t2, t4; +# End of test for bug#12664936. +# +# Bug#13340270: assertion table->sort.record_pointers == __null +# +CREATE TABLE t1 ( +pk int NOT NULL, +col_int_key int DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key, col_int_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t1 VALUES +(10,8,'x','x'), +(11,7,'d','d'), +(12,1,'r','r'), +(13,7,'f','f'), +(14,9,'y','y'), +(15,NULL,'u','u'), +(16,1,'m','m'), +(17,9,NULL,NULL), +(18,2,'o','o'), +(19,9,'w','w'), +(20,2,'m','m'), +(21,4,'q','q'); +CREATE TABLE t2 +SELECT alias1.col_varchar_nokey AS field1 +FROM t1 AS alias1 JOIN t1 AS alias2 +ON alias2.col_int_key = alias1.pk OR +alias2.col_int_key = alias1.col_int_key +WHERE alias1.pk = 58 OR alias1.col_varchar_key = 'o' + +; +EXPLAIN SELECT * +FROM t2 +WHERE (field1) IN (SELECT alias1.col_varchar_nokey AS field1 +FROM t1 AS alias1 JOIN t1 AS alias2 +ON alias2.col_int_key = alias1.pk OR +alias2.col_int_key = alias1.col_int_key +WHERE alias1.pk = 58 OR alias1.col_varchar_key = 'o' +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE alias1 NULL index_merge PRIMARY,col_int_key,col_varchar_key col_varchar_key,PRIMARY 7,4 NULL 2 10.00 Using sort_union(col_varchar_key,PRIMARY); Using where +1 SIMPLE alias2 NULL ALL col_int_key NULL NULL NULL 12 19.00 Range checked for each record (index map: 0x2); FirstMatch(t2) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`field1` AS `field1` from `test`.`t2` semi join (`test`.`t1` `alias1` join `test`.`t1` `alias2`) where ((`test`.`alias1`.`col_varchar_nokey` = `test`.`t2`.`field1`) and ((`test`.`alias1`.`pk` = 58) or (`test`.`alias1`.`col_varchar_key` = 'o')) and ((`test`.`alias2`.`col_int_key` = `test`.`alias1`.`pk`) or (`test`.`alias2`.`col_int_key` = `test`.`alias1`.`col_int_key`))) +SELECT * +FROM t2 +WHERE (field1) IN (SELECT alias1.col_varchar_nokey AS field1 +FROM t1 AS alias1 JOIN t1 AS alias2 +ON alias2.col_int_key = alias1.pk OR +alias2.col_int_key = alias1.col_int_key +WHERE alias1.pk = 58 OR alias1.col_varchar_key = 'o' +); +field1 +o +o +DROP TABLE t1, t2; +# End of test for bug#13340270. +# +# Bug#13335319: Seg fault when analyzing FirstMatch semi-join strategy +# +CREATE TABLE ot1(a INTEGER); +INSERT INTO ot1 VALUES(1), (2), (3); +CREATE TABLE ot2(a INTEGER); +INSERT INTO ot2 VALUES(1), (2), (4), (6), (8), (10); +CREATE TABLE it1(a INTEGER); +INSERT INTO it1 VALUES(1), (3), (5), (7); +CREATE TABLE it2(a INTEGER); +INSERT INTO it2 VALUES(1), (3), (5), (7), (9); +explain SELECT ot1.a, ot2.a +FROM ot1, ot2 +WHERE ot1.a IN (SELECT a FROM it1) AND +ot2.a IN (SELECT a FROM it2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE it1 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; FirstMatch(ot1); Using join buffer (hash join) +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 6 100.00 Using join buffer (hash join) +1 SIMPLE it2 NULL ALL NULL NULL NULL NULL 5 20.00 Using where; FirstMatch(ot2); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` join `test`.`ot2` semi join (`test`.`it1`) semi join (`test`.`it2`) where ((`test`.`it2`.`a` = `test`.`ot2`.`a`) and (`test`.`it1`.`a` = `test`.`ot1`.`a`)) +SELECT ot1.a, ot2.a +FROM ot1, ot2 +WHERE ot1.a IN (SELECT a FROM it1) AND +ot2.a IN (SELECT a FROM it2); +a a +1 1 +3 1 +DROP TABLE ot1, ot2, it1, it2; +# End of test for bug#13335319. +# +# Bug#13334882: Assertion keypart_map failed in MyIsam function +# +CREATE TABLE t1 ( +pk int NOT NULL, +col_int_nokey INT NOT NULL, +col_int_key INT NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +) ENGINE=MyISAM; +INSERT INTO t1 VALUES +(1,4,0), +(2,6,8), +(3,3,1), +(7,2,6), +(8,9,1), +(9,3,6), +(10,8,2), +(11,1,4), +(12,8,8), +(13,8,4), +(14,5,4); +CREATE TABLE t2 ( +pk int NOT NULL, +col_int_nokey int NOT NULL, +col_int_key int NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +) ENGINE=MyISAM; +INSERT INTO t2 VALUES +(10,8,7); +CREATE TABLE t3 +SELECT grandparent1.col_int_nokey AS g1 +FROM t1 AS grandparent1 +WHERE (grandparent1.col_int_nokey, grandparent1.col_int_key) IN +(SELECT parent1.col_int_key AS p1, +parent1.col_int_key AS p2 +FROM t1 AS parent1 +LEFT JOIN t2 AS parent2 +ON parent1.col_int_nokey = parent2.col_int_key +) +AND grandparent1.col_int_key <> 3 +; +explain SELECT * FROM t3 +WHERE g1 NOT IN +(SELECT grandparent1.col_int_nokey AS g1 +FROM t1 AS grandparent1 +WHERE (grandparent1.col_int_nokey, grandparent1.col_int_key) IN +(SELECT parent1.col_int_key AS p1, +parent1.col_int_key AS p2 +FROM t1 AS parent1 +LEFT JOIN t2 AS parent2 +ON parent1.col_int_nokey = parent2.col_int_key +) +AND grandparent1.col_int_key <> 3 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE grandparent1 NULL ref col_int_key col_int_key 4 const 1 100.00 Using where; Not exists +1 SIMPLE parent1 NULL ref col_int_key col_int_key 4 test.grandparent1.col_int_nokey 1 100.00 Using where +1 SIMPLE parent2 NULL ref col_int_key col_int_key 4 test.parent1.col_int_nokey 2 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select '8' AS `g1` from anti join (`test`.`t1` `grandparent1` join `test`.`t1` `parent1` left join `test`.`t2` `parent2` on((`test`.`parent2`.`col_int_key` = `test`.`parent1`.`col_int_nokey`))) on(((`test`.`grandparent1`.`col_int_nokey` = '8') and (`test`.`grandparent1`.`col_int_key` = '8') and (`test`.`parent1`.`col_int_key` = '8') and ('8' <> 3))) where true +explain format=json SELECT * FROM t3 +WHERE g1 NOT IN +(SELECT grandparent1.col_int_nokey AS g1 +FROM t1 AS grandparent1 +WHERE (grandparent1.col_int_nokey, grandparent1.col_int_key) IN +(SELECT parent1.col_int_key AS p1, +parent1.col_int_key AS p2 +FROM t1 AS parent1 +LEFT JOIN t2 AS parent2 +ON parent1.col_int_nokey = parent2.col_int_key +) +AND grandparent1.col_int_key <> 3 +); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.36" + }, + "nested_loop": [ + { + "table": { + "table_name": "t3", + "access_type": "system", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.00", + "eval_cost": "0.10", + "prefix_cost": "0.00", + "data_read_per_join": "8" + }, + "used_columns": [ + "g1" + ] + } + }, + { + "table": { + "table_name": "grandparent1", + "access_type": "ref", + "possible_keys": [ + "col_int_key" + ], + "key": "col_int_key", + "used_key_parts": [ + "col_int_key" + ], + "key_length": "4", + "ref": [ + "const" + ], + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "not_exists": true, + "cost_info": { + "read_cost": "0.28", + "eval_cost": "0.11", + "prefix_cost": "0.39", + "data_read_per_join": "17" + }, + "used_columns": [ + "col_int_nokey", + "col_int_key" + ], + "attached_condition": "(((is_not_null_compl(grandparent1..parent2), (found_match(grandparent1..parent2), false, true), true) and (is_not_null_compl(grandparent1..parent2), (('8' <> 3)), true)) and (is_not_null_compl(grandparent1..parent2), (`test`.`grandparent1`.`col_int_nokey` = '8'), true))" + } + }, + { + "table": { + "table_name": "parent1", + "access_type": "ref", + "possible_keys": [ + "col_int_key" + ], + "key": "col_int_key", + "used_key_parts": [ + "col_int_key" + ], + "key_length": "4", + "ref": [ + "test.grandparent1.col_int_nokey" + ], + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.30", + "eval_cost": "0.12", + "prefix_cost": "0.81", + "data_read_per_join": "19" + }, + "used_columns": [ + "col_int_nokey", + "col_int_key" + ], + "attached_condition": "(is_not_null_compl(grandparent1..parent2), (`test`.`parent1`.`col_int_key` = '8'), true)" + } + }, + { + "table": { + "table_name": "parent2", + "access_type": "ref", + "possible_keys": [ + "col_int_key" + ], + "key": "col_int_key", + "used_key_parts": [ + "col_int_key" + ], + "key_length": "4", + "ref": [ + "test.parent1.col_int_nokey" + ], + "rows_examined_per_scan": 2, + "rows_produced_per_join": 1, + "filtered": "100.00", + "using_index": true, + "cost_info": { + "read_cost": "0.31", + "eval_cost": "0.10", + "prefix_cost": "1.36", + "data_read_per_join": "16" + }, + "used_columns": [ + "col_int_key" + ] + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select '8' AS `g1` from anti join (`test`.`t1` `grandparent1` join `test`.`t1` `parent1` left join `test`.`t2` `parent2` on((`test`.`parent2`.`col_int_key` = `test`.`parent1`.`col_int_nokey`))) on(((`test`.`grandparent1`.`col_int_nokey` = '8') and (`test`.`grandparent1`.`col_int_key` = '8') and (`test`.`parent1`.`col_int_key` = '8') and ('8' <> 3))) where true +SELECT * FROM t3 +WHERE g1 NOT IN +(SELECT grandparent1.col_int_nokey AS g1 +FROM t1 AS grandparent1 +WHERE (grandparent1.col_int_nokey, grandparent1.col_int_key) IN +(SELECT parent1.col_int_key AS p1, +parent1.col_int_key AS p2 +FROM t1 AS parent1 +LEFT JOIN t2 AS parent2 +ON parent1.col_int_nokey = parent2.col_int_key +) +AND grandparent1.col_int_key <> 3 +); +g1 +DROP TABLE t1, t2, t3; +# End of test for bug#13334882. +# +# Bug#13339643: Assertion on JOIN::flatten_subqueries on second execution +# +CREATE TABLE t1 ( +col_int_nokey INT, +col_varchar_nokey VARCHAR(1) +) charset utf8mb4; +INSERT INTO t1 VALUES +(1,'o'), +(2,'t'); +CREATE TABLE t2 LIKE t1; +INSERT INTO t2 VALUES +(1,'o'), +(4,'f'); +CREATE VIEW v_t2 AS SELECT * FROM t2; +CREATE TABLE t3 LIKE t1; +INSERT INTO t3 VALUES +(1,'o'), +(4,'f'); +explain SELECT alias1.col_varchar_nokey +FROM t1 AS alias1 +INNER JOIN v_t2 AS alias2 +ON alias2.col_int_nokey = alias1.col_int_nokey AND +'o' IN (SELECT col_varchar_nokey +FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch +1 SIMPLE alias1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`alias1`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t1` `alias1` join `test`.`t2` semi join (`test`.`t3`) where ((`test`.`t3`.`col_varchar_nokey` = 'o') and (`test`.`t2`.`col_int_nokey` = `test`.`alias1`.`col_int_nokey`)) +SELECT alias1.col_varchar_nokey +FROM t1 AS alias1 +INNER JOIN v_t2 AS alias2 +ON alias2.col_int_nokey = alias1.col_int_nokey AND +'o' IN (SELECT col_varchar_nokey +FROM t3); +col_varchar_nokey +o +PREPARE stmt FROM "SELECT alias1.col_varchar_nokey +FROM t1 AS alias1 +INNER JOIN v_t2 AS alias2 +ON alias2.col_int_nokey = alias1.col_int_nokey AND +'o' IN (SELECT col_varchar_nokey +FROM t3)"; +EXECUTE stmt; +col_varchar_nokey +o +DROP VIEW v_t2; +DROP TABLE t1, t2, t3; +# End of test for bug#13339643. +# +# Bug#13424134: Wrong result on JOIN + nested WHERE ... IN clauses +# +CREATE TABLE t1 ( +pk int NOT NULL, +col_int_nokey int NOT NULL, +col_int_key int NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +) ENGINE=MyIsam; +INSERT INTO t1 VALUES +(10,1,7), (13,7,3), (18,0,1), (23,8,1); +CREATE TABLE t2 ( +pk int NOT NULL, +col_int_key int NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +) ENGINE=MyIsam; +INSERT INTO t2 VALUES (1,7); +EXPLAIN SELECT t1a.* +FROM t1 AS t1a +JOIN t1 AS t1b USING ( col_int_nokey ) +WHERE t1a.col_int_key IN ( +SELECT pk +FROM t2 +WHERE col_int_key IN ( +SELECT col_int_nokey +FROM t1 +) +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL system PRIMARY,col_int_key NULL NULL NULL 1 100.00 NULL +1 SIMPLE t1a NULL ref col_int_key col_int_key 4 const 1 100.00 NULL +1 SIMPLE t1b NULL ALL NULL NULL NULL NULL 4 25.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; FirstMatch(t1b); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1a`.`pk` AS `pk`,`test`.`t1a`.`col_int_nokey` AS `col_int_nokey`,`test`.`t1a`.`col_int_key` AS `col_int_key` from `test`.`t1` `t1a` join `test`.`t1` `t1b` semi join (`test`.`t1`) where ((`test`.`t1b`.`col_int_nokey` = `test`.`t1a`.`col_int_nokey`) and (`test`.`t1a`.`col_int_key` = '1') and (`test`.`t1`.`col_int_nokey` = '7')) +SELECT t1a.* +FROM t1 AS t1a +JOIN t1 AS t1b USING ( col_int_nokey ) +WHERE t1a.col_int_key IN ( +SELECT pk +FROM t2 +WHERE col_int_key IN ( +SELECT col_int_nokey +FROM t1 +) +); +pk col_int_nokey col_int_key +18 0 1 +23 8 1 +ALTER TABLE t1 ENGINE=Innodb; +ALTER TABLE t2 ENGINE=Innodb; +SELECT t1a.* +FROM t1 AS t1a +JOIN t1 AS t1b USING ( col_int_nokey ) +WHERE t1a.col_int_key IN ( +SELECT pk +FROM t2 +WHERE col_int_key IN ( +SELECT col_int_nokey +FROM t1 +) +); +pk col_int_nokey col_int_key +18 0 1 +23 8 1 +DROP TABLE t1, t2; +# End of test for bug#13424134. +# +# Bug#13414014: Extra rows in result on semijoin query with where ... +# +CREATE TABLE t1 ( +c INT, +d INT, +a VARCHAR(1), +b VARCHAR(1), +KEY a (a) +) charset utf8mb4; +INSERT INTO t1 VALUES +(NULL,8,'x','x'), (7,4,'q','q'), (6,8,'c','c'); +CREATE TABLE t2 ( +a VARCHAR(1), +KEY a (a) +) charset utf8mb4; +INSERT INTO t2 VALUES +('c'), (NULL), ('x'), ('q'); +explain SELECT * +FROM t2 AS ot +WHERE (a, a) IN +(SELECT a, b +FROM t1 AS it +WHERE it.a = 'x' OR it.c > it.d +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot NULL index a a 7 NULL 4 100.00 Using index +1 SIMPLE it NULL ALL a NULL NULL NULL 3 33.33 Using where; FirstMatch(ot); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot`.`a` AS `a` from `test`.`t2` `ot` semi join (`test`.`t1` `it`) where ((`test`.`it`.`a` = `test`.`ot`.`a`) and (`test`.`it`.`b` = `test`.`ot`.`a`) and ((`test`.`ot`.`a` = 'x') or (`test`.`it`.`c` > `test`.`it`.`d`))) +SELECT * +FROM t2 AS ot +WHERE (a, a) IN +(SELECT a, b +FROM t1 AS it +WHERE it.a = 'x' OR it.c > it.d +) +; +a +q +x +DROP TABLE t1, t2; +# End of test for bug#13414014. +# +# Bug#13545215: Missing rows on nested in-subquery with materialization +# +CREATE TABLE t1 ( +col_int_key int, +col_varchar_key varchar(1), +col_varchar_nokey varchar(1), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +INSERT INTO t1 VALUES +(8,'x','x'), (0,'p','p'), (8,'c','c'); +CREATE TABLE t2 ( +pk int NOT NULL, +col_varchar_key varchar(1), +col_varchar_nokey varchar(1), +PRIMARY KEY (pk), +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4; +INSERT INTO t2 VALUES +(1,'v','v'), (2,'v','v'), (3,'c','c'), (4,NULL,NULL), +(5,'x','x'), (6,'i','i'), (7,'e','e'), (8,'p','p'); +CREATE TABLE t3 ( +col_int_nokey int +); +INSERT INTO t3 VALUES (7); +explain SELECT grandparent1.col_varchar_nokey +FROM t1 AS grandparent1 JOIN t1 AS grandparent2 USING (col_int_key) +WHERE grandparent1.col_varchar_key IN ( +SELECT col_varchar_nokey +FROM t2 AS parent1 +WHERE col_varchar_key IN ( +SELECT child1.col_varchar_nokey +FROM t2 AS child1 LEFT JOIN t3 AS child2 +ON child1.pk < child2.col_int_nokey +) +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE grandparent1 NULL ALL col_int_key,col_varchar_key NULL NULL NULL 3 100.00 Using where +1 SIMPLE parent1 NULL ALL col_varchar_key NULL NULL NULL 8 12.50 Using where +1 SIMPLE child1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where +1 SIMPLE child2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(grandparent1) +1 SIMPLE grandparent2 NULL ref col_int_key col_int_key 5 test.grandparent1.col_int_key 2 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`grandparent1`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t1` `grandparent1` join `test`.`t1` `grandparent2` semi join (`test`.`t2` `parent1` join `test`.`t2` `child1` left join `test`.`t3` `child2` on((`test`.`child1`.`pk` < `test`.`child2`.`col_int_nokey`))) where ((`test`.`grandparent2`.`col_int_key` = `test`.`grandparent1`.`col_int_key`) and (`test`.`parent1`.`col_varchar_nokey` = `test`.`grandparent1`.`col_varchar_key`) and (`test`.`child1`.`col_varchar_nokey` = `test`.`parent1`.`col_varchar_key`)) +SELECT grandparent1.col_varchar_nokey +FROM t1 AS grandparent1 JOIN t1 AS grandparent2 USING (col_int_key) +WHERE grandparent1.col_varchar_key IN ( +SELECT col_varchar_nokey +FROM t2 AS parent1 +WHERE col_varchar_key IN ( +SELECT child1.col_varchar_nokey +FROM t2 AS child1 LEFT JOIN t3 AS child2 +ON child1.pk < child2.col_int_nokey +) +); +col_varchar_nokey +c +c +p +x +x +DROP TABLE t1, t2, t3; +# End of test for bug#13545215. +# +# BUG#13553211 - MISSING ROWS ON SELECT WITH IN-SUBQUERY AND +# MATERIALIZATION + SEMIJOIN ON +# +CREATE TABLE t1 ( +col_int_key int(11) DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (4,'v','v'); +INSERT INTO t1 VALUES (62,'v','v'); +INSERT INTO t1 VALUES (7,'c','c'); +INSERT INTO t1 VALUES (1,NULL,NULL); +EXPLAIN SELECT +alias1.col_varchar_nokey AS a1_nokey, +alias1.col_varchar_key AS a1_key, +alias2.col_varchar_nokey AS a2_nokey +FROM +t1 AS alias1, t1 AS alias2 +WHERE +(alias1.col_varchar_nokey,alias2.col_varchar_nokey) +IN +( +SELECT +sq2_alias2.col_varchar_nokey, sq2_alias1.col_varchar_key +FROM +t1 AS sq2_alias1, t1 AS sq2_alias2 +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE alias1 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +1 SIMPLE alias2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (hash join) +1 SIMPLE sq2_alias1 NULL ref col_varchar_key col_varchar_key 7 test.alias2.col_varchar_nokey 2 100.00 Using index +1 SIMPLE sq2_alias2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; FirstMatch(alias2) +Warnings: +Note 1003 /* select#1 */ select `test`.`alias1`.`col_varchar_nokey` AS `a1_nokey`,`test`.`alias1`.`col_varchar_key` AS `a1_key`,`test`.`alias2`.`col_varchar_nokey` AS `a2_nokey` from `test`.`t1` `alias1` join `test`.`t1` `alias2` semi join (`test`.`t1` `sq2_alias1` join `test`.`t1` `sq2_alias2`) where ((`test`.`sq2_alias1`.`col_varchar_key` = `test`.`alias2`.`col_varchar_nokey`) and (`test`.`sq2_alias2`.`col_varchar_nokey` = `test`.`alias1`.`col_varchar_nokey`)) +SELECT +alias1.col_varchar_nokey AS a1_nokey, +alias1.col_varchar_key AS a1_key, +alias2.col_varchar_nokey AS a2_nokey +FROM +t1 AS alias1, t1 AS alias2 +WHERE +(alias1.col_varchar_nokey,alias2.col_varchar_nokey) +IN +( +SELECT +sq2_alias2.col_varchar_nokey, sq2_alias1.col_varchar_key +FROM +t1 AS sq2_alias1, t1 AS sq2_alias2 +) +; +a1_nokey a1_key a2_nokey +c c c +c c v +c c v +v v c +v v c +v v v +v v v +v v v +v v v +DROP TABLE t1; +# +# Bug#13541406: Wrong result with loosescan on select .. where .. in +# +CREATE TABLE t1 ( +col_int_key INT NOT NULL, +col_varchar_nokey VARCHAR(1) NOT NULL, +KEY col_int_key (col_int_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t1 VALUES +(7,'v'), (0,'s'), (9,'l'), (3,'y'), (4,'c'), (2,'i'), (5,'h'), (3,'q'), +(1,'a'), (3,'v'), (6,'u'), (7,'s'), (5,'y'), (1,'z'), (204,'h'), (224,'p'), +(9,'e'), (5,'i'), (0,'y'), (3,'w'); +CREATE TABLE t2 ( +pk INT NOT NULL, +col_int_key INT NOT NULL, +col_varchar_key VARCHAR(1) NOT NULL, +col_varchar_nokey VARCHAR(1) NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t2 VALUES +(1,0,'j','j'), (2,8,'v','v'), (3,1,'c','c'), (4,8,'m','m'), +(5,9,'d','d'), (6,24,'d','d'), (7,6,'y','y'), (8,1,'t','t'), +(9,6,'d','d'), (10,2,'s','s'), (11,4,'r','r'), (12,8,'m','m'), +(13,4,'b','b'), (14,4,'x','x'), (15,7,'g','g'), (16,4,'p','p'), +(17,1,'q','q'), (18,9,'w','w'), (19,4,'d','d'), (20,8,'e','e'); +# This query should never use a LooseScan strategy +explain SELECT ot1.col_int_key AS field1 +FROM t2 AS ot1, t2 AS ot2 +WHERE (ot1.col_varchar_key, ot2.col_varchar_nokey) IN ( +SELECT it2.col_varchar_nokey, it1.col_varchar_key +FROM t2 AS it1 JOIN t1 AS it2 ON it2.col_int_key = it1.pk); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 20 100.00 Parallel execute (1 workers) +2 SIMPLE ot1 NULL index col_varchar_key col_varchar_key 10 NULL 20 100.00 Using index +2 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 20 100.00 Using join buffer (hash join) +2 SIMPLE it1 NULL ref PRIMARY,col_varchar_key col_varchar_key 6 test.ot2.col_varchar_nokey 1 100.00 Using index +2 SIMPLE it2 NULL ref col_int_key col_int_key 4 test.it1.pk 1 10.00 Using where; FirstMatch(ot2) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`col_int_key` AS `field1` from `test`.`t2` `ot1` join `test`.`t2` `ot2` semi join (`test`.`t2` `it1` join `test`.`t1` `it2`) where ((`test`.`it2`.`col_int_key` = `test`.`it1`.`pk`) and (`test`.`it1`.`col_varchar_key` = `test`.`ot2`.`col_varchar_nokey`) and (`test`.`it2`.`col_varchar_nokey` = `test`.`ot1`.`col_varchar_key`)) +SELECT ot1.col_int_key AS field1 +FROM t2 AS ot1, t2 AS ot2 +WHERE (ot1.col_varchar_key, ot2.col_varchar_nokey) IN ( +SELECT it2.col_varchar_nokey, it1.col_varchar_key +FROM t2 AS it1 JOIN t1 AS it2 ON it2.col_int_key = it1.pk); +field1 +1 +1 +1 +2 +6 +6 +6 +6 +6 +8 +8 +8 +8 +8 +8 +9 +DROP TABLE t1, t2; +# End of test for bug#13541406. +# +# Bug#13576391: Missing rows on select with in-subquery and +# batched-key-access=on and semijoin +# +CREATE TABLE t1 ( +col_int_nokey int NOT NULL, +col_varchar_key varchar(1) NOT NULL, +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4 engine=InnoDB; +INSERT INTO t1 VALUES +(1,'v'), (7,'s'), (4,'l'), (7,'y'), (0,'c'), (2,'i'), (9,'h'), (4,'q'), +(0,'a'), (9,'v'), (1,'u'), (3,'s'), (8,'y'), (8,'z'), (18,'h'), (84,'p'), +(6,'e'), (3,'i'), (6,'y'), (6,'w'); +CREATE TABLE t2 ( +col_int_nokey int NOT NULL, +col_varchar_nokey varchar(1) NOT NULL +) charset utf8mb4 engine=InnoDB; +INSERT INTO t2 VALUES +(4,'j'), (6,'v'), (3,'c'), (5,'m'), (3,'d'), (246,'d'), (2,'y'), (9,'t'), +(3,'d'), (8,'s'), (1,'r'), (8,'m'), (8,'b'), (5,'x'), (7,'g'), (5,'p'), +(1,'q'), (6,'w'), (2,'d'), (9,'e'); +explain SELECT col_varchar_nokey +FROM t2 AS ot +WHERE col_varchar_nokey IN ( +SELECT col_varchar_key +FROM t1 AS it +WHERE it.col_int_nokey <= it.col_int_nokey +AND NOT ot.col_int_nokey < 2 +) +ORDER BY col_varchar_nokey; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 20 33.33 Parallel execute (1 workers) +2 SIMPLE ot NULL ALL NULL NULL NULL NULL 20 33.33 Using where; Using filesort +2 SIMPLE it NULL ref col_varchar_key col_varchar_key 6 test.ot.col_varchar_nokey 1 100.00 FirstMatch(ot) +Warnings: +Note 1276 Field or reference 'test.ot.col_int_nokey' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`ot`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t2` `ot` semi join (`test`.`t1` `it`) where ((`test`.`it`.`col_varchar_key` = `test`.`ot`.`col_varchar_nokey`) and (`test`.`ot`.`col_int_nokey` >= 2)) order by `test`.`ot`.`col_varchar_nokey` +SELECT col_varchar_nokey +FROM t2 AS ot +WHERE col_varchar_nokey IN ( +SELECT col_varchar_key +FROM t1 AS it +WHERE it.col_int_nokey <= it.col_int_nokey +AND NOT ot.col_int_nokey < 2 +) +ORDER BY col_varchar_nokey; +col_varchar_nokey +c +e +p +s +v +w +y +ALTER TABLE t1 ENGINE=MyISAM; +ALTER TABLE t2 ENGINE=MyISAM; +explain SELECT col_varchar_nokey +FROM t2 AS ot +WHERE col_varchar_nokey IN ( +SELECT col_varchar_key +FROM t1 AS it +WHERE it.col_int_nokey <= it.col_int_nokey +AND NOT ot.col_int_nokey < 2 +) +ORDER BY col_varchar_nokey; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 20 33.33 Using where; Using filesort +1 SIMPLE it NULL ref col_varchar_key col_varchar_key 6 test.ot.col_varchar_nokey 2 100.00 FirstMatch(ot) +Warnings: +Note 1276 Field or reference 'test.ot.col_int_nokey' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`ot`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t2` `ot` semi join (`test`.`t1` `it`) where ((`test`.`it`.`col_varchar_key` = `test`.`ot`.`col_varchar_nokey`) and (`test`.`ot`.`col_int_nokey` >= 2)) order by `test`.`ot`.`col_varchar_nokey` +SELECT col_varchar_nokey +FROM t2 AS ot +WHERE col_varchar_nokey IN ( +SELECT col_varchar_key +FROM t1 AS it +WHERE it.col_int_nokey <= it.col_int_nokey +AND NOT ot.col_int_nokey < 2 +) +ORDER BY col_varchar_nokey; +col_varchar_nokey +c +e +p +s +v +w +y +ALTER TABLE t1 ENGINE=Memory; +ALTER TABLE t2 ENGINE=Memory; +explain SELECT col_varchar_nokey +FROM t2 AS ot +WHERE col_varchar_nokey IN ( +SELECT col_varchar_key +FROM t1 AS it +WHERE it.col_int_nokey <= it.col_int_nokey +AND NOT ot.col_int_nokey < 2 +) +ORDER BY col_varchar_nokey; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 20 33.33 Using where; Using filesort +1 SIMPLE it NULL ref col_varchar_key col_varchar_key 6 test.ot.col_varchar_nokey 2 100.00 FirstMatch(ot) +Warnings: +Note 1276 Field or reference 'test.ot.col_int_nokey' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`ot`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t2` `ot` semi join (`test`.`t1` `it`) where ((`test`.`it`.`col_varchar_key` = `test`.`ot`.`col_varchar_nokey`) and (`test`.`ot`.`col_int_nokey` >= 2)) order by `test`.`ot`.`col_varchar_nokey` +SELECT col_varchar_nokey +FROM t2 AS ot +WHERE col_varchar_nokey IN ( +SELECT col_varchar_key +FROM t1 AS it +WHERE it.col_int_nokey <= it.col_int_nokey +AND NOT ot.col_int_nokey < 2 +) +ORDER BY col_varchar_nokey; +col_varchar_nokey +c +e +p +s +v +w +y +DROP TABLE t1, t2; +# End of test for bug#13576391. +# +# Bug #13589848 "MISSING ROW ON SELECT WITH NESTED IN CLAUSES WHEN LOOSESCAN=ON" +# +CREATE TABLE t1 ( +id INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +KEY (col_varchar_key) +) charset utf8mb4; +INSERT INTO t1 VALUES (100,'m','m'), +(200,'b','b'), (300,'x','x'); +CREATE TABLE t2 ( +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +KEY (col_varchar_key) +) charset utf8mb4; +INSERT INTO t2 VALUES ('b','b'); +CREATE TABLE t3 ( +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +KEY (col_varchar_key) +) charset utf8mb4; +INSERT INTO t3 VALUES ('k','k'); +EXPLAIN SELECT gp1.id +FROM t1 AS gp1 JOIN t3 AS gp2 +ON gp2.col_varchar_key <> gp1.col_varchar_nokey +WHERE (gp1.col_varchar_nokey, gp1.col_varchar_nokey) +IN ( +SELECT col_varchar_nokey, col_varchar_nokey +FROM t1 +WHERE col_varchar_nokey +IN ( SELECT col_varchar_key +FROM t2 LEFT JOIN t3 USING (col_varchar_key) ) +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE gp2 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE gp1 NULL ALL NULL NULL NULL NULL 3 66.67 Using where +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +1 SIMPLE t2 NULL ref col_varchar_key col_varchar_key 7 test.gp1.col_varchar_nokey 2 100.00 Using index +1 SIMPLE t3 NULL ref col_varchar_key col_varchar_key 7 test.gp1.col_varchar_nokey 2 100.00 Using where; Using index; FirstMatch(gp1) +Warnings: +Note 1003 /* select#1 */ select `test`.`gp1`.`id` AS `id` from `test`.`t1` `gp1` semi join (`test`.`t1` join `test`.`t2` left join `test`.`t3` on((`test`.`t2`.`col_varchar_key` = `test`.`t3`.`col_varchar_key`))) where ((`test`.`t1`.`col_varchar_nokey` = `test`.`gp1`.`col_varchar_nokey`) and (`test`.`t2`.`col_varchar_key` = `test`.`gp1`.`col_varchar_nokey`) and ('k' <> `test`.`gp1`.`col_varchar_nokey`)) +SELECT gp1.id +FROM t1 AS gp1 JOIN t3 AS gp2 +ON gp2.col_varchar_key <> gp1.col_varchar_nokey +WHERE (gp1.col_varchar_nokey, gp1.col_varchar_nokey) +IN ( +SELECT col_varchar_nokey, col_varchar_nokey +FROM t1 +WHERE col_varchar_nokey +IN ( SELECT col_varchar_key +FROM t2 LEFT JOIN t3 USING (col_varchar_key) ) +) +; +id +200 +DROP TABLE t1,t2,t3; +# +# Bug #13596176: Missing row on select with nested in clause when +# matr=on and bnl=off + MyISAM +# +CREATE TABLE t1 ( +int_key int DEFAULT NULL, +vc_key varchar(1) DEFAULT NULL, +vc_nokey varchar(1) DEFAULT NULL, +KEY int_key (int_key), +KEY vc_key (vc_key, int_key) +) charset utf8mb4 ENGINE=MyISAM; +INSERT INTO t1 VALUES +(8,'x','x'), (7,'d','d'), (1,'r','r'), (7,'f','f'), +(9,'y','y'), (NULL,'u','u'), (1,'m','m'), (9,NULL,NULL), +(2,'o','o'), (9,'w','w'), (2,'m','m'), (4,'q','q'), +(0,NULL,NULL), (4,'d','d'), (8,'g','g'), (NULL,'x','x'), +(NULL,'f','f'), (0,'p','p'), (NULL,'j','j'), (8,'c','c'); +CREATE TABLE t2 ( +int_key int DEFAULT NULL, +vc_key varchar(1) DEFAULT NULL, +KEY int_key (int_key), +KEY vc_key (vc_key, int_key) +) charset utf8mb4 ENGINE=MyISAM; +INSERT INTO t2 VALUES (8,'g'); +explain SELECT vc_key +FROM t1 as outr +WHERE (vc_nokey, vc_key ) IN +(SELECT vc_nokey, vc_nokey +FROM t1 middle +WHERE vc_nokey IN +(SELECT child1.vc_key +FROM t2 AS child1 JOIN t1 AS child2 USING (int_key) +) +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE outr NULL ALL vc_key NULL NULL NULL 20 100.00 Using where +1 SIMPLE middle NULL ALL NULL NULL NULL NULL 20 10.00 Using where +1 SIMPLE child1 NULL ref int_key,vc_key vc_key 7 test.outr.vc_nokey 2 100.00 Using where; Using index +1 SIMPLE child2 NULL ref int_key int_key 5 test.child1.int_key 3 100.00 Using index; FirstMatch(outr) +Warnings: +Note 1003 /* select#1 */ select `test`.`outr`.`vc_key` AS `vc_key` from `test`.`t1` `outr` semi join (`test`.`t1` `middle` join `test`.`t2` `child1` join `test`.`t1` `child2`) where ((`test`.`child2`.`int_key` = `test`.`child1`.`int_key`) and (`test`.`outr`.`vc_key` = `test`.`outr`.`vc_nokey`) and (`test`.`middle`.`vc_nokey` = `test`.`outr`.`vc_nokey`) and (`test`.`child1`.`vc_key` = `test`.`outr`.`vc_nokey`)) +SELECT vc_key +FROM t1 as outr +WHERE (vc_nokey, vc_key ) IN +(SELECT vc_nokey, vc_nokey +FROM t1 middle +WHERE vc_nokey IN +(SELECT child1.vc_key +FROM t2 AS child1 JOIN t1 AS child2 USING (int_key) +) +); +vc_key +g +DROP TABLE t1, t2; +# End of test for bug#13596176. +# +# BUG#11754478: MAX/MIN + SUBQUERY + AND FAILS TO RETURN ANY ROWS +# BUG#13599013: MAX/MIN + SUBQUERY IN WHERE CLAUSE MATCHING NO +# ROWS + INDEX DOES NOT RETURN NULL +# +CREATE TABLE t1 ( +pk int(11) PRIMARY KEY, +int_key int(11), +KEY int_key (int_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (1,0),(2,0),(3,2),(4,0),(5,3),(6,0); +SELECT MIN(int_key) FROM t1 WHERE (4, 4) IN (SELECT 1, 2); +MIN(int_key) +NULL +SELECT MIN(int_key) FROM t1 WHERE (4, 4) IN (SELECT 4, 4); +MIN(int_key) +0 +SELECT MIN(pk) FROM t1 WHERE pk IN (SELECT int_key FROM t1) AND pk = 6; +MIN(pk) +NULL +DROP TABLE t1; +# BUG#13726217: Crash in Item_ident::fix_after_pullout() +CREATE TABLE t1(a INTEGER) engine=innodb; +INSERT INTO t1 VALUES (0); +SELECT 0 +FROM t1 +WHERE 0 IN +(SELECT 0 +FROM t1 +WHERE 0 LIKE +(SELECT elt(a, 0) AS b +FROM t1 +GROUP BY a +HAVING b +) +); +0 +DROP TABLE t1; +# End of test for bug#13726217. +# BUG#13773979: Missing rows on second execution of prepared statement +CREATE TABLE t1 ( +col_int_nokey INT, +col_int_key INT, +col_varchar_key VARCHAR(1) +); +INSERT INTO t1 VALUES +(1,7,'v'), (7,0,'s'), (4,9,'l'), (7,3,'y'), +(2,2,'i'), (9,5,'h'), (0,1,'a'), (9,3,'v'); +CREATE VIEW v1 AS SELECT * FROM t1; +SELECT * +FROM t1 +WHERE col_int_key IN ( +SELECT alias1.col_int_nokey AS field1 +FROM v1 AS alias1 +WHERE alias1.col_varchar_key < 'v' +); +col_int_nokey col_int_key col_varchar_key +1 7 v +2 2 i +4 9 l +7 0 s +prepare stmt FROM "SELECT * +FROM t1 +WHERE col_int_key IN ( +SELECT alias1.col_int_nokey AS field1 +FROM v1 AS alias1 +WHERE alias1.col_varchar_key < 'v' +)"; +execute stmt; +col_int_nokey col_int_key col_varchar_key +1 7 v +2 2 i +4 9 l +7 0 s +execute stmt; +col_int_nokey col_int_key col_varchar_key +1 7 v +2 2 i +4 9 l +7 0 s +DEALLOCATE PREPARE stmt; +DROP VIEW v1; +DROP TABLE t1; +# End of test for bug#13773979. +# +# BUG#13685026 ASSERTION CUR_SJ_INNER_TABLES == 0 IN +# --OPTIMIZE_TABLE_ORDER::CHOOSE_TABLE_ORDER +# +CREATE TABLE t1 ( +col_int_key INT(11) NOT NULL, +col_datetime_key DATETIME NOT NULL, +col_varchar_key VARCHAR(1) NOT NULL, +col_varchar_nokey VARCHAR(1) NOT NULL, +KEY col_int_key (col_int_key), +KEY col_datetime_key (col_datetime_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (0,'2002-02-13 17:30:06','j','j'); +INSERT INTO t1 VALUES (8,'2008-09-27 00:34:58','v','v'); +CREATE TABLE t2 ( +col_int_key INT(11) NOT NULL, +col_datetime_key DATETIME NOT NULL, +col_varchar_key VARCHAR(1) NOT NULL, +col_varchar_nokey VARCHAR(1) NOT NULL, +KEY col_int_key (col_int_key), +KEY col_datetime_key (col_datetime_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (7,'2003-08-21 00:00:00','b','b'); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +SET @old_depth=@@optimizer_search_depth; +SET optimizer_search_depth=4; +EXPLAIN SELECT col_datetime_key +FROM t1 as outr +WHERE col_datetime_key IN ( +SELECT alias1.col_datetime_key +FROM t1 AS alias1 +LEFT JOIN t1 as alias3 +STRAIGHT_JOIN ( t2 AS alias4 +JOIN t1 AS alias5 +ON alias5.col_varchar_key <= alias4.col_varchar_nokey ) +ON alias5.col_int_key < alias4.col_int_key +ON alias5.col_varchar_key = alias4.col_varchar_key +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE outr NULL index col_datetime_key col_datetime_key 5 NULL 2 100.00 Using index +1 SIMPLE alias1 NULL ref col_datetime_key col_datetime_key 5 test.outr.col_datetime_key 1 100.00 Using index +1 SIMPLE alias4 NULL ALL col_int_key,col_varchar_key NULL NULL NULL 1 100.00 NULL +1 SIMPLE alias5 NULL ref col_int_key,col_varchar_key col_varchar_key 6 test.alias4.col_varchar_key 1 100.00 Using where; Using index +1 SIMPLE alias3 NULL index NULL col_int_key 4 NULL 2 100.00 Using index; FirstMatch(outr) +Warnings: +Note 1003 /* select#1 */ select `test`.`outr`.`col_datetime_key` AS `col_datetime_key` from `test`.`t1` `outr` semi join (`test`.`t1` `alias1` left join (`test`.`t1` `alias3` join `test`.`t2` `alias4` join `test`.`t1` `alias5`) on(((`test`.`alias5`.`col_varchar_key` = `test`.`alias4`.`col_varchar_key`) and (`test`.`alias5`.`col_int_key` < `test`.`alias4`.`col_int_key`) and (`test`.`alias5`.`col_varchar_key` <= `test`.`alias4`.`col_varchar_nokey`)))) where (`test`.`alias1`.`col_datetime_key` = `test`.`outr`.`col_datetime_key`) +SELECT col_datetime_key +FROM t1 as outr +WHERE col_datetime_key IN ( +SELECT alias1.col_datetime_key +FROM t1 AS alias1 +LEFT JOIN t1 as alias3 +STRAIGHT_JOIN ( t2 AS alias4 +JOIN t1 AS alias5 +ON alias5.col_varchar_key <= alias4.col_varchar_nokey ) +ON alias5.col_int_key < alias4.col_int_key +ON alias5.col_varchar_key = alias4.col_varchar_key +); +col_datetime_key +2002-02-13 17:30:06 +2008-09-27 00:34:58 +DROP TABLE t1,t2; +SET @@optimizer_search_depth=@old_depth; +# +# BUG#13848789: SEGFAULT IN JOIN_READ_NEXT_SAME AT +# SQL/SQL_EXECUTOR.CC ON HAVING...IN...JOIN +# +CREATE TABLE t1 ( +col_int_key INT, +col_varchar_key VARCHAR(1), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4; +INSERT INTO t1 VALUES (8,'x'); +CREATE TABLE t2 ( +col_varchar_key VARCHAR(1), +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4; +INSERT INTO t2 VALUES ('x'), ('y'); +explain SELECT MIN(col_int_key) +FROM t1 as t1_outer +HAVING (1, 2) IN ( +SELECT t1_inner.col_int_key, MAX(t1_inner.col_int_key) +FROM t1 as t1_inner JOIN t2 +ON t2.col_varchar_key = t1_inner.col_varchar_key +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible HAVING +2 SUBQUERY t1_inner NULL system col_varchar_key NULL NULL NULL 1 100.00 NULL +2 SUBQUERY t2 NULL ref col_varchar_key col_varchar_key 7 const 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select min(`test`.`t1_outer`.`col_int_key`) AS `MIN(col_int_key)` from `test`.`t1` `t1_outer` having false +SELECT MIN(col_int_key) +FROM t1 as t1_outer +HAVING (1, 2) IN ( +SELECT t1_inner.col_int_key, MAX(t1_inner.col_int_key) +FROM t1 as t1_inner JOIN t2 +ON t2.col_varchar_key = t1_inner.col_varchar_key +); +MIN(col_int_key) +DROP TABLE t1,t2; +# Bug#13838810: Segfault in evaluate_null_complemented_join_record +CREATE TABLE t1 ( +pk int NOT NULL, +col_int_nokey int DEFAULT NULL, +col_int_key int DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t1 VALUES (10,NULL,8,'x'); +CREATE TABLE t2 ( +pk int NOT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +PRIMARY KEY (pk) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t2 VALUES (1,'x'); +CREATE TABLE t3 ( +pk int NOT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +PRIMARY KEY (pk), +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t3 VALUES +(1,'v','v'), (2,'v','v'), (3,'c','c'), (4,NULL,NULL); +EXPLAIN SELECT table1.pk,table2.pk, table3.pk +FROM t2 AS table1 +LEFT JOIN t1 AS table2 +LEFT JOIN t1 AS table3 +ON table3.col_int_key = table2.col_int_key +ON table3.pk = table2.col_int_nokey AND +table1.col_varchar_nokey IN ( +SELECT subquery3_t1.col_varchar_nokey +FROM t3 AS subquery3_t1 +LEFT JOIN t1 AS subquery3_t2 +ON subquery3_t2.col_varchar_key = subquery3_t1.col_varchar_key +WHERE subquery3_t2.col_int_nokey <> 9 +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE table1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE table2 NULL ALL col_int_key NULL NULL NULL 1 100.00 NULL +2 SIMPLE table3 NULL eq_ref PRIMARY,col_int_key PRIMARY 4 test.table2.col_int_nokey 1 100.00 Using where +2 SIMPLE subquery3_t2 NULL ALL col_varchar_key NULL NULL NULL 1 100.00 Using where +2 SIMPLE subquery3_t1 NULL ref col_varchar_key col_varchar_key 7 test.subquery3_t2.col_varchar_key 1 100.00 Using where; FirstMatch(table3) +Warnings: +Note 1003 /* select#1 */ select `test`.`table1`.`pk` AS `pk`,`test`.`table2`.`pk` AS `pk`,`test`.`table3`.`pk` AS `pk` from `test`.`t2` `table1` left join (`test`.`t1` `table2` join `test`.`t1` `table3` semi join (`test`.`t3` `subquery3_t1` join `test`.`t1` `subquery3_t2`)) on(((`test`.`table3`.`col_int_key` = `test`.`table2`.`col_int_key`) and (`test`.`subquery3_t1`.`col_varchar_key` = `test`.`subquery3_t2`.`col_varchar_key`) and (`test`.`subquery3_t1`.`col_varchar_nokey` = `test`.`table1`.`col_varchar_nokey`) and (`test`.`table3`.`pk` = `test`.`table2`.`col_int_nokey`) and (`test`.`subquery3_t2`.`col_int_nokey` <> 9))) where true +SELECT table1.pk,table2.pk, table3.pk +FROM t2 AS table1 +LEFT JOIN t1 AS table2 +LEFT JOIN t1 AS table3 +ON table3.col_int_key = table2.col_int_key +ON table3.pk = table2.col_int_nokey AND +table1.col_varchar_nokey IN ( +SELECT subquery3_t1.col_varchar_nokey +FROM t3 AS subquery3_t1 +LEFT JOIN t1 AS subquery3_t2 +ON subquery3_t2.col_varchar_key = subquery3_t1.col_varchar_key +WHERE subquery3_t2.col_int_nokey <> 9 +) +; +pk pk pk +1 NULL NULL +DROP TABLE t1, t2, t3; +Extra test case for specific code coverage +CREATE TABLE t1(pk INTEGER); +INSERT INTO t1 VALUES(1), (2); +explain SELECT * +FROM t1 AS ot1 LEFT JOIN t1 AS ot2 +ON ot1.pk=ot2.pk AND +ot2.pk IN +(SELECT it1.pk +FROM t1 AS it1 LEFT JOIN t1 AS it2 ON it1.pk=it2.pk); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE it1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE it2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch(ot2) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`pk` AS `pk`,`test`.`ot2`.`pk` AS `pk` from `test`.`t1` `ot1` left join (`test`.`t1` `ot2` semi join (`test`.`t1` `it1` left join `test`.`t1` `it2` on((`test`.`it1`.`pk` = `test`.`it2`.`pk`)))) on(((`test`.`ot2`.`pk` = `test`.`ot1`.`pk`) and (`test`.`it1`.`pk` = `test`.`ot1`.`pk`))) where true +SELECT * +FROM t1 AS ot1 LEFT JOIN t1 AS ot2 +ON ot1.pk=ot2.pk AND +ot2.pk IN +(SELECT it1.pk +FROM t1 AS it1 LEFT JOIN t1 AS it2 ON it1.pk=it2.pk); +pk pk +1 1 +2 2 +DROP TABLE t1; +# End of test for bug#13838810. +# +# Bug#13845930: Segfault in st_join_table::and_with_condition +# +CREATE TABLE t1 ( +col_int INTEGER +); +CREATE TABLE t2 ( +col_varchar_1 VARCHAR(1), +col_varchar_2 VARCHAR(1) +); +INSERT INTO t2 VALUES ('x','x'), ('c','c'); +PREPARE stmt FROM ' +SELECT alias2.col_varchar_2 AS field1 +FROM t2 AS alias1 + JOIN + (t2 AS alias2 + LEFT JOIN t2 AS alias3 + ON (8, 92) IN + (SELECT sq1_alias1.col_int, + sq1_alias2.col_int + FROM t1 AS sq1_alias1 JOIN t1 AS sq1_alias2 + ) + ) + ON alias3.col_varchar_1 = alias2.col_varchar_2 +'; +EXECUTE stmt; +field1 + +EXECUTE stmt; +field1 +DEALLOCATE prepare stmt; +DROP TABLE t1, t2; +# End of test for bug#13845930. +# +# Bug#13855925: Assert 'prebuilt->search_tuple->n_fields > 0' +# in ha_innobase::index_read +# +CREATE TABLE t1 ( +pk INTEGER AUTO_INCREMENT, +col_int_nokey INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk), +KEY (col_varchar_key) +) charset utf8mb4 ENGINE=INNODB; +INSERT INTO t1 ( +col_int_key, col_int_nokey, +col_varchar_key, col_varchar_nokey +) VALUES +(4, 2, 'v','v'), (62, 150, 'v','v'), (7, NULL, 'c','c'), (1, 2, NULL, NULL), +(0, 5, 'x','x'), (7, 3, 'i','i'), (7, 1, 'e','e'), (1, 4, 'p','p'), +(7, NULL, 's','s'), (1, 2, 'j','j'), (5, 6, 'z','z'), (2, 6, 'c','c'), +(0, 8, 'a','a'), (1, 2, 'q','q'), (8, 6, 'y','y'), (1, 8, NULL, NULL), +(1, 3, 'r','r'), (9, 3, 'v','v'), (1, 9, NULL, NULL), (5, 6, 'r','r'); +CREATE TABLE t2 ( +pk INT AUTO_INCREMENT, +col_int_nokey INT, +col_int_key INT, +PRIMARY KEY (pk), +KEY (col_int_key) +) charset utf8mb4 AUTO_INCREMENT=10 ENGINE=INNODB; +INSERT INTO t2 (col_int_key, col_int_nokey) VALUES +(8, NULL), (7, 8), (1, 1), (7, 9), (9, 4), (NULL, 3), (1, 2), (9, NULL), +(2, 2), (9, NULL), (2, 6), (4, 7), (0, 2), (4, 5), (8, 7), (NULL, 6), +(NULL, 6), (0, 2), (NULL, 9), (8, 6); +CREATE TABLE t3 ( +pk INT AUTO_INCREMENT, +col_varchar_key VARCHAR(1), +PRIMARY KEY (pk), +KEY (col_varchar_key) +) charset utf8mb4 ENGINE=INNODB; +INSERT INTO t3 (col_varchar_key) VALUES +('c'), ('c'), ('q'), ('g'), ('e'), ('l'), (NULL), ('c'), ('h'), ('d'), +('c'), ('i'), ('t'), ('g'), ('q'), ('l'), ('n'), ('z'), ('n'), ('r'), ('p'); +CREATE VIEW v1 AS +SELECT table2.col_varchar_nokey AS field1 +FROM t2 AS table1 +INNER JOIN (t1 AS table2 +STRAIGHT_JOIN t2 AS table3 +ON table3.col_int_key = table2.pk AND +table3.col_int_nokey = ANY +(SELECT subquery1_t2.col_int_nokey AS subquery1_field1 +FROM t2 AS subquery1_t1 +RIGHT OUTER JOIN t1 AS subquery1_t2 +INNER JOIN t1 AS subquery1_t3 +ON subquery1_t3.col_int_key = subquery1_t2.pk +ON subquery1_t3.col_varchar_key=subquery1_t2.col_varchar_nokey +WHERE subquery1_t1.pk > 1 +) +) +ON table3.col_int_key IN +(SELECT subquery2_t1.col_int_key AS subquery2_field1 +FROM t2 AS subquery2_t1 +RIGHT OUTER JOIN t3 AS subquery2_t2 +LEFT OUTER JOIN t1 AS subquery2_t3 +ON subquery2_t3.col_varchar_key = subquery2_t2.col_varchar_key +ON subquery2_t3.pk = subquery2_t2.pk +) +; +explain SELECT * FROM v1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE table1 NULL index NULL col_int_key 5 NULL 20 100.00 Using index +1 SIMPLE table2 NULL ALL PRIMARY NULL NULL NULL 20 100.00 Using join buffer (hash join) +1 SIMPLE table3 NULL ref col_int_key col_int_key 5 test.table2.pk 2 100.00 NULL +1 SIMPLE subquery1_t2 NULL ALL PRIMARY NULL NULL NULL 20 10.00 Using where +1 SIMPLE subquery1_t3 NULL ref col_varchar_key col_varchar_key 7 test.subquery1_t2.col_varchar_nokey 1 10.00 Using where +1 SIMPLE subquery1_t1 NULL index PRIMARY col_int_key 5 NULL 20 100.00 Using where; Using index; FirstMatch(table3) +1 SIMPLE subquery2_t3 NULL index PRIMARY,col_varchar_key col_varchar_key 7 NULL 20 100.00 Using where; Using index +1 SIMPLE subquery2_t2 NULL eq_ref PRIMARY,col_varchar_key PRIMARY 4 test.subquery2_t3.pk 1 7.14 Using where +1 SIMPLE subquery2_t1 NULL ref col_int_key col_int_key 5 test.table2.pk 2 100.00 Using index; FirstMatch(subquery1_t1) +Warnings: +Note 1003 /* select#1 */ select `table2`.`col_varchar_nokey` AS `field1` from `test`.`t2` `table1` join `test`.`t1` `table2` straight_join `test`.`t2` `table3` semi join (`test`.`t1` `subquery1_t2` join `test`.`t1` `subquery1_t3` join `test`.`t2` `subquery1_t1`) semi join (`test`.`t3` `subquery2_t2` join `test`.`t1` `subquery2_t3` join `test`.`t2` `subquery2_t1`) where ((`subquery1_t3`.`col_int_key` = `subquery1_t2`.`pk`) and (`subquery1_t3`.`col_varchar_key` = `subquery1_t2`.`col_varchar_nokey`) and (`subquery2_t2`.`col_varchar_key` = `subquery2_t3`.`col_varchar_key`) and (`subquery2_t2`.`pk` = `subquery2_t3`.`pk`) and (`table3`.`col_int_key` = `table2`.`pk`) and (`subquery2_t1`.`col_int_key` = `table2`.`pk`) and (`subquery1_t2`.`col_int_nokey` = `table3`.`col_int_nokey`) and (`subquery1_t1`.`pk` > 1)) +SELECT * FROM v1; +field1 +v +v +v +v +v +v +v +v +v +v +v +v +v +v +v +v +v +v +v +v +DROP VIEW v1; +DROP TABLE t1,t2,t3; +# End of test for bug#13855925. +# +# Bug#13897959: Segfault in setup_semijoin_dups_elimination() +# +CREATE TABLE t1 ( +col_datetime_key DATETIME DEFAULT NULL, +KEY col_datetime_key (col_datetime_key) +) ENGINE=MyISAM; +INSERT INTO t1 VALUES +('2001-04-18 00:00:00'), ('2008-12-18 19:39:55'), +('2000-08-01 12:19:39'), ('2004-09-25 21:29:06'), +('2009-09-20 09:11:48'), ('2004-03-27 09:32:04'); +CREATE TABLE t2 ( +col_date_nokey date DEFAULT NULL, +col_time_key time DEFAULT NULL, +col_datetime_key datetime DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +KEY col_time_key (col_time_key), +KEY col_datetime_key (col_datetime_key), +KEY col_varchar_key(col_varchar_key) +) ENGINE=MyISAM; +INSERT INTO t2 VALUES ('1900-01-01',NULL,'2001-11-04 19:07:55','x','x'); +SELECT grandparent1.col_varchar_nokey +FROM t2 AS grandparent1 LEFT JOIN t1 USING (col_datetime_key) +WHERE grandparent1.col_varchar_nokey IN ( +SELECT col_varchar_nokey +FROM t2 AS parent1 +WHERE parent1.col_time_key > grandparent1.col_date_nokey +); +col_varchar_nokey +DROP TABLE t1, t2; +# End of test for bug#13897959. +# +# Bug#13898625 ASSERT `(REMAINING_TABLES_AFTER != 0) ...' IN +# BEST_EXTENSION_BY_LIMITED_SEARCH +# +CREATE TABLE t1 ( +pk int(11) NOT NULL, +col_int_nokey INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (26,6,NULL,'f','f'); +INSERT INTO t1 VALUES (29,6,8,'c','c'); +CREATE TABLE t2 ( +pk INT NOT NULL, +col_int_nokey INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +INSERT INTO t2 VALUES (1,2,4,'v','v'); +INSERT INTO t2 VALUES (2,150,62,'v','v'); +INSERT INTO t2 VALUES (5,5,0,'x','x'); +INSERT INTO t2 VALUES (6,3,7,'i','i'); +INSERT INTO t2 VALUES (7,1,7,'e','e'); +CREATE VIEW view_c AS SELECT * FROM t2; +PREPARE prep_stmt_7430 FROM 'SELECT SUM( alias1.col_varchar_key ) AS field1 +FROM t1 AS alias1 +RIGHT JOIN t2 AS alias2 +INNER JOIN t1 AS alias3 +ON (alias3.col_varchar_key = alias2.col_varchar_key ) +ON ( "v" ) IN ( +SELECT sq1_alias1.col_varchar_nokey AS sq1_field1 +FROM t1 AS sq1_alias1 +) +WHERE alias3.pk IN ( +SELECT sq2_alias1.col_int_key AS sq2_field1 +FROM ( view_c AS sq2_alias1, t1 AS sq2_alias2 ) +) +'; +EXECUTE prep_stmt_7430; +field1 +NULL +EXECUTE prep_stmt_7430; +field1 +NULL +EXPLAIN SELECT SUM( alias1.col_varchar_key ) AS field1 +FROM t1 AS alias1 +RIGHT JOIN t2 AS alias2 +INNER JOIN t1 AS alias3 +ON (alias3.col_varchar_key = alias2.col_varchar_key ) +ON ( "v" ) IN ( +SELECT sq1_alias1.col_varchar_nokey AS sq1_field1 +FROM t1 AS sq1_alias1 +) +WHERE alias3.pk IN ( +SELECT sq2_alias1.col_int_key AS sq2_field1 +FROM ( view_c AS sq2_alias1, t1 AS sq2_alias2 ) +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE alias3 NULL ALL PRIMARY,col_varchar_key NULL NULL NULL 2 100.00 Using where +1 SIMPLE sq2_alias2 NULL index NULL PRIMARY 4 NULL 2 100.00 Using index +1 SIMPLE t2 NULL ref col_int_key col_int_key 5 test.alias3.pk 2 100.00 Using index; FirstMatch(alias3) +1 SIMPLE alias2 NULL ref col_varchar_key col_varchar_key 7 test.alias3.col_varchar_key 2 100.00 Using index +1 SIMPLE alias1 NULL index NULL col_varchar_key 12 NULL 2 100.00 Using index +1 SIMPLE sq1_alias1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch(alias1) +Warnings: +Note 1003 /* select#1 */ select sum(`test`.`alias1`.`col_varchar_key`) AS `field1` from `test`.`t2` `alias2` join `test`.`t1` `alias3` left join (`test`.`t1` `alias1` semi join (`test`.`t1` `sq1_alias1`)) on(((`test`.`sq1_alias1`.`col_varchar_nokey` = 'v'))) semi join (`test`.`t2` join `test`.`t1` `sq2_alias2`) where ((`test`.`alias2`.`col_varchar_key` = `test`.`alias3`.`col_varchar_key`) and (`test`.`t2`.`col_int_key` = `test`.`alias3`.`pk`)) +PREPARE prep_stmt_7430 FROM 'SELECT SUM( alias1.col_varchar_key ) AS field1 +FROM t1 AS alias1 +RIGHT JOIN t2 AS alias2 +INNER JOIN t1 AS alias3 +ON (alias3.col_varchar_key = alias2.col_varchar_key ) +ON ( "v" ) IN ( +SELECT sq1_alias1.col_varchar_nokey AS sq1_field1 +FROM t1 AS sq1_alias1 +) +WHERE alias3.pk IN ( +SELECT sq2_alias1.col_int_key AS sq2_field1 +FROM ( view_c AS sq2_alias1 , t1 AS sq2_alias2 ) +WHERE sq2_alias1.col_varchar_nokey <> alias2.col_varchar_key +AND sq2_alias1.col_varchar_key < "l" + ) +'; +EXECUTE prep_stmt_7430; +field1 +NULL +EXECUTE prep_stmt_7430; +field1 +NULL +EXPLAIN SELECT SUM( alias1.col_varchar_key ) AS field1 +FROM t1 AS alias1 +RIGHT JOIN t2 AS alias2 +INNER JOIN t1 AS alias3 +ON (alias3.col_varchar_key = alias2.col_varchar_key ) +ON ( "v" ) IN ( +SELECT sq1_alias1.col_varchar_nokey AS sq1_field1 +FROM t1 AS sq1_alias1 +) +WHERE alias3.pk IN ( +SELECT sq2_alias1.col_int_key AS sq2_field1 +FROM ( view_c AS sq2_alias1 , t1 AS sq2_alias2 ) +WHERE sq2_alias1.col_varchar_nokey <> alias2.col_varchar_key +AND sq2_alias1.col_varchar_key < "l" + ) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE alias3 NULL ALL PRIMARY,col_varchar_key NULL NULL NULL 2 100.00 Using where +1 SIMPLE alias2 NULL ref col_varchar_key col_varchar_key 7 test.alias3.col_varchar_key 2 100.00 Using index +1 SIMPLE t2 NULL ref col_int_key,col_varchar_key col_int_key 5 test.alias3.pk 2 32.00 Using where +1 SIMPLE sq2_alias2 NULL index NULL PRIMARY 4 NULL 2 100.00 Using index; FirstMatch(alias2) +1 SIMPLE alias1 NULL index NULL col_varchar_key 12 NULL 2 100.00 Using index +1 SIMPLE sq1_alias1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch(alias1) +Warnings: +Note 1276 Field or reference 'test.alias2.col_varchar_key' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select sum(`test`.`alias1`.`col_varchar_key`) AS `field1` from `test`.`t2` `alias2` join `test`.`t1` `alias3` left join (`test`.`t1` `alias1` semi join (`test`.`t1` `sq1_alias1`)) on(((`test`.`sq1_alias1`.`col_varchar_nokey` = 'v'))) semi join (`test`.`t2` join `test`.`t1` `sq2_alias2`) where ((`test`.`alias2`.`col_varchar_key` = `test`.`alias3`.`col_varchar_key`) and (`test`.`t2`.`col_int_key` = `test`.`alias3`.`pk`) and (`test`.`t2`.`col_varchar_nokey` <> `test`.`alias3`.`col_varchar_key`) and (`test`.`t2`.`col_varchar_key` < 'l')) +DROP TABLE t1,t2; +DROP VIEW view_c; +# +# Bug#13902463 SEGFAULT IN BITMAP<64U>::MERGE OR ADD_KEY_FIELD +# ON SECOND EXEC OF PREP STMT +# +CREATE TABLE t1 ( +pk INT, +col_int_nokey INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +KEY col_varchar_key (col_varchar_key) +); +CREATE VIEW view_b AS SELECT * FROM t1; +PREPARE prep_stmt_20421 FROM 'SELECT alias2.col_varchar_nokey AS field1 +FROM t1 AS alias1 +INNER JOIN t1 AS alias2 +ON (alias1.col_varchar_key = alias2.col_varchar_nokey +AND ( alias1.col_int_key ) IN ( +SELECT t1.col_int_nokey +FROM t1 +) +) +WHERE alias1.col_varchar_key IN ( +SELECT sq2_alias2.col_varchar_nokey AS sq2_field1 +FROM view_b AS sq2_alias1 +INNER JOIN t1 AS sq2_alias2 +ON (sq2_alias2.col_varchar_key = sq2_alias1.col_varchar_key ) +WHERE sq2_alias1.pk > alias2.pk +) +'; +EXECUTE prep_stmt_20421; +field1 +EXECUTE prep_stmt_20421; +field1 +EXPLAIN SELECT alias2.col_varchar_nokey AS field1 +FROM t1 AS alias1 +INNER JOIN t1 AS alias2 +ON (alias1.col_varchar_key = alias2.col_varchar_nokey +AND ( alias1.col_int_key ) IN ( +SELECT t1.col_int_nokey +FROM t1 +) +) +WHERE alias1.col_varchar_key IN ( +SELECT sq2_alias2.col_varchar_nokey AS sq2_field1 +FROM view_b AS sq2_alias1 +INNER JOIN t1 AS sq2_alias2 +ON (sq2_alias2.col_varchar_key = sq2_alias1.col_varchar_key ) +WHERE sq2_alias1.pk > alias2.pk +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.alias2.pk' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `field1` from `test`.`t1` `alias1` join `test`.`t1` `alias2` semi join (`test`.`t1`) semi join (`test`.`t1` join `test`.`t1` `sq2_alias2`) where ((`test`.`t1`.`pk` > NULL) and multiple equal(NULL, `test`.`sq2_alias2`.`col_varchar_nokey`, NULL) and multiple equal(`test`.`sq2_alias2`.`col_varchar_key`, `test`.`t1`.`col_varchar_key`) and multiple equal(NULL, `test`.`t1`.`col_int_nokey`)) +ALTER TABLE t1 DROP INDEX col_varchar_key; +PREPARE prep_stmt_20421 FROM 'SELECT alias2.col_varchar_nokey AS field1 +FROM t1 AS alias1 +INNER JOIN t1 AS alias2 +ON (alias1.col_varchar_key = alias2.col_varchar_nokey +AND ( alias1.col_int_key ) IN ( +SELECT t1.col_int_nokey +FROM t1 +) +) +WHERE alias1.col_varchar_key IN ( +SELECT sq2_alias2.col_varchar_nokey AS sq2_field1 +FROM view_b AS sq2_alias1 +INNER JOIN t1 AS sq2_alias2 +ON (sq2_alias2.col_varchar_key = sq2_alias1.col_varchar_key ) +WHERE sq2_alias1.pk > alias2.pk +) +'; +EXECUTE prep_stmt_20421; +field1 +EXECUTE prep_stmt_20421; +field1 +EXPLAIN SELECT alias2.col_varchar_nokey AS field1 +FROM t1 AS alias1 +INNER JOIN t1 AS alias2 +ON (alias1.col_varchar_key = alias2.col_varchar_nokey +AND ( alias1.col_int_key ) IN ( +SELECT t1.col_int_nokey +FROM t1 +) +) +WHERE alias1.col_varchar_key IN ( +SELECT sq2_alias2.col_varchar_nokey AS sq2_field1 +FROM view_b AS sq2_alias1 +INNER JOIN t1 AS sq2_alias2 +ON (sq2_alias2.col_varchar_key = sq2_alias1.col_varchar_key ) +WHERE sq2_alias1.pk > alias2.pk +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.alias2.pk' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `field1` from `test`.`t1` `alias1` join `test`.`t1` `alias2` semi join (`test`.`t1`) semi join (`test`.`t1` join `test`.`t1` `sq2_alias2`) where ((`test`.`t1`.`pk` > NULL) and multiple equal(NULL, `test`.`sq2_alias2`.`col_varchar_nokey`, NULL) and multiple equal(`test`.`sq2_alias2`.`col_varchar_key`, `test`.`t1`.`col_varchar_key`) and multiple equal(NULL, `test`.`t1`.`col_int_nokey`)) +DROP TABLE t1; +DROP VIEW view_b; +# +# Bug#13907277: Segfault in evaluate_null_complemented_join_record +# +CREATE TABLE t1 ( +pk INTEGER, +col_varchar_nokey VARCHAR(1), +col_varchar_key VARCHAR(1), +PRIMARY KEY (pk) +); +INSERT INTO t1 VALUES (1, 'x', 'x'); +CREATE TABLE t2 ( +pk INTEGER, +PRIMARY KEY (pk) +); +INSERT INTO t2 VALUES (1); +CREATE TABLE t3 ( +pk INTEGER, +col_int_nokey INTEGER, +col_int_key INTEGER, +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk) +); +INSERT INTO t3 VALUES (1, 6, 5, 'r'); +explain SELECT outer_t1.pk, outer_t2.pk +FROM t3 AS outer_t1 +RIGHT JOIN t2 AS outer_t2 +ON outer_t1.col_int_nokey IN +(SELECT inner_t1.col_int_nokey +FROM t3 AS inner_t1 +LEFT JOIN t1 AS inner_t2 +INNER JOIN t1 AS inner_t3 +ON inner_t3.pk = inner_t2.pk +ON inner_t3.col_varchar_nokey = inner_t2.col_varchar_key +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE outer_t2 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE outer_t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE inner_t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE inner_t2 NULL ALL PRIMARY NULL NULL NULL 1 100.00 NULL +1 SIMPLE inner_t3 NULL eq_ref PRIMARY PRIMARY 4 test.inner_t2.pk 1 100.00 Using where; FirstMatch(outer_t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`outer_t1`.`pk` AS `pk`,'1' AS `pk` from left join (`test`.`t3` `outer_t1` semi join (`test`.`t3` `inner_t1` left join (`test`.`t1` `inner_t2` join `test`.`t1` `inner_t3`) on(((`test`.`inner_t3`.`col_varchar_nokey` = `test`.`inner_t2`.`col_varchar_key`) and (`test`.`inner_t3`.`pk` = `test`.`inner_t2`.`pk`))))) on(((`test`.`inner_t1`.`col_int_nokey` = `test`.`outer_t1`.`col_int_nokey`))) where true +SELECT outer_t1.pk, outer_t2.pk +FROM t3 AS outer_t1 +RIGHT JOIN t2 AS outer_t2 +ON outer_t1.col_int_nokey IN +(SELECT inner_t1.col_int_nokey +FROM t3 AS inner_t1 +LEFT JOIN t1 AS inner_t2 +INNER JOIN t1 AS inner_t3 +ON inner_t3.pk = inner_t2.pk +ON inner_t3.col_varchar_nokey = inner_t2.col_varchar_key +); +pk pk +1 1 +DROP TABLE t1, t2, t3; +# End of test for bug#13907277. +# +# Bug#13955713: Assert 'JOIN->best_read < ...' on second execution +# +CREATE TABLE t1 ( +pk INTEGER, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1) +); +PREPARE stmt FROM " +SELECT MIN(alias2.col_varchar_key) AS field1 +FROM t1 AS alias1 + INNER JOIN (t1 AS alias2 + INNER JOIN t1 AS alias3 + ON 8 IN + (SELECT sq1_alias1.pk AS sq1_field2 + FROM t1 AS sq1_alias1 + WHERE 9 IN + (SELECT SUM(t1_sq1_alias1.pk) AS t1_sq1_field2 + FROM t1 AS t1_sq1_alias1 + ) + ) + ) + ON alias3.col_varchar_nokey = alias2.col_varchar_key +WHERE EXISTS + (SELECT sq2_alias1.pk AS sq2_field1 + FROM t1 AS sq2_alias1 + WHERE sq2_alias1.col_varchar_key < alias1.col_varchar_nokey + ) +"; +EXECUTE stmt; +field1 +NULL + +EXECUTE stmt; +field1 +NULL +DEALLOCATE PREPARE stmt; +DROP TABLE t1; +# End of test for bug#13955713. +# +# Bug#13956813: Segfault in memcpy from Join_cache::write_record_data() +# +CREATE TABLE t1 ( +pk INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1) +) charset latin1; +CREATE TABLE t2 ( +pk INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1) +) charset latin1; +INSERT INTO t2 VALUES +(10,'j','j'), (11,'z','z'), (12,'c','c'), (13,'a','a'), +(14,'q','q'), (15,'y','y'), (16,NULL,NULL), (17,'r','r'), +(18,'v','v'), (19,NULL,NULL), (20,'r','r'); +CREATE TABLE t3 ( +pk INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +KEY col_int_key (col_int_key) +) charset latin1; +INSERT INTO t3 VALUES +(15,NULL,'u'), (16,1,'m'), (17,9,NULL), (18,2,'o'), +(19,9,'w'), (20,2,'m'), (21,4,'q'), (22,0,NULL), +(23,4,'d'), (24,8,'g'), (25,NULL,'x'), (26,NULL,'f'), +(27,0,'p'), (28,NULL,'j'), (29,8,'c'); +CREATE VIEW view_inline_0 AS +SELECT t1.* +FROM t1 INNER JOIN t3 +ON t1.pk = t3.pk; +CREATE VIEW view_inline_1 AS +SELECT sq2_alias2.col_varchar_key AS sq2_field1, +sq2_alias1.col_varchar_key AS sq2_field2 +FROM t3 AS sq2_alias1 LEFT OUTER JOIN t3 AS sq2_alias2 +ON sq2_alias1.pk = sq2_alias2.col_int_key; +CREATE VIEW view_inline_2 AS +SELECT 'p', 'p' UNION SELECT 'k', 's'; +SET @optimizer_switch_saved= @@optimizer_switch; +SET @@optimizer_switch="derived_merge=off"; +explain SELECT SUM(alias1.col_varchar_nokey) AS field2 +FROM t2 AS alias2 +LEFT JOIN (SELECT * FROM view_inline_0) AS alias1 +ON alias2.col_varchar_key = alias1.col_varchar_key AND +(alias2.col_varchar_nokey, alias2.col_varchar_key) IN +(SELECT * FROM view_inline_1 +) +WHERE (alias1.col_varchar_key, alias1.col_varchar_nokey) IN +(SELECT * FROM view_inline_2 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL 2 100.00 NULL +1 PRIMARY alias2 NULL ALL NULL NULL NULL NULL 11 10.00 Using where; Using join buffer (hash join) +1 PRIMARY NULL ref 8 test.alias2.col_varchar_nokey,test.view_inline_2.p 3 100.00 Using index; FirstMatch(alias2) +1 PRIMARY NULL ref 8 test.view_inline_2.p,test.view_inline_2.Name_exp_p 2 100.00 NULL +7 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +8 UNION NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +NULL UNION RESULT NULL ALL NULL NULL NULL NULL NULL NULL Using temporary +6 DERIVED sq2_alias1 NULL ALL NULL NULL NULL NULL 15 100.00 NULL +6 DERIVED sq2_alias2 NULL ref col_int_key col_int_key 5 test.sq2_alias1.pk 2 100.00 NULL +2 DERIVED NULL ALL NULL NULL NULL NULL 15 100.00 NULL +5 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select sum(`alias1`.`col_varchar_nokey`) AS `field2` from `test`.`view_inline_2` join `test`.`t2` `alias2` join (/* select#2 */ select `test`.`view_inline_0`.`pk` AS `pk`,`test`.`view_inline_0`.`col_varchar_key` AS `col_varchar_key`,`test`.`view_inline_0`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`view_inline_0`) `alias1` semi join (`test`.`view_inline_1`) where ((`test`.`view_inline_1`.`sq2_field1` = `test`.`alias2`.`col_varchar_nokey`) and (`alias1`.`col_varchar_nokey` = `test`.`view_inline_2`.`Name_exp_p`) and (`test`.`alias2`.`col_varchar_key` = `test`.`view_inline_2`.`p`) and (`test`.`view_inline_1`.`sq2_field2` = `test`.`view_inline_2`.`p`) and (`alias1`.`col_varchar_key` = `test`.`view_inline_2`.`p`)) +SELECT SUM(alias1.col_varchar_nokey) AS field2 +FROM t2 AS alias2 +LEFT JOIN (SELECT * FROM view_inline_0) AS alias1 +ON alias2.col_varchar_key = alias1.col_varchar_key AND +(alias2.col_varchar_nokey, alias2.col_varchar_key) IN +(SELECT * FROM view_inline_1 +) +WHERE (alias1.col_varchar_key, alias1.col_varchar_nokey) IN +(SELECT * FROM view_inline_2 +); +field2 +NULL +SET @@optimizer_switch= @optimizer_switch_saved; +DROP VIEW view_inline_0, view_inline_1, view_inline_2; +DROP TABLE t1, t2, t3; +# End of test for bug#13956813. +# +# Bug#13974177: Assert !(tab->table->regginfo.not_exists_optimize... +# +CREATE TABLE t1 ( +pk INTEGER AUTO_INCREMENT, +col_int_nokey INTEGER, +col_int_key INTEGER, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk), +KEY (col_int_key), +KEY (col_varchar_key, col_int_key) +); +INSERT INTO t1(col_int_key, col_int_nokey, col_varchar_key, col_varchar_nokey) +VALUES +(0, 4, 'j', 'j'), (8, 6, 'v', 'v'), (1, 3, 'c', 'c'), (8, 5, 'm', 'm'), +(9, 3, 'd', 'd'), (24, 246, 'd', 'd'), (6, 2, 'y', 'y'), (1, 9, 't', 't'), +(6, 3, 'd', 'd'), (2, 8, 's', 's'), (4, 1, 'r', 'r'), (8, 8, 'm', 'm'), +(4, 8, 'b', 'b'), (4, 5, 'x', 'x'), (7, 7, 'g', 'g'), (4, 5, 'p', 'p'), +(1, 1, 'q', 'q'), (9, 6, 'w', 'w'), (4, 2, 'd', 'd'), (8, 9, 'e', 'e'); +CREATE TABLE t2 ( +pk INTEGER AUTO_INCREMENT, +col_int_nokey INTEGER NOT NULL, +col_time_key TIME NOT NULL, +col_time_nokey TIME NOT NULL, +PRIMARY KEY (pk), +KEY (col_time_key) +) ENGINE=InnoDB; +INSERT INTO t2 (col_int_nokey, col_time_key, col_time_nokey) VALUES +(7, '00:00:00', '00:00:00'), (0, '00:00:00', '00:00:00'), +(9, '06:35:17', '06:35:17'), (3, '18:07:14', '18:07:14'), +(4, '20:36:52', '20:36:52'), (2, '21:29:07', '21:29:07'), +(5, '23:45:57', '23:45:57'), (3, '22:54:57', '22:54:57'), +(1, '18:45:09', '18:45:09'), (3, '14:30:46', '14:30:46'), +(6, '19:23:43', '19:23:43'), (7, '03:39:30', '03:39:30'), +(5, '23:37:52', '23:37:52'), (1, '16:59:30', '16:59:30'), +(204, '22:21:15', '22:21:15'), (224, '12:24:37', '12:24:37'), +(9, '15:02:08', '15:02:08'), (5, '23:59:59', '23:59:59'), +(0, '08:23:30', '08:23:30'), (3, '08:32:22', '08:32:22'); +explain SELECT ot1.col_int_key AS x +FROM t1 AS ot2 +LEFT JOIN t1 AS ot1 +ON ot2.col_varchar_nokey > ot1.col_varchar_key +WHERE (ot1.col_int_nokey, ot1.pk) IN +(SELECT it1.pk AS x, +it1.col_int_nokey AS y +FROM t2 AS it2 +LEFT JOIN t2 AS it1 +ON it2.col_time_nokey = it1.col_time_key +) AND ot1.pk IS NULL +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`col_int_key` AS `x` from `test`.`t2` `it1` join `test`.`t1` `ot2` join `test`.`t1` `ot1` semi join (`test`.`t2` `it2`) where ((`test`.`ot1`.`pk` is null) and (`test`.`ot2`.`col_varchar_nokey` > `test`.`ot1`.`col_varchar_key`) and multiple equal(`test`.`ot1`.`col_int_nokey`, `test`.`it1`.`pk`) and multiple equal(`test`.`ot1`.`pk`, `test`.`it1`.`col_int_nokey`) and multiple equal(`test`.`it2`.`col_time_nokey`, `test`.`it1`.`col_time_key`)) +SELECT ot1.col_int_key AS x +FROM t1 AS ot2 +LEFT JOIN t1 AS ot1 +ON ot2.col_varchar_nokey > ot1.col_varchar_key +WHERE (ot1.col_int_nokey, ot1.pk) IN +(SELECT it1.pk AS x, +it1.col_int_nokey AS y +FROM t2 AS it2 +LEFT JOIN t2 AS it1 +ON it2.col_time_nokey = it1.col_time_key +) AND ot1.pk IS NULL +; +x +DROP TABLE t1, t2; +# End of test for bug#13974177. +# +# Bug#13971022: Assert 'keyparts > 0' failed in create_ref_for_key... +# +CREATE TABLE t1 ( +pk INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +PRIMARY KEY (pk), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +CREATE TABLE t2 ( +pk INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk) +) charset utf8mb4 ENGINE=InnoDB; +CREATE TABLE t3 ( +i INT +); +SET @optimizer_switch_saved= @@optimizer_switch; +SET @@optimizer_switch="derived_merge=off"; +explain SELECT table1.pk AS field1 +FROM ( SELECT subquery1_t1. * +FROM t2 AS subquery1_t1 +JOIN t2 AS subquery1_t2 +ON subquery1_t2.pk = subquery1_t1.pk) AS table1 +STRAIGHT_JOIN t2 AS table2 +ON table1.col_int_key IN (SELECT 7 FROM t3) +WHERE table1.col_varchar_nokey IN +(SELECT subquery3_t1.col_varchar_key AS subquery3_field1 +FROM t1 AS subquery3_t1 +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 PRIMARY subquery3_t1 NULL ref col_varchar_key col_varchar_key 7 table1.col_varchar_nokey 0 0.00 Using index; FirstMatch() +1 PRIMARY t3 NULL ALL NULL NULL NULL NULL 0 0.00 FirstMatch(subquery3_t1); Using join buffer (hash join) +1 PRIMARY table2 NULL index NULL PRIMARY 4 NULL 1 100.00 Using index; Using join buffer (hash join) +2 DERIVED subquery1_t1 NULL ALL PRIMARY NULL NULL NULL 1 100.00 Using where +2 DERIVED subquery1_t2 NULL eq_ref PRIMARY PRIMARY 4 test.subquery1_t1.pk 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `table1`.`pk` AS `field1` from (/* select#2 */ select `test`.`subquery1_t1`.`pk` AS `pk`,`test`.`subquery1_t1`.`col_int_key` AS `col_int_key`,`test`.`subquery1_t1`.`col_varchar_key` AS `col_varchar_key`,`test`.`subquery1_t1`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t2` `subquery1_t1` join `test`.`t2` `subquery1_t2` where ((`test`.`subquery1_t1`.`col_int_key` = 7) and (`test`.`subquery1_t2`.`pk` = `test`.`subquery1_t1`.`pk`))) `table1` straight_join `test`.`t2` `table2` semi join (`test`.`t3`) semi join (`test`.`t1` `subquery3_t1`) where (`test`.`subquery3_t1`.`col_varchar_key` = `table1`.`col_varchar_nokey`) +SELECT table1.pk AS field1 +FROM ( SELECT subquery1_t1. * +FROM t2 AS subquery1_t1 +JOIN t2 AS subquery1_t2 +ON subquery1_t2.pk = subquery1_t1.pk) AS table1 +STRAIGHT_JOIN t2 AS table2 +ON table1.col_int_key IN (SELECT 7 FROM t3) +WHERE table1.col_varchar_nokey IN +(SELECT subquery3_t1.col_varchar_key AS subquery3_field1 +FROM t1 AS subquery3_t1 +) +; +field1 +SET @@optimizer_switch= @optimizer_switch_saved; +DROP TABLE t1, t2, t3; +# End of test for bug#13971022. +# +# Bug#13623473 "MISSING ROWS ON SELECT AND JOIN WITH +# TIME/DATETIME COMPARE" - Subquery part of test. +# +SET TIMESTAMP=UNIX_TIMESTAMP('2012-01-31 10:14:35'); +CREATE TABLE t1 ( +pk INT NOT NULL, +col_int_nokey INT, +col_int_key INT NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +) ENGINE=InnoDB; +INSERT INTO t1 VALUES (10,1,7), (11,7,0), (12,4,9), (13,7,3), +(14,0,4), (15,2,2), (16,9,5), (17,4,3), (18,0,1), (19,9,3), (20,1,6), +(21,3,7), (22,8,5), (23,8,1), (24,18,204), (25,84,224), (26,6,9), +(27,3,5), (28,6,0), (29,6,3); +CREATE TABLE t2 ( +col_int_nokey INT NOT NULL, +col_datetime_key DATETIME NOT NULL, +col_varchar_key VARCHAR(1) NOT NULL, +KEY col_datetime_key (col_datetime_key), +KEY col_varchar_key (col_varchar_key) +) ENGINE=InnoDB; +INSERT INTO t2 VALUES (1,'2001-11-04 19:07:55','k'); +CREATE TABLE t3 ( +col_time_key TIME, +KEY col_time_key (col_time_key) +) ENGINE=InnoDB; +INSERT INTO t3 VALUES ('21:22:34'), ('10:50:38'), ('00:21:38'), +('04:08:02'), ('16:25:11'), ('10:14:58'), ('19:47:59'), ('11:14:24'), +('00:00:00'), ('00:00:00'), ('15:57:25'), ('07:05:51'), ('19:22:21'), +('03:53:16'), ('09:16:38'), ('15:37:26'), ('00:00:00'), ('05:03:03'), +('02:59:24'), ('00:01:58'); +EXPLAIN SELECT outr.col_int_nokey +FROM t2 as outr +STRAIGHT_JOIN t3 AS outr2 +ON outr2.col_time_key > outr.col_datetime_key +WHERE outr.col_int_nokey IN ( +SELECT col_int_key +FROM t1 AS innr +WHERE innr.pk >= innr.col_int_nokey +) AND ( +outr.col_int_nokey <= 6 +OR +outr.col_varchar_key IS NULL +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE outr NULL ALL col_datetime_key NULL NULL NULL 1 100.00 Using where +2 SIMPLE innr NULL ref col_int_key col_int_key 4 test.outr.col_int_nokey 1 33.33 Using where; FirstMatch(outr) +2 SIMPLE outr2 NULL index col_time_key col_time_key 4 NULL 20 33.33 Using where; Using index; Using join buffer (hash join) +Warnings: +Warning 1739 Cannot use range access on index 'col_time_key' due to type or collation conversion on field 'col_time_key' +Note 1003 /* select#1 */ select `test`.`outr`.`col_int_nokey` AS `col_int_nokey` from `test`.`t2` `outr` straight_join `test`.`t3` `outr2` semi join (`test`.`t1` `innr`) where ((`test`.`innr`.`col_int_key` = `test`.`outr`.`col_int_nokey`) and (`test`.`outr`.`col_int_nokey` <= 6) and (`test`.`innr`.`pk` >= `test`.`innr`.`col_int_nokey`) and (cast(`test`.`outr2`.`col_time_key` as datetime) > `test`.`outr`.`col_datetime_key`)) +SELECT outr.col_int_nokey +FROM t2 as outr +STRAIGHT_JOIN t3 AS outr2 +ON outr2.col_time_key > outr.col_datetime_key +WHERE outr.col_int_nokey IN ( +SELECT col_int_key +FROM t1 AS innr +WHERE innr.pk >= innr.col_int_nokey +) AND ( +outr.col_int_nokey <= 6 +OR +outr.col_varchar_key IS NULL +); +col_int_nokey +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +DROP TABLE t1,t2,t3; +SET TIMESTAMP = DEFAULT; +# End of test for bug#13623473. +# +# Bug#13980954: Missing data on left join + null value + where..in +# +CREATE TABLE t1 ( +ik INT, +vc varchar(1) +) charset utf8mb4; +INSERT INTO t1 VALUES (8, 'x'), (NULL, 'x'); +CREATE TABLE t2 ( +ik INT, +vc varchar(1) +) charset utf8mb4; +INSERT INTO t2 VALUES +(0, 'x'), (7, 'i'), (7, 'e'), (1, 'p'), (7, 's'), (1, 'j'); +explain format=json SELECT t2.vc, t2.ik AS t2_ik, t1.ik AS t1_ik +FROM t2 LEFT JOIN t1 ON t2.vc=t1.vc +WHERE t2.vc IN (SELECT vc FROM t2 AS t3); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "6.92" + }, + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 6, + "rows_produced_per_join": 6, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "0.60", + "prefix_cost": "1.11", + "data_read_per_join": "96" + }, + "used_columns": [ + "ik", + "vc" + ] + } + }, + { + "table": { + "table_name": "t3", + "access_type": "ALL", + "rows_examined_per_scan": 6, + "rows_produced_per_join": 6, + "filtered": "16.67", + "first_match": "t2", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "0.60", + "prefix_cost": "5.21", + "data_read_per_join": "96" + }, + "used_columns": [ + "vc" + ], + "attached_condition": "(`test`.`t3`.`vc` = `test`.`t2`.`vc`)" + } + }, + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 12, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "1.20", + "prefix_cost": "6.92", + "data_read_per_join": "192" + }, + "used_columns": [ + "ik", + "vc" + ], + "attached_condition": "(is_not_null_compl(t1), (`test`.`t1`.`vc` = `test`.`t2`.`vc`), true)" + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`vc` AS `vc`,`test`.`t2`.`ik` AS `t2_ik`,`test`.`t1`.`ik` AS `t1_ik` from `test`.`t2` left join `test`.`t1` on((`test`.`t1`.`vc` = `test`.`t2`.`vc`)) semi join (`test`.`t2` `t3`) where (`test`.`t3`.`vc` = `test`.`t2`.`vc`) +SELECT t2.vc, t2.ik AS t2_ik, t1.ik AS t1_ik +FROM t2 LEFT JOIN t1 ON t2.vc=t1.vc +WHERE t2.vc IN (SELECT vc FROM t2 AS t3); +vc t2_ik t1_ik +e 7 NULL +i 7 NULL +j 1 NULL +p 1 NULL +s 7 NULL +x 0 8 +x 0 NULL +DROP TABLE t1, t2; +# End of test for bug#13980954. +# +# Bug#14048292: Segfault in Item_field::result_type on 2nd execution +# of prep stmt with join of view +# +CREATE TABLE t1 ( +col_int INT +); +INSERT INTO t1 VALUES (0), (1); +CREATE VIEW view_t1 AS SELECT * FROM t1; +explain SELECT alias1.col_int +FROM t1 AS alias1 +LEFT JOIN view_t1 AS alias2 +ON alias1.col_int IN +(SELECT sq1_alias1.col_int +FROM t1 AS sq1_alias1 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE alias1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE sq1_alias1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`alias1`.`col_int` AS `col_int` from `test`.`t1` `alias1` left join (`test`.`t1` semi join (`test`.`t1` `sq1_alias1`)) on(((`test`.`sq1_alias1`.`col_int` = `test`.`alias1`.`col_int`))) where true +PREPARE stmt FROM "SELECT alias1.col_int +FROM t1 AS alias1 +LEFT JOIN view_t1 AS alias2 +ON alias1.col_int IN +(SELECT sq1_alias1.col_int +FROM t1 AS sq1_alias1 +)"; +EXECUTE stmt; +col_int +0 +0 +1 +1 + +EXECUTE stmt; +col_int +0 +0 +1 +1 +DEALLOCATE PREPARE stmt; +DROP VIEW view_t1; +DROP TABLE t1; +# End of test for bug#14048292. +# +# Bug#14064201: Missing data on join of derived table + WHERE .. IN +# with two operands +# +CREATE TABLE t1 ( +col_varchar_nokey VARCHAR(1) +) charset utf8mb4; +INSERT INTO t1 VALUES +('v'), ('s'), ('l'), ('y'), ('c'), ('i'), ('h'), ('q'), ('a'), ('v'), +('u'), ('s'), ('y'), ('z'), ('h'), ('p'), ('e'), ('i'), ('y'), ('w'); +CREATE TABLE t2 ( +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +KEY col_varchar_key(col_varchar_key) +) charset utf8mb4; +INSERT INTO t2 VALUES +('j','j'), ('v','v'), ('c','c'), ('m','m'), ('d','d'), ('d','d'), ('y','y'); +SET @optimizer_switch_saved= @@optimizer_switch; +SET @@optimizer_switch="derived_merge=off"; +explain format=json SELECT * +FROM (SELECT * FROM t2) AS derived1 +LEFT JOIN t1 +USING (col_varchar_nokey) +WHERE (col_varchar_nokey, col_varchar_nokey) IN +(SELECT col_varchar_nokey, col_varchar_key +FROM t2 AS derived2 +); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "22.71" + }, + "nested_loop": [ + { + "table": { + "table_name": "derived1", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "2.59", + "eval_cost": "0.70", + "prefix_cost": "3.29", + "data_read_per_join": "112" + }, + "used_columns": [ + "col_varchar_key", + "col_varchar_nokey" + ], + "attached_condition": "(`derived1`.`col_varchar_nokey` is not null)", + "materialized_from_subquery": { + "using_temporary_table": true, + "dependent": false, + "cacheable": true, + "query_block": { + "select_id": 2, + "cost_info": { + "query_cost": "1.21" + }, + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "0.70", + "prefix_cost": "1.21", + "data_read_per_join": "112" + }, + "used_columns": [ + "col_varchar_key", + "col_varchar_nokey" + ] + } + } + } + } + }, + { + "table": { + "table_name": "derived2", + "access_type": "ref", + "possible_keys": [ + "col_varchar_key" + ], + "key": "col_varchar_key", + "used_key_parts": [ + "col_varchar_key" + ], + "key_length": "7", + "ref": [ + "derived1.col_varchar_nokey" + ], + "rows_examined_per_scan": 2, + "rows_produced_per_join": 7, + "filtered": "14.29", + "first_match": "derived1", + "cost_info": { + "read_cost": "3.50", + "eval_cost": "0.70", + "prefix_cost": "8.19", + "data_read_per_join": "112" + }, + "used_columns": [ + "col_varchar_key", + "col_varchar_nokey" + ], + "attached_condition": "(`test`.`derived2`.`col_varchar_nokey` = `derived1`.`col_varchar_nokey`)" + } + }, + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 140, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.52", + "eval_cost": "14.00", + "prefix_cost": "22.71", + "data_read_per_join": "1K" + }, + "used_columns": [ + "col_varchar_nokey" + ], + "attached_condition": "(is_not_null_compl(t1), (`test`.`t1`.`col_varchar_nokey` = `derived1`.`col_varchar_nokey`), true)" + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select `derived1`.`col_varchar_nokey` AS `col_varchar_nokey`,`derived1`.`col_varchar_key` AS `col_varchar_key` from (/* select#2 */ select `test`.`t2`.`col_varchar_key` AS `col_varchar_key`,`test`.`t2`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t2`) `derived1` left join `test`.`t1` on((`test`.`t1`.`col_varchar_nokey` = `derived1`.`col_varchar_nokey`)) semi join (`test`.`t2` `derived2`) where ((`test`.`derived2`.`col_varchar_nokey` = `derived1`.`col_varchar_nokey`) and (`test`.`derived2`.`col_varchar_key` = `derived1`.`col_varchar_nokey`)) +SELECT * +FROM (SELECT * FROM t2) AS derived1 +LEFT JOIN t1 +USING (col_varchar_nokey) +WHERE (col_varchar_nokey, col_varchar_nokey) IN +(SELECT col_varchar_nokey, col_varchar_key +FROM t2 AS derived2 +); +col_varchar_nokey col_varchar_key +c c +d d +d d +j j +m m +v v +v v +y y +y y +y y +SET @@optimizer_switch= @optimizer_switch_saved; +DROP TABLE t1, t2; +CREATE TABLE t1 ( +col_int_nokey int NOT NULL, +col_int_key int NOT NULL, +KEY col_int_key (col_int_key) +); +INSERT INTO t1 VALUES +(1,7), (7,0), (4,9), (7,3), (0,4), (2,2), (9,5), (4,3), (0,1), (9,3), +(1,6), (3,7), (8,5), (8,1), (18,204), (84,224), (6,9), (3,5), (6,0), (6,3); +CREATE TABLE t2 ( +col_int_nokey int NOT NULL, +col_int_key int NOT NULL, +KEY col_int_key (col_int_key) +); +INSERT INTO t2 VALUES +(4,0), (6,8), (3,1), (5,8), (3,9), (246,24), (2,6), (9,1), (3,6), (8,2), +(1,4), (8,8), (8,4), (5,4), (7,7), (5,4), (1,1), (6,9), (2,4), (9,8); +explain format=json SELECT grandparent1.* +FROM t1 AS grandparent1 +LEFT JOIN t1 USING (col_int_nokey) +WHERE (col_int_nokey, col_int_nokey) IN +(SELECT col_int_nokey, col_int_key +FROM t2 +); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "57.82" + }, + "nested_loop": [ + { + "table": { + "table_name": "grandparent1", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 20, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "2.00", + "prefix_cost": "2.51", + "data_read_per_join": "320" + }, + "used_columns": [ + "col_int_nokey", + "col_int_key" + ] + } + }, + { + "table": { + "table_name": "t2", + "access_type": "ref", + "possible_keys": [ + "col_int_key" + ], + "key": "col_int_key", + "used_key_parts": [ + "col_int_key" + ], + "key_length": "4", + "ref": [ + "test.grandparent1.col_int_nokey" + ], + "rows_examined_per_scan": 2, + "rows_produced_per_join": 20, + "filtered": "10.00", + "first_match": "grandparent1", + "cost_info": { + "read_cost": "10.00", + "eval_cost": "2.00", + "prefix_cost": "17.31", + "data_read_per_join": "320" + }, + "used_columns": [ + "col_int_nokey", + "col_int_key" + ], + "attached_condition": "(`test`.`t2`.`col_int_nokey` = `test`.`grandparent1`.`col_int_nokey`)" + } + }, + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 400, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "40.00", + "prefix_cost": "57.82", + "data_read_per_join": "6K" + }, + "used_columns": [ + "col_int_nokey" + ], + "attached_condition": "(is_not_null_compl(t1), (`test`.`t1`.`col_int_nokey` = `test`.`grandparent1`.`col_int_nokey`), true)" + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`grandparent1`.`col_int_nokey` AS `col_int_nokey`,`test`.`grandparent1`.`col_int_key` AS `col_int_key` from `test`.`t1` `grandparent1` left join `test`.`t1` on((`test`.`t1`.`col_int_nokey` = `test`.`grandparent1`.`col_int_nokey`)) semi join (`test`.`t2`) where ((`test`.`t2`.`col_int_nokey` = `test`.`grandparent1`.`col_int_nokey`) and (`test`.`t2`.`col_int_key` = `test`.`grandparent1`.`col_int_nokey`)) +SELECT grandparent1.* +FROM t1 AS grandparent1 +LEFT JOIN t1 USING (col_int_nokey) +WHERE (col_int_nokey, col_int_nokey) IN +(SELECT col_int_nokey, col_int_key +FROM t2 +); +col_int_nokey col_int_key +1 6 +1 6 +1 7 +1 7 +7 0 +7 0 +7 3 +7 3 +8 1 +8 1 +8 5 +8 5 +DROP TABLE t1, t2; +CREATE TABLE t1 ( +pk int, +col_int_key int, +col_datetime_key datetime, +col_varchar_key varchar(1), +col_varchar_nokey varchar(1), +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_datetime_key (col_datetime_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4 engine=MyISAM; +INSERT INTO t1 VALUES +(10,7,'2004-06-06 04:22:12','v','v'), (11,0,'2005-11-13 01:12:31','s','s'), +(12,9,'2002-05-04 01:50:00','l','l'), (13,3,'2004-10-27 10:28:45','y','y'), +(14,4,'2006-07-22 05:24:23','c','c'), (15,2,'2002-05-16 21:34:03','i','i'), +(16,5,'2008-04-17 10:45:30','h','h'), (17,3,'2009-04-21 02:58:02','q','q'), +(18,1,'2008-01-11 11:01:51','a','a'), (19,3,'1900-01-01 00:00:00','v','v'), +(20,6,'2007-05-17 18:24:57','u','u'), (21,7,'2007-08-07 00:00:00','s','s'), +(22,5,'2001-08-28 00:00:00','y','y'), (23,1,'2004-04-16 00:27:28','z','z'), +(24,204,'2005-05-03 07:06:22','h','h'), (25,224,'2009-03-11 17:09:50','p','p'), +(26,9,'2007-12-08 01:54:28','e','e'), (27,5,'2009-07-28 18:19:54','i','i'), +(28,0,'2008-06-08 00:00:00','y','y'), (29,3,'2005-02-09 09:20:26','w','w'); +CREATE TABLE t2 ( +pk int, +col_int_key int, +col_datetime_key datetime, +col_varchar_key varchar(1), +col_varchar_nokey varchar(1), +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_datetime_key (col_datetime_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4 engine=MyISAM; +INSERT INTO t2 VALUES +(1,0,'2002-02-13 17:30:06','j','j'), (2,8,'2008-09-27 00:34:58','v','v'), +(3,1,'2007-05-28 00:00:00','c','c'), (4,8,'2009-07-25 09:21:20','m','m'), +(5,9,'2002-01-16 00:00:00','d','d'), (6,24,'2006-10-12 04:32:53','d','d'), +(7,6,'2001-02-15 03:08:38','y','y'), (8,1,'2004-10-02 20:31:15','t','t'), +(9,6,'2002-08-20 22:48:00','d','d'), (10,2,'1900-01-01 00:00:00','s','s'), +(11,4,'2005-08-15 00:00:00','r','r'), (12,8,'1900-01-01 00:00:00','m','m'), +(13,4,'2008-05-16 08:09:06','b','b'), (14,4,'2001-01-20 12:47:23','x','x'), +(15,7,'2008-07-02 00:00:00','g','g'), (16,4,'1900-01-01 00:00:00','p','p'), +(17,1,'2002-12-08 11:34:58','q','q'), (18,9,'1900-01-01 00:00:00','w','w'), +(19,4,'1900-01-01 00:00:00','d','d'), (20,8,'2002-08-25 20:35:06','e','e'); +SELECT alias1.col_datetime_key +FROM t2 AS alias1 +RIGHT JOIN t2 AS alias2 +JOIN t2 AS alias3 +ON alias3.pk = alias2.pk +ON alias3.col_varchar_nokey = alias2.col_varchar_key OR +alias2.col_varchar_nokey +WHERE (alias2.col_varchar_key, alias2.col_varchar_key) IN +(SELECT sq2_alias2.col_varchar_key, sq2_alias1.col_varchar_nokey +FROM t1 AS sq2_alias1, t1 AS sq2_alias2 +WHERE sq2_alias2.col_int_key < 2); +col_datetime_key +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +2001-01-20 12:47:23 +2001-01-20 12:47:23 +2001-02-15 03:08:38 +2001-02-15 03:08:38 +2002-01-16 00:00:00 +2002-01-16 00:00:00 +2002-02-13 17:30:06 +2002-02-13 17:30:06 +2002-08-20 22:48:00 +2002-08-20 22:48:00 +2002-08-25 20:35:06 +2002-08-25 20:35:06 +2002-12-08 11:34:58 +2002-12-08 11:34:58 +2004-10-02 20:31:15 +2004-10-02 20:31:15 +2005-08-15 00:00:00 +2005-08-15 00:00:00 +2006-10-12 04:32:53 +2006-10-12 04:32:53 +2007-05-28 00:00:00 +2007-05-28 00:00:00 +2008-05-16 08:09:06 +2008-05-16 08:09:06 +2008-07-02 00:00:00 +2008-07-02 00:00:00 +2008-09-27 00:34:58 +2008-09-27 00:34:58 +2009-07-25 09:21:20 +2009-07-25 09:21:20 +ALTER TABLE t1 DISABLE KEYS; +ALTER TABLE t2 DISABLE KEYS; +explain format=json SELECT alias1.col_datetime_key +FROM t2 AS alias1 +RIGHT JOIN t2 AS alias2 +JOIN t2 AS alias3 +ON alias3.pk = alias2.pk +ON alias3.col_varchar_nokey = alias2.col_varchar_key OR +alias2.col_varchar_nokey +WHERE (alias2.col_varchar_key, alias2.col_varchar_key) IN +(SELECT sq2_alias2.col_varchar_key, sq2_alias1.col_varchar_nokey +FROM t1 AS sq2_alias1, t1 AS sq2_alias2 +WHERE sq2_alias2.col_int_key < 2); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "151.21" + }, + "nested_loop": [ + { + "table": { + "table_name": "alias2", + "access_type": "ALL", + "possible_keys": [ + "PRIMARY" + ], + "rows_examined_per_scan": 20, + "rows_produced_per_join": 20, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.53", + "eval_cost": "2.00", + "prefix_cost": "2.53", + "data_read_per_join": "640" + }, + "used_columns": [ + "pk", + "col_varchar_key", + "col_varchar_nokey" + ] + } + }, + { + "table": { + "table_name": "alias3", + "access_type": "eq_ref", + "possible_keys": [ + "PRIMARY" + ], + "key": "PRIMARY", + "used_key_parts": [ + "pk" + ], + "key_length": "4", + "ref": [ + "test.alias2.pk" + ], + "rows_examined_per_scan": 1, + "rows_produced_per_join": 20, + "filtered": "100.00", + "cost_info": { + "read_cost": "5.00", + "eval_cost": "2.00", + "prefix_cost": "9.53", + "data_read_per_join": "640" + }, + "used_columns": [ + "pk", + "col_varchar_nokey" + ] + } + }, + { + "table": { + "table_name": "sq2_alias2", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 20, + "filtered": "5.00", + "cost_info": { + "read_cost": "37.24", + "eval_cost": "2.00", + "prefix_cost": "24.73", + "data_read_per_join": "640" + }, + "used_columns": [ + "col_int_key", + "col_varchar_key" + ], + "attached_condition": "((`test`.`sq2_alias2`.`col_varchar_key` = `test`.`alias2`.`col_varchar_key`) and (`test`.`sq2_alias2`.`col_int_key` < 2))" + } + }, + { + "table": { + "table_name": "sq2_alias1", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 20, + "filtered": "10.00", + "first_match": "alias3", + "cost_info": { + "read_cost": "10.58", + "eval_cost": "2.00", + "prefix_cost": "110.68", + "data_read_per_join": "640" + }, + "used_columns": [ + "col_varchar_nokey" + ], + "attached_condition": "(`test`.`sq2_alias1`.`col_varchar_nokey` = `test`.`alias2`.`col_varchar_key`)" + } + }, + { + "table": { + "table_name": "alias1", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 400, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.53", + "eval_cost": "40.00", + "prefix_cost": "151.21", + "data_read_per_join": "12K" + }, + "used_columns": [ + "col_datetime_key" + ], + "attached_condition": "(is_not_null_compl(alias1), (((`test`.`alias3`.`col_varchar_nokey` = `test`.`alias2`.`col_varchar_key`) and (`test`.`sq2_alias2`.`col_varchar_key` = `test`.`alias2`.`col_varchar_key`) and (`test`.`sq2_alias1`.`col_varchar_nokey` = `test`.`alias2`.`col_varchar_key`)) or (0 <> `test`.`alias2`.`col_varchar_nokey`)), true)" + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`alias1`.`col_datetime_key` AS `col_datetime_key` from `test`.`t2` `alias2` join `test`.`t2` `alias3` left join `test`.`t2` `alias1` on((((`test`.`alias3`.`col_varchar_nokey` = `test`.`alias2`.`col_varchar_key`) and (`test`.`sq2_alias2`.`col_varchar_key` = `test`.`alias2`.`col_varchar_key`) and (`test`.`sq2_alias1`.`col_varchar_nokey` = `test`.`alias2`.`col_varchar_key`)) or (0 <> `test`.`alias2`.`col_varchar_nokey`))) semi join (`test`.`t1` `sq2_alias1` join `test`.`t1` `sq2_alias2`) where ((`test`.`alias3`.`pk` = `test`.`alias2`.`pk`) and (`test`.`sq2_alias2`.`col_varchar_key` = `test`.`alias2`.`col_varchar_key`) and (`test`.`sq2_alias1`.`col_varchar_nokey` = `test`.`alias2`.`col_varchar_key`) and (`test`.`sq2_alias2`.`col_int_key` < 2)) +SELECT alias1.col_datetime_key +FROM t2 AS alias1 +RIGHT JOIN t2 AS alias2 +JOIN t2 AS alias3 +ON alias3.pk = alias2.pk +ON alias3.col_varchar_nokey = alias2.col_varchar_key OR +alias2.col_varchar_nokey +WHERE (alias2.col_varchar_key, alias2.col_varchar_key) IN +(SELECT sq2_alias2.col_varchar_key, sq2_alias1.col_varchar_nokey +FROM t1 AS sq2_alias1, t1 AS sq2_alias2 +WHERE sq2_alias2.col_int_key < 2); +col_datetime_key +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +2001-01-20 12:47:23 +2001-01-20 12:47:23 +2001-02-15 03:08:38 +2001-02-15 03:08:38 +2002-01-16 00:00:00 +2002-01-16 00:00:00 +2002-02-13 17:30:06 +2002-02-13 17:30:06 +2002-08-20 22:48:00 +2002-08-20 22:48:00 +2002-08-25 20:35:06 +2002-08-25 20:35:06 +2002-12-08 11:34:58 +2002-12-08 11:34:58 +2004-10-02 20:31:15 +2004-10-02 20:31:15 +2005-08-15 00:00:00 +2005-08-15 00:00:00 +2006-10-12 04:32:53 +2006-10-12 04:32:53 +2007-05-28 00:00:00 +2007-05-28 00:00:00 +2008-05-16 08:09:06 +2008-05-16 08:09:06 +2008-07-02 00:00:00 +2008-07-02 00:00:00 +2008-09-27 00:34:58 +2008-09-27 00:34:58 +2009-07-25 09:21:20 +2009-07-25 09:21:20 +DROP TABLE t1, t2; +# End of test for bug#14064201. +# +# Bug#18223655:ASSERTION FAILED: (INT)IDX >= 0 +# && IDX < PARENT_JOIN->TABLES +# +CREATE TABLE b (d INT); +CREATE TABLE c (a INT, b INT,c INT,d BLOB NOT NULL); +SELECT(SELECT 1 +FROM b WHERE(SELECT 1 IN (SELECT 1 FROM b WHERE 1 NOT BETWEEN d AND 1) +FROM b) IN (SELECT d FROM c)) as cc FROM b; +cc +INSERT INTO b VALUE(1); +INSERT INTO c VALUES(1,2,3,'1'),(2,3,4,'1'),(3,4,5,'C'); +SELECT(SELECT d FROM b WHERE(SELECT d IN +(SELECT d FROM b WHERE 1 NOT BETWEEN d AND 1) FROM b) IN +(SELECT d FROM c)) as cc FROM c; +cc +1 +1 +1 +DROP TABLE b,c; +# +# Bug#18447874:WRONG RESULT COMING FROM SEMI-JOIN +# +CREATE TABLE b ( +d INT(11) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE c ( +d BLOB +) ; +CREATE TABLE d ( +b INT(11) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO b VALUES(1),(2),(4); +INSERT INTO c VALUES(1),(2),(3); +SELECT 1 FROM b WHERE (SELECT 1 FROM d ) IN (SELECT d FROM c) ; +1 +INSERT INTO d VALUES(2); +SELECT 1 FROM b WHERE (SELECT 1 FROM d ) IN (SELECT d FROM c) ; +1 +1 +1 +1 +DROP TABLE b,c,d; +# +# Bug#17292723:INCORRECT RESULT FOR (SELECT...) IN (SELECT...) STATEMENT +# +CREATE TABLE t1 ( +ID int(11) NOT NULL AUTO_INCREMENT, +id2 int(11) DEFAULT NULL, +id3 int(11) DEFAULT NULL, +id4 varchar(150) COLLATE utf8_spanish_ci NOT NULL, +id5 int(11) DEFAULT NULL, +PRIMARY KEY (ID), +KEY id2 (id2), +KEY id3 (id3), +KEY id5 (id5) +) ENGINE=InnoDB; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 3778 'utf8_spanish_ci' is a collation of the deprecated character set UTF8MB3. Please consider using UTF8MB4 with an appropriate collation instead. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES +(123,1,1,'1',NULL), +(124,1,1,'2',NULL), +(125,1,1,'4',NULL), +(126,1,1,'3',NULL), +(127,1,1,'6',NULL), +(128,1,1,'8',NULL); +CREATE TABLE t2 ( +id6 int(11) NOT NULL, +id7 int(11) NOT NULL, +PRIMARY KEY (id6,id7), +KEY id7 (id7) +) ENGINE=InnoDB; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (126,123),(130,123),(135,123); +SELECT ID +FROM t1 p0 +WHERE p0.id3=1 +AND ( (SELECT p1.id FROM t1 p1 WHERE p1.id=123) IN (SELECT p3.id FROM t2 +p2, t1 p3 WHERE p0.id=p2.id6 AND p2.id7=p3.id)); +ID +126 +DROP TABLE t1,t2; +set @@optimizer_switch=@old_opt_switch; +# End of 5.6 tests +# +# Bug#19336348 DEBUG CRASH AT SETUP_SEMIJOIN_DUPS_ELIMINATION IN SQL/SQL_SELECT.CC +# +CREATE TABLE t1 ( +col_varchar_nokey varchar(1) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t1 VALUES ('c'),(NULL),('x'); +CREATE TABLE t2 ( +pk int, +col_varchar_key varchar(1), +PRIMARY KEY (pk), +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t2 VALUES (10,'l'),(11,'p'); +ANALYZE TABLE t1,t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN SELECT 1 +FROM t1 AS outr +WHERE outr.col_varchar_nokey IN +( +SELECT innr.col_varchar_key +FROM t2 AS innr +WHERE innr.pk <= 7 +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE outr NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 SIMPLE innr NULL ref PRIMARY,col_varchar_key col_varchar_key 7 test.outr.col_varchar_nokey 1 50.00 Using where; Using index; FirstMatch(outr) +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` `outr` semi join (`test`.`t2` `innr`) where ((`test`.`innr`.`col_varchar_key` = `test`.`outr`.`col_varchar_nokey`) and (`test`.`innr`.`pk` <= 7)) +SELECT 1 +FROM t1 AS outr +WHERE outr.col_varchar_nokey IN +( +SELECT innr.col_varchar_key +FROM t2 AS innr +WHERE innr.pk <= 7 +) +; +1 +DROP TABLE t1,t2; +# +# Bug#18174394 BLOBS: CRASH AFTER UNINITIALIZED VALUES IN ITEM_FIELD::STR_RESULT +# +CREATE TABLE t1(d BLOB, b BLOB); +INSERT INTO t1(d,b) VALUES ('aaaa',''),('bnbb',''); +SELECT 1 FROM t1 +WHERE (SELECT b FROM t1) IN (SELECT (d>=1) FROM t1); +ERROR 21000: Subquery returns more than 1 row +DROP TABLE t1; +# +# Bug#19779600: ASSERT FAILED IN REPLACE_SUBCONDITION WITH IN +# PREDICATE INSIDE IN PREDICATE +# +CREATE TABLE t(X INT) ENGINE=InnoDB; +INSERT INTO t VALUES (1); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +EXPLAIN SELECT 1 FROM t WHERE (1 IN (SELECT 1 FROM t)) IN (SELECT 1 FROM t); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 PRIMARY t NULL ALL NULL NULL NULL NULL 1 100.00 FirstMatch(t); Using join buffer (hash join) +2 SUBQUERY t NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t` semi join (`test`.`t`) where true +SELECT 1 FROM t WHERE (1 IN (SELECT 1 FROM t)) IN (SELECT 1 FROM t); +1 +1 +DROP TABLE t; +# +# Bug#19465034 ASSERT ON SETUP_SEMIJOIN_DUPS_ELIMINATION IN SQL/SQL_SELECT.CC +# +CREATE TABLE t1 ( +pk INTEGER NOT NULL, +i1 INTEGER NOT NULL, +PRIMARY KEY (pk) +) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1,1); +CREATE TABLE t2 ( +pk INTEGER NOT NULL, +c1 VARCHAR(1) NOT NULL, +PRIMARY KEY (pk), +KEY c1_key (c1) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t2 VALUES (1,'j'),(2,'v'),(3,'c'); +CREATE TABLE t3 ( +pk INTEGER NOT NULL, +c1 VARCHAR(1) NOT NULL, +PRIMARY KEY (pk), +KEY c1_key (c1) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t3 VALUES (10,'v'),(11,'s'); +ANALYZE TABLE t1, t2, t3; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +EXPLAIN SELECT * +FROM t1 JOIN t2 ON t1.i1 >= t2.pk +WHERE t2.c1 IN ( +SELECT t3.c1 +FROM t3 +WHERE t3.pk < 3 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t2 NULL ALL PRIMARY,c1_key NULL NULL NULL 3 33.33 Range checked for each record (index map: 0x3) +2 SIMPLE t3 NULL ref PRIMARY,c1_key c1_key 6 test.t2.c1 1 50.00 Using where; Using index; FirstMatch(t2) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`i1` AS `i1`,`test`.`t2`.`pk` AS `pk`,`test`.`t2`.`c1` AS `c1` from `test`.`t1` join `test`.`t2` semi join (`test`.`t3`) where ((`test`.`t3`.`c1` = `test`.`t2`.`c1`) and (`test`.`t3`.`pk` < 3) and (`test`.`t1`.`i1` >= `test`.`t2`.`pk`)) +SELECT * +FROM t1 JOIN t2 ON t1.i1 >= t2.pk +WHERE t2.c1 IN ( +SELECT t3.c1 +FROM t3 +WHERE t3.pk < 3 +); +pk i1 pk c1 +DROP TABLE t1,t2,t3; +# +# Bug#19586047: CRASH IN ARG_COMPARATOR::SET_CMP_FUNC +# +CREATE TABLE t1(x INT) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT 1 FROM t1 WHERE EXISTS(SELECT 1) IN (SELECT 1 FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 1 100.00 FirstMatch(t1); Using join buffer (hash join) +2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` semi join (`test`.`t1`) where true +SELECT 1 FROM t1 WHERE EXISTS(SELECT 1) IN (SELECT 1 FROM t1); +1 +1 +EXPLAIN SELECT 1 FROM t1 WHERE (SELECT 1, 2 FROM t1) IN (SELECT 1, 2 FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 1 100.00 FirstMatch(t1); Using join buffer (hash join) +2 SUBQUERY t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` semi join (`test`.`t1`) where true +SELECT 1 FROM t1 WHERE (SELECT 1, 2 FROM t1) IN (SELECT 1, 2 FROM t1); +1 +1 +EXPLAIN SELECT 1 FROM t1 WHERE +(SELECT 1, 2 FROM t1 WHERE x = 2) IN (SELECT 1, 2 FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +2 SUBQUERY t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` semi join (`test`.`t1`) where false +SELECT 1 FROM t1 WHERE +(SELECT 1, 2 FROM t1 WHERE x = 2) IN (SELECT 1, 2 FROM t1); +1 +DROP TABLE t1; +# +#Bug#20119743 ASSERTIONQEP_TAB->USE_ORDER() IN ENUM_NESTED_LOOP_STATE +# EVALUATE_JOIN_RECORD +# +CREATE TABLE t1 ( +pk int(11) NOT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +PRIMARY KEY (pk) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (1,'x'); +CREATE TABLE t2 ( +col_date_key date DEFAULT NULL, +col_int_key int(11) DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +KEY col_int_key (col_int_key), +KEY col_date_key (col_date_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES ('2000-12-03', 8, 'x', 'x'),('2008-05-03', 7, 'd', 'd'), +('2005-12-06', 1, 'r', 'r'),('2000-04-10', 7, 'f', 'f'), +('2002-11-05', 9, 'y', 'y'),('2000-09-06', NULL, 'u', 'u'), +(NULL, 1, 'm', 'm'),('2007-06-14', 9, NULL, NULL), +('2007-11-17', 2, 'o', 'o'),('2009-02-23', 9, 'w', 'w'), +('2007-01-08', 2, 'm', 'm'), ('2008-06-10', 4, 'q', 'q'), +('2002-10-20', 0, NULL, NULL),('2008-09-12', 4, 'd', 'd'), +('2006-06-16', 8, 'g', 'g'),('2004-09-18', NULL, 'x', 'x'), +('1900-01-01', NULL, 'f', 'f'),('2005-09-13', 0, 'p', 'p'), +('2007-04-09', NULL, 'j', 'j'),('2000-09-20', 8, 'c', 'c'); +CREATE TABLE t3 ( +pk int(11) NOT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +PRIMARY KEY (pk) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t3 VALUES (1, 'c'),(2, 'c'),(3, 'q'),(4, 'g'),(5, 'e'),(6, 'l'), +(7, NULL),(8, 'v'),(9, 'c'),(10, 'u'),(11, 'x'),(12, 'x'),(13, 'x'),(14, 'l'), +(15, 'e'),(16, 's'),(17, 'k'),(18, 'm'),(19, 'x'),(20, 's'); +ANALYZE TABLE t1,t2,t3; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +EXPLAIN SELECT r1.col_date_key +FROM t2 AS r1 +WHERE r1.col_int_key NOT IN +(SELECT ir2.pk +FROM t2 AS ir1 STRAIGHT_JOIN t1 AS ir2 +ON ir2.col_varchar_nokey = ir1.col_varchar_key +WHERE ir2.col_varchar_nokey > r1.col_varchar_nokey +AND ir2.pk IN +(SELECT iir2.pk +FROM t2 AS iir1 RIGHT JOIN t3 AS iir2 +ON iir2.col_varchar_nokey = iir1.col_varchar_key)) +ORDER BY r1.col_date_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY r1 NULL ALL NULL NULL NULL NULL 20 100.00 Using where; Using filesort +2 DEPENDENT SUBQUERY ir1 NULL index col_varchar_key col_varchar_key 12 NULL 20 100.00 Using where; Using index +2 DEPENDENT SUBQUERY ir2 NULL eq_ref PRIMARY PRIMARY 4 func 1 100.00 Using where; Full scan on NULL key +2 DEPENDENT SUBQUERY iir2 NULL eq_ref PRIMARY PRIMARY 4 func 1 100.00 Using where; Full scan on NULL key +2 DEPENDENT SUBQUERY iir1 NULL ref col_varchar_key col_varchar_key 7 test.iir2.col_varchar_nokey 1 100.00 Using index; FirstMatch(ir2) +SELECT r1.col_date_key +FROM t2 AS r1 +WHERE r1.col_int_key NOT IN +(SELECT ir2.pk +FROM t2 AS ir1 STRAIGHT_JOIN t1 AS ir2 +ON ir2.col_varchar_nokey = ir1.col_varchar_key +WHERE ir2.col_varchar_nokey > r1.col_varchar_nokey +AND ir2.pk IN +(SELECT iir2.pk +FROM t2 AS iir1 RIGHT JOIN t3 AS iir2 +ON iir2.col_varchar_nokey = iir1.col_varchar_key)) +ORDER BY r1.col_date_key; +col_date_key +2000-04-10 +2000-09-20 +2000-12-03 +2002-10-20 +2002-11-05 +2004-09-18 +2005-09-13 +2006-06-16 +2007-01-08 +2007-06-14 +2007-11-17 +2008-05-03 +2008-06-10 +2008-09-12 +2009-02-23 +SELECT COUNT(r1.col_date_key) AS COUNT_NUM +FROM t2 AS r1 +WHERE r1.col_int_key NOT IN +(SELECT ir2.pk +FROM t2 AS ir1 STRAIGHT_JOIN t1 AS ir2 +ON ir2.col_varchar_nokey = ir1.col_varchar_key +WHERE ir2.col_varchar_nokey > r1.col_varchar_nokey +AND ir2.pk IN +(SELECT iir2.pk +FROM t2 AS iir1 RIGHT JOIN t3 AS iir2 +ON iir2.col_varchar_nokey = iir1.col_varchar_key +WHERE iir2.pk<3)); +COUNT_NUM +15 +DROP TABLE t1,t2,t3; +# +# Bug#20554585 ASSERT JOIN()->TABLES == 0... IN JOIN_TAB::GET_SJ_STRATEGY ON SUBQUERY + VAR +# +CREATE TABLE t1 ( +pk int NOT NULL, +PRIMARY KEY (pk) +); +CREATE TABLE t2 ( +pk int NOT NULL, +col_int_key int, +col_varchar_key varchar(1), +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key) +); +CREATE TABLE t3 ( +pk int NOT NULL, +col_int_key int, +col_varchar_key varchar(1), +col_varchar varchar(1), +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key) +); +INSERT INTO t3 VALUES (1,4,'c','g'),(20,1,'i','p'); +CREATE TABLE t4 ( +col_int int +); +CREATE TABLE t5 ( +col_varchar_key varchar(1), +pk int NOT NULL, +col_int int, +PRIMARY KEY (pk), +KEY col_varchar_key (col_varchar_key) +); +SELECT table1.col_varchar_key AS field1 +FROM (t3 AS table1 +INNER JOIN ( +SELECT SUBQUERY1_t1.* +FROM (t1 AS SUBQUERY1_t1 +RIGHT JOIN (t2 AS SUBQUERY1_t2 +INNER JOIN t3 AS SUBQUERY1_t3 +ON (SUBQUERY1_t3.col_varchar_key = SUBQUERY1_t2.col_varchar_key) +) ON (SUBQUERY1_t3.col_int_key = SUBQUERY1_t2.pk) +) +WHERE SUBQUERY1_t2.col_varchar_key >= ANY ( +SELECT CHILD_SUBQUERY1_t2.col_varchar AS CHILD_SUBQUERY1_field1 +FROM (t2 AS CHILD_SUBQUERY1_t1 +LEFT OUTER JOIN t3 AS CHILD_SUBQUERY1_t2 +ON (CHILD_SUBQUERY1_t2.col_int_key = CHILD_SUBQUERY1_t1.col_int_key) +) +WHERE CHILD_SUBQUERY1_t1.pk >= SUBQUERY1_t2.pk +) +) AS table2 +ON (table2.pk = table1.pk) +) +WHERE (EXISTS (( +SELECT DISTINCT SUBQUERY2_t2.col_int AS SUBQUERY2_field1 +FROM (t4 AS SUBQUERY2_t1 +LEFT OUTER JOIN t5 AS SUBQUERY2_t2 +ON (SUBQUERY2_t2.pk = SUBQUERY2_t1.col_int) +) +WHERE SUBQUERY2_t2.col_varchar_key != @var4 +))) +AND table1.col_int_key < (35 + 192) +ORDER BY field1 +; +field1 +DROP TABLE t1, t2, t3, t4, t5; +# +# Bug#18892055: MISSING DATA ON SELECT ... IN WITH JOINS AND INNODB +# ENGINE +# +CREATE TABLE t1 ( +col_int_key INT, +pk INT NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +) ENGINE = INNODB; +INSERT INTO t1 VALUES +( 0, 3 ), +( 0, 4 ), +( 3, 1 ), +( 900000000, 2 ), +( 1368719360, 5 ), +( 1922236416, 6 ), +( 8,7 ); +CREATE TABLE t2 ( +pk INT NOT NULL, +col_int INT, +PRIMARY KEY (pk) +) ENGINE = INNODB; +INSERT INTO t2 VALUES +( 1, 3 ), +( 2, 2 ), +( 3, 8 ), +( 4, 7 ); +CREATE TABLE t3 ( +col_int_key INT, +col_int INT, +KEY (col_int_key) +) ENGINE = INNODB; +INSERT INTO t3 VALUES +( 5, 1 ), +( -1, -1 ), +( 300000000, 1 ), +( 8, 1 ); +CREATE TABLE t4 ( col_int_key INT ) ENGINE = INNODB; +INSERT INTO t4 VALUES +(0), +(3), +(8), +(900000000), +(1368719360), +(1922236416); +ANALYZE TABLE t1, t2, t3, t4; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +test.t4 analyze status OK +explain SELECT * +FROM t4 +WHERE (col_int_key) IN ( +SELECT t1.col_int_key +FROM t1 LEFT JOIN ( t2 JOIN t3 ON t3.col_int_key = t2.col_int ) USING ( pk ) +WHERE t3.col_int IS NULL +) +ORDER BY col_int_key +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 6 100.00 Parallel execute (1 workers) +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 6 100.00 Using where; Using filesort +2 SIMPLE t1 NULL ref col_int_key col_int_key 5 test.t4.col_int_key 1 100.00 Using index +2 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.pk 1 100.00 NULL +2 SIMPLE t3 NULL ref col_int_key col_int_key 5 test.t2.col_int 1 25.00 Using where; FirstMatch(t4) +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`col_int_key` AS `col_int_key` from `test`.`t4` semi join (`test`.`t1` left join (`test`.`t2` join `test`.`t3`) on(((`test`.`t1`.`pk` = `test`.`t2`.`pk`) and (`test`.`t3`.`col_int_key` = `test`.`t2`.`col_int`)))) where ((`test`.`t1`.`col_int_key` = `test`.`t4`.`col_int_key`) and (`test`.`t3`.`col_int` is null)) order by `test`.`t4`.`col_int_key` +explain format=tree SELECT * +FROM t4 +WHERE (col_int_key) IN ( +SELECT t1.col_int_key +FROM t1 LEFT JOIN ( t2 JOIN t3 ON t3.col_int_key = t2.col_int ) USING ( pk ) +WHERE t3.col_int IS NULL +) +ORDER BY col_int_key +; +EXPLAIN +-> Parallel scan on + -> Nested loop semijoin (cost=3.05 rows=7) + -> Sort: t4.col_int_key (cost=0.85 rows=6) + -> Filter: (t4.col_int_key is not null) + -> PQblock scan on t4 + -> Filter: (t3.col_int is null) (cost=2.14 rows=1) + -> Nested loop left join (cost=2.14 rows=1) + -> Index lookup on t1 using col_int_key (col_int_key=t4.col_int_key) (cost=0.27 rows=1) + -> Nested loop inner join (cost=2.41 rows=1) + -> Single-row index lookup on t2 using PRIMARY (pk=t1.pk) (cost=0.26 rows=1) + -> Index lookup on t3 using col_int_key (col_int_key=t2.col_int) (cost=0.07 rows=1) + +SELECT * +FROM t4 +WHERE (col_int_key) IN ( +SELECT t1.col_int_key +FROM t1 LEFT JOIN ( t2 JOIN t3 ON t3.col_int_key = t2.col_int ) USING ( pk ) +WHERE t3.col_int IS NULL +) +ORDER BY col_int_key +; +col_int_key +0 +3 +8 +900000000 +1368719360 +1922236416 +DROP TABLE t1, t2, t3, t4; +# +# Bug#20835095 CRASH AT CREATE_REF_FOR_KEY IN SQL/SQL_SELECT.CC +# +CREATE TABLE t1 ( +pk INTEGER, +var_10_latin1 VARCHAR(10) CHARACTER SET latin1, +var_255_utf8 VARCHAR(255) CHARACTER SET utf8, +var_255_latin1 VARCHAR(255) CHARACTER SET latin1, +var_10_utf8 VARCHAR(10) CHARACTER SET utf8, +PRIMARY KEY (pk) +); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +CREATE VIEW v1 AS SELECT * FROM t1; +INSERT INTO t1 VALUES +(1,'FROCJ','korrhrspki','UAYVL','BPZIS'), +(2,'him','a','CHYKN','OZZQT'), +(3,'WBITK','ULWBF','have','rhrh'), +(4,'or','right','up','it'), +(5,'GGDCP','x','who','as'), +(6,'j','i','e','w'); +CREATE TABLE tv +SELECT var_255_utf8 AS field1 +FROM t1; +EXPLAIN SELECT * FROM tv +WHERE field1 IN ( +SELECT tv1.var_255_utf8 +FROM v1 AS tv1 LEFT JOIN v1 AS tv2 ON tv1.var_10_latin1=tv2.var_10_utf8); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE tv NULL ALL NULL NULL NULL NULL 6 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 6 16.67 Using where +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 6 100.00 Using where; FirstMatch(tv) +Warnings: +Note 1003 /* select#1 */ select `test`.`tv`.`field1` AS `field1` from `test`.`tv` semi join (`test`.`t1` left join (`test`.`t1`) on((`test`.`t1`.`var_10_latin1` = `test`.`t1`.`var_10_utf8`))) where (`test`.`t1`.`var_255_utf8` = `test`.`tv`.`field1`) +SELECT * FROM tv +WHERE field1 IN ( +SELECT tv1.var_255_utf8 +FROM v1 AS tv1 LEFT JOIN v1 AS tv2 ON tv1.var_10_latin1=tv2.var_10_utf8); +field1 +korrhrspki +a +ULWBF +right +x +i +DROP VIEW v1; +DROP TABLE t1, tv; +# 17832047 Crash in calculate_materialization_costs +CREATE TABLE t1(a INTEGER PRIMARY KEY); +INSERT INTO t1 VALUES (0),(1),(2); +SELECT 1 FROM t1 +WHERE 1 IN +(SELECT 1 BETWEEN (LENGTH(a) IN (SELECT 1 FROM t1)) AND 1 +FROM t1 +); +1 +1 +1 +1 +DROP TABLE t1; +# 17845989 Assertion failed: !(used_tables() & ... +CREATE TABLE a(b INTEGER) engine=innodb; +CREATE TABLE c(a INTEGER) engine=innodb; +SELECT 1 +FROM a +WHERE 1 IN (SELECT (a.b IS NULL) IN (SELECT 1 FROM c) FROM c) +; +1 +DROP TABLE a, c; +# +# Bug#18194196: OPTIMIZER EXECUTES STATEMENT INPERFORMANT +# +CREATE TABLE t1 (uid INTEGER, fid INTEGER, INDEX(uid)); +INSERT INTO t1 VALUES +(1,1), (1,2), (1,3), (1,4), +(2,5), (2,6), (2,7), (2,8), +(3,1), (3,2), (3,9); +CREATE TABLE t2 (uid INT PRIMARY KEY, name VARCHAR(128), INDEX(name)); +INSERT INTO t2 VALUES +(1, "A"), (2, "B"), (3, "C"), (4, "D"), (5, "E"), +(6, "F"), (7, "G"), (8, "H"), (9, "I"); +CREATE TABLE t3 (uid INT, fid INT, INDEX(uid)); +INSERT INTO t3 VALUES +(1,1), (1,2), (1,3),(1,4), +(2,5), (2,6), (2,7), (2,8), +(3,1), (3,2), (3,9); +CREATE TABLE t4 (uid INT PRIMARY KEY, name VARCHAR(128), INDEX(name)); +INSERT INTO t4 VALUES +(1, "A"), (2, "B"), (3, "C"), (4, "D"), (5, "E"), +(6, "F"), (7, "G"), (8, "H"), (9, "I"); +ANALYZE TABLE t1,t2,t3,t4; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +test.t4 analyze status OK +EXPLAIN SELECT name FROM t2, t1 +WHERE t1.uid IN (SELECT t4.uid FROM t4, t3 WHERE t3.uid=1 AND t4.uid=t3.fid) +AND t2.uid=t1.fid; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL uid NULL NULL NULL 11 100.00 Using where +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.fid 1 100.00 NULL +1 SIMPLE t4 NULL eq_ref PRIMARY PRIMARY 4 test.t1.uid 1 100.00 Using index +1 SIMPLE t3 NULL ref uid uid 5 const 4 10.00 Using where; FirstMatch(t4) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`name` AS `name` from `test`.`t4` join `test`.`t2` join `test`.`t1` semi join (`test`.`t3`) where ((`test`.`t4`.`uid` = `test`.`t1`.`uid`) and (`test`.`t3`.`fid` = `test`.`t1`.`uid`) and (`test`.`t3`.`uid` = 1) and (`test`.`t2`.`uid` = `test`.`t1`.`fid`)) +FLUSH STATUS; +SELECT name FROM t2, t1 +WHERE t1.uid IN (SELECT t4.uid FROM t4, t3 WHERE t3.uid=1 AND t4.uid=t3.fid) +AND t2.uid=t1.fid; +name +A +A +B +B +C +D +E +F +G +H +I +SHOW STATUS LIKE '%handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 25 +Handler_read_last 0 +Handler_read_next 10 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 12 +DROP TABLE t1,t2,t3,t4; +# End of test for Bug#18194196 +# +# Bug#21184091 ASSERT `READ_ROWS >= 0.0' AT +# COST_MODEL_SERVER::TMPTABLE_READWRITE_COST() +# +CREATE TABLE t1 ( +pk INTEGER, +col_varchar varchar(1), +col_int INTEGER, +PRIMARY KEY (pk) +) ENGINE=MyISAM; +CREATE TABLE t2 ( +col_int INTEGER, +col_varchar varchar(1) +) ENGINE=MyISAM; +INSERT INTO t2 VALUES (7,'x'); +INSERT INTO t2 VALUES (4,'z'); +SELECT t2.col_varchar +FROM t2 STRAIGHT_JOIN t1 ON t2.col_varchar = t1.col_varchar +JOIN t2 AS table3 ON t1.pk = table3.col_int +WHERE t1.pk IN (SELECT col_int FROM t1); +col_varchar +DROP TABLE t1,t2; +# End of test for Bug#21184091 +# Bug#21139722: Assertion failed: !(used_tables() & ((table_map) 1) ... +CREATE TABLE t1(a INTEGER) engine=innodb; +CREATE TABLE t2(b INTEGER) engine=innodb; +explain SELECT 1 +FROM (SELECT 1 IN (SELECT 1 +FROM t1 +WHERE (SELECT 1 FROM t2 HAVING b) NOT IN (SELECT 1 FROM t2) +) +FROM t2 +) AS z; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DERIVED t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +3 DEPENDENT SUBQUERY t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +5 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +4 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1276 Field or reference 'b' of SELECT #4 was resolved in SELECT #2 +Note 1003 /* select#1 */ select 1 AS `1` from (/* select#2 */ select (1,(/* select#3 */ select 1 from `test`.`t1` where ((/* select#4 */ select 1 from `test`.`t2` having (0 <> `test`.`t2`.`b`)),(/* select#5 */ select 1 from `test`.`t2` where (outer_field_is_not_null, (((/* select#4 */ select 1 from `test`.`t2` having (0 <> `test`.`t2`.`b`))) = 1), true)) is false))) AS `1 IN (SELECT 1 +FROM t1 +WHERE (SELECT 1 FROM t2 HAVING b) NOT IN (SELECT 1 FROM t2) +)` from `test`.`t2`) `z` +SELECT 1 +FROM (SELECT 1 IN (SELECT 1 +FROM t1 +WHERE (SELECT 1 FROM t2 HAVING b) NOT IN (SELECT 1 FROM t2) +) +FROM t2 +) AS z; +1 +DROP TABLE t1, t2; +CREATE TABLE t1(a INTEGER) engine=innodb; +explain SELECT (SELECT a FROM t1 AS t2 +WHERE a IN (SELECT t1.a+t2.a FROM t1 AS t3)) +FROM t1 AS t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 DEPENDENT SUBQUERY t3 NULL ALL NULL NULL NULL NULL 1 100.00 FirstMatch(t2); Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #3 was resolved in SELECT #1 +Note 1276 Field or reference 'test.t2.a' of SELECT #3 was resolved in SELECT #2 +Note 1003 /* select#1 */ select (/* select#2 */ select `test`.`t2`.`a` from `test`.`t1` `t2` semi join (`test`.`t1` `t3`) where (`test`.`t2`.`a` = (`test`.`t1`.`a` + `test`.`t2`.`a`))) AS `(SELECT a FROM t1 AS t2 +WHERE a IN (SELECT t1.a+t2.a FROM t1 AS t3))` from `test`.`t1` +SELECT (SELECT a FROM t1 AS t2 +WHERE a IN (SELECT t1.a+t2.a FROM t1 AS t3)) +FROM t1 AS t1; +(SELECT a FROM t1 AS t2 +WHERE a IN (SELECT t1.a+t2.a FROM t1 AS t3)) +DROP TABLE t1; +# End of test for Bug#21139722 +SET DEFAULT_STORAGE_ENGINE=INNODB; +# +# Bug#21139402 ASSERTION FAILED: LENGTH > 0 && KEYPARTS != 0, CRASH IN JOIN::OPTIMIZE_KEYUSE +# +CREATE TABLE t1 (a INT, b INT, PRIMARY KEY(a)); +CREATE TABLE t2 (c INT PRIMARY KEY); +EXPLAIN SELECT 1 FROM t1 +WHERE 1 IN +(SELECT (c IS NULL) IN (SELECT a FROM t1 WHERE b) FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +3 SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` semi join (`test`.`t2`) where false +SELECT 1 FROM t1 +WHERE 1 IN +(SELECT (c IS NULL) IN (SELECT a FROM t1 WHERE b) FROM t2); +1 +DROP TABLE t1,t2; +# +# Bug#21619634 ACCESS OF DEALLOCATED ITEM_OUTER_REF CAUSES CRASH: PREPARED STMT +# +create table cc (i int) engine="innodb"; +insert into cc values (1); +select (select count(i) from cc as cc_alias +where (cc.i in (select cc_alias.i from cc))) +from cc group by i; +(select count(i) from cc as cc_alias +where (cc.i in (select cc_alias.i from cc))) +1 +prepare stmt from +"select (select count(i) from cc as cc_alias + where (cc.i in (select cc_alias.i from cc))) + from cc group by i"; +execute stmt; +(select count(i) from cc as cc_alias + where (cc.i in (select cc_alias.i from cc))) +1 +execute stmt; +(select count(i) from cc as cc_alias + where (cc.i in (select cc_alias.i from cc))) +1 +drop table cc; +# +# Bug #22305361: QUERY WITH MATERIALIZED TABLE RETURNS INCORRECT +# RESULTS IN 5.6 +# +CREATE TABLE t(a INT,b INT); +INSERT INTO t VALUES (1,0),(1,0),(1,0),(1,0),(1,1); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +EXPLAIN SELECT * +FROM t AS t1 +WHERE t1.a IN (SELECT t2.a +FROM t AS t2 +WHERE CONCAT(t2.a,'') NOT IN (SELECT t3.a +FROM t AS t3 +WHERE t3.b=1)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 5 20.00 Using where; FirstMatch(t1); Using join buffer (hash join) +3 DEPENDENT SUBQUERY t3 NULL ALL NULL NULL NULL NULL 5 20.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t` `t1` semi join (`test`.`t` `t2`) where ((`test`.`t2`.`a` = `test`.`t1`.`a`) and (concat(`test`.`t1`.`a`,''),(/* select#3 */ select `test`.`t3`.`a` from `test`.`t` `t3` where ((`test`.`t3`.`b` = 1) and (outer_field_is_not_null, (((concat(`test`.`t1`.`a`,'')) = `test`.`t3`.`a`) or (`test`.`t3`.`a` is null)), true)) having (outer_field_is_not_null, (`test`.`t3`.`a`), true)) is false)) +SELECT * +FROM t AS t1 +WHERE t1.a IN (SELECT t2.a +FROM t AS t2 +WHERE CONCAT(t2.a,'') NOT IN (SELECT t3.a +FROM t AS t3 +WHERE t3.b=1)); +a b +DROP TABLE t; +# +# Bug#24287772 SUBQUERY RETURNS EMPTY LIST WHILE IDENTICAL QUERY +# WITH JOIN RETURNS RESULT +# +CREATE TABLE t SELECT 4096 c; +SELECT c FROM t WHERE 1 IN +(SELECT t.c = page_size FROM information_schema.innodb_cmpmem); +c +4096 +DROP TABLE t; +# +# Bug #29132639: WL#12470: SIG 6 IN CONNECTJOINS|SQL/SQL_EXECUTOR.C +# +CREATE TABLE t1 ( f1 TIME, f2 VARCHAR(1) ); +INSERT INTO t1 VALUES ('08:35:24', 'X'), ('14:51:13', 'S'), ('11:22:33', 'Q'); +CREATE TABLE t2 ( pk INTEGER ); +INSERT INTO t2 VALUES (1), (2); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN FORMAT=tree SELECT * FROM t1 WHERE EXISTS ( SELECT alias1.f2 FROM t2 LEFT JOIN t1 ON 1 LEFT JOIN t1 AS alias1 ON 1 ); +EXPLAIN +-> Inner hash join (no condition) (cost=5.40 rows=3) + -> Table scan on t1 (cost=0.55 rows=3) + -> Hash + -> Limit: 1 row(s) (cost=4.85 rows=1) + -> Nested loop left join (cost=4.85 rows=18) + -> Nested loop left join (cost=1.55 rows=6) + -> Table scan on t2 (cost=0.45 rows=2) + -> Table scan on t1 (cost=0.40 rows=3) + -> Table scan on alias1 (cost=5.40 rows=3) + +SELECT * FROM t1 WHERE EXISTS ( SELECT alias1.f2 FROM t2 LEFT JOIN t1 ON 1 LEFT JOIN t1 AS alias1 ON 1 ); +f1 f2 +08:35:24 X +11:22:33 Q +14:51:13 S +DROP TABLE t1, t2; +# +# Bug#51457 Firstmatch semijoin strategy gives wrong results for +# certain query plans +# +SET @@default_storage_engine='innodb'; +SET @@optimizer_switch='semijoin=on,materialization=off,firstmatch=on,loosescan=off,block_nested_loop=off,batched_key_access=off'; +CREATE TABLE t0(a INTEGER); +CREATE TABLE t1(a INTEGER); +INSERT INTO t1 VALUES(1); +CREATE TABLE t2(a INTEGER); +INSERT INTO t2 VALUES(5), (8); +CREATE TABLE t6(a INTEGER); +INSERT INTO t6 VALUES(7), (1), (0), (5), (1), (4); +CREATE TABLE t8(a INTEGER); +INSERT INTO t8 VALUES(1), (3), (5), (7), (9), (7), (3), (1); +EXPLAIN +SELECT * +FROM t2 AS nt2 +WHERE 1 IN (SELECT it1.a +FROM t1 AS it1 JOIN t6 AS it3 ON it1.a=it3.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE it1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE it3 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; FirstMatch +1 SIMPLE nt2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`nt2`.`a` AS `a` from `test`.`t2` `nt2` semi join (`test`.`t1` `it1` join `test`.`t6` `it3`) where ((`test`.`it1`.`a` = 1) and (`test`.`it3`.`a` = 1)) +SELECT * +FROM t2 AS nt2 +WHERE 1 IN (SELECT it1.a +FROM t1 AS it1 JOIN t6 AS it3 ON it1.a=it3.a); +a +5 +8 +EXPLAIN +SELECT * +FROM t2 AS nt2, t8 AS nt4 +WHERE 1 IN (SELECT it1.a +FROM t1 AS it1 JOIN t6 AS it3 ON it1.a=it3.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE it1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE it3 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; FirstMatch +1 SIMPLE nt2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE nt4 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`nt2`.`a` AS `a`,`test`.`nt4`.`a` AS `a` from `test`.`t2` `nt2` join `test`.`t8` `nt4` semi join (`test`.`t1` `it1` join `test`.`t6` `it3`) where ((`test`.`it1`.`a` = 1) and (`test`.`it3`.`a` = 1)) +SELECT * +FROM t2 AS nt2, t8 AS nt4 +WHERE 1 IN (SELECT it1.a +FROM t1 AS it1 JOIN t6 AS it3 ON it1.a=it3.a); +a a +5 1 +5 1 +5 3 +5 3 +5 5 +5 7 +5 7 +5 9 +8 1 +8 1 +8 3 +8 3 +8 5 +8 7 +8 7 +8 9 +EXPLAIN +SELECT * +FROM t0 AS ot1, t2 AS nt3 +WHERE ot1.a IN (SELECT it2.a +FROM t1 AS it2 JOIN t8 AS it4 ON it2.a=it4.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE it2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 SIMPLE it4 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; FirstMatch(ot1) +2 SIMPLE nt3 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`nt3`.`a` AS `a` from `test`.`t0` `ot1` join `test`.`t2` `nt3` semi join (`test`.`t1` `it2` join `test`.`t8` `it4`) where ((`test`.`it2`.`a` = `test`.`ot1`.`a`) and (`test`.`it4`.`a` = `test`.`ot1`.`a`)) +SELECT * +FROM t0 as ot1, t2 AS nt3 +WHERE ot1.a IN (SELECT it2.a +FROM t1 AS it2 JOIN t8 AS it4 ON it2.a=it4.a); +a a +DROP TABLE t0, t1, t2, t6, t8; +SET @@default_storage_engine=default; +SET @@optimizer_switch=default; +# End of bug#51457 +set optimizer_switch=default; +set optimizer_switch=default; diff --git a/mysql-test/r/subquery_sj_firstmatch_bka_nobnl.result-pq b/mysql-test/r/subquery_sj_firstmatch_bka_nobnl.result-pq new file mode 100644 index 000000000000..2959356db0d8 --- /dev/null +++ b/mysql-test/r/subquery_sj_firstmatch_bka_nobnl.result-pq @@ -0,0 +1,12937 @@ +set optimizer_switch='batched_key_access=on,block_nested_loop=off,mrr_cost_based=off'; +set optimizer_switch='semijoin=on,firstmatch=on'; +set @old_opt_switch=@@optimizer_switch; +set optimizer_switch='subquery_materialization_cost_based=off'; +drop table if exists t0, t1, t2, t10, t11, t12; +create table t1 (a int not null, b int, primary key (a)); +create table t2 (a int not null, primary key (a)); +create table t3 (a int not null, b int, primary key (a)); +insert into t1 values (1,10), (2,20), (3,30), (4,40); +insert into t2 values (2), (3), (4), (5); +insert into t3 values (10,3), (20,4), (30,5); +select * from t2 where t2.a in (select a from t1); +a +2 +3 +4 +explain select * from t2 where t2.a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index PRIMARY PRIMARY 4 NULL 4 100.00 Using index +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t1` join `test`.`t2` where (`test`.`t1`.`a` = `test`.`t2`.`a`) +select * from t2 where t2.a in (select a from t1 where t1.b <> 30); +a +2 +4 +explain select * from t2 where t2.a in (select a from t1 where t1.b <> 30); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL PRIMARY NULL NULL NULL 4 75.00 Using where +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`a` = `test`.`t1`.`a`) and (`test`.`t1`.`b` <> 30)) +select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a); +a +2 +3 +explain select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index PRIMARY PRIMARY 4 NULL 4 100.00 Using index +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.a 1 100.00 Using where +1 SIMPLE t3 NULL eq_ref PRIMARY PRIMARY 4 test.t1.b 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t1` join `test`.`t3` join `test`.`t2` where ((`test`.`t1`.`a` = `test`.`t2`.`a`) and (`test`.`t3`.`a` = `test`.`t1`.`b`)) +drop table t1, t2, t3; +create table t1 (a int, b int, index a (a,b)); +create table t2 (a int, index a (a)); +create table t3 (a int, b int, index a (a)); +insert into t1 values (1,10), (2,20), (3,30), (4,40); +create table t0(a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +insert into t1 +select rand()*100000+200,rand()*100000 from t0 A, t0 B, t0 C, t0 D; +insert into t2 values (2), (3), (4), (5); +insert into t3 values (10,3), (20,4), (30,5); +select * from t2 where t2.a in (select a from t1); +a +2 +3 +4 +explain select * from t2 where t2.a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index a a 5 NULL 4 100.00 Using where; Using index +1 SIMPLE t1 NULL ref a a 5 test.t2.a 101 100.00 Using index; FirstMatch(t2) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1`) where (`test`.`t1`.`a` = `test`.`t2`.`a`) +select * from t2 where t2.a in (select a from t1 where t1.b <> 30); +a +2 +4 +explain select * from t2 where t2.a in (select a from t1 where t1.b <> 30); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index a a 5 NULL 4 100.00 Using where; Using index +1 SIMPLE t1 NULL ref a a 5 test.t2.a 101 90.00 Using where; Using index; FirstMatch(t2) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1`) where ((`test`.`t1`.`a` = `test`.`t2`.`a`) and (`test`.`t1`.`b` <> 30)) +select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a); +a +2 +3 +explain select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index a a 5 NULL 4 100.00 Using where; Using index +1 SIMPLE t3 NULL index a a 5 NULL 3 100.00 Using where; Using index +1 SIMPLE t1 NULL ref a a 10 test.t2.a,test.t3.a 116 100.00 Using index; FirstMatch(t2) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1` join `test`.`t3`) where ((`test`.`t1`.`a` = `test`.`t2`.`a`) and (`test`.`t1`.`b` = `test`.`t3`.`a`)) +insert into t1 values (3,31); +select * from t2 where t2.a in (select a from t1 where t1.b <> 30); +a +2 +3 +4 +select * from t2 where t2.a in (select a from t1 where t1.b <> 30 and t1.b <> 31); +a +2 +4 +explain select * from t2 where t2.a in (select a from t1 where t1.b <> 30); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index a a 5 NULL 4 100.00 Using where; Using index +1 SIMPLE t1 NULL ref a a 5 test.t2.a 101 90.00 Using where; Using index; FirstMatch(t2) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1`) where ((`test`.`t1`.`a` = `test`.`t2`.`a`) and (`test`.`t1`.`b` <> 30)) +drop table t0, t1, t2, t3; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1(a int, b int); +insert into t1 values (0,0),(1,1),(2,2); +create table t2 as select * from t1; +create table t11(a int, b int); +create table t10 (pk int, a int, primary key(pk)); +insert into t10 select a,a from t0; +create table t12 like t10; +insert into t12 select * from t10; +Flattened because of dependency, t10=func(t1) +explain select * from t1 where a in (select pk from t10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t1` where (`test`.`t10`.`pk` = `test`.`t1`.`a`) +select * from t1 where a in (select pk from t10); +a b +0 0 +1 1 +2 2 +A confluent case of dependency +explain select * from t1 where a in (select a from t10 where pk=12); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t1` where (multiple equal(12, NULL) and multiple equal(`test`.`t1`.`a`, NULL)) +select * from t1 where a in (select a from t10 where pk=12); +a b +explain select * from t1 where a in (select a from t10 where pk=9); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t10 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t1` where ((`test`.`t1`.`a` = '9')) +select * from t1 where a in (select a from t10 where pk=9); +a b +An empty table inside +explain select * from t1 where a in (select a from t11); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE t11 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t11`) where (`test`.`t11`.`a` = `test`.`t1`.`a`) +select * from t1 where a in (select a from t11); +a b +explain select * from t1 where a in (select pk from t10) and b in (select pk from t10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using index +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.t1.b 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t10` join `test`.`t1` where ((`test`.`t10`.`pk` = `test`.`t1`.`b`) and (`test`.`t10`.`pk` = `test`.`t1`.`a`)) +select * from t1 where a in (select pk from t10) and b in (select pk from t10); +a b +0 0 +1 1 +2 2 +flattening a nested subquery +explain select * from t1 where a in (select pk from t10 where t10.a in (select pk from t12)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using where +1 SIMPLE t12 NULL eq_ref PRIMARY PRIMARY 4 test.t10.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t12` join `test`.`t1` where ((`test`.`t10`.`pk` = `test`.`t1`.`a`) and (`test`.`t12`.`pk` = `test`.`t10`.`a`)) +select * from t1 where a in (select pk from t10 where t10.a in (select pk from t12)); +a b +0 0 +1 1 +2 2 +flattening subquery w/ several tables +explain select * from t1 where a in (select t10.pk from t10, t12 where t12.pk=t10.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using where +1 SIMPLE t12 NULL eq_ref PRIMARY PRIMARY 4 test.t10.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t12` join `test`.`t1` where ((`test`.`t10`.`pk` = `test`.`t1`.`a`) and (`test`.`t12`.`pk` = `test`.`t10`.`a`)) +subqueries within outer joins go into ON expr. +explain +select * from t1 left join (t2 A, t2 B) on ( A.A= t1.A and B.A in (select pk from t10)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE A NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE B NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.B.A 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`A` AS `A`,`test`.`t1`.`B` AS `B`,`test`.`A`.`A` AS `A`,`test`.`A`.`B` AS `B`,`test`.`B`.`A` AS `A`,`test`.`B`.`B` AS `B` from `test`.`t1` left join (`test`.`t10` join `test`.`t2` `A` join `test`.`t2` `B`) on(((`test`.`t10`.`pk` = `test`.`B`.`A`) and (`test`.`A`.`A` = `test`.`t1`.`A`))) where true +t2 should be wrapped into OJ-nest, so we have "t1 LJ (t2 J t10)" +explain +select * from t1 left join t2 on (t2.A= t1.A and t2.A in (select pk from t10)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.t1.A 1 100.00 Using index +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`A` AS `A`,`test`.`t1`.`B` AS `B`,`test`.`t2`.`A` AS `A`,`test`.`t2`.`B` AS `B` from `test`.`t1` left join (`test`.`t10` join `test`.`t2`) on(((`test`.`t10`.`pk` = `test`.`t1`.`A`) and (`test`.`t2`.`A` = `test`.`t1`.`A`))) where true +we shouldn't flatten if we're going to get a join of > MAX_TABLES. +explain select * from +t1 s00, t1 s01, t1 s02, t1 s03, t1 s04,t1 s05,t1 s06,t1 s07,t1 s08,t1 s09, +t1 s10, t1 s11, t1 s12, t1 s13, t1 s14,t1 s15,t1 s16,t1 s17,t1 s18,t1 s19, +t1 s20, t1 s21, t1 s22, t1 s23, t1 s24,t1 s25,t1 s26,t1 s27,t1 s28,t1 s29, +t1 s30, t1 s31, t1 s32, t1 s33, t1 s34,t1 s35,t1 s36,t1 s37,t1 s38,t1 s39, +t1 s40, t1 s41, t1 s42, t1 s43, t1 s44,t1 s45,t1 s46,t1 s47,t1 s48,t1 s49 +where +s00.a in ( +select m00.a from +t1 m00, t1 m01, t1 m02, t1 m03, t1 m04,t1 m05,t1 m06,t1 m07,t1 m08,t1 m09, +t1 m10, t1 m11, t1 m12, t1 m13, t1 m14,t1 m15,t1 m16,t1 m17,t1 m18,t1 m19 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY s00 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 PRIMARY s01 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s02 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s03 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s04 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s05 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s06 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s07 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s08 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s09 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s10 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s11 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s12 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s13 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s14 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s15 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s16 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s17 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s18 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s19 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s20 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s21 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s22 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s23 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s24 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s25 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s26 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s27 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s28 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s29 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s30 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s31 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s32 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s33 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s34 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s35 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s36 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s37 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s38 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s39 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s40 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s41 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s42 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s43 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s44 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s45 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s46 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s47 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s48 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s49 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 DEPENDENT SUBQUERY m00 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +2 DEPENDENT SUBQUERY m01 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 DEPENDENT SUBQUERY m02 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 DEPENDENT SUBQUERY m03 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 DEPENDENT SUBQUERY m04 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 DEPENDENT SUBQUERY m05 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 DEPENDENT SUBQUERY m06 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 DEPENDENT SUBQUERY m07 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 DEPENDENT SUBQUERY m08 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 DEPENDENT SUBQUERY m09 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 DEPENDENT SUBQUERY m10 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 DEPENDENT SUBQUERY m11 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 DEPENDENT SUBQUERY m12 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 DEPENDENT SUBQUERY m13 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 DEPENDENT SUBQUERY m14 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 DEPENDENT SUBQUERY m15 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 DEPENDENT SUBQUERY m16 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 DEPENDENT SUBQUERY m17 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 DEPENDENT SUBQUERY m18 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 DEPENDENT SUBQUERY m19 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`s00`.`a` AS `a`,`test`.`s00`.`b` AS `b`,`test`.`s01`.`a` AS `a`,`test`.`s01`.`b` AS `b`,`test`.`s02`.`a` AS `a`,`test`.`s02`.`b` AS `b`,`test`.`s03`.`a` AS `a`,`test`.`s03`.`b` AS `b`,`test`.`s04`.`a` AS `a`,`test`.`s04`.`b` AS `b`,`test`.`s05`.`a` AS `a`,`test`.`s05`.`b` AS `b`,`test`.`s06`.`a` AS `a`,`test`.`s06`.`b` AS `b`,`test`.`s07`.`a` AS `a`,`test`.`s07`.`b` AS `b`,`test`.`s08`.`a` AS `a`,`test`.`s08`.`b` AS `b`,`test`.`s09`.`a` AS `a`,`test`.`s09`.`b` AS `b`,`test`.`s10`.`a` AS `a`,`test`.`s10`.`b` AS `b`,`test`.`s11`.`a` AS `a`,`test`.`s11`.`b` AS `b`,`test`.`s12`.`a` AS `a`,`test`.`s12`.`b` AS `b`,`test`.`s13`.`a` AS `a`,`test`.`s13`.`b` AS `b`,`test`.`s14`.`a` AS `a`,`test`.`s14`.`b` AS `b`,`test`.`s15`.`a` AS `a`,`test`.`s15`.`b` AS `b`,`test`.`s16`.`a` AS `a`,`test`.`s16`.`b` AS `b`,`test`.`s17`.`a` AS `a`,`test`.`s17`.`b` AS `b`,`test`.`s18`.`a` AS `a`,`test`.`s18`.`b` AS `b`,`test`.`s19`.`a` AS `a`,`test`.`s19`.`b` AS `b`,`test`.`s20`.`a` AS `a`,`test`.`s20`.`b` AS `b`,`test`.`s21`.`a` AS `a`,`test`.`s21`.`b` AS `b`,`test`.`s22`.`a` AS `a`,`test`.`s22`.`b` AS `b`,`test`.`s23`.`a` AS `a`,`test`.`s23`.`b` AS `b`,`test`.`s24`.`a` AS `a`,`test`.`s24`.`b` AS `b`,`test`.`s25`.`a` AS `a`,`test`.`s25`.`b` AS `b`,`test`.`s26`.`a` AS `a`,`test`.`s26`.`b` AS `b`,`test`.`s27`.`a` AS `a`,`test`.`s27`.`b` AS `b`,`test`.`s28`.`a` AS `a`,`test`.`s28`.`b` AS `b`,`test`.`s29`.`a` AS `a`,`test`.`s29`.`b` AS `b`,`test`.`s30`.`a` AS `a`,`test`.`s30`.`b` AS `b`,`test`.`s31`.`a` AS `a`,`test`.`s31`.`b` AS `b`,`test`.`s32`.`a` AS `a`,`test`.`s32`.`b` AS `b`,`test`.`s33`.`a` AS `a`,`test`.`s33`.`b` AS `b`,`test`.`s34`.`a` AS `a`,`test`.`s34`.`b` AS `b`,`test`.`s35`.`a` AS `a`,`test`.`s35`.`b` AS `b`,`test`.`s36`.`a` AS `a`,`test`.`s36`.`b` AS `b`,`test`.`s37`.`a` AS `a`,`test`.`s37`.`b` AS `b`,`test`.`s38`.`a` AS `a`,`test`.`s38`.`b` AS `b`,`test`.`s39`.`a` AS `a`,`test`.`s39`.`b` AS `b`,`test`.`s40`.`a` AS `a`,`test`.`s40`.`b` AS `b`,`test`.`s41`.`a` AS `a`,`test`.`s41`.`b` AS `b`,`test`.`s42`.`a` AS `a`,`test`.`s42`.`b` AS `b`,`test`.`s43`.`a` AS `a`,`test`.`s43`.`b` AS `b`,`test`.`s44`.`a` AS `a`,`test`.`s44`.`b` AS `b`,`test`.`s45`.`a` AS `a`,`test`.`s45`.`b` AS `b`,`test`.`s46`.`a` AS `a`,`test`.`s46`.`b` AS `b`,`test`.`s47`.`a` AS `a`,`test`.`s47`.`b` AS `b`,`test`.`s48`.`a` AS `a`,`test`.`s48`.`b` AS `b`,`test`.`s49`.`a` AS `a`,`test`.`s49`.`b` AS `b` from `test`.`t1` `s00` join `test`.`t1` `s01` join `test`.`t1` `s02` join `test`.`t1` `s03` join `test`.`t1` `s04` join `test`.`t1` `s05` join `test`.`t1` `s06` join `test`.`t1` `s07` join `test`.`t1` `s08` join `test`.`t1` `s09` join `test`.`t1` `s10` join `test`.`t1` `s11` join `test`.`t1` `s12` join `test`.`t1` `s13` join `test`.`t1` `s14` join `test`.`t1` `s15` join `test`.`t1` `s16` join `test`.`t1` `s17` join `test`.`t1` `s18` join `test`.`t1` `s19` join `test`.`t1` `s20` join `test`.`t1` `s21` join `test`.`t1` `s22` join `test`.`t1` `s23` join `test`.`t1` `s24` join `test`.`t1` `s25` join `test`.`t1` `s26` join `test`.`t1` `s27` join `test`.`t1` `s28` join `test`.`t1` `s29` join `test`.`t1` `s30` join `test`.`t1` `s31` join `test`.`t1` `s32` join `test`.`t1` `s33` join `test`.`t1` `s34` join `test`.`t1` `s35` join `test`.`t1` `s36` join `test`.`t1` `s37` join `test`.`t1` `s38` join `test`.`t1` `s39` join `test`.`t1` `s40` join `test`.`t1` `s41` join `test`.`t1` `s42` join `test`.`t1` `s43` join `test`.`t1` `s44` join `test`.`t1` `s45` join `test`.`t1` `s46` join `test`.`t1` `s47` join `test`.`t1` `s48` join `test`.`t1` `s49` where (`test`.`s00`.`a`,(/* select#2 */ select `test`.`m00`.`a` from `test`.`t1` `m00` join `test`.`t1` `m01` join `test`.`t1` `m02` join `test`.`t1` `m03` join `test`.`t1` `m04` join `test`.`t1` `m05` join `test`.`t1` `m06` join `test`.`t1` `m07` join `test`.`t1` `m08` join `test`.`t1` `m09` join `test`.`t1` `m10` join `test`.`t1` `m11` join `test`.`t1` `m12` join `test`.`t1` `m13` join `test`.`t1` `m14` join `test`.`t1` `m15` join `test`.`t1` `m16` join `test`.`t1` `m17` join `test`.`t1` `m18` join `test`.`t1` `m19` where ((`test`.`s00`.`a`) = `test`.`m00`.`a`))) +select * from +t1 left join t2 on (t2.a= t1.a and t2.a in (select pk from t10)) +where t1.a < 5; +a b a b +0 0 0 0 +1 1 1 1 +2 2 2 2 +prepare s1 from +' select * from + t1 left join t2 on (t2.a= t1.a and t2.a in (select pk from t10)) + where t1.a < 5'; +execute s1; +a b a b +0 0 0 0 +1 1 1 1 +2 2 2 2 +execute s1; +a b a b +0 0 0 0 +1 1 1 1 +2 2 2 2 +insert into t1 select (A.a + 10 * B.a),1 from t0 A, t0 B; +explain select * from t1 where a in (select pk from t10 where pk<3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t10 NULL range PRIMARY PRIMARY 4 NULL 4 100.00 Using where; Using index +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 103 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t1` where ((`test`.`t1`.`a` = `test`.`t10`.`pk`) and (`test`.`t10`.`pk` < 3)) +drop table t0, t1, t2; +drop table t10, t11, t12; +# +# Check that subqueries with outer joins or straight_join work for +# different permutations of const and non-const tables. (Ref. Bug#46692) +# +CREATE TABLE t1 (i INTEGER); +CREATE TABLE t2 (i INTEGER); +CREATE TABLE t3 (i INTEGER); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 0 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 0 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 0 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 1 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 1 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 1 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 2 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 2 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 2 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (0); +DELETE FROM t2; +INSERT INTO t1 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 0 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 0 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 0 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 1 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 1 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 1 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 2 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 2 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 2 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (0); +DELETE FROM t2; +INSERT INTO t1 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 0 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = `test`.`t1`.`i`) and (`test`.`t3`.`i` = `test`.`t1`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = `test`.`t1`.`i`) and (`test`.`t3`.`i` = `test`.`t1`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = `test`.`t1`.`i`) and (`test`.`t3`.`i` = `test`.`t1`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = `test`.`t1`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = `test`.`t1`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 0 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = `test`.`t1`.`i`) and (`test`.`t3`.`i` = `test`.`t1`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = `test`.`t1`.`i`) and (`test`.`t3`.`i` = `test`.`t1`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = `test`.`t1`.`i`) and (`test`.`t3`.`i` = `test`.`t1`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = `test`.`t1`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = `test`.`t1`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 0 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = `test`.`t1`.`i`) and (`test`.`t3`.`i` = `test`.`t1`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = `test`.`t1`.`i`) and (`test`.`t3`.`i` = `test`.`t1`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = `test`.`t1`.`i`) and (`test`.`t3`.`i` = `test`.`t1`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = `test`.`t1`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +1 +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = `test`.`t1`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 1 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = `test`.`t1`.`i`) and (`test`.`t2`.`i` = `test`.`t1`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = `test`.`t1`.`i`) and (`test`.`t2`.`i` = `test`.`t1`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = `test`.`t1`.`i`) and (`test`.`t2`.`i` = `test`.`t1`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = `test`.`t1`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = `test`.`t1`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 1 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = `test`.`t1`.`i`) and (`test`.`t3`.`i` = `test`.`t1`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = `test`.`t1`.`i`) and (`test`.`t3`.`i` = `test`.`t1`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = `test`.`t1`.`i`) and (`test`.`t3`.`i` = `test`.`t1`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = `test`.`t1`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = `test`.`t1`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 1 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = `test`.`t1`.`i`) and (`test`.`t3`.`i` = `test`.`t1`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = `test`.`t1`.`i`) and (`test`.`t3`.`i` = `test`.`t1`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = `test`.`t1`.`i`) and (`test`.`t3`.`i` = `test`.`t1`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = `test`.`t1`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +1 +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = `test`.`t1`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +1 +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 2 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = `test`.`t1`.`i`) and (`test`.`t2`.`i` = `test`.`t1`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = `test`.`t1`.`i`) and (`test`.`t2`.`i` = `test`.`t1`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = `test`.`t1`.`i`) and (`test`.`t2`.`i` = `test`.`t1`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = `test`.`t1`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = `test`.`t1`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 2 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = `test`.`t1`.`i`) and (`test`.`t2`.`i` = `test`.`t1`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = `test`.`t1`.`i`) and (`test`.`t2`.`i` = `test`.`t1`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = `test`.`t1`.`i`) and (`test`.`t2`.`i` = `test`.`t1`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = `test`.`t1`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = `test`.`t1`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 2 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = `test`.`t1`.`i`) and (`test`.`t3`.`i` = `test`.`t1`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +1 +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +1 +2 + +EXECUTE stmt; +i +1 +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = `test`.`t1`.`i`) and (`test`.`t3`.`i` = `test`.`t1`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +1 +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = `test`.`t1`.`i`) and (`test`.`t3`.`i` = `test`.`t1`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +1 +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +1 +2 + +EXECUTE stmt; +i +1 +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = `test`.`t1`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +1 +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = `test`.`t1`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +1 +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (0); +DELETE FROM t2; +INSERT INTO t1 VALUES (0); +DROP TABLE t1, t2, t3; +create table x1(k int primary key, d1 int, d2 int); +create table x2(k int primary key, d1 int, d2 int); +insert into x1 values +(10, 10, 10), +(20, 20, 20), +(21, 20, null), +(30, null, 30), +(40, 40, 40); +insert into x2 values +(10, 10, 10), +(20, 20, 20), +(21, 20, null), +(30, null, 30); +select * +from x1 +where (d1, d2) in (select d1, d2 +from x2); +k d1 d2 +10 10 10 +20 20 20 +select * +from x1 +where (d1, d2) in (select d1, d2 +from x2) is true; +k d1 d2 +10 10 10 +20 20 20 +select * +from x1 +where (d1, d2) in (select d1, d2 +from x2) is false; +k d1 d2 +40 40 40 +select * +from x1 +where (d1, d2) in (select d1, d2 +from x2) is unknown; +k d1 d2 +21 20 NULL +30 NULL 30 +select * +from x1 +where d1 in (select d1 +from x2 +where x1.d2=x2.d2); +k d1 d2 +10 10 10 +20 20 20 +select * +from x1 +where d1 in (select d1 +from x2 +where x1.d2=x2.d2) is true; +k d1 d2 +10 10 10 +20 20 20 +select * +from x1 +where d1 in (select d1 +from x2 +where x1.d2=x2.d2) is false; +k d1 d2 +21 20 NULL +40 40 40 +select * +from x1 +where d1 in (select d1 +from x2 +where x1.d2=x2.d2) is unknown; +k d1 d2 +30 NULL 30 +select * +from x1 +where 1 in (select 1 +from x2 +where x1.d1=x2.d1 and x1.d2=x2.d2); +k d1 d2 +10 10 10 +20 20 20 +select * +from x1 +where 1 in (select 1 +from x2 +where x1.d1=x2.d1 and x1.d2=x2.d2) is true; +k d1 d2 +10 10 10 +20 20 20 +select * +from x1 +where 1 in (select 1 +from x2 +where x1.d1=x2.d1 and x1.d2=x2.d2) is false; +k d1 d2 +21 20 NULL +30 NULL 30 +40 40 40 +select * +from x1 +where 1 in (select 1 +from x2 +where x1.d1=x2.d1 and x1.d2=x2.d2) is unknown; +k d1 d2 +select * +from x1 +where exists (select * +from x2 +where x1.d1=x2.d1 and x1.d2=x2.d2); +k d1 d2 +10 10 10 +20 20 20 +drop table x1; +drop table x2; +CREATE TABLE t1 ( +a int(11) NOT NULL, +b int(11) NOT NULL, +c datetime default NULL, +PRIMARY KEY (a), +KEY idx_bc (b,c) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES +(406989,67,'2006-02-23 17:08:46'), (150078,67,'2005-10-26 11:17:45'), +(406993,67,'2006-02-27 11:20:57'), (245655,67,'2005-12-08 15:59:08'), +(406994,67,'2006-02-27 11:26:46'), (256,67,NULL), +(398341,67,'2006-02-20 04:48:44'), (254,67,NULL),(1120,67,NULL), +(406988,67,'2006-02-23 17:07:22'), (255,67,NULL), +(398340,67,'2006-02-20 04:38:53'),(406631,67,'2006-02-23 10:49:42'), +(245653,67,'2005-12-08 15:59:07'),(406992,67,'2006-02-24 16:47:18'), +(245654,67,'2005-12-08 15:59:08'),(406995,67,'2006-02-28 11:55:00'), +(127261,67,'2005-10-13 12:17:58'),(406991,67,'2006-02-24 16:42:32'), +(245652,67,'2005-12-08 15:58:27'),(398545,67,'2006-02-20 04:53:13'), +(154504,67,'2005-10-28 11:53:01'),(9199,67,NULL),(1,67,'2006-02-23 15:01:35'), +(223456,67,NULL),(4101,67,NULL),(1133,67,NULL), +(406990,67,'2006-02-23 18:01:45'),(148815,67,'2005-10-25 15:34:17'), +(148812,67,'2005-10-25 15:30:01'),(245651,67,'2005-12-08 15:58:27'), +(154503,67,'2005-10-28 11:52:38'); +create table t11 select * from t1 where b = 67 AND (c IS NULL OR c > NOW()) order by 3 asc; +create table t12 select * from t1 where b = 67 AND (c IS NULL OR c > NOW()) order by 3 desc; +create table t21 select * from t1 where b = 67 AND (c IS NULL OR c > '2005-12-08') order by 3 asc; +create table t22 select * from t1 where b = 67 AND (c IS NULL OR c > '2005-12-08') order by 3 desc; +update t22 set c = '2005-12-08 15:58:27' where a = 255; +explain select t21.* from t21,t22 where t21.a = t22.a and +t22.a in (select t12.a from t11, t12 where t11.a in(255,256) and t11.a = t12.a and t11.c is null) and t22.c is null order by t21.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t21 NULL ALL NULL NULL NULL NULL 26 100.00 Using where; Using filesort +1 SIMPLE t22 NULL ALL NULL NULL NULL NULL 26 3.85 Using where +1 SIMPLE t11 NULL ALL NULL NULL NULL NULL 8 12.50 Using where +1 SIMPLE t12 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; FirstMatch(t22) +Warnings: +Note 1003 /* select#1 */ select `test`.`t21`.`a` AS `a`,`test`.`t21`.`b` AS `b`,`test`.`t21`.`c` AS `c` from `test`.`t21` join `test`.`t22` semi join (`test`.`t11` join `test`.`t12`) where ((`test`.`t22`.`a` = `test`.`t21`.`a`) and (`test`.`t11`.`a` = `test`.`t21`.`a`) and (`test`.`t12`.`a` = `test`.`t21`.`a`) and (`test`.`t22`.`c` is null) and (`test`.`t21`.`a` in (255,256)) and (`test`.`t11`.`c` is null)) order by `test`.`t21`.`a` +explain format=json select * from t1 where a in (select a from t11); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "45.55" + }, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "possible_keys": [ + "PRIMARY" + ], + "rows_examined_per_scan": 32, + "rows_produced_per_join": 32, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.53", + "eval_cost": "3.20", + "prefix_cost": "3.73", + "data_read_per_join": "512" + }, + "used_columns": [ + "a", + "b", + "c" + ] + } + }, + { + "table": { + "table_name": "t11", + "access_type": "ALL", + "rows_examined_per_scan": 8, + "rows_produced_per_join": 32, + "filtered": "12.50", + "first_match": "t1", + "cost_info": { + "read_cost": "16.22", + "eval_cost": "3.20", + "prefix_cost": "45.55", + "data_read_per_join": "512" + }, + "used_columns": [ + "a" + ], + "attached_condition": "(`test`.`t11`.`a` = `test`.`t1`.`a`)" + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` semi join (`test`.`t11`) where (`test`.`t11`.`a` = `test`.`t1`.`a`) +select t21.* from t21,t22 where t21.a = t22.a and +t22.a in (select t12.a from t11, t12 where t11.a in(255,256) and t11.a = t12.a and t11.c is null) and t22.c is null order by t21.a; +a b c +256 67 NULL +drop table t1, t11, t12, t21, t22; +create table t1(a int); +insert into t1 values (0),(1); +explain +select (select max(y.a) from t1 y where a in (select a from t1 z) and a < x.a) as subq from t1 x; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY x NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DEPENDENT SUBQUERY y NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 DEPENDENT SUBQUERY z NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(y) +Warnings: +Note 1276 Field or reference 'test.x.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select (/* select#2 */ select max(`test`.`y`.`a`) from `test`.`t1` `y` semi join (`test`.`t1` `z`) where ((`test`.`z`.`a` = `test`.`y`.`a`) and (`test`.`y`.`a` < `test`.`x`.`a`))) AS `subq` from `test`.`t1` `x` +select (select max(y.a) from t1 y where a in (select a from t1 z) and a < x.a) as subq from t1 x; +subq +NULL +0 +drop table t1; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 as select * from t0; +insert into t1 select a+10 from t0; +insert into t0 values(2); +explain select * from t1 where 2 in (select a from t0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 11 10.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 20 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t0`) where (`test`.`t0`.`a` = 2) +select * from t1 where 2 in (select a from t0); +a +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +explain select * from (select a from t0) x where a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 11 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 20 10.00 Using where; FirstMatch(t0) +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a` from `test`.`t0` semi join (`test`.`t1`) where (`test`.`t1`.`a` = `test`.`t0`.`a`) +explain format=json select * from (select a from t0) x where a in (select a from t1); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "29.20" + }, + "nested_loop": [ + { + "table": { + "table_name": "t0", + "access_type": "ALL", + "rows_examined_per_scan": 11, + "rows_produced_per_join": 11, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "1.10", + "prefix_cost": "1.60", + "data_read_per_join": "88" + }, + "used_columns": [ + "a" + ] + } + }, + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 11, + "filtered": "10.00", + "first_match": "t0", + "cost_info": { + "read_cost": "5.59", + "eval_cost": "1.10", + "prefix_cost": "29.20", + "data_read_per_join": "88" + }, + "used_columns": [ + "a" + ], + "attached_condition": "(`test`.`t1`.`a` = `test`.`t0`.`a`)" + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a` from `test`.`t0` semi join (`test`.`t1`) where (`test`.`t1`.`a` = `test`.`t0`.`a`) +drop table t0, t1; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (kp1 int, kp2 int, c int, filler char(100), key(kp1, kp2)); +insert into t1 select A.a+10*(B.a+10*C.a), 0, 0, 'filler' from t0 A, t0 B, t0 C; +insert into t1 select * from t1 where kp1 < 20; +create table t3 (a int); +insert into t3 select A.a + 10*B.a from t0 A, t0 B; +explain select * from t3 where a in (select kp1 from t1 where kp1<20); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 100 100.00 Using where +1 SIMPLE t1 NULL ref kp1 kp1 5 test.t3.a 1 100.00 Using index; FirstMatch(t3) +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a` from `test`.`t3` semi join (`test`.`t1`) where ((`test`.`t1`.`kp1` = `test`.`t3`.`a`) and (`test`.`t3`.`a` < 20)) +select * from t3 where a in (select kp1 from t1 where kp1<20); +a +0 +1 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +2 +3 +4 +5 +6 +7 +8 +9 +explain select * from t3 where a in (select kp1 from t1 where kp1<20) and a<20; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 100 33.33 Using where +1 SIMPLE t1 NULL ref kp1 kp1 5 test.t3.a 1 100.00 Using index; FirstMatch(t3) +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a` from `test`.`t3` semi join (`test`.`t1`) where ((`test`.`t1`.`kp1` = `test`.`t3`.`a`) and (`test`.`t3`.`a` < 20) and (`test`.`t3`.`a` < 20)) +select * from t3 where a in (select kp1 from t1 where kp1<20) and a<20; +a +0 +1 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +2 +3 +4 +5 +6 +7 +8 +9 +create table t4 (pk int primary key); +insert into t4 select a from t3; +explain select * from t3 where a in +(select t1.kp1 from t1,t4 where kp1<20 and t4.pk=t1.c); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 100 100.00 Using where +1 SIMPLE t1 NULL ref kp1 kp1 5 test.t3.a 1 100.00 Using where +1 SIMPLE t4 NULL eq_ref PRIMARY PRIMARY 4 test.t1.c 1 100.00 Using index; FirstMatch(t3) +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a` from `test`.`t3` semi join (`test`.`t1` join `test`.`t4`) where ((`test`.`t1`.`kp1` = `test`.`t3`.`a`) and (`test`.`t4`.`pk` = `test`.`t1`.`c`) and (`test`.`t3`.`a` < 20)) +explain format=tree select * from t3 where a in +(select t1.kp1 from t1,t4 where kp1<20 and t4.pk=t1.c); +EXPLAIN +-> Nested loop semijoin (cost=45.54 rows=100) + -> Filter: ((t3.a < 20) and (t3.a is not null)) (cost=10.54 rows=100) + -> Table scan on t3 (cost=10.54 rows=100) + -> Nested loop inner join (cost=25.35 rows=1) + -> Filter: (t1.c is not null) (cost=0.25 rows=1) + -> Index lookup on t1 using kp1 (kp1=t3.a) (cost=0.25 rows=1) + -> Single-row index lookup on t4 using PRIMARY (pk=t1.c) (cost=0.25 rows=1) + +select * from t3 where a in +(select t1.kp1 from t1,t4 where kp1<20 and t4.pk=t1.c); +a +0 +1 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +2 +3 +4 +5 +6 +7 +8 +9 +drop table t1, t3, t4; +create table t1 (a int); +insert into t1 values (0),(0),(0),(1),(1),(1),(2),(2),(2),(3),(3),(3); +set session internal_tmp_mem_storage_engine='memory'; +set @save_max_heap_table_size=@@max_heap_table_size; +set @@max_heap_table_size= 16384; +# Attempt to make one test that overflows the heap table when a +# non-duplicate row is inserted and one test that overflows the +# heap table when a duplicate record is inserted. Debugging showed +# that these situations occurred with max_heap_table_size=16384 +# and optimizer_join_cache_level equals 1 and 0, respectively. +# Finally execute a test that does not overflow the heap table. +explain +select count(*) from t0 a, t0 b, t0 c +where c.a in (select a from t1 d); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE a NULL ALL NULL NULL NULL NULL 10 100.00 NULL +1 SIMPLE b NULL ALL NULL NULL NULL NULL 10 100.00 NULL +1 SIMPLE c NULL ALL NULL NULL NULL NULL 10 100.00 NULL +1 SIMPLE d NULL ALL NULL NULL NULL NULL 12 10.00 Using where; FirstMatch(c) +Warnings: +Note 1003 /* select#1 */ select count(0) AS `count(*)` from `test`.`t0` `a` join `test`.`t0` `b` join `test`.`t0` `c` semi join (`test`.`t1` `d`) where (`test`.`d`.`a` = `test`.`c`.`a`) +flush status; +select count(*) from t0 a, t0 b, t0 c +where c.a in (select a from t1 d); +count(*) +400 +show status like 'Created_tmp_disk_tables'; +Variable_name Value +Created_tmp_disk_tables 0 +set @@max_heap_table_size= @save_max_heap_table_size; +set session internal_tmp_mem_storage_engine=default; +flush status; +select count(*) from t0 a, t0 b, t0 c +where c.a in (select a from t1 d); +count(*) +400 +show status like 'Created_tmp_disk_tables'; +Variable_name Value +Created_tmp_disk_tables 0 +drop table t0, t1; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t2(a int); +insert into t2 values (1),(2); +create table t3 ( a int , filler char(100), key(a)); +insert into t3 select A.a + 10*B.a, 'filler' from t0 A, t0 B; +explain select * from t3 where a in (select a from t2) and (a > 5 or a < 10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL a NULL NULL NULL 100 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t3) +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a`,`test`.`t3`.`filler` AS `filler` from `test`.`t3` semi join (`test`.`t2`) where ((`test`.`t2`.`a` = `test`.`t3`.`a`) and ((`test`.`t3`.`a` > 5) or (`test`.`t3`.`a` < 10))) +select * from t3 where a in (select a from t2); +a filler +1 filler +2 filler +drop table t0, t2, t3; +create table t1 (a date); +insert into t1 values ('2008-01-01'),('2008-01-01'),('2008-02-01'),('2008-02-01'); +create table t2 (a int); +insert into t2 values (1),(2); +create table t3 (a char(10)); +insert into t3 select * from t1; +insert into t3 values (1),(2); +explain select * from t2 where a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; FirstMatch(t2) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1`) where (cast(`test`.`t2`.`a` as double) = cast(`test`.`t1`.`a` as double)) +explain select * from t2 where a in (select a from t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t2) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t2`) where (`test`.`t2`.`a` = `test`.`t2`.`a`) +explain select * from t2 where a in (select a from t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; FirstMatch(t2) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t3`) where (cast(`test`.`t2`.`a` as double) = cast(`test`.`t3`.`a` as double)) +explain select * from t1 where a in (select a from t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t3`) where (`test`.`t1`.`a` = cast(`test`.`t3`.`a` as date)) +drop table t1, t2, t3; +create table t1 (a decimal); +insert into t1 values (1),(2); +explain select * from t1 where a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t1`) where (`test`.`t1`.`a` = `test`.`t1`.`a`) +drop table t1; +create table t1 (a int); +insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t2 as select * from t1; +create table t3 (a int, b int, filler char(100), key(a)) charset utf8mb4; +insert into t3 select A.a + 10*B.a, A.a + 10*B.a, 'filler' from t1 A, t1 B, t1 C; +explain select * from t1, t3 where t3.a in (select a from t2) and (t3.a < 10 or t3.a >30) and t1.a =3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 10.00 Using where +1 SIMPLE t3 NULL ALL a NULL NULL NULL 1000 79.30 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 10 10.00 Using where; FirstMatch(t3) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t3`.`filler` AS `filler` from `test`.`t1` join `test`.`t3` semi join (`test`.`t2`) where ((`test`.`t2`.`a` = `test`.`t3`.`a`) and (`test`.`t1`.`a` = 3) and ((`test`.`t3`.`a` < 10) or (`test`.`t3`.`a` > 30))) +explain format=json select * from t1, t3 where t3.a in (select a from t2) and (t3.a < 10 or t3.a >30) and t1.a =3; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1319.85" + }, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 10, + "rows_produced_per_join": 1, + "filtered": "10.00", + "cost_info": { + "read_cost": "1.40", + "eval_cost": "0.10", + "prefix_cost": "1.50", + "data_read_per_join": "8" + }, + "used_columns": [ + "a" + ], + "attached_condition": "(`test`.`t1`.`a` = 3)" + } + }, + { + "table": { + "table_name": "t3", + "access_type": "ALL", + "possible_keys": [ + "a" + ], + "rows_examined_per_scan": 1000, + "rows_produced_per_join": 793, + "filtered": "79.30", + "cost_info": { + "read_cost": "46.16", + "eval_cost": "79.30", + "prefix_cost": "126.97", + "data_read_per_join": "322K" + }, + "used_columns": [ + "a", + "b", + "filler" + ], + "attached_condition": "((`test`.`t3`.`a` < 10) or (`test`.`t3`.`a` > 30))" + } + }, + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 10, + "rows_produced_per_join": 793, + "filtered": "10.00", + "first_match": "t3", + "cost_info": { + "read_cost": "399.89", + "eval_cost": "79.30", + "prefix_cost": "1319.86", + "data_read_per_join": "6K" + }, + "used_columns": [ + "a" + ], + "attached_condition": "(`test`.`t2`.`a` = `test`.`t3`.`a`)" + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t3`.`filler` AS `filler` from `test`.`t1` join `test`.`t3` semi join (`test`.`t2`) where ((`test`.`t2`.`a` = `test`.`t3`.`a`) and (`test`.`t1`.`a` = 3) and ((`test`.`t3`.`a` < 10) or (`test`.`t3`.`a` > 30))) +explain select straight_join * from t1 a, t1 b where a.a in (select a from t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY a NULL ALL NULL NULL NULL NULL 10 100.00 Using where +1 PRIMARY b NULL ALL NULL NULL NULL NULL 10 100.00 NULL +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select straight_join `test`.`a`.`a` AS `a`,`test`.`b`.`a` AS `a` from `test`.`t1` `a` join `test`.`t1` `b` where (`test`.`a`.`a`,(/* select#2 */ select `test`.`t2`.`a` from `test`.`t2` where ((`test`.`a`.`a`) = `test`.`t2`.`a`))) +explain select * from t2 where a in (select straight_join a.a from t1 a, t1 b); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 10 100.00 Using where +2 DEPENDENT SUBQUERY a NULL ALL NULL NULL NULL NULL 10 10.00 Using where +2 DEPENDENT SUBQUERY b NULL ALL NULL NULL NULL NULL 10 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` where (`test`.`t2`.`a`,(/* select#2 */ select straight_join `test`.`a`.`a` from `test`.`t1` `a` join `test`.`t1` `b` where ((`test`.`t2`.`a`) = `test`.`a`.`a`))) +explain select * from t2 where a in (select straight_join a.a from t1 a, t1 b); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 10 100.00 Using where +2 DEPENDENT SUBQUERY a NULL ALL NULL NULL NULL NULL 10 10.00 Using where +2 DEPENDENT SUBQUERY b NULL ALL NULL NULL NULL NULL 10 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` where (`test`.`t2`.`a`,(/* select#2 */ select straight_join `test`.`a`.`a` from `test`.`t1` `a` join `test`.`t1` `b` where ((`test`.`t2`.`a`) = `test`.`a`.`a`))) +explain select straight_join * from t2 x, t2 y +where x.a in (select straight_join a.a from t1 a, t1 b); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY x NULL ALL NULL NULL NULL NULL 10 100.00 Using where +1 PRIMARY y NULL ALL NULL NULL NULL NULL 10 100.00 NULL +2 DEPENDENT SUBQUERY a NULL ALL NULL NULL NULL NULL 10 10.00 Using where +2 DEPENDENT SUBQUERY b NULL ALL NULL NULL NULL NULL 10 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select straight_join `test`.`x`.`a` AS `a`,`test`.`y`.`a` AS `a` from `test`.`t2` `x` join `test`.`t2` `y` where (`test`.`x`.`a`,(/* select#2 */ select straight_join `test`.`a`.`a` from `test`.`t1` `a` join `test`.`t1` `b` where ((`test`.`x`.`a`) = `test`.`a`.`a`))) +create table t0 (a int, b int); +insert into t0 values(1,1); +explain select * from t0, t3 where t3.a in (select a from t2) and (t3.a < 10 or t3.a >30); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL a NULL NULL NULL 1000 79.30 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 10 10.00 Using where; FirstMatch(t3) +Warnings: +Note 1003 /* select#1 */ select '1' AS `a`,'1' AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t3`.`filler` AS `filler` from `test`.`t3` semi join (`test`.`t2`) where ((`test`.`t2`.`a` = `test`.`t3`.`a`) and ((`test`.`t3`.`a` < 10) or (`test`.`t3`.`a` > 30))) +create table t4 as select a as x, a as y from t1; +explain select * from t0, t3 where (t3.a, t3.b) in (select x,y from t4) and (t3.a < 10 or t3.a >30); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL a NULL NULL NULL 1000 79.30 Using where +1 SIMPLE t4 NULL ALL NULL NULL NULL NULL 10 10.00 Using where; FirstMatch(t3) +Warnings: +Note 1003 /* select#1 */ select '1' AS `a`,'1' AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t3`.`filler` AS `filler` from `test`.`t3` semi join (`test`.`t4`) where ((`test`.`t4`.`y` = `test`.`t3`.`b`) and (`test`.`t4`.`x` = `test`.`t3`.`a`) and ((`test`.`t3`.`a` < 10) or (`test`.`t3`.`a` > 30))) +drop table t0,t1,t2,t3,t4; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (a int, b int, filler char(100), key(a,b)); +insert into t1 select A.a, B.a, 'filler' from t0 A, t0 B; +create table t2 as select * from t1; +explain select * from t2 where a in (select b from t1 where a=3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 100 100.00 Using where +1 SIMPLE t1 NULL ref a a 10 const,test.t2.a 1 100.00 Using index; FirstMatch(t2) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`filler` AS `filler` from `test`.`t2` semi join (`test`.`t1`) where ((`test`.`t1`.`b` = `test`.`t2`.`a`) and (`test`.`t1`.`a` = 3)) +explain select * from t2 where (b,a) in (select a,b from t1 where a=3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 100 10.00 Using where +1 SIMPLE t1 NULL ref a a 10 const,test.t2.a 1 100.00 Using index; FirstMatch(t2) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`filler` AS `filler` from `test`.`t2` semi join (`test`.`t1`) where ((`test`.`t1`.`b` = `test`.`t2`.`a`) and (`test`.`t2`.`b` = 3) and (`test`.`t1`.`a` = 3)) +drop table t1,t2; +create table t1 (a int, b int); +insert into t1 select a,a from t0; +create table t2 (a int, b int); +insert into t2 select A.a + 10*B.a, A.a + 10*B.a from t0 A, t0 B; +explain select * from t1 where (a,b) in (select a,b from t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 100 1.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`a` = `test`.`t1`.`a`)) +drop table t0, t1, t2; +# +# Bug#19695490: CRASH IN CREATE_REF_FOR_KEY ON SELECT + JOIN + UTF8 COLUMN +# + DATETIME INDEX. +# +CREATE TABLE t1 ( +field1 varchar(255) CHARACTER SET utf8, +field2 varchar(255) CHARACTER SET utf8 +); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES +('time','time'), +('lpjdzvkp','lpjdzvkp'), +('dzvkpai', 'dzvkpai'); +CREATE TABLE t2 ( col_varchar varchar(10)); +CREATE TABLE t3 ( +pk int(11) NOT NULL, +col_varchar_255_utf8_key varchar(255) CHARACTER SET utf8, +col_varchar_10_utf8_key varchar(10) CHARACTER SET utf8, +PRIMARY KEY (pk) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t3 VALUES (22,'come','h'), +(23,'time','aaa'), +(24,'lpjdzvkp','ababa'), +(25,'d','GGDD'); +SELECT * FROM t1 WHERE (field1, field2) IN ( +SELECT table1.col_varchar_255_utf8_key AS field1, +table1.col_varchar_255_utf8_key AS field2 +FROM t3 AS table1 LEFT JOIN t2 AS table2 +ON table1.col_varchar_10_utf8_key <= +table2.col_varchar +WHERE table1.pk >= 6); +field1 field2 +time time +lpjdzvkp lpjdzvkp +DROP TABLE t1,t2,t3; +create table t0 (a decimal(4,2)); +insert into t0 values (10.24), (22.11); +create table t1 as select * from t0; +insert into t1 select * from t0; +explain select * from t0 where a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; FirstMatch(t0) +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a` from `test`.`t0` semi join (`test`.`t1`) where (`test`.`t1`.`a` = `test`.`t0`.`a`) +select * from t0 where a in (select a from t1); +a +10.24 +22.11 +drop table t0, t1; +create table t0(a date); +insert into t0 values ('2008-01-01'),('2008-02-02'); +create table t1 as select * from t0; +insert into t1 select * from t0; +explain select * from t0 where a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; FirstMatch(t0) +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a` from `test`.`t0` semi join (`test`.`t1`) where (`test`.`t1`.`a` = `test`.`t0`.`a`) +select * from t0 where a in (select a from t1); +a +2008-01-01 +2008-02-02 +drop table t0, t1; +create table t0(a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 as select a as a, a as b, a as c from t0 where a < 3; +create table t2 as select a as a, a as b from t0 where a < 3; +insert into t2 select * from t2; +explain select * from t1 where (a,b,c) in (select x.a, y.a, z.a from t2 x, t2 y, t2 z where x.b=33); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE x NULL ALL NULL NULL NULL NULL 6 16.67 Using where +1 SIMPLE y NULL ALL NULL NULL NULL NULL 6 16.67 Using where +1 SIMPLE z NULL ALL NULL NULL NULL NULL 6 16.67 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` semi join (`test`.`t2` `x` join `test`.`t2` `y` join `test`.`t2` `z`) where ((`test`.`z`.`a` = `test`.`t1`.`c`) and (`test`.`y`.`a` = `test`.`t1`.`b`) and (`test`.`x`.`a` = `test`.`t1`.`a`) and (`test`.`x`.`b` = 33)) +drop table t0,t1,t2; +set @save_join_buffer_size = @@join_buffer_size; +set join_buffer_size= 8192; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (a int, filler1 binary(200), filler2 binary(200)); +insert into t1 select a, 'filler123456', 'filler123456' from t0; +insert into t1 select a+10, 'filler123456', 'filler123456' from t0; +create table t2 as select * from t1; +insert into t1 select a+20, 'filler123456', 'filler123456' from t0; +insert into t1 values (2, 'duplicate ok', 'duplicate ok'); +insert into t1 values (18, 'duplicate ok', 'duplicate ok'); +insert into t2 values (3, 'duplicate ok', 'duplicate ok'); +insert into t2 values (19, 'duplicate ok', 'duplicate ok'); +explain select +a, mid(filler1, 1,10), length(filler1)=length(filler2) as z +from t1 ot where a in (select a from t2 it); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 32 100.00 NULL +1 SIMPLE it NULL ALL NULL NULL NULL NULL 22 10.00 Using where; FirstMatch(ot) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot`.`a` AS `a`,substr(`test`.`ot`.`filler1`,1,10) AS `mid(filler1, 1,10)`,(length(`test`.`ot`.`filler1`) = length(`test`.`ot`.`filler2`)) AS `z` from `test`.`t1` `ot` semi join (`test`.`t2` `it`) where (`test`.`it`.`a` = `test`.`ot`.`a`) +select +a, mid(filler1, 1,10), length(filler1)=length(filler2) as z +from t1 ot where a in (select a from t2 it); +a mid(filler1, 1,10) z +0 filler1234 1 +1 filler1234 1 +10 filler1234 1 +11 filler1234 1 +12 filler1234 1 +13 filler1234 1 +14 filler1234 1 +15 filler1234 1 +16 filler1234 1 +17 filler1234 1 +18 duplicate 1 +18 filler1234 1 +19 filler1234 1 +2 duplicate 1 +2 filler1234 1 +3 filler1234 1 +4 filler1234 1 +5 filler1234 1 +6 filler1234 1 +7 filler1234 1 +8 filler1234 1 +9 filler1234 1 +explain select +a, mid(filler1, 1,10), length(filler1)=length(filler2) +from t2 ot where a in (select a from t1 it); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 22 100.00 NULL +1 SIMPLE it NULL ALL NULL NULL NULL NULL 32 10.00 Using where; FirstMatch(ot) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot`.`a` AS `a`,substr(`test`.`ot`.`filler1`,1,10) AS `mid(filler1, 1,10)`,(length(`test`.`ot`.`filler1`) = length(`test`.`ot`.`filler2`)) AS `length(filler1)=length(filler2)` from `test`.`t2` `ot` semi join (`test`.`t1` `it`) where (`test`.`it`.`a` = `test`.`ot`.`a`) +select +a, mid(filler1, 1,10), length(filler1)=length(filler2) +from t2 ot where a in (select a from t1 it); +a mid(filler1, 1,10) length(filler1)=length(filler2) +0 filler1234 1 +1 filler1234 1 +10 filler1234 1 +11 filler1234 1 +12 filler1234 1 +13 filler1234 1 +14 filler1234 1 +15 filler1234 1 +16 filler1234 1 +17 filler1234 1 +18 filler1234 1 +19 duplicate 1 +19 filler1234 1 +2 filler1234 1 +3 duplicate 1 +3 filler1234 1 +4 filler1234 1 +5 filler1234 1 +6 filler1234 1 +7 filler1234 1 +8 filler1234 1 +9 filler1234 1 +insert into t1 select a+20, 'filler123456', 'filler123456' from t0; +insert into t1 select a+20, 'filler123456', 'filler123456' from t0; +explain select +a, mid(filler1, 1,10), length(filler1)=length(filler2) as z +from t1 ot where a in (select a from t2 it); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 52 100.00 NULL +1 SIMPLE it NULL ALL NULL NULL NULL NULL 22 10.00 Using where; FirstMatch(ot) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot`.`a` AS `a`,substr(`test`.`ot`.`filler1`,1,10) AS `mid(filler1, 1,10)`,(length(`test`.`ot`.`filler1`) = length(`test`.`ot`.`filler2`)) AS `z` from `test`.`t1` `ot` semi join (`test`.`t2` `it`) where (`test`.`it`.`a` = `test`.`ot`.`a`) +select +a, mid(filler1, 1,10), length(filler1)=length(filler2) as z +from t1 ot where a in (select a from t2 it); +a mid(filler1, 1,10) z +0 filler1234 1 +1 filler1234 1 +10 filler1234 1 +11 filler1234 1 +12 filler1234 1 +13 filler1234 1 +14 filler1234 1 +15 filler1234 1 +16 filler1234 1 +17 filler1234 1 +18 duplicate 1 +18 filler1234 1 +19 filler1234 1 +2 duplicate 1 +2 filler1234 1 +3 filler1234 1 +4 filler1234 1 +5 filler1234 1 +6 filler1234 1 +7 filler1234 1 +8 filler1234 1 +9 filler1234 1 +explain select +a, mid(filler1, 1,10), length(filler1)=length(filler2) +from t2 ot where a in (select a from t1 it); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 22 100.00 NULL +1 SIMPLE it NULL ALL NULL NULL NULL NULL 52 10.00 Using where; FirstMatch(ot) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot`.`a` AS `a`,substr(`test`.`ot`.`filler1`,1,10) AS `mid(filler1, 1,10)`,(length(`test`.`ot`.`filler1`) = length(`test`.`ot`.`filler2`)) AS `length(filler1)=length(filler2)` from `test`.`t2` `ot` semi join (`test`.`t1` `it`) where (`test`.`it`.`a` = `test`.`ot`.`a`) +select +a, mid(filler1, 1,10), length(filler1)=length(filler2) +from t2 ot where a in (select a from t1 it); +a mid(filler1, 1,10) length(filler1)=length(filler2) +0 filler1234 1 +1 filler1234 1 +10 filler1234 1 +11 filler1234 1 +12 filler1234 1 +13 filler1234 1 +14 filler1234 1 +15 filler1234 1 +16 filler1234 1 +17 filler1234 1 +18 filler1234 1 +19 duplicate 1 +19 filler1234 1 +2 filler1234 1 +3 duplicate 1 +3 filler1234 1 +4 filler1234 1 +5 filler1234 1 +6 filler1234 1 +7 filler1234 1 +8 filler1234 1 +9 filler1234 1 +set @@join_buffer_size = @save_join_buffer_size; +drop table t1, t2; +create table t1 (a int, b int, key(a)); +create table t2 (a int, b int, key(a)); +create table t3 (a int, b int, key(a)); +insert into t1 select a,a from t0; +insert into t2 select a,a from t0; +insert into t3 select a,a from t0; +t2 and t3 must be use 'ref', not 'ALL': +explain select * +from t0 where a in +(select t2.a+t3.a from t1 left join (t2 join t3) on t2.a=t1.a and t3.a=t1.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 10 100.00 NULL +1 SIMPLE t1 NULL index a a 5 NULL 10 100.00 Using where; Using index +1 SIMPLE t2 NULL ref a a 5 test.t1.a 1 100.00 Using index +1 SIMPLE t3 NULL ref a a 5 test.t1.a 1 100.00 Using index; FirstMatch(t0) +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a` from `test`.`t0` semi join (`test`.`t1` join `test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`a` = `test`.`t1`.`a`) and (`test`.`t3`.`a` = `test`.`t1`.`a`) and (`test`.`t0`.`a` = (`test`.`t1`.`a` + `test`.`t1`.`a`))) +drop table t0, t1,t2,t3; + +Test that neither MaterializeLookup strategy for semijoin, +nor subquery materialization is used when BLOBs are involved +(except when arguments of some functions). + +set @prefix_len = 6; +set @blob_len = 16; +set @suffix_len = @blob_len - @prefix_len; +create table t1_16 (a1 blob(16), a2 blob(16)); +create table t2_16 (b1 blob(16), b2 blob(16)); +create table t3_16 (c1 blob(16), c2 blob(16)); +insert into t1_16 values +(concat('1 - 00', repeat('x', @suffix_len)), concat('2 - 00', repeat('x', @suffix_len))); +insert into t1_16 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t1_16 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_16 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t2_16 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_16 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_16 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t3_16 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t3_16 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_16 values +(concat('1 - 04', repeat('x', @suffix_len)), concat('2 - 04', repeat('x', @suffix_len))); +explain select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select b1 from t2_16 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1_16 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t2_16 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(t1_16) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_16`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_16`.`a2`,7) AS `left(a2,7)` from `test`.`t1_16` semi join (`test`.`t2_16`) where ((`test`.`t2_16`.`b1` = `test`.`t1_16`.`a1`) and (`test`.`t1_16`.`a1` > '0')) +select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select b1 from t2_16 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_16 +where (a1,a2) in (select b1, b2 from t2_16 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1_16 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t2_16 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(t1_16) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_16`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_16`.`a2`,7) AS `left(a2,7)` from `test`.`t1_16` semi join (`test`.`t2_16`) where ((`test`.`t2_16`.`b2` = `test`.`t1_16`.`a2`) and (`test`.`t2_16`.`b1` = `test`.`t1_16`.`a1`) and (`test`.`t1_16`.`a1` > '0')) +select left(a1,7), left(a2,7) +from t1_16 +where (a1,a2) in (select b1, b2 from t2_16 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select substring(b1,1,16) from t2_16 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1_16 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE t2_16 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(t1_16) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_16`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_16`.`a2`,7) AS `left(a2,7)` from `test`.`t1_16` semi join (`test`.`t2_16`) where ((`test`.`t2_16`.`b1` > '0') and (`test`.`t1_16`.`a1` = substr(`test`.`t2_16`.`b1`,1,16))) +select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select substring(b1,1,16) from t2_16 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select group_concat(b1) from t2_16 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_16 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t2_16 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_16`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_16`.`a2`,7) AS `left(a2,7)` from `test`.`t1_16` where (`test`.`t1_16`.`a1`,(/* select#2 */ select group_concat(`test`.`t2_16`.`b1` separator ',') from `test`.`t2_16` group by `test`.`t2_16`.`b2` having ((`test`.`t1_16`.`a1`) = (group_concat(`test`.`t2_16`.`b1` separator ','))))) +select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select group_concat(b1) from t2_16 group by b2); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +set @@group_concat_max_len = 256; +explain select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select group_concat(b1) from t2_16 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_16 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t2_16 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_16`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_16`.`a2`,7) AS `left(a2,7)` from `test`.`t1_16` where (`test`.`t1_16`.`a1`,(/* select#2 */ select group_concat(`test`.`t2_16`.`b1` separator ',') from `test`.`t2_16` group by `test`.`t2_16`.`b2` having ((`test`.`t1_16`.`a1`) = (group_concat(`test`.`t2_16`.`b1` separator ','))))) +select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select group_concat(b1) from t2_16 group by b2); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +create table t1 (a1 char(8), a2 char(8)) charset latin1; +create table t2 (b1 char(8), b2 char(8)) charset latin1; +create table t3 (c1 char(8), c2 char(8)) charset latin1; +insert into t1 values ('1 - 00', '2 - 00'); +insert into t1 values ('1 - 01', '2 - 01'); +insert into t1 values ('1 - 02', '2 - 02'); +insert into t2 values ('1 - 01', '2 - 01'); +insert into t2 values ('1 - 01', '2 - 01'); +insert into t2 values ('1 - 02', '2 - 02'); +insert into t2 values ('1 - 02', '2 - 02'); +insert into t2 values ('1 - 03', '2 - 03'); +insert into t3 values ('1 - 01', '2 - 01'); +insert into t3 values ('1 - 02', '2 - 02'); +insert into t3 values ('1 - 03', '2 - 03'); +insert into t3 values ('1 - 04', '2 - 04'); +insert into t3 values ('1 - 05', '2 - 05'); +insert into t3 values ('1 - 06', '2 - 06'); +insert into t3 values ('1 - 07', '2 - 07'); +insert into t3 values ('1 - 08', '2 - 08'); +explain +select * from t1 +where concat(a1,'x') IN +(select left(a1,8) from t1_16 +where (a1, a2) IN +(select t2_16.b1, t2_16.b2 from t2_16, t2 +where t2.b2 = substring(t2_16.b2,1,6) and +t2.b1 IN (select c1 from t3 where c2 > '0'))); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE t1_16 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t2_16 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 5 20.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` semi join (`test`.`t1_16` join `test`.`t2_16` join `test`.`t2` join `test`.`t3`) where ((`test`.`t2_16`.`b2` = `test`.`t1_16`.`a2`) and (`test`.`t2_16`.`b1` = `test`.`t1_16`.`a1`) and (`test`.`t3`.`c1` = `test`.`t2`.`b1`) and (`test`.`t2`.`b2` = substr(`test`.`t2_16`.`b2`,1,6)) and (`test`.`t3`.`c2` > '0') and (concat(`test`.`t1`.`a1`,'x') = left(`test`.`t1_16`.`a1`,8))) +drop table t1_16, t2_16, t3_16, t1, t2, t3; +set @blob_len = 512; +set @suffix_len = @blob_len - @prefix_len; +create table t1_512 (a1 blob(512), a2 blob(512)); +create table t2_512 (b1 blob(512), b2 blob(512)); +create table t3_512 (c1 blob(512), c2 blob(512)); +insert into t1_512 values +(concat('1 - 00', repeat('x', @suffix_len)), concat('2 - 00', repeat('x', @suffix_len))); +insert into t1_512 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t1_512 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_512 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t2_512 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_512 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_512 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t3_512 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t3_512 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_512 values +(concat('1 - 04', repeat('x', @suffix_len)), concat('2 - 04', repeat('x', @suffix_len))); +explain select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select b1 from t2_512 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1_512 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t2_512 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(t1_512) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_512`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_512`.`a2`,7) AS `left(a2,7)` from `test`.`t1_512` semi join (`test`.`t2_512`) where ((`test`.`t2_512`.`b1` = `test`.`t1_512`.`a1`) and (`test`.`t1_512`.`a1` > '0')) +select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select b1 from t2_512 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_512 +where (a1,a2) in (select b1, b2 from t2_512 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1_512 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t2_512 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(t1_512) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_512`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_512`.`a2`,7) AS `left(a2,7)` from `test`.`t1_512` semi join (`test`.`t2_512`) where ((`test`.`t2_512`.`b2` = `test`.`t1_512`.`a2`) and (`test`.`t2_512`.`b1` = `test`.`t1_512`.`a1`) and (`test`.`t1_512`.`a1` > '0')) +select left(a1,7), left(a2,7) +from t1_512 +where (a1,a2) in (select b1, b2 from t2_512 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select substring(b1,1,512) from t2_512 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1_512 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE t2_512 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(t1_512) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_512`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_512`.`a2`,7) AS `left(a2,7)` from `test`.`t1_512` semi join (`test`.`t2_512`) where ((`test`.`t2_512`.`b1` > '0') and (`test`.`t1_512`.`a1` = substr(`test`.`t2_512`.`b1`,1,512))) +select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select substring(b1,1,512) from t2_512 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select group_concat(b1) from t2_512 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_512 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t2_512 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_512`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_512`.`a2`,7) AS `left(a2,7)` from `test`.`t1_512` where (`test`.`t1_512`.`a1`,(/* select#2 */ select group_concat(`test`.`t2_512`.`b1` separator ',') from `test`.`t2_512` group by `test`.`t2_512`.`b2` having ((`test`.`t1_512`.`a1`) = (group_concat(`test`.`t2_512`.`b1` separator ','))))) +select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select group_concat(b1) from t2_512 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +Warning 1260 Row 4 was cut by GROUP_CONCAT() +Warning 1260 Row 5 was cut by GROUP_CONCAT() +Warning 1260 Row 6 was cut by GROUP_CONCAT() +Warning 1260 Row 7 was cut by GROUP_CONCAT() +Warning 1260 Row 8 was cut by GROUP_CONCAT() +Warning 1260 Row 9 was cut by GROUP_CONCAT() +set @@group_concat_max_len = 256; +explain select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select group_concat(b1) from t2_512 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_512 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t2_512 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_512`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_512`.`a2`,7) AS `left(a2,7)` from `test`.`t1_512` where (`test`.`t1_512`.`a1`,(/* select#2 */ select group_concat(`test`.`t2_512`.`b1` separator ',') from `test`.`t2_512` group by `test`.`t2_512`.`b2` having ((`test`.`t1_512`.`a1`) = (group_concat(`test`.`t2_512`.`b1` separator ','))))) +select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select group_concat(b1) from t2_512 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +Warning 1260 Row 4 was cut by GROUP_CONCAT() +Warning 1260 Row 5 was cut by GROUP_CONCAT() +Warning 1260 Row 6 was cut by GROUP_CONCAT() +Warning 1260 Row 7 was cut by GROUP_CONCAT() +Warning 1260 Row 8 was cut by GROUP_CONCAT() +Warning 1260 Row 9 was cut by GROUP_CONCAT() +drop table t1_512, t2_512, t3_512; +set @blob_len = 513; +set @suffix_len = @blob_len - @prefix_len; +create table t1_513 (a1 blob(513), a2 blob(513)); +create table t2_513 (b1 blob(513), b2 blob(513)); +create table t3_513 (c1 blob(513), c2 blob(513)); +insert into t1_513 values +(concat('1 - 00', repeat('x', @suffix_len)), concat('2 - 00', repeat('x', @suffix_len))); +insert into t1_513 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t1_513 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_513 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t2_513 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_513 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_513 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t3_513 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t3_513 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_513 values +(concat('1 - 04', repeat('x', @suffix_len)), concat('2 - 04', repeat('x', @suffix_len))); +explain select left(a1,7), left(a2,7) +from t1_513 +where a1 in (select b1 from t2_513 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1_513 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t2_513 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(t1_513) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_513`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_513`.`a2`,7) AS `left(a2,7)` from `test`.`t1_513` semi join (`test`.`t2_513`) where ((`test`.`t2_513`.`b1` = `test`.`t1_513`.`a1`) and (`test`.`t1_513`.`a1` > '0')) +select left(a1,7), left(a2,7) +from t1_513 +where a1 in (select b1 from t2_513 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_513 +where (a1,a2) in (select b1, b2 from t2_513 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1_513 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t2_513 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(t1_513) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_513`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_513`.`a2`,7) AS `left(a2,7)` from `test`.`t1_513` semi join (`test`.`t2_513`) where ((`test`.`t2_513`.`b2` = `test`.`t1_513`.`a2`) and (`test`.`t2_513`.`b1` = `test`.`t1_513`.`a1`) and (`test`.`t1_513`.`a1` > '0')) +select left(a1,7), left(a2,7) +from t1_513 +where (a1,a2) in (select b1, b2 from t2_513 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_513 +where a1 in (select substring(b1,1,513) from t2_513 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1_513 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE t2_513 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(t1_513) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_513`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_513`.`a2`,7) AS `left(a2,7)` from `test`.`t1_513` semi join (`test`.`t2_513`) where ((`test`.`t2_513`.`b1` > '0') and (`test`.`t1_513`.`a1` = substr(`test`.`t2_513`.`b1`,1,513))) +select left(a1,7), left(a2,7) +from t1_513 +where a1 in (select substring(b1,1,513) from t2_513 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_513 +where a1 in (select group_concat(b1) from t2_513 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_513 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t2_513 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_513`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_513`.`a2`,7) AS `left(a2,7)` from `test`.`t1_513` where (`test`.`t1_513`.`a1`,(/* select#2 */ select group_concat(`test`.`t2_513`.`b1` separator ',') from `test`.`t2_513` group by `test`.`t2_513`.`b2` having ((`test`.`t1_513`.`a1`) = (group_concat(`test`.`t2_513`.`b1` separator ','))))) +select left(a1,7), left(a2,7) +from t1_513 +where a1 in (select group_concat(b1) from t2_513 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +Warning 1260 Row 4 was cut by GROUP_CONCAT() +Warning 1260 Row 5 was cut by GROUP_CONCAT() +Warning 1260 Row 6 was cut by GROUP_CONCAT() +Warning 1260 Row 7 was cut by GROUP_CONCAT() +Warning 1260 Row 8 was cut by GROUP_CONCAT() +Warning 1260 Row 9 was cut by GROUP_CONCAT() +drop table t1_513, t2_513, t3_513; +set @blob_len = 1024; +set @suffix_len = @blob_len - @prefix_len; +create table t1_1024 (a1 blob(1024), a2 blob(1024)); +create table t2_1024 (b1 blob(1024), b2 blob(1024)); +create table t3_1024 (c1 blob(1024), c2 blob(1024)); +insert into t1_1024 values +(concat('1 - 00', repeat('x', @suffix_len)), concat('2 - 00', repeat('x', @suffix_len))); +insert into t1_1024 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t1_1024 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_1024 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t2_1024 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_1024 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_1024 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t3_1024 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t3_1024 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_1024 values +(concat('1 - 04', repeat('x', @suffix_len)), concat('2 - 04', repeat('x', @suffix_len))); +explain select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select b1 from t2_1024 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1_1024 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t2_1024 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(t1_1024) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1024`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1024`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1024` semi join (`test`.`t2_1024`) where ((`test`.`t2_1024`.`b1` = `test`.`t1_1024`.`a1`) and (`test`.`t1_1024`.`a1` > '0')) +select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select b1 from t2_1024 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_1024 +where (a1,a2) in (select b1, b2 from t2_1024 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1_1024 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t2_1024 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(t1_1024) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1024`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1024`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1024` semi join (`test`.`t2_1024`) where ((`test`.`t2_1024`.`b2` = `test`.`t1_1024`.`a2`) and (`test`.`t2_1024`.`b1` = `test`.`t1_1024`.`a1`) and (`test`.`t1_1024`.`a1` > '0')) +select left(a1,7), left(a2,7) +from t1_1024 +where (a1,a2) in (select b1, b2 from t2_1024 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select substring(b1,1,1024) from t2_1024 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1_1024 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE t2_1024 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(t1_1024) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1024`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1024`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1024` semi join (`test`.`t2_1024`) where ((`test`.`t2_1024`.`b1` > '0') and (`test`.`t1_1024`.`a1` = substr(`test`.`t2_1024`.`b1`,1,1024))) +select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select substring(b1,1,1024) from t2_1024 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select group_concat(b1) from t2_1024 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_1024 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t2_1024 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1024`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1024`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1024` where (`test`.`t1_1024`.`a1`,(/* select#2 */ select group_concat(`test`.`t2_1024`.`b1` separator ',') from `test`.`t2_1024` group by `test`.`t2_1024`.`b2` having ((`test`.`t1_1024`.`a1`) = (group_concat(`test`.`t2_1024`.`b1` separator ','))))) +select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select group_concat(b1) from t2_1024 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +Warning 1260 Row 4 was cut by GROUP_CONCAT() +Warning 1260 Row 5 was cut by GROUP_CONCAT() +Warning 1260 Row 6 was cut by GROUP_CONCAT() +Warning 1260 Row 7 was cut by GROUP_CONCAT() +Warning 1260 Row 8 was cut by GROUP_CONCAT() +Warning 1260 Row 9 was cut by GROUP_CONCAT() +set @@group_concat_max_len = 256; +explain select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select group_concat(b1) from t2_1024 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_1024 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t2_1024 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1024`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1024`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1024` where (`test`.`t1_1024`.`a1`,(/* select#2 */ select group_concat(`test`.`t2_1024`.`b1` separator ',') from `test`.`t2_1024` group by `test`.`t2_1024`.`b2` having ((`test`.`t1_1024`.`a1`) = (group_concat(`test`.`t2_1024`.`b1` separator ','))))) +select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select group_concat(b1) from t2_1024 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +Warning 1260 Row 4 was cut by GROUP_CONCAT() +Warning 1260 Row 5 was cut by GROUP_CONCAT() +Warning 1260 Row 6 was cut by GROUP_CONCAT() +Warning 1260 Row 7 was cut by GROUP_CONCAT() +Warning 1260 Row 8 was cut by GROUP_CONCAT() +Warning 1260 Row 9 was cut by GROUP_CONCAT() +drop table t1_1024, t2_1024, t3_1024; +set @blob_len = 1025; +set @suffix_len = @blob_len - @prefix_len; +create table t1_1025 (a1 blob(1025), a2 blob(1025)); +create table t2_1025 (b1 blob(1025), b2 blob(1025)); +create table t3_1025 (c1 blob(1025), c2 blob(1025)); +insert into t1_1025 values +(concat('1 - 00', repeat('x', @suffix_len)), concat('2 - 00', repeat('x', @suffix_len))); +insert into t1_1025 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t1_1025 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_1025 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t2_1025 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_1025 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_1025 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t3_1025 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t3_1025 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_1025 values +(concat('1 - 04', repeat('x', @suffix_len)), concat('2 - 04', repeat('x', @suffix_len))); +explain select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select b1 from t2_1025 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1_1025 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t2_1025 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(t1_1025) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1025`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1025`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1025` semi join (`test`.`t2_1025`) where ((`test`.`t2_1025`.`b1` = `test`.`t1_1025`.`a1`) and (`test`.`t1_1025`.`a1` > '0')) +select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select b1 from t2_1025 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_1025 +where (a1,a2) in (select b1, b2 from t2_1025 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1_1025 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t2_1025 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(t1_1025) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1025`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1025`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1025` semi join (`test`.`t2_1025`) where ((`test`.`t2_1025`.`b2` = `test`.`t1_1025`.`a2`) and (`test`.`t2_1025`.`b1` = `test`.`t1_1025`.`a1`) and (`test`.`t1_1025`.`a1` > '0')) +select left(a1,7), left(a2,7) +from t1_1025 +where (a1,a2) in (select b1, b2 from t2_1025 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select substring(b1,1,1025) from t2_1025 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1_1025 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE t2_1025 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(t1_1025) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1025`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1025`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1025` semi join (`test`.`t2_1025`) where ((`test`.`t2_1025`.`b1` > '0') and (`test`.`t1_1025`.`a1` = substr(`test`.`t2_1025`.`b1`,1,1025))) +select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select substring(b1,1,1025) from t2_1025 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select group_concat(b1) from t2_1025 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_1025 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t2_1025 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1025`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1025`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1025` where (`test`.`t1_1025`.`a1`,(/* select#2 */ select group_concat(`test`.`t2_1025`.`b1` separator ',') from `test`.`t2_1025` group by `test`.`t2_1025`.`b2` having ((`test`.`t1_1025`.`a1`) = (group_concat(`test`.`t2_1025`.`b1` separator ','))))) +select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select group_concat(b1) from t2_1025 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +Warning 1260 Row 4 was cut by GROUP_CONCAT() +Warning 1260 Row 5 was cut by GROUP_CONCAT() +Warning 1260 Row 6 was cut by GROUP_CONCAT() +Warning 1260 Row 7 was cut by GROUP_CONCAT() +Warning 1260 Row 8 was cut by GROUP_CONCAT() +Warning 1260 Row 9 was cut by GROUP_CONCAT() +set @@group_concat_max_len = 256; +explain select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select group_concat(b1) from t2_1025 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_1025 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t2_1025 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1025`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1025`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1025` where (`test`.`t1_1025`.`a1`,(/* select#2 */ select group_concat(`test`.`t2_1025`.`b1` separator ',') from `test`.`t2_1025` group by `test`.`t2_1025`.`b2` having ((`test`.`t1_1025`.`a1`) = (group_concat(`test`.`t2_1025`.`b1` separator ','))))) +select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select group_concat(b1) from t2_1025 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +Warning 1260 Row 4 was cut by GROUP_CONCAT() +Warning 1260 Row 5 was cut by GROUP_CONCAT() +Warning 1260 Row 6 was cut by GROUP_CONCAT() +Warning 1260 Row 7 was cut by GROUP_CONCAT() +Warning 1260 Row 8 was cut by GROUP_CONCAT() +Warning 1260 Row 9 was cut by GROUP_CONCAT() +drop table t1_1025, t2_1025, t3_1025; +# +# WL#5561: Enable semi join transformation with outer join. +# +CREATE TABLE ot1(a INT); +CREATE TABLE ot2(a INT); +CREATE TABLE ot3(a INT); +CREATE TABLE it1(a INT); +CREATE TABLE it2(a INT); +CREATE TABLE it3(a INT); +INSERT INTO ot1 VALUES(0),(1),(2),(3),(4),(5),(6),(7); +INSERT INTO ot2 VALUES(0),(2),(4),(6); +INSERT INTO ot3 VALUES(0),(3),(6); +INSERT INTO it1 VALUES(0),(1),(2),(3),(4),(5),(6),(7); +INSERT INTO it2 VALUES(0),(2),(4),(6); +INSERT INTO it3 VALUES(0),(3),(6); +# Test cases, Subquery Pattern 1 +# Example SQ1.1: +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE ot1.a IN (SELECT a FROM it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +1 SIMPLE it3 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(ot1) +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` left join `test`.`ot2` on((`test`.`ot2`.`a` = `test`.`ot1`.`a`)) semi join (`test`.`it3`) where (`test`.`it3`.`a` = `test`.`ot1`.`a`) +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE ot1.a IN (SELECT a FROM it3); +a a +0 0 +3 NULL +6 6 +# Example SQ1.2: +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE COALESCE(ot2.a,0) IN (SELECT a FROM it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +1 SIMPLE it3 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(ot2) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` left join `test`.`ot2` on((`test`.`ot2`.`a` = `test`.`ot1`.`a`)) semi join (`test`.`it3`) where (coalesce(`test`.`ot2`.`a`,0) = `test`.`it3`.`a`) +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE COALESCE(ot2.a,0) IN (SELECT a FROM it3); +a a +0 0 +1 NULL +3 NULL +5 NULL +6 6 +7 NULL +# Example SQ1.3: +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE (ot1.a,ot2.a) IN (SELECT a, a FROM it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where +1 SIMPLE it3 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(ot1) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` join `test`.`ot2` semi join (`test`.`it3`) where ((`test`.`ot1`.`a` = `test`.`ot2`.`a`) and (`test`.`it3`.`a` = `test`.`ot2`.`a`)) +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE (ot1.a,ot2.a) IN (SELECT a, a FROM it3); +a a +0 0 +6 6 +# More test cases +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 +WHERE ot1.a IN (SELECT a FROM it3); +a a +0 0 +3 NULL +6 6 +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 +WHERE ot1.a IN (SELECT a+0 FROM it3); +a a +0 0 +3 NULL +6 6 +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 +WHERE COALESCE(ot2.a,0) IN (SELECT a FROM it3); +a a +0 0 +1 NULL +3 NULL +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE COALESCE(ot2.a,0) IN (SELECT a+0 FROM it3); +a a +0 0 +1 NULL +3 NULL +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 +WHERE (ot1.a,ot2.a) IN (SELECT a, a FROM it3); +a a +0 0 +6 6 +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +LEFT JOIN ot3 ON ot1.a=ot3.a +WHERE ot1.a IN (SELECT a FROM it3); +a a a +0 0 0 +3 NULL 3 +6 6 6 +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +LEFT JOIN ot3 ON ot1.a=ot3.a +WHERE COALESCE(ot2.a,0) IN (SELECT a FROM it3); +a a a +0 0 0 +1 NULL NULL +3 NULL 3 +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +LEFT JOIN ot3 ON ot1.a=ot3.a +WHERE COALESCE(ot3.a,0) IN (SELECT a FROM it3); +a a a +0 0 0 +1 NULL NULL +2 2 NULL +3 NULL 3 +4 4 NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +LEFT JOIN ot3 ON ot2.a=ot3.a +WHERE ot1.a IN (SELECT a FROM it3); +a a a +0 0 0 +3 NULL NULL +6 6 6 +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +LEFT JOIN ot3 ON ot2.a=ot3.a +WHERE COALESCE(ot2.a,0) IN (SELECT a FROM it3); +a a a +0 0 0 +1 NULL NULL +3 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +LEFT JOIN ot3 ON ot2.a=ot3.a +WHERE COALESCE(ot3.a,0) IN (SELECT a FROM it3); +a a a +0 0 0 +1 NULL NULL +2 2 NULL +3 NULL NULL +4 4 NULL +5 NULL NULL +6 6 6 +7 NULL NULL +# Test cases, Subquery Pattern 2 +# Example SQ2.1: +explain SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where +1 SIMPLE it3 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(ot1) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` join `test`.`ot2` semi join (`test`.`it3`) where ((`test`.`ot1`.`a` = `test`.`ot2`.`a`) and (`test`.`it3`.`a` = `test`.`ot2`.`a`)) +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3); +a a +0 0 +6 6 +# Example SQ2.2: +explain SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it2) +AND ot2.a IN (SELECT a FROM it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +1 SIMPLE it3 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(ot2) +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where +1 SIMPLE it2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; FirstMatch(ot1) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` join `test`.`ot2` semi join (`test`.`it2`) semi join (`test`.`it3`) where ((`test`.`it3`.`a` = `test`.`ot2`.`a`) and (`test`.`ot1`.`a` = `test`.`ot2`.`a`) and (`test`.`it2`.`a` = `test`.`ot2`.`a`)) +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it2) +AND ot2.a IN (SELECT a FROM it3); +a a +0 0 +6 6 +# More test cases +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it3); +a a +0 0 +6 6 +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it3); +a a +0 0 +6 6 +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a+0 AND ot2.a IN (SELECT a FROM it3); +a a +0 0 +6 6 +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot2.a IN (SELECT a+0 FROM it3); +a a +0 0 +6 6 +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it2) +AND ot2.a IN (SELECT a+0 FROM it3); +a a +0 0 +6 6 +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3) +JOIN ot3 ON ot2.a=ot3.a AND ot3.a IN (SELECT a FROM it3); +a a a +0 0 0 +6 6 6 +# Test cases, Subquery Pattern 3 +# Example SQ3.1: +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +1 SIMPLE it3 NULL ALL NULL NULL NULL NULL 3 100.00 Using where; FirstMatch(ot2) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` semi join (`test`.`it3`)) on(((`test`.`ot2`.`a` = `test`.`ot1`.`a`) and (`test`.`it3`.`a` = `test`.`ot1`.`a`))) where true +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3); +a a +0 0 +1 NULL +2 NULL +3 NULL +4 NULL +5 NULL +6 6 +7 NULL +# Example SQ3.2: +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot2.a IN (SELECT a FROM it2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +1 SIMPLE it2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where; FirstMatch(ot2) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` semi join (`test`.`it2`)) on(((`test`.`ot2`.`a` = `test`.`ot1`.`a`) and (`test`.`it2`.`a` = `test`.`ot1`.`a`))) where true +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot2.a IN (SELECT a FROM it2); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +# Example SQ3.3 +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1) +AND ot2.a IN (SELECT a FROM it2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +1 SIMPLE it2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where; FirstMatch(ot2) +1 SIMPLE it1 NULL ALL NULL NULL NULL NULL 8 100.00 Using where; FirstMatch(it2) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` semi join (`test`.`it1`) semi join (`test`.`it2`)) on(((`test`.`ot2`.`a` = `test`.`ot1`.`a`) and (`test`.`it2`.`a` = `test`.`ot1`.`a`) and (`test`.`it1`.`a` = `test`.`ot1`.`a`))) where true +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1) +AND ot2.a IN (SELECT a FROM it2); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +# Example SQ3.4 +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND +(ot1.a, ot2.a) IN (SELECT it1.a, it2.a +FROM it1 JOIN it2 ON it1.a=it2.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +1 SIMPLE it2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +1 SIMPLE it1 NULL ALL NULL NULL NULL NULL 8 100.00 Using where; FirstMatch(ot2) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` semi join (`test`.`it1` join `test`.`it2`)) on(((`test`.`ot2`.`a` = `test`.`ot1`.`a`) and (`test`.`it2`.`a` = `test`.`ot1`.`a`) and (`test`.`it1`.`a` = `test`.`ot1`.`a`))) where true +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND +(ot1.a, ot2.a) IN (SELECT it1.a, it2.a +FROM it1 JOIN it2 ON it1.a=it2.a); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +# More test cases +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it3); +a a +0 0 +1 NULL +2 NULL +3 NULL +4 NULL +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it3); +a a +0 0 +1 NULL +2 NULL +3 NULL +4 NULL +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 AND ot2.a IN (SELECT a FROM it2); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot2.a IN (SELECT a+0 FROM it2); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a+0 FROM it1) +AND ot2.a IN (SELECT a+0 FROM it2); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 AND +(ot1.a, ot2.a) IN (SELECT it1.a+0, it2.a+0 +FROM it1 JOIN it2 ON it1.a=it2.a); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +EXPLAIN FORMAT=tree SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3) +LEFT JOIN ot3 ON ot2.a=ot3.a AND ot3.a IN (SELECT a FROM it3); +EXPLAIN +-> Nested loop left join (cost=117.36 rows=864) + -> Nested loop left join (cost=14.92 rows=96) + -> Table scan on ot1 (cost=1.30 rows=8) + -> Nested loop semijoin (cost=17.79 rows=12) + -> Filter: (ot2.a = ot1.a) (cost=0.55 rows=4) + -> Table scan on ot2 (cost=0.55 rows=4) + -> Filter: (it3.a = ot1.a) (cost=1.53 rows=3) + -> Table scan on it3 (cost=1.53 rows=3) + -> Nested loop semijoin (cost=49.53 rows=9) + -> Filter: (ot3.a = ot2.a) (cost=0.51 rows=3) + -> Table scan on ot3 (cost=0.51 rows=3) + -> Filter: (it3.a = ot2.a) (cost=1.51 rows=3) + -> Table scan on it3 (cost=1.51 rows=3) + +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3) +LEFT JOIN ot3 ON ot2.a=ot3.a AND ot3.a IN (SELECT a FROM it3); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it3) +LEFT JOIN ot3 ON ot2.a=ot3.a+0 AND ot3.a IN (SELECT a FROM it3); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +# Test cases, Subquery Pattern 4 +# Example SQ4.1: +explain SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +1 SIMPLE ot3 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE it1 NULL ALL NULL NULL NULL NULL 8 100.00 Using where; FirstMatch(ot3) +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a`,`test`.`ot3`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` join `test`.`ot3` semi join (`test`.`it1`)) on(((`test`.`ot3`.`a` = `test`.`ot1`.`a`) and (`test`.`it1`.`a` = `test`.`ot1`.`a`) and (`test`.`ot2`.`a` = `test`.`ot1`.`a`))) where true +SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +# Example SQ4.2: +explain SELECT * +FROM ot1 +JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot3 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where +1 SIMPLE it1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; FirstMatch(ot1) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a`,`test`.`ot3`.`a` AS `a` from `test`.`ot1` join `test`.`ot2` join `test`.`ot3` semi join (`test`.`it1`) where ((`test`.`ot2`.`a` = `test`.`ot3`.`a`) and (`test`.`ot1`.`a` = `test`.`ot3`.`a`) and (`test`.`it1`.`a` = `test`.`ot3`.`a`)) +SELECT * +FROM ot1 +JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +6 6 6 +# Example SQ4.3: +explain SELECT * +FROM ot1 +JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where +1 SIMPLE it1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; FirstMatch(ot1) +1 SIMPLE ot3 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a`,`test`.`ot3`.`a` AS `a` from `test`.`ot1` join `test`.`ot2` left join `test`.`ot3` on((`test`.`ot3`.`a` = `test`.`ot2`.`a`)) semi join (`test`.`it1`) where ((`test`.`ot1`.`a` = `test`.`ot2`.`a`) and (`test`.`it1`.`a` = `test`.`ot2`.`a`)) +SELECT * +FROM ot1 +JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +2 2 NULL +4 4 NULL +6 6 6 +# Example SQ4.4: +explain SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +1 SIMPLE it1 NULL ALL NULL NULL NULL NULL 8 100.00 Using where; FirstMatch(ot2) +1 SIMPLE ot3 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a`,`test`.`ot3`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` left join `test`.`ot3` on((`test`.`ot3`.`a` = `test`.`ot1`.`a`)) semi join (`test`.`it1`)) on(((`test`.`ot2`.`a` = `test`.`ot1`.`a`) and (`test`.`it1`.`a` = `test`.`ot1`.`a`))) where true +SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +1 NULL NULL +2 2 NULL +3 NULL NULL +4 4 NULL +5 NULL NULL +6 6 6 +7 NULL NULL +# More test cases +SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a+0) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it1); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 +JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a+0) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +6 6 6 +SELECT * +FROM ot1 +JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +6 6 6 +SELECT * +FROM ot1 +JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it1); +a a a +0 0 0 +6 6 6 +SELECT * +FROM ot1 +JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a+0) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +2 2 NULL +4 4 NULL +6 6 6 +SELECT * +FROM ot1 +JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +2 2 NULL +4 4 NULL +6 6 6 +SELECT * +FROM ot1 +JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it1); +a a a +0 0 0 +2 2 NULL +4 4 NULL +6 6 6 +SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a+0) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +1 NULL NULL +2 2 NULL +3 NULL NULL +4 4 NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +1 NULL NULL +2 2 NULL +3 NULL NULL +4 4 NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it1); +a a a +0 0 0 +1 NULL NULL +2 2 NULL +3 NULL NULL +4 4 NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1) +LEFT JOIN +ot1 AS ot4 +ON ot2.a=ot4.a; +a a a a +0 0 0 0 +1 NULL NULL NULL +2 2 NULL 2 +3 NULL NULL NULL +4 4 NULL 4 +5 NULL NULL NULL +6 6 6 6 +7 NULL NULL NULL +SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a +LEFT JOIN ot1 AS ot4 ON ot3.a=ot4.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a a +0 0 0 0 +1 NULL NULL NULL +2 2 NULL NULL +3 NULL NULL NULL +4 4 NULL NULL +5 NULL NULL NULL +6 6 6 6 +7 NULL NULL NULL +DROP TABLE ot1,ot2,ot3,it1,it2,it3; +CREATE TABLE t ( +a INTEGER DEFAULT NULL +) ENGINE=InnoDB; +INSERT INTO t VALUES (1); +CREATE TABLE t2 ( +a INTEGER DEFAULT NULL +) ENGINE=InnoDB; +INSERT INTO t2 VALUES (1),(1); +CREATE TABLE t4 ( +a INTEGER DEFAULT NULL +) ENGINE=InnoDB; +INSERT INTO t4 VALUES (1),(1); +CREATE TABLE v ( +a INTEGER DEFAULT NULL +) ENGINE=InnoDB; +INSERT INTO v VALUES (1),(1); +explain SELECT * +FROM t AS t1 +LEFT JOIN +(t2 +LEFT JOIN t AS t3 +ON t3.a IN (SELECT a FROM t AS it) +JOIN t4 +ON t4.a=100 +) +ON TRUE +WHERE t1.a IN (SELECT * FROM v AS it2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE it2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE it NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t3) +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t4`.`a` AS `a` from `test`.`t` `t1` left join (`test`.`t2` left join (`test`.`t` `t3` semi join (`test`.`t` `it`)) on(((`test`.`it`.`a` = `test`.`t3`.`a`))) join `test`.`t4`) on(((`test`.`t4`.`a` = 100))) semi join (`test`.`v` `it2`) where (`test`.`it2`.`a` = `test`.`t1`.`a`) +SELECT * +FROM t AS t1 +LEFT JOIN +(t2 +LEFT JOIN t AS t3 +ON t3.a IN (SELECT a FROM t AS it) +JOIN t4 +ON t4.a=100 +) +ON TRUE +WHERE t1.a IN (SELECT * FROM v AS it2); +a a a a +1 NULL NULL NULL +DROP TABLE t,t2,t4,v; +# End of WL#5561 +# +# Bug#48868: Left outer join in subquery causes segmentation fault in +# make_join_select. +# +CREATE TABLE t1 (i INTEGER); +INSERT INTO t1 VALUES (1); +INSERT INTO t1 VALUES (2); +CREATE TABLE t2 (i INTEGER); +INSERT INTO t2 VALUES(1); +CREATE TABLE t3 (i INTEGER); +INSERT INTO t3 VALUES (1); +INSERT INTO t3 VALUES (2); +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t2.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +1 +DROP TABLE t1, t2, t3; + +Bug#37899: Wrongly checked optimization prerequisite caused failed +assertion. + +CREATE TABLE t1 ( +`pk` int(11), +`varchar_nokey` varchar(5) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES +(1,'qk'),(2,'j'),(3,'aew'); +SELECT * +FROM t1 +WHERE varchar_nokey IN ( +SELECT +varchar_nokey +FROM +t1 +) XOR pk = 30; +pk varchar_nokey +1 qk +2 j +3 aew +drop table t1; +# +# BUG#41842: Semi-join materialization strategy crashes when the upper query has HAVING +# +CREATE TABLE t1 ( +pk int(11) NOT NULL AUTO_INCREMENT, +int_nokey int(11) NOT NULL, +time_key time NOT NULL, +datetime_key datetime NOT NULL, +datetime_nokey datetime NOT NULL, +varchar_key varchar(1) NOT NULL, +varchar_nokey varchar(1) NOT NULL, +PRIMARY KEY (pk), +KEY time_key (time_key), +KEY datetime_key (datetime_key), +KEY varchar_key (varchar_key) +) ENGINE=MyISaM; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES +(1,0, '00:16:10','2008-09-03 14:25:40','2008-09-03 14:25:40','h','h'), +(2,7, '00:00:00','2001-01-13 00:00:00','2001-01-13 00:00:00','',''), +(3,0, '00:00:00','0000-00-00 00:00:00','0000-00-00 00:00:00','x','x'), +(4,2, '16:29:24','2000-10-16 01:39:08','2000-10-16 01:39:08','w','w'), +(5,1, '09:23:32','0000-00-00 00:00:00','0000-00-00 00:00:00','p','p'), +(6,3, '00:00:00','2007-12-02 00:00:00','2007-12-02 00:00:00','o','o'), +(7,3, '00:00:00','2008-09-11 00:00:00','2008-09-11 00:00:00','',''), +(8,0, '13:59:04','0000-00-00 00:00:00','0000-00-00 00:00:00','s','s'), +(9,7, '09:01:06','0000-00-00 00:00:00','0000-00-00 00:00:00','d','d'), +(10,5,'00:00:00','0000-00-00 00:00:00','0000-00-00 00:00:00','n','n'), +(11,0,'21:06:46','0000-00-00 00:00:00','0000-00-00 00:00:00','o','o'), +(12,2,'00:00:00','0000-00-00 00:00:00','0000-00-00 00:00:00','',''), +(13,6,'14:45:34','2003-07-28 02:34:08','2003-07-28 02:34:08','w','w'), +(14,1,'15:04:12','0000-00-00 00:00:00','0000-00-00 00:00:00','o','o'), +(15,0,'00:00:00','0000-00-00 00:00:00','0000-00-00 00:00:00','x','x'), +(16,0,'15:55:23','2004-03-17 00:32:27','2004-03-17 00:32:27','p','p'), +(17,1,'16:30:00','2004-12-27 19:20:00','2004-12-27 19:20:00','d','d'), +(18,0,'00:00:00','0000-00-00 00:00:00','0000-00-00 00:00:00','h','h'), +(19,0,'14:13:26','2008-11-09 05:53:48','2008-11-09 05:53:48','o','o'), +(20,0,'00:00:00','2009-10-11 06:58:04','2009-10-11 06:58:04','k','k'); +Warnings: +Warning 1264 Out of range value for column 'datetime_key' at row 3 +Warning 1264 Out of range value for column 'datetime_nokey' at row 3 +Warning 1264 Out of range value for column 'datetime_key' at row 5 +Warning 1264 Out of range value for column 'datetime_nokey' at row 5 +Warning 1264 Out of range value for column 'datetime_key' at row 8 +Warning 1264 Out of range value for column 'datetime_nokey' at row 8 +Warning 1264 Out of range value for column 'datetime_key' at row 9 +Warning 1264 Out of range value for column 'datetime_nokey' at row 9 +Warning 1264 Out of range value for column 'datetime_key' at row 10 +Warning 1264 Out of range value for column 'datetime_nokey' at row 10 +Warning 1264 Out of range value for column 'datetime_key' at row 11 +Warning 1264 Out of range value for column 'datetime_nokey' at row 11 +Warning 1264 Out of range value for column 'datetime_key' at row 12 +Warning 1264 Out of range value for column 'datetime_nokey' at row 12 +Warning 1264 Out of range value for column 'datetime_key' at row 14 +Warning 1264 Out of range value for column 'datetime_nokey' at row 14 +Warning 1264 Out of range value for column 'datetime_key' at row 15 +Warning 1264 Out of range value for column 'datetime_nokey' at row 15 +Warning 1264 Out of range value for column 'datetime_key' at row 18 +Warning 1264 Out of range value for column 'datetime_nokey' at row 18 +CREATE TABLE t2 ( +pk int(11) NOT NULL AUTO_INCREMENT, +int_nokey int(11) NOT NULL, +time_key time NOT NULL, +datetime_key datetime NOT NULL, +datetime_nokey datetime NOT NULL, +varchar_key varchar(1) NOT NULL, +varchar_nokey varchar(1) NOT NULL, +PRIMARY KEY (pk), +KEY time_key (time_key), +KEY datetime_key (datetime_key), +KEY varchar_key (varchar_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT IGNORE INTO t2 VALUES +(10,0,'19:39:13','0000-00-00 00:00:00','0000-00-00 00:00:00','g','g'), +(11,8,'03:43:53','0000-00-00 00:00:00','0000-00-00 00:00:00','b','b'); +Warnings: +Warning 1264 Out of range value for column 'datetime_key' at row 1 +Warning 1264 Out of range value for column 'datetime_nokey' at row 1 +Warning 1264 Out of range value for column 'datetime_key' at row 2 +Warning 1264 Out of range value for column 'datetime_nokey' at row 2 +SELECT OUTR.datetime_nokey AS X FROM t1 AS OUTR +WHERE +OUTR.varchar_nokey IN (SELECT +INNR . varchar_nokey AS Y +FROM t2 AS INNR +WHERE +INNR . datetime_key >= INNR . time_key OR +INNR . pk = INNR . int_nokey +) +AND OUTR . varchar_nokey <= 'w' +HAVING X > '2012-12-12'; +X +drop table t1, t2; + +Bug#46797 "Crash in fix_semijoin_strategies_for_picked_join_order +with semijoin=on" + +CREATE TABLE t1 ( +varchar_key varchar(1) DEFAULT NULL, +KEY varchar_key (varchar_key) +); +CREATE TABLE t2 ( +varchar_key varchar(1) DEFAULT NULL, +KEY varchar_key (varchar_key) +); +INSERT INTO t2 VALUES +(NULL),(NULL),(NULL),(NULL),('a'),('a'),('a'),('b'),('b'),('b'),('b'),('c'), +('c'),('c'),('c'),('c'),('c'),('c'),('d'),('d'),('d'),('d'),('d'),('d'),('e'), +('e'),('e'),('e'),('e'),('e'),('f'),('f'),('f'),('g'),('g'),('h'),('h'),('h'), +('h'),('i'),('j'),('j'),('j'),('k'),('k'),('l'),('l'),('m'),('m'),('m'),('m'), +('n'),('n'),('n'),('o'),('o'),('o'),('p'),('p'),('p'),('q'),('q'),('q'),('r'), +('r'),('r'),('r'),('s'),('s'),('s'),('s'),('t'),('t'),('t'),('t'),('u'),('u'), +('u'),('u'),('v'),('v'),('v'),('v'),('w'),('w'),('w'),('w'),('w'),('w'),('x'), +('x'),('x'),('y'),('y'),('y'),('y'),('z'),('z'),('z'),('z'); +CREATE TABLE t3 ( +varchar_key varchar(1) DEFAULT NULL, +KEY varchar_key (varchar_key) +) ENGINE=MyISAM DEFAULT CHARSET=latin1; +INSERT INTO t3 VALUES +(NULL),('c'),('d'),('e'),('f'),('h'),('j'),('k'),('k'),('m'),('m'),('m'), +('n'),('o'),('r'),('t'),('t'),('u'),('w'),('y'); +SELECT varchar_key FROM t3 +WHERE (SELECT varchar_key FROM t3 +WHERE (varchar_key,varchar_key) +IN (SELECT t1.varchar_key, t2 .varchar_key +FROM t1 RIGHT JOIN t2 ON t1.varchar_key +) +); +varchar_key +DROP TABLE t1, t2, t3; +# +# Bug#46556 Returning incorrect, empty results for some IN subqueries +# w/semijoin=on +# +CREATE TABLE t0 ( +pk INTEGER, +vkey VARCHAR(1), +vnokey VARCHAR(1), +PRIMARY KEY (pk), +KEY vkey(vkey) +) charset utf8mb4; +INSERT INTO t0 +VALUES (1,'g','g'), (2,'v','v'), (3,'t','t'), (4,'u','u'), (5,'n','n'); +EXPLAIN SELECT vkey FROM t0 WHERE pk IN +(SELECT t1.pk FROM t0 t1 JOIN t0 t2 ON t2.vkey = t1.vnokey); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL ALL PRIMARY NULL NULL NULL 5 100.00 NULL +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t0.pk 1 100.00 Using where +1 SIMPLE t2 NULL ref vkey vkey 7 test.t1.vnokey 2 100.00 Using index; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`vkey` AS `vkey` from `test`.`t0` `t1` join `test`.`t0` semi join (`test`.`t0` `t2`) where ((`test`.`t2`.`vkey` = `test`.`t1`.`vnokey`) and (`test`.`t1`.`pk` = `test`.`t0`.`pk`)) +SELECT vkey FROM t0 WHERE pk IN +(SELECT t1.pk FROM t0 t1 JOIN t0 t2 ON t2.vkey = t1.vnokey); +vkey +g +n +t +u +v +DROP TABLE t0; +# End of bug#46556 + +Bug#48834: Procedure with view + subquery + semijoin=on +crashes on second call. + +CREATE TABLE t1 ( t1field integer, primary key (t1field)); +CREATE TABLE t2 ( t2field integer, primary key (t2field)); +CREATE VIEW v1 AS +SELECT t1field as v1field +FROM t1 A +WHERE A.t1field IN (SELECT t1field FROM t2 ); +CREATE VIEW v2 AS +SELECT t2field as v2field +FROM t2 A +WHERE A.t2field IN (SELECT t2field FROM t2 ); +CREATE PROCEDURE p1 () +BEGIN +SELECT v1field +FROM v1 +WHERE v1field IN ( SELECT v2field as vf_inner FROM v2 ); +END| +INSERT INTO t1 VALUES (1),(2),(3); +INSERT INTO t2 VALUES (2),(3),(4); +CALL p1; +v1field +2 +3 +CALL p1; +v1field +2 +3 +DROP TABLE t1,t2; +DROP VIEW v1,v2; +DROP PROCEDURE p1; +# End of BUG#48834 +# +# Bug#46692 "Crash occurring on queries with nested FROM subqueries +# using materialization." +# +CREATE TABLE t1 ( +pk INTEGER PRIMARY KEY, +int_key INTEGER, +KEY int_key(int_key) +); +INSERT INTO t1 VALUES (10,186),(11,NULL),(12,2),(13,3),(14,0),(15,133),(16,1); +CREATE TABLE t2 ( +pk INTEGER PRIMARY KEY, +int_key INTEGER, +KEY int_key(int_key) +); +INSERT INTO t2 VALUES (1,7),(2,2); +SELECT * FROM t1 WHERE (140, 4) IN +(SELECT t2.int_key, t2 .pk FROM t2 STRAIGHT_JOIN t1 ON t2.int_key); +pk int_key +DROP TABLE t1, t2; +# +# Bug#42353 "SELECT ... WHERE oe IN (SELECT w/ LEFT JOIN) query +# causes crash." +# +CREATE TABLE t1 ( +pk INTEGER PRIMARY KEY, +int_nokey INTEGER, +int_key INTEGER, +date_key DATE, +datetime_nokey DATETIME, +varchar_nokey VARCHAR(1) +); +CREATE TABLE t2 ( +date_nokey DATE +); +CREATE TABLE t3 ( +pk INTEGER PRIMARY KEY, +int_nokey INTEGER, +date_key date, +varchar_key VARCHAR(1), +varchar_nokey VARCHAR(1), +KEY date_key (date_key) +); +SELECT date_key FROM t1 +WHERE (int_key, int_nokey) +IN (SELECT t3.int_nokey, t3.pk +FROM t2 LEFT JOIN t3 ON (t2.date_nokey < t3.date_key) +WHERE t3.varchar_key <= t3.varchar_nokey OR t3.int_nokey <= t3.pk +) +AND (varchar_nokey <> 'f' OR NOT int_key < 7); +date_key +# +# Bug#45933 "Crash in optimize_semijoin_nests on JOIN in subquery +# + AND in outer query". +# +INSERT INTO t1 VALUES (10,7,5,'2009-06-16','2002-04-10 14:25:30','w'), +(11,7,0,'0000-00-00','0000-00-00 00:00:00','s'), +(12,4,0,'2003-07-14','2006-09-14 04:01:02','y'), +(13,0,4,'2002-07-25','0000-00-00 00:00:00','c'), +(14,1,8,'2007-07-03','0000-00-00 00:00:00','q'), +(15,6,5,'2001-11-12','0000-00-00 00:00:00',''), +(16,2,9,'0000-00-00','0000-00-00 00:00:00','j'), +(29,9,1,'0000-00-00','2003-08-11 00:00:00','m'); +Warnings: +Warning 1264 Out of range value for column 'date_key' at row 2 +Warning 1264 Out of range value for column 'datetime_nokey' at row 2 +Warning 1264 Out of range value for column 'datetime_nokey' at row 4 +Warning 1264 Out of range value for column 'datetime_nokey' at row 5 +Warning 1264 Out of range value for column 'datetime_nokey' at row 6 +Warning 1264 Out of range value for column 'date_key' at row 7 +Warning 1264 Out of range value for column 'datetime_nokey' at row 7 +Warning 1264 Out of range value for column 'date_key' at row 8 +INSERT IGNORE INTO t3 VALUES (1,9,'0000-00-00','b','b'), +(2,2,'2002-09-17','h','h'); +Warnings: +Warning 1264 Out of range value for column 'date_key' at row 1 +SELECT t1.varchar_nokey FROM t1 JOIN t3 ON t1.datetime_nokey +WHERE t1.varchar_nokey +IN (SELECT varchar_nokey FROM t1 +WHERE (pk) +IN (SELECT t3.int_nokey +FROM t3 LEFT JOIN t1 ON t1.varchar_nokey +WHERE t3.date_key BETWEEN '2008-06-07' AND '2006-06-26' + ) +); +varchar_nokey +DROP TABLE t1, t2, t3; +# +# Bug#45219 "Crash on SELECT DISTINCT query containing a +# LEFT JOIN in subquery" +# +CREATE TABLE t1 ( +pk INTEGER NOT NULL, +int_nokey INTEGER NOT NULL, +datetime_key DATETIME NOT NULL, +varchar_key VARCHAR(1) NOT NULL, +PRIMARY KEY (pk), +KEY datetime_key (datetime_key), +KEY varchar_key (varchar_key) +); +INSERT IGNORE INTO t1 VALUES +(1,9,'0000-00-00 00:00:00','p'),(2,0,'2002-02-09 07:38:13','v'), +(3,8,'2001-05-03 12:08:14','t'),(4,3,'0000-00-00 00:00:00','u'), +(5,7,'2009-07-28 03:43:30','n'),(6,0,'2009-08-04 00:00:00','l'), +(7,1,'0000-00-00 00:00:00','h'),(8,9,'0000-00-00 00:00:00','u'), +(9,0,'2005-08-02 17:16:54','n'),(10,9,'2002-12-21 00:00:00','j'), +(11,0,'2005-08-15 12:37:35','k'),(12,5,'0000-00-00 00:00:00','e'), +(13,0,'2006-03-10 00:00:00','i'),(14,8,'2005-05-16 11:02:36','u'), +(15,8,'2008-11-02 00:00:00','n'),(16,5,'2006-03-15 00:00:00','b'), +(17,1,'0000-00-00 00:00:00','x'),(18,7,'0000-00-00 00:00:00',''), +(19,0,'2008-12-17 20:15:40','q'),(20,9,'0000-00-00 00:00:00','u'); +Warnings: +Warning 1264 Out of range value for column 'datetime_key' at row 1 +Warning 1264 Out of range value for column 'datetime_key' at row 4 +Warning 1264 Out of range value for column 'datetime_key' at row 7 +Warning 1264 Out of range value for column 'datetime_key' at row 8 +Warning 1264 Out of range value for column 'datetime_key' at row 12 +Warning 1264 Out of range value for column 'datetime_key' at row 17 +Warning 1264 Out of range value for column 'datetime_key' at row 18 +Warning 1264 Out of range value for column 'datetime_key' at row 20 +CREATE TABLE t2 LIKE t1; +INSERT INTO t2 VALUES +(10,0,'2006-07-07 07:26:28','q'),(11,5,'2002-09-23 00:00:00','m'), +(12,7,'0000-00-00 00:00:00','j'),(13,1,'2006-06-07 00:00:00','z'), +(14,8,'2000-09-16 12:15:34','a'),(15,2,'2007-08-05 15:47:52',''), +(16,1,'0000-00-00 00:00:00','e'),(17,8,'2005-12-02 19:34:26','t'), +(18,5,'0000-00-00 00:00:00','q'),(19,4,'0000-00-00 00:00:00','b'), +(20,5,'2007-12-28 00:00:00','w'),(21,3,'2004-08-02 11:48:43','m'), +(22,0,'0000-00-00 00:00:00','x'),(23,8,'2004-04-19 12:18:43',''), +(24,0,'2009-04-27 00:00:00','w'),(25,4,'2006-10-20 14:52:15','x'), +(26,0,'0000-00-00 00:00:00','e'),(27,0,'2002-03-22 11:48:37','e'), +(28,2,'0000-00-00 00:00:00','p'),(29,0,'2001-01-04 03:55:07','x'); +Warnings: +Warning 1264 Out of range value for column 'datetime_key' at row 3 +Warning 1264 Out of range value for column 'datetime_key' at row 7 +Warning 1264 Out of range value for column 'datetime_key' at row 9 +Warning 1264 Out of range value for column 'datetime_key' at row 10 +Warning 1264 Out of range value for column 'datetime_key' at row 13 +Warning 1264 Out of range value for column 'datetime_key' at row 17 +Warning 1264 Out of range value for column 'datetime_key' at row 19 +CREATE TABLE t3 LIKE t1; +INSERT INTO t3 VALUES +(10,8,'2007-08-19 08:08:38','i'),(11,0,'2000-05-21 03:51:51',''); +SELECT DISTINCT datetime_key FROM t1 +WHERE (int_nokey, pk) +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#46550 Azalea returning duplicate results for some IN subqueries +# w/ semijoin=on +# +DROP TABLE IF EXISTS t0, t1, t2; +CREATE TABLE t0 ( +int_key int(11) DEFAULT NULL, +varchar_key varchar(1) DEFAULT NULL, +varchar_nokey varchar(1) DEFAULT NULL, +KEY int_key (int_key), +KEY varchar_key (varchar_key,int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t0 VALUES +(1,'m','m'), +(40,'h','h'), +(1,'r','r'), +(1,'h','h'), +(9,'x','x'), +(NULL,'q','q'), +(NULL,'k','k'), +(7,'l','l'), +(182,'k','k'), +(202,'a','a'), +(7,'x','x'), +(6,'j','j'), +(119,'z','z'), +(4,'d','d'), +(5,'h','h'), +(1,'u','u'), +(3,'q','q'), +(7,'a','a'), +(3,'e','e'), +(6,'l','l'); +CREATE TABLE t1 ( +int_key int(11) DEFAULT NULL, +varchar_key varchar(1) DEFAULT NULL, +varchar_nokey varchar(1) DEFAULT NULL, +KEY int_key (int_key), +KEY varchar_key (varchar_key,int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (7,NULL,NULL),(4,'x','x'); +CREATE TABLE t2 ( +int_key int(11) DEFAULT NULL, +varchar_key varchar(1) DEFAULT NULL, +varchar_nokey varchar(1) DEFAULT NULL, +KEY int_key (int_key), +KEY varchar_key (varchar_key,int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (123,NULL,NULL); +SELECT int_key +FROM t0 +WHERE varchar_nokey IN ( +SELECT t1 .varchar_key from t1 +); +int_key +7 +9 +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 +7 +9 +EXPLAIN +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 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 20 100.00 Using where +1 SIMPLE t1_1 NULL ref varchar_key varchar_key 7 test.t0.varchar_nokey 2 50.00 Using where; Using index +1 SIMPLE t1_2 NULL index NULL int_key 5 NULL 2 100.00 Using index; FirstMatch(t0) +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`int_key` AS `int_key` from `test`.`t0` semi join (`test`.`t1` `t1_1` join `test`.`t1` `t1_2`) where ((`test`.`t1_1`.`varchar_key` = `test`.`t0`.`varchar_nokey`) and (0 <> `test`.`t1_1`.`int_key`)) +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 +7 +9 +EXPLAIN +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 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 20 100.00 Using where +1 SIMPLE t1_1 NULL ref varchar_key varchar_key 7 test.t0.varchar_nokey 2 50.00 Using where; Using index +1 SIMPLE t1_2 NULL index NULL int_key 5 NULL 2 100.00 Using index; FirstMatch(t0) +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`int_key` AS `int_key` from `test`.`t0` semi join (`test`.`t1` `t1_1` join `test`.`t1` `t1_2`) where ((`test`.`t1_1`.`varchar_key` = `test`.`t0`.`varchar_nokey`) and (0 <> `test`.`t1_1`.`int_key`)) +DROP TABLE t0, t1, t2; +# End of bug#46550 + +Bug #48073 Subquery on char columns from view crashes Mysql + +DROP TABLE IF EXISTS t1, t2; +DROP VIEW IF EXISTS v1; +CREATE TABLE t1 ( +city VARCHAR(50) NOT NULL, +country_id SMALLINT UNSIGNED NOT NULL +); +INSERT INTO t1 VALUES +('Batna',2), +('Bchar',2), +('Skikda',2), +('Tafuna',3), +('Algeria',2) ; +CREATE TABLE t2 ( +country_id SMALLINT UNSIGNED NOT NULL, +country VARCHAR(50) NOT NULL +); +INSERT INTO t2 VALUES +(2,'Algeria'), +(3,'American Samoa') ; +CREATE VIEW v1 AS +SELECT country_id, country +FROM t2 +WHERE LEFT(country,1) = "A" +; +SELECT city, country_id +FROM t1 +WHERE city IN ( +SELECT country +FROM t2 +WHERE LEFT(country, 1) = "A" +); +city country_id +Algeria 2 +SELECT city, country_id +FROM t1 +WHERE city IN ( +SELECT country +FROM v1 +); +city country_id +Algeria 2 +drop table t1, t2; +drop view v1; +# End of bug#48073 + +Bug#49097 subquery with view generates wrong result with +non-prepared statement + +DROP TABLE IF EXISTS t1, t2; +DROP VIEW IF EXISTS v1; +CREATE TABLE t1 ( +city VARCHAR(50) NOT NULL, +country_id SMALLINT UNSIGNED NOT NULL +); +INSERT INTO t1 VALUES +('Batna',2), +('Bchar',2), +('Skikda',2), +('Tafuna',3), +('Algeria',2) ; +CREATE TABLE t2 ( +country_id SMALLINT UNSIGNED NOT NULL, +country VARCHAR(50) NOT NULL +); +INSERT INTO t2 VALUES +(2,'Algeria'), +(3,'XAmerican Samoa') ; +CREATE VIEW v1 AS +SELECT country_id, country +FROM t2 +WHERE LEFT(country,1) = "A" +; +SELECT city, country_id +FROM t1 +WHERE country_id IN ( +SELECT country_id +FROM t2 +WHERE LEFT(country,1) = "A" +); +city country_id +Algeria 2 +Batna 2 +Bchar 2 +Skikda 2 +SELECT city, country_id +FROM t1 +WHERE country_id IN ( +SELECT country_id +FROM v1 +); +city country_id +Algeria 2 +Batna 2 +Bchar 2 +Skikda 2 +PREPARE stmt FROM +" +SELECT city, country_id +FROM t1 +WHERE country_id IN ( + SELECT country_id + FROM v1 +); +"; +execute stmt; +city country_id +Algeria 2 +Batna 2 +Bchar 2 +Skikda 2 +deallocate prepare stmt; +drop table t1, t2; +drop view v1; +# End of Bug#49097 +# +# Bug#49198 Wrong result for second call of procedure +# with view in subselect. +# +CREATE TABLE t1 (t1field integer, primary key (t1field)); +CREATE TABLE t2 (t2field integer, primary key (t2field)); +CREATE TABLE t3 (t3field integer, primary key (t3field)); +CREATE VIEW v2 AS SELECT * FROM t2; +CREATE VIEW v3 AS SELECT * FROM t3; +INSERT INTO t1 VALUES(1),(2); +INSERT INTO t2 VALUES(1),(2); +INSERT INTO t3 VALUES(1),(2); +PREPARE stmt FROM +" +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT * FROM v2); +"; +EXECUTE stmt; +t1field +1 +2 + +EXECUTE stmt; +t1field +1 +2 +PREPARE stmt FROM +" +EXPLAIN +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT * FROM v2) + AND t1field IN (SELECT * FROM v3) +"; +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index PRIMARY PRIMARY 4 NULL 2 100.00 Using index +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +1 SIMPLE t3 NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`t1field` AS `t1field` from `test`.`t2` join `test`.`t3` join `test`.`t1` where ((`test`.`t2`.`t2field` = `test`.`t1`.`t1field`) and (`test`.`t3`.`t3field` = `test`.`t1`.`t1field`)) + +This line is only in place to help --skip_if_hypergraph diffing some more. + +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index PRIMARY PRIMARY 4 NULL 2 100.00 Using index +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +1 SIMPLE t3 NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`t1field` AS `t1field` from `test`.`t2` join `test`.`t3` join `test`.`t1` where ((`test`.`t2`.`t2field` = `test`.`t1`.`t1field`) and (`test`.`t3`.`t3field` = `test`.`t1`.`t1field`)) +DROP TABLE t1, t2, t3; +DROP VIEW v2, v3; +# End of Bug#49198 +# +# Bug#48623 Multiple subqueries are optimized incorrectly +# +CREATE TABLE ot(val VARCHAR(10)) charset utf8mb4; +CREATE TABLE it1(val VARCHAR(10)) charset utf8mb4; +CREATE TABLE it2(val VARCHAR(10)) charset utf8mb4; +INSERT INTO ot VALUES('aaa'), ('bbb'), ('eee'), ('mmm'), ('ppp'); +INSERT INTO it1 VALUES('aaa'), ('aaa'), ('bbb'), ('eee'), ('mmm'), ('ppp'); +INSERT INTO it2 VALUES('aaa'), ('bbb'), ('eee'), ('mmm'), ('ppp'); +EXPLAIN +SELECT * +FROM ot +WHERE ot.val IN (SELECT it1.val FROM it1 +WHERE it1.val LIKE 'a%' OR it1.val LIKE 'e%') +AND ot.val IN (SELECT it2.val FROM it2 +WHERE it2.val LIKE 'a%' OR it2.val LIKE 'e%'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 5 100.00 NULL +1 SIMPLE it2 NULL ALL NULL NULL NULL NULL 5 20.00 Using where; FirstMatch(ot) +1 SIMPLE it1 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; FirstMatch(it2) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot`.`val` AS `val` from `test`.`ot` semi join (`test`.`it1`) semi join (`test`.`it2`) where ((`test`.`it2`.`val` = `test`.`ot`.`val`) and (`test`.`it1`.`val` = `test`.`ot`.`val`) and ((`test`.`it1`.`val` like 'a%') or (`test`.`it1`.`val` like 'e%')) and ((`test`.`it2`.`val` like 'a%') or (`test`.`it2`.`val` like 'e%'))) +SELECT * +FROM ot +WHERE ot.val IN (SELECT it1.val FROM it1 +WHERE it1.val LIKE 'a%' OR it1.val LIKE 'e%') +AND ot.val IN (SELECT it2.val FROM it2 +WHERE it2.val LIKE 'a%' OR it2.val LIKE 'e%'); +val +aaa +eee +DROP TABLE ot; +DROP TABLE it1; +DROP TABLE it2; +# End of Bug#48623 +# +# Bug #51487 Assertion failure when semi-join flattening occurs +# for a subquery in HAVING +# +CREATE TABLE t1 (a INT, b INT); +INSERT INTO t1 VALUES (1,10),(2,11),(1,13); +CREATE TABLE t2 AS SELECT * FROM t1; +CREATE TABLE t3 AS SELECT * FROM t1; +SELECT COUNT(*) FROM t1 +GROUP BY t1.a +HAVING t1.a IN (SELECT t3.a FROM t3 +WHERE t3.b IN (SELECT b FROM t2 WHERE t2.a=t1.a)); +COUNT(*) +2 +1 +DROP TABLE t1, t2, t3; +# End of Bug#51487 +# +# BUG#38075: Wrong result: rows matching a subquery with outer join not returned +# +DROP TABLE IF EXISTS ot1, it1, it2; +CREATE TABLE it2 ( +int_key int(11) NOT NULL, +datetime_key datetime NOT NULL, +KEY int_key (int_key), +KEY datetime_key (datetime_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO it2 VALUES +(5,'2002-04-10 14:25:30'), (0,'0000-00-00 00:00:00'), +(0,'2006-09-14 04:01:02'), (4,'0000-00-00 00:00:00'), +(8,'0000-00-00 00:00:00'), (5,'0000-00-00 00:00:00'), +(9,'0000-00-00 00:00:00'), (8,'2007-04-01 11:04:17'), +(1,'0000-00-00 00:00:00'), (7,'2009-01-12 00:00:00'), +(0,'2009-06-05 00:00:00'), (3,'2006-02-14 18:06:35'), +(5,'2006-02-21 07:08:16'), (0,'0000-00-00 00:00:00'), +(7,'0000-00-00 00:00:00'), (0,'0000-00-00 00:00:00'), +(0,'2007-02-13 00:00:00'), (1,'0000-00-00 00:00:00'), +(0,'0000-00-00 00:00:00'), (1,'2003-08-11 00:00:00'); +Warnings: +Warning 1264 Out of range value for column 'datetime_key' at row 2 +Warning 1264 Out of range value for column 'datetime_key' at row 4 +Warning 1264 Out of range value for column 'datetime_key' at row 5 +Warning 1264 Out of range value for column 'datetime_key' at row 6 +Warning 1264 Out of range value for column 'datetime_key' at row 7 +Warning 1264 Out of range value for column 'datetime_key' at row 9 +Warning 1264 Out of range value for column 'datetime_key' at row 14 +Warning 1264 Out of range value for column 'datetime_key' at row 15 +Warning 1264 Out of range value for column 'datetime_key' at row 16 +Warning 1264 Out of range value for column 'datetime_key' at row 18 +Warning 1264 Out of range value for column 'datetime_key' at row 19 +CREATE TABLE ot1 ( +int_nokey int(11) NOT NULL, +int_key int(11) NOT NULL, +KEY int_key (int_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO ot1 VALUES +(5,0), (3,0), (0,2), (3,0), (1,3), (0,0), (1,7), (7,0), (1,7), (0,7), +(0,9), (8,2), (4,4), (9,3), (0,9), (2,5), (0,5), (8,0), (5,8), (1,5); +CREATE TABLE it1 ( +int_nokey int(11) NOT NULL, +int_key int(11) NOT NULL, +KEY int_key (int_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO it1 VALUES +(9,5), (0,4); +SELECT int_key FROM ot1 +WHERE int_nokey IN (SELECT it2.int_key +FROM it1 LEFT JOIN it2 ON it2.datetime_key); +int_key +0 +0 +0 +0 +0 +0 +2 +2 +3 +5 +5 +7 +7 +7 +8 +9 +9 +EXPLAIN +SELECT int_key FROM ot1 +WHERE int_nokey IN (SELECT it2.int_key +FROM it1 LEFT JOIN it2 ON it2.datetime_key); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 20 100.00 NULL +1 SIMPLE it1 NULL index NULL int_key 4 NULL 2 100.00 Using index +1 SIMPLE it2 NULL ref int_key int_key 4 test.ot1.int_nokey 2 90.00 Using where; FirstMatch(ot1) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`int_key` AS `int_key` from `test`.`ot1` semi join (`test`.`it1` join `test`.`it2`) where ((`test`.`it2`.`int_key` = `test`.`ot1`.`int_nokey`) and (TIMESTAMP'0000-00-00 00:00:00' <> `test`.`it2`.`datetime_key`)) +DROP TABLE ot1, it1, it2; +# End of BUG#38075 +# +# BUG#50089: Second call of procedure with view in subselect crashes server +# +CREATE TABLE t1(t1field INTEGER, PRIMARY KEY(t1field)); +CREATE VIEW v1 AS +SELECT t1field AS v1field +FROM t1 a +WHERE a.t1field IN (SELECT t1field FROM t1); +INSERT INTO t1 VALUES(1),(2); +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT v1field FROM v1); +t1field +1 +2 +EXPLAIN +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT v1field FROM v1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index PRIMARY PRIMARY 4 NULL 2 100.00 Using index +1 SIMPLE a NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `t1`.`t1field` AS `t1field` from `test`.`t1` `a` join `test`.`t1` join `test`.`t1` where ((`test`.`a`.`t1field` = `t1`.`t1field`) and (`test`.`t1`.`t1field` = `t1`.`t1field`)) +SELECT t1.t1field +FROM t1 LEFT JOIN t1 AS t2 ON t1.t1field IN (SELECT v1field FROM v1); +t1field +1 +1 +2 +2 +EXPLAIN +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT v1field FROM v1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index PRIMARY PRIMARY 4 NULL 2 100.00 Using index +1 SIMPLE a NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `t1`.`t1field` AS `t1field` from `test`.`t1` `a` join `test`.`t1` join `test`.`t1` where ((`test`.`a`.`t1field` = `t1`.`t1field`) and (`test`.`t1`.`t1field` = `t1`.`t1field`)) +CREATE PROCEDURE p1() +BEGIN +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT v1field FROM v1); +END| +CALL p1; +t1field +1 +2 +CALL p1; +t1field +1 +2 +PREPARE stmt FROM +" +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT v1field FROM v1); +"; +EXECUTE stmt; +t1field +1 +2 + +EXECUTE stmt; +t1field +1 +2 +DROP PROCEDURE p1; +DROP VIEW v1; +DROP TABLE t1; +# End of BUG#50089 +# +# Bug#45191: Incorrectly initialized semi-join led to a wrong result. +# +CREATE TABLE staff (EMPNUM CHAR(3) NOT NULL, +EMPNAME CHAR(20), GRADE DECIMAL(4), CITY CHAR(15)) charset latin1; +CREATE TABLE proj (PNUM CHAR(3) NOT NULL, +PNAME CHAR(20), PTYPE CHAR(6), +BUDGET DECIMAL(9), +CITY CHAR(15)) charset latin1; +CREATE TABLE works (EMPNUM CHAR(3) NOT NULL, +PNUM CHAR(3) NOT NULL, HOURS DECIMAL(5)) charset latin1; +INSERT INTO staff VALUES ('E1','Alice',12,'Deale'); +INSERT INTO staff VALUES ('E2','Betty',10,'Vienna'); +INSERT INTO staff VALUES ('E3','Carmen',13,'Vienna'); +INSERT INTO staff VALUES ('E4','Don',12,'Deale'); +INSERT INTO staff VALUES ('E5','Ed',13,'Akron'); +INSERT INTO proj VALUES ('P1','MXSS','Design',10000,'Deale'); +INSERT INTO proj VALUES ('P2','CALM','Code',30000,'Vienna'); +INSERT INTO proj VALUES ('P3','SDP','Test',30000,'Tampa'); +INSERT INTO proj VALUES ('P4','SDP','Design',20000,'Deale'); +INSERT INTO proj VALUES ('P5','IRM','Test',10000,'Vienna'); +INSERT INTO proj VALUES ('P6','PAYR','Design',50000,'Deale'); +INSERT INTO works VALUES ('E1','P1',40); +INSERT INTO works VALUES ('E1','P2',20); +INSERT INTO works VALUES ('E1','P3',80); +INSERT INTO works VALUES ('E1','P4',20); +INSERT INTO works VALUES ('E1','P5',12); +INSERT INTO works VALUES ('E1','P6',12); +INSERT INTO works VALUES ('E2','P1',40); +INSERT INTO works VALUES ('E2','P2',80); +INSERT INTO works VALUES ('E3','P2',20); +INSERT INTO works VALUES ('E4','P2',20); +INSERT INTO works VALUES ('E4','P4',40); +INSERT INTO works VALUES ('E4','P5',80); +explain SELECT EMPNUM, EMPNAME +FROM staff +WHERE EMPNUM IN +(SELECT EMPNUM FROM works +WHERE PNUM IN +(SELECT PNUM FROM proj)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE staff NULL ALL NULL NULL NULL NULL 5 100.00 NULL +1 SIMPLE works NULL ALL NULL NULL NULL NULL 12 10.00 Using where +1 SIMPLE proj NULL ALL NULL NULL NULL NULL 6 16.67 Using where; FirstMatch(staff) +Warnings: +Note 1003 /* select#1 */ select `test`.`staff`.`EMPNUM` AS `EMPNUM`,`test`.`staff`.`EMPNAME` AS `EMPNAME` from `test`.`staff` semi join (`test`.`works` join `test`.`proj`) where ((`test`.`works`.`EMPNUM` = `test`.`staff`.`EMPNUM`) and (`test`.`proj`.`PNUM` = `test`.`works`.`PNUM`)) +SELECT EMPNUM, EMPNAME +FROM staff +WHERE EMPNUM IN +(SELECT EMPNUM FROM works +WHERE PNUM IN +(SELECT PNUM FROM proj)); +EMPNUM EMPNAME +E1 Alice +E2 Betty +E3 Carmen +E4 Don +drop table staff,works,proj; +# End of bug#45191 +# +# BUG#36896: Server crash on SELECT FROM DUAL +# +create table t1 (a int); +select 1 as res from dual where (1) in (select * from t1); +res +drop table t1; + +BUG#40118 Crash when running Batched Key Access and requiring one match for each key + +create table t0(a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (a int, key(a)); +insert into t1 select * from t0; +alter table t1 add b int not null, add filler char(200); +insert into t1 select * from t1; +insert into t1 select * from t1; +select * from t0 where t0.a in (select t1.a from t1 where t1.b=0); +a +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +drop table t0, t1; +# +# BUG#32665 Query with dependent subquery is too slow +# +create table t1 ( +idIndividual int primary key +); +insert into t1 values (1),(2); +create table t2 ( +idContact int primary key, +contactType int, +idObj int +); +insert into t2 values (1,1,1),(2,2,2),(3,3,3); +create table t3 ( +idAddress int primary key, +idContact int, +postalStripped varchar(100) +); +insert into t3 values (1,1, 'foo'), (2,2,'bar'); +The following must be converted to a semi-join: +explain SELECT a.idIndividual FROM t1 a +WHERE a.idIndividual IN +( SELECT c.idObj FROM t3 cona +INNER JOIN t2 c ON c.idContact=cona.idContact +WHERE cona.postalStripped='T2H3B2' + ); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE a NULL index PRIMARY PRIMARY 4 NULL 2 100.00 Using index +1 SIMPLE cona NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE c NULL eq_ref PRIMARY PRIMARY 4 test.cona.idContact 1 33.33 Using where; FirstMatch(a) +Warnings: +Note 1003 /* select#1 */ select `test`.`a`.`idIndividual` AS `idIndividual` from `test`.`t1` `a` semi join (`test`.`t3` `cona` join `test`.`t2` `c`) where ((`test`.`c`.`idContact` = `test`.`cona`.`idContact`) and (`test`.`c`.`idObj` = `test`.`a`.`idIndividual`) and (`test`.`cona`.`postalStripped` = 'T2H3B2')) +drop table t1,t2,t3; +CREATE TABLE t1 (one int, two int, flag char(1)); +CREATE TABLE t2 (one int, two int, flag char(1)); +INSERT INTO t1 VALUES(1,2,'Y'),(2,3,'Y'),(3,4,'Y'),(5,6,'N'),(7,8,'N'); +INSERT INTO t2 VALUES(1,2,'Y'),(2,3,'Y'),(3,4,'Y'),(5,6,'N'),(7,8,'N'); +SELECT * FROM t1 +WHERE ROW(one,two) IN (SELECT DISTINCT one,two FROM t2 WHERE flag = 'N'); +one two flag +5 6 N +7 8 N +SELECT * FROM t1 +WHERE ROW(one,two) IN (SELECT DISTINCT one,two FROM t1 WHERE flag = 'N'); +one two flag +5 6 N +7 8 N +insert into t2 values (null,null,'N'); +insert into t2 values (null,3,'0'); +insert into t2 values (null,5,'0'); +insert into t2 values (10,null,'0'); +insert into t1 values (10,3,'0'); +insert into t1 values (10,5,'0'); +insert into t1 values (10,10,'0'); +SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = 'N') as 'test' from t1; +one two test +1 2 NULL +2 3 NULL +3 4 NULL +5 6 1 +7 8 1 +10 3 NULL +10 5 NULL +10 10 NULL +SELECT one,two from t1 where ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = 'N'); +one two +5 6 +7 8 +SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = 'N' group by one,two) as 'test' from t1; +one two test +1 2 NULL +2 3 NULL +3 4 NULL +5 6 1 +7 8 1 +10 3 NULL +10 5 NULL +10 10 NULL +SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = '0') as 'test' from t1; +one two test +1 2 0 +2 3 NULL +3 4 0 +5 6 0 +7 8 0 +10 3 NULL +10 5 NULL +10 10 NULL +SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = '0' group by one,two) as 'test' from t1; +one two test +1 2 0 +2 3 NULL +3 4 0 +5 6 0 +7 8 0 +10 3 NULL +10 5 NULL +10 10 NULL +explain SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = '0') as 'test' from t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 9 11.11 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`one` AS `one`,`test`.`t1`.`two` AS `two`,((`test`.`t1`.`one`,`test`.`t1`.`two`),(/* select#2 */ select `test`.`t2`.`one`,`test`.`t2`.`two` from `test`.`t2` where ((`test`.`t2`.`flag` = '0') and (outer_field_is_not_null, (((`test`.`t1`.`one`) = `test`.`t2`.`one`) or (`test`.`t2`.`one` is null)), true) and (outer_field_is_not_null, (((`test`.`t1`.`two`) = `test`.`t2`.`two`) or (`test`.`t2`.`two` is null)), true)) having ((outer_field_is_not_null, (`test`.`t2`.`one`), true) and (outer_field_is_not_null, (`test`.`t2`.`two`), true)))) AS `test` from `test`.`t1` +explain SELECT one,two from t1 where ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = 'N'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 9 11.11 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`one` AS `one`,`test`.`t1`.`two` AS `two` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`two` = `test`.`t1`.`two`) and (`test`.`t2`.`one` = `test`.`t1`.`one`) and (`test`.`t2`.`flag` = 'N')) +explain SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = '0' group by one,two) as 'test' from t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 9 11.11 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`one` AS `one`,`test`.`t1`.`two` AS `two`,((`test`.`t1`.`one`,`test`.`t1`.`two`),(/* select#2 */ select `test`.`t2`.`one`,`test`.`t2`.`two` from `test`.`t2` where ((`test`.`t2`.`flag` = '0') and (outer_field_is_not_null, (((`test`.`t1`.`one`) = `test`.`t2`.`one`) or (`test`.`t2`.`one` is null)), true) and (outer_field_is_not_null, (((`test`.`t1`.`two`) = `test`.`t2`.`two`) or (`test`.`t2`.`two` is null)), true)) having ((outer_field_is_not_null, (`test`.`t2`.`one`), true) and (outer_field_is_not_null, (`test`.`t2`.`two`), true)))) AS `test` from `test`.`t1` +DROP TABLE t1,t2; +CREATE TABLE t1 (a char(5), b char(5)); +INSERT INTO t1 VALUES (NULL,'aaa'), ('aaa','aaa'); +SELECT * FROM t1 WHERE (a,b) IN (('aaa','aaa'), ('aaa','bbb')); +a b +aaa aaa +DROP TABLE t1; +CREATE TABLE t1 (a CHAR(1), b VARCHAR(10)) charset utf8mb4; +INSERT INTO t1 VALUES ('a', 'aa'); +INSERT INTO t1 VALUES ('a', 'aaa'); +SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1); +a b +CREATE INDEX I1 ON t1 (a); +CREATE INDEX I2 ON t1 (b); +EXPLAIN SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL I2 NULL NULL NULL 2 100.00 Using where +1 SIMPLE t1 NULL ref I1 I1 5 test.t1.b 2 100.00 Using where; Using index; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t1`) where (`test`.`t1`.`b` = `test`.`t1`.`a`) +SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1); +a b +CREATE TABLE t2 (a VARCHAR(1), b VARCHAR(10)) charset utf8mb4; +INSERT INTO t2 SELECT * FROM t1; +CREATE INDEX I1 ON t2 (a); +CREATE INDEX I2 ON t2 (b); +EXPLAIN SELECT a,b FROM t2 WHERE b IN (SELECT a FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL I2 NULL NULL NULL 2 100.00 Using where +1 SIMPLE t2 NULL ref I1 I1 7 test.t2.b 2 100.00 Using where; Using index; FirstMatch(t2) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t2` semi join (`test`.`t2`) where (`test`.`t2`.`b` = `test`.`t2`.`a`) +SELECT a,b FROM t2 WHERE b IN (SELECT a FROM t2); +a b +EXPLAIN +SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1 WHERE LENGTH(a)<500); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL I2 NULL NULL NULL 2 100.00 Using where +1 SIMPLE t1 NULL ref I1 I1 5 test.t1.b 2 100.00 Using where; Using index; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t1`) where ((length(`test`.`t1`.`a`) < 500) and (`test`.`t1`.`b` = `test`.`t1`.`a`)) +SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1 WHERE LENGTH(a)<500); +a b +DROP TABLE t1,t2; +# +# BUG#45928 "Differing query results depending on MRR and +# engine_condition_pushdown settings" +# +CREATE TABLE `t1` ( +`pk` int(11) NOT NULL AUTO_INCREMENT, +`time_nokey` time NOT NULL, +`varchar_key` varchar(1) NOT NULL, +`varchar_nokey` varchar(1) NOT NULL, +PRIMARY KEY (`pk`), +KEY `varchar_key` (`varchar_key`) +) AUTO_INCREMENT=12 DEFAULT CHARSET=latin1; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO `t1` VALUES (10,'00:00:00','i','i'),(11,'00:00:00','',''); +SELECT `time_nokey` G1 FROM t1 WHERE ( `varchar_nokey` , `varchar_key` ) IN ( +SELECT `varchar_nokey` , `varchar_nokey` ) AND `varchar_key` >= 'c' HAVING G1 ORDER +BY `pk` ; +G1 +DROP TABLE t1; +# +# BUG#45863 "Assertion failed: (fixed == 0), function fix_fields(), +# file item.cc, line 4448" +# +DROP TABLE IF EXISTS C, BB; +CREATE TABLE C ( +varchar_nokey varchar(1) NOT NULL +); +INSERT INTO C VALUES +('k'),('a'),(''),('u'),('e'),('v'),('i'), +('t'),('u'),('f'),('u'),('m'),('j'),('f'), +('v'),('j'),('g'),('e'),('h'),('z'); +CREATE TABLE BB ( +varchar_nokey varchar(1) NOT NULL +); +INSERT INTO BB VALUES ('i'),('t'); +SELECT varchar_nokey FROM C +WHERE (varchar_nokey, OUTR) IN (SELECT varchar_nokey +FROM BB); +ERROR 42S22: Unknown column 'OUTR' in 'IN/ALL/ANY subquery' +SELECT varchar_nokey FROM C +WHERE (varchar_nokey, OUTR) IN (SELECT varchar_nokey, varchar_nokey +FROM BB); +ERROR 42S22: Unknown column 'OUTR' in 'IN/ALL/ANY subquery' +DROP TABLE C,BB; +# +# During work with BUG#45863 I had problems with a query that was +# optimized differently in regular and prepared mode. +# Because there was a bug in one of the selected strategies, I became +# aware of the problem. Adding an EXPLAIN query to catch this. +DROP TABLE IF EXISTS t1, t2, t3; +CREATE TABLE t1 +(EMPNUM CHAR(3) NOT NULL, +EMPNAME CHAR(20), +GRADE DECIMAL(4), +CITY CHAR(15)) charset latin1; +CREATE TABLE t2 +(PNUM CHAR(3) NOT NULL, +PNAME CHAR(20), +PTYPE CHAR(6), +BUDGET DECIMAL(9), +CITY CHAR(15)) charset latin1; +CREATE TABLE t3 +(EMPNUM CHAR(3) NOT NULL, +PNUM CHAR(3) NOT NULL, +HOURS DECIMAL(5)) charset latin1; +INSERT INTO t1 VALUES ('E1','Alice',12,'Deale'); +INSERT INTO t1 VALUES ('E2','Betty',10,'Vienna'); +INSERT INTO t1 VALUES ('E3','Carmen',13,'Vienna'); +INSERT INTO t1 VALUES ('E4','Don',12,'Deale'); +INSERT INTO t1 VALUES ('E5','Ed',13,'Akron'); +INSERT INTO t2 VALUES ('P1','MXSS','Design',10000,'Deale'); +INSERT INTO t2 VALUES ('P2','CALM','Code',30000,'Vienna'); +INSERT INTO t2 VALUES ('P3','SDP','Test',30000,'Tampa'); +INSERT INTO t2 VALUES ('P4','SDP','Design',20000,'Deale'); +INSERT INTO t2 VALUES ('P5','IRM','Test',10000,'Vienna'); +INSERT INTO t2 VALUES ('P6','PAYR','Design',50000,'Deale'); +INSERT INTO t3 VALUES ('E1','P1',40); +INSERT INTO t3 VALUES ('E1','P2',20); +INSERT INTO t3 VALUES ('E1','P3',80); +INSERT INTO t3 VALUES ('E1','P4',20); +INSERT INTO t3 VALUES ('E1','P5',12); +INSERT INTO t3 VALUES ('E1','P6',12); +INSERT INTO t3 VALUES ('E2','P1',40); +INSERT INTO t3 VALUES ('E2','P2',80); +INSERT INTO t3 VALUES ('E3','P2',20); +INSERT INTO t3 VALUES ('E4','P2',20); +INSERT INTO t3 VALUES ('E4','P4',40); +INSERT INTO t3 VALUES ('E4','P5',80); +CREATE UNIQUE INDEX t1_IDX ON t1(EMPNUM); +EXPLAIN SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN +(SELECT EMPNUM +FROM t3 +WHERE PNUM IN +(SELECT PNUM +FROM t2 +WHERE PTYPE = 'Design')); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL t1_IDX NULL NULL NULL 5 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 12 8.33 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t3`.`EMPNUM` = `test`.`t1`.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) +PREPARE stmt FROM "EXPLAIN SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN + (SELECT EMPNUM + FROM t3 + WHERE PNUM IN + (SELECT PNUM + FROM t2 + WHERE PTYPE = 'Design'))"; +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL t1_IDX NULL NULL NULL 5 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 12 8.33 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t3`.`EMPNUM` = `test`.`t1`.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) + +This line is only in place to help --skip_if_hypergraph diffing some more. + +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL t1_IDX NULL NULL NULL 5 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 12 8.33 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t3`.`EMPNUM` = `test`.`t1`.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) +DEALLOCATE PREPARE stmt; +DROP INDEX t1_IDX ON t1; +CREATE INDEX t1_IDX ON t1(EMPNUM); +EXPLAIN SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN +(SELECT EMPNUM +FROM t3 +WHERE PNUM IN +(SELECT PNUM +FROM t2 +WHERE PTYPE = 'Design')); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL t1_IDX NULL NULL NULL 5 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 12 8.33 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t3`.`EMPNUM` = `test`.`t1`.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) +PREPARE stmt FROM "EXPLAIN SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN + (SELECT EMPNUM + FROM t3 + WHERE PNUM IN + (SELECT PNUM + FROM t2 + WHERE PTYPE = 'Design'))"; +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL t1_IDX NULL NULL NULL 5 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 12 8.33 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t3`.`EMPNUM` = `test`.`t1`.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) + +This line is only in place to help --skip_if_hypergraph diffing some more. + +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL t1_IDX NULL NULL NULL 5 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 12 8.33 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t3`.`EMPNUM` = `test`.`t1`.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) +DEALLOCATE PREPARE stmt; +DROP INDEX t1_IDX ON t1; +EXPLAIN SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN +(SELECT EMPNUM +FROM t3 +WHERE PNUM IN +(SELECT PNUM +FROM t2 +WHERE PTYPE = 'Design')); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 12 8.33 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t3`.`EMPNUM` = `test`.`t1`.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) +PREPARE stmt FROM "EXPLAIN SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN + (SELECT EMPNUM + FROM t3 + WHERE PNUM IN + (SELECT PNUM + FROM t2 + WHERE PTYPE = 'Design'))"; +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 12 8.33 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t3`.`EMPNUM` = `test`.`t1`.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) + +This line is only in place to help --skip_if_hypergraph diffing some more. + +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 12 8.33 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t3`.`EMPNUM` = `test`.`t1`.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) +DEALLOCATE PREPARE stmt; +DROP TABLE t1, t2, t3; +# +# BUG#45221 Query SELECT pk FROM C WHERE pk IN (SELECT int_key) failing +# +CREATE TABLE t1 ( +i1_key INT, +i2 INT, +i3 INT, +KEY i1_index (i1_key) +); +INSERT INTO t1 VALUES (9,1,2), (9,2,1); +CREATE TABLE t2 ( +pk INT NOT NULL, +i1 INT, +PRIMARY KEY (pk) +); +INSERT INTO t2 VALUES (9,1); +SELECT pk +FROM t2 +WHERE +pk IN ( +SELECT i1_key +FROM t1 +WHERE t1.i2 < t1.i3 XOR t2.i1 > 1 +ORDER BY t1.i2 desc); +pk +9 +DROP TABLE t1,t2; +# BUG#50361 Doublenested noncorrelated subquery with FirstMatch and join cache wrong result +# +CREATE TABLE t1( +id INTEGER +); +INSERT INTO t1 VALUES(10),(20); +create table t2 select * from t1; +create table t3 select * from t1; +SELECT * +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t2 +WHERE 1 IN(SELECT 1 +FROM t3)); +id +10 +20 +explain SELECT * +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t2 +WHERE 1 IN(SELECT 1 +FROM t3)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where true +delete from t2; +delete from t3; +INSERT INTO t1 VALUES(30),(40),(50),(60),(70),(80),(90); +insert into t2 select * from t1; +insert into t3 select * from t1; +create table t4 select * from t1; +SELECT * +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t2 +WHERE 1 IN(SELECT 1 +FROM t3 +WHERE 1 IN(SELECT 1 +FROM t4))); +id +10 +20 +30 +40 +50 +60 +70 +80 +90 +explain SELECT * +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t2 +WHERE 1 IN(SELECT 1 +FROM t3 +WHERE 1 IN(SELECT 1 +FROM t4))); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 9 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 9 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 9 100.00 NULL +1 SIMPLE t4 NULL ALL NULL NULL NULL NULL 9 100.00 FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3` join `test`.`t4`) where true +SELECT * +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t1))); +id +10 +20 +30 +40 +50 +60 +70 +80 +90 +drop table t1,t2,t3,t4; +# +# Bug#53236 Segfault in DTCollation::set(DTCollation&) +# +CREATE TABLE t1 ( +pk INTEGER AUTO_INCREMENT, +col_varchar VARCHAR(1), +PRIMARY KEY (pk) +) +; +INSERT INTO t1 (col_varchar) +VALUES +('w'), +('m') +; +SELECT table1.pk +FROM ( t1 AS table1 JOIN t1 AS table2 ON (table1.col_varchar = +table2.col_varchar) ) +WHERE ( 1, 2 ) IN ( SELECT SUBQUERY1_t1.pk AS SUBQUERY1_field1, +SUBQUERY1_t1.pk AS SUBQUERY1_field2 +FROM ( t1 AS SUBQUERY1_t1 JOIN t1 AS SUBQUERY1_t2 +ON (SUBQUERY1_t2.col_varchar = +SUBQUERY1_t1.col_varchar) ) ) +; +pk +drop table t1; +# +# BUG#53298 "wrong result with semijoin (no semijoin strategy chosen)" +# +create table t1 (uid int, fid int); +insert into t1 values (1,1), (3,1); +create table t2 (uid int, name varchar(128)); +insert into t2 values (1, "A"), (2, "B"); +create table t3 (uid int, fid int, index(uid)); +insert into t3 values (1,3), (1,3); +create table t4 (uid int); +insert into t4 values (3); +explain select t2.uid from t2, t1 +where t1.uid in (select t4.uid from t4, t3 where t3.uid=1 and t4.uid=t3.fid) +and t2.uid=t1.fid; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t3 NULL ref uid uid 5 const 1 50.00 Using where +1 SIMPLE t4 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`uid` AS `uid` from `test`.`t2` join `test`.`t1` semi join (`test`.`t4` join `test`.`t3`) where ((`test`.`t3`.`fid` = `test`.`t1`.`uid`) and (`test`.`t4`.`uid` = `test`.`t1`.`uid`) and (`test`.`t3`.`uid` = 1) and (`test`.`t1`.`fid` = `test`.`t2`.`uid`)) +select t2.uid from t2, t1 +where t1.uid in (select t4.uid from t4, t3 where t3.uid=1 and t4.uid=t3.fid) +and t2.uid=t1.fid; +uid +1 +drop table t1,t2,t3,t4; +CREATE TABLE t1 ( +pk int, +a varchar(1), +b varchar(4), +c varchar(4), +d varchar(4), +PRIMARY KEY (pk) +) charset utf8mb4; +INSERT INTO t1 VALUES (1,'o','ffff','ffff','ffoo'),(2,'f','ffff','ffff','ffff'); +CREATE TABLE t2 LIKE t1; +INSERT INTO t2 VALUES (1,'i','iiii','iiii','iiii'),(2,'f','ffff','ffff','ffff'); +EXPLAIN SELECT pk FROM t1 WHERE (a) IN (SELECT a FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`a` = `test`.`t1`.`a`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (a) IN (SELECT a FROM t2 WHERE pk > 0); +pk +2 +SELECT pk FROM t1 WHERE (b,c,d) IN (SELECT b,c,d FROM t2 WHERE pk > 0); +pk +2 +DROP TABLE t1, t2; +CREATE TABLE t1 (f1 INT, f2 DECIMAL(5,3)) ENGINE=MyISAM; +INSERT INTO t1 (f1, f2) VALUES (1, 1.789); +INSERT INTO t1 (f1, f2) VALUES (13, 1.454); +INSERT INTO t1 (f1, f2) VALUES (10, 1.668); +CREATE TABLE t2 LIKE t1; +INSERT INTO t2 VALUES (1, 1.789); +INSERT INTO t2 VALUES (13, 1.454); +EXPLAIN SELECT COUNT(*) FROM t1 WHERE (f1,f2) IN (SELECT f1,f2 FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`f2` = `test`.`t1`.`f2`) and (`test`.`t2`.`f1` = `test`.`t1`.`f1`)) +SELECT COUNT(*) FROM t1 WHERE (f1,f2) IN (SELECT f1,f2 FROM t2); +COUNT(*) +2 +DROP TABLE t1, t2; +CREATE TABLE t1 ( +ID int(11) NOT NULL auto_increment, +Name char(35) NOT NULL default '', +Country char(3) NOT NULL default '', +Population int(11) NOT NULL default '0', +PRIMARY KEY (ID), +INDEX (Population), +INDEX (Country) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t2 ( +Code char(3) NOT NULL default '', +Name char(52) NOT NULL default '', +SurfaceArea float(10,2) NOT NULL default '0.00', +Population int(11) NOT NULL default '0', +Capital int(11) default NULL, +PRIMARY KEY (Code), +UNIQUE INDEX (Name), +INDEX (Population) +) charset utf8mb4; +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t3 ( +Country char(3) NOT NULL default '', +Language char(30) NOT NULL default '', +Percentage float(3,1) NOT NULL default '0.0', +PRIMARY KEY (Country, Language), +INDEX (Percentage) +) charset utf8mb4; +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +EXPLAIN SELECT Name FROM t2 +WHERE t2.Code IN (SELECT Country FROM t1 WHERE Population > 5000000) +AND +t2.Code IN (SELECT Country FROM t3 +WHERE Language='English' AND Percentage > 10 AND +t2.Population > 100000); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL PRIMARY,Population NULL NULL NULL 16 75.00 Using where +1 SIMPLE t1 NULL range Population,Country Population 4 NULL 1 10.00 Using where; FirstMatch(t2) +1 SIMPLE t3 NULL eq_ref PRIMARY,Percentage PRIMARY 132 test.t2.Code,const 1 95.45 Using where +Warnings: +Note 1276 Field or reference 'test.t2.Population' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t2`.`Name` AS `Name` from `test`.`t3` join `test`.`t2` semi join (`test`.`t1`) where ((`test`.`t1`.`Country` = `test`.`t2`.`Code`) and (`test`.`t3`.`Country` = `test`.`t2`.`Code`) and (`test`.`t3`.`Language` = 'English') and (`test`.`t3`.`Percentage` > 10) and (`test`.`t2`.`Population` > 100000) and (`test`.`t1`.`Population` > 5000000)) +EXPLAIN FORMAT=JSON SELECT Name FROM t2 +WHERE t2.Code IN (SELECT Country FROM t1 WHERE Population > 5000000) +AND +t2.Code IN (SELECT Country FROM t3 +WHERE Language='English' AND Percentage > 10 AND +t2.Population > 100000); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "12.07" + }, + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "possible_keys": [ + "PRIMARY", + "Population" + ], + "rows_examined_per_scan": 16, + "rows_produced_per_join": 12, + "filtered": "75.00", + "cost_info": { + "read_cost": "1.13", + "eval_cost": "1.20", + "prefix_cost": "2.33", + "data_read_per_join": "2K" + }, + "used_columns": [ + "Code", + "Name", + "Population" + ], + "attached_condition": "(`test`.`t2`.`Population` > 100000)" + } + }, + { + "table": { + "table_name": "t1", + "access_type": "range", + "possible_keys": [ + "Population", + "Country" + ], + "key": "Population", + "used_key_parts": [ + "Population" + ], + "key_length": "4", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 12, + "filtered": "10.00", + "first_match": "t2", + "cost_info": { + "read_cost": "7.32", + "eval_cost": "1.20", + "prefix_cost": "10.85", + "data_read_per_join": "1K" + }, + "used_columns": [ + "Country", + "Population" + ], + "attached_condition": "((`test`.`t1`.`Country` = `test`.`t2`.`Code`) and (`test`.`t1`.`Population` > 5000000))" + } + }, + { + "table": { + "table_name": "t3", + "access_type": "eq_ref", + "possible_keys": [ + "PRIMARY", + "Percentage" + ], + "key": "PRIMARY", + "used_key_parts": [ + "Country", + "Language" + ], + "key_length": "132", + "ref": [ + "test.t2.Code", + "const" + ], + "rows_examined_per_scan": 1, + "rows_produced_per_join": 11, + "filtered": "95.45", + "cost_info": { + "read_cost": "0.03", + "eval_cost": "1.15", + "prefix_cost": "12.07", + "data_read_per_join": "1K" + }, + "used_columns": [ + "Country", + "Language", + "Percentage" + ], + "attached_condition": "((`test`.`t3`.`Language` = 'English') and (`test`.`t3`.`Percentage` > 10))" + } + } + ] + } +} +Warnings: +Note 1276 Field or reference 'test.t2.Population' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t2`.`Name` AS `Name` from `test`.`t3` join `test`.`t2` semi join (`test`.`t1`) where ((`test`.`t1`.`Country` = `test`.`t2`.`Code`) and (`test`.`t3`.`Country` = `test`.`t2`.`Code`) and (`test`.`t3`.`Language` = 'English') and (`test`.`t3`.`Percentage` > 10) and (`test`.`t2`.`Population` > 100000) and (`test`.`t1`.`Population` > 5000000)) +DROP TABLE t1,t2,t3; +CREATE TABLE t1 ( +Code char(3) NOT NULL DEFAULT '', +Name char(52) NOT NULL DEFAULT '', +Continent enum('Asia','Europe','North America','Africa','Oceania','Antarctica','South America') NOT NULL DEFAULT 'Asia', +Region char(26) NOT NULL DEFAULT '', +SurfaceArea float(10,2) NOT NULL DEFAULT '0.00', +IndepYear smallint(6) DEFAULT NULL, +Population int(11) NOT NULL DEFAULT '0', +LifeExpectancy float(3,1) DEFAULT NULL, +GNP float(10,2) DEFAULT NULL, +GNPOld float(10,2) DEFAULT NULL, +LocalName char(45) NOT NULL DEFAULT '', +GovernmentForm char(45) NOT NULL DEFAULT '', +HeadOfState char(60) DEFAULT NULL, +Capital int(11) DEFAULT NULL, +Code2 char(2) NOT NULL DEFAULT '', +PRIMARY KEY (Code) +) charset utf8mb4; +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t2 ( +ID int(11) NOT NULL AUTO_INCREMENT, +Name char(35) NOT NULL DEFAULT '', +CountryCode char(3) NOT NULL DEFAULT '', +District char(20) NOT NULL DEFAULT '', +Population int(11) NOT NULL DEFAULT '0', +PRIMARY KEY (ID), +KEY CountryCode (CountryCode) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +set names latin1; +Fill the table with test data +This must not use LooseScan: +EXPLAIN SELECT Name FROM t1 +WHERE t1.Code IN ( +SELECT t2.CountryCode FROM t2 WHERE Population > 5000000); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL PRIMARY NULL NULL NULL 31 100.00 NULL +1 SIMPLE t2 NULL ref CountryCode CountryCode 12 test.t1.Code 18 33.33 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`Name` AS `Name` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`CountryCode` = `test`.`t1`.`Code`) and (`test`.`t2`.`Population` > 5000000)) +SELECT Name FROM t1 +WHERE t1.Code IN ( +SELECT t2.CountryCode FROM t2 WHERE Population > 5000000); +Name +Austria +Canada +China +Czech Republic +drop table t1, t2; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4); +create table t1 (a int, b int, key(a)); +insert into t1 select a,a from t0; +create table t2 (a int, b int, primary key(a)); +insert into t2 select * from t1; +Table t2, unlike table t1, should be displayed as pulled out +explain select * from t0 +where t0.a in ( select t1.a from t1,t2 where t2.a=t0.a and +t1.b=t2.b); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL PRIMARY NULL NULL NULL 5 100.00 NULL +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 5 20.00 Using where +1 SIMPLE t1 NULL ref a a 5 test.t2.a 1 20.00 Using where; FirstMatch(t0) +Warnings: +Note 1276 Field or reference 'test.t0.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a` from `test`.`t2` join `test`.`t0` semi join (`test`.`t1`) where ((`test`.`t0`.`a` = `test`.`t2`.`a`) and (`test`.`t1`.`a` = `test`.`t2`.`a`) and (`test`.`t1`.`b` = `test`.`t2`.`b`)) +update t1 set a=3, b=11 where a=4; +update t2 set b=11 where a=3; +select * from t0 where t0.a in (select t1.a from t1, t2 where t2.a=t0.a and t1.b=t2.b); +a +0 +1 +2 +3 +drop table t0, t1, t2; +CREATE TABLE t1 ( +id int(11) NOT NULL, +PRIMARY KEY (id)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t2 ( +id int(11) NOT NULL, +fid int(11) NOT NULL, +PRIMARY KEY (id)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t1 values(1); +insert into t2 values(1,7503),(2,1); +explain select count(*) +from t1 +where fid IN (select fid from t2 where (id between 7502 and 8420) order by fid ); +ERROR 42S22: Unknown column 'fid' in 'IN/ALL/ANY subquery' +drop table t1, t2; +create table t1 (a int, b int, key (a), key (b)); +insert into t1 values (2,4),(2,4),(2,4); +select t1.a from t1 +where +t1.a in (select 1 from t1 where t1.a in (select 1 from t1) group by t1.a); +a +drop table t1; +create table t1(a int,b int,key(a),key(b)); +insert into t1 values (1,1),(2,2),(3,3); +select 1 from t1 +where t1.a not in (select 1 from t1 +where t1.a in (select 1 from t1) +group by t1.b); +1 +1 +1 +drop table t1; +CREATE TABLE t1 +(EMPNUM CHAR(3) NOT NULL, +EMPNAME CHAR(20), +GRADE DECIMAL(4), +CITY CHAR(15)); +CREATE TABLE t2 +(PNUM CHAR(3) NOT NULL, +PNAME CHAR(20), +PTYPE CHAR(6), +BUDGET DECIMAL(9), +CITY CHAR(15)); +CREATE TABLE t3 +(EMPNUM CHAR(3) NOT NULL, +PNUM CHAR(3) NOT NULL, +HOURS DECIMAL(5)); +INSERT INTO t1 VALUES ('E1','Alice',12,'Deale'); +INSERT INTO t1 VALUES ('E2','Betty',10,'Vienna'); +INSERT INTO t1 VALUES ('E3','Carmen',13,'Vienna'); +INSERT INTO t1 VALUES ('E4','Don',12,'Deale'); +INSERT INTO t1 VALUES ('E5','Ed',13,'Akron'); +INSERT INTO t2 VALUES ('P1','MXSS','Design',10000,'Deale'); +INSERT INTO t2 VALUES ('P2','CALM','Code',30000,'Vienna'); +INSERT INTO t2 VALUES ('P3','SDP','Test',30000,'Tampa'); +INSERT INTO t2 VALUES ('P4','SDP','Design',20000,'Deale'); +INSERT INTO t2 VALUES ('P5','IRM','Test',10000,'Vienna'); +INSERT INTO t2 VALUES ('P6','PAYR','Design',50000,'Deale'); +INSERT INTO t3 VALUES ('E1','P1',40); +INSERT INTO t3 VALUES ('E1','P2',20); +INSERT INTO t3 VALUES ('E1','P3',80); +INSERT INTO t3 VALUES ('E1','P4',20); +INSERT INTO t3 VALUES ('E1','P5',12); +INSERT INTO t3 VALUES ('E1','P6',12); +INSERT INTO t3 VALUES ('E2','P1',40); +INSERT INTO t3 VALUES ('E2','P2',80); +INSERT INTO t3 VALUES ('E3','P2',20); +INSERT INTO t3 VALUES ('E4','P2',20); +INSERT INTO t3 VALUES ('E4','P4',40); +INSERT INTO t3 VALUES ('E4','P5',80); +SELECT * FROM t1; +EMPNUM EMPNAME GRADE CITY +E1 Alice 12 Deale +E2 Betty 10 Vienna +E3 Carmen 13 Vienna +E4 Don 12 Deale +E5 Ed 13 Akron +CREATE UNIQUE INDEX t1_IDX ON t1(EMPNUM); +SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN +(SELECT EMPNUM +FROM t3 +WHERE PNUM IN +(SELECT PNUM +FROM t2 +WHERE PTYPE = 'Design')); +EMPNAME +Alice +Betty +Don +DROP INDEX t1_IDX ON t1; +CREATE INDEX t1_IDX ON t1(EMPNUM); +SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN +(SELECT EMPNUM +FROM t3 +WHERE PNUM IN +(SELECT PNUM +FROM t2 +WHERE PTYPE = 'Design')); +EMPNAME +Alice +Betty +Don +DROP INDEX t1_IDX ON t1; +SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN +(SELECT EMPNUM +FROM t3 +WHERE PNUM IN +(SELECT PNUM +FROM t2 +WHERE PTYPE = 'Design')); +EMPNAME +Alice +Betty +Don +DROP TABLE t1, t2, t3; +CREATE TABLE t1 (f1 INT NOT NULL); +CREATE VIEW v1 (a) AS SELECT f1 IN (SELECT f1 FROM t1) FROM t1; +SELECT * FROM v1; +a +drop view v1; +drop table t1; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1(a int, b int); +insert into t1 values (0,0),(1,1),(2,2); +create table t2 as select * from t1; +create table t3 (pk int, a int, primary key(pk)); +insert into t3 select a,a from t0; +explain +select * from t1 left join t2 on (t2.a= t1.a and t2.a in (select pk from t3)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE t3 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using index +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` left join (`test`.`t3` join `test`.`t2`) on(((`test`.`t3`.`pk` = `test`.`t1`.`a`) and (`test`.`t2`.`a` = `test`.`t1`.`a`))) where true +drop table t0, t1, t2, t3; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (a int) as select A.a + 10 *(B.a + 10*C.a) as a from t0 A, t0 B, t0 C; +create table t2 (id int, a int, primary key(id), key(a)) charset utf8mb4 as select a as id, a as a from t1; +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `id` int NOT NULL, + `a` int DEFAULT NULL, + PRIMARY KEY (`id`), + KEY `a` (`a`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +set @a=0; +create table t3 as select * from t2 limit 0; +insert into t3 select @a:=@a+1, t2.a from t2, t0; +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +insert into t3 select @a:=@a+1, t2.a from t2, t0; +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +insert into t3 select @a:=@a+1, t2.a from t2, t0; +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +alter table t3 add primary key(id), add 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); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index a a 5 NULL 1000 100.00 Using where; Using index +1 SIMPLE t3 NULL ref a a 5 test.t2.a 30 100.00 Using index; FirstMatch(t2) +Warnings: +Note 1003 /* select#1 */ select count(`test`.`t2`.`a`) AS `count(a)` from `test`.`t2` semi join (`test`.`t3`) where (`test`.`t3`.`a` = `test`.`t2`.`a`) +select count(a) from t2 where a in ( SELECT a FROM t3); +count(a) +1000 +drop table t0,t1,t2,t3; +# +# Bug#33062: subquery in stored routine cause crash +# +CREATE TABLE t1(a INT); +CREATE TABLE t2(c INT); +CREATE PROCEDURE p1(v1 int) +BEGIN +SELECT 1 FROM t1 WHERE a = v1 AND a IN (SELECT c FROM t2); +END +// +CREATE PROCEDURE p2(v1 int) +BEGIN +SELECT 1 FROM t1 WHERE a IN (SELECT c FROM t2); +END +// +CREATE PROCEDURE p3(v1 int) +BEGIN +SELECT 1 +FROM +t1 t01,t1 t02,t1 t03,t1 t04,t1 t05,t1 t06,t1 t07,t1 t08, +t1 t09,t1 t10,t1 t11,t1 t12,t1 t13,t1 t14,t1 t15,t1 t16, +t1 t17,t1 t18,t1 t19,t1 t20,t1 t21,t1 t22,t1 t23,t1 t24, +t1 t25,t1 t26,t1 t27,t1 t28,t1 t29,t1 t30,t1 t31,t1 t32, +t1 t33,t1 t34,t1 t35,t1 t36,t1 t37,t1 t38,t1 t39,t1 t40, +t1 t41,t1 t42,t1 t43,t1 t44,t1 t45,t1 t46,t1 t47,t1 t48, +t1 t49,t1 t50,t1 t51,t1 t52,t1 t53,t1 t54,t1 t55,t1 t56, +t1 t57,t1 t58,t1 t59,t1 t60 +WHERE t01.a IN (SELECT c FROM t2); +END +// +CREATE PROCEDURE p4(v1 int) +BEGIN +SELECT 1 +FROM +t1 t01,t1 t02,t1 t03,t1 t04,t1 t05,t1 t06,t1 t07,t1 t08, +t1 t09,t1 t10,t1 t11,t1 t12,t1 t13,t1 t14,t1 t15,t1 t16, +t1 t17,t1 t18,t1 t19,t1 t20,t1 t21,t1 t22,t1 t23,t1 t24, +t1 t25,t1 t26,t1 t27,t1 t28,t1 t29,t1 t30,t1 t31,t1 t32, +t1 t33,t1 t34,t1 t35,t1 t36,t1 t37,t1 t38,t1 t39,t1 t40, +t1 t41,t1 t42,t1 t43,t1 t44,t1 t45,t1 t46,t1 t47,t1 t48, +t1 t49,t1 t50,t1 t51,t1 t52,t1 t53,t1 t54,t1 t55,t1 t56, +t1 t57,t1 t58,t1 t59,t1 t60 +WHERE t01.a = v1 AND t01.a IN (SELECT c FROM t2); +END +// +CALL p1(1); +1 +CALL p2(1); +1 +CALL p3(1); +1 +CALL p4(1); +1 +DROP TABLE t1, t2; +DROP PROCEDURE p1; +DROP PROCEDURE p2; +DROP PROCEDURE p3; +DROP PROCEDURE p4; +# +# Bug#48213 Materialized subselect crashes if using GEOMETRY type +# +CREATE TABLE t1 ( +pk int, +a varchar(1), +b varchar(4), +c tinyblob, +d blob, +e mediumblob, +f longblob, +g tinytext, +h text, +i mediumtext, +j longtext, +k geometry, +PRIMARY KEY (pk) +) charset utf8mb4; +INSERT INTO t1 VALUES (1,'o','ffff','ffff','ffoo','ffff','ffff','ffff','ffff','ffff','ffff',ST_GeomFromText('POLYGON((0 0, 0 2, 2 2, 2 0, 0 0))')), (2,'f','ffff','ffff','ffff', 'ffff','ffff','ffff','ffff','ffff','ffff',ST_GeomFromText('POLYGON((0 0, 0 2, 2 2, 2 0, 0 0))')); +CREATE TABLE t2 LIKE t1; +INSERT INTO t2 VALUES (1,'i','iiii','iiii','iiii','iiii','ffff','ffff','ffff','ffff','ffff',ST_GeomFromText('POLYGON((0 0, 0 2, 2 2, 2 0, 0 0))')), (2,'f','ffff','ffff','ffff','ffff','ffff','ffff','ffff','ffff','ffff',ST_GeomFromText('POLYGON((0 0, 0 2, 2 2, 2 0, 0 0))')); +EXPLAIN SELECT pk FROM t1 WHERE (a, b) IN (SELECT a, b FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ 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); +pk +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, c) IN (SELECT b, c FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`c` = `test`.`t1`.`c`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, c) IN (SELECT b, c FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, d) IN (SELECT b, d FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`d` = `test`.`t1`.`d`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, d) IN (SELECT b, d FROM t2 WHERE pk > 0); +pk +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, e) IN (SELECT b, e FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`e` = `test`.`t1`.`e`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, e) IN (SELECT b, e FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, f) IN (SELECT b, f FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`f` = `test`.`t1`.`f`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, f) IN (SELECT b, f FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, g) IN (SELECT b, g FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`g` = `test`.`t1`.`g`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, g) IN (SELECT b, g FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, h) IN (SELECT b, h FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`h` = `test`.`t1`.`h`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, h) IN (SELECT b, h FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, i) IN (SELECT b, i FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`i` = `test`.`t1`.`i`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, i) IN (SELECT b, i FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, j) IN (SELECT b, j FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`j` = `test`.`t1`.`j`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, j) IN (SELECT b, j FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, k) IN (SELECT b, k FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`k` = `test`.`t1`.`k`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, k) IN (SELECT b, k FROM t2 WHERE pk > 0); +pk +1 +2 +DROP TABLE t1, t2; +# End of Bug#48213 +# +# BUG#53060: LooseScan semijoin strategy does not return all rows +# +CREATE TABLE t1 (i INTEGER); +INSERT INTO t1 VALUES (1), (2), (3), (4), (5); +CREATE TABLE t2 (i INTEGER, j INTEGER, KEY k(i, j)); +INSERT INTO t2 VALUES (1, 0), (1, 1), (2, 0), (2, 1); +EXPLAIN +SELECT * FROM t1 WHERE (i) IN (SELECT i FROM t2 where j > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 100.00 Using where +1 SIMPLE t2 NULL ref k k 5 test.t1.i 2 33.33 Using where; Using index; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`i` = `test`.`t1`.`i`) and (`test`.`t2`.`j` > 0)) +SELECT * FROM t1 WHERE (i) IN (SELECT i FROM t2 where j > 0); +i +1 +2 +DROP TABLE t1, t2; +# End of BUG#53060 +# +# Bug#53305 "Duplicate weedout + join buffer (join cache --level=7,8) loses rows" +# +create table t1 (uid int, fid int, index(uid)); +insert into t1 values +(1,1), (1,2), (1,3), (1,4), +(2,5), (2,6), (2,7), (2,8), +(3,1), (3,2), (3,9); +create table t2 (uid int primary key, name varchar(128), index(name)); +insert into t2 values +(1, "A"), (2, "B"), (3, "C"), (4, "D"), (5, "E"), +(6, "F"), (7, "G"), (8, "H"), (9, "I"); +create table t3 (uid int, fid int, index(uid)); +insert into t3 values +(1,1), (1,2), (1,3),(1,4), +(2,5), (2,6), (2,7), (2,8), +(3,1), (3,2), (3,9); +create table t4 (uid int primary key, name varchar(128), index(name)); +insert into t4 values +(1, "A"), (2, "B"), (3, "C"), (4, "D"), (5, "E"), +(6, "F"), (7, "G"), (8, "H"), (9, "I"); +explain select name from t2, t1 +where t1.uid in (select t4.uid from t4, t3 where t3.uid=1 and t4.uid=t3.fid) +and t2.uid=t1.fid; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL uid NULL NULL NULL 11 100.00 Using where +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.fid 1 100.00 NULL +1 SIMPLE t4 NULL eq_ref PRIMARY PRIMARY 4 test.t1.uid 1 100.00 Using index +1 SIMPLE t3 NULL ref uid uid 5 const 4 10.00 Using where; FirstMatch(t4) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`name` AS `name` from `test`.`t4` join `test`.`t2` join `test`.`t1` semi join (`test`.`t3`) where ((`test`.`t4`.`uid` = `test`.`t1`.`uid`) and (`test`.`t3`.`fid` = `test`.`t1`.`uid`) and (`test`.`t3`.`uid` = 1) and (`test`.`t2`.`uid` = `test`.`t1`.`fid`)) +select name from t2, t1 +where t1.uid in (select t4.uid from t4, t3 where t3.uid=1 and t4.uid=t3.fid) +and t2.uid=t1.fid; +name +A +A +B +B +C +D +E +F +G +H +I +drop table t1,t2,t3,t4; +# +# Bug#43768 Prepared query with nested subqueries core dump on second execution +# +CREATE TABLE t1 ( +id INT PRIMARY KEY, +partner_id VARCHAR(35) +) charset utf8mb4; +INSERT INTO t1 VALUES +(1, 'partner1'), (2, 'partner2'), +(3, 'partner3'), (4, 'partner4'); +CREATE TABLE t2 ( +id INT NOT NULL, +t1_line_id INT, +article_id VARCHAR(20), +PRIMARY KEY(id, t1_line_id) +) charset utf8mb4; +INSERT INTO t2 VALUES +(1, 1, 'sup'), (2, 1, 'sup'), +(2, 2, 'sup'), (2, 3, 'sup'), +(2, 4, 'imp'), (3, 1, 'sup'), +(4, 1, 'sup'); +CREATE TABLE t3 ( +user_id VARCHAR(50), +article_id VARCHAR(20) NOT NULL, +PRIMARY KEY(user_id) +) charset utf8mb4; +INSERT INTO t3 VALUES('nicke', 'imp'); +EXPLAIN +SELECT t1.partner_id +FROM t1 +WHERE t1.id IN ( +SELECT t2.id +FROM t2 +WHERE article_id IN ( +SELECT article_id FROM t3 +WHERE user_id = 'nicke' + ) +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL system PRIMARY NULL NULL NULL 1 100.00 NULL +1 SIMPLE t1 NULL ALL PRIMARY NULL NULL NULL 4 100.00 NULL +1 SIMPLE t2 NULL ref PRIMARY PRIMARY 4 test.t1.id 1 14.29 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`partner_id` AS `partner_id` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`id` = `test`.`t1`.`id`) and (`test`.`t2`.`article_id` = 'imp')) +SELECT t1.partner_id +FROM t1 +WHERE t1.id IN ( +SELECT t2.id +FROM t2 +WHERE article_id IN ( +SELECT article_id FROM t3 +WHERE user_id = 'nicke' + ) +); +partner_id +partner2 +PREPARE stmt FROM +'EXPLAIN SELECT t1.partner_id +FROM t1 +WHERE t1.id IN ( + SELECT t2.id + FROM t2 + WHERE article_id IN ( + SELECT article_id FROM t3 + WHERE user_id = \'nicke\' + ) + )'; +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL system PRIMARY NULL NULL NULL 1 100.00 NULL +1 SIMPLE t1 NULL ALL PRIMARY NULL NULL NULL 4 100.00 NULL +1 SIMPLE t2 NULL ref PRIMARY PRIMARY 4 test.t1.id 1 14.29 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`partner_id` AS `partner_id` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`id` = `test`.`t1`.`id`) and (`test`.`t2`.`article_id` = 'imp')) + +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL system PRIMARY NULL NULL NULL 1 100.00 NULL +1 SIMPLE t1 NULL ALL PRIMARY NULL NULL NULL 4 100.00 NULL +1 SIMPLE t2 NULL ref PRIMARY PRIMARY 4 test.t1.id 1 14.29 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`partner_id` AS `partner_id` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`id` = `test`.`t1`.`id`) and (`test`.`t2`.`article_id` = 'imp')) +PREPARE stmt FROM +'SELECT t1.partner_id +FROM t1 +WHERE t1.id IN ( + SELECT t2.id + FROM t2 + WHERE article_id IN ( + SELECT article_id FROM t3 + WHERE user_id = \'nicke\' + ) + )'; +EXECUTE stmt; +partner_id +partner2 + +EXECUTE stmt; +partner_id +partner2 +DROP TABLE t1,t2,t3; +# End of Bug#43768 +# +# Bug#53058 - semijoin execution of subquery with outerjoin yields wrong result +# +CREATE TABLE t1 (i INTEGER); +CREATE TABLE t2 (i INTEGER); +CREATE TABLE t3 (i INTEGER); +INSERT INTO t1 VALUES (1), (2); +INSERT INTO t2 VALUES (6); +INSERT INTO t3 VALUES (1), (2); +explain SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t3 LEFT JOIN t2 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = `test`.`t1`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t3 LEFT JOIN t2 ON t2.i=t3.i); +i +1 +2 +drop table t1,t2,t3; +# +# BUG#49453: re-execution of prepared statement with view +# and semijoin crashes +# +CREATE TABLE t1 (city VARCHAR(50), country_id INT); +CREATE TABLE t2 (country_id INT, country VARCHAR(50)); +INSERT INTO t1 VALUES +('Batna',2),('Bchar',2),('Skikda',2),('Tafuna',3),('Algeria',2) ; +INSERT INTO t2 VALUES (2,'Algeria'),(2,'AlgeriaDup'),(3,'XAmerican Samoa'); +CREATE VIEW v1 AS +SELECT country_id as vf_country_id +FROM t2 +WHERE LEFT(country,1) = "A"; +PREPARE stmt FROM " +SELECT city, country_id +FROM t1 +WHERE country_id IN (SELECT vf_country_id FROM v1); +"; + +EXECUTE stmt; +city country_id +Algeria 2 +Batna 2 +Bchar 2 +Skikda 2 + +EXECUTE stmt; +city country_id +Algeria 2 +Batna 2 +Bchar 2 +Skikda 2 +DROP TABLE t1,t2; +DROP VIEW v1; +# +# Bug#54437 Extra rows with LEFT JOIN + semijoin (firstmatch +# and duplicates weedout) +# +create table t1 (a int); +create table t2 (a int); +create table t3 (a int); +insert into t1 values(1),(1); +insert into t2 values(1),(1),(1),(1); +insert into t3 values(2),(2); +explain select * from t1 where t1.a in (select t2.a from t2 left join t3 on t2.a=t3.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t2` left join `test`.`t3` on((`test`.`t2`.`a` = `test`.`t3`.`a`))) where (`test`.`t2`.`a` = `test`.`t1`.`a`) +select * from t1 where t1.a in (select t2.a from t2 left join t3 on t2.a=t3.a); +a +1 +1 +drop table t1,t2,t3; +# +# Bug#55955: crash in MEMORY engine with IN(LEFT JOIN (JOIN)) +# +CREATE TABLE t1 (a INT); +CREATE TABLE t2 (a INT); +CREATE TABLE t3 (a INT); +INSERT INTO t1 VALUES(1),(1); +INSERT INTO t2 VALUES(1),(1); +INSERT INTO t3 VALUES(2),(2); +explain SELECT * FROM t1 +WHERE t1.a IN (SELECT t2.a +FROM t2 LEFT JOIN (t2 AS t2inner, t3) ON t2.a=t3.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2inner NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t2` left join (`test`.`t2` `t2inner` join `test`.`t3`) on((`test`.`t2`.`a` = `test`.`t3`.`a`))) where (`test`.`t2`.`a` = `test`.`t1`.`a`) +SELECT * FROM t1 +WHERE t1.a IN (SELECT t2.a +FROM t2 LEFT JOIN (t2 AS t2inner, t3) ON t2.a=t3.a); +a +1 +1 +DROP TABLE t1,t2,t3; +# +# BUG#52329 - Wrong result: subquery materialization, IN, +# non-null field followed by nullable +# +CREATE TABLE t1 (a1 CHAR(8) NOT NULL, a2 char(8) NOT NULL); +CREATE TABLE t2a (b1 char(8), b2 char(8)); +CREATE TABLE t2b (b1 CHAR(8), b2 char(8) NOT NULL); +CREATE TABLE t2c (b1 CHAR(8) NOT NULL, b2 char(8)); +INSERT INTO t1 VALUES ('1 - 12', '2 - 22'); +INSERT INTO t2a VALUES ('1 - 11', '2 - 21'), +('1 - 11', '2 - 21'), +('1 - 12', '2 - 22'), +('1 - 12', '2 - 22'), +('1 - 13', '2 - 23'); +INSERT INTO t2b SELECT * FROM t2a; +INSERT INTO t2c SELECT * FROM t2a; +SELECT * FROM t1 +WHERE (a1, a2) IN ( +SELECT b1, b2 FROM t2c WHERE b1 > '0' GROUP BY b1, b2); +a1 a2 +1 - 12 2 - 22 +SELECT * FROM t1 +WHERE (a1, a2) IN ( +SELECT b1, b2 FROM t2a WHERE b1 > '0'); +a1 a2 +1 - 12 2 - 22 +SELECT * FROM t1 +WHERE (a1, a2) IN ( +SELECT b1, b2 FROM t2b WHERE b1 > '0'); +a1 a2 +1 - 12 2 - 22 +SELECT * FROM t1 +WHERE (a1, a2) IN ( +SELECT b1, b2 FROM t2c WHERE b1 > '0'); +a1 a2 +1 - 12 2 - 22 +DROP TABLE t1,t2a,t2b,t2c; +# End BUG#52329 +# +# Bug#45174: Incorrectly applied equality propagation caused wrong +# result on a query with a materialized semi-join. +# +CREATE TABLE t1 ( +varchar_nokey varchar(1) NOT NULL +) charset utf8mb4; +INSERT INTO t1 VALUES +('v'), ('u'), ('n'), ('l'), ('h'), ('u'), ('n'), ('j'), ('k'), +('e'), ('i'), ('u'), ('n'), ('b'), ('x'), (''), ('q'), ('u'); +CREATE TABLE t2 ( +pk int NOT NULL, +varchar_key varchar(1) NOT NULL, +varchar_nokey varchar(1) NOT NULL, +PRIMARY KEY(pk), +KEY varchar_key(varchar_key) +) charset utf8mb4; +INSERT INTO t2 VALUES +(11,'m','m'), (12,'j','j'), (13,'z','z'), (14,'a','a'), (15,'',''), +(16,'e','e'), (17,'t','t'), (19,'b','b'), (20,'w','w'), (21,'m','m'), +(23,'',''), (24,'w','w'), (26,'e','e'), (27,'e','e'), (28,'p','p'); +SELECT varchar_nokey +FROM t1 +WHERE (varchar_nokey, varchar_nokey) IN (SELECT varchar_key, varchar_nokey +FROM t2 +WHERE varchar_nokey < 'n' XOR pk); +varchar_nokey +explain SELECT varchar_nokey +FROM t1 +WHERE (varchar_nokey, varchar_nokey) IN (SELECT varchar_key, varchar_nokey +FROM t2 +WHERE varchar_nokey < 'n' XOR pk); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 18 100.00 NULL +1 SIMPLE t2 NULL ref varchar_key varchar_key 6 test.t1.varchar_nokey 2 6.67 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`varchar_nokey` AS `varchar_nokey` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`varchar_key` = `test`.`t1`.`varchar_nokey`) and (`test`.`t2`.`varchar_nokey` = `test`.`t1`.`varchar_nokey`) and ((`test`.`t2`.`varchar_nokey` < 'n') xor (0 <> `test`.`t2`.`pk`))) +DROP TABLE t1, t2; +# End of the test for bug#45174. +# +# Bug#50019: Wrong result for IN-query with materialization +# +CREATE TABLE t1(i INT); +INSERT INTO t1 VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10); +CREATE TABLE t2(i INT); +INSERT INTO t2 VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10); +CREATE TABLE t3(i INT); +INSERT INTO t3 VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10); +SELECT * FROM t1 WHERE t1.i IN (SELECT t2.i +FROM t2 JOIN t3 +WHERE t2.i + t3.i = 5); +i +1 +2 +3 +4 +explain SELECT * FROM t1 WHERE t1.i IN (SELECT t2.i +FROM t2 JOIN t3 +WHERE t2.i + t3.i = 5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 10 10.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 10 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = `test`.`t1`.`i`) and ((`test`.`t1`.`i` + `test`.`t3`.`i`) = 5)) +DROP TABLE t1,t2,t3; +# End of the test for bug#50019. +# +# Bug#52068: Optimizer generates invalid semijoin materialization plan +# +CREATE TABLE ot1(a INTEGER); +INSERT INTO ot1 VALUES(5), (8); +CREATE TABLE it2(a INTEGER); +INSERT INTO it2 VALUES(9), (5), (1), (8); +CREATE TABLE it3(a INTEGER); +INSERT INTO it3 VALUES(7), (1), (0), (5), (1), (4); +CREATE TABLE ot4(a INTEGER); +INSERT INTO ot4 VALUES(1), (3), (5), (7), (9), (7), (3), (1); +SELECT * FROM ot1,ot4 +WHERE (ot1.a,ot4.a) IN (SELECT it2.a,it3.a +FROM it2,it3); +a a +5 1 +5 1 +5 5 +5 7 +5 7 +8 1 +8 1 +8 5 +8 7 +8 7 +explain SELECT * FROM ot1,ot4 +WHERE (ot1.a,ot4.a) IN (SELECT it2.a,it3.a +FROM it2,it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE ot4 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +1 SIMPLE it2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where +1 SIMPLE it3 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; FirstMatch(ot4) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot4`.`a` AS `a` from `test`.`ot1` join `test`.`ot4` semi join (`test`.`it2` join `test`.`it3`) where ((`test`.`it3`.`a` = `test`.`ot4`.`a`) and (`test`.`it2`.`a` = `test`.`ot1`.`a`)) +DROP TABLE IF EXISTS ot1, ot4, it2, it3; +# End of the test for bug#52068. +# +# Bug#57623: subquery within before insert trigger causes crash (sj=on) +# +CREATE TABLE ot1(a INT); +CREATE TABLE ot2(a INT); +CREATE TABLE ot3(a INT); +CREATE TABLE it1(a INT); +INSERT INTO ot1 VALUES(0),(1),(2),(3),(4),(5),(6),(7); +INSERT INTO ot2 VALUES(0),(2),(4),(6); +INSERT INTO ot3 VALUES(0),(3),(6); +INSERT INTO it1 VALUES(0),(1),(2),(3),(4),(5),(6),(7); +explain SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 on ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a from it1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +1 SIMPLE ot3 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE it1 NULL ALL NULL NULL NULL NULL 8 100.00 Using where; FirstMatch(ot3) +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a`,`test`.`ot3`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` join `test`.`ot3` semi join (`test`.`it1`)) on(((`test`.`ot3`.`a` = `test`.`ot1`.`a`) and (`test`.`it1`.`a` = `test`.`ot1`.`a`) and (`test`.`ot2`.`a` = `test`.`ot1`.`a`))) where true +SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 on ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a from it1); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +prepare s from 'SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 on ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a from it1)'; +execute s; +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +execute s; +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +deallocate prepare s; +DROP TABLE ot1, ot2, ot3, it1; +# End of the test for bug#57623. +# +# Bug#11766739: Crash in tmp_table_param::init() with semijoin=on +# +CREATE TABLE t1 (f1 INTEGER) ENGINE=MyISAM; +CREATE TABLE t2 (f1 INTEGER, f2 INTEGER) ENGINE=MyISAM; +INSERT INTO t1 VALUES (1); +INSERT INTO t2 VALUES (1,1), (2,1); +EXPLAIN SELECT * FROM t2 +WHERE f2 IN (SELECT t1.f1 +FROM t1 LEFT OUTER JOIN (t2 AS b1 JOIN t2 AS b2 ON TRUE) ON TRUE); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE b1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE b2 NULL ALL NULL NULL NULL NULL 2 100.00 FirstMatch(t2) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`f1` AS `f1`,`test`.`t2`.`f2` AS `f2` from `test`.`t2` semi join (`test`.`t1` left join (`test`.`t2` `b1` join `test`.`t2` `b2`) on((true))) where (`test`.`t1`.`f1` = `test`.`t2`.`f2`) +SELECT * FROM t2 +WHERE f2 IN (SELECT t1.f1 +FROM t1 LEFT OUTER JOIN (t2 AS b1 JOIN t2 AS b2 ON TRUE) ON TRUE); +f1 f2 +1 1 +2 1 +DROP TABLE t1, t2; +# End of the test for bug#11766739. +# +# Bug#11766642: crash in Item_field::register_field_in_read_map with view +# +CREATE TABLE t1(a INT); +CREATE VIEW v1 AS SELECT a FROM t1; +INSERT INTO t1 VALUES (0),(1),(2); +SELECT a FROM t1 WHERE a IN +(SELECT a XOR a FROM v1) +ORDER BY a; +a +0 +DROP TABLE t1; +DROP VIEW v1; +# +# Bug#12546542 MISSING ROW WHEN USING OPTIMIZER_JOIN_CACHE_LEVEL>=3 +# +CREATE TABLE t1 ( +f2 varchar(1024) +); +INSERT INTO t1 VALUES ('v'),('we'); +CREATE TABLE t2 ( +col_varchar_1024_utf8 varchar(1024) CHARACTER SET utf8 DEFAULT NULL, +col_int_key int, +col_int int +); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t2 VALUES ('we',4,NULL),('v',1305673728,6); +CREATE TABLE t3 ( +col_int_key int, +col_int int +); +INSERT INTO t3 VALUES (4,4); +SELECT * +FROM t1 +WHERE f2 IN (SELECT a1.col_varchar_1024_utf8 AS f2 +FROM t2 AS a1 LEFT JOIN t3 AS a2 +ON a1.col_int_key = a2.col_int_key +WHERE a1.col_int BETWEEN 1 AND 10 OR a2.col_int IS NOT NULL); +f2 +v +we +DROP TABLE t1,t2,t3; +# +# BUG#12616344 - JCL: DIFFERENT RESULT SET AND DIFFERENT AMOUNT +# OF ROWS WHEN JCL>=3 +# +CREATE TABLE t1 (col_int_nokey int, col_int_key int, col_varchar_key varchar(1)); +INSERT INTO t1 VALUES (0,4,'c'),(1,6,'u'); +CREATE TABLE t2 (pk int, col_int_nokey int, col_varchar_nokey varchar(1)); +INSERT INTO t2 VALUES (1,4,'b'),(94,6,'u'); +CREATE TABLE t3 (pk int, col_int_nokey int, col_varchar_key varchar(1)); +INSERT INTO t3 VALUES (1,4,'j'),(2,6,'v'); +SELECT table2.col_int_key +from t3 as table1 join t1 as table2 on table2.col_int_nokey +where table1.col_int_nokey in +( +select subquery2_t2.col_int_nokey +from t3 as subquery2_t1 +right join +t2 as subquery2_t2 +join t1 as subquery2_t3 +on subquery2_t3.col_int_key = subquery2_t2.col_int_nokey +on subquery2_t3.col_varchar_key = subquery2_t2.col_varchar_nokey +where subquery2_t1.col_varchar_key != table1.col_varchar_key +or subquery2_t2.pk <= table1.pk +); +col_int_key +6 +6 +DROP TABLE t1,t2,t3; +# +# Bug#12608157: ASSERT IN FIELD_LONG::VAL_INT WHEN USING MEMORY ENGINE +# +CREATE TABLE t1 (i1 int); +INSERT INTO t1 VALUES (1); +CREATE TABLE t2 (i1 int, i2 int) ENGINE=memory; +INSERT INTO t2 VALUES (1, 2),(7, 3); +SELECT GRANDPARENT1.i1 +FROM t2 AS GRANDPARENT1 +WHERE GRANDPARENT1.i2 +IN ( SELECT PARENT1.i2 +FROM t2 AS PARENT1 JOIN t1 AS PARENT2 ON (PARENT1.i1 = PARENT2.i1) +WHERE +GRANDPARENT1.i1 IN ( SELECT CHILD1.i1 FROM t2 AS CHILD1 ) +ORDER BY PARENT1.i1) +ORDER BY GRANDPARENT1.i2 ; +i1 +1 +DROP TABLE t1,t2; +# +# Bug#12640083: Same query executed as WHERE subquery gives different +# results on IN() compare +# +CREATE TABLE t1 ( +pk int NOT NULL, +col_varchar_1024_utf8_key varchar(1024) CHARACTER SET utf8 DEFAULT NULL, +col_varchar_10_latin1_key varchar(10) DEFAULT NULL, +PRIMARY KEY (pk), +KEY col_varchar_1024_utf8_key(col_varchar_1024_utf8_key(333)), +KEY col_varchar_10_latin1_key(col_varchar_10_latin1_key) +) charset utf8mb4; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES +(1, 'a', 'a'), +(2, 'ab', 'ab'), +(3, 'abc', 'abc'), +(4, 'abcd', 'abcd'); +CREATE TABLE t2 ( +pk int NOT NULL AUTO_INCREMENT, +PRIMARY KEY (pk) +) charset utf8mb4 ENGINE=Innodb; +CREATE TABLE t3 charset utf8mb4 +SELECT alias1.col_varchar_10_latin1_key +FROM t1 AS alias1 +LEFT JOIN t1 AS alias2 +JOIN t2 AS alias3 +ON alias2.col_varchar_10_latin1_key +ON alias1.col_varchar_1024_utf8_key +WHERE alias1.pk AND alias1.pk < 3 OR alias1.pk AND alias3.pk; +EXPLAIN SELECT * +FROM t3 +WHERE col_varchar_10_latin1_key IN ( +SELECT alias1.col_varchar_10_latin1_key +FROM t1 AS alias1 +LEFT JOIN t1 AS alias2 +JOIN t2 AS alias3 +ON alias2.col_varchar_10_latin1_key +ON alias1.col_varchar_1024_utf8_key +WHERE alias1.pk AND alias1.pk < 3 OR alias1.pk AND alias3.pk); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE alias1 NULL ref PRIMARY,col_varchar_10_latin1_key col_varchar_10_latin1_key 43 test.t3.col_varchar_10_latin1_key 2 100.00 Using where +1 SIMPLE alias3 NULL index NULL PRIMARY 4 NULL 1 100.00 Using where; Using index +1 SIMPLE alias2 NULL index NULL col_varchar_10_latin1_key 43 NULL 4 100.00 Using where; Using index; FirstMatch(t3) +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`col_varchar_10_latin1_key` AS `col_varchar_10_latin1_key` from `test`.`t3` semi join (`test`.`t1` `alias1` left join (`test`.`t1` `alias2` join `test`.`t2` `alias3`) on(((0 <> `test`.`alias1`.`col_varchar_1024_utf8_key`) and (0 <> `test`.`alias2`.`col_varchar_10_latin1_key`)))) where ((`test`.`alias1`.`col_varchar_10_latin1_key` = `test`.`t3`.`col_varchar_10_latin1_key`) and (((0 <> `test`.`alias1`.`pk`) and (`test`.`alias1`.`pk` < 3)) or ((0 <> `test`.`alias1`.`pk`) and (0 <> `test`.`alias3`.`pk`)))) +SELECT * +FROM t3 +WHERE col_varchar_10_latin1_key IN ( +SELECT alias1.col_varchar_10_latin1_key +FROM t1 AS alias1 +LEFT JOIN t1 AS alias2 +JOIN t2 AS alias3 +ON alias2.col_varchar_10_latin1_key +ON alias1.col_varchar_1024_utf8_key +WHERE alias1.pk AND alias1.pk < 3 OR alias1.pk AND alias3.pk); +col_varchar_10_latin1_key +a +ab +DROP TABLE t1, t2, t3; +# End of the test for bug#12640083. +# +# Bug#12603200 - Assert in QUICK_INDEX_MERGE_SELECT::need_sorted_output +# +CREATE TABLE t1 ( +pk int NOT NULL, +col_int_key int NOT NULL, +col_varchar_nokey varchar(1) NOT NULL, +col_varchar_key varchar(1) NOT NULL, +PRIMARY KEY(pk), +KEY col_int_key(col_int_key), +KEY col_varchar_key(col_varchar_key, col_int_key) +) charset utf8mb4 engine=innodb; +INSERT INTO t1 VALUES +(1,7,'a','a'), +(2,0,'v','v'), +(3,9,'c','c'), +(4,3,'m','m'), +(5,2,'a','a'), +(6,1,'d','d'), +(7,8,'y','y'), +(8,6,'t','t'), +(11,7,'a','x'), +(12,0,'v','v'), +(13,9,'c','c'), +(14,3,'m','m'), +(15,2,'a','x'), +(16,1,'d','d'), +(17,8,'y','y'), +(18,6,'t','u'), +(19,6,'t','u'); +CREATE TABLE t2 ( +pk int NOT NULL, +col_int_key int NOT NULL, +col_varchar_key varchar(1) NOT NULL, +PRIMARY KEY(pk), +KEY col_varchar_key(col_varchar_key, col_int_key) +) charset utf8mb4 engine=innodb; +INSERT INTO t2(pk,col_int_key,col_varchar_key) VALUES +(8,7,'c'), +(11,4,'l'), +(12,7,'b'), +(13,0,'c'), +(14,2,'i'), +(15,9,'h'), +(16,4,'q'), +(17,1,'m'), +(18,9,'b'), +(19,2,'e'), +(20,1,'c'), +(21,7,'z'), +(22,4,'l'), +(23,7,'z'), +(24,0,'c'), +(25,2,'i'), +(26,9,'h'), +(27,4,'q'), +(28,0,'a'), +(29,1,'d'); +EXPLAIN SELECT outr.col_varchar_key AS x, outr.pk AS y +FROM t1 AS outr +WHERE outr.col_varchar_key IN (SELECT innr.col_varchar_key +FROM t2 AS innr +WHERE innr.col_varchar_key = 'a' OR innr.pk = 8) +AND outr.col_varchar_nokey < 't' +ORDER BY outr.col_varchar_key, outr.pk; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 17 33.33 Parallel execute (1 workers) +2 SIMPLE outr NULL ALL col_varchar_key NULL NULL NULL 17 33.33 Using where; Using filesort +2 SIMPLE innr NULL ref PRIMARY,col_varchar_key col_varchar_key 6 test.outr.col_varchar_key 1 100.00 Using where; Using index; FirstMatch(outr) +Warnings: +Note 1003 /* select#1 */ select `test`.`outr`.`col_varchar_key` AS `x`,`test`.`outr`.`pk` AS `y` from `test`.`t1` `outr` semi join (`test`.`t2` `innr`) where ((`test`.`innr`.`col_varchar_key` = `test`.`outr`.`col_varchar_key`) and (`test`.`outr`.`col_varchar_nokey` < 't') and ((`test`.`outr`.`col_varchar_key` = 'a') or (`test`.`innr`.`pk` = 8))) order by `test`.`outr`.`col_varchar_key`,`test`.`outr`.`pk` +SELECT outr.col_varchar_key AS x, outr.pk AS y +FROM t1 AS outr +WHERE outr.col_varchar_key IN (SELECT innr.col_varchar_key +FROM t2 AS innr +WHERE innr.col_varchar_key = 'a' OR innr.pk = 8) +AND outr.col_varchar_nokey < 't' +ORDER BY outr.col_varchar_key, outr.pk; +x y +a 1 +a 5 +c 3 +c 13 +DROP TABLE t1, t2; +# End of bug#12603200 +# +# Bug#12603183: Segfault in hp_movelink +# +CREATE TABLE t1 ( +col_varchar_key varchar(1) , +col_varchar_nokey varchar(1) , +KEY col_varchar_key(col_varchar_key) +) charset latin1; +INSERT INTO t1 VALUES +('i','i'), +('h','h'), +('q','q'), +('a','a'), +('v','v'), +('u','u'), +('s','s'), +('y','y'), +('z','z'), +('h','h'), +('p','p'), +('e','e'), +('i','i'), +('y','y'), +('w','w'); +CREATE TABLE t2 ( +col_varchar_nokey varchar(1) +) charset latin1; +INSERT INTO t2 VALUES +('b'); +EXPLAIN SELECT grandparent1.col_varchar_nokey +FROM t1 AS grandparent1 LEFT JOIN t2 AS grandparent2 USING (col_varchar_nokey) +WHERE (grandparent1.col_varchar_key) IN +(SELECT parent1.col_varchar_nokey +FROM t1 AS parent1 +WHERE parent1.col_varchar_key IN +(SELECT child1.col_varchar_nokey AS c1 +FROM t1 AS child1 LEFT JOIN t2 AS child2 +ON (child1.col_varchar_key > child2.col_varchar_nokey))); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE grandparent1 NULL ALL col_varchar_key NULL NULL NULL 15 100.00 NULL +1 SIMPLE grandparent2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE parent1 NULL ALL col_varchar_key NULL NULL NULL 15 10.00 Using where +1 SIMPLE child1 NULL ALL NULL NULL NULL NULL 15 10.00 Using where +1 SIMPLE child2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(grandparent2) +Warnings: +Note 1003 /* select#1 */ select `test`.`grandparent1`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t1` `grandparent1` left join `test`.`t2` `grandparent2` on((`test`.`grandparent2`.`col_varchar_nokey` = `test`.`grandparent1`.`col_varchar_nokey`)) semi join (`test`.`t1` `parent1` join `test`.`t1` `child1` left join `test`.`t2` `child2` on((`test`.`child1`.`col_varchar_key` > `test`.`child2`.`col_varchar_nokey`))) where ((`test`.`parent1`.`col_varchar_nokey` = `test`.`grandparent1`.`col_varchar_key`) and (`test`.`child1`.`col_varchar_nokey` = `test`.`parent1`.`col_varchar_key`)) +SELECT grandparent1.col_varchar_nokey +FROM t1 AS grandparent1 LEFT JOIN t2 AS grandparent2 USING (col_varchar_nokey) +WHERE (grandparent1.col_varchar_key) IN +(SELECT parent1.col_varchar_nokey +FROM t1 AS parent1 +WHERE parent1.col_varchar_key IN +(SELECT child1.col_varchar_nokey AS c1 +FROM t1 AS child1 LEFT JOIN t2 AS child2 +ON (child1.col_varchar_key > child2.col_varchar_nokey))); +col_varchar_nokey +a +e +h +h +i +i +p +q +s +u +v +w +y +y +z +DROP TABLE t1, t2; +# End of test for bug#12603183. +# +# Bug#12818569: Diff nr of rows returned when using IN/ALL+subquery +# +CREATE TABLE t1 ( +col_int_key INT NOT NULL, +col_datetime_key DATETIME NOT NULL, +col_varchar_key VARCHAR(1) NOT NULL, +KEY col_int_key (col_int_key), +KEY col_datetime_key(col_datetime_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t1 VALUES +(7,'2004-06-06 04:22:12','v'), (0,'2005-11-13 01:12:31','s'), +(9,'2002-05-04 01:50:00','l'), (3,'2004-10-27 10:28:45','y'), +(4,'2006-07-22 05:24:23','c'), (2,'2002-05-16 21:34:03','i'), +(5,'2008-04-17 10:45:30','h'), (3,'2009-04-21 02:58:02','q'), +(1,'2008-01-11 11:01:51','a'), (3,'1900-01-01 00:00:00','v'), +(6,'2007-05-17 18:24:57','u'), (7,'2007-08-07 00:00:00','s'), +(5,'2001-08-28 00:00:00','y'), (1,'2004-04-16 00:27:28','z'), +(204,'2005-05-03 07:06:22','h'), (224,'2009-03-11 17:09:50','p'), +(9,'2007-12-08 01:54:28','e'), (5,'2009-07-28 18:19:54','i'), +(0,'2008-06-08 00:00:00','y'), (3,'2005-02-09 09:20:26','w'); +CREATE TABLE t2 ( +col_varchar_nokey VARCHAR(1) NOT NULL +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t2 VALUES ('v'), ('y'), ('j'), ('c'), ('d'), ('r'); +explain SELECT col_varchar_key +FROM t1 +WHERE col_varchar_key IN (SELECT col_varchar_nokey +FROM t2) +ORDER BY col_datetime_key LIMIT 4; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 20 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL col_varchar_key NULL NULL NULL 20 100.00 Using filesort +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col_varchar_key` AS `col_varchar_key` from `test`.`t1` semi join (`test`.`t2`) where (`test`.`t2`.`col_varchar_nokey` = `test`.`t1`.`col_varchar_key`) order by `test`.`t1`.`col_datetime_key` limit 4 +SELECT col_varchar_key +FROM t1 +WHERE col_varchar_key IN (SELECT col_varchar_nokey +FROM t2) +ORDER BY col_datetime_key LIMIT 4; +col_varchar_key +v +y +v +y +DROP TABLE t1, t2; +# End of test for bug#12818569. +# +# Bug#12803439: Assert in replace_subcondition() on update query +# +CREATE TABLE t1(a INTEGER); +INSERT INTO t1 values(1), (2); +CREATE TABLE t2(a INTEGER); +INSERT INTO t2 VALUES(1), (3); +SELECT * +FROM t1 +WHERE a IN (SELECT a +FROM t2 +HAVING a IN (SELECT a +FROM t2) +) +HAVING a IN (SELECT a +FROM t2); +a +1 +DROP TABLE t1, t2; +# End of test for bug#12803439. +# +# Bug#12797534: Segfault in hp_movelink still exists +# +CREATE TABLE t1 ( +g1 VARCHAR(1) NOT NULL +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t1 VALUES ('d'), ('s'); +CREATE TABLE t2 ( +pk INT NOT NULL, +col_int_key INT NOT NULL, +col_varchar_key VARCHAR(1) NOT NULL, +col_varchar_nokey VARCHAR(1) NOT NULL, +PRIMARY KEY (pk), +KEY col_varchar_key(col_varchar_key, col_int_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t2 VALUES +(1,4,'j','j'), (2,6,'v','v'), (3,3,'c','c'), (4,5,'m','m'), +(5,3,'d','d'), (6,246,'d','d'), (7,2,'y','y'), (8,9,'t','t'), +(9,3,'d','d'), (10,8,'s','s'), (11,1,'r','r'), (12,8,'m','m'), +(13,8,'b','b'), (14,5,'x','x'), (15,7,'g','g'), (16,5,'p','p'), +(17,1,'q','q'), (18,6,'w','w'), (19,2,'d','d'), (20,9,'e','e'); +CREATE TABLE t3 ( +pk INTEGER NOT NULL, +PRIMARY KEY (pk) +) ENGINE=InnoDB; +INSERT INTO t3 VALUES (10); +EXPLAIN SELECT * +FROM t1 +WHERE g1 NOT IN +(SELECT grandparent1.col_varchar_nokey AS g1 +FROM t2 AS grandparent1 +WHERE grandparent1.col_varchar_key IN +(SELECT parent1.col_varchar_nokey AS p1 +FROM t2 AS parent1 LEFT JOIN t3 AS parent2 USING (pk) +) +AND grandparent1.col_varchar_key IS NOT NULL +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 SIMPLE parent1 NULL ALL NULL NULL NULL NULL 20 100.00 Using where; Not exists +2 SIMPLE parent2 NULL eq_ref PRIMARY PRIMARY 4 test.parent1.pk 1 100.00 Using index +2 SIMPLE grandparent1 NULL ref col_varchar_key col_varchar_key 6 test.parent1.col_varchar_nokey 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`g1` AS `g1` from `test`.`t1` anti join (`test`.`t2` `grandparent1` join `test`.`t2` `parent1` left join `test`.`t3` `parent2` on((`test`.`parent2`.`pk` = `test`.`parent1`.`pk`))) on(((`test`.`grandparent1`.`col_varchar_nokey` = `test`.`t1`.`g1`) and (`test`.`grandparent1`.`col_varchar_key` = `test`.`parent1`.`col_varchar_nokey`) and (`test`.`grandparent1`.`col_varchar_key` is not null))) where true +SELECT * +FROM t1 +WHERE g1 NOT IN +(SELECT grandparent1.col_varchar_nokey AS g1 +FROM t2 AS grandparent1 +WHERE grandparent1.col_varchar_key IN +(SELECT parent1.col_varchar_nokey AS p1 +FROM t2 AS parent1 LEFT JOIN t3 AS parent2 USING (pk) +) +AND grandparent1.col_varchar_key IS NOT NULL +); +g1 +DROP TABLE t1, t2, t3; +CREATE TABLE t1 ( +pk INTEGER AUTO_INCREMENT, +col_int_key INTEGER , +col_varchar_key VARCHAR(1) , +col_varchar_nokey VARCHAR(1) , +PRIMARY KEY (pk), +KEY (col_varchar_key,col_int_key) +) ENGINE=INNODB; +INSERT INTO t1 (col_int_key,col_varchar_key,col_varchar_nokey) VALUES +(0,'x','x'), (1,'j','j'), (1,'r','r'), (9,'v','v'), (5,'r','r'); +CREATE TABLE t2 ( +pk INTEGER AUTO_INCREMENT, +col_int_key INTEGER , +col_varchar_key VARCHAR(1) , +col_varchar_nokey VARCHAR(1) , +PRIMARY KEY (pk), +KEY (col_int_key), +KEY (col_varchar_key,col_int_key) +) AUTO_INCREMENT=10 ENGINE=INNODB; +INSERT INTO t2 (col_int_key, col_varchar_key, col_varchar_nokey) VALUES +(NULL,'x','x'), (NULL,'j','j'), (8,'c','c'); +CREATE TABLE t3 +SELECT outr.col_varchar_nokey AS x +FROM t1 AS outr +WHERE outr.col_varchar_nokey IN +(SELECT innr.col_varchar_nokey AS y +FROM t2 AS innr +WHERE innr.col_int_key IS NULL) +AND outr.col_varchar_nokey IS NOT NULL +AND NOT col_varchar_key IS NULL; +SELECT * +FROM t3 +WHERE x NOT IN +(SELECT outr.col_varchar_nokey AS x +FROM t1 AS outr +WHERE outr.col_varchar_nokey IN +(SELECT innr.col_varchar_nokey AS y +FROM t2 AS innr +WHERE innr.col_int_key IS NULL) +AND outr.col_varchar_nokey IS NOT NULL +AND NOT col_varchar_key IS NULL); +x +DROP TABLE t1, t2, t3; +# End of test for bug#12797534. +# +# Bug#12714094: Assert in optimize_semijoin_nests() +# +CREATE TABLE it ( +pk int NOT NULL, +col_varchar VARCHAR(10) DEFAULT NULL, +PRIMARY KEY (pk) +) ENGINE=MyISAM; +INSERT INTO it VALUES (1, 'g'); +CREATE TABLE ot +SELECT alias1.pk AS field1 +FROM it AS alias1 +LEFT JOIN it AS alias2 +ON alias1.col_varchar = alias2.col_varchar +; +SELECT * +FROM ot +WHERE field1 IN ( +SELECT alias1.pk +FROM it AS alias1 +LEFT JOIN it AS alias2 +ON alias1.col_varchar = alias2.col_varchar +); +field1 +1 +DROP TABLE it, ot; +# End of test for bug#12714094 +# +# Bug#12867557: Valgrind: conditional jump/move at key_cmp +# +CREATE TABLE t1 ( +pk INTEGER AUTO_INCREMENT, +col_int_key INTEGER, +PRIMARY KEY (pk), +KEY (col_int_key) +) AUTO_INCREMENT=10; +INSERT INTO t1 (col_int_key) VALUES (8); +CREATE TABLE t2 ( +pk INTEGER AUTO_INCREMENT, +col_int_key INTEGER, +col_time_key TIME, +PRIMARY KEY (pk), +KEY (col_int_key), +KEY (col_time_key) +) AUTO_INCREMENT=10; +INSERT INTO t2 (col_int_key, col_time_key) +VALUES +(8, '22:55:23.019225'), (7, '10:19:31.050677'), (1, '14:40:36.038608'), +(7, '04:37:47.062416'), (9, '19:34:06.054514'), (NULL,'20:35:33.022996'), +(1, NULL), (9, '14:43:37.057393'), (2, '02:23:09.043438'), +(9, '01:22:45.041064'), (2, '00:00:00'), (4, '00:13:25.038482'), +(0, '03:47:16.042671'), (4, '01:41:48.007423'), (8, '00:00:00'), +(NULL, '22:32:04.047407'), (NULL, '16:44:14.028443'), (0, '17:38:37.059754'), +(NULL, '08:46:48.042388'), (8, '14:11:27.044095'); +CREATE TABLE t0 +SELECT DISTINCT grandparent1.col_time_key AS g1 +FROM t2 AS grandparent1 +WHERE grandparent1.col_int_key IN +(SELECT parent1.col_int_key AS p1 +FROM t1 AS parent1) +AND grandparent1.pk > 9; +UPDATE t0 +SET g1 = g1 +WHERE g1 IN +(SELECT grandparent1.col_time_key AS g1 +FROM t2 AS grandparent1 +WHERE grandparent1.col_int_key IN +(SELECT parent1.col_int_key AS p1 +FROM t1 AS parent1) +AND grandparent1.pk > 9); +DROP TABLE t0, t1, t2; +# End of test for bug#12867557 +# +# Bug#12711441: crash in fix_after_pullout +# +CREATE TABLE t1 ( +pk int NOT NULL, +col_int_nokey int DEFAULT NULL, +col_int_key int DEFAULT NULL, +col_time_key time DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +PRIMARY KEY (pk) +); +CREATE VIEW v1 AS SELECT * FROM t1; +CREATE TABLE t2 ( +col_int_key int DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +KEY col_varchar_key(col_varchar_key, col_int_key) +); +CREATE TABLE t3 ( +pk int NOT NULL, +col_int_key INT DEFAULT NULL, +PRIMARY KEY (pk) +); +CREATE TABLE t4 ( +col_int_nokey INT DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +KEY col_varchar_key(col_varchar_key) +); +CREATE TABLE ts +SELECT alias1.col_time_key AS field1 +FROM v1 AS alias1 +RIGHT JOIN t3 AS alias2 +ON alias2.col_int_key = alias1.col_int_nokey +WHERE alias1.pk >= SOME( +SELECT SQ1_alias1.pk AS SQ1_field1 +FROM t3 AS SQ1_alias1 +INNER JOIN (t2 AS SQ1_alias2 +INNER JOIN t4 AS SQ1_alias3 +ON SQ1_alias3.col_varchar_key = SQ1_alias2.col_varchar_nokey) +ON SQ1_alias3.col_int_nokey = SQ1_alias2.col_int_key +WHERE SQ1_alias2.col_varchar_key <= alias1.col_varchar_key +AND SQ1_alias3.col_varchar_nokey <> alias1.col_varchar_key) +; +SELECT * FROM ts WHERE field1 IN ( +SELECT alias1.col_time_key AS field1 +FROM v1 AS alias1 +RIGHT JOIN t3 AS alias2 +ON alias2.col_int_key = alias1.col_int_nokey +WHERE alias1.pk >= SOME( +SELECT SQ1_alias1.pk AS SQ1_field1 +FROM t3 AS SQ1_alias1 +INNER JOIN (t2 AS SQ1_alias2 +INNER JOIN t4 AS SQ1_alias3 +ON SQ1_alias3.col_varchar_key = SQ1_alias2.col_varchar_nokey) +ON SQ1_alias3.col_int_nokey = SQ1_alias2.col_int_key +WHERE SQ1_alias2.col_varchar_key <= alias1.col_varchar_key +AND SQ1_alias3.col_varchar_nokey <> alias1.col_varchar_key) +); +field1 +DROP TABLE t1, t2, t3, t4, ts; +DROP VIEW v1; +# End of test for bug#12711441. +# +# Bug#12664936: Same query executed as where subquery ... +# +CREATE TABLE t1 ( +col_varchar_key VARCHAR(1), +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4; +INSERT INTO t1 VALUES +('o'), ('w'), ('m'), ('q'), +('f'), ('p'), ('j'), ('c'); +CREATE TABLE t2 ( +col_int_nokey INTEGER, +col_int_key INTEGER, +col_varchar_key varchar(1), +KEY col_int_key (col_int_key) +) charset utf8mb4; +INSERT INTO t2 VALUES +(8,5,'u'),(4,5,'p'),(8,1,'o'),(NULL,7,'v'), +(1,2,'g'),(2,1,'q'),(NULL,7,'l'),(3,1,'n'); +CREATE TABLE t4 +SELECT t2.col_int_nokey, t2.col_varchar_key +FROM t1 JOIN t2 ON t2.col_varchar_key = t1.col_varchar_key +WHERE t2.col_int_key = 1; +EXPLAIN SELECT * +FROM t4 +WHERE (col_int_nokey, col_varchar_key) IN +(SELECT t2.col_int_nokey, t2.col_varchar_key +FROM t1 JOIN t2 ON t2.col_varchar_key = t1.col_varchar_key +WHERE t2.col_int_key = 1 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t4 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE t2 NULL ref col_int_key col_int_key 5 const 3 12.50 Using where +1 SIMPLE t1 NULL ref col_varchar_key col_varchar_key 7 test.t4.col_varchar_key 2 100.00 Using index; FirstMatch(t4) +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`col_int_nokey` AS `col_int_nokey`,`test`.`t4`.`col_varchar_key` AS `col_varchar_key` from `test`.`t4` semi join (`test`.`t1` join `test`.`t2`) where ((`test`.`t2`.`col_varchar_key` = `test`.`t4`.`col_varchar_key`) and (`test`.`t1`.`col_varchar_key` = `test`.`t4`.`col_varchar_key`) and (`test`.`t2`.`col_int_nokey` = `test`.`t4`.`col_int_nokey`) and (`test`.`t2`.`col_int_key` = 1)) +SELECT * +FROM t4 +WHERE (col_int_nokey, col_varchar_key) IN +(SELECT t2.col_int_nokey, t2.col_varchar_key +FROM t1 JOIN t2 ON t2.col_varchar_key = t1.col_varchar_key +WHERE t2.col_int_key = 1 +); +col_int_nokey col_varchar_key +8 o +2 q +DROP TABLE t1, t2, t4; +# End of test for bug#12664936. +# +# Bug#13340270: assertion table->sort.record_pointers == __null +# +CREATE TABLE t1 ( +pk int NOT NULL, +col_int_key int DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key, col_int_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t1 VALUES +(10,8,'x','x'), +(11,7,'d','d'), +(12,1,'r','r'), +(13,7,'f','f'), +(14,9,'y','y'), +(15,NULL,'u','u'), +(16,1,'m','m'), +(17,9,NULL,NULL), +(18,2,'o','o'), +(19,9,'w','w'), +(20,2,'m','m'), +(21,4,'q','q'); +CREATE TABLE t2 +SELECT alias1.col_varchar_nokey AS field1 +FROM t1 AS alias1 JOIN t1 AS alias2 +ON alias2.col_int_key = alias1.pk OR +alias2.col_int_key = alias1.col_int_key +WHERE alias1.pk = 58 OR alias1.col_varchar_key = 'o' + +; +EXPLAIN SELECT * +FROM t2 +WHERE (field1) IN (SELECT alias1.col_varchar_nokey AS field1 +FROM t1 AS alias1 JOIN t1 AS alias2 +ON alias2.col_int_key = alias1.pk OR +alias2.col_int_key = alias1.col_int_key +WHERE alias1.pk = 58 OR alias1.col_varchar_key = 'o' +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE alias1 NULL index_merge PRIMARY,col_int_key,col_varchar_key col_varchar_key,PRIMARY 7,4 NULL 2 10.00 Using sort_union(col_varchar_key,PRIMARY); Using where +1 SIMPLE alias2 NULL ALL col_int_key NULL NULL NULL 12 19.00 Range checked for each record (index map: 0x2); FirstMatch(t2) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`field1` AS `field1` from `test`.`t2` semi join (`test`.`t1` `alias1` join `test`.`t1` `alias2`) where ((`test`.`alias1`.`col_varchar_nokey` = `test`.`t2`.`field1`) and ((`test`.`alias1`.`pk` = 58) or (`test`.`alias1`.`col_varchar_key` = 'o')) and ((`test`.`alias2`.`col_int_key` = `test`.`alias1`.`pk`) or (`test`.`alias2`.`col_int_key` = `test`.`alias1`.`col_int_key`))) +SELECT * +FROM t2 +WHERE (field1) IN (SELECT alias1.col_varchar_nokey AS field1 +FROM t1 AS alias1 JOIN t1 AS alias2 +ON alias2.col_int_key = alias1.pk OR +alias2.col_int_key = alias1.col_int_key +WHERE alias1.pk = 58 OR alias1.col_varchar_key = 'o' +); +field1 +o +o +DROP TABLE t1, t2; +# End of test for bug#13340270. +# +# Bug#13335319: Seg fault when analyzing FirstMatch semi-join strategy +# +CREATE TABLE ot1(a INTEGER); +INSERT INTO ot1 VALUES(1), (2), (3); +CREATE TABLE ot2(a INTEGER); +INSERT INTO ot2 VALUES(1), (2), (4), (6), (8), (10); +CREATE TABLE it1(a INTEGER); +INSERT INTO it1 VALUES(1), (3), (5), (7); +CREATE TABLE it2(a INTEGER); +INSERT INTO it2 VALUES(1), (3), (5), (7), (9); +explain SELECT ot1.a, ot2.a +FROM ot1, ot2 +WHERE ot1.a IN (SELECT a FROM it1) AND +ot2.a IN (SELECT a FROM it2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE it1 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; FirstMatch(ot1) +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 6 100.00 NULL +1 SIMPLE it2 NULL ALL NULL NULL NULL NULL 5 20.00 Using where; FirstMatch(ot2) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` join `test`.`ot2` semi join (`test`.`it1`) semi join (`test`.`it2`) where ((`test`.`it2`.`a` = `test`.`ot2`.`a`) and (`test`.`it1`.`a` = `test`.`ot1`.`a`)) +SELECT ot1.a, ot2.a +FROM ot1, ot2 +WHERE ot1.a IN (SELECT a FROM it1) AND +ot2.a IN (SELECT a FROM it2); +a a +1 1 +3 1 +DROP TABLE ot1, ot2, it1, it2; +# End of test for bug#13335319. +# +# Bug#13334882: Assertion keypart_map failed in MyIsam function +# +CREATE TABLE t1 ( +pk int NOT NULL, +col_int_nokey INT NOT NULL, +col_int_key INT NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +) ENGINE=MyISAM; +INSERT INTO t1 VALUES +(1,4,0), +(2,6,8), +(3,3,1), +(7,2,6), +(8,9,1), +(9,3,6), +(10,8,2), +(11,1,4), +(12,8,8), +(13,8,4), +(14,5,4); +CREATE TABLE t2 ( +pk int NOT NULL, +col_int_nokey int NOT NULL, +col_int_key int NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +) ENGINE=MyISAM; +INSERT INTO t2 VALUES +(10,8,7); +CREATE TABLE t3 +SELECT grandparent1.col_int_nokey AS g1 +FROM t1 AS grandparent1 +WHERE (grandparent1.col_int_nokey, grandparent1.col_int_key) IN +(SELECT parent1.col_int_key AS p1, +parent1.col_int_key AS p2 +FROM t1 AS parent1 +LEFT JOIN t2 AS parent2 +ON parent1.col_int_nokey = parent2.col_int_key +) +AND grandparent1.col_int_key <> 3 +; +explain SELECT * FROM t3 +WHERE g1 NOT IN +(SELECT grandparent1.col_int_nokey AS g1 +FROM t1 AS grandparent1 +WHERE (grandparent1.col_int_nokey, grandparent1.col_int_key) IN +(SELECT parent1.col_int_key AS p1, +parent1.col_int_key AS p2 +FROM t1 AS parent1 +LEFT JOIN t2 AS parent2 +ON parent1.col_int_nokey = parent2.col_int_key +) +AND grandparent1.col_int_key <> 3 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE grandparent1 NULL ref col_int_key col_int_key 4 const 1 100.00 Using where; Not exists +1 SIMPLE parent1 NULL ref col_int_key col_int_key 4 test.grandparent1.col_int_nokey 1 100.00 Using where +1 SIMPLE parent2 NULL ref col_int_key col_int_key 4 test.parent1.col_int_nokey 2 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select '8' AS `g1` from anti join (`test`.`t1` `grandparent1` join `test`.`t1` `parent1` left join `test`.`t2` `parent2` on((`test`.`parent2`.`col_int_key` = `test`.`parent1`.`col_int_nokey`))) on(((`test`.`grandparent1`.`col_int_nokey` = '8') and (`test`.`grandparent1`.`col_int_key` = '8') and (`test`.`parent1`.`col_int_key` = '8') and ('8' <> 3))) where true +explain format=json SELECT * FROM t3 +WHERE g1 NOT IN +(SELECT grandparent1.col_int_nokey AS g1 +FROM t1 AS grandparent1 +WHERE (grandparent1.col_int_nokey, grandparent1.col_int_key) IN +(SELECT parent1.col_int_key AS p1, +parent1.col_int_key AS p2 +FROM t1 AS parent1 +LEFT JOIN t2 AS parent2 +ON parent1.col_int_nokey = parent2.col_int_key +) +AND grandparent1.col_int_key <> 3 +); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.36" + }, + "nested_loop": [ + { + "table": { + "table_name": "t3", + "access_type": "system", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.00", + "eval_cost": "0.10", + "prefix_cost": "0.00", + "data_read_per_join": "8" + }, + "used_columns": [ + "g1" + ] + } + }, + { + "table": { + "table_name": "grandparent1", + "access_type": "ref", + "possible_keys": [ + "col_int_key" + ], + "key": "col_int_key", + "used_key_parts": [ + "col_int_key" + ], + "key_length": "4", + "ref": [ + "const" + ], + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "not_exists": true, + "cost_info": { + "read_cost": "0.28", + "eval_cost": "0.11", + "prefix_cost": "0.39", + "data_read_per_join": "17" + }, + "used_columns": [ + "col_int_nokey", + "col_int_key" + ], + "attached_condition": "(((is_not_null_compl(grandparent1..parent2), (found_match(grandparent1..parent2), false, true), true) and (is_not_null_compl(grandparent1..parent2), (('8' <> 3)), true)) and (is_not_null_compl(grandparent1..parent2), (`test`.`grandparent1`.`col_int_nokey` = '8'), true))" + } + }, + { + "table": { + "table_name": "parent1", + "access_type": "ref", + "possible_keys": [ + "col_int_key" + ], + "key": "col_int_key", + "used_key_parts": [ + "col_int_key" + ], + "key_length": "4", + "ref": [ + "test.grandparent1.col_int_nokey" + ], + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.30", + "eval_cost": "0.12", + "prefix_cost": "0.81", + "data_read_per_join": "19" + }, + "used_columns": [ + "col_int_nokey", + "col_int_key" + ], + "attached_condition": "(is_not_null_compl(grandparent1..parent2), (`test`.`parent1`.`col_int_key` = '8'), true)" + } + }, + { + "table": { + "table_name": "parent2", + "access_type": "ref", + "possible_keys": [ + "col_int_key" + ], + "key": "col_int_key", + "used_key_parts": [ + "col_int_key" + ], + "key_length": "4", + "ref": [ + "test.parent1.col_int_nokey" + ], + "rows_examined_per_scan": 2, + "rows_produced_per_join": 1, + "filtered": "100.00", + "using_index": true, + "cost_info": { + "read_cost": "0.31", + "eval_cost": "0.10", + "prefix_cost": "1.36", + "data_read_per_join": "16" + }, + "used_columns": [ + "col_int_key" + ] + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select '8' AS `g1` from anti join (`test`.`t1` `grandparent1` join `test`.`t1` `parent1` left join `test`.`t2` `parent2` on((`test`.`parent2`.`col_int_key` = `test`.`parent1`.`col_int_nokey`))) on(((`test`.`grandparent1`.`col_int_nokey` = '8') and (`test`.`grandparent1`.`col_int_key` = '8') and (`test`.`parent1`.`col_int_key` = '8') and ('8' <> 3))) where true +SELECT * FROM t3 +WHERE g1 NOT IN +(SELECT grandparent1.col_int_nokey AS g1 +FROM t1 AS grandparent1 +WHERE (grandparent1.col_int_nokey, grandparent1.col_int_key) IN +(SELECT parent1.col_int_key AS p1, +parent1.col_int_key AS p2 +FROM t1 AS parent1 +LEFT JOIN t2 AS parent2 +ON parent1.col_int_nokey = parent2.col_int_key +) +AND grandparent1.col_int_key <> 3 +); +g1 +DROP TABLE t1, t2, t3; +# End of test for bug#13334882. +# +# Bug#13339643: Assertion on JOIN::flatten_subqueries on second execution +# +CREATE TABLE t1 ( +col_int_nokey INT, +col_varchar_nokey VARCHAR(1) +) charset utf8mb4; +INSERT INTO t1 VALUES +(1,'o'), +(2,'t'); +CREATE TABLE t2 LIKE t1; +INSERT INTO t2 VALUES +(1,'o'), +(4,'f'); +CREATE VIEW v_t2 AS SELECT * FROM t2; +CREATE TABLE t3 LIKE t1; +INSERT INTO t3 VALUES +(1,'o'), +(4,'f'); +explain SELECT alias1.col_varchar_nokey +FROM t1 AS alias1 +INNER JOIN v_t2 AS alias2 +ON alias2.col_int_nokey = alias1.col_int_nokey AND +'o' IN (SELECT col_varchar_nokey +FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch +1 SIMPLE alias1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`alias1`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t1` `alias1` join `test`.`t2` semi join (`test`.`t3`) where ((`test`.`t3`.`col_varchar_nokey` = 'o') and (`test`.`t2`.`col_int_nokey` = `test`.`alias1`.`col_int_nokey`)) +SELECT alias1.col_varchar_nokey +FROM t1 AS alias1 +INNER JOIN v_t2 AS alias2 +ON alias2.col_int_nokey = alias1.col_int_nokey AND +'o' IN (SELECT col_varchar_nokey +FROM t3); +col_varchar_nokey +o +PREPARE stmt FROM "SELECT alias1.col_varchar_nokey +FROM t1 AS alias1 +INNER JOIN v_t2 AS alias2 +ON alias2.col_int_nokey = alias1.col_int_nokey AND +'o' IN (SELECT col_varchar_nokey +FROM t3)"; +EXECUTE stmt; +col_varchar_nokey +o +DROP VIEW v_t2; +DROP TABLE t1, t2, t3; +# End of test for bug#13339643. +# +# Bug#13424134: Wrong result on JOIN + nested WHERE ... IN clauses +# +CREATE TABLE t1 ( +pk int NOT NULL, +col_int_nokey int NOT NULL, +col_int_key int NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +) ENGINE=MyIsam; +INSERT INTO t1 VALUES +(10,1,7), (13,7,3), (18,0,1), (23,8,1); +CREATE TABLE t2 ( +pk int NOT NULL, +col_int_key int NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +) ENGINE=MyIsam; +INSERT INTO t2 VALUES (1,7); +EXPLAIN SELECT t1a.* +FROM t1 AS t1a +JOIN t1 AS t1b USING ( col_int_nokey ) +WHERE t1a.col_int_key IN ( +SELECT pk +FROM t2 +WHERE col_int_key IN ( +SELECT col_int_nokey +FROM t1 +) +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL system PRIMARY,col_int_key NULL NULL NULL 1 100.00 NULL +1 SIMPLE t1a NULL ref col_int_key col_int_key 4 const 1 100.00 NULL +1 SIMPLE t1b NULL ALL NULL NULL NULL NULL 4 25.00 Using where +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; FirstMatch(t1b) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1a`.`pk` AS `pk`,`test`.`t1a`.`col_int_nokey` AS `col_int_nokey`,`test`.`t1a`.`col_int_key` AS `col_int_key` from `test`.`t1` `t1a` join `test`.`t1` `t1b` semi join (`test`.`t1`) where ((`test`.`t1b`.`col_int_nokey` = `test`.`t1a`.`col_int_nokey`) and (`test`.`t1a`.`col_int_key` = '1') and (`test`.`t1`.`col_int_nokey` = '7')) +SELECT t1a.* +FROM t1 AS t1a +JOIN t1 AS t1b USING ( col_int_nokey ) +WHERE t1a.col_int_key IN ( +SELECT pk +FROM t2 +WHERE col_int_key IN ( +SELECT col_int_nokey +FROM t1 +) +); +pk col_int_nokey col_int_key +18 0 1 +23 8 1 +ALTER TABLE t1 ENGINE=Innodb; +ALTER TABLE t2 ENGINE=Innodb; +SELECT t1a.* +FROM t1 AS t1a +JOIN t1 AS t1b USING ( col_int_nokey ) +WHERE t1a.col_int_key IN ( +SELECT pk +FROM t2 +WHERE col_int_key IN ( +SELECT col_int_nokey +FROM t1 +) +); +pk col_int_nokey col_int_key +18 0 1 +23 8 1 +DROP TABLE t1, t2; +# End of test for bug#13424134. +# +# Bug#13414014: Extra rows in result on semijoin query with where ... +# +CREATE TABLE t1 ( +c INT, +d INT, +a VARCHAR(1), +b VARCHAR(1), +KEY a (a) +) charset utf8mb4; +INSERT INTO t1 VALUES +(NULL,8,'x','x'), (7,4,'q','q'), (6,8,'c','c'); +CREATE TABLE t2 ( +a VARCHAR(1), +KEY a (a) +) charset utf8mb4; +INSERT INTO t2 VALUES +('c'), (NULL), ('x'), ('q'); +explain SELECT * +FROM t2 AS ot +WHERE (a, a) IN +(SELECT a, b +FROM t1 AS it +WHERE it.a = 'x' OR it.c > it.d +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot NULL index a a 7 NULL 4 100.00 Using where; Using index +1 SIMPLE it NULL ref a a 7 test.ot.a 2 33.33 Using where; FirstMatch(ot) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot`.`a` AS `a` from `test`.`t2` `ot` semi join (`test`.`t1` `it`) where ((`test`.`it`.`a` = `test`.`ot`.`a`) and (`test`.`it`.`b` = `test`.`ot`.`a`) and ((`test`.`ot`.`a` = 'x') or (`test`.`it`.`c` > `test`.`it`.`d`))) +SELECT * +FROM t2 AS ot +WHERE (a, a) IN +(SELECT a, b +FROM t1 AS it +WHERE it.a = 'x' OR it.c > it.d +) +; +a +q +x +DROP TABLE t1, t2; +# End of test for bug#13414014. +# +# Bug#13545215: Missing rows on nested in-subquery with materialization +# +CREATE TABLE t1 ( +col_int_key int, +col_varchar_key varchar(1), +col_varchar_nokey varchar(1), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +INSERT INTO t1 VALUES +(8,'x','x'), (0,'p','p'), (8,'c','c'); +CREATE TABLE t2 ( +pk int NOT NULL, +col_varchar_key varchar(1), +col_varchar_nokey varchar(1), +PRIMARY KEY (pk), +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4; +INSERT INTO t2 VALUES +(1,'v','v'), (2,'v','v'), (3,'c','c'), (4,NULL,NULL), +(5,'x','x'), (6,'i','i'), (7,'e','e'), (8,'p','p'); +CREATE TABLE t3 ( +col_int_nokey int +); +INSERT INTO t3 VALUES (7); +explain SELECT grandparent1.col_varchar_nokey +FROM t1 AS grandparent1 JOIN t1 AS grandparent2 USING (col_int_key) +WHERE grandparent1.col_varchar_key IN ( +SELECT col_varchar_nokey +FROM t2 AS parent1 +WHERE col_varchar_key IN ( +SELECT child1.col_varchar_nokey +FROM t2 AS child1 LEFT JOIN t3 AS child2 +ON child1.pk < child2.col_int_nokey +) +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE grandparent1 NULL ALL col_int_key,col_varchar_key NULL NULL NULL 3 100.00 Using where +1 SIMPLE parent1 NULL ALL col_varchar_key NULL NULL NULL 8 12.50 Using where +1 SIMPLE child1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where +1 SIMPLE child2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(grandparent1) +1 SIMPLE grandparent2 NULL ref col_int_key col_int_key 5 test.grandparent1.col_int_key 2 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`grandparent1`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t1` `grandparent1` join `test`.`t1` `grandparent2` semi join (`test`.`t2` `parent1` join `test`.`t2` `child1` left join `test`.`t3` `child2` on((`test`.`child1`.`pk` < `test`.`child2`.`col_int_nokey`))) where ((`test`.`grandparent2`.`col_int_key` = `test`.`grandparent1`.`col_int_key`) and (`test`.`parent1`.`col_varchar_nokey` = `test`.`grandparent1`.`col_varchar_key`) and (`test`.`child1`.`col_varchar_nokey` = `test`.`parent1`.`col_varchar_key`)) +SELECT grandparent1.col_varchar_nokey +FROM t1 AS grandparent1 JOIN t1 AS grandparent2 USING (col_int_key) +WHERE grandparent1.col_varchar_key IN ( +SELECT col_varchar_nokey +FROM t2 AS parent1 +WHERE col_varchar_key IN ( +SELECT child1.col_varchar_nokey +FROM t2 AS child1 LEFT JOIN t3 AS child2 +ON child1.pk < child2.col_int_nokey +) +); +col_varchar_nokey +c +c +p +x +x +DROP TABLE t1, t2, t3; +# End of test for bug#13545215. +# +# BUG#13553211 - MISSING ROWS ON SELECT WITH IN-SUBQUERY AND +# MATERIALIZATION + SEMIJOIN ON +# +CREATE TABLE t1 ( +col_int_key int(11) DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (4,'v','v'); +INSERT INTO t1 VALUES (62,'v','v'); +INSERT INTO t1 VALUES (7,'c','c'); +INSERT INTO t1 VALUES (1,NULL,NULL); +EXPLAIN SELECT +alias1.col_varchar_nokey AS a1_nokey, +alias1.col_varchar_key AS a1_key, +alias2.col_varchar_nokey AS a2_nokey +FROM +t1 AS alias1, t1 AS alias2 +WHERE +(alias1.col_varchar_nokey,alias2.col_varchar_nokey) +IN +( +SELECT +sq2_alias2.col_varchar_nokey, sq2_alias1.col_varchar_key +FROM +t1 AS sq2_alias1, t1 AS sq2_alias2 +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE alias1 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +1 SIMPLE alias2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +1 SIMPLE sq2_alias2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where +1 SIMPLE sq2_alias1 NULL ref col_varchar_key col_varchar_key 7 test.alias2.col_varchar_nokey 2 100.00 Using index; FirstMatch(alias2) +Warnings: +Note 1003 /* select#1 */ select `test`.`alias1`.`col_varchar_nokey` AS `a1_nokey`,`test`.`alias1`.`col_varchar_key` AS `a1_key`,`test`.`alias2`.`col_varchar_nokey` AS `a2_nokey` from `test`.`t1` `alias1` join `test`.`t1` `alias2` semi join (`test`.`t1` `sq2_alias1` join `test`.`t1` `sq2_alias2`) where ((`test`.`sq2_alias1`.`col_varchar_key` = `test`.`alias2`.`col_varchar_nokey`) and (`test`.`sq2_alias2`.`col_varchar_nokey` = `test`.`alias1`.`col_varchar_nokey`)) +SELECT +alias1.col_varchar_nokey AS a1_nokey, +alias1.col_varchar_key AS a1_key, +alias2.col_varchar_nokey AS a2_nokey +FROM +t1 AS alias1, t1 AS alias2 +WHERE +(alias1.col_varchar_nokey,alias2.col_varchar_nokey) +IN +( +SELECT +sq2_alias2.col_varchar_nokey, sq2_alias1.col_varchar_key +FROM +t1 AS sq2_alias1, t1 AS sq2_alias2 +) +; +a1_nokey a1_key a2_nokey +c c c +c c v +c c v +v v c +v v c +v v v +v v v +v v v +v v v +DROP TABLE t1; +# +# Bug#13541406: Wrong result with loosescan on select .. where .. in +# +CREATE TABLE t1 ( +col_int_key INT NOT NULL, +col_varchar_nokey VARCHAR(1) NOT NULL, +KEY col_int_key (col_int_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t1 VALUES +(7,'v'), (0,'s'), (9,'l'), (3,'y'), (4,'c'), (2,'i'), (5,'h'), (3,'q'), +(1,'a'), (3,'v'), (6,'u'), (7,'s'), (5,'y'), (1,'z'), (204,'h'), (224,'p'), +(9,'e'), (5,'i'), (0,'y'), (3,'w'); +CREATE TABLE t2 ( +pk INT NOT NULL, +col_int_key INT NOT NULL, +col_varchar_key VARCHAR(1) NOT NULL, +col_varchar_nokey VARCHAR(1) NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t2 VALUES +(1,0,'j','j'), (2,8,'v','v'), (3,1,'c','c'), (4,8,'m','m'), +(5,9,'d','d'), (6,24,'d','d'), (7,6,'y','y'), (8,1,'t','t'), +(9,6,'d','d'), (10,2,'s','s'), (11,4,'r','r'), (12,8,'m','m'), +(13,4,'b','b'), (14,4,'x','x'), (15,7,'g','g'), (16,4,'p','p'), +(17,1,'q','q'), (18,9,'w','w'), (19,4,'d','d'), (20,8,'e','e'); +# This query should never use a LooseScan strategy +explain SELECT ot1.col_int_key AS field1 +FROM t2 AS ot1, t2 AS ot2 +WHERE (ot1.col_varchar_key, ot2.col_varchar_nokey) IN ( +SELECT it2.col_varchar_nokey, it1.col_varchar_key +FROM t2 AS it1 JOIN t1 AS it2 ON it2.col_int_key = it1.pk); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 20 100.00 Parallel execute (1 workers) +2 SIMPLE ot1 NULL index col_varchar_key col_varchar_key 10 NULL 20 100.00 Using index +2 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 20 100.00 NULL +2 SIMPLE it1 NULL ref PRIMARY,col_varchar_key col_varchar_key 6 test.ot2.col_varchar_nokey 1 100.00 Using index +2 SIMPLE it2 NULL ref col_int_key col_int_key 4 test.it1.pk 1 10.00 Using where; FirstMatch(ot2) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`col_int_key` AS `field1` from `test`.`t2` `ot1` join `test`.`t2` `ot2` semi join (`test`.`t2` `it1` join `test`.`t1` `it2`) where ((`test`.`it2`.`col_int_key` = `test`.`it1`.`pk`) and (`test`.`it1`.`col_varchar_key` = `test`.`ot2`.`col_varchar_nokey`) and (`test`.`it2`.`col_varchar_nokey` = `test`.`ot1`.`col_varchar_key`)) +SELECT ot1.col_int_key AS field1 +FROM t2 AS ot1, t2 AS ot2 +WHERE (ot1.col_varchar_key, ot2.col_varchar_nokey) IN ( +SELECT it2.col_varchar_nokey, it1.col_varchar_key +FROM t2 AS it1 JOIN t1 AS it2 ON it2.col_int_key = it1.pk); +field1 +1 +1 +1 +2 +6 +6 +6 +6 +6 +8 +8 +8 +8 +8 +8 +9 +DROP TABLE t1, t2; +# End of test for bug#13541406. +# +# Bug#13576391: Missing rows on select with in-subquery and +# batched-key-access=on and semijoin +# +CREATE TABLE t1 ( +col_int_nokey int NOT NULL, +col_varchar_key varchar(1) NOT NULL, +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4 engine=InnoDB; +INSERT INTO t1 VALUES +(1,'v'), (7,'s'), (4,'l'), (7,'y'), (0,'c'), (2,'i'), (9,'h'), (4,'q'), +(0,'a'), (9,'v'), (1,'u'), (3,'s'), (8,'y'), (8,'z'), (18,'h'), (84,'p'), +(6,'e'), (3,'i'), (6,'y'), (6,'w'); +CREATE TABLE t2 ( +col_int_nokey int NOT NULL, +col_varchar_nokey varchar(1) NOT NULL +) charset utf8mb4 engine=InnoDB; +INSERT INTO t2 VALUES +(4,'j'), (6,'v'), (3,'c'), (5,'m'), (3,'d'), (246,'d'), (2,'y'), (9,'t'), +(3,'d'), (8,'s'), (1,'r'), (8,'m'), (8,'b'), (5,'x'), (7,'g'), (5,'p'), +(1,'q'), (6,'w'), (2,'d'), (9,'e'); +explain SELECT col_varchar_nokey +FROM t2 AS ot +WHERE col_varchar_nokey IN ( +SELECT col_varchar_key +FROM t1 AS it +WHERE it.col_int_nokey <= it.col_int_nokey +AND NOT ot.col_int_nokey < 2 +) +ORDER BY col_varchar_nokey; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 20 33.33 Parallel execute (1 workers) +2 SIMPLE ot NULL ALL NULL NULL NULL NULL 20 33.33 Using where; Using filesort +2 SIMPLE it NULL ref col_varchar_key col_varchar_key 6 test.ot.col_varchar_nokey 1 100.00 FirstMatch(ot) +Warnings: +Note 1276 Field or reference 'test.ot.col_int_nokey' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`ot`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t2` `ot` semi join (`test`.`t1` `it`) where ((`test`.`it`.`col_varchar_key` = `test`.`ot`.`col_varchar_nokey`) and (`test`.`ot`.`col_int_nokey` >= 2)) order by `test`.`ot`.`col_varchar_nokey` +SELECT col_varchar_nokey +FROM t2 AS ot +WHERE col_varchar_nokey IN ( +SELECT col_varchar_key +FROM t1 AS it +WHERE it.col_int_nokey <= it.col_int_nokey +AND NOT ot.col_int_nokey < 2 +) +ORDER BY col_varchar_nokey; +col_varchar_nokey +c +e +p +s +v +w +y +ALTER TABLE t1 ENGINE=MyISAM; +ALTER TABLE t2 ENGINE=MyISAM; +explain SELECT col_varchar_nokey +FROM t2 AS ot +WHERE col_varchar_nokey IN ( +SELECT col_varchar_key +FROM t1 AS it +WHERE it.col_int_nokey <= it.col_int_nokey +AND NOT ot.col_int_nokey < 2 +) +ORDER BY col_varchar_nokey; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 20 33.33 Using where; Using filesort +1 SIMPLE it NULL ref col_varchar_key col_varchar_key 6 test.ot.col_varchar_nokey 2 100.00 FirstMatch(ot) +Warnings: +Note 1276 Field or reference 'test.ot.col_int_nokey' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`ot`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t2` `ot` semi join (`test`.`t1` `it`) where ((`test`.`it`.`col_varchar_key` = `test`.`ot`.`col_varchar_nokey`) and (`test`.`ot`.`col_int_nokey` >= 2)) order by `test`.`ot`.`col_varchar_nokey` +SELECT col_varchar_nokey +FROM t2 AS ot +WHERE col_varchar_nokey IN ( +SELECT col_varchar_key +FROM t1 AS it +WHERE it.col_int_nokey <= it.col_int_nokey +AND NOT ot.col_int_nokey < 2 +) +ORDER BY col_varchar_nokey; +col_varchar_nokey +c +e +p +s +v +w +y +ALTER TABLE t1 ENGINE=Memory; +ALTER TABLE t2 ENGINE=Memory; +explain SELECT col_varchar_nokey +FROM t2 AS ot +WHERE col_varchar_nokey IN ( +SELECT col_varchar_key +FROM t1 AS it +WHERE it.col_int_nokey <= it.col_int_nokey +AND NOT ot.col_int_nokey < 2 +) +ORDER BY col_varchar_nokey; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 20 33.33 Using where; Using filesort +1 SIMPLE it NULL ref col_varchar_key col_varchar_key 6 test.ot.col_varchar_nokey 2 100.00 FirstMatch(ot) +Warnings: +Note 1276 Field or reference 'test.ot.col_int_nokey' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`ot`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t2` `ot` semi join (`test`.`t1` `it`) where ((`test`.`it`.`col_varchar_key` = `test`.`ot`.`col_varchar_nokey`) and (`test`.`ot`.`col_int_nokey` >= 2)) order by `test`.`ot`.`col_varchar_nokey` +SELECT col_varchar_nokey +FROM t2 AS ot +WHERE col_varchar_nokey IN ( +SELECT col_varchar_key +FROM t1 AS it +WHERE it.col_int_nokey <= it.col_int_nokey +AND NOT ot.col_int_nokey < 2 +) +ORDER BY col_varchar_nokey; +col_varchar_nokey +c +e +p +s +v +w +y +DROP TABLE t1, t2; +# End of test for bug#13576391. +# +# Bug #13589848 "MISSING ROW ON SELECT WITH NESTED IN CLAUSES WHEN LOOSESCAN=ON" +# +CREATE TABLE t1 ( +id INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +KEY (col_varchar_key) +) charset utf8mb4; +INSERT INTO t1 VALUES (100,'m','m'), +(200,'b','b'), (300,'x','x'); +CREATE TABLE t2 ( +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +KEY (col_varchar_key) +) charset utf8mb4; +INSERT INTO t2 VALUES ('b','b'); +CREATE TABLE t3 ( +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +KEY (col_varchar_key) +) charset utf8mb4; +INSERT INTO t3 VALUES ('k','k'); +EXPLAIN SELECT gp1.id +FROM t1 AS gp1 JOIN t3 AS gp2 +ON gp2.col_varchar_key <> gp1.col_varchar_nokey +WHERE (gp1.col_varchar_nokey, gp1.col_varchar_nokey) +IN ( +SELECT col_varchar_nokey, col_varchar_nokey +FROM t1 +WHERE col_varchar_nokey +IN ( SELECT col_varchar_key +FROM t2 LEFT JOIN t3 USING (col_varchar_key) ) +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE gp2 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE gp1 NULL ALL NULL NULL NULL NULL 3 66.67 Using where +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +1 SIMPLE t2 NULL ref col_varchar_key col_varchar_key 7 test.gp1.col_varchar_nokey 2 100.00 Using index +1 SIMPLE t3 NULL ref col_varchar_key col_varchar_key 7 test.gp1.col_varchar_nokey 2 100.00 Using where; Using index; FirstMatch(gp1) +Warnings: +Note 1003 /* select#1 */ select `test`.`gp1`.`id` AS `id` from `test`.`t1` `gp1` semi join (`test`.`t1` join `test`.`t2` left join `test`.`t3` on((`test`.`t2`.`col_varchar_key` = `test`.`t3`.`col_varchar_key`))) where ((`test`.`t1`.`col_varchar_nokey` = `test`.`gp1`.`col_varchar_nokey`) and (`test`.`t2`.`col_varchar_key` = `test`.`gp1`.`col_varchar_nokey`) and ('k' <> `test`.`gp1`.`col_varchar_nokey`)) +SELECT gp1.id +FROM t1 AS gp1 JOIN t3 AS gp2 +ON gp2.col_varchar_key <> gp1.col_varchar_nokey +WHERE (gp1.col_varchar_nokey, gp1.col_varchar_nokey) +IN ( +SELECT col_varchar_nokey, col_varchar_nokey +FROM t1 +WHERE col_varchar_nokey +IN ( SELECT col_varchar_key +FROM t2 LEFT JOIN t3 USING (col_varchar_key) ) +) +; +id +200 +DROP TABLE t1,t2,t3; +# +# Bug #13596176: Missing row on select with nested in clause when +# matr=on and bnl=off + MyISAM +# +CREATE TABLE t1 ( +int_key int DEFAULT NULL, +vc_key varchar(1) DEFAULT NULL, +vc_nokey varchar(1) DEFAULT NULL, +KEY int_key (int_key), +KEY vc_key (vc_key, int_key) +) charset utf8mb4 ENGINE=MyISAM; +INSERT INTO t1 VALUES +(8,'x','x'), (7,'d','d'), (1,'r','r'), (7,'f','f'), +(9,'y','y'), (NULL,'u','u'), (1,'m','m'), (9,NULL,NULL), +(2,'o','o'), (9,'w','w'), (2,'m','m'), (4,'q','q'), +(0,NULL,NULL), (4,'d','d'), (8,'g','g'), (NULL,'x','x'), +(NULL,'f','f'), (0,'p','p'), (NULL,'j','j'), (8,'c','c'); +CREATE TABLE t2 ( +int_key int DEFAULT NULL, +vc_key varchar(1) DEFAULT NULL, +KEY int_key (int_key), +KEY vc_key (vc_key, int_key) +) charset utf8mb4 ENGINE=MyISAM; +INSERT INTO t2 VALUES (8,'g'); +explain SELECT vc_key +FROM t1 as outr +WHERE (vc_nokey, vc_key ) IN +(SELECT vc_nokey, vc_nokey +FROM t1 middle +WHERE vc_nokey IN +(SELECT child1.vc_key +FROM t2 AS child1 JOIN t1 AS child2 USING (int_key) +) +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE outr NULL ALL vc_key NULL NULL NULL 20 100.00 Using where +1 SIMPLE middle NULL ALL NULL NULL NULL NULL 20 10.00 Using where +1 SIMPLE child1 NULL ref int_key,vc_key vc_key 7 test.outr.vc_nokey 2 100.00 Using where; Using index +1 SIMPLE child2 NULL ref int_key int_key 5 test.child1.int_key 3 100.00 Using index; FirstMatch(outr) +Warnings: +Note 1003 /* select#1 */ select `test`.`outr`.`vc_key` AS `vc_key` from `test`.`t1` `outr` semi join (`test`.`t1` `middle` join `test`.`t2` `child1` join `test`.`t1` `child2`) where ((`test`.`child2`.`int_key` = `test`.`child1`.`int_key`) and (`test`.`outr`.`vc_key` = `test`.`outr`.`vc_nokey`) and (`test`.`middle`.`vc_nokey` = `test`.`outr`.`vc_nokey`) and (`test`.`child1`.`vc_key` = `test`.`outr`.`vc_nokey`)) +SELECT vc_key +FROM t1 as outr +WHERE (vc_nokey, vc_key ) IN +(SELECT vc_nokey, vc_nokey +FROM t1 middle +WHERE vc_nokey IN +(SELECT child1.vc_key +FROM t2 AS child1 JOIN t1 AS child2 USING (int_key) +) +); +vc_key +g +DROP TABLE t1, t2; +# End of test for bug#13596176. +# +# BUG#11754478: MAX/MIN + SUBQUERY + AND FAILS TO RETURN ANY ROWS +# BUG#13599013: MAX/MIN + SUBQUERY IN WHERE CLAUSE MATCHING NO +# ROWS + INDEX DOES NOT RETURN NULL +# +CREATE TABLE t1 ( +pk int(11) PRIMARY KEY, +int_key int(11), +KEY int_key (int_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (1,0),(2,0),(3,2),(4,0),(5,3),(6,0); +SELECT MIN(int_key) FROM t1 WHERE (4, 4) IN (SELECT 1, 2); +MIN(int_key) +NULL +SELECT MIN(int_key) FROM t1 WHERE (4, 4) IN (SELECT 4, 4); +MIN(int_key) +0 +SELECT MIN(pk) FROM t1 WHERE pk IN (SELECT int_key FROM t1) AND pk = 6; +MIN(pk) +NULL +DROP TABLE t1; +# BUG#13726217: Crash in Item_ident::fix_after_pullout() +CREATE TABLE t1(a INTEGER) engine=innodb; +INSERT INTO t1 VALUES (0); +SELECT 0 +FROM t1 +WHERE 0 IN +(SELECT 0 +FROM t1 +WHERE 0 LIKE +(SELECT elt(a, 0) AS b +FROM t1 +GROUP BY a +HAVING b +) +); +0 +DROP TABLE t1; +# End of test for bug#13726217. +# BUG#13773979: Missing rows on second execution of prepared statement +CREATE TABLE t1 ( +col_int_nokey INT, +col_int_key INT, +col_varchar_key VARCHAR(1) +); +INSERT INTO t1 VALUES +(1,7,'v'), (7,0,'s'), (4,9,'l'), (7,3,'y'), +(2,2,'i'), (9,5,'h'), (0,1,'a'), (9,3,'v'); +CREATE VIEW v1 AS SELECT * FROM t1; +SELECT * +FROM t1 +WHERE col_int_key IN ( +SELECT alias1.col_int_nokey AS field1 +FROM v1 AS alias1 +WHERE alias1.col_varchar_key < 'v' +); +col_int_nokey col_int_key col_varchar_key +1 7 v +2 2 i +4 9 l +7 0 s +prepare stmt FROM "SELECT * +FROM t1 +WHERE col_int_key IN ( +SELECT alias1.col_int_nokey AS field1 +FROM v1 AS alias1 +WHERE alias1.col_varchar_key < 'v' +)"; +execute stmt; +col_int_nokey col_int_key col_varchar_key +1 7 v +2 2 i +4 9 l +7 0 s +execute stmt; +col_int_nokey col_int_key col_varchar_key +1 7 v +2 2 i +4 9 l +7 0 s +DEALLOCATE PREPARE stmt; +DROP VIEW v1; +DROP TABLE t1; +# End of test for bug#13773979. +# +# BUG#13685026 ASSERTION CUR_SJ_INNER_TABLES == 0 IN +# --OPTIMIZE_TABLE_ORDER::CHOOSE_TABLE_ORDER +# +CREATE TABLE t1 ( +col_int_key INT(11) NOT NULL, +col_datetime_key DATETIME NOT NULL, +col_varchar_key VARCHAR(1) NOT NULL, +col_varchar_nokey VARCHAR(1) NOT NULL, +KEY col_int_key (col_int_key), +KEY col_datetime_key (col_datetime_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (0,'2002-02-13 17:30:06','j','j'); +INSERT INTO t1 VALUES (8,'2008-09-27 00:34:58','v','v'); +CREATE TABLE t2 ( +col_int_key INT(11) NOT NULL, +col_datetime_key DATETIME NOT NULL, +col_varchar_key VARCHAR(1) NOT NULL, +col_varchar_nokey VARCHAR(1) NOT NULL, +KEY col_int_key (col_int_key), +KEY col_datetime_key (col_datetime_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (7,'2003-08-21 00:00:00','b','b'); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +SET @old_depth=@@optimizer_search_depth; +SET optimizer_search_depth=4; +EXPLAIN SELECT col_datetime_key +FROM t1 as outr +WHERE col_datetime_key IN ( +SELECT alias1.col_datetime_key +FROM t1 AS alias1 +LEFT JOIN t1 as alias3 +STRAIGHT_JOIN ( t2 AS alias4 +JOIN t1 AS alias5 +ON alias5.col_varchar_key <= alias4.col_varchar_nokey ) +ON alias5.col_int_key < alias4.col_int_key +ON alias5.col_varchar_key = alias4.col_varchar_key +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE outr NULL index col_datetime_key col_datetime_key 5 NULL 2 100.00 Using index +1 SIMPLE alias1 NULL ref col_datetime_key col_datetime_key 5 test.outr.col_datetime_key 1 100.00 Using index +1 SIMPLE alias4 NULL ALL col_int_key,col_varchar_key NULL NULL NULL 1 100.00 NULL +1 SIMPLE alias5 NULL ref col_int_key,col_varchar_key col_varchar_key 6 test.alias4.col_varchar_key 1 100.00 Using where; Using index +1 SIMPLE alias3 NULL index NULL col_int_key 4 NULL 2 100.00 Using index; FirstMatch(outr) +Warnings: +Note 1003 /* select#1 */ select `test`.`outr`.`col_datetime_key` AS `col_datetime_key` from `test`.`t1` `outr` semi join (`test`.`t1` `alias1` left join (`test`.`t1` `alias3` join `test`.`t2` `alias4` join `test`.`t1` `alias5`) on(((`test`.`alias5`.`col_varchar_key` = `test`.`alias4`.`col_varchar_key`) and (`test`.`alias5`.`col_int_key` < `test`.`alias4`.`col_int_key`) and (`test`.`alias5`.`col_varchar_key` <= `test`.`alias4`.`col_varchar_nokey`)))) where (`test`.`alias1`.`col_datetime_key` = `test`.`outr`.`col_datetime_key`) +SELECT col_datetime_key +FROM t1 as outr +WHERE col_datetime_key IN ( +SELECT alias1.col_datetime_key +FROM t1 AS alias1 +LEFT JOIN t1 as alias3 +STRAIGHT_JOIN ( t2 AS alias4 +JOIN t1 AS alias5 +ON alias5.col_varchar_key <= alias4.col_varchar_nokey ) +ON alias5.col_int_key < alias4.col_int_key +ON alias5.col_varchar_key = alias4.col_varchar_key +); +col_datetime_key +2002-02-13 17:30:06 +2008-09-27 00:34:58 +DROP TABLE t1,t2; +SET @@optimizer_search_depth=@old_depth; +# +# BUG#13848789: SEGFAULT IN JOIN_READ_NEXT_SAME AT +# SQL/SQL_EXECUTOR.CC ON HAVING...IN...JOIN +# +CREATE TABLE t1 ( +col_int_key INT, +col_varchar_key VARCHAR(1), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4; +INSERT INTO t1 VALUES (8,'x'); +CREATE TABLE t2 ( +col_varchar_key VARCHAR(1), +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4; +INSERT INTO t2 VALUES ('x'), ('y'); +explain SELECT MIN(col_int_key) +FROM t1 as t1_outer +HAVING (1, 2) IN ( +SELECT t1_inner.col_int_key, MAX(t1_inner.col_int_key) +FROM t1 as t1_inner JOIN t2 +ON t2.col_varchar_key = t1_inner.col_varchar_key +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible HAVING +2 SUBQUERY t1_inner NULL system col_varchar_key NULL NULL NULL 1 100.00 NULL +2 SUBQUERY t2 NULL ref col_varchar_key col_varchar_key 7 const 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select min(`test`.`t1_outer`.`col_int_key`) AS `MIN(col_int_key)` from `test`.`t1` `t1_outer` having false +SELECT MIN(col_int_key) +FROM t1 as t1_outer +HAVING (1, 2) IN ( +SELECT t1_inner.col_int_key, MAX(t1_inner.col_int_key) +FROM t1 as t1_inner JOIN t2 +ON t2.col_varchar_key = t1_inner.col_varchar_key +); +MIN(col_int_key) +DROP TABLE t1,t2; +# Bug#13838810: Segfault in evaluate_null_complemented_join_record +CREATE TABLE t1 ( +pk int NOT NULL, +col_int_nokey int DEFAULT NULL, +col_int_key int DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t1 VALUES (10,NULL,8,'x'); +CREATE TABLE t2 ( +pk int NOT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +PRIMARY KEY (pk) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t2 VALUES (1,'x'); +CREATE TABLE t3 ( +pk int NOT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +PRIMARY KEY (pk), +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t3 VALUES +(1,'v','v'), (2,'v','v'), (3,'c','c'), (4,NULL,NULL); +EXPLAIN SELECT table1.pk,table2.pk, table3.pk +FROM t2 AS table1 +LEFT JOIN t1 AS table2 +LEFT JOIN t1 AS table3 +ON table3.col_int_key = table2.col_int_key +ON table3.pk = table2.col_int_nokey AND +table1.col_varchar_nokey IN ( +SELECT subquery3_t1.col_varchar_nokey +FROM t3 AS subquery3_t1 +LEFT JOIN t1 AS subquery3_t2 +ON subquery3_t2.col_varchar_key = subquery3_t1.col_varchar_key +WHERE subquery3_t2.col_int_nokey <> 9 +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE table1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE table2 NULL ALL col_int_key NULL NULL NULL 1 100.00 NULL +2 SIMPLE table3 NULL eq_ref PRIMARY,col_int_key PRIMARY 4 test.table2.col_int_nokey 1 100.00 Using where +2 SIMPLE subquery3_t2 NULL ALL col_varchar_key NULL NULL NULL 1 100.00 Using where +2 SIMPLE subquery3_t1 NULL ref col_varchar_key col_varchar_key 7 test.subquery3_t2.col_varchar_key 1 100.00 Using where; FirstMatch(table3) +Warnings: +Note 1003 /* select#1 */ select `test`.`table1`.`pk` AS `pk`,`test`.`table2`.`pk` AS `pk`,`test`.`table3`.`pk` AS `pk` from `test`.`t2` `table1` left join (`test`.`t1` `table2` join `test`.`t1` `table3` semi join (`test`.`t3` `subquery3_t1` join `test`.`t1` `subquery3_t2`)) on(((`test`.`table3`.`col_int_key` = `test`.`table2`.`col_int_key`) and (`test`.`subquery3_t1`.`col_varchar_key` = `test`.`subquery3_t2`.`col_varchar_key`) and (`test`.`subquery3_t1`.`col_varchar_nokey` = `test`.`table1`.`col_varchar_nokey`) and (`test`.`table3`.`pk` = `test`.`table2`.`col_int_nokey`) and (`test`.`subquery3_t2`.`col_int_nokey` <> 9))) where true +SELECT table1.pk,table2.pk, table3.pk +FROM t2 AS table1 +LEFT JOIN t1 AS table2 +LEFT JOIN t1 AS table3 +ON table3.col_int_key = table2.col_int_key +ON table3.pk = table2.col_int_nokey AND +table1.col_varchar_nokey IN ( +SELECT subquery3_t1.col_varchar_nokey +FROM t3 AS subquery3_t1 +LEFT JOIN t1 AS subquery3_t2 +ON subquery3_t2.col_varchar_key = subquery3_t1.col_varchar_key +WHERE subquery3_t2.col_int_nokey <> 9 +) +; +pk pk pk +1 NULL NULL +DROP TABLE t1, t2, t3; +Extra test case for specific code coverage +CREATE TABLE t1(pk INTEGER); +INSERT INTO t1 VALUES(1), (2); +explain SELECT * +FROM t1 AS ot1 LEFT JOIN t1 AS ot2 +ON ot1.pk=ot2.pk AND +ot2.pk IN +(SELECT it1.pk +FROM t1 AS it1 LEFT JOIN t1 AS it2 ON it1.pk=it2.pk); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE it1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE it2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch(ot2) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`pk` AS `pk`,`test`.`ot2`.`pk` AS `pk` from `test`.`t1` `ot1` left join (`test`.`t1` `ot2` semi join (`test`.`t1` `it1` left join `test`.`t1` `it2` on((`test`.`it1`.`pk` = `test`.`it2`.`pk`)))) on(((`test`.`ot2`.`pk` = `test`.`ot1`.`pk`) and (`test`.`it1`.`pk` = `test`.`ot1`.`pk`))) where true +SELECT * +FROM t1 AS ot1 LEFT JOIN t1 AS ot2 +ON ot1.pk=ot2.pk AND +ot2.pk IN +(SELECT it1.pk +FROM t1 AS it1 LEFT JOIN t1 AS it2 ON it1.pk=it2.pk); +pk pk +1 1 +2 2 +DROP TABLE t1; +# End of test for bug#13838810. +# +# Bug#13845930: Segfault in st_join_table::and_with_condition +# +CREATE TABLE t1 ( +col_int INTEGER +); +CREATE TABLE t2 ( +col_varchar_1 VARCHAR(1), +col_varchar_2 VARCHAR(1) +); +INSERT INTO t2 VALUES ('x','x'), ('c','c'); +PREPARE stmt FROM ' +SELECT alias2.col_varchar_2 AS field1 +FROM t2 AS alias1 + JOIN + (t2 AS alias2 + LEFT JOIN t2 AS alias3 + ON (8, 92) IN + (SELECT sq1_alias1.col_int, + sq1_alias2.col_int + FROM t1 AS sq1_alias1 JOIN t1 AS sq1_alias2 + ) + ) + ON alias3.col_varchar_1 = alias2.col_varchar_2 +'; +EXECUTE stmt; +field1 + +EXECUTE stmt; +field1 +DEALLOCATE prepare stmt; +DROP TABLE t1, t2; +# End of test for bug#13845930. +# +# Bug#13855925: Assert 'prebuilt->search_tuple->n_fields > 0' +# in ha_innobase::index_read +# +CREATE TABLE t1 ( +pk INTEGER AUTO_INCREMENT, +col_int_nokey INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk), +KEY (col_varchar_key) +) charset utf8mb4 ENGINE=INNODB; +INSERT INTO t1 ( +col_int_key, col_int_nokey, +col_varchar_key, col_varchar_nokey +) VALUES +(4, 2, 'v','v'), (62, 150, 'v','v'), (7, NULL, 'c','c'), (1, 2, NULL, NULL), +(0, 5, 'x','x'), (7, 3, 'i','i'), (7, 1, 'e','e'), (1, 4, 'p','p'), +(7, NULL, 's','s'), (1, 2, 'j','j'), (5, 6, 'z','z'), (2, 6, 'c','c'), +(0, 8, 'a','a'), (1, 2, 'q','q'), (8, 6, 'y','y'), (1, 8, NULL, NULL), +(1, 3, 'r','r'), (9, 3, 'v','v'), (1, 9, NULL, NULL), (5, 6, 'r','r'); +CREATE TABLE t2 ( +pk INT AUTO_INCREMENT, +col_int_nokey INT, +col_int_key INT, +PRIMARY KEY (pk), +KEY (col_int_key) +) charset utf8mb4 AUTO_INCREMENT=10 ENGINE=INNODB; +INSERT INTO t2 (col_int_key, col_int_nokey) VALUES +(8, NULL), (7, 8), (1, 1), (7, 9), (9, 4), (NULL, 3), (1, 2), (9, NULL), +(2, 2), (9, NULL), (2, 6), (4, 7), (0, 2), (4, 5), (8, 7), (NULL, 6), +(NULL, 6), (0, 2), (NULL, 9), (8, 6); +CREATE TABLE t3 ( +pk INT AUTO_INCREMENT, +col_varchar_key VARCHAR(1), +PRIMARY KEY (pk), +KEY (col_varchar_key) +) charset utf8mb4 ENGINE=INNODB; +INSERT INTO t3 (col_varchar_key) VALUES +('c'), ('c'), ('q'), ('g'), ('e'), ('l'), (NULL), ('c'), ('h'), ('d'), +('c'), ('i'), ('t'), ('g'), ('q'), ('l'), ('n'), ('z'), ('n'), ('r'), ('p'); +CREATE VIEW v1 AS +SELECT table2.col_varchar_nokey AS field1 +FROM t2 AS table1 +INNER JOIN (t1 AS table2 +STRAIGHT_JOIN t2 AS table3 +ON table3.col_int_key = table2.pk AND +table3.col_int_nokey = ANY +(SELECT subquery1_t2.col_int_nokey AS subquery1_field1 +FROM t2 AS subquery1_t1 +RIGHT OUTER JOIN t1 AS subquery1_t2 +INNER JOIN t1 AS subquery1_t3 +ON subquery1_t3.col_int_key = subquery1_t2.pk +ON subquery1_t3.col_varchar_key=subquery1_t2.col_varchar_nokey +WHERE subquery1_t1.pk > 1 +) +) +ON table3.col_int_key IN +(SELECT subquery2_t1.col_int_key AS subquery2_field1 +FROM t2 AS subquery2_t1 +RIGHT OUTER JOIN t3 AS subquery2_t2 +LEFT OUTER JOIN t1 AS subquery2_t3 +ON subquery2_t3.col_varchar_key = subquery2_t2.col_varchar_key +ON subquery2_t3.pk = subquery2_t2.pk +) +; +explain SELECT * FROM v1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE table1 NULL index NULL col_int_key 5 NULL 20 100.00 Using index +1 SIMPLE table2 NULL ALL PRIMARY NULL NULL NULL 20 100.00 NULL +1 SIMPLE table3 NULL ref col_int_key col_int_key 5 test.table2.pk 2 100.00 NULL +1 SIMPLE subquery1_t2 NULL ALL PRIMARY NULL NULL NULL 20 10.00 Using where +1 SIMPLE subquery1_t3 NULL ref col_varchar_key col_varchar_key 7 test.subquery1_t2.col_varchar_nokey 1 10.00 Using where +1 SIMPLE subquery1_t1 NULL index PRIMARY col_int_key 5 NULL 20 100.00 Using where; Using index; FirstMatch(table3) +1 SIMPLE subquery2_t3 NULL index PRIMARY,col_varchar_key col_varchar_key 7 NULL 20 100.00 Using where; Using index +1 SIMPLE subquery2_t2 NULL eq_ref PRIMARY,col_varchar_key PRIMARY 4 test.subquery2_t3.pk 1 7.14 Using where +1 SIMPLE subquery2_t1 NULL ref col_int_key col_int_key 5 test.table2.pk 2 100.00 Using index; FirstMatch(subquery1_t1) +Warnings: +Note 1003 /* select#1 */ select `table2`.`col_varchar_nokey` AS `field1` from `test`.`t2` `table1` join `test`.`t1` `table2` straight_join `test`.`t2` `table3` semi join (`test`.`t1` `subquery1_t2` join `test`.`t1` `subquery1_t3` join `test`.`t2` `subquery1_t1`) semi join (`test`.`t3` `subquery2_t2` join `test`.`t1` `subquery2_t3` join `test`.`t2` `subquery2_t1`) where ((`subquery1_t3`.`col_int_key` = `subquery1_t2`.`pk`) and (`subquery1_t3`.`col_varchar_key` = `subquery1_t2`.`col_varchar_nokey`) and (`subquery2_t2`.`col_varchar_key` = `subquery2_t3`.`col_varchar_key`) and (`subquery2_t2`.`pk` = `subquery2_t3`.`pk`) and (`table3`.`col_int_key` = `table2`.`pk`) and (`subquery2_t1`.`col_int_key` = `table2`.`pk`) and (`subquery1_t2`.`col_int_nokey` = `table3`.`col_int_nokey`) and (`subquery1_t1`.`pk` > 1)) +SELECT * FROM v1; +field1 +v +v +v +v +v +v +v +v +v +v +v +v +v +v +v +v +v +v +v +v +DROP VIEW v1; +DROP TABLE t1,t2,t3; +# End of test for bug#13855925. +# +# Bug#13897959: Segfault in setup_semijoin_dups_elimination() +# +CREATE TABLE t1 ( +col_datetime_key DATETIME DEFAULT NULL, +KEY col_datetime_key (col_datetime_key) +) ENGINE=MyISAM; +INSERT INTO t1 VALUES +('2001-04-18 00:00:00'), ('2008-12-18 19:39:55'), +('2000-08-01 12:19:39'), ('2004-09-25 21:29:06'), +('2009-09-20 09:11:48'), ('2004-03-27 09:32:04'); +CREATE TABLE t2 ( +col_date_nokey date DEFAULT NULL, +col_time_key time DEFAULT NULL, +col_datetime_key datetime DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +KEY col_time_key (col_time_key), +KEY col_datetime_key (col_datetime_key), +KEY col_varchar_key(col_varchar_key) +) ENGINE=MyISAM; +INSERT INTO t2 VALUES ('1900-01-01',NULL,'2001-11-04 19:07:55','x','x'); +SELECT grandparent1.col_varchar_nokey +FROM t2 AS grandparent1 LEFT JOIN t1 USING (col_datetime_key) +WHERE grandparent1.col_varchar_nokey IN ( +SELECT col_varchar_nokey +FROM t2 AS parent1 +WHERE parent1.col_time_key > grandparent1.col_date_nokey +); +col_varchar_nokey +DROP TABLE t1, t2; +# End of test for bug#13897959. +# +# Bug#13898625 ASSERT `(REMAINING_TABLES_AFTER != 0) ...' IN +# BEST_EXTENSION_BY_LIMITED_SEARCH +# +CREATE TABLE t1 ( +pk int(11) NOT NULL, +col_int_nokey INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (26,6,NULL,'f','f'); +INSERT INTO t1 VALUES (29,6,8,'c','c'); +CREATE TABLE t2 ( +pk INT NOT NULL, +col_int_nokey INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +INSERT INTO t2 VALUES (1,2,4,'v','v'); +INSERT INTO t2 VALUES (2,150,62,'v','v'); +INSERT INTO t2 VALUES (5,5,0,'x','x'); +INSERT INTO t2 VALUES (6,3,7,'i','i'); +INSERT INTO t2 VALUES (7,1,7,'e','e'); +CREATE VIEW view_c AS SELECT * FROM t2; +PREPARE prep_stmt_7430 FROM 'SELECT SUM( alias1.col_varchar_key ) AS field1 +FROM t1 AS alias1 +RIGHT JOIN t2 AS alias2 +INNER JOIN t1 AS alias3 +ON (alias3.col_varchar_key = alias2.col_varchar_key ) +ON ( "v" ) IN ( +SELECT sq1_alias1.col_varchar_nokey AS sq1_field1 +FROM t1 AS sq1_alias1 +) +WHERE alias3.pk IN ( +SELECT sq2_alias1.col_int_key AS sq2_field1 +FROM ( view_c AS sq2_alias1, t1 AS sq2_alias2 ) +) +'; +EXECUTE prep_stmt_7430; +field1 +NULL +EXECUTE prep_stmt_7430; +field1 +NULL +EXPLAIN SELECT SUM( alias1.col_varchar_key ) AS field1 +FROM t1 AS alias1 +RIGHT JOIN t2 AS alias2 +INNER JOIN t1 AS alias3 +ON (alias3.col_varchar_key = alias2.col_varchar_key ) +ON ( "v" ) IN ( +SELECT sq1_alias1.col_varchar_nokey AS sq1_field1 +FROM t1 AS sq1_alias1 +) +WHERE alias3.pk IN ( +SELECT sq2_alias1.col_int_key AS sq2_field1 +FROM ( view_c AS sq2_alias1, t1 AS sq2_alias2 ) +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE alias3 NULL ALL PRIMARY,col_varchar_key NULL NULL NULL 2 100.00 Using where +1 SIMPLE sq2_alias2 NULL index NULL PRIMARY 4 NULL 2 100.00 Using index +1 SIMPLE t2 NULL ref col_int_key col_int_key 5 test.alias3.pk 2 100.00 Using index; FirstMatch(alias3) +1 SIMPLE alias2 NULL ref col_varchar_key col_varchar_key 7 test.alias3.col_varchar_key 2 100.00 Using index +1 SIMPLE alias1 NULL index NULL col_varchar_key 12 NULL 2 100.00 Using index +1 SIMPLE sq1_alias1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch(alias1) +Warnings: +Note 1003 /* select#1 */ select sum(`test`.`alias1`.`col_varchar_key`) AS `field1` from `test`.`t2` `alias2` join `test`.`t1` `alias3` left join (`test`.`t1` `alias1` semi join (`test`.`t1` `sq1_alias1`)) on(((`test`.`sq1_alias1`.`col_varchar_nokey` = 'v'))) semi join (`test`.`t2` join `test`.`t1` `sq2_alias2`) where ((`test`.`alias2`.`col_varchar_key` = `test`.`alias3`.`col_varchar_key`) and (`test`.`t2`.`col_int_key` = `test`.`alias3`.`pk`)) +PREPARE prep_stmt_7430 FROM 'SELECT SUM( alias1.col_varchar_key ) AS field1 +FROM t1 AS alias1 +RIGHT JOIN t2 AS alias2 +INNER JOIN t1 AS alias3 +ON (alias3.col_varchar_key = alias2.col_varchar_key ) +ON ( "v" ) IN ( +SELECT sq1_alias1.col_varchar_nokey AS sq1_field1 +FROM t1 AS sq1_alias1 +) +WHERE alias3.pk IN ( +SELECT sq2_alias1.col_int_key AS sq2_field1 +FROM ( view_c AS sq2_alias1 , t1 AS sq2_alias2 ) +WHERE sq2_alias1.col_varchar_nokey <> alias2.col_varchar_key +AND sq2_alias1.col_varchar_key < "l" + ) +'; +EXECUTE prep_stmt_7430; +field1 +NULL +EXECUTE prep_stmt_7430; +field1 +NULL +EXPLAIN SELECT SUM( alias1.col_varchar_key ) AS field1 +FROM t1 AS alias1 +RIGHT JOIN t2 AS alias2 +INNER JOIN t1 AS alias3 +ON (alias3.col_varchar_key = alias2.col_varchar_key ) +ON ( "v" ) IN ( +SELECT sq1_alias1.col_varchar_nokey AS sq1_field1 +FROM t1 AS sq1_alias1 +) +WHERE alias3.pk IN ( +SELECT sq2_alias1.col_int_key AS sq2_field1 +FROM ( view_c AS sq2_alias1 , t1 AS sq2_alias2 ) +WHERE sq2_alias1.col_varchar_nokey <> alias2.col_varchar_key +AND sq2_alias1.col_varchar_key < "l" + ) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE alias3 NULL ALL PRIMARY,col_varchar_key NULL NULL NULL 2 100.00 Using where +1 SIMPLE alias2 NULL ref col_varchar_key col_varchar_key 7 test.alias3.col_varchar_key 2 100.00 Using index +1 SIMPLE t2 NULL ref col_int_key,col_varchar_key col_int_key 5 test.alias3.pk 2 32.00 Using where +1 SIMPLE sq2_alias2 NULL index NULL PRIMARY 4 NULL 2 100.00 Using index; FirstMatch(alias2) +1 SIMPLE alias1 NULL index NULL col_varchar_key 12 NULL 2 100.00 Using index +1 SIMPLE sq1_alias1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch(alias1) +Warnings: +Note 1276 Field or reference 'test.alias2.col_varchar_key' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select sum(`test`.`alias1`.`col_varchar_key`) AS `field1` from `test`.`t2` `alias2` join `test`.`t1` `alias3` left join (`test`.`t1` `alias1` semi join (`test`.`t1` `sq1_alias1`)) on(((`test`.`sq1_alias1`.`col_varchar_nokey` = 'v'))) semi join (`test`.`t2` join `test`.`t1` `sq2_alias2`) where ((`test`.`alias2`.`col_varchar_key` = `test`.`alias3`.`col_varchar_key`) and (`test`.`t2`.`col_int_key` = `test`.`alias3`.`pk`) and (`test`.`t2`.`col_varchar_nokey` <> `test`.`alias3`.`col_varchar_key`) and (`test`.`t2`.`col_varchar_key` < 'l')) +DROP TABLE t1,t2; +DROP VIEW view_c; +# +# Bug#13902463 SEGFAULT IN BITMAP<64U>::MERGE OR ADD_KEY_FIELD +# ON SECOND EXEC OF PREP STMT +# +CREATE TABLE t1 ( +pk INT, +col_int_nokey INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +KEY col_varchar_key (col_varchar_key) +); +CREATE VIEW view_b AS SELECT * FROM t1; +PREPARE prep_stmt_20421 FROM 'SELECT alias2.col_varchar_nokey AS field1 +FROM t1 AS alias1 +INNER JOIN t1 AS alias2 +ON (alias1.col_varchar_key = alias2.col_varchar_nokey +AND ( alias1.col_int_key ) IN ( +SELECT t1.col_int_nokey +FROM t1 +) +) +WHERE alias1.col_varchar_key IN ( +SELECT sq2_alias2.col_varchar_nokey AS sq2_field1 +FROM view_b AS sq2_alias1 +INNER JOIN t1 AS sq2_alias2 +ON (sq2_alias2.col_varchar_key = sq2_alias1.col_varchar_key ) +WHERE sq2_alias1.pk > alias2.pk +) +'; +EXECUTE prep_stmt_20421; +field1 +EXECUTE prep_stmt_20421; +field1 +EXPLAIN SELECT alias2.col_varchar_nokey AS field1 +FROM t1 AS alias1 +INNER JOIN t1 AS alias2 +ON (alias1.col_varchar_key = alias2.col_varchar_nokey +AND ( alias1.col_int_key ) IN ( +SELECT t1.col_int_nokey +FROM t1 +) +) +WHERE alias1.col_varchar_key IN ( +SELECT sq2_alias2.col_varchar_nokey AS sq2_field1 +FROM view_b AS sq2_alias1 +INNER JOIN t1 AS sq2_alias2 +ON (sq2_alias2.col_varchar_key = sq2_alias1.col_varchar_key ) +WHERE sq2_alias1.pk > alias2.pk +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.alias2.pk' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `field1` from `test`.`t1` `alias1` join `test`.`t1` `alias2` semi join (`test`.`t1`) semi join (`test`.`t1` join `test`.`t1` `sq2_alias2`) where ((`test`.`t1`.`pk` > NULL) and multiple equal(NULL, `test`.`sq2_alias2`.`col_varchar_nokey`, NULL) and multiple equal(`test`.`sq2_alias2`.`col_varchar_key`, `test`.`t1`.`col_varchar_key`) and multiple equal(NULL, `test`.`t1`.`col_int_nokey`)) +ALTER TABLE t1 DROP INDEX col_varchar_key; +PREPARE prep_stmt_20421 FROM 'SELECT alias2.col_varchar_nokey AS field1 +FROM t1 AS alias1 +INNER JOIN t1 AS alias2 +ON (alias1.col_varchar_key = alias2.col_varchar_nokey +AND ( alias1.col_int_key ) IN ( +SELECT t1.col_int_nokey +FROM t1 +) +) +WHERE alias1.col_varchar_key IN ( +SELECT sq2_alias2.col_varchar_nokey AS sq2_field1 +FROM view_b AS sq2_alias1 +INNER JOIN t1 AS sq2_alias2 +ON (sq2_alias2.col_varchar_key = sq2_alias1.col_varchar_key ) +WHERE sq2_alias1.pk > alias2.pk +) +'; +EXECUTE prep_stmt_20421; +field1 +EXECUTE prep_stmt_20421; +field1 +EXPLAIN SELECT alias2.col_varchar_nokey AS field1 +FROM t1 AS alias1 +INNER JOIN t1 AS alias2 +ON (alias1.col_varchar_key = alias2.col_varchar_nokey +AND ( alias1.col_int_key ) IN ( +SELECT t1.col_int_nokey +FROM t1 +) +) +WHERE alias1.col_varchar_key IN ( +SELECT sq2_alias2.col_varchar_nokey AS sq2_field1 +FROM view_b AS sq2_alias1 +INNER JOIN t1 AS sq2_alias2 +ON (sq2_alias2.col_varchar_key = sq2_alias1.col_varchar_key ) +WHERE sq2_alias1.pk > alias2.pk +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.alias2.pk' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `field1` from `test`.`t1` `alias1` join `test`.`t1` `alias2` semi join (`test`.`t1`) semi join (`test`.`t1` join `test`.`t1` `sq2_alias2`) where ((`test`.`t1`.`pk` > NULL) and multiple equal(NULL, `test`.`sq2_alias2`.`col_varchar_nokey`, NULL) and multiple equal(`test`.`sq2_alias2`.`col_varchar_key`, `test`.`t1`.`col_varchar_key`) and multiple equal(NULL, `test`.`t1`.`col_int_nokey`)) +DROP TABLE t1; +DROP VIEW view_b; +# +# Bug#13907277: Segfault in evaluate_null_complemented_join_record +# +CREATE TABLE t1 ( +pk INTEGER, +col_varchar_nokey VARCHAR(1), +col_varchar_key VARCHAR(1), +PRIMARY KEY (pk) +); +INSERT INTO t1 VALUES (1, 'x', 'x'); +CREATE TABLE t2 ( +pk INTEGER, +PRIMARY KEY (pk) +); +INSERT INTO t2 VALUES (1); +CREATE TABLE t3 ( +pk INTEGER, +col_int_nokey INTEGER, +col_int_key INTEGER, +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk) +); +INSERT INTO t3 VALUES (1, 6, 5, 'r'); +explain SELECT outer_t1.pk, outer_t2.pk +FROM t3 AS outer_t1 +RIGHT JOIN t2 AS outer_t2 +ON outer_t1.col_int_nokey IN +(SELECT inner_t1.col_int_nokey +FROM t3 AS inner_t1 +LEFT JOIN t1 AS inner_t2 +INNER JOIN t1 AS inner_t3 +ON inner_t3.pk = inner_t2.pk +ON inner_t3.col_varchar_nokey = inner_t2.col_varchar_key +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE outer_t2 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE outer_t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE inner_t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE inner_t2 NULL ALL PRIMARY NULL NULL NULL 1 100.00 NULL +1 SIMPLE inner_t3 NULL eq_ref PRIMARY PRIMARY 4 test.inner_t2.pk 1 100.00 Using where; FirstMatch(outer_t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`outer_t1`.`pk` AS `pk`,'1' AS `pk` from left join (`test`.`t3` `outer_t1` semi join (`test`.`t3` `inner_t1` left join (`test`.`t1` `inner_t2` join `test`.`t1` `inner_t3`) on(((`test`.`inner_t3`.`col_varchar_nokey` = `test`.`inner_t2`.`col_varchar_key`) and (`test`.`inner_t3`.`pk` = `test`.`inner_t2`.`pk`))))) on(((`test`.`inner_t1`.`col_int_nokey` = `test`.`outer_t1`.`col_int_nokey`))) where true +SELECT outer_t1.pk, outer_t2.pk +FROM t3 AS outer_t1 +RIGHT JOIN t2 AS outer_t2 +ON outer_t1.col_int_nokey IN +(SELECT inner_t1.col_int_nokey +FROM t3 AS inner_t1 +LEFT JOIN t1 AS inner_t2 +INNER JOIN t1 AS inner_t3 +ON inner_t3.pk = inner_t2.pk +ON inner_t3.col_varchar_nokey = inner_t2.col_varchar_key +); +pk pk +1 1 +DROP TABLE t1, t2, t3; +# End of test for bug#13907277. +# +# Bug#13955713: Assert 'JOIN->best_read < ...' on second execution +# +CREATE TABLE t1 ( +pk INTEGER, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1) +); +PREPARE stmt FROM " +SELECT MIN(alias2.col_varchar_key) AS field1 +FROM t1 AS alias1 + INNER JOIN (t1 AS alias2 + INNER JOIN t1 AS alias3 + ON 8 IN + (SELECT sq1_alias1.pk AS sq1_field2 + FROM t1 AS sq1_alias1 + WHERE 9 IN + (SELECT SUM(t1_sq1_alias1.pk) AS t1_sq1_field2 + FROM t1 AS t1_sq1_alias1 + ) + ) + ) + ON alias3.col_varchar_nokey = alias2.col_varchar_key +WHERE EXISTS + (SELECT sq2_alias1.pk AS sq2_field1 + FROM t1 AS sq2_alias1 + WHERE sq2_alias1.col_varchar_key < alias1.col_varchar_nokey + ) +"; +EXECUTE stmt; +field1 +NULL + +EXECUTE stmt; +field1 +NULL +DEALLOCATE PREPARE stmt; +DROP TABLE t1; +# End of test for bug#13955713. +# +# Bug#13956813: Segfault in memcpy from Join_cache::write_record_data() +# +CREATE TABLE t1 ( +pk INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1) +) charset latin1; +CREATE TABLE t2 ( +pk INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1) +) charset latin1; +INSERT INTO t2 VALUES +(10,'j','j'), (11,'z','z'), (12,'c','c'), (13,'a','a'), +(14,'q','q'), (15,'y','y'), (16,NULL,NULL), (17,'r','r'), +(18,'v','v'), (19,NULL,NULL), (20,'r','r'); +CREATE TABLE t3 ( +pk INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +KEY col_int_key (col_int_key) +) charset latin1; +INSERT INTO t3 VALUES +(15,NULL,'u'), (16,1,'m'), (17,9,NULL), (18,2,'o'), +(19,9,'w'), (20,2,'m'), (21,4,'q'), (22,0,NULL), +(23,4,'d'), (24,8,'g'), (25,NULL,'x'), (26,NULL,'f'), +(27,0,'p'), (28,NULL,'j'), (29,8,'c'); +CREATE VIEW view_inline_0 AS +SELECT t1.* +FROM t1 INNER JOIN t3 +ON t1.pk = t3.pk; +CREATE VIEW view_inline_1 AS +SELECT sq2_alias2.col_varchar_key AS sq2_field1, +sq2_alias1.col_varchar_key AS sq2_field2 +FROM t3 AS sq2_alias1 LEFT OUTER JOIN t3 AS sq2_alias2 +ON sq2_alias1.pk = sq2_alias2.col_int_key; +CREATE VIEW view_inline_2 AS +SELECT 'p', 'p' UNION SELECT 'k', 's'; +SET @optimizer_switch_saved= @@optimizer_switch; +SET @@optimizer_switch="derived_merge=off"; +explain SELECT SUM(alias1.col_varchar_nokey) AS field2 +FROM t2 AS alias2 +LEFT JOIN (SELECT * FROM view_inline_0) AS alias1 +ON alias2.col_varchar_key = alias1.col_varchar_key AND +(alias2.col_varchar_nokey, alias2.col_varchar_key) IN +(SELECT * FROM view_inline_1 +) +WHERE (alias1.col_varchar_key, alias1.col_varchar_nokey) IN +(SELECT * FROM view_inline_2 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL 2 100.00 NULL +1 PRIMARY alias2 NULL ALL NULL NULL NULL NULL 11 10.00 Using where +1 PRIMARY NULL ref 8 test.alias2.col_varchar_nokey,test.view_inline_2.p 3 100.00 Using index; FirstMatch(alias2) +1 PRIMARY NULL ref 8 test.view_inline_2.p,test.view_inline_2.Name_exp_p 2 100.00 NULL +7 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +8 UNION NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +NULL UNION RESULT NULL ALL NULL NULL NULL NULL NULL NULL Using temporary +6 DERIVED sq2_alias1 NULL ALL NULL NULL NULL NULL 15 100.00 NULL +6 DERIVED sq2_alias2 NULL ref col_int_key col_int_key 5 test.sq2_alias1.pk 2 100.00 NULL +2 DERIVED NULL ALL NULL NULL NULL NULL 15 100.00 NULL +5 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select sum(`alias1`.`col_varchar_nokey`) AS `field2` from `test`.`view_inline_2` join `test`.`t2` `alias2` join (/* select#2 */ select `test`.`view_inline_0`.`pk` AS `pk`,`test`.`view_inline_0`.`col_varchar_key` AS `col_varchar_key`,`test`.`view_inline_0`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`view_inline_0`) `alias1` semi join (`test`.`view_inline_1`) where ((`test`.`view_inline_1`.`sq2_field1` = `test`.`alias2`.`col_varchar_nokey`) and (`alias1`.`col_varchar_nokey` = `test`.`view_inline_2`.`Name_exp_p`) and (`test`.`alias2`.`col_varchar_key` = `test`.`view_inline_2`.`p`) and (`test`.`view_inline_1`.`sq2_field2` = `test`.`view_inline_2`.`p`) and (`alias1`.`col_varchar_key` = `test`.`view_inline_2`.`p`)) +SELECT SUM(alias1.col_varchar_nokey) AS field2 +FROM t2 AS alias2 +LEFT JOIN (SELECT * FROM view_inline_0) AS alias1 +ON alias2.col_varchar_key = alias1.col_varchar_key AND +(alias2.col_varchar_nokey, alias2.col_varchar_key) IN +(SELECT * FROM view_inline_1 +) +WHERE (alias1.col_varchar_key, alias1.col_varchar_nokey) IN +(SELECT * FROM view_inline_2 +); +field2 +NULL +SET @@optimizer_switch= @optimizer_switch_saved; +DROP VIEW view_inline_0, view_inline_1, view_inline_2; +DROP TABLE t1, t2, t3; +# End of test for bug#13956813. +# +# Bug#13974177: Assert !(tab->table->regginfo.not_exists_optimize... +# +CREATE TABLE t1 ( +pk INTEGER AUTO_INCREMENT, +col_int_nokey INTEGER, +col_int_key INTEGER, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk), +KEY (col_int_key), +KEY (col_varchar_key, col_int_key) +); +INSERT INTO t1(col_int_key, col_int_nokey, col_varchar_key, col_varchar_nokey) +VALUES +(0, 4, 'j', 'j'), (8, 6, 'v', 'v'), (1, 3, 'c', 'c'), (8, 5, 'm', 'm'), +(9, 3, 'd', 'd'), (24, 246, 'd', 'd'), (6, 2, 'y', 'y'), (1, 9, 't', 't'), +(6, 3, 'd', 'd'), (2, 8, 's', 's'), (4, 1, 'r', 'r'), (8, 8, 'm', 'm'), +(4, 8, 'b', 'b'), (4, 5, 'x', 'x'), (7, 7, 'g', 'g'), (4, 5, 'p', 'p'), +(1, 1, 'q', 'q'), (9, 6, 'w', 'w'), (4, 2, 'd', 'd'), (8, 9, 'e', 'e'); +CREATE TABLE t2 ( +pk INTEGER AUTO_INCREMENT, +col_int_nokey INTEGER NOT NULL, +col_time_key TIME NOT NULL, +col_time_nokey TIME NOT NULL, +PRIMARY KEY (pk), +KEY (col_time_key) +) ENGINE=InnoDB; +INSERT INTO t2 (col_int_nokey, col_time_key, col_time_nokey) VALUES +(7, '00:00:00', '00:00:00'), (0, '00:00:00', '00:00:00'), +(9, '06:35:17', '06:35:17'), (3, '18:07:14', '18:07:14'), +(4, '20:36:52', '20:36:52'), (2, '21:29:07', '21:29:07'), +(5, '23:45:57', '23:45:57'), (3, '22:54:57', '22:54:57'), +(1, '18:45:09', '18:45:09'), (3, '14:30:46', '14:30:46'), +(6, '19:23:43', '19:23:43'), (7, '03:39:30', '03:39:30'), +(5, '23:37:52', '23:37:52'), (1, '16:59:30', '16:59:30'), +(204, '22:21:15', '22:21:15'), (224, '12:24:37', '12:24:37'), +(9, '15:02:08', '15:02:08'), (5, '23:59:59', '23:59:59'), +(0, '08:23:30', '08:23:30'), (3, '08:32:22', '08:32:22'); +explain SELECT ot1.col_int_key AS x +FROM t1 AS ot2 +LEFT JOIN t1 AS ot1 +ON ot2.col_varchar_nokey > ot1.col_varchar_key +WHERE (ot1.col_int_nokey, ot1.pk) IN +(SELECT it1.pk AS x, +it1.col_int_nokey AS y +FROM t2 AS it2 +LEFT JOIN t2 AS it1 +ON it2.col_time_nokey = it1.col_time_key +) AND ot1.pk IS NULL +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`col_int_key` AS `x` from `test`.`t2` `it1` join `test`.`t1` `ot2` join `test`.`t1` `ot1` semi join (`test`.`t2` `it2`) where ((`test`.`ot1`.`pk` is null) and (`test`.`ot2`.`col_varchar_nokey` > `test`.`ot1`.`col_varchar_key`) and multiple equal(`test`.`ot1`.`col_int_nokey`, `test`.`it1`.`pk`) and multiple equal(`test`.`ot1`.`pk`, `test`.`it1`.`col_int_nokey`) and multiple equal(`test`.`it2`.`col_time_nokey`, `test`.`it1`.`col_time_key`)) +SELECT ot1.col_int_key AS x +FROM t1 AS ot2 +LEFT JOIN t1 AS ot1 +ON ot2.col_varchar_nokey > ot1.col_varchar_key +WHERE (ot1.col_int_nokey, ot1.pk) IN +(SELECT it1.pk AS x, +it1.col_int_nokey AS y +FROM t2 AS it2 +LEFT JOIN t2 AS it1 +ON it2.col_time_nokey = it1.col_time_key +) AND ot1.pk IS NULL +; +x +DROP TABLE t1, t2; +# End of test for bug#13974177. +# +# Bug#13971022: Assert 'keyparts > 0' failed in create_ref_for_key... +# +CREATE TABLE t1 ( +pk INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +PRIMARY KEY (pk), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +CREATE TABLE t2 ( +pk INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk) +) charset utf8mb4 ENGINE=InnoDB; +CREATE TABLE t3 ( +i INT +); +SET @optimizer_switch_saved= @@optimizer_switch; +SET @@optimizer_switch="derived_merge=off"; +explain SELECT table1.pk AS field1 +FROM ( SELECT subquery1_t1. * +FROM t2 AS subquery1_t1 +JOIN t2 AS subquery1_t2 +ON subquery1_t2.pk = subquery1_t1.pk) AS table1 +STRAIGHT_JOIN t2 AS table2 +ON table1.col_int_key IN (SELECT 7 FROM t3) +WHERE table1.col_varchar_nokey IN +(SELECT subquery3_t1.col_varchar_key AS subquery3_field1 +FROM t1 AS subquery3_t1 +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 PRIMARY subquery3_t1 NULL ref col_varchar_key col_varchar_key 7 table1.col_varchar_nokey 0 0.00 Using index; FirstMatch() +1 PRIMARY t3 NULL ALL NULL NULL NULL NULL 0 0.00 FirstMatch(subquery3_t1) +1 PRIMARY table2 NULL index NULL PRIMARY 4 NULL 1 100.00 Using index +2 DERIVED subquery1_t1 NULL ALL PRIMARY NULL NULL NULL 1 100.00 Using where +2 DERIVED subquery1_t2 NULL eq_ref PRIMARY PRIMARY 4 test.subquery1_t1.pk 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `table1`.`pk` AS `field1` from (/* select#2 */ select `test`.`subquery1_t1`.`pk` AS `pk`,`test`.`subquery1_t1`.`col_int_key` AS `col_int_key`,`test`.`subquery1_t1`.`col_varchar_key` AS `col_varchar_key`,`test`.`subquery1_t1`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t2` `subquery1_t1` join `test`.`t2` `subquery1_t2` where ((`test`.`subquery1_t1`.`col_int_key` = 7) and (`test`.`subquery1_t2`.`pk` = `test`.`subquery1_t1`.`pk`))) `table1` straight_join `test`.`t2` `table2` semi join (`test`.`t3`) semi join (`test`.`t1` `subquery3_t1`) where (`test`.`subquery3_t1`.`col_varchar_key` = `table1`.`col_varchar_nokey`) +SELECT table1.pk AS field1 +FROM ( SELECT subquery1_t1. * +FROM t2 AS subquery1_t1 +JOIN t2 AS subquery1_t2 +ON subquery1_t2.pk = subquery1_t1.pk) AS table1 +STRAIGHT_JOIN t2 AS table2 +ON table1.col_int_key IN (SELECT 7 FROM t3) +WHERE table1.col_varchar_nokey IN +(SELECT subquery3_t1.col_varchar_key AS subquery3_field1 +FROM t1 AS subquery3_t1 +) +; +field1 +SET @@optimizer_switch= @optimizer_switch_saved; +DROP TABLE t1, t2, t3; +# End of test for bug#13971022. +# +# Bug#13623473 "MISSING ROWS ON SELECT AND JOIN WITH +# TIME/DATETIME COMPARE" - Subquery part of test. +# +SET TIMESTAMP=UNIX_TIMESTAMP('2012-01-31 10:14:35'); +CREATE TABLE t1 ( +pk INT NOT NULL, +col_int_nokey INT, +col_int_key INT NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +) ENGINE=InnoDB; +INSERT INTO t1 VALUES (10,1,7), (11,7,0), (12,4,9), (13,7,3), +(14,0,4), (15,2,2), (16,9,5), (17,4,3), (18,0,1), (19,9,3), (20,1,6), +(21,3,7), (22,8,5), (23,8,1), (24,18,204), (25,84,224), (26,6,9), +(27,3,5), (28,6,0), (29,6,3); +CREATE TABLE t2 ( +col_int_nokey INT NOT NULL, +col_datetime_key DATETIME NOT NULL, +col_varchar_key VARCHAR(1) NOT NULL, +KEY col_datetime_key (col_datetime_key), +KEY col_varchar_key (col_varchar_key) +) ENGINE=InnoDB; +INSERT INTO t2 VALUES (1,'2001-11-04 19:07:55','k'); +CREATE TABLE t3 ( +col_time_key TIME, +KEY col_time_key (col_time_key) +) ENGINE=InnoDB; +INSERT INTO t3 VALUES ('21:22:34'), ('10:50:38'), ('00:21:38'), +('04:08:02'), ('16:25:11'), ('10:14:58'), ('19:47:59'), ('11:14:24'), +('00:00:00'), ('00:00:00'), ('15:57:25'), ('07:05:51'), ('19:22:21'), +('03:53:16'), ('09:16:38'), ('15:37:26'), ('00:00:00'), ('05:03:03'), +('02:59:24'), ('00:01:58'); +EXPLAIN SELECT outr.col_int_nokey +FROM t2 as outr +STRAIGHT_JOIN t3 AS outr2 +ON outr2.col_time_key > outr.col_datetime_key +WHERE outr.col_int_nokey IN ( +SELECT col_int_key +FROM t1 AS innr +WHERE innr.pk >= innr.col_int_nokey +) AND ( +outr.col_int_nokey <= 6 +OR +outr.col_varchar_key IS NULL +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE outr NULL ALL col_datetime_key NULL NULL NULL 1 100.00 Using where +2 SIMPLE innr NULL ref col_int_key col_int_key 4 test.outr.col_int_nokey 1 33.33 Using where; FirstMatch(outr) +2 SIMPLE outr2 NULL index col_time_key col_time_key 4 NULL 20 33.33 Using where; Using index +Warnings: +Warning 1739 Cannot use range access on index 'col_time_key' due to type or collation conversion on field 'col_time_key' +Note 1003 /* select#1 */ select `test`.`outr`.`col_int_nokey` AS `col_int_nokey` from `test`.`t2` `outr` straight_join `test`.`t3` `outr2` semi join (`test`.`t1` `innr`) where ((`test`.`innr`.`col_int_key` = `test`.`outr`.`col_int_nokey`) and (`test`.`outr`.`col_int_nokey` <= 6) and (`test`.`innr`.`pk` >= `test`.`innr`.`col_int_nokey`) and (cast(`test`.`outr2`.`col_time_key` as datetime) > `test`.`outr`.`col_datetime_key`)) +SELECT outr.col_int_nokey +FROM t2 as outr +STRAIGHT_JOIN t3 AS outr2 +ON outr2.col_time_key > outr.col_datetime_key +WHERE outr.col_int_nokey IN ( +SELECT col_int_key +FROM t1 AS innr +WHERE innr.pk >= innr.col_int_nokey +) AND ( +outr.col_int_nokey <= 6 +OR +outr.col_varchar_key IS NULL +); +col_int_nokey +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +DROP TABLE t1,t2,t3; +SET TIMESTAMP = DEFAULT; +# End of test for bug#13623473. +# +# Bug#13980954: Missing data on left join + null value + where..in +# +CREATE TABLE t1 ( +ik INT, +vc varchar(1) +) charset utf8mb4; +INSERT INTO t1 VALUES (8, 'x'), (NULL, 'x'); +CREATE TABLE t2 ( +ik INT, +vc varchar(1) +) charset utf8mb4; +INSERT INTO t2 VALUES +(0, 'x'), (7, 'i'), (7, 'e'), (1, 'p'), (7, 's'), (1, 'j'); +explain format=json SELECT t2.vc, t2.ik AS t2_ik, t1.ik AS t1_ik +FROM t2 LEFT JOIN t1 ON t2.vc=t1.vc +WHERE t2.vc IN (SELECT vc FROM t2 AS t3); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "11.96" + }, + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 6, + "rows_produced_per_join": 6, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "0.60", + "prefix_cost": "1.11", + "data_read_per_join": "96" + }, + "used_columns": [ + "ik", + "vc" + ] + } + }, + { + "table": { + "table_name": "t3", + "access_type": "ALL", + "rows_examined_per_scan": 6, + "rows_produced_per_join": 6, + "filtered": "16.67", + "first_match": "t2", + "cost_info": { + "read_cost": "3.04", + "eval_cost": "0.60", + "prefix_cost": "7.75", + "data_read_per_join": "96" + }, + "used_columns": [ + "vc" + ], + "attached_condition": "(`test`.`t3`.`vc` = `test`.`t2`.`vc`)" + } + }, + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 12, + "filtered": "100.00", + "cost_info": { + "read_cost": "3.01", + "eval_cost": "1.20", + "prefix_cost": "11.97", + "data_read_per_join": "192" + }, + "used_columns": [ + "ik", + "vc" + ], + "attached_condition": "(is_not_null_compl(t1), (`test`.`t1`.`vc` = `test`.`t2`.`vc`), true)" + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`vc` AS `vc`,`test`.`t2`.`ik` AS `t2_ik`,`test`.`t1`.`ik` AS `t1_ik` from `test`.`t2` left join `test`.`t1` on((`test`.`t1`.`vc` = `test`.`t2`.`vc`)) semi join (`test`.`t2` `t3`) where (`test`.`t3`.`vc` = `test`.`t2`.`vc`) +SELECT t2.vc, t2.ik AS t2_ik, t1.ik AS t1_ik +FROM t2 LEFT JOIN t1 ON t2.vc=t1.vc +WHERE t2.vc IN (SELECT vc FROM t2 AS t3); +vc t2_ik t1_ik +e 7 NULL +i 7 NULL +j 1 NULL +p 1 NULL +s 7 NULL +x 0 8 +x 0 NULL +DROP TABLE t1, t2; +# End of test for bug#13980954. +# +# Bug#14048292: Segfault in Item_field::result_type on 2nd execution +# of prep stmt with join of view +# +CREATE TABLE t1 ( +col_int INT +); +INSERT INTO t1 VALUES (0), (1); +CREATE VIEW view_t1 AS SELECT * FROM t1; +explain SELECT alias1.col_int +FROM t1 AS alias1 +LEFT JOIN view_t1 AS alias2 +ON alias1.col_int IN +(SELECT sq1_alias1.col_int +FROM t1 AS sq1_alias1 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE alias1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE sq1_alias1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`alias1`.`col_int` AS `col_int` from `test`.`t1` `alias1` left join (`test`.`t1` semi join (`test`.`t1` `sq1_alias1`)) on(((`test`.`sq1_alias1`.`col_int` = `test`.`alias1`.`col_int`))) where true +PREPARE stmt FROM "SELECT alias1.col_int +FROM t1 AS alias1 +LEFT JOIN view_t1 AS alias2 +ON alias1.col_int IN +(SELECT sq1_alias1.col_int +FROM t1 AS sq1_alias1 +)"; +EXECUTE stmt; +col_int +0 +0 +1 +1 + +EXECUTE stmt; +col_int +0 +0 +1 +1 +DEALLOCATE PREPARE stmt; +DROP VIEW view_t1; +DROP TABLE t1; +# End of test for bug#14048292. +# +# Bug#14064201: Missing data on join of derived table + WHERE .. IN +# with two operands +# +CREATE TABLE t1 ( +col_varchar_nokey VARCHAR(1) +) charset utf8mb4; +INSERT INTO t1 VALUES +('v'), ('s'), ('l'), ('y'), ('c'), ('i'), ('h'), ('q'), ('a'), ('v'), +('u'), ('s'), ('y'), ('z'), ('h'), ('p'), ('e'), ('i'), ('y'), ('w'); +CREATE TABLE t2 ( +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +KEY col_varchar_key(col_varchar_key) +) charset utf8mb4; +INSERT INTO t2 VALUES +('j','j'), ('v','v'), ('c','c'), ('m','m'), ('d','d'), ('d','d'), ('y','y'); +SET @optimizer_switch_saved= @@optimizer_switch; +SET @@optimizer_switch="derived_merge=off"; +explain format=json SELECT * +FROM (SELECT * FROM t2) AS derived1 +LEFT JOIN t1 +USING (col_varchar_nokey) +WHERE (col_varchar_nokey, col_varchar_nokey) IN +(SELECT col_varchar_nokey, col_varchar_key +FROM t2 AS derived2 +); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "25.86" + }, + "nested_loop": [ + { + "table": { + "table_name": "derived1", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "2.59", + "eval_cost": "0.70", + "prefix_cost": "3.29", + "data_read_per_join": "112" + }, + "used_columns": [ + "col_varchar_key", + "col_varchar_nokey" + ], + "attached_condition": "(`derived1`.`col_varchar_nokey` is not null)", + "materialized_from_subquery": { + "using_temporary_table": true, + "dependent": false, + "cacheable": true, + "query_block": { + "select_id": 2, + "cost_info": { + "query_cost": "1.21" + }, + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "0.70", + "prefix_cost": "1.21", + "data_read_per_join": "112" + }, + "used_columns": [ + "col_varchar_key", + "col_varchar_nokey" + ] + } + } + } + } + }, + { + "table": { + "table_name": "derived2", + "access_type": "ref", + "possible_keys": [ + "col_varchar_key" + ], + "key": "col_varchar_key", + "used_key_parts": [ + "col_varchar_key" + ], + "key_length": "7", + "ref": [ + "derived1.col_varchar_nokey" + ], + "rows_examined_per_scan": 2, + "rows_produced_per_join": 7, + "filtered": "14.29", + "first_match": "derived1", + "cost_info": { + "read_cost": "3.50", + "eval_cost": "0.70", + "prefix_cost": "8.19", + "data_read_per_join": "112" + }, + "used_columns": [ + "col_varchar_key", + "col_varchar_nokey" + ], + "attached_condition": "(`test`.`derived2`.`col_varchar_nokey` = `derived1`.`col_varchar_nokey`)" + } + }, + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 140, + "filtered": "100.00", + "cost_info": { + "read_cost": "3.67", + "eval_cost": "14.00", + "prefix_cost": "25.86", + "data_read_per_join": "1K" + }, + "used_columns": [ + "col_varchar_nokey" + ], + "attached_condition": "(is_not_null_compl(t1), (`test`.`t1`.`col_varchar_nokey` = `derived1`.`col_varchar_nokey`), true)" + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select `derived1`.`col_varchar_nokey` AS `col_varchar_nokey`,`derived1`.`col_varchar_key` AS `col_varchar_key` from (/* select#2 */ select `test`.`t2`.`col_varchar_key` AS `col_varchar_key`,`test`.`t2`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t2`) `derived1` left join `test`.`t1` on((`test`.`t1`.`col_varchar_nokey` = `derived1`.`col_varchar_nokey`)) semi join (`test`.`t2` `derived2`) where ((`test`.`derived2`.`col_varchar_nokey` = `derived1`.`col_varchar_nokey`) and (`test`.`derived2`.`col_varchar_key` = `derived1`.`col_varchar_nokey`)) +SELECT * +FROM (SELECT * FROM t2) AS derived1 +LEFT JOIN t1 +USING (col_varchar_nokey) +WHERE (col_varchar_nokey, col_varchar_nokey) IN +(SELECT col_varchar_nokey, col_varchar_key +FROM t2 AS derived2 +); +col_varchar_nokey col_varchar_key +c c +d d +d d +j j +m m +v v +v v +y y +y y +y y +SET @@optimizer_switch= @optimizer_switch_saved; +DROP TABLE t1, t2; +CREATE TABLE t1 ( +col_int_nokey int NOT NULL, +col_int_key int NOT NULL, +KEY col_int_key (col_int_key) +); +INSERT INTO t1 VALUES +(1,7), (7,0), (4,9), (7,3), (0,4), (2,2), (9,5), (4,3), (0,1), (9,3), +(1,6), (3,7), (8,5), (8,1), (18,204), (84,224), (6,9), (3,5), (6,0), (6,3); +CREATE TABLE t2 ( +col_int_nokey int NOT NULL, +col_int_key int NOT NULL, +KEY col_int_key (col_int_key) +); +INSERT INTO t2 VALUES +(4,0), (6,8), (3,1), (5,8), (3,9), (246,24), (2,6), (9,1), (3,6), (8,2), +(1,4), (8,8), (8,4), (5,4), (7,7), (5,4), (1,1), (6,9), (2,4), (9,8); +explain format=json SELECT grandparent1.* +FROM t1 AS grandparent1 +LEFT JOIN t1 USING (col_int_nokey) +WHERE (col_int_nokey, col_int_nokey) IN +(SELECT col_int_nokey, col_int_key +FROM t2 +); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "67.53" + }, + "nested_loop": [ + { + "table": { + "table_name": "grandparent1", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 20, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "2.00", + "prefix_cost": "2.51", + "data_read_per_join": "320" + }, + "used_columns": [ + "col_int_nokey", + "col_int_key" + ] + } + }, + { + "table": { + "table_name": "t2", + "access_type": "ref", + "possible_keys": [ + "col_int_key" + ], + "key": "col_int_key", + "used_key_parts": [ + "col_int_key" + ], + "key_length": "4", + "ref": [ + "test.grandparent1.col_int_nokey" + ], + "rows_examined_per_scan": 2, + "rows_produced_per_join": 20, + "filtered": "10.00", + "first_match": "grandparent1", + "cost_info": { + "read_cost": "10.00", + "eval_cost": "2.00", + "prefix_cost": "17.31", + "data_read_per_join": "320" + }, + "used_columns": [ + "col_int_nokey", + "col_int_key" + ], + "attached_condition": "(`test`.`t2`.`col_int_nokey` = `test`.`grandparent1`.`col_int_nokey`)" + } + }, + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 400, + "filtered": "100.00", + "cost_info": { + "read_cost": "10.22", + "eval_cost": "40.00", + "prefix_cost": "67.53", + "data_read_per_join": "6K" + }, + "used_columns": [ + "col_int_nokey" + ], + "attached_condition": "(is_not_null_compl(t1), (`test`.`t1`.`col_int_nokey` = `test`.`grandparent1`.`col_int_nokey`), true)" + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`grandparent1`.`col_int_nokey` AS `col_int_nokey`,`test`.`grandparent1`.`col_int_key` AS `col_int_key` from `test`.`t1` `grandparent1` left join `test`.`t1` on((`test`.`t1`.`col_int_nokey` = `test`.`grandparent1`.`col_int_nokey`)) semi join (`test`.`t2`) where ((`test`.`t2`.`col_int_nokey` = `test`.`grandparent1`.`col_int_nokey`) and (`test`.`t2`.`col_int_key` = `test`.`grandparent1`.`col_int_nokey`)) +SELECT grandparent1.* +FROM t1 AS grandparent1 +LEFT JOIN t1 USING (col_int_nokey) +WHERE (col_int_nokey, col_int_nokey) IN +(SELECT col_int_nokey, col_int_key +FROM t2 +); +col_int_nokey col_int_key +1 6 +1 6 +1 7 +1 7 +7 0 +7 0 +7 3 +7 3 +8 1 +8 1 +8 5 +8 5 +DROP TABLE t1, t2; +CREATE TABLE t1 ( +pk int, +col_int_key int, +col_datetime_key datetime, +col_varchar_key varchar(1), +col_varchar_nokey varchar(1), +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_datetime_key (col_datetime_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4 engine=MyISAM; +INSERT INTO t1 VALUES +(10,7,'2004-06-06 04:22:12','v','v'), (11,0,'2005-11-13 01:12:31','s','s'), +(12,9,'2002-05-04 01:50:00','l','l'), (13,3,'2004-10-27 10:28:45','y','y'), +(14,4,'2006-07-22 05:24:23','c','c'), (15,2,'2002-05-16 21:34:03','i','i'), +(16,5,'2008-04-17 10:45:30','h','h'), (17,3,'2009-04-21 02:58:02','q','q'), +(18,1,'2008-01-11 11:01:51','a','a'), (19,3,'1900-01-01 00:00:00','v','v'), +(20,6,'2007-05-17 18:24:57','u','u'), (21,7,'2007-08-07 00:00:00','s','s'), +(22,5,'2001-08-28 00:00:00','y','y'), (23,1,'2004-04-16 00:27:28','z','z'), +(24,204,'2005-05-03 07:06:22','h','h'), (25,224,'2009-03-11 17:09:50','p','p'), +(26,9,'2007-12-08 01:54:28','e','e'), (27,5,'2009-07-28 18:19:54','i','i'), +(28,0,'2008-06-08 00:00:00','y','y'), (29,3,'2005-02-09 09:20:26','w','w'); +CREATE TABLE t2 ( +pk int, +col_int_key int, +col_datetime_key datetime, +col_varchar_key varchar(1), +col_varchar_nokey varchar(1), +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_datetime_key (col_datetime_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4 engine=MyISAM; +INSERT INTO t2 VALUES +(1,0,'2002-02-13 17:30:06','j','j'), (2,8,'2008-09-27 00:34:58','v','v'), +(3,1,'2007-05-28 00:00:00','c','c'), (4,8,'2009-07-25 09:21:20','m','m'), +(5,9,'2002-01-16 00:00:00','d','d'), (6,24,'2006-10-12 04:32:53','d','d'), +(7,6,'2001-02-15 03:08:38','y','y'), (8,1,'2004-10-02 20:31:15','t','t'), +(9,6,'2002-08-20 22:48:00','d','d'), (10,2,'1900-01-01 00:00:00','s','s'), +(11,4,'2005-08-15 00:00:00','r','r'), (12,8,'1900-01-01 00:00:00','m','m'), +(13,4,'2008-05-16 08:09:06','b','b'), (14,4,'2001-01-20 12:47:23','x','x'), +(15,7,'2008-07-02 00:00:00','g','g'), (16,4,'1900-01-01 00:00:00','p','p'), +(17,1,'2002-12-08 11:34:58','q','q'), (18,9,'1900-01-01 00:00:00','w','w'), +(19,4,'1900-01-01 00:00:00','d','d'), (20,8,'2002-08-25 20:35:06','e','e'); +SELECT alias1.col_datetime_key +FROM t2 AS alias1 +RIGHT JOIN t2 AS alias2 +JOIN t2 AS alias3 +ON alias3.pk = alias2.pk +ON alias3.col_varchar_nokey = alias2.col_varchar_key OR +alias2.col_varchar_nokey +WHERE (alias2.col_varchar_key, alias2.col_varchar_key) IN +(SELECT sq2_alias2.col_varchar_key, sq2_alias1.col_varchar_nokey +FROM t1 AS sq2_alias1, t1 AS sq2_alias2 +WHERE sq2_alias2.col_int_key < 2); +col_datetime_key +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +2001-01-20 12:47:23 +2001-01-20 12:47:23 +2001-02-15 03:08:38 +2001-02-15 03:08:38 +2002-01-16 00:00:00 +2002-01-16 00:00:00 +2002-02-13 17:30:06 +2002-02-13 17:30:06 +2002-08-20 22:48:00 +2002-08-20 22:48:00 +2002-08-25 20:35:06 +2002-08-25 20:35:06 +2002-12-08 11:34:58 +2002-12-08 11:34:58 +2004-10-02 20:31:15 +2004-10-02 20:31:15 +2005-08-15 00:00:00 +2005-08-15 00:00:00 +2006-10-12 04:32:53 +2006-10-12 04:32:53 +2007-05-28 00:00:00 +2007-05-28 00:00:00 +2008-05-16 08:09:06 +2008-05-16 08:09:06 +2008-07-02 00:00:00 +2008-07-02 00:00:00 +2008-09-27 00:34:58 +2008-09-27 00:34:58 +2009-07-25 09:21:20 +2009-07-25 09:21:20 +ALTER TABLE t1 DISABLE KEYS; +ALTER TABLE t2 DISABLE KEYS; +explain format=json SELECT alias1.col_datetime_key +FROM t2 AS alias1 +RIGHT JOIN t2 AS alias2 +JOIN t2 AS alias3 +ON alias3.pk = alias2.pk +ON alias3.col_varchar_nokey = alias2.col_varchar_key OR +alias2.col_varchar_nokey +WHERE (alias2.col_varchar_key, alias2.col_varchar_key) IN +(SELECT sq2_alias2.col_varchar_key, sq2_alias1.col_varchar_nokey +FROM t1 AS sq2_alias1, t1 AS sq2_alias2 +WHERE sq2_alias2.col_int_key < 2); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "161.26" + }, + "nested_loop": [ + { + "table": { + "table_name": "alias2", + "access_type": "ALL", + "possible_keys": [ + "PRIMARY" + ], + "rows_examined_per_scan": 20, + "rows_produced_per_join": 20, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.53", + "eval_cost": "2.00", + "prefix_cost": "2.53", + "data_read_per_join": "640" + }, + "used_columns": [ + "pk", + "col_varchar_key", + "col_varchar_nokey" + ] + } + }, + { + "table": { + "table_name": "alias3", + "access_type": "eq_ref", + "possible_keys": [ + "PRIMARY" + ], + "key": "PRIMARY", + "used_key_parts": [ + "pk" + ], + "key_length": "4", + "ref": [ + "test.alias2.pk" + ], + "rows_examined_per_scan": 1, + "rows_produced_per_join": 20, + "filtered": "100.00", + "cost_info": { + "read_cost": "5.00", + "eval_cost": "2.00", + "prefix_cost": "9.53", + "data_read_per_join": "640" + }, + "used_columns": [ + "pk", + "col_varchar_nokey" + ] + } + }, + { + "table": { + "table_name": "sq2_alias2", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 20, + "filtered": "5.00", + "cost_info": { + "read_cost": "37.24", + "eval_cost": "2.00", + "prefix_cost": "60.11", + "data_read_per_join": "640" + }, + "used_columns": [ + "col_int_key", + "col_varchar_key" + ], + "attached_condition": "((`test`.`sq2_alias2`.`col_varchar_key` = `test`.`alias2`.`col_varchar_key`) and (`test`.`sq2_alias2`.`col_int_key` < 2))" + } + }, + { + "table": { + "table_name": "sq2_alias1", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 20, + "filtered": "10.00", + "first_match": "alias3", + "cost_info": { + "read_cost": "10.58", + "eval_cost": "2.00", + "prefix_cost": "110.68", + "data_read_per_join": "640" + }, + "used_columns": [ + "col_varchar_nokey" + ], + "attached_condition": "(`test`.`sq2_alias1`.`col_varchar_nokey` = `test`.`alias2`.`col_varchar_key`)" + } + }, + { + "table": { + "table_name": "alias1", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 400, + "filtered": "100.00", + "cost_info": { + "read_cost": "10.58", + "eval_cost": "40.00", + "prefix_cost": "161.26", + "data_read_per_join": "12K" + }, + "used_columns": [ + "col_datetime_key" + ], + "attached_condition": "(is_not_null_compl(alias1), (((`test`.`alias3`.`col_varchar_nokey` = `test`.`alias2`.`col_varchar_key`) and (`test`.`sq2_alias2`.`col_varchar_key` = `test`.`alias2`.`col_varchar_key`) and (`test`.`sq2_alias1`.`col_varchar_nokey` = `test`.`alias2`.`col_varchar_key`)) or (0 <> `test`.`alias2`.`col_varchar_nokey`)), true)" + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`alias1`.`col_datetime_key` AS `col_datetime_key` from `test`.`t2` `alias2` join `test`.`t2` `alias3` left join `test`.`t2` `alias1` on((((`test`.`alias3`.`col_varchar_nokey` = `test`.`alias2`.`col_varchar_key`) and (`test`.`sq2_alias2`.`col_varchar_key` = `test`.`alias2`.`col_varchar_key`) and (`test`.`sq2_alias1`.`col_varchar_nokey` = `test`.`alias2`.`col_varchar_key`)) or (0 <> `test`.`alias2`.`col_varchar_nokey`))) semi join (`test`.`t1` `sq2_alias1` join `test`.`t1` `sq2_alias2`) where ((`test`.`alias3`.`pk` = `test`.`alias2`.`pk`) and (`test`.`sq2_alias2`.`col_varchar_key` = `test`.`alias2`.`col_varchar_key`) and (`test`.`sq2_alias1`.`col_varchar_nokey` = `test`.`alias2`.`col_varchar_key`) and (`test`.`sq2_alias2`.`col_int_key` < 2)) +SELECT alias1.col_datetime_key +FROM t2 AS alias1 +RIGHT JOIN t2 AS alias2 +JOIN t2 AS alias3 +ON alias3.pk = alias2.pk +ON alias3.col_varchar_nokey = alias2.col_varchar_key OR +alias2.col_varchar_nokey +WHERE (alias2.col_varchar_key, alias2.col_varchar_key) IN +(SELECT sq2_alias2.col_varchar_key, sq2_alias1.col_varchar_nokey +FROM t1 AS sq2_alias1, t1 AS sq2_alias2 +WHERE sq2_alias2.col_int_key < 2); +col_datetime_key +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +2001-01-20 12:47:23 +2001-01-20 12:47:23 +2001-02-15 03:08:38 +2001-02-15 03:08:38 +2002-01-16 00:00:00 +2002-01-16 00:00:00 +2002-02-13 17:30:06 +2002-02-13 17:30:06 +2002-08-20 22:48:00 +2002-08-20 22:48:00 +2002-08-25 20:35:06 +2002-08-25 20:35:06 +2002-12-08 11:34:58 +2002-12-08 11:34:58 +2004-10-02 20:31:15 +2004-10-02 20:31:15 +2005-08-15 00:00:00 +2005-08-15 00:00:00 +2006-10-12 04:32:53 +2006-10-12 04:32:53 +2007-05-28 00:00:00 +2007-05-28 00:00:00 +2008-05-16 08:09:06 +2008-05-16 08:09:06 +2008-07-02 00:00:00 +2008-07-02 00:00:00 +2008-09-27 00:34:58 +2008-09-27 00:34:58 +2009-07-25 09:21:20 +2009-07-25 09:21:20 +DROP TABLE t1, t2; +# End of test for bug#14064201. +# +# Bug#18223655:ASSERTION FAILED: (INT)IDX >= 0 +# && IDX < PARENT_JOIN->TABLES +# +CREATE TABLE b (d INT); +CREATE TABLE c (a INT, b INT,c INT,d BLOB NOT NULL); +SELECT(SELECT 1 +FROM b WHERE(SELECT 1 IN (SELECT 1 FROM b WHERE 1 NOT BETWEEN d AND 1) +FROM b) IN (SELECT d FROM c)) as cc FROM b; +cc +INSERT INTO b VALUE(1); +INSERT INTO c VALUES(1,2,3,'1'),(2,3,4,'1'),(3,4,5,'C'); +SELECT(SELECT d FROM b WHERE(SELECT d IN +(SELECT d FROM b WHERE 1 NOT BETWEEN d AND 1) FROM b) IN +(SELECT d FROM c)) as cc FROM c; +cc +1 +1 +1 +DROP TABLE b,c; +# +# Bug#18447874:WRONG RESULT COMING FROM SEMI-JOIN +# +CREATE TABLE b ( +d INT(11) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE c ( +d BLOB +) ; +CREATE TABLE d ( +b INT(11) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO b VALUES(1),(2),(4); +INSERT INTO c VALUES(1),(2),(3); +SELECT 1 FROM b WHERE (SELECT 1 FROM d ) IN (SELECT d FROM c) ; +1 +INSERT INTO d VALUES(2); +SELECT 1 FROM b WHERE (SELECT 1 FROM d ) IN (SELECT d FROM c) ; +1 +1 +1 +1 +DROP TABLE b,c,d; +# +# Bug#17292723:INCORRECT RESULT FOR (SELECT...) IN (SELECT...) STATEMENT +# +CREATE TABLE t1 ( +ID int(11) NOT NULL AUTO_INCREMENT, +id2 int(11) DEFAULT NULL, +id3 int(11) DEFAULT NULL, +id4 varchar(150) COLLATE utf8_spanish_ci NOT NULL, +id5 int(11) DEFAULT NULL, +PRIMARY KEY (ID), +KEY id2 (id2), +KEY id3 (id3), +KEY id5 (id5) +) ENGINE=InnoDB; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 3778 'utf8_spanish_ci' is a collation of the deprecated character set UTF8MB3. Please consider using UTF8MB4 with an appropriate collation instead. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES +(123,1,1,'1',NULL), +(124,1,1,'2',NULL), +(125,1,1,'4',NULL), +(126,1,1,'3',NULL), +(127,1,1,'6',NULL), +(128,1,1,'8',NULL); +CREATE TABLE t2 ( +id6 int(11) NOT NULL, +id7 int(11) NOT NULL, +PRIMARY KEY (id6,id7), +KEY id7 (id7) +) ENGINE=InnoDB; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (126,123),(130,123),(135,123); +SELECT ID +FROM t1 p0 +WHERE p0.id3=1 +AND ( (SELECT p1.id FROM t1 p1 WHERE p1.id=123) IN (SELECT p3.id FROM t2 +p2, t1 p3 WHERE p0.id=p2.id6 AND p2.id7=p3.id)); +ID +126 +DROP TABLE t1,t2; +set @@optimizer_switch=@old_opt_switch; +# End of 5.6 tests +# +# Bug#19336348 DEBUG CRASH AT SETUP_SEMIJOIN_DUPS_ELIMINATION IN SQL/SQL_SELECT.CC +# +CREATE TABLE t1 ( +col_varchar_nokey varchar(1) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t1 VALUES ('c'),(NULL),('x'); +CREATE TABLE t2 ( +pk int, +col_varchar_key varchar(1), +PRIMARY KEY (pk), +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t2 VALUES (10,'l'),(11,'p'); +ANALYZE TABLE t1,t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN SELECT 1 +FROM t1 AS outr +WHERE outr.col_varchar_nokey IN +( +SELECT innr.col_varchar_key +FROM t2 AS innr +WHERE innr.pk <= 7 +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE outr NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 SIMPLE innr NULL ref PRIMARY,col_varchar_key col_varchar_key 7 test.outr.col_varchar_nokey 1 50.00 Using where; Using index; FirstMatch(outr) +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` `outr` semi join (`test`.`t2` `innr`) where ((`test`.`innr`.`col_varchar_key` = `test`.`outr`.`col_varchar_nokey`) and (`test`.`innr`.`pk` <= 7)) +SELECT 1 +FROM t1 AS outr +WHERE outr.col_varchar_nokey IN +( +SELECT innr.col_varchar_key +FROM t2 AS innr +WHERE innr.pk <= 7 +) +; +1 +DROP TABLE t1,t2; +# +# Bug#18174394 BLOBS: CRASH AFTER UNINITIALIZED VALUES IN ITEM_FIELD::STR_RESULT +# +CREATE TABLE t1(d BLOB, b BLOB); +INSERT INTO t1(d,b) VALUES ('aaaa',''),('bnbb',''); +SELECT 1 FROM t1 +WHERE (SELECT b FROM t1) IN (SELECT (d>=1) FROM t1); +ERROR 21000: Subquery returns more than 1 row +DROP TABLE t1; +# +# Bug#19779600: ASSERT FAILED IN REPLACE_SUBCONDITION WITH IN +# PREDICATE INSIDE IN PREDICATE +# +CREATE TABLE t(X INT) ENGINE=InnoDB; +INSERT INTO t VALUES (1); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +EXPLAIN SELECT 1 FROM t WHERE (1 IN (SELECT 1 FROM t)) IN (SELECT 1 FROM t); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 PRIMARY t NULL ALL NULL NULL NULL NULL 1 100.00 FirstMatch(t) +2 SUBQUERY t NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t` semi join (`test`.`t`) where true +SELECT 1 FROM t WHERE (1 IN (SELECT 1 FROM t)) IN (SELECT 1 FROM t); +1 +1 +DROP TABLE t; +# +# Bug#19465034 ASSERT ON SETUP_SEMIJOIN_DUPS_ELIMINATION IN SQL/SQL_SELECT.CC +# +CREATE TABLE t1 ( +pk INTEGER NOT NULL, +i1 INTEGER NOT NULL, +PRIMARY KEY (pk) +) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1,1); +CREATE TABLE t2 ( +pk INTEGER NOT NULL, +c1 VARCHAR(1) NOT NULL, +PRIMARY KEY (pk), +KEY c1_key (c1) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t2 VALUES (1,'j'),(2,'v'),(3,'c'); +CREATE TABLE t3 ( +pk INTEGER NOT NULL, +c1 VARCHAR(1) NOT NULL, +PRIMARY KEY (pk), +KEY c1_key (c1) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t3 VALUES (10,'v'),(11,'s'); +ANALYZE TABLE t1, t2, t3; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +EXPLAIN SELECT * +FROM t1 JOIN t2 ON t1.i1 >= t2.pk +WHERE t2.c1 IN ( +SELECT t3.c1 +FROM t3 +WHERE t3.pk < 3 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t2 NULL ALL PRIMARY,c1_key NULL NULL NULL 3 33.33 Range checked for each record (index map: 0x3) +2 SIMPLE t3 NULL ref PRIMARY,c1_key c1_key 6 test.t2.c1 1 50.00 Using where; Using index; FirstMatch(t2) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`i1` AS `i1`,`test`.`t2`.`pk` AS `pk`,`test`.`t2`.`c1` AS `c1` from `test`.`t1` join `test`.`t2` semi join (`test`.`t3`) where ((`test`.`t3`.`c1` = `test`.`t2`.`c1`) and (`test`.`t3`.`pk` < 3) and (`test`.`t1`.`i1` >= `test`.`t2`.`pk`)) +SELECT * +FROM t1 JOIN t2 ON t1.i1 >= t2.pk +WHERE t2.c1 IN ( +SELECT t3.c1 +FROM t3 +WHERE t3.pk < 3 +); +pk i1 pk c1 +DROP TABLE t1,t2,t3; +# +# Bug#19586047: CRASH IN ARG_COMPARATOR::SET_CMP_FUNC +# +CREATE TABLE t1(x INT) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT 1 FROM t1 WHERE EXISTS(SELECT 1) IN (SELECT 1 FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 1 100.00 FirstMatch(t1) +2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` semi join (`test`.`t1`) where true +SELECT 1 FROM t1 WHERE EXISTS(SELECT 1) IN (SELECT 1 FROM t1); +1 +1 +EXPLAIN SELECT 1 FROM t1 WHERE (SELECT 1, 2 FROM t1) IN (SELECT 1, 2 FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 1 100.00 FirstMatch(t1) +2 SUBQUERY t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` semi join (`test`.`t1`) where true +SELECT 1 FROM t1 WHERE (SELECT 1, 2 FROM t1) IN (SELECT 1, 2 FROM t1); +1 +1 +EXPLAIN SELECT 1 FROM t1 WHERE +(SELECT 1, 2 FROM t1 WHERE x = 2) IN (SELECT 1, 2 FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +2 SUBQUERY t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` semi join (`test`.`t1`) where false +SELECT 1 FROM t1 WHERE +(SELECT 1, 2 FROM t1 WHERE x = 2) IN (SELECT 1, 2 FROM t1); +1 +DROP TABLE t1; +# +#Bug#20119743 ASSERTIONQEP_TAB->USE_ORDER() IN ENUM_NESTED_LOOP_STATE +# EVALUATE_JOIN_RECORD +# +CREATE TABLE t1 ( +pk int(11) NOT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +PRIMARY KEY (pk) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (1,'x'); +CREATE TABLE t2 ( +col_date_key date DEFAULT NULL, +col_int_key int(11) DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +KEY col_int_key (col_int_key), +KEY col_date_key (col_date_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES ('2000-12-03', 8, 'x', 'x'),('2008-05-03', 7, 'd', 'd'), +('2005-12-06', 1, 'r', 'r'),('2000-04-10', 7, 'f', 'f'), +('2002-11-05', 9, 'y', 'y'),('2000-09-06', NULL, 'u', 'u'), +(NULL, 1, 'm', 'm'),('2007-06-14', 9, NULL, NULL), +('2007-11-17', 2, 'o', 'o'),('2009-02-23', 9, 'w', 'w'), +('2007-01-08', 2, 'm', 'm'), ('2008-06-10', 4, 'q', 'q'), +('2002-10-20', 0, NULL, NULL),('2008-09-12', 4, 'd', 'd'), +('2006-06-16', 8, 'g', 'g'),('2004-09-18', NULL, 'x', 'x'), +('1900-01-01', NULL, 'f', 'f'),('2005-09-13', 0, 'p', 'p'), +('2007-04-09', NULL, 'j', 'j'),('2000-09-20', 8, 'c', 'c'); +CREATE TABLE t3 ( +pk int(11) NOT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +PRIMARY KEY (pk) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t3 VALUES (1, 'c'),(2, 'c'),(3, 'q'),(4, 'g'),(5, 'e'),(6, 'l'), +(7, NULL),(8, 'v'),(9, 'c'),(10, 'u'),(11, 'x'),(12, 'x'),(13, 'x'),(14, 'l'), +(15, 'e'),(16, 's'),(17, 'k'),(18, 'm'),(19, 'x'),(20, 's'); +ANALYZE TABLE t1,t2,t3; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +EXPLAIN SELECT r1.col_date_key +FROM t2 AS r1 +WHERE r1.col_int_key NOT IN +(SELECT ir2.pk +FROM t2 AS ir1 STRAIGHT_JOIN t1 AS ir2 +ON ir2.col_varchar_nokey = ir1.col_varchar_key +WHERE ir2.col_varchar_nokey > r1.col_varchar_nokey +AND ir2.pk IN +(SELECT iir2.pk +FROM t2 AS iir1 RIGHT JOIN t3 AS iir2 +ON iir2.col_varchar_nokey = iir1.col_varchar_key)) +ORDER BY r1.col_date_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY r1 NULL ALL NULL NULL NULL NULL 20 100.00 Using where; Using filesort +2 DEPENDENT SUBQUERY ir1 NULL index col_varchar_key col_varchar_key 12 NULL 20 100.00 Using where; Using index +2 DEPENDENT SUBQUERY ir2 NULL eq_ref PRIMARY PRIMARY 4 func 1 100.00 Using where; Full scan on NULL key +2 DEPENDENT SUBQUERY iir2 NULL eq_ref PRIMARY PRIMARY 4 func 1 100.00 Using where; Full scan on NULL key +2 DEPENDENT SUBQUERY iir1 NULL ref col_varchar_key col_varchar_key 7 test.iir2.col_varchar_nokey 1 100.00 Using index; FirstMatch(ir2) +SELECT r1.col_date_key +FROM t2 AS r1 +WHERE r1.col_int_key NOT IN +(SELECT ir2.pk +FROM t2 AS ir1 STRAIGHT_JOIN t1 AS ir2 +ON ir2.col_varchar_nokey = ir1.col_varchar_key +WHERE ir2.col_varchar_nokey > r1.col_varchar_nokey +AND ir2.pk IN +(SELECT iir2.pk +FROM t2 AS iir1 RIGHT JOIN t3 AS iir2 +ON iir2.col_varchar_nokey = iir1.col_varchar_key)) +ORDER BY r1.col_date_key; +col_date_key +2000-04-10 +2000-09-20 +2000-12-03 +2002-10-20 +2002-11-05 +2004-09-18 +2005-09-13 +2006-06-16 +2007-01-08 +2007-06-14 +2007-11-17 +2008-05-03 +2008-06-10 +2008-09-12 +2009-02-23 +SELECT COUNT(r1.col_date_key) AS COUNT_NUM +FROM t2 AS r1 +WHERE r1.col_int_key NOT IN +(SELECT ir2.pk +FROM t2 AS ir1 STRAIGHT_JOIN t1 AS ir2 +ON ir2.col_varchar_nokey = ir1.col_varchar_key +WHERE ir2.col_varchar_nokey > r1.col_varchar_nokey +AND ir2.pk IN +(SELECT iir2.pk +FROM t2 AS iir1 RIGHT JOIN t3 AS iir2 +ON iir2.col_varchar_nokey = iir1.col_varchar_key +WHERE iir2.pk<3)); +COUNT_NUM +15 +DROP TABLE t1,t2,t3; +# +# Bug#20554585 ASSERT JOIN()->TABLES == 0... IN JOIN_TAB::GET_SJ_STRATEGY ON SUBQUERY + VAR +# +CREATE TABLE t1 ( +pk int NOT NULL, +PRIMARY KEY (pk) +); +CREATE TABLE t2 ( +pk int NOT NULL, +col_int_key int, +col_varchar_key varchar(1), +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key) +); +CREATE TABLE t3 ( +pk int NOT NULL, +col_int_key int, +col_varchar_key varchar(1), +col_varchar varchar(1), +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key) +); +INSERT INTO t3 VALUES (1,4,'c','g'),(20,1,'i','p'); +CREATE TABLE t4 ( +col_int int +); +CREATE TABLE t5 ( +col_varchar_key varchar(1), +pk int NOT NULL, +col_int int, +PRIMARY KEY (pk), +KEY col_varchar_key (col_varchar_key) +); +SELECT table1.col_varchar_key AS field1 +FROM (t3 AS table1 +INNER JOIN ( +SELECT SUBQUERY1_t1.* +FROM (t1 AS SUBQUERY1_t1 +RIGHT JOIN (t2 AS SUBQUERY1_t2 +INNER JOIN t3 AS SUBQUERY1_t3 +ON (SUBQUERY1_t3.col_varchar_key = SUBQUERY1_t2.col_varchar_key) +) ON (SUBQUERY1_t3.col_int_key = SUBQUERY1_t2.pk) +) +WHERE SUBQUERY1_t2.col_varchar_key >= ANY ( +SELECT CHILD_SUBQUERY1_t2.col_varchar AS CHILD_SUBQUERY1_field1 +FROM (t2 AS CHILD_SUBQUERY1_t1 +LEFT OUTER JOIN t3 AS CHILD_SUBQUERY1_t2 +ON (CHILD_SUBQUERY1_t2.col_int_key = CHILD_SUBQUERY1_t1.col_int_key) +) +WHERE CHILD_SUBQUERY1_t1.pk >= SUBQUERY1_t2.pk +) +) AS table2 +ON (table2.pk = table1.pk) +) +WHERE (EXISTS (( +SELECT DISTINCT SUBQUERY2_t2.col_int AS SUBQUERY2_field1 +FROM (t4 AS SUBQUERY2_t1 +LEFT OUTER JOIN t5 AS SUBQUERY2_t2 +ON (SUBQUERY2_t2.pk = SUBQUERY2_t1.col_int) +) +WHERE SUBQUERY2_t2.col_varchar_key != @var4 +))) +AND table1.col_int_key < (35 + 192) +ORDER BY field1 +; +field1 +DROP TABLE t1, t2, t3, t4, t5; +# +# Bug#18892055: MISSING DATA ON SELECT ... IN WITH JOINS AND INNODB +# ENGINE +# +CREATE TABLE t1 ( +col_int_key INT, +pk INT NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +) ENGINE = INNODB; +INSERT INTO t1 VALUES +( 0, 3 ), +( 0, 4 ), +( 3, 1 ), +( 900000000, 2 ), +( 1368719360, 5 ), +( 1922236416, 6 ), +( 8,7 ); +CREATE TABLE t2 ( +pk INT NOT NULL, +col_int INT, +PRIMARY KEY (pk) +) ENGINE = INNODB; +INSERT INTO t2 VALUES +( 1, 3 ), +( 2, 2 ), +( 3, 8 ), +( 4, 7 ); +CREATE TABLE t3 ( +col_int_key INT, +col_int INT, +KEY (col_int_key) +) ENGINE = INNODB; +INSERT INTO t3 VALUES +( 5, 1 ), +( -1, -1 ), +( 300000000, 1 ), +( 8, 1 ); +CREATE TABLE t4 ( col_int_key INT ) ENGINE = INNODB; +INSERT INTO t4 VALUES +(0), +(3), +(8), +(900000000), +(1368719360), +(1922236416); +ANALYZE TABLE t1, t2, t3, t4; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +test.t4 analyze status OK +explain SELECT * +FROM t4 +WHERE (col_int_key) IN ( +SELECT t1.col_int_key +FROM t1 LEFT JOIN ( t2 JOIN t3 ON t3.col_int_key = t2.col_int ) USING ( pk ) +WHERE t3.col_int IS NULL +) +ORDER BY col_int_key +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 6 100.00 Parallel execute (1 workers) +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 6 100.00 Using where; Using filesort +2 SIMPLE t1 NULL ref col_int_key col_int_key 5 test.t4.col_int_key 1 100.00 Using index +2 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.pk 1 100.00 NULL +2 SIMPLE t3 NULL ref col_int_key col_int_key 5 test.t2.col_int 1 25.00 Using where; FirstMatch(t4) +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`col_int_key` AS `col_int_key` from `test`.`t4` semi join (`test`.`t1` left join (`test`.`t2` join `test`.`t3`) on(((`test`.`t1`.`pk` = `test`.`t2`.`pk`) and (`test`.`t3`.`col_int_key` = `test`.`t2`.`col_int`)))) where ((`test`.`t1`.`col_int_key` = `test`.`t4`.`col_int_key`) and (`test`.`t3`.`col_int` is null)) order by `test`.`t4`.`col_int_key` +explain format=tree SELECT * +FROM t4 +WHERE (col_int_key) IN ( +SELECT t1.col_int_key +FROM t1 LEFT JOIN ( t2 JOIN t3 ON t3.col_int_key = t2.col_int ) USING ( pk ) +WHERE t3.col_int IS NULL +) +ORDER BY col_int_key +; +EXPLAIN +-> Parallel scan on + -> Nested loop semijoin (cost=3.05 rows=7) + -> Sort: t4.col_int_key (cost=0.85 rows=6) + -> Filter: (t4.col_int_key is not null) + -> PQblock scan on t4 + -> Filter: (t3.col_int is null) (cost=2.14 rows=1) + -> Nested loop left join (cost=2.14 rows=1) + -> Index lookup on t1 using col_int_key (col_int_key=t4.col_int_key) (cost=0.27 rows=1) + -> Nested loop inner join (cost=2.41 rows=1) + -> Single-row index lookup on t2 using PRIMARY (pk=t1.pk) (cost=0.26 rows=1) + -> Index lookup on t3 using col_int_key (col_int_key=t2.col_int) (cost=0.07 rows=1) + +SELECT * +FROM t4 +WHERE (col_int_key) IN ( +SELECT t1.col_int_key +FROM t1 LEFT JOIN ( t2 JOIN t3 ON t3.col_int_key = t2.col_int ) USING ( pk ) +WHERE t3.col_int IS NULL +) +ORDER BY col_int_key +; +col_int_key +0 +3 +8 +900000000 +1368719360 +1922236416 +DROP TABLE t1, t2, t3, t4; +# +# Bug#20835095 CRASH AT CREATE_REF_FOR_KEY IN SQL/SQL_SELECT.CC +# +CREATE TABLE t1 ( +pk INTEGER, +var_10_latin1 VARCHAR(10) CHARACTER SET latin1, +var_255_utf8 VARCHAR(255) CHARACTER SET utf8, +var_255_latin1 VARCHAR(255) CHARACTER SET latin1, +var_10_utf8 VARCHAR(10) CHARACTER SET utf8, +PRIMARY KEY (pk) +); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +CREATE VIEW v1 AS SELECT * FROM t1; +INSERT INTO t1 VALUES +(1,'FROCJ','korrhrspki','UAYVL','BPZIS'), +(2,'him','a','CHYKN','OZZQT'), +(3,'WBITK','ULWBF','have','rhrh'), +(4,'or','right','up','it'), +(5,'GGDCP','x','who','as'), +(6,'j','i','e','w'); +CREATE TABLE tv +SELECT var_255_utf8 AS field1 +FROM t1; +EXPLAIN SELECT * FROM tv +WHERE field1 IN ( +SELECT tv1.var_255_utf8 +FROM v1 AS tv1 LEFT JOIN v1 AS tv2 ON tv1.var_10_latin1=tv2.var_10_utf8); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE tv NULL ALL NULL NULL NULL NULL 6 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 6 16.67 Using where +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 6 100.00 Using where; FirstMatch(tv) +Warnings: +Note 1003 /* select#1 */ select `test`.`tv`.`field1` AS `field1` from `test`.`tv` semi join (`test`.`t1` left join (`test`.`t1`) on((`test`.`t1`.`var_10_latin1` = `test`.`t1`.`var_10_utf8`))) where (`test`.`t1`.`var_255_utf8` = `test`.`tv`.`field1`) +SELECT * FROM tv +WHERE field1 IN ( +SELECT tv1.var_255_utf8 +FROM v1 AS tv1 LEFT JOIN v1 AS tv2 ON tv1.var_10_latin1=tv2.var_10_utf8); +field1 +korrhrspki +a +ULWBF +right +x +i +DROP VIEW v1; +DROP TABLE t1, tv; +# 17832047 Crash in calculate_materialization_costs +CREATE TABLE t1(a INTEGER PRIMARY KEY); +INSERT INTO t1 VALUES (0),(1),(2); +SELECT 1 FROM t1 +WHERE 1 IN +(SELECT 1 BETWEEN (LENGTH(a) IN (SELECT 1 FROM t1)) AND 1 +FROM t1 +); +1 +1 +1 +1 +DROP TABLE t1; +# 17845989 Assertion failed: !(used_tables() & ... +CREATE TABLE a(b INTEGER) engine=innodb; +CREATE TABLE c(a INTEGER) engine=innodb; +SELECT 1 +FROM a +WHERE 1 IN (SELECT (a.b IS NULL) IN (SELECT 1 FROM c) FROM c) +; +1 +DROP TABLE a, c; +# +# Bug#18194196: OPTIMIZER EXECUTES STATEMENT INPERFORMANT +# +CREATE TABLE t1 (uid INTEGER, fid INTEGER, INDEX(uid)); +INSERT INTO t1 VALUES +(1,1), (1,2), (1,3), (1,4), +(2,5), (2,6), (2,7), (2,8), +(3,1), (3,2), (3,9); +CREATE TABLE t2 (uid INT PRIMARY KEY, name VARCHAR(128), INDEX(name)); +INSERT INTO t2 VALUES +(1, "A"), (2, "B"), (3, "C"), (4, "D"), (5, "E"), +(6, "F"), (7, "G"), (8, "H"), (9, "I"); +CREATE TABLE t3 (uid INT, fid INT, INDEX(uid)); +INSERT INTO t3 VALUES +(1,1), (1,2), (1,3),(1,4), +(2,5), (2,6), (2,7), (2,8), +(3,1), (3,2), (3,9); +CREATE TABLE t4 (uid INT PRIMARY KEY, name VARCHAR(128), INDEX(name)); +INSERT INTO t4 VALUES +(1, "A"), (2, "B"), (3, "C"), (4, "D"), (5, "E"), +(6, "F"), (7, "G"), (8, "H"), (9, "I"); +ANALYZE TABLE t1,t2,t3,t4; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +test.t4 analyze status OK +EXPLAIN SELECT name FROM t2, t1 +WHERE t1.uid IN (SELECT t4.uid FROM t4, t3 WHERE t3.uid=1 AND t4.uid=t3.fid) +AND t2.uid=t1.fid; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL uid NULL NULL NULL 11 100.00 Using where +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.fid 1 100.00 NULL +1 SIMPLE t4 NULL eq_ref PRIMARY PRIMARY 4 test.t1.uid 1 100.00 Using index +1 SIMPLE t3 NULL ref uid uid 5 const 4 10.00 Using where; FirstMatch(t4) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`name` AS `name` from `test`.`t4` join `test`.`t2` join `test`.`t1` semi join (`test`.`t3`) where ((`test`.`t4`.`uid` = `test`.`t1`.`uid`) and (`test`.`t3`.`fid` = `test`.`t1`.`uid`) and (`test`.`t3`.`uid` = 1) and (`test`.`t2`.`uid` = `test`.`t1`.`fid`)) +FLUSH STATUS; +SELECT name FROM t2, t1 +WHERE t1.uid IN (SELECT t4.uid FROM t4, t3 WHERE t3.uid=1 AND t4.uid=t3.fid) +AND t2.uid=t1.fid; +name +A +A +B +B +C +D +E +F +G +H +I +SHOW STATUS LIKE '%handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 25 +Handler_read_last 0 +Handler_read_next 10 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 12 +DROP TABLE t1,t2,t3,t4; +# End of test for Bug#18194196 +# +# Bug#21184091 ASSERT `READ_ROWS >= 0.0' AT +# COST_MODEL_SERVER::TMPTABLE_READWRITE_COST() +# +CREATE TABLE t1 ( +pk INTEGER, +col_varchar varchar(1), +col_int INTEGER, +PRIMARY KEY (pk) +) ENGINE=MyISAM; +CREATE TABLE t2 ( +col_int INTEGER, +col_varchar varchar(1) +) ENGINE=MyISAM; +INSERT INTO t2 VALUES (7,'x'); +INSERT INTO t2 VALUES (4,'z'); +SELECT t2.col_varchar +FROM t2 STRAIGHT_JOIN t1 ON t2.col_varchar = t1.col_varchar +JOIN t2 AS table3 ON t1.pk = table3.col_int +WHERE t1.pk IN (SELECT col_int FROM t1); +col_varchar +DROP TABLE t1,t2; +# End of test for Bug#21184091 +# Bug#21139722: Assertion failed: !(used_tables() & ((table_map) 1) ... +CREATE TABLE t1(a INTEGER) engine=innodb; +CREATE TABLE t2(b INTEGER) engine=innodb; +explain SELECT 1 +FROM (SELECT 1 IN (SELECT 1 +FROM t1 +WHERE (SELECT 1 FROM t2 HAVING b) NOT IN (SELECT 1 FROM t2) +) +FROM t2 +) AS z; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DERIVED t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +3 DEPENDENT SUBQUERY t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +5 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +4 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1276 Field or reference 'b' of SELECT #4 was resolved in SELECT #2 +Note 1003 /* select#1 */ select 1 AS `1` from (/* select#2 */ select (1,(/* select#3 */ select 1 from `test`.`t1` where ((/* select#4 */ select 1 from `test`.`t2` having (0 <> `test`.`t2`.`b`)),(/* select#5 */ select 1 from `test`.`t2` where (outer_field_is_not_null, (((/* select#4 */ select 1 from `test`.`t2` having (0 <> `test`.`t2`.`b`))) = 1), true)) is false))) AS `1 IN (SELECT 1 +FROM t1 +WHERE (SELECT 1 FROM t2 HAVING b) NOT IN (SELECT 1 FROM t2) +)` from `test`.`t2`) `z` +SELECT 1 +FROM (SELECT 1 IN (SELECT 1 +FROM t1 +WHERE (SELECT 1 FROM t2 HAVING b) NOT IN (SELECT 1 FROM t2) +) +FROM t2 +) AS z; +1 +DROP TABLE t1, t2; +CREATE TABLE t1(a INTEGER) engine=innodb; +explain SELECT (SELECT a FROM t1 AS t2 +WHERE a IN (SELECT t1.a+t2.a FROM t1 AS t3)) +FROM t1 AS t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 DEPENDENT SUBQUERY t3 NULL ALL NULL NULL NULL NULL 1 100.00 FirstMatch(t2) +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #3 was resolved in SELECT #1 +Note 1276 Field or reference 'test.t2.a' of SELECT #3 was resolved in SELECT #2 +Note 1003 /* select#1 */ select (/* select#2 */ select `test`.`t2`.`a` from `test`.`t1` `t2` semi join (`test`.`t1` `t3`) where (`test`.`t2`.`a` = (`test`.`t1`.`a` + `test`.`t2`.`a`))) AS `(SELECT a FROM t1 AS t2 +WHERE a IN (SELECT t1.a+t2.a FROM t1 AS t3))` from `test`.`t1` +SELECT (SELECT a FROM t1 AS t2 +WHERE a IN (SELECT t1.a+t2.a FROM t1 AS t3)) +FROM t1 AS t1; +(SELECT a FROM t1 AS t2 +WHERE a IN (SELECT t1.a+t2.a FROM t1 AS t3)) +DROP TABLE t1; +# End of test for Bug#21139722 +SET DEFAULT_STORAGE_ENGINE=INNODB; +# +# Bug#21139402 ASSERTION FAILED: LENGTH > 0 && KEYPARTS != 0, CRASH IN JOIN::OPTIMIZE_KEYUSE +# +CREATE TABLE t1 (a INT, b INT, PRIMARY KEY(a)); +CREATE TABLE t2 (c INT PRIMARY KEY); +EXPLAIN SELECT 1 FROM t1 +WHERE 1 IN +(SELECT (c IS NULL) IN (SELECT a FROM t1 WHERE b) FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +3 SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` semi join (`test`.`t2`) where false +SELECT 1 FROM t1 +WHERE 1 IN +(SELECT (c IS NULL) IN (SELECT a FROM t1 WHERE b) FROM t2); +1 +DROP TABLE t1,t2; +# +# Bug#21619634 ACCESS OF DEALLOCATED ITEM_OUTER_REF CAUSES CRASH: PREPARED STMT +# +create table cc (i int) engine="innodb"; +insert into cc values (1); +select (select count(i) from cc as cc_alias +where (cc.i in (select cc_alias.i from cc))) +from cc group by i; +(select count(i) from cc as cc_alias +where (cc.i in (select cc_alias.i from cc))) +1 +prepare stmt from +"select (select count(i) from cc as cc_alias + where (cc.i in (select cc_alias.i from cc))) + from cc group by i"; +execute stmt; +(select count(i) from cc as cc_alias + where (cc.i in (select cc_alias.i from cc))) +1 +execute stmt; +(select count(i) from cc as cc_alias + where (cc.i in (select cc_alias.i from cc))) +1 +drop table cc; +# +# Bug #22305361: QUERY WITH MATERIALIZED TABLE RETURNS INCORRECT +# RESULTS IN 5.6 +# +CREATE TABLE t(a INT,b INT); +INSERT INTO t VALUES (1,0),(1,0),(1,0),(1,0),(1,1); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +EXPLAIN SELECT * +FROM t AS t1 +WHERE t1.a IN (SELECT t2.a +FROM t AS t2 +WHERE CONCAT(t2.a,'') NOT IN (SELECT t3.a +FROM t AS t3 +WHERE t3.b=1)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 5 20.00 Using where; FirstMatch(t1) +3 DEPENDENT SUBQUERY t3 NULL ALL NULL NULL NULL NULL 5 20.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t` `t1` semi join (`test`.`t` `t2`) where ((`test`.`t2`.`a` = `test`.`t1`.`a`) and (concat(`test`.`t1`.`a`,''),(/* select#3 */ select `test`.`t3`.`a` from `test`.`t` `t3` where ((`test`.`t3`.`b` = 1) and (outer_field_is_not_null, (((concat(`test`.`t1`.`a`,'')) = `test`.`t3`.`a`) or (`test`.`t3`.`a` is null)), true)) having (outer_field_is_not_null, (`test`.`t3`.`a`), true)) is false)) +SELECT * +FROM t AS t1 +WHERE t1.a IN (SELECT t2.a +FROM t AS t2 +WHERE CONCAT(t2.a,'') NOT IN (SELECT t3.a +FROM t AS t3 +WHERE t3.b=1)); +a b +DROP TABLE t; +# +# Bug#24287772 SUBQUERY RETURNS EMPTY LIST WHILE IDENTICAL QUERY +# WITH JOIN RETURNS RESULT +# +CREATE TABLE t SELECT 4096 c; +SELECT c FROM t WHERE 1 IN +(SELECT t.c = page_size FROM information_schema.innodb_cmpmem); +c +4096 +DROP TABLE t; +# +# Bug #29132639: WL#12470: SIG 6 IN CONNECTJOINS|SQL/SQL_EXECUTOR.C +# +CREATE TABLE t1 ( f1 TIME, f2 VARCHAR(1) ); +INSERT INTO t1 VALUES ('08:35:24', 'X'), ('14:51:13', 'S'), ('11:22:33', 'Q'); +CREATE TABLE t2 ( pk INTEGER ); +INSERT INTO t2 VALUES (1), (2); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN FORMAT=tree SELECT * FROM t1 WHERE EXISTS ( SELECT alias1.f2 FROM t2 LEFT JOIN t1 ON 1 LEFT JOIN t1 AS alias1 ON 1 ); +EXPLAIN +-> Nested loop inner join (cost=5.40 rows=3) + -> Limit: 1 row(s) (cost=4.85 rows=1) + -> Nested loop left join (cost=4.85 rows=18) + -> Nested loop left join (cost=1.55 rows=6) + -> Table scan on t2 (cost=0.45 rows=2) + -> Table scan on t1 (cost=0.40 rows=3) + -> Table scan on alias1 (cost=5.40 rows=3) + -> Table scan on t1 (cost=0.55 rows=3) + +SELECT * FROM t1 WHERE EXISTS ( SELECT alias1.f2 FROM t2 LEFT JOIN t1 ON 1 LEFT JOIN t1 AS alias1 ON 1 ); +f1 f2 +08:35:24 X +11:22:33 Q +14:51:13 S +DROP TABLE t1, t2; +# +# Bug#51457 Firstmatch semijoin strategy gives wrong results for +# certain query plans +# +SET @@default_storage_engine='innodb'; +SET @@optimizer_switch='semijoin=on,materialization=off,firstmatch=on,loosescan=off,block_nested_loop=off,batched_key_access=off'; +CREATE TABLE t0(a INTEGER); +CREATE TABLE t1(a INTEGER); +INSERT INTO t1 VALUES(1); +CREATE TABLE t2(a INTEGER); +INSERT INTO t2 VALUES(5), (8); +CREATE TABLE t6(a INTEGER); +INSERT INTO t6 VALUES(7), (1), (0), (5), (1), (4); +CREATE TABLE t8(a INTEGER); +INSERT INTO t8 VALUES(1), (3), (5), (7), (9), (7), (3), (1); +EXPLAIN +SELECT * +FROM t2 AS nt2 +WHERE 1 IN (SELECT it1.a +FROM t1 AS it1 JOIN t6 AS it3 ON it1.a=it3.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE it1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE it3 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; FirstMatch +1 SIMPLE nt2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`nt2`.`a` AS `a` from `test`.`t2` `nt2` semi join (`test`.`t1` `it1` join `test`.`t6` `it3`) where ((`test`.`it1`.`a` = 1) and (`test`.`it3`.`a` = 1)) +SELECT * +FROM t2 AS nt2 +WHERE 1 IN (SELECT it1.a +FROM t1 AS it1 JOIN t6 AS it3 ON it1.a=it3.a); +a +5 +8 +EXPLAIN +SELECT * +FROM t2 AS nt2, t8 AS nt4 +WHERE 1 IN (SELECT it1.a +FROM t1 AS it1 JOIN t6 AS it3 ON it1.a=it3.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE it1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE it3 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; FirstMatch +1 SIMPLE nt2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE nt4 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`nt2`.`a` AS `a`,`test`.`nt4`.`a` AS `a` from `test`.`t2` `nt2` join `test`.`t8` `nt4` semi join (`test`.`t1` `it1` join `test`.`t6` `it3`) where ((`test`.`it1`.`a` = 1) and (`test`.`it3`.`a` = 1)) +SELECT * +FROM t2 AS nt2, t8 AS nt4 +WHERE 1 IN (SELECT it1.a +FROM t1 AS it1 JOIN t6 AS it3 ON it1.a=it3.a); +a a +5 1 +5 1 +5 3 +5 3 +5 5 +5 7 +5 7 +5 9 +8 1 +8 1 +8 3 +8 3 +8 5 +8 7 +8 7 +8 9 +EXPLAIN +SELECT * +FROM t0 AS ot1, t2 AS nt3 +WHERE ot1.a IN (SELECT it2.a +FROM t1 AS it2 JOIN t8 AS it4 ON it2.a=it4.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE it2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 SIMPLE it4 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; FirstMatch(ot1) +2 SIMPLE nt3 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`nt3`.`a` AS `a` from `test`.`t0` `ot1` join `test`.`t2` `nt3` semi join (`test`.`t1` `it2` join `test`.`t8` `it4`) where ((`test`.`it2`.`a` = `test`.`ot1`.`a`) and (`test`.`it4`.`a` = `test`.`ot1`.`a`)) +SELECT * +FROM t0 as ot1, t2 AS nt3 +WHERE ot1.a IN (SELECT it2.a +FROM t1 AS it2 JOIN t8 AS it4 ON it2.a=it4.a); +a a +DROP TABLE t0, t1, t2, t6, t8; +SET @@default_storage_engine=default; +SET @@optimizer_switch=default; +# End of bug#51457 +set optimizer_switch=default; +set optimizer_switch=default; diff --git a/mysql-test/r/subquery_sj_innodb_all.result-pq b/mysql-test/r/subquery_sj_innodb_all.result-pq new file mode 100644 index 000000000000..e8ede8c360ed --- /dev/null +++ b/mysql-test/r/subquery_sj_innodb_all.result-pq @@ -0,0 +1,191 @@ +set optimizer_switch='semijoin=on,materialization=on,firstmatch=on,loosescan=on,index_condition_pushdown=on,mrr=on,mrr_cost_based=off'; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9), +(10),(12),(14),(16),(18); +create table t1 ( +a int, +b int +) engine=innodb; +insert into t1 values (1,1),(1,1),(2,2); +create table t2 ( +a int, +b int, +key(b) +) engine=innodb; +insert into t2 select a, a/2 from t0; +select * from t1; +a b +1 1 +1 1 +2 2 +select * from t2; +a b +0 0 +1 1 +2 1 +3 2 +4 2 +5 3 +6 3 +7 4 +8 4 +9 5 +10 5 +12 6 +14 7 +16 8 +18 9 +explain select * from t2 where b in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using where +1 SIMPLE t2 NULL ref b b 5 .a 1 100.00 NULL +2 MATERIALIZED t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t2` semi join (`test`.`t1`) where (`test`.`t2`.`b` = ``.`a`) +select * from t2 where b in (select a from t1); +a b +1 1 +2 1 +3 2 +4 2 +truncate table t0; +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t3 ( +a int, +b int, +key(b), +pk1 char(200), pk2 char(200), pk3 char(200), +primary key(pk1, pk2, pk3) +) engine=innodb; +insert into t3 select a,a, a,a,a from t0; +explain select * from t3 where b in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using where +1 SIMPLE t3 NULL ref b b 5 .a 1 100.00 NULL +2 MATERIALIZED t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t3`.`pk1` AS `pk1`,`test`.`t3`.`pk2` AS `pk2`,`test`.`t3`.`pk3` AS `pk3` from `test`.`t3` semi join (`test`.`t1`) where (`test`.`t3`.`b` = ``.`a`) +select * from t3 where b in (select a from t1); +a b pk1 pk2 pk3 +1 1 1 1 1 +2 2 2 2 2 +set @save_max_heap_table_size= @@max_heap_table_size; +set max_heap_table_size=16384; +set @save_join_buffer_size = @@join_buffer_size; +set join_buffer_size= 8192; +drop table t3; +create table t3 ( +a int, +b int, +key(b), +pk1 char(200), pk2 char(200), +primary key(pk1, pk2) +) engine=innodb; +insert into t3 select +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; +explain select * from t3 where b in (select a from t0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Using where +1 SIMPLE t3 NULL ref b b 5 .a # 100.00 NULL +2 MATERIALIZED t0 NULL ALL NULL NULL NULL NULL # 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t3`.`pk1` AS `pk1`,`test`.`t3`.`pk2` AS `pk2` from `test`.`t3` semi join (`test`.`t0`) where (`test`.`t3`.`b` = ``.`a`) +select * from t3 where b in (select a.a+b.a from t0 a, t0 b where b.a<5); +a b pk1 pk2 +0 0 0 0 +1 1 1 1 +10 10 10 10 +11 11 11 11 +12 12 12 12 +13 13 13 13 +2 2 2 2 +3 3 3 3 +4 4 4 4 +5 5 5 5 +6 6 6 6 +7 7 7 7 +8 8 8 8 +9 9 9 9 +set join_buffer_size= @save_join_buffer_size; +set max_heap_table_size= @save_max_heap_table_size; +explain select * from t1 where a in (select b from t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 SIMPLE t2 NULL ref b b 5 test.t1.a 1 100.00 Using index; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t2`) where (`test`.`t2`.`b` = `test`.`t1`.`a`) +select * from t1; +a b +1 1 +1 1 +2 2 +select * from t1 where a in (select b from t2); +a b +1 1 +1 1 +2 2 +drop table t0, t1, t2, t3; +create table t1 (a int); +insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t2 (a char(200), b char(200), c char(200), primary key (a,b,c)) engine=innodb; +insert into t2 select concat(a, repeat('X',198)),repeat('B',200),repeat('B',200) from t1; +insert into t2 select concat(a, repeat('Y',198)),repeat('B',200),repeat('B',200) from t1; +alter table t2 add filler1 int; +insert into t1 select A.a + 10*(B.a + 10*C.a) from t1 A, t1 B, t1 C; +set @save_join_buffer_size=@@join_buffer_size; +set join_buffer_size=1; +select * from t2 where filler1 in ( select a from t1); +a b c filler1 +set join_buffer_size=default; +drop table t1, t2; + +BUG#42740: crash in optimize_semijoin_nests + +create table t1 (c6 timestamp,key (c6)) engine=innodb; +create table t2 (c2 double) engine=innodb; +explain select 1 from t2 where c2 = any (select log10(null) from t1 where c6 NULL ALL NULL NULL NULL NULL NULL 100.00 Using where +1 SIMPLE t2 NULL ref b b 5 .a 1 100.00 Using join buffer (Batched Key Access) +2 MATERIALIZED t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t2` semi join (`test`.`t1`) where (`test`.`t2`.`b` = ``.`a`) +select * from t2 where b in (select a from t1); +a b +1 1 +2 1 +3 2 +4 2 +truncate table t0; +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t3 ( +a int, +b int, +key(b), +pk1 char(200), pk2 char(200), pk3 char(200), +primary key(pk1, pk2, pk3) +) engine=innodb; +insert into t3 select a,a, a,a,a from t0; +explain select * from t3 where b in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using where +1 SIMPLE t3 NULL ref b b 5 .a 1 100.00 Using join buffer (Batched Key Access) +2 MATERIALIZED t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t3`.`pk1` AS `pk1`,`test`.`t3`.`pk2` AS `pk2`,`test`.`t3`.`pk3` AS `pk3` from `test`.`t3` semi join (`test`.`t1`) where (`test`.`t3`.`b` = ``.`a`) +select * from t3 where b in (select a from t1); +a b pk1 pk2 pk3 +1 1 1 1 1 +2 2 2 2 2 +set @save_max_heap_table_size= @@max_heap_table_size; +set max_heap_table_size=16384; +set @save_join_buffer_size = @@join_buffer_size; +set join_buffer_size= 8192; +drop table t3; +create table t3 ( +a int, +b int, +key(b), +pk1 char(200), pk2 char(200), +primary key(pk1, pk2) +) engine=innodb; +insert into t3 select +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; +explain select * from t3 where b in (select a from t0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Using where +1 SIMPLE t3 NULL ref b b 5 .a # 100.00 Using join buffer (Batched Key Access) +2 MATERIALIZED t0 NULL ALL NULL NULL NULL NULL # 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t3`.`pk1` AS `pk1`,`test`.`t3`.`pk2` AS `pk2` from `test`.`t3` semi join (`test`.`t0`) where (`test`.`t3`.`b` = ``.`a`) +select * from t3 where b in (select a.a+b.a from t0 a, t0 b where b.a<5); +a b pk1 pk2 +0 0 0 0 +1 1 1 1 +10 10 10 10 +11 11 11 11 +12 12 12 12 +13 13 13 13 +2 2 2 2 +3 3 3 3 +4 4 4 4 +5 5 5 5 +6 6 6 6 +7 7 7 7 +8 8 8 8 +9 9 9 9 +set join_buffer_size= @save_join_buffer_size; +set max_heap_table_size= @save_max_heap_table_size; +explain select * from t1 where a in (select b from t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 SIMPLE t2 NULL ref b b 5 test.t1.a 1 100.00 Using index; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t2`) where (`test`.`t2`.`b` = `test`.`t1`.`a`) +select * from t1; +a b +1 1 +1 1 +2 2 +select * from t1 where a in (select b from t2); +a b +1 1 +1 1 +2 2 +drop table t0, t1, t2, t3; +create table t1 (a int); +insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t2 (a char(200), b char(200), c char(200), primary key (a,b,c)) engine=innodb; +insert into t2 select concat(a, repeat('X',198)),repeat('B',200),repeat('B',200) from t1; +insert into t2 select concat(a, repeat('Y',198)),repeat('B',200),repeat('B',200) from t1; +alter table t2 add filler1 int; +insert into t1 select A.a + 10*(B.a + 10*C.a) from t1 A, t1 B, t1 C; +set @save_join_buffer_size=@@join_buffer_size; +set join_buffer_size=1; +select * from t2 where filler1 in ( select a from t1); +a b c filler1 +set join_buffer_size=default; +drop table t1, t2; + +BUG#42740: crash in optimize_semijoin_nests + +create table t1 (c6 timestamp,key (c6)) engine=innodb; +create table t2 (c2 double) engine=innodb; +explain select 1 from t2 where c2 = any (select log10(null) from t1 where c6 NULL ALL NULL NULL NULL NULL NULL 100.00 Using where +1 SIMPLE t2 NULL ref b b 5 .a 1 100.00 Using join buffer (Batched Key Access) +2 MATERIALIZED t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t2` semi join (`test`.`t1`) where (`test`.`t2`.`b` = ``.`a`) +select * from t2 where b in (select a from t1); +a b +1 1 +2 1 +3 2 +4 2 +truncate table t0; +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t3 ( +a int, +b int, +key(b), +pk1 char(200), pk2 char(200), pk3 char(200), +primary key(pk1, pk2, pk3) +) engine=innodb; +insert into t3 select a,a, a,a,a from t0; +explain select * from t3 where b in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using where +1 SIMPLE t3 NULL ref b b 5 .a 1 100.00 Using join buffer (Batched Key Access) +2 MATERIALIZED t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t3`.`pk1` AS `pk1`,`test`.`t3`.`pk2` AS `pk2`,`test`.`t3`.`pk3` AS `pk3` from `test`.`t3` semi join (`test`.`t1`) where (`test`.`t3`.`b` = ``.`a`) +select * from t3 where b in (select a from t1); +a b pk1 pk2 pk3 +1 1 1 1 1 +2 2 2 2 2 +set @save_max_heap_table_size= @@max_heap_table_size; +set max_heap_table_size=16384; +set @save_join_buffer_size = @@join_buffer_size; +set join_buffer_size= 8192; +drop table t3; +create table t3 ( +a int, +b int, +key(b), +pk1 char(200), pk2 char(200), +primary key(pk1, pk2) +) engine=innodb; +insert into t3 select +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; +explain select * from t3 where b in (select a from t0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Using where +1 SIMPLE t3 NULL ref b b 5 .a # 100.00 Using join buffer (Batched Key Access) +2 MATERIALIZED t0 NULL ALL NULL NULL NULL NULL # 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t3`.`pk1` AS `pk1`,`test`.`t3`.`pk2` AS `pk2` from `test`.`t3` semi join (`test`.`t0`) where (`test`.`t3`.`b` = ``.`a`) +select * from t3 where b in (select a.a+b.a from t0 a, t0 b where b.a<5); +a b pk1 pk2 +0 0 0 0 +1 1 1 1 +10 10 10 10 +11 11 11 11 +12 12 12 12 +13 13 13 13 +2 2 2 2 +3 3 3 3 +4 4 4 4 +5 5 5 5 +6 6 6 6 +7 7 7 7 +8 8 8 8 +9 9 9 9 +set join_buffer_size= @save_join_buffer_size; +set max_heap_table_size= @save_max_heap_table_size; +explain select * from t1 where a in (select b from t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 SIMPLE t2 NULL ref b b 5 test.t1.a 1 100.00 Using index; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t2`) where (`test`.`t2`.`b` = `test`.`t1`.`a`) +select * from t1; +a b +1 1 +1 1 +2 2 +select * from t1 where a in (select b from t2); +a b +1 1 +1 1 +2 2 +drop table t0, t1, t2, t3; +create table t1 (a int); +insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t2 (a char(200), b char(200), c char(200), primary key (a,b,c)) engine=innodb; +insert into t2 select concat(a, repeat('X',198)),repeat('B',200),repeat('B',200) from t1; +insert into t2 select concat(a, repeat('Y',198)),repeat('B',200),repeat('B',200) from t1; +alter table t2 add filler1 int; +insert into t1 select A.a + 10*(B.a + 10*C.a) from t1 A, t1 B, t1 C; +set @save_join_buffer_size=@@join_buffer_size; +set join_buffer_size=1; +select * from t2 where filler1 in ( select a from t1); +a b c filler1 +set join_buffer_size=default; +drop table t1, t2; + +BUG#42740: crash in optimize_semijoin_nests + +create table t1 (c6 timestamp,key (c6)) engine=innodb; +create table t2 (c2 double) engine=innodb; +explain select 1 from t2 where c2 = any (select log10(null) from t1 where c6 30); +a +2 +4 +explain select * from t2 where t2.a in (select a from t1 where t1.b <> 30); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL PRIMARY NULL NULL NULL 4 75.00 Using where +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`a` = `test`.`t1`.`a`) and (`test`.`t1`.`b` <> 30)) +select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a); +a +2 +3 +explain select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL index PRIMARY PRIMARY 4 NULL 3 100.00 Using index +1 SIMPLE t1 NULL ALL PRIMARY NULL NULL NULL 4 25.00 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t1` join `test`.`t3` join `test`.`t2` where ((`test`.`t2`.`a` = `test`.`t1`.`a`) and (`test`.`t1`.`b` = `test`.`t3`.`a`)) +drop table t1, t2, t3; +create table t1 (a int, b int, index a (a,b)); +create table t2 (a int, index a (a)); +create table t3 (a int, b int, index a (a)); +insert into t1 values (1,10), (2,20), (3,30), (4,40); +create table t0(a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +insert into t1 +select rand()*100000+200,rand()*100000 from t0 A, t0 B, t0 C, t0 D; +insert into t2 values (2), (3), (4), (5); +insert into t3 values (10,3), (20,4), (30,5); +select * from t2 where t2.a in (select a from t1); +a +2 +3 +4 +explain select * from t2 where t2.a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index a a 10 NULL 10004 100.00 Using index; LooseScan +1 SIMPLE t2 NULL index a a 5 NULL 4 25.00 Using where; Using index; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1`) where (`test`.`t2`.`a` = `test`.`t1`.`a`) +select * from t2 where t2.a in (select a from t1 where t1.b <> 30); +a +2 +4 +explain select * from t2 where t2.a in (select a from t1 where t1.b <> 30); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index a a 10 NULL 10004 90.00 Using where; Using index; LooseScan +1 SIMPLE t2 NULL index a a 5 NULL 4 25.00 Using where; Using index; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1`) where ((`test`.`t2`.`a` = `test`.`t1`.`a`) and (`test`.`t1`.`b` <> 30)) +select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a); +a +2 +3 +explain select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index a a 10 NULL 10004 100.00 Using where; Using index; LooseScan +1 SIMPLE t3 NULL ref a a 5 test.t1.b 2 100.00 Using index; FirstMatch(t1) +1 SIMPLE t2 NULL index a a 5 NULL 4 25.00 Using where; Using index; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1` join `test`.`t3`) where ((`test`.`t2`.`a` = `test`.`t1`.`a`) and (`test`.`t3`.`a` = `test`.`t1`.`b`)) +insert into t1 values (3,31); +select * from t2 where t2.a in (select a from t1 where t1.b <> 30); +a +2 +3 +4 +select * from t2 where t2.a in (select a from t1 where t1.b <> 30 and t1.b <> 31); +a +2 +4 +explain select * from t2 where t2.a in (select a from t1 where t1.b <> 30); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index a a 10 NULL 10005 90.00 Using where; Using index; LooseScan +1 SIMPLE t2 NULL index a a 5 NULL 4 25.00 Using where; Using index; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1`) where ((`test`.`t2`.`a` = `test`.`t1`.`a`) and (`test`.`t1`.`b` <> 30)) +drop table t0, t1, t2, t3; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1(a int, b int); +insert into t1 values (0,0),(1,1),(2,2); +create table t2 as select * from t1; +create table t11(a int, b int); +create table t10 (pk int, a int, primary key(pk)); +insert into t10 select a,a from t0; +create table t12 like t10; +insert into t12 select * from t10; +Flattened because of dependency, t10=func(t1) +explain select * from t1 where a in (select pk from t10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t1` where (`test`.`t10`.`pk` = `test`.`t1`.`a`) +select * from t1 where a in (select pk from t10); +a b +0 0 +1 1 +2 2 +A confluent case of dependency +explain select * from t1 where a in (select a from t10 where pk=12); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t1` where (multiple equal(12, NULL) and multiple equal(`test`.`t1`.`a`, NULL)) +select * from t1 where a in (select a from t10 where pk=12); +a b +explain select * from t1 where a in (select a from t10 where pk=9); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t10 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t1` where ((`test`.`t1`.`a` = '9')) +select * from t1 where a in (select a from t10 where pk=9); +a b +An empty table inside +explain select * from t1 where a in (select a from t11); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t11 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t11`) where (`test`.`t1`.`a` = `test`.`t11`.`a`) +select * from t1 where a in (select a from t11); +a b +explain select * from t1 where a in (select pk from t10) and b in (select pk from t10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using index +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.t1.b 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t10` join `test`.`t1` where ((`test`.`t10`.`pk` = `test`.`t1`.`b`) and (`test`.`t10`.`pk` = `test`.`t1`.`a`)) +select * from t1 where a in (select pk from t10) and b in (select pk from t10); +a b +0 0 +1 1 +2 2 +flattening a nested subquery +explain select * from t1 where a in (select pk from t10 where t10.a in (select pk from t12)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using where +1 SIMPLE t12 NULL eq_ref PRIMARY PRIMARY 4 test.t10.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t12` join `test`.`t1` where ((`test`.`t10`.`pk` = `test`.`t1`.`a`) and (`test`.`t12`.`pk` = `test`.`t10`.`a`)) +select * from t1 where a in (select pk from t10 where t10.a in (select pk from t12)); +a b +0 0 +1 1 +2 2 +flattening subquery w/ several tables +explain select * from t1 where a in (select t10.pk from t10, t12 where t12.pk=t10.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using where +1 SIMPLE t12 NULL eq_ref PRIMARY PRIMARY 4 test.t10.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t12` join `test`.`t1` where ((`test`.`t10`.`pk` = `test`.`t1`.`a`) and (`test`.`t12`.`pk` = `test`.`t10`.`a`)) +subqueries within outer joins go into ON expr. +explain +select * from t1 left join (t2 A, t2 B) on ( A.A= t1.A and B.A in (select pk from t10)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE A NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE B NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.B.A 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`A` AS `A`,`test`.`t1`.`B` AS `B`,`test`.`A`.`A` AS `A`,`test`.`A`.`B` AS `B`,`test`.`B`.`A` AS `A`,`test`.`B`.`B` AS `B` from `test`.`t1` left join (`test`.`t10` join `test`.`t2` `A` join `test`.`t2` `B`) on(((`test`.`t10`.`pk` = `test`.`B`.`A`) and (`test`.`A`.`A` = `test`.`t1`.`A`))) where true +t2 should be wrapped into OJ-nest, so we have "t1 LJ (t2 J t10)" +explain +select * from t1 left join t2 on (t2.A= t1.A and t2.A in (select pk from t10)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.t1.A 1 100.00 Using index +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`A` AS `A`,`test`.`t1`.`B` AS `B`,`test`.`t2`.`A` AS `A`,`test`.`t2`.`B` AS `B` from `test`.`t1` left join (`test`.`t10` join `test`.`t2`) on(((`test`.`t10`.`pk` = `test`.`t1`.`A`) and (`test`.`t2`.`A` = `test`.`t1`.`A`))) where true +we shouldn't flatten if we're going to get a join of > MAX_TABLES. +explain select * from +t1 s00, t1 s01, t1 s02, t1 s03, t1 s04,t1 s05,t1 s06,t1 s07,t1 s08,t1 s09, +t1 s10, t1 s11, t1 s12, t1 s13, t1 s14,t1 s15,t1 s16,t1 s17,t1 s18,t1 s19, +t1 s20, t1 s21, t1 s22, t1 s23, t1 s24,t1 s25,t1 s26,t1 s27,t1 s28,t1 s29, +t1 s30, t1 s31, t1 s32, t1 s33, t1 s34,t1 s35,t1 s36,t1 s37,t1 s38,t1 s39, +t1 s40, t1 s41, t1 s42, t1 s43, t1 s44,t1 s45,t1 s46,t1 s47,t1 s48,t1 s49 +where +s00.a in ( +select m00.a from +t1 m00, t1 m01, t1 m02, t1 m03, t1 m04,t1 m05,t1 m06,t1 m07,t1 m08,t1 m09, +t1 m10, t1 m11, t1 m12, t1 m13, t1 m14,t1 m15,t1 m16,t1 m17,t1 m18,t1 m19 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY s00 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 PRIMARY s01 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s02 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s03 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s04 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s05 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s06 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s07 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s08 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s09 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s10 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s11 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s12 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s13 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s14 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s15 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s16 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s17 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s18 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s19 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s20 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s21 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s22 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s23 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s24 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s25 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s26 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s27 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s28 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s29 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s30 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s31 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s32 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s33 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s34 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s35 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s36 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s37 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s38 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s39 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s40 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s41 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s42 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s43 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s44 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s45 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s46 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s47 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s48 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s49 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m00 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +2 DEPENDENT SUBQUERY m01 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m02 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m03 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m04 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m05 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m06 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m07 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m08 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m09 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m10 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m11 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m12 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m13 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m14 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m15 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m16 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m17 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m18 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m19 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`s00`.`a` AS `a`,`test`.`s00`.`b` AS `b`,`test`.`s01`.`a` AS `a`,`test`.`s01`.`b` AS `b`,`test`.`s02`.`a` AS `a`,`test`.`s02`.`b` AS `b`,`test`.`s03`.`a` AS `a`,`test`.`s03`.`b` AS `b`,`test`.`s04`.`a` AS `a`,`test`.`s04`.`b` AS `b`,`test`.`s05`.`a` AS `a`,`test`.`s05`.`b` AS `b`,`test`.`s06`.`a` AS `a`,`test`.`s06`.`b` AS `b`,`test`.`s07`.`a` AS `a`,`test`.`s07`.`b` AS `b`,`test`.`s08`.`a` AS `a`,`test`.`s08`.`b` AS `b`,`test`.`s09`.`a` AS `a`,`test`.`s09`.`b` AS `b`,`test`.`s10`.`a` AS `a`,`test`.`s10`.`b` AS `b`,`test`.`s11`.`a` AS `a`,`test`.`s11`.`b` AS `b`,`test`.`s12`.`a` AS `a`,`test`.`s12`.`b` AS `b`,`test`.`s13`.`a` AS `a`,`test`.`s13`.`b` AS `b`,`test`.`s14`.`a` AS `a`,`test`.`s14`.`b` AS `b`,`test`.`s15`.`a` AS `a`,`test`.`s15`.`b` AS `b`,`test`.`s16`.`a` AS `a`,`test`.`s16`.`b` AS `b`,`test`.`s17`.`a` AS `a`,`test`.`s17`.`b` AS `b`,`test`.`s18`.`a` AS `a`,`test`.`s18`.`b` AS `b`,`test`.`s19`.`a` AS `a`,`test`.`s19`.`b` AS `b`,`test`.`s20`.`a` AS `a`,`test`.`s20`.`b` AS `b`,`test`.`s21`.`a` AS `a`,`test`.`s21`.`b` AS `b`,`test`.`s22`.`a` AS `a`,`test`.`s22`.`b` AS `b`,`test`.`s23`.`a` AS `a`,`test`.`s23`.`b` AS `b`,`test`.`s24`.`a` AS `a`,`test`.`s24`.`b` AS `b`,`test`.`s25`.`a` AS `a`,`test`.`s25`.`b` AS `b`,`test`.`s26`.`a` AS `a`,`test`.`s26`.`b` AS `b`,`test`.`s27`.`a` AS `a`,`test`.`s27`.`b` AS `b`,`test`.`s28`.`a` AS `a`,`test`.`s28`.`b` AS `b`,`test`.`s29`.`a` AS `a`,`test`.`s29`.`b` AS `b`,`test`.`s30`.`a` AS `a`,`test`.`s30`.`b` AS `b`,`test`.`s31`.`a` AS `a`,`test`.`s31`.`b` AS `b`,`test`.`s32`.`a` AS `a`,`test`.`s32`.`b` AS `b`,`test`.`s33`.`a` AS `a`,`test`.`s33`.`b` AS `b`,`test`.`s34`.`a` AS `a`,`test`.`s34`.`b` AS `b`,`test`.`s35`.`a` AS `a`,`test`.`s35`.`b` AS `b`,`test`.`s36`.`a` AS `a`,`test`.`s36`.`b` AS `b`,`test`.`s37`.`a` AS `a`,`test`.`s37`.`b` AS `b`,`test`.`s38`.`a` AS `a`,`test`.`s38`.`b` AS `b`,`test`.`s39`.`a` AS `a`,`test`.`s39`.`b` AS `b`,`test`.`s40`.`a` AS `a`,`test`.`s40`.`b` AS `b`,`test`.`s41`.`a` AS `a`,`test`.`s41`.`b` AS `b`,`test`.`s42`.`a` AS `a`,`test`.`s42`.`b` AS `b`,`test`.`s43`.`a` AS `a`,`test`.`s43`.`b` AS `b`,`test`.`s44`.`a` AS `a`,`test`.`s44`.`b` AS `b`,`test`.`s45`.`a` AS `a`,`test`.`s45`.`b` AS `b`,`test`.`s46`.`a` AS `a`,`test`.`s46`.`b` AS `b`,`test`.`s47`.`a` AS `a`,`test`.`s47`.`b` AS `b`,`test`.`s48`.`a` AS `a`,`test`.`s48`.`b` AS `b`,`test`.`s49`.`a` AS `a`,`test`.`s49`.`b` AS `b` from `test`.`t1` `s00` join `test`.`t1` `s01` join `test`.`t1` `s02` join `test`.`t1` `s03` join `test`.`t1` `s04` join `test`.`t1` `s05` join `test`.`t1` `s06` join `test`.`t1` `s07` join `test`.`t1` `s08` join `test`.`t1` `s09` join `test`.`t1` `s10` join `test`.`t1` `s11` join `test`.`t1` `s12` join `test`.`t1` `s13` join `test`.`t1` `s14` join `test`.`t1` `s15` join `test`.`t1` `s16` join `test`.`t1` `s17` join `test`.`t1` `s18` join `test`.`t1` `s19` join `test`.`t1` `s20` join `test`.`t1` `s21` join `test`.`t1` `s22` join `test`.`t1` `s23` join `test`.`t1` `s24` join `test`.`t1` `s25` join `test`.`t1` `s26` join `test`.`t1` `s27` join `test`.`t1` `s28` join `test`.`t1` `s29` join `test`.`t1` `s30` join `test`.`t1` `s31` join `test`.`t1` `s32` join `test`.`t1` `s33` join `test`.`t1` `s34` join `test`.`t1` `s35` join `test`.`t1` `s36` join `test`.`t1` `s37` join `test`.`t1` `s38` join `test`.`t1` `s39` join `test`.`t1` `s40` join `test`.`t1` `s41` join `test`.`t1` `s42` join `test`.`t1` `s43` join `test`.`t1` `s44` join `test`.`t1` `s45` join `test`.`t1` `s46` join `test`.`t1` `s47` join `test`.`t1` `s48` join `test`.`t1` `s49` where (`test`.`s00`.`a`,(/* select#2 */ select `test`.`m00`.`a` from `test`.`t1` `m00` join `test`.`t1` `m01` join `test`.`t1` `m02` join `test`.`t1` `m03` join `test`.`t1` `m04` join `test`.`t1` `m05` join `test`.`t1` `m06` join `test`.`t1` `m07` join `test`.`t1` `m08` join `test`.`t1` `m09` join `test`.`t1` `m10` join `test`.`t1` `m11` join `test`.`t1` `m12` join `test`.`t1` `m13` join `test`.`t1` `m14` join `test`.`t1` `m15` join `test`.`t1` `m16` join `test`.`t1` `m17` join `test`.`t1` `m18` join `test`.`t1` `m19` where ((`test`.`s00`.`a`) = `test`.`m00`.`a`))) +select * from +t1 left join t2 on (t2.a= t1.a and t2.a in (select pk from t10)) +where t1.a < 5; +a b a b +0 0 0 0 +1 1 1 1 +2 2 2 2 +prepare s1 from +' select * from + t1 left join t2 on (t2.a= t1.a and t2.a in (select pk from t10)) + where t1.a < 5'; +execute s1; +a b a b +0 0 0 0 +1 1 1 1 +2 2 2 2 +execute s1; +a b a b +0 0 0 0 +1 1 1 1 +2 2 2 2 +insert into t1 select (A.a + 10 * B.a),1 from t0 A, t0 B; +explain select * from t1 where a in (select pk from t10 where pk<3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t10 NULL range PRIMARY PRIMARY 4 NULL 4 100.00 Using where; Using index +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 103 10.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t1` where ((`test`.`t1`.`a` = `test`.`t10`.`pk`) and (`test`.`t10`.`pk` < 3)) +drop table t0, t1, t2; +drop table t10, t11, t12; +# +# Check that subqueries with outer joins or straight_join work for +# different permutations of const and non-const tables. (Ref. Bug#46692) +# +CREATE TABLE t1 (i INTEGER); +CREATE TABLE t2 (i INTEGER); +CREATE TABLE t3 (i INTEGER); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 0 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 0 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 0 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 1 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 1 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 1 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 2 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 2 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 2 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (0); +DELETE FROM t2; +INSERT INTO t1 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 0 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 0 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 0 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 1 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 1 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 1 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 2 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 2 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 2 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (0); +DELETE FROM t2; +INSERT INTO t1 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 0 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = `test`.`t2`.`i`) and (`test`.`t1`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = `test`.`t2`.`i`) and (`test`.`t1`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = `test`.`t2`.`i`) and (`test`.`t1`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 0 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = `test`.`t2`.`i`) and (`test`.`t1`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = `test`.`t2`.`i`) and (`test`.`t1`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = `test`.`t2`.`i`) and (`test`.`t1`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 0 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t2`.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t2`.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t2`.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +1 +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 1 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = `test`.`t3`.`i`) and (`test`.`t1`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = `test`.`t3`.`i`) and (`test`.`t1`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = `test`.`t3`.`i`) and (`test`.`t1`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 1 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = `test`.`t2`.`i`) and (`test`.`t1`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = `test`.`t2`.`i`) and (`test`.`t1`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = `test`.`t2`.`i`) and (`test`.`t1`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 1 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t2`.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t2`.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t2`.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +1 +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +1 +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 2 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t3`.`i`) and (`test`.`t2`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t3`.`i`) and (`test`.`t2`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t3`.`i`) and (`test`.`t2`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 2 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t3`.`i`) and (`test`.`t2`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t3`.`i`) and (`test`.`t2`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t3`.`i`) and (`test`.`t2`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 2 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t2`.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +1 +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +1 +2 + +EXECUTE stmt; +i +1 +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t2`.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +1 +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t2`.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +1 +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +1 +2 + +EXECUTE stmt; +i +1 +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +1 +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +1 +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (0); +DELETE FROM t2; +INSERT INTO t1 VALUES (0); +DROP TABLE t1, t2, t3; +create table x1(k int primary key, d1 int, d2 int); +create table x2(k int primary key, d1 int, d2 int); +insert into x1 values +(10, 10, 10), +(20, 20, 20), +(21, 20, null), +(30, null, 30), +(40, 40, 40); +insert into x2 values +(10, 10, 10), +(20, 20, 20), +(21, 20, null), +(30, null, 30); +select * +from x1 +where (d1, d2) in (select d1, d2 +from x2); +k d1 d2 +10 10 10 +20 20 20 +select * +from x1 +where (d1, d2) in (select d1, d2 +from x2) is true; +k d1 d2 +10 10 10 +20 20 20 +select * +from x1 +where (d1, d2) in (select d1, d2 +from x2) is false; +k d1 d2 +40 40 40 +select * +from x1 +where (d1, d2) in (select d1, d2 +from x2) is unknown; +k d1 d2 +21 20 NULL +30 NULL 30 +select * +from x1 +where d1 in (select d1 +from x2 +where x1.d2=x2.d2); +k d1 d2 +10 10 10 +20 20 20 +select * +from x1 +where d1 in (select d1 +from x2 +where x1.d2=x2.d2) is true; +k d1 d2 +10 10 10 +20 20 20 +select * +from x1 +where d1 in (select d1 +from x2 +where x1.d2=x2.d2) is false; +k d1 d2 +21 20 NULL +40 40 40 +select * +from x1 +where d1 in (select d1 +from x2 +where x1.d2=x2.d2) is unknown; +k d1 d2 +30 NULL 30 +select * +from x1 +where 1 in (select 1 +from x2 +where x1.d1=x2.d1 and x1.d2=x2.d2); +k d1 d2 +10 10 10 +20 20 20 +select * +from x1 +where 1 in (select 1 +from x2 +where x1.d1=x2.d1 and x1.d2=x2.d2) is true; +k d1 d2 +10 10 10 +20 20 20 +select * +from x1 +where 1 in (select 1 +from x2 +where x1.d1=x2.d1 and x1.d2=x2.d2) is false; +k d1 d2 +21 20 NULL +30 NULL 30 +40 40 40 +select * +from x1 +where 1 in (select 1 +from x2 +where x1.d1=x2.d1 and x1.d2=x2.d2) is unknown; +k d1 d2 +select * +from x1 +where exists (select * +from x2 +where x1.d1=x2.d1 and x1.d2=x2.d2); +k d1 d2 +10 10 10 +20 20 20 +drop table x1; +drop table x2; +CREATE TABLE t1 ( +a int(11) NOT NULL, +b int(11) NOT NULL, +c datetime default NULL, +PRIMARY KEY (a), +KEY idx_bc (b,c) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES +(406989,67,'2006-02-23 17:08:46'), (150078,67,'2005-10-26 11:17:45'), +(406993,67,'2006-02-27 11:20:57'), (245655,67,'2005-12-08 15:59:08'), +(406994,67,'2006-02-27 11:26:46'), (256,67,NULL), +(398341,67,'2006-02-20 04:48:44'), (254,67,NULL),(1120,67,NULL), +(406988,67,'2006-02-23 17:07:22'), (255,67,NULL), +(398340,67,'2006-02-20 04:38:53'),(406631,67,'2006-02-23 10:49:42'), +(245653,67,'2005-12-08 15:59:07'),(406992,67,'2006-02-24 16:47:18'), +(245654,67,'2005-12-08 15:59:08'),(406995,67,'2006-02-28 11:55:00'), +(127261,67,'2005-10-13 12:17:58'),(406991,67,'2006-02-24 16:42:32'), +(245652,67,'2005-12-08 15:58:27'),(398545,67,'2006-02-20 04:53:13'), +(154504,67,'2005-10-28 11:53:01'),(9199,67,NULL),(1,67,'2006-02-23 15:01:35'), +(223456,67,NULL),(4101,67,NULL),(1133,67,NULL), +(406990,67,'2006-02-23 18:01:45'),(148815,67,'2005-10-25 15:34:17'), +(148812,67,'2005-10-25 15:30:01'),(245651,67,'2005-12-08 15:58:27'), +(154503,67,'2005-10-28 11:52:38'); +create table t11 select * from t1 where b = 67 AND (c IS NULL OR c > NOW()) order by 3 asc; +create table t12 select * from t1 where b = 67 AND (c IS NULL OR c > NOW()) order by 3 desc; +create table t21 select * from t1 where b = 67 AND (c IS NULL OR c > '2005-12-08') order by 3 asc; +create table t22 select * from t1 where b = 67 AND (c IS NULL OR c > '2005-12-08') order by 3 desc; +update t22 set c = '2005-12-08 15:58:27' where a = 255; +explain select t21.* from t21,t22 where t21.a = t22.a and +t22.a in (select t12.a from t11, t12 where t11.a in(255,256) and t11.a = t12.a and t11.c is null) and t22.c is null order by t21.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t11 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; Using temporary; Using filesort; Start temporary +1 SIMPLE t12 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; Using join buffer (hash join) +1 SIMPLE t22 NULL ALL NULL NULL NULL NULL 26 3.85 Using where; End temporary; Using join buffer (hash join) +1 SIMPLE t21 NULL ALL NULL NULL NULL NULL 26 10.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t21`.`a` AS `a`,`test`.`t21`.`b` AS `b`,`test`.`t21`.`c` AS `c` from `test`.`t21` join `test`.`t22` semi join (`test`.`t11` join `test`.`t12`) where ((`test`.`t12`.`a` = `test`.`t11`.`a`) and (`test`.`t22`.`a` = `test`.`t11`.`a`) and (`test`.`t21`.`a` = `test`.`t11`.`a`) and (`test`.`t22`.`c` is null) and (`test`.`t11`.`a` in (255,256)) and (`test`.`t11`.`c` is null)) order by `test`.`t21`.`a` +explain format=json select * from t1 where a in (select a from t11); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "6.71" + }, + "duplicates_removal": { + "using_temporary_table": true, + "nested_loop": [ + { + "table": { + "table_name": "t11", + "access_type": "ALL", + "rows_examined_per_scan": 8, + "rows_produced_per_join": 8, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "0.80", + "prefix_cost": "1.31", + "data_read_per_join": "128" + }, + "used_columns": [ + "a" + ] + } + }, + { + "table": { + "table_name": "t1", + "access_type": "eq_ref", + "possible_keys": [ + "PRIMARY" + ], + "key": "PRIMARY", + "used_key_parts": [ + "a" + ], + "key_length": "4", + "ref": [ + "test.t11.a" + ], + "rows_examined_per_scan": 1, + "rows_produced_per_join": 8, + "filtered": "100.00", + "cost_info": { + "read_cost": "2.00", + "eval_cost": "0.80", + "prefix_cost": "6.71", + "data_read_per_join": "128" + }, + "used_columns": [ + "a", + "b", + "c" + ] + } + } + ] + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` semi join (`test`.`t11`) where (`test`.`t1`.`a` = `test`.`t11`.`a`) +select t21.* from t21,t22 where t21.a = t22.a and +t22.a in (select t12.a from t11, t12 where t11.a in(255,256) and t11.a = t12.a and t11.c is null) and t22.c is null order by t21.a; +a b c +256 67 NULL +drop table t1, t11, t12, t21, t22; +create table t1(a int); +insert into t1 values (0),(1); +explain +select (select max(y.a) from t1 y where a in (select a from t1 z) and a < x.a) as subq from t1 x; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY x NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DEPENDENT SUBQUERY y NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +2 DEPENDENT SUBQUERY z NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.x.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select (/* select#2 */ select max(`test`.`y`.`a`) from `test`.`t1` `y` semi join (`test`.`t1` `z`) where ((`test`.`z`.`a` = `test`.`y`.`a`) and (`test`.`y`.`a` < `test`.`x`.`a`))) AS `subq` from `test`.`t1` `x` +select (select max(y.a) from t1 y where a in (select a from t1 z) and a < x.a) as subq from t1 x; +subq +NULL +0 +drop table t1; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 as select * from t0; +insert into t1 select a+10 from t0; +insert into t0 values(2); +explain select * from t1 where 2 in (select a from t0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 11 10.00 Using where; Start temporary; End temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 20 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t0`) where (`test`.`t0`.`a` = 2) +select * from t1 where 2 in (select a from t0); +a +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +explain select * from (select a from t0) x where a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 20 100.00 Start temporary +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 11 10.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a` from `test`.`t0` semi join (`test`.`t1`) where (`test`.`t0`.`a` = `test`.`t1`.`a`) +explain format=json select * from (select a from t0) x where a in (select a from t1); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "28.32" + }, + "duplicates_removal": { + "using_temporary_table": true, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 20, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "2.00", + "prefix_cost": "2.51", + "data_read_per_join": "160" + }, + "used_columns": [ + "a" + ] + } + }, + { + "table": { + "table_name": "t0", + "access_type": "ALL", + "rows_examined_per_scan": 11, + "rows_produced_per_join": 1, + "filtered": "10.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.11", + "prefix_cost": "28.32", + "data_read_per_join": "8" + }, + "used_columns": [ + "a" + ], + "attached_condition": "(`test`.`t0`.`a` = `test`.`t1`.`a`)" + } + } + ] + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a` from `test`.`t0` semi join (`test`.`t1`) where (`test`.`t0`.`a` = `test`.`t1`.`a`) +drop table t0, t1; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (kp1 int, kp2 int, c int, filler char(100), key(kp1, kp2)); +insert into t1 select A.a+10*(B.a+10*C.a), 0, 0, 'filler' from t0 A, t0 B, t0 C; +insert into t1 select * from t1 where kp1 < 20; +create table t3 (a int); +insert into t3 select A.a + 10*B.a from t0 A, t0 B; +explain select * from t3 where a in (select kp1 from t1 where kp1<20); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range kp1 kp1 5 NULL 48 100.00 Using where; Using index; LooseScan +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 100 10.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a` from `test`.`t3` semi join (`test`.`t1`) where ((`test`.`t3`.`a` = `test`.`t1`.`kp1`) and (`test`.`t1`.`kp1` < 20)) +select * from t3 where a in (select kp1 from t1 where kp1<20); +a +0 +1 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +2 +3 +4 +5 +6 +7 +8 +9 +explain select * from t3 where a in (select kp1 from t1 where kp1<20) and a<20; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range kp1 kp1 5 NULL 48 100.00 Using where; Using index; LooseScan +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 100 3.33 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a` from `test`.`t3` semi join (`test`.`t1`) where ((`test`.`t3`.`a` = `test`.`t1`.`kp1`) and (`test`.`t1`.`kp1` < 20) and (`test`.`t1`.`kp1` < 20)) +select * from t3 where a in (select kp1 from t1 where kp1<20) and a<20; +a +0 +1 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +2 +3 +4 +5 +6 +7 +8 +9 +create table t4 (pk int primary key); +insert into t4 select a from t3; +explain select * from t3 where a in +(select t1.kp1 from t1,t4 where kp1<20 and t4.pk=t1.c); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range kp1 kp1 5 NULL 48 100.00 Using where; LooseScan +1 SIMPLE t4 NULL eq_ref PRIMARY PRIMARY 4 test.t1.c 1 100.00 Using index; FirstMatch(t1) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 100 10.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a` from `test`.`t3` semi join (`test`.`t1` join `test`.`t4`) where ((`test`.`t3`.`a` = `test`.`t1`.`kp1`) and (`test`.`t4`.`pk` = `test`.`t1`.`c`) and (`test`.`t1`.`kp1` < 20)) +explain format=tree select * from t3 where a in +(select t1.kp1 from t1,t4 where kp1<20 and t4.pk=t1.c); +EXPLAIN +-> Inner hash join (t3.a = t1.kp1) (cost=519.20 rows=480) + -> Table scan on t3 (cost=1.54 rows=100) + -> Hash + -> Nested loop semijoin with duplicate removal on kp1 (cost=38.66 rows=48) + -> Filter: ((t1.kp1 < 20) and (t1.c is not null)) (cost=21.86 rows=48) + -> Index range scan on t1 using kp1 (cost=21.86 rows=48) + -> Single-row index lookup on t4 using PRIMARY (pk=t1.c) (cost=0.25 rows=1) + +select * from t3 where a in +(select t1.kp1 from t1,t4 where kp1<20 and t4.pk=t1.c); +a +0 +1 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +2 +3 +4 +5 +6 +7 +8 +9 +drop table t1, t3, t4; +create table t1 (a int); +insert into t1 values (0),(0),(0),(1),(1),(1),(2),(2),(2),(3),(3),(3); +set session internal_tmp_mem_storage_engine='memory'; +set @save_max_heap_table_size=@@max_heap_table_size; +set @@max_heap_table_size= 16384; +# Attempt to make one test that overflows the heap table when a +# non-duplicate row is inserted and one test that overflows the +# heap table when a duplicate record is inserted. Debugging showed +# that these situations occurred with max_heap_table_size=16384 +# and optimizer_join_cache_level equals 1 and 0, respectively. +# Finally execute a test that does not overflow the heap table. +explain +select count(*) from t0 a, t0 b, t0 c +where c.a in (select a from t1 d); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE d NULL ALL NULL NULL NULL NULL 12 100.00 Start temporary +1 SIMPLE c NULL ALL NULL NULL NULL NULL 10 10.00 Using where; End temporary; Using join buffer (hash join) +1 SIMPLE a NULL ALL NULL NULL NULL NULL 10 100.00 Using join buffer (hash join) +1 SIMPLE b NULL ALL NULL NULL NULL NULL 10 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select count(0) AS `count(*)` from `test`.`t0` `a` join `test`.`t0` `b` join `test`.`t0` `c` semi join (`test`.`t1` `d`) where (`test`.`c`.`a` = `test`.`d`.`a`) +flush status; +select count(*) from t0 a, t0 b, t0 c +where c.a in (select a from t1 d); +count(*) +400 +show status like 'Created_tmp_disk_tables'; +Variable_name Value +Created_tmp_disk_tables 0 +set @@max_heap_table_size= @save_max_heap_table_size; +set session internal_tmp_mem_storage_engine=default; +flush status; +select count(*) from t0 a, t0 b, t0 c +where c.a in (select a from t1 d); +count(*) +400 +show status like 'Created_tmp_disk_tables'; +Variable_name Value +Created_tmp_disk_tables 0 +drop table t0, t1; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t2(a int); +insert into t2 values (1),(2); +create table t3 ( a int , filler char(100), key(a)); +insert into t3 select A.a + 10*B.a, 'filler' from t0 A, t0 B; +explain select * from t3 where a in (select a from t2) and (a > 5 or a < 10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ref a a 5 test.t2.a 1 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a`,`test`.`t3`.`filler` AS `filler` from `test`.`t3` semi join (`test`.`t2`) where ((`test`.`t3`.`a` = `test`.`t2`.`a`) and ((`test`.`t2`.`a` > 5) or (`test`.`t2`.`a` < 10))) +select * from t3 where a in (select a from t2); +a filler +1 filler +2 filler +drop table t0, t2, t3; +create table t1 (a date); +insert into t1 values ('2008-01-01'),('2008-01-01'),('2008-02-01'),('2008-02-01'); +create table t2 (a int); +insert into t2 values (1),(2); +create table t3 (a char(10)); +insert into t3 select * from t1; +insert into t3 values (1),(2); +explain select * from t2 where a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1`) where (cast(`test`.`t2`.`a` as double) = cast(`test`.`t1`.`a` as double)) +explain select * from t2 where a in (select a from t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t2`) where (`test`.`t2`.`a` = `test`.`t2`.`a`) +explain select * from t2 where a in (select a from t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t3`) where (cast(`test`.`t2`.`a` as double) = cast(`test`.`t3`.`a` as double)) +explain select * from t1 where a in (select a from t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t3`) where (`test`.`t1`.`a` = cast(`test`.`t3`.`a` as date)) +drop table t1, t2, t3; +create table t1 (a decimal); +insert into t1 values (1),(2); +explain select * from t1 where a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t1`) where (`test`.`t1`.`a` = `test`.`t1`.`a`) +drop table t1; +create table t1 (a int); +insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t2 as select * from t1; +create table t3 (a int, b int, filler char(100), key(a)) charset utf8mb4; +insert into t3 select A.a + 10*B.a, A.a + 10*B.a, 'filler' from t1 A, t1 B, t1 C; +explain select * from t1, t3 where t3.a in (select a from t2) and (t3.a < 10 or t3.a >30) and t1.a =3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 10.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 10 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ref a a 5 test.t2.a 10 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t3`.`filler` AS `filler` from `test`.`t1` join `test`.`t3` semi join (`test`.`t2`) where ((`test`.`t3`.`a` = `test`.`t2`.`a`) and (`test`.`t1`.`a` = 3) and ((`test`.`t2`.`a` < 10) or (`test`.`t2`.`a` > 30))) +explain format=json select * from t1, t3 where t3.a in (select a from t2) and (t3.a < 10 or t3.a >30) and t1.a =3; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "59.01" + }, + "duplicates_removal": { + "using_temporary_table": true, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 10, + "rows_produced_per_join": 1, + "filtered": "10.00", + "cost_info": { + "read_cost": "1.40", + "eval_cost": "0.10", + "prefix_cost": "1.50", + "data_read_per_join": "8" + }, + "used_columns": [ + "a" + ], + "attached_condition": "(`test`.`t1`.`a` = 3)" + } + }, + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 10, + "rows_produced_per_join": 10, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "1.00", + "prefix_cost": "3.01", + "data_read_per_join": "80" + }, + "used_columns": [ + "a" + ], + "attached_condition": "(((`test`.`t2`.`a` < 10) or (`test`.`t2`.`a` > 30)) and (`test`.`t2`.`a` is not null))" + } + }, + { + "table": { + "table_name": "t3", + "access_type": "ref", + "possible_keys": [ + "a" + ], + "key": "a", + "used_key_parts": [ + "a" + ], + "key_length": "5", + "ref": [ + "test.t2.a" + ], + "rows_examined_per_scan": 10, + "rows_produced_per_join": 100, + "filtered": "100.00", + "cost_info": { + "read_cost": "25.00", + "eval_cost": "10.00", + "prefix_cost": "59.01", + "data_read_per_join": "40K" + }, + "used_columns": [ + "a", + "b", + "filler" + ] + } + } + ] + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t3`.`filler` AS `filler` from `test`.`t1` join `test`.`t3` semi join (`test`.`t2`) where ((`test`.`t3`.`a` = `test`.`t2`.`a`) and (`test`.`t1`.`a` = 3) and ((`test`.`t2`.`a` < 10) or (`test`.`t2`.`a` > 30))) +explain select straight_join * from t1 a, t1 b where a.a in (select a from t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY a NULL ALL NULL NULL NULL NULL 10 100.00 Using where +1 PRIMARY b NULL ALL NULL NULL NULL NULL 10 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select straight_join `test`.`a`.`a` AS `a`,`test`.`b`.`a` AS `a` from `test`.`t1` `a` join `test`.`t1` `b` where (`test`.`a`.`a`,(/* select#2 */ select `test`.`t2`.`a` from `test`.`t2` where ((`test`.`a`.`a`) = `test`.`t2`.`a`))) +explain select * from t2 where a in (select straight_join a.a from t1 a, t1 b); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 10 100.00 Using where +2 DEPENDENT SUBQUERY a NULL ALL NULL NULL NULL NULL 10 10.00 Using where +2 DEPENDENT SUBQUERY b NULL ALL NULL NULL NULL NULL 10 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` where (`test`.`t2`.`a`,(/* select#2 */ select straight_join `test`.`a`.`a` from `test`.`t1` `a` join `test`.`t1` `b` where ((`test`.`t2`.`a`) = `test`.`a`.`a`))) +explain select * from t2 where a in (select straight_join a.a from t1 a, t1 b); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 10 100.00 Using where +2 DEPENDENT SUBQUERY a NULL ALL NULL NULL NULL NULL 10 10.00 Using where +2 DEPENDENT SUBQUERY b NULL ALL NULL NULL NULL NULL 10 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` where (`test`.`t2`.`a`,(/* select#2 */ select straight_join `test`.`a`.`a` from `test`.`t1` `a` join `test`.`t1` `b` where ((`test`.`t2`.`a`) = `test`.`a`.`a`))) +explain select straight_join * from t2 x, t2 y +where x.a in (select straight_join a.a from t1 a, t1 b); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY x NULL ALL NULL NULL NULL NULL 10 100.00 Using where +1 PRIMARY y NULL ALL NULL NULL NULL NULL 10 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY a NULL ALL NULL NULL NULL NULL 10 10.00 Using where +2 DEPENDENT SUBQUERY b NULL ALL NULL NULL NULL NULL 10 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select straight_join `test`.`x`.`a` AS `a`,`test`.`y`.`a` AS `a` from `test`.`t2` `x` join `test`.`t2` `y` where (`test`.`x`.`a`,(/* select#2 */ select straight_join `test`.`a`.`a` from `test`.`t1` `a` join `test`.`t1` `b` where ((`test`.`x`.`a`) = `test`.`a`.`a`))) +create table t0 (a int, b int); +insert into t0 values(1,1); +explain select * from t0, t3 where t3.a in (select a from t2) and (t3.a < 10 or t3.a >30); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 10 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ref a a 5 test.t2.a 10 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select '1' AS `a`,'1' AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t3`.`filler` AS `filler` from `test`.`t3` semi join (`test`.`t2`) where ((`test`.`t3`.`a` = `test`.`t2`.`a`) and ((`test`.`t2`.`a` < 10) or (`test`.`t2`.`a` > 30))) +create table t4 as select a as x, a as y from t1; +explain select * from t0, t3 where (t3.a, t3.b) in (select x,y from t4) and (t3.a < 10 or t3.a >30); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t4 NULL ALL NULL NULL NULL NULL 10 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ref a a 5 test.t4.x 10 10.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '1' AS `a`,'1' AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t3`.`filler` AS `filler` from `test`.`t3` semi join (`test`.`t4`) where ((`test`.`t3`.`b` = `test`.`t4`.`y`) and (`test`.`t3`.`a` = `test`.`t4`.`x`) and ((`test`.`t4`.`x` < 10) or (`test`.`t4`.`x` > 30))) +drop table t0,t1,t2,t3,t4; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (a int, b int, filler char(100), key(a,b)); +insert into t1 select A.a, B.a, 'filler' from t0 A, t0 B; +create table t2 as select * from t1; +explain select * from t2 where a in (select b from t1 where a=3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ref a a 5 const 8 100.00 Using index; LooseScan +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 100 10.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`filler` AS `filler` from `test`.`t2` semi join (`test`.`t1`) where ((`test`.`t2`.`a` = `test`.`t1`.`b`) and (`test`.`t1`.`a` = 3)) +explain select * from t2 where (b,a) in (select a,b from t1 where a=3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ref a a 5 const 8 100.00 Using index; LooseScan +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 100 1.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`filler` AS `filler` from `test`.`t2` semi join (`test`.`t1`) where ((`test`.`t2`.`a` = `test`.`t1`.`b`) and (`test`.`t1`.`a` = 3) and (`test`.`t2`.`b` = 3)) +drop table t1,t2; +create table t1 (a int, b int); +insert into t1 select a,a from t0; +create table t2 (a int, b int); +insert into t2 select A.a + 10*B.a, A.a + 10*B.a from t0 A, t0 B; +explain select * from t1 where (a,b) in (select a,b from t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 100.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 100 1.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`a` = `test`.`t1`.`a`)) +drop table t0, t1, t2; +# +# Bug#19695490: CRASH IN CREATE_REF_FOR_KEY ON SELECT + JOIN + UTF8 COLUMN +# + DATETIME INDEX. +# +CREATE TABLE t1 ( +field1 varchar(255) CHARACTER SET utf8, +field2 varchar(255) CHARACTER SET utf8 +); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES +('time','time'), +('lpjdzvkp','lpjdzvkp'), +('dzvkpai', 'dzvkpai'); +CREATE TABLE t2 ( col_varchar varchar(10)); +CREATE TABLE t3 ( +pk int(11) NOT NULL, +col_varchar_255_utf8_key varchar(255) CHARACTER SET utf8, +col_varchar_10_utf8_key varchar(10) CHARACTER SET utf8, +PRIMARY KEY (pk) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t3 VALUES (22,'come','h'), +(23,'time','aaa'), +(24,'lpjdzvkp','ababa'), +(25,'d','GGDD'); +SELECT * FROM t1 WHERE (field1, field2) IN ( +SELECT table1.col_varchar_255_utf8_key AS field1, +table1.col_varchar_255_utf8_key AS field2 +FROM t3 AS table1 LEFT JOIN t2 AS table2 +ON table1.col_varchar_10_utf8_key <= +table2.col_varchar +WHERE table1.pk >= 6); +field1 field2 +time time +lpjdzvkp lpjdzvkp +DROP TABLE t1,t2,t3; +create table t0 (a decimal(4,2)); +insert into t0 values (10.24), (22.11); +create table t1 as select * from t0; +insert into t1 select * from t0; +explain select * from t0 where a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a` from `test`.`t0` semi join (`test`.`t1`) where (`test`.`t1`.`a` = `test`.`t0`.`a`) +select * from t0 where a in (select a from t1); +a +10.24 +22.11 +drop table t0, t1; +create table t0(a date); +insert into t0 values ('2008-01-01'),('2008-02-02'); +create table t1 as select * from t0; +insert into t1 select * from t0; +explain select * from t0 where a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a` from `test`.`t0` semi join (`test`.`t1`) where (`test`.`t1`.`a` = `test`.`t0`.`a`) +select * from t0 where a in (select a from t1); +a +2008-01-01 +2008-02-02 +drop table t0, t1; +create table t0(a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 as select a as a, a as b, a as c from t0 where a < 3; +create table t2 as select a as a, a as b from t0 where a < 3; +insert into t2 select * from t2; +explain select * from t1 where (a,b,c) in (select x.a, y.a, z.a from t2 x, t2 y, t2 z where x.b=33); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE x NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +1 SIMPLE y NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Using join buffer (hash join) +1 SIMPLE z NULL ALL NULL NULL NULL NULL 6 16.67 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` semi join (`test`.`t2` `x` join `test`.`t2` `y` join `test`.`t2` `z`) where ((`test`.`z`.`a` = `test`.`t1`.`c`) and (`test`.`y`.`a` = `test`.`t1`.`b`) and (`test`.`t1`.`a` = `test`.`x`.`a`) and (`test`.`x`.`b` = 33)) +drop table t0,t1,t2; +set @save_join_buffer_size = @@join_buffer_size; +set join_buffer_size= 8192; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (a int, filler1 binary(200), filler2 binary(200)); +insert into t1 select a, 'filler123456', 'filler123456' from t0; +insert into t1 select a+10, 'filler123456', 'filler123456' from t0; +create table t2 as select * from t1; +insert into t1 select a+20, 'filler123456', 'filler123456' from t0; +insert into t1 values (2, 'duplicate ok', 'duplicate ok'); +insert into t1 values (18, 'duplicate ok', 'duplicate ok'); +insert into t2 values (3, 'duplicate ok', 'duplicate ok'); +insert into t2 values (19, 'duplicate ok', 'duplicate ok'); +explain select +a, mid(filler1, 1,10), length(filler1)=length(filler2) as z +from t1 ot where a in (select a from t2 it); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE it NULL ALL NULL NULL NULL NULL 22 100.00 Start temporary +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 32 10.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot`.`a` AS `a`,substr(`test`.`ot`.`filler1`,1,10) AS `mid(filler1, 1,10)`,(length(`test`.`ot`.`filler1`) = length(`test`.`ot`.`filler2`)) AS `z` from `test`.`t1` `ot` semi join (`test`.`t2` `it`) where (`test`.`ot`.`a` = `test`.`it`.`a`) +select +a, mid(filler1, 1,10), length(filler1)=length(filler2) as z +from t1 ot where a in (select a from t2 it); +a mid(filler1, 1,10) z +0 filler1234 1 +1 filler1234 1 +10 filler1234 1 +11 filler1234 1 +12 filler1234 1 +13 filler1234 1 +14 filler1234 1 +15 filler1234 1 +16 filler1234 1 +17 filler1234 1 +18 duplicate 1 +18 filler1234 1 +19 filler1234 1 +2 duplicate 1 +2 filler1234 1 +3 filler1234 1 +4 filler1234 1 +5 filler1234 1 +6 filler1234 1 +7 filler1234 1 +8 filler1234 1 +9 filler1234 1 +explain select +a, mid(filler1, 1,10), length(filler1)=length(filler2) +from t2 ot where a in (select a from t1 it); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE it NULL ALL NULL NULL NULL NULL 32 100.00 Start temporary +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 22 10.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot`.`a` AS `a`,substr(`test`.`ot`.`filler1`,1,10) AS `mid(filler1, 1,10)`,(length(`test`.`ot`.`filler1`) = length(`test`.`ot`.`filler2`)) AS `length(filler1)=length(filler2)` from `test`.`t2` `ot` semi join (`test`.`t1` `it`) where (`test`.`ot`.`a` = `test`.`it`.`a`) +select +a, mid(filler1, 1,10), length(filler1)=length(filler2) +from t2 ot where a in (select a from t1 it); +a mid(filler1, 1,10) length(filler1)=length(filler2) +0 filler1234 1 +1 filler1234 1 +10 filler1234 1 +11 filler1234 1 +12 filler1234 1 +13 filler1234 1 +14 filler1234 1 +15 filler1234 1 +16 filler1234 1 +17 filler1234 1 +18 filler1234 1 +19 duplicate 1 +19 filler1234 1 +2 filler1234 1 +3 duplicate 1 +3 filler1234 1 +4 filler1234 1 +5 filler1234 1 +6 filler1234 1 +7 filler1234 1 +8 filler1234 1 +9 filler1234 1 +insert into t1 select a+20, 'filler123456', 'filler123456' from t0; +insert into t1 select a+20, 'filler123456', 'filler123456' from t0; +explain select +a, mid(filler1, 1,10), length(filler1)=length(filler2) as z +from t1 ot where a in (select a from t2 it); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE it NULL ALL NULL NULL NULL NULL 22 100.00 Start temporary +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 52 10.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot`.`a` AS `a`,substr(`test`.`ot`.`filler1`,1,10) AS `mid(filler1, 1,10)`,(length(`test`.`ot`.`filler1`) = length(`test`.`ot`.`filler2`)) AS `z` from `test`.`t1` `ot` semi join (`test`.`t2` `it`) where (`test`.`ot`.`a` = `test`.`it`.`a`) +select +a, mid(filler1, 1,10), length(filler1)=length(filler2) as z +from t1 ot where a in (select a from t2 it); +a mid(filler1, 1,10) z +0 filler1234 1 +1 filler1234 1 +10 filler1234 1 +11 filler1234 1 +12 filler1234 1 +13 filler1234 1 +14 filler1234 1 +15 filler1234 1 +16 filler1234 1 +17 filler1234 1 +18 duplicate 1 +18 filler1234 1 +19 filler1234 1 +2 duplicate 1 +2 filler1234 1 +3 filler1234 1 +4 filler1234 1 +5 filler1234 1 +6 filler1234 1 +7 filler1234 1 +8 filler1234 1 +9 filler1234 1 +explain select +a, mid(filler1, 1,10), length(filler1)=length(filler2) +from t2 ot where a in (select a from t1 it); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE it NULL ALL NULL NULL NULL NULL 52 100.00 Start temporary +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 22 10.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot`.`a` AS `a`,substr(`test`.`ot`.`filler1`,1,10) AS `mid(filler1, 1,10)`,(length(`test`.`ot`.`filler1`) = length(`test`.`ot`.`filler2`)) AS `length(filler1)=length(filler2)` from `test`.`t2` `ot` semi join (`test`.`t1` `it`) where (`test`.`ot`.`a` = `test`.`it`.`a`) +select +a, mid(filler1, 1,10), length(filler1)=length(filler2) +from t2 ot where a in (select a from t1 it); +a mid(filler1, 1,10) length(filler1)=length(filler2) +0 filler1234 1 +1 filler1234 1 +10 filler1234 1 +11 filler1234 1 +12 filler1234 1 +13 filler1234 1 +14 filler1234 1 +15 filler1234 1 +16 filler1234 1 +17 filler1234 1 +18 filler1234 1 +19 duplicate 1 +19 filler1234 1 +2 filler1234 1 +3 duplicate 1 +3 filler1234 1 +4 filler1234 1 +5 filler1234 1 +6 filler1234 1 +7 filler1234 1 +8 filler1234 1 +9 filler1234 1 +set @@join_buffer_size = @save_join_buffer_size; +drop table t1, t2; +create table t1 (a int, b int, key(a)); +create table t2 (a int, b int, key(a)); +create table t3 (a int, b int, key(a)); +insert into t1 select a,a from t0; +insert into t2 select a,a from t0; +insert into t3 select a,a from t0; +t2 and t3 must be use 'ref', not 'ALL': +explain select * +from t0 where a in +(select t2.a+t3.a from t1 left join (t2 join t3) on t2.a=t1.a and t3.a=t1.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index a a 5 NULL 10 100.00 Using index; Start temporary +1 SIMPLE t2 NULL ref a a 5 test.t1.a 1 100.00 Using index +1 SIMPLE t3 NULL ref a a 5 test.t1.a 1 100.00 Using index +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 10 10.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a` from `test`.`t0` semi join (`test`.`t1` join `test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`a` = `test`.`t1`.`a`) and (`test`.`t3`.`a` = `test`.`t1`.`a`) and (`test`.`t0`.`a` = (`test`.`t1`.`a` + `test`.`t1`.`a`))) +drop table t0, t1,t2,t3; + +Test that neither MaterializeLookup strategy for semijoin, +nor subquery materialization is used when BLOBs are involved +(except when arguments of some functions). + +set @prefix_len = 6; +set @blob_len = 16; +set @suffix_len = @blob_len - @prefix_len; +create table t1_16 (a1 blob(16), a2 blob(16)); +create table t2_16 (b1 blob(16), b2 blob(16)); +create table t3_16 (c1 blob(16), c2 blob(16)); +insert into t1_16 values +(concat('1 - 00', repeat('x', @suffix_len)), concat('2 - 00', repeat('x', @suffix_len))); +insert into t1_16 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t1_16 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_16 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t2_16 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_16 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_16 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t3_16 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t3_16 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_16 values +(concat('1 - 04', repeat('x', @suffix_len)), concat('2 - 04', repeat('x', @suffix_len))); +explain select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select b1 from t2_16 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2_16 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Start temporary +1 SIMPLE t1_16 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_16`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_16`.`a2`,7) AS `left(a2,7)` from `test`.`t1_16` semi join (`test`.`t2_16`) where ((`test`.`t1_16`.`a1` = `test`.`t2_16`.`b1`) and (`test`.`t2_16`.`b1` > '0')) +select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select b1 from t2_16 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_16 +where (a1,a2) in (select b1, b2 from t2_16 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2_16 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Start temporary +1 SIMPLE t1_16 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_16`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_16`.`a2`,7) AS `left(a2,7)` from `test`.`t1_16` semi join (`test`.`t2_16`) where ((`test`.`t1_16`.`a2` = `test`.`t2_16`.`b2`) and (`test`.`t1_16`.`a1` = `test`.`t2_16`.`b1`) and (`test`.`t2_16`.`b1` > '0')) +select left(a1,7), left(a2,7) +from t1_16 +where (a1,a2) in (select b1, b2 from t2_16 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select substring(b1,1,16) from t2_16 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2_16 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Start temporary +1 SIMPLE t1_16 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_16`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_16`.`a2`,7) AS `left(a2,7)` from `test`.`t1_16` semi join (`test`.`t2_16`) where ((`test`.`t2_16`.`b1` > '0') and (`test`.`t1_16`.`a1` = substr(`test`.`t2_16`.`b1`,1,16))) +select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select substring(b1,1,16) from t2_16 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select group_concat(b1) from t2_16 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_16 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t2_16 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_16`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_16`.`a2`,7) AS `left(a2,7)` from `test`.`t1_16` where (`test`.`t1_16`.`a1`,(/* select#2 */ select group_concat(`test`.`t2_16`.`b1` separator ',') from `test`.`t2_16` group by `test`.`t2_16`.`b2` having ((`test`.`t1_16`.`a1`) = (group_concat(`test`.`t2_16`.`b1` separator ','))))) +select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select group_concat(b1) from t2_16 group by b2); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +set @@group_concat_max_len = 256; +explain select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select group_concat(b1) from t2_16 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_16 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t2_16 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_16`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_16`.`a2`,7) AS `left(a2,7)` from `test`.`t1_16` where (`test`.`t1_16`.`a1`,(/* select#2 */ select group_concat(`test`.`t2_16`.`b1` separator ',') from `test`.`t2_16` group by `test`.`t2_16`.`b2` having ((`test`.`t1_16`.`a1`) = (group_concat(`test`.`t2_16`.`b1` separator ','))))) +select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select group_concat(b1) from t2_16 group by b2); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +create table t1 (a1 char(8), a2 char(8)) charset latin1; +create table t2 (b1 char(8), b2 char(8)) charset latin1; +create table t3 (c1 char(8), c2 char(8)) charset latin1; +insert into t1 values ('1 - 00', '2 - 00'); +insert into t1 values ('1 - 01', '2 - 01'); +insert into t1 values ('1 - 02', '2 - 02'); +insert into t2 values ('1 - 01', '2 - 01'); +insert into t2 values ('1 - 01', '2 - 01'); +insert into t2 values ('1 - 02', '2 - 02'); +insert into t2 values ('1 - 02', '2 - 02'); +insert into t2 values ('1 - 03', '2 - 03'); +insert into t3 values ('1 - 01', '2 - 01'); +insert into t3 values ('1 - 02', '2 - 02'); +insert into t3 values ('1 - 03', '2 - 03'); +insert into t3 values ('1 - 04', '2 - 04'); +insert into t3 values ('1 - 05', '2 - 05'); +insert into t3 values ('1 - 06', '2 - 06'); +insert into t3 values ('1 - 07', '2 - 07'); +insert into t3 values ('1 - 08', '2 - 08'); +explain +select * from t1 +where concat(a1,'x') IN +(select left(a1,8) from t1_16 +where (a1, a2) IN +(select t2_16.b1, t2_16.b2 from t2_16, t2 +where t2.b2 = substring(t2_16.b2,1,6) and +t2.b1 IN (select c1 from t3 where c2 > '0'))); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1_16 NULL ALL NULL NULL NULL NULL 3 100.00 Start temporary +1 SIMPLE t2_16 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 5 20.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` semi join (`test`.`t1_16` join `test`.`t2_16` join `test`.`t2` join `test`.`t3`) where ((`test`.`t2_16`.`b2` = `test`.`t1_16`.`a2`) and (`test`.`t2_16`.`b1` = `test`.`t1_16`.`a1`) and (`test`.`t3`.`c1` = `test`.`t2`.`b1`) and (`test`.`t2`.`b2` = substr(`test`.`t2_16`.`b2`,1,6)) and (`test`.`t3`.`c2` > '0') and (concat(`test`.`t1`.`a1`,'x') = left(`test`.`t1_16`.`a1`,8))) +drop table t1_16, t2_16, t3_16, t1, t2, t3; +set @blob_len = 512; +set @suffix_len = @blob_len - @prefix_len; +create table t1_512 (a1 blob(512), a2 blob(512)); +create table t2_512 (b1 blob(512), b2 blob(512)); +create table t3_512 (c1 blob(512), c2 blob(512)); +insert into t1_512 values +(concat('1 - 00', repeat('x', @suffix_len)), concat('2 - 00', repeat('x', @suffix_len))); +insert into t1_512 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t1_512 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_512 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t2_512 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_512 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_512 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t3_512 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t3_512 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_512 values +(concat('1 - 04', repeat('x', @suffix_len)), concat('2 - 04', repeat('x', @suffix_len))); +explain select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select b1 from t2_512 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2_512 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Start temporary +1 SIMPLE t1_512 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_512`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_512`.`a2`,7) AS `left(a2,7)` from `test`.`t1_512` semi join (`test`.`t2_512`) where ((`test`.`t1_512`.`a1` = `test`.`t2_512`.`b1`) and (`test`.`t2_512`.`b1` > '0')) +select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select b1 from t2_512 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_512 +where (a1,a2) in (select b1, b2 from t2_512 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2_512 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Start temporary +1 SIMPLE t1_512 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_512`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_512`.`a2`,7) AS `left(a2,7)` from `test`.`t1_512` semi join (`test`.`t2_512`) where ((`test`.`t1_512`.`a2` = `test`.`t2_512`.`b2`) and (`test`.`t1_512`.`a1` = `test`.`t2_512`.`b1`) and (`test`.`t2_512`.`b1` > '0')) +select left(a1,7), left(a2,7) +from t1_512 +where (a1,a2) in (select b1, b2 from t2_512 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select substring(b1,1,512) from t2_512 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2_512 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Start temporary +1 SIMPLE t1_512 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_512`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_512`.`a2`,7) AS `left(a2,7)` from `test`.`t1_512` semi join (`test`.`t2_512`) where ((`test`.`t2_512`.`b1` > '0') and (`test`.`t1_512`.`a1` = substr(`test`.`t2_512`.`b1`,1,512))) +select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select substring(b1,1,512) from t2_512 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select group_concat(b1) from t2_512 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_512 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t2_512 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_512`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_512`.`a2`,7) AS `left(a2,7)` from `test`.`t1_512` where (`test`.`t1_512`.`a1`,(/* select#2 */ select group_concat(`test`.`t2_512`.`b1` separator ',') from `test`.`t2_512` group by `test`.`t2_512`.`b2` having ((`test`.`t1_512`.`a1`) = (group_concat(`test`.`t2_512`.`b1` separator ','))))) +select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select group_concat(b1) from t2_512 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +Warning 1260 Row 4 was cut by GROUP_CONCAT() +Warning 1260 Row 5 was cut by GROUP_CONCAT() +Warning 1260 Row 6 was cut by GROUP_CONCAT() +Warning 1260 Row 7 was cut by GROUP_CONCAT() +Warning 1260 Row 8 was cut by GROUP_CONCAT() +Warning 1260 Row 9 was cut by GROUP_CONCAT() +set @@group_concat_max_len = 256; +explain select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select group_concat(b1) from t2_512 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_512 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t2_512 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_512`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_512`.`a2`,7) AS `left(a2,7)` from `test`.`t1_512` where (`test`.`t1_512`.`a1`,(/* select#2 */ select group_concat(`test`.`t2_512`.`b1` separator ',') from `test`.`t2_512` group by `test`.`t2_512`.`b2` having ((`test`.`t1_512`.`a1`) = (group_concat(`test`.`t2_512`.`b1` separator ','))))) +select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select group_concat(b1) from t2_512 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +Warning 1260 Row 4 was cut by GROUP_CONCAT() +Warning 1260 Row 5 was cut by GROUP_CONCAT() +Warning 1260 Row 6 was cut by GROUP_CONCAT() +Warning 1260 Row 7 was cut by GROUP_CONCAT() +Warning 1260 Row 8 was cut by GROUP_CONCAT() +Warning 1260 Row 9 was cut by GROUP_CONCAT() +drop table t1_512, t2_512, t3_512; +set @blob_len = 513; +set @suffix_len = @blob_len - @prefix_len; +create table t1_513 (a1 blob(513), a2 blob(513)); +create table t2_513 (b1 blob(513), b2 blob(513)); +create table t3_513 (c1 blob(513), c2 blob(513)); +insert into t1_513 values +(concat('1 - 00', repeat('x', @suffix_len)), concat('2 - 00', repeat('x', @suffix_len))); +insert into t1_513 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t1_513 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_513 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t2_513 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_513 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_513 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t3_513 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t3_513 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_513 values +(concat('1 - 04', repeat('x', @suffix_len)), concat('2 - 04', repeat('x', @suffix_len))); +explain select left(a1,7), left(a2,7) +from t1_513 +where a1 in (select b1 from t2_513 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2_513 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Start temporary +1 SIMPLE t1_513 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_513`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_513`.`a2`,7) AS `left(a2,7)` from `test`.`t1_513` semi join (`test`.`t2_513`) where ((`test`.`t1_513`.`a1` = `test`.`t2_513`.`b1`) and (`test`.`t2_513`.`b1` > '0')) +select left(a1,7), left(a2,7) +from t1_513 +where a1 in (select b1 from t2_513 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_513 +where (a1,a2) in (select b1, b2 from t2_513 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2_513 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Start temporary +1 SIMPLE t1_513 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_513`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_513`.`a2`,7) AS `left(a2,7)` from `test`.`t1_513` semi join (`test`.`t2_513`) where ((`test`.`t1_513`.`a2` = `test`.`t2_513`.`b2`) and (`test`.`t1_513`.`a1` = `test`.`t2_513`.`b1`) and (`test`.`t2_513`.`b1` > '0')) +select left(a1,7), left(a2,7) +from t1_513 +where (a1,a2) in (select b1, b2 from t2_513 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_513 +where a1 in (select substring(b1,1,513) from t2_513 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2_513 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Start temporary +1 SIMPLE t1_513 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_513`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_513`.`a2`,7) AS `left(a2,7)` from `test`.`t1_513` semi join (`test`.`t2_513`) where ((`test`.`t2_513`.`b1` > '0') and (`test`.`t1_513`.`a1` = substr(`test`.`t2_513`.`b1`,1,513))) +select left(a1,7), left(a2,7) +from t1_513 +where a1 in (select substring(b1,1,513) from t2_513 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_513 +where a1 in (select group_concat(b1) from t2_513 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_513 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t2_513 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_513`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_513`.`a2`,7) AS `left(a2,7)` from `test`.`t1_513` where (`test`.`t1_513`.`a1`,(/* select#2 */ select group_concat(`test`.`t2_513`.`b1` separator ',') from `test`.`t2_513` group by `test`.`t2_513`.`b2` having ((`test`.`t1_513`.`a1`) = (group_concat(`test`.`t2_513`.`b1` separator ','))))) +select left(a1,7), left(a2,7) +from t1_513 +where a1 in (select group_concat(b1) from t2_513 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +Warning 1260 Row 4 was cut by GROUP_CONCAT() +Warning 1260 Row 5 was cut by GROUP_CONCAT() +Warning 1260 Row 6 was cut by GROUP_CONCAT() +Warning 1260 Row 7 was cut by GROUP_CONCAT() +Warning 1260 Row 8 was cut by GROUP_CONCAT() +Warning 1260 Row 9 was cut by GROUP_CONCAT() +drop table t1_513, t2_513, t3_513; +set @blob_len = 1024; +set @suffix_len = @blob_len - @prefix_len; +create table t1_1024 (a1 blob(1024), a2 blob(1024)); +create table t2_1024 (b1 blob(1024), b2 blob(1024)); +create table t3_1024 (c1 blob(1024), c2 blob(1024)); +insert into t1_1024 values +(concat('1 - 00', repeat('x', @suffix_len)), concat('2 - 00', repeat('x', @suffix_len))); +insert into t1_1024 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t1_1024 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_1024 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t2_1024 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_1024 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_1024 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t3_1024 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t3_1024 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_1024 values +(concat('1 - 04', repeat('x', @suffix_len)), concat('2 - 04', repeat('x', @suffix_len))); +explain select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select b1 from t2_1024 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2_1024 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Start temporary +1 SIMPLE t1_1024 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1024`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1024`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1024` semi join (`test`.`t2_1024`) where ((`test`.`t1_1024`.`a1` = `test`.`t2_1024`.`b1`) and (`test`.`t2_1024`.`b1` > '0')) +select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select b1 from t2_1024 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_1024 +where (a1,a2) in (select b1, b2 from t2_1024 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2_1024 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Start temporary +1 SIMPLE t1_1024 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1024`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1024`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1024` semi join (`test`.`t2_1024`) where ((`test`.`t1_1024`.`a2` = `test`.`t2_1024`.`b2`) and (`test`.`t1_1024`.`a1` = `test`.`t2_1024`.`b1`) and (`test`.`t2_1024`.`b1` > '0')) +select left(a1,7), left(a2,7) +from t1_1024 +where (a1,a2) in (select b1, b2 from t2_1024 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select substring(b1,1,1024) from t2_1024 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2_1024 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Start temporary +1 SIMPLE t1_1024 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1024`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1024`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1024` semi join (`test`.`t2_1024`) where ((`test`.`t2_1024`.`b1` > '0') and (`test`.`t1_1024`.`a1` = substr(`test`.`t2_1024`.`b1`,1,1024))) +select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select substring(b1,1,1024) from t2_1024 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select group_concat(b1) from t2_1024 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_1024 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t2_1024 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1024`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1024`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1024` where (`test`.`t1_1024`.`a1`,(/* select#2 */ select group_concat(`test`.`t2_1024`.`b1` separator ',') from `test`.`t2_1024` group by `test`.`t2_1024`.`b2` having ((`test`.`t1_1024`.`a1`) = (group_concat(`test`.`t2_1024`.`b1` separator ','))))) +select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select group_concat(b1) from t2_1024 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +Warning 1260 Row 4 was cut by GROUP_CONCAT() +Warning 1260 Row 5 was cut by GROUP_CONCAT() +Warning 1260 Row 6 was cut by GROUP_CONCAT() +Warning 1260 Row 7 was cut by GROUP_CONCAT() +Warning 1260 Row 8 was cut by GROUP_CONCAT() +Warning 1260 Row 9 was cut by GROUP_CONCAT() +set @@group_concat_max_len = 256; +explain select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select group_concat(b1) from t2_1024 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_1024 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t2_1024 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1024`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1024`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1024` where (`test`.`t1_1024`.`a1`,(/* select#2 */ select group_concat(`test`.`t2_1024`.`b1` separator ',') from `test`.`t2_1024` group by `test`.`t2_1024`.`b2` having ((`test`.`t1_1024`.`a1`) = (group_concat(`test`.`t2_1024`.`b1` separator ','))))) +select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select group_concat(b1) from t2_1024 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +Warning 1260 Row 4 was cut by GROUP_CONCAT() +Warning 1260 Row 5 was cut by GROUP_CONCAT() +Warning 1260 Row 6 was cut by GROUP_CONCAT() +Warning 1260 Row 7 was cut by GROUP_CONCAT() +Warning 1260 Row 8 was cut by GROUP_CONCAT() +Warning 1260 Row 9 was cut by GROUP_CONCAT() +drop table t1_1024, t2_1024, t3_1024; +set @blob_len = 1025; +set @suffix_len = @blob_len - @prefix_len; +create table t1_1025 (a1 blob(1025), a2 blob(1025)); +create table t2_1025 (b1 blob(1025), b2 blob(1025)); +create table t3_1025 (c1 blob(1025), c2 blob(1025)); +insert into t1_1025 values +(concat('1 - 00', repeat('x', @suffix_len)), concat('2 - 00', repeat('x', @suffix_len))); +insert into t1_1025 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t1_1025 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_1025 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t2_1025 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_1025 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_1025 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t3_1025 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t3_1025 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_1025 values +(concat('1 - 04', repeat('x', @suffix_len)), concat('2 - 04', repeat('x', @suffix_len))); +explain select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select b1 from t2_1025 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2_1025 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Start temporary +1 SIMPLE t1_1025 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1025`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1025`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1025` semi join (`test`.`t2_1025`) where ((`test`.`t1_1025`.`a1` = `test`.`t2_1025`.`b1`) and (`test`.`t2_1025`.`b1` > '0')) +select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select b1 from t2_1025 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_1025 +where (a1,a2) in (select b1, b2 from t2_1025 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2_1025 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Start temporary +1 SIMPLE t1_1025 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1025`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1025`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1025` semi join (`test`.`t2_1025`) where ((`test`.`t1_1025`.`a2` = `test`.`t2_1025`.`b2`) and (`test`.`t1_1025`.`a1` = `test`.`t2_1025`.`b1`) and (`test`.`t2_1025`.`b1` > '0')) +select left(a1,7), left(a2,7) +from t1_1025 +where (a1,a2) in (select b1, b2 from t2_1025 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select substring(b1,1,1025) from t2_1025 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2_1025 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Start temporary +1 SIMPLE t1_1025 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1025`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1025`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1025` semi join (`test`.`t2_1025`) where ((`test`.`t2_1025`.`b1` > '0') and (`test`.`t1_1025`.`a1` = substr(`test`.`t2_1025`.`b1`,1,1025))) +select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select substring(b1,1,1025) from t2_1025 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select group_concat(b1) from t2_1025 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_1025 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t2_1025 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1025`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1025`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1025` where (`test`.`t1_1025`.`a1`,(/* select#2 */ select group_concat(`test`.`t2_1025`.`b1` separator ',') from `test`.`t2_1025` group by `test`.`t2_1025`.`b2` having ((`test`.`t1_1025`.`a1`) = (group_concat(`test`.`t2_1025`.`b1` separator ','))))) +select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select group_concat(b1) from t2_1025 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +Warning 1260 Row 4 was cut by GROUP_CONCAT() +Warning 1260 Row 5 was cut by GROUP_CONCAT() +Warning 1260 Row 6 was cut by GROUP_CONCAT() +Warning 1260 Row 7 was cut by GROUP_CONCAT() +Warning 1260 Row 8 was cut by GROUP_CONCAT() +Warning 1260 Row 9 was cut by GROUP_CONCAT() +set @@group_concat_max_len = 256; +explain select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select group_concat(b1) from t2_1025 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_1025 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t2_1025 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1025`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1025`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1025` where (`test`.`t1_1025`.`a1`,(/* select#2 */ select group_concat(`test`.`t2_1025`.`b1` separator ',') from `test`.`t2_1025` group by `test`.`t2_1025`.`b2` having ((`test`.`t1_1025`.`a1`) = (group_concat(`test`.`t2_1025`.`b1` separator ','))))) +select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select group_concat(b1) from t2_1025 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +Warning 1260 Row 4 was cut by GROUP_CONCAT() +Warning 1260 Row 5 was cut by GROUP_CONCAT() +Warning 1260 Row 6 was cut by GROUP_CONCAT() +Warning 1260 Row 7 was cut by GROUP_CONCAT() +Warning 1260 Row 8 was cut by GROUP_CONCAT() +Warning 1260 Row 9 was cut by GROUP_CONCAT() +drop table t1_1025, t2_1025, t3_1025; +# +# WL#5561: Enable semi join transformation with outer join. +# +CREATE TABLE ot1(a INT); +CREATE TABLE ot2(a INT); +CREATE TABLE ot3(a INT); +CREATE TABLE it1(a INT); +CREATE TABLE it2(a INT); +CREATE TABLE it3(a INT); +INSERT INTO ot1 VALUES(0),(1),(2),(3),(4),(5),(6),(7); +INSERT INTO ot2 VALUES(0),(2),(4),(6); +INSERT INTO ot3 VALUES(0),(3),(6); +INSERT INTO it1 VALUES(0),(1),(2),(3),(4),(5),(6),(7); +INSERT INTO it2 VALUES(0),(2),(4),(6); +INSERT INTO it3 VALUES(0),(3),(6); +# Test cases, Subquery Pattern 1 +# Example SQ1.1: +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE ot1.a IN (SELECT a FROM it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE it3 NULL ALL NULL NULL NULL NULL 3 100.00 Start temporary +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; End temporary; Using join buffer (hash join) +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` left join `test`.`ot2` on((`test`.`ot2`.`a` = `test`.`it3`.`a`)) semi join (`test`.`it3`) where (`test`.`ot1`.`a` = `test`.`it3`.`a`) +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE ot1.a IN (SELECT a FROM it3); +a a +0 0 +3 NULL +6 6 +# Example SQ1.2: +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE COALESCE(ot2.a,0) IN (SELECT a FROM it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 Start temporary +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (hash join) +1 SIMPLE it3 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` left join `test`.`ot2` on((`test`.`ot2`.`a` = `test`.`ot1`.`a`)) semi join (`test`.`it3`) where (coalesce(`test`.`ot2`.`a`,0) = `test`.`it3`.`a`) +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE COALESCE(ot2.a,0) IN (SELECT a FROM it3); +a a +0 0 +1 NULL +3 NULL +5 NULL +6 6 +7 NULL +# Example SQ1.3: +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE (ot1.a,ot2.a) IN (SELECT a, a FROM it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE it3 NULL ALL NULL NULL NULL NULL 3 100.00 Start temporary +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; Using join buffer (hash join) +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` join `test`.`ot2` semi join (`test`.`it3`) where ((`test`.`ot2`.`a` = `test`.`it3`.`a`) and (`test`.`ot1`.`a` = `test`.`it3`.`a`)) +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE (ot1.a,ot2.a) IN (SELECT a, a FROM it3); +a a +0 0 +6 6 +# More test cases +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 +WHERE ot1.a IN (SELECT a FROM it3); +a a +0 0 +3 NULL +6 6 +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 +WHERE ot1.a IN (SELECT a+0 FROM it3); +a a +0 0 +3 NULL +6 6 +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 +WHERE COALESCE(ot2.a,0) IN (SELECT a FROM it3); +a a +0 0 +1 NULL +3 NULL +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE COALESCE(ot2.a,0) IN (SELECT a+0 FROM it3); +a a +0 0 +1 NULL +3 NULL +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 +WHERE (ot1.a,ot2.a) IN (SELECT a, a FROM it3); +a a +0 0 +6 6 +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +LEFT JOIN ot3 ON ot1.a=ot3.a +WHERE ot1.a IN (SELECT a FROM it3); +a a a +0 0 0 +3 NULL 3 +6 6 6 +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +LEFT JOIN ot3 ON ot1.a=ot3.a +WHERE COALESCE(ot2.a,0) IN (SELECT a FROM it3); +a a a +0 0 0 +1 NULL NULL +3 NULL 3 +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +LEFT JOIN ot3 ON ot1.a=ot3.a +WHERE COALESCE(ot3.a,0) IN (SELECT a FROM it3); +a a a +0 0 0 +1 NULL NULL +2 2 NULL +3 NULL 3 +4 4 NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +LEFT JOIN ot3 ON ot2.a=ot3.a +WHERE ot1.a IN (SELECT a FROM it3); +a a a +0 0 0 +3 NULL NULL +6 6 6 +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +LEFT JOIN ot3 ON ot2.a=ot3.a +WHERE COALESCE(ot2.a,0) IN (SELECT a FROM it3); +a a a +0 0 0 +1 NULL NULL +3 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +LEFT JOIN ot3 ON ot2.a=ot3.a +WHERE COALESCE(ot3.a,0) IN (SELECT a FROM it3); +a a a +0 0 0 +1 NULL NULL +2 2 NULL +3 NULL NULL +4 4 NULL +5 NULL NULL +6 6 6 +7 NULL NULL +# Test cases, Subquery Pattern 2 +# Example SQ2.1: +explain SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE it3 NULL ALL NULL NULL NULL NULL 3 100.00 Start temporary +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; End temporary; Using join buffer (hash join) +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` join `test`.`ot2` semi join (`test`.`it3`) where ((`test`.`ot1`.`a` = `test`.`it3`.`a`) and (`test`.`ot2`.`a` = `test`.`it3`.`a`)) +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3); +a a +0 0 +6 6 +# Example SQ2.2: +explain SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it2) +AND ot2.a IN (SELECT a FROM it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE it3 NULL ALL NULL NULL NULL NULL 3 100.00 Start temporary +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; Using join buffer (hash join) +1 SIMPLE it2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; Using join buffer (hash join) +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` join `test`.`ot2` semi join (`test`.`it2`) semi join (`test`.`it3`) where ((`test`.`ot2`.`a` = `test`.`it3`.`a`) and (`test`.`it2`.`a` = `test`.`it3`.`a`) and (`test`.`ot1`.`a` = `test`.`it3`.`a`)) +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it2) +AND ot2.a IN (SELECT a FROM it3); +a a +0 0 +6 6 +# More test cases +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it3); +a a +0 0 +6 6 +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it3); +a a +0 0 +6 6 +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a+0 AND ot2.a IN (SELECT a FROM it3); +a a +0 0 +6 6 +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot2.a IN (SELECT a+0 FROM it3); +a a +0 0 +6 6 +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it2) +AND ot2.a IN (SELECT a+0 FROM it3); +a a +0 0 +6 6 +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3) +JOIN ot3 ON ot2.a=ot3.a AND ot3.a IN (SELECT a FROM it3); +a a a +0 0 0 +6 6 6 +# Test cases, Subquery Pattern 3 +# Example SQ3.1: +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 Start temporary +1 SIMPLE it3 NULL ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (hash join) +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` semi join (`test`.`it3`)) on(((`test`.`it3`.`a` = `test`.`ot1`.`a`) and (`test`.`ot2`.`a` = `test`.`ot1`.`a`))) where true +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3); +a a +0 0 +1 NULL +2 NULL +3 NULL +4 NULL +5 NULL +6 6 +7 NULL +# Example SQ3.2: +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot2.a IN (SELECT a FROM it2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 Start temporary +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (hash join) +1 SIMPLE it2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` semi join (`test`.`it2`)) on(((`test`.`ot2`.`a` = `test`.`ot1`.`a`) and (`test`.`it2`.`a` = `test`.`ot1`.`a`))) where true +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot2.a IN (SELECT a FROM it2); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +# Example SQ3.3 +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1) +AND ot2.a IN (SELECT a FROM it2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 Start temporary +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (hash join) +1 SIMPLE it2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (hash join) +1 SIMPLE it1 NULL ALL NULL NULL NULL NULL 8 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` semi join (`test`.`it1`) semi join (`test`.`it2`)) on(((`test`.`ot2`.`a` = `test`.`ot1`.`a`) and (`test`.`it2`.`a` = `test`.`ot1`.`a`) and (`test`.`it1`.`a` = `test`.`ot1`.`a`))) where true +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1) +AND ot2.a IN (SELECT a FROM it2); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +# Example SQ3.4 +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND +(ot1.a, ot2.a) IN (SELECT it1.a, it2.a +FROM it1 JOIN it2 ON it1.a=it2.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 Start temporary +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (hash join) +1 SIMPLE it2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (hash join) +1 SIMPLE it1 NULL ALL NULL NULL NULL NULL 8 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` semi join (`test`.`it1` join `test`.`it2`)) on(((`test`.`ot2`.`a` = `test`.`ot1`.`a`) and (`test`.`it2`.`a` = `test`.`ot1`.`a`) and (`test`.`it1`.`a` = `test`.`ot1`.`a`))) where true +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND +(ot1.a, ot2.a) IN (SELECT it1.a, it2.a +FROM it1 JOIN it2 ON it1.a=it2.a); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +# More test cases +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it3); +a a +0 0 +1 NULL +2 NULL +3 NULL +4 NULL +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it3); +a a +0 0 +1 NULL +2 NULL +3 NULL +4 NULL +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 AND ot2.a IN (SELECT a FROM it2); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot2.a IN (SELECT a+0 FROM it2); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a+0 FROM it1) +AND ot2.a IN (SELECT a+0 FROM it2); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 AND +(ot1.a, ot2.a) IN (SELECT it1.a+0, it2.a+0 +FROM it1 JOIN it2 ON it1.a=it2.a); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +EXPLAIN FORMAT=tree SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3) +LEFT JOIN ot3 ON ot2.a=ot3.a AND ot3.a IN (SELECT a FROM it3); +EXPLAIN +-> Remove duplicate (ot1, ot2, ot3) rows using temporary table (weedout) (cost=88.33 rows=864) + -> Left hash join (ot3.a = ot2.a), (it3.a = ot2.a) (cost=88.33 rows=864) + -> Left hash join (it3.a = ot1.a), (ot2.a = ot1.a) (cost=12.10 rows=96) + -> Table scan on ot1 (cost=1.30 rows=8) + -> Hash + -> Inner hash join (no condition) (cost=2.00 rows=12) + -> Table scan on ot2 (cost=0.11 rows=4) + -> Hash + -> Table scan on it3 (cost=0.30 rows=3) + -> Hash + -> Inner hash join (no condition) (cost=1.43 rows=9) + -> Table scan on it3 (cost=0.03 rows=3) + -> Hash + -> Table scan on ot3 (cost=0.03 rows=3) + +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3) +LEFT JOIN ot3 ON ot2.a=ot3.a AND ot3.a IN (SELECT a FROM it3); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it3) +LEFT JOIN ot3 ON ot2.a=ot3.a+0 AND ot3.a IN (SELECT a FROM it3); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +# Test cases, Subquery Pattern 4 +# Example SQ4.1: +explain SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 Start temporary +1 SIMPLE it1 NULL ALL NULL NULL NULL NULL 8 100.00 Using where; Using join buffer (hash join) +1 SIMPLE ot3 NULL ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (hash join) +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a`,`test`.`ot3`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` join `test`.`ot3` semi join (`test`.`it1`)) on(((`test`.`it1`.`a` = `test`.`ot1`.`a`) and (`test`.`ot3`.`a` = `test`.`ot1`.`a`) and (`test`.`ot2`.`a` = `test`.`ot1`.`a`))) where true +SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +# Example SQ4.2: +explain SELECT * +FROM ot1 +JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot3 NULL ALL NULL NULL NULL NULL 3 100.00 Start temporary +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; Using join buffer (hash join) +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; Using join buffer (hash join) +1 SIMPLE it1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a`,`test`.`ot3`.`a` AS `a` from `test`.`ot1` join `test`.`ot2` join `test`.`ot3` semi join (`test`.`it1`) where ((`test`.`ot2`.`a` = `test`.`ot3`.`a`) and (`test`.`ot1`.`a` = `test`.`ot3`.`a`) and (`test`.`it1`.`a` = `test`.`ot3`.`a`)) +SELECT * +FROM ot1 +JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +6 6 6 +# Example SQ4.3: +explain SELECT * +FROM ot1 +JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Start temporary +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; Using join buffer (hash join) +1 SIMPLE it1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; End temporary; Using join buffer (hash join) +1 SIMPLE ot3 NULL ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a`,`test`.`ot3`.`a` AS `a` from `test`.`ot1` join `test`.`ot2` left join `test`.`ot3` on((`test`.`ot3`.`a` = `test`.`ot2`.`a`)) semi join (`test`.`it1`) where ((`test`.`ot1`.`a` = `test`.`ot2`.`a`) and (`test`.`it1`.`a` = `test`.`ot2`.`a`)) +SELECT * +FROM ot1 +JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +2 2 NULL +4 4 NULL +6 6 6 +# Example SQ4.4: +explain SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 Start temporary +1 SIMPLE it1 NULL ALL NULL NULL NULL NULL 8 100.00 Using where; Using join buffer (hash join) +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (hash join) +1 SIMPLE ot3 NULL ALL NULL NULL NULL NULL 3 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a`,`test`.`ot3`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` left join `test`.`ot3` on((`test`.`ot3`.`a` = `test`.`it1`.`a`)) semi join (`test`.`it1`)) on(((`test`.`it1`.`a` = `test`.`ot1`.`a`) and (`test`.`ot2`.`a` = `test`.`ot1`.`a`))) where true +SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +1 NULL NULL +2 2 NULL +3 NULL NULL +4 4 NULL +5 NULL NULL +6 6 6 +7 NULL NULL +# More test cases +SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a+0) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it1); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 +JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a+0) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +6 6 6 +SELECT * +FROM ot1 +JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +6 6 6 +SELECT * +FROM ot1 +JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it1); +a a a +0 0 0 +6 6 6 +SELECT * +FROM ot1 +JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a+0) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +2 2 NULL +4 4 NULL +6 6 6 +SELECT * +FROM ot1 +JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +2 2 NULL +4 4 NULL +6 6 6 +SELECT * +FROM ot1 +JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it1); +a a a +0 0 0 +2 2 NULL +4 4 NULL +6 6 6 +SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a+0) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +1 NULL NULL +2 2 NULL +3 NULL NULL +4 4 NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +1 NULL NULL +2 2 NULL +3 NULL NULL +4 4 NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it1); +a a a +0 0 0 +1 NULL NULL +2 2 NULL +3 NULL NULL +4 4 NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1) +LEFT JOIN +ot1 AS ot4 +ON ot2.a=ot4.a; +a a a a +0 0 0 0 +1 NULL NULL NULL +2 2 NULL 2 +3 NULL NULL NULL +4 4 NULL 4 +5 NULL NULL NULL +6 6 6 6 +7 NULL NULL NULL +SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a +LEFT JOIN ot1 AS ot4 ON ot3.a=ot4.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a a +0 0 0 0 +1 NULL NULL NULL +2 2 NULL NULL +3 NULL NULL NULL +4 4 NULL NULL +5 NULL NULL NULL +6 6 6 6 +7 NULL NULL NULL +DROP TABLE ot1,ot2,ot3,it1,it2,it3; +CREATE TABLE t ( +a INTEGER DEFAULT NULL +) ENGINE=InnoDB; +INSERT INTO t VALUES (1); +CREATE TABLE t2 ( +a INTEGER DEFAULT NULL +) ENGINE=InnoDB; +INSERT INTO t2 VALUES (1),(1); +CREATE TABLE t4 ( +a INTEGER DEFAULT NULL +) ENGINE=InnoDB; +INSERT INTO t4 VALUES (1),(1); +CREATE TABLE v ( +a INTEGER DEFAULT NULL +) ENGINE=InnoDB; +INSERT INTO v VALUES (1),(1); +explain SELECT * +FROM t AS t1 +LEFT JOIN +(t2 +LEFT JOIN t AS t3 +ON t3.a IN (SELECT a FROM t AS it) +JOIN t4 +ON t4.a=100 +) +ON TRUE +WHERE t1.a IN (SELECT * FROM v AS it2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +2 SIMPLE it2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using join buffer (hash join) +2 SIMPLE it NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t4`.`a` AS `a` from `test`.`t` `t1` left join (`test`.`t2` left join (`test`.`t` `t3` semi join (`test`.`t` `it`)) on(((`test`.`it`.`a` = `test`.`t3`.`a`))) join `test`.`t4`) on(((`test`.`t4`.`a` = 100))) semi join (`test`.`v` `it2`) where (`test`.`it2`.`a` = `test`.`t1`.`a`) +SELECT * +FROM t AS t1 +LEFT JOIN +(t2 +LEFT JOIN t AS t3 +ON t3.a IN (SELECT a FROM t AS it) +JOIN t4 +ON t4.a=100 +) +ON TRUE +WHERE t1.a IN (SELECT * FROM v AS it2); +a a a a +1 NULL NULL NULL +DROP TABLE t,t2,t4,v; +# End of WL#5561 +# +# Bug#48868: Left outer join in subquery causes segmentation fault in +# make_join_select. +# +CREATE TABLE t1 (i INTEGER); +INSERT INTO t1 VALUES (1); +INSERT INTO t1 VALUES (2); +CREATE TABLE t2 (i INTEGER); +INSERT INTO t2 VALUES(1); +CREATE TABLE t3 (i INTEGER); +INSERT INTO t3 VALUES (1); +INSERT INTO t3 VALUES (2); +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t2.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +1 +DROP TABLE t1, t2, t3; + +Bug#37899: Wrongly checked optimization prerequisite caused failed +assertion. + +CREATE TABLE t1 ( +`pk` int(11), +`varchar_nokey` varchar(5) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES +(1,'qk'),(2,'j'),(3,'aew'); +SELECT * +FROM t1 +WHERE varchar_nokey IN ( +SELECT +varchar_nokey +FROM +t1 +) XOR pk = 30; +pk varchar_nokey +1 qk +2 j +3 aew +drop table t1; +# +# BUG#41842: Semi-join materialization strategy crashes when the upper query has HAVING +# +CREATE TABLE t1 ( +pk int(11) NOT NULL AUTO_INCREMENT, +int_nokey int(11) NOT NULL, +time_key time NOT NULL, +datetime_key datetime NOT NULL, +datetime_nokey datetime NOT NULL, +varchar_key varchar(1) NOT NULL, +varchar_nokey varchar(1) NOT NULL, +PRIMARY KEY (pk), +KEY time_key (time_key), +KEY datetime_key (datetime_key), +KEY varchar_key (varchar_key) +) ENGINE=MyISaM; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES +(1,0, '00:16:10','2008-09-03 14:25:40','2008-09-03 14:25:40','h','h'), +(2,7, '00:00:00','2001-01-13 00:00:00','2001-01-13 00:00:00','',''), +(3,0, '00:00:00','0000-00-00 00:00:00','0000-00-00 00:00:00','x','x'), +(4,2, '16:29:24','2000-10-16 01:39:08','2000-10-16 01:39:08','w','w'), +(5,1, '09:23:32','0000-00-00 00:00:00','0000-00-00 00:00:00','p','p'), +(6,3, '00:00:00','2007-12-02 00:00:00','2007-12-02 00:00:00','o','o'), +(7,3, '00:00:00','2008-09-11 00:00:00','2008-09-11 00:00:00','',''), +(8,0, '13:59:04','0000-00-00 00:00:00','0000-00-00 00:00:00','s','s'), +(9,7, '09:01:06','0000-00-00 00:00:00','0000-00-00 00:00:00','d','d'), +(10,5,'00:00:00','0000-00-00 00:00:00','0000-00-00 00:00:00','n','n'), +(11,0,'21:06:46','0000-00-00 00:00:00','0000-00-00 00:00:00','o','o'), +(12,2,'00:00:00','0000-00-00 00:00:00','0000-00-00 00:00:00','',''), +(13,6,'14:45:34','2003-07-28 02:34:08','2003-07-28 02:34:08','w','w'), +(14,1,'15:04:12','0000-00-00 00:00:00','0000-00-00 00:00:00','o','o'), +(15,0,'00:00:00','0000-00-00 00:00:00','0000-00-00 00:00:00','x','x'), +(16,0,'15:55:23','2004-03-17 00:32:27','2004-03-17 00:32:27','p','p'), +(17,1,'16:30:00','2004-12-27 19:20:00','2004-12-27 19:20:00','d','d'), +(18,0,'00:00:00','0000-00-00 00:00:00','0000-00-00 00:00:00','h','h'), +(19,0,'14:13:26','2008-11-09 05:53:48','2008-11-09 05:53:48','o','o'), +(20,0,'00:00:00','2009-10-11 06:58:04','2009-10-11 06:58:04','k','k'); +Warnings: +Warning 1264 Out of range value for column 'datetime_key' at row 3 +Warning 1264 Out of range value for column 'datetime_nokey' at row 3 +Warning 1264 Out of range value for column 'datetime_key' at row 5 +Warning 1264 Out of range value for column 'datetime_nokey' at row 5 +Warning 1264 Out of range value for column 'datetime_key' at row 8 +Warning 1264 Out of range value for column 'datetime_nokey' at row 8 +Warning 1264 Out of range value for column 'datetime_key' at row 9 +Warning 1264 Out of range value for column 'datetime_nokey' at row 9 +Warning 1264 Out of range value for column 'datetime_key' at row 10 +Warning 1264 Out of range value for column 'datetime_nokey' at row 10 +Warning 1264 Out of range value for column 'datetime_key' at row 11 +Warning 1264 Out of range value for column 'datetime_nokey' at row 11 +Warning 1264 Out of range value for column 'datetime_key' at row 12 +Warning 1264 Out of range value for column 'datetime_nokey' at row 12 +Warning 1264 Out of range value for column 'datetime_key' at row 14 +Warning 1264 Out of range value for column 'datetime_nokey' at row 14 +Warning 1264 Out of range value for column 'datetime_key' at row 15 +Warning 1264 Out of range value for column 'datetime_nokey' at row 15 +Warning 1264 Out of range value for column 'datetime_key' at row 18 +Warning 1264 Out of range value for column 'datetime_nokey' at row 18 +CREATE TABLE t2 ( +pk int(11) NOT NULL AUTO_INCREMENT, +int_nokey int(11) NOT NULL, +time_key time NOT NULL, +datetime_key datetime NOT NULL, +datetime_nokey datetime NOT NULL, +varchar_key varchar(1) NOT NULL, +varchar_nokey varchar(1) NOT NULL, +PRIMARY KEY (pk), +KEY time_key (time_key), +KEY datetime_key (datetime_key), +KEY varchar_key (varchar_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT IGNORE INTO t2 VALUES +(10,0,'19:39:13','0000-00-00 00:00:00','0000-00-00 00:00:00','g','g'), +(11,8,'03:43:53','0000-00-00 00:00:00','0000-00-00 00:00:00','b','b'); +Warnings: +Warning 1264 Out of range value for column 'datetime_key' at row 1 +Warning 1264 Out of range value for column 'datetime_nokey' at row 1 +Warning 1264 Out of range value for column 'datetime_key' at row 2 +Warning 1264 Out of range value for column 'datetime_nokey' at row 2 +SELECT OUTR.datetime_nokey AS X FROM t1 AS OUTR +WHERE +OUTR.varchar_nokey IN (SELECT +INNR . varchar_nokey AS Y +FROM t2 AS INNR +WHERE +INNR . datetime_key >= INNR . time_key OR +INNR . pk = INNR . int_nokey +) +AND OUTR . varchar_nokey <= 'w' +HAVING X > '2012-12-12'; +X +drop table t1, t2; + +Bug#46797 "Crash in fix_semijoin_strategies_for_picked_join_order +with semijoin=on" + +CREATE TABLE t1 ( +varchar_key varchar(1) DEFAULT NULL, +KEY varchar_key (varchar_key) +); +CREATE TABLE t2 ( +varchar_key varchar(1) DEFAULT NULL, +KEY varchar_key (varchar_key) +); +INSERT INTO t2 VALUES +(NULL),(NULL),(NULL),(NULL),('a'),('a'),('a'),('b'),('b'),('b'),('b'),('c'), +('c'),('c'),('c'),('c'),('c'),('c'),('d'),('d'),('d'),('d'),('d'),('d'),('e'), +('e'),('e'),('e'),('e'),('e'),('f'),('f'),('f'),('g'),('g'),('h'),('h'),('h'), +('h'),('i'),('j'),('j'),('j'),('k'),('k'),('l'),('l'),('m'),('m'),('m'),('m'), +('n'),('n'),('n'),('o'),('o'),('o'),('p'),('p'),('p'),('q'),('q'),('q'),('r'), +('r'),('r'),('r'),('s'),('s'),('s'),('s'),('t'),('t'),('t'),('t'),('u'),('u'), +('u'),('u'),('v'),('v'),('v'),('v'),('w'),('w'),('w'),('w'),('w'),('w'),('x'), +('x'),('x'),('y'),('y'),('y'),('y'),('z'),('z'),('z'),('z'); +CREATE TABLE t3 ( +varchar_key varchar(1) DEFAULT NULL, +KEY varchar_key (varchar_key) +) ENGINE=MyISAM DEFAULT CHARSET=latin1; +INSERT INTO t3 VALUES +(NULL),('c'),('d'),('e'),('f'),('h'),('j'),('k'),('k'),('m'),('m'),('m'), +('n'),('o'),('r'),('t'),('t'),('u'),('w'),('y'); +SELECT varchar_key FROM t3 +WHERE (SELECT varchar_key FROM t3 +WHERE (varchar_key,varchar_key) +IN (SELECT t1.varchar_key, t2 .varchar_key +FROM t1 RIGHT JOIN t2 ON t1.varchar_key +) +); +varchar_key +DROP TABLE t1, t2, t3; +# +# Bug#46556 Returning incorrect, empty results for some IN subqueries +# w/semijoin=on +# +CREATE TABLE t0 ( +pk INTEGER, +vkey VARCHAR(1), +vnokey VARCHAR(1), +PRIMARY KEY (pk), +KEY vkey(vkey) +) charset utf8mb4; +INSERT INTO t0 +VALUES (1,'g','g'), (2,'v','v'), (3,'t','t'), (4,'u','u'), (5,'n','n'); +EXPLAIN SELECT vkey FROM t0 WHERE pk IN +(SELECT t1.pk FROM t0 t1 JOIN t0 t2 ON t2.vkey = t1.vnokey); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index vkey vkey 7 NULL 5 100.00 Using index; Start temporary +1 SIMPLE t1 NULL ALL PRIMARY NULL NULL NULL 5 20.00 Using where; Using join buffer (hash join) +1 SIMPLE t0 NULL eq_ref PRIMARY PRIMARY 4 test.t1.pk 1 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`vkey` AS `vkey` from `test`.`t0` `t1` join `test`.`t0` semi join (`test`.`t0` `t2`) where ((`test`.`t1`.`vnokey` = `test`.`t2`.`vkey`) and (`test`.`t0`.`pk` = `test`.`t1`.`pk`)) +SELECT vkey FROM t0 WHERE pk IN +(SELECT t1.pk FROM t0 t1 JOIN t0 t2 ON t2.vkey = t1.vnokey); +vkey +g +n +t +u +v +DROP TABLE t0; +# End of bug#46556 + +Bug#48834: Procedure with view + subquery + semijoin=on +crashes on second call. + +CREATE TABLE t1 ( t1field integer, primary key (t1field)); +CREATE TABLE t2 ( t2field integer, primary key (t2field)); +CREATE VIEW v1 AS +SELECT t1field as v1field +FROM t1 A +WHERE A.t1field IN (SELECT t1field FROM t2 ); +CREATE VIEW v2 AS +SELECT t2field as v2field +FROM t2 A +WHERE A.t2field IN (SELECT t2field FROM t2 ); +CREATE PROCEDURE p1 () +BEGIN +SELECT v1field +FROM v1 +WHERE v1field IN ( SELECT v2field as vf_inner FROM v2 ); +END| +INSERT INTO t1 VALUES (1),(2),(3); +INSERT INTO t2 VALUES (2),(3),(4); +CALL p1; +v1field +2 +3 +CALL p1; +v1field +2 +3 +DROP TABLE t1,t2; +DROP VIEW v1,v2; +DROP PROCEDURE p1; +# End of BUG#48834 +# +# Bug#46692 "Crash occurring on queries with nested FROM subqueries +# using materialization." +# +CREATE TABLE t1 ( +pk INTEGER PRIMARY KEY, +int_key INTEGER, +KEY int_key(int_key) +); +INSERT INTO t1 VALUES (10,186),(11,NULL),(12,2),(13,3),(14,0),(15,133),(16,1); +CREATE TABLE t2 ( +pk INTEGER PRIMARY KEY, +int_key INTEGER, +KEY int_key(int_key) +); +INSERT INTO t2 VALUES (1,7),(2,2); +SELECT * FROM t1 WHERE (140, 4) IN +(SELECT t2.int_key, t2 .pk FROM t2 STRAIGHT_JOIN t1 ON t2.int_key); +pk int_key +DROP TABLE t1, t2; +# +# Bug#42353 "SELECT ... WHERE oe IN (SELECT w/ LEFT JOIN) query +# causes crash." +# +CREATE TABLE t1 ( +pk INTEGER PRIMARY KEY, +int_nokey INTEGER, +int_key INTEGER, +date_key DATE, +datetime_nokey DATETIME, +varchar_nokey VARCHAR(1) +); +CREATE TABLE t2 ( +date_nokey DATE +); +CREATE TABLE t3 ( +pk INTEGER PRIMARY KEY, +int_nokey INTEGER, +date_key date, +varchar_key VARCHAR(1), +varchar_nokey VARCHAR(1), +KEY date_key (date_key) +); +SELECT date_key FROM t1 +WHERE (int_key, int_nokey) +IN (SELECT t3.int_nokey, t3.pk +FROM t2 LEFT JOIN t3 ON (t2.date_nokey < t3.date_key) +WHERE t3.varchar_key <= t3.varchar_nokey OR t3.int_nokey <= t3.pk +) +AND (varchar_nokey <> 'f' OR NOT int_key < 7); +date_key +# +# Bug#45933 "Crash in optimize_semijoin_nests on JOIN in subquery +# + AND in outer query". +# +INSERT INTO t1 VALUES (10,7,5,'2009-06-16','2002-04-10 14:25:30','w'), +(11,7,0,'0000-00-00','0000-00-00 00:00:00','s'), +(12,4,0,'2003-07-14','2006-09-14 04:01:02','y'), +(13,0,4,'2002-07-25','0000-00-00 00:00:00','c'), +(14,1,8,'2007-07-03','0000-00-00 00:00:00','q'), +(15,6,5,'2001-11-12','0000-00-00 00:00:00',''), +(16,2,9,'0000-00-00','0000-00-00 00:00:00','j'), +(29,9,1,'0000-00-00','2003-08-11 00:00:00','m'); +Warnings: +Warning 1264 Out of range value for column 'date_key' at row 2 +Warning 1264 Out of range value for column 'datetime_nokey' at row 2 +Warning 1264 Out of range value for column 'datetime_nokey' at row 4 +Warning 1264 Out of range value for column 'datetime_nokey' at row 5 +Warning 1264 Out of range value for column 'datetime_nokey' at row 6 +Warning 1264 Out of range value for column 'date_key' at row 7 +Warning 1264 Out of range value for column 'datetime_nokey' at row 7 +Warning 1264 Out of range value for column 'date_key' at row 8 +INSERT IGNORE INTO t3 VALUES (1,9,'0000-00-00','b','b'), +(2,2,'2002-09-17','h','h'); +Warnings: +Warning 1264 Out of range value for column 'date_key' at row 1 +SELECT t1.varchar_nokey FROM t1 JOIN t3 ON t1.datetime_nokey +WHERE t1.varchar_nokey +IN (SELECT varchar_nokey FROM t1 +WHERE (pk) +IN (SELECT t3.int_nokey +FROM t3 LEFT JOIN t1 ON t1.varchar_nokey +WHERE t3.date_key BETWEEN '2008-06-07' AND '2006-06-26' + ) +); +varchar_nokey +DROP TABLE t1, t2, t3; +# +# Bug#45219 "Crash on SELECT DISTINCT query containing a +# LEFT JOIN in subquery" +# +CREATE TABLE t1 ( +pk INTEGER NOT NULL, +int_nokey INTEGER NOT NULL, +datetime_key DATETIME NOT NULL, +varchar_key VARCHAR(1) NOT NULL, +PRIMARY KEY (pk), +KEY datetime_key (datetime_key), +KEY varchar_key (varchar_key) +); +INSERT IGNORE INTO t1 VALUES +(1,9,'0000-00-00 00:00:00','p'),(2,0,'2002-02-09 07:38:13','v'), +(3,8,'2001-05-03 12:08:14','t'),(4,3,'0000-00-00 00:00:00','u'), +(5,7,'2009-07-28 03:43:30','n'),(6,0,'2009-08-04 00:00:00','l'), +(7,1,'0000-00-00 00:00:00','h'),(8,9,'0000-00-00 00:00:00','u'), +(9,0,'2005-08-02 17:16:54','n'),(10,9,'2002-12-21 00:00:00','j'), +(11,0,'2005-08-15 12:37:35','k'),(12,5,'0000-00-00 00:00:00','e'), +(13,0,'2006-03-10 00:00:00','i'),(14,8,'2005-05-16 11:02:36','u'), +(15,8,'2008-11-02 00:00:00','n'),(16,5,'2006-03-15 00:00:00','b'), +(17,1,'0000-00-00 00:00:00','x'),(18,7,'0000-00-00 00:00:00',''), +(19,0,'2008-12-17 20:15:40','q'),(20,9,'0000-00-00 00:00:00','u'); +Warnings: +Warning 1264 Out of range value for column 'datetime_key' at row 1 +Warning 1264 Out of range value for column 'datetime_key' at row 4 +Warning 1264 Out of range value for column 'datetime_key' at row 7 +Warning 1264 Out of range value for column 'datetime_key' at row 8 +Warning 1264 Out of range value for column 'datetime_key' at row 12 +Warning 1264 Out of range value for column 'datetime_key' at row 17 +Warning 1264 Out of range value for column 'datetime_key' at row 18 +Warning 1264 Out of range value for column 'datetime_key' at row 20 +CREATE TABLE t2 LIKE t1; +INSERT INTO t2 VALUES +(10,0,'2006-07-07 07:26:28','q'),(11,5,'2002-09-23 00:00:00','m'), +(12,7,'0000-00-00 00:00:00','j'),(13,1,'2006-06-07 00:00:00','z'), +(14,8,'2000-09-16 12:15:34','a'),(15,2,'2007-08-05 15:47:52',''), +(16,1,'0000-00-00 00:00:00','e'),(17,8,'2005-12-02 19:34:26','t'), +(18,5,'0000-00-00 00:00:00','q'),(19,4,'0000-00-00 00:00:00','b'), +(20,5,'2007-12-28 00:00:00','w'),(21,3,'2004-08-02 11:48:43','m'), +(22,0,'0000-00-00 00:00:00','x'),(23,8,'2004-04-19 12:18:43',''), +(24,0,'2009-04-27 00:00:00','w'),(25,4,'2006-10-20 14:52:15','x'), +(26,0,'0000-00-00 00:00:00','e'),(27,0,'2002-03-22 11:48:37','e'), +(28,2,'0000-00-00 00:00:00','p'),(29,0,'2001-01-04 03:55:07','x'); +Warnings: +Warning 1264 Out of range value for column 'datetime_key' at row 3 +Warning 1264 Out of range value for column 'datetime_key' at row 7 +Warning 1264 Out of range value for column 'datetime_key' at row 9 +Warning 1264 Out of range value for column 'datetime_key' at row 10 +Warning 1264 Out of range value for column 'datetime_key' at row 13 +Warning 1264 Out of range value for column 'datetime_key' at row 17 +Warning 1264 Out of range value for column 'datetime_key' at row 19 +CREATE TABLE t3 LIKE t1; +INSERT INTO t3 VALUES +(10,8,'2007-08-19 08:08:38','i'),(11,0,'2000-05-21 03:51:51',''); +SELECT DISTINCT datetime_key FROM t1 +WHERE (int_nokey, pk) +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#46550 Azalea returning duplicate results for some IN subqueries +# w/ semijoin=on +# +DROP TABLE IF EXISTS t0, t1, t2; +CREATE TABLE t0 ( +int_key int(11) DEFAULT NULL, +varchar_key varchar(1) DEFAULT NULL, +varchar_nokey varchar(1) DEFAULT NULL, +KEY int_key (int_key), +KEY varchar_key (varchar_key,int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t0 VALUES +(1,'m','m'), +(40,'h','h'), +(1,'r','r'), +(1,'h','h'), +(9,'x','x'), +(NULL,'q','q'), +(NULL,'k','k'), +(7,'l','l'), +(182,'k','k'), +(202,'a','a'), +(7,'x','x'), +(6,'j','j'), +(119,'z','z'), +(4,'d','d'), +(5,'h','h'), +(1,'u','u'), +(3,'q','q'), +(7,'a','a'), +(3,'e','e'), +(6,'l','l'); +CREATE TABLE t1 ( +int_key int(11) DEFAULT NULL, +varchar_key varchar(1) DEFAULT NULL, +varchar_nokey varchar(1) DEFAULT NULL, +KEY int_key (int_key), +KEY varchar_key (varchar_key,int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (7,NULL,NULL),(4,'x','x'); +CREATE TABLE t2 ( +int_key int(11) DEFAULT NULL, +varchar_key varchar(1) DEFAULT NULL, +varchar_nokey varchar(1) DEFAULT NULL, +KEY int_key (int_key), +KEY varchar_key (varchar_key,int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (123,NULL,NULL); +SELECT int_key +FROM t0 +WHERE varchar_nokey IN ( +SELECT t1 .varchar_key from t1 +); +int_key +7 +9 +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 +7 +9 +EXPLAIN +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 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1_1 NULL index varchar_key varchar_key 12 NULL 2 50.00 Using where; Using index; LooseScan +1 SIMPLE t1_2 NULL index NULL int_key 5 NULL 2 100.00 Using index; FirstMatch(t1_1) +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 20 10.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`int_key` AS `int_key` from `test`.`t0` semi join (`test`.`t1` `t1_1` join `test`.`t1` `t1_2`) where ((`test`.`t0`.`varchar_nokey` = `test`.`t1_1`.`varchar_key`) and (0 <> `test`.`t1_1`.`int_key`)) +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 +7 +9 +EXPLAIN +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 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t1_1 NULL index varchar_key varchar_key 12 NULL 2 50.00 Using where; Using index; LooseScan +1 SIMPLE t1_2 NULL index NULL int_key 5 NULL 2 100.00 Using index; FirstMatch(t1_1) +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 20 10.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`int_key` AS `int_key` from `test`.`t0` semi join (`test`.`t1` `t1_1` join `test`.`t1` `t1_2`) where ((`test`.`t0`.`varchar_nokey` = `test`.`t1_1`.`varchar_key`) and (0 <> `test`.`t1_1`.`int_key`)) +DROP TABLE t0, t1, t2; +# End of bug#46550 + +Bug #48073 Subquery on char columns from view crashes Mysql + +DROP TABLE IF EXISTS t1, t2; +DROP VIEW IF EXISTS v1; +CREATE TABLE t1 ( +city VARCHAR(50) NOT NULL, +country_id SMALLINT UNSIGNED NOT NULL +); +INSERT INTO t1 VALUES +('Batna',2), +('Bchar',2), +('Skikda',2), +('Tafuna',3), +('Algeria',2) ; +CREATE TABLE t2 ( +country_id SMALLINT UNSIGNED NOT NULL, +country VARCHAR(50) NOT NULL +); +INSERT INTO t2 VALUES +(2,'Algeria'), +(3,'American Samoa') ; +CREATE VIEW v1 AS +SELECT country_id, country +FROM t2 +WHERE LEFT(country,1) = "A" +; +SELECT city, country_id +FROM t1 +WHERE city IN ( +SELECT country +FROM t2 +WHERE LEFT(country, 1) = "A" +); +city country_id +Algeria 2 +SELECT city, country_id +FROM t1 +WHERE city IN ( +SELECT country +FROM v1 +); +city country_id +Algeria 2 +drop table t1, t2; +drop view v1; +# End of bug#48073 + +Bug#49097 subquery with view generates wrong result with +non-prepared statement + +DROP TABLE IF EXISTS t1, t2; +DROP VIEW IF EXISTS v1; +CREATE TABLE t1 ( +city VARCHAR(50) NOT NULL, +country_id SMALLINT UNSIGNED NOT NULL +); +INSERT INTO t1 VALUES +('Batna',2), +('Bchar',2), +('Skikda',2), +('Tafuna',3), +('Algeria',2) ; +CREATE TABLE t2 ( +country_id SMALLINT UNSIGNED NOT NULL, +country VARCHAR(50) NOT NULL +); +INSERT INTO t2 VALUES +(2,'Algeria'), +(3,'XAmerican Samoa') ; +CREATE VIEW v1 AS +SELECT country_id, country +FROM t2 +WHERE LEFT(country,1) = "A" +; +SELECT city, country_id +FROM t1 +WHERE country_id IN ( +SELECT country_id +FROM t2 +WHERE LEFT(country,1) = "A" +); +city country_id +Algeria 2 +Batna 2 +Bchar 2 +Skikda 2 +SELECT city, country_id +FROM t1 +WHERE country_id IN ( +SELECT country_id +FROM v1 +); +city country_id +Algeria 2 +Batna 2 +Bchar 2 +Skikda 2 +PREPARE stmt FROM +" +SELECT city, country_id +FROM t1 +WHERE country_id IN ( + SELECT country_id + FROM v1 +); +"; +execute stmt; +city country_id +Algeria 2 +Batna 2 +Bchar 2 +Skikda 2 +deallocate prepare stmt; +drop table t1, t2; +drop view v1; +# End of Bug#49097 +# +# Bug#49198 Wrong result for second call of procedure +# with view in subselect. +# +CREATE TABLE t1 (t1field integer, primary key (t1field)); +CREATE TABLE t2 (t2field integer, primary key (t2field)); +CREATE TABLE t3 (t3field integer, primary key (t3field)); +CREATE VIEW v2 AS SELECT * FROM t2; +CREATE VIEW v3 AS SELECT * FROM t3; +INSERT INTO t1 VALUES(1),(2); +INSERT INTO t2 VALUES(1),(2); +INSERT INTO t3 VALUES(1),(2); +PREPARE stmt FROM +" +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT * FROM v2); +"; +EXECUTE stmt; +t1field +1 +2 + +EXECUTE stmt; +t1field +1 +2 +PREPARE stmt FROM +" +EXPLAIN +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT * FROM v2) + AND t1field IN (SELECT * FROM v3) +"; +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index PRIMARY PRIMARY 4 NULL 2 100.00 Using index +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +1 SIMPLE t3 NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`t1field` AS `t1field` from `test`.`t2` join `test`.`t3` join `test`.`t1` where ((`test`.`t2`.`t2field` = `test`.`t1`.`t1field`) and (`test`.`t3`.`t3field` = `test`.`t1`.`t1field`)) + +This line is only in place to help --skip_if_hypergraph diffing some more. + +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index PRIMARY PRIMARY 4 NULL 2 100.00 Using index +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +1 SIMPLE t3 NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`t1field` AS `t1field` from `test`.`t2` join `test`.`t3` join `test`.`t1` where ((`test`.`t2`.`t2field` = `test`.`t1`.`t1field`) and (`test`.`t3`.`t3field` = `test`.`t1`.`t1field`)) +DROP TABLE t1, t2, t3; +DROP VIEW v2, v3; +# End of Bug#49198 +# +# Bug#48623 Multiple subqueries are optimized incorrectly +# +CREATE TABLE ot(val VARCHAR(10)) charset utf8mb4; +CREATE TABLE it1(val VARCHAR(10)) charset utf8mb4; +CREATE TABLE it2(val VARCHAR(10)) charset utf8mb4; +INSERT INTO ot VALUES('aaa'), ('bbb'), ('eee'), ('mmm'), ('ppp'); +INSERT INTO it1 VALUES('aaa'), ('aaa'), ('bbb'), ('eee'), ('mmm'), ('ppp'); +INSERT INTO it2 VALUES('aaa'), ('bbb'), ('eee'), ('mmm'), ('ppp'); +EXPLAIN +SELECT * +FROM ot +WHERE ot.val IN (SELECT it1.val FROM it1 +WHERE it1.val LIKE 'a%' OR it1.val LIKE 'e%') +AND ot.val IN (SELECT it2.val FROM it2 +WHERE it2.val LIKE 'a%' OR it2.val LIKE 'e%'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE it2 NULL ALL NULL NULL NULL NULL 5 36.00 Using where; Start temporary +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 5 20.00 Using where; Using join buffer (hash join) +1 SIMPLE it1 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot`.`val` AS `val` from `test`.`ot` semi join (`test`.`it1`) semi join (`test`.`it2`) where ((`test`.`ot`.`val` = `test`.`it2`.`val`) and (`test`.`it1`.`val` = `test`.`it2`.`val`) and ((`test`.`it1`.`val` like 'a%') or (`test`.`it1`.`val` like 'e%')) and ((`test`.`it2`.`val` like 'a%') or (`test`.`it2`.`val` like 'e%'))) +SELECT * +FROM ot +WHERE ot.val IN (SELECT it1.val FROM it1 +WHERE it1.val LIKE 'a%' OR it1.val LIKE 'e%') +AND ot.val IN (SELECT it2.val FROM it2 +WHERE it2.val LIKE 'a%' OR it2.val LIKE 'e%'); +val +aaa +eee +DROP TABLE ot; +DROP TABLE it1; +DROP TABLE it2; +# End of Bug#48623 +# +# Bug #51487 Assertion failure when semi-join flattening occurs +# for a subquery in HAVING +# +CREATE TABLE t1 (a INT, b INT); +INSERT INTO t1 VALUES (1,10),(2,11),(1,13); +CREATE TABLE t2 AS SELECT * FROM t1; +CREATE TABLE t3 AS SELECT * FROM t1; +SELECT COUNT(*) FROM t1 +GROUP BY t1.a +HAVING t1.a IN (SELECT t3.a FROM t3 +WHERE t3.b IN (SELECT b FROM t2 WHERE t2.a=t1.a)); +COUNT(*) +2 +1 +DROP TABLE t1, t2, t3; +# End of Bug#51487 +# +# BUG#38075: Wrong result: rows matching a subquery with outer join not returned +# +DROP TABLE IF EXISTS ot1, it1, it2; +CREATE TABLE it2 ( +int_key int(11) NOT NULL, +datetime_key datetime NOT NULL, +KEY int_key (int_key), +KEY datetime_key (datetime_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO it2 VALUES +(5,'2002-04-10 14:25:30'), (0,'0000-00-00 00:00:00'), +(0,'2006-09-14 04:01:02'), (4,'0000-00-00 00:00:00'), +(8,'0000-00-00 00:00:00'), (5,'0000-00-00 00:00:00'), +(9,'0000-00-00 00:00:00'), (8,'2007-04-01 11:04:17'), +(1,'0000-00-00 00:00:00'), (7,'2009-01-12 00:00:00'), +(0,'2009-06-05 00:00:00'), (3,'2006-02-14 18:06:35'), +(5,'2006-02-21 07:08:16'), (0,'0000-00-00 00:00:00'), +(7,'0000-00-00 00:00:00'), (0,'0000-00-00 00:00:00'), +(0,'2007-02-13 00:00:00'), (1,'0000-00-00 00:00:00'), +(0,'0000-00-00 00:00:00'), (1,'2003-08-11 00:00:00'); +Warnings: +Warning 1264 Out of range value for column 'datetime_key' at row 2 +Warning 1264 Out of range value for column 'datetime_key' at row 4 +Warning 1264 Out of range value for column 'datetime_key' at row 5 +Warning 1264 Out of range value for column 'datetime_key' at row 6 +Warning 1264 Out of range value for column 'datetime_key' at row 7 +Warning 1264 Out of range value for column 'datetime_key' at row 9 +Warning 1264 Out of range value for column 'datetime_key' at row 14 +Warning 1264 Out of range value for column 'datetime_key' at row 15 +Warning 1264 Out of range value for column 'datetime_key' at row 16 +Warning 1264 Out of range value for column 'datetime_key' at row 18 +Warning 1264 Out of range value for column 'datetime_key' at row 19 +CREATE TABLE ot1 ( +int_nokey int(11) NOT NULL, +int_key int(11) NOT NULL, +KEY int_key (int_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO ot1 VALUES +(5,0), (3,0), (0,2), (3,0), (1,3), (0,0), (1,7), (7,0), (1,7), (0,7), +(0,9), (8,2), (4,4), (9,3), (0,9), (2,5), (0,5), (8,0), (5,8), (1,5); +CREATE TABLE it1 ( +int_nokey int(11) NOT NULL, +int_key int(11) NOT NULL, +KEY int_key (int_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO it1 VALUES +(9,5), (0,4); +SELECT int_key FROM ot1 +WHERE int_nokey IN (SELECT it2.int_key +FROM it1 LEFT JOIN it2 ON it2.datetime_key); +int_key +0 +0 +0 +0 +0 +0 +2 +2 +3 +5 +5 +7 +7 +7 +8 +9 +9 +EXPLAIN +SELECT int_key FROM ot1 +WHERE int_nokey IN (SELECT it2.int_key +FROM it1 LEFT JOIN it2 ON it2.datetime_key); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 20 100.00 Start temporary +1 SIMPLE it2 NULL ref int_key int_key 4 test.ot1.int_nokey 2 90.00 Using where +1 SIMPLE it1 NULL index NULL int_key 4 NULL 2 100.00 Using index; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`int_key` AS `int_key` from `test`.`ot1` semi join (`test`.`it1` join `test`.`it2`) where ((`test`.`it2`.`int_key` = `test`.`ot1`.`int_nokey`) and (TIMESTAMP'0000-00-00 00:00:00' <> `test`.`it2`.`datetime_key`)) +DROP TABLE ot1, it1, it2; +# End of BUG#38075 +# +# BUG#50089: Second call of procedure with view in subselect crashes server +# +CREATE TABLE t1(t1field INTEGER, PRIMARY KEY(t1field)); +CREATE VIEW v1 AS +SELECT t1field AS v1field +FROM t1 a +WHERE a.t1field IN (SELECT t1field FROM t1); +INSERT INTO t1 VALUES(1),(2); +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT v1field FROM v1); +t1field +1 +2 +EXPLAIN +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT v1field FROM v1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index PRIMARY PRIMARY 4 NULL 2 100.00 Using index +1 SIMPLE a NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `t1`.`t1field` AS `t1field` from `test`.`t1` `a` join `test`.`t1` join `test`.`t1` where ((`test`.`a`.`t1field` = `t1`.`t1field`) and (`test`.`t1`.`t1field` = `t1`.`t1field`)) +SELECT t1.t1field +FROM t1 LEFT JOIN t1 AS t2 ON t1.t1field IN (SELECT v1field FROM v1); +t1field +1 +1 +2 +2 +EXPLAIN +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT v1field FROM v1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index PRIMARY PRIMARY 4 NULL 2 100.00 Using index +1 SIMPLE a NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `t1`.`t1field` AS `t1field` from `test`.`t1` `a` join `test`.`t1` join `test`.`t1` where ((`test`.`a`.`t1field` = `t1`.`t1field`) and (`test`.`t1`.`t1field` = `t1`.`t1field`)) +CREATE PROCEDURE p1() +BEGIN +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT v1field FROM v1); +END| +CALL p1; +t1field +1 +2 +CALL p1; +t1field +1 +2 +PREPARE stmt FROM +" +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT v1field FROM v1); +"; +EXECUTE stmt; +t1field +1 +2 + +EXECUTE stmt; +t1field +1 +2 +DROP PROCEDURE p1; +DROP VIEW v1; +DROP TABLE t1; +# End of BUG#50089 +# +# Bug#45191: Incorrectly initialized semi-join led to a wrong result. +# +CREATE TABLE staff (EMPNUM CHAR(3) NOT NULL, +EMPNAME CHAR(20), GRADE DECIMAL(4), CITY CHAR(15)) charset latin1; +CREATE TABLE proj (PNUM CHAR(3) NOT NULL, +PNAME CHAR(20), PTYPE CHAR(6), +BUDGET DECIMAL(9), +CITY CHAR(15)) charset latin1; +CREATE TABLE works (EMPNUM CHAR(3) NOT NULL, +PNUM CHAR(3) NOT NULL, HOURS DECIMAL(5)) charset latin1; +INSERT INTO staff VALUES ('E1','Alice',12,'Deale'); +INSERT INTO staff VALUES ('E2','Betty',10,'Vienna'); +INSERT INTO staff VALUES ('E3','Carmen',13,'Vienna'); +INSERT INTO staff VALUES ('E4','Don',12,'Deale'); +INSERT INTO staff VALUES ('E5','Ed',13,'Akron'); +INSERT INTO proj VALUES ('P1','MXSS','Design',10000,'Deale'); +INSERT INTO proj VALUES ('P2','CALM','Code',30000,'Vienna'); +INSERT INTO proj VALUES ('P3','SDP','Test',30000,'Tampa'); +INSERT INTO proj VALUES ('P4','SDP','Design',20000,'Deale'); +INSERT INTO proj VALUES ('P5','IRM','Test',10000,'Vienna'); +INSERT INTO proj VALUES ('P6','PAYR','Design',50000,'Deale'); +INSERT INTO works VALUES ('E1','P1',40); +INSERT INTO works VALUES ('E1','P2',20); +INSERT INTO works VALUES ('E1','P3',80); +INSERT INTO works VALUES ('E1','P4',20); +INSERT INTO works VALUES ('E1','P5',12); +INSERT INTO works VALUES ('E1','P6',12); +INSERT INTO works VALUES ('E2','P1',40); +INSERT INTO works VALUES ('E2','P2',80); +INSERT INTO works VALUES ('E3','P2',20); +INSERT INTO works VALUES ('E4','P2',20); +INSERT INTO works VALUES ('E4','P4',40); +INSERT INTO works VALUES ('E4','P5',80); +explain SELECT EMPNUM, EMPNAME +FROM staff +WHERE EMPNUM IN +(SELECT EMPNUM FROM works +WHERE PNUM IN +(SELECT PNUM FROM proj)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE staff NULL ALL NULL NULL NULL NULL 5 100.00 Start temporary +1 SIMPLE works NULL ALL NULL NULL NULL NULL 12 10.00 Using where; Using join buffer (hash join) +1 SIMPLE proj NULL ALL NULL NULL NULL NULL 6 16.67 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`staff`.`EMPNUM` AS `EMPNUM`,`test`.`staff`.`EMPNAME` AS `EMPNAME` from `test`.`staff` semi join (`test`.`works` join `test`.`proj`) where ((`test`.`works`.`EMPNUM` = `test`.`staff`.`EMPNUM`) and (`test`.`proj`.`PNUM` = `test`.`works`.`PNUM`)) +SELECT EMPNUM, EMPNAME +FROM staff +WHERE EMPNUM IN +(SELECT EMPNUM FROM works +WHERE PNUM IN +(SELECT PNUM FROM proj)); +EMPNUM EMPNAME +E1 Alice +E2 Betty +E3 Carmen +E4 Don +drop table staff,works,proj; +# End of bug#45191 +# +# BUG#36896: Server crash on SELECT FROM DUAL +# +create table t1 (a int); +select 1 as res from dual where (1) in (select * from t1); +res +drop table t1; + +BUG#40118 Crash when running Batched Key Access and requiring one match for each key + +create table t0(a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (a int, key(a)); +insert into t1 select * from t0; +alter table t1 add b int not null, add filler char(200); +insert into t1 select * from t1; +insert into t1 select * from t1; +select * from t0 where t0.a in (select t1.a from t1 where t1.b=0); +a +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +drop table t0, t1; +# +# BUG#32665 Query with dependent subquery is too slow +# +create table t1 ( +idIndividual int primary key +); +insert into t1 values (1),(2); +create table t2 ( +idContact int primary key, +contactType int, +idObj int +); +insert into t2 values (1,1,1),(2,2,2),(3,3,3); +create table t3 ( +idAddress int primary key, +idContact int, +postalStripped varchar(100) +); +insert into t3 values (1,1, 'foo'), (2,2,'bar'); +The following must be converted to a semi-join: +explain SELECT a.idIndividual FROM t1 a +WHERE a.idIndividual IN +( SELECT c.idObj FROM t3 cona +INNER JOIN t2 c ON c.idContact=cona.idContact +WHERE cona.postalStripped='T2H3B2' + ); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE cona NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE c NULL eq_ref PRIMARY PRIMARY 4 test.cona.idContact 1 100.00 Using where +1 SIMPLE a NULL eq_ref PRIMARY PRIMARY 4 test.c.idObj 1 100.00 Using index; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`a`.`idIndividual` AS `idIndividual` from `test`.`t1` `a` semi join (`test`.`t3` `cona` join `test`.`t2` `c`) where ((`test`.`c`.`idContact` = `test`.`cona`.`idContact`) and (`test`.`a`.`idIndividual` = `test`.`c`.`idObj`) and (`test`.`cona`.`postalStripped` = 'T2H3B2')) +drop table t1,t2,t3; +CREATE TABLE t1 (one int, two int, flag char(1)); +CREATE TABLE t2 (one int, two int, flag char(1)); +INSERT INTO t1 VALUES(1,2,'Y'),(2,3,'Y'),(3,4,'Y'),(5,6,'N'),(7,8,'N'); +INSERT INTO t2 VALUES(1,2,'Y'),(2,3,'Y'),(3,4,'Y'),(5,6,'N'),(7,8,'N'); +SELECT * FROM t1 +WHERE ROW(one,two) IN (SELECT DISTINCT one,two FROM t2 WHERE flag = 'N'); +one two flag +5 6 N +7 8 N +SELECT * FROM t1 +WHERE ROW(one,two) IN (SELECT DISTINCT one,two FROM t1 WHERE flag = 'N'); +one two flag +5 6 N +7 8 N +insert into t2 values (null,null,'N'); +insert into t2 values (null,3,'0'); +insert into t2 values (null,5,'0'); +insert into t2 values (10,null,'0'); +insert into t1 values (10,3,'0'); +insert into t1 values (10,5,'0'); +insert into t1 values (10,10,'0'); +SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = 'N') as 'test' from t1; +one two test +1 2 NULL +2 3 NULL +3 4 NULL +5 6 1 +7 8 1 +10 3 NULL +10 5 NULL +10 10 NULL +SELECT one,two from t1 where ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = 'N'); +one two +5 6 +7 8 +SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = 'N' group by one,two) as 'test' from t1; +one two test +1 2 NULL +2 3 NULL +3 4 NULL +5 6 1 +7 8 1 +10 3 NULL +10 5 NULL +10 10 NULL +SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = '0') as 'test' from t1; +one two test +1 2 0 +2 3 NULL +3 4 0 +5 6 0 +7 8 0 +10 3 NULL +10 5 NULL +10 10 NULL +SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = '0' group by one,two) as 'test' from t1; +one two test +1 2 0 +2 3 NULL +3 4 0 +5 6 0 +7 8 0 +10 3 NULL +10 5 NULL +10 10 NULL +explain SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = '0') as 'test' from t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 9 11.11 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`one` AS `one`,`test`.`t1`.`two` AS `two`,((`test`.`t1`.`one`,`test`.`t1`.`two`),(/* select#2 */ select `test`.`t2`.`one`,`test`.`t2`.`two` from `test`.`t2` where ((`test`.`t2`.`flag` = '0') and (outer_field_is_not_null, (((`test`.`t1`.`one`) = `test`.`t2`.`one`) or (`test`.`t2`.`one` is null)), true) and (outer_field_is_not_null, (((`test`.`t1`.`two`) = `test`.`t2`.`two`) or (`test`.`t2`.`two` is null)), true)) having ((outer_field_is_not_null, (`test`.`t2`.`one`), true) and (outer_field_is_not_null, (`test`.`t2`.`two`), true)))) AS `test` from `test`.`t1` +explain SELECT one,two from t1 where ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = 'N'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 9 11.11 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`one` AS `one`,`test`.`t1`.`two` AS `two` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`two` = `test`.`t2`.`two`) and (`test`.`t1`.`one` = `test`.`t2`.`one`) and (`test`.`t2`.`flag` = 'N')) +explain SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = '0' group by one,two) as 'test' from t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 9 11.11 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`one` AS `one`,`test`.`t1`.`two` AS `two`,((`test`.`t1`.`one`,`test`.`t1`.`two`),(/* select#2 */ select `test`.`t2`.`one`,`test`.`t2`.`two` from `test`.`t2` where ((`test`.`t2`.`flag` = '0') and (outer_field_is_not_null, (((`test`.`t1`.`one`) = `test`.`t2`.`one`) or (`test`.`t2`.`one` is null)), true) and (outer_field_is_not_null, (((`test`.`t1`.`two`) = `test`.`t2`.`two`) or (`test`.`t2`.`two` is null)), true)) having ((outer_field_is_not_null, (`test`.`t2`.`one`), true) and (outer_field_is_not_null, (`test`.`t2`.`two`), true)))) AS `test` from `test`.`t1` +DROP TABLE t1,t2; +CREATE TABLE t1 (a char(5), b char(5)); +INSERT INTO t1 VALUES (NULL,'aaa'), ('aaa','aaa'); +SELECT * FROM t1 WHERE (a,b) IN (('aaa','aaa'), ('aaa','bbb')); +a b +aaa aaa +DROP TABLE t1; +CREATE TABLE t1 (a CHAR(1), b VARCHAR(10)) charset utf8mb4; +INSERT INTO t1 VALUES ('a', 'aa'); +INSERT INTO t1 VALUES ('a', 'aaa'); +SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1); +a b +CREATE INDEX I1 ON t1 (a); +CREATE INDEX I2 ON t1 (b); +EXPLAIN SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index I1 I1 5 NULL 2 100.00 Using index; LooseScan +1 SIMPLE t1 NULL ALL I2 NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t1`) where (`test`.`t1`.`b` = `test`.`t1`.`a`) +SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1); +a b +CREATE TABLE t2 (a VARCHAR(1), b VARCHAR(10)) charset utf8mb4; +INSERT INTO t2 SELECT * FROM t1; +CREATE INDEX I1 ON t2 (a); +CREATE INDEX I2 ON t2 (b); +EXPLAIN SELECT a,b FROM t2 WHERE b IN (SELECT a FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index I1 I1 7 NULL 2 100.00 Using index; LooseScan +1 SIMPLE t2 NULL ALL I2 NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t2` semi join (`test`.`t2`) where (`test`.`t2`.`b` = `test`.`t2`.`a`) +SELECT a,b FROM t2 WHERE b IN (SELECT a FROM t2); +a b +EXPLAIN +SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1 WHERE LENGTH(a)<500); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index I1 I1 5 NULL 2 100.00 Using where; Using index; LooseScan +1 SIMPLE t1 NULL ALL I2 NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t1`) where ((length(`test`.`t1`.`a`) < 500) and (`test`.`t1`.`b` = `test`.`t1`.`a`)) +SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1 WHERE LENGTH(a)<500); +a b +DROP TABLE t1,t2; +# +# BUG#45928 "Differing query results depending on MRR and +# engine_condition_pushdown settings" +# +CREATE TABLE `t1` ( +`pk` int(11) NOT NULL AUTO_INCREMENT, +`time_nokey` time NOT NULL, +`varchar_key` varchar(1) NOT NULL, +`varchar_nokey` varchar(1) NOT NULL, +PRIMARY KEY (`pk`), +KEY `varchar_key` (`varchar_key`) +) AUTO_INCREMENT=12 DEFAULT CHARSET=latin1; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO `t1` VALUES (10,'00:00:00','i','i'),(11,'00:00:00','',''); +SELECT `time_nokey` G1 FROM t1 WHERE ( `varchar_nokey` , `varchar_key` ) IN ( +SELECT `varchar_nokey` , `varchar_nokey` ) AND `varchar_key` >= 'c' HAVING G1 ORDER +BY `pk` ; +G1 +DROP TABLE t1; +# +# BUG#45863 "Assertion failed: (fixed == 0), function fix_fields(), +# file item.cc, line 4448" +# +DROP TABLE IF EXISTS C, BB; +CREATE TABLE C ( +varchar_nokey varchar(1) NOT NULL +); +INSERT INTO C VALUES +('k'),('a'),(''),('u'),('e'),('v'),('i'), +('t'),('u'),('f'),('u'),('m'),('j'),('f'), +('v'),('j'),('g'),('e'),('h'),('z'); +CREATE TABLE BB ( +varchar_nokey varchar(1) NOT NULL +); +INSERT INTO BB VALUES ('i'),('t'); +SELECT varchar_nokey FROM C +WHERE (varchar_nokey, OUTR) IN (SELECT varchar_nokey +FROM BB); +ERROR 42S22: Unknown column 'OUTR' in 'IN/ALL/ANY subquery' +SELECT varchar_nokey FROM C +WHERE (varchar_nokey, OUTR) IN (SELECT varchar_nokey, varchar_nokey +FROM BB); +ERROR 42S22: Unknown column 'OUTR' in 'IN/ALL/ANY subquery' +DROP TABLE C,BB; +# +# During work with BUG#45863 I had problems with a query that was +# optimized differently in regular and prepared mode. +# Because there was a bug in one of the selected strategies, I became +# aware of the problem. Adding an EXPLAIN query to catch this. +DROP TABLE IF EXISTS t1, t2, t3; +CREATE TABLE t1 +(EMPNUM CHAR(3) NOT NULL, +EMPNAME CHAR(20), +GRADE DECIMAL(4), +CITY CHAR(15)) charset latin1; +CREATE TABLE t2 +(PNUM CHAR(3) NOT NULL, +PNAME CHAR(20), +PTYPE CHAR(6), +BUDGET DECIMAL(9), +CITY CHAR(15)) charset latin1; +CREATE TABLE t3 +(EMPNUM CHAR(3) NOT NULL, +PNUM CHAR(3) NOT NULL, +HOURS DECIMAL(5)) charset latin1; +INSERT INTO t1 VALUES ('E1','Alice',12,'Deale'); +INSERT INTO t1 VALUES ('E2','Betty',10,'Vienna'); +INSERT INTO t1 VALUES ('E3','Carmen',13,'Vienna'); +INSERT INTO t1 VALUES ('E4','Don',12,'Deale'); +INSERT INTO t1 VALUES ('E5','Ed',13,'Akron'); +INSERT INTO t2 VALUES ('P1','MXSS','Design',10000,'Deale'); +INSERT INTO t2 VALUES ('P2','CALM','Code',30000,'Vienna'); +INSERT INTO t2 VALUES ('P3','SDP','Test',30000,'Tampa'); +INSERT INTO t2 VALUES ('P4','SDP','Design',20000,'Deale'); +INSERT INTO t2 VALUES ('P5','IRM','Test',10000,'Vienna'); +INSERT INTO t2 VALUES ('P6','PAYR','Design',50000,'Deale'); +INSERT INTO t3 VALUES ('E1','P1',40); +INSERT INTO t3 VALUES ('E1','P2',20); +INSERT INTO t3 VALUES ('E1','P3',80); +INSERT INTO t3 VALUES ('E1','P4',20); +INSERT INTO t3 VALUES ('E1','P5',12); +INSERT INTO t3 VALUES ('E1','P6',12); +INSERT INTO t3 VALUES ('E2','P1',40); +INSERT INTO t3 VALUES ('E2','P2',80); +INSERT INTO t3 VALUES ('E3','P2',20); +INSERT INTO t3 VALUES ('E4','P2',20); +INSERT INTO t3 VALUES ('E4','P4',40); +INSERT INTO t3 VALUES ('E4','P5',80); +CREATE UNIQUE INDEX t1_IDX ON t1(EMPNUM); +EXPLAIN SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN +(SELECT EMPNUM +FROM t3 +WHERE PNUM IN +(SELECT PNUM +FROM t2 +WHERE PTYPE = 'Design')); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL eq_ref t1_IDX t1_IDX 3 test.t3.EMPNUM 1 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = `test`.`t3`.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) +PREPARE stmt FROM "EXPLAIN SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN + (SELECT EMPNUM + FROM t3 + WHERE PNUM IN + (SELECT PNUM + FROM t2 + WHERE PTYPE = 'Design'))"; +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL eq_ref t1_IDX t1_IDX 3 test.t3.EMPNUM 1 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = `test`.`t3`.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) + +This line is only in place to help --skip_if_hypergraph diffing some more. + +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL eq_ref t1_IDX t1_IDX 3 test.t3.EMPNUM 1 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = `test`.`t3`.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) +DEALLOCATE PREPARE stmt; +DROP INDEX t1_IDX ON t1; +CREATE INDEX t1_IDX ON t1(EMPNUM); +EXPLAIN SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN +(SELECT EMPNUM +FROM t3 +WHERE PNUM IN +(SELECT PNUM +FROM t2 +WHERE PTYPE = 'Design')); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ref t1_IDX t1_IDX 3 test.t3.EMPNUM 2 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = `test`.`t3`.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) +PREPARE stmt FROM "EXPLAIN SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN + (SELECT EMPNUM + FROM t3 + WHERE PNUM IN + (SELECT PNUM + FROM t2 + WHERE PTYPE = 'Design'))"; +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ref t1_IDX t1_IDX 3 test.t3.EMPNUM 2 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = `test`.`t3`.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) + +This line is only in place to help --skip_if_hypergraph diffing some more. + +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ref t1_IDX t1_IDX 3 test.t3.EMPNUM 2 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = `test`.`t3`.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) +DEALLOCATE PREPARE stmt; +DROP INDEX t1_IDX ON t1; +EXPLAIN SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN +(SELECT EMPNUM +FROM t3 +WHERE PNUM IN +(SELECT PNUM +FROM t2 +WHERE PTYPE = 'Design')); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 20.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = `test`.`t3`.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) +PREPARE stmt FROM "EXPLAIN SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN + (SELECT EMPNUM + FROM t3 + WHERE PNUM IN + (SELECT PNUM + FROM t2 + WHERE PTYPE = 'Design'))"; +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 20.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = `test`.`t3`.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) + +This line is only in place to help --skip_if_hypergraph diffing some more. + +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 20.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = `test`.`t3`.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) +DEALLOCATE PREPARE stmt; +DROP TABLE t1, t2, t3; +# +# BUG#45221 Query SELECT pk FROM C WHERE pk IN (SELECT int_key) failing +# +CREATE TABLE t1 ( +i1_key INT, +i2 INT, +i3 INT, +KEY i1_index (i1_key) +); +INSERT INTO t1 VALUES (9,1,2), (9,2,1); +CREATE TABLE t2 ( +pk INT NOT NULL, +i1 INT, +PRIMARY KEY (pk) +); +INSERT INTO t2 VALUES (9,1); +SELECT pk +FROM t2 +WHERE +pk IN ( +SELECT i1_key +FROM t1 +WHERE t1.i2 < t1.i3 XOR t2.i1 > 1 +ORDER BY t1.i2 desc); +pk +9 +DROP TABLE t1,t2; +# BUG#50361 Doublenested noncorrelated subquery with FirstMatch and join cache wrong result +# +CREATE TABLE t1( +id INTEGER +); +INSERT INTO t1 VALUES(10),(20); +create table t2 select * from t1; +create table t3 select * from t1; +SELECT * +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t2 +WHERE 1 IN(SELECT 1 +FROM t3)); +id +10 +20 +explain SELECT * +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t2 +WHERE 1 IN(SELECT 1 +FROM t3)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 End temporary; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where true +delete from t2; +delete from t3; +INSERT INTO t1 VALUES(30),(40),(50),(60),(70),(80),(90); +insert into t2 select * from t1; +insert into t3 select * from t1; +create table t4 select * from t1; +SELECT * +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t2 +WHERE 1 IN(SELECT 1 +FROM t3 +WHERE 1 IN(SELECT 1 +FROM t4))); +id +10 +20 +30 +40 +50 +60 +70 +80 +90 +explain SELECT * +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t2 +WHERE 1 IN(SELECT 1 +FROM t3 +WHERE 1 IN(SELECT 1 +FROM t4))); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 9 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 9 100.00 Using join buffer (hash join) +1 SIMPLE t4 NULL ALL NULL NULL NULL NULL 9 100.00 End temporary; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 9 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3` join `test`.`t4`) where true +SELECT * +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t1))); +id +10 +20 +30 +40 +50 +60 +70 +80 +90 +drop table t1,t2,t3,t4; +# +# Bug#53236 Segfault in DTCollation::set(DTCollation&) +# +CREATE TABLE t1 ( +pk INTEGER AUTO_INCREMENT, +col_varchar VARCHAR(1), +PRIMARY KEY (pk) +) +; +INSERT INTO t1 (col_varchar) +VALUES +('w'), +('m') +; +SELECT table1.pk +FROM ( t1 AS table1 JOIN t1 AS table2 ON (table1.col_varchar = +table2.col_varchar) ) +WHERE ( 1, 2 ) IN ( SELECT SUBQUERY1_t1.pk AS SUBQUERY1_field1, +SUBQUERY1_t1.pk AS SUBQUERY1_field2 +FROM ( t1 AS SUBQUERY1_t1 JOIN t1 AS SUBQUERY1_t2 +ON (SUBQUERY1_t2.col_varchar = +SUBQUERY1_t1.col_varchar) ) ) +; +pk +drop table t1; +# +# BUG#53298 "wrong result with semijoin (no semijoin strategy chosen)" +# +create table t1 (uid int, fid int); +insert into t1 values (1,1), (3,1); +create table t2 (uid int, name varchar(128)); +insert into t2 values (1, "A"), (2, "B"); +create table t3 (uid int, fid int, index(uid)); +insert into t3 values (1,3), (1,3); +create table t4 (uid int); +insert into t4 values (3); +explain select t2.uid from t2, t1 +where t1.uid in (select t4.uid from t4, t3 where t3.uid=1 and t4.uid=t3.fid) +and t2.uid=t1.fid; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t4 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ref uid uid 5 const 1 50.00 Using where +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`uid` AS `uid` from `test`.`t2` join `test`.`t1` semi join (`test`.`t4` join `test`.`t3`) where ((`test`.`t3`.`fid` = `test`.`t4`.`uid`) and (`test`.`t1`.`uid` = `test`.`t4`.`uid`) and (`test`.`t3`.`uid` = 1) and (`test`.`t2`.`uid` = `test`.`t1`.`fid`)) +select t2.uid from t2, t1 +where t1.uid in (select t4.uid from t4, t3 where t3.uid=1 and t4.uid=t3.fid) +and t2.uid=t1.fid; +uid +1 +drop table t1,t2,t3,t4; +CREATE TABLE t1 ( +pk int, +a varchar(1), +b varchar(4), +c varchar(4), +d varchar(4), +PRIMARY KEY (pk) +) charset utf8mb4; +INSERT INTO t1 VALUES (1,'o','ffff','ffff','ffoo'),(2,'f','ffff','ffff','ffff'); +CREATE TABLE t2 LIKE t1; +INSERT INTO t2 VALUES (1,'i','iiii','iiii','iiii'),(2,'f','ffff','ffff','ffff'); +EXPLAIN SELECT pk FROM t1 WHERE (a) IN (SELECT a FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 100.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`a` = `test`.`t2`.`a`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (a) IN (SELECT a FROM t2 WHERE pk > 0); +pk +2 +SELECT pk FROM t1 WHERE (b,c,d) IN (SELECT b,c,d FROM t2 WHERE pk > 0); +pk +2 +DROP TABLE t1, t2; +CREATE TABLE t1 (f1 INT, f2 DECIMAL(5,3)) ENGINE=MyISAM; +INSERT INTO t1 (f1, f2) VALUES (1, 1.789); +INSERT INTO t1 (f1, f2) VALUES (13, 1.454); +INSERT INTO t1 (f1, f2) VALUES (10, 1.668); +CREATE TABLE t2 LIKE t1; +INSERT INTO t2 VALUES (1, 1.789); +INSERT INTO t2 VALUES (13, 1.454); +EXPLAIN SELECT COUNT(*) FROM t1 WHERE (f1,f2) IN (SELECT f1,f2 FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`f2` = `test`.`t2`.`f2`) and (`test`.`t1`.`f1` = `test`.`t2`.`f1`)) +SELECT COUNT(*) FROM t1 WHERE (f1,f2) IN (SELECT f1,f2 FROM t2); +COUNT(*) +2 +DROP TABLE t1, t2; +CREATE TABLE t1 ( +ID int(11) NOT NULL auto_increment, +Name char(35) NOT NULL default '', +Country char(3) NOT NULL default '', +Population int(11) NOT NULL default '0', +PRIMARY KEY (ID), +INDEX (Population), +INDEX (Country) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t2 ( +Code char(3) NOT NULL default '', +Name char(52) NOT NULL default '', +SurfaceArea float(10,2) NOT NULL default '0.00', +Population int(11) NOT NULL default '0', +Capital int(11) default NULL, +PRIMARY KEY (Code), +UNIQUE INDEX (Name), +INDEX (Population) +) charset utf8mb4; +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t3 ( +Country char(3) NOT NULL default '', +Language char(30) NOT NULL default '', +Percentage float(3,1) NOT NULL default '0.0', +PRIMARY KEY (Country, Language), +INDEX (Percentage) +) charset utf8mb4; +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +EXPLAIN SELECT Name FROM t2 +WHERE t2.Code IN (SELECT Country FROM t1 WHERE Population > 5000000) +AND +t2.Code IN (SELECT Country FROM t3 +WHERE Language='English' AND Percentage > 10 AND +t2.Population > 100000); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL PRIMARY,Percentage NULL NULL NULL 22 9.55 Using where +1 SIMPLE t1 NULL ref Population,Country Country 12 test.t3.Country 3 3.33 Using where; LooseScan +1 SIMPLE t2 NULL eq_ref PRIMARY,Population PRIMARY 12 test.t3.Country 1 75.00 Using where +Warnings: +Note 1276 Field or reference 'test.t2.Population' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t2`.`Name` AS `Name` from `test`.`t3` join `test`.`t2` semi join (`test`.`t1`) where ((`test`.`t1`.`Country` = `test`.`t3`.`Country`) and (`test`.`t2`.`Code` = `test`.`t3`.`Country`) and (`test`.`t3`.`Language` = 'English') and (`test`.`t3`.`Percentage` > 10) and (`test`.`t2`.`Population` > 100000) and (`test`.`t1`.`Population` > 5000000)) +EXPLAIN FORMAT=JSON SELECT Name FROM t2 +WHERE t2.Code IN (SELECT Country FROM t1 WHERE Population > 5000000) +AND +t2.Code IN (SELECT Country FROM t3 +WHERE Language='English' AND Percentage > 10 AND +t2.Population > 100000); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "5.18" + }, + "nested_loop": [ + { + "table": { + "table_name": "t3", + "access_type": "ALL", + "possible_keys": [ + "PRIMARY", + "Percentage" + ], + "rows_examined_per_scan": 22, + "rows_produced_per_join": 2, + "filtered": "9.55", + "cost_info": { + "read_cost": "2.67", + "eval_cost": "0.21", + "prefix_cost": "2.88", + "data_read_per_join": "302" + }, + "used_columns": [ + "Country", + "Language", + "Percentage" + ], + "attached_condition": "((`test`.`t3`.`Language` = 'English') and (`test`.`t3`.`Percentage` > 10))" + } + }, + { + "table": { + "table_name": "t1", + "access_type": "ref", + "possible_keys": [ + "Population", + "Country" + ], + "key": "Country", + "used_key_parts": [ + "Country" + ], + "key_length": "12", + "ref": [ + "test.t3.Country" + ], + "rows_examined_per_scan": 3, + "rows_produced_per_join": 0, + "filtered": "3.33", + "loosescan": true, + "cost_info": { + "read_cost": "1.57", + "eval_cost": "0.02", + "prefix_cost": "5.14", + "data_read_per_join": "37" + }, + "used_columns": [ + "Country", + "Population" + ], + "attached_condition": "(`test`.`t1`.`Population` > 5000000)" + } + }, + { + "table": { + "table_name": "t2", + "access_type": "eq_ref", + "possible_keys": [ + "PRIMARY", + "Population" + ], + "key": "PRIMARY", + "used_key_parts": [ + "Code" + ], + "key_length": "12", + "ref": [ + "test.t3.Country" + ], + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "75.00", + "cost_info": { + "read_cost": "0.03", + "eval_cost": "0.16", + "prefix_cost": "5.19", + "data_read_per_join": "377" + }, + "used_columns": [ + "Code", + "Name", + "Population" + ], + "attached_condition": "(`test`.`t2`.`Population` > 100000)" + } + } + ] + } +} +Warnings: +Note 1276 Field or reference 'test.t2.Population' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t2`.`Name` AS `Name` from `test`.`t3` join `test`.`t2` semi join (`test`.`t1`) where ((`test`.`t1`.`Country` = `test`.`t3`.`Country`) and (`test`.`t2`.`Code` = `test`.`t3`.`Country`) and (`test`.`t3`.`Language` = 'English') and (`test`.`t3`.`Percentage` > 10) and (`test`.`t2`.`Population` > 100000) and (`test`.`t1`.`Population` > 5000000)) +DROP TABLE t1,t2,t3; +CREATE TABLE t1 ( +Code char(3) NOT NULL DEFAULT '', +Name char(52) NOT NULL DEFAULT '', +Continent enum('Asia','Europe','North America','Africa','Oceania','Antarctica','South America') NOT NULL DEFAULT 'Asia', +Region char(26) NOT NULL DEFAULT '', +SurfaceArea float(10,2) NOT NULL DEFAULT '0.00', +IndepYear smallint(6) DEFAULT NULL, +Population int(11) NOT NULL DEFAULT '0', +LifeExpectancy float(3,1) DEFAULT NULL, +GNP float(10,2) DEFAULT NULL, +GNPOld float(10,2) DEFAULT NULL, +LocalName char(45) NOT NULL DEFAULT '', +GovernmentForm char(45) NOT NULL DEFAULT '', +HeadOfState char(60) DEFAULT NULL, +Capital int(11) DEFAULT NULL, +Code2 char(2) NOT NULL DEFAULT '', +PRIMARY KEY (Code) +) charset utf8mb4; +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t2 ( +ID int(11) NOT NULL AUTO_INCREMENT, +Name char(35) NOT NULL DEFAULT '', +CountryCode char(3) NOT NULL DEFAULT '', +District char(20) NOT NULL DEFAULT '', +Population int(11) NOT NULL DEFAULT '0', +PRIMARY KEY (ID), +KEY CountryCode (CountryCode) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +set names latin1; +Fill the table with test data +This must not use LooseScan: +EXPLAIN SELECT Name FROM t1 +WHERE t1.Code IN ( +SELECT t2.CountryCode FROM t2 WHERE Population > 5000000); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL CountryCode NULL NULL NULL 545 33.33 Using where; Start temporary +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 12 test.t2.CountryCode 1 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`Name` AS `Name` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`Code` = `test`.`t2`.`CountryCode`) and (`test`.`t2`.`Population` > 5000000)) +SELECT Name FROM t1 +WHERE t1.Code IN ( +SELECT t2.CountryCode FROM t2 WHERE Population > 5000000); +Name +Austria +Canada +China +Czech Republic +drop table t1, t2; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4); +create table t1 (a int, b int, key(a)); +insert into t1 select a,a from t0; +create table t2 (a int, b int, primary key(a)); +insert into t2 select * from t1; +Table t2, unlike table t1, should be displayed as pulled out +explain select * from t0 +where t0.a in ( select t1.a from t1,t2 where t2.a=t0.a and +t1.b=t2.b); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL PRIMARY NULL NULL NULL 5 100.00 NULL +1 SIMPLE t1 NULL ref a a 5 test.t2.a 1 20.00 Using where; LooseScan +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 5 20.00 Using where; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t0.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a` from `test`.`t2` join `test`.`t0` semi join (`test`.`t1`) where ((`test`.`t1`.`a` = `test`.`t2`.`a`) and (`test`.`t0`.`a` = `test`.`t2`.`a`) and (`test`.`t1`.`b` = `test`.`t2`.`b`)) +update t1 set a=3, b=11 where a=4; +update t2 set b=11 where a=3; +select * from t0 where t0.a in (select t1.a from t1, t2 where t2.a=t0.a and t1.b=t2.b); +a +0 +1 +2 +3 +drop table t0, t1, t2; +CREATE TABLE t1 ( +id int(11) NOT NULL, +PRIMARY KEY (id)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t2 ( +id int(11) NOT NULL, +fid int(11) NOT NULL, +PRIMARY KEY (id)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t1 values(1); +insert into t2 values(1,7503),(2,1); +explain select count(*) +from t1 +where fid IN (select fid from t2 where (id between 7502 and 8420) order by fid ); +ERROR 42S22: Unknown column 'fid' in 'IN/ALL/ANY subquery' +drop table t1, t2; +create table t1 (a int, b int, key (a), key (b)); +insert into t1 values (2,4),(2,4),(2,4); +select t1.a from t1 +where +t1.a in (select 1 from t1 where t1.a in (select 1 from t1) group by t1.a); +a +drop table t1; +create table t1(a int,b int,key(a),key(b)); +insert into t1 values (1,1),(2,2),(3,3); +select 1 from t1 +where t1.a not in (select 1 from t1 +where t1.a in (select 1 from t1) +group by t1.b); +1 +1 +1 +drop table t1; +CREATE TABLE t1 +(EMPNUM CHAR(3) NOT NULL, +EMPNAME CHAR(20), +GRADE DECIMAL(4), +CITY CHAR(15)); +CREATE TABLE t2 +(PNUM CHAR(3) NOT NULL, +PNAME CHAR(20), +PTYPE CHAR(6), +BUDGET DECIMAL(9), +CITY CHAR(15)); +CREATE TABLE t3 +(EMPNUM CHAR(3) NOT NULL, +PNUM CHAR(3) NOT NULL, +HOURS DECIMAL(5)); +INSERT INTO t1 VALUES ('E1','Alice',12,'Deale'); +INSERT INTO t1 VALUES ('E2','Betty',10,'Vienna'); +INSERT INTO t1 VALUES ('E3','Carmen',13,'Vienna'); +INSERT INTO t1 VALUES ('E4','Don',12,'Deale'); +INSERT INTO t1 VALUES ('E5','Ed',13,'Akron'); +INSERT INTO t2 VALUES ('P1','MXSS','Design',10000,'Deale'); +INSERT INTO t2 VALUES ('P2','CALM','Code',30000,'Vienna'); +INSERT INTO t2 VALUES ('P3','SDP','Test',30000,'Tampa'); +INSERT INTO t2 VALUES ('P4','SDP','Design',20000,'Deale'); +INSERT INTO t2 VALUES ('P5','IRM','Test',10000,'Vienna'); +INSERT INTO t2 VALUES ('P6','PAYR','Design',50000,'Deale'); +INSERT INTO t3 VALUES ('E1','P1',40); +INSERT INTO t3 VALUES ('E1','P2',20); +INSERT INTO t3 VALUES ('E1','P3',80); +INSERT INTO t3 VALUES ('E1','P4',20); +INSERT INTO t3 VALUES ('E1','P5',12); +INSERT INTO t3 VALUES ('E1','P6',12); +INSERT INTO t3 VALUES ('E2','P1',40); +INSERT INTO t3 VALUES ('E2','P2',80); +INSERT INTO t3 VALUES ('E3','P2',20); +INSERT INTO t3 VALUES ('E4','P2',20); +INSERT INTO t3 VALUES ('E4','P4',40); +INSERT INTO t3 VALUES ('E4','P5',80); +SELECT * FROM t1; +EMPNUM EMPNAME GRADE CITY +E1 Alice 12 Deale +E2 Betty 10 Vienna +E3 Carmen 13 Vienna +E4 Don 12 Deale +E5 Ed 13 Akron +CREATE UNIQUE INDEX t1_IDX ON t1(EMPNUM); +SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN +(SELECT EMPNUM +FROM t3 +WHERE PNUM IN +(SELECT PNUM +FROM t2 +WHERE PTYPE = 'Design')); +EMPNAME +Alice +Betty +Don +DROP INDEX t1_IDX ON t1; +CREATE INDEX t1_IDX ON t1(EMPNUM); +SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN +(SELECT EMPNUM +FROM t3 +WHERE PNUM IN +(SELECT PNUM +FROM t2 +WHERE PTYPE = 'Design')); +EMPNAME +Alice +Betty +Don +DROP INDEX t1_IDX ON t1; +SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN +(SELECT EMPNUM +FROM t3 +WHERE PNUM IN +(SELECT PNUM +FROM t2 +WHERE PTYPE = 'Design')); +EMPNAME +Alice +Betty +Don +DROP TABLE t1, t2, t3; +CREATE TABLE t1 (f1 INT NOT NULL); +CREATE VIEW v1 (a) AS SELECT f1 IN (SELECT f1 FROM t1) FROM t1; +SELECT * FROM v1; +a +drop view v1; +drop table t1; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1(a int, b int); +insert into t1 values (0,0),(1,1),(2,2); +create table t2 as select * from t1; +create table t3 (pk int, a int, primary key(pk)); +insert into t3 select a,a from t0; +explain +select * from t1 left join t2 on (t2.a= t1.a and t2.a in (select pk from t3)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE t3 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using index +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` left join (`test`.`t3` join `test`.`t2`) on(((`test`.`t3`.`pk` = `test`.`t1`.`a`) and (`test`.`t2`.`a` = `test`.`t1`.`a`))) where true +drop table t0, t1, t2, t3; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (a int) as select A.a + 10 *(B.a + 10*C.a) as a from t0 A, t0 B, t0 C; +create table t2 (id int, a int, primary key(id), key(a)) charset utf8mb4 as select a as id, a as a from t1; +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `id` int NOT NULL, + `a` int DEFAULT NULL, + PRIMARY KEY (`id`), + KEY `a` (`a`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +set @a=0; +create table t3 as select * from t2 limit 0; +insert into t3 select @a:=@a+1, t2.a from t2, t0; +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +insert into t3 select @a:=@a+1, t2.a from t2, t0; +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +insert into t3 select @a:=@a+1, t2.a from t2, t0; +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +alter table t3 add primary key(id), add 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); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL index a a 5 NULL 30000 3.33 Using where; Using index; LooseScan +1 SIMPLE t2 NULL ref a a 5 test.t3.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select count(`test`.`t2`.`a`) AS `count(a)` from `test`.`t2` semi join (`test`.`t3`) where (`test`.`t2`.`a` = `test`.`t3`.`a`) +select count(a) from t2 where a in ( SELECT a FROM t3); +count(a) +1000 +drop table t0,t1,t2,t3; +# +# Bug#33062: subquery in stored routine cause crash +# +CREATE TABLE t1(a INT); +CREATE TABLE t2(c INT); +CREATE PROCEDURE p1(v1 int) +BEGIN +SELECT 1 FROM t1 WHERE a = v1 AND a IN (SELECT c FROM t2); +END +// +CREATE PROCEDURE p2(v1 int) +BEGIN +SELECT 1 FROM t1 WHERE a IN (SELECT c FROM t2); +END +// +CREATE PROCEDURE p3(v1 int) +BEGIN +SELECT 1 +FROM +t1 t01,t1 t02,t1 t03,t1 t04,t1 t05,t1 t06,t1 t07,t1 t08, +t1 t09,t1 t10,t1 t11,t1 t12,t1 t13,t1 t14,t1 t15,t1 t16, +t1 t17,t1 t18,t1 t19,t1 t20,t1 t21,t1 t22,t1 t23,t1 t24, +t1 t25,t1 t26,t1 t27,t1 t28,t1 t29,t1 t30,t1 t31,t1 t32, +t1 t33,t1 t34,t1 t35,t1 t36,t1 t37,t1 t38,t1 t39,t1 t40, +t1 t41,t1 t42,t1 t43,t1 t44,t1 t45,t1 t46,t1 t47,t1 t48, +t1 t49,t1 t50,t1 t51,t1 t52,t1 t53,t1 t54,t1 t55,t1 t56, +t1 t57,t1 t58,t1 t59,t1 t60 +WHERE t01.a IN (SELECT c FROM t2); +END +// +CREATE PROCEDURE p4(v1 int) +BEGIN +SELECT 1 +FROM +t1 t01,t1 t02,t1 t03,t1 t04,t1 t05,t1 t06,t1 t07,t1 t08, +t1 t09,t1 t10,t1 t11,t1 t12,t1 t13,t1 t14,t1 t15,t1 t16, +t1 t17,t1 t18,t1 t19,t1 t20,t1 t21,t1 t22,t1 t23,t1 t24, +t1 t25,t1 t26,t1 t27,t1 t28,t1 t29,t1 t30,t1 t31,t1 t32, +t1 t33,t1 t34,t1 t35,t1 t36,t1 t37,t1 t38,t1 t39,t1 t40, +t1 t41,t1 t42,t1 t43,t1 t44,t1 t45,t1 t46,t1 t47,t1 t48, +t1 t49,t1 t50,t1 t51,t1 t52,t1 t53,t1 t54,t1 t55,t1 t56, +t1 t57,t1 t58,t1 t59,t1 t60 +WHERE t01.a = v1 AND t01.a IN (SELECT c FROM t2); +END +// +CALL p1(1); +1 +CALL p2(1); +1 +CALL p3(1); +1 +CALL p4(1); +1 +DROP TABLE t1, t2; +DROP PROCEDURE p1; +DROP PROCEDURE p2; +DROP PROCEDURE p3; +DROP PROCEDURE p4; +# +# Bug#48213 Materialized subselect crashes if using GEOMETRY type +# +CREATE TABLE t1 ( +pk int, +a varchar(1), +b varchar(4), +c tinyblob, +d blob, +e mediumblob, +f longblob, +g tinytext, +h text, +i mediumtext, +j longtext, +k geometry, +PRIMARY KEY (pk) +) charset utf8mb4; +INSERT INTO t1 VALUES (1,'o','ffff','ffff','ffoo','ffff','ffff','ffff','ffff','ffff','ffff',ST_GeomFromText('POLYGON((0 0, 0 2, 2 2, 2 0, 0 0))')), (2,'f','ffff','ffff','ffff', 'ffff','ffff','ffff','ffff','ffff','ffff',ST_GeomFromText('POLYGON((0 0, 0 2, 2 2, 2 0, 0 0))')); +CREATE TABLE t2 LIKE t1; +INSERT INTO t2 VALUES (1,'i','iiii','iiii','iiii','iiii','ffff','ffff','ffff','ffff','ffff',ST_GeomFromText('POLYGON((0 0, 0 2, 2 2, 2 0, 0 0))')), (2,'f','ffff','ffff','ffff','ffff','ffff','ffff','ffff','ffff','ffff',ST_GeomFromText('POLYGON((0 0, 0 2, 2 2, 2 0, 0 0))')); +EXPLAIN SELECT pk FROM t1 WHERE (a, b) IN (SELECT a, b FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 100.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`b` = `test`.`t2`.`b`) and (`test`.`t1`.`a` = `test`.`t2`.`a`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (a, b) IN (SELECT a, b FROM t2 WHERE pk > 0); +pk +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, c) IN (SELECT b, c FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 100.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`c` = `test`.`t2`.`c`) and (`test`.`t1`.`b` = `test`.`t2`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, c) IN (SELECT b, c FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, d) IN (SELECT b, d FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 100.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`d` = `test`.`t2`.`d`) and (`test`.`t1`.`b` = `test`.`t2`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, d) IN (SELECT b, d FROM t2 WHERE pk > 0); +pk +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, e) IN (SELECT b, e FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 100.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`e` = `test`.`t2`.`e`) and (`test`.`t1`.`b` = `test`.`t2`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, e) IN (SELECT b, e FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, f) IN (SELECT b, f FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 100.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`f` = `test`.`t2`.`f`) and (`test`.`t1`.`b` = `test`.`t2`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, f) IN (SELECT b, f FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, g) IN (SELECT b, g FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 100.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`g` = `test`.`t2`.`g`) and (`test`.`t1`.`b` = `test`.`t2`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, g) IN (SELECT b, g FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, h) IN (SELECT b, h FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 100.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`h` = `test`.`t2`.`h`) and (`test`.`t1`.`b` = `test`.`t2`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, h) IN (SELECT b, h FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, i) IN (SELECT b, i FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 100.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`i` = `test`.`t2`.`i`) and (`test`.`t1`.`b` = `test`.`t2`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, i) IN (SELECT b, i FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, j) IN (SELECT b, j FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 100.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`j` = `test`.`t2`.`j`) and (`test`.`t1`.`b` = `test`.`t2`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, j) IN (SELECT b, j FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, k) IN (SELECT b, k FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 100.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`k` = `test`.`t2`.`k`) and (`test`.`t1`.`b` = `test`.`t2`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, k) IN (SELECT b, k FROM t2 WHERE pk > 0); +pk +1 +2 +DROP TABLE t1, t2; +# End of Bug#48213 +# +# BUG#53060: LooseScan semijoin strategy does not return all rows +# +CREATE TABLE t1 (i INTEGER); +INSERT INTO t1 VALUES (1), (2), (3), (4), (5); +CREATE TABLE t2 (i INTEGER, j INTEGER, KEY k(i, j)); +INSERT INTO t2 VALUES (1, 0), (1, 1), (2, 0), (2, 1); +EXPLAIN +SELECT * FROM t1 WHERE (i) IN (SELECT i FROM t2 where j > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index k k 10 NULL 4 33.33 Using where; Using index; LooseScan +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 20.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`i` = `test`.`t2`.`i`) and (`test`.`t2`.`j` > 0)) +SELECT * FROM t1 WHERE (i) IN (SELECT i FROM t2 where j > 0); +i +1 +2 +DROP TABLE t1, t2; +# End of BUG#53060 +# +# Bug#53305 "Duplicate weedout + join buffer (join cache --level=7,8) loses rows" +# +create table t1 (uid int, fid int, index(uid)); +insert into t1 values +(1,1), (1,2), (1,3), (1,4), +(2,5), (2,6), (2,7), (2,8), +(3,1), (3,2), (3,9); +create table t2 (uid int primary key, name varchar(128), index(name)); +insert into t2 values +(1, "A"), (2, "B"), (3, "C"), (4, "D"), (5, "E"), +(6, "F"), (7, "G"), (8, "H"), (9, "I"); +create table t3 (uid int, fid int, index(uid)); +insert into t3 values +(1,1), (1,2), (1,3),(1,4), +(2,5), (2,6), (2,7), (2,8), +(3,1), (3,2), (3,9); +create table t4 (uid int primary key, name varchar(128), index(name)); +insert into t4 values +(1, "A"), (2, "B"), (3, "C"), (4, "D"), (5, "E"), +(6, "F"), (7, "G"), (8, "H"), (9, "I"); +explain select name from t2, t1 +where t1.uid in (select t4.uid from t4, t3 where t3.uid=1 and t4.uid=t3.fid) +and t2.uid=t1.fid; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ref uid uid 5 const 4 100.00 Using where; Start temporary +1 SIMPLE t4 NULL eq_ref PRIMARY PRIMARY 4 test.t3.fid 1 100.00 Using index +1 SIMPLE t1 NULL ref uid uid 5 test.t3.fid 2 100.00 Using where; End temporary +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.fid 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`name` AS `name` from `test`.`t4` join `test`.`t2` join `test`.`t1` semi join (`test`.`t3`) where ((`test`.`t4`.`uid` = `test`.`t3`.`fid`) and (`test`.`t1`.`uid` = `test`.`t3`.`fid`) and (`test`.`t3`.`uid` = 1) and (`test`.`t2`.`uid` = `test`.`t1`.`fid`)) +select name from t2, t1 +where t1.uid in (select t4.uid from t4, t3 where t3.uid=1 and t4.uid=t3.fid) +and t2.uid=t1.fid; +name +A +A +B +B +C +D +E +F +G +H +I +drop table t1,t2,t3,t4; +# +# Bug#43768 Prepared query with nested subqueries core dump on second execution +# +CREATE TABLE t1 ( +id INT PRIMARY KEY, +partner_id VARCHAR(35) +) charset utf8mb4; +INSERT INTO t1 VALUES +(1, 'partner1'), (2, 'partner2'), +(3, 'partner3'), (4, 'partner4'); +CREATE TABLE t2 ( +id INT NOT NULL, +t1_line_id INT, +article_id VARCHAR(20), +PRIMARY KEY(id, t1_line_id) +) charset utf8mb4; +INSERT INTO t2 VALUES +(1, 1, 'sup'), (2, 1, 'sup'), +(2, 2, 'sup'), (2, 3, 'sup'), +(2, 4, 'imp'), (3, 1, 'sup'), +(4, 1, 'sup'); +CREATE TABLE t3 ( +user_id VARCHAR(50), +article_id VARCHAR(20) NOT NULL, +PRIMARY KEY(user_id) +) charset utf8mb4; +INSERT INTO t3 VALUES('nicke', 'imp'); +EXPLAIN +SELECT t1.partner_id +FROM t1 +WHERE t1.id IN ( +SELECT t2.id +FROM t2 +WHERE article_id IN ( +SELECT article_id FROM t3 +WHERE user_id = 'nicke' + ) +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL system PRIMARY NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL PRIMARY NULL NULL NULL 7 14.29 Using where; Start temporary +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.id 1 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`partner_id` AS `partner_id` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`id` = `test`.`t2`.`id`) and (`test`.`t2`.`article_id` = 'imp')) +SELECT t1.partner_id +FROM t1 +WHERE t1.id IN ( +SELECT t2.id +FROM t2 +WHERE article_id IN ( +SELECT article_id FROM t3 +WHERE user_id = 'nicke' + ) +); +partner_id +partner2 +PREPARE stmt FROM +'EXPLAIN SELECT t1.partner_id +FROM t1 +WHERE t1.id IN ( + SELECT t2.id + FROM t2 + WHERE article_id IN ( + SELECT article_id FROM t3 + WHERE user_id = \'nicke\' + ) + )'; +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL system PRIMARY NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL PRIMARY NULL NULL NULL 7 14.29 Using where; Start temporary +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.id 1 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`partner_id` AS `partner_id` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`id` = `test`.`t2`.`id`) and (`test`.`t2`.`article_id` = 'imp')) + +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL system PRIMARY NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL PRIMARY NULL NULL NULL 7 14.29 Using where; Start temporary +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.id 1 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`partner_id` AS `partner_id` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`id` = `test`.`t2`.`id`) and (`test`.`t2`.`article_id` = 'imp')) +PREPARE stmt FROM +'SELECT t1.partner_id +FROM t1 +WHERE t1.id IN ( + SELECT t2.id + FROM t2 + WHERE article_id IN ( + SELECT article_id FROM t3 + WHERE user_id = \'nicke\' + ) + )'; +EXECUTE stmt; +partner_id +partner2 + +EXECUTE stmt; +partner_id +partner2 +DROP TABLE t1,t2,t3; +# End of Bug#43768 +# +# Bug#53058 - semijoin execution of subquery with outerjoin yields wrong result +# +CREATE TABLE t1 (i INTEGER); +CREATE TABLE t2 (i INTEGER); +CREATE TABLE t3 (i INTEGER); +INSERT INTO t1 VALUES (1), (2); +INSERT INTO t2 VALUES (6); +INSERT INTO t3 VALUES (1), (2); +explain SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t3 LEFT JOIN t2 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t3 LEFT JOIN t2 ON t2.i=t3.i); +i +1 +2 +drop table t1,t2,t3; +# +# BUG#49453: re-execution of prepared statement with view +# and semijoin crashes +# +CREATE TABLE t1 (city VARCHAR(50), country_id INT); +CREATE TABLE t2 (country_id INT, country VARCHAR(50)); +INSERT INTO t1 VALUES +('Batna',2),('Bchar',2),('Skikda',2),('Tafuna',3),('Algeria',2) ; +INSERT INTO t2 VALUES (2,'Algeria'),(2,'AlgeriaDup'),(3,'XAmerican Samoa'); +CREATE VIEW v1 AS +SELECT country_id as vf_country_id +FROM t2 +WHERE LEFT(country,1) = "A"; +PREPARE stmt FROM " +SELECT city, country_id +FROM t1 +WHERE country_id IN (SELECT vf_country_id FROM v1); +"; + +EXECUTE stmt; +city country_id +Algeria 2 +Batna 2 +Bchar 2 +Skikda 2 + +EXECUTE stmt; +city country_id +Algeria 2 +Batna 2 +Bchar 2 +Skikda 2 +DROP TABLE t1,t2; +DROP VIEW v1; +# +# Bug#54437 Extra rows with LEFT JOIN + semijoin (firstmatch +# and duplicates weedout) +# +create table t1 (a int); +create table t2 (a int); +create table t3 (a int); +insert into t1 values(1),(1); +insert into t2 values(1),(1),(1),(1); +insert into t3 values(2),(2); +explain select * from t1 where t1.a in (select t2.a from t2 left join t3 on t2.a=t3.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t2` left join `test`.`t3` on((`test`.`t2`.`a` = `test`.`t3`.`a`))) where (`test`.`t2`.`a` = `test`.`t1`.`a`) +select * from t1 where t1.a in (select t2.a from t2 left join t3 on t2.a=t3.a); +a +1 +1 +drop table t1,t2,t3; +# +# Bug#55955: crash in MEMORY engine with IN(LEFT JOIN (JOIN)) +# +CREATE TABLE t1 (a INT); +CREATE TABLE t2 (a INT); +CREATE TABLE t3 (a INT); +INSERT INTO t1 VALUES(1),(1); +INSERT INTO t2 VALUES(1),(1); +INSERT INTO t3 VALUES(2),(2); +explain SELECT * FROM t1 +WHERE t1.a IN (SELECT t2.a +FROM t2 LEFT JOIN (t2 AS t2inner, t3) ON t2.a=t3.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t2inner NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t2` left join (`test`.`t2` `t2inner` join `test`.`t3`) on((`test`.`t2`.`a` = `test`.`t3`.`a`))) where (`test`.`t1`.`a` = `test`.`t2`.`a`) +SELECT * FROM t1 +WHERE t1.a IN (SELECT t2.a +FROM t2 LEFT JOIN (t2 AS t2inner, t3) ON t2.a=t3.a); +a +1 +1 +DROP TABLE t1,t2,t3; +# +# BUG#52329 - Wrong result: subquery materialization, IN, +# non-null field followed by nullable +# +CREATE TABLE t1 (a1 CHAR(8) NOT NULL, a2 char(8) NOT NULL); +CREATE TABLE t2a (b1 char(8), b2 char(8)); +CREATE TABLE t2b (b1 CHAR(8), b2 char(8) NOT NULL); +CREATE TABLE t2c (b1 CHAR(8) NOT NULL, b2 char(8)); +INSERT INTO t1 VALUES ('1 - 12', '2 - 22'); +INSERT INTO t2a VALUES ('1 - 11', '2 - 21'), +('1 - 11', '2 - 21'), +('1 - 12', '2 - 22'), +('1 - 12', '2 - 22'), +('1 - 13', '2 - 23'); +INSERT INTO t2b SELECT * FROM t2a; +INSERT INTO t2c SELECT * FROM t2a; +SELECT * FROM t1 +WHERE (a1, a2) IN ( +SELECT b1, b2 FROM t2c WHERE b1 > '0' GROUP BY b1, b2); +a1 a2 +1 - 12 2 - 22 +SELECT * FROM t1 +WHERE (a1, a2) IN ( +SELECT b1, b2 FROM t2a WHERE b1 > '0'); +a1 a2 +1 - 12 2 - 22 +SELECT * FROM t1 +WHERE (a1, a2) IN ( +SELECT b1, b2 FROM t2b WHERE b1 > '0'); +a1 a2 +1 - 12 2 - 22 +SELECT * FROM t1 +WHERE (a1, a2) IN ( +SELECT b1, b2 FROM t2c WHERE b1 > '0'); +a1 a2 +1 - 12 2 - 22 +DROP TABLE t1,t2a,t2b,t2c; +# End BUG#52329 +# +# Bug#45174: Incorrectly applied equality propagation caused wrong +# result on a query with a materialized semi-join. +# +CREATE TABLE t1 ( +varchar_nokey varchar(1) NOT NULL +) charset utf8mb4; +INSERT INTO t1 VALUES +('v'), ('u'), ('n'), ('l'), ('h'), ('u'), ('n'), ('j'), ('k'), +('e'), ('i'), ('u'), ('n'), ('b'), ('x'), (''), ('q'), ('u'); +CREATE TABLE t2 ( +pk int NOT NULL, +varchar_key varchar(1) NOT NULL, +varchar_nokey varchar(1) NOT NULL, +PRIMARY KEY(pk), +KEY varchar_key(varchar_key) +) charset utf8mb4; +INSERT INTO t2 VALUES +(11,'m','m'), (12,'j','j'), (13,'z','z'), (14,'a','a'), (15,'',''), +(16,'e','e'), (17,'t','t'), (19,'b','b'), (20,'w','w'), (21,'m','m'), +(23,'',''), (24,'w','w'), (26,'e','e'), (27,'e','e'), (28,'p','p'); +SELECT varchar_nokey +FROM t1 +WHERE (varchar_nokey, varchar_nokey) IN (SELECT varchar_key, varchar_nokey +FROM t2 +WHERE varchar_nokey < 'n' XOR pk); +varchar_nokey +explain SELECT varchar_nokey +FROM t1 +WHERE (varchar_nokey, varchar_nokey) IN (SELECT varchar_key, varchar_nokey +FROM t2 +WHERE varchar_nokey < 'n' XOR pk); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 18 100.00 NULL +1 SIMPLE t2 NULL ref varchar_key varchar_key 6 test.t1.varchar_nokey 2 6.67 Using where; Start temporary; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`varchar_nokey` AS `varchar_nokey` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`varchar_key` = `test`.`t1`.`varchar_nokey`) and (`test`.`t2`.`varchar_nokey` = `test`.`t1`.`varchar_nokey`) and ((`test`.`t2`.`varchar_nokey` < 'n') xor (0 <> `test`.`t2`.`pk`))) +DROP TABLE t1, t2; +# End of the test for bug#45174. +# +# Bug#50019: Wrong result for IN-query with materialization +# +CREATE TABLE t1(i INT); +INSERT INTO t1 VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10); +CREATE TABLE t2(i INT); +INSERT INTO t2 VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10); +CREATE TABLE t3(i INT); +INSERT INTO t3 VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10); +SELECT * FROM t1 WHERE t1.i IN (SELECT t2.i +FROM t2 JOIN t3 +WHERE t2.i + t3.i = 5); +i +1 +2 +3 +4 +explain SELECT * FROM t1 WHERE t1.i IN (SELECT t2.i +FROM t2 JOIN t3 +WHERE t2.i + t3.i = 5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 10 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 10.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 10 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t2`.`i`) and ((`test`.`t2`.`i` + `test`.`t3`.`i`) = 5)) +DROP TABLE t1,t2,t3; +# End of the test for bug#50019. +# +# Bug#52068: Optimizer generates invalid semijoin materialization plan +# +CREATE TABLE ot1(a INTEGER); +INSERT INTO ot1 VALUES(5), (8); +CREATE TABLE it2(a INTEGER); +INSERT INTO it2 VALUES(9), (5), (1), (8); +CREATE TABLE it3(a INTEGER); +INSERT INTO it3 VALUES(7), (1), (0), (5), (1), (4); +CREATE TABLE ot4(a INTEGER); +INSERT INTO ot4 VALUES(1), (3), (5), (7), (9), (7), (3), (1); +SELECT * FROM ot1,ot4 +WHERE (ot1.a,ot4.a) IN (SELECT it2.a,it3.a +FROM it2,it3); +a a +5 1 +5 1 +5 5 +5 7 +5 7 +8 1 +8 1 +8 5 +8 7 +8 7 +explain SELECT * FROM ot1,ot4 +WHERE (ot1.a,ot4.a) IN (SELECT it2.a,it3.a +FROM it2,it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE it3 NULL ALL NULL NULL NULL NULL 6 100.00 Start temporary +1 SIMPLE ot4 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; Using join buffer (hash join) +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +1 SIMPLE it2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot4`.`a` AS `a` from `test`.`ot1` join `test`.`ot4` semi join (`test`.`it2` join `test`.`it3`) where ((`test`.`ot4`.`a` = `test`.`it3`.`a`) and (`test`.`it2`.`a` = `test`.`ot1`.`a`)) +DROP TABLE IF EXISTS ot1, ot4, it2, it3; +# End of the test for bug#52068. +# +# Bug#57623: subquery within before insert trigger causes crash (sj=on) +# +CREATE TABLE ot1(a INT); +CREATE TABLE ot2(a INT); +CREATE TABLE ot3(a INT); +CREATE TABLE it1(a INT); +INSERT INTO ot1 VALUES(0),(1),(2),(3),(4),(5),(6),(7); +INSERT INTO ot2 VALUES(0),(2),(4),(6); +INSERT INTO ot3 VALUES(0),(3),(6); +INSERT INTO it1 VALUES(0),(1),(2),(3),(4),(5),(6),(7); +explain SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 on ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a from it1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 Start temporary +1 SIMPLE it1 NULL ALL NULL NULL NULL NULL 8 100.00 Using where; Using join buffer (hash join) +1 SIMPLE ot3 NULL ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (hash join) +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a`,`test`.`ot3`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` join `test`.`ot3` semi join (`test`.`it1`)) on(((`test`.`it1`.`a` = `test`.`ot1`.`a`) and (`test`.`ot3`.`a` = `test`.`ot1`.`a`) and (`test`.`ot2`.`a` = `test`.`ot1`.`a`))) where true +SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 on ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a from it1); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +prepare s from 'SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 on ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a from it1)'; +execute s; +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +execute s; +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +deallocate prepare s; +DROP TABLE ot1, ot2, ot3, it1; +# End of the test for bug#57623. +# +# Bug#11766739: Crash in tmp_table_param::init() with semijoin=on +# +CREATE TABLE t1 (f1 INTEGER) ENGINE=MyISAM; +CREATE TABLE t2 (f1 INTEGER, f2 INTEGER) ENGINE=MyISAM; +INSERT INTO t1 VALUES (1); +INSERT INTO t2 VALUES (1,1), (2,1); +EXPLAIN SELECT * FROM t2 +WHERE f2 IN (SELECT t1.f1 +FROM t1 LEFT OUTER JOIN (t2 AS b1 JOIN t2 AS b2 ON TRUE) ON TRUE); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE b1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +1 SIMPLE b2 NULL ALL NULL NULL NULL NULL 2 100.00 End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`f1` AS `f1`,`test`.`t2`.`f2` AS `f2` from `test`.`t2` semi join (`test`.`t1` left join (`test`.`t2` `b1` join `test`.`t2` `b2`) on((true))) where (`test`.`t2`.`f2` = `test`.`t1`.`f1`) +SELECT * FROM t2 +WHERE f2 IN (SELECT t1.f1 +FROM t1 LEFT OUTER JOIN (t2 AS b1 JOIN t2 AS b2 ON TRUE) ON TRUE); +f1 f2 +1 1 +2 1 +DROP TABLE t1, t2; +# End of the test for bug#11766739. +# +# Bug#11766642: crash in Item_field::register_field_in_read_map with view +# +CREATE TABLE t1(a INT); +CREATE VIEW v1 AS SELECT a FROM t1; +INSERT INTO t1 VALUES (0),(1),(2); +SELECT a FROM t1 WHERE a IN +(SELECT a XOR a FROM v1) +ORDER BY a; +a +0 +DROP TABLE t1; +DROP VIEW v1; +# +# Bug#12546542 MISSING ROW WHEN USING OPTIMIZER_JOIN_CACHE_LEVEL>=3 +# +CREATE TABLE t1 ( +f2 varchar(1024) +); +INSERT INTO t1 VALUES ('v'),('we'); +CREATE TABLE t2 ( +col_varchar_1024_utf8 varchar(1024) CHARACTER SET utf8 DEFAULT NULL, +col_int_key int, +col_int int +); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t2 VALUES ('we',4,NULL),('v',1305673728,6); +CREATE TABLE t3 ( +col_int_key int, +col_int int +); +INSERT INTO t3 VALUES (4,4); +SELECT * +FROM t1 +WHERE f2 IN (SELECT a1.col_varchar_1024_utf8 AS f2 +FROM t2 AS a1 LEFT JOIN t3 AS a2 +ON a1.col_int_key = a2.col_int_key +WHERE a1.col_int BETWEEN 1 AND 10 OR a2.col_int IS NOT NULL); +f2 +v +we +DROP TABLE t1,t2,t3; +# +# BUG#12616344 - JCL: DIFFERENT RESULT SET AND DIFFERENT AMOUNT +# OF ROWS WHEN JCL>=3 +# +CREATE TABLE t1 (col_int_nokey int, col_int_key int, col_varchar_key varchar(1)); +INSERT INTO t1 VALUES (0,4,'c'),(1,6,'u'); +CREATE TABLE t2 (pk int, col_int_nokey int, col_varchar_nokey varchar(1)); +INSERT INTO t2 VALUES (1,4,'b'),(94,6,'u'); +CREATE TABLE t3 (pk int, col_int_nokey int, col_varchar_key varchar(1)); +INSERT INTO t3 VALUES (1,4,'j'),(2,6,'v'); +SELECT table2.col_int_key +from t3 as table1 join t1 as table2 on table2.col_int_nokey +where table1.col_int_nokey in +( +select subquery2_t2.col_int_nokey +from t3 as subquery2_t1 +right join +t2 as subquery2_t2 +join t1 as subquery2_t3 +on subquery2_t3.col_int_key = subquery2_t2.col_int_nokey +on subquery2_t3.col_varchar_key = subquery2_t2.col_varchar_nokey +where subquery2_t1.col_varchar_key != table1.col_varchar_key +or subquery2_t2.pk <= table1.pk +); +col_int_key +6 +6 +DROP TABLE t1,t2,t3; +# +# Bug#12608157: ASSERT IN FIELD_LONG::VAL_INT WHEN USING MEMORY ENGINE +# +CREATE TABLE t1 (i1 int); +INSERT INTO t1 VALUES (1); +CREATE TABLE t2 (i1 int, i2 int) ENGINE=memory; +INSERT INTO t2 VALUES (1, 2),(7, 3); +SELECT GRANDPARENT1.i1 +FROM t2 AS GRANDPARENT1 +WHERE GRANDPARENT1.i2 +IN ( SELECT PARENT1.i2 +FROM t2 AS PARENT1 JOIN t1 AS PARENT2 ON (PARENT1.i1 = PARENT2.i1) +WHERE +GRANDPARENT1.i1 IN ( SELECT CHILD1.i1 FROM t2 AS CHILD1 ) +ORDER BY PARENT1.i1) +ORDER BY GRANDPARENT1.i2 ; +i1 +1 +DROP TABLE t1,t2; +# +# Bug#12640083: Same query executed as WHERE subquery gives different +# results on IN() compare +# +CREATE TABLE t1 ( +pk int NOT NULL, +col_varchar_1024_utf8_key varchar(1024) CHARACTER SET utf8 DEFAULT NULL, +col_varchar_10_latin1_key varchar(10) DEFAULT NULL, +PRIMARY KEY (pk), +KEY col_varchar_1024_utf8_key(col_varchar_1024_utf8_key(333)), +KEY col_varchar_10_latin1_key(col_varchar_10_latin1_key) +) charset utf8mb4; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES +(1, 'a', 'a'), +(2, 'ab', 'ab'), +(3, 'abc', 'abc'), +(4, 'abcd', 'abcd'); +CREATE TABLE t2 ( +pk int NOT NULL AUTO_INCREMENT, +PRIMARY KEY (pk) +) charset utf8mb4 ENGINE=Innodb; +CREATE TABLE t3 charset utf8mb4 +SELECT alias1.col_varchar_10_latin1_key +FROM t1 AS alias1 +LEFT JOIN t1 AS alias2 +JOIN t2 AS alias3 +ON alias2.col_varchar_10_latin1_key +ON alias1.col_varchar_1024_utf8_key +WHERE alias1.pk AND alias1.pk < 3 OR alias1.pk AND alias3.pk; +EXPLAIN SELECT * +FROM t3 +WHERE col_varchar_10_latin1_key IN ( +SELECT alias1.col_varchar_10_latin1_key +FROM t1 AS alias1 +LEFT JOIN t1 AS alias2 +JOIN t2 AS alias3 +ON alias2.col_varchar_10_latin1_key +ON alias1.col_varchar_1024_utf8_key +WHERE alias1.pk AND alias1.pk < 3 OR alias1.pk AND alias3.pk); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Start temporary +1 SIMPLE alias1 NULL ref PRIMARY,col_varchar_10_latin1_key col_varchar_10_latin1_key 43 test.t3.col_varchar_10_latin1_key 2 100.00 Using where +1 SIMPLE alias3 NULL index NULL PRIMARY 4 NULL 1 100.00 Using where; Using index; Using join buffer (hash join) +1 SIMPLE alias2 NULL index NULL col_varchar_10_latin1_key 43 NULL 4 100.00 Using where; Using index; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`col_varchar_10_latin1_key` AS `col_varchar_10_latin1_key` from `test`.`t3` semi join (`test`.`t1` `alias1` left join (`test`.`t1` `alias2` join `test`.`t2` `alias3`) on(((0 <> `test`.`alias1`.`col_varchar_1024_utf8_key`) and (0 <> `test`.`alias2`.`col_varchar_10_latin1_key`)))) where ((`test`.`alias1`.`col_varchar_10_latin1_key` = `test`.`t3`.`col_varchar_10_latin1_key`) and (((0 <> `test`.`alias1`.`pk`) and (`test`.`alias1`.`pk` < 3)) or ((0 <> `test`.`alias1`.`pk`) and (0 <> `test`.`alias3`.`pk`)))) +SELECT * +FROM t3 +WHERE col_varchar_10_latin1_key IN ( +SELECT alias1.col_varchar_10_latin1_key +FROM t1 AS alias1 +LEFT JOIN t1 AS alias2 +JOIN t2 AS alias3 +ON alias2.col_varchar_10_latin1_key +ON alias1.col_varchar_1024_utf8_key +WHERE alias1.pk AND alias1.pk < 3 OR alias1.pk AND alias3.pk); +col_varchar_10_latin1_key +a +ab +DROP TABLE t1, t2, t3; +# End of the test for bug#12640083. +# +# Bug#12603200 - Assert in QUICK_INDEX_MERGE_SELECT::need_sorted_output +# +CREATE TABLE t1 ( +pk int NOT NULL, +col_int_key int NOT NULL, +col_varchar_nokey varchar(1) NOT NULL, +col_varchar_key varchar(1) NOT NULL, +PRIMARY KEY(pk), +KEY col_int_key(col_int_key), +KEY col_varchar_key(col_varchar_key, col_int_key) +) charset utf8mb4 engine=innodb; +INSERT INTO t1 VALUES +(1,7,'a','a'), +(2,0,'v','v'), +(3,9,'c','c'), +(4,3,'m','m'), +(5,2,'a','a'), +(6,1,'d','d'), +(7,8,'y','y'), +(8,6,'t','t'), +(11,7,'a','x'), +(12,0,'v','v'), +(13,9,'c','c'), +(14,3,'m','m'), +(15,2,'a','x'), +(16,1,'d','d'), +(17,8,'y','y'), +(18,6,'t','u'), +(19,6,'t','u'); +CREATE TABLE t2 ( +pk int NOT NULL, +col_int_key int NOT NULL, +col_varchar_key varchar(1) NOT NULL, +PRIMARY KEY(pk), +KEY col_varchar_key(col_varchar_key, col_int_key) +) charset utf8mb4 engine=innodb; +INSERT INTO t2(pk,col_int_key,col_varchar_key) VALUES +(8,7,'c'), +(11,4,'l'), +(12,7,'b'), +(13,0,'c'), +(14,2,'i'), +(15,9,'h'), +(16,4,'q'), +(17,1,'m'), +(18,9,'b'), +(19,2,'e'), +(20,1,'c'), +(21,7,'z'), +(22,4,'l'), +(23,7,'z'), +(24,0,'c'), +(25,2,'i'), +(26,9,'h'), +(27,4,'q'), +(28,0,'a'), +(29,1,'d'); +EXPLAIN SELECT outr.col_varchar_key AS x, outr.pk AS y +FROM t1 AS outr +WHERE outr.col_varchar_key IN (SELECT innr.col_varchar_key +FROM t2 AS innr +WHERE innr.col_varchar_key = 'a' OR innr.pk = 8) +AND outr.col_varchar_nokey < 't' +ORDER BY outr.col_varchar_key, outr.pk; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE innr NULL index PRIMARY,col_varchar_key col_varchar_key 10 NULL 20 55.00 Using where; Using index; Using temporary; Using filesort; LooseScan +1 SIMPLE outr NULL ref col_varchar_key col_varchar_key 6 test.innr.col_varchar_key 1 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`outr`.`col_varchar_key` AS `x`,`test`.`outr`.`pk` AS `y` from `test`.`t1` `outr` semi join (`test`.`t2` `innr`) where ((`test`.`outr`.`col_varchar_key` = `test`.`innr`.`col_varchar_key`) and (`test`.`outr`.`col_varchar_nokey` < 't') and ((`test`.`innr`.`col_varchar_key` = 'a') or (`test`.`innr`.`pk` = 8))) order by `test`.`outr`.`col_varchar_key`,`test`.`outr`.`pk` +SELECT outr.col_varchar_key AS x, outr.pk AS y +FROM t1 AS outr +WHERE outr.col_varchar_key IN (SELECT innr.col_varchar_key +FROM t2 AS innr +WHERE innr.col_varchar_key = 'a' OR innr.pk = 8) +AND outr.col_varchar_nokey < 't' +ORDER BY outr.col_varchar_key, outr.pk; +x y +a 1 +a 5 +c 3 +c 13 +DROP TABLE t1, t2; +# End of bug#12603200 +# +# Bug#12603183: Segfault in hp_movelink +# +CREATE TABLE t1 ( +col_varchar_key varchar(1) , +col_varchar_nokey varchar(1) , +KEY col_varchar_key(col_varchar_key) +) charset latin1; +INSERT INTO t1 VALUES +('i','i'), +('h','h'), +('q','q'), +('a','a'), +('v','v'), +('u','u'), +('s','s'), +('y','y'), +('z','z'), +('h','h'), +('p','p'), +('e','e'), +('i','i'), +('y','y'), +('w','w'); +CREATE TABLE t2 ( +col_varchar_nokey varchar(1) +) charset latin1; +INSERT INTO t2 VALUES +('b'); +EXPLAIN SELECT grandparent1.col_varchar_nokey +FROM t1 AS grandparent1 LEFT JOIN t2 AS grandparent2 USING (col_varchar_nokey) +WHERE (grandparent1.col_varchar_key) IN +(SELECT parent1.col_varchar_nokey +FROM t1 AS parent1 +WHERE parent1.col_varchar_key IN +(SELECT child1.col_varchar_nokey AS c1 +FROM t1 AS child1 LEFT JOIN t2 AS child2 +ON (child1.col_varchar_key > child2.col_varchar_nokey))); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE child1 NULL ALL NULL NULL NULL NULL 15 100.00 Using where; Start temporary +1 SIMPLE child2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE parent1 NULL ref col_varchar_key col_varchar_key 4 test.child1.col_varchar_nokey 2 100.00 Using where +1 SIMPLE grandparent1 NULL ref col_varchar_key col_varchar_key 4 test.parent1.col_varchar_nokey 2 100.00 End temporary +1 SIMPLE grandparent2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`grandparent1`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t1` `grandparent1` left join `test`.`t2` `grandparent2` on((`test`.`grandparent2`.`col_varchar_nokey` = `test`.`grandparent1`.`col_varchar_nokey`)) semi join (`test`.`t1` `parent1` join `test`.`t1` `child1` left join `test`.`t2` `child2` on((`test`.`child1`.`col_varchar_key` > `test`.`child2`.`col_varchar_nokey`))) where ((`test`.`grandparent1`.`col_varchar_key` = `test`.`parent1`.`col_varchar_nokey`) and (`test`.`parent1`.`col_varchar_key` = `test`.`child1`.`col_varchar_nokey`)) +SELECT grandparent1.col_varchar_nokey +FROM t1 AS grandparent1 LEFT JOIN t2 AS grandparent2 USING (col_varchar_nokey) +WHERE (grandparent1.col_varchar_key) IN +(SELECT parent1.col_varchar_nokey +FROM t1 AS parent1 +WHERE parent1.col_varchar_key IN +(SELECT child1.col_varchar_nokey AS c1 +FROM t1 AS child1 LEFT JOIN t2 AS child2 +ON (child1.col_varchar_key > child2.col_varchar_nokey))); +col_varchar_nokey +a +e +h +h +i +i +p +q +s +u +v +w +y +y +z +DROP TABLE t1, t2; +# End of test for bug#12603183. +# +# Bug#12818569: Diff nr of rows returned when using IN/ALL+subquery +# +CREATE TABLE t1 ( +col_int_key INT NOT NULL, +col_datetime_key DATETIME NOT NULL, +col_varchar_key VARCHAR(1) NOT NULL, +KEY col_int_key (col_int_key), +KEY col_datetime_key(col_datetime_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t1 VALUES +(7,'2004-06-06 04:22:12','v'), (0,'2005-11-13 01:12:31','s'), +(9,'2002-05-04 01:50:00','l'), (3,'2004-10-27 10:28:45','y'), +(4,'2006-07-22 05:24:23','c'), (2,'2002-05-16 21:34:03','i'), +(5,'2008-04-17 10:45:30','h'), (3,'2009-04-21 02:58:02','q'), +(1,'2008-01-11 11:01:51','a'), (3,'1900-01-01 00:00:00','v'), +(6,'2007-05-17 18:24:57','u'), (7,'2007-08-07 00:00:00','s'), +(5,'2001-08-28 00:00:00','y'), (1,'2004-04-16 00:27:28','z'), +(204,'2005-05-03 07:06:22','h'), (224,'2009-03-11 17:09:50','p'), +(9,'2007-12-08 01:54:28','e'), (5,'2009-07-28 18:19:54','i'), +(0,'2008-06-08 00:00:00','y'), (3,'2005-02-09 09:20:26','w'); +CREATE TABLE t2 ( +col_varchar_nokey VARCHAR(1) NOT NULL +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t2 VALUES ('v'), ('y'), ('j'), ('c'), ('d'), ('r'); +explain SELECT col_varchar_key +FROM t1 +WHERE col_varchar_key IN (SELECT col_varchar_nokey +FROM t2) +ORDER BY col_datetime_key LIMIT 4; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 100.00 Using temporary; Using filesort; Start temporary +1 SIMPLE t1 NULL ref col_varchar_key col_varchar_key 6 test.t2.col_varchar_nokey 1 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col_varchar_key` AS `col_varchar_key` from `test`.`t1` semi join (`test`.`t2`) where (`test`.`t1`.`col_varchar_key` = `test`.`t2`.`col_varchar_nokey`) order by `test`.`t1`.`col_datetime_key` limit 4 +SELECT col_varchar_key +FROM t1 +WHERE col_varchar_key IN (SELECT col_varchar_nokey +FROM t2) +ORDER BY col_datetime_key LIMIT 4; +col_varchar_key +v +y +v +y +DROP TABLE t1, t2; +# End of test for bug#12818569. +# +# Bug#12803439: Assert in replace_subcondition() on update query +# +CREATE TABLE t1(a INTEGER); +INSERT INTO t1 values(1), (2); +CREATE TABLE t2(a INTEGER); +INSERT INTO t2 VALUES(1), (3); +SELECT * +FROM t1 +WHERE a IN (SELECT a +FROM t2 +HAVING a IN (SELECT a +FROM t2) +) +HAVING a IN (SELECT a +FROM t2); +a +1 +DROP TABLE t1, t2; +# End of test for bug#12803439. +# +# Bug#12797534: Segfault in hp_movelink still exists +# +CREATE TABLE t1 ( +g1 VARCHAR(1) NOT NULL +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t1 VALUES ('d'), ('s'); +CREATE TABLE t2 ( +pk INT NOT NULL, +col_int_key INT NOT NULL, +col_varchar_key VARCHAR(1) NOT NULL, +col_varchar_nokey VARCHAR(1) NOT NULL, +PRIMARY KEY (pk), +KEY col_varchar_key(col_varchar_key, col_int_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t2 VALUES +(1,4,'j','j'), (2,6,'v','v'), (3,3,'c','c'), (4,5,'m','m'), +(5,3,'d','d'), (6,246,'d','d'), (7,2,'y','y'), (8,9,'t','t'), +(9,3,'d','d'), (10,8,'s','s'), (11,1,'r','r'), (12,8,'m','m'), +(13,8,'b','b'), (14,5,'x','x'), (15,7,'g','g'), (16,5,'p','p'), +(17,1,'q','q'), (18,6,'w','w'), (19,2,'d','d'), (20,9,'e','e'); +CREATE TABLE t3 ( +pk INTEGER NOT NULL, +PRIMARY KEY (pk) +) ENGINE=InnoDB; +INSERT INTO t3 VALUES (10); +EXPLAIN SELECT * +FROM t1 +WHERE g1 NOT IN +(SELECT grandparent1.col_varchar_nokey AS g1 +FROM t2 AS grandparent1 +WHERE grandparent1.col_varchar_key IN +(SELECT parent1.col_varchar_nokey AS p1 +FROM t2 AS parent1 LEFT JOIN t3 AS parent2 USING (pk) +) +AND grandparent1.col_varchar_key IS NOT NULL +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 SIMPLE parent1 NULL ALL NULL NULL NULL NULL 20 100.00 Using where; Not exists; Start temporary +2 SIMPLE parent2 NULL eq_ref PRIMARY PRIMARY 4 test.parent1.pk 1 100.00 Using index +2 SIMPLE grandparent1 NULL ref col_varchar_key col_varchar_key 6 test.parent1.col_varchar_nokey 1 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`g1` AS `g1` from `test`.`t1` anti join (`test`.`t2` `grandparent1` join `test`.`t2` `parent1` left join `test`.`t3` `parent2` on((`test`.`parent2`.`pk` = `test`.`parent1`.`pk`))) on(((`test`.`grandparent1`.`col_varchar_nokey` = `test`.`t1`.`g1`) and (`test`.`grandparent1`.`col_varchar_key` = `test`.`parent1`.`col_varchar_nokey`) and (`test`.`grandparent1`.`col_varchar_key` is not null))) where true +SELECT * +FROM t1 +WHERE g1 NOT IN +(SELECT grandparent1.col_varchar_nokey AS g1 +FROM t2 AS grandparent1 +WHERE grandparent1.col_varchar_key IN +(SELECT parent1.col_varchar_nokey AS p1 +FROM t2 AS parent1 LEFT JOIN t3 AS parent2 USING (pk) +) +AND grandparent1.col_varchar_key IS NOT NULL +); +g1 +DROP TABLE t1, t2, t3; +CREATE TABLE t1 ( +pk INTEGER AUTO_INCREMENT, +col_int_key INTEGER , +col_varchar_key VARCHAR(1) , +col_varchar_nokey VARCHAR(1) , +PRIMARY KEY (pk), +KEY (col_varchar_key,col_int_key) +) ENGINE=INNODB; +INSERT INTO t1 (col_int_key,col_varchar_key,col_varchar_nokey) VALUES +(0,'x','x'), (1,'j','j'), (1,'r','r'), (9,'v','v'), (5,'r','r'); +CREATE TABLE t2 ( +pk INTEGER AUTO_INCREMENT, +col_int_key INTEGER , +col_varchar_key VARCHAR(1) , +col_varchar_nokey VARCHAR(1) , +PRIMARY KEY (pk), +KEY (col_int_key), +KEY (col_varchar_key,col_int_key) +) AUTO_INCREMENT=10 ENGINE=INNODB; +INSERT INTO t2 (col_int_key, col_varchar_key, col_varchar_nokey) VALUES +(NULL,'x','x'), (NULL,'j','j'), (8,'c','c'); +CREATE TABLE t3 +SELECT outr.col_varchar_nokey AS x +FROM t1 AS outr +WHERE outr.col_varchar_nokey IN +(SELECT innr.col_varchar_nokey AS y +FROM t2 AS innr +WHERE innr.col_int_key IS NULL) +AND outr.col_varchar_nokey IS NOT NULL +AND NOT col_varchar_key IS NULL; +SELECT * +FROM t3 +WHERE x NOT IN +(SELECT outr.col_varchar_nokey AS x +FROM t1 AS outr +WHERE outr.col_varchar_nokey IN +(SELECT innr.col_varchar_nokey AS y +FROM t2 AS innr +WHERE innr.col_int_key IS NULL) +AND outr.col_varchar_nokey IS NOT NULL +AND NOT col_varchar_key IS NULL); +x +DROP TABLE t1, t2, t3; +# End of test for bug#12797534. +# +# Bug#12714094: Assert in optimize_semijoin_nests() +# +CREATE TABLE it ( +pk int NOT NULL, +col_varchar VARCHAR(10) DEFAULT NULL, +PRIMARY KEY (pk) +) ENGINE=MyISAM; +INSERT INTO it VALUES (1, 'g'); +CREATE TABLE ot +SELECT alias1.pk AS field1 +FROM it AS alias1 +LEFT JOIN it AS alias2 +ON alias1.col_varchar = alias2.col_varchar +; +SELECT * +FROM ot +WHERE field1 IN ( +SELECT alias1.pk +FROM it AS alias1 +LEFT JOIN it AS alias2 +ON alias1.col_varchar = alias2.col_varchar +); +field1 +1 +DROP TABLE it, ot; +# End of test for bug#12714094 +# +# Bug#12867557: Valgrind: conditional jump/move at key_cmp +# +CREATE TABLE t1 ( +pk INTEGER AUTO_INCREMENT, +col_int_key INTEGER, +PRIMARY KEY (pk), +KEY (col_int_key) +) AUTO_INCREMENT=10; +INSERT INTO t1 (col_int_key) VALUES (8); +CREATE TABLE t2 ( +pk INTEGER AUTO_INCREMENT, +col_int_key INTEGER, +col_time_key TIME, +PRIMARY KEY (pk), +KEY (col_int_key), +KEY (col_time_key) +) AUTO_INCREMENT=10; +INSERT INTO t2 (col_int_key, col_time_key) +VALUES +(8, '22:55:23.019225'), (7, '10:19:31.050677'), (1, '14:40:36.038608'), +(7, '04:37:47.062416'), (9, '19:34:06.054514'), (NULL,'20:35:33.022996'), +(1, NULL), (9, '14:43:37.057393'), (2, '02:23:09.043438'), +(9, '01:22:45.041064'), (2, '00:00:00'), (4, '00:13:25.038482'), +(0, '03:47:16.042671'), (4, '01:41:48.007423'), (8, '00:00:00'), +(NULL, '22:32:04.047407'), (NULL, '16:44:14.028443'), (0, '17:38:37.059754'), +(NULL, '08:46:48.042388'), (8, '14:11:27.044095'); +CREATE TABLE t0 +SELECT DISTINCT grandparent1.col_time_key AS g1 +FROM t2 AS grandparent1 +WHERE grandparent1.col_int_key IN +(SELECT parent1.col_int_key AS p1 +FROM t1 AS parent1) +AND grandparent1.pk > 9; +UPDATE t0 +SET g1 = g1 +WHERE g1 IN +(SELECT grandparent1.col_time_key AS g1 +FROM t2 AS grandparent1 +WHERE grandparent1.col_int_key IN +(SELECT parent1.col_int_key AS p1 +FROM t1 AS parent1) +AND grandparent1.pk > 9); +DROP TABLE t0, t1, t2; +# End of test for bug#12867557 +# +# Bug#12711441: crash in fix_after_pullout +# +CREATE TABLE t1 ( +pk int NOT NULL, +col_int_nokey int DEFAULT NULL, +col_int_key int DEFAULT NULL, +col_time_key time DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +PRIMARY KEY (pk) +); +CREATE VIEW v1 AS SELECT * FROM t1; +CREATE TABLE t2 ( +col_int_key int DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +KEY col_varchar_key(col_varchar_key, col_int_key) +); +CREATE TABLE t3 ( +pk int NOT NULL, +col_int_key INT DEFAULT NULL, +PRIMARY KEY (pk) +); +CREATE TABLE t4 ( +col_int_nokey INT DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +KEY col_varchar_key(col_varchar_key) +); +CREATE TABLE ts +SELECT alias1.col_time_key AS field1 +FROM v1 AS alias1 +RIGHT JOIN t3 AS alias2 +ON alias2.col_int_key = alias1.col_int_nokey +WHERE alias1.pk >= SOME( +SELECT SQ1_alias1.pk AS SQ1_field1 +FROM t3 AS SQ1_alias1 +INNER JOIN (t2 AS SQ1_alias2 +INNER JOIN t4 AS SQ1_alias3 +ON SQ1_alias3.col_varchar_key = SQ1_alias2.col_varchar_nokey) +ON SQ1_alias3.col_int_nokey = SQ1_alias2.col_int_key +WHERE SQ1_alias2.col_varchar_key <= alias1.col_varchar_key +AND SQ1_alias3.col_varchar_nokey <> alias1.col_varchar_key) +; +SELECT * FROM ts WHERE field1 IN ( +SELECT alias1.col_time_key AS field1 +FROM v1 AS alias1 +RIGHT JOIN t3 AS alias2 +ON alias2.col_int_key = alias1.col_int_nokey +WHERE alias1.pk >= SOME( +SELECT SQ1_alias1.pk AS SQ1_field1 +FROM t3 AS SQ1_alias1 +INNER JOIN (t2 AS SQ1_alias2 +INNER JOIN t4 AS SQ1_alias3 +ON SQ1_alias3.col_varchar_key = SQ1_alias2.col_varchar_nokey) +ON SQ1_alias3.col_int_nokey = SQ1_alias2.col_int_key +WHERE SQ1_alias2.col_varchar_key <= alias1.col_varchar_key +AND SQ1_alias3.col_varchar_nokey <> alias1.col_varchar_key) +); +field1 +DROP TABLE t1, t2, t3, t4, ts; +DROP VIEW v1; +# End of test for bug#12711441. +# +# Bug#12664936: Same query executed as where subquery ... +# +CREATE TABLE t1 ( +col_varchar_key VARCHAR(1), +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4; +INSERT INTO t1 VALUES +('o'), ('w'), ('m'), ('q'), +('f'), ('p'), ('j'), ('c'); +CREATE TABLE t2 ( +col_int_nokey INTEGER, +col_int_key INTEGER, +col_varchar_key varchar(1), +KEY col_int_key (col_int_key) +) charset utf8mb4; +INSERT INTO t2 VALUES +(8,5,'u'),(4,5,'p'),(8,1,'o'),(NULL,7,'v'), +(1,2,'g'),(2,1,'q'),(NULL,7,'l'),(3,1,'n'); +CREATE TABLE t4 +SELECT t2.col_int_nokey, t2.col_varchar_key +FROM t1 JOIN t2 ON t2.col_varchar_key = t1.col_varchar_key +WHERE t2.col_int_key = 1; +EXPLAIN SELECT * +FROM t4 +WHERE (col_int_nokey, col_varchar_key) IN +(SELECT t2.col_int_nokey, t2.col_varchar_key +FROM t1 JOIN t2 ON t2.col_varchar_key = t1.col_varchar_key +WHERE t2.col_int_key = 1 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t4 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE t2 NULL ref col_int_key col_int_key 5 const 3 12.50 Using where; Start temporary +1 SIMPLE t1 NULL ref col_varchar_key col_varchar_key 7 test.t4.col_varchar_key 2 100.00 Using index; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`col_int_nokey` AS `col_int_nokey`,`test`.`t4`.`col_varchar_key` AS `col_varchar_key` from `test`.`t4` semi join (`test`.`t1` join `test`.`t2`) where ((`test`.`t2`.`col_varchar_key` = `test`.`t4`.`col_varchar_key`) and (`test`.`t1`.`col_varchar_key` = `test`.`t4`.`col_varchar_key`) and (`test`.`t2`.`col_int_nokey` = `test`.`t4`.`col_int_nokey`) and (`test`.`t2`.`col_int_key` = 1)) +SELECT * +FROM t4 +WHERE (col_int_nokey, col_varchar_key) IN +(SELECT t2.col_int_nokey, t2.col_varchar_key +FROM t1 JOIN t2 ON t2.col_varchar_key = t1.col_varchar_key +WHERE t2.col_int_key = 1 +); +col_int_nokey col_varchar_key +8 o +2 q +DROP TABLE t1, t2, t4; +# End of test for bug#12664936. +# +# Bug#13340270: assertion table->sort.record_pointers == __null +# +CREATE TABLE t1 ( +pk int NOT NULL, +col_int_key int DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key, col_int_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t1 VALUES +(10,8,'x','x'), +(11,7,'d','d'), +(12,1,'r','r'), +(13,7,'f','f'), +(14,9,'y','y'), +(15,NULL,'u','u'), +(16,1,'m','m'), +(17,9,NULL,NULL), +(18,2,'o','o'), +(19,9,'w','w'), +(20,2,'m','m'), +(21,4,'q','q'); +CREATE TABLE t2 +SELECT alias1.col_varchar_nokey AS field1 +FROM t1 AS alias1 JOIN t1 AS alias2 +ON alias2.col_int_key = alias1.pk OR +alias2.col_int_key = alias1.col_int_key +WHERE alias1.pk = 58 OR alias1.col_varchar_key = 'o' + +; +EXPLAIN SELECT * +FROM t2 +WHERE (field1) IN (SELECT alias1.col_varchar_nokey AS field1 +FROM t1 AS alias1 JOIN t1 AS alias2 +ON alias2.col_int_key = alias1.pk OR +alias2.col_int_key = alias1.col_int_key +WHERE alias1.pk = 58 OR alias1.col_varchar_key = 'o' +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE alias1 NULL index_merge PRIMARY,col_int_key,col_varchar_key col_varchar_key,PRIMARY 7,4 NULL 2 10.00 Using sort_union(col_varchar_key,PRIMARY); Using where; Using join buffer (hash join) +1 SIMPLE alias2 NULL ALL col_int_key NULL NULL NULL 12 19.00 Range checked for each record (index map: 0x2); End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`field1` AS `field1` from `test`.`t2` semi join (`test`.`t1` `alias1` join `test`.`t1` `alias2`) where ((`test`.`alias1`.`col_varchar_nokey` = `test`.`t2`.`field1`) and ((`test`.`alias1`.`pk` = 58) or (`test`.`alias1`.`col_varchar_key` = 'o')) and ((`test`.`alias2`.`col_int_key` = `test`.`alias1`.`pk`) or (`test`.`alias2`.`col_int_key` = `test`.`alias1`.`col_int_key`))) +SELECT * +FROM t2 +WHERE (field1) IN (SELECT alias1.col_varchar_nokey AS field1 +FROM t1 AS alias1 JOIN t1 AS alias2 +ON alias2.col_int_key = alias1.pk OR +alias2.col_int_key = alias1.col_int_key +WHERE alias1.pk = 58 OR alias1.col_varchar_key = 'o' +); +field1 +o +o +DROP TABLE t1, t2; +# End of test for bug#13340270. +# +# Bug#13335319: Seg fault when analyzing FirstMatch semi-join strategy +# +CREATE TABLE ot1(a INTEGER); +INSERT INTO ot1 VALUES(1), (2), (3); +CREATE TABLE ot2(a INTEGER); +INSERT INTO ot2 VALUES(1), (2), (4), (6), (8), (10); +CREATE TABLE it1(a INTEGER); +INSERT INTO it1 VALUES(1), (3), (5), (7); +CREATE TABLE it2(a INTEGER); +INSERT INTO it2 VALUES(1), (3), (5), (7), (9); +explain SELECT ot1.a, ot2.a +FROM ot1, ot2 +WHERE ot1.a IN (SELECT a FROM it1) AND +ot2.a IN (SELECT a FROM it2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE it2 NULL ALL NULL NULL NULL NULL 5 100.00 Start temporary +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Using join buffer (hash join) +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 SIMPLE it1 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` join `test`.`ot2` semi join (`test`.`it1`) semi join (`test`.`it2`) where ((`test`.`ot2`.`a` = `test`.`it2`.`a`) and (`test`.`it1`.`a` = `test`.`ot1`.`a`)) +SELECT ot1.a, ot2.a +FROM ot1, ot2 +WHERE ot1.a IN (SELECT a FROM it1) AND +ot2.a IN (SELECT a FROM it2); +a a +1 1 +3 1 +DROP TABLE ot1, ot2, it1, it2; +# End of test for bug#13335319. +# +# Bug#13334882: Assertion keypart_map failed in MyIsam function +# +CREATE TABLE t1 ( +pk int NOT NULL, +col_int_nokey INT NOT NULL, +col_int_key INT NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +) ENGINE=MyISAM; +INSERT INTO t1 VALUES +(1,4,0), +(2,6,8), +(3,3,1), +(7,2,6), +(8,9,1), +(9,3,6), +(10,8,2), +(11,1,4), +(12,8,8), +(13,8,4), +(14,5,4); +CREATE TABLE t2 ( +pk int NOT NULL, +col_int_nokey int NOT NULL, +col_int_key int NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +) ENGINE=MyISAM; +INSERT INTO t2 VALUES +(10,8,7); +CREATE TABLE t3 +SELECT grandparent1.col_int_nokey AS g1 +FROM t1 AS grandparent1 +WHERE (grandparent1.col_int_nokey, grandparent1.col_int_key) IN +(SELECT parent1.col_int_key AS p1, +parent1.col_int_key AS p2 +FROM t1 AS parent1 +LEFT JOIN t2 AS parent2 +ON parent1.col_int_nokey = parent2.col_int_key +) +AND grandparent1.col_int_key <> 3 +; +explain SELECT * FROM t3 +WHERE g1 NOT IN +(SELECT grandparent1.col_int_nokey AS g1 +FROM t1 AS grandparent1 +WHERE (grandparent1.col_int_nokey, grandparent1.col_int_key) IN +(SELECT parent1.col_int_key AS p1, +parent1.col_int_key AS p2 +FROM t1 AS parent1 +LEFT JOIN t2 AS parent2 +ON parent1.col_int_nokey = parent2.col_int_key +) +AND grandparent1.col_int_key <> 3 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE grandparent1 NULL ref col_int_key col_int_key 4 const 1 100.00 Using where; Not exists; Start temporary +1 SIMPLE parent1 NULL ref col_int_key col_int_key 4 test.grandparent1.col_int_nokey 1 100.00 Using where +1 SIMPLE parent2 NULL ref col_int_key col_int_key 4 test.parent1.col_int_nokey 2 100.00 Using index; End temporary +Warnings: +Note 1003 /* select#1 */ select '8' AS `g1` from anti join (`test`.`t1` `grandparent1` join `test`.`t1` `parent1` left join `test`.`t2` `parent2` on((`test`.`parent2`.`col_int_key` = `test`.`parent1`.`col_int_nokey`))) on(((`test`.`grandparent1`.`col_int_nokey` = '8') and (`test`.`grandparent1`.`col_int_key` = '8') and (`test`.`parent1`.`col_int_key` = '8') and ('8' <> 3))) where true +explain format=json SELECT * FROM t3 +WHERE g1 NOT IN +(SELECT grandparent1.col_int_nokey AS g1 +FROM t1 AS grandparent1 +WHERE (grandparent1.col_int_nokey, grandparent1.col_int_key) IN +(SELECT parent1.col_int_key AS p1, +parent1.col_int_key AS p2 +FROM t1 AS parent1 +LEFT JOIN t2 AS parent2 +ON parent1.col_int_nokey = parent2.col_int_key +) +AND grandparent1.col_int_key <> 3 +); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "2.70" + }, + "nested_loop": [ + { + "table": { + "table_name": "t3", + "access_type": "system", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.00", + "eval_cost": "0.10", + "prefix_cost": "0.00", + "data_read_per_join": "8" + }, + "used_columns": [ + "g1" + ] + } + }, + { + "duplicates_removal": { + "using_temporary_table": true, + "nested_loop": [ + { + "table": { + "table_name": "grandparent1", + "access_type": "ref", + "possible_keys": [ + "col_int_key" + ], + "key": "col_int_key", + "used_key_parts": [ + "col_int_key" + ], + "key_length": "4", + "ref": [ + "const" + ], + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "not_exists": true, + "cost_info": { + "read_cost": "0.28", + "eval_cost": "0.11", + "prefix_cost": "0.39", + "data_read_per_join": "17" + }, + "used_columns": [ + "col_int_nokey", + "col_int_key" + ], + "attached_condition": "(((is_not_null_compl(grandparent1..parent2), (found_match(grandparent1..parent2), false, true), true) and (is_not_null_compl(grandparent1..parent2), (('8' <> 3)), true)) and (is_not_null_compl(grandparent1..parent2), (`test`.`grandparent1`.`col_int_nokey` = '8'), true))" + } + }, + { + "table": { + "table_name": "parent1", + "access_type": "ref", + "possible_keys": [ + "col_int_key" + ], + "key": "col_int_key", + "used_key_parts": [ + "col_int_key" + ], + "key_length": "4", + "ref": [ + "test.grandparent1.col_int_nokey" + ], + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.30", + "eval_cost": "0.12", + "prefix_cost": "0.81", + "data_read_per_join": "19" + }, + "used_columns": [ + "col_int_nokey", + "col_int_key" + ], + "attached_condition": "(is_not_null_compl(grandparent1..parent2), (`test`.`parent1`.`col_int_key` = '8'), true)" + } + }, + { + "table": { + "table_name": "parent2", + "access_type": "ref", + "possible_keys": [ + "col_int_key" + ], + "key": "col_int_key", + "used_key_parts": [ + "col_int_key" + ], + "key_length": "4", + "ref": [ + "test.parent1.col_int_nokey" + ], + "rows_examined_per_scan": 2, + "rows_produced_per_join": 1, + "filtered": "100.00", + "using_index": true, + "cost_info": { + "read_cost": "0.31", + "eval_cost": "0.10", + "prefix_cost": "2.70", + "data_read_per_join": "16" + }, + "used_columns": [ + "col_int_key" + ] + } + } + ] + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select '8' AS `g1` from anti join (`test`.`t1` `grandparent1` join `test`.`t1` `parent1` left join `test`.`t2` `parent2` on((`test`.`parent2`.`col_int_key` = `test`.`parent1`.`col_int_nokey`))) on(((`test`.`grandparent1`.`col_int_nokey` = '8') and (`test`.`grandparent1`.`col_int_key` = '8') and (`test`.`parent1`.`col_int_key` = '8') and ('8' <> 3))) where true +SELECT * FROM t3 +WHERE g1 NOT IN +(SELECT grandparent1.col_int_nokey AS g1 +FROM t1 AS grandparent1 +WHERE (grandparent1.col_int_nokey, grandparent1.col_int_key) IN +(SELECT parent1.col_int_key AS p1, +parent1.col_int_key AS p2 +FROM t1 AS parent1 +LEFT JOIN t2 AS parent2 +ON parent1.col_int_nokey = parent2.col_int_key +) +AND grandparent1.col_int_key <> 3 +); +g1 +DROP TABLE t1, t2, t3; +# End of test for bug#13334882. +# +# Bug#13339643: Assertion on JOIN::flatten_subqueries on second execution +# +CREATE TABLE t1 ( +col_int_nokey INT, +col_varchar_nokey VARCHAR(1) +) charset utf8mb4; +INSERT INTO t1 VALUES +(1,'o'), +(2,'t'); +CREATE TABLE t2 LIKE t1; +INSERT INTO t2 VALUES +(1,'o'), +(4,'f'); +CREATE VIEW v_t2 AS SELECT * FROM t2; +CREATE TABLE t3 LIKE t1; +INSERT INTO t3 VALUES +(1,'o'), +(4,'f'); +explain SELECT alias1.col_varchar_nokey +FROM t1 AS alias1 +INNER JOIN v_t2 AS alias2 +ON alias2.col_int_nokey = alias1.col_int_nokey AND +'o' IN (SELECT col_varchar_nokey +FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary; End temporary +1 SIMPLE alias1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`alias1`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t1` `alias1` join `test`.`t2` semi join (`test`.`t3`) where ((`test`.`t3`.`col_varchar_nokey` = 'o') and (`test`.`t2`.`col_int_nokey` = `test`.`alias1`.`col_int_nokey`)) +SELECT alias1.col_varchar_nokey +FROM t1 AS alias1 +INNER JOIN v_t2 AS alias2 +ON alias2.col_int_nokey = alias1.col_int_nokey AND +'o' IN (SELECT col_varchar_nokey +FROM t3); +col_varchar_nokey +o +PREPARE stmt FROM "SELECT alias1.col_varchar_nokey +FROM t1 AS alias1 +INNER JOIN v_t2 AS alias2 +ON alias2.col_int_nokey = alias1.col_int_nokey AND +'o' IN (SELECT col_varchar_nokey +FROM t3)"; +EXECUTE stmt; +col_varchar_nokey +o +DROP VIEW v_t2; +DROP TABLE t1, t2, t3; +# End of test for bug#13339643. +# +# Bug#13424134: Wrong result on JOIN + nested WHERE ... IN clauses +# +CREATE TABLE t1 ( +pk int NOT NULL, +col_int_nokey int NOT NULL, +col_int_key int NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +) ENGINE=MyIsam; +INSERT INTO t1 VALUES +(10,1,7), (13,7,3), (18,0,1), (23,8,1); +CREATE TABLE t2 ( +pk int NOT NULL, +col_int_key int NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +) ENGINE=MyIsam; +INSERT INTO t2 VALUES (1,7); +EXPLAIN SELECT t1a.* +FROM t1 AS t1a +JOIN t1 AS t1b USING ( col_int_nokey ) +WHERE t1a.col_int_key IN ( +SELECT pk +FROM t2 +WHERE col_int_key IN ( +SELECT col_int_nokey +FROM t1 +) +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL system PRIMARY,col_int_key NULL NULL NULL 1 100.00 NULL +1 SIMPLE t1a NULL ref col_int_key col_int_key 4 const 1 100.00 Start temporary +1 SIMPLE t1b NULL ALL NULL NULL NULL NULL 4 25.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1a`.`pk` AS `pk`,`test`.`t1a`.`col_int_nokey` AS `col_int_nokey`,`test`.`t1a`.`col_int_key` AS `col_int_key` from `test`.`t1` `t1a` join `test`.`t1` `t1b` semi join (`test`.`t1`) where ((`test`.`t1b`.`col_int_nokey` = `test`.`t1a`.`col_int_nokey`) and (`test`.`t1a`.`col_int_key` = '1') and (`test`.`t1`.`col_int_nokey` = '7')) +SELECT t1a.* +FROM t1 AS t1a +JOIN t1 AS t1b USING ( col_int_nokey ) +WHERE t1a.col_int_key IN ( +SELECT pk +FROM t2 +WHERE col_int_key IN ( +SELECT col_int_nokey +FROM t1 +) +); +pk col_int_nokey col_int_key +18 0 1 +23 8 1 +ALTER TABLE t1 ENGINE=Innodb; +ALTER TABLE t2 ENGINE=Innodb; +SELECT t1a.* +FROM t1 AS t1a +JOIN t1 AS t1b USING ( col_int_nokey ) +WHERE t1a.col_int_key IN ( +SELECT pk +FROM t2 +WHERE col_int_key IN ( +SELECT col_int_nokey +FROM t1 +) +); +pk col_int_nokey col_int_key +18 0 1 +23 8 1 +DROP TABLE t1, t2; +# End of test for bug#13424134. +# +# Bug#13414014: Extra rows in result on semijoin query with where ... +# +CREATE TABLE t1 ( +c INT, +d INT, +a VARCHAR(1), +b VARCHAR(1), +KEY a (a) +) charset utf8mb4; +INSERT INTO t1 VALUES +(NULL,8,'x','x'), (7,4,'q','q'), (6,8,'c','c'); +CREATE TABLE t2 ( +a VARCHAR(1), +KEY a (a) +) charset utf8mb4; +INSERT INTO t2 VALUES +('c'), (NULL), ('x'), ('q'); +explain SELECT * +FROM t2 AS ot +WHERE (a, a) IN +(SELECT a, b +FROM t1 AS it +WHERE it.a = 'x' OR it.c > it.d +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE it NULL ALL a NULL NULL NULL 3 40.74 Using where; Start temporary +1 SIMPLE ot NULL ref a a 7 test.it.a 2 100.00 Using index; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`ot`.`a` AS `a` from `test`.`t2` `ot` semi join (`test`.`t1` `it`) where ((`test`.`it`.`b` = `test`.`it`.`a`) and (`test`.`ot`.`a` = `test`.`it`.`a`) and ((`test`.`it`.`a` = 'x') or (`test`.`it`.`c` > `test`.`it`.`d`))) +SELECT * +FROM t2 AS ot +WHERE (a, a) IN +(SELECT a, b +FROM t1 AS it +WHERE it.a = 'x' OR it.c > it.d +) +; +a +q +x +DROP TABLE t1, t2; +# End of test for bug#13414014. +# +# Bug#13545215: Missing rows on nested in-subquery with materialization +# +CREATE TABLE t1 ( +col_int_key int, +col_varchar_key varchar(1), +col_varchar_nokey varchar(1), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +INSERT INTO t1 VALUES +(8,'x','x'), (0,'p','p'), (8,'c','c'); +CREATE TABLE t2 ( +pk int NOT NULL, +col_varchar_key varchar(1), +col_varchar_nokey varchar(1), +PRIMARY KEY (pk), +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4; +INSERT INTO t2 VALUES +(1,'v','v'), (2,'v','v'), (3,'c','c'), (4,NULL,NULL), +(5,'x','x'), (6,'i','i'), (7,'e','e'), (8,'p','p'); +CREATE TABLE t3 ( +col_int_nokey int +); +INSERT INTO t3 VALUES (7); +explain SELECT grandparent1.col_varchar_nokey +FROM t1 AS grandparent1 JOIN t1 AS grandparent2 USING (col_int_key) +WHERE grandparent1.col_varchar_key IN ( +SELECT col_varchar_nokey +FROM t2 AS parent1 +WHERE col_varchar_key IN ( +SELECT child1.col_varchar_nokey +FROM t2 AS child1 LEFT JOIN t3 AS child2 +ON child1.pk < child2.col_int_nokey +) +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE grandparent1 NULL ALL col_int_key,col_varchar_key NULL NULL NULL 3 100.00 Using where; Start temporary +1 SIMPLE parent1 NULL ALL col_varchar_key NULL NULL NULL 8 12.50 Using where; Using join buffer (hash join) +1 SIMPLE child1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; Using join buffer (hash join) +1 SIMPLE child2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +1 SIMPLE grandparent2 NULL ref col_int_key col_int_key 5 test.grandparent1.col_int_key 2 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`grandparent1`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t1` `grandparent1` join `test`.`t1` `grandparent2` semi join (`test`.`t2` `parent1` join `test`.`t2` `child1` left join `test`.`t3` `child2` on((`test`.`child1`.`pk` < `test`.`child2`.`col_int_nokey`))) where ((`test`.`grandparent2`.`col_int_key` = `test`.`grandparent1`.`col_int_key`) and (`test`.`parent1`.`col_varchar_nokey` = `test`.`grandparent1`.`col_varchar_key`) and (`test`.`child1`.`col_varchar_nokey` = `test`.`parent1`.`col_varchar_key`)) +SELECT grandparent1.col_varchar_nokey +FROM t1 AS grandparent1 JOIN t1 AS grandparent2 USING (col_int_key) +WHERE grandparent1.col_varchar_key IN ( +SELECT col_varchar_nokey +FROM t2 AS parent1 +WHERE col_varchar_key IN ( +SELECT child1.col_varchar_nokey +FROM t2 AS child1 LEFT JOIN t3 AS child2 +ON child1.pk < child2.col_int_nokey +) +); +col_varchar_nokey +c +c +p +x +x +DROP TABLE t1, t2, t3; +# End of test for bug#13545215. +# +# BUG#13553211 - MISSING ROWS ON SELECT WITH IN-SUBQUERY AND +# MATERIALIZATION + SEMIJOIN ON +# +CREATE TABLE t1 ( +col_int_key int(11) DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (4,'v','v'); +INSERT INTO t1 VALUES (62,'v','v'); +INSERT INTO t1 VALUES (7,'c','c'); +INSERT INTO t1 VALUES (1,NULL,NULL); +EXPLAIN SELECT +alias1.col_varchar_nokey AS a1_nokey, +alias1.col_varchar_key AS a1_key, +alias2.col_varchar_nokey AS a2_nokey +FROM +t1 AS alias1, t1 AS alias2 +WHERE +(alias1.col_varchar_nokey,alias2.col_varchar_nokey) +IN +( +SELECT +sq2_alias2.col_varchar_nokey, sq2_alias1.col_varchar_key +FROM +t1 AS sq2_alias1, t1 AS sq2_alias2 +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE alias1 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +1 SIMPLE sq2_alias1 NULL index col_varchar_key col_varchar_key 12 NULL 4 100.00 Using index; LooseScan +1 SIMPLE sq2_alias2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; FirstMatch(sq2_alias1) +1 SIMPLE alias2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`alias1`.`col_varchar_nokey` AS `a1_nokey`,`test`.`alias1`.`col_varchar_key` AS `a1_key`,`test`.`alias2`.`col_varchar_nokey` AS `a2_nokey` from `test`.`t1` `alias1` join `test`.`t1` `alias2` semi join (`test`.`t1` `sq2_alias1` join `test`.`t1` `sq2_alias2`) where ((`test`.`alias2`.`col_varchar_nokey` = `test`.`sq2_alias1`.`col_varchar_key`) and (`test`.`sq2_alias2`.`col_varchar_nokey` = `test`.`alias1`.`col_varchar_nokey`)) +SELECT +alias1.col_varchar_nokey AS a1_nokey, +alias1.col_varchar_key AS a1_key, +alias2.col_varchar_nokey AS a2_nokey +FROM +t1 AS alias1, t1 AS alias2 +WHERE +(alias1.col_varchar_nokey,alias2.col_varchar_nokey) +IN +( +SELECT +sq2_alias2.col_varchar_nokey, sq2_alias1.col_varchar_key +FROM +t1 AS sq2_alias1, t1 AS sq2_alias2 +) +; +a1_nokey a1_key a2_nokey +c c c +c c v +c c v +v v c +v v c +v v v +v v v +v v v +v v v +DROP TABLE t1; +# +# Bug#13541406: Wrong result with loosescan on select .. where .. in +# +CREATE TABLE t1 ( +col_int_key INT NOT NULL, +col_varchar_nokey VARCHAR(1) NOT NULL, +KEY col_int_key (col_int_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t1 VALUES +(7,'v'), (0,'s'), (9,'l'), (3,'y'), (4,'c'), (2,'i'), (5,'h'), (3,'q'), +(1,'a'), (3,'v'), (6,'u'), (7,'s'), (5,'y'), (1,'z'), (204,'h'), (224,'p'), +(9,'e'), (5,'i'), (0,'y'), (3,'w'); +CREATE TABLE t2 ( +pk INT NOT NULL, +col_int_key INT NOT NULL, +col_varchar_key VARCHAR(1) NOT NULL, +col_varchar_nokey VARCHAR(1) NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t2 VALUES +(1,0,'j','j'), (2,8,'v','v'), (3,1,'c','c'), (4,8,'m','m'), +(5,9,'d','d'), (6,24,'d','d'), (7,6,'y','y'), (8,1,'t','t'), +(9,6,'d','d'), (10,2,'s','s'), (11,4,'r','r'), (12,8,'m','m'), +(13,4,'b','b'), (14,4,'x','x'), (15,7,'g','g'), (16,4,'p','p'), +(17,1,'q','q'), (18,9,'w','w'), (19,4,'d','d'), (20,8,'e','e'); +# This query should never use a LooseScan strategy +explain SELECT ot1.col_int_key AS field1 +FROM t2 AS ot1, t2 AS ot2 +WHERE (ot1.col_varchar_key, ot2.col_varchar_nokey) IN ( +SELECT it2.col_varchar_nokey, it1.col_varchar_key +FROM t2 AS it1 JOIN t1 AS it2 ON it2.col_int_key = it1.pk); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 20 100.00 Parallel execute (1 workers) +2 SIMPLE ot1 NULL index col_varchar_key col_varchar_key 10 NULL 20 100.00 Using index +2 SIMPLE it1 NULL index PRIMARY,col_varchar_key col_varchar_key 10 NULL 20 80.00 Using index; LooseScan +2 SIMPLE it2 NULL ref col_int_key col_int_key 4 test.it1.pk 1 10.00 Using where; FirstMatch(it1) +2 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 20 10.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`col_int_key` AS `field1` from `test`.`t2` `ot1` join `test`.`t2` `ot2` semi join (`test`.`t2` `it1` join `test`.`t1` `it2`) where ((`test`.`it2`.`col_int_key` = `test`.`it1`.`pk`) and (`test`.`ot2`.`col_varchar_nokey` = `test`.`it1`.`col_varchar_key`) and (`test`.`it2`.`col_varchar_nokey` = `test`.`ot1`.`col_varchar_key`)) +SELECT ot1.col_int_key AS field1 +FROM t2 AS ot1, t2 AS ot2 +WHERE (ot1.col_varchar_key, ot2.col_varchar_nokey) IN ( +SELECT it2.col_varchar_nokey, it1.col_varchar_key +FROM t2 AS it1 JOIN t1 AS it2 ON it2.col_int_key = it1.pk); +field1 +1 +1 +1 +2 +6 +6 +6 +6 +6 +8 +8 +8 +8 +8 +8 +9 +DROP TABLE t1, t2; +# End of test for bug#13541406. +# +# Bug#13576391: Missing rows on select with in-subquery and +# batched-key-access=on and semijoin +# +CREATE TABLE t1 ( +col_int_nokey int NOT NULL, +col_varchar_key varchar(1) NOT NULL, +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4 engine=InnoDB; +INSERT INTO t1 VALUES +(1,'v'), (7,'s'), (4,'l'), (7,'y'), (0,'c'), (2,'i'), (9,'h'), (4,'q'), +(0,'a'), (9,'v'), (1,'u'), (3,'s'), (8,'y'), (8,'z'), (18,'h'), (84,'p'), +(6,'e'), (3,'i'), (6,'y'), (6,'w'); +CREATE TABLE t2 ( +col_int_nokey int NOT NULL, +col_varchar_nokey varchar(1) NOT NULL +) charset utf8mb4 engine=InnoDB; +INSERT INTO t2 VALUES +(4,'j'), (6,'v'), (3,'c'), (5,'m'), (3,'d'), (246,'d'), (2,'y'), (9,'t'), +(3,'d'), (8,'s'), (1,'r'), (8,'m'), (8,'b'), (5,'x'), (7,'g'), (5,'p'), +(1,'q'), (6,'w'), (2,'d'), (9,'e'); +explain SELECT col_varchar_nokey +FROM t2 AS ot +WHERE col_varchar_nokey IN ( +SELECT col_varchar_key +FROM t1 AS it +WHERE it.col_int_nokey <= it.col_int_nokey +AND NOT ot.col_int_nokey < 2 +) +ORDER BY col_varchar_nokey; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 20 33.33 Parallel execute (1 workers) +2 SIMPLE ot NULL ALL NULL NULL NULL NULL 20 33.33 Using where; Using filesort +2 SIMPLE it NULL ref col_varchar_key col_varchar_key 6 test.ot.col_varchar_nokey 1 100.00 Start temporary; End temporary +Warnings: +Note 1276 Field or reference 'test.ot.col_int_nokey' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`ot`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t2` `ot` semi join (`test`.`t1` `it`) where ((`test`.`it`.`col_varchar_key` = `test`.`ot`.`col_varchar_nokey`) and (`test`.`ot`.`col_int_nokey` >= 2)) order by `test`.`ot`.`col_varchar_nokey` +SELECT col_varchar_nokey +FROM t2 AS ot +WHERE col_varchar_nokey IN ( +SELECT col_varchar_key +FROM t1 AS it +WHERE it.col_int_nokey <= it.col_int_nokey +AND NOT ot.col_int_nokey < 2 +) +ORDER BY col_varchar_nokey; +col_varchar_nokey +c +e +p +s +v +w +y +ALTER TABLE t1 ENGINE=MyISAM; +ALTER TABLE t2 ENGINE=MyISAM; +explain SELECT col_varchar_nokey +FROM t2 AS ot +WHERE col_varchar_nokey IN ( +SELECT col_varchar_key +FROM t1 AS it +WHERE it.col_int_nokey <= it.col_int_nokey +AND NOT ot.col_int_nokey < 2 +) +ORDER BY col_varchar_nokey; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 20 33.33 Using where; Using filesort +1 SIMPLE it NULL ref col_varchar_key col_varchar_key 6 test.ot.col_varchar_nokey 2 100.00 Start temporary; End temporary +Warnings: +Note 1276 Field or reference 'test.ot.col_int_nokey' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`ot`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t2` `ot` semi join (`test`.`t1` `it`) where ((`test`.`it`.`col_varchar_key` = `test`.`ot`.`col_varchar_nokey`) and (`test`.`ot`.`col_int_nokey` >= 2)) order by `test`.`ot`.`col_varchar_nokey` +SELECT col_varchar_nokey +FROM t2 AS ot +WHERE col_varchar_nokey IN ( +SELECT col_varchar_key +FROM t1 AS it +WHERE it.col_int_nokey <= it.col_int_nokey +AND NOT ot.col_int_nokey < 2 +) +ORDER BY col_varchar_nokey; +col_varchar_nokey +c +e +p +s +v +w +y +ALTER TABLE t1 ENGINE=Memory; +ALTER TABLE t2 ENGINE=Memory; +explain SELECT col_varchar_nokey +FROM t2 AS ot +WHERE col_varchar_nokey IN ( +SELECT col_varchar_key +FROM t1 AS it +WHERE it.col_int_nokey <= it.col_int_nokey +AND NOT ot.col_int_nokey < 2 +) +ORDER BY col_varchar_nokey; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 20 33.33 Using where; Using filesort +1 SIMPLE it NULL ref col_varchar_key col_varchar_key 6 test.ot.col_varchar_nokey 2 100.00 Start temporary; End temporary +Warnings: +Note 1276 Field or reference 'test.ot.col_int_nokey' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`ot`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t2` `ot` semi join (`test`.`t1` `it`) where ((`test`.`it`.`col_varchar_key` = `test`.`ot`.`col_varchar_nokey`) and (`test`.`ot`.`col_int_nokey` >= 2)) order by `test`.`ot`.`col_varchar_nokey` +SELECT col_varchar_nokey +FROM t2 AS ot +WHERE col_varchar_nokey IN ( +SELECT col_varchar_key +FROM t1 AS it +WHERE it.col_int_nokey <= it.col_int_nokey +AND NOT ot.col_int_nokey < 2 +) +ORDER BY col_varchar_nokey; +col_varchar_nokey +c +e +p +s +v +w +y +DROP TABLE t1, t2; +# End of test for bug#13576391. +# +# Bug #13589848 "MISSING ROW ON SELECT WITH NESTED IN CLAUSES WHEN LOOSESCAN=ON" +# +CREATE TABLE t1 ( +id INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +KEY (col_varchar_key) +) charset utf8mb4; +INSERT INTO t1 VALUES (100,'m','m'), +(200,'b','b'), (300,'x','x'); +CREATE TABLE t2 ( +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +KEY (col_varchar_key) +) charset utf8mb4; +INSERT INTO t2 VALUES ('b','b'); +CREATE TABLE t3 ( +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +KEY (col_varchar_key) +) charset utf8mb4; +INSERT INTO t3 VALUES ('k','k'); +EXPLAIN SELECT gp1.id +FROM t1 AS gp1 JOIN t3 AS gp2 +ON gp2.col_varchar_key <> gp1.col_varchar_nokey +WHERE (gp1.col_varchar_nokey, gp1.col_varchar_nokey) +IN ( +SELECT col_varchar_nokey, col_varchar_nokey +FROM t1 +WHERE col_varchar_nokey +IN ( SELECT col_varchar_key +FROM t2 LEFT JOIN t3 USING (col_varchar_key) ) +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE gp2 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL index col_varchar_key col_varchar_key 7 NULL 1 100.00 Using where; Using index; Start temporary +1 SIMPLE gp1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ref col_varchar_key col_varchar_key 7 test.t2.col_varchar_key 2 100.00 Using index; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`gp1`.`id` AS `id` from `test`.`t1` `gp1` semi join (`test`.`t1` join `test`.`t2` left join `test`.`t3` on((`test`.`t2`.`col_varchar_key` = `test`.`t3`.`col_varchar_key`))) where ((`test`.`gp1`.`col_varchar_nokey` = `test`.`t2`.`col_varchar_key`) and (`test`.`t1`.`col_varchar_nokey` = `test`.`t2`.`col_varchar_key`) and ('k' <> `test`.`t2`.`col_varchar_key`)) +SELECT gp1.id +FROM t1 AS gp1 JOIN t3 AS gp2 +ON gp2.col_varchar_key <> gp1.col_varchar_nokey +WHERE (gp1.col_varchar_nokey, gp1.col_varchar_nokey) +IN ( +SELECT col_varchar_nokey, col_varchar_nokey +FROM t1 +WHERE col_varchar_nokey +IN ( SELECT col_varchar_key +FROM t2 LEFT JOIN t3 USING (col_varchar_key) ) +) +; +id +200 +DROP TABLE t1,t2,t3; +# +# Bug #13596176: Missing row on select with nested in clause when +# matr=on and bnl=off + MyISAM +# +CREATE TABLE t1 ( +int_key int DEFAULT NULL, +vc_key varchar(1) DEFAULT NULL, +vc_nokey varchar(1) DEFAULT NULL, +KEY int_key (int_key), +KEY vc_key (vc_key, int_key) +) charset utf8mb4 ENGINE=MyISAM; +INSERT INTO t1 VALUES +(8,'x','x'), (7,'d','d'), (1,'r','r'), (7,'f','f'), +(9,'y','y'), (NULL,'u','u'), (1,'m','m'), (9,NULL,NULL), +(2,'o','o'), (9,'w','w'), (2,'m','m'), (4,'q','q'), +(0,NULL,NULL), (4,'d','d'), (8,'g','g'), (NULL,'x','x'), +(NULL,'f','f'), (0,'p','p'), (NULL,'j','j'), (8,'c','c'); +CREATE TABLE t2 ( +int_key int DEFAULT NULL, +vc_key varchar(1) DEFAULT NULL, +KEY int_key (int_key), +KEY vc_key (vc_key, int_key) +) charset utf8mb4 ENGINE=MyISAM; +INSERT INTO t2 VALUES (8,'g'); +explain SELECT vc_key +FROM t1 as outr +WHERE (vc_nokey, vc_key ) IN +(SELECT vc_nokey, vc_nokey +FROM t1 middle +WHERE vc_nokey IN +(SELECT child1.vc_key +FROM t2 AS child1 JOIN t1 AS child2 USING (int_key) +) +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE child1 NULL index int_key,vc_key vc_key 12 NULL 1 100.00 Using where; Using index; Start temporary +1 SIMPLE outr NULL ref vc_key vc_key 7 test.child1.vc_key 3 10.00 Using where +1 SIMPLE middle NULL ALL NULL NULL NULL NULL 20 10.00 Using where; Using join buffer (hash join) +1 SIMPLE child2 NULL ref int_key int_key 5 test.child1.int_key 3 100.00 Using index; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`outr`.`vc_key` AS `vc_key` from `test`.`t1` `outr` semi join (`test`.`t1` `middle` join `test`.`t2` `child1` join `test`.`t1` `child2`) where ((`test`.`child2`.`int_key` = `test`.`child1`.`int_key`) and (`test`.`outr`.`vc_nokey` = `test`.`child1`.`vc_key`) and (`test`.`outr`.`vc_key` = `test`.`child1`.`vc_key`) and (`test`.`middle`.`vc_nokey` = `test`.`child1`.`vc_key`)) +SELECT vc_key +FROM t1 as outr +WHERE (vc_nokey, vc_key ) IN +(SELECT vc_nokey, vc_nokey +FROM t1 middle +WHERE vc_nokey IN +(SELECT child1.vc_key +FROM t2 AS child1 JOIN t1 AS child2 USING (int_key) +) +); +vc_key +g +DROP TABLE t1, t2; +# End of test for bug#13596176. +# +# BUG#11754478: MAX/MIN + SUBQUERY + AND FAILS TO RETURN ANY ROWS +# BUG#13599013: MAX/MIN + SUBQUERY IN WHERE CLAUSE MATCHING NO +# ROWS + INDEX DOES NOT RETURN NULL +# +CREATE TABLE t1 ( +pk int(11) PRIMARY KEY, +int_key int(11), +KEY int_key (int_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (1,0),(2,0),(3,2),(4,0),(5,3),(6,0); +SELECT MIN(int_key) FROM t1 WHERE (4, 4) IN (SELECT 1, 2); +MIN(int_key) +NULL +SELECT MIN(int_key) FROM t1 WHERE (4, 4) IN (SELECT 4, 4); +MIN(int_key) +0 +SELECT MIN(pk) FROM t1 WHERE pk IN (SELECT int_key FROM t1) AND pk = 6; +MIN(pk) +NULL +DROP TABLE t1; +# BUG#13726217: Crash in Item_ident::fix_after_pullout() +CREATE TABLE t1(a INTEGER) engine=innodb; +INSERT INTO t1 VALUES (0); +SELECT 0 +FROM t1 +WHERE 0 IN +(SELECT 0 +FROM t1 +WHERE 0 LIKE +(SELECT elt(a, 0) AS b +FROM t1 +GROUP BY a +HAVING b +) +); +0 +DROP TABLE t1; +# End of test for bug#13726217. +# BUG#13773979: Missing rows on second execution of prepared statement +CREATE TABLE t1 ( +col_int_nokey INT, +col_int_key INT, +col_varchar_key VARCHAR(1) +); +INSERT INTO t1 VALUES +(1,7,'v'), (7,0,'s'), (4,9,'l'), (7,3,'y'), +(2,2,'i'), (9,5,'h'), (0,1,'a'), (9,3,'v'); +CREATE VIEW v1 AS SELECT * FROM t1; +SELECT * +FROM t1 +WHERE col_int_key IN ( +SELECT alias1.col_int_nokey AS field1 +FROM v1 AS alias1 +WHERE alias1.col_varchar_key < 'v' +); +col_int_nokey col_int_key col_varchar_key +1 7 v +2 2 i +4 9 l +7 0 s +prepare stmt FROM "SELECT * +FROM t1 +WHERE col_int_key IN ( +SELECT alias1.col_int_nokey AS field1 +FROM v1 AS alias1 +WHERE alias1.col_varchar_key < 'v' +)"; +execute stmt; +col_int_nokey col_int_key col_varchar_key +1 7 v +2 2 i +4 9 l +7 0 s +execute stmt; +col_int_nokey col_int_key col_varchar_key +1 7 v +2 2 i +4 9 l +7 0 s +DEALLOCATE PREPARE stmt; +DROP VIEW v1; +DROP TABLE t1; +# End of test for bug#13773979. +# +# BUG#13685026 ASSERTION CUR_SJ_INNER_TABLES == 0 IN +# --OPTIMIZE_TABLE_ORDER::CHOOSE_TABLE_ORDER +# +CREATE TABLE t1 ( +col_int_key INT(11) NOT NULL, +col_datetime_key DATETIME NOT NULL, +col_varchar_key VARCHAR(1) NOT NULL, +col_varchar_nokey VARCHAR(1) NOT NULL, +KEY col_int_key (col_int_key), +KEY col_datetime_key (col_datetime_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (0,'2002-02-13 17:30:06','j','j'); +INSERT INTO t1 VALUES (8,'2008-09-27 00:34:58','v','v'); +CREATE TABLE t2 ( +col_int_key INT(11) NOT NULL, +col_datetime_key DATETIME NOT NULL, +col_varchar_key VARCHAR(1) NOT NULL, +col_varchar_nokey VARCHAR(1) NOT NULL, +KEY col_int_key (col_int_key), +KEY col_datetime_key (col_datetime_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (7,'2003-08-21 00:00:00','b','b'); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +SET @old_depth=@@optimizer_search_depth; +SET optimizer_search_depth=4; +EXPLAIN SELECT col_datetime_key +FROM t1 as outr +WHERE col_datetime_key IN ( +SELECT alias1.col_datetime_key +FROM t1 AS alias1 +LEFT JOIN t1 as alias3 +STRAIGHT_JOIN ( t2 AS alias4 +JOIN t1 AS alias5 +ON alias5.col_varchar_key <= alias4.col_varchar_nokey ) +ON alias5.col_int_key < alias4.col_int_key +ON alias5.col_varchar_key = alias4.col_varchar_key +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE outr NULL index col_datetime_key col_datetime_key 5 NULL 2 100.00 Using index +1 SIMPLE alias1 NULL ref col_datetime_key col_datetime_key 5 test.outr.col_datetime_key 1 100.00 Using index; Start temporary +1 SIMPLE alias4 NULL ALL col_int_key,col_varchar_key NULL NULL NULL 1 100.00 NULL +1 SIMPLE alias5 NULL ref col_int_key,col_varchar_key col_varchar_key 6 test.alias4.col_varchar_key 1 100.00 Using where; Using index +1 SIMPLE alias3 NULL index NULL col_int_key 4 NULL 2 100.00 Using index; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`outr`.`col_datetime_key` AS `col_datetime_key` from `test`.`t1` `outr` semi join (`test`.`t1` `alias1` left join (`test`.`t1` `alias3` join `test`.`t2` `alias4` join `test`.`t1` `alias5`) on(((`test`.`alias5`.`col_varchar_key` = `test`.`alias4`.`col_varchar_key`) and (`test`.`alias5`.`col_int_key` < `test`.`alias4`.`col_int_key`) and (`test`.`alias5`.`col_varchar_key` <= `test`.`alias4`.`col_varchar_nokey`)))) where (`test`.`alias1`.`col_datetime_key` = `test`.`outr`.`col_datetime_key`) +SELECT col_datetime_key +FROM t1 as outr +WHERE col_datetime_key IN ( +SELECT alias1.col_datetime_key +FROM t1 AS alias1 +LEFT JOIN t1 as alias3 +STRAIGHT_JOIN ( t2 AS alias4 +JOIN t1 AS alias5 +ON alias5.col_varchar_key <= alias4.col_varchar_nokey ) +ON alias5.col_int_key < alias4.col_int_key +ON alias5.col_varchar_key = alias4.col_varchar_key +); +col_datetime_key +2002-02-13 17:30:06 +2008-09-27 00:34:58 +DROP TABLE t1,t2; +SET @@optimizer_search_depth=@old_depth; +# +# BUG#13848789: SEGFAULT IN JOIN_READ_NEXT_SAME AT +# SQL/SQL_EXECUTOR.CC ON HAVING...IN...JOIN +# +CREATE TABLE t1 ( +col_int_key INT, +col_varchar_key VARCHAR(1), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4; +INSERT INTO t1 VALUES (8,'x'); +CREATE TABLE t2 ( +col_varchar_key VARCHAR(1), +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4; +INSERT INTO t2 VALUES ('x'), ('y'); +explain SELECT MIN(col_int_key) +FROM t1 as t1_outer +HAVING (1, 2) IN ( +SELECT t1_inner.col_int_key, MAX(t1_inner.col_int_key) +FROM t1 as t1_inner JOIN t2 +ON t2.col_varchar_key = t1_inner.col_varchar_key +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible HAVING +2 SUBQUERY t1_inner NULL system col_varchar_key NULL NULL NULL 1 100.00 NULL +2 SUBQUERY t2 NULL ref col_varchar_key col_varchar_key 7 const 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select min(`test`.`t1_outer`.`col_int_key`) AS `MIN(col_int_key)` from `test`.`t1` `t1_outer` having false +SELECT MIN(col_int_key) +FROM t1 as t1_outer +HAVING (1, 2) IN ( +SELECT t1_inner.col_int_key, MAX(t1_inner.col_int_key) +FROM t1 as t1_inner JOIN t2 +ON t2.col_varchar_key = t1_inner.col_varchar_key +); +MIN(col_int_key) +DROP TABLE t1,t2; +# Bug#13838810: Segfault in evaluate_null_complemented_join_record +CREATE TABLE t1 ( +pk int NOT NULL, +col_int_nokey int DEFAULT NULL, +col_int_key int DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t1 VALUES (10,NULL,8,'x'); +CREATE TABLE t2 ( +pk int NOT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +PRIMARY KEY (pk) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t2 VALUES (1,'x'); +CREATE TABLE t3 ( +pk int NOT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +PRIMARY KEY (pk), +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t3 VALUES +(1,'v','v'), (2,'v','v'), (3,'c','c'), (4,NULL,NULL); +EXPLAIN SELECT table1.pk,table2.pk, table3.pk +FROM t2 AS table1 +LEFT JOIN t1 AS table2 +LEFT JOIN t1 AS table3 +ON table3.col_int_key = table2.col_int_key +ON table3.pk = table2.col_int_nokey AND +table1.col_varchar_nokey IN ( +SELECT subquery3_t1.col_varchar_nokey +FROM t3 AS subquery3_t1 +LEFT JOIN t1 AS subquery3_t2 +ON subquery3_t2.col_varchar_key = subquery3_t1.col_varchar_key +WHERE subquery3_t2.col_int_nokey <> 9 +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE table1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE table2 NULL ALL col_int_key NULL NULL NULL 1 100.00 NULL +2 SIMPLE table3 NULL eq_ref PRIMARY,col_int_key PRIMARY 4 test.table2.col_int_nokey 1 100.00 Using where +2 SIMPLE subquery3_t2 NULL ALL col_varchar_key NULL NULL NULL 1 100.00 Using where; Start temporary +2 SIMPLE subquery3_t1 NULL ref col_varchar_key col_varchar_key 7 test.subquery3_t2.col_varchar_key 1 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`table1`.`pk` AS `pk`,`test`.`table2`.`pk` AS `pk`,`test`.`table3`.`pk` AS `pk` from `test`.`t2` `table1` left join (`test`.`t1` `table2` join `test`.`t1` `table3` semi join (`test`.`t3` `subquery3_t1` join `test`.`t1` `subquery3_t2`)) on(((`test`.`table3`.`col_int_key` = `test`.`table2`.`col_int_key`) and (`test`.`subquery3_t1`.`col_varchar_key` = `test`.`subquery3_t2`.`col_varchar_key`) and (`test`.`subquery3_t1`.`col_varchar_nokey` = `test`.`table1`.`col_varchar_nokey`) and (`test`.`table3`.`pk` = `test`.`table2`.`col_int_nokey`) and (`test`.`subquery3_t2`.`col_int_nokey` <> 9))) where true +SELECT table1.pk,table2.pk, table3.pk +FROM t2 AS table1 +LEFT JOIN t1 AS table2 +LEFT JOIN t1 AS table3 +ON table3.col_int_key = table2.col_int_key +ON table3.pk = table2.col_int_nokey AND +table1.col_varchar_nokey IN ( +SELECT subquery3_t1.col_varchar_nokey +FROM t3 AS subquery3_t1 +LEFT JOIN t1 AS subquery3_t2 +ON subquery3_t2.col_varchar_key = subquery3_t1.col_varchar_key +WHERE subquery3_t2.col_int_nokey <> 9 +) +; +pk pk pk +1 NULL NULL +DROP TABLE t1, t2, t3; +Extra test case for specific code coverage +CREATE TABLE t1(pk INTEGER); +INSERT INTO t1 VALUES(1), (2); +explain SELECT * +FROM t1 AS ot1 LEFT JOIN t1 AS ot2 +ON ot1.pk=ot2.pk AND +ot2.pk IN +(SELECT it1.pk +FROM t1 AS it1 LEFT JOIN t1 AS it2 ON it1.pk=it2.pk); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +1 SIMPLE it1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +1 SIMPLE it2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`pk` AS `pk`,`test`.`ot2`.`pk` AS `pk` from `test`.`t1` `ot1` left join (`test`.`t1` `ot2` semi join (`test`.`t1` `it1` left join `test`.`t1` `it2` on((`test`.`it1`.`pk` = `test`.`it2`.`pk`)))) on(((`test`.`ot2`.`pk` = `test`.`ot1`.`pk`) and (`test`.`it1`.`pk` = `test`.`ot1`.`pk`))) where true +SELECT * +FROM t1 AS ot1 LEFT JOIN t1 AS ot2 +ON ot1.pk=ot2.pk AND +ot2.pk IN +(SELECT it1.pk +FROM t1 AS it1 LEFT JOIN t1 AS it2 ON it1.pk=it2.pk); +pk pk +1 1 +2 2 +DROP TABLE t1; +# End of test for bug#13838810. +# +# Bug#13845930: Segfault in st_join_table::and_with_condition +# +CREATE TABLE t1 ( +col_int INTEGER +); +CREATE TABLE t2 ( +col_varchar_1 VARCHAR(1), +col_varchar_2 VARCHAR(1) +); +INSERT INTO t2 VALUES ('x','x'), ('c','c'); +PREPARE stmt FROM ' +SELECT alias2.col_varchar_2 AS field1 +FROM t2 AS alias1 + JOIN + (t2 AS alias2 + LEFT JOIN t2 AS alias3 + ON (8, 92) IN + (SELECT sq1_alias1.col_int, + sq1_alias2.col_int + FROM t1 AS sq1_alias1 JOIN t1 AS sq1_alias2 + ) + ) + ON alias3.col_varchar_1 = alias2.col_varchar_2 +'; +EXECUTE stmt; +field1 + +EXECUTE stmt; +field1 +DEALLOCATE prepare stmt; +DROP TABLE t1, t2; +# End of test for bug#13845930. +# +# Bug#13855925: Assert 'prebuilt->search_tuple->n_fields > 0' +# in ha_innobase::index_read +# +CREATE TABLE t1 ( +pk INTEGER AUTO_INCREMENT, +col_int_nokey INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk), +KEY (col_varchar_key) +) charset utf8mb4 ENGINE=INNODB; +INSERT INTO t1 ( +col_int_key, col_int_nokey, +col_varchar_key, col_varchar_nokey +) VALUES +(4, 2, 'v','v'), (62, 150, 'v','v'), (7, NULL, 'c','c'), (1, 2, NULL, NULL), +(0, 5, 'x','x'), (7, 3, 'i','i'), (7, 1, 'e','e'), (1, 4, 'p','p'), +(7, NULL, 's','s'), (1, 2, 'j','j'), (5, 6, 'z','z'), (2, 6, 'c','c'), +(0, 8, 'a','a'), (1, 2, 'q','q'), (8, 6, 'y','y'), (1, 8, NULL, NULL), +(1, 3, 'r','r'), (9, 3, 'v','v'), (1, 9, NULL, NULL), (5, 6, 'r','r'); +CREATE TABLE t2 ( +pk INT AUTO_INCREMENT, +col_int_nokey INT, +col_int_key INT, +PRIMARY KEY (pk), +KEY (col_int_key) +) charset utf8mb4 AUTO_INCREMENT=10 ENGINE=INNODB; +INSERT INTO t2 (col_int_key, col_int_nokey) VALUES +(8, NULL), (7, 8), (1, 1), (7, 9), (9, 4), (NULL, 3), (1, 2), (9, NULL), +(2, 2), (9, NULL), (2, 6), (4, 7), (0, 2), (4, 5), (8, 7), (NULL, 6), +(NULL, 6), (0, 2), (NULL, 9), (8, 6); +CREATE TABLE t3 ( +pk INT AUTO_INCREMENT, +col_varchar_key VARCHAR(1), +PRIMARY KEY (pk), +KEY (col_varchar_key) +) charset utf8mb4 ENGINE=INNODB; +INSERT INTO t3 (col_varchar_key) VALUES +('c'), ('c'), ('q'), ('g'), ('e'), ('l'), (NULL), ('c'), ('h'), ('d'), +('c'), ('i'), ('t'), ('g'), ('q'), ('l'), ('n'), ('z'), ('n'), ('r'), ('p'); +CREATE VIEW v1 AS +SELECT table2.col_varchar_nokey AS field1 +FROM t2 AS table1 +INNER JOIN (t1 AS table2 +STRAIGHT_JOIN t2 AS table3 +ON table3.col_int_key = table2.pk AND +table3.col_int_nokey = ANY +(SELECT subquery1_t2.col_int_nokey AS subquery1_field1 +FROM t2 AS subquery1_t1 +RIGHT OUTER JOIN t1 AS subquery1_t2 +INNER JOIN t1 AS subquery1_t3 +ON subquery1_t3.col_int_key = subquery1_t2.pk +ON subquery1_t3.col_varchar_key=subquery1_t2.col_varchar_nokey +WHERE subquery1_t1.pk > 1 +) +) +ON table3.col_int_key IN +(SELECT subquery2_t1.col_int_key AS subquery2_field1 +FROM t2 AS subquery2_t1 +RIGHT OUTER JOIN t3 AS subquery2_t2 +LEFT OUTER JOIN t1 AS subquery2_t3 +ON subquery2_t3.col_varchar_key = subquery2_t2.col_varchar_key +ON subquery2_t3.pk = subquery2_t2.pk +) +; +explain SELECT * FROM v1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE subquery2_t3 NULL index PRIMARY,col_varchar_key col_varchar_key 7 NULL 20 100.00 Using where; Using index; Start temporary +1 SIMPLE subquery2_t2 NULL eq_ref PRIMARY,col_varchar_key PRIMARY 4 test.subquery2_t3.pk 1 7.14 Using where +1 SIMPLE subquery1_t3 NULL ALL col_varchar_key NULL NULL NULL 20 100.00 Using where; Using join buffer (hash join) +1 SIMPLE subquery1_t2 NULL eq_ref PRIMARY PRIMARY 4 test.subquery1_t3.col_int_key 1 10.00 Using where +1 SIMPLE subquery2_t1 NULL range col_int_key col_int_key 5 NULL 16 100.00 Using where; Using index; Using join buffer (hash join) +1 SIMPLE table2 NULL eq_ref PRIMARY PRIMARY 4 test.subquery2_t1.col_int_key 1 100.00 NULL +1 SIMPLE table3 NULL ref col_int_key col_int_key 5 test.subquery2_t1.col_int_key 2 10.00 Using where +1 SIMPLE subquery1_t1 NULL index PRIMARY col_int_key 5 NULL 20 100.00 Using where; Using index; End temporary; Using join buffer (hash join) +1 SIMPLE table1 NULL index NULL col_int_key 5 NULL 20 100.00 Using index; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `table2`.`col_varchar_nokey` AS `field1` from `test`.`t2` `table1` join `test`.`t1` `table2` straight_join `test`.`t2` `table3` semi join (`test`.`t1` `subquery1_t2` join `test`.`t1` `subquery1_t3` join `test`.`t2` `subquery1_t1`) semi join (`test`.`t3` `subquery2_t2` join `test`.`t1` `subquery2_t3` join `test`.`t2` `subquery2_t1`) where ((`subquery1_t2`.`pk` = `subquery1_t3`.`col_int_key`) and (`subquery1_t2`.`col_varchar_nokey` = `subquery1_t3`.`col_varchar_key`) and (`subquery2_t2`.`col_varchar_key` = `subquery2_t3`.`col_varchar_key`) and (`subquery2_t2`.`pk` = `subquery2_t3`.`pk`) and (`table2`.`pk` = `subquery2_t1`.`col_int_key`) and (`table3`.`col_int_key` = `subquery2_t1`.`col_int_key`) and (`table3`.`col_int_nokey` = `subquery1_t2`.`col_int_nokey`) and (`subquery1_t1`.`pk` > 1)) +SELECT * FROM v1; +field1 +v +v +v +v +v +v +v +v +v +v +v +v +v +v +v +v +v +v +v +v +DROP VIEW v1; +DROP TABLE t1,t2,t3; +# End of test for bug#13855925. +# +# Bug#13897959: Segfault in setup_semijoin_dups_elimination() +# +CREATE TABLE t1 ( +col_datetime_key DATETIME DEFAULT NULL, +KEY col_datetime_key (col_datetime_key) +) ENGINE=MyISAM; +INSERT INTO t1 VALUES +('2001-04-18 00:00:00'), ('2008-12-18 19:39:55'), +('2000-08-01 12:19:39'), ('2004-09-25 21:29:06'), +('2009-09-20 09:11:48'), ('2004-03-27 09:32:04'); +CREATE TABLE t2 ( +col_date_nokey date DEFAULT NULL, +col_time_key time DEFAULT NULL, +col_datetime_key datetime DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +KEY col_time_key (col_time_key), +KEY col_datetime_key (col_datetime_key), +KEY col_varchar_key(col_varchar_key) +) ENGINE=MyISAM; +INSERT INTO t2 VALUES ('1900-01-01',NULL,'2001-11-04 19:07:55','x','x'); +SELECT grandparent1.col_varchar_nokey +FROM t2 AS grandparent1 LEFT JOIN t1 USING (col_datetime_key) +WHERE grandparent1.col_varchar_nokey IN ( +SELECT col_varchar_nokey +FROM t2 AS parent1 +WHERE parent1.col_time_key > grandparent1.col_date_nokey +); +col_varchar_nokey +DROP TABLE t1, t2; +# End of test for bug#13897959. +# +# Bug#13898625 ASSERT `(REMAINING_TABLES_AFTER != 0) ...' IN +# BEST_EXTENSION_BY_LIMITED_SEARCH +# +CREATE TABLE t1 ( +pk int(11) NOT NULL, +col_int_nokey INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (26,6,NULL,'f','f'); +INSERT INTO t1 VALUES (29,6,8,'c','c'); +CREATE TABLE t2 ( +pk INT NOT NULL, +col_int_nokey INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +INSERT INTO t2 VALUES (1,2,4,'v','v'); +INSERT INTO t2 VALUES (2,150,62,'v','v'); +INSERT INTO t2 VALUES (5,5,0,'x','x'); +INSERT INTO t2 VALUES (6,3,7,'i','i'); +INSERT INTO t2 VALUES (7,1,7,'e','e'); +CREATE VIEW view_c AS SELECT * FROM t2; +PREPARE prep_stmt_7430 FROM 'SELECT SUM( alias1.col_varchar_key ) AS field1 +FROM t1 AS alias1 +RIGHT JOIN t2 AS alias2 +INNER JOIN t1 AS alias3 +ON (alias3.col_varchar_key = alias2.col_varchar_key ) +ON ( "v" ) IN ( +SELECT sq1_alias1.col_varchar_nokey AS sq1_field1 +FROM t1 AS sq1_alias1 +) +WHERE alias3.pk IN ( +SELECT sq2_alias1.col_int_key AS sq2_field1 +FROM ( view_c AS sq2_alias1, t1 AS sq2_alias2 ) +) +'; +EXECUTE prep_stmt_7430; +field1 +NULL +EXECUTE prep_stmt_7430; +field1 +NULL +EXPLAIN SELECT SUM( alias1.col_varchar_key ) AS field1 +FROM t1 AS alias1 +RIGHT JOIN t2 AS alias2 +INNER JOIN t1 AS alias3 +ON (alias3.col_varchar_key = alias2.col_varchar_key ) +ON ( "v" ) IN ( +SELECT sq1_alias1.col_varchar_nokey AS sq1_field1 +FROM t1 AS sq1_alias1 +) +WHERE alias3.pk IN ( +SELECT sq2_alias1.col_int_key AS sq2_field1 +FROM ( view_c AS sq2_alias1, t1 AS sq2_alias2 ) +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE alias3 NULL ALL PRIMARY,col_varchar_key NULL NULL NULL 2 100.00 Using where; Start temporary +1 SIMPLE alias2 NULL ref col_varchar_key col_varchar_key 7 test.alias3.col_varchar_key 2 100.00 Using index +1 SIMPLE t2 NULL ref col_int_key col_int_key 5 test.alias3.pk 2 100.00 Using index +1 SIMPLE sq2_alias2 NULL index NULL PRIMARY 4 NULL 2 100.00 Using index; Using join buffer (hash join) +1 SIMPLE sq1_alias1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +1 SIMPLE alias1 NULL index NULL col_varchar_key 12 NULL 2 100.00 Using index; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select sum(`test`.`alias1`.`col_varchar_key`) AS `field1` from `test`.`t2` `alias2` join `test`.`t1` `alias3` left join (`test`.`t1` `alias1` semi join (`test`.`t1` `sq1_alias1`)) on(((`test`.`sq1_alias1`.`col_varchar_nokey` = 'v'))) semi join (`test`.`t2` join `test`.`t1` `sq2_alias2`) where ((`test`.`alias2`.`col_varchar_key` = `test`.`alias3`.`col_varchar_key`) and (`test`.`t2`.`col_int_key` = `test`.`alias3`.`pk`)) +PREPARE prep_stmt_7430 FROM 'SELECT SUM( alias1.col_varchar_key ) AS field1 +FROM t1 AS alias1 +RIGHT JOIN t2 AS alias2 +INNER JOIN t1 AS alias3 +ON (alias3.col_varchar_key = alias2.col_varchar_key ) +ON ( "v" ) IN ( +SELECT sq1_alias1.col_varchar_nokey AS sq1_field1 +FROM t1 AS sq1_alias1 +) +WHERE alias3.pk IN ( +SELECT sq2_alias1.col_int_key AS sq2_field1 +FROM ( view_c AS sq2_alias1 , t1 AS sq2_alias2 ) +WHERE sq2_alias1.col_varchar_nokey <> alias2.col_varchar_key +AND sq2_alias1.col_varchar_key < "l" + ) +'; +EXECUTE prep_stmt_7430; +field1 +NULL +EXECUTE prep_stmt_7430; +field1 +NULL +EXPLAIN SELECT SUM( alias1.col_varchar_key ) AS field1 +FROM t1 AS alias1 +RIGHT JOIN t2 AS alias2 +INNER JOIN t1 AS alias3 +ON (alias3.col_varchar_key = alias2.col_varchar_key ) +ON ( "v" ) IN ( +SELECT sq1_alias1.col_varchar_nokey AS sq1_field1 +FROM t1 AS sq1_alias1 +) +WHERE alias3.pk IN ( +SELECT sq2_alias1.col_int_key AS sq2_field1 +FROM ( view_c AS sq2_alias1 , t1 AS sq2_alias2 ) +WHERE sq2_alias1.col_varchar_nokey <> alias2.col_varchar_key +AND sq2_alias1.col_varchar_key < "l" + ) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE alias3 NULL ALL PRIMARY,col_varchar_key NULL NULL NULL 2 100.00 Using where; Start temporary +1 SIMPLE t2 NULL ref col_int_key,col_varchar_key col_int_key 5 test.alias3.pk 2 40.00 Using where +1 SIMPLE alias2 NULL ref col_varchar_key col_varchar_key 7 test.alias3.col_varchar_key 2 100.00 Using index +1 SIMPLE sq2_alias2 NULL index NULL PRIMARY 4 NULL 2 100.00 Using index; Using join buffer (hash join) +1 SIMPLE sq1_alias1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +1 SIMPLE alias1 NULL index NULL col_varchar_key 12 NULL 2 100.00 Using index; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.alias2.col_varchar_key' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select sum(`test`.`alias1`.`col_varchar_key`) AS `field1` from `test`.`t2` `alias2` join `test`.`t1` `alias3` left join (`test`.`t1` `alias1` semi join (`test`.`t1` `sq1_alias1`)) on(((`test`.`sq1_alias1`.`col_varchar_nokey` = 'v'))) semi join (`test`.`t2` join `test`.`t1` `sq2_alias2`) where ((`test`.`alias2`.`col_varchar_key` = `test`.`alias3`.`col_varchar_key`) and (`test`.`t2`.`col_int_key` = `test`.`alias3`.`pk`) and (`test`.`t2`.`col_varchar_nokey` <> `test`.`alias3`.`col_varchar_key`) and (`test`.`t2`.`col_varchar_key` < 'l')) +DROP TABLE t1,t2; +DROP VIEW view_c; +# +# Bug#13902463 SEGFAULT IN BITMAP<64U>::MERGE OR ADD_KEY_FIELD +# ON SECOND EXEC OF PREP STMT +# +CREATE TABLE t1 ( +pk INT, +col_int_nokey INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +KEY col_varchar_key (col_varchar_key) +); +CREATE VIEW view_b AS SELECT * FROM t1; +PREPARE prep_stmt_20421 FROM 'SELECT alias2.col_varchar_nokey AS field1 +FROM t1 AS alias1 +INNER JOIN t1 AS alias2 +ON (alias1.col_varchar_key = alias2.col_varchar_nokey +AND ( alias1.col_int_key ) IN ( +SELECT t1.col_int_nokey +FROM t1 +) +) +WHERE alias1.col_varchar_key IN ( +SELECT sq2_alias2.col_varchar_nokey AS sq2_field1 +FROM view_b AS sq2_alias1 +INNER JOIN t1 AS sq2_alias2 +ON (sq2_alias2.col_varchar_key = sq2_alias1.col_varchar_key ) +WHERE sq2_alias1.pk > alias2.pk +) +'; +EXECUTE prep_stmt_20421; +field1 +EXECUTE prep_stmt_20421; +field1 +EXPLAIN SELECT alias2.col_varchar_nokey AS field1 +FROM t1 AS alias1 +INNER JOIN t1 AS alias2 +ON (alias1.col_varchar_key = alias2.col_varchar_nokey +AND ( alias1.col_int_key ) IN ( +SELECT t1.col_int_nokey +FROM t1 +) +) +WHERE alias1.col_varchar_key IN ( +SELECT sq2_alias2.col_varchar_nokey AS sq2_field1 +FROM view_b AS sq2_alias1 +INNER JOIN t1 AS sq2_alias2 +ON (sq2_alias2.col_varchar_key = sq2_alias1.col_varchar_key ) +WHERE sq2_alias1.pk > alias2.pk +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.alias2.pk' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `field1` from `test`.`t1` `alias1` join `test`.`t1` `alias2` semi join (`test`.`t1`) semi join (`test`.`t1` join `test`.`t1` `sq2_alias2`) where ((`test`.`t1`.`pk` > NULL) and multiple equal(NULL, `test`.`sq2_alias2`.`col_varchar_nokey`, NULL) and multiple equal(`test`.`sq2_alias2`.`col_varchar_key`, `test`.`t1`.`col_varchar_key`) and multiple equal(NULL, `test`.`t1`.`col_int_nokey`)) +ALTER TABLE t1 DROP INDEX col_varchar_key; +PREPARE prep_stmt_20421 FROM 'SELECT alias2.col_varchar_nokey AS field1 +FROM t1 AS alias1 +INNER JOIN t1 AS alias2 +ON (alias1.col_varchar_key = alias2.col_varchar_nokey +AND ( alias1.col_int_key ) IN ( +SELECT t1.col_int_nokey +FROM t1 +) +) +WHERE alias1.col_varchar_key IN ( +SELECT sq2_alias2.col_varchar_nokey AS sq2_field1 +FROM view_b AS sq2_alias1 +INNER JOIN t1 AS sq2_alias2 +ON (sq2_alias2.col_varchar_key = sq2_alias1.col_varchar_key ) +WHERE sq2_alias1.pk > alias2.pk +) +'; +EXECUTE prep_stmt_20421; +field1 +EXECUTE prep_stmt_20421; +field1 +EXPLAIN SELECT alias2.col_varchar_nokey AS field1 +FROM t1 AS alias1 +INNER JOIN t1 AS alias2 +ON (alias1.col_varchar_key = alias2.col_varchar_nokey +AND ( alias1.col_int_key ) IN ( +SELECT t1.col_int_nokey +FROM t1 +) +) +WHERE alias1.col_varchar_key IN ( +SELECT sq2_alias2.col_varchar_nokey AS sq2_field1 +FROM view_b AS sq2_alias1 +INNER JOIN t1 AS sq2_alias2 +ON (sq2_alias2.col_varchar_key = sq2_alias1.col_varchar_key ) +WHERE sq2_alias1.pk > alias2.pk +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.alias2.pk' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `field1` from `test`.`t1` `alias1` join `test`.`t1` `alias2` semi join (`test`.`t1`) semi join (`test`.`t1` join `test`.`t1` `sq2_alias2`) where ((`test`.`t1`.`pk` > NULL) and multiple equal(NULL, `test`.`sq2_alias2`.`col_varchar_nokey`, NULL) and multiple equal(`test`.`sq2_alias2`.`col_varchar_key`, `test`.`t1`.`col_varchar_key`) and multiple equal(NULL, `test`.`t1`.`col_int_nokey`)) +DROP TABLE t1; +DROP VIEW view_b; +# +# Bug#13907277: Segfault in evaluate_null_complemented_join_record +# +CREATE TABLE t1 ( +pk INTEGER, +col_varchar_nokey VARCHAR(1), +col_varchar_key VARCHAR(1), +PRIMARY KEY (pk) +); +INSERT INTO t1 VALUES (1, 'x', 'x'); +CREATE TABLE t2 ( +pk INTEGER, +PRIMARY KEY (pk) +); +INSERT INTO t2 VALUES (1); +CREATE TABLE t3 ( +pk INTEGER, +col_int_nokey INTEGER, +col_int_key INTEGER, +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk) +); +INSERT INTO t3 VALUES (1, 6, 5, 'r'); +explain SELECT outer_t1.pk, outer_t2.pk +FROM t3 AS outer_t1 +RIGHT JOIN t2 AS outer_t2 +ON outer_t1.col_int_nokey IN +(SELECT inner_t1.col_int_nokey +FROM t3 AS inner_t1 +LEFT JOIN t1 AS inner_t2 +INNER JOIN t1 AS inner_t3 +ON inner_t3.pk = inner_t2.pk +ON inner_t3.col_varchar_nokey = inner_t2.col_varchar_key +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE outer_t2 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE outer_t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE inner_t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE inner_t2 NULL ALL PRIMARY NULL NULL NULL 1 100.00 NULL +1 SIMPLE inner_t3 NULL eq_ref PRIMARY PRIMARY 4 test.inner_t2.pk 1 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`outer_t1`.`pk` AS `pk`,'1' AS `pk` from left join (`test`.`t3` `outer_t1` semi join (`test`.`t3` `inner_t1` left join (`test`.`t1` `inner_t2` join `test`.`t1` `inner_t3`) on(((`test`.`inner_t3`.`col_varchar_nokey` = `test`.`inner_t2`.`col_varchar_key`) and (`test`.`inner_t3`.`pk` = `test`.`inner_t2`.`pk`))))) on(((`test`.`inner_t1`.`col_int_nokey` = `test`.`outer_t1`.`col_int_nokey`))) where true +SELECT outer_t1.pk, outer_t2.pk +FROM t3 AS outer_t1 +RIGHT JOIN t2 AS outer_t2 +ON outer_t1.col_int_nokey IN +(SELECT inner_t1.col_int_nokey +FROM t3 AS inner_t1 +LEFT JOIN t1 AS inner_t2 +INNER JOIN t1 AS inner_t3 +ON inner_t3.pk = inner_t2.pk +ON inner_t3.col_varchar_nokey = inner_t2.col_varchar_key +); +pk pk +1 1 +DROP TABLE t1, t2, t3; +# End of test for bug#13907277. +# +# Bug#13955713: Assert 'JOIN->best_read < ...' on second execution +# +CREATE TABLE t1 ( +pk INTEGER, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1) +); +PREPARE stmt FROM " +SELECT MIN(alias2.col_varchar_key) AS field1 +FROM t1 AS alias1 + INNER JOIN (t1 AS alias2 + INNER JOIN t1 AS alias3 + ON 8 IN + (SELECT sq1_alias1.pk AS sq1_field2 + FROM t1 AS sq1_alias1 + WHERE 9 IN + (SELECT SUM(t1_sq1_alias1.pk) AS t1_sq1_field2 + FROM t1 AS t1_sq1_alias1 + ) + ) + ) + ON alias3.col_varchar_nokey = alias2.col_varchar_key +WHERE EXISTS + (SELECT sq2_alias1.pk AS sq2_field1 + FROM t1 AS sq2_alias1 + WHERE sq2_alias1.col_varchar_key < alias1.col_varchar_nokey + ) +"; +EXECUTE stmt; +field1 +NULL + +EXECUTE stmt; +field1 +NULL +DEALLOCATE PREPARE stmt; +DROP TABLE t1; +# End of test for bug#13955713. +# +# Bug#13956813: Segfault in memcpy from Join_cache::write_record_data() +# +CREATE TABLE t1 ( +pk INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1) +) charset latin1; +CREATE TABLE t2 ( +pk INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1) +) charset latin1; +INSERT INTO t2 VALUES +(10,'j','j'), (11,'z','z'), (12,'c','c'), (13,'a','a'), +(14,'q','q'), (15,'y','y'), (16,NULL,NULL), (17,'r','r'), +(18,'v','v'), (19,NULL,NULL), (20,'r','r'); +CREATE TABLE t3 ( +pk INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +KEY col_int_key (col_int_key) +) charset latin1; +INSERT INTO t3 VALUES +(15,NULL,'u'), (16,1,'m'), (17,9,NULL), (18,2,'o'), +(19,9,'w'), (20,2,'m'), (21,4,'q'), (22,0,NULL), +(23,4,'d'), (24,8,'g'), (25,NULL,'x'), (26,NULL,'f'), +(27,0,'p'), (28,NULL,'j'), (29,8,'c'); +CREATE VIEW view_inline_0 AS +SELECT t1.* +FROM t1 INNER JOIN t3 +ON t1.pk = t3.pk; +CREATE VIEW view_inline_1 AS +SELECT sq2_alias2.col_varchar_key AS sq2_field1, +sq2_alias1.col_varchar_key AS sq2_field2 +FROM t3 AS sq2_alias1 LEFT OUTER JOIN t3 AS sq2_alias2 +ON sq2_alias1.pk = sq2_alias2.col_int_key; +CREATE VIEW view_inline_2 AS +SELECT 'p', 'p' UNION SELECT 'k', 's'; +SET @optimizer_switch_saved= @@optimizer_switch; +SET @@optimizer_switch="derived_merge=off"; +explain SELECT SUM(alias1.col_varchar_nokey) AS field2 +FROM t2 AS alias2 +LEFT JOIN (SELECT * FROM view_inline_0) AS alias1 +ON alias2.col_varchar_key = alias1.col_varchar_key AND +(alias2.col_varchar_nokey, alias2.col_varchar_key) IN +(SELECT * FROM view_inline_1 +) +WHERE (alias1.col_varchar_key, alias1.col_varchar_nokey) IN +(SELECT * FROM view_inline_2 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL 2 100.00 NULL +1 PRIMARY alias2 NULL ALL NULL NULL NULL NULL 11 10.00 Using where; Using join buffer (hash join) +1 PRIMARY NULL ref 8 test.alias2.col_varchar_nokey,test.view_inline_2.p 3 100.00 Using index; Start temporary; End temporary +1 PRIMARY NULL ref 8 test.view_inline_2.p,test.view_inline_2.Name_exp_p 2 100.00 NULL +7 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +8 UNION NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +NULL UNION RESULT NULL ALL NULL NULL NULL NULL NULL NULL Using temporary +6 DERIVED sq2_alias1 NULL ALL NULL NULL NULL NULL 15 100.00 NULL +6 DERIVED sq2_alias2 NULL ref col_int_key col_int_key 5 test.sq2_alias1.pk 2 100.00 NULL +2 DERIVED NULL ALL NULL NULL NULL NULL 15 100.00 NULL +5 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select sum(`alias1`.`col_varchar_nokey`) AS `field2` from `test`.`view_inline_2` join `test`.`t2` `alias2` join (/* select#2 */ select `test`.`view_inline_0`.`pk` AS `pk`,`test`.`view_inline_0`.`col_varchar_key` AS `col_varchar_key`,`test`.`view_inline_0`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`view_inline_0`) `alias1` semi join (`test`.`view_inline_1`) where ((`test`.`view_inline_1`.`sq2_field1` = `test`.`alias2`.`col_varchar_nokey`) and (`alias1`.`col_varchar_nokey` = `test`.`view_inline_2`.`Name_exp_p`) and (`test`.`alias2`.`col_varchar_key` = `test`.`view_inline_2`.`p`) and (`test`.`view_inline_1`.`sq2_field2` = `test`.`view_inline_2`.`p`) and (`alias1`.`col_varchar_key` = `test`.`view_inline_2`.`p`)) +SELECT SUM(alias1.col_varchar_nokey) AS field2 +FROM t2 AS alias2 +LEFT JOIN (SELECT * FROM view_inline_0) AS alias1 +ON alias2.col_varchar_key = alias1.col_varchar_key AND +(alias2.col_varchar_nokey, alias2.col_varchar_key) IN +(SELECT * FROM view_inline_1 +) +WHERE (alias1.col_varchar_key, alias1.col_varchar_nokey) IN +(SELECT * FROM view_inline_2 +); +field2 +NULL +SET @@optimizer_switch= @optimizer_switch_saved; +DROP VIEW view_inline_0, view_inline_1, view_inline_2; +DROP TABLE t1, t2, t3; +# End of test for bug#13956813. +# +# Bug#13974177: Assert !(tab->table->regginfo.not_exists_optimize... +# +CREATE TABLE t1 ( +pk INTEGER AUTO_INCREMENT, +col_int_nokey INTEGER, +col_int_key INTEGER, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk), +KEY (col_int_key), +KEY (col_varchar_key, col_int_key) +); +INSERT INTO t1(col_int_key, col_int_nokey, col_varchar_key, col_varchar_nokey) +VALUES +(0, 4, 'j', 'j'), (8, 6, 'v', 'v'), (1, 3, 'c', 'c'), (8, 5, 'm', 'm'), +(9, 3, 'd', 'd'), (24, 246, 'd', 'd'), (6, 2, 'y', 'y'), (1, 9, 't', 't'), +(6, 3, 'd', 'd'), (2, 8, 's', 's'), (4, 1, 'r', 'r'), (8, 8, 'm', 'm'), +(4, 8, 'b', 'b'), (4, 5, 'x', 'x'), (7, 7, 'g', 'g'), (4, 5, 'p', 'p'), +(1, 1, 'q', 'q'), (9, 6, 'w', 'w'), (4, 2, 'd', 'd'), (8, 9, 'e', 'e'); +CREATE TABLE t2 ( +pk INTEGER AUTO_INCREMENT, +col_int_nokey INTEGER NOT NULL, +col_time_key TIME NOT NULL, +col_time_nokey TIME NOT NULL, +PRIMARY KEY (pk), +KEY (col_time_key) +) ENGINE=InnoDB; +INSERT INTO t2 (col_int_nokey, col_time_key, col_time_nokey) VALUES +(7, '00:00:00', '00:00:00'), (0, '00:00:00', '00:00:00'), +(9, '06:35:17', '06:35:17'), (3, '18:07:14', '18:07:14'), +(4, '20:36:52', '20:36:52'), (2, '21:29:07', '21:29:07'), +(5, '23:45:57', '23:45:57'), (3, '22:54:57', '22:54:57'), +(1, '18:45:09', '18:45:09'), (3, '14:30:46', '14:30:46'), +(6, '19:23:43', '19:23:43'), (7, '03:39:30', '03:39:30'), +(5, '23:37:52', '23:37:52'), (1, '16:59:30', '16:59:30'), +(204, '22:21:15', '22:21:15'), (224, '12:24:37', '12:24:37'), +(9, '15:02:08', '15:02:08'), (5, '23:59:59', '23:59:59'), +(0, '08:23:30', '08:23:30'), (3, '08:32:22', '08:32:22'); +explain SELECT ot1.col_int_key AS x +FROM t1 AS ot2 +LEFT JOIN t1 AS ot1 +ON ot2.col_varchar_nokey > ot1.col_varchar_key +WHERE (ot1.col_int_nokey, ot1.pk) IN +(SELECT it1.pk AS x, +it1.col_int_nokey AS y +FROM t2 AS it2 +LEFT JOIN t2 AS it1 +ON it2.col_time_nokey = it1.col_time_key +) AND ot1.pk IS NULL +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`col_int_key` AS `x` from `test`.`t2` `it1` join `test`.`t1` `ot2` join `test`.`t1` `ot1` semi join (`test`.`t2` `it2`) where ((`test`.`ot1`.`pk` is null) and (`test`.`ot2`.`col_varchar_nokey` > `test`.`ot1`.`col_varchar_key`) and multiple equal(`test`.`ot1`.`col_int_nokey`, `test`.`it1`.`pk`) and multiple equal(`test`.`ot1`.`pk`, `test`.`it1`.`col_int_nokey`) and multiple equal(`test`.`it2`.`col_time_nokey`, `test`.`it1`.`col_time_key`)) +SELECT ot1.col_int_key AS x +FROM t1 AS ot2 +LEFT JOIN t1 AS ot1 +ON ot2.col_varchar_nokey > ot1.col_varchar_key +WHERE (ot1.col_int_nokey, ot1.pk) IN +(SELECT it1.pk AS x, +it1.col_int_nokey AS y +FROM t2 AS it2 +LEFT JOIN t2 AS it1 +ON it2.col_time_nokey = it1.col_time_key +) AND ot1.pk IS NULL +; +x +DROP TABLE t1, t2; +# End of test for bug#13974177. +# +# Bug#13971022: Assert 'keyparts > 0' failed in create_ref_for_key... +# +CREATE TABLE t1 ( +pk INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +PRIMARY KEY (pk), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +CREATE TABLE t2 ( +pk INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk) +) charset utf8mb4 ENGINE=InnoDB; +CREATE TABLE t3 ( +i INT +); +SET @optimizer_switch_saved= @@optimizer_switch; +SET @@optimizer_switch="derived_merge=off"; +explain SELECT table1.pk AS field1 +FROM ( SELECT subquery1_t1. * +FROM t2 AS subquery1_t1 +JOIN t2 AS subquery1_t2 +ON subquery1_t2.pk = subquery1_t1.pk) AS table1 +STRAIGHT_JOIN t2 AS table2 +ON table1.col_int_key IN (SELECT 7 FROM t3) +WHERE table1.col_varchar_nokey IN +(SELECT subquery3_t1.col_varchar_key AS subquery3_field1 +FROM t1 AS subquery3_t1 +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY subquery3_t1 NULL index col_varchar_key col_varchar_key 12 NULL 0 0.00 Using where; Using index; Start temporary +1 PRIMARY NULL ref 7 test.subquery3_t1.col_varchar_key 2 100.00 NULL +1 PRIMARY table2 NULL index NULL PRIMARY 4 NULL 1 100.00 Using index; Using join buffer (hash join) +1 PRIMARY t3 NULL ALL NULL NULL NULL NULL 0 0.00 End temporary; Using join buffer (hash join) +2 DERIVED subquery1_t1 NULL ALL PRIMARY NULL NULL NULL 1 100.00 Using where +2 DERIVED subquery1_t2 NULL eq_ref PRIMARY PRIMARY 4 test.subquery1_t1.pk 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `table1`.`pk` AS `field1` from (/* select#2 */ select `test`.`subquery1_t1`.`pk` AS `pk`,`test`.`subquery1_t1`.`col_int_key` AS `col_int_key`,`test`.`subquery1_t1`.`col_varchar_key` AS `col_varchar_key`,`test`.`subquery1_t1`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t2` `subquery1_t1` join `test`.`t2` `subquery1_t2` where ((`test`.`subquery1_t1`.`col_int_key` = 7) and (`test`.`subquery1_t2`.`pk` = `test`.`subquery1_t1`.`pk`))) `table1` straight_join `test`.`t2` `table2` semi join (`test`.`t3`) semi join (`test`.`t1` `subquery3_t1`) where (`table1`.`col_varchar_nokey` = `test`.`subquery3_t1`.`col_varchar_key`) +SELECT table1.pk AS field1 +FROM ( SELECT subquery1_t1. * +FROM t2 AS subquery1_t1 +JOIN t2 AS subquery1_t2 +ON subquery1_t2.pk = subquery1_t1.pk) AS table1 +STRAIGHT_JOIN t2 AS table2 +ON table1.col_int_key IN (SELECT 7 FROM t3) +WHERE table1.col_varchar_nokey IN +(SELECT subquery3_t1.col_varchar_key AS subquery3_field1 +FROM t1 AS subquery3_t1 +) +; +field1 +SET @@optimizer_switch= @optimizer_switch_saved; +DROP TABLE t1, t2, t3; +# End of test for bug#13971022. +# +# Bug#13623473 "MISSING ROWS ON SELECT AND JOIN WITH +# TIME/DATETIME COMPARE" - Subquery part of test. +# +SET TIMESTAMP=UNIX_TIMESTAMP('2012-01-31 10:14:35'); +CREATE TABLE t1 ( +pk INT NOT NULL, +col_int_nokey INT, +col_int_key INT NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +) ENGINE=InnoDB; +INSERT INTO t1 VALUES (10,1,7), (11,7,0), (12,4,9), (13,7,3), +(14,0,4), (15,2,2), (16,9,5), (17,4,3), (18,0,1), (19,9,3), (20,1,6), +(21,3,7), (22,8,5), (23,8,1), (24,18,204), (25,84,224), (26,6,9), +(27,3,5), (28,6,0), (29,6,3); +CREATE TABLE t2 ( +col_int_nokey INT NOT NULL, +col_datetime_key DATETIME NOT NULL, +col_varchar_key VARCHAR(1) NOT NULL, +KEY col_datetime_key (col_datetime_key), +KEY col_varchar_key (col_varchar_key) +) ENGINE=InnoDB; +INSERT INTO t2 VALUES (1,'2001-11-04 19:07:55','k'); +CREATE TABLE t3 ( +col_time_key TIME, +KEY col_time_key (col_time_key) +) ENGINE=InnoDB; +INSERT INTO t3 VALUES ('21:22:34'), ('10:50:38'), ('00:21:38'), +('04:08:02'), ('16:25:11'), ('10:14:58'), ('19:47:59'), ('11:14:24'), +('00:00:00'), ('00:00:00'), ('15:57:25'), ('07:05:51'), ('19:22:21'), +('03:53:16'), ('09:16:38'), ('15:37:26'), ('00:00:00'), ('05:03:03'), +('02:59:24'), ('00:01:58'); +EXPLAIN SELECT outr.col_int_nokey +FROM t2 as outr +STRAIGHT_JOIN t3 AS outr2 +ON outr2.col_time_key > outr.col_datetime_key +WHERE outr.col_int_nokey IN ( +SELECT col_int_key +FROM t1 AS innr +WHERE innr.pk >= innr.col_int_nokey +) AND ( +outr.col_int_nokey <= 6 +OR +outr.col_varchar_key IS NULL +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE outr NULL ALL col_datetime_key NULL NULL NULL 1 100.00 Using where +2 SIMPLE innr NULL ref col_int_key col_int_key 4 test.outr.col_int_nokey 1 33.33 Using where; Start temporary; End temporary +2 SIMPLE outr2 NULL index col_time_key col_time_key 4 NULL 20 33.33 Using where; Using index; Using join buffer (hash join) +Warnings: +Warning 1739 Cannot use range access on index 'col_time_key' due to type or collation conversion on field 'col_time_key' +Note 1003 /* select#1 */ select `test`.`outr`.`col_int_nokey` AS `col_int_nokey` from `test`.`t2` `outr` straight_join `test`.`t3` `outr2` semi join (`test`.`t1` `innr`) where ((`test`.`innr`.`col_int_key` = `test`.`outr`.`col_int_nokey`) and (`test`.`outr`.`col_int_nokey` <= 6) and (`test`.`innr`.`pk` >= `test`.`innr`.`col_int_nokey`) and (cast(`test`.`outr2`.`col_time_key` as datetime) > `test`.`outr`.`col_datetime_key`)) +SELECT outr.col_int_nokey +FROM t2 as outr +STRAIGHT_JOIN t3 AS outr2 +ON outr2.col_time_key > outr.col_datetime_key +WHERE outr.col_int_nokey IN ( +SELECT col_int_key +FROM t1 AS innr +WHERE innr.pk >= innr.col_int_nokey +) AND ( +outr.col_int_nokey <= 6 +OR +outr.col_varchar_key IS NULL +); +col_int_nokey +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +DROP TABLE t1,t2,t3; +SET TIMESTAMP = DEFAULT; +# End of test for bug#13623473. +# +# Bug#13980954: Missing data on left join + null value + where..in +# +CREATE TABLE t1 ( +ik INT, +vc varchar(1) +) charset utf8mb4; +INSERT INTO t1 VALUES (8, 'x'), (NULL, 'x'); +CREATE TABLE t2 ( +ik INT, +vc varchar(1) +) charset utf8mb4; +INSERT INTO t2 VALUES +(0, 'x'), (7, 'i'), (7, 'e'), (1, 'p'), (7, 's'), (1, 'j'); +explain format=json SELECT t2.vc, t2.ik AS t2_ik, t1.ik AS t1_ik +FROM t2 LEFT JOIN t1 ON t2.vc=t1.vc +WHERE t2.vc IN (SELECT vc FROM t2 AS t3); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "7.62" + }, + "nested_loop": [ + { + "duplicates_removal": { + "using_temporary_table": true, + "nested_loop": [ + { + "table": { + "table_name": "t3", + "access_type": "ALL", + "rows_examined_per_scan": 6, + "rows_produced_per_join": 6, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "0.60", + "prefix_cost": "1.11", + "data_read_per_join": "96" + }, + "used_columns": [ + "vc" + ] + } + }, + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 6, + "rows_produced_per_join": 1, + "filtered": "16.67", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "0.10", + "prefix_cost": "6.91", + "data_read_per_join": "16" + }, + "used_columns": [ + "ik", + "vc" + ], + "attached_condition": "(`test`.`t2`.`vc` = `test`.`t3`.`vc`)" + } + } + ] + } + }, + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 2, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.20", + "prefix_cost": "7.62", + "data_read_per_join": "32" + }, + "used_columns": [ + "ik", + "vc" + ], + "attached_condition": "(is_not_null_compl(t1), (`test`.`t1`.`vc` = `test`.`t3`.`vc`), true)" + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`vc` AS `vc`,`test`.`t2`.`ik` AS `t2_ik`,`test`.`t1`.`ik` AS `t1_ik` from `test`.`t2` left join `test`.`t1` on((`test`.`t1`.`vc` = `test`.`t3`.`vc`)) semi join (`test`.`t2` `t3`) where (`test`.`t2`.`vc` = `test`.`t3`.`vc`) +SELECT t2.vc, t2.ik AS t2_ik, t1.ik AS t1_ik +FROM t2 LEFT JOIN t1 ON t2.vc=t1.vc +WHERE t2.vc IN (SELECT vc FROM t2 AS t3); +vc t2_ik t1_ik +e 7 NULL +i 7 NULL +j 1 NULL +p 1 NULL +s 7 NULL +x 0 8 +x 0 NULL +DROP TABLE t1, t2; +# End of test for bug#13980954. +# +# Bug#14048292: Segfault in Item_field::result_type on 2nd execution +# of prep stmt with join of view +# +CREATE TABLE t1 ( +col_int INT +); +INSERT INTO t1 VALUES (0), (1); +CREATE VIEW view_t1 AS SELECT * FROM t1; +explain SELECT alias1.col_int +FROM t1 AS alias1 +LEFT JOIN view_t1 AS alias2 +ON alias1.col_int IN +(SELECT sq1_alias1.col_int +FROM t1 AS sq1_alias1 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE alias1 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE sq1_alias1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`alias1`.`col_int` AS `col_int` from `test`.`t1` `alias1` left join (`test`.`t1` semi join (`test`.`t1` `sq1_alias1`)) on(((`test`.`sq1_alias1`.`col_int` = `test`.`alias1`.`col_int`))) where true +PREPARE stmt FROM "SELECT alias1.col_int +FROM t1 AS alias1 +LEFT JOIN view_t1 AS alias2 +ON alias1.col_int IN +(SELECT sq1_alias1.col_int +FROM t1 AS sq1_alias1 +)"; +EXECUTE stmt; +col_int +0 +0 +1 +1 + +EXECUTE stmt; +col_int +0 +0 +1 +1 +DEALLOCATE PREPARE stmt; +DROP VIEW view_t1; +DROP TABLE t1; +# End of test for bug#14048292. +# +# Bug#14064201: Missing data on join of derived table + WHERE .. IN +# with two operands +# +CREATE TABLE t1 ( +col_varchar_nokey VARCHAR(1) +) charset utf8mb4; +INSERT INTO t1 VALUES +('v'), ('s'), ('l'), ('y'), ('c'), ('i'), ('h'), ('q'), ('a'), ('v'), +('u'), ('s'), ('y'), ('z'), ('h'), ('p'), ('e'), ('i'), ('y'), ('w'); +CREATE TABLE t2 ( +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +KEY col_varchar_key(col_varchar_key) +) charset utf8mb4; +INSERT INTO t2 VALUES +('j','j'), ('v','v'), ('c','c'), ('m','m'), ('d','d'), ('d','d'), ('y','y'); +SET @optimizer_switch_saved= @@optimizer_switch; +SET @@optimizer_switch="derived_merge=off"; +explain format=json SELECT * +FROM (SELECT * FROM t2) AS derived1 +LEFT JOIN t1 +USING (col_varchar_nokey) +WHERE (col_varchar_nokey, col_varchar_nokey) IN +(SELECT col_varchar_nokey, col_varchar_key +FROM t2 AS derived2 +); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "23.73" + }, + "nested_loop": [ + { + "duplicates_removal": { + "using_temporary_table": true, + "nested_loop": [ + { + "table": { + "table_name": "derived2", + "access_type": "ALL", + "possible_keys": [ + "col_varchar_key" + ], + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "0.70", + "prefix_cost": "1.21", + "data_read_per_join": "112" + }, + "used_columns": [ + "col_varchar_key", + "col_varchar_nokey" + ], + "attached_condition": "((`test`.`derived2`.`col_varchar_key` = `test`.`derived2`.`col_varchar_nokey`) and (`test`.`derived2`.`col_varchar_nokey` is not null))" + } + }, + { + "table": { + "table_name": "derived1", + "access_type": "ref", + "possible_keys": [ + "" + ], + "key": "", + "used_key_parts": [ + "col_varchar_nokey" + ], + "key_length": "7", + "ref": [ + "test.derived2.col_varchar_nokey" + ], + "rows_examined_per_scan": 2, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "3.50", + "eval_cost": "0.70", + "prefix_cost": "9.21", + "data_read_per_join": "112" + }, + "used_columns": [ + "col_varchar_key", + "col_varchar_nokey" + ], + "materialized_from_subquery": { + "using_temporary_table": true, + "dependent": false, + "cacheable": true, + "query_block": { + "select_id": 2, + "cost_info": { + "query_cost": "1.21" + }, + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "0.70", + "prefix_cost": "1.21", + "data_read_per_join": "112" + }, + "used_columns": [ + "col_varchar_key", + "col_varchar_nokey" + ] + } + } + } + } + } + ] + } + }, + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 140, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.52", + "eval_cost": "14.00", + "prefix_cost": "23.73", + "data_read_per_join": "1K" + }, + "used_columns": [ + "col_varchar_nokey" + ], + "attached_condition": "(is_not_null_compl(t1), (`test`.`t1`.`col_varchar_nokey` = `test`.`derived2`.`col_varchar_nokey`), true)" + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select `derived1`.`col_varchar_nokey` AS `col_varchar_nokey`,`derived1`.`col_varchar_key` AS `col_varchar_key` from (/* select#2 */ select `test`.`t2`.`col_varchar_key` AS `col_varchar_key`,`test`.`t2`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t2`) `derived1` left join `test`.`t1` on((`test`.`t1`.`col_varchar_nokey` = `test`.`derived2`.`col_varchar_nokey`)) semi join (`test`.`t2` `derived2`) where ((`test`.`derived2`.`col_varchar_key` = `test`.`derived2`.`col_varchar_nokey`) and (`derived1`.`col_varchar_nokey` = `test`.`derived2`.`col_varchar_nokey`)) +SELECT * +FROM (SELECT * FROM t2) AS derived1 +LEFT JOIN t1 +USING (col_varchar_nokey) +WHERE (col_varchar_nokey, col_varchar_nokey) IN +(SELECT col_varchar_nokey, col_varchar_key +FROM t2 AS derived2 +); +col_varchar_nokey col_varchar_key +c c +d d +d d +j j +m m +v v +v v +y y +y y +y y +SET @@optimizer_switch= @optimizer_switch_saved; +DROP TABLE t1, t2; +CREATE TABLE t1 ( +col_int_nokey int NOT NULL, +col_int_key int NOT NULL, +KEY col_int_key (col_int_key) +); +INSERT INTO t1 VALUES +(1,7), (7,0), (4,9), (7,3), (0,4), (2,2), (9,5), (4,3), (0,1), (9,3), +(1,6), (3,7), (8,5), (8,1), (18,204), (84,224), (6,9), (3,5), (6,0), (6,3); +CREATE TABLE t2 ( +col_int_nokey int NOT NULL, +col_int_key int NOT NULL, +KEY col_int_key (col_int_key) +); +INSERT INTO t2 VALUES +(4,0), (6,8), (3,1), (5,8), (3,9), (246,24), (2,6), (9,1), (3,6), (8,2), +(1,4), (8,8), (8,4), (5,4), (7,7), (5,4), (1,1), (6,9), (2,4), (9,8); +explain format=json SELECT grandparent1.* +FROM t1 AS grandparent1 +LEFT JOIN t1 USING (col_int_nokey) +WHERE (col_int_nokey, col_int_nokey) IN +(SELECT col_int_nokey, col_int_key +FROM t2 +); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "52.73" + }, + "nested_loop": [ + { + "duplicates_removal": { + "using_temporary_table": true, + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "possible_keys": [ + "col_int_key" + ], + "rows_examined_per_scan": 20, + "rows_produced_per_join": 20, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "2.00", + "prefix_cost": "2.51", + "data_read_per_join": "320" + }, + "used_columns": [ + "col_int_nokey", + "col_int_key" + ], + "attached_condition": "(`test`.`t2`.`col_int_key` = `test`.`t2`.`col_int_nokey`)" + } + }, + { + "table": { + "table_name": "grandparent1", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 2, + "filtered": "10.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "0.20", + "prefix_cost": "48.22", + "data_read_per_join": "32" + }, + "used_columns": [ + "col_int_nokey", + "col_int_key" + ], + "attached_condition": "(`test`.`grandparent1`.`col_int_nokey` = `test`.`t2`.`col_int_nokey`)" + } + } + ] + } + }, + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 40, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "4.00", + "prefix_cost": "52.73", + "data_read_per_join": "640" + }, + "used_columns": [ + "col_int_nokey" + ], + "attached_condition": "(is_not_null_compl(t1), (`test`.`t1`.`col_int_nokey` = `test`.`t2`.`col_int_nokey`), true)" + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`grandparent1`.`col_int_nokey` AS `col_int_nokey`,`test`.`grandparent1`.`col_int_key` AS `col_int_key` from `test`.`t1` `grandparent1` left join `test`.`t1` on((`test`.`t1`.`col_int_nokey` = `test`.`t2`.`col_int_nokey`)) semi join (`test`.`t2`) where ((`test`.`t2`.`col_int_key` = `test`.`t2`.`col_int_nokey`) and (`test`.`grandparent1`.`col_int_nokey` = `test`.`t2`.`col_int_nokey`)) +SELECT grandparent1.* +FROM t1 AS grandparent1 +LEFT JOIN t1 USING (col_int_nokey) +WHERE (col_int_nokey, col_int_nokey) IN +(SELECT col_int_nokey, col_int_key +FROM t2 +); +col_int_nokey col_int_key +1 6 +1 6 +1 7 +1 7 +7 0 +7 0 +7 3 +7 3 +8 1 +8 1 +8 5 +8 5 +DROP TABLE t1, t2; +CREATE TABLE t1 ( +pk int, +col_int_key int, +col_datetime_key datetime, +col_varchar_key varchar(1), +col_varchar_nokey varchar(1), +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_datetime_key (col_datetime_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4 engine=MyISAM; +INSERT INTO t1 VALUES +(10,7,'2004-06-06 04:22:12','v','v'), (11,0,'2005-11-13 01:12:31','s','s'), +(12,9,'2002-05-04 01:50:00','l','l'), (13,3,'2004-10-27 10:28:45','y','y'), +(14,4,'2006-07-22 05:24:23','c','c'), (15,2,'2002-05-16 21:34:03','i','i'), +(16,5,'2008-04-17 10:45:30','h','h'), (17,3,'2009-04-21 02:58:02','q','q'), +(18,1,'2008-01-11 11:01:51','a','a'), (19,3,'1900-01-01 00:00:00','v','v'), +(20,6,'2007-05-17 18:24:57','u','u'), (21,7,'2007-08-07 00:00:00','s','s'), +(22,5,'2001-08-28 00:00:00','y','y'), (23,1,'2004-04-16 00:27:28','z','z'), +(24,204,'2005-05-03 07:06:22','h','h'), (25,224,'2009-03-11 17:09:50','p','p'), +(26,9,'2007-12-08 01:54:28','e','e'), (27,5,'2009-07-28 18:19:54','i','i'), +(28,0,'2008-06-08 00:00:00','y','y'), (29,3,'2005-02-09 09:20:26','w','w'); +CREATE TABLE t2 ( +pk int, +col_int_key int, +col_datetime_key datetime, +col_varchar_key varchar(1), +col_varchar_nokey varchar(1), +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_datetime_key (col_datetime_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4 engine=MyISAM; +INSERT INTO t2 VALUES +(1,0,'2002-02-13 17:30:06','j','j'), (2,8,'2008-09-27 00:34:58','v','v'), +(3,1,'2007-05-28 00:00:00','c','c'), (4,8,'2009-07-25 09:21:20','m','m'), +(5,9,'2002-01-16 00:00:00','d','d'), (6,24,'2006-10-12 04:32:53','d','d'), +(7,6,'2001-02-15 03:08:38','y','y'), (8,1,'2004-10-02 20:31:15','t','t'), +(9,6,'2002-08-20 22:48:00','d','d'), (10,2,'1900-01-01 00:00:00','s','s'), +(11,4,'2005-08-15 00:00:00','r','r'), (12,8,'1900-01-01 00:00:00','m','m'), +(13,4,'2008-05-16 08:09:06','b','b'), (14,4,'2001-01-20 12:47:23','x','x'), +(15,7,'2008-07-02 00:00:00','g','g'), (16,4,'1900-01-01 00:00:00','p','p'), +(17,1,'2002-12-08 11:34:58','q','q'), (18,9,'1900-01-01 00:00:00','w','w'), +(19,4,'1900-01-01 00:00:00','d','d'), (20,8,'2002-08-25 20:35:06','e','e'); +SELECT alias1.col_datetime_key +FROM t2 AS alias1 +RIGHT JOIN t2 AS alias2 +JOIN t2 AS alias3 +ON alias3.pk = alias2.pk +ON alias3.col_varchar_nokey = alias2.col_varchar_key OR +alias2.col_varchar_nokey +WHERE (alias2.col_varchar_key, alias2.col_varchar_key) IN +(SELECT sq2_alias2.col_varchar_key, sq2_alias1.col_varchar_nokey +FROM t1 AS sq2_alias1, t1 AS sq2_alias2 +WHERE sq2_alias2.col_int_key < 2); +col_datetime_key +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +2001-01-20 12:47:23 +2001-01-20 12:47:23 +2001-02-15 03:08:38 +2001-02-15 03:08:38 +2002-01-16 00:00:00 +2002-01-16 00:00:00 +2002-02-13 17:30:06 +2002-02-13 17:30:06 +2002-08-20 22:48:00 +2002-08-20 22:48:00 +2002-08-25 20:35:06 +2002-08-25 20:35:06 +2002-12-08 11:34:58 +2002-12-08 11:34:58 +2004-10-02 20:31:15 +2004-10-02 20:31:15 +2005-08-15 00:00:00 +2005-08-15 00:00:00 +2006-10-12 04:32:53 +2006-10-12 04:32:53 +2007-05-28 00:00:00 +2007-05-28 00:00:00 +2008-05-16 08:09:06 +2008-05-16 08:09:06 +2008-07-02 00:00:00 +2008-07-02 00:00:00 +2008-09-27 00:34:58 +2008-09-27 00:34:58 +2009-07-25 09:21:20 +2009-07-25 09:21:20 +ALTER TABLE t1 DISABLE KEYS; +ALTER TABLE t2 DISABLE KEYS; +explain format=json SELECT alias1.col_datetime_key +FROM t2 AS alias1 +RIGHT JOIN t2 AS alias2 +JOIN t2 AS alias3 +ON alias3.pk = alias2.pk +ON alias3.col_varchar_nokey = alias2.col_varchar_key OR +alias2.col_varchar_nokey +WHERE (alias2.col_varchar_key, alias2.col_varchar_key) IN +(SELECT sq2_alias2.col_varchar_key, sq2_alias1.col_varchar_nokey +FROM t1 AS sq2_alias1, t1 AS sq2_alias2 +WHERE sq2_alias2.col_int_key < 2); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "52.68" + }, + "nested_loop": [ + { + "duplicates_removal": { + "using_temporary_table": true, + "nested_loop": [ + { + "table": { + "table_name": "sq2_alias2", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 6, + "filtered": "33.33", + "cost_info": { + "read_cost": "1.86", + "eval_cost": "0.67", + "prefix_cost": "2.53", + "data_read_per_join": "213" + }, + "used_columns": [ + "col_int_key", + "col_varchar_key" + ], + "attached_condition": "(`test`.`sq2_alias2`.`col_int_key` < 2)" + } + }, + { + "table": { + "table_name": "alias2", + "access_type": "ALL", + "possible_keys": [ + "PRIMARY" + ], + "rows_examined_per_scan": 20, + "rows_produced_per_join": 13, + "filtered": "10.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.53", + "eval_cost": "1.33", + "prefix_cost": "16.39", + "data_read_per_join": "426" + }, + "used_columns": [ + "pk", + "col_varchar_key", + "col_varchar_nokey" + ], + "attached_condition": "(`test`.`alias2`.`col_varchar_key` = `test`.`sq2_alias2`.`col_varchar_key`)" + } + }, + { + "table": { + "table_name": "sq2_alias1", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 2, + "filtered": "10.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.53", + "eval_cost": "0.20", + "prefix_cost": "47.45", + "data_read_per_join": "64" + }, + "used_columns": [ + "col_varchar_nokey" + ], + "attached_condition": "(`test`.`sq2_alias1`.`col_varchar_nokey` = `test`.`sq2_alias2`.`col_varchar_key`)" + } + } + ] + } + }, + { + "table": { + "table_name": "alias3", + "access_type": "eq_ref", + "possible_keys": [ + "PRIMARY" + ], + "key": "PRIMARY", + "used_key_parts": [ + "pk" + ], + "key_length": "4", + "ref": [ + "test.alias2.pk" + ], + "rows_examined_per_scan": 1, + "rows_produced_per_join": 2, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.20", + "prefix_cost": "48.15", + "data_read_per_join": "64" + }, + "used_columns": [ + "pk", + "col_varchar_nokey" + ] + } + }, + { + "table": { + "table_name": "alias1", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 40, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.53", + "eval_cost": "4.00", + "prefix_cost": "52.68", + "data_read_per_join": "1K" + }, + "used_columns": [ + "col_datetime_key" + ], + "attached_condition": "(is_not_null_compl(alias1), (((`test`.`alias2`.`col_varchar_key` = `test`.`sq2_alias2`.`col_varchar_key`) and (`test`.`sq2_alias1`.`col_varchar_nokey` = `test`.`sq2_alias2`.`col_varchar_key`) and (`test`.`alias3`.`col_varchar_nokey` = `test`.`sq2_alias2`.`col_varchar_key`)) or (0 <> `test`.`alias2`.`col_varchar_nokey`)), true)" + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`alias1`.`col_datetime_key` AS `col_datetime_key` from `test`.`t2` `alias2` join `test`.`t2` `alias3` left join `test`.`t2` `alias1` on((((`test`.`alias2`.`col_varchar_key` = `test`.`sq2_alias2`.`col_varchar_key`) and (`test`.`sq2_alias1`.`col_varchar_nokey` = `test`.`sq2_alias2`.`col_varchar_key`) and (`test`.`alias3`.`col_varchar_nokey` = `test`.`sq2_alias2`.`col_varchar_key`)) or (0 <> `test`.`alias2`.`col_varchar_nokey`))) semi join (`test`.`t1` `sq2_alias1` join `test`.`t1` `sq2_alias2`) where ((`test`.`alias3`.`pk` = `test`.`alias2`.`pk`) and (`test`.`alias2`.`col_varchar_key` = `test`.`sq2_alias2`.`col_varchar_key`) and (`test`.`sq2_alias1`.`col_varchar_nokey` = `test`.`sq2_alias2`.`col_varchar_key`) and (`test`.`sq2_alias2`.`col_int_key` < 2)) +SELECT alias1.col_datetime_key +FROM t2 AS alias1 +RIGHT JOIN t2 AS alias2 +JOIN t2 AS alias3 +ON alias3.pk = alias2.pk +ON alias3.col_varchar_nokey = alias2.col_varchar_key OR +alias2.col_varchar_nokey +WHERE (alias2.col_varchar_key, alias2.col_varchar_key) IN +(SELECT sq2_alias2.col_varchar_key, sq2_alias1.col_varchar_nokey +FROM t1 AS sq2_alias1, t1 AS sq2_alias2 +WHERE sq2_alias2.col_int_key < 2); +col_datetime_key +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +2001-01-20 12:47:23 +2001-01-20 12:47:23 +2001-02-15 03:08:38 +2001-02-15 03:08:38 +2002-01-16 00:00:00 +2002-01-16 00:00:00 +2002-02-13 17:30:06 +2002-02-13 17:30:06 +2002-08-20 22:48:00 +2002-08-20 22:48:00 +2002-08-25 20:35:06 +2002-08-25 20:35:06 +2002-12-08 11:34:58 +2002-12-08 11:34:58 +2004-10-02 20:31:15 +2004-10-02 20:31:15 +2005-08-15 00:00:00 +2005-08-15 00:00:00 +2006-10-12 04:32:53 +2006-10-12 04:32:53 +2007-05-28 00:00:00 +2007-05-28 00:00:00 +2008-05-16 08:09:06 +2008-05-16 08:09:06 +2008-07-02 00:00:00 +2008-07-02 00:00:00 +2008-09-27 00:34:58 +2008-09-27 00:34:58 +2009-07-25 09:21:20 +2009-07-25 09:21:20 +DROP TABLE t1, t2; +# End of test for bug#14064201. +# +# Bug#18223655:ASSERTION FAILED: (INT)IDX >= 0 +# && IDX < PARENT_JOIN->TABLES +# +CREATE TABLE b (d INT); +CREATE TABLE c (a INT, b INT,c INT,d BLOB NOT NULL); +SELECT(SELECT 1 +FROM b WHERE(SELECT 1 IN (SELECT 1 FROM b WHERE 1 NOT BETWEEN d AND 1) +FROM b) IN (SELECT d FROM c)) as cc FROM b; +cc +INSERT INTO b VALUE(1); +INSERT INTO c VALUES(1,2,3,'1'),(2,3,4,'1'),(3,4,5,'C'); +SELECT(SELECT d FROM b WHERE(SELECT d IN +(SELECT d FROM b WHERE 1 NOT BETWEEN d AND 1) FROM b) IN +(SELECT d FROM c)) as cc FROM c; +cc +1 +1 +1 +DROP TABLE b,c; +# +# Bug#18447874:WRONG RESULT COMING FROM SEMI-JOIN +# +CREATE TABLE b ( +d INT(11) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE c ( +d BLOB +) ; +CREATE TABLE d ( +b INT(11) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO b VALUES(1),(2),(4); +INSERT INTO c VALUES(1),(2),(3); +SELECT 1 FROM b WHERE (SELECT 1 FROM d ) IN (SELECT d FROM c) ; +1 +INSERT INTO d VALUES(2); +SELECT 1 FROM b WHERE (SELECT 1 FROM d ) IN (SELECT d FROM c) ; +1 +1 +1 +1 +DROP TABLE b,c,d; +# +# Bug#17292723:INCORRECT RESULT FOR (SELECT...) IN (SELECT...) STATEMENT +# +CREATE TABLE t1 ( +ID int(11) NOT NULL AUTO_INCREMENT, +id2 int(11) DEFAULT NULL, +id3 int(11) DEFAULT NULL, +id4 varchar(150) COLLATE utf8_spanish_ci NOT NULL, +id5 int(11) DEFAULT NULL, +PRIMARY KEY (ID), +KEY id2 (id2), +KEY id3 (id3), +KEY id5 (id5) +) ENGINE=InnoDB; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 3778 'utf8_spanish_ci' is a collation of the deprecated character set UTF8MB3. Please consider using UTF8MB4 with an appropriate collation instead. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES +(123,1,1,'1',NULL), +(124,1,1,'2',NULL), +(125,1,1,'4',NULL), +(126,1,1,'3',NULL), +(127,1,1,'6',NULL), +(128,1,1,'8',NULL); +CREATE TABLE t2 ( +id6 int(11) NOT NULL, +id7 int(11) NOT NULL, +PRIMARY KEY (id6,id7), +KEY id7 (id7) +) ENGINE=InnoDB; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (126,123),(130,123),(135,123); +SELECT ID +FROM t1 p0 +WHERE p0.id3=1 +AND ( (SELECT p1.id FROM t1 p1 WHERE p1.id=123) IN (SELECT p3.id FROM t2 +p2, t1 p3 WHERE p0.id=p2.id6 AND p2.id7=p3.id)); +ID +126 +DROP TABLE t1,t2; +set @@optimizer_switch=@old_opt_switch; +# End of 5.6 tests +# +# Bug#19336348 DEBUG CRASH AT SETUP_SEMIJOIN_DUPS_ELIMINATION IN SQL/SQL_SELECT.CC +# +CREATE TABLE t1 ( +col_varchar_nokey varchar(1) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t1 VALUES ('c'),(NULL),('x'); +CREATE TABLE t2 ( +pk int, +col_varchar_key varchar(1), +PRIMARY KEY (pk), +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t2 VALUES (10,'l'),(11,'p'); +ANALYZE TABLE t1,t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN SELECT 1 +FROM t1 AS outr +WHERE outr.col_varchar_nokey IN +( +SELECT innr.col_varchar_key +FROM t2 AS innr +WHERE innr.pk <= 7 +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE innr NULL index PRIMARY,col_varchar_key col_varchar_key 7 NULL 2 100.00 Using where; Using index; LooseScan +1 SIMPLE outr NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` `outr` semi join (`test`.`t2` `innr`) where ((`test`.`outr`.`col_varchar_nokey` = `test`.`innr`.`col_varchar_key`) and (`test`.`innr`.`pk` <= 7)) +SELECT 1 +FROM t1 AS outr +WHERE outr.col_varchar_nokey IN +( +SELECT innr.col_varchar_key +FROM t2 AS innr +WHERE innr.pk <= 7 +) +; +1 +DROP TABLE t1,t2; +# +# Bug#18174394 BLOBS: CRASH AFTER UNINITIALIZED VALUES IN ITEM_FIELD::STR_RESULT +# +CREATE TABLE t1(d BLOB, b BLOB); +INSERT INTO t1(d,b) VALUES ('aaaa',''),('bnbb',''); +SELECT 1 FROM t1 +WHERE (SELECT b FROM t1) IN (SELECT (d>=1) FROM t1); +ERROR 21000: Subquery returns more than 1 row +DROP TABLE t1; +# +# Bug#19779600: ASSERT FAILED IN REPLACE_SUBCONDITION WITH IN +# PREDICATE INSIDE IN PREDICATE +# +CREATE TABLE t(X INT) ENGINE=InnoDB; +INSERT INTO t VALUES (1); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +EXPLAIN SELECT 1 FROM t WHERE (1 IN (SELECT 1 FROM t)) IN (SELECT 1 FROM t); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 PRIMARY t NULL ALL NULL NULL NULL NULL 1 100.00 End temporary; Using join buffer (hash join) +2 SUBQUERY t NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t` semi join (`test`.`t`) where true +SELECT 1 FROM t WHERE (1 IN (SELECT 1 FROM t)) IN (SELECT 1 FROM t); +1 +1 +DROP TABLE t; +# +# Bug#19465034 ASSERT ON SETUP_SEMIJOIN_DUPS_ELIMINATION IN SQL/SQL_SELECT.CC +# +CREATE TABLE t1 ( +pk INTEGER NOT NULL, +i1 INTEGER NOT NULL, +PRIMARY KEY (pk) +) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1,1); +CREATE TABLE t2 ( +pk INTEGER NOT NULL, +c1 VARCHAR(1) NOT NULL, +PRIMARY KEY (pk), +KEY c1_key (c1) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t2 VALUES (1,'j'),(2,'v'),(3,'c'); +CREATE TABLE t3 ( +pk INTEGER NOT NULL, +c1 VARCHAR(1) NOT NULL, +PRIMARY KEY (pk), +KEY c1_key (c1) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t3 VALUES (10,'v'),(11,'s'); +ANALYZE TABLE t1, t2, t3; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +EXPLAIN SELECT * +FROM t1 JOIN t2 ON t1.i1 >= t2.pk +WHERE t2.c1 IN ( +SELECT t3.c1 +FROM t3 +WHERE t3.pk < 3 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t3 NULL index PRIMARY,c1_key c1_key 6 NULL 2 100.00 Using where; Using index; LooseScan +2 SIMPLE t2 NULL ref PRIMARY,c1_key c1_key 6 test.t3.c1 1 33.33 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`i1` AS `i1`,`test`.`t2`.`pk` AS `pk`,`test`.`t2`.`c1` AS `c1` from `test`.`t1` join `test`.`t2` semi join (`test`.`t3`) where ((`test`.`t2`.`c1` = `test`.`t3`.`c1`) and (`test`.`t3`.`pk` < 3) and (`test`.`t1`.`i1` >= `test`.`t2`.`pk`)) +SELECT * +FROM t1 JOIN t2 ON t1.i1 >= t2.pk +WHERE t2.c1 IN ( +SELECT t3.c1 +FROM t3 +WHERE t3.pk < 3 +); +pk i1 pk c1 +DROP TABLE t1,t2,t3; +# +# Bug#19586047: CRASH IN ARG_COMPARATOR::SET_CMP_FUNC +# +CREATE TABLE t1(x INT) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT 1 FROM t1 WHERE EXISTS(SELECT 1) IN (SELECT 1 FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 1 100.00 End temporary; Using join buffer (hash join) +2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` semi join (`test`.`t1`) where true +SELECT 1 FROM t1 WHERE EXISTS(SELECT 1) IN (SELECT 1 FROM t1); +1 +1 +EXPLAIN SELECT 1 FROM t1 WHERE (SELECT 1, 2 FROM t1) IN (SELECT 1, 2 FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 1 100.00 End temporary; Using join buffer (hash join) +2 SUBQUERY t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` semi join (`test`.`t1`) where true +SELECT 1 FROM t1 WHERE (SELECT 1, 2 FROM t1) IN (SELECT 1, 2 FROM t1); +1 +1 +EXPLAIN SELECT 1 FROM t1 WHERE +(SELECT 1, 2 FROM t1 WHERE x = 2) IN (SELECT 1, 2 FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +2 SUBQUERY t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` semi join (`test`.`t1`) where false +SELECT 1 FROM t1 WHERE +(SELECT 1, 2 FROM t1 WHERE x = 2) IN (SELECT 1, 2 FROM t1); +1 +DROP TABLE t1; +# +#Bug#20119743 ASSERTIONQEP_TAB->USE_ORDER() IN ENUM_NESTED_LOOP_STATE +# EVALUATE_JOIN_RECORD +# +CREATE TABLE t1 ( +pk int(11) NOT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +PRIMARY KEY (pk) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (1,'x'); +CREATE TABLE t2 ( +col_date_key date DEFAULT NULL, +col_int_key int(11) DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +KEY col_int_key (col_int_key), +KEY col_date_key (col_date_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES ('2000-12-03', 8, 'x', 'x'),('2008-05-03', 7, 'd', 'd'), +('2005-12-06', 1, 'r', 'r'),('2000-04-10', 7, 'f', 'f'), +('2002-11-05', 9, 'y', 'y'),('2000-09-06', NULL, 'u', 'u'), +(NULL, 1, 'm', 'm'),('2007-06-14', 9, NULL, NULL), +('2007-11-17', 2, 'o', 'o'),('2009-02-23', 9, 'w', 'w'), +('2007-01-08', 2, 'm', 'm'), ('2008-06-10', 4, 'q', 'q'), +('2002-10-20', 0, NULL, NULL),('2008-09-12', 4, 'd', 'd'), +('2006-06-16', 8, 'g', 'g'),('2004-09-18', NULL, 'x', 'x'), +('1900-01-01', NULL, 'f', 'f'),('2005-09-13', 0, 'p', 'p'), +('2007-04-09', NULL, 'j', 'j'),('2000-09-20', 8, 'c', 'c'); +CREATE TABLE t3 ( +pk int(11) NOT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +PRIMARY KEY (pk) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t3 VALUES (1, 'c'),(2, 'c'),(3, 'q'),(4, 'g'),(5, 'e'),(6, 'l'), +(7, NULL),(8, 'v'),(9, 'c'),(10, 'u'),(11, 'x'),(12, 'x'),(13, 'x'),(14, 'l'), +(15, 'e'),(16, 's'),(17, 'k'),(18, 'm'),(19, 'x'),(20, 's'); +ANALYZE TABLE t1,t2,t3; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +EXPLAIN SELECT r1.col_date_key +FROM t2 AS r1 +WHERE r1.col_int_key NOT IN +(SELECT ir2.pk +FROM t2 AS ir1 STRAIGHT_JOIN t1 AS ir2 +ON ir2.col_varchar_nokey = ir1.col_varchar_key +WHERE ir2.col_varchar_nokey > r1.col_varchar_nokey +AND ir2.pk IN +(SELECT iir2.pk +FROM t2 AS iir1 RIGHT JOIN t3 AS iir2 +ON iir2.col_varchar_nokey = iir1.col_varchar_key)) +ORDER BY r1.col_date_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY r1 NULL ALL NULL NULL NULL NULL 20 100.00 Using where; Using filesort +2 DEPENDENT SUBQUERY iir2 NULL eq_ref PRIMARY PRIMARY 4 func 1 100.00 Using where; Start temporary; Full scan on NULL key +2 DEPENDENT SUBQUERY iir1 NULL ref col_varchar_key col_varchar_key 7 test.iir2.col_varchar_nokey 1 100.00 Using index +2 DEPENDENT SUBQUERY ir1 NULL index col_varchar_key col_varchar_key 12 NULL 20 100.00 Using where; Using index; Using join buffer (hash join) +2 DEPENDENT SUBQUERY ir2 NULL eq_ref PRIMARY PRIMARY 4 func 1 100.00 Using where; End temporary; Full scan on NULL key +SELECT r1.col_date_key +FROM t2 AS r1 +WHERE r1.col_int_key NOT IN +(SELECT ir2.pk +FROM t2 AS ir1 STRAIGHT_JOIN t1 AS ir2 +ON ir2.col_varchar_nokey = ir1.col_varchar_key +WHERE ir2.col_varchar_nokey > r1.col_varchar_nokey +AND ir2.pk IN +(SELECT iir2.pk +FROM t2 AS iir1 RIGHT JOIN t3 AS iir2 +ON iir2.col_varchar_nokey = iir1.col_varchar_key)) +ORDER BY r1.col_date_key; +col_date_key +2000-04-10 +2000-09-20 +2000-12-03 +2002-10-20 +2002-11-05 +2004-09-18 +2005-09-13 +2006-06-16 +2007-01-08 +2007-06-14 +2007-11-17 +2008-05-03 +2008-06-10 +2008-09-12 +2009-02-23 +SELECT COUNT(r1.col_date_key) AS COUNT_NUM +FROM t2 AS r1 +WHERE r1.col_int_key NOT IN +(SELECT ir2.pk +FROM t2 AS ir1 STRAIGHT_JOIN t1 AS ir2 +ON ir2.col_varchar_nokey = ir1.col_varchar_key +WHERE ir2.col_varchar_nokey > r1.col_varchar_nokey +AND ir2.pk IN +(SELECT iir2.pk +FROM t2 AS iir1 RIGHT JOIN t3 AS iir2 +ON iir2.col_varchar_nokey = iir1.col_varchar_key +WHERE iir2.pk<3)); +COUNT_NUM +15 +DROP TABLE t1,t2,t3; +# +# Bug#20554585 ASSERT JOIN()->TABLES == 0... IN JOIN_TAB::GET_SJ_STRATEGY ON SUBQUERY + VAR +# +CREATE TABLE t1 ( +pk int NOT NULL, +PRIMARY KEY (pk) +); +CREATE TABLE t2 ( +pk int NOT NULL, +col_int_key int, +col_varchar_key varchar(1), +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key) +); +CREATE TABLE t3 ( +pk int NOT NULL, +col_int_key int, +col_varchar_key varchar(1), +col_varchar varchar(1), +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key) +); +INSERT INTO t3 VALUES (1,4,'c','g'),(20,1,'i','p'); +CREATE TABLE t4 ( +col_int int +); +CREATE TABLE t5 ( +col_varchar_key varchar(1), +pk int NOT NULL, +col_int int, +PRIMARY KEY (pk), +KEY col_varchar_key (col_varchar_key) +); +SELECT table1.col_varchar_key AS field1 +FROM (t3 AS table1 +INNER JOIN ( +SELECT SUBQUERY1_t1.* +FROM (t1 AS SUBQUERY1_t1 +RIGHT JOIN (t2 AS SUBQUERY1_t2 +INNER JOIN t3 AS SUBQUERY1_t3 +ON (SUBQUERY1_t3.col_varchar_key = SUBQUERY1_t2.col_varchar_key) +) ON (SUBQUERY1_t3.col_int_key = SUBQUERY1_t2.pk) +) +WHERE SUBQUERY1_t2.col_varchar_key >= ANY ( +SELECT CHILD_SUBQUERY1_t2.col_varchar AS CHILD_SUBQUERY1_field1 +FROM (t2 AS CHILD_SUBQUERY1_t1 +LEFT OUTER JOIN t3 AS CHILD_SUBQUERY1_t2 +ON (CHILD_SUBQUERY1_t2.col_int_key = CHILD_SUBQUERY1_t1.col_int_key) +) +WHERE CHILD_SUBQUERY1_t1.pk >= SUBQUERY1_t2.pk +) +) AS table2 +ON (table2.pk = table1.pk) +) +WHERE (EXISTS (( +SELECT DISTINCT SUBQUERY2_t2.col_int AS SUBQUERY2_field1 +FROM (t4 AS SUBQUERY2_t1 +LEFT OUTER JOIN t5 AS SUBQUERY2_t2 +ON (SUBQUERY2_t2.pk = SUBQUERY2_t1.col_int) +) +WHERE SUBQUERY2_t2.col_varchar_key != @var4 +))) +AND table1.col_int_key < (35 + 192) +ORDER BY field1 +; +field1 +DROP TABLE t1, t2, t3, t4, t5; +# +# Bug#18892055: MISSING DATA ON SELECT ... IN WITH JOINS AND INNODB +# ENGINE +# +CREATE TABLE t1 ( +col_int_key INT, +pk INT NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +) ENGINE = INNODB; +INSERT INTO t1 VALUES +( 0, 3 ), +( 0, 4 ), +( 3, 1 ), +( 900000000, 2 ), +( 1368719360, 5 ), +( 1922236416, 6 ), +( 8,7 ); +CREATE TABLE t2 ( +pk INT NOT NULL, +col_int INT, +PRIMARY KEY (pk) +) ENGINE = INNODB; +INSERT INTO t2 VALUES +( 1, 3 ), +( 2, 2 ), +( 3, 8 ), +( 4, 7 ); +CREATE TABLE t3 ( +col_int_key INT, +col_int INT, +KEY (col_int_key) +) ENGINE = INNODB; +INSERT INTO t3 VALUES +( 5, 1 ), +( -1, -1 ), +( 300000000, 1 ), +( 8, 1 ); +CREATE TABLE t4 ( col_int_key INT ) ENGINE = INNODB; +INSERT INTO t4 VALUES +(0), +(3), +(8), +(900000000), +(1368719360), +(1922236416); +ANALYZE TABLE t1, t2, t3, t4; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +test.t4 analyze status OK +explain SELECT * +FROM t4 +WHERE (col_int_key) IN ( +SELECT t1.col_int_key +FROM t1 LEFT JOIN ( t2 JOIN t3 ON t3.col_int_key = t2.col_int ) USING ( pk ) +WHERE t3.col_int IS NULL +) +ORDER BY col_int_key +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index col_int_key col_int_key 5 NULL 7 100.00 Using index; Using temporary; Using filesort; Start temporary +1 SIMPLE t4 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.pk 1 100.00 NULL +1 SIMPLE t3 NULL ALL col_int_key NULL NULL NULL 4 25.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`col_int_key` AS `col_int_key` from `test`.`t4` semi join (`test`.`t1` left join (`test`.`t2` join `test`.`t3`) on(((`test`.`t1`.`pk` = `test`.`t2`.`pk`) and (`test`.`t3`.`col_int_key` = `test`.`t2`.`col_int`)))) where ((`test`.`t4`.`col_int_key` = `test`.`t1`.`col_int_key`) and (`test`.`t3`.`col_int` is null)) order by `test`.`t4`.`col_int_key` +explain format=tree SELECT * +FROM t4 +WHERE (col_int_key) IN ( +SELECT t1.col_int_key +FROM t1 LEFT JOIN ( t2 JOIN t3 ON t3.col_int_key = t2.col_int ) USING ( pk ) +WHERE t3.col_int IS NULL +) +ORDER BY col_int_key +; +EXPLAIN +-> Sort: t4.col_int_key + -> Stream results (cost=7.85 rows=7) + -> Remove duplicate t4 rows using temporary table (weedout) (cost=7.85 rows=7) + -> Filter: (t3.col_int is null) (cost=7.85 rows=7) + -> Nested loop left join (cost=7.85 rows=7) + -> Inner hash join (t4.col_int_key = t1.col_int_key) (cost=5.40 rows=7) + -> Table scan on t4 (cost=0.05 rows=6) + -> Hash + -> Index scan on t1 using col_int_key (cost=0.95 rows=7) + -> Nested loop inner join (cost=1.21 rows=1) + -> Single-row index lookup on t2 using PRIMARY (pk=t1.pk) (cost=0.26 rows=1) + -> Filter: (t3.col_int_key = t2.col_int) (cost=0.65 rows=1) + -> Table scan on t3 (cost=0.65 rows=4) + +SELECT * +FROM t4 +WHERE (col_int_key) IN ( +SELECT t1.col_int_key +FROM t1 LEFT JOIN ( t2 JOIN t3 ON t3.col_int_key = t2.col_int ) USING ( pk ) +WHERE t3.col_int IS NULL +) +ORDER BY col_int_key +; +col_int_key +0 +3 +8 +900000000 +1368719360 +1922236416 +DROP TABLE t1, t2, t3, t4; +# +# Bug#20835095 CRASH AT CREATE_REF_FOR_KEY IN SQL/SQL_SELECT.CC +# +CREATE TABLE t1 ( +pk INTEGER, +var_10_latin1 VARCHAR(10) CHARACTER SET latin1, +var_255_utf8 VARCHAR(255) CHARACTER SET utf8, +var_255_latin1 VARCHAR(255) CHARACTER SET latin1, +var_10_utf8 VARCHAR(10) CHARACTER SET utf8, +PRIMARY KEY (pk) +); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +CREATE VIEW v1 AS SELECT * FROM t1; +INSERT INTO t1 VALUES +(1,'FROCJ','korrhrspki','UAYVL','BPZIS'), +(2,'him','a','CHYKN','OZZQT'), +(3,'WBITK','ULWBF','have','rhrh'), +(4,'or','right','up','it'), +(5,'GGDCP','x','who','as'), +(6,'j','i','e','w'); +CREATE TABLE tv +SELECT var_255_utf8 AS field1 +FROM t1; +EXPLAIN SELECT * FROM tv +WHERE field1 IN ( +SELECT tv1.var_255_utf8 +FROM v1 AS tv1 LEFT JOIN v1 AS tv2 ON tv1.var_10_latin1=tv2.var_10_utf8); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 6 100.00 Start temporary +1 SIMPLE tv NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 6 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`tv`.`field1` AS `field1` from `test`.`tv` semi join (`test`.`t1` left join (`test`.`t1`) on((`test`.`t1`.`var_10_latin1` = `test`.`t1`.`var_10_utf8`))) where (`test`.`tv`.`field1` = `test`.`t1`.`var_255_utf8`) +SELECT * FROM tv +WHERE field1 IN ( +SELECT tv1.var_255_utf8 +FROM v1 AS tv1 LEFT JOIN v1 AS tv2 ON tv1.var_10_latin1=tv2.var_10_utf8); +field1 +korrhrspki +a +ULWBF +right +x +i +DROP VIEW v1; +DROP TABLE t1, tv; +# 17832047 Crash in calculate_materialization_costs +CREATE TABLE t1(a INTEGER PRIMARY KEY); +INSERT INTO t1 VALUES (0),(1),(2); +SELECT 1 FROM t1 +WHERE 1 IN +(SELECT 1 BETWEEN (LENGTH(a) IN (SELECT 1 FROM t1)) AND 1 +FROM t1 +); +1 +1 +1 +1 +DROP TABLE t1; +# 17845989 Assertion failed: !(used_tables() & ... +CREATE TABLE a(b INTEGER) engine=innodb; +CREATE TABLE c(a INTEGER) engine=innodb; +SELECT 1 +FROM a +WHERE 1 IN (SELECT (a.b IS NULL) IN (SELECT 1 FROM c) FROM c) +; +1 +DROP TABLE a, c; +# +# Bug#18194196: OPTIMIZER EXECUTES STATEMENT INPERFORMANT +# +CREATE TABLE t1 (uid INTEGER, fid INTEGER, INDEX(uid)); +INSERT INTO t1 VALUES +(1,1), (1,2), (1,3), (1,4), +(2,5), (2,6), (2,7), (2,8), +(3,1), (3,2), (3,9); +CREATE TABLE t2 (uid INT PRIMARY KEY, name VARCHAR(128), INDEX(name)); +INSERT INTO t2 VALUES +(1, "A"), (2, "B"), (3, "C"), (4, "D"), (5, "E"), +(6, "F"), (7, "G"), (8, "H"), (9, "I"); +CREATE TABLE t3 (uid INT, fid INT, INDEX(uid)); +INSERT INTO t3 VALUES +(1,1), (1,2), (1,3),(1,4), +(2,5), (2,6), (2,7), (2,8), +(3,1), (3,2), (3,9); +CREATE TABLE t4 (uid INT PRIMARY KEY, name VARCHAR(128), INDEX(name)); +INSERT INTO t4 VALUES +(1, "A"), (2, "B"), (3, "C"), (4, "D"), (5, "E"), +(6, "F"), (7, "G"), (8, "H"), (9, "I"); +ANALYZE TABLE t1,t2,t3,t4; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +test.t4 analyze status OK +EXPLAIN SELECT name FROM t2, t1 +WHERE t1.uid IN (SELECT t4.uid FROM t4, t3 WHERE t3.uid=1 AND t4.uid=t3.fid) +AND t2.uid=t1.fid; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ref uid uid 5 const 4 100.00 Using where; Start temporary +1 SIMPLE t4 NULL eq_ref PRIMARY PRIMARY 4 test.t3.fid 1 100.00 Using index +1 SIMPLE t1 NULL ref uid uid 5 test.t3.fid 4 100.00 Using where; End temporary +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.fid 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`name` AS `name` from `test`.`t4` join `test`.`t2` join `test`.`t1` semi join (`test`.`t3`) where ((`test`.`t4`.`uid` = `test`.`t3`.`fid`) and (`test`.`t1`.`uid` = `test`.`t3`.`fid`) and (`test`.`t3`.`uid` = 1) and (`test`.`t2`.`uid` = `test`.`t1`.`fid`)) +FLUSH STATUS; +SELECT name FROM t2, t1 +WHERE t1.uid IN (SELECT t4.uid FROM t4, t3 WHERE t3.uid=1 AND t4.uid=t3.fid) +AND t2.uid=t1.fid; +name +A +A +B +B +C +D +E +F +G +H +I +SHOW STATUS LIKE '%handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 20 +Handler_read_last 0 +Handler_read_next 15 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +DROP TABLE t1,t2,t3,t4; +# End of test for Bug#18194196 +# +# Bug#21184091 ASSERT `READ_ROWS >= 0.0' AT +# COST_MODEL_SERVER::TMPTABLE_READWRITE_COST() +# +CREATE TABLE t1 ( +pk INTEGER, +col_varchar varchar(1), +col_int INTEGER, +PRIMARY KEY (pk) +) ENGINE=MyISAM; +CREATE TABLE t2 ( +col_int INTEGER, +col_varchar varchar(1) +) ENGINE=MyISAM; +INSERT INTO t2 VALUES (7,'x'); +INSERT INTO t2 VALUES (4,'z'); +SELECT t2.col_varchar +FROM t2 STRAIGHT_JOIN t1 ON t2.col_varchar = t1.col_varchar +JOIN t2 AS table3 ON t1.pk = table3.col_int +WHERE t1.pk IN (SELECT col_int FROM t1); +col_varchar +DROP TABLE t1,t2; +# End of test for Bug#21184091 +# Bug#21139722: Assertion failed: !(used_tables() & ((table_map) 1) ... +CREATE TABLE t1(a INTEGER) engine=innodb; +CREATE TABLE t2(b INTEGER) engine=innodb; +explain SELECT 1 +FROM (SELECT 1 IN (SELECT 1 +FROM t1 +WHERE (SELECT 1 FROM t2 HAVING b) NOT IN (SELECT 1 FROM t2) +) +FROM t2 +) AS z; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DERIVED t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +3 DEPENDENT SUBQUERY t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +5 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +4 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1276 Field or reference 'b' of SELECT #4 was resolved in SELECT #2 +Note 1003 /* select#1 */ select 1 AS `1` from (/* select#2 */ select (1,(/* select#3 */ select 1 from `test`.`t1` where ((/* select#4 */ select 1 from `test`.`t2` having (0 <> `test`.`t2`.`b`)),(/* select#5 */ select 1 from `test`.`t2` where (outer_field_is_not_null, (((/* select#4 */ select 1 from `test`.`t2` having (0 <> `test`.`t2`.`b`))) = 1), true)) is false))) AS `1 IN (SELECT 1 +FROM t1 +WHERE (SELECT 1 FROM t2 HAVING b) NOT IN (SELECT 1 FROM t2) +)` from `test`.`t2`) `z` +SELECT 1 +FROM (SELECT 1 IN (SELECT 1 +FROM t1 +WHERE (SELECT 1 FROM t2 HAVING b) NOT IN (SELECT 1 FROM t2) +) +FROM t2 +) AS z; +1 +DROP TABLE t1, t2; +CREATE TABLE t1(a INTEGER) engine=innodb; +explain SELECT (SELECT a FROM t1 AS t2 +WHERE a IN (SELECT t1.a+t2.a FROM t1 AS t3)) +FROM t1 AS t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +2 DEPENDENT SUBQUERY t3 NULL ALL NULL NULL NULL NULL 1 100.00 End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #3 was resolved in SELECT #1 +Note 1276 Field or reference 'test.t2.a' of SELECT #3 was resolved in SELECT #2 +Note 1003 /* select#1 */ select (/* select#2 */ select `test`.`t2`.`a` from `test`.`t1` `t2` semi join (`test`.`t1` `t3`) where (`test`.`t2`.`a` = (`test`.`t1`.`a` + `test`.`t2`.`a`))) AS `(SELECT a FROM t1 AS t2 +WHERE a IN (SELECT t1.a+t2.a FROM t1 AS t3))` from `test`.`t1` +SELECT (SELECT a FROM t1 AS t2 +WHERE a IN (SELECT t1.a+t2.a FROM t1 AS t3)) +FROM t1 AS t1; +(SELECT a FROM t1 AS t2 +WHERE a IN (SELECT t1.a+t2.a FROM t1 AS t3)) +DROP TABLE t1; +# End of test for Bug#21139722 +SET DEFAULT_STORAGE_ENGINE=INNODB; +# +# Bug#21139402 ASSERTION FAILED: LENGTH > 0 && KEYPARTS != 0, CRASH IN JOIN::OPTIMIZE_KEYUSE +# +CREATE TABLE t1 (a INT, b INT, PRIMARY KEY(a)); +CREATE TABLE t2 (c INT PRIMARY KEY); +EXPLAIN SELECT 1 FROM t1 +WHERE 1 IN +(SELECT (c IS NULL) IN (SELECT a FROM t1 WHERE b) FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +3 SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` semi join (`test`.`t2`) where false +SELECT 1 FROM t1 +WHERE 1 IN +(SELECT (c IS NULL) IN (SELECT a FROM t1 WHERE b) FROM t2); +1 +DROP TABLE t1,t2; +# +# Bug#21619634 ACCESS OF DEALLOCATED ITEM_OUTER_REF CAUSES CRASH: PREPARED STMT +# +create table cc (i int) engine="innodb"; +insert into cc values (1); +select (select count(i) from cc as cc_alias +where (cc.i in (select cc_alias.i from cc))) +from cc group by i; +(select count(i) from cc as cc_alias +where (cc.i in (select cc_alias.i from cc))) +1 +prepare stmt from +"select (select count(i) from cc as cc_alias + where (cc.i in (select cc_alias.i from cc))) + from cc group by i"; +execute stmt; +(select count(i) from cc as cc_alias + where (cc.i in (select cc_alias.i from cc))) +1 +execute stmt; +(select count(i) from cc as cc_alias + where (cc.i in (select cc_alias.i from cc))) +1 +drop table cc; +# +# Bug #22305361: QUERY WITH MATERIALIZED TABLE RETURNS INCORRECT +# RESULTS IN 5.6 +# +CREATE TABLE t(a INT,b INT); +INSERT INTO t VALUES (1,0),(1,0),(1,0),(1,0),(1,1); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +EXPLAIN SELECT * +FROM t AS t1 +WHERE t1.a IN (SELECT t2.a +FROM t AS t2 +WHERE CONCAT(t2.a,'') NOT IN (SELECT t3.a +FROM t AS t3 +WHERE t3.b=1)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 5 100.00 Using where; Start temporary +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 5 20.00 Using where; End temporary; Using join buffer (hash join) +3 DEPENDENT SUBQUERY t3 NULL ALL NULL NULL NULL NULL 5 20.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t` `t1` semi join (`test`.`t` `t2`) where ((`test`.`t1`.`a` = `test`.`t2`.`a`) and (concat(`test`.`t2`.`a`,''),(/* select#3 */ select `test`.`t3`.`a` from `test`.`t` `t3` where ((`test`.`t3`.`b` = 1) and (outer_field_is_not_null, (((concat(`test`.`t2`.`a`,'')) = `test`.`t3`.`a`) or (`test`.`t3`.`a` is null)), true)) having (outer_field_is_not_null, (`test`.`t3`.`a`), true)) is false)) +SELECT * +FROM t AS t1 +WHERE t1.a IN (SELECT t2.a +FROM t AS t2 +WHERE CONCAT(t2.a,'') NOT IN (SELECT t3.a +FROM t AS t3 +WHERE t3.b=1)); +a b +DROP TABLE t; +# +# Bug#24287772 SUBQUERY RETURNS EMPTY LIST WHILE IDENTICAL QUERY +# WITH JOIN RETURNS RESULT +# +CREATE TABLE t SELECT 4096 c; +SELECT c FROM t WHERE 1 IN +(SELECT t.c = page_size FROM information_schema.innodb_cmpmem); +c +4096 +DROP TABLE t; +# +# Bug #29132639: WL#12470: SIG 6 IN CONNECTJOINS|SQL/SQL_EXECUTOR.C +# +CREATE TABLE t1 ( f1 TIME, f2 VARCHAR(1) ); +INSERT INTO t1 VALUES ('08:35:24', 'X'), ('14:51:13', 'S'), ('11:22:33', 'Q'); +CREATE TABLE t2 ( pk INTEGER ); +INSERT INTO t2 VALUES (1), (2); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN FORMAT=tree SELECT * FROM t1 WHERE EXISTS ( SELECT alias1.f2 FROM t2 LEFT JOIN t1 ON 1 LEFT JOIN t1 AS alias1 ON 1 ); +EXPLAIN +-> Inner hash join (no condition) (cost=9.35 rows=54) + -> Table scan on t1 (cost=0.55 rows=3) + -> Hash + -> Limit: 1 row(s) (cost=3.70 rows=18) + -> Left hash join (no condition) (cost=3.70 rows=18) + -> Left hash join (no condition) (cost=1.12 rows=6) + -> Table scan on t2 (cost=0.45 rows=2) + -> Hash + -> Table scan on t1 (cost=0.28 rows=3) + -> Hash + -> Table scan on alias1 (cost=1.65 rows=3) + +SELECT * FROM t1 WHERE EXISTS ( SELECT alias1.f2 FROM t2 LEFT JOIN t1 ON 1 LEFT JOIN t1 AS alias1 ON 1 ); +f1 f2 +08:35:24 X +11:22:33 Q +14:51:13 S +DROP TABLE t1, t2; +set optimizer_switch=default; diff --git a/mysql-test/r/subquery_sj_loosescan_bka.result-pq b/mysql-test/r/subquery_sj_loosescan_bka.result-pq new file mode 100644 index 000000000000..7b7a609ceac0 --- /dev/null +++ b/mysql-test/r/subquery_sj_loosescan_bka.result-pq @@ -0,0 +1,12909 @@ +set optimizer_switch='batched_key_access=on,mrr_cost_based=off'; +set optimizer_switch='semijoin=on,loosescan=on'; +set @old_opt_switch=@@optimizer_switch; +set optimizer_switch='subquery_materialization_cost_based=off'; +drop table if exists t0, t1, t2, t10, t11, t12; +create table t1 (a int not null, b int, primary key (a)); +create table t2 (a int not null, primary key (a)); +create table t3 (a int not null, b int, primary key (a)); +insert into t1 values (1,10), (2,20), (3,30), (4,40); +insert into t2 values (2), (3), (4), (5); +insert into t3 values (10,3), (20,4), (30,5); +select * from t2 where t2.a in (select a from t1); +a +2 +3 +4 +explain select * from t2 where t2.a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index PRIMARY PRIMARY 4 NULL 4 100.00 Using index +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t1` join `test`.`t2` where (`test`.`t1`.`a` = `test`.`t2`.`a`) +select * from t2 where t2.a in (select a from t1 where t1.b <> 30); +a +2 +4 +explain select * from t2 where t2.a in (select a from t1 where t1.b <> 30); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL PRIMARY NULL NULL NULL 4 75.00 Using where +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`a` = `test`.`t1`.`a`) and (`test`.`t1`.`b` <> 30)) +select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a); +a +2 +3 +explain select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL index PRIMARY PRIMARY 4 NULL 3 100.00 Using index +1 SIMPLE t1 NULL ALL PRIMARY NULL NULL NULL 4 25.00 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t1` join `test`.`t3` join `test`.`t2` where ((`test`.`t2`.`a` = `test`.`t1`.`a`) and (`test`.`t1`.`b` = `test`.`t3`.`a`)) +drop table t1, t2, t3; +create table t1 (a int, b int, index a (a,b)); +create table t2 (a int, index a (a)); +create table t3 (a int, b int, index a (a)); +insert into t1 values (1,10), (2,20), (3,30), (4,40); +create table t0(a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +insert into t1 +select rand()*100000+200,rand()*100000 from t0 A, t0 B, t0 C, t0 D; +insert into t2 values (2), (3), (4), (5); +insert into t3 values (10,3), (20,4), (30,5); +select * from t2 where t2.a in (select a from t1); +a +2 +3 +4 +explain select * from t2 where t2.a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index a a 10 NULL 10004 100.00 Using index; LooseScan +1 SIMPLE t2 NULL index a a 5 NULL 4 25.00 Using where; Using index; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1`) where (`test`.`t2`.`a` = `test`.`t1`.`a`) +select * from t2 where t2.a in (select a from t1 where t1.b <> 30); +a +2 +4 +explain select * from t2 where t2.a in (select a from t1 where t1.b <> 30); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index a a 10 NULL 10004 90.00 Using where; Using index; LooseScan +1 SIMPLE t2 NULL index a a 5 NULL 4 25.00 Using where; Using index; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1`) where ((`test`.`t2`.`a` = `test`.`t1`.`a`) and (`test`.`t1`.`b` <> 30)) +select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a); +a +2 +3 +explain select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index a a 10 NULL 10004 100.00 Using where; Using index; LooseScan +1 SIMPLE t3 NULL ref a a 5 test.t1.b 2 100.00 Using index; FirstMatch(t1) +1 SIMPLE t2 NULL index a a 5 NULL 4 25.00 Using where; Using index; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1` join `test`.`t3`) where ((`test`.`t2`.`a` = `test`.`t1`.`a`) and (`test`.`t3`.`a` = `test`.`t1`.`b`)) +insert into t1 values (3,31); +select * from t2 where t2.a in (select a from t1 where t1.b <> 30); +a +2 +3 +4 +select * from t2 where t2.a in (select a from t1 where t1.b <> 30 and t1.b <> 31); +a +2 +4 +explain select * from t2 where t2.a in (select a from t1 where t1.b <> 30); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index a a 10 NULL 10005 90.00 Using where; Using index; LooseScan +1 SIMPLE t2 NULL index a a 5 NULL 4 25.00 Using where; Using index; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1`) where ((`test`.`t2`.`a` = `test`.`t1`.`a`) and (`test`.`t1`.`b` <> 30)) +drop table t0, t1, t2, t3; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1(a int, b int); +insert into t1 values (0,0),(1,1),(2,2); +create table t2 as select * from t1; +create table t11(a int, b int); +create table t10 (pk int, a int, primary key(pk)); +insert into t10 select a,a from t0; +create table t12 like t10; +insert into t12 select * from t10; +Flattened because of dependency, t10=func(t1) +explain select * from t1 where a in (select pk from t10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t1` where (`test`.`t10`.`pk` = `test`.`t1`.`a`) +select * from t1 where a in (select pk from t10); +a b +0 0 +1 1 +2 2 +A confluent case of dependency +explain select * from t1 where a in (select a from t10 where pk=12); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t1` where (multiple equal(12, NULL) and multiple equal(`test`.`t1`.`a`, NULL)) +select * from t1 where a in (select a from t10 where pk=12); +a b +explain select * from t1 where a in (select a from t10 where pk=9); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t10 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t1` where ((`test`.`t1`.`a` = '9')) +select * from t1 where a in (select a from t10 where pk=9); +a b +An empty table inside +explain select * from t1 where a in (select a from t11); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t11 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t11`) where (`test`.`t1`.`a` = `test`.`t11`.`a`) +select * from t1 where a in (select a from t11); +a b +explain select * from t1 where a in (select pk from t10) and b in (select pk from t10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using index +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.t1.b 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t10` join `test`.`t1` where ((`test`.`t10`.`pk` = `test`.`t1`.`b`) and (`test`.`t10`.`pk` = `test`.`t1`.`a`)) +select * from t1 where a in (select pk from t10) and b in (select pk from t10); +a b +0 0 +1 1 +2 2 +flattening a nested subquery +explain select * from t1 where a in (select pk from t10 where t10.a in (select pk from t12)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using where +1 SIMPLE t12 NULL eq_ref PRIMARY PRIMARY 4 test.t10.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t12` join `test`.`t1` where ((`test`.`t10`.`pk` = `test`.`t1`.`a`) and (`test`.`t12`.`pk` = `test`.`t10`.`a`)) +select * from t1 where a in (select pk from t10 where t10.a in (select pk from t12)); +a b +0 0 +1 1 +2 2 +flattening subquery w/ several tables +explain select * from t1 where a in (select t10.pk from t10, t12 where t12.pk=t10.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using where +1 SIMPLE t12 NULL eq_ref PRIMARY PRIMARY 4 test.t10.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t12` join `test`.`t1` where ((`test`.`t10`.`pk` = `test`.`t1`.`a`) and (`test`.`t12`.`pk` = `test`.`t10`.`a`)) +subqueries within outer joins go into ON expr. +explain +select * from t1 left join (t2 A, t2 B) on ( A.A= t1.A and B.A in (select pk from t10)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE A NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE B NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.B.A 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`A` AS `A`,`test`.`t1`.`B` AS `B`,`test`.`A`.`A` AS `A`,`test`.`A`.`B` AS `B`,`test`.`B`.`A` AS `A`,`test`.`B`.`B` AS `B` from `test`.`t1` left join (`test`.`t10` join `test`.`t2` `A` join `test`.`t2` `B`) on(((`test`.`t10`.`pk` = `test`.`B`.`A`) and (`test`.`A`.`A` = `test`.`t1`.`A`))) where true +t2 should be wrapped into OJ-nest, so we have "t1 LJ (t2 J t10)" +explain +select * from t1 left join t2 on (t2.A= t1.A and t2.A in (select pk from t10)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.t1.A 1 100.00 Using index +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`A` AS `A`,`test`.`t1`.`B` AS `B`,`test`.`t2`.`A` AS `A`,`test`.`t2`.`B` AS `B` from `test`.`t1` left join (`test`.`t10` join `test`.`t2`) on(((`test`.`t10`.`pk` = `test`.`t1`.`A`) and (`test`.`t2`.`A` = `test`.`t1`.`A`))) where true +we shouldn't flatten if we're going to get a join of > MAX_TABLES. +explain select * from +t1 s00, t1 s01, t1 s02, t1 s03, t1 s04,t1 s05,t1 s06,t1 s07,t1 s08,t1 s09, +t1 s10, t1 s11, t1 s12, t1 s13, t1 s14,t1 s15,t1 s16,t1 s17,t1 s18,t1 s19, +t1 s20, t1 s21, t1 s22, t1 s23, t1 s24,t1 s25,t1 s26,t1 s27,t1 s28,t1 s29, +t1 s30, t1 s31, t1 s32, t1 s33, t1 s34,t1 s35,t1 s36,t1 s37,t1 s38,t1 s39, +t1 s40, t1 s41, t1 s42, t1 s43, t1 s44,t1 s45,t1 s46,t1 s47,t1 s48,t1 s49 +where +s00.a in ( +select m00.a from +t1 m00, t1 m01, t1 m02, t1 m03, t1 m04,t1 m05,t1 m06,t1 m07,t1 m08,t1 m09, +t1 m10, t1 m11, t1 m12, t1 m13, t1 m14,t1 m15,t1 m16,t1 m17,t1 m18,t1 m19 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY s00 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 PRIMARY s01 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s02 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s03 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s04 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s05 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s06 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s07 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s08 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s09 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s10 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s11 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s12 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s13 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s14 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s15 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s16 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s17 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s18 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s19 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s20 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s21 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s22 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s23 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s24 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s25 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s26 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s27 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s28 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s29 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s30 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s31 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s32 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s33 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s34 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s35 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s36 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s37 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s38 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s39 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s40 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s41 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s42 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s43 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s44 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s45 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s46 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s47 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s48 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s49 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m00 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +2 DEPENDENT SUBQUERY m01 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m02 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m03 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m04 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m05 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m06 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m07 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m08 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m09 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m10 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m11 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m12 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m13 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m14 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m15 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m16 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m17 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m18 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m19 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`s00`.`a` AS `a`,`test`.`s00`.`b` AS `b`,`test`.`s01`.`a` AS `a`,`test`.`s01`.`b` AS `b`,`test`.`s02`.`a` AS `a`,`test`.`s02`.`b` AS `b`,`test`.`s03`.`a` AS `a`,`test`.`s03`.`b` AS `b`,`test`.`s04`.`a` AS `a`,`test`.`s04`.`b` AS `b`,`test`.`s05`.`a` AS `a`,`test`.`s05`.`b` AS `b`,`test`.`s06`.`a` AS `a`,`test`.`s06`.`b` AS `b`,`test`.`s07`.`a` AS `a`,`test`.`s07`.`b` AS `b`,`test`.`s08`.`a` AS `a`,`test`.`s08`.`b` AS `b`,`test`.`s09`.`a` AS `a`,`test`.`s09`.`b` AS `b`,`test`.`s10`.`a` AS `a`,`test`.`s10`.`b` AS `b`,`test`.`s11`.`a` AS `a`,`test`.`s11`.`b` AS `b`,`test`.`s12`.`a` AS `a`,`test`.`s12`.`b` AS `b`,`test`.`s13`.`a` AS `a`,`test`.`s13`.`b` AS `b`,`test`.`s14`.`a` AS `a`,`test`.`s14`.`b` AS `b`,`test`.`s15`.`a` AS `a`,`test`.`s15`.`b` AS `b`,`test`.`s16`.`a` AS `a`,`test`.`s16`.`b` AS `b`,`test`.`s17`.`a` AS `a`,`test`.`s17`.`b` AS `b`,`test`.`s18`.`a` AS `a`,`test`.`s18`.`b` AS `b`,`test`.`s19`.`a` AS `a`,`test`.`s19`.`b` AS `b`,`test`.`s20`.`a` AS `a`,`test`.`s20`.`b` AS `b`,`test`.`s21`.`a` AS `a`,`test`.`s21`.`b` AS `b`,`test`.`s22`.`a` AS `a`,`test`.`s22`.`b` AS `b`,`test`.`s23`.`a` AS `a`,`test`.`s23`.`b` AS `b`,`test`.`s24`.`a` AS `a`,`test`.`s24`.`b` AS `b`,`test`.`s25`.`a` AS `a`,`test`.`s25`.`b` AS `b`,`test`.`s26`.`a` AS `a`,`test`.`s26`.`b` AS `b`,`test`.`s27`.`a` AS `a`,`test`.`s27`.`b` AS `b`,`test`.`s28`.`a` AS `a`,`test`.`s28`.`b` AS `b`,`test`.`s29`.`a` AS `a`,`test`.`s29`.`b` AS `b`,`test`.`s30`.`a` AS `a`,`test`.`s30`.`b` AS `b`,`test`.`s31`.`a` AS `a`,`test`.`s31`.`b` AS `b`,`test`.`s32`.`a` AS `a`,`test`.`s32`.`b` AS `b`,`test`.`s33`.`a` AS `a`,`test`.`s33`.`b` AS `b`,`test`.`s34`.`a` AS `a`,`test`.`s34`.`b` AS `b`,`test`.`s35`.`a` AS `a`,`test`.`s35`.`b` AS `b`,`test`.`s36`.`a` AS `a`,`test`.`s36`.`b` AS `b`,`test`.`s37`.`a` AS `a`,`test`.`s37`.`b` AS `b`,`test`.`s38`.`a` AS `a`,`test`.`s38`.`b` AS `b`,`test`.`s39`.`a` AS `a`,`test`.`s39`.`b` AS `b`,`test`.`s40`.`a` AS `a`,`test`.`s40`.`b` AS `b`,`test`.`s41`.`a` AS `a`,`test`.`s41`.`b` AS `b`,`test`.`s42`.`a` AS `a`,`test`.`s42`.`b` AS `b`,`test`.`s43`.`a` AS `a`,`test`.`s43`.`b` AS `b`,`test`.`s44`.`a` AS `a`,`test`.`s44`.`b` AS `b`,`test`.`s45`.`a` AS `a`,`test`.`s45`.`b` AS `b`,`test`.`s46`.`a` AS `a`,`test`.`s46`.`b` AS `b`,`test`.`s47`.`a` AS `a`,`test`.`s47`.`b` AS `b`,`test`.`s48`.`a` AS `a`,`test`.`s48`.`b` AS `b`,`test`.`s49`.`a` AS `a`,`test`.`s49`.`b` AS `b` from `test`.`t1` `s00` join `test`.`t1` `s01` join `test`.`t1` `s02` join `test`.`t1` `s03` join `test`.`t1` `s04` join `test`.`t1` `s05` join `test`.`t1` `s06` join `test`.`t1` `s07` join `test`.`t1` `s08` join `test`.`t1` `s09` join `test`.`t1` `s10` join `test`.`t1` `s11` join `test`.`t1` `s12` join `test`.`t1` `s13` join `test`.`t1` `s14` join `test`.`t1` `s15` join `test`.`t1` `s16` join `test`.`t1` `s17` join `test`.`t1` `s18` join `test`.`t1` `s19` join `test`.`t1` `s20` join `test`.`t1` `s21` join `test`.`t1` `s22` join `test`.`t1` `s23` join `test`.`t1` `s24` join `test`.`t1` `s25` join `test`.`t1` `s26` join `test`.`t1` `s27` join `test`.`t1` `s28` join `test`.`t1` `s29` join `test`.`t1` `s30` join `test`.`t1` `s31` join `test`.`t1` `s32` join `test`.`t1` `s33` join `test`.`t1` `s34` join `test`.`t1` `s35` join `test`.`t1` `s36` join `test`.`t1` `s37` join `test`.`t1` `s38` join `test`.`t1` `s39` join `test`.`t1` `s40` join `test`.`t1` `s41` join `test`.`t1` `s42` join `test`.`t1` `s43` join `test`.`t1` `s44` join `test`.`t1` `s45` join `test`.`t1` `s46` join `test`.`t1` `s47` join `test`.`t1` `s48` join `test`.`t1` `s49` where (`test`.`s00`.`a`,(/* select#2 */ select `test`.`m00`.`a` from `test`.`t1` `m00` join `test`.`t1` `m01` join `test`.`t1` `m02` join `test`.`t1` `m03` join `test`.`t1` `m04` join `test`.`t1` `m05` join `test`.`t1` `m06` join `test`.`t1` `m07` join `test`.`t1` `m08` join `test`.`t1` `m09` join `test`.`t1` `m10` join `test`.`t1` `m11` join `test`.`t1` `m12` join `test`.`t1` `m13` join `test`.`t1` `m14` join `test`.`t1` `m15` join `test`.`t1` `m16` join `test`.`t1` `m17` join `test`.`t1` `m18` join `test`.`t1` `m19` where ((`test`.`s00`.`a`) = `test`.`m00`.`a`))) +select * from +t1 left join t2 on (t2.a= t1.a and t2.a in (select pk from t10)) +where t1.a < 5; +a b a b +0 0 0 0 +1 1 1 1 +2 2 2 2 +prepare s1 from +' select * from + t1 left join t2 on (t2.a= t1.a and t2.a in (select pk from t10)) + where t1.a < 5'; +execute s1; +a b a b +0 0 0 0 +1 1 1 1 +2 2 2 2 +execute s1; +a b a b +0 0 0 0 +1 1 1 1 +2 2 2 2 +insert into t1 select (A.a + 10 * B.a),1 from t0 A, t0 B; +explain select * from t1 where a in (select pk from t10 where pk<3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t10 NULL range PRIMARY PRIMARY 4 NULL 4 100.00 Using where; Using index +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 103 10.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t1` where ((`test`.`t1`.`a` = `test`.`t10`.`pk`) and (`test`.`t10`.`pk` < 3)) +drop table t0, t1, t2; +drop table t10, t11, t12; +# +# Check that subqueries with outer joins or straight_join work for +# different permutations of const and non-const tables. (Ref. Bug#46692) +# +CREATE TABLE t1 (i INTEGER); +CREATE TABLE t2 (i INTEGER); +CREATE TABLE t3 (i INTEGER); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 0 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 0 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 0 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 1 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 1 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 1 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 2 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 2 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 2 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (0); +DELETE FROM t2; +INSERT INTO t1 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 0 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 0 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 0 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 1 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 1 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 1 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 2 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 2 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 2 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (0); +DELETE FROM t2; +INSERT INTO t1 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 0 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = `test`.`t2`.`i`) and (`test`.`t1`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = `test`.`t2`.`i`) and (`test`.`t1`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = `test`.`t2`.`i`) and (`test`.`t1`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 0 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = `test`.`t2`.`i`) and (`test`.`t1`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = `test`.`t2`.`i`) and (`test`.`t1`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = `test`.`t2`.`i`) and (`test`.`t1`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 0 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t2`.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t2`.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t2`.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +1 +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 1 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = `test`.`t3`.`i`) and (`test`.`t1`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = `test`.`t3`.`i`) and (`test`.`t1`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = `test`.`t3`.`i`) and (`test`.`t1`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 1 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = `test`.`t2`.`i`) and (`test`.`t1`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = `test`.`t2`.`i`) and (`test`.`t1`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = `test`.`t2`.`i`) and (`test`.`t1`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 1 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t2`.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t2`.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t2`.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +1 +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +1 +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 2 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t3`.`i`) and (`test`.`t2`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t3`.`i`) and (`test`.`t2`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t3`.`i`) and (`test`.`t2`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 2 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t3`.`i`) and (`test`.`t2`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t3`.`i`) and (`test`.`t2`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t3`.`i`) and (`test`.`t2`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 2 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t2`.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +1 +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +1 +2 + +EXECUTE stmt; +i +1 +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t2`.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +1 +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t2`.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +1 +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +1 +2 + +EXECUTE stmt; +i +1 +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +1 +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +1 +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (0); +DELETE FROM t2; +INSERT INTO t1 VALUES (0); +DROP TABLE t1, t2, t3; +create table x1(k int primary key, d1 int, d2 int); +create table x2(k int primary key, d1 int, d2 int); +insert into x1 values +(10, 10, 10), +(20, 20, 20), +(21, 20, null), +(30, null, 30), +(40, 40, 40); +insert into x2 values +(10, 10, 10), +(20, 20, 20), +(21, 20, null), +(30, null, 30); +select * +from x1 +where (d1, d2) in (select d1, d2 +from x2); +k d1 d2 +10 10 10 +20 20 20 +select * +from x1 +where (d1, d2) in (select d1, d2 +from x2) is true; +k d1 d2 +10 10 10 +20 20 20 +select * +from x1 +where (d1, d2) in (select d1, d2 +from x2) is false; +k d1 d2 +40 40 40 +select * +from x1 +where (d1, d2) in (select d1, d2 +from x2) is unknown; +k d1 d2 +21 20 NULL +30 NULL 30 +select * +from x1 +where d1 in (select d1 +from x2 +where x1.d2=x2.d2); +k d1 d2 +10 10 10 +20 20 20 +select * +from x1 +where d1 in (select d1 +from x2 +where x1.d2=x2.d2) is true; +k d1 d2 +10 10 10 +20 20 20 +select * +from x1 +where d1 in (select d1 +from x2 +where x1.d2=x2.d2) is false; +k d1 d2 +21 20 NULL +40 40 40 +select * +from x1 +where d1 in (select d1 +from x2 +where x1.d2=x2.d2) is unknown; +k d1 d2 +30 NULL 30 +select * +from x1 +where 1 in (select 1 +from x2 +where x1.d1=x2.d1 and x1.d2=x2.d2); +k d1 d2 +10 10 10 +20 20 20 +select * +from x1 +where 1 in (select 1 +from x2 +where x1.d1=x2.d1 and x1.d2=x2.d2) is true; +k d1 d2 +10 10 10 +20 20 20 +select * +from x1 +where 1 in (select 1 +from x2 +where x1.d1=x2.d1 and x1.d2=x2.d2) is false; +k d1 d2 +21 20 NULL +30 NULL 30 +40 40 40 +select * +from x1 +where 1 in (select 1 +from x2 +where x1.d1=x2.d1 and x1.d2=x2.d2) is unknown; +k d1 d2 +select * +from x1 +where exists (select * +from x2 +where x1.d1=x2.d1 and x1.d2=x2.d2); +k d1 d2 +10 10 10 +20 20 20 +drop table x1; +drop table x2; +CREATE TABLE t1 ( +a int(11) NOT NULL, +b int(11) NOT NULL, +c datetime default NULL, +PRIMARY KEY (a), +KEY idx_bc (b,c) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES +(406989,67,'2006-02-23 17:08:46'), (150078,67,'2005-10-26 11:17:45'), +(406993,67,'2006-02-27 11:20:57'), (245655,67,'2005-12-08 15:59:08'), +(406994,67,'2006-02-27 11:26:46'), (256,67,NULL), +(398341,67,'2006-02-20 04:48:44'), (254,67,NULL),(1120,67,NULL), +(406988,67,'2006-02-23 17:07:22'), (255,67,NULL), +(398340,67,'2006-02-20 04:38:53'),(406631,67,'2006-02-23 10:49:42'), +(245653,67,'2005-12-08 15:59:07'),(406992,67,'2006-02-24 16:47:18'), +(245654,67,'2005-12-08 15:59:08'),(406995,67,'2006-02-28 11:55:00'), +(127261,67,'2005-10-13 12:17:58'),(406991,67,'2006-02-24 16:42:32'), +(245652,67,'2005-12-08 15:58:27'),(398545,67,'2006-02-20 04:53:13'), +(154504,67,'2005-10-28 11:53:01'),(9199,67,NULL),(1,67,'2006-02-23 15:01:35'), +(223456,67,NULL),(4101,67,NULL),(1133,67,NULL), +(406990,67,'2006-02-23 18:01:45'),(148815,67,'2005-10-25 15:34:17'), +(148812,67,'2005-10-25 15:30:01'),(245651,67,'2005-12-08 15:58:27'), +(154503,67,'2005-10-28 11:52:38'); +create table t11 select * from t1 where b = 67 AND (c IS NULL OR c > NOW()) order by 3 asc; +create table t12 select * from t1 where b = 67 AND (c IS NULL OR c > NOW()) order by 3 desc; +create table t21 select * from t1 where b = 67 AND (c IS NULL OR c > '2005-12-08') order by 3 asc; +create table t22 select * from t1 where b = 67 AND (c IS NULL OR c > '2005-12-08') order by 3 desc; +update t22 set c = '2005-12-08 15:58:27' where a = 255; +explain select t21.* from t21,t22 where t21.a = t22.a and +t22.a in (select t12.a from t11, t12 where t11.a in(255,256) and t11.a = t12.a and t11.c is null) and t22.c is null order by t21.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t11 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; Using temporary; Using filesort; Start temporary +1 SIMPLE t12 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; Using join buffer (hash join) +1 SIMPLE t22 NULL ALL NULL NULL NULL NULL 26 3.85 Using where; End temporary; Using join buffer (hash join) +1 SIMPLE t21 NULL ALL NULL NULL NULL NULL 26 10.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t21`.`a` AS `a`,`test`.`t21`.`b` AS `b`,`test`.`t21`.`c` AS `c` from `test`.`t21` join `test`.`t22` semi join (`test`.`t11` join `test`.`t12`) where ((`test`.`t12`.`a` = `test`.`t11`.`a`) and (`test`.`t22`.`a` = `test`.`t11`.`a`) and (`test`.`t21`.`a` = `test`.`t11`.`a`) and (`test`.`t22`.`c` is null) and (`test`.`t11`.`a` in (255,256)) and (`test`.`t11`.`c` is null)) order by `test`.`t21`.`a` +explain format=json select * from t1 where a in (select a from t11); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "6.71" + }, + "duplicates_removal": { + "using_temporary_table": true, + "nested_loop": [ + { + "table": { + "table_name": "t11", + "access_type": "ALL", + "rows_examined_per_scan": 8, + "rows_produced_per_join": 8, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "0.80", + "prefix_cost": "1.31", + "data_read_per_join": "128" + }, + "used_columns": [ + "a" + ] + } + }, + { + "table": { + "table_name": "t1", + "access_type": "eq_ref", + "possible_keys": [ + "PRIMARY" + ], + "key": "PRIMARY", + "used_key_parts": [ + "a" + ], + "key_length": "4", + "ref": [ + "test.t11.a" + ], + "rows_examined_per_scan": 1, + "rows_produced_per_join": 8, + "filtered": "100.00", + "cost_info": { + "read_cost": "2.00", + "eval_cost": "0.80", + "prefix_cost": "6.71", + "data_read_per_join": "128" + }, + "used_columns": [ + "a", + "b", + "c" + ] + } + } + ] + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` semi join (`test`.`t11`) where (`test`.`t1`.`a` = `test`.`t11`.`a`) +select t21.* from t21,t22 where t21.a = t22.a and +t22.a in (select t12.a from t11, t12 where t11.a in(255,256) and t11.a = t12.a and t11.c is null) and t22.c is null order by t21.a; +a b c +256 67 NULL +drop table t1, t11, t12, t21, t22; +create table t1(a int); +insert into t1 values (0),(1); +explain +select (select max(y.a) from t1 y where a in (select a from t1 z) and a < x.a) as subq from t1 x; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY x NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DEPENDENT SUBQUERY y NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +2 DEPENDENT SUBQUERY z NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.x.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select (/* select#2 */ select max(`test`.`y`.`a`) from `test`.`t1` `y` semi join (`test`.`t1` `z`) where ((`test`.`z`.`a` = `test`.`y`.`a`) and (`test`.`y`.`a` < `test`.`x`.`a`))) AS `subq` from `test`.`t1` `x` +select (select max(y.a) from t1 y where a in (select a from t1 z) and a < x.a) as subq from t1 x; +subq +NULL +0 +drop table t1; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 as select * from t0; +insert into t1 select a+10 from t0; +insert into t0 values(2); +explain select * from t1 where 2 in (select a from t0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 11 10.00 Using where; Start temporary; End temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 20 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t0`) where (`test`.`t0`.`a` = 2) +select * from t1 where 2 in (select a from t0); +a +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +explain select * from (select a from t0) x where a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 20 100.00 Start temporary +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 11 10.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a` from `test`.`t0` semi join (`test`.`t1`) where (`test`.`t0`.`a` = `test`.`t1`.`a`) +explain format=json select * from (select a from t0) x where a in (select a from t1); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "28.32" + }, + "duplicates_removal": { + "using_temporary_table": true, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 20, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "2.00", + "prefix_cost": "2.51", + "data_read_per_join": "160" + }, + "used_columns": [ + "a" + ] + } + }, + { + "table": { + "table_name": "t0", + "access_type": "ALL", + "rows_examined_per_scan": 11, + "rows_produced_per_join": 1, + "filtered": "10.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.11", + "prefix_cost": "28.32", + "data_read_per_join": "8" + }, + "used_columns": [ + "a" + ], + "attached_condition": "(`test`.`t0`.`a` = `test`.`t1`.`a`)" + } + } + ] + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a` from `test`.`t0` semi join (`test`.`t1`) where (`test`.`t0`.`a` = `test`.`t1`.`a`) +drop table t0, t1; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (kp1 int, kp2 int, c int, filler char(100), key(kp1, kp2)); +insert into t1 select A.a+10*(B.a+10*C.a), 0, 0, 'filler' from t0 A, t0 B, t0 C; +insert into t1 select * from t1 where kp1 < 20; +create table t3 (a int); +insert into t3 select A.a + 10*B.a from t0 A, t0 B; +explain select * from t3 where a in (select kp1 from t1 where kp1<20); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range kp1 kp1 5 NULL 48 100.00 Using where; Using index; LooseScan +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 100 10.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a` from `test`.`t3` semi join (`test`.`t1`) where ((`test`.`t3`.`a` = `test`.`t1`.`kp1`) and (`test`.`t1`.`kp1` < 20)) +select * from t3 where a in (select kp1 from t1 where kp1<20); +a +0 +1 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +2 +3 +4 +5 +6 +7 +8 +9 +explain select * from t3 where a in (select kp1 from t1 where kp1<20) and a<20; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range kp1 kp1 5 NULL 48 100.00 Using where; Using index; LooseScan +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 100 3.33 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a` from `test`.`t3` semi join (`test`.`t1`) where ((`test`.`t3`.`a` = `test`.`t1`.`kp1`) and (`test`.`t1`.`kp1` < 20) and (`test`.`t1`.`kp1` < 20)) +select * from t3 where a in (select kp1 from t1 where kp1<20) and a<20; +a +0 +1 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +2 +3 +4 +5 +6 +7 +8 +9 +create table t4 (pk int primary key); +insert into t4 select a from t3; +explain select * from t3 where a in +(select t1.kp1 from t1,t4 where kp1<20 and t4.pk=t1.c); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range kp1 kp1 5 NULL 48 100.00 Using where; LooseScan +1 SIMPLE t4 NULL eq_ref PRIMARY PRIMARY 4 test.t1.c 1 100.00 Using index; FirstMatch(t1) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 100 10.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a` from `test`.`t3` semi join (`test`.`t1` join `test`.`t4`) where ((`test`.`t3`.`a` = `test`.`t1`.`kp1`) and (`test`.`t4`.`pk` = `test`.`t1`.`c`) and (`test`.`t1`.`kp1` < 20)) +explain format=tree select * from t3 where a in +(select t1.kp1 from t1,t4 where kp1<20 and t4.pk=t1.c); +EXPLAIN +-> Inner hash join (t3.a = t1.kp1) (cost=519.20 rows=480) + -> Table scan on t3 (cost=1.54 rows=100) + -> Hash + -> Nested loop semijoin with duplicate removal on kp1 (cost=38.66 rows=48) + -> Filter: ((t1.kp1 < 20) and (t1.c is not null)) (cost=21.86 rows=48) + -> Index range scan on t1 using kp1 (cost=21.86 rows=48) + -> Single-row index lookup on t4 using PRIMARY (pk=t1.c) (cost=0.25 rows=1) + +select * from t3 where a in +(select t1.kp1 from t1,t4 where kp1<20 and t4.pk=t1.c); +a +0 +1 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +2 +3 +4 +5 +6 +7 +8 +9 +drop table t1, t3, t4; +create table t1 (a int); +insert into t1 values (0),(0),(0),(1),(1),(1),(2),(2),(2),(3),(3),(3); +set session internal_tmp_mem_storage_engine='memory'; +set @save_max_heap_table_size=@@max_heap_table_size; +set @@max_heap_table_size= 16384; +# Attempt to make one test that overflows the heap table when a +# non-duplicate row is inserted and one test that overflows the +# heap table when a duplicate record is inserted. Debugging showed +# that these situations occurred with max_heap_table_size=16384 +# and optimizer_join_cache_level equals 1 and 0, respectively. +# Finally execute a test that does not overflow the heap table. +explain +select count(*) from t0 a, t0 b, t0 c +where c.a in (select a from t1 d); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE d NULL ALL NULL NULL NULL NULL 12 100.00 Start temporary +1 SIMPLE c NULL ALL NULL NULL NULL NULL 10 10.00 Using where; End temporary; Using join buffer (hash join) +1 SIMPLE a NULL ALL NULL NULL NULL NULL 10 100.00 Using join buffer (hash join) +1 SIMPLE b NULL ALL NULL NULL NULL NULL 10 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select count(0) AS `count(*)` from `test`.`t0` `a` join `test`.`t0` `b` join `test`.`t0` `c` semi join (`test`.`t1` `d`) where (`test`.`c`.`a` = `test`.`d`.`a`) +flush status; +select count(*) from t0 a, t0 b, t0 c +where c.a in (select a from t1 d); +count(*) +400 +show status like 'Created_tmp_disk_tables'; +Variable_name Value +Created_tmp_disk_tables 0 +set @@max_heap_table_size= @save_max_heap_table_size; +set session internal_tmp_mem_storage_engine=default; +flush status; +select count(*) from t0 a, t0 b, t0 c +where c.a in (select a from t1 d); +count(*) +400 +show status like 'Created_tmp_disk_tables'; +Variable_name Value +Created_tmp_disk_tables 0 +drop table t0, t1; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t2(a int); +insert into t2 values (1),(2); +create table t3 ( a int , filler char(100), key(a)); +insert into t3 select A.a + 10*B.a, 'filler' from t0 A, t0 B; +explain select * from t3 where a in (select a from t2) and (a > 5 or a < 10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ref a a 5 test.t2.a 1 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a`,`test`.`t3`.`filler` AS `filler` from `test`.`t3` semi join (`test`.`t2`) where ((`test`.`t3`.`a` = `test`.`t2`.`a`) and ((`test`.`t2`.`a` > 5) or (`test`.`t2`.`a` < 10))) +select * from t3 where a in (select a from t2); +a filler +1 filler +2 filler +drop table t0, t2, t3; +create table t1 (a date); +insert into t1 values ('2008-01-01'),('2008-01-01'),('2008-02-01'),('2008-02-01'); +create table t2 (a int); +insert into t2 values (1),(2); +create table t3 (a char(10)); +insert into t3 select * from t1; +insert into t3 values (1),(2); +explain select * from t2 where a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1`) where (cast(`test`.`t2`.`a` as double) = cast(`test`.`t1`.`a` as double)) +explain select * from t2 where a in (select a from t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t2`) where (`test`.`t2`.`a` = `test`.`t2`.`a`) +explain select * from t2 where a in (select a from t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t3`) where (cast(`test`.`t2`.`a` as double) = cast(`test`.`t3`.`a` as double)) +explain select * from t1 where a in (select a from t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t3`) where (`test`.`t1`.`a` = cast(`test`.`t3`.`a` as date)) +drop table t1, t2, t3; +create table t1 (a decimal); +insert into t1 values (1),(2); +explain select * from t1 where a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t1`) where (`test`.`t1`.`a` = `test`.`t1`.`a`) +drop table t1; +create table t1 (a int); +insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t2 as select * from t1; +create table t3 (a int, b int, filler char(100), key(a)) charset utf8mb4; +insert into t3 select A.a + 10*B.a, A.a + 10*B.a, 'filler' from t1 A, t1 B, t1 C; +explain select * from t1, t3 where t3.a in (select a from t2) and (t3.a < 10 or t3.a >30) and t1.a =3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 10.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 10 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ref a a 5 test.t2.a 10 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t3`.`filler` AS `filler` from `test`.`t1` join `test`.`t3` semi join (`test`.`t2`) where ((`test`.`t3`.`a` = `test`.`t2`.`a`) and (`test`.`t1`.`a` = 3) and ((`test`.`t2`.`a` < 10) or (`test`.`t2`.`a` > 30))) +explain format=json select * from t1, t3 where t3.a in (select a from t2) and (t3.a < 10 or t3.a >30) and t1.a =3; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "59.01" + }, + "duplicates_removal": { + "using_temporary_table": true, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 10, + "rows_produced_per_join": 1, + "filtered": "10.00", + "cost_info": { + "read_cost": "1.40", + "eval_cost": "0.10", + "prefix_cost": "1.50", + "data_read_per_join": "8" + }, + "used_columns": [ + "a" + ], + "attached_condition": "(`test`.`t1`.`a` = 3)" + } + }, + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 10, + "rows_produced_per_join": 10, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "1.00", + "prefix_cost": "3.01", + "data_read_per_join": "80" + }, + "used_columns": [ + "a" + ], + "attached_condition": "(((`test`.`t2`.`a` < 10) or (`test`.`t2`.`a` > 30)) and (`test`.`t2`.`a` is not null))" + } + }, + { + "table": { + "table_name": "t3", + "access_type": "ref", + "possible_keys": [ + "a" + ], + "key": "a", + "used_key_parts": [ + "a" + ], + "key_length": "5", + "ref": [ + "test.t2.a" + ], + "rows_examined_per_scan": 10, + "rows_produced_per_join": 100, + "filtered": "100.00", + "cost_info": { + "read_cost": "25.00", + "eval_cost": "10.00", + "prefix_cost": "59.01", + "data_read_per_join": "40K" + }, + "used_columns": [ + "a", + "b", + "filler" + ] + } + } + ] + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t3`.`filler` AS `filler` from `test`.`t1` join `test`.`t3` semi join (`test`.`t2`) where ((`test`.`t3`.`a` = `test`.`t2`.`a`) and (`test`.`t1`.`a` = 3) and ((`test`.`t2`.`a` < 10) or (`test`.`t2`.`a` > 30))) +explain select straight_join * from t1 a, t1 b where a.a in (select a from t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY a NULL ALL NULL NULL NULL NULL 10 100.00 Using where +1 PRIMARY b NULL ALL NULL NULL NULL NULL 10 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select straight_join `test`.`a`.`a` AS `a`,`test`.`b`.`a` AS `a` from `test`.`t1` `a` join `test`.`t1` `b` where (`test`.`a`.`a`,(/* select#2 */ select `test`.`t2`.`a` from `test`.`t2` where ((`test`.`a`.`a`) = `test`.`t2`.`a`))) +explain select * from t2 where a in (select straight_join a.a from t1 a, t1 b); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 10 100.00 Using where +2 DEPENDENT SUBQUERY a NULL ALL NULL NULL NULL NULL 10 10.00 Using where +2 DEPENDENT SUBQUERY b NULL ALL NULL NULL NULL NULL 10 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` where (`test`.`t2`.`a`,(/* select#2 */ select straight_join `test`.`a`.`a` from `test`.`t1` `a` join `test`.`t1` `b` where ((`test`.`t2`.`a`) = `test`.`a`.`a`))) +explain select * from t2 where a in (select straight_join a.a from t1 a, t1 b); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 10 100.00 Using where +2 DEPENDENT SUBQUERY a NULL ALL NULL NULL NULL NULL 10 10.00 Using where +2 DEPENDENT SUBQUERY b NULL ALL NULL NULL NULL NULL 10 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` where (`test`.`t2`.`a`,(/* select#2 */ select straight_join `test`.`a`.`a` from `test`.`t1` `a` join `test`.`t1` `b` where ((`test`.`t2`.`a`) = `test`.`a`.`a`))) +explain select straight_join * from t2 x, t2 y +where x.a in (select straight_join a.a from t1 a, t1 b); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY x NULL ALL NULL NULL NULL NULL 10 100.00 Using where +1 PRIMARY y NULL ALL NULL NULL NULL NULL 10 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY a NULL ALL NULL NULL NULL NULL 10 10.00 Using where +2 DEPENDENT SUBQUERY b NULL ALL NULL NULL NULL NULL 10 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select straight_join `test`.`x`.`a` AS `a`,`test`.`y`.`a` AS `a` from `test`.`t2` `x` join `test`.`t2` `y` where (`test`.`x`.`a`,(/* select#2 */ select straight_join `test`.`a`.`a` from `test`.`t1` `a` join `test`.`t1` `b` where ((`test`.`x`.`a`) = `test`.`a`.`a`))) +create table t0 (a int, b int); +insert into t0 values(1,1); +explain select * from t0, t3 where t3.a in (select a from t2) and (t3.a < 10 or t3.a >30); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 10 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ref a a 5 test.t2.a 10 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select '1' AS `a`,'1' AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t3`.`filler` AS `filler` from `test`.`t3` semi join (`test`.`t2`) where ((`test`.`t3`.`a` = `test`.`t2`.`a`) and ((`test`.`t2`.`a` < 10) or (`test`.`t2`.`a` > 30))) +create table t4 as select a as x, a as y from t1; +explain select * from t0, t3 where (t3.a, t3.b) in (select x,y from t4) and (t3.a < 10 or t3.a >30); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t4 NULL ALL NULL NULL NULL NULL 10 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ref a a 5 test.t4.x 10 10.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '1' AS `a`,'1' AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t3`.`filler` AS `filler` from `test`.`t3` semi join (`test`.`t4`) where ((`test`.`t3`.`b` = `test`.`t4`.`y`) and (`test`.`t3`.`a` = `test`.`t4`.`x`) and ((`test`.`t4`.`x` < 10) or (`test`.`t4`.`x` > 30))) +drop table t0,t1,t2,t3,t4; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (a int, b int, filler char(100), key(a,b)); +insert into t1 select A.a, B.a, 'filler' from t0 A, t0 B; +create table t2 as select * from t1; +explain select * from t2 where a in (select b from t1 where a=3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ref a a 5 const 8 100.00 Using index; LooseScan +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 100 10.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`filler` AS `filler` from `test`.`t2` semi join (`test`.`t1`) where ((`test`.`t2`.`a` = `test`.`t1`.`b`) and (`test`.`t1`.`a` = 3)) +explain select * from t2 where (b,a) in (select a,b from t1 where a=3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ref a a 5 const 8 100.00 Using index; LooseScan +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 100 1.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`filler` AS `filler` from `test`.`t2` semi join (`test`.`t1`) where ((`test`.`t2`.`a` = `test`.`t1`.`b`) and (`test`.`t1`.`a` = 3) and (`test`.`t2`.`b` = 3)) +drop table t1,t2; +create table t1 (a int, b int); +insert into t1 select a,a from t0; +create table t2 (a int, b int); +insert into t2 select A.a + 10*B.a, A.a + 10*B.a from t0 A, t0 B; +explain select * from t1 where (a,b) in (select a,b from t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 100.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 100 1.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`a` = `test`.`t1`.`a`)) +drop table t0, t1, t2; +# +# Bug#19695490: CRASH IN CREATE_REF_FOR_KEY ON SELECT + JOIN + UTF8 COLUMN +# + DATETIME INDEX. +# +CREATE TABLE t1 ( +field1 varchar(255) CHARACTER SET utf8, +field2 varchar(255) CHARACTER SET utf8 +); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES +('time','time'), +('lpjdzvkp','lpjdzvkp'), +('dzvkpai', 'dzvkpai'); +CREATE TABLE t2 ( col_varchar varchar(10)); +CREATE TABLE t3 ( +pk int(11) NOT NULL, +col_varchar_255_utf8_key varchar(255) CHARACTER SET utf8, +col_varchar_10_utf8_key varchar(10) CHARACTER SET utf8, +PRIMARY KEY (pk) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t3 VALUES (22,'come','h'), +(23,'time','aaa'), +(24,'lpjdzvkp','ababa'), +(25,'d','GGDD'); +SELECT * FROM t1 WHERE (field1, field2) IN ( +SELECT table1.col_varchar_255_utf8_key AS field1, +table1.col_varchar_255_utf8_key AS field2 +FROM t3 AS table1 LEFT JOIN t2 AS table2 +ON table1.col_varchar_10_utf8_key <= +table2.col_varchar +WHERE table1.pk >= 6); +field1 field2 +time time +lpjdzvkp lpjdzvkp +DROP TABLE t1,t2,t3; +create table t0 (a decimal(4,2)); +insert into t0 values (10.24), (22.11); +create table t1 as select * from t0; +insert into t1 select * from t0; +explain select * from t0 where a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a` from `test`.`t0` semi join (`test`.`t1`) where (`test`.`t1`.`a` = `test`.`t0`.`a`) +select * from t0 where a in (select a from t1); +a +10.24 +22.11 +drop table t0, t1; +create table t0(a date); +insert into t0 values ('2008-01-01'),('2008-02-02'); +create table t1 as select * from t0; +insert into t1 select * from t0; +explain select * from t0 where a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a` from `test`.`t0` semi join (`test`.`t1`) where (`test`.`t1`.`a` = `test`.`t0`.`a`) +select * from t0 where a in (select a from t1); +a +2008-01-01 +2008-02-02 +drop table t0, t1; +create table t0(a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 as select a as a, a as b, a as c from t0 where a < 3; +create table t2 as select a as a, a as b from t0 where a < 3; +insert into t2 select * from t2; +explain select * from t1 where (a,b,c) in (select x.a, y.a, z.a from t2 x, t2 y, t2 z where x.b=33); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE x NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +1 SIMPLE y NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Using join buffer (hash join) +1 SIMPLE z NULL ALL NULL NULL NULL NULL 6 16.67 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` semi join (`test`.`t2` `x` join `test`.`t2` `y` join `test`.`t2` `z`) where ((`test`.`z`.`a` = `test`.`t1`.`c`) and (`test`.`y`.`a` = `test`.`t1`.`b`) and (`test`.`t1`.`a` = `test`.`x`.`a`) and (`test`.`x`.`b` = 33)) +drop table t0,t1,t2; +set @save_join_buffer_size = @@join_buffer_size; +set join_buffer_size= 8192; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (a int, filler1 binary(200), filler2 binary(200)); +insert into t1 select a, 'filler123456', 'filler123456' from t0; +insert into t1 select a+10, 'filler123456', 'filler123456' from t0; +create table t2 as select * from t1; +insert into t1 select a+20, 'filler123456', 'filler123456' from t0; +insert into t1 values (2, 'duplicate ok', 'duplicate ok'); +insert into t1 values (18, 'duplicate ok', 'duplicate ok'); +insert into t2 values (3, 'duplicate ok', 'duplicate ok'); +insert into t2 values (19, 'duplicate ok', 'duplicate ok'); +explain select +a, mid(filler1, 1,10), length(filler1)=length(filler2) as z +from t1 ot where a in (select a from t2 it); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE it NULL ALL NULL NULL NULL NULL 22 100.00 Start temporary +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 32 10.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot`.`a` AS `a`,substr(`test`.`ot`.`filler1`,1,10) AS `mid(filler1, 1,10)`,(length(`test`.`ot`.`filler1`) = length(`test`.`ot`.`filler2`)) AS `z` from `test`.`t1` `ot` semi join (`test`.`t2` `it`) where (`test`.`ot`.`a` = `test`.`it`.`a`) +select +a, mid(filler1, 1,10), length(filler1)=length(filler2) as z +from t1 ot where a in (select a from t2 it); +a mid(filler1, 1,10) z +0 filler1234 1 +1 filler1234 1 +10 filler1234 1 +11 filler1234 1 +12 filler1234 1 +13 filler1234 1 +14 filler1234 1 +15 filler1234 1 +16 filler1234 1 +17 filler1234 1 +18 duplicate 1 +18 filler1234 1 +19 filler1234 1 +2 duplicate 1 +2 filler1234 1 +3 filler1234 1 +4 filler1234 1 +5 filler1234 1 +6 filler1234 1 +7 filler1234 1 +8 filler1234 1 +9 filler1234 1 +explain select +a, mid(filler1, 1,10), length(filler1)=length(filler2) +from t2 ot where a in (select a from t1 it); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE it NULL ALL NULL NULL NULL NULL 32 100.00 Start temporary +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 22 10.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot`.`a` AS `a`,substr(`test`.`ot`.`filler1`,1,10) AS `mid(filler1, 1,10)`,(length(`test`.`ot`.`filler1`) = length(`test`.`ot`.`filler2`)) AS `length(filler1)=length(filler2)` from `test`.`t2` `ot` semi join (`test`.`t1` `it`) where (`test`.`ot`.`a` = `test`.`it`.`a`) +select +a, mid(filler1, 1,10), length(filler1)=length(filler2) +from t2 ot where a in (select a from t1 it); +a mid(filler1, 1,10) length(filler1)=length(filler2) +0 filler1234 1 +1 filler1234 1 +10 filler1234 1 +11 filler1234 1 +12 filler1234 1 +13 filler1234 1 +14 filler1234 1 +15 filler1234 1 +16 filler1234 1 +17 filler1234 1 +18 filler1234 1 +19 duplicate 1 +19 filler1234 1 +2 filler1234 1 +3 duplicate 1 +3 filler1234 1 +4 filler1234 1 +5 filler1234 1 +6 filler1234 1 +7 filler1234 1 +8 filler1234 1 +9 filler1234 1 +insert into t1 select a+20, 'filler123456', 'filler123456' from t0; +insert into t1 select a+20, 'filler123456', 'filler123456' from t0; +explain select +a, mid(filler1, 1,10), length(filler1)=length(filler2) as z +from t1 ot where a in (select a from t2 it); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE it NULL ALL NULL NULL NULL NULL 22 100.00 Start temporary +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 52 10.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot`.`a` AS `a`,substr(`test`.`ot`.`filler1`,1,10) AS `mid(filler1, 1,10)`,(length(`test`.`ot`.`filler1`) = length(`test`.`ot`.`filler2`)) AS `z` from `test`.`t1` `ot` semi join (`test`.`t2` `it`) where (`test`.`ot`.`a` = `test`.`it`.`a`) +select +a, mid(filler1, 1,10), length(filler1)=length(filler2) as z +from t1 ot where a in (select a from t2 it); +a mid(filler1, 1,10) z +0 filler1234 1 +1 filler1234 1 +10 filler1234 1 +11 filler1234 1 +12 filler1234 1 +13 filler1234 1 +14 filler1234 1 +15 filler1234 1 +16 filler1234 1 +17 filler1234 1 +18 duplicate 1 +18 filler1234 1 +19 filler1234 1 +2 duplicate 1 +2 filler1234 1 +3 filler1234 1 +4 filler1234 1 +5 filler1234 1 +6 filler1234 1 +7 filler1234 1 +8 filler1234 1 +9 filler1234 1 +explain select +a, mid(filler1, 1,10), length(filler1)=length(filler2) +from t2 ot where a in (select a from t1 it); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE it NULL ALL NULL NULL NULL NULL 52 100.00 Start temporary +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 22 10.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot`.`a` AS `a`,substr(`test`.`ot`.`filler1`,1,10) AS `mid(filler1, 1,10)`,(length(`test`.`ot`.`filler1`) = length(`test`.`ot`.`filler2`)) AS `length(filler1)=length(filler2)` from `test`.`t2` `ot` semi join (`test`.`t1` `it`) where (`test`.`ot`.`a` = `test`.`it`.`a`) +select +a, mid(filler1, 1,10), length(filler1)=length(filler2) +from t2 ot where a in (select a from t1 it); +a mid(filler1, 1,10) length(filler1)=length(filler2) +0 filler1234 1 +1 filler1234 1 +10 filler1234 1 +11 filler1234 1 +12 filler1234 1 +13 filler1234 1 +14 filler1234 1 +15 filler1234 1 +16 filler1234 1 +17 filler1234 1 +18 filler1234 1 +19 duplicate 1 +19 filler1234 1 +2 filler1234 1 +3 duplicate 1 +3 filler1234 1 +4 filler1234 1 +5 filler1234 1 +6 filler1234 1 +7 filler1234 1 +8 filler1234 1 +9 filler1234 1 +set @@join_buffer_size = @save_join_buffer_size; +drop table t1, t2; +create table t1 (a int, b int, key(a)); +create table t2 (a int, b int, key(a)); +create table t3 (a int, b int, key(a)); +insert into t1 select a,a from t0; +insert into t2 select a,a from t0; +insert into t3 select a,a from t0; +t2 and t3 must be use 'ref', not 'ALL': +explain select * +from t0 where a in +(select t2.a+t3.a from t1 left join (t2 join t3) on t2.a=t1.a and t3.a=t1.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index a a 5 NULL 10 100.00 Using index; Start temporary +1 SIMPLE t2 NULL ref a a 5 test.t1.a 1 100.00 Using index +1 SIMPLE t3 NULL ref a a 5 test.t1.a 1 100.00 Using index +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 10 10.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a` from `test`.`t0` semi join (`test`.`t1` join `test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`a` = `test`.`t1`.`a`) and (`test`.`t3`.`a` = `test`.`t1`.`a`) and (`test`.`t0`.`a` = (`test`.`t1`.`a` + `test`.`t1`.`a`))) +drop table t0, t1,t2,t3; + +Test that neither MaterializeLookup strategy for semijoin, +nor subquery materialization is used when BLOBs are involved +(except when arguments of some functions). + +set @prefix_len = 6; +set @blob_len = 16; +set @suffix_len = @blob_len - @prefix_len; +create table t1_16 (a1 blob(16), a2 blob(16)); +create table t2_16 (b1 blob(16), b2 blob(16)); +create table t3_16 (c1 blob(16), c2 blob(16)); +insert into t1_16 values +(concat('1 - 00', repeat('x', @suffix_len)), concat('2 - 00', repeat('x', @suffix_len))); +insert into t1_16 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t1_16 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_16 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t2_16 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_16 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_16 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t3_16 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t3_16 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_16 values +(concat('1 - 04', repeat('x', @suffix_len)), concat('2 - 04', repeat('x', @suffix_len))); +explain select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select b1 from t2_16 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2_16 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Start temporary +1 SIMPLE t1_16 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_16`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_16`.`a2`,7) AS `left(a2,7)` from `test`.`t1_16` semi join (`test`.`t2_16`) where ((`test`.`t1_16`.`a1` = `test`.`t2_16`.`b1`) and (`test`.`t2_16`.`b1` > '0')) +select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select b1 from t2_16 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_16 +where (a1,a2) in (select b1, b2 from t2_16 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2_16 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Start temporary +1 SIMPLE t1_16 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_16`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_16`.`a2`,7) AS `left(a2,7)` from `test`.`t1_16` semi join (`test`.`t2_16`) where ((`test`.`t1_16`.`a2` = `test`.`t2_16`.`b2`) and (`test`.`t1_16`.`a1` = `test`.`t2_16`.`b1`) and (`test`.`t2_16`.`b1` > '0')) +select left(a1,7), left(a2,7) +from t1_16 +where (a1,a2) in (select b1, b2 from t2_16 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select substring(b1,1,16) from t2_16 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2_16 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Start temporary +1 SIMPLE t1_16 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_16`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_16`.`a2`,7) AS `left(a2,7)` from `test`.`t1_16` semi join (`test`.`t2_16`) where ((`test`.`t2_16`.`b1` > '0') and (`test`.`t1_16`.`a1` = substr(`test`.`t2_16`.`b1`,1,16))) +select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select substring(b1,1,16) from t2_16 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select group_concat(b1) from t2_16 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_16 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t2_16 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_16`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_16`.`a2`,7) AS `left(a2,7)` from `test`.`t1_16` where (`test`.`t1_16`.`a1`,(/* select#2 */ select group_concat(`test`.`t2_16`.`b1` separator ',') from `test`.`t2_16` group by `test`.`t2_16`.`b2` having ((`test`.`t1_16`.`a1`) = (group_concat(`test`.`t2_16`.`b1` separator ','))))) +select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select group_concat(b1) from t2_16 group by b2); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +set @@group_concat_max_len = 256; +explain select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select group_concat(b1) from t2_16 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_16 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t2_16 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_16`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_16`.`a2`,7) AS `left(a2,7)` from `test`.`t1_16` where (`test`.`t1_16`.`a1`,(/* select#2 */ select group_concat(`test`.`t2_16`.`b1` separator ',') from `test`.`t2_16` group by `test`.`t2_16`.`b2` having ((`test`.`t1_16`.`a1`) = (group_concat(`test`.`t2_16`.`b1` separator ','))))) +select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select group_concat(b1) from t2_16 group by b2); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +create table t1 (a1 char(8), a2 char(8)) charset latin1; +create table t2 (b1 char(8), b2 char(8)) charset latin1; +create table t3 (c1 char(8), c2 char(8)) charset latin1; +insert into t1 values ('1 - 00', '2 - 00'); +insert into t1 values ('1 - 01', '2 - 01'); +insert into t1 values ('1 - 02', '2 - 02'); +insert into t2 values ('1 - 01', '2 - 01'); +insert into t2 values ('1 - 01', '2 - 01'); +insert into t2 values ('1 - 02', '2 - 02'); +insert into t2 values ('1 - 02', '2 - 02'); +insert into t2 values ('1 - 03', '2 - 03'); +insert into t3 values ('1 - 01', '2 - 01'); +insert into t3 values ('1 - 02', '2 - 02'); +insert into t3 values ('1 - 03', '2 - 03'); +insert into t3 values ('1 - 04', '2 - 04'); +insert into t3 values ('1 - 05', '2 - 05'); +insert into t3 values ('1 - 06', '2 - 06'); +insert into t3 values ('1 - 07', '2 - 07'); +insert into t3 values ('1 - 08', '2 - 08'); +explain +select * from t1 +where concat(a1,'x') IN +(select left(a1,8) from t1_16 +where (a1, a2) IN +(select t2_16.b1, t2_16.b2 from t2_16, t2 +where t2.b2 = substring(t2_16.b2,1,6) and +t2.b1 IN (select c1 from t3 where c2 > '0'))); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1_16 NULL ALL NULL NULL NULL NULL 3 100.00 Start temporary +1 SIMPLE t2_16 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 5 20.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` semi join (`test`.`t1_16` join `test`.`t2_16` join `test`.`t2` join `test`.`t3`) where ((`test`.`t2_16`.`b2` = `test`.`t1_16`.`a2`) and (`test`.`t2_16`.`b1` = `test`.`t1_16`.`a1`) and (`test`.`t3`.`c1` = `test`.`t2`.`b1`) and (`test`.`t2`.`b2` = substr(`test`.`t2_16`.`b2`,1,6)) and (`test`.`t3`.`c2` > '0') and (concat(`test`.`t1`.`a1`,'x') = left(`test`.`t1_16`.`a1`,8))) +drop table t1_16, t2_16, t3_16, t1, t2, t3; +set @blob_len = 512; +set @suffix_len = @blob_len - @prefix_len; +create table t1_512 (a1 blob(512), a2 blob(512)); +create table t2_512 (b1 blob(512), b2 blob(512)); +create table t3_512 (c1 blob(512), c2 blob(512)); +insert into t1_512 values +(concat('1 - 00', repeat('x', @suffix_len)), concat('2 - 00', repeat('x', @suffix_len))); +insert into t1_512 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t1_512 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_512 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t2_512 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_512 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_512 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t3_512 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t3_512 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_512 values +(concat('1 - 04', repeat('x', @suffix_len)), concat('2 - 04', repeat('x', @suffix_len))); +explain select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select b1 from t2_512 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2_512 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Start temporary +1 SIMPLE t1_512 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_512`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_512`.`a2`,7) AS `left(a2,7)` from `test`.`t1_512` semi join (`test`.`t2_512`) where ((`test`.`t1_512`.`a1` = `test`.`t2_512`.`b1`) and (`test`.`t2_512`.`b1` > '0')) +select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select b1 from t2_512 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_512 +where (a1,a2) in (select b1, b2 from t2_512 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2_512 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Start temporary +1 SIMPLE t1_512 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_512`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_512`.`a2`,7) AS `left(a2,7)` from `test`.`t1_512` semi join (`test`.`t2_512`) where ((`test`.`t1_512`.`a2` = `test`.`t2_512`.`b2`) and (`test`.`t1_512`.`a1` = `test`.`t2_512`.`b1`) and (`test`.`t2_512`.`b1` > '0')) +select left(a1,7), left(a2,7) +from t1_512 +where (a1,a2) in (select b1, b2 from t2_512 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select substring(b1,1,512) from t2_512 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2_512 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Start temporary +1 SIMPLE t1_512 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_512`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_512`.`a2`,7) AS `left(a2,7)` from `test`.`t1_512` semi join (`test`.`t2_512`) where ((`test`.`t2_512`.`b1` > '0') and (`test`.`t1_512`.`a1` = substr(`test`.`t2_512`.`b1`,1,512))) +select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select substring(b1,1,512) from t2_512 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select group_concat(b1) from t2_512 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_512 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t2_512 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_512`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_512`.`a2`,7) AS `left(a2,7)` from `test`.`t1_512` where (`test`.`t1_512`.`a1`,(/* select#2 */ select group_concat(`test`.`t2_512`.`b1` separator ',') from `test`.`t2_512` group by `test`.`t2_512`.`b2` having ((`test`.`t1_512`.`a1`) = (group_concat(`test`.`t2_512`.`b1` separator ','))))) +select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select group_concat(b1) from t2_512 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +Warning 1260 Row 4 was cut by GROUP_CONCAT() +Warning 1260 Row 5 was cut by GROUP_CONCAT() +Warning 1260 Row 6 was cut by GROUP_CONCAT() +Warning 1260 Row 7 was cut by GROUP_CONCAT() +Warning 1260 Row 8 was cut by GROUP_CONCAT() +Warning 1260 Row 9 was cut by GROUP_CONCAT() +set @@group_concat_max_len = 256; +explain select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select group_concat(b1) from t2_512 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_512 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t2_512 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_512`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_512`.`a2`,7) AS `left(a2,7)` from `test`.`t1_512` where (`test`.`t1_512`.`a1`,(/* select#2 */ select group_concat(`test`.`t2_512`.`b1` separator ',') from `test`.`t2_512` group by `test`.`t2_512`.`b2` having ((`test`.`t1_512`.`a1`) = (group_concat(`test`.`t2_512`.`b1` separator ','))))) +select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select group_concat(b1) from t2_512 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +Warning 1260 Row 4 was cut by GROUP_CONCAT() +Warning 1260 Row 5 was cut by GROUP_CONCAT() +Warning 1260 Row 6 was cut by GROUP_CONCAT() +Warning 1260 Row 7 was cut by GROUP_CONCAT() +Warning 1260 Row 8 was cut by GROUP_CONCAT() +Warning 1260 Row 9 was cut by GROUP_CONCAT() +drop table t1_512, t2_512, t3_512; +set @blob_len = 513; +set @suffix_len = @blob_len - @prefix_len; +create table t1_513 (a1 blob(513), a2 blob(513)); +create table t2_513 (b1 blob(513), b2 blob(513)); +create table t3_513 (c1 blob(513), c2 blob(513)); +insert into t1_513 values +(concat('1 - 00', repeat('x', @suffix_len)), concat('2 - 00', repeat('x', @suffix_len))); +insert into t1_513 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t1_513 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_513 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t2_513 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_513 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_513 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t3_513 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t3_513 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_513 values +(concat('1 - 04', repeat('x', @suffix_len)), concat('2 - 04', repeat('x', @suffix_len))); +explain select left(a1,7), left(a2,7) +from t1_513 +where a1 in (select b1 from t2_513 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2_513 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Start temporary +1 SIMPLE t1_513 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_513`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_513`.`a2`,7) AS `left(a2,7)` from `test`.`t1_513` semi join (`test`.`t2_513`) where ((`test`.`t1_513`.`a1` = `test`.`t2_513`.`b1`) and (`test`.`t2_513`.`b1` > '0')) +select left(a1,7), left(a2,7) +from t1_513 +where a1 in (select b1 from t2_513 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_513 +where (a1,a2) in (select b1, b2 from t2_513 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2_513 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Start temporary +1 SIMPLE t1_513 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_513`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_513`.`a2`,7) AS `left(a2,7)` from `test`.`t1_513` semi join (`test`.`t2_513`) where ((`test`.`t1_513`.`a2` = `test`.`t2_513`.`b2`) and (`test`.`t1_513`.`a1` = `test`.`t2_513`.`b1`) and (`test`.`t2_513`.`b1` > '0')) +select left(a1,7), left(a2,7) +from t1_513 +where (a1,a2) in (select b1, b2 from t2_513 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_513 +where a1 in (select substring(b1,1,513) from t2_513 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2_513 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Start temporary +1 SIMPLE t1_513 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_513`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_513`.`a2`,7) AS `left(a2,7)` from `test`.`t1_513` semi join (`test`.`t2_513`) where ((`test`.`t2_513`.`b1` > '0') and (`test`.`t1_513`.`a1` = substr(`test`.`t2_513`.`b1`,1,513))) +select left(a1,7), left(a2,7) +from t1_513 +where a1 in (select substring(b1,1,513) from t2_513 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_513 +where a1 in (select group_concat(b1) from t2_513 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_513 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t2_513 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_513`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_513`.`a2`,7) AS `left(a2,7)` from `test`.`t1_513` where (`test`.`t1_513`.`a1`,(/* select#2 */ select group_concat(`test`.`t2_513`.`b1` separator ',') from `test`.`t2_513` group by `test`.`t2_513`.`b2` having ((`test`.`t1_513`.`a1`) = (group_concat(`test`.`t2_513`.`b1` separator ','))))) +select left(a1,7), left(a2,7) +from t1_513 +where a1 in (select group_concat(b1) from t2_513 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +Warning 1260 Row 4 was cut by GROUP_CONCAT() +Warning 1260 Row 5 was cut by GROUP_CONCAT() +Warning 1260 Row 6 was cut by GROUP_CONCAT() +Warning 1260 Row 7 was cut by GROUP_CONCAT() +Warning 1260 Row 8 was cut by GROUP_CONCAT() +Warning 1260 Row 9 was cut by GROUP_CONCAT() +drop table t1_513, t2_513, t3_513; +set @blob_len = 1024; +set @suffix_len = @blob_len - @prefix_len; +create table t1_1024 (a1 blob(1024), a2 blob(1024)); +create table t2_1024 (b1 blob(1024), b2 blob(1024)); +create table t3_1024 (c1 blob(1024), c2 blob(1024)); +insert into t1_1024 values +(concat('1 - 00', repeat('x', @suffix_len)), concat('2 - 00', repeat('x', @suffix_len))); +insert into t1_1024 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t1_1024 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_1024 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t2_1024 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_1024 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_1024 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t3_1024 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t3_1024 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_1024 values +(concat('1 - 04', repeat('x', @suffix_len)), concat('2 - 04', repeat('x', @suffix_len))); +explain select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select b1 from t2_1024 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2_1024 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Start temporary +1 SIMPLE t1_1024 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1024`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1024`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1024` semi join (`test`.`t2_1024`) where ((`test`.`t1_1024`.`a1` = `test`.`t2_1024`.`b1`) and (`test`.`t2_1024`.`b1` > '0')) +select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select b1 from t2_1024 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_1024 +where (a1,a2) in (select b1, b2 from t2_1024 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2_1024 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Start temporary +1 SIMPLE t1_1024 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1024`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1024`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1024` semi join (`test`.`t2_1024`) where ((`test`.`t1_1024`.`a2` = `test`.`t2_1024`.`b2`) and (`test`.`t1_1024`.`a1` = `test`.`t2_1024`.`b1`) and (`test`.`t2_1024`.`b1` > '0')) +select left(a1,7), left(a2,7) +from t1_1024 +where (a1,a2) in (select b1, b2 from t2_1024 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select substring(b1,1,1024) from t2_1024 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2_1024 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Start temporary +1 SIMPLE t1_1024 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1024`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1024`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1024` semi join (`test`.`t2_1024`) where ((`test`.`t2_1024`.`b1` > '0') and (`test`.`t1_1024`.`a1` = substr(`test`.`t2_1024`.`b1`,1,1024))) +select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select substring(b1,1,1024) from t2_1024 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select group_concat(b1) from t2_1024 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_1024 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t2_1024 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1024`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1024`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1024` where (`test`.`t1_1024`.`a1`,(/* select#2 */ select group_concat(`test`.`t2_1024`.`b1` separator ',') from `test`.`t2_1024` group by `test`.`t2_1024`.`b2` having ((`test`.`t1_1024`.`a1`) = (group_concat(`test`.`t2_1024`.`b1` separator ','))))) +select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select group_concat(b1) from t2_1024 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +Warning 1260 Row 4 was cut by GROUP_CONCAT() +Warning 1260 Row 5 was cut by GROUP_CONCAT() +Warning 1260 Row 6 was cut by GROUP_CONCAT() +Warning 1260 Row 7 was cut by GROUP_CONCAT() +Warning 1260 Row 8 was cut by GROUP_CONCAT() +Warning 1260 Row 9 was cut by GROUP_CONCAT() +set @@group_concat_max_len = 256; +explain select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select group_concat(b1) from t2_1024 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_1024 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t2_1024 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1024`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1024`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1024` where (`test`.`t1_1024`.`a1`,(/* select#2 */ select group_concat(`test`.`t2_1024`.`b1` separator ',') from `test`.`t2_1024` group by `test`.`t2_1024`.`b2` having ((`test`.`t1_1024`.`a1`) = (group_concat(`test`.`t2_1024`.`b1` separator ','))))) +select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select group_concat(b1) from t2_1024 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +Warning 1260 Row 4 was cut by GROUP_CONCAT() +Warning 1260 Row 5 was cut by GROUP_CONCAT() +Warning 1260 Row 6 was cut by GROUP_CONCAT() +Warning 1260 Row 7 was cut by GROUP_CONCAT() +Warning 1260 Row 8 was cut by GROUP_CONCAT() +Warning 1260 Row 9 was cut by GROUP_CONCAT() +drop table t1_1024, t2_1024, t3_1024; +set @blob_len = 1025; +set @suffix_len = @blob_len - @prefix_len; +create table t1_1025 (a1 blob(1025), a2 blob(1025)); +create table t2_1025 (b1 blob(1025), b2 blob(1025)); +create table t3_1025 (c1 blob(1025), c2 blob(1025)); +insert into t1_1025 values +(concat('1 - 00', repeat('x', @suffix_len)), concat('2 - 00', repeat('x', @suffix_len))); +insert into t1_1025 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t1_1025 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_1025 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t2_1025 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_1025 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_1025 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t3_1025 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t3_1025 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_1025 values +(concat('1 - 04', repeat('x', @suffix_len)), concat('2 - 04', repeat('x', @suffix_len))); +explain select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select b1 from t2_1025 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2_1025 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Start temporary +1 SIMPLE t1_1025 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1025`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1025`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1025` semi join (`test`.`t2_1025`) where ((`test`.`t1_1025`.`a1` = `test`.`t2_1025`.`b1`) and (`test`.`t2_1025`.`b1` > '0')) +select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select b1 from t2_1025 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_1025 +where (a1,a2) in (select b1, b2 from t2_1025 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2_1025 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Start temporary +1 SIMPLE t1_1025 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1025`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1025`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1025` semi join (`test`.`t2_1025`) where ((`test`.`t1_1025`.`a2` = `test`.`t2_1025`.`b2`) and (`test`.`t1_1025`.`a1` = `test`.`t2_1025`.`b1`) and (`test`.`t2_1025`.`b1` > '0')) +select left(a1,7), left(a2,7) +from t1_1025 +where (a1,a2) in (select b1, b2 from t2_1025 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select substring(b1,1,1025) from t2_1025 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2_1025 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Start temporary +1 SIMPLE t1_1025 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1025`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1025`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1025` semi join (`test`.`t2_1025`) where ((`test`.`t2_1025`.`b1` > '0') and (`test`.`t1_1025`.`a1` = substr(`test`.`t2_1025`.`b1`,1,1025))) +select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select substring(b1,1,1025) from t2_1025 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select group_concat(b1) from t2_1025 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_1025 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t2_1025 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1025`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1025`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1025` where (`test`.`t1_1025`.`a1`,(/* select#2 */ select group_concat(`test`.`t2_1025`.`b1` separator ',') from `test`.`t2_1025` group by `test`.`t2_1025`.`b2` having ((`test`.`t1_1025`.`a1`) = (group_concat(`test`.`t2_1025`.`b1` separator ','))))) +select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select group_concat(b1) from t2_1025 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +Warning 1260 Row 4 was cut by GROUP_CONCAT() +Warning 1260 Row 5 was cut by GROUP_CONCAT() +Warning 1260 Row 6 was cut by GROUP_CONCAT() +Warning 1260 Row 7 was cut by GROUP_CONCAT() +Warning 1260 Row 8 was cut by GROUP_CONCAT() +Warning 1260 Row 9 was cut by GROUP_CONCAT() +set @@group_concat_max_len = 256; +explain select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select group_concat(b1) from t2_1025 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_1025 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t2_1025 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1025`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1025`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1025` where (`test`.`t1_1025`.`a1`,(/* select#2 */ select group_concat(`test`.`t2_1025`.`b1` separator ',') from `test`.`t2_1025` group by `test`.`t2_1025`.`b2` having ((`test`.`t1_1025`.`a1`) = (group_concat(`test`.`t2_1025`.`b1` separator ','))))) +select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select group_concat(b1) from t2_1025 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +Warning 1260 Row 4 was cut by GROUP_CONCAT() +Warning 1260 Row 5 was cut by GROUP_CONCAT() +Warning 1260 Row 6 was cut by GROUP_CONCAT() +Warning 1260 Row 7 was cut by GROUP_CONCAT() +Warning 1260 Row 8 was cut by GROUP_CONCAT() +Warning 1260 Row 9 was cut by GROUP_CONCAT() +drop table t1_1025, t2_1025, t3_1025; +# +# WL#5561: Enable semi join transformation with outer join. +# +CREATE TABLE ot1(a INT); +CREATE TABLE ot2(a INT); +CREATE TABLE ot3(a INT); +CREATE TABLE it1(a INT); +CREATE TABLE it2(a INT); +CREATE TABLE it3(a INT); +INSERT INTO ot1 VALUES(0),(1),(2),(3),(4),(5),(6),(7); +INSERT INTO ot2 VALUES(0),(2),(4),(6); +INSERT INTO ot3 VALUES(0),(3),(6); +INSERT INTO it1 VALUES(0),(1),(2),(3),(4),(5),(6),(7); +INSERT INTO it2 VALUES(0),(2),(4),(6); +INSERT INTO it3 VALUES(0),(3),(6); +# Test cases, Subquery Pattern 1 +# Example SQ1.1: +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE ot1.a IN (SELECT a FROM it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE it3 NULL ALL NULL NULL NULL NULL 3 100.00 Start temporary +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; End temporary; Using join buffer (hash join) +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` left join `test`.`ot2` on((`test`.`ot2`.`a` = `test`.`it3`.`a`)) semi join (`test`.`it3`) where (`test`.`ot1`.`a` = `test`.`it3`.`a`) +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE ot1.a IN (SELECT a FROM it3); +a a +0 0 +3 NULL +6 6 +# Example SQ1.2: +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE COALESCE(ot2.a,0) IN (SELECT a FROM it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 Start temporary +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (hash join) +1 SIMPLE it3 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` left join `test`.`ot2` on((`test`.`ot2`.`a` = `test`.`ot1`.`a`)) semi join (`test`.`it3`) where (coalesce(`test`.`ot2`.`a`,0) = `test`.`it3`.`a`) +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE COALESCE(ot2.a,0) IN (SELECT a FROM it3); +a a +0 0 +1 NULL +3 NULL +5 NULL +6 6 +7 NULL +# Example SQ1.3: +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE (ot1.a,ot2.a) IN (SELECT a, a FROM it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE it3 NULL ALL NULL NULL NULL NULL 3 100.00 Start temporary +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; Using join buffer (hash join) +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` join `test`.`ot2` semi join (`test`.`it3`) where ((`test`.`ot2`.`a` = `test`.`it3`.`a`) and (`test`.`ot1`.`a` = `test`.`it3`.`a`)) +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE (ot1.a,ot2.a) IN (SELECT a, a FROM it3); +a a +0 0 +6 6 +# More test cases +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 +WHERE ot1.a IN (SELECT a FROM it3); +a a +0 0 +3 NULL +6 6 +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 +WHERE ot1.a IN (SELECT a+0 FROM it3); +a a +0 0 +3 NULL +6 6 +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 +WHERE COALESCE(ot2.a,0) IN (SELECT a FROM it3); +a a +0 0 +1 NULL +3 NULL +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE COALESCE(ot2.a,0) IN (SELECT a+0 FROM it3); +a a +0 0 +1 NULL +3 NULL +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 +WHERE (ot1.a,ot2.a) IN (SELECT a, a FROM it3); +a a +0 0 +6 6 +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +LEFT JOIN ot3 ON ot1.a=ot3.a +WHERE ot1.a IN (SELECT a FROM it3); +a a a +0 0 0 +3 NULL 3 +6 6 6 +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +LEFT JOIN ot3 ON ot1.a=ot3.a +WHERE COALESCE(ot2.a,0) IN (SELECT a FROM it3); +a a a +0 0 0 +1 NULL NULL +3 NULL 3 +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +LEFT JOIN ot3 ON ot1.a=ot3.a +WHERE COALESCE(ot3.a,0) IN (SELECT a FROM it3); +a a a +0 0 0 +1 NULL NULL +2 2 NULL +3 NULL 3 +4 4 NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +LEFT JOIN ot3 ON ot2.a=ot3.a +WHERE ot1.a IN (SELECT a FROM it3); +a a a +0 0 0 +3 NULL NULL +6 6 6 +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +LEFT JOIN ot3 ON ot2.a=ot3.a +WHERE COALESCE(ot2.a,0) IN (SELECT a FROM it3); +a a a +0 0 0 +1 NULL NULL +3 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +LEFT JOIN ot3 ON ot2.a=ot3.a +WHERE COALESCE(ot3.a,0) IN (SELECT a FROM it3); +a a a +0 0 0 +1 NULL NULL +2 2 NULL +3 NULL NULL +4 4 NULL +5 NULL NULL +6 6 6 +7 NULL NULL +# Test cases, Subquery Pattern 2 +# Example SQ2.1: +explain SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE it3 NULL ALL NULL NULL NULL NULL 3 100.00 Start temporary +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; End temporary; Using join buffer (hash join) +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` join `test`.`ot2` semi join (`test`.`it3`) where ((`test`.`ot1`.`a` = `test`.`it3`.`a`) and (`test`.`ot2`.`a` = `test`.`it3`.`a`)) +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3); +a a +0 0 +6 6 +# Example SQ2.2: +explain SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it2) +AND ot2.a IN (SELECT a FROM it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE it3 NULL ALL NULL NULL NULL NULL 3 100.00 Start temporary +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; Using join buffer (hash join) +1 SIMPLE it2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; Using join buffer (hash join) +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` join `test`.`ot2` semi join (`test`.`it2`) semi join (`test`.`it3`) where ((`test`.`ot2`.`a` = `test`.`it3`.`a`) and (`test`.`it2`.`a` = `test`.`it3`.`a`) and (`test`.`ot1`.`a` = `test`.`it3`.`a`)) +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it2) +AND ot2.a IN (SELECT a FROM it3); +a a +0 0 +6 6 +# More test cases +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it3); +a a +0 0 +6 6 +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it3); +a a +0 0 +6 6 +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a+0 AND ot2.a IN (SELECT a FROM it3); +a a +0 0 +6 6 +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot2.a IN (SELECT a+0 FROM it3); +a a +0 0 +6 6 +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it2) +AND ot2.a IN (SELECT a+0 FROM it3); +a a +0 0 +6 6 +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3) +JOIN ot3 ON ot2.a=ot3.a AND ot3.a IN (SELECT a FROM it3); +a a a +0 0 0 +6 6 6 +# Test cases, Subquery Pattern 3 +# Example SQ3.1: +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 Start temporary +1 SIMPLE it3 NULL ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (hash join) +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` semi join (`test`.`it3`)) on(((`test`.`it3`.`a` = `test`.`ot1`.`a`) and (`test`.`ot2`.`a` = `test`.`ot1`.`a`))) where true +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3); +a a +0 0 +1 NULL +2 NULL +3 NULL +4 NULL +5 NULL +6 6 +7 NULL +# Example SQ3.2: +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot2.a IN (SELECT a FROM it2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 Start temporary +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (hash join) +1 SIMPLE it2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` semi join (`test`.`it2`)) on(((`test`.`ot2`.`a` = `test`.`ot1`.`a`) and (`test`.`it2`.`a` = `test`.`ot1`.`a`))) where true +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot2.a IN (SELECT a FROM it2); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +# Example SQ3.3 +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1) +AND ot2.a IN (SELECT a FROM it2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 Start temporary +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (hash join) +1 SIMPLE it2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (hash join) +1 SIMPLE it1 NULL ALL NULL NULL NULL NULL 8 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` semi join (`test`.`it1`) semi join (`test`.`it2`)) on(((`test`.`ot2`.`a` = `test`.`ot1`.`a`) and (`test`.`it2`.`a` = `test`.`ot1`.`a`) and (`test`.`it1`.`a` = `test`.`ot1`.`a`))) where true +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1) +AND ot2.a IN (SELECT a FROM it2); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +# Example SQ3.4 +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND +(ot1.a, ot2.a) IN (SELECT it1.a, it2.a +FROM it1 JOIN it2 ON it1.a=it2.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 Start temporary +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (hash join) +1 SIMPLE it2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (hash join) +1 SIMPLE it1 NULL ALL NULL NULL NULL NULL 8 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` semi join (`test`.`it1` join `test`.`it2`)) on(((`test`.`ot2`.`a` = `test`.`ot1`.`a`) and (`test`.`it2`.`a` = `test`.`ot1`.`a`) and (`test`.`it1`.`a` = `test`.`ot1`.`a`))) where true +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND +(ot1.a, ot2.a) IN (SELECT it1.a, it2.a +FROM it1 JOIN it2 ON it1.a=it2.a); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +# More test cases +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it3); +a a +0 0 +1 NULL +2 NULL +3 NULL +4 NULL +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it3); +a a +0 0 +1 NULL +2 NULL +3 NULL +4 NULL +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 AND ot2.a IN (SELECT a FROM it2); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot2.a IN (SELECT a+0 FROM it2); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a+0 FROM it1) +AND ot2.a IN (SELECT a+0 FROM it2); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 AND +(ot1.a, ot2.a) IN (SELECT it1.a+0, it2.a+0 +FROM it1 JOIN it2 ON it1.a=it2.a); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +EXPLAIN FORMAT=tree SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3) +LEFT JOIN ot3 ON ot2.a=ot3.a AND ot3.a IN (SELECT a FROM it3); +EXPLAIN +-> Remove duplicate (ot1, ot2, ot3) rows using temporary table (weedout) (cost=88.33 rows=864) + -> Left hash join (ot3.a = ot2.a), (it3.a = ot2.a) (cost=88.33 rows=864) + -> Left hash join (it3.a = ot1.a), (ot2.a = ot1.a) (cost=12.10 rows=96) + -> Table scan on ot1 (cost=1.30 rows=8) + -> Hash + -> Inner hash join (no condition) (cost=2.00 rows=12) + -> Table scan on ot2 (cost=0.11 rows=4) + -> Hash + -> Table scan on it3 (cost=0.30 rows=3) + -> Hash + -> Inner hash join (no condition) (cost=1.43 rows=9) + -> Table scan on it3 (cost=0.03 rows=3) + -> Hash + -> Table scan on ot3 (cost=0.03 rows=3) + +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3) +LEFT JOIN ot3 ON ot2.a=ot3.a AND ot3.a IN (SELECT a FROM it3); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it3) +LEFT JOIN ot3 ON ot2.a=ot3.a+0 AND ot3.a IN (SELECT a FROM it3); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +# Test cases, Subquery Pattern 4 +# Example SQ4.1: +explain SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 Start temporary +1 SIMPLE it1 NULL ALL NULL NULL NULL NULL 8 100.00 Using where; Using join buffer (hash join) +1 SIMPLE ot3 NULL ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (hash join) +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a`,`test`.`ot3`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` join `test`.`ot3` semi join (`test`.`it1`)) on(((`test`.`it1`.`a` = `test`.`ot1`.`a`) and (`test`.`ot3`.`a` = `test`.`ot1`.`a`) and (`test`.`ot2`.`a` = `test`.`ot1`.`a`))) where true +SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +# Example SQ4.2: +explain SELECT * +FROM ot1 +JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot3 NULL ALL NULL NULL NULL NULL 3 100.00 Start temporary +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; Using join buffer (hash join) +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; Using join buffer (hash join) +1 SIMPLE it1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a`,`test`.`ot3`.`a` AS `a` from `test`.`ot1` join `test`.`ot2` join `test`.`ot3` semi join (`test`.`it1`) where ((`test`.`ot2`.`a` = `test`.`ot3`.`a`) and (`test`.`ot1`.`a` = `test`.`ot3`.`a`) and (`test`.`it1`.`a` = `test`.`ot3`.`a`)) +SELECT * +FROM ot1 +JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +6 6 6 +# Example SQ4.3: +explain SELECT * +FROM ot1 +JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Start temporary +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; Using join buffer (hash join) +1 SIMPLE it1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; End temporary; Using join buffer (hash join) +1 SIMPLE ot3 NULL ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a`,`test`.`ot3`.`a` AS `a` from `test`.`ot1` join `test`.`ot2` left join `test`.`ot3` on((`test`.`ot3`.`a` = `test`.`ot2`.`a`)) semi join (`test`.`it1`) where ((`test`.`ot1`.`a` = `test`.`ot2`.`a`) and (`test`.`it1`.`a` = `test`.`ot2`.`a`)) +SELECT * +FROM ot1 +JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +2 2 NULL +4 4 NULL +6 6 6 +# Example SQ4.4: +explain SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 Start temporary +1 SIMPLE it1 NULL ALL NULL NULL NULL NULL 8 100.00 Using where; Using join buffer (hash join) +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (hash join) +1 SIMPLE ot3 NULL ALL NULL NULL NULL NULL 3 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a`,`test`.`ot3`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` left join `test`.`ot3` on((`test`.`ot3`.`a` = `test`.`it1`.`a`)) semi join (`test`.`it1`)) on(((`test`.`it1`.`a` = `test`.`ot1`.`a`) and (`test`.`ot2`.`a` = `test`.`ot1`.`a`))) where true +SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +1 NULL NULL +2 2 NULL +3 NULL NULL +4 4 NULL +5 NULL NULL +6 6 6 +7 NULL NULL +# More test cases +SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a+0) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it1); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 +JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a+0) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +6 6 6 +SELECT * +FROM ot1 +JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +6 6 6 +SELECT * +FROM ot1 +JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it1); +a a a +0 0 0 +6 6 6 +SELECT * +FROM ot1 +JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a+0) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +2 2 NULL +4 4 NULL +6 6 6 +SELECT * +FROM ot1 +JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +2 2 NULL +4 4 NULL +6 6 6 +SELECT * +FROM ot1 +JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it1); +a a a +0 0 0 +2 2 NULL +4 4 NULL +6 6 6 +SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a+0) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +1 NULL NULL +2 2 NULL +3 NULL NULL +4 4 NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +1 NULL NULL +2 2 NULL +3 NULL NULL +4 4 NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it1); +a a a +0 0 0 +1 NULL NULL +2 2 NULL +3 NULL NULL +4 4 NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1) +LEFT JOIN +ot1 AS ot4 +ON ot2.a=ot4.a; +a a a a +0 0 0 0 +1 NULL NULL NULL +2 2 NULL 2 +3 NULL NULL NULL +4 4 NULL 4 +5 NULL NULL NULL +6 6 6 6 +7 NULL NULL NULL +SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a +LEFT JOIN ot1 AS ot4 ON ot3.a=ot4.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a a +0 0 0 0 +1 NULL NULL NULL +2 2 NULL NULL +3 NULL NULL NULL +4 4 NULL NULL +5 NULL NULL NULL +6 6 6 6 +7 NULL NULL NULL +DROP TABLE ot1,ot2,ot3,it1,it2,it3; +CREATE TABLE t ( +a INTEGER DEFAULT NULL +) ENGINE=InnoDB; +INSERT INTO t VALUES (1); +CREATE TABLE t2 ( +a INTEGER DEFAULT NULL +) ENGINE=InnoDB; +INSERT INTO t2 VALUES (1),(1); +CREATE TABLE t4 ( +a INTEGER DEFAULT NULL +) ENGINE=InnoDB; +INSERT INTO t4 VALUES (1),(1); +CREATE TABLE v ( +a INTEGER DEFAULT NULL +) ENGINE=InnoDB; +INSERT INTO v VALUES (1),(1); +explain SELECT * +FROM t AS t1 +LEFT JOIN +(t2 +LEFT JOIN t AS t3 +ON t3.a IN (SELECT a FROM t AS it) +JOIN t4 +ON t4.a=100 +) +ON TRUE +WHERE t1.a IN (SELECT * FROM v AS it2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +2 SIMPLE it2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using join buffer (hash join) +2 SIMPLE it NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t4`.`a` AS `a` from `test`.`t` `t1` left join (`test`.`t2` left join (`test`.`t` `t3` semi join (`test`.`t` `it`)) on(((`test`.`it`.`a` = `test`.`t3`.`a`))) join `test`.`t4`) on(((`test`.`t4`.`a` = 100))) semi join (`test`.`v` `it2`) where (`test`.`it2`.`a` = `test`.`t1`.`a`) +SELECT * +FROM t AS t1 +LEFT JOIN +(t2 +LEFT JOIN t AS t3 +ON t3.a IN (SELECT a FROM t AS it) +JOIN t4 +ON t4.a=100 +) +ON TRUE +WHERE t1.a IN (SELECT * FROM v AS it2); +a a a a +1 NULL NULL NULL +DROP TABLE t,t2,t4,v; +# End of WL#5561 +# +# Bug#48868: Left outer join in subquery causes segmentation fault in +# make_join_select. +# +CREATE TABLE t1 (i INTEGER); +INSERT INTO t1 VALUES (1); +INSERT INTO t1 VALUES (2); +CREATE TABLE t2 (i INTEGER); +INSERT INTO t2 VALUES(1); +CREATE TABLE t3 (i INTEGER); +INSERT INTO t3 VALUES (1); +INSERT INTO t3 VALUES (2); +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t2.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +1 +DROP TABLE t1, t2, t3; + +Bug#37899: Wrongly checked optimization prerequisite caused failed +assertion. + +CREATE TABLE t1 ( +`pk` int(11), +`varchar_nokey` varchar(5) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES +(1,'qk'),(2,'j'),(3,'aew'); +SELECT * +FROM t1 +WHERE varchar_nokey IN ( +SELECT +varchar_nokey +FROM +t1 +) XOR pk = 30; +pk varchar_nokey +1 qk +2 j +3 aew +drop table t1; +# +# BUG#41842: Semi-join materialization strategy crashes when the upper query has HAVING +# +CREATE TABLE t1 ( +pk int(11) NOT NULL AUTO_INCREMENT, +int_nokey int(11) NOT NULL, +time_key time NOT NULL, +datetime_key datetime NOT NULL, +datetime_nokey datetime NOT NULL, +varchar_key varchar(1) NOT NULL, +varchar_nokey varchar(1) NOT NULL, +PRIMARY KEY (pk), +KEY time_key (time_key), +KEY datetime_key (datetime_key), +KEY varchar_key (varchar_key) +) ENGINE=MyISaM; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES +(1,0, '00:16:10','2008-09-03 14:25:40','2008-09-03 14:25:40','h','h'), +(2,7, '00:00:00','2001-01-13 00:00:00','2001-01-13 00:00:00','',''), +(3,0, '00:00:00','0000-00-00 00:00:00','0000-00-00 00:00:00','x','x'), +(4,2, '16:29:24','2000-10-16 01:39:08','2000-10-16 01:39:08','w','w'), +(5,1, '09:23:32','0000-00-00 00:00:00','0000-00-00 00:00:00','p','p'), +(6,3, '00:00:00','2007-12-02 00:00:00','2007-12-02 00:00:00','o','o'), +(7,3, '00:00:00','2008-09-11 00:00:00','2008-09-11 00:00:00','',''), +(8,0, '13:59:04','0000-00-00 00:00:00','0000-00-00 00:00:00','s','s'), +(9,7, '09:01:06','0000-00-00 00:00:00','0000-00-00 00:00:00','d','d'), +(10,5,'00:00:00','0000-00-00 00:00:00','0000-00-00 00:00:00','n','n'), +(11,0,'21:06:46','0000-00-00 00:00:00','0000-00-00 00:00:00','o','o'), +(12,2,'00:00:00','0000-00-00 00:00:00','0000-00-00 00:00:00','',''), +(13,6,'14:45:34','2003-07-28 02:34:08','2003-07-28 02:34:08','w','w'), +(14,1,'15:04:12','0000-00-00 00:00:00','0000-00-00 00:00:00','o','o'), +(15,0,'00:00:00','0000-00-00 00:00:00','0000-00-00 00:00:00','x','x'), +(16,0,'15:55:23','2004-03-17 00:32:27','2004-03-17 00:32:27','p','p'), +(17,1,'16:30:00','2004-12-27 19:20:00','2004-12-27 19:20:00','d','d'), +(18,0,'00:00:00','0000-00-00 00:00:00','0000-00-00 00:00:00','h','h'), +(19,0,'14:13:26','2008-11-09 05:53:48','2008-11-09 05:53:48','o','o'), +(20,0,'00:00:00','2009-10-11 06:58:04','2009-10-11 06:58:04','k','k'); +Warnings: +Warning 1264 Out of range value for column 'datetime_key' at row 3 +Warning 1264 Out of range value for column 'datetime_nokey' at row 3 +Warning 1264 Out of range value for column 'datetime_key' at row 5 +Warning 1264 Out of range value for column 'datetime_nokey' at row 5 +Warning 1264 Out of range value for column 'datetime_key' at row 8 +Warning 1264 Out of range value for column 'datetime_nokey' at row 8 +Warning 1264 Out of range value for column 'datetime_key' at row 9 +Warning 1264 Out of range value for column 'datetime_nokey' at row 9 +Warning 1264 Out of range value for column 'datetime_key' at row 10 +Warning 1264 Out of range value for column 'datetime_nokey' at row 10 +Warning 1264 Out of range value for column 'datetime_key' at row 11 +Warning 1264 Out of range value for column 'datetime_nokey' at row 11 +Warning 1264 Out of range value for column 'datetime_key' at row 12 +Warning 1264 Out of range value for column 'datetime_nokey' at row 12 +Warning 1264 Out of range value for column 'datetime_key' at row 14 +Warning 1264 Out of range value for column 'datetime_nokey' at row 14 +Warning 1264 Out of range value for column 'datetime_key' at row 15 +Warning 1264 Out of range value for column 'datetime_nokey' at row 15 +Warning 1264 Out of range value for column 'datetime_key' at row 18 +Warning 1264 Out of range value for column 'datetime_nokey' at row 18 +CREATE TABLE t2 ( +pk int(11) NOT NULL AUTO_INCREMENT, +int_nokey int(11) NOT NULL, +time_key time NOT NULL, +datetime_key datetime NOT NULL, +datetime_nokey datetime NOT NULL, +varchar_key varchar(1) NOT NULL, +varchar_nokey varchar(1) NOT NULL, +PRIMARY KEY (pk), +KEY time_key (time_key), +KEY datetime_key (datetime_key), +KEY varchar_key (varchar_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT IGNORE INTO t2 VALUES +(10,0,'19:39:13','0000-00-00 00:00:00','0000-00-00 00:00:00','g','g'), +(11,8,'03:43:53','0000-00-00 00:00:00','0000-00-00 00:00:00','b','b'); +Warnings: +Warning 1264 Out of range value for column 'datetime_key' at row 1 +Warning 1264 Out of range value for column 'datetime_nokey' at row 1 +Warning 1264 Out of range value for column 'datetime_key' at row 2 +Warning 1264 Out of range value for column 'datetime_nokey' at row 2 +SELECT OUTR.datetime_nokey AS X FROM t1 AS OUTR +WHERE +OUTR.varchar_nokey IN (SELECT +INNR . varchar_nokey AS Y +FROM t2 AS INNR +WHERE +INNR . datetime_key >= INNR . time_key OR +INNR . pk = INNR . int_nokey +) +AND OUTR . varchar_nokey <= 'w' +HAVING X > '2012-12-12'; +X +drop table t1, t2; + +Bug#46797 "Crash in fix_semijoin_strategies_for_picked_join_order +with semijoin=on" + +CREATE TABLE t1 ( +varchar_key varchar(1) DEFAULT NULL, +KEY varchar_key (varchar_key) +); +CREATE TABLE t2 ( +varchar_key varchar(1) DEFAULT NULL, +KEY varchar_key (varchar_key) +); +INSERT INTO t2 VALUES +(NULL),(NULL),(NULL),(NULL),('a'),('a'),('a'),('b'),('b'),('b'),('b'),('c'), +('c'),('c'),('c'),('c'),('c'),('c'),('d'),('d'),('d'),('d'),('d'),('d'),('e'), +('e'),('e'),('e'),('e'),('e'),('f'),('f'),('f'),('g'),('g'),('h'),('h'),('h'), +('h'),('i'),('j'),('j'),('j'),('k'),('k'),('l'),('l'),('m'),('m'),('m'),('m'), +('n'),('n'),('n'),('o'),('o'),('o'),('p'),('p'),('p'),('q'),('q'),('q'),('r'), +('r'),('r'),('r'),('s'),('s'),('s'),('s'),('t'),('t'),('t'),('t'),('u'),('u'), +('u'),('u'),('v'),('v'),('v'),('v'),('w'),('w'),('w'),('w'),('w'),('w'),('x'), +('x'),('x'),('y'),('y'),('y'),('y'),('z'),('z'),('z'),('z'); +CREATE TABLE t3 ( +varchar_key varchar(1) DEFAULT NULL, +KEY varchar_key (varchar_key) +) ENGINE=MyISAM DEFAULT CHARSET=latin1; +INSERT INTO t3 VALUES +(NULL),('c'),('d'),('e'),('f'),('h'),('j'),('k'),('k'),('m'),('m'),('m'), +('n'),('o'),('r'),('t'),('t'),('u'),('w'),('y'); +SELECT varchar_key FROM t3 +WHERE (SELECT varchar_key FROM t3 +WHERE (varchar_key,varchar_key) +IN (SELECT t1.varchar_key, t2 .varchar_key +FROM t1 RIGHT JOIN t2 ON t1.varchar_key +) +); +varchar_key +DROP TABLE t1, t2, t3; +# +# Bug#46556 Returning incorrect, empty results for some IN subqueries +# w/semijoin=on +# +CREATE TABLE t0 ( +pk INTEGER, +vkey VARCHAR(1), +vnokey VARCHAR(1), +PRIMARY KEY (pk), +KEY vkey(vkey) +) charset utf8mb4; +INSERT INTO t0 +VALUES (1,'g','g'), (2,'v','v'), (3,'t','t'), (4,'u','u'), (5,'n','n'); +EXPLAIN SELECT vkey FROM t0 WHERE pk IN +(SELECT t1.pk FROM t0 t1 JOIN t0 t2 ON t2.vkey = t1.vnokey); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index vkey vkey 7 NULL 5 100.00 Using index; Start temporary +1 SIMPLE t1 NULL ALL PRIMARY NULL NULL NULL 5 20.00 Using where; Using join buffer (hash join) +1 SIMPLE t0 NULL eq_ref PRIMARY PRIMARY 4 test.t1.pk 1 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`vkey` AS `vkey` from `test`.`t0` `t1` join `test`.`t0` semi join (`test`.`t0` `t2`) where ((`test`.`t1`.`vnokey` = `test`.`t2`.`vkey`) and (`test`.`t0`.`pk` = `test`.`t1`.`pk`)) +SELECT vkey FROM t0 WHERE pk IN +(SELECT t1.pk FROM t0 t1 JOIN t0 t2 ON t2.vkey = t1.vnokey); +vkey +g +n +t +u +v +DROP TABLE t0; +# End of bug#46556 + +Bug#48834: Procedure with view + subquery + semijoin=on +crashes on second call. + +CREATE TABLE t1 ( t1field integer, primary key (t1field)); +CREATE TABLE t2 ( t2field integer, primary key (t2field)); +CREATE VIEW v1 AS +SELECT t1field as v1field +FROM t1 A +WHERE A.t1field IN (SELECT t1field FROM t2 ); +CREATE VIEW v2 AS +SELECT t2field as v2field +FROM t2 A +WHERE A.t2field IN (SELECT t2field FROM t2 ); +CREATE PROCEDURE p1 () +BEGIN +SELECT v1field +FROM v1 +WHERE v1field IN ( SELECT v2field as vf_inner FROM v2 ); +END| +INSERT INTO t1 VALUES (1),(2),(3); +INSERT INTO t2 VALUES (2),(3),(4); +CALL p1; +v1field +2 +3 +CALL p1; +v1field +2 +3 +DROP TABLE t1,t2; +DROP VIEW v1,v2; +DROP PROCEDURE p1; +# End of BUG#48834 +# +# Bug#46692 "Crash occurring on queries with nested FROM subqueries +# using materialization." +# +CREATE TABLE t1 ( +pk INTEGER PRIMARY KEY, +int_key INTEGER, +KEY int_key(int_key) +); +INSERT INTO t1 VALUES (10,186),(11,NULL),(12,2),(13,3),(14,0),(15,133),(16,1); +CREATE TABLE t2 ( +pk INTEGER PRIMARY KEY, +int_key INTEGER, +KEY int_key(int_key) +); +INSERT INTO t2 VALUES (1,7),(2,2); +SELECT * FROM t1 WHERE (140, 4) IN +(SELECT t2.int_key, t2 .pk FROM t2 STRAIGHT_JOIN t1 ON t2.int_key); +pk int_key +DROP TABLE t1, t2; +# +# Bug#42353 "SELECT ... WHERE oe IN (SELECT w/ LEFT JOIN) query +# causes crash." +# +CREATE TABLE t1 ( +pk INTEGER PRIMARY KEY, +int_nokey INTEGER, +int_key INTEGER, +date_key DATE, +datetime_nokey DATETIME, +varchar_nokey VARCHAR(1) +); +CREATE TABLE t2 ( +date_nokey DATE +); +CREATE TABLE t3 ( +pk INTEGER PRIMARY KEY, +int_nokey INTEGER, +date_key date, +varchar_key VARCHAR(1), +varchar_nokey VARCHAR(1), +KEY date_key (date_key) +); +SELECT date_key FROM t1 +WHERE (int_key, int_nokey) +IN (SELECT t3.int_nokey, t3.pk +FROM t2 LEFT JOIN t3 ON (t2.date_nokey < t3.date_key) +WHERE t3.varchar_key <= t3.varchar_nokey OR t3.int_nokey <= t3.pk +) +AND (varchar_nokey <> 'f' OR NOT int_key < 7); +date_key +# +# Bug#45933 "Crash in optimize_semijoin_nests on JOIN in subquery +# + AND in outer query". +# +INSERT INTO t1 VALUES (10,7,5,'2009-06-16','2002-04-10 14:25:30','w'), +(11,7,0,'0000-00-00','0000-00-00 00:00:00','s'), +(12,4,0,'2003-07-14','2006-09-14 04:01:02','y'), +(13,0,4,'2002-07-25','0000-00-00 00:00:00','c'), +(14,1,8,'2007-07-03','0000-00-00 00:00:00','q'), +(15,6,5,'2001-11-12','0000-00-00 00:00:00',''), +(16,2,9,'0000-00-00','0000-00-00 00:00:00','j'), +(29,9,1,'0000-00-00','2003-08-11 00:00:00','m'); +Warnings: +Warning 1264 Out of range value for column 'date_key' at row 2 +Warning 1264 Out of range value for column 'datetime_nokey' at row 2 +Warning 1264 Out of range value for column 'datetime_nokey' at row 4 +Warning 1264 Out of range value for column 'datetime_nokey' at row 5 +Warning 1264 Out of range value for column 'datetime_nokey' at row 6 +Warning 1264 Out of range value for column 'date_key' at row 7 +Warning 1264 Out of range value for column 'datetime_nokey' at row 7 +Warning 1264 Out of range value for column 'date_key' at row 8 +INSERT IGNORE INTO t3 VALUES (1,9,'0000-00-00','b','b'), +(2,2,'2002-09-17','h','h'); +Warnings: +Warning 1264 Out of range value for column 'date_key' at row 1 +SELECT t1.varchar_nokey FROM t1 JOIN t3 ON t1.datetime_nokey +WHERE t1.varchar_nokey +IN (SELECT varchar_nokey FROM t1 +WHERE (pk) +IN (SELECT t3.int_nokey +FROM t3 LEFT JOIN t1 ON t1.varchar_nokey +WHERE t3.date_key BETWEEN '2008-06-07' AND '2006-06-26' + ) +); +varchar_nokey +DROP TABLE t1, t2, t3; +# +# Bug#45219 "Crash on SELECT DISTINCT query containing a +# LEFT JOIN in subquery" +# +CREATE TABLE t1 ( +pk INTEGER NOT NULL, +int_nokey INTEGER NOT NULL, +datetime_key DATETIME NOT NULL, +varchar_key VARCHAR(1) NOT NULL, +PRIMARY KEY (pk), +KEY datetime_key (datetime_key), +KEY varchar_key (varchar_key) +); +INSERT IGNORE INTO t1 VALUES +(1,9,'0000-00-00 00:00:00','p'),(2,0,'2002-02-09 07:38:13','v'), +(3,8,'2001-05-03 12:08:14','t'),(4,3,'0000-00-00 00:00:00','u'), +(5,7,'2009-07-28 03:43:30','n'),(6,0,'2009-08-04 00:00:00','l'), +(7,1,'0000-00-00 00:00:00','h'),(8,9,'0000-00-00 00:00:00','u'), +(9,0,'2005-08-02 17:16:54','n'),(10,9,'2002-12-21 00:00:00','j'), +(11,0,'2005-08-15 12:37:35','k'),(12,5,'0000-00-00 00:00:00','e'), +(13,0,'2006-03-10 00:00:00','i'),(14,8,'2005-05-16 11:02:36','u'), +(15,8,'2008-11-02 00:00:00','n'),(16,5,'2006-03-15 00:00:00','b'), +(17,1,'0000-00-00 00:00:00','x'),(18,7,'0000-00-00 00:00:00',''), +(19,0,'2008-12-17 20:15:40','q'),(20,9,'0000-00-00 00:00:00','u'); +Warnings: +Warning 1264 Out of range value for column 'datetime_key' at row 1 +Warning 1264 Out of range value for column 'datetime_key' at row 4 +Warning 1264 Out of range value for column 'datetime_key' at row 7 +Warning 1264 Out of range value for column 'datetime_key' at row 8 +Warning 1264 Out of range value for column 'datetime_key' at row 12 +Warning 1264 Out of range value for column 'datetime_key' at row 17 +Warning 1264 Out of range value for column 'datetime_key' at row 18 +Warning 1264 Out of range value for column 'datetime_key' at row 20 +CREATE TABLE t2 LIKE t1; +INSERT INTO t2 VALUES +(10,0,'2006-07-07 07:26:28','q'),(11,5,'2002-09-23 00:00:00','m'), +(12,7,'0000-00-00 00:00:00','j'),(13,1,'2006-06-07 00:00:00','z'), +(14,8,'2000-09-16 12:15:34','a'),(15,2,'2007-08-05 15:47:52',''), +(16,1,'0000-00-00 00:00:00','e'),(17,8,'2005-12-02 19:34:26','t'), +(18,5,'0000-00-00 00:00:00','q'),(19,4,'0000-00-00 00:00:00','b'), +(20,5,'2007-12-28 00:00:00','w'),(21,3,'2004-08-02 11:48:43','m'), +(22,0,'0000-00-00 00:00:00','x'),(23,8,'2004-04-19 12:18:43',''), +(24,0,'2009-04-27 00:00:00','w'),(25,4,'2006-10-20 14:52:15','x'), +(26,0,'0000-00-00 00:00:00','e'),(27,0,'2002-03-22 11:48:37','e'), +(28,2,'0000-00-00 00:00:00','p'),(29,0,'2001-01-04 03:55:07','x'); +Warnings: +Warning 1264 Out of range value for column 'datetime_key' at row 3 +Warning 1264 Out of range value for column 'datetime_key' at row 7 +Warning 1264 Out of range value for column 'datetime_key' at row 9 +Warning 1264 Out of range value for column 'datetime_key' at row 10 +Warning 1264 Out of range value for column 'datetime_key' at row 13 +Warning 1264 Out of range value for column 'datetime_key' at row 17 +Warning 1264 Out of range value for column 'datetime_key' at row 19 +CREATE TABLE t3 LIKE t1; +INSERT INTO t3 VALUES +(10,8,'2007-08-19 08:08:38','i'),(11,0,'2000-05-21 03:51:51',''); +SELECT DISTINCT datetime_key FROM t1 +WHERE (int_nokey, pk) +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#46550 Azalea returning duplicate results for some IN subqueries +# w/ semijoin=on +# +DROP TABLE IF EXISTS t0, t1, t2; +CREATE TABLE t0 ( +int_key int(11) DEFAULT NULL, +varchar_key varchar(1) DEFAULT NULL, +varchar_nokey varchar(1) DEFAULT NULL, +KEY int_key (int_key), +KEY varchar_key (varchar_key,int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t0 VALUES +(1,'m','m'), +(40,'h','h'), +(1,'r','r'), +(1,'h','h'), +(9,'x','x'), +(NULL,'q','q'), +(NULL,'k','k'), +(7,'l','l'), +(182,'k','k'), +(202,'a','a'), +(7,'x','x'), +(6,'j','j'), +(119,'z','z'), +(4,'d','d'), +(5,'h','h'), +(1,'u','u'), +(3,'q','q'), +(7,'a','a'), +(3,'e','e'), +(6,'l','l'); +CREATE TABLE t1 ( +int_key int(11) DEFAULT NULL, +varchar_key varchar(1) DEFAULT NULL, +varchar_nokey varchar(1) DEFAULT NULL, +KEY int_key (int_key), +KEY varchar_key (varchar_key,int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (7,NULL,NULL),(4,'x','x'); +CREATE TABLE t2 ( +int_key int(11) DEFAULT NULL, +varchar_key varchar(1) DEFAULT NULL, +varchar_nokey varchar(1) DEFAULT NULL, +KEY int_key (int_key), +KEY varchar_key (varchar_key,int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (123,NULL,NULL); +SELECT int_key +FROM t0 +WHERE varchar_nokey IN ( +SELECT t1 .varchar_key from t1 +); +int_key +7 +9 +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 +7 +9 +EXPLAIN +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 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1_1 NULL index varchar_key varchar_key 12 NULL 2 50.00 Using where; Using index; LooseScan +1 SIMPLE t1_2 NULL index NULL int_key 5 NULL 2 100.00 Using index; FirstMatch(t1_1) +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 20 10.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`int_key` AS `int_key` from `test`.`t0` semi join (`test`.`t1` `t1_1` join `test`.`t1` `t1_2`) where ((`test`.`t0`.`varchar_nokey` = `test`.`t1_1`.`varchar_key`) and (0 <> `test`.`t1_1`.`int_key`)) +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 +7 +9 +EXPLAIN +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 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t1_1 NULL index varchar_key varchar_key 12 NULL 2 50.00 Using where; Using index; LooseScan +1 SIMPLE t1_2 NULL index NULL int_key 5 NULL 2 100.00 Using index; FirstMatch(t1_1) +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 20 10.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`int_key` AS `int_key` from `test`.`t0` semi join (`test`.`t1` `t1_1` join `test`.`t1` `t1_2`) where ((`test`.`t0`.`varchar_nokey` = `test`.`t1_1`.`varchar_key`) and (0 <> `test`.`t1_1`.`int_key`)) +DROP TABLE t0, t1, t2; +# End of bug#46550 + +Bug #48073 Subquery on char columns from view crashes Mysql + +DROP TABLE IF EXISTS t1, t2; +DROP VIEW IF EXISTS v1; +CREATE TABLE t1 ( +city VARCHAR(50) NOT NULL, +country_id SMALLINT UNSIGNED NOT NULL +); +INSERT INTO t1 VALUES +('Batna',2), +('Bchar',2), +('Skikda',2), +('Tafuna',3), +('Algeria',2) ; +CREATE TABLE t2 ( +country_id SMALLINT UNSIGNED NOT NULL, +country VARCHAR(50) NOT NULL +); +INSERT INTO t2 VALUES +(2,'Algeria'), +(3,'American Samoa') ; +CREATE VIEW v1 AS +SELECT country_id, country +FROM t2 +WHERE LEFT(country,1) = "A" +; +SELECT city, country_id +FROM t1 +WHERE city IN ( +SELECT country +FROM t2 +WHERE LEFT(country, 1) = "A" +); +city country_id +Algeria 2 +SELECT city, country_id +FROM t1 +WHERE city IN ( +SELECT country +FROM v1 +); +city country_id +Algeria 2 +drop table t1, t2; +drop view v1; +# End of bug#48073 + +Bug#49097 subquery with view generates wrong result with +non-prepared statement + +DROP TABLE IF EXISTS t1, t2; +DROP VIEW IF EXISTS v1; +CREATE TABLE t1 ( +city VARCHAR(50) NOT NULL, +country_id SMALLINT UNSIGNED NOT NULL +); +INSERT INTO t1 VALUES +('Batna',2), +('Bchar',2), +('Skikda',2), +('Tafuna',3), +('Algeria',2) ; +CREATE TABLE t2 ( +country_id SMALLINT UNSIGNED NOT NULL, +country VARCHAR(50) NOT NULL +); +INSERT INTO t2 VALUES +(2,'Algeria'), +(3,'XAmerican Samoa') ; +CREATE VIEW v1 AS +SELECT country_id, country +FROM t2 +WHERE LEFT(country,1) = "A" +; +SELECT city, country_id +FROM t1 +WHERE country_id IN ( +SELECT country_id +FROM t2 +WHERE LEFT(country,1) = "A" +); +city country_id +Algeria 2 +Batna 2 +Bchar 2 +Skikda 2 +SELECT city, country_id +FROM t1 +WHERE country_id IN ( +SELECT country_id +FROM v1 +); +city country_id +Algeria 2 +Batna 2 +Bchar 2 +Skikda 2 +PREPARE stmt FROM +" +SELECT city, country_id +FROM t1 +WHERE country_id IN ( + SELECT country_id + FROM v1 +); +"; +execute stmt; +city country_id +Algeria 2 +Batna 2 +Bchar 2 +Skikda 2 +deallocate prepare stmt; +drop table t1, t2; +drop view v1; +# End of Bug#49097 +# +# Bug#49198 Wrong result for second call of procedure +# with view in subselect. +# +CREATE TABLE t1 (t1field integer, primary key (t1field)); +CREATE TABLE t2 (t2field integer, primary key (t2field)); +CREATE TABLE t3 (t3field integer, primary key (t3field)); +CREATE VIEW v2 AS SELECT * FROM t2; +CREATE VIEW v3 AS SELECT * FROM t3; +INSERT INTO t1 VALUES(1),(2); +INSERT INTO t2 VALUES(1),(2); +INSERT INTO t3 VALUES(1),(2); +PREPARE stmt FROM +" +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT * FROM v2); +"; +EXECUTE stmt; +t1field +1 +2 + +EXECUTE stmt; +t1field +1 +2 +PREPARE stmt FROM +" +EXPLAIN +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT * FROM v2) + AND t1field IN (SELECT * FROM v3) +"; +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index PRIMARY PRIMARY 4 NULL 2 100.00 Using index +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +1 SIMPLE t3 NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`t1field` AS `t1field` from `test`.`t2` join `test`.`t3` join `test`.`t1` where ((`test`.`t2`.`t2field` = `test`.`t1`.`t1field`) and (`test`.`t3`.`t3field` = `test`.`t1`.`t1field`)) + +This line is only in place to help --skip_if_hypergraph diffing some more. + +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index PRIMARY PRIMARY 4 NULL 2 100.00 Using index +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +1 SIMPLE t3 NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`t1field` AS `t1field` from `test`.`t2` join `test`.`t3` join `test`.`t1` where ((`test`.`t2`.`t2field` = `test`.`t1`.`t1field`) and (`test`.`t3`.`t3field` = `test`.`t1`.`t1field`)) +DROP TABLE t1, t2, t3; +DROP VIEW v2, v3; +# End of Bug#49198 +# +# Bug#48623 Multiple subqueries are optimized incorrectly +# +CREATE TABLE ot(val VARCHAR(10)) charset utf8mb4; +CREATE TABLE it1(val VARCHAR(10)) charset utf8mb4; +CREATE TABLE it2(val VARCHAR(10)) charset utf8mb4; +INSERT INTO ot VALUES('aaa'), ('bbb'), ('eee'), ('mmm'), ('ppp'); +INSERT INTO it1 VALUES('aaa'), ('aaa'), ('bbb'), ('eee'), ('mmm'), ('ppp'); +INSERT INTO it2 VALUES('aaa'), ('bbb'), ('eee'), ('mmm'), ('ppp'); +EXPLAIN +SELECT * +FROM ot +WHERE ot.val IN (SELECT it1.val FROM it1 +WHERE it1.val LIKE 'a%' OR it1.val LIKE 'e%') +AND ot.val IN (SELECT it2.val FROM it2 +WHERE it2.val LIKE 'a%' OR it2.val LIKE 'e%'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE it2 NULL ALL NULL NULL NULL NULL 5 36.00 Using where; Start temporary +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 5 20.00 Using where; Using join buffer (hash join) +1 SIMPLE it1 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot`.`val` AS `val` from `test`.`ot` semi join (`test`.`it1`) semi join (`test`.`it2`) where ((`test`.`ot`.`val` = `test`.`it2`.`val`) and (`test`.`it1`.`val` = `test`.`it2`.`val`) and ((`test`.`it1`.`val` like 'a%') or (`test`.`it1`.`val` like 'e%')) and ((`test`.`it2`.`val` like 'a%') or (`test`.`it2`.`val` like 'e%'))) +SELECT * +FROM ot +WHERE ot.val IN (SELECT it1.val FROM it1 +WHERE it1.val LIKE 'a%' OR it1.val LIKE 'e%') +AND ot.val IN (SELECT it2.val FROM it2 +WHERE it2.val LIKE 'a%' OR it2.val LIKE 'e%'); +val +aaa +eee +DROP TABLE ot; +DROP TABLE it1; +DROP TABLE it2; +# End of Bug#48623 +# +# Bug #51487 Assertion failure when semi-join flattening occurs +# for a subquery in HAVING +# +CREATE TABLE t1 (a INT, b INT); +INSERT INTO t1 VALUES (1,10),(2,11),(1,13); +CREATE TABLE t2 AS SELECT * FROM t1; +CREATE TABLE t3 AS SELECT * FROM t1; +SELECT COUNT(*) FROM t1 +GROUP BY t1.a +HAVING t1.a IN (SELECT t3.a FROM t3 +WHERE t3.b IN (SELECT b FROM t2 WHERE t2.a=t1.a)); +COUNT(*) +2 +1 +DROP TABLE t1, t2, t3; +# End of Bug#51487 +# +# BUG#38075: Wrong result: rows matching a subquery with outer join not returned +# +DROP TABLE IF EXISTS ot1, it1, it2; +CREATE TABLE it2 ( +int_key int(11) NOT NULL, +datetime_key datetime NOT NULL, +KEY int_key (int_key), +KEY datetime_key (datetime_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO it2 VALUES +(5,'2002-04-10 14:25:30'), (0,'0000-00-00 00:00:00'), +(0,'2006-09-14 04:01:02'), (4,'0000-00-00 00:00:00'), +(8,'0000-00-00 00:00:00'), (5,'0000-00-00 00:00:00'), +(9,'0000-00-00 00:00:00'), (8,'2007-04-01 11:04:17'), +(1,'0000-00-00 00:00:00'), (7,'2009-01-12 00:00:00'), +(0,'2009-06-05 00:00:00'), (3,'2006-02-14 18:06:35'), +(5,'2006-02-21 07:08:16'), (0,'0000-00-00 00:00:00'), +(7,'0000-00-00 00:00:00'), (0,'0000-00-00 00:00:00'), +(0,'2007-02-13 00:00:00'), (1,'0000-00-00 00:00:00'), +(0,'0000-00-00 00:00:00'), (1,'2003-08-11 00:00:00'); +Warnings: +Warning 1264 Out of range value for column 'datetime_key' at row 2 +Warning 1264 Out of range value for column 'datetime_key' at row 4 +Warning 1264 Out of range value for column 'datetime_key' at row 5 +Warning 1264 Out of range value for column 'datetime_key' at row 6 +Warning 1264 Out of range value for column 'datetime_key' at row 7 +Warning 1264 Out of range value for column 'datetime_key' at row 9 +Warning 1264 Out of range value for column 'datetime_key' at row 14 +Warning 1264 Out of range value for column 'datetime_key' at row 15 +Warning 1264 Out of range value for column 'datetime_key' at row 16 +Warning 1264 Out of range value for column 'datetime_key' at row 18 +Warning 1264 Out of range value for column 'datetime_key' at row 19 +CREATE TABLE ot1 ( +int_nokey int(11) NOT NULL, +int_key int(11) NOT NULL, +KEY int_key (int_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO ot1 VALUES +(5,0), (3,0), (0,2), (3,0), (1,3), (0,0), (1,7), (7,0), (1,7), (0,7), +(0,9), (8,2), (4,4), (9,3), (0,9), (2,5), (0,5), (8,0), (5,8), (1,5); +CREATE TABLE it1 ( +int_nokey int(11) NOT NULL, +int_key int(11) NOT NULL, +KEY int_key (int_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO it1 VALUES +(9,5), (0,4); +SELECT int_key FROM ot1 +WHERE int_nokey IN (SELECT it2.int_key +FROM it1 LEFT JOIN it2 ON it2.datetime_key); +int_key +0 +0 +0 +0 +0 +0 +2 +2 +3 +5 +5 +7 +7 +7 +8 +9 +9 +EXPLAIN +SELECT int_key FROM ot1 +WHERE int_nokey IN (SELECT it2.int_key +FROM it1 LEFT JOIN it2 ON it2.datetime_key); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 20 100.00 Start temporary +1 SIMPLE it2 NULL ref int_key int_key 4 test.ot1.int_nokey 2 90.00 Using where +1 SIMPLE it1 NULL index NULL int_key 4 NULL 2 100.00 Using index; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`int_key` AS `int_key` from `test`.`ot1` semi join (`test`.`it1` join `test`.`it2`) where ((`test`.`it2`.`int_key` = `test`.`ot1`.`int_nokey`) and (TIMESTAMP'0000-00-00 00:00:00' <> `test`.`it2`.`datetime_key`)) +DROP TABLE ot1, it1, it2; +# End of BUG#38075 +# +# BUG#50089: Second call of procedure with view in subselect crashes server +# +CREATE TABLE t1(t1field INTEGER, PRIMARY KEY(t1field)); +CREATE VIEW v1 AS +SELECT t1field AS v1field +FROM t1 a +WHERE a.t1field IN (SELECT t1field FROM t1); +INSERT INTO t1 VALUES(1),(2); +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT v1field FROM v1); +t1field +1 +2 +EXPLAIN +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT v1field FROM v1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index PRIMARY PRIMARY 4 NULL 2 100.00 Using index +1 SIMPLE a NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `t1`.`t1field` AS `t1field` from `test`.`t1` `a` join `test`.`t1` join `test`.`t1` where ((`test`.`a`.`t1field` = `t1`.`t1field`) and (`test`.`t1`.`t1field` = `t1`.`t1field`)) +SELECT t1.t1field +FROM t1 LEFT JOIN t1 AS t2 ON t1.t1field IN (SELECT v1field FROM v1); +t1field +1 +1 +2 +2 +EXPLAIN +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT v1field FROM v1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index PRIMARY PRIMARY 4 NULL 2 100.00 Using index +1 SIMPLE a NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `t1`.`t1field` AS `t1field` from `test`.`t1` `a` join `test`.`t1` join `test`.`t1` where ((`test`.`a`.`t1field` = `t1`.`t1field`) and (`test`.`t1`.`t1field` = `t1`.`t1field`)) +CREATE PROCEDURE p1() +BEGIN +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT v1field FROM v1); +END| +CALL p1; +t1field +1 +2 +CALL p1; +t1field +1 +2 +PREPARE stmt FROM +" +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT v1field FROM v1); +"; +EXECUTE stmt; +t1field +1 +2 + +EXECUTE stmt; +t1field +1 +2 +DROP PROCEDURE p1; +DROP VIEW v1; +DROP TABLE t1; +# End of BUG#50089 +# +# Bug#45191: Incorrectly initialized semi-join led to a wrong result. +# +CREATE TABLE staff (EMPNUM CHAR(3) NOT NULL, +EMPNAME CHAR(20), GRADE DECIMAL(4), CITY CHAR(15)) charset latin1; +CREATE TABLE proj (PNUM CHAR(3) NOT NULL, +PNAME CHAR(20), PTYPE CHAR(6), +BUDGET DECIMAL(9), +CITY CHAR(15)) charset latin1; +CREATE TABLE works (EMPNUM CHAR(3) NOT NULL, +PNUM CHAR(3) NOT NULL, HOURS DECIMAL(5)) charset latin1; +INSERT INTO staff VALUES ('E1','Alice',12,'Deale'); +INSERT INTO staff VALUES ('E2','Betty',10,'Vienna'); +INSERT INTO staff VALUES ('E3','Carmen',13,'Vienna'); +INSERT INTO staff VALUES ('E4','Don',12,'Deale'); +INSERT INTO staff VALUES ('E5','Ed',13,'Akron'); +INSERT INTO proj VALUES ('P1','MXSS','Design',10000,'Deale'); +INSERT INTO proj VALUES ('P2','CALM','Code',30000,'Vienna'); +INSERT INTO proj VALUES ('P3','SDP','Test',30000,'Tampa'); +INSERT INTO proj VALUES ('P4','SDP','Design',20000,'Deale'); +INSERT INTO proj VALUES ('P5','IRM','Test',10000,'Vienna'); +INSERT INTO proj VALUES ('P6','PAYR','Design',50000,'Deale'); +INSERT INTO works VALUES ('E1','P1',40); +INSERT INTO works VALUES ('E1','P2',20); +INSERT INTO works VALUES ('E1','P3',80); +INSERT INTO works VALUES ('E1','P4',20); +INSERT INTO works VALUES ('E1','P5',12); +INSERT INTO works VALUES ('E1','P6',12); +INSERT INTO works VALUES ('E2','P1',40); +INSERT INTO works VALUES ('E2','P2',80); +INSERT INTO works VALUES ('E3','P2',20); +INSERT INTO works VALUES ('E4','P2',20); +INSERT INTO works VALUES ('E4','P4',40); +INSERT INTO works VALUES ('E4','P5',80); +explain SELECT EMPNUM, EMPNAME +FROM staff +WHERE EMPNUM IN +(SELECT EMPNUM FROM works +WHERE PNUM IN +(SELECT PNUM FROM proj)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE staff NULL ALL NULL NULL NULL NULL 5 100.00 Start temporary +1 SIMPLE works NULL ALL NULL NULL NULL NULL 12 10.00 Using where; Using join buffer (hash join) +1 SIMPLE proj NULL ALL NULL NULL NULL NULL 6 16.67 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`staff`.`EMPNUM` AS `EMPNUM`,`test`.`staff`.`EMPNAME` AS `EMPNAME` from `test`.`staff` semi join (`test`.`works` join `test`.`proj`) where ((`test`.`works`.`EMPNUM` = `test`.`staff`.`EMPNUM`) and (`test`.`proj`.`PNUM` = `test`.`works`.`PNUM`)) +SELECT EMPNUM, EMPNAME +FROM staff +WHERE EMPNUM IN +(SELECT EMPNUM FROM works +WHERE PNUM IN +(SELECT PNUM FROM proj)); +EMPNUM EMPNAME +E1 Alice +E2 Betty +E3 Carmen +E4 Don +drop table staff,works,proj; +# End of bug#45191 +# +# BUG#36896: Server crash on SELECT FROM DUAL +# +create table t1 (a int); +select 1 as res from dual where (1) in (select * from t1); +res +drop table t1; + +BUG#40118 Crash when running Batched Key Access and requiring one match for each key + +create table t0(a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (a int, key(a)); +insert into t1 select * from t0; +alter table t1 add b int not null, add filler char(200); +insert into t1 select * from t1; +insert into t1 select * from t1; +select * from t0 where t0.a in (select t1.a from t1 where t1.b=0); +a +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +drop table t0, t1; +# +# BUG#32665 Query with dependent subquery is too slow +# +create table t1 ( +idIndividual int primary key +); +insert into t1 values (1),(2); +create table t2 ( +idContact int primary key, +contactType int, +idObj int +); +insert into t2 values (1,1,1),(2,2,2),(3,3,3); +create table t3 ( +idAddress int primary key, +idContact int, +postalStripped varchar(100) +); +insert into t3 values (1,1, 'foo'), (2,2,'bar'); +The following must be converted to a semi-join: +explain SELECT a.idIndividual FROM t1 a +WHERE a.idIndividual IN +( SELECT c.idObj FROM t3 cona +INNER JOIN t2 c ON c.idContact=cona.idContact +WHERE cona.postalStripped='T2H3B2' + ); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE cona NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE c NULL eq_ref PRIMARY PRIMARY 4 test.cona.idContact 1 100.00 Using where +1 SIMPLE a NULL eq_ref PRIMARY PRIMARY 4 test.c.idObj 1 100.00 Using index; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`a`.`idIndividual` AS `idIndividual` from `test`.`t1` `a` semi join (`test`.`t3` `cona` join `test`.`t2` `c`) where ((`test`.`c`.`idContact` = `test`.`cona`.`idContact`) and (`test`.`a`.`idIndividual` = `test`.`c`.`idObj`) and (`test`.`cona`.`postalStripped` = 'T2H3B2')) +drop table t1,t2,t3; +CREATE TABLE t1 (one int, two int, flag char(1)); +CREATE TABLE t2 (one int, two int, flag char(1)); +INSERT INTO t1 VALUES(1,2,'Y'),(2,3,'Y'),(3,4,'Y'),(5,6,'N'),(7,8,'N'); +INSERT INTO t2 VALUES(1,2,'Y'),(2,3,'Y'),(3,4,'Y'),(5,6,'N'),(7,8,'N'); +SELECT * FROM t1 +WHERE ROW(one,two) IN (SELECT DISTINCT one,two FROM t2 WHERE flag = 'N'); +one two flag +5 6 N +7 8 N +SELECT * FROM t1 +WHERE ROW(one,two) IN (SELECT DISTINCT one,two FROM t1 WHERE flag = 'N'); +one two flag +5 6 N +7 8 N +insert into t2 values (null,null,'N'); +insert into t2 values (null,3,'0'); +insert into t2 values (null,5,'0'); +insert into t2 values (10,null,'0'); +insert into t1 values (10,3,'0'); +insert into t1 values (10,5,'0'); +insert into t1 values (10,10,'0'); +SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = 'N') as 'test' from t1; +one two test +1 2 NULL +2 3 NULL +3 4 NULL +5 6 1 +7 8 1 +10 3 NULL +10 5 NULL +10 10 NULL +SELECT one,two from t1 where ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = 'N'); +one two +5 6 +7 8 +SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = 'N' group by one,two) as 'test' from t1; +one two test +1 2 NULL +2 3 NULL +3 4 NULL +5 6 1 +7 8 1 +10 3 NULL +10 5 NULL +10 10 NULL +SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = '0') as 'test' from t1; +one two test +1 2 0 +2 3 NULL +3 4 0 +5 6 0 +7 8 0 +10 3 NULL +10 5 NULL +10 10 NULL +SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = '0' group by one,two) as 'test' from t1; +one two test +1 2 0 +2 3 NULL +3 4 0 +5 6 0 +7 8 0 +10 3 NULL +10 5 NULL +10 10 NULL +explain SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = '0') as 'test' from t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 9 11.11 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`one` AS `one`,`test`.`t1`.`two` AS `two`,((`test`.`t1`.`one`,`test`.`t1`.`two`),(/* select#2 */ select `test`.`t2`.`one`,`test`.`t2`.`two` from `test`.`t2` where ((`test`.`t2`.`flag` = '0') and (outer_field_is_not_null, (((`test`.`t1`.`one`) = `test`.`t2`.`one`) or (`test`.`t2`.`one` is null)), true) and (outer_field_is_not_null, (((`test`.`t1`.`two`) = `test`.`t2`.`two`) or (`test`.`t2`.`two` is null)), true)) having ((outer_field_is_not_null, (`test`.`t2`.`one`), true) and (outer_field_is_not_null, (`test`.`t2`.`two`), true)))) AS `test` from `test`.`t1` +explain SELECT one,two from t1 where ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = 'N'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 9 11.11 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`one` AS `one`,`test`.`t1`.`two` AS `two` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`two` = `test`.`t2`.`two`) and (`test`.`t1`.`one` = `test`.`t2`.`one`) and (`test`.`t2`.`flag` = 'N')) +explain SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = '0' group by one,two) as 'test' from t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 9 11.11 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`one` AS `one`,`test`.`t1`.`two` AS `two`,((`test`.`t1`.`one`,`test`.`t1`.`two`),(/* select#2 */ select `test`.`t2`.`one`,`test`.`t2`.`two` from `test`.`t2` where ((`test`.`t2`.`flag` = '0') and (outer_field_is_not_null, (((`test`.`t1`.`one`) = `test`.`t2`.`one`) or (`test`.`t2`.`one` is null)), true) and (outer_field_is_not_null, (((`test`.`t1`.`two`) = `test`.`t2`.`two`) or (`test`.`t2`.`two` is null)), true)) having ((outer_field_is_not_null, (`test`.`t2`.`one`), true) and (outer_field_is_not_null, (`test`.`t2`.`two`), true)))) AS `test` from `test`.`t1` +DROP TABLE t1,t2; +CREATE TABLE t1 (a char(5), b char(5)); +INSERT INTO t1 VALUES (NULL,'aaa'), ('aaa','aaa'); +SELECT * FROM t1 WHERE (a,b) IN (('aaa','aaa'), ('aaa','bbb')); +a b +aaa aaa +DROP TABLE t1; +CREATE TABLE t1 (a CHAR(1), b VARCHAR(10)) charset utf8mb4; +INSERT INTO t1 VALUES ('a', 'aa'); +INSERT INTO t1 VALUES ('a', 'aaa'); +SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1); +a b +CREATE INDEX I1 ON t1 (a); +CREATE INDEX I2 ON t1 (b); +EXPLAIN SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index I1 I1 5 NULL 2 100.00 Using index; LooseScan +1 SIMPLE t1 NULL ALL I2 NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t1`) where (`test`.`t1`.`b` = `test`.`t1`.`a`) +SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1); +a b +CREATE TABLE t2 (a VARCHAR(1), b VARCHAR(10)) charset utf8mb4; +INSERT INTO t2 SELECT * FROM t1; +CREATE INDEX I1 ON t2 (a); +CREATE INDEX I2 ON t2 (b); +EXPLAIN SELECT a,b FROM t2 WHERE b IN (SELECT a FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index I1 I1 7 NULL 2 100.00 Using index; LooseScan +1 SIMPLE t2 NULL ALL I2 NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t2` semi join (`test`.`t2`) where (`test`.`t2`.`b` = `test`.`t2`.`a`) +SELECT a,b FROM t2 WHERE b IN (SELECT a FROM t2); +a b +EXPLAIN +SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1 WHERE LENGTH(a)<500); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index I1 I1 5 NULL 2 100.00 Using where; Using index; LooseScan +1 SIMPLE t1 NULL ALL I2 NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t1`) where ((length(`test`.`t1`.`a`) < 500) and (`test`.`t1`.`b` = `test`.`t1`.`a`)) +SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1 WHERE LENGTH(a)<500); +a b +DROP TABLE t1,t2; +# +# BUG#45928 "Differing query results depending on MRR and +# engine_condition_pushdown settings" +# +CREATE TABLE `t1` ( +`pk` int(11) NOT NULL AUTO_INCREMENT, +`time_nokey` time NOT NULL, +`varchar_key` varchar(1) NOT NULL, +`varchar_nokey` varchar(1) NOT NULL, +PRIMARY KEY (`pk`), +KEY `varchar_key` (`varchar_key`) +) AUTO_INCREMENT=12 DEFAULT CHARSET=latin1; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO `t1` VALUES (10,'00:00:00','i','i'),(11,'00:00:00','',''); +SELECT `time_nokey` G1 FROM t1 WHERE ( `varchar_nokey` , `varchar_key` ) IN ( +SELECT `varchar_nokey` , `varchar_nokey` ) AND `varchar_key` >= 'c' HAVING G1 ORDER +BY `pk` ; +G1 +DROP TABLE t1; +# +# BUG#45863 "Assertion failed: (fixed == 0), function fix_fields(), +# file item.cc, line 4448" +# +DROP TABLE IF EXISTS C, BB; +CREATE TABLE C ( +varchar_nokey varchar(1) NOT NULL +); +INSERT INTO C VALUES +('k'),('a'),(''),('u'),('e'),('v'),('i'), +('t'),('u'),('f'),('u'),('m'),('j'),('f'), +('v'),('j'),('g'),('e'),('h'),('z'); +CREATE TABLE BB ( +varchar_nokey varchar(1) NOT NULL +); +INSERT INTO BB VALUES ('i'),('t'); +SELECT varchar_nokey FROM C +WHERE (varchar_nokey, OUTR) IN (SELECT varchar_nokey +FROM BB); +ERROR 42S22: Unknown column 'OUTR' in 'IN/ALL/ANY subquery' +SELECT varchar_nokey FROM C +WHERE (varchar_nokey, OUTR) IN (SELECT varchar_nokey, varchar_nokey +FROM BB); +ERROR 42S22: Unknown column 'OUTR' in 'IN/ALL/ANY subquery' +DROP TABLE C,BB; +# +# During work with BUG#45863 I had problems with a query that was +# optimized differently in regular and prepared mode. +# Because there was a bug in one of the selected strategies, I became +# aware of the problem. Adding an EXPLAIN query to catch this. +DROP TABLE IF EXISTS t1, t2, t3; +CREATE TABLE t1 +(EMPNUM CHAR(3) NOT NULL, +EMPNAME CHAR(20), +GRADE DECIMAL(4), +CITY CHAR(15)) charset latin1; +CREATE TABLE t2 +(PNUM CHAR(3) NOT NULL, +PNAME CHAR(20), +PTYPE CHAR(6), +BUDGET DECIMAL(9), +CITY CHAR(15)) charset latin1; +CREATE TABLE t3 +(EMPNUM CHAR(3) NOT NULL, +PNUM CHAR(3) NOT NULL, +HOURS DECIMAL(5)) charset latin1; +INSERT INTO t1 VALUES ('E1','Alice',12,'Deale'); +INSERT INTO t1 VALUES ('E2','Betty',10,'Vienna'); +INSERT INTO t1 VALUES ('E3','Carmen',13,'Vienna'); +INSERT INTO t1 VALUES ('E4','Don',12,'Deale'); +INSERT INTO t1 VALUES ('E5','Ed',13,'Akron'); +INSERT INTO t2 VALUES ('P1','MXSS','Design',10000,'Deale'); +INSERT INTO t2 VALUES ('P2','CALM','Code',30000,'Vienna'); +INSERT INTO t2 VALUES ('P3','SDP','Test',30000,'Tampa'); +INSERT INTO t2 VALUES ('P4','SDP','Design',20000,'Deale'); +INSERT INTO t2 VALUES ('P5','IRM','Test',10000,'Vienna'); +INSERT INTO t2 VALUES ('P6','PAYR','Design',50000,'Deale'); +INSERT INTO t3 VALUES ('E1','P1',40); +INSERT INTO t3 VALUES ('E1','P2',20); +INSERT INTO t3 VALUES ('E1','P3',80); +INSERT INTO t3 VALUES ('E1','P4',20); +INSERT INTO t3 VALUES ('E1','P5',12); +INSERT INTO t3 VALUES ('E1','P6',12); +INSERT INTO t3 VALUES ('E2','P1',40); +INSERT INTO t3 VALUES ('E2','P2',80); +INSERT INTO t3 VALUES ('E3','P2',20); +INSERT INTO t3 VALUES ('E4','P2',20); +INSERT INTO t3 VALUES ('E4','P4',40); +INSERT INTO t3 VALUES ('E4','P5',80); +CREATE UNIQUE INDEX t1_IDX ON t1(EMPNUM); +EXPLAIN SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN +(SELECT EMPNUM +FROM t3 +WHERE PNUM IN +(SELECT PNUM +FROM t2 +WHERE PTYPE = 'Design')); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL eq_ref t1_IDX t1_IDX 3 test.t3.EMPNUM 1 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = `test`.`t3`.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) +PREPARE stmt FROM "EXPLAIN SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN + (SELECT EMPNUM + FROM t3 + WHERE PNUM IN + (SELECT PNUM + FROM t2 + WHERE PTYPE = 'Design'))"; +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL eq_ref t1_IDX t1_IDX 3 test.t3.EMPNUM 1 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = `test`.`t3`.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) + +This line is only in place to help --skip_if_hypergraph diffing some more. + +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL eq_ref t1_IDX t1_IDX 3 test.t3.EMPNUM 1 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = `test`.`t3`.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) +DEALLOCATE PREPARE stmt; +DROP INDEX t1_IDX ON t1; +CREATE INDEX t1_IDX ON t1(EMPNUM); +EXPLAIN SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN +(SELECT EMPNUM +FROM t3 +WHERE PNUM IN +(SELECT PNUM +FROM t2 +WHERE PTYPE = 'Design')); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ref t1_IDX t1_IDX 3 test.t3.EMPNUM 2 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = `test`.`t3`.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) +PREPARE stmt FROM "EXPLAIN SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN + (SELECT EMPNUM + FROM t3 + WHERE PNUM IN + (SELECT PNUM + FROM t2 + WHERE PTYPE = 'Design'))"; +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ref t1_IDX t1_IDX 3 test.t3.EMPNUM 2 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = `test`.`t3`.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) + +This line is only in place to help --skip_if_hypergraph diffing some more. + +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ref t1_IDX t1_IDX 3 test.t3.EMPNUM 2 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = `test`.`t3`.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) +DEALLOCATE PREPARE stmt; +DROP INDEX t1_IDX ON t1; +EXPLAIN SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN +(SELECT EMPNUM +FROM t3 +WHERE PNUM IN +(SELECT PNUM +FROM t2 +WHERE PTYPE = 'Design')); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 20.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = `test`.`t3`.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) +PREPARE stmt FROM "EXPLAIN SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN + (SELECT EMPNUM + FROM t3 + WHERE PNUM IN + (SELECT PNUM + FROM t2 + WHERE PTYPE = 'Design'))"; +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 20.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = `test`.`t3`.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) + +This line is only in place to help --skip_if_hypergraph diffing some more. + +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 20.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = `test`.`t3`.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) +DEALLOCATE PREPARE stmt; +DROP TABLE t1, t2, t3; +# +# BUG#45221 Query SELECT pk FROM C WHERE pk IN (SELECT int_key) failing +# +CREATE TABLE t1 ( +i1_key INT, +i2 INT, +i3 INT, +KEY i1_index (i1_key) +); +INSERT INTO t1 VALUES (9,1,2), (9,2,1); +CREATE TABLE t2 ( +pk INT NOT NULL, +i1 INT, +PRIMARY KEY (pk) +); +INSERT INTO t2 VALUES (9,1); +SELECT pk +FROM t2 +WHERE +pk IN ( +SELECT i1_key +FROM t1 +WHERE t1.i2 < t1.i3 XOR t2.i1 > 1 +ORDER BY t1.i2 desc); +pk +9 +DROP TABLE t1,t2; +# BUG#50361 Doublenested noncorrelated subquery with FirstMatch and join cache wrong result +# +CREATE TABLE t1( +id INTEGER +); +INSERT INTO t1 VALUES(10),(20); +create table t2 select * from t1; +create table t3 select * from t1; +SELECT * +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t2 +WHERE 1 IN(SELECT 1 +FROM t3)); +id +10 +20 +explain SELECT * +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t2 +WHERE 1 IN(SELECT 1 +FROM t3)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 End temporary; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where true +delete from t2; +delete from t3; +INSERT INTO t1 VALUES(30),(40),(50),(60),(70),(80),(90); +insert into t2 select * from t1; +insert into t3 select * from t1; +create table t4 select * from t1; +SELECT * +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t2 +WHERE 1 IN(SELECT 1 +FROM t3 +WHERE 1 IN(SELECT 1 +FROM t4))); +id +10 +20 +30 +40 +50 +60 +70 +80 +90 +explain SELECT * +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t2 +WHERE 1 IN(SELECT 1 +FROM t3 +WHERE 1 IN(SELECT 1 +FROM t4))); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 9 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 9 100.00 Using join buffer (hash join) +1 SIMPLE t4 NULL ALL NULL NULL NULL NULL 9 100.00 End temporary; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 9 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3` join `test`.`t4`) where true +SELECT * +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t1))); +id +10 +20 +30 +40 +50 +60 +70 +80 +90 +drop table t1,t2,t3,t4; +# +# Bug#53236 Segfault in DTCollation::set(DTCollation&) +# +CREATE TABLE t1 ( +pk INTEGER AUTO_INCREMENT, +col_varchar VARCHAR(1), +PRIMARY KEY (pk) +) +; +INSERT INTO t1 (col_varchar) +VALUES +('w'), +('m') +; +SELECT table1.pk +FROM ( t1 AS table1 JOIN t1 AS table2 ON (table1.col_varchar = +table2.col_varchar) ) +WHERE ( 1, 2 ) IN ( SELECT SUBQUERY1_t1.pk AS SUBQUERY1_field1, +SUBQUERY1_t1.pk AS SUBQUERY1_field2 +FROM ( t1 AS SUBQUERY1_t1 JOIN t1 AS SUBQUERY1_t2 +ON (SUBQUERY1_t2.col_varchar = +SUBQUERY1_t1.col_varchar) ) ) +; +pk +drop table t1; +# +# BUG#53298 "wrong result with semijoin (no semijoin strategy chosen)" +# +create table t1 (uid int, fid int); +insert into t1 values (1,1), (3,1); +create table t2 (uid int, name varchar(128)); +insert into t2 values (1, "A"), (2, "B"); +create table t3 (uid int, fid int, index(uid)); +insert into t3 values (1,3), (1,3); +create table t4 (uid int); +insert into t4 values (3); +explain select t2.uid from t2, t1 +where t1.uid in (select t4.uid from t4, t3 where t3.uid=1 and t4.uid=t3.fid) +and t2.uid=t1.fid; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t4 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ref uid uid 5 const 1 50.00 Using where +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`uid` AS `uid` from `test`.`t2` join `test`.`t1` semi join (`test`.`t4` join `test`.`t3`) where ((`test`.`t3`.`fid` = `test`.`t4`.`uid`) and (`test`.`t1`.`uid` = `test`.`t4`.`uid`) and (`test`.`t3`.`uid` = 1) and (`test`.`t2`.`uid` = `test`.`t1`.`fid`)) +select t2.uid from t2, t1 +where t1.uid in (select t4.uid from t4, t3 where t3.uid=1 and t4.uid=t3.fid) +and t2.uid=t1.fid; +uid +1 +drop table t1,t2,t3,t4; +CREATE TABLE t1 ( +pk int, +a varchar(1), +b varchar(4), +c varchar(4), +d varchar(4), +PRIMARY KEY (pk) +) charset utf8mb4; +INSERT INTO t1 VALUES (1,'o','ffff','ffff','ffoo'),(2,'f','ffff','ffff','ffff'); +CREATE TABLE t2 LIKE t1; +INSERT INTO t2 VALUES (1,'i','iiii','iiii','iiii'),(2,'f','ffff','ffff','ffff'); +EXPLAIN SELECT pk FROM t1 WHERE (a) IN (SELECT a FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 100.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`a` = `test`.`t2`.`a`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (a) IN (SELECT a FROM t2 WHERE pk > 0); +pk +2 +SELECT pk FROM t1 WHERE (b,c,d) IN (SELECT b,c,d FROM t2 WHERE pk > 0); +pk +2 +DROP TABLE t1, t2; +CREATE TABLE t1 (f1 INT, f2 DECIMAL(5,3)) ENGINE=MyISAM; +INSERT INTO t1 (f1, f2) VALUES (1, 1.789); +INSERT INTO t1 (f1, f2) VALUES (13, 1.454); +INSERT INTO t1 (f1, f2) VALUES (10, 1.668); +CREATE TABLE t2 LIKE t1; +INSERT INTO t2 VALUES (1, 1.789); +INSERT INTO t2 VALUES (13, 1.454); +EXPLAIN SELECT COUNT(*) FROM t1 WHERE (f1,f2) IN (SELECT f1,f2 FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`f2` = `test`.`t2`.`f2`) and (`test`.`t1`.`f1` = `test`.`t2`.`f1`)) +SELECT COUNT(*) FROM t1 WHERE (f1,f2) IN (SELECT f1,f2 FROM t2); +COUNT(*) +2 +DROP TABLE t1, t2; +CREATE TABLE t1 ( +ID int(11) NOT NULL auto_increment, +Name char(35) NOT NULL default '', +Country char(3) NOT NULL default '', +Population int(11) NOT NULL default '0', +PRIMARY KEY (ID), +INDEX (Population), +INDEX (Country) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t2 ( +Code char(3) NOT NULL default '', +Name char(52) NOT NULL default '', +SurfaceArea float(10,2) NOT NULL default '0.00', +Population int(11) NOT NULL default '0', +Capital int(11) default NULL, +PRIMARY KEY (Code), +UNIQUE INDEX (Name), +INDEX (Population) +) charset utf8mb4; +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t3 ( +Country char(3) NOT NULL default '', +Language char(30) NOT NULL default '', +Percentage float(3,1) NOT NULL default '0.0', +PRIMARY KEY (Country, Language), +INDEX (Percentage) +) charset utf8mb4; +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +EXPLAIN SELECT Name FROM t2 +WHERE t2.Code IN (SELECT Country FROM t1 WHERE Population > 5000000) +AND +t2.Code IN (SELECT Country FROM t3 +WHERE Language='English' AND Percentage > 10 AND +t2.Population > 100000); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL PRIMARY,Percentage NULL NULL NULL 22 9.55 Using where +1 SIMPLE t1 NULL ref Population,Country Country 12 test.t3.Country 3 3.33 Using where; LooseScan +1 SIMPLE t2 NULL eq_ref PRIMARY,Population PRIMARY 12 test.t3.Country 1 75.00 Using where +Warnings: +Note 1276 Field or reference 'test.t2.Population' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t2`.`Name` AS `Name` from `test`.`t3` join `test`.`t2` semi join (`test`.`t1`) where ((`test`.`t1`.`Country` = `test`.`t3`.`Country`) and (`test`.`t2`.`Code` = `test`.`t3`.`Country`) and (`test`.`t3`.`Language` = 'English') and (`test`.`t3`.`Percentage` > 10) and (`test`.`t2`.`Population` > 100000) and (`test`.`t1`.`Population` > 5000000)) +EXPLAIN FORMAT=JSON SELECT Name FROM t2 +WHERE t2.Code IN (SELECT Country FROM t1 WHERE Population > 5000000) +AND +t2.Code IN (SELECT Country FROM t3 +WHERE Language='English' AND Percentage > 10 AND +t2.Population > 100000); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "5.18" + }, + "nested_loop": [ + { + "table": { + "table_name": "t3", + "access_type": "ALL", + "possible_keys": [ + "PRIMARY", + "Percentage" + ], + "rows_examined_per_scan": 22, + "rows_produced_per_join": 2, + "filtered": "9.55", + "cost_info": { + "read_cost": "2.67", + "eval_cost": "0.21", + "prefix_cost": "2.88", + "data_read_per_join": "302" + }, + "used_columns": [ + "Country", + "Language", + "Percentage" + ], + "attached_condition": "((`test`.`t3`.`Language` = 'English') and (`test`.`t3`.`Percentage` > 10))" + } + }, + { + "table": { + "table_name": "t1", + "access_type": "ref", + "possible_keys": [ + "Population", + "Country" + ], + "key": "Country", + "used_key_parts": [ + "Country" + ], + "key_length": "12", + "ref": [ + "test.t3.Country" + ], + "rows_examined_per_scan": 3, + "rows_produced_per_join": 0, + "filtered": "3.33", + "loosescan": true, + "cost_info": { + "read_cost": "1.57", + "eval_cost": "0.02", + "prefix_cost": "5.14", + "data_read_per_join": "37" + }, + "used_columns": [ + "Country", + "Population" + ], + "attached_condition": "(`test`.`t1`.`Population` > 5000000)" + } + }, + { + "table": { + "table_name": "t2", + "access_type": "eq_ref", + "possible_keys": [ + "PRIMARY", + "Population" + ], + "key": "PRIMARY", + "used_key_parts": [ + "Code" + ], + "key_length": "12", + "ref": [ + "test.t3.Country" + ], + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "75.00", + "cost_info": { + "read_cost": "0.03", + "eval_cost": "0.16", + "prefix_cost": "5.19", + "data_read_per_join": "377" + }, + "used_columns": [ + "Code", + "Name", + "Population" + ], + "attached_condition": "(`test`.`t2`.`Population` > 100000)" + } + } + ] + } +} +Warnings: +Note 1276 Field or reference 'test.t2.Population' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t2`.`Name` AS `Name` from `test`.`t3` join `test`.`t2` semi join (`test`.`t1`) where ((`test`.`t1`.`Country` = `test`.`t3`.`Country`) and (`test`.`t2`.`Code` = `test`.`t3`.`Country`) and (`test`.`t3`.`Language` = 'English') and (`test`.`t3`.`Percentage` > 10) and (`test`.`t2`.`Population` > 100000) and (`test`.`t1`.`Population` > 5000000)) +DROP TABLE t1,t2,t3; +CREATE TABLE t1 ( +Code char(3) NOT NULL DEFAULT '', +Name char(52) NOT NULL DEFAULT '', +Continent enum('Asia','Europe','North America','Africa','Oceania','Antarctica','South America') NOT NULL DEFAULT 'Asia', +Region char(26) NOT NULL DEFAULT '', +SurfaceArea float(10,2) NOT NULL DEFAULT '0.00', +IndepYear smallint(6) DEFAULT NULL, +Population int(11) NOT NULL DEFAULT '0', +LifeExpectancy float(3,1) DEFAULT NULL, +GNP float(10,2) DEFAULT NULL, +GNPOld float(10,2) DEFAULT NULL, +LocalName char(45) NOT NULL DEFAULT '', +GovernmentForm char(45) NOT NULL DEFAULT '', +HeadOfState char(60) DEFAULT NULL, +Capital int(11) DEFAULT NULL, +Code2 char(2) NOT NULL DEFAULT '', +PRIMARY KEY (Code) +) charset utf8mb4; +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t2 ( +ID int(11) NOT NULL AUTO_INCREMENT, +Name char(35) NOT NULL DEFAULT '', +CountryCode char(3) NOT NULL DEFAULT '', +District char(20) NOT NULL DEFAULT '', +Population int(11) NOT NULL DEFAULT '0', +PRIMARY KEY (ID), +KEY CountryCode (CountryCode) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +set names latin1; +Fill the table with test data +This must not use LooseScan: +EXPLAIN SELECT Name FROM t1 +WHERE t1.Code IN ( +SELECT t2.CountryCode FROM t2 WHERE Population > 5000000); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL CountryCode NULL NULL NULL 545 33.33 Using where; Start temporary +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 12 test.t2.CountryCode 1 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`Name` AS `Name` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`Code` = `test`.`t2`.`CountryCode`) and (`test`.`t2`.`Population` > 5000000)) +SELECT Name FROM t1 +WHERE t1.Code IN ( +SELECT t2.CountryCode FROM t2 WHERE Population > 5000000); +Name +Austria +Canada +China +Czech Republic +drop table t1, t2; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4); +create table t1 (a int, b int, key(a)); +insert into t1 select a,a from t0; +create table t2 (a int, b int, primary key(a)); +insert into t2 select * from t1; +Table t2, unlike table t1, should be displayed as pulled out +explain select * from t0 +where t0.a in ( select t1.a from t1,t2 where t2.a=t0.a and +t1.b=t2.b); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL PRIMARY NULL NULL NULL 5 100.00 NULL +1 SIMPLE t1 NULL ref a a 5 test.t2.a 1 20.00 Using where; LooseScan +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 5 20.00 Using where; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t0.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a` from `test`.`t2` join `test`.`t0` semi join (`test`.`t1`) where ((`test`.`t1`.`a` = `test`.`t2`.`a`) and (`test`.`t0`.`a` = `test`.`t2`.`a`) and (`test`.`t1`.`b` = `test`.`t2`.`b`)) +update t1 set a=3, b=11 where a=4; +update t2 set b=11 where a=3; +select * from t0 where t0.a in (select t1.a from t1, t2 where t2.a=t0.a and t1.b=t2.b); +a +0 +1 +2 +3 +drop table t0, t1, t2; +CREATE TABLE t1 ( +id int(11) NOT NULL, +PRIMARY KEY (id)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t2 ( +id int(11) NOT NULL, +fid int(11) NOT NULL, +PRIMARY KEY (id)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t1 values(1); +insert into t2 values(1,7503),(2,1); +explain select count(*) +from t1 +where fid IN (select fid from t2 where (id between 7502 and 8420) order by fid ); +ERROR 42S22: Unknown column 'fid' in 'IN/ALL/ANY subquery' +drop table t1, t2; +create table t1 (a int, b int, key (a), key (b)); +insert into t1 values (2,4),(2,4),(2,4); +select t1.a from t1 +where +t1.a in (select 1 from t1 where t1.a in (select 1 from t1) group by t1.a); +a +drop table t1; +create table t1(a int,b int,key(a),key(b)); +insert into t1 values (1,1),(2,2),(3,3); +select 1 from t1 +where t1.a not in (select 1 from t1 +where t1.a in (select 1 from t1) +group by t1.b); +1 +1 +1 +drop table t1; +CREATE TABLE t1 +(EMPNUM CHAR(3) NOT NULL, +EMPNAME CHAR(20), +GRADE DECIMAL(4), +CITY CHAR(15)); +CREATE TABLE t2 +(PNUM CHAR(3) NOT NULL, +PNAME CHAR(20), +PTYPE CHAR(6), +BUDGET DECIMAL(9), +CITY CHAR(15)); +CREATE TABLE t3 +(EMPNUM CHAR(3) NOT NULL, +PNUM CHAR(3) NOT NULL, +HOURS DECIMAL(5)); +INSERT INTO t1 VALUES ('E1','Alice',12,'Deale'); +INSERT INTO t1 VALUES ('E2','Betty',10,'Vienna'); +INSERT INTO t1 VALUES ('E3','Carmen',13,'Vienna'); +INSERT INTO t1 VALUES ('E4','Don',12,'Deale'); +INSERT INTO t1 VALUES ('E5','Ed',13,'Akron'); +INSERT INTO t2 VALUES ('P1','MXSS','Design',10000,'Deale'); +INSERT INTO t2 VALUES ('P2','CALM','Code',30000,'Vienna'); +INSERT INTO t2 VALUES ('P3','SDP','Test',30000,'Tampa'); +INSERT INTO t2 VALUES ('P4','SDP','Design',20000,'Deale'); +INSERT INTO t2 VALUES ('P5','IRM','Test',10000,'Vienna'); +INSERT INTO t2 VALUES ('P6','PAYR','Design',50000,'Deale'); +INSERT INTO t3 VALUES ('E1','P1',40); +INSERT INTO t3 VALUES ('E1','P2',20); +INSERT INTO t3 VALUES ('E1','P3',80); +INSERT INTO t3 VALUES ('E1','P4',20); +INSERT INTO t3 VALUES ('E1','P5',12); +INSERT INTO t3 VALUES ('E1','P6',12); +INSERT INTO t3 VALUES ('E2','P1',40); +INSERT INTO t3 VALUES ('E2','P2',80); +INSERT INTO t3 VALUES ('E3','P2',20); +INSERT INTO t3 VALUES ('E4','P2',20); +INSERT INTO t3 VALUES ('E4','P4',40); +INSERT INTO t3 VALUES ('E4','P5',80); +SELECT * FROM t1; +EMPNUM EMPNAME GRADE CITY +E1 Alice 12 Deale +E2 Betty 10 Vienna +E3 Carmen 13 Vienna +E4 Don 12 Deale +E5 Ed 13 Akron +CREATE UNIQUE INDEX t1_IDX ON t1(EMPNUM); +SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN +(SELECT EMPNUM +FROM t3 +WHERE PNUM IN +(SELECT PNUM +FROM t2 +WHERE PTYPE = 'Design')); +EMPNAME +Alice +Betty +Don +DROP INDEX t1_IDX ON t1; +CREATE INDEX t1_IDX ON t1(EMPNUM); +SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN +(SELECT EMPNUM +FROM t3 +WHERE PNUM IN +(SELECT PNUM +FROM t2 +WHERE PTYPE = 'Design')); +EMPNAME +Alice +Betty +Don +DROP INDEX t1_IDX ON t1; +SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN +(SELECT EMPNUM +FROM t3 +WHERE PNUM IN +(SELECT PNUM +FROM t2 +WHERE PTYPE = 'Design')); +EMPNAME +Alice +Betty +Don +DROP TABLE t1, t2, t3; +CREATE TABLE t1 (f1 INT NOT NULL); +CREATE VIEW v1 (a) AS SELECT f1 IN (SELECT f1 FROM t1) FROM t1; +SELECT * FROM v1; +a +drop view v1; +drop table t1; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1(a int, b int); +insert into t1 values (0,0),(1,1),(2,2); +create table t2 as select * from t1; +create table t3 (pk int, a int, primary key(pk)); +insert into t3 select a,a from t0; +explain +select * from t1 left join t2 on (t2.a= t1.a and t2.a in (select pk from t3)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE t3 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using index +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` left join (`test`.`t3` join `test`.`t2`) on(((`test`.`t3`.`pk` = `test`.`t1`.`a`) and (`test`.`t2`.`a` = `test`.`t1`.`a`))) where true +drop table t0, t1, t2, t3; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (a int) as select A.a + 10 *(B.a + 10*C.a) as a from t0 A, t0 B, t0 C; +create table t2 (id int, a int, primary key(id), key(a)) charset utf8mb4 as select a as id, a as a from t1; +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `id` int NOT NULL, + `a` int DEFAULT NULL, + PRIMARY KEY (`id`), + KEY `a` (`a`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +set @a=0; +create table t3 as select * from t2 limit 0; +insert into t3 select @a:=@a+1, t2.a from t2, t0; +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +insert into t3 select @a:=@a+1, t2.a from t2, t0; +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +insert into t3 select @a:=@a+1, t2.a from t2, t0; +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +alter table t3 add primary key(id), add 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); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL index a a 5 NULL 30000 3.33 Using where; Using index; LooseScan +1 SIMPLE t2 NULL ref a a 5 test.t3.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select count(`test`.`t2`.`a`) AS `count(a)` from `test`.`t2` semi join (`test`.`t3`) where (`test`.`t2`.`a` = `test`.`t3`.`a`) +select count(a) from t2 where a in ( SELECT a FROM t3); +count(a) +1000 +drop table t0,t1,t2,t3; +# +# Bug#33062: subquery in stored routine cause crash +# +CREATE TABLE t1(a INT); +CREATE TABLE t2(c INT); +CREATE PROCEDURE p1(v1 int) +BEGIN +SELECT 1 FROM t1 WHERE a = v1 AND a IN (SELECT c FROM t2); +END +// +CREATE PROCEDURE p2(v1 int) +BEGIN +SELECT 1 FROM t1 WHERE a IN (SELECT c FROM t2); +END +// +CREATE PROCEDURE p3(v1 int) +BEGIN +SELECT 1 +FROM +t1 t01,t1 t02,t1 t03,t1 t04,t1 t05,t1 t06,t1 t07,t1 t08, +t1 t09,t1 t10,t1 t11,t1 t12,t1 t13,t1 t14,t1 t15,t1 t16, +t1 t17,t1 t18,t1 t19,t1 t20,t1 t21,t1 t22,t1 t23,t1 t24, +t1 t25,t1 t26,t1 t27,t1 t28,t1 t29,t1 t30,t1 t31,t1 t32, +t1 t33,t1 t34,t1 t35,t1 t36,t1 t37,t1 t38,t1 t39,t1 t40, +t1 t41,t1 t42,t1 t43,t1 t44,t1 t45,t1 t46,t1 t47,t1 t48, +t1 t49,t1 t50,t1 t51,t1 t52,t1 t53,t1 t54,t1 t55,t1 t56, +t1 t57,t1 t58,t1 t59,t1 t60 +WHERE t01.a IN (SELECT c FROM t2); +END +// +CREATE PROCEDURE p4(v1 int) +BEGIN +SELECT 1 +FROM +t1 t01,t1 t02,t1 t03,t1 t04,t1 t05,t1 t06,t1 t07,t1 t08, +t1 t09,t1 t10,t1 t11,t1 t12,t1 t13,t1 t14,t1 t15,t1 t16, +t1 t17,t1 t18,t1 t19,t1 t20,t1 t21,t1 t22,t1 t23,t1 t24, +t1 t25,t1 t26,t1 t27,t1 t28,t1 t29,t1 t30,t1 t31,t1 t32, +t1 t33,t1 t34,t1 t35,t1 t36,t1 t37,t1 t38,t1 t39,t1 t40, +t1 t41,t1 t42,t1 t43,t1 t44,t1 t45,t1 t46,t1 t47,t1 t48, +t1 t49,t1 t50,t1 t51,t1 t52,t1 t53,t1 t54,t1 t55,t1 t56, +t1 t57,t1 t58,t1 t59,t1 t60 +WHERE t01.a = v1 AND t01.a IN (SELECT c FROM t2); +END +// +CALL p1(1); +1 +CALL p2(1); +1 +CALL p3(1); +1 +CALL p4(1); +1 +DROP TABLE t1, t2; +DROP PROCEDURE p1; +DROP PROCEDURE p2; +DROP PROCEDURE p3; +DROP PROCEDURE p4; +# +# Bug#48213 Materialized subselect crashes if using GEOMETRY type +# +CREATE TABLE t1 ( +pk int, +a varchar(1), +b varchar(4), +c tinyblob, +d blob, +e mediumblob, +f longblob, +g tinytext, +h text, +i mediumtext, +j longtext, +k geometry, +PRIMARY KEY (pk) +) charset utf8mb4; +INSERT INTO t1 VALUES (1,'o','ffff','ffff','ffoo','ffff','ffff','ffff','ffff','ffff','ffff',ST_GeomFromText('POLYGON((0 0, 0 2, 2 2, 2 0, 0 0))')), (2,'f','ffff','ffff','ffff', 'ffff','ffff','ffff','ffff','ffff','ffff',ST_GeomFromText('POLYGON((0 0, 0 2, 2 2, 2 0, 0 0))')); +CREATE TABLE t2 LIKE t1; +INSERT INTO t2 VALUES (1,'i','iiii','iiii','iiii','iiii','ffff','ffff','ffff','ffff','ffff',ST_GeomFromText('POLYGON((0 0, 0 2, 2 2, 2 0, 0 0))')), (2,'f','ffff','ffff','ffff','ffff','ffff','ffff','ffff','ffff','ffff',ST_GeomFromText('POLYGON((0 0, 0 2, 2 2, 2 0, 0 0))')); +EXPLAIN SELECT pk FROM t1 WHERE (a, b) IN (SELECT a, b FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 100.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`b` = `test`.`t2`.`b`) and (`test`.`t1`.`a` = `test`.`t2`.`a`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (a, b) IN (SELECT a, b FROM t2 WHERE pk > 0); +pk +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, c) IN (SELECT b, c FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 100.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`c` = `test`.`t2`.`c`) and (`test`.`t1`.`b` = `test`.`t2`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, c) IN (SELECT b, c FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, d) IN (SELECT b, d FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 100.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`d` = `test`.`t2`.`d`) and (`test`.`t1`.`b` = `test`.`t2`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, d) IN (SELECT b, d FROM t2 WHERE pk > 0); +pk +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, e) IN (SELECT b, e FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 100.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`e` = `test`.`t2`.`e`) and (`test`.`t1`.`b` = `test`.`t2`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, e) IN (SELECT b, e FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, f) IN (SELECT b, f FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 100.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`f` = `test`.`t2`.`f`) and (`test`.`t1`.`b` = `test`.`t2`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, f) IN (SELECT b, f FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, g) IN (SELECT b, g FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 100.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`g` = `test`.`t2`.`g`) and (`test`.`t1`.`b` = `test`.`t2`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, g) IN (SELECT b, g FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, h) IN (SELECT b, h FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 100.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`h` = `test`.`t2`.`h`) and (`test`.`t1`.`b` = `test`.`t2`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, h) IN (SELECT b, h FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, i) IN (SELECT b, i FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 100.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`i` = `test`.`t2`.`i`) and (`test`.`t1`.`b` = `test`.`t2`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, i) IN (SELECT b, i FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, j) IN (SELECT b, j FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 100.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`j` = `test`.`t2`.`j`) and (`test`.`t1`.`b` = `test`.`t2`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, j) IN (SELECT b, j FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, k) IN (SELECT b, k FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 100.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`k` = `test`.`t2`.`k`) and (`test`.`t1`.`b` = `test`.`t2`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, k) IN (SELECT b, k FROM t2 WHERE pk > 0); +pk +1 +2 +DROP TABLE t1, t2; +# End of Bug#48213 +# +# BUG#53060: LooseScan semijoin strategy does not return all rows +# +CREATE TABLE t1 (i INTEGER); +INSERT INTO t1 VALUES (1), (2), (3), (4), (5); +CREATE TABLE t2 (i INTEGER, j INTEGER, KEY k(i, j)); +INSERT INTO t2 VALUES (1, 0), (1, 1), (2, 0), (2, 1); +EXPLAIN +SELECT * FROM t1 WHERE (i) IN (SELECT i FROM t2 where j > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index k k 10 NULL 4 33.33 Using where; Using index; LooseScan +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 20.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`i` = `test`.`t2`.`i`) and (`test`.`t2`.`j` > 0)) +SELECT * FROM t1 WHERE (i) IN (SELECT i FROM t2 where j > 0); +i +1 +2 +DROP TABLE t1, t2; +# End of BUG#53060 +# +# Bug#53305 "Duplicate weedout + join buffer (join cache --level=7,8) loses rows" +# +create table t1 (uid int, fid int, index(uid)); +insert into t1 values +(1,1), (1,2), (1,3), (1,4), +(2,5), (2,6), (2,7), (2,8), +(3,1), (3,2), (3,9); +create table t2 (uid int primary key, name varchar(128), index(name)); +insert into t2 values +(1, "A"), (2, "B"), (3, "C"), (4, "D"), (5, "E"), +(6, "F"), (7, "G"), (8, "H"), (9, "I"); +create table t3 (uid int, fid int, index(uid)); +insert into t3 values +(1,1), (1,2), (1,3),(1,4), +(2,5), (2,6), (2,7), (2,8), +(3,1), (3,2), (3,9); +create table t4 (uid int primary key, name varchar(128), index(name)); +insert into t4 values +(1, "A"), (2, "B"), (3, "C"), (4, "D"), (5, "E"), +(6, "F"), (7, "G"), (8, "H"), (9, "I"); +explain select name from t2, t1 +where t1.uid in (select t4.uid from t4, t3 where t3.uid=1 and t4.uid=t3.fid) +and t2.uid=t1.fid; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ref uid uid 5 const 4 100.00 Using where; Start temporary +1 SIMPLE t4 NULL eq_ref PRIMARY PRIMARY 4 test.t3.fid 1 100.00 Using index +1 SIMPLE t1 NULL ref uid uid 5 test.t3.fid 2 100.00 Using where; End temporary +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.fid 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`name` AS `name` from `test`.`t4` join `test`.`t2` join `test`.`t1` semi join (`test`.`t3`) where ((`test`.`t4`.`uid` = `test`.`t3`.`fid`) and (`test`.`t1`.`uid` = `test`.`t3`.`fid`) and (`test`.`t3`.`uid` = 1) and (`test`.`t2`.`uid` = `test`.`t1`.`fid`)) +select name from t2, t1 +where t1.uid in (select t4.uid from t4, t3 where t3.uid=1 and t4.uid=t3.fid) +and t2.uid=t1.fid; +name +A +A +B +B +C +D +E +F +G +H +I +drop table t1,t2,t3,t4; +# +# Bug#43768 Prepared query with nested subqueries core dump on second execution +# +CREATE TABLE t1 ( +id INT PRIMARY KEY, +partner_id VARCHAR(35) +) charset utf8mb4; +INSERT INTO t1 VALUES +(1, 'partner1'), (2, 'partner2'), +(3, 'partner3'), (4, 'partner4'); +CREATE TABLE t2 ( +id INT NOT NULL, +t1_line_id INT, +article_id VARCHAR(20), +PRIMARY KEY(id, t1_line_id) +) charset utf8mb4; +INSERT INTO t2 VALUES +(1, 1, 'sup'), (2, 1, 'sup'), +(2, 2, 'sup'), (2, 3, 'sup'), +(2, 4, 'imp'), (3, 1, 'sup'), +(4, 1, 'sup'); +CREATE TABLE t3 ( +user_id VARCHAR(50), +article_id VARCHAR(20) NOT NULL, +PRIMARY KEY(user_id) +) charset utf8mb4; +INSERT INTO t3 VALUES('nicke', 'imp'); +EXPLAIN +SELECT t1.partner_id +FROM t1 +WHERE t1.id IN ( +SELECT t2.id +FROM t2 +WHERE article_id IN ( +SELECT article_id FROM t3 +WHERE user_id = 'nicke' + ) +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL system PRIMARY NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL PRIMARY NULL NULL NULL 7 14.29 Using where; Start temporary +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.id 1 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`partner_id` AS `partner_id` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`id` = `test`.`t2`.`id`) and (`test`.`t2`.`article_id` = 'imp')) +SELECT t1.partner_id +FROM t1 +WHERE t1.id IN ( +SELECT t2.id +FROM t2 +WHERE article_id IN ( +SELECT article_id FROM t3 +WHERE user_id = 'nicke' + ) +); +partner_id +partner2 +PREPARE stmt FROM +'EXPLAIN SELECT t1.partner_id +FROM t1 +WHERE t1.id IN ( + SELECT t2.id + FROM t2 + WHERE article_id IN ( + SELECT article_id FROM t3 + WHERE user_id = \'nicke\' + ) + )'; +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL system PRIMARY NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL PRIMARY NULL NULL NULL 7 14.29 Using where; Start temporary +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.id 1 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`partner_id` AS `partner_id` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`id` = `test`.`t2`.`id`) and (`test`.`t2`.`article_id` = 'imp')) + +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL system PRIMARY NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL PRIMARY NULL NULL NULL 7 14.29 Using where; Start temporary +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.id 1 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`partner_id` AS `partner_id` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`id` = `test`.`t2`.`id`) and (`test`.`t2`.`article_id` = 'imp')) +PREPARE stmt FROM +'SELECT t1.partner_id +FROM t1 +WHERE t1.id IN ( + SELECT t2.id + FROM t2 + WHERE article_id IN ( + SELECT article_id FROM t3 + WHERE user_id = \'nicke\' + ) + )'; +EXECUTE stmt; +partner_id +partner2 + +EXECUTE stmt; +partner_id +partner2 +DROP TABLE t1,t2,t3; +# End of Bug#43768 +# +# Bug#53058 - semijoin execution of subquery with outerjoin yields wrong result +# +CREATE TABLE t1 (i INTEGER); +CREATE TABLE t2 (i INTEGER); +CREATE TABLE t3 (i INTEGER); +INSERT INTO t1 VALUES (1), (2); +INSERT INTO t2 VALUES (6); +INSERT INTO t3 VALUES (1), (2); +explain SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t3 LEFT JOIN t2 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t3 LEFT JOIN t2 ON t2.i=t3.i); +i +1 +2 +drop table t1,t2,t3; +# +# BUG#49453: re-execution of prepared statement with view +# and semijoin crashes +# +CREATE TABLE t1 (city VARCHAR(50), country_id INT); +CREATE TABLE t2 (country_id INT, country VARCHAR(50)); +INSERT INTO t1 VALUES +('Batna',2),('Bchar',2),('Skikda',2),('Tafuna',3),('Algeria',2) ; +INSERT INTO t2 VALUES (2,'Algeria'),(2,'AlgeriaDup'),(3,'XAmerican Samoa'); +CREATE VIEW v1 AS +SELECT country_id as vf_country_id +FROM t2 +WHERE LEFT(country,1) = "A"; +PREPARE stmt FROM " +SELECT city, country_id +FROM t1 +WHERE country_id IN (SELECT vf_country_id FROM v1); +"; + +EXECUTE stmt; +city country_id +Algeria 2 +Batna 2 +Bchar 2 +Skikda 2 + +EXECUTE stmt; +city country_id +Algeria 2 +Batna 2 +Bchar 2 +Skikda 2 +DROP TABLE t1,t2; +DROP VIEW v1; +# +# Bug#54437 Extra rows with LEFT JOIN + semijoin (firstmatch +# and duplicates weedout) +# +create table t1 (a int); +create table t2 (a int); +create table t3 (a int); +insert into t1 values(1),(1); +insert into t2 values(1),(1),(1),(1); +insert into t3 values(2),(2); +explain select * from t1 where t1.a in (select t2.a from t2 left join t3 on t2.a=t3.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t2` left join `test`.`t3` on((`test`.`t2`.`a` = `test`.`t3`.`a`))) where (`test`.`t2`.`a` = `test`.`t1`.`a`) +select * from t1 where t1.a in (select t2.a from t2 left join t3 on t2.a=t3.a); +a +1 +1 +drop table t1,t2,t3; +# +# Bug#55955: crash in MEMORY engine with IN(LEFT JOIN (JOIN)) +# +CREATE TABLE t1 (a INT); +CREATE TABLE t2 (a INT); +CREATE TABLE t3 (a INT); +INSERT INTO t1 VALUES(1),(1); +INSERT INTO t2 VALUES(1),(1); +INSERT INTO t3 VALUES(2),(2); +explain SELECT * FROM t1 +WHERE t1.a IN (SELECT t2.a +FROM t2 LEFT JOIN (t2 AS t2inner, t3) ON t2.a=t3.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t2inner NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t2` left join (`test`.`t2` `t2inner` join `test`.`t3`) on((`test`.`t2`.`a` = `test`.`t3`.`a`))) where (`test`.`t1`.`a` = `test`.`t2`.`a`) +SELECT * FROM t1 +WHERE t1.a IN (SELECT t2.a +FROM t2 LEFT JOIN (t2 AS t2inner, t3) ON t2.a=t3.a); +a +1 +1 +DROP TABLE t1,t2,t3; +# +# BUG#52329 - Wrong result: subquery materialization, IN, +# non-null field followed by nullable +# +CREATE TABLE t1 (a1 CHAR(8) NOT NULL, a2 char(8) NOT NULL); +CREATE TABLE t2a (b1 char(8), b2 char(8)); +CREATE TABLE t2b (b1 CHAR(8), b2 char(8) NOT NULL); +CREATE TABLE t2c (b1 CHAR(8) NOT NULL, b2 char(8)); +INSERT INTO t1 VALUES ('1 - 12', '2 - 22'); +INSERT INTO t2a VALUES ('1 - 11', '2 - 21'), +('1 - 11', '2 - 21'), +('1 - 12', '2 - 22'), +('1 - 12', '2 - 22'), +('1 - 13', '2 - 23'); +INSERT INTO t2b SELECT * FROM t2a; +INSERT INTO t2c SELECT * FROM t2a; +SELECT * FROM t1 +WHERE (a1, a2) IN ( +SELECT b1, b2 FROM t2c WHERE b1 > '0' GROUP BY b1, b2); +a1 a2 +1 - 12 2 - 22 +SELECT * FROM t1 +WHERE (a1, a2) IN ( +SELECT b1, b2 FROM t2a WHERE b1 > '0'); +a1 a2 +1 - 12 2 - 22 +SELECT * FROM t1 +WHERE (a1, a2) IN ( +SELECT b1, b2 FROM t2b WHERE b1 > '0'); +a1 a2 +1 - 12 2 - 22 +SELECT * FROM t1 +WHERE (a1, a2) IN ( +SELECT b1, b2 FROM t2c WHERE b1 > '0'); +a1 a2 +1 - 12 2 - 22 +DROP TABLE t1,t2a,t2b,t2c; +# End BUG#52329 +# +# Bug#45174: Incorrectly applied equality propagation caused wrong +# result on a query with a materialized semi-join. +# +CREATE TABLE t1 ( +varchar_nokey varchar(1) NOT NULL +) charset utf8mb4; +INSERT INTO t1 VALUES +('v'), ('u'), ('n'), ('l'), ('h'), ('u'), ('n'), ('j'), ('k'), +('e'), ('i'), ('u'), ('n'), ('b'), ('x'), (''), ('q'), ('u'); +CREATE TABLE t2 ( +pk int NOT NULL, +varchar_key varchar(1) NOT NULL, +varchar_nokey varchar(1) NOT NULL, +PRIMARY KEY(pk), +KEY varchar_key(varchar_key) +) charset utf8mb4; +INSERT INTO t2 VALUES +(11,'m','m'), (12,'j','j'), (13,'z','z'), (14,'a','a'), (15,'',''), +(16,'e','e'), (17,'t','t'), (19,'b','b'), (20,'w','w'), (21,'m','m'), +(23,'',''), (24,'w','w'), (26,'e','e'), (27,'e','e'), (28,'p','p'); +SELECT varchar_nokey +FROM t1 +WHERE (varchar_nokey, varchar_nokey) IN (SELECT varchar_key, varchar_nokey +FROM t2 +WHERE varchar_nokey < 'n' XOR pk); +varchar_nokey +explain SELECT varchar_nokey +FROM t1 +WHERE (varchar_nokey, varchar_nokey) IN (SELECT varchar_key, varchar_nokey +FROM t2 +WHERE varchar_nokey < 'n' XOR pk); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 18 100.00 NULL +1 SIMPLE t2 NULL ref varchar_key varchar_key 6 test.t1.varchar_nokey 2 6.67 Using where; Start temporary; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`varchar_nokey` AS `varchar_nokey` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`varchar_key` = `test`.`t1`.`varchar_nokey`) and (`test`.`t2`.`varchar_nokey` = `test`.`t1`.`varchar_nokey`) and ((`test`.`t2`.`varchar_nokey` < 'n') xor (0 <> `test`.`t2`.`pk`))) +DROP TABLE t1, t2; +# End of the test for bug#45174. +# +# Bug#50019: Wrong result for IN-query with materialization +# +CREATE TABLE t1(i INT); +INSERT INTO t1 VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10); +CREATE TABLE t2(i INT); +INSERT INTO t2 VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10); +CREATE TABLE t3(i INT); +INSERT INTO t3 VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10); +SELECT * FROM t1 WHERE t1.i IN (SELECT t2.i +FROM t2 JOIN t3 +WHERE t2.i + t3.i = 5); +i +1 +2 +3 +4 +explain SELECT * FROM t1 WHERE t1.i IN (SELECT t2.i +FROM t2 JOIN t3 +WHERE t2.i + t3.i = 5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 10 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 10.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 10 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t2`.`i`) and ((`test`.`t2`.`i` + `test`.`t3`.`i`) = 5)) +DROP TABLE t1,t2,t3; +# End of the test for bug#50019. +# +# Bug#52068: Optimizer generates invalid semijoin materialization plan +# +CREATE TABLE ot1(a INTEGER); +INSERT INTO ot1 VALUES(5), (8); +CREATE TABLE it2(a INTEGER); +INSERT INTO it2 VALUES(9), (5), (1), (8); +CREATE TABLE it3(a INTEGER); +INSERT INTO it3 VALUES(7), (1), (0), (5), (1), (4); +CREATE TABLE ot4(a INTEGER); +INSERT INTO ot4 VALUES(1), (3), (5), (7), (9), (7), (3), (1); +SELECT * FROM ot1,ot4 +WHERE (ot1.a,ot4.a) IN (SELECT it2.a,it3.a +FROM it2,it3); +a a +5 1 +5 1 +5 5 +5 7 +5 7 +8 1 +8 1 +8 5 +8 7 +8 7 +explain SELECT * FROM ot1,ot4 +WHERE (ot1.a,ot4.a) IN (SELECT it2.a,it3.a +FROM it2,it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE it3 NULL ALL NULL NULL NULL NULL 6 100.00 Start temporary +1 SIMPLE ot4 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; Using join buffer (hash join) +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +1 SIMPLE it2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot4`.`a` AS `a` from `test`.`ot1` join `test`.`ot4` semi join (`test`.`it2` join `test`.`it3`) where ((`test`.`ot4`.`a` = `test`.`it3`.`a`) and (`test`.`it2`.`a` = `test`.`ot1`.`a`)) +DROP TABLE IF EXISTS ot1, ot4, it2, it3; +# End of the test for bug#52068. +# +# Bug#57623: subquery within before insert trigger causes crash (sj=on) +# +CREATE TABLE ot1(a INT); +CREATE TABLE ot2(a INT); +CREATE TABLE ot3(a INT); +CREATE TABLE it1(a INT); +INSERT INTO ot1 VALUES(0),(1),(2),(3),(4),(5),(6),(7); +INSERT INTO ot2 VALUES(0),(2),(4),(6); +INSERT INTO ot3 VALUES(0),(3),(6); +INSERT INTO it1 VALUES(0),(1),(2),(3),(4),(5),(6),(7); +explain SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 on ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a from it1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 Start temporary +1 SIMPLE it1 NULL ALL NULL NULL NULL NULL 8 100.00 Using where; Using join buffer (hash join) +1 SIMPLE ot3 NULL ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (hash join) +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a`,`test`.`ot3`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` join `test`.`ot3` semi join (`test`.`it1`)) on(((`test`.`it1`.`a` = `test`.`ot1`.`a`) and (`test`.`ot3`.`a` = `test`.`ot1`.`a`) and (`test`.`ot2`.`a` = `test`.`ot1`.`a`))) where true +SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 on ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a from it1); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +prepare s from 'SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 on ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a from it1)'; +execute s; +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +execute s; +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +deallocate prepare s; +DROP TABLE ot1, ot2, ot3, it1; +# End of the test for bug#57623. +# +# Bug#11766739: Crash in tmp_table_param::init() with semijoin=on +# +CREATE TABLE t1 (f1 INTEGER) ENGINE=MyISAM; +CREATE TABLE t2 (f1 INTEGER, f2 INTEGER) ENGINE=MyISAM; +INSERT INTO t1 VALUES (1); +INSERT INTO t2 VALUES (1,1), (2,1); +EXPLAIN SELECT * FROM t2 +WHERE f2 IN (SELECT t1.f1 +FROM t1 LEFT OUTER JOIN (t2 AS b1 JOIN t2 AS b2 ON TRUE) ON TRUE); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE b1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +1 SIMPLE b2 NULL ALL NULL NULL NULL NULL 2 100.00 End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`f1` AS `f1`,`test`.`t2`.`f2` AS `f2` from `test`.`t2` semi join (`test`.`t1` left join (`test`.`t2` `b1` join `test`.`t2` `b2`) on((true))) where (`test`.`t2`.`f2` = `test`.`t1`.`f1`) +SELECT * FROM t2 +WHERE f2 IN (SELECT t1.f1 +FROM t1 LEFT OUTER JOIN (t2 AS b1 JOIN t2 AS b2 ON TRUE) ON TRUE); +f1 f2 +1 1 +2 1 +DROP TABLE t1, t2; +# End of the test for bug#11766739. +# +# Bug#11766642: crash in Item_field::register_field_in_read_map with view +# +CREATE TABLE t1(a INT); +CREATE VIEW v1 AS SELECT a FROM t1; +INSERT INTO t1 VALUES (0),(1),(2); +SELECT a FROM t1 WHERE a IN +(SELECT a XOR a FROM v1) +ORDER BY a; +a +0 +DROP TABLE t1; +DROP VIEW v1; +# +# Bug#12546542 MISSING ROW WHEN USING OPTIMIZER_JOIN_CACHE_LEVEL>=3 +# +CREATE TABLE t1 ( +f2 varchar(1024) +); +INSERT INTO t1 VALUES ('v'),('we'); +CREATE TABLE t2 ( +col_varchar_1024_utf8 varchar(1024) CHARACTER SET utf8 DEFAULT NULL, +col_int_key int, +col_int int +); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t2 VALUES ('we',4,NULL),('v',1305673728,6); +CREATE TABLE t3 ( +col_int_key int, +col_int int +); +INSERT INTO t3 VALUES (4,4); +SELECT * +FROM t1 +WHERE f2 IN (SELECT a1.col_varchar_1024_utf8 AS f2 +FROM t2 AS a1 LEFT JOIN t3 AS a2 +ON a1.col_int_key = a2.col_int_key +WHERE a1.col_int BETWEEN 1 AND 10 OR a2.col_int IS NOT NULL); +f2 +v +we +DROP TABLE t1,t2,t3; +# +# BUG#12616344 - JCL: DIFFERENT RESULT SET AND DIFFERENT AMOUNT +# OF ROWS WHEN JCL>=3 +# +CREATE TABLE t1 (col_int_nokey int, col_int_key int, col_varchar_key varchar(1)); +INSERT INTO t1 VALUES (0,4,'c'),(1,6,'u'); +CREATE TABLE t2 (pk int, col_int_nokey int, col_varchar_nokey varchar(1)); +INSERT INTO t2 VALUES (1,4,'b'),(94,6,'u'); +CREATE TABLE t3 (pk int, col_int_nokey int, col_varchar_key varchar(1)); +INSERT INTO t3 VALUES (1,4,'j'),(2,6,'v'); +SELECT table2.col_int_key +from t3 as table1 join t1 as table2 on table2.col_int_nokey +where table1.col_int_nokey in +( +select subquery2_t2.col_int_nokey +from t3 as subquery2_t1 +right join +t2 as subquery2_t2 +join t1 as subquery2_t3 +on subquery2_t3.col_int_key = subquery2_t2.col_int_nokey +on subquery2_t3.col_varchar_key = subquery2_t2.col_varchar_nokey +where subquery2_t1.col_varchar_key != table1.col_varchar_key +or subquery2_t2.pk <= table1.pk +); +col_int_key +6 +6 +DROP TABLE t1,t2,t3; +# +# Bug#12608157: ASSERT IN FIELD_LONG::VAL_INT WHEN USING MEMORY ENGINE +# +CREATE TABLE t1 (i1 int); +INSERT INTO t1 VALUES (1); +CREATE TABLE t2 (i1 int, i2 int) ENGINE=memory; +INSERT INTO t2 VALUES (1, 2),(7, 3); +SELECT GRANDPARENT1.i1 +FROM t2 AS GRANDPARENT1 +WHERE GRANDPARENT1.i2 +IN ( SELECT PARENT1.i2 +FROM t2 AS PARENT1 JOIN t1 AS PARENT2 ON (PARENT1.i1 = PARENT2.i1) +WHERE +GRANDPARENT1.i1 IN ( SELECT CHILD1.i1 FROM t2 AS CHILD1 ) +ORDER BY PARENT1.i1) +ORDER BY GRANDPARENT1.i2 ; +i1 +1 +DROP TABLE t1,t2; +# +# Bug#12640083: Same query executed as WHERE subquery gives different +# results on IN() compare +# +CREATE TABLE t1 ( +pk int NOT NULL, +col_varchar_1024_utf8_key varchar(1024) CHARACTER SET utf8 DEFAULT NULL, +col_varchar_10_latin1_key varchar(10) DEFAULT NULL, +PRIMARY KEY (pk), +KEY col_varchar_1024_utf8_key(col_varchar_1024_utf8_key(333)), +KEY col_varchar_10_latin1_key(col_varchar_10_latin1_key) +) charset utf8mb4; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES +(1, 'a', 'a'), +(2, 'ab', 'ab'), +(3, 'abc', 'abc'), +(4, 'abcd', 'abcd'); +CREATE TABLE t2 ( +pk int NOT NULL AUTO_INCREMENT, +PRIMARY KEY (pk) +) charset utf8mb4 ENGINE=Innodb; +CREATE TABLE t3 charset utf8mb4 +SELECT alias1.col_varchar_10_latin1_key +FROM t1 AS alias1 +LEFT JOIN t1 AS alias2 +JOIN t2 AS alias3 +ON alias2.col_varchar_10_latin1_key +ON alias1.col_varchar_1024_utf8_key +WHERE alias1.pk AND alias1.pk < 3 OR alias1.pk AND alias3.pk; +EXPLAIN SELECT * +FROM t3 +WHERE col_varchar_10_latin1_key IN ( +SELECT alias1.col_varchar_10_latin1_key +FROM t1 AS alias1 +LEFT JOIN t1 AS alias2 +JOIN t2 AS alias3 +ON alias2.col_varchar_10_latin1_key +ON alias1.col_varchar_1024_utf8_key +WHERE alias1.pk AND alias1.pk < 3 OR alias1.pk AND alias3.pk); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Start temporary +1 SIMPLE alias1 NULL ref PRIMARY,col_varchar_10_latin1_key col_varchar_10_latin1_key 43 test.t3.col_varchar_10_latin1_key 2 100.00 Using where +1 SIMPLE alias3 NULL index NULL PRIMARY 4 NULL 1 100.00 Using where; Using index; Using join buffer (hash join) +1 SIMPLE alias2 NULL index NULL col_varchar_10_latin1_key 43 NULL 4 100.00 Using where; Using index; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`col_varchar_10_latin1_key` AS `col_varchar_10_latin1_key` from `test`.`t3` semi join (`test`.`t1` `alias1` left join (`test`.`t1` `alias2` join `test`.`t2` `alias3`) on(((0 <> `test`.`alias1`.`col_varchar_1024_utf8_key`) and (0 <> `test`.`alias2`.`col_varchar_10_latin1_key`)))) where ((`test`.`alias1`.`col_varchar_10_latin1_key` = `test`.`t3`.`col_varchar_10_latin1_key`) and (((0 <> `test`.`alias1`.`pk`) and (`test`.`alias1`.`pk` < 3)) or ((0 <> `test`.`alias1`.`pk`) and (0 <> `test`.`alias3`.`pk`)))) +SELECT * +FROM t3 +WHERE col_varchar_10_latin1_key IN ( +SELECT alias1.col_varchar_10_latin1_key +FROM t1 AS alias1 +LEFT JOIN t1 AS alias2 +JOIN t2 AS alias3 +ON alias2.col_varchar_10_latin1_key +ON alias1.col_varchar_1024_utf8_key +WHERE alias1.pk AND alias1.pk < 3 OR alias1.pk AND alias3.pk); +col_varchar_10_latin1_key +a +ab +DROP TABLE t1, t2, t3; +# End of the test for bug#12640083. +# +# Bug#12603200 - Assert in QUICK_INDEX_MERGE_SELECT::need_sorted_output +# +CREATE TABLE t1 ( +pk int NOT NULL, +col_int_key int NOT NULL, +col_varchar_nokey varchar(1) NOT NULL, +col_varchar_key varchar(1) NOT NULL, +PRIMARY KEY(pk), +KEY col_int_key(col_int_key), +KEY col_varchar_key(col_varchar_key, col_int_key) +) charset utf8mb4 engine=innodb; +INSERT INTO t1 VALUES +(1,7,'a','a'), +(2,0,'v','v'), +(3,9,'c','c'), +(4,3,'m','m'), +(5,2,'a','a'), +(6,1,'d','d'), +(7,8,'y','y'), +(8,6,'t','t'), +(11,7,'a','x'), +(12,0,'v','v'), +(13,9,'c','c'), +(14,3,'m','m'), +(15,2,'a','x'), +(16,1,'d','d'), +(17,8,'y','y'), +(18,6,'t','u'), +(19,6,'t','u'); +CREATE TABLE t2 ( +pk int NOT NULL, +col_int_key int NOT NULL, +col_varchar_key varchar(1) NOT NULL, +PRIMARY KEY(pk), +KEY col_varchar_key(col_varchar_key, col_int_key) +) charset utf8mb4 engine=innodb; +INSERT INTO t2(pk,col_int_key,col_varchar_key) VALUES +(8,7,'c'), +(11,4,'l'), +(12,7,'b'), +(13,0,'c'), +(14,2,'i'), +(15,9,'h'), +(16,4,'q'), +(17,1,'m'), +(18,9,'b'), +(19,2,'e'), +(20,1,'c'), +(21,7,'z'), +(22,4,'l'), +(23,7,'z'), +(24,0,'c'), +(25,2,'i'), +(26,9,'h'), +(27,4,'q'), +(28,0,'a'), +(29,1,'d'); +EXPLAIN SELECT outr.col_varchar_key AS x, outr.pk AS y +FROM t1 AS outr +WHERE outr.col_varchar_key IN (SELECT innr.col_varchar_key +FROM t2 AS innr +WHERE innr.col_varchar_key = 'a' OR innr.pk = 8) +AND outr.col_varchar_nokey < 't' +ORDER BY outr.col_varchar_key, outr.pk; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE innr NULL index PRIMARY,col_varchar_key col_varchar_key 10 NULL 20 55.00 Using where; Using index; Using temporary; Using filesort; LooseScan +1 SIMPLE outr NULL ref col_varchar_key col_varchar_key 6 test.innr.col_varchar_key 1 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`outr`.`col_varchar_key` AS `x`,`test`.`outr`.`pk` AS `y` from `test`.`t1` `outr` semi join (`test`.`t2` `innr`) where ((`test`.`outr`.`col_varchar_key` = `test`.`innr`.`col_varchar_key`) and (`test`.`outr`.`col_varchar_nokey` < 't') and ((`test`.`innr`.`col_varchar_key` = 'a') or (`test`.`innr`.`pk` = 8))) order by `test`.`outr`.`col_varchar_key`,`test`.`outr`.`pk` +SELECT outr.col_varchar_key AS x, outr.pk AS y +FROM t1 AS outr +WHERE outr.col_varchar_key IN (SELECT innr.col_varchar_key +FROM t2 AS innr +WHERE innr.col_varchar_key = 'a' OR innr.pk = 8) +AND outr.col_varchar_nokey < 't' +ORDER BY outr.col_varchar_key, outr.pk; +x y +a 1 +a 5 +c 3 +c 13 +DROP TABLE t1, t2; +# End of bug#12603200 +# +# Bug#12603183: Segfault in hp_movelink +# +CREATE TABLE t1 ( +col_varchar_key varchar(1) , +col_varchar_nokey varchar(1) , +KEY col_varchar_key(col_varchar_key) +) charset latin1; +INSERT INTO t1 VALUES +('i','i'), +('h','h'), +('q','q'), +('a','a'), +('v','v'), +('u','u'), +('s','s'), +('y','y'), +('z','z'), +('h','h'), +('p','p'), +('e','e'), +('i','i'), +('y','y'), +('w','w'); +CREATE TABLE t2 ( +col_varchar_nokey varchar(1) +) charset latin1; +INSERT INTO t2 VALUES +('b'); +EXPLAIN SELECT grandparent1.col_varchar_nokey +FROM t1 AS grandparent1 LEFT JOIN t2 AS grandparent2 USING (col_varchar_nokey) +WHERE (grandparent1.col_varchar_key) IN +(SELECT parent1.col_varchar_nokey +FROM t1 AS parent1 +WHERE parent1.col_varchar_key IN +(SELECT child1.col_varchar_nokey AS c1 +FROM t1 AS child1 LEFT JOIN t2 AS child2 +ON (child1.col_varchar_key > child2.col_varchar_nokey))); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE child1 NULL ALL NULL NULL NULL NULL 15 100.00 Using where; Start temporary +1 SIMPLE child2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE parent1 NULL ref col_varchar_key col_varchar_key 4 test.child1.col_varchar_nokey 2 100.00 Using where +1 SIMPLE grandparent1 NULL ref col_varchar_key col_varchar_key 4 test.parent1.col_varchar_nokey 2 100.00 End temporary +1 SIMPLE grandparent2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`grandparent1`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t1` `grandparent1` left join `test`.`t2` `grandparent2` on((`test`.`grandparent2`.`col_varchar_nokey` = `test`.`grandparent1`.`col_varchar_nokey`)) semi join (`test`.`t1` `parent1` join `test`.`t1` `child1` left join `test`.`t2` `child2` on((`test`.`child1`.`col_varchar_key` > `test`.`child2`.`col_varchar_nokey`))) where ((`test`.`grandparent1`.`col_varchar_key` = `test`.`parent1`.`col_varchar_nokey`) and (`test`.`parent1`.`col_varchar_key` = `test`.`child1`.`col_varchar_nokey`)) +SELECT grandparent1.col_varchar_nokey +FROM t1 AS grandparent1 LEFT JOIN t2 AS grandparent2 USING (col_varchar_nokey) +WHERE (grandparent1.col_varchar_key) IN +(SELECT parent1.col_varchar_nokey +FROM t1 AS parent1 +WHERE parent1.col_varchar_key IN +(SELECT child1.col_varchar_nokey AS c1 +FROM t1 AS child1 LEFT JOIN t2 AS child2 +ON (child1.col_varchar_key > child2.col_varchar_nokey))); +col_varchar_nokey +a +e +h +h +i +i +p +q +s +u +v +w +y +y +z +DROP TABLE t1, t2; +# End of test for bug#12603183. +# +# Bug#12818569: Diff nr of rows returned when using IN/ALL+subquery +# +CREATE TABLE t1 ( +col_int_key INT NOT NULL, +col_datetime_key DATETIME NOT NULL, +col_varchar_key VARCHAR(1) NOT NULL, +KEY col_int_key (col_int_key), +KEY col_datetime_key(col_datetime_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t1 VALUES +(7,'2004-06-06 04:22:12','v'), (0,'2005-11-13 01:12:31','s'), +(9,'2002-05-04 01:50:00','l'), (3,'2004-10-27 10:28:45','y'), +(4,'2006-07-22 05:24:23','c'), (2,'2002-05-16 21:34:03','i'), +(5,'2008-04-17 10:45:30','h'), (3,'2009-04-21 02:58:02','q'), +(1,'2008-01-11 11:01:51','a'), (3,'1900-01-01 00:00:00','v'), +(6,'2007-05-17 18:24:57','u'), (7,'2007-08-07 00:00:00','s'), +(5,'2001-08-28 00:00:00','y'), (1,'2004-04-16 00:27:28','z'), +(204,'2005-05-03 07:06:22','h'), (224,'2009-03-11 17:09:50','p'), +(9,'2007-12-08 01:54:28','e'), (5,'2009-07-28 18:19:54','i'), +(0,'2008-06-08 00:00:00','y'), (3,'2005-02-09 09:20:26','w'); +CREATE TABLE t2 ( +col_varchar_nokey VARCHAR(1) NOT NULL +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t2 VALUES ('v'), ('y'), ('j'), ('c'), ('d'), ('r'); +explain SELECT col_varchar_key +FROM t1 +WHERE col_varchar_key IN (SELECT col_varchar_nokey +FROM t2) +ORDER BY col_datetime_key LIMIT 4; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 100.00 Using temporary; Using filesort; Start temporary +1 SIMPLE t1 NULL ref col_varchar_key col_varchar_key 6 test.t2.col_varchar_nokey 1 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col_varchar_key` AS `col_varchar_key` from `test`.`t1` semi join (`test`.`t2`) where (`test`.`t1`.`col_varchar_key` = `test`.`t2`.`col_varchar_nokey`) order by `test`.`t1`.`col_datetime_key` limit 4 +SELECT col_varchar_key +FROM t1 +WHERE col_varchar_key IN (SELECT col_varchar_nokey +FROM t2) +ORDER BY col_datetime_key LIMIT 4; +col_varchar_key +v +y +v +y +DROP TABLE t1, t2; +# End of test for bug#12818569. +# +# Bug#12803439: Assert in replace_subcondition() on update query +# +CREATE TABLE t1(a INTEGER); +INSERT INTO t1 values(1), (2); +CREATE TABLE t2(a INTEGER); +INSERT INTO t2 VALUES(1), (3); +SELECT * +FROM t1 +WHERE a IN (SELECT a +FROM t2 +HAVING a IN (SELECT a +FROM t2) +) +HAVING a IN (SELECT a +FROM t2); +a +1 +DROP TABLE t1, t2; +# End of test for bug#12803439. +# +# Bug#12797534: Segfault in hp_movelink still exists +# +CREATE TABLE t1 ( +g1 VARCHAR(1) NOT NULL +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t1 VALUES ('d'), ('s'); +CREATE TABLE t2 ( +pk INT NOT NULL, +col_int_key INT NOT NULL, +col_varchar_key VARCHAR(1) NOT NULL, +col_varchar_nokey VARCHAR(1) NOT NULL, +PRIMARY KEY (pk), +KEY col_varchar_key(col_varchar_key, col_int_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t2 VALUES +(1,4,'j','j'), (2,6,'v','v'), (3,3,'c','c'), (4,5,'m','m'), +(5,3,'d','d'), (6,246,'d','d'), (7,2,'y','y'), (8,9,'t','t'), +(9,3,'d','d'), (10,8,'s','s'), (11,1,'r','r'), (12,8,'m','m'), +(13,8,'b','b'), (14,5,'x','x'), (15,7,'g','g'), (16,5,'p','p'), +(17,1,'q','q'), (18,6,'w','w'), (19,2,'d','d'), (20,9,'e','e'); +CREATE TABLE t3 ( +pk INTEGER NOT NULL, +PRIMARY KEY (pk) +) ENGINE=InnoDB; +INSERT INTO t3 VALUES (10); +EXPLAIN SELECT * +FROM t1 +WHERE g1 NOT IN +(SELECT grandparent1.col_varchar_nokey AS g1 +FROM t2 AS grandparent1 +WHERE grandparent1.col_varchar_key IN +(SELECT parent1.col_varchar_nokey AS p1 +FROM t2 AS parent1 LEFT JOIN t3 AS parent2 USING (pk) +) +AND grandparent1.col_varchar_key IS NOT NULL +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 SIMPLE parent1 NULL ALL NULL NULL NULL NULL 20 100.00 Using where; Not exists; Start temporary +2 SIMPLE parent2 NULL eq_ref PRIMARY PRIMARY 4 test.parent1.pk 1 100.00 Using index +2 SIMPLE grandparent1 NULL ref col_varchar_key col_varchar_key 6 test.parent1.col_varchar_nokey 1 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`g1` AS `g1` from `test`.`t1` anti join (`test`.`t2` `grandparent1` join `test`.`t2` `parent1` left join `test`.`t3` `parent2` on((`test`.`parent2`.`pk` = `test`.`parent1`.`pk`))) on(((`test`.`grandparent1`.`col_varchar_nokey` = `test`.`t1`.`g1`) and (`test`.`grandparent1`.`col_varchar_key` = `test`.`parent1`.`col_varchar_nokey`) and (`test`.`grandparent1`.`col_varchar_key` is not null))) where true +SELECT * +FROM t1 +WHERE g1 NOT IN +(SELECT grandparent1.col_varchar_nokey AS g1 +FROM t2 AS grandparent1 +WHERE grandparent1.col_varchar_key IN +(SELECT parent1.col_varchar_nokey AS p1 +FROM t2 AS parent1 LEFT JOIN t3 AS parent2 USING (pk) +) +AND grandparent1.col_varchar_key IS NOT NULL +); +g1 +DROP TABLE t1, t2, t3; +CREATE TABLE t1 ( +pk INTEGER AUTO_INCREMENT, +col_int_key INTEGER , +col_varchar_key VARCHAR(1) , +col_varchar_nokey VARCHAR(1) , +PRIMARY KEY (pk), +KEY (col_varchar_key,col_int_key) +) ENGINE=INNODB; +INSERT INTO t1 (col_int_key,col_varchar_key,col_varchar_nokey) VALUES +(0,'x','x'), (1,'j','j'), (1,'r','r'), (9,'v','v'), (5,'r','r'); +CREATE TABLE t2 ( +pk INTEGER AUTO_INCREMENT, +col_int_key INTEGER , +col_varchar_key VARCHAR(1) , +col_varchar_nokey VARCHAR(1) , +PRIMARY KEY (pk), +KEY (col_int_key), +KEY (col_varchar_key,col_int_key) +) AUTO_INCREMENT=10 ENGINE=INNODB; +INSERT INTO t2 (col_int_key, col_varchar_key, col_varchar_nokey) VALUES +(NULL,'x','x'), (NULL,'j','j'), (8,'c','c'); +CREATE TABLE t3 +SELECT outr.col_varchar_nokey AS x +FROM t1 AS outr +WHERE outr.col_varchar_nokey IN +(SELECT innr.col_varchar_nokey AS y +FROM t2 AS innr +WHERE innr.col_int_key IS NULL) +AND outr.col_varchar_nokey IS NOT NULL +AND NOT col_varchar_key IS NULL; +SELECT * +FROM t3 +WHERE x NOT IN +(SELECT outr.col_varchar_nokey AS x +FROM t1 AS outr +WHERE outr.col_varchar_nokey IN +(SELECT innr.col_varchar_nokey AS y +FROM t2 AS innr +WHERE innr.col_int_key IS NULL) +AND outr.col_varchar_nokey IS NOT NULL +AND NOT col_varchar_key IS NULL); +x +DROP TABLE t1, t2, t3; +# End of test for bug#12797534. +# +# Bug#12714094: Assert in optimize_semijoin_nests() +# +CREATE TABLE it ( +pk int NOT NULL, +col_varchar VARCHAR(10) DEFAULT NULL, +PRIMARY KEY (pk) +) ENGINE=MyISAM; +INSERT INTO it VALUES (1, 'g'); +CREATE TABLE ot +SELECT alias1.pk AS field1 +FROM it AS alias1 +LEFT JOIN it AS alias2 +ON alias1.col_varchar = alias2.col_varchar +; +SELECT * +FROM ot +WHERE field1 IN ( +SELECT alias1.pk +FROM it AS alias1 +LEFT JOIN it AS alias2 +ON alias1.col_varchar = alias2.col_varchar +); +field1 +1 +DROP TABLE it, ot; +# End of test for bug#12714094 +# +# Bug#12867557: Valgrind: conditional jump/move at key_cmp +# +CREATE TABLE t1 ( +pk INTEGER AUTO_INCREMENT, +col_int_key INTEGER, +PRIMARY KEY (pk), +KEY (col_int_key) +) AUTO_INCREMENT=10; +INSERT INTO t1 (col_int_key) VALUES (8); +CREATE TABLE t2 ( +pk INTEGER AUTO_INCREMENT, +col_int_key INTEGER, +col_time_key TIME, +PRIMARY KEY (pk), +KEY (col_int_key), +KEY (col_time_key) +) AUTO_INCREMENT=10; +INSERT INTO t2 (col_int_key, col_time_key) +VALUES +(8, '22:55:23.019225'), (7, '10:19:31.050677'), (1, '14:40:36.038608'), +(7, '04:37:47.062416'), (9, '19:34:06.054514'), (NULL,'20:35:33.022996'), +(1, NULL), (9, '14:43:37.057393'), (2, '02:23:09.043438'), +(9, '01:22:45.041064'), (2, '00:00:00'), (4, '00:13:25.038482'), +(0, '03:47:16.042671'), (4, '01:41:48.007423'), (8, '00:00:00'), +(NULL, '22:32:04.047407'), (NULL, '16:44:14.028443'), (0, '17:38:37.059754'), +(NULL, '08:46:48.042388'), (8, '14:11:27.044095'); +CREATE TABLE t0 +SELECT DISTINCT grandparent1.col_time_key AS g1 +FROM t2 AS grandparent1 +WHERE grandparent1.col_int_key IN +(SELECT parent1.col_int_key AS p1 +FROM t1 AS parent1) +AND grandparent1.pk > 9; +UPDATE t0 +SET g1 = g1 +WHERE g1 IN +(SELECT grandparent1.col_time_key AS g1 +FROM t2 AS grandparent1 +WHERE grandparent1.col_int_key IN +(SELECT parent1.col_int_key AS p1 +FROM t1 AS parent1) +AND grandparent1.pk > 9); +DROP TABLE t0, t1, t2; +# End of test for bug#12867557 +# +# Bug#12711441: crash in fix_after_pullout +# +CREATE TABLE t1 ( +pk int NOT NULL, +col_int_nokey int DEFAULT NULL, +col_int_key int DEFAULT NULL, +col_time_key time DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +PRIMARY KEY (pk) +); +CREATE VIEW v1 AS SELECT * FROM t1; +CREATE TABLE t2 ( +col_int_key int DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +KEY col_varchar_key(col_varchar_key, col_int_key) +); +CREATE TABLE t3 ( +pk int NOT NULL, +col_int_key INT DEFAULT NULL, +PRIMARY KEY (pk) +); +CREATE TABLE t4 ( +col_int_nokey INT DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +KEY col_varchar_key(col_varchar_key) +); +CREATE TABLE ts +SELECT alias1.col_time_key AS field1 +FROM v1 AS alias1 +RIGHT JOIN t3 AS alias2 +ON alias2.col_int_key = alias1.col_int_nokey +WHERE alias1.pk >= SOME( +SELECT SQ1_alias1.pk AS SQ1_field1 +FROM t3 AS SQ1_alias1 +INNER JOIN (t2 AS SQ1_alias2 +INNER JOIN t4 AS SQ1_alias3 +ON SQ1_alias3.col_varchar_key = SQ1_alias2.col_varchar_nokey) +ON SQ1_alias3.col_int_nokey = SQ1_alias2.col_int_key +WHERE SQ1_alias2.col_varchar_key <= alias1.col_varchar_key +AND SQ1_alias3.col_varchar_nokey <> alias1.col_varchar_key) +; +SELECT * FROM ts WHERE field1 IN ( +SELECT alias1.col_time_key AS field1 +FROM v1 AS alias1 +RIGHT JOIN t3 AS alias2 +ON alias2.col_int_key = alias1.col_int_nokey +WHERE alias1.pk >= SOME( +SELECT SQ1_alias1.pk AS SQ1_field1 +FROM t3 AS SQ1_alias1 +INNER JOIN (t2 AS SQ1_alias2 +INNER JOIN t4 AS SQ1_alias3 +ON SQ1_alias3.col_varchar_key = SQ1_alias2.col_varchar_nokey) +ON SQ1_alias3.col_int_nokey = SQ1_alias2.col_int_key +WHERE SQ1_alias2.col_varchar_key <= alias1.col_varchar_key +AND SQ1_alias3.col_varchar_nokey <> alias1.col_varchar_key) +); +field1 +DROP TABLE t1, t2, t3, t4, ts; +DROP VIEW v1; +# End of test for bug#12711441. +# +# Bug#12664936: Same query executed as where subquery ... +# +CREATE TABLE t1 ( +col_varchar_key VARCHAR(1), +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4; +INSERT INTO t1 VALUES +('o'), ('w'), ('m'), ('q'), +('f'), ('p'), ('j'), ('c'); +CREATE TABLE t2 ( +col_int_nokey INTEGER, +col_int_key INTEGER, +col_varchar_key varchar(1), +KEY col_int_key (col_int_key) +) charset utf8mb4; +INSERT INTO t2 VALUES +(8,5,'u'),(4,5,'p'),(8,1,'o'),(NULL,7,'v'), +(1,2,'g'),(2,1,'q'),(NULL,7,'l'),(3,1,'n'); +CREATE TABLE t4 +SELECT t2.col_int_nokey, t2.col_varchar_key +FROM t1 JOIN t2 ON t2.col_varchar_key = t1.col_varchar_key +WHERE t2.col_int_key = 1; +EXPLAIN SELECT * +FROM t4 +WHERE (col_int_nokey, col_varchar_key) IN +(SELECT t2.col_int_nokey, t2.col_varchar_key +FROM t1 JOIN t2 ON t2.col_varchar_key = t1.col_varchar_key +WHERE t2.col_int_key = 1 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t4 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE t2 NULL ref col_int_key col_int_key 5 const 3 12.50 Using where; Start temporary +1 SIMPLE t1 NULL ref col_varchar_key col_varchar_key 7 test.t4.col_varchar_key 2 100.00 Using index; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`col_int_nokey` AS `col_int_nokey`,`test`.`t4`.`col_varchar_key` AS `col_varchar_key` from `test`.`t4` semi join (`test`.`t1` join `test`.`t2`) where ((`test`.`t2`.`col_varchar_key` = `test`.`t4`.`col_varchar_key`) and (`test`.`t1`.`col_varchar_key` = `test`.`t4`.`col_varchar_key`) and (`test`.`t2`.`col_int_nokey` = `test`.`t4`.`col_int_nokey`) and (`test`.`t2`.`col_int_key` = 1)) +SELECT * +FROM t4 +WHERE (col_int_nokey, col_varchar_key) IN +(SELECT t2.col_int_nokey, t2.col_varchar_key +FROM t1 JOIN t2 ON t2.col_varchar_key = t1.col_varchar_key +WHERE t2.col_int_key = 1 +); +col_int_nokey col_varchar_key +8 o +2 q +DROP TABLE t1, t2, t4; +# End of test for bug#12664936. +# +# Bug#13340270: assertion table->sort.record_pointers == __null +# +CREATE TABLE t1 ( +pk int NOT NULL, +col_int_key int DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key, col_int_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t1 VALUES +(10,8,'x','x'), +(11,7,'d','d'), +(12,1,'r','r'), +(13,7,'f','f'), +(14,9,'y','y'), +(15,NULL,'u','u'), +(16,1,'m','m'), +(17,9,NULL,NULL), +(18,2,'o','o'), +(19,9,'w','w'), +(20,2,'m','m'), +(21,4,'q','q'); +CREATE TABLE t2 +SELECT alias1.col_varchar_nokey AS field1 +FROM t1 AS alias1 JOIN t1 AS alias2 +ON alias2.col_int_key = alias1.pk OR +alias2.col_int_key = alias1.col_int_key +WHERE alias1.pk = 58 OR alias1.col_varchar_key = 'o' + +; +EXPLAIN SELECT * +FROM t2 +WHERE (field1) IN (SELECT alias1.col_varchar_nokey AS field1 +FROM t1 AS alias1 JOIN t1 AS alias2 +ON alias2.col_int_key = alias1.pk OR +alias2.col_int_key = alias1.col_int_key +WHERE alias1.pk = 58 OR alias1.col_varchar_key = 'o' +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE alias1 NULL index_merge PRIMARY,col_int_key,col_varchar_key col_varchar_key,PRIMARY 7,4 NULL 2 10.00 Using sort_union(col_varchar_key,PRIMARY); Using where; Using join buffer (hash join) +1 SIMPLE alias2 NULL ALL col_int_key NULL NULL NULL 12 19.00 Range checked for each record (index map: 0x2); End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`field1` AS `field1` from `test`.`t2` semi join (`test`.`t1` `alias1` join `test`.`t1` `alias2`) where ((`test`.`alias1`.`col_varchar_nokey` = `test`.`t2`.`field1`) and ((`test`.`alias1`.`pk` = 58) or (`test`.`alias1`.`col_varchar_key` = 'o')) and ((`test`.`alias2`.`col_int_key` = `test`.`alias1`.`pk`) or (`test`.`alias2`.`col_int_key` = `test`.`alias1`.`col_int_key`))) +SELECT * +FROM t2 +WHERE (field1) IN (SELECT alias1.col_varchar_nokey AS field1 +FROM t1 AS alias1 JOIN t1 AS alias2 +ON alias2.col_int_key = alias1.pk OR +alias2.col_int_key = alias1.col_int_key +WHERE alias1.pk = 58 OR alias1.col_varchar_key = 'o' +); +field1 +o +o +DROP TABLE t1, t2; +# End of test for bug#13340270. +# +# Bug#13335319: Seg fault when analyzing FirstMatch semi-join strategy +# +CREATE TABLE ot1(a INTEGER); +INSERT INTO ot1 VALUES(1), (2), (3); +CREATE TABLE ot2(a INTEGER); +INSERT INTO ot2 VALUES(1), (2), (4), (6), (8), (10); +CREATE TABLE it1(a INTEGER); +INSERT INTO it1 VALUES(1), (3), (5), (7); +CREATE TABLE it2(a INTEGER); +INSERT INTO it2 VALUES(1), (3), (5), (7), (9); +explain SELECT ot1.a, ot2.a +FROM ot1, ot2 +WHERE ot1.a IN (SELECT a FROM it1) AND +ot2.a IN (SELECT a FROM it2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE it2 NULL ALL NULL NULL NULL NULL 5 100.00 Start temporary +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Using join buffer (hash join) +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 SIMPLE it1 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` join `test`.`ot2` semi join (`test`.`it1`) semi join (`test`.`it2`) where ((`test`.`ot2`.`a` = `test`.`it2`.`a`) and (`test`.`it1`.`a` = `test`.`ot1`.`a`)) +SELECT ot1.a, ot2.a +FROM ot1, ot2 +WHERE ot1.a IN (SELECT a FROM it1) AND +ot2.a IN (SELECT a FROM it2); +a a +1 1 +3 1 +DROP TABLE ot1, ot2, it1, it2; +# End of test for bug#13335319. +# +# Bug#13334882: Assertion keypart_map failed in MyIsam function +# +CREATE TABLE t1 ( +pk int NOT NULL, +col_int_nokey INT NOT NULL, +col_int_key INT NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +) ENGINE=MyISAM; +INSERT INTO t1 VALUES +(1,4,0), +(2,6,8), +(3,3,1), +(7,2,6), +(8,9,1), +(9,3,6), +(10,8,2), +(11,1,4), +(12,8,8), +(13,8,4), +(14,5,4); +CREATE TABLE t2 ( +pk int NOT NULL, +col_int_nokey int NOT NULL, +col_int_key int NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +) ENGINE=MyISAM; +INSERT INTO t2 VALUES +(10,8,7); +CREATE TABLE t3 +SELECT grandparent1.col_int_nokey AS g1 +FROM t1 AS grandparent1 +WHERE (grandparent1.col_int_nokey, grandparent1.col_int_key) IN +(SELECT parent1.col_int_key AS p1, +parent1.col_int_key AS p2 +FROM t1 AS parent1 +LEFT JOIN t2 AS parent2 +ON parent1.col_int_nokey = parent2.col_int_key +) +AND grandparent1.col_int_key <> 3 +; +explain SELECT * FROM t3 +WHERE g1 NOT IN +(SELECT grandparent1.col_int_nokey AS g1 +FROM t1 AS grandparent1 +WHERE (grandparent1.col_int_nokey, grandparent1.col_int_key) IN +(SELECT parent1.col_int_key AS p1, +parent1.col_int_key AS p2 +FROM t1 AS parent1 +LEFT JOIN t2 AS parent2 +ON parent1.col_int_nokey = parent2.col_int_key +) +AND grandparent1.col_int_key <> 3 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE grandparent1 NULL ref col_int_key col_int_key 4 const 1 100.00 Using where; Not exists; Start temporary +1 SIMPLE parent1 NULL ref col_int_key col_int_key 4 test.grandparent1.col_int_nokey 1 100.00 Using where +1 SIMPLE parent2 NULL ref col_int_key col_int_key 4 test.parent1.col_int_nokey 2 100.00 Using index; End temporary +Warnings: +Note 1003 /* select#1 */ select '8' AS `g1` from anti join (`test`.`t1` `grandparent1` join `test`.`t1` `parent1` left join `test`.`t2` `parent2` on((`test`.`parent2`.`col_int_key` = `test`.`parent1`.`col_int_nokey`))) on(((`test`.`grandparent1`.`col_int_nokey` = '8') and (`test`.`grandparent1`.`col_int_key` = '8') and (`test`.`parent1`.`col_int_key` = '8') and ('8' <> 3))) where true +explain format=json SELECT * FROM t3 +WHERE g1 NOT IN +(SELECT grandparent1.col_int_nokey AS g1 +FROM t1 AS grandparent1 +WHERE (grandparent1.col_int_nokey, grandparent1.col_int_key) IN +(SELECT parent1.col_int_key AS p1, +parent1.col_int_key AS p2 +FROM t1 AS parent1 +LEFT JOIN t2 AS parent2 +ON parent1.col_int_nokey = parent2.col_int_key +) +AND grandparent1.col_int_key <> 3 +); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "2.70" + }, + "nested_loop": [ + { + "table": { + "table_name": "t3", + "access_type": "system", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.00", + "eval_cost": "0.10", + "prefix_cost": "0.00", + "data_read_per_join": "8" + }, + "used_columns": [ + "g1" + ] + } + }, + { + "duplicates_removal": { + "using_temporary_table": true, + "nested_loop": [ + { + "table": { + "table_name": "grandparent1", + "access_type": "ref", + "possible_keys": [ + "col_int_key" + ], + "key": "col_int_key", + "used_key_parts": [ + "col_int_key" + ], + "key_length": "4", + "ref": [ + "const" + ], + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "not_exists": true, + "cost_info": { + "read_cost": "0.28", + "eval_cost": "0.11", + "prefix_cost": "0.39", + "data_read_per_join": "17" + }, + "used_columns": [ + "col_int_nokey", + "col_int_key" + ], + "attached_condition": "(((is_not_null_compl(grandparent1..parent2), (found_match(grandparent1..parent2), false, true), true) and (is_not_null_compl(grandparent1..parent2), (('8' <> 3)), true)) and (is_not_null_compl(grandparent1..parent2), (`test`.`grandparent1`.`col_int_nokey` = '8'), true))" + } + }, + { + "table": { + "table_name": "parent1", + "access_type": "ref", + "possible_keys": [ + "col_int_key" + ], + "key": "col_int_key", + "used_key_parts": [ + "col_int_key" + ], + "key_length": "4", + "ref": [ + "test.grandparent1.col_int_nokey" + ], + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.30", + "eval_cost": "0.12", + "prefix_cost": "0.81", + "data_read_per_join": "19" + }, + "used_columns": [ + "col_int_nokey", + "col_int_key" + ], + "attached_condition": "(is_not_null_compl(grandparent1..parent2), (`test`.`parent1`.`col_int_key` = '8'), true)" + } + }, + { + "table": { + "table_name": "parent2", + "access_type": "ref", + "possible_keys": [ + "col_int_key" + ], + "key": "col_int_key", + "used_key_parts": [ + "col_int_key" + ], + "key_length": "4", + "ref": [ + "test.parent1.col_int_nokey" + ], + "rows_examined_per_scan": 2, + "rows_produced_per_join": 1, + "filtered": "100.00", + "using_index": true, + "cost_info": { + "read_cost": "0.31", + "eval_cost": "0.10", + "prefix_cost": "2.70", + "data_read_per_join": "16" + }, + "used_columns": [ + "col_int_key" + ] + } + } + ] + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select '8' AS `g1` from anti join (`test`.`t1` `grandparent1` join `test`.`t1` `parent1` left join `test`.`t2` `parent2` on((`test`.`parent2`.`col_int_key` = `test`.`parent1`.`col_int_nokey`))) on(((`test`.`grandparent1`.`col_int_nokey` = '8') and (`test`.`grandparent1`.`col_int_key` = '8') and (`test`.`parent1`.`col_int_key` = '8') and ('8' <> 3))) where true +SELECT * FROM t3 +WHERE g1 NOT IN +(SELECT grandparent1.col_int_nokey AS g1 +FROM t1 AS grandparent1 +WHERE (grandparent1.col_int_nokey, grandparent1.col_int_key) IN +(SELECT parent1.col_int_key AS p1, +parent1.col_int_key AS p2 +FROM t1 AS parent1 +LEFT JOIN t2 AS parent2 +ON parent1.col_int_nokey = parent2.col_int_key +) +AND grandparent1.col_int_key <> 3 +); +g1 +DROP TABLE t1, t2, t3; +# End of test for bug#13334882. +# +# Bug#13339643: Assertion on JOIN::flatten_subqueries on second execution +# +CREATE TABLE t1 ( +col_int_nokey INT, +col_varchar_nokey VARCHAR(1) +) charset utf8mb4; +INSERT INTO t1 VALUES +(1,'o'), +(2,'t'); +CREATE TABLE t2 LIKE t1; +INSERT INTO t2 VALUES +(1,'o'), +(4,'f'); +CREATE VIEW v_t2 AS SELECT * FROM t2; +CREATE TABLE t3 LIKE t1; +INSERT INTO t3 VALUES +(1,'o'), +(4,'f'); +explain SELECT alias1.col_varchar_nokey +FROM t1 AS alias1 +INNER JOIN v_t2 AS alias2 +ON alias2.col_int_nokey = alias1.col_int_nokey AND +'o' IN (SELECT col_varchar_nokey +FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary; End temporary +1 SIMPLE alias1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`alias1`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t1` `alias1` join `test`.`t2` semi join (`test`.`t3`) where ((`test`.`t3`.`col_varchar_nokey` = 'o') and (`test`.`t2`.`col_int_nokey` = `test`.`alias1`.`col_int_nokey`)) +SELECT alias1.col_varchar_nokey +FROM t1 AS alias1 +INNER JOIN v_t2 AS alias2 +ON alias2.col_int_nokey = alias1.col_int_nokey AND +'o' IN (SELECT col_varchar_nokey +FROM t3); +col_varchar_nokey +o +PREPARE stmt FROM "SELECT alias1.col_varchar_nokey +FROM t1 AS alias1 +INNER JOIN v_t2 AS alias2 +ON alias2.col_int_nokey = alias1.col_int_nokey AND +'o' IN (SELECT col_varchar_nokey +FROM t3)"; +EXECUTE stmt; +col_varchar_nokey +o +DROP VIEW v_t2; +DROP TABLE t1, t2, t3; +# End of test for bug#13339643. +# +# Bug#13424134: Wrong result on JOIN + nested WHERE ... IN clauses +# +CREATE TABLE t1 ( +pk int NOT NULL, +col_int_nokey int NOT NULL, +col_int_key int NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +) ENGINE=MyIsam; +INSERT INTO t1 VALUES +(10,1,7), (13,7,3), (18,0,1), (23,8,1); +CREATE TABLE t2 ( +pk int NOT NULL, +col_int_key int NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +) ENGINE=MyIsam; +INSERT INTO t2 VALUES (1,7); +EXPLAIN SELECT t1a.* +FROM t1 AS t1a +JOIN t1 AS t1b USING ( col_int_nokey ) +WHERE t1a.col_int_key IN ( +SELECT pk +FROM t2 +WHERE col_int_key IN ( +SELECT col_int_nokey +FROM t1 +) +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL system PRIMARY,col_int_key NULL NULL NULL 1 100.00 NULL +1 SIMPLE t1a NULL ref col_int_key col_int_key 4 const 1 100.00 Start temporary +1 SIMPLE t1b NULL ALL NULL NULL NULL NULL 4 25.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1a`.`pk` AS `pk`,`test`.`t1a`.`col_int_nokey` AS `col_int_nokey`,`test`.`t1a`.`col_int_key` AS `col_int_key` from `test`.`t1` `t1a` join `test`.`t1` `t1b` semi join (`test`.`t1`) where ((`test`.`t1b`.`col_int_nokey` = `test`.`t1a`.`col_int_nokey`) and (`test`.`t1a`.`col_int_key` = '1') and (`test`.`t1`.`col_int_nokey` = '7')) +SELECT t1a.* +FROM t1 AS t1a +JOIN t1 AS t1b USING ( col_int_nokey ) +WHERE t1a.col_int_key IN ( +SELECT pk +FROM t2 +WHERE col_int_key IN ( +SELECT col_int_nokey +FROM t1 +) +); +pk col_int_nokey col_int_key +18 0 1 +23 8 1 +ALTER TABLE t1 ENGINE=Innodb; +ALTER TABLE t2 ENGINE=Innodb; +SELECT t1a.* +FROM t1 AS t1a +JOIN t1 AS t1b USING ( col_int_nokey ) +WHERE t1a.col_int_key IN ( +SELECT pk +FROM t2 +WHERE col_int_key IN ( +SELECT col_int_nokey +FROM t1 +) +); +pk col_int_nokey col_int_key +18 0 1 +23 8 1 +DROP TABLE t1, t2; +# End of test for bug#13424134. +# +# Bug#13414014: Extra rows in result on semijoin query with where ... +# +CREATE TABLE t1 ( +c INT, +d INT, +a VARCHAR(1), +b VARCHAR(1), +KEY a (a) +) charset utf8mb4; +INSERT INTO t1 VALUES +(NULL,8,'x','x'), (7,4,'q','q'), (6,8,'c','c'); +CREATE TABLE t2 ( +a VARCHAR(1), +KEY a (a) +) charset utf8mb4; +INSERT INTO t2 VALUES +('c'), (NULL), ('x'), ('q'); +explain SELECT * +FROM t2 AS ot +WHERE (a, a) IN +(SELECT a, b +FROM t1 AS it +WHERE it.a = 'x' OR it.c > it.d +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE it NULL ALL a NULL NULL NULL 3 40.74 Using where; Start temporary +1 SIMPLE ot NULL ref a a 7 test.it.a 2 100.00 Using index; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`ot`.`a` AS `a` from `test`.`t2` `ot` semi join (`test`.`t1` `it`) where ((`test`.`it`.`b` = `test`.`it`.`a`) and (`test`.`ot`.`a` = `test`.`it`.`a`) and ((`test`.`it`.`a` = 'x') or (`test`.`it`.`c` > `test`.`it`.`d`))) +SELECT * +FROM t2 AS ot +WHERE (a, a) IN +(SELECT a, b +FROM t1 AS it +WHERE it.a = 'x' OR it.c > it.d +) +; +a +q +x +DROP TABLE t1, t2; +# End of test for bug#13414014. +# +# Bug#13545215: Missing rows on nested in-subquery with materialization +# +CREATE TABLE t1 ( +col_int_key int, +col_varchar_key varchar(1), +col_varchar_nokey varchar(1), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +INSERT INTO t1 VALUES +(8,'x','x'), (0,'p','p'), (8,'c','c'); +CREATE TABLE t2 ( +pk int NOT NULL, +col_varchar_key varchar(1), +col_varchar_nokey varchar(1), +PRIMARY KEY (pk), +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4; +INSERT INTO t2 VALUES +(1,'v','v'), (2,'v','v'), (3,'c','c'), (4,NULL,NULL), +(5,'x','x'), (6,'i','i'), (7,'e','e'), (8,'p','p'); +CREATE TABLE t3 ( +col_int_nokey int +); +INSERT INTO t3 VALUES (7); +explain SELECT grandparent1.col_varchar_nokey +FROM t1 AS grandparent1 JOIN t1 AS grandparent2 USING (col_int_key) +WHERE grandparent1.col_varchar_key IN ( +SELECT col_varchar_nokey +FROM t2 AS parent1 +WHERE col_varchar_key IN ( +SELECT child1.col_varchar_nokey +FROM t2 AS child1 LEFT JOIN t3 AS child2 +ON child1.pk < child2.col_int_nokey +) +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE grandparent1 NULL ALL col_int_key,col_varchar_key NULL NULL NULL 3 100.00 Using where; Start temporary +1 SIMPLE parent1 NULL ALL col_varchar_key NULL NULL NULL 8 12.50 Using where; Using join buffer (hash join) +1 SIMPLE child1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; Using join buffer (hash join) +1 SIMPLE child2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +1 SIMPLE grandparent2 NULL ref col_int_key col_int_key 5 test.grandparent1.col_int_key 2 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`grandparent1`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t1` `grandparent1` join `test`.`t1` `grandparent2` semi join (`test`.`t2` `parent1` join `test`.`t2` `child1` left join `test`.`t3` `child2` on((`test`.`child1`.`pk` < `test`.`child2`.`col_int_nokey`))) where ((`test`.`grandparent2`.`col_int_key` = `test`.`grandparent1`.`col_int_key`) and (`test`.`parent1`.`col_varchar_nokey` = `test`.`grandparent1`.`col_varchar_key`) and (`test`.`child1`.`col_varchar_nokey` = `test`.`parent1`.`col_varchar_key`)) +SELECT grandparent1.col_varchar_nokey +FROM t1 AS grandparent1 JOIN t1 AS grandparent2 USING (col_int_key) +WHERE grandparent1.col_varchar_key IN ( +SELECT col_varchar_nokey +FROM t2 AS parent1 +WHERE col_varchar_key IN ( +SELECT child1.col_varchar_nokey +FROM t2 AS child1 LEFT JOIN t3 AS child2 +ON child1.pk < child2.col_int_nokey +) +); +col_varchar_nokey +c +c +p +x +x +DROP TABLE t1, t2, t3; +# End of test for bug#13545215. +# +# BUG#13553211 - MISSING ROWS ON SELECT WITH IN-SUBQUERY AND +# MATERIALIZATION + SEMIJOIN ON +# +CREATE TABLE t1 ( +col_int_key int(11) DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (4,'v','v'); +INSERT INTO t1 VALUES (62,'v','v'); +INSERT INTO t1 VALUES (7,'c','c'); +INSERT INTO t1 VALUES (1,NULL,NULL); +EXPLAIN SELECT +alias1.col_varchar_nokey AS a1_nokey, +alias1.col_varchar_key AS a1_key, +alias2.col_varchar_nokey AS a2_nokey +FROM +t1 AS alias1, t1 AS alias2 +WHERE +(alias1.col_varchar_nokey,alias2.col_varchar_nokey) +IN +( +SELECT +sq2_alias2.col_varchar_nokey, sq2_alias1.col_varchar_key +FROM +t1 AS sq2_alias1, t1 AS sq2_alias2 +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE alias1 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +1 SIMPLE sq2_alias1 NULL index col_varchar_key col_varchar_key 12 NULL 4 100.00 Using index; LooseScan +1 SIMPLE sq2_alias2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; FirstMatch(sq2_alias1) +1 SIMPLE alias2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`alias1`.`col_varchar_nokey` AS `a1_nokey`,`test`.`alias1`.`col_varchar_key` AS `a1_key`,`test`.`alias2`.`col_varchar_nokey` AS `a2_nokey` from `test`.`t1` `alias1` join `test`.`t1` `alias2` semi join (`test`.`t1` `sq2_alias1` join `test`.`t1` `sq2_alias2`) where ((`test`.`alias2`.`col_varchar_nokey` = `test`.`sq2_alias1`.`col_varchar_key`) and (`test`.`sq2_alias2`.`col_varchar_nokey` = `test`.`alias1`.`col_varchar_nokey`)) +SELECT +alias1.col_varchar_nokey AS a1_nokey, +alias1.col_varchar_key AS a1_key, +alias2.col_varchar_nokey AS a2_nokey +FROM +t1 AS alias1, t1 AS alias2 +WHERE +(alias1.col_varchar_nokey,alias2.col_varchar_nokey) +IN +( +SELECT +sq2_alias2.col_varchar_nokey, sq2_alias1.col_varchar_key +FROM +t1 AS sq2_alias1, t1 AS sq2_alias2 +) +; +a1_nokey a1_key a2_nokey +c c c +c c v +c c v +v v c +v v c +v v v +v v v +v v v +v v v +DROP TABLE t1; +# +# Bug#13541406: Wrong result with loosescan on select .. where .. in +# +CREATE TABLE t1 ( +col_int_key INT NOT NULL, +col_varchar_nokey VARCHAR(1) NOT NULL, +KEY col_int_key (col_int_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t1 VALUES +(7,'v'), (0,'s'), (9,'l'), (3,'y'), (4,'c'), (2,'i'), (5,'h'), (3,'q'), +(1,'a'), (3,'v'), (6,'u'), (7,'s'), (5,'y'), (1,'z'), (204,'h'), (224,'p'), +(9,'e'), (5,'i'), (0,'y'), (3,'w'); +CREATE TABLE t2 ( +pk INT NOT NULL, +col_int_key INT NOT NULL, +col_varchar_key VARCHAR(1) NOT NULL, +col_varchar_nokey VARCHAR(1) NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t2 VALUES +(1,0,'j','j'), (2,8,'v','v'), (3,1,'c','c'), (4,8,'m','m'), +(5,9,'d','d'), (6,24,'d','d'), (7,6,'y','y'), (8,1,'t','t'), +(9,6,'d','d'), (10,2,'s','s'), (11,4,'r','r'), (12,8,'m','m'), +(13,4,'b','b'), (14,4,'x','x'), (15,7,'g','g'), (16,4,'p','p'), +(17,1,'q','q'), (18,9,'w','w'), (19,4,'d','d'), (20,8,'e','e'); +# This query should never use a LooseScan strategy +explain SELECT ot1.col_int_key AS field1 +FROM t2 AS ot1, t2 AS ot2 +WHERE (ot1.col_varchar_key, ot2.col_varchar_nokey) IN ( +SELECT it2.col_varchar_nokey, it1.col_varchar_key +FROM t2 AS it1 JOIN t1 AS it2 ON it2.col_int_key = it1.pk); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 20 100.00 Parallel execute (1 workers) +2 SIMPLE ot1 NULL index col_varchar_key col_varchar_key 10 NULL 20 100.00 Using index +2 SIMPLE it1 NULL index PRIMARY,col_varchar_key col_varchar_key 10 NULL 20 80.00 Using index; LooseScan +2 SIMPLE it2 NULL ref col_int_key col_int_key 4 test.it1.pk 1 10.00 Using where; FirstMatch(it1) +2 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 20 10.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`col_int_key` AS `field1` from `test`.`t2` `ot1` join `test`.`t2` `ot2` semi join (`test`.`t2` `it1` join `test`.`t1` `it2`) where ((`test`.`it2`.`col_int_key` = `test`.`it1`.`pk`) and (`test`.`ot2`.`col_varchar_nokey` = `test`.`it1`.`col_varchar_key`) and (`test`.`it2`.`col_varchar_nokey` = `test`.`ot1`.`col_varchar_key`)) +SELECT ot1.col_int_key AS field1 +FROM t2 AS ot1, t2 AS ot2 +WHERE (ot1.col_varchar_key, ot2.col_varchar_nokey) IN ( +SELECT it2.col_varchar_nokey, it1.col_varchar_key +FROM t2 AS it1 JOIN t1 AS it2 ON it2.col_int_key = it1.pk); +field1 +1 +1 +1 +2 +6 +6 +6 +6 +6 +8 +8 +8 +8 +8 +8 +9 +DROP TABLE t1, t2; +# End of test for bug#13541406. +# +# Bug#13576391: Missing rows on select with in-subquery and +# batched-key-access=on and semijoin +# +CREATE TABLE t1 ( +col_int_nokey int NOT NULL, +col_varchar_key varchar(1) NOT NULL, +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4 engine=InnoDB; +INSERT INTO t1 VALUES +(1,'v'), (7,'s'), (4,'l'), (7,'y'), (0,'c'), (2,'i'), (9,'h'), (4,'q'), +(0,'a'), (9,'v'), (1,'u'), (3,'s'), (8,'y'), (8,'z'), (18,'h'), (84,'p'), +(6,'e'), (3,'i'), (6,'y'), (6,'w'); +CREATE TABLE t2 ( +col_int_nokey int NOT NULL, +col_varchar_nokey varchar(1) NOT NULL +) charset utf8mb4 engine=InnoDB; +INSERT INTO t2 VALUES +(4,'j'), (6,'v'), (3,'c'), (5,'m'), (3,'d'), (246,'d'), (2,'y'), (9,'t'), +(3,'d'), (8,'s'), (1,'r'), (8,'m'), (8,'b'), (5,'x'), (7,'g'), (5,'p'), +(1,'q'), (6,'w'), (2,'d'), (9,'e'); +explain SELECT col_varchar_nokey +FROM t2 AS ot +WHERE col_varchar_nokey IN ( +SELECT col_varchar_key +FROM t1 AS it +WHERE it.col_int_nokey <= it.col_int_nokey +AND NOT ot.col_int_nokey < 2 +) +ORDER BY col_varchar_nokey; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 20 33.33 Parallel execute (1 workers) +2 SIMPLE ot NULL ALL NULL NULL NULL NULL 20 33.33 Using where; Using filesort +2 SIMPLE it NULL ref col_varchar_key col_varchar_key 6 test.ot.col_varchar_nokey 1 100.00 Start temporary; End temporary +Warnings: +Note 1276 Field or reference 'test.ot.col_int_nokey' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`ot`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t2` `ot` semi join (`test`.`t1` `it`) where ((`test`.`it`.`col_varchar_key` = `test`.`ot`.`col_varchar_nokey`) and (`test`.`ot`.`col_int_nokey` >= 2)) order by `test`.`ot`.`col_varchar_nokey` +SELECT col_varchar_nokey +FROM t2 AS ot +WHERE col_varchar_nokey IN ( +SELECT col_varchar_key +FROM t1 AS it +WHERE it.col_int_nokey <= it.col_int_nokey +AND NOT ot.col_int_nokey < 2 +) +ORDER BY col_varchar_nokey; +col_varchar_nokey +c +e +p +s +v +w +y +ALTER TABLE t1 ENGINE=MyISAM; +ALTER TABLE t2 ENGINE=MyISAM; +explain SELECT col_varchar_nokey +FROM t2 AS ot +WHERE col_varchar_nokey IN ( +SELECT col_varchar_key +FROM t1 AS it +WHERE it.col_int_nokey <= it.col_int_nokey +AND NOT ot.col_int_nokey < 2 +) +ORDER BY col_varchar_nokey; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 20 33.33 Using where; Using filesort +1 SIMPLE it NULL ref col_varchar_key col_varchar_key 6 test.ot.col_varchar_nokey 2 100.00 Start temporary; End temporary +Warnings: +Note 1276 Field or reference 'test.ot.col_int_nokey' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`ot`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t2` `ot` semi join (`test`.`t1` `it`) where ((`test`.`it`.`col_varchar_key` = `test`.`ot`.`col_varchar_nokey`) and (`test`.`ot`.`col_int_nokey` >= 2)) order by `test`.`ot`.`col_varchar_nokey` +SELECT col_varchar_nokey +FROM t2 AS ot +WHERE col_varchar_nokey IN ( +SELECT col_varchar_key +FROM t1 AS it +WHERE it.col_int_nokey <= it.col_int_nokey +AND NOT ot.col_int_nokey < 2 +) +ORDER BY col_varchar_nokey; +col_varchar_nokey +c +e +p +s +v +w +y +ALTER TABLE t1 ENGINE=Memory; +ALTER TABLE t2 ENGINE=Memory; +explain SELECT col_varchar_nokey +FROM t2 AS ot +WHERE col_varchar_nokey IN ( +SELECT col_varchar_key +FROM t1 AS it +WHERE it.col_int_nokey <= it.col_int_nokey +AND NOT ot.col_int_nokey < 2 +) +ORDER BY col_varchar_nokey; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 20 33.33 Using where; Using filesort +1 SIMPLE it NULL ref col_varchar_key col_varchar_key 6 test.ot.col_varchar_nokey 2 100.00 Start temporary; End temporary +Warnings: +Note 1276 Field or reference 'test.ot.col_int_nokey' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`ot`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t2` `ot` semi join (`test`.`t1` `it`) where ((`test`.`it`.`col_varchar_key` = `test`.`ot`.`col_varchar_nokey`) and (`test`.`ot`.`col_int_nokey` >= 2)) order by `test`.`ot`.`col_varchar_nokey` +SELECT col_varchar_nokey +FROM t2 AS ot +WHERE col_varchar_nokey IN ( +SELECT col_varchar_key +FROM t1 AS it +WHERE it.col_int_nokey <= it.col_int_nokey +AND NOT ot.col_int_nokey < 2 +) +ORDER BY col_varchar_nokey; +col_varchar_nokey +c +e +p +s +v +w +y +DROP TABLE t1, t2; +# End of test for bug#13576391. +# +# Bug #13589848 "MISSING ROW ON SELECT WITH NESTED IN CLAUSES WHEN LOOSESCAN=ON" +# +CREATE TABLE t1 ( +id INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +KEY (col_varchar_key) +) charset utf8mb4; +INSERT INTO t1 VALUES (100,'m','m'), +(200,'b','b'), (300,'x','x'); +CREATE TABLE t2 ( +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +KEY (col_varchar_key) +) charset utf8mb4; +INSERT INTO t2 VALUES ('b','b'); +CREATE TABLE t3 ( +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +KEY (col_varchar_key) +) charset utf8mb4; +INSERT INTO t3 VALUES ('k','k'); +EXPLAIN SELECT gp1.id +FROM t1 AS gp1 JOIN t3 AS gp2 +ON gp2.col_varchar_key <> gp1.col_varchar_nokey +WHERE (gp1.col_varchar_nokey, gp1.col_varchar_nokey) +IN ( +SELECT col_varchar_nokey, col_varchar_nokey +FROM t1 +WHERE col_varchar_nokey +IN ( SELECT col_varchar_key +FROM t2 LEFT JOIN t3 USING (col_varchar_key) ) +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE gp2 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL index col_varchar_key col_varchar_key 7 NULL 1 100.00 Using where; Using index; Start temporary +1 SIMPLE gp1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ref col_varchar_key col_varchar_key 7 test.t2.col_varchar_key 2 100.00 Using index; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`gp1`.`id` AS `id` from `test`.`t1` `gp1` semi join (`test`.`t1` join `test`.`t2` left join `test`.`t3` on((`test`.`t2`.`col_varchar_key` = `test`.`t3`.`col_varchar_key`))) where ((`test`.`gp1`.`col_varchar_nokey` = `test`.`t2`.`col_varchar_key`) and (`test`.`t1`.`col_varchar_nokey` = `test`.`t2`.`col_varchar_key`) and ('k' <> `test`.`t2`.`col_varchar_key`)) +SELECT gp1.id +FROM t1 AS gp1 JOIN t3 AS gp2 +ON gp2.col_varchar_key <> gp1.col_varchar_nokey +WHERE (gp1.col_varchar_nokey, gp1.col_varchar_nokey) +IN ( +SELECT col_varchar_nokey, col_varchar_nokey +FROM t1 +WHERE col_varchar_nokey +IN ( SELECT col_varchar_key +FROM t2 LEFT JOIN t3 USING (col_varchar_key) ) +) +; +id +200 +DROP TABLE t1,t2,t3; +# +# Bug #13596176: Missing row on select with nested in clause when +# matr=on and bnl=off + MyISAM +# +CREATE TABLE t1 ( +int_key int DEFAULT NULL, +vc_key varchar(1) DEFAULT NULL, +vc_nokey varchar(1) DEFAULT NULL, +KEY int_key (int_key), +KEY vc_key (vc_key, int_key) +) charset utf8mb4 ENGINE=MyISAM; +INSERT INTO t1 VALUES +(8,'x','x'), (7,'d','d'), (1,'r','r'), (7,'f','f'), +(9,'y','y'), (NULL,'u','u'), (1,'m','m'), (9,NULL,NULL), +(2,'o','o'), (9,'w','w'), (2,'m','m'), (4,'q','q'), +(0,NULL,NULL), (4,'d','d'), (8,'g','g'), (NULL,'x','x'), +(NULL,'f','f'), (0,'p','p'), (NULL,'j','j'), (8,'c','c'); +CREATE TABLE t2 ( +int_key int DEFAULT NULL, +vc_key varchar(1) DEFAULT NULL, +KEY int_key (int_key), +KEY vc_key (vc_key, int_key) +) charset utf8mb4 ENGINE=MyISAM; +INSERT INTO t2 VALUES (8,'g'); +explain SELECT vc_key +FROM t1 as outr +WHERE (vc_nokey, vc_key ) IN +(SELECT vc_nokey, vc_nokey +FROM t1 middle +WHERE vc_nokey IN +(SELECT child1.vc_key +FROM t2 AS child1 JOIN t1 AS child2 USING (int_key) +) +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE child1 NULL index int_key,vc_key vc_key 12 NULL 1 100.00 Using where; Using index; Start temporary +1 SIMPLE outr NULL ref vc_key vc_key 7 test.child1.vc_key 3 10.00 Using where +1 SIMPLE middle NULL ALL NULL NULL NULL NULL 20 10.00 Using where; Using join buffer (hash join) +1 SIMPLE child2 NULL ref int_key int_key 5 test.child1.int_key 3 100.00 Using index; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`outr`.`vc_key` AS `vc_key` from `test`.`t1` `outr` semi join (`test`.`t1` `middle` join `test`.`t2` `child1` join `test`.`t1` `child2`) where ((`test`.`child2`.`int_key` = `test`.`child1`.`int_key`) and (`test`.`outr`.`vc_nokey` = `test`.`child1`.`vc_key`) and (`test`.`outr`.`vc_key` = `test`.`child1`.`vc_key`) and (`test`.`middle`.`vc_nokey` = `test`.`child1`.`vc_key`)) +SELECT vc_key +FROM t1 as outr +WHERE (vc_nokey, vc_key ) IN +(SELECT vc_nokey, vc_nokey +FROM t1 middle +WHERE vc_nokey IN +(SELECT child1.vc_key +FROM t2 AS child1 JOIN t1 AS child2 USING (int_key) +) +); +vc_key +g +DROP TABLE t1, t2; +# End of test for bug#13596176. +# +# BUG#11754478: MAX/MIN + SUBQUERY + AND FAILS TO RETURN ANY ROWS +# BUG#13599013: MAX/MIN + SUBQUERY IN WHERE CLAUSE MATCHING NO +# ROWS + INDEX DOES NOT RETURN NULL +# +CREATE TABLE t1 ( +pk int(11) PRIMARY KEY, +int_key int(11), +KEY int_key (int_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (1,0),(2,0),(3,2),(4,0),(5,3),(6,0); +SELECT MIN(int_key) FROM t1 WHERE (4, 4) IN (SELECT 1, 2); +MIN(int_key) +NULL +SELECT MIN(int_key) FROM t1 WHERE (4, 4) IN (SELECT 4, 4); +MIN(int_key) +0 +SELECT MIN(pk) FROM t1 WHERE pk IN (SELECT int_key FROM t1) AND pk = 6; +MIN(pk) +NULL +DROP TABLE t1; +# BUG#13726217: Crash in Item_ident::fix_after_pullout() +CREATE TABLE t1(a INTEGER) engine=innodb; +INSERT INTO t1 VALUES (0); +SELECT 0 +FROM t1 +WHERE 0 IN +(SELECT 0 +FROM t1 +WHERE 0 LIKE +(SELECT elt(a, 0) AS b +FROM t1 +GROUP BY a +HAVING b +) +); +0 +DROP TABLE t1; +# End of test for bug#13726217. +# BUG#13773979: Missing rows on second execution of prepared statement +CREATE TABLE t1 ( +col_int_nokey INT, +col_int_key INT, +col_varchar_key VARCHAR(1) +); +INSERT INTO t1 VALUES +(1,7,'v'), (7,0,'s'), (4,9,'l'), (7,3,'y'), +(2,2,'i'), (9,5,'h'), (0,1,'a'), (9,3,'v'); +CREATE VIEW v1 AS SELECT * FROM t1; +SELECT * +FROM t1 +WHERE col_int_key IN ( +SELECT alias1.col_int_nokey AS field1 +FROM v1 AS alias1 +WHERE alias1.col_varchar_key < 'v' +); +col_int_nokey col_int_key col_varchar_key +1 7 v +2 2 i +4 9 l +7 0 s +prepare stmt FROM "SELECT * +FROM t1 +WHERE col_int_key IN ( +SELECT alias1.col_int_nokey AS field1 +FROM v1 AS alias1 +WHERE alias1.col_varchar_key < 'v' +)"; +execute stmt; +col_int_nokey col_int_key col_varchar_key +1 7 v +2 2 i +4 9 l +7 0 s +execute stmt; +col_int_nokey col_int_key col_varchar_key +1 7 v +2 2 i +4 9 l +7 0 s +DEALLOCATE PREPARE stmt; +DROP VIEW v1; +DROP TABLE t1; +# End of test for bug#13773979. +# +# BUG#13685026 ASSERTION CUR_SJ_INNER_TABLES == 0 IN +# --OPTIMIZE_TABLE_ORDER::CHOOSE_TABLE_ORDER +# +CREATE TABLE t1 ( +col_int_key INT(11) NOT NULL, +col_datetime_key DATETIME NOT NULL, +col_varchar_key VARCHAR(1) NOT NULL, +col_varchar_nokey VARCHAR(1) NOT NULL, +KEY col_int_key (col_int_key), +KEY col_datetime_key (col_datetime_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (0,'2002-02-13 17:30:06','j','j'); +INSERT INTO t1 VALUES (8,'2008-09-27 00:34:58','v','v'); +CREATE TABLE t2 ( +col_int_key INT(11) NOT NULL, +col_datetime_key DATETIME NOT NULL, +col_varchar_key VARCHAR(1) NOT NULL, +col_varchar_nokey VARCHAR(1) NOT NULL, +KEY col_int_key (col_int_key), +KEY col_datetime_key (col_datetime_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (7,'2003-08-21 00:00:00','b','b'); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +SET @old_depth=@@optimizer_search_depth; +SET optimizer_search_depth=4; +EXPLAIN SELECT col_datetime_key +FROM t1 as outr +WHERE col_datetime_key IN ( +SELECT alias1.col_datetime_key +FROM t1 AS alias1 +LEFT JOIN t1 as alias3 +STRAIGHT_JOIN ( t2 AS alias4 +JOIN t1 AS alias5 +ON alias5.col_varchar_key <= alias4.col_varchar_nokey ) +ON alias5.col_int_key < alias4.col_int_key +ON alias5.col_varchar_key = alias4.col_varchar_key +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE outr NULL index col_datetime_key col_datetime_key 5 NULL 2 100.00 Using index +1 SIMPLE alias1 NULL ref col_datetime_key col_datetime_key 5 test.outr.col_datetime_key 1 100.00 Using index; Start temporary +1 SIMPLE alias4 NULL ALL col_int_key,col_varchar_key NULL NULL NULL 1 100.00 NULL +1 SIMPLE alias5 NULL ref col_int_key,col_varchar_key col_varchar_key 6 test.alias4.col_varchar_key 1 100.00 Using where; Using index +1 SIMPLE alias3 NULL index NULL col_int_key 4 NULL 2 100.00 Using index; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`outr`.`col_datetime_key` AS `col_datetime_key` from `test`.`t1` `outr` semi join (`test`.`t1` `alias1` left join (`test`.`t1` `alias3` join `test`.`t2` `alias4` join `test`.`t1` `alias5`) on(((`test`.`alias5`.`col_varchar_key` = `test`.`alias4`.`col_varchar_key`) and (`test`.`alias5`.`col_int_key` < `test`.`alias4`.`col_int_key`) and (`test`.`alias5`.`col_varchar_key` <= `test`.`alias4`.`col_varchar_nokey`)))) where (`test`.`alias1`.`col_datetime_key` = `test`.`outr`.`col_datetime_key`) +SELECT col_datetime_key +FROM t1 as outr +WHERE col_datetime_key IN ( +SELECT alias1.col_datetime_key +FROM t1 AS alias1 +LEFT JOIN t1 as alias3 +STRAIGHT_JOIN ( t2 AS alias4 +JOIN t1 AS alias5 +ON alias5.col_varchar_key <= alias4.col_varchar_nokey ) +ON alias5.col_int_key < alias4.col_int_key +ON alias5.col_varchar_key = alias4.col_varchar_key +); +col_datetime_key +2002-02-13 17:30:06 +2008-09-27 00:34:58 +DROP TABLE t1,t2; +SET @@optimizer_search_depth=@old_depth; +# +# BUG#13848789: SEGFAULT IN JOIN_READ_NEXT_SAME AT +# SQL/SQL_EXECUTOR.CC ON HAVING...IN...JOIN +# +CREATE TABLE t1 ( +col_int_key INT, +col_varchar_key VARCHAR(1), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4; +INSERT INTO t1 VALUES (8,'x'); +CREATE TABLE t2 ( +col_varchar_key VARCHAR(1), +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4; +INSERT INTO t2 VALUES ('x'), ('y'); +explain SELECT MIN(col_int_key) +FROM t1 as t1_outer +HAVING (1, 2) IN ( +SELECT t1_inner.col_int_key, MAX(t1_inner.col_int_key) +FROM t1 as t1_inner JOIN t2 +ON t2.col_varchar_key = t1_inner.col_varchar_key +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible HAVING +2 SUBQUERY t1_inner NULL system col_varchar_key NULL NULL NULL 1 100.00 NULL +2 SUBQUERY t2 NULL ref col_varchar_key col_varchar_key 7 const 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select min(`test`.`t1_outer`.`col_int_key`) AS `MIN(col_int_key)` from `test`.`t1` `t1_outer` having false +SELECT MIN(col_int_key) +FROM t1 as t1_outer +HAVING (1, 2) IN ( +SELECT t1_inner.col_int_key, MAX(t1_inner.col_int_key) +FROM t1 as t1_inner JOIN t2 +ON t2.col_varchar_key = t1_inner.col_varchar_key +); +MIN(col_int_key) +DROP TABLE t1,t2; +# Bug#13838810: Segfault in evaluate_null_complemented_join_record +CREATE TABLE t1 ( +pk int NOT NULL, +col_int_nokey int DEFAULT NULL, +col_int_key int DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t1 VALUES (10,NULL,8,'x'); +CREATE TABLE t2 ( +pk int NOT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +PRIMARY KEY (pk) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t2 VALUES (1,'x'); +CREATE TABLE t3 ( +pk int NOT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +PRIMARY KEY (pk), +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t3 VALUES +(1,'v','v'), (2,'v','v'), (3,'c','c'), (4,NULL,NULL); +EXPLAIN SELECT table1.pk,table2.pk, table3.pk +FROM t2 AS table1 +LEFT JOIN t1 AS table2 +LEFT JOIN t1 AS table3 +ON table3.col_int_key = table2.col_int_key +ON table3.pk = table2.col_int_nokey AND +table1.col_varchar_nokey IN ( +SELECT subquery3_t1.col_varchar_nokey +FROM t3 AS subquery3_t1 +LEFT JOIN t1 AS subquery3_t2 +ON subquery3_t2.col_varchar_key = subquery3_t1.col_varchar_key +WHERE subquery3_t2.col_int_nokey <> 9 +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE table1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE table2 NULL ALL col_int_key NULL NULL NULL 1 100.00 NULL +2 SIMPLE table3 NULL eq_ref PRIMARY,col_int_key PRIMARY 4 test.table2.col_int_nokey 1 100.00 Using where +2 SIMPLE subquery3_t2 NULL ALL col_varchar_key NULL NULL NULL 1 100.00 Using where; Start temporary +2 SIMPLE subquery3_t1 NULL ref col_varchar_key col_varchar_key 7 test.subquery3_t2.col_varchar_key 1 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`table1`.`pk` AS `pk`,`test`.`table2`.`pk` AS `pk`,`test`.`table3`.`pk` AS `pk` from `test`.`t2` `table1` left join (`test`.`t1` `table2` join `test`.`t1` `table3` semi join (`test`.`t3` `subquery3_t1` join `test`.`t1` `subquery3_t2`)) on(((`test`.`table3`.`col_int_key` = `test`.`table2`.`col_int_key`) and (`test`.`subquery3_t1`.`col_varchar_key` = `test`.`subquery3_t2`.`col_varchar_key`) and (`test`.`subquery3_t1`.`col_varchar_nokey` = `test`.`table1`.`col_varchar_nokey`) and (`test`.`table3`.`pk` = `test`.`table2`.`col_int_nokey`) and (`test`.`subquery3_t2`.`col_int_nokey` <> 9))) where true +SELECT table1.pk,table2.pk, table3.pk +FROM t2 AS table1 +LEFT JOIN t1 AS table2 +LEFT JOIN t1 AS table3 +ON table3.col_int_key = table2.col_int_key +ON table3.pk = table2.col_int_nokey AND +table1.col_varchar_nokey IN ( +SELECT subquery3_t1.col_varchar_nokey +FROM t3 AS subquery3_t1 +LEFT JOIN t1 AS subquery3_t2 +ON subquery3_t2.col_varchar_key = subquery3_t1.col_varchar_key +WHERE subquery3_t2.col_int_nokey <> 9 +) +; +pk pk pk +1 NULL NULL +DROP TABLE t1, t2, t3; +Extra test case for specific code coverage +CREATE TABLE t1(pk INTEGER); +INSERT INTO t1 VALUES(1), (2); +explain SELECT * +FROM t1 AS ot1 LEFT JOIN t1 AS ot2 +ON ot1.pk=ot2.pk AND +ot2.pk IN +(SELECT it1.pk +FROM t1 AS it1 LEFT JOIN t1 AS it2 ON it1.pk=it2.pk); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +1 SIMPLE it1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +1 SIMPLE it2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`pk` AS `pk`,`test`.`ot2`.`pk` AS `pk` from `test`.`t1` `ot1` left join (`test`.`t1` `ot2` semi join (`test`.`t1` `it1` left join `test`.`t1` `it2` on((`test`.`it1`.`pk` = `test`.`it2`.`pk`)))) on(((`test`.`ot2`.`pk` = `test`.`ot1`.`pk`) and (`test`.`it1`.`pk` = `test`.`ot1`.`pk`))) where true +SELECT * +FROM t1 AS ot1 LEFT JOIN t1 AS ot2 +ON ot1.pk=ot2.pk AND +ot2.pk IN +(SELECT it1.pk +FROM t1 AS it1 LEFT JOIN t1 AS it2 ON it1.pk=it2.pk); +pk pk +1 1 +2 2 +DROP TABLE t1; +# End of test for bug#13838810. +# +# Bug#13845930: Segfault in st_join_table::and_with_condition +# +CREATE TABLE t1 ( +col_int INTEGER +); +CREATE TABLE t2 ( +col_varchar_1 VARCHAR(1), +col_varchar_2 VARCHAR(1) +); +INSERT INTO t2 VALUES ('x','x'), ('c','c'); +PREPARE stmt FROM ' +SELECT alias2.col_varchar_2 AS field1 +FROM t2 AS alias1 + JOIN + (t2 AS alias2 + LEFT JOIN t2 AS alias3 + ON (8, 92) IN + (SELECT sq1_alias1.col_int, + sq1_alias2.col_int + FROM t1 AS sq1_alias1 JOIN t1 AS sq1_alias2 + ) + ) + ON alias3.col_varchar_1 = alias2.col_varchar_2 +'; +EXECUTE stmt; +field1 + +EXECUTE stmt; +field1 +DEALLOCATE prepare stmt; +DROP TABLE t1, t2; +# End of test for bug#13845930. +# +# Bug#13855925: Assert 'prebuilt->search_tuple->n_fields > 0' +# in ha_innobase::index_read +# +CREATE TABLE t1 ( +pk INTEGER AUTO_INCREMENT, +col_int_nokey INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk), +KEY (col_varchar_key) +) charset utf8mb4 ENGINE=INNODB; +INSERT INTO t1 ( +col_int_key, col_int_nokey, +col_varchar_key, col_varchar_nokey +) VALUES +(4, 2, 'v','v'), (62, 150, 'v','v'), (7, NULL, 'c','c'), (1, 2, NULL, NULL), +(0, 5, 'x','x'), (7, 3, 'i','i'), (7, 1, 'e','e'), (1, 4, 'p','p'), +(7, NULL, 's','s'), (1, 2, 'j','j'), (5, 6, 'z','z'), (2, 6, 'c','c'), +(0, 8, 'a','a'), (1, 2, 'q','q'), (8, 6, 'y','y'), (1, 8, NULL, NULL), +(1, 3, 'r','r'), (9, 3, 'v','v'), (1, 9, NULL, NULL), (5, 6, 'r','r'); +CREATE TABLE t2 ( +pk INT AUTO_INCREMENT, +col_int_nokey INT, +col_int_key INT, +PRIMARY KEY (pk), +KEY (col_int_key) +) charset utf8mb4 AUTO_INCREMENT=10 ENGINE=INNODB; +INSERT INTO t2 (col_int_key, col_int_nokey) VALUES +(8, NULL), (7, 8), (1, 1), (7, 9), (9, 4), (NULL, 3), (1, 2), (9, NULL), +(2, 2), (9, NULL), (2, 6), (4, 7), (0, 2), (4, 5), (8, 7), (NULL, 6), +(NULL, 6), (0, 2), (NULL, 9), (8, 6); +CREATE TABLE t3 ( +pk INT AUTO_INCREMENT, +col_varchar_key VARCHAR(1), +PRIMARY KEY (pk), +KEY (col_varchar_key) +) charset utf8mb4 ENGINE=INNODB; +INSERT INTO t3 (col_varchar_key) VALUES +('c'), ('c'), ('q'), ('g'), ('e'), ('l'), (NULL), ('c'), ('h'), ('d'), +('c'), ('i'), ('t'), ('g'), ('q'), ('l'), ('n'), ('z'), ('n'), ('r'), ('p'); +CREATE VIEW v1 AS +SELECT table2.col_varchar_nokey AS field1 +FROM t2 AS table1 +INNER JOIN (t1 AS table2 +STRAIGHT_JOIN t2 AS table3 +ON table3.col_int_key = table2.pk AND +table3.col_int_nokey = ANY +(SELECT subquery1_t2.col_int_nokey AS subquery1_field1 +FROM t2 AS subquery1_t1 +RIGHT OUTER JOIN t1 AS subquery1_t2 +INNER JOIN t1 AS subquery1_t3 +ON subquery1_t3.col_int_key = subquery1_t2.pk +ON subquery1_t3.col_varchar_key=subquery1_t2.col_varchar_nokey +WHERE subquery1_t1.pk > 1 +) +) +ON table3.col_int_key IN +(SELECT subquery2_t1.col_int_key AS subquery2_field1 +FROM t2 AS subquery2_t1 +RIGHT OUTER JOIN t3 AS subquery2_t2 +LEFT OUTER JOIN t1 AS subquery2_t3 +ON subquery2_t3.col_varchar_key = subquery2_t2.col_varchar_key +ON subquery2_t3.pk = subquery2_t2.pk +) +; +explain SELECT * FROM v1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE subquery2_t3 NULL index PRIMARY,col_varchar_key col_varchar_key 7 NULL 20 100.00 Using where; Using index; Start temporary +1 SIMPLE subquery2_t2 NULL eq_ref PRIMARY,col_varchar_key PRIMARY 4 test.subquery2_t3.pk 1 7.14 Using where +1 SIMPLE subquery1_t3 NULL ALL col_varchar_key NULL NULL NULL 20 100.00 Using where; Using join buffer (hash join) +1 SIMPLE subquery1_t2 NULL eq_ref PRIMARY PRIMARY 4 test.subquery1_t3.col_int_key 1 10.00 Using where +1 SIMPLE subquery2_t1 NULL range col_int_key col_int_key 5 NULL 16 100.00 Using where; Using index; Using join buffer (hash join) +1 SIMPLE table2 NULL eq_ref PRIMARY PRIMARY 4 test.subquery2_t1.col_int_key 1 100.00 NULL +1 SIMPLE table3 NULL ref col_int_key col_int_key 5 test.subquery2_t1.col_int_key 2 10.00 Using where +1 SIMPLE subquery1_t1 NULL index PRIMARY col_int_key 5 NULL 20 100.00 Using where; Using index; End temporary; Using join buffer (hash join) +1 SIMPLE table1 NULL index NULL col_int_key 5 NULL 20 100.00 Using index; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `table2`.`col_varchar_nokey` AS `field1` from `test`.`t2` `table1` join `test`.`t1` `table2` straight_join `test`.`t2` `table3` semi join (`test`.`t1` `subquery1_t2` join `test`.`t1` `subquery1_t3` join `test`.`t2` `subquery1_t1`) semi join (`test`.`t3` `subquery2_t2` join `test`.`t1` `subquery2_t3` join `test`.`t2` `subquery2_t1`) where ((`subquery1_t2`.`pk` = `subquery1_t3`.`col_int_key`) and (`subquery1_t2`.`col_varchar_nokey` = `subquery1_t3`.`col_varchar_key`) and (`subquery2_t2`.`col_varchar_key` = `subquery2_t3`.`col_varchar_key`) and (`subquery2_t2`.`pk` = `subquery2_t3`.`pk`) and (`table2`.`pk` = `subquery2_t1`.`col_int_key`) and (`table3`.`col_int_key` = `subquery2_t1`.`col_int_key`) and (`table3`.`col_int_nokey` = `subquery1_t2`.`col_int_nokey`) and (`subquery1_t1`.`pk` > 1)) +SELECT * FROM v1; +field1 +v +v +v +v +v +v +v +v +v +v +v +v +v +v +v +v +v +v +v +v +DROP VIEW v1; +DROP TABLE t1,t2,t3; +# End of test for bug#13855925. +# +# Bug#13897959: Segfault in setup_semijoin_dups_elimination() +# +CREATE TABLE t1 ( +col_datetime_key DATETIME DEFAULT NULL, +KEY col_datetime_key (col_datetime_key) +) ENGINE=MyISAM; +INSERT INTO t1 VALUES +('2001-04-18 00:00:00'), ('2008-12-18 19:39:55'), +('2000-08-01 12:19:39'), ('2004-09-25 21:29:06'), +('2009-09-20 09:11:48'), ('2004-03-27 09:32:04'); +CREATE TABLE t2 ( +col_date_nokey date DEFAULT NULL, +col_time_key time DEFAULT NULL, +col_datetime_key datetime DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +KEY col_time_key (col_time_key), +KEY col_datetime_key (col_datetime_key), +KEY col_varchar_key(col_varchar_key) +) ENGINE=MyISAM; +INSERT INTO t2 VALUES ('1900-01-01',NULL,'2001-11-04 19:07:55','x','x'); +SELECT grandparent1.col_varchar_nokey +FROM t2 AS grandparent1 LEFT JOIN t1 USING (col_datetime_key) +WHERE grandparent1.col_varchar_nokey IN ( +SELECT col_varchar_nokey +FROM t2 AS parent1 +WHERE parent1.col_time_key > grandparent1.col_date_nokey +); +col_varchar_nokey +DROP TABLE t1, t2; +# End of test for bug#13897959. +# +# Bug#13898625 ASSERT `(REMAINING_TABLES_AFTER != 0) ...' IN +# BEST_EXTENSION_BY_LIMITED_SEARCH +# +CREATE TABLE t1 ( +pk int(11) NOT NULL, +col_int_nokey INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (26,6,NULL,'f','f'); +INSERT INTO t1 VALUES (29,6,8,'c','c'); +CREATE TABLE t2 ( +pk INT NOT NULL, +col_int_nokey INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +INSERT INTO t2 VALUES (1,2,4,'v','v'); +INSERT INTO t2 VALUES (2,150,62,'v','v'); +INSERT INTO t2 VALUES (5,5,0,'x','x'); +INSERT INTO t2 VALUES (6,3,7,'i','i'); +INSERT INTO t2 VALUES (7,1,7,'e','e'); +CREATE VIEW view_c AS SELECT * FROM t2; +PREPARE prep_stmt_7430 FROM 'SELECT SUM( alias1.col_varchar_key ) AS field1 +FROM t1 AS alias1 +RIGHT JOIN t2 AS alias2 +INNER JOIN t1 AS alias3 +ON (alias3.col_varchar_key = alias2.col_varchar_key ) +ON ( "v" ) IN ( +SELECT sq1_alias1.col_varchar_nokey AS sq1_field1 +FROM t1 AS sq1_alias1 +) +WHERE alias3.pk IN ( +SELECT sq2_alias1.col_int_key AS sq2_field1 +FROM ( view_c AS sq2_alias1, t1 AS sq2_alias2 ) +) +'; +EXECUTE prep_stmt_7430; +field1 +NULL +EXECUTE prep_stmt_7430; +field1 +NULL +EXPLAIN SELECT SUM( alias1.col_varchar_key ) AS field1 +FROM t1 AS alias1 +RIGHT JOIN t2 AS alias2 +INNER JOIN t1 AS alias3 +ON (alias3.col_varchar_key = alias2.col_varchar_key ) +ON ( "v" ) IN ( +SELECT sq1_alias1.col_varchar_nokey AS sq1_field1 +FROM t1 AS sq1_alias1 +) +WHERE alias3.pk IN ( +SELECT sq2_alias1.col_int_key AS sq2_field1 +FROM ( view_c AS sq2_alias1, t1 AS sq2_alias2 ) +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE alias3 NULL ALL PRIMARY,col_varchar_key NULL NULL NULL 2 100.00 Using where; Start temporary +1 SIMPLE alias2 NULL ref col_varchar_key col_varchar_key 7 test.alias3.col_varchar_key 2 100.00 Using index +1 SIMPLE t2 NULL ref col_int_key col_int_key 5 test.alias3.pk 2 100.00 Using index +1 SIMPLE sq2_alias2 NULL index NULL PRIMARY 4 NULL 2 100.00 Using index; Using join buffer (hash join) +1 SIMPLE sq1_alias1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +1 SIMPLE alias1 NULL index NULL col_varchar_key 12 NULL 2 100.00 Using index; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select sum(`test`.`alias1`.`col_varchar_key`) AS `field1` from `test`.`t2` `alias2` join `test`.`t1` `alias3` left join (`test`.`t1` `alias1` semi join (`test`.`t1` `sq1_alias1`)) on(((`test`.`sq1_alias1`.`col_varchar_nokey` = 'v'))) semi join (`test`.`t2` join `test`.`t1` `sq2_alias2`) where ((`test`.`alias2`.`col_varchar_key` = `test`.`alias3`.`col_varchar_key`) and (`test`.`t2`.`col_int_key` = `test`.`alias3`.`pk`)) +PREPARE prep_stmt_7430 FROM 'SELECT SUM( alias1.col_varchar_key ) AS field1 +FROM t1 AS alias1 +RIGHT JOIN t2 AS alias2 +INNER JOIN t1 AS alias3 +ON (alias3.col_varchar_key = alias2.col_varchar_key ) +ON ( "v" ) IN ( +SELECT sq1_alias1.col_varchar_nokey AS sq1_field1 +FROM t1 AS sq1_alias1 +) +WHERE alias3.pk IN ( +SELECT sq2_alias1.col_int_key AS sq2_field1 +FROM ( view_c AS sq2_alias1 , t1 AS sq2_alias2 ) +WHERE sq2_alias1.col_varchar_nokey <> alias2.col_varchar_key +AND sq2_alias1.col_varchar_key < "l" + ) +'; +EXECUTE prep_stmt_7430; +field1 +NULL +EXECUTE prep_stmt_7430; +field1 +NULL +EXPLAIN SELECT SUM( alias1.col_varchar_key ) AS field1 +FROM t1 AS alias1 +RIGHT JOIN t2 AS alias2 +INNER JOIN t1 AS alias3 +ON (alias3.col_varchar_key = alias2.col_varchar_key ) +ON ( "v" ) IN ( +SELECT sq1_alias1.col_varchar_nokey AS sq1_field1 +FROM t1 AS sq1_alias1 +) +WHERE alias3.pk IN ( +SELECT sq2_alias1.col_int_key AS sq2_field1 +FROM ( view_c AS sq2_alias1 , t1 AS sq2_alias2 ) +WHERE sq2_alias1.col_varchar_nokey <> alias2.col_varchar_key +AND sq2_alias1.col_varchar_key < "l" + ) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE alias3 NULL ALL PRIMARY,col_varchar_key NULL NULL NULL 2 100.00 Using where; Start temporary +1 SIMPLE t2 NULL ref col_int_key,col_varchar_key col_int_key 5 test.alias3.pk 2 40.00 Using where +1 SIMPLE alias2 NULL ref col_varchar_key col_varchar_key 7 test.alias3.col_varchar_key 2 100.00 Using index +1 SIMPLE sq2_alias2 NULL index NULL PRIMARY 4 NULL 2 100.00 Using index; Using join buffer (hash join) +1 SIMPLE sq1_alias1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +1 SIMPLE alias1 NULL index NULL col_varchar_key 12 NULL 2 100.00 Using index; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.alias2.col_varchar_key' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select sum(`test`.`alias1`.`col_varchar_key`) AS `field1` from `test`.`t2` `alias2` join `test`.`t1` `alias3` left join (`test`.`t1` `alias1` semi join (`test`.`t1` `sq1_alias1`)) on(((`test`.`sq1_alias1`.`col_varchar_nokey` = 'v'))) semi join (`test`.`t2` join `test`.`t1` `sq2_alias2`) where ((`test`.`alias2`.`col_varchar_key` = `test`.`alias3`.`col_varchar_key`) and (`test`.`t2`.`col_int_key` = `test`.`alias3`.`pk`) and (`test`.`t2`.`col_varchar_nokey` <> `test`.`alias3`.`col_varchar_key`) and (`test`.`t2`.`col_varchar_key` < 'l')) +DROP TABLE t1,t2; +DROP VIEW view_c; +# +# Bug#13902463 SEGFAULT IN BITMAP<64U>::MERGE OR ADD_KEY_FIELD +# ON SECOND EXEC OF PREP STMT +# +CREATE TABLE t1 ( +pk INT, +col_int_nokey INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +KEY col_varchar_key (col_varchar_key) +); +CREATE VIEW view_b AS SELECT * FROM t1; +PREPARE prep_stmt_20421 FROM 'SELECT alias2.col_varchar_nokey AS field1 +FROM t1 AS alias1 +INNER JOIN t1 AS alias2 +ON (alias1.col_varchar_key = alias2.col_varchar_nokey +AND ( alias1.col_int_key ) IN ( +SELECT t1.col_int_nokey +FROM t1 +) +) +WHERE alias1.col_varchar_key IN ( +SELECT sq2_alias2.col_varchar_nokey AS sq2_field1 +FROM view_b AS sq2_alias1 +INNER JOIN t1 AS sq2_alias2 +ON (sq2_alias2.col_varchar_key = sq2_alias1.col_varchar_key ) +WHERE sq2_alias1.pk > alias2.pk +) +'; +EXECUTE prep_stmt_20421; +field1 +EXECUTE prep_stmt_20421; +field1 +EXPLAIN SELECT alias2.col_varchar_nokey AS field1 +FROM t1 AS alias1 +INNER JOIN t1 AS alias2 +ON (alias1.col_varchar_key = alias2.col_varchar_nokey +AND ( alias1.col_int_key ) IN ( +SELECT t1.col_int_nokey +FROM t1 +) +) +WHERE alias1.col_varchar_key IN ( +SELECT sq2_alias2.col_varchar_nokey AS sq2_field1 +FROM view_b AS sq2_alias1 +INNER JOIN t1 AS sq2_alias2 +ON (sq2_alias2.col_varchar_key = sq2_alias1.col_varchar_key ) +WHERE sq2_alias1.pk > alias2.pk +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.alias2.pk' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `field1` from `test`.`t1` `alias1` join `test`.`t1` `alias2` semi join (`test`.`t1`) semi join (`test`.`t1` join `test`.`t1` `sq2_alias2`) where ((`test`.`t1`.`pk` > NULL) and multiple equal(NULL, `test`.`sq2_alias2`.`col_varchar_nokey`, NULL) and multiple equal(`test`.`sq2_alias2`.`col_varchar_key`, `test`.`t1`.`col_varchar_key`) and multiple equal(NULL, `test`.`t1`.`col_int_nokey`)) +ALTER TABLE t1 DROP INDEX col_varchar_key; +PREPARE prep_stmt_20421 FROM 'SELECT alias2.col_varchar_nokey AS field1 +FROM t1 AS alias1 +INNER JOIN t1 AS alias2 +ON (alias1.col_varchar_key = alias2.col_varchar_nokey +AND ( alias1.col_int_key ) IN ( +SELECT t1.col_int_nokey +FROM t1 +) +) +WHERE alias1.col_varchar_key IN ( +SELECT sq2_alias2.col_varchar_nokey AS sq2_field1 +FROM view_b AS sq2_alias1 +INNER JOIN t1 AS sq2_alias2 +ON (sq2_alias2.col_varchar_key = sq2_alias1.col_varchar_key ) +WHERE sq2_alias1.pk > alias2.pk +) +'; +EXECUTE prep_stmt_20421; +field1 +EXECUTE prep_stmt_20421; +field1 +EXPLAIN SELECT alias2.col_varchar_nokey AS field1 +FROM t1 AS alias1 +INNER JOIN t1 AS alias2 +ON (alias1.col_varchar_key = alias2.col_varchar_nokey +AND ( alias1.col_int_key ) IN ( +SELECT t1.col_int_nokey +FROM t1 +) +) +WHERE alias1.col_varchar_key IN ( +SELECT sq2_alias2.col_varchar_nokey AS sq2_field1 +FROM view_b AS sq2_alias1 +INNER JOIN t1 AS sq2_alias2 +ON (sq2_alias2.col_varchar_key = sq2_alias1.col_varchar_key ) +WHERE sq2_alias1.pk > alias2.pk +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.alias2.pk' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `field1` from `test`.`t1` `alias1` join `test`.`t1` `alias2` semi join (`test`.`t1`) semi join (`test`.`t1` join `test`.`t1` `sq2_alias2`) where ((`test`.`t1`.`pk` > NULL) and multiple equal(NULL, `test`.`sq2_alias2`.`col_varchar_nokey`, NULL) and multiple equal(`test`.`sq2_alias2`.`col_varchar_key`, `test`.`t1`.`col_varchar_key`) and multiple equal(NULL, `test`.`t1`.`col_int_nokey`)) +DROP TABLE t1; +DROP VIEW view_b; +# +# Bug#13907277: Segfault in evaluate_null_complemented_join_record +# +CREATE TABLE t1 ( +pk INTEGER, +col_varchar_nokey VARCHAR(1), +col_varchar_key VARCHAR(1), +PRIMARY KEY (pk) +); +INSERT INTO t1 VALUES (1, 'x', 'x'); +CREATE TABLE t2 ( +pk INTEGER, +PRIMARY KEY (pk) +); +INSERT INTO t2 VALUES (1); +CREATE TABLE t3 ( +pk INTEGER, +col_int_nokey INTEGER, +col_int_key INTEGER, +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk) +); +INSERT INTO t3 VALUES (1, 6, 5, 'r'); +explain SELECT outer_t1.pk, outer_t2.pk +FROM t3 AS outer_t1 +RIGHT JOIN t2 AS outer_t2 +ON outer_t1.col_int_nokey IN +(SELECT inner_t1.col_int_nokey +FROM t3 AS inner_t1 +LEFT JOIN t1 AS inner_t2 +INNER JOIN t1 AS inner_t3 +ON inner_t3.pk = inner_t2.pk +ON inner_t3.col_varchar_nokey = inner_t2.col_varchar_key +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE outer_t2 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE outer_t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE inner_t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE inner_t2 NULL ALL PRIMARY NULL NULL NULL 1 100.00 NULL +1 SIMPLE inner_t3 NULL eq_ref PRIMARY PRIMARY 4 test.inner_t2.pk 1 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`outer_t1`.`pk` AS `pk`,'1' AS `pk` from left join (`test`.`t3` `outer_t1` semi join (`test`.`t3` `inner_t1` left join (`test`.`t1` `inner_t2` join `test`.`t1` `inner_t3`) on(((`test`.`inner_t3`.`col_varchar_nokey` = `test`.`inner_t2`.`col_varchar_key`) and (`test`.`inner_t3`.`pk` = `test`.`inner_t2`.`pk`))))) on(((`test`.`inner_t1`.`col_int_nokey` = `test`.`outer_t1`.`col_int_nokey`))) where true +SELECT outer_t1.pk, outer_t2.pk +FROM t3 AS outer_t1 +RIGHT JOIN t2 AS outer_t2 +ON outer_t1.col_int_nokey IN +(SELECT inner_t1.col_int_nokey +FROM t3 AS inner_t1 +LEFT JOIN t1 AS inner_t2 +INNER JOIN t1 AS inner_t3 +ON inner_t3.pk = inner_t2.pk +ON inner_t3.col_varchar_nokey = inner_t2.col_varchar_key +); +pk pk +1 1 +DROP TABLE t1, t2, t3; +# End of test for bug#13907277. +# +# Bug#13955713: Assert 'JOIN->best_read < ...' on second execution +# +CREATE TABLE t1 ( +pk INTEGER, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1) +); +PREPARE stmt FROM " +SELECT MIN(alias2.col_varchar_key) AS field1 +FROM t1 AS alias1 + INNER JOIN (t1 AS alias2 + INNER JOIN t1 AS alias3 + ON 8 IN + (SELECT sq1_alias1.pk AS sq1_field2 + FROM t1 AS sq1_alias1 + WHERE 9 IN + (SELECT SUM(t1_sq1_alias1.pk) AS t1_sq1_field2 + FROM t1 AS t1_sq1_alias1 + ) + ) + ) + ON alias3.col_varchar_nokey = alias2.col_varchar_key +WHERE EXISTS + (SELECT sq2_alias1.pk AS sq2_field1 + FROM t1 AS sq2_alias1 + WHERE sq2_alias1.col_varchar_key < alias1.col_varchar_nokey + ) +"; +EXECUTE stmt; +field1 +NULL + +EXECUTE stmt; +field1 +NULL +DEALLOCATE PREPARE stmt; +DROP TABLE t1; +# End of test for bug#13955713. +# +# Bug#13956813: Segfault in memcpy from Join_cache::write_record_data() +# +CREATE TABLE t1 ( +pk INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1) +) charset latin1; +CREATE TABLE t2 ( +pk INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1) +) charset latin1; +INSERT INTO t2 VALUES +(10,'j','j'), (11,'z','z'), (12,'c','c'), (13,'a','a'), +(14,'q','q'), (15,'y','y'), (16,NULL,NULL), (17,'r','r'), +(18,'v','v'), (19,NULL,NULL), (20,'r','r'); +CREATE TABLE t3 ( +pk INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +KEY col_int_key (col_int_key) +) charset latin1; +INSERT INTO t3 VALUES +(15,NULL,'u'), (16,1,'m'), (17,9,NULL), (18,2,'o'), +(19,9,'w'), (20,2,'m'), (21,4,'q'), (22,0,NULL), +(23,4,'d'), (24,8,'g'), (25,NULL,'x'), (26,NULL,'f'), +(27,0,'p'), (28,NULL,'j'), (29,8,'c'); +CREATE VIEW view_inline_0 AS +SELECT t1.* +FROM t1 INNER JOIN t3 +ON t1.pk = t3.pk; +CREATE VIEW view_inline_1 AS +SELECT sq2_alias2.col_varchar_key AS sq2_field1, +sq2_alias1.col_varchar_key AS sq2_field2 +FROM t3 AS sq2_alias1 LEFT OUTER JOIN t3 AS sq2_alias2 +ON sq2_alias1.pk = sq2_alias2.col_int_key; +CREATE VIEW view_inline_2 AS +SELECT 'p', 'p' UNION SELECT 'k', 's'; +SET @optimizer_switch_saved= @@optimizer_switch; +SET @@optimizer_switch="derived_merge=off"; +explain SELECT SUM(alias1.col_varchar_nokey) AS field2 +FROM t2 AS alias2 +LEFT JOIN (SELECT * FROM view_inline_0) AS alias1 +ON alias2.col_varchar_key = alias1.col_varchar_key AND +(alias2.col_varchar_nokey, alias2.col_varchar_key) IN +(SELECT * FROM view_inline_1 +) +WHERE (alias1.col_varchar_key, alias1.col_varchar_nokey) IN +(SELECT * FROM view_inline_2 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL 2 100.00 NULL +1 PRIMARY alias2 NULL ALL NULL NULL NULL NULL 11 10.00 Using where; Using join buffer (hash join) +1 PRIMARY NULL ref 8 test.alias2.col_varchar_nokey,test.view_inline_2.p 3 100.00 Using index; Start temporary; End temporary +1 PRIMARY NULL ref 8 test.view_inline_2.p,test.view_inline_2.Name_exp_p 2 100.00 NULL +7 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +8 UNION NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +NULL UNION RESULT NULL ALL NULL NULL NULL NULL NULL NULL Using temporary +6 DERIVED sq2_alias1 NULL ALL NULL NULL NULL NULL 15 100.00 NULL +6 DERIVED sq2_alias2 NULL ref col_int_key col_int_key 5 test.sq2_alias1.pk 2 100.00 NULL +2 DERIVED NULL ALL NULL NULL NULL NULL 15 100.00 NULL +5 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select sum(`alias1`.`col_varchar_nokey`) AS `field2` from `test`.`view_inline_2` join `test`.`t2` `alias2` join (/* select#2 */ select `test`.`view_inline_0`.`pk` AS `pk`,`test`.`view_inline_0`.`col_varchar_key` AS `col_varchar_key`,`test`.`view_inline_0`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`view_inline_0`) `alias1` semi join (`test`.`view_inline_1`) where ((`test`.`view_inline_1`.`sq2_field1` = `test`.`alias2`.`col_varchar_nokey`) and (`alias1`.`col_varchar_nokey` = `test`.`view_inline_2`.`Name_exp_p`) and (`test`.`alias2`.`col_varchar_key` = `test`.`view_inline_2`.`p`) and (`test`.`view_inline_1`.`sq2_field2` = `test`.`view_inline_2`.`p`) and (`alias1`.`col_varchar_key` = `test`.`view_inline_2`.`p`)) +SELECT SUM(alias1.col_varchar_nokey) AS field2 +FROM t2 AS alias2 +LEFT JOIN (SELECT * FROM view_inline_0) AS alias1 +ON alias2.col_varchar_key = alias1.col_varchar_key AND +(alias2.col_varchar_nokey, alias2.col_varchar_key) IN +(SELECT * FROM view_inline_1 +) +WHERE (alias1.col_varchar_key, alias1.col_varchar_nokey) IN +(SELECT * FROM view_inline_2 +); +field2 +NULL +SET @@optimizer_switch= @optimizer_switch_saved; +DROP VIEW view_inline_0, view_inline_1, view_inline_2; +DROP TABLE t1, t2, t3; +# End of test for bug#13956813. +# +# Bug#13974177: Assert !(tab->table->regginfo.not_exists_optimize... +# +CREATE TABLE t1 ( +pk INTEGER AUTO_INCREMENT, +col_int_nokey INTEGER, +col_int_key INTEGER, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk), +KEY (col_int_key), +KEY (col_varchar_key, col_int_key) +); +INSERT INTO t1(col_int_key, col_int_nokey, col_varchar_key, col_varchar_nokey) +VALUES +(0, 4, 'j', 'j'), (8, 6, 'v', 'v'), (1, 3, 'c', 'c'), (8, 5, 'm', 'm'), +(9, 3, 'd', 'd'), (24, 246, 'd', 'd'), (6, 2, 'y', 'y'), (1, 9, 't', 't'), +(6, 3, 'd', 'd'), (2, 8, 's', 's'), (4, 1, 'r', 'r'), (8, 8, 'm', 'm'), +(4, 8, 'b', 'b'), (4, 5, 'x', 'x'), (7, 7, 'g', 'g'), (4, 5, 'p', 'p'), +(1, 1, 'q', 'q'), (9, 6, 'w', 'w'), (4, 2, 'd', 'd'), (8, 9, 'e', 'e'); +CREATE TABLE t2 ( +pk INTEGER AUTO_INCREMENT, +col_int_nokey INTEGER NOT NULL, +col_time_key TIME NOT NULL, +col_time_nokey TIME NOT NULL, +PRIMARY KEY (pk), +KEY (col_time_key) +) ENGINE=InnoDB; +INSERT INTO t2 (col_int_nokey, col_time_key, col_time_nokey) VALUES +(7, '00:00:00', '00:00:00'), (0, '00:00:00', '00:00:00'), +(9, '06:35:17', '06:35:17'), (3, '18:07:14', '18:07:14'), +(4, '20:36:52', '20:36:52'), (2, '21:29:07', '21:29:07'), +(5, '23:45:57', '23:45:57'), (3, '22:54:57', '22:54:57'), +(1, '18:45:09', '18:45:09'), (3, '14:30:46', '14:30:46'), +(6, '19:23:43', '19:23:43'), (7, '03:39:30', '03:39:30'), +(5, '23:37:52', '23:37:52'), (1, '16:59:30', '16:59:30'), +(204, '22:21:15', '22:21:15'), (224, '12:24:37', '12:24:37'), +(9, '15:02:08', '15:02:08'), (5, '23:59:59', '23:59:59'), +(0, '08:23:30', '08:23:30'), (3, '08:32:22', '08:32:22'); +explain SELECT ot1.col_int_key AS x +FROM t1 AS ot2 +LEFT JOIN t1 AS ot1 +ON ot2.col_varchar_nokey > ot1.col_varchar_key +WHERE (ot1.col_int_nokey, ot1.pk) IN +(SELECT it1.pk AS x, +it1.col_int_nokey AS y +FROM t2 AS it2 +LEFT JOIN t2 AS it1 +ON it2.col_time_nokey = it1.col_time_key +) AND ot1.pk IS NULL +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`col_int_key` AS `x` from `test`.`t2` `it1` join `test`.`t1` `ot2` join `test`.`t1` `ot1` semi join (`test`.`t2` `it2`) where ((`test`.`ot1`.`pk` is null) and (`test`.`ot2`.`col_varchar_nokey` > `test`.`ot1`.`col_varchar_key`) and multiple equal(`test`.`ot1`.`col_int_nokey`, `test`.`it1`.`pk`) and multiple equal(`test`.`ot1`.`pk`, `test`.`it1`.`col_int_nokey`) and multiple equal(`test`.`it2`.`col_time_nokey`, `test`.`it1`.`col_time_key`)) +SELECT ot1.col_int_key AS x +FROM t1 AS ot2 +LEFT JOIN t1 AS ot1 +ON ot2.col_varchar_nokey > ot1.col_varchar_key +WHERE (ot1.col_int_nokey, ot1.pk) IN +(SELECT it1.pk AS x, +it1.col_int_nokey AS y +FROM t2 AS it2 +LEFT JOIN t2 AS it1 +ON it2.col_time_nokey = it1.col_time_key +) AND ot1.pk IS NULL +; +x +DROP TABLE t1, t2; +# End of test for bug#13974177. +# +# Bug#13971022: Assert 'keyparts > 0' failed in create_ref_for_key... +# +CREATE TABLE t1 ( +pk INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +PRIMARY KEY (pk), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +CREATE TABLE t2 ( +pk INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk) +) charset utf8mb4 ENGINE=InnoDB; +CREATE TABLE t3 ( +i INT +); +SET @optimizer_switch_saved= @@optimizer_switch; +SET @@optimizer_switch="derived_merge=off"; +explain SELECT table1.pk AS field1 +FROM ( SELECT subquery1_t1. * +FROM t2 AS subquery1_t1 +JOIN t2 AS subquery1_t2 +ON subquery1_t2.pk = subquery1_t1.pk) AS table1 +STRAIGHT_JOIN t2 AS table2 +ON table1.col_int_key IN (SELECT 7 FROM t3) +WHERE table1.col_varchar_nokey IN +(SELECT subquery3_t1.col_varchar_key AS subquery3_field1 +FROM t1 AS subquery3_t1 +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY subquery3_t1 NULL index col_varchar_key col_varchar_key 12 NULL 0 0.00 Using where; Using index; Start temporary +1 PRIMARY NULL ref 7 test.subquery3_t1.col_varchar_key 2 100.00 NULL +1 PRIMARY table2 NULL index NULL PRIMARY 4 NULL 1 100.00 Using index; Using join buffer (hash join) +1 PRIMARY t3 NULL ALL NULL NULL NULL NULL 0 0.00 End temporary; Using join buffer (hash join) +2 DERIVED subquery1_t1 NULL ALL PRIMARY NULL NULL NULL 1 100.00 Using where +2 DERIVED subquery1_t2 NULL eq_ref PRIMARY PRIMARY 4 test.subquery1_t1.pk 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `table1`.`pk` AS `field1` from (/* select#2 */ select `test`.`subquery1_t1`.`pk` AS `pk`,`test`.`subquery1_t1`.`col_int_key` AS `col_int_key`,`test`.`subquery1_t1`.`col_varchar_key` AS `col_varchar_key`,`test`.`subquery1_t1`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t2` `subquery1_t1` join `test`.`t2` `subquery1_t2` where ((`test`.`subquery1_t1`.`col_int_key` = 7) and (`test`.`subquery1_t2`.`pk` = `test`.`subquery1_t1`.`pk`))) `table1` straight_join `test`.`t2` `table2` semi join (`test`.`t3`) semi join (`test`.`t1` `subquery3_t1`) where (`table1`.`col_varchar_nokey` = `test`.`subquery3_t1`.`col_varchar_key`) +SELECT table1.pk AS field1 +FROM ( SELECT subquery1_t1. * +FROM t2 AS subquery1_t1 +JOIN t2 AS subquery1_t2 +ON subquery1_t2.pk = subquery1_t1.pk) AS table1 +STRAIGHT_JOIN t2 AS table2 +ON table1.col_int_key IN (SELECT 7 FROM t3) +WHERE table1.col_varchar_nokey IN +(SELECT subquery3_t1.col_varchar_key AS subquery3_field1 +FROM t1 AS subquery3_t1 +) +; +field1 +SET @@optimizer_switch= @optimizer_switch_saved; +DROP TABLE t1, t2, t3; +# End of test for bug#13971022. +# +# Bug#13623473 "MISSING ROWS ON SELECT AND JOIN WITH +# TIME/DATETIME COMPARE" - Subquery part of test. +# +SET TIMESTAMP=UNIX_TIMESTAMP('2012-01-31 10:14:35'); +CREATE TABLE t1 ( +pk INT NOT NULL, +col_int_nokey INT, +col_int_key INT NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +) ENGINE=InnoDB; +INSERT INTO t1 VALUES (10,1,7), (11,7,0), (12,4,9), (13,7,3), +(14,0,4), (15,2,2), (16,9,5), (17,4,3), (18,0,1), (19,9,3), (20,1,6), +(21,3,7), (22,8,5), (23,8,1), (24,18,204), (25,84,224), (26,6,9), +(27,3,5), (28,6,0), (29,6,3); +CREATE TABLE t2 ( +col_int_nokey INT NOT NULL, +col_datetime_key DATETIME NOT NULL, +col_varchar_key VARCHAR(1) NOT NULL, +KEY col_datetime_key (col_datetime_key), +KEY col_varchar_key (col_varchar_key) +) ENGINE=InnoDB; +INSERT INTO t2 VALUES (1,'2001-11-04 19:07:55','k'); +CREATE TABLE t3 ( +col_time_key TIME, +KEY col_time_key (col_time_key) +) ENGINE=InnoDB; +INSERT INTO t3 VALUES ('21:22:34'), ('10:50:38'), ('00:21:38'), +('04:08:02'), ('16:25:11'), ('10:14:58'), ('19:47:59'), ('11:14:24'), +('00:00:00'), ('00:00:00'), ('15:57:25'), ('07:05:51'), ('19:22:21'), +('03:53:16'), ('09:16:38'), ('15:37:26'), ('00:00:00'), ('05:03:03'), +('02:59:24'), ('00:01:58'); +EXPLAIN SELECT outr.col_int_nokey +FROM t2 as outr +STRAIGHT_JOIN t3 AS outr2 +ON outr2.col_time_key > outr.col_datetime_key +WHERE outr.col_int_nokey IN ( +SELECT col_int_key +FROM t1 AS innr +WHERE innr.pk >= innr.col_int_nokey +) AND ( +outr.col_int_nokey <= 6 +OR +outr.col_varchar_key IS NULL +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE outr NULL ALL col_datetime_key NULL NULL NULL 1 100.00 Using where +2 SIMPLE innr NULL ref col_int_key col_int_key 4 test.outr.col_int_nokey 1 33.33 Using where; Start temporary; End temporary +2 SIMPLE outr2 NULL index col_time_key col_time_key 4 NULL 20 33.33 Using where; Using index; Using join buffer (hash join) +Warnings: +Warning 1739 Cannot use range access on index 'col_time_key' due to type or collation conversion on field 'col_time_key' +Note 1003 /* select#1 */ select `test`.`outr`.`col_int_nokey` AS `col_int_nokey` from `test`.`t2` `outr` straight_join `test`.`t3` `outr2` semi join (`test`.`t1` `innr`) where ((`test`.`innr`.`col_int_key` = `test`.`outr`.`col_int_nokey`) and (`test`.`outr`.`col_int_nokey` <= 6) and (`test`.`innr`.`pk` >= `test`.`innr`.`col_int_nokey`) and (cast(`test`.`outr2`.`col_time_key` as datetime) > `test`.`outr`.`col_datetime_key`)) +SELECT outr.col_int_nokey +FROM t2 as outr +STRAIGHT_JOIN t3 AS outr2 +ON outr2.col_time_key > outr.col_datetime_key +WHERE outr.col_int_nokey IN ( +SELECT col_int_key +FROM t1 AS innr +WHERE innr.pk >= innr.col_int_nokey +) AND ( +outr.col_int_nokey <= 6 +OR +outr.col_varchar_key IS NULL +); +col_int_nokey +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +DROP TABLE t1,t2,t3; +SET TIMESTAMP = DEFAULT; +# End of test for bug#13623473. +# +# Bug#13980954: Missing data on left join + null value + where..in +# +CREATE TABLE t1 ( +ik INT, +vc varchar(1) +) charset utf8mb4; +INSERT INTO t1 VALUES (8, 'x'), (NULL, 'x'); +CREATE TABLE t2 ( +ik INT, +vc varchar(1) +) charset utf8mb4; +INSERT INTO t2 VALUES +(0, 'x'), (7, 'i'), (7, 'e'), (1, 'p'), (7, 's'), (1, 'j'); +explain format=json SELECT t2.vc, t2.ik AS t2_ik, t1.ik AS t1_ik +FROM t2 LEFT JOIN t1 ON t2.vc=t1.vc +WHERE t2.vc IN (SELECT vc FROM t2 AS t3); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "7.62" + }, + "nested_loop": [ + { + "duplicates_removal": { + "using_temporary_table": true, + "nested_loop": [ + { + "table": { + "table_name": "t3", + "access_type": "ALL", + "rows_examined_per_scan": 6, + "rows_produced_per_join": 6, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "0.60", + "prefix_cost": "1.11", + "data_read_per_join": "96" + }, + "used_columns": [ + "vc" + ] + } + }, + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 6, + "rows_produced_per_join": 1, + "filtered": "16.67", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "0.10", + "prefix_cost": "6.91", + "data_read_per_join": "16" + }, + "used_columns": [ + "ik", + "vc" + ], + "attached_condition": "(`test`.`t2`.`vc` = `test`.`t3`.`vc`)" + } + } + ] + } + }, + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 2, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.20", + "prefix_cost": "7.62", + "data_read_per_join": "32" + }, + "used_columns": [ + "ik", + "vc" + ], + "attached_condition": "(is_not_null_compl(t1), (`test`.`t1`.`vc` = `test`.`t3`.`vc`), true)" + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`vc` AS `vc`,`test`.`t2`.`ik` AS `t2_ik`,`test`.`t1`.`ik` AS `t1_ik` from `test`.`t2` left join `test`.`t1` on((`test`.`t1`.`vc` = `test`.`t3`.`vc`)) semi join (`test`.`t2` `t3`) where (`test`.`t2`.`vc` = `test`.`t3`.`vc`) +SELECT t2.vc, t2.ik AS t2_ik, t1.ik AS t1_ik +FROM t2 LEFT JOIN t1 ON t2.vc=t1.vc +WHERE t2.vc IN (SELECT vc FROM t2 AS t3); +vc t2_ik t1_ik +e 7 NULL +i 7 NULL +j 1 NULL +p 1 NULL +s 7 NULL +x 0 8 +x 0 NULL +DROP TABLE t1, t2; +# End of test for bug#13980954. +# +# Bug#14048292: Segfault in Item_field::result_type on 2nd execution +# of prep stmt with join of view +# +CREATE TABLE t1 ( +col_int INT +); +INSERT INTO t1 VALUES (0), (1); +CREATE VIEW view_t1 AS SELECT * FROM t1; +explain SELECT alias1.col_int +FROM t1 AS alias1 +LEFT JOIN view_t1 AS alias2 +ON alias1.col_int IN +(SELECT sq1_alias1.col_int +FROM t1 AS sq1_alias1 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE alias1 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE sq1_alias1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`alias1`.`col_int` AS `col_int` from `test`.`t1` `alias1` left join (`test`.`t1` semi join (`test`.`t1` `sq1_alias1`)) on(((`test`.`sq1_alias1`.`col_int` = `test`.`alias1`.`col_int`))) where true +PREPARE stmt FROM "SELECT alias1.col_int +FROM t1 AS alias1 +LEFT JOIN view_t1 AS alias2 +ON alias1.col_int IN +(SELECT sq1_alias1.col_int +FROM t1 AS sq1_alias1 +)"; +EXECUTE stmt; +col_int +0 +0 +1 +1 + +EXECUTE stmt; +col_int +0 +0 +1 +1 +DEALLOCATE PREPARE stmt; +DROP VIEW view_t1; +DROP TABLE t1; +# End of test for bug#14048292. +# +# Bug#14064201: Missing data on join of derived table + WHERE .. IN +# with two operands +# +CREATE TABLE t1 ( +col_varchar_nokey VARCHAR(1) +) charset utf8mb4; +INSERT INTO t1 VALUES +('v'), ('s'), ('l'), ('y'), ('c'), ('i'), ('h'), ('q'), ('a'), ('v'), +('u'), ('s'), ('y'), ('z'), ('h'), ('p'), ('e'), ('i'), ('y'), ('w'); +CREATE TABLE t2 ( +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +KEY col_varchar_key(col_varchar_key) +) charset utf8mb4; +INSERT INTO t2 VALUES +('j','j'), ('v','v'), ('c','c'), ('m','m'), ('d','d'), ('d','d'), ('y','y'); +SET @optimizer_switch_saved= @@optimizer_switch; +SET @@optimizer_switch="derived_merge=off"; +explain format=json SELECT * +FROM (SELECT * FROM t2) AS derived1 +LEFT JOIN t1 +USING (col_varchar_nokey) +WHERE (col_varchar_nokey, col_varchar_nokey) IN +(SELECT col_varchar_nokey, col_varchar_key +FROM t2 AS derived2 +); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "23.73" + }, + "nested_loop": [ + { + "duplicates_removal": { + "using_temporary_table": true, + "nested_loop": [ + { + "table": { + "table_name": "derived2", + "access_type": "ALL", + "possible_keys": [ + "col_varchar_key" + ], + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "0.70", + "prefix_cost": "1.21", + "data_read_per_join": "112" + }, + "used_columns": [ + "col_varchar_key", + "col_varchar_nokey" + ], + "attached_condition": "((`test`.`derived2`.`col_varchar_key` = `test`.`derived2`.`col_varchar_nokey`) and (`test`.`derived2`.`col_varchar_nokey` is not null))" + } + }, + { + "table": { + "table_name": "derived1", + "access_type": "ref", + "possible_keys": [ + "" + ], + "key": "", + "used_key_parts": [ + "col_varchar_nokey" + ], + "key_length": "7", + "ref": [ + "test.derived2.col_varchar_nokey" + ], + "rows_examined_per_scan": 2, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "3.50", + "eval_cost": "0.70", + "prefix_cost": "9.21", + "data_read_per_join": "112" + }, + "used_columns": [ + "col_varchar_key", + "col_varchar_nokey" + ], + "materialized_from_subquery": { + "using_temporary_table": true, + "dependent": false, + "cacheable": true, + "query_block": { + "select_id": 2, + "cost_info": { + "query_cost": "1.21" + }, + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "0.70", + "prefix_cost": "1.21", + "data_read_per_join": "112" + }, + "used_columns": [ + "col_varchar_key", + "col_varchar_nokey" + ] + } + } + } + } + } + ] + } + }, + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 140, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.52", + "eval_cost": "14.00", + "prefix_cost": "23.73", + "data_read_per_join": "1K" + }, + "used_columns": [ + "col_varchar_nokey" + ], + "attached_condition": "(is_not_null_compl(t1), (`test`.`t1`.`col_varchar_nokey` = `test`.`derived2`.`col_varchar_nokey`), true)" + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select `derived1`.`col_varchar_nokey` AS `col_varchar_nokey`,`derived1`.`col_varchar_key` AS `col_varchar_key` from (/* select#2 */ select `test`.`t2`.`col_varchar_key` AS `col_varchar_key`,`test`.`t2`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t2`) `derived1` left join `test`.`t1` on((`test`.`t1`.`col_varchar_nokey` = `test`.`derived2`.`col_varchar_nokey`)) semi join (`test`.`t2` `derived2`) where ((`test`.`derived2`.`col_varchar_key` = `test`.`derived2`.`col_varchar_nokey`) and (`derived1`.`col_varchar_nokey` = `test`.`derived2`.`col_varchar_nokey`)) +SELECT * +FROM (SELECT * FROM t2) AS derived1 +LEFT JOIN t1 +USING (col_varchar_nokey) +WHERE (col_varchar_nokey, col_varchar_nokey) IN +(SELECT col_varchar_nokey, col_varchar_key +FROM t2 AS derived2 +); +col_varchar_nokey col_varchar_key +c c +d d +d d +j j +m m +v v +v v +y y +y y +y y +SET @@optimizer_switch= @optimizer_switch_saved; +DROP TABLE t1, t2; +CREATE TABLE t1 ( +col_int_nokey int NOT NULL, +col_int_key int NOT NULL, +KEY col_int_key (col_int_key) +); +INSERT INTO t1 VALUES +(1,7), (7,0), (4,9), (7,3), (0,4), (2,2), (9,5), (4,3), (0,1), (9,3), +(1,6), (3,7), (8,5), (8,1), (18,204), (84,224), (6,9), (3,5), (6,0), (6,3); +CREATE TABLE t2 ( +col_int_nokey int NOT NULL, +col_int_key int NOT NULL, +KEY col_int_key (col_int_key) +); +INSERT INTO t2 VALUES +(4,0), (6,8), (3,1), (5,8), (3,9), (246,24), (2,6), (9,1), (3,6), (8,2), +(1,4), (8,8), (8,4), (5,4), (7,7), (5,4), (1,1), (6,9), (2,4), (9,8); +explain format=json SELECT grandparent1.* +FROM t1 AS grandparent1 +LEFT JOIN t1 USING (col_int_nokey) +WHERE (col_int_nokey, col_int_nokey) IN +(SELECT col_int_nokey, col_int_key +FROM t2 +); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "52.73" + }, + "nested_loop": [ + { + "duplicates_removal": { + "using_temporary_table": true, + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "possible_keys": [ + "col_int_key" + ], + "rows_examined_per_scan": 20, + "rows_produced_per_join": 20, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "2.00", + "prefix_cost": "2.51", + "data_read_per_join": "320" + }, + "used_columns": [ + "col_int_nokey", + "col_int_key" + ], + "attached_condition": "(`test`.`t2`.`col_int_key` = `test`.`t2`.`col_int_nokey`)" + } + }, + { + "table": { + "table_name": "grandparent1", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 2, + "filtered": "10.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "0.20", + "prefix_cost": "48.22", + "data_read_per_join": "32" + }, + "used_columns": [ + "col_int_nokey", + "col_int_key" + ], + "attached_condition": "(`test`.`grandparent1`.`col_int_nokey` = `test`.`t2`.`col_int_nokey`)" + } + } + ] + } + }, + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 40, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "4.00", + "prefix_cost": "52.73", + "data_read_per_join": "640" + }, + "used_columns": [ + "col_int_nokey" + ], + "attached_condition": "(is_not_null_compl(t1), (`test`.`t1`.`col_int_nokey` = `test`.`t2`.`col_int_nokey`), true)" + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`grandparent1`.`col_int_nokey` AS `col_int_nokey`,`test`.`grandparent1`.`col_int_key` AS `col_int_key` from `test`.`t1` `grandparent1` left join `test`.`t1` on((`test`.`t1`.`col_int_nokey` = `test`.`t2`.`col_int_nokey`)) semi join (`test`.`t2`) where ((`test`.`t2`.`col_int_key` = `test`.`t2`.`col_int_nokey`) and (`test`.`grandparent1`.`col_int_nokey` = `test`.`t2`.`col_int_nokey`)) +SELECT grandparent1.* +FROM t1 AS grandparent1 +LEFT JOIN t1 USING (col_int_nokey) +WHERE (col_int_nokey, col_int_nokey) IN +(SELECT col_int_nokey, col_int_key +FROM t2 +); +col_int_nokey col_int_key +1 6 +1 6 +1 7 +1 7 +7 0 +7 0 +7 3 +7 3 +8 1 +8 1 +8 5 +8 5 +DROP TABLE t1, t2; +CREATE TABLE t1 ( +pk int, +col_int_key int, +col_datetime_key datetime, +col_varchar_key varchar(1), +col_varchar_nokey varchar(1), +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_datetime_key (col_datetime_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4 engine=MyISAM; +INSERT INTO t1 VALUES +(10,7,'2004-06-06 04:22:12','v','v'), (11,0,'2005-11-13 01:12:31','s','s'), +(12,9,'2002-05-04 01:50:00','l','l'), (13,3,'2004-10-27 10:28:45','y','y'), +(14,4,'2006-07-22 05:24:23','c','c'), (15,2,'2002-05-16 21:34:03','i','i'), +(16,5,'2008-04-17 10:45:30','h','h'), (17,3,'2009-04-21 02:58:02','q','q'), +(18,1,'2008-01-11 11:01:51','a','a'), (19,3,'1900-01-01 00:00:00','v','v'), +(20,6,'2007-05-17 18:24:57','u','u'), (21,7,'2007-08-07 00:00:00','s','s'), +(22,5,'2001-08-28 00:00:00','y','y'), (23,1,'2004-04-16 00:27:28','z','z'), +(24,204,'2005-05-03 07:06:22','h','h'), (25,224,'2009-03-11 17:09:50','p','p'), +(26,9,'2007-12-08 01:54:28','e','e'), (27,5,'2009-07-28 18:19:54','i','i'), +(28,0,'2008-06-08 00:00:00','y','y'), (29,3,'2005-02-09 09:20:26','w','w'); +CREATE TABLE t2 ( +pk int, +col_int_key int, +col_datetime_key datetime, +col_varchar_key varchar(1), +col_varchar_nokey varchar(1), +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_datetime_key (col_datetime_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4 engine=MyISAM; +INSERT INTO t2 VALUES +(1,0,'2002-02-13 17:30:06','j','j'), (2,8,'2008-09-27 00:34:58','v','v'), +(3,1,'2007-05-28 00:00:00','c','c'), (4,8,'2009-07-25 09:21:20','m','m'), +(5,9,'2002-01-16 00:00:00','d','d'), (6,24,'2006-10-12 04:32:53','d','d'), +(7,6,'2001-02-15 03:08:38','y','y'), (8,1,'2004-10-02 20:31:15','t','t'), +(9,6,'2002-08-20 22:48:00','d','d'), (10,2,'1900-01-01 00:00:00','s','s'), +(11,4,'2005-08-15 00:00:00','r','r'), (12,8,'1900-01-01 00:00:00','m','m'), +(13,4,'2008-05-16 08:09:06','b','b'), (14,4,'2001-01-20 12:47:23','x','x'), +(15,7,'2008-07-02 00:00:00','g','g'), (16,4,'1900-01-01 00:00:00','p','p'), +(17,1,'2002-12-08 11:34:58','q','q'), (18,9,'1900-01-01 00:00:00','w','w'), +(19,4,'1900-01-01 00:00:00','d','d'), (20,8,'2002-08-25 20:35:06','e','e'); +SELECT alias1.col_datetime_key +FROM t2 AS alias1 +RIGHT JOIN t2 AS alias2 +JOIN t2 AS alias3 +ON alias3.pk = alias2.pk +ON alias3.col_varchar_nokey = alias2.col_varchar_key OR +alias2.col_varchar_nokey +WHERE (alias2.col_varchar_key, alias2.col_varchar_key) IN +(SELECT sq2_alias2.col_varchar_key, sq2_alias1.col_varchar_nokey +FROM t1 AS sq2_alias1, t1 AS sq2_alias2 +WHERE sq2_alias2.col_int_key < 2); +col_datetime_key +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +2001-01-20 12:47:23 +2001-01-20 12:47:23 +2001-02-15 03:08:38 +2001-02-15 03:08:38 +2002-01-16 00:00:00 +2002-01-16 00:00:00 +2002-02-13 17:30:06 +2002-02-13 17:30:06 +2002-08-20 22:48:00 +2002-08-20 22:48:00 +2002-08-25 20:35:06 +2002-08-25 20:35:06 +2002-12-08 11:34:58 +2002-12-08 11:34:58 +2004-10-02 20:31:15 +2004-10-02 20:31:15 +2005-08-15 00:00:00 +2005-08-15 00:00:00 +2006-10-12 04:32:53 +2006-10-12 04:32:53 +2007-05-28 00:00:00 +2007-05-28 00:00:00 +2008-05-16 08:09:06 +2008-05-16 08:09:06 +2008-07-02 00:00:00 +2008-07-02 00:00:00 +2008-09-27 00:34:58 +2008-09-27 00:34:58 +2009-07-25 09:21:20 +2009-07-25 09:21:20 +ALTER TABLE t1 DISABLE KEYS; +ALTER TABLE t2 DISABLE KEYS; +explain format=json SELECT alias1.col_datetime_key +FROM t2 AS alias1 +RIGHT JOIN t2 AS alias2 +JOIN t2 AS alias3 +ON alias3.pk = alias2.pk +ON alias3.col_varchar_nokey = alias2.col_varchar_key OR +alias2.col_varchar_nokey +WHERE (alias2.col_varchar_key, alias2.col_varchar_key) IN +(SELECT sq2_alias2.col_varchar_key, sq2_alias1.col_varchar_nokey +FROM t1 AS sq2_alias1, t1 AS sq2_alias2 +WHERE sq2_alias2.col_int_key < 2); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "52.68" + }, + "nested_loop": [ + { + "duplicates_removal": { + "using_temporary_table": true, + "nested_loop": [ + { + "table": { + "table_name": "sq2_alias2", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 6, + "filtered": "33.33", + "cost_info": { + "read_cost": "1.86", + "eval_cost": "0.67", + "prefix_cost": "2.53", + "data_read_per_join": "213" + }, + "used_columns": [ + "col_int_key", + "col_varchar_key" + ], + "attached_condition": "(`test`.`sq2_alias2`.`col_int_key` < 2)" + } + }, + { + "table": { + "table_name": "alias2", + "access_type": "ALL", + "possible_keys": [ + "PRIMARY" + ], + "rows_examined_per_scan": 20, + "rows_produced_per_join": 13, + "filtered": "10.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.53", + "eval_cost": "1.33", + "prefix_cost": "16.39", + "data_read_per_join": "426" + }, + "used_columns": [ + "pk", + "col_varchar_key", + "col_varchar_nokey" + ], + "attached_condition": "(`test`.`alias2`.`col_varchar_key` = `test`.`sq2_alias2`.`col_varchar_key`)" + } + }, + { + "table": { + "table_name": "sq2_alias1", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 2, + "filtered": "10.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.53", + "eval_cost": "0.20", + "prefix_cost": "47.45", + "data_read_per_join": "64" + }, + "used_columns": [ + "col_varchar_nokey" + ], + "attached_condition": "(`test`.`sq2_alias1`.`col_varchar_nokey` = `test`.`sq2_alias2`.`col_varchar_key`)" + } + } + ] + } + }, + { + "table": { + "table_name": "alias3", + "access_type": "eq_ref", + "possible_keys": [ + "PRIMARY" + ], + "key": "PRIMARY", + "used_key_parts": [ + "pk" + ], + "key_length": "4", + "ref": [ + "test.alias2.pk" + ], + "rows_examined_per_scan": 1, + "rows_produced_per_join": 2, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.20", + "prefix_cost": "48.15", + "data_read_per_join": "64" + }, + "used_columns": [ + "pk", + "col_varchar_nokey" + ] + } + }, + { + "table": { + "table_name": "alias1", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 40, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.53", + "eval_cost": "4.00", + "prefix_cost": "52.68", + "data_read_per_join": "1K" + }, + "used_columns": [ + "col_datetime_key" + ], + "attached_condition": "(is_not_null_compl(alias1), (((`test`.`alias2`.`col_varchar_key` = `test`.`sq2_alias2`.`col_varchar_key`) and (`test`.`sq2_alias1`.`col_varchar_nokey` = `test`.`sq2_alias2`.`col_varchar_key`) and (`test`.`alias3`.`col_varchar_nokey` = `test`.`sq2_alias2`.`col_varchar_key`)) or (0 <> `test`.`alias2`.`col_varchar_nokey`)), true)" + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`alias1`.`col_datetime_key` AS `col_datetime_key` from `test`.`t2` `alias2` join `test`.`t2` `alias3` left join `test`.`t2` `alias1` on((((`test`.`alias2`.`col_varchar_key` = `test`.`sq2_alias2`.`col_varchar_key`) and (`test`.`sq2_alias1`.`col_varchar_nokey` = `test`.`sq2_alias2`.`col_varchar_key`) and (`test`.`alias3`.`col_varchar_nokey` = `test`.`sq2_alias2`.`col_varchar_key`)) or (0 <> `test`.`alias2`.`col_varchar_nokey`))) semi join (`test`.`t1` `sq2_alias1` join `test`.`t1` `sq2_alias2`) where ((`test`.`alias3`.`pk` = `test`.`alias2`.`pk`) and (`test`.`alias2`.`col_varchar_key` = `test`.`sq2_alias2`.`col_varchar_key`) and (`test`.`sq2_alias1`.`col_varchar_nokey` = `test`.`sq2_alias2`.`col_varchar_key`) and (`test`.`sq2_alias2`.`col_int_key` < 2)) +SELECT alias1.col_datetime_key +FROM t2 AS alias1 +RIGHT JOIN t2 AS alias2 +JOIN t2 AS alias3 +ON alias3.pk = alias2.pk +ON alias3.col_varchar_nokey = alias2.col_varchar_key OR +alias2.col_varchar_nokey +WHERE (alias2.col_varchar_key, alias2.col_varchar_key) IN +(SELECT sq2_alias2.col_varchar_key, sq2_alias1.col_varchar_nokey +FROM t1 AS sq2_alias1, t1 AS sq2_alias2 +WHERE sq2_alias2.col_int_key < 2); +col_datetime_key +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +2001-01-20 12:47:23 +2001-01-20 12:47:23 +2001-02-15 03:08:38 +2001-02-15 03:08:38 +2002-01-16 00:00:00 +2002-01-16 00:00:00 +2002-02-13 17:30:06 +2002-02-13 17:30:06 +2002-08-20 22:48:00 +2002-08-20 22:48:00 +2002-08-25 20:35:06 +2002-08-25 20:35:06 +2002-12-08 11:34:58 +2002-12-08 11:34:58 +2004-10-02 20:31:15 +2004-10-02 20:31:15 +2005-08-15 00:00:00 +2005-08-15 00:00:00 +2006-10-12 04:32:53 +2006-10-12 04:32:53 +2007-05-28 00:00:00 +2007-05-28 00:00:00 +2008-05-16 08:09:06 +2008-05-16 08:09:06 +2008-07-02 00:00:00 +2008-07-02 00:00:00 +2008-09-27 00:34:58 +2008-09-27 00:34:58 +2009-07-25 09:21:20 +2009-07-25 09:21:20 +DROP TABLE t1, t2; +# End of test for bug#14064201. +# +# Bug#18223655:ASSERTION FAILED: (INT)IDX >= 0 +# && IDX < PARENT_JOIN->TABLES +# +CREATE TABLE b (d INT); +CREATE TABLE c (a INT, b INT,c INT,d BLOB NOT NULL); +SELECT(SELECT 1 +FROM b WHERE(SELECT 1 IN (SELECT 1 FROM b WHERE 1 NOT BETWEEN d AND 1) +FROM b) IN (SELECT d FROM c)) as cc FROM b; +cc +INSERT INTO b VALUE(1); +INSERT INTO c VALUES(1,2,3,'1'),(2,3,4,'1'),(3,4,5,'C'); +SELECT(SELECT d FROM b WHERE(SELECT d IN +(SELECT d FROM b WHERE 1 NOT BETWEEN d AND 1) FROM b) IN +(SELECT d FROM c)) as cc FROM c; +cc +1 +1 +1 +DROP TABLE b,c; +# +# Bug#18447874:WRONG RESULT COMING FROM SEMI-JOIN +# +CREATE TABLE b ( +d INT(11) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE c ( +d BLOB +) ; +CREATE TABLE d ( +b INT(11) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO b VALUES(1),(2),(4); +INSERT INTO c VALUES(1),(2),(3); +SELECT 1 FROM b WHERE (SELECT 1 FROM d ) IN (SELECT d FROM c) ; +1 +INSERT INTO d VALUES(2); +SELECT 1 FROM b WHERE (SELECT 1 FROM d ) IN (SELECT d FROM c) ; +1 +1 +1 +1 +DROP TABLE b,c,d; +# +# Bug#17292723:INCORRECT RESULT FOR (SELECT...) IN (SELECT...) STATEMENT +# +CREATE TABLE t1 ( +ID int(11) NOT NULL AUTO_INCREMENT, +id2 int(11) DEFAULT NULL, +id3 int(11) DEFAULT NULL, +id4 varchar(150) COLLATE utf8_spanish_ci NOT NULL, +id5 int(11) DEFAULT NULL, +PRIMARY KEY (ID), +KEY id2 (id2), +KEY id3 (id3), +KEY id5 (id5) +) ENGINE=InnoDB; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 3778 'utf8_spanish_ci' is a collation of the deprecated character set UTF8MB3. Please consider using UTF8MB4 with an appropriate collation instead. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES +(123,1,1,'1',NULL), +(124,1,1,'2',NULL), +(125,1,1,'4',NULL), +(126,1,1,'3',NULL), +(127,1,1,'6',NULL), +(128,1,1,'8',NULL); +CREATE TABLE t2 ( +id6 int(11) NOT NULL, +id7 int(11) NOT NULL, +PRIMARY KEY (id6,id7), +KEY id7 (id7) +) ENGINE=InnoDB; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (126,123),(130,123),(135,123); +SELECT ID +FROM t1 p0 +WHERE p0.id3=1 +AND ( (SELECT p1.id FROM t1 p1 WHERE p1.id=123) IN (SELECT p3.id FROM t2 +p2, t1 p3 WHERE p0.id=p2.id6 AND p2.id7=p3.id)); +ID +126 +DROP TABLE t1,t2; +set @@optimizer_switch=@old_opt_switch; +# End of 5.6 tests +# +# Bug#19336348 DEBUG CRASH AT SETUP_SEMIJOIN_DUPS_ELIMINATION IN SQL/SQL_SELECT.CC +# +CREATE TABLE t1 ( +col_varchar_nokey varchar(1) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t1 VALUES ('c'),(NULL),('x'); +CREATE TABLE t2 ( +pk int, +col_varchar_key varchar(1), +PRIMARY KEY (pk), +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t2 VALUES (10,'l'),(11,'p'); +ANALYZE TABLE t1,t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN SELECT 1 +FROM t1 AS outr +WHERE outr.col_varchar_nokey IN +( +SELECT innr.col_varchar_key +FROM t2 AS innr +WHERE innr.pk <= 7 +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE innr NULL index PRIMARY,col_varchar_key col_varchar_key 7 NULL 2 100.00 Using where; Using index; LooseScan +1 SIMPLE outr NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` `outr` semi join (`test`.`t2` `innr`) where ((`test`.`outr`.`col_varchar_nokey` = `test`.`innr`.`col_varchar_key`) and (`test`.`innr`.`pk` <= 7)) +SELECT 1 +FROM t1 AS outr +WHERE outr.col_varchar_nokey IN +( +SELECT innr.col_varchar_key +FROM t2 AS innr +WHERE innr.pk <= 7 +) +; +1 +DROP TABLE t1,t2; +# +# Bug#18174394 BLOBS: CRASH AFTER UNINITIALIZED VALUES IN ITEM_FIELD::STR_RESULT +# +CREATE TABLE t1(d BLOB, b BLOB); +INSERT INTO t1(d,b) VALUES ('aaaa',''),('bnbb',''); +SELECT 1 FROM t1 +WHERE (SELECT b FROM t1) IN (SELECT (d>=1) FROM t1); +ERROR 21000: Subquery returns more than 1 row +DROP TABLE t1; +# +# Bug#19779600: ASSERT FAILED IN REPLACE_SUBCONDITION WITH IN +# PREDICATE INSIDE IN PREDICATE +# +CREATE TABLE t(X INT) ENGINE=InnoDB; +INSERT INTO t VALUES (1); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +EXPLAIN SELECT 1 FROM t WHERE (1 IN (SELECT 1 FROM t)) IN (SELECT 1 FROM t); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 PRIMARY t NULL ALL NULL NULL NULL NULL 1 100.00 End temporary; Using join buffer (hash join) +2 SUBQUERY t NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t` semi join (`test`.`t`) where true +SELECT 1 FROM t WHERE (1 IN (SELECT 1 FROM t)) IN (SELECT 1 FROM t); +1 +1 +DROP TABLE t; +# +# Bug#19465034 ASSERT ON SETUP_SEMIJOIN_DUPS_ELIMINATION IN SQL/SQL_SELECT.CC +# +CREATE TABLE t1 ( +pk INTEGER NOT NULL, +i1 INTEGER NOT NULL, +PRIMARY KEY (pk) +) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1,1); +CREATE TABLE t2 ( +pk INTEGER NOT NULL, +c1 VARCHAR(1) NOT NULL, +PRIMARY KEY (pk), +KEY c1_key (c1) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t2 VALUES (1,'j'),(2,'v'),(3,'c'); +CREATE TABLE t3 ( +pk INTEGER NOT NULL, +c1 VARCHAR(1) NOT NULL, +PRIMARY KEY (pk), +KEY c1_key (c1) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t3 VALUES (10,'v'),(11,'s'); +ANALYZE TABLE t1, t2, t3; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +EXPLAIN SELECT * +FROM t1 JOIN t2 ON t1.i1 >= t2.pk +WHERE t2.c1 IN ( +SELECT t3.c1 +FROM t3 +WHERE t3.pk < 3 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t3 NULL index PRIMARY,c1_key c1_key 6 NULL 2 100.00 Using where; Using index; LooseScan +2 SIMPLE t2 NULL ref PRIMARY,c1_key c1_key 6 test.t3.c1 1 33.33 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`i1` AS `i1`,`test`.`t2`.`pk` AS `pk`,`test`.`t2`.`c1` AS `c1` from `test`.`t1` join `test`.`t2` semi join (`test`.`t3`) where ((`test`.`t2`.`c1` = `test`.`t3`.`c1`) and (`test`.`t3`.`pk` < 3) and (`test`.`t1`.`i1` >= `test`.`t2`.`pk`)) +SELECT * +FROM t1 JOIN t2 ON t1.i1 >= t2.pk +WHERE t2.c1 IN ( +SELECT t3.c1 +FROM t3 +WHERE t3.pk < 3 +); +pk i1 pk c1 +DROP TABLE t1,t2,t3; +# +# Bug#19586047: CRASH IN ARG_COMPARATOR::SET_CMP_FUNC +# +CREATE TABLE t1(x INT) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT 1 FROM t1 WHERE EXISTS(SELECT 1) IN (SELECT 1 FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 1 100.00 End temporary; Using join buffer (hash join) +2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` semi join (`test`.`t1`) where true +SELECT 1 FROM t1 WHERE EXISTS(SELECT 1) IN (SELECT 1 FROM t1); +1 +1 +EXPLAIN SELECT 1 FROM t1 WHERE (SELECT 1, 2 FROM t1) IN (SELECT 1, 2 FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 1 100.00 End temporary; Using join buffer (hash join) +2 SUBQUERY t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` semi join (`test`.`t1`) where true +SELECT 1 FROM t1 WHERE (SELECT 1, 2 FROM t1) IN (SELECT 1, 2 FROM t1); +1 +1 +EXPLAIN SELECT 1 FROM t1 WHERE +(SELECT 1, 2 FROM t1 WHERE x = 2) IN (SELECT 1, 2 FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +2 SUBQUERY t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` semi join (`test`.`t1`) where false +SELECT 1 FROM t1 WHERE +(SELECT 1, 2 FROM t1 WHERE x = 2) IN (SELECT 1, 2 FROM t1); +1 +DROP TABLE t1; +# +#Bug#20119743 ASSERTIONQEP_TAB->USE_ORDER() IN ENUM_NESTED_LOOP_STATE +# EVALUATE_JOIN_RECORD +# +CREATE TABLE t1 ( +pk int(11) NOT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +PRIMARY KEY (pk) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (1,'x'); +CREATE TABLE t2 ( +col_date_key date DEFAULT NULL, +col_int_key int(11) DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +KEY col_int_key (col_int_key), +KEY col_date_key (col_date_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES ('2000-12-03', 8, 'x', 'x'),('2008-05-03', 7, 'd', 'd'), +('2005-12-06', 1, 'r', 'r'),('2000-04-10', 7, 'f', 'f'), +('2002-11-05', 9, 'y', 'y'),('2000-09-06', NULL, 'u', 'u'), +(NULL, 1, 'm', 'm'),('2007-06-14', 9, NULL, NULL), +('2007-11-17', 2, 'o', 'o'),('2009-02-23', 9, 'w', 'w'), +('2007-01-08', 2, 'm', 'm'), ('2008-06-10', 4, 'q', 'q'), +('2002-10-20', 0, NULL, NULL),('2008-09-12', 4, 'd', 'd'), +('2006-06-16', 8, 'g', 'g'),('2004-09-18', NULL, 'x', 'x'), +('1900-01-01', NULL, 'f', 'f'),('2005-09-13', 0, 'p', 'p'), +('2007-04-09', NULL, 'j', 'j'),('2000-09-20', 8, 'c', 'c'); +CREATE TABLE t3 ( +pk int(11) NOT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +PRIMARY KEY (pk) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t3 VALUES (1, 'c'),(2, 'c'),(3, 'q'),(4, 'g'),(5, 'e'),(6, 'l'), +(7, NULL),(8, 'v'),(9, 'c'),(10, 'u'),(11, 'x'),(12, 'x'),(13, 'x'),(14, 'l'), +(15, 'e'),(16, 's'),(17, 'k'),(18, 'm'),(19, 'x'),(20, 's'); +ANALYZE TABLE t1,t2,t3; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +EXPLAIN SELECT r1.col_date_key +FROM t2 AS r1 +WHERE r1.col_int_key NOT IN +(SELECT ir2.pk +FROM t2 AS ir1 STRAIGHT_JOIN t1 AS ir2 +ON ir2.col_varchar_nokey = ir1.col_varchar_key +WHERE ir2.col_varchar_nokey > r1.col_varchar_nokey +AND ir2.pk IN +(SELECT iir2.pk +FROM t2 AS iir1 RIGHT JOIN t3 AS iir2 +ON iir2.col_varchar_nokey = iir1.col_varchar_key)) +ORDER BY r1.col_date_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY r1 NULL ALL NULL NULL NULL NULL 20 100.00 Using where; Using filesort +2 DEPENDENT SUBQUERY iir2 NULL eq_ref PRIMARY PRIMARY 4 func 1 100.00 Using where; Start temporary; Full scan on NULL key +2 DEPENDENT SUBQUERY iir1 NULL ref col_varchar_key col_varchar_key 7 test.iir2.col_varchar_nokey 1 100.00 Using index +2 DEPENDENT SUBQUERY ir1 NULL index col_varchar_key col_varchar_key 12 NULL 20 100.00 Using where; Using index; Using join buffer (hash join) +2 DEPENDENT SUBQUERY ir2 NULL eq_ref PRIMARY PRIMARY 4 func 1 100.00 Using where; End temporary; Full scan on NULL key +SELECT r1.col_date_key +FROM t2 AS r1 +WHERE r1.col_int_key NOT IN +(SELECT ir2.pk +FROM t2 AS ir1 STRAIGHT_JOIN t1 AS ir2 +ON ir2.col_varchar_nokey = ir1.col_varchar_key +WHERE ir2.col_varchar_nokey > r1.col_varchar_nokey +AND ir2.pk IN +(SELECT iir2.pk +FROM t2 AS iir1 RIGHT JOIN t3 AS iir2 +ON iir2.col_varchar_nokey = iir1.col_varchar_key)) +ORDER BY r1.col_date_key; +col_date_key +2000-04-10 +2000-09-20 +2000-12-03 +2002-10-20 +2002-11-05 +2004-09-18 +2005-09-13 +2006-06-16 +2007-01-08 +2007-06-14 +2007-11-17 +2008-05-03 +2008-06-10 +2008-09-12 +2009-02-23 +SELECT COUNT(r1.col_date_key) AS COUNT_NUM +FROM t2 AS r1 +WHERE r1.col_int_key NOT IN +(SELECT ir2.pk +FROM t2 AS ir1 STRAIGHT_JOIN t1 AS ir2 +ON ir2.col_varchar_nokey = ir1.col_varchar_key +WHERE ir2.col_varchar_nokey > r1.col_varchar_nokey +AND ir2.pk IN +(SELECT iir2.pk +FROM t2 AS iir1 RIGHT JOIN t3 AS iir2 +ON iir2.col_varchar_nokey = iir1.col_varchar_key +WHERE iir2.pk<3)); +COUNT_NUM +15 +DROP TABLE t1,t2,t3; +# +# Bug#20554585 ASSERT JOIN()->TABLES == 0... IN JOIN_TAB::GET_SJ_STRATEGY ON SUBQUERY + VAR +# +CREATE TABLE t1 ( +pk int NOT NULL, +PRIMARY KEY (pk) +); +CREATE TABLE t2 ( +pk int NOT NULL, +col_int_key int, +col_varchar_key varchar(1), +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key) +); +CREATE TABLE t3 ( +pk int NOT NULL, +col_int_key int, +col_varchar_key varchar(1), +col_varchar varchar(1), +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key) +); +INSERT INTO t3 VALUES (1,4,'c','g'),(20,1,'i','p'); +CREATE TABLE t4 ( +col_int int +); +CREATE TABLE t5 ( +col_varchar_key varchar(1), +pk int NOT NULL, +col_int int, +PRIMARY KEY (pk), +KEY col_varchar_key (col_varchar_key) +); +SELECT table1.col_varchar_key AS field1 +FROM (t3 AS table1 +INNER JOIN ( +SELECT SUBQUERY1_t1.* +FROM (t1 AS SUBQUERY1_t1 +RIGHT JOIN (t2 AS SUBQUERY1_t2 +INNER JOIN t3 AS SUBQUERY1_t3 +ON (SUBQUERY1_t3.col_varchar_key = SUBQUERY1_t2.col_varchar_key) +) ON (SUBQUERY1_t3.col_int_key = SUBQUERY1_t2.pk) +) +WHERE SUBQUERY1_t2.col_varchar_key >= ANY ( +SELECT CHILD_SUBQUERY1_t2.col_varchar AS CHILD_SUBQUERY1_field1 +FROM (t2 AS CHILD_SUBQUERY1_t1 +LEFT OUTER JOIN t3 AS CHILD_SUBQUERY1_t2 +ON (CHILD_SUBQUERY1_t2.col_int_key = CHILD_SUBQUERY1_t1.col_int_key) +) +WHERE CHILD_SUBQUERY1_t1.pk >= SUBQUERY1_t2.pk +) +) AS table2 +ON (table2.pk = table1.pk) +) +WHERE (EXISTS (( +SELECT DISTINCT SUBQUERY2_t2.col_int AS SUBQUERY2_field1 +FROM (t4 AS SUBQUERY2_t1 +LEFT OUTER JOIN t5 AS SUBQUERY2_t2 +ON (SUBQUERY2_t2.pk = SUBQUERY2_t1.col_int) +) +WHERE SUBQUERY2_t2.col_varchar_key != @var4 +))) +AND table1.col_int_key < (35 + 192) +ORDER BY field1 +; +field1 +DROP TABLE t1, t2, t3, t4, t5; +# +# Bug#18892055: MISSING DATA ON SELECT ... IN WITH JOINS AND INNODB +# ENGINE +# +CREATE TABLE t1 ( +col_int_key INT, +pk INT NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +) ENGINE = INNODB; +INSERT INTO t1 VALUES +( 0, 3 ), +( 0, 4 ), +( 3, 1 ), +( 900000000, 2 ), +( 1368719360, 5 ), +( 1922236416, 6 ), +( 8,7 ); +CREATE TABLE t2 ( +pk INT NOT NULL, +col_int INT, +PRIMARY KEY (pk) +) ENGINE = INNODB; +INSERT INTO t2 VALUES +( 1, 3 ), +( 2, 2 ), +( 3, 8 ), +( 4, 7 ); +CREATE TABLE t3 ( +col_int_key INT, +col_int INT, +KEY (col_int_key) +) ENGINE = INNODB; +INSERT INTO t3 VALUES +( 5, 1 ), +( -1, -1 ), +( 300000000, 1 ), +( 8, 1 ); +CREATE TABLE t4 ( col_int_key INT ) ENGINE = INNODB; +INSERT INTO t4 VALUES +(0), +(3), +(8), +(900000000), +(1368719360), +(1922236416); +ANALYZE TABLE t1, t2, t3, t4; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +test.t4 analyze status OK +explain SELECT * +FROM t4 +WHERE (col_int_key) IN ( +SELECT t1.col_int_key +FROM t1 LEFT JOIN ( t2 JOIN t3 ON t3.col_int_key = t2.col_int ) USING ( pk ) +WHERE t3.col_int IS NULL +) +ORDER BY col_int_key +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index col_int_key col_int_key 5 NULL 7 100.00 Using index; Using temporary; Using filesort; Start temporary +1 SIMPLE t4 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.pk 1 100.00 NULL +1 SIMPLE t3 NULL ALL col_int_key NULL NULL NULL 4 25.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`col_int_key` AS `col_int_key` from `test`.`t4` semi join (`test`.`t1` left join (`test`.`t2` join `test`.`t3`) on(((`test`.`t1`.`pk` = `test`.`t2`.`pk`) and (`test`.`t3`.`col_int_key` = `test`.`t2`.`col_int`)))) where ((`test`.`t4`.`col_int_key` = `test`.`t1`.`col_int_key`) and (`test`.`t3`.`col_int` is null)) order by `test`.`t4`.`col_int_key` +explain format=tree SELECT * +FROM t4 +WHERE (col_int_key) IN ( +SELECT t1.col_int_key +FROM t1 LEFT JOIN ( t2 JOIN t3 ON t3.col_int_key = t2.col_int ) USING ( pk ) +WHERE t3.col_int IS NULL +) +ORDER BY col_int_key +; +EXPLAIN +-> Sort: t4.col_int_key + -> Stream results (cost=7.85 rows=7) + -> Remove duplicate t4 rows using temporary table (weedout) (cost=7.85 rows=7) + -> Filter: (t3.col_int is null) (cost=7.85 rows=7) + -> Nested loop left join (cost=7.85 rows=7) + -> Inner hash join (t4.col_int_key = t1.col_int_key) (cost=5.40 rows=7) + -> Table scan on t4 (cost=0.05 rows=6) + -> Hash + -> Index scan on t1 using col_int_key (cost=0.95 rows=7) + -> Nested loop inner join (cost=1.21 rows=1) + -> Single-row index lookup on t2 using PRIMARY (pk=t1.pk) (cost=0.26 rows=1) + -> Filter: (t3.col_int_key = t2.col_int) (cost=0.65 rows=1) + -> Table scan on t3 (cost=0.65 rows=4) + +SELECT * +FROM t4 +WHERE (col_int_key) IN ( +SELECT t1.col_int_key +FROM t1 LEFT JOIN ( t2 JOIN t3 ON t3.col_int_key = t2.col_int ) USING ( pk ) +WHERE t3.col_int IS NULL +) +ORDER BY col_int_key +; +col_int_key +0 +3 +8 +900000000 +1368719360 +1922236416 +DROP TABLE t1, t2, t3, t4; +# +# Bug#20835095 CRASH AT CREATE_REF_FOR_KEY IN SQL/SQL_SELECT.CC +# +CREATE TABLE t1 ( +pk INTEGER, +var_10_latin1 VARCHAR(10) CHARACTER SET latin1, +var_255_utf8 VARCHAR(255) CHARACTER SET utf8, +var_255_latin1 VARCHAR(255) CHARACTER SET latin1, +var_10_utf8 VARCHAR(10) CHARACTER SET utf8, +PRIMARY KEY (pk) +); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +CREATE VIEW v1 AS SELECT * FROM t1; +INSERT INTO t1 VALUES +(1,'FROCJ','korrhrspki','UAYVL','BPZIS'), +(2,'him','a','CHYKN','OZZQT'), +(3,'WBITK','ULWBF','have','rhrh'), +(4,'or','right','up','it'), +(5,'GGDCP','x','who','as'), +(6,'j','i','e','w'); +CREATE TABLE tv +SELECT var_255_utf8 AS field1 +FROM t1; +EXPLAIN SELECT * FROM tv +WHERE field1 IN ( +SELECT tv1.var_255_utf8 +FROM v1 AS tv1 LEFT JOIN v1 AS tv2 ON tv1.var_10_latin1=tv2.var_10_utf8); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 6 100.00 Start temporary +1 SIMPLE tv NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 6 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`tv`.`field1` AS `field1` from `test`.`tv` semi join (`test`.`t1` left join (`test`.`t1`) on((`test`.`t1`.`var_10_latin1` = `test`.`t1`.`var_10_utf8`))) where (`test`.`tv`.`field1` = `test`.`t1`.`var_255_utf8`) +SELECT * FROM tv +WHERE field1 IN ( +SELECT tv1.var_255_utf8 +FROM v1 AS tv1 LEFT JOIN v1 AS tv2 ON tv1.var_10_latin1=tv2.var_10_utf8); +field1 +korrhrspki +a +ULWBF +right +x +i +DROP VIEW v1; +DROP TABLE t1, tv; +# 17832047 Crash in calculate_materialization_costs +CREATE TABLE t1(a INTEGER PRIMARY KEY); +INSERT INTO t1 VALUES (0),(1),(2); +SELECT 1 FROM t1 +WHERE 1 IN +(SELECT 1 BETWEEN (LENGTH(a) IN (SELECT 1 FROM t1)) AND 1 +FROM t1 +); +1 +1 +1 +1 +DROP TABLE t1; +# 17845989 Assertion failed: !(used_tables() & ... +CREATE TABLE a(b INTEGER) engine=innodb; +CREATE TABLE c(a INTEGER) engine=innodb; +SELECT 1 +FROM a +WHERE 1 IN (SELECT (a.b IS NULL) IN (SELECT 1 FROM c) FROM c) +; +1 +DROP TABLE a, c; +# +# Bug#18194196: OPTIMIZER EXECUTES STATEMENT INPERFORMANT +# +CREATE TABLE t1 (uid INTEGER, fid INTEGER, INDEX(uid)); +INSERT INTO t1 VALUES +(1,1), (1,2), (1,3), (1,4), +(2,5), (2,6), (2,7), (2,8), +(3,1), (3,2), (3,9); +CREATE TABLE t2 (uid INT PRIMARY KEY, name VARCHAR(128), INDEX(name)); +INSERT INTO t2 VALUES +(1, "A"), (2, "B"), (3, "C"), (4, "D"), (5, "E"), +(6, "F"), (7, "G"), (8, "H"), (9, "I"); +CREATE TABLE t3 (uid INT, fid INT, INDEX(uid)); +INSERT INTO t3 VALUES +(1,1), (1,2), (1,3),(1,4), +(2,5), (2,6), (2,7), (2,8), +(3,1), (3,2), (3,9); +CREATE TABLE t4 (uid INT PRIMARY KEY, name VARCHAR(128), INDEX(name)); +INSERT INTO t4 VALUES +(1, "A"), (2, "B"), (3, "C"), (4, "D"), (5, "E"), +(6, "F"), (7, "G"), (8, "H"), (9, "I"); +ANALYZE TABLE t1,t2,t3,t4; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +test.t4 analyze status OK +EXPLAIN SELECT name FROM t2, t1 +WHERE t1.uid IN (SELECT t4.uid FROM t4, t3 WHERE t3.uid=1 AND t4.uid=t3.fid) +AND t2.uid=t1.fid; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ref uid uid 5 const 4 100.00 Using where; Start temporary +1 SIMPLE t4 NULL eq_ref PRIMARY PRIMARY 4 test.t3.fid 1 100.00 Using index +1 SIMPLE t1 NULL ref uid uid 5 test.t3.fid 4 100.00 Using where; End temporary +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.fid 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`name` AS `name` from `test`.`t4` join `test`.`t2` join `test`.`t1` semi join (`test`.`t3`) where ((`test`.`t4`.`uid` = `test`.`t3`.`fid`) and (`test`.`t1`.`uid` = `test`.`t3`.`fid`) and (`test`.`t3`.`uid` = 1) and (`test`.`t2`.`uid` = `test`.`t1`.`fid`)) +FLUSH STATUS; +SELECT name FROM t2, t1 +WHERE t1.uid IN (SELECT t4.uid FROM t4, t3 WHERE t3.uid=1 AND t4.uid=t3.fid) +AND t2.uid=t1.fid; +name +A +A +B +B +C +D +E +F +G +H +I +SHOW STATUS LIKE '%handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 20 +Handler_read_last 0 +Handler_read_next 15 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +DROP TABLE t1,t2,t3,t4; +# End of test for Bug#18194196 +# +# Bug#21184091 ASSERT `READ_ROWS >= 0.0' AT +# COST_MODEL_SERVER::TMPTABLE_READWRITE_COST() +# +CREATE TABLE t1 ( +pk INTEGER, +col_varchar varchar(1), +col_int INTEGER, +PRIMARY KEY (pk) +) ENGINE=MyISAM; +CREATE TABLE t2 ( +col_int INTEGER, +col_varchar varchar(1) +) ENGINE=MyISAM; +INSERT INTO t2 VALUES (7,'x'); +INSERT INTO t2 VALUES (4,'z'); +SELECT t2.col_varchar +FROM t2 STRAIGHT_JOIN t1 ON t2.col_varchar = t1.col_varchar +JOIN t2 AS table3 ON t1.pk = table3.col_int +WHERE t1.pk IN (SELECT col_int FROM t1); +col_varchar +DROP TABLE t1,t2; +# End of test for Bug#21184091 +# Bug#21139722: Assertion failed: !(used_tables() & ((table_map) 1) ... +CREATE TABLE t1(a INTEGER) engine=innodb; +CREATE TABLE t2(b INTEGER) engine=innodb; +explain SELECT 1 +FROM (SELECT 1 IN (SELECT 1 +FROM t1 +WHERE (SELECT 1 FROM t2 HAVING b) NOT IN (SELECT 1 FROM t2) +) +FROM t2 +) AS z; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DERIVED t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +3 DEPENDENT SUBQUERY t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +5 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +4 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1276 Field or reference 'b' of SELECT #4 was resolved in SELECT #2 +Note 1003 /* select#1 */ select 1 AS `1` from (/* select#2 */ select (1,(/* select#3 */ select 1 from `test`.`t1` where ((/* select#4 */ select 1 from `test`.`t2` having (0 <> `test`.`t2`.`b`)),(/* select#5 */ select 1 from `test`.`t2` where (outer_field_is_not_null, (((/* select#4 */ select 1 from `test`.`t2` having (0 <> `test`.`t2`.`b`))) = 1), true)) is false))) AS `1 IN (SELECT 1 +FROM t1 +WHERE (SELECT 1 FROM t2 HAVING b) NOT IN (SELECT 1 FROM t2) +)` from `test`.`t2`) `z` +SELECT 1 +FROM (SELECT 1 IN (SELECT 1 +FROM t1 +WHERE (SELECT 1 FROM t2 HAVING b) NOT IN (SELECT 1 FROM t2) +) +FROM t2 +) AS z; +1 +DROP TABLE t1, t2; +CREATE TABLE t1(a INTEGER) engine=innodb; +explain SELECT (SELECT a FROM t1 AS t2 +WHERE a IN (SELECT t1.a+t2.a FROM t1 AS t3)) +FROM t1 AS t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +2 DEPENDENT SUBQUERY t3 NULL ALL NULL NULL NULL NULL 1 100.00 End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #3 was resolved in SELECT #1 +Note 1276 Field or reference 'test.t2.a' of SELECT #3 was resolved in SELECT #2 +Note 1003 /* select#1 */ select (/* select#2 */ select `test`.`t2`.`a` from `test`.`t1` `t2` semi join (`test`.`t1` `t3`) where (`test`.`t2`.`a` = (`test`.`t1`.`a` + `test`.`t2`.`a`))) AS `(SELECT a FROM t1 AS t2 +WHERE a IN (SELECT t1.a+t2.a FROM t1 AS t3))` from `test`.`t1` +SELECT (SELECT a FROM t1 AS t2 +WHERE a IN (SELECT t1.a+t2.a FROM t1 AS t3)) +FROM t1 AS t1; +(SELECT a FROM t1 AS t2 +WHERE a IN (SELECT t1.a+t2.a FROM t1 AS t3)) +DROP TABLE t1; +# End of test for Bug#21139722 +SET DEFAULT_STORAGE_ENGINE=INNODB; +# +# Bug#21139402 ASSERTION FAILED: LENGTH > 0 && KEYPARTS != 0, CRASH IN JOIN::OPTIMIZE_KEYUSE +# +CREATE TABLE t1 (a INT, b INT, PRIMARY KEY(a)); +CREATE TABLE t2 (c INT PRIMARY KEY); +EXPLAIN SELECT 1 FROM t1 +WHERE 1 IN +(SELECT (c IS NULL) IN (SELECT a FROM t1 WHERE b) FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +3 SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` semi join (`test`.`t2`) where false +SELECT 1 FROM t1 +WHERE 1 IN +(SELECT (c IS NULL) IN (SELECT a FROM t1 WHERE b) FROM t2); +1 +DROP TABLE t1,t2; +# +# Bug#21619634 ACCESS OF DEALLOCATED ITEM_OUTER_REF CAUSES CRASH: PREPARED STMT +# +create table cc (i int) engine="innodb"; +insert into cc values (1); +select (select count(i) from cc as cc_alias +where (cc.i in (select cc_alias.i from cc))) +from cc group by i; +(select count(i) from cc as cc_alias +where (cc.i in (select cc_alias.i from cc))) +1 +prepare stmt from +"select (select count(i) from cc as cc_alias + where (cc.i in (select cc_alias.i from cc))) + from cc group by i"; +execute stmt; +(select count(i) from cc as cc_alias + where (cc.i in (select cc_alias.i from cc))) +1 +execute stmt; +(select count(i) from cc as cc_alias + where (cc.i in (select cc_alias.i from cc))) +1 +drop table cc; +# +# Bug #22305361: QUERY WITH MATERIALIZED TABLE RETURNS INCORRECT +# RESULTS IN 5.6 +# +CREATE TABLE t(a INT,b INT); +INSERT INTO t VALUES (1,0),(1,0),(1,0),(1,0),(1,1); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +EXPLAIN SELECT * +FROM t AS t1 +WHERE t1.a IN (SELECT t2.a +FROM t AS t2 +WHERE CONCAT(t2.a,'') NOT IN (SELECT t3.a +FROM t AS t3 +WHERE t3.b=1)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 5 100.00 Using where; Start temporary +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 5 20.00 Using where; End temporary; Using join buffer (hash join) +3 DEPENDENT SUBQUERY t3 NULL ALL NULL NULL NULL NULL 5 20.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t` `t1` semi join (`test`.`t` `t2`) where ((`test`.`t1`.`a` = `test`.`t2`.`a`) and (concat(`test`.`t2`.`a`,''),(/* select#3 */ select `test`.`t3`.`a` from `test`.`t` `t3` where ((`test`.`t3`.`b` = 1) and (outer_field_is_not_null, (((concat(`test`.`t2`.`a`,'')) = `test`.`t3`.`a`) or (`test`.`t3`.`a` is null)), true)) having (outer_field_is_not_null, (`test`.`t3`.`a`), true)) is false)) +SELECT * +FROM t AS t1 +WHERE t1.a IN (SELECT t2.a +FROM t AS t2 +WHERE CONCAT(t2.a,'') NOT IN (SELECT t3.a +FROM t AS t3 +WHERE t3.b=1)); +a b +DROP TABLE t; +# +# Bug#24287772 SUBQUERY RETURNS EMPTY LIST WHILE IDENTICAL QUERY +# WITH JOIN RETURNS RESULT +# +CREATE TABLE t SELECT 4096 c; +SELECT c FROM t WHERE 1 IN +(SELECT t.c = page_size FROM information_schema.innodb_cmpmem); +c +4096 +DROP TABLE t; +# +# Bug #29132639: WL#12470: SIG 6 IN CONNECTJOINS|SQL/SQL_EXECUTOR.C +# +CREATE TABLE t1 ( f1 TIME, f2 VARCHAR(1) ); +INSERT INTO t1 VALUES ('08:35:24', 'X'), ('14:51:13', 'S'), ('11:22:33', 'Q'); +CREATE TABLE t2 ( pk INTEGER ); +INSERT INTO t2 VALUES (1), (2); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN FORMAT=tree SELECT * FROM t1 WHERE EXISTS ( SELECT alias1.f2 FROM t2 LEFT JOIN t1 ON 1 LEFT JOIN t1 AS alias1 ON 1 ); +EXPLAIN +-> Inner hash join (no condition) (cost=9.35 rows=54) + -> Table scan on t1 (cost=0.55 rows=3) + -> Hash + -> Limit: 1 row(s) (cost=3.70 rows=18) + -> Left hash join (no condition) (cost=3.70 rows=18) + -> Left hash join (no condition) (cost=1.12 rows=6) + -> Table scan on t2 (cost=0.45 rows=2) + -> Hash + -> Table scan on t1 (cost=0.28 rows=3) + -> Hash + -> Table scan on alias1 (cost=1.65 rows=3) + +SELECT * FROM t1 WHERE EXISTS ( SELECT alias1.f2 FROM t2 LEFT JOIN t1 ON 1 LEFT JOIN t1 AS alias1 ON 1 ); +f1 f2 +08:35:24 X +11:22:33 Q +14:51:13 S +DROP TABLE t1, t2; +set optimizer_switch=default; +set optimizer_switch=default; diff --git a/mysql-test/r/subquery_sj_loosescan_bka_nobnl.result-pq b/mysql-test/r/subquery_sj_loosescan_bka_nobnl.result-pq new file mode 100644 index 000000000000..ae851bd75846 --- /dev/null +++ b/mysql-test/r/subquery_sj_loosescan_bka_nobnl.result-pq @@ -0,0 +1,12899 @@ +set optimizer_switch='batched_key_access=on,block_nested_loop=off,mrr_cost_based=off'; +set optimizer_switch='semijoin=on,loosescan=on'; +set @old_opt_switch=@@optimizer_switch; +set optimizer_switch='subquery_materialization_cost_based=off'; +drop table if exists t0, t1, t2, t10, t11, t12; +create table t1 (a int not null, b int, primary key (a)); +create table t2 (a int not null, primary key (a)); +create table t3 (a int not null, b int, primary key (a)); +insert into t1 values (1,10), (2,20), (3,30), (4,40); +insert into t2 values (2), (3), (4), (5); +insert into t3 values (10,3), (20,4), (30,5); +select * from t2 where t2.a in (select a from t1); +a +2 +3 +4 +explain select * from t2 where t2.a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index PRIMARY PRIMARY 4 NULL 4 100.00 Using index +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t1` join `test`.`t2` where (`test`.`t1`.`a` = `test`.`t2`.`a`) +select * from t2 where t2.a in (select a from t1 where t1.b <> 30); +a +2 +4 +explain select * from t2 where t2.a in (select a from t1 where t1.b <> 30); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL PRIMARY NULL NULL NULL 4 75.00 Using where +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`a` = `test`.`t1`.`a`) and (`test`.`t1`.`b` <> 30)) +select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a); +a +2 +3 +explain select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index PRIMARY PRIMARY 4 NULL 4 100.00 Using index +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.a 1 100.00 Using where +1 SIMPLE t3 NULL eq_ref PRIMARY PRIMARY 4 test.t1.b 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t1` join `test`.`t3` join `test`.`t2` where ((`test`.`t1`.`a` = `test`.`t2`.`a`) and (`test`.`t3`.`a` = `test`.`t1`.`b`)) +drop table t1, t2, t3; +create table t1 (a int, b int, index a (a,b)); +create table t2 (a int, index a (a)); +create table t3 (a int, b int, index a (a)); +insert into t1 values (1,10), (2,20), (3,30), (4,40); +create table t0(a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +insert into t1 +select rand()*100000+200,rand()*100000 from t0 A, t0 B, t0 C, t0 D; +insert into t2 values (2), (3), (4), (5); +insert into t3 values (10,3), (20,4), (30,5); +select * from t2 where t2.a in (select a from t1); +a +2 +3 +4 +explain select * from t2 where t2.a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index a a 10 NULL 10004 100.00 Using where; Using index; LooseScan +1 SIMPLE t2 NULL ref a a 5 test.t1.a 2 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1`) where (`test`.`t2`.`a` = `test`.`t1`.`a`) +select * from t2 where t2.a in (select a from t1 where t1.b <> 30); +a +2 +4 +explain select * from t2 where t2.a in (select a from t1 where t1.b <> 30); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index a a 10 NULL 10004 90.00 Using where; Using index; LooseScan +1 SIMPLE t2 NULL ref a a 5 test.t1.a 2 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1`) where ((`test`.`t2`.`a` = `test`.`t1`.`a`) and (`test`.`t1`.`b` <> 30)) +select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a); +a +2 +3 +explain select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index a a 10 NULL 10004 100.00 Using where; Using index; LooseScan +1 SIMPLE t3 NULL ref a a 5 test.t1.b 2 100.00 Using index; FirstMatch(t1) +1 SIMPLE t2 NULL ref a a 5 test.t1.a 2 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1` join `test`.`t3`) where ((`test`.`t2`.`a` = `test`.`t1`.`a`) and (`test`.`t3`.`a` = `test`.`t1`.`b`)) +insert into t1 values (3,31); +select * from t2 where t2.a in (select a from t1 where t1.b <> 30); +a +2 +3 +4 +select * from t2 where t2.a in (select a from t1 where t1.b <> 30 and t1.b <> 31); +a +2 +4 +explain select * from t2 where t2.a in (select a from t1 where t1.b <> 30); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index a a 10 NULL 10005 90.00 Using where; Using index; LooseScan +1 SIMPLE t2 NULL ref a a 5 test.t1.a 2 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1`) where ((`test`.`t2`.`a` = `test`.`t1`.`a`) and (`test`.`t1`.`b` <> 30)) +drop table t0, t1, t2, t3; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1(a int, b int); +insert into t1 values (0,0),(1,1),(2,2); +create table t2 as select * from t1; +create table t11(a int, b int); +create table t10 (pk int, a int, primary key(pk)); +insert into t10 select a,a from t0; +create table t12 like t10; +insert into t12 select * from t10; +Flattened because of dependency, t10=func(t1) +explain select * from t1 where a in (select pk from t10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t1` where (`test`.`t10`.`pk` = `test`.`t1`.`a`) +select * from t1 where a in (select pk from t10); +a b +0 0 +1 1 +2 2 +A confluent case of dependency +explain select * from t1 where a in (select a from t10 where pk=12); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t1` where (multiple equal(12, NULL) and multiple equal(`test`.`t1`.`a`, NULL)) +select * from t1 where a in (select a from t10 where pk=12); +a b +explain select * from t1 where a in (select a from t10 where pk=9); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t10 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t1` where ((`test`.`t1`.`a` = '9')) +select * from t1 where a in (select a from t10 where pk=9); +a b +An empty table inside +explain select * from t1 where a in (select a from t11); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t11 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t11`) where (`test`.`t1`.`a` = `test`.`t11`.`a`) +select * from t1 where a in (select a from t11); +a b +explain select * from t1 where a in (select pk from t10) and b in (select pk from t10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using index +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.t1.b 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t10` join `test`.`t1` where ((`test`.`t10`.`pk` = `test`.`t1`.`b`) and (`test`.`t10`.`pk` = `test`.`t1`.`a`)) +select * from t1 where a in (select pk from t10) and b in (select pk from t10); +a b +0 0 +1 1 +2 2 +flattening a nested subquery +explain select * from t1 where a in (select pk from t10 where t10.a in (select pk from t12)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using where +1 SIMPLE t12 NULL eq_ref PRIMARY PRIMARY 4 test.t10.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t12` join `test`.`t1` where ((`test`.`t10`.`pk` = `test`.`t1`.`a`) and (`test`.`t12`.`pk` = `test`.`t10`.`a`)) +select * from t1 where a in (select pk from t10 where t10.a in (select pk from t12)); +a b +0 0 +1 1 +2 2 +flattening subquery w/ several tables +explain select * from t1 where a in (select t10.pk from t10, t12 where t12.pk=t10.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using where +1 SIMPLE t12 NULL eq_ref PRIMARY PRIMARY 4 test.t10.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t12` join `test`.`t1` where ((`test`.`t10`.`pk` = `test`.`t1`.`a`) and (`test`.`t12`.`pk` = `test`.`t10`.`a`)) +subqueries within outer joins go into ON expr. +explain +select * from t1 left join (t2 A, t2 B) on ( A.A= t1.A and B.A in (select pk from t10)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE A NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE B NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.B.A 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`A` AS `A`,`test`.`t1`.`B` AS `B`,`test`.`A`.`A` AS `A`,`test`.`A`.`B` AS `B`,`test`.`B`.`A` AS `A`,`test`.`B`.`B` AS `B` from `test`.`t1` left join (`test`.`t10` join `test`.`t2` `A` join `test`.`t2` `B`) on(((`test`.`t10`.`pk` = `test`.`B`.`A`) and (`test`.`A`.`A` = `test`.`t1`.`A`))) where true +t2 should be wrapped into OJ-nest, so we have "t1 LJ (t2 J t10)" +explain +select * from t1 left join t2 on (t2.A= t1.A and t2.A in (select pk from t10)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.t1.A 1 100.00 Using index +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`A` AS `A`,`test`.`t1`.`B` AS `B`,`test`.`t2`.`A` AS `A`,`test`.`t2`.`B` AS `B` from `test`.`t1` left join (`test`.`t10` join `test`.`t2`) on(((`test`.`t10`.`pk` = `test`.`t1`.`A`) and (`test`.`t2`.`A` = `test`.`t1`.`A`))) where true +we shouldn't flatten if we're going to get a join of > MAX_TABLES. +explain select * from +t1 s00, t1 s01, t1 s02, t1 s03, t1 s04,t1 s05,t1 s06,t1 s07,t1 s08,t1 s09, +t1 s10, t1 s11, t1 s12, t1 s13, t1 s14,t1 s15,t1 s16,t1 s17,t1 s18,t1 s19, +t1 s20, t1 s21, t1 s22, t1 s23, t1 s24,t1 s25,t1 s26,t1 s27,t1 s28,t1 s29, +t1 s30, t1 s31, t1 s32, t1 s33, t1 s34,t1 s35,t1 s36,t1 s37,t1 s38,t1 s39, +t1 s40, t1 s41, t1 s42, t1 s43, t1 s44,t1 s45,t1 s46,t1 s47,t1 s48,t1 s49 +where +s00.a in ( +select m00.a from +t1 m00, t1 m01, t1 m02, t1 m03, t1 m04,t1 m05,t1 m06,t1 m07,t1 m08,t1 m09, +t1 m10, t1 m11, t1 m12, t1 m13, t1 m14,t1 m15,t1 m16,t1 m17,t1 m18,t1 m19 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY s00 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 PRIMARY s01 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s02 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s03 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s04 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s05 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s06 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s07 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s08 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s09 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s10 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s11 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s12 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s13 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s14 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s15 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s16 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s17 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s18 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s19 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s20 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s21 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s22 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s23 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s24 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s25 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s26 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s27 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s28 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s29 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s30 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s31 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s32 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s33 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s34 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s35 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s36 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s37 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s38 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s39 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s40 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s41 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s42 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s43 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s44 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s45 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s46 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s47 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s48 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s49 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 DEPENDENT SUBQUERY m00 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +2 DEPENDENT SUBQUERY m01 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 DEPENDENT SUBQUERY m02 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 DEPENDENT SUBQUERY m03 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 DEPENDENT SUBQUERY m04 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 DEPENDENT SUBQUERY m05 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 DEPENDENT SUBQUERY m06 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 DEPENDENT SUBQUERY m07 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 DEPENDENT SUBQUERY m08 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 DEPENDENT SUBQUERY m09 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 DEPENDENT SUBQUERY m10 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 DEPENDENT SUBQUERY m11 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 DEPENDENT SUBQUERY m12 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 DEPENDENT SUBQUERY m13 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 DEPENDENT SUBQUERY m14 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 DEPENDENT SUBQUERY m15 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 DEPENDENT SUBQUERY m16 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 DEPENDENT SUBQUERY m17 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 DEPENDENT SUBQUERY m18 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 DEPENDENT SUBQUERY m19 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`s00`.`a` AS `a`,`test`.`s00`.`b` AS `b`,`test`.`s01`.`a` AS `a`,`test`.`s01`.`b` AS `b`,`test`.`s02`.`a` AS `a`,`test`.`s02`.`b` AS `b`,`test`.`s03`.`a` AS `a`,`test`.`s03`.`b` AS `b`,`test`.`s04`.`a` AS `a`,`test`.`s04`.`b` AS `b`,`test`.`s05`.`a` AS `a`,`test`.`s05`.`b` AS `b`,`test`.`s06`.`a` AS `a`,`test`.`s06`.`b` AS `b`,`test`.`s07`.`a` AS `a`,`test`.`s07`.`b` AS `b`,`test`.`s08`.`a` AS `a`,`test`.`s08`.`b` AS `b`,`test`.`s09`.`a` AS `a`,`test`.`s09`.`b` AS `b`,`test`.`s10`.`a` AS `a`,`test`.`s10`.`b` AS `b`,`test`.`s11`.`a` AS `a`,`test`.`s11`.`b` AS `b`,`test`.`s12`.`a` AS `a`,`test`.`s12`.`b` AS `b`,`test`.`s13`.`a` AS `a`,`test`.`s13`.`b` AS `b`,`test`.`s14`.`a` AS `a`,`test`.`s14`.`b` AS `b`,`test`.`s15`.`a` AS `a`,`test`.`s15`.`b` AS `b`,`test`.`s16`.`a` AS `a`,`test`.`s16`.`b` AS `b`,`test`.`s17`.`a` AS `a`,`test`.`s17`.`b` AS `b`,`test`.`s18`.`a` AS `a`,`test`.`s18`.`b` AS `b`,`test`.`s19`.`a` AS `a`,`test`.`s19`.`b` AS `b`,`test`.`s20`.`a` AS `a`,`test`.`s20`.`b` AS `b`,`test`.`s21`.`a` AS `a`,`test`.`s21`.`b` AS `b`,`test`.`s22`.`a` AS `a`,`test`.`s22`.`b` AS `b`,`test`.`s23`.`a` AS `a`,`test`.`s23`.`b` AS `b`,`test`.`s24`.`a` AS `a`,`test`.`s24`.`b` AS `b`,`test`.`s25`.`a` AS `a`,`test`.`s25`.`b` AS `b`,`test`.`s26`.`a` AS `a`,`test`.`s26`.`b` AS `b`,`test`.`s27`.`a` AS `a`,`test`.`s27`.`b` AS `b`,`test`.`s28`.`a` AS `a`,`test`.`s28`.`b` AS `b`,`test`.`s29`.`a` AS `a`,`test`.`s29`.`b` AS `b`,`test`.`s30`.`a` AS `a`,`test`.`s30`.`b` AS `b`,`test`.`s31`.`a` AS `a`,`test`.`s31`.`b` AS `b`,`test`.`s32`.`a` AS `a`,`test`.`s32`.`b` AS `b`,`test`.`s33`.`a` AS `a`,`test`.`s33`.`b` AS `b`,`test`.`s34`.`a` AS `a`,`test`.`s34`.`b` AS `b`,`test`.`s35`.`a` AS `a`,`test`.`s35`.`b` AS `b`,`test`.`s36`.`a` AS `a`,`test`.`s36`.`b` AS `b`,`test`.`s37`.`a` AS `a`,`test`.`s37`.`b` AS `b`,`test`.`s38`.`a` AS `a`,`test`.`s38`.`b` AS `b`,`test`.`s39`.`a` AS `a`,`test`.`s39`.`b` AS `b`,`test`.`s40`.`a` AS `a`,`test`.`s40`.`b` AS `b`,`test`.`s41`.`a` AS `a`,`test`.`s41`.`b` AS `b`,`test`.`s42`.`a` AS `a`,`test`.`s42`.`b` AS `b`,`test`.`s43`.`a` AS `a`,`test`.`s43`.`b` AS `b`,`test`.`s44`.`a` AS `a`,`test`.`s44`.`b` AS `b`,`test`.`s45`.`a` AS `a`,`test`.`s45`.`b` AS `b`,`test`.`s46`.`a` AS `a`,`test`.`s46`.`b` AS `b`,`test`.`s47`.`a` AS `a`,`test`.`s47`.`b` AS `b`,`test`.`s48`.`a` AS `a`,`test`.`s48`.`b` AS `b`,`test`.`s49`.`a` AS `a`,`test`.`s49`.`b` AS `b` from `test`.`t1` `s00` join `test`.`t1` `s01` join `test`.`t1` `s02` join `test`.`t1` `s03` join `test`.`t1` `s04` join `test`.`t1` `s05` join `test`.`t1` `s06` join `test`.`t1` `s07` join `test`.`t1` `s08` join `test`.`t1` `s09` join `test`.`t1` `s10` join `test`.`t1` `s11` join `test`.`t1` `s12` join `test`.`t1` `s13` join `test`.`t1` `s14` join `test`.`t1` `s15` join `test`.`t1` `s16` join `test`.`t1` `s17` join `test`.`t1` `s18` join `test`.`t1` `s19` join `test`.`t1` `s20` join `test`.`t1` `s21` join `test`.`t1` `s22` join `test`.`t1` `s23` join `test`.`t1` `s24` join `test`.`t1` `s25` join `test`.`t1` `s26` join `test`.`t1` `s27` join `test`.`t1` `s28` join `test`.`t1` `s29` join `test`.`t1` `s30` join `test`.`t1` `s31` join `test`.`t1` `s32` join `test`.`t1` `s33` join `test`.`t1` `s34` join `test`.`t1` `s35` join `test`.`t1` `s36` join `test`.`t1` `s37` join `test`.`t1` `s38` join `test`.`t1` `s39` join `test`.`t1` `s40` join `test`.`t1` `s41` join `test`.`t1` `s42` join `test`.`t1` `s43` join `test`.`t1` `s44` join `test`.`t1` `s45` join `test`.`t1` `s46` join `test`.`t1` `s47` join `test`.`t1` `s48` join `test`.`t1` `s49` where (`test`.`s00`.`a`,(/* select#2 */ select `test`.`m00`.`a` from `test`.`t1` `m00` join `test`.`t1` `m01` join `test`.`t1` `m02` join `test`.`t1` `m03` join `test`.`t1` `m04` join `test`.`t1` `m05` join `test`.`t1` `m06` join `test`.`t1` `m07` join `test`.`t1` `m08` join `test`.`t1` `m09` join `test`.`t1` `m10` join `test`.`t1` `m11` join `test`.`t1` `m12` join `test`.`t1` `m13` join `test`.`t1` `m14` join `test`.`t1` `m15` join `test`.`t1` `m16` join `test`.`t1` `m17` join `test`.`t1` `m18` join `test`.`t1` `m19` where ((`test`.`s00`.`a`) = `test`.`m00`.`a`))) +select * from +t1 left join t2 on (t2.a= t1.a and t2.a in (select pk from t10)) +where t1.a < 5; +a b a b +0 0 0 0 +1 1 1 1 +2 2 2 2 +prepare s1 from +' select * from + t1 left join t2 on (t2.a= t1.a and t2.a in (select pk from t10)) + where t1.a < 5'; +execute s1; +a b a b +0 0 0 0 +1 1 1 1 +2 2 2 2 +execute s1; +a b a b +0 0 0 0 +1 1 1 1 +2 2 2 2 +insert into t1 select (A.a + 10 * B.a),1 from t0 A, t0 B; +explain select * from t1 where a in (select pk from t10 where pk<3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t10 NULL range PRIMARY PRIMARY 4 NULL 4 100.00 Using where; Using index +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 103 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t1` where ((`test`.`t1`.`a` = `test`.`t10`.`pk`) and (`test`.`t10`.`pk` < 3)) +drop table t0, t1, t2; +drop table t10, t11, t12; +# +# Check that subqueries with outer joins or straight_join work for +# different permutations of const and non-const tables. (Ref. Bug#46692) +# +CREATE TABLE t1 (i INTEGER); +CREATE TABLE t2 (i INTEGER); +CREATE TABLE t3 (i INTEGER); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 0 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 0 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 0 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 1 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 1 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 1 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 2 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 2 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 2 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (0); +DELETE FROM t2; +INSERT INTO t1 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 0 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 0 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 0 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 1 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 1 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 1 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 2 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 2 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 2 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (0); +DELETE FROM t2; +INSERT INTO t1 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 0 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = `test`.`t2`.`i`) and (`test`.`t1`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = `test`.`t2`.`i`) and (`test`.`t1`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = `test`.`t2`.`i`) and (`test`.`t1`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 0 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = `test`.`t2`.`i`) and (`test`.`t1`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = `test`.`t2`.`i`) and (`test`.`t1`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = `test`.`t2`.`i`) and (`test`.`t1`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 0 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t2`.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t2`.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t2`.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +1 +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 1 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = `test`.`t3`.`i`) and (`test`.`t1`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = `test`.`t3`.`i`) and (`test`.`t1`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = `test`.`t3`.`i`) and (`test`.`t1`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 1 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = `test`.`t2`.`i`) and (`test`.`t1`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = `test`.`t2`.`i`) and (`test`.`t1`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = `test`.`t2`.`i`) and (`test`.`t1`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 1 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t2`.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t2`.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t2`.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +1 +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +1 +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 2 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t3`.`i`) and (`test`.`t2`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t3`.`i`) and (`test`.`t2`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t3`.`i`) and (`test`.`t2`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 2 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t3`.`i`) and (`test`.`t2`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t3`.`i`) and (`test`.`t2`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t3`.`i`) and (`test`.`t2`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 2 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t2`.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +1 +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +1 +2 + +EXECUTE stmt; +i +1 +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t2`.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +1 +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t2`.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +1 +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +1 +2 + +EXECUTE stmt; +i +1 +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +1 +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +1 +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (0); +DELETE FROM t2; +INSERT INTO t1 VALUES (0); +DROP TABLE t1, t2, t3; +create table x1(k int primary key, d1 int, d2 int); +create table x2(k int primary key, d1 int, d2 int); +insert into x1 values +(10, 10, 10), +(20, 20, 20), +(21, 20, null), +(30, null, 30), +(40, 40, 40); +insert into x2 values +(10, 10, 10), +(20, 20, 20), +(21, 20, null), +(30, null, 30); +select * +from x1 +where (d1, d2) in (select d1, d2 +from x2); +k d1 d2 +10 10 10 +20 20 20 +select * +from x1 +where (d1, d2) in (select d1, d2 +from x2) is true; +k d1 d2 +10 10 10 +20 20 20 +select * +from x1 +where (d1, d2) in (select d1, d2 +from x2) is false; +k d1 d2 +40 40 40 +select * +from x1 +where (d1, d2) in (select d1, d2 +from x2) is unknown; +k d1 d2 +21 20 NULL +30 NULL 30 +select * +from x1 +where d1 in (select d1 +from x2 +where x1.d2=x2.d2); +k d1 d2 +10 10 10 +20 20 20 +select * +from x1 +where d1 in (select d1 +from x2 +where x1.d2=x2.d2) is true; +k d1 d2 +10 10 10 +20 20 20 +select * +from x1 +where d1 in (select d1 +from x2 +where x1.d2=x2.d2) is false; +k d1 d2 +21 20 NULL +40 40 40 +select * +from x1 +where d1 in (select d1 +from x2 +where x1.d2=x2.d2) is unknown; +k d1 d2 +30 NULL 30 +select * +from x1 +where 1 in (select 1 +from x2 +where x1.d1=x2.d1 and x1.d2=x2.d2); +k d1 d2 +10 10 10 +20 20 20 +select * +from x1 +where 1 in (select 1 +from x2 +where x1.d1=x2.d1 and x1.d2=x2.d2) is true; +k d1 d2 +10 10 10 +20 20 20 +select * +from x1 +where 1 in (select 1 +from x2 +where x1.d1=x2.d1 and x1.d2=x2.d2) is false; +k d1 d2 +21 20 NULL +30 NULL 30 +40 40 40 +select * +from x1 +where 1 in (select 1 +from x2 +where x1.d1=x2.d1 and x1.d2=x2.d2) is unknown; +k d1 d2 +select * +from x1 +where exists (select * +from x2 +where x1.d1=x2.d1 and x1.d2=x2.d2); +k d1 d2 +10 10 10 +20 20 20 +drop table x1; +drop table x2; +CREATE TABLE t1 ( +a int(11) NOT NULL, +b int(11) NOT NULL, +c datetime default NULL, +PRIMARY KEY (a), +KEY idx_bc (b,c) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES +(406989,67,'2006-02-23 17:08:46'), (150078,67,'2005-10-26 11:17:45'), +(406993,67,'2006-02-27 11:20:57'), (245655,67,'2005-12-08 15:59:08'), +(406994,67,'2006-02-27 11:26:46'), (256,67,NULL), +(398341,67,'2006-02-20 04:48:44'), (254,67,NULL),(1120,67,NULL), +(406988,67,'2006-02-23 17:07:22'), (255,67,NULL), +(398340,67,'2006-02-20 04:38:53'),(406631,67,'2006-02-23 10:49:42'), +(245653,67,'2005-12-08 15:59:07'),(406992,67,'2006-02-24 16:47:18'), +(245654,67,'2005-12-08 15:59:08'),(406995,67,'2006-02-28 11:55:00'), +(127261,67,'2005-10-13 12:17:58'),(406991,67,'2006-02-24 16:42:32'), +(245652,67,'2005-12-08 15:58:27'),(398545,67,'2006-02-20 04:53:13'), +(154504,67,'2005-10-28 11:53:01'),(9199,67,NULL),(1,67,'2006-02-23 15:01:35'), +(223456,67,NULL),(4101,67,NULL),(1133,67,NULL), +(406990,67,'2006-02-23 18:01:45'),(148815,67,'2005-10-25 15:34:17'), +(148812,67,'2005-10-25 15:30:01'),(245651,67,'2005-12-08 15:58:27'), +(154503,67,'2005-10-28 11:52:38'); +create table t11 select * from t1 where b = 67 AND (c IS NULL OR c > NOW()) order by 3 asc; +create table t12 select * from t1 where b = 67 AND (c IS NULL OR c > NOW()) order by 3 desc; +create table t21 select * from t1 where b = 67 AND (c IS NULL OR c > '2005-12-08') order by 3 asc; +create table t22 select * from t1 where b = 67 AND (c IS NULL OR c > '2005-12-08') order by 3 desc; +update t22 set c = '2005-12-08 15:58:27' where a = 255; +explain select t21.* from t21,t22 where t21.a = t22.a and +t22.a in (select t12.a from t11, t12 where t11.a in(255,256) and t11.a = t12.a and t11.c is null) and t22.c is null order by t21.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t11 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; Using temporary; Using filesort; Start temporary +1 SIMPLE t12 NULL ALL NULL NULL NULL NULL 8 12.50 Using where +1 SIMPLE t22 NULL ALL NULL NULL NULL NULL 26 3.85 Using where; End temporary +1 SIMPLE t21 NULL ALL NULL NULL NULL NULL 26 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t21`.`a` AS `a`,`test`.`t21`.`b` AS `b`,`test`.`t21`.`c` AS `c` from `test`.`t21` join `test`.`t22` semi join (`test`.`t11` join `test`.`t12`) where ((`test`.`t12`.`a` = `test`.`t11`.`a`) and (`test`.`t22`.`a` = `test`.`t11`.`a`) and (`test`.`t21`.`a` = `test`.`t11`.`a`) and (`test`.`t22`.`c` is null) and (`test`.`t11`.`a` in (255,256)) and (`test`.`t11`.`c` is null)) order by `test`.`t21`.`a` +explain format=json select * from t1 where a in (select a from t11); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "6.71" + }, + "duplicates_removal": { + "using_temporary_table": true, + "nested_loop": [ + { + "table": { + "table_name": "t11", + "access_type": "ALL", + "rows_examined_per_scan": 8, + "rows_produced_per_join": 8, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "0.80", + "prefix_cost": "1.31", + "data_read_per_join": "128" + }, + "used_columns": [ + "a" + ] + } + }, + { + "table": { + "table_name": "t1", + "access_type": "eq_ref", + "possible_keys": [ + "PRIMARY" + ], + "key": "PRIMARY", + "used_key_parts": [ + "a" + ], + "key_length": "4", + "ref": [ + "test.t11.a" + ], + "rows_examined_per_scan": 1, + "rows_produced_per_join": 8, + "filtered": "100.00", + "cost_info": { + "read_cost": "2.00", + "eval_cost": "0.80", + "prefix_cost": "6.71", + "data_read_per_join": "128" + }, + "used_columns": [ + "a", + "b", + "c" + ] + } + } + ] + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` semi join (`test`.`t11`) where (`test`.`t1`.`a` = `test`.`t11`.`a`) +select t21.* from t21,t22 where t21.a = t22.a and +t22.a in (select t12.a from t11, t12 where t11.a in(255,256) and t11.a = t12.a and t11.c is null) and t22.c is null order by t21.a; +a b c +256 67 NULL +drop table t1, t11, t12, t21, t22; +create table t1(a int); +insert into t1 values (0),(1); +explain +select (select max(y.a) from t1 y where a in (select a from t1 z) and a < x.a) as subq from t1 x; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY x NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DEPENDENT SUBQUERY y NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 DEPENDENT SUBQUERY z NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary; End temporary +Warnings: +Note 1276 Field or reference 'test.x.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select (/* select#2 */ select max(`test`.`y`.`a`) from `test`.`t1` `y` semi join (`test`.`t1` `z`) where ((`test`.`z`.`a` = `test`.`y`.`a`) and (`test`.`y`.`a` < `test`.`x`.`a`))) AS `subq` from `test`.`t1` `x` +select (select max(y.a) from t1 y where a in (select a from t1 z) and a < x.a) as subq from t1 x; +subq +NULL +0 +drop table t1; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 as select * from t0; +insert into t1 select a+10 from t0; +insert into t0 values(2); +explain select * from t1 where 2 in (select a from t0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 11 10.00 Using where; Start temporary; End temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 20 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t0`) where (`test`.`t0`.`a` = 2) +select * from t1 where 2 in (select a from t0); +a +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +explain select * from (select a from t0) x where a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 11 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 20 10.00 Using where; Start temporary; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a` from `test`.`t0` semi join (`test`.`t1`) where (`test`.`t1`.`a` = `test`.`t0`.`a`) +explain format=json select * from (select a from t0) x where a in (select a from t1); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "33.50" + }, + "nested_loop": [ + { + "table": { + "table_name": "t0", + "access_type": "ALL", + "rows_examined_per_scan": 11, + "rows_produced_per_join": 11, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "1.10", + "prefix_cost": "1.60", + "data_read_per_join": "88" + }, + "used_columns": [ + "a" + ] + } + }, + { + "duplicates_removal": { + "using_temporary_table": true, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 11, + "filtered": "10.00", + "cost_info": { + "read_cost": "5.59", + "eval_cost": "1.10", + "prefix_cost": "33.50", + "data_read_per_join": "88" + }, + "used_columns": [ + "a" + ], + "attached_condition": "(`test`.`t1`.`a` = `test`.`t0`.`a`)" + } + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a` from `test`.`t0` semi join (`test`.`t1`) where (`test`.`t1`.`a` = `test`.`t0`.`a`) +drop table t0, t1; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (kp1 int, kp2 int, c int, filler char(100), key(kp1, kp2)); +insert into t1 select A.a+10*(B.a+10*C.a), 0, 0, 'filler' from t0 A, t0 B, t0 C; +insert into t1 select * from t1 where kp1 < 20; +create table t3 (a int); +insert into t3 select A.a + 10*B.a from t0 A, t0 B; +explain select * from t3 where a in (select kp1 from t1 where kp1<20); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range kp1 kp1 5 NULL 48 100.00 Using where; Using index; LooseScan +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 100 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a` from `test`.`t3` semi join (`test`.`t1`) where ((`test`.`t3`.`a` = `test`.`t1`.`kp1`) and (`test`.`t1`.`kp1` < 20)) +select * from t3 where a in (select kp1 from t1 where kp1<20); +a +0 +1 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +2 +3 +4 +5 +6 +7 +8 +9 +explain select * from t3 where a in (select kp1 from t1 where kp1<20) and a<20; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range kp1 kp1 5 NULL 48 100.00 Using where; Using index; LooseScan +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 100 3.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a` from `test`.`t3` semi join (`test`.`t1`) where ((`test`.`t3`.`a` = `test`.`t1`.`kp1`) and (`test`.`t1`.`kp1` < 20) and (`test`.`t1`.`kp1` < 20)) +select * from t3 where a in (select kp1 from t1 where kp1<20) and a<20; +a +0 +1 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +2 +3 +4 +5 +6 +7 +8 +9 +create table t4 (pk int primary key); +insert into t4 select a from t3; +explain select * from t3 where a in +(select t1.kp1 from t1,t4 where kp1<20 and t4.pk=t1.c); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range kp1 kp1 5 NULL 48 100.00 Using where; LooseScan +1 SIMPLE t4 NULL eq_ref PRIMARY PRIMARY 4 test.t1.c 1 100.00 Using index; FirstMatch(t1) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 100 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a` from `test`.`t3` semi join (`test`.`t1` join `test`.`t4`) where ((`test`.`t3`.`a` = `test`.`t1`.`kp1`) and (`test`.`t4`.`pk` = `test`.`t1`.`c`) and (`test`.`t1`.`kp1` < 20)) +explain format=tree select * from t3 where a in +(select t1.kp1 from t1,t4 where kp1<20 and t4.pk=t1.c); +EXPLAIN +-> Nested loop inner join (cost=544.71 rows=480) + -> Nested loop semijoin with duplicate removal on kp1 (cost=38.66 rows=48) + -> Filter: ((t1.kp1 < 20) and (t1.c is not null)) (cost=21.86 rows=48) + -> Index range scan on t1 using kp1 (cost=21.86 rows=48) + -> Single-row index lookup on t4 using PRIMARY (pk=t1.c) (cost=0.25 rows=1) + -> Filter: (t3.a = t1.kp1) (cost=27.05 rows=10) + -> Table scan on t3 (cost=27.05 rows=100) + +select * from t3 where a in +(select t1.kp1 from t1,t4 where kp1<20 and t4.pk=t1.c); +a +0 +1 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +2 +3 +4 +5 +6 +7 +8 +9 +drop table t1, t3, t4; +create table t1 (a int); +insert into t1 values (0),(0),(0),(1),(1),(1),(2),(2),(2),(3),(3),(3); +set session internal_tmp_mem_storage_engine='memory'; +set @save_max_heap_table_size=@@max_heap_table_size; +set @@max_heap_table_size= 16384; +# Attempt to make one test that overflows the heap table when a +# non-duplicate row is inserted and one test that overflows the +# heap table when a duplicate record is inserted. Debugging showed +# that these situations occurred with max_heap_table_size=16384 +# and optimizer_join_cache_level equals 1 and 0, respectively. +# Finally execute a test that does not overflow the heap table. +explain +select count(*) from t0 a, t0 b, t0 c +where c.a in (select a from t1 d); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE d NULL ALL NULL NULL NULL NULL 12 100.00 Start temporary +1 SIMPLE c NULL ALL NULL NULL NULL NULL 10 10.00 Using where; End temporary +1 SIMPLE a NULL ALL NULL NULL NULL NULL 10 100.00 NULL +1 SIMPLE b NULL ALL NULL NULL NULL NULL 10 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select count(0) AS `count(*)` from `test`.`t0` `a` join `test`.`t0` `b` join `test`.`t0` `c` semi join (`test`.`t1` `d`) where (`test`.`c`.`a` = `test`.`d`.`a`) +flush status; +select count(*) from t0 a, t0 b, t0 c +where c.a in (select a from t1 d); +count(*) +400 +show status like 'Created_tmp_disk_tables'; +Variable_name Value +Created_tmp_disk_tables 0 +set @@max_heap_table_size= @save_max_heap_table_size; +set session internal_tmp_mem_storage_engine=default; +flush status; +select count(*) from t0 a, t0 b, t0 c +where c.a in (select a from t1 d); +count(*) +400 +show status like 'Created_tmp_disk_tables'; +Variable_name Value +Created_tmp_disk_tables 0 +drop table t0, t1; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t2(a int); +insert into t2 values (1),(2); +create table t3 ( a int , filler char(100), key(a)); +insert into t3 select A.a + 10*B.a, 'filler' from t0 A, t0 B; +explain select * from t3 where a in (select a from t2) and (a > 5 or a < 10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ref a a 5 test.t2.a 1 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a`,`test`.`t3`.`filler` AS `filler` from `test`.`t3` semi join (`test`.`t2`) where ((`test`.`t3`.`a` = `test`.`t2`.`a`) and ((`test`.`t2`.`a` > 5) or (`test`.`t2`.`a` < 10))) +select * from t3 where a in (select a from t2); +a filler +1 filler +2 filler +drop table t0, t2, t3; +create table t1 (a date); +insert into t1 values ('2008-01-01'),('2008-01-01'),('2008-02-01'),('2008-02-01'); +create table t2 (a int); +insert into t2 values (1),(2); +create table t3 (a char(10)); +insert into t3 select * from t1; +insert into t3 values (1),(2); +explain select * from t2 where a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; Start temporary; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1`) where (cast(`test`.`t2`.`a` as double) = cast(`test`.`t1`.`a` as double)) +explain select * from t2 where a in (select a from t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t2`) where (`test`.`t2`.`a` = `test`.`t2`.`a`) +explain select * from t2 where a in (select a from t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Start temporary; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t3`) where (cast(`test`.`t2`.`a` as double) = cast(`test`.`t3`.`a` as double)) +explain select * from t1 where a in (select a from t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Start temporary; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t3`) where (`test`.`t1`.`a` = cast(`test`.`t3`.`a` as date)) +drop table t1, t2, t3; +create table t1 (a decimal); +insert into t1 values (1),(2); +explain select * from t1 where a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t1`) where (`test`.`t1`.`a` = `test`.`t1`.`a`) +drop table t1; +create table t1 (a int); +insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t2 as select * from t1; +create table t3 (a int, b int, filler char(100), key(a)) charset utf8mb4; +insert into t3 select A.a + 10*B.a, A.a + 10*B.a, 'filler' from t1 A, t1 B, t1 C; +explain select * from t1, t3 where t3.a in (select a from t2) and (t3.a < 10 or t3.a >30) and t1.a =3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 10.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 10 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ref a a 5 test.t2.a 10 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t3`.`filler` AS `filler` from `test`.`t1` join `test`.`t3` semi join (`test`.`t2`) where ((`test`.`t3`.`a` = `test`.`t2`.`a`) and (`test`.`t1`.`a` = 3) and ((`test`.`t2`.`a` < 10) or (`test`.`t2`.`a` > 30))) +explain format=json select * from t1, t3 where t3.a in (select a from t2) and (t3.a < 10 or t3.a >30) and t1.a =3; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "59.01" + }, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 10, + "rows_produced_per_join": 1, + "filtered": "10.00", + "cost_info": { + "read_cost": "1.40", + "eval_cost": "0.10", + "prefix_cost": "1.50", + "data_read_per_join": "8" + }, + "used_columns": [ + "a" + ], + "attached_condition": "(`test`.`t1`.`a` = 3)" + } + }, + { + "duplicates_removal": { + "using_temporary_table": true, + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 10, + "rows_produced_per_join": 10, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "1.00", + "prefix_cost": "3.01", + "data_read_per_join": "80" + }, + "used_columns": [ + "a" + ], + "attached_condition": "(((`test`.`t2`.`a` < 10) or (`test`.`t2`.`a` > 30)) and (`test`.`t2`.`a` is not null))" + } + }, + { + "table": { + "table_name": "t3", + "access_type": "ref", + "possible_keys": [ + "a" + ], + "key": "a", + "used_key_parts": [ + "a" + ], + "key_length": "5", + "ref": [ + "test.t2.a" + ], + "rows_examined_per_scan": 10, + "rows_produced_per_join": 100, + "filtered": "100.00", + "cost_info": { + "read_cost": "25.00", + "eval_cost": "10.00", + "prefix_cost": "59.01", + "data_read_per_join": "40K" + }, + "used_columns": [ + "a", + "b", + "filler" + ] + } + } + ] + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t3`.`filler` AS `filler` from `test`.`t1` join `test`.`t3` semi join (`test`.`t2`) where ((`test`.`t3`.`a` = `test`.`t2`.`a`) and (`test`.`t1`.`a` = 3) and ((`test`.`t2`.`a` < 10) or (`test`.`t2`.`a` > 30))) +explain select straight_join * from t1 a, t1 b where a.a in (select a from t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY a NULL ALL NULL NULL NULL NULL 10 100.00 Using where +1 PRIMARY b NULL ALL NULL NULL NULL NULL 10 100.00 NULL +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select straight_join `test`.`a`.`a` AS `a`,`test`.`b`.`a` AS `a` from `test`.`t1` `a` join `test`.`t1` `b` where (`test`.`a`.`a`,(/* select#2 */ select `test`.`t2`.`a` from `test`.`t2` where ((`test`.`a`.`a`) = `test`.`t2`.`a`))) +explain select * from t2 where a in (select straight_join a.a from t1 a, t1 b); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 10 100.00 Using where +2 DEPENDENT SUBQUERY a NULL ALL NULL NULL NULL NULL 10 10.00 Using where +2 DEPENDENT SUBQUERY b NULL ALL NULL NULL NULL NULL 10 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` where (`test`.`t2`.`a`,(/* select#2 */ select straight_join `test`.`a`.`a` from `test`.`t1` `a` join `test`.`t1` `b` where ((`test`.`t2`.`a`) = `test`.`a`.`a`))) +explain select * from t2 where a in (select straight_join a.a from t1 a, t1 b); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 10 100.00 Using where +2 DEPENDENT SUBQUERY a NULL ALL NULL NULL NULL NULL 10 10.00 Using where +2 DEPENDENT SUBQUERY b NULL ALL NULL NULL NULL NULL 10 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` where (`test`.`t2`.`a`,(/* select#2 */ select straight_join `test`.`a`.`a` from `test`.`t1` `a` join `test`.`t1` `b` where ((`test`.`t2`.`a`) = `test`.`a`.`a`))) +explain select straight_join * from t2 x, t2 y +where x.a in (select straight_join a.a from t1 a, t1 b); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY x NULL ALL NULL NULL NULL NULL 10 100.00 Using where +1 PRIMARY y NULL ALL NULL NULL NULL NULL 10 100.00 NULL +2 DEPENDENT SUBQUERY a NULL ALL NULL NULL NULL NULL 10 10.00 Using where +2 DEPENDENT SUBQUERY b NULL ALL NULL NULL NULL NULL 10 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select straight_join `test`.`x`.`a` AS `a`,`test`.`y`.`a` AS `a` from `test`.`t2` `x` join `test`.`t2` `y` where (`test`.`x`.`a`,(/* select#2 */ select straight_join `test`.`a`.`a` from `test`.`t1` `a` join `test`.`t1` `b` where ((`test`.`x`.`a`) = `test`.`a`.`a`))) +create table t0 (a int, b int); +insert into t0 values(1,1); +explain select * from t0, t3 where t3.a in (select a from t2) and (t3.a < 10 or t3.a >30); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 10 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ref a a 5 test.t2.a 10 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select '1' AS `a`,'1' AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t3`.`filler` AS `filler` from `test`.`t3` semi join (`test`.`t2`) where ((`test`.`t3`.`a` = `test`.`t2`.`a`) and ((`test`.`t2`.`a` < 10) or (`test`.`t2`.`a` > 30))) +create table t4 as select a as x, a as y from t1; +explain select * from t0, t3 where (t3.a, t3.b) in (select x,y from t4) and (t3.a < 10 or t3.a >30); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t4 NULL ALL NULL NULL NULL NULL 10 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ref a a 5 test.t4.x 10 10.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '1' AS `a`,'1' AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t3`.`filler` AS `filler` from `test`.`t3` semi join (`test`.`t4`) where ((`test`.`t3`.`b` = `test`.`t4`.`y`) and (`test`.`t3`.`a` = `test`.`t4`.`x`) and ((`test`.`t4`.`x` < 10) or (`test`.`t4`.`x` > 30))) +drop table t0,t1,t2,t3,t4; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (a int, b int, filler char(100), key(a,b)); +insert into t1 select A.a, B.a, 'filler' from t0 A, t0 B; +create table t2 as select * from t1; +explain select * from t2 where a in (select b from t1 where a=3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ref a a 5 const 8 100.00 Using index; LooseScan +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 100 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`filler` AS `filler` from `test`.`t2` semi join (`test`.`t1`) where ((`test`.`t2`.`a` = `test`.`t1`.`b`) and (`test`.`t1`.`a` = 3)) +explain select * from t2 where (b,a) in (select a,b from t1 where a=3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ref a a 5 const 8 100.00 Using index; LooseScan +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 100 1.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`filler` AS `filler` from `test`.`t2` semi join (`test`.`t1`) where ((`test`.`t2`.`a` = `test`.`t1`.`b`) and (`test`.`t1`.`a` = 3) and (`test`.`t2`.`b` = 3)) +drop table t1,t2; +create table t1 (a int, b int); +insert into t1 select a,a from t0; +create table t2 (a int, b int); +insert into t2 select A.a + 10*B.a, A.a + 10*B.a from t0 A, t0 B; +explain select * from t1 where (a,b) in (select a,b from t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 100 1.00 Using where; Start temporary; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`a` = `test`.`t1`.`a`)) +drop table t0, t1, t2; +# +# Bug#19695490: CRASH IN CREATE_REF_FOR_KEY ON SELECT + JOIN + UTF8 COLUMN +# + DATETIME INDEX. +# +CREATE TABLE t1 ( +field1 varchar(255) CHARACTER SET utf8, +field2 varchar(255) CHARACTER SET utf8 +); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES +('time','time'), +('lpjdzvkp','lpjdzvkp'), +('dzvkpai', 'dzvkpai'); +CREATE TABLE t2 ( col_varchar varchar(10)); +CREATE TABLE t3 ( +pk int(11) NOT NULL, +col_varchar_255_utf8_key varchar(255) CHARACTER SET utf8, +col_varchar_10_utf8_key varchar(10) CHARACTER SET utf8, +PRIMARY KEY (pk) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t3 VALUES (22,'come','h'), +(23,'time','aaa'), +(24,'lpjdzvkp','ababa'), +(25,'d','GGDD'); +SELECT * FROM t1 WHERE (field1, field2) IN ( +SELECT table1.col_varchar_255_utf8_key AS field1, +table1.col_varchar_255_utf8_key AS field2 +FROM t3 AS table1 LEFT JOIN t2 AS table2 +ON table1.col_varchar_10_utf8_key <= +table2.col_varchar +WHERE table1.pk >= 6); +field1 field2 +time time +lpjdzvkp lpjdzvkp +DROP TABLE t1,t2,t3; +create table t0 (a decimal(4,2)); +insert into t0 values (10.24), (22.11); +create table t1 as select * from t0; +insert into t1 select * from t0; +explain select * from t0 where a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; Start temporary; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a` from `test`.`t0` semi join (`test`.`t1`) where (`test`.`t1`.`a` = `test`.`t0`.`a`) +select * from t0 where a in (select a from t1); +a +10.24 +22.11 +drop table t0, t1; +create table t0(a date); +insert into t0 values ('2008-01-01'),('2008-02-02'); +create table t1 as select * from t0; +insert into t1 select * from t0; +explain select * from t0 where a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; Start temporary; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a` from `test`.`t0` semi join (`test`.`t1`) where (`test`.`t1`.`a` = `test`.`t0`.`a`) +select * from t0 where a in (select a from t1); +a +2008-01-01 +2008-02-02 +drop table t0, t1; +create table t0(a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 as select a as a, a as b, a as c from t0 where a < 3; +create table t2 as select a as a, a as b from t0 where a < 3; +insert into t2 select * from t2; +explain select * from t1 where (a,b,c) in (select x.a, y.a, z.a from t2 x, t2 y, t2 z where x.b=33); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE x NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +1 SIMPLE y NULL ALL NULL NULL NULL NULL 6 16.67 Using where +1 SIMPLE z NULL ALL NULL NULL NULL NULL 6 16.67 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` semi join (`test`.`t2` `x` join `test`.`t2` `y` join `test`.`t2` `z`) where ((`test`.`z`.`a` = `test`.`t1`.`c`) and (`test`.`y`.`a` = `test`.`t1`.`b`) and (`test`.`t1`.`a` = `test`.`x`.`a`) and (`test`.`x`.`b` = 33)) +drop table t0,t1,t2; +set @save_join_buffer_size = @@join_buffer_size; +set join_buffer_size= 8192; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (a int, filler1 binary(200), filler2 binary(200)); +insert into t1 select a, 'filler123456', 'filler123456' from t0; +insert into t1 select a+10, 'filler123456', 'filler123456' from t0; +create table t2 as select * from t1; +insert into t1 select a+20, 'filler123456', 'filler123456' from t0; +insert into t1 values (2, 'duplicate ok', 'duplicate ok'); +insert into t1 values (18, 'duplicate ok', 'duplicate ok'); +insert into t2 values (3, 'duplicate ok', 'duplicate ok'); +insert into t2 values (19, 'duplicate ok', 'duplicate ok'); +explain select +a, mid(filler1, 1,10), length(filler1)=length(filler2) as z +from t1 ot where a in (select a from t2 it); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE it NULL ALL NULL NULL NULL NULL 22 100.00 Start temporary +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 32 10.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`ot`.`a` AS `a`,substr(`test`.`ot`.`filler1`,1,10) AS `mid(filler1, 1,10)`,(length(`test`.`ot`.`filler1`) = length(`test`.`ot`.`filler2`)) AS `z` from `test`.`t1` `ot` semi join (`test`.`t2` `it`) where (`test`.`ot`.`a` = `test`.`it`.`a`) +select +a, mid(filler1, 1,10), length(filler1)=length(filler2) as z +from t1 ot where a in (select a from t2 it); +a mid(filler1, 1,10) z +0 filler1234 1 +1 filler1234 1 +10 filler1234 1 +11 filler1234 1 +12 filler1234 1 +13 filler1234 1 +14 filler1234 1 +15 filler1234 1 +16 filler1234 1 +17 filler1234 1 +18 duplicate 1 +18 filler1234 1 +19 filler1234 1 +2 duplicate 1 +2 filler1234 1 +3 filler1234 1 +4 filler1234 1 +5 filler1234 1 +6 filler1234 1 +7 filler1234 1 +8 filler1234 1 +9 filler1234 1 +explain select +a, mid(filler1, 1,10), length(filler1)=length(filler2) +from t2 ot where a in (select a from t1 it); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 22 100.00 NULL +1 SIMPLE it NULL ALL NULL NULL NULL NULL 32 10.00 Using where; Start temporary; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`ot`.`a` AS `a`,substr(`test`.`ot`.`filler1`,1,10) AS `mid(filler1, 1,10)`,(length(`test`.`ot`.`filler1`) = length(`test`.`ot`.`filler2`)) AS `length(filler1)=length(filler2)` from `test`.`t2` `ot` semi join (`test`.`t1` `it`) where (`test`.`it`.`a` = `test`.`ot`.`a`) +select +a, mid(filler1, 1,10), length(filler1)=length(filler2) +from t2 ot where a in (select a from t1 it); +a mid(filler1, 1,10) length(filler1)=length(filler2) +0 filler1234 1 +1 filler1234 1 +10 filler1234 1 +11 filler1234 1 +12 filler1234 1 +13 filler1234 1 +14 filler1234 1 +15 filler1234 1 +16 filler1234 1 +17 filler1234 1 +18 filler1234 1 +19 duplicate 1 +19 filler1234 1 +2 filler1234 1 +3 duplicate 1 +3 filler1234 1 +4 filler1234 1 +5 filler1234 1 +6 filler1234 1 +7 filler1234 1 +8 filler1234 1 +9 filler1234 1 +insert into t1 select a+20, 'filler123456', 'filler123456' from t0; +insert into t1 select a+20, 'filler123456', 'filler123456' from t0; +explain select +a, mid(filler1, 1,10), length(filler1)=length(filler2) as z +from t1 ot where a in (select a from t2 it); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE it NULL ALL NULL NULL NULL NULL 22 100.00 Start temporary +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 52 10.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`ot`.`a` AS `a`,substr(`test`.`ot`.`filler1`,1,10) AS `mid(filler1, 1,10)`,(length(`test`.`ot`.`filler1`) = length(`test`.`ot`.`filler2`)) AS `z` from `test`.`t1` `ot` semi join (`test`.`t2` `it`) where (`test`.`ot`.`a` = `test`.`it`.`a`) +select +a, mid(filler1, 1,10), length(filler1)=length(filler2) as z +from t1 ot where a in (select a from t2 it); +a mid(filler1, 1,10) z +0 filler1234 1 +1 filler1234 1 +10 filler1234 1 +11 filler1234 1 +12 filler1234 1 +13 filler1234 1 +14 filler1234 1 +15 filler1234 1 +16 filler1234 1 +17 filler1234 1 +18 duplicate 1 +18 filler1234 1 +19 filler1234 1 +2 duplicate 1 +2 filler1234 1 +3 filler1234 1 +4 filler1234 1 +5 filler1234 1 +6 filler1234 1 +7 filler1234 1 +8 filler1234 1 +9 filler1234 1 +explain select +a, mid(filler1, 1,10), length(filler1)=length(filler2) +from t2 ot where a in (select a from t1 it); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 22 100.00 NULL +1 SIMPLE it NULL ALL NULL NULL NULL NULL 52 10.00 Using where; Start temporary; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`ot`.`a` AS `a`,substr(`test`.`ot`.`filler1`,1,10) AS `mid(filler1, 1,10)`,(length(`test`.`ot`.`filler1`) = length(`test`.`ot`.`filler2`)) AS `length(filler1)=length(filler2)` from `test`.`t2` `ot` semi join (`test`.`t1` `it`) where (`test`.`it`.`a` = `test`.`ot`.`a`) +select +a, mid(filler1, 1,10), length(filler1)=length(filler2) +from t2 ot where a in (select a from t1 it); +a mid(filler1, 1,10) length(filler1)=length(filler2) +0 filler1234 1 +1 filler1234 1 +10 filler1234 1 +11 filler1234 1 +12 filler1234 1 +13 filler1234 1 +14 filler1234 1 +15 filler1234 1 +16 filler1234 1 +17 filler1234 1 +18 filler1234 1 +19 duplicate 1 +19 filler1234 1 +2 filler1234 1 +3 duplicate 1 +3 filler1234 1 +4 filler1234 1 +5 filler1234 1 +6 filler1234 1 +7 filler1234 1 +8 filler1234 1 +9 filler1234 1 +set @@join_buffer_size = @save_join_buffer_size; +drop table t1, t2; +create table t1 (a int, b int, key(a)); +create table t2 (a int, b int, key(a)); +create table t3 (a int, b int, key(a)); +insert into t1 select a,a from t0; +insert into t2 select a,a from t0; +insert into t3 select a,a from t0; +t2 and t3 must be use 'ref', not 'ALL': +explain select * +from t0 where a in +(select t2.a+t3.a from t1 left join (t2 join t3) on t2.a=t1.a and t3.a=t1.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index a a 5 NULL 10 100.00 Using index; Start temporary +1 SIMPLE t2 NULL ref a a 5 test.t1.a 1 100.00 Using index +1 SIMPLE t3 NULL ref a a 5 test.t1.a 1 100.00 Using index +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 10 10.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a` from `test`.`t0` semi join (`test`.`t1` join `test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`a` = `test`.`t1`.`a`) and (`test`.`t3`.`a` = `test`.`t1`.`a`) and (`test`.`t0`.`a` = (`test`.`t1`.`a` + `test`.`t1`.`a`))) +drop table t0, t1,t2,t3; + +Test that neither MaterializeLookup strategy for semijoin, +nor subquery materialization is used when BLOBs are involved +(except when arguments of some functions). + +set @prefix_len = 6; +set @blob_len = 16; +set @suffix_len = @blob_len - @prefix_len; +create table t1_16 (a1 blob(16), a2 blob(16)); +create table t2_16 (b1 blob(16), b2 blob(16)); +create table t3_16 (c1 blob(16), c2 blob(16)); +insert into t1_16 values +(concat('1 - 00', repeat('x', @suffix_len)), concat('2 - 00', repeat('x', @suffix_len))); +insert into t1_16 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t1_16 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_16 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t2_16 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_16 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_16 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t3_16 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t3_16 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_16 values +(concat('1 - 04', repeat('x', @suffix_len)), concat('2 - 04', repeat('x', @suffix_len))); +explain select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select b1 from t2_16 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2_16 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Start temporary +1 SIMPLE t1_16 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_16`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_16`.`a2`,7) AS `left(a2,7)` from `test`.`t1_16` semi join (`test`.`t2_16`) where ((`test`.`t1_16`.`a1` = `test`.`t2_16`.`b1`) and (`test`.`t2_16`.`b1` > '0')) +select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select b1 from t2_16 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_16 +where (a1,a2) in (select b1, b2 from t2_16 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2_16 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Start temporary +1 SIMPLE t1_16 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_16`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_16`.`a2`,7) AS `left(a2,7)` from `test`.`t1_16` semi join (`test`.`t2_16`) where ((`test`.`t1_16`.`a2` = `test`.`t2_16`.`b2`) and (`test`.`t1_16`.`a1` = `test`.`t2_16`.`b1`) and (`test`.`t2_16`.`b1` > '0')) +select left(a1,7), left(a2,7) +from t1_16 +where (a1,a2) in (select b1, b2 from t2_16 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select substring(b1,1,16) from t2_16 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2_16 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Start temporary +1 SIMPLE t1_16 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_16`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_16`.`a2`,7) AS `left(a2,7)` from `test`.`t1_16` semi join (`test`.`t2_16`) where ((`test`.`t2_16`.`b1` > '0') and (`test`.`t1_16`.`a1` = substr(`test`.`t2_16`.`b1`,1,16))) +select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select substring(b1,1,16) from t2_16 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select group_concat(b1) from t2_16 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_16 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t2_16 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_16`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_16`.`a2`,7) AS `left(a2,7)` from `test`.`t1_16` where (`test`.`t1_16`.`a1`,(/* select#2 */ select group_concat(`test`.`t2_16`.`b1` separator ',') from `test`.`t2_16` group by `test`.`t2_16`.`b2` having ((`test`.`t1_16`.`a1`) = (group_concat(`test`.`t2_16`.`b1` separator ','))))) +select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select group_concat(b1) from t2_16 group by b2); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +set @@group_concat_max_len = 256; +explain select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select group_concat(b1) from t2_16 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_16 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t2_16 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_16`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_16`.`a2`,7) AS `left(a2,7)` from `test`.`t1_16` where (`test`.`t1_16`.`a1`,(/* select#2 */ select group_concat(`test`.`t2_16`.`b1` separator ',') from `test`.`t2_16` group by `test`.`t2_16`.`b2` having ((`test`.`t1_16`.`a1`) = (group_concat(`test`.`t2_16`.`b1` separator ','))))) +select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select group_concat(b1) from t2_16 group by b2); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +create table t1 (a1 char(8), a2 char(8)) charset latin1; +create table t2 (b1 char(8), b2 char(8)) charset latin1; +create table t3 (c1 char(8), c2 char(8)) charset latin1; +insert into t1 values ('1 - 00', '2 - 00'); +insert into t1 values ('1 - 01', '2 - 01'); +insert into t1 values ('1 - 02', '2 - 02'); +insert into t2 values ('1 - 01', '2 - 01'); +insert into t2 values ('1 - 01', '2 - 01'); +insert into t2 values ('1 - 02', '2 - 02'); +insert into t2 values ('1 - 02', '2 - 02'); +insert into t2 values ('1 - 03', '2 - 03'); +insert into t3 values ('1 - 01', '2 - 01'); +insert into t3 values ('1 - 02', '2 - 02'); +insert into t3 values ('1 - 03', '2 - 03'); +insert into t3 values ('1 - 04', '2 - 04'); +insert into t3 values ('1 - 05', '2 - 05'); +insert into t3 values ('1 - 06', '2 - 06'); +insert into t3 values ('1 - 07', '2 - 07'); +insert into t3 values ('1 - 08', '2 - 08'); +explain +select * from t1 +where concat(a1,'x') IN +(select left(a1,8) from t1_16 +where (a1, a2) IN +(select t2_16.b1, t2_16.b2 from t2_16, t2 +where t2.b2 = substring(t2_16.b2,1,6) and +t2.b1 IN (select c1 from t3 where c2 > '0'))); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1_16 NULL ALL NULL NULL NULL NULL 3 100.00 Start temporary +1 SIMPLE t2_16 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 5 20.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 8 12.50 Using where +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` semi join (`test`.`t1_16` join `test`.`t2_16` join `test`.`t2` join `test`.`t3`) where ((`test`.`t2_16`.`b2` = `test`.`t1_16`.`a2`) and (`test`.`t2_16`.`b1` = `test`.`t1_16`.`a1`) and (`test`.`t3`.`c1` = `test`.`t2`.`b1`) and (`test`.`t2`.`b2` = substr(`test`.`t2_16`.`b2`,1,6)) and (`test`.`t3`.`c2` > '0') and (concat(`test`.`t1`.`a1`,'x') = left(`test`.`t1_16`.`a1`,8))) +drop table t1_16, t2_16, t3_16, t1, t2, t3; +set @blob_len = 512; +set @suffix_len = @blob_len - @prefix_len; +create table t1_512 (a1 blob(512), a2 blob(512)); +create table t2_512 (b1 blob(512), b2 blob(512)); +create table t3_512 (c1 blob(512), c2 blob(512)); +insert into t1_512 values +(concat('1 - 00', repeat('x', @suffix_len)), concat('2 - 00', repeat('x', @suffix_len))); +insert into t1_512 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t1_512 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_512 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t2_512 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_512 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_512 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t3_512 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t3_512 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_512 values +(concat('1 - 04', repeat('x', @suffix_len)), concat('2 - 04', repeat('x', @suffix_len))); +explain select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select b1 from t2_512 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2_512 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Start temporary +1 SIMPLE t1_512 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_512`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_512`.`a2`,7) AS `left(a2,7)` from `test`.`t1_512` semi join (`test`.`t2_512`) where ((`test`.`t1_512`.`a1` = `test`.`t2_512`.`b1`) and (`test`.`t2_512`.`b1` > '0')) +select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select b1 from t2_512 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_512 +where (a1,a2) in (select b1, b2 from t2_512 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2_512 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Start temporary +1 SIMPLE t1_512 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_512`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_512`.`a2`,7) AS `left(a2,7)` from `test`.`t1_512` semi join (`test`.`t2_512`) where ((`test`.`t1_512`.`a2` = `test`.`t2_512`.`b2`) and (`test`.`t1_512`.`a1` = `test`.`t2_512`.`b1`) and (`test`.`t2_512`.`b1` > '0')) +select left(a1,7), left(a2,7) +from t1_512 +where (a1,a2) in (select b1, b2 from t2_512 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select substring(b1,1,512) from t2_512 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2_512 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Start temporary +1 SIMPLE t1_512 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_512`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_512`.`a2`,7) AS `left(a2,7)` from `test`.`t1_512` semi join (`test`.`t2_512`) where ((`test`.`t2_512`.`b1` > '0') and (`test`.`t1_512`.`a1` = substr(`test`.`t2_512`.`b1`,1,512))) +select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select substring(b1,1,512) from t2_512 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select group_concat(b1) from t2_512 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_512 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t2_512 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_512`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_512`.`a2`,7) AS `left(a2,7)` from `test`.`t1_512` where (`test`.`t1_512`.`a1`,(/* select#2 */ select group_concat(`test`.`t2_512`.`b1` separator ',') from `test`.`t2_512` group by `test`.`t2_512`.`b2` having ((`test`.`t1_512`.`a1`) = (group_concat(`test`.`t2_512`.`b1` separator ','))))) +select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select group_concat(b1) from t2_512 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +Warning 1260 Row 4 was cut by GROUP_CONCAT() +Warning 1260 Row 5 was cut by GROUP_CONCAT() +Warning 1260 Row 6 was cut by GROUP_CONCAT() +Warning 1260 Row 7 was cut by GROUP_CONCAT() +Warning 1260 Row 8 was cut by GROUP_CONCAT() +Warning 1260 Row 9 was cut by GROUP_CONCAT() +set @@group_concat_max_len = 256; +explain select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select group_concat(b1) from t2_512 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_512 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t2_512 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_512`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_512`.`a2`,7) AS `left(a2,7)` from `test`.`t1_512` where (`test`.`t1_512`.`a1`,(/* select#2 */ select group_concat(`test`.`t2_512`.`b1` separator ',') from `test`.`t2_512` group by `test`.`t2_512`.`b2` having ((`test`.`t1_512`.`a1`) = (group_concat(`test`.`t2_512`.`b1` separator ','))))) +select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select group_concat(b1) from t2_512 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +Warning 1260 Row 4 was cut by GROUP_CONCAT() +Warning 1260 Row 5 was cut by GROUP_CONCAT() +Warning 1260 Row 6 was cut by GROUP_CONCAT() +Warning 1260 Row 7 was cut by GROUP_CONCAT() +Warning 1260 Row 8 was cut by GROUP_CONCAT() +Warning 1260 Row 9 was cut by GROUP_CONCAT() +drop table t1_512, t2_512, t3_512; +set @blob_len = 513; +set @suffix_len = @blob_len - @prefix_len; +create table t1_513 (a1 blob(513), a2 blob(513)); +create table t2_513 (b1 blob(513), b2 blob(513)); +create table t3_513 (c1 blob(513), c2 blob(513)); +insert into t1_513 values +(concat('1 - 00', repeat('x', @suffix_len)), concat('2 - 00', repeat('x', @suffix_len))); +insert into t1_513 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t1_513 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_513 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t2_513 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_513 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_513 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t3_513 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t3_513 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_513 values +(concat('1 - 04', repeat('x', @suffix_len)), concat('2 - 04', repeat('x', @suffix_len))); +explain select left(a1,7), left(a2,7) +from t1_513 +where a1 in (select b1 from t2_513 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2_513 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Start temporary +1 SIMPLE t1_513 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_513`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_513`.`a2`,7) AS `left(a2,7)` from `test`.`t1_513` semi join (`test`.`t2_513`) where ((`test`.`t1_513`.`a1` = `test`.`t2_513`.`b1`) and (`test`.`t2_513`.`b1` > '0')) +select left(a1,7), left(a2,7) +from t1_513 +where a1 in (select b1 from t2_513 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_513 +where (a1,a2) in (select b1, b2 from t2_513 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2_513 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Start temporary +1 SIMPLE t1_513 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_513`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_513`.`a2`,7) AS `left(a2,7)` from `test`.`t1_513` semi join (`test`.`t2_513`) where ((`test`.`t1_513`.`a2` = `test`.`t2_513`.`b2`) and (`test`.`t1_513`.`a1` = `test`.`t2_513`.`b1`) and (`test`.`t2_513`.`b1` > '0')) +select left(a1,7), left(a2,7) +from t1_513 +where (a1,a2) in (select b1, b2 from t2_513 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_513 +where a1 in (select substring(b1,1,513) from t2_513 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2_513 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Start temporary +1 SIMPLE t1_513 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_513`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_513`.`a2`,7) AS `left(a2,7)` from `test`.`t1_513` semi join (`test`.`t2_513`) where ((`test`.`t2_513`.`b1` > '0') and (`test`.`t1_513`.`a1` = substr(`test`.`t2_513`.`b1`,1,513))) +select left(a1,7), left(a2,7) +from t1_513 +where a1 in (select substring(b1,1,513) from t2_513 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_513 +where a1 in (select group_concat(b1) from t2_513 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_513 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t2_513 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_513`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_513`.`a2`,7) AS `left(a2,7)` from `test`.`t1_513` where (`test`.`t1_513`.`a1`,(/* select#2 */ select group_concat(`test`.`t2_513`.`b1` separator ',') from `test`.`t2_513` group by `test`.`t2_513`.`b2` having ((`test`.`t1_513`.`a1`) = (group_concat(`test`.`t2_513`.`b1` separator ','))))) +select left(a1,7), left(a2,7) +from t1_513 +where a1 in (select group_concat(b1) from t2_513 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +Warning 1260 Row 4 was cut by GROUP_CONCAT() +Warning 1260 Row 5 was cut by GROUP_CONCAT() +Warning 1260 Row 6 was cut by GROUP_CONCAT() +Warning 1260 Row 7 was cut by GROUP_CONCAT() +Warning 1260 Row 8 was cut by GROUP_CONCAT() +Warning 1260 Row 9 was cut by GROUP_CONCAT() +drop table t1_513, t2_513, t3_513; +set @blob_len = 1024; +set @suffix_len = @blob_len - @prefix_len; +create table t1_1024 (a1 blob(1024), a2 blob(1024)); +create table t2_1024 (b1 blob(1024), b2 blob(1024)); +create table t3_1024 (c1 blob(1024), c2 blob(1024)); +insert into t1_1024 values +(concat('1 - 00', repeat('x', @suffix_len)), concat('2 - 00', repeat('x', @suffix_len))); +insert into t1_1024 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t1_1024 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_1024 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t2_1024 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_1024 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_1024 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t3_1024 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t3_1024 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_1024 values +(concat('1 - 04', repeat('x', @suffix_len)), concat('2 - 04', repeat('x', @suffix_len))); +explain select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select b1 from t2_1024 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2_1024 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Start temporary +1 SIMPLE t1_1024 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1024`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1024`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1024` semi join (`test`.`t2_1024`) where ((`test`.`t1_1024`.`a1` = `test`.`t2_1024`.`b1`) and (`test`.`t2_1024`.`b1` > '0')) +select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select b1 from t2_1024 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_1024 +where (a1,a2) in (select b1, b2 from t2_1024 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2_1024 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Start temporary +1 SIMPLE t1_1024 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1024`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1024`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1024` semi join (`test`.`t2_1024`) where ((`test`.`t1_1024`.`a2` = `test`.`t2_1024`.`b2`) and (`test`.`t1_1024`.`a1` = `test`.`t2_1024`.`b1`) and (`test`.`t2_1024`.`b1` > '0')) +select left(a1,7), left(a2,7) +from t1_1024 +where (a1,a2) in (select b1, b2 from t2_1024 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select substring(b1,1,1024) from t2_1024 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2_1024 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Start temporary +1 SIMPLE t1_1024 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1024`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1024`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1024` semi join (`test`.`t2_1024`) where ((`test`.`t2_1024`.`b1` > '0') and (`test`.`t1_1024`.`a1` = substr(`test`.`t2_1024`.`b1`,1,1024))) +select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select substring(b1,1,1024) from t2_1024 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select group_concat(b1) from t2_1024 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_1024 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t2_1024 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1024`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1024`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1024` where (`test`.`t1_1024`.`a1`,(/* select#2 */ select group_concat(`test`.`t2_1024`.`b1` separator ',') from `test`.`t2_1024` group by `test`.`t2_1024`.`b2` having ((`test`.`t1_1024`.`a1`) = (group_concat(`test`.`t2_1024`.`b1` separator ','))))) +select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select group_concat(b1) from t2_1024 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +Warning 1260 Row 4 was cut by GROUP_CONCAT() +Warning 1260 Row 5 was cut by GROUP_CONCAT() +Warning 1260 Row 6 was cut by GROUP_CONCAT() +Warning 1260 Row 7 was cut by GROUP_CONCAT() +Warning 1260 Row 8 was cut by GROUP_CONCAT() +Warning 1260 Row 9 was cut by GROUP_CONCAT() +set @@group_concat_max_len = 256; +explain select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select group_concat(b1) from t2_1024 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_1024 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t2_1024 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1024`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1024`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1024` where (`test`.`t1_1024`.`a1`,(/* select#2 */ select group_concat(`test`.`t2_1024`.`b1` separator ',') from `test`.`t2_1024` group by `test`.`t2_1024`.`b2` having ((`test`.`t1_1024`.`a1`) = (group_concat(`test`.`t2_1024`.`b1` separator ','))))) +select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select group_concat(b1) from t2_1024 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +Warning 1260 Row 4 was cut by GROUP_CONCAT() +Warning 1260 Row 5 was cut by GROUP_CONCAT() +Warning 1260 Row 6 was cut by GROUP_CONCAT() +Warning 1260 Row 7 was cut by GROUP_CONCAT() +Warning 1260 Row 8 was cut by GROUP_CONCAT() +Warning 1260 Row 9 was cut by GROUP_CONCAT() +drop table t1_1024, t2_1024, t3_1024; +set @blob_len = 1025; +set @suffix_len = @blob_len - @prefix_len; +create table t1_1025 (a1 blob(1025), a2 blob(1025)); +create table t2_1025 (b1 blob(1025), b2 blob(1025)); +create table t3_1025 (c1 blob(1025), c2 blob(1025)); +insert into t1_1025 values +(concat('1 - 00', repeat('x', @suffix_len)), concat('2 - 00', repeat('x', @suffix_len))); +insert into t1_1025 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t1_1025 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_1025 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t2_1025 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_1025 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_1025 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t3_1025 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t3_1025 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_1025 values +(concat('1 - 04', repeat('x', @suffix_len)), concat('2 - 04', repeat('x', @suffix_len))); +explain select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select b1 from t2_1025 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2_1025 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Start temporary +1 SIMPLE t1_1025 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1025`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1025`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1025` semi join (`test`.`t2_1025`) where ((`test`.`t1_1025`.`a1` = `test`.`t2_1025`.`b1`) and (`test`.`t2_1025`.`b1` > '0')) +select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select b1 from t2_1025 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_1025 +where (a1,a2) in (select b1, b2 from t2_1025 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2_1025 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Start temporary +1 SIMPLE t1_1025 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1025`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1025`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1025` semi join (`test`.`t2_1025`) where ((`test`.`t1_1025`.`a2` = `test`.`t2_1025`.`b2`) and (`test`.`t1_1025`.`a1` = `test`.`t2_1025`.`b1`) and (`test`.`t2_1025`.`b1` > '0')) +select left(a1,7), left(a2,7) +from t1_1025 +where (a1,a2) in (select b1, b2 from t2_1025 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select substring(b1,1,1025) from t2_1025 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2_1025 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Start temporary +1 SIMPLE t1_1025 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1025`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1025`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1025` semi join (`test`.`t2_1025`) where ((`test`.`t2_1025`.`b1` > '0') and (`test`.`t1_1025`.`a1` = substr(`test`.`t2_1025`.`b1`,1,1025))) +select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select substring(b1,1,1025) from t2_1025 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select group_concat(b1) from t2_1025 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_1025 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t2_1025 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1025`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1025`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1025` where (`test`.`t1_1025`.`a1`,(/* select#2 */ select group_concat(`test`.`t2_1025`.`b1` separator ',') from `test`.`t2_1025` group by `test`.`t2_1025`.`b2` having ((`test`.`t1_1025`.`a1`) = (group_concat(`test`.`t2_1025`.`b1` separator ','))))) +select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select group_concat(b1) from t2_1025 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +Warning 1260 Row 4 was cut by GROUP_CONCAT() +Warning 1260 Row 5 was cut by GROUP_CONCAT() +Warning 1260 Row 6 was cut by GROUP_CONCAT() +Warning 1260 Row 7 was cut by GROUP_CONCAT() +Warning 1260 Row 8 was cut by GROUP_CONCAT() +Warning 1260 Row 9 was cut by GROUP_CONCAT() +set @@group_concat_max_len = 256; +explain select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select group_concat(b1) from t2_1025 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_1025 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t2_1025 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1025`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1025`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1025` where (`test`.`t1_1025`.`a1`,(/* select#2 */ select group_concat(`test`.`t2_1025`.`b1` separator ',') from `test`.`t2_1025` group by `test`.`t2_1025`.`b2` having ((`test`.`t1_1025`.`a1`) = (group_concat(`test`.`t2_1025`.`b1` separator ','))))) +select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select group_concat(b1) from t2_1025 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +Warning 1260 Row 4 was cut by GROUP_CONCAT() +Warning 1260 Row 5 was cut by GROUP_CONCAT() +Warning 1260 Row 6 was cut by GROUP_CONCAT() +Warning 1260 Row 7 was cut by GROUP_CONCAT() +Warning 1260 Row 8 was cut by GROUP_CONCAT() +Warning 1260 Row 9 was cut by GROUP_CONCAT() +drop table t1_1025, t2_1025, t3_1025; +# +# WL#5561: Enable semi join transformation with outer join. +# +CREATE TABLE ot1(a INT); +CREATE TABLE ot2(a INT); +CREATE TABLE ot3(a INT); +CREATE TABLE it1(a INT); +CREATE TABLE it2(a INT); +CREATE TABLE it3(a INT); +INSERT INTO ot1 VALUES(0),(1),(2),(3),(4),(5),(6),(7); +INSERT INTO ot2 VALUES(0),(2),(4),(6); +INSERT INTO ot3 VALUES(0),(3),(6); +INSERT INTO it1 VALUES(0),(1),(2),(3),(4),(5),(6),(7); +INSERT INTO it2 VALUES(0),(2),(4),(6); +INSERT INTO it3 VALUES(0),(3),(6); +# Test cases, Subquery Pattern 1 +# Example SQ1.1: +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE ot1.a IN (SELECT a FROM it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE it3 NULL ALL NULL NULL NULL NULL 3 100.00 Start temporary +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; End temporary +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` left join `test`.`ot2` on((`test`.`ot2`.`a` = `test`.`it3`.`a`)) semi join (`test`.`it3`) where (`test`.`ot1`.`a` = `test`.`it3`.`a`) +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE ot1.a IN (SELECT a FROM it3); +a a +0 0 +3 NULL +6 6 +# Example SQ1.2: +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE COALESCE(ot2.a,0) IN (SELECT a FROM it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE it3 NULL ALL NULL NULL NULL NULL 3 100.00 Start temporary +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` left join `test`.`ot2` on((`test`.`ot2`.`a` = `test`.`ot1`.`a`)) semi join (`test`.`it3`) where (coalesce(`test`.`ot2`.`a`,0) = `test`.`it3`.`a`) +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE COALESCE(ot2.a,0) IN (SELECT a FROM it3); +a a +0 0 +1 NULL +3 NULL +5 NULL +6 6 +7 NULL +# Example SQ1.3: +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE (ot1.a,ot2.a) IN (SELECT a, a FROM it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE it3 NULL ALL NULL NULL NULL NULL 3 100.00 Start temporary +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` join `test`.`ot2` semi join (`test`.`it3`) where ((`test`.`ot2`.`a` = `test`.`it3`.`a`) and (`test`.`ot1`.`a` = `test`.`it3`.`a`)) +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE (ot1.a,ot2.a) IN (SELECT a, a FROM it3); +a a +0 0 +6 6 +# More test cases +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 +WHERE ot1.a IN (SELECT a FROM it3); +a a +0 0 +3 NULL +6 6 +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 +WHERE ot1.a IN (SELECT a+0 FROM it3); +a a +0 0 +3 NULL +6 6 +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 +WHERE COALESCE(ot2.a,0) IN (SELECT a FROM it3); +a a +0 0 +1 NULL +3 NULL +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE COALESCE(ot2.a,0) IN (SELECT a+0 FROM it3); +a a +0 0 +1 NULL +3 NULL +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 +WHERE (ot1.a,ot2.a) IN (SELECT a, a FROM it3); +a a +0 0 +6 6 +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +LEFT JOIN ot3 ON ot1.a=ot3.a +WHERE ot1.a IN (SELECT a FROM it3); +a a a +0 0 0 +3 NULL 3 +6 6 6 +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +LEFT JOIN ot3 ON ot1.a=ot3.a +WHERE COALESCE(ot2.a,0) IN (SELECT a FROM it3); +a a a +0 0 0 +1 NULL NULL +3 NULL 3 +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +LEFT JOIN ot3 ON ot1.a=ot3.a +WHERE COALESCE(ot3.a,0) IN (SELECT a FROM it3); +a a a +0 0 0 +1 NULL NULL +2 2 NULL +3 NULL 3 +4 4 NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +LEFT JOIN ot3 ON ot2.a=ot3.a +WHERE ot1.a IN (SELECT a FROM it3); +a a a +0 0 0 +3 NULL NULL +6 6 6 +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +LEFT JOIN ot3 ON ot2.a=ot3.a +WHERE COALESCE(ot2.a,0) IN (SELECT a FROM it3); +a a a +0 0 0 +1 NULL NULL +3 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +LEFT JOIN ot3 ON ot2.a=ot3.a +WHERE COALESCE(ot3.a,0) IN (SELECT a FROM it3); +a a a +0 0 0 +1 NULL NULL +2 2 NULL +3 NULL NULL +4 4 NULL +5 NULL NULL +6 6 6 +7 NULL NULL +# Test cases, Subquery Pattern 2 +# Example SQ2.1: +explain SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE it3 NULL ALL NULL NULL NULL NULL 3 100.00 Start temporary +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; End temporary +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` join `test`.`ot2` semi join (`test`.`it3`) where ((`test`.`ot1`.`a` = `test`.`it3`.`a`) and (`test`.`ot2`.`a` = `test`.`it3`.`a`)) +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3); +a a +0 0 +6 6 +# Example SQ2.2: +explain SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it2) +AND ot2.a IN (SELECT a FROM it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE it3 NULL ALL NULL NULL NULL NULL 3 100.00 Start temporary +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where +1 SIMPLE it2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` join `test`.`ot2` semi join (`test`.`it2`) semi join (`test`.`it3`) where ((`test`.`ot2`.`a` = `test`.`it3`.`a`) and (`test`.`it2`.`a` = `test`.`it3`.`a`) and (`test`.`ot1`.`a` = `test`.`it3`.`a`)) +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it2) +AND ot2.a IN (SELECT a FROM it3); +a a +0 0 +6 6 +# More test cases +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it3); +a a +0 0 +6 6 +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it3); +a a +0 0 +6 6 +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a+0 AND ot2.a IN (SELECT a FROM it3); +a a +0 0 +6 6 +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot2.a IN (SELECT a+0 FROM it3); +a a +0 0 +6 6 +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it2) +AND ot2.a IN (SELECT a+0 FROM it3); +a a +0 0 +6 6 +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3) +JOIN ot3 ON ot2.a=ot3.a AND ot3.a IN (SELECT a FROM it3); +a a a +0 0 0 +6 6 6 +# Test cases, Subquery Pattern 3 +# Example SQ3.1: +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +1 SIMPLE it3 NULL ALL NULL NULL NULL NULL 3 100.00 Using where; Start temporary; End temporary +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` semi join (`test`.`it3`)) on(((`test`.`it3`.`a` = `test`.`ot1`.`a`) and (`test`.`ot2`.`a` = `test`.`ot1`.`a`))) where true +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3); +a a +0 0 +1 NULL +2 NULL +3 NULL +4 NULL +5 NULL +6 6 +7 NULL +# Example SQ3.2: +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot2.a IN (SELECT a FROM it2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +1 SIMPLE it2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where; Start temporary; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` semi join (`test`.`it2`)) on(((`test`.`ot2`.`a` = `test`.`ot1`.`a`) and (`test`.`it2`.`a` = `test`.`ot1`.`a`))) where true +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot2.a IN (SELECT a FROM it2); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +# Example SQ3.3 +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1) +AND ot2.a IN (SELECT a FROM it2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +1 SIMPLE it2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where; Start temporary +1 SIMPLE it1 NULL ALL NULL NULL NULL NULL 8 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` semi join (`test`.`it1`) semi join (`test`.`it2`)) on(((`test`.`ot2`.`a` = `test`.`ot1`.`a`) and (`test`.`it2`.`a` = `test`.`ot1`.`a`) and (`test`.`it1`.`a` = `test`.`ot1`.`a`))) where true +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1) +AND ot2.a IN (SELECT a FROM it2); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +# Example SQ3.4 +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND +(ot1.a, ot2.a) IN (SELECT it1.a, it2.a +FROM it1 JOIN it2 ON it1.a=it2.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +1 SIMPLE it2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where; Start temporary +1 SIMPLE it1 NULL ALL NULL NULL NULL NULL 8 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` semi join (`test`.`it1` join `test`.`it2`)) on(((`test`.`ot2`.`a` = `test`.`ot1`.`a`) and (`test`.`it2`.`a` = `test`.`ot1`.`a`) and (`test`.`it1`.`a` = `test`.`ot1`.`a`))) where true +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND +(ot1.a, ot2.a) IN (SELECT it1.a, it2.a +FROM it1 JOIN it2 ON it1.a=it2.a); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +# More test cases +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it3); +a a +0 0 +1 NULL +2 NULL +3 NULL +4 NULL +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it3); +a a +0 0 +1 NULL +2 NULL +3 NULL +4 NULL +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 AND ot2.a IN (SELECT a FROM it2); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot2.a IN (SELECT a+0 FROM it2); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a+0 FROM it1) +AND ot2.a IN (SELECT a+0 FROM it2); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 AND +(ot1.a, ot2.a) IN (SELECT it1.a+0, it2.a+0 +FROM it1 JOIN it2 ON it1.a=it2.a); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +EXPLAIN FORMAT=tree SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3) +LEFT JOIN ot3 ON ot2.a=ot3.a AND ot3.a IN (SELECT a FROM it3); +EXPLAIN +-> Remove duplicate (ot1, ot2, ot3) rows using temporary table (weedout) + -> Nested loop left join (cost=117.35 rows=864) + -> Nested loop left join (cost=14.91 rows=96) + -> Table scan on ot1 (cost=1.30 rows=8) + -> Nested loop inner join (cost=6.83 rows=12) + -> Filter: (it3.a = ot1.a) (cost=1.62 rows=3) + -> Table scan on it3 (cost=1.62 rows=3) + -> Filter: (ot2.a = ot1.a) (cost=0.55 rows=4) + -> Table scan on ot2 (cost=0.55 rows=4) + -> Nested loop inner join (cost=49.53 rows=9) + -> Filter: (ot3.a = ot2.a) (cost=0.51 rows=3) + -> Table scan on ot3 (cost=0.51 rows=3) + -> Filter: (it3.a = ot2.a) (cost=1.51 rows=3) + -> Table scan on it3 (cost=1.51 rows=3) + +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3) +LEFT JOIN ot3 ON ot2.a=ot3.a AND ot3.a IN (SELECT a FROM it3); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it3) +LEFT JOIN ot3 ON ot2.a=ot3.a+0 AND ot3.a IN (SELECT a FROM it3); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +# Test cases, Subquery Pattern 4 +# Example SQ4.1: +explain SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +1 SIMPLE it1 NULL ALL NULL NULL NULL NULL 8 100.00 Using where; Start temporary; End temporary +1 SIMPLE ot3 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a`,`test`.`ot3`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` join `test`.`ot3` semi join (`test`.`it1`)) on(((`test`.`it1`.`a` = `test`.`ot1`.`a`) and (`test`.`ot3`.`a` = `test`.`ot1`.`a`) and (`test`.`ot2`.`a` = `test`.`ot1`.`a`))) where true +SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +# Example SQ4.2: +explain SELECT * +FROM ot1 +JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot3 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where +1 SIMPLE it1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; Start temporary; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a`,`test`.`ot3`.`a` AS `a` from `test`.`ot1` join `test`.`ot2` join `test`.`ot3` semi join (`test`.`it1`) where ((`test`.`ot2`.`a` = `test`.`ot3`.`a`) and (`test`.`ot1`.`a` = `test`.`ot3`.`a`) and (`test`.`it1`.`a` = `test`.`ot3`.`a`)) +SELECT * +FROM ot1 +JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +6 6 6 +# Example SQ4.3: +explain SELECT * +FROM ot1 +JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE it1 NULL ALL NULL NULL NULL NULL 8 100.00 Start temporary +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; End temporary +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where +1 SIMPLE ot3 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a`,`test`.`ot3`.`a` AS `a` from `test`.`ot1` join `test`.`ot2` left join `test`.`ot3` on((`test`.`ot3`.`a` = `test`.`it1`.`a`)) semi join (`test`.`it1`) where ((`test`.`ot1`.`a` = `test`.`it1`.`a`) and (`test`.`ot2`.`a` = `test`.`it1`.`a`)) +SELECT * +FROM ot1 +JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +2 2 NULL +4 4 NULL +6 6 6 +# Example SQ4.4: +explain SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +1 SIMPLE it1 NULL ALL NULL NULL NULL NULL 8 100.00 Using where; Start temporary; End temporary +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +1 SIMPLE ot3 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a`,`test`.`ot3`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` left join `test`.`ot3` on((`test`.`ot3`.`a` = `test`.`ot1`.`a`)) semi join (`test`.`it1`)) on(((`test`.`it1`.`a` = `test`.`ot1`.`a`) and (`test`.`ot2`.`a` = `test`.`ot1`.`a`))) where true +SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +1 NULL NULL +2 2 NULL +3 NULL NULL +4 4 NULL +5 NULL NULL +6 6 6 +7 NULL NULL +# More test cases +SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a+0) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it1); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 +JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a+0) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +6 6 6 +SELECT * +FROM ot1 +JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +6 6 6 +SELECT * +FROM ot1 +JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it1); +a a a +0 0 0 +6 6 6 +SELECT * +FROM ot1 +JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a+0) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +2 2 NULL +4 4 NULL +6 6 6 +SELECT * +FROM ot1 +JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +2 2 NULL +4 4 NULL +6 6 6 +SELECT * +FROM ot1 +JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it1); +a a a +0 0 0 +2 2 NULL +4 4 NULL +6 6 6 +SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a+0) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +1 NULL NULL +2 2 NULL +3 NULL NULL +4 4 NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +1 NULL NULL +2 2 NULL +3 NULL NULL +4 4 NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it1); +a a a +0 0 0 +1 NULL NULL +2 2 NULL +3 NULL NULL +4 4 NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1) +LEFT JOIN +ot1 AS ot4 +ON ot2.a=ot4.a; +a a a a +0 0 0 0 +1 NULL NULL NULL +2 2 NULL 2 +3 NULL NULL NULL +4 4 NULL 4 +5 NULL NULL NULL +6 6 6 6 +7 NULL NULL NULL +SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a +LEFT JOIN ot1 AS ot4 ON ot3.a=ot4.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a a +0 0 0 0 +1 NULL NULL NULL +2 2 NULL NULL +3 NULL NULL NULL +4 4 NULL NULL +5 NULL NULL NULL +6 6 6 6 +7 NULL NULL NULL +DROP TABLE ot1,ot2,ot3,it1,it2,it3; +CREATE TABLE t ( +a INTEGER DEFAULT NULL +) ENGINE=InnoDB; +INSERT INTO t VALUES (1); +CREATE TABLE t2 ( +a INTEGER DEFAULT NULL +) ENGINE=InnoDB; +INSERT INTO t2 VALUES (1),(1); +CREATE TABLE t4 ( +a INTEGER DEFAULT NULL +) ENGINE=InnoDB; +INSERT INTO t4 VALUES (1),(1); +CREATE TABLE v ( +a INTEGER DEFAULT NULL +) ENGINE=InnoDB; +INSERT INTO v VALUES (1),(1); +explain SELECT * +FROM t AS t1 +LEFT JOIN +(t2 +LEFT JOIN t AS t3 +ON t3.a IN (SELECT a FROM t AS it) +JOIN t4 +ON t4.a=100 +) +ON TRUE +WHERE t1.a IN (SELECT * FROM v AS it2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE it2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE it NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t4`.`a` AS `a` from `test`.`t` `t1` left join (`test`.`t2` left join (`test`.`t` `t3` semi join (`test`.`t` `it`)) on(((`test`.`it`.`a` = `test`.`t3`.`a`))) join `test`.`t4`) on(((`test`.`t4`.`a` = 100))) semi join (`test`.`v` `it2`) where (`test`.`it2`.`a` = `test`.`t1`.`a`) +SELECT * +FROM t AS t1 +LEFT JOIN +(t2 +LEFT JOIN t AS t3 +ON t3.a IN (SELECT a FROM t AS it) +JOIN t4 +ON t4.a=100 +) +ON TRUE +WHERE t1.a IN (SELECT * FROM v AS it2); +a a a a +1 NULL NULL NULL +DROP TABLE t,t2,t4,v; +# End of WL#5561 +# +# Bug#48868: Left outer join in subquery causes segmentation fault in +# make_join_select. +# +CREATE TABLE t1 (i INTEGER); +INSERT INTO t1 VALUES (1); +INSERT INTO t1 VALUES (2); +CREATE TABLE t2 (i INTEGER); +INSERT INTO t2 VALUES(1); +CREATE TABLE t3 (i INTEGER); +INSERT INTO t3 VALUES (1); +INSERT INTO t3 VALUES (2); +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t2.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +1 +DROP TABLE t1, t2, t3; + +Bug#37899: Wrongly checked optimization prerequisite caused failed +assertion. + +CREATE TABLE t1 ( +`pk` int(11), +`varchar_nokey` varchar(5) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES +(1,'qk'),(2,'j'),(3,'aew'); +SELECT * +FROM t1 +WHERE varchar_nokey IN ( +SELECT +varchar_nokey +FROM +t1 +) XOR pk = 30; +pk varchar_nokey +1 qk +2 j +3 aew +drop table t1; +# +# BUG#41842: Semi-join materialization strategy crashes when the upper query has HAVING +# +CREATE TABLE t1 ( +pk int(11) NOT NULL AUTO_INCREMENT, +int_nokey int(11) NOT NULL, +time_key time NOT NULL, +datetime_key datetime NOT NULL, +datetime_nokey datetime NOT NULL, +varchar_key varchar(1) NOT NULL, +varchar_nokey varchar(1) NOT NULL, +PRIMARY KEY (pk), +KEY time_key (time_key), +KEY datetime_key (datetime_key), +KEY varchar_key (varchar_key) +) ENGINE=MyISaM; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES +(1,0, '00:16:10','2008-09-03 14:25:40','2008-09-03 14:25:40','h','h'), +(2,7, '00:00:00','2001-01-13 00:00:00','2001-01-13 00:00:00','',''), +(3,0, '00:00:00','0000-00-00 00:00:00','0000-00-00 00:00:00','x','x'), +(4,2, '16:29:24','2000-10-16 01:39:08','2000-10-16 01:39:08','w','w'), +(5,1, '09:23:32','0000-00-00 00:00:00','0000-00-00 00:00:00','p','p'), +(6,3, '00:00:00','2007-12-02 00:00:00','2007-12-02 00:00:00','o','o'), +(7,3, '00:00:00','2008-09-11 00:00:00','2008-09-11 00:00:00','',''), +(8,0, '13:59:04','0000-00-00 00:00:00','0000-00-00 00:00:00','s','s'), +(9,7, '09:01:06','0000-00-00 00:00:00','0000-00-00 00:00:00','d','d'), +(10,5,'00:00:00','0000-00-00 00:00:00','0000-00-00 00:00:00','n','n'), +(11,0,'21:06:46','0000-00-00 00:00:00','0000-00-00 00:00:00','o','o'), +(12,2,'00:00:00','0000-00-00 00:00:00','0000-00-00 00:00:00','',''), +(13,6,'14:45:34','2003-07-28 02:34:08','2003-07-28 02:34:08','w','w'), +(14,1,'15:04:12','0000-00-00 00:00:00','0000-00-00 00:00:00','o','o'), +(15,0,'00:00:00','0000-00-00 00:00:00','0000-00-00 00:00:00','x','x'), +(16,0,'15:55:23','2004-03-17 00:32:27','2004-03-17 00:32:27','p','p'), +(17,1,'16:30:00','2004-12-27 19:20:00','2004-12-27 19:20:00','d','d'), +(18,0,'00:00:00','0000-00-00 00:00:00','0000-00-00 00:00:00','h','h'), +(19,0,'14:13:26','2008-11-09 05:53:48','2008-11-09 05:53:48','o','o'), +(20,0,'00:00:00','2009-10-11 06:58:04','2009-10-11 06:58:04','k','k'); +Warnings: +Warning 1264 Out of range value for column 'datetime_key' at row 3 +Warning 1264 Out of range value for column 'datetime_nokey' at row 3 +Warning 1264 Out of range value for column 'datetime_key' at row 5 +Warning 1264 Out of range value for column 'datetime_nokey' at row 5 +Warning 1264 Out of range value for column 'datetime_key' at row 8 +Warning 1264 Out of range value for column 'datetime_nokey' at row 8 +Warning 1264 Out of range value for column 'datetime_key' at row 9 +Warning 1264 Out of range value for column 'datetime_nokey' at row 9 +Warning 1264 Out of range value for column 'datetime_key' at row 10 +Warning 1264 Out of range value for column 'datetime_nokey' at row 10 +Warning 1264 Out of range value for column 'datetime_key' at row 11 +Warning 1264 Out of range value for column 'datetime_nokey' at row 11 +Warning 1264 Out of range value for column 'datetime_key' at row 12 +Warning 1264 Out of range value for column 'datetime_nokey' at row 12 +Warning 1264 Out of range value for column 'datetime_key' at row 14 +Warning 1264 Out of range value for column 'datetime_nokey' at row 14 +Warning 1264 Out of range value for column 'datetime_key' at row 15 +Warning 1264 Out of range value for column 'datetime_nokey' at row 15 +Warning 1264 Out of range value for column 'datetime_key' at row 18 +Warning 1264 Out of range value for column 'datetime_nokey' at row 18 +CREATE TABLE t2 ( +pk int(11) NOT NULL AUTO_INCREMENT, +int_nokey int(11) NOT NULL, +time_key time NOT NULL, +datetime_key datetime NOT NULL, +datetime_nokey datetime NOT NULL, +varchar_key varchar(1) NOT NULL, +varchar_nokey varchar(1) NOT NULL, +PRIMARY KEY (pk), +KEY time_key (time_key), +KEY datetime_key (datetime_key), +KEY varchar_key (varchar_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT IGNORE INTO t2 VALUES +(10,0,'19:39:13','0000-00-00 00:00:00','0000-00-00 00:00:00','g','g'), +(11,8,'03:43:53','0000-00-00 00:00:00','0000-00-00 00:00:00','b','b'); +Warnings: +Warning 1264 Out of range value for column 'datetime_key' at row 1 +Warning 1264 Out of range value for column 'datetime_nokey' at row 1 +Warning 1264 Out of range value for column 'datetime_key' at row 2 +Warning 1264 Out of range value for column 'datetime_nokey' at row 2 +SELECT OUTR.datetime_nokey AS X FROM t1 AS OUTR +WHERE +OUTR.varchar_nokey IN (SELECT +INNR . varchar_nokey AS Y +FROM t2 AS INNR +WHERE +INNR . datetime_key >= INNR . time_key OR +INNR . pk = INNR . int_nokey +) +AND OUTR . varchar_nokey <= 'w' +HAVING X > '2012-12-12'; +X +drop table t1, t2; + +Bug#46797 "Crash in fix_semijoin_strategies_for_picked_join_order +with semijoin=on" + +CREATE TABLE t1 ( +varchar_key varchar(1) DEFAULT NULL, +KEY varchar_key (varchar_key) +); +CREATE TABLE t2 ( +varchar_key varchar(1) DEFAULT NULL, +KEY varchar_key (varchar_key) +); +INSERT INTO t2 VALUES +(NULL),(NULL),(NULL),(NULL),('a'),('a'),('a'),('b'),('b'),('b'),('b'),('c'), +('c'),('c'),('c'),('c'),('c'),('c'),('d'),('d'),('d'),('d'),('d'),('d'),('e'), +('e'),('e'),('e'),('e'),('e'),('f'),('f'),('f'),('g'),('g'),('h'),('h'),('h'), +('h'),('i'),('j'),('j'),('j'),('k'),('k'),('l'),('l'),('m'),('m'),('m'),('m'), +('n'),('n'),('n'),('o'),('o'),('o'),('p'),('p'),('p'),('q'),('q'),('q'),('r'), +('r'),('r'),('r'),('s'),('s'),('s'),('s'),('t'),('t'),('t'),('t'),('u'),('u'), +('u'),('u'),('v'),('v'),('v'),('v'),('w'),('w'),('w'),('w'),('w'),('w'),('x'), +('x'),('x'),('y'),('y'),('y'),('y'),('z'),('z'),('z'),('z'); +CREATE TABLE t3 ( +varchar_key varchar(1) DEFAULT NULL, +KEY varchar_key (varchar_key) +) ENGINE=MyISAM DEFAULT CHARSET=latin1; +INSERT INTO t3 VALUES +(NULL),('c'),('d'),('e'),('f'),('h'),('j'),('k'),('k'),('m'),('m'),('m'), +('n'),('o'),('r'),('t'),('t'),('u'),('w'),('y'); +SELECT varchar_key FROM t3 +WHERE (SELECT varchar_key FROM t3 +WHERE (varchar_key,varchar_key) +IN (SELECT t1.varchar_key, t2 .varchar_key +FROM t1 RIGHT JOIN t2 ON t1.varchar_key +) +); +varchar_key +DROP TABLE t1, t2, t3; +# +# Bug#46556 Returning incorrect, empty results for some IN subqueries +# w/semijoin=on +# +CREATE TABLE t0 ( +pk INTEGER, +vkey VARCHAR(1), +vnokey VARCHAR(1), +PRIMARY KEY (pk), +KEY vkey(vkey) +) charset utf8mb4; +INSERT INTO t0 +VALUES (1,'g','g'), (2,'v','v'), (3,'t','t'), (4,'u','u'), (5,'n','n'); +EXPLAIN SELECT vkey FROM t0 WHERE pk IN +(SELECT t1.pk FROM t0 t1 JOIN t0 t2 ON t2.vkey = t1.vnokey); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL ALL PRIMARY NULL NULL NULL 5 100.00 NULL +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t0.pk 1 100.00 Using where +1 SIMPLE t2 NULL ref vkey vkey 7 test.t1.vnokey 2 100.00 Using index; Start temporary; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`vkey` AS `vkey` from `test`.`t0` `t1` join `test`.`t0` semi join (`test`.`t0` `t2`) where ((`test`.`t2`.`vkey` = `test`.`t1`.`vnokey`) and (`test`.`t1`.`pk` = `test`.`t0`.`pk`)) +SELECT vkey FROM t0 WHERE pk IN +(SELECT t1.pk FROM t0 t1 JOIN t0 t2 ON t2.vkey = t1.vnokey); +vkey +g +n +t +u +v +DROP TABLE t0; +# End of bug#46556 + +Bug#48834: Procedure with view + subquery + semijoin=on +crashes on second call. + +CREATE TABLE t1 ( t1field integer, primary key (t1field)); +CREATE TABLE t2 ( t2field integer, primary key (t2field)); +CREATE VIEW v1 AS +SELECT t1field as v1field +FROM t1 A +WHERE A.t1field IN (SELECT t1field FROM t2 ); +CREATE VIEW v2 AS +SELECT t2field as v2field +FROM t2 A +WHERE A.t2field IN (SELECT t2field FROM t2 ); +CREATE PROCEDURE p1 () +BEGIN +SELECT v1field +FROM v1 +WHERE v1field IN ( SELECT v2field as vf_inner FROM v2 ); +END| +INSERT INTO t1 VALUES (1),(2),(3); +INSERT INTO t2 VALUES (2),(3),(4); +CALL p1; +v1field +2 +3 +CALL p1; +v1field +2 +3 +DROP TABLE t1,t2; +DROP VIEW v1,v2; +DROP PROCEDURE p1; +# End of BUG#48834 +# +# Bug#46692 "Crash occurring on queries with nested FROM subqueries +# using materialization." +# +CREATE TABLE t1 ( +pk INTEGER PRIMARY KEY, +int_key INTEGER, +KEY int_key(int_key) +); +INSERT INTO t1 VALUES (10,186),(11,NULL),(12,2),(13,3),(14,0),(15,133),(16,1); +CREATE TABLE t2 ( +pk INTEGER PRIMARY KEY, +int_key INTEGER, +KEY int_key(int_key) +); +INSERT INTO t2 VALUES (1,7),(2,2); +SELECT * FROM t1 WHERE (140, 4) IN +(SELECT t2.int_key, t2 .pk FROM t2 STRAIGHT_JOIN t1 ON t2.int_key); +pk int_key +DROP TABLE t1, t2; +# +# Bug#42353 "SELECT ... WHERE oe IN (SELECT w/ LEFT JOIN) query +# causes crash." +# +CREATE TABLE t1 ( +pk INTEGER PRIMARY KEY, +int_nokey INTEGER, +int_key INTEGER, +date_key DATE, +datetime_nokey DATETIME, +varchar_nokey VARCHAR(1) +); +CREATE TABLE t2 ( +date_nokey DATE +); +CREATE TABLE t3 ( +pk INTEGER PRIMARY KEY, +int_nokey INTEGER, +date_key date, +varchar_key VARCHAR(1), +varchar_nokey VARCHAR(1), +KEY date_key (date_key) +); +SELECT date_key FROM t1 +WHERE (int_key, int_nokey) +IN (SELECT t3.int_nokey, t3.pk +FROM t2 LEFT JOIN t3 ON (t2.date_nokey < t3.date_key) +WHERE t3.varchar_key <= t3.varchar_nokey OR t3.int_nokey <= t3.pk +) +AND (varchar_nokey <> 'f' OR NOT int_key < 7); +date_key +# +# Bug#45933 "Crash in optimize_semijoin_nests on JOIN in subquery +# + AND in outer query". +# +INSERT INTO t1 VALUES (10,7,5,'2009-06-16','2002-04-10 14:25:30','w'), +(11,7,0,'0000-00-00','0000-00-00 00:00:00','s'), +(12,4,0,'2003-07-14','2006-09-14 04:01:02','y'), +(13,0,4,'2002-07-25','0000-00-00 00:00:00','c'), +(14,1,8,'2007-07-03','0000-00-00 00:00:00','q'), +(15,6,5,'2001-11-12','0000-00-00 00:00:00',''), +(16,2,9,'0000-00-00','0000-00-00 00:00:00','j'), +(29,9,1,'0000-00-00','2003-08-11 00:00:00','m'); +Warnings: +Warning 1264 Out of range value for column 'date_key' at row 2 +Warning 1264 Out of range value for column 'datetime_nokey' at row 2 +Warning 1264 Out of range value for column 'datetime_nokey' at row 4 +Warning 1264 Out of range value for column 'datetime_nokey' at row 5 +Warning 1264 Out of range value for column 'datetime_nokey' at row 6 +Warning 1264 Out of range value for column 'date_key' at row 7 +Warning 1264 Out of range value for column 'datetime_nokey' at row 7 +Warning 1264 Out of range value for column 'date_key' at row 8 +INSERT IGNORE INTO t3 VALUES (1,9,'0000-00-00','b','b'), +(2,2,'2002-09-17','h','h'); +Warnings: +Warning 1264 Out of range value for column 'date_key' at row 1 +SELECT t1.varchar_nokey FROM t1 JOIN t3 ON t1.datetime_nokey +WHERE t1.varchar_nokey +IN (SELECT varchar_nokey FROM t1 +WHERE (pk) +IN (SELECT t3.int_nokey +FROM t3 LEFT JOIN t1 ON t1.varchar_nokey +WHERE t3.date_key BETWEEN '2008-06-07' AND '2006-06-26' + ) +); +varchar_nokey +DROP TABLE t1, t2, t3; +# +# Bug#45219 "Crash on SELECT DISTINCT query containing a +# LEFT JOIN in subquery" +# +CREATE TABLE t1 ( +pk INTEGER NOT NULL, +int_nokey INTEGER NOT NULL, +datetime_key DATETIME NOT NULL, +varchar_key VARCHAR(1) NOT NULL, +PRIMARY KEY (pk), +KEY datetime_key (datetime_key), +KEY varchar_key (varchar_key) +); +INSERT IGNORE INTO t1 VALUES +(1,9,'0000-00-00 00:00:00','p'),(2,0,'2002-02-09 07:38:13','v'), +(3,8,'2001-05-03 12:08:14','t'),(4,3,'0000-00-00 00:00:00','u'), +(5,7,'2009-07-28 03:43:30','n'),(6,0,'2009-08-04 00:00:00','l'), +(7,1,'0000-00-00 00:00:00','h'),(8,9,'0000-00-00 00:00:00','u'), +(9,0,'2005-08-02 17:16:54','n'),(10,9,'2002-12-21 00:00:00','j'), +(11,0,'2005-08-15 12:37:35','k'),(12,5,'0000-00-00 00:00:00','e'), +(13,0,'2006-03-10 00:00:00','i'),(14,8,'2005-05-16 11:02:36','u'), +(15,8,'2008-11-02 00:00:00','n'),(16,5,'2006-03-15 00:00:00','b'), +(17,1,'0000-00-00 00:00:00','x'),(18,7,'0000-00-00 00:00:00',''), +(19,0,'2008-12-17 20:15:40','q'),(20,9,'0000-00-00 00:00:00','u'); +Warnings: +Warning 1264 Out of range value for column 'datetime_key' at row 1 +Warning 1264 Out of range value for column 'datetime_key' at row 4 +Warning 1264 Out of range value for column 'datetime_key' at row 7 +Warning 1264 Out of range value for column 'datetime_key' at row 8 +Warning 1264 Out of range value for column 'datetime_key' at row 12 +Warning 1264 Out of range value for column 'datetime_key' at row 17 +Warning 1264 Out of range value for column 'datetime_key' at row 18 +Warning 1264 Out of range value for column 'datetime_key' at row 20 +CREATE TABLE t2 LIKE t1; +INSERT INTO t2 VALUES +(10,0,'2006-07-07 07:26:28','q'),(11,5,'2002-09-23 00:00:00','m'), +(12,7,'0000-00-00 00:00:00','j'),(13,1,'2006-06-07 00:00:00','z'), +(14,8,'2000-09-16 12:15:34','a'),(15,2,'2007-08-05 15:47:52',''), +(16,1,'0000-00-00 00:00:00','e'),(17,8,'2005-12-02 19:34:26','t'), +(18,5,'0000-00-00 00:00:00','q'),(19,4,'0000-00-00 00:00:00','b'), +(20,5,'2007-12-28 00:00:00','w'),(21,3,'2004-08-02 11:48:43','m'), +(22,0,'0000-00-00 00:00:00','x'),(23,8,'2004-04-19 12:18:43',''), +(24,0,'2009-04-27 00:00:00','w'),(25,4,'2006-10-20 14:52:15','x'), +(26,0,'0000-00-00 00:00:00','e'),(27,0,'2002-03-22 11:48:37','e'), +(28,2,'0000-00-00 00:00:00','p'),(29,0,'2001-01-04 03:55:07','x'); +Warnings: +Warning 1264 Out of range value for column 'datetime_key' at row 3 +Warning 1264 Out of range value for column 'datetime_key' at row 7 +Warning 1264 Out of range value for column 'datetime_key' at row 9 +Warning 1264 Out of range value for column 'datetime_key' at row 10 +Warning 1264 Out of range value for column 'datetime_key' at row 13 +Warning 1264 Out of range value for column 'datetime_key' at row 17 +Warning 1264 Out of range value for column 'datetime_key' at row 19 +CREATE TABLE t3 LIKE t1; +INSERT INTO t3 VALUES +(10,8,'2007-08-19 08:08:38','i'),(11,0,'2000-05-21 03:51:51',''); +SELECT DISTINCT datetime_key FROM t1 +WHERE (int_nokey, pk) +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#46550 Azalea returning duplicate results for some IN subqueries +# w/ semijoin=on +# +DROP TABLE IF EXISTS t0, t1, t2; +CREATE TABLE t0 ( +int_key int(11) DEFAULT NULL, +varchar_key varchar(1) DEFAULT NULL, +varchar_nokey varchar(1) DEFAULT NULL, +KEY int_key (int_key), +KEY varchar_key (varchar_key,int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t0 VALUES +(1,'m','m'), +(40,'h','h'), +(1,'r','r'), +(1,'h','h'), +(9,'x','x'), +(NULL,'q','q'), +(NULL,'k','k'), +(7,'l','l'), +(182,'k','k'), +(202,'a','a'), +(7,'x','x'), +(6,'j','j'), +(119,'z','z'), +(4,'d','d'), +(5,'h','h'), +(1,'u','u'), +(3,'q','q'), +(7,'a','a'), +(3,'e','e'), +(6,'l','l'); +CREATE TABLE t1 ( +int_key int(11) DEFAULT NULL, +varchar_key varchar(1) DEFAULT NULL, +varchar_nokey varchar(1) DEFAULT NULL, +KEY int_key (int_key), +KEY varchar_key (varchar_key,int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (7,NULL,NULL),(4,'x','x'); +CREATE TABLE t2 ( +int_key int(11) DEFAULT NULL, +varchar_key varchar(1) DEFAULT NULL, +varchar_nokey varchar(1) DEFAULT NULL, +KEY int_key (int_key), +KEY varchar_key (varchar_key,int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (123,NULL,NULL); +SELECT int_key +FROM t0 +WHERE varchar_nokey IN ( +SELECT t1 .varchar_key from t1 +); +int_key +7 +9 +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 +7 +9 +EXPLAIN +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 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1_1 NULL index varchar_key varchar_key 12 NULL 2 50.00 Using where; Using index; LooseScan +1 SIMPLE t1_2 NULL index NULL int_key 5 NULL 2 100.00 Using index; FirstMatch(t1_1) +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 20 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`int_key` AS `int_key` from `test`.`t0` semi join (`test`.`t1` `t1_1` join `test`.`t1` `t1_2`) where ((`test`.`t0`.`varchar_nokey` = `test`.`t1_1`.`varchar_key`) and (0 <> `test`.`t1_1`.`int_key`)) +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 +7 +9 +EXPLAIN +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 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t1_1 NULL index varchar_key varchar_key 12 NULL 2 50.00 Using where; Using index; LooseScan +1 SIMPLE t1_2 NULL index NULL int_key 5 NULL 2 100.00 Using index; FirstMatch(t1_1) +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 20 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`int_key` AS `int_key` from `test`.`t0` semi join (`test`.`t1` `t1_1` join `test`.`t1` `t1_2`) where ((`test`.`t0`.`varchar_nokey` = `test`.`t1_1`.`varchar_key`) and (0 <> `test`.`t1_1`.`int_key`)) +DROP TABLE t0, t1, t2; +# End of bug#46550 + +Bug #48073 Subquery on char columns from view crashes Mysql + +DROP TABLE IF EXISTS t1, t2; +DROP VIEW IF EXISTS v1; +CREATE TABLE t1 ( +city VARCHAR(50) NOT NULL, +country_id SMALLINT UNSIGNED NOT NULL +); +INSERT INTO t1 VALUES +('Batna',2), +('Bchar',2), +('Skikda',2), +('Tafuna',3), +('Algeria',2) ; +CREATE TABLE t2 ( +country_id SMALLINT UNSIGNED NOT NULL, +country VARCHAR(50) NOT NULL +); +INSERT INTO t2 VALUES +(2,'Algeria'), +(3,'American Samoa') ; +CREATE VIEW v1 AS +SELECT country_id, country +FROM t2 +WHERE LEFT(country,1) = "A" +; +SELECT city, country_id +FROM t1 +WHERE city IN ( +SELECT country +FROM t2 +WHERE LEFT(country, 1) = "A" +); +city country_id +Algeria 2 +SELECT city, country_id +FROM t1 +WHERE city IN ( +SELECT country +FROM v1 +); +city country_id +Algeria 2 +drop table t1, t2; +drop view v1; +# End of bug#48073 + +Bug#49097 subquery with view generates wrong result with +non-prepared statement + +DROP TABLE IF EXISTS t1, t2; +DROP VIEW IF EXISTS v1; +CREATE TABLE t1 ( +city VARCHAR(50) NOT NULL, +country_id SMALLINT UNSIGNED NOT NULL +); +INSERT INTO t1 VALUES +('Batna',2), +('Bchar',2), +('Skikda',2), +('Tafuna',3), +('Algeria',2) ; +CREATE TABLE t2 ( +country_id SMALLINT UNSIGNED NOT NULL, +country VARCHAR(50) NOT NULL +); +INSERT INTO t2 VALUES +(2,'Algeria'), +(3,'XAmerican Samoa') ; +CREATE VIEW v1 AS +SELECT country_id, country +FROM t2 +WHERE LEFT(country,1) = "A" +; +SELECT city, country_id +FROM t1 +WHERE country_id IN ( +SELECT country_id +FROM t2 +WHERE LEFT(country,1) = "A" +); +city country_id +Algeria 2 +Batna 2 +Bchar 2 +Skikda 2 +SELECT city, country_id +FROM t1 +WHERE country_id IN ( +SELECT country_id +FROM v1 +); +city country_id +Algeria 2 +Batna 2 +Bchar 2 +Skikda 2 +PREPARE stmt FROM +" +SELECT city, country_id +FROM t1 +WHERE country_id IN ( + SELECT country_id + FROM v1 +); +"; +execute stmt; +city country_id +Algeria 2 +Batna 2 +Bchar 2 +Skikda 2 +deallocate prepare stmt; +drop table t1, t2; +drop view v1; +# End of Bug#49097 +# +# Bug#49198 Wrong result for second call of procedure +# with view in subselect. +# +CREATE TABLE t1 (t1field integer, primary key (t1field)); +CREATE TABLE t2 (t2field integer, primary key (t2field)); +CREATE TABLE t3 (t3field integer, primary key (t3field)); +CREATE VIEW v2 AS SELECT * FROM t2; +CREATE VIEW v3 AS SELECT * FROM t3; +INSERT INTO t1 VALUES(1),(2); +INSERT INTO t2 VALUES(1),(2); +INSERT INTO t3 VALUES(1),(2); +PREPARE stmt FROM +" +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT * FROM v2); +"; +EXECUTE stmt; +t1field +1 +2 + +EXECUTE stmt; +t1field +1 +2 +PREPARE stmt FROM +" +EXPLAIN +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT * FROM v2) + AND t1field IN (SELECT * FROM v3) +"; +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index PRIMARY PRIMARY 4 NULL 2 100.00 Using index +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +1 SIMPLE t3 NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`t1field` AS `t1field` from `test`.`t2` join `test`.`t3` join `test`.`t1` where ((`test`.`t2`.`t2field` = `test`.`t1`.`t1field`) and (`test`.`t3`.`t3field` = `test`.`t1`.`t1field`)) + +This line is only in place to help --skip_if_hypergraph diffing some more. + +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index PRIMARY PRIMARY 4 NULL 2 100.00 Using index +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +1 SIMPLE t3 NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`t1field` AS `t1field` from `test`.`t2` join `test`.`t3` join `test`.`t1` where ((`test`.`t2`.`t2field` = `test`.`t1`.`t1field`) and (`test`.`t3`.`t3field` = `test`.`t1`.`t1field`)) +DROP TABLE t1, t2, t3; +DROP VIEW v2, v3; +# End of Bug#49198 +# +# Bug#48623 Multiple subqueries are optimized incorrectly +# +CREATE TABLE ot(val VARCHAR(10)) charset utf8mb4; +CREATE TABLE it1(val VARCHAR(10)) charset utf8mb4; +CREATE TABLE it2(val VARCHAR(10)) charset utf8mb4; +INSERT INTO ot VALUES('aaa'), ('bbb'), ('eee'), ('mmm'), ('ppp'); +INSERT INTO it1 VALUES('aaa'), ('aaa'), ('bbb'), ('eee'), ('mmm'), ('ppp'); +INSERT INTO it2 VALUES('aaa'), ('bbb'), ('eee'), ('mmm'), ('ppp'); +EXPLAIN +SELECT * +FROM ot +WHERE ot.val IN (SELECT it1.val FROM it1 +WHERE it1.val LIKE 'a%' OR it1.val LIKE 'e%') +AND ot.val IN (SELECT it2.val FROM it2 +WHERE it2.val LIKE 'a%' OR it2.val LIKE 'e%'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE it2 NULL ALL NULL NULL NULL NULL 5 36.00 Using where; Start temporary +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 5 20.00 Using where +1 SIMPLE it1 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`ot`.`val` AS `val` from `test`.`ot` semi join (`test`.`it1`) semi join (`test`.`it2`) where ((`test`.`ot`.`val` = `test`.`it2`.`val`) and (`test`.`it1`.`val` = `test`.`it2`.`val`) and ((`test`.`it1`.`val` like 'a%') or (`test`.`it1`.`val` like 'e%')) and ((`test`.`it2`.`val` like 'a%') or (`test`.`it2`.`val` like 'e%'))) +SELECT * +FROM ot +WHERE ot.val IN (SELECT it1.val FROM it1 +WHERE it1.val LIKE 'a%' OR it1.val LIKE 'e%') +AND ot.val IN (SELECT it2.val FROM it2 +WHERE it2.val LIKE 'a%' OR it2.val LIKE 'e%'); +val +aaa +eee +DROP TABLE ot; +DROP TABLE it1; +DROP TABLE it2; +# End of Bug#48623 +# +# Bug #51487 Assertion failure when semi-join flattening occurs +# for a subquery in HAVING +# +CREATE TABLE t1 (a INT, b INT); +INSERT INTO t1 VALUES (1,10),(2,11),(1,13); +CREATE TABLE t2 AS SELECT * FROM t1; +CREATE TABLE t3 AS SELECT * FROM t1; +SELECT COUNT(*) FROM t1 +GROUP BY t1.a +HAVING t1.a IN (SELECT t3.a FROM t3 +WHERE t3.b IN (SELECT b FROM t2 WHERE t2.a=t1.a)); +COUNT(*) +2 +1 +DROP TABLE t1, t2, t3; +# End of Bug#51487 +# +# BUG#38075: Wrong result: rows matching a subquery with outer join not returned +# +DROP TABLE IF EXISTS ot1, it1, it2; +CREATE TABLE it2 ( +int_key int(11) NOT NULL, +datetime_key datetime NOT NULL, +KEY int_key (int_key), +KEY datetime_key (datetime_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO it2 VALUES +(5,'2002-04-10 14:25:30'), (0,'0000-00-00 00:00:00'), +(0,'2006-09-14 04:01:02'), (4,'0000-00-00 00:00:00'), +(8,'0000-00-00 00:00:00'), (5,'0000-00-00 00:00:00'), +(9,'0000-00-00 00:00:00'), (8,'2007-04-01 11:04:17'), +(1,'0000-00-00 00:00:00'), (7,'2009-01-12 00:00:00'), +(0,'2009-06-05 00:00:00'), (3,'2006-02-14 18:06:35'), +(5,'2006-02-21 07:08:16'), (0,'0000-00-00 00:00:00'), +(7,'0000-00-00 00:00:00'), (0,'0000-00-00 00:00:00'), +(0,'2007-02-13 00:00:00'), (1,'0000-00-00 00:00:00'), +(0,'0000-00-00 00:00:00'), (1,'2003-08-11 00:00:00'); +Warnings: +Warning 1264 Out of range value for column 'datetime_key' at row 2 +Warning 1264 Out of range value for column 'datetime_key' at row 4 +Warning 1264 Out of range value for column 'datetime_key' at row 5 +Warning 1264 Out of range value for column 'datetime_key' at row 6 +Warning 1264 Out of range value for column 'datetime_key' at row 7 +Warning 1264 Out of range value for column 'datetime_key' at row 9 +Warning 1264 Out of range value for column 'datetime_key' at row 14 +Warning 1264 Out of range value for column 'datetime_key' at row 15 +Warning 1264 Out of range value for column 'datetime_key' at row 16 +Warning 1264 Out of range value for column 'datetime_key' at row 18 +Warning 1264 Out of range value for column 'datetime_key' at row 19 +CREATE TABLE ot1 ( +int_nokey int(11) NOT NULL, +int_key int(11) NOT NULL, +KEY int_key (int_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO ot1 VALUES +(5,0), (3,0), (0,2), (3,0), (1,3), (0,0), (1,7), (7,0), (1,7), (0,7), +(0,9), (8,2), (4,4), (9,3), (0,9), (2,5), (0,5), (8,0), (5,8), (1,5); +CREATE TABLE it1 ( +int_nokey int(11) NOT NULL, +int_key int(11) NOT NULL, +KEY int_key (int_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO it1 VALUES +(9,5), (0,4); +SELECT int_key FROM ot1 +WHERE int_nokey IN (SELECT it2.int_key +FROM it1 LEFT JOIN it2 ON it2.datetime_key); +int_key +0 +0 +0 +0 +0 +0 +2 +2 +3 +5 +5 +7 +7 +7 +8 +9 +9 +EXPLAIN +SELECT int_key FROM ot1 +WHERE int_nokey IN (SELECT it2.int_key +FROM it1 LEFT JOIN it2 ON it2.datetime_key); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE it1 NULL index NULL int_key 4 NULL 2 100.00 Using index; Start temporary +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 20 100.00 NULL +1 SIMPLE it2 NULL ref int_key int_key 4 test.ot1.int_nokey 2 90.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`int_key` AS `int_key` from `test`.`ot1` semi join (`test`.`it1` join `test`.`it2`) where ((`test`.`it2`.`int_key` = `test`.`ot1`.`int_nokey`) and (TIMESTAMP'0000-00-00 00:00:00' <> `test`.`it2`.`datetime_key`)) +DROP TABLE ot1, it1, it2; +# End of BUG#38075 +# +# BUG#50089: Second call of procedure with view in subselect crashes server +# +CREATE TABLE t1(t1field INTEGER, PRIMARY KEY(t1field)); +CREATE VIEW v1 AS +SELECT t1field AS v1field +FROM t1 a +WHERE a.t1field IN (SELECT t1field FROM t1); +INSERT INTO t1 VALUES(1),(2); +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT v1field FROM v1); +t1field +1 +2 +EXPLAIN +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT v1field FROM v1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index PRIMARY PRIMARY 4 NULL 2 100.00 Using index +1 SIMPLE a NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `t1`.`t1field` AS `t1field` from `test`.`t1` `a` join `test`.`t1` join `test`.`t1` where ((`test`.`a`.`t1field` = `t1`.`t1field`) and (`test`.`t1`.`t1field` = `t1`.`t1field`)) +SELECT t1.t1field +FROM t1 LEFT JOIN t1 AS t2 ON t1.t1field IN (SELECT v1field FROM v1); +t1field +1 +1 +2 +2 +EXPLAIN +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT v1field FROM v1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index PRIMARY PRIMARY 4 NULL 2 100.00 Using index +1 SIMPLE a NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `t1`.`t1field` AS `t1field` from `test`.`t1` `a` join `test`.`t1` join `test`.`t1` where ((`test`.`a`.`t1field` = `t1`.`t1field`) and (`test`.`t1`.`t1field` = `t1`.`t1field`)) +CREATE PROCEDURE p1() +BEGIN +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT v1field FROM v1); +END| +CALL p1; +t1field +1 +2 +CALL p1; +t1field +1 +2 +PREPARE stmt FROM +" +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT v1field FROM v1); +"; +EXECUTE stmt; +t1field +1 +2 + +EXECUTE stmt; +t1field +1 +2 +DROP PROCEDURE p1; +DROP VIEW v1; +DROP TABLE t1; +# End of BUG#50089 +# +# Bug#45191: Incorrectly initialized semi-join led to a wrong result. +# +CREATE TABLE staff (EMPNUM CHAR(3) NOT NULL, +EMPNAME CHAR(20), GRADE DECIMAL(4), CITY CHAR(15)) charset latin1; +CREATE TABLE proj (PNUM CHAR(3) NOT NULL, +PNAME CHAR(20), PTYPE CHAR(6), +BUDGET DECIMAL(9), +CITY CHAR(15)) charset latin1; +CREATE TABLE works (EMPNUM CHAR(3) NOT NULL, +PNUM CHAR(3) NOT NULL, HOURS DECIMAL(5)) charset latin1; +INSERT INTO staff VALUES ('E1','Alice',12,'Deale'); +INSERT INTO staff VALUES ('E2','Betty',10,'Vienna'); +INSERT INTO staff VALUES ('E3','Carmen',13,'Vienna'); +INSERT INTO staff VALUES ('E4','Don',12,'Deale'); +INSERT INTO staff VALUES ('E5','Ed',13,'Akron'); +INSERT INTO proj VALUES ('P1','MXSS','Design',10000,'Deale'); +INSERT INTO proj VALUES ('P2','CALM','Code',30000,'Vienna'); +INSERT INTO proj VALUES ('P3','SDP','Test',30000,'Tampa'); +INSERT INTO proj VALUES ('P4','SDP','Design',20000,'Deale'); +INSERT INTO proj VALUES ('P5','IRM','Test',10000,'Vienna'); +INSERT INTO proj VALUES ('P6','PAYR','Design',50000,'Deale'); +INSERT INTO works VALUES ('E1','P1',40); +INSERT INTO works VALUES ('E1','P2',20); +INSERT INTO works VALUES ('E1','P3',80); +INSERT INTO works VALUES ('E1','P4',20); +INSERT INTO works VALUES ('E1','P5',12); +INSERT INTO works VALUES ('E1','P6',12); +INSERT INTO works VALUES ('E2','P1',40); +INSERT INTO works VALUES ('E2','P2',80); +INSERT INTO works VALUES ('E3','P2',20); +INSERT INTO works VALUES ('E4','P2',20); +INSERT INTO works VALUES ('E4','P4',40); +INSERT INTO works VALUES ('E4','P5',80); +explain SELECT EMPNUM, EMPNAME +FROM staff +WHERE EMPNUM IN +(SELECT EMPNUM FROM works +WHERE PNUM IN +(SELECT PNUM FROM proj)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE staff NULL ALL NULL NULL NULL NULL 5 100.00 NULL +1 SIMPLE works NULL ALL NULL NULL NULL NULL 12 10.00 Using where; Start temporary +1 SIMPLE proj NULL ALL NULL NULL NULL NULL 6 16.67 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`staff`.`EMPNUM` AS `EMPNUM`,`test`.`staff`.`EMPNAME` AS `EMPNAME` from `test`.`staff` semi join (`test`.`works` join `test`.`proj`) where ((`test`.`works`.`EMPNUM` = `test`.`staff`.`EMPNUM`) and (`test`.`proj`.`PNUM` = `test`.`works`.`PNUM`)) +SELECT EMPNUM, EMPNAME +FROM staff +WHERE EMPNUM IN +(SELECT EMPNUM FROM works +WHERE PNUM IN +(SELECT PNUM FROM proj)); +EMPNUM EMPNAME +E1 Alice +E2 Betty +E3 Carmen +E4 Don +drop table staff,works,proj; +# End of bug#45191 +# +# BUG#36896: Server crash on SELECT FROM DUAL +# +create table t1 (a int); +select 1 as res from dual where (1) in (select * from t1); +res +drop table t1; + +BUG#40118 Crash when running Batched Key Access and requiring one match for each key + +create table t0(a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (a int, key(a)); +insert into t1 select * from t0; +alter table t1 add b int not null, add filler char(200); +insert into t1 select * from t1; +insert into t1 select * from t1; +select * from t0 where t0.a in (select t1.a from t1 where t1.b=0); +a +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +drop table t0, t1; +# +# BUG#32665 Query with dependent subquery is too slow +# +create table t1 ( +idIndividual int primary key +); +insert into t1 values (1),(2); +create table t2 ( +idContact int primary key, +contactType int, +idObj int +); +insert into t2 values (1,1,1),(2,2,2),(3,3,3); +create table t3 ( +idAddress int primary key, +idContact int, +postalStripped varchar(100) +); +insert into t3 values (1,1, 'foo'), (2,2,'bar'); +The following must be converted to a semi-join: +explain SELECT a.idIndividual FROM t1 a +WHERE a.idIndividual IN +( SELECT c.idObj FROM t3 cona +INNER JOIN t2 c ON c.idContact=cona.idContact +WHERE cona.postalStripped='T2H3B2' + ); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE cona NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE c NULL eq_ref PRIMARY PRIMARY 4 test.cona.idContact 1 100.00 Using where +1 SIMPLE a NULL eq_ref PRIMARY PRIMARY 4 test.c.idObj 1 100.00 Using index; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`a`.`idIndividual` AS `idIndividual` from `test`.`t1` `a` semi join (`test`.`t3` `cona` join `test`.`t2` `c`) where ((`test`.`c`.`idContact` = `test`.`cona`.`idContact`) and (`test`.`a`.`idIndividual` = `test`.`c`.`idObj`) and (`test`.`cona`.`postalStripped` = 'T2H3B2')) +drop table t1,t2,t3; +CREATE TABLE t1 (one int, two int, flag char(1)); +CREATE TABLE t2 (one int, two int, flag char(1)); +INSERT INTO t1 VALUES(1,2,'Y'),(2,3,'Y'),(3,4,'Y'),(5,6,'N'),(7,8,'N'); +INSERT INTO t2 VALUES(1,2,'Y'),(2,3,'Y'),(3,4,'Y'),(5,6,'N'),(7,8,'N'); +SELECT * FROM t1 +WHERE ROW(one,two) IN (SELECT DISTINCT one,two FROM t2 WHERE flag = 'N'); +one two flag +5 6 N +7 8 N +SELECT * FROM t1 +WHERE ROW(one,two) IN (SELECT DISTINCT one,two FROM t1 WHERE flag = 'N'); +one two flag +5 6 N +7 8 N +insert into t2 values (null,null,'N'); +insert into t2 values (null,3,'0'); +insert into t2 values (null,5,'0'); +insert into t2 values (10,null,'0'); +insert into t1 values (10,3,'0'); +insert into t1 values (10,5,'0'); +insert into t1 values (10,10,'0'); +SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = 'N') as 'test' from t1; +one two test +1 2 NULL +2 3 NULL +3 4 NULL +5 6 1 +7 8 1 +10 3 NULL +10 5 NULL +10 10 NULL +SELECT one,two from t1 where ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = 'N'); +one two +5 6 +7 8 +SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = 'N' group by one,two) as 'test' from t1; +one two test +1 2 NULL +2 3 NULL +3 4 NULL +5 6 1 +7 8 1 +10 3 NULL +10 5 NULL +10 10 NULL +SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = '0') as 'test' from t1; +one two test +1 2 0 +2 3 NULL +3 4 0 +5 6 0 +7 8 0 +10 3 NULL +10 5 NULL +10 10 NULL +SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = '0' group by one,two) as 'test' from t1; +one two test +1 2 0 +2 3 NULL +3 4 0 +5 6 0 +7 8 0 +10 3 NULL +10 5 NULL +10 10 NULL +explain SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = '0') as 'test' from t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 9 11.11 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`one` AS `one`,`test`.`t1`.`two` AS `two`,((`test`.`t1`.`one`,`test`.`t1`.`two`),(/* select#2 */ select `test`.`t2`.`one`,`test`.`t2`.`two` from `test`.`t2` where ((`test`.`t2`.`flag` = '0') and (outer_field_is_not_null, (((`test`.`t1`.`one`) = `test`.`t2`.`one`) or (`test`.`t2`.`one` is null)), true) and (outer_field_is_not_null, (((`test`.`t1`.`two`) = `test`.`t2`.`two`) or (`test`.`t2`.`two` is null)), true)) having ((outer_field_is_not_null, (`test`.`t2`.`one`), true) and (outer_field_is_not_null, (`test`.`t2`.`two`), true)))) AS `test` from `test`.`t1` +explain SELECT one,two from t1 where ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = 'N'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 9 11.11 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`one` AS `one`,`test`.`t1`.`two` AS `two` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`two` = `test`.`t2`.`two`) and (`test`.`t1`.`one` = `test`.`t2`.`one`) and (`test`.`t2`.`flag` = 'N')) +explain SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = '0' group by one,two) as 'test' from t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 9 11.11 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`one` AS `one`,`test`.`t1`.`two` AS `two`,((`test`.`t1`.`one`,`test`.`t1`.`two`),(/* select#2 */ select `test`.`t2`.`one`,`test`.`t2`.`two` from `test`.`t2` where ((`test`.`t2`.`flag` = '0') and (outer_field_is_not_null, (((`test`.`t1`.`one`) = `test`.`t2`.`one`) or (`test`.`t2`.`one` is null)), true) and (outer_field_is_not_null, (((`test`.`t1`.`two`) = `test`.`t2`.`two`) or (`test`.`t2`.`two` is null)), true)) having ((outer_field_is_not_null, (`test`.`t2`.`one`), true) and (outer_field_is_not_null, (`test`.`t2`.`two`), true)))) AS `test` from `test`.`t1` +DROP TABLE t1,t2; +CREATE TABLE t1 (a char(5), b char(5)); +INSERT INTO t1 VALUES (NULL,'aaa'), ('aaa','aaa'); +SELECT * FROM t1 WHERE (a,b) IN (('aaa','aaa'), ('aaa','bbb')); +a b +aaa aaa +DROP TABLE t1; +CREATE TABLE t1 (a CHAR(1), b VARCHAR(10)) charset utf8mb4; +INSERT INTO t1 VALUES ('a', 'aa'); +INSERT INTO t1 VALUES ('a', 'aaa'); +SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1); +a b +CREATE INDEX I1 ON t1 (a); +CREATE INDEX I2 ON t1 (b); +EXPLAIN SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index I1 I1 5 NULL 2 100.00 Using where; Using index; LooseScan +1 SIMPLE t1 NULL ref I2 I2 43 test.t1.a 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t1`) where (`test`.`t1`.`b` = `test`.`t1`.`a`) +SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1); +a b +CREATE TABLE t2 (a VARCHAR(1), b VARCHAR(10)) charset utf8mb4; +INSERT INTO t2 SELECT * FROM t1; +CREATE INDEX I1 ON t2 (a); +CREATE INDEX I2 ON t2 (b); +EXPLAIN SELECT a,b FROM t2 WHERE b IN (SELECT a FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index I1 I1 7 NULL 2 100.00 Using where; Using index; LooseScan +1 SIMPLE t2 NULL ref I2 I2 43 test.t2.a 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t2` semi join (`test`.`t2`) where (`test`.`t2`.`b` = `test`.`t2`.`a`) +SELECT a,b FROM t2 WHERE b IN (SELECT a FROM t2); +a b +EXPLAIN +SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1 WHERE LENGTH(a)<500); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index I1 I1 5 NULL 2 100.00 Using where; Using index; LooseScan +1 SIMPLE t1 NULL ref I2 I2 43 test.t1.a 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t1`) where ((length(`test`.`t1`.`a`) < 500) and (`test`.`t1`.`b` = `test`.`t1`.`a`)) +SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1 WHERE LENGTH(a)<500); +a b +DROP TABLE t1,t2; +# +# BUG#45928 "Differing query results depending on MRR and +# engine_condition_pushdown settings" +# +CREATE TABLE `t1` ( +`pk` int(11) NOT NULL AUTO_INCREMENT, +`time_nokey` time NOT NULL, +`varchar_key` varchar(1) NOT NULL, +`varchar_nokey` varchar(1) NOT NULL, +PRIMARY KEY (`pk`), +KEY `varchar_key` (`varchar_key`) +) AUTO_INCREMENT=12 DEFAULT CHARSET=latin1; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO `t1` VALUES (10,'00:00:00','i','i'),(11,'00:00:00','',''); +SELECT `time_nokey` G1 FROM t1 WHERE ( `varchar_nokey` , `varchar_key` ) IN ( +SELECT `varchar_nokey` , `varchar_nokey` ) AND `varchar_key` >= 'c' HAVING G1 ORDER +BY `pk` ; +G1 +DROP TABLE t1; +# +# BUG#45863 "Assertion failed: (fixed == 0), function fix_fields(), +# file item.cc, line 4448" +# +DROP TABLE IF EXISTS C, BB; +CREATE TABLE C ( +varchar_nokey varchar(1) NOT NULL +); +INSERT INTO C VALUES +('k'),('a'),(''),('u'),('e'),('v'),('i'), +('t'),('u'),('f'),('u'),('m'),('j'),('f'), +('v'),('j'),('g'),('e'),('h'),('z'); +CREATE TABLE BB ( +varchar_nokey varchar(1) NOT NULL +); +INSERT INTO BB VALUES ('i'),('t'); +SELECT varchar_nokey FROM C +WHERE (varchar_nokey, OUTR) IN (SELECT varchar_nokey +FROM BB); +ERROR 42S22: Unknown column 'OUTR' in 'IN/ALL/ANY subquery' +SELECT varchar_nokey FROM C +WHERE (varchar_nokey, OUTR) IN (SELECT varchar_nokey, varchar_nokey +FROM BB); +ERROR 42S22: Unknown column 'OUTR' in 'IN/ALL/ANY subquery' +DROP TABLE C,BB; +# +# During work with BUG#45863 I had problems with a query that was +# optimized differently in regular and prepared mode. +# Because there was a bug in one of the selected strategies, I became +# aware of the problem. Adding an EXPLAIN query to catch this. +DROP TABLE IF EXISTS t1, t2, t3; +CREATE TABLE t1 +(EMPNUM CHAR(3) NOT NULL, +EMPNAME CHAR(20), +GRADE DECIMAL(4), +CITY CHAR(15)) charset latin1; +CREATE TABLE t2 +(PNUM CHAR(3) NOT NULL, +PNAME CHAR(20), +PTYPE CHAR(6), +BUDGET DECIMAL(9), +CITY CHAR(15)) charset latin1; +CREATE TABLE t3 +(EMPNUM CHAR(3) NOT NULL, +PNUM CHAR(3) NOT NULL, +HOURS DECIMAL(5)) charset latin1; +INSERT INTO t1 VALUES ('E1','Alice',12,'Deale'); +INSERT INTO t1 VALUES ('E2','Betty',10,'Vienna'); +INSERT INTO t1 VALUES ('E3','Carmen',13,'Vienna'); +INSERT INTO t1 VALUES ('E4','Don',12,'Deale'); +INSERT INTO t1 VALUES ('E5','Ed',13,'Akron'); +INSERT INTO t2 VALUES ('P1','MXSS','Design',10000,'Deale'); +INSERT INTO t2 VALUES ('P2','CALM','Code',30000,'Vienna'); +INSERT INTO t2 VALUES ('P3','SDP','Test',30000,'Tampa'); +INSERT INTO t2 VALUES ('P4','SDP','Design',20000,'Deale'); +INSERT INTO t2 VALUES ('P5','IRM','Test',10000,'Vienna'); +INSERT INTO t2 VALUES ('P6','PAYR','Design',50000,'Deale'); +INSERT INTO t3 VALUES ('E1','P1',40); +INSERT INTO t3 VALUES ('E1','P2',20); +INSERT INTO t3 VALUES ('E1','P3',80); +INSERT INTO t3 VALUES ('E1','P4',20); +INSERT INTO t3 VALUES ('E1','P5',12); +INSERT INTO t3 VALUES ('E1','P6',12); +INSERT INTO t3 VALUES ('E2','P1',40); +INSERT INTO t3 VALUES ('E2','P2',80); +INSERT INTO t3 VALUES ('E3','P2',20); +INSERT INTO t3 VALUES ('E4','P2',20); +INSERT INTO t3 VALUES ('E4','P4',40); +INSERT INTO t3 VALUES ('E4','P5',80); +CREATE UNIQUE INDEX t1_IDX ON t1(EMPNUM); +EXPLAIN SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN +(SELECT EMPNUM +FROM t3 +WHERE PNUM IN +(SELECT PNUM +FROM t2 +WHERE PTYPE = 'Design')); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where +1 SIMPLE t1 NULL eq_ref t1_IDX t1_IDX 3 test.t3.EMPNUM 1 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = `test`.`t3`.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) +PREPARE stmt FROM "EXPLAIN SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN + (SELECT EMPNUM + FROM t3 + WHERE PNUM IN + (SELECT PNUM + FROM t2 + WHERE PTYPE = 'Design'))"; +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where +1 SIMPLE t1 NULL eq_ref t1_IDX t1_IDX 3 test.t3.EMPNUM 1 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = `test`.`t3`.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) + +This line is only in place to help --skip_if_hypergraph diffing some more. + +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where +1 SIMPLE t1 NULL eq_ref t1_IDX t1_IDX 3 test.t3.EMPNUM 1 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = `test`.`t3`.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) +DEALLOCATE PREPARE stmt; +DROP INDEX t1_IDX ON t1; +CREATE INDEX t1_IDX ON t1(EMPNUM); +EXPLAIN SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN +(SELECT EMPNUM +FROM t3 +WHERE PNUM IN +(SELECT PNUM +FROM t2 +WHERE PTYPE = 'Design')); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where +1 SIMPLE t1 NULL ref t1_IDX t1_IDX 3 test.t3.EMPNUM 2 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = `test`.`t3`.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) +PREPARE stmt FROM "EXPLAIN SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN + (SELECT EMPNUM + FROM t3 + WHERE PNUM IN + (SELECT PNUM + FROM t2 + WHERE PTYPE = 'Design'))"; +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where +1 SIMPLE t1 NULL ref t1_IDX t1_IDX 3 test.t3.EMPNUM 2 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = `test`.`t3`.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) + +This line is only in place to help --skip_if_hypergraph diffing some more. + +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where +1 SIMPLE t1 NULL ref t1_IDX t1_IDX 3 test.t3.EMPNUM 2 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = `test`.`t3`.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) +DEALLOCATE PREPARE stmt; +DROP INDEX t1_IDX ON t1; +EXPLAIN SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN +(SELECT EMPNUM +FROM t3 +WHERE PNUM IN +(SELECT PNUM +FROM t2 +WHERE PTYPE = 'Design')); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 20.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = `test`.`t3`.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) +PREPARE stmt FROM "EXPLAIN SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN + (SELECT EMPNUM + FROM t3 + WHERE PNUM IN + (SELECT PNUM + FROM t2 + WHERE PTYPE = 'Design'))"; +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 20.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = `test`.`t3`.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) + +This line is only in place to help --skip_if_hypergraph diffing some more. + +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 20.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = `test`.`t3`.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) +DEALLOCATE PREPARE stmt; +DROP TABLE t1, t2, t3; +# +# BUG#45221 Query SELECT pk FROM C WHERE pk IN (SELECT int_key) failing +# +CREATE TABLE t1 ( +i1_key INT, +i2 INT, +i3 INT, +KEY i1_index (i1_key) +); +INSERT INTO t1 VALUES (9,1,2), (9,2,1); +CREATE TABLE t2 ( +pk INT NOT NULL, +i1 INT, +PRIMARY KEY (pk) +); +INSERT INTO t2 VALUES (9,1); +SELECT pk +FROM t2 +WHERE +pk IN ( +SELECT i1_key +FROM t1 +WHERE t1.i2 < t1.i3 XOR t2.i1 > 1 +ORDER BY t1.i2 desc); +pk +9 +DROP TABLE t1,t2; +# BUG#50361 Doublenested noncorrelated subquery with FirstMatch and join cache wrong result +# +CREATE TABLE t1( +id INTEGER +); +INSERT INTO t1 VALUES(10),(20); +create table t2 select * from t1; +create table t3 select * from t1; +SELECT * +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t2 +WHERE 1 IN(SELECT 1 +FROM t3)); +id +10 +20 +explain SELECT * +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t2 +WHERE 1 IN(SELECT 1 +FROM t3)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 End temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where true +delete from t2; +delete from t3; +INSERT INTO t1 VALUES(30),(40),(50),(60),(70),(80),(90); +insert into t2 select * from t1; +insert into t3 select * from t1; +create table t4 select * from t1; +SELECT * +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t2 +WHERE 1 IN(SELECT 1 +FROM t3 +WHERE 1 IN(SELECT 1 +FROM t4))); +id +10 +20 +30 +40 +50 +60 +70 +80 +90 +explain SELECT * +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t2 +WHERE 1 IN(SELECT 1 +FROM t3 +WHERE 1 IN(SELECT 1 +FROM t4))); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 9 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 9 100.00 NULL +1 SIMPLE t4 NULL ALL NULL NULL NULL NULL 9 100.00 End temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 9 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3` join `test`.`t4`) where true +SELECT * +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t1))); +id +10 +20 +30 +40 +50 +60 +70 +80 +90 +drop table t1,t2,t3,t4; +# +# Bug#53236 Segfault in DTCollation::set(DTCollation&) +# +CREATE TABLE t1 ( +pk INTEGER AUTO_INCREMENT, +col_varchar VARCHAR(1), +PRIMARY KEY (pk) +) +; +INSERT INTO t1 (col_varchar) +VALUES +('w'), +('m') +; +SELECT table1.pk +FROM ( t1 AS table1 JOIN t1 AS table2 ON (table1.col_varchar = +table2.col_varchar) ) +WHERE ( 1, 2 ) IN ( SELECT SUBQUERY1_t1.pk AS SUBQUERY1_field1, +SUBQUERY1_t1.pk AS SUBQUERY1_field2 +FROM ( t1 AS SUBQUERY1_t1 JOIN t1 AS SUBQUERY1_t2 +ON (SUBQUERY1_t2.col_varchar = +SUBQUERY1_t1.col_varchar) ) ) +; +pk +drop table t1; +# +# BUG#53298 "wrong result with semijoin (no semijoin strategy chosen)" +# +create table t1 (uid int, fid int); +insert into t1 values (1,1), (3,1); +create table t2 (uid int, name varchar(128)); +insert into t2 values (1, "A"), (2, "B"); +create table t3 (uid int, fid int, index(uid)); +insert into t3 values (1,3), (1,3); +create table t4 (uid int); +insert into t4 values (3); +explain select t2.uid from t2, t1 +where t1.uid in (select t4.uid from t4, t3 where t3.uid=1 and t4.uid=t3.fid) +and t2.uid=t1.fid; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t4 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ref uid uid 5 const 1 50.00 Using where +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`uid` AS `uid` from `test`.`t2` join `test`.`t1` semi join (`test`.`t4` join `test`.`t3`) where ((`test`.`t3`.`fid` = `test`.`t4`.`uid`) and (`test`.`t1`.`uid` = `test`.`t4`.`uid`) and (`test`.`t3`.`uid` = 1) and (`test`.`t2`.`uid` = `test`.`t1`.`fid`)) +select t2.uid from t2, t1 +where t1.uid in (select t4.uid from t4, t3 where t3.uid=1 and t4.uid=t3.fid) +and t2.uid=t1.fid; +uid +1 +drop table t1,t2,t3,t4; +CREATE TABLE t1 ( +pk int, +a varchar(1), +b varchar(4), +c varchar(4), +d varchar(4), +PRIMARY KEY (pk) +) charset utf8mb4; +INSERT INTO t1 VALUES (1,'o','ffff','ffff','ffoo'),(2,'f','ffff','ffff','ffff'); +CREATE TABLE t2 LIKE t1; +INSERT INTO t2 VALUES (1,'i','iiii','iiii','iiii'),(2,'f','ffff','ffff','ffff'); +EXPLAIN SELECT pk FROM t1 WHERE (a) IN (SELECT a FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 100.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`a` = `test`.`t2`.`a`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (a) IN (SELECT a FROM t2 WHERE pk > 0); +pk +2 +SELECT pk FROM t1 WHERE (b,c,d) IN (SELECT b,c,d FROM t2 WHERE pk > 0); +pk +2 +DROP TABLE t1, t2; +CREATE TABLE t1 (f1 INT, f2 DECIMAL(5,3)) ENGINE=MyISAM; +INSERT INTO t1 (f1, f2) VALUES (1, 1.789); +INSERT INTO t1 (f1, f2) VALUES (13, 1.454); +INSERT INTO t1 (f1, f2) VALUES (10, 1.668); +CREATE TABLE t2 LIKE t1; +INSERT INTO t2 VALUES (1, 1.789); +INSERT INTO t2 VALUES (13, 1.454); +EXPLAIN SELECT COUNT(*) FROM t1 WHERE (f1,f2) IN (SELECT f1,f2 FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`f2` = `test`.`t2`.`f2`) and (`test`.`t1`.`f1` = `test`.`t2`.`f1`)) +SELECT COUNT(*) FROM t1 WHERE (f1,f2) IN (SELECT f1,f2 FROM t2); +COUNT(*) +2 +DROP TABLE t1, t2; +CREATE TABLE t1 ( +ID int(11) NOT NULL auto_increment, +Name char(35) NOT NULL default '', +Country char(3) NOT NULL default '', +Population int(11) NOT NULL default '0', +PRIMARY KEY (ID), +INDEX (Population), +INDEX (Country) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t2 ( +Code char(3) NOT NULL default '', +Name char(52) NOT NULL default '', +SurfaceArea float(10,2) NOT NULL default '0.00', +Population int(11) NOT NULL default '0', +Capital int(11) default NULL, +PRIMARY KEY (Code), +UNIQUE INDEX (Name), +INDEX (Population) +) charset utf8mb4; +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t3 ( +Country char(3) NOT NULL default '', +Language char(30) NOT NULL default '', +Percentage float(3,1) NOT NULL default '0.0', +PRIMARY KEY (Country, Language), +INDEX (Percentage) +) charset utf8mb4; +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +EXPLAIN SELECT Name FROM t2 +WHERE t2.Code IN (SELECT Country FROM t1 WHERE Population > 5000000) +AND +t2.Code IN (SELECT Country FROM t3 +WHERE Language='English' AND Percentage > 10 AND +t2.Population > 100000); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL PRIMARY,Percentage NULL NULL NULL 22 9.55 Using where +1 SIMPLE t1 NULL ref Population,Country Country 12 test.t3.Country 3 3.33 Using where; LooseScan +1 SIMPLE t2 NULL eq_ref PRIMARY,Population PRIMARY 12 test.t3.Country 1 75.00 Using where +Warnings: +Note 1276 Field or reference 'test.t2.Population' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t2`.`Name` AS `Name` from `test`.`t3` join `test`.`t2` semi join (`test`.`t1`) where ((`test`.`t1`.`Country` = `test`.`t3`.`Country`) and (`test`.`t2`.`Code` = `test`.`t3`.`Country`) and (`test`.`t3`.`Language` = 'English') and (`test`.`t3`.`Percentage` > 10) and (`test`.`t2`.`Population` > 100000) and (`test`.`t1`.`Population` > 5000000)) +EXPLAIN FORMAT=JSON SELECT Name FROM t2 +WHERE t2.Code IN (SELECT Country FROM t1 WHERE Population > 5000000) +AND +t2.Code IN (SELECT Country FROM t3 +WHERE Language='English' AND Percentage > 10 AND +t2.Population > 100000); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "5.18" + }, + "nested_loop": [ + { + "table": { + "table_name": "t3", + "access_type": "ALL", + "possible_keys": [ + "PRIMARY", + "Percentage" + ], + "rows_examined_per_scan": 22, + "rows_produced_per_join": 2, + "filtered": "9.55", + "cost_info": { + "read_cost": "2.67", + "eval_cost": "0.21", + "prefix_cost": "2.88", + "data_read_per_join": "302" + }, + "used_columns": [ + "Country", + "Language", + "Percentage" + ], + "attached_condition": "((`test`.`t3`.`Language` = 'English') and (`test`.`t3`.`Percentage` > 10))" + } + }, + { + "table": { + "table_name": "t1", + "access_type": "ref", + "possible_keys": [ + "Population", + "Country" + ], + "key": "Country", + "used_key_parts": [ + "Country" + ], + "key_length": "12", + "ref": [ + "test.t3.Country" + ], + "rows_examined_per_scan": 3, + "rows_produced_per_join": 0, + "filtered": "3.33", + "loosescan": true, + "cost_info": { + "read_cost": "1.57", + "eval_cost": "0.02", + "prefix_cost": "5.14", + "data_read_per_join": "37" + }, + "used_columns": [ + "Country", + "Population" + ], + "attached_condition": "(`test`.`t1`.`Population` > 5000000)" + } + }, + { + "table": { + "table_name": "t2", + "access_type": "eq_ref", + "possible_keys": [ + "PRIMARY", + "Population" + ], + "key": "PRIMARY", + "used_key_parts": [ + "Code" + ], + "key_length": "12", + "ref": [ + "test.t3.Country" + ], + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "75.00", + "cost_info": { + "read_cost": "0.03", + "eval_cost": "0.16", + "prefix_cost": "5.19", + "data_read_per_join": "377" + }, + "used_columns": [ + "Code", + "Name", + "Population" + ], + "attached_condition": "(`test`.`t2`.`Population` > 100000)" + } + } + ] + } +} +Warnings: +Note 1276 Field or reference 'test.t2.Population' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t2`.`Name` AS `Name` from `test`.`t3` join `test`.`t2` semi join (`test`.`t1`) where ((`test`.`t1`.`Country` = `test`.`t3`.`Country`) and (`test`.`t2`.`Code` = `test`.`t3`.`Country`) and (`test`.`t3`.`Language` = 'English') and (`test`.`t3`.`Percentage` > 10) and (`test`.`t2`.`Population` > 100000) and (`test`.`t1`.`Population` > 5000000)) +DROP TABLE t1,t2,t3; +CREATE TABLE t1 ( +Code char(3) NOT NULL DEFAULT '', +Name char(52) NOT NULL DEFAULT '', +Continent enum('Asia','Europe','North America','Africa','Oceania','Antarctica','South America') NOT NULL DEFAULT 'Asia', +Region char(26) NOT NULL DEFAULT '', +SurfaceArea float(10,2) NOT NULL DEFAULT '0.00', +IndepYear smallint(6) DEFAULT NULL, +Population int(11) NOT NULL DEFAULT '0', +LifeExpectancy float(3,1) DEFAULT NULL, +GNP float(10,2) DEFAULT NULL, +GNPOld float(10,2) DEFAULT NULL, +LocalName char(45) NOT NULL DEFAULT '', +GovernmentForm char(45) NOT NULL DEFAULT '', +HeadOfState char(60) DEFAULT NULL, +Capital int(11) DEFAULT NULL, +Code2 char(2) NOT NULL DEFAULT '', +PRIMARY KEY (Code) +) charset utf8mb4; +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t2 ( +ID int(11) NOT NULL AUTO_INCREMENT, +Name char(35) NOT NULL DEFAULT '', +CountryCode char(3) NOT NULL DEFAULT '', +District char(20) NOT NULL DEFAULT '', +Population int(11) NOT NULL DEFAULT '0', +PRIMARY KEY (ID), +KEY CountryCode (CountryCode) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +set names latin1; +Fill the table with test data +This must not use LooseScan: +EXPLAIN SELECT Name FROM t1 +WHERE t1.Code IN ( +SELECT t2.CountryCode FROM t2 WHERE Population > 5000000); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL CountryCode NULL NULL NULL 545 33.33 Using where; Start temporary +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 12 test.t2.CountryCode 1 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`Name` AS `Name` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`Code` = `test`.`t2`.`CountryCode`) and (`test`.`t2`.`Population` > 5000000)) +SELECT Name FROM t1 +WHERE t1.Code IN ( +SELECT t2.CountryCode FROM t2 WHERE Population > 5000000); +Name +Austria +Canada +China +Czech Republic +drop table t1, t2; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4); +create table t1 (a int, b int, key(a)); +insert into t1 select a,a from t0; +create table t2 (a int, b int, primary key(a)); +insert into t2 select * from t1; +Table t2, unlike table t1, should be displayed as pulled out +explain select * from t0 +where t0.a in ( select t1.a from t1,t2 where t2.a=t0.a and +t1.b=t2.b); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL PRIMARY NULL NULL NULL 5 100.00 NULL +1 SIMPLE t1 NULL ref a a 5 test.t2.a 1 20.00 Using where; LooseScan +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 5 20.00 Using where +Warnings: +Note 1276 Field or reference 'test.t0.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a` from `test`.`t2` join `test`.`t0` semi join (`test`.`t1`) where ((`test`.`t1`.`a` = `test`.`t2`.`a`) and (`test`.`t0`.`a` = `test`.`t2`.`a`) and (`test`.`t1`.`b` = `test`.`t2`.`b`)) +update t1 set a=3, b=11 where a=4; +update t2 set b=11 where a=3; +select * from t0 where t0.a in (select t1.a from t1, t2 where t2.a=t0.a and t1.b=t2.b); +a +0 +1 +2 +3 +drop table t0, t1, t2; +CREATE TABLE t1 ( +id int(11) NOT NULL, +PRIMARY KEY (id)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t2 ( +id int(11) NOT NULL, +fid int(11) NOT NULL, +PRIMARY KEY (id)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t1 values(1); +insert into t2 values(1,7503),(2,1); +explain select count(*) +from t1 +where fid IN (select fid from t2 where (id between 7502 and 8420) order by fid ); +ERROR 42S22: Unknown column 'fid' in 'IN/ALL/ANY subquery' +drop table t1, t2; +create table t1 (a int, b int, key (a), key (b)); +insert into t1 values (2,4),(2,4),(2,4); +select t1.a from t1 +where +t1.a in (select 1 from t1 where t1.a in (select 1 from t1) group by t1.a); +a +drop table t1; +create table t1(a int,b int,key(a),key(b)); +insert into t1 values (1,1),(2,2),(3,3); +select 1 from t1 +where t1.a not in (select 1 from t1 +where t1.a in (select 1 from t1) +group by t1.b); +1 +1 +1 +drop table t1; +CREATE TABLE t1 +(EMPNUM CHAR(3) NOT NULL, +EMPNAME CHAR(20), +GRADE DECIMAL(4), +CITY CHAR(15)); +CREATE TABLE t2 +(PNUM CHAR(3) NOT NULL, +PNAME CHAR(20), +PTYPE CHAR(6), +BUDGET DECIMAL(9), +CITY CHAR(15)); +CREATE TABLE t3 +(EMPNUM CHAR(3) NOT NULL, +PNUM CHAR(3) NOT NULL, +HOURS DECIMAL(5)); +INSERT INTO t1 VALUES ('E1','Alice',12,'Deale'); +INSERT INTO t1 VALUES ('E2','Betty',10,'Vienna'); +INSERT INTO t1 VALUES ('E3','Carmen',13,'Vienna'); +INSERT INTO t1 VALUES ('E4','Don',12,'Deale'); +INSERT INTO t1 VALUES ('E5','Ed',13,'Akron'); +INSERT INTO t2 VALUES ('P1','MXSS','Design',10000,'Deale'); +INSERT INTO t2 VALUES ('P2','CALM','Code',30000,'Vienna'); +INSERT INTO t2 VALUES ('P3','SDP','Test',30000,'Tampa'); +INSERT INTO t2 VALUES ('P4','SDP','Design',20000,'Deale'); +INSERT INTO t2 VALUES ('P5','IRM','Test',10000,'Vienna'); +INSERT INTO t2 VALUES ('P6','PAYR','Design',50000,'Deale'); +INSERT INTO t3 VALUES ('E1','P1',40); +INSERT INTO t3 VALUES ('E1','P2',20); +INSERT INTO t3 VALUES ('E1','P3',80); +INSERT INTO t3 VALUES ('E1','P4',20); +INSERT INTO t3 VALUES ('E1','P5',12); +INSERT INTO t3 VALUES ('E1','P6',12); +INSERT INTO t3 VALUES ('E2','P1',40); +INSERT INTO t3 VALUES ('E2','P2',80); +INSERT INTO t3 VALUES ('E3','P2',20); +INSERT INTO t3 VALUES ('E4','P2',20); +INSERT INTO t3 VALUES ('E4','P4',40); +INSERT INTO t3 VALUES ('E4','P5',80); +SELECT * FROM t1; +EMPNUM EMPNAME GRADE CITY +E1 Alice 12 Deale +E2 Betty 10 Vienna +E3 Carmen 13 Vienna +E4 Don 12 Deale +E5 Ed 13 Akron +CREATE UNIQUE INDEX t1_IDX ON t1(EMPNUM); +SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN +(SELECT EMPNUM +FROM t3 +WHERE PNUM IN +(SELECT PNUM +FROM t2 +WHERE PTYPE = 'Design')); +EMPNAME +Alice +Betty +Don +DROP INDEX t1_IDX ON t1; +CREATE INDEX t1_IDX ON t1(EMPNUM); +SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN +(SELECT EMPNUM +FROM t3 +WHERE PNUM IN +(SELECT PNUM +FROM t2 +WHERE PTYPE = 'Design')); +EMPNAME +Alice +Betty +Don +DROP INDEX t1_IDX ON t1; +SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN +(SELECT EMPNUM +FROM t3 +WHERE PNUM IN +(SELECT PNUM +FROM t2 +WHERE PTYPE = 'Design')); +EMPNAME +Alice +Betty +Don +DROP TABLE t1, t2, t3; +CREATE TABLE t1 (f1 INT NOT NULL); +CREATE VIEW v1 (a) AS SELECT f1 IN (SELECT f1 FROM t1) FROM t1; +SELECT * FROM v1; +a +drop view v1; +drop table t1; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1(a int, b int); +insert into t1 values (0,0),(1,1),(2,2); +create table t2 as select * from t1; +create table t3 (pk int, a int, primary key(pk)); +insert into t3 select a,a from t0; +explain +select * from t1 left join t2 on (t2.a= t1.a and t2.a in (select pk from t3)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE t3 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using index +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` left join (`test`.`t3` join `test`.`t2`) on(((`test`.`t3`.`pk` = `test`.`t1`.`a`) and (`test`.`t2`.`a` = `test`.`t1`.`a`))) where true +drop table t0, t1, t2, t3; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (a int) as select A.a + 10 *(B.a + 10*C.a) as a from t0 A, t0 B, t0 C; +create table t2 (id int, a int, primary key(id), key(a)) charset utf8mb4 as select a as id, a as a from t1; +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `id` int NOT NULL, + `a` int DEFAULT NULL, + PRIMARY KEY (`id`), + KEY `a` (`a`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +set @a=0; +create table t3 as select * from t2 limit 0; +insert into t3 select @a:=@a+1, t2.a from t2, t0; +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +insert into t3 select @a:=@a+1, t2.a from t2, t0; +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +insert into t3 select @a:=@a+1, t2.a from t2, t0; +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +alter table t3 add primary key(id), add 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); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL index a a 5 NULL 30000 3.33 Using where; Using index; LooseScan +1 SIMPLE t2 NULL ref a a 5 test.t3.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select count(`test`.`t2`.`a`) AS `count(a)` from `test`.`t2` semi join (`test`.`t3`) where (`test`.`t2`.`a` = `test`.`t3`.`a`) +select count(a) from t2 where a in ( SELECT a FROM t3); +count(a) +1000 +drop table t0,t1,t2,t3; +# +# Bug#33062: subquery in stored routine cause crash +# +CREATE TABLE t1(a INT); +CREATE TABLE t2(c INT); +CREATE PROCEDURE p1(v1 int) +BEGIN +SELECT 1 FROM t1 WHERE a = v1 AND a IN (SELECT c FROM t2); +END +// +CREATE PROCEDURE p2(v1 int) +BEGIN +SELECT 1 FROM t1 WHERE a IN (SELECT c FROM t2); +END +// +CREATE PROCEDURE p3(v1 int) +BEGIN +SELECT 1 +FROM +t1 t01,t1 t02,t1 t03,t1 t04,t1 t05,t1 t06,t1 t07,t1 t08, +t1 t09,t1 t10,t1 t11,t1 t12,t1 t13,t1 t14,t1 t15,t1 t16, +t1 t17,t1 t18,t1 t19,t1 t20,t1 t21,t1 t22,t1 t23,t1 t24, +t1 t25,t1 t26,t1 t27,t1 t28,t1 t29,t1 t30,t1 t31,t1 t32, +t1 t33,t1 t34,t1 t35,t1 t36,t1 t37,t1 t38,t1 t39,t1 t40, +t1 t41,t1 t42,t1 t43,t1 t44,t1 t45,t1 t46,t1 t47,t1 t48, +t1 t49,t1 t50,t1 t51,t1 t52,t1 t53,t1 t54,t1 t55,t1 t56, +t1 t57,t1 t58,t1 t59,t1 t60 +WHERE t01.a IN (SELECT c FROM t2); +END +// +CREATE PROCEDURE p4(v1 int) +BEGIN +SELECT 1 +FROM +t1 t01,t1 t02,t1 t03,t1 t04,t1 t05,t1 t06,t1 t07,t1 t08, +t1 t09,t1 t10,t1 t11,t1 t12,t1 t13,t1 t14,t1 t15,t1 t16, +t1 t17,t1 t18,t1 t19,t1 t20,t1 t21,t1 t22,t1 t23,t1 t24, +t1 t25,t1 t26,t1 t27,t1 t28,t1 t29,t1 t30,t1 t31,t1 t32, +t1 t33,t1 t34,t1 t35,t1 t36,t1 t37,t1 t38,t1 t39,t1 t40, +t1 t41,t1 t42,t1 t43,t1 t44,t1 t45,t1 t46,t1 t47,t1 t48, +t1 t49,t1 t50,t1 t51,t1 t52,t1 t53,t1 t54,t1 t55,t1 t56, +t1 t57,t1 t58,t1 t59,t1 t60 +WHERE t01.a = v1 AND t01.a IN (SELECT c FROM t2); +END +// +CALL p1(1); +1 +CALL p2(1); +1 +CALL p3(1); +1 +CALL p4(1); +1 +DROP TABLE t1, t2; +DROP PROCEDURE p1; +DROP PROCEDURE p2; +DROP PROCEDURE p3; +DROP PROCEDURE p4; +# +# Bug#48213 Materialized subselect crashes if using GEOMETRY type +# +CREATE TABLE t1 ( +pk int, +a varchar(1), +b varchar(4), +c tinyblob, +d blob, +e mediumblob, +f longblob, +g tinytext, +h text, +i mediumtext, +j longtext, +k geometry, +PRIMARY KEY (pk) +) charset utf8mb4; +INSERT INTO t1 VALUES (1,'o','ffff','ffff','ffoo','ffff','ffff','ffff','ffff','ffff','ffff',ST_GeomFromText('POLYGON((0 0, 0 2, 2 2, 2 0, 0 0))')), (2,'f','ffff','ffff','ffff', 'ffff','ffff','ffff','ffff','ffff','ffff',ST_GeomFromText('POLYGON((0 0, 0 2, 2 2, 2 0, 0 0))')); +CREATE TABLE t2 LIKE t1; +INSERT INTO t2 VALUES (1,'i','iiii','iiii','iiii','iiii','ffff','ffff','ffff','ffff','ffff',ST_GeomFromText('POLYGON((0 0, 0 2, 2 2, 2 0, 0 0))')), (2,'f','ffff','ffff','ffff','ffff','ffff','ffff','ffff','ffff','ffff',ST_GeomFromText('POLYGON((0 0, 0 2, 2 2, 2 0, 0 0))')); +EXPLAIN SELECT pk FROM t1 WHERE (a, b) IN (SELECT a, b FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 100.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`b` = `test`.`t2`.`b`) and (`test`.`t1`.`a` = `test`.`t2`.`a`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (a, b) IN (SELECT a, b FROM t2 WHERE pk > 0); +pk +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, c) IN (SELECT b, c FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 100.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`c` = `test`.`t2`.`c`) and (`test`.`t1`.`b` = `test`.`t2`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, c) IN (SELECT b, c FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, d) IN (SELECT b, d FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 100.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`d` = `test`.`t2`.`d`) and (`test`.`t1`.`b` = `test`.`t2`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, d) IN (SELECT b, d FROM t2 WHERE pk > 0); +pk +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, e) IN (SELECT b, e FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 100.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`e` = `test`.`t2`.`e`) and (`test`.`t1`.`b` = `test`.`t2`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, e) IN (SELECT b, e FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, f) IN (SELECT b, f FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 100.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`f` = `test`.`t2`.`f`) and (`test`.`t1`.`b` = `test`.`t2`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, f) IN (SELECT b, f FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, g) IN (SELECT b, g FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 100.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`g` = `test`.`t2`.`g`) and (`test`.`t1`.`b` = `test`.`t2`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, g) IN (SELECT b, g FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, h) IN (SELECT b, h FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 100.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`h` = `test`.`t2`.`h`) and (`test`.`t1`.`b` = `test`.`t2`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, h) IN (SELECT b, h FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, i) IN (SELECT b, i FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 100.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`i` = `test`.`t2`.`i`) and (`test`.`t1`.`b` = `test`.`t2`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, i) IN (SELECT b, i FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, j) IN (SELECT b, j FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 100.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`j` = `test`.`t2`.`j`) and (`test`.`t1`.`b` = `test`.`t2`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, j) IN (SELECT b, j FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, k) IN (SELECT b, k FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 100.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`k` = `test`.`t2`.`k`) and (`test`.`t1`.`b` = `test`.`t2`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, k) IN (SELECT b, k FROM t2 WHERE pk > 0); +pk +1 +2 +DROP TABLE t1, t2; +# End of Bug#48213 +# +# BUG#53060: LooseScan semijoin strategy does not return all rows +# +CREATE TABLE t1 (i INTEGER); +INSERT INTO t1 VALUES (1), (2), (3), (4), (5); +CREATE TABLE t2 (i INTEGER, j INTEGER, KEY k(i, j)); +INSERT INTO t2 VALUES (1, 0), (1, 1), (2, 0), (2, 1); +EXPLAIN +SELECT * FROM t1 WHERE (i) IN (SELECT i FROM t2 where j > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index k k 10 NULL 4 33.33 Using where; Using index; LooseScan +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 20.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`i` = `test`.`t2`.`i`) and (`test`.`t2`.`j` > 0)) +SELECT * FROM t1 WHERE (i) IN (SELECT i FROM t2 where j > 0); +i +1 +2 +DROP TABLE t1, t2; +# End of BUG#53060 +# +# Bug#53305 "Duplicate weedout + join buffer (join cache --level=7,8) loses rows" +# +create table t1 (uid int, fid int, index(uid)); +insert into t1 values +(1,1), (1,2), (1,3), (1,4), +(2,5), (2,6), (2,7), (2,8), +(3,1), (3,2), (3,9); +create table t2 (uid int primary key, name varchar(128), index(name)); +insert into t2 values +(1, "A"), (2, "B"), (3, "C"), (4, "D"), (5, "E"), +(6, "F"), (7, "G"), (8, "H"), (9, "I"); +create table t3 (uid int, fid int, index(uid)); +insert into t3 values +(1,1), (1,2), (1,3),(1,4), +(2,5), (2,6), (2,7), (2,8), +(3,1), (3,2), (3,9); +create table t4 (uid int primary key, name varchar(128), index(name)); +insert into t4 values +(1, "A"), (2, "B"), (3, "C"), (4, "D"), (5, "E"), +(6, "F"), (7, "G"), (8, "H"), (9, "I"); +explain select name from t2, t1 +where t1.uid in (select t4.uid from t4, t3 where t3.uid=1 and t4.uid=t3.fid) +and t2.uid=t1.fid; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ref uid uid 5 const 4 100.00 Using where; Start temporary +1 SIMPLE t4 NULL eq_ref PRIMARY PRIMARY 4 test.t3.fid 1 100.00 Using index +1 SIMPLE t1 NULL ref uid uid 5 test.t3.fid 2 100.00 Using where; End temporary +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.fid 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`name` AS `name` from `test`.`t4` join `test`.`t2` join `test`.`t1` semi join (`test`.`t3`) where ((`test`.`t4`.`uid` = `test`.`t3`.`fid`) and (`test`.`t1`.`uid` = `test`.`t3`.`fid`) and (`test`.`t3`.`uid` = 1) and (`test`.`t2`.`uid` = `test`.`t1`.`fid`)) +select name from t2, t1 +where t1.uid in (select t4.uid from t4, t3 where t3.uid=1 and t4.uid=t3.fid) +and t2.uid=t1.fid; +name +A +A +B +B +C +D +E +F +G +H +I +drop table t1,t2,t3,t4; +# +# Bug#43768 Prepared query with nested subqueries core dump on second execution +# +CREATE TABLE t1 ( +id INT PRIMARY KEY, +partner_id VARCHAR(35) +) charset utf8mb4; +INSERT INTO t1 VALUES +(1, 'partner1'), (2, 'partner2'), +(3, 'partner3'), (4, 'partner4'); +CREATE TABLE t2 ( +id INT NOT NULL, +t1_line_id INT, +article_id VARCHAR(20), +PRIMARY KEY(id, t1_line_id) +) charset utf8mb4; +INSERT INTO t2 VALUES +(1, 1, 'sup'), (2, 1, 'sup'), +(2, 2, 'sup'), (2, 3, 'sup'), +(2, 4, 'imp'), (3, 1, 'sup'), +(4, 1, 'sup'); +CREATE TABLE t3 ( +user_id VARCHAR(50), +article_id VARCHAR(20) NOT NULL, +PRIMARY KEY(user_id) +) charset utf8mb4; +INSERT INTO t3 VALUES('nicke', 'imp'); +EXPLAIN +SELECT t1.partner_id +FROM t1 +WHERE t1.id IN ( +SELECT t2.id +FROM t2 +WHERE article_id IN ( +SELECT article_id FROM t3 +WHERE user_id = 'nicke' + ) +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL system PRIMARY NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL PRIMARY NULL NULL NULL 7 14.29 Using where; Start temporary +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.id 1 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`partner_id` AS `partner_id` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`id` = `test`.`t2`.`id`) and (`test`.`t2`.`article_id` = 'imp')) +SELECT t1.partner_id +FROM t1 +WHERE t1.id IN ( +SELECT t2.id +FROM t2 +WHERE article_id IN ( +SELECT article_id FROM t3 +WHERE user_id = 'nicke' + ) +); +partner_id +partner2 +PREPARE stmt FROM +'EXPLAIN SELECT t1.partner_id +FROM t1 +WHERE t1.id IN ( + SELECT t2.id + FROM t2 + WHERE article_id IN ( + SELECT article_id FROM t3 + WHERE user_id = \'nicke\' + ) + )'; +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL system PRIMARY NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL PRIMARY NULL NULL NULL 7 14.29 Using where; Start temporary +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.id 1 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`partner_id` AS `partner_id` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`id` = `test`.`t2`.`id`) and (`test`.`t2`.`article_id` = 'imp')) + +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL system PRIMARY NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL PRIMARY NULL NULL NULL 7 14.29 Using where; Start temporary +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.id 1 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`partner_id` AS `partner_id` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`id` = `test`.`t2`.`id`) and (`test`.`t2`.`article_id` = 'imp')) +PREPARE stmt FROM +'SELECT t1.partner_id +FROM t1 +WHERE t1.id IN ( + SELECT t2.id + FROM t2 + WHERE article_id IN ( + SELECT article_id FROM t3 + WHERE user_id = \'nicke\' + ) + )'; +EXECUTE stmt; +partner_id +partner2 + +EXECUTE stmt; +partner_id +partner2 +DROP TABLE t1,t2,t3; +# End of Bug#43768 +# +# Bug#53058 - semijoin execution of subquery with outerjoin yields wrong result +# +CREATE TABLE t1 (i INTEGER); +CREATE TABLE t2 (i INTEGER); +CREATE TABLE t3 (i INTEGER); +INSERT INTO t1 VALUES (1), (2); +INSERT INTO t2 VALUES (6); +INSERT INTO t3 VALUES (1), (2); +explain SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t3 LEFT JOIN t2 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t3 LEFT JOIN t2 ON t2.i=t3.i); +i +1 +2 +drop table t1,t2,t3; +# +# BUG#49453: re-execution of prepared statement with view +# and semijoin crashes +# +CREATE TABLE t1 (city VARCHAR(50), country_id INT); +CREATE TABLE t2 (country_id INT, country VARCHAR(50)); +INSERT INTO t1 VALUES +('Batna',2),('Bchar',2),('Skikda',2),('Tafuna',3),('Algeria',2) ; +INSERT INTO t2 VALUES (2,'Algeria'),(2,'AlgeriaDup'),(3,'XAmerican Samoa'); +CREATE VIEW v1 AS +SELECT country_id as vf_country_id +FROM t2 +WHERE LEFT(country,1) = "A"; +PREPARE stmt FROM " +SELECT city, country_id +FROM t1 +WHERE country_id IN (SELECT vf_country_id FROM v1); +"; + +EXECUTE stmt; +city country_id +Algeria 2 +Batna 2 +Bchar 2 +Skikda 2 + +EXECUTE stmt; +city country_id +Algeria 2 +Batna 2 +Bchar 2 +Skikda 2 +DROP TABLE t1,t2; +DROP VIEW v1; +# +# Bug#54437 Extra rows with LEFT JOIN + semijoin (firstmatch +# and duplicates weedout) +# +create table t1 (a int); +create table t2 (a int); +create table t3 (a int); +insert into t1 values(1),(1); +insert into t2 values(1),(1),(1),(1); +insert into t3 values(2),(2); +explain select * from t1 where t1.a in (select t2.a from t2 left join t3 on t2.a=t3.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t2` left join `test`.`t3` on((`test`.`t2`.`a` = `test`.`t3`.`a`))) where (`test`.`t2`.`a` = `test`.`t1`.`a`) +select * from t1 where t1.a in (select t2.a from t2 left join t3 on t2.a=t3.a); +a +1 +1 +drop table t1,t2,t3; +# +# Bug#55955: crash in MEMORY engine with IN(LEFT JOIN (JOIN)) +# +CREATE TABLE t1 (a INT); +CREATE TABLE t2 (a INT); +CREATE TABLE t3 (a INT); +INSERT INTO t1 VALUES(1),(1); +INSERT INTO t2 VALUES(1),(1); +INSERT INTO t3 VALUES(2),(2); +explain SELECT * FROM t1 +WHERE t1.a IN (SELECT t2.a +FROM t2 LEFT JOIN (t2 AS t2inner, t3) ON t2.a=t3.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2inner NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t2` left join (`test`.`t2` `t2inner` join `test`.`t3`) on((`test`.`t2`.`a` = `test`.`t3`.`a`))) where (`test`.`t1`.`a` = `test`.`t2`.`a`) +SELECT * FROM t1 +WHERE t1.a IN (SELECT t2.a +FROM t2 LEFT JOIN (t2 AS t2inner, t3) ON t2.a=t3.a); +a +1 +1 +DROP TABLE t1,t2,t3; +# +# BUG#52329 - Wrong result: subquery materialization, IN, +# non-null field followed by nullable +# +CREATE TABLE t1 (a1 CHAR(8) NOT NULL, a2 char(8) NOT NULL); +CREATE TABLE t2a (b1 char(8), b2 char(8)); +CREATE TABLE t2b (b1 CHAR(8), b2 char(8) NOT NULL); +CREATE TABLE t2c (b1 CHAR(8) NOT NULL, b2 char(8)); +INSERT INTO t1 VALUES ('1 - 12', '2 - 22'); +INSERT INTO t2a VALUES ('1 - 11', '2 - 21'), +('1 - 11', '2 - 21'), +('1 - 12', '2 - 22'), +('1 - 12', '2 - 22'), +('1 - 13', '2 - 23'); +INSERT INTO t2b SELECT * FROM t2a; +INSERT INTO t2c SELECT * FROM t2a; +SELECT * FROM t1 +WHERE (a1, a2) IN ( +SELECT b1, b2 FROM t2c WHERE b1 > '0' GROUP BY b1, b2); +a1 a2 +1 - 12 2 - 22 +SELECT * FROM t1 +WHERE (a1, a2) IN ( +SELECT b1, b2 FROM t2a WHERE b1 > '0'); +a1 a2 +1 - 12 2 - 22 +SELECT * FROM t1 +WHERE (a1, a2) IN ( +SELECT b1, b2 FROM t2b WHERE b1 > '0'); +a1 a2 +1 - 12 2 - 22 +SELECT * FROM t1 +WHERE (a1, a2) IN ( +SELECT b1, b2 FROM t2c WHERE b1 > '0'); +a1 a2 +1 - 12 2 - 22 +DROP TABLE t1,t2a,t2b,t2c; +# End BUG#52329 +# +# Bug#45174: Incorrectly applied equality propagation caused wrong +# result on a query with a materialized semi-join. +# +CREATE TABLE t1 ( +varchar_nokey varchar(1) NOT NULL +) charset utf8mb4; +INSERT INTO t1 VALUES +('v'), ('u'), ('n'), ('l'), ('h'), ('u'), ('n'), ('j'), ('k'), +('e'), ('i'), ('u'), ('n'), ('b'), ('x'), (''), ('q'), ('u'); +CREATE TABLE t2 ( +pk int NOT NULL, +varchar_key varchar(1) NOT NULL, +varchar_nokey varchar(1) NOT NULL, +PRIMARY KEY(pk), +KEY varchar_key(varchar_key) +) charset utf8mb4; +INSERT INTO t2 VALUES +(11,'m','m'), (12,'j','j'), (13,'z','z'), (14,'a','a'), (15,'',''), +(16,'e','e'), (17,'t','t'), (19,'b','b'), (20,'w','w'), (21,'m','m'), +(23,'',''), (24,'w','w'), (26,'e','e'), (27,'e','e'), (28,'p','p'); +SELECT varchar_nokey +FROM t1 +WHERE (varchar_nokey, varchar_nokey) IN (SELECT varchar_key, varchar_nokey +FROM t2 +WHERE varchar_nokey < 'n' XOR pk); +varchar_nokey +explain SELECT varchar_nokey +FROM t1 +WHERE (varchar_nokey, varchar_nokey) IN (SELECT varchar_key, varchar_nokey +FROM t2 +WHERE varchar_nokey < 'n' XOR pk); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 18 100.00 NULL +1 SIMPLE t2 NULL ref varchar_key varchar_key 6 test.t1.varchar_nokey 2 6.67 Using where; Start temporary; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`varchar_nokey` AS `varchar_nokey` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`varchar_key` = `test`.`t1`.`varchar_nokey`) and (`test`.`t2`.`varchar_nokey` = `test`.`t1`.`varchar_nokey`) and ((`test`.`t2`.`varchar_nokey` < 'n') xor (0 <> `test`.`t2`.`pk`))) +DROP TABLE t1, t2; +# End of the test for bug#45174. +# +# Bug#50019: Wrong result for IN-query with materialization +# +CREATE TABLE t1(i INT); +INSERT INTO t1 VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10); +CREATE TABLE t2(i INT); +INSERT INTO t2 VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10); +CREATE TABLE t3(i INT); +INSERT INTO t3 VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10); +SELECT * FROM t1 WHERE t1.i IN (SELECT t2.i +FROM t2 JOIN t3 +WHERE t2.i + t3.i = 5); +i +1 +2 +3 +4 +explain SELECT * FROM t1 WHERE t1.i IN (SELECT t2.i +FROM t2 JOIN t3 +WHERE t2.i + t3.i = 5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 10 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 10.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 10 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t2`.`i`) and ((`test`.`t2`.`i` + `test`.`t3`.`i`) = 5)) +DROP TABLE t1,t2,t3; +# End of the test for bug#50019. +# +# Bug#52068: Optimizer generates invalid semijoin materialization plan +# +CREATE TABLE ot1(a INTEGER); +INSERT INTO ot1 VALUES(5), (8); +CREATE TABLE it2(a INTEGER); +INSERT INTO it2 VALUES(9), (5), (1), (8); +CREATE TABLE it3(a INTEGER); +INSERT INTO it3 VALUES(7), (1), (0), (5), (1), (4); +CREATE TABLE ot4(a INTEGER); +INSERT INTO ot4 VALUES(1), (3), (5), (7), (9), (7), (3), (1); +SELECT * FROM ot1,ot4 +WHERE (ot1.a,ot4.a) IN (SELECT it2.a,it3.a +FROM it2,it3); +a a +5 1 +5 1 +5 5 +5 7 +5 7 +8 1 +8 1 +8 5 +8 7 +8 7 +explain SELECT * FROM ot1,ot4 +WHERE (ot1.a,ot4.a) IN (SELECT it2.a,it3.a +FROM it2,it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE it2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; Start temporary +1 SIMPLE it3 NULL ALL NULL NULL NULL NULL 6 100.00 NULL +1 SIMPLE ot4 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot4`.`a` AS `a` from `test`.`ot1` join `test`.`ot4` semi join (`test`.`it2` join `test`.`it3`) where ((`test`.`ot4`.`a` = `test`.`it3`.`a`) and (`test`.`it2`.`a` = `test`.`ot1`.`a`)) +DROP TABLE IF EXISTS ot1, ot4, it2, it3; +# End of the test for bug#52068. +# +# Bug#57623: subquery within before insert trigger causes crash (sj=on) +# +CREATE TABLE ot1(a INT); +CREATE TABLE ot2(a INT); +CREATE TABLE ot3(a INT); +CREATE TABLE it1(a INT); +INSERT INTO ot1 VALUES(0),(1),(2),(3),(4),(5),(6),(7); +INSERT INTO ot2 VALUES(0),(2),(4),(6); +INSERT INTO ot3 VALUES(0),(3),(6); +INSERT INTO it1 VALUES(0),(1),(2),(3),(4),(5),(6),(7); +explain SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 on ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a from it1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +1 SIMPLE it1 NULL ALL NULL NULL NULL NULL 8 100.00 Using where; Start temporary; End temporary +1 SIMPLE ot3 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a`,`test`.`ot3`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` join `test`.`ot3` semi join (`test`.`it1`)) on(((`test`.`it1`.`a` = `test`.`ot1`.`a`) and (`test`.`ot3`.`a` = `test`.`ot1`.`a`) and (`test`.`ot2`.`a` = `test`.`ot1`.`a`))) where true +SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 on ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a from it1); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +prepare s from 'SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 on ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a from it1)'; +execute s; +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +execute s; +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +deallocate prepare s; +DROP TABLE ot1, ot2, ot3, it1; +# End of the test for bug#57623. +# +# Bug#11766739: Crash in tmp_table_param::init() with semijoin=on +# +CREATE TABLE t1 (f1 INTEGER) ENGINE=MyISAM; +CREATE TABLE t2 (f1 INTEGER, f2 INTEGER) ENGINE=MyISAM; +INSERT INTO t1 VALUES (1); +INSERT INTO t2 VALUES (1,1), (2,1); +EXPLAIN SELECT * FROM t2 +WHERE f2 IN (SELECT t1.f1 +FROM t1 LEFT OUTER JOIN (t2 AS b1 JOIN t2 AS b2 ON TRUE) ON TRUE); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE b1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE b2 NULL ALL NULL NULL NULL NULL 2 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`f1` AS `f1`,`test`.`t2`.`f2` AS `f2` from `test`.`t2` semi join (`test`.`t1` left join (`test`.`t2` `b1` join `test`.`t2` `b2`) on((true))) where (`test`.`t2`.`f2` = `test`.`t1`.`f1`) +SELECT * FROM t2 +WHERE f2 IN (SELECT t1.f1 +FROM t1 LEFT OUTER JOIN (t2 AS b1 JOIN t2 AS b2 ON TRUE) ON TRUE); +f1 f2 +1 1 +2 1 +DROP TABLE t1, t2; +# End of the test for bug#11766739. +# +# Bug#11766642: crash in Item_field::register_field_in_read_map with view +# +CREATE TABLE t1(a INT); +CREATE VIEW v1 AS SELECT a FROM t1; +INSERT INTO t1 VALUES (0),(1),(2); +SELECT a FROM t1 WHERE a IN +(SELECT a XOR a FROM v1) +ORDER BY a; +a +0 +DROP TABLE t1; +DROP VIEW v1; +# +# Bug#12546542 MISSING ROW WHEN USING OPTIMIZER_JOIN_CACHE_LEVEL>=3 +# +CREATE TABLE t1 ( +f2 varchar(1024) +); +INSERT INTO t1 VALUES ('v'),('we'); +CREATE TABLE t2 ( +col_varchar_1024_utf8 varchar(1024) CHARACTER SET utf8 DEFAULT NULL, +col_int_key int, +col_int int +); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t2 VALUES ('we',4,NULL),('v',1305673728,6); +CREATE TABLE t3 ( +col_int_key int, +col_int int +); +INSERT INTO t3 VALUES (4,4); +SELECT * +FROM t1 +WHERE f2 IN (SELECT a1.col_varchar_1024_utf8 AS f2 +FROM t2 AS a1 LEFT JOIN t3 AS a2 +ON a1.col_int_key = a2.col_int_key +WHERE a1.col_int BETWEEN 1 AND 10 OR a2.col_int IS NOT NULL); +f2 +v +we +DROP TABLE t1,t2,t3; +# +# BUG#12616344 - JCL: DIFFERENT RESULT SET AND DIFFERENT AMOUNT +# OF ROWS WHEN JCL>=3 +# +CREATE TABLE t1 (col_int_nokey int, col_int_key int, col_varchar_key varchar(1)); +INSERT INTO t1 VALUES (0,4,'c'),(1,6,'u'); +CREATE TABLE t2 (pk int, col_int_nokey int, col_varchar_nokey varchar(1)); +INSERT INTO t2 VALUES (1,4,'b'),(94,6,'u'); +CREATE TABLE t3 (pk int, col_int_nokey int, col_varchar_key varchar(1)); +INSERT INTO t3 VALUES (1,4,'j'),(2,6,'v'); +SELECT table2.col_int_key +from t3 as table1 join t1 as table2 on table2.col_int_nokey +where table1.col_int_nokey in +( +select subquery2_t2.col_int_nokey +from t3 as subquery2_t1 +right join +t2 as subquery2_t2 +join t1 as subquery2_t3 +on subquery2_t3.col_int_key = subquery2_t2.col_int_nokey +on subquery2_t3.col_varchar_key = subquery2_t2.col_varchar_nokey +where subquery2_t1.col_varchar_key != table1.col_varchar_key +or subquery2_t2.pk <= table1.pk +); +col_int_key +6 +6 +DROP TABLE t1,t2,t3; +# +# Bug#12608157: ASSERT IN FIELD_LONG::VAL_INT WHEN USING MEMORY ENGINE +# +CREATE TABLE t1 (i1 int); +INSERT INTO t1 VALUES (1); +CREATE TABLE t2 (i1 int, i2 int) ENGINE=memory; +INSERT INTO t2 VALUES (1, 2),(7, 3); +SELECT GRANDPARENT1.i1 +FROM t2 AS GRANDPARENT1 +WHERE GRANDPARENT1.i2 +IN ( SELECT PARENT1.i2 +FROM t2 AS PARENT1 JOIN t1 AS PARENT2 ON (PARENT1.i1 = PARENT2.i1) +WHERE +GRANDPARENT1.i1 IN ( SELECT CHILD1.i1 FROM t2 AS CHILD1 ) +ORDER BY PARENT1.i1) +ORDER BY GRANDPARENT1.i2 ; +i1 +1 +DROP TABLE t1,t2; +# +# Bug#12640083: Same query executed as WHERE subquery gives different +# results on IN() compare +# +CREATE TABLE t1 ( +pk int NOT NULL, +col_varchar_1024_utf8_key varchar(1024) CHARACTER SET utf8 DEFAULT NULL, +col_varchar_10_latin1_key varchar(10) DEFAULT NULL, +PRIMARY KEY (pk), +KEY col_varchar_1024_utf8_key(col_varchar_1024_utf8_key(333)), +KEY col_varchar_10_latin1_key(col_varchar_10_latin1_key) +) charset utf8mb4; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES +(1, 'a', 'a'), +(2, 'ab', 'ab'), +(3, 'abc', 'abc'), +(4, 'abcd', 'abcd'); +CREATE TABLE t2 ( +pk int NOT NULL AUTO_INCREMENT, +PRIMARY KEY (pk) +) charset utf8mb4 ENGINE=Innodb; +CREATE TABLE t3 charset utf8mb4 +SELECT alias1.col_varchar_10_latin1_key +FROM t1 AS alias1 +LEFT JOIN t1 AS alias2 +JOIN t2 AS alias3 +ON alias2.col_varchar_10_latin1_key +ON alias1.col_varchar_1024_utf8_key +WHERE alias1.pk AND alias1.pk < 3 OR alias1.pk AND alias3.pk; +EXPLAIN SELECT * +FROM t3 +WHERE col_varchar_10_latin1_key IN ( +SELECT alias1.col_varchar_10_latin1_key +FROM t1 AS alias1 +LEFT JOIN t1 AS alias2 +JOIN t2 AS alias3 +ON alias2.col_varchar_10_latin1_key +ON alias1.col_varchar_1024_utf8_key +WHERE alias1.pk AND alias1.pk < 3 OR alias1.pk AND alias3.pk); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE alias1 NULL ref PRIMARY,col_varchar_10_latin1_key col_varchar_10_latin1_key 43 test.t3.col_varchar_10_latin1_key 2 100.00 Using where; Start temporary +1 SIMPLE alias3 NULL index NULL PRIMARY 4 NULL 1 100.00 Using where; Using index +1 SIMPLE alias2 NULL index NULL col_varchar_10_latin1_key 43 NULL 4 100.00 Using where; Using index; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`col_varchar_10_latin1_key` AS `col_varchar_10_latin1_key` from `test`.`t3` semi join (`test`.`t1` `alias1` left join (`test`.`t1` `alias2` join `test`.`t2` `alias3`) on(((0 <> `test`.`alias1`.`col_varchar_1024_utf8_key`) and (0 <> `test`.`alias2`.`col_varchar_10_latin1_key`)))) where ((`test`.`alias1`.`col_varchar_10_latin1_key` = `test`.`t3`.`col_varchar_10_latin1_key`) and (((0 <> `test`.`alias1`.`pk`) and (`test`.`alias1`.`pk` < 3)) or ((0 <> `test`.`alias1`.`pk`) and (0 <> `test`.`alias3`.`pk`)))) +SELECT * +FROM t3 +WHERE col_varchar_10_latin1_key IN ( +SELECT alias1.col_varchar_10_latin1_key +FROM t1 AS alias1 +LEFT JOIN t1 AS alias2 +JOIN t2 AS alias3 +ON alias2.col_varchar_10_latin1_key +ON alias1.col_varchar_1024_utf8_key +WHERE alias1.pk AND alias1.pk < 3 OR alias1.pk AND alias3.pk); +col_varchar_10_latin1_key +a +ab +DROP TABLE t1, t2, t3; +# End of the test for bug#12640083. +# +# Bug#12603200 - Assert in QUICK_INDEX_MERGE_SELECT::need_sorted_output +# +CREATE TABLE t1 ( +pk int NOT NULL, +col_int_key int NOT NULL, +col_varchar_nokey varchar(1) NOT NULL, +col_varchar_key varchar(1) NOT NULL, +PRIMARY KEY(pk), +KEY col_int_key(col_int_key), +KEY col_varchar_key(col_varchar_key, col_int_key) +) charset utf8mb4 engine=innodb; +INSERT INTO t1 VALUES +(1,7,'a','a'), +(2,0,'v','v'), +(3,9,'c','c'), +(4,3,'m','m'), +(5,2,'a','a'), +(6,1,'d','d'), +(7,8,'y','y'), +(8,6,'t','t'), +(11,7,'a','x'), +(12,0,'v','v'), +(13,9,'c','c'), +(14,3,'m','m'), +(15,2,'a','x'), +(16,1,'d','d'), +(17,8,'y','y'), +(18,6,'t','u'), +(19,6,'t','u'); +CREATE TABLE t2 ( +pk int NOT NULL, +col_int_key int NOT NULL, +col_varchar_key varchar(1) NOT NULL, +PRIMARY KEY(pk), +KEY col_varchar_key(col_varchar_key, col_int_key) +) charset utf8mb4 engine=innodb; +INSERT INTO t2(pk,col_int_key,col_varchar_key) VALUES +(8,7,'c'), +(11,4,'l'), +(12,7,'b'), +(13,0,'c'), +(14,2,'i'), +(15,9,'h'), +(16,4,'q'), +(17,1,'m'), +(18,9,'b'), +(19,2,'e'), +(20,1,'c'), +(21,7,'z'), +(22,4,'l'), +(23,7,'z'), +(24,0,'c'), +(25,2,'i'), +(26,9,'h'), +(27,4,'q'), +(28,0,'a'), +(29,1,'d'); +EXPLAIN SELECT outr.col_varchar_key AS x, outr.pk AS y +FROM t1 AS outr +WHERE outr.col_varchar_key IN (SELECT innr.col_varchar_key +FROM t2 AS innr +WHERE innr.col_varchar_key = 'a' OR innr.pk = 8) +AND outr.col_varchar_nokey < 't' +ORDER BY outr.col_varchar_key, outr.pk; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE innr NULL index PRIMARY,col_varchar_key col_varchar_key 10 NULL 20 55.00 Using where; Using index; Using temporary; Using filesort; LooseScan +1 SIMPLE outr NULL ref col_varchar_key col_varchar_key 6 test.innr.col_varchar_key 1 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`outr`.`col_varchar_key` AS `x`,`test`.`outr`.`pk` AS `y` from `test`.`t1` `outr` semi join (`test`.`t2` `innr`) where ((`test`.`outr`.`col_varchar_key` = `test`.`innr`.`col_varchar_key`) and (`test`.`outr`.`col_varchar_nokey` < 't') and ((`test`.`innr`.`col_varchar_key` = 'a') or (`test`.`innr`.`pk` = 8))) order by `test`.`outr`.`col_varchar_key`,`test`.`outr`.`pk` +SELECT outr.col_varchar_key AS x, outr.pk AS y +FROM t1 AS outr +WHERE outr.col_varchar_key IN (SELECT innr.col_varchar_key +FROM t2 AS innr +WHERE innr.col_varchar_key = 'a' OR innr.pk = 8) +AND outr.col_varchar_nokey < 't' +ORDER BY outr.col_varchar_key, outr.pk; +x y +a 1 +a 5 +c 3 +c 13 +DROP TABLE t1, t2; +# End of bug#12603200 +# +# Bug#12603183: Segfault in hp_movelink +# +CREATE TABLE t1 ( +col_varchar_key varchar(1) , +col_varchar_nokey varchar(1) , +KEY col_varchar_key(col_varchar_key) +) charset latin1; +INSERT INTO t1 VALUES +('i','i'), +('h','h'), +('q','q'), +('a','a'), +('v','v'), +('u','u'), +('s','s'), +('y','y'), +('z','z'), +('h','h'), +('p','p'), +('e','e'), +('i','i'), +('y','y'), +('w','w'); +CREATE TABLE t2 ( +col_varchar_nokey varchar(1) +) charset latin1; +INSERT INTO t2 VALUES +('b'); +EXPLAIN SELECT grandparent1.col_varchar_nokey +FROM t1 AS grandparent1 LEFT JOIN t2 AS grandparent2 USING (col_varchar_nokey) +WHERE (grandparent1.col_varchar_key) IN +(SELECT parent1.col_varchar_nokey +FROM t1 AS parent1 +WHERE parent1.col_varchar_key IN +(SELECT child1.col_varchar_nokey AS c1 +FROM t1 AS child1 LEFT JOIN t2 AS child2 +ON (child1.col_varchar_key > child2.col_varchar_nokey))); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE child1 NULL ALL NULL NULL NULL NULL 15 100.00 Using where; Start temporary +1 SIMPLE child2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE parent1 NULL ref col_varchar_key col_varchar_key 4 test.child1.col_varchar_nokey 2 100.00 Using where +1 SIMPLE grandparent1 NULL ref col_varchar_key col_varchar_key 4 test.parent1.col_varchar_nokey 2 100.00 End temporary +1 SIMPLE grandparent2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`grandparent1`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t1` `grandparent1` left join `test`.`t2` `grandparent2` on((`test`.`grandparent2`.`col_varchar_nokey` = `test`.`grandparent1`.`col_varchar_nokey`)) semi join (`test`.`t1` `parent1` join `test`.`t1` `child1` left join `test`.`t2` `child2` on((`test`.`child1`.`col_varchar_key` > `test`.`child2`.`col_varchar_nokey`))) where ((`test`.`grandparent1`.`col_varchar_key` = `test`.`parent1`.`col_varchar_nokey`) and (`test`.`parent1`.`col_varchar_key` = `test`.`child1`.`col_varchar_nokey`)) +SELECT grandparent1.col_varchar_nokey +FROM t1 AS grandparent1 LEFT JOIN t2 AS grandparent2 USING (col_varchar_nokey) +WHERE (grandparent1.col_varchar_key) IN +(SELECT parent1.col_varchar_nokey +FROM t1 AS parent1 +WHERE parent1.col_varchar_key IN +(SELECT child1.col_varchar_nokey AS c1 +FROM t1 AS child1 LEFT JOIN t2 AS child2 +ON (child1.col_varchar_key > child2.col_varchar_nokey))); +col_varchar_nokey +a +e +h +h +i +i +p +q +s +u +v +w +y +y +z +DROP TABLE t1, t2; +# End of test for bug#12603183. +# +# Bug#12818569: Diff nr of rows returned when using IN/ALL+subquery +# +CREATE TABLE t1 ( +col_int_key INT NOT NULL, +col_datetime_key DATETIME NOT NULL, +col_varchar_key VARCHAR(1) NOT NULL, +KEY col_int_key (col_int_key), +KEY col_datetime_key(col_datetime_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t1 VALUES +(7,'2004-06-06 04:22:12','v'), (0,'2005-11-13 01:12:31','s'), +(9,'2002-05-04 01:50:00','l'), (3,'2004-10-27 10:28:45','y'), +(4,'2006-07-22 05:24:23','c'), (2,'2002-05-16 21:34:03','i'), +(5,'2008-04-17 10:45:30','h'), (3,'2009-04-21 02:58:02','q'), +(1,'2008-01-11 11:01:51','a'), (3,'1900-01-01 00:00:00','v'), +(6,'2007-05-17 18:24:57','u'), (7,'2007-08-07 00:00:00','s'), +(5,'2001-08-28 00:00:00','y'), (1,'2004-04-16 00:27:28','z'), +(204,'2005-05-03 07:06:22','h'), (224,'2009-03-11 17:09:50','p'), +(9,'2007-12-08 01:54:28','e'), (5,'2009-07-28 18:19:54','i'), +(0,'2008-06-08 00:00:00','y'), (3,'2005-02-09 09:20:26','w'); +CREATE TABLE t2 ( +col_varchar_nokey VARCHAR(1) NOT NULL +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t2 VALUES ('v'), ('y'), ('j'), ('c'), ('d'), ('r'); +explain SELECT col_varchar_key +FROM t1 +WHERE col_varchar_key IN (SELECT col_varchar_nokey +FROM t2) +ORDER BY col_datetime_key LIMIT 4; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 100.00 Using temporary; Using filesort; Start temporary +1 SIMPLE t1 NULL ref col_varchar_key col_varchar_key 6 test.t2.col_varchar_nokey 1 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col_varchar_key` AS `col_varchar_key` from `test`.`t1` semi join (`test`.`t2`) where (`test`.`t1`.`col_varchar_key` = `test`.`t2`.`col_varchar_nokey`) order by `test`.`t1`.`col_datetime_key` limit 4 +SELECT col_varchar_key +FROM t1 +WHERE col_varchar_key IN (SELECT col_varchar_nokey +FROM t2) +ORDER BY col_datetime_key LIMIT 4; +col_varchar_key +v +y +v +y +DROP TABLE t1, t2; +# End of test for bug#12818569. +# +# Bug#12803439: Assert in replace_subcondition() on update query +# +CREATE TABLE t1(a INTEGER); +INSERT INTO t1 values(1), (2); +CREATE TABLE t2(a INTEGER); +INSERT INTO t2 VALUES(1), (3); +SELECT * +FROM t1 +WHERE a IN (SELECT a +FROM t2 +HAVING a IN (SELECT a +FROM t2) +) +HAVING a IN (SELECT a +FROM t2); +a +1 +DROP TABLE t1, t2; +# End of test for bug#12803439. +# +# Bug#12797534: Segfault in hp_movelink still exists +# +CREATE TABLE t1 ( +g1 VARCHAR(1) NOT NULL +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t1 VALUES ('d'), ('s'); +CREATE TABLE t2 ( +pk INT NOT NULL, +col_int_key INT NOT NULL, +col_varchar_key VARCHAR(1) NOT NULL, +col_varchar_nokey VARCHAR(1) NOT NULL, +PRIMARY KEY (pk), +KEY col_varchar_key(col_varchar_key, col_int_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t2 VALUES +(1,4,'j','j'), (2,6,'v','v'), (3,3,'c','c'), (4,5,'m','m'), +(5,3,'d','d'), (6,246,'d','d'), (7,2,'y','y'), (8,9,'t','t'), +(9,3,'d','d'), (10,8,'s','s'), (11,1,'r','r'), (12,8,'m','m'), +(13,8,'b','b'), (14,5,'x','x'), (15,7,'g','g'), (16,5,'p','p'), +(17,1,'q','q'), (18,6,'w','w'), (19,2,'d','d'), (20,9,'e','e'); +CREATE TABLE t3 ( +pk INTEGER NOT NULL, +PRIMARY KEY (pk) +) ENGINE=InnoDB; +INSERT INTO t3 VALUES (10); +EXPLAIN SELECT * +FROM t1 +WHERE g1 NOT IN +(SELECT grandparent1.col_varchar_nokey AS g1 +FROM t2 AS grandparent1 +WHERE grandparent1.col_varchar_key IN +(SELECT parent1.col_varchar_nokey AS p1 +FROM t2 AS parent1 LEFT JOIN t3 AS parent2 USING (pk) +) +AND grandparent1.col_varchar_key IS NOT NULL +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 SIMPLE parent1 NULL ALL NULL NULL NULL NULL 20 100.00 Using where; Not exists; Start temporary +2 SIMPLE parent2 NULL eq_ref PRIMARY PRIMARY 4 test.parent1.pk 1 100.00 Using index +2 SIMPLE grandparent1 NULL ref col_varchar_key col_varchar_key 6 test.parent1.col_varchar_nokey 1 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`g1` AS `g1` from `test`.`t1` anti join (`test`.`t2` `grandparent1` join `test`.`t2` `parent1` left join `test`.`t3` `parent2` on((`test`.`parent2`.`pk` = `test`.`parent1`.`pk`))) on(((`test`.`grandparent1`.`col_varchar_nokey` = `test`.`t1`.`g1`) and (`test`.`grandparent1`.`col_varchar_key` = `test`.`parent1`.`col_varchar_nokey`) and (`test`.`grandparent1`.`col_varchar_key` is not null))) where true +SELECT * +FROM t1 +WHERE g1 NOT IN +(SELECT grandparent1.col_varchar_nokey AS g1 +FROM t2 AS grandparent1 +WHERE grandparent1.col_varchar_key IN +(SELECT parent1.col_varchar_nokey AS p1 +FROM t2 AS parent1 LEFT JOIN t3 AS parent2 USING (pk) +) +AND grandparent1.col_varchar_key IS NOT NULL +); +g1 +DROP TABLE t1, t2, t3; +CREATE TABLE t1 ( +pk INTEGER AUTO_INCREMENT, +col_int_key INTEGER , +col_varchar_key VARCHAR(1) , +col_varchar_nokey VARCHAR(1) , +PRIMARY KEY (pk), +KEY (col_varchar_key,col_int_key) +) ENGINE=INNODB; +INSERT INTO t1 (col_int_key,col_varchar_key,col_varchar_nokey) VALUES +(0,'x','x'), (1,'j','j'), (1,'r','r'), (9,'v','v'), (5,'r','r'); +CREATE TABLE t2 ( +pk INTEGER AUTO_INCREMENT, +col_int_key INTEGER , +col_varchar_key VARCHAR(1) , +col_varchar_nokey VARCHAR(1) , +PRIMARY KEY (pk), +KEY (col_int_key), +KEY (col_varchar_key,col_int_key) +) AUTO_INCREMENT=10 ENGINE=INNODB; +INSERT INTO t2 (col_int_key, col_varchar_key, col_varchar_nokey) VALUES +(NULL,'x','x'), (NULL,'j','j'), (8,'c','c'); +CREATE TABLE t3 +SELECT outr.col_varchar_nokey AS x +FROM t1 AS outr +WHERE outr.col_varchar_nokey IN +(SELECT innr.col_varchar_nokey AS y +FROM t2 AS innr +WHERE innr.col_int_key IS NULL) +AND outr.col_varchar_nokey IS NOT NULL +AND NOT col_varchar_key IS NULL; +SELECT * +FROM t3 +WHERE x NOT IN +(SELECT outr.col_varchar_nokey AS x +FROM t1 AS outr +WHERE outr.col_varchar_nokey IN +(SELECT innr.col_varchar_nokey AS y +FROM t2 AS innr +WHERE innr.col_int_key IS NULL) +AND outr.col_varchar_nokey IS NOT NULL +AND NOT col_varchar_key IS NULL); +x +DROP TABLE t1, t2, t3; +# End of test for bug#12797534. +# +# Bug#12714094: Assert in optimize_semijoin_nests() +# +CREATE TABLE it ( +pk int NOT NULL, +col_varchar VARCHAR(10) DEFAULT NULL, +PRIMARY KEY (pk) +) ENGINE=MyISAM; +INSERT INTO it VALUES (1, 'g'); +CREATE TABLE ot +SELECT alias1.pk AS field1 +FROM it AS alias1 +LEFT JOIN it AS alias2 +ON alias1.col_varchar = alias2.col_varchar +; +SELECT * +FROM ot +WHERE field1 IN ( +SELECT alias1.pk +FROM it AS alias1 +LEFT JOIN it AS alias2 +ON alias1.col_varchar = alias2.col_varchar +); +field1 +1 +DROP TABLE it, ot; +# End of test for bug#12714094 +# +# Bug#12867557: Valgrind: conditional jump/move at key_cmp +# +CREATE TABLE t1 ( +pk INTEGER AUTO_INCREMENT, +col_int_key INTEGER, +PRIMARY KEY (pk), +KEY (col_int_key) +) AUTO_INCREMENT=10; +INSERT INTO t1 (col_int_key) VALUES (8); +CREATE TABLE t2 ( +pk INTEGER AUTO_INCREMENT, +col_int_key INTEGER, +col_time_key TIME, +PRIMARY KEY (pk), +KEY (col_int_key), +KEY (col_time_key) +) AUTO_INCREMENT=10; +INSERT INTO t2 (col_int_key, col_time_key) +VALUES +(8, '22:55:23.019225'), (7, '10:19:31.050677'), (1, '14:40:36.038608'), +(7, '04:37:47.062416'), (9, '19:34:06.054514'), (NULL,'20:35:33.022996'), +(1, NULL), (9, '14:43:37.057393'), (2, '02:23:09.043438'), +(9, '01:22:45.041064'), (2, '00:00:00'), (4, '00:13:25.038482'), +(0, '03:47:16.042671'), (4, '01:41:48.007423'), (8, '00:00:00'), +(NULL, '22:32:04.047407'), (NULL, '16:44:14.028443'), (0, '17:38:37.059754'), +(NULL, '08:46:48.042388'), (8, '14:11:27.044095'); +CREATE TABLE t0 +SELECT DISTINCT grandparent1.col_time_key AS g1 +FROM t2 AS grandparent1 +WHERE grandparent1.col_int_key IN +(SELECT parent1.col_int_key AS p1 +FROM t1 AS parent1) +AND grandparent1.pk > 9; +UPDATE t0 +SET g1 = g1 +WHERE g1 IN +(SELECT grandparent1.col_time_key AS g1 +FROM t2 AS grandparent1 +WHERE grandparent1.col_int_key IN +(SELECT parent1.col_int_key AS p1 +FROM t1 AS parent1) +AND grandparent1.pk > 9); +DROP TABLE t0, t1, t2; +# End of test for bug#12867557 +# +# Bug#12711441: crash in fix_after_pullout +# +CREATE TABLE t1 ( +pk int NOT NULL, +col_int_nokey int DEFAULT NULL, +col_int_key int DEFAULT NULL, +col_time_key time DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +PRIMARY KEY (pk) +); +CREATE VIEW v1 AS SELECT * FROM t1; +CREATE TABLE t2 ( +col_int_key int DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +KEY col_varchar_key(col_varchar_key, col_int_key) +); +CREATE TABLE t3 ( +pk int NOT NULL, +col_int_key INT DEFAULT NULL, +PRIMARY KEY (pk) +); +CREATE TABLE t4 ( +col_int_nokey INT DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +KEY col_varchar_key(col_varchar_key) +); +CREATE TABLE ts +SELECT alias1.col_time_key AS field1 +FROM v1 AS alias1 +RIGHT JOIN t3 AS alias2 +ON alias2.col_int_key = alias1.col_int_nokey +WHERE alias1.pk >= SOME( +SELECT SQ1_alias1.pk AS SQ1_field1 +FROM t3 AS SQ1_alias1 +INNER JOIN (t2 AS SQ1_alias2 +INNER JOIN t4 AS SQ1_alias3 +ON SQ1_alias3.col_varchar_key = SQ1_alias2.col_varchar_nokey) +ON SQ1_alias3.col_int_nokey = SQ1_alias2.col_int_key +WHERE SQ1_alias2.col_varchar_key <= alias1.col_varchar_key +AND SQ1_alias3.col_varchar_nokey <> alias1.col_varchar_key) +; +SELECT * FROM ts WHERE field1 IN ( +SELECT alias1.col_time_key AS field1 +FROM v1 AS alias1 +RIGHT JOIN t3 AS alias2 +ON alias2.col_int_key = alias1.col_int_nokey +WHERE alias1.pk >= SOME( +SELECT SQ1_alias1.pk AS SQ1_field1 +FROM t3 AS SQ1_alias1 +INNER JOIN (t2 AS SQ1_alias2 +INNER JOIN t4 AS SQ1_alias3 +ON SQ1_alias3.col_varchar_key = SQ1_alias2.col_varchar_nokey) +ON SQ1_alias3.col_int_nokey = SQ1_alias2.col_int_key +WHERE SQ1_alias2.col_varchar_key <= alias1.col_varchar_key +AND SQ1_alias3.col_varchar_nokey <> alias1.col_varchar_key) +); +field1 +DROP TABLE t1, t2, t3, t4, ts; +DROP VIEW v1; +# End of test for bug#12711441. +# +# Bug#12664936: Same query executed as where subquery ... +# +CREATE TABLE t1 ( +col_varchar_key VARCHAR(1), +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4; +INSERT INTO t1 VALUES +('o'), ('w'), ('m'), ('q'), +('f'), ('p'), ('j'), ('c'); +CREATE TABLE t2 ( +col_int_nokey INTEGER, +col_int_key INTEGER, +col_varchar_key varchar(1), +KEY col_int_key (col_int_key) +) charset utf8mb4; +INSERT INTO t2 VALUES +(8,5,'u'),(4,5,'p'),(8,1,'o'),(NULL,7,'v'), +(1,2,'g'),(2,1,'q'),(NULL,7,'l'),(3,1,'n'); +CREATE TABLE t4 +SELECT t2.col_int_nokey, t2.col_varchar_key +FROM t1 JOIN t2 ON t2.col_varchar_key = t1.col_varchar_key +WHERE t2.col_int_key = 1; +EXPLAIN SELECT * +FROM t4 +WHERE (col_int_nokey, col_varchar_key) IN +(SELECT t2.col_int_nokey, t2.col_varchar_key +FROM t1 JOIN t2 ON t2.col_varchar_key = t1.col_varchar_key +WHERE t2.col_int_key = 1 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t4 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE t2 NULL ref col_int_key col_int_key 5 const 3 12.50 Using where; Start temporary +1 SIMPLE t1 NULL ref col_varchar_key col_varchar_key 7 test.t4.col_varchar_key 2 100.00 Using index; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`col_int_nokey` AS `col_int_nokey`,`test`.`t4`.`col_varchar_key` AS `col_varchar_key` from `test`.`t4` semi join (`test`.`t1` join `test`.`t2`) where ((`test`.`t2`.`col_varchar_key` = `test`.`t4`.`col_varchar_key`) and (`test`.`t1`.`col_varchar_key` = `test`.`t4`.`col_varchar_key`) and (`test`.`t2`.`col_int_nokey` = `test`.`t4`.`col_int_nokey`) and (`test`.`t2`.`col_int_key` = 1)) +SELECT * +FROM t4 +WHERE (col_int_nokey, col_varchar_key) IN +(SELECT t2.col_int_nokey, t2.col_varchar_key +FROM t1 JOIN t2 ON t2.col_varchar_key = t1.col_varchar_key +WHERE t2.col_int_key = 1 +); +col_int_nokey col_varchar_key +8 o +2 q +DROP TABLE t1, t2, t4; +# End of test for bug#12664936. +# +# Bug#13340270: assertion table->sort.record_pointers == __null +# +CREATE TABLE t1 ( +pk int NOT NULL, +col_int_key int DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key, col_int_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t1 VALUES +(10,8,'x','x'), +(11,7,'d','d'), +(12,1,'r','r'), +(13,7,'f','f'), +(14,9,'y','y'), +(15,NULL,'u','u'), +(16,1,'m','m'), +(17,9,NULL,NULL), +(18,2,'o','o'), +(19,9,'w','w'), +(20,2,'m','m'), +(21,4,'q','q'); +CREATE TABLE t2 +SELECT alias1.col_varchar_nokey AS field1 +FROM t1 AS alias1 JOIN t1 AS alias2 +ON alias2.col_int_key = alias1.pk OR +alias2.col_int_key = alias1.col_int_key +WHERE alias1.pk = 58 OR alias1.col_varchar_key = 'o' + +; +EXPLAIN SELECT * +FROM t2 +WHERE (field1) IN (SELECT alias1.col_varchar_nokey AS field1 +FROM t1 AS alias1 JOIN t1 AS alias2 +ON alias2.col_int_key = alias1.pk OR +alias2.col_int_key = alias1.col_int_key +WHERE alias1.pk = 58 OR alias1.col_varchar_key = 'o' +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE alias1 NULL index_merge PRIMARY,col_int_key,col_varchar_key col_varchar_key,PRIMARY 7,4 NULL 2 10.00 Using sort_union(col_varchar_key,PRIMARY); Using where; Start temporary +1 SIMPLE alias2 NULL ALL col_int_key NULL NULL NULL 12 19.00 Range checked for each record (index map: 0x2); End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`field1` AS `field1` from `test`.`t2` semi join (`test`.`t1` `alias1` join `test`.`t1` `alias2`) where ((`test`.`alias1`.`col_varchar_nokey` = `test`.`t2`.`field1`) and ((`test`.`alias1`.`pk` = 58) or (`test`.`alias1`.`col_varchar_key` = 'o')) and ((`test`.`alias2`.`col_int_key` = `test`.`alias1`.`pk`) or (`test`.`alias2`.`col_int_key` = `test`.`alias1`.`col_int_key`))) +SELECT * +FROM t2 +WHERE (field1) IN (SELECT alias1.col_varchar_nokey AS field1 +FROM t1 AS alias1 JOIN t1 AS alias2 +ON alias2.col_int_key = alias1.pk OR +alias2.col_int_key = alias1.col_int_key +WHERE alias1.pk = 58 OR alias1.col_varchar_key = 'o' +); +field1 +o +o +DROP TABLE t1, t2; +# End of test for bug#13340270. +# +# Bug#13335319: Seg fault when analyzing FirstMatch semi-join strategy +# +CREATE TABLE ot1(a INTEGER); +INSERT INTO ot1 VALUES(1), (2), (3); +CREATE TABLE ot2(a INTEGER); +INSERT INTO ot2 VALUES(1), (2), (4), (6), (8), (10); +CREATE TABLE it1(a INTEGER); +INSERT INTO it1 VALUES(1), (3), (5), (7); +CREATE TABLE it2(a INTEGER); +INSERT INTO it2 VALUES(1), (3), (5), (7), (9); +explain SELECT ot1.a, ot2.a +FROM ot1, ot2 +WHERE ot1.a IN (SELECT a FROM it1) AND +ot2.a IN (SELECT a FROM it2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE it2 NULL ALL NULL NULL NULL NULL 5 100.00 Start temporary +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE it1 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` join `test`.`ot2` semi join (`test`.`it1`) semi join (`test`.`it2`) where ((`test`.`ot2`.`a` = `test`.`it2`.`a`) and (`test`.`it1`.`a` = `test`.`ot1`.`a`)) +SELECT ot1.a, ot2.a +FROM ot1, ot2 +WHERE ot1.a IN (SELECT a FROM it1) AND +ot2.a IN (SELECT a FROM it2); +a a +1 1 +3 1 +DROP TABLE ot1, ot2, it1, it2; +# End of test for bug#13335319. +# +# Bug#13334882: Assertion keypart_map failed in MyIsam function +# +CREATE TABLE t1 ( +pk int NOT NULL, +col_int_nokey INT NOT NULL, +col_int_key INT NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +) ENGINE=MyISAM; +INSERT INTO t1 VALUES +(1,4,0), +(2,6,8), +(3,3,1), +(7,2,6), +(8,9,1), +(9,3,6), +(10,8,2), +(11,1,4), +(12,8,8), +(13,8,4), +(14,5,4); +CREATE TABLE t2 ( +pk int NOT NULL, +col_int_nokey int NOT NULL, +col_int_key int NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +) ENGINE=MyISAM; +INSERT INTO t2 VALUES +(10,8,7); +CREATE TABLE t3 +SELECT grandparent1.col_int_nokey AS g1 +FROM t1 AS grandparent1 +WHERE (grandparent1.col_int_nokey, grandparent1.col_int_key) IN +(SELECT parent1.col_int_key AS p1, +parent1.col_int_key AS p2 +FROM t1 AS parent1 +LEFT JOIN t2 AS parent2 +ON parent1.col_int_nokey = parent2.col_int_key +) +AND grandparent1.col_int_key <> 3 +; +explain SELECT * FROM t3 +WHERE g1 NOT IN +(SELECT grandparent1.col_int_nokey AS g1 +FROM t1 AS grandparent1 +WHERE (grandparent1.col_int_nokey, grandparent1.col_int_key) IN +(SELECT parent1.col_int_key AS p1, +parent1.col_int_key AS p2 +FROM t1 AS parent1 +LEFT JOIN t2 AS parent2 +ON parent1.col_int_nokey = parent2.col_int_key +) +AND grandparent1.col_int_key <> 3 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE grandparent1 NULL ref col_int_key col_int_key 4 const 1 100.00 Using where; Not exists; Start temporary +1 SIMPLE parent1 NULL ref col_int_key col_int_key 4 test.grandparent1.col_int_nokey 1 100.00 Using where +1 SIMPLE parent2 NULL ref col_int_key col_int_key 4 test.parent1.col_int_nokey 2 100.00 Using index; End temporary +Warnings: +Note 1003 /* select#1 */ select '8' AS `g1` from anti join (`test`.`t1` `grandparent1` join `test`.`t1` `parent1` left join `test`.`t2` `parent2` on((`test`.`parent2`.`col_int_key` = `test`.`parent1`.`col_int_nokey`))) on(((`test`.`grandparent1`.`col_int_nokey` = '8') and (`test`.`grandparent1`.`col_int_key` = '8') and (`test`.`parent1`.`col_int_key` = '8') and ('8' <> 3))) where true +explain format=json SELECT * FROM t3 +WHERE g1 NOT IN +(SELECT grandparent1.col_int_nokey AS g1 +FROM t1 AS grandparent1 +WHERE (grandparent1.col_int_nokey, grandparent1.col_int_key) IN +(SELECT parent1.col_int_key AS p1, +parent1.col_int_key AS p2 +FROM t1 AS parent1 +LEFT JOIN t2 AS parent2 +ON parent1.col_int_nokey = parent2.col_int_key +) +AND grandparent1.col_int_key <> 3 +); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "2.70" + }, + "nested_loop": [ + { + "table": { + "table_name": "t3", + "access_type": "system", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.00", + "eval_cost": "0.10", + "prefix_cost": "0.00", + "data_read_per_join": "8" + }, + "used_columns": [ + "g1" + ] + } + }, + { + "duplicates_removal": { + "using_temporary_table": true, + "nested_loop": [ + { + "table": { + "table_name": "grandparent1", + "access_type": "ref", + "possible_keys": [ + "col_int_key" + ], + "key": "col_int_key", + "used_key_parts": [ + "col_int_key" + ], + "key_length": "4", + "ref": [ + "const" + ], + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "not_exists": true, + "cost_info": { + "read_cost": "0.28", + "eval_cost": "0.11", + "prefix_cost": "0.39", + "data_read_per_join": "17" + }, + "used_columns": [ + "col_int_nokey", + "col_int_key" + ], + "attached_condition": "(((is_not_null_compl(grandparent1..parent2), (found_match(grandparent1..parent2), false, true), true) and (is_not_null_compl(grandparent1..parent2), (('8' <> 3)), true)) and (is_not_null_compl(grandparent1..parent2), (`test`.`grandparent1`.`col_int_nokey` = '8'), true))" + } + }, + { + "table": { + "table_name": "parent1", + "access_type": "ref", + "possible_keys": [ + "col_int_key" + ], + "key": "col_int_key", + "used_key_parts": [ + "col_int_key" + ], + "key_length": "4", + "ref": [ + "test.grandparent1.col_int_nokey" + ], + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.30", + "eval_cost": "0.12", + "prefix_cost": "0.81", + "data_read_per_join": "19" + }, + "used_columns": [ + "col_int_nokey", + "col_int_key" + ], + "attached_condition": "(is_not_null_compl(grandparent1..parent2), (`test`.`parent1`.`col_int_key` = '8'), true)" + } + }, + { + "table": { + "table_name": "parent2", + "access_type": "ref", + "possible_keys": [ + "col_int_key" + ], + "key": "col_int_key", + "used_key_parts": [ + "col_int_key" + ], + "key_length": "4", + "ref": [ + "test.parent1.col_int_nokey" + ], + "rows_examined_per_scan": 2, + "rows_produced_per_join": 1, + "filtered": "100.00", + "using_index": true, + "cost_info": { + "read_cost": "0.31", + "eval_cost": "0.10", + "prefix_cost": "2.70", + "data_read_per_join": "16" + }, + "used_columns": [ + "col_int_key" + ] + } + } + ] + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select '8' AS `g1` from anti join (`test`.`t1` `grandparent1` join `test`.`t1` `parent1` left join `test`.`t2` `parent2` on((`test`.`parent2`.`col_int_key` = `test`.`parent1`.`col_int_nokey`))) on(((`test`.`grandparent1`.`col_int_nokey` = '8') and (`test`.`grandparent1`.`col_int_key` = '8') and (`test`.`parent1`.`col_int_key` = '8') and ('8' <> 3))) where true +SELECT * FROM t3 +WHERE g1 NOT IN +(SELECT grandparent1.col_int_nokey AS g1 +FROM t1 AS grandparent1 +WHERE (grandparent1.col_int_nokey, grandparent1.col_int_key) IN +(SELECT parent1.col_int_key AS p1, +parent1.col_int_key AS p2 +FROM t1 AS parent1 +LEFT JOIN t2 AS parent2 +ON parent1.col_int_nokey = parent2.col_int_key +) +AND grandparent1.col_int_key <> 3 +); +g1 +DROP TABLE t1, t2, t3; +# End of test for bug#13334882. +# +# Bug#13339643: Assertion on JOIN::flatten_subqueries on second execution +# +CREATE TABLE t1 ( +col_int_nokey INT, +col_varchar_nokey VARCHAR(1) +) charset utf8mb4; +INSERT INTO t1 VALUES +(1,'o'), +(2,'t'); +CREATE TABLE t2 LIKE t1; +INSERT INTO t2 VALUES +(1,'o'), +(4,'f'); +CREATE VIEW v_t2 AS SELECT * FROM t2; +CREATE TABLE t3 LIKE t1; +INSERT INTO t3 VALUES +(1,'o'), +(4,'f'); +explain SELECT alias1.col_varchar_nokey +FROM t1 AS alias1 +INNER JOIN v_t2 AS alias2 +ON alias2.col_int_nokey = alias1.col_int_nokey AND +'o' IN (SELECT col_varchar_nokey +FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary; End temporary +1 SIMPLE alias1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`alias1`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t1` `alias1` join `test`.`t2` semi join (`test`.`t3`) where ((`test`.`t3`.`col_varchar_nokey` = 'o') and (`test`.`t2`.`col_int_nokey` = `test`.`alias1`.`col_int_nokey`)) +SELECT alias1.col_varchar_nokey +FROM t1 AS alias1 +INNER JOIN v_t2 AS alias2 +ON alias2.col_int_nokey = alias1.col_int_nokey AND +'o' IN (SELECT col_varchar_nokey +FROM t3); +col_varchar_nokey +o +PREPARE stmt FROM "SELECT alias1.col_varchar_nokey +FROM t1 AS alias1 +INNER JOIN v_t2 AS alias2 +ON alias2.col_int_nokey = alias1.col_int_nokey AND +'o' IN (SELECT col_varchar_nokey +FROM t3)"; +EXECUTE stmt; +col_varchar_nokey +o +DROP VIEW v_t2; +DROP TABLE t1, t2, t3; +# End of test for bug#13339643. +# +# Bug#13424134: Wrong result on JOIN + nested WHERE ... IN clauses +# +CREATE TABLE t1 ( +pk int NOT NULL, +col_int_nokey int NOT NULL, +col_int_key int NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +) ENGINE=MyIsam; +INSERT INTO t1 VALUES +(10,1,7), (13,7,3), (18,0,1), (23,8,1); +CREATE TABLE t2 ( +pk int NOT NULL, +col_int_key int NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +) ENGINE=MyIsam; +INSERT INTO t2 VALUES (1,7); +EXPLAIN SELECT t1a.* +FROM t1 AS t1a +JOIN t1 AS t1b USING ( col_int_nokey ) +WHERE t1a.col_int_key IN ( +SELECT pk +FROM t2 +WHERE col_int_key IN ( +SELECT col_int_nokey +FROM t1 +) +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL system PRIMARY,col_int_key NULL NULL NULL 1 100.00 NULL +1 SIMPLE t1a NULL ref col_int_key col_int_key 4 const 1 100.00 NULL +1 SIMPLE t1b NULL ALL NULL NULL NULL NULL 4 25.00 Using where +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; Start temporary; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1a`.`pk` AS `pk`,`test`.`t1a`.`col_int_nokey` AS `col_int_nokey`,`test`.`t1a`.`col_int_key` AS `col_int_key` from `test`.`t1` `t1a` join `test`.`t1` `t1b` semi join (`test`.`t1`) where ((`test`.`t1b`.`col_int_nokey` = `test`.`t1a`.`col_int_nokey`) and (`test`.`t1a`.`col_int_key` = '1') and (`test`.`t1`.`col_int_nokey` = '7')) +SELECT t1a.* +FROM t1 AS t1a +JOIN t1 AS t1b USING ( col_int_nokey ) +WHERE t1a.col_int_key IN ( +SELECT pk +FROM t2 +WHERE col_int_key IN ( +SELECT col_int_nokey +FROM t1 +) +); +pk col_int_nokey col_int_key +18 0 1 +23 8 1 +ALTER TABLE t1 ENGINE=Innodb; +ALTER TABLE t2 ENGINE=Innodb; +SELECT t1a.* +FROM t1 AS t1a +JOIN t1 AS t1b USING ( col_int_nokey ) +WHERE t1a.col_int_key IN ( +SELECT pk +FROM t2 +WHERE col_int_key IN ( +SELECT col_int_nokey +FROM t1 +) +); +pk col_int_nokey col_int_key +18 0 1 +23 8 1 +DROP TABLE t1, t2; +# End of test for bug#13424134. +# +# Bug#13414014: Extra rows in result on semijoin query with where ... +# +CREATE TABLE t1 ( +c INT, +d INT, +a VARCHAR(1), +b VARCHAR(1), +KEY a (a) +) charset utf8mb4; +INSERT INTO t1 VALUES +(NULL,8,'x','x'), (7,4,'q','q'), (6,8,'c','c'); +CREATE TABLE t2 ( +a VARCHAR(1), +KEY a (a) +) charset utf8mb4; +INSERT INTO t2 VALUES +('c'), (NULL), ('x'), ('q'); +explain SELECT * +FROM t2 AS ot +WHERE (a, a) IN +(SELECT a, b +FROM t1 AS it +WHERE it.a = 'x' OR it.c > it.d +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE it NULL ALL a NULL NULL NULL 3 40.74 Using where; Start temporary +1 SIMPLE ot NULL ref a a 7 test.it.a 2 100.00 Using index; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`ot`.`a` AS `a` from `test`.`t2` `ot` semi join (`test`.`t1` `it`) where ((`test`.`it`.`b` = `test`.`it`.`a`) and (`test`.`ot`.`a` = `test`.`it`.`a`) and ((`test`.`it`.`a` = 'x') or (`test`.`it`.`c` > `test`.`it`.`d`))) +SELECT * +FROM t2 AS ot +WHERE (a, a) IN +(SELECT a, b +FROM t1 AS it +WHERE it.a = 'x' OR it.c > it.d +) +; +a +q +x +DROP TABLE t1, t2; +# End of test for bug#13414014. +# +# Bug#13545215: Missing rows on nested in-subquery with materialization +# +CREATE TABLE t1 ( +col_int_key int, +col_varchar_key varchar(1), +col_varchar_nokey varchar(1), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +INSERT INTO t1 VALUES +(8,'x','x'), (0,'p','p'), (8,'c','c'); +CREATE TABLE t2 ( +pk int NOT NULL, +col_varchar_key varchar(1), +col_varchar_nokey varchar(1), +PRIMARY KEY (pk), +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4; +INSERT INTO t2 VALUES +(1,'v','v'), (2,'v','v'), (3,'c','c'), (4,NULL,NULL), +(5,'x','x'), (6,'i','i'), (7,'e','e'), (8,'p','p'); +CREATE TABLE t3 ( +col_int_nokey int +); +INSERT INTO t3 VALUES (7); +explain SELECT grandparent1.col_varchar_nokey +FROM t1 AS grandparent1 JOIN t1 AS grandparent2 USING (col_int_key) +WHERE grandparent1.col_varchar_key IN ( +SELECT col_varchar_nokey +FROM t2 AS parent1 +WHERE col_varchar_key IN ( +SELECT child1.col_varchar_nokey +FROM t2 AS child1 LEFT JOIN t3 AS child2 +ON child1.pk < child2.col_int_nokey +) +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE grandparent1 NULL ALL col_int_key,col_varchar_key NULL NULL NULL 3 100.00 Using where +1 SIMPLE parent1 NULL ALL col_varchar_key NULL NULL NULL 8 12.50 Using where; Start temporary +1 SIMPLE child1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where +1 SIMPLE child2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary +1 SIMPLE grandparent2 NULL ref col_int_key col_int_key 5 test.grandparent1.col_int_key 2 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`grandparent1`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t1` `grandparent1` join `test`.`t1` `grandparent2` semi join (`test`.`t2` `parent1` join `test`.`t2` `child1` left join `test`.`t3` `child2` on((`test`.`child1`.`pk` < `test`.`child2`.`col_int_nokey`))) where ((`test`.`grandparent2`.`col_int_key` = `test`.`grandparent1`.`col_int_key`) and (`test`.`parent1`.`col_varchar_nokey` = `test`.`grandparent1`.`col_varchar_key`) and (`test`.`child1`.`col_varchar_nokey` = `test`.`parent1`.`col_varchar_key`)) +SELECT grandparent1.col_varchar_nokey +FROM t1 AS grandparent1 JOIN t1 AS grandparent2 USING (col_int_key) +WHERE grandparent1.col_varchar_key IN ( +SELECT col_varchar_nokey +FROM t2 AS parent1 +WHERE col_varchar_key IN ( +SELECT child1.col_varchar_nokey +FROM t2 AS child1 LEFT JOIN t3 AS child2 +ON child1.pk < child2.col_int_nokey +) +); +col_varchar_nokey +c +c +p +x +x +DROP TABLE t1, t2, t3; +# End of test for bug#13545215. +# +# BUG#13553211 - MISSING ROWS ON SELECT WITH IN-SUBQUERY AND +# MATERIALIZATION + SEMIJOIN ON +# +CREATE TABLE t1 ( +col_int_key int(11) DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (4,'v','v'); +INSERT INTO t1 VALUES (62,'v','v'); +INSERT INTO t1 VALUES (7,'c','c'); +INSERT INTO t1 VALUES (1,NULL,NULL); +EXPLAIN SELECT +alias1.col_varchar_nokey AS a1_nokey, +alias1.col_varchar_key AS a1_key, +alias2.col_varchar_nokey AS a2_nokey +FROM +t1 AS alias1, t1 AS alias2 +WHERE +(alias1.col_varchar_nokey,alias2.col_varchar_nokey) +IN +( +SELECT +sq2_alias2.col_varchar_nokey, sq2_alias1.col_varchar_key +FROM +t1 AS sq2_alias1, t1 AS sq2_alias2 +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE alias1 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +1 SIMPLE sq2_alias1 NULL index col_varchar_key col_varchar_key 12 NULL 4 100.00 Using index; LooseScan +1 SIMPLE sq2_alias2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; FirstMatch(sq2_alias1) +1 SIMPLE alias2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`alias1`.`col_varchar_nokey` AS `a1_nokey`,`test`.`alias1`.`col_varchar_key` AS `a1_key`,`test`.`alias2`.`col_varchar_nokey` AS `a2_nokey` from `test`.`t1` `alias1` join `test`.`t1` `alias2` semi join (`test`.`t1` `sq2_alias1` join `test`.`t1` `sq2_alias2`) where ((`test`.`alias2`.`col_varchar_nokey` = `test`.`sq2_alias1`.`col_varchar_key`) and (`test`.`sq2_alias2`.`col_varchar_nokey` = `test`.`alias1`.`col_varchar_nokey`)) +SELECT +alias1.col_varchar_nokey AS a1_nokey, +alias1.col_varchar_key AS a1_key, +alias2.col_varchar_nokey AS a2_nokey +FROM +t1 AS alias1, t1 AS alias2 +WHERE +(alias1.col_varchar_nokey,alias2.col_varchar_nokey) +IN +( +SELECT +sq2_alias2.col_varchar_nokey, sq2_alias1.col_varchar_key +FROM +t1 AS sq2_alias1, t1 AS sq2_alias2 +) +; +a1_nokey a1_key a2_nokey +c c c +c c v +c c v +v v c +v v c +v v v +v v v +v v v +v v v +DROP TABLE t1; +# +# Bug#13541406: Wrong result with loosescan on select .. where .. in +# +CREATE TABLE t1 ( +col_int_key INT NOT NULL, +col_varchar_nokey VARCHAR(1) NOT NULL, +KEY col_int_key (col_int_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t1 VALUES +(7,'v'), (0,'s'), (9,'l'), (3,'y'), (4,'c'), (2,'i'), (5,'h'), (3,'q'), +(1,'a'), (3,'v'), (6,'u'), (7,'s'), (5,'y'), (1,'z'), (204,'h'), (224,'p'), +(9,'e'), (5,'i'), (0,'y'), (3,'w'); +CREATE TABLE t2 ( +pk INT NOT NULL, +col_int_key INT NOT NULL, +col_varchar_key VARCHAR(1) NOT NULL, +col_varchar_nokey VARCHAR(1) NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t2 VALUES +(1,0,'j','j'), (2,8,'v','v'), (3,1,'c','c'), (4,8,'m','m'), +(5,9,'d','d'), (6,24,'d','d'), (7,6,'y','y'), (8,1,'t','t'), +(9,6,'d','d'), (10,2,'s','s'), (11,4,'r','r'), (12,8,'m','m'), +(13,4,'b','b'), (14,4,'x','x'), (15,7,'g','g'), (16,4,'p','p'), +(17,1,'q','q'), (18,9,'w','w'), (19,4,'d','d'), (20,8,'e','e'); +# This query should never use a LooseScan strategy +explain SELECT ot1.col_int_key AS field1 +FROM t2 AS ot1, t2 AS ot2 +WHERE (ot1.col_varchar_key, ot2.col_varchar_nokey) IN ( +SELECT it2.col_varchar_nokey, it1.col_varchar_key +FROM t2 AS it1 JOIN t1 AS it2 ON it2.col_int_key = it1.pk); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 20 100.00 Parallel execute (1 workers) +2 SIMPLE ot1 NULL index col_varchar_key col_varchar_key 10 NULL 20 100.00 Using index +2 SIMPLE it1 NULL index PRIMARY,col_varchar_key col_varchar_key 10 NULL 20 80.00 Using index; LooseScan +2 SIMPLE it2 NULL ref col_int_key col_int_key 4 test.it1.pk 1 10.00 Using where; FirstMatch(it1) +2 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 20 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`col_int_key` AS `field1` from `test`.`t2` `ot1` join `test`.`t2` `ot2` semi join (`test`.`t2` `it1` join `test`.`t1` `it2`) where ((`test`.`it2`.`col_int_key` = `test`.`it1`.`pk`) and (`test`.`ot2`.`col_varchar_nokey` = `test`.`it1`.`col_varchar_key`) and (`test`.`it2`.`col_varchar_nokey` = `test`.`ot1`.`col_varchar_key`)) +SELECT ot1.col_int_key AS field1 +FROM t2 AS ot1, t2 AS ot2 +WHERE (ot1.col_varchar_key, ot2.col_varchar_nokey) IN ( +SELECT it2.col_varchar_nokey, it1.col_varchar_key +FROM t2 AS it1 JOIN t1 AS it2 ON it2.col_int_key = it1.pk); +field1 +1 +1 +1 +2 +6 +6 +6 +6 +6 +8 +8 +8 +8 +8 +8 +9 +DROP TABLE t1, t2; +# End of test for bug#13541406. +# +# Bug#13576391: Missing rows on select with in-subquery and +# batched-key-access=on and semijoin +# +CREATE TABLE t1 ( +col_int_nokey int NOT NULL, +col_varchar_key varchar(1) NOT NULL, +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4 engine=InnoDB; +INSERT INTO t1 VALUES +(1,'v'), (7,'s'), (4,'l'), (7,'y'), (0,'c'), (2,'i'), (9,'h'), (4,'q'), +(0,'a'), (9,'v'), (1,'u'), (3,'s'), (8,'y'), (8,'z'), (18,'h'), (84,'p'), +(6,'e'), (3,'i'), (6,'y'), (6,'w'); +CREATE TABLE t2 ( +col_int_nokey int NOT NULL, +col_varchar_nokey varchar(1) NOT NULL +) charset utf8mb4 engine=InnoDB; +INSERT INTO t2 VALUES +(4,'j'), (6,'v'), (3,'c'), (5,'m'), (3,'d'), (246,'d'), (2,'y'), (9,'t'), +(3,'d'), (8,'s'), (1,'r'), (8,'m'), (8,'b'), (5,'x'), (7,'g'), (5,'p'), +(1,'q'), (6,'w'), (2,'d'), (9,'e'); +explain SELECT col_varchar_nokey +FROM t2 AS ot +WHERE col_varchar_nokey IN ( +SELECT col_varchar_key +FROM t1 AS it +WHERE it.col_int_nokey <= it.col_int_nokey +AND NOT ot.col_int_nokey < 2 +) +ORDER BY col_varchar_nokey; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 20 33.33 Parallel execute (1 workers) +2 SIMPLE ot NULL ALL NULL NULL NULL NULL 20 33.33 Using where; Using filesort +2 SIMPLE it NULL ref col_varchar_key col_varchar_key 6 test.ot.col_varchar_nokey 1 100.00 Start temporary; End temporary +Warnings: +Note 1276 Field or reference 'test.ot.col_int_nokey' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`ot`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t2` `ot` semi join (`test`.`t1` `it`) where ((`test`.`it`.`col_varchar_key` = `test`.`ot`.`col_varchar_nokey`) and (`test`.`ot`.`col_int_nokey` >= 2)) order by `test`.`ot`.`col_varchar_nokey` +SELECT col_varchar_nokey +FROM t2 AS ot +WHERE col_varchar_nokey IN ( +SELECT col_varchar_key +FROM t1 AS it +WHERE it.col_int_nokey <= it.col_int_nokey +AND NOT ot.col_int_nokey < 2 +) +ORDER BY col_varchar_nokey; +col_varchar_nokey +c +e +p +s +v +w +y +ALTER TABLE t1 ENGINE=MyISAM; +ALTER TABLE t2 ENGINE=MyISAM; +explain SELECT col_varchar_nokey +FROM t2 AS ot +WHERE col_varchar_nokey IN ( +SELECT col_varchar_key +FROM t1 AS it +WHERE it.col_int_nokey <= it.col_int_nokey +AND NOT ot.col_int_nokey < 2 +) +ORDER BY col_varchar_nokey; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 20 33.33 Using where; Using filesort +1 SIMPLE it NULL ref col_varchar_key col_varchar_key 6 test.ot.col_varchar_nokey 2 100.00 Start temporary; End temporary +Warnings: +Note 1276 Field or reference 'test.ot.col_int_nokey' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`ot`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t2` `ot` semi join (`test`.`t1` `it`) where ((`test`.`it`.`col_varchar_key` = `test`.`ot`.`col_varchar_nokey`) and (`test`.`ot`.`col_int_nokey` >= 2)) order by `test`.`ot`.`col_varchar_nokey` +SELECT col_varchar_nokey +FROM t2 AS ot +WHERE col_varchar_nokey IN ( +SELECT col_varchar_key +FROM t1 AS it +WHERE it.col_int_nokey <= it.col_int_nokey +AND NOT ot.col_int_nokey < 2 +) +ORDER BY col_varchar_nokey; +col_varchar_nokey +c +e +p +s +v +w +y +ALTER TABLE t1 ENGINE=Memory; +ALTER TABLE t2 ENGINE=Memory; +explain SELECT col_varchar_nokey +FROM t2 AS ot +WHERE col_varchar_nokey IN ( +SELECT col_varchar_key +FROM t1 AS it +WHERE it.col_int_nokey <= it.col_int_nokey +AND NOT ot.col_int_nokey < 2 +) +ORDER BY col_varchar_nokey; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 20 33.33 Using where; Using filesort +1 SIMPLE it NULL ref col_varchar_key col_varchar_key 6 test.ot.col_varchar_nokey 2 100.00 Start temporary; End temporary +Warnings: +Note 1276 Field or reference 'test.ot.col_int_nokey' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`ot`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t2` `ot` semi join (`test`.`t1` `it`) where ((`test`.`it`.`col_varchar_key` = `test`.`ot`.`col_varchar_nokey`) and (`test`.`ot`.`col_int_nokey` >= 2)) order by `test`.`ot`.`col_varchar_nokey` +SELECT col_varchar_nokey +FROM t2 AS ot +WHERE col_varchar_nokey IN ( +SELECT col_varchar_key +FROM t1 AS it +WHERE it.col_int_nokey <= it.col_int_nokey +AND NOT ot.col_int_nokey < 2 +) +ORDER BY col_varchar_nokey; +col_varchar_nokey +c +e +p +s +v +w +y +DROP TABLE t1, t2; +# End of test for bug#13576391. +# +# Bug #13589848 "MISSING ROW ON SELECT WITH NESTED IN CLAUSES WHEN LOOSESCAN=ON" +# +CREATE TABLE t1 ( +id INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +KEY (col_varchar_key) +) charset utf8mb4; +INSERT INTO t1 VALUES (100,'m','m'), +(200,'b','b'), (300,'x','x'); +CREATE TABLE t2 ( +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +KEY (col_varchar_key) +) charset utf8mb4; +INSERT INTO t2 VALUES ('b','b'); +CREATE TABLE t3 ( +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +KEY (col_varchar_key) +) charset utf8mb4; +INSERT INTO t3 VALUES ('k','k'); +EXPLAIN SELECT gp1.id +FROM t1 AS gp1 JOIN t3 AS gp2 +ON gp2.col_varchar_key <> gp1.col_varchar_nokey +WHERE (gp1.col_varchar_nokey, gp1.col_varchar_nokey) +IN ( +SELECT col_varchar_nokey, col_varchar_nokey +FROM t1 +WHERE col_varchar_nokey +IN ( SELECT col_varchar_key +FROM t2 LEFT JOIN t3 USING (col_varchar_key) ) +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE gp2 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL index col_varchar_key col_varchar_key 7 NULL 1 100.00 Using where; Using index; Start temporary +1 SIMPLE gp1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +1 SIMPLE t3 NULL ref col_varchar_key col_varchar_key 7 test.t2.col_varchar_key 2 100.00 Using index; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`gp1`.`id` AS `id` from `test`.`t1` `gp1` semi join (`test`.`t1` join `test`.`t2` left join `test`.`t3` on((`test`.`t2`.`col_varchar_key` = `test`.`t3`.`col_varchar_key`))) where ((`test`.`gp1`.`col_varchar_nokey` = `test`.`t2`.`col_varchar_key`) and (`test`.`t1`.`col_varchar_nokey` = `test`.`t2`.`col_varchar_key`) and ('k' <> `test`.`t2`.`col_varchar_key`)) +SELECT gp1.id +FROM t1 AS gp1 JOIN t3 AS gp2 +ON gp2.col_varchar_key <> gp1.col_varchar_nokey +WHERE (gp1.col_varchar_nokey, gp1.col_varchar_nokey) +IN ( +SELECT col_varchar_nokey, col_varchar_nokey +FROM t1 +WHERE col_varchar_nokey +IN ( SELECT col_varchar_key +FROM t2 LEFT JOIN t3 USING (col_varchar_key) ) +) +; +id +200 +DROP TABLE t1,t2,t3; +# +# Bug #13596176: Missing row on select with nested in clause when +# matr=on and bnl=off + MyISAM +# +CREATE TABLE t1 ( +int_key int DEFAULT NULL, +vc_key varchar(1) DEFAULT NULL, +vc_nokey varchar(1) DEFAULT NULL, +KEY int_key (int_key), +KEY vc_key (vc_key, int_key) +) charset utf8mb4 ENGINE=MyISAM; +INSERT INTO t1 VALUES +(8,'x','x'), (7,'d','d'), (1,'r','r'), (7,'f','f'), +(9,'y','y'), (NULL,'u','u'), (1,'m','m'), (9,NULL,NULL), +(2,'o','o'), (9,'w','w'), (2,'m','m'), (4,'q','q'), +(0,NULL,NULL), (4,'d','d'), (8,'g','g'), (NULL,'x','x'), +(NULL,'f','f'), (0,'p','p'), (NULL,'j','j'), (8,'c','c'); +CREATE TABLE t2 ( +int_key int DEFAULT NULL, +vc_key varchar(1) DEFAULT NULL, +KEY int_key (int_key), +KEY vc_key (vc_key, int_key) +) charset utf8mb4 ENGINE=MyISAM; +INSERT INTO t2 VALUES (8,'g'); +explain SELECT vc_key +FROM t1 as outr +WHERE (vc_nokey, vc_key ) IN +(SELECT vc_nokey, vc_nokey +FROM t1 middle +WHERE vc_nokey IN +(SELECT child1.vc_key +FROM t2 AS child1 JOIN t1 AS child2 USING (int_key) +) +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE child1 NULL index int_key,vc_key vc_key 12 NULL 1 100.00 Using where; Using index; Start temporary +1 SIMPLE outr NULL ref vc_key vc_key 7 test.child1.vc_key 3 10.00 Using where +1 SIMPLE middle NULL ALL NULL NULL NULL NULL 20 10.00 Using where +1 SIMPLE child2 NULL ref int_key int_key 5 test.child1.int_key 3 100.00 Using index; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`outr`.`vc_key` AS `vc_key` from `test`.`t1` `outr` semi join (`test`.`t1` `middle` join `test`.`t2` `child1` join `test`.`t1` `child2`) where ((`test`.`child2`.`int_key` = `test`.`child1`.`int_key`) and (`test`.`outr`.`vc_nokey` = `test`.`child1`.`vc_key`) and (`test`.`outr`.`vc_key` = `test`.`child1`.`vc_key`) and (`test`.`middle`.`vc_nokey` = `test`.`child1`.`vc_key`)) +SELECT vc_key +FROM t1 as outr +WHERE (vc_nokey, vc_key ) IN +(SELECT vc_nokey, vc_nokey +FROM t1 middle +WHERE vc_nokey IN +(SELECT child1.vc_key +FROM t2 AS child1 JOIN t1 AS child2 USING (int_key) +) +); +vc_key +g +DROP TABLE t1, t2; +# End of test for bug#13596176. +# +# BUG#11754478: MAX/MIN + SUBQUERY + AND FAILS TO RETURN ANY ROWS +# BUG#13599013: MAX/MIN + SUBQUERY IN WHERE CLAUSE MATCHING NO +# ROWS + INDEX DOES NOT RETURN NULL +# +CREATE TABLE t1 ( +pk int(11) PRIMARY KEY, +int_key int(11), +KEY int_key (int_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (1,0),(2,0),(3,2),(4,0),(5,3),(6,0); +SELECT MIN(int_key) FROM t1 WHERE (4, 4) IN (SELECT 1, 2); +MIN(int_key) +NULL +SELECT MIN(int_key) FROM t1 WHERE (4, 4) IN (SELECT 4, 4); +MIN(int_key) +0 +SELECT MIN(pk) FROM t1 WHERE pk IN (SELECT int_key FROM t1) AND pk = 6; +MIN(pk) +NULL +DROP TABLE t1; +# BUG#13726217: Crash in Item_ident::fix_after_pullout() +CREATE TABLE t1(a INTEGER) engine=innodb; +INSERT INTO t1 VALUES (0); +SELECT 0 +FROM t1 +WHERE 0 IN +(SELECT 0 +FROM t1 +WHERE 0 LIKE +(SELECT elt(a, 0) AS b +FROM t1 +GROUP BY a +HAVING b +) +); +0 +DROP TABLE t1; +# End of test for bug#13726217. +# BUG#13773979: Missing rows on second execution of prepared statement +CREATE TABLE t1 ( +col_int_nokey INT, +col_int_key INT, +col_varchar_key VARCHAR(1) +); +INSERT INTO t1 VALUES +(1,7,'v'), (7,0,'s'), (4,9,'l'), (7,3,'y'), +(2,2,'i'), (9,5,'h'), (0,1,'a'), (9,3,'v'); +CREATE VIEW v1 AS SELECT * FROM t1; +SELECT * +FROM t1 +WHERE col_int_key IN ( +SELECT alias1.col_int_nokey AS field1 +FROM v1 AS alias1 +WHERE alias1.col_varchar_key < 'v' +); +col_int_nokey col_int_key col_varchar_key +1 7 v +2 2 i +4 9 l +7 0 s +prepare stmt FROM "SELECT * +FROM t1 +WHERE col_int_key IN ( +SELECT alias1.col_int_nokey AS field1 +FROM v1 AS alias1 +WHERE alias1.col_varchar_key < 'v' +)"; +execute stmt; +col_int_nokey col_int_key col_varchar_key +1 7 v +2 2 i +4 9 l +7 0 s +execute stmt; +col_int_nokey col_int_key col_varchar_key +1 7 v +2 2 i +4 9 l +7 0 s +DEALLOCATE PREPARE stmt; +DROP VIEW v1; +DROP TABLE t1; +# End of test for bug#13773979. +# +# BUG#13685026 ASSERTION CUR_SJ_INNER_TABLES == 0 IN +# --OPTIMIZE_TABLE_ORDER::CHOOSE_TABLE_ORDER +# +CREATE TABLE t1 ( +col_int_key INT(11) NOT NULL, +col_datetime_key DATETIME NOT NULL, +col_varchar_key VARCHAR(1) NOT NULL, +col_varchar_nokey VARCHAR(1) NOT NULL, +KEY col_int_key (col_int_key), +KEY col_datetime_key (col_datetime_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (0,'2002-02-13 17:30:06','j','j'); +INSERT INTO t1 VALUES (8,'2008-09-27 00:34:58','v','v'); +CREATE TABLE t2 ( +col_int_key INT(11) NOT NULL, +col_datetime_key DATETIME NOT NULL, +col_varchar_key VARCHAR(1) NOT NULL, +col_varchar_nokey VARCHAR(1) NOT NULL, +KEY col_int_key (col_int_key), +KEY col_datetime_key (col_datetime_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (7,'2003-08-21 00:00:00','b','b'); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +SET @old_depth=@@optimizer_search_depth; +SET optimizer_search_depth=4; +EXPLAIN SELECT col_datetime_key +FROM t1 as outr +WHERE col_datetime_key IN ( +SELECT alias1.col_datetime_key +FROM t1 AS alias1 +LEFT JOIN t1 as alias3 +STRAIGHT_JOIN ( t2 AS alias4 +JOIN t1 AS alias5 +ON alias5.col_varchar_key <= alias4.col_varchar_nokey ) +ON alias5.col_int_key < alias4.col_int_key +ON alias5.col_varchar_key = alias4.col_varchar_key +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE outr NULL index col_datetime_key col_datetime_key 5 NULL 2 100.00 Using index +1 SIMPLE alias1 NULL ref col_datetime_key col_datetime_key 5 test.outr.col_datetime_key 1 100.00 Using index; Start temporary +1 SIMPLE alias4 NULL ALL col_int_key,col_varchar_key NULL NULL NULL 1 100.00 NULL +1 SIMPLE alias5 NULL ref col_int_key,col_varchar_key col_varchar_key 6 test.alias4.col_varchar_key 1 100.00 Using where; Using index +1 SIMPLE alias3 NULL index NULL col_int_key 4 NULL 2 100.00 Using index; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`outr`.`col_datetime_key` AS `col_datetime_key` from `test`.`t1` `outr` semi join (`test`.`t1` `alias1` left join (`test`.`t1` `alias3` join `test`.`t2` `alias4` join `test`.`t1` `alias5`) on(((`test`.`alias5`.`col_varchar_key` = `test`.`alias4`.`col_varchar_key`) and (`test`.`alias5`.`col_int_key` < `test`.`alias4`.`col_int_key`) and (`test`.`alias5`.`col_varchar_key` <= `test`.`alias4`.`col_varchar_nokey`)))) where (`test`.`alias1`.`col_datetime_key` = `test`.`outr`.`col_datetime_key`) +SELECT col_datetime_key +FROM t1 as outr +WHERE col_datetime_key IN ( +SELECT alias1.col_datetime_key +FROM t1 AS alias1 +LEFT JOIN t1 as alias3 +STRAIGHT_JOIN ( t2 AS alias4 +JOIN t1 AS alias5 +ON alias5.col_varchar_key <= alias4.col_varchar_nokey ) +ON alias5.col_int_key < alias4.col_int_key +ON alias5.col_varchar_key = alias4.col_varchar_key +); +col_datetime_key +2002-02-13 17:30:06 +2008-09-27 00:34:58 +DROP TABLE t1,t2; +SET @@optimizer_search_depth=@old_depth; +# +# BUG#13848789: SEGFAULT IN JOIN_READ_NEXT_SAME AT +# SQL/SQL_EXECUTOR.CC ON HAVING...IN...JOIN +# +CREATE TABLE t1 ( +col_int_key INT, +col_varchar_key VARCHAR(1), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4; +INSERT INTO t1 VALUES (8,'x'); +CREATE TABLE t2 ( +col_varchar_key VARCHAR(1), +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4; +INSERT INTO t2 VALUES ('x'), ('y'); +explain SELECT MIN(col_int_key) +FROM t1 as t1_outer +HAVING (1, 2) IN ( +SELECT t1_inner.col_int_key, MAX(t1_inner.col_int_key) +FROM t1 as t1_inner JOIN t2 +ON t2.col_varchar_key = t1_inner.col_varchar_key +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible HAVING +2 SUBQUERY t1_inner NULL system col_varchar_key NULL NULL NULL 1 100.00 NULL +2 SUBQUERY t2 NULL ref col_varchar_key col_varchar_key 7 const 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select min(`test`.`t1_outer`.`col_int_key`) AS `MIN(col_int_key)` from `test`.`t1` `t1_outer` having false +SELECT MIN(col_int_key) +FROM t1 as t1_outer +HAVING (1, 2) IN ( +SELECT t1_inner.col_int_key, MAX(t1_inner.col_int_key) +FROM t1 as t1_inner JOIN t2 +ON t2.col_varchar_key = t1_inner.col_varchar_key +); +MIN(col_int_key) +DROP TABLE t1,t2; +# Bug#13838810: Segfault in evaluate_null_complemented_join_record +CREATE TABLE t1 ( +pk int NOT NULL, +col_int_nokey int DEFAULT NULL, +col_int_key int DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t1 VALUES (10,NULL,8,'x'); +CREATE TABLE t2 ( +pk int NOT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +PRIMARY KEY (pk) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t2 VALUES (1,'x'); +CREATE TABLE t3 ( +pk int NOT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +PRIMARY KEY (pk), +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t3 VALUES +(1,'v','v'), (2,'v','v'), (3,'c','c'), (4,NULL,NULL); +EXPLAIN SELECT table1.pk,table2.pk, table3.pk +FROM t2 AS table1 +LEFT JOIN t1 AS table2 +LEFT JOIN t1 AS table3 +ON table3.col_int_key = table2.col_int_key +ON table3.pk = table2.col_int_nokey AND +table1.col_varchar_nokey IN ( +SELECT subquery3_t1.col_varchar_nokey +FROM t3 AS subquery3_t1 +LEFT JOIN t1 AS subquery3_t2 +ON subquery3_t2.col_varchar_key = subquery3_t1.col_varchar_key +WHERE subquery3_t2.col_int_nokey <> 9 +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE table1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE table2 NULL ALL col_int_key NULL NULL NULL 1 100.00 NULL +2 SIMPLE table3 NULL eq_ref PRIMARY,col_int_key PRIMARY 4 test.table2.col_int_nokey 1 100.00 Using where +2 SIMPLE subquery3_t2 NULL ALL col_varchar_key NULL NULL NULL 1 100.00 Using where; Start temporary +2 SIMPLE subquery3_t1 NULL ref col_varchar_key col_varchar_key 7 test.subquery3_t2.col_varchar_key 1 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`table1`.`pk` AS `pk`,`test`.`table2`.`pk` AS `pk`,`test`.`table3`.`pk` AS `pk` from `test`.`t2` `table1` left join (`test`.`t1` `table2` join `test`.`t1` `table3` semi join (`test`.`t3` `subquery3_t1` join `test`.`t1` `subquery3_t2`)) on(((`test`.`table3`.`col_int_key` = `test`.`table2`.`col_int_key`) and (`test`.`subquery3_t1`.`col_varchar_key` = `test`.`subquery3_t2`.`col_varchar_key`) and (`test`.`subquery3_t1`.`col_varchar_nokey` = `test`.`table1`.`col_varchar_nokey`) and (`test`.`table3`.`pk` = `test`.`table2`.`col_int_nokey`) and (`test`.`subquery3_t2`.`col_int_nokey` <> 9))) where true +SELECT table1.pk,table2.pk, table3.pk +FROM t2 AS table1 +LEFT JOIN t1 AS table2 +LEFT JOIN t1 AS table3 +ON table3.col_int_key = table2.col_int_key +ON table3.pk = table2.col_int_nokey AND +table1.col_varchar_nokey IN ( +SELECT subquery3_t1.col_varchar_nokey +FROM t3 AS subquery3_t1 +LEFT JOIN t1 AS subquery3_t2 +ON subquery3_t2.col_varchar_key = subquery3_t1.col_varchar_key +WHERE subquery3_t2.col_int_nokey <> 9 +) +; +pk pk pk +1 NULL NULL +DROP TABLE t1, t2, t3; +Extra test case for specific code coverage +CREATE TABLE t1(pk INTEGER); +INSERT INTO t1 VALUES(1), (2); +explain SELECT * +FROM t1 AS ot1 LEFT JOIN t1 AS ot2 +ON ot1.pk=ot2.pk AND +ot2.pk IN +(SELECT it1.pk +FROM t1 AS it1 LEFT JOIN t1 AS it2 ON it1.pk=it2.pk); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE it1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Start temporary +1 SIMPLE it2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`pk` AS `pk`,`test`.`ot2`.`pk` AS `pk` from `test`.`t1` `ot1` left join (`test`.`t1` `ot2` semi join (`test`.`t1` `it1` left join `test`.`t1` `it2` on((`test`.`it1`.`pk` = `test`.`it2`.`pk`)))) on(((`test`.`ot2`.`pk` = `test`.`ot1`.`pk`) and (`test`.`it1`.`pk` = `test`.`ot1`.`pk`))) where true +SELECT * +FROM t1 AS ot1 LEFT JOIN t1 AS ot2 +ON ot1.pk=ot2.pk AND +ot2.pk IN +(SELECT it1.pk +FROM t1 AS it1 LEFT JOIN t1 AS it2 ON it1.pk=it2.pk); +pk pk +1 1 +2 2 +DROP TABLE t1; +# End of test for bug#13838810. +# +# Bug#13845930: Segfault in st_join_table::and_with_condition +# +CREATE TABLE t1 ( +col_int INTEGER +); +CREATE TABLE t2 ( +col_varchar_1 VARCHAR(1), +col_varchar_2 VARCHAR(1) +); +INSERT INTO t2 VALUES ('x','x'), ('c','c'); +PREPARE stmt FROM ' +SELECT alias2.col_varchar_2 AS field1 +FROM t2 AS alias1 + JOIN + (t2 AS alias2 + LEFT JOIN t2 AS alias3 + ON (8, 92) IN + (SELECT sq1_alias1.col_int, + sq1_alias2.col_int + FROM t1 AS sq1_alias1 JOIN t1 AS sq1_alias2 + ) + ) + ON alias3.col_varchar_1 = alias2.col_varchar_2 +'; +EXECUTE stmt; +field1 + +EXECUTE stmt; +field1 +DEALLOCATE prepare stmt; +DROP TABLE t1, t2; +# End of test for bug#13845930. +# +# Bug#13855925: Assert 'prebuilt->search_tuple->n_fields > 0' +# in ha_innobase::index_read +# +CREATE TABLE t1 ( +pk INTEGER AUTO_INCREMENT, +col_int_nokey INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk), +KEY (col_varchar_key) +) charset utf8mb4 ENGINE=INNODB; +INSERT INTO t1 ( +col_int_key, col_int_nokey, +col_varchar_key, col_varchar_nokey +) VALUES +(4, 2, 'v','v'), (62, 150, 'v','v'), (7, NULL, 'c','c'), (1, 2, NULL, NULL), +(0, 5, 'x','x'), (7, 3, 'i','i'), (7, 1, 'e','e'), (1, 4, 'p','p'), +(7, NULL, 's','s'), (1, 2, 'j','j'), (5, 6, 'z','z'), (2, 6, 'c','c'), +(0, 8, 'a','a'), (1, 2, 'q','q'), (8, 6, 'y','y'), (1, 8, NULL, NULL), +(1, 3, 'r','r'), (9, 3, 'v','v'), (1, 9, NULL, NULL), (5, 6, 'r','r'); +CREATE TABLE t2 ( +pk INT AUTO_INCREMENT, +col_int_nokey INT, +col_int_key INT, +PRIMARY KEY (pk), +KEY (col_int_key) +) charset utf8mb4 AUTO_INCREMENT=10 ENGINE=INNODB; +INSERT INTO t2 (col_int_key, col_int_nokey) VALUES +(8, NULL), (7, 8), (1, 1), (7, 9), (9, 4), (NULL, 3), (1, 2), (9, NULL), +(2, 2), (9, NULL), (2, 6), (4, 7), (0, 2), (4, 5), (8, 7), (NULL, 6), +(NULL, 6), (0, 2), (NULL, 9), (8, 6); +CREATE TABLE t3 ( +pk INT AUTO_INCREMENT, +col_varchar_key VARCHAR(1), +PRIMARY KEY (pk), +KEY (col_varchar_key) +) charset utf8mb4 ENGINE=INNODB; +INSERT INTO t3 (col_varchar_key) VALUES +('c'), ('c'), ('q'), ('g'), ('e'), ('l'), (NULL), ('c'), ('h'), ('d'), +('c'), ('i'), ('t'), ('g'), ('q'), ('l'), ('n'), ('z'), ('n'), ('r'), ('p'); +CREATE VIEW v1 AS +SELECT table2.col_varchar_nokey AS field1 +FROM t2 AS table1 +INNER JOIN (t1 AS table2 +STRAIGHT_JOIN t2 AS table3 +ON table3.col_int_key = table2.pk AND +table3.col_int_nokey = ANY +(SELECT subquery1_t2.col_int_nokey AS subquery1_field1 +FROM t2 AS subquery1_t1 +RIGHT OUTER JOIN t1 AS subquery1_t2 +INNER JOIN t1 AS subquery1_t3 +ON subquery1_t3.col_int_key = subquery1_t2.pk +ON subquery1_t3.col_varchar_key=subquery1_t2.col_varchar_nokey +WHERE subquery1_t1.pk > 1 +) +) +ON table3.col_int_key IN +(SELECT subquery2_t1.col_int_key AS subquery2_field1 +FROM t2 AS subquery2_t1 +RIGHT OUTER JOIN t3 AS subquery2_t2 +LEFT OUTER JOIN t1 AS subquery2_t3 +ON subquery2_t3.col_varchar_key = subquery2_t2.col_varchar_key +ON subquery2_t3.pk = subquery2_t2.pk +) +; +explain SELECT * FROM v1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE subquery2_t3 NULL index PRIMARY,col_varchar_key col_varchar_key 7 NULL 20 100.00 Using where; Using index; Start temporary +1 SIMPLE subquery2_t2 NULL eq_ref PRIMARY,col_varchar_key PRIMARY 4 test.subquery2_t3.pk 1 7.14 Using where +1 SIMPLE subquery1_t3 NULL ALL col_varchar_key NULL NULL NULL 20 100.00 Using where +1 SIMPLE subquery1_t2 NULL eq_ref PRIMARY PRIMARY 4 test.subquery1_t3.col_int_key 1 10.00 Using where +1 SIMPLE subquery2_t1 NULL range col_int_key col_int_key 5 NULL 16 100.00 Using where; Using index +1 SIMPLE table2 NULL eq_ref PRIMARY PRIMARY 4 test.subquery2_t1.col_int_key 1 100.00 NULL +1 SIMPLE table3 NULL ref col_int_key col_int_key 5 test.subquery2_t1.col_int_key 2 10.00 Using where +1 SIMPLE subquery1_t1 NULL index PRIMARY col_int_key 5 NULL 20 100.00 Using where; Using index; End temporary +1 SIMPLE table1 NULL index NULL col_int_key 5 NULL 20 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `table2`.`col_varchar_nokey` AS `field1` from `test`.`t2` `table1` join `test`.`t1` `table2` straight_join `test`.`t2` `table3` semi join (`test`.`t1` `subquery1_t2` join `test`.`t1` `subquery1_t3` join `test`.`t2` `subquery1_t1`) semi join (`test`.`t3` `subquery2_t2` join `test`.`t1` `subquery2_t3` join `test`.`t2` `subquery2_t1`) where ((`subquery1_t2`.`pk` = `subquery1_t3`.`col_int_key`) and (`subquery1_t2`.`col_varchar_nokey` = `subquery1_t3`.`col_varchar_key`) and (`subquery2_t2`.`col_varchar_key` = `subquery2_t3`.`col_varchar_key`) and (`subquery2_t2`.`pk` = `subquery2_t3`.`pk`) and (`table2`.`pk` = `subquery2_t1`.`col_int_key`) and (`table3`.`col_int_key` = `subquery2_t1`.`col_int_key`) and (`table3`.`col_int_nokey` = `subquery1_t2`.`col_int_nokey`) and (`subquery1_t1`.`pk` > 1)) +SELECT * FROM v1; +field1 +v +v +v +v +v +v +v +v +v +v +v +v +v +v +v +v +v +v +v +v +DROP VIEW v1; +DROP TABLE t1,t2,t3; +# End of test for bug#13855925. +# +# Bug#13897959: Segfault in setup_semijoin_dups_elimination() +# +CREATE TABLE t1 ( +col_datetime_key DATETIME DEFAULT NULL, +KEY col_datetime_key (col_datetime_key) +) ENGINE=MyISAM; +INSERT INTO t1 VALUES +('2001-04-18 00:00:00'), ('2008-12-18 19:39:55'), +('2000-08-01 12:19:39'), ('2004-09-25 21:29:06'), +('2009-09-20 09:11:48'), ('2004-03-27 09:32:04'); +CREATE TABLE t2 ( +col_date_nokey date DEFAULT NULL, +col_time_key time DEFAULT NULL, +col_datetime_key datetime DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +KEY col_time_key (col_time_key), +KEY col_datetime_key (col_datetime_key), +KEY col_varchar_key(col_varchar_key) +) ENGINE=MyISAM; +INSERT INTO t2 VALUES ('1900-01-01',NULL,'2001-11-04 19:07:55','x','x'); +SELECT grandparent1.col_varchar_nokey +FROM t2 AS grandparent1 LEFT JOIN t1 USING (col_datetime_key) +WHERE grandparent1.col_varchar_nokey IN ( +SELECT col_varchar_nokey +FROM t2 AS parent1 +WHERE parent1.col_time_key > grandparent1.col_date_nokey +); +col_varchar_nokey +DROP TABLE t1, t2; +# End of test for bug#13897959. +# +# Bug#13898625 ASSERT `(REMAINING_TABLES_AFTER != 0) ...' IN +# BEST_EXTENSION_BY_LIMITED_SEARCH +# +CREATE TABLE t1 ( +pk int(11) NOT NULL, +col_int_nokey INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (26,6,NULL,'f','f'); +INSERT INTO t1 VALUES (29,6,8,'c','c'); +CREATE TABLE t2 ( +pk INT NOT NULL, +col_int_nokey INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +INSERT INTO t2 VALUES (1,2,4,'v','v'); +INSERT INTO t2 VALUES (2,150,62,'v','v'); +INSERT INTO t2 VALUES (5,5,0,'x','x'); +INSERT INTO t2 VALUES (6,3,7,'i','i'); +INSERT INTO t2 VALUES (7,1,7,'e','e'); +CREATE VIEW view_c AS SELECT * FROM t2; +PREPARE prep_stmt_7430 FROM 'SELECT SUM( alias1.col_varchar_key ) AS field1 +FROM t1 AS alias1 +RIGHT JOIN t2 AS alias2 +INNER JOIN t1 AS alias3 +ON (alias3.col_varchar_key = alias2.col_varchar_key ) +ON ( "v" ) IN ( +SELECT sq1_alias1.col_varchar_nokey AS sq1_field1 +FROM t1 AS sq1_alias1 +) +WHERE alias3.pk IN ( +SELECT sq2_alias1.col_int_key AS sq2_field1 +FROM ( view_c AS sq2_alias1, t1 AS sq2_alias2 ) +) +'; +EXECUTE prep_stmt_7430; +field1 +NULL +EXECUTE prep_stmt_7430; +field1 +NULL +EXPLAIN SELECT SUM( alias1.col_varchar_key ) AS field1 +FROM t1 AS alias1 +RIGHT JOIN t2 AS alias2 +INNER JOIN t1 AS alias3 +ON (alias3.col_varchar_key = alias2.col_varchar_key ) +ON ( "v" ) IN ( +SELECT sq1_alias1.col_varchar_nokey AS sq1_field1 +FROM t1 AS sq1_alias1 +) +WHERE alias3.pk IN ( +SELECT sq2_alias1.col_int_key AS sq2_field1 +FROM ( view_c AS sq2_alias1, t1 AS sq2_alias2 ) +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE alias3 NULL ALL PRIMARY,col_varchar_key NULL NULL NULL 2 100.00 Using where +1 SIMPLE alias2 NULL ref col_varchar_key col_varchar_key 7 test.alias3.col_varchar_key 2 100.00 Using index +1 SIMPLE sq2_alias2 NULL index NULL PRIMARY 4 NULL 2 100.00 Using index; Start temporary +1 SIMPLE t2 NULL ref col_int_key col_int_key 5 test.alias3.pk 2 100.00 Using index +1 SIMPLE sq1_alias1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE alias1 NULL index NULL col_varchar_key 12 NULL 2 100.00 Using index; End temporary +Warnings: +Note 1003 /* select#1 */ select sum(`test`.`alias1`.`col_varchar_key`) AS `field1` from `test`.`t2` `alias2` join `test`.`t1` `alias3` left join (`test`.`t1` `alias1` semi join (`test`.`t1` `sq1_alias1`)) on(((`test`.`sq1_alias1`.`col_varchar_nokey` = 'v'))) semi join (`test`.`t2` join `test`.`t1` `sq2_alias2`) where ((`test`.`alias2`.`col_varchar_key` = `test`.`alias3`.`col_varchar_key`) and (`test`.`t2`.`col_int_key` = `test`.`alias3`.`pk`)) +PREPARE prep_stmt_7430 FROM 'SELECT SUM( alias1.col_varchar_key ) AS field1 +FROM t1 AS alias1 +RIGHT JOIN t2 AS alias2 +INNER JOIN t1 AS alias3 +ON (alias3.col_varchar_key = alias2.col_varchar_key ) +ON ( "v" ) IN ( +SELECT sq1_alias1.col_varchar_nokey AS sq1_field1 +FROM t1 AS sq1_alias1 +) +WHERE alias3.pk IN ( +SELECT sq2_alias1.col_int_key AS sq2_field1 +FROM ( view_c AS sq2_alias1 , t1 AS sq2_alias2 ) +WHERE sq2_alias1.col_varchar_nokey <> alias2.col_varchar_key +AND sq2_alias1.col_varchar_key < "l" + ) +'; +EXECUTE prep_stmt_7430; +field1 +NULL +EXECUTE prep_stmt_7430; +field1 +NULL +EXPLAIN SELECT SUM( alias1.col_varchar_key ) AS field1 +FROM t1 AS alias1 +RIGHT JOIN t2 AS alias2 +INNER JOIN t1 AS alias3 +ON (alias3.col_varchar_key = alias2.col_varchar_key ) +ON ( "v" ) IN ( +SELECT sq1_alias1.col_varchar_nokey AS sq1_field1 +FROM t1 AS sq1_alias1 +) +WHERE alias3.pk IN ( +SELECT sq2_alias1.col_int_key AS sq2_field1 +FROM ( view_c AS sq2_alias1 , t1 AS sq2_alias2 ) +WHERE sq2_alias1.col_varchar_nokey <> alias2.col_varchar_key +AND sq2_alias1.col_varchar_key < "l" + ) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE alias3 NULL ALL PRIMARY,col_varchar_key NULL NULL NULL 2 100.00 Using where +1 SIMPLE t2 NULL ref col_int_key,col_varchar_key col_int_key 5 test.alias3.pk 2 40.00 Using where; Start temporary +1 SIMPLE alias2 NULL ref col_varchar_key col_varchar_key 7 test.alias3.col_varchar_key 2 100.00 Using index +1 SIMPLE sq2_alias2 NULL index NULL PRIMARY 4 NULL 2 100.00 Using index +1 SIMPLE sq1_alias1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE alias1 NULL index NULL col_varchar_key 12 NULL 2 100.00 Using index; End temporary +Warnings: +Note 1276 Field or reference 'test.alias2.col_varchar_key' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select sum(`test`.`alias1`.`col_varchar_key`) AS `field1` from `test`.`t2` `alias2` join `test`.`t1` `alias3` left join (`test`.`t1` `alias1` semi join (`test`.`t1` `sq1_alias1`)) on(((`test`.`sq1_alias1`.`col_varchar_nokey` = 'v'))) semi join (`test`.`t2` join `test`.`t1` `sq2_alias2`) where ((`test`.`alias2`.`col_varchar_key` = `test`.`alias3`.`col_varchar_key`) and (`test`.`t2`.`col_int_key` = `test`.`alias3`.`pk`) and (`test`.`t2`.`col_varchar_nokey` <> `test`.`alias3`.`col_varchar_key`) and (`test`.`t2`.`col_varchar_key` < 'l')) +DROP TABLE t1,t2; +DROP VIEW view_c; +# +# Bug#13902463 SEGFAULT IN BITMAP<64U>::MERGE OR ADD_KEY_FIELD +# ON SECOND EXEC OF PREP STMT +# +CREATE TABLE t1 ( +pk INT, +col_int_nokey INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +KEY col_varchar_key (col_varchar_key) +); +CREATE VIEW view_b AS SELECT * FROM t1; +PREPARE prep_stmt_20421 FROM 'SELECT alias2.col_varchar_nokey AS field1 +FROM t1 AS alias1 +INNER JOIN t1 AS alias2 +ON (alias1.col_varchar_key = alias2.col_varchar_nokey +AND ( alias1.col_int_key ) IN ( +SELECT t1.col_int_nokey +FROM t1 +) +) +WHERE alias1.col_varchar_key IN ( +SELECT sq2_alias2.col_varchar_nokey AS sq2_field1 +FROM view_b AS sq2_alias1 +INNER JOIN t1 AS sq2_alias2 +ON (sq2_alias2.col_varchar_key = sq2_alias1.col_varchar_key ) +WHERE sq2_alias1.pk > alias2.pk +) +'; +EXECUTE prep_stmt_20421; +field1 +EXECUTE prep_stmt_20421; +field1 +EXPLAIN SELECT alias2.col_varchar_nokey AS field1 +FROM t1 AS alias1 +INNER JOIN t1 AS alias2 +ON (alias1.col_varchar_key = alias2.col_varchar_nokey +AND ( alias1.col_int_key ) IN ( +SELECT t1.col_int_nokey +FROM t1 +) +) +WHERE alias1.col_varchar_key IN ( +SELECT sq2_alias2.col_varchar_nokey AS sq2_field1 +FROM view_b AS sq2_alias1 +INNER JOIN t1 AS sq2_alias2 +ON (sq2_alias2.col_varchar_key = sq2_alias1.col_varchar_key ) +WHERE sq2_alias1.pk > alias2.pk +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.alias2.pk' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `field1` from `test`.`t1` `alias1` join `test`.`t1` `alias2` semi join (`test`.`t1`) semi join (`test`.`t1` join `test`.`t1` `sq2_alias2`) where ((`test`.`t1`.`pk` > NULL) and multiple equal(NULL, `test`.`sq2_alias2`.`col_varchar_nokey`, NULL) and multiple equal(`test`.`sq2_alias2`.`col_varchar_key`, `test`.`t1`.`col_varchar_key`) and multiple equal(NULL, `test`.`t1`.`col_int_nokey`)) +ALTER TABLE t1 DROP INDEX col_varchar_key; +PREPARE prep_stmt_20421 FROM 'SELECT alias2.col_varchar_nokey AS field1 +FROM t1 AS alias1 +INNER JOIN t1 AS alias2 +ON (alias1.col_varchar_key = alias2.col_varchar_nokey +AND ( alias1.col_int_key ) IN ( +SELECT t1.col_int_nokey +FROM t1 +) +) +WHERE alias1.col_varchar_key IN ( +SELECT sq2_alias2.col_varchar_nokey AS sq2_field1 +FROM view_b AS sq2_alias1 +INNER JOIN t1 AS sq2_alias2 +ON (sq2_alias2.col_varchar_key = sq2_alias1.col_varchar_key ) +WHERE sq2_alias1.pk > alias2.pk +) +'; +EXECUTE prep_stmt_20421; +field1 +EXECUTE prep_stmt_20421; +field1 +EXPLAIN SELECT alias2.col_varchar_nokey AS field1 +FROM t1 AS alias1 +INNER JOIN t1 AS alias2 +ON (alias1.col_varchar_key = alias2.col_varchar_nokey +AND ( alias1.col_int_key ) IN ( +SELECT t1.col_int_nokey +FROM t1 +) +) +WHERE alias1.col_varchar_key IN ( +SELECT sq2_alias2.col_varchar_nokey AS sq2_field1 +FROM view_b AS sq2_alias1 +INNER JOIN t1 AS sq2_alias2 +ON (sq2_alias2.col_varchar_key = sq2_alias1.col_varchar_key ) +WHERE sq2_alias1.pk > alias2.pk +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.alias2.pk' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `field1` from `test`.`t1` `alias1` join `test`.`t1` `alias2` semi join (`test`.`t1`) semi join (`test`.`t1` join `test`.`t1` `sq2_alias2`) where ((`test`.`t1`.`pk` > NULL) and multiple equal(NULL, `test`.`sq2_alias2`.`col_varchar_nokey`, NULL) and multiple equal(`test`.`sq2_alias2`.`col_varchar_key`, `test`.`t1`.`col_varchar_key`) and multiple equal(NULL, `test`.`t1`.`col_int_nokey`)) +DROP TABLE t1; +DROP VIEW view_b; +# +# Bug#13907277: Segfault in evaluate_null_complemented_join_record +# +CREATE TABLE t1 ( +pk INTEGER, +col_varchar_nokey VARCHAR(1), +col_varchar_key VARCHAR(1), +PRIMARY KEY (pk) +); +INSERT INTO t1 VALUES (1, 'x', 'x'); +CREATE TABLE t2 ( +pk INTEGER, +PRIMARY KEY (pk) +); +INSERT INTO t2 VALUES (1); +CREATE TABLE t3 ( +pk INTEGER, +col_int_nokey INTEGER, +col_int_key INTEGER, +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk) +); +INSERT INTO t3 VALUES (1, 6, 5, 'r'); +explain SELECT outer_t1.pk, outer_t2.pk +FROM t3 AS outer_t1 +RIGHT JOIN t2 AS outer_t2 +ON outer_t1.col_int_nokey IN +(SELECT inner_t1.col_int_nokey +FROM t3 AS inner_t1 +LEFT JOIN t1 AS inner_t2 +INNER JOIN t1 AS inner_t3 +ON inner_t3.pk = inner_t2.pk +ON inner_t3.col_varchar_nokey = inner_t2.col_varchar_key +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE outer_t2 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE outer_t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE inner_t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE inner_t2 NULL ALL PRIMARY NULL NULL NULL 1 100.00 NULL +1 SIMPLE inner_t3 NULL eq_ref PRIMARY PRIMARY 4 test.inner_t2.pk 1 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`outer_t1`.`pk` AS `pk`,'1' AS `pk` from left join (`test`.`t3` `outer_t1` semi join (`test`.`t3` `inner_t1` left join (`test`.`t1` `inner_t2` join `test`.`t1` `inner_t3`) on(((`test`.`inner_t3`.`col_varchar_nokey` = `test`.`inner_t2`.`col_varchar_key`) and (`test`.`inner_t3`.`pk` = `test`.`inner_t2`.`pk`))))) on(((`test`.`inner_t1`.`col_int_nokey` = `test`.`outer_t1`.`col_int_nokey`))) where true +SELECT outer_t1.pk, outer_t2.pk +FROM t3 AS outer_t1 +RIGHT JOIN t2 AS outer_t2 +ON outer_t1.col_int_nokey IN +(SELECT inner_t1.col_int_nokey +FROM t3 AS inner_t1 +LEFT JOIN t1 AS inner_t2 +INNER JOIN t1 AS inner_t3 +ON inner_t3.pk = inner_t2.pk +ON inner_t3.col_varchar_nokey = inner_t2.col_varchar_key +); +pk pk +1 1 +DROP TABLE t1, t2, t3; +# End of test for bug#13907277. +# +# Bug#13955713: Assert 'JOIN->best_read < ...' on second execution +# +CREATE TABLE t1 ( +pk INTEGER, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1) +); +PREPARE stmt FROM " +SELECT MIN(alias2.col_varchar_key) AS field1 +FROM t1 AS alias1 + INNER JOIN (t1 AS alias2 + INNER JOIN t1 AS alias3 + ON 8 IN + (SELECT sq1_alias1.pk AS sq1_field2 + FROM t1 AS sq1_alias1 + WHERE 9 IN + (SELECT SUM(t1_sq1_alias1.pk) AS t1_sq1_field2 + FROM t1 AS t1_sq1_alias1 + ) + ) + ) + ON alias3.col_varchar_nokey = alias2.col_varchar_key +WHERE EXISTS + (SELECT sq2_alias1.pk AS sq2_field1 + FROM t1 AS sq2_alias1 + WHERE sq2_alias1.col_varchar_key < alias1.col_varchar_nokey + ) +"; +EXECUTE stmt; +field1 +NULL + +EXECUTE stmt; +field1 +NULL +DEALLOCATE PREPARE stmt; +DROP TABLE t1; +# End of test for bug#13955713. +# +# Bug#13956813: Segfault in memcpy from Join_cache::write_record_data() +# +CREATE TABLE t1 ( +pk INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1) +) charset latin1; +CREATE TABLE t2 ( +pk INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1) +) charset latin1; +INSERT INTO t2 VALUES +(10,'j','j'), (11,'z','z'), (12,'c','c'), (13,'a','a'), +(14,'q','q'), (15,'y','y'), (16,NULL,NULL), (17,'r','r'), +(18,'v','v'), (19,NULL,NULL), (20,'r','r'); +CREATE TABLE t3 ( +pk INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +KEY col_int_key (col_int_key) +) charset latin1; +INSERT INTO t3 VALUES +(15,NULL,'u'), (16,1,'m'), (17,9,NULL), (18,2,'o'), +(19,9,'w'), (20,2,'m'), (21,4,'q'), (22,0,NULL), +(23,4,'d'), (24,8,'g'), (25,NULL,'x'), (26,NULL,'f'), +(27,0,'p'), (28,NULL,'j'), (29,8,'c'); +CREATE VIEW view_inline_0 AS +SELECT t1.* +FROM t1 INNER JOIN t3 +ON t1.pk = t3.pk; +CREATE VIEW view_inline_1 AS +SELECT sq2_alias2.col_varchar_key AS sq2_field1, +sq2_alias1.col_varchar_key AS sq2_field2 +FROM t3 AS sq2_alias1 LEFT OUTER JOIN t3 AS sq2_alias2 +ON sq2_alias1.pk = sq2_alias2.col_int_key; +CREATE VIEW view_inline_2 AS +SELECT 'p', 'p' UNION SELECT 'k', 's'; +SET @optimizer_switch_saved= @@optimizer_switch; +SET @@optimizer_switch="derived_merge=off"; +explain SELECT SUM(alias1.col_varchar_nokey) AS field2 +FROM t2 AS alias2 +LEFT JOIN (SELECT * FROM view_inline_0) AS alias1 +ON alias2.col_varchar_key = alias1.col_varchar_key AND +(alias2.col_varchar_nokey, alias2.col_varchar_key) IN +(SELECT * FROM view_inline_1 +) +WHERE (alias1.col_varchar_key, alias1.col_varchar_nokey) IN +(SELECT * FROM view_inline_2 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL 2 100.00 NULL +1 PRIMARY alias2 NULL ALL NULL NULL NULL NULL 11 10.00 Using where +1 PRIMARY NULL ref 8 test.alias2.col_varchar_nokey,test.view_inline_2.p 3 100.00 Using index; Start temporary; End temporary +1 PRIMARY NULL ref 8 test.view_inline_2.p,test.view_inline_2.Name_exp_p 2 100.00 NULL +7 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +8 UNION NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +NULL UNION RESULT NULL ALL NULL NULL NULL NULL NULL NULL Using temporary +6 DERIVED sq2_alias1 NULL ALL NULL NULL NULL NULL 15 100.00 NULL +6 DERIVED sq2_alias2 NULL ref col_int_key col_int_key 5 test.sq2_alias1.pk 2 100.00 NULL +2 DERIVED NULL ALL NULL NULL NULL NULL 15 100.00 NULL +5 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select sum(`alias1`.`col_varchar_nokey`) AS `field2` from `test`.`view_inline_2` join `test`.`t2` `alias2` join (/* select#2 */ select `test`.`view_inline_0`.`pk` AS `pk`,`test`.`view_inline_0`.`col_varchar_key` AS `col_varchar_key`,`test`.`view_inline_0`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`view_inline_0`) `alias1` semi join (`test`.`view_inline_1`) where ((`test`.`view_inline_1`.`sq2_field1` = `test`.`alias2`.`col_varchar_nokey`) and (`alias1`.`col_varchar_nokey` = `test`.`view_inline_2`.`Name_exp_p`) and (`test`.`alias2`.`col_varchar_key` = `test`.`view_inline_2`.`p`) and (`test`.`view_inline_1`.`sq2_field2` = `test`.`view_inline_2`.`p`) and (`alias1`.`col_varchar_key` = `test`.`view_inline_2`.`p`)) +SELECT SUM(alias1.col_varchar_nokey) AS field2 +FROM t2 AS alias2 +LEFT JOIN (SELECT * FROM view_inline_0) AS alias1 +ON alias2.col_varchar_key = alias1.col_varchar_key AND +(alias2.col_varchar_nokey, alias2.col_varchar_key) IN +(SELECT * FROM view_inline_1 +) +WHERE (alias1.col_varchar_key, alias1.col_varchar_nokey) IN +(SELECT * FROM view_inline_2 +); +field2 +NULL +SET @@optimizer_switch= @optimizer_switch_saved; +DROP VIEW view_inline_0, view_inline_1, view_inline_2; +DROP TABLE t1, t2, t3; +# End of test for bug#13956813. +# +# Bug#13974177: Assert !(tab->table->regginfo.not_exists_optimize... +# +CREATE TABLE t1 ( +pk INTEGER AUTO_INCREMENT, +col_int_nokey INTEGER, +col_int_key INTEGER, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk), +KEY (col_int_key), +KEY (col_varchar_key, col_int_key) +); +INSERT INTO t1(col_int_key, col_int_nokey, col_varchar_key, col_varchar_nokey) +VALUES +(0, 4, 'j', 'j'), (8, 6, 'v', 'v'), (1, 3, 'c', 'c'), (8, 5, 'm', 'm'), +(9, 3, 'd', 'd'), (24, 246, 'd', 'd'), (6, 2, 'y', 'y'), (1, 9, 't', 't'), +(6, 3, 'd', 'd'), (2, 8, 's', 's'), (4, 1, 'r', 'r'), (8, 8, 'm', 'm'), +(4, 8, 'b', 'b'), (4, 5, 'x', 'x'), (7, 7, 'g', 'g'), (4, 5, 'p', 'p'), +(1, 1, 'q', 'q'), (9, 6, 'w', 'w'), (4, 2, 'd', 'd'), (8, 9, 'e', 'e'); +CREATE TABLE t2 ( +pk INTEGER AUTO_INCREMENT, +col_int_nokey INTEGER NOT NULL, +col_time_key TIME NOT NULL, +col_time_nokey TIME NOT NULL, +PRIMARY KEY (pk), +KEY (col_time_key) +) ENGINE=InnoDB; +INSERT INTO t2 (col_int_nokey, col_time_key, col_time_nokey) VALUES +(7, '00:00:00', '00:00:00'), (0, '00:00:00', '00:00:00'), +(9, '06:35:17', '06:35:17'), (3, '18:07:14', '18:07:14'), +(4, '20:36:52', '20:36:52'), (2, '21:29:07', '21:29:07'), +(5, '23:45:57', '23:45:57'), (3, '22:54:57', '22:54:57'), +(1, '18:45:09', '18:45:09'), (3, '14:30:46', '14:30:46'), +(6, '19:23:43', '19:23:43'), (7, '03:39:30', '03:39:30'), +(5, '23:37:52', '23:37:52'), (1, '16:59:30', '16:59:30'), +(204, '22:21:15', '22:21:15'), (224, '12:24:37', '12:24:37'), +(9, '15:02:08', '15:02:08'), (5, '23:59:59', '23:59:59'), +(0, '08:23:30', '08:23:30'), (3, '08:32:22', '08:32:22'); +explain SELECT ot1.col_int_key AS x +FROM t1 AS ot2 +LEFT JOIN t1 AS ot1 +ON ot2.col_varchar_nokey > ot1.col_varchar_key +WHERE (ot1.col_int_nokey, ot1.pk) IN +(SELECT it1.pk AS x, +it1.col_int_nokey AS y +FROM t2 AS it2 +LEFT JOIN t2 AS it1 +ON it2.col_time_nokey = it1.col_time_key +) AND ot1.pk IS NULL +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`col_int_key` AS `x` from `test`.`t2` `it1` join `test`.`t1` `ot2` join `test`.`t1` `ot1` semi join (`test`.`t2` `it2`) where ((`test`.`ot1`.`pk` is null) and (`test`.`ot2`.`col_varchar_nokey` > `test`.`ot1`.`col_varchar_key`) and multiple equal(`test`.`ot1`.`col_int_nokey`, `test`.`it1`.`pk`) and multiple equal(`test`.`ot1`.`pk`, `test`.`it1`.`col_int_nokey`) and multiple equal(`test`.`it2`.`col_time_nokey`, `test`.`it1`.`col_time_key`)) +SELECT ot1.col_int_key AS x +FROM t1 AS ot2 +LEFT JOIN t1 AS ot1 +ON ot2.col_varchar_nokey > ot1.col_varchar_key +WHERE (ot1.col_int_nokey, ot1.pk) IN +(SELECT it1.pk AS x, +it1.col_int_nokey AS y +FROM t2 AS it2 +LEFT JOIN t2 AS it1 +ON it2.col_time_nokey = it1.col_time_key +) AND ot1.pk IS NULL +; +x +DROP TABLE t1, t2; +# End of test for bug#13974177. +# +# Bug#13971022: Assert 'keyparts > 0' failed in create_ref_for_key... +# +CREATE TABLE t1 ( +pk INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +PRIMARY KEY (pk), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +CREATE TABLE t2 ( +pk INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk) +) charset utf8mb4 ENGINE=InnoDB; +CREATE TABLE t3 ( +i INT +); +SET @optimizer_switch_saved= @@optimizer_switch; +SET @@optimizer_switch="derived_merge=off"; +explain SELECT table1.pk AS field1 +FROM ( SELECT subquery1_t1. * +FROM t2 AS subquery1_t1 +JOIN t2 AS subquery1_t2 +ON subquery1_t2.pk = subquery1_t1.pk) AS table1 +STRAIGHT_JOIN t2 AS table2 +ON table1.col_int_key IN (SELECT 7 FROM t3) +WHERE table1.col_varchar_nokey IN +(SELECT subquery3_t1.col_varchar_key AS subquery3_field1 +FROM t1 AS subquery3_t1 +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY subquery3_t1 NULL index col_varchar_key col_varchar_key 12 NULL 0 0.00 Using where; Using index; Start temporary +1 PRIMARY t3 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +1 PRIMARY NULL ref 7 test.subquery3_t1.col_varchar_key 2 100.00 End temporary +1 PRIMARY table2 NULL index NULL PRIMARY 4 NULL 1 100.00 Using index +2 DERIVED subquery1_t1 NULL ALL PRIMARY NULL NULL NULL 1 100.00 Using where +2 DERIVED subquery1_t2 NULL eq_ref PRIMARY PRIMARY 4 test.subquery1_t1.pk 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `table1`.`pk` AS `field1` from (/* select#2 */ select `test`.`subquery1_t1`.`pk` AS `pk`,`test`.`subquery1_t1`.`col_int_key` AS `col_int_key`,`test`.`subquery1_t1`.`col_varchar_key` AS `col_varchar_key`,`test`.`subquery1_t1`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t2` `subquery1_t1` join `test`.`t2` `subquery1_t2` where ((`test`.`subquery1_t1`.`col_int_key` = 7) and (`test`.`subquery1_t2`.`pk` = `test`.`subquery1_t1`.`pk`))) `table1` straight_join `test`.`t2` `table2` semi join (`test`.`t3`) semi join (`test`.`t1` `subquery3_t1`) where (`table1`.`col_varchar_nokey` = `test`.`subquery3_t1`.`col_varchar_key`) +SELECT table1.pk AS field1 +FROM ( SELECT subquery1_t1. * +FROM t2 AS subquery1_t1 +JOIN t2 AS subquery1_t2 +ON subquery1_t2.pk = subquery1_t1.pk) AS table1 +STRAIGHT_JOIN t2 AS table2 +ON table1.col_int_key IN (SELECT 7 FROM t3) +WHERE table1.col_varchar_nokey IN +(SELECT subquery3_t1.col_varchar_key AS subquery3_field1 +FROM t1 AS subquery3_t1 +) +; +field1 +SET @@optimizer_switch= @optimizer_switch_saved; +DROP TABLE t1, t2, t3; +# End of test for bug#13971022. +# +# Bug#13623473 "MISSING ROWS ON SELECT AND JOIN WITH +# TIME/DATETIME COMPARE" - Subquery part of test. +# +SET TIMESTAMP=UNIX_TIMESTAMP('2012-01-31 10:14:35'); +CREATE TABLE t1 ( +pk INT NOT NULL, +col_int_nokey INT, +col_int_key INT NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +) ENGINE=InnoDB; +INSERT INTO t1 VALUES (10,1,7), (11,7,0), (12,4,9), (13,7,3), +(14,0,4), (15,2,2), (16,9,5), (17,4,3), (18,0,1), (19,9,3), (20,1,6), +(21,3,7), (22,8,5), (23,8,1), (24,18,204), (25,84,224), (26,6,9), +(27,3,5), (28,6,0), (29,6,3); +CREATE TABLE t2 ( +col_int_nokey INT NOT NULL, +col_datetime_key DATETIME NOT NULL, +col_varchar_key VARCHAR(1) NOT NULL, +KEY col_datetime_key (col_datetime_key), +KEY col_varchar_key (col_varchar_key) +) ENGINE=InnoDB; +INSERT INTO t2 VALUES (1,'2001-11-04 19:07:55','k'); +CREATE TABLE t3 ( +col_time_key TIME, +KEY col_time_key (col_time_key) +) ENGINE=InnoDB; +INSERT INTO t3 VALUES ('21:22:34'), ('10:50:38'), ('00:21:38'), +('04:08:02'), ('16:25:11'), ('10:14:58'), ('19:47:59'), ('11:14:24'), +('00:00:00'), ('00:00:00'), ('15:57:25'), ('07:05:51'), ('19:22:21'), +('03:53:16'), ('09:16:38'), ('15:37:26'), ('00:00:00'), ('05:03:03'), +('02:59:24'), ('00:01:58'); +EXPLAIN SELECT outr.col_int_nokey +FROM t2 as outr +STRAIGHT_JOIN t3 AS outr2 +ON outr2.col_time_key > outr.col_datetime_key +WHERE outr.col_int_nokey IN ( +SELECT col_int_key +FROM t1 AS innr +WHERE innr.pk >= innr.col_int_nokey +) AND ( +outr.col_int_nokey <= 6 +OR +outr.col_varchar_key IS NULL +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE outr NULL ALL col_datetime_key NULL NULL NULL 1 100.00 Using where +2 SIMPLE innr NULL ref col_int_key col_int_key 4 test.outr.col_int_nokey 1 33.33 Using where; Start temporary; End temporary +2 SIMPLE outr2 NULL index col_time_key col_time_key 4 NULL 20 33.33 Using where; Using index +Warnings: +Warning 1739 Cannot use range access on index 'col_time_key' due to type or collation conversion on field 'col_time_key' +Note 1003 /* select#1 */ select `test`.`outr`.`col_int_nokey` AS `col_int_nokey` from `test`.`t2` `outr` straight_join `test`.`t3` `outr2` semi join (`test`.`t1` `innr`) where ((`test`.`innr`.`col_int_key` = `test`.`outr`.`col_int_nokey`) and (`test`.`outr`.`col_int_nokey` <= 6) and (`test`.`innr`.`pk` >= `test`.`innr`.`col_int_nokey`) and (cast(`test`.`outr2`.`col_time_key` as datetime) > `test`.`outr`.`col_datetime_key`)) +SELECT outr.col_int_nokey +FROM t2 as outr +STRAIGHT_JOIN t3 AS outr2 +ON outr2.col_time_key > outr.col_datetime_key +WHERE outr.col_int_nokey IN ( +SELECT col_int_key +FROM t1 AS innr +WHERE innr.pk >= innr.col_int_nokey +) AND ( +outr.col_int_nokey <= 6 +OR +outr.col_varchar_key IS NULL +); +col_int_nokey +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +DROP TABLE t1,t2,t3; +SET TIMESTAMP = DEFAULT; +# End of test for bug#13623473. +# +# Bug#13980954: Missing data on left join + null value + where..in +# +CREATE TABLE t1 ( +ik INT, +vc varchar(1) +) charset utf8mb4; +INSERT INTO t1 VALUES (8, 'x'), (NULL, 'x'); +CREATE TABLE t2 ( +ik INT, +vc varchar(1) +) charset utf8mb4; +INSERT INTO t2 VALUES +(0, 'x'), (7, 'i'), (7, 'e'), (1, 'p'), (7, 's'), (1, 'j'); +explain format=json SELECT t2.vc, t2.ik AS t2_ik, t1.ik AS t1_ik +FROM t2 LEFT JOIN t1 ON t2.vc=t1.vc +WHERE t2.vc IN (SELECT vc FROM t2 AS t3); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "10.15" + }, + "nested_loop": [ + { + "duplicates_removal": { + "using_temporary_table": true, + "nested_loop": [ + { + "table": { + "table_name": "t3", + "access_type": "ALL", + "rows_examined_per_scan": 6, + "rows_produced_per_join": 6, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "0.60", + "prefix_cost": "1.11", + "data_read_per_join": "96" + }, + "used_columns": [ + "vc" + ] + } + }, + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 6, + "rows_produced_per_join": 1, + "filtered": "16.67", + "cost_info": { + "read_cost": "3.04", + "eval_cost": "0.10", + "prefix_cost": "9.45", + "data_read_per_join": "16" + }, + "used_columns": [ + "ik", + "vc" + ], + "attached_condition": "(`test`.`t2`.`vc` = `test`.`t3`.`vc`)" + } + } + ] + } + }, + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 2, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.20", + "prefix_cost": "10.15", + "data_read_per_join": "32" + }, + "used_columns": [ + "ik", + "vc" + ], + "attached_condition": "(is_not_null_compl(t1), (`test`.`t1`.`vc` = `test`.`t3`.`vc`), true)" + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`vc` AS `vc`,`test`.`t2`.`ik` AS `t2_ik`,`test`.`t1`.`ik` AS `t1_ik` from `test`.`t2` left join `test`.`t1` on((`test`.`t1`.`vc` = `test`.`t3`.`vc`)) semi join (`test`.`t2` `t3`) where (`test`.`t2`.`vc` = `test`.`t3`.`vc`) +SELECT t2.vc, t2.ik AS t2_ik, t1.ik AS t1_ik +FROM t2 LEFT JOIN t1 ON t2.vc=t1.vc +WHERE t2.vc IN (SELECT vc FROM t2 AS t3); +vc t2_ik t1_ik +e 7 NULL +i 7 NULL +j 1 NULL +p 1 NULL +s 7 NULL +x 0 8 +x 0 NULL +DROP TABLE t1, t2; +# End of test for bug#13980954. +# +# Bug#14048292: Segfault in Item_field::result_type on 2nd execution +# of prep stmt with join of view +# +CREATE TABLE t1 ( +col_int INT +); +INSERT INTO t1 VALUES (0), (1); +CREATE VIEW view_t1 AS SELECT * FROM t1; +explain SELECT alias1.col_int +FROM t1 AS alias1 +LEFT JOIN view_t1 AS alias2 +ON alias1.col_int IN +(SELECT sq1_alias1.col_int +FROM t1 AS sq1_alias1 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE alias1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE sq1_alias1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Start temporary; End temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`alias1`.`col_int` AS `col_int` from `test`.`t1` `alias1` left join (`test`.`t1` semi join (`test`.`t1` `sq1_alias1`)) on(((`test`.`sq1_alias1`.`col_int` = `test`.`alias1`.`col_int`))) where true +PREPARE stmt FROM "SELECT alias1.col_int +FROM t1 AS alias1 +LEFT JOIN view_t1 AS alias2 +ON alias1.col_int IN +(SELECT sq1_alias1.col_int +FROM t1 AS sq1_alias1 +)"; +EXECUTE stmt; +col_int +0 +0 +1 +1 + +EXECUTE stmt; +col_int +0 +0 +1 +1 +DEALLOCATE PREPARE stmt; +DROP VIEW view_t1; +DROP TABLE t1; +# End of test for bug#14048292. +# +# Bug#14064201: Missing data on join of derived table + WHERE .. IN +# with two operands +# +CREATE TABLE t1 ( +col_varchar_nokey VARCHAR(1) +) charset utf8mb4; +INSERT INTO t1 VALUES +('v'), ('s'), ('l'), ('y'), ('c'), ('i'), ('h'), ('q'), ('a'), ('v'), +('u'), ('s'), ('y'), ('z'), ('h'), ('p'), ('e'), ('i'), ('y'), ('w'); +CREATE TABLE t2 ( +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +KEY col_varchar_key(col_varchar_key) +) charset utf8mb4; +INSERT INTO t2 VALUES +('j','j'), ('v','v'), ('c','c'), ('m','m'), ('d','d'), ('d','d'), ('y','y'); +SET @optimizer_switch_saved= @@optimizer_switch; +SET @@optimizer_switch="derived_merge=off"; +explain format=json SELECT * +FROM (SELECT * FROM t2) AS derived1 +LEFT JOIN t1 +USING (col_varchar_nokey) +WHERE (col_varchar_nokey, col_varchar_nokey) IN +(SELECT col_varchar_nokey, col_varchar_key +FROM t2 AS derived2 +); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "26.88" + }, + "nested_loop": [ + { + "duplicates_removal": { + "using_temporary_table": true, + "nested_loop": [ + { + "table": { + "table_name": "derived2", + "access_type": "ALL", + "possible_keys": [ + "col_varchar_key" + ], + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "0.70", + "prefix_cost": "1.21", + "data_read_per_join": "112" + }, + "used_columns": [ + "col_varchar_key", + "col_varchar_nokey" + ], + "attached_condition": "((`test`.`derived2`.`col_varchar_key` = `test`.`derived2`.`col_varchar_nokey`) and (`test`.`derived2`.`col_varchar_nokey` is not null))" + } + }, + { + "table": { + "table_name": "derived1", + "access_type": "ref", + "possible_keys": [ + "" + ], + "key": "", + "used_key_parts": [ + "col_varchar_nokey" + ], + "key_length": "7", + "ref": [ + "test.derived2.col_varchar_nokey" + ], + "rows_examined_per_scan": 2, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "3.50", + "eval_cost": "0.70", + "prefix_cost": "9.21", + "data_read_per_join": "112" + }, + "used_columns": [ + "col_varchar_key", + "col_varchar_nokey" + ], + "materialized_from_subquery": { + "using_temporary_table": true, + "dependent": false, + "cacheable": true, + "query_block": { + "select_id": 2, + "cost_info": { + "query_cost": "1.21" + }, + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "0.70", + "prefix_cost": "1.21", + "data_read_per_join": "112" + }, + "used_columns": [ + "col_varchar_key", + "col_varchar_nokey" + ] + } + } + } + } + } + ] + } + }, + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 140, + "filtered": "100.00", + "cost_info": { + "read_cost": "3.67", + "eval_cost": "14.00", + "prefix_cost": "26.88", + "data_read_per_join": "1K" + }, + "used_columns": [ + "col_varchar_nokey" + ], + "attached_condition": "(is_not_null_compl(t1), (`test`.`t1`.`col_varchar_nokey` = `test`.`derived2`.`col_varchar_nokey`), true)" + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select `derived1`.`col_varchar_nokey` AS `col_varchar_nokey`,`derived1`.`col_varchar_key` AS `col_varchar_key` from (/* select#2 */ select `test`.`t2`.`col_varchar_key` AS `col_varchar_key`,`test`.`t2`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t2`) `derived1` left join `test`.`t1` on((`test`.`t1`.`col_varchar_nokey` = `test`.`derived2`.`col_varchar_nokey`)) semi join (`test`.`t2` `derived2`) where ((`test`.`derived2`.`col_varchar_key` = `test`.`derived2`.`col_varchar_nokey`) and (`derived1`.`col_varchar_nokey` = `test`.`derived2`.`col_varchar_nokey`)) +SELECT * +FROM (SELECT * FROM t2) AS derived1 +LEFT JOIN t1 +USING (col_varchar_nokey) +WHERE (col_varchar_nokey, col_varchar_nokey) IN +(SELECT col_varchar_nokey, col_varchar_key +FROM t2 AS derived2 +); +col_varchar_nokey col_varchar_key +c c +d d +d d +j j +m m +v v +v v +y y +y y +y y +SET @@optimizer_switch= @optimizer_switch_saved; +DROP TABLE t1, t2; +CREATE TABLE t1 ( +col_int_nokey int NOT NULL, +col_int_key int NOT NULL, +KEY col_int_key (col_int_key) +); +INSERT INTO t1 VALUES +(1,7), (7,0), (4,9), (7,3), (0,4), (2,2), (9,5), (4,3), (0,1), (9,3), +(1,6), (3,7), (8,5), (8,1), (18,204), (84,224), (6,9), (3,5), (6,0), (6,3); +CREATE TABLE t2 ( +col_int_nokey int NOT NULL, +col_int_key int NOT NULL, +KEY col_int_key (col_int_key) +); +INSERT INTO t2 VALUES +(4,0), (6,8), (3,1), (5,8), (3,9), (246,24), (2,6), (9,1), (3,6), (8,2), +(1,4), (8,8), (8,4), (5,4), (7,7), (5,4), (1,1), (6,9), (2,4), (9,8); +explain format=json SELECT grandparent1.* +FROM t1 AS grandparent1 +LEFT JOIN t1 USING (col_int_nokey) +WHERE (col_int_nokey, col_int_nokey) IN +(SELECT col_int_nokey, col_int_key +FROM t2 +); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "62.95" + }, + "nested_loop": [ + { + "duplicates_removal": { + "using_temporary_table": true, + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "possible_keys": [ + "col_int_key" + ], + "rows_examined_per_scan": 20, + "rows_produced_per_join": 20, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "2.00", + "prefix_cost": "2.51", + "data_read_per_join": "320" + }, + "used_columns": [ + "col_int_nokey", + "col_int_key" + ], + "attached_condition": "(`test`.`t2`.`col_int_key` = `test`.`t2`.`col_int_nokey`)" + } + }, + { + "table": { + "table_name": "grandparent1", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 2, + "filtered": "10.00", + "cost_info": { + "read_cost": "10.22", + "eval_cost": "0.20", + "prefix_cost": "57.93", + "data_read_per_join": "32" + }, + "used_columns": [ + "col_int_nokey", + "col_int_key" + ], + "attached_condition": "(`test`.`grandparent1`.`col_int_nokey` = `test`.`t2`.`col_int_nokey`)" + } + } + ] + } + }, + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 40, + "filtered": "100.00", + "cost_info": { + "read_cost": "1.02", + "eval_cost": "4.00", + "prefix_cost": "62.95", + "data_read_per_join": "640" + }, + "used_columns": [ + "col_int_nokey" + ], + "attached_condition": "(is_not_null_compl(t1), (`test`.`t1`.`col_int_nokey` = `test`.`t2`.`col_int_nokey`), true)" + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`grandparent1`.`col_int_nokey` AS `col_int_nokey`,`test`.`grandparent1`.`col_int_key` AS `col_int_key` from `test`.`t1` `grandparent1` left join `test`.`t1` on((`test`.`t1`.`col_int_nokey` = `test`.`t2`.`col_int_nokey`)) semi join (`test`.`t2`) where ((`test`.`t2`.`col_int_key` = `test`.`t2`.`col_int_nokey`) and (`test`.`grandparent1`.`col_int_nokey` = `test`.`t2`.`col_int_nokey`)) +SELECT grandparent1.* +FROM t1 AS grandparent1 +LEFT JOIN t1 USING (col_int_nokey) +WHERE (col_int_nokey, col_int_nokey) IN +(SELECT col_int_nokey, col_int_key +FROM t2 +); +col_int_nokey col_int_key +1 6 +1 6 +1 7 +1 7 +7 0 +7 0 +7 3 +7 3 +8 1 +8 1 +8 5 +8 5 +DROP TABLE t1, t2; +CREATE TABLE t1 ( +pk int, +col_int_key int, +col_datetime_key datetime, +col_varchar_key varchar(1), +col_varchar_nokey varchar(1), +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_datetime_key (col_datetime_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4 engine=MyISAM; +INSERT INTO t1 VALUES +(10,7,'2004-06-06 04:22:12','v','v'), (11,0,'2005-11-13 01:12:31','s','s'), +(12,9,'2002-05-04 01:50:00','l','l'), (13,3,'2004-10-27 10:28:45','y','y'), +(14,4,'2006-07-22 05:24:23','c','c'), (15,2,'2002-05-16 21:34:03','i','i'), +(16,5,'2008-04-17 10:45:30','h','h'), (17,3,'2009-04-21 02:58:02','q','q'), +(18,1,'2008-01-11 11:01:51','a','a'), (19,3,'1900-01-01 00:00:00','v','v'), +(20,6,'2007-05-17 18:24:57','u','u'), (21,7,'2007-08-07 00:00:00','s','s'), +(22,5,'2001-08-28 00:00:00','y','y'), (23,1,'2004-04-16 00:27:28','z','z'), +(24,204,'2005-05-03 07:06:22','h','h'), (25,224,'2009-03-11 17:09:50','p','p'), +(26,9,'2007-12-08 01:54:28','e','e'), (27,5,'2009-07-28 18:19:54','i','i'), +(28,0,'2008-06-08 00:00:00','y','y'), (29,3,'2005-02-09 09:20:26','w','w'); +CREATE TABLE t2 ( +pk int, +col_int_key int, +col_datetime_key datetime, +col_varchar_key varchar(1), +col_varchar_nokey varchar(1), +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_datetime_key (col_datetime_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4 engine=MyISAM; +INSERT INTO t2 VALUES +(1,0,'2002-02-13 17:30:06','j','j'), (2,8,'2008-09-27 00:34:58','v','v'), +(3,1,'2007-05-28 00:00:00','c','c'), (4,8,'2009-07-25 09:21:20','m','m'), +(5,9,'2002-01-16 00:00:00','d','d'), (6,24,'2006-10-12 04:32:53','d','d'), +(7,6,'2001-02-15 03:08:38','y','y'), (8,1,'2004-10-02 20:31:15','t','t'), +(9,6,'2002-08-20 22:48:00','d','d'), (10,2,'1900-01-01 00:00:00','s','s'), +(11,4,'2005-08-15 00:00:00','r','r'), (12,8,'1900-01-01 00:00:00','m','m'), +(13,4,'2008-05-16 08:09:06','b','b'), (14,4,'2001-01-20 12:47:23','x','x'), +(15,7,'2008-07-02 00:00:00','g','g'), (16,4,'1900-01-01 00:00:00','p','p'), +(17,1,'2002-12-08 11:34:58','q','q'), (18,9,'1900-01-01 00:00:00','w','w'), +(19,4,'1900-01-01 00:00:00','d','d'), (20,8,'2002-08-25 20:35:06','e','e'); +SELECT alias1.col_datetime_key +FROM t2 AS alias1 +RIGHT JOIN t2 AS alias2 +JOIN t2 AS alias3 +ON alias3.pk = alias2.pk +ON alias3.col_varchar_nokey = alias2.col_varchar_key OR +alias2.col_varchar_nokey +WHERE (alias2.col_varchar_key, alias2.col_varchar_key) IN +(SELECT sq2_alias2.col_varchar_key, sq2_alias1.col_varchar_nokey +FROM t1 AS sq2_alias1, t1 AS sq2_alias2 +WHERE sq2_alias2.col_int_key < 2); +col_datetime_key +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +2001-01-20 12:47:23 +2001-01-20 12:47:23 +2001-02-15 03:08:38 +2001-02-15 03:08:38 +2002-01-16 00:00:00 +2002-01-16 00:00:00 +2002-02-13 17:30:06 +2002-02-13 17:30:06 +2002-08-20 22:48:00 +2002-08-20 22:48:00 +2002-08-25 20:35:06 +2002-08-25 20:35:06 +2002-12-08 11:34:58 +2002-12-08 11:34:58 +2004-10-02 20:31:15 +2004-10-02 20:31:15 +2005-08-15 00:00:00 +2005-08-15 00:00:00 +2006-10-12 04:32:53 +2006-10-12 04:32:53 +2007-05-28 00:00:00 +2007-05-28 00:00:00 +2008-05-16 08:09:06 +2008-05-16 08:09:06 +2008-07-02 00:00:00 +2008-07-02 00:00:00 +2008-09-27 00:34:58 +2008-09-27 00:34:58 +2009-07-25 09:21:20 +2009-07-25 09:21:20 +ALTER TABLE t1 DISABLE KEYS; +ALTER TABLE t2 DISABLE KEYS; +explain format=json SELECT alias1.col_datetime_key +FROM t2 AS alias1 +RIGHT JOIN t2 AS alias2 +JOIN t2 AS alias3 +ON alias3.pk = alias2.pk +ON alias3.col_varchar_nokey = alias2.col_varchar_key OR +alias2.col_varchar_nokey +WHERE (alias2.col_varchar_key, alias2.col_varchar_key) IN +(SELECT sq2_alias2.col_varchar_key, sq2_alias1.col_varchar_nokey +FROM t1 AS sq2_alias1, t1 AS sq2_alias2 +WHERE sq2_alias2.col_int_key < 2); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "62.73" + }, + "nested_loop": [ + { + "duplicates_removal": { + "using_temporary_table": true, + "nested_loop": [ + { + "table": { + "table_name": "sq2_alias2", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 6, + "filtered": "33.33", + "cost_info": { + "read_cost": "1.86", + "eval_cost": "0.67", + "prefix_cost": "2.53", + "data_read_per_join": "213" + }, + "used_columns": [ + "col_int_key", + "col_varchar_key" + ], + "attached_condition": "(`test`.`sq2_alias2`.`col_int_key` < 2)" + } + }, + { + "table": { + "table_name": "alias2", + "access_type": "ALL", + "possible_keys": [ + "PRIMARY" + ], + "rows_examined_per_scan": 20, + "rows_produced_per_join": 13, + "filtered": "10.00", + "cost_info": { + "read_cost": "3.53", + "eval_cost": "1.33", + "prefix_cost": "19.39", + "data_read_per_join": "426" + }, + "used_columns": [ + "pk", + "col_varchar_key", + "col_varchar_nokey" + ], + "attached_condition": "(`test`.`alias2`.`col_varchar_key` = `test`.`sq2_alias2`.`col_varchar_key`)" + } + }, + { + "table": { + "table_name": "sq2_alias1", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 2, + "filtered": "10.00", + "cost_info": { + "read_cost": "7.05", + "eval_cost": "0.20", + "prefix_cost": "56.97", + "data_read_per_join": "64" + }, + "used_columns": [ + "col_varchar_nokey" + ], + "attached_condition": "(`test`.`sq2_alias1`.`col_varchar_nokey` = `test`.`sq2_alias2`.`col_varchar_key`)" + } + } + ] + } + }, + { + "table": { + "table_name": "alias3", + "access_type": "eq_ref", + "possible_keys": [ + "PRIMARY" + ], + "key": "PRIMARY", + "used_key_parts": [ + "pk" + ], + "key_length": "4", + "ref": [ + "test.alias2.pk" + ], + "rows_examined_per_scan": 1, + "rows_produced_per_join": 2, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.20", + "prefix_cost": "57.67", + "data_read_per_join": "64" + }, + "used_columns": [ + "pk", + "col_varchar_nokey" + ] + } + }, + { + "table": { + "table_name": "alias1", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 40, + "filtered": "100.00", + "cost_info": { + "read_cost": "1.06", + "eval_cost": "4.00", + "prefix_cost": "62.73", + "data_read_per_join": "1K" + }, + "used_columns": [ + "col_datetime_key" + ], + "attached_condition": "(is_not_null_compl(alias1), (((`test`.`alias2`.`col_varchar_key` = `test`.`sq2_alias2`.`col_varchar_key`) and (`test`.`sq2_alias1`.`col_varchar_nokey` = `test`.`sq2_alias2`.`col_varchar_key`) and (`test`.`alias3`.`col_varchar_nokey` = `test`.`sq2_alias2`.`col_varchar_key`)) or (0 <> `test`.`alias2`.`col_varchar_nokey`)), true)" + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`alias1`.`col_datetime_key` AS `col_datetime_key` from `test`.`t2` `alias2` join `test`.`t2` `alias3` left join `test`.`t2` `alias1` on((((`test`.`alias2`.`col_varchar_key` = `test`.`sq2_alias2`.`col_varchar_key`) and (`test`.`sq2_alias1`.`col_varchar_nokey` = `test`.`sq2_alias2`.`col_varchar_key`) and (`test`.`alias3`.`col_varchar_nokey` = `test`.`sq2_alias2`.`col_varchar_key`)) or (0 <> `test`.`alias2`.`col_varchar_nokey`))) semi join (`test`.`t1` `sq2_alias1` join `test`.`t1` `sq2_alias2`) where ((`test`.`alias3`.`pk` = `test`.`alias2`.`pk`) and (`test`.`alias2`.`col_varchar_key` = `test`.`sq2_alias2`.`col_varchar_key`) and (`test`.`sq2_alias1`.`col_varchar_nokey` = `test`.`sq2_alias2`.`col_varchar_key`) and (`test`.`sq2_alias2`.`col_int_key` < 2)) +SELECT alias1.col_datetime_key +FROM t2 AS alias1 +RIGHT JOIN t2 AS alias2 +JOIN t2 AS alias3 +ON alias3.pk = alias2.pk +ON alias3.col_varchar_nokey = alias2.col_varchar_key OR +alias2.col_varchar_nokey +WHERE (alias2.col_varchar_key, alias2.col_varchar_key) IN +(SELECT sq2_alias2.col_varchar_key, sq2_alias1.col_varchar_nokey +FROM t1 AS sq2_alias1, t1 AS sq2_alias2 +WHERE sq2_alias2.col_int_key < 2); +col_datetime_key +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +2001-01-20 12:47:23 +2001-01-20 12:47:23 +2001-02-15 03:08:38 +2001-02-15 03:08:38 +2002-01-16 00:00:00 +2002-01-16 00:00:00 +2002-02-13 17:30:06 +2002-02-13 17:30:06 +2002-08-20 22:48:00 +2002-08-20 22:48:00 +2002-08-25 20:35:06 +2002-08-25 20:35:06 +2002-12-08 11:34:58 +2002-12-08 11:34:58 +2004-10-02 20:31:15 +2004-10-02 20:31:15 +2005-08-15 00:00:00 +2005-08-15 00:00:00 +2006-10-12 04:32:53 +2006-10-12 04:32:53 +2007-05-28 00:00:00 +2007-05-28 00:00:00 +2008-05-16 08:09:06 +2008-05-16 08:09:06 +2008-07-02 00:00:00 +2008-07-02 00:00:00 +2008-09-27 00:34:58 +2008-09-27 00:34:58 +2009-07-25 09:21:20 +2009-07-25 09:21:20 +DROP TABLE t1, t2; +# End of test for bug#14064201. +# +# Bug#18223655:ASSERTION FAILED: (INT)IDX >= 0 +# && IDX < PARENT_JOIN->TABLES +# +CREATE TABLE b (d INT); +CREATE TABLE c (a INT, b INT,c INT,d BLOB NOT NULL); +SELECT(SELECT 1 +FROM b WHERE(SELECT 1 IN (SELECT 1 FROM b WHERE 1 NOT BETWEEN d AND 1) +FROM b) IN (SELECT d FROM c)) as cc FROM b; +cc +INSERT INTO b VALUE(1); +INSERT INTO c VALUES(1,2,3,'1'),(2,3,4,'1'),(3,4,5,'C'); +SELECT(SELECT d FROM b WHERE(SELECT d IN +(SELECT d FROM b WHERE 1 NOT BETWEEN d AND 1) FROM b) IN +(SELECT d FROM c)) as cc FROM c; +cc +1 +1 +1 +DROP TABLE b,c; +# +# Bug#18447874:WRONG RESULT COMING FROM SEMI-JOIN +# +CREATE TABLE b ( +d INT(11) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE c ( +d BLOB +) ; +CREATE TABLE d ( +b INT(11) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO b VALUES(1),(2),(4); +INSERT INTO c VALUES(1),(2),(3); +SELECT 1 FROM b WHERE (SELECT 1 FROM d ) IN (SELECT d FROM c) ; +1 +INSERT INTO d VALUES(2); +SELECT 1 FROM b WHERE (SELECT 1 FROM d ) IN (SELECT d FROM c) ; +1 +1 +1 +1 +DROP TABLE b,c,d; +# +# Bug#17292723:INCORRECT RESULT FOR (SELECT...) IN (SELECT...) STATEMENT +# +CREATE TABLE t1 ( +ID int(11) NOT NULL AUTO_INCREMENT, +id2 int(11) DEFAULT NULL, +id3 int(11) DEFAULT NULL, +id4 varchar(150) COLLATE utf8_spanish_ci NOT NULL, +id5 int(11) DEFAULT NULL, +PRIMARY KEY (ID), +KEY id2 (id2), +KEY id3 (id3), +KEY id5 (id5) +) ENGINE=InnoDB; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 3778 'utf8_spanish_ci' is a collation of the deprecated character set UTF8MB3. Please consider using UTF8MB4 with an appropriate collation instead. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES +(123,1,1,'1',NULL), +(124,1,1,'2',NULL), +(125,1,1,'4',NULL), +(126,1,1,'3',NULL), +(127,1,1,'6',NULL), +(128,1,1,'8',NULL); +CREATE TABLE t2 ( +id6 int(11) NOT NULL, +id7 int(11) NOT NULL, +PRIMARY KEY (id6,id7), +KEY id7 (id7) +) ENGINE=InnoDB; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (126,123),(130,123),(135,123); +SELECT ID +FROM t1 p0 +WHERE p0.id3=1 +AND ( (SELECT p1.id FROM t1 p1 WHERE p1.id=123) IN (SELECT p3.id FROM t2 +p2, t1 p3 WHERE p0.id=p2.id6 AND p2.id7=p3.id)); +ID +126 +DROP TABLE t1,t2; +set @@optimizer_switch=@old_opt_switch; +# End of 5.6 tests +# +# Bug#19336348 DEBUG CRASH AT SETUP_SEMIJOIN_DUPS_ELIMINATION IN SQL/SQL_SELECT.CC +# +CREATE TABLE t1 ( +col_varchar_nokey varchar(1) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t1 VALUES ('c'),(NULL),('x'); +CREATE TABLE t2 ( +pk int, +col_varchar_key varchar(1), +PRIMARY KEY (pk), +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t2 VALUES (10,'l'),(11,'p'); +ANALYZE TABLE t1,t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN SELECT 1 +FROM t1 AS outr +WHERE outr.col_varchar_nokey IN +( +SELECT innr.col_varchar_key +FROM t2 AS innr +WHERE innr.pk <= 7 +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE innr NULL index PRIMARY,col_varchar_key col_varchar_key 7 NULL 2 100.00 Using where; Using index; LooseScan +1 SIMPLE outr NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` `outr` semi join (`test`.`t2` `innr`) where ((`test`.`outr`.`col_varchar_nokey` = `test`.`innr`.`col_varchar_key`) and (`test`.`innr`.`pk` <= 7)) +SELECT 1 +FROM t1 AS outr +WHERE outr.col_varchar_nokey IN +( +SELECT innr.col_varchar_key +FROM t2 AS innr +WHERE innr.pk <= 7 +) +; +1 +DROP TABLE t1,t2; +# +# Bug#18174394 BLOBS: CRASH AFTER UNINITIALIZED VALUES IN ITEM_FIELD::STR_RESULT +# +CREATE TABLE t1(d BLOB, b BLOB); +INSERT INTO t1(d,b) VALUES ('aaaa',''),('bnbb',''); +SELECT 1 FROM t1 +WHERE (SELECT b FROM t1) IN (SELECT (d>=1) FROM t1); +ERROR 21000: Subquery returns more than 1 row +DROP TABLE t1; +# +# Bug#19779600: ASSERT FAILED IN REPLACE_SUBCONDITION WITH IN +# PREDICATE INSIDE IN PREDICATE +# +CREATE TABLE t(X INT) ENGINE=InnoDB; +INSERT INTO t VALUES (1); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +EXPLAIN SELECT 1 FROM t WHERE (1 IN (SELECT 1 FROM t)) IN (SELECT 1 FROM t); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 PRIMARY t NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary; End temporary +2 SUBQUERY t NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t` semi join (`test`.`t`) where true +SELECT 1 FROM t WHERE (1 IN (SELECT 1 FROM t)) IN (SELECT 1 FROM t); +1 +1 +DROP TABLE t; +# +# Bug#19465034 ASSERT ON SETUP_SEMIJOIN_DUPS_ELIMINATION IN SQL/SQL_SELECT.CC +# +CREATE TABLE t1 ( +pk INTEGER NOT NULL, +i1 INTEGER NOT NULL, +PRIMARY KEY (pk) +) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1,1); +CREATE TABLE t2 ( +pk INTEGER NOT NULL, +c1 VARCHAR(1) NOT NULL, +PRIMARY KEY (pk), +KEY c1_key (c1) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t2 VALUES (1,'j'),(2,'v'),(3,'c'); +CREATE TABLE t3 ( +pk INTEGER NOT NULL, +c1 VARCHAR(1) NOT NULL, +PRIMARY KEY (pk), +KEY c1_key (c1) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t3 VALUES (10,'v'),(11,'s'); +ANALYZE TABLE t1, t2, t3; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +EXPLAIN SELECT * +FROM t1 JOIN t2 ON t1.i1 >= t2.pk +WHERE t2.c1 IN ( +SELECT t3.c1 +FROM t3 +WHERE t3.pk < 3 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t3 NULL index PRIMARY,c1_key c1_key 6 NULL 2 100.00 Using where; Using index; LooseScan +2 SIMPLE t2 NULL ref PRIMARY,c1_key c1_key 6 test.t3.c1 1 33.33 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`i1` AS `i1`,`test`.`t2`.`pk` AS `pk`,`test`.`t2`.`c1` AS `c1` from `test`.`t1` join `test`.`t2` semi join (`test`.`t3`) where ((`test`.`t2`.`c1` = `test`.`t3`.`c1`) and (`test`.`t3`.`pk` < 3) and (`test`.`t1`.`i1` >= `test`.`t2`.`pk`)) +SELECT * +FROM t1 JOIN t2 ON t1.i1 >= t2.pk +WHERE t2.c1 IN ( +SELECT t3.c1 +FROM t3 +WHERE t3.pk < 3 +); +pk i1 pk c1 +DROP TABLE t1,t2,t3; +# +# Bug#19586047: CRASH IN ARG_COMPARATOR::SET_CMP_FUNC +# +CREATE TABLE t1(x INT) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT 1 FROM t1 WHERE EXISTS(SELECT 1) IN (SELECT 1 FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary; End temporary +2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` semi join (`test`.`t1`) where true +SELECT 1 FROM t1 WHERE EXISTS(SELECT 1) IN (SELECT 1 FROM t1); +1 +1 +EXPLAIN SELECT 1 FROM t1 WHERE (SELECT 1, 2 FROM t1) IN (SELECT 1, 2 FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary; End temporary +2 SUBQUERY t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` semi join (`test`.`t1`) where true +SELECT 1 FROM t1 WHERE (SELECT 1, 2 FROM t1) IN (SELECT 1, 2 FROM t1); +1 +1 +EXPLAIN SELECT 1 FROM t1 WHERE +(SELECT 1, 2 FROM t1 WHERE x = 2) IN (SELECT 1, 2 FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +2 SUBQUERY t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` semi join (`test`.`t1`) where false +SELECT 1 FROM t1 WHERE +(SELECT 1, 2 FROM t1 WHERE x = 2) IN (SELECT 1, 2 FROM t1); +1 +DROP TABLE t1; +# +#Bug#20119743 ASSERTIONQEP_TAB->USE_ORDER() IN ENUM_NESTED_LOOP_STATE +# EVALUATE_JOIN_RECORD +# +CREATE TABLE t1 ( +pk int(11) NOT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +PRIMARY KEY (pk) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (1,'x'); +CREATE TABLE t2 ( +col_date_key date DEFAULT NULL, +col_int_key int(11) DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +KEY col_int_key (col_int_key), +KEY col_date_key (col_date_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES ('2000-12-03', 8, 'x', 'x'),('2008-05-03', 7, 'd', 'd'), +('2005-12-06', 1, 'r', 'r'),('2000-04-10', 7, 'f', 'f'), +('2002-11-05', 9, 'y', 'y'),('2000-09-06', NULL, 'u', 'u'), +(NULL, 1, 'm', 'm'),('2007-06-14', 9, NULL, NULL), +('2007-11-17', 2, 'o', 'o'),('2009-02-23', 9, 'w', 'w'), +('2007-01-08', 2, 'm', 'm'), ('2008-06-10', 4, 'q', 'q'), +('2002-10-20', 0, NULL, NULL),('2008-09-12', 4, 'd', 'd'), +('2006-06-16', 8, 'g', 'g'),('2004-09-18', NULL, 'x', 'x'), +('1900-01-01', NULL, 'f', 'f'),('2005-09-13', 0, 'p', 'p'), +('2007-04-09', NULL, 'j', 'j'),('2000-09-20', 8, 'c', 'c'); +CREATE TABLE t3 ( +pk int(11) NOT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +PRIMARY KEY (pk) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t3 VALUES (1, 'c'),(2, 'c'),(3, 'q'),(4, 'g'),(5, 'e'),(6, 'l'), +(7, NULL),(8, 'v'),(9, 'c'),(10, 'u'),(11, 'x'),(12, 'x'),(13, 'x'),(14, 'l'), +(15, 'e'),(16, 's'),(17, 'k'),(18, 'm'),(19, 'x'),(20, 's'); +ANALYZE TABLE t1,t2,t3; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +EXPLAIN SELECT r1.col_date_key +FROM t2 AS r1 +WHERE r1.col_int_key NOT IN +(SELECT ir2.pk +FROM t2 AS ir1 STRAIGHT_JOIN t1 AS ir2 +ON ir2.col_varchar_nokey = ir1.col_varchar_key +WHERE ir2.col_varchar_nokey > r1.col_varchar_nokey +AND ir2.pk IN +(SELECT iir2.pk +FROM t2 AS iir1 RIGHT JOIN t3 AS iir2 +ON iir2.col_varchar_nokey = iir1.col_varchar_key)) +ORDER BY r1.col_date_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY r1 NULL ALL NULL NULL NULL NULL 20 100.00 Using where; Using filesort +2 DEPENDENT SUBQUERY iir2 NULL eq_ref PRIMARY PRIMARY 4 func 1 100.00 Using where; Start temporary; Full scan on NULL key +2 DEPENDENT SUBQUERY iir1 NULL ref col_varchar_key col_varchar_key 7 test.iir2.col_varchar_nokey 1 100.00 Using index +2 DEPENDENT SUBQUERY ir1 NULL index col_varchar_key col_varchar_key 12 NULL 20 100.00 Using where; Using index +2 DEPENDENT SUBQUERY ir2 NULL eq_ref PRIMARY PRIMARY 4 func 1 100.00 Using where; End temporary; Full scan on NULL key +SELECT r1.col_date_key +FROM t2 AS r1 +WHERE r1.col_int_key NOT IN +(SELECT ir2.pk +FROM t2 AS ir1 STRAIGHT_JOIN t1 AS ir2 +ON ir2.col_varchar_nokey = ir1.col_varchar_key +WHERE ir2.col_varchar_nokey > r1.col_varchar_nokey +AND ir2.pk IN +(SELECT iir2.pk +FROM t2 AS iir1 RIGHT JOIN t3 AS iir2 +ON iir2.col_varchar_nokey = iir1.col_varchar_key)) +ORDER BY r1.col_date_key; +col_date_key +2000-04-10 +2000-09-20 +2000-12-03 +2002-10-20 +2002-11-05 +2004-09-18 +2005-09-13 +2006-06-16 +2007-01-08 +2007-06-14 +2007-11-17 +2008-05-03 +2008-06-10 +2008-09-12 +2009-02-23 +SELECT COUNT(r1.col_date_key) AS COUNT_NUM +FROM t2 AS r1 +WHERE r1.col_int_key NOT IN +(SELECT ir2.pk +FROM t2 AS ir1 STRAIGHT_JOIN t1 AS ir2 +ON ir2.col_varchar_nokey = ir1.col_varchar_key +WHERE ir2.col_varchar_nokey > r1.col_varchar_nokey +AND ir2.pk IN +(SELECT iir2.pk +FROM t2 AS iir1 RIGHT JOIN t3 AS iir2 +ON iir2.col_varchar_nokey = iir1.col_varchar_key +WHERE iir2.pk<3)); +COUNT_NUM +15 +DROP TABLE t1,t2,t3; +# +# Bug#20554585 ASSERT JOIN()->TABLES == 0... IN JOIN_TAB::GET_SJ_STRATEGY ON SUBQUERY + VAR +# +CREATE TABLE t1 ( +pk int NOT NULL, +PRIMARY KEY (pk) +); +CREATE TABLE t2 ( +pk int NOT NULL, +col_int_key int, +col_varchar_key varchar(1), +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key) +); +CREATE TABLE t3 ( +pk int NOT NULL, +col_int_key int, +col_varchar_key varchar(1), +col_varchar varchar(1), +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key) +); +INSERT INTO t3 VALUES (1,4,'c','g'),(20,1,'i','p'); +CREATE TABLE t4 ( +col_int int +); +CREATE TABLE t5 ( +col_varchar_key varchar(1), +pk int NOT NULL, +col_int int, +PRIMARY KEY (pk), +KEY col_varchar_key (col_varchar_key) +); +SELECT table1.col_varchar_key AS field1 +FROM (t3 AS table1 +INNER JOIN ( +SELECT SUBQUERY1_t1.* +FROM (t1 AS SUBQUERY1_t1 +RIGHT JOIN (t2 AS SUBQUERY1_t2 +INNER JOIN t3 AS SUBQUERY1_t3 +ON (SUBQUERY1_t3.col_varchar_key = SUBQUERY1_t2.col_varchar_key) +) ON (SUBQUERY1_t3.col_int_key = SUBQUERY1_t2.pk) +) +WHERE SUBQUERY1_t2.col_varchar_key >= ANY ( +SELECT CHILD_SUBQUERY1_t2.col_varchar AS CHILD_SUBQUERY1_field1 +FROM (t2 AS CHILD_SUBQUERY1_t1 +LEFT OUTER JOIN t3 AS CHILD_SUBQUERY1_t2 +ON (CHILD_SUBQUERY1_t2.col_int_key = CHILD_SUBQUERY1_t1.col_int_key) +) +WHERE CHILD_SUBQUERY1_t1.pk >= SUBQUERY1_t2.pk +) +) AS table2 +ON (table2.pk = table1.pk) +) +WHERE (EXISTS (( +SELECT DISTINCT SUBQUERY2_t2.col_int AS SUBQUERY2_field1 +FROM (t4 AS SUBQUERY2_t1 +LEFT OUTER JOIN t5 AS SUBQUERY2_t2 +ON (SUBQUERY2_t2.pk = SUBQUERY2_t1.col_int) +) +WHERE SUBQUERY2_t2.col_varchar_key != @var4 +))) +AND table1.col_int_key < (35 + 192) +ORDER BY field1 +; +field1 +DROP TABLE t1, t2, t3, t4, t5; +# +# Bug#18892055: MISSING DATA ON SELECT ... IN WITH JOINS AND INNODB +# ENGINE +# +CREATE TABLE t1 ( +col_int_key INT, +pk INT NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +) ENGINE = INNODB; +INSERT INTO t1 VALUES +( 0, 3 ), +( 0, 4 ), +( 3, 1 ), +( 900000000, 2 ), +( 1368719360, 5 ), +( 1922236416, 6 ), +( 8,7 ); +CREATE TABLE t2 ( +pk INT NOT NULL, +col_int INT, +PRIMARY KEY (pk) +) ENGINE = INNODB; +INSERT INTO t2 VALUES +( 1, 3 ), +( 2, 2 ), +( 3, 8 ), +( 4, 7 ); +CREATE TABLE t3 ( +col_int_key INT, +col_int INT, +KEY (col_int_key) +) ENGINE = INNODB; +INSERT INTO t3 VALUES +( 5, 1 ), +( -1, -1 ), +( 300000000, 1 ), +( 8, 1 ); +CREATE TABLE t4 ( col_int_key INT ) ENGINE = INNODB; +INSERT INTO t4 VALUES +(0), +(3), +(8), +(900000000), +(1368719360), +(1922236416); +ANALYZE TABLE t1, t2, t3, t4; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +test.t4 analyze status OK +explain SELECT * +FROM t4 +WHERE (col_int_key) IN ( +SELECT t1.col_int_key +FROM t1 LEFT JOIN ( t2 JOIN t3 ON t3.col_int_key = t2.col_int ) USING ( pk ) +WHERE t3.col_int IS NULL +) +ORDER BY col_int_key +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index col_int_key col_int_key 5 NULL 7 100.00 Using index; Using temporary; Using filesort; Start temporary +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.pk 1 100.00 NULL +1 SIMPLE t3 NULL ref col_int_key col_int_key 5 test.t2.col_int 1 25.00 Using where +1 SIMPLE t4 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`col_int_key` AS `col_int_key` from `test`.`t4` semi join (`test`.`t1` left join (`test`.`t2` join `test`.`t3`) on(((`test`.`t1`.`pk` = `test`.`t2`.`pk`) and (`test`.`t3`.`col_int_key` = `test`.`t2`.`col_int`)))) where ((`test`.`t4`.`col_int_key` = `test`.`t1`.`col_int_key`) and (`test`.`t3`.`col_int` is null)) order by `test`.`t4`.`col_int_key` +explain format=tree SELECT * +FROM t4 +WHERE (col_int_key) IN ( +SELECT t1.col_int_key +FROM t1 LEFT JOIN ( t2 JOIN t3 ON t3.col_int_key = t2.col_int ) USING ( pk ) +WHERE t3.col_int IS NULL +) +ORDER BY col_int_key +; +EXPLAIN +-> Sort: t4.col_int_key + -> Stream results (cost=8.04 rows=7) + -> Remove duplicate t4 rows using temporary table (weedout) (cost=8.04 rows=7) + -> Nested loop inner join (cost=8.04 rows=7) + -> Filter: (t3.col_int is null) (cost=3.40 rows=7) + -> Nested loop left join (cost=3.40 rows=7) + -> Index scan on t1 using col_int_key (cost=0.95 rows=7) + -> Nested loop inner join (cost=2.41 rows=1) + -> Single-row index lookup on t2 using PRIMARY (pk=t1.pk) (cost=0.26 rows=1) + -> Index lookup on t3 using col_int_key (col_int_key=t2.col_int) (cost=0.25 rows=1) + -> Filter: (t4.col_int_key = t1.col_int_key) (cost=0.54 rows=1) + -> Table scan on t4 (cost=0.54 rows=6) + +SELECT * +FROM t4 +WHERE (col_int_key) IN ( +SELECT t1.col_int_key +FROM t1 LEFT JOIN ( t2 JOIN t3 ON t3.col_int_key = t2.col_int ) USING ( pk ) +WHERE t3.col_int IS NULL +) +ORDER BY col_int_key +; +col_int_key +0 +3 +8 +900000000 +1368719360 +1922236416 +DROP TABLE t1, t2, t3, t4; +# +# Bug#20835095 CRASH AT CREATE_REF_FOR_KEY IN SQL/SQL_SELECT.CC +# +CREATE TABLE t1 ( +pk INTEGER, +var_10_latin1 VARCHAR(10) CHARACTER SET latin1, +var_255_utf8 VARCHAR(255) CHARACTER SET utf8, +var_255_latin1 VARCHAR(255) CHARACTER SET latin1, +var_10_utf8 VARCHAR(10) CHARACTER SET utf8, +PRIMARY KEY (pk) +); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +CREATE VIEW v1 AS SELECT * FROM t1; +INSERT INTO t1 VALUES +(1,'FROCJ','korrhrspki','UAYVL','BPZIS'), +(2,'him','a','CHYKN','OZZQT'), +(3,'WBITK','ULWBF','have','rhrh'), +(4,'or','right','up','it'), +(5,'GGDCP','x','who','as'), +(6,'j','i','e','w'); +CREATE TABLE tv +SELECT var_255_utf8 AS field1 +FROM t1; +EXPLAIN SELECT * FROM tv +WHERE field1 IN ( +SELECT tv1.var_255_utf8 +FROM v1 AS tv1 LEFT JOIN v1 AS tv2 ON tv1.var_10_latin1=tv2.var_10_utf8); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 6 100.00 Start temporary +1 SIMPLE tv NULL ALL NULL NULL NULL NULL 6 16.67 Using where +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 6 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`tv`.`field1` AS `field1` from `test`.`tv` semi join (`test`.`t1` left join (`test`.`t1`) on((`test`.`t1`.`var_10_latin1` = `test`.`t1`.`var_10_utf8`))) where (`test`.`tv`.`field1` = `test`.`t1`.`var_255_utf8`) +SELECT * FROM tv +WHERE field1 IN ( +SELECT tv1.var_255_utf8 +FROM v1 AS tv1 LEFT JOIN v1 AS tv2 ON tv1.var_10_latin1=tv2.var_10_utf8); +field1 +korrhrspki +a +ULWBF +right +x +i +DROP VIEW v1; +DROP TABLE t1, tv; +# 17832047 Crash in calculate_materialization_costs +CREATE TABLE t1(a INTEGER PRIMARY KEY); +INSERT INTO t1 VALUES (0),(1),(2); +SELECT 1 FROM t1 +WHERE 1 IN +(SELECT 1 BETWEEN (LENGTH(a) IN (SELECT 1 FROM t1)) AND 1 +FROM t1 +); +1 +1 +1 +1 +DROP TABLE t1; +# 17845989 Assertion failed: !(used_tables() & ... +CREATE TABLE a(b INTEGER) engine=innodb; +CREATE TABLE c(a INTEGER) engine=innodb; +SELECT 1 +FROM a +WHERE 1 IN (SELECT (a.b IS NULL) IN (SELECT 1 FROM c) FROM c) +; +1 +DROP TABLE a, c; +# +# Bug#18194196: OPTIMIZER EXECUTES STATEMENT INPERFORMANT +# +CREATE TABLE t1 (uid INTEGER, fid INTEGER, INDEX(uid)); +INSERT INTO t1 VALUES +(1,1), (1,2), (1,3), (1,4), +(2,5), (2,6), (2,7), (2,8), +(3,1), (3,2), (3,9); +CREATE TABLE t2 (uid INT PRIMARY KEY, name VARCHAR(128), INDEX(name)); +INSERT INTO t2 VALUES +(1, "A"), (2, "B"), (3, "C"), (4, "D"), (5, "E"), +(6, "F"), (7, "G"), (8, "H"), (9, "I"); +CREATE TABLE t3 (uid INT, fid INT, INDEX(uid)); +INSERT INTO t3 VALUES +(1,1), (1,2), (1,3),(1,4), +(2,5), (2,6), (2,7), (2,8), +(3,1), (3,2), (3,9); +CREATE TABLE t4 (uid INT PRIMARY KEY, name VARCHAR(128), INDEX(name)); +INSERT INTO t4 VALUES +(1, "A"), (2, "B"), (3, "C"), (4, "D"), (5, "E"), +(6, "F"), (7, "G"), (8, "H"), (9, "I"); +ANALYZE TABLE t1,t2,t3,t4; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +test.t4 analyze status OK +EXPLAIN SELECT name FROM t2, t1 +WHERE t1.uid IN (SELECT t4.uid FROM t4, t3 WHERE t3.uid=1 AND t4.uid=t3.fid) +AND t2.uid=t1.fid; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ref uid uid 5 const 4 100.00 Using where; Start temporary +1 SIMPLE t4 NULL eq_ref PRIMARY PRIMARY 4 test.t3.fid 1 100.00 Using index +1 SIMPLE t1 NULL ref uid uid 5 test.t3.fid 4 100.00 Using where; End temporary +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.fid 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`name` AS `name` from `test`.`t4` join `test`.`t2` join `test`.`t1` semi join (`test`.`t3`) where ((`test`.`t4`.`uid` = `test`.`t3`.`fid`) and (`test`.`t1`.`uid` = `test`.`t3`.`fid`) and (`test`.`t3`.`uid` = 1) and (`test`.`t2`.`uid` = `test`.`t1`.`fid`)) +FLUSH STATUS; +SELECT name FROM t2, t1 +WHERE t1.uid IN (SELECT t4.uid FROM t4, t3 WHERE t3.uid=1 AND t4.uid=t3.fid) +AND t2.uid=t1.fid; +name +A +A +B +B +C +D +E +F +G +H +I +SHOW STATUS LIKE '%handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 20 +Handler_read_last 0 +Handler_read_next 15 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +DROP TABLE t1,t2,t3,t4; +# End of test for Bug#18194196 +# +# Bug#21184091 ASSERT `READ_ROWS >= 0.0' AT +# COST_MODEL_SERVER::TMPTABLE_READWRITE_COST() +# +CREATE TABLE t1 ( +pk INTEGER, +col_varchar varchar(1), +col_int INTEGER, +PRIMARY KEY (pk) +) ENGINE=MyISAM; +CREATE TABLE t2 ( +col_int INTEGER, +col_varchar varchar(1) +) ENGINE=MyISAM; +INSERT INTO t2 VALUES (7,'x'); +INSERT INTO t2 VALUES (4,'z'); +SELECT t2.col_varchar +FROM t2 STRAIGHT_JOIN t1 ON t2.col_varchar = t1.col_varchar +JOIN t2 AS table3 ON t1.pk = table3.col_int +WHERE t1.pk IN (SELECT col_int FROM t1); +col_varchar +DROP TABLE t1,t2; +# End of test for Bug#21184091 +# Bug#21139722: Assertion failed: !(used_tables() & ((table_map) 1) ... +CREATE TABLE t1(a INTEGER) engine=innodb; +CREATE TABLE t2(b INTEGER) engine=innodb; +explain SELECT 1 +FROM (SELECT 1 IN (SELECT 1 +FROM t1 +WHERE (SELECT 1 FROM t2 HAVING b) NOT IN (SELECT 1 FROM t2) +) +FROM t2 +) AS z; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DERIVED t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +3 DEPENDENT SUBQUERY t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +5 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +4 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1276 Field or reference 'b' of SELECT #4 was resolved in SELECT #2 +Note 1003 /* select#1 */ select 1 AS `1` from (/* select#2 */ select (1,(/* select#3 */ select 1 from `test`.`t1` where ((/* select#4 */ select 1 from `test`.`t2` having (0 <> `test`.`t2`.`b`)),(/* select#5 */ select 1 from `test`.`t2` where (outer_field_is_not_null, (((/* select#4 */ select 1 from `test`.`t2` having (0 <> `test`.`t2`.`b`))) = 1), true)) is false))) AS `1 IN (SELECT 1 +FROM t1 +WHERE (SELECT 1 FROM t2 HAVING b) NOT IN (SELECT 1 FROM t2) +)` from `test`.`t2`) `z` +SELECT 1 +FROM (SELECT 1 IN (SELECT 1 +FROM t1 +WHERE (SELECT 1 FROM t2 HAVING b) NOT IN (SELECT 1 FROM t2) +) +FROM t2 +) AS z; +1 +DROP TABLE t1, t2; +CREATE TABLE t1(a INTEGER) engine=innodb; +explain SELECT (SELECT a FROM t1 AS t2 +WHERE a IN (SELECT t1.a+t2.a FROM t1 AS t3)) +FROM t1 AS t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 DEPENDENT SUBQUERY t3 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #3 was resolved in SELECT #1 +Note 1276 Field or reference 'test.t2.a' of SELECT #3 was resolved in SELECT #2 +Note 1003 /* select#1 */ select (/* select#2 */ select `test`.`t2`.`a` from `test`.`t1` `t2` semi join (`test`.`t1` `t3`) where (`test`.`t2`.`a` = (`test`.`t1`.`a` + `test`.`t2`.`a`))) AS `(SELECT a FROM t1 AS t2 +WHERE a IN (SELECT t1.a+t2.a FROM t1 AS t3))` from `test`.`t1` +SELECT (SELECT a FROM t1 AS t2 +WHERE a IN (SELECT t1.a+t2.a FROM t1 AS t3)) +FROM t1 AS t1; +(SELECT a FROM t1 AS t2 +WHERE a IN (SELECT t1.a+t2.a FROM t1 AS t3)) +DROP TABLE t1; +# End of test for Bug#21139722 +SET DEFAULT_STORAGE_ENGINE=INNODB; +# +# Bug#21139402 ASSERTION FAILED: LENGTH > 0 && KEYPARTS != 0, CRASH IN JOIN::OPTIMIZE_KEYUSE +# +CREATE TABLE t1 (a INT, b INT, PRIMARY KEY(a)); +CREATE TABLE t2 (c INT PRIMARY KEY); +EXPLAIN SELECT 1 FROM t1 +WHERE 1 IN +(SELECT (c IS NULL) IN (SELECT a FROM t1 WHERE b) FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +3 SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` semi join (`test`.`t2`) where false +SELECT 1 FROM t1 +WHERE 1 IN +(SELECT (c IS NULL) IN (SELECT a FROM t1 WHERE b) FROM t2); +1 +DROP TABLE t1,t2; +# +# Bug#21619634 ACCESS OF DEALLOCATED ITEM_OUTER_REF CAUSES CRASH: PREPARED STMT +# +create table cc (i int) engine="innodb"; +insert into cc values (1); +select (select count(i) from cc as cc_alias +where (cc.i in (select cc_alias.i from cc))) +from cc group by i; +(select count(i) from cc as cc_alias +where (cc.i in (select cc_alias.i from cc))) +1 +prepare stmt from +"select (select count(i) from cc as cc_alias + where (cc.i in (select cc_alias.i from cc))) + from cc group by i"; +execute stmt; +(select count(i) from cc as cc_alias + where (cc.i in (select cc_alias.i from cc))) +1 +execute stmt; +(select count(i) from cc as cc_alias + where (cc.i in (select cc_alias.i from cc))) +1 +drop table cc; +# +# Bug #22305361: QUERY WITH MATERIALIZED TABLE RETURNS INCORRECT +# RESULTS IN 5.6 +# +CREATE TABLE t(a INT,b INT); +INSERT INTO t VALUES (1,0),(1,0),(1,0),(1,0),(1,1); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +EXPLAIN SELECT * +FROM t AS t1 +WHERE t1.a IN (SELECT t2.a +FROM t AS t2 +WHERE CONCAT(t2.a,'') NOT IN (SELECT t3.a +FROM t AS t3 +WHERE t3.b=1)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 5 100.00 Using where; Start temporary +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 5 20.00 Using where; End temporary +3 DEPENDENT SUBQUERY t3 NULL ALL NULL NULL NULL NULL 5 20.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t` `t1` semi join (`test`.`t` `t2`) where ((`test`.`t1`.`a` = `test`.`t2`.`a`) and (concat(`test`.`t2`.`a`,''),(/* select#3 */ select `test`.`t3`.`a` from `test`.`t` `t3` where ((`test`.`t3`.`b` = 1) and (outer_field_is_not_null, (((concat(`test`.`t2`.`a`,'')) = `test`.`t3`.`a`) or (`test`.`t3`.`a` is null)), true)) having (outer_field_is_not_null, (`test`.`t3`.`a`), true)) is false)) +SELECT * +FROM t AS t1 +WHERE t1.a IN (SELECT t2.a +FROM t AS t2 +WHERE CONCAT(t2.a,'') NOT IN (SELECT t3.a +FROM t AS t3 +WHERE t3.b=1)); +a b +DROP TABLE t; +# +# Bug#24287772 SUBQUERY RETURNS EMPTY LIST WHILE IDENTICAL QUERY +# WITH JOIN RETURNS RESULT +# +CREATE TABLE t SELECT 4096 c; +SELECT c FROM t WHERE 1 IN +(SELECT t.c = page_size FROM information_schema.innodb_cmpmem); +c +4096 +DROP TABLE t; +# +# Bug #29132639: WL#12470: SIG 6 IN CONNECTJOINS|SQL/SQL_EXECUTOR.C +# +CREATE TABLE t1 ( f1 TIME, f2 VARCHAR(1) ); +INSERT INTO t1 VALUES ('08:35:24', 'X'), ('14:51:13', 'S'), ('11:22:33', 'Q'); +CREATE TABLE t2 ( pk INTEGER ); +INSERT INTO t2 VALUES (1), (2); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN FORMAT=tree SELECT * FROM t1 WHERE EXISTS ( SELECT alias1.f2 FROM t2 LEFT JOIN t1 ON 1 LEFT JOIN t1 AS alias1 ON 1 ); +EXPLAIN +-> Nested loop inner join (cost=10.50 rows=54) + -> Limit: 1 row(s) (cost=4.85 rows=18) + -> Nested loop left join (cost=4.85 rows=18) + -> Nested loop left join (cost=1.55 rows=6) + -> Table scan on t2 (cost=0.45 rows=2) + -> Table scan on t1 (cost=0.40 rows=3) + -> Table scan on alias1 (cost=5.40 rows=3) + -> Table scan on t1 (cost=0.55 rows=3) + +SELECT * FROM t1 WHERE EXISTS ( SELECT alias1.f2 FROM t2 LEFT JOIN t1 ON 1 LEFT JOIN t1 AS alias1 ON 1 ); +f1 f2 +08:35:24 X +11:22:33 Q +14:51:13 S +DROP TABLE t1, t2; +set optimizer_switch=default; +set optimizer_switch=default; diff --git a/mysql-test/r/subquery_sj_mat.result-pq b/mysql-test/r/subquery_sj_mat.result-pq new file mode 100644 index 000000000000..824b430d9784 --- /dev/null +++ b/mysql-test/r/subquery_sj_mat.result-pq @@ -0,0 +1,13224 @@ +set optimizer_switch='semijoin=on,materialization=on'; +set @old_opt_switch=@@optimizer_switch; +set optimizer_switch='subquery_materialization_cost_based=off'; +drop table if exists t0, t1, t2, t10, t11, t12; +create table t1 (a int not null, b int, primary key (a)); +create table t2 (a int not null, primary key (a)); +create table t3 (a int not null, b int, primary key (a)); +insert into t1 values (1,10), (2,20), (3,30), (4,40); +insert into t2 values (2), (3), (4), (5); +insert into t3 values (10,3), (20,4), (30,5); +select * from t2 where t2.a in (select a from t1); +a +2 +3 +4 +explain select * from t2 where t2.a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index PRIMARY PRIMARY 4 NULL 4 100.00 Using index +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t1` join `test`.`t2` where (`test`.`t1`.`a` = `test`.`t2`.`a`) +select * from t2 where t2.a in (select a from t1 where t1.b <> 30); +a +2 +4 +explain select * from t2 where t2.a in (select a from t1 where t1.b <> 30); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL PRIMARY NULL NULL NULL 4 75.00 Using where +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`a` = `test`.`t1`.`a`) and (`test`.`t1`.`b` <> 30)) +select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a); +a +2 +3 +explain select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL index PRIMARY PRIMARY 4 NULL 3 100.00 Using index +1 SIMPLE t1 NULL ALL PRIMARY NULL NULL NULL 4 25.00 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t1` join `test`.`t3` join `test`.`t2` where ((`test`.`t2`.`a` = `test`.`t1`.`a`) and (`test`.`t1`.`b` = `test`.`t3`.`a`)) +drop table t1, t2, t3; +create table t1 (a int, b int, index a (a,b)); +create table t2 (a int, index a (a)); +create table t3 (a int, b int, index a (a)); +insert into t1 values (1,10), (2,20), (3,30), (4,40); +create table t0(a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +insert into t1 +select rand()*100000+200,rand()*100000 from t0 A, t0 B, t0 C, t0 D; +insert into t2 values (2), (3), (4), (5); +insert into t3 values (10,3), (20,4), (30,5); +select * from t2 where t2.a in (select a from t1); +a +2 +3 +4 +explain select * from t2 where t2.a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index a a 5 NULL 4 100.00 Using where; Using index +1 SIMPLE NULL eq_ref 5 test.t2.a 1 100.00 NULL +2 MATERIALIZED t1 NULL index a a 10 NULL 10004 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1`) where (``.`a` = `test`.`t2`.`a`) +select * from t2 where t2.a in (select a from t1 where t1.b <> 30); +a +2 +4 +explain select * from t2 where t2.a in (select a from t1 where t1.b <> 30); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index a a 5 NULL 4 100.00 Using where; Using index +1 SIMPLE NULL eq_ref 5 test.t2.a 1 100.00 NULL +2 MATERIALIZED t1 NULL index a a 10 NULL 10004 90.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1`) where ((``.`a` = `test`.`t2`.`a`) and (`test`.`t1`.`b` <> 30)) +select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a); +a +2 +3 +explain select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index a a 5 NULL 4 100.00 Using where; Using index +1 SIMPLE NULL eq_ref 5 test.t2.a 1 100.00 NULL +2 MATERIALIZED t3 NULL index a a 5 NULL 3 100.00 Using index +2 MATERIALIZED t1 NULL index a a 10 NULL 10004 10.00 Using where; Using index; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1` join `test`.`t3`) where ((``.`a` = `test`.`t2`.`a`) and (`test`.`t1`.`b` = `test`.`t3`.`a`)) +insert into t1 values (3,31); +select * from t2 where t2.a in (select a from t1 where t1.b <> 30); +a +2 +3 +4 +select * from t2 where t2.a in (select a from t1 where t1.b <> 30 and t1.b <> 31); +a +2 +4 +explain select * from t2 where t2.a in (select a from t1 where t1.b <> 30); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index a a 5 NULL 4 100.00 Using where; Using index +1 SIMPLE NULL eq_ref 5 test.t2.a 1 100.00 NULL +2 MATERIALIZED t1 NULL index a a 10 NULL 10005 90.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1`) where ((``.`a` = `test`.`t2`.`a`) and (`test`.`t1`.`b` <> 30)) +drop table t0, t1, t2, t3; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1(a int, b int); +insert into t1 values (0,0),(1,1),(2,2); +create table t2 as select * from t1; +create table t11(a int, b int); +create table t10 (pk int, a int, primary key(pk)); +insert into t10 select a,a from t0; +create table t12 like t10; +insert into t12 select * from t10; +Flattened because of dependency, t10=func(t1) +explain select * from t1 where a in (select pk from t10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t1` where (`test`.`t10`.`pk` = `test`.`t1`.`a`) +select * from t1 where a in (select pk from t10); +a b +0 0 +1 1 +2 2 +A confluent case of dependency +explain select * from t1 where a in (select a from t10 where pk=12); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t1` where (multiple equal(12, NULL) and multiple equal(`test`.`t1`.`a`, NULL)) +select * from t1 where a in (select a from t10 where pk=12); +a b +explain select * from t1 where a in (select a from t10 where pk=9); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t10 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t1` where ((`test`.`t1`.`a` = '9')) +select * from t1 where a in (select a from t10 where pk=9); +a b +An empty table inside +explain select * from t1 where a in (select a from t11); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 0.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +2 MATERIALIZED t11 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t11`) where (`test`.`t1`.`a` = ``.`a`) +select * from t1 where a in (select a from t11); +a b +explain select * from t1 where a in (select pk from t10) and b in (select pk from t10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using index +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.t1.b 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t10` join `test`.`t1` where ((`test`.`t10`.`pk` = `test`.`t1`.`b`) and (`test`.`t10`.`pk` = `test`.`t1`.`a`)) +select * from t1 where a in (select pk from t10) and b in (select pk from t10); +a b +0 0 +1 1 +2 2 +flattening a nested subquery +explain select * from t1 where a in (select pk from t10 where t10.a in (select pk from t12)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using where +1 SIMPLE t12 NULL eq_ref PRIMARY PRIMARY 4 test.t10.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t12` join `test`.`t1` where ((`test`.`t10`.`pk` = `test`.`t1`.`a`) and (`test`.`t12`.`pk` = `test`.`t10`.`a`)) +select * from t1 where a in (select pk from t10 where t10.a in (select pk from t12)); +a b +0 0 +1 1 +2 2 +flattening subquery w/ several tables +explain select * from t1 where a in (select t10.pk from t10, t12 where t12.pk=t10.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using where +1 SIMPLE t12 NULL eq_ref PRIMARY PRIMARY 4 test.t10.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t12` join `test`.`t1` where ((`test`.`t10`.`pk` = `test`.`t1`.`a`) and (`test`.`t12`.`pk` = `test`.`t10`.`a`)) +subqueries within outer joins go into ON expr. +explain +select * from t1 left join (t2 A, t2 B) on ( A.A= t1.A and B.A in (select pk from t10)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE A NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE B NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.B.A 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`A` AS `A`,`test`.`t1`.`B` AS `B`,`test`.`A`.`A` AS `A`,`test`.`A`.`B` AS `B`,`test`.`B`.`A` AS `A`,`test`.`B`.`B` AS `B` from `test`.`t1` left join (`test`.`t10` join `test`.`t2` `A` join `test`.`t2` `B`) on(((`test`.`t10`.`pk` = `test`.`B`.`A`) and (`test`.`A`.`A` = `test`.`t1`.`A`))) where true +t2 should be wrapped into OJ-nest, so we have "t1 LJ (t2 J t10)" +explain +select * from t1 left join t2 on (t2.A= t1.A and t2.A in (select pk from t10)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.t1.A 1 100.00 Using index +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`A` AS `A`,`test`.`t1`.`B` AS `B`,`test`.`t2`.`A` AS `A`,`test`.`t2`.`B` AS `B` from `test`.`t1` left join (`test`.`t10` join `test`.`t2`) on(((`test`.`t10`.`pk` = `test`.`t1`.`A`) and (`test`.`t2`.`A` = `test`.`t1`.`A`))) where true +we shouldn't flatten if we're going to get a join of > MAX_TABLES. +explain select * from +t1 s00, t1 s01, t1 s02, t1 s03, t1 s04,t1 s05,t1 s06,t1 s07,t1 s08,t1 s09, +t1 s10, t1 s11, t1 s12, t1 s13, t1 s14,t1 s15,t1 s16,t1 s17,t1 s18,t1 s19, +t1 s20, t1 s21, t1 s22, t1 s23, t1 s24,t1 s25,t1 s26,t1 s27,t1 s28,t1 s29, +t1 s30, t1 s31, t1 s32, t1 s33, t1 s34,t1 s35,t1 s36,t1 s37,t1 s38,t1 s39, +t1 s40, t1 s41, t1 s42, t1 s43, t1 s44,t1 s45,t1 s46,t1 s47,t1 s48,t1 s49 +where +s00.a in ( +select m00.a from +t1 m00, t1 m01, t1 m02, t1 m03, t1 m04,t1 m05,t1 m06,t1 m07,t1 m08,t1 m09, +t1 m10, t1 m11, t1 m12, t1 m13, t1 m14,t1 m15,t1 m16,t1 m17,t1 m18,t1 m19 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY s00 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 PRIMARY s01 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s02 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s03 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s04 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s05 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s06 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s07 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s08 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s09 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s10 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s11 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s12 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s13 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s14 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s15 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s16 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s17 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s18 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s19 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s20 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s21 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s22 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s23 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s24 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s25 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s26 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s27 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s28 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s29 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s30 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s31 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s32 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s33 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s34 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s35 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s36 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s37 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s38 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s39 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s40 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s41 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s42 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s43 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s44 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s45 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s46 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s47 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s48 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s49 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 SUBQUERY m00 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 SUBQUERY m01 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 SUBQUERY m02 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 SUBQUERY m03 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 SUBQUERY m04 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 SUBQUERY m05 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 SUBQUERY m06 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 SUBQUERY m07 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 SUBQUERY m08 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 SUBQUERY m09 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 SUBQUERY m10 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 SUBQUERY m11 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 SUBQUERY m12 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 SUBQUERY m13 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 SUBQUERY m14 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 SUBQUERY m15 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 SUBQUERY m16 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 SUBQUERY m17 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 SUBQUERY m18 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 SUBQUERY m19 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`s00`.`a` AS `a`,`test`.`s00`.`b` AS `b`,`test`.`s01`.`a` AS `a`,`test`.`s01`.`b` AS `b`,`test`.`s02`.`a` AS `a`,`test`.`s02`.`b` AS `b`,`test`.`s03`.`a` AS `a`,`test`.`s03`.`b` AS `b`,`test`.`s04`.`a` AS `a`,`test`.`s04`.`b` AS `b`,`test`.`s05`.`a` AS `a`,`test`.`s05`.`b` AS `b`,`test`.`s06`.`a` AS `a`,`test`.`s06`.`b` AS `b`,`test`.`s07`.`a` AS `a`,`test`.`s07`.`b` AS `b`,`test`.`s08`.`a` AS `a`,`test`.`s08`.`b` AS `b`,`test`.`s09`.`a` AS `a`,`test`.`s09`.`b` AS `b`,`test`.`s10`.`a` AS `a`,`test`.`s10`.`b` AS `b`,`test`.`s11`.`a` AS `a`,`test`.`s11`.`b` AS `b`,`test`.`s12`.`a` AS `a`,`test`.`s12`.`b` AS `b`,`test`.`s13`.`a` AS `a`,`test`.`s13`.`b` AS `b`,`test`.`s14`.`a` AS `a`,`test`.`s14`.`b` AS `b`,`test`.`s15`.`a` AS `a`,`test`.`s15`.`b` AS `b`,`test`.`s16`.`a` AS `a`,`test`.`s16`.`b` AS `b`,`test`.`s17`.`a` AS `a`,`test`.`s17`.`b` AS `b`,`test`.`s18`.`a` AS `a`,`test`.`s18`.`b` AS `b`,`test`.`s19`.`a` AS `a`,`test`.`s19`.`b` AS `b`,`test`.`s20`.`a` AS `a`,`test`.`s20`.`b` AS `b`,`test`.`s21`.`a` AS `a`,`test`.`s21`.`b` AS `b`,`test`.`s22`.`a` AS `a`,`test`.`s22`.`b` AS `b`,`test`.`s23`.`a` AS `a`,`test`.`s23`.`b` AS `b`,`test`.`s24`.`a` AS `a`,`test`.`s24`.`b` AS `b`,`test`.`s25`.`a` AS `a`,`test`.`s25`.`b` AS `b`,`test`.`s26`.`a` AS `a`,`test`.`s26`.`b` AS `b`,`test`.`s27`.`a` AS `a`,`test`.`s27`.`b` AS `b`,`test`.`s28`.`a` AS `a`,`test`.`s28`.`b` AS `b`,`test`.`s29`.`a` AS `a`,`test`.`s29`.`b` AS `b`,`test`.`s30`.`a` AS `a`,`test`.`s30`.`b` AS `b`,`test`.`s31`.`a` AS `a`,`test`.`s31`.`b` AS `b`,`test`.`s32`.`a` AS `a`,`test`.`s32`.`b` AS `b`,`test`.`s33`.`a` AS `a`,`test`.`s33`.`b` AS `b`,`test`.`s34`.`a` AS `a`,`test`.`s34`.`b` AS `b`,`test`.`s35`.`a` AS `a`,`test`.`s35`.`b` AS `b`,`test`.`s36`.`a` AS `a`,`test`.`s36`.`b` AS `b`,`test`.`s37`.`a` AS `a`,`test`.`s37`.`b` AS `b`,`test`.`s38`.`a` AS `a`,`test`.`s38`.`b` AS `b`,`test`.`s39`.`a` AS `a`,`test`.`s39`.`b` AS `b`,`test`.`s40`.`a` AS `a`,`test`.`s40`.`b` AS `b`,`test`.`s41`.`a` AS `a`,`test`.`s41`.`b` AS `b`,`test`.`s42`.`a` AS `a`,`test`.`s42`.`b` AS `b`,`test`.`s43`.`a` AS `a`,`test`.`s43`.`b` AS `b`,`test`.`s44`.`a` AS `a`,`test`.`s44`.`b` AS `b`,`test`.`s45`.`a` AS `a`,`test`.`s45`.`b` AS `b`,`test`.`s46`.`a` AS `a`,`test`.`s46`.`b` AS `b`,`test`.`s47`.`a` AS `a`,`test`.`s47`.`b` AS `b`,`test`.`s48`.`a` AS `a`,`test`.`s48`.`b` AS `b`,`test`.`s49`.`a` AS `a`,`test`.`s49`.`b` AS `b` from `test`.`t1` `s00` join `test`.`t1` `s01` join `test`.`t1` `s02` join `test`.`t1` `s03` join `test`.`t1` `s04` join `test`.`t1` `s05` join `test`.`t1` `s06` join `test`.`t1` `s07` join `test`.`t1` `s08` join `test`.`t1` `s09` join `test`.`t1` `s10` join `test`.`t1` `s11` join `test`.`t1` `s12` join `test`.`t1` `s13` join `test`.`t1` `s14` join `test`.`t1` `s15` join `test`.`t1` `s16` join `test`.`t1` `s17` join `test`.`t1` `s18` join `test`.`t1` `s19` join `test`.`t1` `s20` join `test`.`t1` `s21` join `test`.`t1` `s22` join `test`.`t1` `s23` join `test`.`t1` `s24` join `test`.`t1` `s25` join `test`.`t1` `s26` join `test`.`t1` `s27` join `test`.`t1` `s28` join `test`.`t1` `s29` join `test`.`t1` `s30` join `test`.`t1` `s31` join `test`.`t1` `s32` join `test`.`t1` `s33` join `test`.`t1` `s34` join `test`.`t1` `s35` join `test`.`t1` `s36` join `test`.`t1` `s37` join `test`.`t1` `s38` join `test`.`t1` `s39` join `test`.`t1` `s40` join `test`.`t1` `s41` join `test`.`t1` `s42` join `test`.`t1` `s43` join `test`.`t1` `s44` join `test`.`t1` `s45` join `test`.`t1` `s46` join `test`.`t1` `s47` join `test`.`t1` `s48` join `test`.`t1` `s49` where (`test`.`s00`.`a`,`test`.`s00`.`a` in ( (/* select#2 */ select `test`.`m00`.`a` from `test`.`t1` `m00` join `test`.`t1` `m01` join `test`.`t1` `m02` join `test`.`t1` `m03` join `test`.`t1` `m04` join `test`.`t1` `m05` join `test`.`t1` `m06` join `test`.`t1` `m07` join `test`.`t1` `m08` join `test`.`t1` `m09` join `test`.`t1` `m10` join `test`.`t1` `m11` join `test`.`t1` `m12` join `test`.`t1` `m13` join `test`.`t1` `m14` join `test`.`t1` `m15` join `test`.`t1` `m16` join `test`.`t1` `m17` join `test`.`t1` `m18` join `test`.`t1` `m19` where true ), (`test`.`s00`.`a` in on where ((`test`.`s00`.`a` = ``.`a`))))) +select * from +t1 left join t2 on (t2.a= t1.a and t2.a in (select pk from t10)) +where t1.a < 5; +a b a b +0 0 0 0 +1 1 1 1 +2 2 2 2 +prepare s1 from +' select * from + t1 left join t2 on (t2.a= t1.a and t2.a in (select pk from t10)) + where t1.a < 5'; +execute s1; +a b a b +0 0 0 0 +1 1 1 1 +2 2 2 2 +execute s1; +a b a b +0 0 0 0 +1 1 1 1 +2 2 2 2 +insert into t1 select (A.a + 10 * B.a),1 from t0 A, t0 B; +explain select * from t1 where a in (select pk from t10 where pk<3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t10 NULL range PRIMARY PRIMARY 4 NULL 4 100.00 Using where; Using index +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 103 10.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t1` where ((`test`.`t1`.`a` = `test`.`t10`.`pk`) and (`test`.`t10`.`pk` < 3)) +drop table t0, t1, t2; +drop table t10, t11, t12; +# +# Check that subqueries with outer joins or straight_join work for +# different permutations of const and non-const tables. (Ref. Bug#46692) +# +CREATE TABLE t1 (i INTEGER); +CREATE TABLE t2 (i INTEGER); +CREATE TABLE t3 (i INTEGER); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 0 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 0 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 0 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 1 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 1 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 1 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 2 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 2 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 2 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (0); +DELETE FROM t2; +INSERT INTO t1 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 0 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where ((``.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 0 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where ((``.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 0 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where ((``.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 1 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where ((``.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 1 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where ((``.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 1 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where ((``.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 2 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where ((``.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 2 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where ((``.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 2 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where ((``.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (0); +DELETE FROM t2; +INSERT INTO t1 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 0 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 0.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = ``.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 0.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = ``.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 0.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = ``.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 0.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 0.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t1`.`i` = ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL const 5 const 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL const 5 const 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL const 5 const 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 0 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = ``.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = ``.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = ``.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t1`.`i` = ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL const 5 const 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL const 5 const 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL const 5 const 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 0 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = ``.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = ``.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = ``.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +1 +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t1`.`i` = ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL const 5 const 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL const 5 const 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL const 5 const 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 1 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 0.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = ``.`i`) and (`test`.`t2`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 0.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = ``.`i`) and (`test`.`t2`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 0.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = ``.`i`) and (`test`.`t2`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 0.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 0.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t1`.`i` = ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL const 5 const 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL const 5 const 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL const 5 const 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 1 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = ``.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = ``.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = ``.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t1`.`i` = ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL const 5 const 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL const 5 const 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL const 5 const 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 1 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = ``.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = ``.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = ``.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +1 +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t1`.`i` = ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +1 +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL const 5 const 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL const 5 const 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL const 5 const 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 2 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 0.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = ``.`i`) and (`test`.`t2`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 0.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = ``.`i`) and (`test`.`t2`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 0.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = ``.`i`) and (`test`.`t2`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 0.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 0.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t1`.`i` = ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL const 5 const 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL const 5 const 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL const 5 const 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 2 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = ``.`i`) and (`test`.`t2`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = ``.`i`) and (`test`.`t2`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = ``.`i`) and (`test`.`t2`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t1`.`i` = ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL const 5 const 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL const 5 const 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL const 5 const 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 2 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE NULL eq_ref 5 test.t1.i 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = `test`.`t1`.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +1 +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +1 +2 + +EXECUTE stmt; +i +1 +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE NULL eq_ref 5 test.t1.i 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = `test`.`t1`.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +1 +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE NULL eq_ref 5 test.t1.i 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = `test`.`t1`.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +1 +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +1 +2 + +EXECUTE stmt; +i +1 +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE NULL eq_ref 5 test.t1.i 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (``.`i` = `test`.`t1`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +1 +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE NULL eq_ref 5 test.t1.i 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (``.`i` = `test`.`t1`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +1 +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL const 5 const 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL const 5 const 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (0); +DELETE FROM t2; +INSERT INTO t1 VALUES (0); +DROP TABLE t1, t2, t3; +create table x1(k int primary key, d1 int, d2 int); +create table x2(k int primary key, d1 int, d2 int); +insert into x1 values +(10, 10, 10), +(20, 20, 20), +(21, 20, null), +(30, null, 30), +(40, 40, 40); +insert into x2 values +(10, 10, 10), +(20, 20, 20), +(21, 20, null), +(30, null, 30); +select * +from x1 +where (d1, d2) in (select d1, d2 +from x2); +k d1 d2 +10 10 10 +20 20 20 +select * +from x1 +where (d1, d2) in (select d1, d2 +from x2) is true; +k d1 d2 +10 10 10 +20 20 20 +select * +from x1 +where (d1, d2) in (select d1, d2 +from x2) is false; +k d1 d2 +40 40 40 +select * +from x1 +where (d1, d2) in (select d1, d2 +from x2) is unknown; +k d1 d2 +21 20 NULL +30 NULL 30 +select * +from x1 +where d1 in (select d1 +from x2 +where x1.d2=x2.d2); +k d1 d2 +10 10 10 +20 20 20 +select * +from x1 +where d1 in (select d1 +from x2 +where x1.d2=x2.d2) is true; +k d1 d2 +10 10 10 +20 20 20 +select * +from x1 +where d1 in (select d1 +from x2 +where x1.d2=x2.d2) is false; +k d1 d2 +21 20 NULL +40 40 40 +select * +from x1 +where d1 in (select d1 +from x2 +where x1.d2=x2.d2) is unknown; +k d1 d2 +30 NULL 30 +select * +from x1 +where 1 in (select 1 +from x2 +where x1.d1=x2.d1 and x1.d2=x2.d2); +k d1 d2 +10 10 10 +20 20 20 +select * +from x1 +where 1 in (select 1 +from x2 +where x1.d1=x2.d1 and x1.d2=x2.d2) is true; +k d1 d2 +10 10 10 +20 20 20 +select * +from x1 +where 1 in (select 1 +from x2 +where x1.d1=x2.d1 and x1.d2=x2.d2) is false; +k d1 d2 +21 20 NULL +30 NULL 30 +40 40 40 +select * +from x1 +where 1 in (select 1 +from x2 +where x1.d1=x2.d1 and x1.d2=x2.d2) is unknown; +k d1 d2 +select * +from x1 +where exists (select * +from x2 +where x1.d1=x2.d1 and x1.d2=x2.d2); +k d1 d2 +10 10 10 +20 20 20 +drop table x1; +drop table x2; +CREATE TABLE t1 ( +a int(11) NOT NULL, +b int(11) NOT NULL, +c datetime default NULL, +PRIMARY KEY (a), +KEY idx_bc (b,c) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES +(406989,67,'2006-02-23 17:08:46'), (150078,67,'2005-10-26 11:17:45'), +(406993,67,'2006-02-27 11:20:57'), (245655,67,'2005-12-08 15:59:08'), +(406994,67,'2006-02-27 11:26:46'), (256,67,NULL), +(398341,67,'2006-02-20 04:48:44'), (254,67,NULL),(1120,67,NULL), +(406988,67,'2006-02-23 17:07:22'), (255,67,NULL), +(398340,67,'2006-02-20 04:38:53'),(406631,67,'2006-02-23 10:49:42'), +(245653,67,'2005-12-08 15:59:07'),(406992,67,'2006-02-24 16:47:18'), +(245654,67,'2005-12-08 15:59:08'),(406995,67,'2006-02-28 11:55:00'), +(127261,67,'2005-10-13 12:17:58'),(406991,67,'2006-02-24 16:42:32'), +(245652,67,'2005-12-08 15:58:27'),(398545,67,'2006-02-20 04:53:13'), +(154504,67,'2005-10-28 11:53:01'),(9199,67,NULL),(1,67,'2006-02-23 15:01:35'), +(223456,67,NULL),(4101,67,NULL),(1133,67,NULL), +(406990,67,'2006-02-23 18:01:45'),(148815,67,'2005-10-25 15:34:17'), +(148812,67,'2005-10-25 15:30:01'),(245651,67,'2005-12-08 15:58:27'), +(154503,67,'2005-10-28 11:52:38'); +create table t11 select * from t1 where b = 67 AND (c IS NULL OR c > NOW()) order by 3 asc; +create table t12 select * from t1 where b = 67 AND (c IS NULL OR c > NOW()) order by 3 desc; +create table t21 select * from t1 where b = 67 AND (c IS NULL OR c > '2005-12-08') order by 3 asc; +create table t22 select * from t1 where b = 67 AND (c IS NULL OR c > '2005-12-08') order by 3 desc; +update t22 set c = '2005-12-08 15:58:27' where a = 255; +explain select t21.* from t21,t22 where t21.a = t22.a and +t22.a in (select t12.a from t11, t12 where t11.a in(255,256) and t11.a = t12.a and t11.c is null) and t22.c is null order by t21.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using temporary; Using filesort +1 SIMPLE t22 NULL ALL NULL NULL NULL NULL 26 3.85 Using where; Using join buffer (hash join) +1 SIMPLE t21 NULL ALL NULL NULL NULL NULL 26 10.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t11 NULL ALL NULL NULL NULL NULL 8 12.50 Using where +2 MATERIALIZED t12 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t21`.`a` AS `a`,`test`.`t21`.`b` AS `b`,`test`.`t21`.`c` AS `c` from `test`.`t21` join `test`.`t22` semi join (`test`.`t11` join `test`.`t12`) where ((`test`.`t22`.`a` = ``.`a`) and (`test`.`t21`.`a` = ``.`a`) and (`test`.`t12`.`a` = `test`.`t11`.`a`) and (`test`.`t22`.`c` is null) and (`test`.`t11`.`a` in (255,256)) and (`test`.`t11`.`c` is null)) order by `test`.`t21`.`a` +explain format=json select * from t1 where a in (select a from t11); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "6.71" + }, + "nested_loop": [ + { + "table": { + "table_name": "", + "access_type": "ALL", + "materialized_from_subquery": { + "using_temporary_table": true, + "query_block": { + "table": { + "table_name": "t11", + "access_type": "ALL", + "rows_examined_per_scan": 8, + "rows_produced_per_join": 8, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "0.80", + "prefix_cost": "1.31", + "data_read_per_join": "128" + }, + "used_columns": [ + "a" + ] + } + } + } + } + }, + { + "table": { + "table_name": "t1", + "access_type": "eq_ref", + "possible_keys": [ + "PRIMARY" + ], + "key": "PRIMARY", + "used_key_parts": [ + "a" + ], + "key_length": "4", + "ref": [ + ".a" + ], + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.10", + "prefix_cost": "6.71", + "data_read_per_join": "16" + }, + "used_columns": [ + "a", + "b", + "c" + ] + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` semi join (`test`.`t11`) where (`test`.`t1`.`a` = ``.`a`) +select t21.* from t21,t22 where t21.a = t22.a and +t22.a in (select t12.a from t11, t12 where t11.a in(255,256) and t11.a = t12.a and t11.c is null) and t22.c is null order by t21.a; +a b c +256 67 NULL +drop table t1, t11, t12, t21, t22; +create table t1(a int); +insert into t1 values (0),(1); +explain +select (select max(y.a) from t1 y where a in (select a from t1 z) and a < x.a) as subq from t1 x; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY x NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DEPENDENT SUBQUERY y NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 DEPENDENT SUBQUERY NULL eq_ref 5 test.y.a 1 100.00 NULL +3 MATERIALIZED z NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1276 Field or reference 'test.x.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select (/* select#2 */ select max(`test`.`y`.`a`) from `test`.`t1` `y` semi join (`test`.`t1` `z`) where ((``.`a` = `test`.`y`.`a`) and (`test`.`y`.`a` < `test`.`x`.`a`))) AS `subq` from `test`.`t1` `x` +select (select max(y.a) from t1 y where a in (select a from t1 z) and a < x.a) as subq from t1 x; +subq +NULL +0 +drop table t1; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 as select * from t0; +insert into t1 select a+10 from t0; +insert into t0 values(2); +explain select * from t1 where 2 in (select a from t0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL const 5 const 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 20 100.00 Using join buffer (hash join) +2 MATERIALIZED t0 NULL ALL NULL NULL NULL NULL 11 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t0`) where ((``.`a` = 2) and (`test`.`t0`.`a` = 2)) +select * from t1 where 2 in (select a from t0); +a +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +explain select * from (select a from t0) x where a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 11 100.00 NULL +1 SIMPLE NULL eq_ref 5 func 1 100.00 Using where +3 MATERIALIZED t1 NULL ALL NULL NULL NULL NULL 20 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a` from `test`.`t0` semi join (`test`.`t1`) where (``.`a` = `test`.`t0`.`a`) +explain format=json select * from (select a from t0) x where a in (select a from t1); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "8.21" + }, + "nested_loop": [ + { + "table": { + "table_name": "t0", + "access_type": "ALL", + "rows_examined_per_scan": 11, + "rows_produced_per_join": 11, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "1.10", + "prefix_cost": "1.60", + "data_read_per_join": "88" + }, + "used_columns": [ + "a" + ] + } + }, + { + "table": { + "table_name": "", + "access_type": "eq_ref", + "key": "", + "key_length": "5", + "ref": [ + "func" + ], + "rows_examined_per_scan": 1, + "attached_condition": "(``.`a` = `test`.`t0`.`a`)", + "materialized_from_subquery": { + "using_temporary_table": true, + "query_block": { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 20, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "2.00", + "prefix_cost": "2.51", + "data_read_per_join": "160" + }, + "used_columns": [ + "a" + ] + } + } + } + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a` from `test`.`t0` semi join (`test`.`t1`) where (``.`a` = `test`.`t0`.`a`) +drop table t0, t1; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (kp1 int, kp2 int, c int, filler char(100), key(kp1, kp2)); +insert into t1 select A.a+10*(B.a+10*C.a), 0, 0, 'filler' from t0 A, t0 B, t0 C; +insert into t1 select * from t1 where kp1 < 20; +create table t3 (a int); +insert into t3 select A.a + 10*B.a from t0 A, t0 B; +explain select * from t3 where a in (select kp1 from t1 where kp1<20); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 100 100.00 Using where +1 SIMPLE NULL eq_ref 5 test.t3.a 1 100.00 NULL +2 MATERIALIZED t1 NULL range kp1 kp1 5 NULL 48 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a` from `test`.`t3` semi join (`test`.`t1`) where ((``.`kp1` = `test`.`t3`.`a`) and (`test`.`t1`.`kp1` < 20)) +select * from t3 where a in (select kp1 from t1 where kp1<20); +a +0 +1 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +2 +3 +4 +5 +6 +7 +8 +9 +explain select * from t3 where a in (select kp1 from t1 where kp1<20) and a<20; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 100 33.33 Using where +1 SIMPLE NULL eq_ref 5 test.t3.a 1 100.00 NULL +2 MATERIALIZED t1 NULL range kp1 kp1 5 NULL 48 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a` from `test`.`t3` semi join (`test`.`t1`) where ((``.`kp1` = `test`.`t3`.`a`) and (`test`.`t3`.`a` < 20) and (`test`.`t1`.`kp1` < 20)) +select * from t3 where a in (select kp1 from t1 where kp1<20) and a<20; +a +0 +1 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +2 +3 +4 +5 +6 +7 +8 +9 +create table t4 (pk int primary key); +insert into t4 select a from t3; +explain select * from t3 where a in +(select t1.kp1 from t1,t4 where kp1<20 and t4.pk=t1.c); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 100 100.00 Using where +1 SIMPLE NULL eq_ref 5 test.t3.a 1 100.00 NULL +2 MATERIALIZED t1 NULL range kp1 kp1 5 NULL 48 100.00 Using where +2 MATERIALIZED t4 NULL eq_ref PRIMARY PRIMARY 4 test.t1.c 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a` from `test`.`t3` semi join (`test`.`t1` join `test`.`t4`) where ((``.`kp1` = `test`.`t3`.`a`) and (`test`.`t4`.`pk` = `test`.`t1`.`c`) and (`test`.`t1`.`kp1` < 20)) +explain format=tree select * from t3 where a in +(select t1.kp1 from t1,t4 where kp1<20 and t4.pk=t1.c); +EXPLAIN +-> Nested loop inner join (cost=500.54 rows=4800) + -> Filter: (t3.a is not null) (cost=10.54 rows=100) + -> Table scan on t3 (cost=10.54 rows=100) + -> Single-row index lookup on using (kp1=t3.a) + -> Materialize with deduplication (cost=43.46..43.46 rows=48) + -> Filter: (t1.kp1 is not null) (cost=38.66 rows=48) + -> Nested loop inner join (cost=38.66 rows=48) + -> Filter: ((t1.kp1 < 20) and (t1.c is not null)) (cost=21.86 rows=48) + -> Index range scan on t1 using kp1 (cost=21.86 rows=48) + -> Single-row index lookup on t4 using PRIMARY (pk=t1.c) (cost=0.25 rows=1) + +select * from t3 where a in +(select t1.kp1 from t1,t4 where kp1<20 and t4.pk=t1.c); +a +0 +1 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +2 +3 +4 +5 +6 +7 +8 +9 +drop table t1, t3, t4; +create table t1 (a int); +insert into t1 values (0),(0),(0),(1),(1),(1),(2),(2),(2),(3),(3),(3); +set session internal_tmp_mem_storage_engine='memory'; +set @save_max_heap_table_size=@@max_heap_table_size; +set @@max_heap_table_size= 16384; +# Attempt to make one test that overflows the heap table when a +# non-duplicate row is inserted and one test that overflows the +# heap table when a duplicate record is inserted. Debugging showed +# that these situations occurred with max_heap_table_size=16384 +# and optimizer_join_cache_level equals 1 and 0, respectively. +# Finally execute a test that does not overflow the heap table. +explain +select count(*) from t0 a, t0 b, t0 c +where c.a in (select a from t1 d); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE a NULL ALL NULL NULL NULL NULL 10 100.00 NULL +1 SIMPLE b NULL ALL NULL NULL NULL NULL 10 100.00 Using join buffer (hash join) +1 SIMPLE c NULL ALL NULL NULL NULL NULL 10 100.00 Using where; Using join buffer (hash join) +1 SIMPLE NULL eq_ref 5 test.c.a 1 100.00 NULL +2 MATERIALIZED d NULL ALL NULL NULL NULL NULL 12 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select count(0) AS `count(*)` from `test`.`t0` `a` join `test`.`t0` `b` join `test`.`t0` `c` semi join (`test`.`t1` `d`) where (``.`a` = `test`.`c`.`a`) +flush status; +select count(*) from t0 a, t0 b, t0 c +where c.a in (select a from t1 d); +count(*) +400 +show status like 'Created_tmp_disk_tables'; +Variable_name Value +Created_tmp_disk_tables 0 +set @@max_heap_table_size= @save_max_heap_table_size; +set session internal_tmp_mem_storage_engine=default; +flush status; +select count(*) from t0 a, t0 b, t0 c +where c.a in (select a from t1 d); +count(*) +400 +show status like 'Created_tmp_disk_tables'; +Variable_name Value +Created_tmp_disk_tables 0 +drop table t0, t1; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t2(a int); +insert into t2 values (1),(2); +create table t3 ( a int , filler char(100), key(a)); +insert into t3 select A.a + 10*B.a, 'filler' from t0 A, t0 B; +explain select * from t3 where a in (select a from t2) and (a > 5 or a < 10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using where +1 SIMPLE t3 NULL ref a a 5 .a 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a`,`test`.`t3`.`filler` AS `filler` from `test`.`t3` semi join (`test`.`t2`) where ((`test`.`t3`.`a` = ``.`a`) and ((``.`a` > 5) or (``.`a` < 10))) +select * from t3 where a in (select a from t2); +a filler +1 filler +2 filler +drop table t0, t2, t3; +create table t1 (a date); +insert into t1 values ('2008-01-01'),('2008-01-01'),('2008-02-01'),('2008-02-01'); +create table t2 (a int); +insert into t2 values (1),(2); +create table t3 (a char(10)); +insert into t3 select * from t1; +insert into t3 values (1),(2); +explain select * from t2 where a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1`) where (cast(`test`.`t2`.`a` as double) = cast(`test`.`t1`.`a` as double)) +explain select * from t2 where a in (select a from t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE NULL eq_ref 5 test.t2.a 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t2`) where (``.`a` = `test`.`t2`.`a`) +explain select * from t2 where a in (select a from t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t3`) where (cast(`test`.`t2`.`a` as double) = cast(`test`.`t3`.`a` as double)) +explain select * from t1 where a in (select a from t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t3`) where (`test`.`t1`.`a` = cast(`test`.`t3`.`a` as date)) +drop table t1, t2, t3; +create table t1 (a decimal); +insert into t1 values (1),(2); +explain select * from t1 where a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE NULL eq_ref 6 test.t1.a 1 100.00 NULL +2 MATERIALIZED t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t1`) where (``.`a` = `test`.`t1`.`a`) +drop table t1; +create table t1 (a int); +insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t2 as select * from t1; +create table t3 (a int, b int, filler char(100), key(a)) charset utf8mb4; +insert into t3 select A.a + 10*B.a, A.a + 10*B.a, 'filler' from t1 A, t1 B, t1 C; +explain select * from t1, t3 where t3.a in (select a from t2) and (t3.a < 10 or t3.a >30) and t1.a =3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 10.00 Using where +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ref a a 5 .a 10 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 10 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t3`.`filler` AS `filler` from `test`.`t1` join `test`.`t3` semi join (`test`.`t2`) where ((`test`.`t3`.`a` = ``.`a`) and (`test`.`t1`.`a` = 3) and ((``.`a` < 10) or (``.`a` > 30))) +explain format=json select * from t1, t3 where t3.a in (select a from t2) and (t3.a < 10 or t3.a >30) and t1.a =3; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "41.01" + }, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 10, + "rows_produced_per_join": 1, + "filtered": "10.00", + "cost_info": { + "read_cost": "1.40", + "eval_cost": "0.10", + "prefix_cost": "1.50", + "data_read_per_join": "8" + }, + "used_columns": [ + "a" + ], + "attached_condition": "(`test`.`t1`.`a` = 3)" + } + }, + { + "table": { + "table_name": "", + "access_type": "ALL", + "using_join_buffer": "hash join", + "attached_condition": "(((``.`a` < 10) or (``.`a` > 30)) and (``.`a` is not null))", + "materialized_from_subquery": { + "using_temporary_table": true, + "query_block": { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 10, + "rows_produced_per_join": 10, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "1.00", + "prefix_cost": "1.50", + "data_read_per_join": "80" + }, + "used_columns": [ + "a" + ] + } + } + } + } + }, + { + "table": { + "table_name": "t3", + "access_type": "ref", + "possible_keys": [ + "a" + ], + "key": "a", + "used_key_parts": [ + "a" + ], + "key_length": "5", + "ref": [ + ".a" + ], + "rows_examined_per_scan": 10, + "rows_produced_per_join": 10, + "filtered": "100.00", + "cost_info": { + "read_cost": "25.00", + "eval_cost": "1.00", + "prefix_cost": "41.01", + "data_read_per_join": "4K" + }, + "used_columns": [ + "a", + "b", + "filler" + ] + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t3`.`filler` AS `filler` from `test`.`t1` join `test`.`t3` semi join (`test`.`t2`) where ((`test`.`t3`.`a` = ``.`a`) and (`test`.`t1`.`a` = 3) and ((``.`a` < 10) or (``.`a` > 30))) +explain select straight_join * from t1 a, t1 b where a.a in (select a from t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY a NULL ALL NULL NULL NULL NULL 10 100.00 Using where +1 PRIMARY b NULL ALL NULL NULL NULL NULL 10 100.00 Using join buffer (hash join) +2 SUBQUERY t2 NULL ALL NULL NULL NULL NULL 10 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select straight_join `test`.`a`.`a` AS `a`,`test`.`b`.`a` AS `a` from `test`.`t1` `a` join `test`.`t1` `b` where (`test`.`a`.`a`,`test`.`a`.`a` in ( (/* select#2 */ select `test`.`t2`.`a` from `test`.`t2` where true ), (`test`.`a`.`a` in on where ((`test`.`a`.`a` = ``.`a`))))) +explain select * from t2 where a in (select straight_join a.a from t1 a, t1 b); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 10 100.00 Using where +2 SUBQUERY a NULL ALL NULL NULL NULL NULL 10 100.00 NULL +2 SUBQUERY b NULL ALL NULL NULL NULL NULL 10 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` where (`test`.`t2`.`a`,`test`.`t2`.`a` in ( (/* select#2 */ select straight_join `test`.`a`.`a` from `test`.`t1` `a` join `test`.`t1` `b` where true ), (`test`.`t2`.`a` in on where ((`test`.`t2`.`a` = ``.`a`))))) +explain select * from t2 where a in (select straight_join a.a from t1 a, t1 b); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 10 100.00 Using where +2 SUBQUERY a NULL ALL NULL NULL NULL NULL 10 100.00 NULL +2 SUBQUERY b NULL ALL NULL NULL NULL NULL 10 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` where (`test`.`t2`.`a`,`test`.`t2`.`a` in ( (/* select#2 */ select straight_join `test`.`a`.`a` from `test`.`t1` `a` join `test`.`t1` `b` where true ), (`test`.`t2`.`a` in on where ((`test`.`t2`.`a` = ``.`a`))))) +explain select straight_join * from t2 x, t2 y +where x.a in (select straight_join a.a from t1 a, t1 b); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY x NULL ALL NULL NULL NULL NULL 10 100.00 Using where +1 PRIMARY y NULL ALL NULL NULL NULL NULL 10 100.00 Using join buffer (hash join) +2 SUBQUERY a NULL ALL NULL NULL NULL NULL 10 100.00 NULL +2 SUBQUERY b NULL ALL NULL NULL NULL NULL 10 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select straight_join `test`.`x`.`a` AS `a`,`test`.`y`.`a` AS `a` from `test`.`t2` `x` join `test`.`t2` `y` where (`test`.`x`.`a`,`test`.`x`.`a` in ( (/* select#2 */ select straight_join `test`.`a`.`a` from `test`.`t1` `a` join `test`.`t1` `b` where true ), (`test`.`x`.`a` in on where ((`test`.`x`.`a` = ``.`a`))))) +create table t0 (a int, b int); +insert into t0 values(1,1); +explain select * from t0, t3 where t3.a in (select a from t2) and (t3.a < 10 or t3.a >30); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using where +1 SIMPLE t3 NULL ref a a 5 .a 10 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 10 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select '1' AS `a`,'1' AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t3`.`filler` AS `filler` from `test`.`t3` semi join (`test`.`t2`) where ((`test`.`t3`.`a` = ``.`a`) and ((``.`a` < 10) or (``.`a` > 30))) +create table t4 as select a as x, a as y from t1; +explain select * from t0, t3 where (t3.a, t3.b) in (select x,y from t4) and (t3.a < 10 or t3.a >30); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using where +1 SIMPLE t3 NULL ref a a 5 .x 10 10.00 Using where +2 MATERIALIZED t4 NULL ALL NULL NULL NULL NULL 10 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select '1' AS `a`,'1' AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t3`.`filler` AS `filler` from `test`.`t3` semi join (`test`.`t4`) where ((`test`.`t3`.`b` = ``.`y`) and (`test`.`t3`.`a` = ``.`x`) and ((``.`x` < 10) or (``.`x` > 30))) +drop table t0,t1,t2,t3,t4; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (a int, b int, filler char(100), key(a,b)); +insert into t1 select A.a, B.a, 'filler' from t0 A, t0 B; +create table t2 as select * from t1; +explain select * from t2 where a in (select b from t1 where a=3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 100 100.00 Using where +1 SIMPLE NULL eq_ref 5 test.t2.a 1 100.00 NULL +2 MATERIALIZED t1 NULL ref a a 5 const 8 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`filler` AS `filler` from `test`.`t2` semi join (`test`.`t1`) where ((``.`b` = `test`.`t2`.`a`) and (`test`.`t1`.`a` = 3)) +explain select * from t2 where (b,a) in (select a,b from t1 where a=3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 100 10.00 Using where +1 SIMPLE NULL eq_ref 10 test.t2.b,test.t2.a 1 100.00 Using where +2 MATERIALIZED t1 NULL ref a a 5 const 8 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`filler` AS `filler` from `test`.`t2` semi join (`test`.`t1`) where ((``.`b` = `test`.`t2`.`a`) and (`test`.`t2`.`b` = 3) and (``.`a` = 3) and (`test`.`t1`.`a` = 3)) +drop table t1,t2; +create table t1 (a int, b int); +insert into t1 select a,a from t0; +create table t2 (a int, b int); +insert into t2 select A.a + 10*B.a, A.a + 10*B.a from t0 A, t0 B; +explain select * from t1 where (a,b) in (select a,b from t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 100.00 Using where +1 SIMPLE NULL eq_ref 10 test.t1.a,test.t1.b 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 100 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t2`) where ((``.`b` = `test`.`t1`.`b`) and (``.`a` = `test`.`t1`.`a`)) +drop table t0, t1, t2; +# +# Bug#19695490: CRASH IN CREATE_REF_FOR_KEY ON SELECT + JOIN + UTF8 COLUMN +# + DATETIME INDEX. +# +CREATE TABLE t1 ( +field1 varchar(255) CHARACTER SET utf8, +field2 varchar(255) CHARACTER SET utf8 +); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES +('time','time'), +('lpjdzvkp','lpjdzvkp'), +('dzvkpai', 'dzvkpai'); +CREATE TABLE t2 ( col_varchar varchar(10)); +CREATE TABLE t3 ( +pk int(11) NOT NULL, +col_varchar_255_utf8_key varchar(255) CHARACTER SET utf8, +col_varchar_10_utf8_key varchar(10) CHARACTER SET utf8, +PRIMARY KEY (pk) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t3 VALUES (22,'come','h'), +(23,'time','aaa'), +(24,'lpjdzvkp','ababa'), +(25,'d','GGDD'); +SELECT * FROM t1 WHERE (field1, field2) IN ( +SELECT table1.col_varchar_255_utf8_key AS field1, +table1.col_varchar_255_utf8_key AS field2 +FROM t3 AS table1 LEFT JOIN t2 AS table2 +ON table1.col_varchar_10_utf8_key <= +table2.col_varchar +WHERE table1.pk >= 6); +field1 field2 +time time +lpjdzvkp lpjdzvkp +DROP TABLE t1,t2,t3; +create table t0 (a decimal(4,2)); +insert into t0 values (10.24), (22.11); +create table t1 as select * from t0; +insert into t1 select * from t0; +explain select * from t0 where a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE NULL eq_ref 3 test.t0.a 1 100.00 NULL +2 MATERIALIZED t1 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a` from `test`.`t0` semi join (`test`.`t1`) where (``.`a` = `test`.`t0`.`a`) +select * from t0 where a in (select a from t1); +a +10.24 +22.11 +drop table t0, t1; +create table t0(a date); +insert into t0 values ('2008-01-01'),('2008-02-02'); +create table t1 as select * from t0; +insert into t1 select * from t0; +explain select * from t0 where a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE NULL eq_ref 4 test.t0.a 1 100.00 NULL +2 MATERIALIZED t1 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a` from `test`.`t0` semi join (`test`.`t1`) where (``.`a` = `test`.`t0`.`a`) +select * from t0 where a in (select a from t1); +a +2008-01-01 +2008-02-02 +drop table t0, t1; +create table t0(a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 as select a as a, a as b, a as c from t0 where a < 3; +create table t2 as select a as a, a as b from t0 where a < 3; +insert into t2 select * from t2; +explain select * from t1 where (a,b,c) in (select x.a, y.a, z.a from t2 x, t2 y, t2 z where x.b=33); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE NULL eq_ref 15 test.t1.a,test.t1.b,test.t1.c 1 100.00 NULL +2 MATERIALIZED x NULL ALL NULL NULL NULL NULL 6 16.67 Using where +2 MATERIALIZED y NULL ALL NULL NULL NULL NULL 6 100.00 Using join buffer (hash join) +2 MATERIALIZED z NULL ALL NULL NULL NULL NULL 6 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` semi join (`test`.`t2` `x` join `test`.`t2` `y` join `test`.`t2` `z`) where ((``.`a` = `test`.`t1`.`c`) and (``.`a` = `test`.`t1`.`b`) and (``.`a` = `test`.`t1`.`a`) and (`test`.`x`.`b` = 33)) +drop table t0,t1,t2; +set @save_join_buffer_size = @@join_buffer_size; +set join_buffer_size= 8192; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (a int, filler1 binary(200), filler2 binary(200)); +insert into t1 select a, 'filler123456', 'filler123456' from t0; +insert into t1 select a+10, 'filler123456', 'filler123456' from t0; +create table t2 as select * from t1; +insert into t1 select a+20, 'filler123456', 'filler123456' from t0; +insert into t1 values (2, 'duplicate ok', 'duplicate ok'); +insert into t1 values (18, 'duplicate ok', 'duplicate ok'); +insert into t2 values (3, 'duplicate ok', 'duplicate ok'); +insert into t2 values (19, 'duplicate ok', 'duplicate ok'); +explain select +a, mid(filler1, 1,10), length(filler1)=length(filler2) as z +from t1 ot where a in (select a from t2 it); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 32 10.00 Using where; Using join buffer (hash join) +2 MATERIALIZED it NULL ALL NULL NULL NULL NULL 22 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot`.`a` AS `a`,substr(`test`.`ot`.`filler1`,1,10) AS `mid(filler1, 1,10)`,(length(`test`.`ot`.`filler1`) = length(`test`.`ot`.`filler2`)) AS `z` from `test`.`t1` `ot` semi join (`test`.`t2` `it`) where (`test`.`ot`.`a` = ``.`a`) +select +a, mid(filler1, 1,10), length(filler1)=length(filler2) as z +from t1 ot where a in (select a from t2 it); +a mid(filler1, 1,10) z +0 filler1234 1 +1 filler1234 1 +10 filler1234 1 +11 filler1234 1 +12 filler1234 1 +13 filler1234 1 +14 filler1234 1 +15 filler1234 1 +16 filler1234 1 +17 filler1234 1 +18 duplicate 1 +18 filler1234 1 +19 filler1234 1 +2 duplicate 1 +2 filler1234 1 +3 filler1234 1 +4 filler1234 1 +5 filler1234 1 +6 filler1234 1 +7 filler1234 1 +8 filler1234 1 +9 filler1234 1 +explain select +a, mid(filler1, 1,10), length(filler1)=length(filler2) +from t2 ot where a in (select a from t1 it); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 22 100.00 Using where +1 SIMPLE NULL eq_ref 5 test.ot.a 1 100.00 NULL +2 MATERIALIZED it NULL ALL NULL NULL NULL NULL 32 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot`.`a` AS `a`,substr(`test`.`ot`.`filler1`,1,10) AS `mid(filler1, 1,10)`,(length(`test`.`ot`.`filler1`) = length(`test`.`ot`.`filler2`)) AS `length(filler1)=length(filler2)` from `test`.`t2` `ot` semi join (`test`.`t1` `it`) where (``.`a` = `test`.`ot`.`a`) +select +a, mid(filler1, 1,10), length(filler1)=length(filler2) +from t2 ot where a in (select a from t1 it); +a mid(filler1, 1,10) length(filler1)=length(filler2) +0 filler1234 1 +1 filler1234 1 +10 filler1234 1 +11 filler1234 1 +12 filler1234 1 +13 filler1234 1 +14 filler1234 1 +15 filler1234 1 +16 filler1234 1 +17 filler1234 1 +18 filler1234 1 +19 duplicate 1 +19 filler1234 1 +2 filler1234 1 +3 duplicate 1 +3 filler1234 1 +4 filler1234 1 +5 filler1234 1 +6 filler1234 1 +7 filler1234 1 +8 filler1234 1 +9 filler1234 1 +insert into t1 select a+20, 'filler123456', 'filler123456' from t0; +insert into t1 select a+20, 'filler123456', 'filler123456' from t0; +explain select +a, mid(filler1, 1,10), length(filler1)=length(filler2) as z +from t1 ot where a in (select a from t2 it); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 52 10.00 Using where; Using join buffer (hash join) +2 MATERIALIZED it NULL ALL NULL NULL NULL NULL 22 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot`.`a` AS `a`,substr(`test`.`ot`.`filler1`,1,10) AS `mid(filler1, 1,10)`,(length(`test`.`ot`.`filler1`) = length(`test`.`ot`.`filler2`)) AS `z` from `test`.`t1` `ot` semi join (`test`.`t2` `it`) where (`test`.`ot`.`a` = ``.`a`) +select +a, mid(filler1, 1,10), length(filler1)=length(filler2) as z +from t1 ot where a in (select a from t2 it); +a mid(filler1, 1,10) z +0 filler1234 1 +1 filler1234 1 +10 filler1234 1 +11 filler1234 1 +12 filler1234 1 +13 filler1234 1 +14 filler1234 1 +15 filler1234 1 +16 filler1234 1 +17 filler1234 1 +18 duplicate 1 +18 filler1234 1 +19 filler1234 1 +2 duplicate 1 +2 filler1234 1 +3 filler1234 1 +4 filler1234 1 +5 filler1234 1 +6 filler1234 1 +7 filler1234 1 +8 filler1234 1 +9 filler1234 1 +explain select +a, mid(filler1, 1,10), length(filler1)=length(filler2) +from t2 ot where a in (select a from t1 it); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 22 100.00 Using where +1 SIMPLE NULL eq_ref 5 test.ot.a 1 100.00 NULL +2 MATERIALIZED it NULL ALL NULL NULL NULL NULL 52 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot`.`a` AS `a`,substr(`test`.`ot`.`filler1`,1,10) AS `mid(filler1, 1,10)`,(length(`test`.`ot`.`filler1`) = length(`test`.`ot`.`filler2`)) AS `length(filler1)=length(filler2)` from `test`.`t2` `ot` semi join (`test`.`t1` `it`) where (``.`a` = `test`.`ot`.`a`) +select +a, mid(filler1, 1,10), length(filler1)=length(filler2) +from t2 ot where a in (select a from t1 it); +a mid(filler1, 1,10) length(filler1)=length(filler2) +0 filler1234 1 +1 filler1234 1 +10 filler1234 1 +11 filler1234 1 +12 filler1234 1 +13 filler1234 1 +14 filler1234 1 +15 filler1234 1 +16 filler1234 1 +17 filler1234 1 +18 filler1234 1 +19 duplicate 1 +19 filler1234 1 +2 filler1234 1 +3 duplicate 1 +3 filler1234 1 +4 filler1234 1 +5 filler1234 1 +6 filler1234 1 +7 filler1234 1 +8 filler1234 1 +9 filler1234 1 +set @@join_buffer_size = @save_join_buffer_size; +drop table t1, t2; +create table t1 (a int, b int, key(a)); +create table t2 (a int, b int, key(a)); +create table t3 (a int, b int, key(a)); +insert into t1 select a,a from t0; +insert into t2 select a,a from t0; +insert into t3 select a,a from t0; +t2 and t3 must be use 'ref', not 'ALL': +explain select * +from t0 where a in +(select t2.a+t3.a from t1 left join (t2 join t3) on t2.a=t1.a and t3.a=t1.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 10 100.00 Using where +1 SIMPLE NULL eq_ref 9 test.t0.a 1 100.00 Using where +2 MATERIALIZED t1 NULL index a a 5 NULL 10 100.00 Using index +2 MATERIALIZED t2 NULL ref a a 5 test.t1.a 1 100.00 Using index +2 MATERIALIZED t3 NULL ref a a 5 test.t1.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a` from `test`.`t0` semi join (`test`.`t1` join `test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`a` = `test`.`t1`.`a`) and (`test`.`t3`.`a` = `test`.`t1`.`a`) and (`test`.`t0`.`a` = ``.`t2.a+t3.a`)) +drop table t0, t1,t2,t3; + +Test that neither MaterializeLookup strategy for semijoin, +nor subquery materialization is used when BLOBs are involved +(except when arguments of some functions). + +set @prefix_len = 6; +set @blob_len = 16; +set @suffix_len = @blob_len - @prefix_len; +create table t1_16 (a1 blob(16), a2 blob(16)); +create table t2_16 (b1 blob(16), b2 blob(16)); +create table t3_16 (c1 blob(16), c2 blob(16)); +insert into t1_16 values +(concat('1 - 00', repeat('x', @suffix_len)), concat('2 - 00', repeat('x', @suffix_len))); +insert into t1_16 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t1_16 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_16 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t2_16 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_16 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_16 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t3_16 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t3_16 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_16 values +(concat('1 - 04', repeat('x', @suffix_len)), concat('2 - 04', repeat('x', @suffix_len))); +explain select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select b1 from t2_16 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1_16 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +2 MATERIALIZED t2_16 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_16`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_16`.`a2`,7) AS `left(a2,7)` from `test`.`t1_16` semi join (`test`.`t2_16`) where ((`test`.`t1_16`.`a1` = ``.`b1`) and (`test`.`t2_16`.`b1` > '0')) +select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select b1 from t2_16 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_16 +where (a1,a2) in (select b1, b2 from t2_16 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1_16 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +2 MATERIALIZED t2_16 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_16`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_16`.`a2`,7) AS `left(a2,7)` from `test`.`t1_16` semi join (`test`.`t2_16`) where ((`test`.`t1_16`.`a2` = ``.`b2`) and (`test`.`t1_16`.`a1` = ``.`b1`) and (`test`.`t2_16`.`b1` > '0')) +select left(a1,7), left(a2,7) +from t1_16 +where (a1,a2) in (select b1, b2 from t2_16 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select substring(b1,1,16) from t2_16 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1_16 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +2 MATERIALIZED t2_16 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_16`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_16`.`a2`,7) AS `left(a2,7)` from `test`.`t1_16` semi join (`test`.`t2_16`) where ((`test`.`t2_16`.`b1` > '0') and (`test`.`t1_16`.`a1` = ``.`substring(b1,1,16)`)) +select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select substring(b1,1,16) from t2_16 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select group_concat(b1) from t2_16 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_16 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t2_16 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_16`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_16`.`a2`,7) AS `left(a2,7)` from `test`.`t1_16` where (`test`.`t1_16`.`a1`,(/* select#2 */ select group_concat(`test`.`t2_16`.`b1` separator ',') from `test`.`t2_16` group by `test`.`t2_16`.`b2` having ((`test`.`t1_16`.`a1`) = (group_concat(`test`.`t2_16`.`b1` separator ','))))) +select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select group_concat(b1) from t2_16 group by b2); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +set @@group_concat_max_len = 256; +explain select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select group_concat(b1) from t2_16 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_16 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 SUBQUERY t2_16 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_16`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_16`.`a2`,7) AS `left(a2,7)` from `test`.`t1_16` where (`test`.`t1_16`.`a1`,`test`.`t1_16`.`a1` in ( (/* select#2 */ select group_concat(`test`.`t2_16`.`b1` separator ',') from `test`.`t2_16` group by `test`.`t2_16`.`b2` having true ), (`test`.`t1_16`.`a1` in on where ((`test`.`t1_16`.`a1` = ``.`group_concat(b1)`))))) +select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select group_concat(b1) from t2_16 group by b2); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +create table t1 (a1 char(8), a2 char(8)) charset latin1; +create table t2 (b1 char(8), b2 char(8)) charset latin1; +create table t3 (c1 char(8), c2 char(8)) charset latin1; +insert into t1 values ('1 - 00', '2 - 00'); +insert into t1 values ('1 - 01', '2 - 01'); +insert into t1 values ('1 - 02', '2 - 02'); +insert into t2 values ('1 - 01', '2 - 01'); +insert into t2 values ('1 - 01', '2 - 01'); +insert into t2 values ('1 - 02', '2 - 02'); +insert into t2 values ('1 - 02', '2 - 02'); +insert into t2 values ('1 - 03', '2 - 03'); +insert into t3 values ('1 - 01', '2 - 01'); +insert into t3 values ('1 - 02', '2 - 02'); +insert into t3 values ('1 - 03', '2 - 03'); +insert into t3 values ('1 - 04', '2 - 04'); +insert into t3 values ('1 - 05', '2 - 05'); +insert into t3 values ('1 - 06', '2 - 06'); +insert into t3 values ('1 - 07', '2 - 07'); +insert into t3 values ('1 - 08', '2 - 08'); +explain +select * from t1 +where concat(a1,'x') IN +(select left(a1,8) from t1_16 +where (a1, a2) IN +(select t2_16.b1, t2_16.b2 from t2_16, t2 +where t2.b2 = substring(t2_16.b2,1,6) and +t2.b1 IN (select c1 from t3 where c2 > '0'))); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1_16 NULL ALL NULL NULL NULL NULL 3 100.00 Start temporary +1 SIMPLE t2_16 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 5 20.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` semi join (`test`.`t1_16` join `test`.`t2_16` join `test`.`t2` join `test`.`t3`) where ((`test`.`t2_16`.`b2` = `test`.`t1_16`.`a2`) and (`test`.`t2_16`.`b1` = `test`.`t1_16`.`a1`) and (`test`.`t3`.`c1` = `test`.`t2`.`b1`) and (`test`.`t2`.`b2` = substr(`test`.`t2_16`.`b2`,1,6)) and (`test`.`t3`.`c2` > '0') and (concat(`test`.`t1`.`a1`,'x') = left(`test`.`t1_16`.`a1`,8))) +drop table t1_16, t2_16, t3_16, t1, t2, t3; +set @blob_len = 512; +set @suffix_len = @blob_len - @prefix_len; +create table t1_512 (a1 blob(512), a2 blob(512)); +create table t2_512 (b1 blob(512), b2 blob(512)); +create table t3_512 (c1 blob(512), c2 blob(512)); +insert into t1_512 values +(concat('1 - 00', repeat('x', @suffix_len)), concat('2 - 00', repeat('x', @suffix_len))); +insert into t1_512 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t1_512 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_512 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t2_512 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_512 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_512 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t3_512 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t3_512 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_512 values +(concat('1 - 04', repeat('x', @suffix_len)), concat('2 - 04', repeat('x', @suffix_len))); +explain select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select b1 from t2_512 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1_512 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +2 MATERIALIZED t2_512 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_512`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_512`.`a2`,7) AS `left(a2,7)` from `test`.`t1_512` semi join (`test`.`t2_512`) where ((`test`.`t1_512`.`a1` = ``.`b1`) and (`test`.`t2_512`.`b1` > '0')) +select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select b1 from t2_512 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_512 +where (a1,a2) in (select b1, b2 from t2_512 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1_512 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +2 MATERIALIZED t2_512 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_512`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_512`.`a2`,7) AS `left(a2,7)` from `test`.`t1_512` semi join (`test`.`t2_512`) where ((`test`.`t1_512`.`a2` = ``.`b2`) and (`test`.`t1_512`.`a1` = ``.`b1`) and (`test`.`t2_512`.`b1` > '0')) +select left(a1,7), left(a2,7) +from t1_512 +where (a1,a2) in (select b1, b2 from t2_512 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select substring(b1,1,512) from t2_512 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1_512 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +2 MATERIALIZED t2_512 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_512`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_512`.`a2`,7) AS `left(a2,7)` from `test`.`t1_512` semi join (`test`.`t2_512`) where ((`test`.`t2_512`.`b1` > '0') and (`test`.`t1_512`.`a1` = ``.`substring(b1,1,512)`)) +select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select substring(b1,1,512) from t2_512 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select group_concat(b1) from t2_512 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_512 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 SUBQUERY t2_512 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_512`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_512`.`a2`,7) AS `left(a2,7)` from `test`.`t1_512` where (`test`.`t1_512`.`a1`,`test`.`t1_512`.`a1` in ( (/* select#2 */ select group_concat(`test`.`t2_512`.`b1` separator ',') from `test`.`t2_512` group by `test`.`t2_512`.`b2` having true ), (`test`.`t1_512`.`a1` in on where ((`test`.`t1_512`.`a1` = ``.`group_concat(b1)`))))) +select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select group_concat(b1) from t2_512 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +set @@group_concat_max_len = 256; +explain select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select group_concat(b1) from t2_512 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_512 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 SUBQUERY t2_512 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_512`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_512`.`a2`,7) AS `left(a2,7)` from `test`.`t1_512` where (`test`.`t1_512`.`a1`,`test`.`t1_512`.`a1` in ( (/* select#2 */ select group_concat(`test`.`t2_512`.`b1` separator ',') from `test`.`t2_512` group by `test`.`t2_512`.`b2` having true ), (`test`.`t1_512`.`a1` in on where ((`test`.`t1_512`.`a1` = ``.`group_concat(b1)`))))) +select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select group_concat(b1) from t2_512 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +drop table t1_512, t2_512, t3_512; +set @blob_len = 513; +set @suffix_len = @blob_len - @prefix_len; +create table t1_513 (a1 blob(513), a2 blob(513)); +create table t2_513 (b1 blob(513), b2 blob(513)); +create table t3_513 (c1 blob(513), c2 blob(513)); +insert into t1_513 values +(concat('1 - 00', repeat('x', @suffix_len)), concat('2 - 00', repeat('x', @suffix_len))); +insert into t1_513 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t1_513 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_513 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t2_513 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_513 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_513 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t3_513 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t3_513 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_513 values +(concat('1 - 04', repeat('x', @suffix_len)), concat('2 - 04', repeat('x', @suffix_len))); +explain select left(a1,7), left(a2,7) +from t1_513 +where a1 in (select b1 from t2_513 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1_513 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +2 MATERIALIZED t2_513 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_513`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_513`.`a2`,7) AS `left(a2,7)` from `test`.`t1_513` semi join (`test`.`t2_513`) where ((`test`.`t1_513`.`a1` = ``.`b1`) and (`test`.`t2_513`.`b1` > '0')) +select left(a1,7), left(a2,7) +from t1_513 +where a1 in (select b1 from t2_513 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_513 +where (a1,a2) in (select b1, b2 from t2_513 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1_513 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +2 MATERIALIZED t2_513 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_513`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_513`.`a2`,7) AS `left(a2,7)` from `test`.`t1_513` semi join (`test`.`t2_513`) where ((`test`.`t1_513`.`a2` = ``.`b2`) and (`test`.`t1_513`.`a1` = ``.`b1`) and (`test`.`t2_513`.`b1` > '0')) +select left(a1,7), left(a2,7) +from t1_513 +where (a1,a2) in (select b1, b2 from t2_513 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_513 +where a1 in (select substring(b1,1,513) from t2_513 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1_513 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +2 MATERIALIZED t2_513 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_513`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_513`.`a2`,7) AS `left(a2,7)` from `test`.`t1_513` semi join (`test`.`t2_513`) where ((`test`.`t2_513`.`b1` > '0') and (`test`.`t1_513`.`a1` = ``.`substring(b1,1,513)`)) +select left(a1,7), left(a2,7) +from t1_513 +where a1 in (select substring(b1,1,513) from t2_513 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_513 +where a1 in (select group_concat(b1) from t2_513 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_513 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 SUBQUERY t2_513 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_513`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_513`.`a2`,7) AS `left(a2,7)` from `test`.`t1_513` where (`test`.`t1_513`.`a1`,`test`.`t1_513`.`a1` in ( (/* select#2 */ select group_concat(`test`.`t2_513`.`b1` separator ',') from `test`.`t2_513` group by `test`.`t2_513`.`b2` having true ), (`test`.`t1_513`.`a1` in on where ((`test`.`t1_513`.`a1` = ``.`group_concat(b1)`))))) +select left(a1,7), left(a2,7) +from t1_513 +where a1 in (select group_concat(b1) from t2_513 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +drop table t1_513, t2_513, t3_513; +set @blob_len = 1024; +set @suffix_len = @blob_len - @prefix_len; +create table t1_1024 (a1 blob(1024), a2 blob(1024)); +create table t2_1024 (b1 blob(1024), b2 blob(1024)); +create table t3_1024 (c1 blob(1024), c2 blob(1024)); +insert into t1_1024 values +(concat('1 - 00', repeat('x', @suffix_len)), concat('2 - 00', repeat('x', @suffix_len))); +insert into t1_1024 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t1_1024 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_1024 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t2_1024 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_1024 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_1024 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t3_1024 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t3_1024 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_1024 values +(concat('1 - 04', repeat('x', @suffix_len)), concat('2 - 04', repeat('x', @suffix_len))); +explain select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select b1 from t2_1024 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1_1024 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +2 MATERIALIZED t2_1024 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1024`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1024`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1024` semi join (`test`.`t2_1024`) where ((`test`.`t1_1024`.`a1` = ``.`b1`) and (`test`.`t2_1024`.`b1` > '0')) +select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select b1 from t2_1024 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_1024 +where (a1,a2) in (select b1, b2 from t2_1024 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1_1024 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +2 MATERIALIZED t2_1024 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1024`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1024`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1024` semi join (`test`.`t2_1024`) where ((`test`.`t1_1024`.`a2` = ``.`b2`) and (`test`.`t1_1024`.`a1` = ``.`b1`) and (`test`.`t2_1024`.`b1` > '0')) +select left(a1,7), left(a2,7) +from t1_1024 +where (a1,a2) in (select b1, b2 from t2_1024 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select substring(b1,1,1024) from t2_1024 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1_1024 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +2 MATERIALIZED t2_1024 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1024`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1024`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1024` semi join (`test`.`t2_1024`) where ((`test`.`t2_1024`.`b1` > '0') and (`test`.`t1_1024`.`a1` = ``.`substring(b1,1,1024)`)) +select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select substring(b1,1,1024) from t2_1024 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select group_concat(b1) from t2_1024 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_1024 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 SUBQUERY t2_1024 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1024`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1024`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1024` where (`test`.`t1_1024`.`a1`,`test`.`t1_1024`.`a1` in ( (/* select#2 */ select group_concat(`test`.`t2_1024`.`b1` separator ',') from `test`.`t2_1024` group by `test`.`t2_1024`.`b2` having true ), (`test`.`t1_1024`.`a1` in on where ((`test`.`t1_1024`.`a1` = ``.`group_concat(b1)`))))) +select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select group_concat(b1) from t2_1024 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +set @@group_concat_max_len = 256; +explain select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select group_concat(b1) from t2_1024 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_1024 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 SUBQUERY t2_1024 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1024`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1024`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1024` where (`test`.`t1_1024`.`a1`,`test`.`t1_1024`.`a1` in ( (/* select#2 */ select group_concat(`test`.`t2_1024`.`b1` separator ',') from `test`.`t2_1024` group by `test`.`t2_1024`.`b2` having true ), (`test`.`t1_1024`.`a1` in on where ((`test`.`t1_1024`.`a1` = ``.`group_concat(b1)`))))) +select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select group_concat(b1) from t2_1024 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +drop table t1_1024, t2_1024, t3_1024; +set @blob_len = 1025; +set @suffix_len = @blob_len - @prefix_len; +create table t1_1025 (a1 blob(1025), a2 blob(1025)); +create table t2_1025 (b1 blob(1025), b2 blob(1025)); +create table t3_1025 (c1 blob(1025), c2 blob(1025)); +insert into t1_1025 values +(concat('1 - 00', repeat('x', @suffix_len)), concat('2 - 00', repeat('x', @suffix_len))); +insert into t1_1025 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t1_1025 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_1025 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t2_1025 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_1025 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_1025 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t3_1025 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t3_1025 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_1025 values +(concat('1 - 04', repeat('x', @suffix_len)), concat('2 - 04', repeat('x', @suffix_len))); +explain select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select b1 from t2_1025 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1_1025 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +2 MATERIALIZED t2_1025 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1025`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1025`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1025` semi join (`test`.`t2_1025`) where ((`test`.`t1_1025`.`a1` = ``.`b1`) and (`test`.`t2_1025`.`b1` > '0')) +select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select b1 from t2_1025 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_1025 +where (a1,a2) in (select b1, b2 from t2_1025 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1_1025 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +2 MATERIALIZED t2_1025 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1025`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1025`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1025` semi join (`test`.`t2_1025`) where ((`test`.`t1_1025`.`a2` = ``.`b2`) and (`test`.`t1_1025`.`a1` = ``.`b1`) and (`test`.`t2_1025`.`b1` > '0')) +select left(a1,7), left(a2,7) +from t1_1025 +where (a1,a2) in (select b1, b2 from t2_1025 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select substring(b1,1,1025) from t2_1025 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1_1025 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +2 MATERIALIZED t2_1025 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1025`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1025`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1025` semi join (`test`.`t2_1025`) where ((`test`.`t2_1025`.`b1` > '0') and (`test`.`t1_1025`.`a1` = ``.`substring(b1,1,1025)`)) +select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select substring(b1,1,1025) from t2_1025 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select group_concat(b1) from t2_1025 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_1025 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 SUBQUERY t2_1025 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1025`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1025`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1025` where (`test`.`t1_1025`.`a1`,`test`.`t1_1025`.`a1` in ( (/* select#2 */ select group_concat(`test`.`t2_1025`.`b1` separator ',') from `test`.`t2_1025` group by `test`.`t2_1025`.`b2` having true ), (`test`.`t1_1025`.`a1` in on where ((`test`.`t1_1025`.`a1` = ``.`group_concat(b1)`))))) +select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select group_concat(b1) from t2_1025 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +set @@group_concat_max_len = 256; +explain select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select group_concat(b1) from t2_1025 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_1025 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 SUBQUERY t2_1025 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1025`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1025`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1025` where (`test`.`t1_1025`.`a1`,`test`.`t1_1025`.`a1` in ( (/* select#2 */ select group_concat(`test`.`t2_1025`.`b1` separator ',') from `test`.`t2_1025` group by `test`.`t2_1025`.`b2` having true ), (`test`.`t1_1025`.`a1` in on where ((`test`.`t1_1025`.`a1` = ``.`group_concat(b1)`))))) +select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select group_concat(b1) from t2_1025 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +drop table t1_1025, t2_1025, t3_1025; +# +# WL#5561: Enable semi join transformation with outer join. +# +CREATE TABLE ot1(a INT); +CREATE TABLE ot2(a INT); +CREATE TABLE ot3(a INT); +CREATE TABLE it1(a INT); +CREATE TABLE it2(a INT); +CREATE TABLE it3(a INT); +INSERT INTO ot1 VALUES(0),(1),(2),(3),(4),(5),(6),(7); +INSERT INTO ot2 VALUES(0),(2),(4),(6); +INSERT INTO ot3 VALUES(0),(3),(6); +INSERT INTO it1 VALUES(0),(1),(2),(3),(4),(5),(6),(7); +INSERT INTO it2 VALUES(0),(2),(4),(6); +INSERT INTO it3 VALUES(0),(3),(6); +# Test cases, Subquery Pattern 1 +# Example SQ1.1: +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE ot1.a IN (SELECT a FROM it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; Using join buffer (hash join) +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (hash join) +2 MATERIALIZED it3 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` left join `test`.`ot2` on((`test`.`ot2`.`a` = `test`.`ot1`.`a`)) semi join (`test`.`it3`) where (`test`.`ot1`.`a` = ``.`a`) +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE ot1.a IN (SELECT a FROM it3); +a a +0 0 +3 NULL +6 6 +# Example SQ1.2: +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE COALESCE(ot2.a,0) IN (SELECT a FROM it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 Using join buffer (hash join) +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (hash join) +2 MATERIALIZED it3 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` left join `test`.`ot2` on((`test`.`ot2`.`a` = `test`.`ot1`.`a`)) semi join (`test`.`it3`) where (coalesce(`test`.`ot2`.`a`,0) = ``.`a`) +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE COALESCE(ot2.a,0) IN (SELECT a FROM it3); +a a +0 0 +1 NULL +3 NULL +5 NULL +6 6 +7 NULL +# Example SQ1.3: +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE (ot1.a,ot2.a) IN (SELECT a, a FROM it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using where +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; Using join buffer (hash join) +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; Using join buffer (hash join) +2 MATERIALIZED it3 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` join `test`.`ot2` semi join (`test`.`it3`) where ((``.`a` = ``.`a`) and (`test`.`ot2`.`a` = ``.`a`) and (`test`.`ot1`.`a` = ``.`a`)) +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE (ot1.a,ot2.a) IN (SELECT a, a FROM it3); +a a +0 0 +6 6 +# More test cases +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 +WHERE ot1.a IN (SELECT a FROM it3); +a a +0 0 +3 NULL +6 6 +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 +WHERE ot1.a IN (SELECT a+0 FROM it3); +a a +0 0 +3 NULL +6 6 +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 +WHERE COALESCE(ot2.a,0) IN (SELECT a FROM it3); +a a +0 0 +1 NULL +3 NULL +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE COALESCE(ot2.a,0) IN (SELECT a+0 FROM it3); +a a +0 0 +1 NULL +3 NULL +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 +WHERE (ot1.a,ot2.a) IN (SELECT a, a FROM it3); +a a +0 0 +6 6 +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +LEFT JOIN ot3 ON ot1.a=ot3.a +WHERE ot1.a IN (SELECT a FROM it3); +a a a +0 0 0 +3 NULL 3 +6 6 6 +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +LEFT JOIN ot3 ON ot1.a=ot3.a +WHERE COALESCE(ot2.a,0) IN (SELECT a FROM it3); +a a a +0 0 0 +1 NULL NULL +3 NULL 3 +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +LEFT JOIN ot3 ON ot1.a=ot3.a +WHERE COALESCE(ot3.a,0) IN (SELECT a FROM it3); +a a a +0 0 0 +1 NULL NULL +2 2 NULL +3 NULL 3 +4 4 NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +LEFT JOIN ot3 ON ot2.a=ot3.a +WHERE ot1.a IN (SELECT a FROM it3); +a a a +0 0 0 +3 NULL NULL +6 6 6 +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +LEFT JOIN ot3 ON ot2.a=ot3.a +WHERE COALESCE(ot2.a,0) IN (SELECT a FROM it3); +a a a +0 0 0 +1 NULL NULL +3 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +LEFT JOIN ot3 ON ot2.a=ot3.a +WHERE COALESCE(ot3.a,0) IN (SELECT a FROM it3); +a a a +0 0 0 +1 NULL NULL +2 2 NULL +3 NULL NULL +4 4 NULL +5 NULL NULL +6 6 6 +7 NULL NULL +# Test cases, Subquery Pattern 2 +# Example SQ2.1: +explain SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; Using join buffer (hash join) +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; Using join buffer (hash join) +2 MATERIALIZED it3 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` join `test`.`ot2` semi join (`test`.`it3`) where ((`test`.`ot1`.`a` = ``.`a`) and (`test`.`ot2`.`a` = ``.`a`)) +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3); +a a +0 0 +6 6 +# Example SQ2.2: +explain SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it2) +AND ot2.a IN (SELECT a FROM it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using where +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; Using join buffer (hash join) +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; Using join buffer (hash join) +1 SIMPLE NULL eq_ref 5 .a 1 100.00 NULL +3 MATERIALIZED it3 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 MATERIALIZED it2 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` join `test`.`ot2` semi join (`test`.`it2`) semi join (`test`.`it3`) where ((`test`.`ot1`.`a` = ``.`a`) and (`test`.`ot2`.`a` = ``.`a`) and (``.`a` = ``.`a`)) +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it2) +AND ot2.a IN (SELECT a FROM it3); +a a +0 0 +6 6 +# More test cases +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it3); +a a +0 0 +6 6 +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it3); +a a +0 0 +6 6 +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a+0 AND ot2.a IN (SELECT a FROM it3); +a a +0 0 +6 6 +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot2.a IN (SELECT a+0 FROM it3); +a a +0 0 +6 6 +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it2) +AND ot2.a IN (SELECT a+0 FROM it3); +a a +0 0 +6 6 +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3) +JOIN ot3 ON ot2.a=ot3.a AND ot3.a IN (SELECT a FROM it3); +a a a +0 0 0 +6 6 6 +# Test cases, Subquery Pattern 3 +# Example SQ3.1: +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +1 SIMPLE NULL eq_ref 5 test.ot1.a 1 100.00 NULL +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +2 MATERIALIZED it3 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` semi join (`test`.`it3`)) on(((``.`a` = `test`.`ot1`.`a`) and (`test`.`ot2`.`a` = `test`.`ot1`.`a`))) where true +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3); +a a +0 0 +1 NULL +2 NULL +3 NULL +4 NULL +5 NULL +6 6 +7 NULL +# Example SQ3.2: +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot2.a IN (SELECT a FROM it2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +1 SIMPLE NULL eq_ref 5 test.ot2.a 1 100.00 Using where +2 MATERIALIZED it2 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` semi join (`test`.`it2`)) on(((`test`.`ot2`.`a` = `test`.`ot1`.`a`) and (``.`a` = `test`.`ot1`.`a`))) where true +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot2.a IN (SELECT a FROM it2); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +# Example SQ3.3 +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1) +AND ot2.a IN (SELECT a FROM it2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +1 SIMPLE NULL eq_ref 5 test.ot1.a 1 100.00 NULL +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +1 SIMPLE NULL eq_ref 5 test.ot2.a 1 100.00 Using where +2 MATERIALIZED it1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +3 MATERIALIZED it2 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` semi join (`test`.`it1`) semi join (`test`.`it2`)) on(((``.`a` = `test`.`ot1`.`a`) and (`test`.`ot2`.`a` = `test`.`ot1`.`a`) and (``.`a` = `test`.`ot1`.`a`))) where true +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1) +AND ot2.a IN (SELECT a FROM it2); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +# Example SQ3.4 +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND +(ot1.a, ot2.a) IN (SELECT it1.a, it2.a +FROM it1 JOIN it2 ON it1.a=it2.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +1 SIMPLE NULL eq_ref 10 test.ot1.a,test.ot2.a 1 100.00 Using where +2 MATERIALIZED it2 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +2 MATERIALIZED it1 NULL ALL NULL NULL NULL NULL 8 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` semi join (`test`.`it1` join `test`.`it2`)) on(((`test`.`ot2`.`a` = `test`.`ot1`.`a`) and (``.`a` = `test`.`ot1`.`a`) and (``.`a` = `test`.`ot1`.`a`) and (`test`.`it1`.`a` = `test`.`it2`.`a`))) where true +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND +(ot1.a, ot2.a) IN (SELECT it1.a, it2.a +FROM it1 JOIN it2 ON it1.a=it2.a); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +# More test cases +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it3); +a a +0 0 +1 NULL +2 NULL +3 NULL +4 NULL +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it3); +a a +0 0 +1 NULL +2 NULL +3 NULL +4 NULL +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 AND ot2.a IN (SELECT a FROM it2); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot2.a IN (SELECT a+0 FROM it2); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a+0 FROM it1) +AND ot2.a IN (SELECT a+0 FROM it2); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 AND +(ot1.a, ot2.a) IN (SELECT it1.a+0, it2.a+0 +FROM it1 JOIN it2 ON it1.a=it2.a); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +EXPLAIN FORMAT=tree SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3) +LEFT JOIN ot3 ON ot2.a=ot3.a AND ot3.a IN (SELECT a FROM it3); +EXPLAIN +-> Nested loop left join (cost=41.01 rows=288) + -> Nested loop left join (cost=11.70 rows=96) + -> Table scan on ot1 (cost=1.30 rows=8) + -> Nested loop inner join (cost=2.80 rows=12) + -> Single-row index lookup on using (a=ot1.a) + -> Materialize with deduplication (cost=1.10..1.10 rows=3) + -> Filter: (it3.a is not null) (cost=0.80 rows=3) + -> Table scan on it3 (cost=0.80 rows=3) + -> Filter: (ot2.a = ot1.a) (cost=0.11 rows=4) + -> Table scan on ot2 (cost=0.11 rows=4) + -> Nested loop inner join (cost=9.93 rows=3) + -> Filter: (ot3.a = ot2.a) (cost=0.03 rows=3) + -> Table scan on ot3 (cost=0.03 rows=3) + -> Filter: (``.a = ot2.a) (cost=3.23..3.23 rows=1) + -> Single-row index lookup on using (a=ot3.a) + -> Materialize with deduplication (cost=1.10..1.10 rows=3) + -> Filter: (it3.a is not null) (cost=0.80 rows=3) + -> Table scan on it3 (cost=0.80 rows=3) + +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3) +LEFT JOIN ot3 ON ot2.a=ot3.a AND ot3.a IN (SELECT a FROM it3); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it3) +LEFT JOIN ot3 ON ot2.a=ot3.a+0 AND ot3.a IN (SELECT a FROM it3); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +# Test cases, Subquery Pattern 4 +# Example SQ4.1: +explain SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +1 SIMPLE NULL eq_ref 5 test.ot1.a 1 100.00 NULL +1 SIMPLE ot3 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +2 MATERIALIZED it1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a`,`test`.`ot3`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` join `test`.`ot3` semi join (`test`.`it1`)) on(((``.`a` = `test`.`ot1`.`a`) and (`test`.`ot3`.`a` = `test`.`ot1`.`a`) and (`test`.`ot2`.`a` = `test`.`ot1`.`a`))) where true +SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +# Example SQ4.2: +explain SELECT * +FROM ot1 +JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot3 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; Using join buffer (hash join) +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; Using join buffer (hash join) +1 SIMPLE NULL eq_ref 5 test.ot3.a 1 100.00 NULL +2 MATERIALIZED it1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a`,`test`.`ot3`.`a` AS `a` from `test`.`ot1` join `test`.`ot2` join `test`.`ot3` semi join (`test`.`it1`) where ((`test`.`ot2`.`a` = `test`.`ot3`.`a`) and (`test`.`ot1`.`a` = `test`.`ot3`.`a`) and (``.`a` = `test`.`ot3`.`a`)) +SELECT * +FROM ot1 +JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +6 6 6 +# Example SQ4.3: +explain SELECT * +FROM ot1 +JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; Using join buffer (hash join) +1 SIMPLE NULL eq_ref 5 test.ot2.a 1 100.00 NULL +1 SIMPLE ot3 NULL ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (hash join) +2 MATERIALIZED it1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a`,`test`.`ot3`.`a` AS `a` from `test`.`ot1` join `test`.`ot2` left join `test`.`ot3` on((`test`.`ot3`.`a` = `test`.`ot2`.`a`)) semi join (`test`.`it1`) where ((`test`.`ot1`.`a` = `test`.`ot2`.`a`) and (``.`a` = `test`.`ot2`.`a`)) +SELECT * +FROM ot1 +JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +2 2 NULL +4 4 NULL +6 6 6 +# Example SQ4.4: +explain SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +1 SIMPLE NULL eq_ref 5 test.ot1.a 1 100.00 NULL +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +1 SIMPLE ot3 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 MATERIALIZED it1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a`,`test`.`ot3`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` left join `test`.`ot3` on((`test`.`ot3`.`a` = `test`.`ot1`.`a`)) semi join (`test`.`it1`)) on(((``.`a` = `test`.`ot1`.`a`) and (`test`.`ot2`.`a` = `test`.`ot1`.`a`))) where true +SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +1 NULL NULL +2 2 NULL +3 NULL NULL +4 4 NULL +5 NULL NULL +6 6 6 +7 NULL NULL +# More test cases +SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a+0) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it1); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 +JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a+0) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +6 6 6 +SELECT * +FROM ot1 +JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +6 6 6 +SELECT * +FROM ot1 +JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it1); +a a a +0 0 0 +6 6 6 +SELECT * +FROM ot1 +JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a+0) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +2 2 NULL +4 4 NULL +6 6 6 +SELECT * +FROM ot1 +JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +2 2 NULL +4 4 NULL +6 6 6 +SELECT * +FROM ot1 +JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it1); +a a a +0 0 0 +2 2 NULL +4 4 NULL +6 6 6 +SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a+0) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +1 NULL NULL +2 2 NULL +3 NULL NULL +4 4 NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +1 NULL NULL +2 2 NULL +3 NULL NULL +4 4 NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it1); +a a a +0 0 0 +1 NULL NULL +2 2 NULL +3 NULL NULL +4 4 NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1) +LEFT JOIN +ot1 AS ot4 +ON ot2.a=ot4.a; +a a a a +0 0 0 0 +1 NULL NULL NULL +2 2 NULL 2 +3 NULL NULL NULL +4 4 NULL 4 +5 NULL NULL NULL +6 6 6 6 +7 NULL NULL NULL +SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a +LEFT JOIN ot1 AS ot4 ON ot3.a=ot4.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a a +0 0 0 0 +1 NULL NULL NULL +2 2 NULL NULL +3 NULL NULL NULL +4 4 NULL NULL +5 NULL NULL NULL +6 6 6 6 +7 NULL NULL NULL +DROP TABLE ot1,ot2,ot3,it1,it2,it3; +CREATE TABLE t ( +a INTEGER DEFAULT NULL +) ENGINE=InnoDB; +INSERT INTO t VALUES (1); +CREATE TABLE t2 ( +a INTEGER DEFAULT NULL +) ENGINE=InnoDB; +INSERT INTO t2 VALUES (1),(1); +CREATE TABLE t4 ( +a INTEGER DEFAULT NULL +) ENGINE=InnoDB; +INSERT INTO t4 VALUES (1),(1); +CREATE TABLE v ( +a INTEGER DEFAULT NULL +) ENGINE=InnoDB; +INSERT INTO v VALUES (1),(1); +explain SELECT * +FROM t AS t1 +LEFT JOIN +(t2 +LEFT JOIN t AS t3 +ON t3.a IN (SELECT a FROM t AS it) +JOIN t4 +ON t4.a=100 +) +ON TRUE +WHERE t1.a IN (SELECT * FROM v AS it2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE NULL eq_ref 5 test.t1.a 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL eq_ref 5 test.t3.a 1 100.00 NULL +1 SIMPLE t4 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +3 MATERIALIZED it2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED it NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t4`.`a` AS `a` from `test`.`t` `t1` left join (`test`.`t2` left join (`test`.`t` `t3` semi join (`test`.`t` `it`)) on(((``.`a` = `test`.`t3`.`a`))) join `test`.`t4`) on(((`test`.`t4`.`a` = 100))) semi join (`test`.`v` `it2`) where (``.`a` = `test`.`t1`.`a`) +SELECT * +FROM t AS t1 +LEFT JOIN +(t2 +LEFT JOIN t AS t3 +ON t3.a IN (SELECT a FROM t AS it) +JOIN t4 +ON t4.a=100 +) +ON TRUE +WHERE t1.a IN (SELECT * FROM v AS it2); +a a a a +1 NULL NULL NULL +DROP TABLE t,t2,t4,v; +# End of WL#5561 +# +# Bug#48868: Left outer join in subquery causes segmentation fault in +# make_join_select. +# +CREATE TABLE t1 (i INTEGER); +INSERT INTO t1 VALUES (1); +INSERT INTO t1 VALUES (2); +CREATE TABLE t2 (i INTEGER); +INSERT INTO t2 VALUES(1); +CREATE TABLE t3 (i INTEGER); +INSERT INTO t3 VALUES (1); +INSERT INTO t3 VALUES (2); +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t2.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +1 +DROP TABLE t1, t2, t3; + +Bug#37899: Wrongly checked optimization prerequisite caused failed +assertion. + +CREATE TABLE t1 ( +`pk` int(11), +`varchar_nokey` varchar(5) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES +(1,'qk'),(2,'j'),(3,'aew'); +SELECT * +FROM t1 +WHERE varchar_nokey IN ( +SELECT +varchar_nokey +FROM +t1 +) XOR pk = 30; +pk varchar_nokey +1 qk +2 j +3 aew +drop table t1; +# +# BUG#41842: Semi-join materialization strategy crashes when the upper query has HAVING +# +CREATE TABLE t1 ( +pk int(11) NOT NULL AUTO_INCREMENT, +int_nokey int(11) NOT NULL, +time_key time NOT NULL, +datetime_key datetime NOT NULL, +datetime_nokey datetime NOT NULL, +varchar_key varchar(1) NOT NULL, +varchar_nokey varchar(1) NOT NULL, +PRIMARY KEY (pk), +KEY time_key (time_key), +KEY datetime_key (datetime_key), +KEY varchar_key (varchar_key) +) ENGINE=MyISaM; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES +(1,0, '00:16:10','2008-09-03 14:25:40','2008-09-03 14:25:40','h','h'), +(2,7, '00:00:00','2001-01-13 00:00:00','2001-01-13 00:00:00','',''), +(3,0, '00:00:00','0000-00-00 00:00:00','0000-00-00 00:00:00','x','x'), +(4,2, '16:29:24','2000-10-16 01:39:08','2000-10-16 01:39:08','w','w'), +(5,1, '09:23:32','0000-00-00 00:00:00','0000-00-00 00:00:00','p','p'), +(6,3, '00:00:00','2007-12-02 00:00:00','2007-12-02 00:00:00','o','o'), +(7,3, '00:00:00','2008-09-11 00:00:00','2008-09-11 00:00:00','',''), +(8,0, '13:59:04','0000-00-00 00:00:00','0000-00-00 00:00:00','s','s'), +(9,7, '09:01:06','0000-00-00 00:00:00','0000-00-00 00:00:00','d','d'), +(10,5,'00:00:00','0000-00-00 00:00:00','0000-00-00 00:00:00','n','n'), +(11,0,'21:06:46','0000-00-00 00:00:00','0000-00-00 00:00:00','o','o'), +(12,2,'00:00:00','0000-00-00 00:00:00','0000-00-00 00:00:00','',''), +(13,6,'14:45:34','2003-07-28 02:34:08','2003-07-28 02:34:08','w','w'), +(14,1,'15:04:12','0000-00-00 00:00:00','0000-00-00 00:00:00','o','o'), +(15,0,'00:00:00','0000-00-00 00:00:00','0000-00-00 00:00:00','x','x'), +(16,0,'15:55:23','2004-03-17 00:32:27','2004-03-17 00:32:27','p','p'), +(17,1,'16:30:00','2004-12-27 19:20:00','2004-12-27 19:20:00','d','d'), +(18,0,'00:00:00','0000-00-00 00:00:00','0000-00-00 00:00:00','h','h'), +(19,0,'14:13:26','2008-11-09 05:53:48','2008-11-09 05:53:48','o','o'), +(20,0,'00:00:00','2009-10-11 06:58:04','2009-10-11 06:58:04','k','k'); +Warnings: +Warning 1264 Out of range value for column 'datetime_key' at row 3 +Warning 1264 Out of range value for column 'datetime_nokey' at row 3 +Warning 1264 Out of range value for column 'datetime_key' at row 5 +Warning 1264 Out of range value for column 'datetime_nokey' at row 5 +Warning 1264 Out of range value for column 'datetime_key' at row 8 +Warning 1264 Out of range value for column 'datetime_nokey' at row 8 +Warning 1264 Out of range value for column 'datetime_key' at row 9 +Warning 1264 Out of range value for column 'datetime_nokey' at row 9 +Warning 1264 Out of range value for column 'datetime_key' at row 10 +Warning 1264 Out of range value for column 'datetime_nokey' at row 10 +Warning 1264 Out of range value for column 'datetime_key' at row 11 +Warning 1264 Out of range value for column 'datetime_nokey' at row 11 +Warning 1264 Out of range value for column 'datetime_key' at row 12 +Warning 1264 Out of range value for column 'datetime_nokey' at row 12 +Warning 1264 Out of range value for column 'datetime_key' at row 14 +Warning 1264 Out of range value for column 'datetime_nokey' at row 14 +Warning 1264 Out of range value for column 'datetime_key' at row 15 +Warning 1264 Out of range value for column 'datetime_nokey' at row 15 +Warning 1264 Out of range value for column 'datetime_key' at row 18 +Warning 1264 Out of range value for column 'datetime_nokey' at row 18 +CREATE TABLE t2 ( +pk int(11) NOT NULL AUTO_INCREMENT, +int_nokey int(11) NOT NULL, +time_key time NOT NULL, +datetime_key datetime NOT NULL, +datetime_nokey datetime NOT NULL, +varchar_key varchar(1) NOT NULL, +varchar_nokey varchar(1) NOT NULL, +PRIMARY KEY (pk), +KEY time_key (time_key), +KEY datetime_key (datetime_key), +KEY varchar_key (varchar_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT IGNORE INTO t2 VALUES +(10,0,'19:39:13','0000-00-00 00:00:00','0000-00-00 00:00:00','g','g'), +(11,8,'03:43:53','0000-00-00 00:00:00','0000-00-00 00:00:00','b','b'); +Warnings: +Warning 1264 Out of range value for column 'datetime_key' at row 1 +Warning 1264 Out of range value for column 'datetime_nokey' at row 1 +Warning 1264 Out of range value for column 'datetime_key' at row 2 +Warning 1264 Out of range value for column 'datetime_nokey' at row 2 +SELECT OUTR.datetime_nokey AS X FROM t1 AS OUTR +WHERE +OUTR.varchar_nokey IN (SELECT +INNR . varchar_nokey AS Y +FROM t2 AS INNR +WHERE +INNR . datetime_key >= INNR . time_key OR +INNR . pk = INNR . int_nokey +) +AND OUTR . varchar_nokey <= 'w' +HAVING X > '2012-12-12'; +X +drop table t1, t2; + +Bug#46797 "Crash in fix_semijoin_strategies_for_picked_join_order +with semijoin=on" + +CREATE TABLE t1 ( +varchar_key varchar(1) DEFAULT NULL, +KEY varchar_key (varchar_key) +); +CREATE TABLE t2 ( +varchar_key varchar(1) DEFAULT NULL, +KEY varchar_key (varchar_key) +); +INSERT INTO t2 VALUES +(NULL),(NULL),(NULL),(NULL),('a'),('a'),('a'),('b'),('b'),('b'),('b'),('c'), +('c'),('c'),('c'),('c'),('c'),('c'),('d'),('d'),('d'),('d'),('d'),('d'),('e'), +('e'),('e'),('e'),('e'),('e'),('f'),('f'),('f'),('g'),('g'),('h'),('h'),('h'), +('h'),('i'),('j'),('j'),('j'),('k'),('k'),('l'),('l'),('m'),('m'),('m'),('m'), +('n'),('n'),('n'),('o'),('o'),('o'),('p'),('p'),('p'),('q'),('q'),('q'),('r'), +('r'),('r'),('r'),('s'),('s'),('s'),('s'),('t'),('t'),('t'),('t'),('u'),('u'), +('u'),('u'),('v'),('v'),('v'),('v'),('w'),('w'),('w'),('w'),('w'),('w'),('x'), +('x'),('x'),('y'),('y'),('y'),('y'),('z'),('z'),('z'),('z'); +CREATE TABLE t3 ( +varchar_key varchar(1) DEFAULT NULL, +KEY varchar_key (varchar_key) +) ENGINE=MyISAM DEFAULT CHARSET=latin1; +INSERT INTO t3 VALUES +(NULL),('c'),('d'),('e'),('f'),('h'),('j'),('k'),('k'),('m'),('m'),('m'), +('n'),('o'),('r'),('t'),('t'),('u'),('w'),('y'); +SELECT varchar_key FROM t3 +WHERE (SELECT varchar_key FROM t3 +WHERE (varchar_key,varchar_key) +IN (SELECT t1.varchar_key, t2 .varchar_key +FROM t1 RIGHT JOIN t2 ON t1.varchar_key +) +); +varchar_key +DROP TABLE t1, t2, t3; +# +# Bug#46556 Returning incorrect, empty results for some IN subqueries +# w/semijoin=on +# +CREATE TABLE t0 ( +pk INTEGER, +vkey VARCHAR(1), +vnokey VARCHAR(1), +PRIMARY KEY (pk), +KEY vkey(vkey) +) charset utf8mb4; +INSERT INTO t0 +VALUES (1,'g','g'), (2,'v','v'), (3,'t','t'), (4,'u','u'), (5,'n','n'); +EXPLAIN SELECT vkey FROM t0 WHERE pk IN +(SELECT t1.pk FROM t0 t1 JOIN t0 t2 ON t2.vkey = t1.vnokey); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index vkey vkey 7 NULL 5 100.00 Using index; Start temporary +1 SIMPLE t1 NULL ALL PRIMARY NULL NULL NULL 5 20.00 Using where; Using join buffer (hash join) +1 SIMPLE t0 NULL eq_ref PRIMARY PRIMARY 4 test.t1.pk 1 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`vkey` AS `vkey` from `test`.`t0` `t1` join `test`.`t0` semi join (`test`.`t0` `t2`) where ((`test`.`t1`.`vnokey` = `test`.`t2`.`vkey`) and (`test`.`t0`.`pk` = `test`.`t1`.`pk`)) +SELECT vkey FROM t0 WHERE pk IN +(SELECT t1.pk FROM t0 t1 JOIN t0 t2 ON t2.vkey = t1.vnokey); +vkey +g +n +t +u +v +DROP TABLE t0; +# End of bug#46556 + +Bug#48834: Procedure with view + subquery + semijoin=on +crashes on second call. + +CREATE TABLE t1 ( t1field integer, primary key (t1field)); +CREATE TABLE t2 ( t2field integer, primary key (t2field)); +CREATE VIEW v1 AS +SELECT t1field as v1field +FROM t1 A +WHERE A.t1field IN (SELECT t1field FROM t2 ); +CREATE VIEW v2 AS +SELECT t2field as v2field +FROM t2 A +WHERE A.t2field IN (SELECT t2field FROM t2 ); +CREATE PROCEDURE p1 () +BEGIN +SELECT v1field +FROM v1 +WHERE v1field IN ( SELECT v2field as vf_inner FROM v2 ); +END| +INSERT INTO t1 VALUES (1),(2),(3); +INSERT INTO t2 VALUES (2),(3),(4); +CALL p1; +v1field +2 +3 +CALL p1; +v1field +2 +3 +DROP TABLE t1,t2; +DROP VIEW v1,v2; +DROP PROCEDURE p1; +# End of BUG#48834 +# +# Bug#46692 "Crash occurring on queries with nested FROM subqueries +# using materialization." +# +CREATE TABLE t1 ( +pk INTEGER PRIMARY KEY, +int_key INTEGER, +KEY int_key(int_key) +); +INSERT INTO t1 VALUES (10,186),(11,NULL),(12,2),(13,3),(14,0),(15,133),(16,1); +CREATE TABLE t2 ( +pk INTEGER PRIMARY KEY, +int_key INTEGER, +KEY int_key(int_key) +); +INSERT INTO t2 VALUES (1,7),(2,2); +SELECT * FROM t1 WHERE (140, 4) IN +(SELECT t2.int_key, t2 .pk FROM t2 STRAIGHT_JOIN t1 ON t2.int_key); +pk int_key +DROP TABLE t1, t2; +# +# Bug#42353 "SELECT ... WHERE oe IN (SELECT w/ LEFT JOIN) query +# causes crash." +# +CREATE TABLE t1 ( +pk INTEGER PRIMARY KEY, +int_nokey INTEGER, +int_key INTEGER, +date_key DATE, +datetime_nokey DATETIME, +varchar_nokey VARCHAR(1) +); +CREATE TABLE t2 ( +date_nokey DATE +); +CREATE TABLE t3 ( +pk INTEGER PRIMARY KEY, +int_nokey INTEGER, +date_key date, +varchar_key VARCHAR(1), +varchar_nokey VARCHAR(1), +KEY date_key (date_key) +); +SELECT date_key FROM t1 +WHERE (int_key, int_nokey) +IN (SELECT t3.int_nokey, t3.pk +FROM t2 LEFT JOIN t3 ON (t2.date_nokey < t3.date_key) +WHERE t3.varchar_key <= t3.varchar_nokey OR t3.int_nokey <= t3.pk +) +AND (varchar_nokey <> 'f' OR NOT int_key < 7); +date_key +# +# Bug#45933 "Crash in optimize_semijoin_nests on JOIN in subquery +# + AND in outer query". +# +INSERT INTO t1 VALUES (10,7,5,'2009-06-16','2002-04-10 14:25:30','w'), +(11,7,0,'0000-00-00','0000-00-00 00:00:00','s'), +(12,4,0,'2003-07-14','2006-09-14 04:01:02','y'), +(13,0,4,'2002-07-25','0000-00-00 00:00:00','c'), +(14,1,8,'2007-07-03','0000-00-00 00:00:00','q'), +(15,6,5,'2001-11-12','0000-00-00 00:00:00',''), +(16,2,9,'0000-00-00','0000-00-00 00:00:00','j'), +(29,9,1,'0000-00-00','2003-08-11 00:00:00','m'); +Warnings: +Warning 1264 Out of range value for column 'date_key' at row 2 +Warning 1264 Out of range value for column 'datetime_nokey' at row 2 +Warning 1264 Out of range value for column 'datetime_nokey' at row 4 +Warning 1264 Out of range value for column 'datetime_nokey' at row 5 +Warning 1264 Out of range value for column 'datetime_nokey' at row 6 +Warning 1264 Out of range value for column 'date_key' at row 7 +Warning 1264 Out of range value for column 'datetime_nokey' at row 7 +Warning 1264 Out of range value for column 'date_key' at row 8 +INSERT IGNORE INTO t3 VALUES (1,9,'0000-00-00','b','b'), +(2,2,'2002-09-17','h','h'); +Warnings: +Warning 1264 Out of range value for column 'date_key' at row 1 +SELECT t1.varchar_nokey FROM t1 JOIN t3 ON t1.datetime_nokey +WHERE t1.varchar_nokey +IN (SELECT varchar_nokey FROM t1 +WHERE (pk) +IN (SELECT t3.int_nokey +FROM t3 LEFT JOIN t1 ON t1.varchar_nokey +WHERE t3.date_key BETWEEN '2008-06-07' AND '2006-06-26' + ) +); +varchar_nokey +DROP TABLE t1, t2, t3; +# +# Bug#45219 "Crash on SELECT DISTINCT query containing a +# LEFT JOIN in subquery" +# +CREATE TABLE t1 ( +pk INTEGER NOT NULL, +int_nokey INTEGER NOT NULL, +datetime_key DATETIME NOT NULL, +varchar_key VARCHAR(1) NOT NULL, +PRIMARY KEY (pk), +KEY datetime_key (datetime_key), +KEY varchar_key (varchar_key) +); +INSERT IGNORE INTO t1 VALUES +(1,9,'0000-00-00 00:00:00','p'),(2,0,'2002-02-09 07:38:13','v'), +(3,8,'2001-05-03 12:08:14','t'),(4,3,'0000-00-00 00:00:00','u'), +(5,7,'2009-07-28 03:43:30','n'),(6,0,'2009-08-04 00:00:00','l'), +(7,1,'0000-00-00 00:00:00','h'),(8,9,'0000-00-00 00:00:00','u'), +(9,0,'2005-08-02 17:16:54','n'),(10,9,'2002-12-21 00:00:00','j'), +(11,0,'2005-08-15 12:37:35','k'),(12,5,'0000-00-00 00:00:00','e'), +(13,0,'2006-03-10 00:00:00','i'),(14,8,'2005-05-16 11:02:36','u'), +(15,8,'2008-11-02 00:00:00','n'),(16,5,'2006-03-15 00:00:00','b'), +(17,1,'0000-00-00 00:00:00','x'),(18,7,'0000-00-00 00:00:00',''), +(19,0,'2008-12-17 20:15:40','q'),(20,9,'0000-00-00 00:00:00','u'); +Warnings: +Warning 1264 Out of range value for column 'datetime_key' at row 1 +Warning 1264 Out of range value for column 'datetime_key' at row 4 +Warning 1264 Out of range value for column 'datetime_key' at row 7 +Warning 1264 Out of range value for column 'datetime_key' at row 8 +Warning 1264 Out of range value for column 'datetime_key' at row 12 +Warning 1264 Out of range value for column 'datetime_key' at row 17 +Warning 1264 Out of range value for column 'datetime_key' at row 18 +Warning 1264 Out of range value for column 'datetime_key' at row 20 +CREATE TABLE t2 LIKE t1; +INSERT INTO t2 VALUES +(10,0,'2006-07-07 07:26:28','q'),(11,5,'2002-09-23 00:00:00','m'), +(12,7,'0000-00-00 00:00:00','j'),(13,1,'2006-06-07 00:00:00','z'), +(14,8,'2000-09-16 12:15:34','a'),(15,2,'2007-08-05 15:47:52',''), +(16,1,'0000-00-00 00:00:00','e'),(17,8,'2005-12-02 19:34:26','t'), +(18,5,'0000-00-00 00:00:00','q'),(19,4,'0000-00-00 00:00:00','b'), +(20,5,'2007-12-28 00:00:00','w'),(21,3,'2004-08-02 11:48:43','m'), +(22,0,'0000-00-00 00:00:00','x'),(23,8,'2004-04-19 12:18:43',''), +(24,0,'2009-04-27 00:00:00','w'),(25,4,'2006-10-20 14:52:15','x'), +(26,0,'0000-00-00 00:00:00','e'),(27,0,'2002-03-22 11:48:37','e'), +(28,2,'0000-00-00 00:00:00','p'),(29,0,'2001-01-04 03:55:07','x'); +Warnings: +Warning 1264 Out of range value for column 'datetime_key' at row 3 +Warning 1264 Out of range value for column 'datetime_key' at row 7 +Warning 1264 Out of range value for column 'datetime_key' at row 9 +Warning 1264 Out of range value for column 'datetime_key' at row 10 +Warning 1264 Out of range value for column 'datetime_key' at row 13 +Warning 1264 Out of range value for column 'datetime_key' at row 17 +Warning 1264 Out of range value for column 'datetime_key' at row 19 +CREATE TABLE t3 LIKE t1; +INSERT INTO t3 VALUES +(10,8,'2007-08-19 08:08:38','i'),(11,0,'2000-05-21 03:51:51',''); +SELECT DISTINCT datetime_key FROM t1 +WHERE (int_nokey, pk) +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#46550 Azalea returning duplicate results for some IN subqueries +# w/ semijoin=on +# +DROP TABLE IF EXISTS t0, t1, t2; +CREATE TABLE t0 ( +int_key int(11) DEFAULT NULL, +varchar_key varchar(1) DEFAULT NULL, +varchar_nokey varchar(1) DEFAULT NULL, +KEY int_key (int_key), +KEY varchar_key (varchar_key,int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t0 VALUES +(1,'m','m'), +(40,'h','h'), +(1,'r','r'), +(1,'h','h'), +(9,'x','x'), +(NULL,'q','q'), +(NULL,'k','k'), +(7,'l','l'), +(182,'k','k'), +(202,'a','a'), +(7,'x','x'), +(6,'j','j'), +(119,'z','z'), +(4,'d','d'), +(5,'h','h'), +(1,'u','u'), +(3,'q','q'), +(7,'a','a'), +(3,'e','e'), +(6,'l','l'); +CREATE TABLE t1 ( +int_key int(11) DEFAULT NULL, +varchar_key varchar(1) DEFAULT NULL, +varchar_nokey varchar(1) DEFAULT NULL, +KEY int_key (int_key), +KEY varchar_key (varchar_key,int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (7,NULL,NULL),(4,'x','x'); +CREATE TABLE t2 ( +int_key int(11) DEFAULT NULL, +varchar_key varchar(1) DEFAULT NULL, +varchar_nokey varchar(1) DEFAULT NULL, +KEY int_key (int_key), +KEY varchar_key (varchar_key,int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (123,NULL,NULL); +SELECT int_key +FROM t0 +WHERE varchar_nokey IN ( +SELECT t1 .varchar_key from t1 +); +int_key +7 +9 +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 +7 +9 +EXPLAIN +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 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 20 10.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t1_1 NULL index varchar_key varchar_key 12 NULL 2 50.00 Using where; Using index +2 MATERIALIZED t1_2 NULL index NULL int_key 5 NULL 2 100.00 Using index; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`int_key` AS `int_key` from `test`.`t0` semi join (`test`.`t1` `t1_1` join `test`.`t1` `t1_2`) where ((`test`.`t0`.`varchar_nokey` = ``.`varchar_key`) and (0 <> `test`.`t1_1`.`int_key`)) +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 +7 +9 +EXPLAIN +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 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 20 10.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t1_1 NULL index varchar_key varchar_key 12 NULL 2 50.00 Using where; Using index +2 MATERIALIZED t1_2 NULL index NULL int_key 5 NULL 2 100.00 Using index; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`int_key` AS `int_key` from `test`.`t0` semi join (`test`.`t1` `t1_1` join `test`.`t1` `t1_2`) where ((`test`.`t0`.`varchar_nokey` = ``.`varchar_key`) and (0 <> `test`.`t1_1`.`int_key`)) +DROP TABLE t0, t1, t2; +# End of bug#46550 + +Bug #48073 Subquery on char columns from view crashes Mysql + +DROP TABLE IF EXISTS t1, t2; +DROP VIEW IF EXISTS v1; +CREATE TABLE t1 ( +city VARCHAR(50) NOT NULL, +country_id SMALLINT UNSIGNED NOT NULL +); +INSERT INTO t1 VALUES +('Batna',2), +('Bchar',2), +('Skikda',2), +('Tafuna',3), +('Algeria',2) ; +CREATE TABLE t2 ( +country_id SMALLINT UNSIGNED NOT NULL, +country VARCHAR(50) NOT NULL +); +INSERT INTO t2 VALUES +(2,'Algeria'), +(3,'American Samoa') ; +CREATE VIEW v1 AS +SELECT country_id, country +FROM t2 +WHERE LEFT(country,1) = "A" +; +SELECT city, country_id +FROM t1 +WHERE city IN ( +SELECT country +FROM t2 +WHERE LEFT(country, 1) = "A" +); +city country_id +Algeria 2 +SELECT city, country_id +FROM t1 +WHERE city IN ( +SELECT country +FROM v1 +); +city country_id +Algeria 2 +drop table t1, t2; +drop view v1; +# End of bug#48073 + +Bug#49097 subquery with view generates wrong result with +non-prepared statement + +DROP TABLE IF EXISTS t1, t2; +DROP VIEW IF EXISTS v1; +CREATE TABLE t1 ( +city VARCHAR(50) NOT NULL, +country_id SMALLINT UNSIGNED NOT NULL +); +INSERT INTO t1 VALUES +('Batna',2), +('Bchar',2), +('Skikda',2), +('Tafuna',3), +('Algeria',2) ; +CREATE TABLE t2 ( +country_id SMALLINT UNSIGNED NOT NULL, +country VARCHAR(50) NOT NULL +); +INSERT INTO t2 VALUES +(2,'Algeria'), +(3,'XAmerican Samoa') ; +CREATE VIEW v1 AS +SELECT country_id, country +FROM t2 +WHERE LEFT(country,1) = "A" +; +SELECT city, country_id +FROM t1 +WHERE country_id IN ( +SELECT country_id +FROM t2 +WHERE LEFT(country,1) = "A" +); +city country_id +Algeria 2 +Batna 2 +Bchar 2 +Skikda 2 +SELECT city, country_id +FROM t1 +WHERE country_id IN ( +SELECT country_id +FROM v1 +); +city country_id +Algeria 2 +Batna 2 +Bchar 2 +Skikda 2 +PREPARE stmt FROM +" +SELECT city, country_id +FROM t1 +WHERE country_id IN ( + SELECT country_id + FROM v1 +); +"; +execute stmt; +city country_id +Algeria 2 +Batna 2 +Bchar 2 +Skikda 2 +deallocate prepare stmt; +drop table t1, t2; +drop view v1; +# End of Bug#49097 +# +# Bug#49198 Wrong result for second call of procedure +# with view in subselect. +# +CREATE TABLE t1 (t1field integer, primary key (t1field)); +CREATE TABLE t2 (t2field integer, primary key (t2field)); +CREATE TABLE t3 (t3field integer, primary key (t3field)); +CREATE VIEW v2 AS SELECT * FROM t2; +CREATE VIEW v3 AS SELECT * FROM t3; +INSERT INTO t1 VALUES(1),(2); +INSERT INTO t2 VALUES(1),(2); +INSERT INTO t3 VALUES(1),(2); +PREPARE stmt FROM +" +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT * FROM v2); +"; +EXECUTE stmt; +t1field +1 +2 + +EXECUTE stmt; +t1field +1 +2 +PREPARE stmt FROM +" +EXPLAIN +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT * FROM v2) + AND t1field IN (SELECT * FROM v3) +"; +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index PRIMARY PRIMARY 4 NULL 2 100.00 Using index +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +1 SIMPLE t3 NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`t1field` AS `t1field` from `test`.`t2` join `test`.`t3` join `test`.`t1` where ((`test`.`t2`.`t2field` = `test`.`t1`.`t1field`) and (`test`.`t3`.`t3field` = `test`.`t1`.`t1field`)) + +This line is only in place to help --skip_if_hypergraph diffing some more. + +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index PRIMARY PRIMARY 4 NULL 2 100.00 Using index +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +1 SIMPLE t3 NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`t1field` AS `t1field` from `test`.`t2` join `test`.`t3` join `test`.`t1` where ((`test`.`t2`.`t2field` = `test`.`t1`.`t1field`) and (`test`.`t3`.`t3field` = `test`.`t1`.`t1field`)) +DROP TABLE t1, t2, t3; +DROP VIEW v2, v3; +# End of Bug#49198 +# +# Bug#48623 Multiple subqueries are optimized incorrectly +# +CREATE TABLE ot(val VARCHAR(10)) charset utf8mb4; +CREATE TABLE it1(val VARCHAR(10)) charset utf8mb4; +CREATE TABLE it2(val VARCHAR(10)) charset utf8mb4; +INSERT INTO ot VALUES('aaa'), ('bbb'), ('eee'), ('mmm'), ('ppp'); +INSERT INTO it1 VALUES('aaa'), ('aaa'), ('bbb'), ('eee'), ('mmm'), ('ppp'); +INSERT INTO it2 VALUES('aaa'), ('bbb'), ('eee'), ('mmm'), ('ppp'); +EXPLAIN +SELECT * +FROM ot +WHERE ot.val IN (SELECT it1.val FROM it1 +WHERE it1.val LIKE 'a%' OR it1.val LIKE 'e%') +AND ot.val IN (SELECT it2.val FROM it2 +WHERE it2.val LIKE 'a%' OR it2.val LIKE 'e%'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using where +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 5 20.00 Using where; Using join buffer (hash join) +1 SIMPLE NULL eq_ref 43 .val 1 100.00 NULL +3 MATERIALIZED it2 NULL ALL NULL NULL NULL NULL 5 36.00 Using where +2 MATERIALIZED it1 NULL ALL NULL NULL NULL NULL 6 30.56 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`ot`.`val` AS `val` from `test`.`ot` semi join (`test`.`it1`) semi join (`test`.`it2`) where ((`test`.`ot`.`val` = ``.`val`) and (``.`val` = ``.`val`) and ((`test`.`it1`.`val` like 'a%') or (`test`.`it1`.`val` like 'e%')) and ((`test`.`it2`.`val` like 'a%') or (`test`.`it2`.`val` like 'e%'))) +SELECT * +FROM ot +WHERE ot.val IN (SELECT it1.val FROM it1 +WHERE it1.val LIKE 'a%' OR it1.val LIKE 'e%') +AND ot.val IN (SELECT it2.val FROM it2 +WHERE it2.val LIKE 'a%' OR it2.val LIKE 'e%'); +val +aaa +eee +DROP TABLE ot; +DROP TABLE it1; +DROP TABLE it2; +# End of Bug#48623 +# +# Bug #51487 Assertion failure when semi-join flattening occurs +# for a subquery in HAVING +# +CREATE TABLE t1 (a INT, b INT); +INSERT INTO t1 VALUES (1,10),(2,11),(1,13); +CREATE TABLE t2 AS SELECT * FROM t1; +CREATE TABLE t3 AS SELECT * FROM t1; +SELECT COUNT(*) FROM t1 +GROUP BY t1.a +HAVING t1.a IN (SELECT t3.a FROM t3 +WHERE t3.b IN (SELECT b FROM t2 WHERE t2.a=t1.a)); +COUNT(*) +2 +1 +DROP TABLE t1, t2, t3; +# End of Bug#51487 +# +# BUG#38075: Wrong result: rows matching a subquery with outer join not returned +# +DROP TABLE IF EXISTS ot1, it1, it2; +CREATE TABLE it2 ( +int_key int(11) NOT NULL, +datetime_key datetime NOT NULL, +KEY int_key (int_key), +KEY datetime_key (datetime_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO it2 VALUES +(5,'2002-04-10 14:25:30'), (0,'0000-00-00 00:00:00'), +(0,'2006-09-14 04:01:02'), (4,'0000-00-00 00:00:00'), +(8,'0000-00-00 00:00:00'), (5,'0000-00-00 00:00:00'), +(9,'0000-00-00 00:00:00'), (8,'2007-04-01 11:04:17'), +(1,'0000-00-00 00:00:00'), (7,'2009-01-12 00:00:00'), +(0,'2009-06-05 00:00:00'), (3,'2006-02-14 18:06:35'), +(5,'2006-02-21 07:08:16'), (0,'0000-00-00 00:00:00'), +(7,'0000-00-00 00:00:00'), (0,'0000-00-00 00:00:00'), +(0,'2007-02-13 00:00:00'), (1,'0000-00-00 00:00:00'), +(0,'0000-00-00 00:00:00'), (1,'2003-08-11 00:00:00'); +Warnings: +Warning 1264 Out of range value for column 'datetime_key' at row 2 +Warning 1264 Out of range value for column 'datetime_key' at row 4 +Warning 1264 Out of range value for column 'datetime_key' at row 5 +Warning 1264 Out of range value for column 'datetime_key' at row 6 +Warning 1264 Out of range value for column 'datetime_key' at row 7 +Warning 1264 Out of range value for column 'datetime_key' at row 9 +Warning 1264 Out of range value for column 'datetime_key' at row 14 +Warning 1264 Out of range value for column 'datetime_key' at row 15 +Warning 1264 Out of range value for column 'datetime_key' at row 16 +Warning 1264 Out of range value for column 'datetime_key' at row 18 +Warning 1264 Out of range value for column 'datetime_key' at row 19 +CREATE TABLE ot1 ( +int_nokey int(11) NOT NULL, +int_key int(11) NOT NULL, +KEY int_key (int_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO ot1 VALUES +(5,0), (3,0), (0,2), (3,0), (1,3), (0,0), (1,7), (7,0), (1,7), (0,7), +(0,9), (8,2), (4,4), (9,3), (0,9), (2,5), (0,5), (8,0), (5,8), (1,5); +CREATE TABLE it1 ( +int_nokey int(11) NOT NULL, +int_key int(11) NOT NULL, +KEY int_key (int_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO it1 VALUES +(9,5), (0,4); +SELECT int_key FROM ot1 +WHERE int_nokey IN (SELECT it2.int_key +FROM it1 LEFT JOIN it2 ON it2.datetime_key); +int_key +0 +0 +0 +0 +0 +0 +2 +2 +3 +5 +5 +7 +7 +7 +8 +9 +9 +EXPLAIN +SELECT int_key FROM ot1 +WHERE int_nokey IN (SELECT it2.int_key +FROM it1 LEFT JOIN it2 ON it2.datetime_key); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 20 10.00 Using where; Using join buffer (hash join) +2 MATERIALIZED it1 NULL index NULL int_key 4 NULL 2 100.00 Using index +2 MATERIALIZED it2 NULL ALL int_key NULL NULL NULL 20 90.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`int_key` AS `int_key` from `test`.`ot1` semi join (`test`.`it1` join `test`.`it2`) where ((`test`.`ot1`.`int_nokey` = ``.`int_key`) and (TIMESTAMP'0000-00-00 00:00:00' <> `test`.`it2`.`datetime_key`)) +DROP TABLE ot1, it1, it2; +# End of BUG#38075 +# +# BUG#50089: Second call of procedure with view in subselect crashes server +# +CREATE TABLE t1(t1field INTEGER, PRIMARY KEY(t1field)); +CREATE VIEW v1 AS +SELECT t1field AS v1field +FROM t1 a +WHERE a.t1field IN (SELECT t1field FROM t1); +INSERT INTO t1 VALUES(1),(2); +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT v1field FROM v1); +t1field +1 +2 +EXPLAIN +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT v1field FROM v1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index PRIMARY PRIMARY 4 NULL 2 100.00 Using index +1 SIMPLE a NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `t1`.`t1field` AS `t1field` from `test`.`t1` `a` join `test`.`t1` join `test`.`t1` where ((`test`.`a`.`t1field` = `t1`.`t1field`) and (`test`.`t1`.`t1field` = `t1`.`t1field`)) +SELECT t1.t1field +FROM t1 LEFT JOIN t1 AS t2 ON t1.t1field IN (SELECT v1field FROM v1); +t1field +1 +1 +2 +2 +EXPLAIN +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT v1field FROM v1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index PRIMARY PRIMARY 4 NULL 2 100.00 Using index +1 SIMPLE a NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `t1`.`t1field` AS `t1field` from `test`.`t1` `a` join `test`.`t1` join `test`.`t1` where ((`test`.`a`.`t1field` = `t1`.`t1field`) and (`test`.`t1`.`t1field` = `t1`.`t1field`)) +CREATE PROCEDURE p1() +BEGIN +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT v1field FROM v1); +END| +CALL p1; +t1field +1 +2 +CALL p1; +t1field +1 +2 +PREPARE stmt FROM +" +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT v1field FROM v1); +"; +EXECUTE stmt; +t1field +1 +2 + +EXECUTE stmt; +t1field +1 +2 +DROP PROCEDURE p1; +DROP VIEW v1; +DROP TABLE t1; +# End of BUG#50089 +# +# Bug#45191: Incorrectly initialized semi-join led to a wrong result. +# +CREATE TABLE staff (EMPNUM CHAR(3) NOT NULL, +EMPNAME CHAR(20), GRADE DECIMAL(4), CITY CHAR(15)) charset latin1; +CREATE TABLE proj (PNUM CHAR(3) NOT NULL, +PNAME CHAR(20), PTYPE CHAR(6), +BUDGET DECIMAL(9), +CITY CHAR(15)) charset latin1; +CREATE TABLE works (EMPNUM CHAR(3) NOT NULL, +PNUM CHAR(3) NOT NULL, HOURS DECIMAL(5)) charset latin1; +INSERT INTO staff VALUES ('E1','Alice',12,'Deale'); +INSERT INTO staff VALUES ('E2','Betty',10,'Vienna'); +INSERT INTO staff VALUES ('E3','Carmen',13,'Vienna'); +INSERT INTO staff VALUES ('E4','Don',12,'Deale'); +INSERT INTO staff VALUES ('E5','Ed',13,'Akron'); +INSERT INTO proj VALUES ('P1','MXSS','Design',10000,'Deale'); +INSERT INTO proj VALUES ('P2','CALM','Code',30000,'Vienna'); +INSERT INTO proj VALUES ('P3','SDP','Test',30000,'Tampa'); +INSERT INTO proj VALUES ('P4','SDP','Design',20000,'Deale'); +INSERT INTO proj VALUES ('P5','IRM','Test',10000,'Vienna'); +INSERT INTO proj VALUES ('P6','PAYR','Design',50000,'Deale'); +INSERT INTO works VALUES ('E1','P1',40); +INSERT INTO works VALUES ('E1','P2',20); +INSERT INTO works VALUES ('E1','P3',80); +INSERT INTO works VALUES ('E1','P4',20); +INSERT INTO works VALUES ('E1','P5',12); +INSERT INTO works VALUES ('E1','P6',12); +INSERT INTO works VALUES ('E2','P1',40); +INSERT INTO works VALUES ('E2','P2',80); +INSERT INTO works VALUES ('E3','P2',20); +INSERT INTO works VALUES ('E4','P2',20); +INSERT INTO works VALUES ('E4','P4',40); +INSERT INTO works VALUES ('E4','P5',80); +explain SELECT EMPNUM, EMPNAME +FROM staff +WHERE EMPNUM IN +(SELECT EMPNUM FROM works +WHERE PNUM IN +(SELECT PNUM FROM proj)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE staff NULL ALL NULL NULL NULL NULL 5 100.00 NULL +1 SIMPLE NULL eq_ref 3 test.staff.EMPNUM 1 100.00 NULL +2 MATERIALIZED proj NULL ALL NULL NULL NULL NULL 6 100.00 NULL +2 MATERIALIZED works NULL ALL NULL NULL NULL NULL 12 10.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`staff`.`EMPNUM` AS `EMPNUM`,`test`.`staff`.`EMPNAME` AS `EMPNAME` from `test`.`staff` semi join (`test`.`works` join `test`.`proj`) where ((``.`EMPNUM` = `test`.`staff`.`EMPNUM`) and (`test`.`works`.`PNUM` = `test`.`proj`.`PNUM`)) +SELECT EMPNUM, EMPNAME +FROM staff +WHERE EMPNUM IN +(SELECT EMPNUM FROM works +WHERE PNUM IN +(SELECT PNUM FROM proj)); +EMPNUM EMPNAME +E1 Alice +E2 Betty +E3 Carmen +E4 Don +drop table staff,works,proj; +# End of bug#45191 +# +# BUG#36896: Server crash on SELECT FROM DUAL +# +create table t1 (a int); +select 1 as res from dual where (1) in (select * from t1); +res +drop table t1; + +BUG#40118 Crash when running Batched Key Access and requiring one match for each key + +create table t0(a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (a int, key(a)); +insert into t1 select * from t0; +alter table t1 add b int not null, add filler char(200); +insert into t1 select * from t1; +insert into t1 select * from t1; +select * from t0 where t0.a in (select t1.a from t1 where t1.b=0); +a +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +drop table t0, t1; +# +# BUG#32665 Query with dependent subquery is too slow +# +create table t1 ( +idIndividual int primary key +); +insert into t1 values (1),(2); +create table t2 ( +idContact int primary key, +contactType int, +idObj int +); +insert into t2 values (1,1,1),(2,2,2),(3,3,3); +create table t3 ( +idAddress int primary key, +idContact int, +postalStripped varchar(100) +); +insert into t3 values (1,1, 'foo'), (2,2,'bar'); +The following must be converted to a semi-join: +explain SELECT a.idIndividual FROM t1 a +WHERE a.idIndividual IN +( SELECT c.idObj FROM t3 cona +INNER JOIN t2 c ON c.idContact=cona.idContact +WHERE cona.postalStripped='T2H3B2' + ); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using where +1 SIMPLE a NULL eq_ref PRIMARY PRIMARY 4 .idObj 1 100.00 Using index +2 MATERIALIZED cona NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 MATERIALIZED c NULL eq_ref PRIMARY PRIMARY 4 test.cona.idContact 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`a`.`idIndividual` AS `idIndividual` from `test`.`t1` `a` semi join (`test`.`t3` `cona` join `test`.`t2` `c`) where ((`test`.`c`.`idContact` = `test`.`cona`.`idContact`) and (`test`.`a`.`idIndividual` = ``.`idObj`) and (`test`.`cona`.`postalStripped` = 'T2H3B2')) +drop table t1,t2,t3; +CREATE TABLE t1 (one int, two int, flag char(1)); +CREATE TABLE t2 (one int, two int, flag char(1)); +INSERT INTO t1 VALUES(1,2,'Y'),(2,3,'Y'),(3,4,'Y'),(5,6,'N'),(7,8,'N'); +INSERT INTO t2 VALUES(1,2,'Y'),(2,3,'Y'),(3,4,'Y'),(5,6,'N'),(7,8,'N'); +SELECT * FROM t1 +WHERE ROW(one,two) IN (SELECT DISTINCT one,two FROM t2 WHERE flag = 'N'); +one two flag +5 6 N +7 8 N +SELECT * FROM t1 +WHERE ROW(one,two) IN (SELECT DISTINCT one,two FROM t1 WHERE flag = 'N'); +one two flag +5 6 N +7 8 N +insert into t2 values (null,null,'N'); +insert into t2 values (null,3,'0'); +insert into t2 values (null,5,'0'); +insert into t2 values (10,null,'0'); +insert into t1 values (10,3,'0'); +insert into t1 values (10,5,'0'); +insert into t1 values (10,10,'0'); +SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = 'N') as 'test' from t1; +one two test +1 2 NULL +2 3 NULL +3 4 NULL +5 6 1 +7 8 1 +10 3 NULL +10 5 NULL +10 10 NULL +SELECT one,two from t1 where ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = 'N'); +one two +5 6 +7 8 +SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = 'N' group by one,two) as 'test' from t1; +one two test +1 2 NULL +2 3 NULL +3 4 NULL +5 6 1 +7 8 1 +10 3 NULL +10 5 NULL +10 10 NULL +SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = '0') as 'test' from t1; +one two test +1 2 0 +2 3 NULL +3 4 0 +5 6 0 +7 8 0 +10 3 NULL +10 5 NULL +10 10 NULL +SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = '0' group by one,two) as 'test' from t1; +one two test +1 2 0 +2 3 NULL +3 4 0 +5 6 0 +7 8 0 +10 3 NULL +10 5 NULL +10 10 NULL +explain SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = '0') as 'test' from t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 9 11.11 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`one` AS `one`,`test`.`t1`.`two` AS `two`,((`test`.`t1`.`one`,`test`.`t1`.`two`),(/* select#2 */ select `test`.`t2`.`one`,`test`.`t2`.`two` from `test`.`t2` where ((`test`.`t2`.`flag` = '0') and (outer_field_is_not_null, (((`test`.`t1`.`one`) = `test`.`t2`.`one`) or (`test`.`t2`.`one` is null)), true) and (outer_field_is_not_null, (((`test`.`t1`.`two`) = `test`.`t2`.`two`) or (`test`.`t2`.`two` is null)), true)) having ((outer_field_is_not_null, (`test`.`t2`.`one`), true) and (outer_field_is_not_null, (`test`.`t2`.`two`), true)))) AS `test` from `test`.`t1` +explain SELECT one,two from t1 where ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = 'N'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 9 11.11 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`one` AS `one`,`test`.`t1`.`two` AS `two` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`two` = ``.`two`) and (`test`.`t1`.`one` = ``.`one`) and (`test`.`t2`.`flag` = 'N')) +explain SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = '0' group by one,two) as 'test' from t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 9 11.11 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`one` AS `one`,`test`.`t1`.`two` AS `two`,((`test`.`t1`.`one`,`test`.`t1`.`two`),(/* select#2 */ select `test`.`t2`.`one`,`test`.`t2`.`two` from `test`.`t2` where ((`test`.`t2`.`flag` = '0') and (outer_field_is_not_null, (((`test`.`t1`.`one`) = `test`.`t2`.`one`) or (`test`.`t2`.`one` is null)), true) and (outer_field_is_not_null, (((`test`.`t1`.`two`) = `test`.`t2`.`two`) or (`test`.`t2`.`two` is null)), true)) having ((outer_field_is_not_null, (`test`.`t2`.`one`), true) and (outer_field_is_not_null, (`test`.`t2`.`two`), true)))) AS `test` from `test`.`t1` +DROP TABLE t1,t2; +CREATE TABLE t1 (a char(5), b char(5)); +INSERT INTO t1 VALUES (NULL,'aaa'), ('aaa','aaa'); +SELECT * FROM t1 WHERE (a,b) IN (('aaa','aaa'), ('aaa','bbb')); +a b +aaa aaa +DROP TABLE t1; +CREATE TABLE t1 (a CHAR(1), b VARCHAR(10)) charset utf8mb4; +INSERT INTO t1 VALUES ('a', 'aa'); +INSERT INTO t1 VALUES ('a', 'aaa'); +SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1); +a b +CREATE INDEX I1 ON t1 (a); +CREATE INDEX I2 ON t1 (b); +EXPLAIN SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL I2 NULL NULL NULL 2 100.00 Using where +1 SIMPLE NULL eq_ref 5 test.t1.b 1 100.00 Using where +2 MATERIALIZED t1 NULL index I1 I1 5 NULL 2 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t1`) where (`test`.`t1`.`b` = ``.`a`) +SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1); +a b +CREATE TABLE t2 (a VARCHAR(1), b VARCHAR(10)) charset utf8mb4; +INSERT INTO t2 SELECT * FROM t1; +CREATE INDEX I1 ON t2 (a); +CREATE INDEX I2 ON t2 (b); +EXPLAIN SELECT a,b FROM t2 WHERE b IN (SELECT a FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL I2 NULL NULL NULL 2 100.00 Using where +1 SIMPLE NULL eq_ref 7 test.t2.b 1 100.00 Using where +2 MATERIALIZED t2 NULL index I1 I1 7 NULL 2 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t2` semi join (`test`.`t2`) where (`test`.`t2`.`b` = ``.`a`) +SELECT a,b FROM t2 WHERE b IN (SELECT a FROM t2); +a b +EXPLAIN +SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1 WHERE LENGTH(a)<500); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL I2 NULL NULL NULL 2 100.00 Using where +1 SIMPLE NULL eq_ref 5 test.t1.b 1 100.00 Using where +2 MATERIALIZED t1 NULL index I1 I1 5 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t1`) where ((length(`test`.`t1`.`a`) < 500) and (`test`.`t1`.`b` = ``.`a`)) +SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1 WHERE LENGTH(a)<500); +a b +DROP TABLE t1,t2; +# +# BUG#45928 "Differing query results depending on MRR and +# engine_condition_pushdown settings" +# +CREATE TABLE `t1` ( +`pk` int(11) NOT NULL AUTO_INCREMENT, +`time_nokey` time NOT NULL, +`varchar_key` varchar(1) NOT NULL, +`varchar_nokey` varchar(1) NOT NULL, +PRIMARY KEY (`pk`), +KEY `varchar_key` (`varchar_key`) +) AUTO_INCREMENT=12 DEFAULT CHARSET=latin1; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO `t1` VALUES (10,'00:00:00','i','i'),(11,'00:00:00','',''); +SELECT `time_nokey` G1 FROM t1 WHERE ( `varchar_nokey` , `varchar_key` ) IN ( +SELECT `varchar_nokey` , `varchar_nokey` ) AND `varchar_key` >= 'c' HAVING G1 ORDER +BY `pk` ; +G1 +DROP TABLE t1; +# +# BUG#45863 "Assertion failed: (fixed == 0), function fix_fields(), +# file item.cc, line 4448" +# +DROP TABLE IF EXISTS C, BB; +CREATE TABLE C ( +varchar_nokey varchar(1) NOT NULL +); +INSERT INTO C VALUES +('k'),('a'),(''),('u'),('e'),('v'),('i'), +('t'),('u'),('f'),('u'),('m'),('j'),('f'), +('v'),('j'),('g'),('e'),('h'),('z'); +CREATE TABLE BB ( +varchar_nokey varchar(1) NOT NULL +); +INSERT INTO BB VALUES ('i'),('t'); +SELECT varchar_nokey FROM C +WHERE (varchar_nokey, OUTR) IN (SELECT varchar_nokey +FROM BB); +ERROR 42S22: Unknown column 'OUTR' in 'IN/ALL/ANY subquery' +SELECT varchar_nokey FROM C +WHERE (varchar_nokey, OUTR) IN (SELECT varchar_nokey, varchar_nokey +FROM BB); +ERROR 42S22: Unknown column 'OUTR' in 'IN/ALL/ANY subquery' +DROP TABLE C,BB; +# +# During work with BUG#45863 I had problems with a query that was +# optimized differently in regular and prepared mode. +# Because there was a bug in one of the selected strategies, I became +# aware of the problem. Adding an EXPLAIN query to catch this. +DROP TABLE IF EXISTS t1, t2, t3; +CREATE TABLE t1 +(EMPNUM CHAR(3) NOT NULL, +EMPNAME CHAR(20), +GRADE DECIMAL(4), +CITY CHAR(15)) charset latin1; +CREATE TABLE t2 +(PNUM CHAR(3) NOT NULL, +PNAME CHAR(20), +PTYPE CHAR(6), +BUDGET DECIMAL(9), +CITY CHAR(15)) charset latin1; +CREATE TABLE t3 +(EMPNUM CHAR(3) NOT NULL, +PNUM CHAR(3) NOT NULL, +HOURS DECIMAL(5)) charset latin1; +INSERT INTO t1 VALUES ('E1','Alice',12,'Deale'); +INSERT INTO t1 VALUES ('E2','Betty',10,'Vienna'); +INSERT INTO t1 VALUES ('E3','Carmen',13,'Vienna'); +INSERT INTO t1 VALUES ('E4','Don',12,'Deale'); +INSERT INTO t1 VALUES ('E5','Ed',13,'Akron'); +INSERT INTO t2 VALUES ('P1','MXSS','Design',10000,'Deale'); +INSERT INTO t2 VALUES ('P2','CALM','Code',30000,'Vienna'); +INSERT INTO t2 VALUES ('P3','SDP','Test',30000,'Tampa'); +INSERT INTO t2 VALUES ('P4','SDP','Design',20000,'Deale'); +INSERT INTO t2 VALUES ('P5','IRM','Test',10000,'Vienna'); +INSERT INTO t2 VALUES ('P6','PAYR','Design',50000,'Deale'); +INSERT INTO t3 VALUES ('E1','P1',40); +INSERT INTO t3 VALUES ('E1','P2',20); +INSERT INTO t3 VALUES ('E1','P3',80); +INSERT INTO t3 VALUES ('E1','P4',20); +INSERT INTO t3 VALUES ('E1','P5',12); +INSERT INTO t3 VALUES ('E1','P6',12); +INSERT INTO t3 VALUES ('E2','P1',40); +INSERT INTO t3 VALUES ('E2','P2',80); +INSERT INTO t3 VALUES ('E3','P2',20); +INSERT INTO t3 VALUES ('E4','P2',20); +INSERT INTO t3 VALUES ('E4','P4',40); +INSERT INTO t3 VALUES ('E4','P5',80); +CREATE UNIQUE INDEX t1_IDX ON t1(EMPNUM); +EXPLAIN SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN +(SELECT EMPNUM +FROM t3 +WHERE PNUM IN +(SELECT PNUM +FROM t2 +WHERE PTYPE = 'Design')); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL eq_ref t1_IDX t1_IDX 3 .EMPNUM 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = ``.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) +PREPARE stmt FROM "EXPLAIN SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN + (SELECT EMPNUM + FROM t3 + WHERE PNUM IN + (SELECT PNUM + FROM t2 + WHERE PTYPE = 'Design'))"; +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL eq_ref t1_IDX t1_IDX 3 .EMPNUM 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = ``.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) + +This line is only in place to help --skip_if_hypergraph diffing some more. + +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL eq_ref t1_IDX t1_IDX 3 .EMPNUM 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = ``.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) +DEALLOCATE PREPARE stmt; +DROP INDEX t1_IDX ON t1; +CREATE INDEX t1_IDX ON t1(EMPNUM); +EXPLAIN SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN +(SELECT EMPNUM +FROM t3 +WHERE PNUM IN +(SELECT PNUM +FROM t2 +WHERE PTYPE = 'Design')); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ref t1_IDX t1_IDX 3 .EMPNUM 2 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = ``.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) +PREPARE stmt FROM "EXPLAIN SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN + (SELECT EMPNUM + FROM t3 + WHERE PNUM IN + (SELECT PNUM + FROM t2 + WHERE PTYPE = 'Design'))"; +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ref t1_IDX t1_IDX 3 .EMPNUM 2 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = ``.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) + +This line is only in place to help --skip_if_hypergraph diffing some more. + +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ref t1_IDX t1_IDX 3 .EMPNUM 2 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = ``.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) +DEALLOCATE PREPARE stmt; +DROP INDEX t1_IDX ON t1; +EXPLAIN SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN +(SELECT EMPNUM +FROM t3 +WHERE PNUM IN +(SELECT PNUM +FROM t2 +WHERE PTYPE = 'Design')); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 20.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = ``.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) +PREPARE stmt FROM "EXPLAIN SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN + (SELECT EMPNUM + FROM t3 + WHERE PNUM IN + (SELECT PNUM + FROM t2 + WHERE PTYPE = 'Design'))"; +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 20.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = ``.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) + +This line is only in place to help --skip_if_hypergraph diffing some more. + +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 20.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = ``.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) +DEALLOCATE PREPARE stmt; +DROP TABLE t1, t2, t3; +# +# BUG#45221 Query SELECT pk FROM C WHERE pk IN (SELECT int_key) failing +# +CREATE TABLE t1 ( +i1_key INT, +i2 INT, +i3 INT, +KEY i1_index (i1_key) +); +INSERT INTO t1 VALUES (9,1,2), (9,2,1); +CREATE TABLE t2 ( +pk INT NOT NULL, +i1 INT, +PRIMARY KEY (pk) +); +INSERT INTO t2 VALUES (9,1); +SELECT pk +FROM t2 +WHERE +pk IN ( +SELECT i1_key +FROM t1 +WHERE t1.i2 < t1.i3 XOR t2.i1 > 1 +ORDER BY t1.i2 desc); +pk +9 +DROP TABLE t1,t2; +# BUG#50361 Doublenested noncorrelated subquery with FirstMatch and join cache wrong result +# +CREATE TABLE t1( +id INTEGER +); +INSERT INTO t1 VALUES(10),(20); +create table t2 select * from t1; +create table t3 select * from t1; +SELECT * +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t2 +WHERE 1 IN(SELECT 1 +FROM t3)); +id +10 +20 +explain SELECT * +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t2 +WHERE 1 IN(SELECT 1 +FROM t3)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE NULL const 4 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where true +delete from t2; +delete from t3; +INSERT INTO t1 VALUES(30),(40),(50),(60),(70),(80),(90); +insert into t2 select * from t1; +insert into t3 select * from t1; +create table t4 select * from t1; +SELECT * +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t2 +WHERE 1 IN(SELECT 1 +FROM t3 +WHERE 1 IN(SELECT 1 +FROM t4))); +id +10 +20 +30 +40 +50 +60 +70 +80 +90 +explain SELECT * +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t2 +WHERE 1 IN(SELECT 1 +FROM t3 +WHERE 1 IN(SELECT 1 +FROM t4))); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 9 100.00 NULL +1 SIMPLE NULL const 4 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 9 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 9 100.00 Using join buffer (hash join) +2 MATERIALIZED t4 NULL ALL NULL NULL NULL NULL 9 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3` join `test`.`t4`) where true +SELECT * +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t1))); +id +10 +20 +30 +40 +50 +60 +70 +80 +90 +drop table t1,t2,t3,t4; +# +# Bug#53236 Segfault in DTCollation::set(DTCollation&) +# +CREATE TABLE t1 ( +pk INTEGER AUTO_INCREMENT, +col_varchar VARCHAR(1), +PRIMARY KEY (pk) +) +; +INSERT INTO t1 (col_varchar) +VALUES +('w'), +('m') +; +SELECT table1.pk +FROM ( t1 AS table1 JOIN t1 AS table2 ON (table1.col_varchar = +table2.col_varchar) ) +WHERE ( 1, 2 ) IN ( SELECT SUBQUERY1_t1.pk AS SUBQUERY1_field1, +SUBQUERY1_t1.pk AS SUBQUERY1_field2 +FROM ( t1 AS SUBQUERY1_t1 JOIN t1 AS SUBQUERY1_t2 +ON (SUBQUERY1_t2.col_varchar = +SUBQUERY1_t1.col_varchar) ) ) +; +pk +drop table t1; +# +# BUG#53298 "wrong result with semijoin (no semijoin strategy chosen)" +# +create table t1 (uid int, fid int); +insert into t1 values (1,1), (3,1); +create table t2 (uid int, name varchar(128)); +insert into t2 values (1, "A"), (2, "B"); +create table t3 (uid int, fid int, index(uid)); +insert into t3 values (1,3), (1,3); +create table t4 (uid int); +insert into t4 values (3); +explain select t2.uid from t2, t1 +where t1.uid in (select t4.uid from t4, t3 where t3.uid=1 and t4.uid=t3.fid) +and t2.uid=t1.fid; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 0.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t4 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 MATERIALIZED t3 NULL ref uid uid 5 const 1 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`uid` AS `uid` from `test`.`t2` join `test`.`t1` semi join (`test`.`t4` join `test`.`t3`) where ((`test`.`t1`.`uid` = ``.`uid`) and (`test`.`t3`.`fid` = `test`.`t4`.`uid`) and (`test`.`t3`.`uid` = 1) and (`test`.`t1`.`fid` = `test`.`t2`.`uid`)) +select t2.uid from t2, t1 +where t1.uid in (select t4.uid from t4, t3 where t3.uid=1 and t4.uid=t3.fid) +and t2.uid=t1.fid; +uid +1 +drop table t1,t2,t3,t4; +CREATE TABLE t1 ( +pk int, +a varchar(1), +b varchar(4), +c varchar(4), +d varchar(4), +PRIMARY KEY (pk) +) charset utf8mb4; +INSERT INTO t1 VALUES (1,'o','ffff','ffff','ffoo'),(2,'f','ffff','ffff','ffff'); +CREATE TABLE t2 LIKE t1; +INSERT INTO t2 VALUES (1,'i','iiii','iiii','iiii'),(2,'f','ffff','ffff','ffff'); +EXPLAIN SELECT pk FROM t1 WHERE (a) IN (SELECT a FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE NULL eq_ref 7 test.t1.a 1 100.00 NULL +2 MATERIALIZED t2 NULL range PRIMARY PRIMARY 4 NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((``.`a` = `test`.`t1`.`a`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (a) IN (SELECT a FROM t2 WHERE pk > 0); +pk +2 +SELECT pk FROM t1 WHERE (b,c,d) IN (SELECT b,c,d FROM t2 WHERE pk > 0); +pk +2 +DROP TABLE t1, t2; +CREATE TABLE t1 (f1 INT, f2 DECIMAL(5,3)) ENGINE=MyISAM; +INSERT INTO t1 (f1, f2) VALUES (1, 1.789); +INSERT INTO t1 (f1, f2) VALUES (13, 1.454); +INSERT INTO t1 (f1, f2) VALUES (10, 1.668); +CREATE TABLE t2 LIKE t1; +INSERT INTO t2 VALUES (1, 1.789); +INSERT INTO t2 VALUES (13, 1.454); +EXPLAIN SELECT COUNT(*) FROM t1 WHERE (f1,f2) IN (SELECT f1,f2 FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`f2` = ``.`f2`) and (`test`.`t1`.`f1` = ``.`f1`)) +SELECT COUNT(*) FROM t1 WHERE (f1,f2) IN (SELECT f1,f2 FROM t2); +COUNT(*) +2 +DROP TABLE t1, t2; +CREATE TABLE t1 ( +ID int(11) NOT NULL auto_increment, +Name char(35) NOT NULL default '', +Country char(3) NOT NULL default '', +Population int(11) NOT NULL default '0', +PRIMARY KEY (ID), +INDEX (Population), +INDEX (Country) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t2 ( +Code char(3) NOT NULL default '', +Name char(52) NOT NULL default '', +SurfaceArea float(10,2) NOT NULL default '0.00', +Population int(11) NOT NULL default '0', +Capital int(11) default NULL, +PRIMARY KEY (Code), +UNIQUE INDEX (Name), +INDEX (Population) +) charset utf8mb4; +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t3 ( +Country char(3) NOT NULL default '', +Language char(30) NOT NULL default '', +Percentage float(3,1) NOT NULL default '0.0', +PRIMARY KEY (Country, Language), +INDEX (Percentage) +) charset utf8mb4; +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +EXPLAIN SELECT Name FROM t2 +WHERE t2.Code IN (SELECT Country FROM t1 WHERE Population > 5000000) +AND +t2.Code IN (SELECT Country FROM t3 +WHERE Language='English' AND Percentage > 10 AND +t2.Population > 100000); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t2 NULL eq_ref PRIMARY,Population PRIMARY 12 .Country 1 75.00 Using where +1 SIMPLE t3 NULL eq_ref PRIMARY,Percentage PRIMARY 132 .Country,const 1 95.45 Using where +2 MATERIALIZED t1 NULL range Population,Country Population 4 NULL 1 100.00 Using where +Warnings: +Note 1276 Field or reference 'test.t2.Population' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t2`.`Name` AS `Name` from `test`.`t3` join `test`.`t2` semi join (`test`.`t1`) where ((`test`.`t2`.`Code` = ``.`Country`) and (`test`.`t3`.`Country` = ``.`Country`) and (`test`.`t3`.`Language` = 'English') and (`test`.`t3`.`Percentage` > 10) and (`test`.`t2`.`Population` > 100000) and (`test`.`t1`.`Population` > 5000000)) +EXPLAIN FORMAT=JSON SELECT Name FROM t2 +WHERE t2.Code IN (SELECT Country FROM t1 WHERE Population > 5000000) +AND +t2.Code IN (SELECT Country FROM t3 +WHERE Language='English' AND Percentage > 10 AND +t2.Population > 100000); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "2.52" + }, + "nested_loop": [ + { + "table": { + "table_name": "", + "access_type": "ALL", + "materialized_from_subquery": { + "using_temporary_table": true, + "query_block": { + "table": { + "table_name": "t1", + "access_type": "range", + "possible_keys": [ + "Population", + "Country" + ], + "key": "Population", + "used_key_parts": [ + "Population" + ], + "key_length": "4", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.61", + "eval_cost": "0.10", + "prefix_cost": "0.71", + "data_read_per_join": "168" + }, + "used_columns": [ + "Country", + "Population" + ], + "attached_condition": "(`test`.`t1`.`Population` > 5000000)" + } + } + } + } + }, + { + "table": { + "table_name": "t2", + "access_type": "eq_ref", + "possible_keys": [ + "PRIMARY", + "Population" + ], + "key": "PRIMARY", + "used_key_parts": [ + "Code" + ], + "key_length": "12", + "ref": [ + ".Country" + ], + "rows_examined_per_scan": 1, + "rows_produced_per_join": 0, + "filtered": "75.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.08", + "prefix_cost": "2.26", + "data_read_per_join": "180" + }, + "used_columns": [ + "Code", + "Name", + "Population" + ], + "attached_condition": "(`test`.`t2`.`Population` > 100000)" + } + }, + { + "table": { + "table_name": "t3", + "access_type": "eq_ref", + "possible_keys": [ + "PRIMARY", + "Percentage" + ], + "key": "PRIMARY", + "used_key_parts": [ + "Country", + "Language" + ], + "key_length": "132", + "ref": [ + ".Country", + "const" + ], + "rows_examined_per_scan": 1, + "rows_produced_per_join": 0, + "filtered": "95.45", + "cost_info": { + "read_cost": "0.19", + "eval_cost": "0.07", + "prefix_cost": "2.52", + "data_read_per_join": "103" + }, + "used_columns": [ + "Country", + "Language", + "Percentage" + ], + "attached_condition": "((`test`.`t3`.`Language` = 'English') and (`test`.`t3`.`Percentage` > 10))" + } + } + ] + } +} +Warnings: +Note 1276 Field or reference 'test.t2.Population' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t2`.`Name` AS `Name` from `test`.`t3` join `test`.`t2` semi join (`test`.`t1`) where ((`test`.`t2`.`Code` = ``.`Country`) and (`test`.`t3`.`Country` = ``.`Country`) and (`test`.`t3`.`Language` = 'English') and (`test`.`t3`.`Percentage` > 10) and (`test`.`t2`.`Population` > 100000) and (`test`.`t1`.`Population` > 5000000)) +DROP TABLE t1,t2,t3; +CREATE TABLE t1 ( +Code char(3) NOT NULL DEFAULT '', +Name char(52) NOT NULL DEFAULT '', +Continent enum('Asia','Europe','North America','Africa','Oceania','Antarctica','South America') NOT NULL DEFAULT 'Asia', +Region char(26) NOT NULL DEFAULT '', +SurfaceArea float(10,2) NOT NULL DEFAULT '0.00', +IndepYear smallint(6) DEFAULT NULL, +Population int(11) NOT NULL DEFAULT '0', +LifeExpectancy float(3,1) DEFAULT NULL, +GNP float(10,2) DEFAULT NULL, +GNPOld float(10,2) DEFAULT NULL, +LocalName char(45) NOT NULL DEFAULT '', +GovernmentForm char(45) NOT NULL DEFAULT '', +HeadOfState char(60) DEFAULT NULL, +Capital int(11) DEFAULT NULL, +Code2 char(2) NOT NULL DEFAULT '', +PRIMARY KEY (Code) +) charset utf8mb4; +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t2 ( +ID int(11) NOT NULL AUTO_INCREMENT, +Name char(35) NOT NULL DEFAULT '', +CountryCode char(3) NOT NULL DEFAULT '', +District char(20) NOT NULL DEFAULT '', +Population int(11) NOT NULL DEFAULT '0', +PRIMARY KEY (ID), +KEY CountryCode (CountryCode) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +set names latin1; +Fill the table with test data +This must not use LooseScan: +EXPLAIN SELECT Name FROM t1 +WHERE t1.Code IN ( +SELECT t2.CountryCode FROM t2 WHERE Population > 5000000); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL PRIMARY NULL NULL NULL 31 100.00 NULL +1 SIMPLE NULL eq_ref 12 test.t1.Code 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL CountryCode NULL NULL NULL 545 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`Name` AS `Name` from `test`.`t1` semi join (`test`.`t2`) where ((``.`CountryCode` = `test`.`t1`.`Code`) and (`test`.`t2`.`Population` > 5000000)) +SELECT Name FROM t1 +WHERE t1.Code IN ( +SELECT t2.CountryCode FROM t2 WHERE Population > 5000000); +Name +Austria +Canada +China +Czech Republic +drop table t1, t2; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4); +create table t1 (a int, b int, key(a)); +insert into t1 select a,a from t0; +create table t2 (a int, b int, primary key(a)); +insert into t2 select * from t1; +Table t2, unlike table t1, should be displayed as pulled out +explain select * from t0 +where t0.a in ( select t1.a from t1,t2 where t2.a=t0.a and +t1.b=t2.b); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL a NULL NULL NULL 5 100.00 Using where; Start temporary +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 20.00 Using where +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 5 20.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t0.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a` from `test`.`t2` join `test`.`t0` semi join (`test`.`t1`) where ((`test`.`t2`.`a` = `test`.`t1`.`a`) and (`test`.`t0`.`a` = `test`.`t1`.`a`) and (`test`.`t2`.`b` = `test`.`t1`.`b`)) +update t1 set a=3, b=11 where a=4; +update t2 set b=11 where a=3; +select * from t0 where t0.a in (select t1.a from t1, t2 where t2.a=t0.a and t1.b=t2.b); +a +0 +1 +2 +3 +drop table t0, t1, t2; +CREATE TABLE t1 ( +id int(11) NOT NULL, +PRIMARY KEY (id)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t2 ( +id int(11) NOT NULL, +fid int(11) NOT NULL, +PRIMARY KEY (id)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t1 values(1); +insert into t2 values(1,7503),(2,1); +explain select count(*) +from t1 +where fid IN (select fid from t2 where (id between 7502 and 8420) order by fid ); +ERROR 42S22: Unknown column 'fid' in 'IN/ALL/ANY subquery' +drop table t1, t2; +create table t1 (a int, b int, key (a), key (b)); +insert into t1 values (2,4),(2,4),(2,4); +select t1.a from t1 +where +t1.a in (select 1 from t1 where t1.a in (select 1 from t1) group by t1.a); +a +drop table t1; +create table t1(a int,b int,key(a),key(b)); +insert into t1 values (1,1),(2,2),(3,3); +select 1 from t1 +where t1.a not in (select 1 from t1 +where t1.a in (select 1 from t1) +group by t1.b); +1 +1 +1 +drop table t1; +CREATE TABLE t1 +(EMPNUM CHAR(3) NOT NULL, +EMPNAME CHAR(20), +GRADE DECIMAL(4), +CITY CHAR(15)); +CREATE TABLE t2 +(PNUM CHAR(3) NOT NULL, +PNAME CHAR(20), +PTYPE CHAR(6), +BUDGET DECIMAL(9), +CITY CHAR(15)); +CREATE TABLE t3 +(EMPNUM CHAR(3) NOT NULL, +PNUM CHAR(3) NOT NULL, +HOURS DECIMAL(5)); +INSERT INTO t1 VALUES ('E1','Alice',12,'Deale'); +INSERT INTO t1 VALUES ('E2','Betty',10,'Vienna'); +INSERT INTO t1 VALUES ('E3','Carmen',13,'Vienna'); +INSERT INTO t1 VALUES ('E4','Don',12,'Deale'); +INSERT INTO t1 VALUES ('E5','Ed',13,'Akron'); +INSERT INTO t2 VALUES ('P1','MXSS','Design',10000,'Deale'); +INSERT INTO t2 VALUES ('P2','CALM','Code',30000,'Vienna'); +INSERT INTO t2 VALUES ('P3','SDP','Test',30000,'Tampa'); +INSERT INTO t2 VALUES ('P4','SDP','Design',20000,'Deale'); +INSERT INTO t2 VALUES ('P5','IRM','Test',10000,'Vienna'); +INSERT INTO t2 VALUES ('P6','PAYR','Design',50000,'Deale'); +INSERT INTO t3 VALUES ('E1','P1',40); +INSERT INTO t3 VALUES ('E1','P2',20); +INSERT INTO t3 VALUES ('E1','P3',80); +INSERT INTO t3 VALUES ('E1','P4',20); +INSERT INTO t3 VALUES ('E1','P5',12); +INSERT INTO t3 VALUES ('E1','P6',12); +INSERT INTO t3 VALUES ('E2','P1',40); +INSERT INTO t3 VALUES ('E2','P2',80); +INSERT INTO t3 VALUES ('E3','P2',20); +INSERT INTO t3 VALUES ('E4','P2',20); +INSERT INTO t3 VALUES ('E4','P4',40); +INSERT INTO t3 VALUES ('E4','P5',80); +SELECT * FROM t1; +EMPNUM EMPNAME GRADE CITY +E1 Alice 12 Deale +E2 Betty 10 Vienna +E3 Carmen 13 Vienna +E4 Don 12 Deale +E5 Ed 13 Akron +CREATE UNIQUE INDEX t1_IDX ON t1(EMPNUM); +SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN +(SELECT EMPNUM +FROM t3 +WHERE PNUM IN +(SELECT PNUM +FROM t2 +WHERE PTYPE = 'Design')); +EMPNAME +Alice +Betty +Don +DROP INDEX t1_IDX ON t1; +CREATE INDEX t1_IDX ON t1(EMPNUM); +SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN +(SELECT EMPNUM +FROM t3 +WHERE PNUM IN +(SELECT PNUM +FROM t2 +WHERE PTYPE = 'Design')); +EMPNAME +Alice +Betty +Don +DROP INDEX t1_IDX ON t1; +SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN +(SELECT EMPNUM +FROM t3 +WHERE PNUM IN +(SELECT PNUM +FROM t2 +WHERE PTYPE = 'Design')); +EMPNAME +Alice +Betty +Don +DROP TABLE t1, t2, t3; +CREATE TABLE t1 (f1 INT NOT NULL); +CREATE VIEW v1 (a) AS SELECT f1 IN (SELECT f1 FROM t1) FROM t1; +SELECT * FROM v1; +a +drop view v1; +drop table t1; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1(a int, b int); +insert into t1 values (0,0),(1,1),(2,2); +create table t2 as select * from t1; +create table t3 (pk int, a int, primary key(pk)); +insert into t3 select a,a from t0; +explain +select * from t1 left join t2 on (t2.a= t1.a and t2.a in (select pk from t3)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE t3 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using index +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` left join (`test`.`t3` join `test`.`t2`) on(((`test`.`t3`.`pk` = `test`.`t1`.`a`) and (`test`.`t2`.`a` = `test`.`t1`.`a`))) where true +drop table t0, t1, t2, t3; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (a int) as select A.a + 10 *(B.a + 10*C.a) as a from t0 A, t0 B, t0 C; +create table t2 (id int, a int, primary key(id), key(a)) charset utf8mb4 as select a as id, a as a from t1; +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `id` int NOT NULL, + `a` int DEFAULT NULL, + PRIMARY KEY (`id`), + KEY `a` (`a`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +set @a=0; +create table t3 as select * from t2 limit 0; +insert into t3 select @a:=@a+1, t2.a from t2, t0; +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +insert into t3 select @a:=@a+1, t2.a from t2, t0; +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +insert into t3 select @a:=@a+1, t2.a from t2, t0; +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +alter table t3 add primary key(id), add 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); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index a a 5 NULL 1000 100.00 Using where; Using index +1 SIMPLE NULL eq_ref 5 test.t2.a 1 100.00 NULL +2 MATERIALIZED t3 NULL index a a 5 NULL 30000 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select count(`test`.`t2`.`a`) AS `count(a)` from `test`.`t2` semi join (`test`.`t3`) where (``.`a` = `test`.`t2`.`a`) +select count(a) from t2 where a in ( SELECT a FROM t3); +count(a) +1000 +drop table t0,t1,t2,t3; +# +# Bug#33062: subquery in stored routine cause crash +# +CREATE TABLE t1(a INT); +CREATE TABLE t2(c INT); +CREATE PROCEDURE p1(v1 int) +BEGIN +SELECT 1 FROM t1 WHERE a = v1 AND a IN (SELECT c FROM t2); +END +// +CREATE PROCEDURE p2(v1 int) +BEGIN +SELECT 1 FROM t1 WHERE a IN (SELECT c FROM t2); +END +// +CREATE PROCEDURE p3(v1 int) +BEGIN +SELECT 1 +FROM +t1 t01,t1 t02,t1 t03,t1 t04,t1 t05,t1 t06,t1 t07,t1 t08, +t1 t09,t1 t10,t1 t11,t1 t12,t1 t13,t1 t14,t1 t15,t1 t16, +t1 t17,t1 t18,t1 t19,t1 t20,t1 t21,t1 t22,t1 t23,t1 t24, +t1 t25,t1 t26,t1 t27,t1 t28,t1 t29,t1 t30,t1 t31,t1 t32, +t1 t33,t1 t34,t1 t35,t1 t36,t1 t37,t1 t38,t1 t39,t1 t40, +t1 t41,t1 t42,t1 t43,t1 t44,t1 t45,t1 t46,t1 t47,t1 t48, +t1 t49,t1 t50,t1 t51,t1 t52,t1 t53,t1 t54,t1 t55,t1 t56, +t1 t57,t1 t58,t1 t59,t1 t60 +WHERE t01.a IN (SELECT c FROM t2); +END +// +CREATE PROCEDURE p4(v1 int) +BEGIN +SELECT 1 +FROM +t1 t01,t1 t02,t1 t03,t1 t04,t1 t05,t1 t06,t1 t07,t1 t08, +t1 t09,t1 t10,t1 t11,t1 t12,t1 t13,t1 t14,t1 t15,t1 t16, +t1 t17,t1 t18,t1 t19,t1 t20,t1 t21,t1 t22,t1 t23,t1 t24, +t1 t25,t1 t26,t1 t27,t1 t28,t1 t29,t1 t30,t1 t31,t1 t32, +t1 t33,t1 t34,t1 t35,t1 t36,t1 t37,t1 t38,t1 t39,t1 t40, +t1 t41,t1 t42,t1 t43,t1 t44,t1 t45,t1 t46,t1 t47,t1 t48, +t1 t49,t1 t50,t1 t51,t1 t52,t1 t53,t1 t54,t1 t55,t1 t56, +t1 t57,t1 t58,t1 t59,t1 t60 +WHERE t01.a = v1 AND t01.a IN (SELECT c FROM t2); +END +// +CALL p1(1); +1 +CALL p2(1); +1 +CALL p3(1); +1 +CALL p4(1); +1 +DROP TABLE t1, t2; +DROP PROCEDURE p1; +DROP PROCEDURE p2; +DROP PROCEDURE p3; +DROP PROCEDURE p4; +# +# Bug#48213 Materialized subselect crashes if using GEOMETRY type +# +CREATE TABLE t1 ( +pk int, +a varchar(1), +b varchar(4), +c tinyblob, +d blob, +e mediumblob, +f longblob, +g tinytext, +h text, +i mediumtext, +j longtext, +k geometry, +PRIMARY KEY (pk) +) charset utf8mb4; +INSERT INTO t1 VALUES (1,'o','ffff','ffff','ffoo','ffff','ffff','ffff','ffff','ffff','ffff',ST_GeomFromText('POLYGON((0 0, 0 2, 2 2, 2 0, 0 0))')), (2,'f','ffff','ffff','ffff', 'ffff','ffff','ffff','ffff','ffff','ffff',ST_GeomFromText('POLYGON((0 0, 0 2, 2 2, 2 0, 0 0))')); +CREATE TABLE t2 LIKE t1; +INSERT INTO t2 VALUES (1,'i','iiii','iiii','iiii','iiii','ffff','ffff','ffff','ffff','ffff',ST_GeomFromText('POLYGON((0 0, 0 2, 2 2, 2 0, 0 0))')), (2,'f','ffff','ffff','ffff','ffff','ffff','ffff','ffff','ffff','ffff',ST_GeomFromText('POLYGON((0 0, 0 2, 2 2, 2 0, 0 0))')); +EXPLAIN SELECT pk FROM t1 WHERE (a, b) IN (SELECT a, b FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE NULL eq_ref 26 test.t1.a,test.t1.b 1 100.00 NULL +2 MATERIALIZED t2 NULL range PRIMARY PRIMARY 4 NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((``.`b` = `test`.`t1`.`b`) and (``.`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); +pk +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, c) IN (SELECT b, c FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t2 NULL range PRIMARY PRIMARY 4 NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((``.`c` = `test`.`t1`.`c`) and (``.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, c) IN (SELECT b, c FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, d) IN (SELECT b, d FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t2 NULL range PRIMARY PRIMARY 4 NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((``.`d` = `test`.`t1`.`d`) and (``.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, d) IN (SELECT b, d FROM t2 WHERE pk > 0); +pk +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, e) IN (SELECT b, e FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t2 NULL range PRIMARY PRIMARY 4 NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((``.`e` = `test`.`t1`.`e`) and (``.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, e) IN (SELECT b, e FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, f) IN (SELECT b, f FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t2 NULL range PRIMARY PRIMARY 4 NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((``.`f` = `test`.`t1`.`f`) and (``.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, f) IN (SELECT b, f FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, g) IN (SELECT b, g FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t2 NULL range PRIMARY PRIMARY 4 NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((``.`g` = `test`.`t1`.`g`) and (``.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, g) IN (SELECT b, g FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, h) IN (SELECT b, h FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t2 NULL range PRIMARY PRIMARY 4 NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((``.`h` = `test`.`t1`.`h`) and (``.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, h) IN (SELECT b, h FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, i) IN (SELECT b, i FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t2 NULL range PRIMARY PRIMARY 4 NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((``.`i` = `test`.`t1`.`i`) and (``.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, i) IN (SELECT b, i FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, j) IN (SELECT b, j FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t2 NULL range PRIMARY PRIMARY 4 NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((``.`j` = `test`.`t1`.`j`) and (``.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, j) IN (SELECT b, j FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, k) IN (SELECT b, k FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t2 NULL range PRIMARY PRIMARY 4 NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((``.`k` = `test`.`t1`.`k`) and (``.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, k) IN (SELECT b, k FROM t2 WHERE pk > 0); +pk +1 +2 +DROP TABLE t1, t2; +# End of Bug#48213 +# +# BUG#53060: LooseScan semijoin strategy does not return all rows +# +CREATE TABLE t1 (i INTEGER); +INSERT INTO t1 VALUES (1), (2), (3), (4), (5); +CREATE TABLE t2 (i INTEGER, j INTEGER, KEY k(i, j)); +INSERT INTO t2 VALUES (1, 0), (1, 1), (2, 0), (2, 1); +EXPLAIN +SELECT * FROM t1 WHERE (i) IN (SELECT i FROM t2 where j > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 20.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t2 NULL index k k 10 NULL 4 33.33 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`i` = ``.`i`) and (`test`.`t2`.`j` > 0)) +SELECT * FROM t1 WHERE (i) IN (SELECT i FROM t2 where j > 0); +i +1 +2 +DROP TABLE t1, t2; +# End of BUG#53060 +# +# Bug#53305 "Duplicate weedout + join buffer (join cache --level=7,8) loses rows" +# +create table t1 (uid int, fid int, index(uid)); +insert into t1 values +(1,1), (1,2), (1,3), (1,4), +(2,5), (2,6), (2,7), (2,8), +(3,1), (3,2), (3,9); +create table t2 (uid int primary key, name varchar(128), index(name)); +insert into t2 values +(1, "A"), (2, "B"), (3, "C"), (4, "D"), (5, "E"), +(6, "F"), (7, "G"), (8, "H"), (9, "I"); +create table t3 (uid int, fid int, index(uid)); +insert into t3 values +(1,1), (1,2), (1,3),(1,4), +(2,5), (2,6), (2,7), (2,8), +(3,1), (3,2), (3,9); +create table t4 (uid int primary key, name varchar(128), index(name)); +insert into t4 values +(1, "A"), (2, "B"), (3, "C"), (4, "D"), (5, "E"), +(6, "F"), (7, "G"), (8, "H"), (9, "I"); +explain select name from t2, t1 +where t1.uid in (select t4.uid from t4, t3 where t3.uid=1 and t4.uid=t3.fid) +and t2.uid=t1.fid; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ref uid uid 5 const 4 100.00 Using where; Start temporary +1 SIMPLE t4 NULL eq_ref PRIMARY PRIMARY 4 test.t3.fid 1 100.00 Using index +1 SIMPLE t1 NULL ref uid uid 5 test.t3.fid 2 100.00 Using where; End temporary +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.fid 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`name` AS `name` from `test`.`t4` join `test`.`t2` join `test`.`t1` semi join (`test`.`t3`) where ((`test`.`t4`.`uid` = `test`.`t3`.`fid`) and (`test`.`t1`.`uid` = `test`.`t3`.`fid`) and (`test`.`t3`.`uid` = 1) and (`test`.`t2`.`uid` = `test`.`t1`.`fid`)) +select name from t2, t1 +where t1.uid in (select t4.uid from t4, t3 where t3.uid=1 and t4.uid=t3.fid) +and t2.uid=t1.fid; +name +A +A +B +B +C +D +E +F +G +H +I +drop table t1,t2,t3,t4; +# +# Bug#43768 Prepared query with nested subqueries core dump on second execution +# +CREATE TABLE t1 ( +id INT PRIMARY KEY, +partner_id VARCHAR(35) +) charset utf8mb4; +INSERT INTO t1 VALUES +(1, 'partner1'), (2, 'partner2'), +(3, 'partner3'), (4, 'partner4'); +CREATE TABLE t2 ( +id INT NOT NULL, +t1_line_id INT, +article_id VARCHAR(20), +PRIMARY KEY(id, t1_line_id) +) charset utf8mb4; +INSERT INTO t2 VALUES +(1, 1, 'sup'), (2, 1, 'sup'), +(2, 2, 'sup'), (2, 3, 'sup'), +(2, 4, 'imp'), (3, 1, 'sup'), +(4, 1, 'sup'); +CREATE TABLE t3 ( +user_id VARCHAR(50), +article_id VARCHAR(20) NOT NULL, +PRIMARY KEY(user_id) +) charset utf8mb4; +INSERT INTO t3 VALUES('nicke', 'imp'); +EXPLAIN +SELECT t1.partner_id +FROM t1 +WHERE t1.id IN ( +SELECT t2.id +FROM t2 +WHERE article_id IN ( +SELECT article_id FROM t3 +WHERE user_id = 'nicke' + ) +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL system PRIMARY NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL PRIMARY NULL NULL NULL 7 14.29 Using where; Start temporary +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.id 1 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`partner_id` AS `partner_id` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`id` = `test`.`t2`.`id`) and (`test`.`t2`.`article_id` = 'imp')) +SELECT t1.partner_id +FROM t1 +WHERE t1.id IN ( +SELECT t2.id +FROM t2 +WHERE article_id IN ( +SELECT article_id FROM t3 +WHERE user_id = 'nicke' + ) +); +partner_id +partner2 +PREPARE stmt FROM +'EXPLAIN SELECT t1.partner_id +FROM t1 +WHERE t1.id IN ( + SELECT t2.id + FROM t2 + WHERE article_id IN ( + SELECT article_id FROM t3 + WHERE user_id = \'nicke\' + ) + )'; +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL system PRIMARY NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL PRIMARY NULL NULL NULL 7 14.29 Using where; Start temporary +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.id 1 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`partner_id` AS `partner_id` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`id` = `test`.`t2`.`id`) and (`test`.`t2`.`article_id` = 'imp')) + +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL system PRIMARY NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL PRIMARY NULL NULL NULL 7 14.29 Using where; Start temporary +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.id 1 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`partner_id` AS `partner_id` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`id` = `test`.`t2`.`id`) and (`test`.`t2`.`article_id` = 'imp')) +PREPARE stmt FROM +'SELECT t1.partner_id +FROM t1 +WHERE t1.id IN ( + SELECT t2.id + FROM t2 + WHERE article_id IN ( + SELECT article_id FROM t3 + WHERE user_id = \'nicke\' + ) + )'; +EXECUTE stmt; +partner_id +partner2 + +EXECUTE stmt; +partner_id +partner2 +DROP TABLE t1,t2,t3; +# End of Bug#43768 +# +# Bug#53058 - semijoin execution of subquery with outerjoin yields wrong result +# +CREATE TABLE t1 (i INTEGER); +CREATE TABLE t2 (i INTEGER); +CREATE TABLE t3 (i INTEGER); +INSERT INTO t1 VALUES (1), (2); +INSERT INTO t2 VALUES (6); +INSERT INTO t3 VALUES (1), (2); +explain SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t3 LEFT JOIN t2 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t3 LEFT JOIN t2 ON t2.i=t3.i); +i +1 +2 +drop table t1,t2,t3; +# +# BUG#49453: re-execution of prepared statement with view +# and semijoin crashes +# +CREATE TABLE t1 (city VARCHAR(50), country_id INT); +CREATE TABLE t2 (country_id INT, country VARCHAR(50)); +INSERT INTO t1 VALUES +('Batna',2),('Bchar',2),('Skikda',2),('Tafuna',3),('Algeria',2) ; +INSERT INTO t2 VALUES (2,'Algeria'),(2,'AlgeriaDup'),(3,'XAmerican Samoa'); +CREATE VIEW v1 AS +SELECT country_id as vf_country_id +FROM t2 +WHERE LEFT(country,1) = "A"; +PREPARE stmt FROM " +SELECT city, country_id +FROM t1 +WHERE country_id IN (SELECT vf_country_id FROM v1); +"; + +EXECUTE stmt; +city country_id +Algeria 2 +Batna 2 +Bchar 2 +Skikda 2 + +EXECUTE stmt; +city country_id +Algeria 2 +Batna 2 +Bchar 2 +Skikda 2 +DROP TABLE t1,t2; +DROP VIEW v1; +# +# Bug#54437 Extra rows with LEFT JOIN + semijoin (firstmatch +# and duplicates weedout) +# +create table t1 (a int); +create table t2 (a int); +create table t3 (a int); +insert into t1 values(1),(1); +insert into t2 values(1),(1),(1),(1); +insert into t3 values(2),(2); +explain select * from t1 where t1.a in (select t2.a from t2 left join t3 on t2.a=t3.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE NULL eq_ref 5 test.t1.a 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t2` left join `test`.`t3` on((`test`.`t2`.`a` = `test`.`t3`.`a`))) where (``.`a` = `test`.`t1`.`a`) +select * from t1 where t1.a in (select t2.a from t2 left join t3 on t2.a=t3.a); +a +1 +1 +drop table t1,t2,t3; +# +# Bug#55955: crash in MEMORY engine with IN(LEFT JOIN (JOIN)) +# +CREATE TABLE t1 (a INT); +CREATE TABLE t2 (a INT); +CREATE TABLE t3 (a INT); +INSERT INTO t1 VALUES(1),(1); +INSERT INTO t2 VALUES(1),(1); +INSERT INTO t3 VALUES(2),(2); +explain SELECT * FROM t1 +WHERE t1.a IN (SELECT t2.a +FROM t2 LEFT JOIN (t2 AS t2inner, t3) ON t2.a=t3.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE NULL eq_ref 5 test.t1.a 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t2inner NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t2` left join (`test`.`t2` `t2inner` join `test`.`t3`) on((`test`.`t2`.`a` = `test`.`t3`.`a`))) where (``.`a` = `test`.`t1`.`a`) +SELECT * FROM t1 +WHERE t1.a IN (SELECT t2.a +FROM t2 LEFT JOIN (t2 AS t2inner, t3) ON t2.a=t3.a); +a +1 +1 +DROP TABLE t1,t2,t3; +# +# BUG#52329 - Wrong result: subquery materialization, IN, +# non-null field followed by nullable +# +CREATE TABLE t1 (a1 CHAR(8) NOT NULL, a2 char(8) NOT NULL); +CREATE TABLE t2a (b1 char(8), b2 char(8)); +CREATE TABLE t2b (b1 CHAR(8), b2 char(8) NOT NULL); +CREATE TABLE t2c (b1 CHAR(8) NOT NULL, b2 char(8)); +INSERT INTO t1 VALUES ('1 - 12', '2 - 22'); +INSERT INTO t2a VALUES ('1 - 11', '2 - 21'), +('1 - 11', '2 - 21'), +('1 - 12', '2 - 22'), +('1 - 12', '2 - 22'), +('1 - 13', '2 - 23'); +INSERT INTO t2b SELECT * FROM t2a; +INSERT INTO t2c SELECT * FROM t2a; +SELECT * FROM t1 +WHERE (a1, a2) IN ( +SELECT b1, b2 FROM t2c WHERE b1 > '0' GROUP BY b1, b2); +a1 a2 +1 - 12 2 - 22 +SELECT * FROM t1 +WHERE (a1, a2) IN ( +SELECT b1, b2 FROM t2a WHERE b1 > '0'); +a1 a2 +1 - 12 2 - 22 +SELECT * FROM t1 +WHERE (a1, a2) IN ( +SELECT b1, b2 FROM t2b WHERE b1 > '0'); +a1 a2 +1 - 12 2 - 22 +SELECT * FROM t1 +WHERE (a1, a2) IN ( +SELECT b1, b2 FROM t2c WHERE b1 > '0'); +a1 a2 +1 - 12 2 - 22 +DROP TABLE t1,t2a,t2b,t2c; +# End BUG#52329 +# +# Bug#45174: Incorrectly applied equality propagation caused wrong +# result on a query with a materialized semi-join. +# +CREATE TABLE t1 ( +varchar_nokey varchar(1) NOT NULL +) charset utf8mb4; +INSERT INTO t1 VALUES +('v'), ('u'), ('n'), ('l'), ('h'), ('u'), ('n'), ('j'), ('k'), +('e'), ('i'), ('u'), ('n'), ('b'), ('x'), (''), ('q'), ('u'); +CREATE TABLE t2 ( +pk int NOT NULL, +varchar_key varchar(1) NOT NULL, +varchar_nokey varchar(1) NOT NULL, +PRIMARY KEY(pk), +KEY varchar_key(varchar_key) +) charset utf8mb4; +INSERT INTO t2 VALUES +(11,'m','m'), (12,'j','j'), (13,'z','z'), (14,'a','a'), (15,'',''), +(16,'e','e'), (17,'t','t'), (19,'b','b'), (20,'w','w'), (21,'m','m'), +(23,'',''), (24,'w','w'), (26,'e','e'), (27,'e','e'), (28,'p','p'); +SELECT varchar_nokey +FROM t1 +WHERE (varchar_nokey, varchar_nokey) IN (SELECT varchar_key, varchar_nokey +FROM t2 +WHERE varchar_nokey < 'n' XOR pk); +varchar_nokey +explain SELECT varchar_nokey +FROM t1 +WHERE (varchar_nokey, varchar_nokey) IN (SELECT varchar_key, varchar_nokey +FROM t2 +WHERE varchar_nokey < 'n' XOR pk); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 18 100.00 NULL +1 SIMPLE NULL eq_ref 12 test.t1.varchar_nokey,test.t1.varchar_nokey 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL varchar_key NULL NULL NULL 15 63.34 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`varchar_nokey` AS `varchar_nokey` from `test`.`t1` semi join (`test`.`t2`) where ((``.`varchar_key` = `test`.`t1`.`varchar_nokey`) and (``.`varchar_nokey` = `test`.`t1`.`varchar_nokey`) and (`test`.`t2`.`varchar_nokey` = `test`.`t2`.`varchar_key`) and ((`test`.`t2`.`varchar_nokey` < 'n') xor (0 <> `test`.`t2`.`pk`))) +DROP TABLE t1, t2; +# End of the test for bug#45174. +# +# Bug#50019: Wrong result for IN-query with materialization +# +CREATE TABLE t1(i INT); +INSERT INTO t1 VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10); +CREATE TABLE t2(i INT); +INSERT INTO t2 VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10); +CREATE TABLE t3(i INT); +INSERT INTO t3 VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10); +SELECT * FROM t1 WHERE t1.i IN (SELECT t2.i +FROM t2 JOIN t3 +WHERE t2.i + t3.i = 5); +i +1 +2 +3 +4 +explain SELECT * FROM t1 WHERE t1.i IN (SELECT t2.i +FROM t2 JOIN t3 +WHERE t2.i + t3.i = 5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 100.00 Using where +1 SIMPLE NULL eq_ref 5 test.t1.i 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 10 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 10 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = `test`.`t1`.`i`) and ((`test`.`t2`.`i` + `test`.`t3`.`i`) = 5)) +DROP TABLE t1,t2,t3; +# End of the test for bug#50019. +# +# Bug#52068: Optimizer generates invalid semijoin materialization plan +# +CREATE TABLE ot1(a INTEGER); +INSERT INTO ot1 VALUES(5), (8); +CREATE TABLE it2(a INTEGER); +INSERT INTO it2 VALUES(9), (5), (1), (8); +CREATE TABLE it3(a INTEGER); +INSERT INTO it3 VALUES(7), (1), (0), (5), (1), (4); +CREATE TABLE ot4(a INTEGER); +INSERT INTO ot4 VALUES(1), (3), (5), (7), (9), (7), (3), (1); +SELECT * FROM ot1,ot4 +WHERE (ot1.a,ot4.a) IN (SELECT it2.a,it3.a +FROM it2,it3); +a a +5 1 +5 1 +5 5 +5 7 +5 7 +8 1 +8 1 +8 5 +8 7 +8 7 +explain SELECT * FROM ot1,ot4 +WHERE (ot1.a,ot4.a) IN (SELECT it2.a,it3.a +FROM it2,it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using where; Using join buffer (hash join) +1 SIMPLE ot4 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; Using join buffer (hash join) +2 MATERIALIZED it2 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +2 MATERIALIZED it3 NULL ALL NULL NULL NULL NULL 6 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot4`.`a` AS `a` from `test`.`ot1` join `test`.`ot4` semi join (`test`.`it2` join `test`.`it3`) where ((`test`.`ot4`.`a` = ``.`a`) and (``.`a` = `test`.`ot1`.`a`)) +DROP TABLE IF EXISTS ot1, ot4, it2, it3; +# End of the test for bug#52068. +# +# Bug#57623: subquery within before insert trigger causes crash (sj=on) +# +CREATE TABLE ot1(a INT); +CREATE TABLE ot2(a INT); +CREATE TABLE ot3(a INT); +CREATE TABLE it1(a INT); +INSERT INTO ot1 VALUES(0),(1),(2),(3),(4),(5),(6),(7); +INSERT INTO ot2 VALUES(0),(2),(4),(6); +INSERT INTO ot3 VALUES(0),(3),(6); +INSERT INTO it1 VALUES(0),(1),(2),(3),(4),(5),(6),(7); +explain SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 on ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a from it1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +1 SIMPLE NULL eq_ref 5 test.ot1.a 1 100.00 NULL +1 SIMPLE ot3 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +2 MATERIALIZED it1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a`,`test`.`ot3`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` join `test`.`ot3` semi join (`test`.`it1`)) on(((``.`a` = `test`.`ot1`.`a`) and (`test`.`ot3`.`a` = `test`.`ot1`.`a`) and (`test`.`ot2`.`a` = `test`.`ot1`.`a`))) where true +SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 on ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a from it1); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +prepare s from 'SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 on ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a from it1)'; +execute s; +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +execute s; +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +deallocate prepare s; +DROP TABLE ot1, ot2, ot3, it1; +# End of the test for bug#57623. +# +# Bug#11766739: Crash in tmp_table_param::init() with semijoin=on +# +CREATE TABLE t1 (f1 INTEGER) ENGINE=MyISAM; +CREATE TABLE t2 (f1 INTEGER, f2 INTEGER) ENGINE=MyISAM; +INSERT INTO t1 VALUES (1); +INSERT INTO t2 VALUES (1,1), (2,1); +EXPLAIN SELECT * FROM t2 +WHERE f2 IN (SELECT t1.f1 +FROM t1 LEFT OUTER JOIN (t2 AS b1 JOIN t2 AS b2 ON TRUE) ON TRUE); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 MATERIALIZED b1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +2 MATERIALIZED b2 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`f1` AS `f1`,`test`.`t2`.`f2` AS `f2` from `test`.`t2` semi join (`test`.`t1` left join (`test`.`t2` `b1` join `test`.`t2` `b2`) on((true))) where (`test`.`t2`.`f2` = ``.`f1`) +SELECT * FROM t2 +WHERE f2 IN (SELECT t1.f1 +FROM t1 LEFT OUTER JOIN (t2 AS b1 JOIN t2 AS b2 ON TRUE) ON TRUE); +f1 f2 +1 1 +2 1 +DROP TABLE t1, t2; +# End of the test for bug#11766739. +# +# Bug#11766642: crash in Item_field::register_field_in_read_map with view +# +CREATE TABLE t1(a INT); +CREATE VIEW v1 AS SELECT a FROM t1; +INSERT INTO t1 VALUES (0),(1),(2); +SELECT a FROM t1 WHERE a IN +(SELECT a XOR a FROM v1) +ORDER BY a; +a +0 +DROP TABLE t1; +DROP VIEW v1; +# +# Bug#12546542 MISSING ROW WHEN USING OPTIMIZER_JOIN_CACHE_LEVEL>=3 +# +CREATE TABLE t1 ( +f2 varchar(1024) +); +INSERT INTO t1 VALUES ('v'),('we'); +CREATE TABLE t2 ( +col_varchar_1024_utf8 varchar(1024) CHARACTER SET utf8 DEFAULT NULL, +col_int_key int, +col_int int +); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t2 VALUES ('we',4,NULL),('v',1305673728,6); +CREATE TABLE t3 ( +col_int_key int, +col_int int +); +INSERT INTO t3 VALUES (4,4); +SELECT * +FROM t1 +WHERE f2 IN (SELECT a1.col_varchar_1024_utf8 AS f2 +FROM t2 AS a1 LEFT JOIN t3 AS a2 +ON a1.col_int_key = a2.col_int_key +WHERE a1.col_int BETWEEN 1 AND 10 OR a2.col_int IS NOT NULL); +f2 +v +we +DROP TABLE t1,t2,t3; +# +# BUG#12616344 - JCL: DIFFERENT RESULT SET AND DIFFERENT AMOUNT +# OF ROWS WHEN JCL>=3 +# +CREATE TABLE t1 (col_int_nokey int, col_int_key int, col_varchar_key varchar(1)); +INSERT INTO t1 VALUES (0,4,'c'),(1,6,'u'); +CREATE TABLE t2 (pk int, col_int_nokey int, col_varchar_nokey varchar(1)); +INSERT INTO t2 VALUES (1,4,'b'),(94,6,'u'); +CREATE TABLE t3 (pk int, col_int_nokey int, col_varchar_key varchar(1)); +INSERT INTO t3 VALUES (1,4,'j'),(2,6,'v'); +SELECT table2.col_int_key +from t3 as table1 join t1 as table2 on table2.col_int_nokey +where table1.col_int_nokey in +( +select subquery2_t2.col_int_nokey +from t3 as subquery2_t1 +right join +t2 as subquery2_t2 +join t1 as subquery2_t3 +on subquery2_t3.col_int_key = subquery2_t2.col_int_nokey +on subquery2_t3.col_varchar_key = subquery2_t2.col_varchar_nokey +where subquery2_t1.col_varchar_key != table1.col_varchar_key +or subquery2_t2.pk <= table1.pk +); +col_int_key +6 +6 +DROP TABLE t1,t2,t3; +# +# Bug#12608157: ASSERT IN FIELD_LONG::VAL_INT WHEN USING MEMORY ENGINE +# +CREATE TABLE t1 (i1 int); +INSERT INTO t1 VALUES (1); +CREATE TABLE t2 (i1 int, i2 int) ENGINE=memory; +INSERT INTO t2 VALUES (1, 2),(7, 3); +SELECT GRANDPARENT1.i1 +FROM t2 AS GRANDPARENT1 +WHERE GRANDPARENT1.i2 +IN ( SELECT PARENT1.i2 +FROM t2 AS PARENT1 JOIN t1 AS PARENT2 ON (PARENT1.i1 = PARENT2.i1) +WHERE +GRANDPARENT1.i1 IN ( SELECT CHILD1.i1 FROM t2 AS CHILD1 ) +ORDER BY PARENT1.i1) +ORDER BY GRANDPARENT1.i2 ; +i1 +1 +DROP TABLE t1,t2; +# +# Bug#12640083: Same query executed as WHERE subquery gives different +# results on IN() compare +# +CREATE TABLE t1 ( +pk int NOT NULL, +col_varchar_1024_utf8_key varchar(1024) CHARACTER SET utf8 DEFAULT NULL, +col_varchar_10_latin1_key varchar(10) DEFAULT NULL, +PRIMARY KEY (pk), +KEY col_varchar_1024_utf8_key(col_varchar_1024_utf8_key(333)), +KEY col_varchar_10_latin1_key(col_varchar_10_latin1_key) +) charset utf8mb4; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES +(1, 'a', 'a'), +(2, 'ab', 'ab'), +(3, 'abc', 'abc'), +(4, 'abcd', 'abcd'); +CREATE TABLE t2 ( +pk int NOT NULL AUTO_INCREMENT, +PRIMARY KEY (pk) +) charset utf8mb4 ENGINE=Innodb; +CREATE TABLE t3 charset utf8mb4 +SELECT alias1.col_varchar_10_latin1_key +FROM t1 AS alias1 +LEFT JOIN t1 AS alias2 +JOIN t2 AS alias3 +ON alias2.col_varchar_10_latin1_key +ON alias1.col_varchar_1024_utf8_key +WHERE alias1.pk AND alias1.pk < 3 OR alias1.pk AND alias3.pk; +EXPLAIN SELECT * +FROM t3 +WHERE col_varchar_10_latin1_key IN ( +SELECT alias1.col_varchar_10_latin1_key +FROM t1 AS alias1 +LEFT JOIN t1 AS alias2 +JOIN t2 AS alias3 +ON alias2.col_varchar_10_latin1_key +ON alias1.col_varchar_1024_utf8_key +WHERE alias1.pk AND alias1.pk < 3 OR alias1.pk AND alias3.pk); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE NULL eq_ref 43 test.t3.col_varchar_10_latin1_key 1 100.00 NULL +2 MATERIALIZED alias1 NULL range PRIMARY,col_varchar_10_latin1_key PRIMARY 4 NULL 5 100.00 Using where +2 MATERIALIZED alias3 NULL index NULL PRIMARY 4 NULL 1 100.00 Using where; Using index; Using join buffer (hash join) +2 MATERIALIZED alias2 NULL index NULL col_varchar_10_latin1_key 43 NULL 4 100.00 Using where; Using index; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`col_varchar_10_latin1_key` AS `col_varchar_10_latin1_key` from `test`.`t3` semi join (`test`.`t1` `alias1` left join (`test`.`t1` `alias2` join `test`.`t2` `alias3`) on(((0 <> `test`.`alias1`.`col_varchar_1024_utf8_key`) and (0 <> `test`.`alias2`.`col_varchar_10_latin1_key`)))) where ((``.`col_varchar_10_latin1_key` = `test`.`t3`.`col_varchar_10_latin1_key`) and (((0 <> `test`.`alias1`.`pk`) and (`test`.`alias1`.`pk` < 3)) or ((0 <> `test`.`alias1`.`pk`) and (0 <> `test`.`alias3`.`pk`)))) +SELECT * +FROM t3 +WHERE col_varchar_10_latin1_key IN ( +SELECT alias1.col_varchar_10_latin1_key +FROM t1 AS alias1 +LEFT JOIN t1 AS alias2 +JOIN t2 AS alias3 +ON alias2.col_varchar_10_latin1_key +ON alias1.col_varchar_1024_utf8_key +WHERE alias1.pk AND alias1.pk < 3 OR alias1.pk AND alias3.pk); +col_varchar_10_latin1_key +a +ab +DROP TABLE t1, t2, t3; +# End of the test for bug#12640083. +# +# Bug#12603200 - Assert in QUICK_INDEX_MERGE_SELECT::need_sorted_output +# +CREATE TABLE t1 ( +pk int NOT NULL, +col_int_key int NOT NULL, +col_varchar_nokey varchar(1) NOT NULL, +col_varchar_key varchar(1) NOT NULL, +PRIMARY KEY(pk), +KEY col_int_key(col_int_key), +KEY col_varchar_key(col_varchar_key, col_int_key) +) charset utf8mb4 engine=innodb; +INSERT INTO t1 VALUES +(1,7,'a','a'), +(2,0,'v','v'), +(3,9,'c','c'), +(4,3,'m','m'), +(5,2,'a','a'), +(6,1,'d','d'), +(7,8,'y','y'), +(8,6,'t','t'), +(11,7,'a','x'), +(12,0,'v','v'), +(13,9,'c','c'), +(14,3,'m','m'), +(15,2,'a','x'), +(16,1,'d','d'), +(17,8,'y','y'), +(18,6,'t','u'), +(19,6,'t','u'); +CREATE TABLE t2 ( +pk int NOT NULL, +col_int_key int NOT NULL, +col_varchar_key varchar(1) NOT NULL, +PRIMARY KEY(pk), +KEY col_varchar_key(col_varchar_key, col_int_key) +) charset utf8mb4 engine=innodb; +INSERT INTO t2(pk,col_int_key,col_varchar_key) VALUES +(8,7,'c'), +(11,4,'l'), +(12,7,'b'), +(13,0,'c'), +(14,2,'i'), +(15,9,'h'), +(16,4,'q'), +(17,1,'m'), +(18,9,'b'), +(19,2,'e'), +(20,1,'c'), +(21,7,'z'), +(22,4,'l'), +(23,7,'z'), +(24,0,'c'), +(25,2,'i'), +(26,9,'h'), +(27,4,'q'), +(28,0,'a'), +(29,1,'d'); +EXPLAIN SELECT outr.col_varchar_key AS x, outr.pk AS y +FROM t1 AS outr +WHERE outr.col_varchar_key IN (SELECT innr.col_varchar_key +FROM t2 AS innr +WHERE innr.col_varchar_key = 'a' OR innr.pk = 8) +AND outr.col_varchar_nokey < 't' +ORDER BY outr.col_varchar_key, outr.pk; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using temporary; Using filesort +1 SIMPLE outr NULL ref col_varchar_key col_varchar_key 6 .col_varchar_key 1 33.33 Using where +2 MATERIALIZED innr NULL index_merge PRIMARY,col_varchar_key col_varchar_key,PRIMARY 6,4 NULL 2 100.00 Using sort_union(col_varchar_key,PRIMARY); Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`outr`.`col_varchar_key` AS `x`,`test`.`outr`.`pk` AS `y` from `test`.`t1` `outr` semi join (`test`.`t2` `innr`) where ((`test`.`outr`.`col_varchar_key` = ``.`col_varchar_key`) and (`test`.`outr`.`col_varchar_nokey` < 't') and (((``.`col_varchar_key` = 'a') and (`test`.`innr`.`col_varchar_key` = 'a')) or (`test`.`innr`.`pk` = 8))) order by `test`.`outr`.`col_varchar_key`,`test`.`outr`.`pk` +SELECT outr.col_varchar_key AS x, outr.pk AS y +FROM t1 AS outr +WHERE outr.col_varchar_key IN (SELECT innr.col_varchar_key +FROM t2 AS innr +WHERE innr.col_varchar_key = 'a' OR innr.pk = 8) +AND outr.col_varchar_nokey < 't' +ORDER BY outr.col_varchar_key, outr.pk; +x y +a 1 +a 5 +c 3 +c 13 +DROP TABLE t1, t2; +# End of bug#12603200 +# +# Bug#12603183: Segfault in hp_movelink +# +CREATE TABLE t1 ( +col_varchar_key varchar(1) , +col_varchar_nokey varchar(1) , +KEY col_varchar_key(col_varchar_key) +) charset latin1; +INSERT INTO t1 VALUES +('i','i'), +('h','h'), +('q','q'), +('a','a'), +('v','v'), +('u','u'), +('s','s'), +('y','y'), +('z','z'), +('h','h'), +('p','p'), +('e','e'), +('i','i'), +('y','y'), +('w','w'); +CREATE TABLE t2 ( +col_varchar_nokey varchar(1) +) charset latin1; +INSERT INTO t2 VALUES +('b'); +EXPLAIN SELECT grandparent1.col_varchar_nokey +FROM t1 AS grandparent1 LEFT JOIN t2 AS grandparent2 USING (col_varchar_nokey) +WHERE (grandparent1.col_varchar_key) IN +(SELECT parent1.col_varchar_nokey +FROM t1 AS parent1 +WHERE parent1.col_varchar_key IN +(SELECT child1.col_varchar_nokey AS c1 +FROM t1 AS child1 LEFT JOIN t2 AS child2 +ON (child1.col_varchar_key > child2.col_varchar_nokey))); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using where +1 SIMPLE grandparent1 NULL ref col_varchar_key col_varchar_key 4 .col_varchar_nokey 2 100.00 NULL +1 SIMPLE grandparent2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +2 MATERIALIZED child1 NULL ALL NULL NULL NULL NULL 15 100.00 Using where +2 MATERIALIZED child2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +2 MATERIALIZED parent1 NULL ref col_varchar_key col_varchar_key 4 test.child1.col_varchar_nokey 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`grandparent1`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t1` `grandparent1` left join `test`.`t2` `grandparent2` on((`test`.`grandparent2`.`col_varchar_nokey` = `test`.`grandparent1`.`col_varchar_nokey`)) semi join (`test`.`t1` `parent1` join `test`.`t1` `child1` left join `test`.`t2` `child2` on((`test`.`child1`.`col_varchar_key` > `test`.`child2`.`col_varchar_nokey`))) where ((`test`.`grandparent1`.`col_varchar_key` = ``.`col_varchar_nokey`) and (`test`.`parent1`.`col_varchar_key` = `test`.`child1`.`col_varchar_nokey`)) +SELECT grandparent1.col_varchar_nokey +FROM t1 AS grandparent1 LEFT JOIN t2 AS grandparent2 USING (col_varchar_nokey) +WHERE (grandparent1.col_varchar_key) IN +(SELECT parent1.col_varchar_nokey +FROM t1 AS parent1 +WHERE parent1.col_varchar_key IN +(SELECT child1.col_varchar_nokey AS c1 +FROM t1 AS child1 LEFT JOIN t2 AS child2 +ON (child1.col_varchar_key > child2.col_varchar_nokey))); +col_varchar_nokey +a +e +h +h +i +i +p +q +s +u +v +w +y +y +z +DROP TABLE t1, t2; +# End of test for bug#12603183. +# +# Bug#12818569: Diff nr of rows returned when using IN/ALL+subquery +# +CREATE TABLE t1 ( +col_int_key INT NOT NULL, +col_datetime_key DATETIME NOT NULL, +col_varchar_key VARCHAR(1) NOT NULL, +KEY col_int_key (col_int_key), +KEY col_datetime_key(col_datetime_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t1 VALUES +(7,'2004-06-06 04:22:12','v'), (0,'2005-11-13 01:12:31','s'), +(9,'2002-05-04 01:50:00','l'), (3,'2004-10-27 10:28:45','y'), +(4,'2006-07-22 05:24:23','c'), (2,'2002-05-16 21:34:03','i'), +(5,'2008-04-17 10:45:30','h'), (3,'2009-04-21 02:58:02','q'), +(1,'2008-01-11 11:01:51','a'), (3,'1900-01-01 00:00:00','v'), +(6,'2007-05-17 18:24:57','u'), (7,'2007-08-07 00:00:00','s'), +(5,'2001-08-28 00:00:00','y'), (1,'2004-04-16 00:27:28','z'), +(204,'2005-05-03 07:06:22','h'), (224,'2009-03-11 17:09:50','p'), +(9,'2007-12-08 01:54:28','e'), (5,'2009-07-28 18:19:54','i'), +(0,'2008-06-08 00:00:00','y'), (3,'2005-02-09 09:20:26','w'); +CREATE TABLE t2 ( +col_varchar_nokey VARCHAR(1) NOT NULL +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t2 VALUES ('v'), ('y'), ('j'), ('c'), ('d'), ('r'); +explain SELECT col_varchar_key +FROM t1 +WHERE col_varchar_key IN (SELECT col_varchar_nokey +FROM t2) +ORDER BY col_datetime_key LIMIT 4; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL col_varchar_key NULL NULL NULL 20 100.00 Using filesort +1 SIMPLE NULL eq_ref 6 test.t1.col_varchar_key 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 6 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col_varchar_key` AS `col_varchar_key` from `test`.`t1` semi join (`test`.`t2`) where (``.`col_varchar_nokey` = `test`.`t1`.`col_varchar_key`) order by `test`.`t1`.`col_datetime_key` limit 4 +SELECT col_varchar_key +FROM t1 +WHERE col_varchar_key IN (SELECT col_varchar_nokey +FROM t2) +ORDER BY col_datetime_key LIMIT 4; +col_varchar_key +v +y +v +y +DROP TABLE t1, t2; +# End of test for bug#12818569. +# +# Bug#12803439: Assert in replace_subcondition() on update query +# +CREATE TABLE t1(a INTEGER); +INSERT INTO t1 values(1), (2); +CREATE TABLE t2(a INTEGER); +INSERT INTO t2 VALUES(1), (3); +SELECT * +FROM t1 +WHERE a IN (SELECT a +FROM t2 +HAVING a IN (SELECT a +FROM t2) +) +HAVING a IN (SELECT a +FROM t2); +a +1 +DROP TABLE t1, t2; +# End of test for bug#12803439. +# +# Bug#12797534: Segfault in hp_movelink still exists +# +CREATE TABLE t1 ( +g1 VARCHAR(1) NOT NULL +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t1 VALUES ('d'), ('s'); +CREATE TABLE t2 ( +pk INT NOT NULL, +col_int_key INT NOT NULL, +col_varchar_key VARCHAR(1) NOT NULL, +col_varchar_nokey VARCHAR(1) NOT NULL, +PRIMARY KEY (pk), +KEY col_varchar_key(col_varchar_key, col_int_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t2 VALUES +(1,4,'j','j'), (2,6,'v','v'), (3,3,'c','c'), (4,5,'m','m'), +(5,3,'d','d'), (6,246,'d','d'), (7,2,'y','y'), (8,9,'t','t'), +(9,3,'d','d'), (10,8,'s','s'), (11,1,'r','r'), (12,8,'m','m'), +(13,8,'b','b'), (14,5,'x','x'), (15,7,'g','g'), (16,5,'p','p'), +(17,1,'q','q'), (18,6,'w','w'), (19,2,'d','d'), (20,9,'e','e'); +CREATE TABLE t3 ( +pk INTEGER NOT NULL, +PRIMARY KEY (pk) +) ENGINE=InnoDB; +INSERT INTO t3 VALUES (10); +EXPLAIN SELECT * +FROM t1 +WHERE g1 NOT IN +(SELECT grandparent1.col_varchar_nokey AS g1 +FROM t2 AS grandparent1 +WHERE grandparent1.col_varchar_key IN +(SELECT parent1.col_varchar_nokey AS p1 +FROM t2 AS parent1 LEFT JOIN t3 AS parent2 USING (pk) +) +AND grandparent1.col_varchar_key IS NOT NULL +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE NULL eq_ref 7 test.t1.g1 1 100.00 Using where; Not exists +2 MATERIALIZED parent1 NULL ALL NULL NULL NULL NULL 20 100.00 NULL +2 MATERIALIZED parent2 NULL eq_ref PRIMARY PRIMARY 4 test.parent1.pk 1 100.00 Using index +2 MATERIALIZED grandparent1 NULL ref col_varchar_key col_varchar_key 6 test.parent1.col_varchar_nokey 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`g1` AS `g1` from `test`.`t1` anti join (`test`.`t2` `grandparent1` join `test`.`t2` `parent1` left join `test`.`t3` `parent2` on((`test`.`parent2`.`pk` = `test`.`parent1`.`pk`))) on(((``.`g1` = `test`.`t1`.`g1`) and (`test`.`grandparent1`.`col_varchar_key` = `test`.`parent1`.`col_varchar_nokey`) and (`test`.`grandparent1`.`col_varchar_key` is not null))) where true +SELECT * +FROM t1 +WHERE g1 NOT IN +(SELECT grandparent1.col_varchar_nokey AS g1 +FROM t2 AS grandparent1 +WHERE grandparent1.col_varchar_key IN +(SELECT parent1.col_varchar_nokey AS p1 +FROM t2 AS parent1 LEFT JOIN t3 AS parent2 USING (pk) +) +AND grandparent1.col_varchar_key IS NOT NULL +); +g1 +DROP TABLE t1, t2, t3; +CREATE TABLE t1 ( +pk INTEGER AUTO_INCREMENT, +col_int_key INTEGER , +col_varchar_key VARCHAR(1) , +col_varchar_nokey VARCHAR(1) , +PRIMARY KEY (pk), +KEY (col_varchar_key,col_int_key) +) ENGINE=INNODB; +INSERT INTO t1 (col_int_key,col_varchar_key,col_varchar_nokey) VALUES +(0,'x','x'), (1,'j','j'), (1,'r','r'), (9,'v','v'), (5,'r','r'); +CREATE TABLE t2 ( +pk INTEGER AUTO_INCREMENT, +col_int_key INTEGER , +col_varchar_key VARCHAR(1) , +col_varchar_nokey VARCHAR(1) , +PRIMARY KEY (pk), +KEY (col_int_key), +KEY (col_varchar_key,col_int_key) +) AUTO_INCREMENT=10 ENGINE=INNODB; +INSERT INTO t2 (col_int_key, col_varchar_key, col_varchar_nokey) VALUES +(NULL,'x','x'), (NULL,'j','j'), (8,'c','c'); +CREATE TABLE t3 +SELECT outr.col_varchar_nokey AS x +FROM t1 AS outr +WHERE outr.col_varchar_nokey IN +(SELECT innr.col_varchar_nokey AS y +FROM t2 AS innr +WHERE innr.col_int_key IS NULL) +AND outr.col_varchar_nokey IS NOT NULL +AND NOT col_varchar_key IS NULL; +SELECT * +FROM t3 +WHERE x NOT IN +(SELECT outr.col_varchar_nokey AS x +FROM t1 AS outr +WHERE outr.col_varchar_nokey IN +(SELECT innr.col_varchar_nokey AS y +FROM t2 AS innr +WHERE innr.col_int_key IS NULL) +AND outr.col_varchar_nokey IS NOT NULL +AND NOT col_varchar_key IS NULL); +x +DROP TABLE t1, t2, t3; +# End of test for bug#12797534. +# +# Bug#12714094: Assert in optimize_semijoin_nests() +# +CREATE TABLE it ( +pk int NOT NULL, +col_varchar VARCHAR(10) DEFAULT NULL, +PRIMARY KEY (pk) +) ENGINE=MyISAM; +INSERT INTO it VALUES (1, 'g'); +CREATE TABLE ot +SELECT alias1.pk AS field1 +FROM it AS alias1 +LEFT JOIN it AS alias2 +ON alias1.col_varchar = alias2.col_varchar +; +SELECT * +FROM ot +WHERE field1 IN ( +SELECT alias1.pk +FROM it AS alias1 +LEFT JOIN it AS alias2 +ON alias1.col_varchar = alias2.col_varchar +); +field1 +1 +DROP TABLE it, ot; +# End of test for bug#12714094 +# +# Bug#12867557: Valgrind: conditional jump/move at key_cmp +# +CREATE TABLE t1 ( +pk INTEGER AUTO_INCREMENT, +col_int_key INTEGER, +PRIMARY KEY (pk), +KEY (col_int_key) +) AUTO_INCREMENT=10; +INSERT INTO t1 (col_int_key) VALUES (8); +CREATE TABLE t2 ( +pk INTEGER AUTO_INCREMENT, +col_int_key INTEGER, +col_time_key TIME, +PRIMARY KEY (pk), +KEY (col_int_key), +KEY (col_time_key) +) AUTO_INCREMENT=10; +INSERT INTO t2 (col_int_key, col_time_key) +VALUES +(8, '22:55:23.019225'), (7, '10:19:31.050677'), (1, '14:40:36.038608'), +(7, '04:37:47.062416'), (9, '19:34:06.054514'), (NULL,'20:35:33.022996'), +(1, NULL), (9, '14:43:37.057393'), (2, '02:23:09.043438'), +(9, '01:22:45.041064'), (2, '00:00:00'), (4, '00:13:25.038482'), +(0, '03:47:16.042671'), (4, '01:41:48.007423'), (8, '00:00:00'), +(NULL, '22:32:04.047407'), (NULL, '16:44:14.028443'), (0, '17:38:37.059754'), +(NULL, '08:46:48.042388'), (8, '14:11:27.044095'); +CREATE TABLE t0 +SELECT DISTINCT grandparent1.col_time_key AS g1 +FROM t2 AS grandparent1 +WHERE grandparent1.col_int_key IN +(SELECT parent1.col_int_key AS p1 +FROM t1 AS parent1) +AND grandparent1.pk > 9; +UPDATE t0 +SET g1 = g1 +WHERE g1 IN +(SELECT grandparent1.col_time_key AS g1 +FROM t2 AS grandparent1 +WHERE grandparent1.col_int_key IN +(SELECT parent1.col_int_key AS p1 +FROM t1 AS parent1) +AND grandparent1.pk > 9); +DROP TABLE t0, t1, t2; +# End of test for bug#12867557 +# +# Bug#12711441: crash in fix_after_pullout +# +CREATE TABLE t1 ( +pk int NOT NULL, +col_int_nokey int DEFAULT NULL, +col_int_key int DEFAULT NULL, +col_time_key time DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +PRIMARY KEY (pk) +); +CREATE VIEW v1 AS SELECT * FROM t1; +CREATE TABLE t2 ( +col_int_key int DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +KEY col_varchar_key(col_varchar_key, col_int_key) +); +CREATE TABLE t3 ( +pk int NOT NULL, +col_int_key INT DEFAULT NULL, +PRIMARY KEY (pk) +); +CREATE TABLE t4 ( +col_int_nokey INT DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +KEY col_varchar_key(col_varchar_key) +); +CREATE TABLE ts +SELECT alias1.col_time_key AS field1 +FROM v1 AS alias1 +RIGHT JOIN t3 AS alias2 +ON alias2.col_int_key = alias1.col_int_nokey +WHERE alias1.pk >= SOME( +SELECT SQ1_alias1.pk AS SQ1_field1 +FROM t3 AS SQ1_alias1 +INNER JOIN (t2 AS SQ1_alias2 +INNER JOIN t4 AS SQ1_alias3 +ON SQ1_alias3.col_varchar_key = SQ1_alias2.col_varchar_nokey) +ON SQ1_alias3.col_int_nokey = SQ1_alias2.col_int_key +WHERE SQ1_alias2.col_varchar_key <= alias1.col_varchar_key +AND SQ1_alias3.col_varchar_nokey <> alias1.col_varchar_key) +; +SELECT * FROM ts WHERE field1 IN ( +SELECT alias1.col_time_key AS field1 +FROM v1 AS alias1 +RIGHT JOIN t3 AS alias2 +ON alias2.col_int_key = alias1.col_int_nokey +WHERE alias1.pk >= SOME( +SELECT SQ1_alias1.pk AS SQ1_field1 +FROM t3 AS SQ1_alias1 +INNER JOIN (t2 AS SQ1_alias2 +INNER JOIN t4 AS SQ1_alias3 +ON SQ1_alias3.col_varchar_key = SQ1_alias2.col_varchar_nokey) +ON SQ1_alias3.col_int_nokey = SQ1_alias2.col_int_key +WHERE SQ1_alias2.col_varchar_key <= alias1.col_varchar_key +AND SQ1_alias3.col_varchar_nokey <> alias1.col_varchar_key) +); +field1 +DROP TABLE t1, t2, t3, t4, ts; +DROP VIEW v1; +# End of test for bug#12711441. +# +# Bug#12664936: Same query executed as where subquery ... +# +CREATE TABLE t1 ( +col_varchar_key VARCHAR(1), +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4; +INSERT INTO t1 VALUES +('o'), ('w'), ('m'), ('q'), +('f'), ('p'), ('j'), ('c'); +CREATE TABLE t2 ( +col_int_nokey INTEGER, +col_int_key INTEGER, +col_varchar_key varchar(1), +KEY col_int_key (col_int_key) +) charset utf8mb4; +INSERT INTO t2 VALUES +(8,5,'u'),(4,5,'p'),(8,1,'o'),(NULL,7,'v'), +(1,2,'g'),(2,1,'q'),(NULL,7,'l'),(3,1,'n'); +CREATE TABLE t4 +SELECT t2.col_int_nokey, t2.col_varchar_key +FROM t1 JOIN t2 ON t2.col_varchar_key = t1.col_varchar_key +WHERE t2.col_int_key = 1; +EXPLAIN SELECT * +FROM t4 +WHERE (col_int_nokey, col_varchar_key) IN +(SELECT t2.col_int_nokey, t2.col_varchar_key +FROM t1 JOIN t2 ON t2.col_varchar_key = t1.col_varchar_key +WHERE t2.col_int_key = 1 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t4 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE NULL eq_ref 12 test.t4.col_int_nokey,test.t4.col_varchar_key 1 100.00 NULL +2 MATERIALIZED t2 NULL ref col_int_key col_int_key 5 const 3 100.00 Using where +2 MATERIALIZED t1 NULL ref col_varchar_key col_varchar_key 7 test.t2.col_varchar_key 2 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`col_int_nokey` AS `col_int_nokey`,`test`.`t4`.`col_varchar_key` AS `col_varchar_key` from `test`.`t4` semi join (`test`.`t1` join `test`.`t2`) where ((``.`col_varchar_key` = `test`.`t4`.`col_varchar_key`) and (`test`.`t1`.`col_varchar_key` = `test`.`t2`.`col_varchar_key`) and (``.`col_int_nokey` = `test`.`t4`.`col_int_nokey`) and (`test`.`t2`.`col_int_key` = 1)) +SELECT * +FROM t4 +WHERE (col_int_nokey, col_varchar_key) IN +(SELECT t2.col_int_nokey, t2.col_varchar_key +FROM t1 JOIN t2 ON t2.col_varchar_key = t1.col_varchar_key +WHERE t2.col_int_key = 1 +); +col_int_nokey col_varchar_key +8 o +2 q +DROP TABLE t1, t2, t4; +# End of test for bug#12664936. +# +# Bug#13340270: assertion table->sort.record_pointers == __null +# +CREATE TABLE t1 ( +pk int NOT NULL, +col_int_key int DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key, col_int_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t1 VALUES +(10,8,'x','x'), +(11,7,'d','d'), +(12,1,'r','r'), +(13,7,'f','f'), +(14,9,'y','y'), +(15,NULL,'u','u'), +(16,1,'m','m'), +(17,9,NULL,NULL), +(18,2,'o','o'), +(19,9,'w','w'), +(20,2,'m','m'), +(21,4,'q','q'); +CREATE TABLE t2 +SELECT alias1.col_varchar_nokey AS field1 +FROM t1 AS alias1 JOIN t1 AS alias2 +ON alias2.col_int_key = alias1.pk OR +alias2.col_int_key = alias1.col_int_key +WHERE alias1.pk = 58 OR alias1.col_varchar_key = 'o' + +; +EXPLAIN SELECT * +FROM t2 +WHERE (field1) IN (SELECT alias1.col_varchar_nokey AS field1 +FROM t1 AS alias1 JOIN t1 AS alias2 +ON alias2.col_int_key = alias1.pk OR +alias2.col_int_key = alias1.col_int_key +WHERE alias1.pk = 58 OR alias1.col_varchar_key = 'o' +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE NULL eq_ref 7 test.t2.field1 1 100.00 NULL +2 MATERIALIZED alias1 NULL index_merge PRIMARY,col_int_key,col_varchar_key col_varchar_key,PRIMARY 7,4 NULL 2 100.00 Using sort_union(col_varchar_key,PRIMARY); Using where +2 MATERIALIZED alias2 NULL ALL col_int_key NULL NULL NULL 12 19.00 Range checked for each record (index map: 0x2) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`field1` AS `field1` from `test`.`t2` semi join (`test`.`t1` `alias1` join `test`.`t1` `alias2`) where ((``.`field1` = `test`.`t2`.`field1`) and ((`test`.`alias1`.`pk` = 58) or (`test`.`alias1`.`col_varchar_key` = 'o')) and ((`test`.`alias2`.`col_int_key` = `test`.`alias1`.`pk`) or (`test`.`alias2`.`col_int_key` = `test`.`alias1`.`col_int_key`))) +SELECT * +FROM t2 +WHERE (field1) IN (SELECT alias1.col_varchar_nokey AS field1 +FROM t1 AS alias1 JOIN t1 AS alias2 +ON alias2.col_int_key = alias1.pk OR +alias2.col_int_key = alias1.col_int_key +WHERE alias1.pk = 58 OR alias1.col_varchar_key = 'o' +); +field1 +o +o +DROP TABLE t1, t2; +# End of test for bug#13340270. +# +# Bug#13335319: Seg fault when analyzing FirstMatch semi-join strategy +# +CREATE TABLE ot1(a INTEGER); +INSERT INTO ot1 VALUES(1), (2), (3); +CREATE TABLE ot2(a INTEGER); +INSERT INTO ot2 VALUES(1), (2), (4), (6), (8), (10); +CREATE TABLE it1(a INTEGER); +INSERT INTO it1 VALUES(1), (3), (5), (7); +CREATE TABLE it2(a INTEGER); +INSERT INTO it2 VALUES(1), (3), (5), (7), (9); +explain SELECT ot1.a, ot2.a +FROM ot1, ot2 +WHERE ot1.a IN (SELECT a FROM it1) AND +ot2.a IN (SELECT a FROM it2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 6 100.00 Using where; Using join buffer (hash join) +1 SIMPLE NULL eq_ref 5 test.ot1.a 1 100.00 NULL +1 SIMPLE NULL eq_ref 5 test.ot2.a 1 100.00 NULL +2 MATERIALIZED it1 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +3 MATERIALIZED it2 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` join `test`.`ot2` semi join (`test`.`it1`) semi join (`test`.`it2`) where ((``.`a` = `test`.`ot2`.`a`) and (``.`a` = `test`.`ot1`.`a`)) +SELECT ot1.a, ot2.a +FROM ot1, ot2 +WHERE ot1.a IN (SELECT a FROM it1) AND +ot2.a IN (SELECT a FROM it2); +a a +1 1 +3 1 +DROP TABLE ot1, ot2, it1, it2; +# End of test for bug#13335319. +# +# Bug#13334882: Assertion keypart_map failed in MyIsam function +# +CREATE TABLE t1 ( +pk int NOT NULL, +col_int_nokey INT NOT NULL, +col_int_key INT NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +) ENGINE=MyISAM; +INSERT INTO t1 VALUES +(1,4,0), +(2,6,8), +(3,3,1), +(7,2,6), +(8,9,1), +(9,3,6), +(10,8,2), +(11,1,4), +(12,8,8), +(13,8,4), +(14,5,4); +CREATE TABLE t2 ( +pk int NOT NULL, +col_int_nokey int NOT NULL, +col_int_key int NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +) ENGINE=MyISAM; +INSERT INTO t2 VALUES +(10,8,7); +CREATE TABLE t3 +SELECT grandparent1.col_int_nokey AS g1 +FROM t1 AS grandparent1 +WHERE (grandparent1.col_int_nokey, grandparent1.col_int_key) IN +(SELECT parent1.col_int_key AS p1, +parent1.col_int_key AS p2 +FROM t1 AS parent1 +LEFT JOIN t2 AS parent2 +ON parent1.col_int_nokey = parent2.col_int_key +) +AND grandparent1.col_int_key <> 3 +; +explain SELECT * FROM t3 +WHERE g1 NOT IN +(SELECT grandparent1.col_int_nokey AS g1 +FROM t1 AS grandparent1 +WHERE (grandparent1.col_int_nokey, grandparent1.col_int_key) IN +(SELECT parent1.col_int_key AS p1, +parent1.col_int_key AS p2 +FROM t1 AS parent1 +LEFT JOIN t2 AS parent2 +ON parent1.col_int_nokey = parent2.col_int_key +) +AND grandparent1.col_int_key <> 3 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 Using where; Not exists +2 MATERIALIZED parent1 NULL ALL col_int_key NULL NULL NULL 11 100.00 Using where +2 MATERIALIZED parent2 NULL index col_int_key col_int_key 4 NULL 1 100.00 Using where; Using index; Using join buffer (hash join) +2 MATERIALIZED grandparent1 NULL ref col_int_key col_int_key 4 test.parent1.col_int_key 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select '8' AS `g1` from anti join (`test`.`t1` `grandparent1` join `test`.`t1` `parent1` left join `test`.`t2` `parent2` on((`test`.`parent2`.`col_int_key` = `test`.`parent1`.`col_int_nokey`))) on(((``.`g1` = '8') and (`test`.`parent1`.`col_int_key` = '8') and (`test`.`grandparent1`.`col_int_key` = '8') and (`test`.`grandparent1`.`col_int_nokey` = '8') and ('8' <> 3))) where true +explain format=json SELECT * FROM t3 +WHERE g1 NOT IN +(SELECT grandparent1.col_int_nokey AS g1 +FROM t1 AS grandparent1 +WHERE (grandparent1.col_int_nokey, grandparent1.col_int_key) IN +(SELECT parent1.col_int_key AS p1, +parent1.col_int_key AS p2 +FROM t1 AS parent1 +LEFT JOIN t2 AS parent2 +ON parent1.col_int_nokey = parent2.col_int_key +) +AND grandparent1.col_int_key <> 3 +); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "14.21" + }, + "nested_loop": [ + { + "table": { + "table_name": "t3", + "access_type": "system", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.00", + "eval_cost": "0.10", + "prefix_cost": "0.00", + "data_read_per_join": "8" + }, + "used_columns": [ + "g1" + ] + } + }, + { + "table": { + "table_name": "", + "access_type": "const", + "key": "", + "key_length": "5", + "ref": [ + "const" + ], + "rows_examined_per_scan": 1, + "not_exists": true, + "attached_condition": "((is_not_null_compl(), (('8' <> 3)), true) and (is_not_null_compl(), (found_match(), false, true), true))", + "materialized_from_subquery": { + "using_temporary_table": true, + "query_block": { + "nested_loop": [ + { + "table": { + "table_name": "parent1", + "access_type": "ALL", + "possible_keys": [ + "col_int_key" + ], + "rows_examined_per_scan": 11, + "rows_produced_per_join": 11, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "1.10", + "prefix_cost": "1.61", + "data_read_per_join": "176" + }, + "used_columns": [ + "col_int_nokey", + "col_int_key" + ], + "attached_condition": "((('8' <> 3)) and (`test`.`parent1`.`col_int_key` = '8'))" + } + }, + { + "table": { + "table_name": "parent2", + "access_type": "index", + "possible_keys": [ + "col_int_key" + ], + "key": "col_int_key", + "used_key_parts": [ + "col_int_key" + ], + "key_length": "4", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 11, + "filtered": "100.00", + "using_index": true, + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "1.10", + "prefix_cost": "3.21", + "data_read_per_join": "176" + }, + "used_columns": [ + "col_int_key" + ], + "attached_condition": "(is_not_null_compl(parent2), (`test`.`parent2`.`col_int_key` = `test`.`parent1`.`col_int_nokey`), true)" + } + }, + { + "table": { + "table_name": "grandparent1", + "access_type": "ref", + "possible_keys": [ + "col_int_key" + ], + "key": "col_int_key", + "used_key_parts": [ + "col_int_key" + ], + "key_length": "4", + "ref": [ + "test.parent1.col_int_key" + ], + "rows_examined_per_scan": 2, + "rows_produced_per_join": 22, + "filtered": "100.00", + "cost_info": { + "read_cost": "5.50", + "eval_cost": "2.20", + "prefix_cost": "10.91", + "data_read_per_join": "352" + }, + "used_columns": [ + "col_int_nokey", + "col_int_key" + ], + "attached_condition": "((`test`.`grandparent1`.`col_int_key` = '8') and (`test`.`grandparent1`.`col_int_nokey` = '8'))" + } + } + ] + } + } + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select '8' AS `g1` from anti join (`test`.`t1` `grandparent1` join `test`.`t1` `parent1` left join `test`.`t2` `parent2` on((`test`.`parent2`.`col_int_key` = `test`.`parent1`.`col_int_nokey`))) on(((``.`g1` = '8') and (`test`.`parent1`.`col_int_key` = '8') and (`test`.`grandparent1`.`col_int_key` = '8') and (`test`.`grandparent1`.`col_int_nokey` = '8') and ('8' <> 3))) where true +SELECT * FROM t3 +WHERE g1 NOT IN +(SELECT grandparent1.col_int_nokey AS g1 +FROM t1 AS grandparent1 +WHERE (grandparent1.col_int_nokey, grandparent1.col_int_key) IN +(SELECT parent1.col_int_key AS p1, +parent1.col_int_key AS p2 +FROM t1 AS parent1 +LEFT JOIN t2 AS parent2 +ON parent1.col_int_nokey = parent2.col_int_key +) +AND grandparent1.col_int_key <> 3 +); +g1 +DROP TABLE t1, t2, t3; +# End of test for bug#13334882. +# +# Bug#13339643: Assertion on JOIN::flatten_subqueries on second execution +# +CREATE TABLE t1 ( +col_int_nokey INT, +col_varchar_nokey VARCHAR(1) +) charset utf8mb4; +INSERT INTO t1 VALUES +(1,'o'), +(2,'t'); +CREATE TABLE t2 LIKE t1; +INSERT INTO t2 VALUES +(1,'o'), +(4,'f'); +CREATE VIEW v_t2 AS SELECT * FROM t2; +CREATE TABLE t3 LIKE t1; +INSERT INTO t3 VALUES +(1,'o'), +(4,'f'); +explain SELECT alias1.col_varchar_nokey +FROM t1 AS alias1 +INNER JOIN v_t2 AS alias2 +ON alias2.col_int_nokey = alias1.col_int_nokey AND +'o' IN (SELECT col_varchar_nokey +FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary; End temporary +1 SIMPLE alias1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`alias1`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t1` `alias1` join `test`.`t2` semi join (`test`.`t3`) where ((`test`.`t3`.`col_varchar_nokey` = 'o') and (`test`.`t2`.`col_int_nokey` = `test`.`alias1`.`col_int_nokey`)) +SELECT alias1.col_varchar_nokey +FROM t1 AS alias1 +INNER JOIN v_t2 AS alias2 +ON alias2.col_int_nokey = alias1.col_int_nokey AND +'o' IN (SELECT col_varchar_nokey +FROM t3); +col_varchar_nokey +o +PREPARE stmt FROM "SELECT alias1.col_varchar_nokey +FROM t1 AS alias1 +INNER JOIN v_t2 AS alias2 +ON alias2.col_int_nokey = alias1.col_int_nokey AND +'o' IN (SELECT col_varchar_nokey +FROM t3)"; +EXECUTE stmt; +col_varchar_nokey +o +DROP VIEW v_t2; +DROP TABLE t1, t2, t3; +# End of test for bug#13339643. +# +# Bug#13424134: Wrong result on JOIN + nested WHERE ... IN clauses +# +CREATE TABLE t1 ( +pk int NOT NULL, +col_int_nokey int NOT NULL, +col_int_key int NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +) ENGINE=MyIsam; +INSERT INTO t1 VALUES +(10,1,7), (13,7,3), (18,0,1), (23,8,1); +CREATE TABLE t2 ( +pk int NOT NULL, +col_int_key int NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +) ENGINE=MyIsam; +INSERT INTO t2 VALUES (1,7); +EXPLAIN SELECT t1a.* +FROM t1 AS t1a +JOIN t1 AS t1b USING ( col_int_nokey ) +WHERE t1a.col_int_key IN ( +SELECT pk +FROM t2 +WHERE col_int_key IN ( +SELECT col_int_nokey +FROM t1 +) +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL system PRIMARY,col_int_key NULL NULL NULL 1 100.00 NULL +1 SIMPLE t1a NULL ref col_int_key col_int_key 4 const 1 100.00 Start temporary +1 SIMPLE t1b NULL ALL NULL NULL NULL NULL 4 25.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1a`.`pk` AS `pk`,`test`.`t1a`.`col_int_nokey` AS `col_int_nokey`,`test`.`t1a`.`col_int_key` AS `col_int_key` from `test`.`t1` `t1a` join `test`.`t1` `t1b` semi join (`test`.`t1`) where ((`test`.`t1b`.`col_int_nokey` = `test`.`t1a`.`col_int_nokey`) and (`test`.`t1a`.`col_int_key` = '1') and (`test`.`t1`.`col_int_nokey` = '7')) +SELECT t1a.* +FROM t1 AS t1a +JOIN t1 AS t1b USING ( col_int_nokey ) +WHERE t1a.col_int_key IN ( +SELECT pk +FROM t2 +WHERE col_int_key IN ( +SELECT col_int_nokey +FROM t1 +) +); +pk col_int_nokey col_int_key +18 0 1 +23 8 1 +ALTER TABLE t1 ENGINE=Innodb; +ALTER TABLE t2 ENGINE=Innodb; +SELECT t1a.* +FROM t1 AS t1a +JOIN t1 AS t1b USING ( col_int_nokey ) +WHERE t1a.col_int_key IN ( +SELECT pk +FROM t2 +WHERE col_int_key IN ( +SELECT col_int_nokey +FROM t1 +) +); +pk col_int_nokey col_int_key +18 0 1 +23 8 1 +DROP TABLE t1, t2; +# End of test for bug#13424134. +# +# Bug#13414014: Extra rows in result on semijoin query with where ... +# +CREATE TABLE t1 ( +c INT, +d INT, +a VARCHAR(1), +b VARCHAR(1), +KEY a (a) +) charset utf8mb4; +INSERT INTO t1 VALUES +(NULL,8,'x','x'), (7,4,'q','q'), (6,8,'c','c'); +CREATE TABLE t2 ( +a VARCHAR(1), +KEY a (a) +) charset utf8mb4; +INSERT INTO t2 VALUES +('c'), (NULL), ('x'), ('q'); +explain SELECT * +FROM t2 AS ot +WHERE (a, a) IN +(SELECT a, b +FROM t1 AS it +WHERE it.a = 'x' OR it.c > it.d +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using where +1 SIMPLE ot NULL ref a a 7 .a 2 100.00 Using index +2 MATERIALIZED it NULL ALL a NULL NULL NULL 3 40.74 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`ot`.`a` AS `a` from `test`.`t2` `ot` semi join (`test`.`t1` `it`) where ((``.`b` = ``.`a`) and (`test`.`ot`.`a` = ``.`a`) and (`test`.`it`.`b` = `test`.`it`.`a`) and (((``.`a` = 'x') and (`test`.`it`.`a` = 'x') and (`test`.`it`.`b` = 'x')) or (`test`.`it`.`c` > `test`.`it`.`d`))) +SELECT * +FROM t2 AS ot +WHERE (a, a) IN +(SELECT a, b +FROM t1 AS it +WHERE it.a = 'x' OR it.c > it.d +) +; +a +q +x +DROP TABLE t1, t2; +# End of test for bug#13414014. +# +# Bug#13545215: Missing rows on nested in-subquery with materialization +# +CREATE TABLE t1 ( +col_int_key int, +col_varchar_key varchar(1), +col_varchar_nokey varchar(1), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +INSERT INTO t1 VALUES +(8,'x','x'), (0,'p','p'), (8,'c','c'); +CREATE TABLE t2 ( +pk int NOT NULL, +col_varchar_key varchar(1), +col_varchar_nokey varchar(1), +PRIMARY KEY (pk), +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4; +INSERT INTO t2 VALUES +(1,'v','v'), (2,'v','v'), (3,'c','c'), (4,NULL,NULL), +(5,'x','x'), (6,'i','i'), (7,'e','e'), (8,'p','p'); +CREATE TABLE t3 ( +col_int_nokey int +); +INSERT INTO t3 VALUES (7); +explain SELECT grandparent1.col_varchar_nokey +FROM t1 AS grandparent1 JOIN t1 AS grandparent2 USING (col_int_key) +WHERE grandparent1.col_varchar_key IN ( +SELECT col_varchar_nokey +FROM t2 AS parent1 +WHERE col_varchar_key IN ( +SELECT child1.col_varchar_nokey +FROM t2 AS child1 LEFT JOIN t3 AS child2 +ON child1.pk < child2.col_int_nokey +) +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE grandparent1 NULL ALL col_int_key,col_varchar_key NULL NULL NULL 3 100.00 Using where +1 SIMPLE NULL eq_ref 7 test.grandparent1.col_varchar_key 1 100.00 NULL +1 SIMPLE grandparent2 NULL ref col_int_key col_int_key 5 test.grandparent1.col_int_key 2 100.00 Using index +2 MATERIALIZED child1 NULL ALL NULL NULL NULL NULL 8 100.00 Using where +2 MATERIALIZED child2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +2 MATERIALIZED parent1 NULL ref col_varchar_key col_varchar_key 7 test.child1.col_varchar_nokey 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`grandparent1`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t1` `grandparent1` join `test`.`t1` `grandparent2` semi join (`test`.`t2` `parent1` join `test`.`t2` `child1` left join `test`.`t3` `child2` on((`test`.`child1`.`pk` < `test`.`child2`.`col_int_nokey`))) where ((`test`.`grandparent2`.`col_int_key` = `test`.`grandparent1`.`col_int_key`) and (``.`col_varchar_nokey` = `test`.`grandparent1`.`col_varchar_key`) and (`test`.`parent1`.`col_varchar_key` = `test`.`child1`.`col_varchar_nokey`)) +SELECT grandparent1.col_varchar_nokey +FROM t1 AS grandparent1 JOIN t1 AS grandparent2 USING (col_int_key) +WHERE grandparent1.col_varchar_key IN ( +SELECT col_varchar_nokey +FROM t2 AS parent1 +WHERE col_varchar_key IN ( +SELECT child1.col_varchar_nokey +FROM t2 AS child1 LEFT JOIN t3 AS child2 +ON child1.pk < child2.col_int_nokey +) +); +col_varchar_nokey +c +c +p +x +x +DROP TABLE t1, t2, t3; +# End of test for bug#13545215. +# +# BUG#13553211 - MISSING ROWS ON SELECT WITH IN-SUBQUERY AND +# MATERIALIZATION + SEMIJOIN ON +# +CREATE TABLE t1 ( +col_int_key int(11) DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (4,'v','v'); +INSERT INTO t1 VALUES (62,'v','v'); +INSERT INTO t1 VALUES (7,'c','c'); +INSERT INTO t1 VALUES (1,NULL,NULL); +EXPLAIN SELECT +alias1.col_varchar_nokey AS a1_nokey, +alias1.col_varchar_key AS a1_key, +alias2.col_varchar_nokey AS a2_nokey +FROM +t1 AS alias1, t1 AS alias2 +WHERE +(alias1.col_varchar_nokey,alias2.col_varchar_nokey) +IN +( +SELECT +sq2_alias2.col_varchar_nokey, sq2_alias1.col_varchar_key +FROM +t1 AS sq2_alias1, t1 AS sq2_alias2 +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE alias1 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +1 SIMPLE alias2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (hash join) +1 SIMPLE NULL eq_ref 14 test.alias1.col_varchar_nokey,test.alias2.col_varchar_nokey 1 100.00 NULL +2 MATERIALIZED sq2_alias1 NULL index col_varchar_key col_varchar_key 12 NULL 4 100.00 Using index +2 MATERIALIZED sq2_alias2 NULL ALL NULL NULL NULL NULL 4 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`alias1`.`col_varchar_nokey` AS `a1_nokey`,`test`.`alias1`.`col_varchar_key` AS `a1_key`,`test`.`alias2`.`col_varchar_nokey` AS `a2_nokey` from `test`.`t1` `alias1` join `test`.`t1` `alias2` semi join (`test`.`t1` `sq2_alias1` join `test`.`t1` `sq2_alias2`) where ((``.`col_varchar_key` = `test`.`alias2`.`col_varchar_nokey`) and (``.`col_varchar_nokey` = `test`.`alias1`.`col_varchar_nokey`)) +SELECT +alias1.col_varchar_nokey AS a1_nokey, +alias1.col_varchar_key AS a1_key, +alias2.col_varchar_nokey AS a2_nokey +FROM +t1 AS alias1, t1 AS alias2 +WHERE +(alias1.col_varchar_nokey,alias2.col_varchar_nokey) +IN +( +SELECT +sq2_alias2.col_varchar_nokey, sq2_alias1.col_varchar_key +FROM +t1 AS sq2_alias1, t1 AS sq2_alias2 +) +; +a1_nokey a1_key a2_nokey +c c c +c c v +c c v +v v c +v v c +v v v +v v v +v v v +v v v +DROP TABLE t1; +# +# Bug#13541406: Wrong result with loosescan on select .. where .. in +# +CREATE TABLE t1 ( +col_int_key INT NOT NULL, +col_varchar_nokey VARCHAR(1) NOT NULL, +KEY col_int_key (col_int_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t1 VALUES +(7,'v'), (0,'s'), (9,'l'), (3,'y'), (4,'c'), (2,'i'), (5,'h'), (3,'q'), +(1,'a'), (3,'v'), (6,'u'), (7,'s'), (5,'y'), (1,'z'), (204,'h'), (224,'p'), +(9,'e'), (5,'i'), (0,'y'), (3,'w'); +CREATE TABLE t2 ( +pk INT NOT NULL, +col_int_key INT NOT NULL, +col_varchar_key VARCHAR(1) NOT NULL, +col_varchar_nokey VARCHAR(1) NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t2 VALUES +(1,0,'j','j'), (2,8,'v','v'), (3,1,'c','c'), (4,8,'m','m'), +(5,9,'d','d'), (6,24,'d','d'), (7,6,'y','y'), (8,1,'t','t'), +(9,6,'d','d'), (10,2,'s','s'), (11,4,'r','r'), (12,8,'m','m'), +(13,4,'b','b'), (14,4,'x','x'), (15,7,'g','g'), (16,4,'p','p'), +(17,1,'q','q'), (18,9,'w','w'), (19,4,'d','d'), (20,8,'e','e'); +# This query should never use a LooseScan strategy +explain SELECT ot1.col_int_key AS field1 +FROM t2 AS ot1, t2 AS ot2 +WHERE (ot1.col_varchar_key, ot2.col_varchar_nokey) IN ( +SELECT it2.col_varchar_nokey, it1.col_varchar_key +FROM t2 AS it1 JOIN t1 AS it2 ON it2.col_int_key = it1.pk); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE ot1 NULL ref col_varchar_key col_varchar_key 6 .col_varchar_nokey 1 100.00 Using index +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 20 10.00 Using where; Using join buffer (hash join) +2 MATERIALIZED it2 NULL ALL col_int_key NULL NULL NULL 20 100.00 NULL +2 MATERIALIZED it1 NULL eq_ref PRIMARY,col_varchar_key PRIMARY 4 test.it2.col_int_key 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`col_int_key` AS `field1` from `test`.`t2` `ot1` join `test`.`t2` `ot2` semi join (`test`.`t2` `it1` join `test`.`t1` `it2`) where ((`test`.`it1`.`pk` = `test`.`it2`.`col_int_key`) and (`test`.`ot2`.`col_varchar_nokey` = ``.`col_varchar_key`) and (`test`.`ot1`.`col_varchar_key` = ``.`col_varchar_nokey`)) +SELECT ot1.col_int_key AS field1 +FROM t2 AS ot1, t2 AS ot2 +WHERE (ot1.col_varchar_key, ot2.col_varchar_nokey) IN ( +SELECT it2.col_varchar_nokey, it1.col_varchar_key +FROM t2 AS it1 JOIN t1 AS it2 ON it2.col_int_key = it1.pk); +field1 +1 +1 +1 +2 +6 +6 +6 +6 +6 +8 +8 +8 +8 +8 +8 +9 +DROP TABLE t1, t2; +# End of test for bug#13541406. +# +# Bug#13576391: Missing rows on select with in-subquery and +# batched-key-access=on and semijoin +# +CREATE TABLE t1 ( +col_int_nokey int NOT NULL, +col_varchar_key varchar(1) NOT NULL, +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4 engine=InnoDB; +INSERT INTO t1 VALUES +(1,'v'), (7,'s'), (4,'l'), (7,'y'), (0,'c'), (2,'i'), (9,'h'), (4,'q'), +(0,'a'), (9,'v'), (1,'u'), (3,'s'), (8,'y'), (8,'z'), (18,'h'), (84,'p'), +(6,'e'), (3,'i'), (6,'y'), (6,'w'); +CREATE TABLE t2 ( +col_int_nokey int NOT NULL, +col_varchar_nokey varchar(1) NOT NULL +) charset utf8mb4 engine=InnoDB; +INSERT INTO t2 VALUES +(4,'j'), (6,'v'), (3,'c'), (5,'m'), (3,'d'), (246,'d'), (2,'y'), (9,'t'), +(3,'d'), (8,'s'), (1,'r'), (8,'m'), (8,'b'), (5,'x'), (7,'g'), (5,'p'), +(1,'q'), (6,'w'), (2,'d'), (9,'e'); +explain SELECT col_varchar_nokey +FROM t2 AS ot +WHERE col_varchar_nokey IN ( +SELECT col_varchar_key +FROM t1 AS it +WHERE it.col_int_nokey <= it.col_int_nokey +AND NOT ot.col_int_nokey < 2 +) +ORDER BY col_varchar_nokey; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 20 33.33 Parallel execute (1 workers) +2 SIMPLE ot NULL ALL NULL NULL NULL NULL 20 33.33 Using where; Using filesort +2 SIMPLE it NULL ref col_varchar_key col_varchar_key 6 test.ot.col_varchar_nokey 1 100.00 Start temporary; End temporary +Warnings: +Note 1276 Field or reference 'test.ot.col_int_nokey' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`ot`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t2` `ot` semi join (`test`.`t1` `it`) where ((`test`.`it`.`col_varchar_key` = `test`.`ot`.`col_varchar_nokey`) and (`test`.`ot`.`col_int_nokey` >= 2)) order by `test`.`ot`.`col_varchar_nokey` +SELECT col_varchar_nokey +FROM t2 AS ot +WHERE col_varchar_nokey IN ( +SELECT col_varchar_key +FROM t1 AS it +WHERE it.col_int_nokey <= it.col_int_nokey +AND NOT ot.col_int_nokey < 2 +) +ORDER BY col_varchar_nokey; +col_varchar_nokey +c +e +p +s +v +w +y +ALTER TABLE t1 ENGINE=MyISAM; +ALTER TABLE t2 ENGINE=MyISAM; +explain SELECT col_varchar_nokey +FROM t2 AS ot +WHERE col_varchar_nokey IN ( +SELECT col_varchar_key +FROM t1 AS it +WHERE it.col_int_nokey <= it.col_int_nokey +AND NOT ot.col_int_nokey < 2 +) +ORDER BY col_varchar_nokey; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 20 33.33 Using where; Using filesort +1 SIMPLE it NULL ref col_varchar_key col_varchar_key 6 test.ot.col_varchar_nokey 2 100.00 Start temporary; End temporary +Warnings: +Note 1276 Field or reference 'test.ot.col_int_nokey' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`ot`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t2` `ot` semi join (`test`.`t1` `it`) where ((`test`.`it`.`col_varchar_key` = `test`.`ot`.`col_varchar_nokey`) and (`test`.`ot`.`col_int_nokey` >= 2)) order by `test`.`ot`.`col_varchar_nokey` +SELECT col_varchar_nokey +FROM t2 AS ot +WHERE col_varchar_nokey IN ( +SELECT col_varchar_key +FROM t1 AS it +WHERE it.col_int_nokey <= it.col_int_nokey +AND NOT ot.col_int_nokey < 2 +) +ORDER BY col_varchar_nokey; +col_varchar_nokey +c +e +p +s +v +w +y +ALTER TABLE t1 ENGINE=Memory; +ALTER TABLE t2 ENGINE=Memory; +explain SELECT col_varchar_nokey +FROM t2 AS ot +WHERE col_varchar_nokey IN ( +SELECT col_varchar_key +FROM t1 AS it +WHERE it.col_int_nokey <= it.col_int_nokey +AND NOT ot.col_int_nokey < 2 +) +ORDER BY col_varchar_nokey; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 20 33.33 Using where; Using filesort +1 SIMPLE it NULL ref col_varchar_key col_varchar_key 6 test.ot.col_varchar_nokey 2 100.00 Start temporary; End temporary +Warnings: +Note 1276 Field or reference 'test.ot.col_int_nokey' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`ot`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t2` `ot` semi join (`test`.`t1` `it`) where ((`test`.`it`.`col_varchar_key` = `test`.`ot`.`col_varchar_nokey`) and (`test`.`ot`.`col_int_nokey` >= 2)) order by `test`.`ot`.`col_varchar_nokey` +SELECT col_varchar_nokey +FROM t2 AS ot +WHERE col_varchar_nokey IN ( +SELECT col_varchar_key +FROM t1 AS it +WHERE it.col_int_nokey <= it.col_int_nokey +AND NOT ot.col_int_nokey < 2 +) +ORDER BY col_varchar_nokey; +col_varchar_nokey +c +e +p +s +v +w +y +DROP TABLE t1, t2; +# End of test for bug#13576391. +# +# Bug #13589848 "MISSING ROW ON SELECT WITH NESTED IN CLAUSES WHEN LOOSESCAN=ON" +# +CREATE TABLE t1 ( +id INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +KEY (col_varchar_key) +) charset utf8mb4; +INSERT INTO t1 VALUES (100,'m','m'), +(200,'b','b'), (300,'x','x'); +CREATE TABLE t2 ( +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +KEY (col_varchar_key) +) charset utf8mb4; +INSERT INTO t2 VALUES ('b','b'); +CREATE TABLE t3 ( +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +KEY (col_varchar_key) +) charset utf8mb4; +INSERT INTO t3 VALUES ('k','k'); +EXPLAIN SELECT gp1.id +FROM t1 AS gp1 JOIN t3 AS gp2 +ON gp2.col_varchar_key <> gp1.col_varchar_nokey +WHERE (gp1.col_varchar_nokey, gp1.col_varchar_nokey) +IN ( +SELECT col_varchar_nokey, col_varchar_nokey +FROM t1 +WHERE col_varchar_nokey +IN ( SELECT col_varchar_key +FROM t2 LEFT JOIN t3 USING (col_varchar_key) ) +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE gp2 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using where +1 SIMPLE gp1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +2 MATERIALIZED t2 NULL index col_varchar_key col_varchar_key 7 NULL 1 100.00 Using index +2 MATERIALIZED t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +2 MATERIALIZED t3 NULL ref col_varchar_key col_varchar_key 7 test.t2.col_varchar_key 2 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`gp1`.`id` AS `id` from `test`.`t1` `gp1` semi join (`test`.`t1` join `test`.`t2` left join `test`.`t3` on((`test`.`t2`.`col_varchar_key` = `test`.`t3`.`col_varchar_key`))) where ((``.`col_varchar_nokey` = ``.`col_varchar_nokey`) and (`test`.`gp1`.`col_varchar_nokey` = ``.`col_varchar_nokey`) and (`test`.`t1`.`col_varchar_nokey` = `test`.`t2`.`col_varchar_key`) and ('k' <> ``.`col_varchar_nokey`)) +SELECT gp1.id +FROM t1 AS gp1 JOIN t3 AS gp2 +ON gp2.col_varchar_key <> gp1.col_varchar_nokey +WHERE (gp1.col_varchar_nokey, gp1.col_varchar_nokey) +IN ( +SELECT col_varchar_nokey, col_varchar_nokey +FROM t1 +WHERE col_varchar_nokey +IN ( SELECT col_varchar_key +FROM t2 LEFT JOIN t3 USING (col_varchar_key) ) +) +; +id +200 +DROP TABLE t1,t2,t3; +# +# Bug #13596176: Missing row on select with nested in clause when +# matr=on and bnl=off + MyISAM +# +CREATE TABLE t1 ( +int_key int DEFAULT NULL, +vc_key varchar(1) DEFAULT NULL, +vc_nokey varchar(1) DEFAULT NULL, +KEY int_key (int_key), +KEY vc_key (vc_key, int_key) +) charset utf8mb4 ENGINE=MyISAM; +INSERT INTO t1 VALUES +(8,'x','x'), (7,'d','d'), (1,'r','r'), (7,'f','f'), +(9,'y','y'), (NULL,'u','u'), (1,'m','m'), (9,NULL,NULL), +(2,'o','o'), (9,'w','w'), (2,'m','m'), (4,'q','q'), +(0,NULL,NULL), (4,'d','d'), (8,'g','g'), (NULL,'x','x'), +(NULL,'f','f'), (0,'p','p'), (NULL,'j','j'), (8,'c','c'); +CREATE TABLE t2 ( +int_key int DEFAULT NULL, +vc_key varchar(1) DEFAULT NULL, +KEY int_key (int_key), +KEY vc_key (vc_key, int_key) +) charset utf8mb4 ENGINE=MyISAM; +INSERT INTO t2 VALUES (8,'g'); +explain SELECT vc_key +FROM t1 as outr +WHERE (vc_nokey, vc_key ) IN +(SELECT vc_nokey, vc_nokey +FROM t1 middle +WHERE vc_nokey IN +(SELECT child1.vc_key +FROM t2 AS child1 JOIN t1 AS child2 USING (int_key) +) +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using where +1 SIMPLE outr NULL ref vc_key vc_key 7 .vc_nokey 3 10.00 Using where +2 MATERIALIZED child1 NULL index int_key,vc_key vc_key 12 NULL 1 100.00 Using where; Using index +2 MATERIALIZED middle NULL ALL NULL NULL NULL NULL 20 10.00 Using where; Using join buffer (hash join) +2 MATERIALIZED child2 NULL ref int_key int_key 5 test.child1.int_key 3 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`outr`.`vc_key` AS `vc_key` from `test`.`t1` `outr` semi join (`test`.`t1` `middle` join `test`.`t2` `child1` join `test`.`t1` `child2`) where ((`test`.`child2`.`int_key` = `test`.`child1`.`int_key`) and (``.`vc_nokey` = ``.`vc_nokey`) and (`test`.`outr`.`vc_nokey` = ``.`vc_nokey`) and (`test`.`outr`.`vc_key` = ``.`vc_nokey`) and (`test`.`middle`.`vc_nokey` = `test`.`child1`.`vc_key`)) +SELECT vc_key +FROM t1 as outr +WHERE (vc_nokey, vc_key ) IN +(SELECT vc_nokey, vc_nokey +FROM t1 middle +WHERE vc_nokey IN +(SELECT child1.vc_key +FROM t2 AS child1 JOIN t1 AS child2 USING (int_key) +) +); +vc_key +g +DROP TABLE t1, t2; +# End of test for bug#13596176. +# +# BUG#11754478: MAX/MIN + SUBQUERY + AND FAILS TO RETURN ANY ROWS +# BUG#13599013: MAX/MIN + SUBQUERY IN WHERE CLAUSE MATCHING NO +# ROWS + INDEX DOES NOT RETURN NULL +# +CREATE TABLE t1 ( +pk int(11) PRIMARY KEY, +int_key int(11), +KEY int_key (int_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (1,0),(2,0),(3,2),(4,0),(5,3),(6,0); +SELECT MIN(int_key) FROM t1 WHERE (4, 4) IN (SELECT 1, 2); +MIN(int_key) +NULL +SELECT MIN(int_key) FROM t1 WHERE (4, 4) IN (SELECT 4, 4); +MIN(int_key) +0 +SELECT MIN(pk) FROM t1 WHERE pk IN (SELECT int_key FROM t1) AND pk = 6; +MIN(pk) +NULL +DROP TABLE t1; +# BUG#13726217: Crash in Item_ident::fix_after_pullout() +CREATE TABLE t1(a INTEGER) engine=innodb; +INSERT INTO t1 VALUES (0); +SELECT 0 +FROM t1 +WHERE 0 IN +(SELECT 0 +FROM t1 +WHERE 0 LIKE +(SELECT elt(a, 0) AS b +FROM t1 +GROUP BY a +HAVING b +) +); +0 +DROP TABLE t1; +# End of test for bug#13726217. +# BUG#13773979: Missing rows on second execution of prepared statement +CREATE TABLE t1 ( +col_int_nokey INT, +col_int_key INT, +col_varchar_key VARCHAR(1) +); +INSERT INTO t1 VALUES +(1,7,'v'), (7,0,'s'), (4,9,'l'), (7,3,'y'), +(2,2,'i'), (9,5,'h'), (0,1,'a'), (9,3,'v'); +CREATE VIEW v1 AS SELECT * FROM t1; +SELECT * +FROM t1 +WHERE col_int_key IN ( +SELECT alias1.col_int_nokey AS field1 +FROM v1 AS alias1 +WHERE alias1.col_varchar_key < 'v' +); +col_int_nokey col_int_key col_varchar_key +1 7 v +2 2 i +4 9 l +7 0 s +prepare stmt FROM "SELECT * +FROM t1 +WHERE col_int_key IN ( +SELECT alias1.col_int_nokey AS field1 +FROM v1 AS alias1 +WHERE alias1.col_varchar_key < 'v' +)"; +execute stmt; +col_int_nokey col_int_key col_varchar_key +1 7 v +2 2 i +4 9 l +7 0 s +execute stmt; +col_int_nokey col_int_key col_varchar_key +1 7 v +2 2 i +4 9 l +7 0 s +DEALLOCATE PREPARE stmt; +DROP VIEW v1; +DROP TABLE t1; +# End of test for bug#13773979. +# +# BUG#13685026 ASSERTION CUR_SJ_INNER_TABLES == 0 IN +# --OPTIMIZE_TABLE_ORDER::CHOOSE_TABLE_ORDER +# +CREATE TABLE t1 ( +col_int_key INT(11) NOT NULL, +col_datetime_key DATETIME NOT NULL, +col_varchar_key VARCHAR(1) NOT NULL, +col_varchar_nokey VARCHAR(1) NOT NULL, +KEY col_int_key (col_int_key), +KEY col_datetime_key (col_datetime_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (0,'2002-02-13 17:30:06','j','j'); +INSERT INTO t1 VALUES (8,'2008-09-27 00:34:58','v','v'); +CREATE TABLE t2 ( +col_int_key INT(11) NOT NULL, +col_datetime_key DATETIME NOT NULL, +col_varchar_key VARCHAR(1) NOT NULL, +col_varchar_nokey VARCHAR(1) NOT NULL, +KEY col_int_key (col_int_key), +KEY col_datetime_key (col_datetime_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (7,'2003-08-21 00:00:00','b','b'); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +SET @old_depth=@@optimizer_search_depth; +SET optimizer_search_depth=4; +EXPLAIN SELECT col_datetime_key +FROM t1 as outr +WHERE col_datetime_key IN ( +SELECT alias1.col_datetime_key +FROM t1 AS alias1 +LEFT JOIN t1 as alias3 +STRAIGHT_JOIN ( t2 AS alias4 +JOIN t1 AS alias5 +ON alias5.col_varchar_key <= alias4.col_varchar_nokey ) +ON alias5.col_int_key < alias4.col_int_key +ON alias5.col_varchar_key = alias4.col_varchar_key +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE outr NULL index col_datetime_key col_datetime_key 5 NULL 2 100.00 Using index +1 SIMPLE NULL eq_ref 5 test.outr.col_datetime_key 1 100.00 NULL +2 MATERIALIZED alias1 NULL index col_datetime_key col_datetime_key 5 NULL 2 100.00 Using index +2 MATERIALIZED alias4 NULL ALL col_int_key,col_varchar_key NULL NULL NULL 1 100.00 NULL +2 MATERIALIZED alias5 NULL ref col_int_key,col_varchar_key col_varchar_key 6 test.alias4.col_varchar_key 1 100.00 Using where; Using index +2 MATERIALIZED alias3 NULL index NULL col_int_key 4 NULL 2 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`outr`.`col_datetime_key` AS `col_datetime_key` from `test`.`t1` `outr` semi join (`test`.`t1` `alias1` left join (`test`.`t1` `alias3` join `test`.`t2` `alias4` join `test`.`t1` `alias5`) on(((`test`.`alias5`.`col_varchar_key` = `test`.`alias4`.`col_varchar_key`) and (`test`.`alias5`.`col_int_key` < `test`.`alias4`.`col_int_key`) and (`test`.`alias5`.`col_varchar_key` <= `test`.`alias4`.`col_varchar_nokey`)))) where (``.`col_datetime_key` = `test`.`outr`.`col_datetime_key`) +SELECT col_datetime_key +FROM t1 as outr +WHERE col_datetime_key IN ( +SELECT alias1.col_datetime_key +FROM t1 AS alias1 +LEFT JOIN t1 as alias3 +STRAIGHT_JOIN ( t2 AS alias4 +JOIN t1 AS alias5 +ON alias5.col_varchar_key <= alias4.col_varchar_nokey ) +ON alias5.col_int_key < alias4.col_int_key +ON alias5.col_varchar_key = alias4.col_varchar_key +); +col_datetime_key +2002-02-13 17:30:06 +2008-09-27 00:34:58 +DROP TABLE t1,t2; +SET @@optimizer_search_depth=@old_depth; +# +# BUG#13848789: SEGFAULT IN JOIN_READ_NEXT_SAME AT +# SQL/SQL_EXECUTOR.CC ON HAVING...IN...JOIN +# +CREATE TABLE t1 ( +col_int_key INT, +col_varchar_key VARCHAR(1), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4; +INSERT INTO t1 VALUES (8,'x'); +CREATE TABLE t2 ( +col_varchar_key VARCHAR(1), +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4; +INSERT INTO t2 VALUES ('x'), ('y'); +explain SELECT MIN(col_int_key) +FROM t1 as t1_outer +HAVING (1, 2) IN ( +SELECT t1_inner.col_int_key, MAX(t1_inner.col_int_key) +FROM t1 as t1_inner JOIN t2 +ON t2.col_varchar_key = t1_inner.col_varchar_key +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible HAVING +2 SUBQUERY t1_inner NULL system col_varchar_key NULL NULL NULL 1 100.00 NULL +2 SUBQUERY t2 NULL ref col_varchar_key col_varchar_key 7 const 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select min(`test`.`t1_outer`.`col_int_key`) AS `MIN(col_int_key)` from `test`.`t1` `t1_outer` having false +SELECT MIN(col_int_key) +FROM t1 as t1_outer +HAVING (1, 2) IN ( +SELECT t1_inner.col_int_key, MAX(t1_inner.col_int_key) +FROM t1 as t1_inner JOIN t2 +ON t2.col_varchar_key = t1_inner.col_varchar_key +); +MIN(col_int_key) +DROP TABLE t1,t2; +# Bug#13838810: Segfault in evaluate_null_complemented_join_record +CREATE TABLE t1 ( +pk int NOT NULL, +col_int_nokey int DEFAULT NULL, +col_int_key int DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t1 VALUES (10,NULL,8,'x'); +CREATE TABLE t2 ( +pk int NOT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +PRIMARY KEY (pk) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t2 VALUES (1,'x'); +CREATE TABLE t3 ( +pk int NOT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +PRIMARY KEY (pk), +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t3 VALUES +(1,'v','v'), (2,'v','v'), (3,'c','c'), (4,NULL,NULL); +EXPLAIN SELECT table1.pk,table2.pk, table3.pk +FROM t2 AS table1 +LEFT JOIN t1 AS table2 +LEFT JOIN t1 AS table3 +ON table3.col_int_key = table2.col_int_key +ON table3.pk = table2.col_int_nokey AND +table1.col_varchar_nokey IN ( +SELECT subquery3_t1.col_varchar_nokey +FROM t3 AS subquery3_t1 +LEFT JOIN t1 AS subquery3_t2 +ON subquery3_t2.col_varchar_key = subquery3_t1.col_varchar_key +WHERE subquery3_t2.col_int_nokey <> 9 +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE table1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE table2 NULL ALL col_int_key NULL NULL NULL 1 100.00 NULL +1 SIMPLE table3 NULL eq_ref PRIMARY,col_int_key PRIMARY 4 test.table2.col_int_nokey 1 100.00 Using where +1 SIMPLE NULL eq_ref 7 test.table1.col_varchar_nokey 1 100.00 NULL +2 MATERIALIZED subquery3_t2 NULL ALL col_varchar_key NULL NULL NULL 1 100.00 NULL +2 MATERIALIZED subquery3_t1 NULL ref col_varchar_key col_varchar_key 7 test.subquery3_t2.col_varchar_key 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`table1`.`pk` AS `pk`,`test`.`table2`.`pk` AS `pk`,`test`.`table3`.`pk` AS `pk` from `test`.`t2` `table1` left join (`test`.`t1` `table2` join `test`.`t1` `table3` semi join (`test`.`t3` `subquery3_t1` join `test`.`t1` `subquery3_t2`)) on(((`test`.`table3`.`col_int_key` = `test`.`table2`.`col_int_key`) and (`test`.`subquery3_t1`.`col_varchar_key` = `test`.`subquery3_t2`.`col_varchar_key`) and (``.`col_varchar_nokey` = `test`.`table1`.`col_varchar_nokey`) and (`test`.`table3`.`pk` = `test`.`table2`.`col_int_nokey`) and (`test`.`subquery3_t2`.`col_int_nokey` <> 9))) where true +SELECT table1.pk,table2.pk, table3.pk +FROM t2 AS table1 +LEFT JOIN t1 AS table2 +LEFT JOIN t1 AS table3 +ON table3.col_int_key = table2.col_int_key +ON table3.pk = table2.col_int_nokey AND +table1.col_varchar_nokey IN ( +SELECT subquery3_t1.col_varchar_nokey +FROM t3 AS subquery3_t1 +LEFT JOIN t1 AS subquery3_t2 +ON subquery3_t2.col_varchar_key = subquery3_t1.col_varchar_key +WHERE subquery3_t2.col_int_nokey <> 9 +) +; +pk pk pk +1 NULL NULL +DROP TABLE t1, t2, t3; +Extra test case for specific code coverage +CREATE TABLE t1(pk INTEGER); +INSERT INTO t1 VALUES(1), (2); +explain SELECT * +FROM t1 AS ot1 LEFT JOIN t1 AS ot2 +ON ot1.pk=ot2.pk AND +ot2.pk IN +(SELECT it1.pk +FROM t1 AS it1 LEFT JOIN t1 AS it2 ON it1.pk=it2.pk); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE NULL eq_ref 5 test.ot2.pk 1 100.00 Using where +2 MATERIALIZED it1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED it2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`pk` AS `pk`,`test`.`ot2`.`pk` AS `pk` from `test`.`t1` `ot1` left join (`test`.`t1` `ot2` semi join (`test`.`t1` `it1` left join `test`.`t1` `it2` on((`test`.`it1`.`pk` = `test`.`it2`.`pk`)))) on(((`test`.`ot2`.`pk` = `test`.`ot1`.`pk`) and (``.`pk` = `test`.`ot1`.`pk`))) where true +SELECT * +FROM t1 AS ot1 LEFT JOIN t1 AS ot2 +ON ot1.pk=ot2.pk AND +ot2.pk IN +(SELECT it1.pk +FROM t1 AS it1 LEFT JOIN t1 AS it2 ON it1.pk=it2.pk); +pk pk +1 1 +2 2 +DROP TABLE t1; +# End of test for bug#13838810. +# +# Bug#13845930: Segfault in st_join_table::and_with_condition +# +CREATE TABLE t1 ( +col_int INTEGER +); +CREATE TABLE t2 ( +col_varchar_1 VARCHAR(1), +col_varchar_2 VARCHAR(1) +); +INSERT INTO t2 VALUES ('x','x'), ('c','c'); +PREPARE stmt FROM ' +SELECT alias2.col_varchar_2 AS field1 +FROM t2 AS alias1 + JOIN + (t2 AS alias2 + LEFT JOIN t2 AS alias3 + ON (8, 92) IN + (SELECT sq1_alias1.col_int, + sq1_alias2.col_int + FROM t1 AS sq1_alias1 JOIN t1 AS sq1_alias2 + ) + ) + ON alias3.col_varchar_1 = alias2.col_varchar_2 +'; +EXECUTE stmt; +field1 + +EXECUTE stmt; +field1 +DEALLOCATE prepare stmt; +DROP TABLE t1, t2; +# End of test for bug#13845930. +# +# Bug#13855925: Assert 'prebuilt->search_tuple->n_fields > 0' +# in ha_innobase::index_read +# +CREATE TABLE t1 ( +pk INTEGER AUTO_INCREMENT, +col_int_nokey INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk), +KEY (col_varchar_key) +) charset utf8mb4 ENGINE=INNODB; +INSERT INTO t1 ( +col_int_key, col_int_nokey, +col_varchar_key, col_varchar_nokey +) VALUES +(4, 2, 'v','v'), (62, 150, 'v','v'), (7, NULL, 'c','c'), (1, 2, NULL, NULL), +(0, 5, 'x','x'), (7, 3, 'i','i'), (7, 1, 'e','e'), (1, 4, 'p','p'), +(7, NULL, 's','s'), (1, 2, 'j','j'), (5, 6, 'z','z'), (2, 6, 'c','c'), +(0, 8, 'a','a'), (1, 2, 'q','q'), (8, 6, 'y','y'), (1, 8, NULL, NULL), +(1, 3, 'r','r'), (9, 3, 'v','v'), (1, 9, NULL, NULL), (5, 6, 'r','r'); +CREATE TABLE t2 ( +pk INT AUTO_INCREMENT, +col_int_nokey INT, +col_int_key INT, +PRIMARY KEY (pk), +KEY (col_int_key) +) charset utf8mb4 AUTO_INCREMENT=10 ENGINE=INNODB; +INSERT INTO t2 (col_int_key, col_int_nokey) VALUES +(8, NULL), (7, 8), (1, 1), (7, 9), (9, 4), (NULL, 3), (1, 2), (9, NULL), +(2, 2), (9, NULL), (2, 6), (4, 7), (0, 2), (4, 5), (8, 7), (NULL, 6), +(NULL, 6), (0, 2), (NULL, 9), (8, 6); +CREATE TABLE t3 ( +pk INT AUTO_INCREMENT, +col_varchar_key VARCHAR(1), +PRIMARY KEY (pk), +KEY (col_varchar_key) +) charset utf8mb4 ENGINE=INNODB; +INSERT INTO t3 (col_varchar_key) VALUES +('c'), ('c'), ('q'), ('g'), ('e'), ('l'), (NULL), ('c'), ('h'), ('d'), +('c'), ('i'), ('t'), ('g'), ('q'), ('l'), ('n'), ('z'), ('n'), ('r'), ('p'); +CREATE VIEW v1 AS +SELECT table2.col_varchar_nokey AS field1 +FROM t2 AS table1 +INNER JOIN (t1 AS table2 +STRAIGHT_JOIN t2 AS table3 +ON table3.col_int_key = table2.pk AND +table3.col_int_nokey = ANY +(SELECT subquery1_t2.col_int_nokey AS subquery1_field1 +FROM t2 AS subquery1_t1 +RIGHT OUTER JOIN t1 AS subquery1_t2 +INNER JOIN t1 AS subquery1_t3 +ON subquery1_t3.col_int_key = subquery1_t2.pk +ON subquery1_t3.col_varchar_key=subquery1_t2.col_varchar_nokey +WHERE subquery1_t1.pk > 1 +) +) +ON table3.col_int_key IN +(SELECT subquery2_t1.col_int_key AS subquery2_field1 +FROM t2 AS subquery2_t1 +RIGHT OUTER JOIN t3 AS subquery2_t2 +LEFT OUTER JOIN t1 AS subquery2_t3 +ON subquery2_t3.col_varchar_key = subquery2_t2.col_varchar_key +ON subquery2_t3.pk = subquery2_t2.pk +) +; +explain SELECT * FROM v1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE table1 NULL index NULL col_int_key 5 NULL 20 100.00 Using index +1 SIMPLE table2 NULL ALL PRIMARY NULL NULL NULL 20 100.00 Using join buffer (hash join) +1 SIMPLE table3 NULL ref col_int_key col_int_key 5 test.table2.pk 2 100.00 Using where +1 SIMPLE NULL eq_ref 5 test.table3.col_int_nokey 1 100.00 NULL +1 SIMPLE NULL eq_ref 5 test.table2.pk 1 100.00 NULL +4 MATERIALIZED subquery1_t3 NULL ALL col_varchar_key NULL NULL NULL 20 100.00 Using where +4 MATERIALIZED subquery1_t2 NULL eq_ref PRIMARY PRIMARY 4 test.subquery1_t3.col_int_key 1 10.00 Using where +4 MATERIALIZED subquery1_t1 NULL index PRIMARY col_int_key 5 NULL 20 100.00 Using where; Using index; Using join buffer (hash join) +3 MATERIALIZED subquery2_t3 NULL index PRIMARY,col_varchar_key col_varchar_key 7 NULL 20 100.00 Using where; Using index +3 MATERIALIZED subquery2_t2 NULL eq_ref PRIMARY,col_varchar_key PRIMARY 4 test.subquery2_t3.pk 1 7.14 Using where +3 MATERIALIZED subquery2_t1 NULL index col_int_key col_int_key 5 NULL 20 100.00 Using index; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `table2`.`col_varchar_nokey` AS `field1` from `test`.`t2` `table1` join `test`.`t1` `table2` straight_join `test`.`t2` `table3` semi join (`test`.`t1` `subquery1_t2` join `test`.`t1` `subquery1_t3` join `test`.`t2` `subquery1_t1`) semi join (`test`.`t3` `subquery2_t2` join `test`.`t1` `subquery2_t3` join `test`.`t2` `subquery2_t1`) where ((`subquery1_t2`.`pk` = `subquery1_t3`.`col_int_key`) and (`subquery1_t2`.`col_varchar_nokey` = `subquery1_t3`.`col_varchar_key`) and (`subquery2_t2`.`col_varchar_key` = `subquery2_t3`.`col_varchar_key`) and (`subquery2_t2`.`pk` = `subquery2_t3`.`pk`) and (`table3`.`col_int_key` = `table2`.`pk`) and (``.`subquery2_field1` = `table2`.`pk`) and (``.`subquery1_field1` = `table3`.`col_int_nokey`) and (`subquery1_t1`.`pk` > 1)) +SELECT * FROM v1; +field1 +v +v +v +v +v +v +v +v +v +v +v +v +v +v +v +v +v +v +v +v +DROP VIEW v1; +DROP TABLE t1,t2,t3; +# End of test for bug#13855925. +# +# Bug#13897959: Segfault in setup_semijoin_dups_elimination() +# +CREATE TABLE t1 ( +col_datetime_key DATETIME DEFAULT NULL, +KEY col_datetime_key (col_datetime_key) +) ENGINE=MyISAM; +INSERT INTO t1 VALUES +('2001-04-18 00:00:00'), ('2008-12-18 19:39:55'), +('2000-08-01 12:19:39'), ('2004-09-25 21:29:06'), +('2009-09-20 09:11:48'), ('2004-03-27 09:32:04'); +CREATE TABLE t2 ( +col_date_nokey date DEFAULT NULL, +col_time_key time DEFAULT NULL, +col_datetime_key datetime DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +KEY col_time_key (col_time_key), +KEY col_datetime_key (col_datetime_key), +KEY col_varchar_key(col_varchar_key) +) ENGINE=MyISAM; +INSERT INTO t2 VALUES ('1900-01-01',NULL,'2001-11-04 19:07:55','x','x'); +SELECT grandparent1.col_varchar_nokey +FROM t2 AS grandparent1 LEFT JOIN t1 USING (col_datetime_key) +WHERE grandparent1.col_varchar_nokey IN ( +SELECT col_varchar_nokey +FROM t2 AS parent1 +WHERE parent1.col_time_key > grandparent1.col_date_nokey +); +col_varchar_nokey +DROP TABLE t1, t2; +# End of test for bug#13897959. +# +# Bug#13898625 ASSERT `(REMAINING_TABLES_AFTER != 0) ...' IN +# BEST_EXTENSION_BY_LIMITED_SEARCH +# +CREATE TABLE t1 ( +pk int(11) NOT NULL, +col_int_nokey INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (26,6,NULL,'f','f'); +INSERT INTO t1 VALUES (29,6,8,'c','c'); +CREATE TABLE t2 ( +pk INT NOT NULL, +col_int_nokey INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +INSERT INTO t2 VALUES (1,2,4,'v','v'); +INSERT INTO t2 VALUES (2,150,62,'v','v'); +INSERT INTO t2 VALUES (5,5,0,'x','x'); +INSERT INTO t2 VALUES (6,3,7,'i','i'); +INSERT INTO t2 VALUES (7,1,7,'e','e'); +CREATE VIEW view_c AS SELECT * FROM t2; +PREPARE prep_stmt_7430 FROM 'SELECT SUM( alias1.col_varchar_key ) AS field1 +FROM t1 AS alias1 +RIGHT JOIN t2 AS alias2 +INNER JOIN t1 AS alias3 +ON (alias3.col_varchar_key = alias2.col_varchar_key ) +ON ( "v" ) IN ( +SELECT sq1_alias1.col_varchar_nokey AS sq1_field1 +FROM t1 AS sq1_alias1 +) +WHERE alias3.pk IN ( +SELECT sq2_alias1.col_int_key AS sq2_field1 +FROM ( view_c AS sq2_alias1, t1 AS sq2_alias2 ) +) +'; +EXECUTE prep_stmt_7430; +field1 +NULL +EXECUTE prep_stmt_7430; +field1 +NULL +EXPLAIN SELECT SUM( alias1.col_varchar_key ) AS field1 +FROM t1 AS alias1 +RIGHT JOIN t2 AS alias2 +INNER JOIN t1 AS alias3 +ON (alias3.col_varchar_key = alias2.col_varchar_key ) +ON ( "v" ) IN ( +SELECT sq1_alias1.col_varchar_nokey AS sq1_field1 +FROM t1 AS sq1_alias1 +) +WHERE alias3.pk IN ( +SELECT sq2_alias1.col_int_key AS sq2_field1 +FROM ( view_c AS sq2_alias1, t1 AS sq2_alias2 ) +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE alias3 NULL ALL PRIMARY,col_varchar_key NULL NULL NULL 2 100.00 Using where; Start temporary +1 SIMPLE alias2 NULL ref col_varchar_key col_varchar_key 7 test.alias3.col_varchar_key 2 100.00 Using index +1 SIMPLE sq1_alias1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +1 SIMPLE alias1 NULL index NULL col_varchar_key 12 NULL 2 100.00 Using index; End temporary; Using join buffer (hash join) +1 SIMPLE NULL eq_ref 5 test.alias3.pk 1 100.00 NULL +3 MATERIALIZED sq2_alias2 NULL index NULL PRIMARY 4 NULL 2 100.00 Using index +3 MATERIALIZED t2 NULL index col_int_key col_int_key 5 NULL 5 100.00 Using index; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select sum(`test`.`alias1`.`col_varchar_key`) AS `field1` from `test`.`t2` `alias2` join `test`.`t1` `alias3` left join (`test`.`t1` `alias1` semi join (`test`.`t1` `sq1_alias1`)) on(((`test`.`sq1_alias1`.`col_varchar_nokey` = 'v'))) semi join (`test`.`t2` join `test`.`t1` `sq2_alias2`) where ((`test`.`alias2`.`col_varchar_key` = `test`.`alias3`.`col_varchar_key`) and (``.`sq2_field1` = `test`.`alias3`.`pk`)) +PREPARE prep_stmt_7430 FROM 'SELECT SUM( alias1.col_varchar_key ) AS field1 +FROM t1 AS alias1 +RIGHT JOIN t2 AS alias2 +INNER JOIN t1 AS alias3 +ON (alias3.col_varchar_key = alias2.col_varchar_key ) +ON ( "v" ) IN ( +SELECT sq1_alias1.col_varchar_nokey AS sq1_field1 +FROM t1 AS sq1_alias1 +) +WHERE alias3.pk IN ( +SELECT sq2_alias1.col_int_key AS sq2_field1 +FROM ( view_c AS sq2_alias1 , t1 AS sq2_alias2 ) +WHERE sq2_alias1.col_varchar_nokey <> alias2.col_varchar_key +AND sq2_alias1.col_varchar_key < "l" + ) +'; +EXECUTE prep_stmt_7430; +field1 +NULL +EXECUTE prep_stmt_7430; +field1 +NULL +EXPLAIN SELECT SUM( alias1.col_varchar_key ) AS field1 +FROM t1 AS alias1 +RIGHT JOIN t2 AS alias2 +INNER JOIN t1 AS alias3 +ON (alias3.col_varchar_key = alias2.col_varchar_key ) +ON ( "v" ) IN ( +SELECT sq1_alias1.col_varchar_nokey AS sq1_field1 +FROM t1 AS sq1_alias1 +) +WHERE alias3.pk IN ( +SELECT sq2_alias1.col_int_key AS sq2_field1 +FROM ( view_c AS sq2_alias1 , t1 AS sq2_alias2 ) +WHERE sq2_alias1.col_varchar_nokey <> alias2.col_varchar_key +AND sq2_alias1.col_varchar_key < "l" + ) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE alias3 NULL ALL PRIMARY,col_varchar_key NULL NULL NULL 2 100.00 Using where; Start temporary +1 SIMPLE t2 NULL ref col_int_key,col_varchar_key col_int_key 5 test.alias3.pk 2 40.00 Using where +1 SIMPLE alias2 NULL ref col_varchar_key col_varchar_key 7 test.alias3.col_varchar_key 2 100.00 Using index +1 SIMPLE sq2_alias2 NULL index NULL PRIMARY 4 NULL 2 100.00 Using index; Using join buffer (hash join) +1 SIMPLE sq1_alias1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +1 SIMPLE alias1 NULL index NULL col_varchar_key 12 NULL 2 100.00 Using index; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.alias2.col_varchar_key' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select sum(`test`.`alias1`.`col_varchar_key`) AS `field1` from `test`.`t2` `alias2` join `test`.`t1` `alias3` left join (`test`.`t1` `alias1` semi join (`test`.`t1` `sq1_alias1`)) on(((`test`.`sq1_alias1`.`col_varchar_nokey` = 'v'))) semi join (`test`.`t2` join `test`.`t1` `sq2_alias2`) where ((`test`.`alias2`.`col_varchar_key` = `test`.`alias3`.`col_varchar_key`) and (`test`.`t2`.`col_int_key` = `test`.`alias3`.`pk`) and (`test`.`t2`.`col_varchar_nokey` <> `test`.`alias3`.`col_varchar_key`) and (`test`.`t2`.`col_varchar_key` < 'l')) +DROP TABLE t1,t2; +DROP VIEW view_c; +# +# Bug#13902463 SEGFAULT IN BITMAP<64U>::MERGE OR ADD_KEY_FIELD +# ON SECOND EXEC OF PREP STMT +# +CREATE TABLE t1 ( +pk INT, +col_int_nokey INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +KEY col_varchar_key (col_varchar_key) +); +CREATE VIEW view_b AS SELECT * FROM t1; +PREPARE prep_stmt_20421 FROM 'SELECT alias2.col_varchar_nokey AS field1 +FROM t1 AS alias1 +INNER JOIN t1 AS alias2 +ON (alias1.col_varchar_key = alias2.col_varchar_nokey +AND ( alias1.col_int_key ) IN ( +SELECT t1.col_int_nokey +FROM t1 +) +) +WHERE alias1.col_varchar_key IN ( +SELECT sq2_alias2.col_varchar_nokey AS sq2_field1 +FROM view_b AS sq2_alias1 +INNER JOIN t1 AS sq2_alias2 +ON (sq2_alias2.col_varchar_key = sq2_alias1.col_varchar_key ) +WHERE sq2_alias1.pk > alias2.pk +) +'; +EXECUTE prep_stmt_20421; +field1 +EXECUTE prep_stmt_20421; +field1 +EXPLAIN SELECT alias2.col_varchar_nokey AS field1 +FROM t1 AS alias1 +INNER JOIN t1 AS alias2 +ON (alias1.col_varchar_key = alias2.col_varchar_nokey +AND ( alias1.col_int_key ) IN ( +SELECT t1.col_int_nokey +FROM t1 +) +) +WHERE alias1.col_varchar_key IN ( +SELECT sq2_alias2.col_varchar_nokey AS sq2_field1 +FROM view_b AS sq2_alias1 +INNER JOIN t1 AS sq2_alias2 +ON (sq2_alias2.col_varchar_key = sq2_alias1.col_varchar_key ) +WHERE sq2_alias1.pk > alias2.pk +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.alias2.pk' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `field1` from `test`.`t1` `alias1` join `test`.`t1` `alias2` semi join (`test`.`t1`) semi join (`test`.`t1` join `test`.`t1` `sq2_alias2`) where ((`test`.`t1`.`pk` > NULL) and multiple equal(NULL, `test`.`sq2_alias2`.`col_varchar_nokey`, NULL) and multiple equal(`test`.`sq2_alias2`.`col_varchar_key`, `test`.`t1`.`col_varchar_key`) and multiple equal(NULL, `test`.`t1`.`col_int_nokey`)) +ALTER TABLE t1 DROP INDEX col_varchar_key; +PREPARE prep_stmt_20421 FROM 'SELECT alias2.col_varchar_nokey AS field1 +FROM t1 AS alias1 +INNER JOIN t1 AS alias2 +ON (alias1.col_varchar_key = alias2.col_varchar_nokey +AND ( alias1.col_int_key ) IN ( +SELECT t1.col_int_nokey +FROM t1 +) +) +WHERE alias1.col_varchar_key IN ( +SELECT sq2_alias2.col_varchar_nokey AS sq2_field1 +FROM view_b AS sq2_alias1 +INNER JOIN t1 AS sq2_alias2 +ON (sq2_alias2.col_varchar_key = sq2_alias1.col_varchar_key ) +WHERE sq2_alias1.pk > alias2.pk +) +'; +EXECUTE prep_stmt_20421; +field1 +EXECUTE prep_stmt_20421; +field1 +EXPLAIN SELECT alias2.col_varchar_nokey AS field1 +FROM t1 AS alias1 +INNER JOIN t1 AS alias2 +ON (alias1.col_varchar_key = alias2.col_varchar_nokey +AND ( alias1.col_int_key ) IN ( +SELECT t1.col_int_nokey +FROM t1 +) +) +WHERE alias1.col_varchar_key IN ( +SELECT sq2_alias2.col_varchar_nokey AS sq2_field1 +FROM view_b AS sq2_alias1 +INNER JOIN t1 AS sq2_alias2 +ON (sq2_alias2.col_varchar_key = sq2_alias1.col_varchar_key ) +WHERE sq2_alias1.pk > alias2.pk +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.alias2.pk' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `field1` from `test`.`t1` `alias1` join `test`.`t1` `alias2` semi join (`test`.`t1`) semi join (`test`.`t1` join `test`.`t1` `sq2_alias2`) where ((`test`.`t1`.`pk` > NULL) and multiple equal(NULL, `test`.`sq2_alias2`.`col_varchar_nokey`, NULL) and multiple equal(`test`.`sq2_alias2`.`col_varchar_key`, `test`.`t1`.`col_varchar_key`) and multiple equal(NULL, `test`.`t1`.`col_int_nokey`)) +DROP TABLE t1; +DROP VIEW view_b; +# +# Bug#13907277: Segfault in evaluate_null_complemented_join_record +# +CREATE TABLE t1 ( +pk INTEGER, +col_varchar_nokey VARCHAR(1), +col_varchar_key VARCHAR(1), +PRIMARY KEY (pk) +); +INSERT INTO t1 VALUES (1, 'x', 'x'); +CREATE TABLE t2 ( +pk INTEGER, +PRIMARY KEY (pk) +); +INSERT INTO t2 VALUES (1); +CREATE TABLE t3 ( +pk INTEGER, +col_int_nokey INTEGER, +col_int_key INTEGER, +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk) +); +INSERT INTO t3 VALUES (1, 6, 5, 'r'); +explain SELECT outer_t1.pk, outer_t2.pk +FROM t3 AS outer_t1 +RIGHT JOIN t2 AS outer_t2 +ON outer_t1.col_int_nokey IN +(SELECT inner_t1.col_int_nokey +FROM t3 AS inner_t1 +LEFT JOIN t1 AS inner_t2 +INNER JOIN t1 AS inner_t3 +ON inner_t3.pk = inner_t2.pk +ON inner_t3.col_varchar_nokey = inner_t2.col_varchar_key +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE outer_t2 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE outer_t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL eq_ref 5 test.outer_t1.col_int_nokey 1 100.00 NULL +2 MATERIALIZED inner_t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 MATERIALIZED inner_t2 NULL ALL PRIMARY NULL NULL NULL 1 100.00 NULL +2 MATERIALIZED inner_t3 NULL eq_ref PRIMARY PRIMARY 4 test.inner_t2.pk 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`outer_t1`.`pk` AS `pk`,'1' AS `pk` from left join (`test`.`t3` `outer_t1` semi join (`test`.`t3` `inner_t1` left join (`test`.`t1` `inner_t2` join `test`.`t1` `inner_t3`) on(((`test`.`inner_t3`.`col_varchar_nokey` = `test`.`inner_t2`.`col_varchar_key`) and (`test`.`inner_t3`.`pk` = `test`.`inner_t2`.`pk`))))) on(((``.`col_int_nokey` = `test`.`outer_t1`.`col_int_nokey`))) where true +SELECT outer_t1.pk, outer_t2.pk +FROM t3 AS outer_t1 +RIGHT JOIN t2 AS outer_t2 +ON outer_t1.col_int_nokey IN +(SELECT inner_t1.col_int_nokey +FROM t3 AS inner_t1 +LEFT JOIN t1 AS inner_t2 +INNER JOIN t1 AS inner_t3 +ON inner_t3.pk = inner_t2.pk +ON inner_t3.col_varchar_nokey = inner_t2.col_varchar_key +); +pk pk +1 1 +DROP TABLE t1, t2, t3; +# End of test for bug#13907277. +# +# Bug#13955713: Assert 'JOIN->best_read < ...' on second execution +# +CREATE TABLE t1 ( +pk INTEGER, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1) +); +PREPARE stmt FROM " +SELECT MIN(alias2.col_varchar_key) AS field1 +FROM t1 AS alias1 + INNER JOIN (t1 AS alias2 + INNER JOIN t1 AS alias3 + ON 8 IN + (SELECT sq1_alias1.pk AS sq1_field2 + FROM t1 AS sq1_alias1 + WHERE 9 IN + (SELECT SUM(t1_sq1_alias1.pk) AS t1_sq1_field2 + FROM t1 AS t1_sq1_alias1 + ) + ) + ) + ON alias3.col_varchar_nokey = alias2.col_varchar_key +WHERE EXISTS + (SELECT sq2_alias1.pk AS sq2_field1 + FROM t1 AS sq2_alias1 + WHERE sq2_alias1.col_varchar_key < alias1.col_varchar_nokey + ) +"; +EXECUTE stmt; +field1 +NULL + +EXECUTE stmt; +field1 +NULL +DEALLOCATE PREPARE stmt; +DROP TABLE t1; +# End of test for bug#13955713. +# +# Bug#13956813: Segfault in memcpy from Join_cache::write_record_data() +# +CREATE TABLE t1 ( +pk INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1) +) charset latin1; +CREATE TABLE t2 ( +pk INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1) +) charset latin1; +INSERT INTO t2 VALUES +(10,'j','j'), (11,'z','z'), (12,'c','c'), (13,'a','a'), +(14,'q','q'), (15,'y','y'), (16,NULL,NULL), (17,'r','r'), +(18,'v','v'), (19,NULL,NULL), (20,'r','r'); +CREATE TABLE t3 ( +pk INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +KEY col_int_key (col_int_key) +) charset latin1; +INSERT INTO t3 VALUES +(15,NULL,'u'), (16,1,'m'), (17,9,NULL), (18,2,'o'), +(19,9,'w'), (20,2,'m'), (21,4,'q'), (22,0,NULL), +(23,4,'d'), (24,8,'g'), (25,NULL,'x'), (26,NULL,'f'), +(27,0,'p'), (28,NULL,'j'), (29,8,'c'); +CREATE VIEW view_inline_0 AS +SELECT t1.* +FROM t1 INNER JOIN t3 +ON t1.pk = t3.pk; +CREATE VIEW view_inline_1 AS +SELECT sq2_alias2.col_varchar_key AS sq2_field1, +sq2_alias1.col_varchar_key AS sq2_field2 +FROM t3 AS sq2_alias1 LEFT OUTER JOIN t3 AS sq2_alias2 +ON sq2_alias1.pk = sq2_alias2.col_int_key; +CREATE VIEW view_inline_2 AS +SELECT 'p', 'p' UNION SELECT 'k', 's'; +SET @optimizer_switch_saved= @@optimizer_switch; +SET @@optimizer_switch="derived_merge=off"; +explain SELECT SUM(alias1.col_varchar_nokey) AS field2 +FROM t2 AS alias2 +LEFT JOIN (SELECT * FROM view_inline_0) AS alias1 +ON alias2.col_varchar_key = alias1.col_varchar_key AND +(alias2.col_varchar_nokey, alias2.col_varchar_key) IN +(SELECT * FROM view_inline_1 +) +WHERE (alias1.col_varchar_key, alias1.col_varchar_nokey) IN +(SELECT * FROM view_inline_2 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL 2 100.00 NULL +1 PRIMARY alias2 NULL ALL NULL NULL NULL NULL 11 10.00 Using where; Using join buffer (hash join) +1 PRIMARY NULL eq_ref 8 test.alias2.col_varchar_nokey,test.view_inline_2.p 1 100.00 NULL +1 PRIMARY NULL ref 8 test.view_inline_2.p,test.view_inline_2.Name_exp_p 2 100.00 NULL +3 MATERIALIZED NULL ALL NULL NULL NULL NULL 30 100.00 NULL +7 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +8 UNION NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +NULL UNION RESULT NULL ALL NULL NULL NULL NULL NULL NULL Using temporary +6 DERIVED sq2_alias1 NULL ALL NULL NULL NULL NULL 15 100.00 NULL +6 DERIVED sq2_alias2 NULL ref col_int_key col_int_key 5 test.sq2_alias1.pk 2 100.00 NULL +2 DERIVED NULL ALL NULL NULL NULL NULL 15 100.00 NULL +5 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select sum(`alias1`.`col_varchar_nokey`) AS `field2` from `test`.`view_inline_2` join `test`.`t2` `alias2` join (/* select#2 */ select `test`.`view_inline_0`.`pk` AS `pk`,`test`.`view_inline_0`.`col_varchar_key` AS `col_varchar_key`,`test`.`view_inline_0`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`view_inline_0`) `alias1` semi join (`test`.`view_inline_1`) where ((``.`sq2_field1` = `test`.`alias2`.`col_varchar_nokey`) and (`alias1`.`col_varchar_nokey` = `test`.`view_inline_2`.`Name_exp_p`) and (`test`.`alias2`.`col_varchar_key` = `test`.`view_inline_2`.`p`) and (``.`sq2_field2` = `test`.`view_inline_2`.`p`) and (`alias1`.`col_varchar_key` = `test`.`view_inline_2`.`p`)) +SELECT SUM(alias1.col_varchar_nokey) AS field2 +FROM t2 AS alias2 +LEFT JOIN (SELECT * FROM view_inline_0) AS alias1 +ON alias2.col_varchar_key = alias1.col_varchar_key AND +(alias2.col_varchar_nokey, alias2.col_varchar_key) IN +(SELECT * FROM view_inline_1 +) +WHERE (alias1.col_varchar_key, alias1.col_varchar_nokey) IN +(SELECT * FROM view_inline_2 +); +field2 +NULL +SET @@optimizer_switch= @optimizer_switch_saved; +DROP VIEW view_inline_0, view_inline_1, view_inline_2; +DROP TABLE t1, t2, t3; +# End of test for bug#13956813. +# +# Bug#13974177: Assert !(tab->table->regginfo.not_exists_optimize... +# +CREATE TABLE t1 ( +pk INTEGER AUTO_INCREMENT, +col_int_nokey INTEGER, +col_int_key INTEGER, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk), +KEY (col_int_key), +KEY (col_varchar_key, col_int_key) +); +INSERT INTO t1(col_int_key, col_int_nokey, col_varchar_key, col_varchar_nokey) +VALUES +(0, 4, 'j', 'j'), (8, 6, 'v', 'v'), (1, 3, 'c', 'c'), (8, 5, 'm', 'm'), +(9, 3, 'd', 'd'), (24, 246, 'd', 'd'), (6, 2, 'y', 'y'), (1, 9, 't', 't'), +(6, 3, 'd', 'd'), (2, 8, 's', 's'), (4, 1, 'r', 'r'), (8, 8, 'm', 'm'), +(4, 8, 'b', 'b'), (4, 5, 'x', 'x'), (7, 7, 'g', 'g'), (4, 5, 'p', 'p'), +(1, 1, 'q', 'q'), (9, 6, 'w', 'w'), (4, 2, 'd', 'd'), (8, 9, 'e', 'e'); +CREATE TABLE t2 ( +pk INTEGER AUTO_INCREMENT, +col_int_nokey INTEGER NOT NULL, +col_time_key TIME NOT NULL, +col_time_nokey TIME NOT NULL, +PRIMARY KEY (pk), +KEY (col_time_key) +) ENGINE=InnoDB; +INSERT INTO t2 (col_int_nokey, col_time_key, col_time_nokey) VALUES +(7, '00:00:00', '00:00:00'), (0, '00:00:00', '00:00:00'), +(9, '06:35:17', '06:35:17'), (3, '18:07:14', '18:07:14'), +(4, '20:36:52', '20:36:52'), (2, '21:29:07', '21:29:07'), +(5, '23:45:57', '23:45:57'), (3, '22:54:57', '22:54:57'), +(1, '18:45:09', '18:45:09'), (3, '14:30:46', '14:30:46'), +(6, '19:23:43', '19:23:43'), (7, '03:39:30', '03:39:30'), +(5, '23:37:52', '23:37:52'), (1, '16:59:30', '16:59:30'), +(204, '22:21:15', '22:21:15'), (224, '12:24:37', '12:24:37'), +(9, '15:02:08', '15:02:08'), (5, '23:59:59', '23:59:59'), +(0, '08:23:30', '08:23:30'), (3, '08:32:22', '08:32:22'); +explain SELECT ot1.col_int_key AS x +FROM t1 AS ot2 +LEFT JOIN t1 AS ot1 +ON ot2.col_varchar_nokey > ot1.col_varchar_key +WHERE (ot1.col_int_nokey, ot1.pk) IN +(SELECT it1.pk AS x, +it1.col_int_nokey AS y +FROM t2 AS it2 +LEFT JOIN t2 AS it1 +ON it2.col_time_nokey = it1.col_time_key +) AND ot1.pk IS NULL +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`col_int_key` AS `x` from `test`.`t2` `it1` join `test`.`t1` `ot2` join `test`.`t1` `ot1` semi join (`test`.`t2` `it2`) where ((`test`.`ot1`.`pk` is null) and (`test`.`ot2`.`col_varchar_nokey` > `test`.`ot1`.`col_varchar_key`) and multiple equal(`test`.`ot1`.`col_int_nokey`, `test`.`it1`.`pk`) and multiple equal(`test`.`ot1`.`pk`, `test`.`it1`.`col_int_nokey`) and multiple equal(`test`.`it2`.`col_time_nokey`, `test`.`it1`.`col_time_key`)) +SELECT ot1.col_int_key AS x +FROM t1 AS ot2 +LEFT JOIN t1 AS ot1 +ON ot2.col_varchar_nokey > ot1.col_varchar_key +WHERE (ot1.col_int_nokey, ot1.pk) IN +(SELECT it1.pk AS x, +it1.col_int_nokey AS y +FROM t2 AS it2 +LEFT JOIN t2 AS it1 +ON it2.col_time_nokey = it1.col_time_key +) AND ot1.pk IS NULL +; +x +DROP TABLE t1, t2; +# End of test for bug#13974177. +# +# Bug#13971022: Assert 'keyparts > 0' failed in create_ref_for_key... +# +CREATE TABLE t1 ( +pk INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +PRIMARY KEY (pk), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +CREATE TABLE t2 ( +pk INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk) +) charset utf8mb4 ENGINE=InnoDB; +CREATE TABLE t3 ( +i INT +); +SET @optimizer_switch_saved= @@optimizer_switch; +SET @@optimizer_switch="derived_merge=off"; +explain SELECT table1.pk AS field1 +FROM ( SELECT subquery1_t1. * +FROM t2 AS subquery1_t1 +JOIN t2 AS subquery1_t2 +ON subquery1_t2.pk = subquery1_t1.pk) AS table1 +STRAIGHT_JOIN t2 AS table2 +ON table1.col_int_key IN (SELECT 7 FROM t3) +WHERE table1.col_varchar_nokey IN +(SELECT subquery3_t1.col_varchar_key AS subquery3_field1 +FROM t1 AS subquery3_t1 +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL NULL 0.00 Using where +1 PRIMARY NULL ref 7 .subquery3_field1 2 100.00 NULL +1 PRIMARY NULL const 8 const 1 100.00 NULL +1 PRIMARY table2 NULL index NULL PRIMARY 4 NULL 1 100.00 Using index; Using join buffer (hash join) +4 MATERIALIZED subquery3_t1 NULL index col_varchar_key col_varchar_key 12 NULL 0 0.00 Using index +3 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 DERIVED subquery1_t1 NULL ALL PRIMARY NULL NULL NULL 1 100.00 Using where +2 DERIVED subquery1_t2 NULL eq_ref PRIMARY PRIMARY 4 test.subquery1_t1.pk 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `table1`.`pk` AS `field1` from (/* select#2 */ select `test`.`subquery1_t1`.`pk` AS `pk`,`test`.`subquery1_t1`.`col_int_key` AS `col_int_key`,`test`.`subquery1_t1`.`col_varchar_key` AS `col_varchar_key`,`test`.`subquery1_t1`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t2` `subquery1_t1` join `test`.`t2` `subquery1_t2` where ((`test`.`subquery1_t1`.`col_int_key` = 7) and (`test`.`subquery1_t2`.`pk` = `test`.`subquery1_t1`.`pk`))) `table1` straight_join `test`.`t2` `table2` semi join (`test`.`t3`) semi join (`test`.`t1` `subquery3_t1`) where (`table1`.`col_varchar_nokey` = ``.`subquery3_field1`) +SELECT table1.pk AS field1 +FROM ( SELECT subquery1_t1. * +FROM t2 AS subquery1_t1 +JOIN t2 AS subquery1_t2 +ON subquery1_t2.pk = subquery1_t1.pk) AS table1 +STRAIGHT_JOIN t2 AS table2 +ON table1.col_int_key IN (SELECT 7 FROM t3) +WHERE table1.col_varchar_nokey IN +(SELECT subquery3_t1.col_varchar_key AS subquery3_field1 +FROM t1 AS subquery3_t1 +) +; +field1 +SET @@optimizer_switch= @optimizer_switch_saved; +DROP TABLE t1, t2, t3; +# End of test for bug#13971022. +# +# Bug#13623473 "MISSING ROWS ON SELECT AND JOIN WITH +# TIME/DATETIME COMPARE" - Subquery part of test. +# +SET TIMESTAMP=UNIX_TIMESTAMP('2012-01-31 10:14:35'); +CREATE TABLE t1 ( +pk INT NOT NULL, +col_int_nokey INT, +col_int_key INT NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +) ENGINE=InnoDB; +INSERT INTO t1 VALUES (10,1,7), (11,7,0), (12,4,9), (13,7,3), +(14,0,4), (15,2,2), (16,9,5), (17,4,3), (18,0,1), (19,9,3), (20,1,6), +(21,3,7), (22,8,5), (23,8,1), (24,18,204), (25,84,224), (26,6,9), +(27,3,5), (28,6,0), (29,6,3); +CREATE TABLE t2 ( +col_int_nokey INT NOT NULL, +col_datetime_key DATETIME NOT NULL, +col_varchar_key VARCHAR(1) NOT NULL, +KEY col_datetime_key (col_datetime_key), +KEY col_varchar_key (col_varchar_key) +) ENGINE=InnoDB; +INSERT INTO t2 VALUES (1,'2001-11-04 19:07:55','k'); +CREATE TABLE t3 ( +col_time_key TIME, +KEY col_time_key (col_time_key) +) ENGINE=InnoDB; +INSERT INTO t3 VALUES ('21:22:34'), ('10:50:38'), ('00:21:38'), +('04:08:02'), ('16:25:11'), ('10:14:58'), ('19:47:59'), ('11:14:24'), +('00:00:00'), ('00:00:00'), ('15:57:25'), ('07:05:51'), ('19:22:21'), +('03:53:16'), ('09:16:38'), ('15:37:26'), ('00:00:00'), ('05:03:03'), +('02:59:24'), ('00:01:58'); +EXPLAIN SELECT outr.col_int_nokey +FROM t2 as outr +STRAIGHT_JOIN t3 AS outr2 +ON outr2.col_time_key > outr.col_datetime_key +WHERE outr.col_int_nokey IN ( +SELECT col_int_key +FROM t1 AS innr +WHERE innr.pk >= innr.col_int_nokey +) AND ( +outr.col_int_nokey <= 6 +OR +outr.col_varchar_key IS NULL +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE outr NULL ALL col_datetime_key NULL NULL NULL 1 100.00 Using where +1 SIMPLE NULL eq_ref 4 test.outr.col_int_nokey 1 100.00 NULL +1 SIMPLE outr2 NULL index col_time_key col_time_key 4 NULL 20 33.33 Using where; Using index; Using join buffer (hash join) +2 MATERIALIZED innr NULL ALL col_int_key NULL NULL NULL 20 23.33 Using where +Warnings: +Warning 1739 Cannot use range access on index 'col_time_key' due to type or collation conversion on field 'col_time_key' +Note 1003 /* select#1 */ select `test`.`outr`.`col_int_nokey` AS `col_int_nokey` from `test`.`t2` `outr` straight_join `test`.`t3` `outr2` semi join (`test`.`t1` `innr`) where ((``.`col_int_key` = `test`.`outr`.`col_int_nokey`) and (`test`.`outr`.`col_int_nokey` <= 6) and (`test`.`innr`.`pk` >= `test`.`innr`.`col_int_nokey`) and (cast(`test`.`outr2`.`col_time_key` as datetime) > `test`.`outr`.`col_datetime_key`)) +SELECT outr.col_int_nokey +FROM t2 as outr +STRAIGHT_JOIN t3 AS outr2 +ON outr2.col_time_key > outr.col_datetime_key +WHERE outr.col_int_nokey IN ( +SELECT col_int_key +FROM t1 AS innr +WHERE innr.pk >= innr.col_int_nokey +) AND ( +outr.col_int_nokey <= 6 +OR +outr.col_varchar_key IS NULL +); +col_int_nokey +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +DROP TABLE t1,t2,t3; +SET TIMESTAMP = DEFAULT; +# End of test for bug#13623473. +# +# Bug#13980954: Missing data on left join + null value + where..in +# +CREATE TABLE t1 ( +ik INT, +vc varchar(1) +) charset utf8mb4; +INSERT INTO t1 VALUES (8, 'x'), (NULL, 'x'); +CREATE TABLE t2 ( +ik INT, +vc varchar(1) +) charset utf8mb4; +INSERT INTO t2 VALUES +(0, 'x'), (7, 'i'), (7, 'e'), (1, 'p'), (7, 's'), (1, 'j'); +explain format=json SELECT t2.vc, t2.ik AS t2_ik, t1.ik AS t1_ik +FROM t2 LEFT JOIN t1 ON t2.vc=t1.vc +WHERE t2.vc IN (SELECT vc FROM t2 AS t3); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "6.12" + }, + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 6, + "rows_produced_per_join": 6, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "0.60", + "prefix_cost": "1.11", + "data_read_per_join": "96" + }, + "used_columns": [ + "ik", + "vc" + ], + "attached_condition": "(`test`.`t2`.`vc` is not null)" + } + }, + { + "table": { + "table_name": "", + "access_type": "eq_ref", + "key": "", + "key_length": "7", + "ref": [ + "test.t2.vc" + ], + "rows_examined_per_scan": 1, + "materialized_from_subquery": { + "using_temporary_table": true, + "query_block": { + "table": { + "table_name": "t3", + "access_type": "ALL", + "rows_examined_per_scan": 6, + "rows_produced_per_join": 6, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "0.60", + "prefix_cost": "1.11", + "data_read_per_join": "96" + }, + "used_columns": [ + "vc" + ] + } + } + } + } + }, + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 12, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "1.20", + "prefix_cost": "6.12", + "data_read_per_join": "192" + }, + "used_columns": [ + "ik", + "vc" + ], + "attached_condition": "(is_not_null_compl(t1), (`test`.`t1`.`vc` = `test`.`t2`.`vc`), true)" + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`vc` AS `vc`,`test`.`t2`.`ik` AS `t2_ik`,`test`.`t1`.`ik` AS `t1_ik` from `test`.`t2` left join `test`.`t1` on((`test`.`t1`.`vc` = `test`.`t2`.`vc`)) semi join (`test`.`t2` `t3`) where (``.`vc` = `test`.`t2`.`vc`) +SELECT t2.vc, t2.ik AS t2_ik, t1.ik AS t1_ik +FROM t2 LEFT JOIN t1 ON t2.vc=t1.vc +WHERE t2.vc IN (SELECT vc FROM t2 AS t3); +vc t2_ik t1_ik +e 7 NULL +i 7 NULL +j 1 NULL +p 1 NULL +s 7 NULL +x 0 8 +x 0 NULL +DROP TABLE t1, t2; +# End of test for bug#13980954. +# +# Bug#14048292: Segfault in Item_field::result_type on 2nd execution +# of prep stmt with join of view +# +CREATE TABLE t1 ( +col_int INT +); +INSERT INTO t1 VALUES (0), (1); +CREATE VIEW view_t1 AS SELECT * FROM t1; +explain SELECT alias1.col_int +FROM t1 AS alias1 +LEFT JOIN view_t1 AS alias2 +ON alias1.col_int IN +(SELECT sq1_alias1.col_int +FROM t1 AS sq1_alias1 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE alias1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE NULL eq_ref 5 test.alias1.col_int 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED sq1_alias1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`alias1`.`col_int` AS `col_int` from `test`.`t1` `alias1` left join (`test`.`t1` semi join (`test`.`t1` `sq1_alias1`)) on(((``.`col_int` = `test`.`alias1`.`col_int`))) where true +PREPARE stmt FROM "SELECT alias1.col_int +FROM t1 AS alias1 +LEFT JOIN view_t1 AS alias2 +ON alias1.col_int IN +(SELECT sq1_alias1.col_int +FROM t1 AS sq1_alias1 +)"; +EXECUTE stmt; +col_int +0 +0 +1 +1 + +EXECUTE stmt; +col_int +0 +0 +1 +1 +DEALLOCATE PREPARE stmt; +DROP VIEW view_t1; +DROP TABLE t1; +# End of test for bug#14048292. +# +# Bug#14064201: Missing data on join of derived table + WHERE .. IN +# with two operands +# +CREATE TABLE t1 ( +col_varchar_nokey VARCHAR(1) +) charset utf8mb4; +INSERT INTO t1 VALUES +('v'), ('s'), ('l'), ('y'), ('c'), ('i'), ('h'), ('q'), ('a'), ('v'), +('u'), ('s'), ('y'), ('z'), ('h'), ('p'), ('e'), ('i'), ('y'), ('w'); +CREATE TABLE t2 ( +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +KEY col_varchar_key(col_varchar_key) +) charset utf8mb4; +INSERT INTO t2 VALUES +('j','j'), ('v','v'), ('c','c'), ('m','m'), ('d','d'), ('d','d'), ('y','y'); +SET @optimizer_switch_saved= @@optimizer_switch; +SET @@optimizer_switch="derived_merge=off"; +explain format=json SELECT * +FROM (SELECT * FROM t2) AS derived1 +LEFT JOIN t1 +USING (col_varchar_nokey) +WHERE (col_varchar_nokey, col_varchar_nokey) IN +(SELECT col_varchar_nokey, col_varchar_key +FROM t2 AS derived2 +); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "13.03" + }, + "nested_loop": [ + { + "table": { + "table_name": "", + "access_type": "ALL", + "attached_condition": "((``.`col_varchar_key` = ``.`col_varchar_nokey`) and (``.`col_varchar_nokey` is not null))", + "materialized_from_subquery": { + "using_temporary_table": true, + "query_block": { + "table": { + "table_name": "derived2", + "access_type": "ALL", + "possible_keys": [ + "col_varchar_key" + ], + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "0.70", + "prefix_cost": "1.21", + "data_read_per_join": "112" + }, + "used_columns": [ + "col_varchar_key", + "col_varchar_nokey" + ], + "attached_condition": "(`test`.`derived2`.`col_varchar_key` = `test`.`derived2`.`col_varchar_nokey`)" + } + } + } + } + }, + { + "table": { + "table_name": "derived1", + "access_type": "ref", + "possible_keys": [ + "" + ], + "key": "", + "used_key_parts": [ + "col_varchar_nokey" + ], + "key_length": "7", + "ref": [ + ".col_varchar_nokey" + ], + "rows_examined_per_scan": 2, + "rows_produced_per_join": 2, + "filtered": "100.00", + "cost_info": { + "read_cost": "3.50", + "eval_cost": "0.20", + "prefix_cost": "8.51", + "data_read_per_join": "32" + }, + "used_columns": [ + "col_varchar_key", + "col_varchar_nokey" + ], + "materialized_from_subquery": { + "using_temporary_table": true, + "dependent": false, + "cacheable": true, + "query_block": { + "select_id": 2, + "cost_info": { + "query_cost": "1.21" + }, + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "0.70", + "prefix_cost": "1.21", + "data_read_per_join": "112" + }, + "used_columns": [ + "col_varchar_key", + "col_varchar_nokey" + ] + } + } + } + } + }, + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 40, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.52", + "eval_cost": "4.00", + "prefix_cost": "13.03", + "data_read_per_join": "320" + }, + "used_columns": [ + "col_varchar_nokey" + ], + "attached_condition": "(is_not_null_compl(t1), (`test`.`t1`.`col_varchar_nokey` = `derived1`.`col_varchar_nokey`), true)" + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select `derived1`.`col_varchar_nokey` AS `col_varchar_nokey`,`derived1`.`col_varchar_key` AS `col_varchar_key` from (/* select#2 */ select `test`.`t2`.`col_varchar_key` AS `col_varchar_key`,`test`.`t2`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t2`) `derived1` left join `test`.`t1` on(((`test`.`t1`.`col_varchar_nokey` = `derived1`.`col_varchar_nokey`) and (`test`.`derived2`.`col_varchar_nokey` = `test`.`derived2`.`col_varchar_key`))) semi join (`test`.`t2` `derived2`) where ((``.`col_varchar_key` = ``.`col_varchar_nokey`) and (`derived1`.`col_varchar_nokey` = ``.`col_varchar_nokey`) and (`test`.`derived2`.`col_varchar_key` = `test`.`derived2`.`col_varchar_nokey`)) +SELECT * +FROM (SELECT * FROM t2) AS derived1 +LEFT JOIN t1 +USING (col_varchar_nokey) +WHERE (col_varchar_nokey, col_varchar_nokey) IN +(SELECT col_varchar_nokey, col_varchar_key +FROM t2 AS derived2 +); +col_varchar_nokey col_varchar_key +c c +d d +d d +j j +m m +v v +v v +y y +y y +y y +SET @@optimizer_switch= @optimizer_switch_saved; +DROP TABLE t1, t2; +CREATE TABLE t1 ( +col_int_nokey int NOT NULL, +col_int_key int NOT NULL, +KEY col_int_key (col_int_key) +); +INSERT INTO t1 VALUES +(1,7), (7,0), (4,9), (7,3), (0,4), (2,2), (9,5), (4,3), (0,1), (9,3), +(1,6), (3,7), (8,5), (8,1), (18,204), (84,224), (6,9), (3,5), (6,0), (6,3); +CREATE TABLE t2 ( +col_int_nokey int NOT NULL, +col_int_key int NOT NULL, +KEY col_int_key (col_int_key) +); +INSERT INTO t2 VALUES +(4,0), (6,8), (3,1), (5,8), (3,9), (246,24), (2,6), (9,1), (3,6), (8,2), +(1,4), (8,8), (8,4), (5,4), (7,7), (5,4), (1,1), (6,9), (2,4), (9,8); +explain format=json SELECT grandparent1.* +FROM t1 AS grandparent1 +LEFT JOIN t1 USING (col_int_nokey) +WHERE (col_int_nokey, col_int_nokey) IN +(SELECT col_int_nokey, col_int_key +FROM t2 +); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "50.53" + }, + "nested_loop": [ + { + "table": { + "table_name": "grandparent1", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 20, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "2.00", + "prefix_cost": "2.51", + "data_read_per_join": "320" + }, + "used_columns": [ + "col_int_nokey", + "col_int_key" + ] + } + }, + { + "table": { + "table_name": "", + "access_type": "eq_ref", + "key": "", + "key_length": "8", + "ref": [ + "test.grandparent1.col_int_nokey", + "test.grandparent1.col_int_nokey" + ], + "rows_examined_per_scan": 1, + "materialized_from_subquery": { + "using_temporary_table": true, + "query_block": { + "table": { + "table_name": "t2", + "access_type": "ALL", + "possible_keys": [ + "col_int_key" + ], + "rows_examined_per_scan": 20, + "rows_produced_per_join": 20, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "2.00", + "prefix_cost": "2.51", + "data_read_per_join": "320" + }, + "used_columns": [ + "col_int_nokey", + "col_int_key" + ], + "attached_condition": "(`test`.`t2`.`col_int_key` = `test`.`t2`.`col_int_nokey`)" + } + } + } + } + }, + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 400, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "40.00", + "prefix_cost": "50.53", + "data_read_per_join": "6K" + }, + "used_columns": [ + "col_int_nokey" + ], + "attached_condition": "(is_not_null_compl(t1), (`test`.`t1`.`col_int_nokey` = `test`.`grandparent1`.`col_int_nokey`), true)" + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`grandparent1`.`col_int_nokey` AS `col_int_nokey`,`test`.`grandparent1`.`col_int_key` AS `col_int_key` from `test`.`t1` `grandparent1` left join `test`.`t1` on(((`test`.`t1`.`col_int_nokey` = `test`.`grandparent1`.`col_int_nokey`) and (`test`.`t2`.`col_int_nokey` = `test`.`t2`.`col_int_key`))) semi join (`test`.`t2`) where ((``.`col_int_nokey` = `test`.`grandparent1`.`col_int_nokey`) and (``.`col_int_key` = `test`.`grandparent1`.`col_int_nokey`) and (`test`.`t2`.`col_int_key` = `test`.`t2`.`col_int_nokey`)) +SELECT grandparent1.* +FROM t1 AS grandparent1 +LEFT JOIN t1 USING (col_int_nokey) +WHERE (col_int_nokey, col_int_nokey) IN +(SELECT col_int_nokey, col_int_key +FROM t2 +); +col_int_nokey col_int_key +1 6 +1 6 +1 7 +1 7 +7 0 +7 0 +7 3 +7 3 +8 1 +8 1 +8 5 +8 5 +DROP TABLE t1, t2; +CREATE TABLE t1 ( +pk int, +col_int_key int, +col_datetime_key datetime, +col_varchar_key varchar(1), +col_varchar_nokey varchar(1), +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_datetime_key (col_datetime_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4 engine=MyISAM; +INSERT INTO t1 VALUES +(10,7,'2004-06-06 04:22:12','v','v'), (11,0,'2005-11-13 01:12:31','s','s'), +(12,9,'2002-05-04 01:50:00','l','l'), (13,3,'2004-10-27 10:28:45','y','y'), +(14,4,'2006-07-22 05:24:23','c','c'), (15,2,'2002-05-16 21:34:03','i','i'), +(16,5,'2008-04-17 10:45:30','h','h'), (17,3,'2009-04-21 02:58:02','q','q'), +(18,1,'2008-01-11 11:01:51','a','a'), (19,3,'1900-01-01 00:00:00','v','v'), +(20,6,'2007-05-17 18:24:57','u','u'), (21,7,'2007-08-07 00:00:00','s','s'), +(22,5,'2001-08-28 00:00:00','y','y'), (23,1,'2004-04-16 00:27:28','z','z'), +(24,204,'2005-05-03 07:06:22','h','h'), (25,224,'2009-03-11 17:09:50','p','p'), +(26,9,'2007-12-08 01:54:28','e','e'), (27,5,'2009-07-28 18:19:54','i','i'), +(28,0,'2008-06-08 00:00:00','y','y'), (29,3,'2005-02-09 09:20:26','w','w'); +CREATE TABLE t2 ( +pk int, +col_int_key int, +col_datetime_key datetime, +col_varchar_key varchar(1), +col_varchar_nokey varchar(1), +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_datetime_key (col_datetime_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4 engine=MyISAM; +INSERT INTO t2 VALUES +(1,0,'2002-02-13 17:30:06','j','j'), (2,8,'2008-09-27 00:34:58','v','v'), +(3,1,'2007-05-28 00:00:00','c','c'), (4,8,'2009-07-25 09:21:20','m','m'), +(5,9,'2002-01-16 00:00:00','d','d'), (6,24,'2006-10-12 04:32:53','d','d'), +(7,6,'2001-02-15 03:08:38','y','y'), (8,1,'2004-10-02 20:31:15','t','t'), +(9,6,'2002-08-20 22:48:00','d','d'), (10,2,'1900-01-01 00:00:00','s','s'), +(11,4,'2005-08-15 00:00:00','r','r'), (12,8,'1900-01-01 00:00:00','m','m'), +(13,4,'2008-05-16 08:09:06','b','b'), (14,4,'2001-01-20 12:47:23','x','x'), +(15,7,'2008-07-02 00:00:00','g','g'), (16,4,'1900-01-01 00:00:00','p','p'), +(17,1,'2002-12-08 11:34:58','q','q'), (18,9,'1900-01-01 00:00:00','w','w'), +(19,4,'1900-01-01 00:00:00','d','d'), (20,8,'2002-08-25 20:35:06','e','e'); +SELECT alias1.col_datetime_key +FROM t2 AS alias1 +RIGHT JOIN t2 AS alias2 +JOIN t2 AS alias3 +ON alias3.pk = alias2.pk +ON alias3.col_varchar_nokey = alias2.col_varchar_key OR +alias2.col_varchar_nokey +WHERE (alias2.col_varchar_key, alias2.col_varchar_key) IN +(SELECT sq2_alias2.col_varchar_key, sq2_alias1.col_varchar_nokey +FROM t1 AS sq2_alias1, t1 AS sq2_alias2 +WHERE sq2_alias2.col_int_key < 2); +col_datetime_key +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +2001-01-20 12:47:23 +2001-01-20 12:47:23 +2001-02-15 03:08:38 +2001-02-15 03:08:38 +2002-01-16 00:00:00 +2002-01-16 00:00:00 +2002-02-13 17:30:06 +2002-02-13 17:30:06 +2002-08-20 22:48:00 +2002-08-20 22:48:00 +2002-08-25 20:35:06 +2002-08-25 20:35:06 +2002-12-08 11:34:58 +2002-12-08 11:34:58 +2004-10-02 20:31:15 +2004-10-02 20:31:15 +2005-08-15 00:00:00 +2005-08-15 00:00:00 +2006-10-12 04:32:53 +2006-10-12 04:32:53 +2007-05-28 00:00:00 +2007-05-28 00:00:00 +2008-05-16 08:09:06 +2008-05-16 08:09:06 +2008-07-02 00:00:00 +2008-07-02 00:00:00 +2008-09-27 00:34:58 +2008-09-27 00:34:58 +2009-07-25 09:21:20 +2009-07-25 09:21:20 +ALTER TABLE t1 DISABLE KEYS; +ALTER TABLE t2 DISABLE KEYS; +explain format=json SELECT alias1.col_datetime_key +FROM t2 AS alias1 +RIGHT JOIN t2 AS alias2 +JOIN t2 AS alias3 +ON alias3.pk = alias2.pk +ON alias3.col_varchar_nokey = alias2.col_varchar_key OR +alias2.col_varchar_nokey +WHERE (alias2.col_varchar_key, alias2.col_varchar_key) IN +(SELECT sq2_alias2.col_varchar_key, sq2_alias1.col_varchar_nokey +FROM t1 AS sq2_alias1, t1 AS sq2_alias2 +WHERE sq2_alias2.col_int_key < 2); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "52.48" + }, + "nested_loop": [ + { + "table": { + "table_name": "", + "access_type": "ALL", + "attached_condition": "(``.`col_varchar_nokey` = ``.`col_varchar_key`)", + "materialized_from_subquery": { + "using_temporary_table": true, + "query_block": { + "nested_loop": [ + { + "table": { + "table_name": "sq2_alias2", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 6, + "filtered": "33.33", + "cost_info": { + "read_cost": "1.86", + "eval_cost": "0.67", + "prefix_cost": "2.53", + "data_read_per_join": "213" + }, + "used_columns": [ + "col_int_key", + "col_varchar_key" + ], + "attached_condition": "(`test`.`sq2_alias2`.`col_int_key` < 2)" + } + }, + { + "table": { + "table_name": "sq2_alias1", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 13, + "filtered": "10.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.53", + "eval_cost": "1.33", + "prefix_cost": "16.39", + "data_read_per_join": "426" + }, + "used_columns": [ + "col_varchar_nokey" + ], + "attached_condition": "(`test`.`sq2_alias1`.`col_varchar_nokey` = `test`.`sq2_alias2`.`col_varchar_key`)" + } + } + ] + } + } + } + }, + { + "table": { + "table_name": "alias2", + "access_type": "ALL", + "possible_keys": [ + "PRIMARY" + ], + "rows_examined_per_scan": 20, + "rows_produced_per_join": 2, + "filtered": "10.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.53", + "eval_cost": "0.20", + "prefix_cost": "47.25", + "data_read_per_join": "64" + }, + "used_columns": [ + "pk", + "col_varchar_key", + "col_varchar_nokey" + ], + "attached_condition": "(`test`.`alias2`.`col_varchar_key` = ``.`col_varchar_key`)" + } + }, + { + "table": { + "table_name": "alias3", + "access_type": "eq_ref", + "possible_keys": [ + "PRIMARY" + ], + "key": "PRIMARY", + "used_key_parts": [ + "pk" + ], + "key_length": "4", + "ref": [ + "test.alias2.pk" + ], + "rows_examined_per_scan": 1, + "rows_produced_per_join": 2, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.20", + "prefix_cost": "47.95", + "data_read_per_join": "64" + }, + "used_columns": [ + "pk", + "col_varchar_nokey" + ] + } + }, + { + "table": { + "table_name": "alias1", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 40, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.53", + "eval_cost": "4.00", + "prefix_cost": "52.48", + "data_read_per_join": "1K" + }, + "used_columns": [ + "col_datetime_key" + ], + "attached_condition": "(is_not_null_compl(alias1), ((`test`.`alias3`.`col_varchar_nokey` = `test`.`alias2`.`col_varchar_key`) or (0 <> `test`.`alias2`.`col_varchar_nokey`)), true)" + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`alias1`.`col_datetime_key` AS `col_datetime_key` from `test`.`t2` `alias2` join `test`.`t2` `alias3` left join `test`.`t2` `alias1` on((((`test`.`alias3`.`col_varchar_nokey` = `test`.`alias2`.`col_varchar_key`) and (`test`.`sq2_alias1`.`col_varchar_nokey` = `test`.`sq2_alias2`.`col_varchar_key`)) or (0 <> `test`.`alias2`.`col_varchar_nokey`))) semi join (`test`.`t1` `sq2_alias1` join `test`.`t1` `sq2_alias2`) where ((`test`.`alias3`.`pk` = `test`.`alias2`.`pk`) and (``.`col_varchar_nokey` = ``.`col_varchar_key`) and (`test`.`alias2`.`col_varchar_key` = ``.`col_varchar_key`) and (`test`.`sq2_alias1`.`col_varchar_nokey` = `test`.`sq2_alias2`.`col_varchar_key`) and (`test`.`sq2_alias2`.`col_int_key` < 2)) +SELECT alias1.col_datetime_key +FROM t2 AS alias1 +RIGHT JOIN t2 AS alias2 +JOIN t2 AS alias3 +ON alias3.pk = alias2.pk +ON alias3.col_varchar_nokey = alias2.col_varchar_key OR +alias2.col_varchar_nokey +WHERE (alias2.col_varchar_key, alias2.col_varchar_key) IN +(SELECT sq2_alias2.col_varchar_key, sq2_alias1.col_varchar_nokey +FROM t1 AS sq2_alias1, t1 AS sq2_alias2 +WHERE sq2_alias2.col_int_key < 2); +col_datetime_key +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +2001-01-20 12:47:23 +2001-01-20 12:47:23 +2001-02-15 03:08:38 +2001-02-15 03:08:38 +2002-01-16 00:00:00 +2002-01-16 00:00:00 +2002-02-13 17:30:06 +2002-02-13 17:30:06 +2002-08-20 22:48:00 +2002-08-20 22:48:00 +2002-08-25 20:35:06 +2002-08-25 20:35:06 +2002-12-08 11:34:58 +2002-12-08 11:34:58 +2004-10-02 20:31:15 +2004-10-02 20:31:15 +2005-08-15 00:00:00 +2005-08-15 00:00:00 +2006-10-12 04:32:53 +2006-10-12 04:32:53 +2007-05-28 00:00:00 +2007-05-28 00:00:00 +2008-05-16 08:09:06 +2008-05-16 08:09:06 +2008-07-02 00:00:00 +2008-07-02 00:00:00 +2008-09-27 00:34:58 +2008-09-27 00:34:58 +2009-07-25 09:21:20 +2009-07-25 09:21:20 +DROP TABLE t1, t2; +# End of test for bug#14064201. +# +# Bug#18223655:ASSERTION FAILED: (INT)IDX >= 0 +# && IDX < PARENT_JOIN->TABLES +# +CREATE TABLE b (d INT); +CREATE TABLE c (a INT, b INT,c INT,d BLOB NOT NULL); +SELECT(SELECT 1 +FROM b WHERE(SELECT 1 IN (SELECT 1 FROM b WHERE 1 NOT BETWEEN d AND 1) +FROM b) IN (SELECT d FROM c)) as cc FROM b; +cc +INSERT INTO b VALUE(1); +INSERT INTO c VALUES(1,2,3,'1'),(2,3,4,'1'),(3,4,5,'C'); +SELECT(SELECT d FROM b WHERE(SELECT d IN +(SELECT d FROM b WHERE 1 NOT BETWEEN d AND 1) FROM b) IN +(SELECT d FROM c)) as cc FROM c; +cc +1 +1 +1 +DROP TABLE b,c; +# +# Bug#18447874:WRONG RESULT COMING FROM SEMI-JOIN +# +CREATE TABLE b ( +d INT(11) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE c ( +d BLOB +) ; +CREATE TABLE d ( +b INT(11) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO b VALUES(1),(2),(4); +INSERT INTO c VALUES(1),(2),(3); +SELECT 1 FROM b WHERE (SELECT 1 FROM d ) IN (SELECT d FROM c) ; +1 +INSERT INTO d VALUES(2); +SELECT 1 FROM b WHERE (SELECT 1 FROM d ) IN (SELECT d FROM c) ; +1 +1 +1 +1 +DROP TABLE b,c,d; +# +# Bug#17292723:INCORRECT RESULT FOR (SELECT...) IN (SELECT...) STATEMENT +# +CREATE TABLE t1 ( +ID int(11) NOT NULL AUTO_INCREMENT, +id2 int(11) DEFAULT NULL, +id3 int(11) DEFAULT NULL, +id4 varchar(150) COLLATE utf8_spanish_ci NOT NULL, +id5 int(11) DEFAULT NULL, +PRIMARY KEY (ID), +KEY id2 (id2), +KEY id3 (id3), +KEY id5 (id5) +) ENGINE=InnoDB; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 3778 'utf8_spanish_ci' is a collation of the deprecated character set UTF8MB3. Please consider using UTF8MB4 with an appropriate collation instead. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES +(123,1,1,'1',NULL), +(124,1,1,'2',NULL), +(125,1,1,'4',NULL), +(126,1,1,'3',NULL), +(127,1,1,'6',NULL), +(128,1,1,'8',NULL); +CREATE TABLE t2 ( +id6 int(11) NOT NULL, +id7 int(11) NOT NULL, +PRIMARY KEY (id6,id7), +KEY id7 (id7) +) ENGINE=InnoDB; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (126,123),(130,123),(135,123); +SELECT ID +FROM t1 p0 +WHERE p0.id3=1 +AND ( (SELECT p1.id FROM t1 p1 WHERE p1.id=123) IN (SELECT p3.id FROM t2 +p2, t1 p3 WHERE p0.id=p2.id6 AND p2.id7=p3.id)); +ID +126 +DROP TABLE t1,t2; +set @@optimizer_switch=@old_opt_switch; +# End of 5.6 tests +# +# Bug#19336348 DEBUG CRASH AT SETUP_SEMIJOIN_DUPS_ELIMINATION IN SQL/SQL_SELECT.CC +# +CREATE TABLE t1 ( +col_varchar_nokey varchar(1) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t1 VALUES ('c'),(NULL),('x'); +CREATE TABLE t2 ( +pk int, +col_varchar_key varchar(1), +PRIMARY KEY (pk), +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t2 VALUES (10,'l'),(11,'p'); +ANALYZE TABLE t1,t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN SELECT 1 +FROM t1 AS outr +WHERE outr.col_varchar_nokey IN +( +SELECT innr.col_varchar_key +FROM t2 AS innr +WHERE innr.pk <= 7 +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE outr NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +2 MATERIALIZED innr NULL range PRIMARY,col_varchar_key PRIMARY 4 NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` `outr` semi join (`test`.`t2` `innr`) where ((`test`.`outr`.`col_varchar_nokey` = ``.`col_varchar_key`) and (`test`.`innr`.`pk` <= 7)) +SELECT 1 +FROM t1 AS outr +WHERE outr.col_varchar_nokey IN +( +SELECT innr.col_varchar_key +FROM t2 AS innr +WHERE innr.pk <= 7 +) +; +1 +DROP TABLE t1,t2; +# +# Bug#18174394 BLOBS: CRASH AFTER UNINITIALIZED VALUES IN ITEM_FIELD::STR_RESULT +# +CREATE TABLE t1(d BLOB, b BLOB); +INSERT INTO t1(d,b) VALUES ('aaaa',''),('bnbb',''); +SELECT 1 FROM t1 +WHERE (SELECT b FROM t1) IN (SELECT (d>=1) FROM t1); +ERROR 21000: Subquery returns more than 1 row +DROP TABLE t1; +# +# Bug#19779600: ASSERT FAILED IN REPLACE_SUBCONDITION WITH IN +# PREDICATE INSIDE IN PREDICATE +# +CREATE TABLE t(X INT) ENGINE=InnoDB; +INSERT INTO t VALUES (1); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +EXPLAIN SELECT 1 FROM t WHERE (1 IN (SELECT 1 FROM t)) IN (SELECT 1 FROM t); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 PRIMARY NULL eq_ref 4 const 1 100.00 NULL +3 MATERIALIZED t NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SUBQUERY t NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t` semi join (`test`.`t`) where true +SELECT 1 FROM t WHERE (1 IN (SELECT 1 FROM t)) IN (SELECT 1 FROM t); +1 +1 +DROP TABLE t; +# +# Bug#19465034 ASSERT ON SETUP_SEMIJOIN_DUPS_ELIMINATION IN SQL/SQL_SELECT.CC +# +CREATE TABLE t1 ( +pk INTEGER NOT NULL, +i1 INTEGER NOT NULL, +PRIMARY KEY (pk) +) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1,1); +CREATE TABLE t2 ( +pk INTEGER NOT NULL, +c1 VARCHAR(1) NOT NULL, +PRIMARY KEY (pk), +KEY c1_key (c1) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t2 VALUES (1,'j'),(2,'v'),(3,'c'); +CREATE TABLE t3 ( +pk INTEGER NOT NULL, +c1 VARCHAR(1) NOT NULL, +PRIMARY KEY (pk), +KEY c1_key (c1) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t3 VALUES (10,'v'),(11,'s'); +ANALYZE TABLE t1, t2, t3; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +EXPLAIN SELECT * +FROM t1 JOIN t2 ON t1.i1 >= t2.pk +WHERE t2.c1 IN ( +SELECT t3.c1 +FROM t3 +WHERE t3.pk < 3 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using join buffer (hash join) +1 SIMPLE t2 NULL ref PRIMARY,c1_key c1_key 6 .c1 1 33.33 Using where; Using index +2 MATERIALIZED t3 NULL range PRIMARY,c1_key PRIMARY 4 NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`i1` AS `i1`,`test`.`t2`.`pk` AS `pk`,`test`.`t2`.`c1` AS `c1` from `test`.`t1` join `test`.`t2` semi join (`test`.`t3`) where ((`test`.`t2`.`c1` = ``.`c1`) and (`test`.`t3`.`pk` < 3) and (`test`.`t1`.`i1` >= `test`.`t2`.`pk`)) +SELECT * +FROM t1 JOIN t2 ON t1.i1 >= t2.pk +WHERE t2.c1 IN ( +SELECT t3.c1 +FROM t3 +WHERE t3.pk < 3 +); +pk i1 pk c1 +DROP TABLE t1,t2,t3; +# +# Bug#19586047: CRASH IN ARG_COMPARATOR::SET_CMP_FUNC +# +CREATE TABLE t1(x INT) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT 1 FROM t1 WHERE EXISTS(SELECT 1) IN (SELECT 1 FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 PRIMARY NULL const 4 const 1 100.00 NULL +3 MATERIALIZED t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` semi join (`test`.`t1`) where true +SELECT 1 FROM t1 WHERE EXISTS(SELECT 1) IN (SELECT 1 FROM t1); +1 +1 +EXPLAIN SELECT 1 FROM t1 WHERE (SELECT 1, 2 FROM t1) IN (SELECT 1, 2 FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 1 100.00 End temporary; Using join buffer (hash join) +2 SUBQUERY t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` semi join (`test`.`t1`) where true +SELECT 1 FROM t1 WHERE (SELECT 1, 2 FROM t1) IN (SELECT 1, 2 FROM t1); +1 +1 +EXPLAIN SELECT 1 FROM t1 WHERE +(SELECT 1, 2 FROM t1 WHERE x = 2) IN (SELECT 1, 2 FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +2 SUBQUERY t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` semi join (`test`.`t1`) where false +SELECT 1 FROM t1 WHERE +(SELECT 1, 2 FROM t1 WHERE x = 2) IN (SELECT 1, 2 FROM t1); +1 +DROP TABLE t1; +# +#Bug#20119743 ASSERTIONQEP_TAB->USE_ORDER() IN ENUM_NESTED_LOOP_STATE +# EVALUATE_JOIN_RECORD +# +CREATE TABLE t1 ( +pk int(11) NOT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +PRIMARY KEY (pk) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (1,'x'); +CREATE TABLE t2 ( +col_date_key date DEFAULT NULL, +col_int_key int(11) DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +KEY col_int_key (col_int_key), +KEY col_date_key (col_date_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES ('2000-12-03', 8, 'x', 'x'),('2008-05-03', 7, 'd', 'd'), +('2005-12-06', 1, 'r', 'r'),('2000-04-10', 7, 'f', 'f'), +('2002-11-05', 9, 'y', 'y'),('2000-09-06', NULL, 'u', 'u'), +(NULL, 1, 'm', 'm'),('2007-06-14', 9, NULL, NULL), +('2007-11-17', 2, 'o', 'o'),('2009-02-23', 9, 'w', 'w'), +('2007-01-08', 2, 'm', 'm'), ('2008-06-10', 4, 'q', 'q'), +('2002-10-20', 0, NULL, NULL),('2008-09-12', 4, 'd', 'd'), +('2006-06-16', 8, 'g', 'g'),('2004-09-18', NULL, 'x', 'x'), +('1900-01-01', NULL, 'f', 'f'),('2005-09-13', 0, 'p', 'p'), +('2007-04-09', NULL, 'j', 'j'),('2000-09-20', 8, 'c', 'c'); +CREATE TABLE t3 ( +pk int(11) NOT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +PRIMARY KEY (pk) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t3 VALUES (1, 'c'),(2, 'c'),(3, 'q'),(4, 'g'),(5, 'e'),(6, 'l'), +(7, NULL),(8, 'v'),(9, 'c'),(10, 'u'),(11, 'x'),(12, 'x'),(13, 'x'),(14, 'l'), +(15, 'e'),(16, 's'),(17, 'k'),(18, 'm'),(19, 'x'),(20, 's'); +ANALYZE TABLE t1,t2,t3; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +EXPLAIN SELECT r1.col_date_key +FROM t2 AS r1 +WHERE r1.col_int_key NOT IN +(SELECT ir2.pk +FROM t2 AS ir1 STRAIGHT_JOIN t1 AS ir2 +ON ir2.col_varchar_nokey = ir1.col_varchar_key +WHERE ir2.col_varchar_nokey > r1.col_varchar_nokey +AND ir2.pk IN +(SELECT iir2.pk +FROM t2 AS iir1 RIGHT JOIN t3 AS iir2 +ON iir2.col_varchar_nokey = iir1.col_varchar_key)) +ORDER BY r1.col_date_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY r1 NULL ALL NULL NULL NULL NULL 20 100.00 Using where; Using filesort +2 DEPENDENT SUBQUERY NULL ALL NULL NULL NULL NULL NULL 100.00 Using where +2 DEPENDENT SUBQUERY ir1 NULL index col_varchar_key col_varchar_key 12 NULL 20 100.00 Using where; Using index; Using join buffer (hash join) +2 DEPENDENT SUBQUERY ir2 NULL eq_ref PRIMARY PRIMARY 4 func 1 100.00 Using where; Full scan on NULL key +3 MATERIALIZED iir2 NULL eq_ref PRIMARY PRIMARY 4 func 1 100.00 Full scan on NULL key +3 MATERIALIZED iir1 NULL ref col_varchar_key col_varchar_key 7 test.iir2.col_varchar_nokey 1 100.00 Using index +SELECT r1.col_date_key +FROM t2 AS r1 +WHERE r1.col_int_key NOT IN +(SELECT ir2.pk +FROM t2 AS ir1 STRAIGHT_JOIN t1 AS ir2 +ON ir2.col_varchar_nokey = ir1.col_varchar_key +WHERE ir2.col_varchar_nokey > r1.col_varchar_nokey +AND ir2.pk IN +(SELECT iir2.pk +FROM t2 AS iir1 RIGHT JOIN t3 AS iir2 +ON iir2.col_varchar_nokey = iir1.col_varchar_key)) +ORDER BY r1.col_date_key; +col_date_key +2000-04-10 +2000-09-20 +2000-12-03 +2002-10-20 +2002-11-05 +2004-09-18 +2005-09-13 +2006-06-16 +2007-01-08 +2007-06-14 +2007-11-17 +2008-05-03 +2008-06-10 +2008-09-12 +2009-02-23 +SELECT COUNT(r1.col_date_key) AS COUNT_NUM +FROM t2 AS r1 +WHERE r1.col_int_key NOT IN +(SELECT ir2.pk +FROM t2 AS ir1 STRAIGHT_JOIN t1 AS ir2 +ON ir2.col_varchar_nokey = ir1.col_varchar_key +WHERE ir2.col_varchar_nokey > r1.col_varchar_nokey +AND ir2.pk IN +(SELECT iir2.pk +FROM t2 AS iir1 RIGHT JOIN t3 AS iir2 +ON iir2.col_varchar_nokey = iir1.col_varchar_key +WHERE iir2.pk<3)); +COUNT_NUM +15 +DROP TABLE t1,t2,t3; +# +# Bug#20554585 ASSERT JOIN()->TABLES == 0... IN JOIN_TAB::GET_SJ_STRATEGY ON SUBQUERY + VAR +# +CREATE TABLE t1 ( +pk int NOT NULL, +PRIMARY KEY (pk) +); +CREATE TABLE t2 ( +pk int NOT NULL, +col_int_key int, +col_varchar_key varchar(1), +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key) +); +CREATE TABLE t3 ( +pk int NOT NULL, +col_int_key int, +col_varchar_key varchar(1), +col_varchar varchar(1), +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key) +); +INSERT INTO t3 VALUES (1,4,'c','g'),(20,1,'i','p'); +CREATE TABLE t4 ( +col_int int +); +CREATE TABLE t5 ( +col_varchar_key varchar(1), +pk int NOT NULL, +col_int int, +PRIMARY KEY (pk), +KEY col_varchar_key (col_varchar_key) +); +SELECT table1.col_varchar_key AS field1 +FROM (t3 AS table1 +INNER JOIN ( +SELECT SUBQUERY1_t1.* +FROM (t1 AS SUBQUERY1_t1 +RIGHT JOIN (t2 AS SUBQUERY1_t2 +INNER JOIN t3 AS SUBQUERY1_t3 +ON (SUBQUERY1_t3.col_varchar_key = SUBQUERY1_t2.col_varchar_key) +) ON (SUBQUERY1_t3.col_int_key = SUBQUERY1_t2.pk) +) +WHERE SUBQUERY1_t2.col_varchar_key >= ANY ( +SELECT CHILD_SUBQUERY1_t2.col_varchar AS CHILD_SUBQUERY1_field1 +FROM (t2 AS CHILD_SUBQUERY1_t1 +LEFT OUTER JOIN t3 AS CHILD_SUBQUERY1_t2 +ON (CHILD_SUBQUERY1_t2.col_int_key = CHILD_SUBQUERY1_t1.col_int_key) +) +WHERE CHILD_SUBQUERY1_t1.pk >= SUBQUERY1_t2.pk +) +) AS table2 +ON (table2.pk = table1.pk) +) +WHERE (EXISTS (( +SELECT DISTINCT SUBQUERY2_t2.col_int AS SUBQUERY2_field1 +FROM (t4 AS SUBQUERY2_t1 +LEFT OUTER JOIN t5 AS SUBQUERY2_t2 +ON (SUBQUERY2_t2.pk = SUBQUERY2_t1.col_int) +) +WHERE SUBQUERY2_t2.col_varchar_key != @var4 +))) +AND table1.col_int_key < (35 + 192) +ORDER BY field1 +; +field1 +DROP TABLE t1, t2, t3, t4, t5; +# +# Bug#18892055: MISSING DATA ON SELECT ... IN WITH JOINS AND INNODB +# ENGINE +# +CREATE TABLE t1 ( +col_int_key INT, +pk INT NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +) ENGINE = INNODB; +INSERT INTO t1 VALUES +( 0, 3 ), +( 0, 4 ), +( 3, 1 ), +( 900000000, 2 ), +( 1368719360, 5 ), +( 1922236416, 6 ), +( 8,7 ); +CREATE TABLE t2 ( +pk INT NOT NULL, +col_int INT, +PRIMARY KEY (pk) +) ENGINE = INNODB; +INSERT INTO t2 VALUES +( 1, 3 ), +( 2, 2 ), +( 3, 8 ), +( 4, 7 ); +CREATE TABLE t3 ( +col_int_key INT, +col_int INT, +KEY (col_int_key) +) ENGINE = INNODB; +INSERT INTO t3 VALUES +( 5, 1 ), +( -1, -1 ), +( 300000000, 1 ), +( 8, 1 ); +CREATE TABLE t4 ( col_int_key INT ) ENGINE = INNODB; +INSERT INTO t4 VALUES +(0), +(3), +(8), +(900000000), +(1368719360), +(1922236416); +ANALYZE TABLE t1, t2, t3, t4; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +test.t4 analyze status OK +explain SELECT * +FROM t4 +WHERE (col_int_key) IN ( +SELECT t1.col_int_key +FROM t1 LEFT JOIN ( t2 JOIN t3 ON t3.col_int_key = t2.col_int ) USING ( pk ) +WHERE t3.col_int IS NULL +) +ORDER BY col_int_key +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using temporary; Using filesort +1 SIMPLE t4 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Using join buffer (hash join) +2 MATERIALIZED t1 NULL index col_int_key col_int_key 5 NULL 7 100.00 Using index +2 MATERIALIZED t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.pk 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL col_int_key NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`col_int_key` AS `col_int_key` from `test`.`t4` semi join (`test`.`t1` left join (`test`.`t2` join `test`.`t3`) on(((`test`.`t1`.`pk` = `test`.`t2`.`pk`) and (`test`.`t3`.`col_int_key` = `test`.`t2`.`col_int`)))) where ((`test`.`t4`.`col_int_key` = ``.`col_int_key`) and (`test`.`t3`.`col_int` is null)) order by `test`.`t4`.`col_int_key` +explain format=tree SELECT * +FROM t4 +WHERE (col_int_key) IN ( +SELECT t1.col_int_key +FROM t1 LEFT JOIN ( t2 JOIN t3 ON t3.col_int_key = t2.col_int ) USING ( pk ) +WHERE t3.col_int IS NULL +) +ORDER BY col_int_key +; +EXPLAIN +-> Sort: t4.col_int_key + -> Stream results (cost=11.14 rows=7) + -> Inner hash join (t4.col_int_key = ``.col_int_key) (cost=11.14 rows=7) + -> Table scan on t4 (cost=0.35 rows=6) + -> Hash + -> Table scan on (cost=0.37..2.59 rows=7) + -> Materialize with deduplication (cost=4.47..6.69 rows=7) + -> Filter: (t1.col_int_key is not null) (cost=3.40 rows=7) + -> Filter: (t3.col_int is null) (cost=3.40 rows=7) + -> Nested loop left join (cost=3.40 rows=7) + -> Index scan on t1 using col_int_key (cost=0.95 rows=7) + -> Nested loop inner join (cost=1.21 rows=1) + -> Single-row index lookup on t2 using PRIMARY (pk=t1.pk) (cost=0.26 rows=1) + -> Filter: (t3.col_int_key = t2.col_int) (cost=0.09 rows=1) + -> Table scan on t3 (cost=0.09 rows=4) + +SELECT * +FROM t4 +WHERE (col_int_key) IN ( +SELECT t1.col_int_key +FROM t1 LEFT JOIN ( t2 JOIN t3 ON t3.col_int_key = t2.col_int ) USING ( pk ) +WHERE t3.col_int IS NULL +) +ORDER BY col_int_key +; +col_int_key +0 +3 +8 +900000000 +1368719360 +1922236416 +DROP TABLE t1, t2, t3, t4; +# +# Bug#20835095 CRASH AT CREATE_REF_FOR_KEY IN SQL/SQL_SELECT.CC +# +CREATE TABLE t1 ( +pk INTEGER, +var_10_latin1 VARCHAR(10) CHARACTER SET latin1, +var_255_utf8 VARCHAR(255) CHARACTER SET utf8, +var_255_latin1 VARCHAR(255) CHARACTER SET latin1, +var_10_utf8 VARCHAR(10) CHARACTER SET utf8, +PRIMARY KEY (pk) +); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +CREATE VIEW v1 AS SELECT * FROM t1; +INSERT INTO t1 VALUES +(1,'FROCJ','korrhrspki','UAYVL','BPZIS'), +(2,'him','a','CHYKN','OZZQT'), +(3,'WBITK','ULWBF','have','rhrh'), +(4,'or','right','up','it'), +(5,'GGDCP','x','who','as'), +(6,'j','i','e','w'); +CREATE TABLE tv +SELECT var_255_utf8 AS field1 +FROM t1; +EXPLAIN SELECT * FROM tv +WHERE field1 IN ( +SELECT tv1.var_255_utf8 +FROM v1 AS tv1 LEFT JOIN v1 AS tv2 ON tv1.var_10_latin1=tv2.var_10_utf8); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE tv NULL ALL NULL NULL NULL NULL 6 100.00 Using where +1 SIMPLE NULL eq_ref 768 test.tv.field1 1 100.00 NULL +2 MATERIALIZED t1 NULL ALL NULL NULL NULL NULL 6 100.00 NULL +2 MATERIALIZED t1 NULL ALL NULL NULL NULL NULL 6 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`tv`.`field1` AS `field1` from `test`.`tv` semi join (`test`.`t1` left join (`test`.`t1`) on((`test`.`t1`.`var_10_latin1` = `test`.`t1`.`var_10_utf8`))) where (``.`var_255_utf8` = `test`.`tv`.`field1`) +SELECT * FROM tv +WHERE field1 IN ( +SELECT tv1.var_255_utf8 +FROM v1 AS tv1 LEFT JOIN v1 AS tv2 ON tv1.var_10_latin1=tv2.var_10_utf8); +field1 +korrhrspki +a +ULWBF +right +x +i +DROP VIEW v1; +DROP TABLE t1, tv; +# 17832047 Crash in calculate_materialization_costs +CREATE TABLE t1(a INTEGER PRIMARY KEY); +INSERT INTO t1 VALUES (0),(1),(2); +SELECT 1 FROM t1 +WHERE 1 IN +(SELECT 1 BETWEEN (LENGTH(a) IN (SELECT 1 FROM t1)) AND 1 +FROM t1 +); +1 +1 +1 +1 +DROP TABLE t1; +# 17845989 Assertion failed: !(used_tables() & ... +CREATE TABLE a(b INTEGER) engine=innodb; +CREATE TABLE c(a INTEGER) engine=innodb; +SELECT 1 +FROM a +WHERE 1 IN (SELECT (a.b IS NULL) IN (SELECT 1 FROM c) FROM c) +; +1 +DROP TABLE a, c; +# +# Bug#18194196: OPTIMIZER EXECUTES STATEMENT INPERFORMANT +# +CREATE TABLE t1 (uid INTEGER, fid INTEGER, INDEX(uid)); +INSERT INTO t1 VALUES +(1,1), (1,2), (1,3), (1,4), +(2,5), (2,6), (2,7), (2,8), +(3,1), (3,2), (3,9); +CREATE TABLE t2 (uid INT PRIMARY KEY, name VARCHAR(128), INDEX(name)); +INSERT INTO t2 VALUES +(1, "A"), (2, "B"), (3, "C"), (4, "D"), (5, "E"), +(6, "F"), (7, "G"), (8, "H"), (9, "I"); +CREATE TABLE t3 (uid INT, fid INT, INDEX(uid)); +INSERT INTO t3 VALUES +(1,1), (1,2), (1,3),(1,4), +(2,5), (2,6), (2,7), (2,8), +(3,1), (3,2), (3,9); +CREATE TABLE t4 (uid INT PRIMARY KEY, name VARCHAR(128), INDEX(name)); +INSERT INTO t4 VALUES +(1, "A"), (2, "B"), (3, "C"), (4, "D"), (5, "E"), +(6, "F"), (7, "G"), (8, "H"), (9, "I"); +ANALYZE TABLE t1,t2,t3,t4; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +test.t4 analyze status OK +EXPLAIN SELECT name FROM t2, t1 +WHERE t1.uid IN (SELECT t4.uid FROM t4, t3 WHERE t3.uid=1 AND t4.uid=t3.fid) +AND t2.uid=t1.fid; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ref uid uid 5 const 4 100.00 Using where; Start temporary +1 SIMPLE t4 NULL eq_ref PRIMARY PRIMARY 4 test.t3.fid 1 100.00 Using index +1 SIMPLE t1 NULL ref uid uid 5 test.t3.fid 4 100.00 Using where; End temporary +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.fid 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`name` AS `name` from `test`.`t4` join `test`.`t2` join `test`.`t1` semi join (`test`.`t3`) where ((`test`.`t4`.`uid` = `test`.`t3`.`fid`) and (`test`.`t1`.`uid` = `test`.`t3`.`fid`) and (`test`.`t3`.`uid` = 1) and (`test`.`t2`.`uid` = `test`.`t1`.`fid`)) +FLUSH STATUS; +SELECT name FROM t2, t1 +WHERE t1.uid IN (SELECT t4.uid FROM t4, t3 WHERE t3.uid=1 AND t4.uid=t3.fid) +AND t2.uid=t1.fid; +name +A +A +B +B +C +D +E +F +G +H +I +SHOW STATUS LIKE '%handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 20 +Handler_read_last 0 +Handler_read_next 15 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +DROP TABLE t1,t2,t3,t4; +# End of test for Bug#18194196 +# +# Bug#21184091 ASSERT `READ_ROWS >= 0.0' AT +# COST_MODEL_SERVER::TMPTABLE_READWRITE_COST() +# +CREATE TABLE t1 ( +pk INTEGER, +col_varchar varchar(1), +col_int INTEGER, +PRIMARY KEY (pk) +) ENGINE=MyISAM; +CREATE TABLE t2 ( +col_int INTEGER, +col_varchar varchar(1) +) ENGINE=MyISAM; +INSERT INTO t2 VALUES (7,'x'); +INSERT INTO t2 VALUES (4,'z'); +SELECT t2.col_varchar +FROM t2 STRAIGHT_JOIN t1 ON t2.col_varchar = t1.col_varchar +JOIN t2 AS table3 ON t1.pk = table3.col_int +WHERE t1.pk IN (SELECT col_int FROM t1); +col_varchar +DROP TABLE t1,t2; +# End of test for Bug#21184091 +# Bug#21139722: Assertion failed: !(used_tables() & ((table_map) 1) ... +CREATE TABLE t1(a INTEGER) engine=innodb; +CREATE TABLE t2(b INTEGER) engine=innodb; +explain SELECT 1 +FROM (SELECT 1 IN (SELECT 1 +FROM t1 +WHERE (SELECT 1 FROM t2 HAVING b) NOT IN (SELECT 1 FROM t2) +) +FROM t2 +) AS z; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DERIVED t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +3 DEPENDENT SUBQUERY t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +5 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +4 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1276 Field or reference 'b' of SELECT #4 was resolved in SELECT #2 +Note 1003 /* select#1 */ select 1 AS `1` from (/* select#2 */ select (1,(/* select#3 */ select 1 from `test`.`t1` where ((/* select#4 */ select 1 from `test`.`t2` having (0 <> `test`.`t2`.`b`)),(/* select#5 */ select 1 from `test`.`t2` where (outer_field_is_not_null, (((/* select#4 */ select 1 from `test`.`t2` having (0 <> `test`.`t2`.`b`))) = 1), true)) is false))) AS `1 IN (SELECT 1 +FROM t1 +WHERE (SELECT 1 FROM t2 HAVING b) NOT IN (SELECT 1 FROM t2) +)` from `test`.`t2`) `z` +SELECT 1 +FROM (SELECT 1 IN (SELECT 1 +FROM t1 +WHERE (SELECT 1 FROM t2 HAVING b) NOT IN (SELECT 1 FROM t2) +) +FROM t2 +) AS z; +1 +DROP TABLE t1, t2; +CREATE TABLE t1(a INTEGER) engine=innodb; +explain SELECT (SELECT a FROM t1 AS t2 +WHERE a IN (SELECT t1.a+t2.a FROM t1 AS t3)) +FROM t1 AS t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +2 DEPENDENT SUBQUERY t3 NULL ALL NULL NULL NULL NULL 1 100.00 End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #3 was resolved in SELECT #1 +Note 1276 Field or reference 'test.t2.a' of SELECT #3 was resolved in SELECT #2 +Note 1003 /* select#1 */ select (/* select#2 */ select `test`.`t2`.`a` from `test`.`t1` `t2` semi join (`test`.`t1` `t3`) where (`test`.`t2`.`a` = (`test`.`t1`.`a` + `test`.`t2`.`a`))) AS `(SELECT a FROM t1 AS t2 +WHERE a IN (SELECT t1.a+t2.a FROM t1 AS t3))` from `test`.`t1` +SELECT (SELECT a FROM t1 AS t2 +WHERE a IN (SELECT t1.a+t2.a FROM t1 AS t3)) +FROM t1 AS t1; +(SELECT a FROM t1 AS t2 +WHERE a IN (SELECT t1.a+t2.a FROM t1 AS t3)) +DROP TABLE t1; +# End of test for Bug#21139722 +SET DEFAULT_STORAGE_ENGINE=INNODB; +# +# Bug#21139402 ASSERTION FAILED: LENGTH > 0 && KEYPARTS != 0, CRASH IN JOIN::OPTIMIZE_KEYUSE +# +CREATE TABLE t1 (a INT, b INT, PRIMARY KEY(a)); +CREATE TABLE t2 (c INT PRIMARY KEY); +EXPLAIN SELECT 1 FROM t1 +WHERE 1 IN +(SELECT (c IS NULL) IN (SELECT a FROM t1 WHERE b) FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +3 SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` semi join (`test`.`t2`) where false +SELECT 1 FROM t1 +WHERE 1 IN +(SELECT (c IS NULL) IN (SELECT a FROM t1 WHERE b) FROM t2); +1 +DROP TABLE t1,t2; +# +# Bug#21619634 ACCESS OF DEALLOCATED ITEM_OUTER_REF CAUSES CRASH: PREPARED STMT +# +create table cc (i int) engine="innodb"; +insert into cc values (1); +select (select count(i) from cc as cc_alias +where (cc.i in (select cc_alias.i from cc))) +from cc group by i; +(select count(i) from cc as cc_alias +where (cc.i in (select cc_alias.i from cc))) +1 +prepare stmt from +"select (select count(i) from cc as cc_alias + where (cc.i in (select cc_alias.i from cc))) + from cc group by i"; +execute stmt; +(select count(i) from cc as cc_alias + where (cc.i in (select cc_alias.i from cc))) +1 +execute stmt; +(select count(i) from cc as cc_alias + where (cc.i in (select cc_alias.i from cc))) +1 +drop table cc; +# +# Bug #22305361: QUERY WITH MATERIALIZED TABLE RETURNS INCORRECT +# RESULTS IN 5.6 +# +CREATE TABLE t(a INT,b INT); +INSERT INTO t VALUES (1,0),(1,0),(1,0),(1,0),(1,1); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +EXPLAIN SELECT * +FROM t AS t1 +WHERE t1.a IN (SELECT t2.a +FROM t AS t2 +WHERE CONCAT(t2.a,'') NOT IN (SELECT t3.a +FROM t AS t3 +WHERE t3.b=1)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 5 100.00 Using where +1 PRIMARY NULL eq_ref 5 test.t1.a 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 5 100.00 Using where +3 SUBQUERY t3 NULL ALL NULL NULL NULL NULL 5 20.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t` `t1` semi join (`test`.`t` `t2`) where ((``.`a` = `test`.`t1`.`a`) and (concat(`test`.`t2`.`a`,''),concat(`test`.`t2`.`a`,'') in ( (/* select#3 */ select `test`.`t3`.`a` from `test`.`t` `t3` where (`test`.`t3`.`b` = 1) having true ), (concat(`test`.`t2`.`a`,'') in on where ((concat(`test`.`t2`.`a`,'') = ``.`a`)))) is false)) +SELECT * +FROM t AS t1 +WHERE t1.a IN (SELECT t2.a +FROM t AS t2 +WHERE CONCAT(t2.a,'') NOT IN (SELECT t3.a +FROM t AS t3 +WHERE t3.b=1)); +a b +DROP TABLE t; +# +# Bug#24287772 SUBQUERY RETURNS EMPTY LIST WHILE IDENTICAL QUERY +# WITH JOIN RETURNS RESULT +# +CREATE TABLE t SELECT 4096 c; +SELECT c FROM t WHERE 1 IN +(SELECT t.c = page_size FROM information_schema.innodb_cmpmem); +c +4096 +DROP TABLE t; +# +# Bug #29132639: WL#12470: SIG 6 IN CONNECTJOINS|SQL/SQL_EXECUTOR.C +# +CREATE TABLE t1 ( f1 TIME, f2 VARCHAR(1) ); +INSERT INTO t1 VALUES ('08:35:24', 'X'), ('14:51:13', 'S'), ('11:22:33', 'Q'); +CREATE TABLE t2 ( pk INTEGER ); +INSERT INTO t2 VALUES (1), (2); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN FORMAT=tree SELECT * FROM t1 WHERE EXISTS ( SELECT alias1.f2 FROM t2 LEFT JOIN t1 ON 1 LEFT JOIN t1 AS alias1 ON 1 ); +EXPLAIN +-> Inner hash join (no condition) (cost=9.59 rows=54) + -> Table scan on t1 (cost=0.55 rows=3) + -> Hash + -> Constant row from (cost=0.00..0.00 rows=1) + -> Materialize with deduplication (cost=3.94..3.94 rows=18) + -> Left hash join (no condition) (cost=2.14 rows=18) + -> Left hash join (no condition) (cost=1.12 rows=6) + -> Table scan on t2 (cost=0.45 rows=2) + -> Hash + -> Table scan on t1 (cost=0.28 rows=3) + -> Hash + -> Table scan on alias1 (cost=0.09 rows=3) + +SELECT * FROM t1 WHERE EXISTS ( SELECT alias1.f2 FROM t2 LEFT JOIN t1 ON 1 LEFT JOIN t1 AS alias1 ON 1 ); +f1 f2 +08:35:24 X +11:22:33 Q +14:51:13 S +DROP TABLE t1, t2; +set optimizer_switch=default; diff --git a/mysql-test/r/subquery_sj_mat_bka.result-pq b/mysql-test/r/subquery_sj_mat_bka.result-pq new file mode 100644 index 000000000000..7850fc004c69 --- /dev/null +++ b/mysql-test/r/subquery_sj_mat_bka.result-pq @@ -0,0 +1,13226 @@ +set optimizer_switch='batched_key_access=on,mrr_cost_based=off'; +set optimizer_switch='semijoin=on,materialization=on'; +set @old_opt_switch=@@optimizer_switch; +set optimizer_switch='subquery_materialization_cost_based=off'; +drop table if exists t0, t1, t2, t10, t11, t12; +create table t1 (a int not null, b int, primary key (a)); +create table t2 (a int not null, primary key (a)); +create table t3 (a int not null, b int, primary key (a)); +insert into t1 values (1,10), (2,20), (3,30), (4,40); +insert into t2 values (2), (3), (4), (5); +insert into t3 values (10,3), (20,4), (30,5); +select * from t2 where t2.a in (select a from t1); +a +2 +3 +4 +explain select * from t2 where t2.a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index PRIMARY PRIMARY 4 NULL 4 100.00 Using index +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t1` join `test`.`t2` where (`test`.`t1`.`a` = `test`.`t2`.`a`) +select * from t2 where t2.a in (select a from t1 where t1.b <> 30); +a +2 +4 +explain select * from t2 where t2.a in (select a from t1 where t1.b <> 30); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL PRIMARY NULL NULL NULL 4 75.00 Using where +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`a` = `test`.`t1`.`a`) and (`test`.`t1`.`b` <> 30)) +select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a); +a +2 +3 +explain select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL index PRIMARY PRIMARY 4 NULL 3 100.00 Using index +1 SIMPLE t1 NULL ALL PRIMARY NULL NULL NULL 4 25.00 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t1` join `test`.`t3` join `test`.`t2` where ((`test`.`t2`.`a` = `test`.`t1`.`a`) and (`test`.`t1`.`b` = `test`.`t3`.`a`)) +drop table t1, t2, t3; +create table t1 (a int, b int, index a (a,b)); +create table t2 (a int, index a (a)); +create table t3 (a int, b int, index a (a)); +insert into t1 values (1,10), (2,20), (3,30), (4,40); +create table t0(a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +insert into t1 +select rand()*100000+200,rand()*100000 from t0 A, t0 B, t0 C, t0 D; +insert into t2 values (2), (3), (4), (5); +insert into t3 values (10,3), (20,4), (30,5); +select * from t2 where t2.a in (select a from t1); +a +2 +3 +4 +explain select * from t2 where t2.a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index a a 5 NULL 4 100.00 Using where; Using index +1 SIMPLE NULL eq_ref 5 test.t2.a 1 100.00 NULL +2 MATERIALIZED t1 NULL index a a 10 NULL 10004 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1`) where (``.`a` = `test`.`t2`.`a`) +select * from t2 where t2.a in (select a from t1 where t1.b <> 30); +a +2 +4 +explain select * from t2 where t2.a in (select a from t1 where t1.b <> 30); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index a a 5 NULL 4 100.00 Using where; Using index +1 SIMPLE NULL eq_ref 5 test.t2.a 1 100.00 NULL +2 MATERIALIZED t1 NULL index a a 10 NULL 10004 90.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1`) where ((``.`a` = `test`.`t2`.`a`) and (`test`.`t1`.`b` <> 30)) +select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a); +a +2 +3 +explain select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index a a 5 NULL 4 100.00 Using where; Using index +1 SIMPLE NULL eq_ref 5 test.t2.a 1 100.00 NULL +2 MATERIALIZED t3 NULL index a a 5 NULL 3 100.00 Using index +2 MATERIALIZED t1 NULL index a a 10 NULL 10004 10.00 Using where; Using index; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1` join `test`.`t3`) where ((``.`a` = `test`.`t2`.`a`) and (`test`.`t1`.`b` = `test`.`t3`.`a`)) +insert into t1 values (3,31); +select * from t2 where t2.a in (select a from t1 where t1.b <> 30); +a +2 +3 +4 +select * from t2 where t2.a in (select a from t1 where t1.b <> 30 and t1.b <> 31); +a +2 +4 +explain select * from t2 where t2.a in (select a from t1 where t1.b <> 30); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index a a 5 NULL 4 100.00 Using where; Using index +1 SIMPLE NULL eq_ref 5 test.t2.a 1 100.00 NULL +2 MATERIALIZED t1 NULL index a a 10 NULL 10005 90.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1`) where ((``.`a` = `test`.`t2`.`a`) and (`test`.`t1`.`b` <> 30)) +drop table t0, t1, t2, t3; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1(a int, b int); +insert into t1 values (0,0),(1,1),(2,2); +create table t2 as select * from t1; +create table t11(a int, b int); +create table t10 (pk int, a int, primary key(pk)); +insert into t10 select a,a from t0; +create table t12 like t10; +insert into t12 select * from t10; +Flattened because of dependency, t10=func(t1) +explain select * from t1 where a in (select pk from t10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t1` where (`test`.`t10`.`pk` = `test`.`t1`.`a`) +select * from t1 where a in (select pk from t10); +a b +0 0 +1 1 +2 2 +A confluent case of dependency +explain select * from t1 where a in (select a from t10 where pk=12); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t1` where (multiple equal(12, NULL) and multiple equal(`test`.`t1`.`a`, NULL)) +select * from t1 where a in (select a from t10 where pk=12); +a b +explain select * from t1 where a in (select a from t10 where pk=9); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t10 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t1` where ((`test`.`t1`.`a` = '9')) +select * from t1 where a in (select a from t10 where pk=9); +a b +An empty table inside +explain select * from t1 where a in (select a from t11); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 0.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +2 MATERIALIZED t11 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t11`) where (`test`.`t1`.`a` = ``.`a`) +select * from t1 where a in (select a from t11); +a b +explain select * from t1 where a in (select pk from t10) and b in (select pk from t10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using index +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.t1.b 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t10` join `test`.`t1` where ((`test`.`t10`.`pk` = `test`.`t1`.`b`) and (`test`.`t10`.`pk` = `test`.`t1`.`a`)) +select * from t1 where a in (select pk from t10) and b in (select pk from t10); +a b +0 0 +1 1 +2 2 +flattening a nested subquery +explain select * from t1 where a in (select pk from t10 where t10.a in (select pk from t12)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using where +1 SIMPLE t12 NULL eq_ref PRIMARY PRIMARY 4 test.t10.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t12` join `test`.`t1` where ((`test`.`t10`.`pk` = `test`.`t1`.`a`) and (`test`.`t12`.`pk` = `test`.`t10`.`a`)) +select * from t1 where a in (select pk from t10 where t10.a in (select pk from t12)); +a b +0 0 +1 1 +2 2 +flattening subquery w/ several tables +explain select * from t1 where a in (select t10.pk from t10, t12 where t12.pk=t10.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using where +1 SIMPLE t12 NULL eq_ref PRIMARY PRIMARY 4 test.t10.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t12` join `test`.`t1` where ((`test`.`t10`.`pk` = `test`.`t1`.`a`) and (`test`.`t12`.`pk` = `test`.`t10`.`a`)) +subqueries within outer joins go into ON expr. +explain +select * from t1 left join (t2 A, t2 B) on ( A.A= t1.A and B.A in (select pk from t10)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE A NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE B NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.B.A 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`A` AS `A`,`test`.`t1`.`B` AS `B`,`test`.`A`.`A` AS `A`,`test`.`A`.`B` AS `B`,`test`.`B`.`A` AS `A`,`test`.`B`.`B` AS `B` from `test`.`t1` left join (`test`.`t10` join `test`.`t2` `A` join `test`.`t2` `B`) on(((`test`.`t10`.`pk` = `test`.`B`.`A`) and (`test`.`A`.`A` = `test`.`t1`.`A`))) where true +t2 should be wrapped into OJ-nest, so we have "t1 LJ (t2 J t10)" +explain +select * from t1 left join t2 on (t2.A= t1.A and t2.A in (select pk from t10)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.t1.A 1 100.00 Using index +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`A` AS `A`,`test`.`t1`.`B` AS `B`,`test`.`t2`.`A` AS `A`,`test`.`t2`.`B` AS `B` from `test`.`t1` left join (`test`.`t10` join `test`.`t2`) on(((`test`.`t10`.`pk` = `test`.`t1`.`A`) and (`test`.`t2`.`A` = `test`.`t1`.`A`))) where true +we shouldn't flatten if we're going to get a join of > MAX_TABLES. +explain select * from +t1 s00, t1 s01, t1 s02, t1 s03, t1 s04,t1 s05,t1 s06,t1 s07,t1 s08,t1 s09, +t1 s10, t1 s11, t1 s12, t1 s13, t1 s14,t1 s15,t1 s16,t1 s17,t1 s18,t1 s19, +t1 s20, t1 s21, t1 s22, t1 s23, t1 s24,t1 s25,t1 s26,t1 s27,t1 s28,t1 s29, +t1 s30, t1 s31, t1 s32, t1 s33, t1 s34,t1 s35,t1 s36,t1 s37,t1 s38,t1 s39, +t1 s40, t1 s41, t1 s42, t1 s43, t1 s44,t1 s45,t1 s46,t1 s47,t1 s48,t1 s49 +where +s00.a in ( +select m00.a from +t1 m00, t1 m01, t1 m02, t1 m03, t1 m04,t1 m05,t1 m06,t1 m07,t1 m08,t1 m09, +t1 m10, t1 m11, t1 m12, t1 m13, t1 m14,t1 m15,t1 m16,t1 m17,t1 m18,t1 m19 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY s00 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 PRIMARY s01 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s02 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s03 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s04 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s05 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s06 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s07 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s08 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s09 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s10 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s11 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s12 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s13 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s14 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s15 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s16 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s17 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s18 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s19 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s20 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s21 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s22 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s23 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s24 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s25 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s26 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s27 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s28 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s29 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s30 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s31 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s32 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s33 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s34 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s35 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s36 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s37 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s38 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s39 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s40 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s41 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s42 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s43 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s44 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s45 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s46 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s47 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s48 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s49 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 SUBQUERY m00 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 SUBQUERY m01 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 SUBQUERY m02 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 SUBQUERY m03 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 SUBQUERY m04 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 SUBQUERY m05 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 SUBQUERY m06 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 SUBQUERY m07 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 SUBQUERY m08 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 SUBQUERY m09 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 SUBQUERY m10 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 SUBQUERY m11 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 SUBQUERY m12 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 SUBQUERY m13 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 SUBQUERY m14 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 SUBQUERY m15 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 SUBQUERY m16 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 SUBQUERY m17 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 SUBQUERY m18 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 SUBQUERY m19 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`s00`.`a` AS `a`,`test`.`s00`.`b` AS `b`,`test`.`s01`.`a` AS `a`,`test`.`s01`.`b` AS `b`,`test`.`s02`.`a` AS `a`,`test`.`s02`.`b` AS `b`,`test`.`s03`.`a` AS `a`,`test`.`s03`.`b` AS `b`,`test`.`s04`.`a` AS `a`,`test`.`s04`.`b` AS `b`,`test`.`s05`.`a` AS `a`,`test`.`s05`.`b` AS `b`,`test`.`s06`.`a` AS `a`,`test`.`s06`.`b` AS `b`,`test`.`s07`.`a` AS `a`,`test`.`s07`.`b` AS `b`,`test`.`s08`.`a` AS `a`,`test`.`s08`.`b` AS `b`,`test`.`s09`.`a` AS `a`,`test`.`s09`.`b` AS `b`,`test`.`s10`.`a` AS `a`,`test`.`s10`.`b` AS `b`,`test`.`s11`.`a` AS `a`,`test`.`s11`.`b` AS `b`,`test`.`s12`.`a` AS `a`,`test`.`s12`.`b` AS `b`,`test`.`s13`.`a` AS `a`,`test`.`s13`.`b` AS `b`,`test`.`s14`.`a` AS `a`,`test`.`s14`.`b` AS `b`,`test`.`s15`.`a` AS `a`,`test`.`s15`.`b` AS `b`,`test`.`s16`.`a` AS `a`,`test`.`s16`.`b` AS `b`,`test`.`s17`.`a` AS `a`,`test`.`s17`.`b` AS `b`,`test`.`s18`.`a` AS `a`,`test`.`s18`.`b` AS `b`,`test`.`s19`.`a` AS `a`,`test`.`s19`.`b` AS `b`,`test`.`s20`.`a` AS `a`,`test`.`s20`.`b` AS `b`,`test`.`s21`.`a` AS `a`,`test`.`s21`.`b` AS `b`,`test`.`s22`.`a` AS `a`,`test`.`s22`.`b` AS `b`,`test`.`s23`.`a` AS `a`,`test`.`s23`.`b` AS `b`,`test`.`s24`.`a` AS `a`,`test`.`s24`.`b` AS `b`,`test`.`s25`.`a` AS `a`,`test`.`s25`.`b` AS `b`,`test`.`s26`.`a` AS `a`,`test`.`s26`.`b` AS `b`,`test`.`s27`.`a` AS `a`,`test`.`s27`.`b` AS `b`,`test`.`s28`.`a` AS `a`,`test`.`s28`.`b` AS `b`,`test`.`s29`.`a` AS `a`,`test`.`s29`.`b` AS `b`,`test`.`s30`.`a` AS `a`,`test`.`s30`.`b` AS `b`,`test`.`s31`.`a` AS `a`,`test`.`s31`.`b` AS `b`,`test`.`s32`.`a` AS `a`,`test`.`s32`.`b` AS `b`,`test`.`s33`.`a` AS `a`,`test`.`s33`.`b` AS `b`,`test`.`s34`.`a` AS `a`,`test`.`s34`.`b` AS `b`,`test`.`s35`.`a` AS `a`,`test`.`s35`.`b` AS `b`,`test`.`s36`.`a` AS `a`,`test`.`s36`.`b` AS `b`,`test`.`s37`.`a` AS `a`,`test`.`s37`.`b` AS `b`,`test`.`s38`.`a` AS `a`,`test`.`s38`.`b` AS `b`,`test`.`s39`.`a` AS `a`,`test`.`s39`.`b` AS `b`,`test`.`s40`.`a` AS `a`,`test`.`s40`.`b` AS `b`,`test`.`s41`.`a` AS `a`,`test`.`s41`.`b` AS `b`,`test`.`s42`.`a` AS `a`,`test`.`s42`.`b` AS `b`,`test`.`s43`.`a` AS `a`,`test`.`s43`.`b` AS `b`,`test`.`s44`.`a` AS `a`,`test`.`s44`.`b` AS `b`,`test`.`s45`.`a` AS `a`,`test`.`s45`.`b` AS `b`,`test`.`s46`.`a` AS `a`,`test`.`s46`.`b` AS `b`,`test`.`s47`.`a` AS `a`,`test`.`s47`.`b` AS `b`,`test`.`s48`.`a` AS `a`,`test`.`s48`.`b` AS `b`,`test`.`s49`.`a` AS `a`,`test`.`s49`.`b` AS `b` from `test`.`t1` `s00` join `test`.`t1` `s01` join `test`.`t1` `s02` join `test`.`t1` `s03` join `test`.`t1` `s04` join `test`.`t1` `s05` join `test`.`t1` `s06` join `test`.`t1` `s07` join `test`.`t1` `s08` join `test`.`t1` `s09` join `test`.`t1` `s10` join `test`.`t1` `s11` join `test`.`t1` `s12` join `test`.`t1` `s13` join `test`.`t1` `s14` join `test`.`t1` `s15` join `test`.`t1` `s16` join `test`.`t1` `s17` join `test`.`t1` `s18` join `test`.`t1` `s19` join `test`.`t1` `s20` join `test`.`t1` `s21` join `test`.`t1` `s22` join `test`.`t1` `s23` join `test`.`t1` `s24` join `test`.`t1` `s25` join `test`.`t1` `s26` join `test`.`t1` `s27` join `test`.`t1` `s28` join `test`.`t1` `s29` join `test`.`t1` `s30` join `test`.`t1` `s31` join `test`.`t1` `s32` join `test`.`t1` `s33` join `test`.`t1` `s34` join `test`.`t1` `s35` join `test`.`t1` `s36` join `test`.`t1` `s37` join `test`.`t1` `s38` join `test`.`t1` `s39` join `test`.`t1` `s40` join `test`.`t1` `s41` join `test`.`t1` `s42` join `test`.`t1` `s43` join `test`.`t1` `s44` join `test`.`t1` `s45` join `test`.`t1` `s46` join `test`.`t1` `s47` join `test`.`t1` `s48` join `test`.`t1` `s49` where (`test`.`s00`.`a`,`test`.`s00`.`a` in ( (/* select#2 */ select `test`.`m00`.`a` from `test`.`t1` `m00` join `test`.`t1` `m01` join `test`.`t1` `m02` join `test`.`t1` `m03` join `test`.`t1` `m04` join `test`.`t1` `m05` join `test`.`t1` `m06` join `test`.`t1` `m07` join `test`.`t1` `m08` join `test`.`t1` `m09` join `test`.`t1` `m10` join `test`.`t1` `m11` join `test`.`t1` `m12` join `test`.`t1` `m13` join `test`.`t1` `m14` join `test`.`t1` `m15` join `test`.`t1` `m16` join `test`.`t1` `m17` join `test`.`t1` `m18` join `test`.`t1` `m19` where true ), (`test`.`s00`.`a` in on where ((`test`.`s00`.`a` = ``.`a`))))) +select * from +t1 left join t2 on (t2.a= t1.a and t2.a in (select pk from t10)) +where t1.a < 5; +a b a b +0 0 0 0 +1 1 1 1 +2 2 2 2 +prepare s1 from +' select * from + t1 left join t2 on (t2.a= t1.a and t2.a in (select pk from t10)) + where t1.a < 5'; +execute s1; +a b a b +0 0 0 0 +1 1 1 1 +2 2 2 2 +execute s1; +a b a b +0 0 0 0 +1 1 1 1 +2 2 2 2 +insert into t1 select (A.a + 10 * B.a),1 from t0 A, t0 B; +explain select * from t1 where a in (select pk from t10 where pk<3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t10 NULL range PRIMARY PRIMARY 4 NULL 4 100.00 Using where; Using index +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 103 10.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t1` where ((`test`.`t1`.`a` = `test`.`t10`.`pk`) and (`test`.`t10`.`pk` < 3)) +drop table t0, t1, t2; +drop table t10, t11, t12; +# +# Check that subqueries with outer joins or straight_join work for +# different permutations of const and non-const tables. (Ref. Bug#46692) +# +CREATE TABLE t1 (i INTEGER); +CREATE TABLE t2 (i INTEGER); +CREATE TABLE t3 (i INTEGER); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 0 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 0 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 0 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 1 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 1 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 1 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 2 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 2 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 2 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (0); +DELETE FROM t2; +INSERT INTO t1 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 0 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where ((``.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 0 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where ((``.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 0 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where ((``.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 1 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where ((``.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 1 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where ((``.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 1 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where ((``.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 2 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where ((``.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 2 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where ((``.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 2 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where ((``.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (0); +DELETE FROM t2; +INSERT INTO t1 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 0 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 0.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = ``.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 0.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = ``.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 0.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = ``.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 0.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 0.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t1`.`i` = ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL const 5 const 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL const 5 const 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL const 5 const 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 0 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = ``.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = ``.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = ``.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t1`.`i` = ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL const 5 const 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL const 5 const 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL const 5 const 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 0 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = ``.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = ``.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = ``.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +1 +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t1`.`i` = ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL const 5 const 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL const 5 const 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL const 5 const 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 1 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 0.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = ``.`i`) and (`test`.`t2`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 0.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = ``.`i`) and (`test`.`t2`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 0.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = ``.`i`) and (`test`.`t2`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 0.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 0.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t1`.`i` = ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL const 5 const 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL const 5 const 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL const 5 const 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 1 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = ``.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = ``.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = ``.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t1`.`i` = ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL const 5 const 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL const 5 const 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL const 5 const 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 1 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = ``.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = ``.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = ``.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +1 +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t1`.`i` = ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +1 +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL const 5 const 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL const 5 const 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL const 5 const 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 2 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 0.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = ``.`i`) and (`test`.`t2`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 0.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = ``.`i`) and (`test`.`t2`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 0.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = ``.`i`) and (`test`.`t2`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 0.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 0.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t1`.`i` = ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL const 5 const 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL const 5 const 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL const 5 const 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 2 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = ``.`i`) and (`test`.`t2`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = ``.`i`) and (`test`.`t2`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = ``.`i`) and (`test`.`t2`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t1`.`i` = ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL const 5 const 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL const 5 const 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL const 5 const 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 2 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE NULL eq_ref 5 test.t1.i 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = `test`.`t1`.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +1 +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +1 +2 + +EXECUTE stmt; +i +1 +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE NULL eq_ref 5 test.t1.i 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = `test`.`t1`.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +1 +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE NULL eq_ref 5 test.t1.i 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = `test`.`t1`.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +1 +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +1 +2 + +EXECUTE stmt; +i +1 +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE NULL eq_ref 5 test.t1.i 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (``.`i` = `test`.`t1`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +1 +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE NULL eq_ref 5 test.t1.i 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (``.`i` = `test`.`t1`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +1 +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL const 5 const 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL const 5 const 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (0); +DELETE FROM t2; +INSERT INTO t1 VALUES (0); +DROP TABLE t1, t2, t3; +create table x1(k int primary key, d1 int, d2 int); +create table x2(k int primary key, d1 int, d2 int); +insert into x1 values +(10, 10, 10), +(20, 20, 20), +(21, 20, null), +(30, null, 30), +(40, 40, 40); +insert into x2 values +(10, 10, 10), +(20, 20, 20), +(21, 20, null), +(30, null, 30); +select * +from x1 +where (d1, d2) in (select d1, d2 +from x2); +k d1 d2 +10 10 10 +20 20 20 +select * +from x1 +where (d1, d2) in (select d1, d2 +from x2) is true; +k d1 d2 +10 10 10 +20 20 20 +select * +from x1 +where (d1, d2) in (select d1, d2 +from x2) is false; +k d1 d2 +40 40 40 +select * +from x1 +where (d1, d2) in (select d1, d2 +from x2) is unknown; +k d1 d2 +21 20 NULL +30 NULL 30 +select * +from x1 +where d1 in (select d1 +from x2 +where x1.d2=x2.d2); +k d1 d2 +10 10 10 +20 20 20 +select * +from x1 +where d1 in (select d1 +from x2 +where x1.d2=x2.d2) is true; +k d1 d2 +10 10 10 +20 20 20 +select * +from x1 +where d1 in (select d1 +from x2 +where x1.d2=x2.d2) is false; +k d1 d2 +21 20 NULL +40 40 40 +select * +from x1 +where d1 in (select d1 +from x2 +where x1.d2=x2.d2) is unknown; +k d1 d2 +30 NULL 30 +select * +from x1 +where 1 in (select 1 +from x2 +where x1.d1=x2.d1 and x1.d2=x2.d2); +k d1 d2 +10 10 10 +20 20 20 +select * +from x1 +where 1 in (select 1 +from x2 +where x1.d1=x2.d1 and x1.d2=x2.d2) is true; +k d1 d2 +10 10 10 +20 20 20 +select * +from x1 +where 1 in (select 1 +from x2 +where x1.d1=x2.d1 and x1.d2=x2.d2) is false; +k d1 d2 +21 20 NULL +30 NULL 30 +40 40 40 +select * +from x1 +where 1 in (select 1 +from x2 +where x1.d1=x2.d1 and x1.d2=x2.d2) is unknown; +k d1 d2 +select * +from x1 +where exists (select * +from x2 +where x1.d1=x2.d1 and x1.d2=x2.d2); +k d1 d2 +10 10 10 +20 20 20 +drop table x1; +drop table x2; +CREATE TABLE t1 ( +a int(11) NOT NULL, +b int(11) NOT NULL, +c datetime default NULL, +PRIMARY KEY (a), +KEY idx_bc (b,c) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES +(406989,67,'2006-02-23 17:08:46'), (150078,67,'2005-10-26 11:17:45'), +(406993,67,'2006-02-27 11:20:57'), (245655,67,'2005-12-08 15:59:08'), +(406994,67,'2006-02-27 11:26:46'), (256,67,NULL), +(398341,67,'2006-02-20 04:48:44'), (254,67,NULL),(1120,67,NULL), +(406988,67,'2006-02-23 17:07:22'), (255,67,NULL), +(398340,67,'2006-02-20 04:38:53'),(406631,67,'2006-02-23 10:49:42'), +(245653,67,'2005-12-08 15:59:07'),(406992,67,'2006-02-24 16:47:18'), +(245654,67,'2005-12-08 15:59:08'),(406995,67,'2006-02-28 11:55:00'), +(127261,67,'2005-10-13 12:17:58'),(406991,67,'2006-02-24 16:42:32'), +(245652,67,'2005-12-08 15:58:27'),(398545,67,'2006-02-20 04:53:13'), +(154504,67,'2005-10-28 11:53:01'),(9199,67,NULL),(1,67,'2006-02-23 15:01:35'), +(223456,67,NULL),(4101,67,NULL),(1133,67,NULL), +(406990,67,'2006-02-23 18:01:45'),(148815,67,'2005-10-25 15:34:17'), +(148812,67,'2005-10-25 15:30:01'),(245651,67,'2005-12-08 15:58:27'), +(154503,67,'2005-10-28 11:52:38'); +create table t11 select * from t1 where b = 67 AND (c IS NULL OR c > NOW()) order by 3 asc; +create table t12 select * from t1 where b = 67 AND (c IS NULL OR c > NOW()) order by 3 desc; +create table t21 select * from t1 where b = 67 AND (c IS NULL OR c > '2005-12-08') order by 3 asc; +create table t22 select * from t1 where b = 67 AND (c IS NULL OR c > '2005-12-08') order by 3 desc; +update t22 set c = '2005-12-08 15:58:27' where a = 255; +explain select t21.* from t21,t22 where t21.a = t22.a and +t22.a in (select t12.a from t11, t12 where t11.a in(255,256) and t11.a = t12.a and t11.c is null) and t22.c is null order by t21.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using temporary; Using filesort +1 SIMPLE t22 NULL ALL NULL NULL NULL NULL 26 3.85 Using where; Using join buffer (hash join) +1 SIMPLE t21 NULL ALL NULL NULL NULL NULL 26 10.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t11 NULL ALL NULL NULL NULL NULL 8 12.50 Using where +2 MATERIALIZED t12 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t21`.`a` AS `a`,`test`.`t21`.`b` AS `b`,`test`.`t21`.`c` AS `c` from `test`.`t21` join `test`.`t22` semi join (`test`.`t11` join `test`.`t12`) where ((`test`.`t22`.`a` = ``.`a`) and (`test`.`t21`.`a` = ``.`a`) and (`test`.`t12`.`a` = `test`.`t11`.`a`) and (`test`.`t22`.`c` is null) and (`test`.`t11`.`a` in (255,256)) and (`test`.`t11`.`c` is null)) order by `test`.`t21`.`a` +explain format=json select * from t1 where a in (select a from t11); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "6.71" + }, + "nested_loop": [ + { + "table": { + "table_name": "", + "access_type": "ALL", + "materialized_from_subquery": { + "using_temporary_table": true, + "query_block": { + "table": { + "table_name": "t11", + "access_type": "ALL", + "rows_examined_per_scan": 8, + "rows_produced_per_join": 8, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "0.80", + "prefix_cost": "1.31", + "data_read_per_join": "128" + }, + "used_columns": [ + "a" + ] + } + } + } + } + }, + { + "table": { + "table_name": "t1", + "access_type": "eq_ref", + "possible_keys": [ + "PRIMARY" + ], + "key": "PRIMARY", + "used_key_parts": [ + "a" + ], + "key_length": "4", + "ref": [ + ".a" + ], + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.10", + "prefix_cost": "6.71", + "data_read_per_join": "16" + }, + "used_columns": [ + "a", + "b", + "c" + ] + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` semi join (`test`.`t11`) where (`test`.`t1`.`a` = ``.`a`) +select t21.* from t21,t22 where t21.a = t22.a and +t22.a in (select t12.a from t11, t12 where t11.a in(255,256) and t11.a = t12.a and t11.c is null) and t22.c is null order by t21.a; +a b c +256 67 NULL +drop table t1, t11, t12, t21, t22; +create table t1(a int); +insert into t1 values (0),(1); +explain +select (select max(y.a) from t1 y where a in (select a from t1 z) and a < x.a) as subq from t1 x; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY x NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DEPENDENT SUBQUERY y NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 DEPENDENT SUBQUERY NULL eq_ref 5 test.y.a 1 100.00 NULL +3 MATERIALIZED z NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1276 Field or reference 'test.x.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select (/* select#2 */ select max(`test`.`y`.`a`) from `test`.`t1` `y` semi join (`test`.`t1` `z`) where ((``.`a` = `test`.`y`.`a`) and (`test`.`y`.`a` < `test`.`x`.`a`))) AS `subq` from `test`.`t1` `x` +select (select max(y.a) from t1 y where a in (select a from t1 z) and a < x.a) as subq from t1 x; +subq +NULL +0 +drop table t1; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 as select * from t0; +insert into t1 select a+10 from t0; +insert into t0 values(2); +explain select * from t1 where 2 in (select a from t0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL const 5 const 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 20 100.00 Using join buffer (hash join) +2 MATERIALIZED t0 NULL ALL NULL NULL NULL NULL 11 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t0`) where ((``.`a` = 2) and (`test`.`t0`.`a` = 2)) +select * from t1 where 2 in (select a from t0); +a +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +explain select * from (select a from t0) x where a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 11 100.00 NULL +1 SIMPLE NULL eq_ref 5 func 1 100.00 Using where +3 MATERIALIZED t1 NULL ALL NULL NULL NULL NULL 20 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a` from `test`.`t0` semi join (`test`.`t1`) where (``.`a` = `test`.`t0`.`a`) +explain format=json select * from (select a from t0) x where a in (select a from t1); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "8.21" + }, + "nested_loop": [ + { + "table": { + "table_name": "t0", + "access_type": "ALL", + "rows_examined_per_scan": 11, + "rows_produced_per_join": 11, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "1.10", + "prefix_cost": "1.60", + "data_read_per_join": "88" + }, + "used_columns": [ + "a" + ] + } + }, + { + "table": { + "table_name": "", + "access_type": "eq_ref", + "key": "", + "key_length": "5", + "ref": [ + "func" + ], + "rows_examined_per_scan": 1, + "attached_condition": "(``.`a` = `test`.`t0`.`a`)", + "materialized_from_subquery": { + "using_temporary_table": true, + "query_block": { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 20, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "2.00", + "prefix_cost": "2.51", + "data_read_per_join": "160" + }, + "used_columns": [ + "a" + ] + } + } + } + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a` from `test`.`t0` semi join (`test`.`t1`) where (``.`a` = `test`.`t0`.`a`) +drop table t0, t1; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (kp1 int, kp2 int, c int, filler char(100), key(kp1, kp2)); +insert into t1 select A.a+10*(B.a+10*C.a), 0, 0, 'filler' from t0 A, t0 B, t0 C; +insert into t1 select * from t1 where kp1 < 20; +create table t3 (a int); +insert into t3 select A.a + 10*B.a from t0 A, t0 B; +explain select * from t3 where a in (select kp1 from t1 where kp1<20); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 100 100.00 Using where +1 SIMPLE NULL eq_ref 5 test.t3.a 1 100.00 NULL +2 MATERIALIZED t1 NULL range kp1 kp1 5 NULL 48 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a` from `test`.`t3` semi join (`test`.`t1`) where ((``.`kp1` = `test`.`t3`.`a`) and (`test`.`t1`.`kp1` < 20)) +select * from t3 where a in (select kp1 from t1 where kp1<20); +a +0 +1 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +2 +3 +4 +5 +6 +7 +8 +9 +explain select * from t3 where a in (select kp1 from t1 where kp1<20) and a<20; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 100 33.33 Using where +1 SIMPLE NULL eq_ref 5 test.t3.a 1 100.00 NULL +2 MATERIALIZED t1 NULL range kp1 kp1 5 NULL 48 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a` from `test`.`t3` semi join (`test`.`t1`) where ((``.`kp1` = `test`.`t3`.`a`) and (`test`.`t3`.`a` < 20) and (`test`.`t1`.`kp1` < 20)) +select * from t3 where a in (select kp1 from t1 where kp1<20) and a<20; +a +0 +1 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +2 +3 +4 +5 +6 +7 +8 +9 +create table t4 (pk int primary key); +insert into t4 select a from t3; +explain select * from t3 where a in +(select t1.kp1 from t1,t4 where kp1<20 and t4.pk=t1.c); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 100 100.00 Using where +1 SIMPLE NULL eq_ref 5 test.t3.a 1 100.00 NULL +2 MATERIALIZED t1 NULL range kp1 kp1 5 NULL 48 100.00 Using where +2 MATERIALIZED t4 NULL eq_ref PRIMARY PRIMARY 4 test.t1.c 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a` from `test`.`t3` semi join (`test`.`t1` join `test`.`t4`) where ((``.`kp1` = `test`.`t3`.`a`) and (`test`.`t4`.`pk` = `test`.`t1`.`c`) and (`test`.`t1`.`kp1` < 20)) +explain format=tree select * from t3 where a in +(select t1.kp1 from t1,t4 where kp1<20 and t4.pk=t1.c); +EXPLAIN +-> Nested loop inner join (cost=500.54 rows=4800) + -> Filter: (t3.a is not null) (cost=10.54 rows=100) + -> Table scan on t3 (cost=10.54 rows=100) + -> Single-row index lookup on using (kp1=t3.a) + -> Materialize with deduplication (cost=43.46..43.46 rows=48) + -> Filter: (t1.kp1 is not null) (cost=38.66 rows=48) + -> Nested loop inner join (cost=38.66 rows=48) + -> Filter: ((t1.kp1 < 20) and (t1.c is not null)) (cost=21.86 rows=48) + -> Index range scan on t1 using kp1 (cost=21.86 rows=48) + -> Single-row index lookup on t4 using PRIMARY (pk=t1.c) (cost=0.25 rows=1) + +select * from t3 where a in +(select t1.kp1 from t1,t4 where kp1<20 and t4.pk=t1.c); +a +0 +1 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +2 +3 +4 +5 +6 +7 +8 +9 +drop table t1, t3, t4; +create table t1 (a int); +insert into t1 values (0),(0),(0),(1),(1),(1),(2),(2),(2),(3),(3),(3); +set session internal_tmp_mem_storage_engine='memory'; +set @save_max_heap_table_size=@@max_heap_table_size; +set @@max_heap_table_size= 16384; +# Attempt to make one test that overflows the heap table when a +# non-duplicate row is inserted and one test that overflows the +# heap table when a duplicate record is inserted. Debugging showed +# that these situations occurred with max_heap_table_size=16384 +# and optimizer_join_cache_level equals 1 and 0, respectively. +# Finally execute a test that does not overflow the heap table. +explain +select count(*) from t0 a, t0 b, t0 c +where c.a in (select a from t1 d); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE a NULL ALL NULL NULL NULL NULL 10 100.00 NULL +1 SIMPLE b NULL ALL NULL NULL NULL NULL 10 100.00 Using join buffer (hash join) +1 SIMPLE c NULL ALL NULL NULL NULL NULL 10 100.00 Using where; Using join buffer (hash join) +1 SIMPLE NULL eq_ref 5 test.c.a 1 100.00 NULL +2 MATERIALIZED d NULL ALL NULL NULL NULL NULL 12 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select count(0) AS `count(*)` from `test`.`t0` `a` join `test`.`t0` `b` join `test`.`t0` `c` semi join (`test`.`t1` `d`) where (``.`a` = `test`.`c`.`a`) +flush status; +select count(*) from t0 a, t0 b, t0 c +where c.a in (select a from t1 d); +count(*) +400 +show status like 'Created_tmp_disk_tables'; +Variable_name Value +Created_tmp_disk_tables 0 +set @@max_heap_table_size= @save_max_heap_table_size; +set session internal_tmp_mem_storage_engine=default; +flush status; +select count(*) from t0 a, t0 b, t0 c +where c.a in (select a from t1 d); +count(*) +400 +show status like 'Created_tmp_disk_tables'; +Variable_name Value +Created_tmp_disk_tables 0 +drop table t0, t1; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t2(a int); +insert into t2 values (1),(2); +create table t3 ( a int , filler char(100), key(a)); +insert into t3 select A.a + 10*B.a, 'filler' from t0 A, t0 B; +explain select * from t3 where a in (select a from t2) and (a > 5 or a < 10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using where +1 SIMPLE t3 NULL ref a a 5 .a 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a`,`test`.`t3`.`filler` AS `filler` from `test`.`t3` semi join (`test`.`t2`) where ((`test`.`t3`.`a` = ``.`a`) and ((``.`a` > 5) or (``.`a` < 10))) +select * from t3 where a in (select a from t2); +a filler +1 filler +2 filler +drop table t0, t2, t3; +create table t1 (a date); +insert into t1 values ('2008-01-01'),('2008-01-01'),('2008-02-01'),('2008-02-01'); +create table t2 (a int); +insert into t2 values (1),(2); +create table t3 (a char(10)); +insert into t3 select * from t1; +insert into t3 values (1),(2); +explain select * from t2 where a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1`) where (cast(`test`.`t2`.`a` as double) = cast(`test`.`t1`.`a` as double)) +explain select * from t2 where a in (select a from t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE NULL eq_ref 5 test.t2.a 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t2`) where (``.`a` = `test`.`t2`.`a`) +explain select * from t2 where a in (select a from t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t3`) where (cast(`test`.`t2`.`a` as double) = cast(`test`.`t3`.`a` as double)) +explain select * from t1 where a in (select a from t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t3`) where (`test`.`t1`.`a` = cast(`test`.`t3`.`a` as date)) +drop table t1, t2, t3; +create table t1 (a decimal); +insert into t1 values (1),(2); +explain select * from t1 where a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE NULL eq_ref 6 test.t1.a 1 100.00 NULL +2 MATERIALIZED t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t1`) where (``.`a` = `test`.`t1`.`a`) +drop table t1; +create table t1 (a int); +insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t2 as select * from t1; +create table t3 (a int, b int, filler char(100), key(a)) charset utf8mb4; +insert into t3 select A.a + 10*B.a, A.a + 10*B.a, 'filler' from t1 A, t1 B, t1 C; +explain select * from t1, t3 where t3.a in (select a from t2) and (t3.a < 10 or t3.a >30) and t1.a =3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 10.00 Using where +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ref a a 5 .a 10 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 10 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t3`.`filler` AS `filler` from `test`.`t1` join `test`.`t3` semi join (`test`.`t2`) where ((`test`.`t3`.`a` = ``.`a`) and (`test`.`t1`.`a` = 3) and ((``.`a` < 10) or (``.`a` > 30))) +explain format=json select * from t1, t3 where t3.a in (select a from t2) and (t3.a < 10 or t3.a >30) and t1.a =3; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "41.01" + }, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 10, + "rows_produced_per_join": 1, + "filtered": "10.00", + "cost_info": { + "read_cost": "1.40", + "eval_cost": "0.10", + "prefix_cost": "1.50", + "data_read_per_join": "8" + }, + "used_columns": [ + "a" + ], + "attached_condition": "(`test`.`t1`.`a` = 3)" + } + }, + { + "table": { + "table_name": "", + "access_type": "ALL", + "using_join_buffer": "hash join", + "attached_condition": "(((``.`a` < 10) or (``.`a` > 30)) and (``.`a` is not null))", + "materialized_from_subquery": { + "using_temporary_table": true, + "query_block": { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 10, + "rows_produced_per_join": 10, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "1.00", + "prefix_cost": "1.50", + "data_read_per_join": "80" + }, + "used_columns": [ + "a" + ] + } + } + } + } + }, + { + "table": { + "table_name": "t3", + "access_type": "ref", + "possible_keys": [ + "a" + ], + "key": "a", + "used_key_parts": [ + "a" + ], + "key_length": "5", + "ref": [ + ".a" + ], + "rows_examined_per_scan": 10, + "rows_produced_per_join": 10, + "filtered": "100.00", + "cost_info": { + "read_cost": "25.00", + "eval_cost": "1.00", + "prefix_cost": "41.01", + "data_read_per_join": "4K" + }, + "used_columns": [ + "a", + "b", + "filler" + ] + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t3`.`filler` AS `filler` from `test`.`t1` join `test`.`t3` semi join (`test`.`t2`) where ((`test`.`t3`.`a` = ``.`a`) and (`test`.`t1`.`a` = 3) and ((``.`a` < 10) or (``.`a` > 30))) +explain select straight_join * from t1 a, t1 b where a.a in (select a from t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY a NULL ALL NULL NULL NULL NULL 10 100.00 Using where +1 PRIMARY b NULL ALL NULL NULL NULL NULL 10 100.00 Using join buffer (hash join) +2 SUBQUERY t2 NULL ALL NULL NULL NULL NULL 10 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select straight_join `test`.`a`.`a` AS `a`,`test`.`b`.`a` AS `a` from `test`.`t1` `a` join `test`.`t1` `b` where (`test`.`a`.`a`,`test`.`a`.`a` in ( (/* select#2 */ select `test`.`t2`.`a` from `test`.`t2` where true ), (`test`.`a`.`a` in on where ((`test`.`a`.`a` = ``.`a`))))) +explain select * from t2 where a in (select straight_join a.a from t1 a, t1 b); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 10 100.00 Using where +2 SUBQUERY a NULL ALL NULL NULL NULL NULL 10 100.00 NULL +2 SUBQUERY b NULL ALL NULL NULL NULL NULL 10 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` where (`test`.`t2`.`a`,`test`.`t2`.`a` in ( (/* select#2 */ select straight_join `test`.`a`.`a` from `test`.`t1` `a` join `test`.`t1` `b` where true ), (`test`.`t2`.`a` in on where ((`test`.`t2`.`a` = ``.`a`))))) +explain select * from t2 where a in (select straight_join a.a from t1 a, t1 b); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 10 100.00 Using where +2 SUBQUERY a NULL ALL NULL NULL NULL NULL 10 100.00 NULL +2 SUBQUERY b NULL ALL NULL NULL NULL NULL 10 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` where (`test`.`t2`.`a`,`test`.`t2`.`a` in ( (/* select#2 */ select straight_join `test`.`a`.`a` from `test`.`t1` `a` join `test`.`t1` `b` where true ), (`test`.`t2`.`a` in on where ((`test`.`t2`.`a` = ``.`a`))))) +explain select straight_join * from t2 x, t2 y +where x.a in (select straight_join a.a from t1 a, t1 b); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY x NULL ALL NULL NULL NULL NULL 10 100.00 Using where +1 PRIMARY y NULL ALL NULL NULL NULL NULL 10 100.00 Using join buffer (hash join) +2 SUBQUERY a NULL ALL NULL NULL NULL NULL 10 100.00 NULL +2 SUBQUERY b NULL ALL NULL NULL NULL NULL 10 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select straight_join `test`.`x`.`a` AS `a`,`test`.`y`.`a` AS `a` from `test`.`t2` `x` join `test`.`t2` `y` where (`test`.`x`.`a`,`test`.`x`.`a` in ( (/* select#2 */ select straight_join `test`.`a`.`a` from `test`.`t1` `a` join `test`.`t1` `b` where true ), (`test`.`x`.`a` in on where ((`test`.`x`.`a` = ``.`a`))))) +create table t0 (a int, b int); +insert into t0 values(1,1); +explain select * from t0, t3 where t3.a in (select a from t2) and (t3.a < 10 or t3.a >30); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using where +1 SIMPLE t3 NULL ref a a 5 .a 10 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 10 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select '1' AS `a`,'1' AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t3`.`filler` AS `filler` from `test`.`t3` semi join (`test`.`t2`) where ((`test`.`t3`.`a` = ``.`a`) and ((``.`a` < 10) or (``.`a` > 30))) +create table t4 as select a as x, a as y from t1; +explain select * from t0, t3 where (t3.a, t3.b) in (select x,y from t4) and (t3.a < 10 or t3.a >30); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using where +1 SIMPLE t3 NULL ref a a 5 .x 10 10.00 Using where +2 MATERIALIZED t4 NULL ALL NULL NULL NULL NULL 10 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select '1' AS `a`,'1' AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t3`.`filler` AS `filler` from `test`.`t3` semi join (`test`.`t4`) where ((`test`.`t3`.`b` = ``.`y`) and (`test`.`t3`.`a` = ``.`x`) and ((``.`x` < 10) or (``.`x` > 30))) +drop table t0,t1,t2,t3,t4; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (a int, b int, filler char(100), key(a,b)); +insert into t1 select A.a, B.a, 'filler' from t0 A, t0 B; +create table t2 as select * from t1; +explain select * from t2 where a in (select b from t1 where a=3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 100 100.00 Using where +1 SIMPLE NULL eq_ref 5 test.t2.a 1 100.00 NULL +2 MATERIALIZED t1 NULL ref a a 5 const 8 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`filler` AS `filler` from `test`.`t2` semi join (`test`.`t1`) where ((``.`b` = `test`.`t2`.`a`) and (`test`.`t1`.`a` = 3)) +explain select * from t2 where (b,a) in (select a,b from t1 where a=3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 100 10.00 Using where +1 SIMPLE NULL eq_ref 10 test.t2.b,test.t2.a 1 100.00 Using where +2 MATERIALIZED t1 NULL ref a a 5 const 8 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`filler` AS `filler` from `test`.`t2` semi join (`test`.`t1`) where ((``.`b` = `test`.`t2`.`a`) and (`test`.`t2`.`b` = 3) and (``.`a` = 3) and (`test`.`t1`.`a` = 3)) +drop table t1,t2; +create table t1 (a int, b int); +insert into t1 select a,a from t0; +create table t2 (a int, b int); +insert into t2 select A.a + 10*B.a, A.a + 10*B.a from t0 A, t0 B; +explain select * from t1 where (a,b) in (select a,b from t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 100.00 Using where +1 SIMPLE NULL eq_ref 10 test.t1.a,test.t1.b 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 100 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t2`) where ((``.`b` = `test`.`t1`.`b`) and (``.`a` = `test`.`t1`.`a`)) +drop table t0, t1, t2; +# +# Bug#19695490: CRASH IN CREATE_REF_FOR_KEY ON SELECT + JOIN + UTF8 COLUMN +# + DATETIME INDEX. +# +CREATE TABLE t1 ( +field1 varchar(255) CHARACTER SET utf8, +field2 varchar(255) CHARACTER SET utf8 +); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES +('time','time'), +('lpjdzvkp','lpjdzvkp'), +('dzvkpai', 'dzvkpai'); +CREATE TABLE t2 ( col_varchar varchar(10)); +CREATE TABLE t3 ( +pk int(11) NOT NULL, +col_varchar_255_utf8_key varchar(255) CHARACTER SET utf8, +col_varchar_10_utf8_key varchar(10) CHARACTER SET utf8, +PRIMARY KEY (pk) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t3 VALUES (22,'come','h'), +(23,'time','aaa'), +(24,'lpjdzvkp','ababa'), +(25,'d','GGDD'); +SELECT * FROM t1 WHERE (field1, field2) IN ( +SELECT table1.col_varchar_255_utf8_key AS field1, +table1.col_varchar_255_utf8_key AS field2 +FROM t3 AS table1 LEFT JOIN t2 AS table2 +ON table1.col_varchar_10_utf8_key <= +table2.col_varchar +WHERE table1.pk >= 6); +field1 field2 +time time +lpjdzvkp lpjdzvkp +DROP TABLE t1,t2,t3; +create table t0 (a decimal(4,2)); +insert into t0 values (10.24), (22.11); +create table t1 as select * from t0; +insert into t1 select * from t0; +explain select * from t0 where a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE NULL eq_ref 3 test.t0.a 1 100.00 NULL +2 MATERIALIZED t1 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a` from `test`.`t0` semi join (`test`.`t1`) where (``.`a` = `test`.`t0`.`a`) +select * from t0 where a in (select a from t1); +a +10.24 +22.11 +drop table t0, t1; +create table t0(a date); +insert into t0 values ('2008-01-01'),('2008-02-02'); +create table t1 as select * from t0; +insert into t1 select * from t0; +explain select * from t0 where a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE NULL eq_ref 4 test.t0.a 1 100.00 NULL +2 MATERIALIZED t1 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a` from `test`.`t0` semi join (`test`.`t1`) where (``.`a` = `test`.`t0`.`a`) +select * from t0 where a in (select a from t1); +a +2008-01-01 +2008-02-02 +drop table t0, t1; +create table t0(a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 as select a as a, a as b, a as c from t0 where a < 3; +create table t2 as select a as a, a as b from t0 where a < 3; +insert into t2 select * from t2; +explain select * from t1 where (a,b,c) in (select x.a, y.a, z.a from t2 x, t2 y, t2 z where x.b=33); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE NULL eq_ref 15 test.t1.a,test.t1.b,test.t1.c 1 100.00 NULL +2 MATERIALIZED x NULL ALL NULL NULL NULL NULL 6 16.67 Using where +2 MATERIALIZED y NULL ALL NULL NULL NULL NULL 6 100.00 Using join buffer (hash join) +2 MATERIALIZED z NULL ALL NULL NULL NULL NULL 6 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` semi join (`test`.`t2` `x` join `test`.`t2` `y` join `test`.`t2` `z`) where ((``.`a` = `test`.`t1`.`c`) and (``.`a` = `test`.`t1`.`b`) and (``.`a` = `test`.`t1`.`a`) and (`test`.`x`.`b` = 33)) +drop table t0,t1,t2; +set @save_join_buffer_size = @@join_buffer_size; +set join_buffer_size= 8192; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (a int, filler1 binary(200), filler2 binary(200)); +insert into t1 select a, 'filler123456', 'filler123456' from t0; +insert into t1 select a+10, 'filler123456', 'filler123456' from t0; +create table t2 as select * from t1; +insert into t1 select a+20, 'filler123456', 'filler123456' from t0; +insert into t1 values (2, 'duplicate ok', 'duplicate ok'); +insert into t1 values (18, 'duplicate ok', 'duplicate ok'); +insert into t2 values (3, 'duplicate ok', 'duplicate ok'); +insert into t2 values (19, 'duplicate ok', 'duplicate ok'); +explain select +a, mid(filler1, 1,10), length(filler1)=length(filler2) as z +from t1 ot where a in (select a from t2 it); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 32 10.00 Using where; Using join buffer (hash join) +2 MATERIALIZED it NULL ALL NULL NULL NULL NULL 22 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot`.`a` AS `a`,substr(`test`.`ot`.`filler1`,1,10) AS `mid(filler1, 1,10)`,(length(`test`.`ot`.`filler1`) = length(`test`.`ot`.`filler2`)) AS `z` from `test`.`t1` `ot` semi join (`test`.`t2` `it`) where (`test`.`ot`.`a` = ``.`a`) +select +a, mid(filler1, 1,10), length(filler1)=length(filler2) as z +from t1 ot where a in (select a from t2 it); +a mid(filler1, 1,10) z +0 filler1234 1 +1 filler1234 1 +10 filler1234 1 +11 filler1234 1 +12 filler1234 1 +13 filler1234 1 +14 filler1234 1 +15 filler1234 1 +16 filler1234 1 +17 filler1234 1 +18 duplicate 1 +18 filler1234 1 +19 filler1234 1 +2 duplicate 1 +2 filler1234 1 +3 filler1234 1 +4 filler1234 1 +5 filler1234 1 +6 filler1234 1 +7 filler1234 1 +8 filler1234 1 +9 filler1234 1 +explain select +a, mid(filler1, 1,10), length(filler1)=length(filler2) +from t2 ot where a in (select a from t1 it); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 22 100.00 Using where +1 SIMPLE NULL eq_ref 5 test.ot.a 1 100.00 NULL +2 MATERIALIZED it NULL ALL NULL NULL NULL NULL 32 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot`.`a` AS `a`,substr(`test`.`ot`.`filler1`,1,10) AS `mid(filler1, 1,10)`,(length(`test`.`ot`.`filler1`) = length(`test`.`ot`.`filler2`)) AS `length(filler1)=length(filler2)` from `test`.`t2` `ot` semi join (`test`.`t1` `it`) where (``.`a` = `test`.`ot`.`a`) +select +a, mid(filler1, 1,10), length(filler1)=length(filler2) +from t2 ot where a in (select a from t1 it); +a mid(filler1, 1,10) length(filler1)=length(filler2) +0 filler1234 1 +1 filler1234 1 +10 filler1234 1 +11 filler1234 1 +12 filler1234 1 +13 filler1234 1 +14 filler1234 1 +15 filler1234 1 +16 filler1234 1 +17 filler1234 1 +18 filler1234 1 +19 duplicate 1 +19 filler1234 1 +2 filler1234 1 +3 duplicate 1 +3 filler1234 1 +4 filler1234 1 +5 filler1234 1 +6 filler1234 1 +7 filler1234 1 +8 filler1234 1 +9 filler1234 1 +insert into t1 select a+20, 'filler123456', 'filler123456' from t0; +insert into t1 select a+20, 'filler123456', 'filler123456' from t0; +explain select +a, mid(filler1, 1,10), length(filler1)=length(filler2) as z +from t1 ot where a in (select a from t2 it); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 52 10.00 Using where; Using join buffer (hash join) +2 MATERIALIZED it NULL ALL NULL NULL NULL NULL 22 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot`.`a` AS `a`,substr(`test`.`ot`.`filler1`,1,10) AS `mid(filler1, 1,10)`,(length(`test`.`ot`.`filler1`) = length(`test`.`ot`.`filler2`)) AS `z` from `test`.`t1` `ot` semi join (`test`.`t2` `it`) where (`test`.`ot`.`a` = ``.`a`) +select +a, mid(filler1, 1,10), length(filler1)=length(filler2) as z +from t1 ot where a in (select a from t2 it); +a mid(filler1, 1,10) z +0 filler1234 1 +1 filler1234 1 +10 filler1234 1 +11 filler1234 1 +12 filler1234 1 +13 filler1234 1 +14 filler1234 1 +15 filler1234 1 +16 filler1234 1 +17 filler1234 1 +18 duplicate 1 +18 filler1234 1 +19 filler1234 1 +2 duplicate 1 +2 filler1234 1 +3 filler1234 1 +4 filler1234 1 +5 filler1234 1 +6 filler1234 1 +7 filler1234 1 +8 filler1234 1 +9 filler1234 1 +explain select +a, mid(filler1, 1,10), length(filler1)=length(filler2) +from t2 ot where a in (select a from t1 it); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 22 100.00 Using where +1 SIMPLE NULL eq_ref 5 test.ot.a 1 100.00 NULL +2 MATERIALIZED it NULL ALL NULL NULL NULL NULL 52 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot`.`a` AS `a`,substr(`test`.`ot`.`filler1`,1,10) AS `mid(filler1, 1,10)`,(length(`test`.`ot`.`filler1`) = length(`test`.`ot`.`filler2`)) AS `length(filler1)=length(filler2)` from `test`.`t2` `ot` semi join (`test`.`t1` `it`) where (``.`a` = `test`.`ot`.`a`) +select +a, mid(filler1, 1,10), length(filler1)=length(filler2) +from t2 ot where a in (select a from t1 it); +a mid(filler1, 1,10) length(filler1)=length(filler2) +0 filler1234 1 +1 filler1234 1 +10 filler1234 1 +11 filler1234 1 +12 filler1234 1 +13 filler1234 1 +14 filler1234 1 +15 filler1234 1 +16 filler1234 1 +17 filler1234 1 +18 filler1234 1 +19 duplicate 1 +19 filler1234 1 +2 filler1234 1 +3 duplicate 1 +3 filler1234 1 +4 filler1234 1 +5 filler1234 1 +6 filler1234 1 +7 filler1234 1 +8 filler1234 1 +9 filler1234 1 +set @@join_buffer_size = @save_join_buffer_size; +drop table t1, t2; +create table t1 (a int, b int, key(a)); +create table t2 (a int, b int, key(a)); +create table t3 (a int, b int, key(a)); +insert into t1 select a,a from t0; +insert into t2 select a,a from t0; +insert into t3 select a,a from t0; +t2 and t3 must be use 'ref', not 'ALL': +explain select * +from t0 where a in +(select t2.a+t3.a from t1 left join (t2 join t3) on t2.a=t1.a and t3.a=t1.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 10 100.00 Using where +1 SIMPLE NULL eq_ref 9 test.t0.a 1 100.00 Using where +2 MATERIALIZED t1 NULL index a a 5 NULL 10 100.00 Using index +2 MATERIALIZED t2 NULL ref a a 5 test.t1.a 1 100.00 Using index +2 MATERIALIZED t3 NULL ref a a 5 test.t1.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a` from `test`.`t0` semi join (`test`.`t1` join `test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`a` = `test`.`t1`.`a`) and (`test`.`t3`.`a` = `test`.`t1`.`a`) and (`test`.`t0`.`a` = ``.`t2.a+t3.a`)) +drop table t0, t1,t2,t3; + +Test that neither MaterializeLookup strategy for semijoin, +nor subquery materialization is used when BLOBs are involved +(except when arguments of some functions). + +set @prefix_len = 6; +set @blob_len = 16; +set @suffix_len = @blob_len - @prefix_len; +create table t1_16 (a1 blob(16), a2 blob(16)); +create table t2_16 (b1 blob(16), b2 blob(16)); +create table t3_16 (c1 blob(16), c2 blob(16)); +insert into t1_16 values +(concat('1 - 00', repeat('x', @suffix_len)), concat('2 - 00', repeat('x', @suffix_len))); +insert into t1_16 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t1_16 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_16 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t2_16 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_16 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_16 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t3_16 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t3_16 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_16 values +(concat('1 - 04', repeat('x', @suffix_len)), concat('2 - 04', repeat('x', @suffix_len))); +explain select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select b1 from t2_16 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1_16 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +2 MATERIALIZED t2_16 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_16`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_16`.`a2`,7) AS `left(a2,7)` from `test`.`t1_16` semi join (`test`.`t2_16`) where ((`test`.`t1_16`.`a1` = ``.`b1`) and (`test`.`t2_16`.`b1` > '0')) +select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select b1 from t2_16 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_16 +where (a1,a2) in (select b1, b2 from t2_16 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1_16 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +2 MATERIALIZED t2_16 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_16`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_16`.`a2`,7) AS `left(a2,7)` from `test`.`t1_16` semi join (`test`.`t2_16`) where ((`test`.`t1_16`.`a2` = ``.`b2`) and (`test`.`t1_16`.`a1` = ``.`b1`) and (`test`.`t2_16`.`b1` > '0')) +select left(a1,7), left(a2,7) +from t1_16 +where (a1,a2) in (select b1, b2 from t2_16 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select substring(b1,1,16) from t2_16 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1_16 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +2 MATERIALIZED t2_16 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_16`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_16`.`a2`,7) AS `left(a2,7)` from `test`.`t1_16` semi join (`test`.`t2_16`) where ((`test`.`t2_16`.`b1` > '0') and (`test`.`t1_16`.`a1` = ``.`substring(b1,1,16)`)) +select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select substring(b1,1,16) from t2_16 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select group_concat(b1) from t2_16 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_16 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t2_16 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_16`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_16`.`a2`,7) AS `left(a2,7)` from `test`.`t1_16` where (`test`.`t1_16`.`a1`,(/* select#2 */ select group_concat(`test`.`t2_16`.`b1` separator ',') from `test`.`t2_16` group by `test`.`t2_16`.`b2` having ((`test`.`t1_16`.`a1`) = (group_concat(`test`.`t2_16`.`b1` separator ','))))) +select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select group_concat(b1) from t2_16 group by b2); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +set @@group_concat_max_len = 256; +explain select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select group_concat(b1) from t2_16 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_16 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 SUBQUERY t2_16 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_16`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_16`.`a2`,7) AS `left(a2,7)` from `test`.`t1_16` where (`test`.`t1_16`.`a1`,`test`.`t1_16`.`a1` in ( (/* select#2 */ select group_concat(`test`.`t2_16`.`b1` separator ',') from `test`.`t2_16` group by `test`.`t2_16`.`b2` having true ), (`test`.`t1_16`.`a1` in on where ((`test`.`t1_16`.`a1` = ``.`group_concat(b1)`))))) +select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select group_concat(b1) from t2_16 group by b2); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +create table t1 (a1 char(8), a2 char(8)) charset latin1; +create table t2 (b1 char(8), b2 char(8)) charset latin1; +create table t3 (c1 char(8), c2 char(8)) charset latin1; +insert into t1 values ('1 - 00', '2 - 00'); +insert into t1 values ('1 - 01', '2 - 01'); +insert into t1 values ('1 - 02', '2 - 02'); +insert into t2 values ('1 - 01', '2 - 01'); +insert into t2 values ('1 - 01', '2 - 01'); +insert into t2 values ('1 - 02', '2 - 02'); +insert into t2 values ('1 - 02', '2 - 02'); +insert into t2 values ('1 - 03', '2 - 03'); +insert into t3 values ('1 - 01', '2 - 01'); +insert into t3 values ('1 - 02', '2 - 02'); +insert into t3 values ('1 - 03', '2 - 03'); +insert into t3 values ('1 - 04', '2 - 04'); +insert into t3 values ('1 - 05', '2 - 05'); +insert into t3 values ('1 - 06', '2 - 06'); +insert into t3 values ('1 - 07', '2 - 07'); +insert into t3 values ('1 - 08', '2 - 08'); +explain +select * from t1 +where concat(a1,'x') IN +(select left(a1,8) from t1_16 +where (a1, a2) IN +(select t2_16.b1, t2_16.b2 from t2_16, t2 +where t2.b2 = substring(t2_16.b2,1,6) and +t2.b1 IN (select c1 from t3 where c2 > '0'))); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1_16 NULL ALL NULL NULL NULL NULL 3 100.00 Start temporary +1 SIMPLE t2_16 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 5 20.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` semi join (`test`.`t1_16` join `test`.`t2_16` join `test`.`t2` join `test`.`t3`) where ((`test`.`t2_16`.`b2` = `test`.`t1_16`.`a2`) and (`test`.`t2_16`.`b1` = `test`.`t1_16`.`a1`) and (`test`.`t3`.`c1` = `test`.`t2`.`b1`) and (`test`.`t2`.`b2` = substr(`test`.`t2_16`.`b2`,1,6)) and (`test`.`t3`.`c2` > '0') and (concat(`test`.`t1`.`a1`,'x') = left(`test`.`t1_16`.`a1`,8))) +drop table t1_16, t2_16, t3_16, t1, t2, t3; +set @blob_len = 512; +set @suffix_len = @blob_len - @prefix_len; +create table t1_512 (a1 blob(512), a2 blob(512)); +create table t2_512 (b1 blob(512), b2 blob(512)); +create table t3_512 (c1 blob(512), c2 blob(512)); +insert into t1_512 values +(concat('1 - 00', repeat('x', @suffix_len)), concat('2 - 00', repeat('x', @suffix_len))); +insert into t1_512 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t1_512 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_512 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t2_512 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_512 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_512 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t3_512 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t3_512 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_512 values +(concat('1 - 04', repeat('x', @suffix_len)), concat('2 - 04', repeat('x', @suffix_len))); +explain select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select b1 from t2_512 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1_512 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +2 MATERIALIZED t2_512 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_512`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_512`.`a2`,7) AS `left(a2,7)` from `test`.`t1_512` semi join (`test`.`t2_512`) where ((`test`.`t1_512`.`a1` = ``.`b1`) and (`test`.`t2_512`.`b1` > '0')) +select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select b1 from t2_512 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_512 +where (a1,a2) in (select b1, b2 from t2_512 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1_512 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +2 MATERIALIZED t2_512 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_512`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_512`.`a2`,7) AS `left(a2,7)` from `test`.`t1_512` semi join (`test`.`t2_512`) where ((`test`.`t1_512`.`a2` = ``.`b2`) and (`test`.`t1_512`.`a1` = ``.`b1`) and (`test`.`t2_512`.`b1` > '0')) +select left(a1,7), left(a2,7) +from t1_512 +where (a1,a2) in (select b1, b2 from t2_512 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select substring(b1,1,512) from t2_512 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1_512 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +2 MATERIALIZED t2_512 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_512`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_512`.`a2`,7) AS `left(a2,7)` from `test`.`t1_512` semi join (`test`.`t2_512`) where ((`test`.`t2_512`.`b1` > '0') and (`test`.`t1_512`.`a1` = ``.`substring(b1,1,512)`)) +select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select substring(b1,1,512) from t2_512 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select group_concat(b1) from t2_512 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_512 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 SUBQUERY t2_512 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_512`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_512`.`a2`,7) AS `left(a2,7)` from `test`.`t1_512` where (`test`.`t1_512`.`a1`,`test`.`t1_512`.`a1` in ( (/* select#2 */ select group_concat(`test`.`t2_512`.`b1` separator ',') from `test`.`t2_512` group by `test`.`t2_512`.`b2` having true ), (`test`.`t1_512`.`a1` in on where ((`test`.`t1_512`.`a1` = ``.`group_concat(b1)`))))) +select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select group_concat(b1) from t2_512 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +set @@group_concat_max_len = 256; +explain select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select group_concat(b1) from t2_512 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_512 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 SUBQUERY t2_512 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_512`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_512`.`a2`,7) AS `left(a2,7)` from `test`.`t1_512` where (`test`.`t1_512`.`a1`,`test`.`t1_512`.`a1` in ( (/* select#2 */ select group_concat(`test`.`t2_512`.`b1` separator ',') from `test`.`t2_512` group by `test`.`t2_512`.`b2` having true ), (`test`.`t1_512`.`a1` in on where ((`test`.`t1_512`.`a1` = ``.`group_concat(b1)`))))) +select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select group_concat(b1) from t2_512 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +drop table t1_512, t2_512, t3_512; +set @blob_len = 513; +set @suffix_len = @blob_len - @prefix_len; +create table t1_513 (a1 blob(513), a2 blob(513)); +create table t2_513 (b1 blob(513), b2 blob(513)); +create table t3_513 (c1 blob(513), c2 blob(513)); +insert into t1_513 values +(concat('1 - 00', repeat('x', @suffix_len)), concat('2 - 00', repeat('x', @suffix_len))); +insert into t1_513 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t1_513 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_513 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t2_513 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_513 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_513 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t3_513 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t3_513 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_513 values +(concat('1 - 04', repeat('x', @suffix_len)), concat('2 - 04', repeat('x', @suffix_len))); +explain select left(a1,7), left(a2,7) +from t1_513 +where a1 in (select b1 from t2_513 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1_513 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +2 MATERIALIZED t2_513 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_513`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_513`.`a2`,7) AS `left(a2,7)` from `test`.`t1_513` semi join (`test`.`t2_513`) where ((`test`.`t1_513`.`a1` = ``.`b1`) and (`test`.`t2_513`.`b1` > '0')) +select left(a1,7), left(a2,7) +from t1_513 +where a1 in (select b1 from t2_513 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_513 +where (a1,a2) in (select b1, b2 from t2_513 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1_513 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +2 MATERIALIZED t2_513 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_513`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_513`.`a2`,7) AS `left(a2,7)` from `test`.`t1_513` semi join (`test`.`t2_513`) where ((`test`.`t1_513`.`a2` = ``.`b2`) and (`test`.`t1_513`.`a1` = ``.`b1`) and (`test`.`t2_513`.`b1` > '0')) +select left(a1,7), left(a2,7) +from t1_513 +where (a1,a2) in (select b1, b2 from t2_513 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_513 +where a1 in (select substring(b1,1,513) from t2_513 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1_513 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +2 MATERIALIZED t2_513 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_513`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_513`.`a2`,7) AS `left(a2,7)` from `test`.`t1_513` semi join (`test`.`t2_513`) where ((`test`.`t2_513`.`b1` > '0') and (`test`.`t1_513`.`a1` = ``.`substring(b1,1,513)`)) +select left(a1,7), left(a2,7) +from t1_513 +where a1 in (select substring(b1,1,513) from t2_513 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_513 +where a1 in (select group_concat(b1) from t2_513 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_513 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 SUBQUERY t2_513 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_513`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_513`.`a2`,7) AS `left(a2,7)` from `test`.`t1_513` where (`test`.`t1_513`.`a1`,`test`.`t1_513`.`a1` in ( (/* select#2 */ select group_concat(`test`.`t2_513`.`b1` separator ',') from `test`.`t2_513` group by `test`.`t2_513`.`b2` having true ), (`test`.`t1_513`.`a1` in on where ((`test`.`t1_513`.`a1` = ``.`group_concat(b1)`))))) +select left(a1,7), left(a2,7) +from t1_513 +where a1 in (select group_concat(b1) from t2_513 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +drop table t1_513, t2_513, t3_513; +set @blob_len = 1024; +set @suffix_len = @blob_len - @prefix_len; +create table t1_1024 (a1 blob(1024), a2 blob(1024)); +create table t2_1024 (b1 blob(1024), b2 blob(1024)); +create table t3_1024 (c1 blob(1024), c2 blob(1024)); +insert into t1_1024 values +(concat('1 - 00', repeat('x', @suffix_len)), concat('2 - 00', repeat('x', @suffix_len))); +insert into t1_1024 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t1_1024 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_1024 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t2_1024 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_1024 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_1024 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t3_1024 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t3_1024 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_1024 values +(concat('1 - 04', repeat('x', @suffix_len)), concat('2 - 04', repeat('x', @suffix_len))); +explain select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select b1 from t2_1024 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1_1024 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +2 MATERIALIZED t2_1024 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1024`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1024`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1024` semi join (`test`.`t2_1024`) where ((`test`.`t1_1024`.`a1` = ``.`b1`) and (`test`.`t2_1024`.`b1` > '0')) +select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select b1 from t2_1024 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_1024 +where (a1,a2) in (select b1, b2 from t2_1024 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1_1024 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +2 MATERIALIZED t2_1024 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1024`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1024`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1024` semi join (`test`.`t2_1024`) where ((`test`.`t1_1024`.`a2` = ``.`b2`) and (`test`.`t1_1024`.`a1` = ``.`b1`) and (`test`.`t2_1024`.`b1` > '0')) +select left(a1,7), left(a2,7) +from t1_1024 +where (a1,a2) in (select b1, b2 from t2_1024 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select substring(b1,1,1024) from t2_1024 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1_1024 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +2 MATERIALIZED t2_1024 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1024`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1024`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1024` semi join (`test`.`t2_1024`) where ((`test`.`t2_1024`.`b1` > '0') and (`test`.`t1_1024`.`a1` = ``.`substring(b1,1,1024)`)) +select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select substring(b1,1,1024) from t2_1024 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select group_concat(b1) from t2_1024 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_1024 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 SUBQUERY t2_1024 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1024`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1024`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1024` where (`test`.`t1_1024`.`a1`,`test`.`t1_1024`.`a1` in ( (/* select#2 */ select group_concat(`test`.`t2_1024`.`b1` separator ',') from `test`.`t2_1024` group by `test`.`t2_1024`.`b2` having true ), (`test`.`t1_1024`.`a1` in on where ((`test`.`t1_1024`.`a1` = ``.`group_concat(b1)`))))) +select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select group_concat(b1) from t2_1024 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +set @@group_concat_max_len = 256; +explain select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select group_concat(b1) from t2_1024 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_1024 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 SUBQUERY t2_1024 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1024`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1024`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1024` where (`test`.`t1_1024`.`a1`,`test`.`t1_1024`.`a1` in ( (/* select#2 */ select group_concat(`test`.`t2_1024`.`b1` separator ',') from `test`.`t2_1024` group by `test`.`t2_1024`.`b2` having true ), (`test`.`t1_1024`.`a1` in on where ((`test`.`t1_1024`.`a1` = ``.`group_concat(b1)`))))) +select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select group_concat(b1) from t2_1024 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +drop table t1_1024, t2_1024, t3_1024; +set @blob_len = 1025; +set @suffix_len = @blob_len - @prefix_len; +create table t1_1025 (a1 blob(1025), a2 blob(1025)); +create table t2_1025 (b1 blob(1025), b2 blob(1025)); +create table t3_1025 (c1 blob(1025), c2 blob(1025)); +insert into t1_1025 values +(concat('1 - 00', repeat('x', @suffix_len)), concat('2 - 00', repeat('x', @suffix_len))); +insert into t1_1025 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t1_1025 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_1025 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t2_1025 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_1025 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_1025 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t3_1025 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t3_1025 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_1025 values +(concat('1 - 04', repeat('x', @suffix_len)), concat('2 - 04', repeat('x', @suffix_len))); +explain select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select b1 from t2_1025 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1_1025 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +2 MATERIALIZED t2_1025 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1025`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1025`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1025` semi join (`test`.`t2_1025`) where ((`test`.`t1_1025`.`a1` = ``.`b1`) and (`test`.`t2_1025`.`b1` > '0')) +select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select b1 from t2_1025 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_1025 +where (a1,a2) in (select b1, b2 from t2_1025 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1_1025 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +2 MATERIALIZED t2_1025 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1025`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1025`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1025` semi join (`test`.`t2_1025`) where ((`test`.`t1_1025`.`a2` = ``.`b2`) and (`test`.`t1_1025`.`a1` = ``.`b1`) and (`test`.`t2_1025`.`b1` > '0')) +select left(a1,7), left(a2,7) +from t1_1025 +where (a1,a2) in (select b1, b2 from t2_1025 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select substring(b1,1,1025) from t2_1025 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1_1025 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +2 MATERIALIZED t2_1025 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1025`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1025`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1025` semi join (`test`.`t2_1025`) where ((`test`.`t2_1025`.`b1` > '0') and (`test`.`t1_1025`.`a1` = ``.`substring(b1,1,1025)`)) +select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select substring(b1,1,1025) from t2_1025 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select group_concat(b1) from t2_1025 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_1025 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 SUBQUERY t2_1025 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1025`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1025`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1025` where (`test`.`t1_1025`.`a1`,`test`.`t1_1025`.`a1` in ( (/* select#2 */ select group_concat(`test`.`t2_1025`.`b1` separator ',') from `test`.`t2_1025` group by `test`.`t2_1025`.`b2` having true ), (`test`.`t1_1025`.`a1` in on where ((`test`.`t1_1025`.`a1` = ``.`group_concat(b1)`))))) +select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select group_concat(b1) from t2_1025 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +set @@group_concat_max_len = 256; +explain select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select group_concat(b1) from t2_1025 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_1025 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 SUBQUERY t2_1025 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1025`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1025`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1025` where (`test`.`t1_1025`.`a1`,`test`.`t1_1025`.`a1` in ( (/* select#2 */ select group_concat(`test`.`t2_1025`.`b1` separator ',') from `test`.`t2_1025` group by `test`.`t2_1025`.`b2` having true ), (`test`.`t1_1025`.`a1` in on where ((`test`.`t1_1025`.`a1` = ``.`group_concat(b1)`))))) +select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select group_concat(b1) from t2_1025 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +drop table t1_1025, t2_1025, t3_1025; +# +# WL#5561: Enable semi join transformation with outer join. +# +CREATE TABLE ot1(a INT); +CREATE TABLE ot2(a INT); +CREATE TABLE ot3(a INT); +CREATE TABLE it1(a INT); +CREATE TABLE it2(a INT); +CREATE TABLE it3(a INT); +INSERT INTO ot1 VALUES(0),(1),(2),(3),(4),(5),(6),(7); +INSERT INTO ot2 VALUES(0),(2),(4),(6); +INSERT INTO ot3 VALUES(0),(3),(6); +INSERT INTO it1 VALUES(0),(1),(2),(3),(4),(5),(6),(7); +INSERT INTO it2 VALUES(0),(2),(4),(6); +INSERT INTO it3 VALUES(0),(3),(6); +# Test cases, Subquery Pattern 1 +# Example SQ1.1: +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE ot1.a IN (SELECT a FROM it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; Using join buffer (hash join) +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (hash join) +2 MATERIALIZED it3 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` left join `test`.`ot2` on((`test`.`ot2`.`a` = `test`.`ot1`.`a`)) semi join (`test`.`it3`) where (`test`.`ot1`.`a` = ``.`a`) +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE ot1.a IN (SELECT a FROM it3); +a a +0 0 +3 NULL +6 6 +# Example SQ1.2: +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE COALESCE(ot2.a,0) IN (SELECT a FROM it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 Using join buffer (hash join) +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (hash join) +2 MATERIALIZED it3 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` left join `test`.`ot2` on((`test`.`ot2`.`a` = `test`.`ot1`.`a`)) semi join (`test`.`it3`) where (coalesce(`test`.`ot2`.`a`,0) = ``.`a`) +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE COALESCE(ot2.a,0) IN (SELECT a FROM it3); +a a +0 0 +1 NULL +3 NULL +5 NULL +6 6 +7 NULL +# Example SQ1.3: +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE (ot1.a,ot2.a) IN (SELECT a, a FROM it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using where +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; Using join buffer (hash join) +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; Using join buffer (hash join) +2 MATERIALIZED it3 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` join `test`.`ot2` semi join (`test`.`it3`) where ((``.`a` = ``.`a`) and (`test`.`ot2`.`a` = ``.`a`) and (`test`.`ot1`.`a` = ``.`a`)) +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE (ot1.a,ot2.a) IN (SELECT a, a FROM it3); +a a +0 0 +6 6 +# More test cases +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 +WHERE ot1.a IN (SELECT a FROM it3); +a a +0 0 +3 NULL +6 6 +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 +WHERE ot1.a IN (SELECT a+0 FROM it3); +a a +0 0 +3 NULL +6 6 +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 +WHERE COALESCE(ot2.a,0) IN (SELECT a FROM it3); +a a +0 0 +1 NULL +3 NULL +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE COALESCE(ot2.a,0) IN (SELECT a+0 FROM it3); +a a +0 0 +1 NULL +3 NULL +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 +WHERE (ot1.a,ot2.a) IN (SELECT a, a FROM it3); +a a +0 0 +6 6 +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +LEFT JOIN ot3 ON ot1.a=ot3.a +WHERE ot1.a IN (SELECT a FROM it3); +a a a +0 0 0 +3 NULL 3 +6 6 6 +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +LEFT JOIN ot3 ON ot1.a=ot3.a +WHERE COALESCE(ot2.a,0) IN (SELECT a FROM it3); +a a a +0 0 0 +1 NULL NULL +3 NULL 3 +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +LEFT JOIN ot3 ON ot1.a=ot3.a +WHERE COALESCE(ot3.a,0) IN (SELECT a FROM it3); +a a a +0 0 0 +1 NULL NULL +2 2 NULL +3 NULL 3 +4 4 NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +LEFT JOIN ot3 ON ot2.a=ot3.a +WHERE ot1.a IN (SELECT a FROM it3); +a a a +0 0 0 +3 NULL NULL +6 6 6 +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +LEFT JOIN ot3 ON ot2.a=ot3.a +WHERE COALESCE(ot2.a,0) IN (SELECT a FROM it3); +a a a +0 0 0 +1 NULL NULL +3 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +LEFT JOIN ot3 ON ot2.a=ot3.a +WHERE COALESCE(ot3.a,0) IN (SELECT a FROM it3); +a a a +0 0 0 +1 NULL NULL +2 2 NULL +3 NULL NULL +4 4 NULL +5 NULL NULL +6 6 6 +7 NULL NULL +# Test cases, Subquery Pattern 2 +# Example SQ2.1: +explain SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; Using join buffer (hash join) +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; Using join buffer (hash join) +2 MATERIALIZED it3 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` join `test`.`ot2` semi join (`test`.`it3`) where ((`test`.`ot1`.`a` = ``.`a`) and (`test`.`ot2`.`a` = ``.`a`)) +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3); +a a +0 0 +6 6 +# Example SQ2.2: +explain SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it2) +AND ot2.a IN (SELECT a FROM it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using where +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; Using join buffer (hash join) +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; Using join buffer (hash join) +1 SIMPLE NULL eq_ref 5 .a 1 100.00 NULL +3 MATERIALIZED it3 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 MATERIALIZED it2 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` join `test`.`ot2` semi join (`test`.`it2`) semi join (`test`.`it3`) where ((`test`.`ot1`.`a` = ``.`a`) and (`test`.`ot2`.`a` = ``.`a`) and (``.`a` = ``.`a`)) +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it2) +AND ot2.a IN (SELECT a FROM it3); +a a +0 0 +6 6 +# More test cases +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it3); +a a +0 0 +6 6 +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it3); +a a +0 0 +6 6 +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a+0 AND ot2.a IN (SELECT a FROM it3); +a a +0 0 +6 6 +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot2.a IN (SELECT a+0 FROM it3); +a a +0 0 +6 6 +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it2) +AND ot2.a IN (SELECT a+0 FROM it3); +a a +0 0 +6 6 +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3) +JOIN ot3 ON ot2.a=ot3.a AND ot3.a IN (SELECT a FROM it3); +a a a +0 0 0 +6 6 6 +# Test cases, Subquery Pattern 3 +# Example SQ3.1: +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +1 SIMPLE NULL eq_ref 5 test.ot1.a 1 100.00 NULL +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +2 MATERIALIZED it3 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` semi join (`test`.`it3`)) on(((``.`a` = `test`.`ot1`.`a`) and (`test`.`ot2`.`a` = `test`.`ot1`.`a`))) where true +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3); +a a +0 0 +1 NULL +2 NULL +3 NULL +4 NULL +5 NULL +6 6 +7 NULL +# Example SQ3.2: +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot2.a IN (SELECT a FROM it2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +1 SIMPLE NULL eq_ref 5 test.ot2.a 1 100.00 Using where +2 MATERIALIZED it2 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` semi join (`test`.`it2`)) on(((`test`.`ot2`.`a` = `test`.`ot1`.`a`) and (``.`a` = `test`.`ot1`.`a`))) where true +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot2.a IN (SELECT a FROM it2); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +# Example SQ3.3 +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1) +AND ot2.a IN (SELECT a FROM it2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +1 SIMPLE NULL eq_ref 5 test.ot1.a 1 100.00 NULL +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +1 SIMPLE NULL eq_ref 5 test.ot2.a 1 100.00 Using where +2 MATERIALIZED it1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +3 MATERIALIZED it2 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` semi join (`test`.`it1`) semi join (`test`.`it2`)) on(((``.`a` = `test`.`ot1`.`a`) and (`test`.`ot2`.`a` = `test`.`ot1`.`a`) and (``.`a` = `test`.`ot1`.`a`))) where true +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1) +AND ot2.a IN (SELECT a FROM it2); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +# Example SQ3.4 +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND +(ot1.a, ot2.a) IN (SELECT it1.a, it2.a +FROM it1 JOIN it2 ON it1.a=it2.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +1 SIMPLE NULL eq_ref 10 test.ot1.a,test.ot2.a 1 100.00 Using where +2 MATERIALIZED it2 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +2 MATERIALIZED it1 NULL ALL NULL NULL NULL NULL 8 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` semi join (`test`.`it1` join `test`.`it2`)) on(((`test`.`ot2`.`a` = `test`.`ot1`.`a`) and (``.`a` = `test`.`ot1`.`a`) and (``.`a` = `test`.`ot1`.`a`) and (`test`.`it1`.`a` = `test`.`it2`.`a`))) where true +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND +(ot1.a, ot2.a) IN (SELECT it1.a, it2.a +FROM it1 JOIN it2 ON it1.a=it2.a); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +# More test cases +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it3); +a a +0 0 +1 NULL +2 NULL +3 NULL +4 NULL +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it3); +a a +0 0 +1 NULL +2 NULL +3 NULL +4 NULL +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 AND ot2.a IN (SELECT a FROM it2); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot2.a IN (SELECT a+0 FROM it2); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a+0 FROM it1) +AND ot2.a IN (SELECT a+0 FROM it2); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 AND +(ot1.a, ot2.a) IN (SELECT it1.a+0, it2.a+0 +FROM it1 JOIN it2 ON it1.a=it2.a); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +EXPLAIN FORMAT=tree SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3) +LEFT JOIN ot3 ON ot2.a=ot3.a AND ot3.a IN (SELECT a FROM it3); +EXPLAIN +-> Nested loop left join (cost=41.01 rows=288) + -> Nested loop left join (cost=11.70 rows=96) + -> Table scan on ot1 (cost=1.30 rows=8) + -> Nested loop inner join (cost=2.80 rows=12) + -> Single-row index lookup on using (a=ot1.a) + -> Materialize with deduplication (cost=1.10..1.10 rows=3) + -> Filter: (it3.a is not null) (cost=0.80 rows=3) + -> Table scan on it3 (cost=0.80 rows=3) + -> Filter: (ot2.a = ot1.a) (cost=0.11 rows=4) + -> Table scan on ot2 (cost=0.11 rows=4) + -> Nested loop inner join (cost=9.93 rows=3) + -> Filter: (ot3.a = ot2.a) (cost=0.03 rows=3) + -> Table scan on ot3 (cost=0.03 rows=3) + -> Filter: (``.a = ot2.a) (cost=3.23..3.23 rows=1) + -> Single-row index lookup on using (a=ot3.a) + -> Materialize with deduplication (cost=1.10..1.10 rows=3) + -> Filter: (it3.a is not null) (cost=0.80 rows=3) + -> Table scan on it3 (cost=0.80 rows=3) + +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3) +LEFT JOIN ot3 ON ot2.a=ot3.a AND ot3.a IN (SELECT a FROM it3); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it3) +LEFT JOIN ot3 ON ot2.a=ot3.a+0 AND ot3.a IN (SELECT a FROM it3); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +# Test cases, Subquery Pattern 4 +# Example SQ4.1: +explain SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +1 SIMPLE NULL eq_ref 5 test.ot1.a 1 100.00 NULL +1 SIMPLE ot3 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +2 MATERIALIZED it1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a`,`test`.`ot3`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` join `test`.`ot3` semi join (`test`.`it1`)) on(((``.`a` = `test`.`ot1`.`a`) and (`test`.`ot3`.`a` = `test`.`ot1`.`a`) and (`test`.`ot2`.`a` = `test`.`ot1`.`a`))) where true +SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +# Example SQ4.2: +explain SELECT * +FROM ot1 +JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot3 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; Using join buffer (hash join) +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; Using join buffer (hash join) +1 SIMPLE NULL eq_ref 5 test.ot3.a 1 100.00 NULL +2 MATERIALIZED it1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a`,`test`.`ot3`.`a` AS `a` from `test`.`ot1` join `test`.`ot2` join `test`.`ot3` semi join (`test`.`it1`) where ((`test`.`ot2`.`a` = `test`.`ot3`.`a`) and (`test`.`ot1`.`a` = `test`.`ot3`.`a`) and (``.`a` = `test`.`ot3`.`a`)) +SELECT * +FROM ot1 +JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +6 6 6 +# Example SQ4.3: +explain SELECT * +FROM ot1 +JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; Using join buffer (hash join) +1 SIMPLE NULL eq_ref 5 test.ot2.a 1 100.00 NULL +1 SIMPLE ot3 NULL ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (hash join) +2 MATERIALIZED it1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a`,`test`.`ot3`.`a` AS `a` from `test`.`ot1` join `test`.`ot2` left join `test`.`ot3` on((`test`.`ot3`.`a` = `test`.`ot2`.`a`)) semi join (`test`.`it1`) where ((`test`.`ot1`.`a` = `test`.`ot2`.`a`) and (``.`a` = `test`.`ot2`.`a`)) +SELECT * +FROM ot1 +JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +2 2 NULL +4 4 NULL +6 6 6 +# Example SQ4.4: +explain SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +1 SIMPLE NULL eq_ref 5 test.ot1.a 1 100.00 NULL +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +1 SIMPLE ot3 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 MATERIALIZED it1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a`,`test`.`ot3`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` left join `test`.`ot3` on((`test`.`ot3`.`a` = `test`.`ot1`.`a`)) semi join (`test`.`it1`)) on(((``.`a` = `test`.`ot1`.`a`) and (`test`.`ot2`.`a` = `test`.`ot1`.`a`))) where true +SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +1 NULL NULL +2 2 NULL +3 NULL NULL +4 4 NULL +5 NULL NULL +6 6 6 +7 NULL NULL +# More test cases +SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a+0) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it1); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 +JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a+0) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +6 6 6 +SELECT * +FROM ot1 +JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +6 6 6 +SELECT * +FROM ot1 +JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it1); +a a a +0 0 0 +6 6 6 +SELECT * +FROM ot1 +JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a+0) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +2 2 NULL +4 4 NULL +6 6 6 +SELECT * +FROM ot1 +JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +2 2 NULL +4 4 NULL +6 6 6 +SELECT * +FROM ot1 +JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it1); +a a a +0 0 0 +2 2 NULL +4 4 NULL +6 6 6 +SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a+0) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +1 NULL NULL +2 2 NULL +3 NULL NULL +4 4 NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +1 NULL NULL +2 2 NULL +3 NULL NULL +4 4 NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it1); +a a a +0 0 0 +1 NULL NULL +2 2 NULL +3 NULL NULL +4 4 NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1) +LEFT JOIN +ot1 AS ot4 +ON ot2.a=ot4.a; +a a a a +0 0 0 0 +1 NULL NULL NULL +2 2 NULL 2 +3 NULL NULL NULL +4 4 NULL 4 +5 NULL NULL NULL +6 6 6 6 +7 NULL NULL NULL +SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a +LEFT JOIN ot1 AS ot4 ON ot3.a=ot4.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a a +0 0 0 0 +1 NULL NULL NULL +2 2 NULL NULL +3 NULL NULL NULL +4 4 NULL NULL +5 NULL NULL NULL +6 6 6 6 +7 NULL NULL NULL +DROP TABLE ot1,ot2,ot3,it1,it2,it3; +CREATE TABLE t ( +a INTEGER DEFAULT NULL +) ENGINE=InnoDB; +INSERT INTO t VALUES (1); +CREATE TABLE t2 ( +a INTEGER DEFAULT NULL +) ENGINE=InnoDB; +INSERT INTO t2 VALUES (1),(1); +CREATE TABLE t4 ( +a INTEGER DEFAULT NULL +) ENGINE=InnoDB; +INSERT INTO t4 VALUES (1),(1); +CREATE TABLE v ( +a INTEGER DEFAULT NULL +) ENGINE=InnoDB; +INSERT INTO v VALUES (1),(1); +explain SELECT * +FROM t AS t1 +LEFT JOIN +(t2 +LEFT JOIN t AS t3 +ON t3.a IN (SELECT a FROM t AS it) +JOIN t4 +ON t4.a=100 +) +ON TRUE +WHERE t1.a IN (SELECT * FROM v AS it2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE NULL eq_ref 5 test.t1.a 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL eq_ref 5 test.t3.a 1 100.00 NULL +1 SIMPLE t4 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +3 MATERIALIZED it2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED it NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t4`.`a` AS `a` from `test`.`t` `t1` left join (`test`.`t2` left join (`test`.`t` `t3` semi join (`test`.`t` `it`)) on(((``.`a` = `test`.`t3`.`a`))) join `test`.`t4`) on(((`test`.`t4`.`a` = 100))) semi join (`test`.`v` `it2`) where (``.`a` = `test`.`t1`.`a`) +SELECT * +FROM t AS t1 +LEFT JOIN +(t2 +LEFT JOIN t AS t3 +ON t3.a IN (SELECT a FROM t AS it) +JOIN t4 +ON t4.a=100 +) +ON TRUE +WHERE t1.a IN (SELECT * FROM v AS it2); +a a a a +1 NULL NULL NULL +DROP TABLE t,t2,t4,v; +# End of WL#5561 +# +# Bug#48868: Left outer join in subquery causes segmentation fault in +# make_join_select. +# +CREATE TABLE t1 (i INTEGER); +INSERT INTO t1 VALUES (1); +INSERT INTO t1 VALUES (2); +CREATE TABLE t2 (i INTEGER); +INSERT INTO t2 VALUES(1); +CREATE TABLE t3 (i INTEGER); +INSERT INTO t3 VALUES (1); +INSERT INTO t3 VALUES (2); +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t2.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +1 +DROP TABLE t1, t2, t3; + +Bug#37899: Wrongly checked optimization prerequisite caused failed +assertion. + +CREATE TABLE t1 ( +`pk` int(11), +`varchar_nokey` varchar(5) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES +(1,'qk'),(2,'j'),(3,'aew'); +SELECT * +FROM t1 +WHERE varchar_nokey IN ( +SELECT +varchar_nokey +FROM +t1 +) XOR pk = 30; +pk varchar_nokey +1 qk +2 j +3 aew +drop table t1; +# +# BUG#41842: Semi-join materialization strategy crashes when the upper query has HAVING +# +CREATE TABLE t1 ( +pk int(11) NOT NULL AUTO_INCREMENT, +int_nokey int(11) NOT NULL, +time_key time NOT NULL, +datetime_key datetime NOT NULL, +datetime_nokey datetime NOT NULL, +varchar_key varchar(1) NOT NULL, +varchar_nokey varchar(1) NOT NULL, +PRIMARY KEY (pk), +KEY time_key (time_key), +KEY datetime_key (datetime_key), +KEY varchar_key (varchar_key) +) ENGINE=MyISaM; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES +(1,0, '00:16:10','2008-09-03 14:25:40','2008-09-03 14:25:40','h','h'), +(2,7, '00:00:00','2001-01-13 00:00:00','2001-01-13 00:00:00','',''), +(3,0, '00:00:00','0000-00-00 00:00:00','0000-00-00 00:00:00','x','x'), +(4,2, '16:29:24','2000-10-16 01:39:08','2000-10-16 01:39:08','w','w'), +(5,1, '09:23:32','0000-00-00 00:00:00','0000-00-00 00:00:00','p','p'), +(6,3, '00:00:00','2007-12-02 00:00:00','2007-12-02 00:00:00','o','o'), +(7,3, '00:00:00','2008-09-11 00:00:00','2008-09-11 00:00:00','',''), +(8,0, '13:59:04','0000-00-00 00:00:00','0000-00-00 00:00:00','s','s'), +(9,7, '09:01:06','0000-00-00 00:00:00','0000-00-00 00:00:00','d','d'), +(10,5,'00:00:00','0000-00-00 00:00:00','0000-00-00 00:00:00','n','n'), +(11,0,'21:06:46','0000-00-00 00:00:00','0000-00-00 00:00:00','o','o'), +(12,2,'00:00:00','0000-00-00 00:00:00','0000-00-00 00:00:00','',''), +(13,6,'14:45:34','2003-07-28 02:34:08','2003-07-28 02:34:08','w','w'), +(14,1,'15:04:12','0000-00-00 00:00:00','0000-00-00 00:00:00','o','o'), +(15,0,'00:00:00','0000-00-00 00:00:00','0000-00-00 00:00:00','x','x'), +(16,0,'15:55:23','2004-03-17 00:32:27','2004-03-17 00:32:27','p','p'), +(17,1,'16:30:00','2004-12-27 19:20:00','2004-12-27 19:20:00','d','d'), +(18,0,'00:00:00','0000-00-00 00:00:00','0000-00-00 00:00:00','h','h'), +(19,0,'14:13:26','2008-11-09 05:53:48','2008-11-09 05:53:48','o','o'), +(20,0,'00:00:00','2009-10-11 06:58:04','2009-10-11 06:58:04','k','k'); +Warnings: +Warning 1264 Out of range value for column 'datetime_key' at row 3 +Warning 1264 Out of range value for column 'datetime_nokey' at row 3 +Warning 1264 Out of range value for column 'datetime_key' at row 5 +Warning 1264 Out of range value for column 'datetime_nokey' at row 5 +Warning 1264 Out of range value for column 'datetime_key' at row 8 +Warning 1264 Out of range value for column 'datetime_nokey' at row 8 +Warning 1264 Out of range value for column 'datetime_key' at row 9 +Warning 1264 Out of range value for column 'datetime_nokey' at row 9 +Warning 1264 Out of range value for column 'datetime_key' at row 10 +Warning 1264 Out of range value for column 'datetime_nokey' at row 10 +Warning 1264 Out of range value for column 'datetime_key' at row 11 +Warning 1264 Out of range value for column 'datetime_nokey' at row 11 +Warning 1264 Out of range value for column 'datetime_key' at row 12 +Warning 1264 Out of range value for column 'datetime_nokey' at row 12 +Warning 1264 Out of range value for column 'datetime_key' at row 14 +Warning 1264 Out of range value for column 'datetime_nokey' at row 14 +Warning 1264 Out of range value for column 'datetime_key' at row 15 +Warning 1264 Out of range value for column 'datetime_nokey' at row 15 +Warning 1264 Out of range value for column 'datetime_key' at row 18 +Warning 1264 Out of range value for column 'datetime_nokey' at row 18 +CREATE TABLE t2 ( +pk int(11) NOT NULL AUTO_INCREMENT, +int_nokey int(11) NOT NULL, +time_key time NOT NULL, +datetime_key datetime NOT NULL, +datetime_nokey datetime NOT NULL, +varchar_key varchar(1) NOT NULL, +varchar_nokey varchar(1) NOT NULL, +PRIMARY KEY (pk), +KEY time_key (time_key), +KEY datetime_key (datetime_key), +KEY varchar_key (varchar_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT IGNORE INTO t2 VALUES +(10,0,'19:39:13','0000-00-00 00:00:00','0000-00-00 00:00:00','g','g'), +(11,8,'03:43:53','0000-00-00 00:00:00','0000-00-00 00:00:00','b','b'); +Warnings: +Warning 1264 Out of range value for column 'datetime_key' at row 1 +Warning 1264 Out of range value for column 'datetime_nokey' at row 1 +Warning 1264 Out of range value for column 'datetime_key' at row 2 +Warning 1264 Out of range value for column 'datetime_nokey' at row 2 +SELECT OUTR.datetime_nokey AS X FROM t1 AS OUTR +WHERE +OUTR.varchar_nokey IN (SELECT +INNR . varchar_nokey AS Y +FROM t2 AS INNR +WHERE +INNR . datetime_key >= INNR . time_key OR +INNR . pk = INNR . int_nokey +) +AND OUTR . varchar_nokey <= 'w' +HAVING X > '2012-12-12'; +X +drop table t1, t2; + +Bug#46797 "Crash in fix_semijoin_strategies_for_picked_join_order +with semijoin=on" + +CREATE TABLE t1 ( +varchar_key varchar(1) DEFAULT NULL, +KEY varchar_key (varchar_key) +); +CREATE TABLE t2 ( +varchar_key varchar(1) DEFAULT NULL, +KEY varchar_key (varchar_key) +); +INSERT INTO t2 VALUES +(NULL),(NULL),(NULL),(NULL),('a'),('a'),('a'),('b'),('b'),('b'),('b'),('c'), +('c'),('c'),('c'),('c'),('c'),('c'),('d'),('d'),('d'),('d'),('d'),('d'),('e'), +('e'),('e'),('e'),('e'),('e'),('f'),('f'),('f'),('g'),('g'),('h'),('h'),('h'), +('h'),('i'),('j'),('j'),('j'),('k'),('k'),('l'),('l'),('m'),('m'),('m'),('m'), +('n'),('n'),('n'),('o'),('o'),('o'),('p'),('p'),('p'),('q'),('q'),('q'),('r'), +('r'),('r'),('r'),('s'),('s'),('s'),('s'),('t'),('t'),('t'),('t'),('u'),('u'), +('u'),('u'),('v'),('v'),('v'),('v'),('w'),('w'),('w'),('w'),('w'),('w'),('x'), +('x'),('x'),('y'),('y'),('y'),('y'),('z'),('z'),('z'),('z'); +CREATE TABLE t3 ( +varchar_key varchar(1) DEFAULT NULL, +KEY varchar_key (varchar_key) +) ENGINE=MyISAM DEFAULT CHARSET=latin1; +INSERT INTO t3 VALUES +(NULL),('c'),('d'),('e'),('f'),('h'),('j'),('k'),('k'),('m'),('m'),('m'), +('n'),('o'),('r'),('t'),('t'),('u'),('w'),('y'); +SELECT varchar_key FROM t3 +WHERE (SELECT varchar_key FROM t3 +WHERE (varchar_key,varchar_key) +IN (SELECT t1.varchar_key, t2 .varchar_key +FROM t1 RIGHT JOIN t2 ON t1.varchar_key +) +); +varchar_key +DROP TABLE t1, t2, t3; +# +# Bug#46556 Returning incorrect, empty results for some IN subqueries +# w/semijoin=on +# +CREATE TABLE t0 ( +pk INTEGER, +vkey VARCHAR(1), +vnokey VARCHAR(1), +PRIMARY KEY (pk), +KEY vkey(vkey) +) charset utf8mb4; +INSERT INTO t0 +VALUES (1,'g','g'), (2,'v','v'), (3,'t','t'), (4,'u','u'), (5,'n','n'); +EXPLAIN SELECT vkey FROM t0 WHERE pk IN +(SELECT t1.pk FROM t0 t1 JOIN t0 t2 ON t2.vkey = t1.vnokey); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index vkey vkey 7 NULL 5 100.00 Using index; Start temporary +1 SIMPLE t1 NULL ALL PRIMARY NULL NULL NULL 5 20.00 Using where; Using join buffer (hash join) +1 SIMPLE t0 NULL eq_ref PRIMARY PRIMARY 4 test.t1.pk 1 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`vkey` AS `vkey` from `test`.`t0` `t1` join `test`.`t0` semi join (`test`.`t0` `t2`) where ((`test`.`t1`.`vnokey` = `test`.`t2`.`vkey`) and (`test`.`t0`.`pk` = `test`.`t1`.`pk`)) +SELECT vkey FROM t0 WHERE pk IN +(SELECT t1.pk FROM t0 t1 JOIN t0 t2 ON t2.vkey = t1.vnokey); +vkey +g +n +t +u +v +DROP TABLE t0; +# End of bug#46556 + +Bug#48834: Procedure with view + subquery + semijoin=on +crashes on second call. + +CREATE TABLE t1 ( t1field integer, primary key (t1field)); +CREATE TABLE t2 ( t2field integer, primary key (t2field)); +CREATE VIEW v1 AS +SELECT t1field as v1field +FROM t1 A +WHERE A.t1field IN (SELECT t1field FROM t2 ); +CREATE VIEW v2 AS +SELECT t2field as v2field +FROM t2 A +WHERE A.t2field IN (SELECT t2field FROM t2 ); +CREATE PROCEDURE p1 () +BEGIN +SELECT v1field +FROM v1 +WHERE v1field IN ( SELECT v2field as vf_inner FROM v2 ); +END| +INSERT INTO t1 VALUES (1),(2),(3); +INSERT INTO t2 VALUES (2),(3),(4); +CALL p1; +v1field +2 +3 +CALL p1; +v1field +2 +3 +DROP TABLE t1,t2; +DROP VIEW v1,v2; +DROP PROCEDURE p1; +# End of BUG#48834 +# +# Bug#46692 "Crash occurring on queries with nested FROM subqueries +# using materialization." +# +CREATE TABLE t1 ( +pk INTEGER PRIMARY KEY, +int_key INTEGER, +KEY int_key(int_key) +); +INSERT INTO t1 VALUES (10,186),(11,NULL),(12,2),(13,3),(14,0),(15,133),(16,1); +CREATE TABLE t2 ( +pk INTEGER PRIMARY KEY, +int_key INTEGER, +KEY int_key(int_key) +); +INSERT INTO t2 VALUES (1,7),(2,2); +SELECT * FROM t1 WHERE (140, 4) IN +(SELECT t2.int_key, t2 .pk FROM t2 STRAIGHT_JOIN t1 ON t2.int_key); +pk int_key +DROP TABLE t1, t2; +# +# Bug#42353 "SELECT ... WHERE oe IN (SELECT w/ LEFT JOIN) query +# causes crash." +# +CREATE TABLE t1 ( +pk INTEGER PRIMARY KEY, +int_nokey INTEGER, +int_key INTEGER, +date_key DATE, +datetime_nokey DATETIME, +varchar_nokey VARCHAR(1) +); +CREATE TABLE t2 ( +date_nokey DATE +); +CREATE TABLE t3 ( +pk INTEGER PRIMARY KEY, +int_nokey INTEGER, +date_key date, +varchar_key VARCHAR(1), +varchar_nokey VARCHAR(1), +KEY date_key (date_key) +); +SELECT date_key FROM t1 +WHERE (int_key, int_nokey) +IN (SELECT t3.int_nokey, t3.pk +FROM t2 LEFT JOIN t3 ON (t2.date_nokey < t3.date_key) +WHERE t3.varchar_key <= t3.varchar_nokey OR t3.int_nokey <= t3.pk +) +AND (varchar_nokey <> 'f' OR NOT int_key < 7); +date_key +# +# Bug#45933 "Crash in optimize_semijoin_nests on JOIN in subquery +# + AND in outer query". +# +INSERT INTO t1 VALUES (10,7,5,'2009-06-16','2002-04-10 14:25:30','w'), +(11,7,0,'0000-00-00','0000-00-00 00:00:00','s'), +(12,4,0,'2003-07-14','2006-09-14 04:01:02','y'), +(13,0,4,'2002-07-25','0000-00-00 00:00:00','c'), +(14,1,8,'2007-07-03','0000-00-00 00:00:00','q'), +(15,6,5,'2001-11-12','0000-00-00 00:00:00',''), +(16,2,9,'0000-00-00','0000-00-00 00:00:00','j'), +(29,9,1,'0000-00-00','2003-08-11 00:00:00','m'); +Warnings: +Warning 1264 Out of range value for column 'date_key' at row 2 +Warning 1264 Out of range value for column 'datetime_nokey' at row 2 +Warning 1264 Out of range value for column 'datetime_nokey' at row 4 +Warning 1264 Out of range value for column 'datetime_nokey' at row 5 +Warning 1264 Out of range value for column 'datetime_nokey' at row 6 +Warning 1264 Out of range value for column 'date_key' at row 7 +Warning 1264 Out of range value for column 'datetime_nokey' at row 7 +Warning 1264 Out of range value for column 'date_key' at row 8 +INSERT IGNORE INTO t3 VALUES (1,9,'0000-00-00','b','b'), +(2,2,'2002-09-17','h','h'); +Warnings: +Warning 1264 Out of range value for column 'date_key' at row 1 +SELECT t1.varchar_nokey FROM t1 JOIN t3 ON t1.datetime_nokey +WHERE t1.varchar_nokey +IN (SELECT varchar_nokey FROM t1 +WHERE (pk) +IN (SELECT t3.int_nokey +FROM t3 LEFT JOIN t1 ON t1.varchar_nokey +WHERE t3.date_key BETWEEN '2008-06-07' AND '2006-06-26' + ) +); +varchar_nokey +DROP TABLE t1, t2, t3; +# +# Bug#45219 "Crash on SELECT DISTINCT query containing a +# LEFT JOIN in subquery" +# +CREATE TABLE t1 ( +pk INTEGER NOT NULL, +int_nokey INTEGER NOT NULL, +datetime_key DATETIME NOT NULL, +varchar_key VARCHAR(1) NOT NULL, +PRIMARY KEY (pk), +KEY datetime_key (datetime_key), +KEY varchar_key (varchar_key) +); +INSERT IGNORE INTO t1 VALUES +(1,9,'0000-00-00 00:00:00','p'),(2,0,'2002-02-09 07:38:13','v'), +(3,8,'2001-05-03 12:08:14','t'),(4,3,'0000-00-00 00:00:00','u'), +(5,7,'2009-07-28 03:43:30','n'),(6,0,'2009-08-04 00:00:00','l'), +(7,1,'0000-00-00 00:00:00','h'),(8,9,'0000-00-00 00:00:00','u'), +(9,0,'2005-08-02 17:16:54','n'),(10,9,'2002-12-21 00:00:00','j'), +(11,0,'2005-08-15 12:37:35','k'),(12,5,'0000-00-00 00:00:00','e'), +(13,0,'2006-03-10 00:00:00','i'),(14,8,'2005-05-16 11:02:36','u'), +(15,8,'2008-11-02 00:00:00','n'),(16,5,'2006-03-15 00:00:00','b'), +(17,1,'0000-00-00 00:00:00','x'),(18,7,'0000-00-00 00:00:00',''), +(19,0,'2008-12-17 20:15:40','q'),(20,9,'0000-00-00 00:00:00','u'); +Warnings: +Warning 1264 Out of range value for column 'datetime_key' at row 1 +Warning 1264 Out of range value for column 'datetime_key' at row 4 +Warning 1264 Out of range value for column 'datetime_key' at row 7 +Warning 1264 Out of range value for column 'datetime_key' at row 8 +Warning 1264 Out of range value for column 'datetime_key' at row 12 +Warning 1264 Out of range value for column 'datetime_key' at row 17 +Warning 1264 Out of range value for column 'datetime_key' at row 18 +Warning 1264 Out of range value for column 'datetime_key' at row 20 +CREATE TABLE t2 LIKE t1; +INSERT INTO t2 VALUES +(10,0,'2006-07-07 07:26:28','q'),(11,5,'2002-09-23 00:00:00','m'), +(12,7,'0000-00-00 00:00:00','j'),(13,1,'2006-06-07 00:00:00','z'), +(14,8,'2000-09-16 12:15:34','a'),(15,2,'2007-08-05 15:47:52',''), +(16,1,'0000-00-00 00:00:00','e'),(17,8,'2005-12-02 19:34:26','t'), +(18,5,'0000-00-00 00:00:00','q'),(19,4,'0000-00-00 00:00:00','b'), +(20,5,'2007-12-28 00:00:00','w'),(21,3,'2004-08-02 11:48:43','m'), +(22,0,'0000-00-00 00:00:00','x'),(23,8,'2004-04-19 12:18:43',''), +(24,0,'2009-04-27 00:00:00','w'),(25,4,'2006-10-20 14:52:15','x'), +(26,0,'0000-00-00 00:00:00','e'),(27,0,'2002-03-22 11:48:37','e'), +(28,2,'0000-00-00 00:00:00','p'),(29,0,'2001-01-04 03:55:07','x'); +Warnings: +Warning 1264 Out of range value for column 'datetime_key' at row 3 +Warning 1264 Out of range value for column 'datetime_key' at row 7 +Warning 1264 Out of range value for column 'datetime_key' at row 9 +Warning 1264 Out of range value for column 'datetime_key' at row 10 +Warning 1264 Out of range value for column 'datetime_key' at row 13 +Warning 1264 Out of range value for column 'datetime_key' at row 17 +Warning 1264 Out of range value for column 'datetime_key' at row 19 +CREATE TABLE t3 LIKE t1; +INSERT INTO t3 VALUES +(10,8,'2007-08-19 08:08:38','i'),(11,0,'2000-05-21 03:51:51',''); +SELECT DISTINCT datetime_key FROM t1 +WHERE (int_nokey, pk) +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#46550 Azalea returning duplicate results for some IN subqueries +# w/ semijoin=on +# +DROP TABLE IF EXISTS t0, t1, t2; +CREATE TABLE t0 ( +int_key int(11) DEFAULT NULL, +varchar_key varchar(1) DEFAULT NULL, +varchar_nokey varchar(1) DEFAULT NULL, +KEY int_key (int_key), +KEY varchar_key (varchar_key,int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t0 VALUES +(1,'m','m'), +(40,'h','h'), +(1,'r','r'), +(1,'h','h'), +(9,'x','x'), +(NULL,'q','q'), +(NULL,'k','k'), +(7,'l','l'), +(182,'k','k'), +(202,'a','a'), +(7,'x','x'), +(6,'j','j'), +(119,'z','z'), +(4,'d','d'), +(5,'h','h'), +(1,'u','u'), +(3,'q','q'), +(7,'a','a'), +(3,'e','e'), +(6,'l','l'); +CREATE TABLE t1 ( +int_key int(11) DEFAULT NULL, +varchar_key varchar(1) DEFAULT NULL, +varchar_nokey varchar(1) DEFAULT NULL, +KEY int_key (int_key), +KEY varchar_key (varchar_key,int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (7,NULL,NULL),(4,'x','x'); +CREATE TABLE t2 ( +int_key int(11) DEFAULT NULL, +varchar_key varchar(1) DEFAULT NULL, +varchar_nokey varchar(1) DEFAULT NULL, +KEY int_key (int_key), +KEY varchar_key (varchar_key,int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (123,NULL,NULL); +SELECT int_key +FROM t0 +WHERE varchar_nokey IN ( +SELECT t1 .varchar_key from t1 +); +int_key +7 +9 +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 +7 +9 +EXPLAIN +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 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 20 10.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t1_1 NULL index varchar_key varchar_key 12 NULL 2 50.00 Using where; Using index +2 MATERIALIZED t1_2 NULL index NULL int_key 5 NULL 2 100.00 Using index; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`int_key` AS `int_key` from `test`.`t0` semi join (`test`.`t1` `t1_1` join `test`.`t1` `t1_2`) where ((`test`.`t0`.`varchar_nokey` = ``.`varchar_key`) and (0 <> `test`.`t1_1`.`int_key`)) +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 +7 +9 +EXPLAIN +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 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 20 10.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t1_1 NULL index varchar_key varchar_key 12 NULL 2 50.00 Using where; Using index +2 MATERIALIZED t1_2 NULL index NULL int_key 5 NULL 2 100.00 Using index; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`int_key` AS `int_key` from `test`.`t0` semi join (`test`.`t1` `t1_1` join `test`.`t1` `t1_2`) where ((`test`.`t0`.`varchar_nokey` = ``.`varchar_key`) and (0 <> `test`.`t1_1`.`int_key`)) +DROP TABLE t0, t1, t2; +# End of bug#46550 + +Bug #48073 Subquery on char columns from view crashes Mysql + +DROP TABLE IF EXISTS t1, t2; +DROP VIEW IF EXISTS v1; +CREATE TABLE t1 ( +city VARCHAR(50) NOT NULL, +country_id SMALLINT UNSIGNED NOT NULL +); +INSERT INTO t1 VALUES +('Batna',2), +('Bchar',2), +('Skikda',2), +('Tafuna',3), +('Algeria',2) ; +CREATE TABLE t2 ( +country_id SMALLINT UNSIGNED NOT NULL, +country VARCHAR(50) NOT NULL +); +INSERT INTO t2 VALUES +(2,'Algeria'), +(3,'American Samoa') ; +CREATE VIEW v1 AS +SELECT country_id, country +FROM t2 +WHERE LEFT(country,1) = "A" +; +SELECT city, country_id +FROM t1 +WHERE city IN ( +SELECT country +FROM t2 +WHERE LEFT(country, 1) = "A" +); +city country_id +Algeria 2 +SELECT city, country_id +FROM t1 +WHERE city IN ( +SELECT country +FROM v1 +); +city country_id +Algeria 2 +drop table t1, t2; +drop view v1; +# End of bug#48073 + +Bug#49097 subquery with view generates wrong result with +non-prepared statement + +DROP TABLE IF EXISTS t1, t2; +DROP VIEW IF EXISTS v1; +CREATE TABLE t1 ( +city VARCHAR(50) NOT NULL, +country_id SMALLINT UNSIGNED NOT NULL +); +INSERT INTO t1 VALUES +('Batna',2), +('Bchar',2), +('Skikda',2), +('Tafuna',3), +('Algeria',2) ; +CREATE TABLE t2 ( +country_id SMALLINT UNSIGNED NOT NULL, +country VARCHAR(50) NOT NULL +); +INSERT INTO t2 VALUES +(2,'Algeria'), +(3,'XAmerican Samoa') ; +CREATE VIEW v1 AS +SELECT country_id, country +FROM t2 +WHERE LEFT(country,1) = "A" +; +SELECT city, country_id +FROM t1 +WHERE country_id IN ( +SELECT country_id +FROM t2 +WHERE LEFT(country,1) = "A" +); +city country_id +Algeria 2 +Batna 2 +Bchar 2 +Skikda 2 +SELECT city, country_id +FROM t1 +WHERE country_id IN ( +SELECT country_id +FROM v1 +); +city country_id +Algeria 2 +Batna 2 +Bchar 2 +Skikda 2 +PREPARE stmt FROM +" +SELECT city, country_id +FROM t1 +WHERE country_id IN ( + SELECT country_id + FROM v1 +); +"; +execute stmt; +city country_id +Algeria 2 +Batna 2 +Bchar 2 +Skikda 2 +deallocate prepare stmt; +drop table t1, t2; +drop view v1; +# End of Bug#49097 +# +# Bug#49198 Wrong result for second call of procedure +# with view in subselect. +# +CREATE TABLE t1 (t1field integer, primary key (t1field)); +CREATE TABLE t2 (t2field integer, primary key (t2field)); +CREATE TABLE t3 (t3field integer, primary key (t3field)); +CREATE VIEW v2 AS SELECT * FROM t2; +CREATE VIEW v3 AS SELECT * FROM t3; +INSERT INTO t1 VALUES(1),(2); +INSERT INTO t2 VALUES(1),(2); +INSERT INTO t3 VALUES(1),(2); +PREPARE stmt FROM +" +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT * FROM v2); +"; +EXECUTE stmt; +t1field +1 +2 + +EXECUTE stmt; +t1field +1 +2 +PREPARE stmt FROM +" +EXPLAIN +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT * FROM v2) + AND t1field IN (SELECT * FROM v3) +"; +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index PRIMARY PRIMARY 4 NULL 2 100.00 Using index +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +1 SIMPLE t3 NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`t1field` AS `t1field` from `test`.`t2` join `test`.`t3` join `test`.`t1` where ((`test`.`t2`.`t2field` = `test`.`t1`.`t1field`) and (`test`.`t3`.`t3field` = `test`.`t1`.`t1field`)) + +This line is only in place to help --skip_if_hypergraph diffing some more. + +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index PRIMARY PRIMARY 4 NULL 2 100.00 Using index +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +1 SIMPLE t3 NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`t1field` AS `t1field` from `test`.`t2` join `test`.`t3` join `test`.`t1` where ((`test`.`t2`.`t2field` = `test`.`t1`.`t1field`) and (`test`.`t3`.`t3field` = `test`.`t1`.`t1field`)) +DROP TABLE t1, t2, t3; +DROP VIEW v2, v3; +# End of Bug#49198 +# +# Bug#48623 Multiple subqueries are optimized incorrectly +# +CREATE TABLE ot(val VARCHAR(10)) charset utf8mb4; +CREATE TABLE it1(val VARCHAR(10)) charset utf8mb4; +CREATE TABLE it2(val VARCHAR(10)) charset utf8mb4; +INSERT INTO ot VALUES('aaa'), ('bbb'), ('eee'), ('mmm'), ('ppp'); +INSERT INTO it1 VALUES('aaa'), ('aaa'), ('bbb'), ('eee'), ('mmm'), ('ppp'); +INSERT INTO it2 VALUES('aaa'), ('bbb'), ('eee'), ('mmm'), ('ppp'); +EXPLAIN +SELECT * +FROM ot +WHERE ot.val IN (SELECT it1.val FROM it1 +WHERE it1.val LIKE 'a%' OR it1.val LIKE 'e%') +AND ot.val IN (SELECT it2.val FROM it2 +WHERE it2.val LIKE 'a%' OR it2.val LIKE 'e%'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using where +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 5 20.00 Using where; Using join buffer (hash join) +1 SIMPLE NULL eq_ref 43 .val 1 100.00 NULL +3 MATERIALIZED it2 NULL ALL NULL NULL NULL NULL 5 36.00 Using where +2 MATERIALIZED it1 NULL ALL NULL NULL NULL NULL 6 30.56 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`ot`.`val` AS `val` from `test`.`ot` semi join (`test`.`it1`) semi join (`test`.`it2`) where ((`test`.`ot`.`val` = ``.`val`) and (``.`val` = ``.`val`) and ((`test`.`it1`.`val` like 'a%') or (`test`.`it1`.`val` like 'e%')) and ((`test`.`it2`.`val` like 'a%') or (`test`.`it2`.`val` like 'e%'))) +SELECT * +FROM ot +WHERE ot.val IN (SELECT it1.val FROM it1 +WHERE it1.val LIKE 'a%' OR it1.val LIKE 'e%') +AND ot.val IN (SELECT it2.val FROM it2 +WHERE it2.val LIKE 'a%' OR it2.val LIKE 'e%'); +val +aaa +eee +DROP TABLE ot; +DROP TABLE it1; +DROP TABLE it2; +# End of Bug#48623 +# +# Bug #51487 Assertion failure when semi-join flattening occurs +# for a subquery in HAVING +# +CREATE TABLE t1 (a INT, b INT); +INSERT INTO t1 VALUES (1,10),(2,11),(1,13); +CREATE TABLE t2 AS SELECT * FROM t1; +CREATE TABLE t3 AS SELECT * FROM t1; +SELECT COUNT(*) FROM t1 +GROUP BY t1.a +HAVING t1.a IN (SELECT t3.a FROM t3 +WHERE t3.b IN (SELECT b FROM t2 WHERE t2.a=t1.a)); +COUNT(*) +2 +1 +DROP TABLE t1, t2, t3; +# End of Bug#51487 +# +# BUG#38075: Wrong result: rows matching a subquery with outer join not returned +# +DROP TABLE IF EXISTS ot1, it1, it2; +CREATE TABLE it2 ( +int_key int(11) NOT NULL, +datetime_key datetime NOT NULL, +KEY int_key (int_key), +KEY datetime_key (datetime_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO it2 VALUES +(5,'2002-04-10 14:25:30'), (0,'0000-00-00 00:00:00'), +(0,'2006-09-14 04:01:02'), (4,'0000-00-00 00:00:00'), +(8,'0000-00-00 00:00:00'), (5,'0000-00-00 00:00:00'), +(9,'0000-00-00 00:00:00'), (8,'2007-04-01 11:04:17'), +(1,'0000-00-00 00:00:00'), (7,'2009-01-12 00:00:00'), +(0,'2009-06-05 00:00:00'), (3,'2006-02-14 18:06:35'), +(5,'2006-02-21 07:08:16'), (0,'0000-00-00 00:00:00'), +(7,'0000-00-00 00:00:00'), (0,'0000-00-00 00:00:00'), +(0,'2007-02-13 00:00:00'), (1,'0000-00-00 00:00:00'), +(0,'0000-00-00 00:00:00'), (1,'2003-08-11 00:00:00'); +Warnings: +Warning 1264 Out of range value for column 'datetime_key' at row 2 +Warning 1264 Out of range value for column 'datetime_key' at row 4 +Warning 1264 Out of range value for column 'datetime_key' at row 5 +Warning 1264 Out of range value for column 'datetime_key' at row 6 +Warning 1264 Out of range value for column 'datetime_key' at row 7 +Warning 1264 Out of range value for column 'datetime_key' at row 9 +Warning 1264 Out of range value for column 'datetime_key' at row 14 +Warning 1264 Out of range value for column 'datetime_key' at row 15 +Warning 1264 Out of range value for column 'datetime_key' at row 16 +Warning 1264 Out of range value for column 'datetime_key' at row 18 +Warning 1264 Out of range value for column 'datetime_key' at row 19 +CREATE TABLE ot1 ( +int_nokey int(11) NOT NULL, +int_key int(11) NOT NULL, +KEY int_key (int_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO ot1 VALUES +(5,0), (3,0), (0,2), (3,0), (1,3), (0,0), (1,7), (7,0), (1,7), (0,7), +(0,9), (8,2), (4,4), (9,3), (0,9), (2,5), (0,5), (8,0), (5,8), (1,5); +CREATE TABLE it1 ( +int_nokey int(11) NOT NULL, +int_key int(11) NOT NULL, +KEY int_key (int_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO it1 VALUES +(9,5), (0,4); +SELECT int_key FROM ot1 +WHERE int_nokey IN (SELECT it2.int_key +FROM it1 LEFT JOIN it2 ON it2.datetime_key); +int_key +0 +0 +0 +0 +0 +0 +2 +2 +3 +5 +5 +7 +7 +7 +8 +9 +9 +EXPLAIN +SELECT int_key FROM ot1 +WHERE int_nokey IN (SELECT it2.int_key +FROM it1 LEFT JOIN it2 ON it2.datetime_key); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 20 10.00 Using where; Using join buffer (hash join) +2 MATERIALIZED it1 NULL index NULL int_key 4 NULL 2 100.00 Using index +2 MATERIALIZED it2 NULL ALL int_key NULL NULL NULL 20 90.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`int_key` AS `int_key` from `test`.`ot1` semi join (`test`.`it1` join `test`.`it2`) where ((`test`.`ot1`.`int_nokey` = ``.`int_key`) and (TIMESTAMP'0000-00-00 00:00:00' <> `test`.`it2`.`datetime_key`)) +DROP TABLE ot1, it1, it2; +# End of BUG#38075 +# +# BUG#50089: Second call of procedure with view in subselect crashes server +# +CREATE TABLE t1(t1field INTEGER, PRIMARY KEY(t1field)); +CREATE VIEW v1 AS +SELECT t1field AS v1field +FROM t1 a +WHERE a.t1field IN (SELECT t1field FROM t1); +INSERT INTO t1 VALUES(1),(2); +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT v1field FROM v1); +t1field +1 +2 +EXPLAIN +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT v1field FROM v1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index PRIMARY PRIMARY 4 NULL 2 100.00 Using index +1 SIMPLE a NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `t1`.`t1field` AS `t1field` from `test`.`t1` `a` join `test`.`t1` join `test`.`t1` where ((`test`.`a`.`t1field` = `t1`.`t1field`) and (`test`.`t1`.`t1field` = `t1`.`t1field`)) +SELECT t1.t1field +FROM t1 LEFT JOIN t1 AS t2 ON t1.t1field IN (SELECT v1field FROM v1); +t1field +1 +1 +2 +2 +EXPLAIN +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT v1field FROM v1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index PRIMARY PRIMARY 4 NULL 2 100.00 Using index +1 SIMPLE a NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `t1`.`t1field` AS `t1field` from `test`.`t1` `a` join `test`.`t1` join `test`.`t1` where ((`test`.`a`.`t1field` = `t1`.`t1field`) and (`test`.`t1`.`t1field` = `t1`.`t1field`)) +CREATE PROCEDURE p1() +BEGIN +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT v1field FROM v1); +END| +CALL p1; +t1field +1 +2 +CALL p1; +t1field +1 +2 +PREPARE stmt FROM +" +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT v1field FROM v1); +"; +EXECUTE stmt; +t1field +1 +2 + +EXECUTE stmt; +t1field +1 +2 +DROP PROCEDURE p1; +DROP VIEW v1; +DROP TABLE t1; +# End of BUG#50089 +# +# Bug#45191: Incorrectly initialized semi-join led to a wrong result. +# +CREATE TABLE staff (EMPNUM CHAR(3) NOT NULL, +EMPNAME CHAR(20), GRADE DECIMAL(4), CITY CHAR(15)) charset latin1; +CREATE TABLE proj (PNUM CHAR(3) NOT NULL, +PNAME CHAR(20), PTYPE CHAR(6), +BUDGET DECIMAL(9), +CITY CHAR(15)) charset latin1; +CREATE TABLE works (EMPNUM CHAR(3) NOT NULL, +PNUM CHAR(3) NOT NULL, HOURS DECIMAL(5)) charset latin1; +INSERT INTO staff VALUES ('E1','Alice',12,'Deale'); +INSERT INTO staff VALUES ('E2','Betty',10,'Vienna'); +INSERT INTO staff VALUES ('E3','Carmen',13,'Vienna'); +INSERT INTO staff VALUES ('E4','Don',12,'Deale'); +INSERT INTO staff VALUES ('E5','Ed',13,'Akron'); +INSERT INTO proj VALUES ('P1','MXSS','Design',10000,'Deale'); +INSERT INTO proj VALUES ('P2','CALM','Code',30000,'Vienna'); +INSERT INTO proj VALUES ('P3','SDP','Test',30000,'Tampa'); +INSERT INTO proj VALUES ('P4','SDP','Design',20000,'Deale'); +INSERT INTO proj VALUES ('P5','IRM','Test',10000,'Vienna'); +INSERT INTO proj VALUES ('P6','PAYR','Design',50000,'Deale'); +INSERT INTO works VALUES ('E1','P1',40); +INSERT INTO works VALUES ('E1','P2',20); +INSERT INTO works VALUES ('E1','P3',80); +INSERT INTO works VALUES ('E1','P4',20); +INSERT INTO works VALUES ('E1','P5',12); +INSERT INTO works VALUES ('E1','P6',12); +INSERT INTO works VALUES ('E2','P1',40); +INSERT INTO works VALUES ('E2','P2',80); +INSERT INTO works VALUES ('E3','P2',20); +INSERT INTO works VALUES ('E4','P2',20); +INSERT INTO works VALUES ('E4','P4',40); +INSERT INTO works VALUES ('E4','P5',80); +explain SELECT EMPNUM, EMPNAME +FROM staff +WHERE EMPNUM IN +(SELECT EMPNUM FROM works +WHERE PNUM IN +(SELECT PNUM FROM proj)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE staff NULL ALL NULL NULL NULL NULL 5 100.00 NULL +1 SIMPLE NULL eq_ref 3 test.staff.EMPNUM 1 100.00 NULL +2 MATERIALIZED proj NULL ALL NULL NULL NULL NULL 6 100.00 NULL +2 MATERIALIZED works NULL ALL NULL NULL NULL NULL 12 10.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`staff`.`EMPNUM` AS `EMPNUM`,`test`.`staff`.`EMPNAME` AS `EMPNAME` from `test`.`staff` semi join (`test`.`works` join `test`.`proj`) where ((``.`EMPNUM` = `test`.`staff`.`EMPNUM`) and (`test`.`works`.`PNUM` = `test`.`proj`.`PNUM`)) +SELECT EMPNUM, EMPNAME +FROM staff +WHERE EMPNUM IN +(SELECT EMPNUM FROM works +WHERE PNUM IN +(SELECT PNUM FROM proj)); +EMPNUM EMPNAME +E1 Alice +E2 Betty +E3 Carmen +E4 Don +drop table staff,works,proj; +# End of bug#45191 +# +# BUG#36896: Server crash on SELECT FROM DUAL +# +create table t1 (a int); +select 1 as res from dual where (1) in (select * from t1); +res +drop table t1; + +BUG#40118 Crash when running Batched Key Access and requiring one match for each key + +create table t0(a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (a int, key(a)); +insert into t1 select * from t0; +alter table t1 add b int not null, add filler char(200); +insert into t1 select * from t1; +insert into t1 select * from t1; +select * from t0 where t0.a in (select t1.a from t1 where t1.b=0); +a +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +drop table t0, t1; +# +# BUG#32665 Query with dependent subquery is too slow +# +create table t1 ( +idIndividual int primary key +); +insert into t1 values (1),(2); +create table t2 ( +idContact int primary key, +contactType int, +idObj int +); +insert into t2 values (1,1,1),(2,2,2),(3,3,3); +create table t3 ( +idAddress int primary key, +idContact int, +postalStripped varchar(100) +); +insert into t3 values (1,1, 'foo'), (2,2,'bar'); +The following must be converted to a semi-join: +explain SELECT a.idIndividual FROM t1 a +WHERE a.idIndividual IN +( SELECT c.idObj FROM t3 cona +INNER JOIN t2 c ON c.idContact=cona.idContact +WHERE cona.postalStripped='T2H3B2' + ); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using where +1 SIMPLE a NULL eq_ref PRIMARY PRIMARY 4 .idObj 1 100.00 Using index +2 MATERIALIZED cona NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 MATERIALIZED c NULL eq_ref PRIMARY PRIMARY 4 test.cona.idContact 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`a`.`idIndividual` AS `idIndividual` from `test`.`t1` `a` semi join (`test`.`t3` `cona` join `test`.`t2` `c`) where ((`test`.`c`.`idContact` = `test`.`cona`.`idContact`) and (`test`.`a`.`idIndividual` = ``.`idObj`) and (`test`.`cona`.`postalStripped` = 'T2H3B2')) +drop table t1,t2,t3; +CREATE TABLE t1 (one int, two int, flag char(1)); +CREATE TABLE t2 (one int, two int, flag char(1)); +INSERT INTO t1 VALUES(1,2,'Y'),(2,3,'Y'),(3,4,'Y'),(5,6,'N'),(7,8,'N'); +INSERT INTO t2 VALUES(1,2,'Y'),(2,3,'Y'),(3,4,'Y'),(5,6,'N'),(7,8,'N'); +SELECT * FROM t1 +WHERE ROW(one,two) IN (SELECT DISTINCT one,two FROM t2 WHERE flag = 'N'); +one two flag +5 6 N +7 8 N +SELECT * FROM t1 +WHERE ROW(one,two) IN (SELECT DISTINCT one,two FROM t1 WHERE flag = 'N'); +one two flag +5 6 N +7 8 N +insert into t2 values (null,null,'N'); +insert into t2 values (null,3,'0'); +insert into t2 values (null,5,'0'); +insert into t2 values (10,null,'0'); +insert into t1 values (10,3,'0'); +insert into t1 values (10,5,'0'); +insert into t1 values (10,10,'0'); +SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = 'N') as 'test' from t1; +one two test +1 2 NULL +2 3 NULL +3 4 NULL +5 6 1 +7 8 1 +10 3 NULL +10 5 NULL +10 10 NULL +SELECT one,two from t1 where ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = 'N'); +one two +5 6 +7 8 +SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = 'N' group by one,two) as 'test' from t1; +one two test +1 2 NULL +2 3 NULL +3 4 NULL +5 6 1 +7 8 1 +10 3 NULL +10 5 NULL +10 10 NULL +SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = '0') as 'test' from t1; +one two test +1 2 0 +2 3 NULL +3 4 0 +5 6 0 +7 8 0 +10 3 NULL +10 5 NULL +10 10 NULL +SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = '0' group by one,two) as 'test' from t1; +one two test +1 2 0 +2 3 NULL +3 4 0 +5 6 0 +7 8 0 +10 3 NULL +10 5 NULL +10 10 NULL +explain SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = '0') as 'test' from t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 9 11.11 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`one` AS `one`,`test`.`t1`.`two` AS `two`,((`test`.`t1`.`one`,`test`.`t1`.`two`),(/* select#2 */ select `test`.`t2`.`one`,`test`.`t2`.`two` from `test`.`t2` where ((`test`.`t2`.`flag` = '0') and (outer_field_is_not_null, (((`test`.`t1`.`one`) = `test`.`t2`.`one`) or (`test`.`t2`.`one` is null)), true) and (outer_field_is_not_null, (((`test`.`t1`.`two`) = `test`.`t2`.`two`) or (`test`.`t2`.`two` is null)), true)) having ((outer_field_is_not_null, (`test`.`t2`.`one`), true) and (outer_field_is_not_null, (`test`.`t2`.`two`), true)))) AS `test` from `test`.`t1` +explain SELECT one,two from t1 where ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = 'N'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 9 11.11 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`one` AS `one`,`test`.`t1`.`two` AS `two` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`two` = ``.`two`) and (`test`.`t1`.`one` = ``.`one`) and (`test`.`t2`.`flag` = 'N')) +explain SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = '0' group by one,two) as 'test' from t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 9 11.11 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`one` AS `one`,`test`.`t1`.`two` AS `two`,((`test`.`t1`.`one`,`test`.`t1`.`two`),(/* select#2 */ select `test`.`t2`.`one`,`test`.`t2`.`two` from `test`.`t2` where ((`test`.`t2`.`flag` = '0') and (outer_field_is_not_null, (((`test`.`t1`.`one`) = `test`.`t2`.`one`) or (`test`.`t2`.`one` is null)), true) and (outer_field_is_not_null, (((`test`.`t1`.`two`) = `test`.`t2`.`two`) or (`test`.`t2`.`two` is null)), true)) having ((outer_field_is_not_null, (`test`.`t2`.`one`), true) and (outer_field_is_not_null, (`test`.`t2`.`two`), true)))) AS `test` from `test`.`t1` +DROP TABLE t1,t2; +CREATE TABLE t1 (a char(5), b char(5)); +INSERT INTO t1 VALUES (NULL,'aaa'), ('aaa','aaa'); +SELECT * FROM t1 WHERE (a,b) IN (('aaa','aaa'), ('aaa','bbb')); +a b +aaa aaa +DROP TABLE t1; +CREATE TABLE t1 (a CHAR(1), b VARCHAR(10)) charset utf8mb4; +INSERT INTO t1 VALUES ('a', 'aa'); +INSERT INTO t1 VALUES ('a', 'aaa'); +SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1); +a b +CREATE INDEX I1 ON t1 (a); +CREATE INDEX I2 ON t1 (b); +EXPLAIN SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL I2 NULL NULL NULL 2 100.00 Using where +1 SIMPLE NULL eq_ref 5 test.t1.b 1 100.00 Using where +2 MATERIALIZED t1 NULL index I1 I1 5 NULL 2 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t1`) where (`test`.`t1`.`b` = ``.`a`) +SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1); +a b +CREATE TABLE t2 (a VARCHAR(1), b VARCHAR(10)) charset utf8mb4; +INSERT INTO t2 SELECT * FROM t1; +CREATE INDEX I1 ON t2 (a); +CREATE INDEX I2 ON t2 (b); +EXPLAIN SELECT a,b FROM t2 WHERE b IN (SELECT a FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL I2 NULL NULL NULL 2 100.00 Using where +1 SIMPLE NULL eq_ref 7 test.t2.b 1 100.00 Using where +2 MATERIALIZED t2 NULL index I1 I1 7 NULL 2 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t2` semi join (`test`.`t2`) where (`test`.`t2`.`b` = ``.`a`) +SELECT a,b FROM t2 WHERE b IN (SELECT a FROM t2); +a b +EXPLAIN +SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1 WHERE LENGTH(a)<500); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL I2 NULL NULL NULL 2 100.00 Using where +1 SIMPLE NULL eq_ref 5 test.t1.b 1 100.00 Using where +2 MATERIALIZED t1 NULL index I1 I1 5 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t1`) where ((length(`test`.`t1`.`a`) < 500) and (`test`.`t1`.`b` = ``.`a`)) +SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1 WHERE LENGTH(a)<500); +a b +DROP TABLE t1,t2; +# +# BUG#45928 "Differing query results depending on MRR and +# engine_condition_pushdown settings" +# +CREATE TABLE `t1` ( +`pk` int(11) NOT NULL AUTO_INCREMENT, +`time_nokey` time NOT NULL, +`varchar_key` varchar(1) NOT NULL, +`varchar_nokey` varchar(1) NOT NULL, +PRIMARY KEY (`pk`), +KEY `varchar_key` (`varchar_key`) +) AUTO_INCREMENT=12 DEFAULT CHARSET=latin1; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO `t1` VALUES (10,'00:00:00','i','i'),(11,'00:00:00','',''); +SELECT `time_nokey` G1 FROM t1 WHERE ( `varchar_nokey` , `varchar_key` ) IN ( +SELECT `varchar_nokey` , `varchar_nokey` ) AND `varchar_key` >= 'c' HAVING G1 ORDER +BY `pk` ; +G1 +DROP TABLE t1; +# +# BUG#45863 "Assertion failed: (fixed == 0), function fix_fields(), +# file item.cc, line 4448" +# +DROP TABLE IF EXISTS C, BB; +CREATE TABLE C ( +varchar_nokey varchar(1) NOT NULL +); +INSERT INTO C VALUES +('k'),('a'),(''),('u'),('e'),('v'),('i'), +('t'),('u'),('f'),('u'),('m'),('j'),('f'), +('v'),('j'),('g'),('e'),('h'),('z'); +CREATE TABLE BB ( +varchar_nokey varchar(1) NOT NULL +); +INSERT INTO BB VALUES ('i'),('t'); +SELECT varchar_nokey FROM C +WHERE (varchar_nokey, OUTR) IN (SELECT varchar_nokey +FROM BB); +ERROR 42S22: Unknown column 'OUTR' in 'IN/ALL/ANY subquery' +SELECT varchar_nokey FROM C +WHERE (varchar_nokey, OUTR) IN (SELECT varchar_nokey, varchar_nokey +FROM BB); +ERROR 42S22: Unknown column 'OUTR' in 'IN/ALL/ANY subquery' +DROP TABLE C,BB; +# +# During work with BUG#45863 I had problems with a query that was +# optimized differently in regular and prepared mode. +# Because there was a bug in one of the selected strategies, I became +# aware of the problem. Adding an EXPLAIN query to catch this. +DROP TABLE IF EXISTS t1, t2, t3; +CREATE TABLE t1 +(EMPNUM CHAR(3) NOT NULL, +EMPNAME CHAR(20), +GRADE DECIMAL(4), +CITY CHAR(15)) charset latin1; +CREATE TABLE t2 +(PNUM CHAR(3) NOT NULL, +PNAME CHAR(20), +PTYPE CHAR(6), +BUDGET DECIMAL(9), +CITY CHAR(15)) charset latin1; +CREATE TABLE t3 +(EMPNUM CHAR(3) NOT NULL, +PNUM CHAR(3) NOT NULL, +HOURS DECIMAL(5)) charset latin1; +INSERT INTO t1 VALUES ('E1','Alice',12,'Deale'); +INSERT INTO t1 VALUES ('E2','Betty',10,'Vienna'); +INSERT INTO t1 VALUES ('E3','Carmen',13,'Vienna'); +INSERT INTO t1 VALUES ('E4','Don',12,'Deale'); +INSERT INTO t1 VALUES ('E5','Ed',13,'Akron'); +INSERT INTO t2 VALUES ('P1','MXSS','Design',10000,'Deale'); +INSERT INTO t2 VALUES ('P2','CALM','Code',30000,'Vienna'); +INSERT INTO t2 VALUES ('P3','SDP','Test',30000,'Tampa'); +INSERT INTO t2 VALUES ('P4','SDP','Design',20000,'Deale'); +INSERT INTO t2 VALUES ('P5','IRM','Test',10000,'Vienna'); +INSERT INTO t2 VALUES ('P6','PAYR','Design',50000,'Deale'); +INSERT INTO t3 VALUES ('E1','P1',40); +INSERT INTO t3 VALUES ('E1','P2',20); +INSERT INTO t3 VALUES ('E1','P3',80); +INSERT INTO t3 VALUES ('E1','P4',20); +INSERT INTO t3 VALUES ('E1','P5',12); +INSERT INTO t3 VALUES ('E1','P6',12); +INSERT INTO t3 VALUES ('E2','P1',40); +INSERT INTO t3 VALUES ('E2','P2',80); +INSERT INTO t3 VALUES ('E3','P2',20); +INSERT INTO t3 VALUES ('E4','P2',20); +INSERT INTO t3 VALUES ('E4','P4',40); +INSERT INTO t3 VALUES ('E4','P5',80); +CREATE UNIQUE INDEX t1_IDX ON t1(EMPNUM); +EXPLAIN SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN +(SELECT EMPNUM +FROM t3 +WHERE PNUM IN +(SELECT PNUM +FROM t2 +WHERE PTYPE = 'Design')); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL eq_ref t1_IDX t1_IDX 3 .EMPNUM 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = ``.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) +PREPARE stmt FROM "EXPLAIN SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN + (SELECT EMPNUM + FROM t3 + WHERE PNUM IN + (SELECT PNUM + FROM t2 + WHERE PTYPE = 'Design'))"; +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL eq_ref t1_IDX t1_IDX 3 .EMPNUM 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = ``.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) + +This line is only in place to help --skip_if_hypergraph diffing some more. + +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL eq_ref t1_IDX t1_IDX 3 .EMPNUM 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = ``.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) +DEALLOCATE PREPARE stmt; +DROP INDEX t1_IDX ON t1; +CREATE INDEX t1_IDX ON t1(EMPNUM); +EXPLAIN SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN +(SELECT EMPNUM +FROM t3 +WHERE PNUM IN +(SELECT PNUM +FROM t2 +WHERE PTYPE = 'Design')); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ref t1_IDX t1_IDX 3 .EMPNUM 2 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = ``.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) +PREPARE stmt FROM "EXPLAIN SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN + (SELECT EMPNUM + FROM t3 + WHERE PNUM IN + (SELECT PNUM + FROM t2 + WHERE PTYPE = 'Design'))"; +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ref t1_IDX t1_IDX 3 .EMPNUM 2 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = ``.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) + +This line is only in place to help --skip_if_hypergraph diffing some more. + +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ref t1_IDX t1_IDX 3 .EMPNUM 2 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = ``.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) +DEALLOCATE PREPARE stmt; +DROP INDEX t1_IDX ON t1; +EXPLAIN SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN +(SELECT EMPNUM +FROM t3 +WHERE PNUM IN +(SELECT PNUM +FROM t2 +WHERE PTYPE = 'Design')); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 20.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = ``.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) +PREPARE stmt FROM "EXPLAIN SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN + (SELECT EMPNUM + FROM t3 + WHERE PNUM IN + (SELECT PNUM + FROM t2 + WHERE PTYPE = 'Design'))"; +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 20.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = ``.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) + +This line is only in place to help --skip_if_hypergraph diffing some more. + +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 20.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = ``.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) +DEALLOCATE PREPARE stmt; +DROP TABLE t1, t2, t3; +# +# BUG#45221 Query SELECT pk FROM C WHERE pk IN (SELECT int_key) failing +# +CREATE TABLE t1 ( +i1_key INT, +i2 INT, +i3 INT, +KEY i1_index (i1_key) +); +INSERT INTO t1 VALUES (9,1,2), (9,2,1); +CREATE TABLE t2 ( +pk INT NOT NULL, +i1 INT, +PRIMARY KEY (pk) +); +INSERT INTO t2 VALUES (9,1); +SELECT pk +FROM t2 +WHERE +pk IN ( +SELECT i1_key +FROM t1 +WHERE t1.i2 < t1.i3 XOR t2.i1 > 1 +ORDER BY t1.i2 desc); +pk +9 +DROP TABLE t1,t2; +# BUG#50361 Doublenested noncorrelated subquery with FirstMatch and join cache wrong result +# +CREATE TABLE t1( +id INTEGER +); +INSERT INTO t1 VALUES(10),(20); +create table t2 select * from t1; +create table t3 select * from t1; +SELECT * +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t2 +WHERE 1 IN(SELECT 1 +FROM t3)); +id +10 +20 +explain SELECT * +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t2 +WHERE 1 IN(SELECT 1 +FROM t3)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE NULL const 4 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where true +delete from t2; +delete from t3; +INSERT INTO t1 VALUES(30),(40),(50),(60),(70),(80),(90); +insert into t2 select * from t1; +insert into t3 select * from t1; +create table t4 select * from t1; +SELECT * +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t2 +WHERE 1 IN(SELECT 1 +FROM t3 +WHERE 1 IN(SELECT 1 +FROM t4))); +id +10 +20 +30 +40 +50 +60 +70 +80 +90 +explain SELECT * +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t2 +WHERE 1 IN(SELECT 1 +FROM t3 +WHERE 1 IN(SELECT 1 +FROM t4))); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 9 100.00 NULL +1 SIMPLE NULL const 4 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 9 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 9 100.00 Using join buffer (hash join) +2 MATERIALIZED t4 NULL ALL NULL NULL NULL NULL 9 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3` join `test`.`t4`) where true +SELECT * +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t1))); +id +10 +20 +30 +40 +50 +60 +70 +80 +90 +drop table t1,t2,t3,t4; +# +# Bug#53236 Segfault in DTCollation::set(DTCollation&) +# +CREATE TABLE t1 ( +pk INTEGER AUTO_INCREMENT, +col_varchar VARCHAR(1), +PRIMARY KEY (pk) +) +; +INSERT INTO t1 (col_varchar) +VALUES +('w'), +('m') +; +SELECT table1.pk +FROM ( t1 AS table1 JOIN t1 AS table2 ON (table1.col_varchar = +table2.col_varchar) ) +WHERE ( 1, 2 ) IN ( SELECT SUBQUERY1_t1.pk AS SUBQUERY1_field1, +SUBQUERY1_t1.pk AS SUBQUERY1_field2 +FROM ( t1 AS SUBQUERY1_t1 JOIN t1 AS SUBQUERY1_t2 +ON (SUBQUERY1_t2.col_varchar = +SUBQUERY1_t1.col_varchar) ) ) +; +pk +drop table t1; +# +# BUG#53298 "wrong result with semijoin (no semijoin strategy chosen)" +# +create table t1 (uid int, fid int); +insert into t1 values (1,1), (3,1); +create table t2 (uid int, name varchar(128)); +insert into t2 values (1, "A"), (2, "B"); +create table t3 (uid int, fid int, index(uid)); +insert into t3 values (1,3), (1,3); +create table t4 (uid int); +insert into t4 values (3); +explain select t2.uid from t2, t1 +where t1.uid in (select t4.uid from t4, t3 where t3.uid=1 and t4.uid=t3.fid) +and t2.uid=t1.fid; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 0.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t4 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 MATERIALIZED t3 NULL ref uid uid 5 const 1 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`uid` AS `uid` from `test`.`t2` join `test`.`t1` semi join (`test`.`t4` join `test`.`t3`) where ((`test`.`t1`.`uid` = ``.`uid`) and (`test`.`t3`.`fid` = `test`.`t4`.`uid`) and (`test`.`t3`.`uid` = 1) and (`test`.`t1`.`fid` = `test`.`t2`.`uid`)) +select t2.uid from t2, t1 +where t1.uid in (select t4.uid from t4, t3 where t3.uid=1 and t4.uid=t3.fid) +and t2.uid=t1.fid; +uid +1 +drop table t1,t2,t3,t4; +CREATE TABLE t1 ( +pk int, +a varchar(1), +b varchar(4), +c varchar(4), +d varchar(4), +PRIMARY KEY (pk) +) charset utf8mb4; +INSERT INTO t1 VALUES (1,'o','ffff','ffff','ffoo'),(2,'f','ffff','ffff','ffff'); +CREATE TABLE t2 LIKE t1; +INSERT INTO t2 VALUES (1,'i','iiii','iiii','iiii'),(2,'f','ffff','ffff','ffff'); +EXPLAIN SELECT pk FROM t1 WHERE (a) IN (SELECT a FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE NULL eq_ref 7 test.t1.a 1 100.00 NULL +2 MATERIALIZED t2 NULL range PRIMARY PRIMARY 4 NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((``.`a` = `test`.`t1`.`a`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (a) IN (SELECT a FROM t2 WHERE pk > 0); +pk +2 +SELECT pk FROM t1 WHERE (b,c,d) IN (SELECT b,c,d FROM t2 WHERE pk > 0); +pk +2 +DROP TABLE t1, t2; +CREATE TABLE t1 (f1 INT, f2 DECIMAL(5,3)) ENGINE=MyISAM; +INSERT INTO t1 (f1, f2) VALUES (1, 1.789); +INSERT INTO t1 (f1, f2) VALUES (13, 1.454); +INSERT INTO t1 (f1, f2) VALUES (10, 1.668); +CREATE TABLE t2 LIKE t1; +INSERT INTO t2 VALUES (1, 1.789); +INSERT INTO t2 VALUES (13, 1.454); +EXPLAIN SELECT COUNT(*) FROM t1 WHERE (f1,f2) IN (SELECT f1,f2 FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`f2` = ``.`f2`) and (`test`.`t1`.`f1` = ``.`f1`)) +SELECT COUNT(*) FROM t1 WHERE (f1,f2) IN (SELECT f1,f2 FROM t2); +COUNT(*) +2 +DROP TABLE t1, t2; +CREATE TABLE t1 ( +ID int(11) NOT NULL auto_increment, +Name char(35) NOT NULL default '', +Country char(3) NOT NULL default '', +Population int(11) NOT NULL default '0', +PRIMARY KEY (ID), +INDEX (Population), +INDEX (Country) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t2 ( +Code char(3) NOT NULL default '', +Name char(52) NOT NULL default '', +SurfaceArea float(10,2) NOT NULL default '0.00', +Population int(11) NOT NULL default '0', +Capital int(11) default NULL, +PRIMARY KEY (Code), +UNIQUE INDEX (Name), +INDEX (Population) +) charset utf8mb4; +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t3 ( +Country char(3) NOT NULL default '', +Language char(30) NOT NULL default '', +Percentage float(3,1) NOT NULL default '0.0', +PRIMARY KEY (Country, Language), +INDEX (Percentage) +) charset utf8mb4; +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +EXPLAIN SELECT Name FROM t2 +WHERE t2.Code IN (SELECT Country FROM t1 WHERE Population > 5000000) +AND +t2.Code IN (SELECT Country FROM t3 +WHERE Language='English' AND Percentage > 10 AND +t2.Population > 100000); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t2 NULL eq_ref PRIMARY,Population PRIMARY 12 .Country 1 75.00 Using where +1 SIMPLE t3 NULL eq_ref PRIMARY,Percentage PRIMARY 132 .Country,const 1 95.45 Using where +2 MATERIALIZED t1 NULL range Population,Country Population 4 NULL 1 100.00 Using where +Warnings: +Note 1276 Field or reference 'test.t2.Population' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t2`.`Name` AS `Name` from `test`.`t3` join `test`.`t2` semi join (`test`.`t1`) where ((`test`.`t2`.`Code` = ``.`Country`) and (`test`.`t3`.`Country` = ``.`Country`) and (`test`.`t3`.`Language` = 'English') and (`test`.`t3`.`Percentage` > 10) and (`test`.`t2`.`Population` > 100000) and (`test`.`t1`.`Population` > 5000000)) +EXPLAIN FORMAT=JSON SELECT Name FROM t2 +WHERE t2.Code IN (SELECT Country FROM t1 WHERE Population > 5000000) +AND +t2.Code IN (SELECT Country FROM t3 +WHERE Language='English' AND Percentage > 10 AND +t2.Population > 100000); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "2.52" + }, + "nested_loop": [ + { + "table": { + "table_name": "", + "access_type": "ALL", + "materialized_from_subquery": { + "using_temporary_table": true, + "query_block": { + "table": { + "table_name": "t1", + "access_type": "range", + "possible_keys": [ + "Population", + "Country" + ], + "key": "Population", + "used_key_parts": [ + "Population" + ], + "key_length": "4", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.61", + "eval_cost": "0.10", + "prefix_cost": "0.71", + "data_read_per_join": "168" + }, + "used_columns": [ + "Country", + "Population" + ], + "attached_condition": "(`test`.`t1`.`Population` > 5000000)" + } + } + } + } + }, + { + "table": { + "table_name": "t2", + "access_type": "eq_ref", + "possible_keys": [ + "PRIMARY", + "Population" + ], + "key": "PRIMARY", + "used_key_parts": [ + "Code" + ], + "key_length": "12", + "ref": [ + ".Country" + ], + "rows_examined_per_scan": 1, + "rows_produced_per_join": 0, + "filtered": "75.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.08", + "prefix_cost": "2.26", + "data_read_per_join": "180" + }, + "used_columns": [ + "Code", + "Name", + "Population" + ], + "attached_condition": "(`test`.`t2`.`Population` > 100000)" + } + }, + { + "table": { + "table_name": "t3", + "access_type": "eq_ref", + "possible_keys": [ + "PRIMARY", + "Percentage" + ], + "key": "PRIMARY", + "used_key_parts": [ + "Country", + "Language" + ], + "key_length": "132", + "ref": [ + ".Country", + "const" + ], + "rows_examined_per_scan": 1, + "rows_produced_per_join": 0, + "filtered": "95.45", + "cost_info": { + "read_cost": "0.19", + "eval_cost": "0.07", + "prefix_cost": "2.52", + "data_read_per_join": "103" + }, + "used_columns": [ + "Country", + "Language", + "Percentage" + ], + "attached_condition": "((`test`.`t3`.`Language` = 'English') and (`test`.`t3`.`Percentage` > 10))" + } + } + ] + } +} +Warnings: +Note 1276 Field or reference 'test.t2.Population' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t2`.`Name` AS `Name` from `test`.`t3` join `test`.`t2` semi join (`test`.`t1`) where ((`test`.`t2`.`Code` = ``.`Country`) and (`test`.`t3`.`Country` = ``.`Country`) and (`test`.`t3`.`Language` = 'English') and (`test`.`t3`.`Percentage` > 10) and (`test`.`t2`.`Population` > 100000) and (`test`.`t1`.`Population` > 5000000)) +DROP TABLE t1,t2,t3; +CREATE TABLE t1 ( +Code char(3) NOT NULL DEFAULT '', +Name char(52) NOT NULL DEFAULT '', +Continent enum('Asia','Europe','North America','Africa','Oceania','Antarctica','South America') NOT NULL DEFAULT 'Asia', +Region char(26) NOT NULL DEFAULT '', +SurfaceArea float(10,2) NOT NULL DEFAULT '0.00', +IndepYear smallint(6) DEFAULT NULL, +Population int(11) NOT NULL DEFAULT '0', +LifeExpectancy float(3,1) DEFAULT NULL, +GNP float(10,2) DEFAULT NULL, +GNPOld float(10,2) DEFAULT NULL, +LocalName char(45) NOT NULL DEFAULT '', +GovernmentForm char(45) NOT NULL DEFAULT '', +HeadOfState char(60) DEFAULT NULL, +Capital int(11) DEFAULT NULL, +Code2 char(2) NOT NULL DEFAULT '', +PRIMARY KEY (Code) +) charset utf8mb4; +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t2 ( +ID int(11) NOT NULL AUTO_INCREMENT, +Name char(35) NOT NULL DEFAULT '', +CountryCode char(3) NOT NULL DEFAULT '', +District char(20) NOT NULL DEFAULT '', +Population int(11) NOT NULL DEFAULT '0', +PRIMARY KEY (ID), +KEY CountryCode (CountryCode) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +set names latin1; +Fill the table with test data +This must not use LooseScan: +EXPLAIN SELECT Name FROM t1 +WHERE t1.Code IN ( +SELECT t2.CountryCode FROM t2 WHERE Population > 5000000); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL PRIMARY NULL NULL NULL 31 100.00 NULL +1 SIMPLE NULL eq_ref 12 test.t1.Code 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL CountryCode NULL NULL NULL 545 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`Name` AS `Name` from `test`.`t1` semi join (`test`.`t2`) where ((``.`CountryCode` = `test`.`t1`.`Code`) and (`test`.`t2`.`Population` > 5000000)) +SELECT Name FROM t1 +WHERE t1.Code IN ( +SELECT t2.CountryCode FROM t2 WHERE Population > 5000000); +Name +Austria +Canada +China +Czech Republic +drop table t1, t2; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4); +create table t1 (a int, b int, key(a)); +insert into t1 select a,a from t0; +create table t2 (a int, b int, primary key(a)); +insert into t2 select * from t1; +Table t2, unlike table t1, should be displayed as pulled out +explain select * from t0 +where t0.a in ( select t1.a from t1,t2 where t2.a=t0.a and +t1.b=t2.b); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL a NULL NULL NULL 5 100.00 Using where; Start temporary +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 20.00 Using where +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 5 20.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t0.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a` from `test`.`t2` join `test`.`t0` semi join (`test`.`t1`) where ((`test`.`t2`.`a` = `test`.`t1`.`a`) and (`test`.`t0`.`a` = `test`.`t1`.`a`) and (`test`.`t2`.`b` = `test`.`t1`.`b`)) +update t1 set a=3, b=11 where a=4; +update t2 set b=11 where a=3; +select * from t0 where t0.a in (select t1.a from t1, t2 where t2.a=t0.a and t1.b=t2.b); +a +0 +1 +2 +3 +drop table t0, t1, t2; +CREATE TABLE t1 ( +id int(11) NOT NULL, +PRIMARY KEY (id)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t2 ( +id int(11) NOT NULL, +fid int(11) NOT NULL, +PRIMARY KEY (id)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t1 values(1); +insert into t2 values(1,7503),(2,1); +explain select count(*) +from t1 +where fid IN (select fid from t2 where (id between 7502 and 8420) order by fid ); +ERROR 42S22: Unknown column 'fid' in 'IN/ALL/ANY subquery' +drop table t1, t2; +create table t1 (a int, b int, key (a), key (b)); +insert into t1 values (2,4),(2,4),(2,4); +select t1.a from t1 +where +t1.a in (select 1 from t1 where t1.a in (select 1 from t1) group by t1.a); +a +drop table t1; +create table t1(a int,b int,key(a),key(b)); +insert into t1 values (1,1),(2,2),(3,3); +select 1 from t1 +where t1.a not in (select 1 from t1 +where t1.a in (select 1 from t1) +group by t1.b); +1 +1 +1 +drop table t1; +CREATE TABLE t1 +(EMPNUM CHAR(3) NOT NULL, +EMPNAME CHAR(20), +GRADE DECIMAL(4), +CITY CHAR(15)); +CREATE TABLE t2 +(PNUM CHAR(3) NOT NULL, +PNAME CHAR(20), +PTYPE CHAR(6), +BUDGET DECIMAL(9), +CITY CHAR(15)); +CREATE TABLE t3 +(EMPNUM CHAR(3) NOT NULL, +PNUM CHAR(3) NOT NULL, +HOURS DECIMAL(5)); +INSERT INTO t1 VALUES ('E1','Alice',12,'Deale'); +INSERT INTO t1 VALUES ('E2','Betty',10,'Vienna'); +INSERT INTO t1 VALUES ('E3','Carmen',13,'Vienna'); +INSERT INTO t1 VALUES ('E4','Don',12,'Deale'); +INSERT INTO t1 VALUES ('E5','Ed',13,'Akron'); +INSERT INTO t2 VALUES ('P1','MXSS','Design',10000,'Deale'); +INSERT INTO t2 VALUES ('P2','CALM','Code',30000,'Vienna'); +INSERT INTO t2 VALUES ('P3','SDP','Test',30000,'Tampa'); +INSERT INTO t2 VALUES ('P4','SDP','Design',20000,'Deale'); +INSERT INTO t2 VALUES ('P5','IRM','Test',10000,'Vienna'); +INSERT INTO t2 VALUES ('P6','PAYR','Design',50000,'Deale'); +INSERT INTO t3 VALUES ('E1','P1',40); +INSERT INTO t3 VALUES ('E1','P2',20); +INSERT INTO t3 VALUES ('E1','P3',80); +INSERT INTO t3 VALUES ('E1','P4',20); +INSERT INTO t3 VALUES ('E1','P5',12); +INSERT INTO t3 VALUES ('E1','P6',12); +INSERT INTO t3 VALUES ('E2','P1',40); +INSERT INTO t3 VALUES ('E2','P2',80); +INSERT INTO t3 VALUES ('E3','P2',20); +INSERT INTO t3 VALUES ('E4','P2',20); +INSERT INTO t3 VALUES ('E4','P4',40); +INSERT INTO t3 VALUES ('E4','P5',80); +SELECT * FROM t1; +EMPNUM EMPNAME GRADE CITY +E1 Alice 12 Deale +E2 Betty 10 Vienna +E3 Carmen 13 Vienna +E4 Don 12 Deale +E5 Ed 13 Akron +CREATE UNIQUE INDEX t1_IDX ON t1(EMPNUM); +SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN +(SELECT EMPNUM +FROM t3 +WHERE PNUM IN +(SELECT PNUM +FROM t2 +WHERE PTYPE = 'Design')); +EMPNAME +Alice +Betty +Don +DROP INDEX t1_IDX ON t1; +CREATE INDEX t1_IDX ON t1(EMPNUM); +SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN +(SELECT EMPNUM +FROM t3 +WHERE PNUM IN +(SELECT PNUM +FROM t2 +WHERE PTYPE = 'Design')); +EMPNAME +Alice +Betty +Don +DROP INDEX t1_IDX ON t1; +SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN +(SELECT EMPNUM +FROM t3 +WHERE PNUM IN +(SELECT PNUM +FROM t2 +WHERE PTYPE = 'Design')); +EMPNAME +Alice +Betty +Don +DROP TABLE t1, t2, t3; +CREATE TABLE t1 (f1 INT NOT NULL); +CREATE VIEW v1 (a) AS SELECT f1 IN (SELECT f1 FROM t1) FROM t1; +SELECT * FROM v1; +a +drop view v1; +drop table t1; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1(a int, b int); +insert into t1 values (0,0),(1,1),(2,2); +create table t2 as select * from t1; +create table t3 (pk int, a int, primary key(pk)); +insert into t3 select a,a from t0; +explain +select * from t1 left join t2 on (t2.a= t1.a and t2.a in (select pk from t3)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE t3 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using index +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` left join (`test`.`t3` join `test`.`t2`) on(((`test`.`t3`.`pk` = `test`.`t1`.`a`) and (`test`.`t2`.`a` = `test`.`t1`.`a`))) where true +drop table t0, t1, t2, t3; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (a int) as select A.a + 10 *(B.a + 10*C.a) as a from t0 A, t0 B, t0 C; +create table t2 (id int, a int, primary key(id), key(a)) charset utf8mb4 as select a as id, a as a from t1; +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `id` int NOT NULL, + `a` int DEFAULT NULL, + PRIMARY KEY (`id`), + KEY `a` (`a`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +set @a=0; +create table t3 as select * from t2 limit 0; +insert into t3 select @a:=@a+1, t2.a from t2, t0; +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +insert into t3 select @a:=@a+1, t2.a from t2, t0; +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +insert into t3 select @a:=@a+1, t2.a from t2, t0; +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +alter table t3 add primary key(id), add 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); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index a a 5 NULL 1000 100.00 Using where; Using index +1 SIMPLE NULL eq_ref 5 test.t2.a 1 100.00 NULL +2 MATERIALIZED t3 NULL index a a 5 NULL 30000 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select count(`test`.`t2`.`a`) AS `count(a)` from `test`.`t2` semi join (`test`.`t3`) where (``.`a` = `test`.`t2`.`a`) +select count(a) from t2 where a in ( SELECT a FROM t3); +count(a) +1000 +drop table t0,t1,t2,t3; +# +# Bug#33062: subquery in stored routine cause crash +# +CREATE TABLE t1(a INT); +CREATE TABLE t2(c INT); +CREATE PROCEDURE p1(v1 int) +BEGIN +SELECT 1 FROM t1 WHERE a = v1 AND a IN (SELECT c FROM t2); +END +// +CREATE PROCEDURE p2(v1 int) +BEGIN +SELECT 1 FROM t1 WHERE a IN (SELECT c FROM t2); +END +// +CREATE PROCEDURE p3(v1 int) +BEGIN +SELECT 1 +FROM +t1 t01,t1 t02,t1 t03,t1 t04,t1 t05,t1 t06,t1 t07,t1 t08, +t1 t09,t1 t10,t1 t11,t1 t12,t1 t13,t1 t14,t1 t15,t1 t16, +t1 t17,t1 t18,t1 t19,t1 t20,t1 t21,t1 t22,t1 t23,t1 t24, +t1 t25,t1 t26,t1 t27,t1 t28,t1 t29,t1 t30,t1 t31,t1 t32, +t1 t33,t1 t34,t1 t35,t1 t36,t1 t37,t1 t38,t1 t39,t1 t40, +t1 t41,t1 t42,t1 t43,t1 t44,t1 t45,t1 t46,t1 t47,t1 t48, +t1 t49,t1 t50,t1 t51,t1 t52,t1 t53,t1 t54,t1 t55,t1 t56, +t1 t57,t1 t58,t1 t59,t1 t60 +WHERE t01.a IN (SELECT c FROM t2); +END +// +CREATE PROCEDURE p4(v1 int) +BEGIN +SELECT 1 +FROM +t1 t01,t1 t02,t1 t03,t1 t04,t1 t05,t1 t06,t1 t07,t1 t08, +t1 t09,t1 t10,t1 t11,t1 t12,t1 t13,t1 t14,t1 t15,t1 t16, +t1 t17,t1 t18,t1 t19,t1 t20,t1 t21,t1 t22,t1 t23,t1 t24, +t1 t25,t1 t26,t1 t27,t1 t28,t1 t29,t1 t30,t1 t31,t1 t32, +t1 t33,t1 t34,t1 t35,t1 t36,t1 t37,t1 t38,t1 t39,t1 t40, +t1 t41,t1 t42,t1 t43,t1 t44,t1 t45,t1 t46,t1 t47,t1 t48, +t1 t49,t1 t50,t1 t51,t1 t52,t1 t53,t1 t54,t1 t55,t1 t56, +t1 t57,t1 t58,t1 t59,t1 t60 +WHERE t01.a = v1 AND t01.a IN (SELECT c FROM t2); +END +// +CALL p1(1); +1 +CALL p2(1); +1 +CALL p3(1); +1 +CALL p4(1); +1 +DROP TABLE t1, t2; +DROP PROCEDURE p1; +DROP PROCEDURE p2; +DROP PROCEDURE p3; +DROP PROCEDURE p4; +# +# Bug#48213 Materialized subselect crashes if using GEOMETRY type +# +CREATE TABLE t1 ( +pk int, +a varchar(1), +b varchar(4), +c tinyblob, +d blob, +e mediumblob, +f longblob, +g tinytext, +h text, +i mediumtext, +j longtext, +k geometry, +PRIMARY KEY (pk) +) charset utf8mb4; +INSERT INTO t1 VALUES (1,'o','ffff','ffff','ffoo','ffff','ffff','ffff','ffff','ffff','ffff',ST_GeomFromText('POLYGON((0 0, 0 2, 2 2, 2 0, 0 0))')), (2,'f','ffff','ffff','ffff', 'ffff','ffff','ffff','ffff','ffff','ffff',ST_GeomFromText('POLYGON((0 0, 0 2, 2 2, 2 0, 0 0))')); +CREATE TABLE t2 LIKE t1; +INSERT INTO t2 VALUES (1,'i','iiii','iiii','iiii','iiii','ffff','ffff','ffff','ffff','ffff',ST_GeomFromText('POLYGON((0 0, 0 2, 2 2, 2 0, 0 0))')), (2,'f','ffff','ffff','ffff','ffff','ffff','ffff','ffff','ffff','ffff',ST_GeomFromText('POLYGON((0 0, 0 2, 2 2, 2 0, 0 0))')); +EXPLAIN SELECT pk FROM t1 WHERE (a, b) IN (SELECT a, b FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE NULL eq_ref 26 test.t1.a,test.t1.b 1 100.00 NULL +2 MATERIALIZED t2 NULL range PRIMARY PRIMARY 4 NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((``.`b` = `test`.`t1`.`b`) and (``.`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); +pk +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, c) IN (SELECT b, c FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t2 NULL range PRIMARY PRIMARY 4 NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((``.`c` = `test`.`t1`.`c`) and (``.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, c) IN (SELECT b, c FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, d) IN (SELECT b, d FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t2 NULL range PRIMARY PRIMARY 4 NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((``.`d` = `test`.`t1`.`d`) and (``.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, d) IN (SELECT b, d FROM t2 WHERE pk > 0); +pk +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, e) IN (SELECT b, e FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t2 NULL range PRIMARY PRIMARY 4 NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((``.`e` = `test`.`t1`.`e`) and (``.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, e) IN (SELECT b, e FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, f) IN (SELECT b, f FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t2 NULL range PRIMARY PRIMARY 4 NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((``.`f` = `test`.`t1`.`f`) and (``.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, f) IN (SELECT b, f FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, g) IN (SELECT b, g FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t2 NULL range PRIMARY PRIMARY 4 NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((``.`g` = `test`.`t1`.`g`) and (``.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, g) IN (SELECT b, g FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, h) IN (SELECT b, h FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t2 NULL range PRIMARY PRIMARY 4 NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((``.`h` = `test`.`t1`.`h`) and (``.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, h) IN (SELECT b, h FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, i) IN (SELECT b, i FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t2 NULL range PRIMARY PRIMARY 4 NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((``.`i` = `test`.`t1`.`i`) and (``.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, i) IN (SELECT b, i FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, j) IN (SELECT b, j FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t2 NULL range PRIMARY PRIMARY 4 NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((``.`j` = `test`.`t1`.`j`) and (``.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, j) IN (SELECT b, j FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, k) IN (SELECT b, k FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t2 NULL range PRIMARY PRIMARY 4 NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((``.`k` = `test`.`t1`.`k`) and (``.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, k) IN (SELECT b, k FROM t2 WHERE pk > 0); +pk +1 +2 +DROP TABLE t1, t2; +# End of Bug#48213 +# +# BUG#53060: LooseScan semijoin strategy does not return all rows +# +CREATE TABLE t1 (i INTEGER); +INSERT INTO t1 VALUES (1), (2), (3), (4), (5); +CREATE TABLE t2 (i INTEGER, j INTEGER, KEY k(i, j)); +INSERT INTO t2 VALUES (1, 0), (1, 1), (2, 0), (2, 1); +EXPLAIN +SELECT * FROM t1 WHERE (i) IN (SELECT i FROM t2 where j > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 20.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t2 NULL index k k 10 NULL 4 33.33 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`i` = ``.`i`) and (`test`.`t2`.`j` > 0)) +SELECT * FROM t1 WHERE (i) IN (SELECT i FROM t2 where j > 0); +i +1 +2 +DROP TABLE t1, t2; +# End of BUG#53060 +# +# Bug#53305 "Duplicate weedout + join buffer (join cache --level=7,8) loses rows" +# +create table t1 (uid int, fid int, index(uid)); +insert into t1 values +(1,1), (1,2), (1,3), (1,4), +(2,5), (2,6), (2,7), (2,8), +(3,1), (3,2), (3,9); +create table t2 (uid int primary key, name varchar(128), index(name)); +insert into t2 values +(1, "A"), (2, "B"), (3, "C"), (4, "D"), (5, "E"), +(6, "F"), (7, "G"), (8, "H"), (9, "I"); +create table t3 (uid int, fid int, index(uid)); +insert into t3 values +(1,1), (1,2), (1,3),(1,4), +(2,5), (2,6), (2,7), (2,8), +(3,1), (3,2), (3,9); +create table t4 (uid int primary key, name varchar(128), index(name)); +insert into t4 values +(1, "A"), (2, "B"), (3, "C"), (4, "D"), (5, "E"), +(6, "F"), (7, "G"), (8, "H"), (9, "I"); +explain select name from t2, t1 +where t1.uid in (select t4.uid from t4, t3 where t3.uid=1 and t4.uid=t3.fid) +and t2.uid=t1.fid; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ref uid uid 5 const 4 100.00 Using where; Start temporary +1 SIMPLE t4 NULL eq_ref PRIMARY PRIMARY 4 test.t3.fid 1 100.00 Using index +1 SIMPLE t1 NULL ref uid uid 5 test.t3.fid 2 100.00 Using where; End temporary +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.fid 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`name` AS `name` from `test`.`t4` join `test`.`t2` join `test`.`t1` semi join (`test`.`t3`) where ((`test`.`t4`.`uid` = `test`.`t3`.`fid`) and (`test`.`t1`.`uid` = `test`.`t3`.`fid`) and (`test`.`t3`.`uid` = 1) and (`test`.`t2`.`uid` = `test`.`t1`.`fid`)) +select name from t2, t1 +where t1.uid in (select t4.uid from t4, t3 where t3.uid=1 and t4.uid=t3.fid) +and t2.uid=t1.fid; +name +A +A +B +B +C +D +E +F +G +H +I +drop table t1,t2,t3,t4; +# +# Bug#43768 Prepared query with nested subqueries core dump on second execution +# +CREATE TABLE t1 ( +id INT PRIMARY KEY, +partner_id VARCHAR(35) +) charset utf8mb4; +INSERT INTO t1 VALUES +(1, 'partner1'), (2, 'partner2'), +(3, 'partner3'), (4, 'partner4'); +CREATE TABLE t2 ( +id INT NOT NULL, +t1_line_id INT, +article_id VARCHAR(20), +PRIMARY KEY(id, t1_line_id) +) charset utf8mb4; +INSERT INTO t2 VALUES +(1, 1, 'sup'), (2, 1, 'sup'), +(2, 2, 'sup'), (2, 3, 'sup'), +(2, 4, 'imp'), (3, 1, 'sup'), +(4, 1, 'sup'); +CREATE TABLE t3 ( +user_id VARCHAR(50), +article_id VARCHAR(20) NOT NULL, +PRIMARY KEY(user_id) +) charset utf8mb4; +INSERT INTO t3 VALUES('nicke', 'imp'); +EXPLAIN +SELECT t1.partner_id +FROM t1 +WHERE t1.id IN ( +SELECT t2.id +FROM t2 +WHERE article_id IN ( +SELECT article_id FROM t3 +WHERE user_id = 'nicke' + ) +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL system PRIMARY NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL PRIMARY NULL NULL NULL 7 14.29 Using where; Start temporary +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.id 1 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`partner_id` AS `partner_id` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`id` = `test`.`t2`.`id`) and (`test`.`t2`.`article_id` = 'imp')) +SELECT t1.partner_id +FROM t1 +WHERE t1.id IN ( +SELECT t2.id +FROM t2 +WHERE article_id IN ( +SELECT article_id FROM t3 +WHERE user_id = 'nicke' + ) +); +partner_id +partner2 +PREPARE stmt FROM +'EXPLAIN SELECT t1.partner_id +FROM t1 +WHERE t1.id IN ( + SELECT t2.id + FROM t2 + WHERE article_id IN ( + SELECT article_id FROM t3 + WHERE user_id = \'nicke\' + ) + )'; +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL system PRIMARY NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL PRIMARY NULL NULL NULL 7 14.29 Using where; Start temporary +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.id 1 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`partner_id` AS `partner_id` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`id` = `test`.`t2`.`id`) and (`test`.`t2`.`article_id` = 'imp')) + +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL system PRIMARY NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL PRIMARY NULL NULL NULL 7 14.29 Using where; Start temporary +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.id 1 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`partner_id` AS `partner_id` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`id` = `test`.`t2`.`id`) and (`test`.`t2`.`article_id` = 'imp')) +PREPARE stmt FROM +'SELECT t1.partner_id +FROM t1 +WHERE t1.id IN ( + SELECT t2.id + FROM t2 + WHERE article_id IN ( + SELECT article_id FROM t3 + WHERE user_id = \'nicke\' + ) + )'; +EXECUTE stmt; +partner_id +partner2 + +EXECUTE stmt; +partner_id +partner2 +DROP TABLE t1,t2,t3; +# End of Bug#43768 +# +# Bug#53058 - semijoin execution of subquery with outerjoin yields wrong result +# +CREATE TABLE t1 (i INTEGER); +CREATE TABLE t2 (i INTEGER); +CREATE TABLE t3 (i INTEGER); +INSERT INTO t1 VALUES (1), (2); +INSERT INTO t2 VALUES (6); +INSERT INTO t3 VALUES (1), (2); +explain SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t3 LEFT JOIN t2 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t3 LEFT JOIN t2 ON t2.i=t3.i); +i +1 +2 +drop table t1,t2,t3; +# +# BUG#49453: re-execution of prepared statement with view +# and semijoin crashes +# +CREATE TABLE t1 (city VARCHAR(50), country_id INT); +CREATE TABLE t2 (country_id INT, country VARCHAR(50)); +INSERT INTO t1 VALUES +('Batna',2),('Bchar',2),('Skikda',2),('Tafuna',3),('Algeria',2) ; +INSERT INTO t2 VALUES (2,'Algeria'),(2,'AlgeriaDup'),(3,'XAmerican Samoa'); +CREATE VIEW v1 AS +SELECT country_id as vf_country_id +FROM t2 +WHERE LEFT(country,1) = "A"; +PREPARE stmt FROM " +SELECT city, country_id +FROM t1 +WHERE country_id IN (SELECT vf_country_id FROM v1); +"; + +EXECUTE stmt; +city country_id +Algeria 2 +Batna 2 +Bchar 2 +Skikda 2 + +EXECUTE stmt; +city country_id +Algeria 2 +Batna 2 +Bchar 2 +Skikda 2 +DROP TABLE t1,t2; +DROP VIEW v1; +# +# Bug#54437 Extra rows with LEFT JOIN + semijoin (firstmatch +# and duplicates weedout) +# +create table t1 (a int); +create table t2 (a int); +create table t3 (a int); +insert into t1 values(1),(1); +insert into t2 values(1),(1),(1),(1); +insert into t3 values(2),(2); +explain select * from t1 where t1.a in (select t2.a from t2 left join t3 on t2.a=t3.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE NULL eq_ref 5 test.t1.a 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t2` left join `test`.`t3` on((`test`.`t2`.`a` = `test`.`t3`.`a`))) where (``.`a` = `test`.`t1`.`a`) +select * from t1 where t1.a in (select t2.a from t2 left join t3 on t2.a=t3.a); +a +1 +1 +drop table t1,t2,t3; +# +# Bug#55955: crash in MEMORY engine with IN(LEFT JOIN (JOIN)) +# +CREATE TABLE t1 (a INT); +CREATE TABLE t2 (a INT); +CREATE TABLE t3 (a INT); +INSERT INTO t1 VALUES(1),(1); +INSERT INTO t2 VALUES(1),(1); +INSERT INTO t3 VALUES(2),(2); +explain SELECT * FROM t1 +WHERE t1.a IN (SELECT t2.a +FROM t2 LEFT JOIN (t2 AS t2inner, t3) ON t2.a=t3.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE NULL eq_ref 5 test.t1.a 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t2inner NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t2` left join (`test`.`t2` `t2inner` join `test`.`t3`) on((`test`.`t2`.`a` = `test`.`t3`.`a`))) where (``.`a` = `test`.`t1`.`a`) +SELECT * FROM t1 +WHERE t1.a IN (SELECT t2.a +FROM t2 LEFT JOIN (t2 AS t2inner, t3) ON t2.a=t3.a); +a +1 +1 +DROP TABLE t1,t2,t3; +# +# BUG#52329 - Wrong result: subquery materialization, IN, +# non-null field followed by nullable +# +CREATE TABLE t1 (a1 CHAR(8) NOT NULL, a2 char(8) NOT NULL); +CREATE TABLE t2a (b1 char(8), b2 char(8)); +CREATE TABLE t2b (b1 CHAR(8), b2 char(8) NOT NULL); +CREATE TABLE t2c (b1 CHAR(8) NOT NULL, b2 char(8)); +INSERT INTO t1 VALUES ('1 - 12', '2 - 22'); +INSERT INTO t2a VALUES ('1 - 11', '2 - 21'), +('1 - 11', '2 - 21'), +('1 - 12', '2 - 22'), +('1 - 12', '2 - 22'), +('1 - 13', '2 - 23'); +INSERT INTO t2b SELECT * FROM t2a; +INSERT INTO t2c SELECT * FROM t2a; +SELECT * FROM t1 +WHERE (a1, a2) IN ( +SELECT b1, b2 FROM t2c WHERE b1 > '0' GROUP BY b1, b2); +a1 a2 +1 - 12 2 - 22 +SELECT * FROM t1 +WHERE (a1, a2) IN ( +SELECT b1, b2 FROM t2a WHERE b1 > '0'); +a1 a2 +1 - 12 2 - 22 +SELECT * FROM t1 +WHERE (a1, a2) IN ( +SELECT b1, b2 FROM t2b WHERE b1 > '0'); +a1 a2 +1 - 12 2 - 22 +SELECT * FROM t1 +WHERE (a1, a2) IN ( +SELECT b1, b2 FROM t2c WHERE b1 > '0'); +a1 a2 +1 - 12 2 - 22 +DROP TABLE t1,t2a,t2b,t2c; +# End BUG#52329 +# +# Bug#45174: Incorrectly applied equality propagation caused wrong +# result on a query with a materialized semi-join. +# +CREATE TABLE t1 ( +varchar_nokey varchar(1) NOT NULL +) charset utf8mb4; +INSERT INTO t1 VALUES +('v'), ('u'), ('n'), ('l'), ('h'), ('u'), ('n'), ('j'), ('k'), +('e'), ('i'), ('u'), ('n'), ('b'), ('x'), (''), ('q'), ('u'); +CREATE TABLE t2 ( +pk int NOT NULL, +varchar_key varchar(1) NOT NULL, +varchar_nokey varchar(1) NOT NULL, +PRIMARY KEY(pk), +KEY varchar_key(varchar_key) +) charset utf8mb4; +INSERT INTO t2 VALUES +(11,'m','m'), (12,'j','j'), (13,'z','z'), (14,'a','a'), (15,'',''), +(16,'e','e'), (17,'t','t'), (19,'b','b'), (20,'w','w'), (21,'m','m'), +(23,'',''), (24,'w','w'), (26,'e','e'), (27,'e','e'), (28,'p','p'); +SELECT varchar_nokey +FROM t1 +WHERE (varchar_nokey, varchar_nokey) IN (SELECT varchar_key, varchar_nokey +FROM t2 +WHERE varchar_nokey < 'n' XOR pk); +varchar_nokey +explain SELECT varchar_nokey +FROM t1 +WHERE (varchar_nokey, varchar_nokey) IN (SELECT varchar_key, varchar_nokey +FROM t2 +WHERE varchar_nokey < 'n' XOR pk); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 18 100.00 NULL +1 SIMPLE NULL eq_ref 12 test.t1.varchar_nokey,test.t1.varchar_nokey 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL varchar_key NULL NULL NULL 15 63.34 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`varchar_nokey` AS `varchar_nokey` from `test`.`t1` semi join (`test`.`t2`) where ((``.`varchar_key` = `test`.`t1`.`varchar_nokey`) and (``.`varchar_nokey` = `test`.`t1`.`varchar_nokey`) and (`test`.`t2`.`varchar_nokey` = `test`.`t2`.`varchar_key`) and ((`test`.`t2`.`varchar_nokey` < 'n') xor (0 <> `test`.`t2`.`pk`))) +DROP TABLE t1, t2; +# End of the test for bug#45174. +# +# Bug#50019: Wrong result for IN-query with materialization +# +CREATE TABLE t1(i INT); +INSERT INTO t1 VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10); +CREATE TABLE t2(i INT); +INSERT INTO t2 VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10); +CREATE TABLE t3(i INT); +INSERT INTO t3 VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10); +SELECT * FROM t1 WHERE t1.i IN (SELECT t2.i +FROM t2 JOIN t3 +WHERE t2.i + t3.i = 5); +i +1 +2 +3 +4 +explain SELECT * FROM t1 WHERE t1.i IN (SELECT t2.i +FROM t2 JOIN t3 +WHERE t2.i + t3.i = 5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 100.00 Using where +1 SIMPLE NULL eq_ref 5 test.t1.i 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 10 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 10 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = `test`.`t1`.`i`) and ((`test`.`t2`.`i` + `test`.`t3`.`i`) = 5)) +DROP TABLE t1,t2,t3; +# End of the test for bug#50019. +# +# Bug#52068: Optimizer generates invalid semijoin materialization plan +# +CREATE TABLE ot1(a INTEGER); +INSERT INTO ot1 VALUES(5), (8); +CREATE TABLE it2(a INTEGER); +INSERT INTO it2 VALUES(9), (5), (1), (8); +CREATE TABLE it3(a INTEGER); +INSERT INTO it3 VALUES(7), (1), (0), (5), (1), (4); +CREATE TABLE ot4(a INTEGER); +INSERT INTO ot4 VALUES(1), (3), (5), (7), (9), (7), (3), (1); +SELECT * FROM ot1,ot4 +WHERE (ot1.a,ot4.a) IN (SELECT it2.a,it3.a +FROM it2,it3); +a a +5 1 +5 1 +5 5 +5 7 +5 7 +8 1 +8 1 +8 5 +8 7 +8 7 +explain SELECT * FROM ot1,ot4 +WHERE (ot1.a,ot4.a) IN (SELECT it2.a,it3.a +FROM it2,it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using where; Using join buffer (hash join) +1 SIMPLE ot4 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; Using join buffer (hash join) +2 MATERIALIZED it2 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +2 MATERIALIZED it3 NULL ALL NULL NULL NULL NULL 6 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot4`.`a` AS `a` from `test`.`ot1` join `test`.`ot4` semi join (`test`.`it2` join `test`.`it3`) where ((`test`.`ot4`.`a` = ``.`a`) and (``.`a` = `test`.`ot1`.`a`)) +DROP TABLE IF EXISTS ot1, ot4, it2, it3; +# End of the test for bug#52068. +# +# Bug#57623: subquery within before insert trigger causes crash (sj=on) +# +CREATE TABLE ot1(a INT); +CREATE TABLE ot2(a INT); +CREATE TABLE ot3(a INT); +CREATE TABLE it1(a INT); +INSERT INTO ot1 VALUES(0),(1),(2),(3),(4),(5),(6),(7); +INSERT INTO ot2 VALUES(0),(2),(4),(6); +INSERT INTO ot3 VALUES(0),(3),(6); +INSERT INTO it1 VALUES(0),(1),(2),(3),(4),(5),(6),(7); +explain SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 on ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a from it1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +1 SIMPLE NULL eq_ref 5 test.ot1.a 1 100.00 NULL +1 SIMPLE ot3 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +2 MATERIALIZED it1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a`,`test`.`ot3`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` join `test`.`ot3` semi join (`test`.`it1`)) on(((``.`a` = `test`.`ot1`.`a`) and (`test`.`ot3`.`a` = `test`.`ot1`.`a`) and (`test`.`ot2`.`a` = `test`.`ot1`.`a`))) where true +SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 on ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a from it1); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +prepare s from 'SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 on ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a from it1)'; +execute s; +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +execute s; +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +deallocate prepare s; +DROP TABLE ot1, ot2, ot3, it1; +# End of the test for bug#57623. +# +# Bug#11766739: Crash in tmp_table_param::init() with semijoin=on +# +CREATE TABLE t1 (f1 INTEGER) ENGINE=MyISAM; +CREATE TABLE t2 (f1 INTEGER, f2 INTEGER) ENGINE=MyISAM; +INSERT INTO t1 VALUES (1); +INSERT INTO t2 VALUES (1,1), (2,1); +EXPLAIN SELECT * FROM t2 +WHERE f2 IN (SELECT t1.f1 +FROM t1 LEFT OUTER JOIN (t2 AS b1 JOIN t2 AS b2 ON TRUE) ON TRUE); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 MATERIALIZED b1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +2 MATERIALIZED b2 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`f1` AS `f1`,`test`.`t2`.`f2` AS `f2` from `test`.`t2` semi join (`test`.`t1` left join (`test`.`t2` `b1` join `test`.`t2` `b2`) on((true))) where (`test`.`t2`.`f2` = ``.`f1`) +SELECT * FROM t2 +WHERE f2 IN (SELECT t1.f1 +FROM t1 LEFT OUTER JOIN (t2 AS b1 JOIN t2 AS b2 ON TRUE) ON TRUE); +f1 f2 +1 1 +2 1 +DROP TABLE t1, t2; +# End of the test for bug#11766739. +# +# Bug#11766642: crash in Item_field::register_field_in_read_map with view +# +CREATE TABLE t1(a INT); +CREATE VIEW v1 AS SELECT a FROM t1; +INSERT INTO t1 VALUES (0),(1),(2); +SELECT a FROM t1 WHERE a IN +(SELECT a XOR a FROM v1) +ORDER BY a; +a +0 +DROP TABLE t1; +DROP VIEW v1; +# +# Bug#12546542 MISSING ROW WHEN USING OPTIMIZER_JOIN_CACHE_LEVEL>=3 +# +CREATE TABLE t1 ( +f2 varchar(1024) +); +INSERT INTO t1 VALUES ('v'),('we'); +CREATE TABLE t2 ( +col_varchar_1024_utf8 varchar(1024) CHARACTER SET utf8 DEFAULT NULL, +col_int_key int, +col_int int +); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t2 VALUES ('we',4,NULL),('v',1305673728,6); +CREATE TABLE t3 ( +col_int_key int, +col_int int +); +INSERT INTO t3 VALUES (4,4); +SELECT * +FROM t1 +WHERE f2 IN (SELECT a1.col_varchar_1024_utf8 AS f2 +FROM t2 AS a1 LEFT JOIN t3 AS a2 +ON a1.col_int_key = a2.col_int_key +WHERE a1.col_int BETWEEN 1 AND 10 OR a2.col_int IS NOT NULL); +f2 +v +we +DROP TABLE t1,t2,t3; +# +# BUG#12616344 - JCL: DIFFERENT RESULT SET AND DIFFERENT AMOUNT +# OF ROWS WHEN JCL>=3 +# +CREATE TABLE t1 (col_int_nokey int, col_int_key int, col_varchar_key varchar(1)); +INSERT INTO t1 VALUES (0,4,'c'),(1,6,'u'); +CREATE TABLE t2 (pk int, col_int_nokey int, col_varchar_nokey varchar(1)); +INSERT INTO t2 VALUES (1,4,'b'),(94,6,'u'); +CREATE TABLE t3 (pk int, col_int_nokey int, col_varchar_key varchar(1)); +INSERT INTO t3 VALUES (1,4,'j'),(2,6,'v'); +SELECT table2.col_int_key +from t3 as table1 join t1 as table2 on table2.col_int_nokey +where table1.col_int_nokey in +( +select subquery2_t2.col_int_nokey +from t3 as subquery2_t1 +right join +t2 as subquery2_t2 +join t1 as subquery2_t3 +on subquery2_t3.col_int_key = subquery2_t2.col_int_nokey +on subquery2_t3.col_varchar_key = subquery2_t2.col_varchar_nokey +where subquery2_t1.col_varchar_key != table1.col_varchar_key +or subquery2_t2.pk <= table1.pk +); +col_int_key +6 +6 +DROP TABLE t1,t2,t3; +# +# Bug#12608157: ASSERT IN FIELD_LONG::VAL_INT WHEN USING MEMORY ENGINE +# +CREATE TABLE t1 (i1 int); +INSERT INTO t1 VALUES (1); +CREATE TABLE t2 (i1 int, i2 int) ENGINE=memory; +INSERT INTO t2 VALUES (1, 2),(7, 3); +SELECT GRANDPARENT1.i1 +FROM t2 AS GRANDPARENT1 +WHERE GRANDPARENT1.i2 +IN ( SELECT PARENT1.i2 +FROM t2 AS PARENT1 JOIN t1 AS PARENT2 ON (PARENT1.i1 = PARENT2.i1) +WHERE +GRANDPARENT1.i1 IN ( SELECT CHILD1.i1 FROM t2 AS CHILD1 ) +ORDER BY PARENT1.i1) +ORDER BY GRANDPARENT1.i2 ; +i1 +1 +DROP TABLE t1,t2; +# +# Bug#12640083: Same query executed as WHERE subquery gives different +# results on IN() compare +# +CREATE TABLE t1 ( +pk int NOT NULL, +col_varchar_1024_utf8_key varchar(1024) CHARACTER SET utf8 DEFAULT NULL, +col_varchar_10_latin1_key varchar(10) DEFAULT NULL, +PRIMARY KEY (pk), +KEY col_varchar_1024_utf8_key(col_varchar_1024_utf8_key(333)), +KEY col_varchar_10_latin1_key(col_varchar_10_latin1_key) +) charset utf8mb4; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES +(1, 'a', 'a'), +(2, 'ab', 'ab'), +(3, 'abc', 'abc'), +(4, 'abcd', 'abcd'); +CREATE TABLE t2 ( +pk int NOT NULL AUTO_INCREMENT, +PRIMARY KEY (pk) +) charset utf8mb4 ENGINE=Innodb; +CREATE TABLE t3 charset utf8mb4 +SELECT alias1.col_varchar_10_latin1_key +FROM t1 AS alias1 +LEFT JOIN t1 AS alias2 +JOIN t2 AS alias3 +ON alias2.col_varchar_10_latin1_key +ON alias1.col_varchar_1024_utf8_key +WHERE alias1.pk AND alias1.pk < 3 OR alias1.pk AND alias3.pk; +EXPLAIN SELECT * +FROM t3 +WHERE col_varchar_10_latin1_key IN ( +SELECT alias1.col_varchar_10_latin1_key +FROM t1 AS alias1 +LEFT JOIN t1 AS alias2 +JOIN t2 AS alias3 +ON alias2.col_varchar_10_latin1_key +ON alias1.col_varchar_1024_utf8_key +WHERE alias1.pk AND alias1.pk < 3 OR alias1.pk AND alias3.pk); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE NULL eq_ref 43 test.t3.col_varchar_10_latin1_key 1 100.00 NULL +2 MATERIALIZED alias1 NULL range PRIMARY,col_varchar_10_latin1_key PRIMARY 4 NULL 5 100.00 Using where +2 MATERIALIZED alias3 NULL index NULL PRIMARY 4 NULL 1 100.00 Using where; Using index; Using join buffer (hash join) +2 MATERIALIZED alias2 NULL index NULL col_varchar_10_latin1_key 43 NULL 4 100.00 Using where; Using index; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`col_varchar_10_latin1_key` AS `col_varchar_10_latin1_key` from `test`.`t3` semi join (`test`.`t1` `alias1` left join (`test`.`t1` `alias2` join `test`.`t2` `alias3`) on(((0 <> `test`.`alias1`.`col_varchar_1024_utf8_key`) and (0 <> `test`.`alias2`.`col_varchar_10_latin1_key`)))) where ((``.`col_varchar_10_latin1_key` = `test`.`t3`.`col_varchar_10_latin1_key`) and (((0 <> `test`.`alias1`.`pk`) and (`test`.`alias1`.`pk` < 3)) or ((0 <> `test`.`alias1`.`pk`) and (0 <> `test`.`alias3`.`pk`)))) +SELECT * +FROM t3 +WHERE col_varchar_10_latin1_key IN ( +SELECT alias1.col_varchar_10_latin1_key +FROM t1 AS alias1 +LEFT JOIN t1 AS alias2 +JOIN t2 AS alias3 +ON alias2.col_varchar_10_latin1_key +ON alias1.col_varchar_1024_utf8_key +WHERE alias1.pk AND alias1.pk < 3 OR alias1.pk AND alias3.pk); +col_varchar_10_latin1_key +a +ab +DROP TABLE t1, t2, t3; +# End of the test for bug#12640083. +# +# Bug#12603200 - Assert in QUICK_INDEX_MERGE_SELECT::need_sorted_output +# +CREATE TABLE t1 ( +pk int NOT NULL, +col_int_key int NOT NULL, +col_varchar_nokey varchar(1) NOT NULL, +col_varchar_key varchar(1) NOT NULL, +PRIMARY KEY(pk), +KEY col_int_key(col_int_key), +KEY col_varchar_key(col_varchar_key, col_int_key) +) charset utf8mb4 engine=innodb; +INSERT INTO t1 VALUES +(1,7,'a','a'), +(2,0,'v','v'), +(3,9,'c','c'), +(4,3,'m','m'), +(5,2,'a','a'), +(6,1,'d','d'), +(7,8,'y','y'), +(8,6,'t','t'), +(11,7,'a','x'), +(12,0,'v','v'), +(13,9,'c','c'), +(14,3,'m','m'), +(15,2,'a','x'), +(16,1,'d','d'), +(17,8,'y','y'), +(18,6,'t','u'), +(19,6,'t','u'); +CREATE TABLE t2 ( +pk int NOT NULL, +col_int_key int NOT NULL, +col_varchar_key varchar(1) NOT NULL, +PRIMARY KEY(pk), +KEY col_varchar_key(col_varchar_key, col_int_key) +) charset utf8mb4 engine=innodb; +INSERT INTO t2(pk,col_int_key,col_varchar_key) VALUES +(8,7,'c'), +(11,4,'l'), +(12,7,'b'), +(13,0,'c'), +(14,2,'i'), +(15,9,'h'), +(16,4,'q'), +(17,1,'m'), +(18,9,'b'), +(19,2,'e'), +(20,1,'c'), +(21,7,'z'), +(22,4,'l'), +(23,7,'z'), +(24,0,'c'), +(25,2,'i'), +(26,9,'h'), +(27,4,'q'), +(28,0,'a'), +(29,1,'d'); +EXPLAIN SELECT outr.col_varchar_key AS x, outr.pk AS y +FROM t1 AS outr +WHERE outr.col_varchar_key IN (SELECT innr.col_varchar_key +FROM t2 AS innr +WHERE innr.col_varchar_key = 'a' OR innr.pk = 8) +AND outr.col_varchar_nokey < 't' +ORDER BY outr.col_varchar_key, outr.pk; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using temporary; Using filesort +1 SIMPLE outr NULL ref col_varchar_key col_varchar_key 6 .col_varchar_key 1 33.33 Using where +2 MATERIALIZED innr NULL index_merge PRIMARY,col_varchar_key col_varchar_key,PRIMARY 6,4 NULL 2 100.00 Using sort_union(col_varchar_key,PRIMARY); Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`outr`.`col_varchar_key` AS `x`,`test`.`outr`.`pk` AS `y` from `test`.`t1` `outr` semi join (`test`.`t2` `innr`) where ((`test`.`outr`.`col_varchar_key` = ``.`col_varchar_key`) and (`test`.`outr`.`col_varchar_nokey` < 't') and (((``.`col_varchar_key` = 'a') and (`test`.`innr`.`col_varchar_key` = 'a')) or (`test`.`innr`.`pk` = 8))) order by `test`.`outr`.`col_varchar_key`,`test`.`outr`.`pk` +SELECT outr.col_varchar_key AS x, outr.pk AS y +FROM t1 AS outr +WHERE outr.col_varchar_key IN (SELECT innr.col_varchar_key +FROM t2 AS innr +WHERE innr.col_varchar_key = 'a' OR innr.pk = 8) +AND outr.col_varchar_nokey < 't' +ORDER BY outr.col_varchar_key, outr.pk; +x y +a 1 +a 5 +c 3 +c 13 +DROP TABLE t1, t2; +# End of bug#12603200 +# +# Bug#12603183: Segfault in hp_movelink +# +CREATE TABLE t1 ( +col_varchar_key varchar(1) , +col_varchar_nokey varchar(1) , +KEY col_varchar_key(col_varchar_key) +) charset latin1; +INSERT INTO t1 VALUES +('i','i'), +('h','h'), +('q','q'), +('a','a'), +('v','v'), +('u','u'), +('s','s'), +('y','y'), +('z','z'), +('h','h'), +('p','p'), +('e','e'), +('i','i'), +('y','y'), +('w','w'); +CREATE TABLE t2 ( +col_varchar_nokey varchar(1) +) charset latin1; +INSERT INTO t2 VALUES +('b'); +EXPLAIN SELECT grandparent1.col_varchar_nokey +FROM t1 AS grandparent1 LEFT JOIN t2 AS grandparent2 USING (col_varchar_nokey) +WHERE (grandparent1.col_varchar_key) IN +(SELECT parent1.col_varchar_nokey +FROM t1 AS parent1 +WHERE parent1.col_varchar_key IN +(SELECT child1.col_varchar_nokey AS c1 +FROM t1 AS child1 LEFT JOIN t2 AS child2 +ON (child1.col_varchar_key > child2.col_varchar_nokey))); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using where +1 SIMPLE grandparent1 NULL ref col_varchar_key col_varchar_key 4 .col_varchar_nokey 2 100.00 NULL +1 SIMPLE grandparent2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +2 MATERIALIZED child1 NULL ALL NULL NULL NULL NULL 15 100.00 Using where +2 MATERIALIZED child2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +2 MATERIALIZED parent1 NULL ref col_varchar_key col_varchar_key 4 test.child1.col_varchar_nokey 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`grandparent1`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t1` `grandparent1` left join `test`.`t2` `grandparent2` on((`test`.`grandparent2`.`col_varchar_nokey` = `test`.`grandparent1`.`col_varchar_nokey`)) semi join (`test`.`t1` `parent1` join `test`.`t1` `child1` left join `test`.`t2` `child2` on((`test`.`child1`.`col_varchar_key` > `test`.`child2`.`col_varchar_nokey`))) where ((`test`.`grandparent1`.`col_varchar_key` = ``.`col_varchar_nokey`) and (`test`.`parent1`.`col_varchar_key` = `test`.`child1`.`col_varchar_nokey`)) +SELECT grandparent1.col_varchar_nokey +FROM t1 AS grandparent1 LEFT JOIN t2 AS grandparent2 USING (col_varchar_nokey) +WHERE (grandparent1.col_varchar_key) IN +(SELECT parent1.col_varchar_nokey +FROM t1 AS parent1 +WHERE parent1.col_varchar_key IN +(SELECT child1.col_varchar_nokey AS c1 +FROM t1 AS child1 LEFT JOIN t2 AS child2 +ON (child1.col_varchar_key > child2.col_varchar_nokey))); +col_varchar_nokey +a +e +h +h +i +i +p +q +s +u +v +w +y +y +z +DROP TABLE t1, t2; +# End of test for bug#12603183. +# +# Bug#12818569: Diff nr of rows returned when using IN/ALL+subquery +# +CREATE TABLE t1 ( +col_int_key INT NOT NULL, +col_datetime_key DATETIME NOT NULL, +col_varchar_key VARCHAR(1) NOT NULL, +KEY col_int_key (col_int_key), +KEY col_datetime_key(col_datetime_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t1 VALUES +(7,'2004-06-06 04:22:12','v'), (0,'2005-11-13 01:12:31','s'), +(9,'2002-05-04 01:50:00','l'), (3,'2004-10-27 10:28:45','y'), +(4,'2006-07-22 05:24:23','c'), (2,'2002-05-16 21:34:03','i'), +(5,'2008-04-17 10:45:30','h'), (3,'2009-04-21 02:58:02','q'), +(1,'2008-01-11 11:01:51','a'), (3,'1900-01-01 00:00:00','v'), +(6,'2007-05-17 18:24:57','u'), (7,'2007-08-07 00:00:00','s'), +(5,'2001-08-28 00:00:00','y'), (1,'2004-04-16 00:27:28','z'), +(204,'2005-05-03 07:06:22','h'), (224,'2009-03-11 17:09:50','p'), +(9,'2007-12-08 01:54:28','e'), (5,'2009-07-28 18:19:54','i'), +(0,'2008-06-08 00:00:00','y'), (3,'2005-02-09 09:20:26','w'); +CREATE TABLE t2 ( +col_varchar_nokey VARCHAR(1) NOT NULL +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t2 VALUES ('v'), ('y'), ('j'), ('c'), ('d'), ('r'); +explain SELECT col_varchar_key +FROM t1 +WHERE col_varchar_key IN (SELECT col_varchar_nokey +FROM t2) +ORDER BY col_datetime_key LIMIT 4; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL col_varchar_key NULL NULL NULL 20 100.00 Using filesort +1 SIMPLE NULL eq_ref 6 test.t1.col_varchar_key 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 6 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col_varchar_key` AS `col_varchar_key` from `test`.`t1` semi join (`test`.`t2`) where (``.`col_varchar_nokey` = `test`.`t1`.`col_varchar_key`) order by `test`.`t1`.`col_datetime_key` limit 4 +SELECT col_varchar_key +FROM t1 +WHERE col_varchar_key IN (SELECT col_varchar_nokey +FROM t2) +ORDER BY col_datetime_key LIMIT 4; +col_varchar_key +v +y +v +y +DROP TABLE t1, t2; +# End of test for bug#12818569. +# +# Bug#12803439: Assert in replace_subcondition() on update query +# +CREATE TABLE t1(a INTEGER); +INSERT INTO t1 values(1), (2); +CREATE TABLE t2(a INTEGER); +INSERT INTO t2 VALUES(1), (3); +SELECT * +FROM t1 +WHERE a IN (SELECT a +FROM t2 +HAVING a IN (SELECT a +FROM t2) +) +HAVING a IN (SELECT a +FROM t2); +a +1 +DROP TABLE t1, t2; +# End of test for bug#12803439. +# +# Bug#12797534: Segfault in hp_movelink still exists +# +CREATE TABLE t1 ( +g1 VARCHAR(1) NOT NULL +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t1 VALUES ('d'), ('s'); +CREATE TABLE t2 ( +pk INT NOT NULL, +col_int_key INT NOT NULL, +col_varchar_key VARCHAR(1) NOT NULL, +col_varchar_nokey VARCHAR(1) NOT NULL, +PRIMARY KEY (pk), +KEY col_varchar_key(col_varchar_key, col_int_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t2 VALUES +(1,4,'j','j'), (2,6,'v','v'), (3,3,'c','c'), (4,5,'m','m'), +(5,3,'d','d'), (6,246,'d','d'), (7,2,'y','y'), (8,9,'t','t'), +(9,3,'d','d'), (10,8,'s','s'), (11,1,'r','r'), (12,8,'m','m'), +(13,8,'b','b'), (14,5,'x','x'), (15,7,'g','g'), (16,5,'p','p'), +(17,1,'q','q'), (18,6,'w','w'), (19,2,'d','d'), (20,9,'e','e'); +CREATE TABLE t3 ( +pk INTEGER NOT NULL, +PRIMARY KEY (pk) +) ENGINE=InnoDB; +INSERT INTO t3 VALUES (10); +EXPLAIN SELECT * +FROM t1 +WHERE g1 NOT IN +(SELECT grandparent1.col_varchar_nokey AS g1 +FROM t2 AS grandparent1 +WHERE grandparent1.col_varchar_key IN +(SELECT parent1.col_varchar_nokey AS p1 +FROM t2 AS parent1 LEFT JOIN t3 AS parent2 USING (pk) +) +AND grandparent1.col_varchar_key IS NOT NULL +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE NULL eq_ref 7 test.t1.g1 1 100.00 Using where; Not exists +2 MATERIALIZED parent1 NULL ALL NULL NULL NULL NULL 20 100.00 NULL +2 MATERIALIZED parent2 NULL eq_ref PRIMARY PRIMARY 4 test.parent1.pk 1 100.00 Using index +2 MATERIALIZED grandparent1 NULL ref col_varchar_key col_varchar_key 6 test.parent1.col_varchar_nokey 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`g1` AS `g1` from `test`.`t1` anti join (`test`.`t2` `grandparent1` join `test`.`t2` `parent1` left join `test`.`t3` `parent2` on((`test`.`parent2`.`pk` = `test`.`parent1`.`pk`))) on(((``.`g1` = `test`.`t1`.`g1`) and (`test`.`grandparent1`.`col_varchar_key` = `test`.`parent1`.`col_varchar_nokey`) and (`test`.`grandparent1`.`col_varchar_key` is not null))) where true +SELECT * +FROM t1 +WHERE g1 NOT IN +(SELECT grandparent1.col_varchar_nokey AS g1 +FROM t2 AS grandparent1 +WHERE grandparent1.col_varchar_key IN +(SELECT parent1.col_varchar_nokey AS p1 +FROM t2 AS parent1 LEFT JOIN t3 AS parent2 USING (pk) +) +AND grandparent1.col_varchar_key IS NOT NULL +); +g1 +DROP TABLE t1, t2, t3; +CREATE TABLE t1 ( +pk INTEGER AUTO_INCREMENT, +col_int_key INTEGER , +col_varchar_key VARCHAR(1) , +col_varchar_nokey VARCHAR(1) , +PRIMARY KEY (pk), +KEY (col_varchar_key,col_int_key) +) ENGINE=INNODB; +INSERT INTO t1 (col_int_key,col_varchar_key,col_varchar_nokey) VALUES +(0,'x','x'), (1,'j','j'), (1,'r','r'), (9,'v','v'), (5,'r','r'); +CREATE TABLE t2 ( +pk INTEGER AUTO_INCREMENT, +col_int_key INTEGER , +col_varchar_key VARCHAR(1) , +col_varchar_nokey VARCHAR(1) , +PRIMARY KEY (pk), +KEY (col_int_key), +KEY (col_varchar_key,col_int_key) +) AUTO_INCREMENT=10 ENGINE=INNODB; +INSERT INTO t2 (col_int_key, col_varchar_key, col_varchar_nokey) VALUES +(NULL,'x','x'), (NULL,'j','j'), (8,'c','c'); +CREATE TABLE t3 +SELECT outr.col_varchar_nokey AS x +FROM t1 AS outr +WHERE outr.col_varchar_nokey IN +(SELECT innr.col_varchar_nokey AS y +FROM t2 AS innr +WHERE innr.col_int_key IS NULL) +AND outr.col_varchar_nokey IS NOT NULL +AND NOT col_varchar_key IS NULL; +SELECT * +FROM t3 +WHERE x NOT IN +(SELECT outr.col_varchar_nokey AS x +FROM t1 AS outr +WHERE outr.col_varchar_nokey IN +(SELECT innr.col_varchar_nokey AS y +FROM t2 AS innr +WHERE innr.col_int_key IS NULL) +AND outr.col_varchar_nokey IS NOT NULL +AND NOT col_varchar_key IS NULL); +x +DROP TABLE t1, t2, t3; +# End of test for bug#12797534. +# +# Bug#12714094: Assert in optimize_semijoin_nests() +# +CREATE TABLE it ( +pk int NOT NULL, +col_varchar VARCHAR(10) DEFAULT NULL, +PRIMARY KEY (pk) +) ENGINE=MyISAM; +INSERT INTO it VALUES (1, 'g'); +CREATE TABLE ot +SELECT alias1.pk AS field1 +FROM it AS alias1 +LEFT JOIN it AS alias2 +ON alias1.col_varchar = alias2.col_varchar +; +SELECT * +FROM ot +WHERE field1 IN ( +SELECT alias1.pk +FROM it AS alias1 +LEFT JOIN it AS alias2 +ON alias1.col_varchar = alias2.col_varchar +); +field1 +1 +DROP TABLE it, ot; +# End of test for bug#12714094 +# +# Bug#12867557: Valgrind: conditional jump/move at key_cmp +# +CREATE TABLE t1 ( +pk INTEGER AUTO_INCREMENT, +col_int_key INTEGER, +PRIMARY KEY (pk), +KEY (col_int_key) +) AUTO_INCREMENT=10; +INSERT INTO t1 (col_int_key) VALUES (8); +CREATE TABLE t2 ( +pk INTEGER AUTO_INCREMENT, +col_int_key INTEGER, +col_time_key TIME, +PRIMARY KEY (pk), +KEY (col_int_key), +KEY (col_time_key) +) AUTO_INCREMENT=10; +INSERT INTO t2 (col_int_key, col_time_key) +VALUES +(8, '22:55:23.019225'), (7, '10:19:31.050677'), (1, '14:40:36.038608'), +(7, '04:37:47.062416'), (9, '19:34:06.054514'), (NULL,'20:35:33.022996'), +(1, NULL), (9, '14:43:37.057393'), (2, '02:23:09.043438'), +(9, '01:22:45.041064'), (2, '00:00:00'), (4, '00:13:25.038482'), +(0, '03:47:16.042671'), (4, '01:41:48.007423'), (8, '00:00:00'), +(NULL, '22:32:04.047407'), (NULL, '16:44:14.028443'), (0, '17:38:37.059754'), +(NULL, '08:46:48.042388'), (8, '14:11:27.044095'); +CREATE TABLE t0 +SELECT DISTINCT grandparent1.col_time_key AS g1 +FROM t2 AS grandparent1 +WHERE grandparent1.col_int_key IN +(SELECT parent1.col_int_key AS p1 +FROM t1 AS parent1) +AND grandparent1.pk > 9; +UPDATE t0 +SET g1 = g1 +WHERE g1 IN +(SELECT grandparent1.col_time_key AS g1 +FROM t2 AS grandparent1 +WHERE grandparent1.col_int_key IN +(SELECT parent1.col_int_key AS p1 +FROM t1 AS parent1) +AND grandparent1.pk > 9); +DROP TABLE t0, t1, t2; +# End of test for bug#12867557 +# +# Bug#12711441: crash in fix_after_pullout +# +CREATE TABLE t1 ( +pk int NOT NULL, +col_int_nokey int DEFAULT NULL, +col_int_key int DEFAULT NULL, +col_time_key time DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +PRIMARY KEY (pk) +); +CREATE VIEW v1 AS SELECT * FROM t1; +CREATE TABLE t2 ( +col_int_key int DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +KEY col_varchar_key(col_varchar_key, col_int_key) +); +CREATE TABLE t3 ( +pk int NOT NULL, +col_int_key INT DEFAULT NULL, +PRIMARY KEY (pk) +); +CREATE TABLE t4 ( +col_int_nokey INT DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +KEY col_varchar_key(col_varchar_key) +); +CREATE TABLE ts +SELECT alias1.col_time_key AS field1 +FROM v1 AS alias1 +RIGHT JOIN t3 AS alias2 +ON alias2.col_int_key = alias1.col_int_nokey +WHERE alias1.pk >= SOME( +SELECT SQ1_alias1.pk AS SQ1_field1 +FROM t3 AS SQ1_alias1 +INNER JOIN (t2 AS SQ1_alias2 +INNER JOIN t4 AS SQ1_alias3 +ON SQ1_alias3.col_varchar_key = SQ1_alias2.col_varchar_nokey) +ON SQ1_alias3.col_int_nokey = SQ1_alias2.col_int_key +WHERE SQ1_alias2.col_varchar_key <= alias1.col_varchar_key +AND SQ1_alias3.col_varchar_nokey <> alias1.col_varchar_key) +; +SELECT * FROM ts WHERE field1 IN ( +SELECT alias1.col_time_key AS field1 +FROM v1 AS alias1 +RIGHT JOIN t3 AS alias2 +ON alias2.col_int_key = alias1.col_int_nokey +WHERE alias1.pk >= SOME( +SELECT SQ1_alias1.pk AS SQ1_field1 +FROM t3 AS SQ1_alias1 +INNER JOIN (t2 AS SQ1_alias2 +INNER JOIN t4 AS SQ1_alias3 +ON SQ1_alias3.col_varchar_key = SQ1_alias2.col_varchar_nokey) +ON SQ1_alias3.col_int_nokey = SQ1_alias2.col_int_key +WHERE SQ1_alias2.col_varchar_key <= alias1.col_varchar_key +AND SQ1_alias3.col_varchar_nokey <> alias1.col_varchar_key) +); +field1 +DROP TABLE t1, t2, t3, t4, ts; +DROP VIEW v1; +# End of test for bug#12711441. +# +# Bug#12664936: Same query executed as where subquery ... +# +CREATE TABLE t1 ( +col_varchar_key VARCHAR(1), +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4; +INSERT INTO t1 VALUES +('o'), ('w'), ('m'), ('q'), +('f'), ('p'), ('j'), ('c'); +CREATE TABLE t2 ( +col_int_nokey INTEGER, +col_int_key INTEGER, +col_varchar_key varchar(1), +KEY col_int_key (col_int_key) +) charset utf8mb4; +INSERT INTO t2 VALUES +(8,5,'u'),(4,5,'p'),(8,1,'o'),(NULL,7,'v'), +(1,2,'g'),(2,1,'q'),(NULL,7,'l'),(3,1,'n'); +CREATE TABLE t4 +SELECT t2.col_int_nokey, t2.col_varchar_key +FROM t1 JOIN t2 ON t2.col_varchar_key = t1.col_varchar_key +WHERE t2.col_int_key = 1; +EXPLAIN SELECT * +FROM t4 +WHERE (col_int_nokey, col_varchar_key) IN +(SELECT t2.col_int_nokey, t2.col_varchar_key +FROM t1 JOIN t2 ON t2.col_varchar_key = t1.col_varchar_key +WHERE t2.col_int_key = 1 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t4 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE NULL eq_ref 12 test.t4.col_int_nokey,test.t4.col_varchar_key 1 100.00 NULL +2 MATERIALIZED t2 NULL ref col_int_key col_int_key 5 const 3 100.00 Using where +2 MATERIALIZED t1 NULL ref col_varchar_key col_varchar_key 7 test.t2.col_varchar_key 2 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`col_int_nokey` AS `col_int_nokey`,`test`.`t4`.`col_varchar_key` AS `col_varchar_key` from `test`.`t4` semi join (`test`.`t1` join `test`.`t2`) where ((``.`col_varchar_key` = `test`.`t4`.`col_varchar_key`) and (`test`.`t1`.`col_varchar_key` = `test`.`t2`.`col_varchar_key`) and (``.`col_int_nokey` = `test`.`t4`.`col_int_nokey`) and (`test`.`t2`.`col_int_key` = 1)) +SELECT * +FROM t4 +WHERE (col_int_nokey, col_varchar_key) IN +(SELECT t2.col_int_nokey, t2.col_varchar_key +FROM t1 JOIN t2 ON t2.col_varchar_key = t1.col_varchar_key +WHERE t2.col_int_key = 1 +); +col_int_nokey col_varchar_key +8 o +2 q +DROP TABLE t1, t2, t4; +# End of test for bug#12664936. +# +# Bug#13340270: assertion table->sort.record_pointers == __null +# +CREATE TABLE t1 ( +pk int NOT NULL, +col_int_key int DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key, col_int_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t1 VALUES +(10,8,'x','x'), +(11,7,'d','d'), +(12,1,'r','r'), +(13,7,'f','f'), +(14,9,'y','y'), +(15,NULL,'u','u'), +(16,1,'m','m'), +(17,9,NULL,NULL), +(18,2,'o','o'), +(19,9,'w','w'), +(20,2,'m','m'), +(21,4,'q','q'); +CREATE TABLE t2 +SELECT alias1.col_varchar_nokey AS field1 +FROM t1 AS alias1 JOIN t1 AS alias2 +ON alias2.col_int_key = alias1.pk OR +alias2.col_int_key = alias1.col_int_key +WHERE alias1.pk = 58 OR alias1.col_varchar_key = 'o' + +; +EXPLAIN SELECT * +FROM t2 +WHERE (field1) IN (SELECT alias1.col_varchar_nokey AS field1 +FROM t1 AS alias1 JOIN t1 AS alias2 +ON alias2.col_int_key = alias1.pk OR +alias2.col_int_key = alias1.col_int_key +WHERE alias1.pk = 58 OR alias1.col_varchar_key = 'o' +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE NULL eq_ref 7 test.t2.field1 1 100.00 NULL +2 MATERIALIZED alias1 NULL index_merge PRIMARY,col_int_key,col_varchar_key col_varchar_key,PRIMARY 7,4 NULL 2 100.00 Using sort_union(col_varchar_key,PRIMARY); Using where +2 MATERIALIZED alias2 NULL ALL col_int_key NULL NULL NULL 12 19.00 Range checked for each record (index map: 0x2) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`field1` AS `field1` from `test`.`t2` semi join (`test`.`t1` `alias1` join `test`.`t1` `alias2`) where ((``.`field1` = `test`.`t2`.`field1`) and ((`test`.`alias1`.`pk` = 58) or (`test`.`alias1`.`col_varchar_key` = 'o')) and ((`test`.`alias2`.`col_int_key` = `test`.`alias1`.`pk`) or (`test`.`alias2`.`col_int_key` = `test`.`alias1`.`col_int_key`))) +SELECT * +FROM t2 +WHERE (field1) IN (SELECT alias1.col_varchar_nokey AS field1 +FROM t1 AS alias1 JOIN t1 AS alias2 +ON alias2.col_int_key = alias1.pk OR +alias2.col_int_key = alias1.col_int_key +WHERE alias1.pk = 58 OR alias1.col_varchar_key = 'o' +); +field1 +o +o +DROP TABLE t1, t2; +# End of test for bug#13340270. +# +# Bug#13335319: Seg fault when analyzing FirstMatch semi-join strategy +# +CREATE TABLE ot1(a INTEGER); +INSERT INTO ot1 VALUES(1), (2), (3); +CREATE TABLE ot2(a INTEGER); +INSERT INTO ot2 VALUES(1), (2), (4), (6), (8), (10); +CREATE TABLE it1(a INTEGER); +INSERT INTO it1 VALUES(1), (3), (5), (7); +CREATE TABLE it2(a INTEGER); +INSERT INTO it2 VALUES(1), (3), (5), (7), (9); +explain SELECT ot1.a, ot2.a +FROM ot1, ot2 +WHERE ot1.a IN (SELECT a FROM it1) AND +ot2.a IN (SELECT a FROM it2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 6 100.00 Using where; Using join buffer (hash join) +1 SIMPLE NULL eq_ref 5 test.ot1.a 1 100.00 NULL +1 SIMPLE NULL eq_ref 5 test.ot2.a 1 100.00 NULL +2 MATERIALIZED it1 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +3 MATERIALIZED it2 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` join `test`.`ot2` semi join (`test`.`it1`) semi join (`test`.`it2`) where ((``.`a` = `test`.`ot2`.`a`) and (``.`a` = `test`.`ot1`.`a`)) +SELECT ot1.a, ot2.a +FROM ot1, ot2 +WHERE ot1.a IN (SELECT a FROM it1) AND +ot2.a IN (SELECT a FROM it2); +a a +1 1 +3 1 +DROP TABLE ot1, ot2, it1, it2; +# End of test for bug#13335319. +# +# Bug#13334882: Assertion keypart_map failed in MyIsam function +# +CREATE TABLE t1 ( +pk int NOT NULL, +col_int_nokey INT NOT NULL, +col_int_key INT NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +) ENGINE=MyISAM; +INSERT INTO t1 VALUES +(1,4,0), +(2,6,8), +(3,3,1), +(7,2,6), +(8,9,1), +(9,3,6), +(10,8,2), +(11,1,4), +(12,8,8), +(13,8,4), +(14,5,4); +CREATE TABLE t2 ( +pk int NOT NULL, +col_int_nokey int NOT NULL, +col_int_key int NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +) ENGINE=MyISAM; +INSERT INTO t2 VALUES +(10,8,7); +CREATE TABLE t3 +SELECT grandparent1.col_int_nokey AS g1 +FROM t1 AS grandparent1 +WHERE (grandparent1.col_int_nokey, grandparent1.col_int_key) IN +(SELECT parent1.col_int_key AS p1, +parent1.col_int_key AS p2 +FROM t1 AS parent1 +LEFT JOIN t2 AS parent2 +ON parent1.col_int_nokey = parent2.col_int_key +) +AND grandparent1.col_int_key <> 3 +; +explain SELECT * FROM t3 +WHERE g1 NOT IN +(SELECT grandparent1.col_int_nokey AS g1 +FROM t1 AS grandparent1 +WHERE (grandparent1.col_int_nokey, grandparent1.col_int_key) IN +(SELECT parent1.col_int_key AS p1, +parent1.col_int_key AS p2 +FROM t1 AS parent1 +LEFT JOIN t2 AS parent2 +ON parent1.col_int_nokey = parent2.col_int_key +) +AND grandparent1.col_int_key <> 3 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 Using where; Not exists +2 MATERIALIZED parent1 NULL ALL col_int_key NULL NULL NULL 11 100.00 Using where +2 MATERIALIZED parent2 NULL index col_int_key col_int_key 4 NULL 1 100.00 Using where; Using index; Using join buffer (hash join) +2 MATERIALIZED grandparent1 NULL ref col_int_key col_int_key 4 test.parent1.col_int_key 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select '8' AS `g1` from anti join (`test`.`t1` `grandparent1` join `test`.`t1` `parent1` left join `test`.`t2` `parent2` on((`test`.`parent2`.`col_int_key` = `test`.`parent1`.`col_int_nokey`))) on(((``.`g1` = '8') and (`test`.`parent1`.`col_int_key` = '8') and (`test`.`grandparent1`.`col_int_key` = '8') and (`test`.`grandparent1`.`col_int_nokey` = '8') and ('8' <> 3))) where true +explain format=json SELECT * FROM t3 +WHERE g1 NOT IN +(SELECT grandparent1.col_int_nokey AS g1 +FROM t1 AS grandparent1 +WHERE (grandparent1.col_int_nokey, grandparent1.col_int_key) IN +(SELECT parent1.col_int_key AS p1, +parent1.col_int_key AS p2 +FROM t1 AS parent1 +LEFT JOIN t2 AS parent2 +ON parent1.col_int_nokey = parent2.col_int_key +) +AND grandparent1.col_int_key <> 3 +); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "14.21" + }, + "nested_loop": [ + { + "table": { + "table_name": "t3", + "access_type": "system", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.00", + "eval_cost": "0.10", + "prefix_cost": "0.00", + "data_read_per_join": "8" + }, + "used_columns": [ + "g1" + ] + } + }, + { + "table": { + "table_name": "", + "access_type": "const", + "key": "", + "key_length": "5", + "ref": [ + "const" + ], + "rows_examined_per_scan": 1, + "not_exists": true, + "attached_condition": "((is_not_null_compl(), (('8' <> 3)), true) and (is_not_null_compl(), (found_match(), false, true), true))", + "materialized_from_subquery": { + "using_temporary_table": true, + "query_block": { + "nested_loop": [ + { + "table": { + "table_name": "parent1", + "access_type": "ALL", + "possible_keys": [ + "col_int_key" + ], + "rows_examined_per_scan": 11, + "rows_produced_per_join": 11, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "1.10", + "prefix_cost": "1.61", + "data_read_per_join": "176" + }, + "used_columns": [ + "col_int_nokey", + "col_int_key" + ], + "attached_condition": "((('8' <> 3)) and (`test`.`parent1`.`col_int_key` = '8'))" + } + }, + { + "table": { + "table_name": "parent2", + "access_type": "index", + "possible_keys": [ + "col_int_key" + ], + "key": "col_int_key", + "used_key_parts": [ + "col_int_key" + ], + "key_length": "4", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 11, + "filtered": "100.00", + "using_index": true, + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "1.10", + "prefix_cost": "3.21", + "data_read_per_join": "176" + }, + "used_columns": [ + "col_int_key" + ], + "attached_condition": "(is_not_null_compl(parent2), (`test`.`parent2`.`col_int_key` = `test`.`parent1`.`col_int_nokey`), true)" + } + }, + { + "table": { + "table_name": "grandparent1", + "access_type": "ref", + "possible_keys": [ + "col_int_key" + ], + "key": "col_int_key", + "used_key_parts": [ + "col_int_key" + ], + "key_length": "4", + "ref": [ + "test.parent1.col_int_key" + ], + "rows_examined_per_scan": 2, + "rows_produced_per_join": 22, + "filtered": "100.00", + "cost_info": { + "read_cost": "5.50", + "eval_cost": "2.20", + "prefix_cost": "10.91", + "data_read_per_join": "352" + }, + "used_columns": [ + "col_int_nokey", + "col_int_key" + ], + "attached_condition": "((`test`.`grandparent1`.`col_int_key` = '8') and (`test`.`grandparent1`.`col_int_nokey` = '8'))" + } + } + ] + } + } + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select '8' AS `g1` from anti join (`test`.`t1` `grandparent1` join `test`.`t1` `parent1` left join `test`.`t2` `parent2` on((`test`.`parent2`.`col_int_key` = `test`.`parent1`.`col_int_nokey`))) on(((``.`g1` = '8') and (`test`.`parent1`.`col_int_key` = '8') and (`test`.`grandparent1`.`col_int_key` = '8') and (`test`.`grandparent1`.`col_int_nokey` = '8') and ('8' <> 3))) where true +SELECT * FROM t3 +WHERE g1 NOT IN +(SELECT grandparent1.col_int_nokey AS g1 +FROM t1 AS grandparent1 +WHERE (grandparent1.col_int_nokey, grandparent1.col_int_key) IN +(SELECT parent1.col_int_key AS p1, +parent1.col_int_key AS p2 +FROM t1 AS parent1 +LEFT JOIN t2 AS parent2 +ON parent1.col_int_nokey = parent2.col_int_key +) +AND grandparent1.col_int_key <> 3 +); +g1 +DROP TABLE t1, t2, t3; +# End of test for bug#13334882. +# +# Bug#13339643: Assertion on JOIN::flatten_subqueries on second execution +# +CREATE TABLE t1 ( +col_int_nokey INT, +col_varchar_nokey VARCHAR(1) +) charset utf8mb4; +INSERT INTO t1 VALUES +(1,'o'), +(2,'t'); +CREATE TABLE t2 LIKE t1; +INSERT INTO t2 VALUES +(1,'o'), +(4,'f'); +CREATE VIEW v_t2 AS SELECT * FROM t2; +CREATE TABLE t3 LIKE t1; +INSERT INTO t3 VALUES +(1,'o'), +(4,'f'); +explain SELECT alias1.col_varchar_nokey +FROM t1 AS alias1 +INNER JOIN v_t2 AS alias2 +ON alias2.col_int_nokey = alias1.col_int_nokey AND +'o' IN (SELECT col_varchar_nokey +FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary; End temporary +1 SIMPLE alias1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`alias1`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t1` `alias1` join `test`.`t2` semi join (`test`.`t3`) where ((`test`.`t3`.`col_varchar_nokey` = 'o') and (`test`.`t2`.`col_int_nokey` = `test`.`alias1`.`col_int_nokey`)) +SELECT alias1.col_varchar_nokey +FROM t1 AS alias1 +INNER JOIN v_t2 AS alias2 +ON alias2.col_int_nokey = alias1.col_int_nokey AND +'o' IN (SELECT col_varchar_nokey +FROM t3); +col_varchar_nokey +o +PREPARE stmt FROM "SELECT alias1.col_varchar_nokey +FROM t1 AS alias1 +INNER JOIN v_t2 AS alias2 +ON alias2.col_int_nokey = alias1.col_int_nokey AND +'o' IN (SELECT col_varchar_nokey +FROM t3)"; +EXECUTE stmt; +col_varchar_nokey +o +DROP VIEW v_t2; +DROP TABLE t1, t2, t3; +# End of test for bug#13339643. +# +# Bug#13424134: Wrong result on JOIN + nested WHERE ... IN clauses +# +CREATE TABLE t1 ( +pk int NOT NULL, +col_int_nokey int NOT NULL, +col_int_key int NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +) ENGINE=MyIsam; +INSERT INTO t1 VALUES +(10,1,7), (13,7,3), (18,0,1), (23,8,1); +CREATE TABLE t2 ( +pk int NOT NULL, +col_int_key int NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +) ENGINE=MyIsam; +INSERT INTO t2 VALUES (1,7); +EXPLAIN SELECT t1a.* +FROM t1 AS t1a +JOIN t1 AS t1b USING ( col_int_nokey ) +WHERE t1a.col_int_key IN ( +SELECT pk +FROM t2 +WHERE col_int_key IN ( +SELECT col_int_nokey +FROM t1 +) +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL system PRIMARY,col_int_key NULL NULL NULL 1 100.00 NULL +1 SIMPLE t1a NULL ref col_int_key col_int_key 4 const 1 100.00 Start temporary +1 SIMPLE t1b NULL ALL NULL NULL NULL NULL 4 25.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1a`.`pk` AS `pk`,`test`.`t1a`.`col_int_nokey` AS `col_int_nokey`,`test`.`t1a`.`col_int_key` AS `col_int_key` from `test`.`t1` `t1a` join `test`.`t1` `t1b` semi join (`test`.`t1`) where ((`test`.`t1b`.`col_int_nokey` = `test`.`t1a`.`col_int_nokey`) and (`test`.`t1a`.`col_int_key` = '1') and (`test`.`t1`.`col_int_nokey` = '7')) +SELECT t1a.* +FROM t1 AS t1a +JOIN t1 AS t1b USING ( col_int_nokey ) +WHERE t1a.col_int_key IN ( +SELECT pk +FROM t2 +WHERE col_int_key IN ( +SELECT col_int_nokey +FROM t1 +) +); +pk col_int_nokey col_int_key +18 0 1 +23 8 1 +ALTER TABLE t1 ENGINE=Innodb; +ALTER TABLE t2 ENGINE=Innodb; +SELECT t1a.* +FROM t1 AS t1a +JOIN t1 AS t1b USING ( col_int_nokey ) +WHERE t1a.col_int_key IN ( +SELECT pk +FROM t2 +WHERE col_int_key IN ( +SELECT col_int_nokey +FROM t1 +) +); +pk col_int_nokey col_int_key +18 0 1 +23 8 1 +DROP TABLE t1, t2; +# End of test for bug#13424134. +# +# Bug#13414014: Extra rows in result on semijoin query with where ... +# +CREATE TABLE t1 ( +c INT, +d INT, +a VARCHAR(1), +b VARCHAR(1), +KEY a (a) +) charset utf8mb4; +INSERT INTO t1 VALUES +(NULL,8,'x','x'), (7,4,'q','q'), (6,8,'c','c'); +CREATE TABLE t2 ( +a VARCHAR(1), +KEY a (a) +) charset utf8mb4; +INSERT INTO t2 VALUES +('c'), (NULL), ('x'), ('q'); +explain SELECT * +FROM t2 AS ot +WHERE (a, a) IN +(SELECT a, b +FROM t1 AS it +WHERE it.a = 'x' OR it.c > it.d +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using where +1 SIMPLE ot NULL ref a a 7 .a 2 100.00 Using index +2 MATERIALIZED it NULL ALL a NULL NULL NULL 3 40.74 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`ot`.`a` AS `a` from `test`.`t2` `ot` semi join (`test`.`t1` `it`) where ((``.`b` = ``.`a`) and (`test`.`ot`.`a` = ``.`a`) and (`test`.`it`.`b` = `test`.`it`.`a`) and (((``.`a` = 'x') and (`test`.`it`.`a` = 'x') and (`test`.`it`.`b` = 'x')) or (`test`.`it`.`c` > `test`.`it`.`d`))) +SELECT * +FROM t2 AS ot +WHERE (a, a) IN +(SELECT a, b +FROM t1 AS it +WHERE it.a = 'x' OR it.c > it.d +) +; +a +q +x +DROP TABLE t1, t2; +# End of test for bug#13414014. +# +# Bug#13545215: Missing rows on nested in-subquery with materialization +# +CREATE TABLE t1 ( +col_int_key int, +col_varchar_key varchar(1), +col_varchar_nokey varchar(1), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +INSERT INTO t1 VALUES +(8,'x','x'), (0,'p','p'), (8,'c','c'); +CREATE TABLE t2 ( +pk int NOT NULL, +col_varchar_key varchar(1), +col_varchar_nokey varchar(1), +PRIMARY KEY (pk), +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4; +INSERT INTO t2 VALUES +(1,'v','v'), (2,'v','v'), (3,'c','c'), (4,NULL,NULL), +(5,'x','x'), (6,'i','i'), (7,'e','e'), (8,'p','p'); +CREATE TABLE t3 ( +col_int_nokey int +); +INSERT INTO t3 VALUES (7); +explain SELECT grandparent1.col_varchar_nokey +FROM t1 AS grandparent1 JOIN t1 AS grandparent2 USING (col_int_key) +WHERE grandparent1.col_varchar_key IN ( +SELECT col_varchar_nokey +FROM t2 AS parent1 +WHERE col_varchar_key IN ( +SELECT child1.col_varchar_nokey +FROM t2 AS child1 LEFT JOIN t3 AS child2 +ON child1.pk < child2.col_int_nokey +) +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE grandparent1 NULL ALL col_int_key,col_varchar_key NULL NULL NULL 3 100.00 Using where +1 SIMPLE NULL eq_ref 7 test.grandparent1.col_varchar_key 1 100.00 NULL +1 SIMPLE grandparent2 NULL ref col_int_key col_int_key 5 test.grandparent1.col_int_key 2 100.00 Using index +2 MATERIALIZED child1 NULL ALL NULL NULL NULL NULL 8 100.00 Using where +2 MATERIALIZED child2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +2 MATERIALIZED parent1 NULL ref col_varchar_key col_varchar_key 7 test.child1.col_varchar_nokey 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`grandparent1`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t1` `grandparent1` join `test`.`t1` `grandparent2` semi join (`test`.`t2` `parent1` join `test`.`t2` `child1` left join `test`.`t3` `child2` on((`test`.`child1`.`pk` < `test`.`child2`.`col_int_nokey`))) where ((`test`.`grandparent2`.`col_int_key` = `test`.`grandparent1`.`col_int_key`) and (``.`col_varchar_nokey` = `test`.`grandparent1`.`col_varchar_key`) and (`test`.`parent1`.`col_varchar_key` = `test`.`child1`.`col_varchar_nokey`)) +SELECT grandparent1.col_varchar_nokey +FROM t1 AS grandparent1 JOIN t1 AS grandparent2 USING (col_int_key) +WHERE grandparent1.col_varchar_key IN ( +SELECT col_varchar_nokey +FROM t2 AS parent1 +WHERE col_varchar_key IN ( +SELECT child1.col_varchar_nokey +FROM t2 AS child1 LEFT JOIN t3 AS child2 +ON child1.pk < child2.col_int_nokey +) +); +col_varchar_nokey +c +c +p +x +x +DROP TABLE t1, t2, t3; +# End of test for bug#13545215. +# +# BUG#13553211 - MISSING ROWS ON SELECT WITH IN-SUBQUERY AND +# MATERIALIZATION + SEMIJOIN ON +# +CREATE TABLE t1 ( +col_int_key int(11) DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (4,'v','v'); +INSERT INTO t1 VALUES (62,'v','v'); +INSERT INTO t1 VALUES (7,'c','c'); +INSERT INTO t1 VALUES (1,NULL,NULL); +EXPLAIN SELECT +alias1.col_varchar_nokey AS a1_nokey, +alias1.col_varchar_key AS a1_key, +alias2.col_varchar_nokey AS a2_nokey +FROM +t1 AS alias1, t1 AS alias2 +WHERE +(alias1.col_varchar_nokey,alias2.col_varchar_nokey) +IN +( +SELECT +sq2_alias2.col_varchar_nokey, sq2_alias1.col_varchar_key +FROM +t1 AS sq2_alias1, t1 AS sq2_alias2 +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE alias1 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +1 SIMPLE alias2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (hash join) +1 SIMPLE NULL eq_ref 14 test.alias1.col_varchar_nokey,test.alias2.col_varchar_nokey 1 100.00 NULL +2 MATERIALIZED sq2_alias1 NULL index col_varchar_key col_varchar_key 12 NULL 4 100.00 Using index +2 MATERIALIZED sq2_alias2 NULL ALL NULL NULL NULL NULL 4 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`alias1`.`col_varchar_nokey` AS `a1_nokey`,`test`.`alias1`.`col_varchar_key` AS `a1_key`,`test`.`alias2`.`col_varchar_nokey` AS `a2_nokey` from `test`.`t1` `alias1` join `test`.`t1` `alias2` semi join (`test`.`t1` `sq2_alias1` join `test`.`t1` `sq2_alias2`) where ((``.`col_varchar_key` = `test`.`alias2`.`col_varchar_nokey`) and (``.`col_varchar_nokey` = `test`.`alias1`.`col_varchar_nokey`)) +SELECT +alias1.col_varchar_nokey AS a1_nokey, +alias1.col_varchar_key AS a1_key, +alias2.col_varchar_nokey AS a2_nokey +FROM +t1 AS alias1, t1 AS alias2 +WHERE +(alias1.col_varchar_nokey,alias2.col_varchar_nokey) +IN +( +SELECT +sq2_alias2.col_varchar_nokey, sq2_alias1.col_varchar_key +FROM +t1 AS sq2_alias1, t1 AS sq2_alias2 +) +; +a1_nokey a1_key a2_nokey +c c c +c c v +c c v +v v c +v v c +v v v +v v v +v v v +v v v +DROP TABLE t1; +# +# Bug#13541406: Wrong result with loosescan on select .. where .. in +# +CREATE TABLE t1 ( +col_int_key INT NOT NULL, +col_varchar_nokey VARCHAR(1) NOT NULL, +KEY col_int_key (col_int_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t1 VALUES +(7,'v'), (0,'s'), (9,'l'), (3,'y'), (4,'c'), (2,'i'), (5,'h'), (3,'q'), +(1,'a'), (3,'v'), (6,'u'), (7,'s'), (5,'y'), (1,'z'), (204,'h'), (224,'p'), +(9,'e'), (5,'i'), (0,'y'), (3,'w'); +CREATE TABLE t2 ( +pk INT NOT NULL, +col_int_key INT NOT NULL, +col_varchar_key VARCHAR(1) NOT NULL, +col_varchar_nokey VARCHAR(1) NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t2 VALUES +(1,0,'j','j'), (2,8,'v','v'), (3,1,'c','c'), (4,8,'m','m'), +(5,9,'d','d'), (6,24,'d','d'), (7,6,'y','y'), (8,1,'t','t'), +(9,6,'d','d'), (10,2,'s','s'), (11,4,'r','r'), (12,8,'m','m'), +(13,4,'b','b'), (14,4,'x','x'), (15,7,'g','g'), (16,4,'p','p'), +(17,1,'q','q'), (18,9,'w','w'), (19,4,'d','d'), (20,8,'e','e'); +# This query should never use a LooseScan strategy +explain SELECT ot1.col_int_key AS field1 +FROM t2 AS ot1, t2 AS ot2 +WHERE (ot1.col_varchar_key, ot2.col_varchar_nokey) IN ( +SELECT it2.col_varchar_nokey, it1.col_varchar_key +FROM t2 AS it1 JOIN t1 AS it2 ON it2.col_int_key = it1.pk); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE ot1 NULL ref col_varchar_key col_varchar_key 6 .col_varchar_nokey 1 100.00 Using index +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 20 10.00 Using where; Using join buffer (hash join) +2 MATERIALIZED it2 NULL ALL col_int_key NULL NULL NULL 20 100.00 NULL +2 MATERIALIZED it1 NULL eq_ref PRIMARY,col_varchar_key PRIMARY 4 test.it2.col_int_key 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`col_int_key` AS `field1` from `test`.`t2` `ot1` join `test`.`t2` `ot2` semi join (`test`.`t2` `it1` join `test`.`t1` `it2`) where ((`test`.`it1`.`pk` = `test`.`it2`.`col_int_key`) and (`test`.`ot2`.`col_varchar_nokey` = ``.`col_varchar_key`) and (`test`.`ot1`.`col_varchar_key` = ``.`col_varchar_nokey`)) +SELECT ot1.col_int_key AS field1 +FROM t2 AS ot1, t2 AS ot2 +WHERE (ot1.col_varchar_key, ot2.col_varchar_nokey) IN ( +SELECT it2.col_varchar_nokey, it1.col_varchar_key +FROM t2 AS it1 JOIN t1 AS it2 ON it2.col_int_key = it1.pk); +field1 +1 +1 +1 +2 +6 +6 +6 +6 +6 +8 +8 +8 +8 +8 +8 +9 +DROP TABLE t1, t2; +# End of test for bug#13541406. +# +# Bug#13576391: Missing rows on select with in-subquery and +# batched-key-access=on and semijoin +# +CREATE TABLE t1 ( +col_int_nokey int NOT NULL, +col_varchar_key varchar(1) NOT NULL, +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4 engine=InnoDB; +INSERT INTO t1 VALUES +(1,'v'), (7,'s'), (4,'l'), (7,'y'), (0,'c'), (2,'i'), (9,'h'), (4,'q'), +(0,'a'), (9,'v'), (1,'u'), (3,'s'), (8,'y'), (8,'z'), (18,'h'), (84,'p'), +(6,'e'), (3,'i'), (6,'y'), (6,'w'); +CREATE TABLE t2 ( +col_int_nokey int NOT NULL, +col_varchar_nokey varchar(1) NOT NULL +) charset utf8mb4 engine=InnoDB; +INSERT INTO t2 VALUES +(4,'j'), (6,'v'), (3,'c'), (5,'m'), (3,'d'), (246,'d'), (2,'y'), (9,'t'), +(3,'d'), (8,'s'), (1,'r'), (8,'m'), (8,'b'), (5,'x'), (7,'g'), (5,'p'), +(1,'q'), (6,'w'), (2,'d'), (9,'e'); +explain SELECT col_varchar_nokey +FROM t2 AS ot +WHERE col_varchar_nokey IN ( +SELECT col_varchar_key +FROM t1 AS it +WHERE it.col_int_nokey <= it.col_int_nokey +AND NOT ot.col_int_nokey < 2 +) +ORDER BY col_varchar_nokey; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 20 33.33 Parallel execute (1 workers) +2 SIMPLE ot NULL ALL NULL NULL NULL NULL 20 33.33 Using where; Using filesort +2 SIMPLE it NULL ref col_varchar_key col_varchar_key 6 test.ot.col_varchar_nokey 1 100.00 Start temporary; End temporary +Warnings: +Note 1276 Field or reference 'test.ot.col_int_nokey' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`ot`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t2` `ot` semi join (`test`.`t1` `it`) where ((`test`.`it`.`col_varchar_key` = `test`.`ot`.`col_varchar_nokey`) and (`test`.`ot`.`col_int_nokey` >= 2)) order by `test`.`ot`.`col_varchar_nokey` +SELECT col_varchar_nokey +FROM t2 AS ot +WHERE col_varchar_nokey IN ( +SELECT col_varchar_key +FROM t1 AS it +WHERE it.col_int_nokey <= it.col_int_nokey +AND NOT ot.col_int_nokey < 2 +) +ORDER BY col_varchar_nokey; +col_varchar_nokey +c +e +p +s +v +w +y +ALTER TABLE t1 ENGINE=MyISAM; +ALTER TABLE t2 ENGINE=MyISAM; +explain SELECT col_varchar_nokey +FROM t2 AS ot +WHERE col_varchar_nokey IN ( +SELECT col_varchar_key +FROM t1 AS it +WHERE it.col_int_nokey <= it.col_int_nokey +AND NOT ot.col_int_nokey < 2 +) +ORDER BY col_varchar_nokey; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 20 33.33 Using where; Using filesort +1 SIMPLE it NULL ref col_varchar_key col_varchar_key 6 test.ot.col_varchar_nokey 2 100.00 Start temporary; End temporary +Warnings: +Note 1276 Field or reference 'test.ot.col_int_nokey' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`ot`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t2` `ot` semi join (`test`.`t1` `it`) where ((`test`.`it`.`col_varchar_key` = `test`.`ot`.`col_varchar_nokey`) and (`test`.`ot`.`col_int_nokey` >= 2)) order by `test`.`ot`.`col_varchar_nokey` +SELECT col_varchar_nokey +FROM t2 AS ot +WHERE col_varchar_nokey IN ( +SELECT col_varchar_key +FROM t1 AS it +WHERE it.col_int_nokey <= it.col_int_nokey +AND NOT ot.col_int_nokey < 2 +) +ORDER BY col_varchar_nokey; +col_varchar_nokey +c +e +p +s +v +w +y +ALTER TABLE t1 ENGINE=Memory; +ALTER TABLE t2 ENGINE=Memory; +explain SELECT col_varchar_nokey +FROM t2 AS ot +WHERE col_varchar_nokey IN ( +SELECT col_varchar_key +FROM t1 AS it +WHERE it.col_int_nokey <= it.col_int_nokey +AND NOT ot.col_int_nokey < 2 +) +ORDER BY col_varchar_nokey; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 20 33.33 Using where; Using filesort +1 SIMPLE it NULL ref col_varchar_key col_varchar_key 6 test.ot.col_varchar_nokey 2 100.00 Start temporary; End temporary +Warnings: +Note 1276 Field or reference 'test.ot.col_int_nokey' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`ot`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t2` `ot` semi join (`test`.`t1` `it`) where ((`test`.`it`.`col_varchar_key` = `test`.`ot`.`col_varchar_nokey`) and (`test`.`ot`.`col_int_nokey` >= 2)) order by `test`.`ot`.`col_varchar_nokey` +SELECT col_varchar_nokey +FROM t2 AS ot +WHERE col_varchar_nokey IN ( +SELECT col_varchar_key +FROM t1 AS it +WHERE it.col_int_nokey <= it.col_int_nokey +AND NOT ot.col_int_nokey < 2 +) +ORDER BY col_varchar_nokey; +col_varchar_nokey +c +e +p +s +v +w +y +DROP TABLE t1, t2; +# End of test for bug#13576391. +# +# Bug #13589848 "MISSING ROW ON SELECT WITH NESTED IN CLAUSES WHEN LOOSESCAN=ON" +# +CREATE TABLE t1 ( +id INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +KEY (col_varchar_key) +) charset utf8mb4; +INSERT INTO t1 VALUES (100,'m','m'), +(200,'b','b'), (300,'x','x'); +CREATE TABLE t2 ( +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +KEY (col_varchar_key) +) charset utf8mb4; +INSERT INTO t2 VALUES ('b','b'); +CREATE TABLE t3 ( +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +KEY (col_varchar_key) +) charset utf8mb4; +INSERT INTO t3 VALUES ('k','k'); +EXPLAIN SELECT gp1.id +FROM t1 AS gp1 JOIN t3 AS gp2 +ON gp2.col_varchar_key <> gp1.col_varchar_nokey +WHERE (gp1.col_varchar_nokey, gp1.col_varchar_nokey) +IN ( +SELECT col_varchar_nokey, col_varchar_nokey +FROM t1 +WHERE col_varchar_nokey +IN ( SELECT col_varchar_key +FROM t2 LEFT JOIN t3 USING (col_varchar_key) ) +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE gp2 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using where +1 SIMPLE gp1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +2 MATERIALIZED t2 NULL index col_varchar_key col_varchar_key 7 NULL 1 100.00 Using index +2 MATERIALIZED t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +2 MATERIALIZED t3 NULL ref col_varchar_key col_varchar_key 7 test.t2.col_varchar_key 2 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`gp1`.`id` AS `id` from `test`.`t1` `gp1` semi join (`test`.`t1` join `test`.`t2` left join `test`.`t3` on((`test`.`t2`.`col_varchar_key` = `test`.`t3`.`col_varchar_key`))) where ((``.`col_varchar_nokey` = ``.`col_varchar_nokey`) and (`test`.`gp1`.`col_varchar_nokey` = ``.`col_varchar_nokey`) and (`test`.`t1`.`col_varchar_nokey` = `test`.`t2`.`col_varchar_key`) and ('k' <> ``.`col_varchar_nokey`)) +SELECT gp1.id +FROM t1 AS gp1 JOIN t3 AS gp2 +ON gp2.col_varchar_key <> gp1.col_varchar_nokey +WHERE (gp1.col_varchar_nokey, gp1.col_varchar_nokey) +IN ( +SELECT col_varchar_nokey, col_varchar_nokey +FROM t1 +WHERE col_varchar_nokey +IN ( SELECT col_varchar_key +FROM t2 LEFT JOIN t3 USING (col_varchar_key) ) +) +; +id +200 +DROP TABLE t1,t2,t3; +# +# Bug #13596176: Missing row on select with nested in clause when +# matr=on and bnl=off + MyISAM +# +CREATE TABLE t1 ( +int_key int DEFAULT NULL, +vc_key varchar(1) DEFAULT NULL, +vc_nokey varchar(1) DEFAULT NULL, +KEY int_key (int_key), +KEY vc_key (vc_key, int_key) +) charset utf8mb4 ENGINE=MyISAM; +INSERT INTO t1 VALUES +(8,'x','x'), (7,'d','d'), (1,'r','r'), (7,'f','f'), +(9,'y','y'), (NULL,'u','u'), (1,'m','m'), (9,NULL,NULL), +(2,'o','o'), (9,'w','w'), (2,'m','m'), (4,'q','q'), +(0,NULL,NULL), (4,'d','d'), (8,'g','g'), (NULL,'x','x'), +(NULL,'f','f'), (0,'p','p'), (NULL,'j','j'), (8,'c','c'); +CREATE TABLE t2 ( +int_key int DEFAULT NULL, +vc_key varchar(1) DEFAULT NULL, +KEY int_key (int_key), +KEY vc_key (vc_key, int_key) +) charset utf8mb4 ENGINE=MyISAM; +INSERT INTO t2 VALUES (8,'g'); +explain SELECT vc_key +FROM t1 as outr +WHERE (vc_nokey, vc_key ) IN +(SELECT vc_nokey, vc_nokey +FROM t1 middle +WHERE vc_nokey IN +(SELECT child1.vc_key +FROM t2 AS child1 JOIN t1 AS child2 USING (int_key) +) +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using where +1 SIMPLE outr NULL ref vc_key vc_key 7 .vc_nokey 3 10.00 Using where +2 MATERIALIZED child1 NULL index int_key,vc_key vc_key 12 NULL 1 100.00 Using where; Using index +2 MATERIALIZED middle NULL ALL NULL NULL NULL NULL 20 10.00 Using where; Using join buffer (hash join) +2 MATERIALIZED child2 NULL ref int_key int_key 5 test.child1.int_key 3 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`outr`.`vc_key` AS `vc_key` from `test`.`t1` `outr` semi join (`test`.`t1` `middle` join `test`.`t2` `child1` join `test`.`t1` `child2`) where ((`test`.`child2`.`int_key` = `test`.`child1`.`int_key`) and (``.`vc_nokey` = ``.`vc_nokey`) and (`test`.`outr`.`vc_nokey` = ``.`vc_nokey`) and (`test`.`outr`.`vc_key` = ``.`vc_nokey`) and (`test`.`middle`.`vc_nokey` = `test`.`child1`.`vc_key`)) +SELECT vc_key +FROM t1 as outr +WHERE (vc_nokey, vc_key ) IN +(SELECT vc_nokey, vc_nokey +FROM t1 middle +WHERE vc_nokey IN +(SELECT child1.vc_key +FROM t2 AS child1 JOIN t1 AS child2 USING (int_key) +) +); +vc_key +g +DROP TABLE t1, t2; +# End of test for bug#13596176. +# +# BUG#11754478: MAX/MIN + SUBQUERY + AND FAILS TO RETURN ANY ROWS +# BUG#13599013: MAX/MIN + SUBQUERY IN WHERE CLAUSE MATCHING NO +# ROWS + INDEX DOES NOT RETURN NULL +# +CREATE TABLE t1 ( +pk int(11) PRIMARY KEY, +int_key int(11), +KEY int_key (int_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (1,0),(2,0),(3,2),(4,0),(5,3),(6,0); +SELECT MIN(int_key) FROM t1 WHERE (4, 4) IN (SELECT 1, 2); +MIN(int_key) +NULL +SELECT MIN(int_key) FROM t1 WHERE (4, 4) IN (SELECT 4, 4); +MIN(int_key) +0 +SELECT MIN(pk) FROM t1 WHERE pk IN (SELECT int_key FROM t1) AND pk = 6; +MIN(pk) +NULL +DROP TABLE t1; +# BUG#13726217: Crash in Item_ident::fix_after_pullout() +CREATE TABLE t1(a INTEGER) engine=innodb; +INSERT INTO t1 VALUES (0); +SELECT 0 +FROM t1 +WHERE 0 IN +(SELECT 0 +FROM t1 +WHERE 0 LIKE +(SELECT elt(a, 0) AS b +FROM t1 +GROUP BY a +HAVING b +) +); +0 +DROP TABLE t1; +# End of test for bug#13726217. +# BUG#13773979: Missing rows on second execution of prepared statement +CREATE TABLE t1 ( +col_int_nokey INT, +col_int_key INT, +col_varchar_key VARCHAR(1) +); +INSERT INTO t1 VALUES +(1,7,'v'), (7,0,'s'), (4,9,'l'), (7,3,'y'), +(2,2,'i'), (9,5,'h'), (0,1,'a'), (9,3,'v'); +CREATE VIEW v1 AS SELECT * FROM t1; +SELECT * +FROM t1 +WHERE col_int_key IN ( +SELECT alias1.col_int_nokey AS field1 +FROM v1 AS alias1 +WHERE alias1.col_varchar_key < 'v' +); +col_int_nokey col_int_key col_varchar_key +1 7 v +2 2 i +4 9 l +7 0 s +prepare stmt FROM "SELECT * +FROM t1 +WHERE col_int_key IN ( +SELECT alias1.col_int_nokey AS field1 +FROM v1 AS alias1 +WHERE alias1.col_varchar_key < 'v' +)"; +execute stmt; +col_int_nokey col_int_key col_varchar_key +1 7 v +2 2 i +4 9 l +7 0 s +execute stmt; +col_int_nokey col_int_key col_varchar_key +1 7 v +2 2 i +4 9 l +7 0 s +DEALLOCATE PREPARE stmt; +DROP VIEW v1; +DROP TABLE t1; +# End of test for bug#13773979. +# +# BUG#13685026 ASSERTION CUR_SJ_INNER_TABLES == 0 IN +# --OPTIMIZE_TABLE_ORDER::CHOOSE_TABLE_ORDER +# +CREATE TABLE t1 ( +col_int_key INT(11) NOT NULL, +col_datetime_key DATETIME NOT NULL, +col_varchar_key VARCHAR(1) NOT NULL, +col_varchar_nokey VARCHAR(1) NOT NULL, +KEY col_int_key (col_int_key), +KEY col_datetime_key (col_datetime_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (0,'2002-02-13 17:30:06','j','j'); +INSERT INTO t1 VALUES (8,'2008-09-27 00:34:58','v','v'); +CREATE TABLE t2 ( +col_int_key INT(11) NOT NULL, +col_datetime_key DATETIME NOT NULL, +col_varchar_key VARCHAR(1) NOT NULL, +col_varchar_nokey VARCHAR(1) NOT NULL, +KEY col_int_key (col_int_key), +KEY col_datetime_key (col_datetime_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (7,'2003-08-21 00:00:00','b','b'); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +SET @old_depth=@@optimizer_search_depth; +SET optimizer_search_depth=4; +EXPLAIN SELECT col_datetime_key +FROM t1 as outr +WHERE col_datetime_key IN ( +SELECT alias1.col_datetime_key +FROM t1 AS alias1 +LEFT JOIN t1 as alias3 +STRAIGHT_JOIN ( t2 AS alias4 +JOIN t1 AS alias5 +ON alias5.col_varchar_key <= alias4.col_varchar_nokey ) +ON alias5.col_int_key < alias4.col_int_key +ON alias5.col_varchar_key = alias4.col_varchar_key +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE outr NULL index col_datetime_key col_datetime_key 5 NULL 2 100.00 Using index +1 SIMPLE NULL eq_ref 5 test.outr.col_datetime_key 1 100.00 NULL +2 MATERIALIZED alias1 NULL index col_datetime_key col_datetime_key 5 NULL 2 100.00 Using index +2 MATERIALIZED alias4 NULL ALL col_int_key,col_varchar_key NULL NULL NULL 1 100.00 NULL +2 MATERIALIZED alias5 NULL ref col_int_key,col_varchar_key col_varchar_key 6 test.alias4.col_varchar_key 1 100.00 Using where; Using index +2 MATERIALIZED alias3 NULL index NULL col_int_key 4 NULL 2 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`outr`.`col_datetime_key` AS `col_datetime_key` from `test`.`t1` `outr` semi join (`test`.`t1` `alias1` left join (`test`.`t1` `alias3` join `test`.`t2` `alias4` join `test`.`t1` `alias5`) on(((`test`.`alias5`.`col_varchar_key` = `test`.`alias4`.`col_varchar_key`) and (`test`.`alias5`.`col_int_key` < `test`.`alias4`.`col_int_key`) and (`test`.`alias5`.`col_varchar_key` <= `test`.`alias4`.`col_varchar_nokey`)))) where (``.`col_datetime_key` = `test`.`outr`.`col_datetime_key`) +SELECT col_datetime_key +FROM t1 as outr +WHERE col_datetime_key IN ( +SELECT alias1.col_datetime_key +FROM t1 AS alias1 +LEFT JOIN t1 as alias3 +STRAIGHT_JOIN ( t2 AS alias4 +JOIN t1 AS alias5 +ON alias5.col_varchar_key <= alias4.col_varchar_nokey ) +ON alias5.col_int_key < alias4.col_int_key +ON alias5.col_varchar_key = alias4.col_varchar_key +); +col_datetime_key +2002-02-13 17:30:06 +2008-09-27 00:34:58 +DROP TABLE t1,t2; +SET @@optimizer_search_depth=@old_depth; +# +# BUG#13848789: SEGFAULT IN JOIN_READ_NEXT_SAME AT +# SQL/SQL_EXECUTOR.CC ON HAVING...IN...JOIN +# +CREATE TABLE t1 ( +col_int_key INT, +col_varchar_key VARCHAR(1), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4; +INSERT INTO t1 VALUES (8,'x'); +CREATE TABLE t2 ( +col_varchar_key VARCHAR(1), +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4; +INSERT INTO t2 VALUES ('x'), ('y'); +explain SELECT MIN(col_int_key) +FROM t1 as t1_outer +HAVING (1, 2) IN ( +SELECT t1_inner.col_int_key, MAX(t1_inner.col_int_key) +FROM t1 as t1_inner JOIN t2 +ON t2.col_varchar_key = t1_inner.col_varchar_key +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible HAVING +2 SUBQUERY t1_inner NULL system col_varchar_key NULL NULL NULL 1 100.00 NULL +2 SUBQUERY t2 NULL ref col_varchar_key col_varchar_key 7 const 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select min(`test`.`t1_outer`.`col_int_key`) AS `MIN(col_int_key)` from `test`.`t1` `t1_outer` having false +SELECT MIN(col_int_key) +FROM t1 as t1_outer +HAVING (1, 2) IN ( +SELECT t1_inner.col_int_key, MAX(t1_inner.col_int_key) +FROM t1 as t1_inner JOIN t2 +ON t2.col_varchar_key = t1_inner.col_varchar_key +); +MIN(col_int_key) +DROP TABLE t1,t2; +# Bug#13838810: Segfault in evaluate_null_complemented_join_record +CREATE TABLE t1 ( +pk int NOT NULL, +col_int_nokey int DEFAULT NULL, +col_int_key int DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t1 VALUES (10,NULL,8,'x'); +CREATE TABLE t2 ( +pk int NOT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +PRIMARY KEY (pk) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t2 VALUES (1,'x'); +CREATE TABLE t3 ( +pk int NOT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +PRIMARY KEY (pk), +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t3 VALUES +(1,'v','v'), (2,'v','v'), (3,'c','c'), (4,NULL,NULL); +EXPLAIN SELECT table1.pk,table2.pk, table3.pk +FROM t2 AS table1 +LEFT JOIN t1 AS table2 +LEFT JOIN t1 AS table3 +ON table3.col_int_key = table2.col_int_key +ON table3.pk = table2.col_int_nokey AND +table1.col_varchar_nokey IN ( +SELECT subquery3_t1.col_varchar_nokey +FROM t3 AS subquery3_t1 +LEFT JOIN t1 AS subquery3_t2 +ON subquery3_t2.col_varchar_key = subquery3_t1.col_varchar_key +WHERE subquery3_t2.col_int_nokey <> 9 +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE table1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE table2 NULL ALL col_int_key NULL NULL NULL 1 100.00 NULL +1 SIMPLE table3 NULL eq_ref PRIMARY,col_int_key PRIMARY 4 test.table2.col_int_nokey 1 100.00 Using where +1 SIMPLE NULL eq_ref 7 test.table1.col_varchar_nokey 1 100.00 NULL +2 MATERIALIZED subquery3_t2 NULL ALL col_varchar_key NULL NULL NULL 1 100.00 NULL +2 MATERIALIZED subquery3_t1 NULL ref col_varchar_key col_varchar_key 7 test.subquery3_t2.col_varchar_key 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`table1`.`pk` AS `pk`,`test`.`table2`.`pk` AS `pk`,`test`.`table3`.`pk` AS `pk` from `test`.`t2` `table1` left join (`test`.`t1` `table2` join `test`.`t1` `table3` semi join (`test`.`t3` `subquery3_t1` join `test`.`t1` `subquery3_t2`)) on(((`test`.`table3`.`col_int_key` = `test`.`table2`.`col_int_key`) and (`test`.`subquery3_t1`.`col_varchar_key` = `test`.`subquery3_t2`.`col_varchar_key`) and (``.`col_varchar_nokey` = `test`.`table1`.`col_varchar_nokey`) and (`test`.`table3`.`pk` = `test`.`table2`.`col_int_nokey`) and (`test`.`subquery3_t2`.`col_int_nokey` <> 9))) where true +SELECT table1.pk,table2.pk, table3.pk +FROM t2 AS table1 +LEFT JOIN t1 AS table2 +LEFT JOIN t1 AS table3 +ON table3.col_int_key = table2.col_int_key +ON table3.pk = table2.col_int_nokey AND +table1.col_varchar_nokey IN ( +SELECT subquery3_t1.col_varchar_nokey +FROM t3 AS subquery3_t1 +LEFT JOIN t1 AS subquery3_t2 +ON subquery3_t2.col_varchar_key = subquery3_t1.col_varchar_key +WHERE subquery3_t2.col_int_nokey <> 9 +) +; +pk pk pk +1 NULL NULL +DROP TABLE t1, t2, t3; +Extra test case for specific code coverage +CREATE TABLE t1(pk INTEGER); +INSERT INTO t1 VALUES(1), (2); +explain SELECT * +FROM t1 AS ot1 LEFT JOIN t1 AS ot2 +ON ot1.pk=ot2.pk AND +ot2.pk IN +(SELECT it1.pk +FROM t1 AS it1 LEFT JOIN t1 AS it2 ON it1.pk=it2.pk); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE NULL eq_ref 5 test.ot2.pk 1 100.00 Using where +2 MATERIALIZED it1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED it2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`pk` AS `pk`,`test`.`ot2`.`pk` AS `pk` from `test`.`t1` `ot1` left join (`test`.`t1` `ot2` semi join (`test`.`t1` `it1` left join `test`.`t1` `it2` on((`test`.`it1`.`pk` = `test`.`it2`.`pk`)))) on(((`test`.`ot2`.`pk` = `test`.`ot1`.`pk`) and (``.`pk` = `test`.`ot1`.`pk`))) where true +SELECT * +FROM t1 AS ot1 LEFT JOIN t1 AS ot2 +ON ot1.pk=ot2.pk AND +ot2.pk IN +(SELECT it1.pk +FROM t1 AS it1 LEFT JOIN t1 AS it2 ON it1.pk=it2.pk); +pk pk +1 1 +2 2 +DROP TABLE t1; +# End of test for bug#13838810. +# +# Bug#13845930: Segfault in st_join_table::and_with_condition +# +CREATE TABLE t1 ( +col_int INTEGER +); +CREATE TABLE t2 ( +col_varchar_1 VARCHAR(1), +col_varchar_2 VARCHAR(1) +); +INSERT INTO t2 VALUES ('x','x'), ('c','c'); +PREPARE stmt FROM ' +SELECT alias2.col_varchar_2 AS field1 +FROM t2 AS alias1 + JOIN + (t2 AS alias2 + LEFT JOIN t2 AS alias3 + ON (8, 92) IN + (SELECT sq1_alias1.col_int, + sq1_alias2.col_int + FROM t1 AS sq1_alias1 JOIN t1 AS sq1_alias2 + ) + ) + ON alias3.col_varchar_1 = alias2.col_varchar_2 +'; +EXECUTE stmt; +field1 + +EXECUTE stmt; +field1 +DEALLOCATE prepare stmt; +DROP TABLE t1, t2; +# End of test for bug#13845930. +# +# Bug#13855925: Assert 'prebuilt->search_tuple->n_fields > 0' +# in ha_innobase::index_read +# +CREATE TABLE t1 ( +pk INTEGER AUTO_INCREMENT, +col_int_nokey INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk), +KEY (col_varchar_key) +) charset utf8mb4 ENGINE=INNODB; +INSERT INTO t1 ( +col_int_key, col_int_nokey, +col_varchar_key, col_varchar_nokey +) VALUES +(4, 2, 'v','v'), (62, 150, 'v','v'), (7, NULL, 'c','c'), (1, 2, NULL, NULL), +(0, 5, 'x','x'), (7, 3, 'i','i'), (7, 1, 'e','e'), (1, 4, 'p','p'), +(7, NULL, 's','s'), (1, 2, 'j','j'), (5, 6, 'z','z'), (2, 6, 'c','c'), +(0, 8, 'a','a'), (1, 2, 'q','q'), (8, 6, 'y','y'), (1, 8, NULL, NULL), +(1, 3, 'r','r'), (9, 3, 'v','v'), (1, 9, NULL, NULL), (5, 6, 'r','r'); +CREATE TABLE t2 ( +pk INT AUTO_INCREMENT, +col_int_nokey INT, +col_int_key INT, +PRIMARY KEY (pk), +KEY (col_int_key) +) charset utf8mb4 AUTO_INCREMENT=10 ENGINE=INNODB; +INSERT INTO t2 (col_int_key, col_int_nokey) VALUES +(8, NULL), (7, 8), (1, 1), (7, 9), (9, 4), (NULL, 3), (1, 2), (9, NULL), +(2, 2), (9, NULL), (2, 6), (4, 7), (0, 2), (4, 5), (8, 7), (NULL, 6), +(NULL, 6), (0, 2), (NULL, 9), (8, 6); +CREATE TABLE t3 ( +pk INT AUTO_INCREMENT, +col_varchar_key VARCHAR(1), +PRIMARY KEY (pk), +KEY (col_varchar_key) +) charset utf8mb4 ENGINE=INNODB; +INSERT INTO t3 (col_varchar_key) VALUES +('c'), ('c'), ('q'), ('g'), ('e'), ('l'), (NULL), ('c'), ('h'), ('d'), +('c'), ('i'), ('t'), ('g'), ('q'), ('l'), ('n'), ('z'), ('n'), ('r'), ('p'); +CREATE VIEW v1 AS +SELECT table2.col_varchar_nokey AS field1 +FROM t2 AS table1 +INNER JOIN (t1 AS table2 +STRAIGHT_JOIN t2 AS table3 +ON table3.col_int_key = table2.pk AND +table3.col_int_nokey = ANY +(SELECT subquery1_t2.col_int_nokey AS subquery1_field1 +FROM t2 AS subquery1_t1 +RIGHT OUTER JOIN t1 AS subquery1_t2 +INNER JOIN t1 AS subquery1_t3 +ON subquery1_t3.col_int_key = subquery1_t2.pk +ON subquery1_t3.col_varchar_key=subquery1_t2.col_varchar_nokey +WHERE subquery1_t1.pk > 1 +) +) +ON table3.col_int_key IN +(SELECT subquery2_t1.col_int_key AS subquery2_field1 +FROM t2 AS subquery2_t1 +RIGHT OUTER JOIN t3 AS subquery2_t2 +LEFT OUTER JOIN t1 AS subquery2_t3 +ON subquery2_t3.col_varchar_key = subquery2_t2.col_varchar_key +ON subquery2_t3.pk = subquery2_t2.pk +) +; +explain SELECT * FROM v1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE table1 NULL index NULL col_int_key 5 NULL 20 100.00 Using index +1 SIMPLE table2 NULL ALL PRIMARY NULL NULL NULL 20 100.00 Using join buffer (hash join) +1 SIMPLE table3 NULL ref col_int_key col_int_key 5 test.table2.pk 2 100.00 Using where +1 SIMPLE NULL eq_ref 5 test.table3.col_int_nokey 1 100.00 NULL +1 SIMPLE NULL eq_ref 5 test.table2.pk 1 100.00 NULL +4 MATERIALIZED subquery1_t3 NULL ALL col_varchar_key NULL NULL NULL 20 100.00 Using where +4 MATERIALIZED subquery1_t2 NULL eq_ref PRIMARY PRIMARY 4 test.subquery1_t3.col_int_key 1 10.00 Using where +4 MATERIALIZED subquery1_t1 NULL index PRIMARY col_int_key 5 NULL 20 100.00 Using where; Using index; Using join buffer (hash join) +3 MATERIALIZED subquery2_t3 NULL index PRIMARY,col_varchar_key col_varchar_key 7 NULL 20 100.00 Using where; Using index +3 MATERIALIZED subquery2_t2 NULL eq_ref PRIMARY,col_varchar_key PRIMARY 4 test.subquery2_t3.pk 1 7.14 Using where +3 MATERIALIZED subquery2_t1 NULL index col_int_key col_int_key 5 NULL 20 100.00 Using index; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `table2`.`col_varchar_nokey` AS `field1` from `test`.`t2` `table1` join `test`.`t1` `table2` straight_join `test`.`t2` `table3` semi join (`test`.`t1` `subquery1_t2` join `test`.`t1` `subquery1_t3` join `test`.`t2` `subquery1_t1`) semi join (`test`.`t3` `subquery2_t2` join `test`.`t1` `subquery2_t3` join `test`.`t2` `subquery2_t1`) where ((`subquery1_t2`.`pk` = `subquery1_t3`.`col_int_key`) and (`subquery1_t2`.`col_varchar_nokey` = `subquery1_t3`.`col_varchar_key`) and (`subquery2_t2`.`col_varchar_key` = `subquery2_t3`.`col_varchar_key`) and (`subquery2_t2`.`pk` = `subquery2_t3`.`pk`) and (`table3`.`col_int_key` = `table2`.`pk`) and (``.`subquery2_field1` = `table2`.`pk`) and (``.`subquery1_field1` = `table3`.`col_int_nokey`) and (`subquery1_t1`.`pk` > 1)) +SELECT * FROM v1; +field1 +v +v +v +v +v +v +v +v +v +v +v +v +v +v +v +v +v +v +v +v +DROP VIEW v1; +DROP TABLE t1,t2,t3; +# End of test for bug#13855925. +# +# Bug#13897959: Segfault in setup_semijoin_dups_elimination() +# +CREATE TABLE t1 ( +col_datetime_key DATETIME DEFAULT NULL, +KEY col_datetime_key (col_datetime_key) +) ENGINE=MyISAM; +INSERT INTO t1 VALUES +('2001-04-18 00:00:00'), ('2008-12-18 19:39:55'), +('2000-08-01 12:19:39'), ('2004-09-25 21:29:06'), +('2009-09-20 09:11:48'), ('2004-03-27 09:32:04'); +CREATE TABLE t2 ( +col_date_nokey date DEFAULT NULL, +col_time_key time DEFAULT NULL, +col_datetime_key datetime DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +KEY col_time_key (col_time_key), +KEY col_datetime_key (col_datetime_key), +KEY col_varchar_key(col_varchar_key) +) ENGINE=MyISAM; +INSERT INTO t2 VALUES ('1900-01-01',NULL,'2001-11-04 19:07:55','x','x'); +SELECT grandparent1.col_varchar_nokey +FROM t2 AS grandparent1 LEFT JOIN t1 USING (col_datetime_key) +WHERE grandparent1.col_varchar_nokey IN ( +SELECT col_varchar_nokey +FROM t2 AS parent1 +WHERE parent1.col_time_key > grandparent1.col_date_nokey +); +col_varchar_nokey +DROP TABLE t1, t2; +# End of test for bug#13897959. +# +# Bug#13898625 ASSERT `(REMAINING_TABLES_AFTER != 0) ...' IN +# BEST_EXTENSION_BY_LIMITED_SEARCH +# +CREATE TABLE t1 ( +pk int(11) NOT NULL, +col_int_nokey INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (26,6,NULL,'f','f'); +INSERT INTO t1 VALUES (29,6,8,'c','c'); +CREATE TABLE t2 ( +pk INT NOT NULL, +col_int_nokey INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +INSERT INTO t2 VALUES (1,2,4,'v','v'); +INSERT INTO t2 VALUES (2,150,62,'v','v'); +INSERT INTO t2 VALUES (5,5,0,'x','x'); +INSERT INTO t2 VALUES (6,3,7,'i','i'); +INSERT INTO t2 VALUES (7,1,7,'e','e'); +CREATE VIEW view_c AS SELECT * FROM t2; +PREPARE prep_stmt_7430 FROM 'SELECT SUM( alias1.col_varchar_key ) AS field1 +FROM t1 AS alias1 +RIGHT JOIN t2 AS alias2 +INNER JOIN t1 AS alias3 +ON (alias3.col_varchar_key = alias2.col_varchar_key ) +ON ( "v" ) IN ( +SELECT sq1_alias1.col_varchar_nokey AS sq1_field1 +FROM t1 AS sq1_alias1 +) +WHERE alias3.pk IN ( +SELECT sq2_alias1.col_int_key AS sq2_field1 +FROM ( view_c AS sq2_alias1, t1 AS sq2_alias2 ) +) +'; +EXECUTE prep_stmt_7430; +field1 +NULL +EXECUTE prep_stmt_7430; +field1 +NULL +EXPLAIN SELECT SUM( alias1.col_varchar_key ) AS field1 +FROM t1 AS alias1 +RIGHT JOIN t2 AS alias2 +INNER JOIN t1 AS alias3 +ON (alias3.col_varchar_key = alias2.col_varchar_key ) +ON ( "v" ) IN ( +SELECT sq1_alias1.col_varchar_nokey AS sq1_field1 +FROM t1 AS sq1_alias1 +) +WHERE alias3.pk IN ( +SELECT sq2_alias1.col_int_key AS sq2_field1 +FROM ( view_c AS sq2_alias1, t1 AS sq2_alias2 ) +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE alias3 NULL ALL PRIMARY,col_varchar_key NULL NULL NULL 2 100.00 Using where; Start temporary +1 SIMPLE alias2 NULL ref col_varchar_key col_varchar_key 7 test.alias3.col_varchar_key 2 100.00 Using index +1 SIMPLE sq1_alias1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +1 SIMPLE alias1 NULL index NULL col_varchar_key 12 NULL 2 100.00 Using index; End temporary; Using join buffer (hash join) +1 SIMPLE NULL eq_ref 5 test.alias3.pk 1 100.00 NULL +3 MATERIALIZED sq2_alias2 NULL index NULL PRIMARY 4 NULL 2 100.00 Using index +3 MATERIALIZED t2 NULL index col_int_key col_int_key 5 NULL 5 100.00 Using index; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select sum(`test`.`alias1`.`col_varchar_key`) AS `field1` from `test`.`t2` `alias2` join `test`.`t1` `alias3` left join (`test`.`t1` `alias1` semi join (`test`.`t1` `sq1_alias1`)) on(((`test`.`sq1_alias1`.`col_varchar_nokey` = 'v'))) semi join (`test`.`t2` join `test`.`t1` `sq2_alias2`) where ((`test`.`alias2`.`col_varchar_key` = `test`.`alias3`.`col_varchar_key`) and (``.`sq2_field1` = `test`.`alias3`.`pk`)) +PREPARE prep_stmt_7430 FROM 'SELECT SUM( alias1.col_varchar_key ) AS field1 +FROM t1 AS alias1 +RIGHT JOIN t2 AS alias2 +INNER JOIN t1 AS alias3 +ON (alias3.col_varchar_key = alias2.col_varchar_key ) +ON ( "v" ) IN ( +SELECT sq1_alias1.col_varchar_nokey AS sq1_field1 +FROM t1 AS sq1_alias1 +) +WHERE alias3.pk IN ( +SELECT sq2_alias1.col_int_key AS sq2_field1 +FROM ( view_c AS sq2_alias1 , t1 AS sq2_alias2 ) +WHERE sq2_alias1.col_varchar_nokey <> alias2.col_varchar_key +AND sq2_alias1.col_varchar_key < "l" + ) +'; +EXECUTE prep_stmt_7430; +field1 +NULL +EXECUTE prep_stmt_7430; +field1 +NULL +EXPLAIN SELECT SUM( alias1.col_varchar_key ) AS field1 +FROM t1 AS alias1 +RIGHT JOIN t2 AS alias2 +INNER JOIN t1 AS alias3 +ON (alias3.col_varchar_key = alias2.col_varchar_key ) +ON ( "v" ) IN ( +SELECT sq1_alias1.col_varchar_nokey AS sq1_field1 +FROM t1 AS sq1_alias1 +) +WHERE alias3.pk IN ( +SELECT sq2_alias1.col_int_key AS sq2_field1 +FROM ( view_c AS sq2_alias1 , t1 AS sq2_alias2 ) +WHERE sq2_alias1.col_varchar_nokey <> alias2.col_varchar_key +AND sq2_alias1.col_varchar_key < "l" + ) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE alias3 NULL ALL PRIMARY,col_varchar_key NULL NULL NULL 2 100.00 Using where; Start temporary +1 SIMPLE t2 NULL ref col_int_key,col_varchar_key col_int_key 5 test.alias3.pk 2 40.00 Using where +1 SIMPLE alias2 NULL ref col_varchar_key col_varchar_key 7 test.alias3.col_varchar_key 2 100.00 Using index +1 SIMPLE sq2_alias2 NULL index NULL PRIMARY 4 NULL 2 100.00 Using index; Using join buffer (hash join) +1 SIMPLE sq1_alias1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +1 SIMPLE alias1 NULL index NULL col_varchar_key 12 NULL 2 100.00 Using index; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.alias2.col_varchar_key' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select sum(`test`.`alias1`.`col_varchar_key`) AS `field1` from `test`.`t2` `alias2` join `test`.`t1` `alias3` left join (`test`.`t1` `alias1` semi join (`test`.`t1` `sq1_alias1`)) on(((`test`.`sq1_alias1`.`col_varchar_nokey` = 'v'))) semi join (`test`.`t2` join `test`.`t1` `sq2_alias2`) where ((`test`.`alias2`.`col_varchar_key` = `test`.`alias3`.`col_varchar_key`) and (`test`.`t2`.`col_int_key` = `test`.`alias3`.`pk`) and (`test`.`t2`.`col_varchar_nokey` <> `test`.`alias3`.`col_varchar_key`) and (`test`.`t2`.`col_varchar_key` < 'l')) +DROP TABLE t1,t2; +DROP VIEW view_c; +# +# Bug#13902463 SEGFAULT IN BITMAP<64U>::MERGE OR ADD_KEY_FIELD +# ON SECOND EXEC OF PREP STMT +# +CREATE TABLE t1 ( +pk INT, +col_int_nokey INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +KEY col_varchar_key (col_varchar_key) +); +CREATE VIEW view_b AS SELECT * FROM t1; +PREPARE prep_stmt_20421 FROM 'SELECT alias2.col_varchar_nokey AS field1 +FROM t1 AS alias1 +INNER JOIN t1 AS alias2 +ON (alias1.col_varchar_key = alias2.col_varchar_nokey +AND ( alias1.col_int_key ) IN ( +SELECT t1.col_int_nokey +FROM t1 +) +) +WHERE alias1.col_varchar_key IN ( +SELECT sq2_alias2.col_varchar_nokey AS sq2_field1 +FROM view_b AS sq2_alias1 +INNER JOIN t1 AS sq2_alias2 +ON (sq2_alias2.col_varchar_key = sq2_alias1.col_varchar_key ) +WHERE sq2_alias1.pk > alias2.pk +) +'; +EXECUTE prep_stmt_20421; +field1 +EXECUTE prep_stmt_20421; +field1 +EXPLAIN SELECT alias2.col_varchar_nokey AS field1 +FROM t1 AS alias1 +INNER JOIN t1 AS alias2 +ON (alias1.col_varchar_key = alias2.col_varchar_nokey +AND ( alias1.col_int_key ) IN ( +SELECT t1.col_int_nokey +FROM t1 +) +) +WHERE alias1.col_varchar_key IN ( +SELECT sq2_alias2.col_varchar_nokey AS sq2_field1 +FROM view_b AS sq2_alias1 +INNER JOIN t1 AS sq2_alias2 +ON (sq2_alias2.col_varchar_key = sq2_alias1.col_varchar_key ) +WHERE sq2_alias1.pk > alias2.pk +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.alias2.pk' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `field1` from `test`.`t1` `alias1` join `test`.`t1` `alias2` semi join (`test`.`t1`) semi join (`test`.`t1` join `test`.`t1` `sq2_alias2`) where ((`test`.`t1`.`pk` > NULL) and multiple equal(NULL, `test`.`sq2_alias2`.`col_varchar_nokey`, NULL) and multiple equal(`test`.`sq2_alias2`.`col_varchar_key`, `test`.`t1`.`col_varchar_key`) and multiple equal(NULL, `test`.`t1`.`col_int_nokey`)) +ALTER TABLE t1 DROP INDEX col_varchar_key; +PREPARE prep_stmt_20421 FROM 'SELECT alias2.col_varchar_nokey AS field1 +FROM t1 AS alias1 +INNER JOIN t1 AS alias2 +ON (alias1.col_varchar_key = alias2.col_varchar_nokey +AND ( alias1.col_int_key ) IN ( +SELECT t1.col_int_nokey +FROM t1 +) +) +WHERE alias1.col_varchar_key IN ( +SELECT sq2_alias2.col_varchar_nokey AS sq2_field1 +FROM view_b AS sq2_alias1 +INNER JOIN t1 AS sq2_alias2 +ON (sq2_alias2.col_varchar_key = sq2_alias1.col_varchar_key ) +WHERE sq2_alias1.pk > alias2.pk +) +'; +EXECUTE prep_stmt_20421; +field1 +EXECUTE prep_stmt_20421; +field1 +EXPLAIN SELECT alias2.col_varchar_nokey AS field1 +FROM t1 AS alias1 +INNER JOIN t1 AS alias2 +ON (alias1.col_varchar_key = alias2.col_varchar_nokey +AND ( alias1.col_int_key ) IN ( +SELECT t1.col_int_nokey +FROM t1 +) +) +WHERE alias1.col_varchar_key IN ( +SELECT sq2_alias2.col_varchar_nokey AS sq2_field1 +FROM view_b AS sq2_alias1 +INNER JOIN t1 AS sq2_alias2 +ON (sq2_alias2.col_varchar_key = sq2_alias1.col_varchar_key ) +WHERE sq2_alias1.pk > alias2.pk +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.alias2.pk' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `field1` from `test`.`t1` `alias1` join `test`.`t1` `alias2` semi join (`test`.`t1`) semi join (`test`.`t1` join `test`.`t1` `sq2_alias2`) where ((`test`.`t1`.`pk` > NULL) and multiple equal(NULL, `test`.`sq2_alias2`.`col_varchar_nokey`, NULL) and multiple equal(`test`.`sq2_alias2`.`col_varchar_key`, `test`.`t1`.`col_varchar_key`) and multiple equal(NULL, `test`.`t1`.`col_int_nokey`)) +DROP TABLE t1; +DROP VIEW view_b; +# +# Bug#13907277: Segfault in evaluate_null_complemented_join_record +# +CREATE TABLE t1 ( +pk INTEGER, +col_varchar_nokey VARCHAR(1), +col_varchar_key VARCHAR(1), +PRIMARY KEY (pk) +); +INSERT INTO t1 VALUES (1, 'x', 'x'); +CREATE TABLE t2 ( +pk INTEGER, +PRIMARY KEY (pk) +); +INSERT INTO t2 VALUES (1); +CREATE TABLE t3 ( +pk INTEGER, +col_int_nokey INTEGER, +col_int_key INTEGER, +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk) +); +INSERT INTO t3 VALUES (1, 6, 5, 'r'); +explain SELECT outer_t1.pk, outer_t2.pk +FROM t3 AS outer_t1 +RIGHT JOIN t2 AS outer_t2 +ON outer_t1.col_int_nokey IN +(SELECT inner_t1.col_int_nokey +FROM t3 AS inner_t1 +LEFT JOIN t1 AS inner_t2 +INNER JOIN t1 AS inner_t3 +ON inner_t3.pk = inner_t2.pk +ON inner_t3.col_varchar_nokey = inner_t2.col_varchar_key +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE outer_t2 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE outer_t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL eq_ref 5 test.outer_t1.col_int_nokey 1 100.00 NULL +2 MATERIALIZED inner_t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 MATERIALIZED inner_t2 NULL ALL PRIMARY NULL NULL NULL 1 100.00 NULL +2 MATERIALIZED inner_t3 NULL eq_ref PRIMARY PRIMARY 4 test.inner_t2.pk 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`outer_t1`.`pk` AS `pk`,'1' AS `pk` from left join (`test`.`t3` `outer_t1` semi join (`test`.`t3` `inner_t1` left join (`test`.`t1` `inner_t2` join `test`.`t1` `inner_t3`) on(((`test`.`inner_t3`.`col_varchar_nokey` = `test`.`inner_t2`.`col_varchar_key`) and (`test`.`inner_t3`.`pk` = `test`.`inner_t2`.`pk`))))) on(((``.`col_int_nokey` = `test`.`outer_t1`.`col_int_nokey`))) where true +SELECT outer_t1.pk, outer_t2.pk +FROM t3 AS outer_t1 +RIGHT JOIN t2 AS outer_t2 +ON outer_t1.col_int_nokey IN +(SELECT inner_t1.col_int_nokey +FROM t3 AS inner_t1 +LEFT JOIN t1 AS inner_t2 +INNER JOIN t1 AS inner_t3 +ON inner_t3.pk = inner_t2.pk +ON inner_t3.col_varchar_nokey = inner_t2.col_varchar_key +); +pk pk +1 1 +DROP TABLE t1, t2, t3; +# End of test for bug#13907277. +# +# Bug#13955713: Assert 'JOIN->best_read < ...' on second execution +# +CREATE TABLE t1 ( +pk INTEGER, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1) +); +PREPARE stmt FROM " +SELECT MIN(alias2.col_varchar_key) AS field1 +FROM t1 AS alias1 + INNER JOIN (t1 AS alias2 + INNER JOIN t1 AS alias3 + ON 8 IN + (SELECT sq1_alias1.pk AS sq1_field2 + FROM t1 AS sq1_alias1 + WHERE 9 IN + (SELECT SUM(t1_sq1_alias1.pk) AS t1_sq1_field2 + FROM t1 AS t1_sq1_alias1 + ) + ) + ) + ON alias3.col_varchar_nokey = alias2.col_varchar_key +WHERE EXISTS + (SELECT sq2_alias1.pk AS sq2_field1 + FROM t1 AS sq2_alias1 + WHERE sq2_alias1.col_varchar_key < alias1.col_varchar_nokey + ) +"; +EXECUTE stmt; +field1 +NULL + +EXECUTE stmt; +field1 +NULL +DEALLOCATE PREPARE stmt; +DROP TABLE t1; +# End of test for bug#13955713. +# +# Bug#13956813: Segfault in memcpy from Join_cache::write_record_data() +# +CREATE TABLE t1 ( +pk INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1) +) charset latin1; +CREATE TABLE t2 ( +pk INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1) +) charset latin1; +INSERT INTO t2 VALUES +(10,'j','j'), (11,'z','z'), (12,'c','c'), (13,'a','a'), +(14,'q','q'), (15,'y','y'), (16,NULL,NULL), (17,'r','r'), +(18,'v','v'), (19,NULL,NULL), (20,'r','r'); +CREATE TABLE t3 ( +pk INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +KEY col_int_key (col_int_key) +) charset latin1; +INSERT INTO t3 VALUES +(15,NULL,'u'), (16,1,'m'), (17,9,NULL), (18,2,'o'), +(19,9,'w'), (20,2,'m'), (21,4,'q'), (22,0,NULL), +(23,4,'d'), (24,8,'g'), (25,NULL,'x'), (26,NULL,'f'), +(27,0,'p'), (28,NULL,'j'), (29,8,'c'); +CREATE VIEW view_inline_0 AS +SELECT t1.* +FROM t1 INNER JOIN t3 +ON t1.pk = t3.pk; +CREATE VIEW view_inline_1 AS +SELECT sq2_alias2.col_varchar_key AS sq2_field1, +sq2_alias1.col_varchar_key AS sq2_field2 +FROM t3 AS sq2_alias1 LEFT OUTER JOIN t3 AS sq2_alias2 +ON sq2_alias1.pk = sq2_alias2.col_int_key; +CREATE VIEW view_inline_2 AS +SELECT 'p', 'p' UNION SELECT 'k', 's'; +SET @optimizer_switch_saved= @@optimizer_switch; +SET @@optimizer_switch="derived_merge=off"; +explain SELECT SUM(alias1.col_varchar_nokey) AS field2 +FROM t2 AS alias2 +LEFT JOIN (SELECT * FROM view_inline_0) AS alias1 +ON alias2.col_varchar_key = alias1.col_varchar_key AND +(alias2.col_varchar_nokey, alias2.col_varchar_key) IN +(SELECT * FROM view_inline_1 +) +WHERE (alias1.col_varchar_key, alias1.col_varchar_nokey) IN +(SELECT * FROM view_inline_2 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL 2 100.00 NULL +1 PRIMARY alias2 NULL ALL NULL NULL NULL NULL 11 10.00 Using where; Using join buffer (hash join) +1 PRIMARY NULL eq_ref 8 test.alias2.col_varchar_nokey,test.view_inline_2.p 1 100.00 NULL +1 PRIMARY NULL ref 8 test.view_inline_2.p,test.view_inline_2.Name_exp_p 2 100.00 NULL +3 MATERIALIZED NULL ALL NULL NULL NULL NULL 30 100.00 NULL +7 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +8 UNION NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +NULL UNION RESULT NULL ALL NULL NULL NULL NULL NULL NULL Using temporary +6 DERIVED sq2_alias1 NULL ALL NULL NULL NULL NULL 15 100.00 NULL +6 DERIVED sq2_alias2 NULL ref col_int_key col_int_key 5 test.sq2_alias1.pk 2 100.00 NULL +2 DERIVED NULL ALL NULL NULL NULL NULL 15 100.00 NULL +5 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select sum(`alias1`.`col_varchar_nokey`) AS `field2` from `test`.`view_inline_2` join `test`.`t2` `alias2` join (/* select#2 */ select `test`.`view_inline_0`.`pk` AS `pk`,`test`.`view_inline_0`.`col_varchar_key` AS `col_varchar_key`,`test`.`view_inline_0`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`view_inline_0`) `alias1` semi join (`test`.`view_inline_1`) where ((``.`sq2_field1` = `test`.`alias2`.`col_varchar_nokey`) and (`alias1`.`col_varchar_nokey` = `test`.`view_inline_2`.`Name_exp_p`) and (`test`.`alias2`.`col_varchar_key` = `test`.`view_inline_2`.`p`) and (``.`sq2_field2` = `test`.`view_inline_2`.`p`) and (`alias1`.`col_varchar_key` = `test`.`view_inline_2`.`p`)) +SELECT SUM(alias1.col_varchar_nokey) AS field2 +FROM t2 AS alias2 +LEFT JOIN (SELECT * FROM view_inline_0) AS alias1 +ON alias2.col_varchar_key = alias1.col_varchar_key AND +(alias2.col_varchar_nokey, alias2.col_varchar_key) IN +(SELECT * FROM view_inline_1 +) +WHERE (alias1.col_varchar_key, alias1.col_varchar_nokey) IN +(SELECT * FROM view_inline_2 +); +field2 +NULL +SET @@optimizer_switch= @optimizer_switch_saved; +DROP VIEW view_inline_0, view_inline_1, view_inline_2; +DROP TABLE t1, t2, t3; +# End of test for bug#13956813. +# +# Bug#13974177: Assert !(tab->table->regginfo.not_exists_optimize... +# +CREATE TABLE t1 ( +pk INTEGER AUTO_INCREMENT, +col_int_nokey INTEGER, +col_int_key INTEGER, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk), +KEY (col_int_key), +KEY (col_varchar_key, col_int_key) +); +INSERT INTO t1(col_int_key, col_int_nokey, col_varchar_key, col_varchar_nokey) +VALUES +(0, 4, 'j', 'j'), (8, 6, 'v', 'v'), (1, 3, 'c', 'c'), (8, 5, 'm', 'm'), +(9, 3, 'd', 'd'), (24, 246, 'd', 'd'), (6, 2, 'y', 'y'), (1, 9, 't', 't'), +(6, 3, 'd', 'd'), (2, 8, 's', 's'), (4, 1, 'r', 'r'), (8, 8, 'm', 'm'), +(4, 8, 'b', 'b'), (4, 5, 'x', 'x'), (7, 7, 'g', 'g'), (4, 5, 'p', 'p'), +(1, 1, 'q', 'q'), (9, 6, 'w', 'w'), (4, 2, 'd', 'd'), (8, 9, 'e', 'e'); +CREATE TABLE t2 ( +pk INTEGER AUTO_INCREMENT, +col_int_nokey INTEGER NOT NULL, +col_time_key TIME NOT NULL, +col_time_nokey TIME NOT NULL, +PRIMARY KEY (pk), +KEY (col_time_key) +) ENGINE=InnoDB; +INSERT INTO t2 (col_int_nokey, col_time_key, col_time_nokey) VALUES +(7, '00:00:00', '00:00:00'), (0, '00:00:00', '00:00:00'), +(9, '06:35:17', '06:35:17'), (3, '18:07:14', '18:07:14'), +(4, '20:36:52', '20:36:52'), (2, '21:29:07', '21:29:07'), +(5, '23:45:57', '23:45:57'), (3, '22:54:57', '22:54:57'), +(1, '18:45:09', '18:45:09'), (3, '14:30:46', '14:30:46'), +(6, '19:23:43', '19:23:43'), (7, '03:39:30', '03:39:30'), +(5, '23:37:52', '23:37:52'), (1, '16:59:30', '16:59:30'), +(204, '22:21:15', '22:21:15'), (224, '12:24:37', '12:24:37'), +(9, '15:02:08', '15:02:08'), (5, '23:59:59', '23:59:59'), +(0, '08:23:30', '08:23:30'), (3, '08:32:22', '08:32:22'); +explain SELECT ot1.col_int_key AS x +FROM t1 AS ot2 +LEFT JOIN t1 AS ot1 +ON ot2.col_varchar_nokey > ot1.col_varchar_key +WHERE (ot1.col_int_nokey, ot1.pk) IN +(SELECT it1.pk AS x, +it1.col_int_nokey AS y +FROM t2 AS it2 +LEFT JOIN t2 AS it1 +ON it2.col_time_nokey = it1.col_time_key +) AND ot1.pk IS NULL +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`col_int_key` AS `x` from `test`.`t2` `it1` join `test`.`t1` `ot2` join `test`.`t1` `ot1` semi join (`test`.`t2` `it2`) where ((`test`.`ot1`.`pk` is null) and (`test`.`ot2`.`col_varchar_nokey` > `test`.`ot1`.`col_varchar_key`) and multiple equal(`test`.`ot1`.`col_int_nokey`, `test`.`it1`.`pk`) and multiple equal(`test`.`ot1`.`pk`, `test`.`it1`.`col_int_nokey`) and multiple equal(`test`.`it2`.`col_time_nokey`, `test`.`it1`.`col_time_key`)) +SELECT ot1.col_int_key AS x +FROM t1 AS ot2 +LEFT JOIN t1 AS ot1 +ON ot2.col_varchar_nokey > ot1.col_varchar_key +WHERE (ot1.col_int_nokey, ot1.pk) IN +(SELECT it1.pk AS x, +it1.col_int_nokey AS y +FROM t2 AS it2 +LEFT JOIN t2 AS it1 +ON it2.col_time_nokey = it1.col_time_key +) AND ot1.pk IS NULL +; +x +DROP TABLE t1, t2; +# End of test for bug#13974177. +# +# Bug#13971022: Assert 'keyparts > 0' failed in create_ref_for_key... +# +CREATE TABLE t1 ( +pk INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +PRIMARY KEY (pk), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +CREATE TABLE t2 ( +pk INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk) +) charset utf8mb4 ENGINE=InnoDB; +CREATE TABLE t3 ( +i INT +); +SET @optimizer_switch_saved= @@optimizer_switch; +SET @@optimizer_switch="derived_merge=off"; +explain SELECT table1.pk AS field1 +FROM ( SELECT subquery1_t1. * +FROM t2 AS subquery1_t1 +JOIN t2 AS subquery1_t2 +ON subquery1_t2.pk = subquery1_t1.pk) AS table1 +STRAIGHT_JOIN t2 AS table2 +ON table1.col_int_key IN (SELECT 7 FROM t3) +WHERE table1.col_varchar_nokey IN +(SELECT subquery3_t1.col_varchar_key AS subquery3_field1 +FROM t1 AS subquery3_t1 +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL NULL 0.00 Using where +1 PRIMARY NULL ref 7 .subquery3_field1 2 100.00 NULL +1 PRIMARY NULL const 8 const 1 100.00 NULL +1 PRIMARY table2 NULL index NULL PRIMARY 4 NULL 1 100.00 Using index; Using join buffer (hash join) +4 MATERIALIZED subquery3_t1 NULL index col_varchar_key col_varchar_key 12 NULL 0 0.00 Using index +3 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 DERIVED subquery1_t1 NULL ALL PRIMARY NULL NULL NULL 1 100.00 Using where +2 DERIVED subquery1_t2 NULL eq_ref PRIMARY PRIMARY 4 test.subquery1_t1.pk 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `table1`.`pk` AS `field1` from (/* select#2 */ select `test`.`subquery1_t1`.`pk` AS `pk`,`test`.`subquery1_t1`.`col_int_key` AS `col_int_key`,`test`.`subquery1_t1`.`col_varchar_key` AS `col_varchar_key`,`test`.`subquery1_t1`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t2` `subquery1_t1` join `test`.`t2` `subquery1_t2` where ((`test`.`subquery1_t1`.`col_int_key` = 7) and (`test`.`subquery1_t2`.`pk` = `test`.`subquery1_t1`.`pk`))) `table1` straight_join `test`.`t2` `table2` semi join (`test`.`t3`) semi join (`test`.`t1` `subquery3_t1`) where (`table1`.`col_varchar_nokey` = ``.`subquery3_field1`) +SELECT table1.pk AS field1 +FROM ( SELECT subquery1_t1. * +FROM t2 AS subquery1_t1 +JOIN t2 AS subquery1_t2 +ON subquery1_t2.pk = subquery1_t1.pk) AS table1 +STRAIGHT_JOIN t2 AS table2 +ON table1.col_int_key IN (SELECT 7 FROM t3) +WHERE table1.col_varchar_nokey IN +(SELECT subquery3_t1.col_varchar_key AS subquery3_field1 +FROM t1 AS subquery3_t1 +) +; +field1 +SET @@optimizer_switch= @optimizer_switch_saved; +DROP TABLE t1, t2, t3; +# End of test for bug#13971022. +# +# Bug#13623473 "MISSING ROWS ON SELECT AND JOIN WITH +# TIME/DATETIME COMPARE" - Subquery part of test. +# +SET TIMESTAMP=UNIX_TIMESTAMP('2012-01-31 10:14:35'); +CREATE TABLE t1 ( +pk INT NOT NULL, +col_int_nokey INT, +col_int_key INT NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +) ENGINE=InnoDB; +INSERT INTO t1 VALUES (10,1,7), (11,7,0), (12,4,9), (13,7,3), +(14,0,4), (15,2,2), (16,9,5), (17,4,3), (18,0,1), (19,9,3), (20,1,6), +(21,3,7), (22,8,5), (23,8,1), (24,18,204), (25,84,224), (26,6,9), +(27,3,5), (28,6,0), (29,6,3); +CREATE TABLE t2 ( +col_int_nokey INT NOT NULL, +col_datetime_key DATETIME NOT NULL, +col_varchar_key VARCHAR(1) NOT NULL, +KEY col_datetime_key (col_datetime_key), +KEY col_varchar_key (col_varchar_key) +) ENGINE=InnoDB; +INSERT INTO t2 VALUES (1,'2001-11-04 19:07:55','k'); +CREATE TABLE t3 ( +col_time_key TIME, +KEY col_time_key (col_time_key) +) ENGINE=InnoDB; +INSERT INTO t3 VALUES ('21:22:34'), ('10:50:38'), ('00:21:38'), +('04:08:02'), ('16:25:11'), ('10:14:58'), ('19:47:59'), ('11:14:24'), +('00:00:00'), ('00:00:00'), ('15:57:25'), ('07:05:51'), ('19:22:21'), +('03:53:16'), ('09:16:38'), ('15:37:26'), ('00:00:00'), ('05:03:03'), +('02:59:24'), ('00:01:58'); +EXPLAIN SELECT outr.col_int_nokey +FROM t2 as outr +STRAIGHT_JOIN t3 AS outr2 +ON outr2.col_time_key > outr.col_datetime_key +WHERE outr.col_int_nokey IN ( +SELECT col_int_key +FROM t1 AS innr +WHERE innr.pk >= innr.col_int_nokey +) AND ( +outr.col_int_nokey <= 6 +OR +outr.col_varchar_key IS NULL +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE outr NULL ALL col_datetime_key NULL NULL NULL 1 100.00 Using where +1 SIMPLE NULL eq_ref 4 test.outr.col_int_nokey 1 100.00 NULL +1 SIMPLE outr2 NULL index col_time_key col_time_key 4 NULL 20 33.33 Using where; Using index; Using join buffer (hash join) +2 MATERIALIZED innr NULL ALL col_int_key NULL NULL NULL 20 23.33 Using where +Warnings: +Warning 1739 Cannot use range access on index 'col_time_key' due to type or collation conversion on field 'col_time_key' +Note 1003 /* select#1 */ select `test`.`outr`.`col_int_nokey` AS `col_int_nokey` from `test`.`t2` `outr` straight_join `test`.`t3` `outr2` semi join (`test`.`t1` `innr`) where ((``.`col_int_key` = `test`.`outr`.`col_int_nokey`) and (`test`.`outr`.`col_int_nokey` <= 6) and (`test`.`innr`.`pk` >= `test`.`innr`.`col_int_nokey`) and (cast(`test`.`outr2`.`col_time_key` as datetime) > `test`.`outr`.`col_datetime_key`)) +SELECT outr.col_int_nokey +FROM t2 as outr +STRAIGHT_JOIN t3 AS outr2 +ON outr2.col_time_key > outr.col_datetime_key +WHERE outr.col_int_nokey IN ( +SELECT col_int_key +FROM t1 AS innr +WHERE innr.pk >= innr.col_int_nokey +) AND ( +outr.col_int_nokey <= 6 +OR +outr.col_varchar_key IS NULL +); +col_int_nokey +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +DROP TABLE t1,t2,t3; +SET TIMESTAMP = DEFAULT; +# End of test for bug#13623473. +# +# Bug#13980954: Missing data on left join + null value + where..in +# +CREATE TABLE t1 ( +ik INT, +vc varchar(1) +) charset utf8mb4; +INSERT INTO t1 VALUES (8, 'x'), (NULL, 'x'); +CREATE TABLE t2 ( +ik INT, +vc varchar(1) +) charset utf8mb4; +INSERT INTO t2 VALUES +(0, 'x'), (7, 'i'), (7, 'e'), (1, 'p'), (7, 's'), (1, 'j'); +explain format=json SELECT t2.vc, t2.ik AS t2_ik, t1.ik AS t1_ik +FROM t2 LEFT JOIN t1 ON t2.vc=t1.vc +WHERE t2.vc IN (SELECT vc FROM t2 AS t3); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "6.12" + }, + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 6, + "rows_produced_per_join": 6, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "0.60", + "prefix_cost": "1.11", + "data_read_per_join": "96" + }, + "used_columns": [ + "ik", + "vc" + ], + "attached_condition": "(`test`.`t2`.`vc` is not null)" + } + }, + { + "table": { + "table_name": "", + "access_type": "eq_ref", + "key": "", + "key_length": "7", + "ref": [ + "test.t2.vc" + ], + "rows_examined_per_scan": 1, + "materialized_from_subquery": { + "using_temporary_table": true, + "query_block": { + "table": { + "table_name": "t3", + "access_type": "ALL", + "rows_examined_per_scan": 6, + "rows_produced_per_join": 6, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "0.60", + "prefix_cost": "1.11", + "data_read_per_join": "96" + }, + "used_columns": [ + "vc" + ] + } + } + } + } + }, + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 12, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "1.20", + "prefix_cost": "6.12", + "data_read_per_join": "192" + }, + "used_columns": [ + "ik", + "vc" + ], + "attached_condition": "(is_not_null_compl(t1), (`test`.`t1`.`vc` = `test`.`t2`.`vc`), true)" + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`vc` AS `vc`,`test`.`t2`.`ik` AS `t2_ik`,`test`.`t1`.`ik` AS `t1_ik` from `test`.`t2` left join `test`.`t1` on((`test`.`t1`.`vc` = `test`.`t2`.`vc`)) semi join (`test`.`t2` `t3`) where (``.`vc` = `test`.`t2`.`vc`) +SELECT t2.vc, t2.ik AS t2_ik, t1.ik AS t1_ik +FROM t2 LEFT JOIN t1 ON t2.vc=t1.vc +WHERE t2.vc IN (SELECT vc FROM t2 AS t3); +vc t2_ik t1_ik +e 7 NULL +i 7 NULL +j 1 NULL +p 1 NULL +s 7 NULL +x 0 8 +x 0 NULL +DROP TABLE t1, t2; +# End of test for bug#13980954. +# +# Bug#14048292: Segfault in Item_field::result_type on 2nd execution +# of prep stmt with join of view +# +CREATE TABLE t1 ( +col_int INT +); +INSERT INTO t1 VALUES (0), (1); +CREATE VIEW view_t1 AS SELECT * FROM t1; +explain SELECT alias1.col_int +FROM t1 AS alias1 +LEFT JOIN view_t1 AS alias2 +ON alias1.col_int IN +(SELECT sq1_alias1.col_int +FROM t1 AS sq1_alias1 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE alias1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE NULL eq_ref 5 test.alias1.col_int 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED sq1_alias1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`alias1`.`col_int` AS `col_int` from `test`.`t1` `alias1` left join (`test`.`t1` semi join (`test`.`t1` `sq1_alias1`)) on(((``.`col_int` = `test`.`alias1`.`col_int`))) where true +PREPARE stmt FROM "SELECT alias1.col_int +FROM t1 AS alias1 +LEFT JOIN view_t1 AS alias2 +ON alias1.col_int IN +(SELECT sq1_alias1.col_int +FROM t1 AS sq1_alias1 +)"; +EXECUTE stmt; +col_int +0 +0 +1 +1 + +EXECUTE stmt; +col_int +0 +0 +1 +1 +DEALLOCATE PREPARE stmt; +DROP VIEW view_t1; +DROP TABLE t1; +# End of test for bug#14048292. +# +# Bug#14064201: Missing data on join of derived table + WHERE .. IN +# with two operands +# +CREATE TABLE t1 ( +col_varchar_nokey VARCHAR(1) +) charset utf8mb4; +INSERT INTO t1 VALUES +('v'), ('s'), ('l'), ('y'), ('c'), ('i'), ('h'), ('q'), ('a'), ('v'), +('u'), ('s'), ('y'), ('z'), ('h'), ('p'), ('e'), ('i'), ('y'), ('w'); +CREATE TABLE t2 ( +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +KEY col_varchar_key(col_varchar_key) +) charset utf8mb4; +INSERT INTO t2 VALUES +('j','j'), ('v','v'), ('c','c'), ('m','m'), ('d','d'), ('d','d'), ('y','y'); +SET @optimizer_switch_saved= @@optimizer_switch; +SET @@optimizer_switch="derived_merge=off"; +explain format=json SELECT * +FROM (SELECT * FROM t2) AS derived1 +LEFT JOIN t1 +USING (col_varchar_nokey) +WHERE (col_varchar_nokey, col_varchar_nokey) IN +(SELECT col_varchar_nokey, col_varchar_key +FROM t2 AS derived2 +); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "13.03" + }, + "nested_loop": [ + { + "table": { + "table_name": "", + "access_type": "ALL", + "attached_condition": "((``.`col_varchar_key` = ``.`col_varchar_nokey`) and (``.`col_varchar_nokey` is not null))", + "materialized_from_subquery": { + "using_temporary_table": true, + "query_block": { + "table": { + "table_name": "derived2", + "access_type": "ALL", + "possible_keys": [ + "col_varchar_key" + ], + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "0.70", + "prefix_cost": "1.21", + "data_read_per_join": "112" + }, + "used_columns": [ + "col_varchar_key", + "col_varchar_nokey" + ], + "attached_condition": "(`test`.`derived2`.`col_varchar_key` = `test`.`derived2`.`col_varchar_nokey`)" + } + } + } + } + }, + { + "table": { + "table_name": "derived1", + "access_type": "ref", + "possible_keys": [ + "" + ], + "key": "", + "used_key_parts": [ + "col_varchar_nokey" + ], + "key_length": "7", + "ref": [ + ".col_varchar_nokey" + ], + "rows_examined_per_scan": 2, + "rows_produced_per_join": 2, + "filtered": "100.00", + "cost_info": { + "read_cost": "3.50", + "eval_cost": "0.20", + "prefix_cost": "8.51", + "data_read_per_join": "32" + }, + "used_columns": [ + "col_varchar_key", + "col_varchar_nokey" + ], + "materialized_from_subquery": { + "using_temporary_table": true, + "dependent": false, + "cacheable": true, + "query_block": { + "select_id": 2, + "cost_info": { + "query_cost": "1.21" + }, + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "0.70", + "prefix_cost": "1.21", + "data_read_per_join": "112" + }, + "used_columns": [ + "col_varchar_key", + "col_varchar_nokey" + ] + } + } + } + } + }, + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 40, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.52", + "eval_cost": "4.00", + "prefix_cost": "13.03", + "data_read_per_join": "320" + }, + "used_columns": [ + "col_varchar_nokey" + ], + "attached_condition": "(is_not_null_compl(t1), (`test`.`t1`.`col_varchar_nokey` = `derived1`.`col_varchar_nokey`), true)" + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select `derived1`.`col_varchar_nokey` AS `col_varchar_nokey`,`derived1`.`col_varchar_key` AS `col_varchar_key` from (/* select#2 */ select `test`.`t2`.`col_varchar_key` AS `col_varchar_key`,`test`.`t2`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t2`) `derived1` left join `test`.`t1` on(((`test`.`t1`.`col_varchar_nokey` = `derived1`.`col_varchar_nokey`) and (`test`.`derived2`.`col_varchar_nokey` = `test`.`derived2`.`col_varchar_key`))) semi join (`test`.`t2` `derived2`) where ((``.`col_varchar_key` = ``.`col_varchar_nokey`) and (`derived1`.`col_varchar_nokey` = ``.`col_varchar_nokey`) and (`test`.`derived2`.`col_varchar_key` = `test`.`derived2`.`col_varchar_nokey`)) +SELECT * +FROM (SELECT * FROM t2) AS derived1 +LEFT JOIN t1 +USING (col_varchar_nokey) +WHERE (col_varchar_nokey, col_varchar_nokey) IN +(SELECT col_varchar_nokey, col_varchar_key +FROM t2 AS derived2 +); +col_varchar_nokey col_varchar_key +c c +d d +d d +j j +m m +v v +v v +y y +y y +y y +SET @@optimizer_switch= @optimizer_switch_saved; +DROP TABLE t1, t2; +CREATE TABLE t1 ( +col_int_nokey int NOT NULL, +col_int_key int NOT NULL, +KEY col_int_key (col_int_key) +); +INSERT INTO t1 VALUES +(1,7), (7,0), (4,9), (7,3), (0,4), (2,2), (9,5), (4,3), (0,1), (9,3), +(1,6), (3,7), (8,5), (8,1), (18,204), (84,224), (6,9), (3,5), (6,0), (6,3); +CREATE TABLE t2 ( +col_int_nokey int NOT NULL, +col_int_key int NOT NULL, +KEY col_int_key (col_int_key) +); +INSERT INTO t2 VALUES +(4,0), (6,8), (3,1), (5,8), (3,9), (246,24), (2,6), (9,1), (3,6), (8,2), +(1,4), (8,8), (8,4), (5,4), (7,7), (5,4), (1,1), (6,9), (2,4), (9,8); +explain format=json SELECT grandparent1.* +FROM t1 AS grandparent1 +LEFT JOIN t1 USING (col_int_nokey) +WHERE (col_int_nokey, col_int_nokey) IN +(SELECT col_int_nokey, col_int_key +FROM t2 +); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "50.53" + }, + "nested_loop": [ + { + "table": { + "table_name": "grandparent1", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 20, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "2.00", + "prefix_cost": "2.51", + "data_read_per_join": "320" + }, + "used_columns": [ + "col_int_nokey", + "col_int_key" + ] + } + }, + { + "table": { + "table_name": "", + "access_type": "eq_ref", + "key": "", + "key_length": "8", + "ref": [ + "test.grandparent1.col_int_nokey", + "test.grandparent1.col_int_nokey" + ], + "rows_examined_per_scan": 1, + "materialized_from_subquery": { + "using_temporary_table": true, + "query_block": { + "table": { + "table_name": "t2", + "access_type": "ALL", + "possible_keys": [ + "col_int_key" + ], + "rows_examined_per_scan": 20, + "rows_produced_per_join": 20, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "2.00", + "prefix_cost": "2.51", + "data_read_per_join": "320" + }, + "used_columns": [ + "col_int_nokey", + "col_int_key" + ], + "attached_condition": "(`test`.`t2`.`col_int_key` = `test`.`t2`.`col_int_nokey`)" + } + } + } + } + }, + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 400, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "40.00", + "prefix_cost": "50.53", + "data_read_per_join": "6K" + }, + "used_columns": [ + "col_int_nokey" + ], + "attached_condition": "(is_not_null_compl(t1), (`test`.`t1`.`col_int_nokey` = `test`.`grandparent1`.`col_int_nokey`), true)" + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`grandparent1`.`col_int_nokey` AS `col_int_nokey`,`test`.`grandparent1`.`col_int_key` AS `col_int_key` from `test`.`t1` `grandparent1` left join `test`.`t1` on(((`test`.`t1`.`col_int_nokey` = `test`.`grandparent1`.`col_int_nokey`) and (`test`.`t2`.`col_int_nokey` = `test`.`t2`.`col_int_key`))) semi join (`test`.`t2`) where ((``.`col_int_nokey` = `test`.`grandparent1`.`col_int_nokey`) and (``.`col_int_key` = `test`.`grandparent1`.`col_int_nokey`) and (`test`.`t2`.`col_int_key` = `test`.`t2`.`col_int_nokey`)) +SELECT grandparent1.* +FROM t1 AS grandparent1 +LEFT JOIN t1 USING (col_int_nokey) +WHERE (col_int_nokey, col_int_nokey) IN +(SELECT col_int_nokey, col_int_key +FROM t2 +); +col_int_nokey col_int_key +1 6 +1 6 +1 7 +1 7 +7 0 +7 0 +7 3 +7 3 +8 1 +8 1 +8 5 +8 5 +DROP TABLE t1, t2; +CREATE TABLE t1 ( +pk int, +col_int_key int, +col_datetime_key datetime, +col_varchar_key varchar(1), +col_varchar_nokey varchar(1), +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_datetime_key (col_datetime_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4 engine=MyISAM; +INSERT INTO t1 VALUES +(10,7,'2004-06-06 04:22:12','v','v'), (11,0,'2005-11-13 01:12:31','s','s'), +(12,9,'2002-05-04 01:50:00','l','l'), (13,3,'2004-10-27 10:28:45','y','y'), +(14,4,'2006-07-22 05:24:23','c','c'), (15,2,'2002-05-16 21:34:03','i','i'), +(16,5,'2008-04-17 10:45:30','h','h'), (17,3,'2009-04-21 02:58:02','q','q'), +(18,1,'2008-01-11 11:01:51','a','a'), (19,3,'1900-01-01 00:00:00','v','v'), +(20,6,'2007-05-17 18:24:57','u','u'), (21,7,'2007-08-07 00:00:00','s','s'), +(22,5,'2001-08-28 00:00:00','y','y'), (23,1,'2004-04-16 00:27:28','z','z'), +(24,204,'2005-05-03 07:06:22','h','h'), (25,224,'2009-03-11 17:09:50','p','p'), +(26,9,'2007-12-08 01:54:28','e','e'), (27,5,'2009-07-28 18:19:54','i','i'), +(28,0,'2008-06-08 00:00:00','y','y'), (29,3,'2005-02-09 09:20:26','w','w'); +CREATE TABLE t2 ( +pk int, +col_int_key int, +col_datetime_key datetime, +col_varchar_key varchar(1), +col_varchar_nokey varchar(1), +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_datetime_key (col_datetime_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4 engine=MyISAM; +INSERT INTO t2 VALUES +(1,0,'2002-02-13 17:30:06','j','j'), (2,8,'2008-09-27 00:34:58','v','v'), +(3,1,'2007-05-28 00:00:00','c','c'), (4,8,'2009-07-25 09:21:20','m','m'), +(5,9,'2002-01-16 00:00:00','d','d'), (6,24,'2006-10-12 04:32:53','d','d'), +(7,6,'2001-02-15 03:08:38','y','y'), (8,1,'2004-10-02 20:31:15','t','t'), +(9,6,'2002-08-20 22:48:00','d','d'), (10,2,'1900-01-01 00:00:00','s','s'), +(11,4,'2005-08-15 00:00:00','r','r'), (12,8,'1900-01-01 00:00:00','m','m'), +(13,4,'2008-05-16 08:09:06','b','b'), (14,4,'2001-01-20 12:47:23','x','x'), +(15,7,'2008-07-02 00:00:00','g','g'), (16,4,'1900-01-01 00:00:00','p','p'), +(17,1,'2002-12-08 11:34:58','q','q'), (18,9,'1900-01-01 00:00:00','w','w'), +(19,4,'1900-01-01 00:00:00','d','d'), (20,8,'2002-08-25 20:35:06','e','e'); +SELECT alias1.col_datetime_key +FROM t2 AS alias1 +RIGHT JOIN t2 AS alias2 +JOIN t2 AS alias3 +ON alias3.pk = alias2.pk +ON alias3.col_varchar_nokey = alias2.col_varchar_key OR +alias2.col_varchar_nokey +WHERE (alias2.col_varchar_key, alias2.col_varchar_key) IN +(SELECT sq2_alias2.col_varchar_key, sq2_alias1.col_varchar_nokey +FROM t1 AS sq2_alias1, t1 AS sq2_alias2 +WHERE sq2_alias2.col_int_key < 2); +col_datetime_key +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +2001-01-20 12:47:23 +2001-01-20 12:47:23 +2001-02-15 03:08:38 +2001-02-15 03:08:38 +2002-01-16 00:00:00 +2002-01-16 00:00:00 +2002-02-13 17:30:06 +2002-02-13 17:30:06 +2002-08-20 22:48:00 +2002-08-20 22:48:00 +2002-08-25 20:35:06 +2002-08-25 20:35:06 +2002-12-08 11:34:58 +2002-12-08 11:34:58 +2004-10-02 20:31:15 +2004-10-02 20:31:15 +2005-08-15 00:00:00 +2005-08-15 00:00:00 +2006-10-12 04:32:53 +2006-10-12 04:32:53 +2007-05-28 00:00:00 +2007-05-28 00:00:00 +2008-05-16 08:09:06 +2008-05-16 08:09:06 +2008-07-02 00:00:00 +2008-07-02 00:00:00 +2008-09-27 00:34:58 +2008-09-27 00:34:58 +2009-07-25 09:21:20 +2009-07-25 09:21:20 +ALTER TABLE t1 DISABLE KEYS; +ALTER TABLE t2 DISABLE KEYS; +explain format=json SELECT alias1.col_datetime_key +FROM t2 AS alias1 +RIGHT JOIN t2 AS alias2 +JOIN t2 AS alias3 +ON alias3.pk = alias2.pk +ON alias3.col_varchar_nokey = alias2.col_varchar_key OR +alias2.col_varchar_nokey +WHERE (alias2.col_varchar_key, alias2.col_varchar_key) IN +(SELECT sq2_alias2.col_varchar_key, sq2_alias1.col_varchar_nokey +FROM t1 AS sq2_alias1, t1 AS sq2_alias2 +WHERE sq2_alias2.col_int_key < 2); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "52.48" + }, + "nested_loop": [ + { + "table": { + "table_name": "", + "access_type": "ALL", + "attached_condition": "(``.`col_varchar_nokey` = ``.`col_varchar_key`)", + "materialized_from_subquery": { + "using_temporary_table": true, + "query_block": { + "nested_loop": [ + { + "table": { + "table_name": "sq2_alias2", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 6, + "filtered": "33.33", + "cost_info": { + "read_cost": "1.86", + "eval_cost": "0.67", + "prefix_cost": "2.53", + "data_read_per_join": "213" + }, + "used_columns": [ + "col_int_key", + "col_varchar_key" + ], + "attached_condition": "(`test`.`sq2_alias2`.`col_int_key` < 2)" + } + }, + { + "table": { + "table_name": "sq2_alias1", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 13, + "filtered": "10.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.53", + "eval_cost": "1.33", + "prefix_cost": "16.39", + "data_read_per_join": "426" + }, + "used_columns": [ + "col_varchar_nokey" + ], + "attached_condition": "(`test`.`sq2_alias1`.`col_varchar_nokey` = `test`.`sq2_alias2`.`col_varchar_key`)" + } + } + ] + } + } + } + }, + { + "table": { + "table_name": "alias2", + "access_type": "ALL", + "possible_keys": [ + "PRIMARY" + ], + "rows_examined_per_scan": 20, + "rows_produced_per_join": 2, + "filtered": "10.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.53", + "eval_cost": "0.20", + "prefix_cost": "47.25", + "data_read_per_join": "64" + }, + "used_columns": [ + "pk", + "col_varchar_key", + "col_varchar_nokey" + ], + "attached_condition": "(`test`.`alias2`.`col_varchar_key` = ``.`col_varchar_key`)" + } + }, + { + "table": { + "table_name": "alias3", + "access_type": "eq_ref", + "possible_keys": [ + "PRIMARY" + ], + "key": "PRIMARY", + "used_key_parts": [ + "pk" + ], + "key_length": "4", + "ref": [ + "test.alias2.pk" + ], + "rows_examined_per_scan": 1, + "rows_produced_per_join": 2, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.20", + "prefix_cost": "47.95", + "data_read_per_join": "64" + }, + "used_columns": [ + "pk", + "col_varchar_nokey" + ] + } + }, + { + "table": { + "table_name": "alias1", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 40, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.53", + "eval_cost": "4.00", + "prefix_cost": "52.48", + "data_read_per_join": "1K" + }, + "used_columns": [ + "col_datetime_key" + ], + "attached_condition": "(is_not_null_compl(alias1), ((`test`.`alias3`.`col_varchar_nokey` = `test`.`alias2`.`col_varchar_key`) or (0 <> `test`.`alias2`.`col_varchar_nokey`)), true)" + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`alias1`.`col_datetime_key` AS `col_datetime_key` from `test`.`t2` `alias2` join `test`.`t2` `alias3` left join `test`.`t2` `alias1` on((((`test`.`alias3`.`col_varchar_nokey` = `test`.`alias2`.`col_varchar_key`) and (`test`.`sq2_alias1`.`col_varchar_nokey` = `test`.`sq2_alias2`.`col_varchar_key`)) or (0 <> `test`.`alias2`.`col_varchar_nokey`))) semi join (`test`.`t1` `sq2_alias1` join `test`.`t1` `sq2_alias2`) where ((`test`.`alias3`.`pk` = `test`.`alias2`.`pk`) and (``.`col_varchar_nokey` = ``.`col_varchar_key`) and (`test`.`alias2`.`col_varchar_key` = ``.`col_varchar_key`) and (`test`.`sq2_alias1`.`col_varchar_nokey` = `test`.`sq2_alias2`.`col_varchar_key`) and (`test`.`sq2_alias2`.`col_int_key` < 2)) +SELECT alias1.col_datetime_key +FROM t2 AS alias1 +RIGHT JOIN t2 AS alias2 +JOIN t2 AS alias3 +ON alias3.pk = alias2.pk +ON alias3.col_varchar_nokey = alias2.col_varchar_key OR +alias2.col_varchar_nokey +WHERE (alias2.col_varchar_key, alias2.col_varchar_key) IN +(SELECT sq2_alias2.col_varchar_key, sq2_alias1.col_varchar_nokey +FROM t1 AS sq2_alias1, t1 AS sq2_alias2 +WHERE sq2_alias2.col_int_key < 2); +col_datetime_key +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +2001-01-20 12:47:23 +2001-01-20 12:47:23 +2001-02-15 03:08:38 +2001-02-15 03:08:38 +2002-01-16 00:00:00 +2002-01-16 00:00:00 +2002-02-13 17:30:06 +2002-02-13 17:30:06 +2002-08-20 22:48:00 +2002-08-20 22:48:00 +2002-08-25 20:35:06 +2002-08-25 20:35:06 +2002-12-08 11:34:58 +2002-12-08 11:34:58 +2004-10-02 20:31:15 +2004-10-02 20:31:15 +2005-08-15 00:00:00 +2005-08-15 00:00:00 +2006-10-12 04:32:53 +2006-10-12 04:32:53 +2007-05-28 00:00:00 +2007-05-28 00:00:00 +2008-05-16 08:09:06 +2008-05-16 08:09:06 +2008-07-02 00:00:00 +2008-07-02 00:00:00 +2008-09-27 00:34:58 +2008-09-27 00:34:58 +2009-07-25 09:21:20 +2009-07-25 09:21:20 +DROP TABLE t1, t2; +# End of test for bug#14064201. +# +# Bug#18223655:ASSERTION FAILED: (INT)IDX >= 0 +# && IDX < PARENT_JOIN->TABLES +# +CREATE TABLE b (d INT); +CREATE TABLE c (a INT, b INT,c INT,d BLOB NOT NULL); +SELECT(SELECT 1 +FROM b WHERE(SELECT 1 IN (SELECT 1 FROM b WHERE 1 NOT BETWEEN d AND 1) +FROM b) IN (SELECT d FROM c)) as cc FROM b; +cc +INSERT INTO b VALUE(1); +INSERT INTO c VALUES(1,2,3,'1'),(2,3,4,'1'),(3,4,5,'C'); +SELECT(SELECT d FROM b WHERE(SELECT d IN +(SELECT d FROM b WHERE 1 NOT BETWEEN d AND 1) FROM b) IN +(SELECT d FROM c)) as cc FROM c; +cc +1 +1 +1 +DROP TABLE b,c; +# +# Bug#18447874:WRONG RESULT COMING FROM SEMI-JOIN +# +CREATE TABLE b ( +d INT(11) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE c ( +d BLOB +) ; +CREATE TABLE d ( +b INT(11) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO b VALUES(1),(2),(4); +INSERT INTO c VALUES(1),(2),(3); +SELECT 1 FROM b WHERE (SELECT 1 FROM d ) IN (SELECT d FROM c) ; +1 +INSERT INTO d VALUES(2); +SELECT 1 FROM b WHERE (SELECT 1 FROM d ) IN (SELECT d FROM c) ; +1 +1 +1 +1 +DROP TABLE b,c,d; +# +# Bug#17292723:INCORRECT RESULT FOR (SELECT...) IN (SELECT...) STATEMENT +# +CREATE TABLE t1 ( +ID int(11) NOT NULL AUTO_INCREMENT, +id2 int(11) DEFAULT NULL, +id3 int(11) DEFAULT NULL, +id4 varchar(150) COLLATE utf8_spanish_ci NOT NULL, +id5 int(11) DEFAULT NULL, +PRIMARY KEY (ID), +KEY id2 (id2), +KEY id3 (id3), +KEY id5 (id5) +) ENGINE=InnoDB; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 3778 'utf8_spanish_ci' is a collation of the deprecated character set UTF8MB3. Please consider using UTF8MB4 with an appropriate collation instead. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES +(123,1,1,'1',NULL), +(124,1,1,'2',NULL), +(125,1,1,'4',NULL), +(126,1,1,'3',NULL), +(127,1,1,'6',NULL), +(128,1,1,'8',NULL); +CREATE TABLE t2 ( +id6 int(11) NOT NULL, +id7 int(11) NOT NULL, +PRIMARY KEY (id6,id7), +KEY id7 (id7) +) ENGINE=InnoDB; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (126,123),(130,123),(135,123); +SELECT ID +FROM t1 p0 +WHERE p0.id3=1 +AND ( (SELECT p1.id FROM t1 p1 WHERE p1.id=123) IN (SELECT p3.id FROM t2 +p2, t1 p3 WHERE p0.id=p2.id6 AND p2.id7=p3.id)); +ID +126 +DROP TABLE t1,t2; +set @@optimizer_switch=@old_opt_switch; +# End of 5.6 tests +# +# Bug#19336348 DEBUG CRASH AT SETUP_SEMIJOIN_DUPS_ELIMINATION IN SQL/SQL_SELECT.CC +# +CREATE TABLE t1 ( +col_varchar_nokey varchar(1) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t1 VALUES ('c'),(NULL),('x'); +CREATE TABLE t2 ( +pk int, +col_varchar_key varchar(1), +PRIMARY KEY (pk), +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t2 VALUES (10,'l'),(11,'p'); +ANALYZE TABLE t1,t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN SELECT 1 +FROM t1 AS outr +WHERE outr.col_varchar_nokey IN +( +SELECT innr.col_varchar_key +FROM t2 AS innr +WHERE innr.pk <= 7 +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE outr NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +2 MATERIALIZED innr NULL range PRIMARY,col_varchar_key PRIMARY 4 NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` `outr` semi join (`test`.`t2` `innr`) where ((`test`.`outr`.`col_varchar_nokey` = ``.`col_varchar_key`) and (`test`.`innr`.`pk` <= 7)) +SELECT 1 +FROM t1 AS outr +WHERE outr.col_varchar_nokey IN +( +SELECT innr.col_varchar_key +FROM t2 AS innr +WHERE innr.pk <= 7 +) +; +1 +DROP TABLE t1,t2; +# +# Bug#18174394 BLOBS: CRASH AFTER UNINITIALIZED VALUES IN ITEM_FIELD::STR_RESULT +# +CREATE TABLE t1(d BLOB, b BLOB); +INSERT INTO t1(d,b) VALUES ('aaaa',''),('bnbb',''); +SELECT 1 FROM t1 +WHERE (SELECT b FROM t1) IN (SELECT (d>=1) FROM t1); +ERROR 21000: Subquery returns more than 1 row +DROP TABLE t1; +# +# Bug#19779600: ASSERT FAILED IN REPLACE_SUBCONDITION WITH IN +# PREDICATE INSIDE IN PREDICATE +# +CREATE TABLE t(X INT) ENGINE=InnoDB; +INSERT INTO t VALUES (1); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +EXPLAIN SELECT 1 FROM t WHERE (1 IN (SELECT 1 FROM t)) IN (SELECT 1 FROM t); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 PRIMARY NULL eq_ref 4 const 1 100.00 NULL +3 MATERIALIZED t NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SUBQUERY t NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t` semi join (`test`.`t`) where true +SELECT 1 FROM t WHERE (1 IN (SELECT 1 FROM t)) IN (SELECT 1 FROM t); +1 +1 +DROP TABLE t; +# +# Bug#19465034 ASSERT ON SETUP_SEMIJOIN_DUPS_ELIMINATION IN SQL/SQL_SELECT.CC +# +CREATE TABLE t1 ( +pk INTEGER NOT NULL, +i1 INTEGER NOT NULL, +PRIMARY KEY (pk) +) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1,1); +CREATE TABLE t2 ( +pk INTEGER NOT NULL, +c1 VARCHAR(1) NOT NULL, +PRIMARY KEY (pk), +KEY c1_key (c1) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t2 VALUES (1,'j'),(2,'v'),(3,'c'); +CREATE TABLE t3 ( +pk INTEGER NOT NULL, +c1 VARCHAR(1) NOT NULL, +PRIMARY KEY (pk), +KEY c1_key (c1) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t3 VALUES (10,'v'),(11,'s'); +ANALYZE TABLE t1, t2, t3; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +EXPLAIN SELECT * +FROM t1 JOIN t2 ON t1.i1 >= t2.pk +WHERE t2.c1 IN ( +SELECT t3.c1 +FROM t3 +WHERE t3.pk < 3 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using join buffer (hash join) +1 SIMPLE t2 NULL ref PRIMARY,c1_key c1_key 6 .c1 1 33.33 Using where; Using index +2 MATERIALIZED t3 NULL range PRIMARY,c1_key PRIMARY 4 NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`i1` AS `i1`,`test`.`t2`.`pk` AS `pk`,`test`.`t2`.`c1` AS `c1` from `test`.`t1` join `test`.`t2` semi join (`test`.`t3`) where ((`test`.`t2`.`c1` = ``.`c1`) and (`test`.`t3`.`pk` < 3) and (`test`.`t1`.`i1` >= `test`.`t2`.`pk`)) +SELECT * +FROM t1 JOIN t2 ON t1.i1 >= t2.pk +WHERE t2.c1 IN ( +SELECT t3.c1 +FROM t3 +WHERE t3.pk < 3 +); +pk i1 pk c1 +DROP TABLE t1,t2,t3; +# +# Bug#19586047: CRASH IN ARG_COMPARATOR::SET_CMP_FUNC +# +CREATE TABLE t1(x INT) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT 1 FROM t1 WHERE EXISTS(SELECT 1) IN (SELECT 1 FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 PRIMARY NULL const 4 const 1 100.00 NULL +3 MATERIALIZED t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` semi join (`test`.`t1`) where true +SELECT 1 FROM t1 WHERE EXISTS(SELECT 1) IN (SELECT 1 FROM t1); +1 +1 +EXPLAIN SELECT 1 FROM t1 WHERE (SELECT 1, 2 FROM t1) IN (SELECT 1, 2 FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 1 100.00 End temporary; Using join buffer (hash join) +2 SUBQUERY t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` semi join (`test`.`t1`) where true +SELECT 1 FROM t1 WHERE (SELECT 1, 2 FROM t1) IN (SELECT 1, 2 FROM t1); +1 +1 +EXPLAIN SELECT 1 FROM t1 WHERE +(SELECT 1, 2 FROM t1 WHERE x = 2) IN (SELECT 1, 2 FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +2 SUBQUERY t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` semi join (`test`.`t1`) where false +SELECT 1 FROM t1 WHERE +(SELECT 1, 2 FROM t1 WHERE x = 2) IN (SELECT 1, 2 FROM t1); +1 +DROP TABLE t1; +# +#Bug#20119743 ASSERTIONQEP_TAB->USE_ORDER() IN ENUM_NESTED_LOOP_STATE +# EVALUATE_JOIN_RECORD +# +CREATE TABLE t1 ( +pk int(11) NOT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +PRIMARY KEY (pk) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (1,'x'); +CREATE TABLE t2 ( +col_date_key date DEFAULT NULL, +col_int_key int(11) DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +KEY col_int_key (col_int_key), +KEY col_date_key (col_date_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES ('2000-12-03', 8, 'x', 'x'),('2008-05-03', 7, 'd', 'd'), +('2005-12-06', 1, 'r', 'r'),('2000-04-10', 7, 'f', 'f'), +('2002-11-05', 9, 'y', 'y'),('2000-09-06', NULL, 'u', 'u'), +(NULL, 1, 'm', 'm'),('2007-06-14', 9, NULL, NULL), +('2007-11-17', 2, 'o', 'o'),('2009-02-23', 9, 'w', 'w'), +('2007-01-08', 2, 'm', 'm'), ('2008-06-10', 4, 'q', 'q'), +('2002-10-20', 0, NULL, NULL),('2008-09-12', 4, 'd', 'd'), +('2006-06-16', 8, 'g', 'g'),('2004-09-18', NULL, 'x', 'x'), +('1900-01-01', NULL, 'f', 'f'),('2005-09-13', 0, 'p', 'p'), +('2007-04-09', NULL, 'j', 'j'),('2000-09-20', 8, 'c', 'c'); +CREATE TABLE t3 ( +pk int(11) NOT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +PRIMARY KEY (pk) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t3 VALUES (1, 'c'),(2, 'c'),(3, 'q'),(4, 'g'),(5, 'e'),(6, 'l'), +(7, NULL),(8, 'v'),(9, 'c'),(10, 'u'),(11, 'x'),(12, 'x'),(13, 'x'),(14, 'l'), +(15, 'e'),(16, 's'),(17, 'k'),(18, 'm'),(19, 'x'),(20, 's'); +ANALYZE TABLE t1,t2,t3; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +EXPLAIN SELECT r1.col_date_key +FROM t2 AS r1 +WHERE r1.col_int_key NOT IN +(SELECT ir2.pk +FROM t2 AS ir1 STRAIGHT_JOIN t1 AS ir2 +ON ir2.col_varchar_nokey = ir1.col_varchar_key +WHERE ir2.col_varchar_nokey > r1.col_varchar_nokey +AND ir2.pk IN +(SELECT iir2.pk +FROM t2 AS iir1 RIGHT JOIN t3 AS iir2 +ON iir2.col_varchar_nokey = iir1.col_varchar_key)) +ORDER BY r1.col_date_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY r1 NULL ALL NULL NULL NULL NULL 20 100.00 Using where; Using filesort +2 DEPENDENT SUBQUERY NULL ALL NULL NULL NULL NULL NULL 100.00 Using where +2 DEPENDENT SUBQUERY ir1 NULL index col_varchar_key col_varchar_key 12 NULL 20 100.00 Using where; Using index; Using join buffer (hash join) +2 DEPENDENT SUBQUERY ir2 NULL eq_ref PRIMARY PRIMARY 4 func 1 100.00 Using where; Full scan on NULL key +3 MATERIALIZED iir2 NULL eq_ref PRIMARY PRIMARY 4 func 1 100.00 Full scan on NULL key +3 MATERIALIZED iir1 NULL ref col_varchar_key col_varchar_key 7 test.iir2.col_varchar_nokey 1 100.00 Using index +SELECT r1.col_date_key +FROM t2 AS r1 +WHERE r1.col_int_key NOT IN +(SELECT ir2.pk +FROM t2 AS ir1 STRAIGHT_JOIN t1 AS ir2 +ON ir2.col_varchar_nokey = ir1.col_varchar_key +WHERE ir2.col_varchar_nokey > r1.col_varchar_nokey +AND ir2.pk IN +(SELECT iir2.pk +FROM t2 AS iir1 RIGHT JOIN t3 AS iir2 +ON iir2.col_varchar_nokey = iir1.col_varchar_key)) +ORDER BY r1.col_date_key; +col_date_key +2000-04-10 +2000-09-20 +2000-12-03 +2002-10-20 +2002-11-05 +2004-09-18 +2005-09-13 +2006-06-16 +2007-01-08 +2007-06-14 +2007-11-17 +2008-05-03 +2008-06-10 +2008-09-12 +2009-02-23 +SELECT COUNT(r1.col_date_key) AS COUNT_NUM +FROM t2 AS r1 +WHERE r1.col_int_key NOT IN +(SELECT ir2.pk +FROM t2 AS ir1 STRAIGHT_JOIN t1 AS ir2 +ON ir2.col_varchar_nokey = ir1.col_varchar_key +WHERE ir2.col_varchar_nokey > r1.col_varchar_nokey +AND ir2.pk IN +(SELECT iir2.pk +FROM t2 AS iir1 RIGHT JOIN t3 AS iir2 +ON iir2.col_varchar_nokey = iir1.col_varchar_key +WHERE iir2.pk<3)); +COUNT_NUM +15 +DROP TABLE t1,t2,t3; +# +# Bug#20554585 ASSERT JOIN()->TABLES == 0... IN JOIN_TAB::GET_SJ_STRATEGY ON SUBQUERY + VAR +# +CREATE TABLE t1 ( +pk int NOT NULL, +PRIMARY KEY (pk) +); +CREATE TABLE t2 ( +pk int NOT NULL, +col_int_key int, +col_varchar_key varchar(1), +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key) +); +CREATE TABLE t3 ( +pk int NOT NULL, +col_int_key int, +col_varchar_key varchar(1), +col_varchar varchar(1), +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key) +); +INSERT INTO t3 VALUES (1,4,'c','g'),(20,1,'i','p'); +CREATE TABLE t4 ( +col_int int +); +CREATE TABLE t5 ( +col_varchar_key varchar(1), +pk int NOT NULL, +col_int int, +PRIMARY KEY (pk), +KEY col_varchar_key (col_varchar_key) +); +SELECT table1.col_varchar_key AS field1 +FROM (t3 AS table1 +INNER JOIN ( +SELECT SUBQUERY1_t1.* +FROM (t1 AS SUBQUERY1_t1 +RIGHT JOIN (t2 AS SUBQUERY1_t2 +INNER JOIN t3 AS SUBQUERY1_t3 +ON (SUBQUERY1_t3.col_varchar_key = SUBQUERY1_t2.col_varchar_key) +) ON (SUBQUERY1_t3.col_int_key = SUBQUERY1_t2.pk) +) +WHERE SUBQUERY1_t2.col_varchar_key >= ANY ( +SELECT CHILD_SUBQUERY1_t2.col_varchar AS CHILD_SUBQUERY1_field1 +FROM (t2 AS CHILD_SUBQUERY1_t1 +LEFT OUTER JOIN t3 AS CHILD_SUBQUERY1_t2 +ON (CHILD_SUBQUERY1_t2.col_int_key = CHILD_SUBQUERY1_t1.col_int_key) +) +WHERE CHILD_SUBQUERY1_t1.pk >= SUBQUERY1_t2.pk +) +) AS table2 +ON (table2.pk = table1.pk) +) +WHERE (EXISTS (( +SELECT DISTINCT SUBQUERY2_t2.col_int AS SUBQUERY2_field1 +FROM (t4 AS SUBQUERY2_t1 +LEFT OUTER JOIN t5 AS SUBQUERY2_t2 +ON (SUBQUERY2_t2.pk = SUBQUERY2_t1.col_int) +) +WHERE SUBQUERY2_t2.col_varchar_key != @var4 +))) +AND table1.col_int_key < (35 + 192) +ORDER BY field1 +; +field1 +DROP TABLE t1, t2, t3, t4, t5; +# +# Bug#18892055: MISSING DATA ON SELECT ... IN WITH JOINS AND INNODB +# ENGINE +# +CREATE TABLE t1 ( +col_int_key INT, +pk INT NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +) ENGINE = INNODB; +INSERT INTO t1 VALUES +( 0, 3 ), +( 0, 4 ), +( 3, 1 ), +( 900000000, 2 ), +( 1368719360, 5 ), +( 1922236416, 6 ), +( 8,7 ); +CREATE TABLE t2 ( +pk INT NOT NULL, +col_int INT, +PRIMARY KEY (pk) +) ENGINE = INNODB; +INSERT INTO t2 VALUES +( 1, 3 ), +( 2, 2 ), +( 3, 8 ), +( 4, 7 ); +CREATE TABLE t3 ( +col_int_key INT, +col_int INT, +KEY (col_int_key) +) ENGINE = INNODB; +INSERT INTO t3 VALUES +( 5, 1 ), +( -1, -1 ), +( 300000000, 1 ), +( 8, 1 ); +CREATE TABLE t4 ( col_int_key INT ) ENGINE = INNODB; +INSERT INTO t4 VALUES +(0), +(3), +(8), +(900000000), +(1368719360), +(1922236416); +ANALYZE TABLE t1, t2, t3, t4; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +test.t4 analyze status OK +explain SELECT * +FROM t4 +WHERE (col_int_key) IN ( +SELECT t1.col_int_key +FROM t1 LEFT JOIN ( t2 JOIN t3 ON t3.col_int_key = t2.col_int ) USING ( pk ) +WHERE t3.col_int IS NULL +) +ORDER BY col_int_key +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using temporary; Using filesort +1 SIMPLE t4 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Using join buffer (hash join) +2 MATERIALIZED t1 NULL index col_int_key col_int_key 5 NULL 7 100.00 Using index +2 MATERIALIZED t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.pk 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL col_int_key NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`col_int_key` AS `col_int_key` from `test`.`t4` semi join (`test`.`t1` left join (`test`.`t2` join `test`.`t3`) on(((`test`.`t1`.`pk` = `test`.`t2`.`pk`) and (`test`.`t3`.`col_int_key` = `test`.`t2`.`col_int`)))) where ((`test`.`t4`.`col_int_key` = ``.`col_int_key`) and (`test`.`t3`.`col_int` is null)) order by `test`.`t4`.`col_int_key` +explain format=tree SELECT * +FROM t4 +WHERE (col_int_key) IN ( +SELECT t1.col_int_key +FROM t1 LEFT JOIN ( t2 JOIN t3 ON t3.col_int_key = t2.col_int ) USING ( pk ) +WHERE t3.col_int IS NULL +) +ORDER BY col_int_key +; +EXPLAIN +-> Sort: t4.col_int_key + -> Stream results (cost=11.14 rows=7) + -> Inner hash join (t4.col_int_key = ``.col_int_key) (cost=11.14 rows=7) + -> Table scan on t4 (cost=0.35 rows=6) + -> Hash + -> Table scan on (cost=0.37..2.59 rows=7) + -> Materialize with deduplication (cost=4.47..6.69 rows=7) + -> Filter: (t1.col_int_key is not null) (cost=3.40 rows=7) + -> Filter: (t3.col_int is null) (cost=3.40 rows=7) + -> Nested loop left join (cost=3.40 rows=7) + -> Index scan on t1 using col_int_key (cost=0.95 rows=7) + -> Nested loop inner join (cost=1.21 rows=1) + -> Single-row index lookup on t2 using PRIMARY (pk=t1.pk) (cost=0.26 rows=1) + -> Filter: (t3.col_int_key = t2.col_int) (cost=0.09 rows=1) + -> Table scan on t3 (cost=0.09 rows=4) + +SELECT * +FROM t4 +WHERE (col_int_key) IN ( +SELECT t1.col_int_key +FROM t1 LEFT JOIN ( t2 JOIN t3 ON t3.col_int_key = t2.col_int ) USING ( pk ) +WHERE t3.col_int IS NULL +) +ORDER BY col_int_key +; +col_int_key +0 +3 +8 +900000000 +1368719360 +1922236416 +DROP TABLE t1, t2, t3, t4; +# +# Bug#20835095 CRASH AT CREATE_REF_FOR_KEY IN SQL/SQL_SELECT.CC +# +CREATE TABLE t1 ( +pk INTEGER, +var_10_latin1 VARCHAR(10) CHARACTER SET latin1, +var_255_utf8 VARCHAR(255) CHARACTER SET utf8, +var_255_latin1 VARCHAR(255) CHARACTER SET latin1, +var_10_utf8 VARCHAR(10) CHARACTER SET utf8, +PRIMARY KEY (pk) +); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +CREATE VIEW v1 AS SELECT * FROM t1; +INSERT INTO t1 VALUES +(1,'FROCJ','korrhrspki','UAYVL','BPZIS'), +(2,'him','a','CHYKN','OZZQT'), +(3,'WBITK','ULWBF','have','rhrh'), +(4,'or','right','up','it'), +(5,'GGDCP','x','who','as'), +(6,'j','i','e','w'); +CREATE TABLE tv +SELECT var_255_utf8 AS field1 +FROM t1; +EXPLAIN SELECT * FROM tv +WHERE field1 IN ( +SELECT tv1.var_255_utf8 +FROM v1 AS tv1 LEFT JOIN v1 AS tv2 ON tv1.var_10_latin1=tv2.var_10_utf8); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE tv NULL ALL NULL NULL NULL NULL 6 100.00 Using where +1 SIMPLE NULL eq_ref 768 test.tv.field1 1 100.00 NULL +2 MATERIALIZED t1 NULL ALL NULL NULL NULL NULL 6 100.00 NULL +2 MATERIALIZED t1 NULL ALL NULL NULL NULL NULL 6 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`tv`.`field1` AS `field1` from `test`.`tv` semi join (`test`.`t1` left join (`test`.`t1`) on((`test`.`t1`.`var_10_latin1` = `test`.`t1`.`var_10_utf8`))) where (``.`var_255_utf8` = `test`.`tv`.`field1`) +SELECT * FROM tv +WHERE field1 IN ( +SELECT tv1.var_255_utf8 +FROM v1 AS tv1 LEFT JOIN v1 AS tv2 ON tv1.var_10_latin1=tv2.var_10_utf8); +field1 +korrhrspki +a +ULWBF +right +x +i +DROP VIEW v1; +DROP TABLE t1, tv; +# 17832047 Crash in calculate_materialization_costs +CREATE TABLE t1(a INTEGER PRIMARY KEY); +INSERT INTO t1 VALUES (0),(1),(2); +SELECT 1 FROM t1 +WHERE 1 IN +(SELECT 1 BETWEEN (LENGTH(a) IN (SELECT 1 FROM t1)) AND 1 +FROM t1 +); +1 +1 +1 +1 +DROP TABLE t1; +# 17845989 Assertion failed: !(used_tables() & ... +CREATE TABLE a(b INTEGER) engine=innodb; +CREATE TABLE c(a INTEGER) engine=innodb; +SELECT 1 +FROM a +WHERE 1 IN (SELECT (a.b IS NULL) IN (SELECT 1 FROM c) FROM c) +; +1 +DROP TABLE a, c; +# +# Bug#18194196: OPTIMIZER EXECUTES STATEMENT INPERFORMANT +# +CREATE TABLE t1 (uid INTEGER, fid INTEGER, INDEX(uid)); +INSERT INTO t1 VALUES +(1,1), (1,2), (1,3), (1,4), +(2,5), (2,6), (2,7), (2,8), +(3,1), (3,2), (3,9); +CREATE TABLE t2 (uid INT PRIMARY KEY, name VARCHAR(128), INDEX(name)); +INSERT INTO t2 VALUES +(1, "A"), (2, "B"), (3, "C"), (4, "D"), (5, "E"), +(6, "F"), (7, "G"), (8, "H"), (9, "I"); +CREATE TABLE t3 (uid INT, fid INT, INDEX(uid)); +INSERT INTO t3 VALUES +(1,1), (1,2), (1,3),(1,4), +(2,5), (2,6), (2,7), (2,8), +(3,1), (3,2), (3,9); +CREATE TABLE t4 (uid INT PRIMARY KEY, name VARCHAR(128), INDEX(name)); +INSERT INTO t4 VALUES +(1, "A"), (2, "B"), (3, "C"), (4, "D"), (5, "E"), +(6, "F"), (7, "G"), (8, "H"), (9, "I"); +ANALYZE TABLE t1,t2,t3,t4; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +test.t4 analyze status OK +EXPLAIN SELECT name FROM t2, t1 +WHERE t1.uid IN (SELECT t4.uid FROM t4, t3 WHERE t3.uid=1 AND t4.uid=t3.fid) +AND t2.uid=t1.fid; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ref uid uid 5 const 4 100.00 Using where; Start temporary +1 SIMPLE t4 NULL eq_ref PRIMARY PRIMARY 4 test.t3.fid 1 100.00 Using index +1 SIMPLE t1 NULL ref uid uid 5 test.t3.fid 4 100.00 Using where; End temporary +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.fid 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`name` AS `name` from `test`.`t4` join `test`.`t2` join `test`.`t1` semi join (`test`.`t3`) where ((`test`.`t4`.`uid` = `test`.`t3`.`fid`) and (`test`.`t1`.`uid` = `test`.`t3`.`fid`) and (`test`.`t3`.`uid` = 1) and (`test`.`t2`.`uid` = `test`.`t1`.`fid`)) +FLUSH STATUS; +SELECT name FROM t2, t1 +WHERE t1.uid IN (SELECT t4.uid FROM t4, t3 WHERE t3.uid=1 AND t4.uid=t3.fid) +AND t2.uid=t1.fid; +name +A +A +B +B +C +D +E +F +G +H +I +SHOW STATUS LIKE '%handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 20 +Handler_read_last 0 +Handler_read_next 15 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +DROP TABLE t1,t2,t3,t4; +# End of test for Bug#18194196 +# +# Bug#21184091 ASSERT `READ_ROWS >= 0.0' AT +# COST_MODEL_SERVER::TMPTABLE_READWRITE_COST() +# +CREATE TABLE t1 ( +pk INTEGER, +col_varchar varchar(1), +col_int INTEGER, +PRIMARY KEY (pk) +) ENGINE=MyISAM; +CREATE TABLE t2 ( +col_int INTEGER, +col_varchar varchar(1) +) ENGINE=MyISAM; +INSERT INTO t2 VALUES (7,'x'); +INSERT INTO t2 VALUES (4,'z'); +SELECT t2.col_varchar +FROM t2 STRAIGHT_JOIN t1 ON t2.col_varchar = t1.col_varchar +JOIN t2 AS table3 ON t1.pk = table3.col_int +WHERE t1.pk IN (SELECT col_int FROM t1); +col_varchar +DROP TABLE t1,t2; +# End of test for Bug#21184091 +# Bug#21139722: Assertion failed: !(used_tables() & ((table_map) 1) ... +CREATE TABLE t1(a INTEGER) engine=innodb; +CREATE TABLE t2(b INTEGER) engine=innodb; +explain SELECT 1 +FROM (SELECT 1 IN (SELECT 1 +FROM t1 +WHERE (SELECT 1 FROM t2 HAVING b) NOT IN (SELECT 1 FROM t2) +) +FROM t2 +) AS z; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DERIVED t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +3 DEPENDENT SUBQUERY t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +5 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +4 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1276 Field or reference 'b' of SELECT #4 was resolved in SELECT #2 +Note 1003 /* select#1 */ select 1 AS `1` from (/* select#2 */ select (1,(/* select#3 */ select 1 from `test`.`t1` where ((/* select#4 */ select 1 from `test`.`t2` having (0 <> `test`.`t2`.`b`)),(/* select#5 */ select 1 from `test`.`t2` where (outer_field_is_not_null, (((/* select#4 */ select 1 from `test`.`t2` having (0 <> `test`.`t2`.`b`))) = 1), true)) is false))) AS `1 IN (SELECT 1 +FROM t1 +WHERE (SELECT 1 FROM t2 HAVING b) NOT IN (SELECT 1 FROM t2) +)` from `test`.`t2`) `z` +SELECT 1 +FROM (SELECT 1 IN (SELECT 1 +FROM t1 +WHERE (SELECT 1 FROM t2 HAVING b) NOT IN (SELECT 1 FROM t2) +) +FROM t2 +) AS z; +1 +DROP TABLE t1, t2; +CREATE TABLE t1(a INTEGER) engine=innodb; +explain SELECT (SELECT a FROM t1 AS t2 +WHERE a IN (SELECT t1.a+t2.a FROM t1 AS t3)) +FROM t1 AS t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +2 DEPENDENT SUBQUERY t3 NULL ALL NULL NULL NULL NULL 1 100.00 End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #3 was resolved in SELECT #1 +Note 1276 Field or reference 'test.t2.a' of SELECT #3 was resolved in SELECT #2 +Note 1003 /* select#1 */ select (/* select#2 */ select `test`.`t2`.`a` from `test`.`t1` `t2` semi join (`test`.`t1` `t3`) where (`test`.`t2`.`a` = (`test`.`t1`.`a` + `test`.`t2`.`a`))) AS `(SELECT a FROM t1 AS t2 +WHERE a IN (SELECT t1.a+t2.a FROM t1 AS t3))` from `test`.`t1` +SELECT (SELECT a FROM t1 AS t2 +WHERE a IN (SELECT t1.a+t2.a FROM t1 AS t3)) +FROM t1 AS t1; +(SELECT a FROM t1 AS t2 +WHERE a IN (SELECT t1.a+t2.a FROM t1 AS t3)) +DROP TABLE t1; +# End of test for Bug#21139722 +SET DEFAULT_STORAGE_ENGINE=INNODB; +# +# Bug#21139402 ASSERTION FAILED: LENGTH > 0 && KEYPARTS != 0, CRASH IN JOIN::OPTIMIZE_KEYUSE +# +CREATE TABLE t1 (a INT, b INT, PRIMARY KEY(a)); +CREATE TABLE t2 (c INT PRIMARY KEY); +EXPLAIN SELECT 1 FROM t1 +WHERE 1 IN +(SELECT (c IS NULL) IN (SELECT a FROM t1 WHERE b) FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +3 SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` semi join (`test`.`t2`) where false +SELECT 1 FROM t1 +WHERE 1 IN +(SELECT (c IS NULL) IN (SELECT a FROM t1 WHERE b) FROM t2); +1 +DROP TABLE t1,t2; +# +# Bug#21619634 ACCESS OF DEALLOCATED ITEM_OUTER_REF CAUSES CRASH: PREPARED STMT +# +create table cc (i int) engine="innodb"; +insert into cc values (1); +select (select count(i) from cc as cc_alias +where (cc.i in (select cc_alias.i from cc))) +from cc group by i; +(select count(i) from cc as cc_alias +where (cc.i in (select cc_alias.i from cc))) +1 +prepare stmt from +"select (select count(i) from cc as cc_alias + where (cc.i in (select cc_alias.i from cc))) + from cc group by i"; +execute stmt; +(select count(i) from cc as cc_alias + where (cc.i in (select cc_alias.i from cc))) +1 +execute stmt; +(select count(i) from cc as cc_alias + where (cc.i in (select cc_alias.i from cc))) +1 +drop table cc; +# +# Bug #22305361: QUERY WITH MATERIALIZED TABLE RETURNS INCORRECT +# RESULTS IN 5.6 +# +CREATE TABLE t(a INT,b INT); +INSERT INTO t VALUES (1,0),(1,0),(1,0),(1,0),(1,1); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +EXPLAIN SELECT * +FROM t AS t1 +WHERE t1.a IN (SELECT t2.a +FROM t AS t2 +WHERE CONCAT(t2.a,'') NOT IN (SELECT t3.a +FROM t AS t3 +WHERE t3.b=1)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 5 100.00 Using where +1 PRIMARY NULL eq_ref 5 test.t1.a 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 5 100.00 Using where +3 SUBQUERY t3 NULL ALL NULL NULL NULL NULL 5 20.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t` `t1` semi join (`test`.`t` `t2`) where ((``.`a` = `test`.`t1`.`a`) and (concat(`test`.`t2`.`a`,''),concat(`test`.`t2`.`a`,'') in ( (/* select#3 */ select `test`.`t3`.`a` from `test`.`t` `t3` where (`test`.`t3`.`b` = 1) having true ), (concat(`test`.`t2`.`a`,'') in on where ((concat(`test`.`t2`.`a`,'') = ``.`a`)))) is false)) +SELECT * +FROM t AS t1 +WHERE t1.a IN (SELECT t2.a +FROM t AS t2 +WHERE CONCAT(t2.a,'') NOT IN (SELECT t3.a +FROM t AS t3 +WHERE t3.b=1)); +a b +DROP TABLE t; +# +# Bug#24287772 SUBQUERY RETURNS EMPTY LIST WHILE IDENTICAL QUERY +# WITH JOIN RETURNS RESULT +# +CREATE TABLE t SELECT 4096 c; +SELECT c FROM t WHERE 1 IN +(SELECT t.c = page_size FROM information_schema.innodb_cmpmem); +c +4096 +DROP TABLE t; +# +# Bug #29132639: WL#12470: SIG 6 IN CONNECTJOINS|SQL/SQL_EXECUTOR.C +# +CREATE TABLE t1 ( f1 TIME, f2 VARCHAR(1) ); +INSERT INTO t1 VALUES ('08:35:24', 'X'), ('14:51:13', 'S'), ('11:22:33', 'Q'); +CREATE TABLE t2 ( pk INTEGER ); +INSERT INTO t2 VALUES (1), (2); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN FORMAT=tree SELECT * FROM t1 WHERE EXISTS ( SELECT alias1.f2 FROM t2 LEFT JOIN t1 ON 1 LEFT JOIN t1 AS alias1 ON 1 ); +EXPLAIN +-> Inner hash join (no condition) (cost=9.59 rows=54) + -> Table scan on t1 (cost=0.55 rows=3) + -> Hash + -> Constant row from (cost=0.00..0.00 rows=1) + -> Materialize with deduplication (cost=3.94..3.94 rows=18) + -> Left hash join (no condition) (cost=2.14 rows=18) + -> Left hash join (no condition) (cost=1.12 rows=6) + -> Table scan on t2 (cost=0.45 rows=2) + -> Hash + -> Table scan on t1 (cost=0.28 rows=3) + -> Hash + -> Table scan on alias1 (cost=0.09 rows=3) + +SELECT * FROM t1 WHERE EXISTS ( SELECT alias1.f2 FROM t2 LEFT JOIN t1 ON 1 LEFT JOIN t1 AS alias1 ON 1 ); +f1 f2 +08:35:24 X +11:22:33 Q +14:51:13 S +DROP TABLE t1, t2; +set optimizer_switch=default; +set optimizer_switch=default; diff --git a/mysql-test/r/subquery_sj_mat_bka_nobnl.result-pq b/mysql-test/r/subquery_sj_mat_bka_nobnl.result-pq new file mode 100644 index 000000000000..77e85542f78e --- /dev/null +++ b/mysql-test/r/subquery_sj_mat_bka_nobnl.result-pq @@ -0,0 +1,13216 @@ +set optimizer_switch='batched_key_access=on,block_nested_loop=off,mrr_cost_based=off'; +set optimizer_switch='semijoin=on,materialization=on'; +set @old_opt_switch=@@optimizer_switch; +set optimizer_switch='subquery_materialization_cost_based=off'; +drop table if exists t0, t1, t2, t10, t11, t12; +create table t1 (a int not null, b int, primary key (a)); +create table t2 (a int not null, primary key (a)); +create table t3 (a int not null, b int, primary key (a)); +insert into t1 values (1,10), (2,20), (3,30), (4,40); +insert into t2 values (2), (3), (4), (5); +insert into t3 values (10,3), (20,4), (30,5); +select * from t2 where t2.a in (select a from t1); +a +2 +3 +4 +explain select * from t2 where t2.a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index PRIMARY PRIMARY 4 NULL 4 100.00 Using index +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t1` join `test`.`t2` where (`test`.`t1`.`a` = `test`.`t2`.`a`) +select * from t2 where t2.a in (select a from t1 where t1.b <> 30); +a +2 +4 +explain select * from t2 where t2.a in (select a from t1 where t1.b <> 30); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL PRIMARY NULL NULL NULL 4 75.00 Using where +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`a` = `test`.`t1`.`a`) and (`test`.`t1`.`b` <> 30)) +select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a); +a +2 +3 +explain select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index PRIMARY PRIMARY 4 NULL 4 100.00 Using index +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.a 1 100.00 Using where +1 SIMPLE t3 NULL eq_ref PRIMARY PRIMARY 4 test.t1.b 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t1` join `test`.`t3` join `test`.`t2` where ((`test`.`t1`.`a` = `test`.`t2`.`a`) and (`test`.`t3`.`a` = `test`.`t1`.`b`)) +drop table t1, t2, t3; +create table t1 (a int, b int, index a (a,b)); +create table t2 (a int, index a (a)); +create table t3 (a int, b int, index a (a)); +insert into t1 values (1,10), (2,20), (3,30), (4,40); +create table t0(a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +insert into t1 +select rand()*100000+200,rand()*100000 from t0 A, t0 B, t0 C, t0 D; +insert into t2 values (2), (3), (4), (5); +insert into t3 values (10,3), (20,4), (30,5); +select * from t2 where t2.a in (select a from t1); +a +2 +3 +4 +explain select * from t2 where t2.a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index a a 5 NULL 4 100.00 Using where; Using index +1 SIMPLE NULL eq_ref 5 test.t2.a 1 100.00 NULL +2 MATERIALIZED t1 NULL index a a 10 NULL 10004 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1`) where (``.`a` = `test`.`t2`.`a`) +select * from t2 where t2.a in (select a from t1 where t1.b <> 30); +a +2 +4 +explain select * from t2 where t2.a in (select a from t1 where t1.b <> 30); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index a a 5 NULL 4 100.00 Using where; Using index +1 SIMPLE NULL eq_ref 5 test.t2.a 1 100.00 NULL +2 MATERIALIZED t1 NULL index a a 10 NULL 10004 90.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1`) where ((``.`a` = `test`.`t2`.`a`) and (`test`.`t1`.`b` <> 30)) +select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a); +a +2 +3 +explain select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index a a 5 NULL 4 100.00 Using where; Using index +1 SIMPLE NULL eq_ref 5 test.t2.a 1 100.00 NULL +2 MATERIALIZED t3 NULL index a a 5 NULL 3 100.00 Using index +2 MATERIALIZED t1 NULL index a a 10 NULL 10004 10.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1` join `test`.`t3`) where ((``.`a` = `test`.`t2`.`a`) and (`test`.`t1`.`b` = `test`.`t3`.`a`)) +insert into t1 values (3,31); +select * from t2 where t2.a in (select a from t1 where t1.b <> 30); +a +2 +3 +4 +select * from t2 where t2.a in (select a from t1 where t1.b <> 30 and t1.b <> 31); +a +2 +4 +explain select * from t2 where t2.a in (select a from t1 where t1.b <> 30); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index a a 5 NULL 4 100.00 Using where; Using index +1 SIMPLE NULL eq_ref 5 test.t2.a 1 100.00 NULL +2 MATERIALIZED t1 NULL index a a 10 NULL 10005 90.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1`) where ((``.`a` = `test`.`t2`.`a`) and (`test`.`t1`.`b` <> 30)) +drop table t0, t1, t2, t3; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1(a int, b int); +insert into t1 values (0,0),(1,1),(2,2); +create table t2 as select * from t1; +create table t11(a int, b int); +create table t10 (pk int, a int, primary key(pk)); +insert into t10 select a,a from t0; +create table t12 like t10; +insert into t12 select * from t10; +Flattened because of dependency, t10=func(t1) +explain select * from t1 where a in (select pk from t10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t1` where (`test`.`t10`.`pk` = `test`.`t1`.`a`) +select * from t1 where a in (select pk from t10); +a b +0 0 +1 1 +2 2 +A confluent case of dependency +explain select * from t1 where a in (select a from t10 where pk=12); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t1` where (multiple equal(12, NULL) and multiple equal(`test`.`t1`.`a`, NULL)) +select * from t1 where a in (select a from t10 where pk=12); +a b +explain select * from t1 where a in (select a from t10 where pk=9); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t10 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t1` where ((`test`.`t1`.`a` = '9')) +select * from t1 where a in (select a from t10 where pk=9); +a b +An empty table inside +explain select * from t1 where a in (select a from t11); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 0.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +2 MATERIALIZED t11 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t11`) where (`test`.`t1`.`a` = ``.`a`) +select * from t1 where a in (select a from t11); +a b +explain select * from t1 where a in (select pk from t10) and b in (select pk from t10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using index +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.t1.b 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t10` join `test`.`t1` where ((`test`.`t10`.`pk` = `test`.`t1`.`b`) and (`test`.`t10`.`pk` = `test`.`t1`.`a`)) +select * from t1 where a in (select pk from t10) and b in (select pk from t10); +a b +0 0 +1 1 +2 2 +flattening a nested subquery +explain select * from t1 where a in (select pk from t10 where t10.a in (select pk from t12)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using where +1 SIMPLE t12 NULL eq_ref PRIMARY PRIMARY 4 test.t10.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t12` join `test`.`t1` where ((`test`.`t10`.`pk` = `test`.`t1`.`a`) and (`test`.`t12`.`pk` = `test`.`t10`.`a`)) +select * from t1 where a in (select pk from t10 where t10.a in (select pk from t12)); +a b +0 0 +1 1 +2 2 +flattening subquery w/ several tables +explain select * from t1 where a in (select t10.pk from t10, t12 where t12.pk=t10.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using where +1 SIMPLE t12 NULL eq_ref PRIMARY PRIMARY 4 test.t10.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t12` join `test`.`t1` where ((`test`.`t10`.`pk` = `test`.`t1`.`a`) and (`test`.`t12`.`pk` = `test`.`t10`.`a`)) +subqueries within outer joins go into ON expr. +explain +select * from t1 left join (t2 A, t2 B) on ( A.A= t1.A and B.A in (select pk from t10)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE A NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE B NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.B.A 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`A` AS `A`,`test`.`t1`.`B` AS `B`,`test`.`A`.`A` AS `A`,`test`.`A`.`B` AS `B`,`test`.`B`.`A` AS `A`,`test`.`B`.`B` AS `B` from `test`.`t1` left join (`test`.`t10` join `test`.`t2` `A` join `test`.`t2` `B`) on(((`test`.`t10`.`pk` = `test`.`B`.`A`) and (`test`.`A`.`A` = `test`.`t1`.`A`))) where true +t2 should be wrapped into OJ-nest, so we have "t1 LJ (t2 J t10)" +explain +select * from t1 left join t2 on (t2.A= t1.A and t2.A in (select pk from t10)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.t1.A 1 100.00 Using index +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`A` AS `A`,`test`.`t1`.`B` AS `B`,`test`.`t2`.`A` AS `A`,`test`.`t2`.`B` AS `B` from `test`.`t1` left join (`test`.`t10` join `test`.`t2`) on(((`test`.`t10`.`pk` = `test`.`t1`.`A`) and (`test`.`t2`.`A` = `test`.`t1`.`A`))) where true +we shouldn't flatten if we're going to get a join of > MAX_TABLES. +explain select * from +t1 s00, t1 s01, t1 s02, t1 s03, t1 s04,t1 s05,t1 s06,t1 s07,t1 s08,t1 s09, +t1 s10, t1 s11, t1 s12, t1 s13, t1 s14,t1 s15,t1 s16,t1 s17,t1 s18,t1 s19, +t1 s20, t1 s21, t1 s22, t1 s23, t1 s24,t1 s25,t1 s26,t1 s27,t1 s28,t1 s29, +t1 s30, t1 s31, t1 s32, t1 s33, t1 s34,t1 s35,t1 s36,t1 s37,t1 s38,t1 s39, +t1 s40, t1 s41, t1 s42, t1 s43, t1 s44,t1 s45,t1 s46,t1 s47,t1 s48,t1 s49 +where +s00.a in ( +select m00.a from +t1 m00, t1 m01, t1 m02, t1 m03, t1 m04,t1 m05,t1 m06,t1 m07,t1 m08,t1 m09, +t1 m10, t1 m11, t1 m12, t1 m13, t1 m14,t1 m15,t1 m16,t1 m17,t1 m18,t1 m19 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY s00 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 PRIMARY s01 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s02 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s03 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s04 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s05 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s06 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s07 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s08 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s09 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s10 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s11 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s12 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s13 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s14 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s15 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s16 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s17 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s18 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s19 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s20 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s21 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s22 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s23 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s24 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s25 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s26 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s27 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s28 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s29 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s30 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s31 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s32 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s33 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s34 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s35 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s36 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s37 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s38 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s39 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s40 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s41 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s42 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s43 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s44 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s45 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s46 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s47 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s48 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s49 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 SUBQUERY m00 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 SUBQUERY m01 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 SUBQUERY m02 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 SUBQUERY m03 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 SUBQUERY m04 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 SUBQUERY m05 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 SUBQUERY m06 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 SUBQUERY m07 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 SUBQUERY m08 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 SUBQUERY m09 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 SUBQUERY m10 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 SUBQUERY m11 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 SUBQUERY m12 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 SUBQUERY m13 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 SUBQUERY m14 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 SUBQUERY m15 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 SUBQUERY m16 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 SUBQUERY m17 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 SUBQUERY m18 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 SUBQUERY m19 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`s00`.`a` AS `a`,`test`.`s00`.`b` AS `b`,`test`.`s01`.`a` AS `a`,`test`.`s01`.`b` AS `b`,`test`.`s02`.`a` AS `a`,`test`.`s02`.`b` AS `b`,`test`.`s03`.`a` AS `a`,`test`.`s03`.`b` AS `b`,`test`.`s04`.`a` AS `a`,`test`.`s04`.`b` AS `b`,`test`.`s05`.`a` AS `a`,`test`.`s05`.`b` AS `b`,`test`.`s06`.`a` AS `a`,`test`.`s06`.`b` AS `b`,`test`.`s07`.`a` AS `a`,`test`.`s07`.`b` AS `b`,`test`.`s08`.`a` AS `a`,`test`.`s08`.`b` AS `b`,`test`.`s09`.`a` AS `a`,`test`.`s09`.`b` AS `b`,`test`.`s10`.`a` AS `a`,`test`.`s10`.`b` AS `b`,`test`.`s11`.`a` AS `a`,`test`.`s11`.`b` AS `b`,`test`.`s12`.`a` AS `a`,`test`.`s12`.`b` AS `b`,`test`.`s13`.`a` AS `a`,`test`.`s13`.`b` AS `b`,`test`.`s14`.`a` AS `a`,`test`.`s14`.`b` AS `b`,`test`.`s15`.`a` AS `a`,`test`.`s15`.`b` AS `b`,`test`.`s16`.`a` AS `a`,`test`.`s16`.`b` AS `b`,`test`.`s17`.`a` AS `a`,`test`.`s17`.`b` AS `b`,`test`.`s18`.`a` AS `a`,`test`.`s18`.`b` AS `b`,`test`.`s19`.`a` AS `a`,`test`.`s19`.`b` AS `b`,`test`.`s20`.`a` AS `a`,`test`.`s20`.`b` AS `b`,`test`.`s21`.`a` AS `a`,`test`.`s21`.`b` AS `b`,`test`.`s22`.`a` AS `a`,`test`.`s22`.`b` AS `b`,`test`.`s23`.`a` AS `a`,`test`.`s23`.`b` AS `b`,`test`.`s24`.`a` AS `a`,`test`.`s24`.`b` AS `b`,`test`.`s25`.`a` AS `a`,`test`.`s25`.`b` AS `b`,`test`.`s26`.`a` AS `a`,`test`.`s26`.`b` AS `b`,`test`.`s27`.`a` AS `a`,`test`.`s27`.`b` AS `b`,`test`.`s28`.`a` AS `a`,`test`.`s28`.`b` AS `b`,`test`.`s29`.`a` AS `a`,`test`.`s29`.`b` AS `b`,`test`.`s30`.`a` AS `a`,`test`.`s30`.`b` AS `b`,`test`.`s31`.`a` AS `a`,`test`.`s31`.`b` AS `b`,`test`.`s32`.`a` AS `a`,`test`.`s32`.`b` AS `b`,`test`.`s33`.`a` AS `a`,`test`.`s33`.`b` AS `b`,`test`.`s34`.`a` AS `a`,`test`.`s34`.`b` AS `b`,`test`.`s35`.`a` AS `a`,`test`.`s35`.`b` AS `b`,`test`.`s36`.`a` AS `a`,`test`.`s36`.`b` AS `b`,`test`.`s37`.`a` AS `a`,`test`.`s37`.`b` AS `b`,`test`.`s38`.`a` AS `a`,`test`.`s38`.`b` AS `b`,`test`.`s39`.`a` AS `a`,`test`.`s39`.`b` AS `b`,`test`.`s40`.`a` AS `a`,`test`.`s40`.`b` AS `b`,`test`.`s41`.`a` AS `a`,`test`.`s41`.`b` AS `b`,`test`.`s42`.`a` AS `a`,`test`.`s42`.`b` AS `b`,`test`.`s43`.`a` AS `a`,`test`.`s43`.`b` AS `b`,`test`.`s44`.`a` AS `a`,`test`.`s44`.`b` AS `b`,`test`.`s45`.`a` AS `a`,`test`.`s45`.`b` AS `b`,`test`.`s46`.`a` AS `a`,`test`.`s46`.`b` AS `b`,`test`.`s47`.`a` AS `a`,`test`.`s47`.`b` AS `b`,`test`.`s48`.`a` AS `a`,`test`.`s48`.`b` AS `b`,`test`.`s49`.`a` AS `a`,`test`.`s49`.`b` AS `b` from `test`.`t1` `s00` join `test`.`t1` `s01` join `test`.`t1` `s02` join `test`.`t1` `s03` join `test`.`t1` `s04` join `test`.`t1` `s05` join `test`.`t1` `s06` join `test`.`t1` `s07` join `test`.`t1` `s08` join `test`.`t1` `s09` join `test`.`t1` `s10` join `test`.`t1` `s11` join `test`.`t1` `s12` join `test`.`t1` `s13` join `test`.`t1` `s14` join `test`.`t1` `s15` join `test`.`t1` `s16` join `test`.`t1` `s17` join `test`.`t1` `s18` join `test`.`t1` `s19` join `test`.`t1` `s20` join `test`.`t1` `s21` join `test`.`t1` `s22` join `test`.`t1` `s23` join `test`.`t1` `s24` join `test`.`t1` `s25` join `test`.`t1` `s26` join `test`.`t1` `s27` join `test`.`t1` `s28` join `test`.`t1` `s29` join `test`.`t1` `s30` join `test`.`t1` `s31` join `test`.`t1` `s32` join `test`.`t1` `s33` join `test`.`t1` `s34` join `test`.`t1` `s35` join `test`.`t1` `s36` join `test`.`t1` `s37` join `test`.`t1` `s38` join `test`.`t1` `s39` join `test`.`t1` `s40` join `test`.`t1` `s41` join `test`.`t1` `s42` join `test`.`t1` `s43` join `test`.`t1` `s44` join `test`.`t1` `s45` join `test`.`t1` `s46` join `test`.`t1` `s47` join `test`.`t1` `s48` join `test`.`t1` `s49` where (`test`.`s00`.`a`,`test`.`s00`.`a` in ( (/* select#2 */ select `test`.`m00`.`a` from `test`.`t1` `m00` join `test`.`t1` `m01` join `test`.`t1` `m02` join `test`.`t1` `m03` join `test`.`t1` `m04` join `test`.`t1` `m05` join `test`.`t1` `m06` join `test`.`t1` `m07` join `test`.`t1` `m08` join `test`.`t1` `m09` join `test`.`t1` `m10` join `test`.`t1` `m11` join `test`.`t1` `m12` join `test`.`t1` `m13` join `test`.`t1` `m14` join `test`.`t1` `m15` join `test`.`t1` `m16` join `test`.`t1` `m17` join `test`.`t1` `m18` join `test`.`t1` `m19` where true ), (`test`.`s00`.`a` in on where ((`test`.`s00`.`a` = ``.`a`))))) +select * from +t1 left join t2 on (t2.a= t1.a and t2.a in (select pk from t10)) +where t1.a < 5; +a b a b +0 0 0 0 +1 1 1 1 +2 2 2 2 +prepare s1 from +' select * from + t1 left join t2 on (t2.a= t1.a and t2.a in (select pk from t10)) + where t1.a < 5'; +execute s1; +a b a b +0 0 0 0 +1 1 1 1 +2 2 2 2 +execute s1; +a b a b +0 0 0 0 +1 1 1 1 +2 2 2 2 +insert into t1 select (A.a + 10 * B.a),1 from t0 A, t0 B; +explain select * from t1 where a in (select pk from t10 where pk<3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t10 NULL range PRIMARY PRIMARY 4 NULL 4 100.00 Using where; Using index +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 103 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t1` where ((`test`.`t1`.`a` = `test`.`t10`.`pk`) and (`test`.`t10`.`pk` < 3)) +drop table t0, t1, t2; +drop table t10, t11, t12; +# +# Check that subqueries with outer joins or straight_join work for +# different permutations of const and non-const tables. (Ref. Bug#46692) +# +CREATE TABLE t1 (i INTEGER); +CREATE TABLE t2 (i INTEGER); +CREATE TABLE t3 (i INTEGER); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 0 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 0 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 0 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 1 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 1 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 1 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 2 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 2 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 2 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (0); +DELETE FROM t2; +INSERT INTO t1 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 0 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where ((``.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 0 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where ((``.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 0 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where ((``.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 1 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where ((``.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 1 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where ((``.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 1 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where ((``.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 2 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where ((``.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 2 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where ((``.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 2 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where ((``.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (0); +DELETE FROM t2; +INSERT INTO t1 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 0 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 0.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = ``.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 0.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = ``.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 0.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = ``.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 0.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 0.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t1`.`i` = ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL const 5 const 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL const 5 const 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL const 5 const 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 0 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = ``.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = ``.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = ``.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t1`.`i` = ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL const 5 const 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL const 5 const 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL const 5 const 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 0 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = ``.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = ``.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = ``.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +1 +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t1`.`i` = ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL const 5 const 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL const 5 const 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL const 5 const 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 1 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 0.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = ``.`i`) and (`test`.`t2`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 0.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = ``.`i`) and (`test`.`t2`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 0.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = ``.`i`) and (`test`.`t2`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 0.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 0.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t1`.`i` = ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL const 5 const 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL const 5 const 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL const 5 const 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 1 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = ``.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = ``.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = ``.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t1`.`i` = ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL const 5 const 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL const 5 const 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL const 5 const 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 1 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = ``.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = ``.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = ``.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +1 +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t1`.`i` = ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +1 +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL const 5 const 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL const 5 const 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL const 5 const 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 2 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 0.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = ``.`i`) and (`test`.`t2`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 0.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = ``.`i`) and (`test`.`t2`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 0.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = ``.`i`) and (`test`.`t2`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 0.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 0.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t1`.`i` = ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL const 5 const 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL const 5 const 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL const 5 const 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 2 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = ``.`i`) and (`test`.`t2`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = ``.`i`) and (`test`.`t2`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = ``.`i`) and (`test`.`t2`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t1`.`i` = ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL const 5 const 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL const 5 const 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL const 5 const 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 2 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE NULL eq_ref 5 test.t1.i 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = `test`.`t1`.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +1 +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +1 +2 + +EXECUTE stmt; +i +1 +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE NULL eq_ref 5 test.t1.i 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = `test`.`t1`.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +1 +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE NULL eq_ref 5 test.t1.i 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = `test`.`t1`.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +1 +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +1 +2 + +EXECUTE stmt; +i +1 +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE NULL eq_ref 5 test.t1.i 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (``.`i` = `test`.`t1`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +1 +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE NULL eq_ref 5 test.t1.i 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (``.`i` = `test`.`t1`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +1 +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL const 5 const 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL const 5 const 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (0); +DELETE FROM t2; +INSERT INTO t1 VALUES (0); +DROP TABLE t1, t2, t3; +create table x1(k int primary key, d1 int, d2 int); +create table x2(k int primary key, d1 int, d2 int); +insert into x1 values +(10, 10, 10), +(20, 20, 20), +(21, 20, null), +(30, null, 30), +(40, 40, 40); +insert into x2 values +(10, 10, 10), +(20, 20, 20), +(21, 20, null), +(30, null, 30); +select * +from x1 +where (d1, d2) in (select d1, d2 +from x2); +k d1 d2 +10 10 10 +20 20 20 +select * +from x1 +where (d1, d2) in (select d1, d2 +from x2) is true; +k d1 d2 +10 10 10 +20 20 20 +select * +from x1 +where (d1, d2) in (select d1, d2 +from x2) is false; +k d1 d2 +40 40 40 +select * +from x1 +where (d1, d2) in (select d1, d2 +from x2) is unknown; +k d1 d2 +21 20 NULL +30 NULL 30 +select * +from x1 +where d1 in (select d1 +from x2 +where x1.d2=x2.d2); +k d1 d2 +10 10 10 +20 20 20 +select * +from x1 +where d1 in (select d1 +from x2 +where x1.d2=x2.d2) is true; +k d1 d2 +10 10 10 +20 20 20 +select * +from x1 +where d1 in (select d1 +from x2 +where x1.d2=x2.d2) is false; +k d1 d2 +21 20 NULL +40 40 40 +select * +from x1 +where d1 in (select d1 +from x2 +where x1.d2=x2.d2) is unknown; +k d1 d2 +30 NULL 30 +select * +from x1 +where 1 in (select 1 +from x2 +where x1.d1=x2.d1 and x1.d2=x2.d2); +k d1 d2 +10 10 10 +20 20 20 +select * +from x1 +where 1 in (select 1 +from x2 +where x1.d1=x2.d1 and x1.d2=x2.d2) is true; +k d1 d2 +10 10 10 +20 20 20 +select * +from x1 +where 1 in (select 1 +from x2 +where x1.d1=x2.d1 and x1.d2=x2.d2) is false; +k d1 d2 +21 20 NULL +30 NULL 30 +40 40 40 +select * +from x1 +where 1 in (select 1 +from x2 +where x1.d1=x2.d1 and x1.d2=x2.d2) is unknown; +k d1 d2 +select * +from x1 +where exists (select * +from x2 +where x1.d1=x2.d1 and x1.d2=x2.d2); +k d1 d2 +10 10 10 +20 20 20 +drop table x1; +drop table x2; +CREATE TABLE t1 ( +a int(11) NOT NULL, +b int(11) NOT NULL, +c datetime default NULL, +PRIMARY KEY (a), +KEY idx_bc (b,c) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES +(406989,67,'2006-02-23 17:08:46'), (150078,67,'2005-10-26 11:17:45'), +(406993,67,'2006-02-27 11:20:57'), (245655,67,'2005-12-08 15:59:08'), +(406994,67,'2006-02-27 11:26:46'), (256,67,NULL), +(398341,67,'2006-02-20 04:48:44'), (254,67,NULL),(1120,67,NULL), +(406988,67,'2006-02-23 17:07:22'), (255,67,NULL), +(398340,67,'2006-02-20 04:38:53'),(406631,67,'2006-02-23 10:49:42'), +(245653,67,'2005-12-08 15:59:07'),(406992,67,'2006-02-24 16:47:18'), +(245654,67,'2005-12-08 15:59:08'),(406995,67,'2006-02-28 11:55:00'), +(127261,67,'2005-10-13 12:17:58'),(406991,67,'2006-02-24 16:42:32'), +(245652,67,'2005-12-08 15:58:27'),(398545,67,'2006-02-20 04:53:13'), +(154504,67,'2005-10-28 11:53:01'),(9199,67,NULL),(1,67,'2006-02-23 15:01:35'), +(223456,67,NULL),(4101,67,NULL),(1133,67,NULL), +(406990,67,'2006-02-23 18:01:45'),(148815,67,'2005-10-25 15:34:17'), +(148812,67,'2005-10-25 15:30:01'),(245651,67,'2005-12-08 15:58:27'), +(154503,67,'2005-10-28 11:52:38'); +create table t11 select * from t1 where b = 67 AND (c IS NULL OR c > NOW()) order by 3 asc; +create table t12 select * from t1 where b = 67 AND (c IS NULL OR c > NOW()) order by 3 desc; +create table t21 select * from t1 where b = 67 AND (c IS NULL OR c > '2005-12-08') order by 3 asc; +create table t22 select * from t1 where b = 67 AND (c IS NULL OR c > '2005-12-08') order by 3 desc; +update t22 set c = '2005-12-08 15:58:27' where a = 255; +explain select t21.* from t21,t22 where t21.a = t22.a and +t22.a in (select t12.a from t11, t12 where t11.a in(255,256) and t11.a = t12.a and t11.c is null) and t22.c is null order by t21.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using temporary; Using filesort +1 SIMPLE t22 NULL ALL NULL NULL NULL NULL 26 3.85 Using where +1 SIMPLE t21 NULL ALL NULL NULL NULL NULL 26 10.00 Using where +2 MATERIALIZED t11 NULL ALL NULL NULL NULL NULL 8 12.50 Using where +2 MATERIALIZED t12 NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t21`.`a` AS `a`,`test`.`t21`.`b` AS `b`,`test`.`t21`.`c` AS `c` from `test`.`t21` join `test`.`t22` semi join (`test`.`t11` join `test`.`t12`) where ((`test`.`t22`.`a` = ``.`a`) and (`test`.`t21`.`a` = ``.`a`) and (`test`.`t12`.`a` = `test`.`t11`.`a`) and (`test`.`t22`.`c` is null) and (`test`.`t11`.`a` in (255,256)) and (`test`.`t11`.`c` is null)) order by `test`.`t21`.`a` +explain format=json select * from t1 where a in (select a from t11); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "6.71" + }, + "nested_loop": [ + { + "table": { + "table_name": "", + "access_type": "ALL", + "materialized_from_subquery": { + "using_temporary_table": true, + "query_block": { + "table": { + "table_name": "t11", + "access_type": "ALL", + "rows_examined_per_scan": 8, + "rows_produced_per_join": 8, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "0.80", + "prefix_cost": "1.31", + "data_read_per_join": "128" + }, + "used_columns": [ + "a" + ] + } + } + } + } + }, + { + "table": { + "table_name": "t1", + "access_type": "eq_ref", + "possible_keys": [ + "PRIMARY" + ], + "key": "PRIMARY", + "used_key_parts": [ + "a" + ], + "key_length": "4", + "ref": [ + ".a" + ], + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.10", + "prefix_cost": "6.71", + "data_read_per_join": "16" + }, + "used_columns": [ + "a", + "b", + "c" + ] + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` semi join (`test`.`t11`) where (`test`.`t1`.`a` = ``.`a`) +select t21.* from t21,t22 where t21.a = t22.a and +t22.a in (select t12.a from t11, t12 where t11.a in(255,256) and t11.a = t12.a and t11.c is null) and t22.c is null order by t21.a; +a b c +256 67 NULL +drop table t1, t11, t12, t21, t22; +create table t1(a int); +insert into t1 values (0),(1); +explain +select (select max(y.a) from t1 y where a in (select a from t1 z) and a < x.a) as subq from t1 x; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY x NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DEPENDENT SUBQUERY y NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 DEPENDENT SUBQUERY NULL eq_ref 5 test.y.a 1 100.00 NULL +3 MATERIALIZED z NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1276 Field or reference 'test.x.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select (/* select#2 */ select max(`test`.`y`.`a`) from `test`.`t1` `y` semi join (`test`.`t1` `z`) where ((``.`a` = `test`.`y`.`a`) and (`test`.`y`.`a` < `test`.`x`.`a`))) AS `subq` from `test`.`t1` `x` +select (select max(y.a) from t1 y where a in (select a from t1 z) and a < x.a) as subq from t1 x; +subq +NULL +0 +drop table t1; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 as select * from t0; +insert into t1 select a+10 from t0; +insert into t0 values(2); +explain select * from t1 where 2 in (select a from t0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL const 5 const 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 20 100.00 NULL +2 MATERIALIZED t0 NULL ALL NULL NULL NULL NULL 11 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t0`) where ((``.`a` = 2) and (`test`.`t0`.`a` = 2)) +select * from t1 where 2 in (select a from t0); +a +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +explain select * from (select a from t0) x where a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 11 100.00 NULL +1 SIMPLE NULL eq_ref 5 func 1 100.00 Using where +3 MATERIALIZED t1 NULL ALL NULL NULL NULL NULL 20 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a` from `test`.`t0` semi join (`test`.`t1`) where (``.`a` = `test`.`t0`.`a`) +explain format=json select * from (select a from t0) x where a in (select a from t1); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "8.21" + }, + "nested_loop": [ + { + "table": { + "table_name": "t0", + "access_type": "ALL", + "rows_examined_per_scan": 11, + "rows_produced_per_join": 11, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "1.10", + "prefix_cost": "1.60", + "data_read_per_join": "88" + }, + "used_columns": [ + "a" + ] + } + }, + { + "table": { + "table_name": "", + "access_type": "eq_ref", + "key": "", + "key_length": "5", + "ref": [ + "func" + ], + "rows_examined_per_scan": 1, + "attached_condition": "(``.`a` = `test`.`t0`.`a`)", + "materialized_from_subquery": { + "using_temporary_table": true, + "query_block": { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 20, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "2.00", + "prefix_cost": "2.51", + "data_read_per_join": "160" + }, + "used_columns": [ + "a" + ] + } + } + } + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a` from `test`.`t0` semi join (`test`.`t1`) where (``.`a` = `test`.`t0`.`a`) +drop table t0, t1; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (kp1 int, kp2 int, c int, filler char(100), key(kp1, kp2)); +insert into t1 select A.a+10*(B.a+10*C.a), 0, 0, 'filler' from t0 A, t0 B, t0 C; +insert into t1 select * from t1 where kp1 < 20; +create table t3 (a int); +insert into t3 select A.a + 10*B.a from t0 A, t0 B; +explain select * from t3 where a in (select kp1 from t1 where kp1<20); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 100 100.00 Using where +1 SIMPLE NULL eq_ref 5 test.t3.a 1 100.00 NULL +2 MATERIALIZED t1 NULL range kp1 kp1 5 NULL 48 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a` from `test`.`t3` semi join (`test`.`t1`) where ((``.`kp1` = `test`.`t3`.`a`) and (`test`.`t1`.`kp1` < 20)) +select * from t3 where a in (select kp1 from t1 where kp1<20); +a +0 +1 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +2 +3 +4 +5 +6 +7 +8 +9 +explain select * from t3 where a in (select kp1 from t1 where kp1<20) and a<20; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 100 33.33 Using where +1 SIMPLE NULL eq_ref 5 test.t3.a 1 100.00 NULL +2 MATERIALIZED t1 NULL range kp1 kp1 5 NULL 48 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a` from `test`.`t3` semi join (`test`.`t1`) where ((``.`kp1` = `test`.`t3`.`a`) and (`test`.`t3`.`a` < 20) and (`test`.`t1`.`kp1` < 20)) +select * from t3 where a in (select kp1 from t1 where kp1<20) and a<20; +a +0 +1 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +2 +3 +4 +5 +6 +7 +8 +9 +create table t4 (pk int primary key); +insert into t4 select a from t3; +explain select * from t3 where a in +(select t1.kp1 from t1,t4 where kp1<20 and t4.pk=t1.c); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 100 100.00 Using where +1 SIMPLE NULL eq_ref 5 test.t3.a 1 100.00 NULL +2 MATERIALIZED t1 NULL range kp1 kp1 5 NULL 48 100.00 Using where +2 MATERIALIZED t4 NULL eq_ref PRIMARY PRIMARY 4 test.t1.c 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a` from `test`.`t3` semi join (`test`.`t1` join `test`.`t4`) where ((``.`kp1` = `test`.`t3`.`a`) and (`test`.`t4`.`pk` = `test`.`t1`.`c`) and (`test`.`t1`.`kp1` < 20)) +explain format=tree select * from t3 where a in +(select t1.kp1 from t1,t4 where kp1<20 and t4.pk=t1.c); +EXPLAIN +-> Nested loop inner join (cost=500.54 rows=4800) + -> Filter: (t3.a is not null) (cost=10.54 rows=100) + -> Table scan on t3 (cost=10.54 rows=100) + -> Single-row index lookup on using (kp1=t3.a) + -> Materialize with deduplication (cost=43.46..43.46 rows=48) + -> Filter: (t1.kp1 is not null) (cost=38.66 rows=48) + -> Nested loop inner join (cost=38.66 rows=48) + -> Filter: ((t1.kp1 < 20) and (t1.c is not null)) (cost=21.86 rows=48) + -> Index range scan on t1 using kp1 (cost=21.86 rows=48) + -> Single-row index lookup on t4 using PRIMARY (pk=t1.c) (cost=0.25 rows=1) + +select * from t3 where a in +(select t1.kp1 from t1,t4 where kp1<20 and t4.pk=t1.c); +a +0 +1 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +2 +3 +4 +5 +6 +7 +8 +9 +drop table t1, t3, t4; +create table t1 (a int); +insert into t1 values (0),(0),(0),(1),(1),(1),(2),(2),(2),(3),(3),(3); +set session internal_tmp_mem_storage_engine='memory'; +set @save_max_heap_table_size=@@max_heap_table_size; +set @@max_heap_table_size= 16384; +# Attempt to make one test that overflows the heap table when a +# non-duplicate row is inserted and one test that overflows the +# heap table when a duplicate record is inserted. Debugging showed +# that these situations occurred with max_heap_table_size=16384 +# and optimizer_join_cache_level equals 1 and 0, respectively. +# Finally execute a test that does not overflow the heap table. +explain +select count(*) from t0 a, t0 b, t0 c +where c.a in (select a from t1 d); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE a NULL ALL NULL NULL NULL NULL 10 100.00 NULL +1 SIMPLE b NULL ALL NULL NULL NULL NULL 10 100.00 NULL +1 SIMPLE c NULL ALL NULL NULL NULL NULL 10 100.00 Using where +1 SIMPLE NULL eq_ref 5 test.c.a 1 100.00 NULL +2 MATERIALIZED d NULL ALL NULL NULL NULL NULL 12 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select count(0) AS `count(*)` from `test`.`t0` `a` join `test`.`t0` `b` join `test`.`t0` `c` semi join (`test`.`t1` `d`) where (``.`a` = `test`.`c`.`a`) +flush status; +select count(*) from t0 a, t0 b, t0 c +where c.a in (select a from t1 d); +count(*) +400 +show status like 'Created_tmp_disk_tables'; +Variable_name Value +Created_tmp_disk_tables 0 +set @@max_heap_table_size= @save_max_heap_table_size; +set session internal_tmp_mem_storage_engine=default; +flush status; +select count(*) from t0 a, t0 b, t0 c +where c.a in (select a from t1 d); +count(*) +400 +show status like 'Created_tmp_disk_tables'; +Variable_name Value +Created_tmp_disk_tables 0 +drop table t0, t1; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t2(a int); +insert into t2 values (1),(2); +create table t3 ( a int , filler char(100), key(a)); +insert into t3 select A.a + 10*B.a, 'filler' from t0 A, t0 B; +explain select * from t3 where a in (select a from t2) and (a > 5 or a < 10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using where +1 SIMPLE t3 NULL ref a a 5 .a 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a`,`test`.`t3`.`filler` AS `filler` from `test`.`t3` semi join (`test`.`t2`) where ((`test`.`t3`.`a` = ``.`a`) and ((``.`a` > 5) or (``.`a` < 10))) +select * from t3 where a in (select a from t2); +a filler +1 filler +2 filler +drop table t0, t2, t3; +create table t1 (a date); +insert into t1 values ('2008-01-01'),('2008-01-01'),('2008-02-01'),('2008-02-01'); +create table t2 (a int); +insert into t2 values (1),(2); +create table t3 (a char(10)); +insert into t3 select * from t1; +insert into t3 values (1),(2); +explain select * from t2 where a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; Start temporary; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1`) where (cast(`test`.`t2`.`a` as double) = cast(`test`.`t1`.`a` as double)) +explain select * from t2 where a in (select a from t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE NULL eq_ref 5 test.t2.a 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t2`) where (``.`a` = `test`.`t2`.`a`) +explain select * from t2 where a in (select a from t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Start temporary; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t3`) where (cast(`test`.`t2`.`a` as double) = cast(`test`.`t3`.`a` as double)) +explain select * from t1 where a in (select a from t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Start temporary; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t3`) where (`test`.`t1`.`a` = cast(`test`.`t3`.`a` as date)) +drop table t1, t2, t3; +create table t1 (a decimal); +insert into t1 values (1),(2); +explain select * from t1 where a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE NULL eq_ref 6 test.t1.a 1 100.00 NULL +2 MATERIALIZED t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t1`) where (``.`a` = `test`.`t1`.`a`) +drop table t1; +create table t1 (a int); +insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t2 as select * from t1; +create table t3 (a int, b int, filler char(100), key(a)) charset utf8mb4; +insert into t3 select A.a + 10*B.a, A.a + 10*B.a, 'filler' from t1 A, t1 B, t1 C; +explain select * from t1, t3 where t3.a in (select a from t2) and (t3.a < 10 or t3.a >30) and t1.a =3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 10.00 Using where +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using where +1 SIMPLE t3 NULL ref a a 5 .a 10 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 10 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t3`.`filler` AS `filler` from `test`.`t1` join `test`.`t3` semi join (`test`.`t2`) where ((`test`.`t3`.`a` = ``.`a`) and (`test`.`t1`.`a` = 3) and ((``.`a` < 10) or (``.`a` > 30))) +explain format=json select * from t1, t3 where t3.a in (select a from t2) and (t3.a < 10 or t3.a >30) and t1.a =3; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "41.01" + }, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 10, + "rows_produced_per_join": 1, + "filtered": "10.00", + "cost_info": { + "read_cost": "1.40", + "eval_cost": "0.10", + "prefix_cost": "1.50", + "data_read_per_join": "8" + }, + "used_columns": [ + "a" + ], + "attached_condition": "(`test`.`t1`.`a` = 3)" + } + }, + { + "table": { + "table_name": "", + "access_type": "ALL", + "attached_condition": "(((``.`a` < 10) or (``.`a` > 30)) and (``.`a` is not null))", + "materialized_from_subquery": { + "using_temporary_table": true, + "query_block": { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 10, + "rows_produced_per_join": 10, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "1.00", + "prefix_cost": "1.50", + "data_read_per_join": "80" + }, + "used_columns": [ + "a" + ] + } + } + } + } + }, + { + "table": { + "table_name": "t3", + "access_type": "ref", + "possible_keys": [ + "a" + ], + "key": "a", + "used_key_parts": [ + "a" + ], + "key_length": "5", + "ref": [ + ".a" + ], + "rows_examined_per_scan": 10, + "rows_produced_per_join": 10, + "filtered": "100.00", + "cost_info": { + "read_cost": "25.00", + "eval_cost": "1.00", + "prefix_cost": "41.01", + "data_read_per_join": "4K" + }, + "used_columns": [ + "a", + "b", + "filler" + ] + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t3`.`filler` AS `filler` from `test`.`t1` join `test`.`t3` semi join (`test`.`t2`) where ((`test`.`t3`.`a` = ``.`a`) and (`test`.`t1`.`a` = 3) and ((``.`a` < 10) or (``.`a` > 30))) +explain select straight_join * from t1 a, t1 b where a.a in (select a from t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY a NULL ALL NULL NULL NULL NULL 10 100.00 Using where +1 PRIMARY b NULL ALL NULL NULL NULL NULL 10 100.00 NULL +2 SUBQUERY t2 NULL ALL NULL NULL NULL NULL 10 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select straight_join `test`.`a`.`a` AS `a`,`test`.`b`.`a` AS `a` from `test`.`t1` `a` join `test`.`t1` `b` where (`test`.`a`.`a`,`test`.`a`.`a` in ( (/* select#2 */ select `test`.`t2`.`a` from `test`.`t2` where true ), (`test`.`a`.`a` in on where ((`test`.`a`.`a` = ``.`a`))))) +explain select * from t2 where a in (select straight_join a.a from t1 a, t1 b); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 10 100.00 Using where +2 SUBQUERY a NULL ALL NULL NULL NULL NULL 10 100.00 NULL +2 SUBQUERY b NULL ALL NULL NULL NULL NULL 10 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` where (`test`.`t2`.`a`,`test`.`t2`.`a` in ( (/* select#2 */ select straight_join `test`.`a`.`a` from `test`.`t1` `a` join `test`.`t1` `b` where true ), (`test`.`t2`.`a` in on where ((`test`.`t2`.`a` = ``.`a`))))) +explain select * from t2 where a in (select straight_join a.a from t1 a, t1 b); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 10 100.00 Using where +2 SUBQUERY a NULL ALL NULL NULL NULL NULL 10 100.00 NULL +2 SUBQUERY b NULL ALL NULL NULL NULL NULL 10 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` where (`test`.`t2`.`a`,`test`.`t2`.`a` in ( (/* select#2 */ select straight_join `test`.`a`.`a` from `test`.`t1` `a` join `test`.`t1` `b` where true ), (`test`.`t2`.`a` in on where ((`test`.`t2`.`a` = ``.`a`))))) +explain select straight_join * from t2 x, t2 y +where x.a in (select straight_join a.a from t1 a, t1 b); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY x NULL ALL NULL NULL NULL NULL 10 100.00 Using where +1 PRIMARY y NULL ALL NULL NULL NULL NULL 10 100.00 NULL +2 SUBQUERY a NULL ALL NULL NULL NULL NULL 10 100.00 NULL +2 SUBQUERY b NULL ALL NULL NULL NULL NULL 10 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select straight_join `test`.`x`.`a` AS `a`,`test`.`y`.`a` AS `a` from `test`.`t2` `x` join `test`.`t2` `y` where (`test`.`x`.`a`,`test`.`x`.`a` in ( (/* select#2 */ select straight_join `test`.`a`.`a` from `test`.`t1` `a` join `test`.`t1` `b` where true ), (`test`.`x`.`a` in on where ((`test`.`x`.`a` = ``.`a`))))) +create table t0 (a int, b int); +insert into t0 values(1,1); +explain select * from t0, t3 where t3.a in (select a from t2) and (t3.a < 10 or t3.a >30); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using where +1 SIMPLE t3 NULL ref a a 5 .a 10 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 10 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select '1' AS `a`,'1' AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t3`.`filler` AS `filler` from `test`.`t3` semi join (`test`.`t2`) where ((`test`.`t3`.`a` = ``.`a`) and ((``.`a` < 10) or (``.`a` > 30))) +create table t4 as select a as x, a as y from t1; +explain select * from t0, t3 where (t3.a, t3.b) in (select x,y from t4) and (t3.a < 10 or t3.a >30); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using where +1 SIMPLE t3 NULL ref a a 5 .x 10 10.00 Using where +2 MATERIALIZED t4 NULL ALL NULL NULL NULL NULL 10 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select '1' AS `a`,'1' AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t3`.`filler` AS `filler` from `test`.`t3` semi join (`test`.`t4`) where ((`test`.`t3`.`b` = ``.`y`) and (`test`.`t3`.`a` = ``.`x`) and ((``.`x` < 10) or (``.`x` > 30))) +drop table t0,t1,t2,t3,t4; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (a int, b int, filler char(100), key(a,b)); +insert into t1 select A.a, B.a, 'filler' from t0 A, t0 B; +create table t2 as select * from t1; +explain select * from t2 where a in (select b from t1 where a=3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 100 100.00 Using where +1 SIMPLE NULL eq_ref 5 test.t2.a 1 100.00 NULL +2 MATERIALIZED t1 NULL ref a a 5 const 8 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`filler` AS `filler` from `test`.`t2` semi join (`test`.`t1`) where ((``.`b` = `test`.`t2`.`a`) and (`test`.`t1`.`a` = 3)) +explain select * from t2 where (b,a) in (select a,b from t1 where a=3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 100 10.00 Using where +1 SIMPLE NULL eq_ref 10 test.t2.b,test.t2.a 1 100.00 Using where +2 MATERIALIZED t1 NULL ref a a 5 const 8 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`filler` AS `filler` from `test`.`t2` semi join (`test`.`t1`) where ((``.`b` = `test`.`t2`.`a`) and (`test`.`t2`.`b` = 3) and (``.`a` = 3) and (`test`.`t1`.`a` = 3)) +drop table t1,t2; +create table t1 (a int, b int); +insert into t1 select a,a from t0; +create table t2 (a int, b int); +insert into t2 select A.a + 10*B.a, A.a + 10*B.a from t0 A, t0 B; +explain select * from t1 where (a,b) in (select a,b from t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 100.00 Using where +1 SIMPLE NULL eq_ref 10 test.t1.a,test.t1.b 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 100 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t2`) where ((``.`b` = `test`.`t1`.`b`) and (``.`a` = `test`.`t1`.`a`)) +drop table t0, t1, t2; +# +# Bug#19695490: CRASH IN CREATE_REF_FOR_KEY ON SELECT + JOIN + UTF8 COLUMN +# + DATETIME INDEX. +# +CREATE TABLE t1 ( +field1 varchar(255) CHARACTER SET utf8, +field2 varchar(255) CHARACTER SET utf8 +); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES +('time','time'), +('lpjdzvkp','lpjdzvkp'), +('dzvkpai', 'dzvkpai'); +CREATE TABLE t2 ( col_varchar varchar(10)); +CREATE TABLE t3 ( +pk int(11) NOT NULL, +col_varchar_255_utf8_key varchar(255) CHARACTER SET utf8, +col_varchar_10_utf8_key varchar(10) CHARACTER SET utf8, +PRIMARY KEY (pk) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t3 VALUES (22,'come','h'), +(23,'time','aaa'), +(24,'lpjdzvkp','ababa'), +(25,'d','GGDD'); +SELECT * FROM t1 WHERE (field1, field2) IN ( +SELECT table1.col_varchar_255_utf8_key AS field1, +table1.col_varchar_255_utf8_key AS field2 +FROM t3 AS table1 LEFT JOIN t2 AS table2 +ON table1.col_varchar_10_utf8_key <= +table2.col_varchar +WHERE table1.pk >= 6); +field1 field2 +time time +lpjdzvkp lpjdzvkp +DROP TABLE t1,t2,t3; +create table t0 (a decimal(4,2)); +insert into t0 values (10.24), (22.11); +create table t1 as select * from t0; +insert into t1 select * from t0; +explain select * from t0 where a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE NULL eq_ref 3 test.t0.a 1 100.00 NULL +2 MATERIALIZED t1 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a` from `test`.`t0` semi join (`test`.`t1`) where (``.`a` = `test`.`t0`.`a`) +select * from t0 where a in (select a from t1); +a +10.24 +22.11 +drop table t0, t1; +create table t0(a date); +insert into t0 values ('2008-01-01'),('2008-02-02'); +create table t1 as select * from t0; +insert into t1 select * from t0; +explain select * from t0 where a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE NULL eq_ref 4 test.t0.a 1 100.00 NULL +2 MATERIALIZED t1 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a` from `test`.`t0` semi join (`test`.`t1`) where (``.`a` = `test`.`t0`.`a`) +select * from t0 where a in (select a from t1); +a +2008-01-01 +2008-02-02 +drop table t0, t1; +create table t0(a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 as select a as a, a as b, a as c from t0 where a < 3; +create table t2 as select a as a, a as b from t0 where a < 3; +insert into t2 select * from t2; +explain select * from t1 where (a,b,c) in (select x.a, y.a, z.a from t2 x, t2 y, t2 z where x.b=33); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE NULL eq_ref 15 test.t1.a,test.t1.b,test.t1.c 1 100.00 NULL +2 MATERIALIZED x NULL ALL NULL NULL NULL NULL 6 16.67 Using where +2 MATERIALIZED y NULL ALL NULL NULL NULL NULL 6 100.00 NULL +2 MATERIALIZED z NULL ALL NULL NULL NULL NULL 6 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` semi join (`test`.`t2` `x` join `test`.`t2` `y` join `test`.`t2` `z`) where ((``.`a` = `test`.`t1`.`c`) and (``.`a` = `test`.`t1`.`b`) and (``.`a` = `test`.`t1`.`a`) and (`test`.`x`.`b` = 33)) +drop table t0,t1,t2; +set @save_join_buffer_size = @@join_buffer_size; +set join_buffer_size= 8192; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (a int, filler1 binary(200), filler2 binary(200)); +insert into t1 select a, 'filler123456', 'filler123456' from t0; +insert into t1 select a+10, 'filler123456', 'filler123456' from t0; +create table t2 as select * from t1; +insert into t1 select a+20, 'filler123456', 'filler123456' from t0; +insert into t1 values (2, 'duplicate ok', 'duplicate ok'); +insert into t1 values (18, 'duplicate ok', 'duplicate ok'); +insert into t2 values (3, 'duplicate ok', 'duplicate ok'); +insert into t2 values (19, 'duplicate ok', 'duplicate ok'); +explain select +a, mid(filler1, 1,10), length(filler1)=length(filler2) as z +from t1 ot where a in (select a from t2 it); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 32 10.00 Using where +2 MATERIALIZED it NULL ALL NULL NULL NULL NULL 22 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot`.`a` AS `a`,substr(`test`.`ot`.`filler1`,1,10) AS `mid(filler1, 1,10)`,(length(`test`.`ot`.`filler1`) = length(`test`.`ot`.`filler2`)) AS `z` from `test`.`t1` `ot` semi join (`test`.`t2` `it`) where (`test`.`ot`.`a` = ``.`a`) +select +a, mid(filler1, 1,10), length(filler1)=length(filler2) as z +from t1 ot where a in (select a from t2 it); +a mid(filler1, 1,10) z +0 filler1234 1 +1 filler1234 1 +10 filler1234 1 +11 filler1234 1 +12 filler1234 1 +13 filler1234 1 +14 filler1234 1 +15 filler1234 1 +16 filler1234 1 +17 filler1234 1 +18 duplicate 1 +18 filler1234 1 +19 filler1234 1 +2 duplicate 1 +2 filler1234 1 +3 filler1234 1 +4 filler1234 1 +5 filler1234 1 +6 filler1234 1 +7 filler1234 1 +8 filler1234 1 +9 filler1234 1 +explain select +a, mid(filler1, 1,10), length(filler1)=length(filler2) +from t2 ot where a in (select a from t1 it); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 22 100.00 Using where +1 SIMPLE NULL eq_ref 5 test.ot.a 1 100.00 NULL +2 MATERIALIZED it NULL ALL NULL NULL NULL NULL 32 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot`.`a` AS `a`,substr(`test`.`ot`.`filler1`,1,10) AS `mid(filler1, 1,10)`,(length(`test`.`ot`.`filler1`) = length(`test`.`ot`.`filler2`)) AS `length(filler1)=length(filler2)` from `test`.`t2` `ot` semi join (`test`.`t1` `it`) where (``.`a` = `test`.`ot`.`a`) +select +a, mid(filler1, 1,10), length(filler1)=length(filler2) +from t2 ot where a in (select a from t1 it); +a mid(filler1, 1,10) length(filler1)=length(filler2) +0 filler1234 1 +1 filler1234 1 +10 filler1234 1 +11 filler1234 1 +12 filler1234 1 +13 filler1234 1 +14 filler1234 1 +15 filler1234 1 +16 filler1234 1 +17 filler1234 1 +18 filler1234 1 +19 duplicate 1 +19 filler1234 1 +2 filler1234 1 +3 duplicate 1 +3 filler1234 1 +4 filler1234 1 +5 filler1234 1 +6 filler1234 1 +7 filler1234 1 +8 filler1234 1 +9 filler1234 1 +insert into t1 select a+20, 'filler123456', 'filler123456' from t0; +insert into t1 select a+20, 'filler123456', 'filler123456' from t0; +explain select +a, mid(filler1, 1,10), length(filler1)=length(filler2) as z +from t1 ot where a in (select a from t2 it); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 52 10.00 Using where +2 MATERIALIZED it NULL ALL NULL NULL NULL NULL 22 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot`.`a` AS `a`,substr(`test`.`ot`.`filler1`,1,10) AS `mid(filler1, 1,10)`,(length(`test`.`ot`.`filler1`) = length(`test`.`ot`.`filler2`)) AS `z` from `test`.`t1` `ot` semi join (`test`.`t2` `it`) where (`test`.`ot`.`a` = ``.`a`) +select +a, mid(filler1, 1,10), length(filler1)=length(filler2) as z +from t1 ot where a in (select a from t2 it); +a mid(filler1, 1,10) z +0 filler1234 1 +1 filler1234 1 +10 filler1234 1 +11 filler1234 1 +12 filler1234 1 +13 filler1234 1 +14 filler1234 1 +15 filler1234 1 +16 filler1234 1 +17 filler1234 1 +18 duplicate 1 +18 filler1234 1 +19 filler1234 1 +2 duplicate 1 +2 filler1234 1 +3 filler1234 1 +4 filler1234 1 +5 filler1234 1 +6 filler1234 1 +7 filler1234 1 +8 filler1234 1 +9 filler1234 1 +explain select +a, mid(filler1, 1,10), length(filler1)=length(filler2) +from t2 ot where a in (select a from t1 it); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 22 100.00 Using where +1 SIMPLE NULL eq_ref 5 test.ot.a 1 100.00 NULL +2 MATERIALIZED it NULL ALL NULL NULL NULL NULL 52 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot`.`a` AS `a`,substr(`test`.`ot`.`filler1`,1,10) AS `mid(filler1, 1,10)`,(length(`test`.`ot`.`filler1`) = length(`test`.`ot`.`filler2`)) AS `length(filler1)=length(filler2)` from `test`.`t2` `ot` semi join (`test`.`t1` `it`) where (``.`a` = `test`.`ot`.`a`) +select +a, mid(filler1, 1,10), length(filler1)=length(filler2) +from t2 ot where a in (select a from t1 it); +a mid(filler1, 1,10) length(filler1)=length(filler2) +0 filler1234 1 +1 filler1234 1 +10 filler1234 1 +11 filler1234 1 +12 filler1234 1 +13 filler1234 1 +14 filler1234 1 +15 filler1234 1 +16 filler1234 1 +17 filler1234 1 +18 filler1234 1 +19 duplicate 1 +19 filler1234 1 +2 filler1234 1 +3 duplicate 1 +3 filler1234 1 +4 filler1234 1 +5 filler1234 1 +6 filler1234 1 +7 filler1234 1 +8 filler1234 1 +9 filler1234 1 +set @@join_buffer_size = @save_join_buffer_size; +drop table t1, t2; +create table t1 (a int, b int, key(a)); +create table t2 (a int, b int, key(a)); +create table t3 (a int, b int, key(a)); +insert into t1 select a,a from t0; +insert into t2 select a,a from t0; +insert into t3 select a,a from t0; +t2 and t3 must be use 'ref', not 'ALL': +explain select * +from t0 where a in +(select t2.a+t3.a from t1 left join (t2 join t3) on t2.a=t1.a and t3.a=t1.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 10 100.00 Using where +1 SIMPLE NULL eq_ref 9 test.t0.a 1 100.00 Using where +2 MATERIALIZED t1 NULL index a a 5 NULL 10 100.00 Using index +2 MATERIALIZED t2 NULL ref a a 5 test.t1.a 1 100.00 Using index +2 MATERIALIZED t3 NULL ref a a 5 test.t1.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a` from `test`.`t0` semi join (`test`.`t1` join `test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`a` = `test`.`t1`.`a`) and (`test`.`t3`.`a` = `test`.`t1`.`a`) and (`test`.`t0`.`a` = ``.`t2.a+t3.a`)) +drop table t0, t1,t2,t3; + +Test that neither MaterializeLookup strategy for semijoin, +nor subquery materialization is used when BLOBs are involved +(except when arguments of some functions). + +set @prefix_len = 6; +set @blob_len = 16; +set @suffix_len = @blob_len - @prefix_len; +create table t1_16 (a1 blob(16), a2 blob(16)); +create table t2_16 (b1 blob(16), b2 blob(16)); +create table t3_16 (c1 blob(16), c2 blob(16)); +insert into t1_16 values +(concat('1 - 00', repeat('x', @suffix_len)), concat('2 - 00', repeat('x', @suffix_len))); +insert into t1_16 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t1_16 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_16 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t2_16 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_16 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_16 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t3_16 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t3_16 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_16 values +(concat('1 - 04', repeat('x', @suffix_len)), concat('2 - 04', repeat('x', @suffix_len))); +explain select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select b1 from t2_16 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1_16 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +2 MATERIALIZED t2_16 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_16`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_16`.`a2`,7) AS `left(a2,7)` from `test`.`t1_16` semi join (`test`.`t2_16`) where ((`test`.`t1_16`.`a1` = ``.`b1`) and (`test`.`t2_16`.`b1` > '0')) +select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select b1 from t2_16 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_16 +where (a1,a2) in (select b1, b2 from t2_16 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1_16 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +2 MATERIALIZED t2_16 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_16`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_16`.`a2`,7) AS `left(a2,7)` from `test`.`t1_16` semi join (`test`.`t2_16`) where ((`test`.`t1_16`.`a2` = ``.`b2`) and (`test`.`t1_16`.`a1` = ``.`b1`) and (`test`.`t2_16`.`b1` > '0')) +select left(a1,7), left(a2,7) +from t1_16 +where (a1,a2) in (select b1, b2 from t2_16 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select substring(b1,1,16) from t2_16 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1_16 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +2 MATERIALIZED t2_16 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_16`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_16`.`a2`,7) AS `left(a2,7)` from `test`.`t1_16` semi join (`test`.`t2_16`) where ((`test`.`t2_16`.`b1` > '0') and (`test`.`t1_16`.`a1` = ``.`substring(b1,1,16)`)) +select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select substring(b1,1,16) from t2_16 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select group_concat(b1) from t2_16 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_16 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t2_16 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_16`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_16`.`a2`,7) AS `left(a2,7)` from `test`.`t1_16` where (`test`.`t1_16`.`a1`,(/* select#2 */ select group_concat(`test`.`t2_16`.`b1` separator ',') from `test`.`t2_16` group by `test`.`t2_16`.`b2` having ((`test`.`t1_16`.`a1`) = (group_concat(`test`.`t2_16`.`b1` separator ','))))) +select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select group_concat(b1) from t2_16 group by b2); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +set @@group_concat_max_len = 256; +explain select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select group_concat(b1) from t2_16 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_16 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 SUBQUERY t2_16 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_16`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_16`.`a2`,7) AS `left(a2,7)` from `test`.`t1_16` where (`test`.`t1_16`.`a1`,`test`.`t1_16`.`a1` in ( (/* select#2 */ select group_concat(`test`.`t2_16`.`b1` separator ',') from `test`.`t2_16` group by `test`.`t2_16`.`b2` having true ), (`test`.`t1_16`.`a1` in on where ((`test`.`t1_16`.`a1` = ``.`group_concat(b1)`))))) +select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select group_concat(b1) from t2_16 group by b2); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +create table t1 (a1 char(8), a2 char(8)) charset latin1; +create table t2 (b1 char(8), b2 char(8)) charset latin1; +create table t3 (c1 char(8), c2 char(8)) charset latin1; +insert into t1 values ('1 - 00', '2 - 00'); +insert into t1 values ('1 - 01', '2 - 01'); +insert into t1 values ('1 - 02', '2 - 02'); +insert into t2 values ('1 - 01', '2 - 01'); +insert into t2 values ('1 - 01', '2 - 01'); +insert into t2 values ('1 - 02', '2 - 02'); +insert into t2 values ('1 - 02', '2 - 02'); +insert into t2 values ('1 - 03', '2 - 03'); +insert into t3 values ('1 - 01', '2 - 01'); +insert into t3 values ('1 - 02', '2 - 02'); +insert into t3 values ('1 - 03', '2 - 03'); +insert into t3 values ('1 - 04', '2 - 04'); +insert into t3 values ('1 - 05', '2 - 05'); +insert into t3 values ('1 - 06', '2 - 06'); +insert into t3 values ('1 - 07', '2 - 07'); +insert into t3 values ('1 - 08', '2 - 08'); +explain +select * from t1 +where concat(a1,'x') IN +(select left(a1,8) from t1_16 +where (a1, a2) IN +(select t2_16.b1, t2_16.b2 from t2_16, t2 +where t2.b2 = substring(t2_16.b2,1,6) and +t2.b1 IN (select c1 from t3 where c2 > '0'))); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1_16 NULL ALL NULL NULL NULL NULL 3 100.00 Start temporary +1 SIMPLE t2_16 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 5 20.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 8 12.50 Using where +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` semi join (`test`.`t1_16` join `test`.`t2_16` join `test`.`t2` join `test`.`t3`) where ((`test`.`t2_16`.`b2` = `test`.`t1_16`.`a2`) and (`test`.`t2_16`.`b1` = `test`.`t1_16`.`a1`) and (`test`.`t3`.`c1` = `test`.`t2`.`b1`) and (`test`.`t2`.`b2` = substr(`test`.`t2_16`.`b2`,1,6)) and (`test`.`t3`.`c2` > '0') and (concat(`test`.`t1`.`a1`,'x') = left(`test`.`t1_16`.`a1`,8))) +drop table t1_16, t2_16, t3_16, t1, t2, t3; +set @blob_len = 512; +set @suffix_len = @blob_len - @prefix_len; +create table t1_512 (a1 blob(512), a2 blob(512)); +create table t2_512 (b1 blob(512), b2 blob(512)); +create table t3_512 (c1 blob(512), c2 blob(512)); +insert into t1_512 values +(concat('1 - 00', repeat('x', @suffix_len)), concat('2 - 00', repeat('x', @suffix_len))); +insert into t1_512 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t1_512 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_512 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t2_512 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_512 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_512 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t3_512 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t3_512 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_512 values +(concat('1 - 04', repeat('x', @suffix_len)), concat('2 - 04', repeat('x', @suffix_len))); +explain select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select b1 from t2_512 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1_512 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +2 MATERIALIZED t2_512 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_512`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_512`.`a2`,7) AS `left(a2,7)` from `test`.`t1_512` semi join (`test`.`t2_512`) where ((`test`.`t1_512`.`a1` = ``.`b1`) and (`test`.`t2_512`.`b1` > '0')) +select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select b1 from t2_512 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_512 +where (a1,a2) in (select b1, b2 from t2_512 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1_512 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +2 MATERIALIZED t2_512 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_512`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_512`.`a2`,7) AS `left(a2,7)` from `test`.`t1_512` semi join (`test`.`t2_512`) where ((`test`.`t1_512`.`a2` = ``.`b2`) and (`test`.`t1_512`.`a1` = ``.`b1`) and (`test`.`t2_512`.`b1` > '0')) +select left(a1,7), left(a2,7) +from t1_512 +where (a1,a2) in (select b1, b2 from t2_512 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select substring(b1,1,512) from t2_512 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1_512 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +2 MATERIALIZED t2_512 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_512`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_512`.`a2`,7) AS `left(a2,7)` from `test`.`t1_512` semi join (`test`.`t2_512`) where ((`test`.`t2_512`.`b1` > '0') and (`test`.`t1_512`.`a1` = ``.`substring(b1,1,512)`)) +select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select substring(b1,1,512) from t2_512 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select group_concat(b1) from t2_512 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_512 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 SUBQUERY t2_512 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_512`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_512`.`a2`,7) AS `left(a2,7)` from `test`.`t1_512` where (`test`.`t1_512`.`a1`,`test`.`t1_512`.`a1` in ( (/* select#2 */ select group_concat(`test`.`t2_512`.`b1` separator ',') from `test`.`t2_512` group by `test`.`t2_512`.`b2` having true ), (`test`.`t1_512`.`a1` in on where ((`test`.`t1_512`.`a1` = ``.`group_concat(b1)`))))) +select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select group_concat(b1) from t2_512 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +set @@group_concat_max_len = 256; +explain select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select group_concat(b1) from t2_512 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_512 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 SUBQUERY t2_512 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_512`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_512`.`a2`,7) AS `left(a2,7)` from `test`.`t1_512` where (`test`.`t1_512`.`a1`,`test`.`t1_512`.`a1` in ( (/* select#2 */ select group_concat(`test`.`t2_512`.`b1` separator ',') from `test`.`t2_512` group by `test`.`t2_512`.`b2` having true ), (`test`.`t1_512`.`a1` in on where ((`test`.`t1_512`.`a1` = ``.`group_concat(b1)`))))) +select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select group_concat(b1) from t2_512 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +drop table t1_512, t2_512, t3_512; +set @blob_len = 513; +set @suffix_len = @blob_len - @prefix_len; +create table t1_513 (a1 blob(513), a2 blob(513)); +create table t2_513 (b1 blob(513), b2 blob(513)); +create table t3_513 (c1 blob(513), c2 blob(513)); +insert into t1_513 values +(concat('1 - 00', repeat('x', @suffix_len)), concat('2 - 00', repeat('x', @suffix_len))); +insert into t1_513 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t1_513 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_513 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t2_513 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_513 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_513 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t3_513 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t3_513 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_513 values +(concat('1 - 04', repeat('x', @suffix_len)), concat('2 - 04', repeat('x', @suffix_len))); +explain select left(a1,7), left(a2,7) +from t1_513 +where a1 in (select b1 from t2_513 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1_513 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +2 MATERIALIZED t2_513 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_513`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_513`.`a2`,7) AS `left(a2,7)` from `test`.`t1_513` semi join (`test`.`t2_513`) where ((`test`.`t1_513`.`a1` = ``.`b1`) and (`test`.`t2_513`.`b1` > '0')) +select left(a1,7), left(a2,7) +from t1_513 +where a1 in (select b1 from t2_513 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_513 +where (a1,a2) in (select b1, b2 from t2_513 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1_513 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +2 MATERIALIZED t2_513 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_513`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_513`.`a2`,7) AS `left(a2,7)` from `test`.`t1_513` semi join (`test`.`t2_513`) where ((`test`.`t1_513`.`a2` = ``.`b2`) and (`test`.`t1_513`.`a1` = ``.`b1`) and (`test`.`t2_513`.`b1` > '0')) +select left(a1,7), left(a2,7) +from t1_513 +where (a1,a2) in (select b1, b2 from t2_513 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_513 +where a1 in (select substring(b1,1,513) from t2_513 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1_513 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +2 MATERIALIZED t2_513 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_513`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_513`.`a2`,7) AS `left(a2,7)` from `test`.`t1_513` semi join (`test`.`t2_513`) where ((`test`.`t2_513`.`b1` > '0') and (`test`.`t1_513`.`a1` = ``.`substring(b1,1,513)`)) +select left(a1,7), left(a2,7) +from t1_513 +where a1 in (select substring(b1,1,513) from t2_513 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_513 +where a1 in (select group_concat(b1) from t2_513 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_513 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 SUBQUERY t2_513 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_513`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_513`.`a2`,7) AS `left(a2,7)` from `test`.`t1_513` where (`test`.`t1_513`.`a1`,`test`.`t1_513`.`a1` in ( (/* select#2 */ select group_concat(`test`.`t2_513`.`b1` separator ',') from `test`.`t2_513` group by `test`.`t2_513`.`b2` having true ), (`test`.`t1_513`.`a1` in on where ((`test`.`t1_513`.`a1` = ``.`group_concat(b1)`))))) +select left(a1,7), left(a2,7) +from t1_513 +where a1 in (select group_concat(b1) from t2_513 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +drop table t1_513, t2_513, t3_513; +set @blob_len = 1024; +set @suffix_len = @blob_len - @prefix_len; +create table t1_1024 (a1 blob(1024), a2 blob(1024)); +create table t2_1024 (b1 blob(1024), b2 blob(1024)); +create table t3_1024 (c1 blob(1024), c2 blob(1024)); +insert into t1_1024 values +(concat('1 - 00', repeat('x', @suffix_len)), concat('2 - 00', repeat('x', @suffix_len))); +insert into t1_1024 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t1_1024 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_1024 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t2_1024 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_1024 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_1024 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t3_1024 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t3_1024 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_1024 values +(concat('1 - 04', repeat('x', @suffix_len)), concat('2 - 04', repeat('x', @suffix_len))); +explain select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select b1 from t2_1024 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1_1024 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +2 MATERIALIZED t2_1024 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1024`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1024`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1024` semi join (`test`.`t2_1024`) where ((`test`.`t1_1024`.`a1` = ``.`b1`) and (`test`.`t2_1024`.`b1` > '0')) +select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select b1 from t2_1024 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_1024 +where (a1,a2) in (select b1, b2 from t2_1024 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1_1024 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +2 MATERIALIZED t2_1024 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1024`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1024`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1024` semi join (`test`.`t2_1024`) where ((`test`.`t1_1024`.`a2` = ``.`b2`) and (`test`.`t1_1024`.`a1` = ``.`b1`) and (`test`.`t2_1024`.`b1` > '0')) +select left(a1,7), left(a2,7) +from t1_1024 +where (a1,a2) in (select b1, b2 from t2_1024 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select substring(b1,1,1024) from t2_1024 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1_1024 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +2 MATERIALIZED t2_1024 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1024`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1024`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1024` semi join (`test`.`t2_1024`) where ((`test`.`t2_1024`.`b1` > '0') and (`test`.`t1_1024`.`a1` = ``.`substring(b1,1,1024)`)) +select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select substring(b1,1,1024) from t2_1024 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select group_concat(b1) from t2_1024 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_1024 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 SUBQUERY t2_1024 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1024`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1024`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1024` where (`test`.`t1_1024`.`a1`,`test`.`t1_1024`.`a1` in ( (/* select#2 */ select group_concat(`test`.`t2_1024`.`b1` separator ',') from `test`.`t2_1024` group by `test`.`t2_1024`.`b2` having true ), (`test`.`t1_1024`.`a1` in on where ((`test`.`t1_1024`.`a1` = ``.`group_concat(b1)`))))) +select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select group_concat(b1) from t2_1024 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +set @@group_concat_max_len = 256; +explain select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select group_concat(b1) from t2_1024 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_1024 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 SUBQUERY t2_1024 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1024`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1024`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1024` where (`test`.`t1_1024`.`a1`,`test`.`t1_1024`.`a1` in ( (/* select#2 */ select group_concat(`test`.`t2_1024`.`b1` separator ',') from `test`.`t2_1024` group by `test`.`t2_1024`.`b2` having true ), (`test`.`t1_1024`.`a1` in on where ((`test`.`t1_1024`.`a1` = ``.`group_concat(b1)`))))) +select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select group_concat(b1) from t2_1024 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +drop table t1_1024, t2_1024, t3_1024; +set @blob_len = 1025; +set @suffix_len = @blob_len - @prefix_len; +create table t1_1025 (a1 blob(1025), a2 blob(1025)); +create table t2_1025 (b1 blob(1025), b2 blob(1025)); +create table t3_1025 (c1 blob(1025), c2 blob(1025)); +insert into t1_1025 values +(concat('1 - 00', repeat('x', @suffix_len)), concat('2 - 00', repeat('x', @suffix_len))); +insert into t1_1025 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t1_1025 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_1025 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t2_1025 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_1025 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_1025 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t3_1025 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t3_1025 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_1025 values +(concat('1 - 04', repeat('x', @suffix_len)), concat('2 - 04', repeat('x', @suffix_len))); +explain select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select b1 from t2_1025 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1_1025 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +2 MATERIALIZED t2_1025 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1025`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1025`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1025` semi join (`test`.`t2_1025`) where ((`test`.`t1_1025`.`a1` = ``.`b1`) and (`test`.`t2_1025`.`b1` > '0')) +select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select b1 from t2_1025 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_1025 +where (a1,a2) in (select b1, b2 from t2_1025 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1_1025 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +2 MATERIALIZED t2_1025 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1025`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1025`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1025` semi join (`test`.`t2_1025`) where ((`test`.`t1_1025`.`a2` = ``.`b2`) and (`test`.`t1_1025`.`a1` = ``.`b1`) and (`test`.`t2_1025`.`b1` > '0')) +select left(a1,7), left(a2,7) +from t1_1025 +where (a1,a2) in (select b1, b2 from t2_1025 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select substring(b1,1,1025) from t2_1025 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1_1025 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +2 MATERIALIZED t2_1025 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1025`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1025`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1025` semi join (`test`.`t2_1025`) where ((`test`.`t2_1025`.`b1` > '0') and (`test`.`t1_1025`.`a1` = ``.`substring(b1,1,1025)`)) +select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select substring(b1,1,1025) from t2_1025 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select group_concat(b1) from t2_1025 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_1025 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 SUBQUERY t2_1025 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1025`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1025`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1025` where (`test`.`t1_1025`.`a1`,`test`.`t1_1025`.`a1` in ( (/* select#2 */ select group_concat(`test`.`t2_1025`.`b1` separator ',') from `test`.`t2_1025` group by `test`.`t2_1025`.`b2` having true ), (`test`.`t1_1025`.`a1` in on where ((`test`.`t1_1025`.`a1` = ``.`group_concat(b1)`))))) +select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select group_concat(b1) from t2_1025 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +set @@group_concat_max_len = 256; +explain select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select group_concat(b1) from t2_1025 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_1025 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 SUBQUERY t2_1025 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1025`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1025`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1025` where (`test`.`t1_1025`.`a1`,`test`.`t1_1025`.`a1` in ( (/* select#2 */ select group_concat(`test`.`t2_1025`.`b1` separator ',') from `test`.`t2_1025` group by `test`.`t2_1025`.`b2` having true ), (`test`.`t1_1025`.`a1` in on where ((`test`.`t1_1025`.`a1` = ``.`group_concat(b1)`))))) +select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select group_concat(b1) from t2_1025 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +drop table t1_1025, t2_1025, t3_1025; +# +# WL#5561: Enable semi join transformation with outer join. +# +CREATE TABLE ot1(a INT); +CREATE TABLE ot2(a INT); +CREATE TABLE ot3(a INT); +CREATE TABLE it1(a INT); +CREATE TABLE it2(a INT); +CREATE TABLE it3(a INT); +INSERT INTO ot1 VALUES(0),(1),(2),(3),(4),(5),(6),(7); +INSERT INTO ot2 VALUES(0),(2),(4),(6); +INSERT INTO ot3 VALUES(0),(3),(6); +INSERT INTO it1 VALUES(0),(1),(2),(3),(4),(5),(6),(7); +INSERT INTO it2 VALUES(0),(2),(4),(6); +INSERT INTO it3 VALUES(0),(3),(6); +# Test cases, Subquery Pattern 1 +# Example SQ1.1: +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE ot1.a IN (SELECT a FROM it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +2 MATERIALIZED it3 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` left join `test`.`ot2` on((`test`.`ot2`.`a` = `test`.`ot1`.`a`)) semi join (`test`.`it3`) where (`test`.`ot1`.`a` = ``.`a`) +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE ot1.a IN (SELECT a FROM it3); +a a +0 0 +3 NULL +6 6 +# Example SQ1.2: +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE COALESCE(ot2.a,0) IN (SELECT a FROM it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +2 MATERIALIZED it3 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` left join `test`.`ot2` on((`test`.`ot2`.`a` = `test`.`ot1`.`a`)) semi join (`test`.`it3`) where (coalesce(`test`.`ot2`.`a`,0) = ``.`a`) +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE COALESCE(ot2.a,0) IN (SELECT a FROM it3); +a a +0 0 +1 NULL +3 NULL +5 NULL +6 6 +7 NULL +# Example SQ1.3: +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE (ot1.a,ot2.a) IN (SELECT a, a FROM it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using where +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where +2 MATERIALIZED it3 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` join `test`.`ot2` semi join (`test`.`it3`) where ((``.`a` = ``.`a`) and (`test`.`ot2`.`a` = ``.`a`) and (`test`.`ot1`.`a` = ``.`a`)) +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE (ot1.a,ot2.a) IN (SELECT a, a FROM it3); +a a +0 0 +6 6 +# More test cases +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 +WHERE ot1.a IN (SELECT a FROM it3); +a a +0 0 +3 NULL +6 6 +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 +WHERE ot1.a IN (SELECT a+0 FROM it3); +a a +0 0 +3 NULL +6 6 +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 +WHERE COALESCE(ot2.a,0) IN (SELECT a FROM it3); +a a +0 0 +1 NULL +3 NULL +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE COALESCE(ot2.a,0) IN (SELECT a+0 FROM it3); +a a +0 0 +1 NULL +3 NULL +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 +WHERE (ot1.a,ot2.a) IN (SELECT a, a FROM it3); +a a +0 0 +6 6 +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +LEFT JOIN ot3 ON ot1.a=ot3.a +WHERE ot1.a IN (SELECT a FROM it3); +a a a +0 0 0 +3 NULL 3 +6 6 6 +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +LEFT JOIN ot3 ON ot1.a=ot3.a +WHERE COALESCE(ot2.a,0) IN (SELECT a FROM it3); +a a a +0 0 0 +1 NULL NULL +3 NULL 3 +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +LEFT JOIN ot3 ON ot1.a=ot3.a +WHERE COALESCE(ot3.a,0) IN (SELECT a FROM it3); +a a a +0 0 0 +1 NULL NULL +2 2 NULL +3 NULL 3 +4 4 NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +LEFT JOIN ot3 ON ot2.a=ot3.a +WHERE ot1.a IN (SELECT a FROM it3); +a a a +0 0 0 +3 NULL NULL +6 6 6 +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +LEFT JOIN ot3 ON ot2.a=ot3.a +WHERE COALESCE(ot2.a,0) IN (SELECT a FROM it3); +a a a +0 0 0 +1 NULL NULL +3 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +LEFT JOIN ot3 ON ot2.a=ot3.a +WHERE COALESCE(ot3.a,0) IN (SELECT a FROM it3); +a a a +0 0 0 +1 NULL NULL +2 2 NULL +3 NULL NULL +4 4 NULL +5 NULL NULL +6 6 6 +7 NULL NULL +# Test cases, Subquery Pattern 2 +# Example SQ2.1: +explain SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where +2 MATERIALIZED it3 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` join `test`.`ot2` semi join (`test`.`it3`) where ((`test`.`ot1`.`a` = ``.`a`) and (`test`.`ot2`.`a` = ``.`a`)) +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3); +a a +0 0 +6 6 +# Example SQ2.2: +explain SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it2) +AND ot2.a IN (SELECT a FROM it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using where +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where +1 SIMPLE NULL eq_ref 5 .a 1 100.00 NULL +3 MATERIALIZED it3 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 MATERIALIZED it2 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` join `test`.`ot2` semi join (`test`.`it2`) semi join (`test`.`it3`) where ((`test`.`ot1`.`a` = ``.`a`) and (`test`.`ot2`.`a` = ``.`a`) and (``.`a` = ``.`a`)) +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it2) +AND ot2.a IN (SELECT a FROM it3); +a a +0 0 +6 6 +# More test cases +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it3); +a a +0 0 +6 6 +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it3); +a a +0 0 +6 6 +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a+0 AND ot2.a IN (SELECT a FROM it3); +a a +0 0 +6 6 +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot2.a IN (SELECT a+0 FROM it3); +a a +0 0 +6 6 +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it2) +AND ot2.a IN (SELECT a+0 FROM it3); +a a +0 0 +6 6 +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3) +JOIN ot3 ON ot2.a=ot3.a AND ot3.a IN (SELECT a FROM it3); +a a a +0 0 0 +6 6 6 +# Test cases, Subquery Pattern 3 +# Example SQ3.1: +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +1 SIMPLE NULL eq_ref 5 test.ot1.a 1 100.00 NULL +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +2 MATERIALIZED it3 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` semi join (`test`.`it3`)) on(((``.`a` = `test`.`ot1`.`a`) and (`test`.`ot2`.`a` = `test`.`ot1`.`a`))) where true +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3); +a a +0 0 +1 NULL +2 NULL +3 NULL +4 NULL +5 NULL +6 6 +7 NULL +# Example SQ3.2: +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot2.a IN (SELECT a FROM it2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +1 SIMPLE NULL eq_ref 5 test.ot2.a 1 100.00 Using where +2 MATERIALIZED it2 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` semi join (`test`.`it2`)) on(((`test`.`ot2`.`a` = `test`.`ot1`.`a`) and (``.`a` = `test`.`ot1`.`a`))) where true +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot2.a IN (SELECT a FROM it2); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +# Example SQ3.3 +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1) +AND ot2.a IN (SELECT a FROM it2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +1 SIMPLE NULL eq_ref 5 test.ot1.a 1 100.00 NULL +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +1 SIMPLE NULL eq_ref 5 test.ot2.a 1 100.00 Using where +2 MATERIALIZED it1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +3 MATERIALIZED it2 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` semi join (`test`.`it1`) semi join (`test`.`it2`)) on(((``.`a` = `test`.`ot1`.`a`) and (`test`.`ot2`.`a` = `test`.`ot1`.`a`) and (``.`a` = `test`.`ot1`.`a`))) where true +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1) +AND ot2.a IN (SELECT a FROM it2); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +# Example SQ3.4 +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND +(ot1.a, ot2.a) IN (SELECT it1.a, it2.a +FROM it1 JOIN it2 ON it1.a=it2.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +1 SIMPLE NULL eq_ref 10 test.ot1.a,test.ot2.a 1 100.00 Using where +2 MATERIALIZED it2 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +2 MATERIALIZED it1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` semi join (`test`.`it1` join `test`.`it2`)) on(((`test`.`ot2`.`a` = `test`.`ot1`.`a`) and (``.`a` = `test`.`ot1`.`a`) and (``.`a` = `test`.`ot1`.`a`) and (`test`.`it1`.`a` = `test`.`it2`.`a`))) where true +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND +(ot1.a, ot2.a) IN (SELECT it1.a, it2.a +FROM it1 JOIN it2 ON it1.a=it2.a); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +# More test cases +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it3); +a a +0 0 +1 NULL +2 NULL +3 NULL +4 NULL +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it3); +a a +0 0 +1 NULL +2 NULL +3 NULL +4 NULL +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 AND ot2.a IN (SELECT a FROM it2); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot2.a IN (SELECT a+0 FROM it2); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a+0 FROM it1) +AND ot2.a IN (SELECT a+0 FROM it2); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 AND +(ot1.a, ot2.a) IN (SELECT it1.a+0, it2.a+0 +FROM it1 JOIN it2 ON it1.a=it2.a); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +EXPLAIN FORMAT=tree SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3) +LEFT JOIN ot3 ON ot2.a=ot3.a AND ot3.a IN (SELECT a FROM it3); +EXPLAIN +-> Nested loop left join (cost=56.54 rows=288) + -> Nested loop left join (cost=11.70 rows=96) + -> Table scan on ot1 (cost=1.30 rows=8) + -> Nested loop inner join (cost=6.31 rows=12) + -> Single-row index lookup on using (a=ot1.a) + -> Materialize with deduplication (cost=1.10..1.10 rows=3) + -> Filter: (it3.a is not null) (cost=0.80 rows=3) + -> Table scan on it3 (cost=0.80 rows=3) + -> Filter: (ot2.a = ot1.a) (cost=0.55 rows=4) + -> Table scan on ot2 (cost=0.55 rows=4) + -> Nested loop inner join (cost=10.41 rows=3) + -> Filter: (ot3.a = ot2.a) (cost=0.51 rows=3) + -> Table scan on ot3 (cost=0.51 rows=3) + -> Filter: (``.a = ot2.a) (cost=3.23..3.23 rows=1) + -> Single-row index lookup on using (a=ot3.a) + -> Materialize with deduplication (cost=1.10..1.10 rows=3) + -> Filter: (it3.a is not null) (cost=0.80 rows=3) + -> Table scan on it3 (cost=0.80 rows=3) + +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3) +LEFT JOIN ot3 ON ot2.a=ot3.a AND ot3.a IN (SELECT a FROM it3); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it3) +LEFT JOIN ot3 ON ot2.a=ot3.a+0 AND ot3.a IN (SELECT a FROM it3); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +# Test cases, Subquery Pattern 4 +# Example SQ4.1: +explain SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +1 SIMPLE NULL eq_ref 5 test.ot1.a 1 100.00 NULL +1 SIMPLE ot3 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +2 MATERIALIZED it1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a`,`test`.`ot3`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` join `test`.`ot3` semi join (`test`.`it1`)) on(((``.`a` = `test`.`ot1`.`a`) and (`test`.`ot3`.`a` = `test`.`ot1`.`a`) and (`test`.`ot2`.`a` = `test`.`ot1`.`a`))) where true +SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +# Example SQ4.2: +explain SELECT * +FROM ot1 +JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot3 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where +1 SIMPLE NULL eq_ref 5 test.ot3.a 1 100.00 NULL +2 MATERIALIZED it1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a`,`test`.`ot3`.`a` AS `a` from `test`.`ot1` join `test`.`ot2` join `test`.`ot3` semi join (`test`.`it1`) where ((`test`.`ot2`.`a` = `test`.`ot3`.`a`) and (`test`.`ot1`.`a` = `test`.`ot3`.`a`) and (``.`a` = `test`.`ot3`.`a`)) +SELECT * +FROM ot1 +JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +6 6 6 +# Example SQ4.3: +explain SELECT * +FROM ot1 +JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where +1 SIMPLE NULL eq_ref 5 test.ot2.a 1 100.00 NULL +1 SIMPLE ot3 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 MATERIALIZED it1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a`,`test`.`ot3`.`a` AS `a` from `test`.`ot1` join `test`.`ot2` left join `test`.`ot3` on((`test`.`ot3`.`a` = `test`.`ot2`.`a`)) semi join (`test`.`it1`) where ((`test`.`ot1`.`a` = `test`.`ot2`.`a`) and (``.`a` = `test`.`ot2`.`a`)) +SELECT * +FROM ot1 +JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +2 2 NULL +4 4 NULL +6 6 6 +# Example SQ4.4: +explain SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +1 SIMPLE NULL eq_ref 5 test.ot1.a 1 100.00 NULL +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +1 SIMPLE ot3 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 MATERIALIZED it1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a`,`test`.`ot3`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` left join `test`.`ot3` on((`test`.`ot3`.`a` = `test`.`ot1`.`a`)) semi join (`test`.`it1`)) on(((``.`a` = `test`.`ot1`.`a`) and (`test`.`ot2`.`a` = `test`.`ot1`.`a`))) where true +SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +1 NULL NULL +2 2 NULL +3 NULL NULL +4 4 NULL +5 NULL NULL +6 6 6 +7 NULL NULL +# More test cases +SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a+0) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it1); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 +JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a+0) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +6 6 6 +SELECT * +FROM ot1 +JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +6 6 6 +SELECT * +FROM ot1 +JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it1); +a a a +0 0 0 +6 6 6 +SELECT * +FROM ot1 +JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a+0) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +2 2 NULL +4 4 NULL +6 6 6 +SELECT * +FROM ot1 +JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +2 2 NULL +4 4 NULL +6 6 6 +SELECT * +FROM ot1 +JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it1); +a a a +0 0 0 +2 2 NULL +4 4 NULL +6 6 6 +SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a+0) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +1 NULL NULL +2 2 NULL +3 NULL NULL +4 4 NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +1 NULL NULL +2 2 NULL +3 NULL NULL +4 4 NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it1); +a a a +0 0 0 +1 NULL NULL +2 2 NULL +3 NULL NULL +4 4 NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1) +LEFT JOIN +ot1 AS ot4 +ON ot2.a=ot4.a; +a a a a +0 0 0 0 +1 NULL NULL NULL +2 2 NULL 2 +3 NULL NULL NULL +4 4 NULL 4 +5 NULL NULL NULL +6 6 6 6 +7 NULL NULL NULL +SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a +LEFT JOIN ot1 AS ot4 ON ot3.a=ot4.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a a +0 0 0 0 +1 NULL NULL NULL +2 2 NULL NULL +3 NULL NULL NULL +4 4 NULL NULL +5 NULL NULL NULL +6 6 6 6 +7 NULL NULL NULL +DROP TABLE ot1,ot2,ot3,it1,it2,it3; +CREATE TABLE t ( +a INTEGER DEFAULT NULL +) ENGINE=InnoDB; +INSERT INTO t VALUES (1); +CREATE TABLE t2 ( +a INTEGER DEFAULT NULL +) ENGINE=InnoDB; +INSERT INTO t2 VALUES (1),(1); +CREATE TABLE t4 ( +a INTEGER DEFAULT NULL +) ENGINE=InnoDB; +INSERT INTO t4 VALUES (1),(1); +CREATE TABLE v ( +a INTEGER DEFAULT NULL +) ENGINE=InnoDB; +INSERT INTO v VALUES (1),(1); +explain SELECT * +FROM t AS t1 +LEFT JOIN +(t2 +LEFT JOIN t AS t3 +ON t3.a IN (SELECT a FROM t AS it) +JOIN t4 +ON t4.a=100 +) +ON TRUE +WHERE t1.a IN (SELECT * FROM v AS it2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE NULL eq_ref 5 test.t1.a 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL eq_ref 5 test.t3.a 1 100.00 NULL +1 SIMPLE t4 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +3 MATERIALIZED it2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED it NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t4`.`a` AS `a` from `test`.`t` `t1` left join (`test`.`t2` left join (`test`.`t` `t3` semi join (`test`.`t` `it`)) on(((``.`a` = `test`.`t3`.`a`))) join `test`.`t4`) on(((`test`.`t4`.`a` = 100))) semi join (`test`.`v` `it2`) where (``.`a` = `test`.`t1`.`a`) +SELECT * +FROM t AS t1 +LEFT JOIN +(t2 +LEFT JOIN t AS t3 +ON t3.a IN (SELECT a FROM t AS it) +JOIN t4 +ON t4.a=100 +) +ON TRUE +WHERE t1.a IN (SELECT * FROM v AS it2); +a a a a +1 NULL NULL NULL +DROP TABLE t,t2,t4,v; +# End of WL#5561 +# +# Bug#48868: Left outer join in subquery causes segmentation fault in +# make_join_select. +# +CREATE TABLE t1 (i INTEGER); +INSERT INTO t1 VALUES (1); +INSERT INTO t1 VALUES (2); +CREATE TABLE t2 (i INTEGER); +INSERT INTO t2 VALUES(1); +CREATE TABLE t3 (i INTEGER); +INSERT INTO t3 VALUES (1); +INSERT INTO t3 VALUES (2); +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t2.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +1 +DROP TABLE t1, t2, t3; + +Bug#37899: Wrongly checked optimization prerequisite caused failed +assertion. + +CREATE TABLE t1 ( +`pk` int(11), +`varchar_nokey` varchar(5) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES +(1,'qk'),(2,'j'),(3,'aew'); +SELECT * +FROM t1 +WHERE varchar_nokey IN ( +SELECT +varchar_nokey +FROM +t1 +) XOR pk = 30; +pk varchar_nokey +1 qk +2 j +3 aew +drop table t1; +# +# BUG#41842: Semi-join materialization strategy crashes when the upper query has HAVING +# +CREATE TABLE t1 ( +pk int(11) NOT NULL AUTO_INCREMENT, +int_nokey int(11) NOT NULL, +time_key time NOT NULL, +datetime_key datetime NOT NULL, +datetime_nokey datetime NOT NULL, +varchar_key varchar(1) NOT NULL, +varchar_nokey varchar(1) NOT NULL, +PRIMARY KEY (pk), +KEY time_key (time_key), +KEY datetime_key (datetime_key), +KEY varchar_key (varchar_key) +) ENGINE=MyISaM; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES +(1,0, '00:16:10','2008-09-03 14:25:40','2008-09-03 14:25:40','h','h'), +(2,7, '00:00:00','2001-01-13 00:00:00','2001-01-13 00:00:00','',''), +(3,0, '00:00:00','0000-00-00 00:00:00','0000-00-00 00:00:00','x','x'), +(4,2, '16:29:24','2000-10-16 01:39:08','2000-10-16 01:39:08','w','w'), +(5,1, '09:23:32','0000-00-00 00:00:00','0000-00-00 00:00:00','p','p'), +(6,3, '00:00:00','2007-12-02 00:00:00','2007-12-02 00:00:00','o','o'), +(7,3, '00:00:00','2008-09-11 00:00:00','2008-09-11 00:00:00','',''), +(8,0, '13:59:04','0000-00-00 00:00:00','0000-00-00 00:00:00','s','s'), +(9,7, '09:01:06','0000-00-00 00:00:00','0000-00-00 00:00:00','d','d'), +(10,5,'00:00:00','0000-00-00 00:00:00','0000-00-00 00:00:00','n','n'), +(11,0,'21:06:46','0000-00-00 00:00:00','0000-00-00 00:00:00','o','o'), +(12,2,'00:00:00','0000-00-00 00:00:00','0000-00-00 00:00:00','',''), +(13,6,'14:45:34','2003-07-28 02:34:08','2003-07-28 02:34:08','w','w'), +(14,1,'15:04:12','0000-00-00 00:00:00','0000-00-00 00:00:00','o','o'), +(15,0,'00:00:00','0000-00-00 00:00:00','0000-00-00 00:00:00','x','x'), +(16,0,'15:55:23','2004-03-17 00:32:27','2004-03-17 00:32:27','p','p'), +(17,1,'16:30:00','2004-12-27 19:20:00','2004-12-27 19:20:00','d','d'), +(18,0,'00:00:00','0000-00-00 00:00:00','0000-00-00 00:00:00','h','h'), +(19,0,'14:13:26','2008-11-09 05:53:48','2008-11-09 05:53:48','o','o'), +(20,0,'00:00:00','2009-10-11 06:58:04','2009-10-11 06:58:04','k','k'); +Warnings: +Warning 1264 Out of range value for column 'datetime_key' at row 3 +Warning 1264 Out of range value for column 'datetime_nokey' at row 3 +Warning 1264 Out of range value for column 'datetime_key' at row 5 +Warning 1264 Out of range value for column 'datetime_nokey' at row 5 +Warning 1264 Out of range value for column 'datetime_key' at row 8 +Warning 1264 Out of range value for column 'datetime_nokey' at row 8 +Warning 1264 Out of range value for column 'datetime_key' at row 9 +Warning 1264 Out of range value for column 'datetime_nokey' at row 9 +Warning 1264 Out of range value for column 'datetime_key' at row 10 +Warning 1264 Out of range value for column 'datetime_nokey' at row 10 +Warning 1264 Out of range value for column 'datetime_key' at row 11 +Warning 1264 Out of range value for column 'datetime_nokey' at row 11 +Warning 1264 Out of range value for column 'datetime_key' at row 12 +Warning 1264 Out of range value for column 'datetime_nokey' at row 12 +Warning 1264 Out of range value for column 'datetime_key' at row 14 +Warning 1264 Out of range value for column 'datetime_nokey' at row 14 +Warning 1264 Out of range value for column 'datetime_key' at row 15 +Warning 1264 Out of range value for column 'datetime_nokey' at row 15 +Warning 1264 Out of range value for column 'datetime_key' at row 18 +Warning 1264 Out of range value for column 'datetime_nokey' at row 18 +CREATE TABLE t2 ( +pk int(11) NOT NULL AUTO_INCREMENT, +int_nokey int(11) NOT NULL, +time_key time NOT NULL, +datetime_key datetime NOT NULL, +datetime_nokey datetime NOT NULL, +varchar_key varchar(1) NOT NULL, +varchar_nokey varchar(1) NOT NULL, +PRIMARY KEY (pk), +KEY time_key (time_key), +KEY datetime_key (datetime_key), +KEY varchar_key (varchar_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT IGNORE INTO t2 VALUES +(10,0,'19:39:13','0000-00-00 00:00:00','0000-00-00 00:00:00','g','g'), +(11,8,'03:43:53','0000-00-00 00:00:00','0000-00-00 00:00:00','b','b'); +Warnings: +Warning 1264 Out of range value for column 'datetime_key' at row 1 +Warning 1264 Out of range value for column 'datetime_nokey' at row 1 +Warning 1264 Out of range value for column 'datetime_key' at row 2 +Warning 1264 Out of range value for column 'datetime_nokey' at row 2 +SELECT OUTR.datetime_nokey AS X FROM t1 AS OUTR +WHERE +OUTR.varchar_nokey IN (SELECT +INNR . varchar_nokey AS Y +FROM t2 AS INNR +WHERE +INNR . datetime_key >= INNR . time_key OR +INNR . pk = INNR . int_nokey +) +AND OUTR . varchar_nokey <= 'w' +HAVING X > '2012-12-12'; +X +drop table t1, t2; + +Bug#46797 "Crash in fix_semijoin_strategies_for_picked_join_order +with semijoin=on" + +CREATE TABLE t1 ( +varchar_key varchar(1) DEFAULT NULL, +KEY varchar_key (varchar_key) +); +CREATE TABLE t2 ( +varchar_key varchar(1) DEFAULT NULL, +KEY varchar_key (varchar_key) +); +INSERT INTO t2 VALUES +(NULL),(NULL),(NULL),(NULL),('a'),('a'),('a'),('b'),('b'),('b'),('b'),('c'), +('c'),('c'),('c'),('c'),('c'),('c'),('d'),('d'),('d'),('d'),('d'),('d'),('e'), +('e'),('e'),('e'),('e'),('e'),('f'),('f'),('f'),('g'),('g'),('h'),('h'),('h'), +('h'),('i'),('j'),('j'),('j'),('k'),('k'),('l'),('l'),('m'),('m'),('m'),('m'), +('n'),('n'),('n'),('o'),('o'),('o'),('p'),('p'),('p'),('q'),('q'),('q'),('r'), +('r'),('r'),('r'),('s'),('s'),('s'),('s'),('t'),('t'),('t'),('t'),('u'),('u'), +('u'),('u'),('v'),('v'),('v'),('v'),('w'),('w'),('w'),('w'),('w'),('w'),('x'), +('x'),('x'),('y'),('y'),('y'),('y'),('z'),('z'),('z'),('z'); +CREATE TABLE t3 ( +varchar_key varchar(1) DEFAULT NULL, +KEY varchar_key (varchar_key) +) ENGINE=MyISAM DEFAULT CHARSET=latin1; +INSERT INTO t3 VALUES +(NULL),('c'),('d'),('e'),('f'),('h'),('j'),('k'),('k'),('m'),('m'),('m'), +('n'),('o'),('r'),('t'),('t'),('u'),('w'),('y'); +SELECT varchar_key FROM t3 +WHERE (SELECT varchar_key FROM t3 +WHERE (varchar_key,varchar_key) +IN (SELECT t1.varchar_key, t2 .varchar_key +FROM t1 RIGHT JOIN t2 ON t1.varchar_key +) +); +varchar_key +DROP TABLE t1, t2, t3; +# +# Bug#46556 Returning incorrect, empty results for some IN subqueries +# w/semijoin=on +# +CREATE TABLE t0 ( +pk INTEGER, +vkey VARCHAR(1), +vnokey VARCHAR(1), +PRIMARY KEY (pk), +KEY vkey(vkey) +) charset utf8mb4; +INSERT INTO t0 +VALUES (1,'g','g'), (2,'v','v'), (3,'t','t'), (4,'u','u'), (5,'n','n'); +EXPLAIN SELECT vkey FROM t0 WHERE pk IN +(SELECT t1.pk FROM t0 t1 JOIN t0 t2 ON t2.vkey = t1.vnokey); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL ALL PRIMARY NULL NULL NULL 5 100.00 NULL +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t0.pk 1 100.00 Using where +1 SIMPLE t2 NULL ref vkey vkey 7 test.t1.vnokey 2 100.00 Using index; Start temporary; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`vkey` AS `vkey` from `test`.`t0` `t1` join `test`.`t0` semi join (`test`.`t0` `t2`) where ((`test`.`t2`.`vkey` = `test`.`t1`.`vnokey`) and (`test`.`t1`.`pk` = `test`.`t0`.`pk`)) +SELECT vkey FROM t0 WHERE pk IN +(SELECT t1.pk FROM t0 t1 JOIN t0 t2 ON t2.vkey = t1.vnokey); +vkey +g +n +t +u +v +DROP TABLE t0; +# End of bug#46556 + +Bug#48834: Procedure with view + subquery + semijoin=on +crashes on second call. + +CREATE TABLE t1 ( t1field integer, primary key (t1field)); +CREATE TABLE t2 ( t2field integer, primary key (t2field)); +CREATE VIEW v1 AS +SELECT t1field as v1field +FROM t1 A +WHERE A.t1field IN (SELECT t1field FROM t2 ); +CREATE VIEW v2 AS +SELECT t2field as v2field +FROM t2 A +WHERE A.t2field IN (SELECT t2field FROM t2 ); +CREATE PROCEDURE p1 () +BEGIN +SELECT v1field +FROM v1 +WHERE v1field IN ( SELECT v2field as vf_inner FROM v2 ); +END| +INSERT INTO t1 VALUES (1),(2),(3); +INSERT INTO t2 VALUES (2),(3),(4); +CALL p1; +v1field +2 +3 +CALL p1; +v1field +2 +3 +DROP TABLE t1,t2; +DROP VIEW v1,v2; +DROP PROCEDURE p1; +# End of BUG#48834 +# +# Bug#46692 "Crash occurring on queries with nested FROM subqueries +# using materialization." +# +CREATE TABLE t1 ( +pk INTEGER PRIMARY KEY, +int_key INTEGER, +KEY int_key(int_key) +); +INSERT INTO t1 VALUES (10,186),(11,NULL),(12,2),(13,3),(14,0),(15,133),(16,1); +CREATE TABLE t2 ( +pk INTEGER PRIMARY KEY, +int_key INTEGER, +KEY int_key(int_key) +); +INSERT INTO t2 VALUES (1,7),(2,2); +SELECT * FROM t1 WHERE (140, 4) IN +(SELECT t2.int_key, t2 .pk FROM t2 STRAIGHT_JOIN t1 ON t2.int_key); +pk int_key +DROP TABLE t1, t2; +# +# Bug#42353 "SELECT ... WHERE oe IN (SELECT w/ LEFT JOIN) query +# causes crash." +# +CREATE TABLE t1 ( +pk INTEGER PRIMARY KEY, +int_nokey INTEGER, +int_key INTEGER, +date_key DATE, +datetime_nokey DATETIME, +varchar_nokey VARCHAR(1) +); +CREATE TABLE t2 ( +date_nokey DATE +); +CREATE TABLE t3 ( +pk INTEGER PRIMARY KEY, +int_nokey INTEGER, +date_key date, +varchar_key VARCHAR(1), +varchar_nokey VARCHAR(1), +KEY date_key (date_key) +); +SELECT date_key FROM t1 +WHERE (int_key, int_nokey) +IN (SELECT t3.int_nokey, t3.pk +FROM t2 LEFT JOIN t3 ON (t2.date_nokey < t3.date_key) +WHERE t3.varchar_key <= t3.varchar_nokey OR t3.int_nokey <= t3.pk +) +AND (varchar_nokey <> 'f' OR NOT int_key < 7); +date_key +# +# Bug#45933 "Crash in optimize_semijoin_nests on JOIN in subquery +# + AND in outer query". +# +INSERT INTO t1 VALUES (10,7,5,'2009-06-16','2002-04-10 14:25:30','w'), +(11,7,0,'0000-00-00','0000-00-00 00:00:00','s'), +(12,4,0,'2003-07-14','2006-09-14 04:01:02','y'), +(13,0,4,'2002-07-25','0000-00-00 00:00:00','c'), +(14,1,8,'2007-07-03','0000-00-00 00:00:00','q'), +(15,6,5,'2001-11-12','0000-00-00 00:00:00',''), +(16,2,9,'0000-00-00','0000-00-00 00:00:00','j'), +(29,9,1,'0000-00-00','2003-08-11 00:00:00','m'); +Warnings: +Warning 1264 Out of range value for column 'date_key' at row 2 +Warning 1264 Out of range value for column 'datetime_nokey' at row 2 +Warning 1264 Out of range value for column 'datetime_nokey' at row 4 +Warning 1264 Out of range value for column 'datetime_nokey' at row 5 +Warning 1264 Out of range value for column 'datetime_nokey' at row 6 +Warning 1264 Out of range value for column 'date_key' at row 7 +Warning 1264 Out of range value for column 'datetime_nokey' at row 7 +Warning 1264 Out of range value for column 'date_key' at row 8 +INSERT IGNORE INTO t3 VALUES (1,9,'0000-00-00','b','b'), +(2,2,'2002-09-17','h','h'); +Warnings: +Warning 1264 Out of range value for column 'date_key' at row 1 +SELECT t1.varchar_nokey FROM t1 JOIN t3 ON t1.datetime_nokey +WHERE t1.varchar_nokey +IN (SELECT varchar_nokey FROM t1 +WHERE (pk) +IN (SELECT t3.int_nokey +FROM t3 LEFT JOIN t1 ON t1.varchar_nokey +WHERE t3.date_key BETWEEN '2008-06-07' AND '2006-06-26' + ) +); +varchar_nokey +DROP TABLE t1, t2, t3; +# +# Bug#45219 "Crash on SELECT DISTINCT query containing a +# LEFT JOIN in subquery" +# +CREATE TABLE t1 ( +pk INTEGER NOT NULL, +int_nokey INTEGER NOT NULL, +datetime_key DATETIME NOT NULL, +varchar_key VARCHAR(1) NOT NULL, +PRIMARY KEY (pk), +KEY datetime_key (datetime_key), +KEY varchar_key (varchar_key) +); +INSERT IGNORE INTO t1 VALUES +(1,9,'0000-00-00 00:00:00','p'),(2,0,'2002-02-09 07:38:13','v'), +(3,8,'2001-05-03 12:08:14','t'),(4,3,'0000-00-00 00:00:00','u'), +(5,7,'2009-07-28 03:43:30','n'),(6,0,'2009-08-04 00:00:00','l'), +(7,1,'0000-00-00 00:00:00','h'),(8,9,'0000-00-00 00:00:00','u'), +(9,0,'2005-08-02 17:16:54','n'),(10,9,'2002-12-21 00:00:00','j'), +(11,0,'2005-08-15 12:37:35','k'),(12,5,'0000-00-00 00:00:00','e'), +(13,0,'2006-03-10 00:00:00','i'),(14,8,'2005-05-16 11:02:36','u'), +(15,8,'2008-11-02 00:00:00','n'),(16,5,'2006-03-15 00:00:00','b'), +(17,1,'0000-00-00 00:00:00','x'),(18,7,'0000-00-00 00:00:00',''), +(19,0,'2008-12-17 20:15:40','q'),(20,9,'0000-00-00 00:00:00','u'); +Warnings: +Warning 1264 Out of range value for column 'datetime_key' at row 1 +Warning 1264 Out of range value for column 'datetime_key' at row 4 +Warning 1264 Out of range value for column 'datetime_key' at row 7 +Warning 1264 Out of range value for column 'datetime_key' at row 8 +Warning 1264 Out of range value for column 'datetime_key' at row 12 +Warning 1264 Out of range value for column 'datetime_key' at row 17 +Warning 1264 Out of range value for column 'datetime_key' at row 18 +Warning 1264 Out of range value for column 'datetime_key' at row 20 +CREATE TABLE t2 LIKE t1; +INSERT INTO t2 VALUES +(10,0,'2006-07-07 07:26:28','q'),(11,5,'2002-09-23 00:00:00','m'), +(12,7,'0000-00-00 00:00:00','j'),(13,1,'2006-06-07 00:00:00','z'), +(14,8,'2000-09-16 12:15:34','a'),(15,2,'2007-08-05 15:47:52',''), +(16,1,'0000-00-00 00:00:00','e'),(17,8,'2005-12-02 19:34:26','t'), +(18,5,'0000-00-00 00:00:00','q'),(19,4,'0000-00-00 00:00:00','b'), +(20,5,'2007-12-28 00:00:00','w'),(21,3,'2004-08-02 11:48:43','m'), +(22,0,'0000-00-00 00:00:00','x'),(23,8,'2004-04-19 12:18:43',''), +(24,0,'2009-04-27 00:00:00','w'),(25,4,'2006-10-20 14:52:15','x'), +(26,0,'0000-00-00 00:00:00','e'),(27,0,'2002-03-22 11:48:37','e'), +(28,2,'0000-00-00 00:00:00','p'),(29,0,'2001-01-04 03:55:07','x'); +Warnings: +Warning 1264 Out of range value for column 'datetime_key' at row 3 +Warning 1264 Out of range value for column 'datetime_key' at row 7 +Warning 1264 Out of range value for column 'datetime_key' at row 9 +Warning 1264 Out of range value for column 'datetime_key' at row 10 +Warning 1264 Out of range value for column 'datetime_key' at row 13 +Warning 1264 Out of range value for column 'datetime_key' at row 17 +Warning 1264 Out of range value for column 'datetime_key' at row 19 +CREATE TABLE t3 LIKE t1; +INSERT INTO t3 VALUES +(10,8,'2007-08-19 08:08:38','i'),(11,0,'2000-05-21 03:51:51',''); +SELECT DISTINCT datetime_key FROM t1 +WHERE (int_nokey, pk) +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#46550 Azalea returning duplicate results for some IN subqueries +# w/ semijoin=on +# +DROP TABLE IF EXISTS t0, t1, t2; +CREATE TABLE t0 ( +int_key int(11) DEFAULT NULL, +varchar_key varchar(1) DEFAULT NULL, +varchar_nokey varchar(1) DEFAULT NULL, +KEY int_key (int_key), +KEY varchar_key (varchar_key,int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t0 VALUES +(1,'m','m'), +(40,'h','h'), +(1,'r','r'), +(1,'h','h'), +(9,'x','x'), +(NULL,'q','q'), +(NULL,'k','k'), +(7,'l','l'), +(182,'k','k'), +(202,'a','a'), +(7,'x','x'), +(6,'j','j'), +(119,'z','z'), +(4,'d','d'), +(5,'h','h'), +(1,'u','u'), +(3,'q','q'), +(7,'a','a'), +(3,'e','e'), +(6,'l','l'); +CREATE TABLE t1 ( +int_key int(11) DEFAULT NULL, +varchar_key varchar(1) DEFAULT NULL, +varchar_nokey varchar(1) DEFAULT NULL, +KEY int_key (int_key), +KEY varchar_key (varchar_key,int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (7,NULL,NULL),(4,'x','x'); +CREATE TABLE t2 ( +int_key int(11) DEFAULT NULL, +varchar_key varchar(1) DEFAULT NULL, +varchar_nokey varchar(1) DEFAULT NULL, +KEY int_key (int_key), +KEY varchar_key (varchar_key,int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (123,NULL,NULL); +SELECT int_key +FROM t0 +WHERE varchar_nokey IN ( +SELECT t1 .varchar_key from t1 +); +int_key +7 +9 +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 +7 +9 +EXPLAIN +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 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 20 10.00 Using where +2 MATERIALIZED t1_1 NULL index varchar_key varchar_key 12 NULL 2 50.00 Using where; Using index +2 MATERIALIZED t1_2 NULL index NULL int_key 5 NULL 2 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`int_key` AS `int_key` from `test`.`t0` semi join (`test`.`t1` `t1_1` join `test`.`t1` `t1_2`) where ((`test`.`t0`.`varchar_nokey` = ``.`varchar_key`) and (0 <> `test`.`t1_1`.`int_key`)) +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 +7 +9 +EXPLAIN +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 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 20 10.00 Using where +2 MATERIALIZED t1_1 NULL index varchar_key varchar_key 12 NULL 2 50.00 Using where; Using index +2 MATERIALIZED t1_2 NULL index NULL int_key 5 NULL 2 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`int_key` AS `int_key` from `test`.`t0` semi join (`test`.`t1` `t1_1` join `test`.`t1` `t1_2`) where ((`test`.`t0`.`varchar_nokey` = ``.`varchar_key`) and (0 <> `test`.`t1_1`.`int_key`)) +DROP TABLE t0, t1, t2; +# End of bug#46550 + +Bug #48073 Subquery on char columns from view crashes Mysql + +DROP TABLE IF EXISTS t1, t2; +DROP VIEW IF EXISTS v1; +CREATE TABLE t1 ( +city VARCHAR(50) NOT NULL, +country_id SMALLINT UNSIGNED NOT NULL +); +INSERT INTO t1 VALUES +('Batna',2), +('Bchar',2), +('Skikda',2), +('Tafuna',3), +('Algeria',2) ; +CREATE TABLE t2 ( +country_id SMALLINT UNSIGNED NOT NULL, +country VARCHAR(50) NOT NULL +); +INSERT INTO t2 VALUES +(2,'Algeria'), +(3,'American Samoa') ; +CREATE VIEW v1 AS +SELECT country_id, country +FROM t2 +WHERE LEFT(country,1) = "A" +; +SELECT city, country_id +FROM t1 +WHERE city IN ( +SELECT country +FROM t2 +WHERE LEFT(country, 1) = "A" +); +city country_id +Algeria 2 +SELECT city, country_id +FROM t1 +WHERE city IN ( +SELECT country +FROM v1 +); +city country_id +Algeria 2 +drop table t1, t2; +drop view v1; +# End of bug#48073 + +Bug#49097 subquery with view generates wrong result with +non-prepared statement + +DROP TABLE IF EXISTS t1, t2; +DROP VIEW IF EXISTS v1; +CREATE TABLE t1 ( +city VARCHAR(50) NOT NULL, +country_id SMALLINT UNSIGNED NOT NULL +); +INSERT INTO t1 VALUES +('Batna',2), +('Bchar',2), +('Skikda',2), +('Tafuna',3), +('Algeria',2) ; +CREATE TABLE t2 ( +country_id SMALLINT UNSIGNED NOT NULL, +country VARCHAR(50) NOT NULL +); +INSERT INTO t2 VALUES +(2,'Algeria'), +(3,'XAmerican Samoa') ; +CREATE VIEW v1 AS +SELECT country_id, country +FROM t2 +WHERE LEFT(country,1) = "A" +; +SELECT city, country_id +FROM t1 +WHERE country_id IN ( +SELECT country_id +FROM t2 +WHERE LEFT(country,1) = "A" +); +city country_id +Algeria 2 +Batna 2 +Bchar 2 +Skikda 2 +SELECT city, country_id +FROM t1 +WHERE country_id IN ( +SELECT country_id +FROM v1 +); +city country_id +Algeria 2 +Batna 2 +Bchar 2 +Skikda 2 +PREPARE stmt FROM +" +SELECT city, country_id +FROM t1 +WHERE country_id IN ( + SELECT country_id + FROM v1 +); +"; +execute stmt; +city country_id +Algeria 2 +Batna 2 +Bchar 2 +Skikda 2 +deallocate prepare stmt; +drop table t1, t2; +drop view v1; +# End of Bug#49097 +# +# Bug#49198 Wrong result for second call of procedure +# with view in subselect. +# +CREATE TABLE t1 (t1field integer, primary key (t1field)); +CREATE TABLE t2 (t2field integer, primary key (t2field)); +CREATE TABLE t3 (t3field integer, primary key (t3field)); +CREATE VIEW v2 AS SELECT * FROM t2; +CREATE VIEW v3 AS SELECT * FROM t3; +INSERT INTO t1 VALUES(1),(2); +INSERT INTO t2 VALUES(1),(2); +INSERT INTO t3 VALUES(1),(2); +PREPARE stmt FROM +" +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT * FROM v2); +"; +EXECUTE stmt; +t1field +1 +2 + +EXECUTE stmt; +t1field +1 +2 +PREPARE stmt FROM +" +EXPLAIN +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT * FROM v2) + AND t1field IN (SELECT * FROM v3) +"; +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index PRIMARY PRIMARY 4 NULL 2 100.00 Using index +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +1 SIMPLE t3 NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`t1field` AS `t1field` from `test`.`t2` join `test`.`t3` join `test`.`t1` where ((`test`.`t2`.`t2field` = `test`.`t1`.`t1field`) and (`test`.`t3`.`t3field` = `test`.`t1`.`t1field`)) + +This line is only in place to help --skip_if_hypergraph diffing some more. + +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index PRIMARY PRIMARY 4 NULL 2 100.00 Using index +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +1 SIMPLE t3 NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`t1field` AS `t1field` from `test`.`t2` join `test`.`t3` join `test`.`t1` where ((`test`.`t2`.`t2field` = `test`.`t1`.`t1field`) and (`test`.`t3`.`t3field` = `test`.`t1`.`t1field`)) +DROP TABLE t1, t2, t3; +DROP VIEW v2, v3; +# End of Bug#49198 +# +# Bug#48623 Multiple subqueries are optimized incorrectly +# +CREATE TABLE ot(val VARCHAR(10)) charset utf8mb4; +CREATE TABLE it1(val VARCHAR(10)) charset utf8mb4; +CREATE TABLE it2(val VARCHAR(10)) charset utf8mb4; +INSERT INTO ot VALUES('aaa'), ('bbb'), ('eee'), ('mmm'), ('ppp'); +INSERT INTO it1 VALUES('aaa'), ('aaa'), ('bbb'), ('eee'), ('mmm'), ('ppp'); +INSERT INTO it2 VALUES('aaa'), ('bbb'), ('eee'), ('mmm'), ('ppp'); +EXPLAIN +SELECT * +FROM ot +WHERE ot.val IN (SELECT it1.val FROM it1 +WHERE it1.val LIKE 'a%' OR it1.val LIKE 'e%') +AND ot.val IN (SELECT it2.val FROM it2 +WHERE it2.val LIKE 'a%' OR it2.val LIKE 'e%'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 5 100.00 Using where +1 SIMPLE NULL eq_ref 43 test.ot.val 1 100.00 NULL +1 SIMPLE NULL eq_ref 43 test.ot.val 1 100.00 NULL +3 MATERIALIZED it2 NULL ALL NULL NULL NULL NULL 5 36.00 Using where +2 MATERIALIZED it1 NULL ALL NULL NULL NULL NULL 6 30.56 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`ot`.`val` AS `val` from `test`.`ot` semi join (`test`.`it1`) semi join (`test`.`it2`) where ((``.`val` = `test`.`ot`.`val`) and (``.`val` = `test`.`ot`.`val`) and ((`test`.`it1`.`val` like 'a%') or (`test`.`it1`.`val` like 'e%')) and ((`test`.`it2`.`val` like 'a%') or (`test`.`it2`.`val` like 'e%'))) +SELECT * +FROM ot +WHERE ot.val IN (SELECT it1.val FROM it1 +WHERE it1.val LIKE 'a%' OR it1.val LIKE 'e%') +AND ot.val IN (SELECT it2.val FROM it2 +WHERE it2.val LIKE 'a%' OR it2.val LIKE 'e%'); +val +aaa +eee +DROP TABLE ot; +DROP TABLE it1; +DROP TABLE it2; +# End of Bug#48623 +# +# Bug #51487 Assertion failure when semi-join flattening occurs +# for a subquery in HAVING +# +CREATE TABLE t1 (a INT, b INT); +INSERT INTO t1 VALUES (1,10),(2,11),(1,13); +CREATE TABLE t2 AS SELECT * FROM t1; +CREATE TABLE t3 AS SELECT * FROM t1; +SELECT COUNT(*) FROM t1 +GROUP BY t1.a +HAVING t1.a IN (SELECT t3.a FROM t3 +WHERE t3.b IN (SELECT b FROM t2 WHERE t2.a=t1.a)); +COUNT(*) +2 +1 +DROP TABLE t1, t2, t3; +# End of Bug#51487 +# +# BUG#38075: Wrong result: rows matching a subquery with outer join not returned +# +DROP TABLE IF EXISTS ot1, it1, it2; +CREATE TABLE it2 ( +int_key int(11) NOT NULL, +datetime_key datetime NOT NULL, +KEY int_key (int_key), +KEY datetime_key (datetime_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO it2 VALUES +(5,'2002-04-10 14:25:30'), (0,'0000-00-00 00:00:00'), +(0,'2006-09-14 04:01:02'), (4,'0000-00-00 00:00:00'), +(8,'0000-00-00 00:00:00'), (5,'0000-00-00 00:00:00'), +(9,'0000-00-00 00:00:00'), (8,'2007-04-01 11:04:17'), +(1,'0000-00-00 00:00:00'), (7,'2009-01-12 00:00:00'), +(0,'2009-06-05 00:00:00'), (3,'2006-02-14 18:06:35'), +(5,'2006-02-21 07:08:16'), (0,'0000-00-00 00:00:00'), +(7,'0000-00-00 00:00:00'), (0,'0000-00-00 00:00:00'), +(0,'2007-02-13 00:00:00'), (1,'0000-00-00 00:00:00'), +(0,'0000-00-00 00:00:00'), (1,'2003-08-11 00:00:00'); +Warnings: +Warning 1264 Out of range value for column 'datetime_key' at row 2 +Warning 1264 Out of range value for column 'datetime_key' at row 4 +Warning 1264 Out of range value for column 'datetime_key' at row 5 +Warning 1264 Out of range value for column 'datetime_key' at row 6 +Warning 1264 Out of range value for column 'datetime_key' at row 7 +Warning 1264 Out of range value for column 'datetime_key' at row 9 +Warning 1264 Out of range value for column 'datetime_key' at row 14 +Warning 1264 Out of range value for column 'datetime_key' at row 15 +Warning 1264 Out of range value for column 'datetime_key' at row 16 +Warning 1264 Out of range value for column 'datetime_key' at row 18 +Warning 1264 Out of range value for column 'datetime_key' at row 19 +CREATE TABLE ot1 ( +int_nokey int(11) NOT NULL, +int_key int(11) NOT NULL, +KEY int_key (int_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO ot1 VALUES +(5,0), (3,0), (0,2), (3,0), (1,3), (0,0), (1,7), (7,0), (1,7), (0,7), +(0,9), (8,2), (4,4), (9,3), (0,9), (2,5), (0,5), (8,0), (5,8), (1,5); +CREATE TABLE it1 ( +int_nokey int(11) NOT NULL, +int_key int(11) NOT NULL, +KEY int_key (int_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO it1 VALUES +(9,5), (0,4); +SELECT int_key FROM ot1 +WHERE int_nokey IN (SELECT it2.int_key +FROM it1 LEFT JOIN it2 ON it2.datetime_key); +int_key +0 +0 +0 +0 +0 +0 +2 +2 +3 +5 +5 +7 +7 +7 +8 +9 +9 +EXPLAIN +SELECT int_key FROM ot1 +WHERE int_nokey IN (SELECT it2.int_key +FROM it1 LEFT JOIN it2 ON it2.datetime_key); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 20 10.00 Using where +2 MATERIALIZED it1 NULL index NULL int_key 4 NULL 2 100.00 Using index +2 MATERIALIZED it2 NULL ALL int_key NULL NULL NULL 20 90.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`int_key` AS `int_key` from `test`.`ot1` semi join (`test`.`it1` join `test`.`it2`) where ((`test`.`ot1`.`int_nokey` = ``.`int_key`) and (TIMESTAMP'0000-00-00 00:00:00' <> `test`.`it2`.`datetime_key`)) +DROP TABLE ot1, it1, it2; +# End of BUG#38075 +# +# BUG#50089: Second call of procedure with view in subselect crashes server +# +CREATE TABLE t1(t1field INTEGER, PRIMARY KEY(t1field)); +CREATE VIEW v1 AS +SELECT t1field AS v1field +FROM t1 a +WHERE a.t1field IN (SELECT t1field FROM t1); +INSERT INTO t1 VALUES(1),(2); +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT v1field FROM v1); +t1field +1 +2 +EXPLAIN +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT v1field FROM v1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index PRIMARY PRIMARY 4 NULL 2 100.00 Using index +1 SIMPLE a NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `t1`.`t1field` AS `t1field` from `test`.`t1` `a` join `test`.`t1` join `test`.`t1` where ((`test`.`a`.`t1field` = `t1`.`t1field`) and (`test`.`t1`.`t1field` = `t1`.`t1field`)) +SELECT t1.t1field +FROM t1 LEFT JOIN t1 AS t2 ON t1.t1field IN (SELECT v1field FROM v1); +t1field +1 +1 +2 +2 +EXPLAIN +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT v1field FROM v1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index PRIMARY PRIMARY 4 NULL 2 100.00 Using index +1 SIMPLE a NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `t1`.`t1field` AS `t1field` from `test`.`t1` `a` join `test`.`t1` join `test`.`t1` where ((`test`.`a`.`t1field` = `t1`.`t1field`) and (`test`.`t1`.`t1field` = `t1`.`t1field`)) +CREATE PROCEDURE p1() +BEGIN +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT v1field FROM v1); +END| +CALL p1; +t1field +1 +2 +CALL p1; +t1field +1 +2 +PREPARE stmt FROM +" +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT v1field FROM v1); +"; +EXECUTE stmt; +t1field +1 +2 + +EXECUTE stmt; +t1field +1 +2 +DROP PROCEDURE p1; +DROP VIEW v1; +DROP TABLE t1; +# End of BUG#50089 +# +# Bug#45191: Incorrectly initialized semi-join led to a wrong result. +# +CREATE TABLE staff (EMPNUM CHAR(3) NOT NULL, +EMPNAME CHAR(20), GRADE DECIMAL(4), CITY CHAR(15)) charset latin1; +CREATE TABLE proj (PNUM CHAR(3) NOT NULL, +PNAME CHAR(20), PTYPE CHAR(6), +BUDGET DECIMAL(9), +CITY CHAR(15)) charset latin1; +CREATE TABLE works (EMPNUM CHAR(3) NOT NULL, +PNUM CHAR(3) NOT NULL, HOURS DECIMAL(5)) charset latin1; +INSERT INTO staff VALUES ('E1','Alice',12,'Deale'); +INSERT INTO staff VALUES ('E2','Betty',10,'Vienna'); +INSERT INTO staff VALUES ('E3','Carmen',13,'Vienna'); +INSERT INTO staff VALUES ('E4','Don',12,'Deale'); +INSERT INTO staff VALUES ('E5','Ed',13,'Akron'); +INSERT INTO proj VALUES ('P1','MXSS','Design',10000,'Deale'); +INSERT INTO proj VALUES ('P2','CALM','Code',30000,'Vienna'); +INSERT INTO proj VALUES ('P3','SDP','Test',30000,'Tampa'); +INSERT INTO proj VALUES ('P4','SDP','Design',20000,'Deale'); +INSERT INTO proj VALUES ('P5','IRM','Test',10000,'Vienna'); +INSERT INTO proj VALUES ('P6','PAYR','Design',50000,'Deale'); +INSERT INTO works VALUES ('E1','P1',40); +INSERT INTO works VALUES ('E1','P2',20); +INSERT INTO works VALUES ('E1','P3',80); +INSERT INTO works VALUES ('E1','P4',20); +INSERT INTO works VALUES ('E1','P5',12); +INSERT INTO works VALUES ('E1','P6',12); +INSERT INTO works VALUES ('E2','P1',40); +INSERT INTO works VALUES ('E2','P2',80); +INSERT INTO works VALUES ('E3','P2',20); +INSERT INTO works VALUES ('E4','P2',20); +INSERT INTO works VALUES ('E4','P4',40); +INSERT INTO works VALUES ('E4','P5',80); +explain SELECT EMPNUM, EMPNAME +FROM staff +WHERE EMPNUM IN +(SELECT EMPNUM FROM works +WHERE PNUM IN +(SELECT PNUM FROM proj)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE staff NULL ALL NULL NULL NULL NULL 5 100.00 NULL +1 SIMPLE NULL eq_ref 3 test.staff.EMPNUM 1 100.00 NULL +2 MATERIALIZED proj NULL ALL NULL NULL NULL NULL 6 100.00 NULL +2 MATERIALIZED works NULL ALL NULL NULL NULL NULL 12 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`staff`.`EMPNUM` AS `EMPNUM`,`test`.`staff`.`EMPNAME` AS `EMPNAME` from `test`.`staff` semi join (`test`.`works` join `test`.`proj`) where ((``.`EMPNUM` = `test`.`staff`.`EMPNUM`) and (`test`.`works`.`PNUM` = `test`.`proj`.`PNUM`)) +SELECT EMPNUM, EMPNAME +FROM staff +WHERE EMPNUM IN +(SELECT EMPNUM FROM works +WHERE PNUM IN +(SELECT PNUM FROM proj)); +EMPNUM EMPNAME +E1 Alice +E2 Betty +E3 Carmen +E4 Don +drop table staff,works,proj; +# End of bug#45191 +# +# BUG#36896: Server crash on SELECT FROM DUAL +# +create table t1 (a int); +select 1 as res from dual where (1) in (select * from t1); +res +drop table t1; + +BUG#40118 Crash when running Batched Key Access and requiring one match for each key + +create table t0(a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (a int, key(a)); +insert into t1 select * from t0; +alter table t1 add b int not null, add filler char(200); +insert into t1 select * from t1; +insert into t1 select * from t1; +select * from t0 where t0.a in (select t1.a from t1 where t1.b=0); +a +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +drop table t0, t1; +# +# BUG#32665 Query with dependent subquery is too slow +# +create table t1 ( +idIndividual int primary key +); +insert into t1 values (1),(2); +create table t2 ( +idContact int primary key, +contactType int, +idObj int +); +insert into t2 values (1,1,1),(2,2,2),(3,3,3); +create table t3 ( +idAddress int primary key, +idContact int, +postalStripped varchar(100) +); +insert into t3 values (1,1, 'foo'), (2,2,'bar'); +The following must be converted to a semi-join: +explain SELECT a.idIndividual FROM t1 a +WHERE a.idIndividual IN +( SELECT c.idObj FROM t3 cona +INNER JOIN t2 c ON c.idContact=cona.idContact +WHERE cona.postalStripped='T2H3B2' + ); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using where +1 SIMPLE a NULL eq_ref PRIMARY PRIMARY 4 .idObj 1 100.00 Using index +2 MATERIALIZED cona NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 MATERIALIZED c NULL eq_ref PRIMARY PRIMARY 4 test.cona.idContact 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`a`.`idIndividual` AS `idIndividual` from `test`.`t1` `a` semi join (`test`.`t3` `cona` join `test`.`t2` `c`) where ((`test`.`c`.`idContact` = `test`.`cona`.`idContact`) and (`test`.`a`.`idIndividual` = ``.`idObj`) and (`test`.`cona`.`postalStripped` = 'T2H3B2')) +drop table t1,t2,t3; +CREATE TABLE t1 (one int, two int, flag char(1)); +CREATE TABLE t2 (one int, two int, flag char(1)); +INSERT INTO t1 VALUES(1,2,'Y'),(2,3,'Y'),(3,4,'Y'),(5,6,'N'),(7,8,'N'); +INSERT INTO t2 VALUES(1,2,'Y'),(2,3,'Y'),(3,4,'Y'),(5,6,'N'),(7,8,'N'); +SELECT * FROM t1 +WHERE ROW(one,two) IN (SELECT DISTINCT one,two FROM t2 WHERE flag = 'N'); +one two flag +5 6 N +7 8 N +SELECT * FROM t1 +WHERE ROW(one,two) IN (SELECT DISTINCT one,two FROM t1 WHERE flag = 'N'); +one two flag +5 6 N +7 8 N +insert into t2 values (null,null,'N'); +insert into t2 values (null,3,'0'); +insert into t2 values (null,5,'0'); +insert into t2 values (10,null,'0'); +insert into t1 values (10,3,'0'); +insert into t1 values (10,5,'0'); +insert into t1 values (10,10,'0'); +SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = 'N') as 'test' from t1; +one two test +1 2 NULL +2 3 NULL +3 4 NULL +5 6 1 +7 8 1 +10 3 NULL +10 5 NULL +10 10 NULL +SELECT one,two from t1 where ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = 'N'); +one two +5 6 +7 8 +SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = 'N' group by one,two) as 'test' from t1; +one two test +1 2 NULL +2 3 NULL +3 4 NULL +5 6 1 +7 8 1 +10 3 NULL +10 5 NULL +10 10 NULL +SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = '0') as 'test' from t1; +one two test +1 2 0 +2 3 NULL +3 4 0 +5 6 0 +7 8 0 +10 3 NULL +10 5 NULL +10 10 NULL +SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = '0' group by one,two) as 'test' from t1; +one two test +1 2 0 +2 3 NULL +3 4 0 +5 6 0 +7 8 0 +10 3 NULL +10 5 NULL +10 10 NULL +explain SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = '0') as 'test' from t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 9 11.11 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`one` AS `one`,`test`.`t1`.`two` AS `two`,((`test`.`t1`.`one`,`test`.`t1`.`two`),(/* select#2 */ select `test`.`t2`.`one`,`test`.`t2`.`two` from `test`.`t2` where ((`test`.`t2`.`flag` = '0') and (outer_field_is_not_null, (((`test`.`t1`.`one`) = `test`.`t2`.`one`) or (`test`.`t2`.`one` is null)), true) and (outer_field_is_not_null, (((`test`.`t1`.`two`) = `test`.`t2`.`two`) or (`test`.`t2`.`two` is null)), true)) having ((outer_field_is_not_null, (`test`.`t2`.`one`), true) and (outer_field_is_not_null, (`test`.`t2`.`two`), true)))) AS `test` from `test`.`t1` +explain SELECT one,two from t1 where ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = 'N'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 9 11.11 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`one` AS `one`,`test`.`t1`.`two` AS `two` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`two` = ``.`two`) and (`test`.`t1`.`one` = ``.`one`) and (`test`.`t2`.`flag` = 'N')) +explain SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = '0' group by one,two) as 'test' from t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 9 11.11 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`one` AS `one`,`test`.`t1`.`two` AS `two`,((`test`.`t1`.`one`,`test`.`t1`.`two`),(/* select#2 */ select `test`.`t2`.`one`,`test`.`t2`.`two` from `test`.`t2` where ((`test`.`t2`.`flag` = '0') and (outer_field_is_not_null, (((`test`.`t1`.`one`) = `test`.`t2`.`one`) or (`test`.`t2`.`one` is null)), true) and (outer_field_is_not_null, (((`test`.`t1`.`two`) = `test`.`t2`.`two`) or (`test`.`t2`.`two` is null)), true)) having ((outer_field_is_not_null, (`test`.`t2`.`one`), true) and (outer_field_is_not_null, (`test`.`t2`.`two`), true)))) AS `test` from `test`.`t1` +DROP TABLE t1,t2; +CREATE TABLE t1 (a char(5), b char(5)); +INSERT INTO t1 VALUES (NULL,'aaa'), ('aaa','aaa'); +SELECT * FROM t1 WHERE (a,b) IN (('aaa','aaa'), ('aaa','bbb')); +a b +aaa aaa +DROP TABLE t1; +CREATE TABLE t1 (a CHAR(1), b VARCHAR(10)) charset utf8mb4; +INSERT INTO t1 VALUES ('a', 'aa'); +INSERT INTO t1 VALUES ('a', 'aaa'); +SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1); +a b +CREATE INDEX I1 ON t1 (a); +CREATE INDEX I2 ON t1 (b); +EXPLAIN SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL I2 NULL NULL NULL 2 100.00 Using where +1 SIMPLE NULL eq_ref 5 test.t1.b 1 100.00 Using where +2 MATERIALIZED t1 NULL index I1 I1 5 NULL 2 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t1`) where (`test`.`t1`.`b` = ``.`a`) +SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1); +a b +CREATE TABLE t2 (a VARCHAR(1), b VARCHAR(10)) charset utf8mb4; +INSERT INTO t2 SELECT * FROM t1; +CREATE INDEX I1 ON t2 (a); +CREATE INDEX I2 ON t2 (b); +EXPLAIN SELECT a,b FROM t2 WHERE b IN (SELECT a FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL I2 NULL NULL NULL 2 100.00 Using where +1 SIMPLE NULL eq_ref 7 test.t2.b 1 100.00 Using where +2 MATERIALIZED t2 NULL index I1 I1 7 NULL 2 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t2` semi join (`test`.`t2`) where (`test`.`t2`.`b` = ``.`a`) +SELECT a,b FROM t2 WHERE b IN (SELECT a FROM t2); +a b +EXPLAIN +SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1 WHERE LENGTH(a)<500); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL I2 NULL NULL NULL 2 100.00 Using where +1 SIMPLE NULL eq_ref 5 test.t1.b 1 100.00 Using where +2 MATERIALIZED t1 NULL index I1 I1 5 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t1`) where ((length(`test`.`t1`.`a`) < 500) and (`test`.`t1`.`b` = ``.`a`)) +SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1 WHERE LENGTH(a)<500); +a b +DROP TABLE t1,t2; +# +# BUG#45928 "Differing query results depending on MRR and +# engine_condition_pushdown settings" +# +CREATE TABLE `t1` ( +`pk` int(11) NOT NULL AUTO_INCREMENT, +`time_nokey` time NOT NULL, +`varchar_key` varchar(1) NOT NULL, +`varchar_nokey` varchar(1) NOT NULL, +PRIMARY KEY (`pk`), +KEY `varchar_key` (`varchar_key`) +) AUTO_INCREMENT=12 DEFAULT CHARSET=latin1; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO `t1` VALUES (10,'00:00:00','i','i'),(11,'00:00:00','',''); +SELECT `time_nokey` G1 FROM t1 WHERE ( `varchar_nokey` , `varchar_key` ) IN ( +SELECT `varchar_nokey` , `varchar_nokey` ) AND `varchar_key` >= 'c' HAVING G1 ORDER +BY `pk` ; +G1 +DROP TABLE t1; +# +# BUG#45863 "Assertion failed: (fixed == 0), function fix_fields(), +# file item.cc, line 4448" +# +DROP TABLE IF EXISTS C, BB; +CREATE TABLE C ( +varchar_nokey varchar(1) NOT NULL +); +INSERT INTO C VALUES +('k'),('a'),(''),('u'),('e'),('v'),('i'), +('t'),('u'),('f'),('u'),('m'),('j'),('f'), +('v'),('j'),('g'),('e'),('h'),('z'); +CREATE TABLE BB ( +varchar_nokey varchar(1) NOT NULL +); +INSERT INTO BB VALUES ('i'),('t'); +SELECT varchar_nokey FROM C +WHERE (varchar_nokey, OUTR) IN (SELECT varchar_nokey +FROM BB); +ERROR 42S22: Unknown column 'OUTR' in 'IN/ALL/ANY subquery' +SELECT varchar_nokey FROM C +WHERE (varchar_nokey, OUTR) IN (SELECT varchar_nokey, varchar_nokey +FROM BB); +ERROR 42S22: Unknown column 'OUTR' in 'IN/ALL/ANY subquery' +DROP TABLE C,BB; +# +# During work with BUG#45863 I had problems with a query that was +# optimized differently in regular and prepared mode. +# Because there was a bug in one of the selected strategies, I became +# aware of the problem. Adding an EXPLAIN query to catch this. +DROP TABLE IF EXISTS t1, t2, t3; +CREATE TABLE t1 +(EMPNUM CHAR(3) NOT NULL, +EMPNAME CHAR(20), +GRADE DECIMAL(4), +CITY CHAR(15)) charset latin1; +CREATE TABLE t2 +(PNUM CHAR(3) NOT NULL, +PNAME CHAR(20), +PTYPE CHAR(6), +BUDGET DECIMAL(9), +CITY CHAR(15)) charset latin1; +CREATE TABLE t3 +(EMPNUM CHAR(3) NOT NULL, +PNUM CHAR(3) NOT NULL, +HOURS DECIMAL(5)) charset latin1; +INSERT INTO t1 VALUES ('E1','Alice',12,'Deale'); +INSERT INTO t1 VALUES ('E2','Betty',10,'Vienna'); +INSERT INTO t1 VALUES ('E3','Carmen',13,'Vienna'); +INSERT INTO t1 VALUES ('E4','Don',12,'Deale'); +INSERT INTO t1 VALUES ('E5','Ed',13,'Akron'); +INSERT INTO t2 VALUES ('P1','MXSS','Design',10000,'Deale'); +INSERT INTO t2 VALUES ('P2','CALM','Code',30000,'Vienna'); +INSERT INTO t2 VALUES ('P3','SDP','Test',30000,'Tampa'); +INSERT INTO t2 VALUES ('P4','SDP','Design',20000,'Deale'); +INSERT INTO t2 VALUES ('P5','IRM','Test',10000,'Vienna'); +INSERT INTO t2 VALUES ('P6','PAYR','Design',50000,'Deale'); +INSERT INTO t3 VALUES ('E1','P1',40); +INSERT INTO t3 VALUES ('E1','P2',20); +INSERT INTO t3 VALUES ('E1','P3',80); +INSERT INTO t3 VALUES ('E1','P4',20); +INSERT INTO t3 VALUES ('E1','P5',12); +INSERT INTO t3 VALUES ('E1','P6',12); +INSERT INTO t3 VALUES ('E2','P1',40); +INSERT INTO t3 VALUES ('E2','P2',80); +INSERT INTO t3 VALUES ('E3','P2',20); +INSERT INTO t3 VALUES ('E4','P2',20); +INSERT INTO t3 VALUES ('E4','P4',40); +INSERT INTO t3 VALUES ('E4','P5',80); +CREATE UNIQUE INDEX t1_IDX ON t1(EMPNUM); +EXPLAIN SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN +(SELECT EMPNUM +FROM t3 +WHERE PNUM IN +(SELECT PNUM +FROM t2 +WHERE PTYPE = 'Design')); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL eq_ref t1_IDX t1_IDX 3 .EMPNUM 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = ``.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) +PREPARE stmt FROM "EXPLAIN SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN + (SELECT EMPNUM + FROM t3 + WHERE PNUM IN + (SELECT PNUM + FROM t2 + WHERE PTYPE = 'Design'))"; +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL eq_ref t1_IDX t1_IDX 3 .EMPNUM 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = ``.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) + +This line is only in place to help --skip_if_hypergraph diffing some more. + +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL eq_ref t1_IDX t1_IDX 3 .EMPNUM 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = ``.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) +DEALLOCATE PREPARE stmt; +DROP INDEX t1_IDX ON t1; +CREATE INDEX t1_IDX ON t1(EMPNUM); +EXPLAIN SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN +(SELECT EMPNUM +FROM t3 +WHERE PNUM IN +(SELECT PNUM +FROM t2 +WHERE PTYPE = 'Design')); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ref t1_IDX t1_IDX 3 .EMPNUM 2 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = ``.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) +PREPARE stmt FROM "EXPLAIN SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN + (SELECT EMPNUM + FROM t3 + WHERE PNUM IN + (SELECT PNUM + FROM t2 + WHERE PTYPE = 'Design'))"; +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ref t1_IDX t1_IDX 3 .EMPNUM 2 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = ``.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) + +This line is only in place to help --skip_if_hypergraph diffing some more. + +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ref t1_IDX t1_IDX 3 .EMPNUM 2 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = ``.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) +DEALLOCATE PREPARE stmt; +DROP INDEX t1_IDX ON t1; +EXPLAIN SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN +(SELECT EMPNUM +FROM t3 +WHERE PNUM IN +(SELECT PNUM +FROM t2 +WHERE PTYPE = 'Design')); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 20.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = ``.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) +PREPARE stmt FROM "EXPLAIN SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN + (SELECT EMPNUM + FROM t3 + WHERE PNUM IN + (SELECT PNUM + FROM t2 + WHERE PTYPE = 'Design'))"; +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 20.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = ``.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) + +This line is only in place to help --skip_if_hypergraph diffing some more. + +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 20.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = ``.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) +DEALLOCATE PREPARE stmt; +DROP TABLE t1, t2, t3; +# +# BUG#45221 Query SELECT pk FROM C WHERE pk IN (SELECT int_key) failing +# +CREATE TABLE t1 ( +i1_key INT, +i2 INT, +i3 INT, +KEY i1_index (i1_key) +); +INSERT INTO t1 VALUES (9,1,2), (9,2,1); +CREATE TABLE t2 ( +pk INT NOT NULL, +i1 INT, +PRIMARY KEY (pk) +); +INSERT INTO t2 VALUES (9,1); +SELECT pk +FROM t2 +WHERE +pk IN ( +SELECT i1_key +FROM t1 +WHERE t1.i2 < t1.i3 XOR t2.i1 > 1 +ORDER BY t1.i2 desc); +pk +9 +DROP TABLE t1,t2; +# BUG#50361 Doublenested noncorrelated subquery with FirstMatch and join cache wrong result +# +CREATE TABLE t1( +id INTEGER +); +INSERT INTO t1 VALUES(10),(20); +create table t2 select * from t1; +create table t3 select * from t1; +SELECT * +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t2 +WHERE 1 IN(SELECT 1 +FROM t3)); +id +10 +20 +explain SELECT * +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t2 +WHERE 1 IN(SELECT 1 +FROM t3)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE NULL const 4 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where true +delete from t2; +delete from t3; +INSERT INTO t1 VALUES(30),(40),(50),(60),(70),(80),(90); +insert into t2 select * from t1; +insert into t3 select * from t1; +create table t4 select * from t1; +SELECT * +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t2 +WHERE 1 IN(SELECT 1 +FROM t3 +WHERE 1 IN(SELECT 1 +FROM t4))); +id +10 +20 +30 +40 +50 +60 +70 +80 +90 +explain SELECT * +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t2 +WHERE 1 IN(SELECT 1 +FROM t3 +WHERE 1 IN(SELECT 1 +FROM t4))); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 9 100.00 NULL +1 SIMPLE NULL const 4 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 9 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 9 100.00 NULL +2 MATERIALIZED t4 NULL ALL NULL NULL NULL NULL 9 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3` join `test`.`t4`) where true +SELECT * +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t1))); +id +10 +20 +30 +40 +50 +60 +70 +80 +90 +drop table t1,t2,t3,t4; +# +# Bug#53236 Segfault in DTCollation::set(DTCollation&) +# +CREATE TABLE t1 ( +pk INTEGER AUTO_INCREMENT, +col_varchar VARCHAR(1), +PRIMARY KEY (pk) +) +; +INSERT INTO t1 (col_varchar) +VALUES +('w'), +('m') +; +SELECT table1.pk +FROM ( t1 AS table1 JOIN t1 AS table2 ON (table1.col_varchar = +table2.col_varchar) ) +WHERE ( 1, 2 ) IN ( SELECT SUBQUERY1_t1.pk AS SUBQUERY1_field1, +SUBQUERY1_t1.pk AS SUBQUERY1_field2 +FROM ( t1 AS SUBQUERY1_t1 JOIN t1 AS SUBQUERY1_t2 +ON (SUBQUERY1_t2.col_varchar = +SUBQUERY1_t1.col_varchar) ) ) +; +pk +drop table t1; +# +# BUG#53298 "wrong result with semijoin (no semijoin strategy chosen)" +# +create table t1 (uid int, fid int); +insert into t1 values (1,1), (3,1); +create table t2 (uid int, name varchar(128)); +insert into t2 values (1, "A"), (2, "B"); +create table t3 (uid int, fid int, index(uid)); +insert into t3 values (1,3), (1,3); +create table t4 (uid int); +insert into t4 values (3); +explain select t2.uid from t2, t1 +where t1.uid in (select t4.uid from t4, t3 where t3.uid=1 and t4.uid=t3.fid) +and t2.uid=t1.fid; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 0.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 MATERIALIZED t4 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 MATERIALIZED t3 NULL ref uid uid 5 const 1 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`uid` AS `uid` from `test`.`t2` join `test`.`t1` semi join (`test`.`t4` join `test`.`t3`) where ((`test`.`t1`.`uid` = ``.`uid`) and (`test`.`t3`.`fid` = `test`.`t4`.`uid`) and (`test`.`t3`.`uid` = 1) and (`test`.`t1`.`fid` = `test`.`t2`.`uid`)) +select t2.uid from t2, t1 +where t1.uid in (select t4.uid from t4, t3 where t3.uid=1 and t4.uid=t3.fid) +and t2.uid=t1.fid; +uid +1 +drop table t1,t2,t3,t4; +CREATE TABLE t1 ( +pk int, +a varchar(1), +b varchar(4), +c varchar(4), +d varchar(4), +PRIMARY KEY (pk) +) charset utf8mb4; +INSERT INTO t1 VALUES (1,'o','ffff','ffff','ffoo'),(2,'f','ffff','ffff','ffff'); +CREATE TABLE t2 LIKE t1; +INSERT INTO t2 VALUES (1,'i','iiii','iiii','iiii'),(2,'f','ffff','ffff','ffff'); +EXPLAIN SELECT pk FROM t1 WHERE (a) IN (SELECT a FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE NULL eq_ref 7 test.t1.a 1 100.00 NULL +2 MATERIALIZED t2 NULL range PRIMARY PRIMARY 4 NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((``.`a` = `test`.`t1`.`a`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (a) IN (SELECT a FROM t2 WHERE pk > 0); +pk +2 +SELECT pk FROM t1 WHERE (b,c,d) IN (SELECT b,c,d FROM t2 WHERE pk > 0); +pk +2 +DROP TABLE t1, t2; +CREATE TABLE t1 (f1 INT, f2 DECIMAL(5,3)) ENGINE=MyISAM; +INSERT INTO t1 (f1, f2) VALUES (1, 1.789); +INSERT INTO t1 (f1, f2) VALUES (13, 1.454); +INSERT INTO t1 (f1, f2) VALUES (10, 1.668); +CREATE TABLE t2 LIKE t1; +INSERT INTO t2 VALUES (1, 1.789); +INSERT INTO t2 VALUES (13, 1.454); +EXPLAIN SELECT COUNT(*) FROM t1 WHERE (f1,f2) IN (SELECT f1,f2 FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`f2` = ``.`f2`) and (`test`.`t1`.`f1` = ``.`f1`)) +SELECT COUNT(*) FROM t1 WHERE (f1,f2) IN (SELECT f1,f2 FROM t2); +COUNT(*) +2 +DROP TABLE t1, t2; +CREATE TABLE t1 ( +ID int(11) NOT NULL auto_increment, +Name char(35) NOT NULL default '', +Country char(3) NOT NULL default '', +Population int(11) NOT NULL default '0', +PRIMARY KEY (ID), +INDEX (Population), +INDEX (Country) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t2 ( +Code char(3) NOT NULL default '', +Name char(52) NOT NULL default '', +SurfaceArea float(10,2) NOT NULL default '0.00', +Population int(11) NOT NULL default '0', +Capital int(11) default NULL, +PRIMARY KEY (Code), +UNIQUE INDEX (Name), +INDEX (Population) +) charset utf8mb4; +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t3 ( +Country char(3) NOT NULL default '', +Language char(30) NOT NULL default '', +Percentage float(3,1) NOT NULL default '0.0', +PRIMARY KEY (Country, Language), +INDEX (Percentage) +) charset utf8mb4; +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +EXPLAIN SELECT Name FROM t2 +WHERE t2.Code IN (SELECT Country FROM t1 WHERE Population > 5000000) +AND +t2.Code IN (SELECT Country FROM t3 +WHERE Language='English' AND Percentage > 10 AND +t2.Population > 100000); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t2 NULL eq_ref PRIMARY,Population PRIMARY 12 .Country 1 75.00 Using where +1 SIMPLE t3 NULL eq_ref PRIMARY,Percentage PRIMARY 132 .Country,const 1 95.45 Using where +2 MATERIALIZED t1 NULL range Population,Country Population 4 NULL 1 100.00 Using where +Warnings: +Note 1276 Field or reference 'test.t2.Population' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t2`.`Name` AS `Name` from `test`.`t3` join `test`.`t2` semi join (`test`.`t1`) where ((`test`.`t2`.`Code` = ``.`Country`) and (`test`.`t3`.`Country` = ``.`Country`) and (`test`.`t3`.`Language` = 'English') and (`test`.`t3`.`Percentage` > 10) and (`test`.`t2`.`Population` > 100000) and (`test`.`t1`.`Population` > 5000000)) +EXPLAIN FORMAT=JSON SELECT Name FROM t2 +WHERE t2.Code IN (SELECT Country FROM t1 WHERE Population > 5000000) +AND +t2.Code IN (SELECT Country FROM t3 +WHERE Language='English' AND Percentage > 10 AND +t2.Population > 100000); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "2.52" + }, + "nested_loop": [ + { + "table": { + "table_name": "", + "access_type": "ALL", + "materialized_from_subquery": { + "using_temporary_table": true, + "query_block": { + "table": { + "table_name": "t1", + "access_type": "range", + "possible_keys": [ + "Population", + "Country" + ], + "key": "Population", + "used_key_parts": [ + "Population" + ], + "key_length": "4", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.61", + "eval_cost": "0.10", + "prefix_cost": "0.71", + "data_read_per_join": "168" + }, + "used_columns": [ + "Country", + "Population" + ], + "attached_condition": "(`test`.`t1`.`Population` > 5000000)" + } + } + } + } + }, + { + "table": { + "table_name": "t2", + "access_type": "eq_ref", + "possible_keys": [ + "PRIMARY", + "Population" + ], + "key": "PRIMARY", + "used_key_parts": [ + "Code" + ], + "key_length": "12", + "ref": [ + ".Country" + ], + "rows_examined_per_scan": 1, + "rows_produced_per_join": 0, + "filtered": "75.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.08", + "prefix_cost": "2.26", + "data_read_per_join": "180" + }, + "used_columns": [ + "Code", + "Name", + "Population" + ], + "attached_condition": "(`test`.`t2`.`Population` > 100000)" + } + }, + { + "table": { + "table_name": "t3", + "access_type": "eq_ref", + "possible_keys": [ + "PRIMARY", + "Percentage" + ], + "key": "PRIMARY", + "used_key_parts": [ + "Country", + "Language" + ], + "key_length": "132", + "ref": [ + ".Country", + "const" + ], + "rows_examined_per_scan": 1, + "rows_produced_per_join": 0, + "filtered": "95.45", + "cost_info": { + "read_cost": "0.19", + "eval_cost": "0.07", + "prefix_cost": "2.52", + "data_read_per_join": "103" + }, + "used_columns": [ + "Country", + "Language", + "Percentage" + ], + "attached_condition": "((`test`.`t3`.`Language` = 'English') and (`test`.`t3`.`Percentage` > 10))" + } + } + ] + } +} +Warnings: +Note 1276 Field or reference 'test.t2.Population' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t2`.`Name` AS `Name` from `test`.`t3` join `test`.`t2` semi join (`test`.`t1`) where ((`test`.`t2`.`Code` = ``.`Country`) and (`test`.`t3`.`Country` = ``.`Country`) and (`test`.`t3`.`Language` = 'English') and (`test`.`t3`.`Percentage` > 10) and (`test`.`t2`.`Population` > 100000) and (`test`.`t1`.`Population` > 5000000)) +DROP TABLE t1,t2,t3; +CREATE TABLE t1 ( +Code char(3) NOT NULL DEFAULT '', +Name char(52) NOT NULL DEFAULT '', +Continent enum('Asia','Europe','North America','Africa','Oceania','Antarctica','South America') NOT NULL DEFAULT 'Asia', +Region char(26) NOT NULL DEFAULT '', +SurfaceArea float(10,2) NOT NULL DEFAULT '0.00', +IndepYear smallint(6) DEFAULT NULL, +Population int(11) NOT NULL DEFAULT '0', +LifeExpectancy float(3,1) DEFAULT NULL, +GNP float(10,2) DEFAULT NULL, +GNPOld float(10,2) DEFAULT NULL, +LocalName char(45) NOT NULL DEFAULT '', +GovernmentForm char(45) NOT NULL DEFAULT '', +HeadOfState char(60) DEFAULT NULL, +Capital int(11) DEFAULT NULL, +Code2 char(2) NOT NULL DEFAULT '', +PRIMARY KEY (Code) +) charset utf8mb4; +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t2 ( +ID int(11) NOT NULL AUTO_INCREMENT, +Name char(35) NOT NULL DEFAULT '', +CountryCode char(3) NOT NULL DEFAULT '', +District char(20) NOT NULL DEFAULT '', +Population int(11) NOT NULL DEFAULT '0', +PRIMARY KEY (ID), +KEY CountryCode (CountryCode) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +set names latin1; +Fill the table with test data +This must not use LooseScan: +EXPLAIN SELECT Name FROM t1 +WHERE t1.Code IN ( +SELECT t2.CountryCode FROM t2 WHERE Population > 5000000); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL PRIMARY NULL NULL NULL 31 100.00 NULL +1 SIMPLE NULL eq_ref 12 test.t1.Code 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL CountryCode NULL NULL NULL 545 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`Name` AS `Name` from `test`.`t1` semi join (`test`.`t2`) where ((``.`CountryCode` = `test`.`t1`.`Code`) and (`test`.`t2`.`Population` > 5000000)) +SELECT Name FROM t1 +WHERE t1.Code IN ( +SELECT t2.CountryCode FROM t2 WHERE Population > 5000000); +Name +Austria +Canada +China +Czech Republic +drop table t1, t2; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4); +create table t1 (a int, b int, key(a)); +insert into t1 select a,a from t0; +create table t2 (a int, b int, primary key(a)); +insert into t2 select * from t1; +Table t2, unlike table t1, should be displayed as pulled out +explain select * from t0 +where t0.a in ( select t1.a from t1,t2 where t2.a=t0.a and +t1.b=t2.b); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL a NULL NULL NULL 5 100.00 Using where; Start temporary +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 20.00 Using where +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 5 20.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t0.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a` from `test`.`t2` join `test`.`t0` semi join (`test`.`t1`) where ((`test`.`t2`.`a` = `test`.`t1`.`a`) and (`test`.`t0`.`a` = `test`.`t1`.`a`) and (`test`.`t2`.`b` = `test`.`t1`.`b`)) +update t1 set a=3, b=11 where a=4; +update t2 set b=11 where a=3; +select * from t0 where t0.a in (select t1.a from t1, t2 where t2.a=t0.a and t1.b=t2.b); +a +0 +1 +2 +3 +drop table t0, t1, t2; +CREATE TABLE t1 ( +id int(11) NOT NULL, +PRIMARY KEY (id)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t2 ( +id int(11) NOT NULL, +fid int(11) NOT NULL, +PRIMARY KEY (id)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t1 values(1); +insert into t2 values(1,7503),(2,1); +explain select count(*) +from t1 +where fid IN (select fid from t2 where (id between 7502 and 8420) order by fid ); +ERROR 42S22: Unknown column 'fid' in 'IN/ALL/ANY subquery' +drop table t1, t2; +create table t1 (a int, b int, key (a), key (b)); +insert into t1 values (2,4),(2,4),(2,4); +select t1.a from t1 +where +t1.a in (select 1 from t1 where t1.a in (select 1 from t1) group by t1.a); +a +drop table t1; +create table t1(a int,b int,key(a),key(b)); +insert into t1 values (1,1),(2,2),(3,3); +select 1 from t1 +where t1.a not in (select 1 from t1 +where t1.a in (select 1 from t1) +group by t1.b); +1 +1 +1 +drop table t1; +CREATE TABLE t1 +(EMPNUM CHAR(3) NOT NULL, +EMPNAME CHAR(20), +GRADE DECIMAL(4), +CITY CHAR(15)); +CREATE TABLE t2 +(PNUM CHAR(3) NOT NULL, +PNAME CHAR(20), +PTYPE CHAR(6), +BUDGET DECIMAL(9), +CITY CHAR(15)); +CREATE TABLE t3 +(EMPNUM CHAR(3) NOT NULL, +PNUM CHAR(3) NOT NULL, +HOURS DECIMAL(5)); +INSERT INTO t1 VALUES ('E1','Alice',12,'Deale'); +INSERT INTO t1 VALUES ('E2','Betty',10,'Vienna'); +INSERT INTO t1 VALUES ('E3','Carmen',13,'Vienna'); +INSERT INTO t1 VALUES ('E4','Don',12,'Deale'); +INSERT INTO t1 VALUES ('E5','Ed',13,'Akron'); +INSERT INTO t2 VALUES ('P1','MXSS','Design',10000,'Deale'); +INSERT INTO t2 VALUES ('P2','CALM','Code',30000,'Vienna'); +INSERT INTO t2 VALUES ('P3','SDP','Test',30000,'Tampa'); +INSERT INTO t2 VALUES ('P4','SDP','Design',20000,'Deale'); +INSERT INTO t2 VALUES ('P5','IRM','Test',10000,'Vienna'); +INSERT INTO t2 VALUES ('P6','PAYR','Design',50000,'Deale'); +INSERT INTO t3 VALUES ('E1','P1',40); +INSERT INTO t3 VALUES ('E1','P2',20); +INSERT INTO t3 VALUES ('E1','P3',80); +INSERT INTO t3 VALUES ('E1','P4',20); +INSERT INTO t3 VALUES ('E1','P5',12); +INSERT INTO t3 VALUES ('E1','P6',12); +INSERT INTO t3 VALUES ('E2','P1',40); +INSERT INTO t3 VALUES ('E2','P2',80); +INSERT INTO t3 VALUES ('E3','P2',20); +INSERT INTO t3 VALUES ('E4','P2',20); +INSERT INTO t3 VALUES ('E4','P4',40); +INSERT INTO t3 VALUES ('E4','P5',80); +SELECT * FROM t1; +EMPNUM EMPNAME GRADE CITY +E1 Alice 12 Deale +E2 Betty 10 Vienna +E3 Carmen 13 Vienna +E4 Don 12 Deale +E5 Ed 13 Akron +CREATE UNIQUE INDEX t1_IDX ON t1(EMPNUM); +SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN +(SELECT EMPNUM +FROM t3 +WHERE PNUM IN +(SELECT PNUM +FROM t2 +WHERE PTYPE = 'Design')); +EMPNAME +Alice +Betty +Don +DROP INDEX t1_IDX ON t1; +CREATE INDEX t1_IDX ON t1(EMPNUM); +SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN +(SELECT EMPNUM +FROM t3 +WHERE PNUM IN +(SELECT PNUM +FROM t2 +WHERE PTYPE = 'Design')); +EMPNAME +Alice +Betty +Don +DROP INDEX t1_IDX ON t1; +SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN +(SELECT EMPNUM +FROM t3 +WHERE PNUM IN +(SELECT PNUM +FROM t2 +WHERE PTYPE = 'Design')); +EMPNAME +Alice +Betty +Don +DROP TABLE t1, t2, t3; +CREATE TABLE t1 (f1 INT NOT NULL); +CREATE VIEW v1 (a) AS SELECT f1 IN (SELECT f1 FROM t1) FROM t1; +SELECT * FROM v1; +a +drop view v1; +drop table t1; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1(a int, b int); +insert into t1 values (0,0),(1,1),(2,2); +create table t2 as select * from t1; +create table t3 (pk int, a int, primary key(pk)); +insert into t3 select a,a from t0; +explain +select * from t1 left join t2 on (t2.a= t1.a and t2.a in (select pk from t3)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE t3 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using index +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` left join (`test`.`t3` join `test`.`t2`) on(((`test`.`t3`.`pk` = `test`.`t1`.`a`) and (`test`.`t2`.`a` = `test`.`t1`.`a`))) where true +drop table t0, t1, t2, t3; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (a int) as select A.a + 10 *(B.a + 10*C.a) as a from t0 A, t0 B, t0 C; +create table t2 (id int, a int, primary key(id), key(a)) charset utf8mb4 as select a as id, a as a from t1; +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `id` int NOT NULL, + `a` int DEFAULT NULL, + PRIMARY KEY (`id`), + KEY `a` (`a`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +set @a=0; +create table t3 as select * from t2 limit 0; +insert into t3 select @a:=@a+1, t2.a from t2, t0; +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +insert into t3 select @a:=@a+1, t2.a from t2, t0; +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +insert into t3 select @a:=@a+1, t2.a from t2, t0; +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +alter table t3 add primary key(id), add 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); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index a a 5 NULL 1000 100.00 Using where; Using index +1 SIMPLE NULL eq_ref 5 test.t2.a 1 100.00 NULL +2 MATERIALIZED t3 NULL index a a 5 NULL 30000 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select count(`test`.`t2`.`a`) AS `count(a)` from `test`.`t2` semi join (`test`.`t3`) where (``.`a` = `test`.`t2`.`a`) +select count(a) from t2 where a in ( SELECT a FROM t3); +count(a) +1000 +drop table t0,t1,t2,t3; +# +# Bug#33062: subquery in stored routine cause crash +# +CREATE TABLE t1(a INT); +CREATE TABLE t2(c INT); +CREATE PROCEDURE p1(v1 int) +BEGIN +SELECT 1 FROM t1 WHERE a = v1 AND a IN (SELECT c FROM t2); +END +// +CREATE PROCEDURE p2(v1 int) +BEGIN +SELECT 1 FROM t1 WHERE a IN (SELECT c FROM t2); +END +// +CREATE PROCEDURE p3(v1 int) +BEGIN +SELECT 1 +FROM +t1 t01,t1 t02,t1 t03,t1 t04,t1 t05,t1 t06,t1 t07,t1 t08, +t1 t09,t1 t10,t1 t11,t1 t12,t1 t13,t1 t14,t1 t15,t1 t16, +t1 t17,t1 t18,t1 t19,t1 t20,t1 t21,t1 t22,t1 t23,t1 t24, +t1 t25,t1 t26,t1 t27,t1 t28,t1 t29,t1 t30,t1 t31,t1 t32, +t1 t33,t1 t34,t1 t35,t1 t36,t1 t37,t1 t38,t1 t39,t1 t40, +t1 t41,t1 t42,t1 t43,t1 t44,t1 t45,t1 t46,t1 t47,t1 t48, +t1 t49,t1 t50,t1 t51,t1 t52,t1 t53,t1 t54,t1 t55,t1 t56, +t1 t57,t1 t58,t1 t59,t1 t60 +WHERE t01.a IN (SELECT c FROM t2); +END +// +CREATE PROCEDURE p4(v1 int) +BEGIN +SELECT 1 +FROM +t1 t01,t1 t02,t1 t03,t1 t04,t1 t05,t1 t06,t1 t07,t1 t08, +t1 t09,t1 t10,t1 t11,t1 t12,t1 t13,t1 t14,t1 t15,t1 t16, +t1 t17,t1 t18,t1 t19,t1 t20,t1 t21,t1 t22,t1 t23,t1 t24, +t1 t25,t1 t26,t1 t27,t1 t28,t1 t29,t1 t30,t1 t31,t1 t32, +t1 t33,t1 t34,t1 t35,t1 t36,t1 t37,t1 t38,t1 t39,t1 t40, +t1 t41,t1 t42,t1 t43,t1 t44,t1 t45,t1 t46,t1 t47,t1 t48, +t1 t49,t1 t50,t1 t51,t1 t52,t1 t53,t1 t54,t1 t55,t1 t56, +t1 t57,t1 t58,t1 t59,t1 t60 +WHERE t01.a = v1 AND t01.a IN (SELECT c FROM t2); +END +// +CALL p1(1); +1 +CALL p2(1); +1 +CALL p3(1); +1 +CALL p4(1); +1 +DROP TABLE t1, t2; +DROP PROCEDURE p1; +DROP PROCEDURE p2; +DROP PROCEDURE p3; +DROP PROCEDURE p4; +# +# Bug#48213 Materialized subselect crashes if using GEOMETRY type +# +CREATE TABLE t1 ( +pk int, +a varchar(1), +b varchar(4), +c tinyblob, +d blob, +e mediumblob, +f longblob, +g tinytext, +h text, +i mediumtext, +j longtext, +k geometry, +PRIMARY KEY (pk) +) charset utf8mb4; +INSERT INTO t1 VALUES (1,'o','ffff','ffff','ffoo','ffff','ffff','ffff','ffff','ffff','ffff',ST_GeomFromText('POLYGON((0 0, 0 2, 2 2, 2 0, 0 0))')), (2,'f','ffff','ffff','ffff', 'ffff','ffff','ffff','ffff','ffff','ffff',ST_GeomFromText('POLYGON((0 0, 0 2, 2 2, 2 0, 0 0))')); +CREATE TABLE t2 LIKE t1; +INSERT INTO t2 VALUES (1,'i','iiii','iiii','iiii','iiii','ffff','ffff','ffff','ffff','ffff',ST_GeomFromText('POLYGON((0 0, 0 2, 2 2, 2 0, 0 0))')), (2,'f','ffff','ffff','ffff','ffff','ffff','ffff','ffff','ffff','ffff',ST_GeomFromText('POLYGON((0 0, 0 2, 2 2, 2 0, 0 0))')); +EXPLAIN SELECT pk FROM t1 WHERE (a, b) IN (SELECT a, b FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE NULL eq_ref 26 test.t1.a,test.t1.b 1 100.00 NULL +2 MATERIALIZED t2 NULL range PRIMARY PRIMARY 4 NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((``.`b` = `test`.`t1`.`b`) and (``.`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); +pk +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, c) IN (SELECT b, c FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using where +2 MATERIALIZED t2 NULL range PRIMARY PRIMARY 4 NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((``.`c` = `test`.`t1`.`c`) and (``.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, c) IN (SELECT b, c FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, d) IN (SELECT b, d FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using where +2 MATERIALIZED t2 NULL range PRIMARY PRIMARY 4 NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((``.`d` = `test`.`t1`.`d`) and (``.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, d) IN (SELECT b, d FROM t2 WHERE pk > 0); +pk +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, e) IN (SELECT b, e FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using where +2 MATERIALIZED t2 NULL range PRIMARY PRIMARY 4 NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((``.`e` = `test`.`t1`.`e`) and (``.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, e) IN (SELECT b, e FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, f) IN (SELECT b, f FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using where +2 MATERIALIZED t2 NULL range PRIMARY PRIMARY 4 NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((``.`f` = `test`.`t1`.`f`) and (``.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, f) IN (SELECT b, f FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, g) IN (SELECT b, g FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using where +2 MATERIALIZED t2 NULL range PRIMARY PRIMARY 4 NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((``.`g` = `test`.`t1`.`g`) and (``.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, g) IN (SELECT b, g FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, h) IN (SELECT b, h FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using where +2 MATERIALIZED t2 NULL range PRIMARY PRIMARY 4 NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((``.`h` = `test`.`t1`.`h`) and (``.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, h) IN (SELECT b, h FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, i) IN (SELECT b, i FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using where +2 MATERIALIZED t2 NULL range PRIMARY PRIMARY 4 NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((``.`i` = `test`.`t1`.`i`) and (``.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, i) IN (SELECT b, i FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, j) IN (SELECT b, j FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using where +2 MATERIALIZED t2 NULL range PRIMARY PRIMARY 4 NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((``.`j` = `test`.`t1`.`j`) and (``.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, j) IN (SELECT b, j FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, k) IN (SELECT b, k FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using where +2 MATERIALIZED t2 NULL range PRIMARY PRIMARY 4 NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((``.`k` = `test`.`t1`.`k`) and (``.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, k) IN (SELECT b, k FROM t2 WHERE pk > 0); +pk +1 +2 +DROP TABLE t1, t2; +# End of Bug#48213 +# +# BUG#53060: LooseScan semijoin strategy does not return all rows +# +CREATE TABLE t1 (i INTEGER); +INSERT INTO t1 VALUES (1), (2), (3), (4), (5); +CREATE TABLE t2 (i INTEGER, j INTEGER, KEY k(i, j)); +INSERT INTO t2 VALUES (1, 0), (1, 1), (2, 0), (2, 1); +EXPLAIN +SELECT * FROM t1 WHERE (i) IN (SELECT i FROM t2 where j > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 20.00 Using where +2 MATERIALIZED t2 NULL index k k 10 NULL 4 33.33 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`i` = ``.`i`) and (`test`.`t2`.`j` > 0)) +SELECT * FROM t1 WHERE (i) IN (SELECT i FROM t2 where j > 0); +i +1 +2 +DROP TABLE t1, t2; +# End of BUG#53060 +# +# Bug#53305 "Duplicate weedout + join buffer (join cache --level=7,8) loses rows" +# +create table t1 (uid int, fid int, index(uid)); +insert into t1 values +(1,1), (1,2), (1,3), (1,4), +(2,5), (2,6), (2,7), (2,8), +(3,1), (3,2), (3,9); +create table t2 (uid int primary key, name varchar(128), index(name)); +insert into t2 values +(1, "A"), (2, "B"), (3, "C"), (4, "D"), (5, "E"), +(6, "F"), (7, "G"), (8, "H"), (9, "I"); +create table t3 (uid int, fid int, index(uid)); +insert into t3 values +(1,1), (1,2), (1,3),(1,4), +(2,5), (2,6), (2,7), (2,8), +(3,1), (3,2), (3,9); +create table t4 (uid int primary key, name varchar(128), index(name)); +insert into t4 values +(1, "A"), (2, "B"), (3, "C"), (4, "D"), (5, "E"), +(6, "F"), (7, "G"), (8, "H"), (9, "I"); +explain select name from t2, t1 +where t1.uid in (select t4.uid from t4, t3 where t3.uid=1 and t4.uid=t3.fid) +and t2.uid=t1.fid; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ref uid uid 5 const 4 100.00 Using where; Start temporary +1 SIMPLE t4 NULL eq_ref PRIMARY PRIMARY 4 test.t3.fid 1 100.00 Using index +1 SIMPLE t1 NULL ref uid uid 5 test.t3.fid 2 100.00 Using where; End temporary +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.fid 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`name` AS `name` from `test`.`t4` join `test`.`t2` join `test`.`t1` semi join (`test`.`t3`) where ((`test`.`t4`.`uid` = `test`.`t3`.`fid`) and (`test`.`t1`.`uid` = `test`.`t3`.`fid`) and (`test`.`t3`.`uid` = 1) and (`test`.`t2`.`uid` = `test`.`t1`.`fid`)) +select name from t2, t1 +where t1.uid in (select t4.uid from t4, t3 where t3.uid=1 and t4.uid=t3.fid) +and t2.uid=t1.fid; +name +A +A +B +B +C +D +E +F +G +H +I +drop table t1,t2,t3,t4; +# +# Bug#43768 Prepared query with nested subqueries core dump on second execution +# +CREATE TABLE t1 ( +id INT PRIMARY KEY, +partner_id VARCHAR(35) +) charset utf8mb4; +INSERT INTO t1 VALUES +(1, 'partner1'), (2, 'partner2'), +(3, 'partner3'), (4, 'partner4'); +CREATE TABLE t2 ( +id INT NOT NULL, +t1_line_id INT, +article_id VARCHAR(20), +PRIMARY KEY(id, t1_line_id) +) charset utf8mb4; +INSERT INTO t2 VALUES +(1, 1, 'sup'), (2, 1, 'sup'), +(2, 2, 'sup'), (2, 3, 'sup'), +(2, 4, 'imp'), (3, 1, 'sup'), +(4, 1, 'sup'); +CREATE TABLE t3 ( +user_id VARCHAR(50), +article_id VARCHAR(20) NOT NULL, +PRIMARY KEY(user_id) +) charset utf8mb4; +INSERT INTO t3 VALUES('nicke', 'imp'); +EXPLAIN +SELECT t1.partner_id +FROM t1 +WHERE t1.id IN ( +SELECT t2.id +FROM t2 +WHERE article_id IN ( +SELECT article_id FROM t3 +WHERE user_id = 'nicke' + ) +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL system PRIMARY NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL PRIMARY NULL NULL NULL 7 14.29 Using where; Start temporary +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.id 1 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`partner_id` AS `partner_id` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`id` = `test`.`t2`.`id`) and (`test`.`t2`.`article_id` = 'imp')) +SELECT t1.partner_id +FROM t1 +WHERE t1.id IN ( +SELECT t2.id +FROM t2 +WHERE article_id IN ( +SELECT article_id FROM t3 +WHERE user_id = 'nicke' + ) +); +partner_id +partner2 +PREPARE stmt FROM +'EXPLAIN SELECT t1.partner_id +FROM t1 +WHERE t1.id IN ( + SELECT t2.id + FROM t2 + WHERE article_id IN ( + SELECT article_id FROM t3 + WHERE user_id = \'nicke\' + ) + )'; +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL system PRIMARY NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL PRIMARY NULL NULL NULL 7 14.29 Using where; Start temporary +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.id 1 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`partner_id` AS `partner_id` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`id` = `test`.`t2`.`id`) and (`test`.`t2`.`article_id` = 'imp')) + +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL system PRIMARY NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL PRIMARY NULL NULL NULL 7 14.29 Using where; Start temporary +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.id 1 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`partner_id` AS `partner_id` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`id` = `test`.`t2`.`id`) and (`test`.`t2`.`article_id` = 'imp')) +PREPARE stmt FROM +'SELECT t1.partner_id +FROM t1 +WHERE t1.id IN ( + SELECT t2.id + FROM t2 + WHERE article_id IN ( + SELECT article_id FROM t3 + WHERE user_id = \'nicke\' + ) + )'; +EXECUTE stmt; +partner_id +partner2 + +EXECUTE stmt; +partner_id +partner2 +DROP TABLE t1,t2,t3; +# End of Bug#43768 +# +# Bug#53058 - semijoin execution of subquery with outerjoin yields wrong result +# +CREATE TABLE t1 (i INTEGER); +CREATE TABLE t2 (i INTEGER); +CREATE TABLE t3 (i INTEGER); +INSERT INTO t1 VALUES (1), (2); +INSERT INTO t2 VALUES (6); +INSERT INTO t3 VALUES (1), (2); +explain SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t3 LEFT JOIN t2 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t3 LEFT JOIN t2 ON t2.i=t3.i); +i +1 +2 +drop table t1,t2,t3; +# +# BUG#49453: re-execution of prepared statement with view +# and semijoin crashes +# +CREATE TABLE t1 (city VARCHAR(50), country_id INT); +CREATE TABLE t2 (country_id INT, country VARCHAR(50)); +INSERT INTO t1 VALUES +('Batna',2),('Bchar',2),('Skikda',2),('Tafuna',3),('Algeria',2) ; +INSERT INTO t2 VALUES (2,'Algeria'),(2,'AlgeriaDup'),(3,'XAmerican Samoa'); +CREATE VIEW v1 AS +SELECT country_id as vf_country_id +FROM t2 +WHERE LEFT(country,1) = "A"; +PREPARE stmt FROM " +SELECT city, country_id +FROM t1 +WHERE country_id IN (SELECT vf_country_id FROM v1); +"; + +EXECUTE stmt; +city country_id +Algeria 2 +Batna 2 +Bchar 2 +Skikda 2 + +EXECUTE stmt; +city country_id +Algeria 2 +Batna 2 +Bchar 2 +Skikda 2 +DROP TABLE t1,t2; +DROP VIEW v1; +# +# Bug#54437 Extra rows with LEFT JOIN + semijoin (firstmatch +# and duplicates weedout) +# +create table t1 (a int); +create table t2 (a int); +create table t3 (a int); +insert into t1 values(1),(1); +insert into t2 values(1),(1),(1),(1); +insert into t3 values(2),(2); +explain select * from t1 where t1.a in (select t2.a from t2 left join t3 on t2.a=t3.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE NULL eq_ref 5 test.t1.a 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t2` left join `test`.`t3` on((`test`.`t2`.`a` = `test`.`t3`.`a`))) where (``.`a` = `test`.`t1`.`a`) +select * from t1 where t1.a in (select t2.a from t2 left join t3 on t2.a=t3.a); +a +1 +1 +drop table t1,t2,t3; +# +# Bug#55955: crash in MEMORY engine with IN(LEFT JOIN (JOIN)) +# +CREATE TABLE t1 (a INT); +CREATE TABLE t2 (a INT); +CREATE TABLE t3 (a INT); +INSERT INTO t1 VALUES(1),(1); +INSERT INTO t2 VALUES(1),(1); +INSERT INTO t3 VALUES(2),(2); +explain SELECT * FROM t1 +WHERE t1.a IN (SELECT t2.a +FROM t2 LEFT JOIN (t2 AS t2inner, t3) ON t2.a=t3.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE NULL eq_ref 5 test.t1.a 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t2inner NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t2` left join (`test`.`t2` `t2inner` join `test`.`t3`) on((`test`.`t2`.`a` = `test`.`t3`.`a`))) where (``.`a` = `test`.`t1`.`a`) +SELECT * FROM t1 +WHERE t1.a IN (SELECT t2.a +FROM t2 LEFT JOIN (t2 AS t2inner, t3) ON t2.a=t3.a); +a +1 +1 +DROP TABLE t1,t2,t3; +# +# BUG#52329 - Wrong result: subquery materialization, IN, +# non-null field followed by nullable +# +CREATE TABLE t1 (a1 CHAR(8) NOT NULL, a2 char(8) NOT NULL); +CREATE TABLE t2a (b1 char(8), b2 char(8)); +CREATE TABLE t2b (b1 CHAR(8), b2 char(8) NOT NULL); +CREATE TABLE t2c (b1 CHAR(8) NOT NULL, b2 char(8)); +INSERT INTO t1 VALUES ('1 - 12', '2 - 22'); +INSERT INTO t2a VALUES ('1 - 11', '2 - 21'), +('1 - 11', '2 - 21'), +('1 - 12', '2 - 22'), +('1 - 12', '2 - 22'), +('1 - 13', '2 - 23'); +INSERT INTO t2b SELECT * FROM t2a; +INSERT INTO t2c SELECT * FROM t2a; +SELECT * FROM t1 +WHERE (a1, a2) IN ( +SELECT b1, b2 FROM t2c WHERE b1 > '0' GROUP BY b1, b2); +a1 a2 +1 - 12 2 - 22 +SELECT * FROM t1 +WHERE (a1, a2) IN ( +SELECT b1, b2 FROM t2a WHERE b1 > '0'); +a1 a2 +1 - 12 2 - 22 +SELECT * FROM t1 +WHERE (a1, a2) IN ( +SELECT b1, b2 FROM t2b WHERE b1 > '0'); +a1 a2 +1 - 12 2 - 22 +SELECT * FROM t1 +WHERE (a1, a2) IN ( +SELECT b1, b2 FROM t2c WHERE b1 > '0'); +a1 a2 +1 - 12 2 - 22 +DROP TABLE t1,t2a,t2b,t2c; +# End BUG#52329 +# +# Bug#45174: Incorrectly applied equality propagation caused wrong +# result on a query with a materialized semi-join. +# +CREATE TABLE t1 ( +varchar_nokey varchar(1) NOT NULL +) charset utf8mb4; +INSERT INTO t1 VALUES +('v'), ('u'), ('n'), ('l'), ('h'), ('u'), ('n'), ('j'), ('k'), +('e'), ('i'), ('u'), ('n'), ('b'), ('x'), (''), ('q'), ('u'); +CREATE TABLE t2 ( +pk int NOT NULL, +varchar_key varchar(1) NOT NULL, +varchar_nokey varchar(1) NOT NULL, +PRIMARY KEY(pk), +KEY varchar_key(varchar_key) +) charset utf8mb4; +INSERT INTO t2 VALUES +(11,'m','m'), (12,'j','j'), (13,'z','z'), (14,'a','a'), (15,'',''), +(16,'e','e'), (17,'t','t'), (19,'b','b'), (20,'w','w'), (21,'m','m'), +(23,'',''), (24,'w','w'), (26,'e','e'), (27,'e','e'), (28,'p','p'); +SELECT varchar_nokey +FROM t1 +WHERE (varchar_nokey, varchar_nokey) IN (SELECT varchar_key, varchar_nokey +FROM t2 +WHERE varchar_nokey < 'n' XOR pk); +varchar_nokey +explain SELECT varchar_nokey +FROM t1 +WHERE (varchar_nokey, varchar_nokey) IN (SELECT varchar_key, varchar_nokey +FROM t2 +WHERE varchar_nokey < 'n' XOR pk); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 18 100.00 NULL +1 SIMPLE NULL eq_ref 12 test.t1.varchar_nokey,test.t1.varchar_nokey 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL varchar_key NULL NULL NULL 15 63.34 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`varchar_nokey` AS `varchar_nokey` from `test`.`t1` semi join (`test`.`t2`) where ((``.`varchar_key` = `test`.`t1`.`varchar_nokey`) and (``.`varchar_nokey` = `test`.`t1`.`varchar_nokey`) and (`test`.`t2`.`varchar_nokey` = `test`.`t2`.`varchar_key`) and ((`test`.`t2`.`varchar_nokey` < 'n') xor (0 <> `test`.`t2`.`pk`))) +DROP TABLE t1, t2; +# End of the test for bug#45174. +# +# Bug#50019: Wrong result for IN-query with materialization +# +CREATE TABLE t1(i INT); +INSERT INTO t1 VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10); +CREATE TABLE t2(i INT); +INSERT INTO t2 VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10); +CREATE TABLE t3(i INT); +INSERT INTO t3 VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10); +SELECT * FROM t1 WHERE t1.i IN (SELECT t2.i +FROM t2 JOIN t3 +WHERE t2.i + t3.i = 5); +i +1 +2 +3 +4 +explain SELECT * FROM t1 WHERE t1.i IN (SELECT t2.i +FROM t2 JOIN t3 +WHERE t2.i + t3.i = 5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 100.00 Using where +1 SIMPLE NULL eq_ref 5 test.t1.i 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 10 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 10 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = `test`.`t1`.`i`) and ((`test`.`t2`.`i` + `test`.`t3`.`i`) = 5)) +DROP TABLE t1,t2,t3; +# End of the test for bug#50019. +# +# Bug#52068: Optimizer generates invalid semijoin materialization plan +# +CREATE TABLE ot1(a INTEGER); +INSERT INTO ot1 VALUES(5), (8); +CREATE TABLE it2(a INTEGER); +INSERT INTO it2 VALUES(9), (5), (1), (8); +CREATE TABLE it3(a INTEGER); +INSERT INTO it3 VALUES(7), (1), (0), (5), (1), (4); +CREATE TABLE ot4(a INTEGER); +INSERT INTO ot4 VALUES(1), (3), (5), (7), (9), (7), (3), (1); +SELECT * FROM ot1,ot4 +WHERE (ot1.a,ot4.a) IN (SELECT it2.a,it3.a +FROM it2,it3); +a a +5 1 +5 1 +5 5 +5 7 +5 7 +8 1 +8 1 +8 5 +8 7 +8 7 +explain SELECT * FROM ot1,ot4 +WHERE (ot1.a,ot4.a) IN (SELECT it2.a,it3.a +FROM it2,it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using where +1 SIMPLE ot4 NULL ALL NULL NULL NULL NULL 8 12.50 Using where +2 MATERIALIZED it2 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +2 MATERIALIZED it3 NULL ALL NULL NULL NULL NULL 6 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot4`.`a` AS `a` from `test`.`ot1` join `test`.`ot4` semi join (`test`.`it2` join `test`.`it3`) where ((`test`.`ot4`.`a` = ``.`a`) and (``.`a` = `test`.`ot1`.`a`)) +DROP TABLE IF EXISTS ot1, ot4, it2, it3; +# End of the test for bug#52068. +# +# Bug#57623: subquery within before insert trigger causes crash (sj=on) +# +CREATE TABLE ot1(a INT); +CREATE TABLE ot2(a INT); +CREATE TABLE ot3(a INT); +CREATE TABLE it1(a INT); +INSERT INTO ot1 VALUES(0),(1),(2),(3),(4),(5),(6),(7); +INSERT INTO ot2 VALUES(0),(2),(4),(6); +INSERT INTO ot3 VALUES(0),(3),(6); +INSERT INTO it1 VALUES(0),(1),(2),(3),(4),(5),(6),(7); +explain SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 on ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a from it1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +1 SIMPLE NULL eq_ref 5 test.ot1.a 1 100.00 NULL +1 SIMPLE ot3 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +2 MATERIALIZED it1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a`,`test`.`ot3`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` join `test`.`ot3` semi join (`test`.`it1`)) on(((``.`a` = `test`.`ot1`.`a`) and (`test`.`ot3`.`a` = `test`.`ot1`.`a`) and (`test`.`ot2`.`a` = `test`.`ot1`.`a`))) where true +SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 on ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a from it1); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +prepare s from 'SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 on ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a from it1)'; +execute s; +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +execute s; +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +deallocate prepare s; +DROP TABLE ot1, ot2, ot3, it1; +# End of the test for bug#57623. +# +# Bug#11766739: Crash in tmp_table_param::init() with semijoin=on +# +CREATE TABLE t1 (f1 INTEGER) ENGINE=MyISAM; +CREATE TABLE t2 (f1 INTEGER, f2 INTEGER) ENGINE=MyISAM; +INSERT INTO t1 VALUES (1); +INSERT INTO t2 VALUES (1,1), (2,1); +EXPLAIN SELECT * FROM t2 +WHERE f2 IN (SELECT t1.f1 +FROM t1 LEFT OUTER JOIN (t2 AS b1 JOIN t2 AS b2 ON TRUE) ON TRUE); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 MATERIALIZED t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 MATERIALIZED b1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +2 MATERIALIZED b2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`f1` AS `f1`,`test`.`t2`.`f2` AS `f2` from `test`.`t2` semi join (`test`.`t1` left join (`test`.`t2` `b1` join `test`.`t2` `b2`) on((true))) where (`test`.`t2`.`f2` = ``.`f1`) +SELECT * FROM t2 +WHERE f2 IN (SELECT t1.f1 +FROM t1 LEFT OUTER JOIN (t2 AS b1 JOIN t2 AS b2 ON TRUE) ON TRUE); +f1 f2 +1 1 +2 1 +DROP TABLE t1, t2; +# End of the test for bug#11766739. +# +# Bug#11766642: crash in Item_field::register_field_in_read_map with view +# +CREATE TABLE t1(a INT); +CREATE VIEW v1 AS SELECT a FROM t1; +INSERT INTO t1 VALUES (0),(1),(2); +SELECT a FROM t1 WHERE a IN +(SELECT a XOR a FROM v1) +ORDER BY a; +a +0 +DROP TABLE t1; +DROP VIEW v1; +# +# Bug#12546542 MISSING ROW WHEN USING OPTIMIZER_JOIN_CACHE_LEVEL>=3 +# +CREATE TABLE t1 ( +f2 varchar(1024) +); +INSERT INTO t1 VALUES ('v'),('we'); +CREATE TABLE t2 ( +col_varchar_1024_utf8 varchar(1024) CHARACTER SET utf8 DEFAULT NULL, +col_int_key int, +col_int int +); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t2 VALUES ('we',4,NULL),('v',1305673728,6); +CREATE TABLE t3 ( +col_int_key int, +col_int int +); +INSERT INTO t3 VALUES (4,4); +SELECT * +FROM t1 +WHERE f2 IN (SELECT a1.col_varchar_1024_utf8 AS f2 +FROM t2 AS a1 LEFT JOIN t3 AS a2 +ON a1.col_int_key = a2.col_int_key +WHERE a1.col_int BETWEEN 1 AND 10 OR a2.col_int IS NOT NULL); +f2 +v +we +DROP TABLE t1,t2,t3; +# +# BUG#12616344 - JCL: DIFFERENT RESULT SET AND DIFFERENT AMOUNT +# OF ROWS WHEN JCL>=3 +# +CREATE TABLE t1 (col_int_nokey int, col_int_key int, col_varchar_key varchar(1)); +INSERT INTO t1 VALUES (0,4,'c'),(1,6,'u'); +CREATE TABLE t2 (pk int, col_int_nokey int, col_varchar_nokey varchar(1)); +INSERT INTO t2 VALUES (1,4,'b'),(94,6,'u'); +CREATE TABLE t3 (pk int, col_int_nokey int, col_varchar_key varchar(1)); +INSERT INTO t3 VALUES (1,4,'j'),(2,6,'v'); +SELECT table2.col_int_key +from t3 as table1 join t1 as table2 on table2.col_int_nokey +where table1.col_int_nokey in +( +select subquery2_t2.col_int_nokey +from t3 as subquery2_t1 +right join +t2 as subquery2_t2 +join t1 as subquery2_t3 +on subquery2_t3.col_int_key = subquery2_t2.col_int_nokey +on subquery2_t3.col_varchar_key = subquery2_t2.col_varchar_nokey +where subquery2_t1.col_varchar_key != table1.col_varchar_key +or subquery2_t2.pk <= table1.pk +); +col_int_key +6 +6 +DROP TABLE t1,t2,t3; +# +# Bug#12608157: ASSERT IN FIELD_LONG::VAL_INT WHEN USING MEMORY ENGINE +# +CREATE TABLE t1 (i1 int); +INSERT INTO t1 VALUES (1); +CREATE TABLE t2 (i1 int, i2 int) ENGINE=memory; +INSERT INTO t2 VALUES (1, 2),(7, 3); +SELECT GRANDPARENT1.i1 +FROM t2 AS GRANDPARENT1 +WHERE GRANDPARENT1.i2 +IN ( SELECT PARENT1.i2 +FROM t2 AS PARENT1 JOIN t1 AS PARENT2 ON (PARENT1.i1 = PARENT2.i1) +WHERE +GRANDPARENT1.i1 IN ( SELECT CHILD1.i1 FROM t2 AS CHILD1 ) +ORDER BY PARENT1.i1) +ORDER BY GRANDPARENT1.i2 ; +i1 +1 +DROP TABLE t1,t2; +# +# Bug#12640083: Same query executed as WHERE subquery gives different +# results on IN() compare +# +CREATE TABLE t1 ( +pk int NOT NULL, +col_varchar_1024_utf8_key varchar(1024) CHARACTER SET utf8 DEFAULT NULL, +col_varchar_10_latin1_key varchar(10) DEFAULT NULL, +PRIMARY KEY (pk), +KEY col_varchar_1024_utf8_key(col_varchar_1024_utf8_key(333)), +KEY col_varchar_10_latin1_key(col_varchar_10_latin1_key) +) charset utf8mb4; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES +(1, 'a', 'a'), +(2, 'ab', 'ab'), +(3, 'abc', 'abc'), +(4, 'abcd', 'abcd'); +CREATE TABLE t2 ( +pk int NOT NULL AUTO_INCREMENT, +PRIMARY KEY (pk) +) charset utf8mb4 ENGINE=Innodb; +CREATE TABLE t3 charset utf8mb4 +SELECT alias1.col_varchar_10_latin1_key +FROM t1 AS alias1 +LEFT JOIN t1 AS alias2 +JOIN t2 AS alias3 +ON alias2.col_varchar_10_latin1_key +ON alias1.col_varchar_1024_utf8_key +WHERE alias1.pk AND alias1.pk < 3 OR alias1.pk AND alias3.pk; +EXPLAIN SELECT * +FROM t3 +WHERE col_varchar_10_latin1_key IN ( +SELECT alias1.col_varchar_10_latin1_key +FROM t1 AS alias1 +LEFT JOIN t1 AS alias2 +JOIN t2 AS alias3 +ON alias2.col_varchar_10_latin1_key +ON alias1.col_varchar_1024_utf8_key +WHERE alias1.pk AND alias1.pk < 3 OR alias1.pk AND alias3.pk); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE NULL eq_ref 43 test.t3.col_varchar_10_latin1_key 1 100.00 NULL +2 MATERIALIZED alias1 NULL range PRIMARY,col_varchar_10_latin1_key PRIMARY 4 NULL 5 100.00 Using where +2 MATERIALIZED alias3 NULL index NULL PRIMARY 4 NULL 1 100.00 Using where; Using index +2 MATERIALIZED alias2 NULL index NULL col_varchar_10_latin1_key 43 NULL 4 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`col_varchar_10_latin1_key` AS `col_varchar_10_latin1_key` from `test`.`t3` semi join (`test`.`t1` `alias1` left join (`test`.`t1` `alias2` join `test`.`t2` `alias3`) on(((0 <> `test`.`alias1`.`col_varchar_1024_utf8_key`) and (0 <> `test`.`alias2`.`col_varchar_10_latin1_key`)))) where ((``.`col_varchar_10_latin1_key` = `test`.`t3`.`col_varchar_10_latin1_key`) and (((0 <> `test`.`alias1`.`pk`) and (`test`.`alias1`.`pk` < 3)) or ((0 <> `test`.`alias1`.`pk`) and (0 <> `test`.`alias3`.`pk`)))) +SELECT * +FROM t3 +WHERE col_varchar_10_latin1_key IN ( +SELECT alias1.col_varchar_10_latin1_key +FROM t1 AS alias1 +LEFT JOIN t1 AS alias2 +JOIN t2 AS alias3 +ON alias2.col_varchar_10_latin1_key +ON alias1.col_varchar_1024_utf8_key +WHERE alias1.pk AND alias1.pk < 3 OR alias1.pk AND alias3.pk); +col_varchar_10_latin1_key +a +ab +DROP TABLE t1, t2, t3; +# End of the test for bug#12640083. +# +# Bug#12603200 - Assert in QUICK_INDEX_MERGE_SELECT::need_sorted_output +# +CREATE TABLE t1 ( +pk int NOT NULL, +col_int_key int NOT NULL, +col_varchar_nokey varchar(1) NOT NULL, +col_varchar_key varchar(1) NOT NULL, +PRIMARY KEY(pk), +KEY col_int_key(col_int_key), +KEY col_varchar_key(col_varchar_key, col_int_key) +) charset utf8mb4 engine=innodb; +INSERT INTO t1 VALUES +(1,7,'a','a'), +(2,0,'v','v'), +(3,9,'c','c'), +(4,3,'m','m'), +(5,2,'a','a'), +(6,1,'d','d'), +(7,8,'y','y'), +(8,6,'t','t'), +(11,7,'a','x'), +(12,0,'v','v'), +(13,9,'c','c'), +(14,3,'m','m'), +(15,2,'a','x'), +(16,1,'d','d'), +(17,8,'y','y'), +(18,6,'t','u'), +(19,6,'t','u'); +CREATE TABLE t2 ( +pk int NOT NULL, +col_int_key int NOT NULL, +col_varchar_key varchar(1) NOT NULL, +PRIMARY KEY(pk), +KEY col_varchar_key(col_varchar_key, col_int_key) +) charset utf8mb4 engine=innodb; +INSERT INTO t2(pk,col_int_key,col_varchar_key) VALUES +(8,7,'c'), +(11,4,'l'), +(12,7,'b'), +(13,0,'c'), +(14,2,'i'), +(15,9,'h'), +(16,4,'q'), +(17,1,'m'), +(18,9,'b'), +(19,2,'e'), +(20,1,'c'), +(21,7,'z'), +(22,4,'l'), +(23,7,'z'), +(24,0,'c'), +(25,2,'i'), +(26,9,'h'), +(27,4,'q'), +(28,0,'a'), +(29,1,'d'); +EXPLAIN SELECT outr.col_varchar_key AS x, outr.pk AS y +FROM t1 AS outr +WHERE outr.col_varchar_key IN (SELECT innr.col_varchar_key +FROM t2 AS innr +WHERE innr.col_varchar_key = 'a' OR innr.pk = 8) +AND outr.col_varchar_nokey < 't' +ORDER BY outr.col_varchar_key, outr.pk; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using temporary; Using filesort +1 SIMPLE outr NULL ref col_varchar_key col_varchar_key 6 .col_varchar_key 1 33.33 Using where +2 MATERIALIZED innr NULL index_merge PRIMARY,col_varchar_key col_varchar_key,PRIMARY 6,4 NULL 2 100.00 Using sort_union(col_varchar_key,PRIMARY); Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`outr`.`col_varchar_key` AS `x`,`test`.`outr`.`pk` AS `y` from `test`.`t1` `outr` semi join (`test`.`t2` `innr`) where ((`test`.`outr`.`col_varchar_key` = ``.`col_varchar_key`) and (`test`.`outr`.`col_varchar_nokey` < 't') and (((``.`col_varchar_key` = 'a') and (`test`.`innr`.`col_varchar_key` = 'a')) or (`test`.`innr`.`pk` = 8))) order by `test`.`outr`.`col_varchar_key`,`test`.`outr`.`pk` +SELECT outr.col_varchar_key AS x, outr.pk AS y +FROM t1 AS outr +WHERE outr.col_varchar_key IN (SELECT innr.col_varchar_key +FROM t2 AS innr +WHERE innr.col_varchar_key = 'a' OR innr.pk = 8) +AND outr.col_varchar_nokey < 't' +ORDER BY outr.col_varchar_key, outr.pk; +x y +a 1 +a 5 +c 3 +c 13 +DROP TABLE t1, t2; +# End of bug#12603200 +# +# Bug#12603183: Segfault in hp_movelink +# +CREATE TABLE t1 ( +col_varchar_key varchar(1) , +col_varchar_nokey varchar(1) , +KEY col_varchar_key(col_varchar_key) +) charset latin1; +INSERT INTO t1 VALUES +('i','i'), +('h','h'), +('q','q'), +('a','a'), +('v','v'), +('u','u'), +('s','s'), +('y','y'), +('z','z'), +('h','h'), +('p','p'), +('e','e'), +('i','i'), +('y','y'), +('w','w'); +CREATE TABLE t2 ( +col_varchar_nokey varchar(1) +) charset latin1; +INSERT INTO t2 VALUES +('b'); +EXPLAIN SELECT grandparent1.col_varchar_nokey +FROM t1 AS grandparent1 LEFT JOIN t2 AS grandparent2 USING (col_varchar_nokey) +WHERE (grandparent1.col_varchar_key) IN +(SELECT parent1.col_varchar_nokey +FROM t1 AS parent1 +WHERE parent1.col_varchar_key IN +(SELECT child1.col_varchar_nokey AS c1 +FROM t1 AS child1 LEFT JOIN t2 AS child2 +ON (child1.col_varchar_key > child2.col_varchar_nokey))); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using where +1 SIMPLE grandparent1 NULL ref col_varchar_key col_varchar_key 4 .col_varchar_nokey 2 100.00 NULL +1 SIMPLE grandparent2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 MATERIALIZED child1 NULL ALL NULL NULL NULL NULL 15 100.00 Using where +2 MATERIALIZED child2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 MATERIALIZED parent1 NULL ref col_varchar_key col_varchar_key 4 test.child1.col_varchar_nokey 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`grandparent1`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t1` `grandparent1` left join `test`.`t2` `grandparent2` on((`test`.`grandparent2`.`col_varchar_nokey` = `test`.`grandparent1`.`col_varchar_nokey`)) semi join (`test`.`t1` `parent1` join `test`.`t1` `child1` left join `test`.`t2` `child2` on((`test`.`child1`.`col_varchar_key` > `test`.`child2`.`col_varchar_nokey`))) where ((`test`.`grandparent1`.`col_varchar_key` = ``.`col_varchar_nokey`) and (`test`.`parent1`.`col_varchar_key` = `test`.`child1`.`col_varchar_nokey`)) +SELECT grandparent1.col_varchar_nokey +FROM t1 AS grandparent1 LEFT JOIN t2 AS grandparent2 USING (col_varchar_nokey) +WHERE (grandparent1.col_varchar_key) IN +(SELECT parent1.col_varchar_nokey +FROM t1 AS parent1 +WHERE parent1.col_varchar_key IN +(SELECT child1.col_varchar_nokey AS c1 +FROM t1 AS child1 LEFT JOIN t2 AS child2 +ON (child1.col_varchar_key > child2.col_varchar_nokey))); +col_varchar_nokey +a +e +h +h +i +i +p +q +s +u +v +w +y +y +z +DROP TABLE t1, t2; +# End of test for bug#12603183. +# +# Bug#12818569: Diff nr of rows returned when using IN/ALL+subquery +# +CREATE TABLE t1 ( +col_int_key INT NOT NULL, +col_datetime_key DATETIME NOT NULL, +col_varchar_key VARCHAR(1) NOT NULL, +KEY col_int_key (col_int_key), +KEY col_datetime_key(col_datetime_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t1 VALUES +(7,'2004-06-06 04:22:12','v'), (0,'2005-11-13 01:12:31','s'), +(9,'2002-05-04 01:50:00','l'), (3,'2004-10-27 10:28:45','y'), +(4,'2006-07-22 05:24:23','c'), (2,'2002-05-16 21:34:03','i'), +(5,'2008-04-17 10:45:30','h'), (3,'2009-04-21 02:58:02','q'), +(1,'2008-01-11 11:01:51','a'), (3,'1900-01-01 00:00:00','v'), +(6,'2007-05-17 18:24:57','u'), (7,'2007-08-07 00:00:00','s'), +(5,'2001-08-28 00:00:00','y'), (1,'2004-04-16 00:27:28','z'), +(204,'2005-05-03 07:06:22','h'), (224,'2009-03-11 17:09:50','p'), +(9,'2007-12-08 01:54:28','e'), (5,'2009-07-28 18:19:54','i'), +(0,'2008-06-08 00:00:00','y'), (3,'2005-02-09 09:20:26','w'); +CREATE TABLE t2 ( +col_varchar_nokey VARCHAR(1) NOT NULL +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t2 VALUES ('v'), ('y'), ('j'), ('c'), ('d'), ('r'); +explain SELECT col_varchar_key +FROM t1 +WHERE col_varchar_key IN (SELECT col_varchar_nokey +FROM t2) +ORDER BY col_datetime_key LIMIT 4; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL col_varchar_key NULL NULL NULL 20 100.00 Using filesort +1 SIMPLE NULL eq_ref 6 test.t1.col_varchar_key 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 6 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col_varchar_key` AS `col_varchar_key` from `test`.`t1` semi join (`test`.`t2`) where (``.`col_varchar_nokey` = `test`.`t1`.`col_varchar_key`) order by `test`.`t1`.`col_datetime_key` limit 4 +SELECT col_varchar_key +FROM t1 +WHERE col_varchar_key IN (SELECT col_varchar_nokey +FROM t2) +ORDER BY col_datetime_key LIMIT 4; +col_varchar_key +v +y +v +y +DROP TABLE t1, t2; +# End of test for bug#12818569. +# +# Bug#12803439: Assert in replace_subcondition() on update query +# +CREATE TABLE t1(a INTEGER); +INSERT INTO t1 values(1), (2); +CREATE TABLE t2(a INTEGER); +INSERT INTO t2 VALUES(1), (3); +SELECT * +FROM t1 +WHERE a IN (SELECT a +FROM t2 +HAVING a IN (SELECT a +FROM t2) +) +HAVING a IN (SELECT a +FROM t2); +a +1 +DROP TABLE t1, t2; +# End of test for bug#12803439. +# +# Bug#12797534: Segfault in hp_movelink still exists +# +CREATE TABLE t1 ( +g1 VARCHAR(1) NOT NULL +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t1 VALUES ('d'), ('s'); +CREATE TABLE t2 ( +pk INT NOT NULL, +col_int_key INT NOT NULL, +col_varchar_key VARCHAR(1) NOT NULL, +col_varchar_nokey VARCHAR(1) NOT NULL, +PRIMARY KEY (pk), +KEY col_varchar_key(col_varchar_key, col_int_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t2 VALUES +(1,4,'j','j'), (2,6,'v','v'), (3,3,'c','c'), (4,5,'m','m'), +(5,3,'d','d'), (6,246,'d','d'), (7,2,'y','y'), (8,9,'t','t'), +(9,3,'d','d'), (10,8,'s','s'), (11,1,'r','r'), (12,8,'m','m'), +(13,8,'b','b'), (14,5,'x','x'), (15,7,'g','g'), (16,5,'p','p'), +(17,1,'q','q'), (18,6,'w','w'), (19,2,'d','d'), (20,9,'e','e'); +CREATE TABLE t3 ( +pk INTEGER NOT NULL, +PRIMARY KEY (pk) +) ENGINE=InnoDB; +INSERT INTO t3 VALUES (10); +EXPLAIN SELECT * +FROM t1 +WHERE g1 NOT IN +(SELECT grandparent1.col_varchar_nokey AS g1 +FROM t2 AS grandparent1 +WHERE grandparent1.col_varchar_key IN +(SELECT parent1.col_varchar_nokey AS p1 +FROM t2 AS parent1 LEFT JOIN t3 AS parent2 USING (pk) +) +AND grandparent1.col_varchar_key IS NOT NULL +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE NULL eq_ref 7 test.t1.g1 1 100.00 Using where; Not exists +2 MATERIALIZED parent1 NULL ALL NULL NULL NULL NULL 20 100.00 NULL +2 MATERIALIZED parent2 NULL eq_ref PRIMARY PRIMARY 4 test.parent1.pk 1 100.00 Using index +2 MATERIALIZED grandparent1 NULL ref col_varchar_key col_varchar_key 6 test.parent1.col_varchar_nokey 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`g1` AS `g1` from `test`.`t1` anti join (`test`.`t2` `grandparent1` join `test`.`t2` `parent1` left join `test`.`t3` `parent2` on((`test`.`parent2`.`pk` = `test`.`parent1`.`pk`))) on(((``.`g1` = `test`.`t1`.`g1`) and (`test`.`grandparent1`.`col_varchar_key` = `test`.`parent1`.`col_varchar_nokey`) and (`test`.`grandparent1`.`col_varchar_key` is not null))) where true +SELECT * +FROM t1 +WHERE g1 NOT IN +(SELECT grandparent1.col_varchar_nokey AS g1 +FROM t2 AS grandparent1 +WHERE grandparent1.col_varchar_key IN +(SELECT parent1.col_varchar_nokey AS p1 +FROM t2 AS parent1 LEFT JOIN t3 AS parent2 USING (pk) +) +AND grandparent1.col_varchar_key IS NOT NULL +); +g1 +DROP TABLE t1, t2, t3; +CREATE TABLE t1 ( +pk INTEGER AUTO_INCREMENT, +col_int_key INTEGER , +col_varchar_key VARCHAR(1) , +col_varchar_nokey VARCHAR(1) , +PRIMARY KEY (pk), +KEY (col_varchar_key,col_int_key) +) ENGINE=INNODB; +INSERT INTO t1 (col_int_key,col_varchar_key,col_varchar_nokey) VALUES +(0,'x','x'), (1,'j','j'), (1,'r','r'), (9,'v','v'), (5,'r','r'); +CREATE TABLE t2 ( +pk INTEGER AUTO_INCREMENT, +col_int_key INTEGER , +col_varchar_key VARCHAR(1) , +col_varchar_nokey VARCHAR(1) , +PRIMARY KEY (pk), +KEY (col_int_key), +KEY (col_varchar_key,col_int_key) +) AUTO_INCREMENT=10 ENGINE=INNODB; +INSERT INTO t2 (col_int_key, col_varchar_key, col_varchar_nokey) VALUES +(NULL,'x','x'), (NULL,'j','j'), (8,'c','c'); +CREATE TABLE t3 +SELECT outr.col_varchar_nokey AS x +FROM t1 AS outr +WHERE outr.col_varchar_nokey IN +(SELECT innr.col_varchar_nokey AS y +FROM t2 AS innr +WHERE innr.col_int_key IS NULL) +AND outr.col_varchar_nokey IS NOT NULL +AND NOT col_varchar_key IS NULL; +SELECT * +FROM t3 +WHERE x NOT IN +(SELECT outr.col_varchar_nokey AS x +FROM t1 AS outr +WHERE outr.col_varchar_nokey IN +(SELECT innr.col_varchar_nokey AS y +FROM t2 AS innr +WHERE innr.col_int_key IS NULL) +AND outr.col_varchar_nokey IS NOT NULL +AND NOT col_varchar_key IS NULL); +x +DROP TABLE t1, t2, t3; +# End of test for bug#12797534. +# +# Bug#12714094: Assert in optimize_semijoin_nests() +# +CREATE TABLE it ( +pk int NOT NULL, +col_varchar VARCHAR(10) DEFAULT NULL, +PRIMARY KEY (pk) +) ENGINE=MyISAM; +INSERT INTO it VALUES (1, 'g'); +CREATE TABLE ot +SELECT alias1.pk AS field1 +FROM it AS alias1 +LEFT JOIN it AS alias2 +ON alias1.col_varchar = alias2.col_varchar +; +SELECT * +FROM ot +WHERE field1 IN ( +SELECT alias1.pk +FROM it AS alias1 +LEFT JOIN it AS alias2 +ON alias1.col_varchar = alias2.col_varchar +); +field1 +1 +DROP TABLE it, ot; +# End of test for bug#12714094 +# +# Bug#12867557: Valgrind: conditional jump/move at key_cmp +# +CREATE TABLE t1 ( +pk INTEGER AUTO_INCREMENT, +col_int_key INTEGER, +PRIMARY KEY (pk), +KEY (col_int_key) +) AUTO_INCREMENT=10; +INSERT INTO t1 (col_int_key) VALUES (8); +CREATE TABLE t2 ( +pk INTEGER AUTO_INCREMENT, +col_int_key INTEGER, +col_time_key TIME, +PRIMARY KEY (pk), +KEY (col_int_key), +KEY (col_time_key) +) AUTO_INCREMENT=10; +INSERT INTO t2 (col_int_key, col_time_key) +VALUES +(8, '22:55:23.019225'), (7, '10:19:31.050677'), (1, '14:40:36.038608'), +(7, '04:37:47.062416'), (9, '19:34:06.054514'), (NULL,'20:35:33.022996'), +(1, NULL), (9, '14:43:37.057393'), (2, '02:23:09.043438'), +(9, '01:22:45.041064'), (2, '00:00:00'), (4, '00:13:25.038482'), +(0, '03:47:16.042671'), (4, '01:41:48.007423'), (8, '00:00:00'), +(NULL, '22:32:04.047407'), (NULL, '16:44:14.028443'), (0, '17:38:37.059754'), +(NULL, '08:46:48.042388'), (8, '14:11:27.044095'); +CREATE TABLE t0 +SELECT DISTINCT grandparent1.col_time_key AS g1 +FROM t2 AS grandparent1 +WHERE grandparent1.col_int_key IN +(SELECT parent1.col_int_key AS p1 +FROM t1 AS parent1) +AND grandparent1.pk > 9; +UPDATE t0 +SET g1 = g1 +WHERE g1 IN +(SELECT grandparent1.col_time_key AS g1 +FROM t2 AS grandparent1 +WHERE grandparent1.col_int_key IN +(SELECT parent1.col_int_key AS p1 +FROM t1 AS parent1) +AND grandparent1.pk > 9); +DROP TABLE t0, t1, t2; +# End of test for bug#12867557 +# +# Bug#12711441: crash in fix_after_pullout +# +CREATE TABLE t1 ( +pk int NOT NULL, +col_int_nokey int DEFAULT NULL, +col_int_key int DEFAULT NULL, +col_time_key time DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +PRIMARY KEY (pk) +); +CREATE VIEW v1 AS SELECT * FROM t1; +CREATE TABLE t2 ( +col_int_key int DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +KEY col_varchar_key(col_varchar_key, col_int_key) +); +CREATE TABLE t3 ( +pk int NOT NULL, +col_int_key INT DEFAULT NULL, +PRIMARY KEY (pk) +); +CREATE TABLE t4 ( +col_int_nokey INT DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +KEY col_varchar_key(col_varchar_key) +); +CREATE TABLE ts +SELECT alias1.col_time_key AS field1 +FROM v1 AS alias1 +RIGHT JOIN t3 AS alias2 +ON alias2.col_int_key = alias1.col_int_nokey +WHERE alias1.pk >= SOME( +SELECT SQ1_alias1.pk AS SQ1_field1 +FROM t3 AS SQ1_alias1 +INNER JOIN (t2 AS SQ1_alias2 +INNER JOIN t4 AS SQ1_alias3 +ON SQ1_alias3.col_varchar_key = SQ1_alias2.col_varchar_nokey) +ON SQ1_alias3.col_int_nokey = SQ1_alias2.col_int_key +WHERE SQ1_alias2.col_varchar_key <= alias1.col_varchar_key +AND SQ1_alias3.col_varchar_nokey <> alias1.col_varchar_key) +; +SELECT * FROM ts WHERE field1 IN ( +SELECT alias1.col_time_key AS field1 +FROM v1 AS alias1 +RIGHT JOIN t3 AS alias2 +ON alias2.col_int_key = alias1.col_int_nokey +WHERE alias1.pk >= SOME( +SELECT SQ1_alias1.pk AS SQ1_field1 +FROM t3 AS SQ1_alias1 +INNER JOIN (t2 AS SQ1_alias2 +INNER JOIN t4 AS SQ1_alias3 +ON SQ1_alias3.col_varchar_key = SQ1_alias2.col_varchar_nokey) +ON SQ1_alias3.col_int_nokey = SQ1_alias2.col_int_key +WHERE SQ1_alias2.col_varchar_key <= alias1.col_varchar_key +AND SQ1_alias3.col_varchar_nokey <> alias1.col_varchar_key) +); +field1 +DROP TABLE t1, t2, t3, t4, ts; +DROP VIEW v1; +# End of test for bug#12711441. +# +# Bug#12664936: Same query executed as where subquery ... +# +CREATE TABLE t1 ( +col_varchar_key VARCHAR(1), +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4; +INSERT INTO t1 VALUES +('o'), ('w'), ('m'), ('q'), +('f'), ('p'), ('j'), ('c'); +CREATE TABLE t2 ( +col_int_nokey INTEGER, +col_int_key INTEGER, +col_varchar_key varchar(1), +KEY col_int_key (col_int_key) +) charset utf8mb4; +INSERT INTO t2 VALUES +(8,5,'u'),(4,5,'p'),(8,1,'o'),(NULL,7,'v'), +(1,2,'g'),(2,1,'q'),(NULL,7,'l'),(3,1,'n'); +CREATE TABLE t4 +SELECT t2.col_int_nokey, t2.col_varchar_key +FROM t1 JOIN t2 ON t2.col_varchar_key = t1.col_varchar_key +WHERE t2.col_int_key = 1; +EXPLAIN SELECT * +FROM t4 +WHERE (col_int_nokey, col_varchar_key) IN +(SELECT t2.col_int_nokey, t2.col_varchar_key +FROM t1 JOIN t2 ON t2.col_varchar_key = t1.col_varchar_key +WHERE t2.col_int_key = 1 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t4 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE NULL eq_ref 12 test.t4.col_int_nokey,test.t4.col_varchar_key 1 100.00 NULL +2 MATERIALIZED t2 NULL ref col_int_key col_int_key 5 const 3 100.00 Using where +2 MATERIALIZED t1 NULL ref col_varchar_key col_varchar_key 7 test.t2.col_varchar_key 2 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`col_int_nokey` AS `col_int_nokey`,`test`.`t4`.`col_varchar_key` AS `col_varchar_key` from `test`.`t4` semi join (`test`.`t1` join `test`.`t2`) where ((``.`col_varchar_key` = `test`.`t4`.`col_varchar_key`) and (`test`.`t1`.`col_varchar_key` = `test`.`t2`.`col_varchar_key`) and (``.`col_int_nokey` = `test`.`t4`.`col_int_nokey`) and (`test`.`t2`.`col_int_key` = 1)) +SELECT * +FROM t4 +WHERE (col_int_nokey, col_varchar_key) IN +(SELECT t2.col_int_nokey, t2.col_varchar_key +FROM t1 JOIN t2 ON t2.col_varchar_key = t1.col_varchar_key +WHERE t2.col_int_key = 1 +); +col_int_nokey col_varchar_key +8 o +2 q +DROP TABLE t1, t2, t4; +# End of test for bug#12664936. +# +# Bug#13340270: assertion table->sort.record_pointers == __null +# +CREATE TABLE t1 ( +pk int NOT NULL, +col_int_key int DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key, col_int_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t1 VALUES +(10,8,'x','x'), +(11,7,'d','d'), +(12,1,'r','r'), +(13,7,'f','f'), +(14,9,'y','y'), +(15,NULL,'u','u'), +(16,1,'m','m'), +(17,9,NULL,NULL), +(18,2,'o','o'), +(19,9,'w','w'), +(20,2,'m','m'), +(21,4,'q','q'); +CREATE TABLE t2 +SELECT alias1.col_varchar_nokey AS field1 +FROM t1 AS alias1 JOIN t1 AS alias2 +ON alias2.col_int_key = alias1.pk OR +alias2.col_int_key = alias1.col_int_key +WHERE alias1.pk = 58 OR alias1.col_varchar_key = 'o' + +; +EXPLAIN SELECT * +FROM t2 +WHERE (field1) IN (SELECT alias1.col_varchar_nokey AS field1 +FROM t1 AS alias1 JOIN t1 AS alias2 +ON alias2.col_int_key = alias1.pk OR +alias2.col_int_key = alias1.col_int_key +WHERE alias1.pk = 58 OR alias1.col_varchar_key = 'o' +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE NULL eq_ref 7 test.t2.field1 1 100.00 NULL +2 MATERIALIZED alias1 NULL index_merge PRIMARY,col_int_key,col_varchar_key col_varchar_key,PRIMARY 7,4 NULL 2 100.00 Using sort_union(col_varchar_key,PRIMARY); Using where +2 MATERIALIZED alias2 NULL ALL col_int_key NULL NULL NULL 12 19.00 Range checked for each record (index map: 0x2) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`field1` AS `field1` from `test`.`t2` semi join (`test`.`t1` `alias1` join `test`.`t1` `alias2`) where ((``.`field1` = `test`.`t2`.`field1`) and ((`test`.`alias1`.`pk` = 58) or (`test`.`alias1`.`col_varchar_key` = 'o')) and ((`test`.`alias2`.`col_int_key` = `test`.`alias1`.`pk`) or (`test`.`alias2`.`col_int_key` = `test`.`alias1`.`col_int_key`))) +SELECT * +FROM t2 +WHERE (field1) IN (SELECT alias1.col_varchar_nokey AS field1 +FROM t1 AS alias1 JOIN t1 AS alias2 +ON alias2.col_int_key = alias1.pk OR +alias2.col_int_key = alias1.col_int_key +WHERE alias1.pk = 58 OR alias1.col_varchar_key = 'o' +); +field1 +o +o +DROP TABLE t1, t2; +# End of test for bug#13340270. +# +# Bug#13335319: Seg fault when analyzing FirstMatch semi-join strategy +# +CREATE TABLE ot1(a INTEGER); +INSERT INTO ot1 VALUES(1), (2), (3); +CREATE TABLE ot2(a INTEGER); +INSERT INTO ot2 VALUES(1), (2), (4), (6), (8), (10); +CREATE TABLE it1(a INTEGER); +INSERT INTO it1 VALUES(1), (3), (5), (7); +CREATE TABLE it2(a INTEGER); +INSERT INTO it2 VALUES(1), (3), (5), (7), (9); +explain SELECT ot1.a, ot2.a +FROM ot1, ot2 +WHERE ot1.a IN (SELECT a FROM it1) AND +ot2.a IN (SELECT a FROM it2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE NULL eq_ref 5 test.ot1.a 1 100.00 NULL +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where +2 MATERIALIZED it1 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +3 MATERIALIZED it2 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` join `test`.`ot2` semi join (`test`.`it1`) semi join (`test`.`it2`) where ((`test`.`ot2`.`a` = ``.`a`) and (``.`a` = `test`.`ot1`.`a`)) +SELECT ot1.a, ot2.a +FROM ot1, ot2 +WHERE ot1.a IN (SELECT a FROM it1) AND +ot2.a IN (SELECT a FROM it2); +a a +1 1 +3 1 +DROP TABLE ot1, ot2, it1, it2; +# End of test for bug#13335319. +# +# Bug#13334882: Assertion keypart_map failed in MyIsam function +# +CREATE TABLE t1 ( +pk int NOT NULL, +col_int_nokey INT NOT NULL, +col_int_key INT NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +) ENGINE=MyISAM; +INSERT INTO t1 VALUES +(1,4,0), +(2,6,8), +(3,3,1), +(7,2,6), +(8,9,1), +(9,3,6), +(10,8,2), +(11,1,4), +(12,8,8), +(13,8,4), +(14,5,4); +CREATE TABLE t2 ( +pk int NOT NULL, +col_int_nokey int NOT NULL, +col_int_key int NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +) ENGINE=MyISAM; +INSERT INTO t2 VALUES +(10,8,7); +CREATE TABLE t3 +SELECT grandparent1.col_int_nokey AS g1 +FROM t1 AS grandparent1 +WHERE (grandparent1.col_int_nokey, grandparent1.col_int_key) IN +(SELECT parent1.col_int_key AS p1, +parent1.col_int_key AS p2 +FROM t1 AS parent1 +LEFT JOIN t2 AS parent2 +ON parent1.col_int_nokey = parent2.col_int_key +) +AND grandparent1.col_int_key <> 3 +; +explain SELECT * FROM t3 +WHERE g1 NOT IN +(SELECT grandparent1.col_int_nokey AS g1 +FROM t1 AS grandparent1 +WHERE (grandparent1.col_int_nokey, grandparent1.col_int_key) IN +(SELECT parent1.col_int_key AS p1, +parent1.col_int_key AS p2 +FROM t1 AS parent1 +LEFT JOIN t2 AS parent2 +ON parent1.col_int_nokey = parent2.col_int_key +) +AND grandparent1.col_int_key <> 3 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 Using where; Not exists +2 MATERIALIZED grandparent1 NULL ALL col_int_key NULL NULL NULL 11 100.00 Using where +2 MATERIALIZED parent1 NULL ref col_int_key col_int_key 4 test.grandparent1.col_int_nokey 2 100.00 Using where +2 MATERIALIZED parent2 NULL ref col_int_key col_int_key 4 test.parent1.col_int_nokey 2 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select '8' AS `g1` from anti join (`test`.`t1` `grandparent1` join `test`.`t1` `parent1` left join `test`.`t2` `parent2` on((`test`.`parent2`.`col_int_key` = `test`.`parent1`.`col_int_nokey`))) on(((``.`g1` = '8') and (`test`.`grandparent1`.`col_int_key` = '8') and (`test`.`grandparent1`.`col_int_nokey` = '8') and (`test`.`parent1`.`col_int_key` = '8') and ('8' <> 3))) where true +explain format=json SELECT * FROM t3 +WHERE g1 NOT IN +(SELECT grandparent1.col_int_nokey AS g1 +FROM t1 AS grandparent1 +WHERE (grandparent1.col_int_nokey, grandparent1.col_int_key) IN +(SELECT parent1.col_int_key AS p1, +parent1.col_int_key AS p2 +FROM t1 AS parent1 +LEFT JOIN t2 AS parent2 +ON parent1.col_int_nokey = parent2.col_int_key +) +AND grandparent1.col_int_key <> 3 +); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "24.82" + }, + "nested_loop": [ + { + "table": { + "table_name": "t3", + "access_type": "system", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.00", + "eval_cost": "0.10", + "prefix_cost": "0.00", + "data_read_per_join": "8" + }, + "used_columns": [ + "g1" + ] + } + }, + { + "table": { + "table_name": "", + "access_type": "const", + "key": "", + "key_length": "5", + "ref": [ + "const" + ], + "rows_examined_per_scan": 1, + "not_exists": true, + "attached_condition": "((is_not_null_compl(), (('8' <> 3)), true) and (is_not_null_compl(), (found_match(), false, true), true))", + "materialized_from_subquery": { + "using_temporary_table": true, + "query_block": { + "nested_loop": [ + { + "table": { + "table_name": "grandparent1", + "access_type": "ALL", + "possible_keys": [ + "col_int_key" + ], + "rows_examined_per_scan": 11, + "rows_produced_per_join": 11, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "1.10", + "prefix_cost": "1.61", + "data_read_per_join": "176" + }, + "used_columns": [ + "col_int_nokey", + "col_int_key" + ], + "attached_condition": "((('8' <> 3)) and ((`test`.`grandparent1`.`col_int_key` = '8') and (`test`.`grandparent1`.`col_int_nokey` = '8')))" + } + }, + { + "table": { + "table_name": "parent1", + "access_type": "ref", + "possible_keys": [ + "col_int_key" + ], + "key": "col_int_key", + "used_key_parts": [ + "col_int_key" + ], + "key_length": "4", + "ref": [ + "test.grandparent1.col_int_nokey" + ], + "rows_examined_per_scan": 2, + "rows_produced_per_join": 22, + "filtered": "100.00", + "cost_info": { + "read_cost": "5.50", + "eval_cost": "2.20", + "prefix_cost": "9.31", + "data_read_per_join": "352" + }, + "used_columns": [ + "col_int_nokey", + "col_int_key" + ], + "attached_condition": "(`test`.`parent1`.`col_int_key` = '8')" + } + }, + { + "table": { + "table_name": "parent2", + "access_type": "ref", + "possible_keys": [ + "col_int_key" + ], + "key": "col_int_key", + "used_key_parts": [ + "col_int_key" + ], + "key_length": "4", + "ref": [ + "test.parent1.col_int_nokey" + ], + "rows_examined_per_scan": 2, + "rows_produced_per_join": 44, + "filtered": "100.00", + "using_index": true, + "cost_info": { + "read_cost": "5.62", + "eval_cost": "4.40", + "prefix_cost": "19.33", + "data_read_per_join": "704" + }, + "used_columns": [ + "col_int_key" + ] + } + } + ] + } + } + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select '8' AS `g1` from anti join (`test`.`t1` `grandparent1` join `test`.`t1` `parent1` left join `test`.`t2` `parent2` on((`test`.`parent2`.`col_int_key` = `test`.`parent1`.`col_int_nokey`))) on(((``.`g1` = '8') and (`test`.`grandparent1`.`col_int_key` = '8') and (`test`.`grandparent1`.`col_int_nokey` = '8') and (`test`.`parent1`.`col_int_key` = '8') and ('8' <> 3))) where true +SELECT * FROM t3 +WHERE g1 NOT IN +(SELECT grandparent1.col_int_nokey AS g1 +FROM t1 AS grandparent1 +WHERE (grandparent1.col_int_nokey, grandparent1.col_int_key) IN +(SELECT parent1.col_int_key AS p1, +parent1.col_int_key AS p2 +FROM t1 AS parent1 +LEFT JOIN t2 AS parent2 +ON parent1.col_int_nokey = parent2.col_int_key +) +AND grandparent1.col_int_key <> 3 +); +g1 +DROP TABLE t1, t2, t3; +# End of test for bug#13334882. +# +# Bug#13339643: Assertion on JOIN::flatten_subqueries on second execution +# +CREATE TABLE t1 ( +col_int_nokey INT, +col_varchar_nokey VARCHAR(1) +) charset utf8mb4; +INSERT INTO t1 VALUES +(1,'o'), +(2,'t'); +CREATE TABLE t2 LIKE t1; +INSERT INTO t2 VALUES +(1,'o'), +(4,'f'); +CREATE VIEW v_t2 AS SELECT * FROM t2; +CREATE TABLE t3 LIKE t1; +INSERT INTO t3 VALUES +(1,'o'), +(4,'f'); +explain SELECT alias1.col_varchar_nokey +FROM t1 AS alias1 +INNER JOIN v_t2 AS alias2 +ON alias2.col_int_nokey = alias1.col_int_nokey AND +'o' IN (SELECT col_varchar_nokey +FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary; End temporary +1 SIMPLE alias1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`alias1`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t1` `alias1` join `test`.`t2` semi join (`test`.`t3`) where ((`test`.`t3`.`col_varchar_nokey` = 'o') and (`test`.`t2`.`col_int_nokey` = `test`.`alias1`.`col_int_nokey`)) +SELECT alias1.col_varchar_nokey +FROM t1 AS alias1 +INNER JOIN v_t2 AS alias2 +ON alias2.col_int_nokey = alias1.col_int_nokey AND +'o' IN (SELECT col_varchar_nokey +FROM t3); +col_varchar_nokey +o +PREPARE stmt FROM "SELECT alias1.col_varchar_nokey +FROM t1 AS alias1 +INNER JOIN v_t2 AS alias2 +ON alias2.col_int_nokey = alias1.col_int_nokey AND +'o' IN (SELECT col_varchar_nokey +FROM t3)"; +EXECUTE stmt; +col_varchar_nokey +o +DROP VIEW v_t2; +DROP TABLE t1, t2, t3; +# End of test for bug#13339643. +# +# Bug#13424134: Wrong result on JOIN + nested WHERE ... IN clauses +# +CREATE TABLE t1 ( +pk int NOT NULL, +col_int_nokey int NOT NULL, +col_int_key int NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +) ENGINE=MyIsam; +INSERT INTO t1 VALUES +(10,1,7), (13,7,3), (18,0,1), (23,8,1); +CREATE TABLE t2 ( +pk int NOT NULL, +col_int_key int NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +) ENGINE=MyIsam; +INSERT INTO t2 VALUES (1,7); +EXPLAIN SELECT t1a.* +FROM t1 AS t1a +JOIN t1 AS t1b USING ( col_int_nokey ) +WHERE t1a.col_int_key IN ( +SELECT pk +FROM t2 +WHERE col_int_key IN ( +SELECT col_int_nokey +FROM t1 +) +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL system PRIMARY,col_int_key NULL NULL NULL 1 100.00 NULL +1 SIMPLE t1a NULL ref col_int_key col_int_key 4 const 1 100.00 NULL +1 SIMPLE t1b NULL ALL NULL NULL NULL NULL 4 25.00 Using where +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; Start temporary; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1a`.`pk` AS `pk`,`test`.`t1a`.`col_int_nokey` AS `col_int_nokey`,`test`.`t1a`.`col_int_key` AS `col_int_key` from `test`.`t1` `t1a` join `test`.`t1` `t1b` semi join (`test`.`t1`) where ((`test`.`t1b`.`col_int_nokey` = `test`.`t1a`.`col_int_nokey`) and (`test`.`t1a`.`col_int_key` = '1') and (`test`.`t1`.`col_int_nokey` = '7')) +SELECT t1a.* +FROM t1 AS t1a +JOIN t1 AS t1b USING ( col_int_nokey ) +WHERE t1a.col_int_key IN ( +SELECT pk +FROM t2 +WHERE col_int_key IN ( +SELECT col_int_nokey +FROM t1 +) +); +pk col_int_nokey col_int_key +18 0 1 +23 8 1 +ALTER TABLE t1 ENGINE=Innodb; +ALTER TABLE t2 ENGINE=Innodb; +SELECT t1a.* +FROM t1 AS t1a +JOIN t1 AS t1b USING ( col_int_nokey ) +WHERE t1a.col_int_key IN ( +SELECT pk +FROM t2 +WHERE col_int_key IN ( +SELECT col_int_nokey +FROM t1 +) +); +pk col_int_nokey col_int_key +18 0 1 +23 8 1 +DROP TABLE t1, t2; +# End of test for bug#13424134. +# +# Bug#13414014: Extra rows in result on semijoin query with where ... +# +CREATE TABLE t1 ( +c INT, +d INT, +a VARCHAR(1), +b VARCHAR(1), +KEY a (a) +) charset utf8mb4; +INSERT INTO t1 VALUES +(NULL,8,'x','x'), (7,4,'q','q'), (6,8,'c','c'); +CREATE TABLE t2 ( +a VARCHAR(1), +KEY a (a) +) charset utf8mb4; +INSERT INTO t2 VALUES +('c'), (NULL), ('x'), ('q'); +explain SELECT * +FROM t2 AS ot +WHERE (a, a) IN +(SELECT a, b +FROM t1 AS it +WHERE it.a = 'x' OR it.c > it.d +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using where +1 SIMPLE ot NULL ref a a 7 .a 2 100.00 Using index +2 MATERIALIZED it NULL ALL a NULL NULL NULL 3 40.74 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`ot`.`a` AS `a` from `test`.`t2` `ot` semi join (`test`.`t1` `it`) where ((``.`b` = ``.`a`) and (`test`.`ot`.`a` = ``.`a`) and (`test`.`it`.`b` = `test`.`it`.`a`) and (((``.`a` = 'x') and (`test`.`it`.`a` = 'x') and (`test`.`it`.`b` = 'x')) or (`test`.`it`.`c` > `test`.`it`.`d`))) +SELECT * +FROM t2 AS ot +WHERE (a, a) IN +(SELECT a, b +FROM t1 AS it +WHERE it.a = 'x' OR it.c > it.d +) +; +a +q +x +DROP TABLE t1, t2; +# End of test for bug#13414014. +# +# Bug#13545215: Missing rows on nested in-subquery with materialization +# +CREATE TABLE t1 ( +col_int_key int, +col_varchar_key varchar(1), +col_varchar_nokey varchar(1), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +INSERT INTO t1 VALUES +(8,'x','x'), (0,'p','p'), (8,'c','c'); +CREATE TABLE t2 ( +pk int NOT NULL, +col_varchar_key varchar(1), +col_varchar_nokey varchar(1), +PRIMARY KEY (pk), +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4; +INSERT INTO t2 VALUES +(1,'v','v'), (2,'v','v'), (3,'c','c'), (4,NULL,NULL), +(5,'x','x'), (6,'i','i'), (7,'e','e'), (8,'p','p'); +CREATE TABLE t3 ( +col_int_nokey int +); +INSERT INTO t3 VALUES (7); +explain SELECT grandparent1.col_varchar_nokey +FROM t1 AS grandparent1 JOIN t1 AS grandparent2 USING (col_int_key) +WHERE grandparent1.col_varchar_key IN ( +SELECT col_varchar_nokey +FROM t2 AS parent1 +WHERE col_varchar_key IN ( +SELECT child1.col_varchar_nokey +FROM t2 AS child1 LEFT JOIN t3 AS child2 +ON child1.pk < child2.col_int_nokey +) +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE grandparent1 NULL ALL col_int_key,col_varchar_key NULL NULL NULL 3 100.00 Using where +1 SIMPLE NULL eq_ref 7 test.grandparent1.col_varchar_key 1 100.00 NULL +1 SIMPLE grandparent2 NULL ref col_int_key col_int_key 5 test.grandparent1.col_int_key 2 100.00 Using index +2 MATERIALIZED child1 NULL ALL NULL NULL NULL NULL 8 100.00 Using where +2 MATERIALIZED child2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 MATERIALIZED parent1 NULL ref col_varchar_key col_varchar_key 7 test.child1.col_varchar_nokey 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`grandparent1`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t1` `grandparent1` join `test`.`t1` `grandparent2` semi join (`test`.`t2` `parent1` join `test`.`t2` `child1` left join `test`.`t3` `child2` on((`test`.`child1`.`pk` < `test`.`child2`.`col_int_nokey`))) where ((`test`.`grandparent2`.`col_int_key` = `test`.`grandparent1`.`col_int_key`) and (``.`col_varchar_nokey` = `test`.`grandparent1`.`col_varchar_key`) and (`test`.`parent1`.`col_varchar_key` = `test`.`child1`.`col_varchar_nokey`)) +SELECT grandparent1.col_varchar_nokey +FROM t1 AS grandparent1 JOIN t1 AS grandparent2 USING (col_int_key) +WHERE grandparent1.col_varchar_key IN ( +SELECT col_varchar_nokey +FROM t2 AS parent1 +WHERE col_varchar_key IN ( +SELECT child1.col_varchar_nokey +FROM t2 AS child1 LEFT JOIN t3 AS child2 +ON child1.pk < child2.col_int_nokey +) +); +col_varchar_nokey +c +c +p +x +x +DROP TABLE t1, t2, t3; +# End of test for bug#13545215. +# +# BUG#13553211 - MISSING ROWS ON SELECT WITH IN-SUBQUERY AND +# MATERIALIZATION + SEMIJOIN ON +# +CREATE TABLE t1 ( +col_int_key int(11) DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (4,'v','v'); +INSERT INTO t1 VALUES (62,'v','v'); +INSERT INTO t1 VALUES (7,'c','c'); +INSERT INTO t1 VALUES (1,NULL,NULL); +EXPLAIN SELECT +alias1.col_varchar_nokey AS a1_nokey, +alias1.col_varchar_key AS a1_key, +alias2.col_varchar_nokey AS a2_nokey +FROM +t1 AS alias1, t1 AS alias2 +WHERE +(alias1.col_varchar_nokey,alias2.col_varchar_nokey) +IN +( +SELECT +sq2_alias2.col_varchar_nokey, sq2_alias1.col_varchar_key +FROM +t1 AS sq2_alias1, t1 AS sq2_alias2 +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE alias1 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +1 SIMPLE alias2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +1 SIMPLE NULL eq_ref 14 test.alias1.col_varchar_nokey,test.alias2.col_varchar_nokey 1 100.00 NULL +2 MATERIALIZED sq2_alias1 NULL index col_varchar_key col_varchar_key 12 NULL 4 100.00 Using index +2 MATERIALIZED sq2_alias2 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`alias1`.`col_varchar_nokey` AS `a1_nokey`,`test`.`alias1`.`col_varchar_key` AS `a1_key`,`test`.`alias2`.`col_varchar_nokey` AS `a2_nokey` from `test`.`t1` `alias1` join `test`.`t1` `alias2` semi join (`test`.`t1` `sq2_alias1` join `test`.`t1` `sq2_alias2`) where ((``.`col_varchar_key` = `test`.`alias2`.`col_varchar_nokey`) and (``.`col_varchar_nokey` = `test`.`alias1`.`col_varchar_nokey`)) +SELECT +alias1.col_varchar_nokey AS a1_nokey, +alias1.col_varchar_key AS a1_key, +alias2.col_varchar_nokey AS a2_nokey +FROM +t1 AS alias1, t1 AS alias2 +WHERE +(alias1.col_varchar_nokey,alias2.col_varchar_nokey) +IN +( +SELECT +sq2_alias2.col_varchar_nokey, sq2_alias1.col_varchar_key +FROM +t1 AS sq2_alias1, t1 AS sq2_alias2 +) +; +a1_nokey a1_key a2_nokey +c c c +c c v +c c v +v v c +v v c +v v v +v v v +v v v +v v v +DROP TABLE t1; +# +# Bug#13541406: Wrong result with loosescan on select .. where .. in +# +CREATE TABLE t1 ( +col_int_key INT NOT NULL, +col_varchar_nokey VARCHAR(1) NOT NULL, +KEY col_int_key (col_int_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t1 VALUES +(7,'v'), (0,'s'), (9,'l'), (3,'y'), (4,'c'), (2,'i'), (5,'h'), (3,'q'), +(1,'a'), (3,'v'), (6,'u'), (7,'s'), (5,'y'), (1,'z'), (204,'h'), (224,'p'), +(9,'e'), (5,'i'), (0,'y'), (3,'w'); +CREATE TABLE t2 ( +pk INT NOT NULL, +col_int_key INT NOT NULL, +col_varchar_key VARCHAR(1) NOT NULL, +col_varchar_nokey VARCHAR(1) NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t2 VALUES +(1,0,'j','j'), (2,8,'v','v'), (3,1,'c','c'), (4,8,'m','m'), +(5,9,'d','d'), (6,24,'d','d'), (7,6,'y','y'), (8,1,'t','t'), +(9,6,'d','d'), (10,2,'s','s'), (11,4,'r','r'), (12,8,'m','m'), +(13,4,'b','b'), (14,4,'x','x'), (15,7,'g','g'), (16,4,'p','p'), +(17,1,'q','q'), (18,9,'w','w'), (19,4,'d','d'), (20,8,'e','e'); +# This query should never use a LooseScan strategy +explain SELECT ot1.col_int_key AS field1 +FROM t2 AS ot1, t2 AS ot2 +WHERE (ot1.col_varchar_key, ot2.col_varchar_nokey) IN ( +SELECT it2.col_varchar_nokey, it1.col_varchar_key +FROM t2 AS it1 JOIN t1 AS it2 ON it2.col_int_key = it1.pk); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE ot1 NULL ref col_varchar_key col_varchar_key 6 .col_varchar_nokey 1 100.00 Using index +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 20 10.00 Using where +2 MATERIALIZED it2 NULL ALL col_int_key NULL NULL NULL 20 100.00 NULL +2 MATERIALIZED it1 NULL eq_ref PRIMARY,col_varchar_key PRIMARY 4 test.it2.col_int_key 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`col_int_key` AS `field1` from `test`.`t2` `ot1` join `test`.`t2` `ot2` semi join (`test`.`t2` `it1` join `test`.`t1` `it2`) where ((`test`.`it1`.`pk` = `test`.`it2`.`col_int_key`) and (`test`.`ot2`.`col_varchar_nokey` = ``.`col_varchar_key`) and (`test`.`ot1`.`col_varchar_key` = ``.`col_varchar_nokey`)) +SELECT ot1.col_int_key AS field1 +FROM t2 AS ot1, t2 AS ot2 +WHERE (ot1.col_varchar_key, ot2.col_varchar_nokey) IN ( +SELECT it2.col_varchar_nokey, it1.col_varchar_key +FROM t2 AS it1 JOIN t1 AS it2 ON it2.col_int_key = it1.pk); +field1 +1 +1 +1 +2 +6 +6 +6 +6 +6 +8 +8 +8 +8 +8 +8 +9 +DROP TABLE t1, t2; +# End of test for bug#13541406. +# +# Bug#13576391: Missing rows on select with in-subquery and +# batched-key-access=on and semijoin +# +CREATE TABLE t1 ( +col_int_nokey int NOT NULL, +col_varchar_key varchar(1) NOT NULL, +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4 engine=InnoDB; +INSERT INTO t1 VALUES +(1,'v'), (7,'s'), (4,'l'), (7,'y'), (0,'c'), (2,'i'), (9,'h'), (4,'q'), +(0,'a'), (9,'v'), (1,'u'), (3,'s'), (8,'y'), (8,'z'), (18,'h'), (84,'p'), +(6,'e'), (3,'i'), (6,'y'), (6,'w'); +CREATE TABLE t2 ( +col_int_nokey int NOT NULL, +col_varchar_nokey varchar(1) NOT NULL +) charset utf8mb4 engine=InnoDB; +INSERT INTO t2 VALUES +(4,'j'), (6,'v'), (3,'c'), (5,'m'), (3,'d'), (246,'d'), (2,'y'), (9,'t'), +(3,'d'), (8,'s'), (1,'r'), (8,'m'), (8,'b'), (5,'x'), (7,'g'), (5,'p'), +(1,'q'), (6,'w'), (2,'d'), (9,'e'); +explain SELECT col_varchar_nokey +FROM t2 AS ot +WHERE col_varchar_nokey IN ( +SELECT col_varchar_key +FROM t1 AS it +WHERE it.col_int_nokey <= it.col_int_nokey +AND NOT ot.col_int_nokey < 2 +) +ORDER BY col_varchar_nokey; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 20 33.33 Parallel execute (1 workers) +2 SIMPLE ot NULL ALL NULL NULL NULL NULL 20 33.33 Using where; Using filesort +2 SIMPLE it NULL ref col_varchar_key col_varchar_key 6 test.ot.col_varchar_nokey 1 100.00 Start temporary; End temporary +Warnings: +Note 1276 Field or reference 'test.ot.col_int_nokey' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`ot`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t2` `ot` semi join (`test`.`t1` `it`) where ((`test`.`it`.`col_varchar_key` = `test`.`ot`.`col_varchar_nokey`) and (`test`.`ot`.`col_int_nokey` >= 2)) order by `test`.`ot`.`col_varchar_nokey` +SELECT col_varchar_nokey +FROM t2 AS ot +WHERE col_varchar_nokey IN ( +SELECT col_varchar_key +FROM t1 AS it +WHERE it.col_int_nokey <= it.col_int_nokey +AND NOT ot.col_int_nokey < 2 +) +ORDER BY col_varchar_nokey; +col_varchar_nokey +c +e +p +s +v +w +y +ALTER TABLE t1 ENGINE=MyISAM; +ALTER TABLE t2 ENGINE=MyISAM; +explain SELECT col_varchar_nokey +FROM t2 AS ot +WHERE col_varchar_nokey IN ( +SELECT col_varchar_key +FROM t1 AS it +WHERE it.col_int_nokey <= it.col_int_nokey +AND NOT ot.col_int_nokey < 2 +) +ORDER BY col_varchar_nokey; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 20 33.33 Using where; Using filesort +1 SIMPLE it NULL ref col_varchar_key col_varchar_key 6 test.ot.col_varchar_nokey 2 100.00 Start temporary; End temporary +Warnings: +Note 1276 Field or reference 'test.ot.col_int_nokey' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`ot`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t2` `ot` semi join (`test`.`t1` `it`) where ((`test`.`it`.`col_varchar_key` = `test`.`ot`.`col_varchar_nokey`) and (`test`.`ot`.`col_int_nokey` >= 2)) order by `test`.`ot`.`col_varchar_nokey` +SELECT col_varchar_nokey +FROM t2 AS ot +WHERE col_varchar_nokey IN ( +SELECT col_varchar_key +FROM t1 AS it +WHERE it.col_int_nokey <= it.col_int_nokey +AND NOT ot.col_int_nokey < 2 +) +ORDER BY col_varchar_nokey; +col_varchar_nokey +c +e +p +s +v +w +y +ALTER TABLE t1 ENGINE=Memory; +ALTER TABLE t2 ENGINE=Memory; +explain SELECT col_varchar_nokey +FROM t2 AS ot +WHERE col_varchar_nokey IN ( +SELECT col_varchar_key +FROM t1 AS it +WHERE it.col_int_nokey <= it.col_int_nokey +AND NOT ot.col_int_nokey < 2 +) +ORDER BY col_varchar_nokey; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 20 33.33 Using where; Using filesort +1 SIMPLE it NULL ref col_varchar_key col_varchar_key 6 test.ot.col_varchar_nokey 2 100.00 Start temporary; End temporary +Warnings: +Note 1276 Field or reference 'test.ot.col_int_nokey' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`ot`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t2` `ot` semi join (`test`.`t1` `it`) where ((`test`.`it`.`col_varchar_key` = `test`.`ot`.`col_varchar_nokey`) and (`test`.`ot`.`col_int_nokey` >= 2)) order by `test`.`ot`.`col_varchar_nokey` +SELECT col_varchar_nokey +FROM t2 AS ot +WHERE col_varchar_nokey IN ( +SELECT col_varchar_key +FROM t1 AS it +WHERE it.col_int_nokey <= it.col_int_nokey +AND NOT ot.col_int_nokey < 2 +) +ORDER BY col_varchar_nokey; +col_varchar_nokey +c +e +p +s +v +w +y +DROP TABLE t1, t2; +# End of test for bug#13576391. +# +# Bug #13589848 "MISSING ROW ON SELECT WITH NESTED IN CLAUSES WHEN LOOSESCAN=ON" +# +CREATE TABLE t1 ( +id INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +KEY (col_varchar_key) +) charset utf8mb4; +INSERT INTO t1 VALUES (100,'m','m'), +(200,'b','b'), (300,'x','x'); +CREATE TABLE t2 ( +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +KEY (col_varchar_key) +) charset utf8mb4; +INSERT INTO t2 VALUES ('b','b'); +CREATE TABLE t3 ( +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +KEY (col_varchar_key) +) charset utf8mb4; +INSERT INTO t3 VALUES ('k','k'); +EXPLAIN SELECT gp1.id +FROM t1 AS gp1 JOIN t3 AS gp2 +ON gp2.col_varchar_key <> gp1.col_varchar_nokey +WHERE (gp1.col_varchar_nokey, gp1.col_varchar_nokey) +IN ( +SELECT col_varchar_nokey, col_varchar_nokey +FROM t1 +WHERE col_varchar_nokey +IN ( SELECT col_varchar_key +FROM t2 LEFT JOIN t3 USING (col_varchar_key) ) +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE gp2 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using where +1 SIMPLE gp1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +2 MATERIALIZED t2 NULL index col_varchar_key col_varchar_key 7 NULL 1 100.00 Using index +2 MATERIALIZED t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +2 MATERIALIZED t3 NULL ref col_varchar_key col_varchar_key 7 test.t2.col_varchar_key 2 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`gp1`.`id` AS `id` from `test`.`t1` `gp1` semi join (`test`.`t1` join `test`.`t2` left join `test`.`t3` on((`test`.`t2`.`col_varchar_key` = `test`.`t3`.`col_varchar_key`))) where ((``.`col_varchar_nokey` = ``.`col_varchar_nokey`) and (`test`.`gp1`.`col_varchar_nokey` = ``.`col_varchar_nokey`) and (`test`.`t1`.`col_varchar_nokey` = `test`.`t2`.`col_varchar_key`) and ('k' <> ``.`col_varchar_nokey`)) +SELECT gp1.id +FROM t1 AS gp1 JOIN t3 AS gp2 +ON gp2.col_varchar_key <> gp1.col_varchar_nokey +WHERE (gp1.col_varchar_nokey, gp1.col_varchar_nokey) +IN ( +SELECT col_varchar_nokey, col_varchar_nokey +FROM t1 +WHERE col_varchar_nokey +IN ( SELECT col_varchar_key +FROM t2 LEFT JOIN t3 USING (col_varchar_key) ) +) +; +id +200 +DROP TABLE t1,t2,t3; +# +# Bug #13596176: Missing row on select with nested in clause when +# matr=on and bnl=off + MyISAM +# +CREATE TABLE t1 ( +int_key int DEFAULT NULL, +vc_key varchar(1) DEFAULT NULL, +vc_nokey varchar(1) DEFAULT NULL, +KEY int_key (int_key), +KEY vc_key (vc_key, int_key) +) charset utf8mb4 ENGINE=MyISAM; +INSERT INTO t1 VALUES +(8,'x','x'), (7,'d','d'), (1,'r','r'), (7,'f','f'), +(9,'y','y'), (NULL,'u','u'), (1,'m','m'), (9,NULL,NULL), +(2,'o','o'), (9,'w','w'), (2,'m','m'), (4,'q','q'), +(0,NULL,NULL), (4,'d','d'), (8,'g','g'), (NULL,'x','x'), +(NULL,'f','f'), (0,'p','p'), (NULL,'j','j'), (8,'c','c'); +CREATE TABLE t2 ( +int_key int DEFAULT NULL, +vc_key varchar(1) DEFAULT NULL, +KEY int_key (int_key), +KEY vc_key (vc_key, int_key) +) charset utf8mb4 ENGINE=MyISAM; +INSERT INTO t2 VALUES (8,'g'); +explain SELECT vc_key +FROM t1 as outr +WHERE (vc_nokey, vc_key ) IN +(SELECT vc_nokey, vc_nokey +FROM t1 middle +WHERE vc_nokey IN +(SELECT child1.vc_key +FROM t2 AS child1 JOIN t1 AS child2 USING (int_key) +) +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using where +1 SIMPLE outr NULL ref vc_key vc_key 7 .vc_nokey 3 10.00 Using where +2 MATERIALIZED child1 NULL index int_key,vc_key vc_key 12 NULL 1 100.00 Using where; Using index +2 MATERIALIZED middle NULL ALL NULL NULL NULL NULL 20 10.00 Using where +2 MATERIALIZED child2 NULL ref int_key int_key 5 test.child1.int_key 3 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`outr`.`vc_key` AS `vc_key` from `test`.`t1` `outr` semi join (`test`.`t1` `middle` join `test`.`t2` `child1` join `test`.`t1` `child2`) where ((`test`.`child2`.`int_key` = `test`.`child1`.`int_key`) and (``.`vc_nokey` = ``.`vc_nokey`) and (`test`.`outr`.`vc_nokey` = ``.`vc_nokey`) and (`test`.`outr`.`vc_key` = ``.`vc_nokey`) and (`test`.`middle`.`vc_nokey` = `test`.`child1`.`vc_key`)) +SELECT vc_key +FROM t1 as outr +WHERE (vc_nokey, vc_key ) IN +(SELECT vc_nokey, vc_nokey +FROM t1 middle +WHERE vc_nokey IN +(SELECT child1.vc_key +FROM t2 AS child1 JOIN t1 AS child2 USING (int_key) +) +); +vc_key +g +DROP TABLE t1, t2; +# End of test for bug#13596176. +# +# BUG#11754478: MAX/MIN + SUBQUERY + AND FAILS TO RETURN ANY ROWS +# BUG#13599013: MAX/MIN + SUBQUERY IN WHERE CLAUSE MATCHING NO +# ROWS + INDEX DOES NOT RETURN NULL +# +CREATE TABLE t1 ( +pk int(11) PRIMARY KEY, +int_key int(11), +KEY int_key (int_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (1,0),(2,0),(3,2),(4,0),(5,3),(6,0); +SELECT MIN(int_key) FROM t1 WHERE (4, 4) IN (SELECT 1, 2); +MIN(int_key) +NULL +SELECT MIN(int_key) FROM t1 WHERE (4, 4) IN (SELECT 4, 4); +MIN(int_key) +0 +SELECT MIN(pk) FROM t1 WHERE pk IN (SELECT int_key FROM t1) AND pk = 6; +MIN(pk) +NULL +DROP TABLE t1; +# BUG#13726217: Crash in Item_ident::fix_after_pullout() +CREATE TABLE t1(a INTEGER) engine=innodb; +INSERT INTO t1 VALUES (0); +SELECT 0 +FROM t1 +WHERE 0 IN +(SELECT 0 +FROM t1 +WHERE 0 LIKE +(SELECT elt(a, 0) AS b +FROM t1 +GROUP BY a +HAVING b +) +); +0 +DROP TABLE t1; +# End of test for bug#13726217. +# BUG#13773979: Missing rows on second execution of prepared statement +CREATE TABLE t1 ( +col_int_nokey INT, +col_int_key INT, +col_varchar_key VARCHAR(1) +); +INSERT INTO t1 VALUES +(1,7,'v'), (7,0,'s'), (4,9,'l'), (7,3,'y'), +(2,2,'i'), (9,5,'h'), (0,1,'a'), (9,3,'v'); +CREATE VIEW v1 AS SELECT * FROM t1; +SELECT * +FROM t1 +WHERE col_int_key IN ( +SELECT alias1.col_int_nokey AS field1 +FROM v1 AS alias1 +WHERE alias1.col_varchar_key < 'v' +); +col_int_nokey col_int_key col_varchar_key +1 7 v +2 2 i +4 9 l +7 0 s +prepare stmt FROM "SELECT * +FROM t1 +WHERE col_int_key IN ( +SELECT alias1.col_int_nokey AS field1 +FROM v1 AS alias1 +WHERE alias1.col_varchar_key < 'v' +)"; +execute stmt; +col_int_nokey col_int_key col_varchar_key +1 7 v +2 2 i +4 9 l +7 0 s +execute stmt; +col_int_nokey col_int_key col_varchar_key +1 7 v +2 2 i +4 9 l +7 0 s +DEALLOCATE PREPARE stmt; +DROP VIEW v1; +DROP TABLE t1; +# End of test for bug#13773979. +# +# BUG#13685026 ASSERTION CUR_SJ_INNER_TABLES == 0 IN +# --OPTIMIZE_TABLE_ORDER::CHOOSE_TABLE_ORDER +# +CREATE TABLE t1 ( +col_int_key INT(11) NOT NULL, +col_datetime_key DATETIME NOT NULL, +col_varchar_key VARCHAR(1) NOT NULL, +col_varchar_nokey VARCHAR(1) NOT NULL, +KEY col_int_key (col_int_key), +KEY col_datetime_key (col_datetime_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (0,'2002-02-13 17:30:06','j','j'); +INSERT INTO t1 VALUES (8,'2008-09-27 00:34:58','v','v'); +CREATE TABLE t2 ( +col_int_key INT(11) NOT NULL, +col_datetime_key DATETIME NOT NULL, +col_varchar_key VARCHAR(1) NOT NULL, +col_varchar_nokey VARCHAR(1) NOT NULL, +KEY col_int_key (col_int_key), +KEY col_datetime_key (col_datetime_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (7,'2003-08-21 00:00:00','b','b'); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +SET @old_depth=@@optimizer_search_depth; +SET optimizer_search_depth=4; +EXPLAIN SELECT col_datetime_key +FROM t1 as outr +WHERE col_datetime_key IN ( +SELECT alias1.col_datetime_key +FROM t1 AS alias1 +LEFT JOIN t1 as alias3 +STRAIGHT_JOIN ( t2 AS alias4 +JOIN t1 AS alias5 +ON alias5.col_varchar_key <= alias4.col_varchar_nokey ) +ON alias5.col_int_key < alias4.col_int_key +ON alias5.col_varchar_key = alias4.col_varchar_key +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE outr NULL index col_datetime_key col_datetime_key 5 NULL 2 100.00 Using index +1 SIMPLE NULL eq_ref 5 test.outr.col_datetime_key 1 100.00 NULL +2 MATERIALIZED alias1 NULL index col_datetime_key col_datetime_key 5 NULL 2 100.00 Using index +2 MATERIALIZED alias4 NULL ALL col_int_key,col_varchar_key NULL NULL NULL 1 100.00 NULL +2 MATERIALIZED alias5 NULL ref col_int_key,col_varchar_key col_varchar_key 6 test.alias4.col_varchar_key 1 100.00 Using where; Using index +2 MATERIALIZED alias3 NULL index NULL col_int_key 4 NULL 2 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`outr`.`col_datetime_key` AS `col_datetime_key` from `test`.`t1` `outr` semi join (`test`.`t1` `alias1` left join (`test`.`t1` `alias3` join `test`.`t2` `alias4` join `test`.`t1` `alias5`) on(((`test`.`alias5`.`col_varchar_key` = `test`.`alias4`.`col_varchar_key`) and (`test`.`alias5`.`col_int_key` < `test`.`alias4`.`col_int_key`) and (`test`.`alias5`.`col_varchar_key` <= `test`.`alias4`.`col_varchar_nokey`)))) where (``.`col_datetime_key` = `test`.`outr`.`col_datetime_key`) +SELECT col_datetime_key +FROM t1 as outr +WHERE col_datetime_key IN ( +SELECT alias1.col_datetime_key +FROM t1 AS alias1 +LEFT JOIN t1 as alias3 +STRAIGHT_JOIN ( t2 AS alias4 +JOIN t1 AS alias5 +ON alias5.col_varchar_key <= alias4.col_varchar_nokey ) +ON alias5.col_int_key < alias4.col_int_key +ON alias5.col_varchar_key = alias4.col_varchar_key +); +col_datetime_key +2002-02-13 17:30:06 +2008-09-27 00:34:58 +DROP TABLE t1,t2; +SET @@optimizer_search_depth=@old_depth; +# +# BUG#13848789: SEGFAULT IN JOIN_READ_NEXT_SAME AT +# SQL/SQL_EXECUTOR.CC ON HAVING...IN...JOIN +# +CREATE TABLE t1 ( +col_int_key INT, +col_varchar_key VARCHAR(1), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4; +INSERT INTO t1 VALUES (8,'x'); +CREATE TABLE t2 ( +col_varchar_key VARCHAR(1), +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4; +INSERT INTO t2 VALUES ('x'), ('y'); +explain SELECT MIN(col_int_key) +FROM t1 as t1_outer +HAVING (1, 2) IN ( +SELECT t1_inner.col_int_key, MAX(t1_inner.col_int_key) +FROM t1 as t1_inner JOIN t2 +ON t2.col_varchar_key = t1_inner.col_varchar_key +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible HAVING +2 SUBQUERY t1_inner NULL system col_varchar_key NULL NULL NULL 1 100.00 NULL +2 SUBQUERY t2 NULL ref col_varchar_key col_varchar_key 7 const 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select min(`test`.`t1_outer`.`col_int_key`) AS `MIN(col_int_key)` from `test`.`t1` `t1_outer` having false +SELECT MIN(col_int_key) +FROM t1 as t1_outer +HAVING (1, 2) IN ( +SELECT t1_inner.col_int_key, MAX(t1_inner.col_int_key) +FROM t1 as t1_inner JOIN t2 +ON t2.col_varchar_key = t1_inner.col_varchar_key +); +MIN(col_int_key) +DROP TABLE t1,t2; +# Bug#13838810: Segfault in evaluate_null_complemented_join_record +CREATE TABLE t1 ( +pk int NOT NULL, +col_int_nokey int DEFAULT NULL, +col_int_key int DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t1 VALUES (10,NULL,8,'x'); +CREATE TABLE t2 ( +pk int NOT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +PRIMARY KEY (pk) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t2 VALUES (1,'x'); +CREATE TABLE t3 ( +pk int NOT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +PRIMARY KEY (pk), +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t3 VALUES +(1,'v','v'), (2,'v','v'), (3,'c','c'), (4,NULL,NULL); +EXPLAIN SELECT table1.pk,table2.pk, table3.pk +FROM t2 AS table1 +LEFT JOIN t1 AS table2 +LEFT JOIN t1 AS table3 +ON table3.col_int_key = table2.col_int_key +ON table3.pk = table2.col_int_nokey AND +table1.col_varchar_nokey IN ( +SELECT subquery3_t1.col_varchar_nokey +FROM t3 AS subquery3_t1 +LEFT JOIN t1 AS subquery3_t2 +ON subquery3_t2.col_varchar_key = subquery3_t1.col_varchar_key +WHERE subquery3_t2.col_int_nokey <> 9 +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE table1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE table2 NULL ALL col_int_key NULL NULL NULL 1 100.00 NULL +1 SIMPLE table3 NULL eq_ref PRIMARY,col_int_key PRIMARY 4 test.table2.col_int_nokey 1 100.00 Using where +1 SIMPLE NULL eq_ref 7 test.table1.col_varchar_nokey 1 100.00 NULL +2 MATERIALIZED subquery3_t2 NULL ALL col_varchar_key NULL NULL NULL 1 100.00 NULL +2 MATERIALIZED subquery3_t1 NULL ref col_varchar_key col_varchar_key 7 test.subquery3_t2.col_varchar_key 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`table1`.`pk` AS `pk`,`test`.`table2`.`pk` AS `pk`,`test`.`table3`.`pk` AS `pk` from `test`.`t2` `table1` left join (`test`.`t1` `table2` join `test`.`t1` `table3` semi join (`test`.`t3` `subquery3_t1` join `test`.`t1` `subquery3_t2`)) on(((`test`.`table3`.`col_int_key` = `test`.`table2`.`col_int_key`) and (`test`.`subquery3_t1`.`col_varchar_key` = `test`.`subquery3_t2`.`col_varchar_key`) and (``.`col_varchar_nokey` = `test`.`table1`.`col_varchar_nokey`) and (`test`.`table3`.`pk` = `test`.`table2`.`col_int_nokey`) and (`test`.`subquery3_t2`.`col_int_nokey` <> 9))) where true +SELECT table1.pk,table2.pk, table3.pk +FROM t2 AS table1 +LEFT JOIN t1 AS table2 +LEFT JOIN t1 AS table3 +ON table3.col_int_key = table2.col_int_key +ON table3.pk = table2.col_int_nokey AND +table1.col_varchar_nokey IN ( +SELECT subquery3_t1.col_varchar_nokey +FROM t3 AS subquery3_t1 +LEFT JOIN t1 AS subquery3_t2 +ON subquery3_t2.col_varchar_key = subquery3_t1.col_varchar_key +WHERE subquery3_t2.col_int_nokey <> 9 +) +; +pk pk pk +1 NULL NULL +DROP TABLE t1, t2, t3; +Extra test case for specific code coverage +CREATE TABLE t1(pk INTEGER); +INSERT INTO t1 VALUES(1), (2); +explain SELECT * +FROM t1 AS ot1 LEFT JOIN t1 AS ot2 +ON ot1.pk=ot2.pk AND +ot2.pk IN +(SELECT it1.pk +FROM t1 AS it1 LEFT JOIN t1 AS it2 ON it1.pk=it2.pk); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE NULL eq_ref 5 test.ot2.pk 1 100.00 Using where +2 MATERIALIZED it1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED it2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`pk` AS `pk`,`test`.`ot2`.`pk` AS `pk` from `test`.`t1` `ot1` left join (`test`.`t1` `ot2` semi join (`test`.`t1` `it1` left join `test`.`t1` `it2` on((`test`.`it1`.`pk` = `test`.`it2`.`pk`)))) on(((`test`.`ot2`.`pk` = `test`.`ot1`.`pk`) and (``.`pk` = `test`.`ot1`.`pk`))) where true +SELECT * +FROM t1 AS ot1 LEFT JOIN t1 AS ot2 +ON ot1.pk=ot2.pk AND +ot2.pk IN +(SELECT it1.pk +FROM t1 AS it1 LEFT JOIN t1 AS it2 ON it1.pk=it2.pk); +pk pk +1 1 +2 2 +DROP TABLE t1; +# End of test for bug#13838810. +# +# Bug#13845930: Segfault in st_join_table::and_with_condition +# +CREATE TABLE t1 ( +col_int INTEGER +); +CREATE TABLE t2 ( +col_varchar_1 VARCHAR(1), +col_varchar_2 VARCHAR(1) +); +INSERT INTO t2 VALUES ('x','x'), ('c','c'); +PREPARE stmt FROM ' +SELECT alias2.col_varchar_2 AS field1 +FROM t2 AS alias1 + JOIN + (t2 AS alias2 + LEFT JOIN t2 AS alias3 + ON (8, 92) IN + (SELECT sq1_alias1.col_int, + sq1_alias2.col_int + FROM t1 AS sq1_alias1 JOIN t1 AS sq1_alias2 + ) + ) + ON alias3.col_varchar_1 = alias2.col_varchar_2 +'; +EXECUTE stmt; +field1 + +EXECUTE stmt; +field1 +DEALLOCATE prepare stmt; +DROP TABLE t1, t2; +# End of test for bug#13845930. +# +# Bug#13855925: Assert 'prebuilt->search_tuple->n_fields > 0' +# in ha_innobase::index_read +# +CREATE TABLE t1 ( +pk INTEGER AUTO_INCREMENT, +col_int_nokey INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk), +KEY (col_varchar_key) +) charset utf8mb4 ENGINE=INNODB; +INSERT INTO t1 ( +col_int_key, col_int_nokey, +col_varchar_key, col_varchar_nokey +) VALUES +(4, 2, 'v','v'), (62, 150, 'v','v'), (7, NULL, 'c','c'), (1, 2, NULL, NULL), +(0, 5, 'x','x'), (7, 3, 'i','i'), (7, 1, 'e','e'), (1, 4, 'p','p'), +(7, NULL, 's','s'), (1, 2, 'j','j'), (5, 6, 'z','z'), (2, 6, 'c','c'), +(0, 8, 'a','a'), (1, 2, 'q','q'), (8, 6, 'y','y'), (1, 8, NULL, NULL), +(1, 3, 'r','r'), (9, 3, 'v','v'), (1, 9, NULL, NULL), (5, 6, 'r','r'); +CREATE TABLE t2 ( +pk INT AUTO_INCREMENT, +col_int_nokey INT, +col_int_key INT, +PRIMARY KEY (pk), +KEY (col_int_key) +) charset utf8mb4 AUTO_INCREMENT=10 ENGINE=INNODB; +INSERT INTO t2 (col_int_key, col_int_nokey) VALUES +(8, NULL), (7, 8), (1, 1), (7, 9), (9, 4), (NULL, 3), (1, 2), (9, NULL), +(2, 2), (9, NULL), (2, 6), (4, 7), (0, 2), (4, 5), (8, 7), (NULL, 6), +(NULL, 6), (0, 2), (NULL, 9), (8, 6); +CREATE TABLE t3 ( +pk INT AUTO_INCREMENT, +col_varchar_key VARCHAR(1), +PRIMARY KEY (pk), +KEY (col_varchar_key) +) charset utf8mb4 ENGINE=INNODB; +INSERT INTO t3 (col_varchar_key) VALUES +('c'), ('c'), ('q'), ('g'), ('e'), ('l'), (NULL), ('c'), ('h'), ('d'), +('c'), ('i'), ('t'), ('g'), ('q'), ('l'), ('n'), ('z'), ('n'), ('r'), ('p'); +CREATE VIEW v1 AS +SELECT table2.col_varchar_nokey AS field1 +FROM t2 AS table1 +INNER JOIN (t1 AS table2 +STRAIGHT_JOIN t2 AS table3 +ON table3.col_int_key = table2.pk AND +table3.col_int_nokey = ANY +(SELECT subquery1_t2.col_int_nokey AS subquery1_field1 +FROM t2 AS subquery1_t1 +RIGHT OUTER JOIN t1 AS subquery1_t2 +INNER JOIN t1 AS subquery1_t3 +ON subquery1_t3.col_int_key = subquery1_t2.pk +ON subquery1_t3.col_varchar_key=subquery1_t2.col_varchar_nokey +WHERE subquery1_t1.pk > 1 +) +) +ON table3.col_int_key IN +(SELECT subquery2_t1.col_int_key AS subquery2_field1 +FROM t2 AS subquery2_t1 +RIGHT OUTER JOIN t3 AS subquery2_t2 +LEFT OUTER JOIN t1 AS subquery2_t3 +ON subquery2_t3.col_varchar_key = subquery2_t2.col_varchar_key +ON subquery2_t3.pk = subquery2_t2.pk +) +; +explain SELECT * FROM v1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE table1 NULL index NULL col_int_key 5 NULL 20 100.00 Using index +1 SIMPLE table2 NULL ALL PRIMARY NULL NULL NULL 20 100.00 NULL +1 SIMPLE table3 NULL ref col_int_key col_int_key 5 test.table2.pk 2 100.00 Using where +1 SIMPLE NULL eq_ref 5 test.table3.col_int_nokey 1 100.00 NULL +1 SIMPLE NULL eq_ref 5 test.table2.pk 1 100.00 NULL +4 MATERIALIZED subquery1_t3 NULL ALL col_varchar_key NULL NULL NULL 20 100.00 Using where +4 MATERIALIZED subquery1_t2 NULL eq_ref PRIMARY PRIMARY 4 test.subquery1_t3.col_int_key 1 10.00 Using where +4 MATERIALIZED subquery1_t1 NULL index PRIMARY col_int_key 5 NULL 20 100.00 Using where; Using index +3 MATERIALIZED subquery2_t3 NULL index PRIMARY,col_varchar_key col_varchar_key 7 NULL 20 100.00 Using where; Using index +3 MATERIALIZED subquery2_t2 NULL eq_ref PRIMARY,col_varchar_key PRIMARY 4 test.subquery2_t3.pk 1 7.14 Using where +3 MATERIALIZED subquery2_t1 NULL index col_int_key col_int_key 5 NULL 20 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `table2`.`col_varchar_nokey` AS `field1` from `test`.`t2` `table1` join `test`.`t1` `table2` straight_join `test`.`t2` `table3` semi join (`test`.`t1` `subquery1_t2` join `test`.`t1` `subquery1_t3` join `test`.`t2` `subquery1_t1`) semi join (`test`.`t3` `subquery2_t2` join `test`.`t1` `subquery2_t3` join `test`.`t2` `subquery2_t1`) where ((`subquery1_t2`.`pk` = `subquery1_t3`.`col_int_key`) and (`subquery1_t2`.`col_varchar_nokey` = `subquery1_t3`.`col_varchar_key`) and (`subquery2_t2`.`col_varchar_key` = `subquery2_t3`.`col_varchar_key`) and (`subquery2_t2`.`pk` = `subquery2_t3`.`pk`) and (`table3`.`col_int_key` = `table2`.`pk`) and (``.`subquery2_field1` = `table2`.`pk`) and (``.`subquery1_field1` = `table3`.`col_int_nokey`) and (`subquery1_t1`.`pk` > 1)) +SELECT * FROM v1; +field1 +v +v +v +v +v +v +v +v +v +v +v +v +v +v +v +v +v +v +v +v +DROP VIEW v1; +DROP TABLE t1,t2,t3; +# End of test for bug#13855925. +# +# Bug#13897959: Segfault in setup_semijoin_dups_elimination() +# +CREATE TABLE t1 ( +col_datetime_key DATETIME DEFAULT NULL, +KEY col_datetime_key (col_datetime_key) +) ENGINE=MyISAM; +INSERT INTO t1 VALUES +('2001-04-18 00:00:00'), ('2008-12-18 19:39:55'), +('2000-08-01 12:19:39'), ('2004-09-25 21:29:06'), +('2009-09-20 09:11:48'), ('2004-03-27 09:32:04'); +CREATE TABLE t2 ( +col_date_nokey date DEFAULT NULL, +col_time_key time DEFAULT NULL, +col_datetime_key datetime DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +KEY col_time_key (col_time_key), +KEY col_datetime_key (col_datetime_key), +KEY col_varchar_key(col_varchar_key) +) ENGINE=MyISAM; +INSERT INTO t2 VALUES ('1900-01-01',NULL,'2001-11-04 19:07:55','x','x'); +SELECT grandparent1.col_varchar_nokey +FROM t2 AS grandparent1 LEFT JOIN t1 USING (col_datetime_key) +WHERE grandparent1.col_varchar_nokey IN ( +SELECT col_varchar_nokey +FROM t2 AS parent1 +WHERE parent1.col_time_key > grandparent1.col_date_nokey +); +col_varchar_nokey +DROP TABLE t1, t2; +# End of test for bug#13897959. +# +# Bug#13898625 ASSERT `(REMAINING_TABLES_AFTER != 0) ...' IN +# BEST_EXTENSION_BY_LIMITED_SEARCH +# +CREATE TABLE t1 ( +pk int(11) NOT NULL, +col_int_nokey INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (26,6,NULL,'f','f'); +INSERT INTO t1 VALUES (29,6,8,'c','c'); +CREATE TABLE t2 ( +pk INT NOT NULL, +col_int_nokey INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +INSERT INTO t2 VALUES (1,2,4,'v','v'); +INSERT INTO t2 VALUES (2,150,62,'v','v'); +INSERT INTO t2 VALUES (5,5,0,'x','x'); +INSERT INTO t2 VALUES (6,3,7,'i','i'); +INSERT INTO t2 VALUES (7,1,7,'e','e'); +CREATE VIEW view_c AS SELECT * FROM t2; +PREPARE prep_stmt_7430 FROM 'SELECT SUM( alias1.col_varchar_key ) AS field1 +FROM t1 AS alias1 +RIGHT JOIN t2 AS alias2 +INNER JOIN t1 AS alias3 +ON (alias3.col_varchar_key = alias2.col_varchar_key ) +ON ( "v" ) IN ( +SELECT sq1_alias1.col_varchar_nokey AS sq1_field1 +FROM t1 AS sq1_alias1 +) +WHERE alias3.pk IN ( +SELECT sq2_alias1.col_int_key AS sq2_field1 +FROM ( view_c AS sq2_alias1, t1 AS sq2_alias2 ) +) +'; +EXECUTE prep_stmt_7430; +field1 +NULL +EXECUTE prep_stmt_7430; +field1 +NULL +EXPLAIN SELECT SUM( alias1.col_varchar_key ) AS field1 +FROM t1 AS alias1 +RIGHT JOIN t2 AS alias2 +INNER JOIN t1 AS alias3 +ON (alias3.col_varchar_key = alias2.col_varchar_key ) +ON ( "v" ) IN ( +SELECT sq1_alias1.col_varchar_nokey AS sq1_field1 +FROM t1 AS sq1_alias1 +) +WHERE alias3.pk IN ( +SELECT sq2_alias1.col_int_key AS sq2_field1 +FROM ( view_c AS sq2_alias1, t1 AS sq2_alias2 ) +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE alias3 NULL ALL PRIMARY,col_varchar_key NULL NULL NULL 2 100.00 Using where +1 SIMPLE alias2 NULL ref col_varchar_key col_varchar_key 7 test.alias3.col_varchar_key 2 100.00 Using index +1 SIMPLE sq1_alias1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Start temporary; End temporary +1 SIMPLE alias1 NULL index NULL col_varchar_key 12 NULL 2 100.00 Using index +1 SIMPLE NULL eq_ref 5 test.alias3.pk 1 100.00 NULL +3 MATERIALIZED sq2_alias2 NULL index NULL PRIMARY 4 NULL 2 100.00 Using index +3 MATERIALIZED t2 NULL index col_int_key col_int_key 5 NULL 5 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select sum(`test`.`alias1`.`col_varchar_key`) AS `field1` from `test`.`t2` `alias2` join `test`.`t1` `alias3` left join (`test`.`t1` `alias1` semi join (`test`.`t1` `sq1_alias1`)) on(((`test`.`sq1_alias1`.`col_varchar_nokey` = 'v'))) semi join (`test`.`t2` join `test`.`t1` `sq2_alias2`) where ((`test`.`alias2`.`col_varchar_key` = `test`.`alias3`.`col_varchar_key`) and (``.`sq2_field1` = `test`.`alias3`.`pk`)) +PREPARE prep_stmt_7430 FROM 'SELECT SUM( alias1.col_varchar_key ) AS field1 +FROM t1 AS alias1 +RIGHT JOIN t2 AS alias2 +INNER JOIN t1 AS alias3 +ON (alias3.col_varchar_key = alias2.col_varchar_key ) +ON ( "v" ) IN ( +SELECT sq1_alias1.col_varchar_nokey AS sq1_field1 +FROM t1 AS sq1_alias1 +) +WHERE alias3.pk IN ( +SELECT sq2_alias1.col_int_key AS sq2_field1 +FROM ( view_c AS sq2_alias1 , t1 AS sq2_alias2 ) +WHERE sq2_alias1.col_varchar_nokey <> alias2.col_varchar_key +AND sq2_alias1.col_varchar_key < "l" + ) +'; +EXECUTE prep_stmt_7430; +field1 +NULL +EXECUTE prep_stmt_7430; +field1 +NULL +EXPLAIN SELECT SUM( alias1.col_varchar_key ) AS field1 +FROM t1 AS alias1 +RIGHT JOIN t2 AS alias2 +INNER JOIN t1 AS alias3 +ON (alias3.col_varchar_key = alias2.col_varchar_key ) +ON ( "v" ) IN ( +SELECT sq1_alias1.col_varchar_nokey AS sq1_field1 +FROM t1 AS sq1_alias1 +) +WHERE alias3.pk IN ( +SELECT sq2_alias1.col_int_key AS sq2_field1 +FROM ( view_c AS sq2_alias1 , t1 AS sq2_alias2 ) +WHERE sq2_alias1.col_varchar_nokey <> alias2.col_varchar_key +AND sq2_alias1.col_varchar_key < "l" + ) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE alias3 NULL ALL PRIMARY,col_varchar_key NULL NULL NULL 2 100.00 Using where +1 SIMPLE t2 NULL ref col_int_key,col_varchar_key col_int_key 5 test.alias3.pk 2 40.00 Using where; Start temporary +1 SIMPLE alias2 NULL ref col_varchar_key col_varchar_key 7 test.alias3.col_varchar_key 2 100.00 Using index +1 SIMPLE sq2_alias2 NULL index NULL PRIMARY 4 NULL 2 100.00 Using index +1 SIMPLE sq1_alias1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE alias1 NULL index NULL col_varchar_key 12 NULL 2 100.00 Using index; End temporary +Warnings: +Note 1276 Field or reference 'test.alias2.col_varchar_key' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select sum(`test`.`alias1`.`col_varchar_key`) AS `field1` from `test`.`t2` `alias2` join `test`.`t1` `alias3` left join (`test`.`t1` `alias1` semi join (`test`.`t1` `sq1_alias1`)) on(((`test`.`sq1_alias1`.`col_varchar_nokey` = 'v'))) semi join (`test`.`t2` join `test`.`t1` `sq2_alias2`) where ((`test`.`alias2`.`col_varchar_key` = `test`.`alias3`.`col_varchar_key`) and (`test`.`t2`.`col_int_key` = `test`.`alias3`.`pk`) and (`test`.`t2`.`col_varchar_nokey` <> `test`.`alias3`.`col_varchar_key`) and (`test`.`t2`.`col_varchar_key` < 'l')) +DROP TABLE t1,t2; +DROP VIEW view_c; +# +# Bug#13902463 SEGFAULT IN BITMAP<64U>::MERGE OR ADD_KEY_FIELD +# ON SECOND EXEC OF PREP STMT +# +CREATE TABLE t1 ( +pk INT, +col_int_nokey INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +KEY col_varchar_key (col_varchar_key) +); +CREATE VIEW view_b AS SELECT * FROM t1; +PREPARE prep_stmt_20421 FROM 'SELECT alias2.col_varchar_nokey AS field1 +FROM t1 AS alias1 +INNER JOIN t1 AS alias2 +ON (alias1.col_varchar_key = alias2.col_varchar_nokey +AND ( alias1.col_int_key ) IN ( +SELECT t1.col_int_nokey +FROM t1 +) +) +WHERE alias1.col_varchar_key IN ( +SELECT sq2_alias2.col_varchar_nokey AS sq2_field1 +FROM view_b AS sq2_alias1 +INNER JOIN t1 AS sq2_alias2 +ON (sq2_alias2.col_varchar_key = sq2_alias1.col_varchar_key ) +WHERE sq2_alias1.pk > alias2.pk +) +'; +EXECUTE prep_stmt_20421; +field1 +EXECUTE prep_stmt_20421; +field1 +EXPLAIN SELECT alias2.col_varchar_nokey AS field1 +FROM t1 AS alias1 +INNER JOIN t1 AS alias2 +ON (alias1.col_varchar_key = alias2.col_varchar_nokey +AND ( alias1.col_int_key ) IN ( +SELECT t1.col_int_nokey +FROM t1 +) +) +WHERE alias1.col_varchar_key IN ( +SELECT sq2_alias2.col_varchar_nokey AS sq2_field1 +FROM view_b AS sq2_alias1 +INNER JOIN t1 AS sq2_alias2 +ON (sq2_alias2.col_varchar_key = sq2_alias1.col_varchar_key ) +WHERE sq2_alias1.pk > alias2.pk +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.alias2.pk' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `field1` from `test`.`t1` `alias1` join `test`.`t1` `alias2` semi join (`test`.`t1`) semi join (`test`.`t1` join `test`.`t1` `sq2_alias2`) where ((`test`.`t1`.`pk` > NULL) and multiple equal(NULL, `test`.`sq2_alias2`.`col_varchar_nokey`, NULL) and multiple equal(`test`.`sq2_alias2`.`col_varchar_key`, `test`.`t1`.`col_varchar_key`) and multiple equal(NULL, `test`.`t1`.`col_int_nokey`)) +ALTER TABLE t1 DROP INDEX col_varchar_key; +PREPARE prep_stmt_20421 FROM 'SELECT alias2.col_varchar_nokey AS field1 +FROM t1 AS alias1 +INNER JOIN t1 AS alias2 +ON (alias1.col_varchar_key = alias2.col_varchar_nokey +AND ( alias1.col_int_key ) IN ( +SELECT t1.col_int_nokey +FROM t1 +) +) +WHERE alias1.col_varchar_key IN ( +SELECT sq2_alias2.col_varchar_nokey AS sq2_field1 +FROM view_b AS sq2_alias1 +INNER JOIN t1 AS sq2_alias2 +ON (sq2_alias2.col_varchar_key = sq2_alias1.col_varchar_key ) +WHERE sq2_alias1.pk > alias2.pk +) +'; +EXECUTE prep_stmt_20421; +field1 +EXECUTE prep_stmt_20421; +field1 +EXPLAIN SELECT alias2.col_varchar_nokey AS field1 +FROM t1 AS alias1 +INNER JOIN t1 AS alias2 +ON (alias1.col_varchar_key = alias2.col_varchar_nokey +AND ( alias1.col_int_key ) IN ( +SELECT t1.col_int_nokey +FROM t1 +) +) +WHERE alias1.col_varchar_key IN ( +SELECT sq2_alias2.col_varchar_nokey AS sq2_field1 +FROM view_b AS sq2_alias1 +INNER JOIN t1 AS sq2_alias2 +ON (sq2_alias2.col_varchar_key = sq2_alias1.col_varchar_key ) +WHERE sq2_alias1.pk > alias2.pk +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.alias2.pk' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `field1` from `test`.`t1` `alias1` join `test`.`t1` `alias2` semi join (`test`.`t1`) semi join (`test`.`t1` join `test`.`t1` `sq2_alias2`) where ((`test`.`t1`.`pk` > NULL) and multiple equal(NULL, `test`.`sq2_alias2`.`col_varchar_nokey`, NULL) and multiple equal(`test`.`sq2_alias2`.`col_varchar_key`, `test`.`t1`.`col_varchar_key`) and multiple equal(NULL, `test`.`t1`.`col_int_nokey`)) +DROP TABLE t1; +DROP VIEW view_b; +# +# Bug#13907277: Segfault in evaluate_null_complemented_join_record +# +CREATE TABLE t1 ( +pk INTEGER, +col_varchar_nokey VARCHAR(1), +col_varchar_key VARCHAR(1), +PRIMARY KEY (pk) +); +INSERT INTO t1 VALUES (1, 'x', 'x'); +CREATE TABLE t2 ( +pk INTEGER, +PRIMARY KEY (pk) +); +INSERT INTO t2 VALUES (1); +CREATE TABLE t3 ( +pk INTEGER, +col_int_nokey INTEGER, +col_int_key INTEGER, +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk) +); +INSERT INTO t3 VALUES (1, 6, 5, 'r'); +explain SELECT outer_t1.pk, outer_t2.pk +FROM t3 AS outer_t1 +RIGHT JOIN t2 AS outer_t2 +ON outer_t1.col_int_nokey IN +(SELECT inner_t1.col_int_nokey +FROM t3 AS inner_t1 +LEFT JOIN t1 AS inner_t2 +INNER JOIN t1 AS inner_t3 +ON inner_t3.pk = inner_t2.pk +ON inner_t3.col_varchar_nokey = inner_t2.col_varchar_key +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE outer_t2 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE outer_t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL eq_ref 5 test.outer_t1.col_int_nokey 1 100.00 NULL +2 MATERIALIZED inner_t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 MATERIALIZED inner_t2 NULL ALL PRIMARY NULL NULL NULL 1 100.00 NULL +2 MATERIALIZED inner_t3 NULL eq_ref PRIMARY PRIMARY 4 test.inner_t2.pk 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`outer_t1`.`pk` AS `pk`,'1' AS `pk` from left join (`test`.`t3` `outer_t1` semi join (`test`.`t3` `inner_t1` left join (`test`.`t1` `inner_t2` join `test`.`t1` `inner_t3`) on(((`test`.`inner_t3`.`col_varchar_nokey` = `test`.`inner_t2`.`col_varchar_key`) and (`test`.`inner_t3`.`pk` = `test`.`inner_t2`.`pk`))))) on(((``.`col_int_nokey` = `test`.`outer_t1`.`col_int_nokey`))) where true +SELECT outer_t1.pk, outer_t2.pk +FROM t3 AS outer_t1 +RIGHT JOIN t2 AS outer_t2 +ON outer_t1.col_int_nokey IN +(SELECT inner_t1.col_int_nokey +FROM t3 AS inner_t1 +LEFT JOIN t1 AS inner_t2 +INNER JOIN t1 AS inner_t3 +ON inner_t3.pk = inner_t2.pk +ON inner_t3.col_varchar_nokey = inner_t2.col_varchar_key +); +pk pk +1 1 +DROP TABLE t1, t2, t3; +# End of test for bug#13907277. +# +# Bug#13955713: Assert 'JOIN->best_read < ...' on second execution +# +CREATE TABLE t1 ( +pk INTEGER, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1) +); +PREPARE stmt FROM " +SELECT MIN(alias2.col_varchar_key) AS field1 +FROM t1 AS alias1 + INNER JOIN (t1 AS alias2 + INNER JOIN t1 AS alias3 + ON 8 IN + (SELECT sq1_alias1.pk AS sq1_field2 + FROM t1 AS sq1_alias1 + WHERE 9 IN + (SELECT SUM(t1_sq1_alias1.pk) AS t1_sq1_field2 + FROM t1 AS t1_sq1_alias1 + ) + ) + ) + ON alias3.col_varchar_nokey = alias2.col_varchar_key +WHERE EXISTS + (SELECT sq2_alias1.pk AS sq2_field1 + FROM t1 AS sq2_alias1 + WHERE sq2_alias1.col_varchar_key < alias1.col_varchar_nokey + ) +"; +EXECUTE stmt; +field1 +NULL + +EXECUTE stmt; +field1 +NULL +DEALLOCATE PREPARE stmt; +DROP TABLE t1; +# End of test for bug#13955713. +# +# Bug#13956813: Segfault in memcpy from Join_cache::write_record_data() +# +CREATE TABLE t1 ( +pk INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1) +) charset latin1; +CREATE TABLE t2 ( +pk INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1) +) charset latin1; +INSERT INTO t2 VALUES +(10,'j','j'), (11,'z','z'), (12,'c','c'), (13,'a','a'), +(14,'q','q'), (15,'y','y'), (16,NULL,NULL), (17,'r','r'), +(18,'v','v'), (19,NULL,NULL), (20,'r','r'); +CREATE TABLE t3 ( +pk INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +KEY col_int_key (col_int_key) +) charset latin1; +INSERT INTO t3 VALUES +(15,NULL,'u'), (16,1,'m'), (17,9,NULL), (18,2,'o'), +(19,9,'w'), (20,2,'m'), (21,4,'q'), (22,0,NULL), +(23,4,'d'), (24,8,'g'), (25,NULL,'x'), (26,NULL,'f'), +(27,0,'p'), (28,NULL,'j'), (29,8,'c'); +CREATE VIEW view_inline_0 AS +SELECT t1.* +FROM t1 INNER JOIN t3 +ON t1.pk = t3.pk; +CREATE VIEW view_inline_1 AS +SELECT sq2_alias2.col_varchar_key AS sq2_field1, +sq2_alias1.col_varchar_key AS sq2_field2 +FROM t3 AS sq2_alias1 LEFT OUTER JOIN t3 AS sq2_alias2 +ON sq2_alias1.pk = sq2_alias2.col_int_key; +CREATE VIEW view_inline_2 AS +SELECT 'p', 'p' UNION SELECT 'k', 's'; +SET @optimizer_switch_saved= @@optimizer_switch; +SET @@optimizer_switch="derived_merge=off"; +explain SELECT SUM(alias1.col_varchar_nokey) AS field2 +FROM t2 AS alias2 +LEFT JOIN (SELECT * FROM view_inline_0) AS alias1 +ON alias2.col_varchar_key = alias1.col_varchar_key AND +(alias2.col_varchar_nokey, alias2.col_varchar_key) IN +(SELECT * FROM view_inline_1 +) +WHERE (alias1.col_varchar_key, alias1.col_varchar_nokey) IN +(SELECT * FROM view_inline_2 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL 2 100.00 NULL +1 PRIMARY alias2 NULL ALL NULL NULL NULL NULL 11 10.00 Using where +1 PRIMARY NULL eq_ref 8 test.alias2.col_varchar_nokey,test.view_inline_2.p 1 100.00 NULL +1 PRIMARY NULL ref 8 test.view_inline_2.p,test.view_inline_2.Name_exp_p 2 100.00 NULL +3 MATERIALIZED NULL ALL NULL NULL NULL NULL 30 100.00 NULL +7 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +8 UNION NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +NULL UNION RESULT NULL ALL NULL NULL NULL NULL NULL NULL Using temporary +6 DERIVED sq2_alias1 NULL ALL NULL NULL NULL NULL 15 100.00 NULL +6 DERIVED sq2_alias2 NULL ref col_int_key col_int_key 5 test.sq2_alias1.pk 2 100.00 NULL +2 DERIVED NULL ALL NULL NULL NULL NULL 15 100.00 NULL +5 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select sum(`alias1`.`col_varchar_nokey`) AS `field2` from `test`.`view_inline_2` join `test`.`t2` `alias2` join (/* select#2 */ select `test`.`view_inline_0`.`pk` AS `pk`,`test`.`view_inline_0`.`col_varchar_key` AS `col_varchar_key`,`test`.`view_inline_0`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`view_inline_0`) `alias1` semi join (`test`.`view_inline_1`) where ((``.`sq2_field1` = `test`.`alias2`.`col_varchar_nokey`) and (`alias1`.`col_varchar_nokey` = `test`.`view_inline_2`.`Name_exp_p`) and (`test`.`alias2`.`col_varchar_key` = `test`.`view_inline_2`.`p`) and (``.`sq2_field2` = `test`.`view_inline_2`.`p`) and (`alias1`.`col_varchar_key` = `test`.`view_inline_2`.`p`)) +SELECT SUM(alias1.col_varchar_nokey) AS field2 +FROM t2 AS alias2 +LEFT JOIN (SELECT * FROM view_inline_0) AS alias1 +ON alias2.col_varchar_key = alias1.col_varchar_key AND +(alias2.col_varchar_nokey, alias2.col_varchar_key) IN +(SELECT * FROM view_inline_1 +) +WHERE (alias1.col_varchar_key, alias1.col_varchar_nokey) IN +(SELECT * FROM view_inline_2 +); +field2 +NULL +SET @@optimizer_switch= @optimizer_switch_saved; +DROP VIEW view_inline_0, view_inline_1, view_inline_2; +DROP TABLE t1, t2, t3; +# End of test for bug#13956813. +# +# Bug#13974177: Assert !(tab->table->regginfo.not_exists_optimize... +# +CREATE TABLE t1 ( +pk INTEGER AUTO_INCREMENT, +col_int_nokey INTEGER, +col_int_key INTEGER, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk), +KEY (col_int_key), +KEY (col_varchar_key, col_int_key) +); +INSERT INTO t1(col_int_key, col_int_nokey, col_varchar_key, col_varchar_nokey) +VALUES +(0, 4, 'j', 'j'), (8, 6, 'v', 'v'), (1, 3, 'c', 'c'), (8, 5, 'm', 'm'), +(9, 3, 'd', 'd'), (24, 246, 'd', 'd'), (6, 2, 'y', 'y'), (1, 9, 't', 't'), +(6, 3, 'd', 'd'), (2, 8, 's', 's'), (4, 1, 'r', 'r'), (8, 8, 'm', 'm'), +(4, 8, 'b', 'b'), (4, 5, 'x', 'x'), (7, 7, 'g', 'g'), (4, 5, 'p', 'p'), +(1, 1, 'q', 'q'), (9, 6, 'w', 'w'), (4, 2, 'd', 'd'), (8, 9, 'e', 'e'); +CREATE TABLE t2 ( +pk INTEGER AUTO_INCREMENT, +col_int_nokey INTEGER NOT NULL, +col_time_key TIME NOT NULL, +col_time_nokey TIME NOT NULL, +PRIMARY KEY (pk), +KEY (col_time_key) +) ENGINE=InnoDB; +INSERT INTO t2 (col_int_nokey, col_time_key, col_time_nokey) VALUES +(7, '00:00:00', '00:00:00'), (0, '00:00:00', '00:00:00'), +(9, '06:35:17', '06:35:17'), (3, '18:07:14', '18:07:14'), +(4, '20:36:52', '20:36:52'), (2, '21:29:07', '21:29:07'), +(5, '23:45:57', '23:45:57'), (3, '22:54:57', '22:54:57'), +(1, '18:45:09', '18:45:09'), (3, '14:30:46', '14:30:46'), +(6, '19:23:43', '19:23:43'), (7, '03:39:30', '03:39:30'), +(5, '23:37:52', '23:37:52'), (1, '16:59:30', '16:59:30'), +(204, '22:21:15', '22:21:15'), (224, '12:24:37', '12:24:37'), +(9, '15:02:08', '15:02:08'), (5, '23:59:59', '23:59:59'), +(0, '08:23:30', '08:23:30'), (3, '08:32:22', '08:32:22'); +explain SELECT ot1.col_int_key AS x +FROM t1 AS ot2 +LEFT JOIN t1 AS ot1 +ON ot2.col_varchar_nokey > ot1.col_varchar_key +WHERE (ot1.col_int_nokey, ot1.pk) IN +(SELECT it1.pk AS x, +it1.col_int_nokey AS y +FROM t2 AS it2 +LEFT JOIN t2 AS it1 +ON it2.col_time_nokey = it1.col_time_key +) AND ot1.pk IS NULL +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`col_int_key` AS `x` from `test`.`t2` `it1` join `test`.`t1` `ot2` join `test`.`t1` `ot1` semi join (`test`.`t2` `it2`) where ((`test`.`ot1`.`pk` is null) and (`test`.`ot2`.`col_varchar_nokey` > `test`.`ot1`.`col_varchar_key`) and multiple equal(`test`.`ot1`.`col_int_nokey`, `test`.`it1`.`pk`) and multiple equal(`test`.`ot1`.`pk`, `test`.`it1`.`col_int_nokey`) and multiple equal(`test`.`it2`.`col_time_nokey`, `test`.`it1`.`col_time_key`)) +SELECT ot1.col_int_key AS x +FROM t1 AS ot2 +LEFT JOIN t1 AS ot1 +ON ot2.col_varchar_nokey > ot1.col_varchar_key +WHERE (ot1.col_int_nokey, ot1.pk) IN +(SELECT it1.pk AS x, +it1.col_int_nokey AS y +FROM t2 AS it2 +LEFT JOIN t2 AS it1 +ON it2.col_time_nokey = it1.col_time_key +) AND ot1.pk IS NULL +; +x +DROP TABLE t1, t2; +# End of test for bug#13974177. +# +# Bug#13971022: Assert 'keyparts > 0' failed in create_ref_for_key... +# +CREATE TABLE t1 ( +pk INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +PRIMARY KEY (pk), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +CREATE TABLE t2 ( +pk INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk) +) charset utf8mb4 ENGINE=InnoDB; +CREATE TABLE t3 ( +i INT +); +SET @optimizer_switch_saved= @@optimizer_switch; +SET @@optimizer_switch="derived_merge=off"; +explain SELECT table1.pk AS field1 +FROM ( SELECT subquery1_t1. * +FROM t2 AS subquery1_t1 +JOIN t2 AS subquery1_t2 +ON subquery1_t2.pk = subquery1_t1.pk) AS table1 +STRAIGHT_JOIN t2 AS table2 +ON table1.col_int_key IN (SELECT 7 FROM t3) +WHERE table1.col_varchar_nokey IN +(SELECT subquery3_t1.col_varchar_key AS subquery3_field1 +FROM t1 AS subquery3_t1 +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL NULL 0.00 Using where +1 PRIMARY NULL ref 7 .subquery3_field1 2 100.00 NULL +1 PRIMARY NULL const 8 const 1 100.00 NULL +1 PRIMARY table2 NULL index NULL PRIMARY 4 NULL 1 100.00 Using index +4 MATERIALIZED subquery3_t1 NULL index col_varchar_key col_varchar_key 12 NULL 0 0.00 Using index +3 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 DERIVED subquery1_t1 NULL ALL PRIMARY NULL NULL NULL 1 100.00 Using where +2 DERIVED subquery1_t2 NULL eq_ref PRIMARY PRIMARY 4 test.subquery1_t1.pk 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `table1`.`pk` AS `field1` from (/* select#2 */ select `test`.`subquery1_t1`.`pk` AS `pk`,`test`.`subquery1_t1`.`col_int_key` AS `col_int_key`,`test`.`subquery1_t1`.`col_varchar_key` AS `col_varchar_key`,`test`.`subquery1_t1`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t2` `subquery1_t1` join `test`.`t2` `subquery1_t2` where ((`test`.`subquery1_t1`.`col_int_key` = 7) and (`test`.`subquery1_t2`.`pk` = `test`.`subquery1_t1`.`pk`))) `table1` straight_join `test`.`t2` `table2` semi join (`test`.`t3`) semi join (`test`.`t1` `subquery3_t1`) where (`table1`.`col_varchar_nokey` = ``.`subquery3_field1`) +SELECT table1.pk AS field1 +FROM ( SELECT subquery1_t1. * +FROM t2 AS subquery1_t1 +JOIN t2 AS subquery1_t2 +ON subquery1_t2.pk = subquery1_t1.pk) AS table1 +STRAIGHT_JOIN t2 AS table2 +ON table1.col_int_key IN (SELECT 7 FROM t3) +WHERE table1.col_varchar_nokey IN +(SELECT subquery3_t1.col_varchar_key AS subquery3_field1 +FROM t1 AS subquery3_t1 +) +; +field1 +SET @@optimizer_switch= @optimizer_switch_saved; +DROP TABLE t1, t2, t3; +# End of test for bug#13971022. +# +# Bug#13623473 "MISSING ROWS ON SELECT AND JOIN WITH +# TIME/DATETIME COMPARE" - Subquery part of test. +# +SET TIMESTAMP=UNIX_TIMESTAMP('2012-01-31 10:14:35'); +CREATE TABLE t1 ( +pk INT NOT NULL, +col_int_nokey INT, +col_int_key INT NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +) ENGINE=InnoDB; +INSERT INTO t1 VALUES (10,1,7), (11,7,0), (12,4,9), (13,7,3), +(14,0,4), (15,2,2), (16,9,5), (17,4,3), (18,0,1), (19,9,3), (20,1,6), +(21,3,7), (22,8,5), (23,8,1), (24,18,204), (25,84,224), (26,6,9), +(27,3,5), (28,6,0), (29,6,3); +CREATE TABLE t2 ( +col_int_nokey INT NOT NULL, +col_datetime_key DATETIME NOT NULL, +col_varchar_key VARCHAR(1) NOT NULL, +KEY col_datetime_key (col_datetime_key), +KEY col_varchar_key (col_varchar_key) +) ENGINE=InnoDB; +INSERT INTO t2 VALUES (1,'2001-11-04 19:07:55','k'); +CREATE TABLE t3 ( +col_time_key TIME, +KEY col_time_key (col_time_key) +) ENGINE=InnoDB; +INSERT INTO t3 VALUES ('21:22:34'), ('10:50:38'), ('00:21:38'), +('04:08:02'), ('16:25:11'), ('10:14:58'), ('19:47:59'), ('11:14:24'), +('00:00:00'), ('00:00:00'), ('15:57:25'), ('07:05:51'), ('19:22:21'), +('03:53:16'), ('09:16:38'), ('15:37:26'), ('00:00:00'), ('05:03:03'), +('02:59:24'), ('00:01:58'); +EXPLAIN SELECT outr.col_int_nokey +FROM t2 as outr +STRAIGHT_JOIN t3 AS outr2 +ON outr2.col_time_key > outr.col_datetime_key +WHERE outr.col_int_nokey IN ( +SELECT col_int_key +FROM t1 AS innr +WHERE innr.pk >= innr.col_int_nokey +) AND ( +outr.col_int_nokey <= 6 +OR +outr.col_varchar_key IS NULL +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE outr NULL ALL col_datetime_key NULL NULL NULL 1 100.00 Using where +1 SIMPLE NULL eq_ref 4 test.outr.col_int_nokey 1 100.00 NULL +1 SIMPLE outr2 NULL index col_time_key col_time_key 4 NULL 20 33.33 Using where; Using index +2 MATERIALIZED innr NULL ALL col_int_key NULL NULL NULL 20 23.33 Using where +Warnings: +Warning 1739 Cannot use range access on index 'col_time_key' due to type or collation conversion on field 'col_time_key' +Note 1003 /* select#1 */ select `test`.`outr`.`col_int_nokey` AS `col_int_nokey` from `test`.`t2` `outr` straight_join `test`.`t3` `outr2` semi join (`test`.`t1` `innr`) where ((``.`col_int_key` = `test`.`outr`.`col_int_nokey`) and (`test`.`outr`.`col_int_nokey` <= 6) and (`test`.`innr`.`pk` >= `test`.`innr`.`col_int_nokey`) and (cast(`test`.`outr2`.`col_time_key` as datetime) > `test`.`outr`.`col_datetime_key`)) +SELECT outr.col_int_nokey +FROM t2 as outr +STRAIGHT_JOIN t3 AS outr2 +ON outr2.col_time_key > outr.col_datetime_key +WHERE outr.col_int_nokey IN ( +SELECT col_int_key +FROM t1 AS innr +WHERE innr.pk >= innr.col_int_nokey +) AND ( +outr.col_int_nokey <= 6 +OR +outr.col_varchar_key IS NULL +); +col_int_nokey +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +DROP TABLE t1,t2,t3; +SET TIMESTAMP = DEFAULT; +# End of test for bug#13623473. +# +# Bug#13980954: Missing data on left join + null value + where..in +# +CREATE TABLE t1 ( +ik INT, +vc varchar(1) +) charset utf8mb4; +INSERT INTO t1 VALUES (8, 'x'), (NULL, 'x'); +CREATE TABLE t2 ( +ik INT, +vc varchar(1) +) charset utf8mb4; +INSERT INTO t2 VALUES +(0, 'x'), (7, 'i'), (7, 'e'), (1, 'p'), (7, 's'), (1, 'j'); +explain format=json SELECT t2.vc, t2.ik AS t2_ik, t1.ik AS t1_ik +FROM t2 LEFT JOIN t1 ON t2.vc=t1.vc +WHERE t2.vc IN (SELECT vc FROM t2 AS t3); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "8.63" + }, + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 6, + "rows_produced_per_join": 6, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "0.60", + "prefix_cost": "1.11", + "data_read_per_join": "96" + }, + "used_columns": [ + "ik", + "vc" + ], + "attached_condition": "(`test`.`t2`.`vc` is not null)" + } + }, + { + "table": { + "table_name": "", + "access_type": "eq_ref", + "key": "", + "key_length": "7", + "ref": [ + "test.t2.vc" + ], + "rows_examined_per_scan": 1, + "materialized_from_subquery": { + "using_temporary_table": true, + "query_block": { + "table": { + "table_name": "t3", + "access_type": "ALL", + "rows_examined_per_scan": 6, + "rows_produced_per_join": 6, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "0.60", + "prefix_cost": "1.11", + "data_read_per_join": "96" + }, + "used_columns": [ + "vc" + ] + } + } + } + } + }, + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 12, + "filtered": "100.00", + "cost_info": { + "read_cost": "3.01", + "eval_cost": "1.20", + "prefix_cost": "8.63", + "data_read_per_join": "192" + }, + "used_columns": [ + "ik", + "vc" + ], + "attached_condition": "(is_not_null_compl(t1), (`test`.`t1`.`vc` = `test`.`t2`.`vc`), true)" + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`vc` AS `vc`,`test`.`t2`.`ik` AS `t2_ik`,`test`.`t1`.`ik` AS `t1_ik` from `test`.`t2` left join `test`.`t1` on((`test`.`t1`.`vc` = `test`.`t2`.`vc`)) semi join (`test`.`t2` `t3`) where (``.`vc` = `test`.`t2`.`vc`) +SELECT t2.vc, t2.ik AS t2_ik, t1.ik AS t1_ik +FROM t2 LEFT JOIN t1 ON t2.vc=t1.vc +WHERE t2.vc IN (SELECT vc FROM t2 AS t3); +vc t2_ik t1_ik +e 7 NULL +i 7 NULL +j 1 NULL +p 1 NULL +s 7 NULL +x 0 8 +x 0 NULL +DROP TABLE t1, t2; +# End of test for bug#13980954. +# +# Bug#14048292: Segfault in Item_field::result_type on 2nd execution +# of prep stmt with join of view +# +CREATE TABLE t1 ( +col_int INT +); +INSERT INTO t1 VALUES (0), (1); +CREATE VIEW view_t1 AS SELECT * FROM t1; +explain SELECT alias1.col_int +FROM t1 AS alias1 +LEFT JOIN view_t1 AS alias2 +ON alias1.col_int IN +(SELECT sq1_alias1.col_int +FROM t1 AS sq1_alias1 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE alias1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE NULL eq_ref 5 test.alias1.col_int 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED sq1_alias1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`alias1`.`col_int` AS `col_int` from `test`.`t1` `alias1` left join (`test`.`t1` semi join (`test`.`t1` `sq1_alias1`)) on(((``.`col_int` = `test`.`alias1`.`col_int`))) where true +PREPARE stmt FROM "SELECT alias1.col_int +FROM t1 AS alias1 +LEFT JOIN view_t1 AS alias2 +ON alias1.col_int IN +(SELECT sq1_alias1.col_int +FROM t1 AS sq1_alias1 +)"; +EXECUTE stmt; +col_int +0 +0 +1 +1 + +EXECUTE stmt; +col_int +0 +0 +1 +1 +DEALLOCATE PREPARE stmt; +DROP VIEW view_t1; +DROP TABLE t1; +# End of test for bug#14048292. +# +# Bug#14064201: Missing data on join of derived table + WHERE .. IN +# with two operands +# +CREATE TABLE t1 ( +col_varchar_nokey VARCHAR(1) +) charset utf8mb4; +INSERT INTO t1 VALUES +('v'), ('s'), ('l'), ('y'), ('c'), ('i'), ('h'), ('q'), ('a'), ('v'), +('u'), ('s'), ('y'), ('z'), ('h'), ('p'), ('e'), ('i'), ('y'), ('w'); +CREATE TABLE t2 ( +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +KEY col_varchar_key(col_varchar_key) +) charset utf8mb4; +INSERT INTO t2 VALUES +('j','j'), ('v','v'), ('c','c'), ('m','m'), ('d','d'), ('d','d'), ('y','y'); +SET @optimizer_switch_saved= @@optimizer_switch; +SET @@optimizer_switch="derived_merge=off"; +explain format=json SELECT * +FROM (SELECT * FROM t2) AS derived1 +LEFT JOIN t1 +USING (col_varchar_nokey) +WHERE (col_varchar_nokey, col_varchar_nokey) IN +(SELECT col_varchar_nokey, col_varchar_key +FROM t2 AS derived2 +); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "13.56" + }, + "nested_loop": [ + { + "table": { + "table_name": "", + "access_type": "ALL", + "attached_condition": "((``.`col_varchar_key` = ``.`col_varchar_nokey`) and (``.`col_varchar_nokey` is not null))", + "materialized_from_subquery": { + "using_temporary_table": true, + "query_block": { + "table": { + "table_name": "derived2", + "access_type": "ALL", + "possible_keys": [ + "col_varchar_key" + ], + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "0.70", + "prefix_cost": "1.21", + "data_read_per_join": "112" + }, + "used_columns": [ + "col_varchar_key", + "col_varchar_nokey" + ], + "attached_condition": "(`test`.`derived2`.`col_varchar_key` = `test`.`derived2`.`col_varchar_nokey`)" + } + } + } + } + }, + { + "table": { + "table_name": "derived1", + "access_type": "ref", + "possible_keys": [ + "" + ], + "key": "", + "used_key_parts": [ + "col_varchar_nokey" + ], + "key_length": "7", + "ref": [ + ".col_varchar_nokey" + ], + "rows_examined_per_scan": 2, + "rows_produced_per_join": 2, + "filtered": "100.00", + "cost_info": { + "read_cost": "3.50", + "eval_cost": "0.20", + "prefix_cost": "8.51", + "data_read_per_join": "32" + }, + "used_columns": [ + "col_varchar_key", + "col_varchar_nokey" + ], + "materialized_from_subquery": { + "using_temporary_table": true, + "dependent": false, + "cacheable": true, + "query_block": { + "select_id": 2, + "cost_info": { + "query_cost": "1.21" + }, + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "0.70", + "prefix_cost": "1.21", + "data_read_per_join": "112" + }, + "used_columns": [ + "col_varchar_key", + "col_varchar_nokey" + ] + } + } + } + } + }, + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 40, + "filtered": "100.00", + "cost_info": { + "read_cost": "1.05", + "eval_cost": "4.00", + "prefix_cost": "13.56", + "data_read_per_join": "320" + }, + "used_columns": [ + "col_varchar_nokey" + ], + "attached_condition": "(is_not_null_compl(t1), (`test`.`t1`.`col_varchar_nokey` = `derived1`.`col_varchar_nokey`), true)" + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select `derived1`.`col_varchar_nokey` AS `col_varchar_nokey`,`derived1`.`col_varchar_key` AS `col_varchar_key` from (/* select#2 */ select `test`.`t2`.`col_varchar_key` AS `col_varchar_key`,`test`.`t2`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t2`) `derived1` left join `test`.`t1` on(((`test`.`t1`.`col_varchar_nokey` = `derived1`.`col_varchar_nokey`) and (`test`.`derived2`.`col_varchar_nokey` = `test`.`derived2`.`col_varchar_key`))) semi join (`test`.`t2` `derived2`) where ((``.`col_varchar_key` = ``.`col_varchar_nokey`) and (`derived1`.`col_varchar_nokey` = ``.`col_varchar_nokey`) and (`test`.`derived2`.`col_varchar_key` = `test`.`derived2`.`col_varchar_nokey`)) +SELECT * +FROM (SELECT * FROM t2) AS derived1 +LEFT JOIN t1 +USING (col_varchar_nokey) +WHERE (col_varchar_nokey, col_varchar_nokey) IN +(SELECT col_varchar_nokey, col_varchar_key +FROM t2 AS derived2 +); +col_varchar_nokey col_varchar_key +c c +d d +d d +j j +m m +v v +v v +y y +y y +y y +SET @@optimizer_switch= @optimizer_switch_saved; +DROP TABLE t1, t2; +CREATE TABLE t1 ( +col_int_nokey int NOT NULL, +col_int_key int NOT NULL, +KEY col_int_key (col_int_key) +); +INSERT INTO t1 VALUES +(1,7), (7,0), (4,9), (7,3), (0,4), (2,2), (9,5), (4,3), (0,1), (9,3), +(1,6), (3,7), (8,5), (8,1), (18,204), (84,224), (6,9), (3,5), (6,0), (6,3); +CREATE TABLE t2 ( +col_int_nokey int NOT NULL, +col_int_key int NOT NULL, +KEY col_int_key (col_int_key) +); +INSERT INTO t2 VALUES +(4,0), (6,8), (3,1), (5,8), (3,9), (246,24), (2,6), (9,1), (3,6), (8,2), +(1,4), (8,8), (8,4), (5,4), (7,7), (5,4), (1,1), (6,9), (2,4), (9,8); +explain format=json SELECT grandparent1.* +FROM t1 AS grandparent1 +LEFT JOIN t1 USING (col_int_nokey) +WHERE (col_int_nokey, col_int_nokey) IN +(SELECT col_int_nokey, col_int_key +FROM t2 +); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "60.24" + }, + "nested_loop": [ + { + "table": { + "table_name": "grandparent1", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 20, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "2.00", + "prefix_cost": "2.51", + "data_read_per_join": "320" + }, + "used_columns": [ + "col_int_nokey", + "col_int_key" + ] + } + }, + { + "table": { + "table_name": "", + "access_type": "eq_ref", + "key": "", + "key_length": "8", + "ref": [ + "test.grandparent1.col_int_nokey", + "test.grandparent1.col_int_nokey" + ], + "rows_examined_per_scan": 1, + "materialized_from_subquery": { + "using_temporary_table": true, + "query_block": { + "table": { + "table_name": "t2", + "access_type": "ALL", + "possible_keys": [ + "col_int_key" + ], + "rows_examined_per_scan": 20, + "rows_produced_per_join": 20, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "2.00", + "prefix_cost": "2.51", + "data_read_per_join": "320" + }, + "used_columns": [ + "col_int_nokey", + "col_int_key" + ], + "attached_condition": "(`test`.`t2`.`col_int_key` = `test`.`t2`.`col_int_nokey`)" + } + } + } + } + }, + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 400, + "filtered": "100.00", + "cost_info": { + "read_cost": "10.22", + "eval_cost": "40.00", + "prefix_cost": "60.24", + "data_read_per_join": "6K" + }, + "used_columns": [ + "col_int_nokey" + ], + "attached_condition": "(is_not_null_compl(t1), (`test`.`t1`.`col_int_nokey` = `test`.`grandparent1`.`col_int_nokey`), true)" + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`grandparent1`.`col_int_nokey` AS `col_int_nokey`,`test`.`grandparent1`.`col_int_key` AS `col_int_key` from `test`.`t1` `grandparent1` left join `test`.`t1` on(((`test`.`t1`.`col_int_nokey` = `test`.`grandparent1`.`col_int_nokey`) and (`test`.`t2`.`col_int_nokey` = `test`.`t2`.`col_int_key`))) semi join (`test`.`t2`) where ((``.`col_int_nokey` = `test`.`grandparent1`.`col_int_nokey`) and (``.`col_int_key` = `test`.`grandparent1`.`col_int_nokey`) and (`test`.`t2`.`col_int_key` = `test`.`t2`.`col_int_nokey`)) +SELECT grandparent1.* +FROM t1 AS grandparent1 +LEFT JOIN t1 USING (col_int_nokey) +WHERE (col_int_nokey, col_int_nokey) IN +(SELECT col_int_nokey, col_int_key +FROM t2 +); +col_int_nokey col_int_key +1 6 +1 6 +1 7 +1 7 +7 0 +7 0 +7 3 +7 3 +8 1 +8 1 +8 5 +8 5 +DROP TABLE t1, t2; +CREATE TABLE t1 ( +pk int, +col_int_key int, +col_datetime_key datetime, +col_varchar_key varchar(1), +col_varchar_nokey varchar(1), +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_datetime_key (col_datetime_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4 engine=MyISAM; +INSERT INTO t1 VALUES +(10,7,'2004-06-06 04:22:12','v','v'), (11,0,'2005-11-13 01:12:31','s','s'), +(12,9,'2002-05-04 01:50:00','l','l'), (13,3,'2004-10-27 10:28:45','y','y'), +(14,4,'2006-07-22 05:24:23','c','c'), (15,2,'2002-05-16 21:34:03','i','i'), +(16,5,'2008-04-17 10:45:30','h','h'), (17,3,'2009-04-21 02:58:02','q','q'), +(18,1,'2008-01-11 11:01:51','a','a'), (19,3,'1900-01-01 00:00:00','v','v'), +(20,6,'2007-05-17 18:24:57','u','u'), (21,7,'2007-08-07 00:00:00','s','s'), +(22,5,'2001-08-28 00:00:00','y','y'), (23,1,'2004-04-16 00:27:28','z','z'), +(24,204,'2005-05-03 07:06:22','h','h'), (25,224,'2009-03-11 17:09:50','p','p'), +(26,9,'2007-12-08 01:54:28','e','e'), (27,5,'2009-07-28 18:19:54','i','i'), +(28,0,'2008-06-08 00:00:00','y','y'), (29,3,'2005-02-09 09:20:26','w','w'); +CREATE TABLE t2 ( +pk int, +col_int_key int, +col_datetime_key datetime, +col_varchar_key varchar(1), +col_varchar_nokey varchar(1), +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_datetime_key (col_datetime_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4 engine=MyISAM; +INSERT INTO t2 VALUES +(1,0,'2002-02-13 17:30:06','j','j'), (2,8,'2008-09-27 00:34:58','v','v'), +(3,1,'2007-05-28 00:00:00','c','c'), (4,8,'2009-07-25 09:21:20','m','m'), +(5,9,'2002-01-16 00:00:00','d','d'), (6,24,'2006-10-12 04:32:53','d','d'), +(7,6,'2001-02-15 03:08:38','y','y'), (8,1,'2004-10-02 20:31:15','t','t'), +(9,6,'2002-08-20 22:48:00','d','d'), (10,2,'1900-01-01 00:00:00','s','s'), +(11,4,'2005-08-15 00:00:00','r','r'), (12,8,'1900-01-01 00:00:00','m','m'), +(13,4,'2008-05-16 08:09:06','b','b'), (14,4,'2001-01-20 12:47:23','x','x'), +(15,7,'2008-07-02 00:00:00','g','g'), (16,4,'1900-01-01 00:00:00','p','p'), +(17,1,'2002-12-08 11:34:58','q','q'), (18,9,'1900-01-01 00:00:00','w','w'), +(19,4,'1900-01-01 00:00:00','d','d'), (20,8,'2002-08-25 20:35:06','e','e'); +SELECT alias1.col_datetime_key +FROM t2 AS alias1 +RIGHT JOIN t2 AS alias2 +JOIN t2 AS alias3 +ON alias3.pk = alias2.pk +ON alias3.col_varchar_nokey = alias2.col_varchar_key OR +alias2.col_varchar_nokey +WHERE (alias2.col_varchar_key, alias2.col_varchar_key) IN +(SELECT sq2_alias2.col_varchar_key, sq2_alias1.col_varchar_nokey +FROM t1 AS sq2_alias1, t1 AS sq2_alias2 +WHERE sq2_alias2.col_int_key < 2); +col_datetime_key +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +2001-01-20 12:47:23 +2001-01-20 12:47:23 +2001-02-15 03:08:38 +2001-02-15 03:08:38 +2002-01-16 00:00:00 +2002-01-16 00:00:00 +2002-02-13 17:30:06 +2002-02-13 17:30:06 +2002-08-20 22:48:00 +2002-08-20 22:48:00 +2002-08-25 20:35:06 +2002-08-25 20:35:06 +2002-12-08 11:34:58 +2002-12-08 11:34:58 +2004-10-02 20:31:15 +2004-10-02 20:31:15 +2005-08-15 00:00:00 +2005-08-15 00:00:00 +2006-10-12 04:32:53 +2006-10-12 04:32:53 +2007-05-28 00:00:00 +2007-05-28 00:00:00 +2008-05-16 08:09:06 +2008-05-16 08:09:06 +2008-07-02 00:00:00 +2008-07-02 00:00:00 +2008-09-27 00:34:58 +2008-09-27 00:34:58 +2009-07-25 09:21:20 +2009-07-25 09:21:20 +ALTER TABLE t1 DISABLE KEYS; +ALTER TABLE t2 DISABLE KEYS; +explain format=json SELECT alias1.col_datetime_key +FROM t2 AS alias1 +RIGHT JOIN t2 AS alias2 +JOIN t2 AS alias3 +ON alias3.pk = alias2.pk +ON alias3.col_varchar_nokey = alias2.col_varchar_key OR +alias2.col_varchar_nokey +WHERE (alias2.col_varchar_key, alias2.col_varchar_key) IN +(SELECT sq2_alias2.col_varchar_key, sq2_alias1.col_varchar_nokey +FROM t1 AS sq2_alias1, t1 AS sq2_alias2 +WHERE sq2_alias2.col_int_key < 2); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "62.53" + }, + "nested_loop": [ + { + "table": { + "table_name": "", + "access_type": "ALL", + "attached_condition": "(``.`col_varchar_nokey` = ``.`col_varchar_key`)", + "materialized_from_subquery": { + "using_temporary_table": true, + "query_block": { + "nested_loop": [ + { + "table": { + "table_name": "sq2_alias2", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 6, + "filtered": "33.33", + "cost_info": { + "read_cost": "1.86", + "eval_cost": "0.67", + "prefix_cost": "2.53", + "data_read_per_join": "213" + }, + "used_columns": [ + "col_int_key", + "col_varchar_key" + ], + "attached_condition": "(`test`.`sq2_alias2`.`col_int_key` < 2)" + } + }, + { + "table": { + "table_name": "sq2_alias1", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 13, + "filtered": "10.00", + "cost_info": { + "read_cost": "3.53", + "eval_cost": "1.33", + "prefix_cost": "19.39", + "data_read_per_join": "426" + }, + "used_columns": [ + "col_varchar_nokey" + ], + "attached_condition": "(`test`.`sq2_alias1`.`col_varchar_nokey` = `test`.`sq2_alias2`.`col_varchar_key`)" + } + } + ] + } + } + } + }, + { + "table": { + "table_name": "alias2", + "access_type": "ALL", + "possible_keys": [ + "PRIMARY" + ], + "rows_examined_per_scan": 20, + "rows_produced_per_join": 2, + "filtered": "10.00", + "cost_info": { + "read_cost": "7.05", + "eval_cost": "0.20", + "prefix_cost": "56.77", + "data_read_per_join": "64" + }, + "used_columns": [ + "pk", + "col_varchar_key", + "col_varchar_nokey" + ], + "attached_condition": "(`test`.`alias2`.`col_varchar_key` = ``.`col_varchar_key`)" + } + }, + { + "table": { + "table_name": "alias3", + "access_type": "eq_ref", + "possible_keys": [ + "PRIMARY" + ], + "key": "PRIMARY", + "used_key_parts": [ + "pk" + ], + "key_length": "4", + "ref": [ + "test.alias2.pk" + ], + "rows_examined_per_scan": 1, + "rows_produced_per_join": 2, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.20", + "prefix_cost": "57.47", + "data_read_per_join": "64" + }, + "used_columns": [ + "pk", + "col_varchar_nokey" + ] + } + }, + { + "table": { + "table_name": "alias1", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 40, + "filtered": "100.00", + "cost_info": { + "read_cost": "1.06", + "eval_cost": "4.00", + "prefix_cost": "62.53", + "data_read_per_join": "1K" + }, + "used_columns": [ + "col_datetime_key" + ], + "attached_condition": "(is_not_null_compl(alias1), ((`test`.`alias3`.`col_varchar_nokey` = `test`.`alias2`.`col_varchar_key`) or (0 <> `test`.`alias2`.`col_varchar_nokey`)), true)" + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`alias1`.`col_datetime_key` AS `col_datetime_key` from `test`.`t2` `alias2` join `test`.`t2` `alias3` left join `test`.`t2` `alias1` on((((`test`.`alias3`.`col_varchar_nokey` = `test`.`alias2`.`col_varchar_key`) and (`test`.`sq2_alias1`.`col_varchar_nokey` = `test`.`sq2_alias2`.`col_varchar_key`)) or (0 <> `test`.`alias2`.`col_varchar_nokey`))) semi join (`test`.`t1` `sq2_alias1` join `test`.`t1` `sq2_alias2`) where ((`test`.`alias3`.`pk` = `test`.`alias2`.`pk`) and (``.`col_varchar_nokey` = ``.`col_varchar_key`) and (`test`.`alias2`.`col_varchar_key` = ``.`col_varchar_key`) and (`test`.`sq2_alias1`.`col_varchar_nokey` = `test`.`sq2_alias2`.`col_varchar_key`) and (`test`.`sq2_alias2`.`col_int_key` < 2)) +SELECT alias1.col_datetime_key +FROM t2 AS alias1 +RIGHT JOIN t2 AS alias2 +JOIN t2 AS alias3 +ON alias3.pk = alias2.pk +ON alias3.col_varchar_nokey = alias2.col_varchar_key OR +alias2.col_varchar_nokey +WHERE (alias2.col_varchar_key, alias2.col_varchar_key) IN +(SELECT sq2_alias2.col_varchar_key, sq2_alias1.col_varchar_nokey +FROM t1 AS sq2_alias1, t1 AS sq2_alias2 +WHERE sq2_alias2.col_int_key < 2); +col_datetime_key +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +2001-01-20 12:47:23 +2001-01-20 12:47:23 +2001-02-15 03:08:38 +2001-02-15 03:08:38 +2002-01-16 00:00:00 +2002-01-16 00:00:00 +2002-02-13 17:30:06 +2002-02-13 17:30:06 +2002-08-20 22:48:00 +2002-08-20 22:48:00 +2002-08-25 20:35:06 +2002-08-25 20:35:06 +2002-12-08 11:34:58 +2002-12-08 11:34:58 +2004-10-02 20:31:15 +2004-10-02 20:31:15 +2005-08-15 00:00:00 +2005-08-15 00:00:00 +2006-10-12 04:32:53 +2006-10-12 04:32:53 +2007-05-28 00:00:00 +2007-05-28 00:00:00 +2008-05-16 08:09:06 +2008-05-16 08:09:06 +2008-07-02 00:00:00 +2008-07-02 00:00:00 +2008-09-27 00:34:58 +2008-09-27 00:34:58 +2009-07-25 09:21:20 +2009-07-25 09:21:20 +DROP TABLE t1, t2; +# End of test for bug#14064201. +# +# Bug#18223655:ASSERTION FAILED: (INT)IDX >= 0 +# && IDX < PARENT_JOIN->TABLES +# +CREATE TABLE b (d INT); +CREATE TABLE c (a INT, b INT,c INT,d BLOB NOT NULL); +SELECT(SELECT 1 +FROM b WHERE(SELECT 1 IN (SELECT 1 FROM b WHERE 1 NOT BETWEEN d AND 1) +FROM b) IN (SELECT d FROM c)) as cc FROM b; +cc +INSERT INTO b VALUE(1); +INSERT INTO c VALUES(1,2,3,'1'),(2,3,4,'1'),(3,4,5,'C'); +SELECT(SELECT d FROM b WHERE(SELECT d IN +(SELECT d FROM b WHERE 1 NOT BETWEEN d AND 1) FROM b) IN +(SELECT d FROM c)) as cc FROM c; +cc +1 +1 +1 +DROP TABLE b,c; +# +# Bug#18447874:WRONG RESULT COMING FROM SEMI-JOIN +# +CREATE TABLE b ( +d INT(11) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE c ( +d BLOB +) ; +CREATE TABLE d ( +b INT(11) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO b VALUES(1),(2),(4); +INSERT INTO c VALUES(1),(2),(3); +SELECT 1 FROM b WHERE (SELECT 1 FROM d ) IN (SELECT d FROM c) ; +1 +INSERT INTO d VALUES(2); +SELECT 1 FROM b WHERE (SELECT 1 FROM d ) IN (SELECT d FROM c) ; +1 +1 +1 +1 +DROP TABLE b,c,d; +# +# Bug#17292723:INCORRECT RESULT FOR (SELECT...) IN (SELECT...) STATEMENT +# +CREATE TABLE t1 ( +ID int(11) NOT NULL AUTO_INCREMENT, +id2 int(11) DEFAULT NULL, +id3 int(11) DEFAULT NULL, +id4 varchar(150) COLLATE utf8_spanish_ci NOT NULL, +id5 int(11) DEFAULT NULL, +PRIMARY KEY (ID), +KEY id2 (id2), +KEY id3 (id3), +KEY id5 (id5) +) ENGINE=InnoDB; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 3778 'utf8_spanish_ci' is a collation of the deprecated character set UTF8MB3. Please consider using UTF8MB4 with an appropriate collation instead. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES +(123,1,1,'1',NULL), +(124,1,1,'2',NULL), +(125,1,1,'4',NULL), +(126,1,1,'3',NULL), +(127,1,1,'6',NULL), +(128,1,1,'8',NULL); +CREATE TABLE t2 ( +id6 int(11) NOT NULL, +id7 int(11) NOT NULL, +PRIMARY KEY (id6,id7), +KEY id7 (id7) +) ENGINE=InnoDB; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (126,123),(130,123),(135,123); +SELECT ID +FROM t1 p0 +WHERE p0.id3=1 +AND ( (SELECT p1.id FROM t1 p1 WHERE p1.id=123) IN (SELECT p3.id FROM t2 +p2, t1 p3 WHERE p0.id=p2.id6 AND p2.id7=p3.id)); +ID +126 +DROP TABLE t1,t2; +set @@optimizer_switch=@old_opt_switch; +# End of 5.6 tests +# +# Bug#19336348 DEBUG CRASH AT SETUP_SEMIJOIN_DUPS_ELIMINATION IN SQL/SQL_SELECT.CC +# +CREATE TABLE t1 ( +col_varchar_nokey varchar(1) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t1 VALUES ('c'),(NULL),('x'); +CREATE TABLE t2 ( +pk int, +col_varchar_key varchar(1), +PRIMARY KEY (pk), +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t2 VALUES (10,'l'),(11,'p'); +ANALYZE TABLE t1,t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN SELECT 1 +FROM t1 AS outr +WHERE outr.col_varchar_nokey IN +( +SELECT innr.col_varchar_key +FROM t2 AS innr +WHERE innr.pk <= 7 +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE outr NULL ALL NULL NULL NULL NULL 3 33.33 Using where +2 MATERIALIZED innr NULL range PRIMARY,col_varchar_key PRIMARY 4 NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` `outr` semi join (`test`.`t2` `innr`) where ((`test`.`outr`.`col_varchar_nokey` = ``.`col_varchar_key`) and (`test`.`innr`.`pk` <= 7)) +SELECT 1 +FROM t1 AS outr +WHERE outr.col_varchar_nokey IN +( +SELECT innr.col_varchar_key +FROM t2 AS innr +WHERE innr.pk <= 7 +) +; +1 +DROP TABLE t1,t2; +# +# Bug#18174394 BLOBS: CRASH AFTER UNINITIALIZED VALUES IN ITEM_FIELD::STR_RESULT +# +CREATE TABLE t1(d BLOB, b BLOB); +INSERT INTO t1(d,b) VALUES ('aaaa',''),('bnbb',''); +SELECT 1 FROM t1 +WHERE (SELECT b FROM t1) IN (SELECT (d>=1) FROM t1); +ERROR 21000: Subquery returns more than 1 row +DROP TABLE t1; +# +# Bug#19779600: ASSERT FAILED IN REPLACE_SUBCONDITION WITH IN +# PREDICATE INSIDE IN PREDICATE +# +CREATE TABLE t(X INT) ENGINE=InnoDB; +INSERT INTO t VALUES (1); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +EXPLAIN SELECT 1 FROM t WHERE (1 IN (SELECT 1 FROM t)) IN (SELECT 1 FROM t); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 PRIMARY NULL eq_ref 4 const 1 100.00 NULL +3 MATERIALIZED t NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SUBQUERY t NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t` semi join (`test`.`t`) where true +SELECT 1 FROM t WHERE (1 IN (SELECT 1 FROM t)) IN (SELECT 1 FROM t); +1 +1 +DROP TABLE t; +# +# Bug#19465034 ASSERT ON SETUP_SEMIJOIN_DUPS_ELIMINATION IN SQL/SQL_SELECT.CC +# +CREATE TABLE t1 ( +pk INTEGER NOT NULL, +i1 INTEGER NOT NULL, +PRIMARY KEY (pk) +) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1,1); +CREATE TABLE t2 ( +pk INTEGER NOT NULL, +c1 VARCHAR(1) NOT NULL, +PRIMARY KEY (pk), +KEY c1_key (c1) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t2 VALUES (1,'j'),(2,'v'),(3,'c'); +CREATE TABLE t3 ( +pk INTEGER NOT NULL, +c1 VARCHAR(1) NOT NULL, +PRIMARY KEY (pk), +KEY c1_key (c1) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t3 VALUES (10,'v'),(11,'s'); +ANALYZE TABLE t1, t2, t3; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +EXPLAIN SELECT * +FROM t1 JOIN t2 ON t1.i1 >= t2.pk +WHERE t2.c1 IN ( +SELECT t3.c1 +FROM t3 +WHERE t3.pk < 3 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t2 NULL ref PRIMARY,c1_key c1_key 6 .c1 1 33.33 Using where; Using index +2 MATERIALIZED t3 NULL range PRIMARY,c1_key PRIMARY 4 NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`i1` AS `i1`,`test`.`t2`.`pk` AS `pk`,`test`.`t2`.`c1` AS `c1` from `test`.`t1` join `test`.`t2` semi join (`test`.`t3`) where ((`test`.`t2`.`c1` = ``.`c1`) and (`test`.`t3`.`pk` < 3) and (`test`.`t1`.`i1` >= `test`.`t2`.`pk`)) +SELECT * +FROM t1 JOIN t2 ON t1.i1 >= t2.pk +WHERE t2.c1 IN ( +SELECT t3.c1 +FROM t3 +WHERE t3.pk < 3 +); +pk i1 pk c1 +DROP TABLE t1,t2,t3; +# +# Bug#19586047: CRASH IN ARG_COMPARATOR::SET_CMP_FUNC +# +CREATE TABLE t1(x INT) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT 1 FROM t1 WHERE EXISTS(SELECT 1) IN (SELECT 1 FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 PRIMARY NULL const 4 const 1 100.00 NULL +3 MATERIALIZED t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` semi join (`test`.`t1`) where true +SELECT 1 FROM t1 WHERE EXISTS(SELECT 1) IN (SELECT 1 FROM t1); +1 +1 +EXPLAIN SELECT 1 FROM t1 WHERE (SELECT 1, 2 FROM t1) IN (SELECT 1, 2 FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary; End temporary +2 SUBQUERY t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` semi join (`test`.`t1`) where true +SELECT 1 FROM t1 WHERE (SELECT 1, 2 FROM t1) IN (SELECT 1, 2 FROM t1); +1 +1 +EXPLAIN SELECT 1 FROM t1 WHERE +(SELECT 1, 2 FROM t1 WHERE x = 2) IN (SELECT 1, 2 FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +2 SUBQUERY t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` semi join (`test`.`t1`) where false +SELECT 1 FROM t1 WHERE +(SELECT 1, 2 FROM t1 WHERE x = 2) IN (SELECT 1, 2 FROM t1); +1 +DROP TABLE t1; +# +#Bug#20119743 ASSERTIONQEP_TAB->USE_ORDER() IN ENUM_NESTED_LOOP_STATE +# EVALUATE_JOIN_RECORD +# +CREATE TABLE t1 ( +pk int(11) NOT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +PRIMARY KEY (pk) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (1,'x'); +CREATE TABLE t2 ( +col_date_key date DEFAULT NULL, +col_int_key int(11) DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +KEY col_int_key (col_int_key), +KEY col_date_key (col_date_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES ('2000-12-03', 8, 'x', 'x'),('2008-05-03', 7, 'd', 'd'), +('2005-12-06', 1, 'r', 'r'),('2000-04-10', 7, 'f', 'f'), +('2002-11-05', 9, 'y', 'y'),('2000-09-06', NULL, 'u', 'u'), +(NULL, 1, 'm', 'm'),('2007-06-14', 9, NULL, NULL), +('2007-11-17', 2, 'o', 'o'),('2009-02-23', 9, 'w', 'w'), +('2007-01-08', 2, 'm', 'm'), ('2008-06-10', 4, 'q', 'q'), +('2002-10-20', 0, NULL, NULL),('2008-09-12', 4, 'd', 'd'), +('2006-06-16', 8, 'g', 'g'),('2004-09-18', NULL, 'x', 'x'), +('1900-01-01', NULL, 'f', 'f'),('2005-09-13', 0, 'p', 'p'), +('2007-04-09', NULL, 'j', 'j'),('2000-09-20', 8, 'c', 'c'); +CREATE TABLE t3 ( +pk int(11) NOT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +PRIMARY KEY (pk) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t3 VALUES (1, 'c'),(2, 'c'),(3, 'q'),(4, 'g'),(5, 'e'),(6, 'l'), +(7, NULL),(8, 'v'),(9, 'c'),(10, 'u'),(11, 'x'),(12, 'x'),(13, 'x'),(14, 'l'), +(15, 'e'),(16, 's'),(17, 'k'),(18, 'm'),(19, 'x'),(20, 's'); +ANALYZE TABLE t1,t2,t3; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +EXPLAIN SELECT r1.col_date_key +FROM t2 AS r1 +WHERE r1.col_int_key NOT IN +(SELECT ir2.pk +FROM t2 AS ir1 STRAIGHT_JOIN t1 AS ir2 +ON ir2.col_varchar_nokey = ir1.col_varchar_key +WHERE ir2.col_varchar_nokey > r1.col_varchar_nokey +AND ir2.pk IN +(SELECT iir2.pk +FROM t2 AS iir1 RIGHT JOIN t3 AS iir2 +ON iir2.col_varchar_nokey = iir1.col_varchar_key)) +ORDER BY r1.col_date_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY r1 NULL ALL NULL NULL NULL NULL 20 100.00 Using where; Using filesort +2 DEPENDENT SUBQUERY NULL ALL NULL NULL NULL NULL NULL 100.00 Using where +2 DEPENDENT SUBQUERY ir1 NULL index col_varchar_key col_varchar_key 12 NULL 20 100.00 Using where; Using index +2 DEPENDENT SUBQUERY ir2 NULL eq_ref PRIMARY PRIMARY 4 func 1 100.00 Using where; Full scan on NULL key +3 MATERIALIZED iir2 NULL eq_ref PRIMARY PRIMARY 4 func 1 100.00 Full scan on NULL key +3 MATERIALIZED iir1 NULL ref col_varchar_key col_varchar_key 7 test.iir2.col_varchar_nokey 1 100.00 Using index +SELECT r1.col_date_key +FROM t2 AS r1 +WHERE r1.col_int_key NOT IN +(SELECT ir2.pk +FROM t2 AS ir1 STRAIGHT_JOIN t1 AS ir2 +ON ir2.col_varchar_nokey = ir1.col_varchar_key +WHERE ir2.col_varchar_nokey > r1.col_varchar_nokey +AND ir2.pk IN +(SELECT iir2.pk +FROM t2 AS iir1 RIGHT JOIN t3 AS iir2 +ON iir2.col_varchar_nokey = iir1.col_varchar_key)) +ORDER BY r1.col_date_key; +col_date_key +2000-04-10 +2000-09-20 +2000-12-03 +2002-10-20 +2002-11-05 +2004-09-18 +2005-09-13 +2006-06-16 +2007-01-08 +2007-06-14 +2007-11-17 +2008-05-03 +2008-06-10 +2008-09-12 +2009-02-23 +SELECT COUNT(r1.col_date_key) AS COUNT_NUM +FROM t2 AS r1 +WHERE r1.col_int_key NOT IN +(SELECT ir2.pk +FROM t2 AS ir1 STRAIGHT_JOIN t1 AS ir2 +ON ir2.col_varchar_nokey = ir1.col_varchar_key +WHERE ir2.col_varchar_nokey > r1.col_varchar_nokey +AND ir2.pk IN +(SELECT iir2.pk +FROM t2 AS iir1 RIGHT JOIN t3 AS iir2 +ON iir2.col_varchar_nokey = iir1.col_varchar_key +WHERE iir2.pk<3)); +COUNT_NUM +15 +DROP TABLE t1,t2,t3; +# +# Bug#20554585 ASSERT JOIN()->TABLES == 0... IN JOIN_TAB::GET_SJ_STRATEGY ON SUBQUERY + VAR +# +CREATE TABLE t1 ( +pk int NOT NULL, +PRIMARY KEY (pk) +); +CREATE TABLE t2 ( +pk int NOT NULL, +col_int_key int, +col_varchar_key varchar(1), +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key) +); +CREATE TABLE t3 ( +pk int NOT NULL, +col_int_key int, +col_varchar_key varchar(1), +col_varchar varchar(1), +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key) +); +INSERT INTO t3 VALUES (1,4,'c','g'),(20,1,'i','p'); +CREATE TABLE t4 ( +col_int int +); +CREATE TABLE t5 ( +col_varchar_key varchar(1), +pk int NOT NULL, +col_int int, +PRIMARY KEY (pk), +KEY col_varchar_key (col_varchar_key) +); +SELECT table1.col_varchar_key AS field1 +FROM (t3 AS table1 +INNER JOIN ( +SELECT SUBQUERY1_t1.* +FROM (t1 AS SUBQUERY1_t1 +RIGHT JOIN (t2 AS SUBQUERY1_t2 +INNER JOIN t3 AS SUBQUERY1_t3 +ON (SUBQUERY1_t3.col_varchar_key = SUBQUERY1_t2.col_varchar_key) +) ON (SUBQUERY1_t3.col_int_key = SUBQUERY1_t2.pk) +) +WHERE SUBQUERY1_t2.col_varchar_key >= ANY ( +SELECT CHILD_SUBQUERY1_t2.col_varchar AS CHILD_SUBQUERY1_field1 +FROM (t2 AS CHILD_SUBQUERY1_t1 +LEFT OUTER JOIN t3 AS CHILD_SUBQUERY1_t2 +ON (CHILD_SUBQUERY1_t2.col_int_key = CHILD_SUBQUERY1_t1.col_int_key) +) +WHERE CHILD_SUBQUERY1_t1.pk >= SUBQUERY1_t2.pk +) +) AS table2 +ON (table2.pk = table1.pk) +) +WHERE (EXISTS (( +SELECT DISTINCT SUBQUERY2_t2.col_int AS SUBQUERY2_field1 +FROM (t4 AS SUBQUERY2_t1 +LEFT OUTER JOIN t5 AS SUBQUERY2_t2 +ON (SUBQUERY2_t2.pk = SUBQUERY2_t1.col_int) +) +WHERE SUBQUERY2_t2.col_varchar_key != @var4 +))) +AND table1.col_int_key < (35 + 192) +ORDER BY field1 +; +field1 +DROP TABLE t1, t2, t3, t4, t5; +# +# Bug#18892055: MISSING DATA ON SELECT ... IN WITH JOINS AND INNODB +# ENGINE +# +CREATE TABLE t1 ( +col_int_key INT, +pk INT NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +) ENGINE = INNODB; +INSERT INTO t1 VALUES +( 0, 3 ), +( 0, 4 ), +( 3, 1 ), +( 900000000, 2 ), +( 1368719360, 5 ), +( 1922236416, 6 ), +( 8,7 ); +CREATE TABLE t2 ( +pk INT NOT NULL, +col_int INT, +PRIMARY KEY (pk) +) ENGINE = INNODB; +INSERT INTO t2 VALUES +( 1, 3 ), +( 2, 2 ), +( 3, 8 ), +( 4, 7 ); +CREATE TABLE t3 ( +col_int_key INT, +col_int INT, +KEY (col_int_key) +) ENGINE = INNODB; +INSERT INTO t3 VALUES +( 5, 1 ), +( -1, -1 ), +( 300000000, 1 ), +( 8, 1 ); +CREATE TABLE t4 ( col_int_key INT ) ENGINE = INNODB; +INSERT INTO t4 VALUES +(0), +(3), +(8), +(900000000), +(1368719360), +(1922236416); +ANALYZE TABLE t1, t2, t3, t4; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +test.t4 analyze status OK +explain SELECT * +FROM t4 +WHERE (col_int_key) IN ( +SELECT t1.col_int_key +FROM t1 LEFT JOIN ( t2 JOIN t3 ON t3.col_int_key = t2.col_int ) USING ( pk ) +WHERE t3.col_int IS NULL +) +ORDER BY col_int_key +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using temporary; Using filesort +1 SIMPLE t4 NULL ALL NULL NULL NULL NULL 6 16.67 Using where +2 MATERIALIZED t1 NULL index col_int_key col_int_key 5 NULL 7 100.00 Using index +2 MATERIALIZED t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.pk 1 100.00 NULL +2 MATERIALIZED t3 NULL ref col_int_key col_int_key 5 test.t2.col_int 1 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`col_int_key` AS `col_int_key` from `test`.`t4` semi join (`test`.`t1` left join (`test`.`t2` join `test`.`t3`) on(((`test`.`t1`.`pk` = `test`.`t2`.`pk`) and (`test`.`t3`.`col_int_key` = `test`.`t2`.`col_int`)))) where ((`test`.`t4`.`col_int_key` = ``.`col_int_key`) and (`test`.`t3`.`col_int` is null)) order by `test`.`t4`.`col_int_key` +explain format=tree SELECT * +FROM t4 +WHERE (col_int_key) IN ( +SELECT t1.col_int_key +FROM t1 LEFT JOIN ( t2 JOIN t3 ON t3.col_int_key = t2.col_int ) USING ( pk ) +WHERE t3.col_int IS NULL +) +ORDER BY col_int_key +; +EXPLAIN +-> Sort: t4.col_int_key + -> Stream results (cost=11.32 rows=7) + -> Nested loop inner join (cost=11.32 rows=7) + -> Table scan on (cost=0.37..2.59 rows=7) + -> Materialize with deduplication (cost=4.47..6.69 rows=7) + -> Filter: (t1.col_int_key is not null) (cost=3.40 rows=7) + -> Filter: (t3.col_int is null) (cost=3.40 rows=7) + -> Nested loop left join (cost=3.40 rows=7) + -> Index scan on t1 using col_int_key (cost=0.95 rows=7) + -> Nested loop inner join (cost=2.41 rows=1) + -> Single-row index lookup on t2 using PRIMARY (pk=t1.pk) (cost=0.26 rows=1) + -> Index lookup on t3 using col_int_key (col_int_key=t2.col_int) (cost=0.25 rows=1) + -> Filter: (t4.col_int_key = ``.col_int_key) (cost=0.54 rows=1) + -> Table scan on t4 (cost=0.54 rows=6) + +SELECT * +FROM t4 +WHERE (col_int_key) IN ( +SELECT t1.col_int_key +FROM t1 LEFT JOIN ( t2 JOIN t3 ON t3.col_int_key = t2.col_int ) USING ( pk ) +WHERE t3.col_int IS NULL +) +ORDER BY col_int_key +; +col_int_key +0 +3 +8 +900000000 +1368719360 +1922236416 +DROP TABLE t1, t2, t3, t4; +# +# Bug#20835095 CRASH AT CREATE_REF_FOR_KEY IN SQL/SQL_SELECT.CC +# +CREATE TABLE t1 ( +pk INTEGER, +var_10_latin1 VARCHAR(10) CHARACTER SET latin1, +var_255_utf8 VARCHAR(255) CHARACTER SET utf8, +var_255_latin1 VARCHAR(255) CHARACTER SET latin1, +var_10_utf8 VARCHAR(10) CHARACTER SET utf8, +PRIMARY KEY (pk) +); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +CREATE VIEW v1 AS SELECT * FROM t1; +INSERT INTO t1 VALUES +(1,'FROCJ','korrhrspki','UAYVL','BPZIS'), +(2,'him','a','CHYKN','OZZQT'), +(3,'WBITK','ULWBF','have','rhrh'), +(4,'or','right','up','it'), +(5,'GGDCP','x','who','as'), +(6,'j','i','e','w'); +CREATE TABLE tv +SELECT var_255_utf8 AS field1 +FROM t1; +EXPLAIN SELECT * FROM tv +WHERE field1 IN ( +SELECT tv1.var_255_utf8 +FROM v1 AS tv1 LEFT JOIN v1 AS tv2 ON tv1.var_10_latin1=tv2.var_10_utf8); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE tv NULL ALL NULL NULL NULL NULL 6 100.00 Using where +1 SIMPLE NULL eq_ref 768 test.tv.field1 1 100.00 NULL +2 MATERIALIZED t1 NULL ALL NULL NULL NULL NULL 6 100.00 NULL +2 MATERIALIZED t1 NULL ALL NULL NULL NULL NULL 6 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tv`.`field1` AS `field1` from `test`.`tv` semi join (`test`.`t1` left join (`test`.`t1`) on((`test`.`t1`.`var_10_latin1` = `test`.`t1`.`var_10_utf8`))) where (``.`var_255_utf8` = `test`.`tv`.`field1`) +SELECT * FROM tv +WHERE field1 IN ( +SELECT tv1.var_255_utf8 +FROM v1 AS tv1 LEFT JOIN v1 AS tv2 ON tv1.var_10_latin1=tv2.var_10_utf8); +field1 +korrhrspki +a +ULWBF +right +x +i +DROP VIEW v1; +DROP TABLE t1, tv; +# 17832047 Crash in calculate_materialization_costs +CREATE TABLE t1(a INTEGER PRIMARY KEY); +INSERT INTO t1 VALUES (0),(1),(2); +SELECT 1 FROM t1 +WHERE 1 IN +(SELECT 1 BETWEEN (LENGTH(a) IN (SELECT 1 FROM t1)) AND 1 +FROM t1 +); +1 +1 +1 +1 +DROP TABLE t1; +# 17845989 Assertion failed: !(used_tables() & ... +CREATE TABLE a(b INTEGER) engine=innodb; +CREATE TABLE c(a INTEGER) engine=innodb; +SELECT 1 +FROM a +WHERE 1 IN (SELECT (a.b IS NULL) IN (SELECT 1 FROM c) FROM c) +; +1 +DROP TABLE a, c; +# +# Bug#18194196: OPTIMIZER EXECUTES STATEMENT INPERFORMANT +# +CREATE TABLE t1 (uid INTEGER, fid INTEGER, INDEX(uid)); +INSERT INTO t1 VALUES +(1,1), (1,2), (1,3), (1,4), +(2,5), (2,6), (2,7), (2,8), +(3,1), (3,2), (3,9); +CREATE TABLE t2 (uid INT PRIMARY KEY, name VARCHAR(128), INDEX(name)); +INSERT INTO t2 VALUES +(1, "A"), (2, "B"), (3, "C"), (4, "D"), (5, "E"), +(6, "F"), (7, "G"), (8, "H"), (9, "I"); +CREATE TABLE t3 (uid INT, fid INT, INDEX(uid)); +INSERT INTO t3 VALUES +(1,1), (1,2), (1,3),(1,4), +(2,5), (2,6), (2,7), (2,8), +(3,1), (3,2), (3,9); +CREATE TABLE t4 (uid INT PRIMARY KEY, name VARCHAR(128), INDEX(name)); +INSERT INTO t4 VALUES +(1, "A"), (2, "B"), (3, "C"), (4, "D"), (5, "E"), +(6, "F"), (7, "G"), (8, "H"), (9, "I"); +ANALYZE TABLE t1,t2,t3,t4; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +test.t4 analyze status OK +EXPLAIN SELECT name FROM t2, t1 +WHERE t1.uid IN (SELECT t4.uid FROM t4, t3 WHERE t3.uid=1 AND t4.uid=t3.fid) +AND t2.uid=t1.fid; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ref uid uid 5 const 4 100.00 Using where; Start temporary +1 SIMPLE t4 NULL eq_ref PRIMARY PRIMARY 4 test.t3.fid 1 100.00 Using index +1 SIMPLE t1 NULL ref uid uid 5 test.t3.fid 4 100.00 Using where; End temporary +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.fid 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`name` AS `name` from `test`.`t4` join `test`.`t2` join `test`.`t1` semi join (`test`.`t3`) where ((`test`.`t4`.`uid` = `test`.`t3`.`fid`) and (`test`.`t1`.`uid` = `test`.`t3`.`fid`) and (`test`.`t3`.`uid` = 1) and (`test`.`t2`.`uid` = `test`.`t1`.`fid`)) +FLUSH STATUS; +SELECT name FROM t2, t1 +WHERE t1.uid IN (SELECT t4.uid FROM t4, t3 WHERE t3.uid=1 AND t4.uid=t3.fid) +AND t2.uid=t1.fid; +name +A +A +B +B +C +D +E +F +G +H +I +SHOW STATUS LIKE '%handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 20 +Handler_read_last 0 +Handler_read_next 15 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +DROP TABLE t1,t2,t3,t4; +# End of test for Bug#18194196 +# +# Bug#21184091 ASSERT `READ_ROWS >= 0.0' AT +# COST_MODEL_SERVER::TMPTABLE_READWRITE_COST() +# +CREATE TABLE t1 ( +pk INTEGER, +col_varchar varchar(1), +col_int INTEGER, +PRIMARY KEY (pk) +) ENGINE=MyISAM; +CREATE TABLE t2 ( +col_int INTEGER, +col_varchar varchar(1) +) ENGINE=MyISAM; +INSERT INTO t2 VALUES (7,'x'); +INSERT INTO t2 VALUES (4,'z'); +SELECT t2.col_varchar +FROM t2 STRAIGHT_JOIN t1 ON t2.col_varchar = t1.col_varchar +JOIN t2 AS table3 ON t1.pk = table3.col_int +WHERE t1.pk IN (SELECT col_int FROM t1); +col_varchar +DROP TABLE t1,t2; +# End of test for Bug#21184091 +# Bug#21139722: Assertion failed: !(used_tables() & ((table_map) 1) ... +CREATE TABLE t1(a INTEGER) engine=innodb; +CREATE TABLE t2(b INTEGER) engine=innodb; +explain SELECT 1 +FROM (SELECT 1 IN (SELECT 1 +FROM t1 +WHERE (SELECT 1 FROM t2 HAVING b) NOT IN (SELECT 1 FROM t2) +) +FROM t2 +) AS z; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DERIVED t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +3 DEPENDENT SUBQUERY t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +5 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +4 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1276 Field or reference 'b' of SELECT #4 was resolved in SELECT #2 +Note 1003 /* select#1 */ select 1 AS `1` from (/* select#2 */ select (1,(/* select#3 */ select 1 from `test`.`t1` where ((/* select#4 */ select 1 from `test`.`t2` having (0 <> `test`.`t2`.`b`)),(/* select#5 */ select 1 from `test`.`t2` where (outer_field_is_not_null, (((/* select#4 */ select 1 from `test`.`t2` having (0 <> `test`.`t2`.`b`))) = 1), true)) is false))) AS `1 IN (SELECT 1 +FROM t1 +WHERE (SELECT 1 FROM t2 HAVING b) NOT IN (SELECT 1 FROM t2) +)` from `test`.`t2`) `z` +SELECT 1 +FROM (SELECT 1 IN (SELECT 1 +FROM t1 +WHERE (SELECT 1 FROM t2 HAVING b) NOT IN (SELECT 1 FROM t2) +) +FROM t2 +) AS z; +1 +DROP TABLE t1, t2; +CREATE TABLE t1(a INTEGER) engine=innodb; +explain SELECT (SELECT a FROM t1 AS t2 +WHERE a IN (SELECT t1.a+t2.a FROM t1 AS t3)) +FROM t1 AS t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 DEPENDENT SUBQUERY t3 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #3 was resolved in SELECT #1 +Note 1276 Field or reference 'test.t2.a' of SELECT #3 was resolved in SELECT #2 +Note 1003 /* select#1 */ select (/* select#2 */ select `test`.`t2`.`a` from `test`.`t1` `t2` semi join (`test`.`t1` `t3`) where (`test`.`t2`.`a` = (`test`.`t1`.`a` + `test`.`t2`.`a`))) AS `(SELECT a FROM t1 AS t2 +WHERE a IN (SELECT t1.a+t2.a FROM t1 AS t3))` from `test`.`t1` +SELECT (SELECT a FROM t1 AS t2 +WHERE a IN (SELECT t1.a+t2.a FROM t1 AS t3)) +FROM t1 AS t1; +(SELECT a FROM t1 AS t2 +WHERE a IN (SELECT t1.a+t2.a FROM t1 AS t3)) +DROP TABLE t1; +# End of test for Bug#21139722 +SET DEFAULT_STORAGE_ENGINE=INNODB; +# +# Bug#21139402 ASSERTION FAILED: LENGTH > 0 && KEYPARTS != 0, CRASH IN JOIN::OPTIMIZE_KEYUSE +# +CREATE TABLE t1 (a INT, b INT, PRIMARY KEY(a)); +CREATE TABLE t2 (c INT PRIMARY KEY); +EXPLAIN SELECT 1 FROM t1 +WHERE 1 IN +(SELECT (c IS NULL) IN (SELECT a FROM t1 WHERE b) FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +3 SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` semi join (`test`.`t2`) where false +SELECT 1 FROM t1 +WHERE 1 IN +(SELECT (c IS NULL) IN (SELECT a FROM t1 WHERE b) FROM t2); +1 +DROP TABLE t1,t2; +# +# Bug#21619634 ACCESS OF DEALLOCATED ITEM_OUTER_REF CAUSES CRASH: PREPARED STMT +# +create table cc (i int) engine="innodb"; +insert into cc values (1); +select (select count(i) from cc as cc_alias +where (cc.i in (select cc_alias.i from cc))) +from cc group by i; +(select count(i) from cc as cc_alias +where (cc.i in (select cc_alias.i from cc))) +1 +prepare stmt from +"select (select count(i) from cc as cc_alias + where (cc.i in (select cc_alias.i from cc))) + from cc group by i"; +execute stmt; +(select count(i) from cc as cc_alias + where (cc.i in (select cc_alias.i from cc))) +1 +execute stmt; +(select count(i) from cc as cc_alias + where (cc.i in (select cc_alias.i from cc))) +1 +drop table cc; +# +# Bug #22305361: QUERY WITH MATERIALIZED TABLE RETURNS INCORRECT +# RESULTS IN 5.6 +# +CREATE TABLE t(a INT,b INT); +INSERT INTO t VALUES (1,0),(1,0),(1,0),(1,0),(1,1); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +EXPLAIN SELECT * +FROM t AS t1 +WHERE t1.a IN (SELECT t2.a +FROM t AS t2 +WHERE CONCAT(t2.a,'') NOT IN (SELECT t3.a +FROM t AS t3 +WHERE t3.b=1)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 5 100.00 Using where +1 PRIMARY NULL eq_ref 5 test.t1.a 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 5 100.00 Using where +3 SUBQUERY t3 NULL ALL NULL NULL NULL NULL 5 20.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t` `t1` semi join (`test`.`t` `t2`) where ((``.`a` = `test`.`t1`.`a`) and (concat(`test`.`t2`.`a`,''),concat(`test`.`t2`.`a`,'') in ( (/* select#3 */ select `test`.`t3`.`a` from `test`.`t` `t3` where (`test`.`t3`.`b` = 1) having true ), (concat(`test`.`t2`.`a`,'') in on where ((concat(`test`.`t2`.`a`,'') = ``.`a`)))) is false)) +SELECT * +FROM t AS t1 +WHERE t1.a IN (SELECT t2.a +FROM t AS t2 +WHERE CONCAT(t2.a,'') NOT IN (SELECT t3.a +FROM t AS t3 +WHERE t3.b=1)); +a b +DROP TABLE t; +# +# Bug#24287772 SUBQUERY RETURNS EMPTY LIST WHILE IDENTICAL QUERY +# WITH JOIN RETURNS RESULT +# +CREATE TABLE t SELECT 4096 c; +SELECT c FROM t WHERE 1 IN +(SELECT t.c = page_size FROM information_schema.innodb_cmpmem); +c +4096 +DROP TABLE t; +# +# Bug #29132639: WL#12470: SIG 6 IN CONNECTJOINS|SQL/SQL_EXECUTOR.C +# +CREATE TABLE t1 ( f1 TIME, f2 VARCHAR(1) ); +INSERT INTO t1 VALUES ('08:35:24', 'X'), ('14:51:13', 'S'), ('11:22:33', 'Q'); +CREATE TABLE t2 ( pk INTEGER ); +INSERT INTO t2 VALUES (1), (2); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN FORMAT=tree SELECT * FROM t1 WHERE EXISTS ( SELECT alias1.f2 FROM t2 LEFT JOIN t1 ON 1 LEFT JOIN t1 AS alias1 ON 1 ); +EXPLAIN +-> Nested loop inner join (cost=12.30 rows=54) + -> Constant row from (cost=0.00..0.00 rows=1) + -> Materialize with deduplication (cost=6.65..6.65 rows=18) + -> Nested loop left join (cost=4.85 rows=18) + -> Nested loop left join (cost=1.55 rows=6) + -> Table scan on t2 (cost=0.45 rows=2) + -> Table scan on t1 (cost=0.40 rows=3) + -> Table scan on alias1 (cost=0.30 rows=3) + -> Table scan on t1 (cost=0.55 rows=3) + +SELECT * FROM t1 WHERE EXISTS ( SELECT alias1.f2 FROM t2 LEFT JOIN t1 ON 1 LEFT JOIN t1 AS alias1 ON 1 ); +f1 f2 +08:35:24 X +11:22:33 Q +14:51:13 S +DROP TABLE t1, t2; +set optimizer_switch=default; +set optimizer_switch=default; diff --git a/mysql-test/r/truth_value_transform.result-pq b/mysql-test/r/truth_value_transform.result-pq new file mode 100644 index 000000000000..80aed4a211fa --- /dev/null +++ b/mysql-test/r/truth_value_transform.result-pq @@ -0,0 +1,83 @@ +create table t1(id int, a int); +insert into t1 values(1,1),(2,2),(3,null); +analyze table t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +explain select id, a=1 is false from t1 ; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,((`test`.`t1`.`a` = 1) is false) AS `a=1 is false` from `test`.`t1` +select id, a=1 is false from t1 ; +id a=1 is false +1 0 +2 1 +3 0 +explain select id, not (a=1 is true) from t1 ; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,((`test`.`t1`.`a` = 1) is not true) AS `not (a=1 is true)` from `test`.`t1` +select id, not (a=1 is true) from t1 ; +id not (a=1 is true) +1 0 +2 1 +3 1 +explain select id, (not a=1) is true from t1 ; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,((`test`.`t1`.`a` <> 1) is true) AS `(not a=1) is true` from `test`.`t1` +select id, (not a=1) is true from t1 ; +id (not a=1) is true +1 0 +2 1 +3 0 +explain select id, not (a=1 is false) from t1 ; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,((`test`.`t1`.`a` = 1) is not false) AS `not (a=1 is false)` from `test`.`t1` +select id, not (a=1 is false) from t1 ; +id not (a=1 is false) +1 1 +2 0 +3 1 +explain select id, not (a=1 is unknown) from t1 ; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,((`test`.`t1`.`a` = 1) is not null) AS `not (a=1 is unknown)` from `test`.`t1` +select id, not (a=1 is unknown) from t1 ; +id not (a=1 is unknown) +1 1 +2 1 +3 0 +explain select id, ((not a=1) is true) is false from t1 ; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,((`test`.`t1`.`a` <> 1) is not true) AS `((not a=1) is true) is false` from `test`.`t1` +select id, ((not a=1) is true) is false from t1 ; +id ((not a=1) is true) is false +1 1 +2 0 +3 1 +explain select id, 3 + (not (a=1 is false)) from t1 ; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,(3 + ((`test`.`t1`.`a` = 1) is not false)) AS `3 + (not (a=1 is false))` from `test`.`t1` +select id, 3 + (not (a=1 is false)) from t1 ; +id 3 + (not (a=1 is false)) +1 4 +2 3 +3 4 +drop table t1; diff --git a/mysql-test/r/type_bit_innodb.result-pq b/mysql-test/r/type_bit_innodb.result-pq new file mode 100644 index 000000000000..fec36ddc8663 --- /dev/null +++ b/mysql-test/r/type_bit_innodb.result-pq @@ -0,0 +1,446 @@ +select 0 + b'1'; +0 + b'1' +1 +select 0 + b'0'; +0 + b'0' +0 +select 0 + b'000001'; +0 + b'000001' +1 +select 0 + b'000011'; +0 + b'000011' +3 +select 0 + b'000101'; +0 + b'000101' +5 +select 0 + b'000000'; +0 + b'000000' +0 +select 0 + b'10000000'; +0 + b'10000000' +128 +select 0 + b'11111111'; +0 + b'11111111' +255 +select 0 + b'10000001'; +0 + b'10000001' +129 +select 0 + b'1000000000000000'; +0 + b'1000000000000000' +32768 +select 0 + b'1111111111111111'; +0 + b'1111111111111111' +65535 +select 0 + b'1000000000000001'; +0 + b'1000000000000001' +32769 +drop table if exists t1; +create table t1 (a bit(65)) engine=innodb; +ERROR 42000: Display width out of range for column 'a' (max = 64) +create table t1 (a bit(0)) engine=innodb; +ERROR HY000: Invalid size for column 'a'. +create table t1 (a bit(64)) engine=innodb; +insert into t1 values +(b'1111111111111111111111111111111111111111111111111111111111111111'), +(b'1000000000000000000000000000000000000000000000000000000000000000'), +(b'0000000000000000000000000000000000000000000000000000000000000001'), +(b'1010101010101010101010101010101010101010101010101010101010101010'), +(b'0101010101010101010101010101010101010101010101010101010101010101'); +select hex(a) from t1; +hex(a) +FFFFFFFFFFFFFFFF +8000000000000000 +1 +AAAAAAAAAAAAAAAA +5555555555555555 +drop table t1; +create table t1 (a bit) engine=innodb; +insert ignore into t1 values (b'0'), (b'1'), (b'000'), (b'100'), (b'001'); +Warnings: +Warning 1406 Data too long for column 'a' at row 4 +select hex(a) from t1; +hex(a) +0 +1 +0 +1 +1 +alter table t1 add unique (a); +ERROR 23000: Duplicate entry '\x01' for key 't1.a' +drop table t1; +create table t1 (a bit(2)) engine=innodb; +insert ignore into t1 values (b'00'), (b'01'), (b'10'), (b'100'); +Warnings: +Warning 1406 Data too long for column 'a' at row 4 +select a+0 from t1; +a+0 +0 +1 +2 +3 +alter table t1 add key (a); +analyze table t1; +explain select a+0 from t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL a 2 NULL 4 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select (`test`.`t1`.`a` + 0) AS `a+0` from `test`.`t1` +select a+0 from t1; +a+0 +0 +1 +2 +3 +drop table t1; +create table t1 (a bit(7), b bit(9), key(a, b)) engine=innodb; +insert into t1 values +(94, 46), (31, 438), (61, 152), (78, 123), (88, 411), (122, 118), (0, 177), +(75, 42), (108, 67), (79, 349), (59, 188), (68, 206), (49, 345), (118, 380), +(111, 368), (94, 468), (56, 379), (77, 133), (29, 399), (9, 363), (23, 36), +(116, 390), (119, 368), (87, 351), (123, 411), (24, 398), (34, 202), (28, 499), +(30, 83), (5, 178), (60, 343), (4, 245), (104, 280), (106, 446), (127, 403), +(44, 307), (68, 454), (57, 135); +analyze table t1; +explain select a+0 from t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 38 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL a 5 NULL 38 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select (`test`.`t1`.`a` + 0) AS `a+0` from `test`.`t1` +select a+0 from t1; +a+0 +0 +104 +106 +108 +111 +116 +118 +119 +122 +123 +127 +23 +24 +28 +29 +30 +31 +34 +4 +44 +49 +5 +56 +57 +59 +60 +61 +68 +68 +75 +77 +78 +79 +87 +88 +9 +94 +94 +explain select b+0 from t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 38 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL a 5 NULL 38 100.00 Using index +Note 1003 /* select#1 */ select (`test`.`t1`.`b` + 0) AS `b+0` from `test`.`t1` +Warnings: +select b+0 from t1; +b+0 +118 +123 +133 +135 +152 +177 +178 +188 +202 +206 +245 +280 +307 +343 +345 +349 +351 +36 +363 +368 +368 +379 +380 +390 +398 +399 +403 +411 +411 +42 +438 +446 +454 +46 +468 +499 +67 +83 +explain select a+0, b+0 from t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 38 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL a 5 NULL 38 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select (`test`.`t1`.`a` + 0) AS `a+0`,(`test`.`t1`.`b` + 0) AS `b+0` from `test`.`t1` +select a+0, b+0 from t1; +a+0 b+0 +0 177 +104 280 +106 446 +108 67 +111 368 +116 390 +118 380 +119 368 +122 118 +123 411 +127 403 +23 36 +24 398 +28 499 +29 399 +30 83 +31 438 +34 202 +4 245 +44 307 +49 345 +5 178 +56 379 +57 135 +59 188 +60 343 +61 152 +68 206 +68 454 +75 42 +77 133 +78 123 +79 349 +87 351 +88 411 +9 363 +94 46 +94 468 +explain select a+0, b+0 from t1 where a > 40 and b > 200 order by 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 27 33.33 Parallel execute (1 workers) +2 SIMPLE t1 NULL range a a 2 NULL 27 33.33 Using where; Using index; Using filesort +Warnings: +Note 1003 /* select#1 */ select (`test`.`t1`.`a` + 0) AS `a+0`,(`test`.`t1`.`b` + 0) AS `b+0` from `test`.`t1` where ((`test`.`t1`.`a` > 40) and (`test`.`t1`.`b` > 200)) order by `a+0` +select a+0, b+0 from t1 where a > 40 and b > 200 order by 1; +a+0 b+0 +44 307 +49 345 +56 379 +60 343 +68 206 +68 454 +79 349 +87 351 +88 411 +94 468 +104 280 +106 446 +111 368 +116 390 +118 380 +119 368 +123 411 +127 403 +explain select a+0, b+0 from t1 where a > 40 and a < 70 order by 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 9 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range a a 2 NULL 9 100.00 Using where; Using index; Using filesort +Warnings: +Note 1003 /* select#1 */ select (`test`.`t1`.`a` + 0) AS `a+0`,(`test`.`t1`.`b` + 0) AS `b+0` from `test`.`t1` where ((`test`.`t1`.`a` > 40) and (`test`.`t1`.`a` < 70)) order by `b+0` +select a+0, b+0 from t1 where a > 40 and a < 70 order by 2; +a+0 b+0 +57 135 +61 152 +59 188 +68 206 +44 307 +60 343 +49 345 +56 379 +68 454 +select hex(min(a)) from t1; +hex(min(a)) +0 +select hex(min(b)) from t1; +hex(min(b)) +24 +select hex(min(a)), hex(max(a)), hex(min(b)), hex(max(b)) from t1; +hex(min(a)) hex(max(a)) hex(min(b)) hex(max(b)) +0 7F 24 1F3 +drop table t1; +create table t1 (a int not null, b bit, c bit(9), key(a, b, c)) engine=innodb; +insert into t1 values +(4, NULL, 1), (4, 0, 3), (2, 1, 4), (1, 1, 100), (4, 0, 23), (4, 0, 54), +(56, 0, 22), (4, 1, 100), (23, 0, 1), (4, 0, 34); +select a+0, b+0, c+0 from t1; +a+0 b+0 c+0 +1 1 100 +2 1 4 +23 0 1 +4 0 23 +4 0 3 +4 0 34 +4 0 54 +4 1 100 +4 NULL 1 +56 0 22 +select hex(min(b)) from t1 where a = 4; +hex(min(b)) +0 +select hex(min(c)) from t1 where a = 4 and b = 0; +hex(min(c)) +3 +select hex(max(b)) from t1; +hex(max(b)) +1 +select a+0, b+0, c+0 from t1 where a = 4 and b = 0 limit 2; +a+0 b+0 c+0 +4 0 3 +4 0 23 +select a+0, b+0, c+0 from t1 where a = 4 and b = 1; +a+0 b+0 c+0 +4 1 100 +select a+0, b+0, c+0 from t1 where a = 4 and b = 1 and c=100; +a+0 b+0 c+0 +4 1 100 +select b+0, a+0, c+0 from t1 order by b desc; +b+0 a+0 c+0 +1 1 100 +1 2 4 +1 4 100 +0 23 1 +0 4 23 +0 4 3 +0 4 34 +0 4 54 +0 56 22 +NULL 4 1 +select c+0, a+0, b+0 from t1 order by c; +c+0 a+0 b+0 +1 23 0 +1 4 NULL +3 4 0 +4 2 1 +22 56 0 +23 4 0 +34 4 0 +54 4 0 +100 1 1 +100 4 1 +drop table t1; +create table t1(a bit(2), b bit(2)) engine=innodb; +insert into t1 (a) values (0x01), (0x03), (0x02); +update t1 set b= concat(a); +select a+0, b+0 from t1; +a+0 b+0 +1 1 +3 3 +2 2 +drop table t1; +create table t1 (a bit(7), key(a)) engine=innodb; +insert into t1 values (44), (57); +select a+0 from t1; +a+0 +44 +57 +drop table t1; +create table t1 (a bit(3), b bit(12)) engine=innodb; +insert into t1 values (7,(1<<12)-2), (0x01,0x01ff); +select hex(a),hex(b) from t1; +hex(a) hex(b) +7 FFE +1 1FF +select hex(concat(a)),hex(concat(b)) from t1; +hex(concat(a)) hex(concat(b)) +07 0FFE +01 01FF +drop table t1; +create table t1(a int, b bit not null) engine=innodb; +alter table t1 add primary key (a); +drop table t1; +create table t1 (a bit, b bit(10)) engine=innodb; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` bit(1) DEFAULT NULL, + `b` bit(10) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +alter table t1 engine=heap; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` bit(1) DEFAULT NULL, + `b` bit(10) DEFAULT NULL +) ENGINE=MEMORY DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +alter table t1 engine=innodb; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` bit(1) DEFAULT NULL, + `b` bit(10) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +create table t1 (a bit(7)) engine=innodb; +insert into t1 values (0x60); +select * from t1; +Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr +def test t1 t1 a a 16 7 1 Y 32 0 63 +a +` +drop table t1; +End of 5.0 tests +# +# Bug #31564742 LOST ULLONG_MAX VALUE IN TABLE WITH TYPE OF BIT(64) +# +CREATE TABLE t1 (a BIT(64)); +INSERT INTO t1 VALUES +(b'1111111111111111111111111111111111111111111111111111111111111111'); +SELECT HEX(a) FROM t1 WHERE a = +b'1111111111111111111111111111111111111111111111111111111111111111'; +HEX(a) +FFFFFFFFFFFFFFFF +DROP TABLE t1; +# +# Bug #31019130 CASTING DOUBLE TO LONGLONG CAUSES UB +# IN FIELD_*::STORE(DOUBLE) +# +CREATE TABLE t_double (a double not null); +INSERT INTO t_double (a) VALUES +(-20000000000000000000000000000.0001), (20000000000000000000000000000.0001); +CREATE TABLE t_bit ( +b bit(3) +); +INSERT IGNORE INTO t_bit (b) SELECT a from t_double; +Warnings: +Warning 1406 Data too long for column 'b' at row 1 +Warning 1406 Data too long for column 'b' at row 2 +SELECT HEX(b) FROM t_bit; +HEX(b) +7 +7 +DROP TABLE t_double, t_bit; diff --git a/mysql-test/r/type_date.result-pq b/mysql-test/r/type_date.result-pq new file mode 100644 index 000000000000..b7532cea1110 --- /dev/null +++ b/mysql-test/r/type_date.result-pq @@ -0,0 +1,611 @@ +drop table if exists t1,t2; +create table t1 (a char(16), b date, c datetime); +insert into t1 SET a='test 2000-01-01', b='2000-01-01', c='2000-01-01'; +select * from t1 where c = '2000-01-01'; +a b c +test 2000-01-01 2000-01-01 2000-01-01 00:00:00 +select * from t1 where b = '2000-01-01'; +a b c +test 2000-01-01 2000-01-01 2000-01-01 00:00:00 +drop table t1; +CREATE TABLE t1 (name char(6),cdate date); +INSERT INTO t1 VALUES ('name1','1998-01-01'); +INSERT INTO t1 VALUES ('name2','1998-01-01'); +INSERT INTO t1 VALUES ('name1','1998-01-02'); +INSERT INTO t1 VALUES ('name2','1998-01-02'); +CREATE TABLE t2 (cdate date, note char(6)); +INSERT INTO t2 VALUES ('1998-01-01','note01'); +INSERT INTO t2 VALUES ('1998-01-02','note02'); +select name,t1.cdate,note from t1,t2 where t1.cdate=t2.cdate and t1.cdate='1998-01-01'; +name cdate note +name1 1998-01-01 note01 +name2 1998-01-01 note01 +drop table t1,t2; +CREATE TABLE t1 ( datum DATE ); +INSERT INTO t1 VALUES ( "2000-1-1" ); +INSERT INTO t1 VALUES ( "2000-1-2" ); +INSERT INTO t1 VALUES ( "2000-1-3" ); +INSERT INTO t1 VALUES ( "2000-1-4" ); +INSERT INTO t1 VALUES ( "2000-1-5" ); +SELECT * FROM t1 WHERE datum BETWEEN cast("2000-1-2" as date) AND cast("2000-1-4" as date); +datum +2000-01-02 +2000-01-03 +2000-01-04 +SELECT * FROM t1 WHERE datum BETWEEN cast("2000-1-2" as date) AND datum - INTERVAL 100 DAY; +datum +DROP TABLE t1; +CREATE TABLE t1 ( +user_id char(10), +summa int(11), +rdate date +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES ('aaa',100,'1998-01-01'); +INSERT INTO t1 VALUES ('aaa',200,'1998-01-03'); +INSERT INTO t1 VALUES ('bbb',50,'1998-01-02'); +INSERT INTO t1 VALUES ('bbb',200,'1998-01-04'); +select max(rdate) as s from t1 where rdate < '1998-01-03' having s> "1998-01-01"; +s +1998-01-02 +select max(rdate) as s from t1 having s="1998-01-04"; +s +1998-01-04 +select max(rdate+0) as s from t1 having s="19980104"; +s +19980104 +drop table t1; +create table t1 (date date); +insert into t1 values ("2000-08-10"),("2000-08-11"); +select date_add(date,INTERVAL 1 DAY),date_add(date,INTERVAL 1 SECOND) from t1; +date_add(date,INTERVAL 1 DAY) date_add(date,INTERVAL 1 SECOND) +2000-08-11 2000-08-10 00:00:01 +2000-08-12 2000-08-11 00:00:01 +drop table t1; +CREATE TABLE t1(AFIELD INT); +INSERT INTO t1 VALUES(1); +CREATE TABLE t2(GMT VARCHAR(32)); +INSERT INTO t2 VALUES('GMT-0800'); +SELECT DATE_FORMAT("2002-03-06 10:11:12", CONCAT('%a, %d %M %Y %H:%i:%s ', t2.GMT)) +FROM t1, t2 GROUP BY t1.AFIELD; +DATE_FORMAT("2002-03-06 10:11:12", CONCAT('%a, %d %M %Y %H:%i:%s ', t2.GMT)) +Wed, 06 March 2002 10:11:12 GMT-0800 +INSERT INTO t1 VALUES(1); +SELECT DATE_FORMAT("2002-03-06 10:11:12", CONCAT('%a, %d %M %Y %H:%i:%s ', t2.GMT)), +DATE_FORMAT("2002-03-06 10:11:12", CONCAT('%a, %d %M %Y %H:%i:%s ', t2.GMT)) +FROM t1,t2 GROUP BY t1.AFIELD; +DATE_FORMAT("2002-03-06 10:11:12", CONCAT('%a, %d %M %Y %H:%i:%s ', t2.GMT)) DATE_FORMAT("2002-03-06 10:11:12", CONCAT('%a, %d %M %Y %H:%i:%s ', t2.GMT)) +Wed, 06 March 2002 10:11:12 GMT-0800 Wed, 06 March 2002 10:11:12 GMT-0800 +drop table t1,t2; +CREATE TABLE t1 (f1 time default NULL, f2 time default NULL); +INSERT INTO t1 (f1, f2) VALUES ('09:00', '12:00'); +SELECT DATE_FORMAT(f1, "%l.%i %p") , DATE_FORMAT(f2, "%l.%i %p") FROM t1; +DATE_FORMAT(f1, "%l.%i %p") DATE_FORMAT(f2, "%l.%i %p") +9.00 AM 12.00 PM +DROP TABLE t1; +CREATE TABLE t1 (f1 DATE); +CREATE TABLE t2 (f2 VARCHAR(8)); +CREATE TABLE t3 (f2 CHAR(8)); +INSERT INTO t1 VALUES ('1978-11-26'); +INSERT INTO t2 SELECT f1+0 FROM t1; +INSERT INTO t2 SELECT f1+0 FROM t1 UNION SELECT f1+0 FROM t1; +INSERT INTO t3 SELECT f1+0 FROM t1; +INSERT INTO t3 SELECT f1+0 FROM t1 UNION SELECT f1+0 FROM t1; +SELECT * FROM t2; +f2 +19781126 +19781126 +SELECT * FROM t3; +f2 +19781126 +19781126 +DROP TABLE t1, t2, t3; +CREATE TABLE t1 (y YEAR); +INSERT IGNORE INTO t1 VALUES ('abc'); +Warnings: +Warning 1366 Incorrect integer value: 'abc' for column 'y' at row 1 +SELECT * FROM t1; +y +0000 +DROP TABLE t1; +create table t1(start_date date, end_date date); +insert into t1 values ('2000-01-01','2000-01-02'); +select 1 from t1 where cast('2000-01-01 12:01:01' as datetime) between start_date and end_date; +1 +1 +drop table t1; +select @d:=1111; +@d:=1111 +1111 +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +select year(@d), month(@d), day(@d), cast(@d as date); +year(@d) month(@d) day(@d) cast(@d as date) +2000 11 11 2000-11-11 +select @d:=011111; +@d:=011111 +11111 +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +select year(@d), month(@d), day(@d), cast(@d as date); +year(@d) month(@d) day(@d) cast(@d as date) +2001 11 11 2001-11-11 +select @d:=1311; +@d:=1311 +1311 +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +select year(@d), month(@d), day(@d), cast(@d as date); +year(@d) month(@d) day(@d) cast(@d as date) +NULL NULL NULL NULL +Warnings: +Warning 1292 Incorrect datetime value: '1311' +Warning 1292 Incorrect datetime value: '1311' +Warning 1292 Incorrect datetime value: '1311' +Warning 1292 Incorrect datetime value: '1311' +create table t1 (d date , dt datetime , ts timestamp); +insert ignore into t1 values (9912101,9912101,9912101); +Warnings: +Warning 1265 Data truncated for column 'd' at row 1 +Warning 1265 Data truncated for column 'dt' at row 1 +Warning 1265 Data truncated for column 'ts' at row 1 +insert into t1 values (11111,11111,11111); +select * from t1; +d dt ts +0000-00-00 0000-00-00 00:00:00 0000-00-00 00:00:00 +2001-11-11 2001-11-11 00:00:00 2001-11-11 00:00:00 +drop table t1; +SET sql_mode='STRICT_TRANS_TABLES'; +Warnings: +Warning 3135 'NO_ZERO_DATE', 'NO_ZERO_IN_DATE' and 'ERROR_FOR_DIVISION_BY_ZERO' sql modes should be used with strict mode. They will be merged with strict mode in a future release. +CREATE TABLE t1 ( +a INT +); +INSERT INTO t1 VALUES (1); +INSERT INTO t1 VALUES (NULL); +SELECT str_to_date( '', a ) FROM t1; +str_to_date( '', a ) +0000-00-00 00:00:00.000000 +NULL +DROP TABLE t1; +SET sql_mode=default; +CREATE TABLE t1 (a DATE, b INT, PRIMARY KEY (a,b)); +INSERT INTO t1 VALUES (DATE(NOW()), 1); +SELECT COUNT(*) FROM t1 WHERE a = NOW(); +COUNT(*) +0 +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT COUNT(*) FROM t1 WHERE a = NOW(); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where multiple equal(now(), `test`.`t1`.`a`) +INSERT INTO t1 VALUES (DATE(NOW()), 2); +SELECT COUNT(*) FROM t1 WHERE a = NOW(); +COUNT(*) +0 +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT COUNT(*) FROM t1 WHERE a = NOW(); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where multiple equal(now(), `test`.`t1`.`a`) +SELECT COUNT(*) FROM t1 WHERE a = NOW() AND b = 1; +COUNT(*) +0 +EXPLAIN SELECT COUNT(*) FROM t1 WHERE a = NOW() AND b = 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables +ALTER TABLE t1 DROP PRIMARY KEY; +SELECT COUNT(*) FROM t1 WHERE a = NOW(); +COUNT(*) +0 +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT COUNT(*) FROM t1 WHERE a = NOW(); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 50.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`a` = (now())) +DROP TABLE t1; +CREATE TABLE t1 (a DATE); +CREATE TABLE t2 (a DATE); +CREATE INDEX i ON t1 (a); +INSERT IGNORE INTO t1 VALUES ('0000-00-00'),('0000-00-00'); +Warnings: +Warning 1264 Out of range value for column 'a' at row 1 +Warning 1264 Out of range value for column 'a' at row 2 +INSERT IGNORE INTO t2 VALUES ('0000-00-00'),('0000-00-00'); +Warnings: +Warning 1264 Out of range value for column 'a' at row 1 +Warning 1264 Out of range value for column 'a' at row 2 +SET sql_mode = 'ALLOW_INVALID_DATES'; +SELECT * FROM t1 WHERE a = '0000-00-00'; +a +0000-00-00 +0000-00-00 +SELECT * FROM t2 WHERE a = '0000-00-00'; +a +0000-00-00 +0000-00-00 +SET SQL_MODE=TRADITIONAL; +EXPLAIN SELECT * FROM t1 WHERE a = '0000-00-00'; +ERROR HY000: Incorrect DATE value: '0000-00-00' +SELECT * FROM t1 WHERE a = '0000-00-00'; +ERROR HY000: Incorrect DATE value: '0000-00-00' +SELECT * FROM t2 WHERE a = '0000-00-00'; +ERROR HY000: Incorrect DATE value: '0000-00-00' +INSERT INTO t1 VALUES ('0000-00-00'); +ERROR 22007: Incorrect date value: '0000-00-00' for column 'a' at row 1 +SET SQL_MODE=DEFAULT; +DROP TABLE t1,t2; +SET sql_mode = 'ALLOW_INVALID_DATES'; +CREATE TABLE t1 (a DATE); +CREATE TABLE t2 (a DATE); +CREATE INDEX i ON t1 (a); +INSERT IGNORE INTO t1 VALUES ('1000-00-00'),('1000-00-00'); +INSERT IGNORE INTO t2 VALUES ('1000-00-00'),('1000-00-00'); +SELECT * FROM t1 WHERE a = '1000-00-00'; +a +1000-00-00 +1000-00-00 +SELECT * FROM t2 WHERE a = '1000-00-00'; +a +1000-00-00 +1000-00-00 +SET SQL_MODE=TRADITIONAL; +EXPLAIN SELECT * FROM t1 WHERE a = '1000-00-00'; +ERROR HY000: Incorrect DATE value: '1000-00-00' +SELECT * FROM t1 WHERE a = '1000-00-00'; +ERROR HY000: Incorrect DATE value: '1000-00-00' +SELECT * FROM t2 WHERE a = '1000-00-00'; +ERROR HY000: Incorrect DATE value: '1000-00-00' +INSERT INTO t1 VALUES ('1000-00-00'); +ERROR 22007: Incorrect date value: '1000-00-00' for column 'a' at row 1 +SET SQL_MODE=DEFAULT; +DROP TABLE t1,t2; +CREATE TABLE t1 SELECT curdate() AS f1; +SELECT hour(f1), minute(f1), second(f1) FROM t1; +hour(f1) minute(f1) second(f1) +0 0 0 +DROP TABLE t1; +End of 5.0 tests +create table t1 (a date, primary key (a))engine=memory; +insert into t1 values ('0000-01-01'), ('0000-00-01'), ('0001-01-01'); +Warnings: +Warning 1264 Out of range value for column 'a' at row 2 +select * from t1 where a between '0000-00-01' and '0000-00-02'; +a +0000-00-00 +Warnings: +Warning 1292 Incorrect date value: '0000-00-01' for column 'a' at row 1 +Warning 1292 Incorrect date value: '0000-00-02' for column 'a' at row 1 +Warning 1292 Incorrect date value: '0000-00-01' for column 'a' at row 1 +Warning 1292 Incorrect date value: '0000-00-02' for column 'a' at row 1 +Warning 1292 Incorrect date value: '0000-00-01' for column 'a' at row 2 +Warning 1292 Incorrect date value: '0000-00-02' for column 'a' at row 2 +drop table t1; +# +# Bug#50918: Date columns treated differently in Views than in Base +# Tables +# +CREATE TABLE t1 ( the_date DATE, the_time TIME ); +INSERT INTO t1 VALUES ( '2010-01-01', '01:01:01' ); +SELECT * FROM t1 t11 JOIN t1 t12 ON addtime( t11.the_date, t11.the_time ) = +addtime( t12.the_date, t12.the_time ); +the_date the_time the_date the_time +2010-01-01 01:01:01 2010-01-01 01:01:01 +CREATE VIEW v1 AS SELECT * FROM t1; +SELECT * FROM t1 JOIN v1 ON addtime( t1.the_date, t1.the_time ) = +addtime( v1.the_date, v1.the_time ); +the_date the_time the_date the_time +2010-01-01 01:01:01 2010-01-01 01:01:01 +SELECT * FROM t1 JOIN v1 ON addtime( t1.the_date, t1.the_time ) = +addtime( cast(v1.the_date AS DATETIME), v1.the_time ); +the_date the_time the_date the_time +2010-01-01 01:01:01 2010-01-01 01:01:01 +DROP TABLE t1; +DROP VIEW v1; +# +# Bug#59685 crash in String::length with date types +# +CREATE TABLE t1(a DATE, b YEAR, KEY(a)); +INSERT INTO t1 VALUES ('2011-01-01',2011); +SELECT b = CONVERT(a, DATE) FROM t1; +b = CONVERT(a, DATE) +0 +SELECT b = (SELECT CONVERT(a, DATE) FROM t1 GROUP BY a) FROM t1; +b = (SELECT CONVERT(a, DATE) FROM t1 GROUP BY a) +0 +SELECT b = CONVERT((SELECT CONVERT(a, DATE) FROM t1 GROUP BY a), DATE) FROM t1; +b = CONVERT((SELECT CONVERT(a, DATE) FROM t1 GROUP BY a), DATE) +0 +DROP TABLE t1; +End of 5.1 tests +# +# Bug #33629: last_day function can return null, but has 'not null' +# flag set for result +# +SELECT 1 FROM (SELECT LAST_DAY('0')) a; +1 +1 +Warnings: +Warning 1292 Incorrect datetime value: '0' +SELECT 1 FROM (SELECT MAKEDATE(2011,0)) a; +1 +1 +CREATE TABLE t1 AS +SELECT LAST_DAY('1970-01-01') AS f1, +MAKEDATE(1970, 1) AS f2; +DESCRIBE t1; +Field Type Null Key Default Extra +f1 date YES NULL +f2 date YES NULL +DROP TABLE t1; +# +# +# Bug#57278: Crash on min/max + with date out of range. +# +set @a=(select min(makedate('111','1'))) ; +select @a; +@a +0111-01-01 +# +# +# WL#946: testing rounding from DATETIME/TIME to DATE +# +SET timestamp=UNIX_TIMESTAMP('2001-01-01 00:00:00'); +CREATE TABLE t1 (a DATE); +INSERT INTO t1 VALUES ('2001-01-01 23:59:59.4'); +Warnings: +Note 1292 Incorrect date value: '2001-01-01 23:59:59.4' for column 'a' at row 1 +INSERT INTO t1 VALUES (TIMESTAMP'2001-01-01 23:59:59.4'); +Warnings: +Note 1292 Incorrect date value: '2001-01-01 23:59:59' for column 'a' at row 1 +INSERT INTO t1 VALUES (20010101235959.4); +Warnings: +Note 1292 Incorrect date value: '20010101235959.4' for column 'a' at row 1 +INSERT INTO t1 VALUES (TIME'23:59:59.4'); +Warnings: +Note 1292 Incorrect date value: '23:59:59' for column 'a' at row 1 +INSERT INTO t1 VALUES +(TIMESTAMP'9999-12-30 23:59:59.4'), +(TIMESTAMP'9999-12-31 23:59:59.4'); +Warnings: +Note 1292 Incorrect date value: '9999-12-30 23:59:59' for column 'a' at row 1 +Note 1292 Incorrect date value: '9999-12-31 23:59:59' for column 'a' at row 2 +SELECT * FROM t1; +a +2001-01-01 +2001-01-01 +2001-01-01 +2001-01-01 +9999-12-30 +9999-12-31 +DROP TABLE t1; +SET timestamp=DEFAULT; +SET timestamp=UNIX_TIMESTAMP('2001-01-01 00:00:00'); +CREATE TABLE t1 (a DATE); +INSERT INTO t1 VALUES ('2001-01-01 23:59:59.9'); +INSERT INTO t1 VALUES (TIMESTAMP'2001-01-01 23:59:59.9'); +INSERT INTO t1 VALUES (20010101235959.9); +INSERT INTO t1 VALUES (TIME'23:59:59.9'); +INSERT INTO t1 VALUES +(TIMESTAMP'9999-12-30 23:59:59.9'), +(TIMESTAMP'9999-12-31 23:59:59.9'); +ERROR 22008: Datetime function: datetime field overflow +SELECT * FROM t1; +a +2001-01-02 +2001-01-02 +2001-01-02 +2001-01-02 +DROP TABLE t1; +SET timestamp=DEFAULT; +# +# Testing cast from DECIMAL to DATE +# +CREATE TABLE t1 (a DECIMAL(23,4)); +INSERT INTO t1 VALUES (NULL),(101010.9999),(-101010.9999); +SELECT a, CAST(a AS DATE) FROM t1; +a CAST(a AS DATE) +NULL NULL +101010.9999 2010-10-10 +-101010.9999 NULL +Warnings: +Warning 1292 Incorrect datetime value: '-101010.9999' +DROP TABLE t1; +# +# Testing CASE with DATE type without a found item +# +SELECT CAST(CASE WHEN 0 THEN '2001-01-01' END AS DATE); +CAST(CASE WHEN 0 THEN '2001-01-01' END AS DATE) +NULL +SELECT CAST(CASE WHEN 0 THEN DATE'2001-01-01' END AS DATE); +CAST(CASE WHEN 0 THEN DATE'2001-01-01' END AS DATE) +NULL +# +# Testing DATE field with NULL value with NOT IN +# +CREATE TABLE t1 (a DATE); +INSERT INTO t1 VALUES (NULL); +SELECT * FROM t1 WHERE a NOT IN (DATE'2001-01-01',DATE'2002-02-02'); +a +DROP TABLE t1; +# +# Testing COALESCE with DATE type without a found item +# +SELECT COALESCE(DATE(NULL)); +COALESCE(DATE(NULL)) +NULL +# +# Testing Item_func_min_max::val_str when DATE type and NULL +# +SELECT CAST(LEAST(DATE(NULL), DATE(NULL)) AS CHAR); +CAST(LEAST(DATE(NULL), DATE(NULL)) AS CHAR) +NULL +# +# Testing Item_func_min_max::get_date with non-temporal arguments +# +SELECT CAST(LEAST(20010101,20020202) AS DATE); +CAST(LEAST(20010101,20020202) AS DATE) +2001-01-01 +# +# Item::get_date_from_numeric +# +SELECT CAST(SUM(0) AS DATETIME); +CAST(SUM(0) AS DATETIME) +NULL +Warnings: +Warning 1292 Incorrect datetime value: '0' +SELECT CAST(SUM(0 + 0e0) AS DATETIME); +CAST(SUM(0 + 0e0) AS DATETIME) +NULL +Warnings: +Warning 1292 Incorrect datetime value: '0' +SET timestamp=1322115004; +SELECT CAST(UNIX_TIMESTAMP() AS DATE); +CAST(UNIX_TIMESTAMP() AS DATE) +NULL +Warnings: +Warning 1292 Incorrect datetime value: '1322115004' +SET timestamp=DEFAULT; +# +# Item::get_date_from_non_temporal +# +SELECT DATE(20110512154559.6 + 0e0); +DATE(20110512154559.6 + 0e0) +2011-05-12 +# +# Item_name_const::get_date +# +SELECT DATE(NAME_CONST('a', 0)); +DATE(NAME_CONST('a', 0)) +NULL +Warnings: +Warning 1292 Incorrect datetime value: '0' +# +# Item_cache_datetime::get_date +# +SET timestamp=UNIX_TIMESTAMP('2011-11-24'); +CREATE TABLE t1 (a TIME); +INSERT INTO t1 VALUES (0); +SELECT DATE(MIN(a)) FROM t1; +DATE(MIN(a)) +2011-11-24 +DROP TABLE t1; +SET timestamp=DEFAULT; +# +# Bug #13626019 DIFFERENCE IN OUTPUT BETWEEN 5.1 & 5.5 FOR A LAST_DAY IS +# NULL SELECT QUERY +# +CREATE TABLE t1(a INT) ENGINE=InnoDB; +CREATE TABLE t2(b CHAR(19)); +INSERT INTO t1 VALUES(1); +INSERT INTO t2 VALUES('0000-00-00 00:00:00'); +SELECT * FROM t1 WHERE LAST_DAY('0000-00-00 00:00:00') IS NULL; +a +1 +Warnings: +Warning 1292 Incorrect datetime value: '0000-00-00 00:00:00' +SELECT * FROM t1 WHERE +LAST_DAY((SELECT b FROM t2 WHERE b = '0000-00-00 00:00:00')) IS NULL; +a +1 +Warnings: +Warning 1292 Incorrect datetime value: '0000-00-00 00:00:00' +DROP TABLE t1,t2; +# +# Test for bug#11747847 - 34280: create table fails if NO_ZERO_DATE +# or NO_ZERO_IN_DATE SQL mode is set. +DROP TABLE IF EXISTS t1, t2, t3; +SET @org_mode=@@sql_mode; +#Table creation in strict mode with NO_ZERO_IN_DATE/NO_ZERO_DATE +SET @@sql_mode='NO_ZERO_DATE,STRICT_ALL_TABLES'; +Warnings: +Warning 3135 'NO_ZERO_DATE', 'NO_ZERO_IN_DATE' and 'ERROR_FOR_DIVISION_BY_ZERO' sql modes should be used with strict mode. They will be merged with strict mode in a future release. +CREATE TABLE t1 (c1 DATE DEFAULT 0); +ERROR 42000: Invalid default value for 'c1' +CREATE TABLE t1 (c1 DATE DEFAULT '0000-00-00'); +ERROR 42000: Invalid default value for 'c1' +SET @@sql_mode='NO_ZERO_IN_DATE,STRICT_ALL_TABLES'; +Warnings: +Warning 3135 'NO_ZERO_DATE', 'NO_ZERO_IN_DATE' and 'ERROR_FOR_DIVISION_BY_ZERO' sql modes should be used with strict mode. They will be merged with strict mode in a future release. +CREATE TABLE t1 (c1 DATE DEFAULT '2012-02-00'); +ERROR 42000: Invalid default value for 'c1' +#Table creation in non-strict mode but with NO_ZERO_DATE/NO_ZERO_IN_DATE +SET @@sql_mode='NO_ZERO_DATE'; +Warnings: +Warning 3135 'NO_ZERO_DATE', 'NO_ZERO_IN_DATE' and 'ERROR_FOR_DIVISION_BY_ZERO' sql modes should be used with strict mode. They will be merged with strict mode in a future release. +CREATE TABLE t1 (c1 DATE DEFAULT 0); +Warnings: +Warning 1264 Out of range value for column 'c1' at row 1 +CREATE TABLE t2 (c1 DATE DEFAULT '0000-00-00'); +Warnings: +Warning 1264 Out of range value for column 'c1' at row 1 +SET @@sql_mode='NO_ZERO_IN_DATE'; +Warnings: +Warning 3135 'NO_ZERO_DATE', 'NO_ZERO_IN_DATE' and 'ERROR_FOR_DIVISION_BY_ZERO' sql modes should be used with strict mode. They will be merged with strict mode in a future release. +CREATE TABLE t3 (c1 DATE DEFAULT '2012-02-00'); +Warnings: +Warning 1264 Out of range value for column 'c1' at row 1 +DROP TABLE t1, t2, t3; +#Table creation with out any SQL modes +SET @@sql_mode=''; +CREATE TABLE t1 (c1 DATE DEFAULT 0); +CREATE TABLE t2 (c1 DATE DEFAULT '0000-00-00'); +CREATE TABLE t3 (c1 DATE DEFAULT '2012-02-00'); +DROP TABLE t1, t2, t3; +CREATE TABLE t1 (c1 INT); +#Alter table in strict mode with NO_ZERO_DATE/NO_ZERO_IN_DATE +SET @@sql_mode='NO_ZERO_DATE,STRICT_ALL_TABLES'; +Warnings: +Warning 3135 'NO_ZERO_DATE', 'NO_ZERO_IN_DATE' and 'ERROR_FOR_DIVISION_BY_ZERO' sql modes should be used with strict mode. They will be merged with strict mode in a future release. +ALTER TABLE t1 ADD c2 DATE DEFAULT 0; +ERROR 42000: Invalid default value for 'c2' +ALTER TABLE t1 ADD c2 DATE DEFAULT '0000-00-00'; +ERROR 42000: Invalid default value for 'c2' +SET @@sql_mode='NO_ZERO_IN_DATE,STRICT_ALL_TABLES'; +Warnings: +Warning 3135 'NO_ZERO_DATE', 'NO_ZERO_IN_DATE' and 'ERROR_FOR_DIVISION_BY_ZERO' sql modes should be used with strict mode. They will be merged with strict mode in a future release. +ALTER TABLE t1 ADD c2 DATE DEFAULT '2012-02-00'; +ERROR 42000: Invalid default value for 'c2' +#Alter table in non-strict mode but with NO_ZERO_DATE/NO_ZERO_IN_DATE +SET @@sql_mode='NO_ZERO_DATE'; +Warnings: +Warning 3135 'NO_ZERO_DATE', 'NO_ZERO_IN_DATE' and 'ERROR_FOR_DIVISION_BY_ZERO' sql modes should be used with strict mode. They will be merged with strict mode in a future release. +ALTER TABLE t1 ADD c2 DATE DEFAULT 0; +Warnings: +Warning 1264 Out of range value for column 'c2' at row 1 +ALTER TABLE t1 ADD c3 DATE DEFAULT '0000-00-00'; +Warnings: +Warning 1264 Out of range value for column 'c2' at row 1 +Warning 1264 Out of range value for column 'c3' at row 1 +SET @@sql_mode='NO_ZERO_IN_DATE'; +Warnings: +Warning 3135 'NO_ZERO_DATE', 'NO_ZERO_IN_DATE' and 'ERROR_FOR_DIVISION_BY_ZERO' sql modes should be used with strict mode. They will be merged with strict mode in a future release. +ALTER TABLE t1 ADD c4 DATE DEFAULT '2012-02-00'; +Warnings: +Warning 1264 Out of range value for column 'c4' at row 1 +DROP TABLE t1; +CREATE TABLE t1 (c1 int); +#Alter table with out any SQL modes +SET @@sql_mode=''; +ALTER TABLE t1 ADD c2 DATE DEFAULT 0; +ALTER TABLE t1 ADD c3 DATE DEFAULT '0000-00-00'; +ALTER TABLE t1 ADD c4 DATE DEFAULT '2012-02-00'; +DROP TABLE t1; +SET @@sql_mode= @org_mode; +# END of Test for bug#11747847 - 34280 +End of 5.6 tests +CREATE TABLE t1(a int); +INSERT INTO t1 VALUE(15.00+adddate('2011-00-00', 1)); +ERROR 22007: Incorrect datetime value: '2011-00-00' +DROP TABLE t1; diff --git a/mysql-test/r/type_enum.result-pq b/mysql-test/r/type_enum.result-pq new file mode 100644 index 000000000000..bbcc6c749807 --- /dev/null +++ b/mysql-test/r/type_enum.result-pq @@ -0,0 +1,1975 @@ +DROP TABLE if exists t1; +SET sql_mode = 'NO_ENGINE_SUBSTITUTION'; +CREATE TABLE t1 ( +field enum('001001','001004','001010','001018','001019','001020','001021','001027','001028','001029','001030','001031','001100','002003','002004','002005','002007','002008','002009','002012','002013','002014','003002','003003','003004','003005','003006','003007','003008','003009','003010','003011','003012','003013','003014','003015','003016','003017','003018','003019','004002','004003','004005','004006','004007','004008','004010','004012','004014','004016','004017','004020','004021','004022','004023','004024','004025','004026','006002','006004','006006','006010','006011','006012','006013','006014','007001','007002','007003','007004','007005','007006','007007','007008','007009','007010','007011','007012','007013','007014','007015','007016','007017','007018','007019','007020','007021','007022','007023','007024','007025','007026','007027','007028','007029','007030','007031','007032','007033','007034','007035','007036','007037','007038','007039','007040','007043','007044','009001','009002','009004','009005','009006','009007','009008','009009','009010','009011','009012','009013','010002','010003','010004','010005','010006','010007','010008','010009','010010','010011','010012','010013','010015','010016','010017','010018','010019','010020','010021','010022','010023','010024','010025','010026','010027','010028','011001','011002','011003','011004','011006','011012','011013','011014','011015','011016','012017','012018','012019','012023','012027','012028','012029','012030','012031','012032','012033','012034','012035','012036','012037','012038','012039','014001','016002','016003','016004','016007','016010','016011','016016','016019','016020','016021','016022','016023','016024','016026','016027','016028','016029','016030','016031','016032','016033','016034','017002','018001','019002','019004','020001','020003','020004','020005','020006','020007','020008','020009','022001','022002','022003','023001','023002','023003','023004','023005','023006','023007','023008','023010','023011','023012','023017','023019','023020','023021','023025','023026','023027','023028','023029','023030','023031','023032','023033','023034','023035','025001','025003','025004','025005','025006','025007','025008','025009','025010','025011','025012','025013','025014','025015','025016','025017','025018','025019','025020','025021','025022','025023','025024','025025','025026','025027','025028','025029','025030','025031','025032','025033','025034','025035','025036','025037','025038','025039','025040','025041','025042','025043','025044','025045','025046','025047','025048','025049','025050','025051','025052','025053','025054','025055','025056','025057','025058','025059','025060','025061','025062','025063','027001','027002','027011','035008','035012','036001','037001','037003','037004','037005','037006','037007','037008','037009','038004','038005','038006','038007','038009','039001','039002','039003','039004','039005','039006','046001','046002','046003','046004','046005','046007','046008','046009','046010','046011','046012','046013','046014','047001','047002','048001','051001','051002','051003','051004','052001','052002','052005','053015','053016','053019','053020','053023','053024','053026','053028','053029','053033','053034','053036','053037','053038','053039','053041','053042','053043','053045','053046','053047','053048','053051','053052','053054','053055','053056','053057','053068','053069','053070','053073','053074','053075','053086','053094','053095','053096','053097','053098','053099','053100','053101','053102','053103','053104','053105','053107','053122','053123','053124','053125','053127','053128','054001','054002','054003','054004','054005','054006','054007','054009','054010','056001','056002','056003','056004','056005','056006','056009','056010','056011','056016','056017','056018','056019','056020','056021','056022','057001','057002','057003','057004','058002','058003','058004','058005','060001','060003','060004','060005','060006','060007','061002','061003','061004','061005','061006','069006','069007','069010','069011','069012','069013','069014','069015','069016','069017','069018','069020','069021','069022','069023','069024','071002','071003','071004','071005','071006','071008','071011','071013','071020','071021','071022','072001','073001','073002','073003','073004','074001','074002','074003','074004','074005','074006','074007','074008','074009','074010','074011','074012','075001','075007','076101','076102','076103','077001','077002','077003','077004','077006','077007','077008','077009','078005','079002','079003','079004','079005','079006','079007','081001','082006','082007','082011','082013','082014','082015','082016','082017','082021','082022','082023','082024','082025','082026','082027','082028','082029','082030','082031','082032','082033','082034','082035','082036','082037','082038','082039','082040','082041','082042','082043','082044','084001','084002','084003','084004','084005','084007','084008','084009','084011','084013','084014','084016','084017','084027','084031','084032','084033','084035','084036','084037','084038','084039','084040','084041','084042','084043','084044','084045','084046','084047','084048','084049','084050','084051','085001','085002','085003','085004','085005','085006','085007','085009','085011','085012','085013','085014','085015','085016','085017','085018','085019','085020','085021','085022','085023','085028','085029','085030','085031','085033','085034','085035','085036','085037','085038','085040','085041','085042','085043','085044','085045','085046','085047','085048','085063','085064','085065','085068','085070','085071','085073','085082','085083','085086','085088','085089','085090','085091','085092','085093','085094','085095','085096','085097','085098','085099','085100','085101','085102','085103','085104','085105','085106','085107','085108','085109','085110','085111','085112','085113','085115','085119','085120','085121','085122','085123','085124','085125','085126','085127','085128','085129','085130','085132','085133','085134','085135','085136','085137','086001','086002','086003','086004','086005','088001','088003','088005','088006','088007','088008','088009','089001','090001','090002','090003','090004','090005','090006','090007','090008','090009','090010','090013','090015','090016','090017','090018','090019','090022','090027','090028','091001','091002','091005','091008','091009','091010','091011','091012','091013','091014','091015','091016','091017','091018','093001','093003','093098','093100','093102','093104','093141','093142','093146','093151','093153','093167','093168','093176','094001','094002','094004','094005','095004','099001','099002','100001','101001','102002','102003','105001','105002','106001','113001','113002','113003','113004','113005','113006','113007','113008','113009','113010','113011','113012','113013','113014','113015','113016','113017','113018','113019','113020','113021','113022','113023','113024','113025','113026','113027','113028','114001','115001','115002','115003','115004','115005','115006','115007','115008','115009','115010','115011','115012','115013','115014','115015','115016','115017','115018','115020','115021','115022','115023','115025','115026','115027','115028','115029','115030','115031','115032','115033','115034','115035','115036','115039','115040','115041','115042','115043','115044','115045','115046','115047','115048','115049','115050','115051','115052','115053','115054','115055','115056','115057','115059','115060','115061','115062','115063','115064','115065','115066','115067','115068','115069','115070','115071','115072','115073','115075','115076','115081','115082','115085','115086','115087','115088','115095','115096','115097','115098','115099','115101','115102','115103','115104','115105','115106','115108','115109','115110','115111','115112','115113','115114','115115','115116','115117','115118','115119','115120','115121','115122','116001','116002','116003','116004','116005','116006','116007','116008','116009','116010','116011','116012','117001','117002','117003','123001','124010','124014','124015','124019','124024','124025','124026','124027','124028','124029','124030','124031','124032','124033','124035','124036','124037','124038','124039','124040','124041','124042','124043','124044','124045','124046','124047','124048','124049','124050','124051','124052','124053','124054','124055','124056','124057','124058','124059','124060','124061','124062','124063','124064','124065','126001','126002','126003','126004','126005','126006','126007','126008','126009','126010','126011','126012','130001','132001','132002','132003','133001','133008','133009','133010','133011','133012','133013','133014','133015','133016','133017','133018','133019','133020','133021','133022','133023','133024','133025','133027','133028','133029','133030','133031','134001','135001','135002','135003','135004','135005','135006','135007','135008','135009','135010','136001','137009','137010','137011','137012','137013','137014','137015','137016','137017','137018','137019','138001','138002','138003','138004','139001','139003','140001','141001','141002','141003','141006','141007','141008','141009','141011','141012','141014','141015','141016','141017','141018','141019','141020','141021','141022','141023','141024','141025','141026','141027','141028','142001','142002','142003','142004','142005','142006','142007','142008','142010','142011','142012','144001','145001','145002','145003','145004','145005','145006','145007','145008','145009','145010','145011','145012','145013','145014','145015','145016','147001','150003','150005','150009','150013','150014','150015','150016','150017','150020','150021','152001','152002','152003','152004','152005','152006','152007','154001','154002','154003','155001','155002','155003','155004','155005','155006','159001','159002','159003','159004','160001','160002','160003','161001','162001','162002','162003','162004','162007','162010','162011','162012','163001','163002','163003','163005','163010','163011','163014','163015','163016','165001','165002','165003','165004','165005','165006','165007','165008','165009','165010','165011','165012','165013','165014','165015','165016','165017','165018','165019','165020','165021','165022','165023','165024','165025','165026','165027','165028','165029','165030','165031','165032','165033','165034','165035','165036','167001','168001','168002','168003','168004','168005','168007','168008','168009','168010','168011','168012','168013','168014','169001','169002','169003','169007','169008','169009','169010','170001','171001','171002','171003','171004','171005','171006','171007','171008','171009','172001','174001','174002','174003','176001','176002','176003','177001','177002','179001','179002','179003','179004','179005','179006','179007','179008','179009','179010','179011','179012','179013','179014','179015','179016','179017','179018','179019','179020','179021','179022','179023','179024','179025','179026','179027','179028','179029','179030','179031','179032','179033','179034','179035','179036','179037','179038','179039','179040','179041','179042','179043','179044','179045','179046','179047','180001','180010','180012','180013','180014','180015','180016','180017','180018','180019','180020','180021','180022','180023','180024','180025','180026','180027','180028','180030','180031','180032','180033','180034','180035','180036','180037','180038','180039','180041','180042','180043','180044','180045','180046','180047','180048','180049','180050','180051','180052','180053','180054','180055','180056','180057','180058','180059','180060','180061','180062','180063','180064','180065','180066','180067','180068','180069','180070','180071','182001','184001','184002','184005','184006','184007','184008','184009','184010','184011','185001','185003','187001','188001','188002','188003','188004','188005','188006','188007','188008','188009','188010','188011','191001','191002','192002','194001','194002','194003','194004','194005','194006','194007','195001','195002','195003','195004','195005','195006','195007','196001','196002','197001','197002','197003','197004','197005','197006','198001','198003','198004','198005','198006','198007','198008','198009','198010','198011','198012','198013','198014','198015','198016','198017','201001','201002','201005','202001','203001','203002','203003','203017','203018','203019','204001','204002','204003','205001','208001','208002','208003','208004','208005','209001','209002','209003','210001','210002','210003','210004','210005','210006','210007','210008','210009','210010','210011','210012','210013','211017','212001','212002','212003','212004','212005','212006','212007','212008','212009','212010','212011','212012','212013','218001','218003','218004','218006','218007','218008','218009','218011','218015','218016','218017','218018','218019','218020','218021','218022','218023','218024','218025','218026','218027','218028','218029','218030','218031','218032','218033','218034','218035','218036','221001','221002','221003','221004','221005','221006','221007','221008','221009','221010','221011','221012','221013','223001','223002','223003','224001','224002','224003','224006','224007','224008','225001','225002','225003','225004','225005','225006','225007','225008','225009','225010','225011','225012','225013','226001','226002','226003','226004','226005','226006','226007','226008','226009','227001','227002','227003','227004','227005','227006','227007','227008','227009','227010','227011','227012','227013','227014','227015','227016','227017','227018','227019','227020','227021','227022','227023','227024','227025','227026','227027','227028','227029','227030','227031','227032','227033','227034','227035','227036','227037','227038','227039','227040','227041','227042','227043','227044','227045','227046','227047','227048','227049','227050','227051','227052','227053','227054','227055','227056','227057','227058','227059','227060','227061','227062','227063','227064','227065','227066','227067','227068','227069','227070','227071','227072','227073','227074','227075','227076','227077','227078','227079','227080','227081','227082','227083','227084','227085','227086','227087','227088','227089','227090','227091','227092','227093','227094','227095','227096','227097','227098','227099','227100','227101','227102','227103','227104','227105','227106','227107','227108','227109','227110','227111','227112','227113','227114','227115','227116','227117','227118','227119','227120','227122','227123','227124','227125','227126','227127','227128','227129','227130','227131','227132','227133','227134','227135','227136','227137','227138','227139','227140','227141','227142','227143','227144','227145','227146','227147','227148','227149','227150','227151','227152','228001','229001','229002','229003','229004','229005','230001','230002','232001','233001','233002','233003','233004','233005','233006','233007','233008','234001','234002','234003','234004','234005','234006','234007','234008','234009','234010','234011','234012','234013','234014','234015','234016','234017','234018','234019','234020','234021','234022','234023','234024','234025','234026','234027','234028','234029','234030','235001','235002','235003','235004','235005','236001','236002','236003','237001','238002','238003','238004','238005','238006','238007','238008','333013','333014','333015','333016','333017','333018','333019','333020','333021','333022','333023','333024','333025','333030','333031','333032','333033','333034','333035','334001','334002','334003','334004','334005','334006','334007','336004','337001','337002','337003','337004','339001','339002','343001','344001','344002','344003','344004','344005','345001','345002','345003','347001','347002','348001','348002','348003','348004','348005','349001','349002','349003','350001','353001','353002','353003','353004','355001','355002','355003','355004','355005','355006','356001','358001','359001','359002','360001','360002','360003','360004','360005','366001','366002','366003','366004','369001','373001','373002','373003','373004','373005','373006','373007','373008','373009','373010','373011','373012','373013','373014','373015','373016','373017','373018','373019','373020','373021','374001','374002','374003','374004','374005','374006','374007','374008','374009','374010','374011','374012','374013','374014','374015','374016','376001','376002','376003','376004','376005','376006','376007','376008','376009','376010','376011','376012','376013','376016','376017','376018','376019','376020','376021','379003','382001','382002','383001','384001','384002','385001','385002','386001','386002','386003','386004','386005','386006','386007','386008','386009','386010','386011','386012','386013','386014','387001','389001','389002','389003','389004','392001','393001','393002','393003','393004','395001','396001','397001','397002','399001','399002','399003','400001','400002','401001','401002','401003','402001','402002','402003','402004','402005','403001','403002','403003','504001','504002','504004','504005','504006','504007','504008','504009','504010','504011','504012','504013','504014','504017','504018','504019','504021','504022','504023','504024','504025','506001','506002','508001','508002','511001','511002','511003','511004','511005','511006','511007','511008','511009','511010','511011','511012','511013','511014','511017','511018','511020','511021','511022','511024','511028','511029','513001','513002','513003','513004','514001','515001','515002','515003','515007','515008','515009','515010','515011','515012','515013','515014','515015','518001','518002','518003','520001','520002','521001','521002','521003','521004','521005','521006','521007','521008','521009','521010','521011','521012','521013','521014','521015','521016','523001','523002','523003','523004','523005','523006','523007','524001','700001','701001','701002','701003','702001','702002','702003','702004','702005','702006','702007','702008','703001','703002','703003','704001','704002','704003','704004','705001','706001','706002','707001','707002','707003','708001','709001','709002','710001','710002','711001','711002','712001','713001','713002','714001','714002','715001','716001','718001','718002','719001','719002','991001','991002','991003','991004','991005','991006','991007','991008','992001','995001','996001','996002','996003','998001','998002','998003','998004','998005','998006','998007','999001','999002','011017','011018','034001','034002','071010','208006','239001','519001','519003','126013','184012','053071','374017','374018','374019','374020','374021','404001','405002','405001','405003','405007','405006','405005','405004','240011','240010','240009','240008','240007','240006','240005','240004','240003','240002','240001','240012','240013','240014','240015','240016','240017','357001','235006','235007','712002','355008','355007','056023','999999','046015','019005','126014','241003','241002','241001','240018','240020','240019','242001','242002','242003','242004','242005','242006','089002','406001','406002','406003','406004','406005','406006','243001','243002','243003','243004','243005','243006','243007','243008','010030','010029','407001','407006','407005','407004','407003','407002','408001','366005','133032','016035','077010','996004','025064','011019','407007','407008','407009','409001','115123','504026','039007','039009','039008','039010','039011','039012','180072','240021','240023','408002','405008','235008','525001','525002','525003','525004','410001','410002','410003','410004','410005','410006','410007','410008','410009','410010','410011','410012','410013','410014','410015','410016','344006','240031','240030','240029','240028','240027','240026','240025','240024','240034','240033','240032','410017','410018','411001','411002','411003','411004','411005','411006','411007','411008','203020','203021','203022','412001','412002','412003','412004','069025','244001','244002','244009','244008','244007','244006','244005','244004','244003','244015','244014','244013','244012','244011','244010','244016','244017','240042','240041','240040','240039','240038','240037','240036','240035','405009','405010','240043','504034','504033','504032','504031','504030','504029','504028','504027','504042','504041','504040','504039','504038','504037','504036','504035','800001','410019','410020','410021','244018','244019','244020','399004','413001','504043','198018','198019','344007','082045','010031','010032','010033','010034','010035','504044','515016','801002','801003','801004','801005','802001','801001','414001','414002','414003','141029','141030','803001','803002','803003','803004','803005','803006','803007','803008','803009','803010','803011','803012','803013','803014','803015','803016','803017','410022','410023','803018','803019','803020','415002','415001','244021','011020','011023','011022','011021','025065','165037','165038','165039','416001','416002','416003','417001','418001','504045','803022','803021','240022','419001','420001','804010','804009','804008','804007','804006','804005','804004','804003','804002','804001','804020','804019','804018','804017','804016','804015','804014','804013','804012','804011','804024','804021','804023','804022','511019','511016','511015','511032','511031','511030','511027','511026','511025','511033','511023','133034','133033','169011','344008','344009','244022','244026','244025','244030','244023','244024','244027','244028','244029','244031','082046','082047','082048','126015','126016','416004','416005','421001','421002','016037','016036','115124','115125','115126','240049','240048','240047','240046','240045','240044','244032','244033','422001','422002','422003','422004','422005','184013','239002','805001','805002','805003','805004','805005','056024','423001','344010','235009','212014','056025','056026','802002','244034','244035','244036','244037','244038','244039','515017','504046','203015','245002','245001','071023','056027','056028','056029','056030','056031','056032','424001','056034','056033','805006','805007','805008','805009','805010','422008','422007','422006','422010','422009','422011','209004','150022','150023','100002','056035','023036','185004','185005','246001','247001','247002','425001','416006','165042','165041','165040','165043','010040','010039','010038','010037','010036','422012','422013','422014','422015','426000','248001','248002','248003','248004','248005','249001','249002','249003','249004','249005','249006','250007','250001','250002','250003','250004','250005','250006','250008','250009','250010','250011','250012','250013','251001','251002','422016','422017','422018','806001','806002','116013','235010','235011','091026','091027','091028','091029','091019','091020','091021','091022','091023','091024','091025','252001','243009','249007','249008','249009','011024','011025','427001','428002','428001','169012','429001','429002','429003') DEFAULT '001001' NOT NULL, +KEY field (field) +); +INSERT INTO t1 VALUES ('001001'),('001001'),('001001'),('001001'),('001001'),('001001'),('001001'),('001001'),('001001'),('001010'),('001010'),('001010'),('001010'),('001010'),('001018'),('001018'),('001018'),('001018'),('001018'),('001018'),('001020'),('001020'),('001020'),('001020'),('001020'),('001020'),('001020'),('001020'),('001021'),('001021'),('001021'),('001021'),('001021'),('001021'),('001027'),('001027'),('001028'),('001030'),('001030'),('001030'),('001030'),('001031'),('001031'),('001031'),('001031'),('001031'),('001100'),('001100'),('002003'),('002003'),('002003'),('002003'),('002003'),('002003'),('002003'),('002003'),('002003'),('002004'),('002004'),('002004'),('002004'),('002004'),('002004'),('002004'),('002004'),('002004'),('002005'),('002005'),('002005'),('002005'),('002005'),('002005'),('002005'),('002005'),('002007'),('002007'),('002007'),('002007'),('002007'),('002007'),('002007'),('002008'),('002008'),('002008'),('002008'),('002008'),('002008'),('002008'),('002008'),('002009'),('002009'),('002009'),('002009'),('002009'),('002009'),('002009'),('002009'),('002012'),('002012'),('002012'),('002012'),('002012'),('002012'),('002012'),('002013'),('002013'),('002013'),('002013'),('002013'),('002013'),('002013'),('002013'),('002013'),('002014'),('002014'),('002014'),('002014'),('002014'),('002014'),('002014'),('002014'),('003002'),('003002'),('003002'),('003002'),('003002'),('003002'),('003003'),('003003'),('003003'),('003003'),('003003'),('003003'),('003004'),('003004'),('003004'),('003004'),('003004'),('003004'),('003005'),('003005'),('003005'),('003005'),('003005'),('003005'),('003005'),('003005'),('003005'),('003006'),('003006'),('003006'),('003006'),('003006'),('003006'),('003006'),('003006'),('003007'),('003007'),('003007'),('003007'),('003007'),('003008'),('003008'),('003008'),('003008'),('003008'),('003008'),('003009'),('003009'),('003009'),('003009'),('003009'),('003009'),('003009'),('003009'),('003009'),('003010'),('003010'),('003010'),('003010'),('003010'),('003010'),('003010'),('003010'),('003010'),('003011'),('003011'),('003011'),('003011'),('003011'),('003011'),('003011'),('003011'),('003012'),('003012'),('003012'),('003012'),('003012'),('003012'),('003012'),('003012'),('003013'),('003013'),('003013'),('003013'),('003013'),('003013'),('003013'),('003013'),('003014'),('003014'),('003014'),('003014'),('003014'),('003014'),('003014'),('003014'),('003015'),('003015'),('003015'),('003015'),('003015'),('003015'),('003016'),('003016'),('003016'),('003016'),('003016'),('003016'),('003017'),('003017'),('003017'),('003017'),('003017'),('003018'),('003018'),('003018'),('003018'),('003018'),('003019'),('003019'),('004003'),('004005'),('004005'),('004005'),('004005'),('004005'),('004005'),('004006'),('004008'),('004010'),('004012'),('004012'),('004014'),('004014'),('004014'),('004014'),('004014'),('004016'),('004017'),('004017'),('004017'),('004017'),('004017'),('004017'),('004017'),('004017'),('004020'),('004020'),('004020'),('004020'),('004020'),('004020'),('004021'),('004021'),('004021'),('004021'),('004021'),('004021'),('004021'),('004022'),('004023'),('004023'),('004023'),('004023'),('004023'),('004023'),('004023'),('004025'),('004026'),('004026'),('004026'),('004026'),('004026'),('006004'),('006006'),('006010'),('006010'),('006010'),('006010'),('006010'),('006010'),('006010'),('006011'),('006011'),('006011'),('006011'),('006011'),('006011'),('006012'),('006012'),('006012'),('006012'),('006012'),('006012'),('006014'),('006014'),('006014'),('007001'),('007001'),('007002'),('007003'),('007005'),('007007'),('007008'),('007009'),('007011'),('007012'),('007013'),('007015'),('007016'),('007017'),('007018'),('007019'),('007019'),('007020'),('007021'),('007021'),('007022'),('007023'),('007023'),('007025'),('007025'),('007025'),('007027'),('007029'),('007031'),('007031'),('007032'),('007034'),('007034'),('007036'),('007036'),('007036'),('007037'),('007037'),('007038'),('007040'),('007040'),('007040'),('007043'),('009001'),('009001'),('009001'),('009001'),('009001'),('009001'),('009001'),('009002'),('009002'),('009002'),('009002'),('009002'),('009004'),('009004'),('009004'),('009004'),('009005'),('009005'),('009005'),('009005'),('009005'),('009005'),('009005'),('009005'),('009006'),('009006'),('009006'),('009006'),('009007'),('009007'),('009007'),('009007'),('009007'),('009007'),('009008'),('009010'),('009010'),('009010'),('009010'),('009010'),('009010'),('009011'),('009011'),('009011'),('009011'),('009011'),('009012'),('009013'),('009013'),('009013'),('010002'),('010002'),('010002'),('010002'),('010002'),('010002'),('010002'),('010002'),('010003'),('010003'),('010003'),('010003'),('010003'),('010003'),('010003'),('010003'),('010003'),('010004'),('010004'),('010004'),('010004'),('010004'),('010004'),('010004'),('010004'),('010004'),('010005'),('010005'),('010005'),('010005'),('010006'),('010006'),('010006'),('010006'),('010006'),('010006'),('010006'),('010006'),('010006'),('010007'),('010007'),('010007'),('010007'),('010007'),('010007'),('010008'),('010008'),('010008'),('010008'),('010008'),('010008'),('010008'),('010009'),('010009'),('010009'),('010009'),('010009'),('010009'),('010010'),('010010'),('010010'),('010010'),('010010'),('010010'),('010010'),('010011'),('010011'),('010011'),('010011'),('010011'),('010011'),('010011'),('010011'),('010012'),('010012'),('010012'),('010012'),('010012'),('010012'),('010012'),('010013'),('010013'),('010013'),('010013'),('010013'),('010013'),('010015'),('010016'),('010016'),('010016'),('010016'),('010016'),('010016'),('010016'),('010016'),('010017'),('010017'),('010017'),('010017'),('010017'),('010017'),('010018'),('010018'),('010018'),('010018'),('010018'),('010018'),('010018'),('010018'),('010018'),('010019'),('010019'),('010019'),('010019'),('010019'),('010019'),('010020'),('010020'),('010020'),('010021'),('010021'),('010021'),('010021'),('010021'),('010021'),('010022'),('010022'),('010022'),('010022'),('010022'),('010022'),('010022'),('010022'),('010023'),('010023'),('010023'),('010023'),('010023'),('010023'),('010023'),('010023'),('010026'),('010027'),('010028'),('010028'),('011001'),('011001'),('011001'),('011001'),('011001'),('011001'),('011001'),('011002'),('011002'),('011002'),('011002'),('011002'),('011002'),('011002'),('011003'),('011003'),('011003'),('011003'),('011003'),('011003'),('011003'),('011003'),('011004'),('011004'),('011004'),('011004'),('011004'),('011004'),('011004'),('011006'),('011006'),('011006'),('011006'),('011006'),('011006'),('011006'),('011012'),('011012'),('011012'),('011013'),('011013'),('011013'),('011013'),('011013'),('011013'),('011014'),('011014'),('011014'),('011014'),('011015'),('011015'),('011015'),('011015'),('011015'),('011016'),('011016'),('011016'),('011016'),('011016'),('012017'),('012017'),('012027'),('012027'),('012032'),('012034'),('012036'),('012036'),('012037'),('012037'),('012038'),('012039'),('014001'),('014001'),('016016'),('016016'),('016016'),('016019'),('016020'),('016020'),('016020'),('016020'),('016020'),('016020'),('016020'),('016020'),('016021'),('016021'),('016021'),('016021'),('016021'),('016021'),('016021'),('016022'),('016022'),('016022'),('016023'),('016023'),('016023'),('016024'),('016024'),('016024'),('016024'),('016024'),('016024'),('016024'),('016026'),('016026'),('016026'),('016026'),('016026'),('016026'),('016028'),('016028'),('016028'),('016028'),('016028'),('016028'),('016028'),('016029'),('016029'),('016030'),('016031'),('016032'),('016032'),('016032'),('016032'),('016032'),('016032'),('016032'),('016033'),('016033'),('016033'),('016033'),('016033'),('016034'),('016034'),('016034'),('016034'),('016034'),('017002'),('017002'),('017002'),('017002'),('017002'),('018001'),('018001'),('018001'),('018001'),('018001'),('018001'),('018001'),('018001'),('019002'),('019002'),('019002'),('019002'),('019002'),('019002'),('019004'),('019004'),('019004'),('019004'),('019004'),('019004'),('020001'),('020001'),('020001'),('020001'),('020004'),('020006'),('020006'),('020006'),('020006'),('020006'),('020006'),('020008'),('020009'),('020009'),('020009'),('020009'),('020009'),('022001'),('022001'),('022001'),('022001'),('022002'),('022002'),('022002'),('022002'),('022003'),('022003'),('022003'),('022003'),('023001'),('023002'),('023002'),('023002'),('023002'),('023002'),('023002'),('023003'),('023003'),('023003'),('023003'),('023004'),('023004'),('023005'),('023005'),('023006'),('023006'),('023006'),('023006'),('023006'),('023006'),('023007'),('023007'),('023010'),('023010'),('023011'),('023011'),('023017'),('023019'),('023019'),('023019'),('023020'),('023020'),('023025'),('023025'),('023025'),('023026'),('023026'),('023026'),('023027'),('023027'),('023027'),('023028'),('023028'),('023029'),('023029'),('023030'),('023030'),('023032'),('023033'),('023033'),('023033'),('023033'),('023033'),('023033'),('023034'),('023035'),('023035'),('025001'),('025001'),('025001'),('025001'),('025001'),('025001'),('025001'),('025003'),('025003'),('025004'),('025004'),('025005'),('025005'),('025007'),('025007'),('025008'),('025008'),('025009'),('025010'),('025010'),('025010'),('025011'),('025011'),('025012'),('025012'),('025013'),('025013'),('025013'),('025014'),('025015'),('025016'),('025018'),('025018'),('025019'),('025019'),('025020'),('025020'),('025021'),('025022'),('025022'),('025023'),('025023'),('025024'),('025025'),('025025'),('025026'),('025026'),('025027'),('025027'),('025027'),('025028'),('025030'),('025031'),('025033'),('025034'),('025035'),('025037'),('025041'),('025042'),('025043'),('025046'),('025048'),('025048'),('025048'),('025049'),('025049'),('025049'),('025050'),('025050'),('025050'),('025051'),('025051'),('025052'),('025052'),('025052'),('025053'),('025053'),('025054'),('025054'),('025054'),('025054'),('025055'),('025056'),('025056'),('025056'),('025056'),('025056'),('025056'),('025056'),('025056'),('025056'),('025057'),('025057'),('025058'),('025058'),('025060'),('025060'),('025061'),('025062'),('025063'),('027001'),('027002'),('027011'),('036001'),('036001'),('036001'),('036001'),('036001'),('037003'),('037006'),('037007'),('037008'),('037008'),('038009'),('039001'),('039001'),('039001'),('039001'),('039001'),('039001'),('039002'),('039002'),('039002'),('039002'),('039002'),('039003'),('039003'),('039003'),('039003'),('039003'),('039003'),('039004'),('039004'),('039004'),('039004'),('039004'),('039005'),('039005'),('039005'),('039005'),('039005'),('039006'),('039006'),('039006'),('039006'),('046001'),('046001'),('046001'),('046001'),('046001'),('046001'),('046001'),('046001'),('046002'),('046002'),('046002'),('046002'),('046002'),('046002'),('046002'),('046002'),('046003'),('046003'),('046003'),('046003'),('046003'),('046003'),('046003'),('046005'),('046005'),('046005'),('046005'),('046005'),('046005'),('046005'),('046007'),('046007'),('046007'),('046007'),('046007'),('046007'),('046008'),('046008'),('046008'),('046008'),('046008'),('046009'),('046009'),('046009'),('046010'),('046012'),('046012'),('046012'),('046013'),('046014'),('046014'),('046014'),('047001'),('047001'),('047001'),('047001'),('047001'),('047001'),('047001'),('047001'),('047002'),('047002'),('047002'),('047002'),('047002'),('047002'),('047002'),('047002'),('048001'),('048001'),('048001'),('048001'),('048001'),('048001'),('048001'),('048001'),('051003'),('051003'),('051003'),('051003'),('051003'),('051004'),('051004'),('051004'),('051004'),('052001'),('052001'),('052001'),('052001'),('052001'),('052001'),('052001'),('052001'),('052002'),('052002'),('052005'),('052005'),('052005'),('052005'),('052005'),('052005'),('053016'),('053019'),('053019'),('053023'),('053023'),('053023'),('053023'),('053024'),('053024'),('053024'),('053026'),('053026'),('053026'),('053026'),('053028'),('053028'),('053029'),('053029'),('053029'),('053029'),('053033'),('053033'),('053033'),('053045'),('053046'),('053051'),('053051'),('053051'),('053054'),('053054'),('053054'),('053054'),('053057'),('053069'),('053069'),('053097'),('053107'),('053125'),('053125'),('053127'),('054001'),('054001'),('054001'),('054001'),('054001'),('054001'),('054001'),('054002'),('054002'),('054002'),('054002'),('054002'),('054002'),('054003'),('054003'),('054003'),('054003'),('054003'),('054003'),('054003'),('054004'),('054004'),('054004'),('054004'),('054004'),('054004'),('054004'),('054006'),('054006'),('054006'),('054007'),('054007'),('054007'),('054007'),('054007'),('054009'),('054009'),('054009'),('054009'),('054010'),('054010'),('054010'),('054010'),('054010'),('054010'),('054010'),('056001'),('056001'),('056001'),('056001'),('056001'),('056001'),('056001'),('056001'),('056001'),('056002'),('056002'),('056002'),('056002'),('056002'),('056002'),('056002'),('056002'),('056003'),('056003'),('056003'),('056003'),('056003'),('056003'),('056004'),('056004'),('056004'),('056004'),('056004'),('056004'),('056004'),('056005'),('056005'),('056005'),('056005'),('056005'),('056005'),('056005'),('056005'),('056005'),('056006'),('056006'),('056006'),('056006'),('056006'),('056006'),('056006'),('056006'),('056006'),('056009'),('056009'),('056009'),('056011'),('056016'),('056016'),('056016'),('056016'),('056016'),('056016'),('056016'),('056017'),('056017'),('056017'),('056017'),('056017'),('056017'),('056017'),('056017'),('056017'),('056018'),('056018'),('056018'),('056018'),('056018'),('056018'),('056019'),('056019'),('056019'),('056019'),('056019'),('056019'),('056019'),('056019'),('056020'),('056020'),('056020'),('056020'),('056022'),('056022'),('056022'),('056022'),('056022'),('057003'),('057003'),('057004'),('058002'),('058002'),('058002'),('058002'),('058003'),('058003'),('058003'),('058003'),('058004'),('058004'),('058004'),('058005'),('058005'),('058005'),('060001'),('060001'),('060001'),('060001'),('060001'),('060004'),('060004'),('060004'),('060004'),('060004'),('060004'),('060005'),('060005'),('060005'),('060005'),('060005'),('060005'),('060007'),('060007'),('060007'),('060007'),('060007'),('060007'),('060007'),('061004'),('061004'),('061004'),('061004'),('061004'),('061004'),('061006'),('061006'),('061006'),('061006'),('061006'),('061006'),('069006'),('069006'),('069006'),('069006'),('069006'),('069006'),('069006'),('069006'),('069006'),('069007'),('069007'),('069007'),('069007'),('069007'),('069007'),('069007'),('069007'),('069010'),('069010'),('069010'),('069010'),('069010'),('069010'),('069011'),('069012'),('069012'),('069012'),('069012'),('069012'),('069012'),('069012'),('069012'),('069012'),('069012'),('069013'),('069013'),('069013'),('069013'),('069013'),('069013'),('069013'),('069013'),('069013'),('069014'),('069014'),('069014'),('069014'),('069014'),('069014'),('069014'),('069014'),('069014'),('069015'),('069015'),('069015'),('069015'),('069015'),('069015'),('069015'),('069015'),('069015'),('069015'),('069016'),('069016'),('069016'),('069016'),('069016'),('069018'),('069018'),('069018'),('069018'),('069018'),('069018'),('069018'),('069018'),('069018'),('069020'),('069020'),('069020'),('069020'),('069021'),('069023'),('071002'),('071002'),('071002'),('071002'),('071002'),('071003'),('071003'),('071003'),('071003'),('071003'),('071004'),('071004'),('071004'),('071004'),('071004'),('071005'),('071005'),('071005'),('071005'),('071005'),('071005'),('071006'),('071006'),('071006'),('071006'),('071008'),('071008'),('071008'),('071008'),('071008'),('071008'),('071011'),('071011'),('071011'),('071011'),('071011'),('071020'),('071020'),('071020'),('071020'),('071020'),('071021'),('071022'),('071022'),('071022'),('072001'),('072001'),('074001'),('074002'),('074002'),('074002'),('074002'),('074002'),('074002'),('074002'),('074002'),('074003'),('074003'),('074003'),('074003'),('074003'),('074003'),('074003'),('074003'),('074004'),('074004'),('074004'),('074004'),('074004'),('074004'),('074004'),('074004'),('074005'),('074005'),('074005'),('074005'),('074005'),('074005'),('074005'),('074005'),('074006'),('074006'),('074006'),('074006'),('074006'),('074006'),('074006'),('074006'),('074007'),('074007'),('074007'),('074007'),('074007'),('074007'),('074007'),('074007'),('074008'),('074008'),('074008'),('074008'),('074008'),('074008'),('074008'),('074008'),('074009'),('074009'),('074009'),('074009'),('074009'),('074009'),('074009'),('074009'),('074010'),('074010'),('074010'),('074010'),('074010'),('074010'),('074010'),('074010'),('074011'),('074011'),('074011'),('074011'),('074011'),('074011'),('074011'),('074011'),('074012'),('074012'),('074012'),('074012'),('074012'),('074012'),('074012'),('075001'),('075001'),('075001'),('075007'),('075007'),('075007'),('075007'),('076101'),('076101'),('076101'),('076101'),('076102'),('076102'),('076102'),('076103'),('076103'),('076103'),('076103'),('076103'),('077001'),('077001'),('077001'),('077002'),('077002'),('077002'),('077002'),('077002'),('077002'),('077002'),('077003'),('077003'),('077003'),('077003'),('077003'),('077003'),('077003'),('077004'),('077004'),('077004'),('077004'),('077004'),('077004'),('077006'),('077006'),('077008'),('077008'),('077008'),('077008'),('077008'),('077008'),('077008'),('077009'),('077009'),('077009'),('077009'),('077009'),('077009'),('077009'),('078005'),('078005'),('078005'),('079002'),('079002'),('079002'),('079002'),('079002'),('079002'),('079002'),('079003'),('079003'),('079004'),('079004'),('079005'),('079005'),('079005'),('079005'),('079005'),('079005'),('079006'),('079006'),('079006'),('079006'),('079007'),('079007'),('079007'),('079007'),('079007'),('081001'),('081001'),('081001'),('081001'),('081001'),('082011'),('082011'),('082011'),('082011'),('082011'),('082013'),('082013'),('082013'),('082013'),('082013'),('082013'),('082014'),('082014'),('082014'),('082014'),('082014'),('082014'),('082014'),('082015'),('082015'),('082015'),('082015'),('082015'),('082016'),('082016'),('082016'),('082016'),('082016'),('082016'),('082017'),('082017'),('082017'),('082017'),('082017'),('082017'),('082017'),('082021'),('082021'),('082022'),('082022'),('082022'),('082022'),('082022'),('082023'),('082023'),('082023'),('082023'),('082023'),('082024'),('082024'),('082024'),('082024'),('082024'),('082025'),('082025'),('082025'),('082025'),('082025'),('082026'),('082026'),('082026'),('082026'),('082026'),('082027'),('082027'),('082027'),('082027'),('082027'),('082028'),('082028'),('082028'),('082028'),('082029'),('082029'),('082029'),('082029'),('082029'),('082030'),('082030'),('082030'),('082030'),('082031'),('082031'),('082031'),('082031'),('082031'),('082032'),('082032'),('082032'),('082033'),('082033'),('082034'),('082034'),('082034'),('082034'),('082034'),('082034'),('082034'),('082035'),('082035'),('082035'),('082036'),('082036'),('082036'),('082036'),('082037'),('082037'),('082037'),('082038'),('082038'),('082038'),('082038'),('082039'),('082039'),('082039'),('082039'),('082040'),('082040'),('082040'),('082040'),('082040'),('082041'),('082041'),('082041'),('082041'),('082042'),('082042'),('082043'),('082043'),('082043'),('082043'),('082043'),('082044'),('082044'),('082044'),('082044'),('084001'),('084002'),('084002'),('084002'),('084002'),('084003'),('084003'),('084003'),('084003'),('084003'),('084003'),('084003'),('084003'),('084004'),('084004'),('084004'),('084004'),('084004'),('084005'),('084005'),('084005'),('084005'),('084005'),('084007'),('084007'),('084007'),('084007'),('084007'),('084007'),('084008'),('084008'),('084008'),('084008'),('084008'),('084008'),('084009'),('084009'),('084009'),('084009'),('084009'),('084009'),('084011'),('084013'),('084013'),('084013'),('084013'),('084013'),('084014'),('084014'),('084014'),('084016'),('084016'),('084016'),('084016'),('084016'),('084016'),('084016'),('084016'),('084017'),('084017'),('084017'),('084017'),('084017'),('084017'),('084017'),('084017'),('084017'),('084027'),('084027'),('084027'),('084027'),('084027'),('084027'),('084032'),('084032'),('084033'),('084033'),('084033'),('084035'),('084035'),('084035'),('084036'),('084036'),('084036'),('084036'),('084036'),('084036'),('084037'),('084037'),('084038'),('084038'),('084038'),('084038'),('084038'),('084038'),('084039'),('084039'),('084039'),('084039'),('084040'),('084040'),('084040'),('084040'),('084040'),('084041'),('084041'),('084041'),('084041'),('084042'),('084042'),('084043'),('084043'),('084043'),('084043'),('084044'),('084044'),('084044'),('084044'),('084044'),('084045'),('084046'),('084046'),('084046'),('084047'),('084048'),('084048'),('084049'),('084049'),('084050'),('084051'),('084051'),('085001'),('085001'),('085001'),('085001'),('085001'),('085001'),('085002'),('085002'),('085002'),('085002'),('085003'),('085003'),('085003'),('085003'),('085003'),('085003'),('085003'),('085004'),('085004'),('085004'),('085004'),('085004'),('085004'),('085004'),('085005'),('085005'),('085005'),('085005'),('085005'),('085005'),('085006'),('085006'),('085006'),('085006'),('085006'),('085006'),('085006'),('085006'),('085007'),('085007'),('085007'),('085007'),('085007'),('085007'),('085007'),('085009'),('085009'),('085009'),('085009'),('085009'),('085009'),('085011'),('085011'),('085011'),('085011'),('085011'),('085011'),('085011'),('085011'),('085012'),('085012'),('085012'),('085012'),('085012'),('085012'),('085012'),('085014'),('085014'),('085014'),('085014'),('085014'),('085014'),('085014'),('085014'),('085014'),('085015'),('085015'),('085015'),('085015'),('085015'),('085015'),('085015'),('085015'),('085016'),('085016'),('085016'),('085016'),('085016'),('085016'),('085016'),('085016'),('085017'),('085017'),('085017'),('085017'),('085017'),('085018'),('085018'),('085018'),('085018'),('085018'),('085019'),('085019'),('085019'),('085019'),('085019'),('085019'),('085019'),('085019'),('085019'),('085020'),('085020'),('085020'),('085020'),('085020'),('085020'),('085022'),('085022'),('085022'),('085022'),('085022'),('085022'),('085023'),('085023'),('085023'),('085023'),('085023'),('085028'),('085028'),('085028'),('085028'),('085028'),('085028'),('085028'),('085029'),('085029'),('085029'),('085029'),('085029'),('085029'),('085029'),('085030'),('085030'),('085030'),('085030'),('085030'),('085030'),('085030'),('085031'),('085031'),('085031'),('085031'),('085031'),('085031'),('085031'),('085033'),('085034'),('085034'),('085034'),('085034'),('085034'),('085034'),('085034'),('085035'),('085035'),('085035'),('085035'),('085035'),('085035'),('085036'),('085036'),('085036'),('085036'),('085036'),('085036'),('085037'),('085037'),('085037'),('085037'),('085037'),('085037'),('085038'),('085038'),('085038'),('085038'),('085038'),('085038'),('085038'),('085040'),('085040'),('085040'),('085040'),('085040'),('085040'),('085040'),('085040'),('085041'),('085041'),('085041'),('085041'),('085041'),('085041'),('085041'),('085041'),('085042'),('085042'),('085042'),('085042'),('085042'),('085042'),('085042'),('085043'),('085043'),('085043'),('085043'),('085043'),('085043'),('085044'),('085044'),('085044'),('085044'),('085044'),('085044'),('085044'),('085045'),('085045'),('085045'),('085045'),('085045'),('085046'),('085046'),('085046'),('085046'),('085046'),('085046'),('085046'),('085046'),('085047'),('085047'),('085047'),('085047'),('085047'),('085047'),('085047'),('085047'),('085048'),('085048'),('085048'),('085048'),('085048'),('085048'),('085048'),('085063'),('085063'),('085063'),('085063'),('085063'),('085064'),('085064'),('085064'),('085064'),('085064'),('085065'),('085065'),('085068'),('085068'),('085068'),('085068'),('085068'),('085068'),('085071'),('085071'),('085071'),('085071'),('085071'),('085071'),('085073'),('085073'),('085082'),('085082'),('085082'),('085082'),('085082'),('085086'),('085086'),('085086'),('085088'),('085088'),('085088'),('085088'),('085088'),('085088'),('085088'),('085089'),('085089'),('085090'),('085090'),('085090'),('085090'),('085090'),('085090'),('085090'),('085090'),('085091'),('085091'),('085091'),('085091'),('085091'),('085092'),('085092'),('085092'),('085093'),('085093'),('085095'),('085095'),('085095'),('085095'),('085095'),('085096'),('085096'),('085096'),('085096'),('085096'),('085096'),('085097'),('085097'),('085097'),('085097'),('085097'),('085098'),('085098'),('085098'),('085098'),('085098'),('085098'),('085098'),('085099'),('085099'),('085099'),('085099'),('085099'),('085099'),('085099'),('085100'),('085100'),('085100'),('085100'),('085100'),('085100'),('085100'),('085100'),('085100'),('085100'),('085101'),('085101'),('085101'),('085101'),('085101'),('085101'),('085101'),('085101'),('085102'),('085102'),('085103'),('085103'),('085103'),('085104'),('085104'),('085104'),('085104'),('085104'),('085105'),('085105'),('085106'),('085106'),('085106'),('085106'),('085106'),('085106'),('085108'),('085108'),('085109'),('085109'),('085109'),('085109'),('085109'),('085109'),('085109'),('085109'),('085110'),('085110'),('085110'),('085110'),('085110'),('085111'),('085111'),('085111'),('085112'),('085112'),('085112'),('085112'),('085113'),('085113'),('085113'),('085113'),('085113'),('085115'),('085120'),('085121'),('085121'),('085121'),('085121'),('085122'),('085122'),('085122'),('085122'),('085122'),('085122'),('085122'),('085122'),('085123'),('085123'),('085123'),('085123'),('085123'),('085123'),('085123'),('085123'),('085125'),('085125'),('085125'),('085125'),('085125'),('085126'),('085126'),('085126'),('085126'),('085126'),('085127'),('085127'),('085127'),('085127'),('085127'),('085127'),('085127'),('085127'),('085128'),('085128'),('085128'),('085128'),('085128'),('085129'),('085129'),('085129'),('085129'),('085129'),('085130'),('085130'),('085130'),('085130'),('085130'),('085132'),('085132'),('085132'),('085132'),('085132'),('085132'),('085133'),('085133'),('085133'),('085133'),('085133'),('085134'),('085134'),('085134'),('085135'),('085135'),('085135'),('085136'),('085136'),('085136'),('085136'),('085137'),('085137'),('085137'),('085137'),('085137'),('085137'),('085137'),('086002'),('086002'),('086002'),('086002'),('086003'),('086003'),('086003'),('086003'),('086005'),('088001'),('088001'),('088001'),('088001'),('088001'),('088003'),('088003'),('088003'),('088003'),('088003'),('088003'),('088005'),('088005'),('088005'),('088005'),('088005'),('088006'),('088006'),('088006'),('088006'),('088006'),('088007'),('088007'),('088007'),('088008'),('088008'),('088008'),('088008'),('088009'),('088009'),('088009'),('088009'),('088009'),('089001'),('089001'),('089001'),('089001'),('089001'),('089001'),('089001'),('090001'),('090001'),('090001'),('090001'),('090001'),('090001'),('090001'),('090002'),('090002'),('090002'),('090002'),('090002'),('090002'),('090003'),('090003'),('090003'),('090003'),('090003'),('090003'),('090003'),('090004'),('090004'),('090004'),('090004'),('090004'),('090004'),('090004'),('090006'),('090006'),('090006'),('090006'),('090006'),('090006'),('090006'),('090008'),('090008'),('090008'),('090008'),('090008'),('090009'),('090009'),('090009'),('090009'),('090009'),('090010'),('090010'),('090013'),('090013'),('090013'),('090016'),('090016'),('090017'),('090018'),('090022'),('090027'),('091001'),('091001'),('091001'),('091001'),('091001'),('091001'),('091002'),('091002'),('091002'),('091002'),('091002'),('091002'),('091009'),('091009'),('091009'),('091009'),('091009'),('091011'),('091011'),('091011'),('091011'),('091011'),('091011'),('091011'),('091012'),('091012'),('091013'),('091013'),('091013'),('091013'),('091013'),('091013'),('091015'),('091015'),('091015'),('091015'),('091015'),('091015'),('091016'),('091016'),('091016'),('091016'),('091016'),('091017'),('091017'),('091018'),('091018'),('091018'),('091018'),('093003'),('093003'),('093003'),('093003'),('093003'),('093003'),('099001'),('099001'),('099001'),('099001'),('099001'),('099001'),('099001'),('100001'),('100001'),('100001'),('100001'),('106001'),('113005'),('113005'),('113005'),('113006'),('113006'),('113018'),('113019'),('113020'),('115001'),('115001'),('115001'),('115002'),('115002'),('115003'),('115004'),('115004'),('115004'),('115004'),('115005'),('115005'),('115005'),('115006'),('115006'),('115006'),('115007'),('115007'),('115007'),('115007'),('115007'),('115008'),('115008'),('115008'),('115009'),('115010'),('115010'),('115010'),('115010'),('115010'),('115011'),('115011'),('115011'),('115011'),('115012'),('115012'),('115013'),('115013'),('115013'),('115014'),('115014'),('115014'),('115014'),('115015'),('115015'),('115015'),('115016'),('115016'),('115016'),('115016'),('115017'),('115017'),('115017'),('115017'),('115017'),('115018'),('115018'),('115020'),('115020'),('115021'),('115021'),('115022'),('115022'),('115022'),('115023'),('115023'),('115023'),('115023'),('115023'),('115025'),('115025'),('115025'),('115026'),('115026'),('115027'),('115027'),('115027'),('115028'),('115028'),('115028'),('115028'),('115029'),('115029'),('115029'),('115030'),('115030'),('115030'),('115031'),('115031'),('115032'),('115032'),('115032'),('115033'),('115033'),('115033'),('115033'),('115034'),('115034'),('115034'),('115035'),('115035'),('115036'),('115036'),('115036'),('115036'),('115036'),('115039'),('115040'),('115040'),('115040'),('115041'),('115041'),('115041'),('115041'),('115041'),('115042'),('115042'),('115042'),('115042'),('115042'),('115043'),('115043'),('115043'),('115044'),('115044'),('115044'),('115044'),('115046'),('115046'),('115046'),('115047'),('115048'),('115050'),('115050'),('115050'),('115050'),('115050'),('115051'),('115051'),('115051'),('115052'),('115053'),('115053'),('115054'),('115054'),('115054'),('115055'),('115055'),('115055'),('115057'),('115059'),('115059'),('115059'),('115059'),('115060'),('115060'),('115060'),('115060'),('115060'),('115060'),('115061'),('115061'),('115061'),('115062'),('115062'),('115062'),('115062'),('115064'),('115064'),('115064'),('115065'),('115065'),('115065'),('115065'),('115066'),('115066'),('115066'),('115067'),('115067'),('115067'),('115068'),('115068'),('115068'),('115069'),('115069'),('115069'),('115069'),('115069'),('115070'),('115070'),('115070'),('115071'),('115071'),('115071'),('115072'),('115072'),('115072'),('115073'),('115073'),('115075'),('115075'),('115075'),('115076'),('115076'),('115076'),('115076'),('115076'),('115076'),('115081'),('115081'),('115081'),('115082'),('115082'),('115082'),('115085'),('115085'),('115085'),('115085'),('115085'),('115086'),('115086'),('115086'),('115087'),('115087'),('115088'),('115088'),('115088'),('115088'),('115088'),('115095'),('115095'),('115095'),('115096'),('115096'),('115097'),('115097'),('115098'),('115098'),('115099'),('115101'),('115102'),('115102'),('115102'),('115103'),('115103'),('115104'),('115104'),('115104'),('115104'),('115105'),('115105'),('115106'),('115106'),('115106'),('115106'),('115106'),('115108'),('115109'),('115111'),('115111'),('115111'),('115111'),('115112'),('115112'),('115112'),('115112'),('115112'),('115113'),('115113'),('115113'),('115114'),('115114'),('115114'),('115114'),('115114'),('115115'),('115115'),('115115'),('115115'),('115116'),('115117'),('115117'),('115117'),('115118'),('115118'),('115119'),('115119'),('115119'),('115119'),('115120'),('115121'),('115121'),('115122'),('115122'),('116001'),('116003'),('116003'),('116003'),('116003'),('116004'),('116004'),('116005'),('116005'),('116006'),('116006'),('116006'),('116007'),('116007'),('116008'),('116008'),('116009'),('116009'),('116009'),('116010'),('116010'),('116010'),('116010'),('116011'),('116011'),('116011'),('116011'),('116012'),('116012'),('123001'),('123001'),('123001'),('123001'),('123001'),('124065'),('126001'),('126001'),('126001'),('126001'),('126001'),('126001'),('126001'),('126001'),('126002'),('126002'),('126002'),('126002'),('126002'),('126002'),('126002'),('126002'),('126003'),('126003'),('126003'),('126003'),('126003'),('126003'),('126003'),('126003'),('126003'),('126004'),('126004'),('126004'),('126004'),('126004'),('126004'),('126004'),('126004'),('126004'),('126004'),('126005'),('126005'),('126005'),('126005'),('126005'),('126005'),('126005'),('126005'),('126005'),('126006'),('126006'),('126006'),('126006'),('126006'),('126006'),('126006'),('126006'),('126006'),('126007'),('126007'),('126007'),('126007'),('126007'),('126007'),('126007'),('126008'),('126008'),('126008'),('126008'),('126008'),('126008'),('126008'),('126008'),('126009'),('126009'),('126009'),('126009'),('126009'),('126009'),('126009'),('126009'),('126010'),('126010'),('126010'),('126010'),('126010'),('126010'),('126010'),('126010'),('126010'),('126011'),('126011'),('126011'),('126011'),('126011'),('126011'),('126011'),('126012'),('126012'),('126012'),('126012'),('130001'),('130001'),('130001'),('130001'),('132001'),('132001'),('132001'),('132001'),('132001'),('132002'),('132002'),('132002'),('132002'),('132002'),('132002'),('132002'),('133001'),('133001'),('133008'),('133009'),('133010'),('133011'),('133011'),('133011'),('133011'),('133011'),('133011'),('133012'),('133015'),('133015'),('133015'),('133015'),('133016'),('133018'),('133018'),('133018'),('133018'),('133018'),('133019'),('133021'),('133021'),('133022'),('133022'),('133023'),('133023'),('133024'),('133024'),('133024'),('133024'),('133024'),('133024'),('133025'),('133027'),('133027'),('133027'),('133027'),('133027'),('133028'),('133028'),('133028'),('133029'),('133029'),('133029'),('133029'),('133029'),('133029'),('133030'),('133030'),('133031'),('133031'),('133031'),('134001'),('134001'),('134001'),('135001'),('135001'),('135001'),('135001'),('135001'),('135002'),('135002'),('135002'),('135004'),('135010'),('135010'),('135010'),('135010'),('135010'),('135010'),('137010'),('137011'),('137012'),('137014'),('137015'),('137015'),('137016'),('137019'),('139001'),('140001'),('140001'),('140001'),('140001'),('140001'),('140001'),('141001'),('141001'),('141001'),('141001'),('141001'),('141002'),('141002'),('141002'),('141002'),('141002'),('141003'),('141003'),('141003'),('141003'),('141003'),('141003'),('141003'),('141003'),('141006'),('141006'),('141006'),('141006'),('141006'),('141006'),('141006'),('141006'),('141007'),('141007'),('141007'),('141007'),('141007'),('141009'),('141009'),('141009'),('141009'),('141009'),('141011'),('141011'),('141011'),('141011'),('141011'),('141011'),('141012'),('141014'),('141014'),('141014'),('141014'),('141014'),('141014'),('141014'),('141014'),('141015'),('141015'),('141015'),('141015'),('141015'),('141016'),('141016'),('141016'),('141016'),('141016'),('141016'),('141017'),('141017'),('141017'),('141017'),('141017'),('141017'),('141018'),('141018'),('141018'),('141018'),('141019'),('141019'),('141019'),('141019'),('141020'),('141020'),('141020'),('141020'),('141020'),('141020'),('141020'),('141021'),('141021'),('141021'),('141021'),('141021'),('141021'),('141022'),('141022'),('141022'),('141022'),('141022'),('141022'),('141023'),('141023'),('141023'),('141023'),('141023'),('141023'),('141023'),('141024'),('141025'),('141025'),('141025'),('141026'),('141026'),('141026'),('141026'),('141026'),('141026'),('141027'),('141027'),('141027'),('141027'),('141027'),('141028'),('141028'),('145001'),('145001'),('145001'),('145001'),('145001'),('145001'),('145001'),('145001'),('145001'),('145002'),('145002'),('145002'),('145002'),('145002'),('145002'),('145002'),('145002'),('145002'),('145003'),('145003'),('145003'),('145003'),('145003'),('145003'),('145003'),('145003'),('145003'),('145003'),('145004'),('145004'),('145004'),('145004'),('145004'),('145004'),('145004'),('145004'),('145004'),('145005'),('145005'),('145005'),('145005'),('145005'),('145005'),('145005'),('145005'),('145005'),('145006'),('145006'),('145006'),('145006'),('145006'),('145006'),('145006'),('145006'),('145006'),('145008'),('145008'),('145008'),('145008'),('145008'),('145008'),('145008'),('145008'),('145009'),('145009'),('145009'),('145009'),('145009'),('145009'),('145009'),('145011'),('145011'),('145011'),('145011'),('145011'),('145011'),('145011'),('145011'),('145012'),('145012'),('145012'),('145012'),('145012'),('145012'),('145012'),('145012'),('145013'),('145013'),('145013'),('145013'),('145013'),('145013'),('145013'),('150009'),('150013'),('150014'),('150015'),('150015'),('150015'),('150016'),('150016'),('150017'),('150017'),('150017'),('150017'),('150020'),('152001'),('152001'),('152001'),('152002'),('152003'),('152003'),('152003'),('152003'),('152004'),('152005'),('152006'),('152006'),('152006'),('152006'),('152007'),('154001'),('154002'),('154002'),('155001'),('155001'),('155002'),('155003'),('155004'),('155004'),('155006'),('159001'),('159003'),('160001'),('160001'),('160001'),('160001'),('160002'),('160002'),('161001'),('162002'),('162002'),('162003'),('162003'),('162003'),('162003'),('162003'),('162007'),('162012'),('162012'),('162012'),('163001'),('163001'),('163001'),('163011'),('163015'),('163016'),('163016'),('165001'),('165001'),('165001'),('165001'),('165002'),('165002'),('165002'),('165002'),('165003'),('165003'),('165003'),('165004'),('165004'),('165004'),('165005'),('165005'),('165005'),('165006'),('165006'),('165006'),('165006'),('165007'),('165007'),('165007'),('165007'),('165008'),('165008'),('165008'),('165008'),('165009'),('165009'),('165009'),('165009'),('165010'),('165010'),('165010'),('165011'),('165011'),('165012'),('165012'),('165012'),('165013'),('165013'),('165013'),('165014'),('165014'),('165014'),('165015'),('165015'),('165015'),('165015'),('165016'),('165016'),('165016'),('165017'),('165017'),('165017'),('165017'),('165018'),('165018'),('165018'),('165018'),('165019'),('165019'),('165019'),('165019'),('165020'),('165020'),('165020'),('165020'),('165021'),('165021'),('165021'),('165021'),('165022'),('165022'),('165022'),('165023'),('165024'),('165024'),('165024'),('165025'),('165025'),('165025'),('165026'),('165026'),('165026'),('165028'),('165029'),('165030'),('165030'),('165030'),('165031'),('165031'),('165033'),('165033'),('165034'),('165034'),('165034'),('165035'),('165035'),('165035'),('165036'),('165036'),('165036'),('168003'),('168003'),('168004'),('168005'),('168014'),('169001'),('169001'),('169001'),('169001'),('169001'),('169001'),('169001'),('169001'),('169001'),('169001'),('169002'),('169002'),('169002'),('169002'),('169002'),('169002'),('169002'),('169002'),('169002'),('169002'),('169003'),('169003'),('169003'),('169003'),('169007'),('169007'),('169007'),('169007'),('169007'),('169007'),('169007'),('169007'),('169007'),('169007'),('169008'),('169008'),('169008'),('169008'),('169008'),('169008'),('169008'),('169009'),('169009'),('169009'),('169009'),('169010'),('171006'),('171006'),('171007'),('171007'),('171008'),('171008'),('171008'),('171009'),('171009'),('171009'),('172001'),('176001'),('176001'),('176001'),('176001'),('176001'),('176001'),('176001'),('176002'),('176002'),('176002'),('176002'),('176002'),('176003'),('176003'),('176003'),('176003'),('176003'),('176003'),('177001'),('177001'),('177001'),('177001'),('177001'),('177001'),('179007'),('179007'),('179012'),('179012'),('179012'),('179012'),('179012'),('179012'),('179013'),('179013'),('179013'),('179013'),('179013'),('179013'),('179042'),('179044'),('179045'),('180001'),('180013'),('180014'),('180014'),('180015'),('180017'),('180018'),('180020'),('180020'),('180021'),('180021'),('180027'),('180030'),('180033'),('180035'),('180036'),('180037'),('180038'),('180041'),('180042'),('180045'),('180045'),('180047'),('180048'),('180049'),('180050'),('180054'),('180060'),('180066'),('180067'),('180068'),('180070'),('182001'),('184001'),('184002'),('184005'),('184005'),('184005'),('184005'),('184006'),('184006'),('184006'),('184006'),('184008'),('184008'),('184008'),('184008'),('184009'),('184009'),('184009'),('184009'),('184010'),('184010'),('184010'),('184010'),('184011'),('184011'),('184011'),('184011'),('185001'),('185001'),('185001'),('185001'),('185001'),('185001'),('185001'),('185003'),('185003'),('185003'),('185003'),('185003'),('185003'),('185003'),('187001'),('191002'),('191002'),('192002'),('194003'),('197001'),('197001'),('197001'),('197001'),('197001'),('197001'),('197001'),('197002'),('197002'),('197002'),('197002'),('197002'),('197002'),('197002'),('197003'),('197003'),('197003'),('197003'),('197003'),('197003'),('197003'),('197004'),('197004'),('197004'),('197004'),('197004'),('197004'),('197004'),('197005'),('197005'),('197005'),('197005'),('197005'),('197005'),('197006'),('197006'),('197006'),('197006'),('197006'),('198001'),('198001'),('198001'),('198001'),('198001'),('198001'),('198003'),('198003'),('198003'),('198004'),('198004'),('198004'),('198004'),('198004'),('198004'),('198005'),('198005'),('198005'),('198005'),('198005'),('198005'),('198005'),('198006'),('198006'),('198006'),('198006'),('198006'),('198006'),('198007'),('198007'),('198007'),('198007'),('198007'),('198007'),('198007'),('198008'),('198008'),('198008'),('198008'),('198008'),('198008'),('198009'),('198009'),('198009'),('198009'),('198009'),('198009'),('198009'),('198010'),('198010'),('198010'),('198010'),('198010'),('198010'),('198011'),('198012'),('198012'),('198012'),('198012'),('198015'),('198015'),('198016'),('198016'),('198016'),('198016'),('198016'),('198016'),('198017'),('198017'),('198017'),('198017'),('198017'),('198017'),('201001'),('201001'),('201001'),('201001'),('201001'),('201002'),('202001'),('202001'),('203001'),('203001'),('203001'),('203001'),('203001'),('203001'),('203001'),('203002'),('203002'),('203002'),('203002'),('203003'),('203003'),('203003'),('203003'),('203003'),('203017'),('203017'),('203017'),('203017'),('203017'),('203017'),('203017'),('203017'),('203017'),('203018'),('203018'),('203018'),('203018'),('203018'),('203019'),('203019'),('203019'),('203019'),('203019'),('204001'),('204002'),('205001'),('205001'),('205001'),('205001'),('205001'),('205001'),('205001'),('208001'),('208001'),('208002'),('208002'),('208002'),('208003'),('208003'),('208003'),('208004'),('208004'),('208004'),('208004'),('208004'),('208004'),('208004'),('208005'),('208005'),('208005'),('208005'),('208005'),('209001'),('209001'),('209001'),('209001'),('209001'),('209002'),('209002'),('209002'),('209002'),('209002'),('209003'),('209003'),('209003'),('209003'),('209003'),('210001'),('210001'),('210001'),('210001'),('210001'),('210004'),('210004'),('210004'),('210004'),('210004'),('210004'),('210009'),('210010'),('212001'),('212001'),('212002'),('212002'),('212002'),('212002'),('212003'),('212003'),('212003'),('212004'),('212004'),('212004'),('212005'),('212005'),('212005'),('212005'),('212005'),('212006'),('212006'),('212006'),('212007'),('212007'),('212008'),('212008'),('212008'),('212008'),('212009'),('212009'),('212009'),('212009'),('212010'),('212010'),('212010'),('212010'),('212011'),('212011'),('212012'),('212012'),('212013'),('212013'),('212013'),('218001'),('218004'),('218009'),('218011'),('218011'),('218015'),('218020'),('218021'),('218021'),('218022'),('218022'),('218022'),('218023'),('218024'),('218025'),('218026'),('218026'),('218027'),('218028'),('218029'),('218029'),('218029'),('218030'),('218031'),('221001'),('221001'),('221001'),('221001'),('221001'),('221001'),('221002'),('221002'),('221002'),('221002'),('221002'),('221002'),('221003'),('221003'),('221003'),('221003'),('221003'),('221003'),('221004'),('221004'),('221004'),('221004'),('221004'),('221004'),('221005'),('221005'),('221005'),('221005'),('221005'),('221006'),('221006'),('221006'),('221006'),('221006'),('221007'),('221007'),('221007'),('221007'),('221007'),('221007'),('221008'),('221008'),('221008'),('221008'),('221008'),('221008'),('221009'),('221009'),('221009'),('221009'),('221009'),('221009'),('221010'),('221010'),('221010'),('221010'),('221011'),('221011'),('221011'),('221011'),('221012'),('221012'),('221012'),('221012'),('221012'),('221012'),('221013'),('221013'),('221013'),('221013'),('221013'),('221013'),('223003'),('223003'),('224001'),('224001'),('224002'),('224002'),('224003'),('224007'),('224008'),('225001'),('225002'),('225002'),('225002'),('225003'),('225003'),('225003'),('225003'),('225004'),('225004'),('225004'),('225005'),('225005'),('225005'),('225005'),('225005'),('225005'),('225006'),('225006'),('225006'),('225007'),('225007'),('225007'),('225008'),('225008'),('225008'),('225008'),('225008'),('225009'),('225009'),('225009'),('225010'),('225010'),('225010'),('225011'),('225011'),('225011'),('225011'),('225011'),('225012'),('225012'),('225012'),('225012'),('225012'),('225012'),('225013'),('225013'),('226001'),('226002'),('226003'),('226003'),('226005'),('226005'),('226006'),('226007'),('226007'),('226007'),('226007'),('227011'),('227015'),('227015'),('227041'),('227045'),('227052'),('227056'),('227063'),('227064'),('227066'),('227067'),('227069'),('227071'),('227073'),('227085'),('227116'),('227119'),('227131'),('227133'),('227147'),('229005'),('229005'),('229005'),('233003'),('233004'),('235001'),('235001'),('235002'),('235003'),('235003'),('235003'),('235004'),('235005'),('235005'),('235005'),('235005'),('235005'),('235005'),('235005'),('236001'),('236001'),('236001'),('236001'),('236002'),('236003'),('236003'),('236003'),('236003'),('236003'),('236003'),('238002'),('238002'),('238002'),('238002'),('238002'),('238002'),('238003'),('238003'),('238003'),('238003'),('238003'),('238003'),('238004'),('238004'),('238004'),('238004'),('238004'),('238005'),('238005'),('238005'),('238007'),('238007'),('238007'),('238007'),('238007'),('238007'),('238007'),('238008'),('238008'),('238008'),('238008'),('238008'),('238008'),('238008'),('334005'),('334006'),('337001'),('337001'),('337001'),('337002'),('337002'),('337003'),('337003'),('337003'),('337004'),('343001'),('343001'),('344001'),('344002'),('344003'),('344004'),('344005'),('344005'),('345001'),('345001'),('348001'),('348004'),('348005'),('348005'),('349001'),('349001'),('349002'),('349002'),('349002'),('350001'),('353002'),('353002'),('353002'),('353003'),('355001'),('355002'),('355005'),('355006'),('355006'),('356001'),('358001'),('358001'),('358001'),('359001'),('359001'),('359002'),('359002'),('359002'),('359002'),('360001'),('360001'),('360002'),('360002'),('360003'),('360003'),('360004'),('360004'),('360005'),('360005'),('360005'),('366001'),('366002'),('366002'),('366003'),('366004'),('369001'),('369001'),('373001'),('373002'),('373002'),('373003'),('373003'),('373005'),('373007'),('373008'),('373009'),('373009'),('373010'),('373010'),('373010'),('373011'),('373011'),('373011'),('373011'),('373012'),('373012'),('373012'),('373013'),('373013'),('373014'),('373014'),('373015'),('373015'),('373015'),('373015'),('373017'),('373017'),('373017'),('373017'),('373018'),('373021'),('374002'),('374004'),('374006'),('374007'),('374008'),('374009'),('374010'),('374011'),('374012'),('374015'),('374016'),('382001'),('382002'),('382002'),('384001'),('386001'),('386001'),('386001'),('386001'),('386001'),('386001'),('386001'),('386002'),('386002'),('386002'),('386002'),('386002'),('386002'),('386002'),('386003'),('386003'),('386003'),('386003'),('386003'),('386003'),('386003'),('386003'),('386003'),('386004'),('386004'),('386004'),('386004'),('386004'),('386004'),('386004'),('386004'),('386005'),('386005'),('386005'),('386005'),('386005'),('386005'),('386005'),('386006'),('386006'),('386006'),('386006'),('386006'),('386006'),('386007'),('386007'),('386007'),('386007'),('386007'),('386007'),('386007'),('386007'),('386007'),('386008'),('386008'),('386008'),('386008'),('386008'),('386008'),('386008'),('386008'),('386009'),('386009'),('386009'),('386010'),('386010'),('386010'),('386010'),('386010'),('386010'),('386010'),('386010'),('386011'),('386011'),('386011'),('386011'),('386011'),('386011'),('386011'),('386011'),('386011'),('386012'),('386012'),('386012'),('386012'),('386012'),('386012'),('386012'),('386012'),('386012'),('386013'),('386013'),('386013'),('386013'),('386013'),('386013'),('386013'),('386014'),('386014'),('386014'),('386014'),('389001'),('389002'),('389002'),('389003'),('389003'),('389003'),('389003'),('389004'),('389004'),('389004'),('389004'),('392001'),('393001'),('393002'),('393002'),('393003'),('393004'),('395001'),('395001'),('397001'),('397001'),('397001'),('397002'),('399001'),('399001'),('399001'),('399001'),('399001'),('399001'),('399001'),('399002'),('399002'),('399002'),('399002'),('399002'),('399002'),('399002'),('399003'),('400001'),('400001'),('400001'),('400001'),('400002'),('403002'),('504001'),('504001'),('504002'),('504002'),('504002'),('504004'),('504004'),('504005'),('504006'),('504007'),('504007'),('504007'),('504008'),('504008'),('504009'),('504009'),('504009'),('504009'),('504009'),('504010'),('504011'),('504011'),('504012'),('504012'),('504014'),('504014'),('504014'),('504014'),('504014'),('504014'),('504014'),('504014'),('504017'),('504017'),('504021'),('504021'),('504021'),('504021'),('504021'),('504021'),('504021'),('504022'),('504023'),('504023'),('504024'),('504024'),('504025'),('504025'),('506001'),('506001'),('506001'),('506001'),('506001'),('506001'),('506002'),('506002'),('506002'),('506002'),('506002'),('511001'),('511001'),('511001'),('511001'),('511001'),('511001'),('511001'),('511002'),('511002'),('511002'),('511002'),('511002'),('511002'),('511002'),('511003'),('511003'),('511003'),('511003'),('511003'),('511003'),('511004'),('511004'),('511004'),('511004'),('511004'),('511004'),('511004'),('511005'),('511005'),('511005'),('511005'),('511005'),('511005'),('511005'),('511006'),('511006'),('511006'),('511006'),('511006'),('511006'),('511006'),('511007'),('511007'),('511007'),('511007'),('511007'),('511008'),('511008'),('511008'),('511008'),('511008'),('511008'),('511009'),('511009'),('511009'),('511009'),('511009'),('511009'),('511010'),('511010'),('511010'),('511010'),('511010'),('511010'),('511011'),('511011'),('511011'),('511011'),('511011'),('511011'),('511012'),('511012'),('511012'),('511012'),('511012'),('511012'),('511012'),('511013'),('511013'),('511013'),('511013'),('511013'),('511013'),('511013'),('511014'),('511014'),('511014'),('511014'),('511014'),('511017'),('511018'),('511020'),('511021'),('511022'),('511024'),('511028'),('511029'),('511029'),('511029'),('511029'),('511029'),('511029'),('513001'),('513001'),('513001'),('513001'),('513001'),('513001'),('513001'),('513001'),('513002'),('513002'),('513002'),('513002'),('513002'),('513002'),('513003'),('513003'),('513003'),('513003'),('513003'),('513003'),('513003'),('513003'),('513004'),('513004'),('513004'),('515001'),('515001'),('515001'),('515001'),('515001'),('515002'),('515002'),('515003'),('515003'),('515007'),('515007'),('515008'),('515011'),('515011'),('515011'),('515011'),('515011'),('515011'),('515012'),('515012'),('515012'),('515012'),('515013'),('515013'),('515013'),('515013'),('515013'),('515014'),('515014'),('515014'),('515014'),('515014'),('515015'),('515015'),('515015'),('515015'),('515015'),('518001'),('518002'),('521001'),('521002'),('521002'),('521002'),('521003'),('521003'),('521003'),('521003'),('521004'),('521004'),('521004'),('521004'),('521005'),('521005'),('521005'),('521005'),('521006'),('521006'),('521006'),('521009'),('521010'),('521010'),('521010'),('521010'),('521011'),('521011'),('521011'),('521011'),('521012'),('521013'),('521013'),('521015'),('521016'),('521016'),('523001'),('523001'),('523001'),('523001'),('523001'),('523001'),('523001'),('523002'),('523002'),('523002'),('523002'),('523002'),('523002'),('523003'),('523003'),('523003'),('523003'),('523003'),('523003'),('523003'),('523004'),('523004'),('523004'),('523004'),('523004'),('523004'),('523005'),('523005'),('523005'),('523005'),('523005'),('523005'),('523005'),('523005'),('523006'),('523006'),('523006'),('523006'),('523006'),('523006'),('523006'),('523007'),('523007'),('523007'),('523007'),('523007'),('523007'),('523007'),('524001'),('700001'),('701001'),('701002'),('701003'),('702001'),('702002'),('702004'),('702005'),('704001'),('704004'),('705001'),('706001'),('706002'),('707001'),('707002'),('707003'),('708001'),('710001'),('710002'),('711001'),('711002'),('712001'),('714001'),('714002'),('715001'),('719001'),('719002'),('991002'),('991002'),('991002'),('991003'),('991003'),('991003'),('991003'),('991003'),('991003'),('991003'),('991004'),('991004'),('991004'),('991005'),('991005'),('991005'),('991006'),('991007'),('995001'),('995001'),('995001'),('995001'),('995001'),('995001'),('995001'),('995001'),('995001'),('995001'),('995001'),('996001'),('996001'),('996001'),('996001'),('996001'),('996001'),('996001'),('996001'),('996002'),('996002'),('996003'),('996003'),('996003'),('996003'),('996003'),('998001'),('998001'),('998001'),('998001'),('998001'),('998001'),('998001'),('998001'),('998001'),('998001'),('998002'),('998002'),('998002'),('998002'),('998002'),('998002'),('998002'),('998002'),('998002'),('998002'),('998003'),('998003'),('998003'),('998003'),('998003'),('998003'),('998003'),('998003'),('998004'),('998004'),('998005'),('998005'),('998006'),('998007'),('999001'),('999001'),('999001'),('999001'),('999001'),('999001'),('999001'),('999001'),('999001'),('999001'),('999001'),('999002'),('999002'),('011017'),('011017'),('011017'),('011017'),('011017'),('011017'),('011017'),('011018'),('011018'),('011018'),('011018'),('034001'),('034001'),('034002'),('034002'),('071010'),('071010'),('071010'),('519001'),('126013'),('126013'),('126013'),('126013'),('126013'),('184012'),('184012'),('184012'),('404001'),('405002'),('405002'),('405001'),('405003'),('405006'),('240011'),('240011'),('240011'),('240011'),('240011'),('240011'),('240010'),('240010'),('240010'),('240009'),('240009'),('240009'),('240009'),('240008'),('240008'),('240008'),('240007'),('240007'),('240007'),('240007'),('240007'),('240007'),('240005'),('240005'),('240005'),('240005'),('240005'),('240004'),('240004'),('240004'),('240004'),('240004'),('240003'),('240003'),('240003'),('240003'),('240002'),('240002'),('240002'),('240002'),('240002'),('240002'),('240002'),('240001'),('240001'),('240001'),('240001'),('240001'),('240012'),('240012'),('240012'),('240012'),('240012'),('240013'),('240014'),('240015'),('240015'),('240015'),('240015'),('240015'),('240015'),('240015'),('240015'),('240016'),('240016'),('240016'),('240016'),('240016'),('240016'),('240017'),('240017'),('240017'),('357001'),('357001'),('235006'),('235006'),('235007'),('235007'),('235007'),('235007'),('235007'),('056023'),('056023'),('056023'),('056023'),('056023'),('046015'),('019005'),('019005'),('126014'),('126014'),('126014'),('126014'),('126014'),('126014'),('241003'),('241003'),('241003'),('241003'),('241003'),('241003'),('241002'),('241002'),('241002'),('241002'),('241002'),('241002'),('241001'),('241001'),('241001'),('241001'),('241001'),('240020'),('240020'),('240020'),('240020'),('240020'),('240020'),('240019'),('240019'),('240019'),('242001'),('242002'),('242004'),('242005'),('242006'),('089002'),('089002'),('089002'),('089002'),('089002'),('089002'),('406001'),('406002'),('406003'),('406004'),('406004'),('243001'),('243005'),('243006'),('243007'),('243008'),('408001'),('408001'),('408001'),('408001'),('408001'),('366005'),('366005'),('016035'),('016035'),('016035'),('016035'),('077010'),('996004'),('996004'),('996004'),('996004'),('996004'),('996004'),('996004'),('996004'),('025064'),('025064'),('025064'),('025064'),('011019'),('011019'),('011019'),('011019'),('011019'),('115123'),('115123'),('504026'),('039007'),('039009'),('039008'),('039008'),('039010'),('039010'),('039011'),('039012'),('180072'),('240021'),('240021'),('240021'),('240021'),('240021'),('240021'),('240021'),('240023'),('240023'),('240023'),('240023'),('405008'),('405008'),('525002'),('410002'),('410002'),('410004'),('410005'),('410005'),('410006'),('410007'),('410007'),('410008'),('410009'),('410010'),('410011'),('410011'),('410012'),('410012'),('410013'),('410013'),('410014'),('410014'),('410016'),('410016'),('344006'),('240031'),('240031'),('240031'),('240031'),('240030'),('240030'),('240030'),('240030'),('240029'),('240029'),('240029'),('240029'),('240028'),('240028'),('240028'),('240028'),('240027'),('240027'),('240026'),('240026'),('240026'),('240025'),('240025'),('240025'),('240025'),('240024'),('240024'),('240034'),('240034'),('240034'),('240033'),('240033'),('240033'),('240032'),('240032'),('240032'),('240032'),('411001'),('411002'),('203020'),('069025'),('069025'),('069025'),('069025'),('069025'),('069025'),('244001'),('244001'),('244001'),('244001'),('244001'),('244001'),('244001'),('244001'),('244001'),('244001'),('244001'),('244002'),('244002'),('244002'),('244002'),('244002'),('244002'),('244002'),('244002'),('244002'),('244002'),('244002'),('244009'),('244009'),('244009'),('244009'),('244009'),('244009'),('244009'),('244009'),('244009'),('244009'),('244009'),('244008'),('244008'),('244008'),('244008'),('244008'),('244008'),('244008'),('244008'),('244008'),('244008'),('244008'),('244007'),('244007'),('244007'),('244007'),('244007'),('244007'),('244007'),('244007'),('244007'),('244007'),('244007'),('244006'),('244006'),('244006'),('244006'),('244006'),('244006'),('244006'),('244006'),('244006'),('244006'),('244006'),('244004'),('244004'),('244004'),('244004'),('244004'),('244004'),('244004'),('244004'),('244004'),('244004'),('244004'),('244003'),('244003'),('244003'),('244003'),('244003'),('244003'),('244003'),('244003'),('244003'),('244003'),('244003'),('244014'),('244014'),('244014'),('244014'),('244014'),('244014'),('244014'),('244014'),('244013'),('244013'),('244013'),('244013'),('244013'),('244013'),('244013'),('244013'),('244012'),('244012'),('244012'),('244012'),('244012'),('244012'),('244012'),('244012'),('244011'),('244011'),('244011'),('244011'),('244011'),('244011'),('244011'),('244011'),('244016'),('244016'),('244016'),('244016'),('244016'),('244016'),('244016'),('244016'),('244016'),('244016'),('244016'),('244017'),('244017'),('244017'),('244017'),('244017'),('244017'),('244017'),('244017'),('244017'),('240040'),('240037'),('405009'),('405009'),('405009'),('405010'),('405010'),('240043'),('240043'),('504028'),('504040'),('800001'),('410019'),('410019'),('410020'),('410020'),('410020'),('410021'),('410021'),('244018'),('244018'),('244018'),('244018'),('244018'),('244018'),('244018'),('244018'),('244018'),('244018'),('244018'),('244019'),('244019'),('244019'),('244019'),('244019'),('244019'),('244019'),('244019'),('244019'),('244019'),('244019'),('244020'),('244020'),('244020'),('244020'),('244020'),('244020'),('244020'),('244020'),('413001'),('344007'),('082045'),('082045'),('082045'),('082045'),('082045'),('010031'),('010031'),('010031'),('010031'),('010032'),('010032'),('010032'),('010032'),('010033'),('010033'),('010033'),('010033'),('010033'),('010034'),('010034'),('010034'),('010034'),('010035'),('010035'),('010035'),('010035'),('504044'),('515016'),('515016'),('515016'),('515016'),('801002'),('801003'),('801004'),('801005'),('802001'),('801001'),('414001'),('141029'),('803001'),('803002'),('803004'),('803005'),('803006'),('803007'),('803008'),('803009'),('803013'),('803014'),('803015'),('803016'),('803017'),('410022'),('410023'),('410023'),('803019'),('415002'),('415001'),('244021'),('244021'),('244021'),('244021'),('244021'),('244021'),('244021'),('011020'),('011020'),('011020'),('011020'),('011023'),('011023'),('011023'),('011023'),('011022'),('011022'),('011022'),('011022'),('011022'),('011022'),('011021'),('011021'),('011021'),('011021'),('025065'),('025065'),('025065'),('025065'),('165037'),('165037'),('165038'),('165038'),('165038'),('165039'),('416001'),('416001'),('416001'),('416001'),('416001'),('416002'),('416003'),('417001'),('418001'),('504045'),('504045'),('504045'),('803022'),('240022'),('240022'),('240022'),('240022'),('420001'),('420001'),('420001'),('420001'),('804010'),('804005'),('804002'),('804018'),('804013'),('511019'),('511016'),('511015'),('511032'),('511031'),('511030'),('511027'),('511026'),('511025'),('511033'),('511023'),('133034'),('133034'),('133034'),('133033'),('169011'),('169011'),('169011'),('169011'),('169011'),('344008'),('244022'),('244022'),('244022'),('244022'),('244022'),('244022'),('244022'),('244026'),('244026'),('244026'),('244026'),('244026'),('244026'),('244025'),('244025'),('244025'),('244025'),('244025'),('244025'),('244025'),('244025'),('244030'),('244030'),('244030'),('244030'),('244030'),('244030'),('244030'),('244030'),('244023'),('244023'),('244023'),('244023'),('244023'),('244023'),('244024'),('244024'),('244024'),('244024'),('244024'),('244024'),('244024'),('244024'),('244027'),('244027'),('244027'),('244027'),('244027'),('244027'),('244027'),('244027'),('244028'),('244028'),('244028'),('244028'),('244028'),('244028'),('244028'),('244028'),('244029'),('244029'),('244029'),('244029'),('244029'),('244029'),('244029'),('244029'),('244031'),('244031'),('244031'),('244031'),('244031'),('244031'),('244031'),('244031'),('082046'),('082046'),('082046'),('082046'),('082047'),('082047'),('082048'),('082048'),('126015'),('126015'),('126016'),('126016'),('126016'),('126016'),('126016'),('416005'),('421001'),('421001'),('421002'),('016037'),('016037'),('016037'),('016037'),('016036'),('016036'),('016036'),('016036'),('115124'),('115124'),('115126'),('240049'),('240049'),('240048'),('240048'),('240047'),('240047'),('240046'),('240046'),('240045'),('240044'),('244032'),('244033'),('422002'),('422004'),('422004'),('422004'),('422005'),('422005'),('184013'),('184013'),('184013'),('805001'),('805002'),('805003'),('805004'),('805005'),('056024'),('056024'),('056024'),('423001'),('344010'),('235009'),('235009'),('235009'),('235009'),('212014'),('212014'),('056025'),('056025'),('056025'),('056026'),('056026'),('056026'),('056026'),('056026'),('056026'),('244034'),('244034'),('244034'),('244034'),('244034'),('244034'),('244035'),('244035'),('244035'),('244035'),('244035'),('244035'),('244035'),('244036'),('244036'),('244036'),('244036'),('244036'),('244036'),('244036'),('244037'),('244037'),('244037'),('244037'),('244037'),('244037'),('244037'),('244038'),('244038'),('244038'),('244038'),('244038'),('244038'),('244038'),('244039'),('244039'),('244039'),('244039'),('244039'),('244039'),('244039'),('203015'),('245002'),('245002'),('245001'),('245001'),('056029'),('056030'),('056032'),('424001'),('056034'),('056034'),('056034'),('056034'),('056033'),('056033'),('056033'),('805006'),('805007'),('805008'),('805009'),('805010'),('422008'),('422008'),('422007'),('422007'),('422006'),('422006'),('422010'),('422009'),('422009'),('422011'),('422011'),('209004'),('209004'),('150022'),('100002'),('056035'),('056035'),('056035'),('023036'),('023036'),('185005'),('246001'),('246001'),('247001'),('247001'),('247001'),('247001'),('247001'),('247001'),('247001'),('247002'),('247002'),('425001'),('416006'),('416006'),('165042'),('165041'),('165040'),('165043'),('010040'),('010039'),('010038'),('010036'),('248001'),('248002'),('248003'),('248004'),('248005'),('249001'),('249003'),('249004'),('249005'),('250007'),('250001'),('250002'),('250003'),('250004'),('250005'),('250006'),('250008'),('250009'),('250010'),('250011'),('250012'),('250013'),('251001'),('251002'),('806001'),('806002'),('235010'),('243009'),('249007'),('249008'),('249009'),('011024'),('011025'),('429001'),('429001'),('429002'),('429002'),('429003'),('429003'); +select field from t1 group by field; +field +001001 +001010 +001018 +001020 +001021 +001027 +001028 +001030 +001031 +001100 +002003 +002004 +002005 +002007 +002008 +002009 +002012 +002013 +002014 +003002 +003003 +003004 +003005 +003006 +003007 +003008 +003009 +003010 +003011 +003012 +003013 +003014 +003015 +003016 +003017 +003018 +003019 +004003 +004005 +004006 +004008 +004010 +004012 +004014 +004016 +004017 +004020 +004021 +004022 +004023 +004025 +004026 +006004 +006006 +006010 +006011 +006012 +006014 +007001 +007002 +007003 +007005 +007007 +007008 +007009 +007011 +007012 +007013 +007015 +007016 +007017 +007018 +007019 +007020 +007021 +007022 +007023 +007025 +007027 +007029 +007031 +007032 +007034 +007036 +007037 +007038 +007040 +007043 +009001 +009002 +009004 +009005 +009006 +009007 +009008 +009010 +009011 +009012 +009013 +010002 +010003 +010004 +010005 +010006 +010007 +010008 +010009 +010010 +010011 +010012 +010013 +010015 +010016 +010017 +010018 +010019 +010020 +010021 +010022 +010023 +010026 +010027 +010028 +011001 +011002 +011003 +011004 +011006 +011012 +011013 +011014 +011015 +011016 +012017 +012027 +012032 +012034 +012036 +012037 +012038 +012039 +014001 +016016 +016019 +016020 +016021 +016022 +016023 +016024 +016026 +016028 +016029 +016030 +016031 +016032 +016033 +016034 +017002 +018001 +019002 +019004 +020001 +020004 +020006 +020008 +020009 +022001 +022002 +022003 +023001 +023002 +023003 +023004 +023005 +023006 +023007 +023010 +023011 +023017 +023019 +023020 +023025 +023026 +023027 +023028 +023029 +023030 +023032 +023033 +023034 +023035 +025001 +025003 +025004 +025005 +025007 +025008 +025009 +025010 +025011 +025012 +025013 +025014 +025015 +025016 +025018 +025019 +025020 +025021 +025022 +025023 +025024 +025025 +025026 +025027 +025028 +025030 +025031 +025033 +025034 +025035 +025037 +025041 +025042 +025043 +025046 +025048 +025049 +025050 +025051 +025052 +025053 +025054 +025055 +025056 +025057 +025058 +025060 +025061 +025062 +025063 +027001 +027002 +027011 +036001 +037003 +037006 +037007 +037008 +038009 +039001 +039002 +039003 +039004 +039005 +039006 +046001 +046002 +046003 +046005 +046007 +046008 +046009 +046010 +046012 +046013 +046014 +047001 +047002 +048001 +051003 +051004 +052001 +052002 +052005 +053016 +053019 +053023 +053024 +053026 +053028 +053029 +053033 +053045 +053046 +053051 +053054 +053057 +053069 +053097 +053107 +053125 +053127 +054001 +054002 +054003 +054004 +054006 +054007 +054009 +054010 +056001 +056002 +056003 +056004 +056005 +056006 +056009 +056011 +056016 +056017 +056018 +056019 +056020 +056022 +057003 +057004 +058002 +058003 +058004 +058005 +060001 +060004 +060005 +060007 +061004 +061006 +069006 +069007 +069010 +069011 +069012 +069013 +069014 +069015 +069016 +069018 +069020 +069021 +069023 +071002 +071003 +071004 +071005 +071006 +071008 +071011 +071020 +071021 +071022 +072001 +074001 +074002 +074003 +074004 +074005 +074006 +074007 +074008 +074009 +074010 +074011 +074012 +075001 +075007 +076101 +076102 +076103 +077001 +077002 +077003 +077004 +077006 +077008 +077009 +078005 +079002 +079003 +079004 +079005 +079006 +079007 +081001 +082011 +082013 +082014 +082015 +082016 +082017 +082021 +082022 +082023 +082024 +082025 +082026 +082027 +082028 +082029 +082030 +082031 +082032 +082033 +082034 +082035 +082036 +082037 +082038 +082039 +082040 +082041 +082042 +082043 +082044 +084001 +084002 +084003 +084004 +084005 +084007 +084008 +084009 +084011 +084013 +084014 +084016 +084017 +084027 +084032 +084033 +084035 +084036 +084037 +084038 +084039 +084040 +084041 +084042 +084043 +084044 +084045 +084046 +084047 +084048 +084049 +084050 +084051 +085001 +085002 +085003 +085004 +085005 +085006 +085007 +085009 +085011 +085012 +085014 +085015 +085016 +085017 +085018 +085019 +085020 +085022 +085023 +085028 +085029 +085030 +085031 +085033 +085034 +085035 +085036 +085037 +085038 +085040 +085041 +085042 +085043 +085044 +085045 +085046 +085047 +085048 +085063 +085064 +085065 +085068 +085071 +085073 +085082 +085086 +085088 +085089 +085090 +085091 +085092 +085093 +085095 +085096 +085097 +085098 +085099 +085100 +085101 +085102 +085103 +085104 +085105 +085106 +085108 +085109 +085110 +085111 +085112 +085113 +085115 +085120 +085121 +085122 +085123 +085125 +085126 +085127 +085128 +085129 +085130 +085132 +085133 +085134 +085135 +085136 +085137 +086002 +086003 +086005 +088001 +088003 +088005 +088006 +088007 +088008 +088009 +089001 +090001 +090002 +090003 +090004 +090006 +090008 +090009 +090010 +090013 +090016 +090017 +090018 +090022 +090027 +091001 +091002 +091009 +091011 +091012 +091013 +091015 +091016 +091017 +091018 +093003 +099001 +100001 +106001 +113005 +113006 +113018 +113019 +113020 +115001 +115002 +115003 +115004 +115005 +115006 +115007 +115008 +115009 +115010 +115011 +115012 +115013 +115014 +115015 +115016 +115017 +115018 +115020 +115021 +115022 +115023 +115025 +115026 +115027 +115028 +115029 +115030 +115031 +115032 +115033 +115034 +115035 +115036 +115039 +115040 +115041 +115042 +115043 +115044 +115046 +115047 +115048 +115050 +115051 +115052 +115053 +115054 +115055 +115057 +115059 +115060 +115061 +115062 +115064 +115065 +115066 +115067 +115068 +115069 +115070 +115071 +115072 +115073 +115075 +115076 +115081 +115082 +115085 +115086 +115087 +115088 +115095 +115096 +115097 +115098 +115099 +115101 +115102 +115103 +115104 +115105 +115106 +115108 +115109 +115111 +115112 +115113 +115114 +115115 +115116 +115117 +115118 +115119 +115120 +115121 +115122 +116001 +116003 +116004 +116005 +116006 +116007 +116008 +116009 +116010 +116011 +116012 +123001 +124065 +126001 +126002 +126003 +126004 +126005 +126006 +126007 +126008 +126009 +126010 +126011 +126012 +130001 +132001 +132002 +133001 +133008 +133009 +133010 +133011 +133012 +133015 +133016 +133018 +133019 +133021 +133022 +133023 +133024 +133025 +133027 +133028 +133029 +133030 +133031 +134001 +135001 +135002 +135004 +135010 +137010 +137011 +137012 +137014 +137015 +137016 +137019 +139001 +140001 +141001 +141002 +141003 +141006 +141007 +141009 +141011 +141012 +141014 +141015 +141016 +141017 +141018 +141019 +141020 +141021 +141022 +141023 +141024 +141025 +141026 +141027 +141028 +145001 +145002 +145003 +145004 +145005 +145006 +145008 +145009 +145011 +145012 +145013 +150009 +150013 +150014 +150015 +150016 +150017 +150020 +152001 +152002 +152003 +152004 +152005 +152006 +152007 +154001 +154002 +155001 +155002 +155003 +155004 +155006 +159001 +159003 +160001 +160002 +161001 +162002 +162003 +162007 +162012 +163001 +163011 +163015 +163016 +165001 +165002 +165003 +165004 +165005 +165006 +165007 +165008 +165009 +165010 +165011 +165012 +165013 +165014 +165015 +165016 +165017 +165018 +165019 +165020 +165021 +165022 +165023 +165024 +165025 +165026 +165028 +165029 +165030 +165031 +165033 +165034 +165035 +165036 +168003 +168004 +168005 +168014 +169001 +169002 +169003 +169007 +169008 +169009 +169010 +171006 +171007 +171008 +171009 +172001 +176001 +176002 +176003 +177001 +179007 +179012 +179013 +179042 +179044 +179045 +180001 +180013 +180014 +180015 +180017 +180018 +180020 +180021 +180027 +180030 +180033 +180035 +180036 +180037 +180038 +180041 +180042 +180045 +180047 +180048 +180049 +180050 +180054 +180060 +180066 +180067 +180068 +180070 +182001 +184001 +184002 +184005 +184006 +184008 +184009 +184010 +184011 +185001 +185003 +187001 +191002 +192002 +194003 +197001 +197002 +197003 +197004 +197005 +197006 +198001 +198003 +198004 +198005 +198006 +198007 +198008 +198009 +198010 +198011 +198012 +198015 +198016 +198017 +201001 +201002 +202001 +203001 +203002 +203003 +203017 +203018 +203019 +204001 +204002 +205001 +208001 +208002 +208003 +208004 +208005 +209001 +209002 +209003 +210001 +210004 +210009 +210010 +212001 +212002 +212003 +212004 +212005 +212006 +212007 +212008 +212009 +212010 +212011 +212012 +212013 +218001 +218004 +218009 +218011 +218015 +218020 +218021 +218022 +218023 +218024 +218025 +218026 +218027 +218028 +218029 +218030 +218031 +221001 +221002 +221003 +221004 +221005 +221006 +221007 +221008 +221009 +221010 +221011 +221012 +221013 +223003 +224001 +224002 +224003 +224007 +224008 +225001 +225002 +225003 +225004 +225005 +225006 +225007 +225008 +225009 +225010 +225011 +225012 +225013 +226001 +226002 +226003 +226005 +226006 +226007 +227011 +227015 +227041 +227045 +227052 +227056 +227063 +227064 +227066 +227067 +227069 +227071 +227073 +227085 +227116 +227119 +227131 +227133 +227147 +229005 +233003 +233004 +235001 +235002 +235003 +235004 +235005 +236001 +236002 +236003 +238002 +238003 +238004 +238005 +238007 +238008 +334005 +334006 +337001 +337002 +337003 +337004 +343001 +344001 +344002 +344003 +344004 +344005 +345001 +348001 +348004 +348005 +349001 +349002 +350001 +353002 +353003 +355001 +355002 +355005 +355006 +356001 +358001 +359001 +359002 +360001 +360002 +360003 +360004 +360005 +366001 +366002 +366003 +366004 +369001 +373001 +373002 +373003 +373005 +373007 +373008 +373009 +373010 +373011 +373012 +373013 +373014 +373015 +373017 +373018 +373021 +374002 +374004 +374006 +374007 +374008 +374009 +374010 +374011 +374012 +374015 +374016 +382001 +382002 +384001 +386001 +386002 +386003 +386004 +386005 +386006 +386007 +386008 +386009 +386010 +386011 +386012 +386013 +386014 +389001 +389002 +389003 +389004 +392001 +393001 +393002 +393003 +393004 +395001 +397001 +397002 +399001 +399002 +399003 +400001 +400002 +403002 +504001 +504002 +504004 +504005 +504006 +504007 +504008 +504009 +504010 +504011 +504012 +504014 +504017 +504021 +504022 +504023 +504024 +504025 +506001 +506002 +511001 +511002 +511003 +511004 +511005 +511006 +511007 +511008 +511009 +511010 +511011 +511012 +511013 +511014 +511017 +511018 +511020 +511021 +511022 +511024 +511028 +511029 +513001 +513002 +513003 +513004 +515001 +515002 +515003 +515007 +515008 +515011 +515012 +515013 +515014 +515015 +518001 +518002 +521001 +521002 +521003 +521004 +521005 +521006 +521009 +521010 +521011 +521012 +521013 +521015 +521016 +523001 +523002 +523003 +523004 +523005 +523006 +523007 +524001 +700001 +701001 +701002 +701003 +702001 +702002 +702004 +702005 +704001 +704004 +705001 +706001 +706002 +707001 +707002 +707003 +708001 +710001 +710002 +711001 +711002 +712001 +714001 +714002 +715001 +719001 +719002 +991002 +991003 +991004 +991005 +991006 +991007 +995001 +996001 +996002 +996003 +998001 +998002 +998003 +998004 +998005 +998006 +998007 +999001 +999002 +011017 +011018 +034001 +034002 +071010 +519001 +126013 +184012 +404001 +405002 +405001 +405003 +405006 +240011 +240010 +240009 +240008 +240007 +240005 +240004 +240003 +240002 +240001 +240012 +240013 +240014 +240015 +240016 +240017 +357001 +235006 +235007 +056023 +046015 +019005 +126014 +241003 +241002 +241001 +240020 +240019 +242001 +242002 +242004 +242005 +242006 +089002 +406001 +406002 +406003 +406004 +243001 +243005 +243006 +243007 +243008 +408001 +366005 +016035 +077010 +996004 +025064 +011019 +115123 +504026 +039007 +039009 +039008 +039010 +039011 +039012 +180072 +240021 +240023 +405008 +525002 +410002 +410004 +410005 +410006 +410007 +410008 +410009 +410010 +410011 +410012 +410013 +410014 +410016 +344006 +240031 +240030 +240029 +240028 +240027 +240026 +240025 +240024 +240034 +240033 +240032 +411001 +411002 +203020 +069025 +244001 +244002 +244009 +244008 +244007 +244006 +244004 +244003 +244014 +244013 +244012 +244011 +244016 +244017 +240040 +240037 +405009 +405010 +240043 +504028 +504040 +800001 +410019 +410020 +410021 +244018 +244019 +244020 +413001 +344007 +082045 +010031 +010032 +010033 +010034 +010035 +504044 +515016 +801002 +801003 +801004 +801005 +802001 +801001 +414001 +141029 +803001 +803002 +803004 +803005 +803006 +803007 +803008 +803009 +803013 +803014 +803015 +803016 +803017 +410022 +410023 +803019 +415002 +415001 +244021 +011020 +011023 +011022 +011021 +025065 +165037 +165038 +165039 +416001 +416002 +416003 +417001 +418001 +504045 +803022 +240022 +420001 +804010 +804005 +804002 +804018 +804013 +511019 +511016 +511015 +511032 +511031 +511030 +511027 +511026 +511025 +511033 +511023 +133034 +133033 +169011 +344008 +244022 +244026 +244025 +244030 +244023 +244024 +244027 +244028 +244029 +244031 +082046 +082047 +082048 +126015 +126016 +416005 +421001 +421002 +016037 +016036 +115124 +115126 +240049 +240048 +240047 +240046 +240045 +240044 +244032 +244033 +422002 +422004 +422005 +184013 +805001 +805002 +805003 +805004 +805005 +056024 +423001 +344010 +235009 +212014 +056025 +056026 +244034 +244035 +244036 +244037 +244038 +244039 +203015 +245002 +245001 +056029 +056030 +056032 +424001 +056034 +056033 +805006 +805007 +805008 +805009 +805010 +422008 +422007 +422006 +422010 +422009 +422011 +209004 +150022 +100002 +056035 +023036 +185005 +246001 +247001 +247002 +425001 +416006 +165042 +165041 +165040 +165043 +010040 +010039 +010038 +010036 +248001 +248002 +248003 +248004 +248005 +249001 +249003 +249004 +249005 +250007 +250001 +250002 +250003 +250004 +250005 +250006 +250008 +250009 +250010 +250011 +250012 +250013 +251001 +251002 +806001 +806002 +235010 +243009 +249007 +249008 +249009 +011024 +011025 +429001 +429002 +429003 +drop table t1; +create table t1 (a enum (' ','a','b') not null); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` enum('','a','b') NOT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +create table t1 (a enum (' ','a','b ') not null default 'b '); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` enum('','a','b') NOT NULL DEFAULT 'b' +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +create table t1 (a enum ('0','1')); +insert into t1 set a='foobar'; +Warnings: +Warning 1265 Data truncated for column 'a' at row 1 +select * from t1; +a + +update t1 set a = replace(a,'x','y'); +Warnings: +Warning 1265 Data truncated for column 'a' at row 1 +select * from t1; +a + +drop table t1; +set names latin1; +create table t1 (a enum(0xE4, '1', '2') not null default 0xE4) character set latin1; +show columns from t1; +Field Type Null Key Default Extra +a enum('ä','1','2') NO ä +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` enum('ä','1','2') NOT NULL DEFAULT 'ä' +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +drop table t1; +set names latin1; +CREATE TABLE t1 ( +a INT default 1, +b ENUM('value','öäü_value','ÊÃÕ') character set latin1 NOT NULL +); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int DEFAULT '1', + `b` enum('value','öäü_value','ÊÃÕ') CHARACTER SET latin1 COLLATE latin1_swedish_ci NOT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +show columns from t1; +Field Type Null Key Default Extra +a int YES 1 +b enum('value','öäü_value','ÊÃÕ') NO NULL +drop table t1; +CREATE TABLE t1 (c enum('a', 'A') BINARY); +Warnings: +Warning 1287 'BINARY as attribute of a type' is deprecated and will be removed in a future release. Please use a CHARACTER SET clause with _bin collation instead +INSERT INTO t1 VALUES ('a'),('A'); +SELECT * FROM t1; +c +a +A +DROP TABLE t1; +CREATE TABLE t1 (c enum('ae','oe','ue','ss') collate latin1_german2_ci); +INSERT INTO t1 VALUES ('ä'),('ö'),('ü'),('ß'); +SELECT * FROM t1; +c +ae +oe +ue +ss +DROP TABLE t1; +CREATE TABLE t1 ( +a ENUM('ä','ö','ü') character set utf8 default 'ü' +); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` enum('ä','ö','ü') CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT 'ü' +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +insert into t1 values ('ä'), ('ö'), ('ü'); +select a from t1 order by a; +a +ä +ö +ü +drop table t1; +set names utf8; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +CREATE TABLE t1 ( +a ENUM('ä','ö','ü') character set latin1 default 'ü' +); +insert into t1 values ('ä'),('ö'),('ü'); +set names latin1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` enum('ä','ö','ü') CHARACTER SET latin1 COLLATE latin1_swedish_ci DEFAULT 'ü' +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +select a from t1 order by a; +a +ä +ö +ü +drop table t1; +create table t1 (a enum ('Y','N') CHARACTER SET utf8 COLLATE utf8_bin); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 3778 'utf8_bin' is a collation of the deprecated character set UTF8MB3. Please consider using UTF8MB4 with an appropriate collation instead. +insert into t1 values ('Y'); +alter table t1 add b set ('Y','N') CHARACTER SET utf8 COLLATE utf8_bin; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 3778 'utf8_bin' is a collation of the deprecated character set UTF8MB3. Please consider using UTF8MB4 with an appropriate collation instead. +alter table t1 add c enum ('Y','N') CHARACTER SET utf8 COLLATE utf8_bin; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 3778 'utf8_bin' is a collation of the deprecated character set UTF8MB3. Please consider using UTF8MB4 with an appropriate collation instead. +select * from t1; +Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr +def test t1 t1 a a 254 1 1 Y 384 0 8 +def test t1 t1 b b 254 3 0 Y 2176 0 8 +def test t1 t1 c c 254 1 0 Y 384 0 8 +a b c +Y NULL NULL +drop table t1; +create table t1 (a enum('x','y') default 'x'); +alter table t1 alter a set default 'z'; +ERROR 42000: Invalid default value for 'a' +drop table t1; +create table t1 (a set('x','y') default 'x'); +alter table t1 alter a set default 'z'; +ERROR 42000: Invalid default value for 'a' +drop table t1; +create table t1 (f1 int); +alter table t1 add f2 enum(0xFFFF); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `f1` int DEFAULT NULL, + `f2` enum('') DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +create table t1(russian enum('E','F','EÿF','FÿE') NOT NULL DEFAULT'E'); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `russian` enum('E','F','EÿF','FÿE') NOT NULL DEFAULT 'E' +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +create table t1(denormal enum('E','F','E,F','F,E') NOT NULL DEFAULT'E'); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `denormal` enum('E','F','E,F','F,E') NOT NULL DEFAULT 'E' +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +create table t1(russian_deviant enum('E','F','EÿF','F,E') NOT NULL DEFAULT'E'); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `russian_deviant` enum('E','F','EÿF','F,E') NOT NULL DEFAULT 'E' +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +create table t1(exhausting_charset enum('ABCDEFGHIJKLMNOPQRSTUVWXYZ',' +  !"','#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~','xx\','yy\€','zz‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ ¡¢£¤¥¦§¨©ª«¬­®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ')); +drop table t1; +CREATE TABLE t1 ( +id INT AUTO_INCREMENT PRIMARY KEY, +c1 ENUM('a', '', 'b') +); +INSERT INTO t1 (c1) VALUES (0), ('a'), (''), ('b'); +Warnings: +Warning 1265 Data truncated for column 'c1' at row 1 +SELECT id, c1 + 0, c1 FROM t1; +id c1 + 0 c1 +1 0 +2 1 a +3 2 +4 3 b +ALTER TABLE t1 CHANGE c1 c1 ENUM('a', '') NOT NULL; +Warnings: +Warning 1265 Data truncated for column 'c1' at row 4 +SELECT id, c1 + 0, c1 FROM t1; +id c1 + 0 c1 +1 0 +2 1 a +3 2 +4 0 +DROP TABLE t1; +End of 4.1 tests +create table t1(f1 set('a','b'), index(f1)); +insert into t1 values(''),(''),('a'),('b'); +select * from t1 where f1=''; +f1 + + +drop table t1; +CREATE TABLE t1 (c1 ENUM('a', '', 'b')); +INSERT INTO t1 (c1) VALUES ('b'); +INSERT INTO t1 (c1) VALUES (''); +INSERT INTO t1 (c1) VALUES (0); +Warnings: +Warning 1265 Data truncated for column 'c1' at row 1 +INSERT INTO t1 (c1) VALUES (''); +SELECT c1 + 0, COUNT(c1) FROM t1 GROUP BY c1; +c1 + 0 COUNT(c1) +0 1 +2 2 +3 1 +CREATE TABLE t2 SELECT * FROM t1; +SELECT c1 + 0 FROM t2; +c1 + 0 +0 +2 +2 +3 +DROP TABLE t1,t2; +CREATE TABLE t1(a enum('a','b','c','d')); +INSERT INTO t1 VALUES (4),(1),(0),(3); +Warnings: +Warning 1265 Data truncated for column 'a' at row 3 +ANALYZE TABLE t1; +SELECT a FROM t1; +a +d +a + +c +EXPLAIN SELECT a FROM t1 WHERE a=0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 24.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 24.00 Using where +Warnings: +Note 1004 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` = 0) +SELECT a FROM t1 WHERE a=0; +a + +ALTER TABLE t1 ADD PRIMARY KEY (a); +EXPLAIN SELECT a FROM t1 WHERE a=0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL const PRIMARY PRIMARY 1 const 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select '' AS `a` from `test`.`t1` where true +SELECT a FROM t1 WHERE a=0; +a + +DROP TABLE t1; +SET sql_mode = default; +End of 5.1 tests +# +# Bug #25481355: Handle long enum literals gracefully. +# +# Handle a column type element < 255 symbols but > 255 bytes. +CREATE TABLE t1(exhausting_charset enum( +'zz‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ ¡¢£¤¥¦§¨©ª«¬­®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ')) +CHARSET=utf8mb4; +DROP TABLE t1; +# Fail if the element is > 255 symbols. +CREATE TABLE t1(exhausting_charset enum( +'zz‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ ¡¢£¤¥¦§¨©ª«¬­®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ + zz‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ ¡¢£¤¥¦§¨©ª«¬­®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ')) +CHARSET=utf8mb4; +ERROR HY000: Too long enumeration/set value for column exhausting_charset. +# Handle a parameter type element < 255 symbols but > 255 bytes. +CREATE PROCEDURE p1(exhausting_charset enum( +'zz‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ ¡¢£¤¥¦§¨©ª«¬­®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ') +CHARACTER SET utf8mb4) +BEGIN +END; +DROP PROCEDURE p1; +# Fail if the element is > 255 symbols. +CREATE PROCEDURE p1(exhausting_charset enum( +'zz‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ ¡¢£¤¥¦§¨©ª«¬­®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ + zz‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ ¡¢£¤¥¦§¨©ª«¬­®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ') +CHARACTER SET utf8mb4) +BEGIN +END; +ERROR HY000: Too long enumeration/set value for column exhausting_charset. +# +# Bug#28777704, Bug#28769996, Field_enum::cmp() hit ASSERT_COLUMN_MARKED_FOR_READ +# +set session optimizer_switch="derived_merge=off"; +set session internal_tmp_mem_storage_engine=temptable; +show function status; +select ROUTINE_SCHEMA, ROUTINE_NAME, ROUTINE_TYPE +from INFORMATION_SCHEMA.ROUTINES +where ROUTINE_TYPE = 'FUNCTION' + order by ROUTINE_SCHEMA, ROUTINE_NAME; +set session internal_tmp_mem_storage_engine=default; +set session optimizer_switch="derived_merge=default"; +CREATE TABLE grants ( +USER char(32), +HOST char(60), +PRIV char(32), +WITH_GRANT_OPTION enum('N','Y'), +PRIMARY KEY (WITH_GRANT_OPTION,`USER`,`HOST`, `PRIV`) +) engine innodb; +insert into grants values ('mysql.session','localhost','PERSIST_RO_VARIABLES_ADMIN','N'); +insert into grants values ('mysql.session','localhost','SESSION_VARIABLES_ADMIN','N'); +insert into grants values ('mysql.session','localhost','SYSTEM_VARIABLES_ADMIN','N'); +insert into grants values ('root','localhost','AXA_RECOVER_ADMIN','Y'); +insert into grants values ('root','localhost','BXA_RECOVER_ADMIN','Y'); +insert into grants values ('root','localhost','CXA_RECOVER_ADMIN','Y'); +insert into grants values ('root','localhost','DXA_RECOVER_ADMIN','Y'); +insert into grants values ('root','localhost','EXA_RECOVER_ADMIN','Y'); +insert into grants values ('root','localhost','FXA_RECOVER_ADMIN','Y'); +insert into grants values ('root','localhost','GXA_RECOVER_ADMIN','Y'); +insert into grants values ('root','localhost','HXA_RECOVER_ADMIN','Y'); +insert into grants values ('root','localhost','IXA_RECOVER_ADMIN','Y'); +insert into grants values ('root','localhost','JXA_RECOVER_ADMIN','Y'); +insert into grants values ('root','localhost','KXA_RECOVER_ADMIN','Y'); +insert into grants values ('root','localhost','LXA_RECOVER_ADMIN','Y'); +insert into grants values ('root','localhost','MXA_RECOVER_ADMIN','Y'); +insert into grants values ('root','localhost','XA_RECOVER_ADMIN','Y'); +analyze table grants; +Table Op Msg_type Msg_text +test.grants analyze status OK +EXPLAIN SELECT COUNT(*) FROM grants WHERE priv = 'XA_RECOVER_ADMIN'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE grants NULL range PRIMARY PRIMARY 497 NULL 2 100.00 Using where; Using index for skip scan +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`grants` where (`test`.`grants`.`PRIV` = 'XA_RECOVER_ADMIN') +SELECT COUNT(*) FROM grants WHERE priv = 'XA_RECOVER_ADMIN'; +COUNT(*) +1 +drop table grants; +# +# Bug #31019130 CASTING DOUBLE TO LONGLONG CAUSES UB +# IN FIELD_*::STORE(DOUBLE) +# +CREATE TABLE t_double (a double not null); +INSERT INTO t_double (a) VALUES +(-20000000000000000000000000000.0001), (20000000000000000000000000000.0001); +CREATE TABLE t_enum ( +b enum('N','Y') +); +INSERT IGNORE INTO t_enum (b) SELECT a from t_double; +Warnings: +Warning 1265 Data truncated for column 'b' at row 1 +Warning 1265 Data truncated for column 'b' at row 2 +SELECT b FROM t_enum; +b + + +DROP TABLE t_double, t_enum; diff --git a/mysql-test/r/type_float.result-pq b/mysql-test/r/type_float.result-pq new file mode 100644 index 000000000000..ab4c47f7a027 --- /dev/null +++ b/mysql-test/r/type_float.result-pq @@ -0,0 +1,726 @@ +SET sql_mode = 'NO_ENGINE_SUBSTITUTION'; +SELECT 10,10.0,10.,.1e+2,100.0e-1; +10 10.0 10. .1e+2 100.0e-1 +10 10.0 10 10 10 +SELECT 6e-16, -6e-16, --6e-16, -6e-16+1.000000; +6e-16 -6e-16 --6e-16 -6e-16+1.000000 +6e-16 -6e-16 6e-16 0.9999999999999994 +SELECT 1e1,1.e1,1.0e1,1e+1,1.e+1,1.0e+1,1e-1,1.e-1,1.0e-1; +1e1 1.e1 1.0e1 1e+1 1.e+1 1.0e+1 1e-1 1.e-1 1.0e-1 +10 10 10 10 10 10 0.1 0.1 0.1 +SELECT 0.001e+1,0.001e-1, -0.001e+01,-0.001e-01; +0.001e+1 0.001e-1 -0.001e+01 -0.001e-01 +0.01 0.0001 -0.01 -0.0001 +SELECT 123.23E+02,-123.23E-02,"123.23E+02"+0.0,"-123.23E-02"+0.0; +123.23E+02 -123.23E-02 "123.23E+02"+0.0 "-123.23E-02"+0.0 +12323 -1.2323 12323 -1.2323 +SELECT 2147483647E+02,21474836.47E+06; +2147483647E+02 21474836.47E+06 +214748364700 21474836470000 +create table t1 (f1 float(24),f2 float(52)); +show full columns from t1; +Field Type Collation Null Key Default Extra Privileges Comment +f1 float NULL YES NULL select,insert,update,references +f2 double NULL YES NULL select,insert,update,references +insert into t1 values(10,10),(1e+5,1e+5),(1234567890,1234567890),(1e+10,1e+10),(1e+15,1e+15),(1e+20,1e+20),(1e+50,1e+50),(1e+150,1e+150); +Warnings: +Warning 1264 Out of range value for column 'f1' at row 7 +Warning 1264 Out of range value for column 'f1' at row 8 +insert into t1 values(-10,-10),(1e-5,1e-5),(1e-10,1e-10),(1e-15,1e-15),(1e-20,1e-20),(1e-50,1e-50),(1e-150,1e-150); +select * from t1; +f1 f2 +10 10 +100000 100000 +1234570000 1234567890 +10000000000 10000000000 +1e15 1e15 +1e20 1e20 +3.40282e38 1e50 +3.40282e38 1e150 +-10 -10 +0.00001 0.00001 +0.0000000001 0.0000000001 +0.000000000000001 0.000000000000001 +1e-20 1e-20 +0 1e-50 +0 1e-150 +drop table t1; +create table t1 (datum double); +insert into t1 values (0.5),(1.0),(1.5),(2.0),(2.5); +select * from t1; +datum +0.5 +1 +1.5 +2 +2.5 +select * from t1 where datum < 1.5; +datum +0.5 +1 +select * from t1 where datum > 1.5; +datum +2 +2.5 +select * from t1 where datum = 1.5; +datum +1.5 +drop table t1; +create table t1 (a decimal(7,3) not null, key (a)); +insert into t1 values ("0"),("-0.00"),("-0.01"),("-0.002"),("1"); +select a from t1 order by a; +a +-0.010 +-0.002 +0.000 +0.000 +1.000 +select min(a) from t1; +min(a) +-0.010 +drop table t1; +create table t1 (c1 double, c2 varchar(20)); +insert t1 values (121,"16"); +select c1 + c1 * (c2 / 100) as col from t1; +col +140.36 +create table t2 select c1 + c1 * (c2 / 100) as col1, round(c1, 5) as col2, round(c1, 35) as col3, sqrt(c1*1e-15) col4 from t1; +select * from t2; +col1 col2 col3 col4 +140.36 121 121 0.00000034785054261852176 +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `col1` double DEFAULT NULL, + `col2` double DEFAULT NULL, + `col3` double DEFAULT NULL, + `col4` double DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1,t2; +create table t1 (a float); +insert into t1 values (1); +select max(a),min(a),avg(a) from t1; +max(a) min(a) avg(a) +1 1 1 +drop table t1; +create table t1 (f float, f2 float(24), f3 float(6,2), d double, d2 float(53), d3 double(10,3), de decimal, de2 decimal(6), de3 decimal(5,2), n numeric, n2 numeric(8), n3 numeric(7,6)); +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +show full columns from t1; +Field Type Collation Null Key Default Extra Privileges Comment +f float NULL YES NULL select,insert,update,references +f2 float NULL YES NULL select,insert,update,references +f3 float(6,2) NULL YES NULL select,insert,update,references +d double NULL YES NULL select,insert,update,references +d2 double NULL YES NULL select,insert,update,references +d3 double(10,3) NULL YES NULL select,insert,update,references +de decimal(10,0) NULL YES NULL select,insert,update,references +de2 decimal(6,0) NULL YES NULL select,insert,update,references +de3 decimal(5,2) NULL YES NULL select,insert,update,references +n decimal(10,0) NULL YES NULL select,insert,update,references +n2 decimal(8,0) NULL YES NULL select,insert,update,references +n3 decimal(7,6) NULL YES NULL select,insert,update,references +drop table t1; +create table t1 (a decimal(7,3) not null, key (a)); +insert into t1 values ("0"),("-0.00"),("-0.01"),("-0.002"),("1"); +select a from t1 order by a; +a +-0.010 +-0.002 +0.000 +0.000 +1.000 +select min(a) from t1; +min(a) +-0.010 +drop table t1; +create table t1 (a float(200,100), b double(200,100)); +ERROR 42000: Too big scale 100 specified for column 'a'. Maximum is 30. +create table t1 (c20 char); +insert into t1 values (5000.0); +Warnings: +Warning 1265 Data truncated for column 'c20' at row 1 +insert into t1 values (0.5e4); +Warnings: +Warning 1265 Data truncated for column 'c20' at row 1 +drop table t1; +create table t1 (f float(54)); +ERROR 42000: Incorrect column specifier for column 'f' +drop table if exists t1; +create table t1 (d1 double, d2 double unsigned); +Warnings: +Warning 1681 UNSIGNED for decimal and floating point data types is deprecated and support for it will be removed in a future release. +insert into t1 set d1 = -1.0; +update t1 set d2 = d1; +Warnings: +Warning 1264 Out of range value for column 'd2' at row 1 +select * from t1; +d1 d2 +-1 0 +drop table t1; +create table t1 (f float(4,3)); +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +insert into t1 values (-11.0),(-11),("-11"),(11.0),(11),("11"); +Warnings: +Warning 1264 Out of range value for column 'f' at row 1 +Warning 1264 Out of range value for column 'f' at row 2 +Warning 1264 Out of range value for column 'f' at row 3 +Warning 1264 Out of range value for column 'f' at row 4 +Warning 1264 Out of range value for column 'f' at row 5 +Warning 1264 Out of range value for column 'f' at row 6 +select * from t1; +f +-9.999 +-9.999 +-9.999 +9.999 +9.999 +9.999 +drop table if exists t1; +create table t1 (f double(4,3)); +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +insert into t1 values (-11.0),(-11),("-11"),(11.0),(11),("11"); +Warnings: +Warning 1264 Out of range value for column 'f' at row 1 +Warning 1264 Out of range value for column 'f' at row 2 +Warning 1264 Out of range value for column 'f' at row 3 +Warning 1264 Out of range value for column 'f' at row 4 +Warning 1264 Out of range value for column 'f' at row 5 +Warning 1264 Out of range value for column 'f' at row 6 +select * from t1; +f +-9.999 +-9.999 +-9.999 +9.999 +9.999 +9.999 +drop table if exists t1; +create table t1 (c char(20)); +insert into t1 values (5e-28); +select * from t1; +c +5e-28 +drop table t1; +create table t1 (c char(6)); +insert into t1 values (2e5),(2e6),(2e-4),(2e-5); +select * from t1; +c +200000 +2e6 +0.0002 +2e-5 +drop table t1; +create table t1 (d double(10,1)); +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +create table t2 (d double(10,9)); +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +insert into t1 values ("100000000.0"); +insert into t2 values ("1.23456780"); +create table t3 select * from t2 union select * from t1; +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +select * from t3; +d +1.234567800 +100000000.000000000 +show create table t3; +Table Create Table +t3 CREATE TABLE `t3` ( + `d` double(18,9) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1, t2, t3; +create table t1 select 105213674794682365.00 + 0.0 x; +show warnings; +Level Code Message +desc t1; +Field Type Null Key Default Extra +x decimal(21,2) NO 0.00 +drop table t1; +create table t1 select 0.0 x; +desc t1; +Field Type Null Key Default Extra +x decimal(2,1) NO 0.0 +create table t2 select 105213674794682365.00 y; +desc t2; +Field Type Null Key Default Extra +y decimal(20,2) NO 0.00 +create table t3 select x+y a from t1,t2; +show warnings; +Level Code Message +desc t3; +Field Type Null Key Default Extra +a decimal(21,2) NO 0.00 +drop table t1,t2,t3; +select 1e-308, 1.00000001e-300, 100000000e-300; +1e-308 1.00000001e-300 100000000e-300 +1e-308 1.00000001e-300 1e-292 +select 10e307; +10e307 +1e308 +create table t1(a int, b double(8, 2)); +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +insert into t1 values +(1, 28.50), (1, 121.85), (1, 157.23), (1, 1351.00), (1, -1965.35), (1, 81.75), +(1, 217.08), (1, 7.94), (4, 96.07), (4, 6404.65), (4, -6500.72), (2, 100.00), +(5, 5.00), (5, -2104.80), (5, 2033.80), (5, 0.07), (5, 65.93), +(3, -4986.24), (3, 5.00), (3, 4857.34), (3, 123.74), (3, 0.16), +(6, -1695.31), (6, 1003.77), (6, 499.72), (6, 191.82); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +explain select sum(b) s from t1 group by a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 26 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 26 100.00 Using temporary +Warnings: +Note 1003 /* select#1 */ select sum(`test`.`t1`.`b`) AS `s` from `test`.`t1` group by `test`.`t1`.`a` +select sum(b) s from t1 group by a; +s +-0.00 +-0.00 +0.00 +0.00 +0.00 +100.00 +select sum(b) s from t1 group by a having s <> 0; +s +100.00 +select sum(b) s from t1 group by a having s <> 0 order by s; +s +100.00 +select sum(b) s from t1 group by a having s <=> 0; +s +-0.00 +-0.00 +0.00 +0.00 +0.00 +select sum(b) s from t1 group by a having s <=> 0 order by s; +s +-0.00 +-0.00 +0.00 +0.00 +0.00 +alter table t1 add key (a, b); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +explain select sum(b) s from t1 group by a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 26 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index a a 14 NULL 26 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select sum(`test`.`t1`.`b`) AS `s` from `test`.`t1` group by `test`.`t1`.`a` +select sum(b) s from t1 group by a; +s +-0.00 +0.00 +0.00 +0.00 +0.00 +100.00 +select sum(b) s from t1 group by a having s <> 0; +s +100.00 +select sum(b) s from t1 group by a having s <> 0 order by s; +s +100.00 +select sum(b) s from t1 group by a having s <=> 0; +s +-0.00 +0.00 +0.00 +0.00 +0.00 +select sum(b) s from t1 group by a having s <=> 0 order by s; +s +-0.00 +0.00 +0.00 +0.00 +0.00 +drop table t1; +End of 4.1 tests +create table t1 (s1 float(0,2)); +ERROR 42000: For float(M,D), double(M,D) or decimal(M,D), M must be >= D (column 's1'). +create table t1 (s1 float(1,2)); +ERROR 42000: For float(M,D), double(M,D) or decimal(M,D), M must be >= D (column 's1'). +CREATE TABLE t1 ( +f1 real zerofill, +f2 double zerofill, +f3 float zerofill); +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +INSERT INTO t1 VALUES ( 0.314152e+1, 0.314152e+1, 0.314152e+1); +PREPARE stmt1 FROM 'select f1, f2, f3 FROM t1'; +select f1, f2, f3 FROM t1; +f1 f2 f3 +0000000000000003.14152 0000000000000003.14152 000003.14152 +select f1, f2, f3 FROM t1; +f1 f2 f3 +0000000000000003.14152 0000000000000003.14152 000003.14152 +EXECUTE stmt1; +f1 f2 f3 +0000000000000003.14152 0000000000000003.14152 000003.14152 +DROP TABLE t1; +create table t1 (f1 double(200, 0)); +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +insert into t1 values (1e199), (-1e199); +insert into t1 values (1e200), (-1e200); +insert into t1 values (2e200), (-2e200); +Warnings: +Warning 1264 Out of range value for column 'f1' at row 1 +Warning 1264 Out of range value for column 'f1' at row 2 +select f1 + 0e0 from t1; +f1 + 0e0 +1e199 +-1e199 +1e200 +-1e200 +1e200 +-1e200 +drop table t1; +create table t1 (f1 float(30, 0)); +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +insert into t1 values (1e29), (-1e29); +insert into t1 values (1e30), (-1e30); +insert into t1 values (2e30), (-2e30); +Warnings: +Warning 1264 Out of range value for column 'f1' at row 1 +Warning 1264 Out of range value for column 'f1' at row 2 +select f1 + 0e0 from t1; +f1 + 0e0 +1.0000000150474662e29 +-1.0000000150474662e29 +1.0000000150474662e30 +-1.0000000150474662e30 +1.0000000150474662e30 +-1.0000000150474662e30 +drop table t1; +create table t1 (c char(6)); +insert into t1 values (2e6),(2e-5); +select * from t1; +c +2e6 +2e-5 +drop table t1; +CREATE TABLE d1 (d DOUBLE); +INSERT INTO d1 VALUES (1.7976931348623157E+308); +SELECT * FROM d1; +d +1.7976931348623157e308 +INSERT INTO d1 VALUES (1.79769313486232e+308); +ERROR 22007: Illegal double '1.79769313486232e+308' value found during parsing +SELECT * FROM d1; +d +1.7976931348623157e308 +DROP TABLE d1; +create table t1 (a char(20)); +insert into t1 values (1.225e-05); +select a+0 from t1; +a+0 +0.00001225 +drop table t1; +create table t1(d double, u bigint unsigned); +insert into t1(d) values (9.22337203685479e18), +(1.84e19); +update t1 set u = d; +select u from t1; +u +9223372036854790144 +18400000000000000000 +drop table t1; +CREATE TABLE t1 (f1 DOUBLE); +INSERT INTO t1 VALUES(-1.79769313486231e+308); +SELECT f1 FROM t1; +f1 +-1.79769313486231e308 +DROP TABLE t1; +# +# Bug#12406055 BUFFER OVERFLOW OF VARIABLE 'BUFF' IN STRING::SET_REAL +# +# Ignoring output from misc. float operations +select format(-1.7976931348623157E+307,256) as foo; +select least(-1.1111111111111111111111111, +- group_concat(1.7976931348623157E+308)) as foo; +select concat((truncate((-1.7976931348623157E+307),(0x1e))), +(99999999999999999999999999999999999999999999999999999999999999999)) into @a; +End of 5.0 tests +# +# Bug#12368853 FORMAT() CRASHES WITH LARGE NUMBERS AFTER TRUNCATE... +# +select format(truncate('1.7976931348623157E+308',-12),1,'fr_BE') as foo; +foo +0 +# +# Bug #13500371 63704: CONVERSION OF '1.' TO A NUMBER GIVES ERROR 1265 +# (WARN_DATA_TRUNCATED) +# +CREATE TABLE t1 (f FLOAT); +INSERT INTO t1 VALUES ('1.'); +INSERT INTO t1 VALUES ('2.0.'); +Warnings: +Warning 1265 Data truncated for column 'f' at row 1 +INSERT INTO t1 VALUES ('.'); +Warnings: +Warning 1265 Data truncated for column 'f' at row 1 +SELECT * FROM t1 ORDER BY f; +f +0 +1 +2 +DROP TABLE t1; +SET sql_mode = default; +# +# Bug#28225635 RUNTIME ERROR: 1E+52 IS OUTSIDE THE RANGE OF +# REPRESENTABLE VALUES OF TYPE FLOAT +# +CREATE TABLE t5u(c1 FLOAT(58,0) UNSIGNED NOT NULL); +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 UNSIGNED for decimal and floating point data types is deprecated and support for it will be removed in a future release. +CREATE TABLE t5s(c1 FLOAT(58,0) SIGNED NOT NULL); +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +INSERT INTO t5u VALUES('1e+52'); +ERROR 22003: Out of range value for column 'c1' at row 1 +INSERT INTO t5s VALUES('-1e+52'); +ERROR 22003: Out of range value for column 'c1' at row 1 +SELECT * from t5u; +c1 +SELECT * from t5s; +c1 +DROP TABLE t5u, t5s; +# +# WL#12575: Deprecate AUTO_INCREMENT on DOUBLE and FLOAT +# +CREATE TABLE t1(a FLOAT PRIMARY KEY AUTO_INCREMENT); +Warnings: +Warning 3856 AUTO_INCREMENT support for FLOAT/DOUBLE columns is deprecated and will be removed in a future release. Consider removing AUTO_INCREMENT from column 'a'. +ALTER TABLE t1 ADD COLUMN b INT; +CREATE TABLE t2 LIKE t1; +Warnings: +Warning 3856 AUTO_INCREMENT support for FLOAT/DOUBLE columns is deprecated and will be removed in a future release. Consider removing AUTO_INCREMENT from column 'a'. +CREATE TABLE t3(a FLOAT); +ALTER TABLE t3 MODIFY COLUMN a FLOAT PRIMARY KEY AUTO_INCREMENT; +Warnings: +Warning 3856 AUTO_INCREMENT support for FLOAT/DOUBLE columns is deprecated and will be removed in a future release. Consider removing AUTO_INCREMENT from column 'a'. +CREATE TABLE t4(a INT PRIMARY KEY); +ALTER TABLE t4 DROP PRIMARY KEY, ADD COLUMN b FLOAT PRIMARY KEY AUTO_INCREMENT; +Warnings: +Warning 3856 AUTO_INCREMENT support for FLOAT/DOUBLE columns is deprecated and will be removed in a future release. Consider removing AUTO_INCREMENT from column 'b'. +DROP TABLE t4, t3, t2, t1; +CREATE TABLE t1(a DOUBLE PRIMARY KEY AUTO_INCREMENT); +Warnings: +Warning 3856 AUTO_INCREMENT support for FLOAT/DOUBLE columns is deprecated and will be removed in a future release. Consider removing AUTO_INCREMENT from column 'a'. +ALTER TABLE t1 ADD COLUMN b INT; +CREATE TABLE t2 LIKE t1; +Warnings: +Warning 3856 AUTO_INCREMENT support for FLOAT/DOUBLE columns is deprecated and will be removed in a future release. Consider removing AUTO_INCREMENT from column 'a'. +CREATE TABLE t3(a DOUBLE); +ALTER TABLE t3 MODIFY COLUMN a DOUBLE PRIMARY KEY AUTO_INCREMENT; +Warnings: +Warning 3856 AUTO_INCREMENT support for FLOAT/DOUBLE columns is deprecated and will be removed in a future release. Consider removing AUTO_INCREMENT from column 'a'. +CREATE TABLE t4(a INT PRIMARY KEY); +ALTER TABLE t4 DROP PRIMARY KEY, ADD COLUMN b DOUBLE PRIMARY KEY AUTO_INCREMENT; +Warnings: +Warning 3856 AUTO_INCREMENT support for FLOAT/DOUBLE columns is deprecated and will be removed in a future release. Consider removing AUTO_INCREMENT from column 'b'. +DROP TABLE t4, t3, t2, t1; +# +# WL#12595: Deprecate the ability to specify number of digits +# for floating point types +# +CREATE TABLE t1(a FLOAT(255,0)); +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +ALTER TABLE t1 ADD COLUMN b INT; +CREATE TABLE t2 LIKE t1; +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +CREATE TABLE t3 AS SELECT * FROM t1; +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +CREATE TABLE t4(a FLOAT); +ALTER TABLE t4 MODIFY COLUMN a FLOAT(255,0); +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +CREATE TABLE t5(a INT PRIMARY KEY); +ALTER TABLE t5 ADD COLUMN b FLOAT(255,0); +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +CREATE TABLE t6(a FLOAT(12)); +DROP TABLE t6, t5, t4, t3, t2, t1; +CREATE TABLE t1(a DOUBLE(42,12)); +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +ALTER TABLE t1 ADD COLUMN b INT; +CREATE TABLE t2 LIKE t1; +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +CREATE TABLE t3 AS SELECT * FROM t1; +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +CREATE TABLE t4(a DOUBLE); +ALTER TABLE t4 MODIFY COLUMN a DOUBLE(42,12); +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +CREATE TABLE t5(a INT PRIMARY KEY); +ALTER TABLE t5 ADD COLUMN b DOUBLE(42,12); +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +DROP TABLE t5, t4, t3, t2, t1; +CREATE TABLE t1(a DOUBLE PRECISION(42,12)); +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +ALTER TABLE t1 ADD COLUMN b INT; +CREATE TABLE t2 LIKE t1; +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +CREATE TABLE t3 AS SELECT * FROM t1; +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +CREATE TABLE t4(a DOUBLE); +ALTER TABLE t4 MODIFY COLUMN a DOUBLE PRECISION(42,12); +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +CREATE TABLE t5(a INT PRIMARY KEY); +ALTER TABLE t5 ADD COLUMN b DOUBLE PRECISION(42,12); +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +DROP TABLE t5, t4, t3, t2, t1; +CREATE TABLE t1(a REAL(42,12)); +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +ALTER TABLE t1 ADD COLUMN b INT; +CREATE TABLE t2 LIKE t1; +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +CREATE TABLE t3 AS SELECT * FROM t1; +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +CREATE TABLE t4(a REAL); +ALTER TABLE t4 MODIFY COLUMN a REAL(42,12); +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +CREATE TABLE t5(a INT PRIMARY KEY); +ALTER TABLE t5 ADD COLUMN b REAL(42,12); +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +DROP TABLE t5, t4, t3, t2, t1; +CREATE FUNCTION f1(a FLOAT(255,0)) RETURNS DOUBLE(12,3) RETURN 1; +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +DROP FUNCTION f1; +CREATE PROCEDURE p1(IN a FLOAT(255,0), OUT b DOUBLE(12,3)) +BEGIN +SELECT 1 INTO b; +END|| +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +DROP PROCEDURE p1; +# +# WL#12391: Deprecate unsigned attribute for DECIMAL and FLOAT data types +# +CREATE TABLE t1(a FLOAT UNSIGNED); +Warnings: +Warning 1681 UNSIGNED for decimal and floating point data types is deprecated and support for it will be removed in a future release. +ALTER TABLE t1 ADD COLUMN b INT; +CREATE TABLE t2 LIKE t1; +Warnings: +Warning 1681 UNSIGNED for decimal and floating point data types is deprecated and support for it will be removed in a future release. +CREATE TABLE t3 AS SELECT * FROM t1; +Warnings: +Warning 1681 UNSIGNED for decimal and floating point data types is deprecated and support for it will be removed in a future release. +CREATE TABLE t4(a FLOAT); +ALTER TABLE t4 MODIFY COLUMN a FLOAT UNSIGNED; +Warnings: +Warning 1681 UNSIGNED for decimal and floating point data types is deprecated and support for it will be removed in a future release. +CREATE TABLE t5(a INT PRIMARY KEY); +ALTER TABLE t5 ADD COLUMN b FLOAT UNSIGNED; +Warnings: +Warning 1681 UNSIGNED for decimal and floating point data types is deprecated and support for it will be removed in a future release. +DROP TABLE t5, t4, t3, t2, t1; +CREATE TABLE t1(a DOUBLE UNSIGNED); +Warnings: +Warning 1681 UNSIGNED for decimal and floating point data types is deprecated and support for it will be removed in a future release. +ALTER TABLE t1 ADD COLUMN b INT; +CREATE TABLE t2 LIKE t1; +Warnings: +Warning 1681 UNSIGNED for decimal and floating point data types is deprecated and support for it will be removed in a future release. +CREATE TABLE t3 AS SELECT * FROM t1; +Warnings: +Warning 1681 UNSIGNED for decimal and floating point data types is deprecated and support for it will be removed in a future release. +CREATE TABLE t4(a DOUBLE); +ALTER TABLE t4 MODIFY COLUMN a DOUBLE UNSIGNED; +Warnings: +Warning 1681 UNSIGNED for decimal and floating point data types is deprecated and support for it will be removed in a future release. +CREATE TABLE t5(a INT PRIMARY KEY); +ALTER TABLE t5 ADD COLUMN b DOUBLE UNSIGNED; +Warnings: +Warning 1681 UNSIGNED for decimal and floating point data types is deprecated and support for it will be removed in a future release. +DROP TABLE t5, t4, t3, t2, t1; +CREATE TABLE t1(a REAL UNSIGNED); +Warnings: +Warning 1681 UNSIGNED for decimal and floating point data types is deprecated and support for it will be removed in a future release. +ALTER TABLE t1 ADD COLUMN b INT; +CREATE TABLE t2 LIKE t1; +Warnings: +Warning 1681 UNSIGNED for decimal and floating point data types is deprecated and support for it will be removed in a future release. +CREATE TABLE t3 AS SELECT * FROM t1; +Warnings: +Warning 1681 UNSIGNED for decimal and floating point data types is deprecated and support for it will be removed in a future release. +CREATE TABLE t4(a REAL); +ALTER TABLE t4 MODIFY COLUMN a REAL UNSIGNED; +Warnings: +Warning 1681 UNSIGNED for decimal and floating point data types is deprecated and support for it will be removed in a future release. +CREATE TABLE t5(a INT PRIMARY KEY); +ALTER TABLE t5 ADD COLUMN b REAL UNSIGNED; +Warnings: +Warning 1681 UNSIGNED for decimal and floating point data types is deprecated and support for it will be removed in a future release. +DROP TABLE t5, t4, t3, t2, t1; +CREATE TABLE t1(a DECIMAL(4,2) UNSIGNED); +Warnings: +Warning 1681 UNSIGNED for decimal and floating point data types is deprecated and support for it will be removed in a future release. +ALTER TABLE t1 ADD COLUMN b INT; +CREATE TABLE t2 LIKE t1; +Warnings: +Warning 1681 UNSIGNED for decimal and floating point data types is deprecated and support for it will be removed in a future release. +CREATE TABLE t3 AS SELECT * FROM t1; +Warnings: +Warning 1681 UNSIGNED for decimal and floating point data types is deprecated and support for it will be removed in a future release. +CREATE TABLE t4(a DECIMAL(4,2)); +ALTER TABLE t4 MODIFY COLUMN a DECIMAL(4,2) UNSIGNED; +Warnings: +Warning 1681 UNSIGNED for decimal and floating point data types is deprecated and support for it will be removed in a future release. +CREATE TABLE t5(a INT PRIMARY KEY); +ALTER TABLE t5 ADD COLUMN b DECIMAL(4,2) UNSIGNED; +Warnings: +Warning 1681 UNSIGNED for decimal and floating point data types is deprecated and support for it will be removed in a future release. +DROP TABLE t5, t4, t3, t2, t1; +CREATE FUNCTION f1(a FLOAT UNSIGNED) RETURNS DOUBLE UNSIGNED RETURN 1; +Warnings: +Warning 1681 UNSIGNED for decimal and floating point data types is deprecated and support for it will be removed in a future release. +Warning 1681 UNSIGNED for decimal and floating point data types is deprecated and support for it will be removed in a future release. +DROP FUNCTION f1; +CREATE PROCEDURE p1(IN a FLOAT UNSIGNED, OUT b DOUBLE UNSIGNED) +BEGIN +SELECT 1 INTO b; +END|| +Warnings: +Warning 1681 UNSIGNED for decimal and floating point data types is deprecated and support for it will be removed in a future release. +Warning 1681 UNSIGNED for decimal and floating point data types is deprecated and support for it will be removed in a future release. +DROP PROCEDURE p1; diff --git a/mysql-test/r/type_time.result-pq b/mysql-test/r/type_time.result-pq new file mode 100644 index 000000000000..561e3fc0cfc9 --- /dev/null +++ b/mysql-test/r/type_time.result-pq @@ -0,0 +1,2820 @@ +drop table if exists t1; +SET sql_mode = 'NO_ENGINE_SUBSTITUTION'; +create table t1 (t time); +insert into t1 values("10:22:33"),("12:34:56.78"),(10),(1234),(123456.78),(1234559.99),("1"),("1:23"),("1:23:45"), ("10.22"), ("-10 1:22:33.45"),("20 10:22:33"),("1999-02-03 20:33:34"); +Warnings: +Note 1265 Data truncated for column 't' at row 13 +insert t1 values (30),(1230),("1230"),("12:30"),("12:30:35"),("1 12:30:31.32"); +select * from t1; +t +10:22:33 +12:34:57 +00:00:10 +00:12:34 +12:34:57 +123:46:00 +00:00:01 +01:23:00 +01:23:45 +00:00:10 +-241:22:33 +490:22:33 +20:33:34 +00:00:30 +00:12:30 +00:12:30 +12:30:00 +12:30:35 +36:30:31 +insert into t1 values("10.22.22"),(1234567),(123456789),(123456789.10),("10 22:22"),("12.45a"); +Warnings: +Warning 1265 Data truncated for column 't' at row 1 +Warning 1264 Out of range value for column 't' at row 2 +Warning 1264 Out of range value for column 't' at row 3 +Warning 1264 Out of range value for column 't' at row 4 +Warning 1265 Data truncated for column 't' at row 6 +select * from t1; +t +10:22:33 +12:34:57 +00:00:10 +00:12:34 +12:34:57 +123:46:00 +00:00:01 +01:23:00 +01:23:45 +00:00:10 +-241:22:33 +490:22:33 +20:33:34 +00:00:30 +00:12:30 +00:12:30 +12:30:00 +12:30:35 +36:30:31 +00:00:10 +00:00:00 +838:59:59 +838:59:59 +262:22:00 +00:00:12 +drop table t1; +create table t1 (t time); +insert into t1 values ('09:00:00'),('13:00:00'),('19:38:34'), ('13:00:00'),('09:00:00'),('09:00:00'),('13:00:00'),('13:00:00'),('13:00:00'),('09:00:00'); +select t, time_to_sec(t),sec_to_time(time_to_sec(t)) from t1; +t time_to_sec(t) sec_to_time(time_to_sec(t)) +09:00:00 32400 09:00:00 +13:00:00 46800 13:00:00 +19:38:34 70714 19:38:34 +13:00:00 46800 13:00:00 +09:00:00 32400 09:00:00 +09:00:00 32400 09:00:00 +13:00:00 46800 13:00:00 +13:00:00 46800 13:00:00 +13:00:00 46800 13:00:00 +09:00:00 32400 09:00:00 +select sec_to_time(time_to_sec(t)) from t1; +sec_to_time(time_to_sec(t)) +09:00:00 +13:00:00 +19:38:34 +13:00:00 +09:00:00 +09:00:00 +13:00:00 +13:00:00 +13:00:00 +09:00:00 +drop table t1; +CREATE TABLE t1 (t TIME); +INSERT INTO t1 VALUES (+10), (+10.0), (+10e0); +INSERT INTO t1 VALUES (-10), (-10.0), (-10e0); +SELECT * FROM t1; +t +00:00:10 +00:00:10 +00:00:10 +-00:00:10 +-00:00:10 +-00:00:10 +DROP TABLE t1; +SELECT CAST(235959.123456 AS TIME); +CAST(235959.123456 AS TIME) +23:59:59 +SELECT CAST(0.235959123456e+6 AS TIME); +CAST(0.235959123456e+6 AS TIME) +23:59:59 +SELECT CAST(235959123456e-6 AS TIME); +CAST(235959123456e-6 AS TIME) +23:59:59 +SELECT CAST(235959.1234567 AS TIME); +CAST(235959.1234567 AS TIME) +23:59:59 +SELECT CAST(0.2359591234567e6 AS TIME); +CAST(0.2359591234567e6 AS TIME) +23:59:59 +SELECT CAST(0.2359591234567e+30 AS TIME); +CAST(0.2359591234567e+30 AS TIME) +NULL +Warnings: +Warning 1292 Truncated incorrect time value: '2.359591234567e29' +End of 4.1 tests +select cast('100:55:50' as time) < cast('24:00:00' as time); +cast('100:55:50' as time) < cast('24:00:00' as time) +0 +select cast('100:55:50' as time) < cast('024:00:00' as time); +cast('100:55:50' as time) < cast('024:00:00' as time) +0 +select cast('300:55:50' as time) < cast('240:00:00' as time); +cast('300:55:50' as time) < cast('240:00:00' as time) +0 +select cast('100:55:50' as time) > cast('24:00:00' as time); +cast('100:55:50' as time) > cast('24:00:00' as time) +1 +select cast('100:55:50' as time) > cast('024:00:00' as time); +cast('100:55:50' as time) > cast('024:00:00' as time) +1 +select cast('300:55:50' as time) > cast('240:00:00' as time); +cast('300:55:50' as time) > cast('240:00:00' as time) +1 +create table t1 (f1 time); +insert into t1 values ('24:00:00'); +select cast('24:00:00' as time) = (select f1 from t1); +cast('24:00:00' as time) = (select f1 from t1) +1 +drop table t1; +create table t1(f1 time, f2 time); +insert into t1 values('20:00:00','150:00:00'); +select 1 from t1 where cast('100:00:00' as time) between f1 and f2; +1 +1 +drop table t1; +CREATE TABLE t1 ( +f2 date NOT NULL, +f3 int(11) unsigned NOT NULL default '0', +PRIMARY KEY (f3, f2) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t1 values('2007-07-01', 1); +insert into t1 values('2007-07-01', 2); +insert into t1 values('2007-07-02', 1); +insert into t1 values('2007-07-02', 2); +SELECT sum(f3) FROM t1 where f2='2007-07-01 00:00:00' group by f2; +sum(f3) +3 +drop table t1; +# +# Bug #44792: valgrind warning when casting from time to time +# +CREATE TABLE t1 (c TIME); +INSERT INTO t1 VALUES ('0:00:00'); +SELECT CAST(c AS TIME) FROM t1; +CAST(c AS TIME) +00:00:00 +DROP TABLE t1; +End of 5.0 tests +# +# Bug#53942 valgrind warnings with timestamp() function and incomplete datetime values +# +SET @@timestamp=UNIX_TIMESTAMP('2001-01-01 01:00:00'); +CREATE TABLE t1(f1 TIME); +INSERT INTO t1 VALUES ('23:38:57'); +SELECT TIMESTAMP(f1,'1') FROM t1; +TIMESTAMP(f1,'1') +2001-01-01 23:38:58 +DROP TABLE t1; +SET @@timestamp=default; +End of 5.1 tests +CREATE TABLE t1 (f1 TIME); +INSERT INTO t1 VALUES ('24:00:00'); +SELECT '24:00:00' = (SELECT f1 FROM t1); +'24:00:00' = (SELECT f1 FROM t1) +1 +SELECT CAST('24:00:00' AS TIME) = (SELECT f1 FROM t1); +CAST('24:00:00' AS TIME) = (SELECT f1 FROM t1) +1 +SELECT CAST('-24:00:00' AS TIME) = (SELECT f1 FROM t1); +CAST('-24:00:00' AS TIME) = (SELECT f1 FROM t1) +0 +TRUNCATE t1; +INSERT INTO t1 VALUES ('-24:00:00'); +SELECT CAST('24:00:00' AS TIME) = (SELECT f1 FROM t1); +CAST('24:00:00' AS TIME) = (SELECT f1 FROM t1) +0 +SELECT CAST('-24:00:00' AS TIME) = (SELECT f1 FROM t1); +CAST('-24:00:00' AS TIME) = (SELECT f1 FROM t1) +1 +SELECT '-24:00:00' = (SELECT f1 FROM t1); +'-24:00:00' = (SELECT f1 FROM t1) +1 +DROP TABLE t1; +# +# Start of 5.6 tests +# +# +# WL#946 Testing <=> operator with TIME +# +CREATE TABLE t1 (a TIME); +INSERT INTO t1 VALUES ('20:00:00'),('19:20:30'); +SELECT * FROM t1 WHERE a<=>'19:20:30'; +a +19:20:30 +SELECT * FROM t1 WHERE a<=>TIME'19:20:30'; +a +19:20:30 +SELECT * FROM t1 WHERE a<=>192030; +a +19:20:30 +DROP TABLE t1; +# +# WL#946: Testing rounding +# +CREATE TABLE t1 (a TIME); +INSERT INTO t1 VALUES ('10:10:10.9999994'), ('10:10:10.9999995'); +INSERT INTO t1 VALUES (101010.9999994), (101010.9999995); +SELECT * FROM t1; +a +10:10:11 +10:10:11 +10:10:11 +10:10:11 +DROP TABLE t1; +# +# Before WL#946 TIME did not reject too big negative minutes/seconds +# +CREATE TABLE t1 (a TIME); +INSERT INTO t1 VALUES ('-10:60:59'), ('-10:59:60'), (-106059), (-105960); +Warnings: +Warning 1264 Out of range value for column 'a' at row 1 +Warning 1264 Out of range value for column 'a' at row 2 +Warning 1264 Out of range value for column 'a' at row 3 +Warning 1264 Out of range value for column 'a' at row 4 +SELECT * FROM t1; +a +00:00:00 +00:00:00 +00:00:00 +00:00:00 +DROP TABLE t1; +# +# WL#946 Make sure case from number to TIME properly handles +# too big negative minutes/secons +# +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (-106059), (-105960); +SELECT CAST(a AS TIME) FROM t1; +CAST(a AS TIME) +NULL +NULL +Warnings: +Warning 1292 Truncated incorrect time value: '-106059' +Warning 1292 Truncated incorrect time value: '-105960' +DROP TABLE t1; +# +# WL#946 Checking function TIME() +# +SELECT TIME('1000009:10:10'); +TIME('1000009:10:10') +838:59:59 +Warnings: +Warning 1292 Truncated incorrect time value: '1000009:10:10' +SELECT TIME('1000009:10:10.1999999999999'); +TIME('1000009:10:10.1999999999999') +838:59:59.000000 +Warnings: +Warning 1292 Truncated incorrect time value: '1000009:10:10.1999999999999' +SELECT TIME('10000090:10:10'); +TIME('10000090:10:10') +838:59:59 +Warnings: +Warning 1292 Truncated incorrect time value: '10000090:10:10' +SELECT TIME('10000090:10:10.1999999999999'); +TIME('10000090:10:10.1999999999999') +838:59:59.000000 +Warnings: +Warning 1292 Truncated incorrect time value: '10000090:10:10.1999999999999' +SELECT TIME('100000900:10:10'); +TIME('100000900:10:10') +838:59:59 +Warnings: +Warning 1292 Truncated incorrect time value: '100000900:10:10' +SELECT TIME('100000900:10:10.1999999999999'); +TIME('100000900:10:10.1999999999999') +838:59:59.000000 +Warnings: +Warning 1292 Truncated incorrect time value: '100000900:10:10.1999999999999' +SELECT TIME('1000009000:10:10'); +TIME('1000009000:10:10') +838:59:59 +Warnings: +Warning 1292 Truncated incorrect time value: '1000009000:10:10' +SELECT TIME('1000009000:10:10.1999999999999'); +TIME('1000009000:10:10.1999999999999') +838:59:59.000000 +Warnings: +Warning 1292 Truncated incorrect time value: '1000009000:10:10.1999999999999' +SELECT TIME('10000090000:10:10'); +TIME('10000090000:10:10') +NULL +Warnings: +Warning 1292 Truncated incorrect time value: '10000090000:10:10' +SELECT TIME('10000090000:10:10.1999999999999'); +TIME('10000090000:10:10.1999999999999') +NULL +Warnings: +Warning 1292 Truncated incorrect time value: '10000090000:10:10.1999999999999' +# +# Checking Item_func_if::val_str with TIME arguments +# +SELECT CAST(IF(1, TIME'00:00:00',TIME'00:00:00') AS CHAR); +CAST(IF(1, TIME'00:00:00',TIME'00:00:00') AS CHAR) +00:00:00 +# +# Checking Item_func_case::val_str with TIME arguments +# +SELECT CAST(CASE WHEN 1 THEN TIME'00:00:00' ELSE TIME'00:00:00' END AS CHAR); +CAST(CASE WHEN 1 THEN TIME'00:00:00' ELSE TIME'00:00:00' END AS CHAR) +00:00:00 +# +# Testing CASE with TIME type without a found item +# +SELECT CAST(CASE WHEN 0 THEN '01:01:01' END AS TIME); +CAST(CASE WHEN 0 THEN '01:01:01' END AS TIME) +NULL +SELECT CAST(CASE WHEN 0 THEN TIME'01:01:01' END AS TIME); +CAST(CASE WHEN 0 THEN TIME'01:01:01' END AS TIME) +NULL +# +# Testing COALESCE with TIME type without a found item +# +SELECT COALESCE(TIME(NULL)); +COALESCE(TIME(NULL)) +NULL +# +# Testing TIME field with NULL value with NOT IN +# +CREATE TABLE t1 (a TIME); +INSERT INTO t1 VALUES (NULL); +SELECT * FROM t1 WHERE a NOT IN (TIME'20:20:20',TIME'10:10:10'); +a +DROP TABLE t1; +# +# Testing Item_func_numhybrid::val_int when TIME type +# +CREATE TABLE t1 (a TIME); +INSERT INTO t1 VALUES ('10:10:10'); +SELECT CAST(COALESCE(a,a) AS SIGNED) FROM t1; +CAST(COALESCE(a,a) AS SIGNED) +101010 +DROP TABLE t1; +# +# Testing Item_func_numhybrid::val_decimal when TIME type +# +CREATE TABLE t1 (a TIME); +INSERT INTO t1 VALUES ('10:10:10'); +SELECT CAST(COALESCE(a,a) AS DECIMAL(23,6)) FROM t1; +CAST(COALESCE(a,a) AS DECIMAL(23,6)) +101010.000000 +DROP TABLE t1; +# +# Testing Item_func_numhybrid::get_time when non-temporal type +# +SELECT CAST(COALESCE(10,20) AS TIME); +CAST(COALESCE(10,20) AS TIME) +00:00:10 +# +# Testing Item_func_min_max::get_time when DATE type and NULL +# +SELECT CAST(LEAST(DATE(NULL), DATE(NULL)) AS TIME); +CAST(LEAST(DATE(NULL), DATE(NULL)) AS TIME) +NULL +# +# Testing Item_func_min_max::get_time with non-temporal arguments +# +SELECT CAST(LEAST(111111,222222) AS TIME); +CAST(LEAST(111111,222222) AS TIME) +11:11:11 +# +# Item::get_time_from_numeric +# +SELECT CAST(SUM(0) AS TIME); +CAST(SUM(0) AS TIME) +00:00:00 +SELECT CAST(SUM(0 + 0e0) AS TIME); +CAST(SUM(0 + 0e0) AS TIME) +00:00:00 +SET timestamp=1322115328; +SELECT CAST(UNIX_TIMESTAMP() AS TIME); +CAST(UNIX_TIMESTAMP() AS TIME) +NULL +Warnings: +Warning 1292 Truncated incorrect time value: '1322115328' +SET timestamp=default; +# +# Item::get_time_from_non_temporal +# +SELECT TIME(154559.616 + 0e0); +TIME(154559.616 + 0e0) +15:45:59.616000 +# +# Item_name_const::get_time +# +SELECT TIME(NAME_CONST('a', 0)); +TIME(NAME_CONST('a', 0)) +00:00:00 +# +# Item_cache_datetime::get_time +# +CREATE TABLE t1 (a DATE); +INSERT INTO t1 VALUES (0); +SELECT TIME(MIN(a)) FROM t1; +TIME(MIN(a)) +00:00:00 +DROP TABLE t1; +# +# Bug#13623473 "MISSING ROWS ON SELECT AND JOIN WITH +# TIME/DATETIME COMPARE" +# +# Systematic testing of ref access and range scan +SET TIMESTAMP=UNIX_TIMESTAMP('2012-01-31 10:14:35'); +CREATE TABLE t1 (col_time_key TIME, KEY(col_time_key)) ENGINE=InnoDB; +INSERT INTO t1 VALUES ('00:00:00'),('-24:00:00'),('-48:00:00'),('24:00:00'),('48:00:00'); +CREATE TABLE t2 (col_datetime_key DATETIME, KEY(col_datetime_key)) ENGINE=InnoDB; +INSERT INTO t2 SELECT * FROM t1; +ANALYZE TABLE t1; +ANALYZE TABLE t2; +EXPLAIN SELECT * FROM +t1 ignore INDEX (col_time_key) +STRAIGHT_JOIN +t2 ignore INDEX (col_datetime_key) +WHERE col_time_key = col_datetime_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 5 20.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col_time_key` AS `col_time_key`,`test`.`t2`.`col_datetime_key` AS `col_datetime_key` from `test`.`t1` IGNORE INDEX (`col_time_key`) straight_join `test`.`t2` IGNORE INDEX (`col_datetime_key`) where (cast(`test`.`t1`.`col_time_key` as datetime) = `test`.`t2`.`col_datetime_key`) +SELECT * FROM +t1 ignore INDEX (col_time_key) +STRAIGHT_JOIN +t2 ignore INDEX (col_datetime_key) +WHERE col_time_key = col_datetime_key; +col_time_key col_datetime_key +-24:00:00 2012-01-30 00:00:00 +-48:00:00 2012-01-29 00:00:00 +00:00:00 2012-01-31 00:00:00 +24:00:00 2012-02-01 00:00:00 +48:00:00 2012-02-02 00:00:00 +EXPLAIN SELECT * FROM +t1 ignore INDEX (col_time_key) +STRAIGHT_JOIN +t2 ignore INDEX (col_datetime_key) +WHERE col_datetime_key = col_time_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 5 20.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col_time_key` AS `col_time_key`,`test`.`t2`.`col_datetime_key` AS `col_datetime_key` from `test`.`t1` IGNORE INDEX (`col_time_key`) straight_join `test`.`t2` IGNORE INDEX (`col_datetime_key`) where (`test`.`t2`.`col_datetime_key` = cast(`test`.`t1`.`col_time_key` as datetime)) +SELECT * FROM +t1 ignore INDEX (col_time_key) +STRAIGHT_JOIN +t2 ignore INDEX (col_datetime_key) +WHERE col_datetime_key = col_time_key; +col_time_key col_datetime_key +-24:00:00 2012-01-30 00:00:00 +-48:00:00 2012-01-29 00:00:00 +00:00:00 2012-01-31 00:00:00 +24:00:00 2012-02-01 00:00:00 +48:00:00 2012-02-02 00:00:00 +EXPLAIN SELECT * FROM +t1 ignore INDEX (col_time_key) +STRAIGHT_JOIN +t2 force INDEX (col_datetime_key) +WHERE col_time_key = col_datetime_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 100.00 Using where +2 SIMPLE t2 NULL ref col_datetime_key col_datetime_key 6 test.t1.col_time_key 1 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col_time_key` AS `col_time_key`,`test`.`t2`.`col_datetime_key` AS `col_datetime_key` from `test`.`t1` IGNORE INDEX (`col_time_key`) straight_join `test`.`t2` FORCE INDEX (`col_datetime_key`) where (cast(`test`.`t1`.`col_time_key` as datetime) = `test`.`t2`.`col_datetime_key`) +SELECT * FROM +t1 ignore INDEX (col_time_key) +STRAIGHT_JOIN +t2 force INDEX (col_datetime_key) +WHERE col_time_key = col_datetime_key; +col_time_key col_datetime_key +-24:00:00 2012-01-30 00:00:00 +-48:00:00 2012-01-29 00:00:00 +00:00:00 2012-01-31 00:00:00 +24:00:00 2012-02-01 00:00:00 +48:00:00 2012-02-02 00:00:00 +EXPLAIN SELECT * FROM +t1 ignore INDEX (col_time_key) +STRAIGHT_JOIN +t2 force INDEX (col_datetime_key) +WHERE col_datetime_key = col_time_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 100.00 Using where +2 SIMPLE t2 NULL ref col_datetime_key col_datetime_key 6 test.t1.col_time_key 1 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col_time_key` AS `col_time_key`,`test`.`t2`.`col_datetime_key` AS `col_datetime_key` from `test`.`t1` IGNORE INDEX (`col_time_key`) straight_join `test`.`t2` FORCE INDEX (`col_datetime_key`) where (`test`.`t2`.`col_datetime_key` = cast(`test`.`t1`.`col_time_key` as datetime)) +SELECT * FROM +t1 ignore INDEX (col_time_key) +STRAIGHT_JOIN +t2 force INDEX (col_datetime_key) +WHERE col_datetime_key = col_time_key; +col_time_key col_datetime_key +-24:00:00 2012-01-30 00:00:00 +-48:00:00 2012-01-29 00:00:00 +00:00:00 2012-01-31 00:00:00 +24:00:00 2012-02-01 00:00:00 +48:00:00 2012-02-02 00:00:00 +EXPLAIN SELECT * FROM +t1 force INDEX (col_time_key) +STRAIGHT_JOIN +t2 ignore INDEX (col_datetime_key) +WHERE col_time_key = col_datetime_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index col_time_key col_time_key 4 NULL 5 100.00 Using index +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 5 20.00 Using where; Using join buffer (hash join) +Warnings: +Warning 1739 Cannot use ref access on index 'col_time_key' due to type or collation conversion on field 'col_time_key' +Note 1003 /* select#1 */ select `test`.`t1`.`col_time_key` AS `col_time_key`,`test`.`t2`.`col_datetime_key` AS `col_datetime_key` from `test`.`t1` FORCE INDEX (`col_time_key`) straight_join `test`.`t2` IGNORE INDEX (`col_datetime_key`) where (cast(`test`.`t1`.`col_time_key` as datetime) = `test`.`t2`.`col_datetime_key`) +SELECT * FROM +t1 force INDEX (col_time_key) +STRAIGHT_JOIN +t2 ignore INDEX (col_datetime_key) +WHERE col_time_key = col_datetime_key; +col_time_key col_datetime_key +-24:00:00 2012-01-30 00:00:00 +-48:00:00 2012-01-29 00:00:00 +00:00:00 2012-01-31 00:00:00 +24:00:00 2012-02-01 00:00:00 +48:00:00 2012-02-02 00:00:00 +EXPLAIN SELECT * FROM +t1 force INDEX (col_time_key) +STRAIGHT_JOIN +t2 ignore INDEX (col_datetime_key) +WHERE col_datetime_key = col_time_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index col_time_key col_time_key 4 NULL 5 100.00 Using index +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 5 20.00 Using where; Using join buffer (hash join) +Warnings: +Warning 1739 Cannot use ref access on index 'col_time_key' due to type or collation conversion on field 'col_time_key' +Note 1003 /* select#1 */ select `test`.`t1`.`col_time_key` AS `col_time_key`,`test`.`t2`.`col_datetime_key` AS `col_datetime_key` from `test`.`t1` FORCE INDEX (`col_time_key`) straight_join `test`.`t2` IGNORE INDEX (`col_datetime_key`) where (`test`.`t2`.`col_datetime_key` = cast(`test`.`t1`.`col_time_key` as datetime)) +SELECT * FROM +t1 force INDEX (col_time_key) +STRAIGHT_JOIN +t2 ignore INDEX (col_datetime_key) +WHERE col_datetime_key = col_time_key; +col_time_key col_datetime_key +-24:00:00 2012-01-30 00:00:00 +-48:00:00 2012-01-29 00:00:00 +00:00:00 2012-01-31 00:00:00 +24:00:00 2012-02-01 00:00:00 +48:00:00 2012-02-02 00:00:00 +EXPLAIN SELECT * FROM +t1 force INDEX (col_time_key) +STRAIGHT_JOIN +t2 force INDEX (col_datetime_key) +WHERE col_time_key = col_datetime_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index col_time_key col_time_key 4 NULL 5 100.00 Using where; Using index +2 SIMPLE t2 NULL ref col_datetime_key col_datetime_key 6 test.t1.col_time_key 1 100.00 Using where; Using index +Warnings: +Warning 1739 Cannot use ref access on index 'col_time_key' due to type or collation conversion on field 'col_time_key' +Note 1003 /* select#1 */ select `test`.`t1`.`col_time_key` AS `col_time_key`,`test`.`t2`.`col_datetime_key` AS `col_datetime_key` from `test`.`t1` FORCE INDEX (`col_time_key`) straight_join `test`.`t2` FORCE INDEX (`col_datetime_key`) where (cast(`test`.`t1`.`col_time_key` as datetime) = `test`.`t2`.`col_datetime_key`) +SELECT * FROM +t1 force INDEX (col_time_key) +STRAIGHT_JOIN +t2 force INDEX (col_datetime_key) +WHERE col_time_key = col_datetime_key; +col_time_key col_datetime_key +-24:00:00 2012-01-30 00:00:00 +-48:00:00 2012-01-29 00:00:00 +00:00:00 2012-01-31 00:00:00 +24:00:00 2012-02-01 00:00:00 +48:00:00 2012-02-02 00:00:00 +EXPLAIN SELECT * FROM +t1 force INDEX (col_time_key) +STRAIGHT_JOIN +t2 force INDEX (col_datetime_key) +WHERE col_datetime_key = col_time_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index col_time_key col_time_key 4 NULL 5 100.00 Using where; Using index +2 SIMPLE t2 NULL ref col_datetime_key col_datetime_key 6 test.t1.col_time_key 1 100.00 Using where; Using index +Warnings: +Warning 1739 Cannot use ref access on index 'col_time_key' due to type or collation conversion on field 'col_time_key' +Note 1003 /* select#1 */ select `test`.`t1`.`col_time_key` AS `col_time_key`,`test`.`t2`.`col_datetime_key` AS `col_datetime_key` from `test`.`t1` FORCE INDEX (`col_time_key`) straight_join `test`.`t2` FORCE INDEX (`col_datetime_key`) where (`test`.`t2`.`col_datetime_key` = cast(`test`.`t1`.`col_time_key` as datetime)) +SELECT * FROM +t1 force INDEX (col_time_key) +STRAIGHT_JOIN +t2 force INDEX (col_datetime_key) +WHERE col_datetime_key = col_time_key; +col_time_key col_datetime_key +-24:00:00 2012-01-30 00:00:00 +-48:00:00 2012-01-29 00:00:00 +00:00:00 2012-01-31 00:00:00 +24:00:00 2012-02-01 00:00:00 +48:00:00 2012-02-02 00:00:00 +EXPLAIN SELECT * FROM +t2 ignore INDEX (col_datetime_key) +STRAIGHT_JOIN +t1 ignore INDEX (col_time_key) +WHERE col_time_key = col_datetime_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 20.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`col_datetime_key` AS `col_datetime_key`,`test`.`t1`.`col_time_key` AS `col_time_key` from `test`.`t2` IGNORE INDEX (`col_datetime_key`) straight_join `test`.`t1` IGNORE INDEX (`col_time_key`) where (cast(`test`.`t1`.`col_time_key` as datetime) = `test`.`t2`.`col_datetime_key`) +SELECT * FROM +t2 ignore INDEX (col_datetime_key) +STRAIGHT_JOIN +t1 ignore INDEX (col_time_key) +WHERE col_time_key = col_datetime_key; +col_datetime_key col_time_key +2012-01-29 00:00:00 -48:00:00 +2012-01-30 00:00:00 -24:00:00 +2012-01-31 00:00:00 00:00:00 +2012-02-01 00:00:00 24:00:00 +2012-02-02 00:00:00 48:00:00 +EXPLAIN SELECT * FROM +t2 ignore INDEX (col_datetime_key) +STRAIGHT_JOIN +t1 ignore INDEX (col_time_key) +WHERE col_datetime_key = col_time_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 20.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`col_datetime_key` AS `col_datetime_key`,`test`.`t1`.`col_time_key` AS `col_time_key` from `test`.`t2` IGNORE INDEX (`col_datetime_key`) straight_join `test`.`t1` IGNORE INDEX (`col_time_key`) where (`test`.`t2`.`col_datetime_key` = cast(`test`.`t1`.`col_time_key` as datetime)) +SELECT * FROM +t2 ignore INDEX (col_datetime_key) +STRAIGHT_JOIN +t1 ignore INDEX (col_time_key) +WHERE col_datetime_key = col_time_key; +col_datetime_key col_time_key +2012-01-29 00:00:00 -48:00:00 +2012-01-30 00:00:00 -24:00:00 +2012-01-31 00:00:00 00:00:00 +2012-02-01 00:00:00 24:00:00 +2012-02-02 00:00:00 48:00:00 +EXPLAIN SELECT * FROM +t2 ignore INDEX (col_datetime_key) +STRAIGHT_JOIN +t1 force INDEX (col_time_key) +WHERE col_time_key = col_datetime_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +2 SIMPLE t1 NULL index col_time_key col_time_key 4 NULL 5 20.00 Using where; Using index; Using join buffer (hash join) +Warnings: +Warning 1739 Cannot use ref access on index 'col_time_key' due to type or collation conversion on field 'col_time_key' +Warning 1739 Cannot use range access on index 'col_time_key' due to type or collation conversion on field 'col_time_key' +Note 1003 /* select#1 */ select `test`.`t2`.`col_datetime_key` AS `col_datetime_key`,`test`.`t1`.`col_time_key` AS `col_time_key` from `test`.`t2` IGNORE INDEX (`col_datetime_key`) straight_join `test`.`t1` FORCE INDEX (`col_time_key`) where (cast(`test`.`t1`.`col_time_key` as datetime) = `test`.`t2`.`col_datetime_key`) +SELECT * FROM +t2 ignore INDEX (col_datetime_key) +STRAIGHT_JOIN +t1 force INDEX (col_time_key) +WHERE col_time_key = col_datetime_key; +col_datetime_key col_time_key +2012-01-29 00:00:00 -48:00:00 +2012-01-30 00:00:00 -24:00:00 +2012-01-31 00:00:00 00:00:00 +2012-02-01 00:00:00 24:00:00 +2012-02-02 00:00:00 48:00:00 +EXPLAIN SELECT * FROM +t2 ignore INDEX (col_datetime_key) +STRAIGHT_JOIN +t1 force INDEX (col_time_key) +WHERE col_datetime_key = col_time_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +2 SIMPLE t1 NULL index col_time_key col_time_key 4 NULL 5 20.00 Using where; Using index; Using join buffer (hash join) +Warnings: +Warning 1739 Cannot use ref access on index 'col_time_key' due to type or collation conversion on field 'col_time_key' +Warning 1739 Cannot use range access on index 'col_time_key' due to type or collation conversion on field 'col_time_key' +Note 1003 /* select#1 */ select `test`.`t2`.`col_datetime_key` AS `col_datetime_key`,`test`.`t1`.`col_time_key` AS `col_time_key` from `test`.`t2` IGNORE INDEX (`col_datetime_key`) straight_join `test`.`t1` FORCE INDEX (`col_time_key`) where (`test`.`t2`.`col_datetime_key` = cast(`test`.`t1`.`col_time_key` as datetime)) +SELECT * FROM +t2 ignore INDEX (col_datetime_key) +STRAIGHT_JOIN +t1 force INDEX (col_time_key) +WHERE col_datetime_key = col_time_key; +col_datetime_key col_time_key +2012-01-29 00:00:00 -48:00:00 +2012-01-30 00:00:00 -24:00:00 +2012-01-31 00:00:00 00:00:00 +2012-02-01 00:00:00 24:00:00 +2012-02-02 00:00:00 48:00:00 +EXPLAIN SELECT * FROM +t2 force INDEX (col_datetime_key) +STRAIGHT_JOIN +t1 ignore INDEX (col_time_key) +WHERE col_time_key = col_datetime_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL index col_datetime_key col_datetime_key 6 NULL 5 100.00 Using index +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 20.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`col_datetime_key` AS `col_datetime_key`,`test`.`t1`.`col_time_key` AS `col_time_key` from `test`.`t2` FORCE INDEX (`col_datetime_key`) straight_join `test`.`t1` IGNORE INDEX (`col_time_key`) where (cast(`test`.`t1`.`col_time_key` as datetime) = `test`.`t2`.`col_datetime_key`) +SELECT * FROM +t2 force INDEX (col_datetime_key) +STRAIGHT_JOIN +t1 ignore INDEX (col_time_key) +WHERE col_time_key = col_datetime_key; +col_datetime_key col_time_key +2012-01-29 00:00:00 -48:00:00 +2012-01-30 00:00:00 -24:00:00 +2012-01-31 00:00:00 00:00:00 +2012-02-01 00:00:00 24:00:00 +2012-02-02 00:00:00 48:00:00 +EXPLAIN SELECT * FROM +t2 force INDEX (col_datetime_key) +STRAIGHT_JOIN +t1 ignore INDEX (col_time_key) +WHERE col_datetime_key = col_time_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL index col_datetime_key col_datetime_key 6 NULL 5 100.00 Using index +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 20.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`col_datetime_key` AS `col_datetime_key`,`test`.`t1`.`col_time_key` AS `col_time_key` from `test`.`t2` FORCE INDEX (`col_datetime_key`) straight_join `test`.`t1` IGNORE INDEX (`col_time_key`) where (`test`.`t2`.`col_datetime_key` = cast(`test`.`t1`.`col_time_key` as datetime)) +SELECT * FROM +t2 force INDEX (col_datetime_key) +STRAIGHT_JOIN +t1 ignore INDEX (col_time_key) +WHERE col_datetime_key = col_time_key; +col_datetime_key col_time_key +2012-01-29 00:00:00 -48:00:00 +2012-01-30 00:00:00 -24:00:00 +2012-01-31 00:00:00 00:00:00 +2012-02-01 00:00:00 24:00:00 +2012-02-02 00:00:00 48:00:00 +EXPLAIN SELECT * FROM +t2 force INDEX (col_datetime_key) +STRAIGHT_JOIN +t1 force INDEX (col_time_key) +WHERE col_time_key = col_datetime_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL index col_datetime_key col_datetime_key 6 NULL 5 100.00 Using index +2 SIMPLE t1 NULL index col_time_key col_time_key 4 NULL 5 20.00 Using where; Using index; Using join buffer (hash join) +Warnings: +Warning 1739 Cannot use ref access on index 'col_time_key' due to type or collation conversion on field 'col_time_key' +Warning 1739 Cannot use range access on index 'col_time_key' due to type or collation conversion on field 'col_time_key' +Note 1003 /* select#1 */ select `test`.`t2`.`col_datetime_key` AS `col_datetime_key`,`test`.`t1`.`col_time_key` AS `col_time_key` from `test`.`t2` FORCE INDEX (`col_datetime_key`) straight_join `test`.`t1` FORCE INDEX (`col_time_key`) where (cast(`test`.`t1`.`col_time_key` as datetime) = `test`.`t2`.`col_datetime_key`) +SELECT * FROM +t2 force INDEX (col_datetime_key) +STRAIGHT_JOIN +t1 force INDEX (col_time_key) +WHERE col_time_key = col_datetime_key; +col_datetime_key col_time_key +2012-01-29 00:00:00 -48:00:00 +2012-01-30 00:00:00 -24:00:00 +2012-01-31 00:00:00 00:00:00 +2012-02-01 00:00:00 24:00:00 +2012-02-02 00:00:00 48:00:00 +EXPLAIN SELECT * FROM +t2 force INDEX (col_datetime_key) +STRAIGHT_JOIN +t1 force INDEX (col_time_key) +WHERE col_datetime_key = col_time_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL index col_datetime_key col_datetime_key 6 NULL 5 100.00 Using index +2 SIMPLE t1 NULL index col_time_key col_time_key 4 NULL 5 20.00 Using where; Using index; Using join buffer (hash join) +Warnings: +Warning 1739 Cannot use ref access on index 'col_time_key' due to type or collation conversion on field 'col_time_key' +Warning 1739 Cannot use range access on index 'col_time_key' due to type or collation conversion on field 'col_time_key' +Note 1003 /* select#1 */ select `test`.`t2`.`col_datetime_key` AS `col_datetime_key`,`test`.`t1`.`col_time_key` AS `col_time_key` from `test`.`t2` FORCE INDEX (`col_datetime_key`) straight_join `test`.`t1` FORCE INDEX (`col_time_key`) where (`test`.`t2`.`col_datetime_key` = cast(`test`.`t1`.`col_time_key` as datetime)) +SELECT * FROM +t2 force INDEX (col_datetime_key) +STRAIGHT_JOIN +t1 force INDEX (col_time_key) +WHERE col_datetime_key = col_time_key; +col_datetime_key col_time_key +2012-01-29 00:00:00 -48:00:00 +2012-01-30 00:00:00 -24:00:00 +2012-01-31 00:00:00 00:00:00 +2012-02-01 00:00:00 24:00:00 +2012-02-02 00:00:00 48:00:00 +EXPLAIN SELECT * FROM +t1 ignore INDEX (col_time_key) +STRAIGHT_JOIN +t2 ignore INDEX (col_datetime_key) +WHERE col_time_key >= col_datetime_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 5 33.33 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col_time_key` AS `col_time_key`,`test`.`t2`.`col_datetime_key` AS `col_datetime_key` from `test`.`t1` IGNORE INDEX (`col_time_key`) straight_join `test`.`t2` IGNORE INDEX (`col_datetime_key`) where (cast(`test`.`t1`.`col_time_key` as datetime) >= `test`.`t2`.`col_datetime_key`) +SELECT * FROM +t1 ignore INDEX (col_time_key) +STRAIGHT_JOIN +t2 ignore INDEX (col_datetime_key) +WHERE col_time_key >= col_datetime_key; +col_time_key col_datetime_key +-24:00:00 2012-01-29 00:00:00 +-24:00:00 2012-01-30 00:00:00 +-48:00:00 2012-01-29 00:00:00 +00:00:00 2012-01-29 00:00:00 +00:00:00 2012-01-30 00:00:00 +00:00:00 2012-01-31 00:00:00 +24:00:00 2012-01-29 00:00:00 +24:00:00 2012-01-30 00:00:00 +24:00:00 2012-01-31 00:00:00 +24:00:00 2012-02-01 00:00:00 +48:00:00 2012-01-29 00:00:00 +48:00:00 2012-01-30 00:00:00 +48:00:00 2012-01-31 00:00:00 +48:00:00 2012-02-01 00:00:00 +48:00:00 2012-02-02 00:00:00 +EXPLAIN SELECT * FROM +t1 ignore INDEX (col_time_key) +STRAIGHT_JOIN +t2 ignore INDEX (col_datetime_key) +WHERE col_datetime_key >= col_time_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 5 33.33 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col_time_key` AS `col_time_key`,`test`.`t2`.`col_datetime_key` AS `col_datetime_key` from `test`.`t1` IGNORE INDEX (`col_time_key`) straight_join `test`.`t2` IGNORE INDEX (`col_datetime_key`) where (`test`.`t2`.`col_datetime_key` >= cast(`test`.`t1`.`col_time_key` as datetime)) +SELECT * FROM +t1 ignore INDEX (col_time_key) +STRAIGHT_JOIN +t2 ignore INDEX (col_datetime_key) +WHERE col_datetime_key >= col_time_key; +col_time_key col_datetime_key +-24:00:00 2012-01-30 00:00:00 +-24:00:00 2012-01-31 00:00:00 +-24:00:00 2012-02-01 00:00:00 +-24:00:00 2012-02-02 00:00:00 +-48:00:00 2012-01-29 00:00:00 +-48:00:00 2012-01-30 00:00:00 +-48:00:00 2012-01-31 00:00:00 +-48:00:00 2012-02-01 00:00:00 +-48:00:00 2012-02-02 00:00:00 +00:00:00 2012-01-31 00:00:00 +00:00:00 2012-02-01 00:00:00 +00:00:00 2012-02-02 00:00:00 +24:00:00 2012-02-01 00:00:00 +24:00:00 2012-02-02 00:00:00 +48:00:00 2012-02-02 00:00:00 +EXPLAIN SELECT * FROM +t1 ignore INDEX (col_time_key) +STRAIGHT_JOIN +t2 force INDEX (col_datetime_key) +WHERE col_time_key >= col_datetime_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +2 SIMPLE t2 NULL ALL col_datetime_key NULL NULL NULL 5 33.33 Range checked for each record (index map: 0x1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col_time_key` AS `col_time_key`,`test`.`t2`.`col_datetime_key` AS `col_datetime_key` from `test`.`t1` IGNORE INDEX (`col_time_key`) straight_join `test`.`t2` FORCE INDEX (`col_datetime_key`) where (cast(`test`.`t1`.`col_time_key` as datetime) >= `test`.`t2`.`col_datetime_key`) +SELECT * FROM +t1 ignore INDEX (col_time_key) +STRAIGHT_JOIN +t2 force INDEX (col_datetime_key) +WHERE col_time_key >= col_datetime_key; +col_time_key col_datetime_key +-24:00:00 2012-01-29 00:00:00 +-24:00:00 2012-01-30 00:00:00 +-48:00:00 2012-01-29 00:00:00 +00:00:00 2012-01-29 00:00:00 +00:00:00 2012-01-30 00:00:00 +00:00:00 2012-01-31 00:00:00 +24:00:00 2012-01-29 00:00:00 +24:00:00 2012-01-30 00:00:00 +24:00:00 2012-01-31 00:00:00 +24:00:00 2012-02-01 00:00:00 +48:00:00 2012-01-29 00:00:00 +48:00:00 2012-01-30 00:00:00 +48:00:00 2012-01-31 00:00:00 +48:00:00 2012-02-01 00:00:00 +48:00:00 2012-02-02 00:00:00 +EXPLAIN SELECT * FROM +t1 ignore INDEX (col_time_key) +STRAIGHT_JOIN +t2 force INDEX (col_datetime_key) +WHERE col_datetime_key >= col_time_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +2 SIMPLE t2 NULL ALL col_datetime_key NULL NULL NULL 5 33.33 Range checked for each record (index map: 0x1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col_time_key` AS `col_time_key`,`test`.`t2`.`col_datetime_key` AS `col_datetime_key` from `test`.`t1` IGNORE INDEX (`col_time_key`) straight_join `test`.`t2` FORCE INDEX (`col_datetime_key`) where (`test`.`t2`.`col_datetime_key` >= cast(`test`.`t1`.`col_time_key` as datetime)) +SELECT * FROM +t1 ignore INDEX (col_time_key) +STRAIGHT_JOIN +t2 force INDEX (col_datetime_key) +WHERE col_datetime_key >= col_time_key; +col_time_key col_datetime_key +-24:00:00 2012-01-30 00:00:00 +-24:00:00 2012-01-31 00:00:00 +-24:00:00 2012-02-01 00:00:00 +-24:00:00 2012-02-02 00:00:00 +-48:00:00 2012-01-29 00:00:00 +-48:00:00 2012-01-30 00:00:00 +-48:00:00 2012-01-31 00:00:00 +-48:00:00 2012-02-01 00:00:00 +-48:00:00 2012-02-02 00:00:00 +00:00:00 2012-01-31 00:00:00 +00:00:00 2012-02-01 00:00:00 +00:00:00 2012-02-02 00:00:00 +24:00:00 2012-02-01 00:00:00 +24:00:00 2012-02-02 00:00:00 +48:00:00 2012-02-02 00:00:00 +EXPLAIN SELECT * FROM +t1 force INDEX (col_time_key) +STRAIGHT_JOIN +t2 ignore INDEX (col_datetime_key) +WHERE col_time_key >= col_datetime_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index col_time_key col_time_key 4 NULL 5 100.00 Using index +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 5 33.33 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col_time_key` AS `col_time_key`,`test`.`t2`.`col_datetime_key` AS `col_datetime_key` from `test`.`t1` FORCE INDEX (`col_time_key`) straight_join `test`.`t2` IGNORE INDEX (`col_datetime_key`) where (cast(`test`.`t1`.`col_time_key` as datetime) >= `test`.`t2`.`col_datetime_key`) +SELECT * FROM +t1 force INDEX (col_time_key) +STRAIGHT_JOIN +t2 ignore INDEX (col_datetime_key) +WHERE col_time_key >= col_datetime_key; +col_time_key col_datetime_key +-24:00:00 2012-01-29 00:00:00 +-24:00:00 2012-01-30 00:00:00 +-48:00:00 2012-01-29 00:00:00 +00:00:00 2012-01-29 00:00:00 +00:00:00 2012-01-30 00:00:00 +00:00:00 2012-01-31 00:00:00 +24:00:00 2012-01-29 00:00:00 +24:00:00 2012-01-30 00:00:00 +24:00:00 2012-01-31 00:00:00 +24:00:00 2012-02-01 00:00:00 +48:00:00 2012-01-29 00:00:00 +48:00:00 2012-01-30 00:00:00 +48:00:00 2012-01-31 00:00:00 +48:00:00 2012-02-01 00:00:00 +48:00:00 2012-02-02 00:00:00 +EXPLAIN SELECT * FROM +t1 force INDEX (col_time_key) +STRAIGHT_JOIN +t2 ignore INDEX (col_datetime_key) +WHERE col_datetime_key >= col_time_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index col_time_key col_time_key 4 NULL 5 100.00 Using index +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 5 33.33 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col_time_key` AS `col_time_key`,`test`.`t2`.`col_datetime_key` AS `col_datetime_key` from `test`.`t1` FORCE INDEX (`col_time_key`) straight_join `test`.`t2` IGNORE INDEX (`col_datetime_key`) where (`test`.`t2`.`col_datetime_key` >= cast(`test`.`t1`.`col_time_key` as datetime)) +SELECT * FROM +t1 force INDEX (col_time_key) +STRAIGHT_JOIN +t2 ignore INDEX (col_datetime_key) +WHERE col_datetime_key >= col_time_key; +col_time_key col_datetime_key +-24:00:00 2012-01-30 00:00:00 +-24:00:00 2012-01-31 00:00:00 +-24:00:00 2012-02-01 00:00:00 +-24:00:00 2012-02-02 00:00:00 +-48:00:00 2012-01-29 00:00:00 +-48:00:00 2012-01-30 00:00:00 +-48:00:00 2012-01-31 00:00:00 +-48:00:00 2012-02-01 00:00:00 +-48:00:00 2012-02-02 00:00:00 +00:00:00 2012-01-31 00:00:00 +00:00:00 2012-02-01 00:00:00 +00:00:00 2012-02-02 00:00:00 +24:00:00 2012-02-01 00:00:00 +24:00:00 2012-02-02 00:00:00 +48:00:00 2012-02-02 00:00:00 +EXPLAIN SELECT * FROM +t1 force INDEX (col_time_key) +STRAIGHT_JOIN +t2 force INDEX (col_datetime_key) +WHERE col_time_key >= col_datetime_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index col_time_key col_time_key 4 NULL 5 100.00 Using index +2 SIMPLE t2 NULL ALL col_datetime_key NULL NULL NULL 5 33.33 Range checked for each record (index map: 0x1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col_time_key` AS `col_time_key`,`test`.`t2`.`col_datetime_key` AS `col_datetime_key` from `test`.`t1` FORCE INDEX (`col_time_key`) straight_join `test`.`t2` FORCE INDEX (`col_datetime_key`) where (cast(`test`.`t1`.`col_time_key` as datetime) >= `test`.`t2`.`col_datetime_key`) +SELECT * FROM +t1 force INDEX (col_time_key) +STRAIGHT_JOIN +t2 force INDEX (col_datetime_key) +WHERE col_time_key >= col_datetime_key; +col_time_key col_datetime_key +-24:00:00 2012-01-29 00:00:00 +-24:00:00 2012-01-30 00:00:00 +-48:00:00 2012-01-29 00:00:00 +00:00:00 2012-01-29 00:00:00 +00:00:00 2012-01-30 00:00:00 +00:00:00 2012-01-31 00:00:00 +24:00:00 2012-01-29 00:00:00 +24:00:00 2012-01-30 00:00:00 +24:00:00 2012-01-31 00:00:00 +24:00:00 2012-02-01 00:00:00 +48:00:00 2012-01-29 00:00:00 +48:00:00 2012-01-30 00:00:00 +48:00:00 2012-01-31 00:00:00 +48:00:00 2012-02-01 00:00:00 +48:00:00 2012-02-02 00:00:00 +EXPLAIN SELECT * FROM +t1 force INDEX (col_time_key) +STRAIGHT_JOIN +t2 force INDEX (col_datetime_key) +WHERE col_datetime_key >= col_time_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index col_time_key col_time_key 4 NULL 5 100.00 Using index +2 SIMPLE t2 NULL ALL col_datetime_key NULL NULL NULL 5 33.33 Range checked for each record (index map: 0x1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col_time_key` AS `col_time_key`,`test`.`t2`.`col_datetime_key` AS `col_datetime_key` from `test`.`t1` FORCE INDEX (`col_time_key`) straight_join `test`.`t2` FORCE INDEX (`col_datetime_key`) where (`test`.`t2`.`col_datetime_key` >= cast(`test`.`t1`.`col_time_key` as datetime)) +SELECT * FROM +t1 force INDEX (col_time_key) +STRAIGHT_JOIN +t2 force INDEX (col_datetime_key) +WHERE col_datetime_key >= col_time_key; +col_time_key col_datetime_key +-24:00:00 2012-01-30 00:00:00 +-24:00:00 2012-01-31 00:00:00 +-24:00:00 2012-02-01 00:00:00 +-24:00:00 2012-02-02 00:00:00 +-48:00:00 2012-01-29 00:00:00 +-48:00:00 2012-01-30 00:00:00 +-48:00:00 2012-01-31 00:00:00 +-48:00:00 2012-02-01 00:00:00 +-48:00:00 2012-02-02 00:00:00 +00:00:00 2012-01-31 00:00:00 +00:00:00 2012-02-01 00:00:00 +00:00:00 2012-02-02 00:00:00 +24:00:00 2012-02-01 00:00:00 +24:00:00 2012-02-02 00:00:00 +48:00:00 2012-02-02 00:00:00 +EXPLAIN SELECT * FROM +t2 ignore INDEX (col_datetime_key) +STRAIGHT_JOIN +t1 ignore INDEX (col_time_key) +WHERE col_time_key >= col_datetime_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 33.33 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`col_datetime_key` AS `col_datetime_key`,`test`.`t1`.`col_time_key` AS `col_time_key` from `test`.`t2` IGNORE INDEX (`col_datetime_key`) straight_join `test`.`t1` IGNORE INDEX (`col_time_key`) where (cast(`test`.`t1`.`col_time_key` as datetime) >= `test`.`t2`.`col_datetime_key`) +SELECT * FROM +t2 ignore INDEX (col_datetime_key) +STRAIGHT_JOIN +t1 ignore INDEX (col_time_key) +WHERE col_time_key >= col_datetime_key; +col_datetime_key col_time_key +2012-01-29 00:00:00 -24:00:00 +2012-01-29 00:00:00 -48:00:00 +2012-01-29 00:00:00 00:00:00 +2012-01-29 00:00:00 24:00:00 +2012-01-29 00:00:00 48:00:00 +2012-01-30 00:00:00 -24:00:00 +2012-01-30 00:00:00 00:00:00 +2012-01-30 00:00:00 24:00:00 +2012-01-30 00:00:00 48:00:00 +2012-01-31 00:00:00 00:00:00 +2012-01-31 00:00:00 24:00:00 +2012-01-31 00:00:00 48:00:00 +2012-02-01 00:00:00 24:00:00 +2012-02-01 00:00:00 48:00:00 +2012-02-02 00:00:00 48:00:00 +EXPLAIN SELECT * FROM +t2 ignore INDEX (col_datetime_key) +STRAIGHT_JOIN +t1 ignore INDEX (col_time_key) +WHERE col_datetime_key >= col_time_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 33.33 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`col_datetime_key` AS `col_datetime_key`,`test`.`t1`.`col_time_key` AS `col_time_key` from `test`.`t2` IGNORE INDEX (`col_datetime_key`) straight_join `test`.`t1` IGNORE INDEX (`col_time_key`) where (`test`.`t2`.`col_datetime_key` >= cast(`test`.`t1`.`col_time_key` as datetime)) +SELECT * FROM +t2 ignore INDEX (col_datetime_key) +STRAIGHT_JOIN +t1 ignore INDEX (col_time_key) +WHERE col_datetime_key >= col_time_key; +col_datetime_key col_time_key +2012-01-29 00:00:00 -48:00:00 +2012-01-30 00:00:00 -24:00:00 +2012-01-30 00:00:00 -48:00:00 +2012-01-31 00:00:00 -24:00:00 +2012-01-31 00:00:00 -48:00:00 +2012-01-31 00:00:00 00:00:00 +2012-02-01 00:00:00 -24:00:00 +2012-02-01 00:00:00 -48:00:00 +2012-02-01 00:00:00 00:00:00 +2012-02-01 00:00:00 24:00:00 +2012-02-02 00:00:00 -24:00:00 +2012-02-02 00:00:00 -48:00:00 +2012-02-02 00:00:00 00:00:00 +2012-02-02 00:00:00 24:00:00 +2012-02-02 00:00:00 48:00:00 +EXPLAIN SELECT * FROM +t2 ignore INDEX (col_datetime_key) +STRAIGHT_JOIN +t1 force INDEX (col_time_key) +WHERE col_time_key >= col_datetime_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +2 SIMPLE t1 NULL index col_time_key col_time_key 4 NULL 5 33.33 Using where; Using index; Using join buffer (hash join) +Warnings: +Warning 1739 Cannot use range access on index 'col_time_key' due to type or collation conversion on field 'col_time_key' +Note 1003 /* select#1 */ select `test`.`t2`.`col_datetime_key` AS `col_datetime_key`,`test`.`t1`.`col_time_key` AS `col_time_key` from `test`.`t2` IGNORE INDEX (`col_datetime_key`) straight_join `test`.`t1` FORCE INDEX (`col_time_key`) where (cast(`test`.`t1`.`col_time_key` as datetime) >= `test`.`t2`.`col_datetime_key`) +SELECT * FROM +t2 ignore INDEX (col_datetime_key) +STRAIGHT_JOIN +t1 force INDEX (col_time_key) +WHERE col_time_key >= col_datetime_key; +col_datetime_key col_time_key +2012-01-29 00:00:00 -24:00:00 +2012-01-29 00:00:00 -48:00:00 +2012-01-29 00:00:00 00:00:00 +2012-01-29 00:00:00 24:00:00 +2012-01-29 00:00:00 48:00:00 +2012-01-30 00:00:00 -24:00:00 +2012-01-30 00:00:00 00:00:00 +2012-01-30 00:00:00 24:00:00 +2012-01-30 00:00:00 48:00:00 +2012-01-31 00:00:00 00:00:00 +2012-01-31 00:00:00 24:00:00 +2012-01-31 00:00:00 48:00:00 +2012-02-01 00:00:00 24:00:00 +2012-02-01 00:00:00 48:00:00 +2012-02-02 00:00:00 48:00:00 +EXPLAIN SELECT * FROM +t2 ignore INDEX (col_datetime_key) +STRAIGHT_JOIN +t1 force INDEX (col_time_key) +WHERE col_datetime_key >= col_time_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +2 SIMPLE t1 NULL index col_time_key col_time_key 4 NULL 5 33.33 Using where; Using index; Using join buffer (hash join) +Warnings: +Warning 1739 Cannot use range access on index 'col_time_key' due to type or collation conversion on field 'col_time_key' +Note 1003 /* select#1 */ select `test`.`t2`.`col_datetime_key` AS `col_datetime_key`,`test`.`t1`.`col_time_key` AS `col_time_key` from `test`.`t2` IGNORE INDEX (`col_datetime_key`) straight_join `test`.`t1` FORCE INDEX (`col_time_key`) where (`test`.`t2`.`col_datetime_key` >= cast(`test`.`t1`.`col_time_key` as datetime)) +SELECT * FROM +t2 ignore INDEX (col_datetime_key) +STRAIGHT_JOIN +t1 force INDEX (col_time_key) +WHERE col_datetime_key >= col_time_key; +col_datetime_key col_time_key +2012-01-29 00:00:00 -48:00:00 +2012-01-30 00:00:00 -24:00:00 +2012-01-30 00:00:00 -48:00:00 +2012-01-31 00:00:00 -24:00:00 +2012-01-31 00:00:00 -48:00:00 +2012-01-31 00:00:00 00:00:00 +2012-02-01 00:00:00 -24:00:00 +2012-02-01 00:00:00 -48:00:00 +2012-02-01 00:00:00 00:00:00 +2012-02-01 00:00:00 24:00:00 +2012-02-02 00:00:00 -24:00:00 +2012-02-02 00:00:00 -48:00:00 +2012-02-02 00:00:00 00:00:00 +2012-02-02 00:00:00 24:00:00 +2012-02-02 00:00:00 48:00:00 +EXPLAIN SELECT * FROM +t2 force INDEX (col_datetime_key) +STRAIGHT_JOIN +t1 ignore INDEX (col_time_key) +WHERE col_time_key >= col_datetime_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL index col_datetime_key col_datetime_key 6 NULL 5 100.00 Using index +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 33.33 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`col_datetime_key` AS `col_datetime_key`,`test`.`t1`.`col_time_key` AS `col_time_key` from `test`.`t2` FORCE INDEX (`col_datetime_key`) straight_join `test`.`t1` IGNORE INDEX (`col_time_key`) where (cast(`test`.`t1`.`col_time_key` as datetime) >= `test`.`t2`.`col_datetime_key`) +SELECT * FROM +t2 force INDEX (col_datetime_key) +STRAIGHT_JOIN +t1 ignore INDEX (col_time_key) +WHERE col_time_key >= col_datetime_key; +col_datetime_key col_time_key +2012-01-29 00:00:00 -24:00:00 +2012-01-29 00:00:00 -48:00:00 +2012-01-29 00:00:00 00:00:00 +2012-01-29 00:00:00 24:00:00 +2012-01-29 00:00:00 48:00:00 +2012-01-30 00:00:00 -24:00:00 +2012-01-30 00:00:00 00:00:00 +2012-01-30 00:00:00 24:00:00 +2012-01-30 00:00:00 48:00:00 +2012-01-31 00:00:00 00:00:00 +2012-01-31 00:00:00 24:00:00 +2012-01-31 00:00:00 48:00:00 +2012-02-01 00:00:00 24:00:00 +2012-02-01 00:00:00 48:00:00 +2012-02-02 00:00:00 48:00:00 +EXPLAIN SELECT * FROM +t2 force INDEX (col_datetime_key) +STRAIGHT_JOIN +t1 ignore INDEX (col_time_key) +WHERE col_datetime_key >= col_time_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL index col_datetime_key col_datetime_key 6 NULL 5 100.00 Using index +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 33.33 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`col_datetime_key` AS `col_datetime_key`,`test`.`t1`.`col_time_key` AS `col_time_key` from `test`.`t2` FORCE INDEX (`col_datetime_key`) straight_join `test`.`t1` IGNORE INDEX (`col_time_key`) where (`test`.`t2`.`col_datetime_key` >= cast(`test`.`t1`.`col_time_key` as datetime)) +SELECT * FROM +t2 force INDEX (col_datetime_key) +STRAIGHT_JOIN +t1 ignore INDEX (col_time_key) +WHERE col_datetime_key >= col_time_key; +col_datetime_key col_time_key +2012-01-29 00:00:00 -48:00:00 +2012-01-30 00:00:00 -24:00:00 +2012-01-30 00:00:00 -48:00:00 +2012-01-31 00:00:00 -24:00:00 +2012-01-31 00:00:00 -48:00:00 +2012-01-31 00:00:00 00:00:00 +2012-02-01 00:00:00 -24:00:00 +2012-02-01 00:00:00 -48:00:00 +2012-02-01 00:00:00 00:00:00 +2012-02-01 00:00:00 24:00:00 +2012-02-02 00:00:00 -24:00:00 +2012-02-02 00:00:00 -48:00:00 +2012-02-02 00:00:00 00:00:00 +2012-02-02 00:00:00 24:00:00 +2012-02-02 00:00:00 48:00:00 +EXPLAIN SELECT * FROM +t2 force INDEX (col_datetime_key) +STRAIGHT_JOIN +t1 force INDEX (col_time_key) +WHERE col_time_key >= col_datetime_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL index col_datetime_key col_datetime_key 6 NULL 5 100.00 Using index +2 SIMPLE t1 NULL index col_time_key col_time_key 4 NULL 5 33.33 Using where; Using index; Using join buffer (hash join) +Warnings: +Warning 1739 Cannot use range access on index 'col_time_key' due to type or collation conversion on field 'col_time_key' +Note 1003 /* select#1 */ select `test`.`t2`.`col_datetime_key` AS `col_datetime_key`,`test`.`t1`.`col_time_key` AS `col_time_key` from `test`.`t2` FORCE INDEX (`col_datetime_key`) straight_join `test`.`t1` FORCE INDEX (`col_time_key`) where (cast(`test`.`t1`.`col_time_key` as datetime) >= `test`.`t2`.`col_datetime_key`) +SELECT * FROM +t2 force INDEX (col_datetime_key) +STRAIGHT_JOIN +t1 force INDEX (col_time_key) +WHERE col_time_key >= col_datetime_key; +col_datetime_key col_time_key +2012-01-29 00:00:00 -24:00:00 +2012-01-29 00:00:00 -48:00:00 +2012-01-29 00:00:00 00:00:00 +2012-01-29 00:00:00 24:00:00 +2012-01-29 00:00:00 48:00:00 +2012-01-30 00:00:00 -24:00:00 +2012-01-30 00:00:00 00:00:00 +2012-01-30 00:00:00 24:00:00 +2012-01-30 00:00:00 48:00:00 +2012-01-31 00:00:00 00:00:00 +2012-01-31 00:00:00 24:00:00 +2012-01-31 00:00:00 48:00:00 +2012-02-01 00:00:00 24:00:00 +2012-02-01 00:00:00 48:00:00 +2012-02-02 00:00:00 48:00:00 +EXPLAIN SELECT * FROM +t2 force INDEX (col_datetime_key) +STRAIGHT_JOIN +t1 force INDEX (col_time_key) +WHERE col_datetime_key >= col_time_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL index col_datetime_key col_datetime_key 6 NULL 5 100.00 Using index +2 SIMPLE t1 NULL index col_time_key col_time_key 4 NULL 5 33.33 Using where; Using index; Using join buffer (hash join) +Warnings: +Warning 1739 Cannot use range access on index 'col_time_key' due to type or collation conversion on field 'col_time_key' +Note 1003 /* select#1 */ select `test`.`t2`.`col_datetime_key` AS `col_datetime_key`,`test`.`t1`.`col_time_key` AS `col_time_key` from `test`.`t2` FORCE INDEX (`col_datetime_key`) straight_join `test`.`t1` FORCE INDEX (`col_time_key`) where (`test`.`t2`.`col_datetime_key` >= cast(`test`.`t1`.`col_time_key` as datetime)) +SELECT * FROM +t2 force INDEX (col_datetime_key) +STRAIGHT_JOIN +t1 force INDEX (col_time_key) +WHERE col_datetime_key >= col_time_key; +col_datetime_key col_time_key +2012-01-29 00:00:00 -48:00:00 +2012-01-30 00:00:00 -24:00:00 +2012-01-30 00:00:00 -48:00:00 +2012-01-31 00:00:00 -24:00:00 +2012-01-31 00:00:00 -48:00:00 +2012-01-31 00:00:00 00:00:00 +2012-02-01 00:00:00 -24:00:00 +2012-02-01 00:00:00 -48:00:00 +2012-02-01 00:00:00 00:00:00 +2012-02-01 00:00:00 24:00:00 +2012-02-02 00:00:00 -24:00:00 +2012-02-02 00:00:00 -48:00:00 +2012-02-02 00:00:00 00:00:00 +2012-02-02 00:00:00 24:00:00 +2012-02-02 00:00:00 48:00:00 +EXPLAIN SELECT * FROM +t1 ignore INDEX (col_time_key) +STRAIGHT_JOIN +t2 ignore INDEX (col_datetime_key) +WHERE col_time_key > col_datetime_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 5 33.33 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col_time_key` AS `col_time_key`,`test`.`t2`.`col_datetime_key` AS `col_datetime_key` from `test`.`t1` IGNORE INDEX (`col_time_key`) straight_join `test`.`t2` IGNORE INDEX (`col_datetime_key`) where (cast(`test`.`t1`.`col_time_key` as datetime) > `test`.`t2`.`col_datetime_key`) +SELECT * FROM +t1 ignore INDEX (col_time_key) +STRAIGHT_JOIN +t2 ignore INDEX (col_datetime_key) +WHERE col_time_key > col_datetime_key; +col_time_key col_datetime_key +-24:00:00 2012-01-29 00:00:00 +00:00:00 2012-01-29 00:00:00 +00:00:00 2012-01-30 00:00:00 +24:00:00 2012-01-29 00:00:00 +24:00:00 2012-01-30 00:00:00 +24:00:00 2012-01-31 00:00:00 +48:00:00 2012-01-29 00:00:00 +48:00:00 2012-01-30 00:00:00 +48:00:00 2012-01-31 00:00:00 +48:00:00 2012-02-01 00:00:00 +EXPLAIN SELECT * FROM +t1 ignore INDEX (col_time_key) +STRAIGHT_JOIN +t2 ignore INDEX (col_datetime_key) +WHERE col_datetime_key > col_time_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 5 33.33 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col_time_key` AS `col_time_key`,`test`.`t2`.`col_datetime_key` AS `col_datetime_key` from `test`.`t1` IGNORE INDEX (`col_time_key`) straight_join `test`.`t2` IGNORE INDEX (`col_datetime_key`) where (`test`.`t2`.`col_datetime_key` > cast(`test`.`t1`.`col_time_key` as datetime)) +SELECT * FROM +t1 ignore INDEX (col_time_key) +STRAIGHT_JOIN +t2 ignore INDEX (col_datetime_key) +WHERE col_datetime_key > col_time_key; +col_time_key col_datetime_key +-24:00:00 2012-01-31 00:00:00 +-24:00:00 2012-02-01 00:00:00 +-24:00:00 2012-02-02 00:00:00 +-48:00:00 2012-01-30 00:00:00 +-48:00:00 2012-01-31 00:00:00 +-48:00:00 2012-02-01 00:00:00 +-48:00:00 2012-02-02 00:00:00 +00:00:00 2012-02-01 00:00:00 +00:00:00 2012-02-02 00:00:00 +24:00:00 2012-02-02 00:00:00 +EXPLAIN SELECT * FROM +t1 ignore INDEX (col_time_key) +STRAIGHT_JOIN +t2 force INDEX (col_datetime_key) +WHERE col_time_key > col_datetime_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +2 SIMPLE t2 NULL ALL col_datetime_key NULL NULL NULL 5 33.33 Range checked for each record (index map: 0x1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col_time_key` AS `col_time_key`,`test`.`t2`.`col_datetime_key` AS `col_datetime_key` from `test`.`t1` IGNORE INDEX (`col_time_key`) straight_join `test`.`t2` FORCE INDEX (`col_datetime_key`) where (cast(`test`.`t1`.`col_time_key` as datetime) > `test`.`t2`.`col_datetime_key`) +SELECT * FROM +t1 ignore INDEX (col_time_key) +STRAIGHT_JOIN +t2 force INDEX (col_datetime_key) +WHERE col_time_key > col_datetime_key; +col_time_key col_datetime_key +-24:00:00 2012-01-29 00:00:00 +00:00:00 2012-01-29 00:00:00 +00:00:00 2012-01-30 00:00:00 +24:00:00 2012-01-29 00:00:00 +24:00:00 2012-01-30 00:00:00 +24:00:00 2012-01-31 00:00:00 +48:00:00 2012-01-29 00:00:00 +48:00:00 2012-01-30 00:00:00 +48:00:00 2012-01-31 00:00:00 +48:00:00 2012-02-01 00:00:00 +EXPLAIN SELECT * FROM +t1 ignore INDEX (col_time_key) +STRAIGHT_JOIN +t2 force INDEX (col_datetime_key) +WHERE col_datetime_key > col_time_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +2 SIMPLE t2 NULL ALL col_datetime_key NULL NULL NULL 5 33.33 Range checked for each record (index map: 0x1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col_time_key` AS `col_time_key`,`test`.`t2`.`col_datetime_key` AS `col_datetime_key` from `test`.`t1` IGNORE INDEX (`col_time_key`) straight_join `test`.`t2` FORCE INDEX (`col_datetime_key`) where (`test`.`t2`.`col_datetime_key` > cast(`test`.`t1`.`col_time_key` as datetime)) +SELECT * FROM +t1 ignore INDEX (col_time_key) +STRAIGHT_JOIN +t2 force INDEX (col_datetime_key) +WHERE col_datetime_key > col_time_key; +col_time_key col_datetime_key +-24:00:00 2012-01-31 00:00:00 +-24:00:00 2012-02-01 00:00:00 +-24:00:00 2012-02-02 00:00:00 +-48:00:00 2012-01-30 00:00:00 +-48:00:00 2012-01-31 00:00:00 +-48:00:00 2012-02-01 00:00:00 +-48:00:00 2012-02-02 00:00:00 +00:00:00 2012-02-01 00:00:00 +00:00:00 2012-02-02 00:00:00 +24:00:00 2012-02-02 00:00:00 +EXPLAIN SELECT * FROM +t1 force INDEX (col_time_key) +STRAIGHT_JOIN +t2 ignore INDEX (col_datetime_key) +WHERE col_time_key > col_datetime_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index col_time_key col_time_key 4 NULL 5 100.00 Using index +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 5 33.33 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col_time_key` AS `col_time_key`,`test`.`t2`.`col_datetime_key` AS `col_datetime_key` from `test`.`t1` FORCE INDEX (`col_time_key`) straight_join `test`.`t2` IGNORE INDEX (`col_datetime_key`) where (cast(`test`.`t1`.`col_time_key` as datetime) > `test`.`t2`.`col_datetime_key`) +SELECT * FROM +t1 force INDEX (col_time_key) +STRAIGHT_JOIN +t2 ignore INDEX (col_datetime_key) +WHERE col_time_key > col_datetime_key; +col_time_key col_datetime_key +-24:00:00 2012-01-29 00:00:00 +00:00:00 2012-01-29 00:00:00 +00:00:00 2012-01-30 00:00:00 +24:00:00 2012-01-29 00:00:00 +24:00:00 2012-01-30 00:00:00 +24:00:00 2012-01-31 00:00:00 +48:00:00 2012-01-29 00:00:00 +48:00:00 2012-01-30 00:00:00 +48:00:00 2012-01-31 00:00:00 +48:00:00 2012-02-01 00:00:00 +EXPLAIN SELECT * FROM +t1 force INDEX (col_time_key) +STRAIGHT_JOIN +t2 ignore INDEX (col_datetime_key) +WHERE col_datetime_key > col_time_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index col_time_key col_time_key 4 NULL 5 100.00 Using index +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 5 33.33 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col_time_key` AS `col_time_key`,`test`.`t2`.`col_datetime_key` AS `col_datetime_key` from `test`.`t1` FORCE INDEX (`col_time_key`) straight_join `test`.`t2` IGNORE INDEX (`col_datetime_key`) where (`test`.`t2`.`col_datetime_key` > cast(`test`.`t1`.`col_time_key` as datetime)) +SELECT * FROM +t1 force INDEX (col_time_key) +STRAIGHT_JOIN +t2 ignore INDEX (col_datetime_key) +WHERE col_datetime_key > col_time_key; +col_time_key col_datetime_key +-24:00:00 2012-01-31 00:00:00 +-24:00:00 2012-02-01 00:00:00 +-24:00:00 2012-02-02 00:00:00 +-48:00:00 2012-01-30 00:00:00 +-48:00:00 2012-01-31 00:00:00 +-48:00:00 2012-02-01 00:00:00 +-48:00:00 2012-02-02 00:00:00 +00:00:00 2012-02-01 00:00:00 +00:00:00 2012-02-02 00:00:00 +24:00:00 2012-02-02 00:00:00 +EXPLAIN SELECT * FROM +t1 force INDEX (col_time_key) +STRAIGHT_JOIN +t2 force INDEX (col_datetime_key) +WHERE col_time_key > col_datetime_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index col_time_key col_time_key 4 NULL 5 100.00 Using index +2 SIMPLE t2 NULL ALL col_datetime_key NULL NULL NULL 5 33.33 Range checked for each record (index map: 0x1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col_time_key` AS `col_time_key`,`test`.`t2`.`col_datetime_key` AS `col_datetime_key` from `test`.`t1` FORCE INDEX (`col_time_key`) straight_join `test`.`t2` FORCE INDEX (`col_datetime_key`) where (cast(`test`.`t1`.`col_time_key` as datetime) > `test`.`t2`.`col_datetime_key`) +SELECT * FROM +t1 force INDEX (col_time_key) +STRAIGHT_JOIN +t2 force INDEX (col_datetime_key) +WHERE col_time_key > col_datetime_key; +col_time_key col_datetime_key +-24:00:00 2012-01-29 00:00:00 +00:00:00 2012-01-29 00:00:00 +00:00:00 2012-01-30 00:00:00 +24:00:00 2012-01-29 00:00:00 +24:00:00 2012-01-30 00:00:00 +24:00:00 2012-01-31 00:00:00 +48:00:00 2012-01-29 00:00:00 +48:00:00 2012-01-30 00:00:00 +48:00:00 2012-01-31 00:00:00 +48:00:00 2012-02-01 00:00:00 +EXPLAIN SELECT * FROM +t1 force INDEX (col_time_key) +STRAIGHT_JOIN +t2 force INDEX (col_datetime_key) +WHERE col_datetime_key > col_time_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index col_time_key col_time_key 4 NULL 5 100.00 Using index +2 SIMPLE t2 NULL ALL col_datetime_key NULL NULL NULL 5 33.33 Range checked for each record (index map: 0x1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col_time_key` AS `col_time_key`,`test`.`t2`.`col_datetime_key` AS `col_datetime_key` from `test`.`t1` FORCE INDEX (`col_time_key`) straight_join `test`.`t2` FORCE INDEX (`col_datetime_key`) where (`test`.`t2`.`col_datetime_key` > cast(`test`.`t1`.`col_time_key` as datetime)) +SELECT * FROM +t1 force INDEX (col_time_key) +STRAIGHT_JOIN +t2 force INDEX (col_datetime_key) +WHERE col_datetime_key > col_time_key; +col_time_key col_datetime_key +-24:00:00 2012-01-31 00:00:00 +-24:00:00 2012-02-01 00:00:00 +-24:00:00 2012-02-02 00:00:00 +-48:00:00 2012-01-30 00:00:00 +-48:00:00 2012-01-31 00:00:00 +-48:00:00 2012-02-01 00:00:00 +-48:00:00 2012-02-02 00:00:00 +00:00:00 2012-02-01 00:00:00 +00:00:00 2012-02-02 00:00:00 +24:00:00 2012-02-02 00:00:00 +EXPLAIN SELECT * FROM +t2 ignore INDEX (col_datetime_key) +STRAIGHT_JOIN +t1 ignore INDEX (col_time_key) +WHERE col_time_key > col_datetime_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 33.33 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`col_datetime_key` AS `col_datetime_key`,`test`.`t1`.`col_time_key` AS `col_time_key` from `test`.`t2` IGNORE INDEX (`col_datetime_key`) straight_join `test`.`t1` IGNORE INDEX (`col_time_key`) where (cast(`test`.`t1`.`col_time_key` as datetime) > `test`.`t2`.`col_datetime_key`) +SELECT * FROM +t2 ignore INDEX (col_datetime_key) +STRAIGHT_JOIN +t1 ignore INDEX (col_time_key) +WHERE col_time_key > col_datetime_key; +col_datetime_key col_time_key +2012-01-29 00:00:00 -24:00:00 +2012-01-29 00:00:00 00:00:00 +2012-01-29 00:00:00 24:00:00 +2012-01-29 00:00:00 48:00:00 +2012-01-30 00:00:00 00:00:00 +2012-01-30 00:00:00 24:00:00 +2012-01-30 00:00:00 48:00:00 +2012-01-31 00:00:00 24:00:00 +2012-01-31 00:00:00 48:00:00 +2012-02-01 00:00:00 48:00:00 +EXPLAIN SELECT * FROM +t2 ignore INDEX (col_datetime_key) +STRAIGHT_JOIN +t1 ignore INDEX (col_time_key) +WHERE col_datetime_key > col_time_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 33.33 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`col_datetime_key` AS `col_datetime_key`,`test`.`t1`.`col_time_key` AS `col_time_key` from `test`.`t2` IGNORE INDEX (`col_datetime_key`) straight_join `test`.`t1` IGNORE INDEX (`col_time_key`) where (`test`.`t2`.`col_datetime_key` > cast(`test`.`t1`.`col_time_key` as datetime)) +SELECT * FROM +t2 ignore INDEX (col_datetime_key) +STRAIGHT_JOIN +t1 ignore INDEX (col_time_key) +WHERE col_datetime_key > col_time_key; +col_datetime_key col_time_key +2012-01-30 00:00:00 -48:00:00 +2012-01-31 00:00:00 -24:00:00 +2012-01-31 00:00:00 -48:00:00 +2012-02-01 00:00:00 -24:00:00 +2012-02-01 00:00:00 -48:00:00 +2012-02-01 00:00:00 00:00:00 +2012-02-02 00:00:00 -24:00:00 +2012-02-02 00:00:00 -48:00:00 +2012-02-02 00:00:00 00:00:00 +2012-02-02 00:00:00 24:00:00 +EXPLAIN SELECT * FROM +t2 ignore INDEX (col_datetime_key) +STRAIGHT_JOIN +t1 force INDEX (col_time_key) +WHERE col_time_key > col_datetime_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +2 SIMPLE t1 NULL index col_time_key col_time_key 4 NULL 5 33.33 Using where; Using index; Using join buffer (hash join) +Warnings: +Warning 1739 Cannot use range access on index 'col_time_key' due to type or collation conversion on field 'col_time_key' +Note 1003 /* select#1 */ select `test`.`t2`.`col_datetime_key` AS `col_datetime_key`,`test`.`t1`.`col_time_key` AS `col_time_key` from `test`.`t2` IGNORE INDEX (`col_datetime_key`) straight_join `test`.`t1` FORCE INDEX (`col_time_key`) where (cast(`test`.`t1`.`col_time_key` as datetime) > `test`.`t2`.`col_datetime_key`) +SELECT * FROM +t2 ignore INDEX (col_datetime_key) +STRAIGHT_JOIN +t1 force INDEX (col_time_key) +WHERE col_time_key > col_datetime_key; +col_datetime_key col_time_key +2012-01-29 00:00:00 -24:00:00 +2012-01-29 00:00:00 00:00:00 +2012-01-29 00:00:00 24:00:00 +2012-01-29 00:00:00 48:00:00 +2012-01-30 00:00:00 00:00:00 +2012-01-30 00:00:00 24:00:00 +2012-01-30 00:00:00 48:00:00 +2012-01-31 00:00:00 24:00:00 +2012-01-31 00:00:00 48:00:00 +2012-02-01 00:00:00 48:00:00 +EXPLAIN SELECT * FROM +t2 ignore INDEX (col_datetime_key) +STRAIGHT_JOIN +t1 force INDEX (col_time_key) +WHERE col_datetime_key > col_time_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +2 SIMPLE t1 NULL index col_time_key col_time_key 4 NULL 5 33.33 Using where; Using index; Using join buffer (hash join) +Warnings: +Warning 1739 Cannot use range access on index 'col_time_key' due to type or collation conversion on field 'col_time_key' +Note 1003 /* select#1 */ select `test`.`t2`.`col_datetime_key` AS `col_datetime_key`,`test`.`t1`.`col_time_key` AS `col_time_key` from `test`.`t2` IGNORE INDEX (`col_datetime_key`) straight_join `test`.`t1` FORCE INDEX (`col_time_key`) where (`test`.`t2`.`col_datetime_key` > cast(`test`.`t1`.`col_time_key` as datetime)) +SELECT * FROM +t2 ignore INDEX (col_datetime_key) +STRAIGHT_JOIN +t1 force INDEX (col_time_key) +WHERE col_datetime_key > col_time_key; +col_datetime_key col_time_key +2012-01-30 00:00:00 -48:00:00 +2012-01-31 00:00:00 -24:00:00 +2012-01-31 00:00:00 -48:00:00 +2012-02-01 00:00:00 -24:00:00 +2012-02-01 00:00:00 -48:00:00 +2012-02-01 00:00:00 00:00:00 +2012-02-02 00:00:00 -24:00:00 +2012-02-02 00:00:00 -48:00:00 +2012-02-02 00:00:00 00:00:00 +2012-02-02 00:00:00 24:00:00 +EXPLAIN SELECT * FROM +t2 force INDEX (col_datetime_key) +STRAIGHT_JOIN +t1 ignore INDEX (col_time_key) +WHERE col_time_key > col_datetime_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL index col_datetime_key col_datetime_key 6 NULL 5 100.00 Using index +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 33.33 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`col_datetime_key` AS `col_datetime_key`,`test`.`t1`.`col_time_key` AS `col_time_key` from `test`.`t2` FORCE INDEX (`col_datetime_key`) straight_join `test`.`t1` IGNORE INDEX (`col_time_key`) where (cast(`test`.`t1`.`col_time_key` as datetime) > `test`.`t2`.`col_datetime_key`) +SELECT * FROM +t2 force INDEX (col_datetime_key) +STRAIGHT_JOIN +t1 ignore INDEX (col_time_key) +WHERE col_time_key > col_datetime_key; +col_datetime_key col_time_key +2012-01-29 00:00:00 -24:00:00 +2012-01-29 00:00:00 00:00:00 +2012-01-29 00:00:00 24:00:00 +2012-01-29 00:00:00 48:00:00 +2012-01-30 00:00:00 00:00:00 +2012-01-30 00:00:00 24:00:00 +2012-01-30 00:00:00 48:00:00 +2012-01-31 00:00:00 24:00:00 +2012-01-31 00:00:00 48:00:00 +2012-02-01 00:00:00 48:00:00 +EXPLAIN SELECT * FROM +t2 force INDEX (col_datetime_key) +STRAIGHT_JOIN +t1 ignore INDEX (col_time_key) +WHERE col_datetime_key > col_time_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL index col_datetime_key col_datetime_key 6 NULL 5 100.00 Using index +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 33.33 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`col_datetime_key` AS `col_datetime_key`,`test`.`t1`.`col_time_key` AS `col_time_key` from `test`.`t2` FORCE INDEX (`col_datetime_key`) straight_join `test`.`t1` IGNORE INDEX (`col_time_key`) where (`test`.`t2`.`col_datetime_key` > cast(`test`.`t1`.`col_time_key` as datetime)) +SELECT * FROM +t2 force INDEX (col_datetime_key) +STRAIGHT_JOIN +t1 ignore INDEX (col_time_key) +WHERE col_datetime_key > col_time_key; +col_datetime_key col_time_key +2012-01-30 00:00:00 -48:00:00 +2012-01-31 00:00:00 -24:00:00 +2012-01-31 00:00:00 -48:00:00 +2012-02-01 00:00:00 -24:00:00 +2012-02-01 00:00:00 -48:00:00 +2012-02-01 00:00:00 00:00:00 +2012-02-02 00:00:00 -24:00:00 +2012-02-02 00:00:00 -48:00:00 +2012-02-02 00:00:00 00:00:00 +2012-02-02 00:00:00 24:00:00 +EXPLAIN SELECT * FROM +t2 force INDEX (col_datetime_key) +STRAIGHT_JOIN +t1 force INDEX (col_time_key) +WHERE col_time_key > col_datetime_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL index col_datetime_key col_datetime_key 6 NULL 5 100.00 Using index +2 SIMPLE t1 NULL index col_time_key col_time_key 4 NULL 5 33.33 Using where; Using index; Using join buffer (hash join) +Warnings: +Warning 1739 Cannot use range access on index 'col_time_key' due to type or collation conversion on field 'col_time_key' +Note 1003 /* select#1 */ select `test`.`t2`.`col_datetime_key` AS `col_datetime_key`,`test`.`t1`.`col_time_key` AS `col_time_key` from `test`.`t2` FORCE INDEX (`col_datetime_key`) straight_join `test`.`t1` FORCE INDEX (`col_time_key`) where (cast(`test`.`t1`.`col_time_key` as datetime) > `test`.`t2`.`col_datetime_key`) +SELECT * FROM +t2 force INDEX (col_datetime_key) +STRAIGHT_JOIN +t1 force INDEX (col_time_key) +WHERE col_time_key > col_datetime_key; +col_datetime_key col_time_key +2012-01-29 00:00:00 -24:00:00 +2012-01-29 00:00:00 00:00:00 +2012-01-29 00:00:00 24:00:00 +2012-01-29 00:00:00 48:00:00 +2012-01-30 00:00:00 00:00:00 +2012-01-30 00:00:00 24:00:00 +2012-01-30 00:00:00 48:00:00 +2012-01-31 00:00:00 24:00:00 +2012-01-31 00:00:00 48:00:00 +2012-02-01 00:00:00 48:00:00 +EXPLAIN SELECT * FROM +t2 force INDEX (col_datetime_key) +STRAIGHT_JOIN +t1 force INDEX (col_time_key) +WHERE col_datetime_key > col_time_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL index col_datetime_key col_datetime_key 6 NULL 5 100.00 Using index +2 SIMPLE t1 NULL index col_time_key col_time_key 4 NULL 5 33.33 Using where; Using index; Using join buffer (hash join) +Warnings: +Warning 1739 Cannot use range access on index 'col_time_key' due to type or collation conversion on field 'col_time_key' +Note 1003 /* select#1 */ select `test`.`t2`.`col_datetime_key` AS `col_datetime_key`,`test`.`t1`.`col_time_key` AS `col_time_key` from `test`.`t2` FORCE INDEX (`col_datetime_key`) straight_join `test`.`t1` FORCE INDEX (`col_time_key`) where (`test`.`t2`.`col_datetime_key` > cast(`test`.`t1`.`col_time_key` as datetime)) +SELECT * FROM +t2 force INDEX (col_datetime_key) +STRAIGHT_JOIN +t1 force INDEX (col_time_key) +WHERE col_datetime_key > col_time_key; +col_datetime_key col_time_key +2012-01-30 00:00:00 -48:00:00 +2012-01-31 00:00:00 -24:00:00 +2012-01-31 00:00:00 -48:00:00 +2012-02-01 00:00:00 -24:00:00 +2012-02-01 00:00:00 -48:00:00 +2012-02-01 00:00:00 00:00:00 +2012-02-02 00:00:00 -24:00:00 +2012-02-02 00:00:00 -48:00:00 +2012-02-02 00:00:00 00:00:00 +2012-02-02 00:00:00 24:00:00 +EXPLAIN SELECT * FROM +t1 ignore INDEX (col_time_key) +STRAIGHT_JOIN +t2 ignore INDEX (col_datetime_key) +WHERE col_time_key <= col_datetime_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 5 33.33 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col_time_key` AS `col_time_key`,`test`.`t2`.`col_datetime_key` AS `col_datetime_key` from `test`.`t1` IGNORE INDEX (`col_time_key`) straight_join `test`.`t2` IGNORE INDEX (`col_datetime_key`) where (cast(`test`.`t1`.`col_time_key` as datetime) <= `test`.`t2`.`col_datetime_key`) +SELECT * FROM +t1 ignore INDEX (col_time_key) +STRAIGHT_JOIN +t2 ignore INDEX (col_datetime_key) +WHERE col_time_key <= col_datetime_key; +col_time_key col_datetime_key +-24:00:00 2012-01-30 00:00:00 +-24:00:00 2012-01-31 00:00:00 +-24:00:00 2012-02-01 00:00:00 +-24:00:00 2012-02-02 00:00:00 +-48:00:00 2012-01-29 00:00:00 +-48:00:00 2012-01-30 00:00:00 +-48:00:00 2012-01-31 00:00:00 +-48:00:00 2012-02-01 00:00:00 +-48:00:00 2012-02-02 00:00:00 +00:00:00 2012-01-31 00:00:00 +00:00:00 2012-02-01 00:00:00 +00:00:00 2012-02-02 00:00:00 +24:00:00 2012-02-01 00:00:00 +24:00:00 2012-02-02 00:00:00 +48:00:00 2012-02-02 00:00:00 +EXPLAIN SELECT * FROM +t1 ignore INDEX (col_time_key) +STRAIGHT_JOIN +t2 ignore INDEX (col_datetime_key) +WHERE col_datetime_key <= col_time_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 5 33.33 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col_time_key` AS `col_time_key`,`test`.`t2`.`col_datetime_key` AS `col_datetime_key` from `test`.`t1` IGNORE INDEX (`col_time_key`) straight_join `test`.`t2` IGNORE INDEX (`col_datetime_key`) where (`test`.`t2`.`col_datetime_key` <= cast(`test`.`t1`.`col_time_key` as datetime)) +SELECT * FROM +t1 ignore INDEX (col_time_key) +STRAIGHT_JOIN +t2 ignore INDEX (col_datetime_key) +WHERE col_datetime_key <= col_time_key; +col_time_key col_datetime_key +-24:00:00 2012-01-29 00:00:00 +-24:00:00 2012-01-30 00:00:00 +-48:00:00 2012-01-29 00:00:00 +00:00:00 2012-01-29 00:00:00 +00:00:00 2012-01-30 00:00:00 +00:00:00 2012-01-31 00:00:00 +24:00:00 2012-01-29 00:00:00 +24:00:00 2012-01-30 00:00:00 +24:00:00 2012-01-31 00:00:00 +24:00:00 2012-02-01 00:00:00 +48:00:00 2012-01-29 00:00:00 +48:00:00 2012-01-30 00:00:00 +48:00:00 2012-01-31 00:00:00 +48:00:00 2012-02-01 00:00:00 +48:00:00 2012-02-02 00:00:00 +EXPLAIN SELECT * FROM +t1 ignore INDEX (col_time_key) +STRAIGHT_JOIN +t2 force INDEX (col_datetime_key) +WHERE col_time_key <= col_datetime_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +2 SIMPLE t2 NULL ALL col_datetime_key NULL NULL NULL 5 33.33 Range checked for each record (index map: 0x1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col_time_key` AS `col_time_key`,`test`.`t2`.`col_datetime_key` AS `col_datetime_key` from `test`.`t1` IGNORE INDEX (`col_time_key`) straight_join `test`.`t2` FORCE INDEX (`col_datetime_key`) where (cast(`test`.`t1`.`col_time_key` as datetime) <= `test`.`t2`.`col_datetime_key`) +SELECT * FROM +t1 ignore INDEX (col_time_key) +STRAIGHT_JOIN +t2 force INDEX (col_datetime_key) +WHERE col_time_key <= col_datetime_key; +col_time_key col_datetime_key +-24:00:00 2012-01-30 00:00:00 +-24:00:00 2012-01-31 00:00:00 +-24:00:00 2012-02-01 00:00:00 +-24:00:00 2012-02-02 00:00:00 +-48:00:00 2012-01-29 00:00:00 +-48:00:00 2012-01-30 00:00:00 +-48:00:00 2012-01-31 00:00:00 +-48:00:00 2012-02-01 00:00:00 +-48:00:00 2012-02-02 00:00:00 +00:00:00 2012-01-31 00:00:00 +00:00:00 2012-02-01 00:00:00 +00:00:00 2012-02-02 00:00:00 +24:00:00 2012-02-01 00:00:00 +24:00:00 2012-02-02 00:00:00 +48:00:00 2012-02-02 00:00:00 +EXPLAIN SELECT * FROM +t1 ignore INDEX (col_time_key) +STRAIGHT_JOIN +t2 force INDEX (col_datetime_key) +WHERE col_datetime_key <= col_time_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +2 SIMPLE t2 NULL ALL col_datetime_key NULL NULL NULL 5 33.33 Range checked for each record (index map: 0x1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col_time_key` AS `col_time_key`,`test`.`t2`.`col_datetime_key` AS `col_datetime_key` from `test`.`t1` IGNORE INDEX (`col_time_key`) straight_join `test`.`t2` FORCE INDEX (`col_datetime_key`) where (`test`.`t2`.`col_datetime_key` <= cast(`test`.`t1`.`col_time_key` as datetime)) +SELECT * FROM +t1 ignore INDEX (col_time_key) +STRAIGHT_JOIN +t2 force INDEX (col_datetime_key) +WHERE col_datetime_key <= col_time_key; +col_time_key col_datetime_key +-24:00:00 2012-01-29 00:00:00 +-24:00:00 2012-01-30 00:00:00 +-48:00:00 2012-01-29 00:00:00 +00:00:00 2012-01-29 00:00:00 +00:00:00 2012-01-30 00:00:00 +00:00:00 2012-01-31 00:00:00 +24:00:00 2012-01-29 00:00:00 +24:00:00 2012-01-30 00:00:00 +24:00:00 2012-01-31 00:00:00 +24:00:00 2012-02-01 00:00:00 +48:00:00 2012-01-29 00:00:00 +48:00:00 2012-01-30 00:00:00 +48:00:00 2012-01-31 00:00:00 +48:00:00 2012-02-01 00:00:00 +48:00:00 2012-02-02 00:00:00 +EXPLAIN SELECT * FROM +t1 force INDEX (col_time_key) +STRAIGHT_JOIN +t2 ignore INDEX (col_datetime_key) +WHERE col_time_key <= col_datetime_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index col_time_key col_time_key 4 NULL 5 100.00 Using index +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 5 33.33 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col_time_key` AS `col_time_key`,`test`.`t2`.`col_datetime_key` AS `col_datetime_key` from `test`.`t1` FORCE INDEX (`col_time_key`) straight_join `test`.`t2` IGNORE INDEX (`col_datetime_key`) where (cast(`test`.`t1`.`col_time_key` as datetime) <= `test`.`t2`.`col_datetime_key`) +SELECT * FROM +t1 force INDEX (col_time_key) +STRAIGHT_JOIN +t2 ignore INDEX (col_datetime_key) +WHERE col_time_key <= col_datetime_key; +col_time_key col_datetime_key +-24:00:00 2012-01-30 00:00:00 +-24:00:00 2012-01-31 00:00:00 +-24:00:00 2012-02-01 00:00:00 +-24:00:00 2012-02-02 00:00:00 +-48:00:00 2012-01-29 00:00:00 +-48:00:00 2012-01-30 00:00:00 +-48:00:00 2012-01-31 00:00:00 +-48:00:00 2012-02-01 00:00:00 +-48:00:00 2012-02-02 00:00:00 +00:00:00 2012-01-31 00:00:00 +00:00:00 2012-02-01 00:00:00 +00:00:00 2012-02-02 00:00:00 +24:00:00 2012-02-01 00:00:00 +24:00:00 2012-02-02 00:00:00 +48:00:00 2012-02-02 00:00:00 +EXPLAIN SELECT * FROM +t1 force INDEX (col_time_key) +STRAIGHT_JOIN +t2 ignore INDEX (col_datetime_key) +WHERE col_datetime_key <= col_time_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index col_time_key col_time_key 4 NULL 5 100.00 Using index +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 5 33.33 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col_time_key` AS `col_time_key`,`test`.`t2`.`col_datetime_key` AS `col_datetime_key` from `test`.`t1` FORCE INDEX (`col_time_key`) straight_join `test`.`t2` IGNORE INDEX (`col_datetime_key`) where (`test`.`t2`.`col_datetime_key` <= cast(`test`.`t1`.`col_time_key` as datetime)) +SELECT * FROM +t1 force INDEX (col_time_key) +STRAIGHT_JOIN +t2 ignore INDEX (col_datetime_key) +WHERE col_datetime_key <= col_time_key; +col_time_key col_datetime_key +-24:00:00 2012-01-29 00:00:00 +-24:00:00 2012-01-30 00:00:00 +-48:00:00 2012-01-29 00:00:00 +00:00:00 2012-01-29 00:00:00 +00:00:00 2012-01-30 00:00:00 +00:00:00 2012-01-31 00:00:00 +24:00:00 2012-01-29 00:00:00 +24:00:00 2012-01-30 00:00:00 +24:00:00 2012-01-31 00:00:00 +24:00:00 2012-02-01 00:00:00 +48:00:00 2012-01-29 00:00:00 +48:00:00 2012-01-30 00:00:00 +48:00:00 2012-01-31 00:00:00 +48:00:00 2012-02-01 00:00:00 +48:00:00 2012-02-02 00:00:00 +EXPLAIN SELECT * FROM +t1 force INDEX (col_time_key) +STRAIGHT_JOIN +t2 force INDEX (col_datetime_key) +WHERE col_time_key <= col_datetime_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index col_time_key col_time_key 4 NULL 5 100.00 Using index +2 SIMPLE t2 NULL ALL col_datetime_key NULL NULL NULL 5 33.33 Range checked for each record (index map: 0x1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col_time_key` AS `col_time_key`,`test`.`t2`.`col_datetime_key` AS `col_datetime_key` from `test`.`t1` FORCE INDEX (`col_time_key`) straight_join `test`.`t2` FORCE INDEX (`col_datetime_key`) where (cast(`test`.`t1`.`col_time_key` as datetime) <= `test`.`t2`.`col_datetime_key`) +SELECT * FROM +t1 force INDEX (col_time_key) +STRAIGHT_JOIN +t2 force INDEX (col_datetime_key) +WHERE col_time_key <= col_datetime_key; +col_time_key col_datetime_key +-24:00:00 2012-01-30 00:00:00 +-24:00:00 2012-01-31 00:00:00 +-24:00:00 2012-02-01 00:00:00 +-24:00:00 2012-02-02 00:00:00 +-48:00:00 2012-01-29 00:00:00 +-48:00:00 2012-01-30 00:00:00 +-48:00:00 2012-01-31 00:00:00 +-48:00:00 2012-02-01 00:00:00 +-48:00:00 2012-02-02 00:00:00 +00:00:00 2012-01-31 00:00:00 +00:00:00 2012-02-01 00:00:00 +00:00:00 2012-02-02 00:00:00 +24:00:00 2012-02-01 00:00:00 +24:00:00 2012-02-02 00:00:00 +48:00:00 2012-02-02 00:00:00 +EXPLAIN SELECT * FROM +t1 force INDEX (col_time_key) +STRAIGHT_JOIN +t2 force INDEX (col_datetime_key) +WHERE col_datetime_key <= col_time_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index col_time_key col_time_key 4 NULL 5 100.00 Using index +2 SIMPLE t2 NULL ALL col_datetime_key NULL NULL NULL 5 33.33 Range checked for each record (index map: 0x1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col_time_key` AS `col_time_key`,`test`.`t2`.`col_datetime_key` AS `col_datetime_key` from `test`.`t1` FORCE INDEX (`col_time_key`) straight_join `test`.`t2` FORCE INDEX (`col_datetime_key`) where (`test`.`t2`.`col_datetime_key` <= cast(`test`.`t1`.`col_time_key` as datetime)) +SELECT * FROM +t1 force INDEX (col_time_key) +STRAIGHT_JOIN +t2 force INDEX (col_datetime_key) +WHERE col_datetime_key <= col_time_key; +col_time_key col_datetime_key +-24:00:00 2012-01-29 00:00:00 +-24:00:00 2012-01-30 00:00:00 +-48:00:00 2012-01-29 00:00:00 +00:00:00 2012-01-29 00:00:00 +00:00:00 2012-01-30 00:00:00 +00:00:00 2012-01-31 00:00:00 +24:00:00 2012-01-29 00:00:00 +24:00:00 2012-01-30 00:00:00 +24:00:00 2012-01-31 00:00:00 +24:00:00 2012-02-01 00:00:00 +48:00:00 2012-01-29 00:00:00 +48:00:00 2012-01-30 00:00:00 +48:00:00 2012-01-31 00:00:00 +48:00:00 2012-02-01 00:00:00 +48:00:00 2012-02-02 00:00:00 +EXPLAIN SELECT * FROM +t2 ignore INDEX (col_datetime_key) +STRAIGHT_JOIN +t1 ignore INDEX (col_time_key) +WHERE col_time_key <= col_datetime_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 33.33 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`col_datetime_key` AS `col_datetime_key`,`test`.`t1`.`col_time_key` AS `col_time_key` from `test`.`t2` IGNORE INDEX (`col_datetime_key`) straight_join `test`.`t1` IGNORE INDEX (`col_time_key`) where (cast(`test`.`t1`.`col_time_key` as datetime) <= `test`.`t2`.`col_datetime_key`) +SELECT * FROM +t2 ignore INDEX (col_datetime_key) +STRAIGHT_JOIN +t1 ignore INDEX (col_time_key) +WHERE col_time_key <= col_datetime_key; +col_datetime_key col_time_key +2012-01-29 00:00:00 -48:00:00 +2012-01-30 00:00:00 -24:00:00 +2012-01-30 00:00:00 -48:00:00 +2012-01-31 00:00:00 -24:00:00 +2012-01-31 00:00:00 -48:00:00 +2012-01-31 00:00:00 00:00:00 +2012-02-01 00:00:00 -24:00:00 +2012-02-01 00:00:00 -48:00:00 +2012-02-01 00:00:00 00:00:00 +2012-02-01 00:00:00 24:00:00 +2012-02-02 00:00:00 -24:00:00 +2012-02-02 00:00:00 -48:00:00 +2012-02-02 00:00:00 00:00:00 +2012-02-02 00:00:00 24:00:00 +2012-02-02 00:00:00 48:00:00 +EXPLAIN SELECT * FROM +t2 ignore INDEX (col_datetime_key) +STRAIGHT_JOIN +t1 ignore INDEX (col_time_key) +WHERE col_datetime_key <= col_time_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 33.33 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`col_datetime_key` AS `col_datetime_key`,`test`.`t1`.`col_time_key` AS `col_time_key` from `test`.`t2` IGNORE INDEX (`col_datetime_key`) straight_join `test`.`t1` IGNORE INDEX (`col_time_key`) where (`test`.`t2`.`col_datetime_key` <= cast(`test`.`t1`.`col_time_key` as datetime)) +SELECT * FROM +t2 ignore INDEX (col_datetime_key) +STRAIGHT_JOIN +t1 ignore INDEX (col_time_key) +WHERE col_datetime_key <= col_time_key; +col_datetime_key col_time_key +2012-01-29 00:00:00 -24:00:00 +2012-01-29 00:00:00 -48:00:00 +2012-01-29 00:00:00 00:00:00 +2012-01-29 00:00:00 24:00:00 +2012-01-29 00:00:00 48:00:00 +2012-01-30 00:00:00 -24:00:00 +2012-01-30 00:00:00 00:00:00 +2012-01-30 00:00:00 24:00:00 +2012-01-30 00:00:00 48:00:00 +2012-01-31 00:00:00 00:00:00 +2012-01-31 00:00:00 24:00:00 +2012-01-31 00:00:00 48:00:00 +2012-02-01 00:00:00 24:00:00 +2012-02-01 00:00:00 48:00:00 +2012-02-02 00:00:00 48:00:00 +EXPLAIN SELECT * FROM +t2 ignore INDEX (col_datetime_key) +STRAIGHT_JOIN +t1 force INDEX (col_time_key) +WHERE col_time_key <= col_datetime_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +2 SIMPLE t1 NULL index col_time_key col_time_key 4 NULL 5 33.33 Using where; Using index; Using join buffer (hash join) +Warnings: +Warning 1739 Cannot use range access on index 'col_time_key' due to type or collation conversion on field 'col_time_key' +Note 1003 /* select#1 */ select `test`.`t2`.`col_datetime_key` AS `col_datetime_key`,`test`.`t1`.`col_time_key` AS `col_time_key` from `test`.`t2` IGNORE INDEX (`col_datetime_key`) straight_join `test`.`t1` FORCE INDEX (`col_time_key`) where (cast(`test`.`t1`.`col_time_key` as datetime) <= `test`.`t2`.`col_datetime_key`) +SELECT * FROM +t2 ignore INDEX (col_datetime_key) +STRAIGHT_JOIN +t1 force INDEX (col_time_key) +WHERE col_time_key <= col_datetime_key; +col_datetime_key col_time_key +2012-01-29 00:00:00 -48:00:00 +2012-01-30 00:00:00 -24:00:00 +2012-01-30 00:00:00 -48:00:00 +2012-01-31 00:00:00 -24:00:00 +2012-01-31 00:00:00 -48:00:00 +2012-01-31 00:00:00 00:00:00 +2012-02-01 00:00:00 -24:00:00 +2012-02-01 00:00:00 -48:00:00 +2012-02-01 00:00:00 00:00:00 +2012-02-01 00:00:00 24:00:00 +2012-02-02 00:00:00 -24:00:00 +2012-02-02 00:00:00 -48:00:00 +2012-02-02 00:00:00 00:00:00 +2012-02-02 00:00:00 24:00:00 +2012-02-02 00:00:00 48:00:00 +EXPLAIN SELECT * FROM +t2 ignore INDEX (col_datetime_key) +STRAIGHT_JOIN +t1 force INDEX (col_time_key) +WHERE col_datetime_key <= col_time_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +2 SIMPLE t1 NULL index col_time_key col_time_key 4 NULL 5 33.33 Using where; Using index; Using join buffer (hash join) +Warnings: +Warning 1739 Cannot use range access on index 'col_time_key' due to type or collation conversion on field 'col_time_key' +Note 1003 /* select#1 */ select `test`.`t2`.`col_datetime_key` AS `col_datetime_key`,`test`.`t1`.`col_time_key` AS `col_time_key` from `test`.`t2` IGNORE INDEX (`col_datetime_key`) straight_join `test`.`t1` FORCE INDEX (`col_time_key`) where (`test`.`t2`.`col_datetime_key` <= cast(`test`.`t1`.`col_time_key` as datetime)) +SELECT * FROM +t2 ignore INDEX (col_datetime_key) +STRAIGHT_JOIN +t1 force INDEX (col_time_key) +WHERE col_datetime_key <= col_time_key; +col_datetime_key col_time_key +2012-01-29 00:00:00 -24:00:00 +2012-01-29 00:00:00 -48:00:00 +2012-01-29 00:00:00 00:00:00 +2012-01-29 00:00:00 24:00:00 +2012-01-29 00:00:00 48:00:00 +2012-01-30 00:00:00 -24:00:00 +2012-01-30 00:00:00 00:00:00 +2012-01-30 00:00:00 24:00:00 +2012-01-30 00:00:00 48:00:00 +2012-01-31 00:00:00 00:00:00 +2012-01-31 00:00:00 24:00:00 +2012-01-31 00:00:00 48:00:00 +2012-02-01 00:00:00 24:00:00 +2012-02-01 00:00:00 48:00:00 +2012-02-02 00:00:00 48:00:00 +EXPLAIN SELECT * FROM +t2 force INDEX (col_datetime_key) +STRAIGHT_JOIN +t1 ignore INDEX (col_time_key) +WHERE col_time_key <= col_datetime_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL index col_datetime_key col_datetime_key 6 NULL 5 100.00 Using index +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 33.33 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`col_datetime_key` AS `col_datetime_key`,`test`.`t1`.`col_time_key` AS `col_time_key` from `test`.`t2` FORCE INDEX (`col_datetime_key`) straight_join `test`.`t1` IGNORE INDEX (`col_time_key`) where (cast(`test`.`t1`.`col_time_key` as datetime) <= `test`.`t2`.`col_datetime_key`) +SELECT * FROM +t2 force INDEX (col_datetime_key) +STRAIGHT_JOIN +t1 ignore INDEX (col_time_key) +WHERE col_time_key <= col_datetime_key; +col_datetime_key col_time_key +2012-01-29 00:00:00 -48:00:00 +2012-01-30 00:00:00 -24:00:00 +2012-01-30 00:00:00 -48:00:00 +2012-01-31 00:00:00 -24:00:00 +2012-01-31 00:00:00 -48:00:00 +2012-01-31 00:00:00 00:00:00 +2012-02-01 00:00:00 -24:00:00 +2012-02-01 00:00:00 -48:00:00 +2012-02-01 00:00:00 00:00:00 +2012-02-01 00:00:00 24:00:00 +2012-02-02 00:00:00 -24:00:00 +2012-02-02 00:00:00 -48:00:00 +2012-02-02 00:00:00 00:00:00 +2012-02-02 00:00:00 24:00:00 +2012-02-02 00:00:00 48:00:00 +EXPLAIN SELECT * FROM +t2 force INDEX (col_datetime_key) +STRAIGHT_JOIN +t1 ignore INDEX (col_time_key) +WHERE col_datetime_key <= col_time_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL index col_datetime_key col_datetime_key 6 NULL 5 100.00 Using index +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 33.33 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`col_datetime_key` AS `col_datetime_key`,`test`.`t1`.`col_time_key` AS `col_time_key` from `test`.`t2` FORCE INDEX (`col_datetime_key`) straight_join `test`.`t1` IGNORE INDEX (`col_time_key`) where (`test`.`t2`.`col_datetime_key` <= cast(`test`.`t1`.`col_time_key` as datetime)) +SELECT * FROM +t2 force INDEX (col_datetime_key) +STRAIGHT_JOIN +t1 ignore INDEX (col_time_key) +WHERE col_datetime_key <= col_time_key; +col_datetime_key col_time_key +2012-01-29 00:00:00 -24:00:00 +2012-01-29 00:00:00 -48:00:00 +2012-01-29 00:00:00 00:00:00 +2012-01-29 00:00:00 24:00:00 +2012-01-29 00:00:00 48:00:00 +2012-01-30 00:00:00 -24:00:00 +2012-01-30 00:00:00 00:00:00 +2012-01-30 00:00:00 24:00:00 +2012-01-30 00:00:00 48:00:00 +2012-01-31 00:00:00 00:00:00 +2012-01-31 00:00:00 24:00:00 +2012-01-31 00:00:00 48:00:00 +2012-02-01 00:00:00 24:00:00 +2012-02-01 00:00:00 48:00:00 +2012-02-02 00:00:00 48:00:00 +EXPLAIN SELECT * FROM +t2 force INDEX (col_datetime_key) +STRAIGHT_JOIN +t1 force INDEX (col_time_key) +WHERE col_time_key <= col_datetime_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL index col_datetime_key col_datetime_key 6 NULL 5 100.00 Using index +2 SIMPLE t1 NULL index col_time_key col_time_key 4 NULL 5 33.33 Using where; Using index; Using join buffer (hash join) +Warnings: +Warning 1739 Cannot use range access on index 'col_time_key' due to type or collation conversion on field 'col_time_key' +Note 1003 /* select#1 */ select `test`.`t2`.`col_datetime_key` AS `col_datetime_key`,`test`.`t1`.`col_time_key` AS `col_time_key` from `test`.`t2` FORCE INDEX (`col_datetime_key`) straight_join `test`.`t1` FORCE INDEX (`col_time_key`) where (cast(`test`.`t1`.`col_time_key` as datetime) <= `test`.`t2`.`col_datetime_key`) +SELECT * FROM +t2 force INDEX (col_datetime_key) +STRAIGHT_JOIN +t1 force INDEX (col_time_key) +WHERE col_time_key <= col_datetime_key; +col_datetime_key col_time_key +2012-01-29 00:00:00 -48:00:00 +2012-01-30 00:00:00 -24:00:00 +2012-01-30 00:00:00 -48:00:00 +2012-01-31 00:00:00 -24:00:00 +2012-01-31 00:00:00 -48:00:00 +2012-01-31 00:00:00 00:00:00 +2012-02-01 00:00:00 -24:00:00 +2012-02-01 00:00:00 -48:00:00 +2012-02-01 00:00:00 00:00:00 +2012-02-01 00:00:00 24:00:00 +2012-02-02 00:00:00 -24:00:00 +2012-02-02 00:00:00 -48:00:00 +2012-02-02 00:00:00 00:00:00 +2012-02-02 00:00:00 24:00:00 +2012-02-02 00:00:00 48:00:00 +EXPLAIN SELECT * FROM +t2 force INDEX (col_datetime_key) +STRAIGHT_JOIN +t1 force INDEX (col_time_key) +WHERE col_datetime_key <= col_time_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL index col_datetime_key col_datetime_key 6 NULL 5 100.00 Using index +2 SIMPLE t1 NULL index col_time_key col_time_key 4 NULL 5 33.33 Using where; Using index; Using join buffer (hash join) +Warnings: +Warning 1739 Cannot use range access on index 'col_time_key' due to type or collation conversion on field 'col_time_key' +Note 1003 /* select#1 */ select `test`.`t2`.`col_datetime_key` AS `col_datetime_key`,`test`.`t1`.`col_time_key` AS `col_time_key` from `test`.`t2` FORCE INDEX (`col_datetime_key`) straight_join `test`.`t1` FORCE INDEX (`col_time_key`) where (`test`.`t2`.`col_datetime_key` <= cast(`test`.`t1`.`col_time_key` as datetime)) +SELECT * FROM +t2 force INDEX (col_datetime_key) +STRAIGHT_JOIN +t1 force INDEX (col_time_key) +WHERE col_datetime_key <= col_time_key; +col_datetime_key col_time_key +2012-01-29 00:00:00 -24:00:00 +2012-01-29 00:00:00 -48:00:00 +2012-01-29 00:00:00 00:00:00 +2012-01-29 00:00:00 24:00:00 +2012-01-29 00:00:00 48:00:00 +2012-01-30 00:00:00 -24:00:00 +2012-01-30 00:00:00 00:00:00 +2012-01-30 00:00:00 24:00:00 +2012-01-30 00:00:00 48:00:00 +2012-01-31 00:00:00 00:00:00 +2012-01-31 00:00:00 24:00:00 +2012-01-31 00:00:00 48:00:00 +2012-02-01 00:00:00 24:00:00 +2012-02-01 00:00:00 48:00:00 +2012-02-02 00:00:00 48:00:00 +EXPLAIN SELECT * FROM +t1 ignore INDEX (col_time_key) +STRAIGHT_JOIN +t2 ignore INDEX (col_datetime_key) +WHERE col_time_key < col_datetime_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 5 33.33 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col_time_key` AS `col_time_key`,`test`.`t2`.`col_datetime_key` AS `col_datetime_key` from `test`.`t1` IGNORE INDEX (`col_time_key`) straight_join `test`.`t2` IGNORE INDEX (`col_datetime_key`) where (cast(`test`.`t1`.`col_time_key` as datetime) < `test`.`t2`.`col_datetime_key`) +SELECT * FROM +t1 ignore INDEX (col_time_key) +STRAIGHT_JOIN +t2 ignore INDEX (col_datetime_key) +WHERE col_time_key < col_datetime_key; +col_time_key col_datetime_key +-24:00:00 2012-01-31 00:00:00 +-24:00:00 2012-02-01 00:00:00 +-24:00:00 2012-02-02 00:00:00 +-48:00:00 2012-01-30 00:00:00 +-48:00:00 2012-01-31 00:00:00 +-48:00:00 2012-02-01 00:00:00 +-48:00:00 2012-02-02 00:00:00 +00:00:00 2012-02-01 00:00:00 +00:00:00 2012-02-02 00:00:00 +24:00:00 2012-02-02 00:00:00 +EXPLAIN SELECT * FROM +t1 ignore INDEX (col_time_key) +STRAIGHT_JOIN +t2 ignore INDEX (col_datetime_key) +WHERE col_datetime_key < col_time_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 5 33.33 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col_time_key` AS `col_time_key`,`test`.`t2`.`col_datetime_key` AS `col_datetime_key` from `test`.`t1` IGNORE INDEX (`col_time_key`) straight_join `test`.`t2` IGNORE INDEX (`col_datetime_key`) where (`test`.`t2`.`col_datetime_key` < cast(`test`.`t1`.`col_time_key` as datetime)) +SELECT * FROM +t1 ignore INDEX (col_time_key) +STRAIGHT_JOIN +t2 ignore INDEX (col_datetime_key) +WHERE col_datetime_key < col_time_key; +col_time_key col_datetime_key +-24:00:00 2012-01-29 00:00:00 +00:00:00 2012-01-29 00:00:00 +00:00:00 2012-01-30 00:00:00 +24:00:00 2012-01-29 00:00:00 +24:00:00 2012-01-30 00:00:00 +24:00:00 2012-01-31 00:00:00 +48:00:00 2012-01-29 00:00:00 +48:00:00 2012-01-30 00:00:00 +48:00:00 2012-01-31 00:00:00 +48:00:00 2012-02-01 00:00:00 +EXPLAIN SELECT * FROM +t1 ignore INDEX (col_time_key) +STRAIGHT_JOIN +t2 force INDEX (col_datetime_key) +WHERE col_time_key < col_datetime_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +2 SIMPLE t2 NULL ALL col_datetime_key NULL NULL NULL 5 33.33 Range checked for each record (index map: 0x1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col_time_key` AS `col_time_key`,`test`.`t2`.`col_datetime_key` AS `col_datetime_key` from `test`.`t1` IGNORE INDEX (`col_time_key`) straight_join `test`.`t2` FORCE INDEX (`col_datetime_key`) where (cast(`test`.`t1`.`col_time_key` as datetime) < `test`.`t2`.`col_datetime_key`) +SELECT * FROM +t1 ignore INDEX (col_time_key) +STRAIGHT_JOIN +t2 force INDEX (col_datetime_key) +WHERE col_time_key < col_datetime_key; +col_time_key col_datetime_key +-24:00:00 2012-01-31 00:00:00 +-24:00:00 2012-02-01 00:00:00 +-24:00:00 2012-02-02 00:00:00 +-48:00:00 2012-01-30 00:00:00 +-48:00:00 2012-01-31 00:00:00 +-48:00:00 2012-02-01 00:00:00 +-48:00:00 2012-02-02 00:00:00 +00:00:00 2012-02-01 00:00:00 +00:00:00 2012-02-02 00:00:00 +24:00:00 2012-02-02 00:00:00 +EXPLAIN SELECT * FROM +t1 ignore INDEX (col_time_key) +STRAIGHT_JOIN +t2 force INDEX (col_datetime_key) +WHERE col_datetime_key < col_time_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +2 SIMPLE t2 NULL ALL col_datetime_key NULL NULL NULL 5 33.33 Range checked for each record (index map: 0x1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col_time_key` AS `col_time_key`,`test`.`t2`.`col_datetime_key` AS `col_datetime_key` from `test`.`t1` IGNORE INDEX (`col_time_key`) straight_join `test`.`t2` FORCE INDEX (`col_datetime_key`) where (`test`.`t2`.`col_datetime_key` < cast(`test`.`t1`.`col_time_key` as datetime)) +SELECT * FROM +t1 ignore INDEX (col_time_key) +STRAIGHT_JOIN +t2 force INDEX (col_datetime_key) +WHERE col_datetime_key < col_time_key; +col_time_key col_datetime_key +-24:00:00 2012-01-29 00:00:00 +00:00:00 2012-01-29 00:00:00 +00:00:00 2012-01-30 00:00:00 +24:00:00 2012-01-29 00:00:00 +24:00:00 2012-01-30 00:00:00 +24:00:00 2012-01-31 00:00:00 +48:00:00 2012-01-29 00:00:00 +48:00:00 2012-01-30 00:00:00 +48:00:00 2012-01-31 00:00:00 +48:00:00 2012-02-01 00:00:00 +EXPLAIN SELECT * FROM +t1 force INDEX (col_time_key) +STRAIGHT_JOIN +t2 ignore INDEX (col_datetime_key) +WHERE col_time_key < col_datetime_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index col_time_key col_time_key 4 NULL 5 100.00 Using index +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 5 33.33 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col_time_key` AS `col_time_key`,`test`.`t2`.`col_datetime_key` AS `col_datetime_key` from `test`.`t1` FORCE INDEX (`col_time_key`) straight_join `test`.`t2` IGNORE INDEX (`col_datetime_key`) where (cast(`test`.`t1`.`col_time_key` as datetime) < `test`.`t2`.`col_datetime_key`) +SELECT * FROM +t1 force INDEX (col_time_key) +STRAIGHT_JOIN +t2 ignore INDEX (col_datetime_key) +WHERE col_time_key < col_datetime_key; +col_time_key col_datetime_key +-24:00:00 2012-01-31 00:00:00 +-24:00:00 2012-02-01 00:00:00 +-24:00:00 2012-02-02 00:00:00 +-48:00:00 2012-01-30 00:00:00 +-48:00:00 2012-01-31 00:00:00 +-48:00:00 2012-02-01 00:00:00 +-48:00:00 2012-02-02 00:00:00 +00:00:00 2012-02-01 00:00:00 +00:00:00 2012-02-02 00:00:00 +24:00:00 2012-02-02 00:00:00 +EXPLAIN SELECT * FROM +t1 force INDEX (col_time_key) +STRAIGHT_JOIN +t2 ignore INDEX (col_datetime_key) +WHERE col_datetime_key < col_time_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index col_time_key col_time_key 4 NULL 5 100.00 Using index +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 5 33.33 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col_time_key` AS `col_time_key`,`test`.`t2`.`col_datetime_key` AS `col_datetime_key` from `test`.`t1` FORCE INDEX (`col_time_key`) straight_join `test`.`t2` IGNORE INDEX (`col_datetime_key`) where (`test`.`t2`.`col_datetime_key` < cast(`test`.`t1`.`col_time_key` as datetime)) +SELECT * FROM +t1 force INDEX (col_time_key) +STRAIGHT_JOIN +t2 ignore INDEX (col_datetime_key) +WHERE col_datetime_key < col_time_key; +col_time_key col_datetime_key +-24:00:00 2012-01-29 00:00:00 +00:00:00 2012-01-29 00:00:00 +00:00:00 2012-01-30 00:00:00 +24:00:00 2012-01-29 00:00:00 +24:00:00 2012-01-30 00:00:00 +24:00:00 2012-01-31 00:00:00 +48:00:00 2012-01-29 00:00:00 +48:00:00 2012-01-30 00:00:00 +48:00:00 2012-01-31 00:00:00 +48:00:00 2012-02-01 00:00:00 +EXPLAIN SELECT * FROM +t1 force INDEX (col_time_key) +STRAIGHT_JOIN +t2 force INDEX (col_datetime_key) +WHERE col_time_key < col_datetime_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index col_time_key col_time_key 4 NULL 5 100.00 Using index +2 SIMPLE t2 NULL ALL col_datetime_key NULL NULL NULL 5 33.33 Range checked for each record (index map: 0x1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col_time_key` AS `col_time_key`,`test`.`t2`.`col_datetime_key` AS `col_datetime_key` from `test`.`t1` FORCE INDEX (`col_time_key`) straight_join `test`.`t2` FORCE INDEX (`col_datetime_key`) where (cast(`test`.`t1`.`col_time_key` as datetime) < `test`.`t2`.`col_datetime_key`) +SELECT * FROM +t1 force INDEX (col_time_key) +STRAIGHT_JOIN +t2 force INDEX (col_datetime_key) +WHERE col_time_key < col_datetime_key; +col_time_key col_datetime_key +-24:00:00 2012-01-31 00:00:00 +-24:00:00 2012-02-01 00:00:00 +-24:00:00 2012-02-02 00:00:00 +-48:00:00 2012-01-30 00:00:00 +-48:00:00 2012-01-31 00:00:00 +-48:00:00 2012-02-01 00:00:00 +-48:00:00 2012-02-02 00:00:00 +00:00:00 2012-02-01 00:00:00 +00:00:00 2012-02-02 00:00:00 +24:00:00 2012-02-02 00:00:00 +EXPLAIN SELECT * FROM +t1 force INDEX (col_time_key) +STRAIGHT_JOIN +t2 force INDEX (col_datetime_key) +WHERE col_datetime_key < col_time_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index col_time_key col_time_key 4 NULL 5 100.00 Using index +2 SIMPLE t2 NULL ALL col_datetime_key NULL NULL NULL 5 33.33 Range checked for each record (index map: 0x1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col_time_key` AS `col_time_key`,`test`.`t2`.`col_datetime_key` AS `col_datetime_key` from `test`.`t1` FORCE INDEX (`col_time_key`) straight_join `test`.`t2` FORCE INDEX (`col_datetime_key`) where (`test`.`t2`.`col_datetime_key` < cast(`test`.`t1`.`col_time_key` as datetime)) +SELECT * FROM +t1 force INDEX (col_time_key) +STRAIGHT_JOIN +t2 force INDEX (col_datetime_key) +WHERE col_datetime_key < col_time_key; +col_time_key col_datetime_key +-24:00:00 2012-01-29 00:00:00 +00:00:00 2012-01-29 00:00:00 +00:00:00 2012-01-30 00:00:00 +24:00:00 2012-01-29 00:00:00 +24:00:00 2012-01-30 00:00:00 +24:00:00 2012-01-31 00:00:00 +48:00:00 2012-01-29 00:00:00 +48:00:00 2012-01-30 00:00:00 +48:00:00 2012-01-31 00:00:00 +48:00:00 2012-02-01 00:00:00 +EXPLAIN SELECT * FROM +t2 ignore INDEX (col_datetime_key) +STRAIGHT_JOIN +t1 ignore INDEX (col_time_key) +WHERE col_time_key < col_datetime_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 33.33 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`col_datetime_key` AS `col_datetime_key`,`test`.`t1`.`col_time_key` AS `col_time_key` from `test`.`t2` IGNORE INDEX (`col_datetime_key`) straight_join `test`.`t1` IGNORE INDEX (`col_time_key`) where (cast(`test`.`t1`.`col_time_key` as datetime) < `test`.`t2`.`col_datetime_key`) +SELECT * FROM +t2 ignore INDEX (col_datetime_key) +STRAIGHT_JOIN +t1 ignore INDEX (col_time_key) +WHERE col_time_key < col_datetime_key; +col_datetime_key col_time_key +2012-01-30 00:00:00 -48:00:00 +2012-01-31 00:00:00 -24:00:00 +2012-01-31 00:00:00 -48:00:00 +2012-02-01 00:00:00 -24:00:00 +2012-02-01 00:00:00 -48:00:00 +2012-02-01 00:00:00 00:00:00 +2012-02-02 00:00:00 -24:00:00 +2012-02-02 00:00:00 -48:00:00 +2012-02-02 00:00:00 00:00:00 +2012-02-02 00:00:00 24:00:00 +EXPLAIN SELECT * FROM +t2 ignore INDEX (col_datetime_key) +STRAIGHT_JOIN +t1 ignore INDEX (col_time_key) +WHERE col_datetime_key < col_time_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 33.33 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`col_datetime_key` AS `col_datetime_key`,`test`.`t1`.`col_time_key` AS `col_time_key` from `test`.`t2` IGNORE INDEX (`col_datetime_key`) straight_join `test`.`t1` IGNORE INDEX (`col_time_key`) where (`test`.`t2`.`col_datetime_key` < cast(`test`.`t1`.`col_time_key` as datetime)) +SELECT * FROM +t2 ignore INDEX (col_datetime_key) +STRAIGHT_JOIN +t1 ignore INDEX (col_time_key) +WHERE col_datetime_key < col_time_key; +col_datetime_key col_time_key +2012-01-29 00:00:00 -24:00:00 +2012-01-29 00:00:00 00:00:00 +2012-01-29 00:00:00 24:00:00 +2012-01-29 00:00:00 48:00:00 +2012-01-30 00:00:00 00:00:00 +2012-01-30 00:00:00 24:00:00 +2012-01-30 00:00:00 48:00:00 +2012-01-31 00:00:00 24:00:00 +2012-01-31 00:00:00 48:00:00 +2012-02-01 00:00:00 48:00:00 +EXPLAIN SELECT * FROM +t2 ignore INDEX (col_datetime_key) +STRAIGHT_JOIN +t1 force INDEX (col_time_key) +WHERE col_time_key < col_datetime_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +2 SIMPLE t1 NULL index col_time_key col_time_key 4 NULL 5 33.33 Using where; Using index; Using join buffer (hash join) +Warnings: +Warning 1739 Cannot use range access on index 'col_time_key' due to type or collation conversion on field 'col_time_key' +Note 1003 /* select#1 */ select `test`.`t2`.`col_datetime_key` AS `col_datetime_key`,`test`.`t1`.`col_time_key` AS `col_time_key` from `test`.`t2` IGNORE INDEX (`col_datetime_key`) straight_join `test`.`t1` FORCE INDEX (`col_time_key`) where (cast(`test`.`t1`.`col_time_key` as datetime) < `test`.`t2`.`col_datetime_key`) +SELECT * FROM +t2 ignore INDEX (col_datetime_key) +STRAIGHT_JOIN +t1 force INDEX (col_time_key) +WHERE col_time_key < col_datetime_key; +col_datetime_key col_time_key +2012-01-30 00:00:00 -48:00:00 +2012-01-31 00:00:00 -24:00:00 +2012-01-31 00:00:00 -48:00:00 +2012-02-01 00:00:00 -24:00:00 +2012-02-01 00:00:00 -48:00:00 +2012-02-01 00:00:00 00:00:00 +2012-02-02 00:00:00 -24:00:00 +2012-02-02 00:00:00 -48:00:00 +2012-02-02 00:00:00 00:00:00 +2012-02-02 00:00:00 24:00:00 +EXPLAIN SELECT * FROM +t2 ignore INDEX (col_datetime_key) +STRAIGHT_JOIN +t1 force INDEX (col_time_key) +WHERE col_datetime_key < col_time_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +2 SIMPLE t1 NULL index col_time_key col_time_key 4 NULL 5 33.33 Using where; Using index; Using join buffer (hash join) +Warnings: +Warning 1739 Cannot use range access on index 'col_time_key' due to type or collation conversion on field 'col_time_key' +Note 1003 /* select#1 */ select `test`.`t2`.`col_datetime_key` AS `col_datetime_key`,`test`.`t1`.`col_time_key` AS `col_time_key` from `test`.`t2` IGNORE INDEX (`col_datetime_key`) straight_join `test`.`t1` FORCE INDEX (`col_time_key`) where (`test`.`t2`.`col_datetime_key` < cast(`test`.`t1`.`col_time_key` as datetime)) +SELECT * FROM +t2 ignore INDEX (col_datetime_key) +STRAIGHT_JOIN +t1 force INDEX (col_time_key) +WHERE col_datetime_key < col_time_key; +col_datetime_key col_time_key +2012-01-29 00:00:00 -24:00:00 +2012-01-29 00:00:00 00:00:00 +2012-01-29 00:00:00 24:00:00 +2012-01-29 00:00:00 48:00:00 +2012-01-30 00:00:00 00:00:00 +2012-01-30 00:00:00 24:00:00 +2012-01-30 00:00:00 48:00:00 +2012-01-31 00:00:00 24:00:00 +2012-01-31 00:00:00 48:00:00 +2012-02-01 00:00:00 48:00:00 +EXPLAIN SELECT * FROM +t2 force INDEX (col_datetime_key) +STRAIGHT_JOIN +t1 ignore INDEX (col_time_key) +WHERE col_time_key < col_datetime_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL index col_datetime_key col_datetime_key 6 NULL 5 100.00 Using index +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 33.33 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`col_datetime_key` AS `col_datetime_key`,`test`.`t1`.`col_time_key` AS `col_time_key` from `test`.`t2` FORCE INDEX (`col_datetime_key`) straight_join `test`.`t1` IGNORE INDEX (`col_time_key`) where (cast(`test`.`t1`.`col_time_key` as datetime) < `test`.`t2`.`col_datetime_key`) +SELECT * FROM +t2 force INDEX (col_datetime_key) +STRAIGHT_JOIN +t1 ignore INDEX (col_time_key) +WHERE col_time_key < col_datetime_key; +col_datetime_key col_time_key +2012-01-30 00:00:00 -48:00:00 +2012-01-31 00:00:00 -24:00:00 +2012-01-31 00:00:00 -48:00:00 +2012-02-01 00:00:00 -24:00:00 +2012-02-01 00:00:00 -48:00:00 +2012-02-01 00:00:00 00:00:00 +2012-02-02 00:00:00 -24:00:00 +2012-02-02 00:00:00 -48:00:00 +2012-02-02 00:00:00 00:00:00 +2012-02-02 00:00:00 24:00:00 +EXPLAIN SELECT * FROM +t2 force INDEX (col_datetime_key) +STRAIGHT_JOIN +t1 ignore INDEX (col_time_key) +WHERE col_datetime_key < col_time_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL index col_datetime_key col_datetime_key 6 NULL 5 100.00 Using index +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 33.33 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`col_datetime_key` AS `col_datetime_key`,`test`.`t1`.`col_time_key` AS `col_time_key` from `test`.`t2` FORCE INDEX (`col_datetime_key`) straight_join `test`.`t1` IGNORE INDEX (`col_time_key`) where (`test`.`t2`.`col_datetime_key` < cast(`test`.`t1`.`col_time_key` as datetime)) +SELECT * FROM +t2 force INDEX (col_datetime_key) +STRAIGHT_JOIN +t1 ignore INDEX (col_time_key) +WHERE col_datetime_key < col_time_key; +col_datetime_key col_time_key +2012-01-29 00:00:00 -24:00:00 +2012-01-29 00:00:00 00:00:00 +2012-01-29 00:00:00 24:00:00 +2012-01-29 00:00:00 48:00:00 +2012-01-30 00:00:00 00:00:00 +2012-01-30 00:00:00 24:00:00 +2012-01-30 00:00:00 48:00:00 +2012-01-31 00:00:00 24:00:00 +2012-01-31 00:00:00 48:00:00 +2012-02-01 00:00:00 48:00:00 +EXPLAIN SELECT * FROM +t2 force INDEX (col_datetime_key) +STRAIGHT_JOIN +t1 force INDEX (col_time_key) +WHERE col_time_key < col_datetime_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL index col_datetime_key col_datetime_key 6 NULL 5 100.00 Using index +2 SIMPLE t1 NULL index col_time_key col_time_key 4 NULL 5 33.33 Using where; Using index; Using join buffer (hash join) +Warnings: +Warning 1739 Cannot use range access on index 'col_time_key' due to type or collation conversion on field 'col_time_key' +Note 1003 /* select#1 */ select `test`.`t2`.`col_datetime_key` AS `col_datetime_key`,`test`.`t1`.`col_time_key` AS `col_time_key` from `test`.`t2` FORCE INDEX (`col_datetime_key`) straight_join `test`.`t1` FORCE INDEX (`col_time_key`) where (cast(`test`.`t1`.`col_time_key` as datetime) < `test`.`t2`.`col_datetime_key`) +SELECT * FROM +t2 force INDEX (col_datetime_key) +STRAIGHT_JOIN +t1 force INDEX (col_time_key) +WHERE col_time_key < col_datetime_key; +col_datetime_key col_time_key +2012-01-30 00:00:00 -48:00:00 +2012-01-31 00:00:00 -24:00:00 +2012-01-31 00:00:00 -48:00:00 +2012-02-01 00:00:00 -24:00:00 +2012-02-01 00:00:00 -48:00:00 +2012-02-01 00:00:00 00:00:00 +2012-02-02 00:00:00 -24:00:00 +2012-02-02 00:00:00 -48:00:00 +2012-02-02 00:00:00 00:00:00 +2012-02-02 00:00:00 24:00:00 +EXPLAIN SELECT * FROM +t2 force INDEX (col_datetime_key) +STRAIGHT_JOIN +t1 force INDEX (col_time_key) +WHERE col_datetime_key < col_time_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL index col_datetime_key col_datetime_key 6 NULL 5 100.00 Using index +2 SIMPLE t1 NULL index col_time_key col_time_key 4 NULL 5 33.33 Using where; Using index; Using join buffer (hash join) +Warnings: +Warning 1739 Cannot use range access on index 'col_time_key' due to type or collation conversion on field 'col_time_key' +Note 1003 /* select#1 */ select `test`.`t2`.`col_datetime_key` AS `col_datetime_key`,`test`.`t1`.`col_time_key` AS `col_time_key` from `test`.`t2` FORCE INDEX (`col_datetime_key`) straight_join `test`.`t1` FORCE INDEX (`col_time_key`) where (`test`.`t2`.`col_datetime_key` < cast(`test`.`t1`.`col_time_key` as datetime)) +SELECT * FROM +t2 force INDEX (col_datetime_key) +STRAIGHT_JOIN +t1 force INDEX (col_time_key) +WHERE col_datetime_key < col_time_key; +col_datetime_key col_time_key +2012-01-29 00:00:00 -24:00:00 +2012-01-29 00:00:00 00:00:00 +2012-01-29 00:00:00 24:00:00 +2012-01-29 00:00:00 48:00:00 +2012-01-30 00:00:00 00:00:00 +2012-01-30 00:00:00 24:00:00 +2012-01-30 00:00:00 48:00:00 +2012-01-31 00:00:00 24:00:00 +2012-01-31 00:00:00 48:00:00 +2012-02-01 00:00:00 48:00:00 +DROP TABLE t1,t2; + +# Original test of the bug report + +CREATE TABLE t1 ( +pk INT NOT NULL AUTO_INCREMENT, +col_int_nokey INT, +col_int_key INT NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +) ENGINE=InnoDB; +INSERT INTO t1 VALUES (10,1,7), (11,7,0), (12,4,9), (13,7,3), +(14,0,4), (15,2,2), (16,9,5), (17,4,3), (18,0,1), (19,9,3), (20,1,6), +(21,3,7), (22,8,5), (23,8,1), (24,18,204), (25,84,224), (26,6,9), +(27,3,5), (28,6,0), (29,6,3); +CREATE TABLE t2 ( +col_int_nokey INT NOT NULL, +col_datetime_key DATETIME NOT NULL, +col_varchar_key VARCHAR(1) NOT NULL, +KEY col_datetime_key (col_datetime_key), +KEY col_varchar_key (col_varchar_key) +) ENGINE=InnoDB; +INSERT INTO t2 VALUES (1,'2001-11-04 19:07:55','k'); +CREATE TABLE t3 ( +col_time_key TIME, +KEY col_time_key (col_time_key) +) ENGINE=InnoDB; +INSERT INTO t3 VALUES ('21:22:34'), ('10:50:38'), ('00:21:38'), +('04:08:02'), ('16:25:11'), ('10:14:58'), ('19:47:59'), ('11:14:24'), +('00:00:00'), ('00:00:00'), ('15:57:25'), ('07:05:51'), ('19:22:21'), +('03:53:16'), ('09:16:38'), ('15:37:26'), ('00:00:00'), ('05:03:03'), +('02:59:24'), ('00:01:58'); +ANALYZE TABLE t1; +ANALYZE TABLE t2; +ANALYZE TABLE t3; +EXPLAIN SELECT * FROM t2 STRAIGHT_JOIN t3 FORCE INDEX (col_time_key) +ON t3.col_time_key > t2.col_datetime_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ALL col_datetime_key NULL NULL NULL 1 100.00 NULL +2 SIMPLE t3 NULL index col_time_key col_time_key 4 NULL 20 33.33 Using where; Using index; Using join buffer (hash join) +Warnings: +Warning 1739 Cannot use range access on index 'col_time_key' due to type or collation conversion on field 'col_time_key' +Note 1003 /* select#1 */ select `test`.`t2`.`col_int_nokey` AS `col_int_nokey`,`test`.`t2`.`col_datetime_key` AS `col_datetime_key`,`test`.`t2`.`col_varchar_key` AS `col_varchar_key`,`test`.`t3`.`col_time_key` AS `col_time_key` from `test`.`t2` straight_join `test`.`t3` FORCE INDEX (`col_time_key`) where (cast(`test`.`t3`.`col_time_key` as datetime) > `test`.`t2`.`col_datetime_key`) +SELECT * FROM t2 STRAIGHT_JOIN t3 FORCE INDEX (col_time_key) +ON t3.col_time_key > t2.col_datetime_key; +col_int_nokey col_datetime_key col_varchar_key col_time_key +1 2001-11-04 19:07:55 k 00:00:00 +1 2001-11-04 19:07:55 k 00:00:00 +1 2001-11-04 19:07:55 k 00:00:00 +1 2001-11-04 19:07:55 k 00:01:58 +1 2001-11-04 19:07:55 k 00:21:38 +1 2001-11-04 19:07:55 k 02:59:24 +1 2001-11-04 19:07:55 k 03:53:16 +1 2001-11-04 19:07:55 k 04:08:02 +1 2001-11-04 19:07:55 k 05:03:03 +1 2001-11-04 19:07:55 k 07:05:51 +1 2001-11-04 19:07:55 k 09:16:38 +1 2001-11-04 19:07:55 k 10:14:58 +1 2001-11-04 19:07:55 k 10:50:38 +1 2001-11-04 19:07:55 k 11:14:24 +1 2001-11-04 19:07:55 k 15:37:26 +1 2001-11-04 19:07:55 k 15:57:25 +1 2001-11-04 19:07:55 k 16:25:11 +1 2001-11-04 19:07:55 k 19:22:21 +1 2001-11-04 19:07:55 k 19:47:59 +1 2001-11-04 19:07:55 k 21:22:34 +EXPLAIN SELECT * FROM t2 STRAIGHT_JOIN t3 IGNORE INDEX (col_time_key) +ON t3.col_time_key > t2.col_datetime_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ALL col_datetime_key NULL NULL NULL 1 100.00 NULL +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 20 33.33 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`col_int_nokey` AS `col_int_nokey`,`test`.`t2`.`col_datetime_key` AS `col_datetime_key`,`test`.`t2`.`col_varchar_key` AS `col_varchar_key`,`test`.`t3`.`col_time_key` AS `col_time_key` from `test`.`t2` straight_join `test`.`t3` IGNORE INDEX (`col_time_key`) where (cast(`test`.`t3`.`col_time_key` as datetime) > `test`.`t2`.`col_datetime_key`) +SELECT * FROM t2 STRAIGHT_JOIN t3 IGNORE INDEX (col_time_key) +ON t3.col_time_key > t2.col_datetime_key; +col_int_nokey col_datetime_key col_varchar_key col_time_key +1 2001-11-04 19:07:55 k 00:00:00 +1 2001-11-04 19:07:55 k 00:00:00 +1 2001-11-04 19:07:55 k 00:00:00 +1 2001-11-04 19:07:55 k 00:01:58 +1 2001-11-04 19:07:55 k 00:21:38 +1 2001-11-04 19:07:55 k 02:59:24 +1 2001-11-04 19:07:55 k 03:53:16 +1 2001-11-04 19:07:55 k 04:08:02 +1 2001-11-04 19:07:55 k 05:03:03 +1 2001-11-04 19:07:55 k 07:05:51 +1 2001-11-04 19:07:55 k 09:16:38 +1 2001-11-04 19:07:55 k 10:14:58 +1 2001-11-04 19:07:55 k 10:50:38 +1 2001-11-04 19:07:55 k 11:14:24 +1 2001-11-04 19:07:55 k 15:37:26 +1 2001-11-04 19:07:55 k 15:57:25 +1 2001-11-04 19:07:55 k 16:25:11 +1 2001-11-04 19:07:55 k 19:22:21 +1 2001-11-04 19:07:55 k 19:47:59 +1 2001-11-04 19:07:55 k 21:22:34 +DROP TABLE t1,t2,t3; +SET TIMESTAMP = DEFAULT; +SET sql_mode = default; +# +# End of 5.6 tests +# diff --git a/mysql-test/r/type_timestamp.result-pq b/mysql-test/r/type_timestamp.result-pq new file mode 100644 index 000000000000..2570419046c1 --- /dev/null +++ b/mysql-test/r/type_timestamp.result-pq @@ -0,0 +1,686 @@ +drop table if exists t1,t2; +SET sql_mode = 'NO_ENGINE_SUBSTITUTION'; +set time_zone="+03:00"; +CREATE TABLE t1 (a int, t timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP); +CREATE TABLE t2 (a int, t datetime); +SET TIMESTAMP=1234; +insert into t1 values(1,NULL); +insert into t1 values(2,"2002-03-03"); +SET TIMESTAMP=1235; +insert into t1 values(3,NULL); +SET TIMESTAMP=1236; +insert into t1 (a) values(4); +insert into t2 values(5,"2002-03-04"),(6,NULL),(7,"2002-03-05"),(8,"00-00-00"); +SET TIMESTAMP=1237; +insert into t1 select * from t2; +SET TIMESTAMP=1238; +insert into t1 (a) select a+1 from t2 where a=8; +select * from t1; +a t +1 1970-01-01 03:20:34 +2 2002-03-03 00:00:00 +3 1970-01-01 03:20:35 +4 1970-01-01 03:20:36 +5 2002-03-04 00:00:00 +6 1970-01-01 03:20:37 +7 2002-03-05 00:00:00 +8 0000-00-00 00:00:00 +9 1970-01-01 03:20:38 +drop table t1,t2; +SET TIMESTAMP=1234; +CREATE TABLE t1 (value TEXT NOT NULL, id VARCHAR(32) NOT NULL, stamp timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (id)); +INSERT INTO t1 VALUES ("my value", "myKey","1999-04-02 00:00:00"); +SELECT stamp FROM t1 WHERE id="myKey"; +stamp +1999-04-02 00:00:00 +UPDATE t1 SET value="my value" WHERE id="myKey"; +SELECT stamp FROM t1 WHERE id="myKey"; +stamp +1999-04-02 00:00:00 +UPDATE t1 SET id="myKey" WHERE value="my value"; +SELECT stamp FROM t1 WHERE id="myKey"; +stamp +1999-04-02 00:00:00 +drop table t1; +create table t1 (a timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP); +insert into t1 values (now()); +select date_format(a,"%Y %y"),year(a),year(now()) from t1; +date_format(a,"%Y %y") year(a) year(now()) +1970 70 1970 1970 +drop table t1; +create table t1 (ix timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP); +insert into t1 values (19991101000000),(19990102030405),(19990630232922),(19990601000000),(19990930232922),(19990531232922),(19990501000000),(19991101000000),(19990501000000); +select ix+0 from t1; +ix+0 +19991101000000 +19990102030405 +19990630232922 +19990601000000 +19990930232922 +19990531232922 +19990501000000 +19991101000000 +19990501000000 +truncate table t1; +insert into t1 values ("19991101000000"),("19990102030405"),("19990630232922"),("19990601000000"); +select ix+0 from t1; +ix+0 +19991101000000 +19990102030405 +19990630232922 +19990601000000 +drop table t1; +CREATE TABLE t1 (date date, date_time datetime, time_stamp timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP); +INSERT INTO t1 VALUES ("1998-12-31","1998-12-31 23:59:59",19981231235959); +INSERT INTO t1 VALUES ("1999-01-01","1999-01-01 00:00:00",19990101000000); +INSERT INTO t1 VALUES ("1999-09-09","1999-09-09 23:59:59",19990909235959); +INSERT INTO t1 VALUES ("2000-01-01","2000-01-01 00:00:00",20000101000000); +INSERT INTO t1 VALUES ("2000-02-28","2000-02-28 00:00:00",20000228000000); +INSERT INTO t1 VALUES ("2000-02-29","2000-02-29 00:00:00",20000229000000); +INSERT INTO t1 VALUES ("2000-03-01","2000-03-01 00:00:00",20000301000000); +INSERT INTO t1 VALUES ("2000-12-31","2000-12-31 23:59:59",20001231235959); +INSERT INTO t1 VALUES ("2001-01-01","2001-01-01 00:00:00",20010101000000); +INSERT INTO t1 VALUES ("2004-12-31","2004-12-31 23:59:59",20041231235959); +INSERT INTO t1 VALUES ("2005-01-01","2005-01-01 00:00:00",20050101000000); +INSERT INTO t1 VALUES ("2030-01-01","2030-01-01 00:00:00",20300101000000); +SELECT * FROM t1; +date date_time time_stamp +1998-12-31 1998-12-31 23:59:59 1998-12-31 23:59:59 +1999-01-01 1999-01-01 00:00:00 1999-01-01 00:00:00 +1999-09-09 1999-09-09 23:59:59 1999-09-09 23:59:59 +2000-01-01 2000-01-01 00:00:00 2000-01-01 00:00:00 +2000-02-28 2000-02-28 00:00:00 2000-02-28 00:00:00 +2000-02-29 2000-02-29 00:00:00 2000-02-29 00:00:00 +2000-03-01 2000-03-01 00:00:00 2000-03-01 00:00:00 +2000-12-31 2000-12-31 23:59:59 2000-12-31 23:59:59 +2001-01-01 2001-01-01 00:00:00 2001-01-01 00:00:00 +2004-12-31 2004-12-31 23:59:59 2004-12-31 23:59:59 +2005-01-01 2005-01-01 00:00:00 2005-01-01 00:00:00 +2030-01-01 2030-01-01 00:00:00 2030-01-01 00:00:00 +drop table t1; +create table t1 (ix timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP); +insert into t1 values (0),(20030101010160),(20030101016001),(20030101240101),(20030132010101),(20031301010101),(20031200000000),(20030000000000); +Warnings: +Warning 1265 Data truncated for column 'ix' at row 2 +Warning 1265 Data truncated for column 'ix' at row 3 +Warning 1265 Data truncated for column 'ix' at row 4 +Warning 1265 Data truncated for column 'ix' at row 5 +Warning 1265 Data truncated for column 'ix' at row 6 +Warning 1265 Data truncated for column 'ix' at row 7 +Warning 1265 Data truncated for column 'ix' at row 8 +select ix+0 from t1; +ix+0 +0 +0 +0 +0 +0 +0 +0 +0 +truncate table t1; +insert into t1 values ("00000000000000"),("20030101010160"),("20030101016001"),("20030101240101"),("20030132010101"),("20031301010101"),("20031200000000"),("20030000000000"); +Warnings: +Warning 1265 Data truncated for column 'ix' at row 2 +Warning 1265 Data truncated for column 'ix' at row 3 +Warning 1265 Data truncated for column 'ix' at row 4 +Warning 1265 Data truncated for column 'ix' at row 5 +Warning 1265 Data truncated for column 'ix' at row 6 +Warning 1264 Out of range value for column 'ix' at row 7 +Warning 1264 Out of range value for column 'ix' at row 8 +select ix+0 from t1; +ix+0 +0 +0 +0 +0 +0 +0 +0 +0 +truncate table t1; +insert into t1 values ("0000-00-00 00:00:00 some trailer"),("2003-01-01 00:00:00 some trailer"); +Warnings: +Warning 1265 Data truncated for column 'ix' at row 1 +Warning 1265 Data truncated for column 'ix' at row 2 +select ix+0 from t1; +ix+0 +0 +20030101000000 +drop table t1; +create table t1 (t1 timestamp not null default '2003-01-01 00:00:00', t2 datetime, t3 timestamp NOT NULL DEFAULT '0000-00-00 00:00:00'); +SET TIMESTAMP=1000000000; +insert into t1 values (); +SET TIMESTAMP=1000000001; +update t1 set t2=now(); +SET TIMESTAMP=1000000002; +insert into t1 (t1,t3) values (default, default); +select * from t1; +t1 t2 t3 +2003-01-01 00:00:00 2001-09-09 04:46:41 0000-00-00 00:00:00 +2003-01-01 00:00:00 NULL 0000-00-00 00:00:00 +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `t1` timestamp NOT NULL DEFAULT '2003-01-01 00:00:00', + `t2` datetime DEFAULT NULL, + `t3` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +show columns from t1; +Field Type Null Key Default Extra +t1 timestamp NO 2003-01-01 00:00:00 +t2 datetime YES NULL +t3 timestamp NO 0000-00-00 00:00:00 +drop table t1; +create table t1 (t1 timestamp not null default now(), t2 datetime, t3 timestamp NOT NULL DEFAULT '0000-00-00 00:00:00'); +SET TIMESTAMP=1000000002; +insert into t1 values (); +SET TIMESTAMP=1000000003; +update t1 set t2=now(); +SET TIMESTAMP=1000000003; +insert into t1 (t1,t3) values (default, default); +select * from t1; +t1 t2 t3 +2001-09-09 04:46:42 2001-09-09 04:46:43 0000-00-00 00:00:00 +2001-09-09 04:46:43 NULL 0000-00-00 00:00:00 +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `t1` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `t2` datetime DEFAULT NULL, + `t3` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +show columns from t1; +Field Type Null Key Default Extra +t1 timestamp NO CURRENT_TIMESTAMP DEFAULT_GENERATED +t2 datetime YES NULL +t3 timestamp NO 0000-00-00 00:00:00 +drop table t1; +create table t1 (t1 timestamp not null default '2003-01-01 00:00:00' on update now(), t2 datetime); +SET TIMESTAMP=1000000004; +insert into t1 values (); +select * from t1; +t1 t2 +2003-01-01 00:00:00 NULL +SET TIMESTAMP=1000000005; +update t1 set t2=now(); +SET TIMESTAMP=1000000005; +insert into t1 (t1) values (default); +select * from t1; +t1 t2 +2001-09-09 04:46:45 2001-09-09 04:46:45 +2003-01-01 00:00:00 NULL +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `t1` timestamp NOT NULL DEFAULT '2003-01-01 00:00:00' ON UPDATE CURRENT_TIMESTAMP, + `t2` datetime DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +show columns from t1; +Field Type Null Key Default Extra +t1 timestamp NO 2003-01-01 00:00:00 on update CURRENT_TIMESTAMP +t2 datetime YES NULL +drop table t1; +create table t1 (t1 timestamp not null default now() on update now(), t2 datetime); +SET TIMESTAMP=1000000006; +insert into t1 values (); +select * from t1; +t1 t2 +2001-09-09 04:46:46 NULL +SET TIMESTAMP=1000000007; +update t1 set t2=now(); +SET TIMESTAMP=1000000007; +insert into t1 (t1) values (default); +select * from t1; +t1 t2 +2001-09-09 04:46:47 2001-09-09 04:46:47 +2001-09-09 04:46:47 NULL +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `t1` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + `t2` datetime DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +show columns from t1; +Field Type Null Key Default Extra +t1 timestamp NO CURRENT_TIMESTAMP DEFAULT_GENERATED on update CURRENT_TIMESTAMP +t2 datetime YES NULL +drop table t1; +create table t1 (t1 timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, t2 datetime, t3 timestamp NOT NULL DEFAULT '0000-00-00 00:00:00'); +SET TIMESTAMP=1000000007; +insert into t1 values (); +select * from t1; +t1 t2 t3 +2001-09-09 04:46:47 NULL 0000-00-00 00:00:00 +SET TIMESTAMP=1000000008; +update t1 set t2=now(); +SET TIMESTAMP=1000000008; +insert into t1 (t1,t3) values (default, default); +select * from t1; +t1 t2 t3 +2001-09-09 04:46:48 2001-09-09 04:46:48 0000-00-00 00:00:00 +2001-09-09 04:46:48 NULL 0000-00-00 00:00:00 +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `t1` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + `t2` datetime DEFAULT NULL, + `t3` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +show columns from t1; +Field Type Null Key Default Extra +t1 timestamp NO CURRENT_TIMESTAMP DEFAULT_GENERATED on update CURRENT_TIMESTAMP +t2 datetime YES NULL +t3 timestamp NO 0000-00-00 00:00:00 +drop table t1; +create table t1 (t1 timestamp not null default current_timestamp on update current_timestamp, t2 datetime); +SET TIMESTAMP=1000000009; +insert into t1 values (); +select * from t1; +t1 t2 +2001-09-09 04:46:49 NULL +SET TIMESTAMP=1000000010; +update t1 set t2=now(); +SET TIMESTAMP=1000000011; +insert into t1 (t1) values (default); +select * from t1; +t1 t2 +2001-09-09 04:46:50 2001-09-09 04:46:50 +2001-09-09 04:46:51 NULL +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `t1` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + `t2` datetime DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +show columns from t1; +Field Type Null Key Default Extra +t1 timestamp NO CURRENT_TIMESTAMP DEFAULT_GENERATED on update CURRENT_TIMESTAMP +t2 datetime YES NULL +truncate table t1; +insert into t1 values ('2004-04-01 00:00:00', '2004-04-01 00:00:00'); +SET TIMESTAMP=1000000012; +update t1 set t1= '2004-04-02 00:00:00'; +select * from t1; +t1 t2 +2004-04-02 00:00:00 2004-04-01 00:00:00 +update t1 as ta, t1 as tb set tb.t1= '2004-04-03 00:00:00'; +select * from t1; +t1 t2 +2004-04-03 00:00:00 2004-04-01 00:00:00 +drop table t1; +create table t1 (pk int primary key, t1 timestamp not null default current_timestamp on update current_timestamp, bulk int); +insert into t1 values (1, '2004-04-01 00:00:00', 10); +SET TIMESTAMP=1000000013; +replace into t1 set pk = 1, bulk= 20; +select * from t1; +pk t1 bulk +1 2001-09-09 04:46:53 20 +drop table t1; +create table t1 (pk int primary key, t1 timestamp not null default '2003-01-01 00:00:00' on update current_timestamp, bulk int); +insert into t1 values (1, '2004-04-01 00:00:00', 10); +SET TIMESTAMP=1000000014; +replace into t1 set pk = 1, bulk= 20; +select * from t1; +pk t1 bulk +1 2003-01-01 00:00:00 20 +drop table t1; +create table t1 (pk int primary key, t1 timestamp not null default current_timestamp on update current_timestamp, bulk int); +insert into t1 values (1, '2004-04-01 00:00:00', 10); +SET TIMESTAMP=1000000015; +replace into t1 set pk = 1, bulk= 20; +select * from t1; +pk t1 bulk +1 2001-09-09 04:46:55 20 +drop table t1; +create table t1 (t1 timestamp not null default current_timestamp on update current_timestamp); +insert into t1 values ('2004-04-01 00:00:00'); +SET TIMESTAMP=1000000016; +alter table t1 add i int default 10; +select * from t1; +t1 i +2004-04-01 00:00:00 10 +drop table t1; +create table t1 (a timestamp null, b timestamp null); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` timestamp NULL DEFAULT NULL, + `b` timestamp NULL DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +insert into t1 values (NULL, NULL); +SET TIMESTAMP=1000000017; +insert into t1 values (); +select * from t1; +a b +NULL NULL +NULL NULL +drop table t1; +create table t1 (a timestamp null default current_timestamp on update current_timestamp, b timestamp null); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + `b` timestamp NULL DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +insert into t1 values (NULL, NULL); +SET TIMESTAMP=1000000018; +insert into t1 values (); +select * from t1; +a b +NULL NULL +2001-09-09 04:46:58 NULL +drop table t1; +create table t1 (a timestamp null default null, b timestamp null default '2003-01-01 00:00:00'); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` timestamp NULL DEFAULT NULL, + `b` timestamp NULL DEFAULT '2003-01-01 00:00:00' +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +insert into t1 values (NULL, NULL); +insert into t1 values (DEFAULT, DEFAULT); +select * from t1; +a b +NULL NULL +NULL 2003-01-01 00:00:00 +drop table t1; +create table t1 (a bigint, b bigint); +insert into t1 values (NULL, NULL), (20030101000000, 20030102000000); +set timestamp=1000000019; +alter table t1 modify a timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, modify b timestamp NOT NULL DEFAULT '0000-00-00 00:00:0'; +select * from t1; +a b +2001-09-09 04:46:59 2001-09-09 04:46:59 +2003-01-01 00:00:00 2003-01-02 00:00:00 +drop table t1; +create table t1 (a char(2), t timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP); +insert into t1 values ('a', '2004-01-01 00:00:00'), ('a', '2004-01-01 01:00:00'), +('b', '2004-02-01 00:00:00'); +select max(t) from t1 group by a; +max(t) +2004-01-01 01:00:00 +2004-02-01 00:00:00 +drop table t1; +create table t1 (a int auto_increment primary key, b int, c timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP); +insert into t1 (a, b, c) values (1, 0, '2001-01-01 01:01:01'), +(2, 0, '2002-02-02 02:02:02'), (3, 0, '2003-03-03 03:03:03'); +select * from t1; +a b c +1 0 2001-01-01 01:01:01 +2 0 2002-02-02 02:02:02 +3 0 2003-03-03 03:03:03 +update t1 set b = 2, c = c where a = 2; +select * from t1; +a b c +1 0 2001-01-01 01:01:01 +2 2 2002-02-02 02:02:02 +3 0 2003-03-03 03:03:03 +insert into t1 (a) values (4); +select * from t1; +a b c +1 0 2001-01-01 01:01:01 +2 2 2002-02-02 02:02:02 +3 0 2003-03-03 03:03:03 +4 NULL 2001-09-09 04:46:59 +update t1 set c = '2004-04-04 04:04:04' where a = 4; +select * from t1; +a b c +1 0 2001-01-01 01:01:01 +2 2 2002-02-02 02:02:02 +3 0 2003-03-03 03:03:03 +4 NULL 2004-04-04 04:04:04 +insert into t1 (a) values (3), (5) on duplicate key update b = 3, c = c; +select * from t1; +a b c +1 0 2001-01-01 01:01:01 +2 2 2002-02-02 02:02:02 +3 3 2003-03-03 03:03:03 +4 NULL 2004-04-04 04:04:04 +5 NULL 2001-09-09 04:46:59 +insert into t1 (a, c) values (4, '2004-04-04 00:00:00'), +(6, '2006-06-06 06:06:06') on duplicate key update b = 4; +select * from t1; +a b c +1 0 2001-01-01 01:01:01 +2 2 2002-02-02 02:02:02 +3 3 2003-03-03 03:03:03 +4 4 2001-09-09 04:46:59 +5 NULL 2001-09-09 04:46:59 +6 NULL 2006-06-06 06:06:06 +drop table t1; +End of 4.1 tests +set time_zone= @@global.time_zone; +CREATE TABLE t1 ( f1 INT(11) NOT NULL AUTO_INCREMENT PRIMARY KEY, +f2 TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, +f3 TIMESTAMP NOT NULL default '0000-00-00 00:00:00'); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 (f2,f3) VALUES (NOW(), "0000-00-00 00:00:00"); +INSERT INTO t1 (f2,f3) VALUES (NOW(), NULL); +INSERT INTO t1 (f2,f3) VALUES (NOW(), ASCII(NULL)); +INSERT INTO t1 (f2,f3) VALUES (NOW(), FROM_UNIXTIME('9999999999')); +INSERT INTO t1 (f2,f3) VALUES (NOW(), TIME(NULL)); +UPDATE t1 SET f2=NOW(), f3=FROM_UNIXTIME('9999999999') WHERE f1=1; +SELECT f1,f2-f3 FROM t1; +f1 f2-f3 +1 0 +2 0 +3 0 +4 0 +5 0 +DROP TABLE t1; +End of 5.0 tests +# +# Bug #55779: select does not work properly in mysql server +# Version "5.1.42 SUSE MySQL RPM" +# +CREATE TABLE t1 (a TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, KEY (a)); +INSERT INTO t1 VALUES ('2000-01-01 00:00:00'), ('2000-01-01 00:00:00'), +('2000-01-01 00:00:01'), ('2000-01-01 00:00:01'); +SELECT a FROM t1 WHERE a >= 20000101000000; +a +2000-01-01 00:00:00 +2000-01-01 00:00:00 +2000-01-01 00:00:01 +2000-01-01 00:00:01 +SELECT a FROM t1 WHERE a >= '20000101000000'; +a +2000-01-01 00:00:00 +2000-01-01 00:00:00 +2000-01-01 00:00:01 +2000-01-01 00:00:01 +DROP TABLE t1; +# +# Bug#50774: failed to get the correct resultset when timestamp values +# are appended with .0 +# +CREATE TABLE t1 ( a TIMESTAMP, KEY ( a ) ); +INSERT INTO t1 VALUES( '2010-02-01 09:31:01' ); +INSERT INTO t1 VALUES( '2010-02-01 09:31:02' ); +INSERT INTO t1 VALUES( '2010-02-01 09:31:03' ); +INSERT INTO t1 VALUES( '2010-02-01 09:31:04' ); +SELECT * FROM t1 WHERE a >= '2010-02-01 09:31:02.0'; +a +2010-02-01 09:31:02 +2010-02-01 09:31:03 +2010-02-01 09:31:04 +SELECT * FROM t1 WHERE '2010-02-01 09:31:02.0' <= a; +a +2010-02-01 09:31:02 +2010-02-01 09:31:03 +2010-02-01 09:31:04 +SELECT * FROM t1 WHERE a <= '2010-02-01 09:31:02.0'; +a +2010-02-01 09:31:01 +2010-02-01 09:31:02 +SELECT * FROM t1 WHERE '2010-02-01 09:31:02.0' >= a; +a +2010-02-01 09:31:01 +2010-02-01 09:31:02 +SELECT * FROM t1 WHERE a >= '2010-02-01 09:31:02.0'; +a +2010-02-01 09:31:02 +2010-02-01 09:31:03 +2010-02-01 09:31:04 +CREATE TABLE t2 ( a TIMESTAMP, KEY ( a ) ); +INSERT INTO t2 VALUES( '2010-02-01 09:31:01' ); +INSERT INTO t2 VALUES( '2010-02-01 09:31:02' ); +INSERT INTO t2 VALUES( '2010-02-01 09:31:03' ); +INSERT INTO t2 VALUES( '2010-02-01 09:31:04' ); +INSERT INTO t2 VALUES( '2010-02-01 09:31:05' ); +INSERT INTO t2 VALUES( '2010-02-01 09:31:06' ); +INSERT INTO t2 VALUES( '2010-02-01 09:31:07' ); +INSERT INTO t2 VALUES( '2010-02-01 09:31:08' ); +INSERT INTO t2 VALUES( '2010-02-01 09:31:09' ); +INSERT INTO t2 VALUES( '2010-02-01 09:31:10' ); +INSERT INTO t2 VALUES( '2010-02-01 09:31:11' ); +# The bug would cause the range optimizer's comparison to use an open +# interval here. This reveals itself only in the number of reads +# performed. +FLUSH STATUS; +SELECT * FROM t2 WHERE a < '2010-02-01 09:31:02.0'; +a +2010-02-01 09:31:01 +SHOW STATUS LIKE 'Handler_read_next'; +Variable_name Value +Handler_read_next 0 +DROP TABLE t1, t2; +End of 5.1 tests + +Bug#50888 valgrind warnings in Field_timestamp::val_str + +SET TIMESTAMP=0; +CREATE TABLE t1(a timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP); +INSERT INTO t1 VALUES ('2008-02-23 09:23:45'), ('2010-03-05 11:08:02'); +FLUSH TABLES t1; +SELECT MAX(a) FROM t1; +MAX(a) +2010-03-05 11:08:02 +SELECT a FROM t1; +a +2008-02-23 09:23:45 +2010-03-05 11:08:02 +DROP TABLE t1; +End of Bug#50888 +# +# Bug59330: Incorrect result when comparing an aggregate +# function with TIMESTAMP +# +CREATE TABLE t1 (dt DATETIME, ts TIMESTAMP); +INSERT INTO t1 VALUES('2011-01-06 12:34:30', '2011-01-06 12:34:30'); +SELECT MAX(dt), MAX(ts) FROM t1; +MAX(dt) MAX(ts) +2011-01-06 12:34:30 2011-01-06 12:34:30 +SELECT MAX(ts) < '2010-01-01 00:00:00' FROM t1; +MAX(ts) < '2010-01-01 00:00:00' +0 +SELECT MAX(dt) < '2010-01-01 00:00:00' FROM t1; +MAX(dt) < '2010-01-01 00:00:00' +0 +SELECT MAX(ts) > '2010-01-01 00:00:00' FROM t1; +MAX(ts) > '2010-01-01 00:00:00' +1 +SELECT MAX(dt) > '2010-01-01 00:00:00' FROM t1; +MAX(dt) > '2010-01-01 00:00:00' +1 +SELECT MAX(ts) = '2011-01-06 12:34:30' FROM t1; +MAX(ts) = '2011-01-06 12:34:30' +1 +SELECT MAX(dt) = '2011-01-06 12:34:30' FROM t1; +MAX(dt) = '2011-01-06 12:34:30' +1 +DROP TABLE t1; +End of 5.5 tests +# +# Start of 5.6 tests +# +# +# Bug#13596893 - "ERROR 1690 (22003): BIGINT UNSIGNED VALUE IS OUT OF RANGE" ON DATE OPERATION +# +CREATE TABLE t1 ( +`c1` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, +`c2` TIMESTAMP NOT NULL DEFAULT '0000-00-00 00:00:00' +); +INSERT INTO t1 VALUES ('2003-05-16 23:53:29','2000-01-27 23:13:41'); +SELECT c2-c1 FROM t1; +c2-c1 +-30389003988 +SELECT * FROM t1; +c1 c2 +2003-05-16 23:53:29 2000-01-27 23:13:41 +SELECT TIMESTAMP'2000-01-27 23:13:41' - TIMESTAMP'2003-05-16 23:53:29'; +TIMESTAMP'2000-01-27 23:13:41' - TIMESTAMP'2003-05-16 23:53:29' +-30389003988 +SELECT TIMESTAMP('2000-01-27','23:13:41') - TIMESTAMP('2003-05-16','23:53:29'); +TIMESTAMP('2000-01-27','23:13:41') - TIMESTAMP('2003-05-16','23:53:29') +-30389003988 +DROP TABLE t1; +SET sql_mode = default; +# +# Test for bug#11747847 - 34280: create table fails if NO_ZERO_DATE +# or NO_ZERO_IN_DATE SQL mode is set. +DROP TABLE IF EXISTS t1, t2, t3; +SET @org_mode=@@sql_mode; +#Table creation in strict mode +SET @@sql_mode='NO_ZERO_DATE,STRICT_ALL_TABLES'; +Warnings: +Warning 3135 'NO_ZERO_DATE', 'NO_ZERO_IN_DATE' and 'ERROR_FOR_DIVISION_BY_ZERO' sql modes should be used with strict mode. They will be merged with strict mode in a future release. +CREATE TABLE t1 (c1 TIMESTAMP DEFAULT 0); +ERROR 42000: Invalid default value for 'c1' +CREATE TABLE t1 (c1 TIMESTAMP DEFAULT '0000-00-00 00:00:00'); +ERROR 42000: Invalid default value for 'c1' +CREATE TABLE t1 (c1 TIMESTAMP DEFAULT '2012-02-00 12:12:12'); +ERROR 42000: Invalid default value for 'c1' +#Table creation in non-strict mode but with NO_ZERO_DATE/NO_ZERO_IN_DATE +SET @@sql_mode='NO_ZERO_DATE'; +Warnings: +Warning 3135 'NO_ZERO_DATE', 'NO_ZERO_IN_DATE' and 'ERROR_FOR_DIVISION_BY_ZERO' sql modes should be used with strict mode. They will be merged with strict mode in a future release. +CREATE TABLE t1 (c1 TIMESTAMP DEFAULT 0); +Warnings: +Warning 1264 Out of range value for column 'c1' at row 1 +CREATE TABLE t2 (c1 TIMESTAMP DEFAULT '0000-00-00 00:00:00'); +Warnings: +Warning 1264 Out of range value for column 'c1' at row 1 +SET @@sql_mode='NO_ZERO_IN_DATE'; +Warnings: +Warning 3135 'NO_ZERO_DATE', 'NO_ZERO_IN_DATE' and 'ERROR_FOR_DIVISION_BY_ZERO' sql modes should be used with strict mode. They will be merged with strict mode in a future release. +CREATE TABLE t3 (c1 TIMESTAMP DEFAULT '2012-02-00 12:12:12'); +Warnings: +Warning 1264 Out of range value for column 'c1' at row 1 +DROP TABLE t1, t2, t3; +#Table creation with out any SQL modes +SET @@sql_mode=''; +CREATE TABLE t1 (c1 TIMESTAMP DEFAULT 0); +CREATE TABLE t2 (c1 TIMESTAMP DEFAULT '0000-00-00 00:00:00'); +CREATE TABLE t3 (c1 TIMESTAMP DEFAULT '2012-02-00 12:12:12'); +Warnings: +Warning 1264 Out of range value for column 'c1' at row 1 +DROP TABLE t1, t2, t3; +CREATE TABLE t1 (c1 INT); +#Alter table in strict mode with NO_ZERO_DATE/NO_ZERO_IN_DATE +SET @@sql_mode='NO_ZERO_DATE,STRICT_ALL_TABLES'; +Warnings: +Warning 3135 'NO_ZERO_DATE', 'NO_ZERO_IN_DATE' and 'ERROR_FOR_DIVISION_BY_ZERO' sql modes should be used with strict mode. They will be merged with strict mode in a future release. +ALTER TABLE t1 ADD c2 TIMESTAMP DEFAULT 0; +ERROR 42000: Invalid default value for 'c2' +ALTER TABLE t1 ADD c2 TIMESTAMP DEFAULT '0000-00-00'; +ERROR 42000: Invalid default value for 'c2' +SET @@sql_mode='NO_ZERO_IN_DATE,STRICT_ALL_TABLES'; +Warnings: +Warning 3135 'NO_ZERO_DATE', 'NO_ZERO_IN_DATE' and 'ERROR_FOR_DIVISION_BY_ZERO' sql modes should be used with strict mode. They will be merged with strict mode in a future release. +ALTER TABLE t1 ADD c2 TIMESTAMP DEFAULT '2012-02-00'; +ERROR 42000: Invalid default value for 'c2' +#Alter table with out any SQL modes +SET @@sql_mode=''; +ALTER TABLE t1 ADD c2 TIMESTAMP DEFAULT 0; +ALTER TABLE t1 ADD c3 TIMESTAMP DEFAULT '0000-00-00'; +ALTER TABLE t1 ADD c4 TIMESTAMP DEFAULT '2012-02-00'; +Warnings: +Warning 1264 Out of range value for column 'c4' at row 1 +DROP TABLE t1; +SET @@sql_mode= @org_mode; +# END of Test for bug#11747847 - 34280 +# +# End of 5.6 tests +# diff --git a/mysql-test/r/type_timestamp_explicit.result-pq b/mysql-test/r/type_timestamp_explicit.result-pq new file mode 100644 index 000000000000..80768ec92a5a --- /dev/null +++ b/mysql-test/r/type_timestamp_explicit.result-pq @@ -0,0 +1,872 @@ +drop table if exists t1,t2; +SET sql_mode = 'NO_ENGINE_SUBSTITUTION'; +set time_zone="+03:00"; +CREATE TABLE t1 (a int, t timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP); +CREATE TABLE t2 (a int, t datetime); +SET TIMESTAMP=1234; +insert into t1 values(2,"2002-03-03"); +SET TIMESTAMP=1235; +SET TIMESTAMP=1236; +insert into t1 (a) values(4); +insert into t2 values(5,"2002-03-04"),(6,NULL),(7,"2002-03-05"),(8,"00-00-00"); +SET TIMESTAMP=1237; +insert into t1 select * from t2; +Warnings: +Warning 1048 Column 't' cannot be null +SET TIMESTAMP=1238; +insert into t1 (a) select a+1 from t2 where a=8; +select * from t1; +a t +2 2002-03-03 00:00:00 +4 1970-01-01 03:20:36 +5 2002-03-04 00:00:00 +6 0000-00-00 00:00:00 +7 2002-03-05 00:00:00 +8 0000-00-00 00:00:00 +9 1970-01-01 03:20:38 +drop table t1,t2; +SET TIMESTAMP=1234; +CREATE TABLE t1 (value TEXT NOT NULL, id VARCHAR(32) NOT NULL, stamp timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (id)); +INSERT INTO t1 VALUES ("my value", "myKey","1999-04-02 00:00:00"); +SELECT stamp FROM t1 WHERE id="myKey"; +stamp +1999-04-02 00:00:00 +UPDATE t1 SET value="my value" WHERE id="myKey"; +SELECT stamp FROM t1 WHERE id="myKey"; +stamp +1999-04-02 00:00:00 +UPDATE t1 SET id="myKey" WHERE value="my value"; +SELECT stamp FROM t1 WHERE id="myKey"; +stamp +1999-04-02 00:00:00 +drop table t1; +create table t1 (a timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP); +insert into t1 values (now()); +select date_format(a,"%Y %y"),year(a),year(now()) from t1; +date_format(a,"%Y %y") year(a) year(now()) +1970 70 1970 1970 +drop table t1; +create table t1 (ix timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP); +insert into t1 values (19991101000000),(19990102030405),(19990630232922),(19990601000000),(19990930232922),(19990531232922),(19990501000000),(19991101000000),(19990501000000); +select ix+0 from t1; +ix+0 +19991101000000 +19990102030405 +19990630232922 +19990601000000 +19990930232922 +19990531232922 +19990501000000 +19991101000000 +19990501000000 +truncate table t1; +insert into t1 values ("19991101000000"),("19990102030405"),("19990630232922"),("19990601000000"); +select ix+0 from t1; +ix+0 +19991101000000 +19990102030405 +19990630232922 +19990601000000 +drop table t1; +CREATE TABLE t1 (date date, date_time datetime, time_stamp timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP); +INSERT INTO t1 VALUES ("1998-12-31","1998-12-31 23:59:59",19981231235959); +INSERT INTO t1 VALUES ("1999-01-01","1999-01-01 00:00:00",19990101000000); +INSERT INTO t1 VALUES ("1999-09-09","1999-09-09 23:59:59",19990909235959); +INSERT INTO t1 VALUES ("2000-01-01","2000-01-01 00:00:00",20000101000000); +INSERT INTO t1 VALUES ("2000-02-28","2000-02-28 00:00:00",20000228000000); +INSERT INTO t1 VALUES ("2000-02-29","2000-02-29 00:00:00",20000229000000); +INSERT INTO t1 VALUES ("2000-03-01","2000-03-01 00:00:00",20000301000000); +INSERT INTO t1 VALUES ("2000-12-31","2000-12-31 23:59:59",20001231235959); +INSERT INTO t1 VALUES ("2001-01-01","2001-01-01 00:00:00",20010101000000); +INSERT INTO t1 VALUES ("2004-12-31","2004-12-31 23:59:59",20041231235959); +INSERT INTO t1 VALUES ("2005-01-01","2005-01-01 00:00:00",20050101000000); +INSERT INTO t1 VALUES ("2030-01-01","2030-01-01 00:00:00",20300101000000); +SELECT * FROM t1; +date date_time time_stamp +1998-12-31 1998-12-31 23:59:59 1998-12-31 23:59:59 +1999-01-01 1999-01-01 00:00:00 1999-01-01 00:00:00 +1999-09-09 1999-09-09 23:59:59 1999-09-09 23:59:59 +2000-01-01 2000-01-01 00:00:00 2000-01-01 00:00:00 +2000-02-28 2000-02-28 00:00:00 2000-02-28 00:00:00 +2000-02-29 2000-02-29 00:00:00 2000-02-29 00:00:00 +2000-03-01 2000-03-01 00:00:00 2000-03-01 00:00:00 +2000-12-31 2000-12-31 23:59:59 2000-12-31 23:59:59 +2001-01-01 2001-01-01 00:00:00 2001-01-01 00:00:00 +2004-12-31 2004-12-31 23:59:59 2004-12-31 23:59:59 +2005-01-01 2005-01-01 00:00:00 2005-01-01 00:00:00 +2030-01-01 2030-01-01 00:00:00 2030-01-01 00:00:00 +drop table t1; +create table t1 (ix timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP); +insert into t1 values (0),(20030101010160),(20030101016001),(20030101240101),(20030132010101),(20031301010101),(20031200000000),(20030000000000); +Warnings: +Warning 1265 Data truncated for column 'ix' at row 2 +Warning 1265 Data truncated for column 'ix' at row 3 +Warning 1265 Data truncated for column 'ix' at row 4 +Warning 1265 Data truncated for column 'ix' at row 5 +Warning 1265 Data truncated for column 'ix' at row 6 +Warning 1265 Data truncated for column 'ix' at row 7 +Warning 1265 Data truncated for column 'ix' at row 8 +select ix+0 from t1; +ix+0 +0 +0 +0 +0 +0 +0 +0 +0 +truncate table t1; +insert into t1 values ("00000000000000"),("20030101010160"),("20030101016001"),("20030101240101"),("20030132010101"),("20031301010101"),("20031200000000"),("20030000000000"); +Warnings: +Warning 1265 Data truncated for column 'ix' at row 2 +Warning 1265 Data truncated for column 'ix' at row 3 +Warning 1265 Data truncated for column 'ix' at row 4 +Warning 1265 Data truncated for column 'ix' at row 5 +Warning 1265 Data truncated for column 'ix' at row 6 +Warning 1264 Out of range value for column 'ix' at row 7 +Warning 1264 Out of range value for column 'ix' at row 8 +select ix+0 from t1; +ix+0 +0 +0 +0 +0 +0 +0 +0 +0 +truncate table t1; +insert into t1 values ("0000-00-00 00:00:00 some trailer"),("2003-01-01 00:00:00 some trailer"); +Warnings: +Warning 1265 Data truncated for column 'ix' at row 1 +Warning 1265 Data truncated for column 'ix' at row 2 +select ix+0 from t1; +ix+0 +0 +20030101000000 +drop table t1; +create table t1 (t1 timestamp not null default '2003-01-01 00:00:00', t2 datetime, t3 timestamp NOT NULL DEFAULT '0000-00-00 00:00:00'); +SET TIMESTAMP=1000000000; +insert into t1 values (); +SET TIMESTAMP=1000000001; +update t1 set t2=now(); +SET TIMESTAMP=1000000002; +insert into t1 (t1,t3) values (default, default); +select * from t1; +t1 t2 t3 +2003-01-01 00:00:00 2001-09-09 04:46:41 0000-00-00 00:00:00 +2003-01-01 00:00:00 NULL 0000-00-00 00:00:00 +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `t1` timestamp NOT NULL DEFAULT '2003-01-01 00:00:00', + `t2` datetime DEFAULT NULL, + `t3` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +show columns from t1; +Field Type Null Key Default Extra +t1 timestamp NO 2003-01-01 00:00:00 +t2 datetime YES NULL +t3 timestamp NO 0000-00-00 00:00:00 +drop table t1; +create table t1 (t1 timestamp not null default now(), t2 datetime, t3 timestamp NOT NULL DEFAULT '0000-00-00 00:00:00'); +SET TIMESTAMP=1000000002; +insert into t1 values (); +SET TIMESTAMP=1000000003; +update t1 set t2=now(); +SET TIMESTAMP=1000000003; +insert into t1 (t1,t3) values (default, default); +select * from t1; +t1 t2 t3 +2001-09-09 04:46:42 2001-09-09 04:46:43 0000-00-00 00:00:00 +2001-09-09 04:46:43 NULL 0000-00-00 00:00:00 +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `t1` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `t2` datetime DEFAULT NULL, + `t3` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +show columns from t1; +Field Type Null Key Default Extra +t1 timestamp NO CURRENT_TIMESTAMP DEFAULT_GENERATED +t2 datetime YES NULL +t3 timestamp NO 0000-00-00 00:00:00 +drop table t1; +create table t1 (t1 timestamp not null default '2003-01-01 00:00:00' on update now(), t2 datetime); +SET TIMESTAMP=1000000004; +insert into t1 values (); +select * from t1; +t1 t2 +2003-01-01 00:00:00 NULL +SET TIMESTAMP=1000000005; +update t1 set t2=now(); +SET TIMESTAMP=1000000005; +insert into t1 (t1) values (default); +select * from t1; +t1 t2 +2001-09-09 04:46:45 2001-09-09 04:46:45 +2003-01-01 00:00:00 NULL +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `t1` timestamp NOT NULL DEFAULT '2003-01-01 00:00:00' ON UPDATE CURRENT_TIMESTAMP, + `t2` datetime DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +show columns from t1; +Field Type Null Key Default Extra +t1 timestamp NO 2003-01-01 00:00:00 on update CURRENT_TIMESTAMP +t2 datetime YES NULL +drop table t1; +create table t1 (t1 timestamp not null default now() on update now(), t2 datetime); +SET TIMESTAMP=1000000006; +insert into t1 values (); +select * from t1; +t1 t2 +2001-09-09 04:46:46 NULL +SET TIMESTAMP=1000000007; +update t1 set t2=now(); +SET TIMESTAMP=1000000007; +insert into t1 (t1) values (default); +select * from t1; +t1 t2 +2001-09-09 04:46:47 2001-09-09 04:46:47 +2001-09-09 04:46:47 NULL +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `t1` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + `t2` datetime DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +show columns from t1; +Field Type Null Key Default Extra +t1 timestamp NO CURRENT_TIMESTAMP DEFAULT_GENERATED on update CURRENT_TIMESTAMP +t2 datetime YES NULL +drop table t1; +create table t1 (t1 timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, t2 datetime, t3 timestamp NOT NULL DEFAULT '0000-00-00 00:00:00'); +SET TIMESTAMP=1000000007; +insert into t1 values (); +select * from t1; +t1 t2 t3 +2001-09-09 04:46:47 NULL 0000-00-00 00:00:00 +SET TIMESTAMP=1000000008; +update t1 set t2=now(); +SET TIMESTAMP=1000000008; +insert into t1 (t1,t3) values (default, default); +select * from t1; +t1 t2 t3 +2001-09-09 04:46:48 2001-09-09 04:46:48 0000-00-00 00:00:00 +2001-09-09 04:46:48 NULL 0000-00-00 00:00:00 +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `t1` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + `t2` datetime DEFAULT NULL, + `t3` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +show columns from t1; +Field Type Null Key Default Extra +t1 timestamp NO CURRENT_TIMESTAMP DEFAULT_GENERATED on update CURRENT_TIMESTAMP +t2 datetime YES NULL +t3 timestamp NO 0000-00-00 00:00:00 +drop table t1; +create table t1 (t1 timestamp not null default current_timestamp on update current_timestamp, t2 datetime); +SET TIMESTAMP=1000000009; +insert into t1 values (); +select * from t1; +t1 t2 +2001-09-09 04:46:49 NULL +SET TIMESTAMP=1000000010; +update t1 set t2=now(); +SET TIMESTAMP=1000000011; +insert into t1 (t1) values (default); +select * from t1; +t1 t2 +2001-09-09 04:46:50 2001-09-09 04:46:50 +2001-09-09 04:46:51 NULL +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `t1` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + `t2` datetime DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +show columns from t1; +Field Type Null Key Default Extra +t1 timestamp NO CURRENT_TIMESTAMP DEFAULT_GENERATED on update CURRENT_TIMESTAMP +t2 datetime YES NULL +truncate table t1; +insert into t1 values ('2004-04-01 00:00:00', '2004-04-01 00:00:00'); +SET TIMESTAMP=1000000012; +update t1 set t1= '2004-04-02 00:00:00'; +select * from t1; +t1 t2 +2004-04-02 00:00:00 2004-04-01 00:00:00 +update t1 as ta, t1 as tb set tb.t1= '2004-04-03 00:00:00'; +select * from t1; +t1 t2 +2004-04-03 00:00:00 2004-04-01 00:00:00 +drop table t1; +create table t1 (pk int primary key, t1 timestamp not null default current_timestamp on update current_timestamp, bulk int); +insert into t1 values (1, '2004-04-01 00:00:00', 10); +SET TIMESTAMP=1000000013; +replace into t1 set pk = 1, bulk= 20; +select * from t1; +pk t1 bulk +1 2001-09-09 04:46:53 20 +drop table t1; +create table t1 (pk int primary key, t1 timestamp not null default '2003-01-01 00:00:00' on update current_timestamp, bulk int); +insert into t1 values (1, '2004-04-01 00:00:00', 10); +SET TIMESTAMP=1000000014; +replace into t1 set pk = 1, bulk= 20; +select * from t1; +pk t1 bulk +1 2003-01-01 00:00:00 20 +drop table t1; +create table t1 (pk int primary key, t1 timestamp not null default current_timestamp on update current_timestamp, bulk int); +insert into t1 values (1, '2004-04-01 00:00:00', 10); +SET TIMESTAMP=1000000015; +replace into t1 set pk = 1, bulk= 20; +select * from t1; +pk t1 bulk +1 2001-09-09 04:46:55 20 +drop table t1; +create table t1 (t1 timestamp not null default current_timestamp on update current_timestamp); +insert into t1 values ('2004-04-01 00:00:00'); +SET TIMESTAMP=1000000016; +alter table t1 add i int default 10; +select * from t1; +t1 i +2004-04-01 00:00:00 10 +drop table t1; +create table t1 (a timestamp null, b timestamp null); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` timestamp NULL DEFAULT NULL, + `b` timestamp NULL DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +insert into t1 values (NULL, NULL); +SET TIMESTAMP=1000000017; +insert into t1 values (); +select * from t1; +a b +NULL NULL +NULL NULL +drop table t1; +create table t1 (a timestamp null default current_timestamp on update current_timestamp, b timestamp null); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + `b` timestamp NULL DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +insert into t1 values (NULL, NULL); +SET TIMESTAMP=1000000018; +insert into t1 values (); +select * from t1; +a b +NULL NULL +2001-09-09 04:46:58 NULL +drop table t1; +create table t1 (a timestamp null default null, b timestamp null default '2003-01-01 00:00:00'); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` timestamp NULL DEFAULT NULL, + `b` timestamp NULL DEFAULT '2003-01-01 00:00:00' +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +insert into t1 values (NULL, NULL); +insert into t1 values (DEFAULT, DEFAULT); +select * from t1; +a b +NULL NULL +NULL 2003-01-01 00:00:00 +drop table t1; +create table t1 (a bigint, b bigint); +insert into t1 values (NULL, NULL), (20030101000000, 20030102000000); +set timestamp=1000000019; +alter table t1 modify a timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, modify b timestamp NOT NULL DEFAULT '0000-00-00 00:00:0'; +select * from t1; +a b +2001-09-09 04:46:59 2001-09-09 04:46:59 +2003-01-01 00:00:00 2003-01-02 00:00:00 +drop table t1; +create table t1 (a char(2), t timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP); +insert into t1 values ('a', '2004-01-01 00:00:00'), ('a', '2004-01-01 01:00:00'), +('b', '2004-02-01 00:00:00'); +select max(t) from t1 group by a; +max(t) +2004-01-01 01:00:00 +2004-02-01 00:00:00 +drop table t1; +create table t1 (a int auto_increment primary key, b int, c timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP); +insert into t1 (a, b, c) values (1, 0, '2001-01-01 01:01:01'), +(2, 0, '2002-02-02 02:02:02'), (3, 0, '2003-03-03 03:03:03'); +select * from t1; +a b c +1 0 2001-01-01 01:01:01 +2 0 2002-02-02 02:02:02 +3 0 2003-03-03 03:03:03 +update t1 set b = 2, c = c where a = 2; +select * from t1; +a b c +1 0 2001-01-01 01:01:01 +2 2 2002-02-02 02:02:02 +3 0 2003-03-03 03:03:03 +insert into t1 (a) values (4); +select * from t1; +a b c +1 0 2001-01-01 01:01:01 +2 2 2002-02-02 02:02:02 +3 0 2003-03-03 03:03:03 +4 NULL 2001-09-09 04:46:59 +update t1 set c = '2004-04-04 04:04:04' where a = 4; +select * from t1; +a b c +1 0 2001-01-01 01:01:01 +2 2 2002-02-02 02:02:02 +3 0 2003-03-03 03:03:03 +4 NULL 2004-04-04 04:04:04 +insert into t1 (a) values (3), (5) on duplicate key update b = 3, c = c; +select * from t1; +a b c +1 0 2001-01-01 01:01:01 +2 2 2002-02-02 02:02:02 +3 3 2003-03-03 03:03:03 +4 NULL 2004-04-04 04:04:04 +5 NULL 2001-09-09 04:46:59 +insert into t1 (a, c) values (4, '2004-04-04 00:00:00'), +(6, '2006-06-06 06:06:06') on duplicate key update b = 4; +select * from t1; +a b c +1 0 2001-01-01 01:01:01 +2 2 2002-02-02 02:02:02 +3 3 2003-03-03 03:03:03 +4 4 2001-09-09 04:46:59 +5 NULL 2001-09-09 04:46:59 +6 NULL 2006-06-06 06:06:06 +drop table t1; +End of 4.1 tests +set time_zone= @@global.time_zone; +CREATE TABLE t1 ( f1 INT(11) NOT NULL AUTO_INCREMENT PRIMARY KEY, +f2 TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, +f3 TIMESTAMP NOT NULL default '0000-00-00 00:00:00'); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 (f2,f3) VALUES (NOW(), "0000-00-00 00:00:00"); +UPDATE t1 SET f2=NOW(), f3=FROM_UNIXTIME('9999999999') WHERE f1=1; +Warnings: +Warning 1048 Column 'f3' cannot be null +SELECT f1,f2-f3 FROM t1; +f1 f2-f3 +1 20010909044659 +DROP TABLE t1; +End of 5.0 tests +# +# Bug #55779: select does not work properly in mysql server +# Version "5.1.42 SUSE MySQL RPM" +# +CREATE TABLE t1 (a TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, KEY (a)); +INSERT INTO t1 VALUES ('2000-01-01 00:00:00'), ('2000-01-01 00:00:00'), +('2000-01-01 00:00:01'), ('2000-01-01 00:00:01'); +SELECT a FROM t1 WHERE a >= 20000101000000; +a +2000-01-01 00:00:00 +2000-01-01 00:00:00 +2000-01-01 00:00:01 +2000-01-01 00:00:01 +SELECT a FROM t1 WHERE a >= '20000101000000'; +a +2000-01-01 00:00:00 +2000-01-01 00:00:00 +2000-01-01 00:00:01 +2000-01-01 00:00:01 +DROP TABLE t1; +# +# Bug#50774: failed to get the correct resultset when timestamp values +# are appended with .0 +# +CREATE TABLE t1 ( a TIMESTAMP, KEY ( a ) ); +INSERT INTO t1 VALUES( '2010-02-01 09:31:01' ); +INSERT INTO t1 VALUES( '2010-02-01 09:31:02' ); +INSERT INTO t1 VALUES( '2010-02-01 09:31:03' ); +INSERT INTO t1 VALUES( '2010-02-01 09:31:04' ); +SELECT * FROM t1 WHERE a >= '2010-02-01 09:31:02.0'; +a +2010-02-01 09:31:02 +2010-02-01 09:31:03 +2010-02-01 09:31:04 +SELECT * FROM t1 WHERE '2010-02-01 09:31:02.0' <= a; +a +2010-02-01 09:31:02 +2010-02-01 09:31:03 +2010-02-01 09:31:04 +SELECT * FROM t1 WHERE a <= '2010-02-01 09:31:02.0'; +a +2010-02-01 09:31:01 +2010-02-01 09:31:02 +SELECT * FROM t1 WHERE '2010-02-01 09:31:02.0' >= a; +a +2010-02-01 09:31:01 +2010-02-01 09:31:02 +SELECT * FROM t1 WHERE a >= '2010-02-01 09:31:02.0'; +a +2010-02-01 09:31:02 +2010-02-01 09:31:03 +2010-02-01 09:31:04 +CREATE TABLE t2 ( a TIMESTAMP, KEY ( a ) ); +INSERT INTO t2 VALUES( '2010-02-01 09:31:01' ); +INSERT INTO t2 VALUES( '2010-02-01 09:31:02' ); +INSERT INTO t2 VALUES( '2010-02-01 09:31:03' ); +INSERT INTO t2 VALUES( '2010-02-01 09:31:04' ); +INSERT INTO t2 VALUES( '2010-02-01 09:31:05' ); +INSERT INTO t2 VALUES( '2010-02-01 09:31:06' ); +INSERT INTO t2 VALUES( '2010-02-01 09:31:07' ); +INSERT INTO t2 VALUES( '2010-02-01 09:31:08' ); +INSERT INTO t2 VALUES( '2010-02-01 09:31:09' ); +INSERT INTO t2 VALUES( '2010-02-01 09:31:10' ); +INSERT INTO t2 VALUES( '2010-02-01 09:31:11' ); +# The bug would cause the range optimizer's comparison to use an open +# interval here. This reveals itself only in the number of reads +# performed. +FLUSH STATUS; +SELECT * FROM t2 WHERE a < '2010-02-01 09:31:02.0'; +a +2010-02-01 09:31:01 +SHOW STATUS LIKE 'Handler_read_next'; +Variable_name Value +Handler_read_next 0 +DROP TABLE t1, t2; +End of 5.1 tests + +Bug#50888 valgrind warnings in Field_timestamp::val_str + +SET TIMESTAMP=0; +CREATE TABLE t1(a timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP); +INSERT INTO t1 VALUES ('2008-02-23 09:23:45'), ('2010-03-05 11:08:02'); +FLUSH TABLES t1; +SELECT MAX(a) FROM t1; +MAX(a) +2010-03-05 11:08:02 +SELECT a FROM t1; +a +2008-02-23 09:23:45 +2010-03-05 11:08:02 +DROP TABLE t1; +End of Bug#50888 +# +# Bug59330: Incorrect result when comparing an aggregate +# function with TIMESTAMP +# +CREATE TABLE t1 (dt DATETIME, ts TIMESTAMP); +INSERT INTO t1 VALUES('2011-01-06 12:34:30', '2011-01-06 12:34:30'); +SELECT MAX(dt), MAX(ts) FROM t1; +MAX(dt) MAX(ts) +2011-01-06 12:34:30 2011-01-06 12:34:30 +SELECT MAX(ts) < '2010-01-01 00:00:00' FROM t1; +MAX(ts) < '2010-01-01 00:00:00' +0 +SELECT MAX(dt) < '2010-01-01 00:00:00' FROM t1; +MAX(dt) < '2010-01-01 00:00:00' +0 +SELECT MAX(ts) > '2010-01-01 00:00:00' FROM t1; +MAX(ts) > '2010-01-01 00:00:00' +1 +SELECT MAX(dt) > '2010-01-01 00:00:00' FROM t1; +MAX(dt) > '2010-01-01 00:00:00' +1 +SELECT MAX(ts) = '2011-01-06 12:34:30' FROM t1; +MAX(ts) = '2011-01-06 12:34:30' +1 +SELECT MAX(dt) = '2011-01-06 12:34:30' FROM t1; +MAX(dt) = '2011-01-06 12:34:30' +1 +DROP TABLE t1; +End of 5.5 tests +# +# Start of 5.6 tests +# +# +# Bug#13596893 - "ERROR 1690 (22003): BIGINT UNSIGNED VALUE IS OUT OF RANGE" ON DATE OPERATION +# +CREATE TABLE t1 ( +`c1` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, +`c2` TIMESTAMP NOT NULL DEFAULT '0000-00-00 00:00:00' +); +INSERT INTO t1 VALUES ('2003-05-16 23:53:29','2000-01-27 23:13:41'); +SELECT c2-c1 FROM t1; +c2-c1 +-30389003988 +SELECT * FROM t1; +c1 c2 +2003-05-16 23:53:29 2000-01-27 23:13:41 +SELECT TIMESTAMP'2000-01-27 23:13:41' - TIMESTAMP'2003-05-16 23:53:29'; +TIMESTAMP'2000-01-27 23:13:41' - TIMESTAMP'2003-05-16 23:53:29' +-30389003988 +SELECT TIMESTAMP('2000-01-27','23:13:41') - TIMESTAMP('2003-05-16','23:53:29'); +TIMESTAMP('2000-01-27','23:13:41') - TIMESTAMP('2003-05-16','23:53:29') +-30389003988 +DROP TABLE t1; +SET sql_mode = default; +# +# Test for bug#11747847 - 34280: create table fails if NO_ZERO_DATE +# or NO_ZERO_IN_DATE SQL mode is set. +DROP TABLE IF EXISTS t1, t2, t3; +SET @org_mode=@@sql_mode; +#Table creation in strict mode +SET @@sql_mode='NO_ZERO_DATE,STRICT_ALL_TABLES'; +Warnings: +Warning 3135 'NO_ZERO_DATE', 'NO_ZERO_IN_DATE' and 'ERROR_FOR_DIVISION_BY_ZERO' sql modes should be used with strict mode. They will be merged with strict mode in a future release. +CREATE TABLE t1 (c1 TIMESTAMP DEFAULT 0); +ERROR 42000: Invalid default value for 'c1' +CREATE TABLE t1 (c1 TIMESTAMP DEFAULT '0000-00-00 00:00:00'); +ERROR 42000: Invalid default value for 'c1' +CREATE TABLE t1 (c1 TIMESTAMP DEFAULT '2012-02-00 12:12:12'); +ERROR 42000: Invalid default value for 'c1' +#Table creation in non-strict mode but with NO_ZERO_DATE/NO_ZERO_IN_DATE +SET @@sql_mode='NO_ZERO_DATE'; +Warnings: +Warning 3135 'NO_ZERO_DATE', 'NO_ZERO_IN_DATE' and 'ERROR_FOR_DIVISION_BY_ZERO' sql modes should be used with strict mode. They will be merged with strict mode in a future release. +CREATE TABLE t1 (c1 TIMESTAMP DEFAULT 0); +Warnings: +Warning 1264 Out of range value for column 'c1' at row 1 +CREATE TABLE t2 (c1 TIMESTAMP DEFAULT '0000-00-00 00:00:00'); +Warnings: +Warning 1264 Out of range value for column 'c1' at row 1 +SET @@sql_mode='NO_ZERO_IN_DATE'; +Warnings: +Warning 3135 'NO_ZERO_DATE', 'NO_ZERO_IN_DATE' and 'ERROR_FOR_DIVISION_BY_ZERO' sql modes should be used with strict mode. They will be merged with strict mode in a future release. +CREATE TABLE t3 (c1 TIMESTAMP DEFAULT '2012-02-00 12:12:12'); +Warnings: +Warning 1264 Out of range value for column 'c1' at row 1 +DROP TABLE t1, t2, t3; +#Table creation with out any SQL modes +SET @@sql_mode=''; +CREATE TABLE t1 (c1 TIMESTAMP DEFAULT 0); +CREATE TABLE t2 (c1 TIMESTAMP DEFAULT '0000-00-00 00:00:00'); +CREATE TABLE t3 (c1 TIMESTAMP DEFAULT '2012-02-00 12:12:12'); +Warnings: +Warning 1264 Out of range value for column 'c1' at row 1 +DROP TABLE t1, t2, t3; +CREATE TABLE t1 (c1 INT); +#Alter table in strict mode with NO_ZERO_DATE/NO_ZERO_IN_DATE +SET @@sql_mode='NO_ZERO_DATE,STRICT_ALL_TABLES'; +Warnings: +Warning 3135 'NO_ZERO_DATE', 'NO_ZERO_IN_DATE' and 'ERROR_FOR_DIVISION_BY_ZERO' sql modes should be used with strict mode. They will be merged with strict mode in a future release. +ALTER TABLE t1 ADD c2 TIMESTAMP DEFAULT 0; +ERROR 42000: Invalid default value for 'c2' +ALTER TABLE t1 ADD c2 TIMESTAMP DEFAULT '0000-00-00'; +ERROR 42000: Invalid default value for 'c2' +SET @@sql_mode='NO_ZERO_IN_DATE,STRICT_ALL_TABLES'; +Warnings: +Warning 3135 'NO_ZERO_DATE', 'NO_ZERO_IN_DATE' and 'ERROR_FOR_DIVISION_BY_ZERO' sql modes should be used with strict mode. They will be merged with strict mode in a future release. +ALTER TABLE t1 ADD c2 TIMESTAMP DEFAULT '2012-02-00'; +ERROR 42000: Invalid default value for 'c2' +#Alter table with out any SQL modes +SET @@sql_mode=''; +ALTER TABLE t1 ADD c2 TIMESTAMP DEFAULT 0; +ALTER TABLE t1 ADD c3 TIMESTAMP DEFAULT '0000-00-00'; +ALTER TABLE t1 ADD c4 TIMESTAMP DEFAULT '2012-02-00'; +Warnings: +Warning 1264 Out of range value for column 'c4' at row 1 +DROP TABLE t1; +SET @@sql_mode= @org_mode; +# END of Test for bug#11747847 - 34280 +# +# End of 5.6 tests +# +SET sql_mode = 'NO_ENGINE_SUBSTITUTION'; +# +# WL6292 - Test cases to test new behavior with +# --explicit_defaults_for_timestamp +# Almost all the scenario's required to test this WL, is already tested +# by most of existing test case. Adding some basic tests here. +# +CREATE TABLE t1 (f1 TIMESTAMP, f2 TIMESTAMP); +ALTER TABLE t1 ADD COLUMN (f3 TIMESTAMP NOT NULL); +ALTER TABLE t1 ADD COLUMN (f4 TIMESTAMP DEFAULT NULL); +ALTER TABLE t1 ADD COLUMN (f5 TIMESTAMP DEFAULT '0:0:0'); +ALTER TABLE t1 ADD COLUMN (f6 TIMESTAMP ON UPDATE CURRENT_TIMESTAMP); +# Following is expected out of SHOW CREATE TABLE +# `f1` timestamp NULL DEFAULT NULL, +# `f2` timestamp NULL DEFAULT NULL, +# `f3` timestamp NOT NULL, +# `f4` timestamp NULL DEFAULT NULL, +# `f5` timestamp NULL DEFAULT '0000-00-00 00:00:00' +# `f6` timestamp NULL DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `f1` timestamp NULL DEFAULT NULL, + `f2` timestamp NULL DEFAULT NULL, + `f3` timestamp NOT NULL, + `f4` timestamp NULL DEFAULT NULL, + `f5` timestamp NULL DEFAULT '0000-00-00 00:00:00', + `f6` timestamp NULL DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +# The new behavior affects CREATE SELECT with column definitions +# before SELECT keyword. The columns f1,f2 in t2 do not get promoted +# with the new behavior. +CREATE TABLE t2 (f1 TIMESTAMP, f2 TIMESTAMP) SELECT f1,f2,f3,f4,f5,f6 FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `f1` timestamp NULL DEFAULT NULL, + `f2` timestamp NULL DEFAULT NULL, + `f3` timestamp NOT NULL, + `f4` timestamp NULL DEFAULT NULL, + `f5` timestamp NULL DEFAULT '0000-00-00 00:00:00', + `f6` timestamp NULL DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +DROP TABLE t1; +DROP TABLE t2; +# With --explicit_defaults_for_timestamp, +# inserting NULL in TIMESTAMP NOT NULL gives error, not NOW(). +# INT serves as model. +CREATE TABLE t1( +c1 TIMESTAMP NOT NULL, +c2 TIMESTAMP NOT NULL DEFAULT '2001-01-01 01:01:01', +c3 INT NOT NULL DEFAULT 42); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` timestamp NOT NULL, + `c2` timestamp NOT NULL DEFAULT '2001-01-01 01:01:01', + `c3` int NOT NULL DEFAULT '42' +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +INSERT INTO t1 VALUES (NULL, DEFAULT, DEFAULT); +ERROR 23000: Column 'c1' cannot be null +INSERT INTO t1 VALUES ('2005-05-05 06:06:06', NULL, DEFAULT); +ERROR 23000: Column 'c2' cannot be null +INSERT INTO t1 VALUES ('2005-05-05 06:06:06', DEFAULT, NULL); +ERROR 23000: Column 'c3' cannot be null +INSERT INTO t1 VALUES ('2005-05-05 06:06:06', DEFAULT, DEFAULT); +SELECT * FROM t1; +c1 c2 c3 +2005-05-05 06:06:06 2001-01-01 01:01:01 42 +UPDATE t1 SET c1=NULL,c2=NULL,c3=NULL; +Warnings: +Warning 1048 Column 'c1' cannot be null +Warning 1048 Column 'c2' cannot be null +Warning 1048 Column 'c3' cannot be null +SELECT * FROM t1; +c1 c2 c3 +0000-00-00 00:00:00 0000-00-00 00:00:00 0 +DROP TABLE t1; +SET sql_mode = default; +# +#Bug#19881933 : TABLE CREATION WITH TIMESTAMP IS REJECTED +# +SET sql_mode=TRADITIONAL; +CREATE TABLE t1( +dummy INT, +i1_null_const INT NULL DEFAULT 42, +t1_null_now TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP, +t1_null_const TIMESTAMP NULL DEFAULT '2001-01-01 03:03:03', +i2_not_null_const INT NOT NULL DEFAULT 42, +t2_not_null_now TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, +t2_not_null_const TIMESTAMP NOT NULL DEFAULT '2001-01-01 03:03:03', +i3_null INT NULL, +t3_null TIMESTAMP NULL, +i4_not_null INT NOT NULL, +t4_not_null TIMESTAMP NOT NULL); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `dummy` int DEFAULT NULL, + `i1_null_const` int DEFAULT '42', + `t1_null_now` timestamp NULL DEFAULT CURRENT_TIMESTAMP, + `t1_null_const` timestamp NULL DEFAULT '2001-01-01 03:03:03', + `i2_not_null_const` int NOT NULL DEFAULT '42', + `t2_not_null_now` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `t2_not_null_const` timestamp NOT NULL DEFAULT '2001-01-01 03:03:03', + `i3_null` int DEFAULT NULL, + `t3_null` timestamp NULL DEFAULT NULL, + `i4_not_null` int NOT NULL, + `t4_not_null` timestamp NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +DROP TABLE t1; +CREATE TABLE t1(a TIMESTAMP, b TIMESTAMP); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` timestamp NULL DEFAULT NULL, + `b` timestamp NULL DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +CREATE TABLE t2(a INT); +ALTER TABLE t2 ADD COLUMN b TIMESTAMP; +ALTER TABLE t2 ADD COLUMN c TIMESTAMP; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `a` int DEFAULT NULL, + `b` timestamp NULL DEFAULT NULL, + `c` timestamp NULL DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +ALTER TABLE t2 ADD COLUMN d TIMESTAMP; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `a` int DEFAULT NULL, + `b` timestamp NULL DEFAULT NULL, + `c` timestamp NULL DEFAULT NULL, + `d` timestamp NULL DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +ALTER TABLE t2 MODIFY b TIMESTAMP NOT NULL DEFAULT '0000-00-00 00:00:00'; +ERROR 42000: Invalid default value for 'b' +ALTER TABLE t2 MODIFY b TIMESTAMP DEFAULT '0000-00-00 00:00:00'; +ERROR 42000: Invalid default value for 'b' +INSERT INTO t1 VALUES(); +SET sql_mode=''; +INSERT INTO t1 VALUES(); +SET sql_mode=TRADITIONAL; +SELECT b FROM t1; +b +NULL +NULL +CREATE TABLE t3(a TIMESTAMP, b TIMESTAMP); +# INSERT SELECT statement +INSERT INTO t3 SELECT * from t1; +#CREATE SELECT with data in t1 +CREATE TABLE t4 AS SELECT * FROM t1; +DELETE FROM t1; +DROP TABLE t4; +#CREATE SELECT without data +CREATE TABLE t4 AS SELECT * FROM t1; +#DML statements +INSERT INTO t1 VALUES(default, default); +INSERT INTO t1 VALUES(default(a), default(b)); +UPDATE t1 SET b=default; +UPDATE t1 SET b=default(b); +CREATE TABLE t5(a TIMESTAMP NOT NULL); +CREATE TABLE t6(a TIMESTAMP, b TIMESTAMP NOT NULL); +DROP TABLE t1,t2,t3,t4,t5,t6; +SET sql_mode=default; +# +# BUG#27041502: ASSERTION `TYPE() != MYSQL_TYPE_TIMESTAMP' +# FAILED. +CREATE TABLE t1(fld1 TIMESTAMP,PRIMARY KEY (fld1)); +CREATE TRIGGER trg BEFORE INSERT ON t1 FOR EACH ROW SET @a=1; +# Without patch, an assert is triggered in the below +# INSERT/UPDATE cases. +INSERT INTO t1 VALUES(NULL); +ERROR 23000: Column 'fld1' cannot be null +DROP TRIGGER trg; +CREATE TRIGGER trg AFTER INSERT ON t1 FOR EACH ROW SET @a=1; +INSERT INTO t1 VALUES(NULL); +ERROR 23000: Column 'fld1' cannot be null +DROP TRIGGER trg; +CREATE TRIGGER trg BEFORE UPDATE ON t1 FOR EACH ROW SET @a=1; +INSERT INTO t1 VALUES("20121231"); +UPDATE t1 SET fld1=NULL WHERE fld1="20121231"; +ERROR 23000: Column 'fld1' cannot be null +SELECT * from t1; +fld1 +2012-12-31 00:00:00 +DROP TRIGGER trg; +CREATE TRIGGER trg AFTER UPDATE ON t1 FOR EACH ROW SET @a=1; +UPDATE t1 SET fld1=NULL WHERE fld1="20121231"; +ERROR 23000: Column 'fld1' cannot be null +DROP TRIGGER trg; +DROP TABLE t1; diff --git a/mysql-test/r/type_varchar.result-pq b/mysql-test/r/type_varchar.result-pq new file mode 100644 index 000000000000..f8e81f8f8910 --- /dev/null +++ b/mysql-test/r/type_varchar.result-pq @@ -0,0 +1,614 @@ +drop table if exists t1, t2; +create table t1 (v varchar(30), c char(3), e enum('abc','def','ghi'), t text); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `v` varchar(30) DEFAULT NULL, + `c` char(3) DEFAULT NULL, + `e` enum('abc','def','ghi') DEFAULT NULL, + `t` text +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +insert into t1 values ('abc', 'de', 'ghi', 'jkl'); +insert into t1 values ('abc ', 'de ', 'ghi', 'jkl '); +insert into t1 values ('abc ', 'd ', 'ghi', 'jkl '); +select length(v),length(c),length(e),length(t) from t1; +length(v) length(c) length(e) length(t) +3 2 3 3 +4 2 3 4 +7 1 3 7 +drop table t1; +create table t1 (v varchar(20)) charset latin1; +insert into t1 values('a '); +select v='a' from t1; +v='a' +1 +select binary v='a' from t1; +binary v='a' +0 +select binary v='a ' from t1; +binary v='a ' +1 +insert into t1 values('a'); +alter table t1 add primary key (v); +ERROR 23000: Duplicate entry 'a ' for key 't1.PRIMARY' +drop table t1; +create table t1 (v varbinary(20)); +insert into t1 values('a'); +insert into t1 values('a '); +alter table t1 add primary key (v); +drop table t1; +create table t1 (v varchar(254), index (v)) charset latin1; +insert into t1 values ("This is a test "); +insert into t1 values ("Some sample data"); +insert into t1 values (" garbage "); +insert into t1 values (" This is a test "); +insert into t1 values ("This is a test"); +insert into t1 values ("Hello world"); +insert into t1 values ("Foo bar"); +insert into t1 values ("This is a test"); +insert into t1 values ("MySQL varchar test"); +insert into t1 values ("test MySQL varchar"); +insert into t1 values ("This is a long string to have some random length data included"); +insert into t1 values ("Short string"); +insert into t1 values ("VSS"); +insert into t1 values ("Some samples"); +insert into t1 values ("Bar foo"); +insert into t1 values ("Bye"); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +select * from t1 where v like 'This is a test' order by v; +v +This is a test +This is a test +select * from t1 where v='This is a test' order by v; +v +This is a test +This is a test +This is a test +select * from t1 where v like 'S%' order by v; +v +Short string +Some sample data +Some samples +explain select * from t1 where v like 'This is a test' order by v; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range v v 257 NULL 3 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`v` AS `v` from `test`.`t1` where (`test`.`t1`.`v` like 'This is a test') order by `test`.`t1`.`v` +Helper line 1 for --skip_if_hypergraph diffing +explain select * from t1 where v='This is a test' order by v; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref v v 257 const 3 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`v` AS `v` from `test`.`t1` where (`test`.`t1`.`v` = 'This is a test') order by `test`.`t1`.`v` +Helper line 2 for --skip_if_hypergraph diffing +explain select * from t1 where v like 'S%' order by v; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range v v 257 NULL 3 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`v` AS `v` from `test`.`t1` where (`test`.`t1`.`v` like 'S%') order by `test`.`t1`.`v` +alter table t1 change v v varchar(255); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +select * from t1 where v like 'This is a test' order by v; +v +This is a test +This is a test +select * from t1 where v='This is a test' order by v; +v +This is a test +This is a test +This is a test +select * from t1 where v like 'S%' order by v; +v +Short string +Some sample data +Some samples +explain select * from t1 where v like 'This is a test' order by v; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range v v 258 NULL 3 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`v` AS `v` from `test`.`t1` where (`test`.`t1`.`v` like 'This is a test') order by `test`.`t1`.`v` +Helper line 1 for --skip_if_hypergraph diffing +explain select * from t1 where v='This is a test' order by v; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref v v 258 const 3 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`v` AS `v` from `test`.`t1` where (`test`.`t1`.`v` = 'This is a test') order by `test`.`t1`.`v` +Helper line 2 for --skip_if_hypergraph diffing +explain select * from t1 where v like 'S%' order by v; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range v v 258 NULL 3 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`v` AS `v` from `test`.`t1` where (`test`.`t1`.`v` like 'S%') order by `test`.`t1`.`v` +alter table t1 change v v varchar(256); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +select * from t1 where v like 'This is a test' order by v; +v +This is a test +This is a test +select * from t1 where v='This is a test' order by v; +v +This is a test +This is a test +This is a test +select * from t1 where v like 'S%' order by v; +v +Short string +Some sample data +Some samples +explain select * from t1 where v like 'This is a test' order by v; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range v v 259 NULL 3 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`v` AS `v` from `test`.`t1` where (`test`.`t1`.`v` like 'This is a test') order by `test`.`t1`.`v` +Helper line 1 for --skip_if_hypergraph diffing +explain select * from t1 where v='This is a test' order by v; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref v v 259 const 3 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`v` AS `v` from `test`.`t1` where (`test`.`t1`.`v` = 'This is a test') order by `test`.`t1`.`v` +Helper line 2 for --skip_if_hypergraph diffing +explain select * from t1 where v like 'S%' order by v; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range v v 259 NULL 3 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`v` AS `v` from `test`.`t1` where (`test`.`t1`.`v` like 'S%') order by `test`.`t1`.`v` +alter table t1 change v v varchar(257); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +select * from t1 where v like 'This is a test' order by v; +v +This is a test +This is a test +select * from t1 where v='This is a test' order by v; +v +This is a test +This is a test +This is a test +select * from t1 where v like 'S%' order by v; +v +Short string +Some sample data +Some samples +explain select * from t1 where v like 'This is a test' order by v; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range v v 260 NULL 3 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`v` AS `v` from `test`.`t1` where (`test`.`t1`.`v` like 'This is a test') order by `test`.`t1`.`v` +Helper line 1 for --skip_if_hypergraph diffing +explain select * from t1 where v='This is a test' order by v; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref v v 260 const 3 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`v` AS `v` from `test`.`t1` where (`test`.`t1`.`v` = 'This is a test') order by `test`.`t1`.`v` +Helper line 2 for --skip_if_hypergraph diffing +explain select * from t1 where v like 'S%' order by v; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range v v 260 NULL 3 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`v` AS `v` from `test`.`t1` where (`test`.`t1`.`v` like 'S%') order by `test`.`t1`.`v` +alter table t1 change v v varchar(258); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +select * from t1 where v like 'This is a test' order by v; +v +This is a test +This is a test +select * from t1 where v='This is a test' order by v; +v +This is a test +This is a test +This is a test +select * from t1 where v like 'S%' order by v; +v +Short string +Some sample data +Some samples +explain select * from t1 where v like 'This is a test' order by v; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range v v 261 NULL 3 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`v` AS `v` from `test`.`t1` where (`test`.`t1`.`v` like 'This is a test') order by `test`.`t1`.`v` +Helper line 1 for --skip_if_hypergraph diffing +explain select * from t1 where v='This is a test' order by v; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref v v 261 const 3 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`v` AS `v` from `test`.`t1` where (`test`.`t1`.`v` = 'This is a test') order by `test`.`t1`.`v` +Helper line 2 for --skip_if_hypergraph diffing +explain select * from t1 where v like 'S%' order by v; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range v v 261 NULL 3 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`v` AS `v` from `test`.`t1` where (`test`.`t1`.`v` like 'S%') order by `test`.`t1`.`v` +alter table t1 change v v varchar(259); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +select * from t1 where v like 'This is a test' order by v; +v +This is a test +This is a test +select * from t1 where v='This is a test' order by v; +v +This is a test +This is a test +This is a test +select * from t1 where v like 'S%' order by v; +v +Short string +Some sample data +Some samples +explain select * from t1 where v like 'This is a test' order by v; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range v v 262 NULL 3 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`v` AS `v` from `test`.`t1` where (`test`.`t1`.`v` like 'This is a test') order by `test`.`t1`.`v` +Helper line 3 for --skip_if_hypergraph diffing +explain select * from t1 where v='This is a test' order by v; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref v v 262 const 3 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`v` AS `v` from `test`.`t1` where (`test`.`t1`.`v` = 'This is a test') order by `test`.`t1`.`v` +Helper line 4 for --skip_if_hypergraph diffing +explain select * from t1 where v like 'S%' order by v; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range v v 262 NULL 3 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`v` AS `v` from `test`.`t1` where (`test`.`t1`.`v` like 'S%') order by `test`.`t1`.`v` +alter table t1 change v v varchar(258); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +select * from t1 where v like 'This is a test' order by v; +v +This is a test +This is a test +select * from t1 where v='This is a test' order by v; +v +This is a test +This is a test +This is a test +select * from t1 where v like 'S%' order by v; +v +Short string +Some sample data +Some samples +explain select * from t1 where v like 'This is a test' order by v; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range v v 261 NULL 3 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`v` AS `v` from `test`.`t1` where (`test`.`t1`.`v` like 'This is a test') order by `test`.`t1`.`v` +Helper line 3 for --skip_if_hypergraph diffing +explain select * from t1 where v='This is a test' order by v; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref v v 261 const 3 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`v` AS `v` from `test`.`t1` where (`test`.`t1`.`v` = 'This is a test') order by `test`.`t1`.`v` +Helper line 4 for --skip_if_hypergraph diffing +explain select * from t1 where v like 'S%' order by v; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range v v 261 NULL 3 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`v` AS `v` from `test`.`t1` where (`test`.`t1`.`v` like 'S%') order by `test`.`t1`.`v` +alter table t1 change v v varchar(257); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +select * from t1 where v like 'This is a test' order by v; +v +This is a test +This is a test +select * from t1 where v='This is a test' order by v; +v +This is a test +This is a test +This is a test +select * from t1 where v like 'S%' order by v; +v +Short string +Some sample data +Some samples +explain select * from t1 where v like 'This is a test' order by v; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range v v 260 NULL 3 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`v` AS `v` from `test`.`t1` where (`test`.`t1`.`v` like 'This is a test') order by `test`.`t1`.`v` +Helper line 3 for --skip_if_hypergraph diffing +explain select * from t1 where v='This is a test' order by v; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref v v 260 const 3 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`v` AS `v` from `test`.`t1` where (`test`.`t1`.`v` = 'This is a test') order by `test`.`t1`.`v` +Helper line 4 for --skip_if_hypergraph diffing +explain select * from t1 where v like 'S%' order by v; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range v v 260 NULL 3 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`v` AS `v` from `test`.`t1` where (`test`.`t1`.`v` like 'S%') order by `test`.`t1`.`v` +alter table t1 change v v varchar(256); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +select * from t1 where v like 'This is a test' order by v; +v +This is a test +This is a test +select * from t1 where v='This is a test' order by v; +v +This is a test +This is a test +This is a test +select * from t1 where v like 'S%' order by v; +v +Short string +Some sample data +Some samples +explain select * from t1 where v like 'This is a test' order by v; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range v v 259 NULL 3 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`v` AS `v` from `test`.`t1` where (`test`.`t1`.`v` like 'This is a test') order by `test`.`t1`.`v` +Helper line 3 for --skip_if_hypergraph diffing +explain select * from t1 where v='This is a test' order by v; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref v v 259 const 3 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`v` AS `v` from `test`.`t1` where (`test`.`t1`.`v` = 'This is a test') order by `test`.`t1`.`v` +Helper line 4 for --skip_if_hypergraph diffing +explain select * from t1 where v like 'S%' order by v; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range v v 259 NULL 3 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`v` AS `v` from `test`.`t1` where (`test`.`t1`.`v` like 'S%') order by `test`.`t1`.`v` +alter table t1 change v v varchar(255); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +select * from t1 where v like 'This is a test' order by v; +v +This is a test +This is a test +select * from t1 where v='This is a test' order by v; +v +This is a test +This is a test +This is a test +select * from t1 where v like 'S%' order by v; +v +Short string +Some sample data +Some samples +explain select * from t1 where v like 'This is a test' order by v; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range v v 258 NULL 3 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`v` AS `v` from `test`.`t1` where (`test`.`t1`.`v` like 'This is a test') order by `test`.`t1`.`v` +Helper line 3 for --skip_if_hypergraph diffing +explain select * from t1 where v='This is a test' order by v; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref v v 258 const 3 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`v` AS `v` from `test`.`t1` where (`test`.`t1`.`v` = 'This is a test') order by `test`.`t1`.`v` +Helper line 4 for --skip_if_hypergraph diffing +explain select * from t1 where v like 'S%' order by v; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range v v 258 NULL 3 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`v` AS `v` from `test`.`t1` where (`test`.`t1`.`v` like 'S%') order by `test`.`t1`.`v` +alter table t1 change v v varchar(254); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +select * from t1 where v like 'This is a test' order by v; +v +This is a test +This is a test +select * from t1 where v='This is a test' order by v; +v +This is a test +This is a test +This is a test +select * from t1 where v like 'S%' order by v; +v +Short string +Some sample data +Some samples +explain select * from t1 where v like 'This is a test' order by v; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range v v 257 NULL 3 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`v` AS `v` from `test`.`t1` where (`test`.`t1`.`v` like 'This is a test') order by `test`.`t1`.`v` +Helper line 3 for --skip_if_hypergraph diffing +explain select * from t1 where v='This is a test' order by v; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref v v 257 const 3 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`v` AS `v` from `test`.`t1` where (`test`.`t1`.`v` = 'This is a test') order by `test`.`t1`.`v` +Helper line 4 for --skip_if_hypergraph diffing +explain select * from t1 where v like 'S%' order by v; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range v v 257 NULL 3 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`v` AS `v` from `test`.`t1` where (`test`.`t1`.`v` like 'S%') order by `test`.`t1`.`v` +alter table t1 change v v varchar(253); +alter table t1 change v v varchar(254), drop key v; +alter table t1 change v v varchar(300), add key (v(10)); +select * from t1 where v like 'This is a test' order by v; +v +This is a test +This is a test +select * from t1 where v='This is a test' order by v; +v +This is a test +This is a test +This is a test +select * from t1 where v like 'S%' order by v; +v +Short string +Some sample data +Some samples +explain select * from t1 where v like 'This is a test' order by v; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range v v 13 NULL 4 100.00 Using where; Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`v` AS `v` from `test`.`t1` where (`test`.`t1`.`v` like 'This is a test') order by `test`.`t1`.`v` +Helper line 5 for --skip_if_hypergraph diffing +explain select * from t1 where v='This is a test' order by v; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref v v 13 const 4 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`v` AS `v` from `test`.`t1` where (`test`.`t1`.`v` = 'This is a test') order by `test`.`t1`.`v` +Helper line 6 for --skip_if_hypergraph diffing +explain select * from t1 where v like 'S%' order by v; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range v v 13 NULL 3 100.00 Using where; Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`v` AS `v` from `test`.`t1` where (`test`.`t1`.`v` like 'S%') order by `test`.`t1`.`v` +drop table t1; +create table t1 (pkcol varchar(16), othercol varchar(16), primary key (pkcol)); +insert into t1 values ('test', 'something'); +update t1 set othercol='somethingelse' where pkcol='test'; +select * from t1; +pkcol othercol +test somethingelse +drop table t1; +create table t1 (a int, b varchar(12)); +insert into t1 values (1, 'A'), (22, NULL); +create table t2 (a int); +insert into t2 values (22), (22); +select t1.a, t1.b, min(t1.b) from t1 inner join t2 ON t2.a = t1.a +group by t1.b, t1.a; +a b min(t1.b) +22 NULL NULL +drop table t1, t2; +create table t1 (f1 varchar(65500)) charset latin1; +create index index1 on t1(f1(10)); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `f1` varchar(65500) DEFAULT NULL, + KEY `index1` (`f1`(10)) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +alter table t1 modify f1 varchar(255); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `f1` varchar(255) DEFAULT NULL, + KEY `index1` (`f1`(10)) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +alter table t1 modify f1 tinytext; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `f1` tinytext, + KEY `index1` (`f1`(10)) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +drop table t1; +DROP TABLE IF EXISTS t1; +CREATE TABLE t1(f1 VARCHAR(100) DEFAULT 'test'); +INSERT INTO t1 VALUES(SUBSTR(f1, 1, 3)); +DROP TABLE IF EXISTS t1; +CREATE TABLE t1(f1 CHAR(100) DEFAULT 'test'); +INSERT INTO t1 VALUES(SUBSTR(f1, 1, 3)); +DROP TABLE IF EXISTS t1; +CREATE TABLE t1 (a CHAR(2)); +INSERT INTO t1 VALUES (10), (50), (30), ('1a'), (60), ('t'); +SELECT a,(a + 0) FROM t1 ORDER BY a; +a (a + 0) +10 10 +1a 1 +30 30 +50 50 +60 60 +t 0 +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: '1a' +Warning 1292 Truncated incorrect DOUBLE value: 't' +SELECT a,(a DIV 2) FROM t1 ORDER BY a; +a (a DIV 2) +10 5 +1a 0 +30 15 +50 25 +60 30 +t 0 +Warnings: +Warning 1292 Truncated incorrect DECIMAL value: '1a' +Warning 1366 Incorrect DECIMAL value: '0' for column '' at row -1 +Warning 1292 Truncated incorrect DECIMAL value: 't' +SELECT a,CAST(a AS SIGNED) FROM t1 ORDER BY a; +a CAST(a AS SIGNED) +10 10 +1a 1 +30 30 +50 50 +60 60 +t 0 +Warnings: +Warning 1292 Truncated incorrect INTEGER value: '1a' +Warning 1292 Truncated incorrect INTEGER value: 't' +DROP TABLE t1; +CREATE TABLE t1 (a VARCHAR(16)); +INSERT INTO t1 VALUES ('5'), ('s'), (''); +SELECT 5 = a FROM t1; +5 = a +1 +0 +0 +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 's' +DROP TABLE t1; +CREATE TABLE t1 (a CHAR(16)); +INSERT INTO t1 VALUES ('5'), ('s'), (''); +SELECT 5 = a FROM t1; +5 = a +1 +0 +0 +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 's' +DROP TABLE t1; diff --git a/mysql-test/r/update.result-pq b/mysql-test/r/update.result-pq new file mode 100644 index 000000000000..cd208da0272e --- /dev/null +++ b/mysql-test/r/update.result-pq @@ -0,0 +1,983 @@ +drop table if exists t1,t2; +create table t1 (a int auto_increment , primary key (a)); +insert into t1 values (NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL); +update t1 set a=a+10 where a > 34; +update t1 set a=a+100 where a > 0; +update t1 set a=a+100 limit 0; +explain update t1 set a=a+100 limit 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE NULL NULL NULL NULL NULL NULL NULL NULL NULL LIMIT is zero +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`a` = (`test`.`t1`.`a` + 100) limit 0 +update t1 set a=a+100 where a=1 and a=2; +update t1 set a=b+100 where a=1 and a=2; +ERROR 42S22: Unknown column 'b' in 'field list' +update t1 set a=b+100 where c=1 and a=2; +ERROR 42S22: Unknown column 'c' in 'where clause' +update t1 set d=a+100 where a=1; +ERROR 42S22: Unknown column 'd' in 'field list' +select * from t1; +a +101 +102 +103 +104 +105 +106 +107 +108 +109 +110 +111 +112 +113 +114 +115 +116 +117 +118 +119 +120 +121 +122 +123 +124 +125 +126 +127 +128 +129 +130 +131 +132 +133 +134 +145 +146 +drop table t1; +CREATE TABLE t1 +( +place_id int (10) unsigned NOT NULL, +shows int(10) unsigned DEFAULT '0' NOT NULL, +ishows int(10) unsigned DEFAULT '0' NOT NULL, +ushows int(10) unsigned DEFAULT '0' NOT NULL, +clicks int(10) unsigned DEFAULT '0' NOT NULL, +iclicks int(10) unsigned DEFAULT '0' NOT NULL, +uclicks int(10) unsigned DEFAULT '0' NOT NULL, +ts timestamp, +PRIMARY KEY (place_id,ts) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 (place_id,shows,ishows,ushows,clicks,iclicks,uclicks,ts) +VALUES (1,0,0,0,0,0,0,20000928174434); +UPDATE t1 SET shows=shows+1,ishows=ishows+1,ushows=ushows+1,clicks=clicks+1,iclicks=iclicks+1,uclicks=uclicks+1 WHERE place_id=1 AND ts>="2000-09-28 00:00:00"; +select place_id,shows from t1; +place_id shows +1 1 +drop table t1; +create table t1 (a int not null, b int not null, key (a)); +insert into t1 values (1,1),(1,2),(1,3),(3,1),(3,2),(3,3),(3,1),(3,2),(3,3),(2,1),(2,2),(2,3); +SET @tmp=0; +update t1 set b=(@tmp:=@tmp+1) order by a; +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +update t1 set b=99 where a=1 order by b asc limit 1; +select * from t1 order by a,b; +a b +1 2 +1 3 +1 99 +2 4 +2 5 +2 6 +3 7 +3 8 +3 9 +3 10 +3 11 +3 12 +update t1 set b=100 where a=1 order by b desc limit 2; +update t1 set a=a+10+b where a=1 order by b; +select * from t1 order by a,b; +a b +2 4 +2 5 +2 6 +3 7 +3 8 +3 9 +3 10 +3 11 +3 12 +13 2 +111 100 +111 100 +create table t2 (a int not null, b int not null); +insert into t2 values (1,1),(1,2),(1,3); +update t1 set b=(select distinct 1 from (select * from t2) a); +drop table t1,t2; +create table t1 (F1 VARCHAR(30), F2 VARCHAR(30), F3 VARCHAR(30), cnt int, groupid int, KEY groupid_index (groupid)); +insert into t1 (F1,F2,F3,cnt,groupid) values ('0','0','0',1,6), +('0','1','2',1,5), ('0','2','0',1,3), ('1','0','1',1,2), +('1','2','1',1,1), ('1','2','2',1,1), ('2','0','1',2,4), +('2','2','0',1,7); +delete from m1 using t1 m1,t1 m2 where m1.groupid=m2.groupid and (m1.cnt < m2.cnt or m1.cnt=m2.cnt and m1.F3>m2.F3); +select * from t1; +F1 F2 F3 cnt groupid +0 0 0 1 6 +0 1 2 1 5 +0 2 0 1 3 +1 0 1 1 2 +1 2 1 1 1 +2 0 1 2 4 +2 2 0 1 7 +drop table t1; +CREATE TABLE t1 ( +`colA` int(10) unsigned NOT NULL auto_increment, +`colB` int(11) NOT NULL default '0', +PRIMARY KEY (`colA`) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (4433,5424); +CREATE TABLE t2 ( +`colC` int(10) unsigned NOT NULL default '0', +`colA` int(10) unsigned NOT NULL default '0', +`colD` int(10) unsigned NOT NULL default '0', +`colE` int(10) unsigned NOT NULL default '0', +`colF` int(10) unsigned NOT NULL default '0', +PRIMARY KEY (`colC`,`colA`,`colD`,`colE`) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (3,4433,10005,495,500); +INSERT INTO t2 VALUES (3,4433,10005,496,500); +INSERT INTO t2 VALUES (3,4433,10009,494,500); +INSERT INTO t2 VALUES (3,4433,10011,494,500); +INSERT INTO t2 VALUES (3,4433,10005,497,500); +INSERT INTO t2 VALUES (3,4433,10013,489,500); +INSERT INTO t2 VALUES (3,4433,10005,494,500); +INSERT INTO t2 VALUES (3,4433,10005,493,500); +INSERT INTO t2 VALUES (3,4433,10005,492,500); +UPDATE IGNORE t2,t1 set t2.colE = t2.colE + 1,colF=0 WHERE t1.colA = t2.colA AND (t1.colB & 4096) > 0 AND (colE + 1) < colF; +Warnings: +Warning 1062 Duplicate entry '3-4433-10005-493' for key 't2.PRIMARY' +Warning 1062 Duplicate entry '3-4433-10005-494' for key 't2.PRIMARY' +Warning 1062 Duplicate entry '3-4433-10005-495' for key 't2.PRIMARY' +Warning 1062 Duplicate entry '3-4433-10005-496' for key 't2.PRIMARY' +Warning 1062 Duplicate entry '3-4433-10005-497' for key 't2.PRIMARY' +SELECT * FROM t2; +colC colA colD colE colF +3 4433 10005 492 500 +3 4433 10005 493 500 +3 4433 10005 494 500 +3 4433 10005 495 500 +3 4433 10005 496 500 +3 4433 10005 498 0 +3 4433 10009 495 0 +3 4433 10011 495 0 +3 4433 10013 490 0 +DROP TABLE t1; +DROP TABLE t2; +create table t1 (c1 int, c2 char(6), c3 int); +create table t2 (c1 int, c2 char(6)); +insert into t1 values (1, "t1c2-1", 10), (2, "t1c2-2", 20); +update t1 left join t2 on t1.c1 = t2.c1 set t2.c2 = "t2c2-1"; +update t1 left join t2 on t1.c1 = t2.c1 set t2.c2 = "t2c2-1" where t1.c3 = 10; +drop table t1, t2; +create table t1 (id int not null auto_increment primary key, id_str varchar(32)); +insert into t1 (id_str) values ("test"); +update t1 set id_str = concat(id_str, id) where id = last_insert_id(); +select * from t1; +id id_str +1 test1 +drop table t1; +create table t1 (a int, b char(255), key(a, b(20))); +insert into t1 values (0, '1'); +update t1 set b = b + 1 where a = 0; +select * from t1; +a b +0 2 +drop table t1; +create table t1(f1 int, f2 int); +create table t2(f3 int, f4 int); +create index idx on t2(f3); +insert into t1 values(1,0),(2,0); +insert into t2 values(1,1),(2,2); +UPDATE t1 SET t1.f2=(SELECT MAX(t2.f4) FROM t2 WHERE t2.f3=t1.f1); +select * from t1; +f1 f2 +1 1 +2 2 +drop table t1,t2; +create table t1(f1 int); +select DATABASE(); +DATABASE() +test +update t1 set f1=1 where count(*)=1; +ERROR HY000: Invalid use of group function +select DATABASE(); +DATABASE() +test +delete from t1 where count(*)=1; +ERROR HY000: Invalid use of group function +drop table t1; +create table t1 ( a int, b int default 0, index (a) ); +insert into t1 (a) values (0),(0),(0),(0),(0),(0),(0),(0); +flush status; +select a from t1 order by a limit 1; +a +0 +show status like 'handler_read%'; +Variable_name Value +Handler_read_first 1 +Handler_read_key 1 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 1 +flush status; +update t1 set a=9999 order by a limit 1; +update t1 set b=9999 order by a limit 1; +show status like 'handler_read%'; +Variable_name Value +Handler_read_first 2 +Handler_read_key 4 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 2 +Handler_read_rnd_next 0 +flush status; +delete from t1 order by a, b desc limit 1; +show status like 'handler_read%'; +Variable_name Value +Handler_read_first 1 +Handler_read_key 2 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 1 +Handler_read_rnd_next 9 +flush status; +delete from t1 order by a desc, b desc limit 1; +show status like 'handler_read%'; +Variable_name Value +Handler_read_first 1 +Handler_read_key 2 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 1 +Handler_read_rnd_next 8 +alter table t1 disable keys; +Warnings: +Note 1031 Table storage engine for 't1' doesn't have this option +flush status; +delete from t1 order by a limit 1; +show status like 'handler_read%'; +Variable_name Value +Handler_read_first 1 +Handler_read_key 3 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +select * from t1; +a b +0 0 +0 0 +0 0 +0 0 +0 0 +update t1 set a=a+10,b=1 order by a limit 3; +update t1 set a=a+11,b=2 order by a limit 3; +update t1 set a=a+12,b=3 order by a limit 3; +select * from t1 order by a; +a b +11 2 +21 2 +22 3 +22 3 +23 3 +drop table t1; +create table t1 (f1 int); +create table t2 (f2 int); +insert into t1 values(1),(2); +insert into t2 values(1),(1); +update t1,t2 set f1=3,f2=3 where f1=f2 and f1=1; +affected rows: 3 +info: Rows matched: 3 Changed: 3 Warnings: 0 +update t2 set f2=1; +update t1 set f1=1 where f1=3; +update t2,t1 set f1=3,f2=3 where f1=f2 and f1=1; +affected rows: 3 +info: Rows matched: 3 Changed: 3 Warnings: 0 +drop table t1,t2; +create table t1 (a int); +insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t2 (a int, filler1 char(200), filler2 char(200), key(a)); +insert into t2 select A.a + 10*B.a, 'filler','filler' from t1 A, t1 B; +flush status; +update t2 set a=3 where a=2; +show status like 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 2 +Handler_read_last 0 +Handler_read_next 1 +Handler_read_prev 0 +Handler_read_rnd 1 +Handler_read_rnd_next 0 +drop table t1, t2; +create table t1(f1 int, `*f2` int); +insert into t1 values (1,1); +update t1 set `*f2`=1; +drop table t1; +create table t1(f1 int); +update t1 set f2=1 order by f2; +ERROR 42S22: Unknown column 'f2' in 'field list' +drop table t1; +SET sql_mode = 'NO_ENGINE_SUBSTITUTION'; +CREATE TABLE t1 ( +request_id int unsigned NOT NULL auto_increment, +user_id varchar(12) default NULL, +time_stamp datetime NOT NULL default '0000-00-00 00:00:00', +ip_address varchar(15) default NULL, +PRIMARY KEY (request_id), +KEY user_id_2 (user_id,time_stamp) +); +INSERT INTO t1 (user_id) VALUES ('user1'); +INSERT INTO t1(user_id) SELECT user_id FROM t1; +INSERT INTO t1(user_id) SELECT user_id FROM t1; +INSERT INTO t1(user_id) SELECT user_id FROM t1; +INSERT INTO t1(user_id) SELECT user_id FROM t1; +INSERT INTO t1(user_id) SELECT user_id FROM t1; +INSERT INTO t1(user_id) SELECT user_id FROM t1; +INSERT INTO t1(user_id) SELECT user_id FROM t1; +INSERT INTO t1(user_id) SELECT user_id FROM t1; +flush status; +SELECT user_id FROM t1 WHERE request_id=9999999999999; +user_id +show status like '%Handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 0 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +SELECT user_id FROM t1 WHERE request_id=999999999999999999999999999999; +user_id +show status like '%Handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 0 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +UPDATE t1 SET user_id=null WHERE request_id=9999999999999; +show status like '%Handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 0 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +UPDATE t1 SET user_id=null WHERE request_id=999999999999999999999999999999; +show status like '%Handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 0 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +DROP TABLE t1; +SET sql_mode = default; +CREATE TABLE t1 ( +a INT(11), +quux decimal( 31, 30 ), +UNIQUE KEY bar (a), +KEY quux (quux) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO +t1 ( a, quux ) +VALUES +( 1, 1 ), +( 2, 0.1 ); +INSERT INTO t1( a ) +SELECT @newA := 1 + a FROM t1 WHERE quux <= 0.1; +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +SELECT * FROM t1; +a quux +1 1.000000000000000000000000000000 +2 0.100000000000000000000000000000 +3 NULL +DROP TABLE t1; +set tmp_table_size=1024; +create table t1 (id int, a int, key idx(a)); +create table t2 (id int unsigned not null auto_increment primary key, a int); +insert into t2(a) values(1),(2),(3),(4),(5),(6),(7),(8); +insert into t2(a) select a from t2; +insert into t2(a) select a from t2; +insert into t2(a) select a from t2; +update t2 set a=id; +insert into t1 select * from t2; +select count(*) from t1 join t2 on (t1.a=t2.a); +count(*) +64 +update t1 join t2 on (t1.a=t2.a) set t1.id=t2.id; +affected rows: 0 +info: Rows matched: 64 Changed: 0 Warnings: 0 +insert into t2(a) select a from t2; +update t2 set a=id; +truncate t1; +insert into t1 select * from t2; +select count(*) from t1 join t2 on (t1.a=t2.a); +count(*) +128 +update t1 join t2 on (t1.a=t2.a) set t1.id=t2.id; +affected rows: 0 +info: Rows matched: 128 Changed: 0 Warnings: 0 +update t1 set a=1; +update t2 set a=1; +select count(*) from t1 join t2 on (t1.a=t2.a); +count(*) +16384 +update t1 join t2 on (t1.a=t2.a) set t1.id=t2.id; +affected rows: 127 +info: Rows matched: 128 Changed: 127 Warnings: 0 +drop table t1,t2; +DROP TABLE IF EXISTS t1; +DROP FUNCTION IF EXISTS f1; +CREATE FUNCTION f1() RETURNS INT RETURN f1(); +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (1); +UPDATE t1 SET i = 3 WHERE f1(); +ERROR HY000: Recursive stored functions and triggers are not allowed. +UPDATE t1 SET i = f1(); +ERROR HY000: Recursive stored functions and triggers are not allowed. +DROP TABLE t1; +DROP FUNCTION f1; +End of 5.0 tests +# +# Bug #47919 assert in open_table during ALTER temporary table +# +CREATE TABLE t1 (f1 INTEGER AUTO_INCREMENT, PRIMARY KEY (f1)); +CREATE TEMPORARY TABLE t2 LIKE t1; +INSERT INTO t1 VALUES (1); +INSERT INTO t2 VALUES (1); +ALTER TABLE t2 COMMENT = 'ABC'; +UPDATE t2, t1 SET t2.f1 = 2, t1.f1 = 9; +ALTER TABLE t2 COMMENT = 'DEF'; +DROP TABLE t1, t2; +# +# Bug#50545: Single table UPDATE IGNORE crashes on join view in +# sql_safe_updates mode. +# +CREATE TABLE t1 ( a INT, KEY( a ) ); +INSERT INTO t1 VALUES (0), (1); +CREATE VIEW v1 AS SELECT t11.a, t12.a AS b FROM t1 t11, t1 t12; +SET SESSION sql_safe_updates = 1; +UPDATE IGNORE v1 SET a = 1; +ERROR HY000: You are using safe update mode and you tried to update a table without a WHERE that uses a KEY column. +SET SESSION sql_safe_updates = DEFAULT; +DROP TABLE t1; +DROP VIEW v1; +# +# Bug#54734 assert in Diagnostics_area::set_ok_status +# +SET sql_mode = 'NO_ENGINE_SUBSTITUTION'; +DROP TABLE IF EXISTS t1, not_exists; +DROP FUNCTION IF EXISTS f1; +DROP VIEW IF EXISTS v1; +CREATE TABLE t1 (PRIMARY KEY(pk)) AS SELECT 1 AS pk; +CREATE FUNCTION f1() RETURNS INTEGER RETURN (SELECT 1 FROM not_exists); +CREATE VIEW v1 AS SELECT pk FROM t1 WHERE f1() = 13; +UPDATE v1 SET pk = 7 WHERE pk > 0; +ERROR HY000: View 'test.v1' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +DROP VIEW v1; +DROP FUNCTION f1; +DROP TABLE t1; +SET sql_mode = default; +# +# Verify that UPDATE does the same number of handler_update +# operations, no matter if there is ORDER BY or not. +# +CREATE TABLE t1 (i INT) ENGINE=INNODB; +INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2 (a CHAR(2), b CHAR(2), c CHAR(2), d CHAR(2), +INDEX idx (a,b(1),c)) ENGINE=INNODB; +INSERT INTO t2 SELECT i, i, i, i FROM t1; +FLUSH STATUS; +START TRANSACTION; +UPDATE t2 SET d = 10 WHERE b = 10 LIMIT 5; +SET @binlog_handler_update= IF(@@global.log_bin AND @@global.binlog_format != 'STATEMENT', 1, 0); +SELECT VARIABLE_VALUE + @binlog_handler_update FROM performance_schema.session_status WHERE VARIABLE_NAME = 'HANDLER_UPDATE'; +VARIABLE_VALUE + @binlog_handler_update +1 +ROLLBACK; +FLUSH STATUS; +START TRANSACTION; +UPDATE t2 SET d = 10 WHERE b = 10 ORDER BY a, c LIMIT 5; +SELECT VARIABLE_VALUE + @binlog_handler_update FROM performance_schema.session_status WHERE VARIABLE_NAME = 'HANDLER_UPDATE'; +VARIABLE_VALUE + @binlog_handler_update +1 +ROLLBACK; +Same test with a different UPDATE. +ALTER TABLE t2 DROP INDEX idx, ADD INDEX idx2 (a, b); +FLUSH STATUS; +START TRANSACTION; +UPDATE t2 SET c = 10 LIMIT 5; +SELECT VARIABLE_VALUE + @binlog_handler_update FROM performance_schema.session_status WHERE VARIABLE_NAME = 'HANDLER_UPDATE'; +VARIABLE_VALUE + @binlog_handler_update +5 +ROLLBACK; +FLUSH STATUS; +START TRANSACTION; +UPDATE t2 SET c = 10 ORDER BY a, b DESC LIMIT 5; +SELECT VARIABLE_VALUE + @binlog_handler_update FROM performance_schema.session_status WHERE VARIABLE_NAME = 'HANDLER_UPDATE'; +VARIABLE_VALUE + @binlog_handler_update +5 +ROLLBACK; +DROP TABLE t1, t2; +# Bug#20454533: Assertion failed: sargables == 0 || *keyfields ... +CREATE TABLE t1( +a int, +c int, +e int, +f int, +g blob, +h int, +i int, +j blob, +unique key (g(221),c), +unique key (c,a,j(148)), +key (i) +) engine=innodb; +UPDATE (SELECT 1 AS a FROM t1 NATURAL JOIN t1 AS t2) AS x, t1 +SET t1.e= x.a; +DROP TABLE t1; +# Bug #21143080: UPDATE ON VARCHAR AND TEXT COLUMNS PRODUCE INCORRECT +# RESULTS +CREATE TABLE t1 (a VARCHAR(50), b TEXT, c CHAR(50)) ENGINE=INNODB; +INSERT INTO t1 (a, b, c) VALUES ('start trail', '', 'even longer string'); +UPDATE t1 SET b = a, a = 'inject'; +SELECT a, b FROM t1; +a b +inject start trail +UPDATE t1 SET b = c, c = 'inject'; +SELECT c, b FROM t1; +c b +inject even longer string +DROP TABLE t1; +# +# Bug#18698556: UPDATE ORDER BY DOES A FILESORT IF UPDATING +# A COLUMN IN THE INDEX +# +CREATE TABLE t1 ( +a INTEGER, +b INTEGER, +c INTEGER, +d INTEGER, +KEY key1 (a,b,c) +); +INSERT INTO t1 (a,b,c,d) VALUES (1, 1, 1, 4), (2, 2, 2, 5), (2, 3, 4, 7), +(3, 3, 3, 9), (4, 4, 4, 0), (5, 5, 5, 1), (5, 6, 7, 3), (5, 7, 9, 9); +analyze table t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +analyze table t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +explain UPDATE t1 SET c = 72 WHERE a = 2 ORDER BY b ASC LIMIT 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL range key1 key1 5 const # 100.00 Using where; Using temporary +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`c` = 72 where (`test`.`t1`.`a` = 2) order by `test`.`t1`.`b` limit 1 +UPDATE t1 SET c = 72 WHERE a = 2 ORDER BY b ASC LIMIT 1; +SELECT * FROM t1; +a b c d +1 1 1 4 +2 2 72 5 +2 3 4 7 +3 3 3 9 +4 4 4 0 +5 5 5 1 +5 6 7 3 +5 7 9 9 +explain UPDATE t1 SET d = 72 WHERE a = 2 ORDER BY b ASC LIMIT 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL range key1 key1 5 const # 100.00 Using where; Using temporary +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`d` = 72 where (`test`.`t1`.`a` = 2) order by `test`.`t1`.`b` limit 1 +UPDATE t1 SET d = 72 WHERE a = 2 ORDER BY b ASC LIMIT 1; +SELECT * FROM t1; +a b c d +1 1 1 4 +2 2 72 72 +2 3 4 7 +3 3 3 9 +4 4 4 0 +5 5 5 1 +5 6 7 3 +5 7 9 9 +INSERT INTO t1 (a,b,c,d) VALUES (5, 5, 1, 1), (5, 5, 2, 1), (5, 5, 4, 1); +analyze table t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +explain UPDATE t1 SET c = 3 WHERE a = 5 ORDER BY b ASC LIMIT 3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL range key1 key1 5 const # 100.00 Using where; Using temporary +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`c` = 3 where (`test`.`t1`.`a` = 5) order by `test`.`t1`.`b` limit 3 +UPDATE t1 SET c = 3 WHERE a = 5 ORDER BY b ASC LIMIT 3; +SELECT * FROM t1; +a b c d +1 1 1 4 +2 2 72 72 +2 3 4 7 +3 3 3 9 +4 4 4 0 +5 5 5 1 +5 6 7 3 +5 7 9 9 +5 5 3 1 +5 5 3 1 +5 5 3 1 +analyze table t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +explain UPDATE t1 SET c = 62 WHERE a > 4 ORDER BY b ASC LIMIT 3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL range key1 key1 5 const # 100.00 Using where; Using filesort +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`c` = 62 where (`test`.`t1`.`a` > 4) order by `test`.`t1`.`b` limit 3 +UPDATE t1 SET c = 62 WHERE a > 4 ORDER BY b ASC LIMIT 3; +SELECT * FROM t1; +a b c d +1 1 1 4 +2 2 72 72 +2 3 4 7 +3 3 3 9 +4 4 4 0 +5 5 62 1 +5 6 7 3 +5 7 9 9 +5 5 62 1 +5 5 62 1 +5 5 3 1 +INSERT INTO t1 (a,b,c,d) VALUES (1, 1, 1, 4), (2, 2, 2, 5), (2, 3, 4, 7), +(3, 3, 3, 9), (4, 4, 4, 0), (5, 5, 5, 1), (5, 6, 7, 3), (5, 7, 9, 9); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +explain UPDATE t1 SET c = 82 ORDER BY a ASC LIMIT 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL index NULL key1 15 NULL # 100.00 Using temporary +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`c` = 82 order by `test`.`t1`.`a` limit 1 +UPDATE t1 SET c = 82 ORDER BY a ASC LIMIT 1; +SELECT * FROM t1; +a b c d +1 1 82 4 +2 2 72 72 +2 3 4 7 +3 3 3 9 +4 4 4 0 +5 5 62 1 +5 6 7 3 +5 7 9 9 +5 5 62 1 +5 5 62 1 +5 5 3 1 +1 1 1 4 +2 2 2 5 +2 3 4 7 +3 3 3 9 +4 4 4 0 +5 5 5 1 +5 6 7 3 +5 7 9 9 +explain UPDATE t1 SET a = 82 ORDER BY b ASC LIMIT 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL # 100.00 Using filesort +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`a` = 82 order by `test`.`t1`.`b` limit 1 +UPDATE t1 SET a = 82 ORDER BY b ASC LIMIT 1; +SELECT * FROM t1; +a b c d +82 1 82 4 +2 2 72 72 +2 3 4 7 +3 3 3 9 +4 4 4 0 +5 5 62 1 +5 6 7 3 +5 7 9 9 +5 5 62 1 +5 5 62 1 +5 5 3 1 +1 1 1 4 +2 2 2 5 +2 3 4 7 +3 3 3 9 +4 4 4 0 +5 5 5 1 +5 6 7 3 +5 7 9 9 +explain UPDATE t1 SET b = 82 ORDER BY d ASC LIMIT 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL # 100.00 Using filesort +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`b` = 82 order by `test`.`t1`.`d` limit 1 +UPDATE t1 SET b = 82 ORDER BY d ASC LIMIT 1; +SELECT * FROM t1; +a b c d +82 1 82 4 +2 2 72 72 +2 3 4 7 +3 3 3 9 +4 82 4 0 +5 5 62 1 +5 6 7 3 +5 7 9 9 +5 5 62 1 +5 5 62 1 +5 5 3 1 +1 1 1 4 +2 2 2 5 +2 3 4 7 +3 3 3 9 +4 4 4 0 +5 5 5 1 +5 6 7 3 +5 7 9 9 +INSERT INTO t1 (a,b,c,d) VALUES (1, 1, 1, 4), (2, 2, 2, 5), (2, 3, 4, 7), +(3, 3, 3, 9), (4, 4, 4, 0), (5, 5, 5, 1), (5, 6, 7, 3), (5, 7, 9, 9); +INSERT INTO t1 (a,b,c,d) VALUES (1, 1, 1, 4), (2, 2, 2, 5), (2, 3, 4, 7), +(3, 3, 3, 9), (4, 4, 4, 0), (5, 5, 5, 1), (5, 6, 7, 3), (5, 7, 9, 9); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +explain UPDATE t1 SET c = 82 ORDER BY a ASC LIMIT 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL index NULL key1 15 NULL # 100.00 Using temporary +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`c` = 82 order by `test`.`t1`.`a` limit 2 +UPDATE t1 SET c = 82 ORDER BY a ASC LIMIT 2; +SELECT * FROM t1; +a b c d +82 1 82 4 +2 2 72 72 +2 3 4 7 +3 3 3 9 +4 82 4 0 +5 5 62 1 +5 6 7 3 +5 7 9 9 +5 5 62 1 +5 5 62 1 +5 5 3 1 +1 1 82 4 +2 2 2 5 +2 3 4 7 +3 3 3 9 +4 4 4 0 +5 5 5 1 +5 6 7 3 +5 7 9 9 +1 1 82 4 +2 2 2 5 +2 3 4 7 +3 3 3 9 +4 4 4 0 +5 5 5 1 +5 6 7 3 +5 7 9 9 +1 1 1 4 +2 2 2 5 +2 3 4 7 +3 3 3 9 +4 4 4 0 +5 5 5 1 +5 6 7 3 +5 7 9 9 +DROP TABLE t1; +# End of test for Bug#18698556 +# +# Bug#21944866: REFACTORING: REMOVE KILL_BAD_DATA +# +CREATE TABLE t1 (a INT PRIMARY KEY, b DATE); +UPDATE t1 SET b= NULL WHERE a < '00:38:47.008761'; +ERROR 22007: Truncated incorrect DOUBLE value: '00:38:47.008761' +DROP TABLE t1; +# +# Bug#21032418: PERFORMANCE REGRESSION IN 5.6: UPDATE DOES NOT USE INDEX +# +CREATE TABLE t1( +id INTEGER NOT NULL AUTO_INCREMENT, +token VARCHAR(255) DEFAULT NULL, +PRIMARY KEY (id), +KEY token (token) +)DEFAULT CHARSET=utf8; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES (1, "abc"), (2, "def"); +SET sql_mode=''; +UPDATE t1 SET token = X'ad'; +Warnings: +Warning 1366 Incorrect string value: '\xAD' for column 'token' at row 1 +Warning 1366 Incorrect string value: '\xAD' for column 'token' at row 2 +SELECT * FROM t1; +id token +1 +2 +EXPLAIN UPDATE t1 SET token = NULL WHERE token = X'ad'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Warning 1366 Incorrect string value: '\xAD' for column 'token' at row 1 +Note 1003 update `test`.`t1` set `test`.`t1`.`token` = NULL where (`test`.`t1`.`token` = 0xad) +UPDATE t1 SET token = NULL WHERE token = X'ad'; +Warnings: +Warning 1366 Incorrect string value: '\xAD' for column 'token' at row 1 +SET sql_mode=default; +EXPLAIN UPDATE t1 SET token = NULL WHERE token = X'ad'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Warning 1366 Incorrect string value: '\xAD' for column 'token' at row 1 +Note 1003 update `test`.`t1` set `test`.`t1`.`token` = NULL where (`test`.`t1`.`token` = 0xad) +UPDATE t1 SET token = NULL WHERE token = X'ad'; +Warnings: +Warning 1366 Incorrect string value: '\xAD' for column 'token' at row 1 +SELECT * FROM t1; +id token +1 +2 +DROP TABLE t1; +# End of test for Bug#21032418 +# +# Bug #29047894: ASSERTION FAILURE: ROW0MYSQL.CC:2387:TRX->ALLOW_SEMI_CONSISTENT() +# +CREATE TABLE t1 (a INTEGER); +SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED; +INSERT INTO t1 VALUES (0); +UPDATE t1 SET a=1 ORDER BY CAST('invalid' AS DATETIME); +ERROR 22007: Incorrect datetime value: 'invalid' +SET SESSION TRANSACTION ISOLATION LEVEL SERIALIZABLE; +DELETE FROM t1 WHERE a=2; +DROP TABLE t1; +SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ; +# +# Bug#30158954: INCONSISTENT ROWS MATCHED VALUE FOR UPDATE +# WITH FAILED CONSTRAINT +# +CREATE TABLE t1 (f1 INT PRIMARY KEY, f2 INT CHECK (f2 < 400)); +CREATE TABLE t2 (f1 INT PRIMARY KEY, f2 INT); +CREATE VIEW v2 AS SELECT * FROM t2 WHERE f2 < 400 WITH CHECK OPTION; +INSERT INTO t1 VALUES (1, 10), (2, 20); +INSERT INTO t2 VALUES (1, 10), (2, 20); +UPDATE IGNORE t1 SET f2 = 400; +affected rows: 0 +info: Rows matched: 2 Changed: 0 Warnings: 2 +Warnings: +Warning 3819 Check constraint 't1_chk_1' is violated. +Warning 3819 Check constraint 't1_chk_1' is violated. +UPDATE IGNORE v2 SET f2 = 400; +affected rows: 0 +info: Rows matched: 2 Changed: 0 Warnings: 2 +Warnings: +Warning 1369 CHECK OPTION failed 'test.v2' +Warning 1369 CHECK OPTION failed 'test.v2' +UPDATE IGNORE t2 SET f2 = 400; +affected rows: 2 +info: Rows matched: 2 Changed: 2 Warnings: 0 +DROP VIEW v2; +DROP TABLE t2, t1; +Bug#22671310: Generated columns mess up explain of multi-table update +CREATE TABLE t1(a INTEGER, b INTEGER AS (a)); +CREATE TABLE t2(a INTEGER); +EXPLAIN +UPDATE t1 JOIN t2 USING(a) SET t2.a=t2.a+1 WHERE t1.b>0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 UPDATE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 update `test`.`t1` join `test`.`t2` set `test`.`t2`.`a` = (`test`.`t2`.`a` + 1) where ((`test`.`t2`.`a` = `test`.`t1`.`a`) and (`test`.`t1`.`b` > 0)) +DROP TABLE t1, t2; +# Bug#22891840: Error message from update of non-updatable part of +# join view is inaccurate +CREATE TABLE t1(a1 INTEGER PRIMARY KEY, b1 INTEGER); +CREATE TABLE t2(a2 INTEGER PRIMARY KEY, b2 INTEGER); +CREATE VIEW vmat2 AS SELECT DISTINCT * FROM t2; +CREATE VIEW vtr AS +SELECT * FROM t1 JOIN vmat2 AS dt2 ON t1.a1=dt2.a2; +UPDATE vtr SET b1=b1+1 WHERE a1=1; +UPDATE vtr SET b2=b2+1 WHERE a2=1; +ERROR HY000: The target table vtr of the UPDATE is not updatable +DROP VIEW vtr, vmat2; +DROP TABLE t1, t2; +# Bug#31360425: Segfault in Query_result_update::optimize() +CREATE TABLE g(c INTEGER, b INTEGER); +CREATE TABLE t(a INTEGER); +UPDATE t SET a=1 WHERE EXISTS(SELECT b FROM g WHERE 1 NOT LIKE c FOR UPDATE); +DROP TABLE g, t; +# +# Bug#32112403: UPDATE ON TEXT TYPE COLUMN MAY LEAVE IT EMPTY +# +CREATE TABLE t1(i int primary key, c1 tinytext, c2 text); +INSERT INTO t1 VALUES (-1, 'twofiftyfive', '012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234'); +INSERT INTO t1 VALUES(0,'zero', +'0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345'); +INSERT INTO t1 VALUES (1, 'one', '01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456'); +INSERT INTO t1 VALUES (2, 'two', '012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567'); +# Ok because the c2 value can fit in c1 +UPDATE t1 SET c1 = c2 WHERE i = -1; +# Fails because these c2 value are too large to fit in c1 +UPDATE t1 SET c1 = c2 WHERE i = 0; +ERROR 22001: Data too long for column 'c1' at row 1 +# Ok with warning when using IGNORE +UPDATE IGNORE t1 SET c1 = c2 WHERE i = 1; +Warnings: +Warning 1265 Data truncated for column 'c1' at row 1 +# Ok with warning with empty sql_mode +SET SESSION sql_mode = ''; +UPDATE t1 SET c1 = c2 WHERE i = 2; +Warnings: +Warning 1265 Data truncated for column 'c1' at row 1 +SET SESSION sql_mode = DEFAULT; +SELECT * FROM t1; +i c1 c2 +-1 012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234 012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234 +0 zero 0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345 +1 012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234 01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456 +2 012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234 012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567 +DROP TABlE t1; diff --git a/mysql-test/r/varbinary.result-pq b/mysql-test/r/varbinary.result-pq new file mode 100644 index 000000000000..75eab51c7648 --- /dev/null +++ b/mysql-test/r/varbinary.result-pq @@ -0,0 +1,717 @@ +drop table if exists t1; +select 0x41,0x41+0,0x41 | 0x7fffffffffffffff | 0,0xffffffffffffffff | 0 ; +0x41 0x41+0 0x41 | 0x7fffffffffffffff | 0 0xffffffffffffffff | 0 +A 65 9223372036854775807 18446744073709551615 +select 0x31+1,concat(0x31)+1,-0xf; +0x31+1 concat(0x31)+1 -0xf +50 2 -15 +select x'31',X'ffff'+0; +x'31' X'ffff'+0 +1 65535 +create table t1 (ID int(8) unsigned zerofill not null auto_increment,UNIQ bigint(21) unsigned zerofill not null,primary key (ID),unique (UNIQ) ); +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t1 set UNIQ=0x38afba1d73e6a18a; +insert into t1 set UNIQ=123; +analyze table t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +explain select * from t1 where UNIQ=0x38afba1d73e6a18a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL const UNIQ UNIQ 8 const 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select '00000001' AS `ID`,'004084688022709641610' AS `UNIQ` from `test`.`t1` where true +drop table t1; +select x'hello'; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'x'hello'' at line 1 +select 0xfg; +ERROR 42S22: Unknown column '0xfg' in 'field list' +create table t1 select 1 as x, 2 as xx; +select x,xx from t1; +x xx +1 2 +drop table t1; +drop table if exists table_28127_a; +drop table if exists table_28127_b; +create table table_28127_a(0b02 int); +show create table table_28127_a; +Table Create Table +table_28127_a CREATE TABLE `table_28127_a` ( + `0b02` int DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +create table table_28127_b(0b2 int); +show create table table_28127_b; +Table Create Table +table_28127_b CREATE TABLE `table_28127_b` ( + `0b2` int DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table table_28127_a; +drop table table_28127_b; +select 0b01000001; +0b01000001 +A +select 0x41; +0x41 +A +select b'01000001'; +b'01000001' +A +select x'41', 0+x'41'; +x'41' 0+x'41' +A 65 +select N'abc', length(N'abc'); +abc length(N'abc') +abc 3 +Warnings: +Warning 3720 NATIONAL/NCHAR/NVARCHAR implies the character set UTF8MB3, which will be replaced by UTF8MB4 in a future release. Please consider using CHAR(x) CHARACTER SET UTF8MB4 in order to be unambiguous. +Warning 3720 NATIONAL/NCHAR/NVARCHAR implies the character set UTF8MB3, which will be replaced by UTF8MB4 in a future release. Please consider using CHAR(x) CHARACTER SET UTF8MB4 in order to be unambiguous. +select N'', length(N''); + length(N'') + 0 +Warnings: +Warning 3720 NATIONAL/NCHAR/NVARCHAR implies the character set UTF8MB3, which will be replaced by UTF8MB4 in a future release. Please consider using CHAR(x) CHARACTER SET UTF8MB4 in order to be unambiguous. +Warning 3720 NATIONAL/NCHAR/NVARCHAR implies the character set UTF8MB3, which will be replaced by UTF8MB4 in a future release. Please consider using CHAR(x) CHARACTER SET UTF8MB4 in order to be unambiguous. +select '', length(''); + length('') + 0 +select b'', 0+b''; +b'' 0+b'' + 0 +select x'', 0+x''; +x'' 0+x'' + 0 +select 0x; +ERROR 42S22: Unknown column '0x' in 'field list' +select 0b; +ERROR 42S22: Unknown column '0b' in 'field list' +create TABLE t1(a INT, b VARBINARY(4), c VARBINARY(4)); +INSERT INTO t1 VALUES +(1, 0x31393831, 0x31303037), +(2, 0x31393832, 0x31303038), +(3, 0x31393833, 0x31303039), +(3, 0x31393834, 0x31393831), +(4, 0x31393835, 0x31393832), +(5, 0x31393836, 0x31303038); +# +# deprecation warnings +# +SELECT +hex(b & c), hex(b & 0x31393838), b & NULL, hex(b & 0b00000000000000000000000000001011), +hex(0x31393838 & b), NULL & b, hex(0b00000000000000000000000000001011 & b) +FROM t1; +hex(b & c) hex(b & 0x31393838) b & NULL hex(b & 0b00000000000000000000000000001011) hex(0x31393838 & b) NULL & b hex(0b00000000000000000000000000001011 & b) +31303031 31393830 NULL 00000001 31393830 NULL 00000001 +31303030 31393830 NULL 00000002 31393830 NULL 00000002 +31303031 31393830 NULL 00000003 31393830 NULL 00000003 +31393830 31393830 NULL 00000000 31393830 NULL 00000000 +31393830 31393830 NULL 00000001 31393830 NULL 00000001 +31303030 31393830 NULL 00000002 31393830 NULL 00000002 +SELECT +hex(b | c), hex(b | 0x31393838), b | NULL, hex(b | 0b00000000000000000000000000001011), +hex(0x31393838 | b), NULL | b, hex(0b00000000000000000000000000001011 | b) +FROM t1; +hex(b | c) hex(b | 0x31393838) b | NULL hex(b | 0b00000000000000000000000000001011) hex(0x31393838 | b) NULL | b hex(0b00000000000000000000000000001011 | b) +31393837 31393839 NULL 3139383B 31393839 NULL 3139383B +3139383A 3139383A NULL 3139383B 3139383A NULL 3139383B +3139383B 3139383B NULL 3139383B 3139383B NULL 3139383B +31393835 3139383C NULL 3139383F 3139383C NULL 3139383F +31393837 3139383D NULL 3139383F 3139383D NULL 3139383F +3139383E 3139383E NULL 3139383F 3139383E NULL 3139383F +SELECT +hex(b ^ c), hex(b ^ 0x31393838), b ^ NULL, hex(b ^ 0b00000000000000000000000000001011), +hex(0x31393838 ^ b), NULL ^ b, hex(0b00000000000000000000000000001011 ^ b) +FROM t1; +hex(b ^ c) hex(b ^ 0x31393838) b ^ NULL hex(b ^ 0b00000000000000000000000000001011) hex(0x31393838 ^ b) NULL ^ b hex(0b00000000000000000000000000001011 ^ b) +00090806 00000009 NULL 3139383A 00000009 NULL 3139383A +0009080A 0000000A NULL 31393839 0000000A NULL 31393839 +0009080A 0000000B NULL 31393838 0000000B NULL 31393838 +00000005 0000000C NULL 3139383F 0000000C NULL 3139383F +00000007 0000000D NULL 3139383E 0000000D NULL 3139383E +0009080E 0000000E NULL 3139383D 0000000E NULL 3139383D +SELECT BIT_COUNT(b), HEX(~b), HEX(b << 1), HEX(b >> 1) from t1; +BIT_COUNT(b) HEX(~b) HEX(b << 1) HEX(b >> 1) +13 CEC6C7CE 62727062 189C9C18 +13 CEC6C7CD 62727064 189C9C19 +14 CEC6C7CC 62727066 189C9C19 +13 CEC6C7CB 62727068 189C9C1A +14 CEC6C7CA 6272706A 189C9C1A +14 CEC6C7C9 6272706C 189C9C1B +SELECT HEX(BIT_AND(b)), HEX(BIT_OR(b)), HEX(BIT_XOR(b)) FROM t1 GROUP BY a; +HEX(BIT_AND(b)) HEX(BIT_OR(b)) HEX(BIT_XOR(b)) +31393831 31393831 31393831 +31393832 31393832 31393832 +31393830 31393837 00000007 +31393835 31393835 31393835 +31393836 31393836 31393836 +SELECT HEX(BIT_AND(b)), HEX(BIT_OR(b)), HEX(BIT_XOR(b)) FROM t1; +HEX(BIT_AND(b)) HEX(BIT_OR(b)) HEX(BIT_XOR(b)) +31393830 31393837 00000007 +# +# stored procedures with warnings +# +CREATE PROCEDURE test_bin_op() +SELECT +HEX(b & c), HEX(b & 0x31393838), b & NULL, HEX(b & 0b00000000000000000000000000001011), +HEX(0x31393838 & b), NULL & b, HEX(0b00000000000000000000000000001011 & b), +HEX(b | c), HEX(b | 0x31393838), b | NULL, HEX(b | 0b00000000000000000000000000001011), +HEX(0x31393838 | b), NULL | b, HEX(0b00000000000000000000000000001011 | b), +HEX(b ^ c), HEX(b ^ 0x31393838), b ^ NULL, HEX(b ^ 0b00000000000000000000000000001011), +HEX(0x31393838 ^ b), NULL ^ b, HEX(0b00000000000000000000000000001011 ^ b), +BIT_COUNT(b), HEX(~b), HEX(b << 1), HEX(b >> 1) +FROM t1; +CALL test_bin_op(); +HEX(b & c) HEX(b & 0x31393838) b & NULL HEX(b & 0b00000000000000000000000000001011) HEX(0x31393838 & b) NULL & b HEX(0b00000000000000000000000000001011 & b) HEX(b | c) HEX(b | 0x31393838) b | NULL HEX(b | 0b00000000000000000000000000001011) HEX(0x31393838 | b) NULL | b HEX(0b00000000000000000000000000001011 | b) HEX(b ^ c) HEX(b ^ 0x31393838) b ^ NULL HEX(b ^ 0b00000000000000000000000000001011) HEX(0x31393838 ^ b) NULL ^ b HEX(0b00000000000000000000000000001011 ^ b) BIT_COUNT(b) HEX(~b) HEX(b << 1) HEX(b >> 1) +31303031 31393830 NULL 00000001 31393830 NULL 00000001 31393837 31393839 NULL 3139383B 31393839 NULL 3139383B 00090806 00000009 NULL 3139383A 00000009 NULL 3139383A 13 CEC6C7CE 62727062 189C9C18 +31303030 31393830 NULL 00000002 31393830 NULL 00000002 3139383A 3139383A NULL 3139383B 3139383A NULL 3139383B 0009080A 0000000A NULL 31393839 0000000A NULL 31393839 13 CEC6C7CD 62727064 189C9C19 +31303031 31393830 NULL 00000003 31393830 NULL 00000003 3139383B 3139383B NULL 3139383B 3139383B NULL 3139383B 0009080A 0000000B NULL 31393838 0000000B NULL 31393838 14 CEC6C7CC 62727066 189C9C19 +31393830 31393830 NULL 00000000 31393830 NULL 00000000 31393835 3139383C NULL 3139383F 3139383C NULL 3139383F 00000005 0000000C NULL 3139383F 0000000C NULL 3139383F 13 CEC6C7CB 62727068 189C9C1A +31393830 31393830 NULL 00000001 31393830 NULL 00000001 31393837 3139383D NULL 3139383F 3139383D NULL 3139383F 00000007 0000000D NULL 3139383E 0000000D NULL 3139383E 14 CEC6C7CA 6272706A 189C9C1A +31303030 31393830 NULL 00000002 31393830 NULL 00000002 3139383E 3139383E NULL 3139383F 3139383E NULL 3139383F 0009080E 0000000E NULL 3139383D 0000000E NULL 3139383D 14 CEC6C7C9 6272706C 189C9C1B +CALL test_bin_op(); +HEX(b & c) HEX(b & 0x31393838) b & NULL HEX(b & 0b00000000000000000000000000001011) HEX(0x31393838 & b) NULL & b HEX(0b00000000000000000000000000001011 & b) HEX(b | c) HEX(b | 0x31393838) b | NULL HEX(b | 0b00000000000000000000000000001011) HEX(0x31393838 | b) NULL | b HEX(0b00000000000000000000000000001011 | b) HEX(b ^ c) HEX(b ^ 0x31393838) b ^ NULL HEX(b ^ 0b00000000000000000000000000001011) HEX(0x31393838 ^ b) NULL ^ b HEX(0b00000000000000000000000000001011 ^ b) BIT_COUNT(b) HEX(~b) HEX(b << 1) HEX(b >> 1) +31303031 31393830 NULL 00000001 31393830 NULL 00000001 31393837 31393839 NULL 3139383B 31393839 NULL 3139383B 00090806 00000009 NULL 3139383A 00000009 NULL 3139383A 13 CEC6C7CE 62727062 189C9C18 +31303030 31393830 NULL 00000002 31393830 NULL 00000002 3139383A 3139383A NULL 3139383B 3139383A NULL 3139383B 0009080A 0000000A NULL 31393839 0000000A NULL 31393839 13 CEC6C7CD 62727064 189C9C19 +31303031 31393830 NULL 00000003 31393830 NULL 00000003 3139383B 3139383B NULL 3139383B 3139383B NULL 3139383B 0009080A 0000000B NULL 31393838 0000000B NULL 31393838 14 CEC6C7CC 62727066 189C9C19 +31393830 31393830 NULL 00000000 31393830 NULL 00000000 31393835 3139383C NULL 3139383F 3139383C NULL 3139383F 00000005 0000000C NULL 3139383F 0000000C NULL 3139383F 13 CEC6C7CB 62727068 189C9C1A +31393830 31393830 NULL 00000001 31393830 NULL 00000001 31393837 3139383D NULL 3139383F 3139383D NULL 3139383F 00000007 0000000D NULL 3139383E 0000000D NULL 3139383E 14 CEC6C7CA 6272706A 189C9C1A +31303030 31393830 NULL 00000002 31393830 NULL 00000002 3139383E 3139383E NULL 3139383F 3139383E NULL 3139383F 0009080E 0000000E NULL 3139383D 0000000E NULL 3139383D 14 CEC6C7C9 6272706C 189C9C1B +DROP PROCEDURE test_bin_op; +CREATE PROCEDURE test_bin_op() +SELECT HEX(BIT_AND(b)), HEX(BIT_OR(b)), HEX(BIT_XOR(b)) FROM t1 GROUP BY a; +CALL test_bin_op(); +HEX(BIT_AND(b)) HEX(BIT_OR(b)) HEX(BIT_XOR(b)) +31393831 31393831 31393831 +31393832 31393832 31393832 +31393830 31393837 00000007 +31393835 31393835 31393835 +31393836 31393836 31393836 +CALL test_bin_op(); +HEX(BIT_AND(b)) HEX(BIT_OR(b)) HEX(BIT_XOR(b)) +31393831 31393831 31393831 +31393832 31393832 31393832 +31393830 31393837 00000007 +31393835 31393835 31393835 +31393836 31393836 31393836 +DROP PROCEDURE test_bin_op; +CREATE PROCEDURE test_bin_op() +SELECT HEX(BIT_AND(b)), HEX(BIT_OR(b)), HEX(BIT_XOR(b)) FROM t1; +CALL test_bin_op(); +HEX(BIT_AND(b)) HEX(BIT_OR(b)) HEX(BIT_XOR(b)) +31393830 31393837 00000007 +CALL test_bin_op(); +HEX(BIT_AND(b)) HEX(BIT_OR(b)) HEX(BIT_XOR(b)) +31393830 31393837 00000007 +DROP PROCEDURE test_bin_op; +# +# prepared statements with warnings +# +PREPARE s1 FROM +"SELECT +HEX(b & c), HEX(b & 0x31393838), b & NULL, HEX(b & 0b00000000000000000000000000001011), +HEX(0x31393838 & b), NULL & b, HEX(0b00000000000000000000000000001011 & b), +HEX(b | c), HEX(b | 0x31393838), b | NULL, HEX(b | 0b00000000000000000000000000001011), +HEX(0x31393838 | b), NULL | b, HEX(0b00000000000000000000000000001011 | b), +HEX(b ^ c), HEX(b ^ 0x31393838), b ^ NULL, HEX(b ^ 0b00000000000000000000000000001011), +HEX(0x31393838 ^ b), NULL ^ b, HEX(0b00000000000000000000000000001011 ^ b), +BIT_COUNT(b), HEX( ~b), HEX(b << 1), HEX(b >> 1) +FROM t1;"; +EXECUTE s1; +HEX(b & c) HEX(b & 0x31393838) b & NULL HEX(b & 0b00000000000000000000000000001011) HEX(0x31393838 & b) NULL & b HEX(0b00000000000000000000000000001011 & b) HEX(b | c) HEX(b | 0x31393838) b | NULL HEX(b | 0b00000000000000000000000000001011) HEX(0x31393838 | b) NULL | b HEX(0b00000000000000000000000000001011 | b) HEX(b ^ c) HEX(b ^ 0x31393838) b ^ NULL HEX(b ^ 0b00000000000000000000000000001011) HEX(0x31393838 ^ b) NULL ^ b HEX(0b00000000000000000000000000001011 ^ b) BIT_COUNT(b) HEX( ~b) HEX(b << 1) HEX(b >> 1) +31303031 31393830 NULL 00000001 31393830 NULL 00000001 31393837 31393839 NULL 3139383B 31393839 NULL 3139383B 00090806 00000009 NULL 3139383A 00000009 NULL 3139383A 13 CEC6C7CE 62727062 189C9C18 +31303030 31393830 NULL 00000002 31393830 NULL 00000002 3139383A 3139383A NULL 3139383B 3139383A NULL 3139383B 0009080A 0000000A NULL 31393839 0000000A NULL 31393839 13 CEC6C7CD 62727064 189C9C19 +31303031 31393830 NULL 00000003 31393830 NULL 00000003 3139383B 3139383B NULL 3139383B 3139383B NULL 3139383B 0009080A 0000000B NULL 31393838 0000000B NULL 31393838 14 CEC6C7CC 62727066 189C9C19 +31393830 31393830 NULL 00000000 31393830 NULL 00000000 31393835 3139383C NULL 3139383F 3139383C NULL 3139383F 00000005 0000000C NULL 3139383F 0000000C NULL 3139383F 13 CEC6C7CB 62727068 189C9C1A +31393830 31393830 NULL 00000001 31393830 NULL 00000001 31393837 3139383D NULL 3139383F 3139383D NULL 3139383F 00000007 0000000D NULL 3139383E 0000000D NULL 3139383E 14 CEC6C7CA 6272706A 189C9C1A +31303030 31393830 NULL 00000002 31393830 NULL 00000002 3139383E 3139383E NULL 3139383F 3139383E NULL 3139383F 0009080E 0000000E NULL 3139383D 0000000E NULL 3139383D 14 CEC6C7C9 6272706C 189C9C1B +EXECUTE s1; +HEX(b & c) HEX(b & 0x31393838) b & NULL HEX(b & 0b00000000000000000000000000001011) HEX(0x31393838 & b) NULL & b HEX(0b00000000000000000000000000001011 & b) HEX(b | c) HEX(b | 0x31393838) b | NULL HEX(b | 0b00000000000000000000000000001011) HEX(0x31393838 | b) NULL | b HEX(0b00000000000000000000000000001011 | b) HEX(b ^ c) HEX(b ^ 0x31393838) b ^ NULL HEX(b ^ 0b00000000000000000000000000001011) HEX(0x31393838 ^ b) NULL ^ b HEX(0b00000000000000000000000000001011 ^ b) BIT_COUNT(b) HEX( ~b) HEX(b << 1) HEX(b >> 1) +31303031 31393830 NULL 00000001 31393830 NULL 00000001 31393837 31393839 NULL 3139383B 31393839 NULL 3139383B 00090806 00000009 NULL 3139383A 00000009 NULL 3139383A 13 CEC6C7CE 62727062 189C9C18 +31303030 31393830 NULL 00000002 31393830 NULL 00000002 3139383A 3139383A NULL 3139383B 3139383A NULL 3139383B 0009080A 0000000A NULL 31393839 0000000A NULL 31393839 13 CEC6C7CD 62727064 189C9C19 +31303031 31393830 NULL 00000003 31393830 NULL 00000003 3139383B 3139383B NULL 3139383B 3139383B NULL 3139383B 0009080A 0000000B NULL 31393838 0000000B NULL 31393838 14 CEC6C7CC 62727066 189C9C19 +31393830 31393830 NULL 00000000 31393830 NULL 00000000 31393835 3139383C NULL 3139383F 3139383C NULL 3139383F 00000005 0000000C NULL 3139383F 0000000C NULL 3139383F 13 CEC6C7CB 62727068 189C9C1A +31393830 31393830 NULL 00000001 31393830 NULL 00000001 31393837 3139383D NULL 3139383F 3139383D NULL 3139383F 00000007 0000000D NULL 3139383E 0000000D NULL 3139383E 14 CEC6C7CA 6272706A 189C9C1A +31303030 31393830 NULL 00000002 31393830 NULL 00000002 3139383E 3139383E NULL 3139383F 3139383E NULL 3139383F 0009080E 0000000E NULL 3139383D 0000000E NULL 3139383D 14 CEC6C7C9 6272706C 189C9C1B +PREPARE s2 from "SELECT HEX(BIT_AND(b)), HEX(BIT_OR(b)), HEX(BIT_XOR(b)) FROM t1 GROUP BY a"; +EXECUTE s2; +HEX(BIT_AND(b)) HEX(BIT_OR(b)) HEX(BIT_XOR(b)) +31393831 31393831 31393831 +31393832 31393832 31393832 +31393830 31393837 00000007 +31393835 31393835 31393835 +31393836 31393836 31393836 +EXECUTE s2; +HEX(BIT_AND(b)) HEX(BIT_OR(b)) HEX(BIT_XOR(b)) +31393831 31393831 31393831 +31393832 31393832 31393832 +31393830 31393837 00000007 +31393835 31393835 31393835 +31393836 31393836 31393836 +PREPARE s2 from "SELECT HEX(BIT_AND(b)), HEX(BIT_OR(b)), HEX(BIT_XOR(b)) FROM t1"; +EXECUTE s2; +HEX(BIT_AND(b)) HEX(BIT_OR(b)) HEX(BIT_XOR(b)) +31393830 31393837 00000007 +EXECUTE s2; +HEX(BIT_AND(b)) HEX(BIT_OR(b)) HEX(BIT_XOR(b)) +31393830 31393837 00000007 +# +# views with warnings +# +CREATE VIEW v1 AS +SELECT +HEX(b & c), HEX(b & 0x31393838), b & NULL, HEX(b & 0b00000000000000000000000000001011), +HEX(0x31393838 & b), NULL & b, HEX(0b00000000000000000000000000001011 & b), +HEX(b | c), HEX(b | 0x31393838), b | NULL, HEX(b | 0b00000000000000000000000000001011), +HEX(0x31393838 | b), NULL | b, HEX(0b00000000000000000000000000001011 | b), +HEX(b ^ c), HEX(b ^ 0x31393838), b ^ NULL, HEX(b ^ 0b00000000000000000000000000001011), +HEX(0x31393838 ^ b), NULL ^ b, HEX(0b00000000000000000000000000001011 ^ b), +BIT_COUNT(b), HEX(~b), HEX(b << 1), HEX(b >> 1) +FROM t1; +SELECT * from v1; +HEX(b & c) HEX(b & 0x31393838) b & NULL HEX(b & 0b00000000000000000000000000001011) HEX(0x31393838 & b) NULL & b HEX(0b00000000000000000000000000001011 & b) HEX(b | c) HEX(b | 0x31393838) b | NULL HEX(b | 0b00000000000000000000000000001011) HEX(0x31393838 | b) NULL | b HEX(0b00000000000000000000000000001011 | b) HEX(b ^ c) HEX(b ^ 0x31393838) b ^ NULL HEX(b ^ 0b00000000000000000000000000001011) HEX(0x31393838 ^ b) NULL ^ b HEX(0b00000000000000000000000000001011 ^ b) BIT_COUNT(b) HEX(~b) HEX(b << 1) HEX(b >> 1) +31303031 31393830 NULL 00000001 31393830 NULL 00000001 31393837 31393839 NULL 3139383B 31393839 NULL 3139383B 00090806 00000009 NULL 3139383A 00000009 NULL 3139383A 13 CEC6C7CE 62727062 189C9C18 +31303030 31393830 NULL 00000002 31393830 NULL 00000002 3139383A 3139383A NULL 3139383B 3139383A NULL 3139383B 0009080A 0000000A NULL 31393839 0000000A NULL 31393839 13 CEC6C7CD 62727064 189C9C19 +31303031 31393830 NULL 00000003 31393830 NULL 00000003 3139383B 3139383B NULL 3139383B 3139383B NULL 3139383B 0009080A 0000000B NULL 31393838 0000000B NULL 31393838 14 CEC6C7CC 62727066 189C9C19 +31393830 31393830 NULL 00000000 31393830 NULL 00000000 31393835 3139383C NULL 3139383F 3139383C NULL 3139383F 00000005 0000000C NULL 3139383F 0000000C NULL 3139383F 13 CEC6C7CB 62727068 189C9C1A +31393830 31393830 NULL 00000001 31393830 NULL 00000001 31393837 3139383D NULL 3139383F 3139383D NULL 3139383F 00000007 0000000D NULL 3139383E 0000000D NULL 3139383E 14 CEC6C7CA 6272706A 189C9C1A +31303030 31393830 NULL 00000002 31393830 NULL 00000002 3139383E 3139383E NULL 3139383F 3139383E NULL 3139383F 0009080E 0000000E NULL 3139383D 0000000E NULL 3139383D 14 CEC6C7C9 6272706C 189C9C1B +SELECT * from v1; +HEX(b & c) HEX(b & 0x31393838) b & NULL HEX(b & 0b00000000000000000000000000001011) HEX(0x31393838 & b) NULL & b HEX(0b00000000000000000000000000001011 & b) HEX(b | c) HEX(b | 0x31393838) b | NULL HEX(b | 0b00000000000000000000000000001011) HEX(0x31393838 | b) NULL | b HEX(0b00000000000000000000000000001011 | b) HEX(b ^ c) HEX(b ^ 0x31393838) b ^ NULL HEX(b ^ 0b00000000000000000000000000001011) HEX(0x31393838 ^ b) NULL ^ b HEX(0b00000000000000000000000000001011 ^ b) BIT_COUNT(b) HEX(~b) HEX(b << 1) HEX(b >> 1) +31303031 31393830 NULL 00000001 31393830 NULL 00000001 31393837 31393839 NULL 3139383B 31393839 NULL 3139383B 00090806 00000009 NULL 3139383A 00000009 NULL 3139383A 13 CEC6C7CE 62727062 189C9C18 +31303030 31393830 NULL 00000002 31393830 NULL 00000002 3139383A 3139383A NULL 3139383B 3139383A NULL 3139383B 0009080A 0000000A NULL 31393839 0000000A NULL 31393839 13 CEC6C7CD 62727064 189C9C19 +31303031 31393830 NULL 00000003 31393830 NULL 00000003 3139383B 3139383B NULL 3139383B 3139383B NULL 3139383B 0009080A 0000000B NULL 31393838 0000000B NULL 31393838 14 CEC6C7CC 62727066 189C9C19 +31393830 31393830 NULL 00000000 31393830 NULL 00000000 31393835 3139383C NULL 3139383F 3139383C NULL 3139383F 00000005 0000000C NULL 3139383F 0000000C NULL 3139383F 13 CEC6C7CB 62727068 189C9C1A +31393830 31393830 NULL 00000001 31393830 NULL 00000001 31393837 3139383D NULL 3139383F 3139383D NULL 3139383F 00000007 0000000D NULL 3139383E 0000000D NULL 3139383E 14 CEC6C7CA 6272706A 189C9C1A +31303030 31393830 NULL 00000002 31393830 NULL 00000002 3139383E 3139383E NULL 3139383F 3139383E NULL 3139383F 0009080E 0000000E NULL 3139383D 0000000E NULL 3139383D 14 CEC6C7C9 6272706C 189C9C1B +CREATE VIEW v2 AS +SELECT HEX(BIT_AND(b)), HEX(BIT_OR(b)), HEX(BIT_XOR(b)) FROM t1 GROUP BY a; +SELECT * from v2; +HEX(BIT_AND(b)) HEX(BIT_OR(b)) HEX(BIT_XOR(b)) +31393831 31393831 31393831 +31393832 31393832 31393832 +31393830 31393837 00000007 +31393835 31393835 31393835 +31393836 31393836 31393836 +SELECT * from v2; +HEX(BIT_AND(b)) HEX(BIT_OR(b)) HEX(BIT_XOR(b)) +31393831 31393831 31393831 +31393832 31393832 31393832 +31393830 31393837 00000007 +31393835 31393835 31393835 +31393836 31393836 31393836 +CREATE VIEW v3 AS +SELECT HEX(BIT_AND(b)), HEX(BIT_OR(b)), HEX(BIT_XOR(b)) FROM t1; +SELECT * from v3; +HEX(BIT_AND(b)) HEX(BIT_OR(b)) HEX(BIT_XOR(b)) +31393830 31393837 00000007 +SELECT * from v3; +HEX(BIT_AND(b)) HEX(BIT_OR(b)) HEX(BIT_XOR(b)) +31393830 31393837 00000007 +DROP VIEW v1,v2,v3; +# +# working as before +# +SELECT +a & 0x31393838, 0x31393838 & a, 0x31393838 & 0x31393838, 0x31393838 & NULL, +0x31393838 & 0b1011, NULL & 0x31393838, 0b1011 & 0x31393838, NULL & NULL, +NULL & 0b1011, 0b1011 & NULL, 0b1011 & 0b1011, BIT_COUNT(a) +FROM t1; +a & 0x31393838 0x31393838 & a 0x31393838 & 0x31393838 0x31393838 & NULL 0x31393838 & 0b1011 NULL & 0x31393838 0b1011 & 0x31393838 NULL & NULL NULL & 0b1011 0b1011 & NULL 0b1011 & 0b1011 BIT_COUNT(a) +0 0 825833528 NULL 8 NULL 8 NULL NULL NULL 11 1 +0 0 825833528 NULL 8 NULL 8 NULL NULL NULL 11 1 +0 0 825833528 NULL 8 NULL 8 NULL NULL NULL 11 2 +0 0 825833528 NULL 8 NULL 8 NULL NULL NULL 11 2 +0 0 825833528 NULL 8 NULL 8 NULL NULL NULL 11 1 +0 0 825833528 NULL 8 NULL 8 NULL NULL NULL 11 2 +SELECT +a | 0x31393838, 0x31393838 | a, 0x31393838 | 0x31393838, 0x31393838 | NULL, +0x31393838 | 0b1011, NULL | 0x31393838, 0b1011 | 0x31393838, NULL | NULL, +NULL | 0b1011, 0b1011 | NULL, 0b1011 | 0b1011 +FROM t1; +a | 0x31393838 0x31393838 | a 0x31393838 | 0x31393838 0x31393838 | NULL 0x31393838 | 0b1011 NULL | 0x31393838 0b1011 | 0x31393838 NULL | NULL NULL | 0b1011 0b1011 | NULL 0b1011 | 0b1011 +825833529 825833529 825833528 NULL 825833531 NULL 825833531 NULL NULL NULL 11 +825833530 825833530 825833528 NULL 825833531 NULL 825833531 NULL NULL NULL 11 +825833531 825833531 825833528 NULL 825833531 NULL 825833531 NULL NULL NULL 11 +825833531 825833531 825833528 NULL 825833531 NULL 825833531 NULL NULL NULL 11 +825833532 825833532 825833528 NULL 825833531 NULL 825833531 NULL NULL NULL 11 +825833533 825833533 825833528 NULL 825833531 NULL 825833531 NULL NULL NULL 11 +SELECT +a ^ 0x31393838, 0x31393838 ^ a, 0x31393838 ^ 0x31393838, 0x31393838 ^ NULL, +0x31393838 ^ 0b1011, NULL ^ 0x31393838, 0b1011 ^ 0x31393838, NULL ^ NULL, +NULL ^ 0b1011, 0b1011 ^ NULL, 0b1011 ^ 0b1011 +FROM t1; +a ^ 0x31393838 0x31393838 ^ a 0x31393838 ^ 0x31393838 0x31393838 ^ NULL 0x31393838 ^ 0b1011 NULL ^ 0x31393838 0b1011 ^ 0x31393838 NULL ^ NULL NULL ^ 0b1011 0b1011 ^ NULL 0b1011 ^ 0b1011 +825833529 825833529 0 NULL 825833523 NULL 825833523 NULL NULL NULL 0 +825833530 825833530 0 NULL 825833523 NULL 825833523 NULL NULL NULL 0 +825833531 825833531 0 NULL 825833523 NULL 825833523 NULL NULL NULL 0 +825833531 825833531 0 NULL 825833523 NULL 825833523 NULL NULL NULL 0 +825833532 825833532 0 NULL 825833523 NULL 825833523 NULL NULL NULL 0 +825833533 825833533 0 NULL 825833523 NULL 825833523 NULL NULL NULL 0 +SELECT a, BIT_AND(a), BIT_OR(a), BIT_XOR(a), +~NULL, NULL << 1, NULL >> 1, 1 << NULL, 1 >> NULL, +~0x31393838, 0x31393838 << 1, 0x31393838 >> 1, +~0b1011, 0b1011 << 1, 0b1011 >> 1 +FROM t1 +GROUP BY a; +a BIT_AND(a) BIT_OR(a) BIT_XOR(a) ~NULL NULL << 1 NULL >> 1 1 << NULL 1 >> NULL ~0x31393838 0x31393838 << 1 0x31393838 >> 1 ~0b1011 0b1011 << 1 0b1011 >> 1 +1 1 1 1 NULL NULL NULL NULL NULL 18446744072883718087 1651667056 412916764 18446744073709551604 22 5 +2 2 2 2 NULL NULL NULL NULL NULL 18446744072883718087 1651667056 412916764 18446744073709551604 22 5 +3 3 3 0 NULL NULL NULL NULL NULL 18446744072883718087 1651667056 412916764 18446744073709551604 22 5 +4 4 4 4 NULL NULL NULL NULL NULL 18446744072883718087 1651667056 412916764 18446744073709551604 22 5 +5 5 5 5 NULL NULL NULL NULL NULL 18446744072883718087 1651667056 412916764 18446744073709551604 22 5 +# +# binary/varbinary vs char/varchar +# +SELECT '12' | '12'; +Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr +def '12' | '12' 8 21 2 N 32929 0 63 +'12' | '12' +12 +SELECT _binary '12' | '12'; +Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr +def _binary '12' | '12' 8 21 2 N 32929 0 63 +_binary '12' | '12' +12 +SELECT _binary '12' | _binary '12'; +Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr +def _binary '12' | _binary '12' 253 2 2 N 129 31 63 +_binary '12' | _binary '12' +12 +SELECT _binary '12' | 0x0001; +Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr +def _binary '12' | 0x0001 253 2 2 N 129 31 63 +_binary '12' | 0x0001 +13 +SELECT _binary '12' | 1; +Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr +def _binary '12' | 1 8 21 2 N 32929 0 63 +_binary '12' | 1 +13 +SELECT binary '12' | '12'; +Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr +def binary '12' | '12' 8 21 2 Y 32928 0 63 +binary '12' | '12' +12 +SELECT binary '12' | binary '12'; +Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr +def binary '12' | binary '12' 253 8 2 Y 128 31 63 +binary '12' | binary '12' +12 +SELECT binary '12' | 0x0001; +Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr +def binary '12' | 0x0001 253 8 2 Y 128 31 63 +binary '12' | 0x0001 +13 +SELECT binary '12' | 1; +Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr +def binary '12' | 1 8 21 2 Y 32928 0 63 +binary '12' | 1 +13 +SELECT '12' | 0x01; +Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr +def '12' | 0x01 8 21 2 N 32929 0 63 +'12' | 0x01 +13 +SELECT '12' | 1; +Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr +def '12' | 1 8 21 2 N 32929 0 63 +'12' | 1 +13 +SELECT CAST('12' AS binary) | 0x0001; +Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr +def CAST('12' AS binary) | 0x0001 253 8 2 Y 128 31 63 +CAST('12' AS binary) | 0x0001 +13 +SELECT CAST('12' AS binary) | 1; +Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr +def CAST('12' AS binary) | 1 8 21 2 Y 32928 0 63 +CAST('12' AS binary) | 1 +13 +SELECT CAST(b AS char) | 0x31393838 FROM t1 LIMIT 1; +Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr +def CAST(b AS char) | 0x31393838 CAST(b AS char) | 0x31393838 8 21 9 Y 32800 0 63 +CAST(b AS char) | 0x31393838 +825835453 +SELECT (b + 0) | 0x31393838 FROM t1 LIMIT 1; +Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr +def (b + 0) | 0x31393838 (b + 0) | 0x31393838 8 21 9 Y 32800 0 63 +(b + 0) | 0x31393838 +825835453 +SELECT CAST(0x01 AS char) | 0x31393838 FROM t1 LIMIT 1; +Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr +def CAST(0x01 AS char) | 0x31393838 8 21 9 Y 32928 0 63 +CAST(0x01 AS char) | 0x31393838 +825833528 +SELECT 0x01 << 1; +Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr +def 0x01 << 1 8 21 1 N 32929 0 63 +0x01 << 1 +2 +SELECT _binary '12' << 1; +Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr +def _binary '12' << 1 253 2 2 N 129 31 63 +_binary '12' << 1 +bd +SELECT binary '12' << 1; +Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr +def binary '12' << 1 253 8 2 Y 128 31 63 +binary '12' << 1 +bd +SELECT CAST('12' AS binary) << 1; +Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr +def CAST('12' AS binary) << 1 253 8 2 Y 128 31 63 +CAST('12' AS binary) << 1 +bd +SELECT CAST(b AS char) << 1 FROM t1 LIMIT 1; +Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr +def CAST(b AS char) << 1 CAST(b AS char) << 1 8 21 4 Y 32800 0 63 +CAST(b AS char) << 1 +3962 +SELECT CAST(b AS unsigned) << 1 FROM t1 LIMIT 1; +Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr +def CAST(b AS unsigned) << 1 CAST(b AS unsigned) << 1 8 21 4 Y 32800 0 63 +CAST(b AS unsigned) << 1 +3962 +SELECT (b + 0) << 1 FROM t1 LIMIT 1; +Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr +def (b + 0) << 1 (b + 0) << 1 8 21 4 Y 32800 0 63 +(b + 0) << 1 +3962 +SELECT CAST(b AS unsigned) | 0x31393838 FROM t1 LIMIT 1; +Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr +def CAST(b AS unsigned) | 0x31393838 CAST(b AS unsigned) | 0x31393838 8 21 9 Y 32800 0 63 +CAST(b AS unsigned) | 0x31393838 +825835453 +SELECT CAST(b AS unsigned) | CAST(c AS unsigned) FROM t1 LIMIT 1; +Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr +def CAST(b AS unsigned) | CAST(c AS unsigned) CAST(b AS unsigned) | CAST(c AS unsigned) 8 21 4 Y 32800 0 63 +CAST(b AS unsigned) | CAST(c AS unsigned) +2047 +DROP TABLE t1; +PREPARE ps FROM 'SELECT (~?)'; +SET @a:=0; +EXECUTE ps USING @a; +(~?) +18446744073709551615 +SET @a:='abcd'; +EXECUTE ps USING @a; +(~?) +18446744073709551615 +Warnings: +Warning 1292 Truncated incorrect INTEGER value: 'abcd' +SET @a:=_binary 'abcd'; +EXECUTE ps USING @a; +(~?) +18446744073709551615 +Warnings: +Warning 1292 Truncated incorrect INTEGER value: 'abcd' +SET @a:=34; +EXECUTE ps USING @a; +(~?) +18446744073709551581 +SELECT (_binary x'31' | x'31'); +(_binary x'31' | x'31') +1 +SELECT _binary '1' + 0; +_binary '1' + 0 +1 +SELECT (_binary x'31' | x'31') + 0; +(_binary x'31' | x'31') + 0 +1 +SELECT 1.0 * (_binary x'312E35' | x'312E35'); +1.0 * (_binary x'312E35' | x'312E35') +1.5 +SELECT 1.0 * (x'312E35' | x'312E35'); +1.0 * (x'312E35' | x'312E35') +3223093.0 +SELECT HEX(_binary 0x0003 << (_binary 0x38 | NULL)); +HEX(_binary 0x0003 << (_binary 0x38 | NULL)) +NULL +SELECT (_binary x'31' | NULL) + 0; +(_binary x'31' | NULL) + 0 +NULL +SELECT CONCAT("", (0x39 | NULL)); +CONCAT("", (0x39 | NULL)) +NULL +SELECT ~(CONCAT ("", NULL)); +~(CONCAT ("", NULL)) +NULL +# +# Testing datetime and time without warnings +# +SELECT DATEDIFF((_binary '2012-05-19 09:06:07' | _binary '2012-05-19 09:06:07'), '2012-05-21 09:06:07'); +DATEDIFF((_binary '2012-05-19 09:06:07' | _binary '2012-05-19 09:06:07'), '2012-05-21 09:06:07') +-2 +SELECT DATEDIFF(20120519090607 | 20120519090607, '2012-05-21 09:06:07'); +DATEDIFF(20120519090607 | 20120519090607, '2012-05-21 09:06:07') +-2 +SELECT DATEDIFF(20120519090607, '2012-05-21 09:06:07'); +DATEDIFF(20120519090607, '2012-05-21 09:06:07') +-2 +SELECT SUBTIME((_binary '2012-05-19 09:06:07' | _binary '2012-05-19 09:06:07'),'1 1:1:1.000002'); +SUBTIME((_binary '2012-05-19 09:06:07' | _binary '2012-05-19 09:06:07'),'1 1:1:1.000002') +2012-05-18 08:05:05.999998 +SELECT SUBTIME(20120519090607 | 20120519090607 ,'1 1:1:1.000002'); +SUBTIME(20120519090607 | 20120519090607 ,'1 1:1:1.000002') +2012-05-18 08:05:05.999998 +SELECT SUBTIME(20120519090607 ,'1 1:1:1.000002'); +SUBTIME(20120519090607 ,'1 1:1:1.000002') +2012-05-18 08:05:05.999998 +# +# Testing datetime and time with warnings +# +SELECT DATEDIFF((_binary '12012-05-19 09:06:07' | _binary '12012-05-19 09:06:07'), '2012-05-21 09:06:07'); +DATEDIFF((_binary '12012-05-19 09:06:07' | _binary '12012-05-19 09:06:07'), '2012-05-21 09:06:07') +NULL +Warnings: +Warning 1292 Incorrect datetime value: '12012-05-19 09:06:07' +SELECT DATEDIFF(120120519090607 | 120120519090607, '2012-05-21 09:06:07'); +DATEDIFF(120120519090607 | 120120519090607, '2012-05-21 09:06:07') +NULL +Warnings: +Warning 1292 Incorrect datetime value: '120120519090607' +SELECT DATEDIFF(120120519090607, '12012-05-21 09:06:07'); +DATEDIFF(120120519090607, '12012-05-21 09:06:07') +NULL +Warnings: +Warning 1292 Incorrect datetime value: '120120519090607' +Warning 1292 Incorrect datetime value: '12012-05-21 09:06:07' +SELECT SUBTIME((_binary '12007-12-31 23:59:59.999999' | _binary '12007-12-31 23:59:59.999999'),'1 1:1:1.000002'); +SUBTIME((_binary '12007-12-31 23:59:59.999999' | _binary '12007-12-31 23:59:59.999999'),'1 1:1:1.000002') +NULL +Warnings: +Warning 1292 Truncated incorrect time value: '12007-12-31 23:59:59.999999' +SELECT SUBTIME(120120519090607 | 120120519090607 ,'1 1:1:1.000002'); +SUBTIME(120120519090607 | 120120519090607 ,'1 1:1:1.000002') +NULL +Warnings: +Warning 1292 Truncated incorrect time value: '120120519090607' +SELECT SUBTIME(120120519090607 ,'1 1:1:1.000002'); +SUBTIME(120120519090607 ,'1 1:1:1.000002') +NULL +Warnings: +Warning 1292 Truncated incorrect time value: '120120519090607' +CREATE TABLE t1(gid INT, a VARBINARY(20), b BIGINT); +INSERT INTO t1 VALUES(1, _binary '2012-05-19 09:06:07', 20120519090607), +(1, _binary '2012-05-19 09:06:07', 20120519090607), +(2, _binary '12012-05-19 09:06:07', 120120519090607), +(2, _binary '12012-05-19 09:06:07', 120120519090607); +SELECT DATEDIFF(BIT_OR(a), '2012-05-21 09:06:07') FROM t1 GROUP BY gid; +DATEDIFF(BIT_OR(a), '2012-05-21 09:06:07') +-2 +NULL +Warnings: +Warning 1292 Incorrect datetime value: '12012-05-19 09:06:07' +SELECT DATEDIFF(BIT_OR(b), '2012-05-21 09:06:07') FROM t1 GROUP BY gid; +DATEDIFF(BIT_OR(b), '2012-05-21 09:06:07') +-2 +NULL +Warnings: +Warning 1292 Incorrect datetime value: '120120519090607' +SELECT DATEDIFF(BIT_OR(a), '2012-05-21 09:06:07') FROM t1 WHERE gid = 1; +DATEDIFF(BIT_OR(a), '2012-05-21 09:06:07') +-2 +SELECT DATEDIFF(BIT_OR(b), '2012-05-21 09:06:07') FROM t1 WHERE gid = 1; +DATEDIFF(BIT_OR(b), '2012-05-21 09:06:07') +-2 +SELECT DATEDIFF(BIT_OR(a), '2012-05-21 09:06:07') FROM t1 WHERE gid = 2; +DATEDIFF(BIT_OR(a), '2012-05-21 09:06:07') +NULL +Warnings: +Warning 1292 Incorrect datetime value: '12012-05-19 09:06:07' +SELECT DATEDIFF(BIT_OR(b), '2012-05-21 09:06:07') FROM t1 WHERE gid = 2; +DATEDIFF(BIT_OR(b), '2012-05-21 09:06:07') +NULL +Warnings: +Warning 1292 Incorrect datetime value: '120120519090607' +SELECT SUBTIME(BIT_OR(a), '1 1:1:1.000002') FROM t1 GROUP BY gid; +SUBTIME(BIT_OR(a), '1 1:1:1.000002') +2012-05-18 08:05:05.999998 +NULL +Warnings: +Warning 1292 Truncated incorrect time value: '12012-05-19 09:06:07' +SELECT SUBTIME(BIT_OR(b), '1 1:1:1.000002') FROM t1 GROUP BY gid; +SUBTIME(BIT_OR(b), '1 1:1:1.000002') +2012-05-18 08:05:05.999998 +NULL +Warnings: +Warning 1292 Truncated incorrect time value: '120120519090607' +SELECT SUBTIME(BIT_OR(a), '1 1:1:1.000002') FROM t1 WHERE gid = 1; +SUBTIME(BIT_OR(a), '1 1:1:1.000002') +2012-05-18 08:05:05.999998 +SELECT SUBTIME(BIT_OR(b), '1 1:1:1.000002') FROM t1 WHERE gid = 1; +SUBTIME(BIT_OR(b), '1 1:1:1.000002') +2012-05-18 08:05:05.999998 +SELECT SUBTIME(BIT_OR(a), '1 1:1:1.000002') FROM t1 WHERE gid = 2; +SUBTIME(BIT_OR(a), '1 1:1:1.000002') +NULL +Warnings: +Warning 1292 Truncated incorrect time value: '12012-05-19 09:06:07' +SELECT SUBTIME(BIT_OR(b), '1 1:1:1.000002') FROM t1 WHERE gid = 2; +SUBTIME(BIT_OR(b), '1 1:1:1.000002') +NULL +Warnings: +Warning 1292 Truncated incorrect time value: '120120519090607' +DROP TABLE t1; +# +# Test conversions +# +CREATE TABLE t1(vb varbinary(10), i INT, d DECIMAL(5,2), f FLOAT(5,2), dd DOUBLE(5,2), gid INT); +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (_binary "-98765.23", 98765, 0.0, 0.0, 0.0, 1); +INSERT INTO t1 VALUES (_binary "-98765.23", 98765, 1.0, 1.0, 1.0, 2); +SELECT +d + (vb | vb) , f + (vb | vb), dd + (vb | vb), CAST((vb | vb) AS DECIMAL(10,2)), +d + (i | i) , f + (i | i), dd + (i | i), CAST((i | i) AS DECIMAL(10,2)) +FROM t1 +WHERE gid = 1; +d + (vb | vb) f + (vb | vb) dd + (vb | vb) CAST((vb | vb) AS DECIMAL(10,2)) d + (i | i) f + (i | i) dd + (i | i) CAST((i | i) AS DECIMAL(10,2)) +-98765.23 -98765.23 -98765.23 -98765.23 98765.00 98765.00 98765.00 98765.00 +SELECT +d * (vb | vb) , f * (vb | vb), dd * (vb | vb), +(vb | vb) / d , (vb | vb) / f, (vb | vb) / dd, +d * (i | i) , f * (i | i), dd * (i | i), +(i | i) / d , (i | i) / f, (i | i) / dd +FROM t1 WHERE gid = 2; +d * (vb | vb) f * (vb | vb) dd * (vb | vb) (vb | vb) / d (vb | vb) / f (vb | vb) / dd d * (i | i) f * (i | i) dd * (i | i) (i | i) / d (i | i) / f (i | i) / dd +-98765.23 -98765.23 -98765.23 -98765.23 -98765.23 -98765.23 98765.00 98765.00 98765.00 98765.0000 98765.000000 98765.000000 +SET sql_mode=''; +SELECT +d + BIT_OR(vb), f + BIT_OR(vb), dd + BIT_OR(vb), CAST(BIT_OR(vb) AS DECIMAL(10,2)), +d + BIT_OR(i), f + BIT_OR(i), dd + BIT_OR(i), CAST(BIT_OR(i) AS DECIMAL(10,2)) +FROM t1 +WHERE gid= 1; +d + BIT_OR(vb) f + BIT_OR(vb) dd + BIT_OR(vb) CAST(BIT_OR(vb) AS DECIMAL(10,2)) d + BIT_OR(i) f + BIT_OR(i) dd + BIT_OR(i) CAST(BIT_OR(i) AS DECIMAL(10,2)) +-98765.23 -98765.23 -98765.23 -98765.23 98765.00 98765.00 98765.00 98765.00 +SELECT +d * BIT_OR(vb), f * BIT_OR(vb), dd * BIT_OR(vb), BIT_OR(vb) / d, +CAST(BIT_OR(vb) AS DECIMAL(10,2)), BIT_OR(vb) / f, BIT_OR(vb) / dd, +d * BIT_OR(i), f * BIT_OR(i), dd * BIT_OR(i), BIT_OR(i) / d, +CAST(BIT_OR(i) AS DECIMAL(10,2)), BIT_OR(i) / f, BIT_OR(i) / dd +FROM t1 +WHERE gid= 2; +d * BIT_OR(vb) f * BIT_OR(vb) dd * BIT_OR(vb) BIT_OR(vb) / d CAST(BIT_OR(vb) AS DECIMAL(10,2)) BIT_OR(vb) / f BIT_OR(vb) / dd d * BIT_OR(i) f * BIT_OR(i) dd * BIT_OR(i) BIT_OR(i) / d CAST(BIT_OR(i) AS DECIMAL(10,2)) BIT_OR(i) / f BIT_OR(i) / dd +-98765.23 -98765.23 -98765.23 -98765.230000 -98765.23 -98765.230000 -98765.230000 98765.00 98765.00 98765.00 98765.0000 98765.00 98765.000000 98765.000000 +SELECT +d + BIT_OR(vb), f + BIT_OR(vb), dd + BIT_OR(vb), +d + BIT_OR(i), f + BIT_OR(i), dd + BIT_OR(i) +FROM t1 +WHERE gid= 1 +GROUP BY gid; +d + BIT_OR(vb) f + BIT_OR(vb) dd + BIT_OR(vb) d + BIT_OR(i) f + BIT_OR(i) dd + BIT_OR(i) +-98765.23 -98765.23 -98765.23 98765.00 98765.00 98765.00 +SELECT +d * BIT_OR(vb), f * BIT_OR(vb), dd * BIT_OR(vb), BIT_OR(vb) / d, +BIT_OR(vb) / f, BIT_OR(vb) / dd, +d * BIT_OR(i), f * BIT_OR(i), dd * BIT_OR(i), BIT_OR(i) / d, +BIT_OR(i) / f, BIT_OR(i) / dd +FROM t1 +WHERE gid= 2 +GROUP BY gid; +d * BIT_OR(vb) f * BIT_OR(vb) dd * BIT_OR(vb) BIT_OR(vb) / d BIT_OR(vb) / f BIT_OR(vb) / dd d * BIT_OR(i) f * BIT_OR(i) dd * BIT_OR(i) BIT_OR(i) / d BIT_OR(i) / f BIT_OR(i) / dd +-98765.23 -98765.23 -98765.23 -98765.230000 -98765.230000 -98765.230000 98765.00 98765.00 98765.00 98765.0000 98765.000000 98765.000000 +drop table t1; diff --git a/mysql-test/r/view.result-pq b/mysql-test/r/view.result-pq new file mode 100644 index 000000000000..2ee7492467b0 --- /dev/null +++ b/mysql-test/r/view.result-pq @@ -0,0 +1,6745 @@ +drop table if exists t1,t2,t3,t4,t9,`t1a``b`,v1,v2,v3,v4,v5,v6; +drop view if exists t1,t2,`t1a``b`,v1,v2,v3,v4,v5,v6; +drop database if exists mysqltest; +use test; +create view v1 (c,d) as select a,b from t1; +ERROR 42S02: Table 'test.t1' doesn't exist +create temporary table t1 (a int, b int); +create view v1 (c) as select b+1 from t1; +ERROR HY000: View's SELECT refers to a temporary table 't1' +drop table t1; +create table t1 (a int, b int); +insert into t1 values (1,2), (1,3), (2,4), (2,5), (3,10); +create view v1 (c,d) as select a,b+@@global.max_user_connections from t1; +ERROR HY000: View's SELECT contains a variable or parameter +create view v1 (c,d) as select a,b from t1 +where a = @@global.max_user_connections; +ERROR HY000: View's SELECT contains a variable or parameter +CREATE VIEW v1 AS SELECT @a=1 FROM DUAL; +ERROR HY000: View's SELECT contains a variable or parameter +CREATE VIEW v1 AS SELECT 1 FROM DUAL WHERE @a>1; +ERROR HY000: View's SELECT contains a variable or parameter +CREATE VIEW v1 AS SELECT (@a:= 1) AS one FROM DUAL; +ERROR HY000: View's SELECT contains a variable or parameter +CREATE VIEW v1 AS SELECT 1 FROM DUAL WHERE (@a:= 1); +ERROR HY000: View's SELECT contains a variable or parameter +create view v1 (c) as select b+1 from t1; +select c from v1; +c +3 +4 +5 +6 +11 +select is_updatable from information_schema.views where table_name='v1'; +IS_UPDATABLE +NO +create temporary table t1 (a int, b int); +select * from t1; +a b +select c from v1; +c +3 +4 +5 +6 +11 +show create table v1; +View Create View character_set_client collation_connection +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` (`c`) AS select (`t1`.`b` + 1) AS `b+1` from `t1` utf8mb4 utf8mb4_0900_ai_ci +show create view v1; +View Create View character_set_client collation_connection +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` (`c`) AS select (`t1`.`b` + 1) AS `b+1` from `t1` utf8mb4 utf8mb4_0900_ai_ci +show create view t1; +ERROR HY000: 'test.t1' is not VIEW +drop table t1; +select a from v1; +ERROR 42S22: Unknown column 'a' in 'field list' +select v1.a from v1; +ERROR 42S22: Unknown column 'v1.a' in 'field list' +select b from v1; +ERROR 42S22: Unknown column 'b' in 'field list' +select v1.b from v1; +ERROR 42S22: Unknown column 'v1.b' in 'field list' +analyze table t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +explain select c from v1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL # # NULL +Warnings: +Note 1003 /* select#1 */ select (`test`.`t1`.`b` + 1) AS `c` from `test`.`t1` +create algorithm=temptable view v2 (c) as select b+1 from t1; +show create view v2; +View Create View character_set_client collation_connection +v2 CREATE ALGORITHM=TEMPTABLE DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v2` (`c`) AS select (`t1`.`b` + 1) AS `b+1` from `t1` utf8mb4 utf8mb4_0900_ai_ci +select c from v2; +c +3 +4 +5 +6 +11 +explain select c from v2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL # # NULL +2 DERIVED t1 NULL ALL NULL NULL NULL NULL # # NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`v2`.`c` AS `c` from `test`.`v2` +create view v3 (c) as select a+1 from v1; +ERROR 42S22: Unknown column 'a' in 'field list' +create view v3 (c) as select b+1 from v1; +ERROR 42S22: Unknown column 'b' in 'field list' +create view v3 (c) as select c+1 from v1; +select c from v3; +c +4 +5 +6 +7 +12 +explain select c from v3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL # # NULL +Warnings: +Note 1003 /* select#1 */ select ((`test`.`t1`.`b` + 1) + 1) AS `c` from `test`.`t1` +create algorithm=temptable view v4 (c) as select c+1 from v2; +select c from v4; +c +4 +5 +6 +7 +12 +explain select c from v4; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL # # NULL +2 DERIVED NULL ALL NULL NULL NULL NULL # # NULL +3 DERIVED t1 NULL ALL NULL NULL NULL NULL # # NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`v4`.`c` AS `c` from `test`.`v4` +create view v5 (c) as select c+1 from v2; +select c from v5; +c +4 +5 +6 +7 +12 +explain select c from v5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL # # NULL +3 DERIVED t1 NULL ALL NULL NULL NULL NULL # # NULL +Warnings: +Note 1003 /* select#1 */ select (`test`.`v2`.`c` + 1) AS `c` from `test`.`v2` +create algorithm=temptable view v6 (c) as select c+1 from v1; +select c from v6; +c +4 +5 +6 +7 +12 +explain select c from v6; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL # # NULL +2 DERIVED t1 NULL ALL NULL NULL NULL NULL # # NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`v6`.`c` AS `c` from `test`.`v6` +show tables; +Tables_in_test +t1 +v1 +v2 +v3 +v4 +v5 +v6 +show full tables; +Tables_in_test Table_type +t1 BASE TABLE +v1 VIEW +v2 VIEW +v3 VIEW +v4 VIEW +v5 VIEW +v6 VIEW +show table status; +Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment +t1 InnoDB 10 Dynamic # # # # 0 0 NULL # # NULL utf8mb4_0900_ai_ci NULL +v1 NULL NULL NULL # # # # NULL NULL NULL # # NULL NULL NULL NULL VIEW +v2 NULL NULL NULL # # # # NULL NULL NULL # # NULL NULL NULL NULL VIEW +v3 NULL NULL NULL # # # # NULL NULL NULL # # NULL NULL NULL NULL VIEW +v4 NULL NULL NULL # # # # NULL NULL NULL # # NULL NULL NULL NULL VIEW +v5 NULL NULL NULL # # # # NULL NULL NULL # # NULL NULL NULL NULL VIEW +v6 NULL NULL NULL # # # # NULL NULL NULL # # NULL NULL NULL NULL VIEW +drop view v1,v2,v3,v4,v5,v6; +create view v1 (c,d,e,f) as select a,b, +a in (select a+2 from t1), a = all (select a from t1) from t1; +create view v2 as select c, d from v1; +select * from v1; +c d e f +1 2 0 0 +1 3 0 0 +2 4 0 0 +2 5 0 0 +3 10 1 0 +select * from v2; +c d +1 2 +1 3 +2 4 +2 5 +3 10 +create view v1 (c,d,e,f) as select a,b, a in (select a+2 from t1), a = all (select a from t1) from t1; +ERROR 42S01: Table 'v1' already exists +create or replace view v1 (c,d,e,f) as select a,b, a in (select a+2 from t1), a = all (select a from t1) from t1; +drop view v2; +alter view v2 as select c, d from v1; +ERROR 42S02: Table 'test.v2' doesn't exist +create or replace view v2 as select c, d from v1; +alter view v1 (c,d) as select a,max(b) from t1 group by a; +select * from v1; +c d +1 3 +2 5 +3 10 +select * from v2; +c d +1 3 +2 5 +3 10 +drop view v100; +ERROR 42S02: Unknown table 'test.v100' +drop view t1; +ERROR HY000: 'test.t1' is not VIEW +drop table v1; +ERROR 42S02: Unknown table 'test.v1' +drop view v1,v2; +drop table t1; +create table t1 (a int); +insert into t1 values (1), (2), (3); +create view v1 (a) as select a+1 from t1; +create view v2 (a) as select a-1 from t1; +select * from t1 natural left join v1; +a +1 +2 +3 +select * from v2 natural left join t1; +a +0 +1 +2 +select * from v2 natural left join v1; +a +0 +1 +2 +drop view v1, v2; +drop table t1; +create table t1 (a int); +insert into t1 values (1), (2), (3), (1), (2), (3); +analyze table t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +create view v1 as select distinct a from t1; +select * from v1; +a +1 +2 +3 +explain select * from v1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL # # NULL +2 DERIVED t1 NULL ALL NULL NULL NULL NULL # # Using temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`v1`.`a` AS `a` from `test`.`v1` +select * from t1; +a +1 +2 +3 +1 +2 +3 +drop view v1; +drop table t1; +create table t1 (a int); +create view v1 as select distinct a from t1 WITH CHECK OPTION; +ERROR HY000: CHECK OPTION on non-updatable view 'test.v1' +create view v1 as select a from t1 WITH CHECK OPTION; +create view v2 as select a from t1 WITH CASCADED CHECK OPTION; +create view v3 as select a from t1 WITH LOCAL CHECK OPTION; +drop view v3 RESTRICT; +drop view v2 CASCADE; +drop view v1; +drop table t1; +create table t1 (a int, b int); +insert into t1 values (1,2), (1,3), (2,4), (2,5), (3,10); +create view v1 (c) as select b+1 from t1; +select test.c from v1 test; +c +3 +4 +5 +6 +11 +create algorithm=temptable view v2 (c) as select b+1 from t1; +select test.c from v2 test; +c +3 +4 +5 +6 +11 +select test1.* from v1 test1, v2 test2 where test1.c=test2.c; +c +3 +4 +5 +6 +11 +select test2.* from v1 test1, v2 test2 where test1.c=test2.c; +c +3 +4 +5 +6 +11 +drop table t1; +drop view v1,v2; +create table t1 (a int); +insert into t1 values (1), (2), (3), (4); +analyze table t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +create view v1 as select a+1 from t1 order by 1 desc limit 2; +select * from v1; +a+1 +5 +4 +explain select * from v1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL # # NULL +2 DERIVED t1 NULL ALL NULL NULL NULL NULL # # Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`v1`.`a+1` AS `a+1` from `test`.`v1` +drop view v1; +drop table t1; +create table t1 (a int); +insert into t1 values (1), (2), (3), (4); +create view v1 as select a+1 from t1; +create table t2 select * from v1; +show columns from t2; +Field Type Null Key Default Extra +a+1 bigint YES NULL +select * from t2; +a+1 +2 +3 +4 +5 +drop view v1; +drop table t1,t2; +create table t1 (a int, b int, primary key(a)); +insert into t1 values (10,2), (20,3), (30,4), (40,5), (50,10); +create view v1 (a,c) as select a, b+1 from t1; +create algorithm=temptable view v2 (a,c) as select a, b+1 from t1; +select is_updatable from information_schema.views where table_name='v2'; +IS_UPDATABLE +NO +select is_updatable from information_schema.views where table_name='v1'; +IS_UPDATABLE +YES +update v1 set c=a+c; +ERROR HY000: Column 'c' is not updatable +update v2 set a=a+c; +ERROR HY000: The target table v2 of the UPDATE is not updatable +update v1 set a=a+c; +select * from v1; +a c +13 3 +24 4 +35 5 +46 6 +61 11 +select * from t1; +a b +13 2 +24 3 +35 4 +46 5 +61 10 +drop table t1; +drop view v1,v2; +create table t1 (a int, b int, primary key(a)); +insert into t1 values (10,2), (20,3), (30,4), (40,5), (50,10); +create table t2 (x int); +insert into t2 values (10), (20); +create view v1 (a,c) as select a, b+1 from t1; +create algorithm=temptable view v2 (a,c) as select a, b+1 from t1; +update t2,v1 set v1.c=v1.a+v1.c where t2.x=v1.a; +ERROR HY000: Column 'c' is not updatable +update t2,v2 set v2.a=v2.a+c where t2.x=v2.a; +ERROR HY000: The target table v2 of the UPDATE is not updatable +update t2,v1 set v1.a=v1.a+v1.c where t2.x=v1.a; +select * from v1; +a c +13 3 +24 4 +30 5 +40 6 +50 11 +select * from t1; +a b +13 2 +24 3 +30 4 +40 5 +50 10 +drop table t1,t2; +drop view v1,v2; +create table t1 (a int, b int, primary key(b)); +insert into t1 values (1,20), (2,30), (3,40), (4,50), (5,100); +analyze table t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +create view v1 (c) as select b from t1 where a<3; +select * from v1; +c +20 +30 +explain select * from v1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL # # Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`b` AS `c` from `test`.`t1` where (`test`.`t1`.`a` < 3) +update v1 set c=c+1; +select * from t1; +a b +1 21 +2 31 +3 40 +4 50 +5 100 +create view v2 (c) as select b from t1 where a>=3; +select * from v1, v2; +c c +21 100 +21 40 +21 50 +31 100 +31 40 +31 50 +drop view v1, v2; +drop table t1; +create table t1 (a int, b int, primary key(a)); +insert into t1 values (1,2), (2,3), (3,4), (4,5), (5,10); +create view v1 (a,c) as select a, b+1 from t1; +create algorithm=temptable view v2 (a,c) as select a, b+1 from t1; +delete from v2 where c < 4; +ERROR HY000: The target table v2 of the DELETE is not updatable +delete from v1 where c < 4; +select * from v1; +a c +2 4 +3 5 +4 6 +5 11 +select * from t1; +a b +2 3 +3 4 +4 5 +5 10 +drop table t1; +drop view v1,v2; +create table t1 (a int, b int, primary key(a)); +insert into t1 values (1,2), (2,3), (3,4), (4,5), (5,10); +create table t2 (x int); +insert into t2 values (1), (2), (3), (4); +create view v1 (a,c) as select a, b+1 from t1; +create algorithm=temptable view v2 (a,c) as select a, b+1 from t1; +delete v2 from t2,v2 where t2.x=v2.a; +ERROR HY000: The target table v2 of the DELETE is not updatable +delete v1 from t2,v1 where t2.x=v1.a; +select * from v1; +a c +5 11 +select * from t1; +a b +5 10 +drop table t1,t2; +drop view v1,v2; +create table t1 (a int, b int, c int, primary key(a,b)); +insert into t1 values (10,2,-1), (20,3,-2), (30,4,-3), (40,5,-4), (50,10,-5); +create view v1 (x,y) as select a, b from t1; +create view v2 (x,y) as select a, c from t1; +set updatable_views_with_limit=NO; +update v1 set x=x+1; +update v2 set x=x+1; +update v1 set x=x+1 limit 1; +update v2 set x=x+1 limit 1; +ERROR HY000: The target table v2 of the UPDATE is not updatable +delete from v2 limit 1; +ERROR HY000: The target table v2 of the DELETE is not updatable +set updatable_views_with_limit=YES; +update v1 set x=x+1 limit 1; +update v2 set x=x+1 limit 1; +Warnings: +Note 1355 View being updated does not have complete key of underlying table in it +set updatable_views_with_limit=DEFAULT; +show variables like "updatable_views_with_limit"; +Variable_name Value +updatable_views_with_limit YES +select * from t1; +a b c +15 2 -1 +22 3 -2 +32 4 -3 +42 5 -4 +52 10 -5 +drop table t1; +drop view v1,v2; +create table t1 (a int, b int, c int, primary key(a,b)); +insert into t1 values (10,2,-1), (20,3,-2); +create view v1 (x,y,z) as select c, b, a from t1; +create view v2 (x,y) as select b, a from t1; +create view v3 (x,y,z) as select b, a, b from t1; +create view v4 (x,y,z) as select c+1, b, a from t1; +create algorithm=temptable view v5 (x,y,z) as select c, b, a from t1; +insert into v3 values (-60,4,30); +ERROR HY000: The target table v3 of the INSERT is not insertable-into +insert into v4 values (-60,4,30); +ERROR HY000: Column 'x' is not updatable +insert into v5 values (-60,4,30); +ERROR HY000: The target table v5 of the INSERT is not insertable-into +insert into v1 values (-60,4,30); +insert into v1 (z,y,x) values (50,6,-100); +insert into v2 values (5,40); +select * from t1; +a b c +10 2 -1 +20 3 -2 +30 4 -60 +40 5 NULL +50 6 -100 +drop table t1; +drop view v1,v2,v3,v4,v5; +create table t1 (a int, b int, c int, primary key(a,b)); +insert into t1 values (10,2,-1), (20,3,-2); +create table t2 (a int, b int, c int, primary key(a,b)); +insert into t2 values (30,4,-60); +create view v1 (x,y,z) as select c, b, a from t1; +create view v2 (x,y) as select b, a from t1; +create view v3 (x,y,z) as select b, a, b from t1; +create view v4 (x,y,z) as select c+1, b, a from t1; +create algorithm=temptable view v5 (x,y,z) as select c, b, a from t1; +insert into v3 select c, b, a from t2; +ERROR HY000: The target table v3 of the INSERT is not insertable-into +insert into v4 select c, b, a from t2; +ERROR HY000: Column 'x' is not updatable +insert into v5 select c, b, a from t2; +ERROR HY000: The target table v5 of the INSERT is not insertable-into +insert into v1 select c, b, a from t2; +insert into v1 (z,y,x) select a+20,b+2,-100 from t2; +insert into v2 select b+1, a+10 from t2; +select * from t1; +a b c +10 2 -1 +20 3 -2 +30 4 -60 +40 5 NULL +50 6 -100 +drop table t1, t2; +drop view v1,v2,v3,v4,v5; +create table t1 (a int, primary key(a)); +insert into t1 values (1), (2), (3); +create view v1 (x) as select a from t1 where a > 1; +select t1.a, v1.x from t1 left join v1 on (t1.a= v1.x); +a x +1 NULL +2 2 +3 3 +drop table t1; +drop view v1; +create table t1 (a int, primary key(a)); +insert into t1 values (1), (2), (3), (200); +create view v1 (x) as select a from t1 where a > 1; +create view v2 (y) as select x from v1 where x < 100; +select * from v2; +y +2 +3 +drop table t1; +drop view v1,v2; +create table t1 (a int, primary key(a)); +insert into t1 values (1), (2), (3), (200); +create ALGORITHM=TEMPTABLE view v1 (x) as select a from t1; +create view v2 (y) as select x from v1; +update v2 set y=10 where y=2; +ERROR HY000: The target table v2 of the UPDATE is not updatable +drop table t1; +drop view v1,v2; +create table t1 (a int not null auto_increment, b int not null, primary key(a), unique(b)); +create view v1 (x) as select b from t1; +insert into v1 values (1); +select last_insert_id(); +last_insert_id() +0 +insert into t1 (b) values (2); +select last_insert_id(); +last_insert_id() +2 +select * from t1; +a b +1 1 +2 2 +drop view v1; +drop table t1; +set sql_mode='ansi'; +create table t1 ("a*b" int); +create view v1 as select "a*b" from t1; +show create view v1; +View Create View character_set_client collation_connection +v1 CREATE VIEW "v1" AS select "t1"."a*b" AS "a*b" from "t1" utf8mb4 utf8mb4_0900_ai_ci +drop view v1; +drop table t1; +set sql_mode=default; +create table t1 (t_column int); +create view v1 as select 'a'; +select * from v1, t1; +a t_column +drop view v1; +drop table t1; +create table `t1a``b` (col1 char(2)); +create view v1 as select * from `t1a``b`; +select * from v1; +col1 +describe v1; +Field Type Null Key Default Extra +col1 char(2) YES NULL +drop view v1; +drop table `t1a``b`; +SET sql_mode = 'NO_ENGINE_SUBSTITUTION'; +create table t1 (col1 char(5),col2 char(5)); +create view v1 as select * from t1; +drop table t1; +create table t1 (col1 char(5),newcol2 char(5)); +insert into v1 values('a','aa'); +ERROR HY000: View 'test.v1' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +drop table t1; +select * from v1; +ERROR HY000: View 'test.v1' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +drop view v1; +SET sql_mode = default; +create view v1 (a,a) as select 'a','a'; +ERROR 42S21: Duplicate column name 'a' +create table t1 (col1 int,col2 char(22)); +insert into t1 values(5,'Hello, world of views'); +create view v1 as select * from t1; +create view v2 as select * from v1; +update v2 set col2='Hello, view world'; +select is_updatable from information_schema.views where +table_schema != 'sys' and table_schema != 'information_schema'; +IS_UPDATABLE +YES +YES +select * from t1; +col1 col2 +5 Hello, view world +drop view v2, v1; +drop table t1; +create table t1 (a int, b int); +create view v1 as select a, sum(b) from t1 group by a; +select b from v1 use index (some_index) where b=1; +ERROR 42000: Key 'some_index' doesn't exist in table 'v1' +drop view v1; +drop table t1; +create table t1 (col1 char(5),col2 char(5)); +create view v1 (col1,col2) as select col1,col2 from t1; +insert into v1 values('s1','p1'),('s1','p2'),('s1','p3'),('s1','p4'),('s2','p1'),('s3','p2'),('s4','p4'); +select distinct first.col2 from t1 first where first.col2 in (select second.col2 from t1 second where second.col1<>first.col1); +col2 +p1 +p2 +p4 +select distinct first.col2 from v1 first where first.col2 in (select second.col2 from t1 second where second.col1<>first.col1); +col2 +p1 +p2 +p4 +drop view v1; +drop table t1; +create table t1 (a int); +create view v1 as select a from t1; +insert into t1 values (1); +SET @v0 = '2'; +PREPARE stmt FROM 'UPDATE v1 SET a = ?'; +EXECUTE stmt USING @v0; +DEALLOCATE PREPARE stmt; +SET @v0 = '3'; +PREPARE stmt FROM 'insert into v1 values (?)'; +EXECUTE stmt USING @v0; +DEALLOCATE PREPARE stmt; +SET @v0 = '4'; +PREPARE stmt FROM 'insert into v1 (a) values (?)'; +EXECUTE stmt USING @v0; +DEALLOCATE PREPARE stmt; +select * from t1; +a +2 +3 +4 +drop view v1; +drop table t1; +CREATE VIEW v02 AS SELECT * FROM DUAL; +ERROR HY000: No tables used +SHOW TABLES; +Tables_in_test +CREATE VIEW v1 AS SELECT EXISTS (SELECT 1 UNION SELECT 2); +select * from v1; +EXISTS (SELECT 1 UNION SELECT 2) +1 +drop view v1; +create table t1 (col1 int,col2 char(22)); +create view v1 as select * from t1; +create index i1 on v1 (col1); +ERROR HY000: 'test.v1' is not BASE TABLE +drop view v1; +drop table t1; +CREATE VIEW v1 (f1,f2,f3,f4) AS SELECT connection_id(), pi(), current_user(), version(); +SHOW CREATE VIEW v1; +View Create View character_set_client collation_connection +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` (`f1`,`f2`,`f3`,`f4`) AS select connection_id() AS `connection_id()`,pi() AS `pi()`,current_user() AS `current_user()`,version() AS `version()` utf8mb4 utf8mb4_0900_ai_ci +drop view v1; +create table t1 (s1 int); +create table t2 (s2 int); +insert into t1 values (1), (2); +insert into t2 values (2), (3); +create view v1 as select * from t1,t2 union all select * from t1,t2; +select * from v1; +s1 s2 +1 2 +1 2 +1 3 +1 3 +2 2 +2 2 +2 3 +2 3 +drop view v1; +drop tables t1, t2; +create table t1 (col1 int); +insert into t1 values (1); +create view v1 as select count(*) from t1; +insert into t1 values (null); +select * from v1; +count(*) +2 +drop view v1; +drop table t1; +create table t1 (a int); +create table t2 (a int); +create view v1 as select a from t1; +create view v2 as select a from t2 where a in (select a from v1); +show create view v2; +View Create View character_set_client collation_connection +v2 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v2` AS select `t2`.`a` AS `a` from `t2` where `t2`.`a` in (select `v1`.`a` from `v1`) utf8mb4 utf8mb4_0900_ai_ci +drop view v2, v1; +drop table t1, t2; +CREATE VIEW `v 1` AS select 5 AS `5`; +show create view `v 1`; +View Create View character_set_client collation_connection +v 1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v 1` AS select 5 AS `5` utf8mb4 utf8mb4_0900_ai_ci +drop view `v 1`; +create database mysqltest; +create table mysqltest.t1 (a int, b int); +create view mysqltest.v1 as select a from mysqltest.t1; +alter view mysqltest.v1 as select b from mysqltest.t1; +alter view mysqltest.v1 as select a from mysqltest.t1; +drop database mysqltest; +CREATE TABLE t1 (c1 int not null auto_increment primary key, c2 varchar(20), fulltext(c2)); +insert into t1 (c2) VALUES ('real Beer'),('Water'),('Kossu'),('Coca-Cola'),('Vodka'),('Wine'),('almost real Beer'); +select * from t1 WHERE match (c2) against ('Beer'); +c1 c2 +1 real Beer +7 almost real Beer +CREATE VIEW v1 AS SELECT * from t1 WHERE match (c2) against ('Beer'); +select * from v1; +c1 c2 +1 real Beer +7 almost real Beer +drop view v1; +drop table t1; +create table t1 (a int); +insert into t1 values (1),(1),(2),(2),(3),(3); +create view v1 as select a from t1; +select distinct a from v1; +a +1 +2 +3 +select distinct a from v1 limit 2; +a +1 +2 +select distinct a from t1 limit 2; +a +1 +2 +prepare stmt1 from "select distinct a from v1 limit 2"; +execute stmt1; +a +1 +2 +execute stmt1; +a +1 +2 +deallocate prepare stmt1; +drop view v1; +drop table t1; +create table t1 (tg_column bigint); +create view v1 as select count(tg_column) as vg_column from t1; +select avg(vg_column) from v1; +avg(vg_column) +0.0000 +drop view v1; +drop table t1; +create table t1 (col1 bigint not null, primary key (col1)); +create table t2 (col1 bigint not null, key (col1)); +create view v1 as select * from t1; +create view v2 as select * from t2; +insert into v1 values (1); +insert into v2 values (1); +create view v3 (a,b) as select v1.col1 as a, v2.col1 as b from v1, v2 where v1.col1 = v2.col1; +select * from v3; +a b +1 1 +show create view v3; +View Create View character_set_client collation_connection +v3 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v3` (`a`,`b`) AS select `v1`.`col1` AS `a`,`v2`.`col1` AS `b` from (`v1` join `v2`) where (`v1`.`col1` = `v2`.`col1`) utf8mb4 utf8mb4_0900_ai_ci +drop view v3, v2, v1; +drop table t2, t1; +create function `f``1` () returns int return 5; +create view v1 as select test.`f``1` (); +show create view v1; +View Create View character_set_client collation_connection +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `test`.`f``1`() AS `test.``f````1`` ()` utf8mb4 utf8mb4_0900_ai_ci +select * from v1; +test.`f``1` () +5 +drop view v1; +drop function `f``1`; +create function a() returns int return 5; +create view v1 as select a(); +select * from v1; +a() +5 +drop view v1; +drop function a; +create table t2 (col1 char collate latin1_german2_ci); +create view v2 as select col1 collate latin1_german1_ci from t2; +show create view v2; +View Create View character_set_client collation_connection +v2 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v2` AS select (`t2`.`col1` collate latin1_german1_ci) AS `col1 collate latin1_german1_ci` from `t2` utf8mb4 utf8mb4_0900_ai_ci +show create view v2; +View Create View character_set_client collation_connection +v2 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v2` AS select (`t2`.`col1` collate latin1_german1_ci) AS `col1 collate latin1_german1_ci` from `t2` utf8mb4 utf8mb4_0900_ai_ci +drop view v2; +drop table t2; +create table t1 (a int); +insert into t1 values (1), (2); +create view v1 as select 5 from t1 order by 1; +select * from v1; +5 +5 +5 +drop view v1; +drop table t1; +create function x1 () returns int return 5; +create table t1 (s1 int); +create view v1 as select x1() from t1; +drop function x1; +select * from v1; +ERROR HY000: View 'test.v1' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +show table status; +Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment +t1 InnoDB 10 Dynamic # # # # 0 0 NULL # # NULL utf8mb4_0900_ai_ci NULL +v1 NULL NULL NULL # # # # NULL NULL NULL # # NULL NULL NULL NULL View 'test.v1' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +Warnings: +Warning 1356 View 'test.v1' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +drop view v1; +drop table t1; +create view v1 as select 99999999999999999999999999999999999999999999999999999 as col1; +show create view v1; +View Create View character_set_client collation_connection +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select 99999999999999999999999999999999999999999999999999999 AS `col1` utf8mb4 utf8mb4_0900_ai_ci +drop view v1; +SET @old_cs_client = @@character_set_client; +SET @old_cs_results = @@character_set_results; +SET @old_cs_connection = @@character_set_connection; +set names utf8; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +create table tü (cü char); +create view vü as select cü from tü; +insert into vü values ('ü'); +select * from vü; +cü +ü +drop view vü; +drop table tü; +SET character_set_client = @old_cs_client; +SET character_set_results = @old_cs_results; +SET character_set_connection = @old_cs_connection; +create table t1 (a int, b int); +insert into t1 values (1,2), (1,3), (2,4), (2,5), (3,10); +create view v1(c) as select a+1 from t1 where b >= 4; +select c from v1 where exists (select * from t1 where a=2 and b=c); +c +4 +drop view v1; +drop table t1; +create view v1 as select cast(1 as char(3)); +show create view v1; +View Create View character_set_client collation_connection +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select cast(1 as char(3) charset utf8mb4) AS `cast(1 as char(3))` utf8mb4 utf8mb4_0900_ai_ci +select * from v1; +cast(1 as char(3)) +1 +drop view v1; +create table t1 (a int); +create view v1 as select a from t1; +create view v3 as select a from t1; +create database mysqltest; +rename table v1 to mysqltest.v1; +ERROR HY000: Changing schema from 'test' to 'mysqltest' is not allowed. +rename table v1 to v2; +rename table v3 to v1, v2 to t1; +ERROR 42S01: Table 't1' already exists +drop table t1; +drop view v2,v3; +drop database mysqltest; +create view v1 as select 'a',1; +create view v2 as select * from v1 union all select * from v1; +create view v3 as select * from v2 where 1 = (select `1` from v2); +create view v4 as select * from v3; +select * from v4; +ERROR 21000: Subquery returns more than 1 row +drop view v4, v3, v2, v1; +create view v1 as select 5 into @w; +ERROR HY000: View's SELECT contains a 'INTO' clause +create view v1 as select 5 into outfile 'ttt'; +ERROR HY000: View's SELECT contains a 'INTO' clause +create table t1 (a int); +create view v1 as select 1 from (select 1) as d1; +drop view v1; +drop table t1; +create table t1 (s1 int, primary key (s1)); +create view v1 as select * from t1; +insert into v1 values (1) on duplicate key update s1 = 7; +insert into v1 values (1) on duplicate key update s1 = 7; +select * from t1; +s1 +7 +drop view v1; +drop table t1; +create table t1 (col1 int); +create table t2 (col1 int); +create table t3 (col1 datetime not null); +create view v1 as select * from t1; +create view v2 as select * from v1; +create view v3 as select v2.col1 from v2,t2 where v2.col1 = t2.col1; +update v2 set col1 = (select max(col1) from v1); +ERROR HY000: The definition of table 'v1' prevents operation UPDATE on table 'v2'. +update v2 set col1 = (select max(col1) from t1); +ERROR HY000: The definition of table 'v2' prevents operation UPDATE on table 'v2'. +update v2 set col1 = (select max(col1) from v2); +ERROR HY000: You can't specify target table 'v2' for update in FROM clause +update v2,t2 set v2.col1 = (select max(col1) from v1) where v2.col1 = t2.col1; +ERROR HY000: The definition of table 'v1' prevents operation UPDATE on table 'v2'. +update t1,t2 set t1.col1 = (select max(col1) from v1) where t1.col1 = t2.col1; +ERROR HY000: The definition of table 'v1' prevents operation UPDATE on table 't1'. +update v1,t2 set v1.col1 = (select max(col1) from v1) where v1.col1 = t2.col1; +ERROR HY000: You can't specify target table 'v1' for update in FROM clause +update t2,v2 set v2.col1 = (select max(col1) from v1) where v2.col1 = t2.col1; +ERROR HY000: The definition of table 'v1' prevents operation UPDATE on table 't2'. +update t2,t1 set t1.col1 = (select max(col1) from v1) where t1.col1 = t2.col1; +ERROR HY000: The definition of table 'v1' prevents operation UPDATE on table 't2'. +update t2,v1 set v1.col1 = (select max(col1) from v1) where v1.col1 = t2.col1; +ERROR HY000: The definition of table 'v1' prevents operation UPDATE on table 't2'. +update v2,t2 set v2.col1 = (select max(col1) from t1) where v2.col1 = t2.col1; +ERROR HY000: The definition of table 'v2' prevents operation UPDATE on table 'v2'. +update t1,t2 set t1.col1 = (select max(col1) from t1) where t1.col1 = t2.col1; +ERROR HY000: You can't specify target table 't1' for update in FROM clause +update v1,t2 set v1.col1 = (select max(col1) from t1) where v1.col1 = t2.col1; +ERROR HY000: The definition of table 'v1' prevents operation UPDATE on table 'v1'. +update t2,v2 set v2.col1 = (select max(col1) from t1) where v2.col1 = t2.col1; +ERROR HY000: You can't specify target table 't2' for update in FROM clause +update t2,t1 set t1.col1 = (select max(col1) from t1) where t1.col1 = t2.col1; +ERROR HY000: You can't specify target table 't2' for update in FROM clause +update t2,v1 set v1.col1 = (select max(col1) from t1) where v1.col1 = t2.col1; +ERROR HY000: You can't specify target table 't2' for update in FROM clause +update v2,t2 set v2.col1 = (select max(col1) from v2) where v2.col1 = t2.col1; +ERROR HY000: You can't specify target table 'v2' for update in FROM clause +update t1,t2 set t1.col1 = (select max(col1) from v2) where t1.col1 = t2.col1; +ERROR HY000: The definition of table 'v2' prevents operation UPDATE on table 't1'. +update v1,t2 set v1.col1 = (select max(col1) from v2) where v1.col1 = t2.col1; +ERROR HY000: The definition of table 'v2' prevents operation UPDATE on table 'v1'. +update t2,v2 set v2.col1 = (select max(col1) from v2) where v2.col1 = t2.col1; +ERROR HY000: The definition of table 'v2' prevents operation UPDATE on table 't2'. +update t2,t1 set t1.col1 = (select max(col1) from v2) where t1.col1 = t2.col1; +ERROR HY000: The definition of table 'v2' prevents operation UPDATE on table 't2'. +update t2,v1 set v1.col1 = (select max(col1) from v2) where v1.col1 = t2.col1; +ERROR HY000: The definition of table 'v2' prevents operation UPDATE on table 't2'. +update v3 set v3.col1 = (select max(col1) from v1); +ERROR HY000: The definition of table 'v1' prevents operation UPDATE on table 'v3'. +update v3 set v3.col1 = (select max(col1) from t1); +ERROR HY000: The definition of table 'v3' prevents operation UPDATE on table 'v3'. +update v3 set v3.col1 = (select max(col1) from v2); +ERROR HY000: The definition of table 'v2' prevents operation UPDATE on table 'v3'. +update v3 set v3.col1 = (select max(col1) from v3); +ERROR HY000: You can't specify target table 'v3' for update in FROM clause +delete from v2 where col1 = (select max(col1) from v1); +ERROR HY000: The definition of table 'v1' prevents operation DELETE on table 'v2'. +delete from v2 where col1 = (select max(col1) from t1); +ERROR HY000: The definition of table 'v2' prevents operation DELETE on table 'v2'. +delete from v2 where col1 = (select max(col1) from v2); +ERROR HY000: You can't specify target table 'v2' for update in FROM clause +delete v2 from v2,t2 where (select max(col1) from v1) > 0 and v2.col1 = t2.col1; +ERROR HY000: The definition of table 'v1' prevents operation DELETE on table 'v2'. +delete t1 from t1,t2 where (select max(col1) from v1) > 0 and t1.col1 = t2.col1; +ERROR HY000: The definition of table 'v1' prevents operation DELETE on table 't1'. +delete v1 from v1,t2 where (select max(col1) from v1) > 0 and v1.col1 = t2.col1; +ERROR HY000: You can't specify target table 'v1' for update in FROM clause +delete v2 from v2,t2 where (select max(col1) from t1) > 0 and v2.col1 = t2.col1; +ERROR HY000: The definition of table 'v2' prevents operation DELETE on table 'v2'. +delete t1 from t1,t2 where (select max(col1) from t1) > 0 and t1.col1 = t2.col1; +ERROR HY000: You can't specify target table 't1' for update in FROM clause +delete v1 from v1,t2 where (select max(col1) from t1) > 0 and v1.col1 = t2.col1; +ERROR HY000: The definition of table 'v1' prevents operation DELETE on table 'v1'. +delete v2 from v2,t2 where (select max(col1) from v2) > 0 and v2.col1 = t2.col1; +ERROR HY000: You can't specify target table 'v2' for update in FROM clause +delete t1 from t1,t2 where (select max(col1) from v2) > 0 and t1.col1 = t2.col1; +ERROR HY000: The definition of table 'v2' prevents operation DELETE on table 't1'. +delete v1 from v1,t2 where (select max(col1) from v2) > 0 and v1.col1 = t2.col1; +ERROR HY000: The definition of table 'v2' prevents operation DELETE on table 'v1'. +insert into v2 values ((select max(col1) from v1)); +ERROR HY000: The definition of table 'v1' prevents operation INSERT on table 'v2'. +insert into t1 values ((select max(col1) from v1)); +ERROR HY000: The definition of table 'v1' prevents operation INSERT on table 't1'. +insert into v2 values ((select max(col1) from v1)); +ERROR HY000: The definition of table 'v1' prevents operation INSERT on table 'v2'. +insert into v2 values ((select max(col1) from t1)); +ERROR HY000: The definition of table 'v2' prevents operation INSERT on table 'v2'. +insert into t1 values ((select max(col1) from t1)); +ERROR HY000: You can't specify target table 't1' for update in FROM clause +insert into v2 values ((select max(col1) from t1)); +ERROR HY000: The definition of table 'v2' prevents operation INSERT on table 'v2'. +insert into v2 values ((select max(col1) from v2)); +ERROR HY000: You can't specify target table 'v2' for update in FROM clause +insert into t1 values ((select max(col1) from v2)); +ERROR HY000: The definition of table 'v2' prevents operation INSERT on table 't1'. +insert into v2 values ((select max(col1) from v2)); +ERROR HY000: You can't specify target table 'v2' for update in FROM clause +insert into v3 (col1) values ((select max(col1) from v1)); +ERROR HY000: The definition of table 'v1' prevents operation INSERT on table 'v3'. +insert into v3 (col1) values ((select max(col1) from t1)); +ERROR HY000: The definition of table 'v3' prevents operation INSERT on table 'v3'. +insert into v3 (col1) values ((select max(col1) from v2)); +ERROR HY000: The definition of table 'v2' prevents operation INSERT on table 'v3'. +insert into v3 (col1) values ((select CONVERT_TZ('20050101000000','UTC','MET') from v2)); +ERROR HY000: The definition of table 'v2' prevents operation INSERT on table 'v3'. +insert into v3 (col1) values ((select CONVERT_TZ('20050101000000','UTC','MET') from t2)); +insert into t3 values ((select CONVERT_TZ('20050101000000','UTC','MET') from t2)); +ERROR 23000: Column 'col1' cannot be null +create algorithm=temptable view v4 as select * from t1; +insert into t1 values (1),(2),(3); +insert into t1 (col1) values ((select max(col1) from v4)); +select * from t1; +col1 +NULL +1 +2 +3 +3 +drop view v4,v3,v2,v1; +drop table t1,t2,t3; +create table t1 (s1 int); +create view v1 as select * from t1; +handler v1 open as xx; +ERROR HY000: 'test.v1' is not BASE TABLE +drop view v1; +drop table t1; +create table t1(a int); +insert into t1 values (0), (1), (2), (3); +create table t2 (a int); +insert into t2 select a from t1 where a > 1; +create view v1 as select a from t1 where a > 1; +select * from t1 left join (t2 as t, v1) on v1.a=t1.a; +a a a +0 NULL NULL +1 NULL NULL +2 2 2 +2 3 2 +3 2 3 +3 3 3 +select * from t1 left join (t2 as t, t2) on t2.a=t1.a; +a a a +0 NULL NULL +1 NULL NULL +2 2 2 +2 3 2 +3 2 3 +3 3 3 +drop view v1; +drop table t1, t2; +create table t1 (s1 char) charset latin1; +create view v1 as select s1 collate latin1_german1_ci as s1 from t1; +insert into v1 values ('a'); +select * from v1; +s1 +a +update v1 set s1='b'; +select * from v1; +s1 +b +update v1,t1 set v1.s1='c' where t1.s1=v1.s1; +select * from v1; +s1 +c +prepare stmt1 from "update v1,t1 set v1.s1=? where t1.s1=v1.s1"; +set @arg='d'; +execute stmt1 using @arg; +select * from v1; +s1 +d +set @arg='e'; +execute stmt1 using @arg; +select * from v1; +s1 +e +deallocate prepare stmt1; +drop view v1; +drop table t1; +create table t1 (a int); +create table t2 (a int); +create view v1 as select * from t1; +lock tables t1 read, v1 read; +select * from v1; +a +select * from t2; +ERROR HY000: Table 't2' was not locked with LOCK TABLES +unlock tables; +drop view v1; +drop table t1, t2; +create table t1 (a int); +create view v1 as select * from t1 where a < 2 with check option; +insert into v1 values(1); +insert into v1 values(3); +ERROR HY000: CHECK OPTION failed 'test.v1' +insert ignore into v1 values (2),(3),(0); +Warnings: +Warning 1369 CHECK OPTION failed 'test.v1' +Warning 1369 CHECK OPTION failed 'test.v1' +select * from t1; +a +1 +0 +delete from t1; +insert into v1 SELECT 1; +insert into v1 SELECT 3; +ERROR HY000: CHECK OPTION failed 'test.v1' +create table t2 (a int); +insert into t2 values (2),(3),(0); +insert ignore into v1 SELECT a from t2; +Warnings: +Warning 1369 CHECK OPTION failed 'test.v1' +Warning 1369 CHECK OPTION failed 'test.v1' +select * from t1 order by a desc; +a +1 +0 +update v1 set a=-1 where a=0; +update v1 set a=2 where a=1; +ERROR HY000: CHECK OPTION failed 'test.v1' +select * from t1 order by a desc; +a +1 +-1 +update v1 set a=0 where a=0; +insert into t2 values (1); +update v1,t2 set v1.a=v1.a-1 where v1.a=t2.a; +select * from t1 order by a desc; +a +0 +-1 +update v1 set a=a+1; +update ignore v1,t2 set v1.a=v1.a+1 where v1.a=t2.a; +Warnings: +Warning 1369 CHECK OPTION failed 'test.v1' +select * from t1; +a +1 +1 +drop view v1; +drop table t1, t2; +create table t1 (a int); +create view v1 as select * from t1 where a < 2 with check option; +create view v2 as select * from v1 where a > 0 with local check option; +create view v3 as select * from v1 where a > 0 with cascaded check option; +insert into v2 values (1); +insert into v3 values (1); +insert into v2 values (0); +ERROR HY000: CHECK OPTION failed 'test.v2' +insert into v3 values (0); +ERROR HY000: CHECK OPTION failed 'test.v3' +insert into v2 values (2); +ERROR HY000: CHECK OPTION failed 'test.v2' +insert into v3 values (2); +ERROR HY000: CHECK OPTION failed 'test.v3' +select * from t1; +a +1 +1 +drop view v3,v2,v1; +drop table t1; +create table t1 (a int, primary key (a)); +create view v1 as select * from t1 where a < 2 with check option; +insert into v1 values (1) on duplicate key update a=2; +insert into v1 values (1) on duplicate key update a=2; +ERROR HY000: CHECK OPTION failed 'test.v1' +insert ignore into v1 values (1) on duplicate key update a=2; +Warnings: +Warning 1369 CHECK OPTION failed 'test.v1' +select * from t1; +a +1 +drop view v1; +drop table t1; +create table t1 (s1 int); +create view v1 as select * from t1; +create view v2 as select * from v1; +alter view v1 as select * from v2; +ERROR 42S02: Table 'test.v1' doesn't exist +alter view v1 as select * from v1; +ERROR 42S02: Table 'test.v1' doesn't exist +create or replace view v1 as select * from v2; +ERROR 42S02: Table 'test.v1' doesn't exist +create or replace view v1 as select * from v1; +ERROR 42S02: Table 'test.v1' doesn't exist +drop view v2,v1; +drop table t1; +create table t1 (a int); +create view v1 as select * from t1; +show create view v1; +View Create View character_set_client collation_connection +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`a` AS `a` from `t1` utf8mb4 utf8mb4_0900_ai_ci +alter algorithm=undefined view v1 as select * from t1 with check option; +show create view v1; +View Create View character_set_client collation_connection +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`a` AS `a` from `t1` WITH CASCADED CHECK OPTION utf8mb4 utf8mb4_0900_ai_ci +alter algorithm=merge view v1 as select * from t1 with cascaded check option; +show create view v1; +View Create View character_set_client collation_connection +v1 CREATE ALGORITHM=MERGE DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`a` AS `a` from `t1` WITH CASCADED CHECK OPTION utf8mb4 utf8mb4_0900_ai_ci +alter algorithm=temptable view v1 as select * from t1; +show create view v1; +View Create View character_set_client collation_connection +v1 CREATE ALGORITHM=TEMPTABLE DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`a` AS `a` from `t1` utf8mb4 utf8mb4_0900_ai_ci +drop view v1; +drop table t1; +create table t1 (s1 int); +create table t2 (s1 int); +create view v2 as select * from t2 where s1 in (select s1 from t1); +insert into v2 values (5); +insert into t1 values (5); +select * from v2; +s1 +5 +update v2 set s1 = 0; +select * from v2; +s1 +select * from t2; +s1 +0 +alter view v2 as select * from t2 where s1 in (select s1 from t1) with check option; +insert into v2 values (5); +update v2 set s1 = 1; +ERROR HY000: CHECK OPTION failed 'test.v2' +insert into t1 values (1); +update v2 set s1 = 1; +select * from v2; +s1 +1 +select * from t2; +s1 +0 +1 +prepare stmt1 from "select * from v2;"; +execute stmt1; +s1 +1 +insert into t1 values (0); +execute stmt1; +s1 +0 +1 +deallocate prepare stmt1; +drop view v2; +drop table t1, t2; +create table t1 (t time); +create view v1 as select substring_index(t,':',2) as t from t1; +insert into t1 (t) values ('12:24:10'); +select substring_index(t,':',2) from t1; +substring_index(t,':',2) +12:24 +select substring_index(t,':',2) from v1; +substring_index(t,':',2) +12:24 +drop view v1; +drop table t1; +create table t1 (s1 tinyint); +create view v1 as select * from t1 where s1 <> 0 with local check option; +create view v2 as select * from v1 with cascaded check option; +insert into v2 values (0); +ERROR HY000: CHECK OPTION failed 'test.v2' +drop view v2, v1; +drop table t1; +create table t1 (s1 int); +create view v1 as select * from t1 where s1 < 5 with check option; +insert ignore into v1 values (6); +Warnings: +Warning 1369 CHECK OPTION failed 'test.v1' +insert ignore into v1 values (6),(3); +Warnings: +Warning 1369 CHECK OPTION failed 'test.v1' +select * from t1; +s1 +3 +drop view v1; +drop table t1; +SET sql_mode = 'NO_ENGINE_SUBSTITUTION'; +create table t1 (s1 tinyint); +create trigger t1_bi before insert on t1 for each row set new.s1 = 500; +create view v1 as select * from t1 where s1 <> 127 with check option; +insert into v1 values (0); +ERROR HY000: CHECK OPTION failed 'test.v1' +select * from v1; +s1 +select * from t1; +s1 +drop trigger t1_bi; +drop view v1; +drop table t1; +SET sql_mode = default; +create table t1 (s1 tinyint); +create view v1 as select * from t1 where s1 <> 0; +create view v2 as select * from v1 where s1 <> 1 with cascaded check option; +insert into v2 values (0); +ERROR HY000: CHECK OPTION failed 'test.v2' +select * from v2; +s1 +select * from t1; +s1 +drop view v2, v1; +drop table t1; +create table t1 (a text, b text); +create view v1 as select * from t1 where a <> 'Field A' with check option; +load data infile '../../std_data/loaddata2.dat' into table v1 fields terminated by ',' enclosed by ''''; +ERROR HY000: CHECK OPTION failed 'test.v1' +select concat('|',a,'|'), concat('|',b,'|') from t1; +concat('|',a,'|') concat('|',b,'|') +select concat('|',a,'|'), concat('|',b,'|') from v1; +concat('|',a,'|') concat('|',b,'|') +delete from t1; +load data infile '../../std_data/loaddata2.dat' ignore into table v1 fields terminated by ',' enclosed by ''''; +Warnings: +Warning 1369 CHECK OPTION failed 'test.v1' +Warning 1261 Row 2 doesn't contain data for all columns +select concat('|',a,'|'), concat('|',b,'|') from t1; +concat('|',a,'|') concat('|',b,'|') +|Field 1| |Field 2' +Field 3,'Field 4| +|Field 5' ,'Field 6| NULL +|Field 6| | 'Field 7'| +select concat('|',a,'|'), concat('|',b,'|') from v1; +concat('|',a,'|') concat('|',b,'|') +|Field 1| |Field 2' +Field 3,'Field 4| +|Field 5' ,'Field 6| NULL +|Field 6| | 'Field 7'| +drop view v1; +drop table t1; +create table t1 (a int, b char(10)) charset latin1; +create view v1 as select * from t1 where a != 0 with check option; +load data infile '../../std_data/loaddata3.dat' into table v1 fields terminated by '' enclosed by '' ignore 1 lines; +ERROR HY000: Incorrect integer value: 'error ' for column 'a' at row 3 +select * from t1; +a b +select * from v1; +a b +delete from t1; +load data infile '../../std_data/loaddata3.dat' ignore into table v1 fields terminated by '' enclosed by '' ignore 1 lines; +Warnings: +Warning 1366 Incorrect integer value: 'error ' for column 'a' at row 3 +Warning 1369 CHECK OPTION failed 'test.v1' +Warning 1366 Incorrect integer value: 'wrong end ' for column 'a' at row 4 +Warning 1369 CHECK OPTION failed 'test.v1' +select * from t1; +a b +1 row 1 +2 row 2 +3 row 3 +select * from v1; +a b +1 row 1 +2 row 2 +3 row 3 +drop view v1; +drop table t1; +create table t1 (a text, b text) ; +create view v1 as select * from t1 where a <> 'Field A' with check option; +load data infile '../../std_data/loaddata2.dat' into table v1 fields terminated by ',' enclosed by ''''; +ERROR HY000: CHECK OPTION failed 'test.v1' +select concat('|',a,'|'), concat('|',b,'|') from t1; +concat('|',a,'|') concat('|',b,'|') +select concat('|',a,'|'), concat('|',b,'|') from v1; +concat('|',a,'|') concat('|',b,'|') +delete from t1; +load data infile '../../std_data/loaddata2.dat' ignore into table v1 fields terminated by ',' enclosed by ''''; +Warnings: +Warning 1369 CHECK OPTION failed 'test.v1' +Warning 1261 Row 2 doesn't contain data for all columns +select concat('|',a,'|'), concat('|',b,'|') from t1; +concat('|',a,'|') concat('|',b,'|') +|Field 1| |Field 2' +Field 3,'Field 4| +|Field 5' ,'Field 6| NULL +|Field 6| | 'Field 7'| +select concat('|',a,'|'), concat('|',b,'|') from v1; +concat('|',a,'|') concat('|',b,'|') +|Field 1| |Field 2' +Field 3,'Field 4| +|Field 5' ,'Field 6| NULL +|Field 6| | 'Field 7'| +drop view v1; +drop table t1; +create table t1 (s1 smallint); +create view v1 as select * from t1 where 20 < (select (s1) from t1); +insert into v1 values (30); +ERROR HY000: The target table v1 of the INSERT is not insertable-into +create view v2 as select * from t1; +create view v3 as select * from t1 where 20 < (select (s1) from v2); +insert into v3 values (30); +ERROR HY000: The target table v3 of the INSERT is not insertable-into +create view v4 as select * from v2 where 20 < (select (s1) from t1); +insert into v4 values (30); +ERROR HY000: The target table v4 of the INSERT is not insertable-into +drop view v4, v3, v2, v1; +drop table t1; +create table t1 (a int); +create view v1 as select * from t1; +check table t1,v1; +Table Op Msg_type Msg_text +test.t1 check status OK +test.v1 check status OK +check table v1,t1; +Table Op Msg_type Msg_text +test.v1 check status OK +test.t1 check status OK +drop table t1; +check table v1; +Table Op Msg_type Msg_text +test.v1 check Error View 'test.v1' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +test.v1 check error Corrupt +drop view v1; +create table t1 (a int); +create table t2 (a int); +create table t3 (a int); +insert into t1 values (1), (2), (3); +insert into t2 values (1), (3); +insert into t3 values (1), (2), (4); +analyze table t1,t2,t3; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +create view v3 (a,b) as select t1.a as a, t2.a as b from t1 left join t2 on (t1.a=t2.a); +select * from t3 left join v3 on (t3.a = v3.a); +a a b +1 1 1 +2 2 NULL +4 NULL NULL +explain select * from t3 left join v3 on (t3.a = v3.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL # # NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL # # Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL # # Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a`,`test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `b` from `test`.`t3` left join (`test`.`t1` left join `test`.`t2` on((`test`.`t2`.`a` = `test`.`t1`.`a`))) on((`test`.`t1`.`a` = `test`.`t3`.`a`)) where true +create view v1 (a) as select a from t1; +create view v2 (a) as select a from t2; +create view v4 (a,b) as select v1.a as a, v2.a as b from v1 left join v2 on (v1.a=v2.a); +select * from t3 left join v4 on (t3.a = v4.a); +a a b +1 1 1 +2 2 NULL +4 NULL NULL +explain select * from t3 left join v4 on (t3.a = v4.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL # # NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL # # Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL # # Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a`,`test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `b` from `test`.`t3` left join (`test`.`t1` left join (`test`.`t2`) on(((`test`.`t1`.`a` = `test`.`t2`.`a`) and (`test`.`t2`.`a` = `test`.`t1`.`a`)))) on((`test`.`t1`.`a` = `test`.`t3`.`a`)) where true +prepare stmt1 from "select * from t3 left join v4 on (t3.a = v4.a);"; +execute stmt1; +a a b +1 1 1 +2 2 NULL +4 NULL NULL +execute stmt1; +a a b +1 1 1 +2 2 NULL +4 NULL NULL +deallocate prepare stmt1; +drop view v4,v3,v2,v1; +drop tables t1,t2,t3; +create table t1 (a int, primary key (a), b int); +create table t2 (a int, primary key (a)); +insert into t1 values (1,100), (2,200); +insert into t2 values (1), (3); +create view v3 (a,b) as select t1.a as a, t2.a as b from t1, t2; +update v3 set a= 10 where a=1; +select * from t1; +a b +10 100 +2 200 +select * from t2; +a +1 +3 +create view v2 (a,b) as select t1.b as a, t2.a as b from t1, t2; +set updatable_views_with_limit=NO; +update v2 set a= 10 where a=200 limit 1; +Got one of the listed errors +set updatable_views_with_limit=DEFAULT; +select * from v3; +a b +10 1 +10 3 +2 1 +2 3 +select * from v2; +a b +100 1 +100 3 +200 1 +200 3 +set @a= 10; +set @b= 100; +prepare stmt1 from "update v3 set a= ? where a=?"; +execute stmt1 using @a,@b; +select * from v3; +a b +10 1 +10 3 +2 1 +2 3 +set @a= 300; +set @b= 10; +execute stmt1 using @a,@b; +select * from v3; +a b +2 1 +2 3 +300 1 +300 3 +deallocate prepare stmt1; +drop view v3,v2; +drop tables t1,t2; +create table t1 (a int, primary key (a), b int); +create table t2 (a int, primary key (a), b int); +insert into t2 values (1000, 2000); +create view v3 (a,b) as select t1.a as a, t2.a as b from t1, t2; +insert into v3 values (1,2); +ERROR HY000: Can not insert into join view 'test.v3' without fields list +insert into v3 select * from t2; +ERROR HY000: Can not insert into join view 'test.v3' without fields list +insert into v3(a,b) values (1,2); +ERROR HY000: Can not modify more than one base table through a join view 'test.v3' +insert into v3(a,b) select * from t2; +ERROR HY000: Can not modify more than one base table through a join view 'test.v3' +update v3 set a=1,b=2; +ERROR HY000: Can not modify more than one base table through a join view 'test.v3' +insert into v3(a) values (1); +insert into v3(b) values (10); +insert into v3(a) select a from t2; +insert into v3(b) select b from t2; +ERROR 23000: Column 'a' cannot be null +insert into v3(a) values (1) on duplicate key update a=a+10000+VALUES(a); +Warnings: +Warning 1287 'VALUES function' is deprecated and will be removed in a future release. Please use an alias (INSERT INTO ... VALUES (...) AS alias) and replace VALUES(col) in the ON DUPLICATE KEY UPDATE clause with alias.col instead +select * from t1; +a b +10 NULL +1000 NULL +10002 NULL +select * from t2; +a b +10 NULL +1000 2000 +delete from v3; +ERROR HY000: Can not delete from join view 'test.v3' +delete v3,t1 from v3,t1; +ERROR HY000: Can not delete from join view 'test.v3' +delete t1,v3 from t1,v3; +ERROR HY000: Can not delete from join view 'test.v3' +delete from t1; +prepare stmt1 from "insert into v3(a) values (?);"; +set @a= 100; +execute stmt1 using @a; +set @a= 300; +execute stmt1 using @a; +deallocate prepare stmt1; +prepare stmt1 from "insert into v3(a) select ?;"; +set @a= 101; +execute stmt1 using @a; +set @a= 301; +execute stmt1 using @a; +deallocate prepare stmt1; +select * from v3; +a b +100 10 +100 1000 +101 10 +101 1000 +300 10 +300 1000 +301 10 +301 1000 +drop view v3; +drop tables t1,t2; +create table t1(f1 int); +create view v1 as select f1 from t1; +select * from v1 where F1 = 1; +f1 +drop view v1; +drop table t1; +create table t1(c1 int); +create table t2(c2 int); +insert into t1 values (1),(2),(3); +insert into t2 values (1); +SELECT c1 FROM t1 WHERE c1 IN (SELECT c2 FROM t2); +c1 +1 +SELECT c1 FROM t1 WHERE EXISTS (SELECT c2 FROM t2 WHERE c2 = c1); +c1 +1 +create view v1 as SELECT c1 FROM t1 WHERE c1 IN (SELECT c2 FROM t2); +create view v2 as SELECT c1 FROM t1 WHERE EXISTS (SELECT c2 FROM t2 WHERE c2 = c1); +select * from v1; +c1 +1 +select * from v2; +c1 +1 +select * from (select c1 from v2) X; +c1 +1 +drop view v2, v1; +drop table t1, t2; +CREATE TABLE t1 (C1 INT, C2 INT); +CREATE TABLE t2 (C2 INT); +CREATE VIEW v1 AS SELECT C2 FROM t2; +CREATE VIEW v2 AS SELECT C1 FROM t1 LEFT OUTER JOIN v1 USING (C2); +SELECT * FROM v2; +C1 +drop view v2, v1; +drop table t1, t2; +create table t1 (col1 char(5),col2 int,col3 int); +insert into t1 values ('one',10,25), ('two',10,50), ('two',10,50), ('one',20,25), ('one',30,25); +create view v1 as select * from t1; +select col1,group_concat(col2,col3) from t1 group by col1; +col1 group_concat(col2,col3) +one 1025,2025,3025 +two 1050,1050 +select col1,group_concat(col2,col3) from v1 group by col1; +col1 group_concat(col2,col3) +one 1025,2025,3025 +two 1050,1050 +drop view v1; +drop table t1; +create table t1 (s1 int, s2 char); +create view v1 as select s1, s2 from t1; +select s2 from v1 vq1 where 2 = (select count(*) from v1 vq2 having vq1.s2 = vq2.s2); +ERROR 42S22: Unknown column 'vq2.s2' in 'having clause' +select s2 from v1 vq1 where 2 = (select count(*) aa from v1 vq2 having vq1.s2 = aa); +s2 +drop view v1; +drop table t1; +CREATE TABLE t1 (a1 int); +CREATE TABLE t2 (a2 int); +INSERT INTO t1 VALUES (1), (2), (3), (4); +INSERT INTO t2 VALUES (1), (2), (3); +CREATE VIEW v1(a,b) AS SELECT a1,a2 FROM t1 JOIN t2 ON a1=a2 WHERE a1>1; +SELECT * FROM v1; +a b +2 2 +3 3 +CREATE TABLE t3 SELECT * FROM v1; +SELECT * FROM t3; +a b +2 2 +3 3 +DROP VIEW v1; +DROP TABLE t1,t2,t3; +create table t1 (a int); +create table t2 like t1; +create table t3 like t1; +create view v1 as select t1.a x, t2.a y from t1 join t2 where t1.a=t2.a; +insert into t3 select x from v1; +insert into t2 select x from v1; +drop view v1; +drop table t1,t2,t3; +CREATE TABLE t1 (col1 int PRIMARY KEY, col2 varchar(10)); +INSERT INTO t1 VALUES(1,'trudy'); +INSERT INTO t1 VALUES(2,'peter'); +INSERT INTO t1 VALUES(3,'sanja'); +INSERT INTO t1 VALUES(4,'monty'); +INSERT INTO t1 VALUES(5,'david'); +INSERT INTO t1 VALUES(6,'kent'); +INSERT INTO t1 VALUES(7,'carsten'); +INSERT INTO t1 VALUES(8,'ranger'); +INSERT INTO t1 VALUES(10,'matt'); +CREATE TABLE t2 (col1 int, col2 int, col3 char(1)); +INSERT INTO t2 VALUES (1,1,'y'); +INSERT INTO t2 VALUES (1,2,'y'); +INSERT INTO t2 VALUES (2,1,'n'); +INSERT INTO t2 VALUES (3,1,'n'); +INSERT INTO t2 VALUES (4,1,'y'); +INSERT INTO t2 VALUES (4,2,'n'); +INSERT INTO t2 VALUES (4,3,'n'); +INSERT INTO t2 VALUES (6,1,'n'); +INSERT INTO t2 VALUES (8,1,'y'); +CREATE VIEW v1 AS SELECT * FROM t1; +SELECT a.col1,a.col2,b.col2,b.col3 +FROM t1 a LEFT JOIN t2 b ON a.col1=b.col1 +WHERE b.col2 IS NULL OR +b.col2=(SELECT MAX(col2) FROM t2 b WHERE b.col1=a.col1); +col1 col2 col2 col3 +1 trudy 2 y +10 matt NULL NULL +2 peter 1 n +3 sanja 1 n +4 monty 3 n +5 david NULL NULL +6 kent 1 n +7 carsten NULL NULL +8 ranger 1 y +SELECT a.col1,a.col2,b.col2,b.col3 +FROM v1 a LEFT JOIN t2 b ON a.col1=b.col1 +WHERE b.col2 IS NULL OR +b.col2=(SELECT MAX(col2) FROM t2 b WHERE b.col1=a.col1); +col1 col2 col2 col3 +1 trudy 2 y +10 matt NULL NULL +2 peter 1 n +3 sanja 1 n +4 monty 3 n +5 david NULL NULL +6 kent 1 n +7 carsten NULL NULL +8 ranger 1 y +CREATE VIEW v2 AS SELECT * FROM t2; +SELECT a.col1,a.col2,b.col2,b.col3 +FROM v2 b RIGHT JOIN v1 a ON a.col1=b.col1 +WHERE b.col2 IS NULL OR +b.col2=(SELECT MAX(col2) FROM v2 b WHERE b.col1=a.col1); +col1 col2 col2 col3 +1 trudy 2 y +10 matt NULL NULL +2 peter 1 n +3 sanja 1 n +4 monty 3 n +5 david NULL NULL +6 kent 1 n +7 carsten NULL NULL +8 ranger 1 y +SELECT a.col1,a.col2,b.col2,b.col3 +FROM v2 b RIGHT JOIN v1 a ON a.col1=b.col1 +WHERE a.col1 IN (1,5,9) AND +(b.col2 IS NULL OR +b.col2=(SELECT MAX(col2) FROM v2 b WHERE b.col1=a.col1)); +col1 col2 col2 col3 +1 trudy 2 y +5 david NULL NULL +CREATE VIEW v3 AS SELECT * FROM t1 WHERE col1 IN (1,5,9); +SELECT a.col1,a.col2,b.col2,b.col3 +FROM v2 b RIGHT JOIN v3 a ON a.col1=b.col1 +WHERE b.col2 IS NULL OR +b.col2=(SELECT MAX(col2) FROM v2 b WHERE b.col1=a.col1); +col1 col2 col2 col3 +1 trudy 2 y +5 david NULL NULL +DROP VIEW v1,v2,v3; +DROP TABLE t1,t2; +create table t1 as select 1 A union select 2 union select 3; +create table t2 as select * from t1; +create view v1 as select * from t1 where a in (select * from t2); +select * from v1 A, v1 B where A.a = B.a; +A A +1 1 +2 2 +3 3 +create table t3 as select a a,a b from t2; +create view v2 as select * from t3 where +a in (select * from t1) or b in (select * from t2); +select * from v2 A, v2 B where A.a = B.b; +a b a b +1 1 1 1 +2 2 2 2 +3 3 3 3 +drop view v1, v2; +drop table t1, t2, t3; +CREATE TABLE t1 (a int); +CREATE TABLE t2 (b int); +INSERT INTO t1 VALUES (1), (2), (3), (4); +INSERT INTO t2 VALUES (4), (2); +CREATE VIEW v1 AS SELECT * FROM t1,t2 WHERE t1.a=t2.b; +SELECT * FROM v1; +a b +2 2 +4 4 +CREATE VIEW v2 AS SELECT * FROM v1; +SELECT * FROM v2; +a b +2 2 +4 4 +DROP VIEW v2,v1; +DROP TABLE t1, t2; +create table t1 (a int); +create view v1 as select sum(a) from t1 group by a; +create procedure p1() +begin +select * from v1; +end// +call p1(); +sum(a) +call p1(); +sum(a) +drop procedure p1; +drop view v1; +drop table t1; +CREATE TABLE t1(a char(2) primary key, b char(2)); +CREATE TABLE t2(a char(2), b char(2), index i(a)); +INSERT INTO t1 VALUES ('a','1'), ('b','2'); +INSERT INTO t2 VALUES ('a','5'), ('a','6'), ('b','5'), ('b','6'); +CREATE VIEW v1 AS +SELECT t1.b as c, t2.b as d FROM t1,t2 WHERE t1.a=t2.a; +SELECT d, c FROM v1 ORDER BY d,c; +d c +5 1 +5 2 +6 1 +6 2 +DROP VIEW v1; +DROP TABLE t1, t2; +create table t1 (s1 int); +create view v1 as select sum(distinct s1) from t1; +select * from v1; +sum(distinct s1) +NULL +drop view v1; +create view v1 as select avg(distinct s1) from t1; +select * from v1; +avg(distinct s1) +NULL +drop view v1; +drop table t1; +create view v1 as select cast(1 as decimal); +select * from v1; +cast(1 as decimal) +1 +drop view v1; +create table t1(f1 int); +create table t2(f2 int); +insert into t1 values(1),(2),(3); +insert into t2 values(1),(2),(3); +create view v1 as select * from t1,t2 where f1=f2; +create table t3 (f1 int, f2 int); +insert into t3 select * from v1 order by 1; +select * from t3; +f1 f2 +1 1 +2 2 +3 3 +drop view v1; +drop table t1,t2,t3; +create view v1 as select '\\','\\shazam'; +select * from v1; +\ \shazam +\ \shazam +drop view v1; +create view v1 as select '\'','\shazam'; +select * from v1; +' shazam +' shazam +drop view v1; +create view v1 as select 'k','K'; +select * from v1; +k Name_exp_K +k K +drop view v1; +create table t1 (s1 int); +create view v1 as select s1, 's1' from t1; +select * from v1; +s1 Name_exp_s1 +drop view v1; +create view v1 as select 's1', s1 from t1; +select * from v1; +Name_exp_s1 s1 +drop view v1; +create view v1 as select 's1', s1, 1 as Name_exp_s1 from t1; +select * from v1; +Name_exp_1_s1 s1 Name_exp_s1 +drop view v1; +create view v1 as select 1 as Name_exp_s1, 's1', s1 from t1; +select * from v1; +Name_exp_s1 Name_exp_1_s1 s1 +drop view v1; +create view v1 as select 1 as s1, 's1', 's1' from t1; +select * from v1; +s1 Name_exp_s1 Name_exp_1_s1 +drop view v1; +create view v1 as select 's1', 's1', 1 as s1 from t1; +select * from v1; +Name_exp_1_s1 Name_exp_s1 s1 +drop view v1; +create view v1 as select s1, 's1', 's1' from t1; +select * from v1; +s1 Name_exp_s1 Name_exp_1_s1 +drop view v1; +create view v1 as select 's1', 's1', s1 from t1; +select * from v1; +Name_exp_1_s1 Name_exp_s1 s1 +drop view v1; +create view v1 as select 1 as s1, 's1', s1 from t1; +ERROR 42S21: Duplicate column name 's1' +create view v1 as select 's1', s1, 1 as s1 from t1; +ERROR 42S21: Duplicate column name 's1' +drop table t1; +create view v1(k, K) as select 1,2; +ERROR 42S21: Duplicate column name 'k' +create view v1 as SELECT TIME_FORMAT(SEC_TO_TIME(3600),'%H:%i') as t; +select * from v1; +t +01:00 +drop view v1; +create table t1 (a timestamp default now()); +create table t2 (b timestamp default now()); +create view v1 as select a,b,t1.a < now() from t1,t2 where t1.a < now(); +SHOW CREATE VIEW v1; +View Create View character_set_client collation_connection +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`a` AS `a`,`t2`.`b` AS `b`,(`t1`.`a` < now()) AS `t1.a < now()` from (`t1` join `t2`) where (`t1`.`a` < now()) utf8mb4 utf8mb4_0900_ai_ci +drop view v1; +drop table t1, t2; +CREATE TABLE t1 ( a varchar(50) ); +CREATE VIEW v1 AS SELECT * FROM t1 WHERE a = CURRENT_USER(); +SHOW CREATE VIEW v1; +View Create View character_set_client collation_connection +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`a` AS `a` from `t1` where (`t1`.`a` = current_user()) utf8mb4 utf8mb4_0900_ai_ci +DROP VIEW v1; +CREATE VIEW v1 AS SELECT * FROM t1 WHERE a = VERSION(); +SHOW CREATE VIEW v1; +View Create View character_set_client collation_connection +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`a` AS `a` from `t1` where (`t1`.`a` = version()) utf8mb4 utf8mb4_0900_ai_ci +DROP VIEW v1; +CREATE VIEW v1 AS SELECT * FROM t1 WHERE a = DATABASE(); +SHOW CREATE VIEW v1; +View Create View character_set_client collation_connection +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`a` AS `a` from `t1` where (`t1`.`a` = database()) utf8mb4 utf8mb4_0900_ai_ci +DROP VIEW v1; +DROP TABLE t1; +CREATE TABLE t1 (col1 time); +CREATE TABLE t2 (col1 time); +CREATE VIEW v1 AS SELECT CONVERT_TZ(col1,'GMT','MET') FROM t1; +CREATE VIEW v2 AS SELECT CONVERT_TZ(col1,'GMT','MET') FROM t2; +CREATE VIEW v3 AS SELECT CONVERT_TZ(col1,'GMT','MET') FROM t1; +CREATE VIEW v4 AS SELECT CONVERT_TZ(col1,'GMT','MET') FROM t2; +CREATE VIEW v5 AS SELECT CONVERT_TZ(col1,'GMT','MET') FROM t1; +CREATE VIEW v6 AS SELECT CONVERT_TZ(col1,'GMT','MET') FROM t2; +DROP TABLE t1; +CHECK TABLE v1, v2, v3, v4, v5, v6; +Table Op Msg_type Msg_text +test.v1 check Error View 'test.v1' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +test.v1 check error Corrupt +test.v2 check status OK +test.v3 check Error View 'test.v3' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +test.v3 check error Corrupt +test.v4 check status OK +test.v5 check Error View 'test.v5' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +test.v5 check error Corrupt +test.v6 check status OK +drop view v1, v2, v3, v4, v5, v6; +drop table t2; +drop function if exists f1; +drop function if exists f2; +CREATE TABLE t1 (col1 time); +CREATE TABLE t2 (col1 time); +CREATE TABLE t3 (col1 time); +create function f1 () returns int return (select max(col1) from t1); +create function f2 () returns int return (select max(col1) from t2); +CREATE VIEW v1 AS SELECT f1() FROM t3; +CREATE VIEW v2 AS SELECT f2() FROM t3; +CREATE VIEW v3 AS SELECT f1() FROM t3; +CREATE VIEW v4 AS SELECT f2() FROM t3; +CREATE VIEW v5 AS SELECT f1() FROM t3; +CREATE VIEW v6 AS SELECT f2() FROM t3; +drop function f1; +CHECK TABLE v1, v2, v3, v4, v5, v6; +Table Op Msg_type Msg_text +test.v1 check Error View 'test.v1' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +test.v1 check status Operation failed +test.v2 check status OK +test.v3 check Error View 'test.v3' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +test.v3 check status Operation failed +test.v4 check status OK +test.v5 check Error View 'test.v5' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +test.v5 check status Operation failed +test.v6 check status OK +create function f1 () returns int return (select max(col1) from t1); +DROP TABLE t1; +CHECK TABLE v1, v2, v3, v4, v5, v6; +Table Op Msg_type Msg_text +test.v1 check status OK +test.v2 check status OK +test.v3 check status OK +test.v4 check status OK +test.v5 check status OK +test.v6 check status OK +drop function f1; +drop function f2; +drop view v1, v2, v3, v4, v5, v6; +drop table t2,t3; +create table t1 (f1 date); +insert into t1 values ('2005-01-01'),('2005-02-02'); +create view v1 as select * from t1; +select * from v1 where f1='2005.02.02'; +f1 +2005-02-02 +select * from v1 where '2005.02.02'=f1; +f1 +2005-02-02 +drop view v1; +drop table t1; +CREATE VIEW v1 AS SELECT SUBSTRING_INDEX("dkjhgd:kjhdjh", ":", 1); +SELECT * FROM v1; +SUBSTRING_INDEX("dkjhgd:kjhdjh", ":", 1) +dkjhgd +drop view v1; +create table t1 (f59 int, f60 int, f61 int); +insert into t1 values (19,41,32); +create view v1 as select f59, f60 from t1 where f59 in +(select f59 from t1); +update v1 set f60=2345; +ERROR HY000: The target table v1 of the UPDATE is not updatable +update t1 set f60=(select max(f60) from v1); +ERROR HY000: The definition of table 'v1' prevents operation UPDATE on table 't1'. +drop view v1; +drop table t1; +create table t1 (s1 int); +create view v1 as select var_samp(s1) from t1; +show create view v1; +View Create View character_set_client collation_connection +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select var_samp(`t1`.`s1`) AS `var_samp(s1)` from `t1` utf8mb4 utf8mb4_0900_ai_ci +drop view v1; +drop table t1; +CREATE TABLE t1 (col1 INT NOT NULL, col2 INT NOT NULL); +CREATE VIEW v1 (vcol1) AS SELECT col1 FROM t1; +CREATE VIEW v2 (vcol1) AS SELECT col1 FROM t1 WHERE col2 > 2; +INSERT INTO t1 (col1) VALUES(12); +ERROR HY000: Field 'col2' doesn't have a default value +INSERT INTO v1 (vcol1) VALUES(12); +ERROR HY000: Field of view 'test.v1' underlying table doesn't have a default value +INSERT INTO v2 (vcol1) VALUES(12); +ERROR HY000: Field of view 'test.v2' underlying table doesn't have a default value +drop view v2,v1; +drop table t1; +create table t1 (f1 int); +insert into t1 values (1); +create view v1 as select f1 from t1; +select f1 as alias from v1; +alias +1 +drop view v1; +drop table t1; +CREATE TABLE t1 (s1 int, s2 int); +INSERT INTO t1 VALUES (1,2); +CREATE VIEW v1 AS SELECT s2 AS s1, s1 AS s2 FROM t1; +SELECT * FROM v1; +s1 s2 +2 1 +CREATE PROCEDURE p1 () SELECT * FROM v1; +CALL p1(); +s1 s2 +2 1 +ALTER VIEW v1 AS SELECT s1 AS s1, s2 AS s2 FROM t1; +CALL p1(); +s1 s2 +1 2 +DROP VIEW v1; +CREATE VIEW v1 AS SELECT s2 AS s1, s1 AS s2 FROM t1; +CALL p1(); +s1 s2 +2 1 +DROP PROCEDURE p1; +DROP VIEW v1; +DROP TABLE t1; +create table t1 (f1 int, f2 int); +create view v1 as select f1 as f3, f2 as f1 from t1; +insert into t1 values (1,3),(2,1),(3,2); +select * from v1 order by f1; +f3 f1 +2 1 +3 2 +1 3 +drop view v1; +drop table t1; +CREATE TABLE t1 (f1 char); +INSERT INTO t1 VALUES ('A'); +CREATE VIEW v1 AS SELECT * FROM t1; +INSERT INTO t1 VALUES('B'); +SELECT * FROM v1; +f1 +A +B +SELECT * FROM t1; +f1 +A +B +DROP VIEW v1; +DROP TABLE t1; +CREATE TABLE t1 ( bug_table_seq INTEGER NOT NULL); +CREATE OR REPLACE VIEW v1 AS SELECT * from t1; +DROP PROCEDURE IF EXISTS p1; +Warnings: +Note 1305 PROCEDURE test.p1 does not exist +CREATE PROCEDURE p1 ( ) +BEGIN +DO (SELECT @next := IFNULL(max(bug_table_seq),0) + 1 FROM v1); +INSERT INTO t1 VALUES (1); +END // +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +CALL p1(); +DROP PROCEDURE p1; +DROP VIEW v1; +DROP TABLE t1; +create table t1(f1 datetime); +insert into t1 values('2005.01.01 12:0:0'); +create view v1 as select f1, subtime(f1, '1:1:1') as sb from t1; +select * from v1; +f1 sb +2005-01-01 12:00:00 2005-01-01 10:58:59 +drop view v1; +drop table t1; +CREATE TABLE t1 ( +aid int PRIMARY KEY, +fn varchar(20) NOT NULL, +ln varchar(20) NOT NULL +); +CREATE TABLE t2 ( +aid int NOT NULL, +pid int NOT NULL +); +INSERT INTO t1 VALUES(1,'a','b'), (2,'c','d'); +INSERT INTO t2 values (1,1), (2,1), (2,2); +CREATE VIEW v1 AS SELECT t1.*,t2.pid FROM t1,t2 WHERE t1.aid = t2.aid; +SELECT pid,GROUP_CONCAT(CONCAT(fn,' ',ln) ORDER BY 1) FROM t1,t2 +WHERE t1.aid = t2.aid GROUP BY pid; +pid GROUP_CONCAT(CONCAT(fn,' ',ln) ORDER BY 1) +1 a b,c d +2 c d +SELECT pid,GROUP_CONCAT(CONCAT(fn,' ',ln) ORDER BY 1) FROM v1 GROUP BY pid; +pid GROUP_CONCAT(CONCAT(fn,' ',ln) ORDER BY 1) +1 a b,c d +2 c d +DROP VIEW v1; +DROP TABLE t1,t2; +CREATE TABLE t1 (id int PRIMARY KEY, f varchar(255)); +CREATE VIEW v1 AS SELECT id, f FROM t1 WHERE id <= 2; +INSERT INTO t1 VALUES (2, 'foo2'); +INSERT INTO t1 VALUES (1, 'foo1'); +SELECT * FROM v1; +id f +1 foo1 +2 foo2 +SELECT * FROM v1; +id f +1 foo1 +2 foo2 +DROP VIEW v1; +DROP TABLE t1; +CREATE TABLE t1 (pk int PRIMARY KEY, b int); +CREATE TABLE t2 (pk int PRIMARY KEY, fk int, INDEX idx(fk)); +CREATE TABLE t3 (pk int PRIMARY KEY, fk int, INDEX idx(fk)); +CREATE TABLE t4 (pk int PRIMARY KEY, fk int, INDEX idx(fk)); +CREATE TABLE t5 (pk int PRIMARY KEY, fk int, INDEX idx(fk)); +CREATE VIEW v1 AS +SELECT t1.pk as a FROM t1,t2,t3,t4,t5 +WHERE t1.b IS NULL AND +t1.pk=t2.fk AND t2.pk=t3.fk AND t3.pk=t4.fk AND t4.pk=t5.fk; +SELECT a FROM v1; +a +DROP VIEW v1; +DROP TABLE t1,t2,t3,t4,t5; +create view v1 as select timestampdiff(day,'1997-01-01 00:00:00','1997-01-02 00:00:00') as f1; +select * from v1; +f1 +1 +drop view v1; +create table t1(a int); +create procedure p1() create view v1 as select * from t1; +drop table t1; +call p1(); +ERROR 42S02: Table 'test.t1' doesn't exist +call p1(); +ERROR 42S02: Table 'test.t1' doesn't exist +drop procedure p1; +create table t1 (f1 int); +create table t2 (f1 int); +insert into t1 values (1); +insert into t2 values (2); +create view v1 as select * from t1 union select * from t2 union all select * from t2; +select * from v1; +f1 +1 +2 +2 +drop view v1; +drop table t1,t2; +CREATE TEMPORARY TABLE t1 (a int); +CREATE FUNCTION f1 () RETURNS int RETURN (SELECT COUNT(*) FROM t1); +CREATE VIEW v1 AS SELECT f1(); +ERROR HY000: View's SELECT refers to a temporary table 't1' +DROP FUNCTION f1; +DROP TABLE t1; +DROP TABLE IF EXISTS t1; +DROP VIEW IF EXISTS v1; +CREATE TABLE t1 (f4 CHAR(5)); +CREATE VIEW v1 AS SELECT * FROM t1; +DESCRIBE v1; +Field Type Null Key Default Extra +f4 char(5) YES NULL +ALTER TABLE t1 CHANGE COLUMN f4 f4x CHAR(5); +DESCRIBE v1; +ERROR HY000: View 'test.v1' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +DROP TABLE t1; +DROP VIEW v1; +create table t1 (f1 char); +create view v1 as select strcmp(f1,'a') from t1; +select * from v1; +strcmp(f1,'a') +drop view v1; +drop table t1; +create table t1 (f1 int, f2 int,f3 int); +insert into t1 values (1,10,20),(2,0,0); +create view v1 as select * from t1; +select if(sum(f1)>1,f2,f3) from v1 group by f1; +if(sum(f1)>1,f2,f3) +20 +0 +drop view v1; +drop table t1; +create table t1 ( +r_object_id char(16) NOT NULL, +group_name varchar(32) NOT NULL +) engine = InnoDB; +create table t2 ( +r_object_id char(16) NOT NULL, +i_position int(11) NOT NULL, +users_names varchar(32) default NULL +) Engine = InnoDB; +create view v1 as select r_object_id, group_name from t1; +create view v2 as select r_object_id, i_position, users_names from t2; +create unique index r_object_id on t1(r_object_id); +create index group_name on t1(group_name); +create unique index r_object_id_i_position on t2(r_object_id,i_position); +create index users_names on t2(users_names); +insert into t1 values('120001a080000542','tstgroup1'); +insert into t2 values('120001a080000542',-1, 'guser01'); +insert into t2 values('120001a080000542',-2, 'guser02'); +select v1.r_object_id, v2.users_names from v1, v2 +where (v1.group_name='tstgroup1') and v2.r_object_id=v1.r_object_id +order by users_names; +r_object_id users_names +120001a080000542 guser01 +120001a080000542 guser02 +drop view v1, v2; +drop table t1, t2; +create table t1 (s1 int); +create view abc as select * from t1 as abc; +drop table t1; +drop view abc; +create table t1(f1 char(1)); +create view v1 as select * from t1; +select * from (select f1 as f2 from v1) v where v.f2='a'; +f2 +drop view v1; +drop table t1; +create view v1 as SELECT CONVERT_TZ('2004-01-01 12:00:00','GMT','MET'); +select * from v1; +CONVERT_TZ('2004-01-01 12:00:00','GMT','MET') +NULL +drop view v1; +CREATE TABLE t1 (date DATE NOT NULL); +INSERT INTO t1 VALUES ('2005-09-06'); +CREATE VIEW v1 AS SELECT DAYNAME(date) FROM t1; +SHOW CREATE VIEW v1; +View Create View character_set_client collation_connection +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select dayname(`t1`.`date`) AS `DAYNAME(date)` from `t1` utf8mb4 utf8mb4_0900_ai_ci +CREATE VIEW v2 AS SELECT DAYOFWEEK(date) FROM t1; +SHOW CREATE VIEW v2; +View Create View character_set_client collation_connection +v2 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v2` AS select dayofweek(`t1`.`date`) AS `DAYOFWEEK(date)` from `t1` utf8mb4 utf8mb4_0900_ai_ci +CREATE VIEW v3 AS SELECT WEEKDAY(date) FROM t1; +SHOW CREATE VIEW v3; +View Create View character_set_client collation_connection +v3 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v3` AS select weekday(`t1`.`date`) AS `WEEKDAY(date)` from `t1` utf8mb4 utf8mb4_0900_ai_ci +SELECT DAYNAME('2005-09-06'); +DAYNAME('2005-09-06') +Tuesday +SELECT DAYNAME(date) FROM t1; +DAYNAME(date) +Tuesday +SELECT * FROM v1; +DAYNAME(date) +Tuesday +SELECT DAYOFWEEK('2005-09-06'); +DAYOFWEEK('2005-09-06') +3 +SELECT DAYOFWEEK(date) FROM t1; +DAYOFWEEK(date) +3 +SELECT * FROM v2; +DAYOFWEEK(date) +3 +SELECT WEEKDAY('2005-09-06'); +WEEKDAY('2005-09-06') +1 +SELECT WEEKDAY(date) FROM t1; +WEEKDAY(date) +1 +SELECT * FROM v3; +WEEKDAY(date) +1 +DROP TABLE t1; +DROP VIEW v1, v2, v3; +CREATE TABLE t1 ( a int, b int ); +INSERT INTO t1 VALUES (1,1),(2,2),(3,3); +CREATE VIEW v1 AS SELECT a,b FROM t1; +SELECT t1.a FROM t1 GROUP BY t1.a HAVING a > 1; +a +2 +3 +SELECT v1.a FROM v1 GROUP BY v1.a HAVING a > 1; +a +2 +3 +DROP VIEW v1; +DROP TABLE t1; +CREATE TABLE t1 ( a int, b int ); +INSERT INTO t1 VALUES (1,1),(2,2),(3,3); +CREATE VIEW v1 AS SELECT a,b FROM t1; +SELECT t1.a FROM t1 GROUP BY t1.a HAVING t1.a > 1; +a +2 +3 +SELECT v1.a FROM v1 GROUP BY v1.a HAVING v1.a > 1; +a +2 +3 +SELECT t_1.a FROM t1 AS t_1 GROUP BY t_1.a HAVING t_1.a IN (1,2,3); +a +1 +2 +3 +SELECT v_1.a FROM v1 AS v_1 GROUP BY v_1.a HAVING v_1.a IN (1,2,3); +a +1 +2 +3 +DROP VIEW v1; +DROP TABLE t1; +CREATE TABLE t1 (a INT, b INT, INDEX(a,b)); +CREATE TABLE t2 LIKE t1; +CREATE TABLE t3 (a INT); +INSERT INTO t1 VALUES (1,1),(2,2),(3,3); +INSERT INTO t2 VALUES (1,1),(2,2),(3,3); +INSERT INTO t3 VALUES (1),(2),(3); +ANALYZE TABLE t1,t2,t3; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +CREATE VIEW v1 AS SELECT t1.* FROM t1,t2 WHERE t1.a=t2.a AND t1.b=t2.b; +CREATE VIEW v2 AS SELECT t3.* FROM t1,t3 WHERE t1.a=t3.a; +EXPLAIN SELECT t1.* FROM t1 JOIN t2 WHERE t1.a=t2.a AND t1.b=t2.b AND t1.a=1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # # Parallel execute (1 workers) +2 SIMPLE t1 NULL ref a a 5 const # # Using where; Using index +2 SIMPLE t2 NULL ref a a 10 const,test.t1.b # # Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t1`.`a` = 1) and (`test`.`t2`.`a` = 1)) +EXPLAIN SELECT * FROM v1 WHERE a=1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ref a a 5 const # # Using where; Using index +1 SIMPLE t2 NULL ref a a 10 const,test.t1.b # # Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t1`.`a` = 1) and (`test`.`t2`.`a` = 1)) +EXPLAIN SELECT * FROM v2 WHERE a=1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ref a a 5 const # # Using index +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL # # Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a` from `test`.`t1` join `test`.`t3` where ((`test`.`t1`.`a` = 1) and (`test`.`t3`.`a` = 1)) +DROP VIEW v1,v2; +DROP TABLE t1,t2,t3; +create table t1 (f1 int); +create view v1 as select t1.f1 as '123 +456' from t1; +select * from v1; +123 +456 +drop view v1; +drop table t1; +create table t1 (f1 int, f2 int); +insert into t1 values(1,1),(1,2),(1,3); +create view v1 as select f1 ,group_concat(f2 order by f2 asc) from t1 group by f1; +create view v2 as select f1 ,group_concat(f2 order by f2 desc) from t1 group by f1; +select * from v1; +f1 group_concat(f2 order by f2 asc) +1 1,2,3 +select * from v2; +f1 group_concat(f2 order by f2 desc) +1 3,2,1 +drop view v1,v2; +drop table t1; +create table t1 (x int, y int); +create table t2 (x int, y int, z int); +create table t3 (x int, y int, z int); +create table t4 (x int, y int, z int); +create view v1 as +select t1.x +from ( +(t1 join t2 on ((t1.y = t2.y))) +join +(t3 left join t4 on (t3.y = t4.y) and (t3.z = t4.z)) +); +prepare stmt1 from "select count(*) from v1 where x = ?"; +set @parm1=1; +execute stmt1 using @parm1; +count(*) +0 +execute stmt1 using @parm1; +count(*) +0 +drop view v1; +drop table t1,t2,t3,t4; +CREATE TABLE t1(id INT); +CREATE VIEW v1 AS SELECT id FROM t1; +OPTIMIZE TABLE v1; +Table Op Msg_type Msg_text +test.v1 optimize Error 'test.v1' is not BASE TABLE +test.v1 optimize status Operation failed +ANALYZE TABLE v1; +Table Op Msg_type Msg_text +test.v1 analyze Error 'test.v1' is not BASE TABLE +test.v1 analyze status Operation failed +REPAIR TABLE v1; +Table Op Msg_type Msg_text +test.v1 repair Error 'test.v1' is not BASE TABLE +test.v1 repair status Operation failed +DROP TABLE t1; +OPTIMIZE TABLE v1; +Table Op Msg_type Msg_text +test.v1 optimize Error 'test.v1' is not BASE TABLE +test.v1 optimize status Operation failed +ANALYZE TABLE v1; +Table Op Msg_type Msg_text +test.v1 analyze Error 'test.v1' is not BASE TABLE +test.v1 analyze status Operation failed +REPAIR TABLE v1; +Table Op Msg_type Msg_text +test.v1 repair Error 'test.v1' is not BASE TABLE +test.v1 repair status Operation failed +DROP VIEW v1; +create definer = current_user() sql security invoker view v1 as select 1; +show create view v1; +View Create View character_set_client collation_connection +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY INVOKER VIEW `v1` AS select 1 AS `1` utf8mb4 utf8mb4_0900_ai_ci +drop view v1; +create definer = current_user sql security invoker view v1 as select 1; +show create view v1; +View Create View character_set_client collation_connection +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY INVOKER VIEW `v1` AS select 1 AS `1` utf8mb4 utf8mb4_0900_ai_ci +drop view v1; +create table t1 (id INT, primary key(id)); +insert into t1 values (1),(2); +analyze table t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +create view v1 as select * from t1; +explain select id from v1 order by id; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index NULL PRIMARY 4 NULL # # Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id` from `test`.`t1` order by `test`.`t1`.`id` +drop view v1; +drop table t1; +create table t1(f1 int, f2 int); +insert into t1 values (null, 10), (null,2); +select f1, sum(f2) from t1 group by f1; +f1 sum(f2) +NULL 12 +create view v1 as select * from t1; +select f1, sum(f2) from v1 group by f1; +f1 sum(f2) +NULL 12 +drop view v1; +drop table t1; +drop procedure if exists p1; +create procedure p1 () deterministic +begin +create view v1 as select 1; +end; +// +call p1(); +show create view v1; +View Create View character_set_client collation_connection +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select 1 AS `1` utf8mb4 utf8mb4_0900_ai_ci +drop view v1; +drop procedure p1; +CREATE VIEW v1 AS SELECT 42 AS Meaning; +DROP FUNCTION IF EXISTS f1; +CREATE FUNCTION f1() RETURNS INTEGER +BEGIN +DECLARE retn INTEGER; +SELECT Meaning FROM v1 INTO retn; +RETURN retn; +END +// +CREATE VIEW v2 AS SELECT f1(); +select * from v2; +f1() +42 +drop view v2,v1; +drop function f1; +create table t1 (id numeric, warehouse_id numeric); +create view v1 as select id from t1; +create view v2 as +select t1.warehouse_id, v1.id as receipt_id +from t1, v1 where t1.id = v1.id; +insert into t1 (id, warehouse_id) values(3, 2); +insert into t1 (id, warehouse_id) values(4, 2); +insert into t1 (id, warehouse_id) values(5, 1); +select v2.receipt_id as alias1, v2.receipt_id as alias2 from v2 +order by v2.receipt_id; +alias1 alias2 +3 3 +4 4 +5 5 +drop view v2, v1; +drop table t1; +CREATE TABLE t1 (a int PRIMARY KEY, b int); +INSERT INTO t1 VALUES (2,20), (3,10), (1,10), (0,30), (5,10); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +CREATE VIEW v1 AS SELECT * FROM t1; +SELECT MAX(a) FROM t1; +MAX(a) +5 +SELECT MAX(a) FROM v1; +MAX(a) +5 +EXPLAIN SELECT MAX(a) FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Select tables optimized away +Warnings: +Note 1003 /* select#1 */ select max(`test`.`t1`.`a`) AS `MAX(a)` from `test`.`t1` +EXPLAIN SELECT MAX(a) FROM v1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Select tables optimized away +Warnings: +Note 1003 /* select#1 */ select max(`test`.`t1`.`a`) AS `MAX(a)` from `test`.`t1` +SELECT MIN(a) FROM t1; +MIN(a) +0 +SELECT MIN(a) FROM v1; +MIN(a) +0 +EXPLAIN SELECT MIN(a) FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Select tables optimized away +Warnings: +Note 1003 /* select#1 */ select min(`test`.`t1`.`a`) AS `MIN(a)` from `test`.`t1` +EXPLAIN SELECT MIN(a) FROM v1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Select tables optimized away +Warnings: +Note 1003 /* select#1 */ select min(`test`.`t1`.`a`) AS `MIN(a)` from `test`.`t1` +DROP VIEW v1; +DROP TABLE t1; +CREATE TABLE t1 (x varchar(10)); +INSERT INTO t1 VALUES (null), ('foo'), ('bar'), (null); +CREATE VIEW v1 AS SELECT * FROM t1; +SELECT IF(x IS NULL, 'blank', 'not blank') FROM v1 GROUP BY x; +IF(x IS NULL, 'blank', 'not blank') +blank +not blank +not blank +SELECT IF(x IS NULL, 'blank', 'not blank') AS x FROM t1 GROUP BY x; +x +blank +not blank +not blank +Warnings: +Warning 1052 Column 'x' in group statement is ambiguous +SELECT IF(x IS NULL, 'blank', 'not blank') AS x FROM v1; +x +blank +not blank +not blank +blank +SELECT IF(x IS NULL, 'blank', 'not blank') AS y FROM v1 GROUP BY y; +y +blank +not blank +SELECT IF(x IS NULL, 'blank', 'not blank') AS x FROM v1 GROUP BY x; +x +blank +not blank +not blank +Warnings: +Warning 1052 Column 'x' in group statement is ambiguous +DROP VIEW v1; +DROP TABLE t1; +drop table if exists t1; +drop view if exists v1; +create table t1 (id int); +create view v1 as select * from t1; +drop table t1; +show create view v1; +drop view v1; +// +View Create View character_set_client collation_connection +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`id` AS `id` from `t1` utf8mb4 utf8mb4_0900_ai_ci +create table t1(f1 int, f2 int); +create view v1 as select ta.f1 as a, tb.f1 as b from t1 ta, t1 tb where ta.f1=tb +.f1 and ta.f2=tb.f2; +insert into t1 values(1,1),(2,2); +create view v2 as select * from v1 where a > 1 with local check option; +select * from v2; +a b +2 2 +update v2 set b=3 where a=2; +select * from v2; +a b +3 3 +drop view v2, v1; +drop table t1; +CREATE TABLE t1 (a int); +INSERT INTO t1 VALUES (1), (2); +CREATE VIEW v1 AS SELECT SQRT(a) my_sqrt FROM t1; +SELECT my_sqrt FROM v1 ORDER BY my_sqrt; +my_sqrt +1 +1.4142135623730951 +DROP VIEW v1; +DROP TABLE t1; +CREATE TABLE t1 (id int PRIMARY KEY); +CREATE TABLE t2 (id int PRIMARY KEY); +INSERT INTO t1 VALUES (1), (3); +INSERT INTO t2 VALUES (1), (2), (3); +CREATE VIEW v2 AS SELECT * FROM t2; +SELECT COUNT(*) FROM t1 LEFT JOIN t2 ON t1.id=t2.id; +COUNT(*) +2 +SELECT * FROM t1 LEFT JOIN t2 ON t1.id=t2.id; +id id +1 1 +3 3 +SELECT COUNT(*) FROM t1 LEFT JOIN v2 ON t1.id=v2.id; +COUNT(*) +2 +DROP VIEW v2; +DROP TABLE t1, t2; +CREATE TABLE t1 (id int NOT NULL PRIMARY KEY, +td date DEFAULT NULL, KEY idx(td)); +INSERT INTO t1 VALUES +(1, '2005-01-01'), (2, '2005-01-02'), (3, '2005-01-02'), +(4, '2005-01-03'), (5, '2005-01-04'), (6, '2005-01-05'), +(7, '2005-01-05'), (8, '2005-01-05'), (9, '2005-01-06'); +CREATE VIEW v1 AS SELECT * FROM t1; +SELECT * FROM t1 WHERE td BETWEEN CAST('2005.01.02' AS DATE) AND CAST('2005.01.04' AS DATE); +id td +2 2005-01-02 +3 2005-01-02 +4 2005-01-03 +5 2005-01-04 +SELECT * FROM v1 WHERE td BETWEEN CAST('2005.01.02' AS DATE) AND CAST('2005.01.04' AS DATE); +id td +2 2005-01-02 +3 2005-01-02 +4 2005-01-03 +5 2005-01-04 +DROP VIEW v1; +DROP TABLE t1; +create table t1 (a int); +create view v1 as select * from t1; +create view v2 as select * from v1; +drop table t1; +rename table v2 to t1; +select * from v1; +ERROR HY000: `test`.`v1` contains view recursion +drop view t1, v1; +create table t1 (a int); +create function f1() returns int +begin +declare mx int; +select max(a) from t1 into mx; +return mx; +end// +create view v1 as select f1() as a; +create view v2 as select * from v1; +drop table t1; +rename table v2 to t1; +select * from v1; +ERROR HY000: Recursive stored functions and triggers are not allowed. +drop function f1; +drop view t1, v1; +create table t1 (dt datetime); +insert into t1 values (20040101000000), (20050101000000), (20060101000000); +create view v1 as select convert_tz(dt, 'UTC', 'Europe/Moscow') as ldt from t1; +select * from v1; +ldt +2004-01-01 03:00:00 +2005-01-01 03:00:00 +2006-01-01 03:00:00 +drop view v1; +create view v1 as select * from t1 where convert_tz(dt, 'UTC', 'Europe/Moscow') >= 20050101000000; +select * from v1; +dt +2005-01-01 00:00:00 +2006-01-01 00:00:00 +create view v2 as select * from v1 where dt < 20060101000000; +select * from v2; +dt +2005-01-01 00:00:00 +drop view v2; +create view v2 as select convert_tz(dt, 'UTC', 'Europe/Moscow') as ldt from v1; +select * from v2; +ldt +2005-01-01 03:00:00 +2006-01-01 03:00:00 +drop view v1, v2; +drop table t1; +CREATE TABLE t1 (id int NOT NULL PRIMARY KEY, d datetime); +CREATE VIEW v1 AS +SELECT id, date(d) + INTERVAL TIME_TO_SEC(d) SECOND AS t, COUNT(*) +FROM t1 GROUP BY id, t; +SHOW CREATE VIEW v1; +View Create View character_set_client collation_connection +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`id` AS `id`,(cast(`t1`.`d` as date) + interval time_to_sec(`t1`.`d`) second) AS `t`,count(0) AS `COUNT(*)` from `t1` group by `t1`.`id`,`t` utf8mb4 utf8mb4_0900_ai_ci +SELECT * FROM v1; +id t COUNT(*) +DROP VIEW v1; +DROP TABLE t1; +CREATE TABLE t1 (i INT, j BIGINT); +INSERT INTO t1 VALUES (1, 2), (2, 2), (3, 2); +CREATE VIEW v1 AS SELECT MIN(j) AS j FROM t1; +CREATE VIEW v2 AS SELECT MIN(i) FROM t1 WHERE j = ( SELECT * FROM v1 ); +SELECT * FROM v2; +MIN(i) +1 +DROP VIEW v2, v1; +DROP TABLE t1; +CREATE TABLE t1( +fName varchar(25) NOT NULL, +lName varchar(25) NOT NULL, +DOB date NOT NULL, +test_date date NOT NULL, +uID int unsigned NOT NULL AUTO_INCREMENT PRIMARY KEY); +INSERT INTO t1(fName, lName, DOB, test_date) VALUES +('Hank', 'Hill', '1964-09-29', '2007-01-01'), +('Tom', 'Adams', '1908-02-14', '2007-01-01'), +('Homer', 'Simpson', '1968-03-05', '2007-01-01'); +CREATE VIEW v1 AS +SELECT (year(test_date)-year(DOB)) AS Age +FROM t1 HAVING Age < 75; +SHOW CREATE VIEW v1; +View Create View character_set_client collation_connection +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select (year(`t1`.`test_date`) - year(`t1`.`DOB`)) AS `Age` from `t1` having (`Age` < 75) utf8mb4 utf8mb4_0900_ai_ci +SELECT (year(test_date)-year(DOB)) AS Age FROM t1 HAVING Age < 75; +Age +43 +39 +SELECT * FROM v1; +Age +43 +39 +DROP VIEW v1; +DROP TABLE t1; +CREATE TABLE t1 (id int NOT NULL PRIMARY KEY, a char(6) DEFAULT 'xxx'); +INSERT INTO t1(id) VALUES (1), (2), (3), (4); +INSERT INTO t1 VALUES (5,'yyy'), (6,'yyy'); +SELECT * FROM t1; +id a +1 xxx +2 xxx +3 xxx +4 xxx +5 yyy +6 yyy +CREATE VIEW v1(a, m) AS SELECT a, MIN(id) FROM t1 GROUP BY a; +SELECT * FROM v1; +a m +xxx 1 +yyy 5 +CREATE TABLE t2 SELECT * FROM v1; +INSERT INTO t2(m) VALUES (0); +SELECT * FROM t2; +a m +xxx 1 +yyy 5 +xxx 0 +DROP VIEW v1; +DROP TABLE t1,t2; +CREATE TABLE t1 (id int PRIMARY KEY, e ENUM('a','b') NOT NULL DEFAULT 'b'); +INSERT INTO t1(id) VALUES (1), (2), (3); +INSERT INTO t1 VALUES (4,'a'); +SELECT * FROM t1; +id e +1 b +2 b +3 b +4 a +CREATE VIEW v1(m, e) AS SELECT MIN(id), e FROM t1 GROUP BY e; +CREATE TABLE t2 SELECT * FROM v1; +SELECT * FROM t2; +m e +1 b +4 a +DROP VIEW v1; +DROP TABLE t1,t2; +CREATE TABLE t1 (a INT NOT NULL, b INT NULL DEFAULT NULL); +CREATE VIEW v1 AS SELECT a, b FROM t1; +INSERT IGNORE INTO v1 (b) VALUES (2); +Warnings: +Warning 1423 Field of view 'test.v1' underlying table doesn't have a default value +SET SQL_MODE = STRICT_ALL_TABLES; +Warnings: +Warning 3135 'NO_ZERO_DATE', 'NO_ZERO_IN_DATE' and 'ERROR_FOR_DIVISION_BY_ZERO' sql modes should be used with strict mode. They will be merged with strict mode in a future release. +INSERT INTO v1 (b) VALUES (4); +ERROR HY000: Field of view 'test.v1' underlying table doesn't have a default value +SET SQL_MODE = ''; +SELECT * FROM t1; +a b +0 2 +DROP VIEW v1; +DROP TABLE t1; +CREATE TABLE t1 (firstname text, surname text); +INSERT INTO t1 VALUES +("Bart","Simpson"),("Milhouse","van Houten"),("Montgomery","Burns"); +CREATE VIEW v1 AS SELECT CONCAT(firstname," ",surname) AS name FROM t1; +SELECT CONCAT(LEFT(name,LENGTH(name)-INSTR(REVERSE(name)," ")), +LEFT(name,LENGTH(name)-INSTR(REVERSE(name)," "))) AS f1 +FROM v1; +f1 +BartBart +Milhouse vanMilhouse van +MontgomeryMontgomery +DROP VIEW v1; +DROP TABLE t1; +CREATE TABLE t1 (i int, j int); +CREATE VIEW v1 AS SELECT COALESCE(i,j) FROM t1; +DESCRIBE v1; +Field Type Null Key Default Extra +COALESCE(i,j) bigint YES NULL +CREATE TABLE t2 SELECT COALESCE(i,j) FROM t1; +DESCRIBE t2; +Field Type Null Key Default Extra +COALESCE(i,j) int YES NULL +DROP VIEW v1; +DROP TABLE t1,t2; +CREATE TABLE t1 (s varchar(10)); +INSERT INTO t1 VALUES ('yadda'), ('yady'); +SELECT TRIM(BOTH 'y' FROM s) FROM t1; +TRIM(BOTH 'y' FROM s) +adda +ad +CREATE VIEW v1 AS SELECT TRIM(BOTH 'y' FROM s) FROM t1; +SELECT * FROM v1; +TRIM(BOTH 'y' FROM s) +adda +ad +DROP VIEW v1; +SELECT TRIM(LEADING 'y' FROM s) FROM t1; +TRIM(LEADING 'y' FROM s) +adda +ady +CREATE VIEW v1 AS SELECT TRIM(LEADING 'y' FROM s) FROM t1; +SELECT * FROM v1; +TRIM(LEADING 'y' FROM s) +adda +ady +DROP VIEW v1; +SELECT TRIM(TRAILING 'y' FROM s) FROM t1; +TRIM(TRAILING 'y' FROM s) +yadda +yad +CREATE VIEW v1 AS SELECT TRIM(TRAILING 'y' FROM s) FROM t1; +SELECT * FROM v1; +TRIM(TRAILING 'y' FROM s) +yadda +yad +DROP VIEW v1; +DROP TABLE t1; +CREATE TABLE t1 (x INT, y INT); +CREATE ALGORITHM=TEMPTABLE SQL SECURITY INVOKER VIEW v1 AS SELECT x FROM t1; +SHOW CREATE VIEW v1; +View Create View character_set_client collation_connection +v1 CREATE ALGORITHM=TEMPTABLE DEFINER=`root`@`localhost` SQL SECURITY INVOKER VIEW `v1` AS select `t1`.`x` AS `x` from `t1` utf8mb4 utf8mb4_0900_ai_ci +ALTER VIEW v1 AS SELECT x, y FROM t1; +SHOW CREATE VIEW v1; +View Create View character_set_client collation_connection +v1 CREATE ALGORITHM=TEMPTABLE DEFINER=`root`@`localhost` SQL SECURITY INVOKER VIEW `v1` AS select `t1`.`x` AS `x`,`t1`.`y` AS `y` from `t1` utf8mb4 utf8mb4_0900_ai_ci +DROP VIEW v1; +DROP TABLE t1; +CREATE TABLE t1 (s1 char) charset latin1; +INSERT INTO t1 VALUES ('Z'); +CREATE VIEW v1 AS SELECT s1 collate latin1_german1_ci AS col FROM t1; +CREATE VIEW v2 (col) AS SELECT s1 collate latin1_german1_ci FROM t1; +INSERT INTO v1 (col) VALUES ('b'); +INSERT INTO v2 (col) VALUES ('c'); +SELECT s1 FROM t1; +s1 +Z +b +c +DROP VIEW v1, v2; +DROP TABLE t1; +CREATE TABLE t1 (id INT); +CREATE VIEW v1 AS SELECT id FROM t1; +SHOW TABLES; +Tables_in_test +t1 +v1 +DROP VIEW v2,v1; +ERROR 42S02: Unknown table 'test.v2' +SHOW TABLES; +Tables_in_test +t1 +v1 +DROP VIEW t1,v1; +ERROR HY000: 'test.t1' is not VIEW +SHOW TABLES; +Tables_in_test +t1 +v1 +DROP TABLE t1; +DROP VIEW IF EXISTS v1; +CREATE DATABASE bug21261DB; +USE bug21261DB; +CREATE TABLE t1 (x INT); +CREATE SQL SECURITY INVOKER VIEW v1 AS SELECT x FROM t1; +CREATE USER 'user21261'@'localhost'; +GRANT INSERT, UPDATE ON v1 TO 'user21261'@'localhost'; +GRANT INSERT, UPDATE ON t1 TO 'user21261'@'localhost'; +CREATE TABLE t2 (y INT); +GRANT SELECT ON t2 TO 'user21261'@'localhost'; +INSERT INTO v1 (x) VALUES (5); +UPDATE v1 SET x=1; +GRANT SELECT ON v1 TO 'user21261'@'localhost'; +GRANT SELECT ON t1 TO 'user21261'@'localhost'; +UPDATE v1,t2 SET x=1 WHERE x=y; +SELECT * FROM t1; +x +1 +REVOKE ALL PRIVILEGES, GRANT OPTION FROM 'user21261'@'localhost'; +DROP USER 'user21261'@'localhost'; +DROP VIEW v1; +DROP TABLE t1; +DROP DATABASE bug21261DB; +USE test; +create table t1 (f1 datetime); +create view v1 as select * from t1 where f1 between now() and now() + interval 1 minute; +show create view v1; +View Create View character_set_client collation_connection +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`f1` AS `f1` from `t1` where (`t1`.`f1` between now() and (now() + interval 1 minute)) utf8mb4 utf8mb4_0900_ai_ci +drop view v1; +drop table t1; +DROP TABLE IF EXISTS t1; +DROP VIEW IF EXISTS v1; +DROP VIEW IF EXISTS v2; +CREATE TABLE t1(a INT, b INT); +CREATE DEFINER=1234567890abcdefGHIKL1234567890abcdefGHIKL@localhost +VIEW v1 AS SELECT a FROM t1; +ERROR HY000: String '1234567890abcdefGHIKL1234567890abcdefGHIKL' is too long for user name (should be no longer than 32) +CREATE DEFINER=some_user_name@host_1234567890abcdefghij1234567890abcdefghij1234567890abcdefghij1234567890abcdefghij1234567890abcdefghij1234567890abcdefghij1234567890abcdefghij1234567890abcdefghij1234567890abcdefghij1234567890abcdefghij1234567890abcdefghij1234567890abcdefghij1234567890X +VIEW v2 AS SELECT b FROM t1; +ERROR HY000: String 'host_1234567890abcdefghij1234567890abcdefghij1234567890abcdefghij12345' is too long for host name (should be no longer than 255) +DROP TABLE t1; +DROP FUNCTION IF EXISTS f1; +DROP FUNCTION IF EXISTS f2; +DROP VIEW IF EXISTS v1, v2; +DROP TABLE IF EXISTS t1; +CREATE TABLE t1 (i INT); +CREATE VIEW v1 AS SELECT * FROM t1; +CREATE FUNCTION f1() RETURNS INT +BEGIN +INSERT INTO v1 VALUES (0); +RETURN 0; +END | +SELECT f1(); +f1() +0 +CREATE ALGORITHM=TEMPTABLE VIEW v2 AS SELECT * FROM t1; +CREATE FUNCTION f2() RETURNS INT +BEGIN +INSERT INTO v2 VALUES (0); +RETURN 0; +END | +SELECT f2(); +ERROR HY000: The target table v2 of the INSERT is not insertable-into +DROP FUNCTION f1; +DROP FUNCTION f2; +DROP VIEW v1, v2; +DROP TABLE t1; +CREATE TABLE t1 (s1 int); +CREATE VIEW v1 AS SELECT * FROM t1; +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT * FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # # Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL # # NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`s1` AS `s1` from `test`.`t1` +EXPLAIN SELECT * FROM v1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL # # NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`s1` AS `s1` from `test`.`t1` +INSERT INTO t1 VALUES (1), (3), (2); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT * FROM t1 t WHERE t.s1+1 < (SELECT MAX(t1.s1) FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t NULL ALL NULL NULL NULL # # # Using where +2 SUBQUERY t1 NULL ALL NULL NULL NULL # # # NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`s1` AS `s1` from `test`.`t1` `t` where ((`test`.`t`.`s1` + 1) < (/* select#2 */ select max(`test`.`t1`.`s1`) from `test`.`t1`)) +EXPLAIN SELECT * FROM v1 t WHERE t.s1+1 < (SELECT MAX(t1.s1) FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL # # # Using where +2 SUBQUERY t1 NULL ALL NULL NULL NULL # # # NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`s1` AS `s1` from `test`.`t1` where ((`test`.`t1`.`s1` + 1) < (/* select#2 */ select max(`test`.`t1`.`s1`) from `test`.`t1`)) +DROP VIEW v1; +DROP TABLE t1; +create table t1 (s1 int); +create view v1 as select s1 as a, s1 as b from t1; +insert into v1 values (1,1); +ERROR HY000: The target table v1 of the INSERT is not insertable-into +update v1 set a = 5; +drop view v1; +drop table t1; +CREATE TABLE t1(pk int PRIMARY KEY); +CREATE TABLE t2(pk int PRIMARY KEY, fk int, ver int, org int); +CREATE ALGORITHM=MERGE VIEW v1 AS +SELECT t1.* +FROM t1 JOIN t2 +ON t2.fk = t1.pk AND +t2.ver = (SELECT MAX(t.ver) FROM t2 t WHERE t.org = t2.org); +SHOW WARNINGS; +Level Code Message +SHOW CREATE VIEW v1; +View Create View character_set_client collation_connection +v1 CREATE ALGORITHM=MERGE DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`pk` AS `pk` from (`t1` join `t2` on(((`t2`.`fk` = `t1`.`pk`) and (`t2`.`ver` = (select max(`t`.`ver`) from `t2` `t` where (`t`.`org` = `t2`.`org`)))))) utf8mb4 utf8mb4_0900_ai_ci +DROP VIEW v1; +DROP TABLE t1, t2; +DROP FUNCTION IF EXISTS f1; +DROP VIEW IF EXISTS v1; +DROP TABLE IF EXISTS t1; +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (1); +CREATE VIEW v1 AS SELECT MAX(i) FROM t1; +CREATE TRIGGER t1_bi BEFORE INSERT ON t1 FOR EACH ROW +SET NEW.i = (SELECT * FROM v1) + 1; +INSERT INTO t1 VALUES (1); +CREATE FUNCTION f1() RETURNS INT RETURN (SELECT * FROM v1); +UPDATE t1 SET i= f1(); +DROP FUNCTION f1; +DROP VIEW v1; +DROP TABLE t1; +CREATE TABLE t1(id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, val INT UNSIGNED NOT NULL); +CREATE VIEW v1 AS SELECT id, val FROM t1 WHERE val >= 1 AND val <= 5 WITH CHECK OPTION; +INSERT INTO v1 (val) VALUES (2); +INSERT INTO v1 (val) VALUES (4); +INSERT INTO v1 (val) VALUES (6); +ERROR HY000: CHECK OPTION failed 'test.v1' +UPDATE v1 SET val=6 WHERE id=2; +ERROR HY000: CHECK OPTION failed 'test.v1' +DROP VIEW v1; +DROP TABLE t1; +DROP VIEW IF EXISTS v1, v2; +DROP TABLE IF EXISTS t1; +CREATE TABLE t1 (i INT AUTO_INCREMENT PRIMARY KEY, j INT); +CREATE VIEW v1 AS SELECT j FROM t1; +CREATE VIEW v2 AS SELECT * FROM t1; +INSERT INTO t1 (j) VALUES (1); +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +1 +INSERT INTO v1 (j) VALUES (2); +# LAST_INSERT_ID() should not change. +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +1 +INSERT INTO v2 (j) VALUES (3); +# LAST_INSERT_ID() should be updated. +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +3 +INSERT INTO v1 (j) SELECT j FROM t1; +# LAST_INSERT_ID() should not change. +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +3 +SELECT * FROM t1; +i j +1 1 +2 2 +3 3 +4 1 +5 2 +6 3 +DROP VIEW v1, v2; +DROP TABLE t1; +CREATE VIEW v AS SELECT !0 * 5 AS x FROM DUAL; +Warnings: +Warning 1287 '!' is deprecated and will be removed in a future release. Please use NOT instead +SHOW CREATE VIEW v; +View Create View character_set_client collation_connection +v CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v` AS select ((0 = 0) * 5) AS `x` utf8mb4 utf8mb4_0900_ai_ci +SELECT !0 * 5 AS x FROM DUAL; +x +5 +Warnings: +Warning 1287 '!' is deprecated and will be removed in a future release. Please use NOT instead +SELECT * FROM v; +x +5 +DROP VIEW v; +DROP VIEW IF EXISTS v1; +CREATE VIEW v1 AS SELECT 'The\ZEnd'; +SELECT * FROM v1; +TheEnd +TheEnd +SHOW CREATE VIEW v1; +View Create View character_set_client collation_connection +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select 'The\ZEnd' AS `TheEnd` utf8mb4 utf8mb4_0900_ai_ci +DROP VIEW v1; +CREATE TABLE t1 (mydate DATETIME); +INSERT INTO t1 VALUES +('2007-01-01'), ('2007-01-02'), ('2007-01-30'), ('2007-01-31'); +CREATE VIEW v1 AS SELECT mydate from t1; +SELECT * FROM t1 WHERE mydate BETWEEN '2007-01-01' AND '2007-01-31'; +mydate +2007-01-01 00:00:00 +2007-01-02 00:00:00 +2007-01-30 00:00:00 +2007-01-31 00:00:00 +SELECT * FROM v1 WHERE mydate BETWEEN '2007-01-01' AND '2007-01-31'; +mydate +2007-01-01 00:00:00 +2007-01-02 00:00:00 +2007-01-30 00:00:00 +2007-01-31 00:00:00 +DROP VIEW v1; +DROP TABLE t1; +CREATE TABLE t1 (a int); +CREATE TABLE t2 (b int); +INSERT INTO t1 VALUES (1), (2); +INSERT INTO t2 VALUES (1), (2); +CREATE VIEW v1 AS +SELECT t2.b FROM t1,t2 WHERE t1.a = t2.b WITH CHECK OPTION; +SELECT * FROM v1; +b +1 +2 +UPDATE v1 SET b=3; +ERROR HY000: CHECK OPTION failed 'test.v1' +SELECT * FROM v1; +b +1 +2 +SELECT * FROM t1; +a +1 +2 +SELECT * FROM t2; +b +1 +2 +DROP VIEW v1; +DROP TABLE t1,t2; +create table t1(f1 int, f2 int); +insert into t1 values(1,2),(1,3),(1,1),(2,3),(2,1),(2,2); +analyze table t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +select * from t1; +f1 f2 +1 2 +1 3 +1 1 +2 3 +2 1 +2 2 +create view v1 as select * from t1 order by f2; +select * from v1; +f1 f2 +1 1 +2 1 +1 2 +2 2 +1 3 +2 3 +explain select * from v1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL # 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`f1` AS `f1`,`test`.`t1`.`f2` AS `f2` from `test`.`t1` order by `test`.`t1`.`f2` +select * from v1 order by f1; +f1 f2 +1 2 +1 3 +1 1 +2 3 +2 1 +2 2 +explain select * from v1 order by f1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL # 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`f1` AS `f1`,`test`.`t1`.`f2` AS `f2` from `test`.`t1` order by `test`.`t1`.`f1` +drop view v1; +drop table t1; +CREATE TABLE t1 ( +id int(11) NOT NULL PRIMARY KEY, +country varchar(32), +code int(11) default NULL +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES +(1,'ITALY',100),(2,'ITALY',200),(3,'FRANCE',100), (4,'ITALY',100); +CREATE VIEW v1 AS SELECT * FROM t1; +SELECT code, COUNT(DISTINCT country) FROM t1 GROUP BY code ORDER BY MAX(id); +code COUNT(DISTINCT country) +200 1 +100 2 +SELECT code, COUNT(DISTINCT country) FROM v1 GROUP BY code ORDER BY MAX(id); +code COUNT(DISTINCT country) +200 1 +100 2 +DROP VIEW v1; +DROP TABLE t1; +DROP VIEW IF EXISTS v1; +SELECT * FROM (SELECT 1) AS t; +1 +1 +CREATE VIEW v1 AS SELECT * FROM (SELECT 1) AS t; +DROP VIEW v1; +# Previously the following would fail. +SELECT * FROM (SELECT 1) AS t; +1 +1 +drop view if exists view_24532_a; +drop view if exists view_24532_b; +drop table if exists table_24532; +create table table_24532 ( +a int, +b bigint, +c int(4), +d bigint(48) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +create view view_24532_a as +select +a IS TRUE, +a IS NOT TRUE, +a IS FALSE, +a IS NOT FALSE, +a IS UNKNOWN, +a IS NOT UNKNOWN, +a is NULL, +a IS NOT NULL, +ISNULL(a), +b IS TRUE, +b IS NOT TRUE, +b IS FALSE, +b IS NOT FALSE, +b IS UNKNOWN, +b IS NOT UNKNOWN, +b is NULL, +b IS NOT NULL, +ISNULL(b), +c IS TRUE, +c IS NOT TRUE, +c IS FALSE, +c IS NOT FALSE, +c IS UNKNOWN, +c IS NOT UNKNOWN, +c is NULL, +c IS NOT NULL, +ISNULL(c), +d IS TRUE, +d IS NOT TRUE, +d IS FALSE, +d IS NOT FALSE, +d IS UNKNOWN, +d IS NOT UNKNOWN, +d is NULL, +d IS NOT NULL, +ISNULL(d) +from table_24532; +describe view_24532_a; +Field Type Null Key Default Extra +a IS TRUE int NO 0 +a IS NOT TRUE int NO 0 +a IS FALSE int NO 0 +a IS NOT FALSE int NO 0 +a IS UNKNOWN int NO 0 +a IS NOT UNKNOWN int NO 0 +a is NULL int NO 0 +a IS NOT NULL int NO 0 +ISNULL(a) int NO 0 +b IS TRUE int NO 0 +b IS NOT TRUE int NO 0 +b IS FALSE int NO 0 +b IS NOT FALSE int NO 0 +b IS UNKNOWN int NO 0 +b IS NOT UNKNOWN int NO 0 +b is NULL int NO 0 +b IS NOT NULL int NO 0 +ISNULL(b) int NO 0 +c IS TRUE int NO 0 +c IS NOT TRUE int NO 0 +c IS FALSE int NO 0 +c IS NOT FALSE int NO 0 +c IS UNKNOWN int NO 0 +c IS NOT UNKNOWN int NO 0 +c is NULL int NO 0 +c IS NOT NULL int NO 0 +ISNULL(c) int NO 0 +d IS TRUE int NO 0 +d IS NOT TRUE int NO 0 +d IS FALSE int NO 0 +d IS NOT FALSE int NO 0 +d IS UNKNOWN int NO 0 +d IS NOT UNKNOWN int NO 0 +d is NULL int NO 0 +d IS NOT NULL int NO 0 +ISNULL(d) int NO 0 +create view view_24532_b as +select +a IS TRUE, +if(ifnull(a, 0), 1, 0) as old_istrue, +a IS NOT TRUE, +if(ifnull(a, 0), 0, 1) as old_isnottrue, +a IS FALSE, +if(ifnull(a, 1), 0, 1) as old_isfalse, +a IS NOT FALSE, +if(ifnull(a, 1), 1, 0) as old_isnotfalse +from table_24532; +describe view_24532_b; +Field Type Null Key Default Extra +a IS TRUE int NO 0 +old_istrue int NO 0 +a IS NOT TRUE int NO 0 +old_isnottrue int NO 0 +a IS FALSE int NO 0 +old_isfalse int NO 0 +a IS NOT FALSE int NO 0 +old_isnotfalse int NO 0 +show create view view_24532_b; +View Create View character_set_client collation_connection +view_24532_b CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `view_24532_b` AS select ((0 <> `table_24532`.`a`) is true) AS `a IS TRUE`,if(ifnull(`table_24532`.`a`,0),1,0) AS `old_istrue`,((0 <> `table_24532`.`a`) is not true) AS `a IS NOT TRUE`,if(ifnull(`table_24532`.`a`,0),0,1) AS `old_isnottrue`,((0 <> `table_24532`.`a`) is false) AS `a IS FALSE`,if(ifnull(`table_24532`.`a`,1),0,1) AS `old_isfalse`,((0 <> `table_24532`.`a`) is not false) AS `a IS NOT FALSE`,if(ifnull(`table_24532`.`a`,1),1,0) AS `old_isnotfalse` from `table_24532` utf8mb4 utf8mb4_0900_ai_ci +insert into table_24532 values (0, 0, 0, 0); +select * from view_24532_b; +a IS TRUE old_istrue a IS NOT TRUE old_isnottrue a IS FALSE old_isfalse a IS NOT FALSE old_isnotfalse +0 0 1 1 1 1 0 0 +update table_24532 set a=1; +select * from view_24532_b; +a IS TRUE old_istrue a IS NOT TRUE old_isnottrue a IS FALSE old_isfalse a IS NOT FALSE old_isnotfalse +1 1 0 0 0 0 1 1 +update table_24532 set a=NULL; +select * from view_24532_b; +a IS TRUE old_istrue a IS NOT TRUE old_isnottrue a IS FALSE old_isfalse a IS NOT FALSE old_isnotfalse +0 0 1 1 0 0 1 1 +drop view view_24532_a; +drop view view_24532_b; +drop table table_24532; +CREATE TABLE t1 ( +lid int NOT NULL PRIMARY KEY, +name char(10) NOT NULL +); +INSERT INTO t1 (lid, name) VALUES +(1, 'YES'), (2, 'NO'); +CREATE TABLE t2 ( +id int NOT NULL PRIMARY KEY, +gid int NOT NULL, +lid int NOT NULL, +dt date +); +CREATE TABLE t3 ( +id int NOT NULL PRIMARY KEY, +gid int NOT NULL, +lid int NOT NULL, +dt date +); +INSERT INTO t2 (id, gid, lid, dt) VALUES +(1, 1, 1, '2007-01-01'),(2, 1, 2, '2007-01-02'), +(3, 2, 2, '2007-02-01'),(4, 2, 1, '2007-02-02'); +INSERT INTO t3 (id, gid, lid, dt) VALUES +(1, 1, 1, '2007-01-01'),(2, 1, 2, '2007-01-02'), +(3, 2, 2, '2007-02-01'),(4, 2, 1, '2007-02-02'); +SELECT DISTINCT t2.gid AS lgid, +(SELECT t1.name FROM t1, t3 +WHERE t1.lid = t3.lid AND t3.gid = t2.gid +ORDER BY t3.dt DESC LIMIT 1 +) as clid +FROM t2; +lgid clid +1 NO +2 YES +CREATE VIEW v1 AS +SELECT DISTINCT t2.gid AS lgid, +(SELECT t1.name FROM t1, t3 +WHERE t1.lid = t3.lid AND t3.gid = t2.gid +ORDER BY t3.dt DESC LIMIT 1 +) as clid +FROM t2; +SELECT * FROM v1; +lgid clid +1 NO +2 YES +DROP VIEW v1; +DROP table t1,t2,t3; +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1),(2),(3); +analyze table t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +CREATE VIEW v1 AS SELECT a FROM t1 ORDER BY a; +SELECT * FROM t1 UNION SELECT * FROM v1; +a +1 +2 +3 +EXPLAIN SELECT * FROM t1 UNION SELECT * FROM v1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL # # NULL +2 UNION t1 NULL ALL NULL NULL NULL NULL # # NULL +NULL UNION RESULT NULL ALL NULL NULL NULL NULL # # Using temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` union /* select#2 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` +SELECT * FROM v1 UNION SELECT * FROM t1; +a +1 +2 +3 +EXPLAIN SELECT * FROM v1 UNION SELECT * FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL # # NULL +2 UNION t1 NULL ALL NULL NULL NULL NULL # # NULL +NULL UNION RESULT NULL ALL NULL NULL NULL NULL # # Using temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` union /* select#2 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` +SELECT * FROM t1 UNION SELECT * FROM v1 ORDER BY a; +a +1 +2 +3 +EXPLAIN SELECT * FROM t1 UNION SELECT * FROM v1 ORDER BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL # # NULL +2 UNION t1 NULL ALL NULL NULL NULL NULL # # NULL +NULL UNION RESULT NULL ALL NULL NULL NULL NULL # # Using temporary; Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` union /* select#2 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` order by `a` +DROP VIEW v1; +DROP TABLE t1; +CREATE VIEW v1 AS SELECT CAST( 1.23456789 AS DECIMAL( 7,5 ) ) AS col; +SELECT * FROM v1; +col +1.23457 +DESCRIBE v1; +Field Type Null Key Default Extra +col decimal(7,5) NO 0.00000 +DROP VIEW v1; +CREATE VIEW v1 AS SELECT CAST(1.23456789 AS DECIMAL(8,0)) AS col; +SHOW CREATE VIEW v1; +View Create View character_set_client collation_connection +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select cast(1.23456789 as decimal(8,0)) AS `col` utf8mb4 utf8mb4_0900_ai_ci +DROP VIEW v1; +CREATE TABLE t1 (a INT); +CREATE TABLE t2 (b INT, c INT DEFAULT 0); +INSERT INTO t1 (a) VALUES (1), (2); +INSERT INTO t2 (b) VALUES (1), (2); +CREATE VIEW v1 AS SELECT t2.b,t2.c FROM t1, t2 +WHERE t1.a=t2.b AND t2.b < 3 WITH CHECK OPTION; +SELECT * FROM v1; +b c +1 0 +2 0 +UPDATE v1 SET c=1 WHERE b=1; +SELECT * FROM v1; +b c +1 1 +2 0 +DROP VIEW v1; +DROP TABLE t1,t2; +CREATE TABLE t1 (id int); +CREATE TABLE t2 (id int, c int DEFAULT 0); +INSERT INTO t1 (id) VALUES (1); +INSERT INTO t2 (id) VALUES (1); +CREATE VIEW v1 AS +SELECT t2.c FROM t1, t2 +WHERE t1.id=t2.id AND 1 IN (SELECT id FROM t1) WITH CHECK OPTION; +UPDATE v1 SET c=1; +DROP VIEW v1; +DROP TABLE t1,t2; +CREATE TABLE t1 (a1 INT, c INT DEFAULT 0); +CREATE TABLE t2 (a2 INT); +CREATE TABLE t3 (a3 INT); +CREATE TABLE t4 (a4 INT); +INSERT INTO t1 (a1) VALUES (1),(2); +INSERT INTO t2 (a2) VALUES (1),(2); +INSERT INTO t3 (a3) VALUES (1),(2); +INSERT INTO t4 (a4) VALUES (1),(2); +CREATE VIEW v1 AS +SELECT t1.a1, t1.c FROM t1 JOIN t2 ON t1.a1=t2.a2 AND t1.c < 3 +WITH CHECK OPTION; +SELECT * FROM v1; +a1 c +1 0 +2 0 +UPDATE v1 SET c=3; +ERROR HY000: CHECK OPTION failed 'test.v1' +PREPARE t FROM 'UPDATE v1 SET c=3'; +EXECUTE t; +ERROR HY000: CHECK OPTION failed 'test.v1' +EXECUTE t; +ERROR HY000: CHECK OPTION failed 'test.v1' +INSERT INTO v1(a1, c) VALUES (3, 3); +ERROR HY000: CHECK OPTION failed 'test.v1' +UPDATE v1 SET c=1 WHERE a1=1; +SELECT * FROM v1; +a1 c +1 1 +2 0 +SELECT * FROM t1; +a1 c +1 1 +2 0 +CREATE VIEW v2 AS SELECT t1.a1, t1.c +FROM (t1 JOIN t2 ON t1.a1=t2.a2 AND t1.c < 3) +JOIN (t3 JOIN t4 ON t3.a3=t4.a4) +ON t2.a2=t3.a3 WITH CHECK OPTION; +SELECT * FROM v2; +a1 c +1 1 +2 0 +UPDATE v2 SET c=3; +ERROR HY000: CHECK OPTION failed 'test.v2' +PREPARE t FROM 'UPDATE v2 SET c=3'; +EXECUTE t; +ERROR HY000: CHECK OPTION failed 'test.v2' +EXECUTE t; +ERROR HY000: CHECK OPTION failed 'test.v2' +INSERT INTO v2(a1, c) VALUES (3, 3); +ERROR HY000: CHECK OPTION failed 'test.v2' +UPDATE v2 SET c=2 WHERE a1=1; +SELECT * FROM v2; +a1 c +1 2 +2 0 +SELECT * FROM t1; +a1 c +1 2 +2 0 +DROP VIEW v1,v2; +DROP TABLE t1,t2,t3,t4; +CREATE TABLE t1 (a int, b int); +INSERT INTO t1 VALUES (1,2), (2,2), (1,3), (1,2); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +CREATE VIEW v1 AS SELECT a, b+1 as b FROM t1; +SELECT b, SUM(a) FROM v1 WHERE b=3 GROUP BY b; +b SUM(a) +3 4 +EXPLAIN SELECT b, SUM(a) FROM v1 WHERE b=3 GROUP BY b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select (`test`.`t1`.`b` + 1) AS `b`,sum(`test`.`t1`.`a`) AS `SUM(a)` from `test`.`t1` where ((`test`.`t1`.`b` + 1) = 3) group by (`test`.`t1`.`b` + 1) +SELECT a, SUM(b) FROM v1 WHERE b=3 GROUP BY a; +a SUM(b) +1 6 +2 3 +EXPLAIN SELECT a, SUM(b) FROM v1 WHERE b=3 GROUP BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 100.00 Using where; Using temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,sum((`test`.`t1`.`b` + 1)) AS `SUM(b)` from `test`.`t1` where ((`test`.`t1`.`b` + 1) = 3) group by `test`.`t1`.`a` +SELECT a, SUM(b) FROM v1 WHERE a=1 GROUP BY a; +a SUM(b) +1 10 +EXPLAIN SELECT a, SUM(b) FROM v1 WHERE a=1 GROUP BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,sum((`test`.`t1`.`b` + 1)) AS `SUM(b)` from `test`.`t1` where (`test`.`t1`.`a` = 1) group by `test`.`t1`.`a` +DROP VIEW v1; +DROP TABLE t1; +CREATE TABLE t1 ( +person_id int NOT NULL PRIMARY KEY, +username varchar(40) default NULL, +status_flg char(1) NOT NULL default 'A' +); +CREATE TABLE t2 ( +person_role_id int NOT NULL auto_increment PRIMARY KEY, +role_id int NOT NULL, +person_id int NOT NULL, +INDEX idx_person_id (person_id), +INDEX idx_role_id (role_id) +); +CREATE TABLE t3 ( +role_id int NOT NULL auto_increment PRIMARY KEY, +role_name varchar(100) default NULL, +app_name varchar(40) NOT NULL, +INDEX idx_app_name(app_name) +); +CREATE VIEW v1 AS +SELECT profile.person_id AS person_id +FROM t1 profile, t2 userrole, t3 `role` + WHERE userrole.person_id = profile.person_id AND +role.role_id = userrole.role_id AND +profile.status_flg = 'A' + ORDER BY profile.person_id,role.app_name,role.role_name; +INSERT INTO t1 VALUES +(6,'Sw','A'), (-1136332546,'ols','e'), (0,' *\n','0'), +(-717462680,'ENTS Ta','0'), (-904346964,'ndard SQL\n','0'); +INSERT INTO t2 VALUES +(1,3,6),(2,4,7),(3,5,8),(4,6,9),(5,1,6),(6,1,7),(7,1,8),(8,1,9),(9,1,10); +INSERT INTO t3 VALUES +(1,'NUCANS_APP_USER','NUCANSAPP'),(2,'NUCANS_TRGAPP_USER','NUCANSAPP'), +(3,'IA_INTAKE_COORDINATOR','IACANS'),(4,'IA_SCREENER','IACANS'), +(5,'IA_SUPERVISOR','IACANS'),(6,'IA_READONLY','IACANS'), +(7,'SOC_USER','SOCCANS'),(8,'CAYIT_USER','CAYITCANS'), +(9,'RTOS_DCFSPOS_SUPERVISOR','RTOS'); +ANALYZE TABLE t1,t2,t3; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +EXPLAIN SELECT t.person_id AS a, t.person_id AS b FROM v1 t WHERE t.person_id=6; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE profile NULL const PRIMARY PRIMARY 4 const # # Using temporary; Using filesort +1 SIMPLE userrole NULL ref idx_person_id,idx_role_id idx_person_id 4 const # # NULL +1 SIMPLE role NULL eq_ref PRIMARY PRIMARY 4 test.userrole.role_id # # NULL +Warnings: +Note 1003 /* select#1 */ select '6' AS `a`,'6' AS `b` from `test`.`t1` `profile` join `test`.`t2` `userrole` join `test`.`t3` `role` where ((`test`.`role`.`role_id` = `test`.`userrole`.`role_id`) and (`test`.`userrole`.`person_id` = 6)) order by '6',`test`.`role`.`app_name`,`test`.`role`.`role_name` +SELECT t.person_id AS a, t.person_id AS b FROM v1 t WHERE t.person_id=6; +a b +6 6 +6 6 +DROP VIEW v1; +DROP TABLE t1,t2,t3; +create table t1 (i int); +insert into t1 values (1), (2), (1), (3), (2), (4); +create view v1 as select distinct i from t1; +select * from v1; +i +1 +2 +3 +4 +select table_name, is_updatable from information_schema.views +where table_name = 'v1'; +TABLE_NAME IS_UPDATABLE +v1 NO +drop view v1; +drop table t1; +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1),(2); +CREATE VIEW v1 AS SELECT * FROM t1; +SELECT * FROM v1 USE KEY(non_existant); +ERROR 42000: Key 'non_existant' doesn't exist in table 'v1' +SELECT * FROM v1 FORCE KEY(non_existant); +ERROR 42000: Key 'non_existant' doesn't exist in table 'v1' +SELECT * FROM v1 IGNORE KEY(non_existant); +ERROR 42000: Key 'non_existant' doesn't exist in table 'v1' +DROP VIEW v1; +DROP TABLE t1; +CREATE TABLE t1 (a INT NOT NULL AUTO_INCREMENT, b INT NOT NULL DEFAULT 0, +PRIMARY KEY(a), KEY (b)); +INSERT INTO t1 VALUES (),(),(),(),(),(),(),(),(),(),(),(),(),(),(); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +CREATE VIEW v1 AS SELECT * FROM t1 FORCE KEY (PRIMARY,b) ORDER BY a; +SHOW CREATE VIEW v1; +View Create View character_set_client collation_connection +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`a` AS `a`,`t1`.`b` AS `b` from `t1` FORCE INDEX (PRIMARY) FORCE INDEX (`b`) order by `t1`.`a` utf8mb4 utf8mb4_0900_ai_ci +EXPLAIN SELECT * FROM v1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index NULL PRIMARY 4 NULL # # NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` FORCE INDEX (PRIMARY) FORCE INDEX (`b`) order by `test`.`t1`.`a` +CREATE VIEW v2 AS SELECT * FROM t1 USE KEY () ORDER BY a; +SHOW CREATE VIEW v2; +View Create View character_set_client collation_connection +v2 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v2` AS select `t1`.`a` AS `a`,`t1`.`b` AS `b` from `t1` USE INDEX () order by `t1`.`a` utf8mb4 utf8mb4_0900_ai_ci +EXPLAIN SELECT * FROM v2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL # # Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` USE INDEX () order by `test`.`t1`.`a` +CREATE VIEW v3 AS SELECT * FROM t1 IGNORE KEY (b) ORDER BY a; +SHOW CREATE VIEW v3; +View Create View character_set_client collation_connection +v3 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v3` AS select `t1`.`a` AS `a`,`t1`.`b` AS `b` from `t1` IGNORE INDEX (`b`) order by `t1`.`a` utf8mb4 utf8mb4_0900_ai_ci +EXPLAIN SELECT * FROM v3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index NULL PRIMARY 4 NULL # # NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` IGNORE INDEX (`b`) order by `test`.`t1`.`a` +DROP VIEW v1; +DROP VIEW v2; +DROP VIEW v3; +DROP TABLE t1; +# +# Bug#29477 Not all fields of the target table were checked to have +# a default value when inserting into a view. +# +create table t1(f1 int, f2 int not null); +create view v1 as select f1 from t1; +insert into v1 values(1); +Warnings: +Warning 1423 Field of view 'test.v1' underlying table doesn't have a default value +set @old_mode=@@sql_mode; +set @@sql_mode=traditional; +insert into v1 values(1); +ERROR HY000: Field of view 'test.v1' underlying table doesn't have a default value +set @@sql_mode=@old_mode; +drop view v1; +drop table t1; +create table t1 (a int, key(a)); +create table t2 (c int); +create view v1 as select a b from t1; +create view v2 as select 1 a from t2, v1 where c in +(select 1 from t1 where b = a); +insert into t1 values (1), (1); +insert into t2 values (1), (1); +prepare stmt from "select * from v2 where a = 1"; +execute stmt; +a +1 +1 +1 +1 +drop view v1, v2; +drop table t1, t2; +CREATE TABLE t1 (a INT); +CREATE VIEW v1 AS SELECT p.a AS a FROM t1 p, t1 q; +INSERT INTO t1 VALUES (1), (1); +SELECT MAX(a), COUNT(DISTINCT a) FROM v1 GROUP BY a; +MAX(a) COUNT(DISTINCT a) +1 1 +DROP VIEW v1; +DROP TABLE t1; +# ----------------------------------------------------------------- +# -- Bug#34337 Server crash when Altering a view using a table name. +# ----------------------------------------------------------------- + +DROP TABLE IF EXISTS t1; + +CREATE TABLE t1(c1 INT); + +SELECT * FROM t1; +c1 +ALTER ALGORITHM=TEMPTABLE SQL SECURITY INVOKER VIEW t1 (c2) AS SELECT (1); +ERROR HY000: 'test.t1' is not VIEW + +DROP TABLE t1; + +# -- End of test case for Bug#34337. + +# ----------------------------------------------------------------- +# -- Bug#35193 VIEW query is rewritten without "FROM DUAL", +# -- causing syntax error +# ----------------------------------------------------------------- + +CREATE VIEW v1 AS SELECT 1 FROM DUAL WHERE 1; + +SELECT * FROM v1; +1 +1 +SHOW CREATE TABLE v1; +View Create View character_set_client collation_connection +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select 1 AS `1` from DUAL where (0 <> 1) utf8mb4 utf8mb4_0900_ai_ci + +DROP VIEW v1; + +# -- End of test case for Bug#35193. + +CREATE VIEW v1 AS SELECT 1; +DROP VIEW v1; +CREATE TABLE t1 (c1 INT PRIMARY KEY, c2 INT, INDEX (c2)); +INSERT INTO t1 VALUES (1,1), (2,2), (3,3); +SELECT * FROM t1 USE INDEX (PRIMARY) WHERE c1=2; +c1 c2 +2 2 +SELECT * FROM t1 USE INDEX (c2) WHERE c2=2; +c1 c2 +2 2 +CREATE VIEW v1 AS SELECT c1, c2 FROM t1; +SHOW INDEX FROM v1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible Expression +SELECT * FROM v1 USE INDEX (PRIMARY) WHERE c1=2; +ERROR 42000: Key 'PRIMARY' doesn't exist in table 'v1' +SELECT * FROM v1 FORCE INDEX (PRIMARY) WHERE c1=2; +ERROR 42000: Key 'PRIMARY' doesn't exist in table 'v1' +SELECT * FROM v1 IGNORE INDEX (PRIMARY) WHERE c1=2; +ERROR 42000: Key 'PRIMARY' doesn't exist in table 'v1' +SELECT * FROM v1 USE INDEX (c2) WHERE c2=2; +ERROR 42000: Key 'c2' doesn't exist in table 'v1' +SELECT * FROM v1 FORCE INDEX (c2) WHERE c2=2; +ERROR 42000: Key 'c2' doesn't exist in table 'v1' +SELECT * FROM v1 IGNORE INDEX (c2) WHERE c2=2; +ERROR 42000: Key 'c2' doesn't exist in table 'v1' +DROP VIEW v1; +DROP TABLE t1; +# +# Bug #45806 crash when replacing into a view with a join! +# +CREATE TABLE t1(a INT UNIQUE); +CREATE VIEW v1 AS SELECT t1.a FROM t1, t1 AS a; +INSERT INTO t1 VALUES (1), (2); +REPLACE INTO v1(a) SELECT 1 FROM t1,t1 AS c; +ERROR HY000: Can not delete from join view 'test.v1' +SELECT * FROM v1; +a +1 +1 +2 +2 +REPLACE INTO v1(a) SELECT 3 FROM t1,t1 AS c; +ERROR HY000: Can not delete from join view 'test.v1' +SELECT * FROM v1; +a +1 +1 +2 +2 +DELETE FROM t1 WHERE a=3; +INSERT INTO v1(a) SELECT 1 FROM t1,t1 AS c +ON DUPLICATE KEY UPDATE `v1`.`a`= 1; +SELECT * FROM v1; +a +1 +1 +2 +2 +CREATE VIEW v2 AS SELECT t1.a FROM t1, v1 AS a; +REPLACE INTO v2(a) SELECT 1 FROM t1,t1 AS c; +ERROR HY000: Can not delete from join view 'test.v2' +SELECT * FROM v2; +a +1 +1 +1 +1 +2 +2 +2 +2 +REPLACE INTO v2(a) SELECT 3 FROM t1,t1 AS c; +ERROR HY000: Can not delete from join view 'test.v2' +SELECT * FROM v2; +a +1 +1 +1 +1 +2 +2 +2 +2 +INSERT INTO v2(a) SELECT 1 FROM t1,t1 AS c +ON DUPLICATE KEY UPDATE `v2`.`a`= 1; +SELECT * FROM v2; +a +1 +1 +1 +1 +2 +2 +2 +2 +DROP VIEW v1; +DROP VIEW v2; +DROP TABLE t1; +# -- End of test case for Bug#45806 +# ----------------------------------------------------------------- +# -- Bug#40825: Error 1356 while selecting from a view +# -- with a "HAVING" clause though query works +# ----------------------------------------------------------------- + +CREATE TABLE t1 (c INT); + +CREATE VIEW v1 (view_column) AS SELECT c AS alias FROM t1 HAVING alias; +SHOW CREATE VIEW v1; +View Create View character_set_client collation_connection +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` (`view_column`) AS select `t1`.`c` AS `alias` from `t1` having (0 <> `alias`) utf8mb4 utf8mb4_0900_ai_ci +SELECT * FROM v1; +view_column + +DROP VIEW v1; +DROP TABLE t1; + +# -- End of test case for Bug#40825 + +# ----------------------------------------------------------------- +# -- End of 5.0 tests. +# ----------------------------------------------------------------- +DROP DATABASE IF EXISTS `d-1`; +CREATE DATABASE `d-1`; +USE `d-1`; +CREATE TABLE `t-1` (c1 INT); +CREATE VIEW `v-1` AS SELECT c1 FROM `t-1`; +SHOW TABLES; +Tables_in_d-1 +t-1 +v-1 +RENAME TABLE `t-1` TO `t-2`; +RENAME TABLE `v-1` TO `v-2`; +SHOW TABLES; +Tables_in_d-1 +t-2 +v-2 +DROP TABLE `t-2`; +DROP VIEW `v-2`; +DROP DATABASE `d-1`; +USE test; + +# +# Bug#26676 VIEW using old table schema in a session. +# + +DROP VIEW IF EXISTS v1; +DROP TABLE IF EXISTS t1; +CREATE TABLE t1(c1 INT, c2 INT); +INSERT INTO t1 VALUES (1, 2), (3, 4); + +SELECT * FROM t1; +c1 c2 +1 2 +3 4 + +CREATE VIEW v1 AS SELECT * FROM t1; + +SELECT * FROM v1; +c1 c2 +1 2 +3 4 + +ALTER TABLE t1 ADD COLUMN c3 INT AFTER c2; + +SELECT * FROM t1; +c1 c2 c3 +1 2 NULL +3 4 NULL + +SELECT * FROM v1; +c1 c2 +1 2 +3 4 + +SHOW CREATE VIEW v1; +View Create View character_set_client collation_connection +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`c1` AS `c1`,`t1`.`c2` AS `c2` from `t1` utf8mb4 utf8mb4_0900_ai_ci + +DROP VIEW v1; +DROP TABLE t1; + +# End of test case for Bug#26676. + +# ----------------------------------------------------------------- +# -- Bug#32538 View definition picks up character set, but not collation +# ----------------------------------------------------------------- + +DROP VIEW IF EXISTS v1; + +SET collation_connection = latin1_general_ci; +CREATE VIEW v1 AS SELECT _latin1 'text1' AS c1, 'text2' AS c2; + +SELECT COLLATION(c1), COLLATION(c2) FROM v1; +COLLATION(c1) COLLATION(c2) +latin1_swedish_ci latin1_general_ci + +SHOW CREATE VIEW v1; +View Create View character_set_client collation_connection +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select _latin1'text1' AS `c1`,'text2' AS `c2` utf8mb4 latin1_general_ci + +SELECT * FROM v1 WHERE c1 = 'text1'; +ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE) and (latin1_general_ci,COERCIBLE) for operation '=' + +SELECT * FROM v1 WHERE c2 = 'text2'; +c1 c2 +text1 text2 + +use test; +SET names latin1; + +SELECT COLLATION(c1), COLLATION(c2) FROM v1; +COLLATION(c1) COLLATION(c2) +latin1_swedish_ci latin1_general_ci + +SELECT * FROM v1 WHERE c1 = 'text1'; +c1 c2 +text1 text2 + +SELECT * FROM v1 WHERE c2 = 'text2'; +ERROR HY000: Illegal mix of collations (latin1_general_ci,COERCIBLE) and (latin1_swedish_ci,COERCIBLE) for operation '=' + +DROP VIEW v1; +SET NAMES DEFAULT; + +# -- End of test case for Bug#32538. + +drop view if exists a; +drop procedure if exists p; +create procedure p() +begin +declare continue handler for sqlexception begin end; +create view a as select 1; +end| +call p(); +call p(); +drop view a; +drop procedure p; +# +# Bug #44860: ALTER TABLE on view crashes server +# +CREATE TABLE t1 (a INT); +CREATE VIEW v1 AS SELECT a FROM t1; +ALTER TABLE v1; +ERROR HY000: 'test.v1' is not BASE TABLE +DROP VIEW v1; +DROP TABLE t1; +CREATE TABLE t1(f1 INT); +INSERT INTO t1 VALUES (); +CREATE VIEW v1 AS SELECT 1 FROM t1 WHERE +ROW(1,1) >= ROW(1, (SELECT 1 FROM t1 WHERE f1 >= ANY ( SELECT '1' ))); +DROP VIEW v1; +DROP TABLE t1; +# +# Bug#52120 create view cause Assertion failed: 0, file .\item_subselect.cc, line 817 +# +CREATE TABLE t1 (a CHAR(1) CHARSET latin1, b CHAR(1) CHARSET utf8); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +CREATE VIEW v1 AS SELECT 1 from t1 +WHERE t1.b <=> (SELECT a FROM t1 WHERE a < SOME(SELECT '1')); +DROP VIEW v1; +DROP TABLE t1; +# +# Bug#57703 create view cause Assertion failed: 0, file .\item_subselect.cc, line 846 +# +CREATE TABLE t1(a int); +CREATE VIEW v1 AS SELECT 1 FROM t1 GROUP BY +SUBSTRING(1 FROM (SELECT 3 FROM t1 WHERE a >= ANY(SELECT 1))); +DROP VIEW v1; +DROP TABLE t1; +# +# Bug#57352 valgrind warnings when creating view +# +CREATE VIEW v1 AS SELECT 1 IN (1 LIKE 2,0) AS f; +DROP VIEW v1; +# +# Bug 11829681 - 60295: ERROR 1356 ON VIEW THAT EXECUTES FINE AS A QUERY +# +CREATE TABLE t1 (a INT); +CREATE VIEW v1 AS SELECT s.* FROM t1 s, t1 b HAVING a; +SELECT * FROM v1; +a +DROP VIEW v1; +DROP TABLE t1; +# ----------------------------------------------------------------- +# -- End of 5.1 tests. +# ----------------------------------------------------------------- +drop table if exists t_9801; +drop view if exists v_9801; +create table t_9801 (s1 int); +create view v_9801 as +select sum(s1) from t_9801 with check option; +ERROR HY000: CHECK OPTION on non-updatable view 'test.v_9801' +create view v_9801 as +select sum(s1) from t_9801 group by s1 with check option; +ERROR HY000: CHECK OPTION on non-updatable view 'test.v_9801' +create view v_9801 as +select sum(s1) from t_9801 group by s1 with rollup with check option; +ERROR HY000: CHECK OPTION on non-updatable view 'test.v_9801' +drop table t_9801; +# +# Bug #47335 assert in get_table_share +# +DROP TABLE IF EXISTS t1; +DROP VIEW IF EXISTS v1; +CREATE TEMPORARY TABLE t1 (id INT); +ALTER VIEW t1 AS SELECT 1 AS f1; +ERROR 42S02: Table 'test.t1' doesn't exist +DROP TABLE t1; +CREATE VIEW v1 AS SELECT 1 AS f1; +CREATE TEMPORARY TABLE v1 (id INT); +ALTER VIEW v1 AS SELECT 2 AS f1; +DROP TABLE v1; +SELECT * FROM v1; +f1 +2 +DROP VIEW v1; +# +# Bug #47635 assert in start_waiting_global_read_lock +# during CREATE VIEW +# +DROP TABLE IF EXISTS t1, t2; +DROP VIEW IF EXISTS t2; +CREATE TABLE t1 (f1 integer); +CREATE TEMPORARY TABLE IF NOT EXISTS t1 (f1 integer); +CREATE TEMPORARY TABLE t2 (f1 integer); +DROP TABLE t1; +FLUSH TABLES WITH READ LOCK; +CREATE VIEW t2 AS SELECT * FROM t1; +ERROR HY000: Can't execute the query because you have a conflicting read lock +UNLOCK TABLES; +DROP TABLE t1, t2; +# +# Bug#48315 Metadata lock is not taken for merged views that +# use an INFORMATION_SCHEMA table +# +DROP VIEW IF EXISTS v1; +DROP PROCEDURE IF EXISTS p1; +# Connection default +CREATE VIEW v1 AS SELECT schema_name FROM information_schema.schemata; +CREATE PROCEDURE p1() SELECT COUNT(*), GET_LOCK('blocker', 100) FROM v1; +# CALL p1() so the view is merged. +CALL p1(); +SELECT RELEASE_LOCK('blocker'); +RELEASE_LOCK('blocker') +1 +# Connection 3 +SELECT GET_LOCK('blocker', 100); +GET_LOCK('blocker', 100) +1 +# Connection default +# Try to CALL p1() again, this time it should block for t1. +# Sending: +CALL p1(); +# Connection 2 +# ... then try to drop the view. This should block. +# Sending: +DROP VIEW v1; +# Connection 3 +# Now allow CALL p1() to complete +SELECT RELEASE_LOCK('blocker'); +RELEASE_LOCK('blocker') +1 +# Connection default +# Reaping: CALL p1() +SELECT RELEASE_LOCK('blocker'); +RELEASE_LOCK('blocker') +1 +# Connection 2 +# Reaping: DROP VIEW v1 +# Connection default +DROP PROCEDURE p1; +# +# Bug#11766440 59546: Assertion m_sp == __null fails in +# Item_func_sp::init_result_field with functions +# +CREATE TABLE t1 (a INT); +CREATE FUNCTION f1 () RETURNS INTEGER RETURN 1; +CREATE FUNCTION f2 (i INTEGER) RETURNS INTEGER RETURN 1; +CREATE VIEW v1 AS SELECT f1() AS a FROM t1; +CREATE VIEW v2 AS SELECT f2(a) AS a FROM v1; +DROP FUNCTION f1; +SELECT f2(a) FROM v2; +ERROR HY000: View 'test.v2' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +DROP VIEW v2; +DROP VIEW v1; +DROP FUNCTION f2; +DROP TABLE t1; +# +# Bug#13418197: ASSERTION `(*TABLES)->REGINFO.LOCK_TYPE >= +# TL_READ' FAILED | MYSQL_LOCK_TABLES +# +DROP TABLE IF EXISTS t1; +CREATE TEMPORARY TABLE t1 (a INT) engine=InnoDB; +CREATE VIEW t1 AS SELECT 1; +DROP VIEW t1; +DROP TEMPORARY TABLE t1; +# +# Bug#13601606: FAILED VIEW CREATION ERROR MESSAGE (FOR DB NOT PRESENT) +# NEEDS BIG IMPROVEMENT +# +DROP DATABASE IF EXISTS nodb; +CREATE VIEW nodb.a AS SELECT 1; +ERROR 42000: Unknown database 'nodb' +# +# Bug#13633549 HANDLE_FATAL_SIGNAL IN +# TEST_IF_SKIP_SORT_ORDER/CREATE_SORT_INDEX +# +CREATE TABLE t1 ( +pk INT AUTO_INCREMENT, +c_int_key INT, +PRIMARY KEY (pk), +KEY (c_int_key) +) +ENGINE=innodb; +CREATE VIEW v_t1 AS SELECT * FROM t1; +CREATE TABLE t2 ( +pk INT auto_increment, +c_varchar_600_x VARCHAR(600), +c_int_key INT, +c_varchar_600_y VARCHAR(600), +c_varchar_600_z VARCHAR(600), +PRIMARY KEY (pk), +KEY (c_int_key) +) +ENGINE=innodb; +CREATE VIEW v_t2 AS SELECT * FROM t2; +INSERT INTO t2 VALUES +( +NULL, +repeat('x', 600), +3, +repeat('y', 600), +repeat('z', 600) +); +SELECT a1.pk AS f1 +FROM v_t1 AS a1 LEFT JOIN v_t2 AS a2 ON a1.pk=a2.c_int_key +WHERE +a1.pk > 8 +OR ((a1.pk BETWEEN 9 AND 13) AND a1.pk = 90) +ORDER BY f1 ; +f1 +DROP TABLE t1, t2; +DROP VIEW v_t1, v_t2; +# +# Bug#13783777 CONSTANT PROPAGATION IS WRONG FOR +# DISJUNCTIVE PREDICATES IN VIEWS +# +CREATE TABLE t1 ( +pk INTEGER, +PRIMARY KEY (pk) +); +INSERT INTO t1 VALUES (1), (2); +CREATE VIEW v_t1 AS SELECT * FROM t1; +SELECT pk +FROM t1 +WHERE +pk > 8 +OR ((pk BETWEEN 9 AND 13) AND pk = 90) +; +pk +SELECT pk +FROM v_t1 +WHERE +pk > 8 +OR ((pk BETWEEN 9 AND 13) AND pk = 90) +; +pk +DROP VIEW v_t1; +DROP TABLE t1; +# +# WL#5275 Process subqueries in FROM clause in the same way as view +# +CREATE TABLE t1(a INTEGER, b INTEGER); +CREATE TABLE t2(a INTEGER, b INTEGER); +INSERT INTO t1 VALUES(1, 10), (2, 20); +INSERT INTO t2 VALUES(1, 100), (2, 200); +CREATE VIEW v2 AS SELECT * FROM t2; +CREATE VIEW v2_sj AS SELECT * FROM t2 +WHERE a IN (SELECT a FROM t1); +CREATE VIEW v12_1 AS SELECT t2.a, t2.b FROM t1 JOIN t2 USING (a); +CREATE VIEW v12_2 AS SELECT t1.a, t2.b FROM t1 JOIN t2 USING (a); +CREATE VIEW v12_3 AS SELECT t2.a, t2.b FROM t1 JOIN t2 USING (a) +WHERE t1.b > 15; +CREATE VIEW vu_1 AS SELECT * FROM t2 UNION SELECT * FROM t2; +CREATE VIEW vu_2 AS SELECT * FROM t2 UNION ALL SELECT * FROM t2; +CREATE VIEW vd_1 AS SELECT DISTINCT a, b FROM t2; +CREATE VIEW va_1 AS SELECT SUM(a) AS a, SUM(b) AS b FROM t2; +CREATE VIEW vg_1 AS SELECT a, SUM(b) AS b FROM t2 GROUP BY a; +CREATE VIEW vh_1 AS SELECT 1 AS a FROM t2 HAVING COUNT(*) > 1; +CREATE VIEW vl_1 AS SELECT * FROM t2 LIMIT 1; +CREATE VIEW vlo_1 AS SELECT * FROM t2 LIMIT 2 OFFSET 1; +CREATE VIEW vrow AS SELECT 1 AS a; +CREATE VIEW vo_1 AS SELECT * FROM t2 ORDER BY a; +CREATE VIEW vo_2 AS SELECT * FROM t2 ORDER BY a DESC; +CREATE VIEW vx AS SELECT a, (SELECT b) AS b FROM t2; +ANALYZE TABLE t1,t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +SELECT * +FROM t1 JOIN v2 AS dt ON t1.a=dt.a; +a b a b +1 10 1 100 +2 20 2 200 +explain SELECT * +FROM t1 JOIN v2 AS dt ON t1.a=dt.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL # # NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL # # Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` join `test`.`t2` where (`test`.`t2`.`a` = `test`.`t1`.`a`) +SELECT * +FROM t1, v2 AS dt WHERE t1.a=dt.a; +a b a b +1 10 1 100 +2 20 2 200 +explain SELECT * +FROM t1, v2 AS dt WHERE t1.a=dt.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL # # NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL # # Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` join `test`.`t2` where (`test`.`t2`.`a` = `test`.`t1`.`a`) +SELECT * +FROM (t1 JOIN t2 ON t1.a=t2.a) JOIN v2 AS dt ON t1.a=dt.a; +a b a b a b +1 10 1 100 1 100 +2 20 2 200 2 200 +explain SELECT * +FROM (t1 JOIN t2 ON t1.a=t2.a) JOIN v2 AS dt ON t1.a=dt.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL # # NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL # # Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL # # Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` join `test`.`t2` join `test`.`t2` where ((`test`.`t2`.`a` = `test`.`t1`.`a`) and (`test`.`t2`.`a` = `test`.`t1`.`a`)) +SELECT * +FROM t1 JOIN v12_1 AS dt ON t1.a=dt.a; +a b a b +1 10 1 100 +2 20 2 200 +explain SELECT * +FROM t1 JOIN v12_1 AS dt ON t1.a=dt.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL # # NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL # # Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL # # Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` join `test`.`t1` join `test`.`t2` where ((`test`.`t1`.`a` = `test`.`t1`.`a`) and (`test`.`t2`.`a` = `test`.`t1`.`a`)) +SELECT * +FROM (t1 JOIN t2 USING (a)) +JOIN v12_1 AS dt +ON t1.a=dt.a; +a b b a b +1 10 100 1 100 +2 20 200 2 200 +explain SELECT * +FROM (t1 JOIN t2 USING (a)) +JOIN v12_1 AS dt +ON t1.a=dt.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL # # NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL # # Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL # # Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL # # Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` join `test`.`t2` join `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`a` = `test`.`t1`.`a`) and (`test`.`t1`.`a` = `test`.`t1`.`a`) and (`test`.`t2`.`a` = `test`.`t1`.`a`)) +SELECT * +FROM (t1 JOIN t2 USING (a)) +JOIN v12_2 AS dt1 +ON t1.a=dt1.a AND t2.b=dt1.b +JOIN v12_1 AS dt2 +ON dt1.a=dt2.a; +a b b a b a b +1 10 100 1 100 1 100 +2 20 200 2 200 2 200 +explain SELECT * +FROM (t1 JOIN t2 USING (a)) +JOIN v12_2 AS dt1 +ON t1.a=dt1.a AND t2.b=dt1.b +JOIN v12_1 AS dt2 +ON dt1.a=dt2.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL # # NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL # # Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL # # Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL # # Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL # # Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL # # Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`b` AS `b`,`test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` join `test`.`t2` join `test`.`t1` join `test`.`t2` join `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`b` = `test`.`t2`.`b`) and (`test`.`t2`.`a` = `test`.`t1`.`a`) and (`test`.`t1`.`a` = `test`.`t1`.`a`) and (`test`.`t2`.`a` = `test`.`t1`.`a`) and (`test`.`t1`.`a` = `test`.`t1`.`a`) and (`test`.`t2`.`a` = `test`.`t1`.`a`)) +SELECT * +FROM t1 JOIN v12_3 AS dt ON t1.a=dt.a; +a b a b +2 20 2 200 +explain SELECT * +FROM t1 JOIN v12_3 AS dt ON t1.a=dt.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL # # Using where +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL # # Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL # # Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` join `test`.`t1` join `test`.`t2` where ((`test`.`t1`.`a` = `test`.`t1`.`a`) and (`test`.`t2`.`a` = `test`.`t1`.`a`) and (`test`.`t1`.`b` > 15)) +SELECT * +FROM t1 JOIN v2_sj AS dt ON t1.a=dt.a; +a b a b +1 10 1 100 +2 20 2 200 +explain SELECT * +FROM t1 JOIN v2_sj AS dt ON t1.a=dt.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL # # NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL # # Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL # # Using where; FirstMatch(t2); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` join `test`.`t2` semi join (`test`.`t1`) where ((`test`.`t2`.`a` = `test`.`t1`.`a`) and (`test`.`t1`.`a` = `test`.`t1`.`a`)) +SELECT * +FROM t1 JOIN vu_1 AS dt ON t1.a=dt.a; +a b a b +1 10 1 100 +2 20 2 200 +explain SELECT * +FROM t1 JOIN vu_1 AS dt ON t1.a=dt.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL # # Using where +1 PRIMARY NULL ref 5 test.t1.a # # NULL +2 DERIVED t2 NULL ALL NULL NULL NULL NULL # # NULL +3 UNION t2 NULL ALL NULL NULL NULL NULL # # NULL +NULL UNION RESULT NULL ALL NULL NULL NULL NULL # # Using temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`dt`.`a` AS `a`,`test`.`dt`.`b` AS `b` from `test`.`t1` join `test`.`vu_1` `dt` where (`test`.`dt`.`a` = `test`.`t1`.`a`) +SELECT * +FROM t1 JOIN vu_2 AS dt ON t1.a=dt.a; +a b a b +1 10 1 100 +1 10 1 100 +2 20 2 200 +2 20 2 200 +explain SELECT * +FROM t1 JOIN vu_2 AS dt ON t1.a=dt.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL # # Using where +1 PRIMARY NULL ref 5 test.t1.a # # NULL +2 DERIVED t2 NULL ALL NULL NULL NULL NULL # # NULL +3 UNION t2 NULL ALL NULL NULL NULL NULL # # NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`dt`.`a` AS `a`,`test`.`dt`.`b` AS `b` from `test`.`t1` join `test`.`vu_2` `dt` where (`test`.`dt`.`a` = `test`.`t1`.`a`) +SELECT * +FROM t1 JOIN vd_1 AS dt ON t1.a=dt.a; +a b a b +1 10 1 100 +2 20 2 200 +explain SELECT * +FROM t1 JOIN vd_1 AS dt ON t1.a=dt.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL # # Using where +1 PRIMARY NULL ref 5 test.t1.a # # NULL +2 DERIVED t2 NULL ALL NULL NULL NULL NULL # # Using temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`dt`.`a` AS `a`,`test`.`dt`.`b` AS `b` from `test`.`t1` join `test`.`vd_1` `dt` where (`test`.`dt`.`a` = `test`.`t1`.`a`) +SELECT * +FROM t1 JOIN va_1 AS dt ON t1.a=dt.a; +a b a b +explain SELECT * +FROM t1 JOIN va_1 AS dt ON t1.a=dt.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL system NULL NULL NULL NULL # # NULL +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL # # Using where +2 DERIVED t2 NULL ALL NULL NULL NULL NULL # # NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,'3' AS `a`,'300' AS `b` from `test`.`t1` where (`test`.`t1`.`a` = '3') +SELECT * +FROM t1 JOIN vg_1 AS dt ON t1.a=dt.a; +a b a b +1 10 1 100 +2 20 2 200 +explain SELECT * +FROM t1 JOIN vg_1 AS dt ON t1.a=dt.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL # # Using where +1 PRIMARY NULL ref 5 test.t1.a # # NULL +2 DERIVED t2 NULL ALL NULL NULL NULL NULL # # Using temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`dt`.`a` AS `a`,`test`.`dt`.`b` AS `b` from `test`.`t1` join `test`.`vg_1` `dt` where (`test`.`dt`.`a` = `test`.`t1`.`a`) +SELECT * +FROM t1 JOIN vh_1 AS dt ON t1.a=dt.a; +a b a +1 10 1 +explain SELECT * +FROM t1 JOIN vh_1 AS dt ON t1.a=dt.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL system NULL NULL NULL NULL # # NULL +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL # # Using where +2 DERIVED t2 NULL ALL NULL NULL NULL NULL # # NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,'1' AS `a` from `test`.`t1` where (`test`.`t1`.`a` = '1') +SELECT * +FROM t1 JOIN vl_1 AS dt ON t1.a=dt.a; +a b a b +1 10 1 100 +explain SELECT * +FROM t1 JOIN vl_1 AS dt ON t1.a=dt.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL system NULL NULL NULL NULL # # NULL +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL # # Using where +2 DERIVED t2 NULL ALL NULL NULL NULL NULL # # NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,'1' AS `a`,'100' AS `b` from `test`.`t1` where (`test`.`t1`.`a` = '1') +SELECT * +FROM t1 JOIN vlo_1 AS dt ON t1.a=dt.a; +a b a b +2 20 2 200 +explain SELECT * +FROM t1 JOIN vlo_1 AS dt ON t1.a=dt.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL # # Using where +1 PRIMARY NULL ref 5 test.t1.a # # NULL +2 DERIVED t2 NULL ALL NULL NULL NULL NULL # # NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`dt`.`a` AS `a`,`test`.`dt`.`b` AS `b` from `test`.`t1` join `test`.`vlo_1` `dt` where (`test`.`dt`.`a` = `test`.`t1`.`a`) +SELECT * +FROM t1 JOIN vrow AS dt ON t1.a=dt.a; +a b a +1 10 1 +explain SELECT * +FROM t1 JOIN vrow AS dt ON t1.a=dt.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL system NULL NULL NULL NULL # # NULL +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL # # Using where +2 DERIVED NULL NULL NULL NULL NULL NULL NULL # # No tables used +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,'1' AS `a` from `test`.`t1` where (`test`.`t1`.`a` = '1') +SELECT * +FROM vo_1 AS dt; +a b +1 100 +2 200 +explain SELECT * +FROM vo_1 AS dt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL # # Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t2` order by `test`.`t2`.`a` +SELECT * +FROM vo_2 AS dt; +a b +2 200 +1 100 +explain SELECT * +FROM vo_2 AS dt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL # # Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t2` order by `test`.`t2`.`a` desc +SELECT * +FROM vo_1 AS dt +WHERE dt.a > 0; +a b +1 100 +2 200 +explain SELECT * +FROM vo_1 AS dt +WHERE dt.a > 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL # # Using where; Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t2` where (`test`.`t2`.`a` > 0) order by `test`.`t2`.`a` +SELECT * +FROM vo_2 AS dt +WHERE dt.a > 0; +a b +2 200 +1 100 +explain SELECT * +FROM vo_2 AS dt +WHERE dt.a > 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL # # Using where; Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t2` where (`test`.`t2`.`a` > 0) order by `test`.`t2`.`a` desc +SELECT * +FROM t1 JOIN vo_1 AS dt ON t1.a=dt.a; +a b a b +1 10 1 100 +2 20 2 200 +explain SELECT * +FROM t1 JOIN vo_1 AS dt ON t1.a=dt.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL # # NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL # # Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` join `test`.`t2` where (`test`.`t2`.`a` = `test`.`t1`.`a`) +SELECT * +FROM t1 JOIN vo_2 AS dt ON t1.a=dt.a; +a b a b +1 10 1 100 +2 20 2 200 +explain SELECT * +FROM t1 JOIN vo_2 AS dt ON t1.a=dt.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL # # NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL # # Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` join `test`.`t2` where (`test`.`t2`.`a` = `test`.`t1`.`a`) +SELECT dt.a, COUNT(*) +FROM vo_1 AS dt +GROUP BY dt.a; +a COUNT(*) +1 1 +2 1 +explain SELECT dt.a, COUNT(*) +FROM vo_1 AS dt +GROUP BY dt.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,count(0) AS `COUNT(*)` from `test`.`t2` group by `test`.`t2`.`a` +SELECT dt.a, COUNT(*) +FROM vo_2 AS dt +GROUP BY dt.a; +a COUNT(*) +1 1 +2 1 +explain SELECT dt.a, COUNT(*) +FROM vo_2 AS dt +GROUP BY dt.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,count(0) AS `COUNT(*)` from `test`.`t2` group by `test`.`t2`.`a` +SELECT COUNT(*) +FROM vo_1 AS dt; +COUNT(*) +2 +explain SELECT COUNT(*) +FROM vo_1 AS dt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t2` +SELECT COUNT(*) +FROM vo_2 AS dt; +COUNT(*) +2 +explain SELECT COUNT(*) +FROM vo_2 AS dt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t2` +SELECT DISTINCT * +FROM vo_1 AS dt; +a b +1 100 +2 200 +explain SELECT DISTINCT * +FROM vo_1 AS dt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using temporary +Warnings: +Note 1003 /* select#1 */ select distinct `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t2` +SELECT DISTINCT * +FROM vo_2 AS dt; +a b +1 100 +2 200 +explain SELECT DISTINCT * +FROM vo_2 AS dt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using temporary +Warnings: +Note 1003 /* select#1 */ select distinct `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t2` +SELECT * +FROM t1 JOIN vo_1 AS dt ON t1.a=dt.a +ORDER BY t1.b; +a b a b +1 10 1 100 +2 20 2 200 +explain SELECT * +FROM t1 JOIN vo_1 AS dt ON t1.a=dt.a +ORDER BY t1.b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL # # Using temporary; Using filesort +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL # # Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` join `test`.`t2` where (`test`.`t2`.`a` = `test`.`t1`.`a`) order by `test`.`t1`.`b` +SELECT * +FROM t1 JOIN vo_2 AS dt ON t1.a=dt.a +ORDER BY t1.b; +a b a b +1 10 1 100 +2 20 2 200 +explain SELECT * +FROM t1 JOIN vo_2 AS dt ON t1.a=dt.a +ORDER BY t1.b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL # # Using temporary; Using filesort +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL # # Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` join `test`.`t2` where (`test`.`t2`.`a` = `test`.`t1`.`a`) order by `test`.`t1`.`b` +SELECT * +FROM t1 JOIN vx AS dt ON t1.a=dt.a; +a b a b +1 10 1 100 +2 20 2 200 +explain SELECT * +FROM t1 JOIN vx AS dt ON t1.a=dt.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL # # NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL # # Using where; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t2.b' of SELECT #3 was resolved in SELECT #2 +Note 1249 Select 3 was reduced during optimization +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` join `test`.`t2` where (`test`.`t2`.`a` = `test`.`t1`.`a`) +SET @optimizer_switch_saved= @@optimizer_switch; +SET @@optimizer_switch="derived_merge=off"; +SELECT * +FROM (t1 JOIN t2 USING (a)) +JOIN v12_1 AS dt +ON t1.a=dt.a; +a b b a b +1 10 100 1 100 +2 20 200 2 200 +explain SELECT * +FROM (t1 JOIN t2 USING (a)) +JOIN v12_1 AS dt +ON t1.a=dt.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL # # Using where +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL # # Using where; Using join buffer (hash join) +1 PRIMARY NULL ref 5 test.t1.a # # NULL +2 DERIVED t1 NULL ALL NULL NULL NULL NULL # # NULL +2 DERIVED t2 NULL ALL NULL NULL NULL NULL # # Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`b` AS `b`,`test`.`dt`.`a` AS `a`,`test`.`dt`.`b` AS `b` from `test`.`t1` join `test`.`t2` join `test`.`v12_1` `dt` where ((`test`.`t2`.`a` = `test`.`t1`.`a`) and (`test`.`dt`.`a` = `test`.`t1`.`a`)) +SET @@optimizer_switch="derived_merge=on"; +SELECT * +FROM (t1 JOIN t2 USING (a)) +JOIN v12_1 AS dt +ON t1.a=dt.a; +a b b a b +1 10 100 1 100 +2 20 200 2 200 +explain SELECT * +FROM (t1 JOIN t2 USING (a)) +JOIN v12_1 AS dt +ON t1.a=dt.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` join `test`.`t2` join `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`a` = `test`.`t1`.`a`) and (`test`.`t1`.`a` = `test`.`t1`.`a`) and (`test`.`t2`.`a` = `test`.`t1`.`a`)) +SET @@optimizer_switch= @optimizer_switch_saved; +DROP VIEW v2, v2_sj, v12_1, v12_2, v12_3; +DROP VIEW vu_1, vu_2, vd_1, va_1, vg_1, vh_1, vl_1; +DROP VIEW vlo_1, vrow, vo_1, vo_2, vx; +DROP TABLE t1, t2; +CREATE TABLE t1(a INTEGER, b INTEGER); +CREATE TABLE t2(a INTEGER); +INSERT INTO t1 VALUES +(1, 10), +(2, 20), (2, 21), +(3, NULL), +(4, 40), (4, 41), (4, 42), (4, 43), (4, 44); +INSERT INTO t2 VALUES (1), (2), (3), (4), (5), (NULL); +ANALYZE TABLE t1,t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +CREATE VIEW v1 AS +SELECT * FROM (SELECT * FROM t2) AS dt; +SELECT * FROM v1; +a +1 +2 +3 +4 +5 +NULL +SELECT * FROM (SELECT * FROM t2) AS dt; +a +1 +2 +3 +4 +5 +NULL +explain SELECT * FROM v1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL # # NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` +explain SELECT * FROM (SELECT * FROM t2) AS dt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # # Parallel execute (1 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL # # NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` +DROP VIEW v1; +CREATE VIEW v1 AS +SELECT * FROM (SELECT * FROM t1 WHERE b=a*10) AS dt; +SELECT * FROM v1; +a b +1 10 +2 20 +4 40 +SELECT * FROM (SELECT * FROM t1 WHERE b=a*10) AS dt; +a b +1 10 +2 20 +4 40 +explain SELECT * FROM v1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL # # Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (`test`.`t1`.`b` = (`test`.`t1`.`a` * 10)) +explain SELECT * FROM (SELECT * FROM t1 WHERE b=a*10) AS dt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # # Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL # # Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (`test`.`t1`.`b` = (`test`.`t1`.`a` * 10)) +DROP VIEW v1; +CREATE VIEW v1 AS +SELECT * FROM (SELECT a, SUM(b) AS s, COUNT(*) AS c FROM t1 GROUP BY a ORDER BY a) AS dt; +SELECT * FROM v1; +a s c +1 10 1 +2 41 2 +3 NULL 1 +4 210 5 +SELECT * FROM (SELECT a, SUM(b) AS s, COUNT(*) AS c FROM t1 GROUP BY a ORDER BY a) AS dt; +a s c +1 10 1 +2 41 2 +3 NULL 1 +4 210 5 +explain SELECT * FROM v1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL # # NULL +3 DERIVED t1 NULL ALL NULL NULL NULL NULL # # Using temporary; Using filesort +Warnings: +Note 1003 /* select#1 */ select `dt`.`a` AS `a`,`dt`.`s` AS `s`,`dt`.`c` AS `c` from (/* select#3 */ select `test`.`t1`.`a` AS `a`,sum(`test`.`t1`.`b`) AS `s`,count(0) AS `c` from `test`.`t1` group by `test`.`t1`.`a` order by `test`.`t1`.`a`) `dt` +explain SELECT * FROM (SELECT a, SUM(b) AS s, COUNT(*) AS c FROM t1 GROUP BY a ORDER BY a) AS dt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL # # NULL +2 DERIVED t1 NULL ALL NULL NULL NULL NULL # # Using temporary; Using filesort +Warnings: +Note 1003 /* select#1 */ select `dt`.`a` AS `a`,`dt`.`s` AS `s`,`dt`.`c` AS `c` from (/* select#2 */ select `test`.`t1`.`a` AS `a`,sum(`test`.`t1`.`b`) AS `s`,count(0) AS `c` from `test`.`t1` group by `test`.`t1`.`a` order by `test`.`t1`.`a`) `dt` +DROP VIEW v1; +CREATE VIEW v1 AS +SELECT * FROM (SELECT DISTINCT a FROM t1) AS dt; +SELECT * FROM v1; +a +1 +2 +3 +4 +SELECT * FROM (SELECT DISTINCT a FROM t1) AS dt; +a +1 +2 +3 +4 +explain SELECT * FROM v1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL # # NULL +3 DERIVED t1 NULL ALL NULL NULL NULL NULL # # Using temporary +Warnings: +Note 1003 /* select#1 */ select `dt`.`a` AS `a` from (/* select#3 */ select distinct `test`.`t1`.`a` AS `a` from `test`.`t1`) `dt` +explain SELECT * FROM (SELECT DISTINCT a FROM t1) AS dt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL # # NULL +2 DERIVED t1 NULL ALL NULL NULL NULL NULL # # Using temporary +Warnings: +Note 1003 /* select#1 */ select `dt`.`a` AS `a` from (/* select#2 */ select distinct `test`.`t1`.`a` AS `a` from `test`.`t1`) `dt` +DROP VIEW v1; +CREATE VIEW v1 AS +SELECT * FROM (SELECT * FROM t1 LIMIT 3 OFFSET 3) AS dt; +SELECT * FROM v1; +a b +3 NULL +4 40 +4 41 +SELECT * FROM (SELECT * FROM t1 LIMIT 3 OFFSET 3) AS dt; +a b +3 NULL +4 40 +4 41 +explain SELECT * FROM v1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL # # NULL +3 DERIVED t1 NULL ALL NULL NULL NULL NULL # # NULL +Warnings: +Note 1003 /* select#1 */ select `dt`.`a` AS `a`,`dt`.`b` AS `b` from (/* select#3 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` limit 3,3) `dt` +explain SELECT * FROM (SELECT * FROM t1 LIMIT 3 OFFSET 3) AS dt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL # # NULL +2 DERIVED t1 NULL ALL NULL NULL NULL NULL # # NULL +Warnings: +Note 1003 /* select#1 */ select `dt`.`a` AS `a`,`dt`.`b` AS `b` from (/* select#2 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` limit 3,3) `dt` +DROP VIEW v1; +CREATE VIEW v1 AS +SELECT * FROM (SELECT DISTINCT a FROM t1 UNION ALL SELECT a FROM t2) AS dt; +SELECT * FROM v1; +a +1 +2 +3 +4 +1 +2 +3 +4 +5 +NULL +SELECT * FROM (SELECT DISTINCT a FROM t1 UNION ALL SELECT a FROM t2) AS dt; +a +1 +2 +3 +4 +1 +2 +3 +4 +5 +NULL +explain SELECT * FROM v1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL # # NULL +3 DERIVED t1 NULL ALL NULL NULL NULL NULL # # Using temporary +4 UNION t2 NULL ALL NULL NULL NULL NULL # # NULL +Warnings: +Note 1003 /* select#1 */ select `dt`.`a` AS `a` from (/* select#3 */ select distinct `test`.`t1`.`a` AS `a` from `test`.`t1` union all /* select#4 */ select `test`.`t2`.`a` AS `a` from `test`.`t2`) `dt` +explain SELECT * FROM (SELECT DISTINCT a FROM t1 UNION ALL SELECT a FROM t2) AS dt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL # # NULL +2 DERIVED t1 NULL ALL NULL NULL NULL NULL # # Using temporary +3 UNION t2 NULL ALL NULL NULL NULL NULL # # NULL +Warnings: +Note 1003 /* select#1 */ select `dt`.`a` AS `a` from (/* select#2 */ select distinct `test`.`t1`.`a` AS `a` from `test`.`t1` union all /* select#3 */ select `test`.`t2`.`a` AS `a` from `test`.`t2`) `dt` +DROP VIEW v1; +CREATE VIEW v1 AS +SELECT * FROM (SELECT * FROM t1 WHERE (SELECT a FROM t1 LIMIT 1) = b/10) AS dt; +SELECT * FROM v1; +a b +1 10 +SELECT * FROM (SELECT * FROM t1 WHERE (SELECT a FROM t1 LIMIT 1) = b/10) AS dt; +a b +1 10 +explain SELECT * FROM v1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL # # Using where +4 SUBQUERY t1 NULL ALL NULL NULL NULL NULL # # NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((/* select#4 */ select `test`.`t1`.`a` from `test`.`t1` limit 1) = (`test`.`t1`.`b` / 10)) +explain SELECT * FROM (SELECT * FROM t1 WHERE (SELECT a FROM t1 LIMIT 1) = b/10) AS dt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL # # Using where +3 SUBQUERY t1 NULL ALL NULL NULL NULL NULL # # NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((/* select#3 */ select `test`.`t1`.`a` from `test`.`t1` limit 1) = (`test`.`t1`.`b` / 10)) +DROP VIEW v1; +CREATE VIEW v1 AS +SELECT * FROM (SELECT * FROM t1 WHERE a IN (SELECT a FROM t2 WHERE a % 2 = 0)) AS dt; +SELECT * FROM v1; +a b +2 20 +2 21 +4 40 +4 41 +4 42 +4 43 +4 44 +SELECT * FROM (SELECT * FROM t1 WHERE a IN (SELECT a FROM t2 WHERE a % 2 = 0)) AS dt; +a b +2 20 +2 21 +4 40 +4 41 +4 42 +4 43 +4 44 +explain SELECT * FROM v1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL # # Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL # # Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`a` = `test`.`t2`.`a`) and ((`test`.`t2`.`a` % 2) = 0)) +explain SELECT * FROM (SELECT * FROM t1 WHERE a IN (SELECT a FROM t2 WHERE a % 2 = 0)) AS dt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL # # Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL # # Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`a` = `test`.`t2`.`a`) and ((`test`.`t2`.`a` % 2) = 0)) +DROP VIEW v1; +CREATE VIEW v1 AS +SELECT * FROM (SELECT a, (SELECT a FROM t2 WHERE a=t1.a) +FROM t1 WHERE b IN (SELECT a*10 FROM t2)) AS dt; +SELECT * FROM v1; +a (SELECT a FROM t2 WHERE a=t1.a) +1 1 +2 2 +4 4 +SELECT * FROM (SELECT a, (SELECT a FROM t2 WHERE a=t1.a) +FROM t1 WHERE b IN (SELECT a*10 FROM t2)) AS dt; +a (SELECT a FROM t2 WHERE a=t1.a) +1 1 +2 2 +4 4 +explain SELECT * FROM v1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL # # NULL +3 DERIVED t2 NULL ALL NULL NULL NULL NULL # # Start temporary +3 DERIVED t1 NULL ALL NULL NULL NULL NULL # # Using where; End temporary; Using join buffer (hash join) +5 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL # # Using where +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #5 was resolved in SELECT #3 +Note 1003 /* select#1 */ select `dt`.`a` AS `a`,`dt`.`(SELECT a FROM t2 WHERE a=t1.a)` AS `(SELECT a FROM t2 WHERE a=t1.a)` from (/* select#3 */ select `test`.`t1`.`a` AS `a`,(/* select#5 */ select `test`.`t2`.`a` from `test`.`t2` where (`test`.`t2`.`a` = `test`.`t1`.`a`)) AS `(SELECT a FROM t2 WHERE a=t1.a)` from `test`.`t1` semi join (`test`.`t2`) where (`test`.`t1`.`b` = (`test`.`t2`.`a` * 10))) `dt` +explain SELECT * FROM (SELECT a, (SELECT a FROM t2 WHERE a=t1.a) +FROM t1 WHERE b IN (SELECT a*10 FROM t2)) AS dt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL # # NULL +2 DERIVED t2 NULL ALL NULL NULL NULL NULL # # Start temporary +2 DERIVED t1 NULL ALL NULL NULL NULL NULL # # Using where; End temporary; Using join buffer (hash join) +3 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL # # Using where +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #3 was resolved in SELECT #2 +Note 1003 /* select#1 */ select `dt`.`a` AS `a`,`dt`.`(SELECT a FROM t2 WHERE a=t1.a)` AS `(SELECT a FROM t2 WHERE a=t1.a)` from (/* select#2 */ select `test`.`t1`.`a` AS `a`,(/* select#3 */ select `test`.`t2`.`a` from `test`.`t2` where (`test`.`t2`.`a` = `test`.`t1`.`a`)) AS `(SELECT a FROM t2 WHERE a=t1.a)` from `test`.`t1` semi join (`test`.`t2`) where (`test`.`t1`.`b` = (`test`.`t2`.`a` * 10))) `dt` +DROP VIEW v1; +CREATE VIEW v1 AS +SELECT * FROM (SELECT a, (SELECT a FROM t2) FROM t1 WHERE b=a*10) AS dt; +SELECT * FROM v1; +ERROR 21000: Subquery returns more than 1 row +SELECT * FROM (SELECT a, (SELECT a FROM t2) FROM t1 WHERE b=a*10) AS dt; +ERROR 21000: Subquery returns more than 1 row +DROP VIEW v1; +CREATE VIEW v1 AS +SELECT * FROM (SELECT a, b FROM t1 WHERE b IN (SELECT a*10 FROM t2)) AS dt; +SELECT * FROM v1 JOIN t2 ON v1.a=t2.a; +a b a +1 10 1 +2 20 2 +4 40 4 +SELECT * FROM (SELECT a, b FROM t1 WHERE b IN (SELECT a*10 FROM t2)) AS dt JOIN t2 ON dt.a=t2.a; +a b a +1 10 1 +2 20 2 +4 40 4 +explain SELECT * FROM v1 JOIN t2 ON v1.a=t2.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL # # Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL # # Using where; End temporary; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL # # Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a` from `test`.`t1` semi join (`test`.`t2`) join `test`.`t2` where ((`test`.`t2`.`a` = `test`.`t1`.`a`) and (`test`.`t1`.`b` = (`test`.`t2`.`a` * 10))) +explain SELECT * FROM (SELECT a, b FROM t1 WHERE b IN (SELECT a*10 FROM t2)) AS dt JOIN t2 ON dt.a=t2.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL # # Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL # # Using where; End temporary; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL # # Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a` from `test`.`t1` semi join (`test`.`t2`) join `test`.`t2` where ((`test`.`t2`.`a` = `test`.`t1`.`a`) and (`test`.`t1`.`b` = (`test`.`t2`.`a` * 10))) +DROP VIEW v1; +DROP TABLE t1, t2; +CREATE TABLE t1(a INTEGER, b INTEGER); +CREATE TABLE t2(a INTEGER); +INSERT INTO t1 VALUES +(1, 10), +(2, 20), (2, 21), +(3, NULL), +(4, 40), (4, 41), (4, 42), (4, 43), (4, 44); +INSERT INTO t2 VALUES (1), (2), (3), (4), (5), (NULL); +ANALYZE TABLE t1,t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +CREATE VIEW v1 AS SELECT a, b, (SELECT 1 FROM t2 WHERE a=3) AS s +FROM t1; +SELECT * FROM v1; +a b s +1 10 1 +2 20 1 +2 21 1 +3 NULL 1 +4 40 1 +4 41 1 +4 42 1 +4 43 1 +4 44 1 +SELECT a FROM v1; +a +1 +2 +2 +3 +4 +4 +4 +4 +4 +SELECT a, b, (SELECT 1 FROM t2 WHERE a=3) AS s +FROM t1; +a b s +1 10 1 +2 20 1 +2 21 1 +3 NULL 1 +4 40 1 +4 41 1 +4 42 1 +4 43 1 +4 44 1 +explain SELECT * FROM v1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL # # NULL +3 SUBQUERY t2 NULL ALL NULL NULL NULL NULL # # Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,(/* select#3 */ select 1 from `test`.`t2` where (`test`.`t2`.`a` = 3)) AS `s` from `test`.`t1` +explain SELECT a FROM v1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL # # NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` +explain SELECT a, b, (SELECT 1 FROM t2 WHERE a=3) AS s +FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL # # NULL +2 SUBQUERY t2 NULL ALL NULL NULL NULL NULL # # Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,(/* select#2 */ select 1 from `test`.`t2` where (`test`.`t2`.`a` = 3)) AS `s` from `test`.`t1` +DROP VIEW v1; +CREATE VIEW v1 AS SELECT a, b, (SELECT 1 FROM t2 WHERE a=6) AS s +FROM t1; +SELECT * FROM v1; +a b s +1 10 NULL +2 20 NULL +2 21 NULL +3 NULL NULL +4 40 NULL +4 41 NULL +4 42 NULL +4 43 NULL +4 44 NULL +SELECT a FROM v1; +a +1 +2 +2 +3 +4 +4 +4 +4 +4 +SELECT a, b, (SELECT 1 FROM t2 WHERE a=6) AS s +FROM t1; +a b s +1 10 NULL +2 20 NULL +2 21 NULL +3 NULL NULL +4 40 NULL +4 41 NULL +4 42 NULL +4 43 NULL +4 44 NULL +explain SELECT * FROM v1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL # # NULL +3 SUBQUERY t2 NULL ALL NULL NULL NULL NULL # # Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,(/* select#3 */ select 1 from `test`.`t2` where (`test`.`t2`.`a` = 6)) AS `s` from `test`.`t1` +explain SELECT a FROM v1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL # # NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` +explain SELECT a, b, (SELECT 1 FROM t2 WHERE a=6) AS s +FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL # # NULL +2 SUBQUERY t2 NULL ALL NULL NULL NULL NULL # # Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,(/* select#2 */ select 1 from `test`.`t2` where (`test`.`t2`.`a` = 6)) AS `s` from `test`.`t1` +DROP VIEW v1; +CREATE VIEW v1 AS SELECT a, b, (SELECT 1 FROM t2 WHERE a>=3) AS s +FROM t1; +SELECT * FROM v1; +ERROR 21000: Subquery returns more than 1 row +SELECT a FROM v1; +a +1 +2 +2 +3 +4 +4 +4 +4 +4 +SELECT a, b, (SELECT 1 FROM t2 WHERE a>=3) AS s +FROM t1; +ERROR 21000: Subquery returns more than 1 row +explain SELECT a FROM v1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL # # NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` +DROP VIEW v1; +CREATE VIEW v1 AS SELECT a, b, a IN (SELECT 1 FROM t2 WHERE a=6) AS s +FROM t1; +SELECT * FROM v1; +a b s +1 10 0 +2 20 0 +2 21 0 +3 NULL 0 +4 40 0 +4 41 0 +4 42 0 +4 43 0 +4 44 0 +SELECT a FROM v1; +a +1 +2 +2 +3 +4 +4 +4 +4 +4 +SELECT a, b, a IN (SELECT 1 FROM t2 WHERE a=6) AS s +FROM t1; +a b s +1 10 0 +2 20 0 +2 21 0 +3 NULL 0 +4 40 0 +4 41 0 +4 42 0 +4 43 0 +4 44 0 +explain SELECT * FROM v1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL # # NULL +2 DERIVED t1 NULL ALL NULL NULL NULL NULL # # NULL +3 SUBQUERY t2 NULL ALL NULL NULL NULL NULL # # Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`v1`.`a` AS `a`,`test`.`v1`.`b` AS `b`,`test`.`v1`.`s` AS `s` from `test`.`v1` +explain SELECT a FROM v1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL # # NULL +2 DERIVED t1 NULL ALL NULL NULL NULL NULL # # NULL +3 SUBQUERY t2 NULL ALL NULL NULL NULL NULL # # Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`v1`.`a` AS `a` from `test`.`v1` +explain SELECT a, b, a IN (SELECT 1 FROM t2 WHERE a=6) AS s +FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL # # NULL +2 SUBQUERY t2 NULL ALL NULL NULL NULL NULL # # Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,(`test`.`t1`.`a`,`test`.`t1`.`a` in ( (/* select#2 */ select 1 from `test`.`t2` where (`test`.`t2`.`a` = 6) ), (`test`.`t1`.`a` in on where ((`test`.`t1`.`a` = ``.`1`))))) AS `s` from `test`.`t1` +DROP VIEW v1; +CREATE VIEW v1 AS SELECT a, b, (SELECT COUNT(*) FROM t2) AS c +FROM t1; +SELECT * FROM v1; +a b c +1 10 6 +2 20 6 +2 21 6 +3 NULL 6 +4 40 6 +4 41 6 +4 42 6 +4 43 6 +4 44 6 +SELECT a FROM v1; +a +1 +2 +2 +3 +4 +4 +4 +4 +4 +SELECT a, b, (SELECT COUNT(*) FROM t2) AS c +FROM t1; +a b c +1 10 6 +2 20 6 +2 21 6 +3 NULL 6 +4 40 6 +4 41 6 +4 42 6 +4 43 6 +4 44 6 +explain SELECT * FROM v1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL # # NULL +3 SUBQUERY t2 NULL ALL NULL NULL NULL NULL # # NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,(/* select#3 */ select count(0) from `test`.`t2`) AS `c` from `test`.`t1` +explain SELECT a FROM v1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL # # NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` +explain SELECT a, b, (SELECT COUNT(*) FROM t2) AS c +FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL # # NULL +2 SUBQUERY t2 NULL ALL NULL NULL NULL NULL # # NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,(/* select#2 */ select count(0) from `test`.`t2`) AS `c` from `test`.`t1` +DROP VIEW v1; +CREATE VIEW v1 AS SELECT a, b, a IN (SELECT COUNT(*) FROM t2) AS c +FROM t1; +SELECT * FROM v1; +a b c +1 10 0 +2 20 0 +2 21 0 +3 NULL 0 +4 40 0 +4 41 0 +4 42 0 +4 43 0 +4 44 0 +SELECT a FROM v1; +a +1 +2 +2 +3 +4 +4 +4 +4 +4 +SELECT a, b, a IN (SELECT COUNT(*) FROM t2) AS c +FROM t1; +a b c +1 10 0 +2 20 0 +2 21 0 +3 NULL 0 +4 40 0 +4 41 0 +4 42 0 +4 43 0 +4 44 0 +explain SELECT * FROM v1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL # # NULL +2 DERIVED t1 NULL ALL NULL NULL NULL NULL # # NULL +3 SUBQUERY t2 NULL ALL NULL NULL NULL NULL # # NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`v1`.`a` AS `a`,`test`.`v1`.`b` AS `b`,`test`.`v1`.`c` AS `c` from `test`.`v1` +explain SELECT a FROM v1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL # # NULL +2 DERIVED t1 NULL ALL NULL NULL NULL NULL # # NULL +3 SUBQUERY t2 NULL ALL NULL NULL NULL NULL # # NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`v1`.`a` AS `a` from `test`.`v1` +explain SELECT a, b, a IN (SELECT COUNT(*) FROM t2) AS c +FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL # # NULL +2 SUBQUERY t2 NULL ALL NULL NULL NULL NULL # # NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,(`test`.`t1`.`a`,`test`.`t1`.`a` in ( (/* select#2 */ select count(0) from `test`.`t2` having true ), (`test`.`t1`.`a` in on where ((`test`.`t1`.`a` = ``.`COUNT(*)`))))) AS `c` from `test`.`t1` +DROP VIEW v1; +CREATE VIEW v1 AS SELECT a, b, (SELECT a*2 FROM t2 WHERE a=t1.a) AS s +FROM t1; +SELECT * FROM v1; +a b s +1 10 2 +2 20 4 +2 21 4 +3 NULL 6 +4 40 8 +4 41 8 +4 42 8 +4 43 8 +4 44 8 +SELECT a FROM v1; +a +1 +2 +2 +3 +4 +4 +4 +4 +4 +SELECT a, b, (SELECT a*2 FROM t2 WHERE a=t1.a) AS s +FROM t1; +a b s +1 10 2 +2 20 4 +2 21 4 +3 NULL 6 +4 40 8 +4 41 8 +4 42 8 +4 43 8 +4 44 8 +explain SELECT * FROM v1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL # # NULL +2 DERIVED t1 NULL ALL NULL NULL NULL NULL # # NULL +3 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL # # Using where +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #3 was resolved in SELECT #2 +Note 1003 /* select#1 */ select `test`.`v1`.`a` AS `a`,`test`.`v1`.`b` AS `b`,`test`.`v1`.`s` AS `s` from `test`.`v1` +explain SELECT a FROM v1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL # # NULL +2 DERIVED t1 NULL ALL NULL NULL NULL NULL # # NULL +3 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL # # Using where +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #3 was resolved in SELECT #2 +Note 1003 /* select#1 */ select `test`.`v1`.`a` AS `a` from `test`.`v1` +explain SELECT a, b, (SELECT a*2 FROM t2 WHERE a=t1.a) AS s +FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL # # NULL +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL # # Using where +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,(/* select#2 */ select (`test`.`t2`.`a` * 2) from `test`.`t2` where (`test`.`t2`.`a` = `test`.`t1`.`a`)) AS `s` from `test`.`t1` +DROP VIEW v1; +CREATE VIEW v1 AS SELECT a, b, EXISTS (SELECT a*2 FROM t2 WHERE a=t1.a) AS s +FROM t1; +SELECT * FROM v1; +a b s +1 10 1 +2 20 1 +2 21 1 +3 NULL 1 +4 40 1 +4 41 1 +4 42 1 +4 43 1 +4 44 1 +SELECT a FROM v1; +a +1 +2 +2 +3 +4 +4 +4 +4 +4 +SELECT a, b, EXISTS (SELECT a*2 FROM t2 WHERE a=t1.a) AS s +FROM t1; +a b s +1 10 1 +2 20 1 +2 21 1 +3 NULL 1 +4 40 1 +4 41 1 +4 42 1 +4 43 1 +4 44 1 +explain SELECT * FROM v1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL # # NULL +2 DERIVED t1 NULL ALL NULL NULL NULL NULL # # NULL +3 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL # # Using where +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #3 was resolved in SELECT #2 +Note 1003 /* select#1 */ select `test`.`v1`.`a` AS `a`,`test`.`v1`.`b` AS `b`,`test`.`v1`.`s` AS `s` from `test`.`v1` +explain SELECT a FROM v1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL # # NULL +2 DERIVED t1 NULL ALL NULL NULL NULL NULL # # NULL +3 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL # # Using where +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #3 was resolved in SELECT #2 +Note 1003 /* select#1 */ select `test`.`v1`.`a` AS `a` from `test`.`v1` +explain SELECT a, b, EXISTS (SELECT a*2 FROM t2 WHERE a=t1.a) AS s +FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL # # NULL +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL # # Using where +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,exists(/* select#2 */ select (`test`.`t2`.`a` * 2) from `test`.`t2` where (`test`.`t2`.`a` = `test`.`t1`.`a`)) AS `s` from `test`.`t1` +DROP VIEW v1; +CREATE VIEW v1 AS SELECT a, b, (SELECT COUNT(*) FROM t1 AS t2 WHERE a=t1.a) AS s +FROM t1; +SELECT * FROM v1; +a b s +1 10 1 +2 20 2 +2 21 2 +3 NULL 1 +4 40 5 +4 41 5 +4 42 5 +4 43 5 +4 44 5 +SELECT a FROM v1; +a +1 +2 +2 +3 +4 +4 +4 +4 +4 +SELECT a, b, (SELECT COUNT(*) FROM t1 AS t2 WHERE a=t1.a) AS s +FROM t1; +a b s +1 10 1 +2 20 2 +2 21 2 +3 NULL 1 +4 40 5 +4 41 5 +4 42 5 +4 43 5 +4 44 5 +explain SELECT * FROM v1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL # # NULL +2 DERIVED t1 NULL ALL NULL NULL NULL NULL # # NULL +3 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL # # Using where +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #3 was resolved in SELECT #2 +Note 1003 /* select#1 */ select `test`.`v1`.`a` AS `a`,`test`.`v1`.`b` AS `b`,`test`.`v1`.`s` AS `s` from `test`.`v1` +explain SELECT a FROM v1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL # # NULL +2 DERIVED t1 NULL ALL NULL NULL NULL NULL # # NULL +3 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL # # Using where +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #3 was resolved in SELECT #2 +Note 1003 /* select#1 */ select `test`.`v1`.`a` AS `a` from `test`.`v1` +explain SELECT a, b, (SELECT COUNT(*) FROM t1 AS t2 WHERE a=t1.a) AS s +FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL # # NULL +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL # # Using where +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,(/* select#2 */ select count(0) from `test`.`t1` `t2` where (`t2`.`a` = `test`.`t1`.`a`)) AS `s` from `test`.`t1` +DROP VIEW v1; +CREATE VIEW v1 AS SELECT a, b, EXISTS (SELECT COUNT(*) FROM t1 AS t2 WHERE a=t1.a) AS s +FROM t1; +SELECT * FROM v1; +a b s +1 10 1 +2 20 1 +2 21 1 +3 NULL 1 +4 40 1 +4 41 1 +4 42 1 +4 43 1 +4 44 1 +SELECT a FROM v1; +a +1 +2 +2 +3 +4 +4 +4 +4 +4 +SELECT a, b, EXISTS (SELECT COUNT(*) FROM t1 AS t2 WHERE a=t1.a) AS s +FROM t1; +a b s +1 10 1 +2 20 1 +2 21 1 +3 NULL 1 +4 40 1 +4 41 1 +4 42 1 +4 43 1 +4 44 1 +explain SELECT * FROM v1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL # # NULL +2 DERIVED t1 NULL ALL NULL NULL NULL NULL # # NULL +3 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL # # Using where +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #3 was resolved in SELECT #2 +Note 1003 /* select#1 */ select `test`.`v1`.`a` AS `a`,`test`.`v1`.`b` AS `b`,`test`.`v1`.`s` AS `s` from `test`.`v1` +explain SELECT a FROM v1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL # # NULL +2 DERIVED t1 NULL ALL NULL NULL NULL NULL # # NULL +3 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL # # Using where +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #3 was resolved in SELECT #2 +Note 1003 /* select#1 */ select `test`.`v1`.`a` AS `a` from `test`.`v1` +explain SELECT a, b, EXISTS (SELECT COUNT(*) FROM t1 AS t2 WHERE a=t1.a) AS s +FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL # # NULL +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL # # Using where +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,exists(/* select#2 */ select count(0) from `test`.`t1` `t2` where (`t2`.`a` = `test`.`t1`.`a`)) AS `s` from `test`.`t1` +DROP VIEW v1; +CREATE VIEW v1 AS SELECT (SELECT a FROM t2 WHERE a=FLOOR(COUNT(t1.a)/2)) AS s +FROM t1; +SELECT * FROM v1; +s +4 +SELECT (SELECT a FROM t2 WHERE a=FLOOR(COUNT(t1.a)/2)) AS s +FROM t1; +s +4 +explain SELECT * FROM v1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL system NULL NULL NULL NULL # # NULL +2 DERIVED t1 NULL ALL NULL NULL NULL NULL # # NULL +3 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL # # Using where +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #3 was resolved in SELECT #2 +Note 1003 /* select#1 */ select '4' AS `s` from dual +explain SELECT (SELECT a FROM t2 WHERE a=FLOOR(COUNT(t1.a)/2)) AS s +FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL # # NULL +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL # # Using where +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select (/* select#2 */ select `test`.`t2`.`a` from `test`.`t2` where (`test`.`t2`.`a` = floor((count(`test`.`t1`.`a`) / 2)))) AS `s` from `test`.`t1` +DROP VIEW v1; +CREATE VIEW v1 AS SELECT COUNT(*) AS a, (SELECT a FROM t2 WHERE a=FLOOR(COUNT(t1.a)/2)) AS s +FROM t1; +SELECT * FROM v1; +a s +9 4 +SELECT a FROM v1; +a +9 +SELECT COUNT(*) AS a, (SELECT a FROM t2 WHERE a=FLOOR(COUNT(t1.a)/2)) AS s +FROM t1; +a s +9 4 +explain SELECT * FROM v1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL system NULL NULL NULL NULL # # NULL +2 DERIVED t1 NULL ALL NULL NULL NULL NULL # # NULL +3 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL # # Using where +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #3 was resolved in SELECT #2 +Note 1003 /* select#1 */ select '9' AS `a`,'4' AS `s` from dual +explain SELECT a FROM v1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL system NULL NULL NULL NULL # # NULL +2 DERIVED t1 NULL ALL NULL NULL NULL NULL # # NULL +3 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL # # Using where +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #3 was resolved in SELECT #2 +Note 1003 /* select#1 */ select '9' AS `a` from dual +explain SELECT COUNT(*) AS a, (SELECT a FROM t2 WHERE a=FLOOR(COUNT(t1.a)/2)) AS s +FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL # # NULL +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL # # Using where +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select count(0) AS `a`,(/* select#2 */ select `test`.`t2`.`a` from `test`.`t2` where (`test`.`t2`.`a` = floor((count(`test`.`t1`.`a`) / 2)))) AS `s` from `test`.`t1` +DROP VIEW v1; +CREATE VIEW v1 AS SELECT a IN (SELECT a FROM t2 WHERE a=FLOOR(COUNT(t1.a)/2)) AS s +FROM t1; +SELECT * FROM v1; +s +0 +SELECT a IN (SELECT a FROM t2 WHERE a=FLOOR(COUNT(t1.a)/2)) AS s +FROM t1; +s +0 +explain SELECT * FROM v1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL system NULL NULL NULL NULL # # NULL +2 DERIVED t1 NULL ALL NULL NULL NULL NULL # # NULL +3 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL # # Using where +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #3 was resolved in SELECT #2 +Note 1003 /* select#1 */ select '0' AS `s` from dual +explain SELECT a IN (SELECT a FROM t2 WHERE a=FLOOR(COUNT(t1.a)/2)) AS s +FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL # # NULL +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL # # Using where +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select (`test`.`t1`.`a`,(/* select#2 */ select `test`.`t2`.`a` from `test`.`t2` where (`test`.`t2`.`a` = floor((count(`test`.`t1`.`a`) / 2))) having (outer_field_is_not_null, ((`test`.`t1`.`a`) = (`test`.`t2`.`a`)), true))) AS `s` from `test`.`t1` +DROP VIEW v1; +CREATE VIEW v1 AS SELECT COUNT(*) AS a, a IN (SELECT a FROM t2 WHERE a=FLOOR(COUNT(t1.a)/2)) AS s +FROM t1; +SELECT * FROM v1; +a s +9 0 +SELECT a FROM v1; +a +9 +SELECT COUNT(*) AS a, a IN (SELECT a FROM t2 WHERE a=FLOOR(COUNT(t1.a)/2)) AS s +FROM t1; +a s +9 0 +explain SELECT * FROM v1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL system NULL NULL NULL NULL # # NULL +2 DERIVED t1 NULL ALL NULL NULL NULL NULL # # NULL +3 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL # # Using where +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #3 was resolved in SELECT #2 +Note 1003 /* select#1 */ select '9' AS `a`,'0' AS `s` from dual +explain SELECT a FROM v1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL system NULL NULL NULL NULL # # NULL +2 DERIVED t1 NULL ALL NULL NULL NULL NULL # # NULL +3 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL # # Using where +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #3 was resolved in SELECT #2 +Note 1003 /* select#1 */ select '9' AS `a` from dual +explain SELECT COUNT(*) AS a, a IN (SELECT a FROM t2 WHERE a=FLOOR(COUNT(t1.a)/2)) AS s +FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL # # NULL +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL # # Using where +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select count(0) AS `a`,(`test`.`t1`.`a`,(/* select#2 */ select `test`.`t2`.`a` from `test`.`t2` where (`test`.`t2`.`a` = floor((count(`test`.`t1`.`a`) / 2))) having (outer_field_is_not_null, ((`test`.`t1`.`a`) = (`test`.`t2`.`a`)), true))) AS `s` from `test`.`t1` +DROP VIEW v1; +CREATE VIEW v1 AS SELECT a, COUNT(*) AS c, (SELECT a FROM t2 WHERE a=COUNT(t1.a)) AS s +FROM t1 +GROUP BY a; +SELECT * FROM v1; +a c s +1 1 1 +2 2 2 +3 1 1 +4 5 5 +SELECT a FROM v1; +a +1 +2 +3 +4 +SELECT a, COUNT(*) AS c, (SELECT a FROM t2 WHERE a=COUNT(t1.a)) AS s +FROM t1 +GROUP BY a; +a c s +1 1 1 +2 2 2 +3 1 1 +4 5 5 +explain SELECT * FROM v1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL # # NULL +2 DERIVED t1 NULL ALL NULL NULL NULL NULL # # Using temporary +3 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL # # Using where +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #3 was resolved in SELECT #2 +Note 1003 /* select#1 */ select `test`.`v1`.`a` AS `a`,`test`.`v1`.`c` AS `c`,`test`.`v1`.`s` AS `s` from `test`.`v1` +explain SELECT a FROM v1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL # # NULL +2 DERIVED t1 NULL ALL NULL NULL NULL NULL # # Using temporary +3 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL # # Using where +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #3 was resolved in SELECT #2 +Note 1003 /* select#1 */ select `test`.`v1`.`a` AS `a` from `test`.`v1` +explain SELECT a, COUNT(*) AS c, (SELECT a FROM t2 WHERE a=COUNT(t1.a)) AS s +FROM t1 +GROUP BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL # # Using temporary +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL # # Using where +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,count(0) AS `c`,(/* select#2 */ select `test`.`t2`.`a` from `test`.`t2` where (`test`.`t2`.`a` = count(`test`.`t1`.`a`))) AS `s` from `test`.`t1` group by `test`.`t1`.`a` +DROP VIEW v1; +CREATE VIEW v1 AS SELECT a, COUNT(*) AS c, a IN (SELECT a FROM t2 WHERE a=COUNT(t1.a)) AS s +FROM t1 +GROUP BY a; +SELECT * FROM v1; +a c s +1 1 1 +2 2 1 +3 1 0 +4 5 0 +SELECT a FROM v1; +a +1 +2 +3 +4 +SELECT a, COUNT(*) AS c, a IN (SELECT a FROM t2 WHERE a=COUNT(t1.a)) AS s +FROM t1 +GROUP BY a; +a c s +1 1 1 +2 2 1 +3 1 0 +4 5 0 +explain SELECT * FROM v1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL # # NULL +2 DERIVED t1 NULL ALL NULL NULL NULL NULL # # Using temporary +3 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL # # Using where +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #3 was resolved in SELECT #2 +Note 1003 /* select#1 */ select `test`.`v1`.`a` AS `a`,`test`.`v1`.`c` AS `c`,`test`.`v1`.`s` AS `s` from `test`.`v1` +explain SELECT a FROM v1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL # # NULL +2 DERIVED t1 NULL ALL NULL NULL NULL NULL # # Using temporary +3 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL # # Using where +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #3 was resolved in SELECT #2 +Note 1003 /* select#1 */ select `test`.`v1`.`a` AS `a` from `test`.`v1` +explain SELECT a, COUNT(*) AS c, a IN (SELECT a FROM t2 WHERE a=COUNT(t1.a)) AS s +FROM t1 +GROUP BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL # # Using temporary +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL # # Using where +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,count(0) AS `c`,(`test`.`t1`.`a`,(/* select#2 */ select `test`.`t2`.`a` from `test`.`t2` where (`test`.`t2`.`a` = count(`test`.`t1`.`a`)) having (outer_field_is_not_null, ((`test`.`t1`.`a`) = (`test`.`t2`.`a`)), true))) AS `s` from `test`.`t1` group by `test`.`t1`.`a` +DROP VIEW v1; +DROP TABLE t1, t2; +# +# Bug#19789450 Assert fail in add_key_field +# +CREATE TABLE t1 ( +pk int NOT NULL, +col_date_key date DEFAULT NULL, +PRIMARY KEY (pk), +KEY col_date_key (col_date_key) +) ; +CREATE TABLE t2 ( +pk int NOT NULL, +col_time_key time DEFAULT NULL, +col_datetime_key datetime DEFAULT NULL, +PRIMARY KEY (pk), +KEY col_time_key (col_time_key), +KEY col_datetime_key (col_datetime_key) +); +CREATE ALGORITHM=MERGE VIEW v1 AS +SELECT col_date_key +FROM t1 WHERE (pk, pk, col_date_key) IN +(SELECT col_datetime_key, +col_time_key, +col_time_key +FROM t2 +WHERE pk <= 7); +SELECT * FROM v1; +col_date_key +DROP VIEW v1; +DROP TABLE t1, t2; +# +# BUG#14117018 - MYSQL SERVER CREATES INVALID VIEW DEFINITION +# BUG#18405221 - SHOW CREATE VIEW OUTPUT INCCORRECT +# +CREATE VIEW v1 AS (SELECT '' FROM DUAL); +CREATE VIEW v2 AS (SELECT 'BUG#14117018' AS col1 FROM DUAL) UNION ALL +(SELECT '' FROM DUAL); +CREATE VIEW v3 AS (SELECT 'BUG#14117018' AS col1 FROM DUAL) UNION ALL +(SELECT '' FROM DUAL) UNION ALL +(SELECT '' FROM DUAL); +CREATE VIEW v4 AS (SELECT 'BUG#14117018' AS col1 FROM DUAL) UNION ALL +(SELECT '' AS col2 FROM DUAL) UNION ALL +(SELECT '' FROM DUAL); +# Name for the column in select1 is set properly with or +# without this fix. +SHOW CREATE VIEW v1; +View Create View character_set_client collation_connection +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select '' AS `Name_exp_1` utf8mb4 utf8mb4_0900_ai_ci +# Name for the column in select2 is set with this fix. +# Without this fix, name would not have set for the +# columns in select2. +SHOW CREATE VIEW v2; +View Create View character_set_client collation_connection +v2 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v2` AS select 'BUG#14117018' AS `col1` union all select '' AS `Name_exp_2` utf8mb4 utf8mb4_0900_ai_ci +# Name for the field item in select2 & select3 is set with this fix. +# Without this fix, name would not have set for the +# columns in select2 & select3. +SHOW CREATE VIEW v3; +View Create View character_set_client collation_connection +v3 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v3` AS select 'BUG#14117018' AS `col1` union all select '' AS `Name_exp_2` union all select '' AS `Name_exp_3` utf8mb4 utf8mb4_0900_ai_ci +# Name for the field item in select3 is set with this fix. +# Without this fix, name would not have set for the +# columns in select3. +SHOW CREATE VIEW v4; +View Create View character_set_client collation_connection +v4 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v4` AS select 'BUG#14117018' AS `col1` union all select '' AS `col2` union all select '' AS `Name_exp_3` utf8mb4 utf8mb4_0900_ai_ci +DROP VIEW v1, v2, v3, v4; +# Bug#20087932 Assert fail in Join_tab_compare_straight::operator() +CREATE TABLE t1 ( +pk int NOT NULL, +col_varchar_key varchar(1) NOT NULL, +PRIMARY KEY (pk) +); +CREATE TABLE t2 ( +pk int NOT NULL, +col_varchar_key varchar(1) NOT NULL, +col_varchar_nokey varchar(1) NOT NULL, +PRIMARY KEY (pk) +); +CREATE TABLE t3 ( +pk int NOT NULL, +col_int_key int NOT NULL, +col_varchar_nokey varchar(1) NOT NULL, +PRIMARY KEY (pk) +); +CREATE VIEW v2 AS SELECT * FROM t2; +ANALYZE TABLE t1,t2,t3; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +explain SELECT STRAIGHT_JOIN alias1.pk +FROM t2 AS alias1 +RIGHT JOIN +(SELECT sq1_alias2.* +FROM t1 AS sq1_alias1 +RIGHT OUTER JOIN +v2 AS sq1_alias2 +ON sq1_alias2.col_varchar_key = sq1_alias1.col_varchar_key AND +sq1_alias2.col_varchar_nokey IN +(SELECT c_sq1_alias1.col_varchar_nokey AS c_sq1_field1 +FROM t3 AS c_sq1_alias1 +WHERE c_sq1_alias1.col_int_key <> c_sq1_alias1.col_int_key +) +) AS alias2 +ON alias2.col_varchar_key = alias1.col_varchar_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL # # NULL +1 PRIMARY alias1 NULL ALL NULL NULL NULL NULL # # Using where; Using join buffer (hash join) +2 DERIVED t2 NULL ALL NULL NULL NULL NULL # # NULL +2 DERIVED sq1_alias1 NULL ALL NULL NULL NULL NULL # # Using where +2 DERIVED c_sq1_alias1 NULL ALL NULL NULL NULL NULL # # Using where; FirstMatch(sq1_alias1) +Warnings: +Note 1003 /* select#1 */ select straight_join `test`.`alias1`.`pk` AS `pk` from (/* select#2 */ select `test`.`t2`.`pk` AS `pk`,`test`.`t2`.`col_varchar_key` AS `col_varchar_key`,`test`.`t2`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t2` left join (`test`.`t1` `sq1_alias1` semi join (`test`.`t3` `c_sq1_alias1`)) on(((`test`.`c_sq1_alias1`.`col_varchar_nokey` = `test`.`t2`.`col_varchar_nokey`) and (`test`.`sq1_alias1`.`col_varchar_key` = `test`.`t2`.`col_varchar_key`) and (`test`.`c_sq1_alias1`.`col_int_key` <> `test`.`c_sq1_alias1`.`col_int_key`))) where true) `alias2` left join `test`.`t2` `alias1` on((`test`.`alias1`.`col_varchar_key` = `alias2`.`col_varchar_key`)) where true +SELECT STRAIGHT_JOIN alias1.pk +FROM t2 AS alias1 +RIGHT JOIN +(SELECT sq1_alias2.* +FROM t1 AS sq1_alias1 +RIGHT OUTER JOIN +v2 AS sq1_alias2 +ON sq1_alias2.col_varchar_key = sq1_alias1.col_varchar_key AND +sq1_alias2.col_varchar_nokey IN +(SELECT c_sq1_alias1.col_varchar_nokey AS c_sq1_field1 +FROM t3 AS c_sq1_alias1 +WHERE c_sq1_alias1.col_int_key <> c_sq1_alias1.col_int_key +) +) AS alias2 +ON alias2.col_varchar_key = alias1.col_varchar_key; +pk +DROP VIEW v2; +DROP TABLE t1, t2, t3; +CREATE TABLE t0(x INTEGER); +INSERT INTO t0 VALUES(0); +CREATE TABLE t1(a1 INTEGER PRIMARY KEY, b1 INTEGER); +CREATE TABLE t2(a2 INTEGER PRIMARY KEY, b2 INTEGER); +CREATE VIEW v0 AS SELECT DISTINCT x FROM t0; +CREATE VIEW vmat1 AS SELECT DISTINCT * FROM t1; +CREATE VIEW vmat2 AS SELECT DISTINCT * FROM t2; +CREATE VIEW vtt AS +SELECT * FROM t1 JOIN t2 ON t1.a1=t2.a2; +CREATE VIEW vtr AS +SELECT * FROM t1 JOIN vmat2 AS dt2 ON t1.a1=dt2.a2; +CREATE VIEW vtrd AS +SELECT * FROM t1 JOIN (SELECT DISTINCT * FROM t2) AS dt2 ON t1.a1=dt2.a2; +CREATE VIEW vrt AS +SELECT * FROM vmat1 AS dt1 JOIN t2 ON dt1.a1=t2.a2; +CREATE VIEW vrtd AS +SELECT * FROM (SELECT DISTINCT * FROM t1) AS dt1 JOIN t2 ON dt1.a1=t2.a2; +CREATE VIEW vrr AS +SELECT * FROM vmat1 AS dt1 JOIN vmat2 AS dt2 ON dt1.a1=dt2.a2; +CREATE VIEW vrrd AS +SELECT * FROM (SELECT DISTINCT * FROM t1) AS dt1 JOIN +(SELECT DISTINCT * FROM t2) AS dt2 ON dt1.a1=dt2.a2; +INSERT INTO vtt(a1,b1) VALUES (1,100); +INSERT INTO vtt(a2,b2) VALUES (1,100); +INSERT INTO vtr(a1,b1) VALUES (2,100); +ERROR HY000: The target table vtr of the INSERT is not insertable-into +INSERT INTO vtrd(a1,b1) VALUES (3,100); +ERROR HY000: The target table vtrd of the INSERT is not insertable-into +INSERT INTO vtr(a2,b2) VALUES (2,100); +ERROR HY000: The target table vtr of the INSERT is not insertable-into +INSERT INTO vtrd(a2,b2) VALUES (3,100); +ERROR HY000: The target table vtrd of the INSERT is not insertable-into +INSERT INTO vrt(a1,b1) VALUES (4,100); +ERROR HY000: The target table vrt of the INSERT is not insertable-into +INSERT INTO vrtd(a1,b1) VALUES (5,100); +ERROR HY000: The target table vrtd of the INSERT is not insertable-into +INSERT INTO vrt(a2,b2) VALUES (4,100); +ERROR HY000: The target table vrt of the INSERT is not insertable-into +INSERT INTO vrtd(a2,b2) VALUES (5,100); +ERROR HY000: The target table vrtd of the INSERT is not insertable-into +INSERT INTO vrr(a1,b1) VALUES (6,100); +ERROR HY000: The target table vrr of the INSERT is not insertable-into +INSERT INTO vrrd(a1,b1) VALUES (7,100); +ERROR HY000: The target table vrrd of the INSERT is not insertable-into +INSERT INTO vrr(a2,b2) VALUES (6,100); +ERROR HY000: The target table vrr of the INSERT is not insertable-into +INSERT INTO vrrd(a2,b2) VALUES (7,100); +ERROR HY000: The target table vrrd of the INSERT is not insertable-into +SELECT * FROM vtt; +a1 b1 a2 b2 +1 100 1 100 +DELETE FROM t1; +DELETE FROM t2; +INSERT INTO vtt(a1,b1) SELECT 1,100; +INSERT INTO vtt(a2,b2) SELECT 1,100; +INSERT INTO vtr(a1,b1) SELECT 2,100; +ERROR HY000: The target table vtr of the INSERT is not insertable-into +INSERT INTO vtrd(a1,b1) SELECT 3,100; +ERROR HY000: The target table vtrd of the INSERT is not insertable-into +INSERT INTO vtr(a2,b2) SELECT 2,100; +ERROR HY000: The target table vtr of the INSERT is not insertable-into +INSERT INTO vtrd(a2,b2) SELECT 3,100; +ERROR HY000: The target table vtrd of the INSERT is not insertable-into +INSERT INTO vrt(a1,b1) SELECT 4,100; +ERROR HY000: The target table vrt of the INSERT is not insertable-into +INSERT INTO vrtd(a1,b1) SELECT 5,100; +ERROR HY000: The target table vrtd of the INSERT is not insertable-into +INSERT INTO vrt(a2,b2) SELECT 4,100; +ERROR HY000: The target table vrt of the INSERT is not insertable-into +INSERT INTO vrtd(a2,b2) SELECT 5,100; +ERROR HY000: The target table vrtd of the INSERT is not insertable-into +INSERT INTO vrr(a1,b1) SELECT 6,100; +ERROR HY000: The target table vrr of the INSERT is not insertable-into +INSERT INTO vrrd(a1,b1) SELECT 7,100; +ERROR HY000: The target table vrrd of the INSERT is not insertable-into +INSERT INTO vrr(a2,b2) SELECT 6,100; +ERROR HY000: The target table vrr of the INSERT is not insertable-into +INSERT INTO vrrd(a2,b2) SELECT 7,100; +ERROR HY000: The target table vrrd of the INSERT is not insertable-into +SELECT * FROM vtt; +a1 b1 a2 b2 +1 100 1 100 +DELETE FROM t1; +DELETE FROM t2; +INSERT INTO t1 VALUES +(1,100), (2,100), (3,100), (4,100), (5,100), +(6,100), (7,100), (8,100), (9,100), (10,100), +(11,100), (12,100), (13,100), (14,100); +INSERT INTO t2 VALUES +(1,100), (2,100), (3,100), (4,100), (5,100), +(6,100), (7,100), (8,100), (9,100), (10,100), +(11,100), (12,100), (13,100), (14,100); +DELETE FROM vtt WHERE a1=1; +ERROR HY000: Can not delete from join view 'test.vtt' +DELETE FROM vtr WHERE a1=2; +ERROR HY000: Can not delete from join view 'test.vtr' +DELETE FROM vtrd WHERE a1=3; +ERROR HY000: Can not delete from join view 'test.vtrd' +DELETE FROM vrt WHERE a1=4; +ERROR HY000: Can not delete from join view 'test.vrt' +DELETE FROM vrtd WHERE a1=5; +ERROR HY000: Can not delete from join view 'test.vrtd' +DELETE FROM vrr WHERE a1=6; +ERROR HY000: The target table vrr of the DELETE is not updatable +DELETE FROM vrrd WHERE a1=7; +ERROR HY000: The target table vrrd of the DELETE is not updatable +DELETE vtt FROM vtt WHERE a1=8; +ERROR HY000: Can not delete from join view 'test.vtt' +DELETE vtr FROM vtr WHERE a1=9; +ERROR HY000: Can not delete from join view 'test.vtr' +DELETE vtrd FROM vtrd WHERE a1=10; +ERROR HY000: Can not delete from join view 'test.vtrd' +DELETE vrt FROM vrt WHERE a1=11; +ERROR HY000: Can not delete from join view 'test.vrt' +DELETE vrtd FROM vrtd WHERE a1=12; +ERROR HY000: Can not delete from join view 'test.vrtd' +DELETE vrr FROM vrr WHERE a1=13; +ERROR HY000: The target table vrr of the DELETE is not updatable +DELETE vrrd FROM vrrd WHERE a1=14; +ERROR HY000: The target table vrrd of the DELETE is not updatable +SELECT * FROM vtt; +a1 b1 a2 b2 +1 100 1 100 +2 100 2 100 +3 100 3 100 +4 100 4 100 +5 100 5 100 +6 100 6 100 +7 100 7 100 +8 100 8 100 +9 100 9 100 +10 100 10 100 +11 100 11 100 +12 100 12 100 +13 100 13 100 +14 100 14 100 +DELETE FROM t1; +DELETE FROM t2; +INSERT INTO t1 VALUES (1,100); +INSERT INTO t2 VALUES (1,100); +UPDATE vtt SET b1=b1+1 WHERE a1=1; +UPDATE vtt SET b2=b2+1 WHERE a2=1; +UPDATE vtr SET b1=b1+1 WHERE a1=1; +UPDATE vtrd SET b1=b1+1 WHERE a1=1; +UPDATE vtr SET b2=b2+1 WHERE a2=1; +ERROR HY000: The target table vtr of the UPDATE is not updatable +UPDATE vtrd SET b2=b2+1 WHERE a2=1; +ERROR HY000: The target table vtrd of the UPDATE is not updatable +UPDATE vrt SET b1=b1+1 WHERE a1=1; +ERROR HY000: The target table vrt of the UPDATE is not updatable +UPDATE vrtd SET b1=b1+1 WHERE a1=1; +ERROR HY000: The target table vrtd of the UPDATE is not updatable +UPDATE vrt SET b2=b2+1 WHERE a2=1; +UPDATE vrtd SET b2=b2+1 WHERE a2=1; +UPDATE vrr SET b1=b1+1 WHERE a1=1; +ERROR HY000: The target table vrr of the UPDATE is not updatable +UPDATE vrrd SET b1=b1+1 WHERE a1=1; +ERROR HY000: The target table vrrd of the UPDATE is not updatable +UPDATE vrr SET b2=b2+1 WHERE a2=1; +ERROR HY000: The target table vrr of the UPDATE is not updatable +UPDATE vrrd SET b2=b2+1 WHERE a2=1; +ERROR HY000: The target table vrrd of the UPDATE is not updatable +UPDATE vtt, v0 AS dt SET b1=b1+1 WHERE a1=1; +UPDATE vtt, v0 SET b2=b2+1 WHERE a2=1; +UPDATE vtr, v0 SET b1=b1+1 WHERE a1=1; +UPDATE vtrd, v0 SET b1=b1+1 WHERE a1=1; +UPDATE vtr, v0 SET b2=b2+1 WHERE a2=1; +ERROR HY000: The target table vtr of the UPDATE is not updatable +UPDATE vtrd, v0 SET b2=b2+1 WHERE a2=1; +ERROR HY000: The target table vtrd of the UPDATE is not updatable +UPDATE vrt, v0 SET b1=b1+1 WHERE a1=1; +ERROR HY000: The target table vrt of the UPDATE is not updatable +UPDATE vrtd, v0 SET b1=b1+1 WHERE a1=1; +ERROR HY000: The target table vrtd of the UPDATE is not updatable +UPDATE vrt, v0 SET b2=b2+1 WHERE a2=1; +UPDATE vrtd, v0 SET b2=b2+1 WHERE a2=1; +UPDATE vrr, v0 SET b1=b1+1 WHERE a1=1; +ERROR HY000: The target table vrr of the UPDATE is not updatable +UPDATE vrrd, v0 SET b1=b1+1 WHERE a1=1; +ERROR HY000: The target table vrrd of the UPDATE is not updatable +UPDATE vrr, v0 SET b2=b2+1 WHERE a2=1; +ERROR HY000: The target table vrr of the UPDATE is not updatable +UPDATE vrrd, v0 SET b2=b2+1 WHERE a2=1; +ERROR HY000: The target table vrrd of the UPDATE is not updatable +SELECT * FROM vtt; +a1 b1 a2 b2 +1 106 1 106 +DROP VIEW v0, vtt, vtr, vrt, vrr, vmat1, vmat2; +DROP VIEW vtrd, vrtd, vrrd; +DROP TABLE t0, t1, t2; +# +# Bug#20407961 VIEW'S CHECK OPTION SOMETIMES NOT HONOURED IF INCLUDED IN A TOP VIEW +# +create table t1 (a varchar(100)); +# n/c/l letter suffix means: no/cascaded/local check option +create view v1n as select * from t1 where a like '%v1n%'; +create view v2c as select * from t1 where a like '%v2c%' + with check option; +show create view v2c; +View Create View character_set_client collation_connection +v2c CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v2c` AS select `t1`.`a` AS `a` from `t1` where (`t1`.`a` like '%v2c%') WITH CASCADED CHECK OPTION utf8mb4 utf8mb4_0900_ai_ci +create view v3l as select * from t1 where a like '%v3l%' + with local check option; +show create view v3l; +View Create View character_set_client collation_connection +v3l CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v3l` AS select `t1`.`a` AS `a` from `t1` where (`t1`.`a` like '%v3l%') WITH LOCAL CHECK OPTION utf8mb4 utf8mb4_0900_ai_ci +# The basic, single-view feature works: +insert into t1 values(''); +insert into v1n values(''); +insert into v2c values(''); +ERROR HY000: CHECK OPTION failed 'test.v2c' +insert into v2c values('v2c'); +insert into v3l values(''); +ERROR HY000: CHECK OPTION failed 'test.v3l' +insert into v3l values('v3l'); +# We also test UPDATE of the successfully inserted row +update v1n set a='_'; +# if this update to v2c was allowed, it would be produce a row in t1 +# not matching v2c's filter, which is against the goal of CHECK +# OPTION. +update v2c set a=''; +ERROR HY000: CHECK OPTION failed 'test.v2c' +update v3l set a=''; +ERROR HY000: CHECK OPTION failed 'test.v3l' +# Top view without no CHECK OPTION, still CHECK OPTION conditions +# of underlying views are checked. +create view v4n as select * from v2c where a like '%v4n%'; +create view v5n as select * from v3l where a like '%v5n%'; +# The view's nesting structure is: +# v4n -> v2c -> t1 +# We present the query with needed tags, verify that it passes, +# then we take each tag away and verify that it fails. +insert into v4n values('v2c'); +insert into v4n values(''); +ERROR HY000: CHECK OPTION failed 'test.v4n' +# To check UPDATE on v4n, we need to update a row originally +# visible in v4n, so we create it: +insert into v4n values('v4n v2c'); +# This row can legally disappear from v4n: +update v4n set a='v2c'; +insert into v4n values('v4n v2c'); +# But this row cannot disappear from v2c: +update v4n set a='v4n'; +ERROR HY000: CHECK OPTION failed 'test.v4n' +# Lest we delete it: +delete from v4n; +# v5n -> v3l -> t1 +insert into v5n values('v3l'); +insert into v5n values(''); +ERROR HY000: CHECK OPTION failed 'test.v5n' +# Top view with LOCAL CHECK OPTION, still CHECK OPTION conditions +# of underlying views are checked. +create view v4l as select * from v2c where a like '%v4l%' + with local check option; +create view v5l as select * from v3l where a like '%v5l%' + with local check option; +# v4l -> v2c -> t1 +insert into v4l values('v4l v2c'); +insert into v4l values('v2c'); +ERROR HY000: CHECK OPTION failed 'test.v4l' +update v4l set a='v2c'; +ERROR HY000: CHECK OPTION failed 'test.v4l' +insert into v4l values('v4l'); +ERROR HY000: CHECK OPTION failed 'test.v4l' +update v4l set a='v4l'; +ERROR HY000: CHECK OPTION failed 'test.v4l' +# v5l -> v3l -> t1 +insert into v5l values('v5l v3l'); +insert into v5l values('v3l'); +ERROR HY000: CHECK OPTION failed 'test.v5l' +update v5l set a='v3l'; +ERROR HY000: CHECK OPTION failed 'test.v5l' +insert into v5l values('v5l'); +ERROR HY000: CHECK OPTION failed 'test.v5l' +update v5l set a='v5l'; +ERROR HY000: CHECK OPTION failed 'test.v5l' +# CASCADED makes all filtering conditions a requirement +create view v6c as select * from v5n where a like '%v6c%' + with cascaded check option; +# v6c -> v5n -> v3l -> t1 +insert into v6c values('v6c v5n v3l'); +insert into v6c values('v5n v3l'); +ERROR HY000: CHECK OPTION failed 'test.v6c' +update v6c set a='v5n v3l'; +ERROR HY000: CHECK OPTION failed 'test.v6c' +insert into v6c values('v6c v3l'); +ERROR HY000: CHECK OPTION failed 'test.v6c' +update v6c set a='v6c v3l'; +ERROR HY000: CHECK OPTION failed 'test.v6c' +insert into v6c values('v6c v5n'); +ERROR HY000: CHECK OPTION failed 'test.v6c' +update v6c set a='v6c v5n'; +ERROR HY000: CHECK OPTION failed 'test.v6c' +# Also true if top view has no check option: +create view v7n as select * from v6c where a like '%v7n%'; +# v7n -> v6c -> v5n -> v3l -> t1 +insert into v7n values('v6c v5n v3l'); +insert into v7n values('v5n v3l'); +ERROR HY000: CHECK OPTION failed 'test.v7n' +insert into v7n values('v6c v3l'); +ERROR HY000: CHECK OPTION failed 'test.v7n' +insert into v7n values('v6c v5n'); +ERROR HY000: CHECK OPTION failed 'test.v7n' +# Make a visible row to update: +insert into v7n values('v7n v6c v5n v3l'); +update v7n set a='v7n v5n v3l'; +ERROR HY000: CHECK OPTION failed 'test.v7n' +update v7n set a='v7n v6c v3l'; +ERROR HY000: CHECK OPTION failed 'test.v7n' +update v7n set a='v7n v6c v5nà'; +ERROR HY000: CHECK OPTION failed 'test.v7n' +# Also true if top view has LOCAL: +create view v8l as select * from v7n where a like '%v8l%' + with local check option; +# v8l -> v7n -> v6c -> v5n -> v3l -> t1 +insert into v8l values('v8l v6c v5n v3l'); +insert into v8l values('v6c v5n v3l'); +ERROR HY000: CHECK OPTION failed 'test.v8l' +insert into v8l values('v8l v5n v3l'); +ERROR HY000: CHECK OPTION failed 'test.v8l' +insert into v8l values('v8l v6c v3l'); +ERROR HY000: CHECK OPTION failed 'test.v8l' +insert into v8l values('v8l v6c v5n'); +ERROR HY000: CHECK OPTION failed 'test.v8l' +# Make a visible row (=> satisfy v7n's WHERE clause): +insert into v8l values('v8l v7n v6c v5n v3l'); +update v8l set a='v7n v6c v5n v3l'; +ERROR HY000: CHECK OPTION failed 'test.v8l' +update v8l set a='v8l v7n v5n v3l'; +ERROR HY000: CHECK OPTION failed 'test.v8l' +update v8l set a='v8l v7n v6c v3l'; +ERROR HY000: CHECK OPTION failed 'test.v8l' +update v8l set a='v8l v7n v6c v5n'; +ERROR HY000: CHECK OPTION failed 'test.v8l' +drop view v1n,v2c,v3l,v4n,v5n,v4l,v5l,v6c,v7n,v8l; +drop table t1; +# Bug#20982756 Crash in Table_list::fetch_number_of_rows +CREATE TABLE t1(a INTEGER) engine=innodb; +CREATE VIEW v3 AS SELECT 1 FROM t1; +CREATE VIEW v2 AS SELECT 1 FROM v3 LEFT JOIN t1 ON 1; +PREPARE s FROM "set @a:=(SELECT 1 FROM t1,v2);"; +EXECUTE s; +EXECUTE s; +DROP VIEW v2,v3; +DROP TABLE t1; +# Bug#21097485 *insert_table_ref && (*insert_table_ref)->is_insertable +CREATE TABLE t1 (r INTEGER) engine=innodb; +CREATE VIEW v1 AS +SELECT 1 AS z from t1; +INSERT INTO v1(z) VALUES(1); +ERROR HY000: Column 'z' is not updatable +DROP VIEW v1; +DROP TABLE t1; +# Bug#21277074: crash (segfault) in THD::change_item_tree on exec of prep +CREATE TABLE t (i INTEGER); +PREPARE s1 FROM +"SELECT (SELECT MAX(i)) AS field1 + FROM (SELECT * FROM t) AS table1" +; +EXECUTE s1; +field1 +NULL +CREATE VIEW v AS SELECT * FROM t; +PREPARE s2 FROM +"SELECT (SELECT MAX(i)) AS field1 + FROM v AS table1" +; +EXECUTE s2; +field1 +NULL +DEALLOCATE PREPARE s1; +DEALLOCATE PREPARE s2; +DROP VIEW v; +DROP TABLE t; +# +# BUG#19886430: VIEW CREATION WITH NAMED COLUMNS, OVER UNION, +# IS REJECTED +# Without the patch, reports an error. +CREATE VIEW v1 (fld1, fld2) AS +SELECT 1 AS a, 2 AS b +UNION ALL +SELECT 1 AS a, 1 AS a; +# The column names are explicitly specified and not duplicates, hence +# succeeds. +CREATE VIEW v2 (fld1, fld2) AS +SELECT 1 AS a, 2 AS a +UNION ALL +SELECT 1 AS a, 1 AS a; +# The column name in the first SELECT are not duplicates, hence succeeds. +CREATE VIEW v3 AS +SELECT 1 AS a, 2 AS b +UNION ALL +SELECT 1 AS a, 1 AS a; +# Should report an error, since the explicitly specified column names are +# duplicates. +CREATE VIEW v4 (fld1, fld1) AS +SELECT 1 AS a, 2 AS b +UNION ALL +SELECT 1 AS a, 1 AS a; +ERROR 42S21: Duplicate column name 'fld1' +# Should report an error, since duplicate column name is specified in the +# First SELECT. +CREATE VIEW v4 AS +SELECT 1 AS a, 2 AS a +UNION ALL +SELECT 1 AS a, 1 AS a; +ERROR 42S21: Duplicate column name 'a' +# Cleanup +DROP VIEW v1, v2, v3; +# +# Bug #22108567 ASSERTION `TABLE != 0' FAILED +# +PREPARE X FROM 'CREATE VIEW bug22108567_v1 AS SELECT 1 FROM (SELECT 1) AS D1'; +EXECUTE X; +DROP VIEW bug22108567_v1; +# +# BUG#21877062: MIN/MAX IN VIEW ON TIMESTAMDIFF IN VIEW CONFUSES +# OPTIMIZER TO THROW SYNTAX ERROR +# +CREATE TABLE t(ts1 DATETIME(6), ts2 DATETIME(6)); +INSERT INTO t VALUES('2016-01-11 09:15:25','2016-01-11 21:15:25'); +CREATE VIEW v1 AS +SELECT TIMESTAMPDIFF(MICROSECOND, ts1, ts2) duration FROM t; +# Without the patch, a syntax error is reported. +SELECT * FROM v1; +duration +43200000000 +CREATE VIEW v2 AS +SELECT MIN(duration) AS dmin, MAX(duration) AS dmax FROM v1; +DROP VIEW v1, v2; +DROP TABLE t; +# +# Bug24786327 SIG 11 IN __STPCPY_SSE2_UNALIGNED FROM MY_STPCPY() IN SQL/AUTH/SQL_AUTH_CACHE.CC +# +CREATE TABLE t1_base_N3 (pk INT, col_int INT); +CREATE VIEW t1_view_N3 AS SELECT * FROM t1_base_N3 WHERE `pk` BETWEEN 1 AND +2; +CREATE VIEW t1_view_N4 AS SELECT * FROM ( SELECT * FROM t1_view_N3 ) AS A; +UPDATE t1_view_N3 AS A JOIN t1_view_N4 B SET A. col_int = 1 , B. col_int = 2; +ERROR HY000: The target table B of the UPDATE is not updatable +DROP VIEW t1_view_N3, t1_view_N4; +DROP TABLE t1_base_N3; +# +# WL#7743: New data dictionary: changes to DDL-related parts of SE API +# +CREATE TABLE t1(a INT); +CREATE VIEW v1 AS SELECT * FROM t1; +RENAME TABLE t1 TO t2, v1 TO v2; +SELECT * FROM information_schema.views WHERE table_schema='test'; +TABLE_CATALOG TABLE_SCHEMA TABLE_NAME VIEW_DEFINITION CHECK_OPTION IS_UPDATABLE DEFINER SECURITY_TYPE CHARACTER_SET_CLIENT COLLATION_CONNECTION +def test v2 select `test`.`t1`.`a` AS `a` from `test`.`t1` NONE YES root@localhost DEFINER utf8mb4 utf8mb4_0900_ai_ci +Warnings: +Warning 1356 View 'test.v2' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +DROP VIEW v2; +DROP TABLE t2; +CREATE TABLE t1(a INT); +CREATE TABLE t2(b INT); +CREATE TABLE t3(a INT); +CREATE TABLE t4(b INT); +CREATE VIEW v1 AS SELECT * FROM t1, t2; +DROP TABLE t1, t2; +RENAME TABLE t3 TO t1, t4 TO t2; +DROP VIEW v1; +DROP TABLE t1, t2; +# +# BUG#25634576: DATABASE NAME IN SHOW CREATE VIEW +# +CREATE DATABASE db; +CREATE TABLE db.t1(fld1 INT); +CREATE TABLE db.t2(fld2 INT); +CREATE TABLE t1(fld1 INT); +CREATE TABLE t2(fld2 INT); +# With patch, db name is appended only to those tables +# which are not present in the current database. +# Test cases with reference to table within current +# db and outside current db. +CREATE VIEW v1 AS SELECT * FROM t1 UNION SELECT * FROM t2; +SHOW CREATE VIEW v1; +View Create View character_set_client collation_connection +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`fld1` AS `fld1` from `t1` union select `t2`.`fld2` AS `fld2` from `t2` utf8mb4 utf8mb4_0900_ai_ci +CREATE VIEW v2 AS SELECT * FROM t1 UNION SELECT * FROM db.t2; +SHOW CREATE VIEW v2; +View Create View character_set_client collation_connection +v2 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v2` AS select `t1`.`fld1` AS `fld1` from `t1` union select `db`.`t2`.`fld2` AS `fld2` from `db`.`t2` utf8mb4 utf8mb4_0900_ai_ci +CREATE VIEW v3 AS SELECT fld1 FROM t1 UNION SELECT * FROM db.t2; +SHOW CREATE VIEW v3; +View Create View character_set_client collation_connection +v3 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v3` AS select `t1`.`fld1` AS `fld1` from `t1` union select `db`.`t2`.`fld2` AS `fld2` from `db`.`t2` utf8mb4 utf8mb4_0900_ai_ci +CREATE VIEW v4 AS SELECT t1.fld1 FROM t1 UNION SELECT * FROM db.t2; +SHOW CREATE VIEW v4; +View Create View character_set_client collation_connection +v4 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v4` AS select `t1`.`fld1` AS `fld1` from `t1` union select `db`.`t2`.`fld2` AS `fld2` from `db`.`t2` utf8mb4 utf8mb4_0900_ai_ci +CREATE VIEW v5 AS SELECT * FROM db.t1 UNION SELECT * FROM db.t2; +SHOW CREATE VIEW v5; +View Create View character_set_client collation_connection +v5 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v5` AS select `db`.`t1`.`fld1` AS `fld1` from `db`.`t1` union select `db`.`t2`.`fld2` AS `fld2` from `db`.`t2` utf8mb4 utf8mb4_0900_ai_ci +# Test cases with subquery. +CREATE VIEW v6 AS SELECT * FROM t2 WHERE fld2 IN (SELECT fld1 FROM t1); +SHOW CREATE VIEW v6; +View Create View character_set_client collation_connection +v6 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v6` AS select `t2`.`fld2` AS `fld2` from `t2` where `t2`.`fld2` in (select `t1`.`fld1` from `t1`) utf8mb4 utf8mb4_0900_ai_ci +CREATE VIEW v7 AS SELECT * FROM db.t2 WHERE fld2 IN (SELECT fld1 FROM t1); +SHOW CREATE VIEW v7; +View Create View character_set_client collation_connection +v7 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v7` AS select `db`.`t2`.`fld2` AS `fld2` from `db`.`t2` where `db`.`t2`.`fld2` in (select `t1`.`fld1` from `t1`) utf8mb4 utf8mb4_0900_ai_ci +CREATE VIEW v8 AS SELECT * FROM t1 where fld1 NOT IN (SELECT fld2 FROM db.t2); +SHOW CREATE VIEW v8; +View Create View character_set_client collation_connection +v8 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v8` AS select `t1`.`fld1` AS `fld1` from `t1` where `t1`.`fld1` in (select `db`.`t2`.`fld2` from `db`.`t2`) is false utf8mb4 utf8mb4_0900_ai_ci +CREATE VIEW v9 AS SELECT fld1 FROM t1 where fld1 NOT IN (SELECT fld2 FROM db.t2); +SHOW CREATE VIEW v9; +View Create View character_set_client collation_connection +v9 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v9` AS select `t1`.`fld1` AS `fld1` from `t1` where `t1`.`fld1` in (select `db`.`t2`.`fld2` from `db`.`t2`) is false utf8mb4 utf8mb4_0900_ai_ci +CREATE VIEW v10 AS SELECT t1.fld1 FROM t1 where fld1 NOT IN (SELECT fld2 FROM db.t2); +SHOW CREATE VIEW v10; +View Create View character_set_client collation_connection +v10 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v10` AS select `t1`.`fld1` AS `fld1` from `t1` where `t1`.`fld1` in (select `db`.`t2`.`fld2` from `db`.`t2`) is false utf8mb4 utf8mb4_0900_ai_ci +CREATE VIEW v11 AS SELECT * FROM db.t1 WHERE fld1 NOT IN +(SELECT fld2 FROM db.t2); +SHOW CREATE VIEW v11; +View Create View character_set_client collation_connection +v11 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v11` AS select `db`.`t1`.`fld1` AS `fld1` from `db`.`t1` where `db`.`t1`.`fld1` in (select `db`.`t2`.`fld2` from `db`.`t2`) is false utf8mb4 utf8mb4_0900_ai_ci +# Test cases which uses derived table in sub query. +CREATE VIEW v12 AS SELECT * FROM (SELECT fld1 FROM t1) dummy; +SHOW CREATE VIEW v12; +View Create View character_set_client collation_connection +v12 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v12` AS select `dummy`.`fld1` AS `fld1` from (select `t1`.`fld1` AS `fld1` from `t1`) `dummy` utf8mb4 utf8mb4_0900_ai_ci +CREATE VIEW v13 AS SELECT * FROM (SELECT fld1 FROM db.t1) dummy; +SHOW CREATE VIEW v13; +View Create View character_set_client collation_connection +v13 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v13` AS select `dummy`.`fld1` AS `fld1` from (select `db`.`t1`.`fld1` AS `fld1` from `db`.`t1`) `dummy` utf8mb4 utf8mb4_0900_ai_ci +CREATE VIEW v14 AS SELECT * FROM db.t2, (SELECT fld1 FROM t1) dummy; +SHOW CREATE VIEW v14; +View Create View character_set_client collation_connection +v14 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v14` AS select `db`.`t2`.`fld2` AS `fld2`,`dummy`.`fld1` AS `fld1` from (`db`.`t2` join (select `t1`.`fld1` AS `fld1` from `t1`) `dummy`) utf8mb4 utf8mb4_0900_ai_ci +CREATE VIEW v15 AS SELECT * FROM db.t2, (SELECT fld1 FROM db.t1) dummy; +SHOW CREATE VIEW v15; +View Create View character_set_client collation_connection +v15 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v15` AS select `db`.`t2`.`fld2` AS `fld2`,`dummy`.`fld1` AS `fld1` from (`db`.`t2` join (select `db`.`t1`.`fld1` AS `fld1` from `db`.`t1`) `dummy`) utf8mb4 utf8mb4_0900_ai_ci +CREATE VIEW v16 AS SELECT db.t2.fld2 FROM db.t2, (SELECT t1.fld1 FROM db.t1) dummy; +SHOW CREATE VIEW v16; +View Create View character_set_client collation_connection +v16 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v16` AS select `db`.`t2`.`fld2` AS `fld2` from (`db`.`t2` join (select `db`.`t1`.`fld1` AS `fld1` from `db`.`t1`) `dummy`) utf8mb4 utf8mb4_0900_ai_ci +# Test cases using CTE. +CREATE VIEW v17 AS WITH cte AS (SELECT * FROM t1) SELECT * FROM cte; +SHOW CREATE VIEW v17; +View Create View character_set_client collation_connection +v17 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v17` AS with `cte` as (select `t1`.`fld1` AS `fld1` from `t1`) select `cte`.`fld1` AS `fld1` from `cte` utf8mb4 utf8mb4_0900_ai_ci +CREATE VIEW v18 AS WITH cte AS (SELECT fld1 FROM t1) SELECT * FROM cte; +SHOW CREATE VIEW v18; +View Create View character_set_client collation_connection +v18 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v18` AS with `cte` as (select `t1`.`fld1` AS `fld1` from `t1`) select `cte`.`fld1` AS `fld1` from `cte` utf8mb4 utf8mb4_0900_ai_ci +CREATE VIEW v19 AS WITH cte AS (SELECT db.t2.fld2 FROM db.t2) SELECT * FROM cte; +SHOW CREATE VIEW v19; +View Create View character_set_client collation_connection +v19 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v19` AS with `cte` as (select `db`.`t2`.`fld2` AS `fld2` from `db`.`t2`) select `cte`.`fld2` AS `fld2` from `cte` utf8mb4 utf8mb4_0900_ai_ci +# Test case added for coverage where view is created in different db. +CREATE VIEW db.v1 AS SELECT * FROM db.t1 UNION SELECT * FROM t2; +SHOW CREATE VIEW db.v1; +View Create View character_set_client collation_connection +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `db`.`v1` AS select `db`.`t1`.`fld1` AS `fld1` from `db`.`t1` union select `t2`.`fld2` AS `fld2` from `t2` utf8mb4 utf8mb4_0900_ai_ci +CREATE VIEW db.v2 AS SELECT * FROM t1 where fld1 NOT IN (SELECT fld2 FROM db.t2); +SHOW CREATE VIEW db.v2; +View Create View character_set_client collation_connection +v2 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `db`.`v2` AS select `t1`.`fld1` AS `fld1` from `t1` where `t1`.`fld1` in (select `db`.`t2`.`fld2` from `db`.`t2`) is false utf8mb4 utf8mb4_0900_ai_ci +CREATE VIEW db.v3 AS SELECT * FROM (SELECT fld1 FROM t1) dummy; +SHOW CREATE VIEW db.v3; +View Create View character_set_client collation_connection +v3 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `db`.`v3` AS select `dummy`.`fld1` AS `fld1` from (select `t1`.`fld1` AS `fld1` from `t1`) `dummy` utf8mb4 utf8mb4_0900_ai_ci +# Cleanup. +DROP VIEW v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, +v16, v17, v18, v19; +DROP TABLE t1, t2; +DROP DATABASE db; +# +# Bug#25832861: TABLE_SHARE->TMP_TABLE != NO_TMP_TABLE || M_LOCK_TYPE == 1' AT HANDLER::HA_UPDAT +# +CREATE TABLE t1 (a INTEGER); +INSERT INTO t1 VALUES (1), (2); +CREATE VIEW v1 AS SELECT a FROM t1; +CREATE VIEW v2 AS SELECT 1; +CREATE VIEW v3 AS SELECT a FROM (SELECT a FROM v1) AS dt; +CREATE VIEW v4 AS SELECT a FROM (SELECT a FROM t1) AS dt; +CREATE VIEW v5 AS SELECT a FROM (SELECT a FROM v3) AS dt2; +UPDATE v3 SET v3.a=3; +ERROR HY000: The target table v3 of the UPDATE is not updatable +UPDATE v3, v2 SET v3.a=3; +ERROR HY000: The target table v3 of the UPDATE is not updatable +UPDATE v3, v1 SET v1.a=3; +SELECT * FROM t1; +a +3 +3 +UPDATE v3, t1 SET t1.a=4; +SELECT * FROM t1; +a +4 +4 +UPDATE v4 SET v4.a=6; +ERROR HY000: The target table v4 of the UPDATE is not updatable +SELECT * FROM t1; +a +4 +4 +UPDATE v4, v2 SET v4.a=6; +ERROR HY000: The target table v4 of the UPDATE is not updatable +UPDATE v4, v1 SET v1.a=6; +SELECT * FROM t1; +a +6 +6 +UPDATE v4, t1 SET t1.a=7; +SELECT * FROM t1; +a +7 +7 +UPDATE v5 SET v5.a=9; +ERROR HY000: The target table v5 of the UPDATE is not updatable +UPDATE v5, v2 SET v5.a=9; +ERROR HY000: The target table v5 of the UPDATE is not updatable +UPDATE v5, v1 SET v1.a=9; +SELECT * FROM t1; +a +9 +9 +UPDATE v5, t1 SET t1.a=10; +SELECT * FROM t1; +a +10 +10 +DROP TABLE t1; +DROP VIEW v1, v2, v3, v4, v5; +# Bug#26659699 Assertion !(thd->lex->context_analysis_only & 2) failed +CREATE TABLE t1(pk INTEGER, cik INTEGER, UNIQUE KEY(cik)) +PARTITION BY KEY(cik) PARTITIONS 10; +CREATE TABLE t2(pk INTEGER, cvk VARCHAR(20), cik INTEGER, UNIQUE KEY(cik)) +PARTITION BY KEY(cik) PARTITIONS 10; +CREATE VIEW v1 AS +SELECT MAX(t2.pk) AS field1 +FROM t1, t2 +WHERE (SELECT 7 FROM DUAL) IS NOT NULL AND +t1.pk BETWEEN 123 AND (123 + 128) AND +t2.cvk <= 'p' +ORDER BY t1.pk DESC; +DROP VIEW v1; +DROP TABLE t1, t2; +# +# BUG#26266789: ON SERVER 8.0 CREATE OR REPLACE VIEW FAILS FOR COLUMN SIZE > 64 +# +CREATE TABLE t1(fld1 INT, fld2 INT); +INSERT INTO t1 VALUES(1, 1); +# Without patch, a dictionary store error is triggered on release +# build and an assert on debug build. +CREATE OR REPLACE VIEW v1 +(`x12345678901234567890123456789012345678901234567890123456789012322`) AS +SELECT fld1 FROM t1; +ERROR 42000: Incorrect column name 'x12345678901234567890123456789012345678901234567890123456789012322' +# Clean up. +DROP TABLE t1; +# +# Bug#26360114 WRONG RESULT WITH AGGREGATE AND HAVING CLAUSE IN VIEW +# +CREATE TABLE t1 ( +col_date_key DATE, +KEY col_date_key (col_date_key) +); +INSERT INTO t1 VALUES ('2007-02-08'); +INSERT INTO t1 VALUES ('2007-02-08'); +INSERT INTO t1 VALUES ('2008-11-04'); +INSERT INTO t1 VALUES ('2008-11-04'); +INSERT INTO t1 VALUES ('2009-01-14'); +INSERT INTO t1 VALUES ('2009-01-14'); +SELECT MAX(col_date_key) AS x +FROM t1 +HAVING x >= CAST('2009-01-01' AS DATE) +; +x +2009-01-14 +CREATE VIEW v1 AS +SELECT MAX(col_date_key) AS x +FROM t1 +HAVING x >= CAST('2009-01-01' AS DATE) +; +SELECT * FROM v1; +x +2009-01-14 +DROP VIEW v1; +DROP TABLE t1; +# +# Bug#27121663: SIG 11 IN FILL_DD_VIEW_TABLES | SQL/DD/DD_VIEW.CC +# +CREATE TABLE t1 (pk INT); +CREATE VIEW v1 AS SELECT COUNT(*) FROM t1 +ORDER BY (SELECT 1 FROM t1 WHERE 1 IN (SELECT * FROM (SELECT 1 as field) AS dt)); +DROP TABLE t1; +DROP VIEW v1; +# +# Bug #28278220 - WRONG COLUMN TYPE , VIEW , BINARY +# +CREATE VIEW v AS SELECT null AS 'c' UNION SELECT 'a' AS 'c'; +# Without fix, type for field c is listed as binary instead of +# varchar(1). With fix type is listed correctly. +SHOW FIELDS FROM v; +Field Type Null Key Default Extra +c varchar(1) YES NULL +DROP VIEW v; +# +# Bug#32050275 - can't create synonym of information_schema using create_synonym_db() +# +PREPARE stmt FROM "CREATE VIEW v1 AS SELECT * FROM + JSON_TABLE('[]', '$[*]' COLUMNS (c1 INT PATH '$.x')) AS jt"; +EXECUTE stmt; +EXECUTE stmt; +ERROR 42S01: Table 'v1' already exists +DROP VIEW v1; +EXECUTE stmt; +DEALLOCATE PREPARE stmt; +DROP VIEW v1; +PREPARE stmt FROM "CREATE VIEW v1 AS WITH RECURSIVE cte (n) AS + ( + SELECT 1 + UNION ALL + SELECT n + 1 FROM cte WHERE n < 5 + ) + SELECT * FROM cte"; +EXECUTE stmt; +EXECUTE stmt; +ERROR 42S01: Table 'v1' already exists +DROP VIEW v1; +EXECUTE stmt; +DEALLOCATE PREPARE stmt; +DROP VIEW v1; +call sys.create_synonym_db("INFORMATION_SCHEMA", "I_S"); +summary +Created XX views in the `I_S` database +DROP DATABASE I_S; diff --git a/mysql-test/r/view_grant.result-pq b/mysql-test/r/view_grant.result-pq new file mode 100644 index 000000000000..9eb2578085f9 --- /dev/null +++ b/mysql-test/r/view_grant.result-pq @@ -0,0 +1,2743 @@ +set @orig_sql_mode_session= @@SESSION.sql_mode; +set @orig_sql_mode_global= @@GLOBAL.sql_mode; +drop database if exists mysqltest; +drop view if exists v1,v2,v3; +create user test@localhost; +grant create view on test.* to test@localhost; +show grants for test@localhost; +Grants for test@localhost +GRANT USAGE ON *.* TO `test`@`localhost` +GRANT CREATE VIEW ON `test`.* TO `test`@`localhost` +revoke create view on test.* from test@localhost; +show grants for test@localhost; +Grants for test@localhost +GRANT USAGE ON *.* TO `test`@`localhost` +drop user test@localhost; +create database mysqltest; +create table mysqltest.t1 (a int, b int); +create table mysqltest.t2 (a int, b int); +create user mysqltest_1@localhost; +grant select on mysqltest.t1 to mysqltest_1@localhost; +grant create view,select on test.* to mysqltest_1@localhost; +create definer=root@localhost view v1 as select * from mysqltest.t1; +ERROR 42000: Access denied; you need (at least one of) the SUPER or SET_USER_ID privilege(s) for this operation +create view v1 as select * from mysqltest.t1; +alter view v1 as select * from mysqltest.t1; +ERROR 42000: DROP command denied to user 'mysqltest_1'@'localhost' for table 'v1' +create or replace view v1 as select * from mysqltest.t1; +ERROR 42000: DROP command denied to user 'mysqltest_1'@'localhost' for table 'v1' +create view mysqltest.v2 as select * from mysqltest.t1; +ERROR 42000: CREATE VIEW command denied to user 'mysqltest_1'@'localhost' for table 'v2' +create view v2 as select * from mysqltest.t2; +ERROR 42000: ANY command denied to user 'mysqltest_1'@'localhost' for table 't2' +show create view v1; +View Create View character_set_client collation_connection +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`mysqltest_1`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `mysqltest`.`t1`.`a` AS `a`,`mysqltest`.`t1`.`b` AS `b` from `mysqltest`.`t1` utf8mb4 utf8mb4_0900_ai_ci +grant create view,drop,select on test.* to mysqltest_1@localhost; +use test; +alter view v1 as select * from mysqltest.t1; +create or replace view v1 as select * from mysqltest.t1; +revoke all privileges on mysqltest.t1 from mysqltest_1@localhost; +revoke all privileges on test.* from mysqltest_1@localhost; +drop database mysqltest; +drop view test.v1; +create database mysqltest; +create table mysqltest.t1 (a int, b int); +create view mysqltest.v1 (c,d) as select a+1,b+1 from mysqltest.t1; +grant select (c) on mysqltest.v1 to mysqltest_1@localhost; +select c from mysqltest.v1; +c +select d from mysqltest.v1; +ERROR 42000: SELECT command denied to user 'mysqltest_1'@'localhost' for column 'd' in table 'v1' +revoke all privileges on mysqltest.v1 from mysqltest_1@localhost; +delete from mysql.user where user='mysqltest_1'; +drop database mysqltest; +create database mysqltest; +create table mysqltest.t1 (a int, b int); +create algorithm=temptable view mysqltest.v1 (c,d) as select a+1,b+1 from mysqltest.t1; +grant select (c) on mysqltest.v1 to mysqltest_1@localhost; +select c from mysqltest.v1; +c +select d from mysqltest.v1; +ERROR 42000: SELECT command denied to user 'mysqltest_1'@'localhost' for column 'd' in table 'v1' +revoke all privileges on mysqltest.v1 from mysqltest_1@localhost; +delete from mysql.user where user='mysqltest_1'; +drop database mysqltest; +flush privileges; +create user mysqltest_1@localhost; +create database mysqltest; +create table mysqltest.t1 (a int, b int); +create table mysqltest.t2 (a int, b int); +create view mysqltest.v1 (c,d) as select a+1,b+1 from mysqltest.t1; +create algorithm=temptable view mysqltest.v2 (c,d) as select a+1,b+1 from mysqltest.t1; +create view mysqltest.v3 (c,d) as select a+1,b+1 from mysqltest.t2; +create algorithm=temptable view mysqltest.v4 (c,d) as select a+1,b+1 from mysqltest.t2; +create view mysqltest.v5 (c,d) as select a+1,b+1 from mysqltest.t1; +grant select on mysqltest.v1 to mysqltest_1@localhost; +grant select on mysqltest.v2 to mysqltest_1@localhost; +grant select on mysqltest.v3 to mysqltest_1@localhost; +grant select on mysqltest.v4 to mysqltest_1@localhost; +grant show view on mysqltest.v5 to mysqltest_1@localhost; +select c from mysqltest.v1; +c +select c from mysqltest.v2; +c +select c from mysqltest.v3; +c +select c from mysqltest.v4; +c +select c from mysqltest.v5; +ERROR 42000: SELECT command denied to user 'mysqltest_1'@'localhost' for table 'v5' +show columns from mysqltest.v1; +Field Type Null Key Default Extra +c bigint YES NULL +d bigint YES NULL +show columns from mysqltest.v2; +Field Type Null Key Default Extra +c bigint YES NULL +d bigint YES NULL +explain select c from mysqltest.v1; +ERROR HY000: EXPLAIN/SHOW can not be issued; lacking privileges for underlying table +show create view mysqltest.v1; +ERROR 42000: SHOW VIEW command denied to user 'mysqltest_1'@'localhost' for table 'v1' +explain select c from mysqltest.v2; +ERROR HY000: EXPLAIN/SHOW can not be issued; lacking privileges for underlying table +show create view mysqltest.v2; +ERROR 42000: SHOW VIEW command denied to user 'mysqltest_1'@'localhost' for table 'v2' +explain select c from mysqltest.v3; +ERROR HY000: EXPLAIN/SHOW can not be issued; lacking privileges for underlying table +show create view mysqltest.v3; +ERROR 42000: SHOW VIEW command denied to user 'mysqltest_1'@'localhost' for table 'v3' +explain select c from mysqltest.v4; +ERROR HY000: EXPLAIN/SHOW can not be issued; lacking privileges for underlying table +show create view mysqltest.v4; +ERROR 42000: SHOW VIEW command denied to user 'mysqltest_1'@'localhost' for table 'v4' +explain select c from mysqltest.v5; +ERROR 42000: SELECT command denied to user 'mysqltest_1'@'localhost' for table 'v5' +show create view mysqltest.v5; +ERROR 42000: SELECT command denied to user 'mysqltest_1'@'localhost' for table 'v5' +grant select on mysqltest.v5 to mysqltest_1@localhost; +show create view mysqltest.v5; +View Create View character_set_client collation_connection +v5 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `mysqltest`.`v5` (`c`,`d`) AS select (`mysqltest`.`t1`.`a` + 1) AS `a+1`,(`mysqltest`.`t1`.`b` + 1) AS `b+1` from `mysqltest`.`t1` utf8mb4 utf8mb4_0900_ai_ci +explain select c from mysqltest.v1; +ERROR HY000: EXPLAIN/SHOW can not be issued; lacking privileges for underlying table +show create view mysqltest.v1; +ERROR 42000: SHOW VIEW command denied to user 'mysqltest_1'@'localhost' for table 'v1' +grant show view on mysqltest.v1 to mysqltest_1@localhost; +grant select on mysqltest.t1 to mysqltest_1@localhost; +revoke select on mysqltest.v5 from mysqltest_1@localhost; +explain select c from mysqltest.v1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select (`mysqltest`.`t1`.`a` + 1) AS `c` from `mysqltest`.`t1` +show create view mysqltest.v1; +View Create View character_set_client collation_connection +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `mysqltest`.`v1` (`c`,`d`) AS select (`mysqltest`.`t1`.`a` + 1) AS `a+1`,(`mysqltest`.`t1`.`b` + 1) AS `b+1` from `mysqltest`.`t1` utf8mb4 utf8mb4_0900_ai_ci +explain select c from mysqltest.v2; +ERROR HY000: EXPLAIN/SHOW can not be issued; lacking privileges for underlying table +show create view mysqltest.v2; +ERROR 42000: SHOW VIEW command denied to user 'mysqltest_1'@'localhost' for table 'v2' +explain select c from mysqltest.v3; +ERROR HY000: EXPLAIN/SHOW can not be issued; lacking privileges for underlying table +show create view mysqltest.v3; +ERROR 42000: SHOW VIEW command denied to user 'mysqltest_1'@'localhost' for table 'v3' +explain select c from mysqltest.v4; +ERROR HY000: EXPLAIN/SHOW can not be issued; lacking privileges for underlying table +show create view mysqltest.v4; +ERROR 42000: SHOW VIEW command denied to user 'mysqltest_1'@'localhost' for table 'v4' +explain select c from mysqltest.v5; +ERROR 42000: SELECT command denied to user 'mysqltest_1'@'localhost' for table 'v5' +grant show view on mysqltest.* to mysqltest_1@localhost; +explain select c from mysqltest.v1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select (`mysqltest`.`t1`.`a` + 1) AS `c` from `mysqltest`.`t1` +show create view mysqltest.v1; +View Create View character_set_client collation_connection +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `mysqltest`.`v1` (`c`,`d`) AS select (`mysqltest`.`t1`.`a` + 1) AS `a+1`,(`mysqltest`.`t1`.`b` + 1) AS `b+1` from `mysqltest`.`t1` utf8mb4 utf8mb4_0900_ai_ci +explain select c from mysqltest.v2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DERIVED t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `mysqltest`.`v2`.`c` AS `c` from `mysqltest`.`v2` +show create view mysqltest.v2; +View Create View character_set_client collation_connection +v2 CREATE ALGORITHM=TEMPTABLE DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `mysqltest`.`v2` (`c`,`d`) AS select (`mysqltest`.`t1`.`a` + 1) AS `a+1`,(`mysqltest`.`t1`.`b` + 1) AS `b+1` from `mysqltest`.`t1` utf8mb4 utf8mb4_0900_ai_ci +explain select c from mysqltest.v3; +ERROR HY000: EXPLAIN/SHOW can not be issued; lacking privileges for underlying table +show create view mysqltest.v3; +View Create View character_set_client collation_connection +v3 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `mysqltest`.`v3` (`c`,`d`) AS select (`mysqltest`.`t2`.`a` + 1) AS `a+1`,(`mysqltest`.`t2`.`b` + 1) AS `b+1` from `mysqltest`.`t2` utf8mb4 utf8mb4_0900_ai_ci +explain select c from mysqltest.v4; +ERROR HY000: EXPLAIN/SHOW can not be issued; lacking privileges for underlying table +show create view mysqltest.v4; +View Create View character_set_client collation_connection +v4 CREATE ALGORITHM=TEMPTABLE DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `mysqltest`.`v4` (`c`,`d`) AS select (`mysqltest`.`t2`.`a` + 1) AS `a+1`,(`mysqltest`.`t2`.`b` + 1) AS `b+1` from `mysqltest`.`t2` utf8mb4 utf8mb4_0900_ai_ci +revoke all privileges, grant option from mysqltest_1@localhost; +delete from mysql.user where user='mysqltest_1'; +drop database mysqltest; +flush privileges; +create user mysqltest_1@localhost; +create database mysqltest; +create table mysqltest.t1 (a int, b int, primary key(a)); +insert into mysqltest.t1 values (10,2), (20,3), (30,4), (40,5), (50,10); +create table mysqltest.t2 (x int); +insert into mysqltest.t2 values (3), (4), (5), (6); +create view mysqltest.v1 (a,c) as select a, b+1 from mysqltest.t1; +create view mysqltest.v2 (a,c) as select a, b from mysqltest.t1; +create view mysqltest.v3 (a,c) as select a, b+1 from mysqltest.t1; +grant update (a) on mysqltest.v2 to mysqltest_1@localhost; +grant update on mysqltest.v1 to mysqltest_1@localhost; +grant select on mysqltest.* to mysqltest_1@localhost; +use mysqltest; +update t2,v1 set v1.a=v1.a+v1.c where t2.x=v1.c; +select * from t1; +a b +13 2 +24 3 +35 4 +46 5 +50 10 +update v1 set a=a+c; +select * from t1; +a b +16 2 +28 3 +40 4 +52 5 +61 10 +update t2,v2 set v2.a=v2.a+v2.c where t2.x=v2.c; +select * from t1; +a b +16 2 +31 3 +44 4 +57 5 +61 10 +update v2 set a=a+c; +select * from t1; +a b +18 2 +34 3 +48 4 +62 5 +71 10 +update t2,v2 set v2.c=v2.a+v2.c where t2.x=v2.c; +ERROR 42000: UPDATE command denied to user 'mysqltest_1'@'localhost' for column 'c' in table 'v2' +update v2 set c=a+c; +ERROR 42000: UPDATE command denied to user 'mysqltest_1'@'localhost' for column 'c' in table 'v2' +update t2,v3 set v3.a=v3.a+v3.c where t2.x=v3.c; +ERROR 42000: UPDATE command denied to user 'mysqltest_1'@'localhost' for column 'a' in table 'v3' +update v3 set a=a+c; +ERROR 42000: UPDATE command denied to user 'mysqltest_1'@'localhost' for table 'v3' +use test; +REVOKE ALL PRIVILEGES, GRANT OPTION FROM mysqltest_1@localhost; +drop database mysqltest; +create database mysqltest; +create table mysqltest.t1 (a int, b int, primary key(a)); +insert into mysqltest.t1 values (1,2), (2,3), (3,4), (4,5), (5,10); +create table mysqltest.t2 (x int); +insert into mysqltest.t2 values (3), (4), (5), (6); +create view mysqltest.v1 (a,c) as select a, b+1 from mysqltest.t1; +create view mysqltest.v2 (a,c) as select a, b+1 from mysqltest.t1; +grant delete on mysqltest.v1 to mysqltest_1@localhost; +grant select on mysqltest.* to mysqltest_1@localhost; +use mysqltest; +delete from v1 where c < 4; +select * from t1; +a b +2 3 +3 4 +4 5 +5 10 +delete v1 from t2,v1 where t2.x=v1.c; +select * from t1; +a b +5 10 +delete v2 from t2,v2 where t2.x=v2.c; +ERROR 42000: DELETE command denied to user 'mysqltest_1'@'localhost' for table 'v2' +delete from v2 where c < 4; +ERROR 42000: DELETE command denied to user 'mysqltest_1'@'localhost' for table 'v2' +use test; +REVOKE ALL PRIVILEGES, GRANT OPTION FROM mysqltest_1@localhost; +drop database mysqltest; +create database mysqltest; +create table mysqltest.t1 (a int, b int, primary key(a)); +insert into mysqltest.t1 values (1,2), (2,3); +create table mysqltest.t2 (x int, y int); +insert into mysqltest.t2 values (3,4); +create view mysqltest.v1 (a,c) as select a, b from mysqltest.t1; +create view mysqltest.v2 (a,c) as select a, b from mysqltest.t1; +grant insert on mysqltest.v1 to mysqltest_1@localhost; +grant select on mysqltest.* to mysqltest_1@localhost; +use mysqltest; +insert into v1 values (5,6); +select * from t1; +a b +1 2 +2 3 +5 6 +insert into v1 select x,y from t2; +select * from t1; +a b +1 2 +2 3 +3 4 +5 6 +insert into v2 values (5,6); +ERROR 42000: INSERT command denied to user 'mysqltest_1'@'localhost' for table 'v2' +insert into v2 select x,y from t2; +ERROR 42000: INSERT command denied to user 'mysqltest_1'@'localhost' for table 'v2' +use test; +REVOKE ALL PRIVILEGES, GRANT OPTION FROM mysqltest_1@localhost; +drop database mysqltest; +create database mysqltest; +create table mysqltest.t1 (a int, b int); +create table mysqltest.t2 (a int, b int); +grant update on mysqltest.t1 to mysqltest_1@localhost; +grant update(b) on mysqltest.t2 to mysqltest_1@localhost; +grant create view,update on test.* to mysqltest_1@localhost; +create view v1 as select * from mysqltest.t1; +create view v2 as select b from mysqltest.t2; +create view mysqltest.v1 as select * from mysqltest.t1; +ERROR 42000: CREATE VIEW command denied to user 'mysqltest_1'@'localhost' for table 'v1' +create view v3 as select a from mysqltest.t2; +ERROR 42000: ANY command denied to user 'mysqltest_1'@'localhost' for column 'a' in table 't2' +create table mysqltest.v3 (b int); +grant create view on mysqltest.v3 to mysqltest_1@localhost; +drop table mysqltest.v3; +create view mysqltest.v3 as select b from mysqltest.t2; +grant create view, update on mysqltest.v3 to mysqltest_1@localhost; +drop view mysqltest.v3; +create view mysqltest.v3 as select b from mysqltest.t2; +create view v4 as select b+1 from mysqltest.t2; +ERROR 42000: SELECT command denied to user 'mysqltest_1'@'localhost' for column 'b' in table 't2' +grant create view,update,select on test.* to mysqltest_1@localhost; +create view v4 as select b+1 from mysqltest.t2; +ERROR 42000: SELECT command denied to user 'mysqltest_1'@'localhost' for column 'b' in table 't2' +grant update,select(b) on mysqltest.t2 to mysqltest_1@localhost; +create view v4 as select b+1 from mysqltest.t2; +REVOKE ALL PRIVILEGES, GRANT OPTION FROM mysqltest_1@localhost; +drop database mysqltest; +drop view v1,v2,v4; +create database mysqltest; +create table mysqltest.t1 (a int); +grant all privileges on mysqltest.* to mysqltest_1@localhost; +use mysqltest; +create view v1 as select * from t1; +use test; +revoke all privileges on mysqltest.* from mysqltest_1@localhost; +drop database mysqltest; +create database mysqltest; +create table mysqltest.t1 (a int, b int); +grant select on mysqltest.t1 to mysqltest_1@localhost; +grant create view,select on test.* to mysqltest_1@localhost; +create view v1 as select * from mysqltest.t1; +show create view v1; +View Create View character_set_client collation_connection +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`mysqltest_1`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `mysqltest`.`t1`.`a` AS `a`,`mysqltest`.`t1`.`b` AS `b` from `mysqltest`.`t1` utf8mb4 utf8mb4_0900_ai_ci +revoke select on mysqltest.t1 from mysqltest_1@localhost; +select * from v1; +ERROR HY000: View 'test.v1' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +grant select on mysqltest.t1 to mysqltest_1@localhost; +select * from v1; +a b +REVOKE ALL PRIVILEGES, GRANT OPTION FROM mysqltest_1@localhost; +drop view v1; +drop database mysqltest; +create database mysqltest; +use mysqltest; +create table t1 (a int); +insert into t1 values (1); +create table t2 (s1 int); +create function f2 () returns int begin declare v int; select s1 from t2 +into v; return v; end// +create algorithm=TEMPTABLE view v1 as select f2() from t1; +create algorithm=MERGE view v2 as select f2() from t1; +create algorithm=TEMPTABLE SQL SECURITY INVOKER view v3 as select f2() from t1; +create algorithm=MERGE SQL SECURITY INVOKER view v4 as select f2() from t1; +create SQL SECURITY INVOKER view v5 as select * from v4; +grant select on v1 to mysqltest_1@localhost; +grant select on v2 to mysqltest_1@localhost; +grant select on v3 to mysqltest_1@localhost; +grant select on v4 to mysqltest_1@localhost; +grant select on v5 to mysqltest_1@localhost; +use mysqltest; +select * from v1; +f2() +NULL +select * from v2; +f2() +NULL +select * from v3; +ERROR HY000: View 'mysqltest.v3' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +select * from v4; +ERROR HY000: View 'mysqltest.v4' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +select * from v5; +ERROR HY000: View 'mysqltest.v5' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +use test; +drop view v1, v2, v3, v4, v5; +drop function f2; +drop table t1, t2; +use test; +REVOKE ALL PRIVILEGES, GRANT OPTION FROM mysqltest_1@localhost; +drop database mysqltest; +create database mysqltest; +use mysqltest; +create table t1 (a int); +insert into t1 values (1); +create table t2 (s1 int); +create function f2 () returns int begin declare v int; select s1 from t2 +into v; return v; end// +grant select on t1 to mysqltest_1@localhost; +grant execute on function f2 to mysqltest_1@localhost; +grant create view on mysqltest.* to mysqltest_1@localhost; +use mysqltest; +create algorithm=TEMPTABLE view v1 as select f2() from t1; +create algorithm=MERGE view v2 as select f2() from t1; +create algorithm=TEMPTABLE SQL SECURITY INVOKER view v3 as select f2() from t1; +create algorithm=MERGE SQL SECURITY INVOKER view v4 as select f2() from t1; +use test; +create view v5 as select * from v1; +revoke execute on function f2 from mysqltest_1@localhost; +select * from v1; +ERROR HY000: View 'mysqltest.v1' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +select * from v2; +ERROR HY000: View 'mysqltest.v2' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +select * from v3; +f2() +NULL +select * from v4; +f2() +NULL +select * from v5; +ERROR HY000: View 'mysqltest.v5' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +drop view v1, v2, v3, v4, v5; +drop function f2; +drop table t1, t2; +use test; +REVOKE ALL PRIVILEGES, GRANT OPTION FROM mysqltest_1@localhost; +drop database mysqltest; +create database mysqltest; +use mysqltest; +create table t1 (a int); +create table v1 (a int); +insert into t1 values (1); +grant select on t1 to mysqltest_1@localhost; +grant select on v1 to mysqltest_1@localhost; +grant create view on mysqltest.* to mysqltest_1@localhost; +drop table v1; +use mysqltest; +create algorithm=TEMPTABLE view v1 as select *, a as b from t1; +create algorithm=MERGE view v2 as select *, a as b from t1; +create algorithm=TEMPTABLE SQL SECURITY INVOKER view v3 as select *, a as b from t1; +create algorithm=MERGE SQL SECURITY INVOKER view v4 as select *, a as b from t1; +create view v5 as select * from v1; +use test; +revoke select on t1 from mysqltest_1@localhost; +select * from v1; +ERROR HY000: View 'mysqltest.v1' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +select * from v2; +ERROR HY000: View 'mysqltest.v2' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +select * from v3; +a b +1 1 +select * from v4; +a b +1 1 +select * from v5; +ERROR HY000: View 'mysqltest.v5' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +drop table t1; +use test; +REVOKE ALL PRIVILEGES, GRANT OPTION FROM mysqltest_1@localhost; +drop database mysqltest; +create database mysqltest; +use mysqltest; +create table t1 (a int); +insert into t1 values (1); +create algorithm=TEMPTABLE view v1 as select *, a as b from t1; +create algorithm=MERGE view v2 as select *, a as b from t1; +create algorithm=TEMPTABLE SQL SECURITY INVOKER view v3 as select *, a as b from t1; +create algorithm=MERGE SQL SECURITY INVOKER view v4 as select *, a as b from t1; +create SQL SECURITY INVOKER view v5 as select * from v4; +grant select on v1 to mysqltest_1@localhost; +grant select on v2 to mysqltest_1@localhost; +grant select on v3 to mysqltest_1@localhost; +grant select on v4 to mysqltest_1@localhost; +grant select on v5 to mysqltest_1@localhost; +use mysqltest; +select * from v1; +a b +1 1 +select * from v2; +a b +1 1 +select * from v3; +ERROR HY000: View 'mysqltest.v3' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +select * from v4; +ERROR HY000: View 'mysqltest.v4' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +select * from v5; +ERROR HY000: View 'mysqltest.v5' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +use test; +drop view v1, v2, v3, v4, v5; +drop table t1; +use test; +REVOKE ALL PRIVILEGES, GRANT OPTION FROM mysqltest_1@localhost; +drop database mysqltest; +drop view if exists v1; +drop table if exists t1; +create table t1 as select * from mysql.user where user=''; +delete from mysql.user where user=''; +flush privileges; +create user 'test14256'@'%'; +grant all on test.* to 'test14256'@'%'; +use test; +create view v1 as select 42; +show create view v1; +View Create View character_set_client collation_connection +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`test14256`@`%` SQL SECURITY DEFINER VIEW `v1` AS select 42 AS `42` utf8mb4 utf8mb4_0900_ai_ci +select definer into @v1def1 from information_schema.views +where table_schema = 'test' and table_name='v1'; +drop view v1; +create definer=`test14256`@`%` view v1 as select 42; +show create view v1; +View Create View character_set_client collation_connection +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`test14256`@`%` SQL SECURITY DEFINER VIEW `v1` AS select 42 AS `42` utf8mb4 utf8mb4_0900_ai_ci +select definer into @v1def2 from information_schema.views +where table_schema = 'test' and table_name='v1'; +drop view v1; +select @v1def1, @v1def2, @v1def1=@v1def2; +@v1def1 @v1def2 @v1def1=@v1def2 +test14256@% test14256@% 1 +drop user test14256; +insert into mysql.user select * from t1; +flush privileges; +drop table t1; +create database mysqltest; +use mysqltest; +CREATE TABLE t1 (i INT); +CREATE VIEW v1 AS SELECT * FROM t1; +SHOW CREATE VIEW v1; +View Create View character_set_client collation_connection +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`i` AS `i` from `t1` utf8mb4 utf8mb4_0900_ai_ci +GRANT SELECT, LOCK TABLES ON mysqltest.* TO mysqltest_1@localhost; +use mysqltest; +LOCK TABLES v1 READ; +SHOW CREATE TABLE v1; +ERROR 42000: SHOW VIEW command denied to user 'mysqltest_1'@'localhost' for table 'v1' +UNLOCK TABLES; +use test; +use test; +drop user mysqltest_1@localhost; +drop database mysqltest; +create definer=some_user@`` sql security invoker view v1 as select 1; +Warnings: +Note 1449 The user specified as a definer ('some_user'@'') does not exist +create definer=some_user@localhost sql security invoker view v2 as select 1; +Warnings: +Note 1449 The user specified as a definer ('some_user'@'localhost') does not exist +show create view v1; +View Create View character_set_client collation_connection +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`some_user`@`` SQL SECURITY INVOKER VIEW `v1` AS select 1 AS `1` utf8mb4 utf8mb4_0900_ai_ci +show create view v2; +View Create View character_set_client collation_connection +v2 CREATE ALGORITHM=UNDEFINED DEFINER=`some_user`@`localhost` SQL SECURITY INVOKER VIEW `v2` AS select 1 AS `1` utf8mb4 utf8mb4_0900_ai_ci +drop view v1; +drop view v2; +CREATE DATABASE mysqltest1; +CREATE USER readonly@localhost; +CREATE TABLE mysqltest1.t1 (x INT); +INSERT INTO mysqltest1.t1 VALUES (1), (2); +CREATE SQL SECURITY INVOKER VIEW mysqltest1.v_t1 AS SELECT * FROM mysqltest1.t1; +CREATE SQL SECURITY DEFINER VIEW mysqltest1.v_ts AS SELECT * FROM mysqltest1.t1; +CREATE SQL SECURITY DEFINER VIEW mysqltest1.v_ti AS SELECT * FROM mysqltest1.t1; +CREATE SQL SECURITY DEFINER VIEW mysqltest1.v_tu AS SELECT * FROM mysqltest1.t1; +CREATE SQL SECURITY DEFINER VIEW mysqltest1.v_tus AS SELECT * FROM mysqltest1.t1; +CREATE SQL SECURITY DEFINER VIEW mysqltest1.v_td AS SELECT * FROM mysqltest1.t1; +CREATE SQL SECURITY DEFINER VIEW mysqltest1.v_tds AS SELECT * FROM mysqltest1.t1; +GRANT SELECT, INSERT, UPDATE, DELETE ON mysqltest1.v_t1 TO readonly@localhost; +GRANT SELECT ON mysqltest1.v_ts TO readonly@localhost; +GRANT INSERT ON mysqltest1.v_ti TO readonly@localhost; +GRANT UPDATE ON mysqltest1.v_tu TO readonly@localhost; +GRANT UPDATE,SELECT ON mysqltest1.v_tus TO readonly@localhost; +GRANT DELETE ON mysqltest1.v_td TO readonly@localhost; +GRANT DELETE,SELECT ON mysqltest1.v_tds TO readonly@localhost; +SELECT * FROM mysqltest1.v_t1; +ERROR HY000: View 'mysqltest1.v_t1' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +SET sql_mode = 'NO_ENGINE_SUBSTITUTION'; +INSERT INTO mysqltest1.v_t1 VALUES(4); +ERROR HY000: View 'mysqltest1.v_t1' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +DELETE FROM mysqltest1.v_t1 WHERE x = 1; +ERROR HY000: View 'mysqltest1.v_t1' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +UPDATE mysqltest1.v_t1 SET x = 3 WHERE x = 2; +ERROR HY000: View 'mysqltest1.v_t1' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +UPDATE mysqltest1.v_t1 SET x = 3; +ERROR HY000: View 'mysqltest1.v_t1' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +DELETE FROM mysqltest1.v_t1; +ERROR HY000: View 'mysqltest1.v_t1' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +SET sql_mode = default; +SELECT 1 FROM mysqltest1.v_t1; +ERROR HY000: View 'mysqltest1.v_t1' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +SELECT * FROM mysqltest1.t1; +ERROR 42000: SELECT command denied to user 'readonly'@'localhost' for table 't1' +SELECT * FROM mysqltest1.v_ts; +x +1 +2 +SELECT * FROM mysqltest1.v_ts, mysqltest1.t1 WHERE mysqltest1.t1.x = mysqltest1.v_ts.x; +ERROR 42000: SELECT command denied to user 'readonly'@'localhost' for table 't1' +SELECT * FROM mysqltest1.v_ti; +ERROR 42000: SELECT command denied to user 'readonly'@'localhost' for table 'v_ti' +INSERT INTO mysqltest1.v_ts VALUES (100); +ERROR 42000: INSERT command denied to user 'readonly'@'localhost' for table 'v_ts' +INSERT INTO mysqltest1.v_ti VALUES (100); +UPDATE mysqltest1.v_ts SET x= 200 WHERE x = 100; +ERROR 42000: UPDATE command denied to user 'readonly'@'localhost' for table 'v_ts' +UPDATE mysqltest1.v_ts SET x= 200; +ERROR 42000: UPDATE command denied to user 'readonly'@'localhost' for table 'v_ts' +UPDATE mysqltest1.v_tu SET x= 200 WHERE x = 100; +ERROR 42000: SELECT command denied to user 'readonly'@'localhost' for column 'x' in table 'v_tu' +UPDATE mysqltest1.v_tus SET x= 200 WHERE x = 100; +UPDATE mysqltest1.v_tu SET x= 200; +DELETE FROM mysqltest1.v_ts WHERE x= 200; +ERROR 42000: DELETE command denied to user 'readonly'@'localhost' for table 'v_ts' +DELETE FROM mysqltest1.v_ts; +ERROR 42000: DELETE command denied to user 'readonly'@'localhost' for table 'v_ts' +DELETE FROM mysqltest1.v_td WHERE x= 200; +ERROR 42000: SELECT command denied to user 'readonly'@'localhost' for column 'x' in table 'v_td' +DELETE FROM mysqltest1.v_tds WHERE x= 200; +DELETE FROM mysqltest1.v_td; +DROP VIEW mysqltest1.v_tds; +DROP VIEW mysqltest1.v_td; +DROP VIEW mysqltest1.v_tus; +DROP VIEW mysqltest1.v_tu; +DROP VIEW mysqltest1.v_ti; +DROP VIEW mysqltest1.v_ts; +DROP VIEW mysqltest1.v_t1; +DROP TABLE mysqltest1.t1; +DROP USER readonly@localhost; +DROP DATABASE mysqltest1; +CREATE TABLE t1 (a INT PRIMARY KEY); +INSERT INTO t1 VALUES (1), (2), (3); +CREATE DEFINER = 'no-such-user'@localhost VIEW v AS SELECT a from t1; +Warnings: +Note 1449 The user specified as a definer ('no-such-user'@'localhost') does not exist +SHOW CREATE VIEW v; +View Create View character_set_client collation_connection +v CREATE ALGORITHM=UNDEFINED DEFINER=`no-such-user`@`localhost` SQL SECURITY DEFINER VIEW `v` AS select `t1`.`a` AS `a` from `t1` utf8mb4 utf8mb4_0900_ai_ci +Warnings: +Note 1449 The user specified as a definer ('no-such-user'@'localhost') does not exist +SELECT * FROM v; +ERROR HY000: The user specified as a definer ('no-such-user'@'localhost') does not exist +DROP VIEW v; +DROP TABLE t1; +USE test; +CREATE USER mysqltest_db1@localhost identified by 'PWD'; +GRANT ALL ON mysqltest_db1.* TO mysqltest_db1@localhost WITH GRANT OPTION; +CREATE SCHEMA mysqltest_db1 ; +USE mysqltest_db1 ; +CREATE TABLE t1 (f1 INTEGER); +CREATE VIEW view1 AS +SELECT * FROM t1; +SHOW CREATE VIEW view1; +View Create View character_set_client collation_connection +view1 CREATE ALGORITHM=UNDEFINED DEFINER=`mysqltest_db1`@`localhost` SQL SECURITY DEFINER VIEW `view1` AS select `t1`.`f1` AS `f1` from `t1` utf8mb4 utf8mb4_0900_ai_ci +CREATE VIEW view2 AS +SELECT * FROM view1; +# Here comes a suspicious warning +SHOW CREATE VIEW view2; +View Create View character_set_client collation_connection +view2 CREATE ALGORITHM=UNDEFINED DEFINER=`mysqltest_db1`@`localhost` SQL SECURITY DEFINER VIEW `view2` AS select `view1`.`f1` AS `f1` from `view1` utf8mb4 utf8mb4_0900_ai_ci +# But the view view2 is usable +SELECT * FROM view2; +f1 +CREATE VIEW view3 AS +SELECT * FROM view2; +SELECT * from view3; +f1 +DROP VIEW mysqltest_db1.view3; +DROP VIEW mysqltest_db1.view2; +DROP VIEW mysqltest_db1.view1; +DROP TABLE mysqltest_db1.t1; +DROP SCHEMA mysqltest_db1; +DROP USER mysqltest_db1@localhost; +CREATE DATABASE test1; +CREATE DATABASE test2; +CREATE TABLE test1.t0 (a VARCHAR(20)); +CREATE TABLE test2.t1 (a VARCHAR(20)); +CREATE VIEW test2.t3 AS SELECT * FROM test1.t0; +CREATE OR REPLACE VIEW test.v1 AS +SELECT ta.a AS col1, tb.a AS col2 FROM test2.t3 ta, test2.t1 tb; +DROP VIEW test.v1; +DROP VIEW test2.t3; +DROP TABLE test2.t1, test1.t0; +DROP DATABASE test2; +DROP DATABASE test1; +DROP VIEW IF EXISTS v1; +DROP VIEW IF EXISTS v2; +DROP VIEW IF EXISTS v3; +DROP FUNCTION IF EXISTS f1; +DROP FUNCTION IF EXISTS f2; +DROP PROCEDURE IF EXISTS p1; +CREATE SQL SECURITY DEFINER VIEW v1 AS SELECT CURRENT_USER() AS cu; +CREATE FUNCTION f1() RETURNS VARCHAR(77) SQL SECURITY INVOKER +RETURN CURRENT_USER(); +CREATE SQL SECURITY DEFINER VIEW v2 AS SELECT f1() AS cu; +CREATE PROCEDURE p1(OUT cu VARCHAR(77)) SQL SECURITY INVOKER +SET cu= CURRENT_USER(); +CREATE FUNCTION f2() RETURNS VARCHAR(77) SQL SECURITY INVOKER +BEGIN +DECLARE cu VARCHAR(77); +CALL p1(cu); +RETURN cu; +END| +CREATE SQL SECURITY DEFINER VIEW v3 AS SELECT f2() AS cu; +CREATE USER mysqltest_u1@localhost; +GRANT ALL ON test.* TO mysqltest_u1@localhost; + +The following tests should all return 1. + +SELECT CURRENT_USER() = 'mysqltest_u1@localhost'; +CURRENT_USER() = 'mysqltest_u1@localhost' +1 +SELECT f1() = 'mysqltest_u1@localhost'; +f1() = 'mysqltest_u1@localhost' +1 +CALL p1(@cu); +SELECT @cu = 'mysqltest_u1@localhost'; +@cu = 'mysqltest_u1@localhost' +1 +SELECT f2() = 'mysqltest_u1@localhost'; +f2() = 'mysqltest_u1@localhost' +1 +SELECT cu = 'root@localhost' FROM v1; +cu = 'root@localhost' +1 +SELECT cu = 'root@localhost' FROM v2; +cu = 'root@localhost' +1 +SELECT cu = 'root@localhost' FROM v3; +cu = 'root@localhost' +1 +DROP VIEW v3; +DROP FUNCTION f2; +DROP PROCEDURE p1; +DROP FUNCTION f1; +DROP VIEW v2; +DROP VIEW v1; +DROP USER mysqltest_u1@localhost; +CREATE DATABASE db17254; +USE db17254; +CREATE TABLE t1 (f1 INT); +INSERT INTO t1 VALUES (10),(20); +CREATE USER def_17254@localhost; +GRANT SELECT ON db17254.* TO def_17254@localhost; +CREATE USER inv_17254@localhost; +GRANT SELECT ON db17254.t1 TO inv_17254@localhost; +GRANT CREATE VIEW ON db17254.* TO def_17254@localhost; +CREATE VIEW v1 AS SELECT * FROM t1; +DROP USER def_17254@localhost; +Warnings: +Warning 4005 User 'def_17254'@'localhost' is referenced as a definer account in a view. +for a user +SELECT * FROM v1; +ERROR 42000: SELECT command denied to user 'inv_17254'@'localhost' for table 'v1' +for a superuser +SELECT * FROM v1; +ERROR HY000: The user specified as a definer ('def_17254'@'localhost') does not exist +DROP USER inv_17254@localhost; +DROP DATABASE db17254; +DROP DATABASE IF EXISTS mysqltest_db1; +DROP DATABASE IF EXISTS mysqltest_db2; +DROP USER mysqltest_u1; +DROP USER mysqltest_u2; +CREATE USER mysqltest_u1@localhost; +CREATE USER mysqltest_u2@localhost; +CREATE DATABASE mysqltest_db1; +CREATE DATABASE mysqltest_db2; +GRANT ALL ON mysqltest_db1.* TO mysqltest_u1@localhost WITH GRANT OPTION; +GRANT ALL ON mysqltest_db2.* TO mysqltest_u2@localhost; +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (1); +CREATE VIEW v1 AS SELECT i FROM t1 WHERE 1 IN (SELECT * FROM t1); +CREATE TABLE t2 (s CHAR(7)); +INSERT INTO t2 VALUES ('public'); +GRANT SELECT ON v1 TO mysqltest_u2@localhost; +GRANT SELECT ON t2 TO mysqltest_u2@localhost; +SELECT * FROM mysqltest_db1.v1, mysqltest_db1.t2; +i s +1 public +PREPARE stmt1 FROM "SELECT * FROM mysqltest_db1.t2"; +EXECUTE stmt1; +s +public +PREPARE stmt2 FROM "SELECT * FROM mysqltest_db1.v1, mysqltest_db1.t2"; +EXECUTE stmt2; +i s +1 public +REVOKE SELECT ON t2 FROM mysqltest_u2@localhost; +UPDATE t2 SET s = 'private' WHERE s = 'public'; +SELECT * FROM mysqltest_db1.v1, mysqltest_db1.t2; +ERROR 42000: SELECT command denied to user 'mysqltest_u2'@'localhost' for table 't2' +EXECUTE stmt1; +ERROR 42000: SELECT command denied to user 'mysqltest_u2'@'localhost' for table 't2' +EXECUTE stmt2; +ERROR 42000: SELECT command denied to user 'mysqltest_u2'@'localhost' for table 't2' +REVOKE ALL ON mysqltest_db1.* FROM mysqltest_u1@localhost; +REVOKE ALL ON mysqltest_db2.* FROM mysqltest_u2@localhost; +DROP DATABASE mysqltest_db1; +DROP DATABASE mysqltest_db2; +DROP USER mysqltest_u1@localhost; +DROP USER mysqltest_u2@localhost; +CREATE DATABASE db26813; +USE db26813; +CREATE TABLE t1(f1 INT, f2 INT); +CREATE VIEW v1 AS SELECT f1 FROM t1; +CREATE VIEW v2 AS SELECT f1 FROM t1; +CREATE VIEW v3 AS SELECT f1 FROM t1; +CREATE USER u26813@localhost; +GRANT DROP ON db26813.v1 TO u26813@localhost; +GRANT CREATE VIEW ON db26813.v2 TO u26813@localhost; +GRANT DROP, CREATE VIEW ON db26813.v3 TO u26813@localhost; +GRANT SELECT ON db26813.t1 TO u26813@localhost; +ALTER VIEW v1 AS SELECT f2 FROM t1; +ERROR 42000: CREATE VIEW command denied to user 'u26813'@'localhost' for table 'v1' +ALTER VIEW v2 AS SELECT f2 FROM t1; +ERROR 42000: DROP command denied to user 'u26813'@'localhost' for table 'v2' +ALTER VIEW v3 AS SELECT f2 FROM t1; +ERROR 42000: Access denied; you need (at least one of) the SUPER or SET_USER_ID privilege(s) for this operation +SHOW CREATE VIEW v3; +View Create View character_set_client collation_connection +v3 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v3` AS select `t1`.`f1` AS `f1` from `t1` utf8mb4 utf8mb4_0900_ai_ci +DROP USER u26813@localhost; +DROP DATABASE db26813; +# +# Bug#29908 A user can gain additional access through the ALTER VIEW. +# +CREATE DATABASE mysqltest_29908; +USE mysqltest_29908; +CREATE TABLE t1(f1 INT, f2 INT); +CREATE USER u29908_1@localhost; +CREATE DEFINER = u29908_1@localhost VIEW v1 AS SELECT f1 FROM t1; +CREATE DEFINER = u29908_1@localhost SQL SECURITY INVOKER VIEW v2 AS +SELECT f1 FROM t1; +GRANT SELECT, DROP, CREATE VIEW, SHOW VIEW ON mysqltest_29908.v1 TO u29908_1@localhost; +GRANT SELECT, DROP, CREATE VIEW, SHOW VIEW ON mysqltest_29908.v2 TO u29908_1@localhost; +GRANT SELECT ON mysqltest_29908.t1 TO u29908_1@localhost; +CREATE USER u29908_2@localhost; +GRANT SELECT, DROP, CREATE VIEW ON mysqltest_29908.v1 TO u29908_2@localhost; +GRANT SELECT, DROP, CREATE VIEW, SHOW VIEW ON mysqltest_29908.v2 TO u29908_2@localhost; +GRANT SELECT ON mysqltest_29908.t1 TO u29908_2@localhost; +ALTER VIEW v1 AS SELECT f2 FROM t1; +ERROR 42000: Access denied; you need (at least one of) the SUPER or SET_USER_ID privilege(s) for this operation +ALTER VIEW v2 AS SELECT f2 FROM t1; +ERROR 42000: Access denied; you need (at least one of) the SUPER or SET_USER_ID privilege(s) for this operation +SHOW CREATE VIEW v2; +View Create View character_set_client collation_connection +v2 CREATE ALGORITHM=UNDEFINED DEFINER=`u29908_1`@`localhost` SQL SECURITY INVOKER VIEW `v2` AS select `t1`.`f1` AS `f1` from `t1` utf8mb4 utf8mb4_0900_ai_ci +ALTER VIEW v1 AS SELECT f2 FROM t1; +SHOW CREATE VIEW v1; +View Create View character_set_client collation_connection +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`u29908_1`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`f2` AS `f2` from `t1` utf8mb4 utf8mb4_0900_ai_ci +ALTER VIEW v2 AS SELECT f2 FROM t1; +SHOW CREATE VIEW v2; +View Create View character_set_client collation_connection +v2 CREATE ALGORITHM=UNDEFINED DEFINER=`u29908_1`@`localhost` SQL SECURITY INVOKER VIEW `v2` AS select `t1`.`f2` AS `f2` from `t1` utf8mb4 utf8mb4_0900_ai_ci +ALTER VIEW v1 AS SELECT f1 FROM t1; +SHOW CREATE VIEW v1; +View Create View character_set_client collation_connection +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`u29908_1`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`f1` AS `f1` from `t1` utf8mb4 utf8mb4_0900_ai_ci +ALTER VIEW v2 AS SELECT f1 FROM t1; +SHOW CREATE VIEW v2; +View Create View character_set_client collation_connection +v2 CREATE ALGORITHM=UNDEFINED DEFINER=`u29908_1`@`localhost` SQL SECURITY INVOKER VIEW `v2` AS select `t1`.`f1` AS `f1` from `t1` utf8mb4 utf8mb4_0900_ai_ci +DROP USER u29908_1@localhost; +Warnings: +Warning 4005 User 'u29908_1'@'localhost' is referenced as a definer account in a view. +DROP USER u29908_2@localhost; +DROP DATABASE mysqltest_29908; +####################################################################### +DROP DATABASE IF EXISTS mysqltest1; +DROP DATABASE IF EXISTS mysqltest2; +CREATE DATABASE mysqltest1; +CREATE DATABASE mysqltest2; +CREATE TABLE mysqltest1.t1(c1 INT); +CREATE TABLE mysqltest1.t2(c2 INT); +CREATE TABLE mysqltest1.t3(c3 INT); +CREATE TABLE mysqltest1.t4(c4 INT); +INSERT INTO mysqltest1.t1 VALUES (11), (12), (13), (14); +INSERT INTO mysqltest1.t2 VALUES (21), (22), (23), (24); +INSERT INTO mysqltest1.t3 VALUES (31), (32), (33), (34); +INSERT INTO mysqltest1.t4 VALUES (41), (42), (43), (44); +CREATE USER mysqltest_u1@localhost; +GRANT SELECT ON mysqltest1.t1 TO mysqltest_u1@localhost; +GRANT INSERT ON mysqltest1.t2 TO mysqltest_u1@localhost; +GRANT SELECT, UPDATE ON mysqltest1.t3 TO mysqltest_u1@localhost; +GRANT SELECT, DELETE ON mysqltest1.t4 TO mysqltest_u1@localhost; +GRANT ALL PRIVILEGES ON mysqltest2.* TO mysqltest_u1@localhost; + +---> connection: bug24040_con +SELECT * FROM mysqltest1.t1; +c1 +11 +12 +13 +14 +INSERT INTO mysqltest1.t2 VALUES(25); +UPDATE mysqltest1.t3 SET c3 = 331 WHERE c3 = 31; +DELETE FROM mysqltest1.t4 WHERE c4 = 44; +CREATE VIEW v1 AS SELECT * FROM mysqltest1.t1; +CREATE VIEW v2 AS SELECT * FROM mysqltest1.t2; +CREATE VIEW v3 AS SELECT * FROM mysqltest1.t3; +CREATE VIEW v4 AS SELECT * FROM mysqltest1.t4; +SELECT * FROM v1; +c1 +11 +12 +13 +14 +INSERT INTO v2 VALUES(26); +UPDATE v3 SET c3 = 332 WHERE c3 = 32; +DELETE FROM v4 WHERE c4 = 43; +CREATE VIEW v12 AS SELECT c1, c2 FROM mysqltest1.t1, mysqltest1.t2; +ERROR 42000: create view command denied to user 'mysqltest_u1'@'localhost' for column 'c2' in table 'v12' +CREATE VIEW v13 AS SELECT c1, c3 FROM mysqltest1.t1, mysqltest1.t3; +CREATE VIEW v14 AS SELECT c1, c4 FROM mysqltest1.t1, mysqltest1.t4; +CREATE VIEW v21 AS SELECT c2, c1 FROM mysqltest1.t2, mysqltest1.t1; +ERROR 42000: create view command denied to user 'mysqltest_u1'@'localhost' for column 'c1' in table 'v21' +CREATE VIEW v23 AS SELECT c2, c3 FROM mysqltest1.t2, mysqltest1.t3; +ERROR 42000: create view command denied to user 'mysqltest_u1'@'localhost' for column 'c3' in table 'v23' +CREATE VIEW v24 AS SELECT c2, c4 FROM mysqltest1.t2, mysqltest1.t4; +ERROR 42000: create view command denied to user 'mysqltest_u1'@'localhost' for column 'c4' in table 'v24' +CREATE VIEW v31 AS SELECT c3, c1 FROM mysqltest1.t3, mysqltest1.t1; +CREATE VIEW v32 AS SELECT c3, c2 FROM mysqltest1.t3, mysqltest1.t2; +ERROR 42000: create view command denied to user 'mysqltest_u1'@'localhost' for column 'c2' in table 'v32' +CREATE VIEW v34 AS SELECT c3, c4 FROM mysqltest1.t3, mysqltest1.t4; +CREATE VIEW v41 AS SELECT c4, c1 FROM mysqltest1.t4, mysqltest1.t1; +CREATE VIEW v42 AS SELECT c4, c2 FROM mysqltest1.t4, mysqltest1.t2; +ERROR 42000: create view command denied to user 'mysqltest_u1'@'localhost' for column 'c2' in table 'v42' +CREATE VIEW v43 AS SELECT c4, c3 FROM mysqltest1.t4, mysqltest1.t3; + +---> connection: default +SELECT * FROM mysqltest1.t1; +c1 +11 +12 +13 +14 +SELECT * FROM mysqltest1.t2; +c2 +21 +22 +23 +24 +25 +26 +SELECT * FROM mysqltest1.t3; +c3 +331 +332 +33 +34 +SELECT * FROM mysqltest1.t4; +c4 +41 +42 +DROP DATABASE mysqltest1; +DROP DATABASE mysqltest2; +DROP USER mysqltest_u1@localhost; +CREATE DATABASE db1; +USE db1; +CREATE TABLE t1(f1 INT, f2 INT); +CREATE VIEW v1 AS SELECT f1, f2 FROM t1; +CREATE USER foo; +GRANT SELECT (f1) ON t1 TO foo; +GRANT SELECT (f1) ON v1 TO foo; +USE db1; +SELECT f1 FROM t1; +f1 +SELECT f2 FROM t1; +ERROR 42000: SELECT command denied to user 'foo'@'localhost' for column 'f2' in table 't1' +SELECT * FROM t1; +ERROR 42000: SELECT command denied to user 'foo'@'localhost' for table 't1' +SELECT f1 FROM v1; +f1 +SELECT f2 FROM v1; +ERROR 42000: SELECT command denied to user 'foo'@'localhost' for column 'f2' in table 'v1' +SELECT * FROM v1; +ERROR 42000: SELECT command denied to user 'foo'@'localhost' for table 'v1' +USE test; +REVOKE SELECT (f1) ON db1.t1 FROM foo; +REVOKE SELECT (f1) ON db1.v1 FROM foo; +DROP USER foo; +DROP VIEW db1.v1; +DROP TABLE db1.t1; +DROP DATABASE db1; +Bug #11765687/#58677: +No privilege on table/view, but can know #rows / underlying table's name +create database mysqltest1; +create table mysqltest1.t1 (i int); +create table mysqltest1.t2 (j int); +create table mysqltest1.t3 (k int, secret int); +create user alice@localhost; +create user bob@localhost; +create user cecil@localhost; +create user dan@localhost; +create user eugene@localhost; +create user fiona@localhost; +create user greg@localhost; +create user han@localhost; +create user inga@localhost; +create user jamie@localhost; +create user karl@localhost; +create user lena@localhost; +create user mhairi@localhost; +create user noam@localhost; +create user olga@localhost; +create user pjotr@localhost; +create user quintessa@localhost; +grant all privileges on mysqltest1.* to alice@localhost with grant option; +... as alice +create view v1 as select * from t1; +create view v2 as select * from v1, t2; +create view v3 as select k from t3; +grant select on mysqltest1.v1 to bob@localhost; +grant show view on mysqltest1.v1 to cecil@localhost; +grant select, show view on mysqltest1.v1 to dan@localhost; +grant select on mysqltest1.t1 to dan@localhost; +grant select on mysqltest1.* to eugene@localhost; +grant select, show view on mysqltest1.v2 to fiona@localhost; +grant select, show view on mysqltest1.v2 to greg@localhost; +grant show view on mysqltest1.v1 to greg@localhost; +grant select(k) on mysqltest1.t3 to han@localhost; +grant select, show view on mysqltest1.v3 to han@localhost; +grant select on mysqltest1.t1 to inga@localhost; +grant select on mysqltest1.t2 to inga@localhost; +grant select on mysqltest1.v1 to inga@localhost; +grant select, show view on mysqltest1.v2 to inga@localhost; +grant select on mysqltest1.t1 to jamie@localhost; +grant select on mysqltest1.t2 to jamie@localhost; +grant show view on mysqltest1.v1 to jamie@localhost; +grant select, show view on mysqltest1.v2 to jamie@localhost; +grant select on mysqltest1.t1 to karl@localhost; +grant select on mysqltest1.t2 to karl@localhost; +grant select, show view on mysqltest1.v1 to karl@localhost; +grant select on mysqltest1.v2 to karl@localhost; +grant select on mysqltest1.t1 to lena@localhost; +grant select on mysqltest1.t2 to lena@localhost; +grant select, show view on mysqltest1.v1 to lena@localhost; +grant show view on mysqltest1.v2 to lena@localhost; +grant select on mysqltest1.t1 to mhairi@localhost; +grant select on mysqltest1.t2 to mhairi@localhost; +grant select, show view on mysqltest1.v1 to mhairi@localhost; +grant select, show view on mysqltest1.v2 to mhairi@localhost; +grant select on mysqltest1.t1 to noam@localhost; +grant select, show view on mysqltest1.v1 to noam@localhost; +grant select, show view on mysqltest1.v2 to noam@localhost; +grant select on mysqltest1.t2 to olga@localhost; +grant select, show view on mysqltest1.v1 to olga@localhost; +grant select, show view on mysqltest1.v2 to olga@localhost; +grant select on mysqltest1.t1 to pjotr@localhost; +grant select on mysqltest1.t2 to pjotr@localhost; +grant select, show view on mysqltest1.v2 to pjotr@localhost; +grant select, show view on mysqltest1.v1 to quintessa@localhost; +... as bob +select * from v1; +i +explain select * from v1; +ERROR HY000: EXPLAIN/SHOW can not be issued; lacking privileges for underlying table +... as cecil +select * from v1; +ERROR 42000: SELECT command denied to user 'cecil'@'localhost' for table 'v1' +explain select * from v1; +ERROR 42000: SELECT command denied to user 'cecil'@'localhost' for table 'v1' +... as dan +select * from v1; +i +explain select * from v1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `mysqltest1`.`t1`.`i` AS `i` from `mysqltest1`.`t1` +... as eugene +select * from v1; +i +explain select * from v1; +ERROR HY000: EXPLAIN/SHOW can not be issued; lacking privileges for underlying table +... as fiona +select * from v2; +i j +show create view v2; +View Create View character_set_client collation_connection +v2 CREATE ALGORITHM=UNDEFINED DEFINER=`alice`@`localhost` SQL SECURITY DEFINER VIEW `v2` AS select `v1`.`i` AS `i`,`t2`.`j` AS `j` from (`v1` join `t2`) utf8mb4 utf8mb4_0900_ai_ci +explain select * from t1; +ERROR 42000: SELECT command denied to user 'fiona'@'localhost' for table 't1' +explain select * from v1; +ERROR 42000: SELECT command denied to user 'fiona'@'localhost' for table 'v1' +explain select * from t2; +ERROR 42000: SELECT command denied to user 'fiona'@'localhost' for table 't2' +explain select * from v2; +ERROR HY000: EXPLAIN/SHOW can not be issued; lacking privileges for underlying table +... as greg +select * from v2; +i j +explain select * from v1; +ERROR 42000: SELECT command denied to user 'greg'@'localhost' for table 'v1' +explain select * from v2; +ERROR HY000: EXPLAIN/SHOW can not be issued; lacking privileges for underlying table +... as han +select * from t3; +ERROR 42000: SELECT command denied to user 'han'@'localhost' for table 't3' +explain select * from t3; +ERROR 42000: SELECT command denied to user 'han'@'localhost' for table 't3' +select k from t3; +k +explain select k from t3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `mysqltest1`.`t3`.`k` AS `k` from `mysqltest1`.`t3` +select * from v3; +k +explain select * from v3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `mysqltest1`.`t3`.`k` AS `k` from `mysqltest1`.`t3` +... as inga +select * from v2; +i j +explain select * from v2; +ERROR HY000: EXPLAIN/SHOW can not be issued; lacking privileges for underlying table +... as jamie +select * from v2; +i j +explain select * from v2; +ERROR HY000: EXPLAIN/SHOW can not be issued; lacking privileges for underlying table +... as karl +select * from v2; +i j +explain select * from v2; +ERROR HY000: EXPLAIN/SHOW can not be issued; lacking privileges for underlying table +... as lena +select * from v2; +ERROR 42000: SELECT command denied to user 'lena'@'localhost' for table 'v2' +explain select * from v2; +ERROR 42000: SELECT command denied to user 'lena'@'localhost' for table 'v2' +... as mhairi +select * from v2; +i j +explain select * from v2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `mysqltest1`.`t1`.`i` AS `i`,`mysqltest1`.`t2`.`j` AS `j` from `mysqltest1`.`t1` join `mysqltest1`.`t2` +... as noam +select * from v2; +i j +explain select * from v2; +ERROR HY000: EXPLAIN/SHOW can not be issued; lacking privileges for underlying table +... as olga +select * from v2; +i j +explain select * from v2; +ERROR HY000: EXPLAIN/SHOW can not be issued; lacking privileges for underlying table +... as pjotr +select * from v2; +i j +explain select * from v2; +ERROR HY000: EXPLAIN/SHOW can not be issued; lacking privileges for underlying table +... as quintessa +select * from v1; +i +explain select * from v1; +ERROR HY000: EXPLAIN/SHOW can not be issued; lacking privileges for underlying table +... as root again at last: clean-up time! +drop user alice@localhost; +Warnings: +Warning 4005 User 'alice'@'localhost' is referenced as a definer account in a view. +drop user bob@localhost; +drop user cecil@localhost; +drop user dan@localhost; +drop user eugene@localhost; +drop user fiona@localhost; +drop user greg@localhost; +drop user han@localhost; +drop user inga@localhost; +drop user jamie@localhost; +drop user karl@localhost; +drop user lena@localhost; +drop user mhairi@localhost; +drop user noam@localhost; +drop user olga@localhost; +drop user pjotr@localhost; +drop user quintessa@localhost; +drop database mysqltest1; +End of 5.0 tests. +DROP VIEW IF EXISTS v1; +DROP TABLE IF EXISTS t1; +CREATE TABLE t1 (i INT); +CREATE VIEW v1 AS SELECT * FROM t1; +ALTER VIEW v1 AS SELECT * FROM t1; +SHOW CREATE VIEW v1; +View Create View character_set_client collation_connection +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`i` AS `i` from `t1` utf8mb4 utf8mb4_0900_ai_ci +ALTER DEFINER=no_such@user_1 VIEW v1 AS SELECT * FROM t1; +Warnings: +Note 1449 The user specified as a definer ('no_such'@'user_1') does not exist +SHOW CREATE VIEW v1; +View Create View character_set_client collation_connection +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`no_such`@`user_1` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`i` AS `i` from `t1` utf8mb4 utf8mb4_0900_ai_ci +Warnings: +Note 1449 The user specified as a definer ('no_such'@'user_1') does not exist +ALTER ALGORITHM=MERGE VIEW v1 AS SELECT * FROM t1; +Warnings: +Note 1449 The user specified as a definer ('no_such'@'user_1') does not exist +SHOW CREATE VIEW v1; +View Create View character_set_client collation_connection +v1 CREATE ALGORITHM=MERGE DEFINER=`no_such`@`user_1` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`i` AS `i` from `t1` utf8mb4 utf8mb4_0900_ai_ci +Warnings: +Note 1449 The user specified as a definer ('no_such'@'user_1') does not exist +ALTER ALGORITHM=TEMPTABLE DEFINER=no_such@user_2 VIEW v1 AS SELECT * FROM t1; +Warnings: +Note 1449 The user specified as a definer ('no_such'@'user_2') does not exist +SHOW CREATE VIEW v1; +View Create View character_set_client collation_connection +v1 CREATE ALGORITHM=TEMPTABLE DEFINER=`no_such`@`user_2` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`i` AS `i` from `t1` utf8mb4 utf8mb4_0900_ai_ci +Warnings: +Note 1449 The user specified as a definer ('no_such'@'user_2') does not exist +DROP VIEW v1; +DROP TABLE t1; +CREATE USER mysqluser1@localhost; +CREATE DATABASE mysqltest1; +USE mysqltest1; +CREATE TABLE t1 ( a INT ); +CREATE TABLE t2 ( b INT ); +INSERT INTO t1 VALUES (1), (2); +INSERT INTO t2 VALUES (1), (2); +GRANT CREATE VIEW ON mysqltest1.* TO mysqluser1@localhost; +GRANT SELECT ON t1 TO mysqluser1@localhost; +GRANT INSERT ON t2 TO mysqluser1@localhost; +This would lead to failed assertion. +CREATE VIEW v1 AS SELECT a, b FROM t1, t2; +SELECT * FROM v1; +ERROR 42000: SELECT command denied to user 'mysqluser1'@'localhost' for table 'v1' +SELECT b FROM v1; +ERROR 42000: SELECT command denied to user 'mysqluser1'@'localhost' for table 'v1' +DROP TABLE t1, t2; +DROP VIEW v1; +DROP DATABASE mysqltest1; +DROP USER mysqluser1@localhost; +USE test; +End of 5.1 tests. +CREATE USER mysqluser1@localhost; +CREATE DATABASE mysqltest1; +USE mysqltest1; +CREATE TABLE t1 ( a INT, b INT ); +CREATE TABLE t2 ( a INT, b INT ); +CREATE VIEW v1 AS SELECT a, b FROM t1; +GRANT SELECT( a ) ON v1 TO mysqluser1@localhost; +GRANT UPDATE( b ) ON t2 TO mysqluser1@localhost; +SELECT * FROM mysqltest1.v1; +ERROR 42000: SELECT command denied to user 'mysqluser1'@'localhost' for table 'v1' +CREATE VIEW v1 AS SELECT * FROM mysqltest1.t2; +ERROR 42000: ANY command denied to user 'mysqluser1'@'localhost' for table 't2' +DROP TABLE t1, t2; +DROP VIEW v1; +DROP DATABASE mysqltest1; +DROP USER mysqluser1@localhost; +CREATE USER mysqluser1@localhost; +CREATE DATABASE mysqltest1; +USE mysqltest1; +CREATE VIEW v1 AS SELECT * FROM information_schema.tables LIMIT 1; +CREATE ALGORITHM = TEMPTABLE VIEW v2 AS SELECT 1 AS A; +CREATE VIEW test.v3 AS SELECT 1 AS a; +GRANT SELECT ON mysqltest1.* to mysqluser1@localhost; +GRANT ALL ON test.* TO mysqluser1@localhost; +PREPARE stmt_v1 FROM "SELECT * FROM mysqltest1.v1"; +PREPARE stmt_v2 FROM "SELECT * FROM mysqltest1.v2"; +REVOKE SELECT ON mysqltest1.* FROM mysqluser1@localhost; +EXECUTE stmt_v1; +ERROR 42000: SELECT command denied to user 'mysqluser1'@'localhost' for table 'v1' +EXECUTE stmt_v2; +ERROR 42000: SELECT command denied to user 'mysqluser1'@'localhost' for table 'v2' +PREPARE stmt FROM "SELECT a FROM v3"; +EXECUTE stmt; +a +1 +DROP VIEW v1, v2; +DROP DATABASE mysqltest1; +DROP VIEW test.v3; +DROP USER mysqluser1@localhost; +USE test; +# +# Bug#35996: SELECT + SHOW VIEW should be enough to display view +# definition +# +CREATE USER mysqluser1@localhost; +CREATE DATABASE mysqltest1; +CREATE DATABASE mysqltest2; +GRANT USAGE, SELECT, CREATE VIEW, SHOW VIEW +ON mysqltest2.* TO mysqluser1@localhost; +USE mysqltest1; +CREATE TABLE t1( a INT ); +CREATE TABLE t2( a INT, b INT ); +CREATE FUNCTION f1() RETURNS INT RETURN 1; +CREATE VIEW v1 AS SELECT 1 AS a; +CREATE VIEW v2 AS SELECT 1 AS a, 2 AS b; +GRANT SELECT ON TABLE t1 TO mysqluser1@localhost; +GRANT SELECT (a, b) ON TABLE t2 TO mysqluser1@localhost; +GRANT EXECUTE ON FUNCTION f1 TO mysqluser1@localhost; +GRANT SELECT ON TABLE v1 TO mysqluser1@localhost; +GRANT SELECT (a, b) ON TABLE v2 TO mysqluser1@localhost; +CREATE VIEW v_t1 AS SELECT * FROM t1; +CREATE VIEW v_t2 AS SELECT * FROM t2; +CREATE VIEW v_f1 AS SELECT f1() AS a; +CREATE VIEW v_v1 AS SELECT * FROM v1; +CREATE VIEW v_v2 AS SELECT * FROM v2; +GRANT SELECT, SHOW VIEW ON v_t1 TO mysqluser1@localhost; +GRANT SELECT, SHOW VIEW ON v_t2 TO mysqluser1@localhost; +GRANT SELECT, SHOW VIEW ON v_f1 TO mysqluser1@localhost; +GRANT SELECT, SHOW VIEW ON v_v1 TO mysqluser1@localhost; +GRANT SELECT, SHOW VIEW ON v_v2 TO mysqluser1@localhost; +CREATE VIEW v_mysqluser1_t1 AS SELECT * FROM mysqltest1.t1; +CREATE VIEW v_mysqluser1_t2 AS SELECT * FROM mysqltest1.t2; +CREATE VIEW v_mysqluser1_f1 AS SELECT mysqltest1.f1() AS a; +CREATE VIEW v_mysqluser1_v1 AS SELECT * FROM mysqltest1.v1; +CREATE VIEW v_mysqluser1_v2 AS SELECT * FROM mysqltest1.v2; +SHOW CREATE VIEW mysqltest1.v_t1; +View Create View character_set_client collation_connection +v_t1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `mysqltest1`.`v_t1` AS select `mysqltest1`.`t1`.`a` AS `a` from `mysqltest1`.`t1` utf8mb4 utf8mb4_0900_ai_ci +SHOW CREATE VIEW mysqltest1.v_t2; +View Create View character_set_client collation_connection +v_t2 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `mysqltest1`.`v_t2` AS select `mysqltest1`.`t2`.`a` AS `a`,`mysqltest1`.`t2`.`b` AS `b` from `mysqltest1`.`t2` utf8mb4 utf8mb4_0900_ai_ci +SHOW CREATE VIEW mysqltest1.v_f1; +View Create View character_set_client collation_connection +v_f1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `mysqltest1`.`v_f1` AS select `f1`() AS `a` utf8mb4 utf8mb4_0900_ai_ci +SHOW CREATE VIEW mysqltest1.v_v1; +View Create View character_set_client collation_connection +v_v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `mysqltest1`.`v_v1` AS select `mysqltest1`.`v1`.`a` AS `a` from `mysqltest1`.`v1` utf8mb4 utf8mb4_0900_ai_ci +SHOW CREATE VIEW mysqltest1.v_v2; +View Create View character_set_client collation_connection +v_v2 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `mysqltest1`.`v_v2` AS select `mysqltest1`.`v2`.`a` AS `a`,`mysqltest1`.`v2`.`b` AS `b` from `mysqltest1`.`v2` utf8mb4 utf8mb4_0900_ai_ci +SHOW CREATE VIEW v_mysqluser1_t1; +View Create View character_set_client collation_connection +v_mysqluser1_t1 CREATE ALGORITHM=UNDEFINED DEFINER=`mysqluser1`@`localhost` SQL SECURITY DEFINER VIEW `v_mysqluser1_t1` AS select `mysqltest1`.`t1`.`a` AS `a` from `mysqltest1`.`t1` utf8mb4 utf8mb4_0900_ai_ci +SHOW CREATE VIEW v_mysqluser1_t2; +View Create View character_set_client collation_connection +v_mysqluser1_t2 CREATE ALGORITHM=UNDEFINED DEFINER=`mysqluser1`@`localhost` SQL SECURITY DEFINER VIEW `v_mysqluser1_t2` AS select `mysqltest1`.`t2`.`a` AS `a`,`mysqltest1`.`t2`.`b` AS `b` from `mysqltest1`.`t2` utf8mb4 utf8mb4_0900_ai_ci +SHOW CREATE VIEW v_mysqluser1_f1; +View Create View character_set_client collation_connection +v_mysqluser1_f1 CREATE ALGORITHM=UNDEFINED DEFINER=`mysqluser1`@`localhost` SQL SECURITY DEFINER VIEW `v_mysqluser1_f1` AS select `mysqltest1`.`f1`() AS `a` utf8mb4 utf8mb4_0900_ai_ci +SHOW CREATE VIEW v_mysqluser1_v1; +View Create View character_set_client collation_connection +v_mysqluser1_v1 CREATE ALGORITHM=UNDEFINED DEFINER=`mysqluser1`@`localhost` SQL SECURITY DEFINER VIEW `v_mysqluser1_v1` AS select `mysqltest1`.`v1`.`a` AS `a` from `mysqltest1`.`v1` utf8mb4 utf8mb4_0900_ai_ci +SHOW CREATE VIEW v_mysqluser1_v2; +View Create View character_set_client collation_connection +v_mysqluser1_v2 CREATE ALGORITHM=UNDEFINED DEFINER=`mysqluser1`@`localhost` SQL SECURITY DEFINER VIEW `v_mysqluser1_v2` AS select `mysqltest1`.`v2`.`a` AS `a`,`mysqltest1`.`v2`.`b` AS `b` from `mysqltest1`.`v2` utf8mb4 utf8mb4_0900_ai_ci +REVOKE SELECT ON TABLE t1 FROM mysqluser1@localhost; +REVOKE SELECT (a) ON TABLE t2 FROM mysqluser1@localhost; +REVOKE EXECUTE ON FUNCTION f1 FROM mysqluser1@localhost; +REVOKE SELECT ON TABLE v1 FROM mysqluser1@localhost; +SHOW CREATE VIEW mysqltest1.v_t1; +View Create View character_set_client collation_connection +v_t1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `mysqltest1`.`v_t1` AS select `mysqltest1`.`t1`.`a` AS `a` from `mysqltest1`.`t1` utf8mb4 utf8mb4_0900_ai_ci +SHOW CREATE VIEW mysqltest1.v_t2; +View Create View character_set_client collation_connection +v_t2 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `mysqltest1`.`v_t2` AS select `mysqltest1`.`t2`.`a` AS `a`,`mysqltest1`.`t2`.`b` AS `b` from `mysqltest1`.`t2` utf8mb4 utf8mb4_0900_ai_ci +SHOW CREATE VIEW mysqltest1.v_f1; +View Create View character_set_client collation_connection +v_f1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `mysqltest1`.`v_f1` AS select `f1`() AS `a` utf8mb4 utf8mb4_0900_ai_ci +SHOW CREATE VIEW mysqltest1.v_v1; +View Create View character_set_client collation_connection +v_v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `mysqltest1`.`v_v1` AS select `mysqltest1`.`v1`.`a` AS `a` from `mysqltest1`.`v1` utf8mb4 utf8mb4_0900_ai_ci +SHOW CREATE VIEW mysqltest1.v_v2; +View Create View character_set_client collation_connection +v_v2 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `mysqltest1`.`v_v2` AS select `mysqltest1`.`v2`.`a` AS `a`,`mysqltest1`.`v2`.`b` AS `b` from `mysqltest1`.`v2` utf8mb4 utf8mb4_0900_ai_ci +SHOW CREATE VIEW v_mysqluser1_t1; +View Create View character_set_client collation_connection +v_mysqluser1_t1 CREATE ALGORITHM=UNDEFINED DEFINER=`mysqluser1`@`localhost` SQL SECURITY DEFINER VIEW `v_mysqluser1_t1` AS select `mysqltest1`.`t1`.`a` AS `a` from `mysqltest1`.`t1` utf8mb4 utf8mb4_0900_ai_ci +SHOW CREATE VIEW v_mysqluser1_t2; +View Create View character_set_client collation_connection +v_mysqluser1_t2 CREATE ALGORITHM=UNDEFINED DEFINER=`mysqluser1`@`localhost` SQL SECURITY DEFINER VIEW `v_mysqluser1_t2` AS select `mysqltest1`.`t2`.`a` AS `a`,`mysqltest1`.`t2`.`b` AS `b` from `mysqltest1`.`t2` utf8mb4 utf8mb4_0900_ai_ci +SHOW CREATE VIEW v_mysqluser1_f1; +View Create View character_set_client collation_connection +v_mysqluser1_f1 CREATE ALGORITHM=UNDEFINED DEFINER=`mysqluser1`@`localhost` SQL SECURITY DEFINER VIEW `v_mysqluser1_f1` AS select `mysqltest1`.`f1`() AS `a` utf8mb4 utf8mb4_0900_ai_ci +SHOW CREATE VIEW v_mysqluser1_v1; +View Create View character_set_client collation_connection +v_mysqluser1_v1 CREATE ALGORITHM=UNDEFINED DEFINER=`mysqluser1`@`localhost` SQL SECURITY DEFINER VIEW `v_mysqluser1_v1` AS select `mysqltest1`.`v1`.`a` AS `a` from `mysqltest1`.`v1` utf8mb4 utf8mb4_0900_ai_ci +SHOW CREATE VIEW v_mysqluser1_v2; +View Create View character_set_client collation_connection +v_mysqluser1_v2 CREATE ALGORITHM=UNDEFINED DEFINER=`mysqluser1`@`localhost` SQL SECURITY DEFINER VIEW `v_mysqluser1_v2` AS select `mysqltest1`.`v2`.`a` AS `a`,`mysqltest1`.`v2`.`b` AS `b` from `mysqltest1`.`v2` utf8mb4 utf8mb4_0900_ai_ci +# Testing the case when the views reference missing objects. +# Obviously, there are no privileges to check for, so we +# need only each object type once. +DROP TABLE t1; +DROP FUNCTION f1; +DROP VIEW v1; +SHOW CREATE VIEW mysqltest1.v_t1; +View Create View character_set_client collation_connection +v_t1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `mysqltest1`.`v_t1` AS select `mysqltest1`.`t1`.`a` AS `a` from `mysqltest1`.`t1` utf8mb4 utf8mb4_0900_ai_ci +Warnings: +Warning 1356 View 'mysqltest1.v_t1' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +SHOW CREATE VIEW mysqltest1.v_f1; +View Create View character_set_client collation_connection +v_f1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `mysqltest1`.`v_f1` AS select `f1`() AS `a` utf8mb4 utf8mb4_0900_ai_ci +Warnings: +Warning 1356 View 'mysqltest1.v_f1' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +SHOW CREATE VIEW mysqltest1.v_v1; +View Create View character_set_client collation_connection +v_v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `mysqltest1`.`v_v1` AS select `mysqltest1`.`v1`.`a` AS `a` from `mysqltest1`.`v1` utf8mb4 utf8mb4_0900_ai_ci +Warnings: +Warning 1356 View 'mysqltest1.v_v1' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +SHOW CREATE VIEW v_mysqluser1_t1; +View Create View character_set_client collation_connection +v_mysqluser1_t1 CREATE ALGORITHM=UNDEFINED DEFINER=`mysqluser1`@`localhost` SQL SECURITY DEFINER VIEW `v_mysqluser1_t1` AS select `mysqltest1`.`t1`.`a` AS `a` from `mysqltest1`.`t1` utf8mb4 utf8mb4_0900_ai_ci +Warnings: +Warning 1356 View 'mysqltest2.v_mysqluser1_t1' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +SHOW CREATE VIEW v_mysqluser1_f1; +View Create View character_set_client collation_connection +v_mysqluser1_f1 CREATE ALGORITHM=UNDEFINED DEFINER=`mysqluser1`@`localhost` SQL SECURITY DEFINER VIEW `v_mysqluser1_f1` AS select `mysqltest1`.`f1`() AS `a` utf8mb4 utf8mb4_0900_ai_ci +Warnings: +Warning 1356 View 'mysqltest2.v_mysqluser1_f1' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +SHOW CREATE VIEW v_mysqluser1_v1; +View Create View character_set_client collation_connection +v_mysqluser1_v1 CREATE ALGORITHM=UNDEFINED DEFINER=`mysqluser1`@`localhost` SQL SECURITY DEFINER VIEW `v_mysqluser1_v1` AS select `mysqltest1`.`v1`.`a` AS `a` from `mysqltest1`.`v1` utf8mb4 utf8mb4_0900_ai_ci +Warnings: +Warning 1356 View 'mysqltest2.v_mysqluser1_v1' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +REVOKE SHOW VIEW ON v_t1 FROM mysqluser1@localhost; +REVOKE SHOW VIEW ON v_f1 FROM mysqluser1@localhost; +REVOKE SHOW VIEW ON v_v1 FROM mysqluser1@localhost; +SHOW CREATE VIEW mysqltest1.v_t1; +ERROR 42000: SHOW VIEW command denied to user 'mysqluser1'@'localhost' for table 'v_t1' +SHOW CREATE VIEW mysqltest1.v_f1; +ERROR 42000: SHOW VIEW command denied to user 'mysqluser1'@'localhost' for table 'v_f1' +SHOW CREATE VIEW mysqltest1.v_v1; +ERROR 42000: SHOW VIEW command denied to user 'mysqluser1'@'localhost' for table 'v_v1' +SHOW CREATE VIEW v_mysqluser1_t1; +View Create View character_set_client collation_connection +v_mysqluser1_t1 CREATE ALGORITHM=UNDEFINED DEFINER=`mysqluser1`@`localhost` SQL SECURITY DEFINER VIEW `v_mysqluser1_t1` AS select `mysqltest1`.`t1`.`a` AS `a` from `mysqltest1`.`t1` utf8mb4 utf8mb4_0900_ai_ci +Warnings: +Warning 1356 View 'mysqltest2.v_mysqluser1_t1' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +SHOW CREATE VIEW v_mysqluser1_f1; +View Create View character_set_client collation_connection +v_mysqluser1_f1 CREATE ALGORITHM=UNDEFINED DEFINER=`mysqluser1`@`localhost` SQL SECURITY DEFINER VIEW `v_mysqluser1_f1` AS select `mysqltest1`.`f1`() AS `a` utf8mb4 utf8mb4_0900_ai_ci +Warnings: +Warning 1356 View 'mysqltest2.v_mysqluser1_f1' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +SHOW CREATE VIEW v_mysqluser1_v1; +View Create View character_set_client collation_connection +v_mysqluser1_v1 CREATE ALGORITHM=UNDEFINED DEFINER=`mysqluser1`@`localhost` SQL SECURITY DEFINER VIEW `v_mysqluser1_v1` AS select `mysqltest1`.`v1`.`a` AS `a` from `mysqltest1`.`v1` utf8mb4 utf8mb4_0900_ai_ci +Warnings: +Warning 1356 View 'mysqltest2.v_mysqluser1_v1' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +DROP USER mysqluser1@localhost; +Warnings: +Warning 4005 User 'mysqluser1'@'localhost' is referenced as a definer account in a view. +DROP DATABASE mysqltest1; +DROP DATABASE mysqltest2; +USE test; +CREATE TABLE t1( a INT ); +CREATE DEFINER = no_such_user@no_such_host VIEW v1 AS SELECT * FROM t1; +Warnings: +Note 1449 The user specified as a definer ('no_such_user'@'no_such_host') does not exist +SHOW CREATE VIEW v1; +View Create View character_set_client collation_connection +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`no_such_user`@`no_such_host` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`a` AS `a` from `t1` utf8mb4 utf8mb4_0900_ai_ci +Warnings: +Note 1449 The user specified as a definer ('no_such_user'@'no_such_host') does not exist +DROP TABLE t1; +DROP VIEW v1; +# +# Bug #46019: ERROR 1356 When selecting from within another +# view that has Group By +# +CREATE DATABASE mysqltest1; +USE mysqltest1; +CREATE TABLE t1 (a INT); +CREATE SQL SECURITY INVOKER VIEW v1 AS SELECT a FROM t1 GROUP BY a; +CREATE SQL SECURITY INVOKER VIEW v2 AS SELECT a FROM v1; +CREATE USER mysqluser1; +GRANT SELECT ON TABLE t1 TO mysqluser1; +GRANT SELECT, SHOW VIEW ON TABLE v1 TO mysqluser1; +GRANT SELECT, SHOW VIEW ON TABLE v2 TO mysqluser1; +SELECT a FROM v1; +a +SELECT a FROM v2; +a +DROP USER mysqluser1; +DROP DATABASE mysqltest1; +USE test; +# +# Bug#47734: Assertion failed: ! is_set() when locking a view with non-existing definer +# +CREATE DEFINER=`unknown`@`unknown` SQL SECURITY DEFINER VIEW v1 AS SELECT 1; +Warnings: +Note 1449 The user specified as a definer ('unknown'@'unknown') does not exist +LOCK TABLES v1 READ; +ERROR HY000: The user specified as a definer ('unknown'@'unknown') does not exist +DROP VIEW v1; +# +# Bug #58499 "DEFINER-security view selecting from INVOKER-security view +# access check wrong". +# +# Check that we correctly handle privileges for various combinations +# of INVOKER and DEFINER-security views using each other. +CREATE DATABASE mysqltest1; +USE mysqltest1; +CREATE TABLE t1 (i INT); +CREATE TABLE t2 (j INT); +INSERT INTO t1 VALUES (1); +INSERT INTO t2 VALUES (2); +# +# 1) DEFINER-security view uses INVOKER-security view (covers +# scenario originally described in the bug report). +CREATE SQL SECURITY INVOKER VIEW v1_uses_t1 AS SELECT * FROM t1; +CREATE SQL SECURITY INVOKER VIEW v1_uses_t2 AS SELECT * FROM t2; +CREATE USER 'mysqluser1'@'%'; +GRANT CREATE VIEW ON mysqltest1.* TO 'mysqluser1'@'%'; +GRANT SELECT ON t1 TO 'mysqluser1'@'%'; +# To be able create 'v2_uses_t2' we also need select on t2. +GRANT SELECT ON t2 TO 'mysqluser1'@'%'; +GRANT SELECT ON v1_uses_t1 TO 'mysqluser1'@'%'; +GRANT SELECT ON v1_uses_t2 TO 'mysqluser1'@'%'; +# +# Connection 'mysqluser1'. +CREATE SQL SECURITY DEFINER VIEW v2_uses_t1 AS SELECT * FROM v1_uses_t1; +CREATE SQL SECURITY DEFINER VIEW v2_uses_t2 AS SELECT * FROM v1_uses_t2; +# +# Connection 'default'. +CREATE USER 'mysqluser2'@'%'; +GRANT SELECT ON v2_uses_t1 TO 'mysqluser2'@'%'; +GRANT SELECT ON v2_uses_t2 TO 'mysqluser2'@'%'; +GRANT SELECT ON t2 TO 'mysqluser2'@'%'; +GRANT CREATE VIEW ON mysqltest1.* TO 'mysqluser2'@'%'; +# Make 'mysqluser1' unable to access t2. +REVOKE SELECT ON t2 FROM 'mysqluser1'@'%'; +# +# Connection 'mysqluser2'. +# The below statement should succeed thanks to suid nature of v2_uses_t1. +SELECT * FROM v2_uses_t1; +i +1 +# The below statement should fail due to suid nature of v2_uses_t2. +SELECT * FROM v2_uses_t2; +ERROR HY000: View 'mysqltest1.v2_uses_t2' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +# +# 2) INVOKER-security view uses INVOKER-security view. +# +# Connection 'default'. +DROP VIEW v2_uses_t1, v2_uses_t2; +CREATE SQL SECURITY INVOKER VIEW v2_uses_t1 AS SELECT * FROM v1_uses_t1; +CREATE SQL SECURITY INVOKER VIEW v2_uses_t2 AS SELECT * FROM v1_uses_t2; +GRANT SELECT ON v2_uses_t1 TO 'mysqluser1'@'%'; +GRANT SELECT ON v2_uses_t2 TO 'mysqluser1'@'%'; +GRANT SELECT ON v1_uses_t1 TO 'mysqluser2'@'%'; +GRANT SELECT ON v1_uses_t2 TO 'mysqluser2'@'%'; +# +# Connection 'mysqluser1'. +# For both versions of 'v2' 'mysqluser1' privileges should be used. +SELECT * FROM v2_uses_t1; +i +1 +SELECT * FROM v2_uses_t2; +ERROR HY000: View 'mysqltest1.v2_uses_t2' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +# +# Connection 'mysqluser2'. +# And now for both versions of 'v2' 'mysqluser2' privileges should +# be used. +SELECT * FROM v2_uses_t1; +ERROR HY000: View 'mysqltest1.v2_uses_t1' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +SELECT * FROM v2_uses_t2; +j +2 +# +# 3) INVOKER-security view uses DEFINER-security view. +# +# Connection 'default'. +DROP VIEW v1_uses_t1, v1_uses_t2; +# To be able create 'v1_uses_t2' we also need select on t2. +GRANT SELECT ON t2 TO 'mysqluser1'@'%'; +# +# Connection 'mysqluser1'. +CREATE SQL SECURITY DEFINER VIEW v1_uses_t1 AS SELECT * FROM t1; +CREATE SQL SECURITY DEFINER VIEW v1_uses_t2 AS SELECT * FROM t2; +# +# Connection 'default'. +# Make 'mysqluser1' unable to access t2. +REVOKE SELECT ON t2 FROM 'mysqluser1'@'%'; +# +# Connection 'mysqluser2'. +# Due to suid nature of v1_uses_t1 and v1_uses_t2 the first +# select should succeed and the second select should fail. +SELECT * FROM v2_uses_t1; +i +1 +SELECT * FROM v2_uses_t2; +ERROR HY000: View 'mysqltest1.v2_uses_t2' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +# +# 4) DEFINER-security view uses DEFINER-security view. +# +# Connection 'default'. +DROP VIEW v2_uses_t1, v2_uses_t2; +# To be able create 'v2_uses_t2' we also need select on t2. +GRANT SELECT ON t2 TO 'mysqluser1'@'%'; +# +# Connection 'mysqluser2'. +CREATE SQL SECURITY DEFINER VIEW v2_uses_t1 AS SELECT * FROM v1_uses_t1; +CREATE SQL SECURITY DEFINER VIEW v2_uses_t2 AS SELECT * FROM v1_uses_t2; +# +# Connection 'default'. +# Make 'mysqluser1' unable to access t2. +REVOKE SELECT ON t2 FROM 'mysqluser1'@'%'; +# +# Connection 'mysqluser2'. +# Again privileges of creator of innermost views should apply. +SELECT * FROM v2_uses_t1; +i +1 +SELECT * FROM v2_uses_t2; +ERROR HY000: View 'mysqltest1.v2_uses_t2' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +USE test; +DROP DATABASE mysqltest1; +DROP USER 'mysqluser1'@'%'; +DROP USER 'mysqluser2'@'%'; +# +# Test for bug #11766767 - "59957: VIEW USING MERGE PERMISSIONS +# IN MULTI-TABLE UPDATE". +# +drop database if exists mysqltest1; +drop database if exists mysqltest2; +# +# Prepare playground. +create database mysqltest1; +create database mysqltest2; +create user user_11766767; +grant select on mysqltest1.* to user_11766767; +grant all on mysqltest2.* to user_11766767; +use mysqltest1; +create table t1 (id int primary key, val varchar(20)); +insert into t1 values (1, 'test1'); +create table t11 (id int primary key); +insert into t11 values (1); +create algorithm=temptable view v1_temp as select * from t1; +create algorithm=merge view v1_merge as select * from t1; +create algorithm=temptable view v11_temp as +select t1.id as id, t1.val as val from t1, t11 where t1.id= t11.id; +create algorithm=merge view v11_merge as +select t1.id as id, t1.val as val from t1, t11 where t1.id= t11.id; +use mysqltest2; +create table t2 (id int primary key, val varchar(20)); +insert into t2 values (1, 'test2'); +create table t21 (id int primary key); +insert into t21 values (1); +create algorithm=temptable view v2_temp as select * from t2; +create algorithm=merge view v2_merge as select * from t2; +create algorithm=temptable view v21_temp as +select t2.id as id, t2.val as val from t2, t21 where t2.id= t21.id; +create algorithm=merge view v21_merge as +select t2.id as id, t2.val as val from t2, t21 where t2.id= t21.id; +create algorithm=temptable sql security invoker view v3_temp as +select t1.id as id, t1.val as val from mysqltest1.t1 as t1, mysqltest1.t11 as t11 +where t1.id = t11.id; +create algorithm=merge sql security invoker view v3_merge as +select t1.id as id, t1.val as val from mysqltest1.t1 as t1, mysqltest1.t11 as t11 +where t1.id = t11.id; +create sql security invoker view v31 as +select t2.id as id, t2.val as val from mysqltest2.t2 as t2, mysqltest1.t11 as t11 +where t2.id = t11.id; +create sql security invoker view v4 as +select t2.id as id, t2.val as val from mysqltest2.t2 as t2, mysqltest1.v1_merge as v1 +where t2.id = v1.id; +create sql security invoker view v41 as +select v1.id as id, v1.val as val from mysqltest2.t2 as t2, mysqltest1.v1_merge as v1 +where t2.id = v1.id; +create sql security invoker view v42 as +select v2.id as id, v2.val as val from mysqltest2.t2 as t2, mysqltest2.v2_merge as v2 +where t2.id = v2.id; +# +# Connect as user_11766767 +# +# A) Check how we handle privilege checking in multi-update for +# directly used views. +# +# A.1) Originally reported problem, view is used in read-only mode. +# This should work with only SELECT privilege for both mergeable +# and temptable algorithms. +update mysqltest2.t2 as t2, mysqltest1.v1_merge as v1 set t2.val= 'test3' + where t2.id= v1.id; +update mysqltest2.t2 as t2, mysqltest1.v1_temp as v1 set t2.val= 'test4' + where t2.id= v1.id; +# +# A.2) If view is updated an UPDATE privilege on it is required. +# Temptable views can't be updated. +update mysqltest2.t2 as t2, mysqltest1.v1_merge as v1 set v1.val= 'test5' + where t2.id= v1.id; +ERROR 42000: UPDATE command denied to user 'user_11766767'@'localhost' for column 'val' in table 'v1_merge' +update mysqltest1.t1 as t1, mysqltest2.v2_merge as v2 set v2.val= 'test6' + where t1.id= v2.id; +# +# Note that the below error is OK even though user lacks UPDATE +# privilege on v1_temp since he/she still has SELECT privilege on +# this view. +update mysqltest2.t2 as t2, mysqltest1.v1_temp as v1 set v1.val= 'test7' + where t2.id= v1.id; +ERROR HY000: The target table v1 of the UPDATE is not updatable +update mysqltest1.t1 as t1, mysqltest2.v2_temp as v2 set v2.val= 'test8' + where t1.id= v2.id; +ERROR HY000: The target table v2 of the UPDATE is not updatable +# +# A.3) This also works for correctly for multi-table views. +# When usage is read-only SELECT is enough. +update mysqltest2.t2 as t2, mysqltest1.v11_merge as v11 set t2.val= 'test9' + where t2.id= v11.id; +update mysqltest2.t2 as t2, mysqltest1.v11_temp as v11 set t2.val= 'test10' + where t2.id= v11.id; +# When one of view's tables is updated, UPDATE is required +# on a view. +update mysqltest2.t2 as t2, mysqltest1.v11_merge as v11 set v11.val= 'test11' + where t2.id= v11.id; +ERROR 42000: UPDATE command denied to user 'user_11766767'@'localhost' for column 'val' in table 'v11_merge' +update mysqltest1.t1 as t1, mysqltest2.v21_merge as v21 set v21.val= 'test12' + where t1.id= v21.id; +# As before, temptable views are not updateable. +update mysqltest2.t2 as t2, mysqltest1.v11_temp as v11 set v11.val= 'test13' + where t2.id= v11.id; +ERROR HY000: The target table v11 of the UPDATE is not updatable +update mysqltest1.t1 as t1, mysqltest2.v21_temp as v21 set v21.val= 'test14' + where t1.id= v21.id; +ERROR HY000: The target table v21 of the UPDATE is not updatable +# +# B) Now check that correct privileges are required on underlying +# tables. To simplify this part of test we will use SECURITY +# INVOKER views in it. +# +# B.1) In case when view is used for read only it is enough to have +# SELECT on its underlying tables. +update mysqltest2.t2 as t2, mysqltest2.v3_merge as v3 set t2.val= 'test15' + where t2.id= v3.id; +update mysqltest2.t2 as t2, mysqltest2.v3_temp as v3 set t2.val= 'test16' + where t2.id= v3.id; +# +# B.2) If view is updated, UPDATE privilege on the table being updated +# is required (since we already checked that temptable views are +# not updateable we don't test them here). +update mysqltest2.t2 as t2, mysqltest2.v3_merge as v3 set v3.val= 'test17' + where t2.id= v3.id; +ERROR HY000: View 'mysqltest2.v3_merge' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +update mysqltest1.t11 as t11, mysqltest2.v31 as v31 set v31.val= 'test18' + where t11.id= v31.id; +# +# C) Finally, check how we handle privilege checking in case when +# view is used through another view. Again we will use SECURITY +# INVOKER views for simplicity. +# +# C.1) As usual, when a view used by another view is going to be used +# in read-only fashion, only SELECT privilege is necessary. +update mysqltest1.t11 as t11, mysqltest2.v4 as v4 set v4.val= 'test19' + where t11.id= v4.id; +# +# C.2) If one of underlying tables of the view is updated then +# UPDATE on a view is necessary. +update mysqltest1.t11 as t11, mysqltest2.v41 as v4 set v4.val= 'test20' + where t11.id= v4.id; +ERROR HY000: View 'mysqltest2.v41' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +update mysqltest1.t11 as t11, mysqltest2.v42 as v4 set v4.val= 'test20' + where t11.id= v4.id; +# +# Clean-up. +# +# Switching to connection 'default'. +drop user user_11766767; +drop database mysqltest1; +drop database mysqltest2; +# +# WL#5275 Process subqueries in FROM clause in the same way as view +# Extended testing of column privileges for views +# +CREATE DATABASE test1; +USE test1; +CREATE USER user1@localhost; +CREATE TABLE test1.t1 +(cn CHAR(1), cs CHAR(1), ci CHAR(1), cu CHAR(1), cus CHAR(1)); +GRANT SELECT(cs,cus) ON test1.t1 TO user1@localhost; +GRANT INSERT(ci) ON test1.t1 TO user1@localhost; +GRANT UPDATE(cu,cus) ON test1.t1 TO user1@localhost; +INSERT INTO test1.t1 VALUES('0', '0', '0', '0', '0'); +CREATE TABLE test1.single (a INTEGER); +GRANT ALL PRIVILEGES ON test1.single TO user1@localhost; +INSERT INTO test1.single VALUES(1); +CREATE SQL SECURITY INVOKER VIEW test1.v1_none AS +SELECT * FROM test1.t1; +CREATE SQL SECURITY INVOKER VIEW test1.v1_all AS +SELECT * FROM test1.t1; +GRANT SELECT,INSERT,UPDATE,DELETE ON test1.v1_all TO user1@localhost; +CREATE SQL SECURITY INVOKER VIEW test1.v1_same AS +SELECT * FROM test1.t1; +GRANT SELECT(cs,cus) ON test1.v1_same TO user1@localhost; +GRANT INSERT(ci) ON test1.v1_same TO user1@localhost; +GRANT UPDATE(cu,cus) ON test1.v1_same TO user1@localhost; +CREATE SQL SECURITY INVOKER VIEW test1.v1_cross AS +SELECT * FROM test1.t1; +GRANT SELECT(cu,ci) ON test1.v1_cross TO user1@localhost; +GRANT INSERT(cus) ON test1.v1_cross TO user1@localhost; +GRANT UPDATE(cs) ON test1.v1_cross TO user1@localhost; +CREATE SQL SECURITY INVOKER VIEW test1.v1_middle AS +SELECT * FROM test1.t1; +GRANT SELECT(cus) ON test1.v1_middle TO user1@localhost; +CREATE SQL SECURITY INVOKER VIEW test1.v1_multi AS +SELECT * FROM test1.v1_middle; +GRANT SELECT(cs,cus) ON test1.v1_multi TO user1@localhost; +GRANT INSERT(ci) ON test1.v1_multi TO user1@localhost; +GRANT UPDATE(cu,cus) ON test1.v1_multi TO user1@localhost; +CREATE SQL SECURITY INVOKER VIEW test1.v1_renamed AS +SELECT cn AS cs, cn AS cx, cs AS cus, cs AS cy FROM test1.t1; +GRANT SELECT(cs,cus) ON test1.v1_renamed TO user1@localhost; +# Connect as user1 on database test +# Test access to a base table +SELECT cs, cus FROM test1.t1; +cs cus +0 0 +SELECT * FROM test1.t1; +ERROR 42000: SELECT command denied to user 'user1'@'localhost' for column 'cn' in table 't1' +SELECT cn FROM test1.t1; +ERROR 42000: SELECT command denied to user 'user1'@'localhost' for column 'cn' in table 't1' +SELECT ci FROM test1.t1; +ERROR 42000: SELECT command denied to user 'user1'@'localhost' for column 'ci' in table 't1' +SELECT cu FROM test1.t1; +ERROR 42000: SELECT command denied to user 'user1'@'localhost' for column 'cu' in table 't1' +SELECT cs FROM test1.t1 WHERE cs = '0'; +cs +0 +SELECT cs FROM test1.t1 WHERE cus = '0'; +cs +0 +SELECT cs FROM test1.t1 WHERE cn = '0'; +ERROR 42000: SELECT command denied to user 'user1'@'localhost' for column 'cn' in table 't1' +SELECT cs FROM test1.t1 WHERE ci = '0'; +ERROR 42000: SELECT command denied to user 'user1'@'localhost' for column 'ci' in table 't1' +SELECT cs FROM test1.t1 WHERE cu = '0'; +ERROR 42000: SELECT command denied to user 'user1'@'localhost' for column 'cu' in table 't1' +SELECT COUNT(*) AS c FROM test1.t1 GROUP BY cs; +c +1 +SELECT COUNT(*) AS c FROM test1.t1 GROUP BY cus; +c +1 +SELECT COUNT(*) AS c FROM test1.t1 GROUP BY cn; +ERROR 42000: SELECT command denied to user 'user1'@'localhost' for column 'cn' in table 't1' +SELECT COUNT(*) AS c FROM test1.t1 GROUP BY ci; +ERROR 42000: SELECT command denied to user 'user1'@'localhost' for column 'ci' in table 't1' +SELECT COUNT(*) AS c FROM test1.t1 GROUP BY cu; +ERROR 42000: SELECT command denied to user 'user1'@'localhost' for column 'cu' in table 't1' +SELECT COUNT(*) AS c FROM test1.t1 HAVING MIN(cs) = '0'; +c +1 +SELECT COUNT(*) AS c FROM test1.t1 HAVING MIN(cus) = '0'; +c +1 +SELECT COUNT(*) AS c FROM test1.t1 HAVING MIN(cn) = '0'; +ERROR 42000: SELECT command denied to user 'user1'@'localhost' for column 'cn' in table 't1' +SELECT COUNT(*) AS c FROM test1.t1 HAVING MIN(ci) = '0'; +ERROR 42000: SELECT command denied to user 'user1'@'localhost' for column 'ci' in table 't1' +SELECT COUNT(*) AS c FROM test1.t1 HAVING MIN(cu) = '0'; +ERROR 42000: SELECT command denied to user 'user1'@'localhost' for column 'cu' in table 't1' +SELECT COUNT(*) AS c FROM test1.t1 ORDER BY MIN(cs); +c +1 +SELECT COUNT(*) AS c FROM test1.t1 ORDER BY MIN(cus); +c +1 +SELECT COUNT(*) AS c FROM test1.t1 ORDER BY MIN(cn); +ERROR 42000: SELECT command denied to user 'user1'@'localhost' for column 'cn' in table 't1' +SELECT COUNT(*) AS c FROM test1.t1 ORDER BY MIN(ci); +ERROR 42000: SELECT command denied to user 'user1'@'localhost' for column 'ci' in table 't1' +SELECT COUNT(*) AS c FROM test1.t1 ORDER BY MIN(cu); +ERROR 42000: SELECT command denied to user 'user1'@'localhost' for column 'cu' in table 't1' +UPDATE test1.t1 SET cu='u'; +UPDATE test1.t1 SET cus='s' WHERE cus='0'; +UPDATE test1.t1, test1.single SET cu='u'; +UPDATE test1.t1, test1.single SET cus='s' WHERE cus='0'; +UPDATE test1.t1 SET cn='x'; +ERROR 42000: UPDATE command denied to user 'user1'@'localhost' for column 'cn' in table 't1' +UPDATE test1.t1, test1.single SET cn='x'; +ERROR 42000: UPDATE command denied to user 'user1'@'localhost' for column 'cn' in table 't1' +UPDATE test1.t1 SET cs='x'; +ERROR 42000: UPDATE command denied to user 'user1'@'localhost' for column 'cs' in table 't1' +UPDATE test1.t1, test1.single SET cs='x'; +ERROR 42000: UPDATE command denied to user 'user1'@'localhost' for column 'cs' in table 't1' +UPDATE test1.t1 SET ci='x'; +ERROR 42000: UPDATE command denied to user 'user1'@'localhost' for column 'ci' in table 't1' +UPDATE test1.t1, test1.single SET ci='x'; +ERROR 42000: UPDATE command denied to user 'user1'@'localhost' for column 'ci' in table 't1' +UPDATE test1.t1 SET cu='x' WHERE cn='0'; +ERROR 42000: SELECT command denied to user 'user1'@'localhost' for column 'cn' in table 't1' +UPDATE test1.t1, test1.single SET cu='x' WHERE cn='0'; +ERROR 42000: SELECT command denied to user 'user1'@'localhost' for column 'cn' in table 't1' +INSERT INTO test1.t1(ci) VALUES('i'); +INSERT INTO test1.t1(ci) SELECT 'i' FROM test1.single; +INSERT INTO test1.t1(ci) VALUES('i') +ON DUPLICATE KEY UPDATE cu='u'; +INSERT INTO test1.t1(ci) SELECT 'i' FROM test1.single +ON DUPLICATE KEY UPDATE cu='u'; +INSERT INTO test1.t1(cn) VALUES('x'); +ERROR 42000: INSERT command denied to user 'user1'@'localhost' for column 'cn' in table 't1' +INSERT INTO test1.t1(cn) SELECT 'x' FROM test1.single; +ERROR 42000: INSERT command denied to user 'user1'@'localhost' for column 'cn' in table 't1' +INSERT INTO test1.t1(cs) VALUES('x'); +ERROR 42000: INSERT command denied to user 'user1'@'localhost' for column 'cs' in table 't1' +INSERT INTO test1.t1(cs) SELECT 'x' FROM test1.single; +ERROR 42000: INSERT command denied to user 'user1'@'localhost' for column 'cs' in table 't1' +INSERT INTO test1.t1(cu) VALUES('x'); +ERROR 42000: INSERT command denied to user 'user1'@'localhost' for column 'cu' in table 't1' +INSERT INTO test1.t1(cu) SELECT 'x' FROM test1.single; +ERROR 42000: INSERT command denied to user 'user1'@'localhost' for column 'cu' in table 't1' +INSERT INTO test1.t1(cus) VALUES('x'); +ERROR 42000: INSERT command denied to user 'user1'@'localhost' for column 'cus' in table 't1' +INSERT INTO test1.t1(cus) SELECT 'x' FROM test1.single; +ERROR 42000: INSERT command denied to user 'user1'@'localhost' for column 'cus' in table 't1' +INSERT INTO test1.t1(ci) VALUES('i') +ON DUPLICATE KEY UPDATE cn='u'; +ERROR 42000: UPDATE command denied to user 'user1'@'localhost' for column 'cn' in table 't1' +INSERT INTO test1.t1(ci) SELECT 'i' FROM test1.single +ON DUPLICATE KEY UPDATE cn='u'; +ERROR 42000: UPDATE command denied to user 'user1'@'localhost' for column 'cn' in table 't1' +DELETE FROM test1.t1; +ERROR 42000: DELETE command denied to user 'user1'@'localhost' for table 't1' +DELETE FROM test1.t1 WHERE cs='0'; +ERROR 42000: DELETE command denied to user 'user1'@'localhost' for table 't1' +DELETE test1.t1 FROM test1.t1, test1.single WHERE cs='0'; +ERROR 42000: DELETE command denied to user 'user1'@'localhost' for table 't1' +# Test access to derived tables +SELECT * FROM (SELECT cs FROM test1.t1) AS dt; +cs +0 +NULL +NULL +NULL +NULL +SELECT * FROM (SELECT cus FROM test1.t1) AS dt; +cus +s +NULL +NULL +NULL +NULL +SELECT * FROM (SELECT cn FROM test1.t1) AS dt; +ERROR 42000: SELECT command denied to user 'user1'@'localhost' for column 'cn' in table 't1' +SELECT * FROM (SELECT cu FROM test1.t1) AS dt; +ERROR 42000: SELECT command denied to user 'user1'@'localhost' for column 'cu' in table 't1' +SELECT * FROM (SELECT ci FROM test1.t1) AS dt; +ERROR 42000: SELECT command denied to user 'user1'@'localhost' for column 'ci' in table 't1' +SELECT * FROM (SELECT MIN(cs) AS c FROM test1.t1) AS dt; +c +0 +SELECT * FROM (SELECT MIN(cus) AS c FROM test1.t1) AS dt; +c +s +SELECT * FROM (SELECT MIN(cn) AS c FROM test1.t1) AS dt; +ERROR 42000: SELECT command denied to user 'user1'@'localhost' for column 'cn' in table 't1' +SELECT * FROM (SELECT MIN(cu) AS c FROM test1.t1) AS dt; +ERROR 42000: SELECT command denied to user 'user1'@'localhost' for column 'cu' in table 't1' +SELECT * FROM (SELECT MIN(ci) AS c FROM test1.t1) AS dt; +ERROR 42000: SELECT command denied to user 'user1'@'localhost' for column 'ci' in table 't1' +SELECT * FROM (SELECT cs FROM test1.t1 WHERE cs = '0') AS dt; +cs +0 +SELECT * FROM (SELECT cs FROM test1.t1 WHERE cus = '0') AS dt; +cs +SELECT * FROM (SELECT cs FROM test1.t1 WHERE cn = '0') AS dt; +ERROR 42000: SELECT command denied to user 'user1'@'localhost' for column 'cn' in table 't1' +SELECT * FROM (SELECT cs FROM test1.t1 WHERE ci = '0') AS dt; +ERROR 42000: SELECT command denied to user 'user1'@'localhost' for column 'ci' in table 't1' +SELECT * FROM (SELECT cs FROM test1.t1 WHERE cu = '0') AS dt; +ERROR 42000: SELECT command denied to user 'user1'@'localhost' for column 'cu' in table 't1' +SELECT * FROM (SELECT COUNT(*) AS c FROM test1.t1 GROUP BY cs) AS dt; +c +1 +4 +SELECT * FROM (SELECT COUNT(*) AS c FROM test1.t1 GROUP BY cus) AS dt; +c +1 +4 +SELECT * FROM (SELECT COUNT(*) AS c FROM test1.t1 GROUP BY cn) AS dt; +ERROR 42000: SELECT command denied to user 'user1'@'localhost' for column 'cn' in table 't1' +SELECT * FROM (SELECT COUNT(*) AS c FROM test1.t1 GROUP BY ci) AS dt; +ERROR 42000: SELECT command denied to user 'user1'@'localhost' for column 'ci' in table 't1' +SELECT * FROM (SELECT COUNT(*) AS c FROM test1.t1 GROUP BY cu) AS dt; +ERROR 42000: SELECT command denied to user 'user1'@'localhost' for column 'cu' in table 't1' +SELECT * FROM (SELECT COUNT(*) AS c FROM test1.t1 HAVING MIN(cs) = '0') AS dt; +c +5 +SELECT * FROM (SELECT COUNT(*) AS c FROM test1.t1 HAVING MIN(cus) = '0') AS dt; +c +SELECT * FROM (SELECT COUNT(*) AS c FROM test1.t1 HAVING MIN(cn) = '0') AS dt; +ERROR 42000: SELECT command denied to user 'user1'@'localhost' for column 'cn' in table 't1' +SELECT * FROM (SELECT COUNT(*) AS c FROM test1.t1 HAVING MIN(ci) = '0') AS dt; +ERROR 42000: SELECT command denied to user 'user1'@'localhost' for column 'ci' in table 't1' +SELECT * FROM (SELECT COUNT(*) AS c FROM test1.t1 HAVING MIN(cu) = '0') AS dt; +ERROR 42000: SELECT command denied to user 'user1'@'localhost' for column 'cu' in table 't1' +SELECT * FROM (SELECT COUNT(*) AS c FROM test1.t1 ORDER BY MIN(cs)) AS dt; +c +5 +SELECT * FROM (SELECT COUNT(*) AS c FROM test1.t1 ORDER BY MIN(cus)) AS dt; +c +5 +SELECT * FROM (SELECT COUNT(*) AS c FROM test1.t1 ORDER BY MIN(cn)) AS dt; +ERROR 42000: SELECT command denied to user 'user1'@'localhost' for column 'cn' in table 't1' +SELECT * FROM (SELECT COUNT(*) AS c FROM test1.t1 ORDER BY MIN(ci)) AS dt; +ERROR 42000: SELECT command denied to user 'user1'@'localhost' for column 'ci' in table 't1' +SELECT * FROM (SELECT COUNT(*) AS c FROM test1.t1 ORDER BY MIN(cu)) AS dt; +ERROR 42000: SELECT command denied to user 'user1'@'localhost' for column 'cu' in table 't1' +# Test access to a view with no privileges +SELECT cs, cus FROM test1.v1_none; +ERROR 42000: SELECT command denied to user 'user1'@'localhost' for table 'v1_none' +UPDATE test1.v1_none SET cu='x'; +ERROR 42000: UPDATE command denied to user 'user1'@'localhost' for table 'v1_none' +UPDATE test1.v1_none, test1.single SET cu='x'; +ERROR 42000: SELECT command denied to user 'user1'@'localhost' for table 'v1_none' +UPDATE test1.v1_none SET cus='x' WHERE cus='0'; +ERROR 42000: UPDATE command denied to user 'user1'@'localhost' for table 'v1_none' +UPDATE test1.v1_none, test1.single SET cus='x' WHERE cus='0'; +ERROR 42000: SELECT command denied to user 'user1'@'localhost' for table 'v1_none' +INSERT INTO test1.v1_none(ci) VALUES('x'); +ERROR 42000: INSERT command denied to user 'user1'@'localhost' for table 'v1_none' +INSERT INTO test1.v1_none(ci) SELECT 'x' FROM test1.single; +ERROR 42000: INSERT command denied to user 'user1'@'localhost' for table 'v1_none' +INSERT INTO test1.v1_none(ci) VALUES('x') +ON DUPLICATE KEY UPDATE cu='u'; +ERROR 42000: INSERT, UPDATE command denied to user 'user1'@'localhost' for table 'v1_none' +INSERT INTO test1.v1_none(ci) SELECT 'x' FROM test1.single +ON DUPLICATE KEY UPDATE cu='u'; +ERROR 42000: INSERT, UPDATE command denied to user 'user1'@'localhost' for table 'v1_none' +DELETE FROM test1.v1_none; +ERROR 42000: DELETE command denied to user 'user1'@'localhost' for table 'v1_none' +DELETE FROM test1.v1_none WHERE cs='0'; +ERROR 42000: DELETE command denied to user 'user1'@'localhost' for table 'v1_none' +DELETE test1.v1_none FROM test1.v1_none, test1.single WHERE cs='0'; +ERROR 42000: SELECT command denied to user 'user1'@'localhost' for table 'v1_none' +# Test access to a view with all privileges +SELECT cs, cus FROM test1.v1_all; +cs cus +0 s +NULL NULL +NULL NULL +NULL NULL +NULL NULL +SELECT * FROM test1.v1_all; +ERROR HY000: View 'test1.v1_all' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +SELECT cn FROM test1.v1_all; +ERROR HY000: View 'test1.v1_all' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +SELECT ci FROM test1.v1_all; +ERROR HY000: View 'test1.v1_all' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +SELECT cu FROM test1.v1_all; +ERROR HY000: View 'test1.v1_all' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +UPDATE test1.v1_all SET cu='v'; +UPDATE test1.v1_all, test1.single SET cu='v'; +UPDATE test1.v1_all SET cus='t' WHERE cus='0'; +UPDATE test1.v1_all, test1.single SET cus='t' WHERE cus='0'; +UPDATE test1.v1_all SET cn='x'; +ERROR HY000: View 'test1.v1_all' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +UPDATE test1.v1_all, test1.single SET cn='x'; +ERROR HY000: View 'test1.v1_all' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +UPDATE test1.v1_all SET cs='x'; +ERROR HY000: View 'test1.v1_all' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +UPDATE test1.v1_all, test1.single SET cs='x'; +ERROR HY000: View 'test1.v1_all' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +UPDATE test1.v1_all SET ci='x'; +ERROR HY000: View 'test1.v1_all' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +UPDATE test1.v1_all, test1.single SET ci='x'; +ERROR HY000: View 'test1.v1_all' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +UPDATE test1.v1_all SET cu='x' WHERE cn='0'; +ERROR HY000: View 'test1.v1_all' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +UPDATE test1.v1_all, test1.single SET cu='x' WHERE cn='0'; +ERROR HY000: View 'test1.v1_all' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +INSERT INTO test1.v1_all(ci) VALUES('j'); +INSERT INTO test1.v1_all(ci) SELECT 'j' FROM test1.single; +INSERT INTO test1.v1_all(ci) VALUES('j') +ON DUPLICATE KEY UPDATE cu='u'; +INSERT INTO test1.v1_all(ci) SELECT 'j' FROM test1.single +ON DUPLICATE KEY UPDATE cu='u'; +INSERT INTO test1.v1_all(cn) VALUES('x'); +ERROR HY000: View 'test1.v1_all' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +INSERT INTO test1.v1_all(cn) SELECT 'x' FROM test1.single; +ERROR HY000: View 'test1.v1_all' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +INSERT INTO test1.v1_all(cs) VALUES('x'); +ERROR HY000: View 'test1.v1_all' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +INSERT INTO test1.v1_all(cs) SELECT 'x' FROM test1.single; +ERROR HY000: View 'test1.v1_all' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +INSERT INTO test1.v1_all(cu) VALUES('x'); +ERROR HY000: View 'test1.v1_all' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +INSERT INTO test1.v1_all(cu) SELECT 'x' FROM test1.single; +ERROR HY000: View 'test1.v1_all' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +INSERT INTO test1.v1_all(cus) VALUES('x'); +ERROR HY000: View 'test1.v1_all' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +INSERT INTO test1.v1_all(cus) SELECT 'x' FROM test1.single; +ERROR HY000: View 'test1.v1_all' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +INSERT INTO test1.v1_all(cn) VALUES('x') +ON DUPLICATE KEY UPDATE cu='u'; +ERROR HY000: View 'test1.v1_all' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +INSERT INTO test1.v1_all(cn) SELECT 'x' FROM test1.single +ON DUPLICATE KEY UPDATE cu='u'; +ERROR HY000: View 'test1.v1_all' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +INSERT INTO test1.v1_all(ci) VALUES('x') +ON DUPLICATE KEY UPDATE cn='u'; +ERROR HY000: View 'test1.v1_all' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +INSERT INTO test1.v1_all(ci) SELECT 'x' FROM test1.single +ON DUPLICATE KEY UPDATE cn='u'; +ERROR HY000: View 'test1.v1_all' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +DELETE FROM test1.v1_all; +ERROR HY000: View 'test1.v1_all' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +DELETE FROM test1.v1_all WHERE cs='0'; +ERROR HY000: View 'test1.v1_all' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +DELETE test1.v1_all FROM test1.v1_all, test1.single WHERE cs='0'; +ERROR HY000: View 'test1.v1_all' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +# Test access to a view with all privileges, inside derived table +SELECT * FROM (SELECT cs FROM test1.v1_all) AS dt; +cs +0 +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +SELECT * FROM (SELECT cus FROM test1.v1_all) AS dt; +cus +s +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +SELECT * FROM (SELECT cn FROM test1.v1_all) AS dt; +ERROR HY000: View 'test1.v1_all' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +SELECT * FROM (SELECT cu FROM test1.v1_all) AS dt; +ERROR HY000: View 'test1.v1_all' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +SELECT * FROM (SELECT ci FROM test1.v1_all) AS dt; +ERROR HY000: View 'test1.v1_all' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +SELECT * FROM (SELECT MIN(cs) AS c FROM test1.v1_all) AS dt; +c +0 +SELECT * FROM (SELECT MIN(cus) AS c FROM test1.v1_all) AS dt; +c +s +SELECT * FROM (SELECT MIN(cn) AS c FROM test1.v1_all) AS dt; +ERROR HY000: View 'test1.v1_all' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +SELECT * FROM (SELECT MIN(cu) AS c FROM test1.v1_all) AS dt; +ERROR HY000: View 'test1.v1_all' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +SELECT * FROM (SELECT MIN(ci) AS c FROM test1.v1_all) AS dt; +ERROR HY000: View 'test1.v1_all' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +SELECT * FROM (SELECT cs FROM test1.v1_all WHERE cs = '0') AS dt; +cs +0 +SELECT * FROM (SELECT cs FROM test1.v1_all WHERE cus = '0') AS dt; +cs +SELECT * FROM (SELECT cs FROM test1.v1_all WHERE cn = '0') AS dt; +ERROR HY000: View 'test1.v1_all' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +SELECT * FROM (SELECT cs FROM test1.v1_all WHERE ci = '0') AS dt; +ERROR HY000: View 'test1.v1_all' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +SELECT * FROM (SELECT cs FROM test1.v1_all WHERE cu = '0') AS dt; +ERROR HY000: View 'test1.v1_all' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +SELECT * FROM (SELECT COUNT(*) AS c FROM test1.v1_all GROUP BY cs) AS dt; +c +1 +8 +SELECT * FROM (SELECT COUNT(*) AS c FROM test1.v1_all GROUP BY cus) AS dt; +c +1 +8 +SELECT * FROM (SELECT COUNT(*) AS c FROM test1.v1_all GROUP BY cn) AS dt; +ERROR HY000: View 'test1.v1_all' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +SELECT * FROM (SELECT COUNT(*) AS c FROM test1.v1_all GROUP BY ci) AS dt; +ERROR HY000: View 'test1.v1_all' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +SELECT * FROM (SELECT COUNT(*) AS c FROM test1.v1_all GROUP BY cu) AS dt; +ERROR HY000: View 'test1.v1_all' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +SELECT * FROM (SELECT COUNT(*) AS c FROM test1.v1_all HAVING MIN(cs) = '0') AS dt; +c +9 +SELECT * FROM (SELECT COUNT(*) AS c FROM test1.v1_all HAVING MIN(cus) = '0') AS dt; +c +SELECT * FROM (SELECT COUNT(*) AS c FROM test1.v1_all HAVING MIN(cn) = '0') AS dt; +ERROR HY000: View 'test1.v1_all' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +SELECT * FROM (SELECT COUNT(*) AS c FROM test1.v1_all HAVING MIN(ci) = '0') AS dt; +ERROR HY000: View 'test1.v1_all' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +SELECT * FROM (SELECT COUNT(*) AS c FROM test1.v1_all HAVING MIN(cu) = '0') AS dt; +ERROR HY000: View 'test1.v1_all' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +SELECT * FROM (SELECT COUNT(*) AS c FROM test1.v1_all ORDER BY MIN(cs)) AS dt; +c +9 +SELECT * FROM (SELECT COUNT(*) AS c FROM test1.v1_all ORDER BY MIN(cus)) AS dt; +c +9 +SELECT * FROM (SELECT COUNT(*) AS c FROM test1.v1_all ORDER BY MIN(cn)) AS dt; +ERROR HY000: View 'test1.v1_all' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +SELECT * FROM (SELECT COUNT(*) AS c FROM test1.v1_all ORDER BY MIN(ci)) AS dt; +ERROR HY000: View 'test1.v1_all' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +SELECT * FROM (SELECT COUNT(*) AS c FROM test1.v1_all ORDER BY MIN(cu)) AS dt; +ERROR HY000: View 'test1.v1_all' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +# Test access to a view with same privileges as base table +SELECT cs, cus FROM test1.v1_same; +cs cus +0 s +NULL NULL +NULL NULL +NULL NULL +NULL NULL +NULL NULL +NULL NULL +NULL NULL +NULL NULL +SELECT * FROM test1.v1_same; +ERROR 42000: SELECT command denied to user 'user1'@'localhost' for column 'cn' in table 'v1_same' +SELECT cn FROM test1.v1_same; +ERROR 42000: SELECT command denied to user 'user1'@'localhost' for column 'cn' in table 'v1_same' +SELECT ci FROM test1.v1_same; +ERROR 42000: SELECT command denied to user 'user1'@'localhost' for column 'ci' in table 'v1_same' +SELECT cu FROM test1.v1_same; +ERROR 42000: SELECT command denied to user 'user1'@'localhost' for column 'cu' in table 'v1_same' +UPDATE test1.v1_same SET cu='w'; +UPDATE test1.v1_same, test1.single SET cu='w'; +UPDATE test1.v1_same SET cus='z' WHERE cus='0'; +UPDATE test1.v1_same, test1.single SET cus='z' WHERE cus='0'; +UPDATE test1.v1_same SET cn='x'; +ERROR 42000: UPDATE command denied to user 'user1'@'localhost' for column 'cn' in table 'v1_same' +UPDATE test1.v1_same, test1.single SET cn='x'; +ERROR 42000: UPDATE command denied to user 'user1'@'localhost' for column 'cn' in table 'v1_same' +UPDATE test1.v1_same SET cs='x'; +ERROR 42000: UPDATE command denied to user 'user1'@'localhost' for column 'cs' in table 'v1_same' +UPDATE test1.v1_same, test1.single SET cs='x'; +ERROR 42000: UPDATE command denied to user 'user1'@'localhost' for column 'cs' in table 'v1_same' +UPDATE test1.v1_same SET ci='x'; +ERROR 42000: UPDATE command denied to user 'user1'@'localhost' for column 'ci' in table 'v1_same' +UPDATE test1.v1_same, test1.single SET ci='x'; +ERROR 42000: UPDATE command denied to user 'user1'@'localhost' for column 'ci' in table 'v1_same' +UPDATE test1.v1_same SET cu='x' WHERE cn='0'; +ERROR 42000: SELECT command denied to user 'user1'@'localhost' for column 'cn' in table 'v1_same' +UPDATE test1.v1_same, test1.single SET cu='x' WHERE cn='0'; +ERROR 42000: SELECT command denied to user 'user1'@'localhost' for column 'cn' in table 'v1_same' +INSERT INTO test1.v1_same(ci) VALUES('k'); +INSERT INTO test1.v1_same(ci) SELECT 'k' FROM test1.single; +INSERT INTO test1.v1_same(ci) VALUES('k') +ON DUPLICATE KEY UPDATE cu='u'; +INSERT INTO test1.v1_same(ci) SELECT 'k' FROM test1.single +ON DUPLICATE KEY UPDATE cu='u'; +INSERT INTO test1.v1_same(cn) VALUES('x'); +ERROR 42000: INSERT command denied to user 'user1'@'localhost' for column 'cn' in table 'v1_same' +INSERT INTO test1.v1_same(cn) SELECT 'x' FROM test1.single; +ERROR 42000: INSERT command denied to user 'user1'@'localhost' for column 'cn' in table 'v1_same' +INSERT INTO test1.v1_same(cs) VALUES('x'); +ERROR 42000: INSERT command denied to user 'user1'@'localhost' for column 'cs' in table 'v1_same' +INSERT INTO test1.v1_same(cs) SELECT 'x' FROM test1.single; +ERROR 42000: INSERT command denied to user 'user1'@'localhost' for column 'cs' in table 'v1_same' +INSERT INTO test1.v1_same(cu) VALUES('x'); +ERROR 42000: INSERT command denied to user 'user1'@'localhost' for column 'cu' in table 'v1_same' +INSERT INTO test1.v1_same(cu) SELECT 'x' FROM test1.single; +ERROR 42000: INSERT command denied to user 'user1'@'localhost' for column 'cu' in table 'v1_same' +INSERT INTO test1.v1_same(cus) VALUES('x'); +ERROR 42000: INSERT command denied to user 'user1'@'localhost' for column 'cus' in table 'v1_same' +INSERT INTO test1.v1_same(cus) SELECT 'x' FROM test1.single; +ERROR 42000: INSERT command denied to user 'user1'@'localhost' for column 'cus' in table 'v1_same' +DELETE FROM test1.v1_same; +ERROR 42000: DELETE command denied to user 'user1'@'localhost' for table 'v1_same' +DELETE FROM test1.v1_same WHERE cs='0'; +ERROR 42000: DELETE command denied to user 'user1'@'localhost' for table 'v1_same' +DELETE test1.v1_same FROM test1.v1_same, test1.single WHERE cs='0'; +ERROR 42000: DELETE command denied to user 'user1'@'localhost' for table 'v1_same' +# Test access to a view with same privileges, inside derived table +SELECT * FROM (SELECT cs FROM test1.v1_same) AS dt; +cs +0 +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +SELECT * FROM (SELECT cus FROM test1.v1_same) AS dt; +cus +s +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +SELECT * FROM (SELECT cn FROM test1.v1_same) AS dt; +ERROR 42000: SELECT command denied to user 'user1'@'localhost' for column 'cn' in table 'v1_same' +SELECT * FROM (SELECT cu FROM test1.v1_same) AS dt; +ERROR 42000: SELECT command denied to user 'user1'@'localhost' for column 'cu' in table 'v1_same' +SELECT * FROM (SELECT ci FROM test1.v1_same) AS dt; +ERROR 42000: SELECT command denied to user 'user1'@'localhost' for column 'ci' in table 'v1_same' +SELECT * FROM (SELECT MIN(cs) AS c FROM test1.v1_same) AS dt; +c +0 +SELECT * FROM (SELECT MIN(cus) AS c FROM test1.v1_same) AS dt; +c +s +SELECT * FROM (SELECT MIN(cn) AS c FROM test1.v1_same) AS dt; +ERROR 42000: SELECT command denied to user 'user1'@'localhost' for column 'cn' in table 'v1_same' +SELECT * FROM (SELECT MIN(cu) AS c FROM test1.v1_same) AS dt; +ERROR 42000: SELECT command denied to user 'user1'@'localhost' for column 'cu' in table 'v1_same' +SELECT * FROM (SELECT MIN(ci) AS c FROM test1.v1_same) AS dt; +ERROR 42000: SELECT command denied to user 'user1'@'localhost' for column 'ci' in table 'v1_same' +SELECT * FROM (SELECT cs FROM test1.v1_same WHERE cs = '0') AS dt; +cs +0 +SELECT * FROM (SELECT cs FROM test1.v1_same WHERE cus = '0') AS dt; +cs +SELECT * FROM (SELECT cs FROM test1.v1_same WHERE cn = '0') AS dt; +ERROR 42000: SELECT command denied to user 'user1'@'localhost' for column 'cn' in table 'v1_same' +SELECT * FROM (SELECT cs FROM test1.v1_same WHERE ci = '0') AS dt; +ERROR 42000: SELECT command denied to user 'user1'@'localhost' for column 'ci' in table 'v1_same' +SELECT * FROM (SELECT cs FROM test1.v1_same WHERE cu = '0') AS dt; +ERROR 42000: SELECT command denied to user 'user1'@'localhost' for column 'cu' in table 'v1_same' +SELECT * FROM (SELECT COUNT(*) AS c FROM test1.v1_same GROUP BY cs) AS dt; +c +1 +12 +SELECT * FROM (SELECT COUNT(*) AS c FROM test1.v1_same GROUP BY cus) AS dt; +c +1 +12 +SELECT * FROM (SELECT COUNT(*) AS c FROM test1.v1_same GROUP BY cn) AS dt; +ERROR 42000: SELECT command denied to user 'user1'@'localhost' for column 'cn' in table 'v1_same' +SELECT * FROM (SELECT COUNT(*) AS c FROM test1.v1_same GROUP BY ci) AS dt; +ERROR 42000: SELECT command denied to user 'user1'@'localhost' for column 'ci' in table 'v1_same' +SELECT * FROM (SELECT COUNT(*) AS c FROM test1.v1_same GROUP BY cu) AS dt; +ERROR 42000: SELECT command denied to user 'user1'@'localhost' for column 'cu' in table 'v1_same' +SELECT * FROM (SELECT COUNT(*) AS c FROM test1.v1_same HAVING MIN(cs) = '0') AS dt; +c +13 +SELECT * FROM (SELECT COUNT(*) AS c FROM test1.v1_same HAVING MIN(cus) = '0') AS dt; +c +SELECT * FROM (SELECT COUNT(*) AS c FROM test1.v1_same HAVING MIN(cn) = '0') AS dt; +ERROR 42000: SELECT command denied to user 'user1'@'localhost' for column 'cn' in table 'v1_same' +SELECT * FROM (SELECT COUNT(*) AS c FROM test1.v1_same HAVING MIN(ci) = '0') AS dt; +ERROR 42000: SELECT command denied to user 'user1'@'localhost' for column 'ci' in table 'v1_same' +SELECT * FROM (SELECT COUNT(*) AS c FROM test1.v1_same HAVING MIN(cu) = '0') AS dt; +ERROR 42000: SELECT command denied to user 'user1'@'localhost' for column 'cu' in table 'v1_same' +SELECT * FROM (SELECT COUNT(*) AS c FROM test1.v1_same ORDER BY MIN(cs)) AS dt; +c +13 +SELECT * FROM (SELECT COUNT(*) AS c FROM test1.v1_same ORDER BY MIN(cus)) AS dt; +c +13 +SELECT * FROM (SELECT COUNT(*) AS c FROM test1.v1_same ORDER BY MIN(cn)) AS dt; +ERROR 42000: SELECT command denied to user 'user1'@'localhost' for column 'cn' in table 'v1_same' +SELECT * FROM (SELECT COUNT(*) AS c FROM test1.v1_same ORDER BY MIN(ci)) AS dt; +ERROR 42000: SELECT command denied to user 'user1'@'localhost' for column 'ci' in table 'v1_same' +SELECT * FROM (SELECT COUNT(*) AS c FROM test1.v1_same ORDER BY MIN(cu)) AS dt; +ERROR 42000: SELECT command denied to user 'user1'@'localhost' for column 'cu' in table 'v1_same' +# Test access to a view with "mixed" privileges +SELECT cs, cus FROM test1.v1_cross; +ERROR 42000: SELECT command denied to user 'user1'@'localhost' for column 'cs' in table 'v1_cross' +SELECT * FROM test1.v1_cross; +ERROR 42000: SELECT command denied to user 'user1'@'localhost' for column 'cn' in table 'v1_cross' +SELECT cn FROM test1.v1_cross; +ERROR 42000: SELECT command denied to user 'user1'@'localhost' for column 'cn' in table 'v1_cross' +SELECT ci FROM test1.v1_cross; +ERROR HY000: View 'test1.v1_cross' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +SELECT cu FROM test1.v1_cross; +ERROR HY000: View 'test1.v1_cross' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +UPDATE test1.v1_cross SET cu='x'; +ERROR 42000: UPDATE command denied to user 'user1'@'localhost' for column 'cu' in table 'v1_cross' +UPDATE test1.v1_cross, test1.single SET cu='x'; +ERROR 42000: UPDATE command denied to user 'user1'@'localhost' for column 'cu' in table 'v1_cross' +UPDATE test1.v1_cross SET cus='x' WHERE cus='0'; +ERROR 42000: SELECT command denied to user 'user1'@'localhost' for column 'cus' in table 'v1_cross' +UPDATE test1.v1_cross, test1.single SET cus='x' WHERE cus='0'; +ERROR 42000: SELECT command denied to user 'user1'@'localhost' for column 'cus' in table 'v1_cross' +UPDATE test1.v1_cross SET cn='x'; +ERROR 42000: UPDATE command denied to user 'user1'@'localhost' for column 'cn' in table 'v1_cross' +UPDATE test1.v1_cross, test1.single SET cn='x'; +ERROR 42000: UPDATE command denied to user 'user1'@'localhost' for column 'cn' in table 'v1_cross' +UPDATE test1.v1_cross SET cs='x'; +ERROR HY000: View 'test1.v1_cross' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +UPDATE test1.v1_cross, test1.single SET cs='x'; +ERROR HY000: View 'test1.v1_cross' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +UPDATE test1.v1_cross SET ci='x'; +ERROR 42000: UPDATE command denied to user 'user1'@'localhost' for column 'ci' in table 'v1_cross' +UPDATE test1.v1_cross, test1.single SET ci='x'; +ERROR 42000: UPDATE command denied to user 'user1'@'localhost' for column 'ci' in table 'v1_cross' +UPDATE test1.v1_cross SET cu='x' WHERE cn='0'; +ERROR 42000: SELECT command denied to user 'user1'@'localhost' for column 'cn' in table 'v1_cross' +UPDATE test1.v1_cross, test1.single SET cu='x' WHERE cn='0'; +ERROR 42000: SELECT command denied to user 'user1'@'localhost' for column 'cn' in table 'v1_cross' +INSERT INTO test1.v1_cross(ci) VALUES('x'); +ERROR 42000: INSERT command denied to user 'user1'@'localhost' for column 'ci' in table 'v1_cross' +INSERT INTO test1.v1_cross(ci) SELECT 'x' FROM test1.single; +ERROR 42000: INSERT command denied to user 'user1'@'localhost' for column 'ci' in table 'v1_cross' +INSERT INTO test1.v1_cross(ci) VALUES('k') +ON DUPLICATE KEY UPDATE cu='u'; +ERROR 42000: INSERT command denied to user 'user1'@'localhost' for column 'ci' in table 'v1_cross' +INSERT INTO test1.v1_cross(ci) SELECT 'k' FROM test1.single +ON DUPLICATE KEY UPDATE cu='u'; +ERROR 42000: INSERT command denied to user 'user1'@'localhost' for column 'ci' in table 'v1_cross' +INSERT INTO test1.v1_cross(cn) VALUES('x'); +ERROR 42000: INSERT command denied to user 'user1'@'localhost' for column 'cn' in table 'v1_cross' +INSERT INTO test1.v1_cross(cn) SELECT 'x' FROM test1.single; +ERROR 42000: INSERT command denied to user 'user1'@'localhost' for column 'cn' in table 'v1_cross' +INSERT INTO test1.v1_cross(cs) VALUES('x'); +ERROR 42000: INSERT command denied to user 'user1'@'localhost' for column 'cs' in table 'v1_cross' +INSERT INTO test1.v1_cross(cs) SELECT 'x' FROM test1.single; +ERROR 42000: INSERT command denied to user 'user1'@'localhost' for column 'cs' in table 'v1_cross' +INSERT INTO test1.v1_cross(cu) VALUES('x'); +ERROR 42000: INSERT command denied to user 'user1'@'localhost' for column 'cu' in table 'v1_cross' +INSERT INTO test1.v1_cross(cu) SELECT 'x' FROM test1.single; +ERROR 42000: INSERT command denied to user 'user1'@'localhost' for column 'cu' in table 'v1_cross' +INSERT INTO test1.v1_cross(cus) VALUES('x'); +ERROR HY000: View 'test1.v1_cross' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +INSERT INTO test1.v1_cross(cus) SELECT 'x' FROM test1.single; +ERROR HY000: View 'test1.v1_cross' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +DELETE FROM test1.v1_cross; +ERROR 42000: DELETE command denied to user 'user1'@'localhost' for table 'v1_cross' +DELETE FROM test1.v1_cross WHERE cs='0'; +ERROR 42000: DELETE command denied to user 'user1'@'localhost' for table 'v1_cross' +DELETE test1.v1_cross FROM test1.v1_cross, test1.single WHERE cs='0'; +ERROR 42000: DELETE command denied to user 'user1'@'localhost' for table 'v1_cross' +# Test access to a multi-level view with no privileges +SELECT cs FROM test1.v1_multi; +ERROR HY000: View 'test1.v1_multi' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +SELECT cus FROM test1.v1_multi; +cus +s +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +UPDATE test1.v1_multi SET cu='x'; +ERROR HY000: View 'test1.v1_multi' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +UPDATE test1.v1_multi, test1.single SET cu='x'; +ERROR HY000: View 'test1.v1_multi' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +UPDATE test1.v1_multi SET cus='x' WHERE cus='0'; +ERROR HY000: View 'test1.v1_multi' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +UPDATE test1.v1_multi, test1.single SET cus='x' WHERE cus='0'; +ERROR HY000: View 'test1.v1_multi' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +INSERT INTO test1.v1_multi(ci) VALUES('x'); +ERROR HY000: View 'test1.v1_multi' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +INSERT INTO test1.v1_multi(ci) SELECT 'x' FROM test1.single; +ERROR HY000: View 'test1.v1_multi' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +INSERT INTO test1.v1_multi(ci) VALUES('x') +ON DUPLICATE KEY UPDATE cu='u'; +ERROR HY000: View 'test1.v1_multi' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +INSERT INTO test1.v1_multi(ci) SELECT 'x' FROM test1.single +ON DUPLICATE KEY UPDATE cu='u'; +ERROR HY000: View 'test1.v1_multi' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +DELETE FROM test1.v1_multi; +ERROR 42000: DELETE command denied to user 'user1'@'localhost' for table 'v1_multi' +DELETE FROM test1.v1_multi WHERE cs='0'; +ERROR 42000: DELETE command denied to user 'user1'@'localhost' for table 'v1_multi' +DELETE test1.v1_multi FROM test1.v1_multi WHERE cs='0'; +ERROR 42000: DELETE command denied to user 'user1'@'localhost' for table 'v1_multi' +# Test access to a renamed view +SELECT cn FROM test1.v1_renamed; +ERROR 42000: SELECT command denied to user 'user1'@'localhost' for column 'cn' in table 'v1_renamed' +SELECT cs FROM test1.v1_renamed; +ERROR HY000: View 'test1.v1_renamed' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +SELECT cus FROM test1.v1_renamed; +cus +0 +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +SELECT cx FROM test1.v1_renamed; +ERROR 42000: SELECT command denied to user 'user1'@'localhost' for column 'cx' in table 'v1_renamed' +SELECT cy FROM test1.v1_renamed; +ERROR 42000: SELECT command denied to user 'user1'@'localhost' for column 'cy' in table 'v1_renamed' +# Test access to a derived tables. Since they can be used in SELECT +# only, update functions are not needed +SELECT cs, cus FROM (SELECT * FROM test1.t1) AS dt; +ERROR 42000: SELECT command denied to user 'user1'@'localhost' for column 'cn' in table 't1' +SELECT * FROM (SELECT * FROM test1.t1) AS dt; +ERROR 42000: SELECT command denied to user 'user1'@'localhost' for column 'cn' in table 't1' +SELECT cn FROM (SELECT * FROM test1.t1) AS dt; +ERROR 42000: SELECT command denied to user 'user1'@'localhost' for column 'cn' in table 't1' +SELECT ci FROM (SELECT * FROM test1.t1) AS dt; +ERROR 42000: SELECT command denied to user 'user1'@'localhost' for column 'cn' in table 't1' +SELECT cu FROM (SELECT * FROM test1.t1) AS dt; +ERROR 42000: SELECT command denied to user 'user1'@'localhost' for column 'cn' in table 't1' +SELECT * FROM (SELECT cs, cus FROM test1.t1) AS dt; +cs cus +0 s +NULL NULL +NULL NULL +NULL NULL +NULL NULL +NULL NULL +NULL NULL +NULL NULL +NULL NULL +NULL NULL +NULL NULL +NULL NULL +NULL NULL +SELECT cs, cus FROM (SELECT cs, cus FROM test1.t1) AS dt; +cs cus +0 s +NULL NULL +NULL NULL +NULL NULL +NULL NULL +NULL NULL +NULL NULL +NULL NULL +NULL NULL +NULL NULL +NULL NULL +NULL NULL +NULL NULL +SELECT cx FROM (SELECT CONCAT(cs, cus) AS cx FROM test1.t1) AS dt; +cx +0s +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +SELECT * FROM (SELECT cn FROM test1.t1) AS dt; +ERROR 42000: SELECT command denied to user 'user1'@'localhost' for column 'cn' in table 't1' +SELECT * FROM (SELECT ci FROM test1.t1) AS dt; +ERROR 42000: SELECT command denied to user 'user1'@'localhost' for column 'ci' in table 't1' +SELECT * FROM (SELECT cu FROM test1.t1) AS dt; +ERROR 42000: SELECT command denied to user 'user1'@'localhost' for column 'cu' in table 't1' +SELECT * FROM (SELECT CONCAT(cs, cu) AS cx FROM test1.t1) AS dt; +ERROR 42000: SELECT command denied to user 'user1'@'localhost' for column 'cu' in table 't1' +SELECT * FROM (SELECT CONCAT(ci, cu) AS cx FROM test1.t1) AS dt; +ERROR 42000: SELECT command denied to user 'user1'@'localhost' for column 'ci' in table 't1' +SELECT cx FROM (SELECT CONCAT(cs, cu) AS cx FROM test1.t1) AS dt; +ERROR 42000: SELECT command denied to user 'user1'@'localhost' for column 'cu' in table 't1' +SELECT cx FROM (SELECT CONCAT(ci, cu) AS cx FROM test1.t1) AS dt; +ERROR 42000: SELECT command denied to user 'user1'@'localhost' for column 'ci' in table 't1' +DROP VIEW test1.v1_none, test1.v1_all, test1.v1_same; +DROP VIEW test1.v1_cross, test1.v1_middle, test1.v1_multi; +DROP VIEW test1.v1_renamed; +DROP USER user1@localhost; +CREATE USER user1@localhost; +GRANT SELECT(cs) ON test1.t1 TO user1@localhost; +CREATE DEFINER=user1@localhost SQL SECURITY DEFINER VIEW test1.v1_none AS +SELECT cs FROM test1.t1; +CREATE DEFINER=user1@localhost SQL SECURITY DEFINER VIEW test1.v1_middle AS +SELECT cs FROM test1.t1; +CREATE DEFINER=user1@localhost SQL SECURITY DEFINER VIEW test1.v1_multi AS +SELECT * FROM test1.v1_middle; +REVOKE SELECT(cs) ON test1.t1 FROM user1@localhost; +SHOW GRANTS FOR user1@localhost; +Grants for user1@localhost +GRANT USAGE ON *.* TO `user1`@`localhost` +SELECT * FROM test1.t1 LIMIT 1; +cn cs ci cu cus +0 0 0 w s +# Test access to a view with no privileges +SELECT cs FROM test1.v1_none; +ERROR HY000: View 'test1.v1_none' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +GRANT SELECT(cs) ON test1.t1 TO user1@localhost; +SELECT cs FROM test1.v1_none LIMIT 1; +cs +0 +SELECT cs FROM test1.v1_multi; +ERROR HY000: View 'test1.v1_multi' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +GRANT SELECT(cs) ON test1.v1_middle TO user1@localhost; +SELECT cs FROM test1.v1_multi LIMIT 1; +cs +0 +REVOKE SELECT(cs) ON test1.t1 FROM user1@localhost; +SELECT cs FROM test1.v1_multi; +ERROR HY000: View 'test1.v1_multi' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +DROP USER user1@localhost; +Warnings: +Warning 4005 User 'user1'@'localhost' is referenced as a definer account in a view. +DROP DATABASE test1; +# +# Bug#20032855 STRICT MODE REVEALS UNDERLYING PRIVILEGE ERROR +# +CREATE DATABASE test1; +CREATE USER 'user1'@'localhost'; +CREATE TABLE test1.t1 (cn CHAR(1), cs CHAR(1), ci CHAR(1), cu CHAR(1), cus CHAR(1)); +GRANT SELECT(cs,cus) ON test1.t1 TO user1@localhost; +GRANT INSERT(ci) ON test1.t1 TO user1@localhost; +GRANT UPDATE(cu,cus) ON test1.t1 TO user1@localhost; +CREATE SQL SECURITY INVOKER VIEW test1.v1_all AS +SELECT * FROM test1.t1; +GRANT SELECT,INSERT,UPDATE,DELETE ON test1.v1_all TO user1@localhost; +FLUSH PRIVILEGES; +connect con1,localhost,user1,,; +SET sql_mode='STRICT_ALL_TABLES'; +Warnings: +Warning 3135 'NO_ZERO_DATE', 'NO_ZERO_IN_DATE' and 'ERROR_FOR_DIVISION_BY_ZERO' sql modes should be used with strict mode. They will be merged with strict mode in a future release. +UPDATE test1.v1_all SET cn='x'; +ERROR HY000: View 'test1.v1_all' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +SHOW WARNINGS; +Level Code Message +Error 1356 View 'test1.v1_all' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +SET sql_mode=''; +UPDATE test1.v1_all SET cn='x'; +ERROR HY000: View 'test1.v1_all' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +SHOW WARNINGS; +Level Code Message +Error 1356 View 'test1.v1_all' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +UPDATE IGNORE test1.v1_all SET cn='x'; +ERROR HY000: View 'test1.v1_all' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +SHOW WARNINGS; +Level Code Message +Error 1356 View 'test1.v1_all' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them + +# Bug21338077 HANDLE_FATAL_SIGNAL (SIG=11) IN __STPCPY_SSE2_UNALIGNED FROM MY_STPCPY + +CREATE VIEW v1 AS SELECT 1 FROM (SELECT 1) AS d1; +PREPARE stmt FROM 'SELECT * FROM v1'; +EXECUTE stmt; +1 +1 +DROP PREPARE stmt; +DROP VIEW v1; +connection default; +disconnect con1; +DROP USER 'user1'@'localhost'; +DROP DATABASE test1; +set GLOBAL sql_mode= @orig_sql_mode_global; +set SESSION sql_mode= @orig_sql_mode_session; +# +# WL#2284: Increase the length of a user name +# +CREATE DATABASE test1; +CREATE TABLE test1.t1 ( +int_field INTEGER UNSIGNED NOT NULL, +char_field CHAR(10), +INDEX(`int_field`) +); +use test; +CREATE USER user_name_len_22_01234@localhost; +CREATE USER user_name_len_32_012345678901234@localhost; +REVOKE ALL PRIVILEGES, GRANT OPTION FROM user_name_len_22_01234@localhost; +REVOKE ALL PRIVILEGES, GRANT OPTION FROM user_name_len_32_012345678901234@localhost; +# Check that user_name_len_22_01234 has no SELECT permission ON t1 +connect con_user_22,localhost,user_name_len_22_01234,,test; +SELECT * FROM test1.t1; +ERROR 42000: SELECT command denied to user 'user_name_len_22_01234'@'localhost' for table 't1' +# Check that user_name_len_32_012345678901234 has no SELECT permission ON t1 +connect con_user_32,localhost,user_name_len_32_012345678901234,,test; +SELECT * FROM test1.t1; +ERROR 42000: SELECT command denied to user 'user_name_len_32_012345678901234'@'localhost' for table 't1' +connection default; +GRANT ALL ON test1.* TO user_name_len_32_012345678901234@localhost; +CREATE DEFINER=user_name_len_32_012345678901234@localhost +VIEW test1.v1 AS SELECT int_field FROM test1.t1; +GRANT SELECT ON test1.v1 TO user_name_len_22_01234@localhost; +# Now user_name_len_22_01234 should be able to SELECT int_field FROM +# test1.t1 by using test1.v1 +connection con_user_22; +SELECT * FROM test1.v1; +int_field +connection default; +CREATE DEFINER=user_name_len_33_0123456789012345@localhost +VIEW test1.v2 AS SELECT int_field FROM test1.t1; +ERROR HY000: String 'user_name_len_33_0123456789012345' is too long for user name (should be no longer than 32) +DROP DATABASE test1; +DROP USER user_name_len_22_01234@localhost; +DROP USER user_name_len_32_012345678901234@localhost; +# +# WL#9262: All system tables should support 32 character length user names +# +#Create user with max length (max username length + max hostname length) +CREATE USER user_name_robert_golebiowski@oh_my_gosh_this_is_a_long_hostname_look_at_it_it_has_60_char; +CREATE TABLE silly_one (ID INT); +CREATE DEFINER=user_name_robert_golebiowski@oh_my_gosh_this_is_a_long_hostname_look_at_it_it_has_60_char VIEW silly_view AS SELECT * FROM silly_one; +SELECT DEFINER FROM information_schema.VIEWS WHERE TABLE_NAME='silly_view'; +DEFINER +user_name_robert_golebiowski@oh_my_gosh_this_is_a_long_hostname_look_at_it_it_has_60_char +DROP USER user_name_robert_golebiowski@oh_my_gosh_this_is_a_long_hostname_look_at_it_it_has_60_char; +Warnings: +Warning 4005 User 'user_name_robert_golebiowski'@'oh_my_gosh_this_is_a_long_hostname_look_at_it_it_has_60_char' is referenced as a definer account in a view. +DROP VIEW silly_view; +DROP TABLE silly_one; +# +# Bug #27094955 -- INCORRECT CHECKING FOR FILE PRIVILEGE IN CASE QUERY IS RUN AGAINST A VIEW +# +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1); +CREATE USER `u1`@`localhost`; +CREATE USER `u2`@`localhost`; +# Create a view for that a user specified as definer doesn't have the FILE privilege +CREATE DEFINER=`u2`@`localhost` VIEW v1 AS SELECT a FROM t1; +# Grant the FILE privilege to a user who will run the SELECT INTO OUTFILE against the view v1 +GRANT FILE ON *.* TO `u1`@`localhost`; +connect con1,localhost,u1,,; +connection con1; +# Run SELECT from a view with the clause "INTO OUTFILE". +# Without the patch this query would failed with error ER_ACCESS_DENIED_ERROR. +SELECT a INTO OUTFILE '' +FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' +LINES TERMINATED BY '\n' +FROM v1; +disconnect con1; +connection default; +1 +# Now revoke the privilege FILE from the user u1@localhost +# in order to check that without this privilege the statement +# "SELECT INTO OUTFILE .. FROM view" will fail. That is, check that +# the privilege FILE is still taken into account during processing +# when the clause INTO OUTFILE is specified. +REVOKE FILE ON *.* FROM `u1`@`localhost`; +connect con1,localhost,u1,,; +connection con1; +# Check that querying from v1 with the clause INTO OUTFILE is failed in case +# a user who running a query doesn't have the FILE privilege +SELECT a INTO OUTFILE '' +FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' +LINES TERMINATED BY '\n' +FROM v1; +ERROR 42000: Access denied; you need (at least one of) the FILE privilege(s) for this operation +disconnect con1; +connection default; +DROP USER `u1`@`localhost`; +DROP USER `u2`@`localhost`; +Warnings: +Warning 4005 User 'u2'@'localhost' is referenced as a definer account in a view. +DROP VIEW v1; +DROP TABLE t1; diff --git a/mysql-test/r/window_functions_explain.result-pq b/mysql-test/r/window_functions_explain.result-pq new file mode 100644 index 000000000000..96195c2aaf68 --- /dev/null +++ b/mysql-test/r/window_functions_explain.result-pq @@ -0,0 +1,16944 @@ +# Explain of SQL window functions. +# ---------------------------------------------------------------------- +SET NAMES utf8; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Single window function (plus ORDER BY). +CREATE TABLE t(i INT, j INT); +INSERT INTO t VALUES (1,1), (1,4), (1,2), (1,4); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +Single partition, no sorting +EXPLAIN FORMAT=JSON SELECT i, j, SUM(i+j) OVER (ROWS UNBOUNDED PRECEDING) foo FROM t; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.65" + }, + "windowing": { + "windows": [ + { + "name": "", + "functions": [ + "sum" + ] + } + ], + "table": { + "table_name": "t", + "access_type": "ALL", + "rows_examined_per_scan": 4, + "rows_produced_per_join": 4, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.40", + "prefix_cost": "0.65", + "data_read_per_join": "64" + }, + "used_columns": [ + "i", + "j" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`i` AS `i`,`test`.`t`.`j` AS `j`,sum((`test`.`t`.`i` + `test`.`t`.`j`)) OVER (ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) AS `foo` from `test`.`t` +EXPLAIN FORMAT=TRADITIONAL SELECT i, j, SUM(i+j) OVER (ROWS UNBOUNDED PRECEDING) foo FROM t; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL ALL NULL NULL NULL NULL 4 100.00 NULL +Warnings: +Note 3598 To get information about window functions use EXPLAIN FORMAT=JSON +Note 1003 /* select#1 */ select `test`.`t`.`i` AS `i`,`test`.`t`.`j` AS `j`,sum((`test`.`t`.`i` + `test`.`t`.`j`)) OVER (ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) AS `foo` from `test`.`t` +EXPLAIN FORMAT=JSON SELECT i, j, SUM(i+j) OVER (ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) foo FROM t; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.65" + }, + "windowing": { + "windows": [ + { + "name": "", + "functions": [ + "sum" + ] + } + ], + "table": { + "table_name": "t", + "access_type": "ALL", + "rows_examined_per_scan": 4, + "rows_produced_per_join": 4, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.40", + "prefix_cost": "0.65", + "data_read_per_join": "64" + }, + "used_columns": [ + "i", + "j" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`i` AS `i`,`test`.`t`.`j` AS `j`,sum((`test`.`t`.`i` + `test`.`t`.`j`)) OVER (ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) AS `foo` from `test`.`t` +EXPLAIN FORMAT=JSON SELECT i, j, SUM(i+j) OVER (ROWS UNBOUNDED PRECEDING) foo FROM t ORDER BY foo; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "4.65" + }, + "ordering_operation": { + "using_filesort": true, + "cost_info": { + "sort_cost": "4.00" + }, + "windowing": { + "windows": [ + { + "name": "", + "using_temporary_table": true, + "functions": [ + "sum" + ] + } + ], + "table": { + "table_name": "t", + "access_type": "ALL", + "rows_examined_per_scan": 4, + "rows_produced_per_join": 4, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.40", + "prefix_cost": "0.65", + "data_read_per_join": "64" + }, + "used_columns": [ + "i", + "j" + ] + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`i` AS `i`,`test`.`t`.`j` AS `j`,sum((`test`.`t`.`i` + `test`.`t`.`j`)) OVER (ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) AS `foo` from `test`.`t` order by `foo` +EXPLAIN FORMAT=JSON SELECT i, j, SUM(i+j) OVER (ROWS UNBOUNDED PRECEDING) foo FROM t ORDER BY foo DESC; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "4.65" + }, + "ordering_operation": { + "using_filesort": true, + "cost_info": { + "sort_cost": "4.00" + }, + "windowing": { + "windows": [ + { + "name": "", + "using_temporary_table": true, + "functions": [ + "sum" + ] + } + ], + "table": { + "table_name": "t", + "access_type": "ALL", + "rows_examined_per_scan": 4, + "rows_produced_per_join": 4, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.40", + "prefix_cost": "0.65", + "data_read_per_join": "64" + }, + "used_columns": [ + "i", + "j" + ] + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`i` AS `i`,`test`.`t`.`j` AS `j`,sum((`test`.`t`.`i` + `test`.`t`.`j`)) OVER (ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) AS `foo` from `test`.`t` order by `foo` desc +With LIMIT +EXPLAIN FORMAT=JSON SELECT i, j, SUM(i+j) OVER (ROWS UNBOUNDED PRECEDING) foo FROM t ORDER BY foo DESC LIMIT 3; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.65" + }, + "ordering_operation": { + "using_filesort": true, + "windowing": { + "windows": [ + { + "name": "", + "using_temporary_table": true, + "functions": [ + "sum" + ] + } + ], + "table": { + "table_name": "t", + "access_type": "ALL", + "rows_examined_per_scan": 4, + "rows_produced_per_join": 4, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.40", + "prefix_cost": "0.65", + "data_read_per_join": "64" + }, + "used_columns": [ + "i", + "j" + ] + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`i` AS `i`,`test`.`t`.`j` AS `j`,sum((`test`.`t`.`i` + `test`.`t`.`j`)) OVER (ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) AS `foo` from `test`.`t` order by `foo` desc limit 3 +Single ordered partition +EXPLAIN FORMAT=JSON SELECT i, j, SUM(i+j) OVER (ORDER BY j ROWS UNBOUNDED PRECEDING) foo FROM t; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "4.65" + }, + "windowing": { + "windows": [ + { + "name": "", + "using_filesort": true, + "filesort_key": [ + "`j`" + ], + "functions": [ + "sum" + ] + } + ], + "cost_info": { + "sort_cost": "4.00" + }, + "table": { + "table_name": "t", + "access_type": "ALL", + "rows_examined_per_scan": 4, + "rows_produced_per_join": 4, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.40", + "prefix_cost": "0.65", + "data_read_per_join": "64" + }, + "used_columns": [ + "i", + "j" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`i` AS `i`,`test`.`t`.`j` AS `j`,sum((`test`.`t`.`i` + `test`.`t`.`j`)) OVER (ORDER BY `test`.`t`.`j` ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) AS `foo` from `test`.`t` +EXPLAIN FORMAT=JSON SELECT i, j, SUM(i+j) OVER (ORDER BY j ROWS UNBOUNDED PRECEDING) foo FROM t ORDER BY foo; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "8.65" + }, + "ordering_operation": { + "using_filesort": true, + "cost_info": { + "sort_cost": "4.00" + }, + "windowing": { + "windows": [ + { + "name": "", + "using_temporary_table": true, + "using_filesort": true, + "filesort_key": [ + "`j`" + ], + "functions": [ + "sum" + ] + } + ], + "cost_info": { + "sort_cost": "4.00" + }, + "table": { + "table_name": "t", + "access_type": "ALL", + "rows_examined_per_scan": 4, + "rows_produced_per_join": 4, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.40", + "prefix_cost": "0.65", + "data_read_per_join": "64" + }, + "used_columns": [ + "i", + "j" + ] + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`i` AS `i`,`test`.`t`.`j` AS `j`,sum((`test`.`t`.`i` + `test`.`t`.`j`)) OVER (ORDER BY `test`.`t`.`j` ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) AS `foo` from `test`.`t` order by `foo` +EXPLAIN FORMAT=JSON SELECT i, j, SUM(i+j) OVER (ORDER BY j ROWS UNBOUNDED PRECEDING) foo FROM t ORDER BY foo DESC; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "8.65" + }, + "ordering_operation": { + "using_filesort": true, + "cost_info": { + "sort_cost": "4.00" + }, + "windowing": { + "windows": [ + { + "name": "", + "using_temporary_table": true, + "using_filesort": true, + "filesort_key": [ + "`j`" + ], + "functions": [ + "sum" + ] + } + ], + "cost_info": { + "sort_cost": "4.00" + }, + "table": { + "table_name": "t", + "access_type": "ALL", + "rows_examined_per_scan": 4, + "rows_produced_per_join": 4, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.40", + "prefix_cost": "0.65", + "data_read_per_join": "64" + }, + "used_columns": [ + "i", + "j" + ] + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`i` AS `i`,`test`.`t`.`j` AS `j`,sum((`test`.`t`.`i` + `test`.`t`.`j`)) OVER (ORDER BY `test`.`t`.`j` ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) AS `foo` from `test`.`t` order by `foo` desc +EXPLAIN FORMAT=JSON SELECT i, j, SUM(i+j) OVER (ORDER BY j DESC ROWS UNBOUNDED PRECEDING) foo FROM t; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "4.65" + }, + "windowing": { + "windows": [ + { + "name": "", + "using_filesort": true, + "filesort_key": [ + "`j` desc" + ], + "functions": [ + "sum" + ] + } + ], + "cost_info": { + "sort_cost": "4.00" + }, + "table": { + "table_name": "t", + "access_type": "ALL", + "rows_examined_per_scan": 4, + "rows_produced_per_join": 4, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.40", + "prefix_cost": "0.65", + "data_read_per_join": "64" + }, + "used_columns": [ + "i", + "j" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`i` AS `i`,`test`.`t`.`j` AS `j`,sum((`test`.`t`.`i` + `test`.`t`.`j`)) OVER (ORDER BY `test`.`t`.`j` desc ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) AS `foo` from `test`.`t` +EXPLAIN FORMAT=TRADITIONAL SELECT i, j, SUM(i+j) OVER (ORDER BY j DESC ROWS UNBOUNDED PRECEDING) foo FROM t; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL ALL NULL NULL NULL NULL 4 100.00 Using filesort +Warnings: +Note 3598 To get information about window functions use EXPLAIN FORMAT=JSON +Note 1003 /* select#1 */ select `test`.`t`.`i` AS `i`,`test`.`t`.`j` AS `j`,sum((`test`.`t`.`i` + `test`.`t`.`j`)) OVER (ORDER BY `test`.`t`.`j` desc ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) AS `foo` from `test`.`t` +View with window function +CREATE VIEW v AS +SELECT i, j, SUM(i+j) OVER (ORDER BY j DESC ROWS UNBOUNDED PRECEDING) foo FROM t; +SHOW CREATE VIEW v; +View Create View character_set_client collation_connection +v CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v` AS select `t`.`i` AS `i`,`t`.`j` AS `j`,sum((`t`.`i` + `t`.`j`)) OVER (ORDER BY `t`.`j` desc ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) AS `foo` from `t` utf8 utf8_general_ci +EXPLAIN FORMAT=JSON SELECT * FROM v; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "2.95" + }, + "table": { + "table_name": "v", + "access_type": "ALL", + "rows_examined_per_scan": 4, + "rows_produced_per_join": 4, + "filtered": "100.00", + "cost_info": { + "read_cost": "2.55", + "eval_cost": "0.40", + "prefix_cost": "2.95", + "data_read_per_join": "128" + }, + "used_columns": [ + "i", + "j", + "foo" + ], + "materialized_from_subquery": { + "using_temporary_table": true, + "dependent": false, + "cacheable": true, + "query_block": { + "select_id": 2, + "cost_info": { + "query_cost": "4.65" + }, + "windowing": { + "windows": [ + { + "name": "", + "using_filesort": true, + "filesort_key": [ + "`j` desc" + ], + "functions": [ + "sum" + ] + } + ], + "cost_info": { + "sort_cost": "4.00" + }, + "table": { + "table_name": "t", + "access_type": "ALL", + "rows_examined_per_scan": 4, + "rows_produced_per_join": 4, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.40", + "prefix_cost": "0.65", + "data_read_per_join": "64" + }, + "used_columns": [ + "i", + "j" + ] + } + } + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`v`.`i` AS `i`,`test`.`v`.`j` AS `j`,`test`.`v`.`foo` AS `foo` from `test`.`v` +DROP VIEW v; +EXPLAIN FORMAT=JSON SELECT i, j, SUM(i+j) OVER (ORDER BY j DESC ROWS UNBOUNDED PRECEDING) foo FROM t ORDER BY foo; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "8.65" + }, + "ordering_operation": { + "using_filesort": true, + "cost_info": { + "sort_cost": "4.00" + }, + "windowing": { + "windows": [ + { + "name": "", + "using_temporary_table": true, + "using_filesort": true, + "filesort_key": [ + "`j` desc" + ], + "functions": [ + "sum" + ] + } + ], + "cost_info": { + "sort_cost": "4.00" + }, + "table": { + "table_name": "t", + "access_type": "ALL", + "rows_examined_per_scan": 4, + "rows_produced_per_join": 4, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.40", + "prefix_cost": "0.65", + "data_read_per_join": "64" + }, + "used_columns": [ + "i", + "j" + ] + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`i` AS `i`,`test`.`t`.`j` AS `j`,sum((`test`.`t`.`i` + `test`.`t`.`j`)) OVER (ORDER BY `test`.`t`.`j` desc ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) AS `foo` from `test`.`t` order by `foo` +EXPLAIN FORMAT=JSON SELECT i, j, SUM(i+j) OVER (ORDER BY j DESC ROWS UNBOUNDED PRECEDING) foo FROM t ORDER BY foo DESC; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "8.65" + }, + "ordering_operation": { + "using_filesort": true, + "cost_info": { + "sort_cost": "4.00" + }, + "windowing": { + "windows": [ + { + "name": "", + "using_temporary_table": true, + "using_filesort": true, + "filesort_key": [ + "`j` desc" + ], + "functions": [ + "sum" + ] + } + ], + "cost_info": { + "sort_cost": "4.00" + }, + "table": { + "table_name": "t", + "access_type": "ALL", + "rows_examined_per_scan": 4, + "rows_produced_per_join": 4, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.40", + "prefix_cost": "0.65", + "data_read_per_join": "64" + }, + "used_columns": [ + "i", + "j" + ] + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`i` AS `i`,`test`.`t`.`j` AS `j`,sum((`test`.`t`.`i` + `test`.`t`.`j`)) OVER (ORDER BY `test`.`t`.`j` desc ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) AS `foo` from `test`.`t` order by `foo` desc +TRUNCATE TABLE t; +Check my_decimal bug: no warning if c=a+b and c is one of a,b... just fails over 9 digits +INSERT INTO t VALUES (999961560, DEFAULT), (44721, DEFAULT); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +EXPLAIN FORMAT=JSON SELECT SUM(i) OVER () FROM t; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.45" + }, + "windowing": { + "windows": [ + { + "name": "", + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "sum" + ] + } + ], + "table": { + "table_name": "t", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 2, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.20", + "prefix_cost": "0.45", + "data_read_per_join": "32" + }, + "used_columns": [ + "i" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select sum(`test`.`t`.`i`) OVER () AS `SUM(i) OVER ()` from `test`.`t` +DROP TABLE t; +CREATE TABLE t(i INT, j INT, k INT); +INSERT INTO t VALUES (1,1,1), (1,4,1), (1,2,1), (1,4,1); +INSERT INTO t VALUES (1,1,2), (1,4,2), (1,2,2), (1,4,2); +INSERT INTO t VALUES (1,1,3), (1,4,3), (1,2,3), (1,4,3); +INSERT INTO t VALUES (1,1,4), (1,4,4), (1,2,4), (1,4,4); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +---------------------------------------------------------------------- +- Combination with GROUP BY +---------------------------------------------------------------------- +EXPLAIN FORMAT=JSON SELECT k, SUM(k) OVER (ROWS UNBOUNDED PRECEDING) wf FROM t; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.85" + }, + "windowing": { + "windows": [ + { + "name": "", + "functions": [ + "sum" + ] + } + ], + "table": { + "table_name": "t", + "access_type": "ALL", + "rows_examined_per_scan": 16, + "rows_produced_per_join": 16, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "1.60", + "prefix_cost": "1.85", + "data_read_per_join": "256" + }, + "used_columns": [ + "k" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`k` AS `k`,sum(`test`.`t`.`k`) OVER (ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) AS `wf` from `test`.`t` +EXPLAIN FORMAT=JSON SELECT k, MIN(i), SUM(j), SUM(k) OVER (ROWS UNBOUNDED PRECEDING) wf FROM t GROUP BY (k); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.85" + }, + "windowing": { + "windows": [ + { + "name": "", + "functions": [ + "sum" + ] + } + ], + "grouping_operation": { + "using_temporary_table": true, + "using_filesort": false, + "table": { + "table_name": "t", + "access_type": "ALL", + "rows_examined_per_scan": 16, + "rows_produced_per_join": 16, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "1.60", + "prefix_cost": "1.85", + "data_read_per_join": "256" + }, + "used_columns": [ + "i", + "j", + "k" + ] + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`k` AS `k`,min(`test`.`t`.`i`) AS `MIN(i)`,sum(`test`.`t`.`j`) AS `SUM(j)`,sum(`test`.`t`.`k`) OVER (ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) AS `wf` from `test`.`t` group by `test`.`t`.`k` +EXPLAIN FORMAT=JSON SELECT k, MIN(i), SUM(j), SUM(k) OVER (ROWS UNBOUNDED PRECEDING) wf FROM t GROUP BY (k) ORDER BY wf DESC; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.85" + }, + "ordering_operation": { + "using_filesort": true, + "windowing": { + "windows": [ + { + "name": "", + "using_temporary_table": true, + "functions": [ + "sum" + ] + } + ], + "grouping_operation": { + "using_temporary_table": true, + "using_filesort": false, + "table": { + "table_name": "t", + "access_type": "ALL", + "rows_examined_per_scan": 16, + "rows_produced_per_join": 16, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "1.60", + "prefix_cost": "1.85", + "data_read_per_join": "256" + }, + "used_columns": [ + "i", + "j", + "k" + ] + } + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`k` AS `k`,min(`test`.`t`.`i`) AS `MIN(i)`,sum(`test`.`t`.`j`) AS `SUM(j)`,sum(`test`.`t`.`k`) OVER (ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) AS `wf` from `test`.`t` group by `test`.`t`.`k` order by `wf` desc +EXPLAIN FORMAT=JSON SELECT k, GROUP_CONCAT(j ORDER BY j), SUM(k) OVER (ROWS UNBOUNDED PRECEDING) foo FROM t GROUP BY (k); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "17.85" + }, + "windowing": { + "windows": [ + { + "name": "", + "functions": [ + "sum" + ] + } + ], + "grouping_operation": { + "using_temporary_table": true, + "using_filesort": true, + "cost_info": { + "sort_cost": "16.00" + }, + "buffer_result": { + "using_temporary_table": true, + "table": { + "table_name": "t", + "access_type": "ALL", + "rows_examined_per_scan": 16, + "rows_produced_per_join": 16, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "1.60", + "prefix_cost": "1.85", + "data_read_per_join": "256" + }, + "used_columns": [ + "j", + "k" + ] + } + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`k` AS `k`,group_concat(`test`.`t`.`j` order by `test`.`t`.`j` ASC separator ',') AS `GROUP_CONCAT(j ORDER BY j)`,sum(`test`.`t`.`k`) OVER (ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) AS `foo` from `test`.`t` group by `test`.`t`.`k` +EXPLAIN FORMAT=JSON SELECT k, AVG(DISTINCT j), SUM(k) OVER (ROWS UNBOUNDED PRECEDING) foo FROM t GROUP BY (k); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "17.85" + }, + "windowing": { + "windows": [ + { + "name": "", + "functions": [ + "sum" + ] + } + ], + "grouping_operation": { + "using_temporary_table": true, + "using_filesort": true, + "cost_info": { + "sort_cost": "16.00" + }, + "buffer_result": { + "using_temporary_table": true, + "table": { + "table_name": "t", + "access_type": "ALL", + "rows_examined_per_scan": 16, + "rows_produced_per_join": 16, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "1.60", + "prefix_cost": "1.85", + "data_read_per_join": "256" + }, + "used_columns": [ + "j", + "k" + ] + } + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`k` AS `k`,avg(distinct `test`.`t`.`j`) AS `AVG(DISTINCT j)`,sum(`test`.`t`.`k`) OVER (ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) AS `foo` from `test`.`t` group by `test`.`t`.`k` +EXPLAIN FORMAT=JSON SELECT k, GROUP_CONCAT(j ORDER BY j), SUM(k+1) OVER (ROWS UNBOUNDED PRECEDING) foo FROM t GROUP BY (k); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "17.85" + }, + "windowing": { + "windows": [ + { + "name": "", + "functions": [ + "sum" + ] + } + ], + "grouping_operation": { + "using_temporary_table": true, + "using_filesort": true, + "cost_info": { + "sort_cost": "16.00" + }, + "buffer_result": { + "using_temporary_table": true, + "table": { + "table_name": "t", + "access_type": "ALL", + "rows_examined_per_scan": 16, + "rows_produced_per_join": 16, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "1.60", + "prefix_cost": "1.85", + "data_read_per_join": "256" + }, + "used_columns": [ + "j", + "k" + ] + } + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`k` AS `k`,group_concat(`test`.`t`.`j` order by `test`.`t`.`j` ASC separator ',') AS `GROUP_CONCAT(j ORDER BY j)`,sum((`test`.`t`.`k` + 1)) OVER (ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) AS `foo` from `test`.`t` group by `test`.`t`.`k` +EXPLAIN FORMAT=JSON SELECT k, GROUP_CONCAT(j ORDER BY j), SUM(k+1) OVER (ORDER BY k DESC ROWS UNBOUNDED PRECEDING) foo FROM t GROUP BY (k); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "33.85" + }, + "windowing": { + "windows": [ + { + "name": "", + "using_filesort": true, + "filesort_key": [ + "`k` desc" + ], + "functions": [ + "sum" + ] + } + ], + "cost_info": { + "sort_cost": "16.00" + }, + "grouping_operation": { + "using_temporary_table": true, + "using_filesort": true, + "cost_info": { + "sort_cost": "16.00" + }, + "buffer_result": { + "using_temporary_table": true, + "table": { + "table_name": "t", + "access_type": "ALL", + "rows_examined_per_scan": 16, + "rows_produced_per_join": 16, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "1.60", + "prefix_cost": "1.85", + "data_read_per_join": "256" + }, + "used_columns": [ + "j", + "k" + ] + } + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`k` AS `k`,group_concat(`test`.`t`.`j` order by `test`.`t`.`j` ASC separator ',') AS `GROUP_CONCAT(j ORDER BY j)`,sum((`test`.`t`.`k` + 1)) OVER (ORDER BY `test`.`t`.`k` desc ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) AS `foo` from `test`.`t` group by `test`.`t`.`k` +DROP TABLE t; +---------------------------------------------------------------------- +- Some RANK, DENSE_RANK tests +---------------------------------------------------------------------- +CREATE TABLE t1 (id INTEGER, sex CHAR(1)); +INSERT INTO t1 VALUES (1, 'M'), +(2, 'F'), +(3, 'F'), +(4, 'F'), +(5, 'M'); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +CREATE TABLE t2 (user_id INTEGER NOT NULL, date DATE); +INSERT INTO t2 VALUES (1, '2002-06-09'), +(2, '2002-06-09'), +(1, '2002-06-09'), +(3, '2002-06-09'), +(4, '2002-06-09'), +(4, '2002-06-09'), +(5, '2002-06-09'); +ANALYZE TABLE t2; +Table Op Msg_type Msg_text +test.t2 analyze status OK +EXPLAIN FORMAT=JSON SELECT RANK() OVER (ORDER BY user_id) r FROM t2; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "7.95" + }, + "windowing": { + "windows": [ + { + "name": "", + "using_filesort": true, + "filesort_key": [ + "`user_id`" + ], + "functions": [ + "rank" + ] + } + ], + "cost_info": { + "sort_cost": "7.00" + }, + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.70", + "prefix_cost": "0.95", + "data_read_per_join": "112" + }, + "used_columns": [ + "user_id" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select rank() OVER (ORDER BY `test`.`t2`.`user_id` ) AS `r` from `test`.`t2` +EXPLAIN FORMAT=JSON SELECT DENSE_RANK() OVER (ORDER BY user_id) r FROM t2; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "7.95" + }, + "windowing": { + "windows": [ + { + "name": "", + "using_filesort": true, + "filesort_key": [ + "`user_id`" + ], + "functions": [ + "dense_rank" + ] + } + ], + "cost_info": { + "sort_cost": "7.00" + }, + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.70", + "prefix_cost": "0.95", + "data_read_per_join": "112" + }, + "used_columns": [ + "user_id" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select dense_rank() OVER (ORDER BY `test`.`t2`.`user_id` ) AS `r` from `test`.`t2` +EXPLAIN FORMAT=JSON SELECT sex, SUM(DISTINCT id) AS uids FROM t1 u, t2 +WHERE t2.user_id = u.id GROUP BY sex ORDER BY uids; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "4.50" + }, + "ordering_operation": { + "using_filesort": true, + "grouping_operation": { + "using_temporary_table": true, + "using_filesort": true, + "buffer_result": { + "using_temporary_table": true, + "nested_loop": [ + { + "table": { + "table_name": "u", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "80" + }, + "used_columns": [ + "id", + "sex" + ] + } + }, + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 5, + "filtered": "14.29", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "4.50", + "data_read_per_join": "80" + }, + "used_columns": [ + "user_id" + ], + "attached_condition": "(`test`.`t2`.`user_id` = `test`.`u`.`id`)" + } + } + ] + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`u`.`sex` AS `sex`,sum(distinct `test`.`t1`.`id`) AS `uids` from `test`.`t1` `u` join `test`.`t2` where (`test`.`t2`.`user_id` = `test`.`u`.`id`) group by `test`.`u`.`sex` order by `uids` +EXPLAIN FORMAT=JSON SELECT id, sex, RANK() OVER (ORDER BY sex) FROM t1 ORDER BY id; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "10.75" + }, + "ordering_operation": { + "using_filesort": true, + "cost_info": { + "sort_cost": "5.00" + }, + "windowing": { + "windows": [ + { + "name": "", + "using_temporary_table": true, + "using_filesort": true, + "filesort_key": [ + "`sex`" + ], + "functions": [ + "rank" + ] + } + ], + "cost_info": { + "sort_cost": "5.00" + }, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "80" + }, + "used_columns": [ + "id", + "sex" + ] + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,`test`.`t1`.`sex` AS `sex`,rank() OVER (ORDER BY `test`.`t1`.`sex` ) AS `RANK() OVER (ORDER BY sex)` from `test`.`t1` order by `test`.`t1`.`id` +EXPLAIN FORMAT=JSON SELECT id, sex, DENSE_RANK() OVER (ORDER BY sex) FROM t1 ORDER BY id; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "10.75" + }, + "ordering_operation": { + "using_filesort": true, + "cost_info": { + "sort_cost": "5.00" + }, + "windowing": { + "windows": [ + { + "name": "", + "using_temporary_table": true, + "using_filesort": true, + "filesort_key": [ + "`sex`" + ], + "functions": [ + "dense_rank" + ] + } + ], + "cost_info": { + "sort_cost": "5.00" + }, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "80" + }, + "used_columns": [ + "id", + "sex" + ] + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,`test`.`t1`.`sex` AS `sex`,dense_rank() OVER (ORDER BY `test`.`t1`.`sex` ) AS `DENSE_RANK() OVER (ORDER BY sex)` from `test`.`t1` order by `test`.`t1`.`id` +EXPLAIN FORMAT=JSON SELECT sex, RANK() OVER (ORDER BY sex DESC) `rank`, AVG(DISTINCT id) AS uids FROM t1 u, t2 +WHERE t2.user_id = u.id GROUP BY sex ORDER BY sex; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "19.50" + }, + "ordering_operation": { + "using_filesort": true, + "cost_info": { + "sort_cost": "5.00" + }, + "windowing": { + "windows": [ + { + "name": "", + "using_temporary_table": true, + "using_filesort": true, + "filesort_key": [ + "`sex` desc" + ], + "functions": [ + "rank" + ] + } + ], + "cost_info": { + "sort_cost": "5.00" + }, + "grouping_operation": { + "using_temporary_table": true, + "using_filesort": true, + "cost_info": { + "sort_cost": "5.00" + }, + "buffer_result": { + "using_temporary_table": true, + "nested_loop": [ + { + "table": { + "table_name": "u", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "80" + }, + "used_columns": [ + "id", + "sex" + ] + } + }, + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 5, + "filtered": "14.29", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "4.50", + "data_read_per_join": "80" + }, + "used_columns": [ + "user_id" + ], + "attached_condition": "(`test`.`t2`.`user_id` = `test`.`u`.`id`)" + } + } + ] + } + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`u`.`sex` AS `sex`,rank() OVER (ORDER BY `test`.`u`.`sex` desc ) AS `rank`,avg(distinct `test`.`t1`.`id`) AS `uids` from `test`.`t1` `u` join `test`.`t2` where (`test`.`t2`.`user_id` = `test`.`u`.`id`) group by `test`.`u`.`sex` order by `test`.`u`.`sex` +Explicit window definition, WINDOW DESC ordering from GROUP BY +EXPLAIN FORMAT=JSON SELECT sex, AVG(id) AS uids, RANK() OVER w `rank` FROM t1 u, t2 +WHERE t2.user_id = u.id GROUP BY sex +WINDOW w AS (ORDER BY AVG(id)); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "9.50" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "avg(`id`)" + ], + "functions": [ + "rank" + ] + } + ], + "cost_info": { + "sort_cost": "5.00" + }, + "grouping_operation": { + "using_temporary_table": true, + "using_filesort": false, + "nested_loop": [ + { + "table": { + "table_name": "u", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "80" + }, + "used_columns": [ + "id", + "sex" + ] + } + }, + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 5, + "filtered": "14.29", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "4.50", + "data_read_per_join": "80" + }, + "used_columns": [ + "user_id" + ], + "attached_condition": "(`test`.`t2`.`user_id` = `test`.`u`.`id`)" + } + } + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`u`.`sex` AS `sex`,avg(`test`.`u`.`id`) AS `uids`,rank() OVER `w` AS `rank` from `test`.`t1` `u` join `test`.`t2` where (`test`.`t2`.`user_id` = `test`.`u`.`id`) group by `test`.`u`.`sex` window `w` AS (ORDER BY avg(`test`.`u`.`id`) ) +Explicit window definition, window ordering from DISTINCT GROUP BY +EXPLAIN FORMAT=JSON SELECT sex, AVG(DISTINCT id) AS uids, RANK() OVER w `rank` FROM t1 u, t2 +WHERE t2.user_id = u.id GROUP BY sex +WINDOW w AS (ORDER BY AVG(DISTINCT id) DESC) ORDER BY sex; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "19.50" + }, + "ordering_operation": { + "using_filesort": true, + "cost_info": { + "sort_cost": "5.00" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_temporary_table": true, + "using_filesort": true, + "filesort_key": [ + "avg(distinct `id`) desc" + ], + "functions": [ + "rank" + ] + } + ], + "cost_info": { + "sort_cost": "5.00" + }, + "grouping_operation": { + "using_temporary_table": true, + "using_filesort": true, + "cost_info": { + "sort_cost": "5.00" + }, + "buffer_result": { + "using_temporary_table": true, + "nested_loop": [ + { + "table": { + "table_name": "u", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "80" + }, + "used_columns": [ + "id", + "sex" + ] + } + }, + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 5, + "filtered": "14.29", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "4.50", + "data_read_per_join": "80" + }, + "used_columns": [ + "user_id" + ], + "attached_condition": "(`test`.`t2`.`user_id` = `test`.`u`.`id`)" + } + } + ] + } + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`u`.`sex` AS `sex`,avg(distinct `test`.`t1`.`id`) AS `uids`,rank() OVER `w` AS `rank` from `test`.`t1` `u` join `test`.`t2` where (`test`.`t2`.`user_id` = `test`.`u`.`id`) group by `test`.`u`.`sex` window `w` AS (ORDER BY avg(distinct `test`.`t1`.`id`) desc ) order by `test`.`u`.`sex` +Explicit window definition, window ordering from GROUP BY, final ORDER BY +EXPLAIN FORMAT=JSON SELECT sex, AVG(id) AS uids, RANK() OVER w `rank` FROM t1 u, t2 +WHERE t2.user_id = u.id GROUP BY sex +WINDOW w AS (ORDER BY AVG(id) DESC) +ORDER BY `rank` DESC; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "9.50" + }, + "ordering_operation": { + "using_filesort": true, + "windowing": { + "windows": [ + { + "name": "w", + "using_temporary_table": true, + "using_filesort": true, + "filesort_key": [ + "avg(`id`) desc" + ], + "functions": [ + "rank" + ] + } + ], + "cost_info": { + "sort_cost": "5.00" + }, + "grouping_operation": { + "using_temporary_table": true, + "using_filesort": false, + "nested_loop": [ + { + "table": { + "table_name": "u", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "80" + }, + "used_columns": [ + "id", + "sex" + ] + } + }, + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 5, + "filtered": "14.29", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "4.50", + "data_read_per_join": "80" + }, + "used_columns": [ + "user_id" + ], + "attached_condition": "(`test`.`t2`.`user_id` = `test`.`u`.`id`)" + } + } + ] + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`u`.`sex` AS `sex`,avg(`test`.`u`.`id`) AS `uids`,rank() OVER `w` AS `rank` from `test`.`t1` `u` join `test`.`t2` where (`test`.`t2`.`user_id` = `test`.`u`.`id`) group by `test`.`u`.`sex` window `w` AS (ORDER BY avg(`test`.`u`.`id`) desc ) order by `rank` desc +EXPLAIN FORMAT=TRADITIONAL SELECT sex, AVG(id) AS uids, RANK() OVER w `rank` FROM t1 u, t2 +WHERE t2.user_id = u.id GROUP BY sex +WINDOW w AS (ORDER BY AVG(id) DESC) +ORDER BY `rank` DESC; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE u NULL ALL NULL NULL NULL NULL 5 100.00 Using temporary; Using filesort +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 7 14.29 Using where; Using join buffer (hash join) +Warnings: +Note 3598 To get information about window functions use EXPLAIN FORMAT=JSON +Note 1003 /* select#1 */ select `test`.`u`.`sex` AS `sex`,avg(`test`.`u`.`id`) AS `uids`,rank() OVER `w` AS `rank` from `test`.`t1` `u` join `test`.`t2` where (`test`.`t2`.`user_id` = `test`.`u`.`id`) group by `test`.`u`.`sex` window `w` AS (ORDER BY avg(`test`.`u`.`id`) desc ) order by `rank` desc +With NULLs +INSERT INTO t1 VALUES (10, NULL), (11, NULL); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN FORMAT=JSON SELECT id, sex, RANK() OVER w, DENSE_RANK() OVER w FROM t1 +WINDOW w AS (ORDER BY sex) ORDER BY id; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "14.95" + }, + "ordering_operation": { + "using_filesort": true, + "cost_info": { + "sort_cost": "7.00" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_temporary_table": true, + "using_filesort": true, + "filesort_key": [ + "`sex`" + ], + "functions": [ + "rank", + "dense_rank" + ] + } + ], + "cost_info": { + "sort_cost": "7.00" + }, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.70", + "prefix_cost": "0.95", + "data_read_per_join": "112" + }, + "used_columns": [ + "id", + "sex" + ] + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,`test`.`t1`.`sex` AS `sex`,rank() OVER `w` AS `RANK() OVER w`,dense_rank() OVER `w` AS `DENSE_RANK() OVER w` from `test`.`t1` window `w` AS (ORDER BY `test`.`t1`.`sex` ) order by `test`.`t1`.`id` +EXPLAIN FORMAT=JSON SELECT id, sex, RANK() OVER (ORDER BY sex DESC) FROM t1 ORDER BY id; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "14.95" + }, + "ordering_operation": { + "using_filesort": true, + "cost_info": { + "sort_cost": "7.00" + }, + "windowing": { + "windows": [ + { + "name": "", + "using_temporary_table": true, + "using_filesort": true, + "filesort_key": [ + "`sex` desc" + ], + "functions": [ + "rank" + ] + } + ], + "cost_info": { + "sort_cost": "7.00" + }, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.70", + "prefix_cost": "0.95", + "data_read_per_join": "112" + }, + "used_columns": [ + "id", + "sex" + ] + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,`test`.`t1`.`sex` AS `sex`,rank() OVER (ORDER BY `test`.`t1`.`sex` desc ) AS `RANK() OVER (ORDER BY sex DESC)` from `test`.`t1` order by `test`.`t1`.`id` +EXPLAIN FORMAT=JSON SELECT id value, +SUM(id) OVER (ROWS UNBOUNDED PRECEDING) +FROM t1 u, t2 WHERE t2.user_id = u.id; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "6.10" + }, + "windowing": { + "windows": [ + { + "name": "", + "functions": [ + "sum" + ] + } + ], + "nested_loop": [ + { + "table": { + "table_name": "u", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.70", + "prefix_cost": "0.95", + "data_read_per_join": "112" + }, + "used_columns": [ + "id" + ] + } + }, + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "14.29", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.70", + "prefix_cost": "6.10", + "data_read_per_join": "112" + }, + "used_columns": [ + "user_id" + ], + "attached_condition": "(`test`.`t2`.`user_id` = `test`.`u`.`id`)" + } + } + ] + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`u`.`id` AS `value`,sum(`test`.`u`.`id`) OVER (ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) AS `SUM(id) OVER (ROWS UNBOUNDED PRECEDING)` from `test`.`t1` `u` join `test`.`t2` where (`test`.`t2`.`user_id` = `test`.`u`.`id`) +Aggregate with GROUP BY arguments to window function +EXPLAIN FORMAT=JSON SELECT AVG(id) average, +SUM(AVG(id)) OVER (ROWS UNBOUNDED PRECEDING) +FROM t1 u, t2 WHERE t2.user_id = u.id GROUP BY sex; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "6.10" + }, + "windowing": { + "windows": [ + { + "name": "", + "functions": [ + "sum" + ] + } + ], + "grouping_operation": { + "using_temporary_table": true, + "using_filesort": false, + "nested_loop": [ + { + "table": { + "table_name": "u", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.70", + "prefix_cost": "0.95", + "data_read_per_join": "112" + }, + "used_columns": [ + "id", + "sex" + ] + } + }, + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "14.29", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.70", + "prefix_cost": "6.10", + "data_read_per_join": "112" + }, + "used_columns": [ + "user_id" + ], + "attached_condition": "(`test`.`t2`.`user_id` = `test`.`u`.`id`)" + } + } + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select avg(`test`.`u`.`id`) AS `average`,sum(avg(`test`.`u`.`id`)) OVER (ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) AS `SUM(AVG(id)) OVER (ROWS UNBOUNDED PRECEDING)` from `test`.`t1` `u` join `test`.`t2` where (`test`.`t2`.`user_id` = `test`.`u`.`id`) group by `test`.`u`.`sex` +Aggregate with GROUP BY in window's ORDER BY clause, with aggregate present in +SELECT list or not. +EXPLAIN FORMAT=JSON SELECT sex, AVG(id), RANK() OVER (ORDER BY AVG(id) DESC) FROM t1 GROUP BY sex ORDER BY sex; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "14.95" + }, + "ordering_operation": { + "using_filesort": true, + "cost_info": { + "sort_cost": "7.00" + }, + "windowing": { + "windows": [ + { + "name": "", + "using_temporary_table": true, + "using_filesort": true, + "filesort_key": [ + "avg(`id`) desc" + ], + "functions": [ + "rank" + ] + } + ], + "cost_info": { + "sort_cost": "7.00" + }, + "grouping_operation": { + "using_temporary_table": true, + "using_filesort": false, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.70", + "prefix_cost": "0.95", + "data_read_per_join": "112" + }, + "used_columns": [ + "id", + "sex" + ] + } + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`sex` AS `sex`,avg(`test`.`t1`.`id`) AS `AVG(id)`,rank() OVER (ORDER BY avg(`test`.`t1`.`id`) desc ) AS `RANK() OVER (ORDER BY AVG(id) DESC)` from `test`.`t1` group by `test`.`t1`.`sex` order by `test`.`t1`.`sex` +EXPLAIN FORMAT=JSON SELECT sex, RANK() OVER (ORDER BY AVG(id) DESC) FROM t1 GROUP BY sex ORDER BY sex; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "14.95" + }, + "ordering_operation": { + "using_filesort": true, + "cost_info": { + "sort_cost": "7.00" + }, + "windowing": { + "windows": [ + { + "name": "", + "using_temporary_table": true, + "using_filesort": true, + "filesort_key": [ + "avg(`id`) desc" + ], + "functions": [ + "rank" + ] + } + ], + "cost_info": { + "sort_cost": "7.00" + }, + "grouping_operation": { + "using_temporary_table": true, + "using_filesort": false, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.70", + "prefix_cost": "0.95", + "data_read_per_join": "112" + }, + "used_columns": [ + "id", + "sex" + ] + } + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`sex` AS `sex`,rank() OVER (ORDER BY avg(`test`.`t1`.`id`) desc ) AS `RANK() OVER (ORDER BY AVG(id) DESC)` from `test`.`t1` group by `test`.`t1`.`sex` order by `test`.`t1`.`sex` +Implicit group aggregate arguments to window function and in +window's ORDER BY clause +EXPLAIN FORMAT=JSON SELECT RANK() OVER (ORDER BY AVG(id)) FROM t1; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.95" + }, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.70", + "prefix_cost": "0.95", + "data_read_per_join": "112" + }, + "used_columns": [ + "id" + ] + } + } +} +Warnings: +Note 1003 /* select#1 */ select rank() OVER (ORDER BY avg(`test`.`t1`.`id`) ) AS `RANK() OVER (ORDER BY AVG(id))` from `test`.`t1` +EXPLAIN FORMAT=JSON SELECT AVG(id), RANK() OVER (ORDER BY AVG(id)) FROM t1; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.95" + }, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.70", + "prefix_cost": "0.95", + "data_read_per_join": "112" + }, + "used_columns": [ + "id" + ] + } + } +} +Warnings: +Note 1003 /* select#1 */ select avg(`test`.`t1`.`id`) AS `AVG(id)`,rank() OVER (ORDER BY avg(`test`.`t1`.`id`) ) AS `RANK() OVER (ORDER BY AVG(id))` from `test`.`t1` +EXPLAIN FORMAT=JSON SELECT AVG(id), SUM(AVG(id)) OVER (ORDER BY AVG(id) ROWS UNBOUNDED PRECEDING) FROM t1; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.95" + }, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.70", + "prefix_cost": "0.95", + "data_read_per_join": "112" + }, + "used_columns": [ + "id" + ] + } + } +} +Warnings: +Note 1003 /* select#1 */ select avg(`test`.`t1`.`id`) AS `AVG(id)`,sum(avg(`test`.`t1`.`id`)) OVER (ORDER BY avg(`test`.`t1`.`id`) ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) AS `SUM(AVG(id)) OVER (ORDER BY AVG(id) ROWS UNBOUNDED PRECEDING)` from `test`.`t1` +Several partitions, several window functions over the same window +EXPLAIN FORMAT=JSON SELECT sex, id, RANK() OVER (PARTITION BY sex ORDER BY id DESC) FROM t1; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "7.95" + }, + "windowing": { + "windows": [ + { + "name": "", + "using_filesort": true, + "filesort_key": [ + "`sex`", + "`id` desc" + ], + "functions": [ + "rank" + ] + } + ], + "cost_info": { + "sort_cost": "7.00" + }, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.70", + "prefix_cost": "0.95", + "data_read_per_join": "112" + }, + "used_columns": [ + "id", + "sex" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`sex` AS `sex`,`test`.`t1`.`id` AS `id`,rank() OVER (PARTITION BY `test`.`t1`.`sex` ORDER BY `test`.`t1`.`id` desc ) AS `RANK() OVER (PARTITION BY sex ORDER BY id DESC)` from `test`.`t1` +EXPLAIN FORMAT=JSON SELECT sex, id, RANK() OVER (PARTITION BY sex ORDER BY id ASC) FROM t1; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "7.95" + }, + "windowing": { + "windows": [ + { + "name": "", + "using_filesort": true, + "filesort_key": [ + "`sex`", + "`id`" + ], + "functions": [ + "rank" + ] + } + ], + "cost_info": { + "sort_cost": "7.00" + }, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.70", + "prefix_cost": "0.95", + "data_read_per_join": "112" + }, + "used_columns": [ + "id", + "sex" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`sex` AS `sex`,`test`.`t1`.`id` AS `id`,rank() OVER (PARTITION BY `test`.`t1`.`sex` ORDER BY `test`.`t1`.`id` ) AS `RANK() OVER (PARTITION BY sex ORDER BY id ASC)` from `test`.`t1` +EXPLAIN FORMAT=JSON SELECT sex, id, SUM(id) OVER w summ, RANK() OVER w `rank` FROM t1 +WINDOW w AS (PARTITION BY sex ORDER BY id ASC ROWS UNBOUNDED PRECEDING); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "7.95" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`sex`", + "`id`" + ], + "functions": [ + "sum", + "rank" + ] + } + ], + "cost_info": { + "sort_cost": "7.00" + }, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.70", + "prefix_cost": "0.95", + "data_read_per_join": "112" + }, + "used_columns": [ + "id", + "sex" + ] + } + } + } +} +Warnings: +Note 3599 Window function 'rank' ignores the frame clause of window 'w' and aggregates over the whole partition +Note 1003 /* select#1 */ select `test`.`t1`.`sex` AS `sex`,`test`.`t1`.`id` AS `id`,sum(`test`.`t1`.`id`) OVER `w` AS `summ`,rank() OVER `w` AS `rank` from `test`.`t1` window `w` AS (PARTITION BY `test`.`t1`.`sex` ORDER BY `test`.`t1`.`id` ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) +EXPLAIN FORMAT=JSON SELECT sex, id, SUM(id) OVER w summ, RANK() OVER w `rank` FROM t1 +WINDOW w AS (PARTITION BY sex ORDER BY id ASC ROWS UNBOUNDED PRECEDING) ORDER BY summ; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "14.95" + }, + "ordering_operation": { + "using_filesort": true, + "cost_info": { + "sort_cost": "7.00" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_temporary_table": true, + "using_filesort": true, + "filesort_key": [ + "`sex`", + "`id`" + ], + "functions": [ + "sum", + "rank" + ] + } + ], + "cost_info": { + "sort_cost": "7.00" + }, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.70", + "prefix_cost": "0.95", + "data_read_per_join": "112" + }, + "used_columns": [ + "id", + "sex" + ] + } + } + } + } +} +Warnings: +Note 3599 Window function 'rank' ignores the frame clause of window 'w' and aggregates over the whole partition +Note 1003 /* select#1 */ select `test`.`t1`.`sex` AS `sex`,`test`.`t1`.`id` AS `id`,sum(`test`.`t1`.`id`) OVER `w` AS `summ`,rank() OVER `w` AS `rank` from `test`.`t1` window `w` AS (PARTITION BY `test`.`t1`.`sex` ORDER BY `test`.`t1`.`id` ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) order by `summ` +CREATE TABLE t(d decimal(10,2), date DATE); +INSERT INTO t values (10.4, '2002-06-09'), +(20.5, '2002-06-09'), +(10.4, '2002-06-10'), +(3, '2002-06-09'), +(40.2, '2015-08-01'), +(40.2, '2002-06-09'), +(5, '2015-08-01'); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +EXPLAIN FORMAT=JSON SELECT * FROM (SELECT RANK() OVER (ORDER BY d) AS `rank`, d, date FROM t) alias ORDER BY `rank`, d, date; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "10.29" + }, + "ordering_operation": { + "using_filesort": true, + "cost_info": { + "sort_cost": "7.00" + }, + "table": { + "table_name": "alias", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "2.59", + "eval_cost": "0.70", + "prefix_cost": "3.29", + "data_read_per_join": "168" + }, + "used_columns": [ + "rank", + "d", + "date" + ], + "materialized_from_subquery": { + "using_temporary_table": true, + "dependent": false, + "cacheable": true, + "query_block": { + "select_id": 2, + "cost_info": { + "query_cost": "7.95" + }, + "windowing": { + "windows": [ + { + "name": "", + "using_filesort": true, + "filesort_key": [ + "`d`" + ], + "functions": [ + "rank" + ] + } + ], + "cost_info": { + "sort_cost": "7.00" + }, + "table": { + "table_name": "t", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.70", + "prefix_cost": "0.95", + "data_read_per_join": "112" + }, + "used_columns": [ + "d", + "date" + ] + } + } + } + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `alias`.`rank` AS `rank`,`alias`.`d` AS `d`,`alias`.`date` AS `date` from (/* select#2 */ select rank() OVER (ORDER BY `test`.`t`.`d` ) AS `rank`,`test`.`t`.`d` AS `d`,`test`.`t`.`date` AS `date` from `test`.`t`) `alias` order by `alias`.`rank`,`alias`.`d`,`alias`.`date` +EXPLAIN FORMAT=JSON SELECT * FROM (SELECT RANK() OVER (ORDER BY date) AS `rank`, date, d FROM t) alias ORDER BY `rank`, d DESC; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "10.29" + }, + "ordering_operation": { + "using_filesort": true, + "cost_info": { + "sort_cost": "7.00" + }, + "table": { + "table_name": "alias", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "2.59", + "eval_cost": "0.70", + "prefix_cost": "3.29", + "data_read_per_join": "168" + }, + "used_columns": [ + "rank", + "date", + "d" + ], + "materialized_from_subquery": { + "using_temporary_table": true, + "dependent": false, + "cacheable": true, + "query_block": { + "select_id": 2, + "cost_info": { + "query_cost": "7.95" + }, + "windowing": { + "windows": [ + { + "name": "", + "using_filesort": true, + "filesort_key": [ + "`date`" + ], + "functions": [ + "rank" + ] + } + ], + "cost_info": { + "sort_cost": "7.00" + }, + "table": { + "table_name": "t", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.70", + "prefix_cost": "0.95", + "data_read_per_join": "112" + }, + "used_columns": [ + "d", + "date" + ] + } + } + } + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `alias`.`rank` AS `rank`,`alias`.`date` AS `date`,`alias`.`d` AS `d` from (/* select#2 */ select rank() OVER (ORDER BY `test`.`t`.`date` ) AS `rank`,`test`.`t`.`date` AS `date`,`test`.`t`.`d` AS `d` from `test`.`t`) `alias` order by `alias`.`rank`,`alias`.`d` desc +DROP TABLE t; +Check that SUM stays that same when it sees NULL values +CREATE TABLE t(i INT, j INT); +INSERT INTO t VALUES (1,NULL), +(1,NULL), +(1,1), +(1,NULL), +(1,2), +(2,1), +(2,2), +(2,NULL), +(2,NULL); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +EXPLAIN FORMAT=JSON SELECT i, j, SUM(j) OVER (PARTITION BY i ORDER BY j ROWS UNBOUNDED PRECEDING) FROM t; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "10.15" + }, + "windowing": { + "windows": [ + { + "name": "", + "using_filesort": true, + "filesort_key": [ + "`i`", + "`j`" + ], + "functions": [ + "sum" + ] + } + ], + "cost_info": { + "sort_cost": "9.00" + }, + "table": { + "table_name": "t", + "access_type": "ALL", + "rows_examined_per_scan": 9, + "rows_produced_per_join": 9, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.90", + "prefix_cost": "1.15", + "data_read_per_join": "144" + }, + "used_columns": [ + "i", + "j" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`i` AS `i`,`test`.`t`.`j` AS `j`,sum(`test`.`t`.`j`) OVER (PARTITION BY `test`.`t`.`i` ORDER BY `test`.`t`.`j` ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) AS `SUM(j) OVER (PARTITION BY i ORDER BY j ROWS UNBOUNDED PRECEDING)` from `test`.`t` +EXPLAIN FORMAT=JSON SELECT SUM(id), SUM(SUM(id)) OVER (ORDER BY sex ROWS UNBOUNDED PRECEDING) FROM t1,t2 WHERE t1.id=t2.user_id GROUP BY sex; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "13.10" + }, + "windowing": { + "windows": [ + { + "name": "", + "using_filesort": true, + "filesort_key": [ + "`sex`" + ], + "functions": [ + "sum" + ] + } + ], + "cost_info": { + "sort_cost": "7.00" + }, + "grouping_operation": { + "using_temporary_table": true, + "using_filesort": false, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.70", + "prefix_cost": "0.95", + "data_read_per_join": "112" + }, + "used_columns": [ + "id", + "sex" + ] + } + }, + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "14.29", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.70", + "prefix_cost": "6.10", + "data_read_per_join": "112" + }, + "used_columns": [ + "user_id" + ], + "attached_condition": "(`test`.`t2`.`user_id` = `test`.`t1`.`id`)" + } + } + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select sum(`test`.`t1`.`id`) AS `SUM(id)`,sum(sum(`test`.`t1`.`id`)) OVER (ORDER BY `test`.`t1`.`sex` ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) AS `SUM(SUM(id)) OVER (ORDER BY sex ROWS UNBOUNDED PRECEDING)` from `test`.`t1` join `test`.`t2` where (`test`.`t2`.`user_id` = `test`.`t1`.`id`) group by `test`.`t1`.`sex` +EXPLAIN FORMAT=JSON SELECT RANK() OVER w FROM t1,t2 WHERE t1.id=t2.user_id WINDOW w AS (PARTITION BY id ORDER BY sex); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "13.10" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`id`", + "`sex`" + ], + "functions": [ + "rank" + ] + } + ], + "cost_info": { + "sort_cost": "7.00" + }, + "buffer_result": { + "using_temporary_table": true, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.70", + "prefix_cost": "0.95", + "data_read_per_join": "112" + }, + "used_columns": [ + "id", + "sex" + ] + } + }, + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "14.29", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.70", + "prefix_cost": "6.10", + "data_read_per_join": "112" + }, + "used_columns": [ + "user_id" + ], + "attached_condition": "(`test`.`t2`.`user_id` = `test`.`t1`.`id`)" + } + } + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select rank() OVER `w` AS `RANK() OVER w` from `test`.`t1` join `test`.`t2` where (`test`.`t2`.`user_id` = `test`.`t1`.`id`) window `w` AS (PARTITION BY `test`.`t1`.`id` ORDER BY `test`.`t1`.`sex` ) +EXPLAIN FORMAT=JSON SELECT RANK() OVER w FROM (SELECT * FROM t1,t2 WHERE t1.id=t2.user_id) t WINDOW w AS (PARTITION BY id ORDER BY sex); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "13.10" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`id`", + "`sex`" + ], + "functions": [ + "rank" + ] + } + ], + "cost_info": { + "sort_cost": "7.00" + }, + "buffer_result": { + "using_temporary_table": true, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.70", + "prefix_cost": "0.95", + "data_read_per_join": "112" + }, + "used_columns": [ + "id", + "sex" + ] + } + }, + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "14.29", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.70", + "prefix_cost": "6.10", + "data_read_per_join": "112" + }, + "used_columns": [ + "user_id" + ], + "attached_condition": "(`test`.`t2`.`user_id` = `test`.`t1`.`id`)" + } + } + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select rank() OVER `w` AS `RANK() OVER w` from `test`.`t1` join `test`.`t2` where (`test`.`t2`.`user_id` = `test`.`t1`.`id`) window `w` AS (PARTITION BY `test`.`t1`.`id` ORDER BY `test`.`t1`.`sex` ) +Check that aggregate window functions that reference columns not in the SELECT list work +EXPLAIN FORMAT=JSON SELECT SUM(id) OVER (PARTITION BY sex ORDER BY id ROWS UNBOUNDED PRECEDING) summ, sex FROM t1; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "7.95" + }, + "windowing": { + "windows": [ + { + "name": "", + "using_filesort": true, + "filesort_key": [ + "`sex`", + "`id`" + ], + "functions": [ + "sum" + ] + } + ], + "cost_info": { + "sort_cost": "7.00" + }, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.70", + "prefix_cost": "0.95", + "data_read_per_join": "112" + }, + "used_columns": [ + "id", + "sex" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select sum(`test`.`t1`.`id`) OVER (PARTITION BY `test`.`t1`.`sex` ORDER BY `test`.`t1`.`id` ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) AS `summ`,`test`.`t1`.`sex` AS `sex` from `test`.`t1` +---------------------------------------------------------------------- +- Some ROW_NUMBER tests +---------------------------------------------------------------------- +EXPLAIN FORMAT=JSON SELECT user_id, ROW_NUMBER() OVER (PARTITION BY user_id) FROM t2; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "7.95" + }, + "windowing": { + "windows": [ + { + "name": "", + "using_filesort": true, + "filesort_key": [ + "`user_id`" + ], + "functions": [ + "row_number" + ] + } + ], + "cost_info": { + "sort_cost": "7.00" + }, + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.70", + "prefix_cost": "0.95", + "data_read_per_join": "112" + }, + "used_columns": [ + "user_id" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`user_id` AS `user_id`,row_number() OVER (PARTITION BY `test`.`t2`.`user_id` ) AS `ROW_NUMBER() OVER (PARTITION BY user_id)` from `test`.`t2` +EXPLAIN FORMAT=JSON SELECT * FROM t1,t2 WHERE t1.id=t2.user_id; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "6.10" + }, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.70", + "prefix_cost": "0.95", + "data_read_per_join": "168" + }, + "used_columns": [ + "id", + "sex", + "user_id", + "date" + ], + "query_block": { + "cost_info": { + "query_cost": "6.10" + }, + "nested_loop": [ + { + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.70", + "prefix_cost": "0.95", + "data_read_per_join": "112" + }, + "used_columns": [ + "id", + "sex" + ] + } + }, + { + "table": { + "select_id": 2, + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "14.29", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.70", + "prefix_cost": "6.10", + "data_read_per_join": "112" + }, + "used_columns": [ + "user_id", + "date" + ], + "attached_condition": "(`test`.`t2`.`user_id` = `test`.`t1`.`id`)" + } + } + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,`test`.`t1`.`sex` AS `sex`,`test`.`t2`.`user_id` AS `user_id`,`test`.`t2`.`date` AS `date` from `test`.`t1` join `test`.`t2` where (`test`.`t2`.`user_id` = `test`.`t1`.`id`) +EXPLAIN FORMAT=JSON SELECT sex, id, date, ROW_NUMBER() OVER w AS row_no, RANK() OVER w AS `rank` FROM t1,t2 +WHERE t1.id=t2.user_id +WINDOW w AS (PARTITION BY id ORDER BY sex); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "13.10" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`id`", + "`sex`" + ], + "functions": [ + "row_number", + "rank" + ] + } + ], + "cost_info": { + "sort_cost": "7.00" + }, + "buffer_result": { + "using_temporary_table": true, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.70", + "prefix_cost": "0.95", + "data_read_per_join": "112" + }, + "used_columns": [ + "id", + "sex" + ] + } + }, + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "14.29", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.70", + "prefix_cost": "6.10", + "data_read_per_join": "112" + }, + "used_columns": [ + "user_id", + "date" + ], + "attached_condition": "(`test`.`t2`.`user_id` = `test`.`t1`.`id`)" + } + } + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`sex` AS `sex`,`test`.`t1`.`id` AS `id`,`test`.`t2`.`date` AS `date`,row_number() OVER `w` AS `row_no`,rank() OVER `w` AS `rank` from `test`.`t1` join `test`.`t2` where (`test`.`t2`.`user_id` = `test`.`t1`.`id`) window `w` AS (PARTITION BY `test`.`t1`.`id` ORDER BY `test`.`t1`.`sex` ) +EXPLAIN FORMAT=JSON SELECT sex, id, date, ROW_NUMBER() OVER w AS row_no, RANK() OVER w AS `rank` FROM t1,t2 +WHERE t1.id=t2.user_id +WINDOW w AS (PARTITION BY date ORDER BY id); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "13.10" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`date`", + "`id`" + ], + "functions": [ + "row_number", + "rank" + ] + } + ], + "cost_info": { + "sort_cost": "7.00" + }, + "buffer_result": { + "using_temporary_table": true, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.70", + "prefix_cost": "0.95", + "data_read_per_join": "112" + }, + "used_columns": [ + "id", + "sex" + ] + } + }, + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "14.29", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.70", + "prefix_cost": "6.10", + "data_read_per_join": "112" + }, + "used_columns": [ + "user_id", + "date" + ], + "attached_condition": "(`test`.`t2`.`user_id` = `test`.`t1`.`id`)" + } + } + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`sex` AS `sex`,`test`.`t1`.`id` AS `id`,`test`.`t2`.`date` AS `date`,row_number() OVER `w` AS `row_no`,rank() OVER `w` AS `rank` from `test`.`t1` join `test`.`t2` where (`test`.`t2`.`user_id` = `test`.`t1`.`id`) window `w` AS (PARTITION BY `test`.`t2`.`date` ORDER BY `test`.`t1`.`id` ) +---------------------------------------------------------------------- +- Window function in subquery +---------------------------------------------------------------------- +EXPLAIN FORMAT=JSON SELECT date,id, RANK() OVER w AS `rank` FROM t1,t2 WINDOW w AS (PARTITION BY date ORDER BY id); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "55.10" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`date`", + "`id`" + ], + "functions": [ + "rank" + ] + } + ], + "cost_info": { + "sort_cost": "49.00" + }, + "buffer_result": { + "using_temporary_table": true, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.70", + "prefix_cost": "0.95", + "data_read_per_join": "112" + }, + "used_columns": [ + "id" + ] + } + }, + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 49, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "4.90", + "prefix_cost": "6.10", + "data_read_per_join": "784" + }, + "used_columns": [ + "date" + ] + } + } + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`date` AS `date`,`test`.`t1`.`id` AS `id`,rank() OVER `w` AS `rank` from `test`.`t1` join `test`.`t2` window `w` AS (PARTITION BY `test`.`t2`.`date` ORDER BY `test`.`t1`.`id` ) +EXPLAIN FORMAT=JSON SELECT * from (SELECT date,id, RANK() OVER w AS `rank` FROM t1,t2 WINDOW w AS (PARTITION BY date ORDER BY id)) t; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "8.01" + }, + "table": { + "table_name": "t", + "access_type": "ALL", + "rows_examined_per_scan": 49, + "rows_produced_per_join": 49, + "filtered": "100.00", + "cost_info": { + "read_cost": "3.11", + "eval_cost": "4.90", + "prefix_cost": "8.01", + "data_read_per_join": "1K" + }, + "used_columns": [ + "date", + "id", + "rank" + ], + "materialized_from_subquery": { + "using_temporary_table": true, + "dependent": false, + "cacheable": true, + "query_block": { + "select_id": 2, + "cost_info": { + "query_cost": "55.10" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`date`", + "`id`" + ], + "functions": [ + "rank" + ] + } + ], + "cost_info": { + "sort_cost": "49.00" + }, + "buffer_result": { + "using_temporary_table": true, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.70", + "prefix_cost": "0.95", + "data_read_per_join": "112" + }, + "used_columns": [ + "id" + ] + } + }, + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 49, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "4.90", + "prefix_cost": "6.10", + "data_read_per_join": "784" + }, + "used_columns": [ + "date" + ] + } + } + ] + } + } + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `t`.`date` AS `date`,`t`.`id` AS `id`,`t`.`rank` AS `rank` from (/* select#2 */ select `test`.`t2`.`date` AS `date`,`test`.`t1`.`id` AS `id`,rank() OVER `w` AS `rank` from `test`.`t1` join `test`.`t2` window `w` AS (PARTITION BY `test`.`t2`.`date` ORDER BY `test`.`t1`.`id` ) ) `t` +---------------------------------------------------------------------- +- Window function in parent and subquery +---------------------------------------------------------------------- +EXPLAIN FORMAT=JSON SELECT t.*, SUM(t.`rank`) OVER (ROWS UNBOUNDED PRECEDING) FROM +(SELECT sex, id, date, ROW_NUMBER() OVER w AS row_no, RANK() OVER w AS `rank` FROM t1,t2 +WHERE t1.id=t2.user_id +WINDOW w AS (PARTITION BY date ORDER BY id) +) AS t; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "3.29" + }, + "windowing": { + "windows": [ + { + "name": "", + "functions": [ + "sum" + ] + } + ], + "table": { + "table_name": "t", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "2.59", + "eval_cost": "0.70", + "prefix_cost": "3.29", + "data_read_per_join": "280" + }, + "used_columns": [ + "sex", + "id", + "date", + "row_no", + "rank" + ], + "materialized_from_subquery": { + "using_temporary_table": true, + "dependent": false, + "cacheable": true, + "query_block": { + "select_id": 2, + "cost_info": { + "query_cost": "13.10" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`date`", + "`id`" + ], + "functions": [ + "row_number", + "rank" + ] + } + ], + "cost_info": { + "sort_cost": "7.00" + }, + "buffer_result": { + "using_temporary_table": true, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.70", + "prefix_cost": "0.95", + "data_read_per_join": "112" + }, + "used_columns": [ + "id", + "sex" + ] + } + }, + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "14.29", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.70", + "prefix_cost": "6.10", + "data_read_per_join": "112" + }, + "used_columns": [ + "user_id", + "date" + ], + "attached_condition": "(`test`.`t2`.`user_id` = `test`.`t1`.`id`)" + } + } + ] + } + } + } + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `t`.`sex` AS `sex`,`t`.`id` AS `id`,`t`.`date` AS `date`,`t`.`row_no` AS `row_no`,`t`.`rank` AS `rank`,sum(`t`.`rank`) OVER (ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) AS `SUM(t.``rank``) OVER (ROWS UNBOUNDED PRECEDING)` from (/* select#2 */ select `test`.`t1`.`sex` AS `sex`,`test`.`t1`.`id` AS `id`,`test`.`t2`.`date` AS `date`,row_number() OVER `w` AS `row_no`,rank() OVER `w` AS `rank` from `test`.`t1` join `test`.`t2` where (`test`.`t2`.`user_id` = `test`.`t1`.`id`) window `w` AS (PARTITION BY `test`.`t2`.`date` ORDER BY `test`.`t1`.`id` ) ) `t` +---------------------------------------------------------------------- +- Multiple windows +---------------------------------------------------------------------- +EXPLAIN FORMAT=JSON SELECT t1.*, RANK() OVER (ORDER BY sex), SUM(id) OVER (ORDER BY sex,id ROWS UNBOUNDED PRECEDING) FROM t1; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "14.95" + }, + "windowing": { + "windows": [ + { + "name": "", + "definition_position": 1, + "using_temporary_table": true, + "using_filesort": true, + "filesort_key": [ + "`sex`" + ], + "functions": [ + "rank" + ] + }, + { + "name": "", + "definition_position": 2, + "last_executed_window": true, + "using_filesort": true, + "filesort_key": [ + "`sex`", + "`id`" + ], + "functions": [ + "sum" + ] + } + ], + "cost_info": { + "sort_cost": "14.00" + }, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.70", + "prefix_cost": "0.95", + "data_read_per_join": "112" + }, + "used_columns": [ + "id", + "sex" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,`test`.`t1`.`sex` AS `sex`,rank() OVER (ORDER BY `test`.`t1`.`sex` ) AS `RANK() OVER (ORDER BY sex)`,sum(`test`.`t1`.`id`) OVER (ORDER BY `test`.`t1`.`sex`,`test`.`t1`.`id` ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) AS `SUM(id) OVER (ORDER BY sex,id ROWS UNBOUNDED PRECEDING)` from `test`.`t1` +EXPLAIN FORMAT=JSON SELECT * from (SELECT t1.*, SUM(id) OVER (ROWS UNBOUNDED PRECEDING), RANK() OVER (ORDER BY sex) FROM t1) alias ORDER BY id; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "10.29" + }, + "ordering_operation": { + "using_filesort": true, + "cost_info": { + "sort_cost": "7.00" + }, + "table": { + "table_name": "alias", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "2.59", + "eval_cost": "0.70", + "prefix_cost": "3.29", + "data_read_per_join": "280" + }, + "used_columns": [ + "id", + "sex", + "SUM(id) OVER (ROWS UNBOUNDED PRECEDING)", + "RANK() OVER (ORDER BY sex)" + ], + "materialized_from_subquery": { + "using_temporary_table": true, + "dependent": false, + "cacheable": true, + "query_block": { + "select_id": 2, + "cost_info": { + "query_cost": "7.95" + }, + "windowing": { + "windows": [ + { + "name": "", + "definition_position": 1, + "using_temporary_table": true, + "functions": [ + "sum" + ] + }, + { + "name": "", + "definition_position": 2, + "last_executed_window": true, + "using_filesort": true, + "filesort_key": [ + "`sex`" + ], + "functions": [ + "rank" + ] + } + ], + "cost_info": { + "sort_cost": "7.00" + }, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.70", + "prefix_cost": "0.95", + "data_read_per_join": "112" + }, + "used_columns": [ + "id", + "sex" + ] + } + } + } + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `alias`.`id` AS `id`,`alias`.`sex` AS `sex`,`alias`.`SUM(id) OVER (ROWS UNBOUNDED PRECEDING)` AS `SUM(id) OVER (ROWS UNBOUNDED PRECEDING)`,`alias`.`RANK() OVER (ORDER BY sex)` AS `RANK() OVER (ORDER BY sex)` from (/* select#2 */ select `test`.`t1`.`id` AS `id`,`test`.`t1`.`sex` AS `sex`,sum(`test`.`t1`.`id`) OVER (ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) AS `SUM(id) OVER (ROWS UNBOUNDED PRECEDING)`,rank() OVER (ORDER BY `test`.`t1`.`sex` ) AS `RANK() OVER (ORDER BY sex)` from `test`.`t1`) `alias` order by `alias`.`id` +EXPLAIN FORMAT=JSON SELECT t1.*, SUM(id) OVER (ORDER BY id ROWS UNBOUNDED PRECEDING), +RANK() OVER (ORDER BY sex,id), +ROW_NUMBER() OVER (ORDER BY sex,id) +FROM t1; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "14.95" + }, + "windowing": { + "windows": [ + { + "name": "", + "definition_position": 1, + "using_temporary_table": true, + "using_filesort": true, + "filesort_key": [ + "`id`" + ], + "functions": [ + "sum" + ] + }, + { + "name": "", + "definition_position": 2, + "using_temporary_table": true, + "using_filesort": true, + "filesort_key": [ + "`sex`", + "`id`" + ], + "functions": [ + "rank" + ] + }, + { + "name": "", + "definition_position": 3, + "last_executed_window": true, + "functions": [ + "row_number" + ] + } + ], + "cost_info": { + "sort_cost": "14.00" + }, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.70", + "prefix_cost": "0.95", + "data_read_per_join": "112" + }, + "used_columns": [ + "id", + "sex" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,`test`.`t1`.`sex` AS `sex`,sum(`test`.`t1`.`id`) OVER (ORDER BY `test`.`t1`.`id` ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) AS `SUM(id) OVER (ORDER BY id ROWS UNBOUNDED PRECEDING)`,rank() OVER (ORDER BY `test`.`t1`.`sex`,`test`.`t1`.`id` ) AS `RANK() OVER (ORDER BY sex,id)`,row_number() OVER (ORDER BY `test`.`t1`.`sex`,`test`.`t1`.`id` ) AS `ROW_NUMBER() OVER (ORDER BY sex,id)` from `test`.`t1` +a little more windows + subquery +EXPLAIN FORMAT=JSON SELECT t.*, SUM(id + r00 + r01) OVER (ORDER BY id ROWS UNBOUNDED PRECEDING) AS s FROM ( +SELECT t1.*, +RANK() OVER (ORDER BY sex) AS r00, +RANK() OVER (ORDER BY sex DESC) AS r01, +RANK() OVER (ORDER BY sex, id DESC) AS r02, +RANK() OVER (PARTITION BY id ORDER BY sex) AS r03, +RANK() OVER (ORDER BY sex) AS r04, +RANK() OVER (ORDER BY sex) AS r05, +RANK() OVER (ORDER BY sex) AS r06, +RANK() OVER (ORDER BY sex) AS r07, +RANK() OVER (ORDER BY sex) AS r08, +RANK() OVER (ORDER BY sex) AS r09, +RANK() OVER (ORDER BY sex) AS r10, +RANK() OVER (ORDER BY sex) AS r11, +RANK() OVER (ORDER BY sex) AS r12, +RANK() OVER (ORDER BY sex) AS r13, +RANK() OVER (ORDER BY sex) AS r14 +FROM t1) t; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "10.29" + }, + "windowing": { + "windows": [ + { + "name": "", + "using_filesort": true, + "filesort_key": [ + "`id`" + ], + "functions": [ + "sum" + ] + } + ], + "cost_info": { + "sort_cost": "7.00" + }, + "table": { + "table_name": "t", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "2.59", + "eval_cost": "0.70", + "prefix_cost": "3.29", + "data_read_per_join": "952" + }, + "used_columns": [ + "id", + "sex", + "r00", + "r01", + "r02", + "r03", + "r04", + "r05", + "r06", + "r07", + "r08", + "r09", + "r10", + "r11", + "r12", + "r13", + "r14" + ], + "materialized_from_subquery": { + "using_temporary_table": true, + "dependent": false, + "cacheable": true, + "query_block": { + "select_id": 2, + "cost_info": { + "query_cost": "28.95" + }, + "windowing": { + "windows": [ + { + "name": "", + "definition_position": 1, + "using_temporary_table": true, + "using_filesort": true, + "filesort_key": [ + "`sex`" + ], + "functions": [ + "rank" + ] + }, + { + "name": "", + "definition_position": 5, + "using_temporary_table": true, + "functions": [ + "rank" + ] + }, + { + "name": "", + "definition_position": 6, + "using_temporary_table": true, + "functions": [ + "rank" + ] + }, + { + "name": "", + "definition_position": 7, + "using_temporary_table": true, + "functions": [ + "rank" + ] + }, + { + "name": "", + "definition_position": 8, + "using_temporary_table": true, + "functions": [ + "rank" + ] + }, + { + "name": "", + "definition_position": 9, + "using_temporary_table": true, + "functions": [ + "rank" + ] + }, + { + "name": "", + "definition_position": 10, + "using_temporary_table": true, + "functions": [ + "rank" + ] + }, + { + "name": "", + "definition_position": 11, + "using_temporary_table": true, + "functions": [ + "rank" + ] + }, + { + "name": "", + "definition_position": 12, + "using_temporary_table": true, + "functions": [ + "rank" + ] + }, + { + "name": "", + "definition_position": 13, + "using_temporary_table": true, + "functions": [ + "rank" + ] + }, + { + "name": "", + "definition_position": 14, + "using_temporary_table": true, + "functions": [ + "rank" + ] + }, + { + "name": "", + "definition_position": 15, + "using_temporary_table": true, + "functions": [ + "rank" + ] + }, + { + "name": "", + "definition_position": 4, + "using_temporary_table": true, + "using_filesort": true, + "filesort_key": [ + "`id`", + "`sex`" + ], + "functions": [ + "rank" + ] + }, + { + "name": "", + "definition_position": 2, + "using_temporary_table": true, + "using_filesort": true, + "filesort_key": [ + "`sex` desc" + ], + "functions": [ + "rank" + ] + }, + { + "name": "", + "definition_position": 3, + "last_executed_window": true, + "using_filesort": true, + "filesort_key": [ + "`sex`", + "`id` desc" + ], + "functions": [ + "rank" + ] + } + ], + "cost_info": { + "sort_cost": "28.00" + }, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.70", + "prefix_cost": "0.95", + "data_read_per_join": "112" + }, + "used_columns": [ + "id", + "sex" + ] + } + } + } + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `t`.`id` AS `id`,`t`.`sex` AS `sex`,`t`.`r00` AS `r00`,`t`.`r01` AS `r01`,`t`.`r02` AS `r02`,`t`.`r03` AS `r03`,`t`.`r04` AS `r04`,`t`.`r05` AS `r05`,`t`.`r06` AS `r06`,`t`.`r07` AS `r07`,`t`.`r08` AS `r08`,`t`.`r09` AS `r09`,`t`.`r10` AS `r10`,`t`.`r11` AS `r11`,`t`.`r12` AS `r12`,`t`.`r13` AS `r13`,`t`.`r14` AS `r14`,sum(((`t`.`id` + `t`.`r00`) + `t`.`r01`)) OVER (ORDER BY `t`.`id` ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) AS `s` from (/* select#2 */ select `test`.`t1`.`id` AS `id`,`test`.`t1`.`sex` AS `sex`,rank() OVER (ORDER BY `test`.`t1`.`sex` ) AS `r00`,rank() OVER (ORDER BY `test`.`t1`.`sex` desc ) AS `r01`,rank() OVER (ORDER BY `test`.`t1`.`sex`,`test`.`t1`.`id` desc ) AS `r02`,rank() OVER (PARTITION BY `test`.`t1`.`id` ORDER BY `test`.`t1`.`sex` ) AS `r03`,rank() OVER (ORDER BY `test`.`t1`.`sex` ) AS `r04`,rank() OVER (ORDER BY `test`.`t1`.`sex` ) AS `r05`,rank() OVER (ORDER BY `test`.`t1`.`sex` ) AS `r06`,rank() OVER (ORDER BY `test`.`t1`.`sex` ) AS `r07`,rank() OVER (ORDER BY `test`.`t1`.`sex` ) AS `r08`,rank() OVER (ORDER BY `test`.`t1`.`sex` ) AS `r09`,rank() OVER (ORDER BY `test`.`t1`.`sex` ) AS `r10`,rank() OVER (ORDER BY `test`.`t1`.`sex` ) AS `r11`,rank() OVER (ORDER BY `test`.`t1`.`sex` ) AS `r12`,rank() OVER (ORDER BY `test`.`t1`.`sex` ) AS `r13`,rank() OVER (ORDER BY `test`.`t1`.`sex` ) AS `r14` from `test`.`t1`) `t` +With LIMIT +EXPLAIN FORMAT=JSON SELECT t.*, SUM(id + r00 + r01) OVER (ORDER BY id ROWS UNBOUNDED PRECEDING) AS s FROM ( +SELECT t1.*, +RANK() OVER (ORDER BY sex) AS r00, +RANK() OVER (ORDER BY sex DESC) AS r01, +RANK() OVER (ORDER BY sex, id DESC) AS r02, +RANK() OVER (PARTITION BY id ORDER BY sex) AS r03, +RANK() OVER (ORDER BY sex) AS r04, +RANK() OVER (ORDER BY sex) AS r05, +RANK() OVER (ORDER BY sex) AS r06, +RANK() OVER (ORDER BY sex) AS r07, +RANK() OVER (ORDER BY sex) AS r08, +RANK() OVER (ORDER BY sex) AS r09, +RANK() OVER (ORDER BY sex) AS r10, +RANK() OVER (ORDER BY sex) AS r11, +RANK() OVER (ORDER BY sex) AS r12, +RANK() OVER (ORDER BY sex) AS r13, +RANK() OVER (ORDER BY sex) AS r14 +FROM t1 LIMIT 4) t; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "6.95" + }, + "windowing": { + "windows": [ + { + "name": "", + "using_filesort": true, + "filesort_key": [ + "`id`" + ], + "functions": [ + "sum" + ] + } + ], + "cost_info": { + "sort_cost": "4.00" + }, + "table": { + "table_name": "t", + "access_type": "ALL", + "rows_examined_per_scan": 4, + "rows_produced_per_join": 4, + "filtered": "100.00", + "cost_info": { + "read_cost": "2.55", + "eval_cost": "0.40", + "prefix_cost": "2.95", + "data_read_per_join": "544" + }, + "used_columns": [ + "id", + "sex", + "r00", + "r01", + "r02", + "r03", + "r04", + "r05", + "r06", + "r07", + "r08", + "r09", + "r10", + "r11", + "r12", + "r13", + "r14" + ], + "materialized_from_subquery": { + "using_temporary_table": true, + "dependent": false, + "cacheable": true, + "query_block": { + "select_id": 2, + "cost_info": { + "query_cost": "28.95" + }, + "windowing": { + "windows": [ + { + "name": "", + "definition_position": 1, + "using_temporary_table": true, + "using_filesort": true, + "filesort_key": [ + "`sex`" + ], + "functions": [ + "rank" + ] + }, + { + "name": "", + "definition_position": 5, + "using_temporary_table": true, + "functions": [ + "rank" + ] + }, + { + "name": "", + "definition_position": 6, + "using_temporary_table": true, + "functions": [ + "rank" + ] + }, + { + "name": "", + "definition_position": 7, + "using_temporary_table": true, + "functions": [ + "rank" + ] + }, + { + "name": "", + "definition_position": 8, + "using_temporary_table": true, + "functions": [ + "rank" + ] + }, + { + "name": "", + "definition_position": 9, + "using_temporary_table": true, + "functions": [ + "rank" + ] + }, + { + "name": "", + "definition_position": 10, + "using_temporary_table": true, + "functions": [ + "rank" + ] + }, + { + "name": "", + "definition_position": 11, + "using_temporary_table": true, + "functions": [ + "rank" + ] + }, + { + "name": "", + "definition_position": 12, + "using_temporary_table": true, + "functions": [ + "rank" + ] + }, + { + "name": "", + "definition_position": 13, + "using_temporary_table": true, + "functions": [ + "rank" + ] + }, + { + "name": "", + "definition_position": 14, + "using_temporary_table": true, + "functions": [ + "rank" + ] + }, + { + "name": "", + "definition_position": 15, + "using_temporary_table": true, + "functions": [ + "rank" + ] + }, + { + "name": "", + "definition_position": 4, + "using_temporary_table": true, + "using_filesort": true, + "filesort_key": [ + "`id`", + "`sex`" + ], + "functions": [ + "rank" + ] + }, + { + "name": "", + "definition_position": 2, + "using_temporary_table": true, + "using_filesort": true, + "filesort_key": [ + "`sex` desc" + ], + "functions": [ + "rank" + ] + }, + { + "name": "", + "definition_position": 3, + "last_executed_window": true, + "using_filesort": true, + "filesort_key": [ + "`sex`", + "`id` desc" + ], + "functions": [ + "rank" + ] + } + ], + "cost_info": { + "sort_cost": "28.00" + }, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.70", + "prefix_cost": "0.95", + "data_read_per_join": "112" + }, + "used_columns": [ + "id", + "sex" + ] + } + } + } + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `t`.`id` AS `id`,`t`.`sex` AS `sex`,`t`.`r00` AS `r00`,`t`.`r01` AS `r01`,`t`.`r02` AS `r02`,`t`.`r03` AS `r03`,`t`.`r04` AS `r04`,`t`.`r05` AS `r05`,`t`.`r06` AS `r06`,`t`.`r07` AS `r07`,`t`.`r08` AS `r08`,`t`.`r09` AS `r09`,`t`.`r10` AS `r10`,`t`.`r11` AS `r11`,`t`.`r12` AS `r12`,`t`.`r13` AS `r13`,`t`.`r14` AS `r14`,sum(((`t`.`id` + `t`.`r00`) + `t`.`r01`)) OVER (ORDER BY `t`.`id` ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) AS `s` from (/* select#2 */ select `test`.`t1`.`id` AS `id`,`test`.`t1`.`sex` AS `sex`,rank() OVER (ORDER BY `test`.`t1`.`sex` ) AS `r00`,rank() OVER (ORDER BY `test`.`t1`.`sex` desc ) AS `r01`,rank() OVER (ORDER BY `test`.`t1`.`sex`,`test`.`t1`.`id` desc ) AS `r02`,rank() OVER (PARTITION BY `test`.`t1`.`id` ORDER BY `test`.`t1`.`sex` ) AS `r03`,rank() OVER (ORDER BY `test`.`t1`.`sex` ) AS `r04`,rank() OVER (ORDER BY `test`.`t1`.`sex` ) AS `r05`,rank() OVER (ORDER BY `test`.`t1`.`sex` ) AS `r06`,rank() OVER (ORDER BY `test`.`t1`.`sex` ) AS `r07`,rank() OVER (ORDER BY `test`.`t1`.`sex` ) AS `r08`,rank() OVER (ORDER BY `test`.`t1`.`sex` ) AS `r09`,rank() OVER (ORDER BY `test`.`t1`.`sex` ) AS `r10`,rank() OVER (ORDER BY `test`.`t1`.`sex` ) AS `r11`,rank() OVER (ORDER BY `test`.`t1`.`sex` ) AS `r12`,rank() OVER (ORDER BY `test`.`t1`.`sex` ) AS `r13`,rank() OVER (ORDER BY `test`.`t1`.`sex` ) AS `r14` from `test`.`t1` limit 4) `t` +---------------------------------------------------------------------- +- SUM, AVG, COUNT with frames +---------------------------------------------------------------------- +EXPLAIN FORMAT=JSON SELECT SUM(id) OVER w * 2, AVG(id) OVER w, COUNT(id) OVER w FROM t1 +WINDOW w AS (PARTITION BY sex); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "7.95" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`sex`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "sum", + "avg", + "count" + ] + } + ], + "cost_info": { + "sort_cost": "7.00" + }, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.70", + "prefix_cost": "0.95", + "data_read_per_join": "112" + }, + "used_columns": [ + "id", + "sex" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select (sum(`test`.`t1`.`id`) OVER `w` * 2) AS `SUM(id) OVER w * 2`,avg(`test`.`t1`.`id`) OVER `w` AS `AVG(id) OVER w`,count(`test`.`t1`.`id`) OVER `w` AS `COUNT(id) OVER w` from `test`.`t1` window `w` AS (PARTITION BY `test`.`t1`.`sex` ) +EXPLAIN FORMAT=JSON SELECT * FROM ( +SELECT id, SUM(id) OVER w, COUNT(*) OVER w, sex FROM t1 +WINDOW w AS (PARTITION BY sex) +) alias ORDER BY id; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "10.29" + }, + "ordering_operation": { + "using_filesort": true, + "cost_info": { + "sort_cost": "7.00" + }, + "table": { + "table_name": "alias", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "2.59", + "eval_cost": "0.70", + "prefix_cost": "3.29", + "data_read_per_join": "280" + }, + "used_columns": [ + "id", + "SUM(id) OVER w", + "COUNT(*) OVER w", + "sex" + ], + "materialized_from_subquery": { + "using_temporary_table": true, + "dependent": false, + "cacheable": true, + "query_block": { + "select_id": 2, + "cost_info": { + "query_cost": "7.95" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`sex`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "sum", + "count" + ] + } + ], + "cost_info": { + "sort_cost": "7.00" + }, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.70", + "prefix_cost": "0.95", + "data_read_per_join": "112" + }, + "used_columns": [ + "id", + "sex" + ] + } + } + } + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `alias`.`id` AS `id`,`alias`.`SUM(id) OVER w` AS `SUM(id) OVER w`,`alias`.`COUNT(*) OVER w` AS `COUNT(*) OVER w`,`alias`.`sex` AS `sex` from (/* select#2 */ select `test`.`t1`.`id` AS `id`,sum(`test`.`t1`.`id`) OVER `w` AS `SUM(id) OVER w`,count(0) OVER `w` AS `COUNT(*) OVER w`,`test`.`t1`.`sex` AS `sex` from `test`.`t1` window `w` AS (PARTITION BY `test`.`t1`.`sex` ) ) `alias` order by `alias`.`id` +EXPLAIN FORMAT=JSON SELECT SUM(id) OVER w FROM t1 WINDOW w AS (PARTITION BY sex); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "7.95" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`sex`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "sum" + ] + } + ], + "cost_info": { + "sort_cost": "7.00" + }, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.70", + "prefix_cost": "0.95", + "data_read_per_join": "112" + }, + "used_columns": [ + "id", + "sex" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select sum(`test`.`t1`.`id`) OVER `w` AS `SUM(id) OVER w` from `test`.`t1` window `w` AS (PARTITION BY `test`.`t1`.`sex` ) +EXPLAIN FORMAT=JSON SELECT id, SUM(id) OVER w, sex FROM t1 +WINDOW w AS (PARTITION BY sex ORDER BY id +ROWS BETWEEN 2 PRECEDING AND 1 PRECEDING); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "7.95" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`sex`", + "`id`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "sum" + ] + } + ], + "cost_info": { + "sort_cost": "7.00" + }, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.70", + "prefix_cost": "0.95", + "data_read_per_join": "112" + }, + "used_columns": [ + "id", + "sex" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,sum(`test`.`t1`.`id`) OVER `w` AS `SUM(id) OVER w`,`test`.`t1`.`sex` AS `sex` from `test`.`t1` window `w` AS (PARTITION BY `test`.`t1`.`sex` ORDER BY `test`.`t1`.`id` ROWS BETWEEN 2 PRECEDING AND 1 PRECEDING) +try the same as a view +CREATE VIEW v AS +SELECT id, SUM(id) OVER w, sex FROM t1 +WINDOW w AS (PARTITION BY sex ORDER BY id +ROWS BETWEEN 2 PRECEDING AND 1 PRECEDING); +SHOW CREATE VIEW v; +View Create View character_set_client collation_connection +v CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v` AS select `t1`.`id` AS `id`,sum(`t1`.`id`) OVER `w` AS `SUM(id) OVER w`,`t1`.`sex` AS `sex` from `t1` window `w` AS (PARTITION BY `t1`.`sex` ORDER BY `t1`.`id` ROWS BETWEEN 2 PRECEDING AND 1 PRECEDING) utf8 utf8_general_ci +EXPLAIN FORMAT=JSON SELECT * FROM v; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "3.29" + }, + "table": { + "table_name": "v", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "2.59", + "eval_cost": "0.70", + "prefix_cost": "3.29", + "data_read_per_join": "224" + }, + "used_columns": [ + "id", + "SUM(id) OVER w", + "sex" + ], + "materialized_from_subquery": { + "using_temporary_table": true, + "dependent": false, + "cacheable": true, + "query_block": { + "select_id": 2, + "cost_info": { + "query_cost": "7.95" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`sex`", + "`id`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "sum" + ] + } + ], + "cost_info": { + "sort_cost": "7.00" + }, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.70", + "prefix_cost": "0.95", + "data_read_per_join": "112" + }, + "used_columns": [ + "id", + "sex" + ] + } + } + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`v`.`id` AS `id`,`test`.`v`.`SUM(id) OVER w` AS `SUM(id) OVER w`,`test`.`v`.`sex` AS `sex` from `test`.`v` +DROP VIEW v; +EXPLAIN FORMAT=JSON SELECT SUM(id) OVER w FROM t1 +WINDOW w AS (PARTITION BY sex ORDER BY id +ROWS BETWEEN 2 PRECEDING AND 1 PRECEDING); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "7.95" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`sex`", + "`id`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "sum" + ] + } + ], + "cost_info": { + "sort_cost": "7.00" + }, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.70", + "prefix_cost": "0.95", + "data_read_per_join": "112" + }, + "used_columns": [ + "id", + "sex" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select sum(`test`.`t1`.`id`) OVER `w` AS `SUM(id) OVER w` from `test`.`t1` window `w` AS (PARTITION BY `test`.`t1`.`sex` ORDER BY `test`.`t1`.`id` ROWS BETWEEN 2 PRECEDING AND 1 PRECEDING) +EXPLAIN FORMAT=JSON SELECT id, SUM(id) OVER w, sex FROM t1 +WINDOW w AS (PARTITION BY sex ORDER BY id +ROWS BETWEEN 1 FOLLOWING AND 2 FOLLOWING); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "7.95" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`sex`", + "`id`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "sum" + ] + } + ], + "cost_info": { + "sort_cost": "7.00" + }, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.70", + "prefix_cost": "0.95", + "data_read_per_join": "112" + }, + "used_columns": [ + "id", + "sex" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,sum(`test`.`t1`.`id`) OVER `w` AS `SUM(id) OVER w`,`test`.`t1`.`sex` AS `sex` from `test`.`t1` window `w` AS (PARTITION BY `test`.`t1`.`sex` ORDER BY `test`.`t1`.`id` ROWS BETWEEN 1 FOLLOWING AND 2 FOLLOWING) +EXPLAIN FORMAT=JSON SELECT SUM(id) OVER w, COUNT(*) OVER w FROM t1 +WINDOW w AS (PARTITION BY sex ORDER BY id +ROWS BETWEEN 1 FOLLOWING AND 2 FOLLOWING); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "7.95" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`sex`", + "`id`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "sum", + "count" + ] + } + ], + "cost_info": { + "sort_cost": "7.00" + }, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.70", + "prefix_cost": "0.95", + "data_read_per_join": "112" + }, + "used_columns": [ + "id", + "sex" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select sum(`test`.`t1`.`id`) OVER `w` AS `SUM(id) OVER w`,count(0) OVER `w` AS `COUNT(*) OVER w` from `test`.`t1` window `w` AS (PARTITION BY `test`.`t1`.`sex` ORDER BY `test`.`t1`.`id` ROWS BETWEEN 1 FOLLOWING AND 2 FOLLOWING) +EXPLAIN FORMAT=JSON SELECT id, AVG(id) OVER (ROWS UNBOUNDED PRECEDING) FROM t1; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.95" + }, + "windowing": { + "windows": [ + { + "name": "", + "functions": [ + "avg" + ] + } + ], + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.70", + "prefix_cost": "0.95", + "data_read_per_join": "112" + }, + "used_columns": [ + "id" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,avg(`test`.`t1`.`id`) OVER (ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) AS `AVG(id) OVER (ROWS UNBOUNDED PRECEDING)` from `test`.`t1` +EXPLAIN FORMAT=JSON SELECT id, AVG(id) OVER w, COUNT(id) OVER w FROM t1 +WINDOW w AS (ORDER BY id ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "7.95" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`id`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "avg", + "count" + ] + } + ], + "cost_info": { + "sort_cost": "7.00" + }, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.70", + "prefix_cost": "0.95", + "data_read_per_join": "112" + }, + "used_columns": [ + "id" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,avg(`test`.`t1`.`id`) OVER `w` AS `AVG(id) OVER w`,count(`test`.`t1`.`id`) OVER `w` AS `COUNT(id) OVER w` from `test`.`t1` window `w` AS (ORDER BY `test`.`t1`.`id` ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING) +AVG, SUM with double type +CREATE TABLE td(d DOUBLE); +INSERT INTO td VALUES (2),(2),(3),(1),(1.2),(NULL); +ANALYZE TABLE td; +Table Op Msg_type Msg_text +test.td analyze status OK +EXPLAIN FORMAT=JSON SELECT d, SUM(d) OVER (ORDER BY d), AVG(d) OVER (ORDER BY d) FROM td; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "6.85" + }, + "windowing": { + "windows": [ + { + "name": "", + "definition_position": 1, + "using_temporary_table": true, + "using_filesort": true, + "filesort_key": [ + "`d`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "sum" + ] + }, + { + "name": "", + "definition_position": 2, + "last_executed_window": true, + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "avg" + ] + } + ], + "cost_info": { + "sort_cost": "6.00" + }, + "table": { + "table_name": "td", + "access_type": "ALL", + "rows_examined_per_scan": 6, + "rows_produced_per_join": 6, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.60", + "prefix_cost": "0.85", + "data_read_per_join": "96" + }, + "used_columns": [ + "d" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`td`.`d` AS `d`,sum(`test`.`td`.`d`) OVER (ORDER BY `test`.`td`.`d` ) AS `SUM(d) OVER (ORDER BY d)`,avg(`test`.`td`.`d`) OVER (ORDER BY `test`.`td`.`d` ) AS `AVG(d) OVER (ORDER BY d)` from `test`.`td` +EXPLAIN FORMAT=JSON SELECT d, SUM(d) OVER (ORDER BY d), AVG(d) OVER () FROM td; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "6.85" + }, + "windowing": { + "windows": [ + { + "name": "", + "definition_position": 1, + "using_temporary_table": true, + "using_filesort": true, + "filesort_key": [ + "`d`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "sum" + ] + }, + { + "name": "", + "definition_position": 2, + "last_executed_window": true, + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "avg" + ] + } + ], + "cost_info": { + "sort_cost": "6.00" + }, + "table": { + "table_name": "td", + "access_type": "ALL", + "rows_examined_per_scan": 6, + "rows_produced_per_join": 6, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.60", + "prefix_cost": "0.85", + "data_read_per_join": "96" + }, + "used_columns": [ + "d" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`td`.`d` AS `d`,sum(`test`.`td`.`d`) OVER (ORDER BY `test`.`td`.`d` ) AS `SUM(d) OVER (ORDER BY d)`,avg(`test`.`td`.`d`) OVER () AS `AVG(d) OVER ()` from `test`.`td` +EXPLAIN FORMAT=JSON SELECT d, SUM(d) OVER (ORDER BY d), AVG(d) OVER (ORDER BY d ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING) FROM td; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "6.85" + }, + "windowing": { + "windows": [ + { + "name": "", + "definition_position": 1, + "using_temporary_table": true, + "using_filesort": true, + "filesort_key": [ + "`d`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "sum" + ] + }, + { + "name": "", + "definition_position": 2, + "last_executed_window": true, + "frame_buffer": { + "using_temporary_table": true + }, + "functions": [ + "avg" + ] + } + ], + "cost_info": { + "sort_cost": "6.00" + }, + "table": { + "table_name": "td", + "access_type": "ALL", + "rows_examined_per_scan": 6, + "rows_produced_per_join": 6, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.60", + "prefix_cost": "0.85", + "data_read_per_join": "96" + }, + "used_columns": [ + "d" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`td`.`d` AS `d`,sum(`test`.`td`.`d`) OVER (ORDER BY `test`.`td`.`d` ) AS `SUM(d) OVER (ORDER BY d)`,avg(`test`.`td`.`d`) OVER (ORDER BY `test`.`td`.`d` ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING) AS `AVG(d) OVER (ORDER BY d ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING)` from `test`.`td` +Check system variable "windowing_use_high_precision" +TRUNCATE td; +INSERT INTO td VALUES (1.7976931348623157E+307), (1); +ANALYZE TABLE td; +Table Op Msg_type Msg_text +test.td analyze status OK +should be default off: +SHOW VARIABLES LIKE 'windowing_use_high_precision'; +Variable_name Value +windowing_use_high_precision ON +EXPLAIN FORMAT=JSON SELECT d, SUM(d) OVER (ROWS BETWEEN CURRENT ROW AND 1 FOLLOWING) FROM td; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.45" + }, + "windowing": { + "windows": [ + { + "name": "", + "frame_buffer": { + "using_temporary_table": true + }, + "functions": [ + "sum" + ] + } + ], + "table": { + "table_name": "td", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 2, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.20", + "prefix_cost": "0.45", + "data_read_per_join": "32" + }, + "used_columns": [ + "d" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`td`.`d` AS `d`,sum(`test`.`td`.`d`) OVER (ROWS BETWEEN CURRENT ROW AND 1 FOLLOWING) AS `SUM(d) OVER (ROWS BETWEEN CURRENT ROW AND 1 FOLLOWING)` from `test`.`td` +allow unsafe optimization: result changes +SET SESSION windowing_use_high_precision=FALSE; +EXPLAIN FORMAT=JSON SELECT d, SUM(d) OVER (ROWS BETWEEN CURRENT ROW AND 1 FOLLOWING) FROM td; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.45" + }, + "windowing": { + "windows": [ + { + "name": "", + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "sum" + ] + } + ], + "table": { + "table_name": "td", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 2, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.20", + "prefix_cost": "0.45", + "data_read_per_join": "32" + }, + "used_columns": [ + "d" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`td`.`d` AS `d`,sum(`test`.`td`.`d`) OVER (ROWS BETWEEN CURRENT ROW AND 1 FOLLOWING) AS `SUM(d) OVER (ROWS BETWEEN CURRENT ROW AND 1 FOLLOWING)` from `test`.`td` +SET SESSION windowing_use_high_precision=TRUE; +bugfix: AVG for moving range frame +TRUNCATE td; +INSERT INTO td VALUES (10),(1),(2),(3),(4),(5),(6),(7),(8),(9); +ANALYZE TABLE td; +Table Op Msg_type Msg_text +test.td analyze status OK +EXPLAIN FORMAT=JSON SELECT d, SUM(d) OVER w, AVG(d) OVER w FROM td +WINDOW w AS (ORDER BY d RANGE BETWEEN 2 PRECEDING AND CURRENT ROW); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "11.25" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`d`" + ], + "frame_buffer": { + "using_temporary_table": true + }, + "functions": [ + "sum", + "avg" + ] + } + ], + "cost_info": { + "sort_cost": "10.00" + }, + "table": { + "table_name": "td", + "access_type": "ALL", + "rows_examined_per_scan": 10, + "rows_produced_per_join": 10, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "1.00", + "prefix_cost": "1.25", + "data_read_per_join": "160" + }, + "used_columns": [ + "d" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`td`.`d` AS `d`,sum(`test`.`td`.`d`) OVER `w` AS `SUM(d) OVER w`,avg(`test`.`td`.`d`) OVER `w` AS `AVG(d) OVER w` from `test`.`td` window `w` AS (ORDER BY `test`.`td`.`d` RANGE BETWEEN 2 PRECEDING AND CURRENT ROW) +EXPLAIN FORMAT=JSON SELECT d, SUM(d) OVER w, AVG(d) OVER w FROM td +WINDOW w AS (ORDER BY d RANGE BETWEEN 2 PRECEDING AND 2 FOLLOWING); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "11.25" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`d`" + ], + "frame_buffer": { + "using_temporary_table": true + }, + "functions": [ + "sum", + "avg" + ] + } + ], + "cost_info": { + "sort_cost": "10.00" + }, + "table": { + "table_name": "td", + "access_type": "ALL", + "rows_examined_per_scan": 10, + "rows_produced_per_join": 10, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "1.00", + "prefix_cost": "1.25", + "data_read_per_join": "160" + }, + "used_columns": [ + "d" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`td`.`d` AS `d`,sum(`test`.`td`.`d`) OVER `w` AS `SUM(d) OVER w`,avg(`test`.`td`.`d`) OVER `w` AS `AVG(d) OVER w` from `test`.`td` window `w` AS (ORDER BY `test`.`td`.`d` RANGE BETWEEN 2 PRECEDING AND 2 FOLLOWING) +EXPLAIN FORMAT=JSON SELECT d, SUM(d) OVER w, AVG(d) OVER w FROM td +WINDOW w AS (ORDER BY d RANGE BETWEEN CURRENT ROW AND 2 FOLLOWING); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "11.25" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`d`" + ], + "frame_buffer": { + "using_temporary_table": true + }, + "functions": [ + "sum", + "avg" + ] + } + ], + "cost_info": { + "sort_cost": "10.00" + }, + "table": { + "table_name": "td", + "access_type": "ALL", + "rows_examined_per_scan": 10, + "rows_produced_per_join": 10, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "1.00", + "prefix_cost": "1.25", + "data_read_per_join": "160" + }, + "used_columns": [ + "d" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`td`.`d` AS `d`,sum(`test`.`td`.`d`) OVER `w` AS `SUM(d) OVER w`,avg(`test`.`td`.`d`) OVER `w` AS `AVG(d) OVER w` from `test`.`td` window `w` AS (ORDER BY `test`.`td`.`d` RANGE BETWEEN CURRENT ROW AND 2 FOLLOWING) +SET SESSION windowing_use_high_precision=FALSE; +EXPLAIN FORMAT=JSON SELECT d, SUM(d) OVER w, AVG(d) OVER w FROM td +WINDOW w AS (ORDER BY d RANGE BETWEEN 2 PRECEDING AND CURRENT ROW); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "11.25" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`d`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "sum", + "avg" + ] + } + ], + "cost_info": { + "sort_cost": "10.00" + }, + "table": { + "table_name": "td", + "access_type": "ALL", + "rows_examined_per_scan": 10, + "rows_produced_per_join": 10, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "1.00", + "prefix_cost": "1.25", + "data_read_per_join": "160" + }, + "used_columns": [ + "d" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`td`.`d` AS `d`,sum(`test`.`td`.`d`) OVER `w` AS `SUM(d) OVER w`,avg(`test`.`td`.`d`) OVER `w` AS `AVG(d) OVER w` from `test`.`td` window `w` AS (ORDER BY `test`.`td`.`d` RANGE BETWEEN 2 PRECEDING AND CURRENT ROW) +EXPLAIN FORMAT=JSON SELECT d, SUM(d) OVER w, AVG(d) OVER w FROM td +WINDOW w AS (ORDER BY d RANGE BETWEEN 2 PRECEDING AND 2 FOLLOWING); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "11.25" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`d`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "sum", + "avg" + ] + } + ], + "cost_info": { + "sort_cost": "10.00" + }, + "table": { + "table_name": "td", + "access_type": "ALL", + "rows_examined_per_scan": 10, + "rows_produced_per_join": 10, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "1.00", + "prefix_cost": "1.25", + "data_read_per_join": "160" + }, + "used_columns": [ + "d" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`td`.`d` AS `d`,sum(`test`.`td`.`d`) OVER `w` AS `SUM(d) OVER w`,avg(`test`.`td`.`d`) OVER `w` AS `AVG(d) OVER w` from `test`.`td` window `w` AS (ORDER BY `test`.`td`.`d` RANGE BETWEEN 2 PRECEDING AND 2 FOLLOWING) +EXPLAIN FORMAT=JSON SELECT d, SUM(d) OVER w, AVG(d) OVER w FROM td +WINDOW w AS (ORDER BY d RANGE BETWEEN CURRENT ROW AND 2 FOLLOWING); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "11.25" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`d`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "sum", + "avg" + ] + } + ], + "cost_info": { + "sort_cost": "10.00" + }, + "table": { + "table_name": "td", + "access_type": "ALL", + "rows_examined_per_scan": 10, + "rows_produced_per_join": 10, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "1.00", + "prefix_cost": "1.25", + "data_read_per_join": "160" + }, + "used_columns": [ + "d" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`td`.`d` AS `d`,sum(`test`.`td`.`d`) OVER `w` AS `SUM(d) OVER w`,avg(`test`.`td`.`d`) OVER `w` AS `AVG(d) OVER w` from `test`.`td` window `w` AS (ORDER BY `test`.`td`.`d` RANGE BETWEEN CURRENT ROW AND 2 FOLLOWING) +SET SESSION windowing_use_high_precision=TRUE; +INSERT INTO td SELECT * FROM td; +ANALYZE TABLE td; +Table Op Msg_type Msg_text +test.td analyze status OK +EXPLAIN FORMAT=JSON SELECT d, SUM(d) OVER w, AVG(d) OVER w FROM td +WINDOW w AS (ORDER BY d RANGE BETWEEN 2 PRECEDING AND CURRENT ROW); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "22.25" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`d`" + ], + "frame_buffer": { + "using_temporary_table": true + }, + "functions": [ + "sum", + "avg" + ] + } + ], + "cost_info": { + "sort_cost": "20.00" + }, + "table": { + "table_name": "td", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 20, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "2.00", + "prefix_cost": "2.25", + "data_read_per_join": "320" + }, + "used_columns": [ + "d" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`td`.`d` AS `d`,sum(`test`.`td`.`d`) OVER `w` AS `SUM(d) OVER w`,avg(`test`.`td`.`d`) OVER `w` AS `AVG(d) OVER w` from `test`.`td` window `w` AS (ORDER BY `test`.`td`.`d` RANGE BETWEEN 2 PRECEDING AND CURRENT ROW) +EXPLAIN FORMAT=JSON SELECT d, SUM(d) OVER w, AVG(d) OVER w FROM td +WINDOW w AS (ORDER BY d RANGE BETWEEN 2 PRECEDING AND 2 FOLLOWING); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "22.25" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`d`" + ], + "frame_buffer": { + "using_temporary_table": true + }, + "functions": [ + "sum", + "avg" + ] + } + ], + "cost_info": { + "sort_cost": "20.00" + }, + "table": { + "table_name": "td", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 20, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "2.00", + "prefix_cost": "2.25", + "data_read_per_join": "320" + }, + "used_columns": [ + "d" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`td`.`d` AS `d`,sum(`test`.`td`.`d`) OVER `w` AS `SUM(d) OVER w`,avg(`test`.`td`.`d`) OVER `w` AS `AVG(d) OVER w` from `test`.`td` window `w` AS (ORDER BY `test`.`td`.`d` RANGE BETWEEN 2 PRECEDING AND 2 FOLLOWING) +EXPLAIN FORMAT=JSON SELECT d, SUM(d) OVER w, AVG(d) OVER w FROM td +WINDOW w AS (ORDER BY d RANGE BETWEEN CURRENT ROW AND 2 FOLLOWING); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "22.25" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`d`" + ], + "frame_buffer": { + "using_temporary_table": true + }, + "functions": [ + "sum", + "avg" + ] + } + ], + "cost_info": { + "sort_cost": "20.00" + }, + "table": { + "table_name": "td", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 20, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "2.00", + "prefix_cost": "2.25", + "data_read_per_join": "320" + }, + "used_columns": [ + "d" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`td`.`d` AS `d`,sum(`test`.`td`.`d`) OVER `w` AS `SUM(d) OVER w`,avg(`test`.`td`.`d`) OVER `w` AS `AVG(d) OVER w` from `test`.`td` window `w` AS (ORDER BY `test`.`td`.`d` RANGE BETWEEN CURRENT ROW AND 2 FOLLOWING) +SET SESSION windowing_use_high_precision=FALSE; +EXPLAIN FORMAT=JSON SELECT d, SUM(d) OVER w, AVG(d) OVER w FROM td +WINDOW w AS (ORDER BY d RANGE BETWEEN 2 PRECEDING AND CURRENT ROW); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "22.25" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`d`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "sum", + "avg" + ] + } + ], + "cost_info": { + "sort_cost": "20.00" + }, + "table": { + "table_name": "td", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 20, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "2.00", + "prefix_cost": "2.25", + "data_read_per_join": "320" + }, + "used_columns": [ + "d" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`td`.`d` AS `d`,sum(`test`.`td`.`d`) OVER `w` AS `SUM(d) OVER w`,avg(`test`.`td`.`d`) OVER `w` AS `AVG(d) OVER w` from `test`.`td` window `w` AS (ORDER BY `test`.`td`.`d` RANGE BETWEEN 2 PRECEDING AND CURRENT ROW) +EXPLAIN FORMAT=JSON SELECT d, SUM(d) OVER w, AVG(d) OVER w FROM td +WINDOW w AS (ORDER BY d RANGE BETWEEN 2 PRECEDING AND 2 FOLLOWING); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "22.25" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`d`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "sum", + "avg" + ] + } + ], + "cost_info": { + "sort_cost": "20.00" + }, + "table": { + "table_name": "td", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 20, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "2.00", + "prefix_cost": "2.25", + "data_read_per_join": "320" + }, + "used_columns": [ + "d" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`td`.`d` AS `d`,sum(`test`.`td`.`d`) OVER `w` AS `SUM(d) OVER w`,avg(`test`.`td`.`d`) OVER `w` AS `AVG(d) OVER w` from `test`.`td` window `w` AS (ORDER BY `test`.`td`.`d` RANGE BETWEEN 2 PRECEDING AND 2 FOLLOWING) +EXPLAIN FORMAT=JSON SELECT d, SUM(d) OVER w, AVG(d) OVER w FROM td +WINDOW w AS (ORDER BY d RANGE BETWEEN CURRENT ROW AND 2 FOLLOWING); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "22.25" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`d`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "sum", + "avg" + ] + } + ], + "cost_info": { + "sort_cost": "20.00" + }, + "table": { + "table_name": "td", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 20, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "2.00", + "prefix_cost": "2.25", + "data_read_per_join": "320" + }, + "used_columns": [ + "d" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`td`.`d` AS `d`,sum(`test`.`td`.`d`) OVER `w` AS `SUM(d) OVER w`,avg(`test`.`td`.`d`) OVER `w` AS `AVG(d) OVER w` from `test`.`td` window `w` AS (ORDER BY `test`.`td`.`d` RANGE BETWEEN CURRENT ROW AND 2 FOLLOWING) +SET SESSION windowing_use_high_precision=TRUE; +DROP TABLE td; +---------------------------------------------------------------------- +- NTILE (requires two passes over partition). +- Currently suboptimal in that it causes N*N reads of tmp buffer +---------------------------------------------------------------------- +EXPLAIN FORMAT=JSON SELECT id, NTILE(NULL) OVER w FROM t1 WINDOW w AS (ORDER BY id); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'NULL) OVER w FROM t1 WINDOW w AS (ORDER BY id)' at line 1 +EXPLAIN FORMAT=JSON SELECT id, NTILE(1) OVER w FROM t1 WINDOW w AS (ORDER BY id); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "7.95" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`id`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "ntile" + ] + } + ], + "cost_info": { + "sort_cost": "7.00" + }, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.70", + "prefix_cost": "0.95", + "data_read_per_join": "112" + }, + "used_columns": [ + "id" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,ntile(1) OVER `w` AS `NTILE(1) OVER w` from `test`.`t1` window `w` AS (ORDER BY `test`.`t1`.`id` ) +EXPLAIN FORMAT=JSON SELECT id, NTILE(2) OVER w FROM t1 WINDOW w AS (ORDER BY id); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "7.95" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`id`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "ntile" + ] + } + ], + "cost_info": { + "sort_cost": "7.00" + }, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.70", + "prefix_cost": "0.95", + "data_read_per_join": "112" + }, + "used_columns": [ + "id" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,ntile(2) OVER `w` AS `NTILE(2) OVER w` from `test`.`t1` window `w` AS (ORDER BY `test`.`t1`.`id` ) +EXPLAIN FORMAT=JSON SELECT id, NTILE(5) OVER w FROM t1 WINDOW w AS (ORDER BY id); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "7.95" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`id`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "ntile" + ] + } + ], + "cost_info": { + "sort_cost": "7.00" + }, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.70", + "prefix_cost": "0.95", + "data_read_per_join": "112" + }, + "used_columns": [ + "id" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,ntile(5) OVER `w` AS `NTILE(5) OVER w` from `test`.`t1` window `w` AS (ORDER BY `test`.`t1`.`id` ) +EXPLAIN FORMAT=JSON SELECT id, NTILE(11) OVER w FROM t1 WINDOW w AS (ORDER BY id); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "7.95" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`id`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "ntile" + ] + } + ], + "cost_info": { + "sort_cost": "7.00" + }, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.70", + "prefix_cost": "0.95", + "data_read_per_join": "112" + }, + "used_columns": [ + "id" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,ntile(11) OVER `w` AS `NTILE(11) OVER w` from `test`.`t1` window `w` AS (ORDER BY `test`.`t1`.`id` ) +combo with frame +EXPLAIN FORMAT=JSON SELECT id, ROW_NUMBER() OVER w, NTILE(4) OVER w, SUM(id) OVER w FROM t1 +WINDOW w AS (ORDER BY id ROWS 1 PRECEDING); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "7.95" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`id`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "row_number", + "ntile", + "sum" + ] + } + ], + "cost_info": { + "sort_cost": "7.00" + }, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.70", + "prefix_cost": "0.95", + "data_read_per_join": "112" + }, + "used_columns": [ + "id" + ] + } + } + } +} +Warnings: +Note 3599 Window function 'row_number' ignores the frame clause of window 'w' and aggregates over the whole partition +Note 3599 Window function 'ntile' ignores the frame clause of window 'w' and aggregates over the whole partition +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,row_number() OVER `w` AS `ROW_NUMBER() OVER w`,ntile(4) OVER `w` AS `NTILE(4) OVER w`,sum(`test`.`t1`.`id`) OVER `w` AS `SUM(id) OVER w` from `test`.`t1` window `w` AS (ORDER BY `test`.`t1`.`id` ROWS BETWEEN 1 PRECEDING AND CURRENT ROW) +Try one where there are no extras +DELETE FROM t1 WHERE id=11; +EXPLAIN FORMAT=JSON SELECT id, NTILE(3) OVER w FROM t1 WINDOW w AS (ORDER BY id); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "6.85" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`id`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "ntile" + ] + } + ], + "cost_info": { + "sort_cost": "6.00" + }, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 6, + "rows_produced_per_join": 6, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.60", + "prefix_cost": "0.85", + "data_read_per_join": "96" + }, + "used_columns": [ + "id" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,ntile(3) OVER `w` AS `NTILE(3) OVER w` from `test`.`t1` window `w` AS (ORDER BY `test`.`t1`.`id` ) +INSERT INTO t1 VALUES (11, NULL); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +Simulated NTILE via other SQL window functions. Exercises an +an expression containing window functions defined on different +windows +EXPLAIN FORMAT=JSON SELECT (ROW_NUMBER() OVER w1 * 5 - 1) DIV (COUNT(*) OVER w2) + 1 AS cnt +FROM t1 WINDOW w1 AS (ORDER BY id ASC), +w2 AS (); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "7.95" + }, + "windowing": { + "windows": [ + { + "name": "w1", + "definition_position": 1, + "using_temporary_table": true, + "using_filesort": true, + "filesort_key": [ + "`id`" + ], + "functions": [ + "row_number" + ] + }, + { + "name": "w2", + "definition_position": 2, + "last_executed_window": true, + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "count" + ] + } + ], + "cost_info": { + "sort_cost": "7.00" + }, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.70", + "prefix_cost": "0.95", + "data_read_per_join": "112" + }, + "used_columns": [ + "id" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select ((((row_number() OVER `w1` * 5) - 1) DIV count(0) OVER `w2`) + 1) AS `cnt` from `test`.`t1` window `w1` AS (ORDER BY `test`.`t1`.`id` ) , `w2` AS () +EXPLAIN FORMAT=JSON SELECT (ROW_NUMBER() OVER w1 * 5 - 1) DIV (COUNT(*) OVER w2) + 1 AS ntile_manually, +COUNT(*) OVER w3 +FROM t1 WINDOW w1 AS (ORDER BY id ASC), +w2 AS (), w3 AS (); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "7.95" + }, + "windowing": { + "windows": [ + { + "name": "w1", + "definition_position": 1, + "using_temporary_table": true, + "using_filesort": true, + "filesort_key": [ + "`id`" + ], + "functions": [ + "row_number" + ] + }, + { + "name": "w2", + "definition_position": 2, + "using_temporary_table": true, + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "count" + ] + }, + { + "name": "w3", + "definition_position": 3, + "last_executed_window": true, + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "count" + ] + } + ], + "cost_info": { + "sort_cost": "7.00" + }, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.70", + "prefix_cost": "0.95", + "data_read_per_join": "112" + }, + "used_columns": [ + "id" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select ((((row_number() OVER `w1` * 5) - 1) DIV count(0) OVER `w2`) + 1) AS `ntile_manually`,count(0) OVER `w3` AS `COUNT(*) OVER w3` from `test`.`t1` window `w1` AS (ORDER BY `test`.`t1`.`id` ) , `w2` AS () , `w3` AS () +NTILE in combination with a frame that doesn't cover current row (was bug) +EXPLAIN FORMAT=JSON SELECT id, ROW_NUMBER() OVER w, SUM(id) OVER w, NTILE(5) OVER w FROM t1 +WINDOW w AS (ORDER BY id ROWS BETWEEN UNBOUNDED PRECEDING AND 2 PRECEDING); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "7.95" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`id`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "row_number", + "sum", + "ntile" + ] + } + ], + "cost_info": { + "sort_cost": "7.00" + }, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.70", + "prefix_cost": "0.95", + "data_read_per_join": "112" + }, + "used_columns": [ + "id" + ] + } + } + } +} +Warnings: +Note 3599 Window function 'row_number' ignores the frame clause of window 'w' and aggregates over the whole partition +Note 3599 Window function 'ntile' ignores the frame clause of window 'w' and aggregates over the whole partition +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,row_number() OVER `w` AS `ROW_NUMBER() OVER w`,sum(`test`.`t1`.`id`) OVER `w` AS `SUM(id) OVER w`,ntile(5) OVER `w` AS `NTILE(5) OVER w` from `test`.`t1` window `w` AS (ORDER BY `test`.`t1`.`id` ROWS BETWEEN UNBOUNDED PRECEDING AND 2 PRECEDING) +---------------------------------------------------------------------- +- SUM with frames in combination with non-framing window functions +- ROW_NUMBER and RANK +---------------------------------------------------------------------- +EXPLAIN FORMAT=JSON SELECT ROW_NUMBER() OVER w, id, SUM(id) OVER w, sex FROM t1 +WINDOW w AS (PARTITION BY sex ORDER BY id ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "7.95" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`sex`", + "`id`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "row_number", + "sum" + ] + } + ], + "cost_info": { + "sort_cost": "7.00" + }, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.70", + "prefix_cost": "0.95", + "data_read_per_join": "112" + }, + "used_columns": [ + "id", + "sex" + ] + } + } + } +} +Warnings: +Note 3599 Window function 'row_number' ignores the frame clause of window 'w' and aggregates over the whole partition +Note 1003 /* select#1 */ select row_number() OVER `w` AS `ROW_NUMBER() OVER w`,`test`.`t1`.`id` AS `id`,sum(`test`.`t1`.`id`) OVER `w` AS `SUM(id) OVER w`,`test`.`t1`.`sex` AS `sex` from `test`.`t1` window `w` AS (PARTITION BY `test`.`t1`.`sex` ORDER BY `test`.`t1`.`id` ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) +EXPLAIN FORMAT=JSON SELECT ROW_NUMBER() OVER w, SUM(id) OVER w FROM t1 +WINDOW w AS (PARTITION BY sex ORDER BY id +ROWS BETWEEN 1 FOLLOWING AND 2 FOLLOWING); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "7.95" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`sex`", + "`id`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "row_number", + "sum" + ] + } + ], + "cost_info": { + "sort_cost": "7.00" + }, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.70", + "prefix_cost": "0.95", + "data_read_per_join": "112" + }, + "used_columns": [ + "id", + "sex" + ] + } + } + } +} +Warnings: +Note 3599 Window function 'row_number' ignores the frame clause of window 'w' and aggregates over the whole partition +Note 1003 /* select#1 */ select row_number() OVER `w` AS `ROW_NUMBER() OVER w`,sum(`test`.`t1`.`id`) OVER `w` AS `SUM(id) OVER w` from `test`.`t1` window `w` AS (PARTITION BY `test`.`t1`.`sex` ORDER BY `test`.`t1`.`id` ROWS BETWEEN 1 FOLLOWING AND 2 FOLLOWING) +INSERT INTO t1 VALUES (10, NULL); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN FORMAT=JSON SELECT RANK() OVER w, id, SUM(id) OVER w, sex FROM t1 +WINDOW w AS (PARTITION BY sex ORDER BY id); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "9.05" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`sex`", + "`id`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "rank", + "sum" + ] + } + ], + "cost_info": { + "sort_cost": "8.00" + }, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 8, + "rows_produced_per_join": 8, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.80", + "prefix_cost": "1.05", + "data_read_per_join": "128" + }, + "used_columns": [ + "id", + "sex" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select rank() OVER `w` AS `RANK() OVER w`,`test`.`t1`.`id` AS `id`,sum(`test`.`t1`.`id`) OVER `w` AS `SUM(id) OVER w`,`test`.`t1`.`sex` AS `sex` from `test`.`t1` window `w` AS (PARTITION BY `test`.`t1`.`sex` ORDER BY `test`.`t1`.`id` ) +EXPLAIN FORMAT=JSON SELECT RANK() OVER w, SUM(id) OVER w FROM t1 +WINDOW w AS (PARTITION BY sex ORDER BY id +ROWS BETWEEN 1 FOLLOWING AND 2 FOLLOWING); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "9.05" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`sex`", + "`id`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "rank", + "sum" + ] + } + ], + "cost_info": { + "sort_cost": "8.00" + }, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 8, + "rows_produced_per_join": 8, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.80", + "prefix_cost": "1.05", + "data_read_per_join": "128" + }, + "used_columns": [ + "id", + "sex" + ] + } + } + } +} +Warnings: +Note 3599 Window function 'rank' ignores the frame clause of window 'w' and aggregates over the whole partition +Note 1003 /* select#1 */ select rank() OVER `w` AS `RANK() OVER w`,sum(`test`.`t1`.`id`) OVER `w` AS `SUM(id) OVER w` from `test`.`t1` window `w` AS (PARTITION BY `test`.`t1`.`sex` ORDER BY `test`.`t1`.`id` ROWS BETWEEN 1 FOLLOWING AND 2 FOLLOWING) +EXPLAIN FORMAT=JSON SELECT id, sex, SUM(id) OVER w, +ROW_NUMBER() OVER w, +RANK() OVER w FROM t1 +WINDOW w AS (PARTITION BY sex ORDER BY id ROWS BETWEEN 2 PRECEDING AND 1 PRECEDING); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "9.05" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`sex`", + "`id`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "sum", + "row_number", + "rank" + ] + } + ], + "cost_info": { + "sort_cost": "8.00" + }, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 8, + "rows_produced_per_join": 8, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.80", + "prefix_cost": "1.05", + "data_read_per_join": "128" + }, + "used_columns": [ + "id", + "sex" + ] + } + } + } +} +Warnings: +Note 3599 Window function 'row_number' ignores the frame clause of window 'w' and aggregates over the whole partition +Note 3599 Window function 'rank' ignores the frame clause of window 'w' and aggregates over the whole partition +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,`test`.`t1`.`sex` AS `sex`,sum(`test`.`t1`.`id`) OVER `w` AS `SUM(id) OVER w`,row_number() OVER `w` AS `ROW_NUMBER() OVER w`,rank() OVER `w` AS `RANK() OVER w` from `test`.`t1` window `w` AS (PARTITION BY `test`.`t1`.`sex` ORDER BY `test`.`t1`.`id` ROWS BETWEEN 2 PRECEDING AND 1 PRECEDING) +---------------------------------------------------------------------- +- FIRST_VALUE +---------------------------------------------------------------------- +INSERT INTO t1 VALUES (NULL, 'M'); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN FORMAT=JSON SELECT id, FIRST_VALUE(id) OVER w FROM t1 WINDOW w AS (); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.15" + }, + "windowing": { + "windows": [ + { + "name": "w", + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "first_value" + ] + } + ], + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 9, + "rows_produced_per_join": 9, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.90", + "prefix_cost": "1.15", + "data_read_per_join": "144" + }, + "used_columns": [ + "id" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,first_value(`test`.`t1`.`id`) OVER `w` AS `FIRST_VALUE(id) OVER w` from `test`.`t1` window `w` AS () +select id, FIRST_VALUE(id) OVER (ROWS UNBOUNDED PRECEDING) FROM t1; +id FIRST_VALUE(id) OVER (ROWS UNBOUNDED PRECEDING) +1 1 +2 1 +3 1 +4 1 +5 1 +10 1 +11 1 +10 1 +NULL 1 +EXPLAIN FORMAT=JSON SELECT id, FIRST_VALUE(id) OVER w FROM t1 WINDOW w AS (ORDER BY id); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "10.15" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`id`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "first_value" + ] + } + ], + "cost_info": { + "sort_cost": "9.00" + }, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 9, + "rows_produced_per_join": 9, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.90", + "prefix_cost": "1.15", + "data_read_per_join": "144" + }, + "used_columns": [ + "id" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,first_value(`test`.`t1`.`id`) OVER `w` AS `FIRST_VALUE(id) OVER w` from `test`.`t1` window `w` AS (ORDER BY `test`.`t1`.`id` ) +EXPLAIN FORMAT=JSON SELECT id, FIRST_VALUE(id) OVER w FROM t1 WINDOW w AS (PARTITION BY sex ORDER BY id); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "10.15" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`sex`", + "`id`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "first_value" + ] + } + ], + "cost_info": { + "sort_cost": "9.00" + }, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 9, + "rows_produced_per_join": 9, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.90", + "prefix_cost": "1.15", + "data_read_per_join": "144" + }, + "used_columns": [ + "id", + "sex" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,first_value(`test`.`t1`.`id`) OVER `w` AS `FIRST_VALUE(id) OVER w` from `test`.`t1` window `w` AS (PARTITION BY `test`.`t1`.`sex` ORDER BY `test`.`t1`.`id` ) +EXPLAIN FORMAT=JSON SELECT id, FIRST_VALUE(id) OVER w FROM t1 WINDOW w AS (ORDER BY id DESC); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "10.15" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`id` desc" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "first_value" + ] + } + ], + "cost_info": { + "sort_cost": "9.00" + }, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 9, + "rows_produced_per_join": 9, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.90", + "prefix_cost": "1.15", + "data_read_per_join": "144" + }, + "used_columns": [ + "id" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,first_value(`test`.`t1`.`id`) OVER `w` AS `FIRST_VALUE(id) OVER w` from `test`.`t1` window `w` AS (ORDER BY `test`.`t1`.`id` desc ) +EXPLAIN FORMAT=JSON SELECT id, FIRST_VALUE(id) OVER w FROM t1 WINDOW w AS (ORDER BY id ROWS 2 PRECEDING); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "10.15" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`id`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "first_value" + ] + } + ], + "cost_info": { + "sort_cost": "9.00" + }, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 9, + "rows_produced_per_join": 9, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.90", + "prefix_cost": "1.15", + "data_read_per_join": "144" + }, + "used_columns": [ + "id" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,first_value(`test`.`t1`.`id`) OVER `w` AS `FIRST_VALUE(id) OVER w` from `test`.`t1` window `w` AS (ORDER BY `test`.`t1`.`id` ROWS BETWEEN 2 PRECEDING AND CURRENT ROW) +EXPLAIN FORMAT=JSON SELECT id, FIRST_VALUE(id) OVER w FROM t1 WINDOW w AS (ORDER BY id RANGE 2 PRECEDING); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "10.15" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`id`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "first_value" + ] + } + ], + "cost_info": { + "sort_cost": "9.00" + }, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 9, + "rows_produced_per_join": 9, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.90", + "prefix_cost": "1.15", + "data_read_per_join": "144" + }, + "used_columns": [ + "id" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,first_value(`test`.`t1`.`id`) OVER `w` AS `FIRST_VALUE(id) OVER w` from `test`.`t1` window `w` AS (ORDER BY `test`.`t1`.`id` RANGE BETWEEN 2 PRECEDING AND CURRENT ROW) +EXPLAIN FORMAT=JSON SELECT id, FIRST_VALUE(id) OVER w FROM t1 WINDOW w AS (ORDER BY id ROWS BETWEEN 2 PRECEDING AND 1 PRECEDING); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "10.15" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`id`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "first_value" + ] + } + ], + "cost_info": { + "sort_cost": "9.00" + }, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 9, + "rows_produced_per_join": 9, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.90", + "prefix_cost": "1.15", + "data_read_per_join": "144" + }, + "used_columns": [ + "id" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,first_value(`test`.`t1`.`id`) OVER `w` AS `FIRST_VALUE(id) OVER w` from `test`.`t1` window `w` AS (ORDER BY `test`.`t1`.`id` ROWS BETWEEN 2 PRECEDING AND 1 PRECEDING) +EXPLAIN FORMAT=JSON SELECT id, FIRST_VALUE(id) OVER w FROM t1 WINDOW w AS (ORDER BY id RANGE BETWEEN 2 PRECEDING AND 1 PRECEDING); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "10.15" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`id`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "first_value" + ] + } + ], + "cost_info": { + "sort_cost": "9.00" + }, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 9, + "rows_produced_per_join": 9, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.90", + "prefix_cost": "1.15", + "data_read_per_join": "144" + }, + "used_columns": [ + "id" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,first_value(`test`.`t1`.`id`) OVER `w` AS `FIRST_VALUE(id) OVER w` from `test`.`t1` window `w` AS (ORDER BY `test`.`t1`.`id` RANGE BETWEEN 2 PRECEDING AND 1 PRECEDING) +EXPLAIN FORMAT=JSON SELECT id, FIRST_VALUE(id) OVER w FROM t1 WINDOW w AS (ORDER BY id ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "10.15" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`id`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "first_value" + ] + } + ], + "cost_info": { + "sort_cost": "9.00" + }, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 9, + "rows_produced_per_join": 9, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.90", + "prefix_cost": "1.15", + "data_read_per_join": "144" + }, + "used_columns": [ + "id" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,first_value(`test`.`t1`.`id`) OVER `w` AS `FIRST_VALUE(id) OVER w` from `test`.`t1` window `w` AS (ORDER BY `test`.`t1`.`id` ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) +EXPLAIN FORMAT=JSON SELECT id, FIRST_VALUE(id) OVER w FROM t1 WINDOW w AS (ORDER BY id RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "10.15" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`id`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "first_value" + ] + } + ], + "cost_info": { + "sort_cost": "9.00" + }, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 9, + "rows_produced_per_join": 9, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.90", + "prefix_cost": "1.15", + "data_read_per_join": "144" + }, + "used_columns": [ + "id" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,first_value(`test`.`t1`.`id`) OVER `w` AS `FIRST_VALUE(id) OVER w` from `test`.`t1` window `w` AS (ORDER BY `test`.`t1`.`id` RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) +CREATE VIEW v AS +SELECT id, FIRST_VALUE(id) OVER w FROM t1 WINDOW w AS (ORDER BY id RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING); +SHOW CREATE VIEW v; +View Create View character_set_client collation_connection +v CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v` AS select `t1`.`id` AS `id`,first_value(`t1`.`id`) OVER `w` AS `FIRST_VALUE(id) OVER w` from `t1` window `w` AS (ORDER BY `t1`.`id` RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) utf8 utf8_general_ci +EXPLAIN FORMAT=JSON SELECT * FROM v; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "3.51" + }, + "table": { + "table_name": "v", + "access_type": "ALL", + "rows_examined_per_scan": 9, + "rows_produced_per_join": 9, + "filtered": "100.00", + "cost_info": { + "read_cost": "2.61", + "eval_cost": "0.90", + "prefix_cost": "3.51", + "data_read_per_join": "216" + }, + "used_columns": [ + "id", + "FIRST_VALUE(id) OVER w" + ], + "materialized_from_subquery": { + "using_temporary_table": true, + "dependent": false, + "cacheable": true, + "query_block": { + "select_id": 2, + "cost_info": { + "query_cost": "10.15" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`id`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "first_value" + ] + } + ], + "cost_info": { + "sort_cost": "9.00" + }, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 9, + "rows_produced_per_join": 9, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.90", + "prefix_cost": "1.15", + "data_read_per_join": "144" + }, + "used_columns": [ + "id" + ] + } + } + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`v`.`id` AS `id`,`test`.`v`.`FIRST_VALUE(id) OVER w` AS `FIRST_VALUE(id) OVER w` from `test`.`v` +DROP VIEW v; +EXPLAIN FORMAT=JSON SELECT id, FIRST_VALUE(id) OVER w FROM t1 WINDOW w AS (ORDER BY id ROWS BETWEEN 2 FOLLOWING AND 3 FOLLOWING); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "10.15" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`id`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "first_value" + ] + } + ], + "cost_info": { + "sort_cost": "9.00" + }, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 9, + "rows_produced_per_join": 9, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.90", + "prefix_cost": "1.15", + "data_read_per_join": "144" + }, + "used_columns": [ + "id" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,first_value(`test`.`t1`.`id`) OVER `w` AS `FIRST_VALUE(id) OVER w` from `test`.`t1` window `w` AS (ORDER BY `test`.`t1`.`id` ROWS BETWEEN 2 FOLLOWING AND 3 FOLLOWING) +EXPLAIN FORMAT=JSON SELECT id, FIRST_VALUE(id) OVER w FROM t1 WINDOW w AS (ORDER BY id RANGE BETWEEN 2 FOLLOWING AND 3 FOLLOWING); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "10.15" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`id`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "first_value" + ] + } + ], + "cost_info": { + "sort_cost": "9.00" + }, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 9, + "rows_produced_per_join": 9, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.90", + "prefix_cost": "1.15", + "data_read_per_join": "144" + }, + "used_columns": [ + "id" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,first_value(`test`.`t1`.`id`) OVER `w` AS `FIRST_VALUE(id) OVER w` from `test`.`t1` window `w` AS (ORDER BY `test`.`t1`.`id` RANGE BETWEEN 2 FOLLOWING AND 3 FOLLOWING) +CREATE TABLE td1 (id DOUBLE, sex CHAR(1)); +INSERT INTO td1 SELECT * FROM t1; +ANALYZE TABLE td1; +Table Op Msg_type Msg_text +test.td1 analyze status OK +EXPLAIN FORMAT=JSON SELECT id, FIRST_VALUE(id) OVER w FROM td1 WINDOW w AS (); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.15" + }, + "windowing": { + "windows": [ + { + "name": "w", + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "first_value" + ] + } + ], + "table": { + "table_name": "td1", + "access_type": "ALL", + "rows_examined_per_scan": 9, + "rows_produced_per_join": 9, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.90", + "prefix_cost": "1.15", + "data_read_per_join": "144" + }, + "used_columns": [ + "id" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`td1`.`id` AS `id`,first_value(`test`.`td1`.`id`) OVER `w` AS `FIRST_VALUE(id) OVER w` from `test`.`td1` window `w` AS () +EXPLAIN FORMAT=JSON SELECT id, FIRST_VALUE(id) OVER w FROM td1 WINDOW w AS (ORDER BY id); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "10.15" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`id`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "first_value" + ] + } + ], + "cost_info": { + "sort_cost": "9.00" + }, + "table": { + "table_name": "td1", + "access_type": "ALL", + "rows_examined_per_scan": 9, + "rows_produced_per_join": 9, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.90", + "prefix_cost": "1.15", + "data_read_per_join": "144" + }, + "used_columns": [ + "id" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`td1`.`id` AS `id`,first_value(`test`.`td1`.`id`) OVER `w` AS `FIRST_VALUE(id) OVER w` from `test`.`td1` window `w` AS (ORDER BY `test`.`td1`.`id` ) +EXPLAIN FORMAT=JSON SELECT id, FIRST_VALUE(id) OVER w FROM td1 WINDOW w AS (PARTITION BY sex ORDER BY id); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "10.15" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`sex`", + "`id`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "first_value" + ] + } + ], + "cost_info": { + "sort_cost": "9.00" + }, + "table": { + "table_name": "td1", + "access_type": "ALL", + "rows_examined_per_scan": 9, + "rows_produced_per_join": 9, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.90", + "prefix_cost": "1.15", + "data_read_per_join": "144" + }, + "used_columns": [ + "id", + "sex" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`td1`.`id` AS `id`,first_value(`test`.`td1`.`id`) OVER `w` AS `FIRST_VALUE(id) OVER w` from `test`.`td1` window `w` AS (PARTITION BY `test`.`td1`.`sex` ORDER BY `test`.`td1`.`id` ) +EXPLAIN FORMAT=JSON SELECT id, FIRST_VALUE(id) OVER w FROM td1 WINDOW w AS (ORDER BY id DESC); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "10.15" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`id` desc" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "first_value" + ] + } + ], + "cost_info": { + "sort_cost": "9.00" + }, + "table": { + "table_name": "td1", + "access_type": "ALL", + "rows_examined_per_scan": 9, + "rows_produced_per_join": 9, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.90", + "prefix_cost": "1.15", + "data_read_per_join": "144" + }, + "used_columns": [ + "id" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`td1`.`id` AS `id`,first_value(`test`.`td1`.`id`) OVER `w` AS `FIRST_VALUE(id) OVER w` from `test`.`td1` window `w` AS (ORDER BY `test`.`td1`.`id` desc ) +EXPLAIN FORMAT=JSON SELECT id, FIRST_VALUE(id) OVER w FROM td1 WINDOW w AS (ORDER BY id ROWS 2 PRECEDING); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "10.15" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`id`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "first_value" + ] + } + ], + "cost_info": { + "sort_cost": "9.00" + }, + "table": { + "table_name": "td1", + "access_type": "ALL", + "rows_examined_per_scan": 9, + "rows_produced_per_join": 9, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.90", + "prefix_cost": "1.15", + "data_read_per_join": "144" + }, + "used_columns": [ + "id" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`td1`.`id` AS `id`,first_value(`test`.`td1`.`id`) OVER `w` AS `FIRST_VALUE(id) OVER w` from `test`.`td1` window `w` AS (ORDER BY `test`.`td1`.`id` ROWS BETWEEN 2 PRECEDING AND CURRENT ROW) +EXPLAIN FORMAT=JSON SELECT id, FIRST_VALUE(id) OVER w FROM td1 WINDOW w AS (ORDER BY id RANGE 2 PRECEDING); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "10.15" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`id`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "first_value" + ] + } + ], + "cost_info": { + "sort_cost": "9.00" + }, + "table": { + "table_name": "td1", + "access_type": "ALL", + "rows_examined_per_scan": 9, + "rows_produced_per_join": 9, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.90", + "prefix_cost": "1.15", + "data_read_per_join": "144" + }, + "used_columns": [ + "id" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`td1`.`id` AS `id`,first_value(`test`.`td1`.`id`) OVER `w` AS `FIRST_VALUE(id) OVER w` from `test`.`td1` window `w` AS (ORDER BY `test`.`td1`.`id` RANGE BETWEEN 2 PRECEDING AND CURRENT ROW) +EXPLAIN FORMAT=JSON SELECT id, FIRST_VALUE(id) OVER w FROM td1 WINDOW w AS (ORDER BY id ROWS BETWEEN 2 PRECEDING AND 1 PRECEDING); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "10.15" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`id`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "first_value" + ] + } + ], + "cost_info": { + "sort_cost": "9.00" + }, + "table": { + "table_name": "td1", + "access_type": "ALL", + "rows_examined_per_scan": 9, + "rows_produced_per_join": 9, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.90", + "prefix_cost": "1.15", + "data_read_per_join": "144" + }, + "used_columns": [ + "id" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`td1`.`id` AS `id`,first_value(`test`.`td1`.`id`) OVER `w` AS `FIRST_VALUE(id) OVER w` from `test`.`td1` window `w` AS (ORDER BY `test`.`td1`.`id` ROWS BETWEEN 2 PRECEDING AND 1 PRECEDING) +EXPLAIN FORMAT=JSON SELECT id, FIRST_VALUE(id) OVER w FROM td1 WINDOW w AS (ORDER BY id RANGE BETWEEN 2 PRECEDING AND 1 PRECEDING); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "10.15" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`id`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "first_value" + ] + } + ], + "cost_info": { + "sort_cost": "9.00" + }, + "table": { + "table_name": "td1", + "access_type": "ALL", + "rows_examined_per_scan": 9, + "rows_produced_per_join": 9, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.90", + "prefix_cost": "1.15", + "data_read_per_join": "144" + }, + "used_columns": [ + "id" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`td1`.`id` AS `id`,first_value(`test`.`td1`.`id`) OVER `w` AS `FIRST_VALUE(id) OVER w` from `test`.`td1` window `w` AS (ORDER BY `test`.`td1`.`id` RANGE BETWEEN 2 PRECEDING AND 1 PRECEDING) +EXPLAIN FORMAT=JSON SELECT id, FIRST_VALUE(id) OVER w FROM td1 WINDOW w AS (ORDER BY id ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "10.15" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`id`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "first_value" + ] + } + ], + "cost_info": { + "sort_cost": "9.00" + }, + "table": { + "table_name": "td1", + "access_type": "ALL", + "rows_examined_per_scan": 9, + "rows_produced_per_join": 9, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.90", + "prefix_cost": "1.15", + "data_read_per_join": "144" + }, + "used_columns": [ + "id" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`td1`.`id` AS `id`,first_value(`test`.`td1`.`id`) OVER `w` AS `FIRST_VALUE(id) OVER w` from `test`.`td1` window `w` AS (ORDER BY `test`.`td1`.`id` ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) +EXPLAIN FORMAT=JSON SELECT id, FIRST_VALUE(id) OVER w FROM td1 WINDOW w AS (ORDER BY id RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "10.15" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`id`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "first_value" + ] + } + ], + "cost_info": { + "sort_cost": "9.00" + }, + "table": { + "table_name": "td1", + "access_type": "ALL", + "rows_examined_per_scan": 9, + "rows_produced_per_join": 9, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.90", + "prefix_cost": "1.15", + "data_read_per_join": "144" + }, + "used_columns": [ + "id" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`td1`.`id` AS `id`,first_value(`test`.`td1`.`id`) OVER `w` AS `FIRST_VALUE(id) OVER w` from `test`.`td1` window `w` AS (ORDER BY `test`.`td1`.`id` RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) +EXPLAIN FORMAT=JSON SELECT id, FIRST_VALUE(id) OVER w FROM td1 WINDOW w AS (ORDER BY id ROWS BETWEEN 2 FOLLOWING AND 3 FOLLOWING); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "10.15" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`id`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "first_value" + ] + } + ], + "cost_info": { + "sort_cost": "9.00" + }, + "table": { + "table_name": "td1", + "access_type": "ALL", + "rows_examined_per_scan": 9, + "rows_produced_per_join": 9, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.90", + "prefix_cost": "1.15", + "data_read_per_join": "144" + }, + "used_columns": [ + "id" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`td1`.`id` AS `id`,first_value(`test`.`td1`.`id`) OVER `w` AS `FIRST_VALUE(id) OVER w` from `test`.`td1` window `w` AS (ORDER BY `test`.`td1`.`id` ROWS BETWEEN 2 FOLLOWING AND 3 FOLLOWING) +EXPLAIN FORMAT=JSON SELECT id, FIRST_VALUE(id) OVER w FROM td1 WINDOW w AS (ORDER BY id RANGE BETWEEN 2 FOLLOWING AND 3 FOLLOWING); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "10.15" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`id`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "first_value" + ] + } + ], + "cost_info": { + "sort_cost": "9.00" + }, + "table": { + "table_name": "td1", + "access_type": "ALL", + "rows_examined_per_scan": 9, + "rows_produced_per_join": 9, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.90", + "prefix_cost": "1.15", + "data_read_per_join": "144" + }, + "used_columns": [ + "id" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`td1`.`id` AS `id`,first_value(`test`.`td1`.`id`) OVER `w` AS `FIRST_VALUE(id) OVER w` from `test`.`td1` window `w` AS (ORDER BY `test`.`td1`.`id` RANGE BETWEEN 2 FOLLOWING AND 3 FOLLOWING) +DROP TABLE td1; +CREATE TABLE td_dec (id DECIMAL(10,2), sex CHAR(1)); +INSERT INTO td_dec SELECT * FROM t1; +ANALYZE TABLE td_dec; +Table Op Msg_type Msg_text +test.td_dec analyze status OK +EXPLAIN FORMAT=JSON SELECT id, FIRST_VALUE(id) OVER w FROM td_dec WINDOW w AS (); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.15" + }, + "windowing": { + "windows": [ + { + "name": "w", + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "first_value" + ] + } + ], + "table": { + "table_name": "td_dec", + "access_type": "ALL", + "rows_examined_per_scan": 9, + "rows_produced_per_join": 9, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.90", + "prefix_cost": "1.15", + "data_read_per_join": "144" + }, + "used_columns": [ + "id" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`td_dec`.`id` AS `id`,first_value(`test`.`td_dec`.`id`) OVER `w` AS `FIRST_VALUE(id) OVER w` from `test`.`td_dec` window `w` AS () +EXPLAIN FORMAT=JSON SELECT id, FIRST_VALUE(id) OVER w FROM td_dec WINDOW w AS (ORDER BY id); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "10.15" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`id`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "first_value" + ] + } + ], + "cost_info": { + "sort_cost": "9.00" + }, + "table": { + "table_name": "td_dec", + "access_type": "ALL", + "rows_examined_per_scan": 9, + "rows_produced_per_join": 9, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.90", + "prefix_cost": "1.15", + "data_read_per_join": "144" + }, + "used_columns": [ + "id" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`td_dec`.`id` AS `id`,first_value(`test`.`td_dec`.`id`) OVER `w` AS `FIRST_VALUE(id) OVER w` from `test`.`td_dec` window `w` AS (ORDER BY `test`.`td_dec`.`id` ) +EXPLAIN FORMAT=JSON SELECT id, FIRST_VALUE(id) OVER w FROM td_dec WINDOW w AS (PARTITION BY sex ORDER BY id); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "10.15" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`sex`", + "`id`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "first_value" + ] + } + ], + "cost_info": { + "sort_cost": "9.00" + }, + "table": { + "table_name": "td_dec", + "access_type": "ALL", + "rows_examined_per_scan": 9, + "rows_produced_per_join": 9, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.90", + "prefix_cost": "1.15", + "data_read_per_join": "144" + }, + "used_columns": [ + "id", + "sex" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`td_dec`.`id` AS `id`,first_value(`test`.`td_dec`.`id`) OVER `w` AS `FIRST_VALUE(id) OVER w` from `test`.`td_dec` window `w` AS (PARTITION BY `test`.`td_dec`.`sex` ORDER BY `test`.`td_dec`.`id` ) +EXPLAIN FORMAT=JSON SELECT id, FIRST_VALUE(id) OVER w FROM td_dec WINDOW w AS (ORDER BY id DESC); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "10.15" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`id` desc" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "first_value" + ] + } + ], + "cost_info": { + "sort_cost": "9.00" + }, + "table": { + "table_name": "td_dec", + "access_type": "ALL", + "rows_examined_per_scan": 9, + "rows_produced_per_join": 9, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.90", + "prefix_cost": "1.15", + "data_read_per_join": "144" + }, + "used_columns": [ + "id" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`td_dec`.`id` AS `id`,first_value(`test`.`td_dec`.`id`) OVER `w` AS `FIRST_VALUE(id) OVER w` from `test`.`td_dec` window `w` AS (ORDER BY `test`.`td_dec`.`id` desc ) +EXPLAIN FORMAT=JSON SELECT id, FIRST_VALUE(id) OVER w FROM td_dec WINDOW w AS (ORDER BY id ROWS 2 PRECEDING); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "10.15" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`id`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "first_value" + ] + } + ], + "cost_info": { + "sort_cost": "9.00" + }, + "table": { + "table_name": "td_dec", + "access_type": "ALL", + "rows_examined_per_scan": 9, + "rows_produced_per_join": 9, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.90", + "prefix_cost": "1.15", + "data_read_per_join": "144" + }, + "used_columns": [ + "id" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`td_dec`.`id` AS `id`,first_value(`test`.`td_dec`.`id`) OVER `w` AS `FIRST_VALUE(id) OVER w` from `test`.`td_dec` window `w` AS (ORDER BY `test`.`td_dec`.`id` ROWS BETWEEN 2 PRECEDING AND CURRENT ROW) +EXPLAIN FORMAT=JSON SELECT id, FIRST_VALUE(id) OVER w FROM td_dec WINDOW w AS (ORDER BY id RANGE 2 PRECEDING); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "10.15" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`id`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "first_value" + ] + } + ], + "cost_info": { + "sort_cost": "9.00" + }, + "table": { + "table_name": "td_dec", + "access_type": "ALL", + "rows_examined_per_scan": 9, + "rows_produced_per_join": 9, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.90", + "prefix_cost": "1.15", + "data_read_per_join": "144" + }, + "used_columns": [ + "id" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`td_dec`.`id` AS `id`,first_value(`test`.`td_dec`.`id`) OVER `w` AS `FIRST_VALUE(id) OVER w` from `test`.`td_dec` window `w` AS (ORDER BY `test`.`td_dec`.`id` RANGE BETWEEN 2 PRECEDING AND CURRENT ROW) +EXPLAIN FORMAT=JSON SELECT id, FIRST_VALUE(id) OVER w FROM td_dec WINDOW w AS (ORDER BY id ROWS BETWEEN 2 PRECEDING AND 1 PRECEDING); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "10.15" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`id`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "first_value" + ] + } + ], + "cost_info": { + "sort_cost": "9.00" + }, + "table": { + "table_name": "td_dec", + "access_type": "ALL", + "rows_examined_per_scan": 9, + "rows_produced_per_join": 9, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.90", + "prefix_cost": "1.15", + "data_read_per_join": "144" + }, + "used_columns": [ + "id" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`td_dec`.`id` AS `id`,first_value(`test`.`td_dec`.`id`) OVER `w` AS `FIRST_VALUE(id) OVER w` from `test`.`td_dec` window `w` AS (ORDER BY `test`.`td_dec`.`id` ROWS BETWEEN 2 PRECEDING AND 1 PRECEDING) +EXPLAIN FORMAT=JSON SELECT id, FIRST_VALUE(id) OVER w FROM td_dec WINDOW w AS (ORDER BY id RANGE BETWEEN 2 PRECEDING AND 1 PRECEDING); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "10.15" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`id`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "first_value" + ] + } + ], + "cost_info": { + "sort_cost": "9.00" + }, + "table": { + "table_name": "td_dec", + "access_type": "ALL", + "rows_examined_per_scan": 9, + "rows_produced_per_join": 9, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.90", + "prefix_cost": "1.15", + "data_read_per_join": "144" + }, + "used_columns": [ + "id" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`td_dec`.`id` AS `id`,first_value(`test`.`td_dec`.`id`) OVER `w` AS `FIRST_VALUE(id) OVER w` from `test`.`td_dec` window `w` AS (ORDER BY `test`.`td_dec`.`id` RANGE BETWEEN 2 PRECEDING AND 1 PRECEDING) +EXPLAIN FORMAT=JSON SELECT id, FIRST_VALUE(id) OVER w FROM td_dec WINDOW w AS (ORDER BY id ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "10.15" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`id`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "first_value" + ] + } + ], + "cost_info": { + "sort_cost": "9.00" + }, + "table": { + "table_name": "td_dec", + "access_type": "ALL", + "rows_examined_per_scan": 9, + "rows_produced_per_join": 9, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.90", + "prefix_cost": "1.15", + "data_read_per_join": "144" + }, + "used_columns": [ + "id" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`td_dec`.`id` AS `id`,first_value(`test`.`td_dec`.`id`) OVER `w` AS `FIRST_VALUE(id) OVER w` from `test`.`td_dec` window `w` AS (ORDER BY `test`.`td_dec`.`id` ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) +EXPLAIN FORMAT=JSON SELECT id, FIRST_VALUE(id) OVER w FROM td_dec WINDOW w AS (ORDER BY id RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "10.15" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`id`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "first_value" + ] + } + ], + "cost_info": { + "sort_cost": "9.00" + }, + "table": { + "table_name": "td_dec", + "access_type": "ALL", + "rows_examined_per_scan": 9, + "rows_produced_per_join": 9, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.90", + "prefix_cost": "1.15", + "data_read_per_join": "144" + }, + "used_columns": [ + "id" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`td_dec`.`id` AS `id`,first_value(`test`.`td_dec`.`id`) OVER `w` AS `FIRST_VALUE(id) OVER w` from `test`.`td_dec` window `w` AS (ORDER BY `test`.`td_dec`.`id` RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) +EXPLAIN FORMAT=JSON SELECT id, FIRST_VALUE(id) OVER w FROM td_dec WINDOW w AS (ORDER BY id ROWS BETWEEN 2 FOLLOWING AND 3 FOLLOWING); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "10.15" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`id`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "first_value" + ] + } + ], + "cost_info": { + "sort_cost": "9.00" + }, + "table": { + "table_name": "td_dec", + "access_type": "ALL", + "rows_examined_per_scan": 9, + "rows_produced_per_join": 9, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.90", + "prefix_cost": "1.15", + "data_read_per_join": "144" + }, + "used_columns": [ + "id" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`td_dec`.`id` AS `id`,first_value(`test`.`td_dec`.`id`) OVER `w` AS `FIRST_VALUE(id) OVER w` from `test`.`td_dec` window `w` AS (ORDER BY `test`.`td_dec`.`id` ROWS BETWEEN 2 FOLLOWING AND 3 FOLLOWING) +EXPLAIN FORMAT=JSON SELECT id, FIRST_VALUE(id) OVER w FROM td_dec WINDOW w AS (ORDER BY id RANGE BETWEEN 2 FOLLOWING AND 3 FOLLOWING); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "10.15" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`id`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "first_value" + ] + } + ], + "cost_info": { + "sort_cost": "9.00" + }, + "table": { + "table_name": "td_dec", + "access_type": "ALL", + "rows_examined_per_scan": 9, + "rows_produced_per_join": 9, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.90", + "prefix_cost": "1.15", + "data_read_per_join": "144" + }, + "used_columns": [ + "id" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`td_dec`.`id` AS `id`,first_value(`test`.`td_dec`.`id`) OVER `w` AS `FIRST_VALUE(id) OVER w` from `test`.`td_dec` window `w` AS (ORDER BY `test`.`td_dec`.`id` RANGE BETWEEN 2 FOLLOWING AND 3 FOLLOWING) +DROP TABLE td_dec; +CREATE TABLE td_str (id VARCHAR(20), sex CHAR(1)); +INSERT INTO td_str SELECT * FROM t1; +ANALYZE TABLE td_str; +Table Op Msg_type Msg_text +test.td_str analyze status OK +EXPLAIN FORMAT=JSON SELECT id, FIRST_VALUE(id) OVER w FROM td_str WINDOW w AS (); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.15" + }, + "windowing": { + "windows": [ + { + "name": "w", + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "first_value" + ] + } + ], + "table": { + "table_name": "td_str", + "access_type": "ALL", + "rows_examined_per_scan": 9, + "rows_produced_per_join": 9, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.90", + "prefix_cost": "1.15", + "data_read_per_join": "792" + }, + "used_columns": [ + "id" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`td_str`.`id` AS `id`,first_value(`test`.`td_str`.`id`) OVER `w` AS `FIRST_VALUE(id) OVER w` from `test`.`td_str` window `w` AS () +EXPLAIN FORMAT=JSON SELECT id, FIRST_VALUE(id) OVER w FROM td_str WINDOW w AS (ORDER BY id); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "10.15" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`id`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "first_value" + ] + } + ], + "cost_info": { + "sort_cost": "9.00" + }, + "table": { + "table_name": "td_str", + "access_type": "ALL", + "rows_examined_per_scan": 9, + "rows_produced_per_join": 9, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.90", + "prefix_cost": "1.15", + "data_read_per_join": "792" + }, + "used_columns": [ + "id" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`td_str`.`id` AS `id`,first_value(`test`.`td_str`.`id`) OVER `w` AS `FIRST_VALUE(id) OVER w` from `test`.`td_str` window `w` AS (ORDER BY `test`.`td_str`.`id` ) +EXPLAIN FORMAT=JSON SELECT id, FIRST_VALUE(id) OVER w FROM td_str WINDOW w AS (PARTITION BY sex ORDER BY id); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "10.15" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`sex`", + "`id`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "first_value" + ] + } + ], + "cost_info": { + "sort_cost": "9.00" + }, + "table": { + "table_name": "td_str", + "access_type": "ALL", + "rows_examined_per_scan": 9, + "rows_produced_per_join": 9, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.90", + "prefix_cost": "1.15", + "data_read_per_join": "792" + }, + "used_columns": [ + "id", + "sex" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`td_str`.`id` AS `id`,first_value(`test`.`td_str`.`id`) OVER `w` AS `FIRST_VALUE(id) OVER w` from `test`.`td_str` window `w` AS (PARTITION BY `test`.`td_str`.`sex` ORDER BY `test`.`td_str`.`id` ) +EXPLAIN FORMAT=JSON SELECT id, FIRST_VALUE(id) OVER w FROM td_str WINDOW w AS (ORDER BY id DESC); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "10.15" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`id` desc" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "first_value" + ] + } + ], + "cost_info": { + "sort_cost": "9.00" + }, + "table": { + "table_name": "td_str", + "access_type": "ALL", + "rows_examined_per_scan": 9, + "rows_produced_per_join": 9, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.90", + "prefix_cost": "1.15", + "data_read_per_join": "792" + }, + "used_columns": [ + "id" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`td_str`.`id` AS `id`,first_value(`test`.`td_str`.`id`) OVER `w` AS `FIRST_VALUE(id) OVER w` from `test`.`td_str` window `w` AS (ORDER BY `test`.`td_str`.`id` desc ) +EXPLAIN FORMAT=JSON SELECT id, FIRST_VALUE(id) OVER w FROM td_str WINDOW w AS (ORDER BY id ROWS 2 PRECEDING); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "10.15" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`id`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "first_value" + ] + } + ], + "cost_info": { + "sort_cost": "9.00" + }, + "table": { + "table_name": "td_str", + "access_type": "ALL", + "rows_examined_per_scan": 9, + "rows_produced_per_join": 9, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.90", + "prefix_cost": "1.15", + "data_read_per_join": "792" + }, + "used_columns": [ + "id" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`td_str`.`id` AS `id`,first_value(`test`.`td_str`.`id`) OVER `w` AS `FIRST_VALUE(id) OVER w` from `test`.`td_str` window `w` AS (ORDER BY `test`.`td_str`.`id` ROWS BETWEEN 2 PRECEDING AND CURRENT ROW) +EXPLAIN FORMAT=JSON SELECT id, FIRST_VALUE(id) OVER w FROM td_str WINDOW w AS (ORDER BY id ROWS BETWEEN 2 PRECEDING AND 1 PRECEDING); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "10.15" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`id`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "first_value" + ] + } + ], + "cost_info": { + "sort_cost": "9.00" + }, + "table": { + "table_name": "td_str", + "access_type": "ALL", + "rows_examined_per_scan": 9, + "rows_produced_per_join": 9, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.90", + "prefix_cost": "1.15", + "data_read_per_join": "792" + }, + "used_columns": [ + "id" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`td_str`.`id` AS `id`,first_value(`test`.`td_str`.`id`) OVER `w` AS `FIRST_VALUE(id) OVER w` from `test`.`td_str` window `w` AS (ORDER BY `test`.`td_str`.`id` ROWS BETWEEN 2 PRECEDING AND 1 PRECEDING) +EXPLAIN FORMAT=JSON SELECT id, FIRST_VALUE(id) OVER w FROM td_str WINDOW w AS (ORDER BY id ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "10.15" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`id`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "first_value" + ] + } + ], + "cost_info": { + "sort_cost": "9.00" + }, + "table": { + "table_name": "td_str", + "access_type": "ALL", + "rows_examined_per_scan": 9, + "rows_produced_per_join": 9, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.90", + "prefix_cost": "1.15", + "data_read_per_join": "792" + }, + "used_columns": [ + "id" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`td_str`.`id` AS `id`,first_value(`test`.`td_str`.`id`) OVER `w` AS `FIRST_VALUE(id) OVER w` from `test`.`td_str` window `w` AS (ORDER BY `test`.`td_str`.`id` ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) +EXPLAIN FORMAT=JSON SELECT id, FIRST_VALUE(id) OVER w FROM td_str WINDOW w AS (ORDER BY id ROWS BETWEEN 2 FOLLOWING AND 3 FOLLOWING); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "10.15" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`id`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "first_value" + ] + } + ], + "cost_info": { + "sort_cost": "9.00" + }, + "table": { + "table_name": "td_str", + "access_type": "ALL", + "rows_examined_per_scan": 9, + "rows_produced_per_join": 9, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.90", + "prefix_cost": "1.15", + "data_read_per_join": "792" + }, + "used_columns": [ + "id" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`td_str`.`id` AS `id`,first_value(`test`.`td_str`.`id`) OVER `w` AS `FIRST_VALUE(id) OVER w` from `test`.`td_str` window `w` AS (ORDER BY `test`.`td_str`.`id` ROWS BETWEEN 2 FOLLOWING AND 3 FOLLOWING) +DROP TABLE td_str; +CREATE TABLE t_date(id DATE); +INSERT INTO t_date VALUES ('2002-06-09'), +('2002-06-09'), +('2002-06-10'), +('2002-06-09'), +('2015-08-01'), +('2002-06-09'), +('2015-08-01'); +ANALYZE TABLE t_date; +Table Op Msg_type Msg_text +test.t_date analyze status OK +EXPLAIN FORMAT=JSON SELECT id, FIRST_VALUE(id) OVER w FROM t_date WINDOW w AS (); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.95" + }, + "windowing": { + "windows": [ + { + "name": "w", + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "first_value" + ] + } + ], + "table": { + "table_name": "t_date", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.70", + "prefix_cost": "0.95", + "data_read_per_join": "56" + }, + "used_columns": [ + "id" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t_date`.`id` AS `id`,first_value(`test`.`t_date`.`id`) OVER `w` AS `FIRST_VALUE(id) OVER w` from `test`.`t_date` window `w` AS () +EXPLAIN FORMAT=JSON SELECT id, FIRST_VALUE(id) OVER w FROM t_date WINDOW w AS (ORDER BY id); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "7.95" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`id`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "first_value" + ] + } + ], + "cost_info": { + "sort_cost": "7.00" + }, + "table": { + "table_name": "t_date", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.70", + "prefix_cost": "0.95", + "data_read_per_join": "56" + }, + "used_columns": [ + "id" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t_date`.`id` AS `id`,first_value(`test`.`t_date`.`id`) OVER `w` AS `FIRST_VALUE(id) OVER w` from `test`.`t_date` window `w` AS (ORDER BY `test`.`t_date`.`id` ) +EXPLAIN FORMAT=JSON SELECT id, FIRST_VALUE(id) OVER w FROM t_date WINDOW w AS (ORDER BY id DESC); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "7.95" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`id` desc" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "first_value" + ] + } + ], + "cost_info": { + "sort_cost": "7.00" + }, + "table": { + "table_name": "t_date", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.70", + "prefix_cost": "0.95", + "data_read_per_join": "56" + }, + "used_columns": [ + "id" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t_date`.`id` AS `id`,first_value(`test`.`t_date`.`id`) OVER `w` AS `FIRST_VALUE(id) OVER w` from `test`.`t_date` window `w` AS (ORDER BY `test`.`t_date`.`id` desc ) +EXPLAIN FORMAT=JSON SELECT id, FIRST_VALUE(id) OVER w FROM t_date WINDOW w AS (ORDER BY id ROWS 2 PRECEDING); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "7.95" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`id`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "first_value" + ] + } + ], + "cost_info": { + "sort_cost": "7.00" + }, + "table": { + "table_name": "t_date", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.70", + "prefix_cost": "0.95", + "data_read_per_join": "56" + }, + "used_columns": [ + "id" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t_date`.`id` AS `id`,first_value(`test`.`t_date`.`id`) OVER `w` AS `FIRST_VALUE(id) OVER w` from `test`.`t_date` window `w` AS (ORDER BY `test`.`t_date`.`id` ROWS BETWEEN 2 PRECEDING AND CURRENT ROW) +EXPLAIN FORMAT=JSON SELECT id, FIRST_VALUE(id) OVER w FROM t_date WINDOW w AS (ORDER BY id RANGE INTERVAL 2 DAY PRECEDING); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "7.95" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`id`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "first_value" + ] + } + ], + "cost_info": { + "sort_cost": "7.00" + }, + "table": { + "table_name": "t_date", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.70", + "prefix_cost": "0.95", + "data_read_per_join": "56" + }, + "used_columns": [ + "id" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t_date`.`id` AS `id`,first_value(`test`.`t_date`.`id`) OVER `w` AS `FIRST_VALUE(id) OVER w` from `test`.`t_date` window `w` AS (ORDER BY `test`.`t_date`.`id` RANGE BETWEEN INTERVAL 2 day PRECEDING AND CURRENT ROW) +EXPLAIN FORMAT=JSON SELECT id, FIRST_VALUE(id) OVER w FROM t_date WINDOW w AS (ORDER BY id ROWS BETWEEN 2 PRECEDING AND 1 PRECEDING); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "7.95" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`id`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "first_value" + ] + } + ], + "cost_info": { + "sort_cost": "7.00" + }, + "table": { + "table_name": "t_date", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.70", + "prefix_cost": "0.95", + "data_read_per_join": "56" + }, + "used_columns": [ + "id" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t_date`.`id` AS `id`,first_value(`test`.`t_date`.`id`) OVER `w` AS `FIRST_VALUE(id) OVER w` from `test`.`t_date` window `w` AS (ORDER BY `test`.`t_date`.`id` ROWS BETWEEN 2 PRECEDING AND 1 PRECEDING) +EXPLAIN FORMAT=JSON SELECT id, FIRST_VALUE(id) OVER w FROM t_date WINDOW w AS (ORDER BY id RANGE BETWEEN INTERVAL 2 DAY PRECEDING AND INTERVAL 1 DAY PRECEDING); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "7.95" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`id`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "first_value" + ] + } + ], + "cost_info": { + "sort_cost": "7.00" + }, + "table": { + "table_name": "t_date", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.70", + "prefix_cost": "0.95", + "data_read_per_join": "56" + }, + "used_columns": [ + "id" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t_date`.`id` AS `id`,first_value(`test`.`t_date`.`id`) OVER `w` AS `FIRST_VALUE(id) OVER w` from `test`.`t_date` window `w` AS (ORDER BY `test`.`t_date`.`id` RANGE BETWEEN INTERVAL 2 day PRECEDING AND INTERVAL 1 day PRECEDING) +EXPLAIN FORMAT=JSON SELECT id, FIRST_VALUE(id) OVER w FROM t_date WINDOW w AS (ORDER BY id ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "7.95" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`id`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "first_value" + ] + } + ], + "cost_info": { + "sort_cost": "7.00" + }, + "table": { + "table_name": "t_date", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.70", + "prefix_cost": "0.95", + "data_read_per_join": "56" + }, + "used_columns": [ + "id" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t_date`.`id` AS `id`,first_value(`test`.`t_date`.`id`) OVER `w` AS `FIRST_VALUE(id) OVER w` from `test`.`t_date` window `w` AS (ORDER BY `test`.`t_date`.`id` ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) +EXPLAIN FORMAT=JSON SELECT id, FIRST_VALUE(id) OVER w FROM t_date WINDOW w AS (ORDER BY id RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "7.95" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`id`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "first_value" + ] + } + ], + "cost_info": { + "sort_cost": "7.00" + }, + "table": { + "table_name": "t_date", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.70", + "prefix_cost": "0.95", + "data_read_per_join": "56" + }, + "used_columns": [ + "id" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t_date`.`id` AS `id`,first_value(`test`.`t_date`.`id`) OVER `w` AS `FIRST_VALUE(id) OVER w` from `test`.`t_date` window `w` AS (ORDER BY `test`.`t_date`.`id` RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) +CREATE VIEW v AS +SELECT id, FIRST_VALUE(id) OVER w FROM t_date WINDOW w AS (ORDER BY id RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING); +SHOW CREATE VIEW v; +View Create View character_set_client collation_connection +v CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v` AS select `t_date`.`id` AS `id`,first_value(`t_date`.`id`) OVER `w` AS `FIRST_VALUE(id) OVER w` from `t_date` window `w` AS (ORDER BY `t_date`.`id` RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) utf8 utf8_general_ci +EXPLAIN FORMAT=JSON SELECT * FROM v; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "3.29" + }, + "table": { + "table_name": "v", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "2.59", + "eval_cost": "0.70", + "prefix_cost": "3.29", + "data_read_per_join": "112" + }, + "used_columns": [ + "id", + "FIRST_VALUE(id) OVER w" + ], + "materialized_from_subquery": { + "using_temporary_table": true, + "dependent": false, + "cacheable": true, + "query_block": { + "select_id": 2, + "cost_info": { + "query_cost": "7.95" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`id`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "first_value" + ] + } + ], + "cost_info": { + "sort_cost": "7.00" + }, + "table": { + "table_name": "t_date", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.70", + "prefix_cost": "0.95", + "data_read_per_join": "56" + }, + "used_columns": [ + "id" + ] + } + } + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`v`.`id` AS `id`,`test`.`v`.`FIRST_VALUE(id) OVER w` AS `FIRST_VALUE(id) OVER w` from `test`.`v` +DROP VIEW v; +EXPLAIN FORMAT=JSON SELECT id, FIRST_VALUE(id) OVER w FROM t_date WINDOW w AS (ORDER BY id ROWS BETWEEN 2 FOLLOWING AND 3 FOLLOWING); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "7.95" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`id`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "first_value" + ] + } + ], + "cost_info": { + "sort_cost": "7.00" + }, + "table": { + "table_name": "t_date", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.70", + "prefix_cost": "0.95", + "data_read_per_join": "56" + }, + "used_columns": [ + "id" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t_date`.`id` AS `id`,first_value(`test`.`t_date`.`id`) OVER `w` AS `FIRST_VALUE(id) OVER w` from `test`.`t_date` window `w` AS (ORDER BY `test`.`t_date`.`id` ROWS BETWEEN 2 FOLLOWING AND 3 FOLLOWING) +EXPLAIN FORMAT=JSON SELECT id, FIRST_VALUE(id) OVER w FROM t_date WINDOW w AS (ORDER BY id RANGE BETWEEN INTERVAL 2 DAY FOLLOWING AND INTERVAL 3 DAY FOLLOWING); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "7.95" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`id`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "first_value" + ] + } + ], + "cost_info": { + "sort_cost": "7.00" + }, + "table": { + "table_name": "t_date", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.70", + "prefix_cost": "0.95", + "data_read_per_join": "56" + }, + "used_columns": [ + "id" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t_date`.`id` AS `id`,first_value(`test`.`t_date`.`id`) OVER `w` AS `FIRST_VALUE(id) OVER w` from `test`.`t_date` window `w` AS (ORDER BY `test`.`t_date`.`id` RANGE BETWEEN INTERVAL 2 day FOLLOWING AND INTERVAL 3 day FOLLOWING) +CREATE VIEW v AS +SELECT id, FIRST_VALUE(id) OVER w FROM t_date WINDOW w AS (ORDER BY id RANGE BETWEEN INTERVAL 2 DAY FOLLOWING AND INTERVAL 3 DAY FOLLOWING); +SHOW CREATE VIEW v; +View Create View character_set_client collation_connection +v CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v` AS select `t_date`.`id` AS `id`,first_value(`t_date`.`id`) OVER `w` AS `FIRST_VALUE(id) OVER w` from `t_date` window `w` AS (ORDER BY `t_date`.`id` RANGE BETWEEN INTERVAL 2 day FOLLOWING AND INTERVAL 3 day FOLLOWING) utf8 utf8_general_ci +EXPLAIN FORMAT=JSON SELECT * FROM v; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "3.29" + }, + "table": { + "table_name": "v", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "2.59", + "eval_cost": "0.70", + "prefix_cost": "3.29", + "data_read_per_join": "112" + }, + "used_columns": [ + "id", + "FIRST_VALUE(id) OVER w" + ], + "materialized_from_subquery": { + "using_temporary_table": true, + "dependent": false, + "cacheable": true, + "query_block": { + "select_id": 2, + "cost_info": { + "query_cost": "7.95" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`id`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "first_value" + ] + } + ], + "cost_info": { + "sort_cost": "7.00" + }, + "table": { + "table_name": "t_date", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.70", + "prefix_cost": "0.95", + "data_read_per_join": "56" + }, + "used_columns": [ + "id" + ] + } + } + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`v`.`id` AS `id`,`test`.`v`.`FIRST_VALUE(id) OVER w` AS `FIRST_VALUE(id) OVER w` from `test`.`v` +DROP VIEW v; +DROP TABLE t_date; +CREATE TABLE t_time(t TIME, ts TIMESTAMP); +INSERT INTO t_time VALUES ('12:30', '2016-07-05 08:30:42'); +INSERT INTO t_time VALUES ('22:30', '2015-07-05 08:30:43'); +INSERT INTO t_time VALUES ('13:30', '2014-07-05 08:30:44'); +INSERT INTO t_time VALUES ('01:30', '2013-07-05 08:30:45'); +INSERT INTO t_time VALUES ('15:30', '2016-08-05 08:31:42'); +INSERT INTO t_time VALUES ('20:30', '2016-09-05 08:32:42'); +INSERT INTO t_time VALUES ('04:30', '2016-10-05 08:33:42'); +INSERT INTO t_time VALUES ('06:30', '2016-11-05 08:34:42'); +INSERT INTO t_time VALUES ('18:30', '2016-07-05 09:30:42'); +INSERT INTO t_time VALUES ('21:30', '2016-07-06 10:30:42'); +INSERT INTO t_time VALUES ('00:30', '2016-07-07 11:30:42'); +INSERT INTO t_time VALUES ('00:31', '2016-07-08 12:30:42'); +ANALYZE TABLE t_time; +Table Op Msg_type Msg_text +test.t_time analyze status OK +CREATE TABLE t_time2(t TIME, ts TIMESTAMP, p INTEGER DEFAULT 1); +INSERT INTO t_time2(t, ts) SELECT * FROM t_time; +UPDATE t_time2 SET p=p+1; +INSERT INTO t_time2(t, ts) SELECT * FROM t_time; +ANALYZE TABLE t_time2; +Table Op Msg_type Msg_text +test.t_time2 analyze status OK +EXPLAIN FORMAT=JSON SELECT t, FIRST_VALUE(t) OVER w FROM t_time WINDOW w AS (); +EXPLAIN + "first_value" + "optimized_frame_evaluation": true + "using_temporary_table": true, + "data_read_per_join": "192" + "eval_cost": "1.20", + "frame_buffer": { + "functions": [ + "name": "w", + "prefix_cost": "1.45", + "read_cost": "0.25", + "t" + ] + }, + "access_type": "ALL", + "cost_info": { + "filtered": "100.00", + "rows_examined_per_scan": 12, + "rows_produced_per_join": 12, + "table_name": "t_time", + "used_columns": [ + ] + { + } + }, + "query_cost": "1.45" + "table": { + "windows": [ + ], + } + "cost_info": { + "select_id": 1, + "windowing": { + } + }, + "query_block": { + } +Note 1003 /* select#1 */ select `test`.`t_time`.`t` AS `t`,first_value(`test`.`t_time`.`t`) OVER `w` AS `FIRST_VALUE(t) OVER w` from `test`.`t_time` window `w` AS () +Warnings: +{ +} +EXPLAIN FORMAT=JSON SELECT t, FIRST_VALUE(t) OVER w FROM t_time WINDOW w AS (ORDER BY t); +EXPLAIN + "`t`" + "first_value" + "optimized_frame_evaluation": true + "using_temporary_table": true, + "data_read_per_join": "192" + "eval_cost": "1.20", + "filesort_key": [ + "frame_buffer": { + "functions": [ + "name": "w", + "prefix_cost": "1.45", + "read_cost": "0.25", + "t" + "using_filesort": true, + ] + ], + }, + "access_type": "ALL", + "cost_info": { + "filtered": "100.00", + "rows_examined_per_scan": 12, + "rows_produced_per_join": 12, + "sort_cost": "12.00" + "table_name": "t_time", + "used_columns": [ + ] + { + } + }, + "cost_info": { + "query_cost": "13.45" + "table": { + "windows": [ + ], + } + }, + "cost_info": { + "select_id": 1, + "windowing": { + } + }, + "query_block": { + } +Note 1003 /* select#1 */ select `test`.`t_time`.`t` AS `t`,first_value(`test`.`t_time`.`t`) OVER `w` AS `FIRST_VALUE(t) OVER w` from `test`.`t_time` window `w` AS (ORDER BY `test`.`t_time`.`t` ) +Warnings: +{ +} +EXPLAIN FORMAT=JSON SELECT t, FIRST_VALUE(t) OVER w FROM t_time WINDOW w AS (ORDER BY t DESC); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "13.45" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`t` desc" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "first_value" + ] + } + ], + "cost_info": { + "sort_cost": "12.00" + }, + "table": { + "table_name": "t_time", + "access_type": "ALL", + "rows_examined_per_scan": 12, + "rows_produced_per_join": 12, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "1.20", + "prefix_cost": "1.45", + "data_read_per_join": "192" + }, + "used_columns": [ + "t" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t_time`.`t` AS `t`,first_value(`test`.`t_time`.`t`) OVER `w` AS `FIRST_VALUE(t) OVER w` from `test`.`t_time` window `w` AS (ORDER BY `test`.`t_time`.`t` desc ) +EXPLAIN FORMAT=JSON SELECT t, FIRST_VALUE(t) OVER w FROM t_time WINDOW w AS (ORDER BY t ROWS 2 PRECEDING); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "13.45" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`t`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "first_value" + ] + } + ], + "cost_info": { + "sort_cost": "12.00" + }, + "table": { + "table_name": "t_time", + "access_type": "ALL", + "rows_examined_per_scan": 12, + "rows_produced_per_join": 12, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "1.20", + "prefix_cost": "1.45", + "data_read_per_join": "192" + }, + "used_columns": [ + "t" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t_time`.`t` AS `t`,first_value(`test`.`t_time`.`t`) OVER `w` AS `FIRST_VALUE(t) OVER w` from `test`.`t_time` window `w` AS (ORDER BY `test`.`t_time`.`t` ROWS BETWEEN 2 PRECEDING AND CURRENT ROW) +EXPLAIN FORMAT=JSON SELECT t, FIRST_VALUE(t) OVER w FROM t_time WINDOW w AS (ORDER BY t RANGE INTERVAL 2 HOUR PRECEDING); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "13.45" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`t`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "first_value" + ] + } + ], + "cost_info": { + "sort_cost": "12.00" + }, + "table": { + "table_name": "t_time", + "access_type": "ALL", + "rows_examined_per_scan": 12, + "rows_produced_per_join": 12, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "1.20", + "prefix_cost": "1.45", + "data_read_per_join": "192" + }, + "used_columns": [ + "t" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t_time`.`t` AS `t`,first_value(`test`.`t_time`.`t`) OVER `w` AS `FIRST_VALUE(t) OVER w` from `test`.`t_time` window `w` AS (ORDER BY `test`.`t_time`.`t` RANGE BETWEEN INTERVAL 2 hour PRECEDING AND CURRENT ROW) +EXPLAIN FORMAT=JSON SELECT t, FIRST_VALUE(t) OVER w FROM t_time WINDOW w AS (ORDER BY t ROWS BETWEEN 2 PRECEDING AND 1 PRECEDING); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "13.45" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`t`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "first_value" + ] + } + ], + "cost_info": { + "sort_cost": "12.00" + }, + "table": { + "table_name": "t_time", + "access_type": "ALL", + "rows_examined_per_scan": 12, + "rows_produced_per_join": 12, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "1.20", + "prefix_cost": "1.45", + "data_read_per_join": "192" + }, + "used_columns": [ + "t" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t_time`.`t` AS `t`,first_value(`test`.`t_time`.`t`) OVER `w` AS `FIRST_VALUE(t) OVER w` from `test`.`t_time` window `w` AS (ORDER BY `test`.`t_time`.`t` ROWS BETWEEN 2 PRECEDING AND 1 PRECEDING) +EXPLAIN FORMAT=JSON SELECT t, FIRST_VALUE(t) OVER w FROM t_time WINDOW w AS (ORDER BY t RANGE BETWEEN INTERVAL 2 HOUR PRECEDING AND INTERVAL 1 HOUR PRECEDING); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "13.45" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`t`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "first_value" + ] + } + ], + "cost_info": { + "sort_cost": "12.00" + }, + "table": { + "table_name": "t_time", + "access_type": "ALL", + "rows_examined_per_scan": 12, + "rows_produced_per_join": 12, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "1.20", + "prefix_cost": "1.45", + "data_read_per_join": "192" + }, + "used_columns": [ + "t" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t_time`.`t` AS `t`,first_value(`test`.`t_time`.`t`) OVER `w` AS `FIRST_VALUE(t) OVER w` from `test`.`t_time` window `w` AS (ORDER BY `test`.`t_time`.`t` RANGE BETWEEN INTERVAL 2 hour PRECEDING AND INTERVAL 1 hour PRECEDING) +EXPLAIN FORMAT=JSON SELECT t, FIRST_VALUE(t) OVER w FROM t_time WINDOW w AS (ORDER BY t ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "13.45" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`t`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "first_value" + ] + } + ], + "cost_info": { + "sort_cost": "12.00" + }, + "table": { + "table_name": "t_time", + "access_type": "ALL", + "rows_examined_per_scan": 12, + "rows_produced_per_join": 12, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "1.20", + "prefix_cost": "1.45", + "data_read_per_join": "192" + }, + "used_columns": [ + "t" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t_time`.`t` AS `t`,first_value(`test`.`t_time`.`t`) OVER `w` AS `FIRST_VALUE(t) OVER w` from `test`.`t_time` window `w` AS (ORDER BY `test`.`t_time`.`t` ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) +EXPLAIN FORMAT=JSON SELECT t, FIRST_VALUE(t) OVER w FROM t_time WINDOW w AS (ORDER BY t RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "13.45" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`t`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "first_value" + ] + } + ], + "cost_info": { + "sort_cost": "12.00" + }, + "table": { + "table_name": "t_time", + "access_type": "ALL", + "rows_examined_per_scan": 12, + "rows_produced_per_join": 12, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "1.20", + "prefix_cost": "1.45", + "data_read_per_join": "192" + }, + "used_columns": [ + "t" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t_time`.`t` AS `t`,first_value(`test`.`t_time`.`t`) OVER `w` AS `FIRST_VALUE(t) OVER w` from `test`.`t_time` window `w` AS (ORDER BY `test`.`t_time`.`t` RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) +EXPLAIN FORMAT=JSON SELECT t, FIRST_VALUE(t) OVER w FROM t_time WINDOW w AS (ORDER BY t ROWS BETWEEN 2 FOLLOWING AND 3 FOLLOWING); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "13.45" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`t`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "first_value" + ] + } + ], + "cost_info": { + "sort_cost": "12.00" + }, + "table": { + "table_name": "t_time", + "access_type": "ALL", + "rows_examined_per_scan": 12, + "rows_produced_per_join": 12, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "1.20", + "prefix_cost": "1.45", + "data_read_per_join": "192" + }, + "used_columns": [ + "t" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t_time`.`t` AS `t`,first_value(`test`.`t_time`.`t`) OVER `w` AS `FIRST_VALUE(t) OVER w` from `test`.`t_time` window `w` AS (ORDER BY `test`.`t_time`.`t` ROWS BETWEEN 2 FOLLOWING AND 3 FOLLOWING) +EXPLAIN FORMAT=JSON SELECT t, FIRST_VALUE(t) OVER w FROM t_time WINDOW w AS (ORDER BY t RANGE BETWEEN INTERVAL 2 HOUR FOLLOWING AND INTERVAL 3 HOUR FOLLOWING); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "13.45" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`t`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "first_value" + ] + } + ], + "cost_info": { + "sort_cost": "12.00" + }, + "table": { + "table_name": "t_time", + "access_type": "ALL", + "rows_examined_per_scan": 12, + "rows_produced_per_join": 12, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "1.20", + "prefix_cost": "1.45", + "data_read_per_join": "192" + }, + "used_columns": [ + "t" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t_time`.`t` AS `t`,first_value(`test`.`t_time`.`t`) OVER `w` AS `FIRST_VALUE(t) OVER w` from `test`.`t_time` window `w` AS (ORDER BY `test`.`t_time`.`t` RANGE BETWEEN INTERVAL 2 hour FOLLOWING AND INTERVAL 3 hour FOLLOWING) +EXPLAIN FORMAT=JSON SELECT p, t, FIRST_VALUE(t) OVER w FROM t_time2 WINDOW w AS (PARTITION by p ORDER BY t); +EXPLAIN + "`p`", + "`t`" + "first_value" + "optimized_frame_evaluation": true + "using_temporary_table": true, + "data_read_per_join": "384" + "eval_cost": "2.40", + "filesort_key": [ + "frame_buffer": { + "functions": [ + "name": "w", + "p" + "prefix_cost": "2.65", + "read_cost": "0.25", + "t", + "using_filesort": true, + ] + ], + }, + "access_type": "ALL", + "cost_info": { + "filtered": "100.00", + "rows_examined_per_scan": 24, + "rows_produced_per_join": 24, + "sort_cost": "24.00" + "table_name": "t_time2", + "used_columns": [ + ] + { + } + }, + "cost_info": { + "query_cost": "26.65" + "table": { + "windows": [ + ], + } + }, + "cost_info": { + "select_id": 1, + "windowing": { + } + }, + "query_block": { + } +Note 1003 /* select#1 */ select `test`.`t_time2`.`p` AS `p`,`test`.`t_time2`.`t` AS `t`,first_value(`test`.`t_time2`.`t`) OVER `w` AS `FIRST_VALUE(t) OVER w` from `test`.`t_time2` window `w` AS (PARTITION BY `test`.`t_time2`.`p` ORDER BY `test`.`t_time2`.`t` ) +Warnings: +{ +} +EXPLAIN FORMAT=JSON SELECT p, t, FIRST_VALUE(t) OVER w FROM t_time2 WINDOW w AS (PARTITION by p ORDER BY t DESC); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "26.65" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`p`", + "`t` desc" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "first_value" + ] + } + ], + "cost_info": { + "sort_cost": "24.00" + }, + "table": { + "table_name": "t_time2", + "access_type": "ALL", + "rows_examined_per_scan": 24, + "rows_produced_per_join": 24, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "2.40", + "prefix_cost": "2.65", + "data_read_per_join": "384" + }, + "used_columns": [ + "t", + "p" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t_time2`.`p` AS `p`,`test`.`t_time2`.`t` AS `t`,first_value(`test`.`t_time2`.`t`) OVER `w` AS `FIRST_VALUE(t) OVER w` from `test`.`t_time2` window `w` AS (PARTITION BY `test`.`t_time2`.`p` ORDER BY `test`.`t_time2`.`t` desc ) +EXPLAIN FORMAT=JSON SELECT p, t, FIRST_VALUE(t) OVER w FROM t_time2 WINDOW w AS (PARTITION by p ORDER BY t ROWS 2 PRECEDING); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "26.65" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`p`", + "`t`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "first_value" + ] + } + ], + "cost_info": { + "sort_cost": "24.00" + }, + "table": { + "table_name": "t_time2", + "access_type": "ALL", + "rows_examined_per_scan": 24, + "rows_produced_per_join": 24, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "2.40", + "prefix_cost": "2.65", + "data_read_per_join": "384" + }, + "used_columns": [ + "t", + "p" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t_time2`.`p` AS `p`,`test`.`t_time2`.`t` AS `t`,first_value(`test`.`t_time2`.`t`) OVER `w` AS `FIRST_VALUE(t) OVER w` from `test`.`t_time2` window `w` AS (PARTITION BY `test`.`t_time2`.`p` ORDER BY `test`.`t_time2`.`t` ROWS BETWEEN 2 PRECEDING AND CURRENT ROW) +EXPLAIN FORMAT=JSON SELECT p, t, FIRST_VALUE(t) OVER w FROM t_time2 WINDOW w AS (PARTITION by p ORDER BY t RANGE INTERVAL 2 HOUR PRECEDING); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "26.65" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`p`", + "`t`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "first_value" + ] + } + ], + "cost_info": { + "sort_cost": "24.00" + }, + "table": { + "table_name": "t_time2", + "access_type": "ALL", + "rows_examined_per_scan": 24, + "rows_produced_per_join": 24, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "2.40", + "prefix_cost": "2.65", + "data_read_per_join": "384" + }, + "used_columns": [ + "t", + "p" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t_time2`.`p` AS `p`,`test`.`t_time2`.`t` AS `t`,first_value(`test`.`t_time2`.`t`) OVER `w` AS `FIRST_VALUE(t) OVER w` from `test`.`t_time2` window `w` AS (PARTITION BY `test`.`t_time2`.`p` ORDER BY `test`.`t_time2`.`t` RANGE BETWEEN INTERVAL 2 hour PRECEDING AND CURRENT ROW) +EXPLAIN FORMAT=JSON SELECT p, t, FIRST_VALUE(t) OVER w FROM t_time2 WINDOW w AS (PARTITION by p ORDER BY t ROWS BETWEEN 2 PRECEDING AND 1 PRECEDING); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "26.65" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`p`", + "`t`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "first_value" + ] + } + ], + "cost_info": { + "sort_cost": "24.00" + }, + "table": { + "table_name": "t_time2", + "access_type": "ALL", + "rows_examined_per_scan": 24, + "rows_produced_per_join": 24, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "2.40", + "prefix_cost": "2.65", + "data_read_per_join": "384" + }, + "used_columns": [ + "t", + "p" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t_time2`.`p` AS `p`,`test`.`t_time2`.`t` AS `t`,first_value(`test`.`t_time2`.`t`) OVER `w` AS `FIRST_VALUE(t) OVER w` from `test`.`t_time2` window `w` AS (PARTITION BY `test`.`t_time2`.`p` ORDER BY `test`.`t_time2`.`t` ROWS BETWEEN 2 PRECEDING AND 1 PRECEDING) +EXPLAIN FORMAT=JSON SELECT p, t, FIRST_VALUE(t) OVER w FROM t_time2 WINDOW w AS (PARTITION by p ORDER BY t RANGE BETWEEN INTERVAL 2 HOUR PRECEDING AND INTERVAL 1 HOUR PRECEDING); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "26.65" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`p`", + "`t`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "first_value" + ] + } + ], + "cost_info": { + "sort_cost": "24.00" + }, + "table": { + "table_name": "t_time2", + "access_type": "ALL", + "rows_examined_per_scan": 24, + "rows_produced_per_join": 24, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "2.40", + "prefix_cost": "2.65", + "data_read_per_join": "384" + }, + "used_columns": [ + "t", + "p" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t_time2`.`p` AS `p`,`test`.`t_time2`.`t` AS `t`,first_value(`test`.`t_time2`.`t`) OVER `w` AS `FIRST_VALUE(t) OVER w` from `test`.`t_time2` window `w` AS (PARTITION BY `test`.`t_time2`.`p` ORDER BY `test`.`t_time2`.`t` RANGE BETWEEN INTERVAL 2 hour PRECEDING AND INTERVAL 1 hour PRECEDING) +EXPLAIN FORMAT=JSON SELECT p, t, FIRST_VALUE(t) OVER w FROM t_time2 WINDOW w AS (PARTITION by p ORDER BY t ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "26.65" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`p`", + "`t`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "first_value" + ] + } + ], + "cost_info": { + "sort_cost": "24.00" + }, + "table": { + "table_name": "t_time2", + "access_type": "ALL", + "rows_examined_per_scan": 24, + "rows_produced_per_join": 24, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "2.40", + "prefix_cost": "2.65", + "data_read_per_join": "384" + }, + "used_columns": [ + "t", + "p" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t_time2`.`p` AS `p`,`test`.`t_time2`.`t` AS `t`,first_value(`test`.`t_time2`.`t`) OVER `w` AS `FIRST_VALUE(t) OVER w` from `test`.`t_time2` window `w` AS (PARTITION BY `test`.`t_time2`.`p` ORDER BY `test`.`t_time2`.`t` ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) +EXPLAIN FORMAT=JSON SELECT p, t, FIRST_VALUE(t) OVER w FROM t_time2 WINDOW w AS (PARTITION by p ORDER BY t RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "26.65" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`p`", + "`t`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "first_value" + ] + } + ], + "cost_info": { + "sort_cost": "24.00" + }, + "table": { + "table_name": "t_time2", + "access_type": "ALL", + "rows_examined_per_scan": 24, + "rows_produced_per_join": 24, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "2.40", + "prefix_cost": "2.65", + "data_read_per_join": "384" + }, + "used_columns": [ + "t", + "p" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t_time2`.`p` AS `p`,`test`.`t_time2`.`t` AS `t`,first_value(`test`.`t_time2`.`t`) OVER `w` AS `FIRST_VALUE(t) OVER w` from `test`.`t_time2` window `w` AS (PARTITION BY `test`.`t_time2`.`p` ORDER BY `test`.`t_time2`.`t` RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) +EXPLAIN FORMAT=JSON SELECT p, t, FIRST_VALUE(t) OVER w FROM t_time2 WINDOW w AS (PARTITION by p ORDER BY t ROWS BETWEEN 2 FOLLOWING AND 3 FOLLOWING); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "26.65" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`p`", + "`t`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "first_value" + ] + } + ], + "cost_info": { + "sort_cost": "24.00" + }, + "table": { + "table_name": "t_time2", + "access_type": "ALL", + "rows_examined_per_scan": 24, + "rows_produced_per_join": 24, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "2.40", + "prefix_cost": "2.65", + "data_read_per_join": "384" + }, + "used_columns": [ + "t", + "p" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t_time2`.`p` AS `p`,`test`.`t_time2`.`t` AS `t`,first_value(`test`.`t_time2`.`t`) OVER `w` AS `FIRST_VALUE(t) OVER w` from `test`.`t_time2` window `w` AS (PARTITION BY `test`.`t_time2`.`p` ORDER BY `test`.`t_time2`.`t` ROWS BETWEEN 2 FOLLOWING AND 3 FOLLOWING) +EXPLAIN FORMAT=JSON SELECT p, t, FIRST_VALUE(t) OVER w FROM t_time2 WINDOW w AS (PARTITION by p ORDER BY t RANGE BETWEEN INTERVAL 2 HOUR FOLLOWING AND INTERVAL 3 HOUR FOLLOWING); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "26.65" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`p`", + "`t`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "first_value" + ] + } + ], + "cost_info": { + "sort_cost": "24.00" + }, + "table": { + "table_name": "t_time2", + "access_type": "ALL", + "rows_examined_per_scan": 24, + "rows_produced_per_join": 24, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "2.40", + "prefix_cost": "2.65", + "data_read_per_join": "384" + }, + "used_columns": [ + "t", + "p" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t_time2`.`p` AS `p`,`test`.`t_time2`.`t` AS `t`,first_value(`test`.`t_time2`.`t`) OVER `w` AS `FIRST_VALUE(t) OVER w` from `test`.`t_time2` window `w` AS (PARTITION BY `test`.`t_time2`.`p` ORDER BY `test`.`t_time2`.`t` RANGE BETWEEN INTERVAL 2 hour FOLLOWING AND INTERVAL 3 hour FOLLOWING) +DROP TABLE t_time, t_time2; +---------------------------------------------------------------------- +- Aggregates with RANGE frame specification +---------------------------------------------------------------------- +EXPLAIN FORMAT=JSON SELECT * FROM t1; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.15" + }, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 9, + "rows_produced_per_join": 9, + "filtered": "100.00", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.90", + "prefix_cost": "1.15", + "data_read_per_join": "144" + }, + "used_columns": [ + "id", + "sex" + ], + "query_block": { + "cost_info": { + "query_cost": "1.15" + }, + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 9, + "rows_produced_per_join": 9, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.90", + "prefix_cost": "1.15", + "data_read_per_join": "144" + }, + "used_columns": [ + "id", + "sex" + ] + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,`test`.`t1`.`sex` AS `sex` from `test`.`t1` +Make t11 a clone of t1 but with an extra partitioning column, but other values +repeated, so we can test it the same frames work on more than one partition +CREATE TABLE t11 (id INTEGER, sex CHAR(1), p INTEGER DEFAULT 1); +INSERT INTO t11(id, sex) SELECT * FROM t1; +UPDATE t11 SET p=p+1; +INSERT INTO t11(id, sex) SELECT * FROM t1; +ANALYZE TABLE t11; +Table Op Msg_type Msg_text +test.t11 analyze status OK +Make t22 a clone of t2 but with an extra partitioning column, but other values +repeated, so we can test it the same frames work on more than one partition +CREATE TABLE t22 (user_id INTEGER NOT NULL, date DATE, p INTEGER DEFAULT 1); +INSERT INTO t22(user_id, date) SELECT * FROM t2; +UPDATE t22 SET p=p+1; +INSERT INTO t22(user_id, date) SELECT * FROM t2; +ANALYZE TABLE t22; +Table Op Msg_type Msg_text +test.t22 analyze status OK +EXPLAIN FORMAT=JSON SELECT id, SUM(id) OVER (ORDER BY id RANGE 2 PRECEDING) FROM t1 ORDER BY id; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "19.15" + }, + "ordering_operation": { + "using_filesort": true, + "cost_info": { + "sort_cost": "9.00" + }, + "windowing": { + "windows": [ + { + "name": "", + "using_temporary_table": true, + "using_filesort": true, + "filesort_key": [ + "`id`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "sum" + ] + } + ], + "cost_info": { + "sort_cost": "9.00" + }, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 9, + "rows_produced_per_join": 9, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.90", + "prefix_cost": "1.15", + "data_read_per_join": "144" + }, + "used_columns": [ + "id" + ] + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,sum(`test`.`t1`.`id`) OVER (ORDER BY `test`.`t1`.`id` RANGE BETWEEN 2 PRECEDING AND CURRENT ROW) AS `SUM(id) OVER (ORDER BY id RANGE 2 PRECEDING)` from `test`.`t1` order by `test`.`t1`.`id` +EXPLAIN FORMAT=JSON SELECT id, SUM(id) OVER (ORDER BY id RANGE BETWEEN 1 PRECEDING AND 1 FOLLOWING) FROM t1 ORDER BY id; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "19.15" + }, + "ordering_operation": { + "using_filesort": true, + "cost_info": { + "sort_cost": "9.00" + }, + "windowing": { + "windows": [ + { + "name": "", + "using_temporary_table": true, + "using_filesort": true, + "filesort_key": [ + "`id`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "sum" + ] + } + ], + "cost_info": { + "sort_cost": "9.00" + }, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 9, + "rows_produced_per_join": 9, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.90", + "prefix_cost": "1.15", + "data_read_per_join": "144" + }, + "used_columns": [ + "id" + ] + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,sum(`test`.`t1`.`id`) OVER (ORDER BY `test`.`t1`.`id` RANGE BETWEEN 1 PRECEDING AND 1 FOLLOWING) AS `SUM(id) OVER (ORDER BY id RANGE BETWEEN 1 PRECEDING AND 1 FOLLOWING)` from `test`.`t1` order by `test`.`t1`.`id` +EXPLAIN FORMAT=JSON SELECT id, SUM(id) OVER (ORDER BY id RANGE UNBOUNDED PRECEDING) FROM t1 ORDER BY id; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "19.15" + }, + "ordering_operation": { + "using_filesort": true, + "cost_info": { + "sort_cost": "9.00" + }, + "windowing": { + "windows": [ + { + "name": "", + "using_temporary_table": true, + "using_filesort": true, + "filesort_key": [ + "`id`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "sum" + ] + } + ], + "cost_info": { + "sort_cost": "9.00" + }, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 9, + "rows_produced_per_join": 9, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.90", + "prefix_cost": "1.15", + "data_read_per_join": "144" + }, + "used_columns": [ + "id" + ] + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,sum(`test`.`t1`.`id`) OVER (ORDER BY `test`.`t1`.`id` RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) AS `SUM(id) OVER (ORDER BY id RANGE UNBOUNDED PRECEDING)` from `test`.`t1` order by `test`.`t1`.`id` +EXPLAIN FORMAT=JSON SELECT p, id, SUM(id) OVER (PARTITION BY p ORDER BY id RANGE 2 PRECEDING) FROM t11 ORDER BY p,id; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "38.05" + }, + "ordering_operation": { + "using_filesort": true, + "cost_info": { + "sort_cost": "18.00" + }, + "windowing": { + "windows": [ + { + "name": "", + "using_temporary_table": true, + "using_filesort": true, + "filesort_key": [ + "`p`", + "`id`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "sum" + ] + } + ], + "cost_info": { + "sort_cost": "18.00" + }, + "table": { + "table_name": "t11", + "access_type": "ALL", + "rows_examined_per_scan": 18, + "rows_produced_per_join": 18, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "1.80", + "prefix_cost": "2.05", + "data_read_per_join": "288" + }, + "used_columns": [ + "id", + "p" + ] + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t11`.`p` AS `p`,`test`.`t11`.`id` AS `id`,sum(`test`.`t11`.`id`) OVER (PARTITION BY `test`.`t11`.`p` ORDER BY `test`.`t11`.`id` RANGE BETWEEN 2 PRECEDING AND CURRENT ROW) AS `SUM(id) OVER (PARTITION BY p ORDER BY id RANGE 2 PRECEDING)` from `test`.`t11` order by `test`.`t11`.`p`,`test`.`t11`.`id` +EXPLAIN FORMAT=JSON SELECT p, id, SUM(id) OVER (PARTITION BY p ORDER BY id RANGE BETWEEN 1 PRECEDING AND 1 FOLLOWING) FROM t11 ORDER BY p,id; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "38.05" + }, + "ordering_operation": { + "using_filesort": true, + "cost_info": { + "sort_cost": "18.00" + }, + "windowing": { + "windows": [ + { + "name": "", + "using_temporary_table": true, + "using_filesort": true, + "filesort_key": [ + "`p`", + "`id`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "sum" + ] + } + ], + "cost_info": { + "sort_cost": "18.00" + }, + "table": { + "table_name": "t11", + "access_type": "ALL", + "rows_examined_per_scan": 18, + "rows_produced_per_join": 18, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "1.80", + "prefix_cost": "2.05", + "data_read_per_join": "288" + }, + "used_columns": [ + "id", + "p" + ] + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t11`.`p` AS `p`,`test`.`t11`.`id` AS `id`,sum(`test`.`t11`.`id`) OVER (PARTITION BY `test`.`t11`.`p` ORDER BY `test`.`t11`.`id` RANGE BETWEEN 1 PRECEDING AND 1 FOLLOWING) AS `SUM(id) OVER (PARTITION BY p ORDER BY id RANGE BETWEEN 1 PRECEDING AND 1 FOLLOWING)` from `test`.`t11` order by `test`.`t11`.`p`,`test`.`t11`.`id` +EXPLAIN FORMAT=JSON SELECT p, id, SUM(id) OVER (PARTITION BY p ORDER BY id RANGE UNBOUNDED PRECEDING) FROM t11 ORDER BY p,id; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "38.05" + }, + "ordering_operation": { + "using_filesort": true, + "cost_info": { + "sort_cost": "18.00" + }, + "windowing": { + "windows": [ + { + "name": "", + "using_temporary_table": true, + "using_filesort": true, + "filesort_key": [ + "`p`", + "`id`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "sum" + ] + } + ], + "cost_info": { + "sort_cost": "18.00" + }, + "table": { + "table_name": "t11", + "access_type": "ALL", + "rows_examined_per_scan": 18, + "rows_produced_per_join": 18, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "1.80", + "prefix_cost": "2.05", + "data_read_per_join": "288" + }, + "used_columns": [ + "id", + "p" + ] + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t11`.`p` AS `p`,`test`.`t11`.`id` AS `id`,sum(`test`.`t11`.`id`) OVER (PARTITION BY `test`.`t11`.`p` ORDER BY `test`.`t11`.`id` RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) AS `SUM(id) OVER (PARTITION BY p ORDER BY id RANGE UNBOUNDED PRECEDING)` from `test`.`t11` order by `test`.`t11`.`p`,`test`.`t11`.`id` +Implicit frame due to ORDER BY, with last in peer group as upper bound +EXPLAIN FORMAT=JSON SELECT user_id, SUM(user_id) OVER w, AVG(user_id) OVER w FROM t2 WINDOW w AS (ORDER BY user_id); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "7.95" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`user_id`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "sum", + "avg" + ] + } + ], + "cost_info": { + "sort_cost": "7.00" + }, + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.70", + "prefix_cost": "0.95", + "data_read_per_join": "112" + }, + "used_columns": [ + "user_id" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`user_id` AS `user_id`,sum(`test`.`t2`.`user_id`) OVER `w` AS `SUM(user_id) OVER w`,avg(`test`.`t2`.`user_id`) OVER `w` AS `AVG(user_id) OVER w` from `test`.`t2` window `w` AS (ORDER BY `test`.`t2`.`user_id` ) +EXPLAIN FORMAT=JSON SELECT p, user_id, SUM(user_id) OVER w, AVG(user_id) OVER w FROM t22 WINDOW w AS (PARTITION BY p ORDER BY user_id) ORDER BY p; +EXPLAIN + "`p`", + "`user_id`" + "avg" + "optimized_frame_evaluation": true + "sum", + "using_temporary_table": true, + "data_read_per_join": "224" + "eval_cost": "1.40", + "filesort_key": [ + "frame_buffer": { + "functions": [ + "name": "w", + "p" + "prefix_cost": "1.65", + "read_cost": "0.25", + "user_id", + "using_filesort": true, + "using_temporary_table": true, + ] + ], + }, + "access_type": "ALL", + "cost_info": { + "filtered": "100.00", + "rows_examined_per_scan": 14, + "rows_produced_per_join": 14, + "sort_cost": "14.00" + "table_name": "t22", + "used_columns": [ + ] + { + } + }, + "cost_info": { + "sort_cost": "14.00" + "table": { + "windows": [ + ], + } + }, + "cost_info": { + "query_cost": "29.65" + "using_filesort": true, + "windowing": { + } + }, + "cost_info": { + "ordering_operation": { + "select_id": 1, + } + }, + "query_block": { + } +Note 1003 /* select#1 */ select `test`.`t22`.`p` AS `p`,`test`.`t22`.`user_id` AS `user_id`,sum(`test`.`t22`.`user_id`) OVER `w` AS `SUM(user_id) OVER w`,avg(`test`.`t22`.`user_id`) OVER `w` AS `AVG(user_id) OVER w` from `test`.`t22` window `w` AS (PARTITION BY `test`.`t22`.`p` ORDER BY `test`.`t22`.`user_id` ) order by `test`.`t22`.`p` +Warnings: +{ +} +Window function use of same field in different windows, both of which +need buffering. In this case we need subsequent rewrites of arg fields +Field pointer in tmp files for window 2..n The intervening internal +window buffering in each step used to mess that up. +EXPLAIN FORMAT=JSON SELECT user_id, SUM(user_id) OVER w, AVG(user_id) OVER w1 FROM t2 +WINDOW w AS (ORDER BY user_id), w1 AS (ORDER BY user_id); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "7.95" + }, + "windowing": { + "windows": [ + { + "name": "w", + "definition_position": 1, + "using_temporary_table": true, + "using_filesort": true, + "filesort_key": [ + "`user_id`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "sum" + ] + }, + { + "name": "w1", + "definition_position": 2, + "last_executed_window": true, + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "avg" + ] + } + ], + "cost_info": { + "sort_cost": "7.00" + }, + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.70", + "prefix_cost": "0.95", + "data_read_per_join": "112" + }, + "used_columns": [ + "user_id" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`user_id` AS `user_id`,sum(`test`.`t2`.`user_id`) OVER `w` AS `SUM(user_id) OVER w`,avg(`test`.`t2`.`user_id`) OVER `w1` AS `AVG(user_id) OVER w1` from `test`.`t2` window `w` AS (ORDER BY `test`.`t2`.`user_id` ) , `w1` AS (ORDER BY `test`.`t2`.`user_id` ) +Check descending order by with RANGE: 2 PRECEDING in this case means larger than +current row. +EXPLAIN FORMAT=JSON SELECT NTILE(5) OVER w, ROW_NUMBER() OVER w, id, SUM(id) OVER w FROM t1 +WINDOW w AS (ORDER BY id DESC RANGE 2 PRECEDING); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "10.15" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`id` desc" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "ntile", + "row_number", + "sum" + ] + } + ], + "cost_info": { + "sort_cost": "9.00" + }, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 9, + "rows_produced_per_join": 9, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.90", + "prefix_cost": "1.15", + "data_read_per_join": "144" + }, + "used_columns": [ + "id" + ] + } + } + } +} +Warnings: +Note 3599 Window function 'ntile' ignores the frame clause of window 'w' and aggregates over the whole partition +Note 3599 Window function 'row_number' ignores the frame clause of window 'w' and aggregates over the whole partition +Note 1003 /* select#1 */ select ntile(5) OVER `w` AS `NTILE(5) OVER w`,row_number() OVER `w` AS `ROW_NUMBER() OVER w`,`test`.`t1`.`id` AS `id`,sum(`test`.`t1`.`id`) OVER `w` AS `SUM(id) OVER w` from `test`.`t1` window `w` AS (ORDER BY `test`.`t1`.`id` desc RANGE BETWEEN 2 PRECEDING AND CURRENT ROW) +EXPLAIN FORMAT=JSON SELECT p, NTILE(5) OVER w, ROW_NUMBER() OVER w, id, SUM(id) OVER w FROM t11 +WINDOW w AS (PARTITION BY p ORDER BY id DESC RANGE 2 PRECEDING); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "20.05" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`p`", + "`id` desc" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "ntile", + "row_number", + "sum" + ] + } + ], + "cost_info": { + "sort_cost": "18.00" + }, + "table": { + "table_name": "t11", + "access_type": "ALL", + "rows_examined_per_scan": 18, + "rows_produced_per_join": 18, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "1.80", + "prefix_cost": "2.05", + "data_read_per_join": "288" + }, + "used_columns": [ + "id", + "p" + ] + } + } + } +} +Warnings: +Note 3599 Window function 'ntile' ignores the frame clause of window 'w' and aggregates over the whole partition +Note 3599 Window function 'row_number' ignores the frame clause of window 'w' and aggregates over the whole partition +Note 1003 /* select#1 */ select `test`.`t11`.`p` AS `p`,ntile(5) OVER `w` AS `NTILE(5) OVER w`,row_number() OVER `w` AS `ROW_NUMBER() OVER w`,`test`.`t11`.`id` AS `id`,sum(`test`.`t11`.`id`) OVER `w` AS `SUM(id) OVER w` from `test`.`t11` window `w` AS (PARTITION BY `test`.`t11`.`p` ORDER BY `test`.`t11`.`id` desc RANGE BETWEEN 2 PRECEDING AND CURRENT ROW) +update t2 set date=date + user_id; +EXPLAIN FORMAT=JSON SELECT user_id, date, COUNT(*) OVER (ORDER BY date RANGE INTERVAL 1 DAY PRECEDING) FROM t2; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "7.95" + }, + "windowing": { + "windows": [ + { + "name": "", + "using_filesort": true, + "filesort_key": [ + "`date`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "count" + ] + } + ], + "cost_info": { + "sort_cost": "7.00" + }, + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.70", + "prefix_cost": "0.95", + "data_read_per_join": "112" + }, + "used_columns": [ + "user_id", + "date" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`user_id` AS `user_id`,`test`.`t2`.`date` AS `date`,count(0) OVER (ORDER BY `test`.`t2`.`date` RANGE BETWEEN INTERVAL 1 day PRECEDING AND CURRENT ROW) AS `COUNT(*) OVER (ORDER BY date RANGE INTERVAL 1 DAY PRECEDING)` from `test`.`t2` +CREATE TABLE t3(d DOUBLE); +INSERT INTO t3 +VALUES (1.1),(1.9),(4.0),(8.3),(16.0),(24.0),(20.1),(22.0),(23.0); +ANALYZE TABLE t3; +Table Op Msg_type Msg_text +test.t3 analyze status OK +EXPLAIN FORMAT=JSON SELECT d, SUM(d) OVER w, COUNT(*) OVER w FROM t3 WINDOW w AS (ORDER BY d RANGE BETWEEN 2.1 PRECEDING AND 1.1 FOLLOWING); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "10.15" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`d`" + ], + "frame_buffer": { + "using_temporary_table": true + }, + "functions": [ + "sum", + "count" + ] + } + ], + "cost_info": { + "sort_cost": "9.00" + }, + "table": { + "table_name": "t3", + "access_type": "ALL", + "rows_examined_per_scan": 9, + "rows_produced_per_join": 9, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.90", + "prefix_cost": "1.15", + "data_read_per_join": "144" + }, + "used_columns": [ + "d" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`d` AS `d`,sum(`test`.`t3`.`d`) OVER `w` AS `SUM(d) OVER w`,count(0) OVER `w` AS `COUNT(*) OVER w` from `test`.`t3` window `w` AS (ORDER BY `test`.`t3`.`d` RANGE BETWEEN 2.1 PRECEDING AND 1.1 FOLLOWING) +---------------------------------------------------------------------- +- wf over JSON +---------------------------------------------------------------------- +CREATE TABLE tj(j JSON, i INT DEFAULT 7); +INSERT INTO tj(j) VALUES ('1'), ('2'), ('3'), ('4'), ('5'), (NULL); +INSERT INTO tj(j) VALUES ('3.14'); +INSERT INTO tj(j) VALUES ('[1,2,3]'); +ANALYZE TABLE tj; +Table Op Msg_type Msg_text +test.tj analyze status OK +EXPLAIN FORMAT=JSON SELECT CAST(SUM(j) OVER () AS JSON) FROM tj; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.05" + }, + "windowing": { + "windows": [ + { + "name": "", + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "sum" + ] + } + ], + "table": { + "table_name": "tj", + "access_type": "ALL", + "rows_examined_per_scan": 8, + "rows_produced_per_join": 8, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.80", + "prefix_cost": "1.05", + "data_read_per_join": "192" + }, + "used_columns": [ + "j" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select cast(sum(`test`.`tj`.`j`) OVER () as json) AS `CAST(SUM(j) OVER () AS JSON)` from `test`.`tj` +---------------------------------------------------------------------- +- SELECT DISTINCT +---------------------------------------------------------------------- +One window +EXPLAIN FORMAT=JSON SELECT DISTINCT i,COUNT(*) OVER () FROM tj; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.05" + }, + "duplicates_removal": { + "using_filesort": false, + "windowing": { + "windows": [ + { + "name": "", + "using_temporary_table": true, + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "count" + ] + } + ], + "table": { + "table_name": "tj", + "access_type": "ALL", + "rows_examined_per_scan": 8, + "rows_produced_per_join": 8, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.80", + "prefix_cost": "1.05", + "data_read_per_join": "192" + }, + "used_columns": [ + "i" + ] + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select distinct `test`.`tj`.`i` AS `i`,count(0) OVER () AS `COUNT(*) OVER ()` from `test`.`tj` +Several windows with final ORDER BY also +EXPLAIN FORMAT=JSON SELECT DISTINCT i,NTILE(3) OVER (ORDER BY i), SUM(i) OVER (), COUNT(*) OVER () FROM tj ORDER BY NTILE(3) OVER (ORDER BY i); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "17.05" + }, + "ordering_operation": { + "using_filesort": true, + "duplicates_removal": { + "using_filesort": false, + "cost_info": { + "sort_cost": "8.00" + }, + "windowing": { + "windows": [ + { + "name": "", + "definition_position": 1, + "using_temporary_table": true, + "using_filesort": true, + "filesort_key": [ + "`i`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "ntile" + ] + }, + { + "name": "", + "definition_position": 4, + "using_temporary_table": true, + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "ntile" + ] + }, + { + "name": "", + "definition_position": 3, + "using_temporary_table": true, + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "count" + ] + }, + { + "name": "", + "definition_position": 2, + "last_executed_window": true, + "using_temporary_table": true, + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "sum" + ] + } + ], + "cost_info": { + "sort_cost": "8.00" + }, + "table": { + "table_name": "tj", + "access_type": "ALL", + "rows_examined_per_scan": 8, + "rows_produced_per_join": 8, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.80", + "prefix_cost": "1.05", + "data_read_per_join": "192" + }, + "used_columns": [ + "i" + ] + } + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select distinct `test`.`tj`.`i` AS `i`,ntile(3) OVER (ORDER BY `test`.`tj`.`i` ) AS `NTILE(3) OVER (ORDER BY i)`,sum(`test`.`tj`.`i`) OVER () AS `SUM(i) OVER ()`,count(0) OVER () AS `COUNT(*) OVER ()` from `test`.`tj` order by ntile(3) OVER (ORDER BY `test`.`tj`.`i` ) +UPDATE tj SET i=i+CASE WHEN JSON_TYPE(j) = 'ARRAY' THEN 1 ELSE j END; +UPDATE tj SET i=7 where i=8 AND JSON_TYPE(j) != 'ARRAY'; +CREATE TABLE tj2 AS SELECT * FROM tj; +UPDATE tj2 SET i=MOD(i,3); +EXPLAIN FORMAT=JSON SELECT * FROM tj2; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.05" + }, + "table": { + "table_name": "tj2", + "access_type": "ALL", + "rows_examined_per_scan": 8, + "rows_produced_per_join": 8, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.80", + "prefix_cost": "1.05", + "data_read_per_join": "192" + }, + "used_columns": [ + "j", + "i" + ] + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`tj2`.`j` AS `j`,`test`.`tj2`.`i` AS `i` from `test`.`tj2` +With GROUP BY +EXPLAIN FORMAT=JSON SELECT COUNT(*) OVER (), MOD(SUM(i),2) FROM tj2 GROUP BY i; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.05" + }, + "windowing": { + "windows": [ + { + "name": "", + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "count" + ] + } + ], + "grouping_operation": { + "using_temporary_table": true, + "using_filesort": false, + "table": { + "table_name": "tj2", + "access_type": "ALL", + "rows_examined_per_scan": 8, + "rows_produced_per_join": 8, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.80", + "prefix_cost": "1.05", + "data_read_per_join": "192" + }, + "used_columns": [ + "i" + ] + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select count(0) OVER () AS `COUNT(*) OVER ()`,(sum(`test`.`tj2`.`i`) % 2) AS `MOD(SUM(i),2)` from `test`.`tj2` group by `test`.`tj2`.`i` +EXPLAIN FORMAT=JSON SELECT DISTINCT COUNT(*) OVER (), MOD(SUM(i),2) FROM tj2 GROUP BY i; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.05" + }, + "duplicates_removal": { + "using_temporary_table": true, + "using_filesort": false, + "windowing": { + "windows": [ + { + "name": "", + "using_temporary_table": true, + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "count" + ] + } + ], + "grouping_operation": { + "using_temporary_table": true, + "using_filesort": false, + "table": { + "table_name": "tj2", + "access_type": "ALL", + "rows_examined_per_scan": 8, + "rows_produced_per_join": 8, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.80", + "prefix_cost": "1.05", + "data_read_per_join": "192" + }, + "used_columns": [ + "i" + ] + } + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select distinct count(0) OVER () AS `COUNT(*) OVER ()`,(sum(`test`.`tj2`.`i`) % 2) AS `MOD(SUM(i),2)` from `test`.`tj2` group by `test`.`tj2`.`i` +Bug fix GROUP BY with window function referring column used in grouping expression +EXPLAIN FORMAT=JSON SELECT i, SUM(i) OVER (), MOD(SUM(i),2) FROM tj2 GROUP BY i; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.05" + }, + "windowing": { + "windows": [ + { + "name": "", + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "sum" + ] + } + ], + "grouping_operation": { + "using_temporary_table": true, + "using_filesort": false, + "table": { + "table_name": "tj2", + "access_type": "ALL", + "rows_examined_per_scan": 8, + "rows_produced_per_join": 8, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.80", + "prefix_cost": "1.05", + "data_read_per_join": "192" + }, + "used_columns": [ + "i" + ] + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`tj2`.`i` AS `i`,sum(`test`.`tj2`.`i`) OVER () AS `SUM(i) OVER ()`,(sum(`test`.`tj2`.`i`) % 2) AS `MOD(SUM(i),2)` from `test`.`tj2` group by `test`.`tj2`.`i` +EXPLAIN FORMAT=JSON SELECT i, SUM(SUM(i)) OVER (), SUM(i) OVER (ORDER BY i), MOD(SUM(i),2), SUM(i) FROM tj2 GROUP BY i; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "9.05" + }, + "windowing": { + "windows": [ + { + "name": "", + "definition_position": 1, + "using_temporary_table": true, + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "sum" + ] + }, + { + "name": "", + "definition_position": 2, + "last_executed_window": true, + "using_filesort": true, + "filesort_key": [ + "`i`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "sum" + ] + } + ], + "cost_info": { + "sort_cost": "8.00" + }, + "grouping_operation": { + "using_temporary_table": true, + "using_filesort": false, + "table": { + "table_name": "tj2", + "access_type": "ALL", + "rows_examined_per_scan": 8, + "rows_produced_per_join": 8, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.80", + "prefix_cost": "1.05", + "data_read_per_join": "192" + }, + "used_columns": [ + "i" + ] + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`tj2`.`i` AS `i`,sum(sum(`test`.`tj2`.`i`)) OVER () AS `SUM(SUM(i)) OVER ()`,sum(`test`.`tj2`.`i`) OVER (ORDER BY `test`.`tj2`.`i` ) AS `SUM(i) OVER (ORDER BY i)`,(sum(`test`.`tj2`.`i`) % 2) AS `MOD(SUM(i),2)`,sum(`test`.`tj2`.`i`) AS `SUM(i)` from `test`.`tj2` group by `test`.`tj2`.`i` +DROP TABLE tj2; +---------------------------------------------------------------------- +- Bug fixes +---------------------------------------------------------------------- +Bug fix for FIRST_VALUE, LAST_VALUE when not buffered processing +EXPLAIN FORMAT=JSON SELECT LAST_VALUE(j) OVER w, FIRST_VALUE(j) OVER w FROM tj WINDOW w AS (PARTITION BY i ORDER BY j ROWS UNBOUNDED PRECEDING); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "9.05" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`i`", + "`j`" + ], + "functions": [ + "last_value", + "first_value" + ] + } + ], + "cost_info": { + "sort_cost": "8.00" + }, + "table": { + "table_name": "tj", + "access_type": "ALL", + "rows_examined_per_scan": 8, + "rows_produced_per_join": 8, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.80", + "prefix_cost": "1.05", + "data_read_per_join": "192" + }, + "used_columns": [ + "j", + "i" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select last_value(`test`.`tj`.`j`) OVER `w` AS `LAST_VALUE(j) OVER w`,first_value(`test`.`tj`.`j`) OVER `w` AS `FIRST_VALUE(j) OVER w` from `test`.`tj` window `w` AS (PARTITION BY `test`.`tj`.`i` ORDER BY `test`.`tj`.`j` ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) +Bug missing hidden column (j) induction to select list: FIRST_VALUE/LAST_VALUE +EXPLAIN FORMAT=JSON SELECT i, LAST_VALUE((CAST(j AS UNSIGNED))) OVER w, FIRST_VALUE(CAST(j AS UNSIGNED)) OVER w FROM tj +WINDOW w AS (PARTITION BY i ORDER BY CAST(j AS UNSIGNED) RANGE UNBOUNDED PRECEDING); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "9.05" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`i`", + "cast(`j` as unsigned)" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "last_value", + "first_value" + ] + } + ], + "cost_info": { + "sort_cost": "8.00" + }, + "table": { + "table_name": "tj", + "access_type": "ALL", + "rows_examined_per_scan": 8, + "rows_produced_per_join": 8, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.80", + "prefix_cost": "1.05", + "data_read_per_join": "192" + }, + "used_columns": [ + "j", + "i" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`tj`.`i` AS `i`,last_value(cast(`test`.`tj`.`j` as unsigned)) OVER `w` AS `LAST_VALUE((CAST(j AS UNSIGNED))) OVER w`,first_value(cast(`test`.`tj`.`j` as unsigned)) OVER `w` AS `FIRST_VALUE(CAST(j AS UNSIGNED)) OVER w` from `test`.`tj` window `w` AS (PARTITION BY `test`.`tj`.`i` ORDER BY cast(`test`.`tj`.`j` as unsigned) RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) +Fix for lineno in warnings buffered and unbuffered windows +EXPLAIN FORMAT=JSON SELECT j,CAST(SUM(j) OVER (PARTITION BY i) AS JSON), CAST(SUM(j) OVER () AS JSON) FROM tj; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "9.05" + }, + "windowing": { + "windows": [ + { + "name": "", + "definition_position": 1, + "using_temporary_table": true, + "using_filesort": true, + "filesort_key": [ + "`i`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "sum" + ] + }, + { + "name": "", + "definition_position": 2, + "last_executed_window": true, + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "sum" + ] + } + ], + "cost_info": { + "sort_cost": "8.00" + }, + "table": { + "table_name": "tj", + "access_type": "ALL", + "rows_examined_per_scan": 8, + "rows_produced_per_join": 8, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.80", + "prefix_cost": "1.05", + "data_read_per_join": "192" + }, + "used_columns": [ + "j", + "i" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`tj`.`j` AS `j`,cast(sum(`test`.`tj`.`j`) OVER (PARTITION BY `test`.`tj`.`i` ) as json) AS `CAST(SUM(j) OVER (PARTITION BY i) AS JSON)`,cast(sum(`test`.`tj`.`j`) OVER () as json) AS `CAST(SUM(j) OVER () AS JSON)` from `test`.`tj` +EXPLAIN FORMAT=JSON SELECT j,CAST(SUM(j) OVER (PARTITION BY i ROWS UNBOUNDED PRECEDING) AS JSON), CAST(SUM(j) OVER (PARTITION BY i ROWS UNBOUNDED PRECEDING) AS JSON) FROM tj; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "9.05" + }, + "windowing": { + "windows": [ + { + "name": "", + "definition_position": 1, + "using_temporary_table": true, + "using_filesort": true, + "filesort_key": [ + "`i`" + ], + "functions": [ + "sum" + ] + }, + { + "name": "", + "definition_position": 2, + "last_executed_window": true, + "functions": [ + "sum" + ] + } + ], + "cost_info": { + "sort_cost": "8.00" + }, + "table": { + "table_name": "tj", + "access_type": "ALL", + "rows_examined_per_scan": 8, + "rows_produced_per_join": 8, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.80", + "prefix_cost": "1.05", + "data_read_per_join": "192" + }, + "used_columns": [ + "j", + "i" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`tj`.`j` AS `j`,cast(sum(`test`.`tj`.`j`) OVER (PARTITION BY `test`.`tj`.`i` ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) as json) AS `CAST(SUM(j) OVER (PARTITION BY i ROWS UNBOUNDED PRECEDING) AS JSON)`,cast(sum(`test`.`tj`.`j`) OVER (PARTITION BY `test`.`tj`.`i` ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) as json) AS `CAST(SUM(j) OVER (PARTITION BY i ROWS UNBOUNDED PRECEDING) AS JSON)` from `test`.`tj` +Bug fix for UNION +EXPLAIN FORMAT=JSON SELECT i, ROW_NUMBER() OVER () FROM tj UNION ALL SELECT i, ROW_NUMBER() OVER () FROM tj; +EXPLAIN +{ + "query_block": { + "union_result": { + "using_temporary_table": false, + "query_specifications": [ + { + "dependent": false, + "cacheable": true, + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.05" + }, + "windowing": { + "windows": [ + { + "name": "", + "functions": [ + "row_number" + ] + } + ], + "table": { + "table_name": "tj", + "access_type": "ALL", + "rows_examined_per_scan": 8, + "rows_produced_per_join": 8, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.80", + "prefix_cost": "1.05", + "data_read_per_join": "192" + }, + "used_columns": [ + "i" + ] + } + } + } + }, + { + "dependent": false, + "cacheable": true, + "query_block": { + "select_id": 2, + "cost_info": { + "query_cost": "1.05" + }, + "windowing": { + "windows": [ + { + "name": "", + "functions": [ + "row_number" + ] + } + ], + "table": { + "table_name": "tj", + "access_type": "ALL", + "rows_examined_per_scan": 8, + "rows_produced_per_join": 8, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.80", + "prefix_cost": "1.05", + "data_read_per_join": "192" + }, + "used_columns": [ + "i" + ] + } + } + } + } + ] + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`tj`.`i` AS `i`,row_number() OVER () AS `ROW_NUMBER() OVER ()` from `test`.`tj` union all /* select#2 */ select `test`.`tj`.`i` AS `i`,row_number() OVER () AS `ROW_NUMBER() OVER ()` from `test`.`tj` +EXPLAIN FORMAT=JSON SELECT * FROM (SELECT i, j, ROW_NUMBER() OVER (ORDER BY j) FROM tj UNION SELECT i, j, ROW_NUMBER() OVER (ORDER BY j) FROM tj) alias; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "4.30" + }, + "table": { + "table_name": "alias", + "access_type": "ALL", + "rows_examined_per_scan": 16, + "rows_produced_per_join": 16, + "filtered": "100.00", + "cost_info": { + "read_cost": "2.70", + "eval_cost": "1.60", + "prefix_cost": "4.30", + "data_read_per_join": "640" + }, + "used_columns": [ + "", + "i", + "j", + "ROW_NUMBER() OVER (ORDER BY j)" + ], + "materialized_from_subquery": { + "using_temporary_table": true, + "dependent": false, + "cacheable": true, + "query_block": { + "union_result": { + "using_temporary_table": true, + "table_name": "", + "access_type": "ALL", + "query_specifications": [ + { + "dependent": false, + "cacheable": true, + "query_block": { + "select_id": 2, + "cost_info": { + "query_cost": "9.05" + }, + "windowing": { + "windows": [ + { + "name": "", + "using_filesort": true, + "filesort_key": [ + "`j`" + ], + "functions": [ + "row_number" + ] + } + ], + "cost_info": { + "sort_cost": "8.00" + }, + "table": { + "table_name": "tj", + "access_type": "ALL", + "rows_examined_per_scan": 8, + "rows_produced_per_join": 8, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.80", + "prefix_cost": "1.05", + "data_read_per_join": "192" + }, + "used_columns": [ + "j", + "i" + ] + } + } + } + }, + { + "dependent": false, + "cacheable": true, + "query_block": { + "select_id": 3, + "cost_info": { + "query_cost": "9.05" + }, + "windowing": { + "windows": [ + { + "name": "", + "using_filesort": true, + "filesort_key": [ + "`j`" + ], + "functions": [ + "row_number" + ] + } + ], + "cost_info": { + "sort_cost": "8.00" + }, + "table": { + "table_name": "tj", + "access_type": "ALL", + "rows_examined_per_scan": 8, + "rows_produced_per_join": 8, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.80", + "prefix_cost": "1.05", + "data_read_per_join": "192" + }, + "used_columns": [ + "j", + "i" + ] + } + } + } + } + ] + } + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `alias`.`i` AS `i`,`alias`.`j` AS `j`,`alias`.`ROW_NUMBER() OVER (ORDER BY j)` AS `ROW_NUMBER() OVER (ORDER BY j)` from (/* select#2 */ select `test`.`tj`.`i` AS `i`,`test`.`tj`.`j` AS `j`,row_number() OVER (ORDER BY `test`.`tj`.`j` ) AS `ROW_NUMBER() OVER (ORDER BY j)` from `test`.`tj` union /* select#3 */ select `test`.`tj`.`i` AS `i`,`test`.`tj`.`j` AS `j`,row_number() OVER (ORDER BY `test`.`tj`.`j` ) AS `ROW_NUMBER() OVER (ORDER BY j)` from `test`.`tj`) `alias` +DROP TABLE tj; +---------------------------------------------------------------------- +- More JSON +---------------------------------------------------------------------- +CREATE TABLE tj(j JSON); +INSERT INTO tj VALUES ('1'), ('2'), ('3'), ('4'), ('5'), (NULL); +EXPLAIN FORMAT=JSON SELECT j, JSON_TYPE(j), SUM(j) OVER (ORDER BY j ROWS 3 PRECEDING) FROM tj; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "6.85" + }, + "windowing": { + "windows": [ + { + "name": "", + "using_filesort": true, + "filesort_key": [ + "`j`" + ], + "frame_buffer": { + "using_temporary_table": true + }, + "functions": [ + "sum" + ] + } + ], + "cost_info": { + "sort_cost": "6.00" + }, + "table": { + "table_name": "tj", + "access_type": "ALL", + "rows_examined_per_scan": 6, + "rows_produced_per_join": 6, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.60", + "prefix_cost": "0.85", + "data_read_per_join": "96" + }, + "used_columns": [ + "j" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`tj`.`j` AS `j`,json_type(`test`.`tj`.`j`) AS `JSON_TYPE(j)`,sum(`test`.`tj`.`j`) OVER (ORDER BY `test`.`tj`.`j` ROWS BETWEEN 3 PRECEDING AND CURRENT ROW) AS `SUM(j) OVER (ORDER BY j ROWS 3 PRECEDING)` from `test`.`tj` +INSERT INTO tj VALUES ('3.14'); +EXPLAIN FORMAT=JSON SELECT j, JSON_TYPE(j), SUM(j) OVER (ORDER BY j ROWS 3 PRECEDING) FROM tj; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "7.95" + }, + "windowing": { + "windows": [ + { + "name": "", + "using_filesort": true, + "filesort_key": [ + "`j`" + ], + "frame_buffer": { + "using_temporary_table": true + }, + "functions": [ + "sum" + ] + } + ], + "cost_info": { + "sort_cost": "7.00" + }, + "table": { + "table_name": "tj", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.70", + "prefix_cost": "0.95", + "data_read_per_join": "112" + }, + "used_columns": [ + "j" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`tj`.`j` AS `j`,json_type(`test`.`tj`.`j`) AS `JSON_TYPE(j)`,sum(`test`.`tj`.`j`) OVER (ORDER BY `test`.`tj`.`j` ROWS BETWEEN 3 PRECEDING AND CURRENT ROW) AS `SUM(j) OVER (ORDER BY j ROWS 3 PRECEDING)` from `test`.`tj` +INSERT INTO tj VALUES ('[1,2,3]'); +ANALYZE TABLE tj; +Table Op Msg_type Msg_text +test.tj analyze status OK +EXPLAIN FORMAT=JSON SELECT j, +JSON_TYPE(j), +SUM(CASE WHEN JSON_TYPE(j) = 'ARRAY' THEN j->"$[0]" ELSE j END) +OVER (ORDER BY j ROWS 3 PRECEDING) +FROM tj; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "9.05" + }, + "windowing": { + "windows": [ + { + "name": "", + "using_filesort": true, + "filesort_key": [ + "`j`" + ], + "frame_buffer": { + "using_temporary_table": true + }, + "functions": [ + "sum" + ] + } + ], + "cost_info": { + "sort_cost": "8.00" + }, + "table": { + "table_name": "tj", + "access_type": "ALL", + "rows_examined_per_scan": 8, + "rows_produced_per_join": 8, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.80", + "prefix_cost": "1.05", + "data_read_per_join": "128" + }, + "used_columns": [ + "j" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`tj`.`j` AS `j`,json_type(`test`.`tj`.`j`) AS `JSON_TYPE(j)`,sum((case when (json_type(`test`.`tj`.`j`) = 'ARRAY') then json_extract(`test`.`tj`.`j`,'$[0]') else `test`.`tj`.`j` end)) OVER (ORDER BY `test`.`tj`.`j` ROWS BETWEEN 3 PRECEDING AND CURRENT ROW) AS `SUM(CASE WHEN JSON_TYPE(j) = 'ARRAY' THEN j->"$[0]" ELSE j END) +OVER (ORDER BY j ROWS 3 PRECEDING)` from `test`.`tj` +CREATE TABLE t5(b BIGINT UNSIGNED); +INSERT INTO t5 VALUES (1), (2), (3), (4), (5), (6), (7); +ANALYZE TABLE t5; +Table Op Msg_type Msg_text +test.t5 analyze status OK +last row should have COUNT(*) == 0 , not 1 (bug fix) +EXPLAIN FORMAT=JSON SELECT b, COUNT(*) OVER (ORDER BY b RANGE BETWEEN 1 FOLLOWING AND 100 FOLLOWING) bb FROM t5; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "7.95" + }, + "windowing": { + "windows": [ + { + "name": "", + "using_filesort": true, + "filesort_key": [ + "`b`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "count" + ] + } + ], + "cost_info": { + "sort_cost": "7.00" + }, + "table": { + "table_name": "t5", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.70", + "prefix_cost": "0.95", + "data_read_per_join": "112" + }, + "used_columns": [ + "b" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t5`.`b` AS `b`,count(0) OVER (ORDER BY `test`.`t5`.`b` RANGE BETWEEN 1 FOLLOWING AND 100 FOLLOWING) AS `bb` from `test`.`t5` +CREATE TABLE t6(t TIME, ts TIMESTAMP); +INSERT INTO t6 VALUES ('12:30', '2016-07-05 08:30:42'); +INSERT INTO t6 VALUES ('22:30', '2015-07-05 08:30:43'); +INSERT INTO t6 VALUES ('13:30', '2014-07-05 08:30:44'); +INSERT INTO t6 VALUES ('01:30', '2013-07-05 08:30:45'); +INSERT INTO t6 VALUES ('15:30', '2016-08-05 08:31:42'); +INSERT INTO t6 VALUES ('20:30', '2016-09-05 08:32:42'); +INSERT INTO t6 VALUES ('04:30', '2016-10-05 08:33:42'); +INSERT INTO t6 VALUES ('06:30', '2016-11-05 08:34:42'); +INSERT INTO t6 VALUES ('18:30', '2016-07-05 09:30:42'); +INSERT INTO t6 VALUES ('21:30', '2016-07-06 10:30:42'); +INSERT INTO t6 VALUES ('00:30', '2016-07-07 11:30:42'); +INSERT INTO t6 VALUES ('00:31', '2016-07-08 12:30:42'); +ANALYZE TABLE t6; +Table Op Msg_type Msg_text +test.t6 analyze status OK +INTERVAL specified with string as below failed +EXPLAIN FORMAT=JSON SELECT t, COUNT(*) OVER (ORDER BY t RANGE +BETWEEN INTERVAL 1 HOUR PRECEDING AND INTERVAL '2:2' MINUTE_SECOND FOLLOWING) AS cnt FROM t6; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "13.45" + }, + "windowing": { + "windows": [ + { + "name": "", + "using_filesort": true, + "filesort_key": [ + "`t`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "count" + ] + } + ], + "cost_info": { + "sort_cost": "12.00" + }, + "table": { + "table_name": "t6", + "access_type": "ALL", + "rows_examined_per_scan": 12, + "rows_produced_per_join": 12, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "1.20", + "prefix_cost": "1.45", + "data_read_per_join": "192" + }, + "used_columns": [ + "t" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t6`.`t` AS `t`,count(0) OVER (ORDER BY `test`.`t6`.`t` RANGE BETWEEN INTERVAL 1 hour PRECEDING AND INTERVAL '2:2' minute_second FOLLOWING) AS `cnt` from `test`.`t6` +---------------------------------------------------------------------- +- Window spec inheritance +---------------------------------------------------------------------- +EXPLAIN FORMAT=JSON SELECT COUNT(*) OVER w0, +COUNT(*) OVER w, +COUNT(*) OVER w1 FROM t6 +WINDOW w0 AS (), +w AS (w0 ORDER BY t), +w1 AS (w RANGE BETWEEN INTERVAL 24 HOUR PRECEDING AND INTERVAL '2:2' MINUTE_SECOND FOLLOWING); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "13.45" + }, + "windowing": { + "windows": [ + { + "name": "w0", + "definition_position": 1, + "using_temporary_table": true, + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "count" + ] + }, + { + "name": "w", + "definition_position": 2, + "using_temporary_table": true, + "using_filesort": true, + "filesort_key": [ + "`t`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "count" + ] + }, + { + "name": "w1", + "definition_position": 3, + "last_executed_window": true, + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "count" + ] + } + ], + "cost_info": { + "sort_cost": "12.00" + }, + "table": { + "table_name": "t6", + "access_type": "ALL", + "rows_examined_per_scan": 12, + "rows_produced_per_join": 12, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "1.20", + "prefix_cost": "1.45", + "data_read_per_join": "192" + }, + "used_columns": [ + "t" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select count(0) OVER `w0` AS `COUNT(*) OVER w0`,count(0) OVER `w` AS `COUNT(*) OVER w`,count(0) OVER `w1` AS `COUNT(*) OVER w1` from `test`.`t6` window `w0` AS () , `w` AS (`w0` ORDER BY `test`.`t6`.`t` ) , `w1` AS (`w` RANGE BETWEEN INTERVAL 24 hour PRECEDING AND INTERVAL '2:2' minute_second FOLLOWING) +CREATE VIEW v AS +SELECT COUNT(*) OVER w0, +COUNT(*) OVER w, +COUNT(*) OVER w1 FROM t6 +WINDOW w0 AS (), +w AS (w0 ORDER BY t), +w1 AS (w RANGE BETWEEN INTERVAL 24 HOUR PRECEDING AND INTERVAL '2:2' MINUTE_SECOND FOLLOWING); +SHOW CREATE VIEW v; +View Create View character_set_client collation_connection +v CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v` AS select count(0) OVER `w0` AS `COUNT(*) OVER w0`,count(0) OVER `w` AS `COUNT(*) OVER w`,count(0) OVER `w1` AS `COUNT(*) OVER w1` from `t6` window `w0` AS () , `w` AS (`w0` ORDER BY `t6`.`t` ) , `w1` AS (`w` RANGE BETWEEN INTERVAL 24 hour PRECEDING AND INTERVAL '2:2' minute_second FOLLOWING) utf8 utf8_general_ci +EXPLAIN FORMAT=JSON SELECT * FROM v; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "3.85" + }, + "table": { + "table_name": "v", + "access_type": "ALL", + "rows_examined_per_scan": 12, + "rows_produced_per_join": 12, + "filtered": "100.00", + "cost_info": { + "read_cost": "2.65", + "eval_cost": "1.20", + "prefix_cost": "3.85", + "data_read_per_join": "384" + }, + "used_columns": [ + "COUNT(*) OVER w0", + "COUNT(*) OVER w", + "COUNT(*) OVER w1" + ], + "materialized_from_subquery": { + "using_temporary_table": true, + "dependent": false, + "cacheable": true, + "query_block": { + "select_id": 2, + "cost_info": { + "query_cost": "13.45" + }, + "windowing": { + "windows": [ + { + "name": "w0", + "definition_position": 1, + "using_temporary_table": true, + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "count" + ] + }, + { + "name": "w", + "definition_position": 2, + "using_temporary_table": true, + "using_filesort": true, + "filesort_key": [ + "`t`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "count" + ] + }, + { + "name": "w1", + "definition_position": 3, + "last_executed_window": true, + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "count" + ] + } + ], + "cost_info": { + "sort_cost": "12.00" + }, + "table": { + "table_name": "t6", + "access_type": "ALL", + "rows_examined_per_scan": 12, + "rows_produced_per_join": 12, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "1.20", + "prefix_cost": "1.45", + "data_read_per_join": "192" + }, + "used_columns": [ + "t" + ] + } + } + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`v`.`COUNT(*) OVER w0` AS `COUNT(*) OVER w0`,`test`.`v`.`COUNT(*) OVER w` AS `COUNT(*) OVER w`,`test`.`v`.`COUNT(*) OVER w1` AS `COUNT(*) OVER w1` from `test`.`v` +DROP VIEW v; +---------------------------------------------------------------------- +- Bugs with induction of hidden fields from window function also used +- in ORDER BY/PARTITION BY +---------------------------------------------------------------------- +EXPLAIN FORMAT=JSON SELECT id, AVG(id) OVER (PARTITION BY id) summ FROM t1; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "10.15" + }, + "windowing": { + "windows": [ + { + "name": "", + "using_filesort": true, + "filesort_key": [ + "`id`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "avg" + ] + } + ], + "cost_info": { + "sort_cost": "9.00" + }, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 9, + "rows_produced_per_join": 9, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.90", + "prefix_cost": "1.15", + "data_read_per_join": "144" + }, + "used_columns": [ + "id" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,avg(`test`.`t1`.`id`) OVER (PARTITION BY `test`.`t1`.`id` ) AS `summ` from `test`.`t1` +EXPLAIN FORMAT=JSON SELECT AVG(id) OVER (PARTITION BY id) summ FROM t1; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "10.15" + }, + "windowing": { + "windows": [ + { + "name": "", + "using_filesort": true, + "filesort_key": [ + "`id`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "avg" + ] + } + ], + "cost_info": { + "sort_cost": "9.00" + }, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 9, + "rows_produced_per_join": 9, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.90", + "prefix_cost": "1.15", + "data_read_per_join": "144" + }, + "used_columns": [ + "id" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select avg(`test`.`t1`.`id`) OVER (PARTITION BY `test`.`t1`.`id` ) AS `summ` from `test`.`t1` +EXPLAIN FORMAT=JSON SELECT id, AVG(id) OVER (PARTITION BY id) summ, +AVG(id) OVER (PARTITION BY id) summ2 FROM t1; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "10.15" + }, + "windowing": { + "windows": [ + { + "name": "", + "definition_position": 1, + "using_temporary_table": true, + "using_filesort": true, + "filesort_key": [ + "`id`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "avg" + ] + }, + { + "name": "", + "definition_position": 2, + "last_executed_window": true, + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "avg" + ] + } + ], + "cost_info": { + "sort_cost": "9.00" + }, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 9, + "rows_produced_per_join": 9, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.90", + "prefix_cost": "1.15", + "data_read_per_join": "144" + }, + "used_columns": [ + "id" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,avg(`test`.`t1`.`id`) OVER (PARTITION BY `test`.`t1`.`id` ) AS `summ`,avg(`test`.`t1`.`id`) OVER (PARTITION BY `test`.`t1`.`id` ) AS `summ2` from `test`.`t1` +EXPLAIN FORMAT=JSON SELECT AVG(id) OVER (PARTITION BY id) summ, +AVG(id) OVER (PARTITION BY id) summ2 FROM t1; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "10.15" + }, + "windowing": { + "windows": [ + { + "name": "", + "definition_position": 1, + "using_temporary_table": true, + "using_filesort": true, + "filesort_key": [ + "`id`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "avg" + ] + }, + { + "name": "", + "definition_position": 2, + "last_executed_window": true, + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "avg" + ] + } + ], + "cost_info": { + "sort_cost": "9.00" + }, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 9, + "rows_produced_per_join": 9, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.90", + "prefix_cost": "1.15", + "data_read_per_join": "144" + }, + "used_columns": [ + "id" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select avg(`test`.`t1`.`id`) OVER (PARTITION BY `test`.`t1`.`id` ) AS `summ`,avg(`test`.`t1`.`id`) OVER (PARTITION BY `test`.`t1`.`id` ) AS `summ2` from `test`.`t1` +Bug for AVG in presence of several NULLs +INSERT INTO t1 VALUES (NULL, 'F'); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN FORMAT=JSON SELECT COUNT(id) OVER w, id, AVG(id) OVER w, SUM(id) OVER w, FIRST_VALUE(id) OVER w FROM t1 +WINDOW w AS (ORDER BY id RANGE 1 PRECEDING); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "11.25" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`id`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "count", + "avg", + "sum", + "first_value" + ] + } + ], + "cost_info": { + "sort_cost": "10.00" + }, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 10, + "rows_produced_per_join": 10, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "1.00", + "prefix_cost": "1.25", + "data_read_per_join": "160" + }, + "used_columns": [ + "id" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select count(`test`.`t1`.`id`) OVER `w` AS `COUNT(id) OVER w`,`test`.`t1`.`id` AS `id`,avg(`test`.`t1`.`id`) OVER `w` AS `AVG(id) OVER w`,sum(`test`.`t1`.`id`) OVER `w` AS `SUM(id) OVER w`,first_value(`test`.`t1`.`id`) OVER `w` AS `FIRST_VALUE(id) OVER w` from `test`.`t1` window `w` AS (ORDER BY `test`.`t1`.`id` RANGE BETWEEN 1 PRECEDING AND CURRENT ROW) +Check frame size, COUNT(*) vs COUNT() in frames with NULLs +EXPLAIN FORMAT=JSON SELECT id, count(id) over w, count(*) over w, FIRST_VALUE(id) OVER w FROM t1 +WINDOW w AS (ORDER BY id ASC RANGE BETWEEN 2 PRECEDING AND 1 PRECEDING); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "11.25" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`id`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "count", + "count", + "first_value" + ] + } + ], + "cost_info": { + "sort_cost": "10.00" + }, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 10, + "rows_produced_per_join": 10, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "1.00", + "prefix_cost": "1.25", + "data_read_per_join": "160" + }, + "used_columns": [ + "id" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,count(`test`.`t1`.`id`) OVER `w` AS `count(id) over w`,count(0) OVER `w` AS `count(*) over w`,first_value(`test`.`t1`.`id`) OVER `w` AS `FIRST_VALUE(id) OVER w` from `test`.`t1` window `w` AS (ORDER BY `test`.`t1`.`id` RANGE BETWEEN 2 PRECEDING AND 1 PRECEDING) +EXPLAIN FORMAT=JSON SELECT id, count(id) over w, count(*) over w, FIRST_VALUE(id) OVER w FROM t1 +WINDOW w AS (ORDER BY id DESC RANGE BETWEEN 2 PRECEDING AND 1 PRECEDING); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "11.25" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`id` desc" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "count", + "count", + "first_value" + ] + } + ], + "cost_info": { + "sort_cost": "10.00" + }, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 10, + "rows_produced_per_join": 10, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "1.00", + "prefix_cost": "1.25", + "data_read_per_join": "160" + }, + "used_columns": [ + "id" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,count(`test`.`t1`.`id`) OVER `w` AS `count(id) over w`,count(0) OVER `w` AS `count(*) over w`,first_value(`test`.`t1`.`id`) OVER `w` AS `FIRST_VALUE(id) OVER w` from `test`.`t1` window `w` AS (ORDER BY `test`.`t1`.`id` desc RANGE BETWEEN 2 PRECEDING AND 1 PRECEDING) +CREATE TABLE ss(c CHAR(1)); +INSERT INTO ss VALUES ('M'); +ANALYZE TABLE ss; +Table Op Msg_type Msg_text +test.ss analyze status OK +EXPLAIN FORMAT=JSON SELECT sex, NTILE(2) OVER w, SUM(ASCII(sex)) OVER w s FROM t1 +HAVING sex=(SELECT c FROM ss LIMIT 1) +WINDOW w AS (ORDER BY id ROWS UNBOUNDED PRECEDING); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "11.25" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`id`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "ntile", + "sum" + ] + } + ], + "cost_info": { + "sort_cost": "10.00" + }, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 10, + "rows_produced_per_join": 10, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "1.00", + "prefix_cost": "1.25", + "data_read_per_join": "160" + }, + "used_columns": [ + "id", + "sex" + ] + }, + "having_subqueries": [ + { + "dependent": false, + "cacheable": true, + "query_block": { + "select_id": 2, + "cost_info": { + "query_cost": "0.35" + }, + "table": { + "table_name": "ss", + "access_type": "ALL", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.10", + "prefix_cost": "0.35", + "data_read_per_join": "8" + }, + "used_columns": [ + "c" + ] + } + } + } + ] + } + } +} +Warnings: +Note 3599 Window function 'ntile' ignores the frame clause of window 'w' and aggregates over the whole partition +Note 1003 /* select#1 */ select `test`.`t1`.`sex` AS `sex`,ntile(2) OVER `w` AS `NTILE(2) OVER w`,sum(ascii(`test`.`t1`.`sex`)) OVER `w` AS `s` from `test`.`t1` having (`test`.`t1`.`sex` = (/* select#2 */ select `test`.`ss`.`c` from `test`.`ss` limit 1)) window `w` AS (ORDER BY `test`.`t1`.`id` ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) +EXPLAIN FORMAT=JSON SELECT sex, AVG(id), ROW_NUMBER() OVER w FROM t1 +GROUP BY sex HAVING sex='M' OR sex IS NULL +WINDOW w AS (ORDER BY AVG(id)) ORDER BY sex DESC; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "21.25" + }, + "ordering_operation": { + "using_filesort": true, + "cost_info": { + "sort_cost": "10.00" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_temporary_table": true, + "using_filesort": true, + "filesort_key": [ + "avg(`id`)" + ], + "functions": [ + "row_number" + ] + } + ], + "cost_info": { + "sort_cost": "10.00" + }, + "grouping_operation": { + "using_temporary_table": true, + "using_filesort": false, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 10, + "rows_produced_per_join": 10, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "1.00", + "prefix_cost": "1.25", + "data_read_per_join": "160" + }, + "used_columns": [ + "id", + "sex" + ] + } + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`sex` AS `sex`,avg(`test`.`t1`.`id`) AS `AVG(id)`,row_number() OVER `w` AS `ROW_NUMBER() OVER w` from `test`.`t1` group by `test`.`t1`.`sex` desc having ((`test`.`t1`.`sex` = 'M') or (`test`.`t1`.`sex` is null)) window `w` AS (ORDER BY avg(`test`.`t1`.`id`) ) order by `test`.`t1`.`sex` desc +DROP TABLE t, t1, t11, t2, t22, t3, t5, t6, tj, ss; +---------------------------------------------------------------------- +- ORDER BY + RANK with more than one ordering expression +---------------------------------------------------------------------- +CREATE TABLE t(i INT, j INT, k INT); +INSERT INTO t VALUES (1,1,1), +(1,1,2), +(1,1,2), +(1,2,1), +(1,2,2), +(2,1,1), +(2,1,1), +(2,1,2), +(2,2,1), +(2,2,2); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +EXPLAIN FORMAT=JSON SELECT *, RANK() OVER (ORDER BY i,j,k) AS O_IJK, +RANK() OVER (ORDER BY j) AS O_J, +RANK() OVER (ORDER BY k,j) AS O_KJ FROM t ORDER BY i,j,k; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "41.25" + }, + "ordering_operation": { + "using_filesort": true, + "cost_info": { + "sort_cost": "10.00" + }, + "windowing": { + "windows": [ + { + "name": "", + "definition_position": 1, + "using_temporary_table": true, + "using_filesort": true, + "filesort_key": [ + "`i`", + "`j`", + "`k`" + ], + "functions": [ + "rank" + ] + }, + { + "name": "", + "definition_position": 2, + "using_temporary_table": true, + "using_filesort": true, + "filesort_key": [ + "`j`" + ], + "functions": [ + "rank" + ] + }, + { + "name": "", + "definition_position": 3, + "last_executed_window": true, + "using_temporary_table": true, + "using_filesort": true, + "filesort_key": [ + "`k`", + "`j`" + ], + "functions": [ + "rank" + ] + } + ], + "cost_info": { + "sort_cost": "30.00" + }, + "table": { + "table_name": "t", + "access_type": "ALL", + "rows_examined_per_scan": 10, + "rows_produced_per_join": 10, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "1.00", + "prefix_cost": "1.25", + "data_read_per_join": "160" + }, + "used_columns": [ + "i", + "j", + "k" + ] + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`i` AS `i`,`test`.`t`.`j` AS `j`,`test`.`t`.`k` AS `k`,rank() OVER (ORDER BY `test`.`t`.`i`,`test`.`t`.`j`,`test`.`t`.`k` ) AS `O_IJK`,rank() OVER (ORDER BY `test`.`t`.`j` ) AS `O_J`,rank() OVER (ORDER BY `test`.`t`.`k`,`test`.`t`.`j` ) AS `O_KJ` from `test`.`t` order by `test`.`t`.`i`,`test`.`t`.`j`,`test`.`t`.`k` +DROP TABLE t; +---------------------------------------------------------------------- +- Gulutzan's sanity tests in +- http://ocelot.ca/blog/blog/2016/04/18/mariadb-10-2-window-functions/ +- His comments are quoted. +---------------------------------------------------------------------- +CREATE TABLE t1 (s1 INT, s2 CHAR(5)); +INSERT INTO t1 VALUES (1, 'a'); +INSERT INTO t1 VALUES (NULL, NULL); +INSERT INTO t1 VALUES (1, NULL); +INSERT INTO t1 VALUES (NULL, 'a'); +INSERT INTO t1 VALUES (2, 'b'); +INSERT INTO t1 VALUES (-1, ''); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +"The following statements all cause the MariaDB server to crash" +MySQL doesn't crash +EXPLAIN FORMAT=JSON SELECT ROW_NUMBER() OVER (); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "message": "No tables used" + } +} +Warnings: +Note 1003 /* select#1 */ select row_number() OVER () AS `ROW_NUMBER() OVER ()` +EXPLAIN FORMAT=JSON SELECT *, ABS(ROW_NUMBER() OVER (ORDER BY s1,s2)) +- ROW_NUMBER() OVER (ORDER BY s1,s2) AS X FROM t1; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "6.85" + }, + "windowing": { + "windows": [ + { + "name": "", + "definition_position": 1, + "using_temporary_table": true, + "using_filesort": true, + "filesort_key": [ + "`s1`", + "`s2`" + ], + "functions": [ + "row_number" + ] + }, + { + "name": "", + "definition_position": 2, + "last_executed_window": true, + "functions": [ + "row_number" + ] + } + ], + "cost_info": { + "sort_cost": "6.00" + }, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 6, + "rows_produced_per_join": 6, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.60", + "prefix_cost": "0.85", + "data_read_per_join": "192" + }, + "used_columns": [ + "s1", + "s2" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`s1` AS `s1`,`test`.`t1`.`s2` AS `s2`,(abs(row_number() OVER (ORDER BY `test`.`t1`.`s1`,`test`.`t1`.`s2` ) ) - row_number() OVER (ORDER BY `test`.`t1`.`s1`,`test`.`t1`.`s2` ) ) AS `X` from `test`.`t1` +EXPLAIN FORMAT=JSON SELECT RANK() OVER (ORDER BY AVG(s1)) FROM t1; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.85" + }, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 6, + "rows_produced_per_join": 6, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.60", + "prefix_cost": "0.85", + "data_read_per_join": "192" + }, + "used_columns": [ + "s1" + ] + } + } +} +Warnings: +Note 1003 /* select#1 */ select rank() OVER (ORDER BY avg(`test`.`t1`.`s1`) ) AS `RANK() OVER (ORDER BY AVG(s1))` from `test`.`t1` +"The following statements all give the wrong answers with MariaDB" +Correct with MySQL. +EXPLAIN FORMAT=JSON SELECT COUNT(*) OVER (ORDER BY s2) FROM t1 WHERE s2 IS NULL; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.85" + }, + "windowing": { + "windows": [ + { + "name": "", + "using_filesort": true, + "filesort_key": [ + "`s2`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "count" + ] + } + ], + "cost_info": { + "sort_cost": "1.00" + }, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 6, + "rows_produced_per_join": 1, + "filtered": "16.67", + "cost_info": { + "read_cost": "0.75", + "eval_cost": "0.10", + "prefix_cost": "0.85", + "data_read_per_join": "32" + }, + "used_columns": [ + "s2" + ], + "attached_condition": "(`test`.`t1`.`s2` is null)" + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select count(0) OVER (ORDER BY `test`.`t1`.`s2` ) AS `COUNT(*) OVER (ORDER BY s2)` from `test`.`t1` where (`test`.`t1`.`s2` is null) +EXPLAIN FORMAT=JSON SELECT * FROM ( +SELECT *,DENSE_RANK() OVER (ORDER BY s2 DESC), +DENSE_RANK() OVER (ORDER BY s2) FROM t1 +) alias ORDER BY s1,s2; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "9.17" + }, + "ordering_operation": { + "using_filesort": true, + "cost_info": { + "sort_cost": "6.00" + }, + "table": { + "table_name": "alias", + "access_type": "ALL", + "rows_examined_per_scan": 6, + "rows_produced_per_join": 6, + "filtered": "100.00", + "cost_info": { + "read_cost": "2.58", + "eval_cost": "0.60", + "prefix_cost": "3.18", + "data_read_per_join": "288" + }, + "used_columns": [ + "s1", + "s2", + "DENSE_RANK() OVER (ORDER BY s2 DESC)", + "DENSE_RANK() OVER (ORDER BY s2)" + ], + "materialized_from_subquery": { + "using_temporary_table": true, + "dependent": false, + "cacheable": true, + "query_block": { + "select_id": 2, + "cost_info": { + "query_cost": "12.85" + }, + "windowing": { + "windows": [ + { + "name": "", + "definition_position": 1, + "using_temporary_table": true, + "using_filesort": true, + "filesort_key": [ + "`s2` desc" + ], + "functions": [ + "dense_rank" + ] + }, + { + "name": "", + "definition_position": 2, + "last_executed_window": true, + "using_filesort": true, + "filesort_key": [ + "`s2`" + ], + "functions": [ + "dense_rank" + ] + } + ], + "cost_info": { + "sort_cost": "12.00" + }, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 6, + "rows_produced_per_join": 6, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.60", + "prefix_cost": "0.85", + "data_read_per_join": "192" + }, + "used_columns": [ + "s1", + "s2" + ] + } + } + } + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `alias`.`s1` AS `s1`,`alias`.`s2` AS `s2`,`alias`.`DENSE_RANK() OVER (ORDER BY s2 DESC)` AS `DENSE_RANK() OVER (ORDER BY s2 DESC)`,`alias`.`DENSE_RANK() OVER (ORDER BY s2)` AS `DENSE_RANK() OVER (ORDER BY s2)` from (/* select#2 */ select `test`.`t1`.`s1` AS `s1`,`test`.`t1`.`s2` AS `s2`,dense_rank() OVER (ORDER BY `test`.`t1`.`s2` desc ) AS `DENSE_RANK() OVER (ORDER BY s2 DESC)`,dense_rank() OVER (ORDER BY `test`.`t1`.`s2` ) AS `DENSE_RANK() OVER (ORDER BY s2)` from `test`.`t1`) `alias` order by `alias`.`s1`,`alias`.`s2` +EXPLAIN FORMAT=JSON SELECT * FROM ( +SELECT *, SUM(s1) OVER (ORDER BY s1) FROM t1 ORDER BY s1 +) alias ORDER BY s1,s2; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "9.17" + }, + "ordering_operation": { + "using_filesort": true, + "cost_info": { + "sort_cost": "6.00" + }, + "table": { + "table_name": "alias", + "access_type": "ALL", + "rows_examined_per_scan": 6, + "rows_produced_per_join": 6, + "filtered": "100.00", + "cost_info": { + "read_cost": "2.58", + "eval_cost": "0.60", + "prefix_cost": "3.18", + "data_read_per_join": "288" + }, + "used_columns": [ + "s1", + "s2", + "SUM(s1) OVER (ORDER BY s1)" + ], + "materialized_from_subquery": { + "using_temporary_table": true, + "dependent": false, + "cacheable": true, + "query_block": { + "select_id": 2, + "cost_info": { + "query_cost": "12.85" + }, + "ordering_operation": { + "using_filesort": true, + "cost_info": { + "sort_cost": "6.00" + }, + "windowing": { + "windows": [ + { + "name": "", + "using_temporary_table": true, + "using_filesort": true, + "filesort_key": [ + "`s1`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "sum" + ] + } + ], + "cost_info": { + "sort_cost": "6.00" + }, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 6, + "rows_produced_per_join": 6, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.60", + "prefix_cost": "0.85", + "data_read_per_join": "192" + }, + "used_columns": [ + "s1", + "s2" + ] + } + } + } + } + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `alias`.`s1` AS `s1`,`alias`.`s2` AS `s2`,`alias`.`SUM(s1) OVER (ORDER BY s1)` AS `SUM(s1) OVER (ORDER BY s1)` from (/* select#2 */ select `test`.`t1`.`s1` AS `s1`,`test`.`t1`.`s2` AS `s2`,sum(`test`.`t1`.`s1`) OVER (ORDER BY `test`.`t1`.`s1` ) AS `SUM(s1) OVER (ORDER BY s1)` from `test`.`t1` order by `test`.`t1`.`s1`) `alias` order by `alias`.`s1`,`alias`.`s2` +EXPLAIN FORMAT=JSON SELECT AVG(s1), RANK() OVER (ORDER BY s1) FROM t1; +ERROR 42000: In aggregated query without GROUP BY, expression #1 of PARTITION BY or ORDER BY clause of window '' contains nonaggregated column 'test.t1.s1'; this is incompatible with sql_mode=only_full_group_by +"The following statement causes the client to hang (it loops in +mysql_store_result, I think this is the first time I've seen this type of +error)" +No issue with MySQL +EXPLAIN FORMAT=JSON SELECT *, AVG(s1) OVER () FROM t1; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.85" + }, + "windowing": { + "windows": [ + { + "name": "", + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "avg" + ] + } + ], + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 6, + "rows_produced_per_join": 6, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.60", + "prefix_cost": "0.85", + "data_read_per_join": "192" + }, + "used_columns": [ + "s1", + "s2" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`s1` AS `s1`,`test`.`t1`.`s2` AS `s2`,avg(`test`.`t1`.`s1`) OVER () AS `AVG(s1) OVER ()` from `test`.`t1` +EXPLAIN FORMAT=JSON SELECT *, AVG(s1) OVER (ROWS UNBOUNDED PRECEDING) FROM t1; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.85" + }, + "windowing": { + "windows": [ + { + "name": "", + "functions": [ + "avg" + ] + } + ], + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 6, + "rows_produced_per_join": 6, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.60", + "prefix_cost": "0.85", + "data_read_per_join": "192" + }, + "used_columns": [ + "s1", + "s2" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`s1` AS `s1`,`test`.`t1`.`s2` AS `s2`,avg(`test`.`t1`.`s1`) OVER (ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) AS `AVG(s1) OVER (ROWS UNBOUNDED PRECEDING)` from `test`.`t1` +DROP TABLE t1; +Some negative tests (from Srikanth) +CREATE TABLE t (a INT, b INT, c INT); +INSERT INTO t VALUES (1,1,1), (1,1,2), (1,1,3), +(1,2,1), (1,2,2), (1,2,3), +(1,3,1), (1,3,2), (1,3,3), +(2,1,1), (2,1,2), (2,1,3), +(2,2,1), (2,2,2), (2,2,3), +(2,3,1), (2,3,2), (2,3,3); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +Wfs OK in ORDER BY, but not in WHERE or HAVING clauses +EXPLAIN FORMAT=JSON SELECT * FROM t ORDER BY RANK() OVER (ORDER BY a DESC,b,c); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "38.05" + }, + "ordering_operation": { + "using_filesort": true, + "cost_info": { + "sort_cost": "18.00" + }, + "windowing": { + "windows": [ + { + "name": "", + "using_temporary_table": true, + "using_filesort": true, + "filesort_key": [ + "`a` desc", + "`b`", + "`c`" + ], + "functions": [ + "rank" + ] + } + ], + "cost_info": { + "sort_cost": "18.00" + }, + "table": { + "table_name": "t", + "access_type": "ALL", + "rows_examined_per_scan": 18, + "rows_produced_per_join": 18, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "1.80", + "prefix_cost": "2.05", + "data_read_per_join": "288" + }, + "used_columns": [ + "a", + "b", + "c" + ] + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,`test`.`t`.`c` AS `c` from `test`.`t` order by rank() OVER (ORDER BY `test`.`t`.`a` desc,`test`.`t`.`b`,`test`.`t`.`c` ) +EXPLAIN FORMAT=JSON SELECT *, RANK() OVER (ORDER BY a DESC,b,c) AS `rank` FROM t ORDER BY `rank`; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "38.05" + }, + "ordering_operation": { + "using_filesort": true, + "cost_info": { + "sort_cost": "18.00" + }, + "windowing": { + "windows": [ + { + "name": "", + "using_temporary_table": true, + "using_filesort": true, + "filesort_key": [ + "`a` desc", + "`b`", + "`c`" + ], + "functions": [ + "rank" + ] + } + ], + "cost_info": { + "sort_cost": "18.00" + }, + "table": { + "table_name": "t", + "access_type": "ALL", + "rows_examined_per_scan": 18, + "rows_produced_per_join": 18, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "1.80", + "prefix_cost": "2.05", + "data_read_per_join": "288" + }, + "used_columns": [ + "a", + "b", + "c" + ] + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,`test`.`t`.`c` AS `c`,rank() OVER (ORDER BY `test`.`t`.`a` desc,`test`.`t`.`b`,`test`.`t`.`c` ) AS `rank` from `test`.`t` order by `rank` +Windows should only be allowed in order by of a simple table query +This is legal, though: +(select a from t) union (select a from t order by (row_number() over ())); +a +1 +2 +Non constants as frame bounds +Non-unique window name +Illegal legacy position indication in window's ORDER BY clause +EXPLAIN FORMAT=JSON SELECT * FROM ( +SELECT a,b,c, RANK() OVER (ORDER BY 1*1) FROM t +) alias ORDER BY a,b,c; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "22.52" + }, + "ordering_operation": { + "using_filesort": true, + "cost_info": { + "sort_cost": "18.00" + }, + "table": { + "table_name": "alias", + "access_type": "ALL", + "rows_examined_per_scan": 18, + "rows_produced_per_join": 18, + "filtered": "100.00", + "cost_info": { + "read_cost": "2.73", + "eval_cost": "1.80", + "prefix_cost": "4.53", + "data_read_per_join": "576" + }, + "used_columns": [ + "a", + "b", + "c", + "RANK() OVER (ORDER BY 1*1)" + ], + "materialized_from_subquery": { + "using_temporary_table": true, + "dependent": false, + "cacheable": true, + "query_block": { + "select_id": 2, + "cost_info": { + "query_cost": "20.05" + }, + "windowing": { + "windows": [ + { + "name": "", + "using_filesort": true, + "filesort_key": [ + "(1 * 1)" + ], + "functions": [ + "rank" + ] + } + ], + "cost_info": { + "sort_cost": "18.00" + }, + "table": { + "table_name": "t", + "access_type": "ALL", + "rows_examined_per_scan": 18, + "rows_produced_per_join": 18, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "1.80", + "prefix_cost": "2.05", + "data_read_per_join": "288" + }, + "used_columns": [ + "a", + "b", + "c" + ] + } + } + } + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `alias`.`a` AS `a`,`alias`.`b` AS `b`,`alias`.`c` AS `c`,`alias`.`RANK() OVER (ORDER BY 1*1)` AS `RANK() OVER (ORDER BY 1*1)` from (/* select#2 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,`test`.`t`.`c` AS `c`,rank() OVER (ORDER BY (1 * 1) ) AS `RANK() OVER (ORDER BY 1*1)` from `test`.`t`) `alias` order by `alias`.`a`,`alias`.`b`,`alias`.`c` +Crashed: more than one window in subquery +EXPLAIN FORMAT=JSON SELECT * FROM (SELECT count(*) OVER (), sum(c) OVER () AS sum1, a from t) as alias; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "4.52" + }, + "table": { + "table_name": "alias", + "access_type": "ALL", + "rows_examined_per_scan": 18, + "rows_produced_per_join": 18, + "filtered": "100.00", + "cost_info": { + "read_cost": "2.73", + "eval_cost": "1.80", + "prefix_cost": "4.53", + "data_read_per_join": "720" + }, + "used_columns": [ + "count(*) OVER ()", + "sum1", + "a" + ], + "materialized_from_subquery": { + "using_temporary_table": true, + "dependent": false, + "cacheable": true, + "query_block": { + "select_id": 2, + "cost_info": { + "query_cost": "2.05" + }, + "windowing": { + "windows": [ + { + "name": "", + "definition_position": 1, + "using_temporary_table": true, + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "count" + ] + }, + { + "name": "", + "definition_position": 2, + "last_executed_window": true, + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "sum" + ] + } + ], + "table": { + "table_name": "t", + "access_type": "ALL", + "rows_examined_per_scan": 18, + "rows_produced_per_join": 18, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "1.80", + "prefix_cost": "2.05", + "data_read_per_join": "288" + }, + "used_columns": [ + "a", + "c" + ] + } + } + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `alias`.`count(*) OVER ()` AS `count(*) OVER ()`,`alias`.`sum1` AS `sum1`,`alias`.`a` AS `a` from (/* select#2 */ select count(0) OVER () AS `count(*) OVER ()`,sum(`test`.`t`.`c`) OVER () AS `sum1`,`test`.`t`.`a` AS `a` from `test`.`t`) `alias` +Crashed: expression containing window function(s) in subquery +EXPLAIN FORMAT=JSON SELECT * FROM (SELECT count(*) OVER () + sum(c) OVER () AS sum1, a from t) as alias; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "4.52" + }, + "table": { + "table_name": "alias", + "access_type": "ALL", + "rows_examined_per_scan": 18, + "rows_produced_per_join": 18, + "filtered": "100.00", + "cost_info": { + "read_cost": "2.73", + "eval_cost": "1.80", + "prefix_cost": "4.53", + "data_read_per_join": "576" + }, + "used_columns": [ + "sum1", + "a" + ], + "materialized_from_subquery": { + "using_temporary_table": true, + "dependent": false, + "cacheable": true, + "query_block": { + "select_id": 2, + "cost_info": { + "query_cost": "2.05" + }, + "windowing": { + "windows": [ + { + "name": "", + "definition_position": 1, + "using_temporary_table": true, + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "count" + ] + }, + { + "name": "", + "definition_position": 2, + "last_executed_window": true, + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "sum" + ] + } + ], + "table": { + "table_name": "t", + "access_type": "ALL", + "rows_examined_per_scan": 18, + "rows_produced_per_join": 18, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "1.80", + "prefix_cost": "2.05", + "data_read_per_join": "288" + }, + "used_columns": [ + "a", + "c" + ] + } + } + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `alias`.`sum1` AS `sum1`,`alias`.`a` AS `a` from (/* select#2 */ select (count(0) OVER () + sum(`test`.`t`.`c`) OVER () ) AS `sum1`,`test`.`t`.`a` AS `a` from `test`.`t`) `alias` +Wrong result if subquery window function referenced another column in the select list +This was OK, but: +EXPLAIN FORMAT=JSON SELECT * FROM (SELECT SUM(b) OVER (), a FROM t) AS alias; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "4.52" + }, + "table": { + "table_name": "alias", + "access_type": "ALL", + "rows_examined_per_scan": 18, + "rows_produced_per_join": 18, + "filtered": "100.00", + "cost_info": { + "read_cost": "2.73", + "eval_cost": "1.80", + "prefix_cost": "4.53", + "data_read_per_join": "576" + }, + "used_columns": [ + "SUM(b) OVER ()", + "a" + ], + "materialized_from_subquery": { + "using_temporary_table": true, + "dependent": false, + "cacheable": true, + "query_block": { + "select_id": 2, + "cost_info": { + "query_cost": "2.05" + }, + "windowing": { + "windows": [ + { + "name": "", + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "sum" + ] + } + ], + "table": { + "table_name": "t", + "access_type": "ALL", + "rows_examined_per_scan": 18, + "rows_produced_per_join": 18, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "1.80", + "prefix_cost": "2.05", + "data_read_per_join": "288" + }, + "used_columns": [ + "a", + "b" + ] + } + } + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `alias`.`SUM(b) OVER ()` AS `SUM(b) OVER ()`,`alias`.`a` AS `a` from (/* select#2 */ select sum(`test`.`t`.`b`) OVER () AS `SUM(b) OVER ()`,`test`.`t`.`a` AS `a` from `test`.`t`) `alias` +this one failed with NULL as sum +EXPLAIN FORMAT=JSON SELECT * FROM (SELECT SUM(b) OVER (), b FROM t) AS alias; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "4.52" + }, + "table": { + "table_name": "alias", + "access_type": "ALL", + "rows_examined_per_scan": 18, + "rows_produced_per_join": 18, + "filtered": "100.00", + "cost_info": { + "read_cost": "2.73", + "eval_cost": "1.80", + "prefix_cost": "4.53", + "data_read_per_join": "576" + }, + "used_columns": [ + "SUM(b) OVER ()", + "b" + ], + "materialized_from_subquery": { + "using_temporary_table": true, + "dependent": false, + "cacheable": true, + "query_block": { + "select_id": 2, + "cost_info": { + "query_cost": "2.05" + }, + "windowing": { + "windows": [ + { + "name": "", + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "sum" + ] + } + ], + "table": { + "table_name": "t", + "access_type": "ALL", + "rows_examined_per_scan": 18, + "rows_produced_per_join": 18, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "1.80", + "prefix_cost": "2.05", + "data_read_per_join": "288" + }, + "used_columns": [ + "b" + ] + } + } + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `alias`.`SUM(b) OVER ()` AS `SUM(b) OVER ()`,`alias`.`b` AS `b` from (/* select#2 */ select sum(`test`.`t`.`b`) OVER () AS `SUM(b) OVER ()`,`test`.`t`.`b` AS `b` from `test`.`t`) `alias` +Window function having subquery in argument: +CREATE TABLE u(d INT); +SELECT AVG(a * (SELECT a*d FROM u)) OVER +(PARTITION BY (SELECT a+d FROM u) ORDER BY (SELECT d FROM u)) FROM t; +AVG(a * (SELECT a*d FROM u)) OVER +(PARTITION BY (SELECT a+d FROM u) ORDER BY (SELECT d FROM u)) +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +EXPLAIN FORMAT=JSON SELECT AVG(a * (SELECT a*d FROM u)) OVER +(PARTITION BY (SELECT a+d FROM u) ORDER BY (SELECT d FROM u)) FROM t; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "20.05" + }, + "windowing": { + "windows": [ + { + "name": "", + "using_filesort": true, + "filesort_key": [ + "(select (`a` + `d`) from `u`)", + "(select `d` from `u`)" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "avg" + ] + } + ], + "cost_info": { + "sort_cost": "18.00" + }, + "table": { + "table_name": "t", + "access_type": "ALL", + "rows_examined_per_scan": 18, + "rows_produced_per_join": 18, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "1.80", + "prefix_cost": "2.05", + "data_read_per_join": "288" + }, + "used_columns": [ + "a" + ] + }, + "select_list_subqueries": [ + { + "dependent": true, + "cacheable": false, + "query_block": { + "select_id": 4, + "cost_info": { + "query_cost": "0.35" + }, + "table": { + "table_name": "u", + "access_type": "ALL", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.10", + "prefix_cost": "0.35", + "data_read_per_join": "8" + }, + "used_columns": [ + "d" + ] + } + } + }, + { + "dependent": false, + "cacheable": true, + "query_block": { + "select_id": 3, + "cost_info": { + "query_cost": "0.35" + }, + "table": { + "table_name": "u", + "access_type": "ALL", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.10", + "prefix_cost": "0.35", + "data_read_per_join": "8" + }, + "used_columns": [ + "d" + ] + } + } + }, + { + "dependent": true, + "cacheable": false, + "query_block": { + "select_id": 2, + "cost_info": { + "query_cost": "0.35" + }, + "table": { + "table_name": "u", + "access_type": "ALL", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.10", + "prefix_cost": "0.35", + "data_read_per_join": "8" + }, + "used_columns": [ + "d" + ] + } + } + } + ] + } + } +} +Warnings: +Note 1276 Field or reference 'test.t.a' of SELECT #4 was resolved in SELECT #1 +Note 1276 Field or reference 'test.t.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select avg((`test`.`t`.`a` * (/* select#4 */ select (`test`.`t`.`a` * `test`.`u`.`d`) from `test`.`u`))) OVER (PARTITION BY (/* select#2 */ select (`test`.`t`.`a` + `test`.`u`.`d`) from `test`.`u`) ORDER BY (/* select#3 */ select `test`.`u`.`d` from `test`.`u`) ) AS `AVG(a * (SELECT a*d FROM u)) OVER +(PARTITION BY (SELECT a+d FROM u) ORDER BY (SELECT d FROM u))` from `test`.`t` +DROP TABLE u; +Crash due to unguarded access for window name string for an unnamed +window while producing the error message +Check that DISTINCT is not allowed in wfs +Check that GROUPS bounds unit is not supported yet +Check that EXCLUDE in frames is not supported yet +Check Nested wfs +DROP TABLE t; +Crash report (Srikanth) +CREATE TABLE t(a int, b int); +INSERT INTO t VALUES (1,1),(2,1),(3,2),(4,2),(5,3),(6,3); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +EXPLAIN FORMAT=JSON SELECT SUM(a) OVER (ORDER BY b) FROM t; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "6.85" + }, + "windowing": { + "windows": [ + { + "name": "", + "using_filesort": true, + "filesort_key": [ + "`b`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "sum" + ] + } + ], + "cost_info": { + "sort_cost": "6.00" + }, + "table": { + "table_name": "t", + "access_type": "ALL", + "rows_examined_per_scan": 6, + "rows_produced_per_join": 6, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.60", + "prefix_cost": "0.85", + "data_read_per_join": "96" + }, + "used_columns": [ + "a", + "b" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select sum(`test`.`t`.`a`) OVER (ORDER BY `test`.`t`.`b` ) AS `SUM(a) OVER (ORDER BY b)` from `test`.`t` +EXPLAIN FORMAT=JSON SELECT COUNT(*) OVER (ORDER BY b) FROM t; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "6.85" + }, + "windowing": { + "windows": [ + { + "name": "", + "using_filesort": true, + "filesort_key": [ + "`b`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "count" + ] + } + ], + "cost_info": { + "sort_cost": "6.00" + }, + "table": { + "table_name": "t", + "access_type": "ALL", + "rows_examined_per_scan": 6, + "rows_produced_per_join": 6, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.60", + "prefix_cost": "0.85", + "data_read_per_join": "96" + }, + "used_columns": [ + "b" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select count(0) OVER (ORDER BY `test`.`t`.`b` ) AS `COUNT(*) OVER (ORDER BY b)` from `test`.`t` +EXPLAIN FORMAT=JSON SELECT AVG(b) OVER (ORDER BY b) FROM t; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "6.85" + }, + "windowing": { + "windows": [ + { + "name": "", + "using_filesort": true, + "filesort_key": [ + "`b`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "avg" + ] + } + ], + "cost_info": { + "sort_cost": "6.00" + }, + "table": { + "table_name": "t", + "access_type": "ALL", + "rows_examined_per_scan": 6, + "rows_produced_per_join": 6, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.60", + "prefix_cost": "0.85", + "data_read_per_join": "96" + }, + "used_columns": [ + "b" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select avg(`test`.`t`.`b`) OVER (ORDER BY `test`.`t`.`b` ) AS `AVG(b) OVER (ORDER BY b)` from `test`.`t` +EXPLAIN FORMAT=JSON SELECT a,b,LAST_VALUE(a) OVER (ORDER BY b,a) FROM t; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "6.85" + }, + "windowing": { + "windows": [ + { + "name": "", + "using_filesort": true, + "filesort_key": [ + "`b`", + "`a`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "last_value" + ] + } + ], + "cost_info": { + "sort_cost": "6.00" + }, + "table": { + "table_name": "t", + "access_type": "ALL", + "rows_examined_per_scan": 6, + "rows_produced_per_join": 6, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.60", + "prefix_cost": "0.85", + "data_read_per_join": "96" + }, + "used_columns": [ + "a", + "b" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,last_value(`test`.`t`.`a`) OVER (ORDER BY `test`.`t`.`b`,`test`.`t`.`a` ) AS `LAST_VALUE(a) OVER (ORDER BY b,a)` from `test`.`t` +EXPLAIN FORMAT=JSON SELECT NTILE(2) OVER (ORDER BY b) FROM t; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "6.85" + }, + "windowing": { + "windows": [ + { + "name": "", + "using_filesort": true, + "filesort_key": [ + "`b`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "ntile" + ] + } + ], + "cost_info": { + "sort_cost": "6.00" + }, + "table": { + "table_name": "t", + "access_type": "ALL", + "rows_examined_per_scan": 6, + "rows_produced_per_join": 6, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.60", + "prefix_cost": "0.85", + "data_read_per_join": "96" + }, + "used_columns": [ + "b" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select ntile(2) OVER (ORDER BY `test`.`t`.`b` ) AS `NTILE(2) OVER (ORDER BY b)` from `test`.`t` +DROP TABLE t; +Wrong result (Srikanth) +CREATE TABLE t1(a INT, b INT); +INSERT INTO t1 VALUES (1,2), +(1,3); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN FORMAT=JSON SELECT a, b, COUNT(a) OVER w count, +SUM(a) OVER w sum, +AVG(a) over w average, +LAST_VALUE(a) OVER w lastval FROM t1 +WINDOW w as (PARTITION BY a ORDER BY b ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "2.45" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`a`", + "`b`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "count", + "sum", + "avg", + "last_value" + ] + } + ], + "cost_info": { + "sort_cost": "2.00" + }, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 2, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.20", + "prefix_cost": "0.45", + "data_read_per_join": "32" + }, + "used_columns": [ + "a", + "b" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,count(`test`.`t1`.`a`) OVER `w` AS `count`,sum(`test`.`t1`.`a`) OVER `w` AS `sum`,avg(`test`.`t1`.`a`) OVER `w` AS `average`,last_value(`test`.`t1`.`a`) OVER `w` AS `lastval` from `test`.`t1` window `w` AS (PARTITION BY `test`.`t1`.`a` ORDER BY `test`.`t1`.`b` ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING) +INSERT INTO t1 VALUES (1,3); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN FORMAT=JSON SELECT a, b, COUNT(a) OVER w count, +SUM(a) OVER w sum, +AVG(a) OVER w average, +LAST_VALUE(a) OVER w lastval FROM t1 +WINDOW w as (PARTITION BY a ORDER BY b ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "3.55" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`a`", + "`b`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "count", + "sum", + "avg", + "last_value" + ] + } + ], + "cost_info": { + "sort_cost": "3.00" + }, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.30", + "prefix_cost": "0.55", + "data_read_per_join": "48" + }, + "used_columns": [ + "a", + "b" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,count(`test`.`t1`.`a`) OVER `w` AS `count`,sum(`test`.`t1`.`a`) OVER `w` AS `sum`,avg(`test`.`t1`.`a`) OVER `w` AS `average`,last_value(`test`.`t1`.`a`) OVER `w` AS `lastval` from `test`.`t1` window `w` AS (PARTITION BY `test`.`t1`.`a` ORDER BY `test`.`t1`.`b` ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING) +EXPLAIN FORMAT=JSON SELECT a, b, COUNT(a) OVER w count, +SUM(a) OVER w sum, +AVG(a) OVER w average, +LAST_VALUE(a) OVER w lastval FROM t1 +WINDOW w as (PARTITION BY a ORDER BY b ROWS BETWEEN 1 PRECEDING AND 2 FOLLOWING); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "3.55" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`a`", + "`b`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "count", + "sum", + "avg", + "last_value" + ] + } + ], + "cost_info": { + "sort_cost": "3.00" + }, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.30", + "prefix_cost": "0.55", + "data_read_per_join": "48" + }, + "used_columns": [ + "a", + "b" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,count(`test`.`t1`.`a`) OVER `w` AS `count`,sum(`test`.`t1`.`a`) OVER `w` AS `sum`,avg(`test`.`t1`.`a`) OVER `w` AS `average`,last_value(`test`.`t1`.`a`) OVER `w` AS `lastval` from `test`.`t1` window `w` AS (PARTITION BY `test`.`t1`.`a` ORDER BY `test`.`t1`.`b` ROWS BETWEEN 1 PRECEDING AND 2 FOLLOWING) +DROP TABLE t1; +frame buffer navigation assert +CREATE TABLE ta (a INT(11) DEFAULT NULL, b INT(11) DEFAULT NULL); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO ta VALUES (1,1), (1,2), (1,3), (2,1), (2,2), (2,3); +ANALYZE TABLE ta; +Table Op Msg_type Msg_text +test.ta analyze status OK +EXPLAIN FORMAT=JSON SELECT last_value(b) OVER (ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM ta; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.85" + }, + "windowing": { + "windows": [ + { + "name": "", + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "last_value" + ] + } + ], + "table": { + "table_name": "ta", + "access_type": "ALL", + "rows_examined_per_scan": 6, + "rows_produced_per_join": 6, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.60", + "prefix_cost": "0.85", + "data_read_per_join": "96" + }, + "used_columns": [ + "b" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select last_value(`test`.`ta`.`b`) OVER (ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) AS `last_value(b) OVER (ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING)` from `test`.`ta` +DROP TABLE ta; +Nullability fix bug for COUNT OVER in non optimized eval strategy +CREATE TABLE t(d DOUBLE); +INSERT INTO t VALUES (1.0), (2.0), (3.0); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +EXPLAIN FORMAT=JSON SELECT SUM(d) OVER w, COUNT(*) OVER w FROM t WINDOW W AS (ROWS BETWEEN 1 FOLLOWING AND 2 FOLLOWING); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.55" + }, + "windowing": { + "windows": [ + { + "name": "W", + "frame_buffer": { + "using_temporary_table": true + }, + "functions": [ + "sum", + "count" + ] + } + ], + "table": { + "table_name": "t", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.30", + "prefix_cost": "0.55", + "data_read_per_join": "48" + }, + "used_columns": [ + "d" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select sum(`test`.`t`.`d`) OVER `W` AS `SUM(d) OVER w`,count(0) OVER `W` AS `COUNT(*) OVER w` from `test`.`t` window `W` AS (ROWS BETWEEN 1 FOLLOWING AND 2 FOLLOWING) +DROP TABLE t; +Bug in inverse logic with initial NULL and RANGE BETWEEN N FOLLOWING AND M FOLLOWING +CREATE TABLE t1 (d DOUBLE, id INT, sex CHAR(1), n INT NOT NULL AUTO_INCREMENT, PRIMARY KEY(n)); +INSERT INTO t1(d, id, sex) VALUES (1.0, 1, 'M'), +(2.0, 2, 'F'), +(3.0, 3, 'F'), +(4.0, 4, 'F'), +(5.0, 5, 'M'), +(NULL, NULL, 'M'), +(10.0, 10, NULL), +(10.0, 10, NULL), +(11.0, 11, NULL); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN FORMAT=JSON SELECT id, AVG(id) over w `avg`, SUM(id) OVER w `sum`, COUNT(*) OVER w cnt FROM t1 WINDOW w as (ORDER BY id RANGE BETWEEN 1 FOLLOWING AND 2 FOLLOWING); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "10.15" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`id`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "avg", + "sum", + "count" + ] + } + ], + "cost_info": { + "sort_cost": "9.00" + }, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 9, + "rows_produced_per_join": 9, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.90", + "prefix_cost": "1.15", + "data_read_per_join": "216" + }, + "used_columns": [ + "id", + "n" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,avg(`test`.`t1`.`id`) OVER `w` AS `avg`,sum(`test`.`t1`.`id`) OVER `w` AS `sum`,count(0) OVER `w` AS `cnt` from `test`.`t1` window `w` AS (ORDER BY `test`.`t1`.`id` RANGE BETWEEN 1 FOLLOWING AND 2 FOLLOWING) +SET windowing_use_high_precision= OFF; +EXPLAIN FORMAT=JSON SELECT d, AVG(d) over w `avg`, SUM(d) OVER w `sum`, COUNT(*) OVER w cnt FROM t1 WINDOW w as (ORDER BY d RANGE BETWEEN 1 FOLLOWING AND 2 FOLLOWING); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "10.15" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`d`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "avg", + "sum", + "count" + ] + } + ], + "cost_info": { + "sort_cost": "9.00" + }, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 9, + "rows_produced_per_join": 9, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.90", + "prefix_cost": "1.15", + "data_read_per_join": "216" + }, + "used_columns": [ + "d", + "n" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`d` AS `d`,avg(`test`.`t1`.`d`) OVER `w` AS `avg`,sum(`test`.`t1`.`d`) OVER `w` AS `sum`,count(0) OVER `w` AS `cnt` from `test`.`t1` window `w` AS (ORDER BY `test`.`t1`.`d` RANGE BETWEEN 1 FOLLOWING AND 2 FOLLOWING) +SET windowing_use_high_precision= ON; +DROP TABLE t1; +Bug in inverse logic with e.g. ROWS BETWEEN UNBOUNDED PRECEDING AND 1 +FOLLOWING: at end of partition, when no rows are removed or added we +lacked initialization of aggregates in optimized mode. +CREATE TABLE t (i char(10), j int); +INSERT INTO t VALUES('A', 1); +INSERT INTO t VALUES('A', 3); +INSERT INTO t VALUES('A', 5); +INSERT INTO t VALUES('B', 1); +INSERT INTO t VALUES('B', 7); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +EXPLAIN FORMAT=JSON SELECT i, j, SUM(j) OVER w FROM t +WINDOW w AS (PARTITION BY i ORDER BY j +ROWS BETWEEN UNBOUNDED PRECEDING AND 1 FOLLOWING); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "5.75" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`i`", + "`j`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "sum" + ] + } + ], + "cost_info": { + "sort_cost": "5.00" + }, + "table": { + "table_name": "t", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "240" + }, + "used_columns": [ + "i", + "j" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`i` AS `i`,`test`.`t`.`j` AS `j`,sum(`test`.`t`.`j`) OVER `w` AS `SUM(j) OVER w` from `test`.`t` window `w` AS (PARTITION BY `test`.`t`.`i` ORDER BY `test`.`t`.`j` ROWS BETWEEN UNBOUNDED PRECEDING AND 1 FOLLOWING) +Test definition_position: references don't count, only definitions, +thus we have an unnamed, then another unnamed (based on w but not +exactly w) then w then two unnamed. +EXPLAIN FORMAT=JSON SELECT SUM(j) OVER w, COUNT(j) OVER (), +AVG(j) OVER (w ORDER BY j), FIRST_VALUE(j) OVER w +FROM t WINDOW w AS (PARTITION BY i) +ORDER BY LAST_VALUE(j) OVER w, NTH_VALUE(j,1) OVER (), +ROW_NUMBER() OVER (PARTITION BY j); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "20.75" + }, + "ordering_operation": { + "using_filesort": true, + "cost_info": { + "sort_cost": "5.00" + }, + "windowing": { + "windows": [ + { + "name": "w", + "definition_position": 3, + "using_temporary_table": true, + "using_filesort": true, + "filesort_key": [ + "`i`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "sum", + "first_value", + "last_value" + ] + }, + { + "name": "", + "definition_position": 1, + "using_temporary_table": true, + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "count" + ] + }, + { + "name": "", + "definition_position": 2, + "using_temporary_table": true, + "using_filesort": true, + "filesort_key": [ + "`i`", + "`j`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "avg" + ] + }, + { + "name": "", + "definition_position": 4, + "using_temporary_table": true, + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "nth_value" + ] + }, + { + "name": "", + "definition_position": 5, + "last_executed_window": true, + "using_temporary_table": true, + "using_filesort": true, + "filesort_key": [ + "`j`" + ], + "functions": [ + "row_number" + ] + } + ], + "cost_info": { + "sort_cost": "15.00" + }, + "table": { + "table_name": "t", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "240" + }, + "used_columns": [ + "i", + "j" + ] + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select sum(`test`.`t`.`j`) OVER `w` AS `SUM(j) OVER w`,count(`test`.`t`.`j`) OVER () AS `COUNT(j) OVER ()`,avg(`test`.`t`.`j`) OVER (`w` ORDER BY `test`.`t`.`j` ) AS `AVG(j) OVER (w ORDER BY j)`,first_value(`test`.`t`.`j`) OVER `w` AS `FIRST_VALUE(j) OVER w` from `test`.`t` window `w` AS (PARTITION BY `test`.`t`.`i` ) order by last_value(`test`.`t`.`j`) OVER `w`,nth_value(`test`.`t`.`j`,1) OVER () ,row_number() OVER (PARTITION BY `test`.`t`.`j` ) +DROP TABLE t; +# +# Bug#26114396 WL#9603: SIG11 AT OPT_EXPLAIN_JSON_NAMESPACE::WINDOW_CTX::FORMAT_BODY +# +CREATE TABLE t1(a int,b int); +CREATE TABLE t2(a int,b int); +INSERT INTO t1 VALUES (0,1); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +INSERT INTO t2 VALUES +(2,8),(81,0),(6,7),(8,1),(4,0),(0,2),(6,5),(5,4),(0,6),(9,3), +(5,0),(6,254),(6,0),(2,7),(8,73),(9,7),(3,5),(0,5),(7,75),(2,1); +ANALYZE TABLE t2; +Table Op Msg_type Msg_text +test.t2 analyze status OK +EXPLAIN FORMAT=JSON +SELECT ROW_NUMBER() OVER () AS rn +FROM ( t1 LEFT JOIN t2 ON (t2.a <= t1 . a ) ) +WHERE t1.a = 3 +GROUP BY t1.a; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "2.60" + }, + "grouping_operation": { + "using_filesort": false, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.10", + "prefix_cost": "0.35", + "data_read_per_join": "16" + }, + "used_columns": [ + "a" + ], + "attached_condition": "(`test`.`t1`.`a` = 3)" + } + }, + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 20, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "2.00", + "prefix_cost": "2.60", + "data_read_per_join": "320" + }, + "used_columns": [ + "a" + ], + "attached_condition": "(is_not_null_compl(t2), (`test`.`t2`.`a` <= 3), true)" + } + } + ] + } + } +} +Warnings: +Note 1003 /* select#1 */ select row_number() OVER () AS `rn` from `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`a` <= 3)) where (`test`.`t1`.`a` = 3) group by `test`.`t1`.`a` +DROP TABLE t1,t2; +# +# Printing the true number of "using temporary table" +# +CREATE TABLE t1(a INT, b INT); +INSERT INTO t1 VALUES(1, 1); +FLUSH STATUS; +SELECT t1.a, SUM(t2.b) OVER(ORDER BY t1.a) FROM t1, t1 AS t2 ORDER BY t2.a; +a SUM(t2.b) OVER(ORDER BY t1.a) +1 1 +SHOW STATUS LIKE 'Created_tmp_tables'; +Variable_name Value +Created_tmp_tables 2 +EXPLAIN FORMAT=JSON SELECT t1.a, SUM(t2.b) OVER(ORDER BY t1.a) FROM t1, t1 AS t2 ORDER BY t2.a; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "2.70" + }, + "ordering_operation": { + "using_filesort": true, + "cost_info": { + "sort_cost": "1.00" + }, + "windowing": { + "windows": [ + { + "name": "", + "using_temporary_table": true, + "using_filesort": true, + "filesort_key": [ + "`a`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "sum" + ] + } + ], + "cost_info": { + "sort_cost": "1.00" + }, + "buffer_result": { + "using_temporary_table": true, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.10", + "prefix_cost": "0.35", + "data_read_per_join": "16" + }, + "used_columns": [ + "a" + ] + } + }, + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.10", + "prefix_cost": "0.70", + "data_read_per_join": "16" + }, + "used_columns": [ + "a", + "b" + ] + } + } + ] + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,sum(`test`.`t2`.`b`) OVER (ORDER BY `test`.`t1`.`a` ) AS `SUM(t2.b) OVER(ORDER BY t1.a)` from `test`.`t1` join `test`.`t1` `t2` order by `test`.`t2`.`a` +DROP TABLE t1; +# +# Bug#26612356 WINDOW FUNCTIONS: FIX COST ESTIMATES +# +CREATE TABLE t(i INT); +INSERT INTO t VALUES +(2), (3), (1), (5), (8), (4), (6), (2), (10), (16), (4), (6), (2), +(10), (16), (8), (12), (4), (20), (32), (19), (29), (9), (49), (79), +(39), (59), (19), (99), (159), (39), (59), (19), (99), (159), (79), +(119), (39), (199), (319); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +EXPLAIN FORMAT=JSON SELECT * FROM t; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "4.25" + }, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 40, + "rows_produced_per_join": 40, + "filtered": "100.00", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "4.00", + "prefix_cost": "4.25", + "data_read_per_join": "640" + }, + "used_columns": [ + "i" + ], + "query_block": { + "cost_info": { + "query_cost": "4.25" + }, + "table": { + "select_id": 2, + "table_name": "t", + "access_type": "ALL", + "rows_examined_per_scan": 40, + "rows_produced_per_join": 40, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "4.00", + "prefix_cost": "4.25", + "data_read_per_join": "320" + }, + "used_columns": [ + "i" + ] + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`i` AS `i` from `test`.`t` +EXPLAIN FORMAT=JSON SELECT * FROM t ORDER BY i; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "44.25" + }, + "ordering_operation": { + "using_filesort": true, + "cost_info": { + "sort_cost": "40.00" + }, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 40, + "rows_produced_per_join": 40, + "filtered": "100.00", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "4.00", + "prefix_cost": "4.25", + "data_read_per_join": "640" + }, + "used_columns": [ + "i" + ], + "ordering_operation": { + "using_filesort": true, + "table": { + "select_id": 2, + "table_name": "t", + "access_type": "ALL", + "rows_examined_per_scan": 40, + "rows_produced_per_join": 40, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "4.00", + "prefix_cost": "4.25", + "data_read_per_join": "320" + }, + "used_columns": [ + "i" + ] + } + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`i` AS `i` from `test`.`t` order by `test`.`t`.`i` +EXPLAIN FORMAT=JSON SELECT * FROM t GROUP BY i; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "4.25" + }, + "grouping_operation": { + "using_temporary_table": true, + "using_filesort": false, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 40, + "rows_produced_per_join": 40, + "filtered": "100.00", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "4.00", + "prefix_cost": "4.25", + "data_read_per_join": "640" + }, + "used_columns": [ + "i" + ], + "grouping_operation": { + "using_temporary_table": true, + "using_filesort": false, + "table": { + "select_id": 2, + "table_name": "t", + "access_type": "ALL", + "rows_examined_per_scan": 40, + "rows_produced_per_join": 40, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "4.00", + "prefix_cost": "4.25", + "data_read_per_join": "320" + }, + "used_columns": [ + "i" + ] + } + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`i` AS `i` from `test`.`t` group by `test`.`t`.`i` +EXPLAIN FORMAT=JSON SELECT * FROM t GROUP BY i ORDER BY i DESC; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "44.25" + }, + "ordering_operation": { + "using_filesort": false, + "grouping_operation": { + "using_temporary_table": true, + "using_filesort": true, + "cost_info": { + "sort_cost": "40.00" + }, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 40, + "rows_produced_per_join": 40, + "filtered": "100.00", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "4.00", + "prefix_cost": "4.25", + "data_read_per_join": "640" + }, + "used_columns": [ + "i" + ], + "ordering_operation": { + "using_filesort": false, + "grouping_operation": { + "using_temporary_table": true, + "using_filesort": true, + "table": { + "select_id": 2, + "table_name": "t", + "access_type": "ALL", + "rows_examined_per_scan": 40, + "rows_produced_per_join": 40, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "4.00", + "prefix_cost": "4.25", + "data_read_per_join": "320" + }, + "used_columns": [ + "i" + ] + } + } + } + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`i` AS `i` from `test`.`t` group by `test`.`t`.`i` desc order by `test`.`t`.`i` desc +EXPLAIN FORMAT=JSON SELECT ROW_NUMBER() OVER () FROM t; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "4.25" + }, + "windowing": { + "windows": [ + { + "name": "", + "functions": [ + "row_number" + ] + } + ], + "table": { + "table_name": "t", + "access_type": "ALL", + "rows_examined_per_scan": 40, + "rows_produced_per_join": 40, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "4.00", + "prefix_cost": "4.25", + "data_read_per_join": "320" + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select row_number() OVER () AS `ROW_NUMBER() OVER ()` from `test`.`t` +EXPLAIN FORMAT=JSON SELECT DISTINCT i FROM t; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "4.25" + }, + "duplicates_removal": { + "using_temporary_table": true, + "using_filesort": false, + "table": { + "table_name": "t", + "access_type": "ALL", + "rows_examined_per_scan": 40, + "rows_produced_per_join": 40, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "4.00", + "prefix_cost": "4.25", + "data_read_per_join": "320" + }, + "used_columns": [ + "i" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select distinct `test`.`t`.`i` AS `i` from `test`.`t` +EXPLAIN FORMAT=JSON SELECT DISTINCT ROW_NUMBER() OVER () FROM t; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "4.25" + }, + "duplicates_removal": { + "using_filesort": false, + "windowing": { + "windows": [ + { + "name": "", + "using_temporary_table": true, + "functions": [ + "row_number" + ] + } + ], + "table": { + "table_name": "t", + "access_type": "ALL", + "rows_examined_per_scan": 40, + "rows_produced_per_join": 40, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "4.00", + "prefix_cost": "4.25", + "data_read_per_join": "320" + } + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select distinct row_number() OVER () AS `ROW_NUMBER() OVER ()` from `test`.`t` +EXPLAIN FORMAT=JSON SELECT ROW_NUMBER() OVER () FROM t ORDER BY i; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "44.25" + }, + "ordering_operation": { + "using_filesort": true, + "cost_info": { + "sort_cost": "40.00" + }, + "windowing": { + "windows": [ + { + "name": "", + "functions": [ + "row_number" + ] + } + ], + "table": { + "table_name": "t", + "access_type": "ALL", + "rows_examined_per_scan": 40, + "rows_produced_per_join": 40, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "4.00", + "prefix_cost": "4.25", + "data_read_per_join": "320" + }, + "used_columns": [ + "i" + ] + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select row_number() OVER () AS `ROW_NUMBER() OVER ()` from `test`.`t` order by `test`.`t`.`i` +EXPLAIN FORMAT=JSON SELECT ROW_NUMBER() OVER () FROM t GROUP BY i; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "4.25" + }, + "windowing": { + "windows": [ + { + "name": "", + "functions": [ + "row_number" + ] + } + ], + "grouping_operation": { + "using_temporary_table": true, + "using_filesort": false, + "table": { + "table_name": "t", + "access_type": "ALL", + "rows_examined_per_scan": 40, + "rows_produced_per_join": 40, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "4.00", + "prefix_cost": "4.25", + "data_read_per_join": "320" + }, + "used_columns": [ + "i" + ] + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select row_number() OVER () AS `ROW_NUMBER() OVER ()` from `test`.`t` group by `test`.`t`.`i` +EXPLAIN FORMAT=JSON SELECT ROW_NUMBER() OVER (PARTITION BY i) FROM t; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "44.25" + }, + "windowing": { + "windows": [ + { + "name": "", + "using_filesort": true, + "filesort_key": [ + "`i`" + ], + "functions": [ + "row_number" + ] + } + ], + "cost_info": { + "sort_cost": "40.00" + }, + "table": { + "table_name": "t", + "access_type": "ALL", + "rows_examined_per_scan": 40, + "rows_produced_per_join": 40, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "4.00", + "prefix_cost": "4.25", + "data_read_per_join": "320" + }, + "used_columns": [ + "i" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select row_number() OVER (PARTITION BY `test`.`t`.`i` ) AS `ROW_NUMBER() OVER (PARTITION BY i)` from `test`.`t` +EXPLAIN FORMAT=JSON SELECT DISTINCT ROW_NUMBER() OVER (PARTITION BY i) FROM t; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "44.25" + }, + "duplicates_removal": { + "using_filesort": false, + "windowing": { + "windows": [ + { + "name": "", + "using_temporary_table": true, + "using_filesort": true, + "filesort_key": [ + "`i`" + ], + "functions": [ + "row_number" + ] + } + ], + "cost_info": { + "sort_cost": "40.00" + }, + "table": { + "table_name": "t", + "access_type": "ALL", + "rows_examined_per_scan": 40, + "rows_produced_per_join": 40, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "4.00", + "prefix_cost": "4.25", + "data_read_per_join": "320" + }, + "used_columns": [ + "i" + ] + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select distinct row_number() OVER (PARTITION BY `test`.`t`.`i` ) AS `ROW_NUMBER() OVER (PARTITION BY i)` from `test`.`t` +Final ORDER BY i could be eliminated +EXPLAIN FORMAT=JSON SELECT ROW_NUMBER() OVER (PARTITION BY i) FROM t ORDER BY i; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "84.25" + }, + "ordering_operation": { + "using_filesort": true, + "cost_info": { + "sort_cost": "40.00" + }, + "windowing": { + "windows": [ + { + "name": "", + "using_temporary_table": true, + "using_filesort": true, + "filesort_key": [ + "`i`" + ], + "functions": [ + "row_number" + ] + } + ], + "cost_info": { + "sort_cost": "40.00" + }, + "table": { + "table_name": "t", + "access_type": "ALL", + "rows_examined_per_scan": 40, + "rows_produced_per_join": 40, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "4.00", + "prefix_cost": "4.25", + "data_read_per_join": "320" + }, + "used_columns": [ + "i" + ] + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select row_number() OVER (PARTITION BY `test`.`t`.`i` ) AS `ROW_NUMBER() OVER (PARTITION BY i)` from `test`.`t` order by `test`.`t`.`i` +EXPLAIN FORMAT=JSON SELECT ROW_NUMBER() OVER (PARTITION BY i) FROM t ORDER BY i DESC; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "84.25" + }, + "ordering_operation": { + "using_filesort": true, + "cost_info": { + "sort_cost": "40.00" + }, + "windowing": { + "windows": [ + { + "name": "", + "using_temporary_table": true, + "using_filesort": true, + "filesort_key": [ + "`i`" + ], + "functions": [ + "row_number" + ] + } + ], + "cost_info": { + "sort_cost": "40.00" + }, + "table": { + "table_name": "t", + "access_type": "ALL", + "rows_examined_per_scan": 40, + "rows_produced_per_join": 40, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "4.00", + "prefix_cost": "4.25", + "data_read_per_join": "320" + }, + "used_columns": [ + "i" + ] + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select row_number() OVER (PARTITION BY `test`.`t`.`i` ) AS `ROW_NUMBER() OVER (PARTITION BY i)` from `test`.`t` order by `test`.`t`.`i` desc +EXPLAIN FORMAT=JSON SELECT ROW_NUMBER() OVER (PARTITION BY i), SUM(i) OVER () FROM t; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "44.25" + }, + "windowing": { + "windows": [ + { + "name": "", + "definition_position": 1, + "using_temporary_table": true, + "using_filesort": true, + "filesort_key": [ + "`i`" + ], + "functions": [ + "row_number" + ] + }, + { + "name": "", + "definition_position": 2, + "last_executed_window": true, + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "sum" + ] + } + ], + "cost_info": { + "sort_cost": "40.00" + }, + "table": { + "table_name": "t", + "access_type": "ALL", + "rows_examined_per_scan": 40, + "rows_produced_per_join": 40, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "4.00", + "prefix_cost": "4.25", + "data_read_per_join": "320" + }, + "used_columns": [ + "i" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select row_number() OVER (PARTITION BY `test`.`t`.`i` ) AS `ROW_NUMBER() OVER (PARTITION BY i)`,sum(`test`.`t`.`i`) OVER () AS `SUM(i) OVER ()` from `test`.`t` +Sorting for 2nd window redundant and skipped +EXPLAIN FORMAT=JSON SELECT ROW_NUMBER() OVER (PARTITION BY i), SUM(i) OVER (ORDER BY i) FROM t; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "44.25" + }, + "windowing": { + "windows": [ + { + "name": "", + "definition_position": 1, + "using_temporary_table": true, + "using_filesort": true, + "filesort_key": [ + "`i`" + ], + "functions": [ + "row_number" + ] + }, + { + "name": "", + "definition_position": 2, + "last_executed_window": true, + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "sum" + ] + } + ], + "cost_info": { + "sort_cost": "40.00" + }, + "table": { + "table_name": "t", + "access_type": "ALL", + "rows_examined_per_scan": 40, + "rows_produced_per_join": 40, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "4.00", + "prefix_cost": "4.25", + "data_read_per_join": "320" + }, + "used_columns": [ + "i" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select row_number() OVER (PARTITION BY `test`.`t`.`i` ) AS `ROW_NUMBER() OVER (PARTITION BY i)`,sum(`test`.`t`.`i`) OVER (ORDER BY `test`.`t`.`i` ) AS `SUM(i) OVER (ORDER BY i)` from `test`.`t` +EXPLAIN FORMAT=JSON SELECT ROW_NUMBER() OVER (PARTITION BY i), SUM(i) OVER (ORDER BY i DESC) FROM t; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "84.25" + }, + "windowing": { + "windows": [ + { + "name": "", + "definition_position": 1, + "using_temporary_table": true, + "using_filesort": true, + "filesort_key": [ + "`i`" + ], + "functions": [ + "row_number" + ] + }, + { + "name": "", + "definition_position": 2, + "last_executed_window": true, + "using_filesort": true, + "filesort_key": [ + "`i` desc" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "sum" + ] + } + ], + "cost_info": { + "sort_cost": "80.00" + }, + "table": { + "table_name": "t", + "access_type": "ALL", + "rows_examined_per_scan": 40, + "rows_produced_per_join": 40, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "4.00", + "prefix_cost": "4.25", + "data_read_per_join": "320" + }, + "used_columns": [ + "i" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select row_number() OVER (PARTITION BY `test`.`t`.`i` ) AS `ROW_NUMBER() OVER (PARTITION BY i)`,sum(`test`.`t`.`i`) OVER (ORDER BY `test`.`t`.`i` desc ) AS `SUM(i) OVER (ORDER BY i DESC)` from `test`.`t` +EXPLAIN FORMAT=JSON SELECT ROW_NUMBER() OVER (PARTITION BY i), SUM(i) OVER (ORDER BY i DESC) FROM t GROUP BY i; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "84.25" + }, + "windowing": { + "windows": [ + { + "name": "", + "definition_position": 1, + "using_temporary_table": true, + "using_filesort": true, + "filesort_key": [ + "`i`" + ], + "functions": [ + "row_number" + ] + }, + { + "name": "", + "definition_position": 2, + "last_executed_window": true, + "using_filesort": true, + "filesort_key": [ + "`i` desc" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "sum" + ] + } + ], + "cost_info": { + "sort_cost": "80.00" + }, + "grouping_operation": { + "using_temporary_table": true, + "using_filesort": false, + "table": { + "table_name": "t", + "access_type": "ALL", + "rows_examined_per_scan": 40, + "rows_produced_per_join": 40, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "4.00", + "prefix_cost": "4.25", + "data_read_per_join": "320" + }, + "used_columns": [ + "i" + ] + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select row_number() OVER (PARTITION BY `test`.`t`.`i` ) AS `ROW_NUMBER() OVER (PARTITION BY i)`,sum(`test`.`t`.`i`) OVER (ORDER BY `test`.`t`.`i` desc ) AS `SUM(i) OVER (ORDER BY i DESC)` from `test`.`t` group by `test`.`t`.`i` +EXPLAIN FORMAT=JSON SELECT ROW_NUMBER() OVER (PARTITION BY i), SUM(i) OVER (ORDER BY i DESC) FROM t GROUP BY i; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "84.25" + }, + "windowing": { + "windows": [ + { + "name": "", + "definition_position": 1, + "using_temporary_table": true, + "using_filesort": true, + "filesort_key": [ + "`i`" + ], + "functions": [ + "row_number" + ] + }, + { + "name": "", + "definition_position": 2, + "last_executed_window": true, + "using_filesort": true, + "filesort_key": [ + "`i` desc" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "sum" + ] + } + ], + "cost_info": { + "sort_cost": "80.00" + }, + "grouping_operation": { + "using_temporary_table": true, + "using_filesort": false, + "table": { + "table_name": "t", + "access_type": "ALL", + "rows_examined_per_scan": 40, + "rows_produced_per_join": 40, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "4.00", + "prefix_cost": "4.25", + "data_read_per_join": "320" + }, + "used_columns": [ + "i" + ] + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select row_number() OVER (PARTITION BY `test`.`t`.`i` ) AS `ROW_NUMBER() OVER (PARTITION BY i)`,sum(`test`.`t`.`i`) OVER (ORDER BY `test`.`t`.`i` desc ) AS `SUM(i) OVER (ORDER BY i DESC)` from `test`.`t` group by `test`.`t`.`i` +Could be optimized further to drop final ordering +EXPLAIN FORMAT=JSON SELECT ROW_NUMBER() OVER (PARTITION BY i), SUM(i) OVER (ORDER BY i DESC) FROM t GROUP BY i ORDER BY i DESC; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "124.25" + }, + "ordering_operation": { + "using_filesort": true, + "cost_info": { + "sort_cost": "40.00" + }, + "windowing": { + "windows": [ + { + "name": "", + "definition_position": 1, + "using_temporary_table": true, + "using_filesort": true, + "filesort_key": [ + "`i`" + ], + "functions": [ + "row_number" + ] + }, + { + "name": "", + "definition_position": 2, + "last_executed_window": true, + "using_temporary_table": true, + "using_filesort": true, + "filesort_key": [ + "`i` desc" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "sum" + ] + } + ], + "cost_info": { + "sort_cost": "80.00" + }, + "grouping_operation": { + "using_temporary_table": true, + "using_filesort": false, + "table": { + "table_name": "t", + "access_type": "ALL", + "rows_examined_per_scan": 40, + "rows_produced_per_join": 40, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "4.00", + "prefix_cost": "4.25", + "data_read_per_join": "320" + }, + "used_columns": [ + "i" + ] + } + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select row_number() OVER (PARTITION BY `test`.`t`.`i` ) AS `ROW_NUMBER() OVER (PARTITION BY i)`,sum(`test`.`t`.`i`) OVER (ORDER BY `test`.`t`.`i` desc ) AS `SUM(i) OVER (ORDER BY i DESC)` from `test`.`t` group by `test`.`t`.`i` desc order by `test`.`t`.`i` desc +Reordering of windows could have made it possible to eliminate final ORDER BY +EXPLAIN FORMAT=JSON SELECT ROW_NUMBER() OVER (PARTITION BY i), SUM(i) OVER (ORDER BY i DESC) FROM t GROUP BY i ORDER BY i; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "124.25" + }, + "ordering_operation": { + "using_filesort": true, + "cost_info": { + "sort_cost": "40.00" + }, + "windowing": { + "windows": [ + { + "name": "", + "definition_position": 1, + "using_temporary_table": true, + "using_filesort": true, + "filesort_key": [ + "`i`" + ], + "functions": [ + "row_number" + ] + }, + { + "name": "", + "definition_position": 2, + "last_executed_window": true, + "using_temporary_table": true, + "using_filesort": true, + "filesort_key": [ + "`i` desc" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "sum" + ] + } + ], + "cost_info": { + "sort_cost": "80.00" + }, + "grouping_operation": { + "using_temporary_table": true, + "using_filesort": false, + "table": { + "table_name": "t", + "access_type": "ALL", + "rows_examined_per_scan": 40, + "rows_produced_per_join": 40, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "4.00", + "prefix_cost": "4.25", + "data_read_per_join": "320" + }, + "used_columns": [ + "i" + ] + } + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select row_number() OVER (PARTITION BY `test`.`t`.`i` ) AS `ROW_NUMBER() OVER (PARTITION BY i)`,sum(`test`.`t`.`i`) OVER (ORDER BY `test`.`t`.`i` desc ) AS `SUM(i) OVER (ORDER BY i DESC)` from `test`.`t` group by `test`.`t`.`i` order by `test`.`t`.`i` +Implicit grouping should eliminate windowing ordering costs: only one row +EXPLAIN FORMAT=JSON SELECT ROW_NUMBER() OVER (ORDER BY AVG(i)) AS rn FROM t; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "4.25" + }, + "table": { + "table_name": "t", + "access_type": "ALL", + "rows_examined_per_scan": 40, + "rows_produced_per_join": 40, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "4.00", + "prefix_cost": "4.25", + "data_read_per_join": "320" + }, + "used_columns": [ + "i" + ] + } + } +} +Warnings: +Note 1003 /* select#1 */ select row_number() OVER (ORDER BY avg(`test`.`t`.`i`) ) AS `rn` from `test`.`t` +Used to miss printing the sorting key +EXPLAIN FORMAT=JSON SELECT ROW_NUMBER() OVER (PARTITION BY i) FROM t; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "44.25" + }, + "windowing": { + "windows": [ + { + "name": "", + "using_filesort": true, + "filesort_key": [ + "`i`" + ], + "functions": [ + "row_number" + ] + } + ], + "cost_info": { + "sort_cost": "40.00" + }, + "table": { + "table_name": "t", + "access_type": "ALL", + "rows_examined_per_scan": 40, + "rows_produced_per_join": 40, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "4.00", + "prefix_cost": "4.25", + "data_read_per_join": "320" + }, + "used_columns": [ + "i" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select row_number() OVER (PARTITION BY `test`.`t`.`i` ) AS `ROW_NUMBER() OVER (PARTITION BY i)` from `test`.`t` +Test optimizer trace with window costs +SET optimizer_trace="enabled=on"; +SELECT ROW_NUMBER() OVER (PARTITION BY i), SUM(i) OVER (ORDER BY i DESC) FROM t GROUP BY i ORDER BY i; +ROW_NUMBER() OVER (PARTITION BY i) SUM(i) OVER (ORDER BY i DESC) +1 1297 +1 1296 +1 1294 +1 1291 +1 1287 +1 1282 +1 1276 +1 1268 +1 1259 +1 1249 +1 1237 +1 1221 +1 1202 +1 1182 +1 1153 +1 1121 +1 1082 +1 1033 +1 974 +1 895 +1 796 +1 677 +1 518 +1 319 +SELECT REGEXP_SUBSTR(TRACE, 'join_optimization.*', 1, 1, 'n') FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +REGEXP_SUBSTR(TRACE, 'join_optimization.*', 1, 1, 'n') +join_optimization": { + "select#": 1, + "steps": [ + { + "substitute_generated_columns": { + } + }, + { + "table_dependencies": [ + { + "table": "`t`", + "row_may_be_null": false, + "map_bit": 0, + "depends_on_map_bits": [ + ] + } + ] + }, + { + "rows_estimation": [ + { + "table": "`t`", + "table_scan": { + "rows": 40, + "cost": 0.25 + } + } + ] + }, + { + "considered_execution_plans": [ + { + "plan_prefix": [ + ], + "table": "`t`", + "best_access_path": { + "considered_access_paths": [ + { + "rows_to_scan": 40, + "access_type": "scan", + "resulting_rows": 40, + "cost": 4.25, + "chosen": true, + "use_tmp_table": true + } + ] + }, + "condition_filtering_pct": 100, + "rows_for_plan": 40, + "cost_for_plan": 4.25, + "sort_cost": 40, + "new_cost_for_plan": 44.25, + "chosen": true, + "windowing_sort_cost": 80, + "new_cost_for_plan": 124.25 + } + ] + }, + { + "attaching_conditions_to_tables": { + "original_condition": null, + "attached_conditions_computation": [ + ], + "attached_conditions_summary": [ + { + "table": "`t`", + "attached": null + } + ] + } + }, + { + "optimizing_distinct_group_by_order_by": { + "simplifying_order_by": { + "original_clause": "`t`.`i`", + "items": [ + { + "item": "`t`.`i`" + } + ], + "resulting_clause_is_simple": true, + "resulting_clause": "`t`.`i`" + }, + "simplifying_group_by": { + "original_clause": "`t`.`i`", + "items": [ + { + "item": "`t`.`i`" + } + ], + "resulting_clause_is_simple": false, + "resulting_clause": "`t`.`i`" + } + } + }, + { + "finalizing_table_conditions": [ + ] + }, + { + "refine_plan": [ + { + "table": "`t`" + } + ] + }, + { + "considering_tmp_tables": [ + { + "adding_tmp_table_in_plan_at_position": 1, + "write_method": "write_all_rows" + }, + { + "adding_tmp_table_in_plan_at_position": 2, + "cause": "output_for_window_functions", + "with_buffer": false, + "write_method": "write_all_rows", + "adding_sort_to_previous_table": { + "filesort": { + "adding_sort_to_table": "" + } + } + }, + { + "creating_tmp_table": { + "tmp_table_info": { + "table": "intermediate_tmp_table", + "columns": 6, + "row_length": 29, + "key_length": 0, + "unique_constraint": false, + "makes_grouped_rows": false, + "cannot_insert_duplicates": false, + "location": "TempTable" + } + } + }, + { + "adding_tmp_table_in_plan_at_position": 3, + "cause": "output_for_window_functions", + "with_buffer": true, + "write_method": "write_all_rows", + "adding_sort_to_previous_table": { + "filesort": { + "adding_sort_to_table": "" + } + }, + "filesort": { + "adding_sort_to_table": "" + } + } + ] + } + ] + } + }, + { + "join_execution": { + "select#": 1, + "steps": [ + { + "creating_tmp_table": { + "tmp_table_info": { + "in_plan_at_position": 3, + "columns": 7, + "row_length": 45, + "key_length": 0, + "unique_constraint": false, + "makes_grouped_rows": false, + "cannot_insert_duplicates": false, + "location": "TempTable" + } + } + }, + { + "materialize": { + "select#": 1, + "steps": [ + { + "creating_tmp_table": { + "tmp_table_info": { + "in_plan_at_position": 2, + "columns": 6, + "row_length": 29, + "key_length": 0, + "unique_constraint": false, + "makes_grouped_rows": false, + "cannot_insert_duplicates": false, + "location": "TempTable" + } + } + }, + { + "materialize": { + "select#": 1, + "steps": [ + { + "creating_tmp_table": { + "tmp_table_info": { + "in_plan_at_position": 1, + "columns": 5, + "row_length": 22, + "key_length": 5, + "unique_constraint": false, + "makes_grouped_rows": true, + "cannot_insert_duplicates": false, + "location": "TempTable" + } + } + }, + { + "materialize": { + "select#": 1, + "steps": [ + ] + } + }, + { + "sorting_table": "", + "filesort_information": [ + { + "direction": "asc", + "expression": "`t`.`i`" + } + ], + "filesort_priority_queue_optimization": { + "usable": false, + "cause": "not applicable (no LIMIT)" + }, + "filesort_execution": [ + ], + "filesort_summary": { + "memory_available": 262144, + "key_size": "XXX", + "row_size": "XXX", + "max_rows_per_buffer": "NNN", + "num_rows_estimate": 40, + "num_rows_found": 24, + "num_initial_chunks_spilled_to_disk": 0, + "peak_memory_used": "NNN", + "sort_algorithm": "std::stable_sort", + "sort_mode": "" + } + } + ] + } + }, + { + "sorting_table": "", + "filesort_information": [ + { + "direction": "desc", + "expression": "`t`.`i`" + } + ], + "filesort_priority_queue_optimization": { + "usable": false, + "cause": "not applicable (no LIMIT)" + }, + "filesort_execution": [ + ], + "filesort_summary": { + "memory_available": 262144, + "key_size": "XXX", + "row_size": "XXX", + "max_rows_per_buffer": "NNN", + "num_rows_estimate": 15, + "num_rows_found": 24, + "num_initial_chunks_spilled_to_disk": 0, + "peak_memory_used": "NNN", + "sort_algorithm": "std::stable_sort", + "sort_mode": "" + } + } + ] + } + }, + { + "sorting_table": "", + "filesort_information": [ + { + "direction": "asc", + "expression": "`t`.`i`" + } + ], + "filesort_priority_queue_optimization": { + "usable": false, + "cause": "not applicable (no LIMIT)" + }, + "filesort_execution": [ + ], + "filesort_summary": { + "memory_available": 262144, + "key_size": "XXX", + "row_size": "XXX", + "max_rows_per_buffer": "NNN", + "num_rows_estimate": 15, + "num_rows_found": 24, + "num_initial_chunks_spilled_to_disk": 0, + "peak_memory_used": "NNN", + "sort_algorithm": "std::sort", + "sort_mode": "" + } + } + ] + } + } + ] +} +SET optimizer_trace="enabled=off"; +DROP TABLE t; diff --git a/mysql-test/r/with_grant.result-pq b/mysql-test/r/with_grant.result-pq new file mode 100644 index 000000000000..e3eae4b054af --- /dev/null +++ b/mysql-test/r/with_grant.result-pq @@ -0,0 +1,55 @@ +# privileges +create database mysqltest1; +use mysqltest1; +create table t1(pub int, priv int); +insert into t1 values(1,2); +analyze table t1; +Table Op Msg_type Msg_text +mysqltest1.t1 analyze status OK +CREATE USER user1@localhost; +GRANT SELECT (pub) ON mysqltest1.t1 TO user1@localhost; +use mysqltest1; +select pub from t1; +pub +1 +select priv from t1; +ERROR 42000: SELECT command denied to user 'user1'@'localhost' for column 'priv' in table 't1' +select * from (select pub from t1) as dt; +pub +1 +explain select * from (select pub from t1) as dt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `mysqltest1`.`t1`.`pub` AS `pub` from `mysqltest1`.`t1` +select /*+ merge(dt) */ * from (select priv from t1) as dt; +ERROR 42000: SELECT command denied to user 'user1'@'localhost' for column 'priv' in table 't1' +select /*+ no_merge(dt) */ * from (select priv from t1) as dt; +ERROR 42000: SELECT command denied to user 'user1'@'localhost' for column 'priv' in table 't1' +explain select * from (select priv from t1) as dt; +ERROR 42000: SELECT command denied to user 'user1'@'localhost' for column 'priv' in table 't1' +with qn as (select pub from t1) select * from qn; +pub +1 +explain with qn as (select pub from t1) select * from qn; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `mysqltest1`.`t1`.`pub` AS `pub` from `mysqltest1`.`t1` +with qn as (select priv from t1) select /*+ merge(qn) */ * from qn; +ERROR 42000: SELECT command denied to user 'user1'@'localhost' for column 'priv' in table 't1' +with qn as (select priv from t1) select /*+ no_merge(qn) */ * from qn; +ERROR 42000: SELECT command denied to user 'user1'@'localhost' for column 'priv' in table 't1' +explain with qn as (select priv from t1) select * from qn; +ERROR 42000: SELECT command denied to user 'user1'@'localhost' for column 'priv' in table 't1' +with qn2 as (with qn as (select pub from t1) select * from qn) +select * from qn2; +pub +1 +with qn2 as (with qn as (select priv from t1) select * from qn) +select * from qn2; +ERROR 42000: SELECT command denied to user 'user1'@'localhost' for column 'priv' in table 't1' +drop user user1@localhost; +drop database mysqltest1; diff --git a/mysql-test/r/with_non_recursive.result-pq b/mysql-test/r/with_non_recursive.result-pq new file mode 100644 index 000000000000..74e488487ad6 --- /dev/null +++ b/mysql-test/r/with_non_recursive.result-pq @@ -0,0 +1,2232 @@ +# In-memory tmp tables +set big_tables=0; +# WL#883 Non-recursive WITH clause (common table expression) +flush status; +create table t1(a int, b int, c int); +insert into t1 values(null,null,null),(2,3,4); +WITH qn AS (SELECT a FROM t1) +SELECT 1 FROM dual; +1 +1 +# two query names +WITH qn AS (SELECT a FROM t1), qn2 as (select b from t1) +SELECT 1 FROM dual; +1 +1 +# duplicate query names +WITH qn AS (SELECT a FROM t1), qn as (select b from t1) +SELECT 1 FROM qn; +ERROR 42000: Not unique table/alias: 'qn' +# multiple refs +WITH qn AS (SELECT b as a FROM t1) +SELECT qn.a, qn2.a FROM qn, qn as qn2; +a a +3 3 +3 NULL +NULL 3 +NULL NULL +WITH qn AS (SELECT b as a FROM t1), +qn2 AS (SELECT c FROM t1 WHERE a IS NULL or a>0) +SELECT qn.a, qn2.c FROM qn, qn2; +a c +3 4 +3 NULL +NULL 4 +NULL NULL +# qn2 ref qn: +WITH qn AS (SELECT 10*a as a FROM t1), +qn2 AS (SELECT 3*a FROM qn) +SELECT * from qn2; +3*a +NULL +60 +WITH qn AS (SELECT a FROM t1), qn2 AS (SELECT a FROM qn) +SELECT * from qn2; +a +NULL +2 +WITH qn AS (SELECT b as a FROM t1), +qn2 AS (SELECT a FROM qn WHERE a IS NULL or a>0) +SELECT qn.a, qn2.a FROM qn, qn2; +a a +3 3 +3 NULL +NULL 3 +NULL NULL +EXPLAIN WITH qn AS (SELECT b as a FROM t1), +qn2 AS (SELECT a FROM qn WHERE a IS NULL or a>0) +SELECT qn.a, qn2.a FROM qn, qn2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 75.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 75.00 Using where +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`b` AS `a`,`test`.`t1`.`b` AS `a` from `test`.`t1` join `test`.`t1` where ((`test`.`t1`.`b` is null) or (`test`.`t1`.`b` > 0)) +# forward ref (should error) +WITH qn2 AS (SELECT a FROM qn WHERE a IS NULL or a>0), +qn AS (SELECT b as a FROM t1) +SELECT qn2.a FROM qn2; +ERROR 42S02: Table 'test.qn' doesn't exist +with qn1 as (with qn3 as (select * from qn2) select * from qn3), +qn2 as (select 1) +select * from qn1; +ERROR 42S02: Table 'test.qn2' doesn't exist +# This is valid; it is to test moving boundaries. +# When we resolve qn3, resolving qn1 moves the right bound to +# qn0, but the bound is properly restored so that we can later +# resolve qn2. +with qn0 as (select 1), qn1 as (select * from qn0), qn2 as (select 1), qn3 as (select 1 from qn1, qn2) select 1 from qn3; +1 +1 +# No ref +explain with qn as (select 1) select 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 /* select#1 */ select 2 AS `2` +with qn as (select 1) select 2; +2 +2 +# circular ref +WITH qn2 AS (SELECT a FROM qn WHERE a IS NULL or a>0), +qn AS (SELECT b as a FROM qn2) +SELECT qn.a FROM qn; +ERROR 42S02: Table 'test.qn' doesn't exist +# recursive +WITH qn AS (SELECT a FROM qn) +SELECT qn.a FROM qn; +ERROR 42S02: Table 'test.qn' doesn't exist +WITH qn1 AS (SELECT a FROM qn3), +qn2 AS (SELECT a FROM qn1), +qn3 AS (SELECT a FROM t1), +qn4 AS (SELECT a FROM qn2) +SELECT a FROM qn4; +ERROR 42S02: Table 'test.qn3' doesn't exist +# ref from subq +with qn as (select * from t1) select (select max(a) from qn); +(select max(a) from qn) +2 +# QN defined in subq +SELECT (WITH qn AS (SELECT 10*a as a FROM t1), +qn2 AS (SELECT 3*a AS b FROM qn) +SELECT * from qn2 LIMIT 1) +FROM t1; +(WITH qn AS (SELECT 10*a as a FROM t1), +qn2 AS (SELECT 3*a AS b FROM qn) +SELECT * from qn2 LIMIT 1) +NULL +NULL +SELECT * +FROM (WITH qn AS (SELECT 10*a as a FROM t1), +qn2 AS (SELECT 3*a AS b FROM qn) +SELECT * from qn2) +AS dt; +b +NULL +60 +# WITH in WITH +with qn as +(with qn2 as (select "qn2" as a from t1) select "qn", a from qn2) +select * from qn; +qn a +qn qn2 +qn qn2 +# outer ref to a table, placed in a QN in a subq (later) +# QN defined in view +CREATE VIEW v AS +WITH qn AS (SELECT 10*a as a FROM t1), +qn2 AS (SELECT 3*a AS b FROM qn) +SELECT * from qn2; +SELECT * FROM v; +b +NULL +60 +DROP VIEW v; +# CREATE INSERT SELECT +CREATE TABLE t2 +WITH qn AS (SELECT 10*a as a FROM t1), +qn2 AS (SELECT 3*a AS b FROM qn) +SELECT * from qn2; +SELECT * FROM t2; +b +NULL +60 +INSERT INTO t2 +WITH qn AS (SELECT 10*a as a FROM t1), +qn2 AS (SELECT 3*a AS b FROM qn) +SELECT * from qn2; +SELECT * FROM t2; +b +NULL +60 +NULL +60 +DROP TABLE t2; +# Double use of QN in two subqueries. +explain with qn as (select * from t1 limit 10) +select (select max(a) from qn where a=0), +(select min(b) from qn where b=3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +4 SUBQUERY NULL ref 5 const 1 100.00 NULL +2 SUBQUERY NULL ref 5 const 1 100.00 NULL +3 DERIVED t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 with `qn` as (/* select#3 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` limit 10) /* select#1 */ select (/* select#2 */ select max(`qn`.`a`) from `qn` where (`qn`.`a` = 0)) AS `(select max(a) from qn where a=0)`,(/* select#4 */ select min(`qn`.`b`) from `qn` where (`qn`.`b` = 3)) AS `(select min(b) from qn where b=3)` +with qn as (select * from t1 limit 10) +select (select max(a) from qn where a=0), +(select min(b) from qn where b=3); +(select max(a) from qn where a=0) (select min(b) from qn where b=3) +NULL 3 +# when QN, when table. +create table qn select "base"; +select * from qn; +base +base +with qn as (select "with") select * from qn; +with +with +# In a non-recursive WITH, the scope of the QN doesn't extend to its +# subquery, so "qn" inside AS() is the base table. +WITH qn AS (select * from qn) select * from qn; +base +base +# View doesn't look out to external QNs +create view v as select * from qn; +select * from v; +base +base +with qn as (select "with") select * from v; +base +base +with qn as (select * from v) select * from qn; +base +base +# Even if the base table is temporarily dropped +drop table qn; +with qn as (select "with") select * from v; +ERROR HY000: View 'test.v' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +with qn as (select * from v) select * from qn; +ERROR HY000: View 'test.v' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +create table qn select "base" as a; +# Neither does SP +create function f() returns varchar(10) +return (select * from qn); +select f(); +f() +base +with qn as (select "with") select f(); +f() +base +with qn as (select f()) select * from qn; +f() +base +# QN shadows tmp table +create temporary table qn select "tmp" as a; +select * from qn; +a +tmp +with qn as (select "with") select * from qn; +with +with +drop function f; +drop view v; +# DT shadows QN: +with qn as (select "with") select * from (select "dt") as qn; +dt +dt +# QN of subq shadows outer QN +WITH qn AS (select "outer" as a) +SELECT (WITH qn AS (SELECT "inner" as a) SELECT a from qn), +qn.a +FROM qn; +(WITH qn AS (SELECT "inner" as a) SELECT a from qn) a +inner outer +# Qualified name isn't allowed after WITH: +with test.qn as (select "with") select * from test.qn; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '.qn as (select "with") select * from test.qn' at line 1 +# Adding a db. prefix to a field still resolves to the QN; it's a bit awkward as +# the QN doesn't belong to a db, but it's the same with derived table: +select test.qn.a from (select "with" as a) qn; +a +with +# OTOH, db. prefix in FROM doesn't resolve to QN, which is good +with qn as (select "with") select * from qn; +with +with +with qn as (select "with") select * from test.qn; +a +tmp +with qn as (select "with" as a) select a from qn; +a +with +with qn as (select "with" as a) select qn.a from qn; +a +with +with qn as (select "with" as a) select test.qn.a from qn; +a +with +with qn as (select "with" as a) select a from test.qn; +a +tmp +with qn as (select "with" as a) select qn.a from test.qn; +a +tmp +with qn as (select "with" as a) select test.qn.a from test.qn; +a +tmp +drop temporary table qn; +with qn as (select "with" as a) select a from test.qn; +a +base +with qn as (select "with" as a) select qn.a from test.qn; +a +base +with qn as (select "with" as a) select test.qn.a from test.qn; +a +base +drop table qn; +with qn as (select "with" as a) select a from test.qn; +ERROR 42S02: Table 'test.qn' doesn't exist +with qn as (select "with" as a) select qn.a from test.qn; +ERROR 42S02: Table 'test.qn' doesn't exist +with qn as (select "with" as a) select test.qn.a from test.qn; +ERROR 42S02: Table 'test.qn' doesn't exist +# Unions +WITH qn AS (SELECT b as a FROM t1 UNION SELECT b+5 FROM t1), +qn2 AS (SELECT a FROM qn WHERE a IS NULL or a>0) +SELECT qn.a FROM qn +UNION SELECT qn2.a FROM qn2 WHERE qn2.a>3; +a +NULL +3 +8 +# No double WITH +with qn as (select "with" as a) +with qn2 as (select "with" as a) +select a from test.qn; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'with qn2 as (select "with" as a) +select a from test.qn' at line 2 +# with comma +with qn as (select "with" as a), +with qn2 as (select "with" as a) +select a from test.qn; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'with qn2 as (select "with" as a) +select a from test.qn' at line 2 +# ORDER BY removed unless there is LIMIT or single table (check "Using filesort") +explain +with qn as (select a from t1 order by 1) +select a from qn; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` order by `qn`.`a` +explain +with qn as (select a from t1 order by 1) +select qn.a from qn, t1 as t2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` join `test`.`t1` `t2` +explain +with qn as (select a from t1 order by 1 limit 10) +select qn.a from qn, t1 as t2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +2 DERIVED t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using filesort +Warnings: +Note 1003 with `qn` as (/* select#2 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` order by `test`.`t1`.`a` limit 10) /* select#1 */ select `qn`.`a` AS `a` from `qn` join `test`.`t1` `t2` +# Merge hint +explain +with qn as (select a from t1), +qn2 as (select b from t1) +select /*+ merge(qn) no_merge(qn2) */ qn.a,qn2.b from qn, qn2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +3 DERIVED t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 with `qn2` as (/* select#3 */ select `test`.`t1`.`b` AS `b` from `test`.`t1`) /* select#1 */ select /*+ MERGE(`qn`@`select#1`) NO_MERGE(`qn2`@`select#1`) */ `test`.`t1`.`a` AS `a`,`qn2`.`b` AS `b` from `test`.`t1` join `qn2` +explain +with qn as (select a from t1) +select /*+ merge(qn) no_merge(qn2) */ qn2.a from qn, qn as qn2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +3 DERIVED t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 with `qn` as (/* select#3 */ select `test`.`t1`.`a` AS `a` from `test`.`t1`) /* select#1 */ select /*+ MERGE(`qn`@`select#1`) NO_MERGE(`qn2`@`select#1`) */ `qn2`.`a` AS `a` from `test`.`t1` join `qn` `qn2` +# FD detection +with qn as (select a, b from t1) +select b from qn group by a; +ERROR 42000: Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'qn.b' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +with qn as (select a, b from t1 where a=b) +select b from qn group by a; +b +with qn as (select a, sum(b) as s from t1 group by a) +select s from qn group by a; +s +NULL +3 +# CTEs work if used in SET +set @myvar= +(with qn as (select a, sum(b) as s from t1 group by a) +select s from qn group by a having s is not null); +select @myvar; +@myvar +3 +# CTE works with semijoin +explain with cte as (select * from t1 as t2 limit 1) +select * from t1 where t1.a in (select a+0 from cte); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 PRIMARY NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1); Using join buffer (hash join) +3 DERIVED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 with `cte` as (/* select#3 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c` from `test`.`t1` `t2` limit 1) /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` semi join (`cte`) where (`test`.`t1`.`a` = (`cte`.`a` + 0)) +with cte as (select * from t1 as t2 limit 1) +select * from t1 where t1.a in (select a+0 from cte); +a b c +explain with cte as (select * from t1 as t2) +select * from t1 where t1.a in (select a+0 from cte); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch(t1); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` semi join (`test`.`t1` `t2`) where (`test`.`t1`.`a` = (`test`.`t2`.`a` + 0)) +with cte as (select * from t1 as t2) +select * from t1 where t1.a in (select a+0 from cte); +a b c +2 3 4 +# Column names +# empty list +with qn () as (select 1) select * from qn, qn qn1; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ') as (select 1) select * from qn, qn qn1' at line 1 +# Materialization +with qn (foo, bar) as (select 1) select * from qn, qn qn1; +ERROR HY000: In definition of view, derived table or common table expression, SELECT list and column names list have different column counts +explain with qn (foo, bar) as (select 1, 2 from t1 limit 2) select * from qn, qn qn1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +2 DERIVED t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 with `qn` (`foo`,`bar`) as (/* select#2 */ select 1 AS `1`,2 AS `2` from `test`.`t1` limit 2) /* select#1 */ select `qn`.`foo` AS `foo`,`qn`.`bar` AS `bar`,`qn1`.`foo` AS `foo`,`qn1`.`bar` AS `bar` from `qn` join `qn` `qn1` +with qn (foo, bar) as (select 1, 2 from t1 limit 2) select * from qn, qn qn1; +foo bar foo bar +1 2 1 2 +1 2 1 2 +1 2 1 2 +1 2 1 2 +with qn (foo, bar) as (select 1 as col, 2 as coll from t1 limit 2) select * from qn, qn qn1; +foo bar foo bar +1 2 1 2 +1 2 1 2 +1 2 1 2 +1 2 1 2 +with qn (foo, bar) as (select 1 as col, 2 as coll union +select a,b from t1) select qn1.bar from qn qn1; +bar +2 +NULL +3 +with qn (foo, bar) as (select a, b from t1 limit 2) select qn.bar,foo from qn; +bar foo +NULL NULL +3 2 +create table t3 +with qn (foo, bar) as (select a, b from t1 limit 2) select bar,foo from qn; +desc t3; +Field Type Null Key Default Extra +bar int YES NULL +foo int YES NULL +drop table t3; +# Merge +with qn (foo, bar) as (select 1 from t1) select * from qn, qn qn1; +ERROR HY000: In definition of view, derived table or common table expression, SELECT list and column names list have different column counts +with qn (foo, bar) as (select 1, 2 from t1) select * from qn, qn qn1; +foo bar foo bar +1 2 1 2 +1 2 1 2 +1 2 1 2 +1 2 1 2 +explain with qn (foo, bar) as (select 1, 2 from t1) select * from qn, qn qn1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select 1 AS `foo`,2 AS `bar`,1 AS `foo`,2 AS `bar` from `test`.`t1` join `test`.`t1` +with qn (foo, bar) as (select 1 as col, 2 as coll from t1) select * from qn, qn qn1; +foo bar foo bar +1 2 1 2 +1 2 1 2 +1 2 1 2 +1 2 1 2 +with qn (foo, bar) as (select a, b from t1) select qn1.bar,foo from qn qn1; +bar foo +NULL NULL +3 2 +create table t3 +with qn (foo, bar) as (select a, b from t1) select bar,foo from qn; +desc t3; +Field Type Null Key Default Extra +bar int YES NULL +foo int YES NULL +drop table t3; +# Disambiguates same-name expressions +with qn as (select 1,1) select * from qn; +ERROR 42S21: Duplicate column name '1' +with qn (foo, bar) as (select 1,1) select * from qn; +foo bar +1 1 +with qn as (select 1,1 from t1) select * from qn; +ERROR 42S21: Duplicate column name '1' +with qn (foo, bar) as (select 1,1 from t1) select * from qn; +foo bar +1 1 +1 1 +# Duplicate names are forbidden +with qn (foo, foo) as (select 1,2) select * from qn; +ERROR 42S21: Duplicate column name 'foo' +# Derived tables support this too +select * from (select '1', 1) dt(foo,bar); +foo bar +1 1 +select * from (select a,b from t1) dt(foo,bar); +foo bar +NULL NULL +2 3 +select * from (select a from t1) dt(foo,bar); +ERROR HY000: In definition of view, derived table or common table expression, SELECT list and column names list have different column counts +# Column names for QN/DT are printed +create view v1 as +with qn (foo, bar) as (select 1,1) select * from qn; +show create view v1; +View Create View character_set_client collation_connection +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS with `qn` (`foo`,`bar`) as (select 1 AS `1`,1 AS `1`) select `qn`.`foo` AS `foo`,`qn`.`bar` AS `bar` from `qn` utf8mb4 utf8mb4_0900_ai_ci +show fields from v1; +Field Type Null Key Default Extra +foo int NO 0 +bar int NO 0 +select * from v1; +foo bar +1 1 +drop view v1; +create view v1 as +select * from (select 1,1) dt(foo,bar); +show create view v1; +View Create View character_set_client collation_connection +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `dt`.`foo` AS `foo`,`dt`.`bar` AS `bar` from (select 1 AS `1`,1 AS `1`) `dt` (`foo`,`bar`) utf8mb4 utf8mb4_0900_ai_ci +select * from v1; +foo bar +1 1 +drop view v1; +create view v1 as +with qn (foo, bar) as (select 1,1 from t1) select * from qn; +show create view v1; +View Create View character_set_client collation_connection +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS with `qn` (`foo`,`bar`) as (select 1 AS `1`,1 AS `1` from `t1`) select `qn`.`foo` AS `foo`,`qn`.`bar` AS `bar` from `qn` utf8mb4 utf8mb4_0900_ai_ci +select * from v1; +foo bar +1 1 +1 1 +drop view v1; +create view v1 as +select * from (select 1,1 from t1) dt(foo,bar); +show create view v1; +View Create View character_set_client collation_connection +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `dt`.`foo` AS `foo`,`dt`.`bar` AS `bar` from (select 1 AS `1`,1 AS `1` from `t1`) `dt` (`foo`,`bar`) utf8mb4 utf8mb4_0900_ai_ci +select * from v1; +foo bar +1 1 +1 1 +drop view v1; +# printing with back-quoting is necessary, when using a +# reserved word as column name. +create view v1 as +select * from (select 1) dt(`select`); +show create view v1; +View Create View character_set_client collation_connection +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `dt`.`select` AS `select` from (select 1 AS `1`) `dt` (`select`) utf8mb4 utf8mb4_0900_ai_ci +select * from v1; +select +1 +drop view v1; +# Works for views too. Using testcase of: +# Bug#23265335 SPECIFYING A NAME FOR VIEW'S COLUMN IN CREATE VIEW MAKES SELECT FAIL +create view v1 (bar) as +select 1 as foo group by foo union select 2 order by foo; +select * from v1; +bar +1 +2 +show create view v1; +View Create View character_set_client collation_connection +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` (`bar`) AS select 1 AS `foo` group by `foo` union select 2 AS `2` order by `foo` utf8mb4 utf8mb4_0900_ai_ci +# The column's name for the view +select TABLE_NAME,COLUMN_NAME from information_schema.columns +where TABLE_SCHEMA='test' and TABLE_NAME='v1'; +TABLE_NAME COLUMN_NAME +v1 bar +# is different from the alias in the defining SELECT +select VIEW_DEFINITION from information_schema.views +where TABLE_SCHEMA='test' and TABLE_NAME='v1'; +VIEW_DEFINITION +select 1 AS `foo` group by `foo` union select 2 AS `2` order by `foo` +drop view v1; +create view v1 (bar) as +select 1, 2 from t1; +ERROR HY000: In definition of view, derived table or common table expression, SELECT list and column names list have different column counts +drop table t1; +# Prove that a materialized QN is shared among all references: +create table t1(a int); +insert into t1 values(1),(2),(3),(4); +flush status; +with qn as (select 123 as col) +select * from qn; +col +123 +show status like "handler_write"; +Variable_name Value +Handler_write 1 +flush status; +with qn as (select 123 as col) +select * from qn, qn as qn1; +col col +123 123 +show status like "handler_write"; +Variable_name Value +Handler_write 1 +create view qn as select 123 as col; +flush status; +select * from qn, qn as qn1; +col col +123 123 +show status like "handler_write"; +Variable_name Value +Handler_write 2 +drop view qn; +drop table t1; +# Printing of WITH to DD for view +create view v as +select (with qn as (select "with") select * from qn) as scal_subq +from dual; +show create view v; +View Create View character_set_client collation_connection +v CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v` AS select (with `qn` as (select 'with' AS `with`) select `qn`.`with` from `qn`) AS `scal_subq` utf8mb4 utf8mb4_0900_ai_ci +select * from v; +scal_subq +with +drop view v; +create view v as select * from (with qn as (select "with") select * from qn) as dt; +show create view v; +View Create View character_set_client collation_connection +v CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v` AS select `dt`.`with` AS `with` from (with `qn` as (select 'with' AS `with`) select `qn`.`with` AS `with` from `qn`) `dt` utf8mb4 utf8mb4_0900_ai_ci +select * from v; +with +with +drop view v; +# Printing of merged/materialized QN, with or without alias +create table t1 (a int); +explain with qne as (select a from t1), +qnm as (select a from t1), +qnea as (select a from t1), +qnma as (select a from t1) +select /*+ merge(qne) no_merge(qnm) merge(alias1) no_merge(alias2) */ +qne.a,qnm.a,alias1.a,alias2.a +from qne, qnm, qnea as alias1, qnma as alias2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using join buffer (hash join) +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +5 DERIVED t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +3 DERIVED t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 with `qnm` as (/* select#3 */ select `test`.`t1`.`a` AS `a` from `test`.`t1`), `qnma` as (/* select#5 */ select `test`.`t1`.`a` AS `a` from `test`.`t1`) /* select#1 */ select /*+ MERGE(`qne`@`select#1`) NO_MERGE(`qnm`@`select#1`) MERGE(`alias1`@`select#1`) NO_MERGE(`alias2`@`select#1`) */ `test`.`t1`.`a` AS `a`,`qnm`.`a` AS `a`,`test`.`t1`.`a` AS `a`,`alias2`.`a` AS `a` from `test`.`t1` join `qnm` join `test`.`t1` join `qnma` `alias2` +drop table t1; +# Automatic index creation if materialized +create table t1 (a int); +insert into t1(a) values (1),(2),(3),(4),(5),(6),(7),(8),(9),(0); +analyze table t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +# EXPLAIN should not fill the tmp table +flush status; +# Should use auto_key0 and ref access. +explain with tt as (select * from t1) +select /*+ no_merge(tt) */ tt.a +from t1 straight_join tt where t1.a=tt.a +limit 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL # 100.00 Using where +1 PRIMARY NULL ref 5 test.t1.a # 100.00 Using index +2 DERIVED t1 NULL ALL NULL NULL NULL NULL # 100.00 NULL +Warnings: +Note 1003 with `tt` as (/* select#2 */ select `test`.`t1`.`a` AS `a` from `test`.`t1`) /* select#1 */ select /*+ NO_MERGE(`tt`@`select#1`) */ `tt`.`a` AS `a` from `test`.`t1` straight_join `tt` where (`tt`.`a` = `test`.`t1`.`a`) limit 1 +show status like "handler_write"; +Variable_name Value +Handler_write 0 +flush status; +with tt as (select * from t1) +select /*+ no_merge(tt) */ tt.a +from t1 straight_join tt where t1.a=tt.a +limit 1; +a +1 +show status like "handler_write"; +Variable_name Value +Handler_write 10 +# With two references +with tt as (select * from t1) +select /*+ no_merge(tt) no_merge(tt_)*/ tt.a +from t1 straight_join tt straight_join tt as tt_ +where t1.a=tt.a and tt.a=tt_.a +limit 1; +a +1 +# One merged, one materialized: index creation on the second +# should of course ignore the first +with q as (select * from t1) +select /*+ merge(q) no_merge(q1) */ * from q, q q1 where q.a=1 and q1.a=2; +a a +1 2 +drop table t1; +# Must not create more than 64 indexes. +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +(select max(c1) from qn where qn.c1=1) (select max(c2) from qn where qn.c2=1) (select max(c3) from qn where qn.c3=1) (select max(c4) from qn where qn.c4=1) (select max(c5) from qn where qn.c5=1) (select max(c6) from qn where qn.c6=1) (select max(c7) from qn where qn.c7=1) (select max(c8) from qn where qn.c8=1) (select max(c9) from qn where qn.c9=1) (select max(c10) from qn where qn.c10=1) (select max(c11) from qn where qn.c11=1) (select max(c12) from qn where qn.c12=1) (select max(c13) from qn where qn.c13=1) (select max(c14) from qn where qn.c14=1) (select max(c15) from qn where qn.c15=1) (select max(c16) from qn where qn.c16=1) (select max(c17) from qn where qn.c17=1) (select max(c18) from qn where qn.c18=1) (select max(c19) from qn where qn.c19=1) (select max(c20) from qn where qn.c20=1) (select max(c21) from qn where qn.c21=1) (select max(c22) from qn where qn.c22=1) (select max(c23) from qn where qn.c23=1) (select max(c24) from qn where qn.c24=1) (select max(c25) from qn where qn.c25=1) (select max(c26) from qn where qn.c26=1) (select max(c27) from qn where qn.c27=1) (select max(c28) from qn where qn.c28=1) (select max(c29) from qn where qn.c29=1) (select max(c30) from qn where qn.c30=1) (select max(c31) from qn where qn.c31=1) (select max(c32) from qn where qn.c32=1) (select max(c33) from qn where qn.c33=1) (select max(c34) from qn where qn.c34=1) (select max(c35) from qn where qn.c35=1) (select max(c36) from qn where qn.c36=1) (select max(c37) from qn where qn.c37=1) (select max(c38) from qn where qn.c38=1) (select max(c39) from qn where qn.c39=1) (select max(c40) from qn where qn.c40=1) (select max(c41) from qn where qn.c41=1) (select max(c42) from qn where qn.c42=1) (select max(c43) from qn where qn.c43=1) (select max(c44) from qn where qn.c44=1) (select max(c45) from qn where qn.c45=1) (select max(c46) from qn where qn.c46=1) (select max(c47) from qn where qn.c47=1) (select max(c48) from qn where qn.c48=1) (select max(c49) from qn where qn.c49=1) (select max(c50) from qn where qn.c50=1) (select max(c51) from qn where qn.c51=1) (select max(c52) from qn where qn.c52=1) (select max(c53) from qn where qn.c53=1) (select max(c54) from qn where qn.c54=1) (select max(c55) from qn where qn.c55=1) (select max(c56) from qn where qn.c56=1) (select max(c57) from qn where qn.c57=1) (select max(c58) from qn where qn.c58=1) (select max(c59) from qn where qn.c59=1) (select max(c60) from qn where qn.c60=1) (select max(c61) from qn where qn.c61=1) (select max(c62) from qn where qn.c62=1) (select max(c63) from qn where qn.c63=1) (select max(c64) from qn where qn.c64=1) (select max(c65) from qn where qn.c65=1) (select max(c66) from qn where qn.c66=1) (select max(c67) from qn where qn.c67=1) (select max(c68) from qn where qn.c68=1) (select max(c69) from qn where qn.c69=1) (select max(c70) from qn where qn.c70=1) (select max(c71) from qn where qn.c71=1) (select max(c72) from qn where qn.c72=1) (select max(c73) from qn where qn.c73=1) (select max(c74) from qn where qn.c74=1) (select max(c75) from qn where qn.c75=1) (select max(c76) from qn where qn.c76=1) (select max(c77) from qn where qn.c77=1) (select max(c78) from qn where qn.c78=1) (select max(c79) from qn where qn.c79=1) (select max(c80) from qn where qn.c80=1) (select max(c81) from qn where qn.c81=1) (select max(c82) from qn where qn.c82=1) (select max(c83) from qn where qn.c83=1) (select max(c84) from qn where qn.c84=1) (select max(c85) from qn where qn.c85=1) (select max(c86) from qn where qn.c86=1) (select max(c87) from qn where qn.c87=1) (select max(c88) from qn where qn.c88=1) (select max(c89) from qn where qn.c89=1) (select max(c90) from qn where qn.c90=1) (select max(c91) from qn where qn.c91=1) (select max(c92) from qn where qn.c92=1) (select max(c93) from qn where qn.c93=1) (select max(c94) from qn where qn.c94=1) (select max(c95) from qn where qn.c95=1) (select max(c96) from qn where qn.c96=1) (select max(c97) from qn where qn.c97=1) (select max(c98) from qn where qn.c98=1) (select max(c99) from qn where qn.c99=1) (select max(c100) from qn where qn.c100=1) +NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL +drop table t; +# Choice between two auto_key: +create table t1(a int, b int); +insert into t1 values (null, 6), (null, 10); +# Test the covering key; note that MEMORY doesn't use a +# covering key (always reads the "data file"). But InnoDB does. +EXPLAIN with t2 as +(select * from t1) +SELECT /*+ no_merge(t2) */ * FROM t2 +WHERE (a = a OR b <= 6) AND (a IS NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DERIVED t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1003 with `t2` as (/* select#2 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (((`test`.`t1`.`a` = `test`.`t1`.`a`) or (`test`.`t1`.`b` <= 6)) and (`test`.`t1`.`a` is null))) /* select#1 */ select /*+ NO_MERGE(`t2`@`select#1`) */ `t2`.`a` AS `a`,`t2`.`b` AS `b` from `t2` +with t2 as +(select * from t1) +SELECT /*+ no_merge(t2) */ * FROM t2 +WHERE (a = a OR b <= 6) AND (a IS NULL); +a b +NULL 6 +drop table t1; +# QN referencing view of same name isn't a "recursive view", +# shouldn't cause ER_VIEW_RECURSIVE +create view v1 as select "with"; +with v1 as (select * from v1) select * from v1; +with +with +drop view v1; +# QN inside view +create view v1 as +with qn as (select 1 as col) select * from qn; +select * from v1; +col +1 +drop view v1; +create table t1(a int, b int); +# Alas merge hints are ignored in views (filed Bug#23017428) +create view v1 as +with qn as (select a from t1), +qn2 as (select b from t1) +select /*+ merge(qn) no_merge(qn2) */ qn.a,qn2.b from qn, qn2; +explain select * from v1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` join `test`.`t1` +drop view v1; +# Materializing view doesn't impose materializing query name +create algorithm=temptable view v1 as +with qn as (select a from t1) +select qn.a from qn; +explain select * from v1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DERIVED t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`v1`.`a` AS `a` from `test`.`v1` +drop view v1; +drop table t1; +# CTE referenced four times, including in subqueries in other CTEs +create table sales_days(day_of_sale DATE, amount INT); +insert into sales_days values +('2015-01-02', 100), ('2015-01-05', 200), +('2015-02-02', 10), ('2015-02-10', 100), +('2015-03-02', 10), ('2015-03-18', 1); +with +# first CTE: one row per month, with amount sold on all days of month +sales_by_month(month,total) as +(select month(day_of_sale), sum(amount) from sales_days +where year(day_of_sale)=2015 +group by month(day_of_sale)), +# second CTE: best month +best_month(month, total, award) as +(select month, total, "best" from sales_by_month +where total=(select max(total) from sales_by_month)), +# 3rd CTE: worst month +worst_month(month, total, award) as +(select month, total, "worst" from sales_by_month +where total=(select min(total) from sales_by_month)) +# Now show results: +select * from best_month union all select * from worst_month; +month total award +1 300 best +3 11 worst +drop table sales_days; +# Special parser command not allowed to users. +parse_cte ( select 1 ) ; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'parse_cte ( select 1 )' at line 1 +# Query names are a partial workaround to the problem that +# user-created temp tables can't be referenced twice. +create temporary table tmp(a int) as select 1; +select * from tmp, tmp tmp1; +ERROR HY000: Can't reopen table: 'tmp' +# the workaround works if the temp table's life is necessary +# only for a single statement: +with qn as (select 1) select * from qn, qn qn1; +1 1 +1 1 +# If the tmp table is necessary, wrapping it in a query name doesn't +# help: +with qn as (select * from tmp) select /*+ merge(qn,qn1) */ * from qn, qn qn1; +ERROR HY000: Can't reopen table: 'tmp' +with qn as (select * from tmp) select /*+ no_merge(qn,qn1) */ * from qn, qn qn1; +ERROR HY000: Can't reopen table: 'tmp' +drop temporary table tmp; +# Using a query name in UPDATE +create table t1(a int, b int); +insert into t1 values(1,2),(3,4); +create table t2 select * from t1; +set autocommit=0; +# Multi-table syntax +with qn as (select a, b from t1) update t1, qn set qn.a=qn.a+10; +ERROR HY000: The target table t1 of the UPDATE is not updatable +select * from t1; +a b +1 2 +3 4 +rollback; +explain with qn as (select a+2 as a, b from t1) update t1, qn set t1.a=qn.a+10 where t1.a-qn.a=0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +Warnings: +Note 1003 update `test`.`t1` join `test`.`t1` set `test`.`t1`.`a` = ((`test`.`t1`.`a` + 2) + 10) where ((`test`.`t1`.`a` - (`test`.`t1`.`a` + 2)) = 0) +with qn as (select a+2 as a, b from t1) update t1, qn set t1.a=qn.a+10 where t1.a-qn.a=0; +select * from t1; +a b +1 2 +13 4 +rollback; +explain with qn as (select a+2 as a, b from t2) update t1, qn set t1.a=qn.a+10 where t1.a-qn.a=0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +Warnings: +Note 1003 update `test`.`t1` join `test`.`t2` set `test`.`t1`.`a` = ((`test`.`t2`.`a` + 2) + 10) where ((`test`.`t1`.`a` - (`test`.`t2`.`a` + 2)) = 0) +with qn as (select a+2 as a, b from t2) update t1, qn set t1.a=qn.a+10 where t1.a-qn.a=0; +select * from t1; +a b +1 2 +13 4 +rollback; +explain with qn as (select a+2 as a, b from t2) update /*+ no_merge(qn) */ t1, qn set t1.a=qn.a+10 where t1.a-qn.a=0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 Using where +2 DERIVED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 with `qn` as (/* select#2 */ select (`test`.`t2`.`a` + 2) AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t2`) update /*+ NO_MERGE(`qn`@`select#1`) */ `test`.`t1` join `qn` set `test`.`t1`.`a` = (`qn`.`a` + 10) where ((`test`.`t1`.`a` - `qn`.`a`) = 0) +with qn as (select a+2 as a, b from t2) update /*+ no_merge(qn) */ t1, qn set t1.a=qn.a+10 where t1.a-qn.a=0; +select * from t1; +a b +1 2 +13 4 +rollback; +# Two references to query name +explain with qn as (select a+2 as a, b from t2) +update t1, qn, qn as qn2 set t1.a=qn.a+10 where t1.a-qn.a=0 and qn.b=qn2.b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1003 update `test`.`t1` join `test`.`t2` join `test`.`t2` set `test`.`t1`.`a` = ((`test`.`t2`.`a` + 2) + 10) where ((`test`.`t2`.`b` = `test`.`t2`.`b`) and ((`test`.`t1`.`a` - (`test`.`t2`.`a` + 2)) = 0)) +with qn as (select a+2 as a, b from t2) +update t1, qn, qn as qn2 set t1.a=qn.a+10 where t1.a-qn.a=0 and qn.b=qn2.b; +select * from t1; +a b +1 2 +13 4 +rollback; +# Single-table syntax +explain with qn as (select a+2 as a, b from t2) update t1 +set t1.a=(select qn.a+10 from qn where t1.a-qn.a=0 limit 1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DEPENDENT SUBQUERY NULL ALL NULL NULL NULL NULL 2 100.00 Using where +3 DERIVED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 with `qn` as (/* select#3 */ select (`test`.`t2`.`a` + 2) AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t2`) update `test`.`t1` set `test`.`t1`.`a` = (/* select#2 */ select (`qn`.`a` + 10) from `qn` where ((`test`.`t1`.`a` - `qn`.`a`) = 0) limit 1) +with qn as (select a+2 as a, b from t2) update t1 +set t1.a=(select qn.a+10 from qn where t1.a-qn.a=0 limit 1); +select * from t1; +a b +NULL 2 +13 4 +rollback; +explain with qn as (select a+2 as a, b from t2) update t1 +set t1.a=(select /*+ merge(qn) */ qn.a+10 from qn where t1.a-qn.a=0 limit 1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 update /*+ MERGE(`qn`@`select#2`) */ `test`.`t1` set `test`.`t1`.`a` = (/* select#2 */ select ((`test`.`t2`.`a` + 2) + 10) from `test`.`t2` where ((`test`.`t1`.`a` - (`test`.`t2`.`a` + 2)) = 0) limit 1) +with qn as (select a+2 as a, b from t2) update t1 +set t1.a=(select /*+ merge(qn) */ qn.a+10 from qn where t1.a-qn.a=0 limit 1); +select * from t1; +a b +NULL 2 +13 4 +rollback; +# Using a query name in DELETE +# Multi-table syntax +with qn as (select a, b from t1) delete qn from t1,qn; +ERROR HY000: The target table qn of the DELETE is not updatable +select * from t1; +a b +1 2 +3 4 +rollback; +explain with qn as (select a+2 as a, b from t1) delete t1 from t1, qn where t1.a-qn.a=0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +Warnings: +Note 1003 delete `test`.`t1` from `test`.`t1` join `test`.`t1` where ((`test`.`t1`.`a` - (`test`.`t1`.`a` + 2)) = 0) +with qn as (select a+2 as a, b from t1) delete t1 from t1, qn where t1.a-qn.a=0; +select * from t1; +a b +1 2 +rollback; +explain with qn as (select a+2 as a, b from t2) delete t1 from t1, qn where t1.a-qn.a=0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +Warnings: +Note 1003 delete `test`.`t1` from `test`.`t1` join `test`.`t2` where ((`test`.`t1`.`a` - (`test`.`t2`.`a` + 2)) = 0) +with qn as (select a+2 as a, b from t2) delete t1 from t1, qn where t1.a-qn.a=0; +select * from t1; +a b +1 2 +rollback; +explain with qn as (select a+2 as a, b from t2) delete /*+ no_merge(qn) */ t1 from t1, qn where t1.a-qn.a=0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 Using where +2 DERIVED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 with `qn` as (/* select#2 */ select (`test`.`t2`.`a` + 2) AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t2`) delete /*+ NO_MERGE(`qn`@`select#1`) */ `test`.`t1` from `test`.`t1` join `qn` where ((`test`.`t1`.`a` - `qn`.`a`) = 0) +with qn as (select a+2 as a, b from t2) delete /*+ no_merge(qn) */ t1 from t1, qn where t1.a-qn.a=0; +select * from t1; +a b +1 2 +rollback; +explain with qn as (select a+2 as a, b from t2) +delete t1 from t1, qn, qn as qn2 where t1.a-qn.a=0 and qn.b=qn2.b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1003 delete `test`.`t1` from `test`.`t1` join `test`.`t2` join `test`.`t2` where ((`test`.`t2`.`b` = `test`.`t2`.`b`) and ((`test`.`t1`.`a` - (`test`.`t2`.`a` + 2)) = 0)) +with qn as (select a+2 as a, b from t2) +delete t1 from t1, qn, qn as qn2 where t1.a-qn.a=0 and qn.b=qn2.b; +select * from t1; +a b +1 2 +rollback; +# Single-table syntax +explain with qn as (select a+2 as a, b from t2) +delete from t1 where t1.a=(select qn.a from qn where t1.a-qn.a=0 limit 1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 DEPENDENT SUBQUERY NULL ALL NULL NULL NULL NULL 2 100.00 Using where +3 DERIVED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 with `qn` as (/* select#3 */ select (`test`.`t2`.`a` + 2) AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t2`) delete from `test`.`t1` where (`test`.`t1`.`a` = (/* select#2 */ select `qn`.`a` from `qn` where ((`test`.`t1`.`a` - `qn`.`a`) = 0) limit 1)) +with qn as (select a+2 as a, b from t2) +delete from t1 where t1.a=(select qn.a from qn where t1.a-qn.a=0 limit 1); +select * from t1; +a b +1 2 +rollback; +explain with qn as (select a+2 as a, b from t2) +delete from t1 where t1.a=(select /*+ merge(qn) */ qn.a from qn where t1.a-qn.a=0 limit 1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 delete /*+ MERGE(`qn`@`select#2`) */ from `test`.`t1` where (`test`.`t1`.`a` = (/* select#2 */ select (`test`.`t2`.`a` + 2) from `test`.`t2` where ((`test`.`t1`.`a` - (`test`.`t2`.`a` + 2)) = 0) limit 1)) +with qn as (select a+2 as a, b from t2) +delete from t1 where t1.a=(select /*+ merge(qn) */ qn.a from qn where t1.a-qn.a=0 limit 1); +select * from t1; +a b +1 2 +rollback; +drop table t1,t2; +set autocommit=default; +# No default db +select database(); +database() +test +create database mysqltest1; +use mysqltest1; +drop database mysqltest1; +select database(); +database() +NULL +with qn as (select 1) select * from qn; +1 +1 +# Back to usual db 'test' +use test; +show status like 'Created_tmp_disk_tables'; +Variable_name Value +Created_tmp_disk_tables 0 +# On-disk tmp tables +set big_tables=1; +# WL#883 Non-recursive WITH clause (common table expression) +flush status; +create table t1(a int, b int, c int); +insert into t1 values(null,null,null),(2,3,4); +WITH qn AS (SELECT a FROM t1) +SELECT 1 FROM dual; +1 +1 +# two query names +WITH qn AS (SELECT a FROM t1), qn2 as (select b from t1) +SELECT 1 FROM dual; +1 +1 +# duplicate query names +WITH qn AS (SELECT a FROM t1), qn as (select b from t1) +SELECT 1 FROM qn; +ERROR 42000: Not unique table/alias: 'qn' +# multiple refs +WITH qn AS (SELECT b as a FROM t1) +SELECT qn.a, qn2.a FROM qn, qn as qn2; +a a +3 3 +3 NULL +NULL 3 +NULL NULL +WITH qn AS (SELECT b as a FROM t1), +qn2 AS (SELECT c FROM t1 WHERE a IS NULL or a>0) +SELECT qn.a, qn2.c FROM qn, qn2; +a c +3 4 +3 NULL +NULL 4 +NULL NULL +# qn2 ref qn: +WITH qn AS (SELECT 10*a as a FROM t1), +qn2 AS (SELECT 3*a FROM qn) +SELECT * from qn2; +3*a +NULL +60 +WITH qn AS (SELECT a FROM t1), qn2 AS (SELECT a FROM qn) +SELECT * from qn2; +a +NULL +2 +WITH qn AS (SELECT b as a FROM t1), +qn2 AS (SELECT a FROM qn WHERE a IS NULL or a>0) +SELECT qn.a, qn2.a FROM qn, qn2; +a a +3 3 +3 NULL +NULL 3 +NULL NULL +EXPLAIN WITH qn AS (SELECT b as a FROM t1), +qn2 AS (SELECT a FROM qn WHERE a IS NULL or a>0) +SELECT qn.a, qn2.a FROM qn, qn2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 75.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 75.00 Using where +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`b` AS `a`,`test`.`t1`.`b` AS `a` from `test`.`t1` join `test`.`t1` where ((`test`.`t1`.`b` is null) or (`test`.`t1`.`b` > 0)) +# forward ref (should error) +WITH qn2 AS (SELECT a FROM qn WHERE a IS NULL or a>0), +qn AS (SELECT b as a FROM t1) +SELECT qn2.a FROM qn2; +ERROR 42S02: Table 'test.qn' doesn't exist +with qn1 as (with qn3 as (select * from qn2) select * from qn3), +qn2 as (select 1) +select * from qn1; +ERROR 42S02: Table 'test.qn2' doesn't exist +# This is valid; it is to test moving boundaries. +# When we resolve qn3, resolving qn1 moves the right bound to +# qn0, but the bound is properly restored so that we can later +# resolve qn2. +with qn0 as (select 1), qn1 as (select * from qn0), qn2 as (select 1), qn3 as (select 1 from qn1, qn2) select 1 from qn3; +1 +1 +# No ref +explain with qn as (select 1) select 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 /* select#1 */ select 2 AS `2` +with qn as (select 1) select 2; +2 +2 +# circular ref +WITH qn2 AS (SELECT a FROM qn WHERE a IS NULL or a>0), +qn AS (SELECT b as a FROM qn2) +SELECT qn.a FROM qn; +ERROR 42S02: Table 'test.qn' doesn't exist +# recursive +WITH qn AS (SELECT a FROM qn) +SELECT qn.a FROM qn; +ERROR 42S02: Table 'test.qn' doesn't exist +WITH qn1 AS (SELECT a FROM qn3), +qn2 AS (SELECT a FROM qn1), +qn3 AS (SELECT a FROM t1), +qn4 AS (SELECT a FROM qn2) +SELECT a FROM qn4; +ERROR 42S02: Table 'test.qn3' doesn't exist +# ref from subq +with qn as (select * from t1) select (select max(a) from qn); +(select max(a) from qn) +2 +# QN defined in subq +SELECT (WITH qn AS (SELECT 10*a as a FROM t1), +qn2 AS (SELECT 3*a AS b FROM qn) +SELECT * from qn2 LIMIT 1) +FROM t1; +(WITH qn AS (SELECT 10*a as a FROM t1), +qn2 AS (SELECT 3*a AS b FROM qn) +SELECT * from qn2 LIMIT 1) +NULL +NULL +SELECT * +FROM (WITH qn AS (SELECT 10*a as a FROM t1), +qn2 AS (SELECT 3*a AS b FROM qn) +SELECT * from qn2) +AS dt; +b +NULL +60 +# WITH in WITH +with qn as +(with qn2 as (select "qn2" as a from t1) select "qn", a from qn2) +select * from qn; +qn a +qn qn2 +qn qn2 +# outer ref to a table, placed in a QN in a subq (later) +# QN defined in view +CREATE VIEW v AS +WITH qn AS (SELECT 10*a as a FROM t1), +qn2 AS (SELECT 3*a AS b FROM qn) +SELECT * from qn2; +SELECT * FROM v; +b +NULL +60 +DROP VIEW v; +# CREATE INSERT SELECT +CREATE TABLE t2 +WITH qn AS (SELECT 10*a as a FROM t1), +qn2 AS (SELECT 3*a AS b FROM qn) +SELECT * from qn2; +SELECT * FROM t2; +b +NULL +60 +INSERT INTO t2 +WITH qn AS (SELECT 10*a as a FROM t1), +qn2 AS (SELECT 3*a AS b FROM qn) +SELECT * from qn2; +SELECT * FROM t2; +b +NULL +60 +NULL +60 +DROP TABLE t2; +# Double use of QN in two subqueries. +explain with qn as (select * from t1 limit 10) +select (select max(a) from qn where a=0), +(select min(b) from qn where b=3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +4 SUBQUERY NULL ref 5 const 1 100.00 NULL +2 SUBQUERY NULL ref 5 const 1 100.00 NULL +3 DERIVED t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 with `qn` as (/* select#3 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` limit 10) /* select#1 */ select (/* select#2 */ select max(`qn`.`a`) from `qn` where (`qn`.`a` = 0)) AS `(select max(a) from qn where a=0)`,(/* select#4 */ select min(`qn`.`b`) from `qn` where (`qn`.`b` = 3)) AS `(select min(b) from qn where b=3)` +with qn as (select * from t1 limit 10) +select (select max(a) from qn where a=0), +(select min(b) from qn where b=3); +(select max(a) from qn where a=0) (select min(b) from qn where b=3) +NULL 3 +# when QN, when table. +create table qn select "base"; +select * from qn; +base +base +with qn as (select "with") select * from qn; +with +with +# In a non-recursive WITH, the scope of the QN doesn't extend to its +# subquery, so "qn" inside AS() is the base table. +WITH qn AS (select * from qn) select * from qn; +base +base +# View doesn't look out to external QNs +create view v as select * from qn; +select * from v; +base +base +with qn as (select "with") select * from v; +base +base +with qn as (select * from v) select * from qn; +base +base +# Even if the base table is temporarily dropped +drop table qn; +with qn as (select "with") select * from v; +ERROR HY000: View 'test.v' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +with qn as (select * from v) select * from qn; +ERROR HY000: View 'test.v' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +create table qn select "base" as a; +# Neither does SP +create function f() returns varchar(10) +return (select * from qn); +select f(); +f() +base +with qn as (select "with") select f(); +f() +base +with qn as (select f()) select * from qn; +f() +base +# QN shadows tmp table +create temporary table qn select "tmp" as a; +select * from qn; +a +tmp +with qn as (select "with") select * from qn; +with +with +drop function f; +drop view v; +# DT shadows QN: +with qn as (select "with") select * from (select "dt") as qn; +dt +dt +# QN of subq shadows outer QN +WITH qn AS (select "outer" as a) +SELECT (WITH qn AS (SELECT "inner" as a) SELECT a from qn), +qn.a +FROM qn; +(WITH qn AS (SELECT "inner" as a) SELECT a from qn) a +inner outer +# Qualified name isn't allowed after WITH: +with test.qn as (select "with") select * from test.qn; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '.qn as (select "with") select * from test.qn' at line 1 +# Adding a db. prefix to a field still resolves to the QN; it's a bit awkward as +# the QN doesn't belong to a db, but it's the same with derived table: +select test.qn.a from (select "with" as a) qn; +a +with +# OTOH, db. prefix in FROM doesn't resolve to QN, which is good +with qn as (select "with") select * from qn; +with +with +with qn as (select "with") select * from test.qn; +a +tmp +with qn as (select "with" as a) select a from qn; +a +with +with qn as (select "with" as a) select qn.a from qn; +a +with +with qn as (select "with" as a) select test.qn.a from qn; +a +with +with qn as (select "with" as a) select a from test.qn; +a +tmp +with qn as (select "with" as a) select qn.a from test.qn; +a +tmp +with qn as (select "with" as a) select test.qn.a from test.qn; +a +tmp +drop temporary table qn; +with qn as (select "with" as a) select a from test.qn; +a +base +with qn as (select "with" as a) select qn.a from test.qn; +a +base +with qn as (select "with" as a) select test.qn.a from test.qn; +a +base +drop table qn; +with qn as (select "with" as a) select a from test.qn; +ERROR 42S02: Table 'test.qn' doesn't exist +with qn as (select "with" as a) select qn.a from test.qn; +ERROR 42S02: Table 'test.qn' doesn't exist +with qn as (select "with" as a) select test.qn.a from test.qn; +ERROR 42S02: Table 'test.qn' doesn't exist +# Unions +WITH qn AS (SELECT b as a FROM t1 UNION SELECT b+5 FROM t1), +qn2 AS (SELECT a FROM qn WHERE a IS NULL or a>0) +SELECT qn.a FROM qn +UNION SELECT qn2.a FROM qn2 WHERE qn2.a>3; +a +NULL +3 +8 +# No double WITH +with qn as (select "with" as a) +with qn2 as (select "with" as a) +select a from test.qn; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'with qn2 as (select "with" as a) +select a from test.qn' at line 2 +# with comma +with qn as (select "with" as a), +with qn2 as (select "with" as a) +select a from test.qn; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'with qn2 as (select "with" as a) +select a from test.qn' at line 2 +# ORDER BY removed unless there is LIMIT or single table (check "Using filesort") +explain +with qn as (select a from t1 order by 1) +select a from qn; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` order by `qn`.`a` +explain +with qn as (select a from t1 order by 1) +select qn.a from qn, t1 as t2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` join `test`.`t1` `t2` +explain +with qn as (select a from t1 order by 1 limit 10) +select qn.a from qn, t1 as t2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +2 DERIVED t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using filesort +Warnings: +Note 1003 with `qn` as (/* select#2 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` order by `test`.`t1`.`a` limit 10) /* select#1 */ select `qn`.`a` AS `a` from `qn` join `test`.`t1` `t2` +# Merge hint +explain +with qn as (select a from t1), +qn2 as (select b from t1) +select /*+ merge(qn) no_merge(qn2) */ qn.a,qn2.b from qn, qn2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +3 DERIVED t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 with `qn2` as (/* select#3 */ select `test`.`t1`.`b` AS `b` from `test`.`t1`) /* select#1 */ select /*+ MERGE(`qn`@`select#1`) NO_MERGE(`qn2`@`select#1`) */ `test`.`t1`.`a` AS `a`,`qn2`.`b` AS `b` from `test`.`t1` join `qn2` +explain +with qn as (select a from t1) +select /*+ merge(qn) no_merge(qn2) */ qn2.a from qn, qn as qn2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +3 DERIVED t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 with `qn` as (/* select#3 */ select `test`.`t1`.`a` AS `a` from `test`.`t1`) /* select#1 */ select /*+ MERGE(`qn`@`select#1`) NO_MERGE(`qn2`@`select#1`) */ `qn2`.`a` AS `a` from `test`.`t1` join `qn` `qn2` +# FD detection +with qn as (select a, b from t1) +select b from qn group by a; +ERROR 42000: Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'qn.b' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +with qn as (select a, b from t1 where a=b) +select b from qn group by a; +b +with qn as (select a, sum(b) as s from t1 group by a) +select s from qn group by a; +s +NULL +3 +# CTEs work if used in SET +set @myvar= +(with qn as (select a, sum(b) as s from t1 group by a) +select s from qn group by a having s is not null); +select @myvar; +@myvar +3 +# CTE works with semijoin +explain with cte as (select * from t1 as t2 limit 1) +select * from t1 where t1.a in (select a+0 from cte); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +3 DERIVED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 with `cte` as (/* select#3 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c` from `test`.`t1` `t2` limit 1) /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` semi join (`cte`) where (`test`.`t1`.`a` = (`cte`.`a` + 0)) +with cte as (select * from t1 as t2 limit 1) +select * from t1 where t1.a in (select a+0 from cte); +a b c +explain with cte as (select * from t1 as t2) +select * from t1 where t1.a in (select a+0 from cte); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch(t1); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` semi join (`test`.`t1` `t2`) where (`test`.`t1`.`a` = (`test`.`t2`.`a` + 0)) +with cte as (select * from t1 as t2) +select * from t1 where t1.a in (select a+0 from cte); +a b c +2 3 4 +# Column names +# empty list +with qn () as (select 1) select * from qn, qn qn1; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ') as (select 1) select * from qn, qn qn1' at line 1 +# Materialization +with qn (foo, bar) as (select 1) select * from qn, qn qn1; +ERROR HY000: In definition of view, derived table or common table expression, SELECT list and column names list have different column counts +explain with qn (foo, bar) as (select 1, 2 from t1 limit 2) select * from qn, qn qn1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +2 DERIVED t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 with `qn` (`foo`,`bar`) as (/* select#2 */ select 1 AS `1`,2 AS `2` from `test`.`t1` limit 2) /* select#1 */ select `qn`.`foo` AS `foo`,`qn`.`bar` AS `bar`,`qn1`.`foo` AS `foo`,`qn1`.`bar` AS `bar` from `qn` join `qn` `qn1` +with qn (foo, bar) as (select 1, 2 from t1 limit 2) select * from qn, qn qn1; +foo bar foo bar +1 2 1 2 +1 2 1 2 +1 2 1 2 +1 2 1 2 +with qn (foo, bar) as (select 1 as col, 2 as coll from t1 limit 2) select * from qn, qn qn1; +foo bar foo bar +1 2 1 2 +1 2 1 2 +1 2 1 2 +1 2 1 2 +with qn (foo, bar) as (select 1 as col, 2 as coll union +select a,b from t1) select qn1.bar from qn qn1; +bar +NULL +2 +3 +with qn (foo, bar) as (select a, b from t1 limit 2) select qn.bar,foo from qn; +bar foo +NULL NULL +3 2 +create table t3 +with qn (foo, bar) as (select a, b from t1 limit 2) select bar,foo from qn; +desc t3; +Field Type Null Key Default Extra +bar int YES NULL +foo int YES NULL +drop table t3; +# Merge +with qn (foo, bar) as (select 1 from t1) select * from qn, qn qn1; +ERROR HY000: In definition of view, derived table or common table expression, SELECT list and column names list have different column counts +with qn (foo, bar) as (select 1, 2 from t1) select * from qn, qn qn1; +foo bar foo bar +1 2 1 2 +1 2 1 2 +1 2 1 2 +1 2 1 2 +explain with qn (foo, bar) as (select 1, 2 from t1) select * from qn, qn qn1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select 1 AS `foo`,2 AS `bar`,1 AS `foo`,2 AS `bar` from `test`.`t1` join `test`.`t1` +with qn (foo, bar) as (select 1 as col, 2 as coll from t1) select * from qn, qn qn1; +foo bar foo bar +1 2 1 2 +1 2 1 2 +1 2 1 2 +1 2 1 2 +with qn (foo, bar) as (select a, b from t1) select qn1.bar,foo from qn qn1; +bar foo +NULL NULL +3 2 +create table t3 +with qn (foo, bar) as (select a, b from t1) select bar,foo from qn; +desc t3; +Field Type Null Key Default Extra +bar int YES NULL +foo int YES NULL +drop table t3; +# Disambiguates same-name expressions +with qn as (select 1,1) select * from qn; +ERROR 42S21: Duplicate column name '1' +with qn (foo, bar) as (select 1,1) select * from qn; +foo bar +1 1 +with qn as (select 1,1 from t1) select * from qn; +ERROR 42S21: Duplicate column name '1' +with qn (foo, bar) as (select 1,1 from t1) select * from qn; +foo bar +1 1 +1 1 +# Duplicate names are forbidden +with qn (foo, foo) as (select 1,2) select * from qn; +ERROR 42S21: Duplicate column name 'foo' +# Derived tables support this too +select * from (select '1', 1) dt(foo,bar); +foo bar +1 1 +select * from (select a,b from t1) dt(foo,bar); +foo bar +NULL NULL +2 3 +select * from (select a from t1) dt(foo,bar); +ERROR HY000: In definition of view, derived table or common table expression, SELECT list and column names list have different column counts +# Column names for QN/DT are printed +create view v1 as +with qn (foo, bar) as (select 1,1) select * from qn; +show create view v1; +View Create View character_set_client collation_connection +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS with `qn` (`foo`,`bar`) as (select 1 AS `1`,1 AS `1`) select `qn`.`foo` AS `foo`,`qn`.`bar` AS `bar` from `qn` utf8mb4 utf8mb4_0900_ai_ci +show fields from v1; +Field Type Null Key Default Extra +foo int NO 0 +bar int NO 0 +select * from v1; +foo bar +1 1 +drop view v1; +create view v1 as +select * from (select 1,1) dt(foo,bar); +show create view v1; +View Create View character_set_client collation_connection +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `dt`.`foo` AS `foo`,`dt`.`bar` AS `bar` from (select 1 AS `1`,1 AS `1`) `dt` (`foo`,`bar`) utf8mb4 utf8mb4_0900_ai_ci +select * from v1; +foo bar +1 1 +drop view v1; +create view v1 as +with qn (foo, bar) as (select 1,1 from t1) select * from qn; +show create view v1; +View Create View character_set_client collation_connection +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS with `qn` (`foo`,`bar`) as (select 1 AS `1`,1 AS `1` from `t1`) select `qn`.`foo` AS `foo`,`qn`.`bar` AS `bar` from `qn` utf8mb4 utf8mb4_0900_ai_ci +select * from v1; +foo bar +1 1 +1 1 +drop view v1; +create view v1 as +select * from (select 1,1 from t1) dt(foo,bar); +show create view v1; +View Create View character_set_client collation_connection +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `dt`.`foo` AS `foo`,`dt`.`bar` AS `bar` from (select 1 AS `1`,1 AS `1` from `t1`) `dt` (`foo`,`bar`) utf8mb4 utf8mb4_0900_ai_ci +select * from v1; +foo bar +1 1 +1 1 +drop view v1; +# printing with back-quoting is necessary, when using a +# reserved word as column name. +create view v1 as +select * from (select 1) dt(`select`); +show create view v1; +View Create View character_set_client collation_connection +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `dt`.`select` AS `select` from (select 1 AS `1`) `dt` (`select`) utf8mb4 utf8mb4_0900_ai_ci +select * from v1; +select +1 +drop view v1; +# Works for views too. Using testcase of: +# Bug#23265335 SPECIFYING A NAME FOR VIEW'S COLUMN IN CREATE VIEW MAKES SELECT FAIL +create view v1 (bar) as +select 1 as foo group by foo union select 2 order by foo; +select * from v1; +bar +1 +2 +show create view v1; +View Create View character_set_client collation_connection +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` (`bar`) AS select 1 AS `foo` group by `foo` union select 2 AS `2` order by `foo` utf8mb4 utf8mb4_0900_ai_ci +# The column's name for the view +select TABLE_NAME,COLUMN_NAME from information_schema.columns +where TABLE_SCHEMA='test' and TABLE_NAME='v1'; +TABLE_NAME COLUMN_NAME +v1 bar +# is different from the alias in the defining SELECT +select VIEW_DEFINITION from information_schema.views +where TABLE_SCHEMA='test' and TABLE_NAME='v1'; +VIEW_DEFINITION +select 1 AS `foo` group by `foo` union select 2 AS `2` order by `foo` +drop view v1; +create view v1 (bar) as +select 1, 2 from t1; +ERROR HY000: In definition of view, derived table or common table expression, SELECT list and column names list have different column counts +drop table t1; +# Prove that a materialized QN is shared among all references: +create table t1(a int); +insert into t1 values(1),(2),(3),(4); +flush status; +with qn as (select 123 as col) +select * from qn; +col +123 +show status like "handler_write"; +Variable_name Value +Handler_write 1 +flush status; +with qn as (select 123 as col) +select * from qn, qn as qn1; +col col +123 123 +show status like "handler_write"; +Variable_name Value +Handler_write 1 +create view qn as select 123 as col; +flush status; +select * from qn, qn as qn1; +col col +123 123 +show status like "handler_write"; +Variable_name Value +Handler_write 2 +drop view qn; +drop table t1; +# Printing of WITH to DD for view +create view v as +select (with qn as (select "with") select * from qn) as scal_subq +from dual; +show create view v; +View Create View character_set_client collation_connection +v CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v` AS select (with `qn` as (select 'with' AS `with`) select `qn`.`with` from `qn`) AS `scal_subq` utf8mb4 utf8mb4_0900_ai_ci +select * from v; +scal_subq +with +drop view v; +create view v as select * from (with qn as (select "with") select * from qn) as dt; +show create view v; +View Create View character_set_client collation_connection +v CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v` AS select `dt`.`with` AS `with` from (with `qn` as (select 'with' AS `with`) select `qn`.`with` AS `with` from `qn`) `dt` utf8mb4 utf8mb4_0900_ai_ci +select * from v; +with +with +drop view v; +# Printing of merged/materialized QN, with or without alias +create table t1 (a int); +explain with qne as (select a from t1), +qnm as (select a from t1), +qnea as (select a from t1), +qnma as (select a from t1) +select /*+ merge(qne) no_merge(qnm) merge(alias1) no_merge(alias2) */ +qne.a,qnm.a,alias1.a,alias2.a +from qne, qnm, qnea as alias1, qnma as alias2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using join buffer (hash join) +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +5 DERIVED t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +3 DERIVED t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 with `qnm` as (/* select#3 */ select `test`.`t1`.`a` AS `a` from `test`.`t1`), `qnma` as (/* select#5 */ select `test`.`t1`.`a` AS `a` from `test`.`t1`) /* select#1 */ select /*+ MERGE(`qne`@`select#1`) NO_MERGE(`qnm`@`select#1`) MERGE(`alias1`@`select#1`) NO_MERGE(`alias2`@`select#1`) */ `test`.`t1`.`a` AS `a`,`qnm`.`a` AS `a`,`test`.`t1`.`a` AS `a`,`alias2`.`a` AS `a` from `test`.`t1` join `qnm` join `test`.`t1` join `qnma` `alias2` +drop table t1; +# Automatic index creation if materialized +create table t1 (a int); +insert into t1(a) values (1),(2),(3),(4),(5),(6),(7),(8),(9),(0); +analyze table t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +# EXPLAIN should not fill the tmp table +flush status; +# Should use auto_key0 and ref access. +explain with tt as (select * from t1) +select /*+ no_merge(tt) */ tt.a +from t1 straight_join tt where t1.a=tt.a +limit 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL # 100.00 Using where +1 PRIMARY NULL ref 5 test.t1.a # 100.00 Using index +2 DERIVED t1 NULL ALL NULL NULL NULL NULL # 100.00 NULL +Warnings: +Note 1003 with `tt` as (/* select#2 */ select `test`.`t1`.`a` AS `a` from `test`.`t1`) /* select#1 */ select /*+ NO_MERGE(`tt`@`select#1`) */ `tt`.`a` AS `a` from `test`.`t1` straight_join `tt` where (`tt`.`a` = `test`.`t1`.`a`) limit 1 +show status like "handler_write"; +Variable_name Value +Handler_write 0 +flush status; +with tt as (select * from t1) +select /*+ no_merge(tt) */ tt.a +from t1 straight_join tt where t1.a=tt.a +limit 1; +a +1 +show status like "handler_write"; +Variable_name Value +Handler_write 10 +# With two references +with tt as (select * from t1) +select /*+ no_merge(tt) no_merge(tt_)*/ tt.a +from t1 straight_join tt straight_join tt as tt_ +where t1.a=tt.a and tt.a=tt_.a +limit 1; +a +1 +# One merged, one materialized: index creation on the second +# should of course ignore the first +with q as (select * from t1) +select /*+ merge(q) no_merge(q1) */ * from q, q q1 where q.a=1 and q1.a=2; +a a +1 2 +drop table t1; +# Must not create more than 64 indexes. +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +(select max(c1) from qn where qn.c1=1) (select max(c2) from qn where qn.c2=1) (select max(c3) from qn where qn.c3=1) (select max(c4) from qn where qn.c4=1) (select max(c5) from qn where qn.c5=1) (select max(c6) from qn where qn.c6=1) (select max(c7) from qn where qn.c7=1) (select max(c8) from qn where qn.c8=1) (select max(c9) from qn where qn.c9=1) (select max(c10) from qn where qn.c10=1) (select max(c11) from qn where qn.c11=1) (select max(c12) from qn where qn.c12=1) (select max(c13) from qn where qn.c13=1) (select max(c14) from qn where qn.c14=1) (select max(c15) from qn where qn.c15=1) (select max(c16) from qn where qn.c16=1) (select max(c17) from qn where qn.c17=1) (select max(c18) from qn where qn.c18=1) (select max(c19) from qn where qn.c19=1) (select max(c20) from qn where qn.c20=1) (select max(c21) from qn where qn.c21=1) (select max(c22) from qn where qn.c22=1) (select max(c23) from qn where qn.c23=1) (select max(c24) from qn where qn.c24=1) (select max(c25) from qn where qn.c25=1) (select max(c26) from qn where qn.c26=1) (select max(c27) from qn where qn.c27=1) (select max(c28) from qn where qn.c28=1) (select max(c29) from qn where qn.c29=1) (select max(c30) from qn where qn.c30=1) (select max(c31) from qn where qn.c31=1) (select max(c32) from qn where qn.c32=1) (select max(c33) from qn where qn.c33=1) (select max(c34) from qn where qn.c34=1) (select max(c35) from qn where qn.c35=1) (select max(c36) from qn where qn.c36=1) (select max(c37) from qn where qn.c37=1) (select max(c38) from qn where qn.c38=1) (select max(c39) from qn where qn.c39=1) (select max(c40) from qn where qn.c40=1) (select max(c41) from qn where qn.c41=1) (select max(c42) from qn where qn.c42=1) (select max(c43) from qn where qn.c43=1) (select max(c44) from qn where qn.c44=1) (select max(c45) from qn where qn.c45=1) (select max(c46) from qn where qn.c46=1) (select max(c47) from qn where qn.c47=1) (select max(c48) from qn where qn.c48=1) (select max(c49) from qn where qn.c49=1) (select max(c50) from qn where qn.c50=1) (select max(c51) from qn where qn.c51=1) (select max(c52) from qn where qn.c52=1) (select max(c53) from qn where qn.c53=1) (select max(c54) from qn where qn.c54=1) (select max(c55) from qn where qn.c55=1) (select max(c56) from qn where qn.c56=1) (select max(c57) from qn where qn.c57=1) (select max(c58) from qn where qn.c58=1) (select max(c59) from qn where qn.c59=1) (select max(c60) from qn where qn.c60=1) (select max(c61) from qn where qn.c61=1) (select max(c62) from qn where qn.c62=1) (select max(c63) from qn where qn.c63=1) (select max(c64) from qn where qn.c64=1) (select max(c65) from qn where qn.c65=1) (select max(c66) from qn where qn.c66=1) (select max(c67) from qn where qn.c67=1) (select max(c68) from qn where qn.c68=1) (select max(c69) from qn where qn.c69=1) (select max(c70) from qn where qn.c70=1) (select max(c71) from qn where qn.c71=1) (select max(c72) from qn where qn.c72=1) (select max(c73) from qn where qn.c73=1) (select max(c74) from qn where qn.c74=1) (select max(c75) from qn where qn.c75=1) (select max(c76) from qn where qn.c76=1) (select max(c77) from qn where qn.c77=1) (select max(c78) from qn where qn.c78=1) (select max(c79) from qn where qn.c79=1) (select max(c80) from qn where qn.c80=1) (select max(c81) from qn where qn.c81=1) (select max(c82) from qn where qn.c82=1) (select max(c83) from qn where qn.c83=1) (select max(c84) from qn where qn.c84=1) (select max(c85) from qn where qn.c85=1) (select max(c86) from qn where qn.c86=1) (select max(c87) from qn where qn.c87=1) (select max(c88) from qn where qn.c88=1) (select max(c89) from qn where qn.c89=1) (select max(c90) from qn where qn.c90=1) (select max(c91) from qn where qn.c91=1) (select max(c92) from qn where qn.c92=1) (select max(c93) from qn where qn.c93=1) (select max(c94) from qn where qn.c94=1) (select max(c95) from qn where qn.c95=1) (select max(c96) from qn where qn.c96=1) (select max(c97) from qn where qn.c97=1) (select max(c98) from qn where qn.c98=1) (select max(c99) from qn where qn.c99=1) (select max(c100) from qn where qn.c100=1) +NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL +drop table t; +# Choice between two auto_key: +create table t1(a int, b int); +insert into t1 values (null, 6), (null, 10); +# Test the covering key; note that MEMORY doesn't use a +# covering key (always reads the "data file"). But InnoDB does. +EXPLAIN with t2 as +(select * from t1) +SELECT /*+ no_merge(t2) */ * FROM t2 +WHERE (a = a OR b <= 6) AND (a IS NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DERIVED t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1003 with `t2` as (/* select#2 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (((`test`.`t1`.`a` = `test`.`t1`.`a`) or (`test`.`t1`.`b` <= 6)) and (`test`.`t1`.`a` is null))) /* select#1 */ select /*+ NO_MERGE(`t2`@`select#1`) */ `t2`.`a` AS `a`,`t2`.`b` AS `b` from `t2` +with t2 as +(select * from t1) +SELECT /*+ no_merge(t2) */ * FROM t2 +WHERE (a = a OR b <= 6) AND (a IS NULL); +a b +NULL 6 +drop table t1; +# QN referencing view of same name isn't a "recursive view", +# shouldn't cause ER_VIEW_RECURSIVE +create view v1 as select "with"; +with v1 as (select * from v1) select * from v1; +with +with +drop view v1; +# QN inside view +create view v1 as +with qn as (select 1 as col) select * from qn; +select * from v1; +col +1 +drop view v1; +create table t1(a int, b int); +# Alas merge hints are ignored in views (filed Bug#23017428) +create view v1 as +with qn as (select a from t1), +qn2 as (select b from t1) +select /*+ merge(qn) no_merge(qn2) */ qn.a,qn2.b from qn, qn2; +explain select * from v1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` join `test`.`t1` +drop view v1; +# Materializing view doesn't impose materializing query name +create algorithm=temptable view v1 as +with qn as (select a from t1) +select qn.a from qn; +explain select * from v1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DERIVED t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`v1`.`a` AS `a` from `test`.`v1` +drop view v1; +drop table t1; +# CTE referenced four times, including in subqueries in other CTEs +create table sales_days(day_of_sale DATE, amount INT); +insert into sales_days values +('2015-01-02', 100), ('2015-01-05', 200), +('2015-02-02', 10), ('2015-02-10', 100), +('2015-03-02', 10), ('2015-03-18', 1); +with +# first CTE: one row per month, with amount sold on all days of month +sales_by_month(month,total) as +(select month(day_of_sale), sum(amount) from sales_days +where year(day_of_sale)=2015 +group by month(day_of_sale)), +# second CTE: best month +best_month(month, total, award) as +(select month, total, "best" from sales_by_month +where total=(select max(total) from sales_by_month)), +# 3rd CTE: worst month +worst_month(month, total, award) as +(select month, total, "worst" from sales_by_month +where total=(select min(total) from sales_by_month)) +# Now show results: +select * from best_month union all select * from worst_month; +month total award +1 300 best +3 11 worst +drop table sales_days; +# Special parser command not allowed to users. +parse_cte ( select 1 ) ; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'parse_cte ( select 1 )' at line 1 +# Query names are a partial workaround to the problem that +# user-created temp tables can't be referenced twice. +create temporary table tmp(a int) as select 1; +select * from tmp, tmp tmp1; +ERROR HY000: Can't reopen table: 'tmp' +# the workaround works if the temp table's life is necessary +# only for a single statement: +with qn as (select 1) select * from qn, qn qn1; +1 1 +1 1 +# If the tmp table is necessary, wrapping it in a query name doesn't +# help: +with qn as (select * from tmp) select /*+ merge(qn,qn1) */ * from qn, qn qn1; +ERROR HY000: Can't reopen table: 'tmp' +with qn as (select * from tmp) select /*+ no_merge(qn,qn1) */ * from qn, qn qn1; +ERROR HY000: Can't reopen table: 'tmp' +drop temporary table tmp; +# Using a query name in UPDATE +create table t1(a int, b int); +insert into t1 values(1,2),(3,4); +create table t2 select * from t1; +set autocommit=0; +# Multi-table syntax +with qn as (select a, b from t1) update t1, qn set qn.a=qn.a+10; +ERROR HY000: The target table t1 of the UPDATE is not updatable +select * from t1; +a b +1 2 +3 4 +rollback; +explain with qn as (select a+2 as a, b from t1) update t1, qn set t1.a=qn.a+10 where t1.a-qn.a=0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +Warnings: +Note 1003 update `test`.`t1` join `test`.`t1` set `test`.`t1`.`a` = ((`test`.`t1`.`a` + 2) + 10) where ((`test`.`t1`.`a` - (`test`.`t1`.`a` + 2)) = 0) +with qn as (select a+2 as a, b from t1) update t1, qn set t1.a=qn.a+10 where t1.a-qn.a=0; +select * from t1; +a b +1 2 +13 4 +rollback; +explain with qn as (select a+2 as a, b from t2) update t1, qn set t1.a=qn.a+10 where t1.a-qn.a=0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +Warnings: +Note 1003 update `test`.`t1` join `test`.`t2` set `test`.`t1`.`a` = ((`test`.`t2`.`a` + 2) + 10) where ((`test`.`t1`.`a` - (`test`.`t2`.`a` + 2)) = 0) +with qn as (select a+2 as a, b from t2) update t1, qn set t1.a=qn.a+10 where t1.a-qn.a=0; +select * from t1; +a b +1 2 +13 4 +rollback; +explain with qn as (select a+2 as a, b from t2) update /*+ no_merge(qn) */ t1, qn set t1.a=qn.a+10 where t1.a-qn.a=0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 Using where +2 DERIVED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 with `qn` as (/* select#2 */ select (`test`.`t2`.`a` + 2) AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t2`) update /*+ NO_MERGE(`qn`@`select#1`) */ `test`.`t1` join `qn` set `test`.`t1`.`a` = (`qn`.`a` + 10) where ((`test`.`t1`.`a` - `qn`.`a`) = 0) +with qn as (select a+2 as a, b from t2) update /*+ no_merge(qn) */ t1, qn set t1.a=qn.a+10 where t1.a-qn.a=0; +select * from t1; +a b +1 2 +13 4 +rollback; +# Two references to query name +explain with qn as (select a+2 as a, b from t2) +update t1, qn, qn as qn2 set t1.a=qn.a+10 where t1.a-qn.a=0 and qn.b=qn2.b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1003 update `test`.`t1` join `test`.`t2` join `test`.`t2` set `test`.`t1`.`a` = ((`test`.`t2`.`a` + 2) + 10) where ((`test`.`t2`.`b` = `test`.`t2`.`b`) and ((`test`.`t1`.`a` - (`test`.`t2`.`a` + 2)) = 0)) +with qn as (select a+2 as a, b from t2) +update t1, qn, qn as qn2 set t1.a=qn.a+10 where t1.a-qn.a=0 and qn.b=qn2.b; +select * from t1; +a b +1 2 +13 4 +rollback; +# Single-table syntax +explain with qn as (select a+2 as a, b from t2) update t1 +set t1.a=(select qn.a+10 from qn where t1.a-qn.a=0 limit 1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DEPENDENT SUBQUERY NULL ALL NULL NULL NULL NULL 2 100.00 Using where +3 DERIVED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 with `qn` as (/* select#3 */ select (`test`.`t2`.`a` + 2) AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t2`) update `test`.`t1` set `test`.`t1`.`a` = (/* select#2 */ select (`qn`.`a` + 10) from `qn` where ((`test`.`t1`.`a` - `qn`.`a`) = 0) limit 1) +with qn as (select a+2 as a, b from t2) update t1 +set t1.a=(select qn.a+10 from qn where t1.a-qn.a=0 limit 1); +select * from t1; +a b +NULL 2 +13 4 +rollback; +explain with qn as (select a+2 as a, b from t2) update t1 +set t1.a=(select /*+ merge(qn) */ qn.a+10 from qn where t1.a-qn.a=0 limit 1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 update /*+ MERGE(`qn`@`select#2`) */ `test`.`t1` set `test`.`t1`.`a` = (/* select#2 */ select ((`test`.`t2`.`a` + 2) + 10) from `test`.`t2` where ((`test`.`t1`.`a` - (`test`.`t2`.`a` + 2)) = 0) limit 1) +with qn as (select a+2 as a, b from t2) update t1 +set t1.a=(select /*+ merge(qn) */ qn.a+10 from qn where t1.a-qn.a=0 limit 1); +select * from t1; +a b +NULL 2 +13 4 +rollback; +# Using a query name in DELETE +# Multi-table syntax +with qn as (select a, b from t1) delete qn from t1,qn; +ERROR HY000: The target table qn of the DELETE is not updatable +select * from t1; +a b +1 2 +3 4 +rollback; +explain with qn as (select a+2 as a, b from t1) delete t1 from t1, qn where t1.a-qn.a=0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +Warnings: +Note 1003 delete `test`.`t1` from `test`.`t1` join `test`.`t1` where ((`test`.`t1`.`a` - (`test`.`t1`.`a` + 2)) = 0) +with qn as (select a+2 as a, b from t1) delete t1 from t1, qn where t1.a-qn.a=0; +select * from t1; +a b +1 2 +rollback; +explain with qn as (select a+2 as a, b from t2) delete t1 from t1, qn where t1.a-qn.a=0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +Warnings: +Note 1003 delete `test`.`t1` from `test`.`t1` join `test`.`t2` where ((`test`.`t1`.`a` - (`test`.`t2`.`a` + 2)) = 0) +with qn as (select a+2 as a, b from t2) delete t1 from t1, qn where t1.a-qn.a=0; +select * from t1; +a b +1 2 +rollback; +explain with qn as (select a+2 as a, b from t2) delete /*+ no_merge(qn) */ t1 from t1, qn where t1.a-qn.a=0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 Using where +2 DERIVED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 with `qn` as (/* select#2 */ select (`test`.`t2`.`a` + 2) AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t2`) delete /*+ NO_MERGE(`qn`@`select#1`) */ `test`.`t1` from `test`.`t1` join `qn` where ((`test`.`t1`.`a` - `qn`.`a`) = 0) +with qn as (select a+2 as a, b from t2) delete /*+ no_merge(qn) */ t1 from t1, qn where t1.a-qn.a=0; +select * from t1; +a b +1 2 +rollback; +explain with qn as (select a+2 as a, b from t2) +delete t1 from t1, qn, qn as qn2 where t1.a-qn.a=0 and qn.b=qn2.b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1003 delete `test`.`t1` from `test`.`t1` join `test`.`t2` join `test`.`t2` where ((`test`.`t2`.`b` = `test`.`t2`.`b`) and ((`test`.`t1`.`a` - (`test`.`t2`.`a` + 2)) = 0)) +with qn as (select a+2 as a, b from t2) +delete t1 from t1, qn, qn as qn2 where t1.a-qn.a=0 and qn.b=qn2.b; +select * from t1; +a b +1 2 +rollback; +# Single-table syntax +explain with qn as (select a+2 as a, b from t2) +delete from t1 where t1.a=(select qn.a from qn where t1.a-qn.a=0 limit 1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 DEPENDENT SUBQUERY NULL ALL NULL NULL NULL NULL 2 100.00 Using where +3 DERIVED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 with `qn` as (/* select#3 */ select (`test`.`t2`.`a` + 2) AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t2`) delete from `test`.`t1` where (`test`.`t1`.`a` = (/* select#2 */ select `qn`.`a` from `qn` where ((`test`.`t1`.`a` - `qn`.`a`) = 0) limit 1)) +with qn as (select a+2 as a, b from t2) +delete from t1 where t1.a=(select qn.a from qn where t1.a-qn.a=0 limit 1); +select * from t1; +a b +1 2 +rollback; +explain with qn as (select a+2 as a, b from t2) +delete from t1 where t1.a=(select /*+ merge(qn) */ qn.a from qn where t1.a-qn.a=0 limit 1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 delete /*+ MERGE(`qn`@`select#2`) */ from `test`.`t1` where (`test`.`t1`.`a` = (/* select#2 */ select (`test`.`t2`.`a` + 2) from `test`.`t2` where ((`test`.`t1`.`a` - (`test`.`t2`.`a` + 2)) = 0) limit 1)) +with qn as (select a+2 as a, b from t2) +delete from t1 where t1.a=(select /*+ merge(qn) */ qn.a from qn where t1.a-qn.a=0 limit 1); +select * from t1; +a b +1 2 +rollback; +drop table t1,t2; +set autocommit=default; +# No default db +select database(); +database() +test +create database mysqltest1; +use mysqltest1; +drop database mysqltest1; +select database(); +database() +NULL +with qn as (select 1) select * from qn; +1 +1 +# Back to usual db 'test' +use test; +show status like 'Created_tmp_disk_tables'; +Variable_name Value +Created_tmp_disk_tables 17 diff --git a/mysql-test/suite/all_vars.result-pq b/mysql-test/suite/all_vars.result-pq new file mode 100644 index 000000000000..9c4053b4fe39 --- /dev/null +++ b/mysql-test/suite/all_vars.result-pq @@ -0,0 +1,92 @@ +create table t1 (test_name text); +create table t2 (variable_name text); +load data infile "MYSQLTEST_VARDIR/tmp/sys_vars.all_vars.txt" into table t1; +insert into t2 select variable_name from performance_schema.global_variables; +insert into t2 select variable_name from performance_schema.session_variables; +update t2 set variable_name= replace(variable_name, "performance_schema_", "pfs_"); +update t2 set variable_name= replace(variable_name, "_history_long_", "_hl_"); +update t2 set variable_name= replace(variable_name, "_history_", "_h_"); +update t2 set variable_name= replace(variable_name, "_throttle_queries_not_using_indexes", "_throttle_qni"); +update t2 set variable_name= replace(variable_name, "lock_order_", "lo_"); +select variable_name as `There should be *no* long test name listed below:` from t2 +where length(variable_name) > 50; +There should be *no* long test name listed below: +select variable_name as `There should be *no* variables listed below:` from t2 +left join t1 on variable_name=test_name where test_name is null ORDER BY variable_name; +There should be *no* variables listed below: +activate_all_roles_on_login +activate_all_roles_on_login +binlog_encryption +binlog_encryption +binlog_rotate_encryption_master_key_at_startup +binlog_rotate_encryption_master_key_at_startup +cte_max_recursion_depth +cte_max_recursion_depth +default_collation_for_utf8mb4 +default_collation_for_utf8mb4 +disabled_storage_engines +disabled_storage_engines +force_parallel_execute +force_parallel_execute +generated_random_password_length +generated_random_password_length +group_replication_consistency +group_replication_consistency +innodb_dedicated_server +innodb_dedicated_server +innodb_log_spin_cpu_abs_lwm +innodb_log_spin_cpu_abs_lwm +innodb_log_spin_cpu_pct_hwm +innodb_log_spin_cpu_pct_hwm +innodb_log_wait_for_flush_spin_hwm +innodb_log_wait_for_flush_spin_hwm +keyring_operations +keyring_operations +mandatory_roles +mandatory_roles +max_length_for_sort_data +max_length_for_sort_data +parallel_cost_threshold +parallel_cost_threshold +parallel_default_dop +parallel_default_dop +parallel_max_threads +parallel_max_threads +parallel_memory_limit +parallel_memory_limit +parallel_queue_timeout +parallel_queue_timeout +partial_revokes +partial_revokes +password_require_current +password_require_current +regexp_stack_limit +regexp_stack_limit +regexp_time_limit +regexp_time_limit +replication_optimize_for_static_plugin_config +replication_optimize_for_static_plugin_config +replication_sender_observe_commit_only +replication_sender_observe_commit_only +resultset_metadata +select_into_buffer_size +select_into_buffer_size +select_into_disk_sync +select_into_disk_sync +select_into_disk_sync_delay +select_into_disk_sync_delay +skip_slave_start +skip_slave_start +sql_require_primary_key +sql_require_primary_key +temptable_max_mmap +temptable_max_mmap +temptable_use_mmap +temptable_use_mmap +tls_ciphersuites +tls_ciphersuites +tls_version +tls_version +use_secondary_engine +drop table t1; +drop table t2; diff --git a/mysql-test/suite/batch_table_io_func.result-pq b/mysql-test/suite/batch_table_io_func.result-pq new file mode 100644 index 000000000000..0bc09ff22dd4 --- /dev/null +++ b/mysql-test/suite/batch_table_io_func.result-pq @@ -0,0 +1,188 @@ +UPDATE performance_schema.setup_instruments SET enabled = 'NO', timed = 'YES'; +UPDATE performance_schema.setup_instruments SET enabled = 'YES' +WHERE name in ('wait/io/table/sql/handler', +'wait/lock/table/sql/handler'); +drop procedure if exists before_payload; +drop procedure if exists after_payload; +create procedure before_payload() +begin +TRUNCATE TABLE performance_schema.table_io_waits_summary_by_index_usage; +TRUNCATE TABLE performance_schema.table_io_waits_summary_by_table; +TRUNCATE TABLE performance_schema.events_waits_history_long; +TRUNCATE TABLE performance_schema.events_waits_history; +TRUNCATE TABLE performance_schema.events_waits_current; +end +$$ +create procedure after_payload() +begin +select count(1) as number_seen, +OBJECT_TYPE, OBJECT_SCHEMA, OBJECT_NAME, INDEX_NAME, +OPERATION, NUMBER_OF_BYTES +from performance_schema.events_waits_history_long +where OBJECT_SCHEMA = "test" + group by OBJECT_TYPE, OBJECT_SCHEMA, OBJECT_NAME, INDEX_NAME, OPERATION, NUMBER_OF_BYTES; +select OBJECT_TYPE, OBJECT_SCHEMA, OBJECT_NAME, INDEX_NAME, +COUNT_STAR, COUNT_READ, COUNT_WRITE +from performance_schema.table_io_waits_summary_by_index_usage +where OBJECT_SCHEMA = "test" + order by OBJECT_TYPE, OBJECT_SCHEMA, OBJECT_NAME, INDEX_NAME; +select OBJECT_TYPE, OBJECT_SCHEMA, OBJECT_NAME, +COUNT_STAR, COUNT_READ, COUNT_WRITE +from performance_schema.table_io_waits_summary_by_table +where OBJECT_SCHEMA = "test" + order by OBJECT_TYPE, OBJECT_SCHEMA, OBJECT_NAME; +end +$$ +drop table if exists t1; +drop table if exists t2; +drop table if exists t3; +create table t0(v int); +create table t1(id1 int, a int); +create table t2(id1 int, id2 int, b int); +create table t3(id2 int, id3 int, c int); +insert into t0 values +(0), (1), (2), (3), (4), +(5), (6), (7), (8), (9); +insert into t1(id1, a) +select v, 100*v from t0; +insert into t2(id1, id2, b) +select X.v, 10*X.v + Y.v, 100*X.v + 10*Y.v +from t0 X, t0 Y; +insert into t3(id2, id3, c) +select 10*X.v + Y.v, 100*X.v + 10*Y.v + Z.v, 100*X.v + 10*Y.v + Z.v +from t0 X, t0 Y, t0 Z; +analyze table t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +analyze table t2; +Table Op Msg_type Msg_text +test.t2 analyze status OK +analyze table t3; +Table Op Msg_type Msg_text +test.t3 analyze status OK +select * from t1 order by a; +id1 a +0 0 +1 100 +2 200 +3 300 +4 400 +5 500 +6 600 +7 700 +8 800 +9 900 +select * from t2 +where (b >= 180) and (b <= 220) +order by b; +id1 id2 b +1 18 180 +1 19 190 +2 20 200 +2 21 210 +2 22 220 +select * from t3 +where (c >= 587) and (c <= 612) +order by c; +id2 id3 c +58 587 587 +58 588 588 +58 589 589 +59 590 590 +59 591 591 +59 592 592 +59 593 593 +59 594 594 +59 595 595 +59 596 596 +59 597 597 +59 598 598 +59 599 599 +60 600 600 +60 601 601 +60 602 602 +60 603 603 +60 604 604 +60 605 605 +60 606 606 +60 607 607 +60 608 608 +60 609 609 +61 610 610 +61 611 611 +61 612 612 +explain select t1.*, t2.*, t3.* +from t1 join t2 using (id1) join t3 using (id2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 100 10.00 Using where; Using join buffer (hash join) +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1000 10.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id1` AS `id1`,`test`.`t1`.`a` AS `a`,`test`.`t2`.`id1` AS `id1`,`test`.`t2`.`id2` AS `id2`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`id2` AS `id2`,`test`.`t3`.`id3` AS `id3`,`test`.`t3`.`c` AS `c` from `test`.`t1` join `test`.`t2` join `test`.`t3` where ((`test`.`t2`.`id1` = `test`.`t1`.`id1`) and (`test`.`t3`.`id2` = `test`.`t2`.`id2`)) +call before_payload(); +select t1.*, t2.*, t3.* +from t1 join t2 using (id1) join t3 using (id2); +call after_payload(); +number_seen OBJECT_TYPE OBJECT_SCHEMA OBJECT_NAME INDEX_NAME OPERATION NUMBER_OF_BYTES +3 TABLE test t1 NULL read external NULL +3 TABLE test t2 NULL read external NULL +3 TABLE test t3 NULL read external NULL +1 TABLE test t1 NULL fetch 10 +1 TABLE test t2 NULL fetch 100 +1 TABLE test t3 NULL fetch 1000 +OBJECT_TYPE OBJECT_SCHEMA OBJECT_NAME INDEX_NAME COUNT_STAR COUNT_READ COUNT_WRITE +TABLE test t0 NULL 0 0 0 +TABLE test t1 NULL 10 10 0 +TABLE test t2 NULL 100 100 0 +TABLE test t3 NULL 1000 1000 0 +OBJECT_TYPE OBJECT_SCHEMA OBJECT_NAME COUNT_STAR COUNT_READ COUNT_WRITE +TABLE test t0 0 0 0 +TABLE test t1 10 10 0 +TABLE test t2 100 100 0 +TABLE test t3 1000 1000 0 +alter table t1 add unique index(id1); +alter table t2 add unique index(id2); +alter table t2 add index(id1); +alter table t3 add unique index(id3); +alter table t3 add index(id2); +explain select t1.*, t2.*, t3.* +from t1 join t2 using (id1) join t3 using (id2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL id1 NULL NULL NULL 10 100.00 Using where +2 SIMPLE t2 NULL ref id2,id1 id1 5 test.t1.id1 10 100.00 Using where +2 SIMPLE t3 NULL ref id2 id2 5 test.t2.id2 10 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id1` AS `id1`,`test`.`t1`.`a` AS `a`,`test`.`t2`.`id1` AS `id1`,`test`.`t2`.`id2` AS `id2`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`id2` AS `id2`,`test`.`t3`.`id3` AS `id3`,`test`.`t3`.`c` AS `c` from `test`.`t1` join `test`.`t2` join `test`.`t3` where ((`test`.`t2`.`id1` = `test`.`t1`.`id1`) and (`test`.`t3`.`id2` = `test`.`t2`.`id2`)) +call before_payload(); +select t1.*, t2.*, t3.* +from t1 join t2 using (id1) join t3 using (id2); +call after_payload(); +number_seen OBJECT_TYPE OBJECT_SCHEMA OBJECT_NAME INDEX_NAME OPERATION NUMBER_OF_BYTES +3 TABLE test t1 id1 read external NULL +3 TABLE test t2 id2 read external NULL +3 TABLE test t3 id3 read external NULL +11 TABLE test t1 NULL fetch 1 +110 TABLE test t2 id1 fetch 1 +100 TABLE test t3 id2 fetch 10 +OBJECT_TYPE OBJECT_SCHEMA OBJECT_NAME INDEX_NAME COUNT_STAR COUNT_READ COUNT_WRITE +TABLE test t0 NULL 0 0 0 +TABLE test t1 NULL 11 11 0 +TABLE test t1 id1 0 0 0 +TABLE test t2 id1 110 110 0 +TABLE test t2 id2 0 0 0 +TABLE test t3 id2 1000 1000 0 +TABLE test t3 id3 0 0 0 +OBJECT_TYPE OBJECT_SCHEMA OBJECT_NAME COUNT_STAR COUNT_READ COUNT_WRITE +TABLE test t0 0 0 0 +TABLE test t1 11 11 0 +TABLE test t2 110 110 0 +TABLE test t3 1000 1000 0 +drop table t0; +drop table t1; +drop table t2; +drop table t3; +drop procedure before_payload; +drop procedure after_payload; +UPDATE performance_schema.setup_instruments SET enabled = 'YES', timed = 'YES'; diff --git a/mysql-test/suite/bugs_no_prot_all.result-pq b/mysql-test/suite/bugs_no_prot_all.result-pq new file mode 100644 index 000000000000..13a24052ac6c --- /dev/null +++ b/mysql-test/suite/bugs_no_prot_all.result-pq @@ -0,0 +1,3121 @@ +set optimizer_switch='semijoin=on,materialization=on,firstmatch=on,loosescan=on,index_condition_pushdown=on,mrr=on,mrr_cost_based=off'; +set optimizer_trace_max_mem_size=1048576; +SET end_markers_in_json=on; +SET optimizer_trace="enabled=on,one_line=off"; +# +# BUG#12430646 - SEL_ARG::LEFT AND RIGHT POINTERS INCORRECTLY +# USED. CRASHES OPTIMIZER TRACING +# +CREATE TABLE t1 ( +a INT, +b CHAR(2), +c INT, +d INT, +KEY (c), +KEY (d,a,b(2)), +KEY (b(1)) +); +INSERT INTO t1 VALUES (NULL, 'a', 1, 2), (NULL, 'a', 1, 2), +(1, 'a', 1, 2), (1, 'a', 1, 2); +CREATE TABLE t2 ( +a INT, +c INT, +e INT, +KEY (e) +); +INSERT INTO t2 VALUES (1, 1, NULL), (1, 1, NULL); +SELECT 1 +FROM t1, t2 +WHERE t1.d <> '1' AND t1.b > '1' +AND t1.a = t2.a AND t1.c = t2.c; +1 +1 +1 +1 +1 +DROP TABLE t1, t2; +# +# BUG#12595210 - JSON SYNTAX ERROR ASSERT ON WHERE FIELD NOT IN SUBQUERY +# +CREATE TABLE t1 ( +pk INT NOT NULL AUTO_INCREMENT, +col_int_key INT DEFAULT NULL, +col_varchar_key VARCHAR(1) DEFAULT NULL, +PRIMARY KEY (pk) +) ENGINE=InnoDB, CHARSET utf8mb4; +CREATE TABLE t2 ( +pk INT NOT NULL AUTO_INCREMENT, +col_int_key INT DEFAULT NULL, +col_varchar_key VARCHAR(1) DEFAULT NULL, +col_varchar_nokey VARCHAR(1) DEFAULT NULL, +PRIMARY KEY (pk) +) ENGINE=InnoDB, CHARSET utf8mb4; +CREATE TABLE t3 ( +pk INT NOT NULL AUTO_INCREMENT, +col_int_key INT DEFAULT NULL, +col_varchar_key VARCHAR(1) DEFAULT NULL, +col_varchar_nokey VARCHAR(1) DEFAULT NULL, +PRIMARY KEY (pk) +) ENGINE=InnoDB, CHARSET utf8mb4; +CREATE TABLE t4 ( +pk INT NOT NULL AUTO_INCREMENT, +col_int_key INT DEFAULT NULL, +col_varchar_key VARCHAR(1) DEFAULT NULL, +PRIMARY KEY (pk) +) ENGINE=InnoDB, CHARSET utf8mb4; +CREATE VIEW view_t4 AS SELECT * FROM t4; +CREATE TABLE where_subselect_19379 SELECT +( +SELECT SUM(sq1_alias1.pk) AS sq1_field1 +FROM view_t4 AS sq1_alias1 +INNER JOIN t1 AS sq1_alias2 ON (sq1_alias2.col_varchar_key = +sq1_alias1.col_varchar_key ) +) AS field1, +alias1.col_varchar_nokey AS field2 +FROM (t2 AS alias1 +LEFT JOIN ( t2 AS alias2 +LEFT OUTER JOIN t2 AS alias3 ON (alias3.col_varchar_nokey = +alias2.col_varchar_key ) +) ON (alias3.col_varchar_key = alias2.col_varchar_key) +) +WHERE ( alias2.col_varchar_key IN ( +SELECT sq2_alias1.col_varchar_nokey AS sq2_field1 +FROM t3 AS sq2_alias1 +WHERE sq2_alias1.col_varchar_nokey <= alias1.col_varchar_key +) +); +SELECT * FROM where_subselect_19379 WHERE (field1, field2) NOT IN +(SELECT +( +SELECT SUM(sq1_alias1.pk) AS sq1_field1 +FROM view_t4 AS sq1_alias1 +INNER JOIN t1 AS sq1_alias2 ON (sq1_alias2.col_varchar_key = +sq1_alias1.col_varchar_key ) +) AS field1, +alias1.col_varchar_nokey AS field2 +FROM (t2 AS alias1 +LEFT JOIN ( t2 AS alias2 +LEFT OUTER JOIN t2 AS alias3 ON (alias3.col_varchar_nokey = +alias2.col_varchar_key ) +) ON (alias3.col_varchar_key = alias2.col_varchar_key) +) +WHERE ( alias2.col_varchar_key IN ( +SELECT sq2_alias1.col_varchar_nokey AS sq2_field1 +FROM t3 AS sq2_alias1 +WHERE sq2_alias1.col_varchar_nokey <= alias1.col_varchar_key +) +)); +field1 field2 +select * from information_schema.OPTIMIZER_TRACE; +QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES +SELECT * FROM where_subselect_19379 WHERE (field1, field2) NOT IN +(SELECT +( +SELECT SUM(sq1_alias1.pk) AS sq1_field1 +FROM view_t4 AS sq1_alias1 +INNER JOIN t1 AS sq1_alias2 ON (sq1_alias2.col_varchar_key = +sq1_alias1.col_varchar_key ) +) AS field1, +alias1.col_varchar_nokey AS field2 +FROM (t2 AS alias1 +LEFT JOIN ( t2 AS alias2 +LEFT OUTER JOIN t2 AS alias3 ON (alias3.col_varchar_nokey = +alias2.col_varchar_key ) +) ON (alias3.col_varchar_key = alias2.col_varchar_key) +) +WHERE ( alias2.col_varchar_key IN ( +SELECT sq2_alias1.col_varchar_nokey AS sq2_field1 +FROM t3 AS sq2_alias1 +WHERE sq2_alias1.col_varchar_nokey <= alias1.col_varchar_key +) +)) { + "steps": [ + { + "join_preparation": { + "select#": 1, + "steps": [ + { + "join_preparation": { + "select#": 2, + "steps": [ + { + "join_preparation": { + "select#": 3, + "steps": [ + { + "join_preparation": { + "select#": 5, + "steps": [ + { + "expanded_query": "/* select#5 */ select `t4`.`pk` AS `pk`,`t4`.`col_int_key` AS `col_int_key`,`t4`.`col_varchar_key` AS `col_varchar_key` from `t4`" + } + ] /* steps */ + } /* join_preparation */ + }, + { + "view": { + "table": "`view_t4` `sq1_alias1`", + "select#": 5, + "merged": true + } /* view */ + }, + { + "expanded_query": "/* select#3 */ select sum(`t4`.`pk`) AS `sq1_field1` from ((`t4`) join `t1` `sq1_alias2` on((`sq1_alias2`.`col_varchar_key` = `t4`.`col_varchar_key`)))" + } + ] /* steps */ + } /* join_preparation */ + }, + { + "join_preparation": { + "select#": 4, + "steps": [ + { + "expanded_query": "/* select#4 */ select `sq2_alias1`.`col_varchar_nokey` AS `sq2_field1` from `t3` `sq2_alias1` where (`sq2_alias1`.`col_varchar_nokey` <= `alias1`.`col_varchar_key`)" + } + ] /* steps */ + } /* join_preparation */ + }, + { + "expanded_query": "/* select#2 */ select (/* select#3 */ select sum(`t4`.`pk`) AS `sq1_field1` from ((`t4`) join `t1` `sq1_alias2` on((`sq1_alias2`.`col_varchar_key` = `t4`.`col_varchar_key`)))) AS `field1`,`alias1`.`col_varchar_nokey` AS `field2` from (`t2` `alias1` left join (`t2` `alias2` left join `t2` `alias3` on((`alias3`.`col_varchar_nokey` = `alias2`.`col_varchar_key`))) on((`alias3`.`col_varchar_key` = `alias2`.`col_varchar_key`))) where `alias2`.`col_varchar_key` in (/* select#4 */ select `sq2_alias1`.`col_varchar_nokey` AS `sq2_field1` from `t3` `sq2_alias1` where (`sq2_alias1`.`col_varchar_nokey` <= `alias1`.`col_varchar_key`))" + }, + { + "transformation": { + "select#": 2, + "from": "IN (SELECT)", + "to": "EXISTS (CORRELATED SELECT)", + "chosen": true, + "evaluating_constant_where_conditions": [ + ] /* evaluating_constant_where_conditions */, + "evaluating_constant_having_conditions": [ + ] /* evaluating_constant_having_conditions */ + } /* transformation */ + }, + { + "transformation": { + "select#": 4, + "from": "IN (SELECT)", + "to": "semijoin", + "chosen": true, + "transformation_to_semi_join": { + "subquery_predicate": "`alias2`.`col_varchar_key` in (/* select#4 */ select `sq2_alias1`.`col_varchar_nokey` AS `sq2_field1` from `t3` `sq2_alias1` where (`sq2_alias1`.`col_varchar_nokey` <= `alias1`.`col_varchar_key`))", + "embedded in": "WHERE", + "evaluating_constant_semijoin_conditions": [ + ] /* evaluating_constant_semijoin_conditions */, + "semi-join condition": "((`sq2_alias1`.`col_varchar_nokey` <= `alias1`.`col_varchar_key`) and (`alias2`.`col_varchar_key` = `sq2_alias1`.`col_varchar_nokey`))", + "decorrelated_predicates": [ + { + "outer": "`alias2`.`col_varchar_key`", + "inner": "`sq2_alias1`.`col_varchar_nokey`" + } + ] /* decorrelated_predicates */ + } /* transformation_to_semi_join */ + } /* transformation */ + } + ] /* steps */ + } /* join_preparation */ + }, + { + "expanded_query": "/* select#1 */ select `where_subselect_19379`.`field1` AS `field1`,`where_subselect_19379`.`field2` AS `field2` from `where_subselect_19379` where ((`where_subselect_19379`.`field1`,`where_subselect_19379`.`field2`),(/* select#2 */ select (/* select#3 */ select sum(`t4`.`pk`) AS `sq1_field1` from ((`t4`) join `t1` `sq1_alias2` on((`sq1_alias2`.`col_varchar_key` = `t4`.`col_varchar_key`)))) AS `field1`,`alias1`.`col_varchar_nokey` AS `field2` from (`t2` `alias1` left join (`t2` `alias2` left join `t2` `alias3` on((`alias3`.`col_varchar_nokey` = `alias2`.`col_varchar_key`))) on((`alias3`.`col_varchar_key` = `alias2`.`col_varchar_key`))) semi join (`t3` `sq2_alias1`) where ((outer_field_is_not_null, (((`where_subselect_19379`.`field1`) = (/* select#3 */ select sum(`t4`.`pk`) AS `sq1_field1` from ((`t4`) join `t1` `sq1_alias2` on((`sq1_alias2`.`col_varchar_key` = `t4`.`col_varchar_key`))))) or ((/* select#3 */ select sum(`t4`.`pk`) AS `sq1_field1` from ((`t4`) join `t1` `sq1_alias2` on((`sq1_alias2`.`col_varchar_key` = `t4`.`col_varchar_key`)))) is null)), true) and (outer_field_is_not_null, (((`where_subselect_19379`.`field2`) = `alias1`.`col_varchar_nokey`) or (`alias1`.`col_varchar_nokey` is null)), true) and (`sq2_alias1`.`col_varchar_nokey` <= `alias1`.`col_varchar_key`) and (`alias2`.`col_varchar_key` = `sq2_alias1`.`col_varchar_nokey`)) having ((outer_field_is_not_null, ((/* select#3 */ select sum(`t4`.`pk`) AS `sq1_field1` from ((`t4`) join `t1` `sq1_alias2` on((`sq1_alias2`.`col_varchar_key` = `t4`.`col_varchar_key`))))), true) and (outer_field_is_not_null, (`alias1`.`col_varchar_nokey`), true))) is false)" + }, + { + "transformations_to_nested_joins": { + "transformations": [ + "JOIN_condition_to_WHERE", + "parenthesis_removal" + ] /* transformations */, + "expanded_query": "/* select#3 */ select sum(`t4`.`pk`) AS `sq1_field1` from `t4` join `t1` `sq1_alias2` where (`sq1_alias2`.`col_varchar_key` = `t4`.`col_varchar_key`)" + } /* transformations_to_nested_joins */ + }, + { + "transformations_to_nested_joins": { + "transformations": [ + "semijoin", + "outer_join_to_inner_join", + "JOIN_condition_to_WHERE", + "parenthesis_removal" + ] /* transformations */, + "expanded_query": "/* select#2 */ select (/* select#3 */ select sum(`t4`.`pk`) AS `sq1_field1` from `t4` join `t1` `sq1_alias2` where (`sq1_alias2`.`col_varchar_key` = `t4`.`col_varchar_key`)) AS `field1`,`alias1`.`col_varchar_nokey` AS `field2` from `t2` `alias1` join `t2` `alias2` join `t2` `alias3` semi join (`t3` `sq2_alias1`) where ((outer_field_is_not_null, (((`where_subselect_19379`.`field1`) = (/* select#3 */ select sum(`t4`.`pk`) AS `sq1_field1` from `t4` join `t1` `sq1_alias2` where (`sq1_alias2`.`col_varchar_key` = `t4`.`col_varchar_key`))) or ((/* select#3 */ select sum(`t4`.`pk`) AS `sq1_field1` from `t4` join `t1` `sq1_alias2` where (`sq1_alias2`.`col_varchar_key` = `t4`.`col_varchar_key`)) is null)), true) and (outer_field_is_not_null, (((`where_subselect_19379`.`field2`) = `alias1`.`col_varchar_nokey`) or (`alias1`.`col_varchar_nokey` is null)), true) and (`sq2_alias1`.`col_varchar_nokey` <= `alias1`.`col_varchar_key`) and (`alias2`.`col_varchar_key` = `sq2_alias1`.`col_varchar_nokey`) and (`alias3`.`col_varchar_key` = `alias2`.`col_varchar_key`) and (`alias3`.`col_varchar_nokey` = `alias2`.`col_varchar_key`)) having ((outer_field_is_not_null, ((/* select#3 */ select sum(`t4`.`pk`) AS `sq1_field1` from `t4` join `t1` `sq1_alias2` where (`sq1_alias2`.`col_varchar_key` = `t4`.`col_varchar_key`))), true) and (outer_field_is_not_null, (`alias1`.`col_varchar_nokey`), true))" + } /* transformations_to_nested_joins */ + } + ] /* steps */ + } /* join_preparation */ + }, + { + "join_optimization": { + "select#": 1, + "steps": [ + { + "condition_processing": { + "condition": "WHERE", + "original_condition": "((`where_subselect_19379`.`field1`,`where_subselect_19379`.`field2`),(/* select#2 */ select (/* select#3 */ select sum(`t4`.`pk`) AS `sq1_field1` from `t4` join `t1` `sq1_alias2` where (`sq1_alias2`.`col_varchar_key` = `t4`.`col_varchar_key`)) AS `field1`,`alias1`.`col_varchar_nokey` AS `field2` from `t2` `alias1` join `t2` `alias2` join `t2` `alias3` semi join (`t3` `sq2_alias1`) where ((outer_field_is_not_null, (((`where_subselect_19379`.`field1`) = (/* select#3 */ select sum(`t4`.`pk`) AS `sq1_field1` from `t4` join `t1` `sq1_alias2` where (`sq1_alias2`.`col_varchar_key` = `t4`.`col_varchar_key`))) or ((/* select#3 */ select sum(`t4`.`pk`) AS `sq1_field1` from `t4` join `t1` `sq1_alias2` where (`sq1_alias2`.`col_varchar_key` = `t4`.`col_varchar_key`)) is null)), true) and (outer_field_is_not_null, (((`where_subselect_19379`.`field2`) = `alias1`.`col_varchar_nokey`) or (`alias1`.`col_varchar_nokey` is null)), true) and (`sq2_alias1`.`col_varchar_nokey` <= `alias1`.`col_varchar_key`) and (`alias2`.`col_varchar_key` = `sq2_alias1`.`col_varchar_nokey`) and (`alias3`.`col_varchar_key` = `alias2`.`col_varchar_key`) and (`alias3`.`col_varchar_nokey` = `alias2`.`col_varchar_key`)) having ((outer_field_is_not_null, ((/* select#3 */ select sum(`t4`.`pk`) AS `sq1_field1` from `t4` join `t1` `sq1_alias2` where (`sq1_alias2`.`col_varchar_key` = `t4`.`col_varchar_key`))), true) and (outer_field_is_not_null, (`alias1`.`col_varchar_nokey`), true))) is false)", + "steps": [ + { + "transformation": "equality_propagation", + "subselect_evaluation": [ + ] /* subselect_evaluation */, + "resulting_condition": "((`where_subselect_19379`.`field1`,`where_subselect_19379`.`field2`),(/* select#2 */ select (/* select#3 */ select sum(`t4`.`pk`) AS `sq1_field1` from `t4` join `t1` `sq1_alias2` where (`sq1_alias2`.`col_varchar_key` = `t4`.`col_varchar_key`)) AS `field1`,`alias1`.`col_varchar_nokey` AS `field2` from `t2` `alias1` join `t2` `alias2` join `t2` `alias3` semi join (`t3` `sq2_alias1`) where ((outer_field_is_not_null, (((`where_subselect_19379`.`field1`) = (/* select#3 */ select sum(`t4`.`pk`) AS `sq1_field1` from `t4` join `t1` `sq1_alias2` where (`sq1_alias2`.`col_varchar_key` = `t4`.`col_varchar_key`))) or ((/* select#3 */ select sum(`t4`.`pk`) AS `sq1_field1` from `t4` join `t1` `sq1_alias2` where (`sq1_alias2`.`col_varchar_key` = `t4`.`col_varchar_key`)) is null)), true) and (outer_field_is_not_null, (((`where_subselect_19379`.`field2`) = `alias1`.`col_varchar_nokey`) or (`alias1`.`col_varchar_nokey` is null)), true) and (`sq2_alias1`.`col_varchar_nokey` <= `alias1`.`col_varchar_key`) and (`alias2`.`col_varchar_key` = `sq2_alias1`.`col_varchar_nokey`) and (`alias3`.`col_varchar_key` = `alias2`.`col_varchar_key`) and (`alias3`.`col_varchar_nokey` = `alias2`.`col_varchar_key`)) having ((outer_field_is_not_null, ((/* select#3 */ select sum(`t4`.`pk`) AS `sq1_field1` from `t4` join `t1` `sq1_alias2` where (`sq1_alias2`.`col_varchar_key` = `t4`.`col_varchar_key`))), true) and (outer_field_is_not_null, (`alias1`.`col_varchar_nokey`), true))) is false)" + }, + { + "transformation": "constant_propagation", + "subselect_evaluation": [ + ] /* subselect_evaluation */, + "resulting_condition": "((`where_subselect_19379`.`field1`,`where_subselect_19379`.`field2`),(/* select#2 */ select (/* select#3 */ select sum(`t4`.`pk`) AS `sq1_field1` from `t4` join `t1` `sq1_alias2` where (`sq1_alias2`.`col_varchar_key` = `t4`.`col_varchar_key`)) AS `field1`,`alias1`.`col_varchar_nokey` AS `field2` from `t2` `alias1` join `t2` `alias2` join `t2` `alias3` semi join (`t3` `sq2_alias1`) where ((outer_field_is_not_null, (((`where_subselect_19379`.`field1`) = (/* select#3 */ select sum(`t4`.`pk`) AS `sq1_field1` from `t4` join `t1` `sq1_alias2` where (`sq1_alias2`.`col_varchar_key` = `t4`.`col_varchar_key`))) or ((/* select#3 */ select sum(`t4`.`pk`) AS `sq1_field1` from `t4` join `t1` `sq1_alias2` where (`sq1_alias2`.`col_varchar_key` = `t4`.`col_varchar_key`)) is null)), true) and (outer_field_is_not_null, (((`where_subselect_19379`.`field2`) = `alias1`.`col_varchar_nokey`) or (`alias1`.`col_varchar_nokey` is null)), true) and (`sq2_alias1`.`col_varchar_nokey` <= `alias1`.`col_varchar_key`) and (`alias2`.`col_varchar_key` = `sq2_alias1`.`col_varchar_nokey`) and (`alias3`.`col_varchar_key` = `alias2`.`col_varchar_key`) and (`alias3`.`col_varchar_nokey` = `alias2`.`col_varchar_key`)) having ((outer_field_is_not_null, ((/* select#3 */ select sum(`t4`.`pk`) AS `sq1_field1` from `t4` join `t1` `sq1_alias2` where (`sq1_alias2`.`col_varchar_key` = `t4`.`col_varchar_key`))), true) and (outer_field_is_not_null, (`alias1`.`col_varchar_nokey`), true))) is false)" + }, + { + "transformation": "trivial_condition_removal", + "subselect_evaluation": [ + ] /* subselect_evaluation */, + "resulting_condition": "((`where_subselect_19379`.`field1`,`where_subselect_19379`.`field2`),(/* select#2 */ select (/* select#3 */ select sum(`t4`.`pk`) AS `sq1_field1` from `t4` join `t1` `sq1_alias2` where (`sq1_alias2`.`col_varchar_key` = `t4`.`col_varchar_key`)) AS `field1`,`alias1`.`col_varchar_nokey` AS `field2` from `t2` `alias1` join `t2` `alias2` join `t2` `alias3` semi join (`t3` `sq2_alias1`) where ((outer_field_is_not_null, (((`where_subselect_19379`.`field1`) = (/* select#3 */ select sum(`t4`.`pk`) AS `sq1_field1` from `t4` join `t1` `sq1_alias2` where (`sq1_alias2`.`col_varchar_key` = `t4`.`col_varchar_key`))) or ((/* select#3 */ select sum(`t4`.`pk`) AS `sq1_field1` from `t4` join `t1` `sq1_alias2` where (`sq1_alias2`.`col_varchar_key` = `t4`.`col_varchar_key`)) is null)), true) and (outer_field_is_not_null, (((`where_subselect_19379`.`field2`) = `alias1`.`col_varchar_nokey`) or (`alias1`.`col_varchar_nokey` is null)), true) and (`sq2_alias1`.`col_varchar_nokey` <= `alias1`.`col_varchar_key`) and (`alias2`.`col_varchar_key` = `sq2_alias1`.`col_varchar_nokey`) and (`alias3`.`col_varchar_key` = `alias2`.`col_varchar_key`) and (`alias3`.`col_varchar_nokey` = `alias2`.`col_varchar_key`)) having ((outer_field_is_not_null, ((/* select#3 */ select sum(`t4`.`pk`) AS `sq1_field1` from `t4` join `t1` `sq1_alias2` where (`sq1_alias2`.`col_varchar_key` = `t4`.`col_varchar_key`))), true) and (outer_field_is_not_null, (`alias1`.`col_varchar_nokey`), true))) is false)" + } + ] /* steps */ + } /* condition_processing */ + }, + { + "substitute_generated_columns": { + } /* substitute_generated_columns */ + }, + { + "table_dependencies": [ + { + "table": "`where_subselect_19379`", + "row_may_be_null": false, + "map_bit": 0, + "depends_on_map_bits": [ + ] /* depends_on_map_bits */ + } + ] /* table_dependencies */ + }, + { + "ref_optimizer_key_uses": [ + ] /* ref_optimizer_key_uses */ + }, + { + "rows_estimation": [ + { + "table": "`where_subselect_19379`", + "rows": 1, + "cost": 1, + "table_type": "system", + "empty": true + } + ] /* rows_estimation */ + } + ] /* steps */, + "empty_result": { + "cause": "no matching row in const table" + } /* empty_result */ + } /* join_optimization */ + }, + { + "join_execution": { + "select#": 1, + "steps": [ + ] /* steps */ + } /* join_execution */ + } + ] /* steps */ +} 0 0 +drop table t1,t2,t3,t4,where_subselect_19379; +drop view view_t4; +# +# BUG#12607524 JSON PARSE ERROR ON SELECT ... FROM ... WHERE .. IN (SUBQUERY) +# +CREATE TABLE t1 ( +col_int_key int(11) DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) ENGINE=MyISAM; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (8,'g'); +CREATE TABLE t2 ( +col_int_key int(11) DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) ENGINE=MyISAM; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (7,'x'); +CREATE TABLE where_subselect_19033 +SELECT +( SELECT col_int_key FROM t2 ) as field1 +FROM t1 +; +SELECT * FROM where_subselect_19033; +field1 +7 +SELECT field1 +FROM where_subselect_19033 +WHERE field1 IN +( SELECT +( SELECT col_int_key FROM t2 ) +FROM t1 +) +; +field1 +7 +SELECT * FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES +SELECT field1 +FROM where_subselect_19033 +WHERE field1 IN +( SELECT +( SELECT col_int_key FROM t2 ) +FROM t1 +) { + "steps": [ + { + "join_preparation": { + "select#": 1, + "steps": [ + { + "join_preparation": { + "select#": 2, + "steps": [ + { + "join_preparation": { + "select#": 3, + "steps": [ + { + "expanded_query": "/* select#3 */ select `t2`.`col_int_key` from `t2`" + } + ] /* steps */ + } /* join_preparation */ + }, + { + "expanded_query": "/* select#2 */ select (/* select#3 */ select `t2`.`col_int_key` from `t2`) from `t1`" + } + ] /* steps */ + } /* join_preparation */ + }, + { + "expanded_query": "/* select#1 */ select `where_subselect_19033`.`field1` AS `field1` from `where_subselect_19033` where `where_subselect_19033`.`field1` in (/* select#2 */ select (/* select#3 */ select `t2`.`col_int_key` from `t2`) from `t1`)" + }, + { + "transformation": { + "select#": 2, + "from": "IN (SELECT)", + "to": "semijoin", + "chosen": true, + "transformation_to_semi_join": { + "subquery_predicate": "`where_subselect_19033`.`field1` in (/* select#2 */ select (/* select#3 */ select `t2`.`col_int_key` from `t2`) from `t1`)", + "embedded in": "WHERE", + "semi-join condition": "(`where_subselect_19033`.`field1` = (/* select#3 */ select `t2`.`col_int_key` from `t2`))", + "decorrelated_predicates": [ + { + "outer": "`where_subselect_19033`.`field1`", + "inner": "(/* select#3 */ select `t2`.`col_int_key` from `t2`)" + } + ] /* decorrelated_predicates */ + } /* transformation_to_semi_join */ + } /* transformation */ + }, + { + "transformations_to_nested_joins": { + "transformations": [ + "semijoin" + ] /* transformations */, + "expanded_query": "/* select#1 */ select `where_subselect_19033`.`field1` AS `field1` from `where_subselect_19033` semi join (`t1`) where ((`where_subselect_19033`.`field1` = (/* select#3 */ select `t2`.`col_int_key` from `t2`)))" + } /* transformations_to_nested_joins */ + } + ] /* steps */ + } /* join_preparation */ + }, + { + "join_optimization": { + "select#": 1, + "steps": [ + { + "condition_processing": { + "condition": "WHERE", + "original_condition": "((`where_subselect_19033`.`field1` = (/* select#3 */ select `t2`.`col_int_key` from `t2`)))", + "steps": [ + { + "transformation": "equality_propagation", + "subselect_evaluation": [ + ] /* subselect_evaluation */, + "resulting_condition": "(multiple equal((/* select#3 */ select `t2`.`col_int_key` from `t2`), `where_subselect_19033`.`field1`))" + }, + { + "transformation": "constant_propagation", + "resulting_condition": "(multiple equal((/* select#3 */ select `t2`.`col_int_key` from `t2`), `where_subselect_19033`.`field1`))" + }, + { + "transformation": "trivial_condition_removal", + "resulting_condition": "multiple equal((/* select#3 */ select `t2`.`col_int_key` from `t2`), `where_subselect_19033`.`field1`)" + } + ] /* steps */ + } /* condition_processing */ + }, + { + "substitute_generated_columns": { + } /* substitute_generated_columns */ + }, + { + "table_dependencies": [ + { + "table": "`where_subselect_19033`", + "row_may_be_null": false, + "map_bit": 0, + "depends_on_map_bits": [ + ] /* depends_on_map_bits */ + }, + { + "table": "`t1`", + "row_may_be_null": false, + "map_bit": 1, + "depends_on_map_bits": [ + ] /* depends_on_map_bits */ + } + ] /* table_dependencies */ + }, + { + "ref_optimizer_key_uses": [ + ] /* ref_optimizer_key_uses */ + }, + { + "pulled_out_semijoin_tables": [ + ] /* pulled_out_semijoin_tables */ + }, + { + "subselect_execution": { + "select#": 3, + "steps": [ + { + "join_optimization": { + "select#": 3, + "steps": [ + { + "table_dependencies": [ + { + "table": "`t2`", + "row_may_be_null": false, + "map_bit": 0, + "depends_on_map_bits": [ + ] /* depends_on_map_bits */ + } + ] /* table_dependencies */ + }, + { + "rows_estimation": [ + { + "table": "`t2`", + "rows": 1, + "cost": 1, + "table_type": "system", + "empty": false + } + ] /* rows_estimation */ + }, + { + "attaching_conditions_to_tables": { + "original_condition": null, + "attached_conditions_computation": [ + ] /* attached_conditions_computation */, + "attached_conditions_summary": [ + ] /* attached_conditions_summary */ + } /* attaching_conditions_to_tables */ + }, + { + "refine_plan": [ + ] /* refine_plan */ + } + ] /* steps */ + } /* join_optimization */ + }, + { + "join_execution": { + "select#": 3, + "steps": [ + ] /* steps */ + } /* join_execution */ + } + ] /* steps */ + } /* subselect_execution */ + }, + { + "rows_estimation": [ + { + "table": "`where_subselect_19033`", + "rows": 1, + "cost": 1, + "table_type": "system", + "empty": false + }, + { + "table": "`t1`", + "table_scan": { + "rows": 1, + "cost": 0.501221 + } /* table_scan */ + } + ] /* rows_estimation */ + }, + { + "execution_plan_for_potential_materialization": { + "steps": [ + { + "considered_execution_plans": [ + { + "plan_prefix": [ + ] /* plan_prefix */, + "table": "`t1`", + "best_access_path": { + "considered_access_paths": [ + { + "rows_to_scan": 1, + "access_type": "scan", + "resulting_rows": 1, + "cost": 0.601221, + "chosen": true + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 100, + "rows_for_plan": 1, + "cost_for_plan": 0.601221, + "chosen": true + } + ] /* considered_execution_plans */ + } + ] /* steps */ + } /* execution_plan_for_potential_materialization */ + }, + { + "considered_execution_plans": [ + { + "plan_prefix": [ + "`where_subselect_19033`" + ] /* plan_prefix */, + "table": "`t1`", + "best_access_path": { + "considered_access_paths": [ + { + "rows_to_scan": 1, + "access_type": "scan", + "resulting_rows": 1, + "cost": 0.601221, + "chosen": true + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 100, + "rows_for_plan": 1, + "cost_for_plan": 0.601221, + "semijoin_strategy_choice": [ + { + "strategy": "FirstMatch", + "recalculate_access_paths_and_cost": { + "tables": [ + ] /* tables */ + } /* recalculate_access_paths_and_cost */, + "cost": 0.601221, + "rows": 1, + "chosen": true + }, + { + "strategy": "MaterializeLookup", + "cost": 1.80122, + "rows": 1, + "duplicate_tables_left": false, + "chosen": false + }, + { + "strategy": "DuplicatesWeedout", + "cost": 1.80122, + "rows": 1, + "duplicate_tables_left": false, + "chosen": false + } + ] /* semijoin_strategy_choice */, + "chosen": true + }, + { + "final_semijoin_strategy": "FirstMatch", + "recalculate_access_paths_and_cost": { + "tables": [ + ] /* tables */ + } /* recalculate_access_paths_and_cost */ + } + ] /* considered_execution_plans */ + }, + { + "condition_on_constant_tables": "true", + "condition_value": true + }, + { + "attaching_conditions_to_tables": { + "original_condition": "true", + "attached_conditions_computation": [ + ] /* attached_conditions_computation */, + "attached_conditions_summary": [ + { + "table": "`t1`", + "attached": null + } + ] /* attached_conditions_summary */ + } /* attaching_conditions_to_tables */ + }, + { + "finalizing_table_conditions": [ + ] /* finalizing_table_conditions */ + }, + { + "refine_plan": [ + { + "table": "`t1`" + } + ] /* refine_plan */ + } + ] /* steps */ + } /* join_optimization */ + }, + { + "join_execution": { + "select#": 1, + "steps": [ + ] /* steps */ + } /* join_execution */ + } + ] /* steps */ +} 0 0 +DROP TABLE where_subselect_19033,t1,t2; + +# BUG#12612201 - SEGFAULT IN +# SUBSELECT_UNIQUESUBQUERY_ENGINE::PRINT WITH OPTIMIZER TRACE + +CREATE TABLE t1 ( +col_int_key int(11) DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t2 ( +pk int(11) NOT NULL AUTO_INCREMENT, +col_int_key int(11) DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +PRIMARY KEY (pk) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (1,4,'v','v'),(20,5,'r','r'); +CREATE TABLE t3 ( +col_int_key int(11) DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t3 VALUES (NULL,'j','j'),(8,'c','c'); +CREATE TABLE where_updatedelete_20769 select count( alias2 . col_varchar_key ) as field1 +from ( +(select sq1_alias1 . * +from ( t3 as sq1_alias1 +straight_join t1 as sq1_alias2 +on (sq1_alias2 . col_varchar_key = sq1_alias1 . col_varchar_key) +) +where sq1_alias1 . col_int_key in ( +select c_sq1_alias1 . pk as c_sq1_field1 +from t2 as c_sq1_alias1 +) +) as alias1 +left outer join t1 as alias2 +on (alias2 . col_varchar_key = alias1 . col_varchar_key ) +) +where ( alias2 . col_varchar_key in ( +select sq2_alias1 . col_varchar_nokey as sq2_field1 +from t2 as sq2_alias1 +where sq2_alias1 . col_int_key in ( +select distinct c_sq2_alias1 . col_int_key as c_sq2_field1 +from t3 as c_sq2_alias1 +) +) ) +or alias1 . col_int_key = 2 +and alias2 . col_varchar_nokey <= alias1 . col_varchar_nokey +order by alias1 . col_varchar_key , field1 +; +UPDATE where_updatedelete_20769 SET field1 = ( select count( alias2 . col_varchar_key ) as field1 +from ( +(select sq1_alias1 . * +from ( t3 as sq1_alias1 +straight_join t1 as sq1_alias2 +on (sq1_alias2 . col_varchar_key = sq1_alias1 . col_varchar_key) +) +where sq1_alias1 . col_int_key in ( +select c_sq1_alias1 . pk as c_sq1_field1 +from t2 as c_sq1_alias1 +) +) as alias1 +left outer join t1 as alias2 +on (alias2 . col_varchar_key = alias1 . col_varchar_key ) +) +where ( alias2 . col_varchar_key in ( +select sq2_alias1 . col_varchar_nokey as sq2_field1 +from t2 as sq2_alias1 +where sq2_alias1 . col_int_key in ( +select distinct c_sq2_alias1 . col_int_key as c_sq2_field1 +from t3 as c_sq2_alias1 +) +) ) +or alias1 . col_int_key = 2 +and alias2 . col_varchar_nokey <= alias1 . col_varchar_nokey +order by alias1 . col_varchar_key , field1 + ); +DROP TABLE where_updatedelete_20769; +DROP TABLE t1,t2,t3; + +# BUG#12710761 - INVALID JSON TRACE ON SUBQUERY IN IN-CLAUSE + +CREATE TABLE t1 (col_int_key int, KEY col_int_key (col_int_key)); +INSERT INTO t1 VALUES (0),(8),(1),(8); +CREATE TABLE where_subselect_20070 +SELECT table2 .col_int_key AS field1, +( SELECT COUNT( col_int_key ) +FROM t1 +) +FROM t1 AS table1 +JOIN t1 AS table2 +ON table2 .col_int_key = table1 .col_int_key; +SELECT * +FROM where_subselect_20070 +WHERE (field1, ( SELECT COUNT( col_int_key ) FROM t1 )) IN ( +SELECT table2 .col_int_key AS field1, +( SELECT COUNT( col_int_key ) +FROM t1 +) +FROM t1 AS table1 +JOIN t1 AS table2 +ON table2 .col_int_key = table1 .col_int_key +); +field1 ( SELECT COUNT( col_int_key ) +FROM t1 +) +0 4 +1 4 +8 4 +8 4 +8 4 +8 4 +select * from information_schema.optimizer_trace; +QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES +SELECT * +FROM where_subselect_20070 +WHERE (field1, ( SELECT COUNT( col_int_key ) FROM t1 )) IN ( +SELECT table2 .col_int_key AS field1, +( SELECT COUNT( col_int_key ) +FROM t1 +) +FROM t1 AS table1 +JOIN t1 AS table2 +ON table2 .col_int_key = table1 .col_int_key +) { + "steps": [ + { + "join_preparation": { + "select#": 1, + "steps": [ + { + "join_preparation": { + "select#": 3, + "steps": [ + { + "join_preparation": { + "select#": 4, + "steps": [ + { + "expanded_query": "/* select#4 */ select count(`t1`.`col_int_key`) from `t1`" + } + ] /* steps */ + } /* join_preparation */ + }, + { + "expanded_query": "/* select#3 */ select `table2`.`col_int_key` AS `field1`,(/* select#4 */ select count(`t1`.`col_int_key`) from `t1`) from (`t1` `table1` join `t1` `table2` on((`table2`.`col_int_key` = `table1`.`col_int_key`)))" + }, + { + "join_preparation": { + "select#": 2, + "steps": [ + { + "expanded_query": "/* select#2 */ select count(`t1`.`col_int_key`) from `t1`" + } + ] /* steps */ + } /* join_preparation */ + } + ] /* steps */ + } /* join_preparation */ + }, + { + "expanded_query": "/* select#1 */ select `where_subselect_20070`.`field1` AS `field1`,`where_subselect_20070`.`( SELECT COUNT( col_int_key )\nFROM t1\n)` AS `( SELECT COUNT( col_int_key )\nFROM t1\n)` from `where_subselect_20070` where (`where_subselect_20070`.`field1`,(/* select#2 */ select count(`t1`.`col_int_key`) from `t1`)) in (/* select#3 */ select `table2`.`col_int_key` AS `field1`,(/* select#4 */ select count(`t1`.`col_int_key`) from `t1`) from (`t1` `table1` join `t1` `table2` on((`table2`.`col_int_key` = `table1`.`col_int_key`))))" + }, + { + "transformation": { + "select#": 3, + "from": "IN (SELECT)", + "to": "semijoin", + "chosen": true, + "transformation_to_semi_join": { + "subquery_predicate": "(`where_subselect_20070`.`field1`,(/* select#2 */ select count(`t1`.`col_int_key`) from `t1`)) in (/* select#3 */ select `table2`.`col_int_key` AS `field1`,(/* select#4 */ select count(`t1`.`col_int_key`) from `t1`) from (`t1` `table1` join `t1` `table2` on((`table2`.`col_int_key` = `table1`.`col_int_key`))))", + "embedded in": "WHERE", + "evaluating_constant_semijoin_conditions": [ + ] /* evaluating_constant_semijoin_conditions */, + "semi-join condition": "((`where_subselect_20070`.`field1` = `table2`.`col_int_key`) and ((/* select#2 */ select count(`t1`.`col_int_key`) from `t1`) = (/* select#4 */ select count(`t1`.`col_int_key`) from `t1`)))", + "decorrelated_predicates": [ + { + "outer": "`where_subselect_20070`.`field1`", + "inner": "`table2`.`col_int_key`" + }, + { + "outer": "(/* select#2 */ select count(`t1`.`col_int_key`) from `t1`)", + "inner": "(/* select#4 */ select count(`t1`.`col_int_key`) from `t1`)" + } + ] /* decorrelated_predicates */ + } /* transformation_to_semi_join */ + } /* transformation */ + }, + { + "transformations_to_nested_joins": { + "transformations": [ + "semijoin", + "JOIN_condition_to_WHERE", + "parenthesis_removal" + ] /* transformations */, + "expanded_query": "/* select#1 */ select `where_subselect_20070`.`field1` AS `field1`,`where_subselect_20070`.`( SELECT COUNT( col_int_key )\nFROM t1\n)` AS `( SELECT COUNT( col_int_key )\nFROM t1\n)` from `where_subselect_20070` semi join (`t1` `table1` join `t1` `table2`) where ((`where_subselect_20070`.`field1` = `table2`.`col_int_key`) and ((/* select#2 */ select count(`t1`.`col_int_key`) from `t1`) = (/* select#4 */ select count(`t1`.`col_int_key`) from `t1`)) and (`table2`.`col_int_key` = `table1`.`col_int_key`))" + } /* transformations_to_nested_joins */ + } + ] /* steps */ + } /* join_preparation */ + }, + { + "join_optimization": { + "select#": 1, + "steps": [ + { + "condition_processing": { + "condition": "WHERE", + "original_condition": "((`where_subselect_20070`.`field1` = `table2`.`col_int_key`) and ((/* select#2 */ select count(`t1`.`col_int_key`) from `t1`) = (/* select#4 */ select count(`t1`.`col_int_key`) from `t1`)) and (`table2`.`col_int_key` = `table1`.`col_int_key`))", + "steps": [ + { + "transformation": "equality_propagation", + "subselect_evaluation": [ + ] /* subselect_evaluation */, + "resulting_condition": "(((/* select#2 */ select count(`t1`.`col_int_key`) from `t1`) = (/* select#4 */ select count(`t1`.`col_int_key`) from `t1`)) and multiple equal(`where_subselect_20070`.`field1`, `table2`.`col_int_key`, `table1`.`col_int_key`))" + }, + { + "transformation": "constant_propagation", + "subselect_evaluation": [ + ] /* subselect_evaluation */, + "resulting_condition": "(((/* select#2 */ select count(`t1`.`col_int_key`) from `t1`) = (/* select#4 */ select count(`t1`.`col_int_key`) from `t1`)) and multiple equal(`where_subselect_20070`.`field1`, `table2`.`col_int_key`, `table1`.`col_int_key`))" + }, + { + "transformation": "trivial_condition_removal", + "subselect_evaluation": [ + { + "subselect_execution": { + "select#": 2, + "steps": [ + { + "join_optimization": { + "select#": 2, + "steps": [ + { + "table_dependencies": [ + { + "table": "`t1`", + "row_may_be_null": false, + "map_bit": 0, + "depends_on_map_bits": [ + ] /* depends_on_map_bits */ + } + ] /* table_dependencies */ + }, + { + "rows_estimation": [ + { + "table": "`t1`", + "table_scan": { + "rows": 4, + "cost": 0.501709 + } /* table_scan */ + } + ] /* rows_estimation */ + }, + { + "considered_execution_plans": [ + { + "plan_prefix": [ + ] /* plan_prefix */, + "table": "`t1`", + "best_access_path": { + "considered_access_paths": [ + { + "rows_to_scan": 4, + "access_type": "scan", + "resulting_rows": 4, + "cost": 0.901709, + "chosen": true + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 100, + "rows_for_plan": 4, + "cost_for_plan": 0.901709, + "chosen": true + } + ] /* considered_execution_plans */ + }, + { + "attaching_conditions_to_tables": { + "original_condition": null, + "attached_conditions_computation": [ + ] /* attached_conditions_computation */, + "attached_conditions_summary": [ + { + "table": "`t1`", + "attached": null + } + ] /* attached_conditions_summary */ + } /* attaching_conditions_to_tables */ + }, + { + "optimizing_distinct_group_by_order_by": { + } /* optimizing_distinct_group_by_order_by */ + }, + { + "finalizing_table_conditions": [ + ] /* finalizing_table_conditions */ + }, + { + "refine_plan": [ + { + "table": "`t1`" + } + ] /* refine_plan */ + }, + { + "considering_tmp_tables": [ + ] /* considering_tmp_tables */ + } + ] /* steps */ + } /* join_optimization */ + }, + { + "join_execution": { + "select#": 2, + "steps": [ + ] /* steps */ + } /* join_execution */ + } + ] /* steps */ + } /* subselect_execution */ + }, + { + "subselect_execution": { + "select#": 4, + "steps": [ + { + "join_optimization": { + "select#": 4, + "steps": [ + { + "table_dependencies": [ + { + "table": "`t1`", + "row_may_be_null": false, + "map_bit": 0, + "depends_on_map_bits": [ + ] /* depends_on_map_bits */ + } + ] /* table_dependencies */ + }, + { + "rows_estimation": [ + { + "table": "`t1`", + "table_scan": { + "rows": 4, + "cost": 0.501709 + } /* table_scan */ + } + ] /* rows_estimation */ + }, + { + "considered_execution_plans": [ + { + "plan_prefix": [ + ] /* plan_prefix */, + "table": "`t1`", + "best_access_path": { + "considered_access_paths": [ + { + "rows_to_scan": 4, + "access_type": "scan", + "resulting_rows": 4, + "cost": 0.901709, + "chosen": true + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 100, + "rows_for_plan": 4, + "cost_for_plan": 0.901709, + "chosen": true + } + ] /* considered_execution_plans */ + }, + { + "attaching_conditions_to_tables": { + "original_condition": null, + "attached_conditions_computation": [ + ] /* attached_conditions_computation */, + "attached_conditions_summary": [ + { + "table": "`t1`", + "attached": null + } + ] /* attached_conditions_summary */ + } /* attaching_conditions_to_tables */ + }, + { + "optimizing_distinct_group_by_order_by": { + } /* optimizing_distinct_group_by_order_by */ + }, + { + "finalizing_table_conditions": [ + ] /* finalizing_table_conditions */ + }, + { + "refine_plan": [ + { + "table": "`t1`" + } + ] /* refine_plan */ + }, + { + "considering_tmp_tables": [ + ] /* considering_tmp_tables */ + } + ] /* steps */ + } /* join_optimization */ + }, + { + "join_execution": { + "select#": 4, + "steps": [ + ] /* steps */ + } /* join_execution */ + } + ] /* steps */ + } /* subselect_execution */ + } + ] /* subselect_evaluation */, + "resulting_condition": "multiple equal(`where_subselect_20070`.`field1`, `table2`.`col_int_key`, `table1`.`col_int_key`)" + } + ] /* steps */ + } /* condition_processing */ + }, + { + "substitute_generated_columns": { + } /* substitute_generated_columns */ + }, + { + "table_dependencies": [ + { + "table": "`where_subselect_20070`", + "row_may_be_null": false, + "map_bit": 0, + "depends_on_map_bits": [ + ] /* depends_on_map_bits */ + }, + { + "table": "`t1` `table1`", + "row_may_be_null": false, + "map_bit": 1, + "depends_on_map_bits": [ + ] /* depends_on_map_bits */ + }, + { + "table": "`t1` `table2`", + "row_may_be_null": false, + "map_bit": 2, + "depends_on_map_bits": [ + ] /* depends_on_map_bits */ + } + ] /* table_dependencies */ + }, + { + "ref_optimizer_key_uses": [ + { + "table": "`t1` `table1`", + "field": "col_int_key", + "equals": "`where_subselect_20070`.`field1`", + "null_rejecting": true + }, + { + "table": "`t1` `table1`", + "field": "col_int_key", + "equals": "`table2`.`col_int_key`", + "null_rejecting": true + }, + { + "table": "`t1` `table2`", + "field": "col_int_key", + "equals": "`where_subselect_20070`.`field1`", + "null_rejecting": true + }, + { + "table": "`t1` `table2`", + "field": "col_int_key", + "equals": "`table1`.`col_int_key`", + "null_rejecting": true + } + ] /* ref_optimizer_key_uses */ + }, + { + "pulled_out_semijoin_tables": [ + ] /* pulled_out_semijoin_tables */ + }, + { + "rows_estimation": [ + { + "table": "`where_subselect_20070`", + "table_scan": { + "rows": 6, + "cost": 0.504761 + } /* table_scan */ + }, + { + "table": "`t1` `table1`", + "table_scan": { + "rows": 4, + "cost": 0.501709 + } /* table_scan */ + }, + { + "table": "`t1` `table2`", + "table_scan": { + "rows": 4, + "cost": 0.501709 + } /* table_scan */ + } + ] /* rows_estimation */ + }, + { + "execution_plan_for_potential_materialization": { + "steps": [ + { + "considered_execution_plans": [ + { + "plan_prefix": [ + ] /* plan_prefix */, + "table": "`t1` `table1`", + "best_access_path": { + "considered_access_paths": [ + { + "access_type": "ref", + "index": "col_int_key", + "usable": false, + "chosen": false + }, + { + "rows_to_scan": 4, + "filtering_effect": [ + ] /* filtering_effect */, + "final_filtering_effect": 1, + "access_type": "scan", + "resulting_rows": 4, + "cost": 0.901709, + "chosen": true + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 100, + "rows_for_plan": 4, + "cost_for_plan": 0.901709, + "rest_of_plan": [ + { + "plan_prefix": [ + "`t1` `table1`" + ] /* plan_prefix */, + "table": "`t1` `table2`", + "best_access_path": { + "considered_access_paths": [ + { + "access_type": "ref", + "index": "col_int_key", + "rows": 2, + "cost": 1.82326, + "chosen": true + }, + { + "rows_to_scan": 4, + "filtering_effect": [ + ] /* filtering_effect */, + "final_filtering_effect": 1, + "access_type": "scan", + "using_join_cache": true, + "buffers_needed": 1, + "resulting_rows": 4, + "cost": 2.10175, + "chosen": false + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 100, + "rows_for_plan": 8, + "cost_for_plan": 2.72496, + "chosen": true + } + ] /* rest_of_plan */ + }, + { + "plan_prefix": [ + ] /* plan_prefix */, + "table": "`t1` `table2`", + "best_access_path": { + "considered_access_paths": [ + { + "access_type": "ref", + "index": "col_int_key", + "usable": false, + "chosen": false + }, + { + "rows_to_scan": 4, + "filtering_effect": [ + ] /* filtering_effect */, + "final_filtering_effect": 1, + "access_type": "scan", + "resulting_rows": 4, + "cost": 0.901709, + "chosen": true + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 100, + "rows_for_plan": 4, + "cost_for_plan": 0.901709, + "rest_of_plan": [ + { + "plan_prefix": [ + "`t1` `table2`" + ] /* plan_prefix */, + "table": "`t1` `table1`", + "best_access_path": { + "considered_access_paths": [ + { + "access_type": "ref", + "index": "col_int_key", + "rows": 2, + "cost": 1.82326, + "chosen": true + }, + { + "rows_to_scan": 4, + "filtering_effect": [ + ] /* filtering_effect */, + "final_filtering_effect": 1, + "access_type": "scan", + "using_join_cache": true, + "buffers_needed": 1, + "resulting_rows": 4, + "cost": 2.10175, + "chosen": false + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 100, + "rows_for_plan": 8, + "cost_for_plan": 2.72496, + "pruned_by_cost": true + } + ] /* rest_of_plan */ + } + ] /* considered_execution_plans */ + } + ] /* steps */ + } /* execution_plan_for_potential_materialization */ + }, + { + "considered_execution_plans": [ + { + "plan_prefix": [ + ] /* plan_prefix */, + "table": "`where_subselect_20070`", + "best_access_path": { + "considered_access_paths": [ + { + "rows_to_scan": 6, + "filtering_effect": [ + ] /* filtering_effect */, + "final_filtering_effect": 1, + "access_type": "scan", + "resulting_rows": 6, + "cost": 1.10476, + "chosen": true + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 100, + "rows_for_plan": 6, + "cost_for_plan": 1.10476, + "semijoin_strategy_choice": [ + ] /* semijoin_strategy_choice */, + "rest_of_plan": [ + { + "plan_prefix": [ + "`where_subselect_20070`" + ] /* plan_prefix */, + "table": "`t1` `table1`", + "best_access_path": { + "considered_access_paths": [ + { + "access_type": "ref", + "index": "col_int_key", + "rows": 2, + "cost": 2.73488, + "chosen": true + }, + { + "rows_to_scan": 4, + "filtering_effect": [ + ] /* filtering_effect */, + "final_filtering_effect": 1, + "access_type": "scan", + "using_join_cache": true, + "buffers_needed": 1, + "resulting_rows": 4, + "cost": 2.90186, + "chosen": false + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 100, + "rows_for_plan": 12, + "cost_for_plan": 3.83964, + "semijoin_strategy_choice": [ + ] /* semijoin_strategy_choice */, + "rest_of_plan": [ + { + "plan_prefix": [ + "`where_subselect_20070`", + "`t1` `table1`" + ] /* plan_prefix */, + "table": "`t1` `table2`", + "best_access_path": { + "considered_access_paths": [ + { + "access_type": "ref", + "index": "col_int_key", + "rows": 2, + "cost": 5.46977, + "chosen": true + }, + { + "rows_to_scan": 4, + "filtering_effect": [ + ] /* filtering_effect */, + "final_filtering_effect": 1, + "access_type": "scan", + "using_join_cache": true, + "buffers_needed": 1, + "resulting_rows": 4, + "cost": 5.30212, + "chosen": true + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 25, + "rows_for_plan": 12, + "cost_for_plan": 9.14177, + "semijoin_strategy_choice": [ + { + "strategy": "FirstMatch", + "recalculate_access_paths_and_cost": { + "tables": [ + { + "table": "`t1` `table2`", + "best_access_path": { + "considered_access_paths": [ + { + "access_type": "ref", + "index": "col_int_key", + "rows": 2, + "cost": 5.46977, + "chosen": true + }, + { + "rows_to_scan": 4, + "filtering_effect": [ + ] /* filtering_effect */, + "final_filtering_effect": 1, + "access_type": "scan", + "resulting_rows": 4, + "cost": 10.8205, + "chosen": false + } + ] /* considered_access_paths */ + } /* best_access_path */ + } + ] /* tables */ + } /* recalculate_access_paths_and_cost */, + "cost": 9.30941, + "rows": 6, + "chosen": true + }, + { + "strategy": "MaterializeLookup", + "cost": 6.22973, + "rows": 6, + "duplicate_tables_left": false, + "chosen": true + }, + { + "strategy": "DuplicatesWeedout", + "cost": 11.9418, + "rows": 6, + "duplicate_tables_left": false, + "chosen": false + } + ] /* semijoin_strategy_choice */, + "chosen": true + } + ] /* rest_of_plan */ + }, + { + "plan_prefix": [ + "`where_subselect_20070`" + ] /* plan_prefix */, + "table": "`t1` `table2`", + "best_access_path": { + "considered_access_paths": [ + { + "access_type": "ref", + "index": "col_int_key", + "rows": 2, + "cost": 2.73488, + "chosen": true + }, + { + "rows_to_scan": 4, + "filtering_effect": [ + ] /* filtering_effect */, + "final_filtering_effect": 1, + "access_type": "scan", + "using_join_cache": true, + "buffers_needed": 1, + "resulting_rows": 4, + "cost": 2.90186, + "chosen": false + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 100, + "rows_for_plan": 12, + "cost_for_plan": 3.83964, + "semijoin_strategy_choice": [ + ] /* semijoin_strategy_choice */, + "rest_of_plan": [ + { + "plan_prefix": [ + "`where_subselect_20070`", + "`t1` `table2`" + ] /* plan_prefix */, + "table": "`t1` `table1`", + "best_access_path": { + "considered_access_paths": [ + { + "access_type": "ref", + "index": "col_int_key", + "rows": 2, + "cost": 5.46977, + "chosen": true + }, + { + "rows_to_scan": 4, + "filtering_effect": [ + ] /* filtering_effect */, + "final_filtering_effect": 1, + "access_type": "scan", + "using_join_cache": true, + "buffers_needed": 1, + "resulting_rows": 4, + "cost": 5.30212, + "chosen": true + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 25, + "rows_for_plan": 12, + "cost_for_plan": 9.14177, + "semijoin_strategy_choice": [ + { + "strategy": "FirstMatch", + "recalculate_access_paths_and_cost": { + "tables": [ + { + "table": "`t1` `table1`", + "best_access_path": { + "considered_access_paths": [ + { + "access_type": "ref", + "index": "col_int_key", + "rows": 2, + "cost": 5.46977, + "chosen": true + }, + { + "rows_to_scan": 4, + "filtering_effect": [ + ] /* filtering_effect */, + "final_filtering_effect": 1, + "access_type": "scan", + "resulting_rows": 4, + "cost": 10.8205, + "chosen": false + } + ] /* considered_access_paths */ + } /* best_access_path */ + } + ] /* tables */ + } /* recalculate_access_paths_and_cost */, + "cost": 9.30941, + "rows": 6, + "chosen": true + }, + { + "strategy": "MaterializeLookup", + "cost": 6.22973, + "rows": 6, + "duplicate_tables_left": false, + "chosen": true + }, + { + "strategy": "DuplicatesWeedout", + "cost": 11.9418, + "rows": 6, + "duplicate_tables_left": false, + "chosen": false + } + ] /* semijoin_strategy_choice */, + "pruned_by_cost": true + } + ] /* rest_of_plan */ + } + ] /* rest_of_plan */ + }, + { + "plan_prefix": [ + ] /* plan_prefix */, + "table": "`t1` `table1`", + "best_access_path": { + "considered_access_paths": [ + { + "access_type": "ref", + "index": "col_int_key", + "usable": false, + "chosen": false + }, + { + "rows_to_scan": 4, + "filtering_effect": [ + ] /* filtering_effect */, + "final_filtering_effect": 1, + "access_type": "scan", + "resulting_rows": 4, + "cost": 0.901709, + "chosen": true + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 100, + "rows_for_plan": 4, + "cost_for_plan": 0.901709, + "semijoin_strategy_choice": [ + ] /* semijoin_strategy_choice */, + "rest_of_plan": [ + { + "plan_prefix": [ + "`t1` `table1`" + ] /* plan_prefix */, + "table": "`where_subselect_20070`", + "best_access_path": { + "considered_access_paths": [ + { + "rows_to_scan": 6, + "filtering_effect": [ + ] /* filtering_effect */, + "final_filtering_effect": 1, + "access_type": "scan", + "using_join_cache": true, + "buffers_needed": 1, + "resulting_rows": 6, + "cost": 2.9048, + "chosen": true + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 16.6667, + "rows_for_plan": 4, + "cost_for_plan": 3.80651, + "semijoin_strategy_choice": [ + ] /* semijoin_strategy_choice */, + "rest_of_plan": [ + { + "plan_prefix": [ + "`t1` `table1`", + "`where_subselect_20070`" + ] /* plan_prefix */, + "table": "`t1` `table2`", + "best_access_path": { + "considered_access_paths": [ + { + "access_type": "ref", + "index": "col_int_key", + "rows": 2, + "cost": 1.82326, + "chosen": true + }, + { + "rows_to_scan": 4, + "filtering_effect": [ + ] /* filtering_effect */, + "final_filtering_effect": 1, + "access_type": "scan", + "using_join_cache": true, + "buffers_needed": 1, + "resulting_rows": 4, + "cost": 2.10185, + "chosen": false + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 100, + "rows_for_plan": 8, + "cost_for_plan": 5.62976, + "semijoin_strategy_choice": [ + { + "strategy": "DuplicatesWeedout", + "cost": 7.52976, + "rows": 1, + "duplicate_tables_left": true, + "chosen": true + } + ] /* semijoin_strategy_choice */, + "pruned_by_cost": true + } + ] /* rest_of_plan */ + }, + { + "plan_prefix": [ + "`t1` `table1`" + ] /* plan_prefix */, + "table": "`t1` `table2`", + "best_access_path": { + "considered_access_paths": [ + { + "access_type": "ref", + "index": "col_int_key", + "rows": 2, + "cost": 1.82326, + "chosen": true + }, + { + "rows_to_scan": 4, + "filtering_effect": [ + ] /* filtering_effect */, + "final_filtering_effect": 1, + "access_type": "scan", + "using_join_cache": true, + "buffers_needed": 1, + "resulting_rows": 4, + "cost": 2.10175, + "chosen": false + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 100, + "rows_for_plan": 8, + "cost_for_plan": 2.72496, + "semijoin_strategy_choice": [ + { + "strategy": "MaterializeScan", + "choice": "deferred" + } + ] /* semijoin_strategy_choice */, + "rest_of_plan": [ + { + "plan_prefix": [ + "`t1` `table1`", + "`t1` `table2`" + ] /* plan_prefix */, + "table": "`where_subselect_20070`", + "best_access_path": { + "considered_access_paths": [ + { + "rows_to_scan": 6, + "filtering_effect": [ + ] /* filtering_effect */, + "final_filtering_effect": 1, + "access_type": "scan", + "using_join_cache": true, + "buffers_needed": 1, + "resulting_rows": 6, + "cost": 5.30491, + "chosen": true + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 16.6667, + "rows_for_plan": 8, + "cost_for_plan": 8.02988, + "semijoin_strategy_choice": [ + { + "strategy": "LooseScan", + "recalculate_access_paths_and_cost": { + "tables": [ + { + "table": "`t1` `table1`", + "best_access_path": { + "considered_access_paths": [ + { + "access_type": "ref", + "index": "col_int_key", + "usable": false, + "chosen": false + }, + { + "rows_to_scan": 4, + "filtering_effect": [ + ] /* filtering_effect */, + "final_filtering_effect": 1, + "access_type": "scan", + "resulting_rows": 4, + "cost": 0.901709, + "chosen": true + } + ] /* considered_access_paths */ + } /* best_access_path */, + "unknown_key_1": { + "searching_loose_scan_index": { + "indexes": [ + { + "index": "col_int_key", + "index_handles_needed_semijoin_equalities": false + } + ] /* indexes */ + } /* searching_loose_scan_index */ + } + } + ] /* tables */ + } /* recalculate_access_paths_and_cost */, + "chosen": false + }, + { + "strategy": "MaterializeScan", + "recalculate_access_paths_and_cost": { + "tables": [ + { + "table": "`where_subselect_20070`", + "best_access_path": { + "considered_access_paths": [ + { + "rows_to_scan": 6, + "filtering_effect": [ + ] /* filtering_effect */, + "final_filtering_effect": 1, + "access_type": "scan", + "using_join_cache": true, + "buffers_needed": 1, + "resulting_rows": 6, + "cost": 2.90484, + "chosen": true + } + ] /* considered_access_paths */ + } /* best_access_path */ + } + ] /* tables */ + } /* recalculate_access_paths_and_cost */, + "cost": 7.8298, + "rows": 1, + "duplicate_tables_left": true, + "chosen": true + }, + { + "strategy": "DuplicatesWeedout", + "cost": 9.92988, + "rows": 1, + "duplicate_tables_left": false, + "chosen": false + } + ] /* semijoin_strategy_choice */, + "pruned_by_cost": true + } + ] /* rest_of_plan */ + } + ] /* rest_of_plan */ + }, + { + "plan_prefix": [ + ] /* plan_prefix */, + "table": "`t1` `table2`", + "best_access_path": { + "considered_access_paths": [ + { + "access_type": "ref", + "index": "col_int_key", + "usable": false, + "chosen": false + }, + { + "rows_to_scan": 4, + "filtering_effect": [ + ] /* filtering_effect */, + "final_filtering_effect": 1, + "access_type": "scan", + "resulting_rows": 4, + "cost": 0.901709, + "chosen": true + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 100, + "rows_for_plan": 4, + "cost_for_plan": 0.901709, + "semijoin_strategy_choice": [ + ] /* semijoin_strategy_choice */, + "rest_of_plan": [ + { + "plan_prefix": [ + "`t1` `table2`" + ] /* plan_prefix */, + "table": "`where_subselect_20070`", + "best_access_path": { + "considered_access_paths": [ + { + "rows_to_scan": 6, + "filtering_effect": [ + ] /* filtering_effect */, + "final_filtering_effect": 1, + "access_type": "scan", + "using_join_cache": true, + "buffers_needed": 1, + "resulting_rows": 6, + "cost": 2.9048, + "chosen": true + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 16.6667, + "rows_for_plan": 4, + "cost_for_plan": 3.80651, + "semijoin_strategy_choice": [ + ] /* semijoin_strategy_choice */, + "rest_of_plan": [ + { + "plan_prefix": [ + "`t1` `table2`", + "`where_subselect_20070`" + ] /* plan_prefix */, + "table": "`t1` `table1`", + "best_access_path": { + "considered_access_paths": [ + { + "access_type": "ref", + "index": "col_int_key", + "rows": 2, + "cost": 1.82326, + "chosen": true + }, + { + "rows_to_scan": 4, + "filtering_effect": [ + ] /* filtering_effect */, + "final_filtering_effect": 1, + "access_type": "scan", + "using_join_cache": true, + "buffers_needed": 1, + "resulting_rows": 4, + "cost": 2.10185, + "chosen": false + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 100, + "rows_for_plan": 8, + "cost_for_plan": 5.62976, + "semijoin_strategy_choice": [ + { + "strategy": "DuplicatesWeedout", + "cost": 7.52976, + "rows": 1, + "duplicate_tables_left": true, + "chosen": true + } + ] /* semijoin_strategy_choice */, + "pruned_by_cost": true + } + ] /* rest_of_plan */ + }, + { + "plan_prefix": [ + "`t1` `table2`" + ] /* plan_prefix */, + "table": "`t1` `table1`", + "best_access_path": { + "considered_access_paths": [ + { + "access_type": "ref", + "index": "col_int_key", + "rows": 2, + "cost": 1.82326, + "chosen": true + }, + { + "rows_to_scan": 4, + "filtering_effect": [ + ] /* filtering_effect */, + "final_filtering_effect": 1, + "access_type": "scan", + "using_join_cache": true, + "buffers_needed": 1, + "resulting_rows": 4, + "cost": 2.10175, + "chosen": false + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 100, + "rows_for_plan": 8, + "cost_for_plan": 2.72496, + "semijoin_strategy_choice": [ + { + "strategy": "MaterializeScan", + "choice": "deferred" + } + ] /* semijoin_strategy_choice */, + "rest_of_plan": [ + { + "plan_prefix": [ + "`t1` `table2`", + "`t1` `table1`" + ] /* plan_prefix */, + "table": "`where_subselect_20070`", + "best_access_path": { + "considered_access_paths": [ + { + "rows_to_scan": 6, + "filtering_effect": [ + ] /* filtering_effect */, + "final_filtering_effect": 1, + "access_type": "scan", + "using_join_cache": true, + "buffers_needed": 1, + "resulting_rows": 6, + "cost": 5.30491, + "chosen": true + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 16.6667, + "rows_for_plan": 8, + "cost_for_plan": 8.02988, + "semijoin_strategy_choice": [ + { + "strategy": "LooseScan", + "recalculate_access_paths_and_cost": { + "tables": [ + { + "table": "`t1` `table2`", + "best_access_path": { + "considered_access_paths": [ + { + "access_type": "ref", + "index": "col_int_key", + "usable": false, + "chosen": false + }, + { + "rows_to_scan": 4, + "filtering_effect": [ + ] /* filtering_effect */, + "final_filtering_effect": 1, + "access_type": "scan", + "resulting_rows": 4, + "cost": 0.901709, + "chosen": true + } + ] /* considered_access_paths */ + } /* best_access_path */, + "unknown_key_2": { + "searching_loose_scan_index": { + "indexes": [ + { + "index": "col_int_key", + "covering_scan": { + "cost": 0.267442, + "chosen": true + } /* covering_scan */ + } + ] /* indexes */ + } /* searching_loose_scan_index */ + } + }, + { + "table": "`where_subselect_20070`", + "best_access_path": { + "considered_access_paths": [ + { + "rows_to_scan": 6, + "filtering_effect": [ + ] /* filtering_effect */, + "final_filtering_effect": 1, + "access_type": "scan", + "using_join_cache": true, + "buffers_needed": 1, + "resulting_rows": 6, + "cost": 5.30491, + "chosen": true + } + ] /* considered_access_paths */ + } /* best_access_path */ + } + ] /* tables */ + } /* recalculate_access_paths_and_cost */, + "cost": 7.79561, + "rows": 1, + "chosen": true + }, + { + "strategy": "MaterializeScan", + "recalculate_access_paths_and_cost": { + "tables": [ + { + "table": "`where_subselect_20070`", + "best_access_path": { + "considered_access_paths": [ + { + "rows_to_scan": 6, + "filtering_effect": [ + ] /* filtering_effect */, + "final_filtering_effect": 1, + "access_type": "scan", + "using_join_cache": true, + "buffers_needed": 1, + "resulting_rows": 6, + "cost": 2.90484, + "chosen": true + } + ] /* considered_access_paths */ + } /* best_access_path */ + } + ] /* tables */ + } /* recalculate_access_paths_and_cost */, + "cost": 7.8298, + "rows": 1, + "duplicate_tables_left": false, + "chosen": false + }, + { + "strategy": "DuplicatesWeedout", + "cost": 9.92988, + "rows": 1, + "duplicate_tables_left": false, + "chosen": false + } + ] /* semijoin_strategy_choice */, + "pruned_by_cost": true + } + ] /* rest_of_plan */ + } + ] /* rest_of_plan */ + }, + { + "final_semijoin_strategy": "MaterializeLookup" + } + ] /* considered_execution_plans */ + }, + { + "creating_tmp_table": { + "tmp_table_info": { + "columns": 2, + "row_length": 13, + "key_length": 14, + "unique_constraint": false, + "makes_grouped_rows": false, + "cannot_insert_duplicates": true, + "location": "TempTable" + } /* tmp_table_info */ + } /* creating_tmp_table */ + }, + { + "subselect_execution": { + "select#": 2, + "steps": [ + ] /* steps */ + } /* subselect_execution */ + }, + { + "attaching_conditions_to_tables": { + "original_condition": "((``.`field1` = `where_subselect_20070`.`field1`) and (`table2`.`col_int_key` = `table1`.`col_int_key`))", + "attached_conditions_computation": [ + { + "table": "`t1` `table1`", + "rechecking_index_usage": { + "recheck_reason": "not_first_table", + "range_analysis": { + "table_scan": { + "rows": 4, + "cost": 3.00171 + } /* table_scan */, + "potential_range_indexes": [ + { + "index": "col_int_key", + "usable": true, + "key_parts": [ + "col_int_key" + ] /* key_parts */ + } + ] /* potential_range_indexes */, + "best_covering_index_scan": { + "index": "col_int_key", + "cost": 0.667442, + "chosen": true + } /* best_covering_index_scan */, + "setup_range_conditions": [ + ] /* setup_range_conditions */, + "group_index_range": { + "chosen": false, + "cause": "not_single_table" + } /* group_index_range */, + "skip_scan_range": { + "chosen": false, + "cause": "not_single_table" + } /* skip_scan_range */, + "analyzing_range_alternatives": { + "range_scan_alternatives": [ + { + "index": "col_int_key", + "ranges": [ + "NULL < col_int_key" + ] /* ranges */, + "index_dives_for_eq_ranges": true, + "rowid_ordered": false, + "using_mrr": false, + "index_only": true, + "rows": 4, + "cost": 0.677442, + "chosen": false, + "cause": "cost" + } + ] /* range_scan_alternatives */, + "analyzing_roworder_intersect": { + "usable": false, + "cause": "too_few_roworder_scans" + } /* analyzing_roworder_intersect */ + } /* analyzing_range_alternatives */ + } /* range_analysis */ + } /* rechecking_index_usage */ + } + ] /* attached_conditions_computation */, + "attached_conditions_summary": [ + { + "table": "`where_subselect_20070`", + "attached": "(`where_subselect_20070`.`field1` is not null)" + }, + { + "table": "``", + "attached": "(``.`field1` = `where_subselect_20070`.`field1`)" + }, + { + "table": "`t1` `table1`", + "attached": "(`table1`.`col_int_key` is not null)" + }, + { + "table": "`t1` `table2`", + "attached": "(`table2`.`col_int_key` = `table1`.`col_int_key`)" + } + ] /* attached_conditions_summary */ + } /* attaching_conditions_to_tables */ + }, + { + "finalizing_table_conditions": [ + { + "table": "`where_subselect_20070`", + "original_table_condition": "(`where_subselect_20070`.`field1` is not null)", + "final_table_condition ": "(`where_subselect_20070`.`field1` is not null)" + }, + { + "table": "``", + "original_table_condition": "(``.`field1` = `where_subselect_20070`.`field1`)", + "final_table_condition ": null + }, + { + "table": "`t1` `table1`", + "original_table_condition": "(`table1`.`col_int_key` is not null)", + "final_table_condition ": "(`table1`.`col_int_key` is not null)" + }, + { + "table": "`t1` `table2`", + "original_table_condition": "(`table2`.`col_int_key` = `table1`.`col_int_key`)", + "final_table_condition ": null + } + ] /* finalizing_table_conditions */ + }, + { + "refine_plan": [ + { + "table": "`where_subselect_20070`" + }, + { + "table": "``" + }, + { + "table": "`t1` `table1`" + }, + { + "table": "`t1` `table2`" + } + ] /* refine_plan */ + } + ] /* steps */ + } /* join_optimization */ + }, + { + "join_execution": { + "select#": 1, + "steps": [ + { + "materialize": { + "select#": 1, + "steps": [ + { + "subselect_execution": { + "select#": 4, + "steps": [ + ] /* steps */ + } /* subselect_execution */ + }, + { + "subselect_execution": { + "select#": 4, + "steps": [ + ] /* steps */ + } /* subselect_execution */ + }, + { + "subselect_execution": { + "select#": 4, + "steps": [ + ] /* steps */ + } /* subselect_execution */ + }, + { + "subselect_execution": { + "select#": 4, + "steps": [ + ] /* steps */ + } /* subselect_execution */ + }, + { + "subselect_execution": { + "select#": 4, + "steps": [ + ] /* steps */ + } /* subselect_execution */ + }, + { + "subselect_execution": { + "select#": 4, + "steps": [ + ] /* steps */ + } /* subselect_execution */ + }, + { + "subselect_execution": { + "select#": 4, + "steps": [ + ] /* steps */ + } /* subselect_execution */ + }, + { + "subselect_execution": { + "select#": 4, + "steps": [ + ] /* steps */ + } /* subselect_execution */ + }, + { + "subselect_execution": { + "select#": 4, + "steps": [ + ] /* steps */ + } /* subselect_execution */ + }, + { + "subselect_execution": { + "select#": 4, + "steps": [ + ] /* steps */ + } /* subselect_execution */ + }, + { + "subselect_execution": { + "select#": 4, + "steps": [ + ] /* steps */ + } /* subselect_execution */ + }, + { + "subselect_execution": { + "select#": 4, + "steps": [ + ] /* steps */ + } /* subselect_execution */ + } + ] /* steps */ + } /* materialize */ + } + ] /* steps */ + } /* join_execution */ + } + ] /* steps */ +} 0 0 +DROP TABLE where_subselect_20070,t1; +# +# Bug#13430443 - ASSERTION `NEW_TYPE[0] != 'U'' FAILED. WHEN +# OPTIMIZER_TRACE IS ENABLED +# +CREATE TABLE t1 +(a INT,b INT,c INT, KEY(a),KEY (a,c)) ENGINE=INNODB; +SELECT 1 FROM t1 WHERE 1 LIKE +(SELECT a FROM t1 WHERE a = 1 ORDER BY c); +1 +SELECT * FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES +SELECT 1 FROM t1 WHERE 1 LIKE +(SELECT a FROM t1 WHERE a = 1 ORDER BY c) { + "steps": [ + { + "join_preparation": { + "select#": 1, + "steps": [ + { + "join_preparation": { + "select#": 2, + "steps": [ + { + "transformations_to_subquery": [ + "removed_ordering" + ] /* transformations_to_subquery */ + }, + { + "expanded_query": "/* select#2 */ select `t1`.`a` from `t1` where (`t1`.`a` = 1)" + } + ] /* steps */ + } /* join_preparation */ + }, + { + "expanded_query": "/* select#1 */ select 1 AS `1` from `t1` where (1 like (/* select#2 */ select `t1`.`a` from `t1` where (`t1`.`a` = 1)))" + } + ] /* steps */ + } /* join_preparation */ + }, + { + "join_optimization": { + "select#": 1, + "steps": [ + { + "condition_processing": { + "condition": "WHERE", + "original_condition": "(1 like (/* select#2 */ select `t1`.`a` from `t1` where (`t1`.`a` = 1)))", + "steps": [ + { + "transformation": "equality_propagation", + "subselect_evaluation": [ + ] /* subselect_evaluation */, + "resulting_condition": "(1 like (/* select#2 */ select `t1`.`a` from `t1` where (`t1`.`a` = 1)))" + }, + { + "transformation": "constant_propagation", + "subselect_evaluation": [ + ] /* subselect_evaluation */, + "resulting_condition": "(1 like (/* select#2 */ select `t1`.`a` from `t1` where (`t1`.`a` = 1)))" + }, + { + "transformation": "trivial_condition_removal", + "subselect_evaluation": [ + { + "subselect_execution": { + "select#": 2, + "steps": [ + { + "join_optimization": { + "select#": 2, + "steps": [ + { + "condition_processing": { + "condition": "WHERE", + "original_condition": "(`t1`.`a` = 1)", + "steps": [ + { + "transformation": "equality_propagation", + "resulting_condition": "multiple equal(1, `t1`.`a`)" + }, + { + "transformation": "constant_propagation", + "resulting_condition": "multiple equal(1, `t1`.`a`)" + }, + { + "transformation": "trivial_condition_removal", + "resulting_condition": "multiple equal(1, `t1`.`a`)" + } + ] /* steps */ + } /* condition_processing */ + }, + { + "substitute_generated_columns": { + } /* substitute_generated_columns */ + }, + { + "table_dependencies": [ + { + "table": "`t1`", + "row_may_be_null": false, + "map_bit": 0, + "depends_on_map_bits": [ + ] /* depends_on_map_bits */ + } + ] /* table_dependencies */ + }, + { + "ref_optimizer_key_uses": [ + { + "table": "`t1`", + "field": "a", + "equals": "1", + "null_rejecting": true + }, + { + "table": "`t1`", + "field": "a", + "equals": "1", + "null_rejecting": true + } + ] /* ref_optimizer_key_uses */ + }, + { + "rows_estimation": [ + { + "table": "`t1`", + "range_analysis": { + "table_scan": { + "rows": 1, + "cost": 2.45 + } /* table_scan */, + "potential_range_indexes": [ + { + "index": "a", + "usable": true, + "key_parts": [ + "a" + ] /* key_parts */ + }, + { + "index": "a_2", + "usable": true, + "key_parts": [ + "a", + "c" + ] /* key_parts */ + } + ] /* potential_range_indexes */, + "best_covering_index_scan": { + "index": "a_2", + "cost": 0.35, + "chosen": true + } /* best_covering_index_scan */, + "setup_range_conditions": [ + ] /* setup_range_conditions */, + "group_index_range": { + "chosen": false, + "cause": "not_group_by_or_distinct" + } /* group_index_range */, + "skip_scan_range": { + "potential_skip_scan_indexes": [ + { + "index": "a", + "usable": false, + "cause": "query_references_nonkey_column" + }, + { + "index": "a_2", + "usable": false, + "cause": "no_range_predicate" + } + ] /* potential_skip_scan_indexes */ + } /* skip_scan_range */, + "analyzing_range_alternatives": { + "range_scan_alternatives": [ + { + "index": "a", + "ranges": [ + "1 <= a <= 1" + ] /* ranges */, + "index_dives_for_eq_ranges": true, + "rowid_ordered": true, + "using_mrr": true, + "index_only": false, + "rows": 1, + "cost": 0.6, + "chosen": false, + "cause": "cost" + }, + { + "index": "a_2", + "ranges": [ + "1 <= a <= 1" + ] /* ranges */, + "index_dives_for_eq_ranges": true, + "rowid_ordered": false, + "using_mrr": false, + "index_only": true, + "rows": 1, + "cost": 0.36, + "chosen": false, + "cause": "cost" + } + ] /* range_scan_alternatives */, + "analyzing_roworder_intersect": { + "usable": false, + "cause": "too_few_roworder_scans" + } /* analyzing_roworder_intersect */ + } /* analyzing_range_alternatives */ + } /* range_analysis */ + } + ] /* rows_estimation */ + }, + { + "considered_execution_plans": [ + { + "plan_prefix": [ + ] /* plan_prefix */, + "table": "`t1`", + "best_access_path": { + "considered_access_paths": [ + { + "access_type": "ref", + "index": "a", + "rows": 1, + "cost": 0.35, + "chosen": true + }, + { + "access_type": "ref", + "index": "a_2", + "rows": 1, + "cost": 0.35, + "chosen": false + }, + { + "access_type": "scan", + "chosen": false, + "cause": "covering_index_better_than_full_scan" + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 100, + "rows_for_plan": 1, + "cost_for_plan": 0.35, + "chosen": true + } + ] /* considered_execution_plans */ + }, + { + "attaching_conditions_to_tables": { + "original_condition": "(`t1`.`a` = 1)", + "attached_conditions_computation": [ + ] /* attached_conditions_computation */, + "attached_conditions_summary": [ + { + "table": "`t1`", + "attached": "(`t1`.`a` = 1)" + } + ] /* attached_conditions_summary */ + } /* attaching_conditions_to_tables */ + }, + { + "finalizing_table_conditions": [ + { + "table": "`t1`", + "original_table_condition": "(`t1`.`a` = 1)", + "final_table_condition ": null + } + ] /* finalizing_table_conditions */ + }, + { + "refine_plan": [ + { + "table": "`t1`" + } + ] /* refine_plan */ + } + ] /* steps */ + } /* join_optimization */ + }, + { + "join_execution": { + "select#": 2, + "steps": [ + ] /* steps */ + } /* join_execution */ + } + ] /* steps */ + } /* subselect_execution */ + } + ] /* subselect_evaluation */, + "resulting_condition": null + } + ] /* steps */ + } /* condition_processing */ + } + ] /* steps */, + "empty_result": { + "cause": "Impossible WHERE" + } /* empty_result */ + } /* join_optimization */ + }, + { + "join_execution": { + "select#": 1, + "steps": [ + ] /* steps */ + } /* join_execution */ + } + ] /* steps */ +} 0 0 +DROP TABLE t1; +# +# Bug #18346750 OPTIMIZER_TRACE & DBUG_PRINT CRASH IN ST_SELECT_LEX::PRINT +# +"Skipped since this engine does not support native partitioning. +# +# Bug#18791851 CRASH IN ST_SELECT_LEX::PRINT WITH OPTIMIZER_TRACE ON SUBQUERY +# +CREATE TABLE t1 ( +pk INT NOT NULL, +col_int_nokey INT, +col_int_key INT, +col_time_key time, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk), +KEY col_varchar_key (col_varchar_key,col_int_key) +); +CREATE TABLE t2 ( +pk INT NOT NULL, +col_int_nokey INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk), +KEY col_varchar_key (col_varchar_key,col_int_key) +); +CREATE TABLE t3 ( +pk INT NOT NULL, +col_int_nokey INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk), +KEY col_varchar_key (col_varchar_key,col_int_key) +); +CREATE TABLE t4 ( +pk INT NOT NULL, +col_int_nokey INT, +col_int_key INT, +col_time_key time, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk), +KEY col_varchar_key (col_varchar_key,col_int_key) +); +SELECT alias1.col_int_nokey AS field1, +alias2.col_varchar_key AS field2, +alias1.col_time_key AS field3, +MIN( alias1.col_int_nokey ) AS field4 +FROM ( +( +SELECT SQ1_alias1.* +FROM ( t1 AS SQ1_alias1, t2 AS SQ1_alias2 ) +) AS alias1, +t4 AS alias2 +) +WHERE +EXISTS ( +SELECT DISTINCT SQ2_alias2.col_varchar_nokey AS SQ2_field1 +FROM t2 AS SQ2_alias1 +INNER JOIN (t4 AS SQ2_alias2 +INNER JOIN t3 AS SQ2_alias3 +ON SQ2_alias3.pk = SQ2_alias2.pk) +ON SQ2_alias3.col_varchar_key = SQ2_alias2.col_varchar_nokey +) +AND alias1.col_int_key = alias2.pk +HAVING alias1.col_int_nokey IN ( SELECT 2 FROM DUAL ) ; +field1 field2 field3 field4 +DROP TABLE t1,t2,t3,t4; +CREATE TABLE t1(a INT); +SET @a:=(SELECT ROW(1, 2)= +ROW((SELECT 1 FROM t1 LEFT JOIN t1 t2 ON 1 +HAVING 3 IN (SELECT 2 FROM DUAL)), +1)); +DROP TABLE t1; +# +# Bug #18945693 CRASH IN PRINT_TABLE_ARRAY AT SQL/SQL_LEX.CC ON 2ND EXEC OF PREPARED STATEMENT +# +CREATE TABLE t1 ( +pk INT NOT NULL, +col_int_nokey INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1) +); +INSERT INTO t1 VALUES (13,7,3,'y','y'),(14,0,4,'c','c'); +CREATE TABLE t2 ( +pk INT NOT NULL, +col_int_nokey INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1) +); +INSERT INTO t2 VALUES (20,9,8,'e','e'); +CREATE TABLE t3 ( +pk INT NOT NULL, +col_int_nokey INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1) +); +INSERT INTO t3 VALUES (1,1,7,'k','k'); +PREPARE prep_stmt FROM " +SELECT + alias1.col_varchar_nokey AS field1, + MAX(alias1.pk) AS field2 +FROM t3 AS alias1 +GROUP BY field1 +HAVING + 1 > ( + SELECT MAX(SQ4_alias1.col_varchar_nokey) + FROM t1 AS SQ4_alias1 + RIGHT OUTER JOIN + ( + t2 AS SQ4_alias2 + JOIN t1 AS SQ4_alias3 + ON SQ4_alias3.col_int_key = SQ4_alias2.col_int_nokey + ) + ON SQ4_alias3.pk = SQ4_alias2.col_int_nokey + ) +"; +EXECUTE prep_stmt; +field1 field2 +EXECUTE prep_stmt; +field1 field2 +DROP TABLE t1,t2,t3; +# +# Bug#19063289 CRASH IN PRINT_TABLE_ARRAY ON 2ND EXECUTION OF PS WITH SUBQUERY AND VIEW +# +CREATE TABLE B ( +pk INTEGER, +col_int_key INTEGER, +col_varchar_nokey VARCHAR(1) +); +CREATE TABLE C ( +col_int_nokey INTEGER, +col_int_key INTEGER, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1) +) ; +CREATE TABLE CC ( +pk INTEGER, +col_int_key INTEGER +) ENGINE=MYISAM; +INSERT INTO CC VALUES (1, 0),(2, 7); +PREPARE stmt FROM " +SELECT +alias1.col_int_key AS field1 , +COUNT(alias1.pk) AS field2 +FROM +CC AS alias1 +GROUP BY field1 +HAVING +alias1.col_int_key > + ( + SELECT + MAX( SQ2_alias2.col_int_key ) AS SQ2_field1 + FROM + C AS SQ2_alias1 LEFT JOIN + ( B AS SQ2_alias2 INNER JOIN C AS SQ2_alias3 + ON 1) + ON 1 + ) +OR field2 < 2 +"; +EXECUTE stmt; +field1 field2 +0 1 +7 1 +EXECUTE stmt; +field1 field2 +0 1 +7 1 +DROP TABLE B,C,CC; +# +# Bug #23259872: OPTIMIZER CHOOSES TO USE NON PRIMARY +# INDEX, EVEN THOUGH COST IS HIGHER +# +CREATE TABLE t1 ( +a TINYTEXT NOT NULL, +b TINYINT(3) UNSIGNED NOT NULL, +PRIMARY KEY (a(32),b) +) ENGINE=MyISAM, CHARSET utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t2 ( +a TINYTEXT NOT NULL, +b TINYINT(3) UNSIGNED NOT NULL, +PRIMARY KEY (a(32),b) +) ENGINE=INNODB, CHARSET utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES ('a',1),('a',2); +INSERT INTO t2 VALUES ('a',1),('a',2),('a',3),('b',1),('c',1),('c',4),('e',2); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +ANALYZE TABLE t2; +Table Op Msg_type Msg_text +test.t2 analyze status OK +EXPLAIN SELECT * FROM t1 WHERE a='a' AND b in (1,2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range PRIMARY PRIMARY 131 NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`a` = 'a') and (`test`.`t1`.`b` in (1,2))) +SELECT TRACE into @trace FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +SELECT @trace RLIKE "range_uses_more_keyparts"; +@trace RLIKE "range_uses_more_keyparts" +1 +EXPLAIN SELECT * FROM t2 WHERE a='a' AND b in (1,2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range PRIMARY PRIMARY 131 NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t2` where ((`test`.`t2`.`a` = 'a') and (`test`.`t2`.`b` in (1,2))) +SELECT TRACE into @trace FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +SELECT @trace RLIKE "range_uses_more_keyparts"; +@trace RLIKE "range_uses_more_keyparts" +1 +DROP TABLE t1, t2; +# +# Bug #23227428: SQL PLAN IS NOT ACCORDING WITH OPTIMIZER_TRACE +# +CREATE TABLE t1(c1 INT NOT NULL AUTO_INCREMENT PRIMARY KEY, +c2 CHAR(12)) ENGINE=INNODB; +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT c1, c2 FROM t1 ORDER BY c1 DESC LIMIT 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Backward index scan; Parallel execute (3 workers) +2 SIMPLE t1 NULL index NULL PRIMARY 4 NULL 1 100.00 Backward index scan +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c1` AS `c1`,`test`.`t1`.`c2` AS `c2` from `test`.`t1` order by `test`.`t1`.`c1` desc limit 1 +SELECT * FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES +EXPLAIN SELECT c1, c2 FROM t1 ORDER BY c1 DESC LIMIT 1 { + "steps": [ + { + "join_preparation": { + "select#": 1, + "steps": [ + { + "expanded_query": "/* select#1 */ select `t1`.`c1` AS `c1`,`t1`.`c2` AS `c2` from `t1` order by `t1`.`c1` desc limit 1" + } + ] /* steps */ + } /* join_preparation */ + }, + { + "join_optimization": { + "select#": 1, + "steps": [ + { + "substitute_generated_columns": { + } /* substitute_generated_columns */ + }, + { + "table_dependencies": [ + { + "table": "`t1`", + "row_may_be_null": false, + "map_bit": 0, + "depends_on_map_bits": [ + ] /* depends_on_map_bits */ + } + ] /* table_dependencies */ + }, + { + "rows_estimation": [ + { + "table": "`t1`", + "table_scan": { + "rows": 1000, + "cost": 1 + } /* table_scan */ + } + ] /* rows_estimation */ + }, + { + "considered_execution_plans": [ + { + "plan_prefix": [ + ] /* plan_prefix */, + "table": "`t1`", + "best_access_path": { + "considered_access_paths": [ + { + "rows_to_scan": 1000, + "access_type": "scan", + "resulting_rows": 1000, + "cost": 101, + "chosen": true + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 100, + "rows_for_plan": 1000, + "cost_for_plan": 101, + "chosen": true + } + ] /* considered_execution_plans */ + }, + { + "attaching_conditions_to_tables": { + "original_condition": null, + "attached_conditions_computation": [ + ] /* attached_conditions_computation */, + "attached_conditions_summary": [ + { + "table": "`t1`", + "attached": null + } + ] /* attached_conditions_summary */ + } /* attaching_conditions_to_tables */ + }, + { + "optimizing_distinct_group_by_order_by": { + "simplifying_order_by": { + "original_clause": "`t1`.`c1` desc", + "items": [ + { + "item": "`t1`.`c1`" + } + ] /* items */, + "resulting_clause_is_simple": true, + "resulting_clause": "`t1`.`c1` desc" + } /* simplifying_order_by */ + } /* optimizing_distinct_group_by_order_by */ + }, + { + "reconsidering_access_paths_for_index_ordering": { + "clause": "ORDER BY", + "steps": [ + ] /* steps */, + "index_order_summary": { + "table": "`t1`", + "index_provides_order": true, + "order_direction": "desc", + "index": "PRIMARY", + "plan_changed": true, + "access_type": "index" + } /* index_order_summary */ + } /* reconsidering_access_paths_for_index_ordering */ + }, + { + "finalizing_table_conditions": [ + ] /* finalizing_table_conditions */ + }, + { + "refine_plan": [ + { + "table": "`t1`" + } + ] /* refine_plan */ + }, + { + "considering_tmp_tables": [ + ] /* considering_tmp_tables */ + } + ] /* steps */ + } /* join_optimization */ + }, + { + "make_parallel_query_plan": { + "select#": 1, + "detail": [ + { + "table": "`t1`", + "degree of parallel": 4, + "unknown_key_1": { + "considering_tmp_tables": [ + { + "adding_tmp_table_in_plan_at_position": 0, + "cause": "output_for_parallel_query" + } + ] /* considering_tmp_tables */ + } + } + ] /* detail */ + } /* make_parallel_query_plan */ + }, + { + "join_explain": { + "select#": 1, + "steps": [ + ] /* steps */ + } /* join_explain */ + } + ] /* steps */ +} 0 0 +DROP TABLE t1; +# Bug#29016383 - fil_report_invalid_page_access +CREATE TABLE t1 ( +pk INTEGER PRIMARY KEY, +a INTEGER, +b VARCHAR(20) +); +CREATE TABLE t2 ( +pk INTEGER PRIMARY KEY, +c VARCHAR(20), +KEY (c) +); +INSERT INTO t2 VALUES +(1,'koeiwsgpmfyvvuqvtjnc'), +(2,'pmfyvvuqvtjncdsvq'), +(3,'mfyv'), +(4,NULL); +SET end_markers_in_json=off; +SELECT alias1.* +FROM t2 AS alias1, t2 AS alias2 +WHERE alias2.c IN ( +WITH qn AS (SELECT b FROM t1 WHERE a = alias1.pk) +SELECT * FROM qn); +pk c +# Prove that the predicate from the WHERE clause of the CTE +# is decorrelated: +SELECT json_extract(trace,'$**.decorrelated_predicates') +FROM information_schema.optimizer_trace; +json_extract(trace,'$**.decorrelated_predicates') +[[{"inner": "`t1`.`b`", "outer": "`alias2`.`c`"}, {"inner": "`t1`.`a`", "outer": "`alias1`.`pk`"}]] +DROP TABLE t1, t2; diff --git a/mysql-test/suite/bugs_no_prot_none.result-pq b/mysql-test/suite/bugs_no_prot_none.result-pq new file mode 100644 index 000000000000..920d41083af0 --- /dev/null +++ b/mysql-test/suite/bugs_no_prot_none.result-pq @@ -0,0 +1,2395 @@ +set optimizer_trace_max_mem_size=1048576; +SET end_markers_in_json=on; +SET optimizer_trace="enabled=on,one_line=off"; +# +# BUG#12430646 - SEL_ARG::LEFT AND RIGHT POINTERS INCORRECTLY +# USED. CRASHES OPTIMIZER TRACING +# +CREATE TABLE t1 ( +a INT, +b CHAR(2), +c INT, +d INT, +KEY (c), +KEY (d,a,b(2)), +KEY (b(1)) +); +INSERT INTO t1 VALUES (NULL, 'a', 1, 2), (NULL, 'a', 1, 2), +(1, 'a', 1, 2), (1, 'a', 1, 2); +CREATE TABLE t2 ( +a INT, +c INT, +e INT, +KEY (e) +); +INSERT INTO t2 VALUES (1, 1, NULL), (1, 1, NULL); +SELECT 1 +FROM t1, t2 +WHERE t1.d <> '1' AND t1.b > '1' +AND t1.a = t2.a AND t1.c = t2.c; +1 +1 +1 +1 +1 +DROP TABLE t1, t2; +# +# BUG#12595210 - JSON SYNTAX ERROR ASSERT ON WHERE FIELD NOT IN SUBQUERY +# +CREATE TABLE t1 ( +pk INT NOT NULL AUTO_INCREMENT, +col_int_key INT DEFAULT NULL, +col_varchar_key VARCHAR(1) DEFAULT NULL, +PRIMARY KEY (pk) +) ENGINE=InnoDB, CHARSET utf8mb4; +CREATE TABLE t2 ( +pk INT NOT NULL AUTO_INCREMENT, +col_int_key INT DEFAULT NULL, +col_varchar_key VARCHAR(1) DEFAULT NULL, +col_varchar_nokey VARCHAR(1) DEFAULT NULL, +PRIMARY KEY (pk) +) ENGINE=InnoDB, CHARSET utf8mb4; +CREATE TABLE t3 ( +pk INT NOT NULL AUTO_INCREMENT, +col_int_key INT DEFAULT NULL, +col_varchar_key VARCHAR(1) DEFAULT NULL, +col_varchar_nokey VARCHAR(1) DEFAULT NULL, +PRIMARY KEY (pk) +) ENGINE=InnoDB, CHARSET utf8mb4; +CREATE TABLE t4 ( +pk INT NOT NULL AUTO_INCREMENT, +col_int_key INT DEFAULT NULL, +col_varchar_key VARCHAR(1) DEFAULT NULL, +PRIMARY KEY (pk) +) ENGINE=InnoDB, CHARSET utf8mb4; +CREATE VIEW view_t4 AS SELECT * FROM t4; +CREATE TABLE where_subselect_19379 SELECT +( +SELECT SUM(sq1_alias1.pk) AS sq1_field1 +FROM view_t4 AS sq1_alias1 +INNER JOIN t1 AS sq1_alias2 ON (sq1_alias2.col_varchar_key = +sq1_alias1.col_varchar_key ) +) AS field1, +alias1.col_varchar_nokey AS field2 +FROM (t2 AS alias1 +LEFT JOIN ( t2 AS alias2 +LEFT OUTER JOIN t2 AS alias3 ON (alias3.col_varchar_nokey = +alias2.col_varchar_key ) +) ON (alias3.col_varchar_key = alias2.col_varchar_key) +) +WHERE ( alias2.col_varchar_key IN ( +SELECT sq2_alias1.col_varchar_nokey AS sq2_field1 +FROM t3 AS sq2_alias1 +WHERE sq2_alias1.col_varchar_nokey <= alias1.col_varchar_key +) +); +SELECT * FROM where_subselect_19379 WHERE (field1, field2) NOT IN +(SELECT +( +SELECT SUM(sq1_alias1.pk) AS sq1_field1 +FROM view_t4 AS sq1_alias1 +INNER JOIN t1 AS sq1_alias2 ON (sq1_alias2.col_varchar_key = +sq1_alias1.col_varchar_key ) +) AS field1, +alias1.col_varchar_nokey AS field2 +FROM (t2 AS alias1 +LEFT JOIN ( t2 AS alias2 +LEFT OUTER JOIN t2 AS alias3 ON (alias3.col_varchar_nokey = +alias2.col_varchar_key ) +) ON (alias3.col_varchar_key = alias2.col_varchar_key) +) +WHERE ( alias2.col_varchar_key IN ( +SELECT sq2_alias1.col_varchar_nokey AS sq2_field1 +FROM t3 AS sq2_alias1 +WHERE sq2_alias1.col_varchar_nokey <= alias1.col_varchar_key +) +)); +field1 field2 +select * from information_schema.OPTIMIZER_TRACE; +QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES +SELECT * FROM where_subselect_19379 WHERE (field1, field2) NOT IN +(SELECT +( +SELECT SUM(sq1_alias1.pk) AS sq1_field1 +FROM view_t4 AS sq1_alias1 +INNER JOIN t1 AS sq1_alias2 ON (sq1_alias2.col_varchar_key = +sq1_alias1.col_varchar_key ) +) AS field1, +alias1.col_varchar_nokey AS field2 +FROM (t2 AS alias1 +LEFT JOIN ( t2 AS alias2 +LEFT OUTER JOIN t2 AS alias3 ON (alias3.col_varchar_nokey = +alias2.col_varchar_key ) +) ON (alias3.col_varchar_key = alias2.col_varchar_key) +) +WHERE ( alias2.col_varchar_key IN ( +SELECT sq2_alias1.col_varchar_nokey AS sq2_field1 +FROM t3 AS sq2_alias1 +WHERE sq2_alias1.col_varchar_nokey <= alias1.col_varchar_key +) +)) { + "steps": [ + { + "join_preparation": { + "select#": 1, + "steps": [ + { + "join_preparation": { + "select#": 2, + "steps": [ + { + "join_preparation": { + "select#": 3, + "steps": [ + { + "join_preparation": { + "select#": 5, + "steps": [ + { + "expanded_query": "/* select#5 */ select `t4`.`pk` AS `pk`,`t4`.`col_int_key` AS `col_int_key`,`t4`.`col_varchar_key` AS `col_varchar_key` from `t4`" + } + ] /* steps */ + } /* join_preparation */ + }, + { + "view": { + "table": "`view_t4` `sq1_alias1`", + "select#": 5, + "merged": true + } /* view */ + }, + { + "expanded_query": "/* select#3 */ select sum(`t4`.`pk`) AS `sq1_field1` from ((`t4`) join `t1` `sq1_alias2` on((`sq1_alias2`.`col_varchar_key` = `t4`.`col_varchar_key`)))" + } + ] /* steps */ + } /* join_preparation */ + }, + { + "join_preparation": { + "select#": 4, + "steps": [ + { + "expanded_query": "/* select#4 */ select `sq2_alias1`.`col_varchar_nokey` AS `sq2_field1` from `t3` `sq2_alias1` where (`sq2_alias1`.`col_varchar_nokey` <= `alias1`.`col_varchar_key`)" + }, + { + "transformation": { + "select#": 4, + "from": "IN (SELECT)", + "to": "EXISTS (CORRELATED SELECT)", + "chosen": true, + "evaluating_constant_where_conditions": [ + ] /* evaluating_constant_where_conditions */ + } /* transformation */ + } + ] /* steps */ + } /* join_preparation */ + }, + { + "expanded_query": "/* select#2 */ select (/* select#3 */ select sum(`t4`.`pk`) AS `sq1_field1` from ((`t4`) join `t1` `sq1_alias2` on((`sq1_alias2`.`col_varchar_key` = `t4`.`col_varchar_key`)))) AS `field1`,`alias1`.`col_varchar_nokey` AS `field2` from (`t2` `alias1` left join (`t2` `alias2` left join `t2` `alias3` on((`alias3`.`col_varchar_nokey` = `alias2`.`col_varchar_key`))) on((`alias3`.`col_varchar_key` = `alias2`.`col_varchar_key`))) where (`alias2`.`col_varchar_key`,(/* select#4 */ select `sq2_alias1`.`col_varchar_nokey` AS `sq2_field1` from `t3` `sq2_alias1` where ((`sq2_alias1`.`col_varchar_nokey` <= `alias1`.`col_varchar_key`) and ((`alias2`.`col_varchar_key`) = `sq2_alias1`.`col_varchar_nokey`))))" + }, + { + "transformation": { + "select#": 2, + "from": "IN (SELECT)", + "to": "EXISTS (CORRELATED SELECT)", + "chosen": true, + "evaluating_constant_where_conditions": [ + ] /* evaluating_constant_where_conditions */, + "evaluating_constant_having_conditions": [ + ] /* evaluating_constant_having_conditions */ + } /* transformation */ + } + ] /* steps */ + } /* join_preparation */ + }, + { + "expanded_query": "/* select#1 */ select `where_subselect_19379`.`field1` AS `field1`,`where_subselect_19379`.`field2` AS `field2` from `where_subselect_19379` where ((`where_subselect_19379`.`field1`,`where_subselect_19379`.`field2`),(/* select#2 */ select (/* select#3 */ select sum(`t4`.`pk`) AS `sq1_field1` from ((`t4`) join `t1` `sq1_alias2` on((`sq1_alias2`.`col_varchar_key` = `t4`.`col_varchar_key`)))) AS `field1`,`alias1`.`col_varchar_nokey` AS `field2` from (`t2` `alias1` left join (`t2` `alias2` left join `t2` `alias3` on((`alias3`.`col_varchar_nokey` = `alias2`.`col_varchar_key`))) on((`alias3`.`col_varchar_key` = `alias2`.`col_varchar_key`))) where ((`alias2`.`col_varchar_key`,(/* select#4 */ select `sq2_alias1`.`col_varchar_nokey` AS `sq2_field1` from `t3` `sq2_alias1` where ((`sq2_alias1`.`col_varchar_nokey` <= `alias1`.`col_varchar_key`) and ((`alias2`.`col_varchar_key`) = `sq2_alias1`.`col_varchar_nokey`)))) and (outer_field_is_not_null, (((`where_subselect_19379`.`field1`) = (/* select#3 */ select sum(`t4`.`pk`) AS `sq1_field1` from ((`t4`) join `t1` `sq1_alias2` on((`sq1_alias2`.`col_varchar_key` = `t4`.`col_varchar_key`))))) or ((/* select#3 */ select sum(`t4`.`pk`) AS `sq1_field1` from ((`t4`) join `t1` `sq1_alias2` on((`sq1_alias2`.`col_varchar_key` = `t4`.`col_varchar_key`)))) is null)), true) and (outer_field_is_not_null, (((`where_subselect_19379`.`field2`) = `alias1`.`col_varchar_nokey`) or (`alias1`.`col_varchar_nokey` is null)), true)) having ((outer_field_is_not_null, ((/* select#3 */ select sum(`t4`.`pk`) AS `sq1_field1` from ((`t4`) join `t1` `sq1_alias2` on((`sq1_alias2`.`col_varchar_key` = `t4`.`col_varchar_key`))))), true) and (outer_field_is_not_null, (`alias1`.`col_varchar_nokey`), true))) is false)" + }, + { + "transformations_to_nested_joins": { + "transformations": [ + "JOIN_condition_to_WHERE", + "parenthesis_removal" + ] /* transformations */, + "expanded_query": "/* select#3 */ select sum(`t4`.`pk`) AS `sq1_field1` from `t4` join `t1` `sq1_alias2` where (`sq1_alias2`.`col_varchar_key` = `t4`.`col_varchar_key`)" + } /* transformations_to_nested_joins */ + }, + { + "transformations_to_nested_joins": { + "transformations": [ + "outer_join_to_inner_join", + "JOIN_condition_to_WHERE", + "parenthesis_removal" + ] /* transformations */, + "expanded_query": "/* select#2 */ select (/* select#3 */ select sum(`t4`.`pk`) AS `sq1_field1` from `t4` join `t1` `sq1_alias2` where (`sq1_alias2`.`col_varchar_key` = `t4`.`col_varchar_key`)) AS `field1`,`alias1`.`col_varchar_nokey` AS `field2` from `t2` `alias1` join `t2` `alias2` join `t2` `alias3` where ((`alias2`.`col_varchar_key`,(/* select#4 */ select `sq2_alias1`.`col_varchar_nokey` AS `sq2_field1` from `t3` `sq2_alias1` where ((`sq2_alias1`.`col_varchar_nokey` <= `alias1`.`col_varchar_key`) and ((`alias2`.`col_varchar_key`) = `sq2_alias1`.`col_varchar_nokey`)))) and (outer_field_is_not_null, (((`where_subselect_19379`.`field1`) = (/* select#3 */ select sum(`t4`.`pk`) AS `sq1_field1` from `t4` join `t1` `sq1_alias2` where (`sq1_alias2`.`col_varchar_key` = `t4`.`col_varchar_key`))) or ((/* select#3 */ select sum(`t4`.`pk`) AS `sq1_field1` from `t4` join `t1` `sq1_alias2` where (`sq1_alias2`.`col_varchar_key` = `t4`.`col_varchar_key`)) is null)), true) and (outer_field_is_not_null, (((`where_subselect_19379`.`field2`) = `alias1`.`col_varchar_nokey`) or (`alias1`.`col_varchar_nokey` is null)), true) and (`alias3`.`col_varchar_key` = `alias2`.`col_varchar_key`) and (`alias3`.`col_varchar_nokey` = `alias2`.`col_varchar_key`)) having ((outer_field_is_not_null, ((/* select#3 */ select sum(`t4`.`pk`) AS `sq1_field1` from `t4` join `t1` `sq1_alias2` where (`sq1_alias2`.`col_varchar_key` = `t4`.`col_varchar_key`))), true) and (outer_field_is_not_null, (`alias1`.`col_varchar_nokey`), true))" + } /* transformations_to_nested_joins */ + } + ] /* steps */ + } /* join_preparation */ + }, + { + "join_optimization": { + "select#": 1, + "steps": [ + { + "condition_processing": { + "condition": "WHERE", + "original_condition": "((`where_subselect_19379`.`field1`,`where_subselect_19379`.`field2`),(/* select#2 */ select (/* select#3 */ select sum(`t4`.`pk`) AS `sq1_field1` from `t4` join `t1` `sq1_alias2` where (`sq1_alias2`.`col_varchar_key` = `t4`.`col_varchar_key`)) AS `field1`,`alias1`.`col_varchar_nokey` AS `field2` from `t2` `alias1` join `t2` `alias2` join `t2` `alias3` where ((`alias2`.`col_varchar_key`,(/* select#4 */ select `sq2_alias1`.`col_varchar_nokey` AS `sq2_field1` from `t3` `sq2_alias1` where ((`sq2_alias1`.`col_varchar_nokey` <= `alias1`.`col_varchar_key`) and ((`alias2`.`col_varchar_key`) = `sq2_alias1`.`col_varchar_nokey`)))) and (outer_field_is_not_null, (((`where_subselect_19379`.`field1`) = (/* select#3 */ select sum(`t4`.`pk`) AS `sq1_field1` from `t4` join `t1` `sq1_alias2` where (`sq1_alias2`.`col_varchar_key` = `t4`.`col_varchar_key`))) or ((/* select#3 */ select sum(`t4`.`pk`) AS `sq1_field1` from `t4` join `t1` `sq1_alias2` where (`sq1_alias2`.`col_varchar_key` = `t4`.`col_varchar_key`)) is null)), true) and (outer_field_is_not_null, (((`where_subselect_19379`.`field2`) = `alias1`.`col_varchar_nokey`) or (`alias1`.`col_varchar_nokey` is null)), true) and (`alias3`.`col_varchar_key` = `alias2`.`col_varchar_key`) and (`alias3`.`col_varchar_nokey` = `alias2`.`col_varchar_key`)) having ((outer_field_is_not_null, ((/* select#3 */ select sum(`t4`.`pk`) AS `sq1_field1` from `t4` join `t1` `sq1_alias2` where (`sq1_alias2`.`col_varchar_key` = `t4`.`col_varchar_key`))), true) and (outer_field_is_not_null, (`alias1`.`col_varchar_nokey`), true))) is false)", + "steps": [ + { + "transformation": "equality_propagation", + "subselect_evaluation": [ + ] /* subselect_evaluation */, + "resulting_condition": "((`where_subselect_19379`.`field1`,`where_subselect_19379`.`field2`),(/* select#2 */ select (/* select#3 */ select sum(`t4`.`pk`) AS `sq1_field1` from `t4` join `t1` `sq1_alias2` where (`sq1_alias2`.`col_varchar_key` = `t4`.`col_varchar_key`)) AS `field1`,`alias1`.`col_varchar_nokey` AS `field2` from `t2` `alias1` join `t2` `alias2` join `t2` `alias3` where ((`alias2`.`col_varchar_key`,(/* select#4 */ select `sq2_alias1`.`col_varchar_nokey` AS `sq2_field1` from `t3` `sq2_alias1` where ((`sq2_alias1`.`col_varchar_nokey` <= `alias1`.`col_varchar_key`) and ((`alias2`.`col_varchar_key`) = `sq2_alias1`.`col_varchar_nokey`)))) and (outer_field_is_not_null, (((`where_subselect_19379`.`field1`) = (/* select#3 */ select sum(`t4`.`pk`) AS `sq1_field1` from `t4` join `t1` `sq1_alias2` where (`sq1_alias2`.`col_varchar_key` = `t4`.`col_varchar_key`))) or ((/* select#3 */ select sum(`t4`.`pk`) AS `sq1_field1` from `t4` join `t1` `sq1_alias2` where (`sq1_alias2`.`col_varchar_key` = `t4`.`col_varchar_key`)) is null)), true) and (outer_field_is_not_null, (((`where_subselect_19379`.`field2`) = `alias1`.`col_varchar_nokey`) or (`alias1`.`col_varchar_nokey` is null)), true) and (`alias3`.`col_varchar_key` = `alias2`.`col_varchar_key`) and (`alias3`.`col_varchar_nokey` = `alias2`.`col_varchar_key`)) having ((outer_field_is_not_null, ((/* select#3 */ select sum(`t4`.`pk`) AS `sq1_field1` from `t4` join `t1` `sq1_alias2` where (`sq1_alias2`.`col_varchar_key` = `t4`.`col_varchar_key`))), true) and (outer_field_is_not_null, (`alias1`.`col_varchar_nokey`), true))) is false)" + }, + { + "transformation": "constant_propagation", + "subselect_evaluation": [ + ] /* subselect_evaluation */, + "resulting_condition": "((`where_subselect_19379`.`field1`,`where_subselect_19379`.`field2`),(/* select#2 */ select (/* select#3 */ select sum(`t4`.`pk`) AS `sq1_field1` from `t4` join `t1` `sq1_alias2` where (`sq1_alias2`.`col_varchar_key` = `t4`.`col_varchar_key`)) AS `field1`,`alias1`.`col_varchar_nokey` AS `field2` from `t2` `alias1` join `t2` `alias2` join `t2` `alias3` where ((`alias2`.`col_varchar_key`,(/* select#4 */ select `sq2_alias1`.`col_varchar_nokey` AS `sq2_field1` from `t3` `sq2_alias1` where ((`sq2_alias1`.`col_varchar_nokey` <= `alias1`.`col_varchar_key`) and ((`alias2`.`col_varchar_key`) = `sq2_alias1`.`col_varchar_nokey`)))) and (outer_field_is_not_null, (((`where_subselect_19379`.`field1`) = (/* select#3 */ select sum(`t4`.`pk`) AS `sq1_field1` from `t4` join `t1` `sq1_alias2` where (`sq1_alias2`.`col_varchar_key` = `t4`.`col_varchar_key`))) or ((/* select#3 */ select sum(`t4`.`pk`) AS `sq1_field1` from `t4` join `t1` `sq1_alias2` where (`sq1_alias2`.`col_varchar_key` = `t4`.`col_varchar_key`)) is null)), true) and (outer_field_is_not_null, (((`where_subselect_19379`.`field2`) = `alias1`.`col_varchar_nokey`) or (`alias1`.`col_varchar_nokey` is null)), true) and (`alias3`.`col_varchar_key` = `alias2`.`col_varchar_key`) and (`alias3`.`col_varchar_nokey` = `alias2`.`col_varchar_key`)) having ((outer_field_is_not_null, ((/* select#3 */ select sum(`t4`.`pk`) AS `sq1_field1` from `t4` join `t1` `sq1_alias2` where (`sq1_alias2`.`col_varchar_key` = `t4`.`col_varchar_key`))), true) and (outer_field_is_not_null, (`alias1`.`col_varchar_nokey`), true))) is false)" + }, + { + "transformation": "trivial_condition_removal", + "subselect_evaluation": [ + ] /* subselect_evaluation */, + "resulting_condition": "((`where_subselect_19379`.`field1`,`where_subselect_19379`.`field2`),(/* select#2 */ select (/* select#3 */ select sum(`t4`.`pk`) AS `sq1_field1` from `t4` join `t1` `sq1_alias2` where (`sq1_alias2`.`col_varchar_key` = `t4`.`col_varchar_key`)) AS `field1`,`alias1`.`col_varchar_nokey` AS `field2` from `t2` `alias1` join `t2` `alias2` join `t2` `alias3` where ((`alias2`.`col_varchar_key`,(/* select#4 */ select `sq2_alias1`.`col_varchar_nokey` AS `sq2_field1` from `t3` `sq2_alias1` where ((`sq2_alias1`.`col_varchar_nokey` <= `alias1`.`col_varchar_key`) and ((`alias2`.`col_varchar_key`) = `sq2_alias1`.`col_varchar_nokey`)))) and (outer_field_is_not_null, (((`where_subselect_19379`.`field1`) = (/* select#3 */ select sum(`t4`.`pk`) AS `sq1_field1` from `t4` join `t1` `sq1_alias2` where (`sq1_alias2`.`col_varchar_key` = `t4`.`col_varchar_key`))) or ((/* select#3 */ select sum(`t4`.`pk`) AS `sq1_field1` from `t4` join `t1` `sq1_alias2` where (`sq1_alias2`.`col_varchar_key` = `t4`.`col_varchar_key`)) is null)), true) and (outer_field_is_not_null, (((`where_subselect_19379`.`field2`) = `alias1`.`col_varchar_nokey`) or (`alias1`.`col_varchar_nokey` is null)), true) and (`alias3`.`col_varchar_key` = `alias2`.`col_varchar_key`) and (`alias3`.`col_varchar_nokey` = `alias2`.`col_varchar_key`)) having ((outer_field_is_not_null, ((/* select#3 */ select sum(`t4`.`pk`) AS `sq1_field1` from `t4` join `t1` `sq1_alias2` where (`sq1_alias2`.`col_varchar_key` = `t4`.`col_varchar_key`))), true) and (outer_field_is_not_null, (`alias1`.`col_varchar_nokey`), true))) is false)" + } + ] /* steps */ + } /* condition_processing */ + }, + { + "substitute_generated_columns": { + } /* substitute_generated_columns */ + }, + { + "table_dependencies": [ + { + "table": "`where_subselect_19379`", + "row_may_be_null": false, + "map_bit": 0, + "depends_on_map_bits": [ + ] /* depends_on_map_bits */ + } + ] /* table_dependencies */ + }, + { + "ref_optimizer_key_uses": [ + ] /* ref_optimizer_key_uses */ + }, + { + "rows_estimation": [ + { + "table": "`where_subselect_19379`", + "rows": 1, + "cost": 1, + "table_type": "system", + "empty": true + } + ] /* rows_estimation */ + } + ] /* steps */, + "empty_result": { + "cause": "no matching row in const table" + } /* empty_result */ + } /* join_optimization */ + }, + { + "join_execution": { + "select#": 1, + "steps": [ + ] /* steps */ + } /* join_execution */ + } + ] /* steps */ +} 0 0 +drop table t1,t2,t3,t4,where_subselect_19379; +drop view view_t4; +# +# BUG#12607524 JSON PARSE ERROR ON SELECT ... FROM ... WHERE .. IN (SUBQUERY) +# +CREATE TABLE t1 ( +col_int_key int(11) DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) ENGINE=MyISAM; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (8,'g'); +CREATE TABLE t2 ( +col_int_key int(11) DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) ENGINE=MyISAM; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (7,'x'); +CREATE TABLE where_subselect_19033 +SELECT +( SELECT col_int_key FROM t2 ) as field1 +FROM t1 +; +SELECT * FROM where_subselect_19033; +field1 +7 +SELECT field1 +FROM where_subselect_19033 +WHERE field1 IN +( SELECT +( SELECT col_int_key FROM t2 ) +FROM t1 +) +; +field1 +7 +SELECT * FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES +SELECT field1 +FROM where_subselect_19033 +WHERE field1 IN +( SELECT +( SELECT col_int_key FROM t2 ) +FROM t1 +) { + "steps": [ + { + "join_preparation": { + "select#": 1, + "steps": [ + { + "join_preparation": { + "select#": 2, + "steps": [ + { + "join_preparation": { + "select#": 3, + "steps": [ + { + "expanded_query": "/* select#3 */ select `t2`.`col_int_key` from `t2`" + } + ] /* steps */ + } /* join_preparation */ + }, + { + "expanded_query": "/* select#2 */ select (/* select#3 */ select `t2`.`col_int_key` from `t2`) from `t1`" + }, + { + "transformation": { + "select#": 2, + "from": "IN (SELECT)", + "to": "EXISTS (CORRELATED SELECT)", + "chosen": true, + "evaluating_constant_where_conditions": [ + ] /* evaluating_constant_where_conditions */ + } /* transformation */ + } + ] /* steps */ + } /* join_preparation */ + }, + { + "expanded_query": "/* select#1 */ select `where_subselect_19033`.`field1` AS `field1` from `where_subselect_19033` where (`where_subselect_19033`.`field1`,(/* select#2 */ select (/* select#3 */ select `t2`.`col_int_key` from `t2`) from `t1` where ((`where_subselect_19033`.`field1`) = (/* select#3 */ select `t2`.`col_int_key` from `t2`))))" + } + ] /* steps */ + } /* join_preparation */ + }, + { + "join_optimization": { + "select#": 1, + "steps": [ + { + "condition_processing": { + "condition": "WHERE", + "original_condition": "(`where_subselect_19033`.`field1`,(/* select#2 */ select (/* select#3 */ select `t2`.`col_int_key` from `t2`) from `t1` where ((`where_subselect_19033`.`field1`) = (/* select#3 */ select `t2`.`col_int_key` from `t2`))))", + "steps": [ + { + "transformation": "equality_propagation", + "subselect_evaluation": [ + ] /* subselect_evaluation */, + "resulting_condition": "(`where_subselect_19033`.`field1`,(/* select#2 */ select (/* select#3 */ select `t2`.`col_int_key` from `t2`) from `t1` where ((`where_subselect_19033`.`field1`) = (/* select#3 */ select `t2`.`col_int_key` from `t2`))))" + }, + { + "transformation": "constant_propagation", + "subselect_evaluation": [ + ] /* subselect_evaluation */, + "resulting_condition": "(`where_subselect_19033`.`field1`,(/* select#2 */ select (/* select#3 */ select `t2`.`col_int_key` from `t2`) from `t1` where ((`where_subselect_19033`.`field1`) = (/* select#3 */ select `t2`.`col_int_key` from `t2`))))" + }, + { + "transformation": "trivial_condition_removal", + "subselect_evaluation": [ + ] /* subselect_evaluation */, + "resulting_condition": "(`where_subselect_19033`.`field1`,(/* select#2 */ select (/* select#3 */ select `t2`.`col_int_key` from `t2`) from `t1` where ((`where_subselect_19033`.`field1`) = (/* select#3 */ select `t2`.`col_int_key` from `t2`))))" + } + ] /* steps */ + } /* condition_processing */ + }, + { + "substitute_generated_columns": { + } /* substitute_generated_columns */ + }, + { + "table_dependencies": [ + { + "table": "`where_subselect_19033`", + "row_may_be_null": false, + "map_bit": 0, + "depends_on_map_bits": [ + ] /* depends_on_map_bits */ + } + ] /* table_dependencies */ + }, + { + "ref_optimizer_key_uses": [ + ] /* ref_optimizer_key_uses */ + }, + { + "rows_estimation": [ + { + "table": "`where_subselect_19033`", + "rows": 1, + "cost": 1, + "table_type": "system", + "empty": false + } + ] /* rows_estimation */ + }, + { + "subselect_execution": { + "select#": 2, + "steps": [ + { + "join_optimization": { + "select#": 2, + "steps": [ + { + "condition_processing": { + "condition": "WHERE", + "original_condition": "(('7') = (/* select#3 */ select `t2`.`col_int_key` from `t2`))", + "steps": [ + { + "transformation": "equality_propagation", + "subselect_evaluation": [ + ] /* subselect_evaluation */, + "resulting_condition": "(('7') = (/* select#3 */ select `t2`.`col_int_key` from `t2`))" + }, + { + "transformation": "constant_propagation", + "subselect_evaluation": [ + ] /* subselect_evaluation */, + "resulting_condition": "(('7') = (/* select#3 */ select `t2`.`col_int_key` from `t2`))" + }, + { + "transformation": "trivial_condition_removal", + "subselect_evaluation": [ + ] /* subselect_evaluation */, + "resulting_condition": "(('7') = (/* select#3 */ select `t2`.`col_int_key` from `t2`))" + } + ] /* steps */ + } /* condition_processing */ + }, + { + "substitute_generated_columns": { + } /* substitute_generated_columns */ + }, + { + "table_dependencies": [ + { + "table": "`t1`", + "row_may_be_null": false, + "map_bit": 0, + "depends_on_map_bits": [ + ] /* depends_on_map_bits */ + } + ] /* table_dependencies */ + }, + { + "ref_optimizer_key_uses": [ + ] /* ref_optimizer_key_uses */ + }, + { + "rows_estimation": [ + { + "table": "`t1`", + "rows": 1, + "cost": 1, + "table_type": "system", + "empty": false + } + ] /* rows_estimation */ + }, + { + "attaching_conditions_to_tables": { + "original_condition": "(('7') = (/* select#3 */ select `t2`.`col_int_key` from `t2`))", + "attached_conditions_computation": [ + ] /* attached_conditions_computation */, + "attached_conditions_summary": [ + ] /* attached_conditions_summary */ + } /* attaching_conditions_to_tables */ + }, + { + "refine_plan": [ + ] /* refine_plan */ + } + ] /* steps */ + } /* join_optimization */ + }, + { + "join_optimization": { + "select#": 3, + "steps": [ + { + "table_dependencies": [ + { + "table": "`t2`", + "row_may_be_null": false, + "map_bit": 0, + "depends_on_map_bits": [ + ] /* depends_on_map_bits */ + } + ] /* table_dependencies */ + }, + { + "rows_estimation": [ + { + "table": "`t2`", + "rows": 1, + "cost": 1, + "table_type": "system", + "empty": false + } + ] /* rows_estimation */ + }, + { + "attaching_conditions_to_tables": { + "original_condition": null, + "attached_conditions_computation": [ + ] /* attached_conditions_computation */, + "attached_conditions_summary": [ + ] /* attached_conditions_summary */ + } /* attaching_conditions_to_tables */ + }, + { + "refine_plan": [ + ] /* refine_plan */ + } + ] /* steps */ + } /* join_optimization */ + }, + { + "join_execution": { + "select#": 2, + "steps": [ + { + "subselect_execution": { + "select#": 3, + "steps": [ + { + "join_execution": { + "select#": 3, + "steps": [ + ] /* steps */ + } /* join_execution */ + } + ] /* steps */ + } /* subselect_execution */ + } + ] /* steps */ + } /* join_execution */ + } + ] /* steps */ + } /* subselect_execution */ + }, + { + "condition_on_constant_tables": "('7',(/* select#2 */ select (/* select#3 */ select '7' from dual) from dual where (('7') = (/* select#3 */ select '7' from dual))))", + "condition_value": true + }, + { + "attaching_conditions_to_tables": { + "original_condition": "('7',(/* select#2 */ select (/* select#3 */ select '7' from dual) from dual where (('7') = (/* select#3 */ select '7' from dual))))", + "attached_conditions_computation": [ + ] /* attached_conditions_computation */, + "attached_conditions_summary": [ + ] /* attached_conditions_summary */ + } /* attaching_conditions_to_tables */ + }, + { + "refine_plan": [ + ] /* refine_plan */ + } + ] /* steps */ + } /* join_optimization */ + }, + { + "join_execution": { + "select#": 1, + "steps": [ + ] /* steps */ + } /* join_execution */ + } + ] /* steps */ +} 0 0 +DROP TABLE where_subselect_19033,t1,t2; + +# BUG#12612201 - SEGFAULT IN +# SUBSELECT_UNIQUESUBQUERY_ENGINE::PRINT WITH OPTIMIZER TRACE + +CREATE TABLE t1 ( +col_int_key int(11) DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t2 ( +pk int(11) NOT NULL AUTO_INCREMENT, +col_int_key int(11) DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +PRIMARY KEY (pk) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (1,4,'v','v'),(20,5,'r','r'); +CREATE TABLE t3 ( +col_int_key int(11) DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t3 VALUES (NULL,'j','j'),(8,'c','c'); +CREATE TABLE where_updatedelete_20769 select count( alias2 . col_varchar_key ) as field1 +from ( +(select sq1_alias1 . * +from ( t3 as sq1_alias1 +straight_join t1 as sq1_alias2 +on (sq1_alias2 . col_varchar_key = sq1_alias1 . col_varchar_key) +) +where sq1_alias1 . col_int_key in ( +select c_sq1_alias1 . pk as c_sq1_field1 +from t2 as c_sq1_alias1 +) +) as alias1 +left outer join t1 as alias2 +on (alias2 . col_varchar_key = alias1 . col_varchar_key ) +) +where ( alias2 . col_varchar_key in ( +select sq2_alias1 . col_varchar_nokey as sq2_field1 +from t2 as sq2_alias1 +where sq2_alias1 . col_int_key in ( +select distinct c_sq2_alias1 . col_int_key as c_sq2_field1 +from t3 as c_sq2_alias1 +) +) ) +or alias1 . col_int_key = 2 +and alias2 . col_varchar_nokey <= alias1 . col_varchar_nokey +order by alias1 . col_varchar_key , field1 +; +UPDATE where_updatedelete_20769 SET field1 = ( select count( alias2 . col_varchar_key ) as field1 +from ( +(select sq1_alias1 . * +from ( t3 as sq1_alias1 +straight_join t1 as sq1_alias2 +on (sq1_alias2 . col_varchar_key = sq1_alias1 . col_varchar_key) +) +where sq1_alias1 . col_int_key in ( +select c_sq1_alias1 . pk as c_sq1_field1 +from t2 as c_sq1_alias1 +) +) as alias1 +left outer join t1 as alias2 +on (alias2 . col_varchar_key = alias1 . col_varchar_key ) +) +where ( alias2 . col_varchar_key in ( +select sq2_alias1 . col_varchar_nokey as sq2_field1 +from t2 as sq2_alias1 +where sq2_alias1 . col_int_key in ( +select distinct c_sq2_alias1 . col_int_key as c_sq2_field1 +from t3 as c_sq2_alias1 +) +) ) +or alias1 . col_int_key = 2 +and alias2 . col_varchar_nokey <= alias1 . col_varchar_nokey +order by alias1 . col_varchar_key , field1 + ); +DROP TABLE where_updatedelete_20769; +DROP TABLE t1,t2,t3; + +# BUG#12710761 - INVALID JSON TRACE ON SUBQUERY IN IN-CLAUSE + +CREATE TABLE t1 (col_int_key int, KEY col_int_key (col_int_key)); +INSERT INTO t1 VALUES (0),(8),(1),(8); +CREATE TABLE where_subselect_20070 +SELECT table2 .col_int_key AS field1, +( SELECT COUNT( col_int_key ) +FROM t1 +) +FROM t1 AS table1 +JOIN t1 AS table2 +ON table2 .col_int_key = table1 .col_int_key; +SELECT * +FROM where_subselect_20070 +WHERE (field1, ( SELECT COUNT( col_int_key ) FROM t1 )) IN ( +SELECT table2 .col_int_key AS field1, +( SELECT COUNT( col_int_key ) +FROM t1 +) +FROM t1 AS table1 +JOIN t1 AS table2 +ON table2 .col_int_key = table1 .col_int_key +); +field1 ( SELECT COUNT( col_int_key ) +FROM t1 +) +0 4 +1 4 +8 4 +8 4 +8 4 +8 4 +select * from information_schema.optimizer_trace; +QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES +SELECT * +FROM where_subselect_20070 +WHERE (field1, ( SELECT COUNT( col_int_key ) FROM t1 )) IN ( +SELECT table2 .col_int_key AS field1, +( SELECT COUNT( col_int_key ) +FROM t1 +) +FROM t1 AS table1 +JOIN t1 AS table2 +ON table2 .col_int_key = table1 .col_int_key +) { + "steps": [ + { + "join_preparation": { + "select#": 1, + "steps": [ + { + "join_preparation": { + "select#": 3, + "steps": [ + { + "join_preparation": { + "select#": 4, + "steps": [ + { + "expanded_query": "/* select#4 */ select count(`t1`.`col_int_key`) from `t1`" + } + ] /* steps */ + } /* join_preparation */ + }, + { + "expanded_query": "/* select#3 */ select `table2`.`col_int_key` AS `field1`,(/* select#4 */ select count(`t1`.`col_int_key`) from `t1`) from (`t1` `table1` join `t1` `table2` on((`table2`.`col_int_key` = `table1`.`col_int_key`)))" + }, + { + "join_preparation": { + "select#": 2, + "steps": [ + { + "expanded_query": "/* select#2 */ select count(`t1`.`col_int_key`) from `t1`" + } + ] /* steps */ + } /* join_preparation */ + }, + { + "transformation": { + "select#": 3, + "from": "IN (SELECT)", + "to": "EXISTS (CORRELATED SELECT)", + "chosen": true, + "evaluating_constant_where_conditions": [ + ] /* evaluating_constant_where_conditions */ + } /* transformation */ + } + ] /* steps */ + } /* join_preparation */ + }, + { + "expanded_query": "/* select#1 */ select `where_subselect_20070`.`field1` AS `field1`,`where_subselect_20070`.`( SELECT COUNT( col_int_key )\nFROM t1\n)` AS `( SELECT COUNT( col_int_key )\nFROM t1\n)` from `where_subselect_20070` where ((`where_subselect_20070`.`field1`,(/* select#2 */ select count(`t1`.`col_int_key`) from `t1`)),(/* select#3 */ select `table2`.`col_int_key` AS `field1`,(/* select#4 */ select count(`t1`.`col_int_key`) from `t1`) from (`t1` `table1` join `t1` `table2` on((`table2`.`col_int_key` = `table1`.`col_int_key`))) where (((`where_subselect_20070`.`field1`) = `table2`.`col_int_key`) and (((/* select#2 */ select count(`t1`.`col_int_key`) from `t1`)) = (/* select#4 */ select count(`t1`.`col_int_key`) from `t1`)))))" + }, + { + "transformations_to_nested_joins": { + "transformations": [ + "JOIN_condition_to_WHERE", + "parenthesis_removal" + ] /* transformations */, + "expanded_query": "/* select#3 */ select `table2`.`col_int_key` AS `field1`,(/* select#4 */ select count(`t1`.`col_int_key`) from `t1`) from `t1` `table1` join `t1` `table2` where (((`where_subselect_20070`.`field1`) = `table2`.`col_int_key`) and (((/* select#2 */ select count(`t1`.`col_int_key`) from `t1`)) = (/* select#4 */ select count(`t1`.`col_int_key`) from `t1`)) and (`table2`.`col_int_key` = `table1`.`col_int_key`))" + } /* transformations_to_nested_joins */ + } + ] /* steps */ + } /* join_preparation */ + }, + { + "join_optimization": { + "select#": 1, + "steps": [ + { + "condition_processing": { + "condition": "WHERE", + "original_condition": "((`where_subselect_20070`.`field1`,(/* select#2 */ select count(`t1`.`col_int_key`) from `t1`)),(/* select#3 */ select `table2`.`col_int_key` AS `field1`,(/* select#4 */ select count(`t1`.`col_int_key`) from `t1`) from `t1` `table1` join `t1` `table2` where (((`where_subselect_20070`.`field1`) = `table2`.`col_int_key`) and (((/* select#2 */ select count(`t1`.`col_int_key`) from `t1`)) = (/* select#4 */ select count(`t1`.`col_int_key`) from `t1`)) and (`table2`.`col_int_key` = `table1`.`col_int_key`))))", + "steps": [ + { + "transformation": "equality_propagation", + "subselect_evaluation": [ + ] /* subselect_evaluation */, + "resulting_condition": "((`where_subselect_20070`.`field1`,(/* select#2 */ select count(`t1`.`col_int_key`) from `t1`)),(/* select#3 */ select `table2`.`col_int_key` AS `field1`,(/* select#4 */ select count(`t1`.`col_int_key`) from `t1`) from `t1` `table1` join `t1` `table2` where (((`where_subselect_20070`.`field1`) = `table2`.`col_int_key`) and (((/* select#2 */ select count(`t1`.`col_int_key`) from `t1`)) = (/* select#4 */ select count(`t1`.`col_int_key`) from `t1`)) and (`table2`.`col_int_key` = `table1`.`col_int_key`))))" + }, + { + "transformation": "constant_propagation", + "subselect_evaluation": [ + ] /* subselect_evaluation */, + "resulting_condition": "((`where_subselect_20070`.`field1`,(/* select#2 */ select count(`t1`.`col_int_key`) from `t1`)),(/* select#3 */ select `table2`.`col_int_key` AS `field1`,(/* select#4 */ select count(`t1`.`col_int_key`) from `t1`) from `t1` `table1` join `t1` `table2` where (((`where_subselect_20070`.`field1`) = `table2`.`col_int_key`) and (((/* select#2 */ select count(`t1`.`col_int_key`) from `t1`)) = (/* select#4 */ select count(`t1`.`col_int_key`) from `t1`)) and (`table2`.`col_int_key` = `table1`.`col_int_key`))))" + }, + { + "transformation": "trivial_condition_removal", + "subselect_evaluation": [ + ] /* subselect_evaluation */, + "resulting_condition": "((`where_subselect_20070`.`field1`,(/* select#2 */ select count(`t1`.`col_int_key`) from `t1`)),(/* select#3 */ select `table2`.`col_int_key` AS `field1`,(/* select#4 */ select count(`t1`.`col_int_key`) from `t1`) from `t1` `table1` join `t1` `table2` where (((`where_subselect_20070`.`field1`) = `table2`.`col_int_key`) and (((/* select#2 */ select count(`t1`.`col_int_key`) from `t1`)) = (/* select#4 */ select count(`t1`.`col_int_key`) from `t1`)) and (`table2`.`col_int_key` = `table1`.`col_int_key`))))" + } + ] /* steps */ + } /* condition_processing */ + }, + { + "substitute_generated_columns": { + } /* substitute_generated_columns */ + }, + { + "table_dependencies": [ + { + "table": "`where_subselect_20070`", + "row_may_be_null": false, + "map_bit": 0, + "depends_on_map_bits": [ + ] /* depends_on_map_bits */ + } + ] /* table_dependencies */ + }, + { + "ref_optimizer_key_uses": [ + ] /* ref_optimizer_key_uses */ + }, + { + "rows_estimation": [ + { + "table": "`where_subselect_20070`", + "table_scan": { + "rows": 6, + "cost": 0.504761 + } /* table_scan */ + } + ] /* rows_estimation */ + }, + { + "considered_execution_plans": [ + { + "plan_prefix": [ + ] /* plan_prefix */, + "table": "`where_subselect_20070`", + "best_access_path": { + "considered_access_paths": [ + { + "rows_to_scan": 6, + "access_type": "scan", + "resulting_rows": 6, + "cost": 1.10476, + "chosen": true + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 100, + "rows_for_plan": 6, + "cost_for_plan": 1.10476, + "chosen": true + } + ] /* considered_execution_plans */ + }, + { + "attaching_conditions_to_tables": { + "original_condition": "((`where_subselect_20070`.`field1`,(/* select#2 */ select count(`t1`.`col_int_key`) from `t1`)),(/* select#3 */ select `table2`.`col_int_key` AS `field1`,(/* select#4 */ select count(`t1`.`col_int_key`) from `t1`) from `t1` `table1` join `t1` `table2` where (((`where_subselect_20070`.`field1`) = `table2`.`col_int_key`) and (((/* select#2 */ select count(`t1`.`col_int_key`) from `t1`)) = (/* select#4 */ select count(`t1`.`col_int_key`) from `t1`)) and (`table2`.`col_int_key` = `table1`.`col_int_key`))))", + "attached_conditions_computation": [ + ] /* attached_conditions_computation */, + "attached_conditions_summary": [ + { + "table": "`where_subselect_20070`", + "attached": "((`where_subselect_20070`.`field1`,(/* select#2 */ select count(`t1`.`col_int_key`) from `t1`)),(/* select#3 */ select `table2`.`col_int_key` AS `field1`,(/* select#4 */ select count(`t1`.`col_int_key`) from `t1`) from `t1` `table1` join `t1` `table2` where (((`where_subselect_20070`.`field1`) = `table2`.`col_int_key`) and (((/* select#2 */ select count(`t1`.`col_int_key`) from `t1`)) = (/* select#4 */ select count(`t1`.`col_int_key`) from `t1`)) and (`table2`.`col_int_key` = `table1`.`col_int_key`))))" + } + ] /* attached_conditions_summary */ + } /* attaching_conditions_to_tables */ + }, + { + "finalizing_table_conditions": [ + { + "table": "`where_subselect_20070`", + "original_table_condition": "((`where_subselect_20070`.`field1`,(/* select#2 */ select count(`t1`.`col_int_key`) from `t1`)),(/* select#3 */ select `table2`.`col_int_key` AS `field1`,(/* select#4 */ select count(`t1`.`col_int_key`) from `t1`) from `t1` `table1` join `t1` `table2` where (((`where_subselect_20070`.`field1`) = `table2`.`col_int_key`) and (((/* select#2 */ select count(`t1`.`col_int_key`) from `t1`)) = (/* select#4 */ select count(`t1`.`col_int_key`) from `t1`)) and (`table2`.`col_int_key` = `table1`.`col_int_key`))))", + "final_table_condition ": "((`where_subselect_20070`.`field1`,(/* select#2 */ select count(`t1`.`col_int_key`) from `t1`)),(/* select#3 */ select `table2`.`col_int_key` AS `field1`,(/* select#4 */ select count(`t1`.`col_int_key`) from `t1`) from `t1` `table1` join `t1` `table2` where (((`where_subselect_20070`.`field1`) = `table2`.`col_int_key`) and (((/* select#2 */ select count(`t1`.`col_int_key`) from `t1`)) = (/* select#4 */ select count(`t1`.`col_int_key`) from `t1`)) and (`table2`.`col_int_key` = `table1`.`col_int_key`))))" + } + ] /* finalizing_table_conditions */ + }, + { + "refine_plan": [ + { + "table": "`where_subselect_20070`" + } + ] /* refine_plan */ + } + ] /* steps */ + } /* join_optimization */ + }, + { + "join_optimization": { + "select#": 3, + "steps": [ + { + "condition_processing": { + "condition": "WHERE", + "original_condition": "(((`where_subselect_20070`.`field1`) = `table2`.`col_int_key`) and (((/* select#2 */ select count(`t1`.`col_int_key`) from `t1`)) = (/* select#4 */ select count(`t1`.`col_int_key`) from `t1`)) and (`table2`.`col_int_key` = `table1`.`col_int_key`))", + "steps": [ + { + "transformation": "equality_propagation", + "subselect_evaluation": [ + ] /* subselect_evaluation */, + "resulting_condition": "(((`where_subselect_20070`.`field1`) = `table2`.`col_int_key`) and (((/* select#2 */ select count(`t1`.`col_int_key`) from `t1`)) = (/* select#4 */ select count(`t1`.`col_int_key`) from `t1`)) and multiple equal(`table2`.`col_int_key`, `table1`.`col_int_key`))" + }, + { + "transformation": "constant_propagation", + "subselect_evaluation": [ + ] /* subselect_evaluation */, + "resulting_condition": "(((`where_subselect_20070`.`field1`) = `table2`.`col_int_key`) and (((/* select#2 */ select count(`t1`.`col_int_key`) from `t1`)) = (/* select#4 */ select count(`t1`.`col_int_key`) from `t1`)) and multiple equal(`table2`.`col_int_key`, `table1`.`col_int_key`))" + }, + { + "transformation": "trivial_condition_removal", + "subselect_evaluation": [ + ] /* subselect_evaluation */, + "resulting_condition": "(((`where_subselect_20070`.`field1`) = `table2`.`col_int_key`) and (((/* select#2 */ select count(`t1`.`col_int_key`) from `t1`)) = (/* select#4 */ select count(`t1`.`col_int_key`) from `t1`)) and multiple equal(`table2`.`col_int_key`, `table1`.`col_int_key`))" + } + ] /* steps */ + } /* condition_processing */ + }, + { + "substitute_generated_columns": { + } /* substitute_generated_columns */ + }, + { + "table_dependencies": [ + { + "table": "`t1` `table1`", + "row_may_be_null": false, + "map_bit": 0, + "depends_on_map_bits": [ + ] /* depends_on_map_bits */ + }, + { + "table": "`t1` `table2`", + "row_may_be_null": false, + "map_bit": 1, + "depends_on_map_bits": [ + ] /* depends_on_map_bits */ + } + ] /* table_dependencies */ + }, + { + "ref_optimizer_key_uses": [ + { + "table": "`t1` `table1`", + "field": "col_int_key", + "equals": "(`where_subselect_20070`.`field1`)", + "null_rejecting": true + }, + { + "table": "`t1` `table1`", + "field": "col_int_key", + "equals": "`table2`.`col_int_key`", + "null_rejecting": true + }, + { + "table": "`t1` `table2`", + "field": "col_int_key", + "equals": "(`where_subselect_20070`.`field1`)", + "null_rejecting": true + }, + { + "table": "`t1` `table2`", + "field": "col_int_key", + "equals": "`table1`.`col_int_key`", + "null_rejecting": true + } + ] /* ref_optimizer_key_uses */ + }, + { + "rows_estimation": [ + { + "table": "`t1` `table1`", + "table_scan": { + "rows": 4, + "cost": 0.501709 + } /* table_scan */ + }, + { + "table": "`t1` `table2`", + "table_scan": { + "rows": 4, + "cost": 0.501709 + } /* table_scan */ + } + ] /* rows_estimation */ + }, + { + "considered_execution_plans": [ + { + "plan_prefix": [ + ] /* plan_prefix */, + "table": "`t1` `table1`", + "best_access_path": { + "considered_access_paths": [ + { + "access_type": "ref", + "index": "col_int_key", + "rows": 2, + "cost": 0.455814, + "chosen": true + }, + { + "access_type": "scan", + "cost": 0.901709, + "rows": 4, + "chosen": false, + "cause": "cost" + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 100, + "rows_for_plan": 2, + "cost_for_plan": 0.455814, + "rest_of_plan": [ + { + "plan_prefix": [ + "`t1` `table1`" + ] /* plan_prefix */, + "table": "`t1` `table2`", + "best_access_path": { + "considered_access_paths": [ + { + "access_type": "ref", + "index": "col_int_key", + "rows": 2, + "cost": 0.911628, + "chosen": true + }, + { + "rows_to_scan": 4, + "filtering_effect": [ + ] /* filtering_effect */, + "final_filtering_effect": 1, + "access_type": "scan", + "using_join_cache": true, + "buffers_needed": 1, + "resulting_rows": 4, + "cost": 1.30173, + "chosen": false + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 100, + "rows_for_plan": 4, + "cost_for_plan": 1.36744, + "chosen": true + } + ] /* rest_of_plan */ + }, + { + "plan_prefix": [ + ] /* plan_prefix */, + "table": "`t1` `table2`", + "best_access_path": { + "considered_access_paths": [ + { + "access_type": "ref", + "index": "col_int_key", + "rows": 2, + "cost": 0.455814, + "chosen": true + }, + { + "access_type": "scan", + "cost": 0.901709, + "rows": 4, + "chosen": false, + "cause": "cost" + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 100, + "rows_for_plan": 2, + "cost_for_plan": 0.455814, + "rest_of_plan": [ + { + "plan_prefix": [ + "`t1` `table2`" + ] /* plan_prefix */, + "table": "`t1` `table1`", + "best_access_path": { + "considered_access_paths": [ + { + "access_type": "ref", + "index": "col_int_key", + "rows": 2, + "cost": 0.911628, + "chosen": true + }, + { + "rows_to_scan": 4, + "filtering_effect": [ + ] /* filtering_effect */, + "final_filtering_effect": 1, + "access_type": "scan", + "using_join_cache": true, + "buffers_needed": 1, + "resulting_rows": 4, + "cost": 1.30173, + "chosen": false + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 100, + "rows_for_plan": 4, + "cost_for_plan": 1.36744, + "pruned_by_cost": true + } + ] /* rest_of_plan */ + } + ] /* considered_execution_plans */ + }, + { + "attaching_conditions_to_tables": { + "original_condition": "((`table2`.`col_int_key` = `table1`.`col_int_key`) and ((`where_subselect_20070`.`field1`) = `table1`.`col_int_key`) and (((/* select#2 */ select count(`t1`.`col_int_key`) from `t1`)) = (/* select#4 */ select count(`t1`.`col_int_key`) from `t1`)))", + "attached_conditions_computation": [ + ] /* attached_conditions_computation */, + "attached_conditions_summary": [ + { + "table": "`t1` `table1`", + "attached": "(((`where_subselect_20070`.`field1`) = `table1`.`col_int_key`) and (((/* select#2 */ select count(`t1`.`col_int_key`) from `t1`)) = (/* select#4 */ select count(`t1`.`col_int_key`) from `t1`)))" + }, + { + "table": "`t1` `table2`", + "attached": "(`table2`.`col_int_key` = `table1`.`col_int_key`)" + } + ] /* attached_conditions_summary */ + } /* attaching_conditions_to_tables */ + }, + { + "finalizing_table_conditions": [ + { + "table": "`t1` `table1`", + "original_table_condition": "(((`where_subselect_20070`.`field1`) = `table1`.`col_int_key`) and (((/* select#2 */ select count(`t1`.`col_int_key`) from `t1`)) = (/* select#4 */ select count(`t1`.`col_int_key`) from `t1`)))", + "final_table_condition ": "(((/* select#2 */ select count(`t1`.`col_int_key`) from `t1`)) = (/* select#4 */ select count(`t1`.`col_int_key`) from `t1`))" + }, + { + "table": "`t1` `table2`", + "original_table_condition": "(`table2`.`col_int_key` = `table1`.`col_int_key`)", + "final_table_condition ": "(`table2`.`col_int_key` = `table1`.`col_int_key`)" + } + ] /* finalizing_table_conditions */ + }, + { + "refine_plan": [ + { + "table": "`t1` `table1`" + }, + { + "table": "`t1` `table2`" + } + ] /* refine_plan */ + } + ] /* steps */ + } /* join_optimization */ + }, + { + "join_optimization": { + "select#": 4, + "steps": [ + { + "table_dependencies": [ + { + "table": "`t1`", + "row_may_be_null": false, + "map_bit": 0, + "depends_on_map_bits": [ + ] /* depends_on_map_bits */ + } + ] /* table_dependencies */ + }, + { + "rows_estimation": [ + { + "table": "`t1`", + "table_scan": { + "rows": 4, + "cost": 0.501709 + } /* table_scan */ + } + ] /* rows_estimation */ + }, + { + "considered_execution_plans": [ + { + "plan_prefix": [ + ] /* plan_prefix */, + "table": "`t1`", + "best_access_path": { + "considered_access_paths": [ + { + "rows_to_scan": 4, + "access_type": "scan", + "resulting_rows": 4, + "cost": 0.901709, + "chosen": true + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 100, + "rows_for_plan": 4, + "cost_for_plan": 0.901709, + "chosen": true + } + ] /* considered_execution_plans */ + }, + { + "attaching_conditions_to_tables": { + "original_condition": null, + "attached_conditions_computation": [ + ] /* attached_conditions_computation */, + "attached_conditions_summary": [ + { + "table": "`t1`", + "attached": null + } + ] /* attached_conditions_summary */ + } /* attaching_conditions_to_tables */ + }, + { + "optimizing_distinct_group_by_order_by": { + } /* optimizing_distinct_group_by_order_by */ + }, + { + "finalizing_table_conditions": [ + ] /* finalizing_table_conditions */ + }, + { + "refine_plan": [ + { + "table": "`t1`" + } + ] /* refine_plan */ + }, + { + "considering_tmp_tables": [ + ] /* considering_tmp_tables */ + } + ] /* steps */ + } /* join_optimization */ + }, + { + "join_optimization": { + "select#": 2, + "steps": [ + { + "table_dependencies": [ + { + "table": "`t1`", + "row_may_be_null": false, + "map_bit": 0, + "depends_on_map_bits": [ + ] /* depends_on_map_bits */ + } + ] /* table_dependencies */ + }, + { + "rows_estimation": [ + { + "table": "`t1`", + "table_scan": { + "rows": 4, + "cost": 0.501709 + } /* table_scan */ + } + ] /* rows_estimation */ + }, + { + "considered_execution_plans": [ + { + "plan_prefix": [ + ] /* plan_prefix */, + "table": "`t1`", + "best_access_path": { + "considered_access_paths": [ + { + "rows_to_scan": 4, + "access_type": "scan", + "resulting_rows": 4, + "cost": 0.901709, + "chosen": true + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 100, + "rows_for_plan": 4, + "cost_for_plan": 0.901709, + "chosen": true + } + ] /* considered_execution_plans */ + }, + { + "attaching_conditions_to_tables": { + "original_condition": null, + "attached_conditions_computation": [ + ] /* attached_conditions_computation */, + "attached_conditions_summary": [ + { + "table": "`t1`", + "attached": null + } + ] /* attached_conditions_summary */ + } /* attaching_conditions_to_tables */ + }, + { + "optimizing_distinct_group_by_order_by": { + } /* optimizing_distinct_group_by_order_by */ + }, + { + "finalizing_table_conditions": [ + ] /* finalizing_table_conditions */ + }, + { + "refine_plan": [ + { + "table": "`t1`" + } + ] /* refine_plan */ + }, + { + "considering_tmp_tables": [ + ] /* considering_tmp_tables */ + } + ] /* steps */ + } /* join_optimization */ + }, + { + "join_execution": { + "select#": 1, + "steps": [ + { + "subselect_execution": { + "select#": 2, + "steps": [ + { + "join_execution": { + "select#": 2, + "steps": [ + ] /* steps */ + } /* join_execution */ + } + ] /* steps */ + } /* subselect_execution */ + }, + { + "subselect_execution": { + "select#": 2, + "steps": [ + ] /* steps */ + } /* subselect_execution */ + }, + { + "subselect_execution": { + "select#": 3, + "steps": [ + { + "join_execution": { + "select#": 3, + "steps": [ + { + "subselect_execution": { + "select#": 4, + "steps": [ + { + "join_execution": { + "select#": 4, + "steps": [ + ] /* steps */ + } /* join_execution */ + } + ] /* steps */ + } /* subselect_execution */ + } + ] /* steps */ + } /* join_execution */ + } + ] /* steps */ + } /* subselect_execution */ + }, + { + "subselect_execution": { + "select#": 2, + "steps": [ + ] /* steps */ + } /* subselect_execution */ + }, + { + "subselect_execution": { + "select#": 2, + "steps": [ + ] /* steps */ + } /* subselect_execution */ + }, + { + "subselect_execution": { + "select#": 3, + "steps": [ + { + "join_execution": { + "select#": 3, + "steps": [ + { + "subselect_execution": { + "select#": 4, + "steps": [ + ] /* steps */ + } /* subselect_execution */ + } + ] /* steps */ + } /* join_execution */ + } + ] /* steps */ + } /* subselect_execution */ + }, + { + "subselect_execution": { + "select#": 2, + "steps": [ + ] /* steps */ + } /* subselect_execution */ + }, + { + "subselect_execution": { + "select#": 2, + "steps": [ + ] /* steps */ + } /* subselect_execution */ + }, + { + "subselect_execution": { + "select#": 3, + "steps": [ + { + "join_execution": { + "select#": 3, + "steps": [ + { + "subselect_execution": { + "select#": 4, + "steps": [ + ] /* steps */ + } /* subselect_execution */ + } + ] /* steps */ + } /* join_execution */ + } + ] /* steps */ + } /* subselect_execution */ + }, + { + "subselect_execution": { + "select#": 2, + "steps": [ + ] /* steps */ + } /* subselect_execution */ + }, + { + "subselect_execution": { + "select#": 2, + "steps": [ + ] /* steps */ + } /* subselect_execution */ + }, + { + "subselect_execution": { + "select#": 3, + "steps": [ + { + "join_execution": { + "select#": 3, + "steps": [ + { + "subselect_execution": { + "select#": 4, + "steps": [ + ] /* steps */ + } /* subselect_execution */ + } + ] /* steps */ + } /* join_execution */ + } + ] /* steps */ + } /* subselect_execution */ + }, + { + "subselect_execution": { + "select#": 2, + "steps": [ + ] /* steps */ + } /* subselect_execution */ + }, + { + "subselect_execution": { + "select#": 2, + "steps": [ + ] /* steps */ + } /* subselect_execution */ + }, + { + "subselect_execution": { + "select#": 3, + "steps": [ + { + "join_execution": { + "select#": 3, + "steps": [ + { + "subselect_execution": { + "select#": 4, + "steps": [ + ] /* steps */ + } /* subselect_execution */ + } + ] /* steps */ + } /* join_execution */ + } + ] /* steps */ + } /* subselect_execution */ + }, + { + "subselect_execution": { + "select#": 2, + "steps": [ + ] /* steps */ + } /* subselect_execution */ + }, + { + "subselect_execution": { + "select#": 2, + "steps": [ + ] /* steps */ + } /* subselect_execution */ + }, + { + "subselect_execution": { + "select#": 3, + "steps": [ + { + "join_execution": { + "select#": 3, + "steps": [ + { + "subselect_execution": { + "select#": 4, + "steps": [ + ] /* steps */ + } /* subselect_execution */ + } + ] /* steps */ + } /* join_execution */ + } + ] /* steps */ + } /* subselect_execution */ + } + ] /* steps */ + } /* join_execution */ + } + ] /* steps */ +} 0 0 +DROP TABLE where_subselect_20070,t1; +# +# Bug#13430443 - ASSERTION `NEW_TYPE[0] != 'U'' FAILED. WHEN +# OPTIMIZER_TRACE IS ENABLED +# +CREATE TABLE t1 +(a INT,b INT,c INT, KEY(a),KEY (a,c)) ENGINE=INNODB; +SELECT 1 FROM t1 WHERE 1 LIKE +(SELECT a FROM t1 WHERE a = 1 ORDER BY c); +1 +SELECT * FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES +SELECT 1 FROM t1 WHERE 1 LIKE +(SELECT a FROM t1 WHERE a = 1 ORDER BY c) { + "steps": [ + { + "join_preparation": { + "select#": 1, + "steps": [ + { + "join_preparation": { + "select#": 2, + "steps": [ + { + "transformations_to_subquery": [ + "removed_ordering" + ] /* transformations_to_subquery */ + }, + { + "expanded_query": "/* select#2 */ select `t1`.`a` from `t1` where (`t1`.`a` = 1)" + } + ] /* steps */ + } /* join_preparation */ + }, + { + "expanded_query": "/* select#1 */ select 1 AS `1` from `t1` where (1 like (/* select#2 */ select `t1`.`a` from `t1` where (`t1`.`a` = 1)))" + } + ] /* steps */ + } /* join_preparation */ + }, + { + "join_optimization": { + "select#": 1, + "steps": [ + { + "condition_processing": { + "condition": "WHERE", + "original_condition": "(1 like (/* select#2 */ select `t1`.`a` from `t1` where (`t1`.`a` = 1)))", + "steps": [ + { + "transformation": "equality_propagation", + "subselect_evaluation": [ + ] /* subselect_evaluation */, + "resulting_condition": "(1 like (/* select#2 */ select `t1`.`a` from `t1` where (`t1`.`a` = 1)))" + }, + { + "transformation": "constant_propagation", + "subselect_evaluation": [ + ] /* subselect_evaluation */, + "resulting_condition": "(1 like (/* select#2 */ select `t1`.`a` from `t1` where (`t1`.`a` = 1)))" + }, + { + "transformation": "trivial_condition_removal", + "subselect_evaluation": [ + { + "subselect_execution": { + "select#": 2, + "steps": [ + { + "join_optimization": { + "select#": 2, + "steps": [ + { + "condition_processing": { + "condition": "WHERE", + "original_condition": "(`t1`.`a` = 1)", + "steps": [ + { + "transformation": "equality_propagation", + "resulting_condition": "multiple equal(1, `t1`.`a`)" + }, + { + "transformation": "constant_propagation", + "resulting_condition": "multiple equal(1, `t1`.`a`)" + }, + { + "transformation": "trivial_condition_removal", + "resulting_condition": "multiple equal(1, `t1`.`a`)" + } + ] /* steps */ + } /* condition_processing */ + }, + { + "substitute_generated_columns": { + } /* substitute_generated_columns */ + }, + { + "table_dependencies": [ + { + "table": "`t1`", + "row_may_be_null": false, + "map_bit": 0, + "depends_on_map_bits": [ + ] /* depends_on_map_bits */ + } + ] /* table_dependencies */ + }, + { + "ref_optimizer_key_uses": [ + { + "table": "`t1`", + "field": "a", + "equals": "1", + "null_rejecting": true + }, + { + "table": "`t1`", + "field": "a", + "equals": "1", + "null_rejecting": true + } + ] /* ref_optimizer_key_uses */ + }, + { + "rows_estimation": [ + { + "table": "`t1`", + "range_analysis": { + "table_scan": { + "rows": 1, + "cost": 2.45 + } /* table_scan */, + "potential_range_indexes": [ + { + "index": "a", + "usable": true, + "key_parts": [ + "a" + ] /* key_parts */ + }, + { + "index": "a_2", + "usable": true, + "key_parts": [ + "a", + "c" + ] /* key_parts */ + } + ] /* potential_range_indexes */, + "best_covering_index_scan": { + "index": "a_2", + "cost": 0.35, + "chosen": true + } /* best_covering_index_scan */, + "setup_range_conditions": [ + ] /* setup_range_conditions */, + "group_index_range": { + "chosen": false, + "cause": "not_group_by_or_distinct" + } /* group_index_range */, + "skip_scan_range": { + "potential_skip_scan_indexes": [ + { + "index": "a", + "usable": false, + "cause": "query_references_nonkey_column" + }, + { + "index": "a_2", + "usable": false, + "cause": "no_range_predicate" + } + ] /* potential_skip_scan_indexes */ + } /* skip_scan_range */, + "analyzing_range_alternatives": { + "range_scan_alternatives": [ + { + "index": "a", + "ranges": [ + "1 <= a <= 1" + ] /* ranges */, + "index_dives_for_eq_ranges": true, + "rowid_ordered": true, + "using_mrr": false, + "index_only": false, + "rows": 1, + "cost": 0.61, + "chosen": false, + "cause": "cost" + }, + { + "index": "a_2", + "ranges": [ + "1 <= a <= 1" + ] /* ranges */, + "index_dives_for_eq_ranges": true, + "rowid_ordered": false, + "using_mrr": false, + "index_only": true, + "rows": 1, + "cost": 0.36, + "chosen": false, + "cause": "cost" + } + ] /* range_scan_alternatives */, + "analyzing_roworder_intersect": { + "usable": false, + "cause": "too_few_roworder_scans" + } /* analyzing_roworder_intersect */ + } /* analyzing_range_alternatives */ + } /* range_analysis */ + } + ] /* rows_estimation */ + }, + { + "considered_execution_plans": [ + { + "plan_prefix": [ + ] /* plan_prefix */, + "table": "`t1`", + "best_access_path": { + "considered_access_paths": [ + { + "access_type": "ref", + "index": "a", + "rows": 1, + "cost": 0.35, + "chosen": true + }, + { + "access_type": "ref", + "index": "a_2", + "rows": 1, + "cost": 0.35, + "chosen": false + }, + { + "access_type": "scan", + "chosen": false, + "cause": "covering_index_better_than_full_scan" + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 100, + "rows_for_plan": 1, + "cost_for_plan": 0.35, + "chosen": true + } + ] /* considered_execution_plans */ + }, + { + "attaching_conditions_to_tables": { + "original_condition": "(`t1`.`a` = 1)", + "attached_conditions_computation": [ + ] /* attached_conditions_computation */, + "attached_conditions_summary": [ + { + "table": "`t1`", + "attached": "(`t1`.`a` = 1)" + } + ] /* attached_conditions_summary */ + } /* attaching_conditions_to_tables */ + }, + { + "finalizing_table_conditions": [ + { + "table": "`t1`", + "original_table_condition": "(`t1`.`a` = 1)", + "final_table_condition ": null + } + ] /* finalizing_table_conditions */ + }, + { + "refine_plan": [ + { + "table": "`t1`" + } + ] /* refine_plan */ + } + ] /* steps */ + } /* join_optimization */ + }, + { + "join_execution": { + "select#": 2, + "steps": [ + ] /* steps */ + } /* join_execution */ + } + ] /* steps */ + } /* subselect_execution */ + } + ] /* subselect_evaluation */, + "resulting_condition": null + } + ] /* steps */ + } /* condition_processing */ + } + ] /* steps */, + "empty_result": { + "cause": "Impossible WHERE" + } /* empty_result */ + } /* join_optimization */ + }, + { + "join_execution": { + "select#": 1, + "steps": [ + ] /* steps */ + } /* join_execution */ + } + ] /* steps */ +} 0 0 +DROP TABLE t1; +# +# Bug #18346750 OPTIMIZER_TRACE & DBUG_PRINT CRASH IN ST_SELECT_LEX::PRINT +# +"Skipped since this engine does not support native partitioning. +# +# Bug#18791851 CRASH IN ST_SELECT_LEX::PRINT WITH OPTIMIZER_TRACE ON SUBQUERY +# +CREATE TABLE t1 ( +pk INT NOT NULL, +col_int_nokey INT, +col_int_key INT, +col_time_key time, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk), +KEY col_varchar_key (col_varchar_key,col_int_key) +); +CREATE TABLE t2 ( +pk INT NOT NULL, +col_int_nokey INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk), +KEY col_varchar_key (col_varchar_key,col_int_key) +); +CREATE TABLE t3 ( +pk INT NOT NULL, +col_int_nokey INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk), +KEY col_varchar_key (col_varchar_key,col_int_key) +); +CREATE TABLE t4 ( +pk INT NOT NULL, +col_int_nokey INT, +col_int_key INT, +col_time_key time, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk), +KEY col_varchar_key (col_varchar_key,col_int_key) +); +SELECT alias1.col_int_nokey AS field1, +alias2.col_varchar_key AS field2, +alias1.col_time_key AS field3, +MIN( alias1.col_int_nokey ) AS field4 +FROM ( +( +SELECT SQ1_alias1.* +FROM ( t1 AS SQ1_alias1, t2 AS SQ1_alias2 ) +) AS alias1, +t4 AS alias2 +) +WHERE +EXISTS ( +SELECT DISTINCT SQ2_alias2.col_varchar_nokey AS SQ2_field1 +FROM t2 AS SQ2_alias1 +INNER JOIN (t4 AS SQ2_alias2 +INNER JOIN t3 AS SQ2_alias3 +ON SQ2_alias3.pk = SQ2_alias2.pk) +ON SQ2_alias3.col_varchar_key = SQ2_alias2.col_varchar_nokey +) +AND alias1.col_int_key = alias2.pk +HAVING alias1.col_int_nokey IN ( SELECT 2 FROM DUAL ) ; +field1 field2 field3 field4 +DROP TABLE t1,t2,t3,t4; +CREATE TABLE t1(a INT); +SET @a:=(SELECT ROW(1, 2)= +ROW((SELECT 1 FROM t1 LEFT JOIN t1 t2 ON 1 +HAVING 3 IN (SELECT 2 FROM DUAL)), +1)); +DROP TABLE t1; +# +# Bug #18945693 CRASH IN PRINT_TABLE_ARRAY AT SQL/SQL_LEX.CC ON 2ND EXEC OF PREPARED STATEMENT +# +CREATE TABLE t1 ( +pk INT NOT NULL, +col_int_nokey INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1) +); +INSERT INTO t1 VALUES (13,7,3,'y','y'),(14,0,4,'c','c'); +CREATE TABLE t2 ( +pk INT NOT NULL, +col_int_nokey INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1) +); +INSERT INTO t2 VALUES (20,9,8,'e','e'); +CREATE TABLE t3 ( +pk INT NOT NULL, +col_int_nokey INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1) +); +INSERT INTO t3 VALUES (1,1,7,'k','k'); +PREPARE prep_stmt FROM " +SELECT + alias1.col_varchar_nokey AS field1, + MAX(alias1.pk) AS field2 +FROM t3 AS alias1 +GROUP BY field1 +HAVING + 1 > ( + SELECT MAX(SQ4_alias1.col_varchar_nokey) + FROM t1 AS SQ4_alias1 + RIGHT OUTER JOIN + ( + t2 AS SQ4_alias2 + JOIN t1 AS SQ4_alias3 + ON SQ4_alias3.col_int_key = SQ4_alias2.col_int_nokey + ) + ON SQ4_alias3.pk = SQ4_alias2.col_int_nokey + ) +"; +EXECUTE prep_stmt; +field1 field2 +EXECUTE prep_stmt; +field1 field2 +DROP TABLE t1,t2,t3; +# +# Bug#19063289 CRASH IN PRINT_TABLE_ARRAY ON 2ND EXECUTION OF PS WITH SUBQUERY AND VIEW +# +CREATE TABLE B ( +pk INTEGER, +col_int_key INTEGER, +col_varchar_nokey VARCHAR(1) +); +CREATE TABLE C ( +col_int_nokey INTEGER, +col_int_key INTEGER, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1) +) ; +CREATE TABLE CC ( +pk INTEGER, +col_int_key INTEGER +) ENGINE=MYISAM; +INSERT INTO CC VALUES (1, 0),(2, 7); +PREPARE stmt FROM " +SELECT +alias1.col_int_key AS field1 , +COUNT(alias1.pk) AS field2 +FROM +CC AS alias1 +GROUP BY field1 +HAVING +alias1.col_int_key > + ( + SELECT + MAX( SQ2_alias2.col_int_key ) AS SQ2_field1 + FROM + C AS SQ2_alias1 LEFT JOIN + ( B AS SQ2_alias2 INNER JOIN C AS SQ2_alias3 + ON 1) + ON 1 + ) +OR field2 < 2 +"; +EXECUTE stmt; +field1 field2 +0 1 +7 1 +EXECUTE stmt; +field1 field2 +0 1 +7 1 +DROP TABLE B,C,CC; +# +# Bug #23259872: OPTIMIZER CHOOSES TO USE NON PRIMARY +# INDEX, EVEN THOUGH COST IS HIGHER +# +CREATE TABLE t1 ( +a TINYTEXT NOT NULL, +b TINYINT(3) UNSIGNED NOT NULL, +PRIMARY KEY (a(32),b) +) ENGINE=MyISAM, CHARSET utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t2 ( +a TINYTEXT NOT NULL, +b TINYINT(3) UNSIGNED NOT NULL, +PRIMARY KEY (a(32),b) +) ENGINE=INNODB, CHARSET utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES ('a',1),('a',2); +INSERT INTO t2 VALUES ('a',1),('a',2),('a',3),('b',1),('c',1),('c',4),('e',2); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +ANALYZE TABLE t2; +Table Op Msg_type Msg_text +test.t2 analyze status OK +EXPLAIN SELECT * FROM t1 WHERE a='a' AND b in (1,2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range PRIMARY PRIMARY 131 NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`a` = 'a') and (`test`.`t1`.`b` in (1,2))) +SELECT TRACE into @trace FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +SELECT @trace RLIKE "range_uses_more_keyparts"; +@trace RLIKE "range_uses_more_keyparts" +1 +EXPLAIN SELECT * FROM t2 WHERE a='a' AND b in (1,2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range PRIMARY PRIMARY 131 NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t2` where ((`test`.`t2`.`a` = 'a') and (`test`.`t2`.`b` in (1,2))) +SELECT TRACE into @trace FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +SELECT @trace RLIKE "range_uses_more_keyparts"; +@trace RLIKE "range_uses_more_keyparts" +1 +DROP TABLE t1, t2; +# +# Bug #23227428: SQL PLAN IS NOT ACCORDING WITH OPTIMIZER_TRACE +# +CREATE TABLE t1(c1 INT NOT NULL AUTO_INCREMENT PRIMARY KEY, +c2 CHAR(12)) ENGINE=INNODB; +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT c1, c2 FROM t1 ORDER BY c1 DESC LIMIT 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Backward index scan; Parallel execute (3 workers) +2 SIMPLE t1 NULL index NULL PRIMARY 4 NULL 1 100.00 Backward index scan +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c1` AS `c1`,`test`.`t1`.`c2` AS `c2` from `test`.`t1` order by `test`.`t1`.`c1` desc limit 1 +SELECT * FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES +EXPLAIN SELECT c1, c2 FROM t1 ORDER BY c1 DESC LIMIT 1 { + "steps": [ + { + "join_preparation": { + "select#": 1, + "steps": [ + { + "expanded_query": "/* select#1 */ select `t1`.`c1` AS `c1`,`t1`.`c2` AS `c2` from `t1` order by `t1`.`c1` desc limit 1" + } + ] /* steps */ + } /* join_preparation */ + }, + { + "join_optimization": { + "select#": 1, + "steps": [ + { + "substitute_generated_columns": { + } /* substitute_generated_columns */ + }, + { + "table_dependencies": [ + { + "table": "`t1`", + "row_may_be_null": false, + "map_bit": 0, + "depends_on_map_bits": [ + ] /* depends_on_map_bits */ + } + ] /* table_dependencies */ + }, + { + "rows_estimation": [ + { + "table": "`t1`", + "table_scan": { + "rows": 1000, + "cost": 1 + } /* table_scan */ + } + ] /* rows_estimation */ + }, + { + "considered_execution_plans": [ + { + "plan_prefix": [ + ] /* plan_prefix */, + "table": "`t1`", + "best_access_path": { + "considered_access_paths": [ + { + "rows_to_scan": 1000, + "access_type": "scan", + "resulting_rows": 1000, + "cost": 101, + "chosen": true + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 100, + "rows_for_plan": 1000, + "cost_for_plan": 101, + "chosen": true + } + ] /* considered_execution_plans */ + }, + { + "attaching_conditions_to_tables": { + "original_condition": null, + "attached_conditions_computation": [ + ] /* attached_conditions_computation */, + "attached_conditions_summary": [ + { + "table": "`t1`", + "attached": null + } + ] /* attached_conditions_summary */ + } /* attaching_conditions_to_tables */ + }, + { + "optimizing_distinct_group_by_order_by": { + "simplifying_order_by": { + "original_clause": "`t1`.`c1` desc", + "items": [ + { + "item": "`t1`.`c1`" + } + ] /* items */, + "resulting_clause_is_simple": true, + "resulting_clause": "`t1`.`c1` desc" + } /* simplifying_order_by */ + } /* optimizing_distinct_group_by_order_by */ + }, + { + "reconsidering_access_paths_for_index_ordering": { + "clause": "ORDER BY", + "steps": [ + ] /* steps */, + "index_order_summary": { + "table": "`t1`", + "index_provides_order": true, + "order_direction": "desc", + "index": "PRIMARY", + "plan_changed": true, + "access_type": "index" + } /* index_order_summary */ + } /* reconsidering_access_paths_for_index_ordering */ + }, + { + "finalizing_table_conditions": [ + ] /* finalizing_table_conditions */ + }, + { + "refine_plan": [ + { + "table": "`t1`" + } + ] /* refine_plan */ + }, + { + "considering_tmp_tables": [ + ] /* considering_tmp_tables */ + } + ] /* steps */ + } /* join_optimization */ + }, + { + "make_parallel_query_plan": { + "select#": 1, + "detail": [ + { + "table": "`t1`", + "degree of parallel": 4, + "unknown_key_1": { + "considering_tmp_tables": [ + { + "adding_tmp_table_in_plan_at_position": 0, + "cause": "output_for_parallel_query" + } + ] /* considering_tmp_tables */ + } + } + ] /* detail */ + } /* make_parallel_query_plan */ + }, + { + "join_explain": { + "select#": 1, + "steps": [ + ] /* steps */ + } /* join_explain */ + } + ] /* steps */ +} 0 0 +DROP TABLE t1; +# Bug#29016383 - fil_report_invalid_page_access +CREATE TABLE t1 ( +pk INTEGER PRIMARY KEY, +a INTEGER, +b VARCHAR(20) +); +CREATE TABLE t2 ( +pk INTEGER PRIMARY KEY, +c VARCHAR(20), +KEY (c) +); +INSERT INTO t2 VALUES +(1,'koeiwsgpmfyvvuqvtjnc'), +(2,'pmfyvvuqvtjncdsvq'), +(3,'mfyv'), +(4,NULL); +SET end_markers_in_json=off; +SELECT alias1.* +FROM t2 AS alias1, t2 AS alias2 +WHERE alias2.c IN ( +WITH qn AS (SELECT b FROM t1 WHERE a = alias1.pk) +SELECT * FROM qn); +pk c +# Prove that the predicate from the WHERE clause of the CTE +# is decorrelated: +SELECT json_extract(trace,'$**.decorrelated_predicates') +FROM information_schema.optimizer_trace; +json_extract(trace,'$**.decorrelated_predicates') +NULL +DROP TABLE t1, t2; +# +# BUG#18365641: SERVER EXIT IN TRACE OF QUICK SELECT +# +CREATE TABLE t1 ( +pk INT(11), +i1 INT(11), +vc VARCHAR(10), +vc2 VARCHAR(10), +PRIMARY KEY (pk), +KEY i1 (i1), +KEY vc (vc) +) ENGINE=InnoDB, CHARSET utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (1, -1281753088,'p','r'); +INSERT INTO t1 VALUES (4, NULL,'a','i'); +INSERT INTO t1 VALUES (5, NULL,'lhtrovamzq','t'); +INSERT INTO t1 VALUES (6, 3,'d','RZDUH'); +INSERT INTO t1 VALUES (7, 951910400,'z','it\'s'); +INSERT INTO t1 VALUES (8, 1067319296,'get','WZJHD'); +INSERT INTO t1 VALUES (9, -1666187264,'zqrdcenchy','me'); +INSERT INTO t1 VALUES (10, NULL,'what','there'); +CREATE TABLE t2 ( +vc VARCHAR(10), +pk INT(11), +PRIMARY KEY (pk), +KEY vc2 (vc) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES ('ukkoeiwsgp',1); +EXPLAIN +SELECT * +FROM t1 LEFT JOIN t2 +ON t1.i1 < t2.vc +WHERE t1.vc IN ( 'AVZPQ' ) +OR t1.i1 IS NULL AND t1.pk >= 9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge PRIMARY,i1,vc vc,i1,PRIMARY 43,9,4 NULL 2 100.00 Using union(vc,intersect(i1,PRIMARY)); Using where +1 SIMPLE t2 NULL ALL vc2 NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`i1` AS `i1`,`test`.`t1`.`vc` AS `vc`,`test`.`t1`.`vc2` AS `vc2`,`test`.`t2`.`vc` AS `vc`,`test`.`t2`.`pk` AS `pk` from `test`.`t1` left join `test`.`t2` on((cast(`test`.`t1`.`i1` as double) < cast(`test`.`t2`.`vc` as double))) where ((`test`.`t1`.`vc` = 'AVZPQ') or ((`test`.`t1`.`i1` is null) and (`test`.`t1`.`pk` >= 9))) +SELECT * +FROM t1 LEFT JOIN t2 +ON t1.i1 < t2.vc +WHERE t1.vc IN ( 'AVZPQ' ) +OR t1.i1 IS NULL AND t1.pk >= 9; +pk i1 vc vc2 vc pk +10 NULL what there NULL NULL +DROP TABLE t1, t2; diff --git a/mysql-test/suite/charset.result-pq b/mysql-test/suite/charset.result-pq new file mode 100644 index 000000000000..2d8156cd8bb0 --- /dev/null +++ b/mysql-test/suite/charset.result-pq @@ -0,0 +1,912 @@ +set @@session.end_markers_in_json=on; +set @@session.optimizer_trace="enabled=on"; +create table t1(a int); +insert into t1 values(1); +set names latin1; +explain select 'ÁÂÃÄÅ', _latin1'ÁÂÃÄÅ' from t1 limit 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select 'ÁÂÃÄÅ' AS `ÁÂÃÄÅ`,_latin1'\xC1\xC2\xC3\xC4\xC5' AS `ÁÂÃÄÅ` from `test`.`t1` limit 1 +select (@query:=QUERY)+NULL, (@trace:=TRACE)+NULL from information_schema.OPTIMIZER_TRACE; +(@query:=QUERY)+NULL (@trace:=TRACE)+NULL +NULL NULL +select @query, @trace; +@query @trace +explain select 'ÁÂÃÄÅ', _latin1'ÁÂÃÄÅ' from t1 limit 1 { + "steps": [ + { + "join_preparation": { + "select#": 1, + "steps": [ + { + "expanded_query": "/* select#1 */ select 'ÁÂÃÄÅ' AS `ÁÂÃÄÅ`,_latin1'\\xC1\\xC2\\xC3\\xC4\\xC5' AS `ÁÂÃÄÅ` from `t1` limit 1" + } + ] /* steps */ + } /* join_preparation */ + }, + { + "join_optimization": { + "select#": 1, + "steps": [ + { + "table_dependencies": [ + { + "table": "`t1`", + "row_may_be_null": false, + "map_bit": 0, + "depends_on_map_bits": [ + ] /* depends_on_map_bits */ + } + ] /* table_dependencies */ + }, + { + "rows_estimation": [ + { + "table": "`t1`", + "table_scan": { + "rows": 1, + "cost": 0.25 + } /* table_scan */ + } + ] /* rows_estimation */ + }, + { + "considered_execution_plans": [ + { + "plan_prefix": [ + ] /* plan_prefix */, + "table": "`t1`", + "best_access_path": { + "considered_access_paths": [ + { + "rows_to_scan": 1, + "access_type": "scan", + "resulting_rows": 1, + "cost": 0.35, + "chosen": true + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 100, + "rows_for_plan": 1, + "cost_for_plan": 0.35, + "chosen": true + } + ] /* considered_execution_plans */ + }, + { + "attaching_conditions_to_tables": { + "original_condition": null, + "attached_conditions_computation": [ + ] /* attached_conditions_computation */, + "attached_conditions_summary": [ + { + "table": "`t1`", + "attached": null + } + ] /* attached_conditions_summary */ + } /* attaching_conditions_to_tables */ + }, + { + "finalizing_table_conditions": [ + ] /* finalizing_table_conditions */ + }, + { + "refine_plan": [ + { + "table": "`t1`" + } + ] /* refine_plan */ + } + ] /* steps */ + } /* join_optimization */ + }, + { + "make_parallel_query_plan": { + "select#": 1, + "detail": [ + { + "table": "`t1`", + "degree of parallel": 4 + } + ] /* detail */ + } /* make_parallel_query_plan */ + }, + { + "join_explain": { + "select#": 1, + "steps": [ + ] /* steps */ + } /* join_explain */ + } + ] /* steps */ +} +set names utf8; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +select @query, @trace; +@query @trace +explain select 'ÃÂÃÄÅ', _latin1'ÃÂÃÄÅ' from t1 limit 1 { + "steps": [ + { + "join_preparation": { + "select#": 1, + "steps": [ + { + "expanded_query": "/* select#1 */ select 'ÃÂÃÄÅ' AS `ÃÂÃÄÅ`,_latin1'\\xC1\\xC2\\xC3\\xC4\\xC5' AS `ÃÂÃÄÅ` from `t1` limit 1" + } + ] /* steps */ + } /* join_preparation */ + }, + { + "join_optimization": { + "select#": 1, + "steps": [ + { + "table_dependencies": [ + { + "table": "`t1`", + "row_may_be_null": false, + "map_bit": 0, + "depends_on_map_bits": [ + ] /* depends_on_map_bits */ + } + ] /* table_dependencies */ + }, + { + "rows_estimation": [ + { + "table": "`t1`", + "table_scan": { + "rows": 1, + "cost": 0.25 + } /* table_scan */ + } + ] /* rows_estimation */ + }, + { + "considered_execution_plans": [ + { + "plan_prefix": [ + ] /* plan_prefix */, + "table": "`t1`", + "best_access_path": { + "considered_access_paths": [ + { + "rows_to_scan": 1, + "access_type": "scan", + "resulting_rows": 1, + "cost": 0.35, + "chosen": true + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 100, + "rows_for_plan": 1, + "cost_for_plan": 0.35, + "chosen": true + } + ] /* considered_execution_plans */ + }, + { + "attaching_conditions_to_tables": { + "original_condition": null, + "attached_conditions_computation": [ + ] /* attached_conditions_computation */, + "attached_conditions_summary": [ + { + "table": "`t1`", + "attached": null + } + ] /* attached_conditions_summary */ + } /* attaching_conditions_to_tables */ + }, + { + "finalizing_table_conditions": [ + ] /* finalizing_table_conditions */ + }, + { + "refine_plan": [ + { + "table": "`t1`" + } + ] /* refine_plan */ + } + ] /* steps */ + } /* join_optimization */ + }, + { + "make_parallel_query_plan": { + "select#": 1, + "detail": [ + { + "table": "`t1`", + "degree of parallel": 4 + } + ] /* detail */ + } /* make_parallel_query_plan */ + }, + { + "join_explain": { + "select#": 1, + "steps": [ + ] /* steps */ + } /* join_explain */ + } + ] /* steps */ +} +set names latin1; +create view v1 as select 'ÁÂÃÄÅ' as col from t1 limit 1; +select * from v1 where v1.col = 'ÁÂÃÄÅ'; +col +ÁÂÃÄÅ +select (@query:=QUERY)+NULL, (@trace:=TRACE)+NULL from information_schema.OPTIMIZER_TRACE; +(@query:=QUERY)+NULL (@trace:=TRACE)+NULL +NULL NULL +set names utf8; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +select @query, @trace; +@query @trace +select * from v1 where v1.col = 'ÃÂÃÄÅ' { + "steps": [ + { + "join_preparation": { + "select#": 1, + "steps": [ + { + "join_preparation": { + "select#": 2, + "steps": [ + { + "expanded_query": "/* select#2 */ select 'ÃÂÃÄÅ' AS `col` from `t1` limit 1" + } + ] /* steps */ + } /* join_preparation */ + }, + { + "view": { + "table": "`v1`", + "select#": 2, + "materialized": true + } /* view */ + }, + { + "expanded_query": "/* select#1 */ select `v1`.`col` AS `col` from `v1` where (`v1`.`col` = 'ÃÂÃÄÅ')" + } + ] /* steps */ + } /* join_preparation */ + }, + { + "join_optimization": { + "select#": 1, + "steps": [ + { + "join_optimization": { + "select#": 2, + "steps": [ + { + "table_dependencies": [ + { + "table": "`t1`", + "row_may_be_null": false, + "map_bit": 0, + "depends_on_map_bits": [ + ] /* depends_on_map_bits */ + } + ] /* table_dependencies */ + }, + { + "rows_estimation": [ + { + "table": "`t1`", + "table_scan": { + "rows": 1, + "cost": 0.25 + } /* table_scan */ + } + ] /* rows_estimation */ + }, + { + "considered_execution_plans": [ + { + "plan_prefix": [ + ] /* plan_prefix */, + "table": "`t1`", + "best_access_path": { + "considered_access_paths": [ + { + "rows_to_scan": 1, + "access_type": "scan", + "resulting_rows": 1, + "cost": 0.35, + "chosen": true + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 100, + "rows_for_plan": 1, + "cost_for_plan": 0.35, + "chosen": true + } + ] /* considered_execution_plans */ + }, + { + "attaching_conditions_to_tables": { + "original_condition": null, + "attached_conditions_computation": [ + ] /* attached_conditions_computation */, + "attached_conditions_summary": [ + { + "table": "`t1`", + "attached": null + } + ] /* attached_conditions_summary */ + } /* attaching_conditions_to_tables */ + }, + { + "finalizing_table_conditions": [ + ] /* finalizing_table_conditions */ + }, + { + "refine_plan": [ + { + "table": "`t1`" + } + ] /* refine_plan */ + } + ] /* steps */ + } /* join_optimization */ + }, + { + "creating_tmp_table": { + "tmp_table_info": { + "table": "`v1`", + "columns": 1, + "row_length": 7, + "key_length": 0, + "unique_constraint": false, + "makes_grouped_rows": false, + "cannot_insert_duplicates": false, + "location": "TempTable" + } /* tmp_table_info */ + } /* creating_tmp_table */ + }, + { + "join_execution": { + "select#": 2, + "steps": [ + ] /* steps */ + } /* join_execution */ + }, + { + "condition_processing": { + "condition": "WHERE", + "original_condition": "(`v1`.`col` = 'ÃÂÃÄÅ')", + "steps": [ + { + "transformation": "equality_propagation", + "resulting_condition": "multiple equal('ÃÂÃÄÅ', `v1`.`col`)" + }, + { + "transformation": "constant_propagation", + "resulting_condition": "multiple equal('ÃÂÃÄÅ', `v1`.`col`)" + }, + { + "transformation": "trivial_condition_removal", + "resulting_condition": "multiple equal('ÃÂÃÄÅ', `v1`.`col`)" + } + ] /* steps */ + } /* condition_processing */ + }, + { + "substitute_generated_columns": { + } /* substitute_generated_columns */ + }, + { + "table_dependencies": [ + { + "table": "`v1`", + "row_may_be_null": false, + "map_bit": 0, + "depends_on_map_bits": [ + ] /* depends_on_map_bits */ + } + ] /* table_dependencies */ + }, + { + "ref_optimizer_key_uses": [ + ] /* ref_optimizer_key_uses */ + }, + { + "rows_estimation": [ + { + "table": "`v1`", + "rows": 1, + "cost": 1, + "table_type": "system", + "empty": false + } + ] /* rows_estimation */ + }, + { + "condition_on_constant_tables": "true", + "condition_value": true + }, + { + "attaching_conditions_to_tables": { + "original_condition": "true", + "attached_conditions_computation": [ + ] /* attached_conditions_computation */, + "attached_conditions_summary": [ + ] /* attached_conditions_summary */ + } /* attaching_conditions_to_tables */ + }, + { + "refine_plan": [ + ] /* refine_plan */ + } + ] /* steps */ + } /* join_optimization */ + }, + { + "join_execution": { + "select#": 1, + "steps": [ + ] /* steps */ + } /* join_execution */ + } + ] /* steps */ +} +drop table t1; +drop view v1; +set names latin1; +create table t1(c char(4) primary key) charset latin1; +insert into t1 values ('aaa'), ('ÁÂÃÄ'); +select * from t1 where c < 'ÁÂÃÄÅ'; +c +aaa +ÁÂÃÄ +select (@query:=QUERY)+NULL, (@trace:=TRACE)+NULL from information_schema.OPTIMIZER_TRACE; +(@query:=QUERY)+NULL (@trace:=TRACE)+NULL +NULL NULL +set names utf8; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +select @query, @trace; +@query @trace +select * from t1 where c < 'ÃÂÃÄÅ' { + "steps": [ + { + "join_preparation": { + "select#": 1, + "steps": [ + { + "expanded_query": "/* select#1 */ select `t1`.`c` AS `c` from `t1` where (`t1`.`c` < 'ÃÂÃÄÅ')" + } + ] /* steps */ + } /* join_preparation */ + }, + { + "join_optimization": { + "select#": 1, + "steps": [ + { + "condition_processing": { + "condition": "WHERE", + "original_condition": "(`t1`.`c` < 'ÃÂÃÄÅ')", + "steps": [ + { + "transformation": "equality_propagation", + "resulting_condition": "(`t1`.`c` < 'ÃÂÃÄÅ')" + }, + { + "transformation": "constant_propagation", + "resulting_condition": "(`t1`.`c` < 'ÃÂÃÄÅ')" + }, + { + "transformation": "trivial_condition_removal", + "resulting_condition": "(`t1`.`c` < 'ÃÂÃÄÅ')" + } + ] /* steps */ + } /* condition_processing */ + }, + { + "substitute_generated_columns": { + } /* substitute_generated_columns */ + }, + { + "table_dependencies": [ + { + "table": "`t1`", + "row_may_be_null": false, + "map_bit": 0, + "depends_on_map_bits": [ + ] /* depends_on_map_bits */ + } + ] /* table_dependencies */ + }, + { + "ref_optimizer_key_uses": [ + ] /* ref_optimizer_key_uses */ + }, + { + "rows_estimation": [ + { + "table": "`t1`", + "range_analysis": { + "table_scan": { + "rows": 2, + "cost": 2.55 + } /* table_scan */, + "potential_range_indexes": [ + { + "index": "PRIMARY", + "usable": true, + "key_parts": [ + "c" + ] /* key_parts */ + } + ] /* potential_range_indexes */, + "best_covering_index_scan": { + "index": "PRIMARY", + "cost": 0.450244, + "chosen": true + } /* best_covering_index_scan */, + "setup_range_conditions": [ + ] /* setup_range_conditions */, + "group_index_range": { + "chosen": false, + "cause": "not_group_by_or_distinct" + } /* group_index_range */, + "skip_scan_range": { + "potential_skip_scan_indexes": [ + { + "index": "PRIMARY", + "usable": false, + "cause": "prefix_not_const_equality" + } + ] /* potential_skip_scan_indexes */ + } /* skip_scan_range */, + "analyzing_range_alternatives": { + "range_scan_alternatives": [ + { + "index": "PRIMARY", + "ranges": [ + "c <= ÃÂÃÄ" + ] /* ranges */, + "index_dives_for_eq_ranges": true, + "rowid_ordered": true, + "using_mrr": false, + "index_only": true, + "rows": 2, + "cost": 0.71, + "chosen": false, + "cause": "cost" + } + ] /* range_scan_alternatives */, + "analyzing_roworder_intersect": { + "usable": false, + "cause": "too_few_roworder_scans" + } /* analyzing_roworder_intersect */ + } /* analyzing_range_alternatives */ + } /* range_analysis */ + } + ] /* rows_estimation */ + }, + { + "considered_execution_plans": [ + { + "plan_prefix": [ + ] /* plan_prefix */, + "table": "`t1`", + "best_access_path": { + "considered_access_paths": [ + { + "rows_to_scan": 2, + "access_type": "scan", + "resulting_rows": 2, + "cost": 0.45, + "chosen": true + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 100, + "rows_for_plan": 2, + "cost_for_plan": 0.45, + "chosen": true + } + ] /* considered_execution_plans */ + }, + { + "attaching_conditions_to_tables": { + "original_condition": "(`t1`.`c` < 'ÃÂÃÄÅ')", + "attached_conditions_computation": [ + ] /* attached_conditions_computation */, + "attached_conditions_summary": [ + { + "table": "`t1`", + "attached": "(`t1`.`c` < 'ÃÂÃÄÅ')" + } + ] /* attached_conditions_summary */ + } /* attaching_conditions_to_tables */ + }, + { + "finalizing_table_conditions": [ + { + "table": "`t1`", + "original_table_condition": "(`t1`.`c` < 'ÃÂÃÄÅ')", + "final_table_condition ": "(`t1`.`c` < 'ÃÂÃÄÅ')" + } + ] /* finalizing_table_conditions */ + }, + { + "refine_plan": [ + { + "table": "`t1`" + } + ] /* refine_plan */ + } + ] /* steps */ + } /* join_optimization */ + }, + { + "make_parallel_query_plan": { + "select#": 1, + "detail": [ + { + "table": "`t1`", + "degree of parallel": 4 + } + ] /* detail */ + } /* make_parallel_query_plan */ + }, + { + "join_execution": { + "select#": 1, + "steps": [ + ] /* steps */ + } /* join_execution */ + } + ] /* steps */ +} +drop table t1; +create table `t +1 a`(`col +1 a` int, index `index +1 a` (`col +1 a`)); +insert into `t +1 a` values(2),(3); +create view `v +1 a` as select * from `t +1 a`; +select `col +1 a` from `v +1 a` where `col +1 a` < 6; +col +1 a +2 +3 +select query, trace from information_schema.OPTIMIZER_TRACE; +query trace +select `col +1 a` from `v +1 a` where `col +1 a` < 6 { + "steps": [ + { + "join_preparation": { + "select#": 1, + "steps": [ + { + "join_preparation": { + "select#": 2, + "steps": [ + { + "expanded_query": "/* select#2 */ select `t\n1\ta`.`col\n1\ta` AS `col\n1\ta` from `t\n1\ta`" + } + ] /* steps */ + } /* join_preparation */ + }, + { + "view": { + "table": "`v\n1\ta`", + "select#": 2, + "merged": true + } /* view */ + }, + { + "expanded_query": "/* select#1 */ select `t\n1\ta`.`col\n1\ta` AS `col\n1\ta` from (`t\n1\ta`) where (`t\n1\ta`.`col\n1\ta` < 6)" + }, + { + "transformations_to_nested_joins": { + "transformations": [ + "parenthesis_removal" + ] /* transformations */, + "expanded_query": "/* select#1 */ select `t\n1\ta`.`col\n1\ta` AS `col\n1\ta` from `t\n1\ta` where (`t\n1\ta`.`col\n1\ta` < 6)" + } /* transformations_to_nested_joins */ + } + ] /* steps */ + } /* join_preparation */ + }, + { + "join_optimization": { + "select#": 1, + "steps": [ + { + "condition_processing": { + "condition": "WHERE", + "original_condition": "(`t\n1\ta`.`col\n1\ta` < 6)", + "steps": [ + { + "transformation": "equality_propagation", + "resulting_condition": "(`t\n1\ta`.`col\n1\ta` < 6)" + }, + { + "transformation": "constant_propagation", + "resulting_condition": "(`t\n1\ta`.`col\n1\ta` < 6)" + }, + { + "transformation": "trivial_condition_removal", + "resulting_condition": "(`t\n1\ta`.`col\n1\ta` < 6)" + } + ] /* steps */ + } /* condition_processing */ + }, + { + "substitute_generated_columns": { + } /* substitute_generated_columns */ + }, + { + "table_dependencies": [ + { + "table": "`t\n1\ta`", + "row_may_be_null": false, + "map_bit": 0, + "depends_on_map_bits": [ + ] /* depends_on_map_bits */ + } + ] /* table_dependencies */ + }, + { + "ref_optimizer_key_uses": [ + ] /* ref_optimizer_key_uses */ + }, + { + "rows_estimation": [ + { + "table": "`t\n1\ta`", + "range_analysis": { + "table_scan": { + "rows": 2, + "cost": 2.55 + } /* table_scan */, + "potential_range_indexes": [ + { + "index": "index\n1\ta", + "usable": true, + "key_parts": [ + "col\n1\ta" + ] /* key_parts */ + } + ] /* potential_range_indexes */, + "best_covering_index_scan": { + "index": "index\n1\ta", + "cost": 0.450336, + "chosen": true + } /* best_covering_index_scan */, + "setup_range_conditions": [ + ] /* setup_range_conditions */, + "group_index_range": { + "chosen": false, + "cause": "not_group_by_or_distinct" + } /* group_index_range */, + "skip_scan_range": { + "potential_skip_scan_indexes": [ + { + "index": "index\n1\ta", + "usable": false, + "cause": "prefix_not_const_equality" + } + ] /* potential_skip_scan_indexes */ + } /* skip_scan_range */, + "analyzing_range_alternatives": { + "range_scan_alternatives": [ + { + "index": "index\n1\ta", + "ranges": [ + "NULL < col\n1\ta < 6" + ] /* ranges */, + "index_dives_for_eq_ranges": true, + "rowid_ordered": false, + "using_mrr": false, + "index_only": true, + "rows": 2, + "cost": 0.460336, + "chosen": false, + "cause": "cost" + } + ] /* range_scan_alternatives */, + "analyzing_roworder_intersect": { + "usable": false, + "cause": "too_few_roworder_scans" + } /* analyzing_roworder_intersect */ + } /* analyzing_range_alternatives */ + } /* range_analysis */ + } + ] /* rows_estimation */ + }, + { + "considered_execution_plans": [ + { + "plan_prefix": [ + ] /* plan_prefix */, + "table": "`t\n1\ta`", + "best_access_path": { + "considered_access_paths": [ + { + "rows_to_scan": 2, + "access_type": "scan", + "resulting_rows": 2, + "cost": 0.45, + "chosen": true + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 100, + "rows_for_plan": 2, + "cost_for_plan": 0.45, + "chosen": true + } + ] /* considered_execution_plans */ + }, + { + "attaching_conditions_to_tables": { + "original_condition": "(`t\n1\ta`.`col\n1\ta` < 6)", + "attached_conditions_computation": [ + ] /* attached_conditions_computation */, + "attached_conditions_summary": [ + { + "table": "`t\n1\ta`", + "attached": "(`t\n1\ta`.`col\n1\ta` < 6)" + } + ] /* attached_conditions_summary */ + } /* attaching_conditions_to_tables */ + }, + { + "finalizing_table_conditions": [ + { + "table": "`t\n1\ta`", + "original_table_condition": "(`t\n1\ta`.`col\n1\ta` < 6)", + "final_table_condition ": "(`t\n1\ta`.`col\n1\ta` < 6)" + } + ] /* finalizing_table_conditions */ + }, + { + "refine_plan": [ + { + "table": "`t\n1\ta`" + } + ] /* refine_plan */ + } + ] /* steps */ + } /* join_optimization */ + }, + { + "join_execution": { + "select#": 1, + "steps": [ + ] /* steps */ + } /* join_execution */ + } + ] /* steps */ +} +drop table `t +1 a`; +drop view `v +1 a`; +set optimizer_trace=default; diff --git a/mysql-test/suite/crud_resultset_metadata.result-pq b/mysql-test/suite/crud_resultset_metadata.result-pq new file mode 100644 index 000000000000..490f7a2646a9 --- /dev/null +++ b/mysql-test/suite/crud_resultset_metadata.result-pq @@ -0,0 +1,24 @@ +CREATE SCHEMA xtest; +CREATE TABLE xtest.xtable (x INT AUTO_INCREMENT PRIMARY KEY, y VARCHAR(1) NOT NULL, z INT UNSIGNED UNIQUE); +INSERT INTO xtest.xtable VALUES (1,2,3); +CREATE TABLE xtest.ytable (a INT ZEROFILL, b TIMESTAMP, c FLOAT UNSIGNED, INDEX(a)); +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +Warning 1681 UNSIGNED for decimal and floating point data types is deprecated and support for it will be removed in a future release. +INSERT INTO xtest.ytable VALUES (1,'2015-02-15',3); +x y z +1 2 3 +x:SINT: NOT_NULL +y:BYTES: NOT_NULL +z:UINT: +command ok +a b c +1 2015-02-15 00:00:00 3 +a:UINT: ZEROFILL +b:DATETIME: TIMESTAMP +c:FLOAT: UNSIGNED +command ok +Mysqlx.Ok { + msg: "bye!" +} +ok diff --git a/mysql-test/suite/dml_setup_instruments.result-pq b/mysql-test/suite/dml_setup_instruments.result-pq new file mode 100644 index 000000000000..897b91968a68 --- /dev/null +++ b/mysql-test/suite/dml_setup_instruments.result-pq @@ -0,0 +1,87 @@ +select * from performance_schema.setup_instruments; +select * from performance_schema.setup_instruments +where name like 'Wait/Synch/Mutex/sql/%' + and name not in ('wait/synch/mutex/sql/DEBUG_SYNC::mutex') +order by name limit 10; +NAME ENABLED TIMED PROPERTIES VOLATILITY DOCUMENTATION +wait/synch/mutex/sql/Commit_order_manager::m_mutex YES YES 0 NULL +wait/synch/mutex/sql/Cost_constant_cache::LOCK_cost_const YES YES singleton 0 NULL +wait/synch/mutex/sql/Event_scheduler::LOCK_scheduler_state YES YES singleton 0 NULL +wait/synch/mutex/sql/Gtid_set::gtid_executed::free_intervals_mutex YES YES 0 NULL +wait/synch/mutex/sql/Gtid_state YES YES singleton 0 NULL +wait/synch/mutex/sql/hash_filo::lock YES YES 0 NULL +wait/synch/mutex/sql/key_mts_gaq_LOCK YES YES 0 NULL +wait/synch/mutex/sql/key_mts_temp_table_LOCK YES YES 0 NULL +wait/synch/mutex/sql/LOCK_acl_cache_flush YES YES singleton 0 NULL +wait/synch/mutex/sql/LOCK_admin_tls_ctx_options YES YES 0 A lock to control all of the --ssl-* CTX related command line options for administrative connection port +select * from performance_schema.setup_instruments +where name like 'Wait/Synch/Rwlock/sql/%' + and name not in ( +'wait/synch/rwlock/sql/CRYPTO_dynlock_value::lock', +'wait/synch/rwlock/sql/LOCK_named_pipe_full_access_group') +order by name limit 10; +NAME ENABLED TIMED PROPERTIES VOLATILITY DOCUMENTATION +wait/synch/rwlock/sql/Binlog_relay_IO_delegate::lock YES YES singleton 0 NULL +wait/synch/rwlock/sql/Binlog_storage_delegate::lock YES YES singleton 0 NULL +wait/synch/rwlock/sql/Binlog_transmit_delegate::lock YES YES singleton 0 NULL +wait/synch/rwlock/sql/channel_lock YES YES 0 NULL +wait/synch/rwlock/sql/channel_map_lock YES YES 0 NULL +wait/synch/rwlock/sql/channel_to_filter_lock YES YES 0 NULL +wait/synch/rwlock/sql/gtid_commit_rollback YES YES singleton 0 NULL +wait/synch/rwlock/sql/gtid_mode_lock YES YES singleton 0 NULL +wait/synch/rwlock/sql/gtid_retrieved YES YES singleton 0 NULL +wait/synch/rwlock/sql/LOCK_sys_init_connect YES YES singleton 0 NULL +select * from performance_schema.setup_instruments +where name like 'Wait/Synch/Cond/sql/%' + and name not in ( +'wait/synch/cond/sql/COND_open', +'wait/synch/cond/sql/COND_handler_count', +'wait/synch/cond/sql/DEBUG_SYNC::cond', +'wait/synch/cond/sql/COND_socket_listener_active', +'wait/synch/cond/sql/COND_start_signal_handler') +order by name limit 10; +NAME ENABLED TIMED PROPERTIES VOLATILITY DOCUMENTATION +wait/synch/cond/sql/Commit_order_manager::m_workers.cond YES YES 0 NULL +wait/synch/cond/sql/COND_compress_gtid_table YES YES singleton 0 NULL +wait/synch/cond/sql/COND_connection_count YES YES singleton 0 NULL +wait/synch/cond/sql/COND_flush_thread_cache YES YES singleton 0 NULL +wait/synch/cond/sql/COND_manager YES YES singleton 0 NULL +wait/synch/cond/sql/COND_pq_threads_running YES YES singleton 0 NULL +wait/synch/cond/sql/COND_queue_state YES YES singleton 0 NULL +wait/synch/cond/sql/COND_server_started YES YES singleton 0 NULL +wait/synch/cond/sql/COND_thd_list YES YES 0 NULL +wait/synch/cond/sql/COND_thr_lock YES YES 0 NULL +select * from performance_schema.setup_instruments +where name='Wait'; +select * from performance_schema.setup_instruments +where enabled='YES'; +insert into performance_schema.setup_instruments +set name='FOO', enabled='YES', timed='YES'; +ERROR 42000: INSERT command denied to user 'root'@'localhost' for table 'setup_instruments' +update performance_schema.setup_instruments +set name='FOO'; +ERROR HY000: Invalid performance_schema usage. +update performance_schema.setup_instruments +set enabled='NO'; +update performance_schema.setup_instruments +set timed='NO'; +select * from performance_schema.setup_instruments; +update performance_schema.setup_instruments +set enabled='YES', timed='YES'; +delete from performance_schema.setup_instruments; +ERROR 42000: DELETE command denied to user 'root'@'localhost' for table 'setup_instruments' +delete from performance_schema.setup_instruments +where name like 'Wait/Synch/%'; +ERROR 42000: DELETE command denied to user 'root'@'localhost' for table 'setup_instruments' +LOCK TABLES performance_schema.setup_instruments READ; +UNLOCK TABLES; +LOCK TABLES performance_schema.setup_instruments WRITE; +UNLOCK TABLES; + +# Bug#13813193 ASSERTION `TABLE->READ_SET == +# &TABLE->DEF_READ_SET' FAILED / MYSQL_UPDATE + +UPDATE performance_schema.setup_instruments SET timed='NO' +ORDER BY RAND(); +update performance_schema.setup_instruments +set enabled='YES', TIMED='YES'; diff --git a/mysql-test/suite/explain.result-pq b/mysql-test/suite/explain.result-pq new file mode 100644 index 000000000000..20266a79e27d --- /dev/null +++ b/mysql-test/suite/explain.result-pq @@ -0,0 +1,105 @@ +# +# Bug#28556942: ADD USING SECONDARY ENGINE TO EXPLAIN +# +CREATE TABLE t1 (a INT) SECONDARY_ENGINE MOCK; +# Before table is loaded, the secondary engine should not be used. +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT * FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` +EXPLAIN FORMAT=JSON SELECT * FROM t1; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.35" + }, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.10", + "prefix_cost": "0.35", + "data_read_per_join": "16" + }, + "used_columns": [ + "a" + ], + "query_block": { + "cost_info": { + "query_cost": "0.35" + }, + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.10", + "prefix_cost": "0.35", + "data_read_per_join": "8" + }, + "used_columns": [ + "a" + ] + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` +ALTER TABLE t1 SECONDARY_LOAD; +# After table is loaded, the secondary engine should be used. +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT * FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using secondary engine MOCK +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` +EXPLAIN FORMAT=JSON SELECT * FROM t1; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.60" + }, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "using_secondary_engine": "MOCK", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.10", + "prefix_cost": "0.60", + "data_read_per_join": "8" + }, + "used_columns": [ + "a" + ] + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` +DROP TABLE t1; diff --git a/mysql-test/suite/filesort_pack.result-pq b/mysql-test/suite/filesort_pack.result-pq new file mode 100644 index 000000000000..84e34a006205 --- /dev/null +++ b/mysql-test/suite/filesort_pack.result-pq @@ -0,0 +1,947 @@ +call mtr.add_suppression("Cannot add field"); +SET optimizer_trace_max_mem_size=1048576; +SET end_markers_in_json=off; +SET optimizer_trace="enabled=on,one_line=off"; +CREATE TABLE t1 ( +c1 VARCHAR(1022) NOT NULL DEFAULT '', +c2 VARCHAR(1022) NOT NULL DEFAULT '', +c3 VARCHAR(1022) NOT NULL DEFAULT '', +c4 VARCHAR(1022) NOT NULL DEFAULT '', +c5 VARCHAR(1022) NOT NULL DEFAULT '', +c6 VARCHAR(1022) NOT NULL DEFAULT '', +c7 VARCHAR(1022) NOT NULL DEFAULT '', +c8 VARCHAR(1022) NOT NULL DEFAULT '', +c9 VARCHAR(1022) NOT NULL DEFAULT '', +c10 VARCHAR(1022) NOT NULL DEFAULT '', +c11 VARCHAR(1022) NOT NULL DEFAULT '', +c12 VARCHAR(1022) NOT NULL DEFAULT '', +c13 VARCHAR(1022) NOT NULL DEFAULT '', +c14 VARCHAR(1022) NOT NULL DEFAULT '', +c15 VARCHAR(1022) NOT NULL DEFAULT '', +c16 VARCHAR(1022) NOT NULL DEFAULT '', +c17 VARCHAR(1022) NOT NULL DEFAULT '', +c18 VARCHAR(1022) NOT NULL DEFAULT '', +c19 VARCHAR(1022) NOT NULL DEFAULT '', +c20 VARCHAR(1022) NOT NULL DEFAULT '', +c21 VARCHAR(1022) NOT NULL DEFAULT '', +c22 VARCHAR(1022) NOT NULL DEFAULT '', +c23 VARCHAR(1022) NOT NULL DEFAULT '', +c24 VARCHAR(1022) NOT NULL DEFAULT '', +c25 VARCHAR(1022) NOT NULL DEFAULT '', +c26 VARCHAR(1022) NOT NULL DEFAULT '', +c27 VARCHAR(1022) NOT NULL DEFAULT '', +c28 VARCHAR(1022) NOT NULL DEFAULT '', +c29 VARCHAR(1022) NOT NULL DEFAULT '', +c30 VARCHAR(1022) NOT NULL DEFAULT '', +c31 VARCHAR(1022) NOT NULL DEFAULT '', +c32 VARCHAR(1022) NOT NULL DEFAULT '', +c33 VARCHAR(1022) NOT NULL DEFAULT '', +c34 VARCHAR(1022) NOT NULL DEFAULT '', +c35 VARCHAR(1022) NOT NULL DEFAULT '', +c36 VARCHAR(1022) NOT NULL DEFAULT '', +c37 VARCHAR(1022) NOT NULL DEFAULT '', +c38 VARCHAR(1022) NOT NULL DEFAULT '', +c39 VARCHAR(1022) NOT NULL DEFAULT '', +c40 VARCHAR(1022) NOT NULL DEFAULT '', +c41 VARCHAR(1022) NOT NULL DEFAULT '', +c42 VARCHAR(1022) NOT NULL DEFAULT '', +c43 VARCHAR(1022) NOT NULL DEFAULT '', +c44 VARCHAR(1022) NOT NULL DEFAULT '', +c45 VARCHAR(1022) NOT NULL DEFAULT '', +c46 VARCHAR(1022) NOT NULL DEFAULT '', +c47 VARCHAR(1022) NOT NULL DEFAULT '', +c48 VARCHAR(1022) NOT NULL DEFAULT '', +c49 VARCHAR(1022) NOT NULL DEFAULT '', +c50 VARCHAR(1022) NOT NULL DEFAULT '', +c51 VARCHAR(1022) NOT NULL DEFAULT '', +c52 VARCHAR(1022) NOT NULL DEFAULT '', +c53 VARCHAR(1022) NOT NULL DEFAULT '', +c54 VARCHAR(1022) NOT NULL DEFAULT '', +c55 VARCHAR(1022) NOT NULL DEFAULT '', +c56 VARCHAR(1022) NOT NULL DEFAULT '', +c57 VARCHAR(1022) NOT NULL DEFAULT '', +c58 VARCHAR(1022) NOT NULL DEFAULT '', +c59 VARCHAR(1022) NOT NULL DEFAULT '', +c60 VARCHAR(1022) NOT NULL DEFAULT '', +c61 VARCHAR(1022) NOT NULL DEFAULT '', +c62 VARCHAR(1022) NOT NULL DEFAULT '', +c63 VARCHAR(1022) NOT NULL DEFAULT '', +c64 VARCHAR(1021) NOT NULL DEFAULT '' +) ENGINE = INNODB, charset latin1; +SET @save_sort_buffer_size= @@sort_buffer_size; +SET @@sort_buffer_size = 8 + 15 * (65535 + 1022 + 8); +select * from t1 order by c1; +c1 c2 c3 c4 c5 c6 c7 c8 c9 c10 c11 c12 c13 c14 c15 c16 c17 c18 c19 c20 c21 c22 c23 c24 c25 c26 c27 c28 c29 c30 c31 c32 c33 c34 c35 c36 c37 c38 c39 c40 c41 c42 c43 c44 c45 c46 c47 c48 c49 c50 c51 c52 c53 c54 c55 c56 c57 c58 c59 c60 c61 c62 c63 c64 +SELECT * FROM information_schema.OPTIMIZER_TRACE; +QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES +select * from t1 order by c1 { + "steps": [ + { + "join_preparation": { + "select#": 1, + "steps": [ + { + "expanded_query": "/* select#1 */ select `t1`.`c1` AS `c1`,`t1`.`c2` AS `c2`,`t1`.`c3` AS `c3`,`t1`.`c4` AS `c4`,`t1`.`c5` AS `c5`,`t1`.`c6` AS `c6`,`t1`.`c7` AS `c7`,`t1`.`c8` AS `c8`,`t1`.`c9` AS `c9`,`t1`.`c10` AS `c10`,`t1`.`c11` AS `c11`,`t1`.`c12` AS `c12`,`t1`.`c13` AS `c13`,`t1`.`c14` AS `c14`,`t1`.`c15` AS `c15`,`t1`.`c16` AS `c16`,`t1`.`c17` AS `c17`,`t1`.`c18` AS `c18`,`t1`.`c19` AS `c19`,`t1`.`c20` AS `c20`,`t1`.`c21` AS `c21`,`t1`.`c22` AS `c22`,`t1`.`c23` AS `c23`,`t1`.`c24` AS `c24`,`t1`.`c25` AS `c25`,`t1`.`c26` AS `c26`,`t1`.`c27` AS `c27`,`t1`.`c28` AS `c28`,`t1`.`c29` AS `c29`,`t1`.`c30` AS `c30`,`t1`.`c31` AS `c31`,`t1`.`c32` AS `c32`,`t1`.`c33` AS `c33`,`t1`.`c34` AS `c34`,`t1`.`c35` AS `c35`,`t1`.`c36` AS `c36`,`t1`.`c37` AS `c37`,`t1`.`c38` AS `c38`,`t1`.`c39` AS `c39`,`t1`.`c40` AS `c40`,`t1`.`c41` AS `c41`,`t1`.`c42` AS `c42`,`t1`.`c43` AS `c43`,`t1`.`c44` AS `c44`,`t1`.`c45` AS `c45`,`t1`.`c46` AS `c46`,`t1`.`c47` AS `c47`,`t1`.`c48` AS `c48`,`t1`.`c49` AS `c49`,`t1`.`c50` AS `c50`,`t1`.`c51` AS `c51`,`t1`.`c52` AS `c52`,`t1`.`c53` AS `c53`,`t1`.`c54` AS `c54`,`t1`.`c55` AS `c55`,`t1`.`c56` AS `c56`,`t1`.`c57` AS `c57`,`t1`.`c58` AS `c58`,`t1`.`c59` AS `c59`,`t1`.`c60` AS `c60`,`t1`.`c61` AS `c61`,`t1`.`c62` AS `c62`,`t1`.`c63` AS `c63`,`t1`.`c64` AS `c64` from `t1` order by `t1`.`c1`" + } + ] + } + }, + { + "join_optimization": { + "select#": 1, + "steps": [ + { + "substitute_generated_columns": { + } + }, + { + "table_dependencies": [ + { + "table": "`t1`", + "row_may_be_null": false, + "map_bit": 0, + "depends_on_map_bits": [ + ] + } + ] + }, + { + "rows_estimation": [ + { + "table": "`t1`", + "table_scan": { + "rows": 1, + "cost": 0.25 + } + } + ] + }, + { + "considered_execution_plans": [ + { + "plan_prefix": [ + ], + "table": "`t1`", + "best_access_path": { + "considered_access_paths": [ + { + "rows_to_scan": 1, + "access_type": "scan", + "resulting_rows": 1, + "cost": 0.35, + "chosen": true, + "use_tmp_table": true + } + ] + }, + "condition_filtering_pct": 100, + "rows_for_plan": 1, + "cost_for_plan": 0.35, + "sort_cost": 1, + "new_cost_for_plan": 1.35, + "chosen": true + } + ] + }, + { + "attaching_conditions_to_tables": { + "original_condition": null, + "attached_conditions_computation": [ + ], + "attached_conditions_summary": [ + { + "table": "`t1`", + "attached": null + } + ] + } + }, + { + "optimizing_distinct_group_by_order_by": { + "simplifying_order_by": { + "original_clause": "`t1`.`c1`", + "items": [ + { + "item": "`t1`.`c1`" + } + ], + "resulting_clause_is_simple": true, + "resulting_clause": "`t1`.`c1`" + } + } + }, + { + "finalizing_table_conditions": [ + ] + }, + { + "refine_plan": [ + { + "table": "`t1`" + } + ] + }, + { + "considering_tmp_tables": [ + { + "adding_sort_to_table": "t1" + } + ] + } + ] + } + }, + { + "make_parallel_query_plan": { + "select#": 1, + "detail": [ + { + "table": "`t1`", + "degree of parallel": 4, + "unknown_key_1": { + "considering_tmp_tables": [ + { + "adding_tmp_table_in_plan_at_position": 0, + "cause": "output_for_parallel_query", + "filesort": { + "adding_sort_to_table": "" + } + } + ] + } + } + ] + } + }, + { + "join_execution": { + "select#": 1, + "steps": [ + ] + } + } + ] +} 0 0 +SET @@sort_buffer_size = 8 + 15 * (65535 + 1023 + 8); +select * from t1 order by c1; +c1 c2 c3 c4 c5 c6 c7 c8 c9 c10 c11 c12 c13 c14 c15 c16 c17 c18 c19 c20 c21 c22 c23 c24 c25 c26 c27 c28 c29 c30 c31 c32 c33 c34 c35 c36 c37 c38 c39 c40 c41 c42 c43 c44 c45 c46 c47 c48 c49 c50 c51 c52 c53 c54 c55 c56 c57 c58 c59 c60 c61 c62 c63 c64 +SELECT * FROM information_schema.OPTIMIZER_TRACE; +QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES +select * from t1 order by c1 { + "steps": [ + { + "join_preparation": { + "select#": 1, + "steps": [ + { + "expanded_query": "/* select#1 */ select `t1`.`c1` AS `c1`,`t1`.`c2` AS `c2`,`t1`.`c3` AS `c3`,`t1`.`c4` AS `c4`,`t1`.`c5` AS `c5`,`t1`.`c6` AS `c6`,`t1`.`c7` AS `c7`,`t1`.`c8` AS `c8`,`t1`.`c9` AS `c9`,`t1`.`c10` AS `c10`,`t1`.`c11` AS `c11`,`t1`.`c12` AS `c12`,`t1`.`c13` AS `c13`,`t1`.`c14` AS `c14`,`t1`.`c15` AS `c15`,`t1`.`c16` AS `c16`,`t1`.`c17` AS `c17`,`t1`.`c18` AS `c18`,`t1`.`c19` AS `c19`,`t1`.`c20` AS `c20`,`t1`.`c21` AS `c21`,`t1`.`c22` AS `c22`,`t1`.`c23` AS `c23`,`t1`.`c24` AS `c24`,`t1`.`c25` AS `c25`,`t1`.`c26` AS `c26`,`t1`.`c27` AS `c27`,`t1`.`c28` AS `c28`,`t1`.`c29` AS `c29`,`t1`.`c30` AS `c30`,`t1`.`c31` AS `c31`,`t1`.`c32` AS `c32`,`t1`.`c33` AS `c33`,`t1`.`c34` AS `c34`,`t1`.`c35` AS `c35`,`t1`.`c36` AS `c36`,`t1`.`c37` AS `c37`,`t1`.`c38` AS `c38`,`t1`.`c39` AS `c39`,`t1`.`c40` AS `c40`,`t1`.`c41` AS `c41`,`t1`.`c42` AS `c42`,`t1`.`c43` AS `c43`,`t1`.`c44` AS `c44`,`t1`.`c45` AS `c45`,`t1`.`c46` AS `c46`,`t1`.`c47` AS `c47`,`t1`.`c48` AS `c48`,`t1`.`c49` AS `c49`,`t1`.`c50` AS `c50`,`t1`.`c51` AS `c51`,`t1`.`c52` AS `c52`,`t1`.`c53` AS `c53`,`t1`.`c54` AS `c54`,`t1`.`c55` AS `c55`,`t1`.`c56` AS `c56`,`t1`.`c57` AS `c57`,`t1`.`c58` AS `c58`,`t1`.`c59` AS `c59`,`t1`.`c60` AS `c60`,`t1`.`c61` AS `c61`,`t1`.`c62` AS `c62`,`t1`.`c63` AS `c63`,`t1`.`c64` AS `c64` from `t1` order by `t1`.`c1`" + } + ] + } + }, + { + "join_optimization": { + "select#": 1, + "steps": [ + { + "substitute_generated_columns": { + } + }, + { + "table_dependencies": [ + { + "table": "`t1`", + "row_may_be_null": false, + "map_bit": 0, + "depends_on_map_bits": [ + ] + } + ] + }, + { + "rows_estimation": [ + { + "table": "`t1`", + "table_scan": { + "rows": 1, + "cost": 0.25 + } + } + ] + }, + { + "considered_execution_plans": [ + { + "plan_prefix": [ + ], + "table": "`t1`", + "best_access_path": { + "considered_access_paths": [ + { + "rows_to_scan": 1, + "access_type": "scan", + "resulting_rows": 1, + "cost": 0.35, + "chosen": true, + "use_tmp_table": true + } + ] + }, + "condition_filtering_pct": 100, + "rows_for_plan": 1, + "cost_for_plan": 0.35, + "sort_cost": 1, + "new_cost_for_plan": 1.35, + "chosen": true + } + ] + }, + { + "attaching_conditions_to_tables": { + "original_condition": null, + "attached_conditions_computation": [ + ], + "attached_conditions_summary": [ + { + "table": "`t1`", + "attached": null + } + ] + } + }, + { + "optimizing_distinct_group_by_order_by": { + "simplifying_order_by": { + "original_clause": "`t1`.`c1`", + "items": [ + { + "item": "`t1`.`c1`" + } + ], + "resulting_clause_is_simple": true, + "resulting_clause": "`t1`.`c1`" + } + } + }, + { + "finalizing_table_conditions": [ + ] + }, + { + "refine_plan": [ + { + "table": "`t1`" + } + ] + }, + { + "considering_tmp_tables": [ + { + "adding_sort_to_table": "t1" + } + ] + } + ] + } + }, + { + "make_parallel_query_plan": { + "select#": 1, + "detail": [ + { + "table": "`t1`", + "degree of parallel": 4, + "unknown_key_1": { + "considering_tmp_tables": [ + { + "adding_tmp_table_in_plan_at_position": 0, + "cause": "output_for_parallel_query", + "filesort": { + "adding_sort_to_table": "" + } + } + ] + } + } + ] + } + }, + { + "join_execution": { + "select#": 1, + "steps": [ + ] + } + } + ] +} 0 0 +SET @@sort_buffer_size = 8 + 15 * (65535 + 1024 + 8); +select * from t1 order by c1; +c1 c2 c3 c4 c5 c6 c7 c8 c9 c10 c11 c12 c13 c14 c15 c16 c17 c18 c19 c20 c21 c22 c23 c24 c25 c26 c27 c28 c29 c30 c31 c32 c33 c34 c35 c36 c37 c38 c39 c40 c41 c42 c43 c44 c45 c46 c47 c48 c49 c50 c51 c52 c53 c54 c55 c56 c57 c58 c59 c60 c61 c62 c63 c64 +SELECT * FROM information_schema.OPTIMIZER_TRACE; +QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES +select * from t1 order by c1 { + "steps": [ + { + "join_preparation": { + "select#": 1, + "steps": [ + { + "expanded_query": "/* select#1 */ select `t1`.`c1` AS `c1`,`t1`.`c2` AS `c2`,`t1`.`c3` AS `c3`,`t1`.`c4` AS `c4`,`t1`.`c5` AS `c5`,`t1`.`c6` AS `c6`,`t1`.`c7` AS `c7`,`t1`.`c8` AS `c8`,`t1`.`c9` AS `c9`,`t1`.`c10` AS `c10`,`t1`.`c11` AS `c11`,`t1`.`c12` AS `c12`,`t1`.`c13` AS `c13`,`t1`.`c14` AS `c14`,`t1`.`c15` AS `c15`,`t1`.`c16` AS `c16`,`t1`.`c17` AS `c17`,`t1`.`c18` AS `c18`,`t1`.`c19` AS `c19`,`t1`.`c20` AS `c20`,`t1`.`c21` AS `c21`,`t1`.`c22` AS `c22`,`t1`.`c23` AS `c23`,`t1`.`c24` AS `c24`,`t1`.`c25` AS `c25`,`t1`.`c26` AS `c26`,`t1`.`c27` AS `c27`,`t1`.`c28` AS `c28`,`t1`.`c29` AS `c29`,`t1`.`c30` AS `c30`,`t1`.`c31` AS `c31`,`t1`.`c32` AS `c32`,`t1`.`c33` AS `c33`,`t1`.`c34` AS `c34`,`t1`.`c35` AS `c35`,`t1`.`c36` AS `c36`,`t1`.`c37` AS `c37`,`t1`.`c38` AS `c38`,`t1`.`c39` AS `c39`,`t1`.`c40` AS `c40`,`t1`.`c41` AS `c41`,`t1`.`c42` AS `c42`,`t1`.`c43` AS `c43`,`t1`.`c44` AS `c44`,`t1`.`c45` AS `c45`,`t1`.`c46` AS `c46`,`t1`.`c47` AS `c47`,`t1`.`c48` AS `c48`,`t1`.`c49` AS `c49`,`t1`.`c50` AS `c50`,`t1`.`c51` AS `c51`,`t1`.`c52` AS `c52`,`t1`.`c53` AS `c53`,`t1`.`c54` AS `c54`,`t1`.`c55` AS `c55`,`t1`.`c56` AS `c56`,`t1`.`c57` AS `c57`,`t1`.`c58` AS `c58`,`t1`.`c59` AS `c59`,`t1`.`c60` AS `c60`,`t1`.`c61` AS `c61`,`t1`.`c62` AS `c62`,`t1`.`c63` AS `c63`,`t1`.`c64` AS `c64` from `t1` order by `t1`.`c1`" + } + ] + } + }, + { + "join_optimization": { + "select#": 1, + "steps": [ + { + "substitute_generated_columns": { + } + }, + { + "table_dependencies": [ + { + "table": "`t1`", + "row_may_be_null": false, + "map_bit": 0, + "depends_on_map_bits": [ + ] + } + ] + }, + { + "rows_estimation": [ + { + "table": "`t1`", + "table_scan": { + "rows": 1, + "cost": 0.25 + } + } + ] + }, + { + "considered_execution_plans": [ + { + "plan_prefix": [ + ], + "table": "`t1`", + "best_access_path": { + "considered_access_paths": [ + { + "rows_to_scan": 1, + "access_type": "scan", + "resulting_rows": 1, + "cost": 0.35, + "chosen": true, + "use_tmp_table": true + } + ] + }, + "condition_filtering_pct": 100, + "rows_for_plan": 1, + "cost_for_plan": 0.35, + "sort_cost": 1, + "new_cost_for_plan": 1.35, + "chosen": true + } + ] + }, + { + "attaching_conditions_to_tables": { + "original_condition": null, + "attached_conditions_computation": [ + ], + "attached_conditions_summary": [ + { + "table": "`t1`", + "attached": null + } + ] + } + }, + { + "optimizing_distinct_group_by_order_by": { + "simplifying_order_by": { + "original_clause": "`t1`.`c1`", + "items": [ + { + "item": "`t1`.`c1`" + } + ], + "resulting_clause_is_simple": true, + "resulting_clause": "`t1`.`c1`" + } + } + }, + { + "finalizing_table_conditions": [ + ] + }, + { + "refine_plan": [ + { + "table": "`t1`" + } + ] + }, + { + "considering_tmp_tables": [ + { + "adding_sort_to_table": "t1" + } + ] + } + ] + } + }, + { + "make_parallel_query_plan": { + "select#": 1, + "detail": [ + { + "table": "`t1`", + "degree of parallel": 4, + "unknown_key_1": { + "considering_tmp_tables": [ + { + "adding_tmp_table_in_plan_at_position": 0, + "cause": "output_for_parallel_query", + "filesort": { + "adding_sort_to_table": "" + } + } + ] + } + } + ] + } + }, + { + "join_execution": { + "select#": 1, + "steps": [ + ] + } + } + ] +} 0 0 +SET @@sort_buffer_size= @save_sort_buffer_size; +DROP TABLE t1; +SET innodb_strict_mode=off; +CREATE TABLE t1 ( +c1 CHAR(255) NOT NULL DEFAULT '', +c2 CHAR(255) NOT NULL DEFAULT '', +c3 CHAR(255) NOT NULL DEFAULT '', +c4 CHAR(255) NOT NULL DEFAULT '', +c5 CHAR(255) NOT NULL DEFAULT '', +c6 CHAR(255) NOT NULL DEFAULT '', +c7 CHAR(255) NOT NULL DEFAULT '', +c8 CHAR(255) NOT NULL DEFAULT '', +c9 CHAR(255) NOT NULL DEFAULT '', +c10 CHAR(255) NOT NULL DEFAULT '', +c11 CHAR(255) NOT NULL DEFAULT '', +c12 CHAR(255) NOT NULL DEFAULT '', +c13 CHAR(255) NOT NULL DEFAULT '', +c14 CHAR(255) NOT NULL DEFAULT '', +c15 CHAR(255) NOT NULL DEFAULT '', +c16 CHAR(255) NOT NULL DEFAULT '', +c17 CHAR(255) NOT NULL DEFAULT '', +c18 CHAR(255) NOT NULL DEFAULT '', +c19 CHAR(255) NOT NULL DEFAULT '', +c20 CHAR(255) NOT NULL DEFAULT '', +c21 CHAR(255) NOT NULL DEFAULT '', +c22 CHAR(255) NOT NULL DEFAULT '', +c23 CHAR(255) NOT NULL DEFAULT '', +c24 CHAR(255) NOT NULL DEFAULT '', +c25 CHAR(255) NOT NULL DEFAULT '', +c26 CHAR(255) NOT NULL DEFAULT '', +c27 CHAR(255) NOT NULL DEFAULT '', +c28 CHAR(255) NOT NULL DEFAULT '', +c29 CHAR(255) NOT NULL DEFAULT '', +c30 CHAR(255) NOT NULL DEFAULT '', +c31 CHAR(255) NOT NULL DEFAULT '', +c32 CHAR(255) NOT NULL DEFAULT '', +c33 CHAR(255) NOT NULL DEFAULT '', +c34 CHAR(255) NOT NULL DEFAULT '', +c35 CHAR(255) NOT NULL DEFAULT '', +c36 CHAR(255) NOT NULL DEFAULT '', +c37 CHAR(255) NOT NULL DEFAULT '', +c38 CHAR(255) NOT NULL DEFAULT '', +c39 CHAR(255) NOT NULL DEFAULT '', +c40 CHAR(255) NOT NULL DEFAULT '', +c41 CHAR(255) NOT NULL DEFAULT '', +c42 CHAR(255) NOT NULL DEFAULT '', +c43 CHAR(255) NOT NULL DEFAULT '', +c44 CHAR(255) NOT NULL DEFAULT '', +c45 CHAR(255) NOT NULL DEFAULT '', +c46 CHAR(255) NOT NULL DEFAULT '', +c47 CHAR(255) NOT NULL DEFAULT '', +c48 CHAR(255) NOT NULL DEFAULT '', +c49 CHAR(255) NOT NULL DEFAULT '', +c50 CHAR(255) NOT NULL DEFAULT '', +c51 CHAR(255) NOT NULL DEFAULT '', +c52 CHAR(255) NOT NULL DEFAULT '', +c53 CHAR(255) NOT NULL DEFAULT '', +c54 CHAR(255) NOT NULL DEFAULT '', +c55 CHAR(255) NOT NULL DEFAULT '', +c56 CHAR(255) NOT NULL DEFAULT '', +c57 CHAR(255) NOT NULL DEFAULT '', +c58 CHAR(255) NOT NULL DEFAULT '', +c59 CHAR(255) NOT NULL DEFAULT '', +c60 CHAR(255) NOT NULL DEFAULT '', +c61 CHAR(255) NOT NULL DEFAULT '', +c62 CHAR(255) NOT NULL DEFAULT '', +c63 CHAR(255) NOT NULL DEFAULT '', +c64 CHAR(255) NOT NULL DEFAULT '', +c65 CHAR(255) NOT NULL DEFAULT '', +c66 CHAR(255) NOT NULL DEFAULT '', +c67 CHAR(255) NOT NULL DEFAULT '', +c68 CHAR(255) NOT NULL DEFAULT '', +c69 CHAR(255) NOT NULL DEFAULT '', +c70 CHAR(255) NOT NULL DEFAULT '', +c71 CHAR(255) NOT NULL DEFAULT '', +c72 CHAR(255) NOT NULL DEFAULT '', +c73 CHAR(255) NOT NULL DEFAULT '', +c74 CHAR(255) NOT NULL DEFAULT '', +c75 CHAR(255) NOT NULL DEFAULT '', +c76 CHAR(255) NOT NULL DEFAULT '', +c77 CHAR(255) NOT NULL DEFAULT '', +c78 CHAR(255) NOT NULL DEFAULT '', +c79 CHAR(255) NOT NULL DEFAULT '', +c80 CHAR(255) NOT NULL DEFAULT '', +c81 CHAR(255) NOT NULL DEFAULT '', +c82 CHAR(255) NOT NULL DEFAULT '', +c83 CHAR(255) NOT NULL DEFAULT '', +c84 CHAR(255) NOT NULL DEFAULT '', +c85 CHAR(255) NOT NULL DEFAULT '', +c86 CHAR(255) NOT NULL DEFAULT '', +c87 CHAR(255) NOT NULL DEFAULT '', +c88 CHAR(255) NOT NULL DEFAULT '', +c89 CHAR(255) NOT NULL DEFAULT '', +c90 CHAR(255) NOT NULL DEFAULT '', +c91 CHAR(255) NOT NULL DEFAULT '', +c92 CHAR(255) NOT NULL DEFAULT '', +c93 CHAR(255) NOT NULL DEFAULT '', +c94 CHAR(255) NOT NULL DEFAULT '', +c95 CHAR(255) NOT NULL DEFAULT '', +c96 CHAR(255) NOT NULL DEFAULT '', +c97 CHAR(255) NOT NULL DEFAULT '', +c98 CHAR(255) NOT NULL DEFAULT '', +c99 CHAR(255) NOT NULL DEFAULT '', +c100 CHAR(255) NOT NULL DEFAULT '', +c101 CHAR(255) NOT NULL DEFAULT '', +c102 CHAR(255) NOT NULL DEFAULT '', +c103 CHAR(255) NOT NULL DEFAULT '', +c104 CHAR(255) NOT NULL DEFAULT '', +c105 CHAR(255) NOT NULL DEFAULT '', +c106 CHAR(255) NOT NULL DEFAULT '', +c107 CHAR(255) NOT NULL DEFAULT '', +c108 CHAR(255) NOT NULL DEFAULT '', +c109 CHAR(255) NOT NULL DEFAULT '', +c110 CHAR(255) NOT NULL DEFAULT '', +c111 CHAR(255) NOT NULL DEFAULT '', +c112 CHAR(255) NOT NULL DEFAULT '', +c113 CHAR(255) NOT NULL DEFAULT '', +c114 CHAR(255) NOT NULL DEFAULT '', +c115 CHAR(255) NOT NULL DEFAULT '', +c116 CHAR(255) NOT NULL DEFAULT '', +c117 CHAR(255) NOT NULL DEFAULT '', +c118 CHAR(255) NOT NULL DEFAULT '', +c119 CHAR(255) NOT NULL DEFAULT '', +c120 CHAR(255) NOT NULL DEFAULT '', +c121 CHAR(255) NOT NULL DEFAULT '', +c122 CHAR(255) NOT NULL DEFAULT '', +c123 CHAR(255) NOT NULL DEFAULT '', +c124 CHAR(255) NOT NULL DEFAULT '', +c125 CHAR(255) NOT NULL DEFAULT '', +c126 CHAR(255) NOT NULL DEFAULT '', +c127 CHAR(255) NOT NULL DEFAULT '', +c128 CHAR(255) NOT NULL DEFAULT '', +c129 CHAR(255) NOT NULL DEFAULT '', +c130 CHAR(255) NOT NULL DEFAULT '', +c131 CHAR(255) NOT NULL DEFAULT '', +c132 CHAR(255) NOT NULL DEFAULT '', +c133 CHAR(255) NOT NULL DEFAULT '', +c134 CHAR(255) NOT NULL DEFAULT '', +c135 CHAR(255) NOT NULL DEFAULT '', +c136 CHAR(255) NOT NULL DEFAULT '', +c137 CHAR(255) NOT NULL DEFAULT '', +c138 CHAR(255) NOT NULL DEFAULT '', +c139 CHAR(255) NOT NULL DEFAULT '', +c140 CHAR(255) NOT NULL DEFAULT '', +c141 CHAR(255) NOT NULL DEFAULT '', +c142 CHAR(255) NOT NULL DEFAULT '', +c143 CHAR(255) NOT NULL DEFAULT '', +c144 CHAR(255) NOT NULL DEFAULT '', +c145 CHAR(255) NOT NULL DEFAULT '', +c146 CHAR(255) NOT NULL DEFAULT '', +c147 CHAR(255) NOT NULL DEFAULT '', +c148 CHAR(255) NOT NULL DEFAULT '', +c149 CHAR(255) NOT NULL DEFAULT '', +c150 CHAR(255) NOT NULL DEFAULT '', +c151 CHAR(255) NOT NULL DEFAULT '', +c152 CHAR(255) NOT NULL DEFAULT '', +c153 CHAR(255) NOT NULL DEFAULT '', +c154 CHAR(255) NOT NULL DEFAULT '', +c155 CHAR(255) NOT NULL DEFAULT '', +c156 CHAR(255) NOT NULL DEFAULT '', +c157 CHAR(255) NOT NULL DEFAULT '', +c158 CHAR(255) NOT NULL DEFAULT '', +c159 CHAR(255) NOT NULL DEFAULT '', +c160 CHAR(255) NOT NULL DEFAULT '', +c161 CHAR(255) NOT NULL DEFAULT '', +c162 CHAR(255) NOT NULL DEFAULT '', +c163 CHAR(255) NOT NULL DEFAULT '', +c164 CHAR(255) NOT NULL DEFAULT '', +c165 CHAR(255) NOT NULL DEFAULT '', +c166 CHAR(255) NOT NULL DEFAULT '', +c167 CHAR(255) NOT NULL DEFAULT '', +c168 CHAR(255) NOT NULL DEFAULT '', +c169 CHAR(255) NOT NULL DEFAULT '', +c170 CHAR(255) NOT NULL DEFAULT '', +c171 CHAR(255) NOT NULL DEFAULT '', +c172 CHAR(255) NOT NULL DEFAULT '', +c173 CHAR(255) NOT NULL DEFAULT '', +c174 CHAR(255) NOT NULL DEFAULT '', +c175 CHAR(255) NOT NULL DEFAULT '', +c176 CHAR(255) NOT NULL DEFAULT '', +c177 CHAR(255) NOT NULL DEFAULT '', +c178 CHAR(255) NOT NULL DEFAULT '', +c179 CHAR(255) NOT NULL DEFAULT '', +c180 CHAR(255) NOT NULL DEFAULT '', +c181 CHAR(255) NOT NULL DEFAULT '', +c182 CHAR(255) NOT NULL DEFAULT '', +c183 CHAR(255) NOT NULL DEFAULT '', +c184 CHAR(255) NOT NULL DEFAULT '', +c185 CHAR(255) NOT NULL DEFAULT '', +c186 CHAR(255) NOT NULL DEFAULT '', +c187 CHAR(255) NOT NULL DEFAULT '', +c188 CHAR(255) NOT NULL DEFAULT '', +c189 CHAR(255) NOT NULL DEFAULT '', +c190 CHAR(255) NOT NULL DEFAULT '', +c191 CHAR(255) NOT NULL DEFAULT '', +c192 CHAR(255) NOT NULL DEFAULT '', +c193 CHAR(255) NOT NULL DEFAULT '', +c194 CHAR(255) NOT NULL DEFAULT '', +c195 CHAR(255) NOT NULL DEFAULT '', +c196 CHAR(255) NOT NULL DEFAULT '', +c197 CHAR(255) NOT NULL DEFAULT '', +c198 CHAR(255) NOT NULL DEFAULT '', +c199 CHAR(255) NOT NULL DEFAULT '', +c200 CHAR(255) NOT NULL DEFAULT '', +c201 CHAR(255) NOT NULL DEFAULT '', +c202 CHAR(255) NOT NULL DEFAULT '', +c203 CHAR(255) NOT NULL DEFAULT '', +c204 CHAR(255) NOT NULL DEFAULT '', +c205 CHAR(255) NOT NULL DEFAULT '', +c206 CHAR(255) NOT NULL DEFAULT '', +c207 CHAR(255) NOT NULL DEFAULT '', +c208 CHAR(255) NOT NULL DEFAULT '', +c209 CHAR(255) NOT NULL DEFAULT '', +c210 CHAR(255) NOT NULL DEFAULT '', +c211 CHAR(255) NOT NULL DEFAULT '', +c212 CHAR(255) NOT NULL DEFAULT '', +c213 CHAR(255) NOT NULL DEFAULT '', +c214 CHAR(255) NOT NULL DEFAULT '', +c215 CHAR(255) NOT NULL DEFAULT '', +c216 CHAR(255) NOT NULL DEFAULT '', +c217 CHAR(255) NOT NULL DEFAULT '', +c218 CHAR(255) NOT NULL DEFAULT '', +c219 CHAR(255) NOT NULL DEFAULT '', +c220 CHAR(255) NOT NULL DEFAULT '', +c221 CHAR(255) NOT NULL DEFAULT '', +c222 CHAR(255) NOT NULL DEFAULT '', +c223 CHAR(255) NOT NULL DEFAULT '', +c224 CHAR(255) NOT NULL DEFAULT '', +c225 CHAR(255) NOT NULL DEFAULT '', +c226 CHAR(255) NOT NULL DEFAULT '', +c227 CHAR(255) NOT NULL DEFAULT '', +c228 CHAR(255) NOT NULL DEFAULT '', +c229 CHAR(255) NOT NULL DEFAULT '', +c230 CHAR(255) NOT NULL DEFAULT '', +c231 CHAR(255) NOT NULL DEFAULT '', +c232 CHAR(255) NOT NULL DEFAULT '', +c233 CHAR(255) NOT NULL DEFAULT '', +c234 CHAR(255) NOT NULL DEFAULT '', +c235 CHAR(255) NOT NULL DEFAULT '', +c236 CHAR(255) NOT NULL DEFAULT '', +c237 CHAR(255) NOT NULL DEFAULT '', +c238 CHAR(255) NOT NULL DEFAULT '', +c239 CHAR(255) NOT NULL DEFAULT '', +c240 CHAR(255) NOT NULL DEFAULT '', +c241 CHAR(255) NOT NULL DEFAULT '', +c242 CHAR(255) NOT NULL DEFAULT '', +c243 CHAR(255) NOT NULL DEFAULT '', +c244 CHAR(255) NOT NULL DEFAULT '', +c245 CHAR(255) NOT NULL DEFAULT '', +c246 CHAR(255) NOT NULL DEFAULT '', +c247 CHAR(255) NOT NULL DEFAULT '', +c248 CHAR(255) NOT NULL DEFAULT '', +c249 CHAR(255) NOT NULL DEFAULT '', +c250 CHAR(255) NOT NULL DEFAULT '', +c251 CHAR(255) NOT NULL DEFAULT '', +c252 CHAR(255) NOT NULL DEFAULT '', +c253 CHAR(255) NOT NULL DEFAULT '', +c254 CHAR(255) NOT NULL DEFAULT '', +c255 CHAR(255) NOT NULL DEFAULT '', +c256 CHAR(255) NOT NULL DEFAULT '', +c257 CHAR(254) NOT NULL DEFAULT '' +) ENGINE = INNODB ROW_FORMAT=COMPACT charset latin1; +Warnings: +Warning 139 Row size too large (> 8126). Changing some columns to TEXT or BLOB or using ROW_FORMAT=DYNAMIC or ROW_FORMAT=COMPRESSED may help. In current row format, BLOB prefix of 768 bytes is stored inline. +SELECT * FROM t1 ORDER BY c1; +c1 c2 c3 c4 c5 c6 c7 c8 c9 c10 c11 c12 c13 c14 c15 c16 c17 c18 c19 c20 c21 c22 c23 c24 c25 c26 c27 c28 c29 c30 c31 c32 c33 c34 c35 c36 c37 c38 c39 c40 c41 c42 c43 c44 c45 c46 c47 c48 c49 c50 c51 c52 c53 c54 c55 c56 c57 c58 c59 c60 c61 c62 c63 c64 c65 c66 c67 c68 c69 c70 c71 c72 c73 c74 c75 c76 c77 c78 c79 c80 c81 c82 c83 c84 c85 c86 c87 c88 c89 c90 c91 c92 c93 c94 c95 c96 c97 c98 c99 c100 c101 c102 c103 c104 c105 c106 c107 c108 c109 c110 c111 c112 c113 c114 c115 c116 c117 c118 c119 c120 c121 c122 c123 c124 c125 c126 c127 c128 c129 c130 c131 c132 c133 c134 c135 c136 c137 c138 c139 c140 c141 c142 c143 c144 c145 c146 c147 c148 c149 c150 c151 c152 c153 c154 c155 c156 c157 c158 c159 c160 c161 c162 c163 c164 c165 c166 c167 c168 c169 c170 c171 c172 c173 c174 c175 c176 c177 c178 c179 c180 c181 c182 c183 c184 c185 c186 c187 c188 c189 c190 c191 c192 c193 c194 c195 c196 c197 c198 c199 c200 c201 c202 c203 c204 c205 c206 c207 c208 c209 c210 c211 c212 c213 c214 c215 c216 c217 c218 c219 c220 c221 c222 c223 c224 c225 c226 c227 c228 c229 c230 c231 c232 c233 c234 c235 c236 c237 c238 c239 c240 c241 c242 c243 c244 c245 c246 c247 c248 c249 c250 c251 c252 c253 c254 c255 c256 c257 +SELECT * FROM information_schema.OPTIMIZER_TRACE; +QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES +SELECT * FROM t1 ORDER BY c1 { + "steps": [ + { + "join_preparation": { + "select#": 1, + "steps": [ + { + "expanded_query": "/* select#1 */ select `t1`.`c1` AS `c1`,`t1`.`c2` AS `c2`,`t1`.`c3` AS `c3`,`t1`.`c4` AS `c4`,`t1`.`c5` AS `c5`,`t1`.`c6` AS `c6`,`t1`.`c7` AS `c7`,`t1`.`c8` AS `c8`,`t1`.`c9` AS `c9`,`t1`.`c10` AS `c10`,`t1`.`c11` AS `c11`,`t1`.`c12` AS `c12`,`t1`.`c13` AS `c13`,`t1`.`c14` AS `c14`,`t1`.`c15` AS `c15`,`t1`.`c16` AS `c16`,`t1`.`c17` AS `c17`,`t1`.`c18` AS `c18`,`t1`.`c19` AS `c19`,`t1`.`c20` AS `c20`,`t1`.`c21` AS `c21`,`t1`.`c22` AS `c22`,`t1`.`c23` AS `c23`,`t1`.`c24` AS `c24`,`t1`.`c25` AS `c25`,`t1`.`c26` AS `c26`,`t1`.`c27` AS `c27`,`t1`.`c28` AS `c28`,`t1`.`c29` AS `c29`,`t1`.`c30` AS `c30`,`t1`.`c31` AS `c31`,`t1`.`c32` AS `c32`,`t1`.`c33` AS `c33`,`t1`.`c34` AS `c34`,`t1`.`c35` AS `c35`,`t1`.`c36` AS `c36`,`t1`.`c37` AS `c37`,`t1`.`c38` AS `c38`,`t1`.`c39` AS `c39`,`t1`.`c40` AS `c40`,`t1`.`c41` AS `c41`,`t1`.`c42` AS `c42`,`t1`.`c43` AS `c43`,`t1`.`c44` AS `c44`,`t1`.`c45` AS `c45`,`t1`.`c46` AS `c46`,`t1`.`c47` AS `c47`,`t1`.`c48` AS `c48`,`t1`.`c49` AS `c49`,`t1`.`c50` AS `c50`,`t1`.`c51` AS `c51`,`t1`.`c52` AS `c52`,`t1`.`c53` AS `c53`,`t1`.`c54` AS `c54`,`t1`.`c55` AS `c55`,`t1`.`c56` AS `c56`,`t1`.`c57` AS `c57`,`t1`.`c58` AS `c58`,`t1`.`c59` AS `c59`,`t1`.`c60` AS `c60`,`t1`.`c61` AS `c61`,`t1`.`c62` AS `c62`,`t1`.`c63` AS `c63`,`t1`.`c64` AS `c64`,`t1`.`c65` AS `c65`,`t1`.`c66` AS `c66`,`t1`.`c67` AS `c67`,`t1`.`c68` AS `c68`,`t1`.`c69` AS `c69`,`t1`.`c70` AS `c70`,`t1`.`c71` AS `c71`,`t1`.`c72` AS `c72`,`t1`.`c73` AS `c73`,`t1`.`c74` AS `c74`,`t1`.`c75` AS `c75`,`t1`.`c76` AS `c76`,`t1`.`c77` AS `c77`,`t1`.`c78` AS `c78`,`t1`.`c79` AS `c79`,`t1`.`c80` AS `c80`,`t1`.`c81` AS `c81`,`t1`.`c82` AS `c82`,`t1`.`c83` AS `c83`,`t1`.`c84` AS `c84`,`t1`.`c85` AS `c85`,`t1`.`c86` AS `c86`,`t1`.`c87` AS `c87`,`t1`.`c88` AS `c88`,`t1`.`c89` AS `c89`,`t1`.`c90` AS `c90`,`t1`.`c91` AS `c91`,`t1`.`c92` AS `c92`,`t1`.`c93` AS `c93`,`t1`.`c94` AS `c94`,`t1`.`c95` AS `c95`,`t1`.`c96` AS `c96`,`t1`.`c97` AS `c97`,`t1`.`c98` AS `c98`,`t1`.`c99` AS `c99`,`t1`.`c100` AS `c100`,`t1`.`c101` AS `c101`,`t1`.`c102` AS `c102`,`t1`.`c103` AS `c103`,`t1`.`c104` AS `c104`,`t1`.`c105` AS `c105`,`t1`.`c106` AS `c106`,`t1`.`c107` AS `c107`,`t1`.`c108` AS `c108`,`t1`.`c109` AS `c109`,`t1`.`c110` AS `c110`,`t1`.`c111` AS `c111`,`t1`.`c112` AS `c112`,`t1`.`c113` AS `c113`,`t1`.`c114` AS `c114`,`t1`.`c115` AS `c115`,`t1`.`c116` AS `c116`,`t1`.`c117` AS `c117`,`t1`.`c118` AS `c118`,`t1`.`c119` AS `c119`,`t1`.`c120` AS `c120`,`t1`.`c121` AS `c121`,`t1`.`c122` AS `c122`,`t1`.`c123` AS `c123`,`t1`.`c124` AS `c124`,`t1`.`c125` AS `c125`,`t1`.`c126` AS `c126`,`t1`.`c127` AS `c127`,`t1`.`c128` AS `c128`,`t1`.`c129` AS `c129`,`t1`.`c130` AS `c130`,`t1`.`c131` AS `c131`,`t1`.`c132` AS `c132`,`t1`.`c133` AS `c133`,`t1`.`c134` AS `c134`,`t1`.`c135` AS `c135`,`t1`.`c136` AS `c136`,`t1`.`c137` AS `c137`,`t1`.`c138` AS `c138`,`t1`.`c139` AS `c139`,`t1`.`c140` AS `c140`,`t1`.`c141` AS `c141`,`t1`.`c142` AS `c142`,`t1`.`c143` AS `c143`,`t1`.`c144` AS `c144`,`t1`.`c145` AS `c145`,`t1`.`c146` AS `c146`,`t1`.`c147` AS `c147`,`t1`.`c148` AS `c148`,`t1`.`c149` AS `c149`,`t1`.`c150` AS `c150`,`t1`.`c151` AS `c151`,`t1`.`c152` AS `c152`,`t1`.`c153` AS `c153`,`t1`.`c154` AS `c154`,`t1`.`c155` AS `c155`,`t1`.`c156` AS `c156`,`t1`.`c157` AS `c157`,`t1`.`c158` AS `c158`,`t1`.`c159` AS `c159`,`t1`.`c160` AS `c160`,`t1`.`c161` AS `c161`,`t1`.`c162` AS `c162`,`t1`.`c163` AS `c163`,`t1`.`c164` AS `c164`,`t1`.`c165` AS `c165`,`t1`.`c166` AS `c166`,`t1`.`c167` AS `c167`,`t1`.`c168` AS `c168`,`t1`.`c169` AS `c169`,`t1`.`c170` AS `c170`,`t1`.`c171` AS `c171`,`t1`.`c172` AS `c172`,`t1`.`c173` AS `c173`,`t1`.`c174` AS `c174`,`t1`.`c175` AS `c175`,`t1`.`c176` AS `c176`,`t1`.`c177` AS `c177`,`t1`.`c178` AS `c178`,`t1`.`c179` AS `c179`,`t1`.`c180` AS `c180`,`t1`.`c181` AS `c181`,`t1`.`c182` AS `c182`,`t1`.`c183` AS `c183`,`t1`.`c184` AS `c184`,`t1`.`c185` AS `c185`,`t1`.`c186` AS `c186`,`t1`.`c187` AS `c187`,`t1`.`c188` AS `c188`,`t1`.`c189` AS `c189`,`t1`.`c190` AS `c190`,`t1`.`c191` AS `c191`,`t1`.`c192` AS `c192`,`t1`.`c193` AS `c193`,`t1`.`c194` AS `c194`,`t1`.`c195` AS `c195`,`t1`.`c196` AS `c196`,`t1`.`c197` AS `c197`,`t1`.`c198` AS `c198`,`t1`.`c199` AS `c199`,`t1`.`c200` AS `c200`,`t1`.`c201` AS `c201`,`t1`.`c202` AS `c202`,`t1`.`c203` AS `c203`,`t1`.`c204` AS `c204`,`t1`.`c205` AS `c205`,`t1`.`c206` AS `c206`,`t1`.`c207` AS `c207`,`t1`.`c208` AS `c208`,`t1`.`c209` AS `c209`,`t1`.`c210` AS `c210`,`t1`.`c211` AS `c211`,`t1`.`c212` AS `c212`,`t1`.`c213` AS `c213`,`t1`.`c214` AS `c214`,`t1`.`c215` AS `c215`,`t1`.`c216` AS `c216`,`t1`.`c217` AS `c217`,`t1`.`c218` AS `c218`,`t1`.`c219` AS `c219`,`t1`.`c220` AS `c220`,`t1`.`c221` AS `c221`,`t1`.`c222` AS `c222`,`t1`.`c223` AS `c223`,`t1`.`c224` AS `c224`,`t1`.`c225` AS `c225`,`t1`.`c226` AS `c226`,`t1`.`c227` AS `c227`,`t1`.`c228` AS `c228`,`t1`.`c229` AS `c229`,`t1`.`c230` AS `c230`,`t1`.`c231` AS `c231`,`t1`.`c232` AS `c232`,`t1`.`c233` AS `c233`,`t1`.`c234` AS `c234`,`t1`.`c235` AS `c235`,`t1`.`c236` AS `c236`,`t1`.`c237` AS `c237`,`t1`.`c238` AS `c238`,`t1`.`c239` AS `c239`,`t1`.`c240` AS `c240`,`t1`.`c241` AS `c241`,`t1`.`c242` AS `c242`,`t1`.`c243` AS `c243`,`t1`.`c244` AS `c244`,`t1`.`c245` AS `c245`,`t1`.`c246` AS `c246`,`t1`.`c247` AS `c247`,`t1`.`c248` AS `c248`,`t1`.`c249` AS `c249`,`t1`.`c250` AS `c250`,`t1`.`c251` AS `c251`,`t1`.`c252` AS `c252`,`t1`.`c253` AS `c253`,`t1`.`c254` AS `c254`,`t1`.`c255` AS `c255`,`t1`.`c256` AS `c256`,`t1`.`c257` AS `c257` from `t1` order by `t1`.`c1`" + } + ] + } + }, + { + "join_optimization": { + "select#": 1, + "steps": [ + { + "substitute_generated_columns": { + } + }, + { + "table_dependencies": [ + { + "table": "`t1`", + "row_may_be_null": false, + "map_bit": 0, + "depends_on_map_bits": [ + ] + } + ] + }, + { + "rows_estimation": [ + { + "table": "`t1`", + "table_scan": { + "rows": 1, + "cost": 0.25 + } + } + ] + }, + { + "considered_execution_plans": [ + { + "plan_prefix": [ + ], + "table": "`t1`", + "best_access_path": { + "considered_access_paths": [ + { + "rows_to_scan": 1, + "access_type": "scan", + "resulting_rows": 1, + "cost": 0.35, + "chosen": true, + "use_tmp_table": true + } + ] + }, + "condition_filtering_pct": 100, + "rows_for_plan": 1, + "cost_for_plan": 0.35, + "sort_cost": 1, + "new_cost_for_plan": 1.35, + "chosen": true + } + ] + }, + { + "attaching_conditions_to_tables": { + "original_condition": null, + "attached_conditions_computation": [ + ], + "attached_conditions_summary": [ + { + "table": "`t1`", + "attached": null + } + ] + } + }, + { + "optimizing_distinct_group_by_order_by": { + "simplifying_order_by": { + "original_clause": "`t1`.`c1`", + "items": [ + { + "item": "`t1`.`c1`" + } + ], + "resulting_clause_is_simple": true, + "resulting_clause": "`t1`.`c1`" + } + } + }, + { + "finalizing_table_conditions": [ + ] + }, + { + "refine_plan": [ + { + "table": "`t1`" + } + ] + }, + { + "considering_tmp_tables": [ + { + "adding_sort_to_table": "t1" + } + ] + } + ] + } + }, + { + "make_parallel_query_plan": { + "select#": 1, + "detail": [ + { + "table": "`t1`", + "degree of parallel": 4, + "unknown_key_1": { + "considering_tmp_tables": [ + { + "adding_tmp_table_in_plan_at_position": 0, + "cause": "output_for_parallel_query", + "filesort": { + "adding_sort_to_table": "" + } + } + ] + } + } + ] + } + }, + { + "join_execution": { + "select#": 1, + "steps": [ + ] + } + } + ] +} 0 0 +DROP TABLE t1; diff --git a/mysql-test/suite/find_crud_conditionalclauses_o.result-pq b/mysql-test/suite/find_crud_conditionalclauses_o.result-pq new file mode 100644 index 000000000000..28e3754d662a --- /dev/null +++ b/mysql-test/suite/find_crud_conditionalclauses_o.result-pq @@ -0,0 +1,1469 @@ +============================================== +CRUD FIND CONDITIONAL CLAUSES SCENARIOS +============================================== + +================================================================================ +PREAMBLE +================================================================================ +create user crudfinduser@localhost identified by 'crudfinduser'; +grant all on *.* to crudfinduser@localhost; +================================================================================ +TEST START +================================================================================ +RUN DROP SCHEMA if EXISTS minisakila + +0 rows affected +RUN CREATE SCHEMA minisakila + +1 rows affected +RUN USE minisakila + +0 rows affected +RUN CREATE TABLE actor ( + actor_id int unsigned NOT NULL AUTO_INCREMENT, + first_name varchar(45) NOT NULL, + last_name varchar(45) NOT NULL, + is_active bit(1) NOT NULL, + PRIMARY KEY (actor_id) +) + +0 rows affected +RUN INSERT INTO actor VALUES +(NULL,'Victor','Otero',true), +(NULL,'Gonzalo','Crhystens',false), +(NULL,'Abraham','Vega',true), +(NULL,'Jennifer','Leon',false), +(NULL,'Jhonny','Test',true) + +5 rows affected +last insert id: 1 +Records: 5 Duplicates: 0 Warnings: 0 +Table based scenarios +Find all the rows including all the metadata +send Mysqlx.Crud.Find { + collection { + name: "actor" + schema: "minisakila" + } + data_model: TABLE +} + +Mysqlx.Resultset.ColumnMetaData { + type: UINT + name: "actor_id" + original_name: "actor_id" + table: "actor" + original_table: "actor" + schema: "minisakila" + catalog: "def" + length: 10 + flags: 16 +} + +Mysqlx.Resultset.ColumnMetaData { + type: BYTES + name: "first_name" + original_name: "first_name" + table: "actor" + original_table: "actor" + schema: "minisakila" + catalog: "def" + collation: 255 + length: 180 + flags: 16 +} + +Mysqlx.Resultset.ColumnMetaData { + type: BYTES + name: "last_name" + original_name: "last_name" + table: "actor" + original_table: "actor" + schema: "minisakila" + catalog: "def" + collation: 255 + length: 180 + flags: 16 +} + +Mysqlx.Resultset.ColumnMetaData { + type: BIT + name: "is_active" + original_name: "is_active" + table: "actor" + original_table: "actor" + schema: "minisakila" + catalog: "def" + length: 1 + flags: 16 +} + +Mysqlx.Resultset.Row { + field: "\001" + field: "Victor\000" + field: "Otero\000" + field: "\001" +} + +Mysqlx.Resultset.Row { + field: "\002" + field: "Gonzalo\000" + field: "Crhystens\000" + field: "\000" +} + +Mysqlx.Resultset.Row { + field: "\003" + field: "Abraham\000" + field: "Vega\000" + field: "\001" +} + +Mysqlx.Resultset.Row { + field: "\004" + field: "Jennifer\000" + field: "Leon\000" + field: "\000" +} + +Mysqlx.Resultset.Row { + field: "\005" + field: "Jhonny\000" + field: "Test\000" + field: "\001" +} + +Mysqlx.Resultset.FetchDone { +} + +Mysqlx.Sql.StmtExecuteOk { +} + +Find all the rows without the metadata +send Mysqlx.Crud.Find { + collection { + name: "actor" + schema: "minisakila" + } + data_model: TABLE +} + +actor_id first_name last_name is_active +1 Victor Otero 1 +2 Gonzalo Crhystens 0 +3 Abraham Vega 1 +4 Jennifer Leon 0 +5 Jhonny Test 1 +command ok + Find with limit row count and offset +send Mysqlx.Crud.Find { + collection { + name: "actor" + schema: "minisakila" + } + data_model: TABLE + limit { + row_count: 1 + offset: 3 + } +} + +actor_id first_name last_name is_active +4 Jennifer Leon 0 +command ok +Find with limit row count +send Mysqlx.Crud.Find { + collection { + name: "actor" + schema: "minisakila" + } + data_model: TABLE + limit { + row_count: 4 + } +} + +actor_id first_name last_name is_active +1 Victor Otero 1 +2 Gonzalo Crhystens 0 +3 Abraham Vega 1 +4 Jennifer Leon 0 +command ok +Find specific row with == Operator +send Mysqlx.Crud.Find { + collection { + name: "actor" + schema: "minisakila" + } + data_model: TABLE + criteria { + type: OPERATOR + operator { + name: "==" + param { + type: IDENT + identifier { + name: "actor_id" + } + } + param { + type: LITERAL + literal { + type: V_SINT + v_signed_int: 1 + } + } + } + } +} + +actor_id first_name last_name is_active +1 Victor Otero 1 +command ok +Find specific row with != Operator +send Mysqlx.Crud.Find { + collection { + name: "actor" + schema: "minisakila" + } + data_model: TABLE + criteria { + type: OPERATOR + operator { + name: "!=" + param { + type: IDENT + identifier { + name: "actor_id" + } + } + param { + type: LITERAL + literal { + type: V_SINT + v_signed_int: 1 + } + } + } + } +} + +actor_id first_name last_name is_active +2 Gonzalo Crhystens 0 +3 Abraham Vega 1 +4 Jennifer Leon 0 +5 Jhonny Test 1 +command ok +Find specific row with like Operator +send Mysqlx.Crud.Find { + collection { + name: "actor" + schema: "minisakila" + } + data_model: TABLE + criteria { + type: OPERATOR + operator { + name: "like" + param { + type: IDENT + identifier { + name: "first_name" + } + } + param { + type: LITERAL + literal { + type: V_OCTETS + v_octets { + value: "%on%" + } + } + } + } + } +} + +actor_id first_name last_name is_active +2 Gonzalo Crhystens 0 +5 Jhonny Test 1 +command ok +Find specific row with && and like Operators +send Mysqlx.Crud.Find { + collection { + name: "actor" + schema: "minisakila" + } + data_model: TABLE + criteria { + type: OPERATOR + operator { + name: "&&" + param { + type: OPERATOR + operator { + name: "like" + param { + type: IDENT + identifier { + name: "first_name" + } + } + param { + type: LITERAL + literal { + type: V_OCTETS + v_octets { + value: "%on%" + } + } + } + } + } + param { + type: OPERATOR + operator { + name: "like" + param { + type: IDENT + identifier { + name: "last_name" + } + } + param { + type: LITERAL + literal { + type: V_OCTETS + v_octets { + value: "%ns%" + } + } + } + } + } + } + } +} + +actor_id first_name last_name is_active +2 Gonzalo Crhystens 0 +command ok +Find specific row with || and in Operators +send Mysqlx.Crud.Find { + collection { + name: "actor" + schema: "minisakila" + } + data_model: TABLE + criteria { + type: OPERATOR + operator { + name: "||" + param { + type: OPERATOR + operator { + name: "in" + param { + type: IDENT + identifier { + name: "actor_id" + } + } + param { + type: LITERAL + literal { + type: V_SINT + v_signed_int: 1 + } + } + param { + type: LITERAL + literal { + type: V_SINT + v_signed_int: 2 + } + } + } + } + param { + type: OPERATOR + operator { + name: "like" + param { + type: IDENT + identifier { + name: "first_name" + } + } + param { + type: LITERAL + literal { + type: V_OCTETS + v_octets { + value: "%ham%" + } + } + } + } + } + } + } +} + +actor_id first_name last_name is_active +1 Victor Otero 1 +2 Gonzalo Crhystens 0 +3 Abraham Vega 1 +command ok +Find specific row with not_in Operators +send Mysqlx.Crud.Find { + collection { + name: "actor" + schema: "minisakila" + } + data_model: TABLE + criteria { + type: OPERATOR + operator { + name: "||" + param { + type: OPERATOR + operator { + name: "not_in" + param { + type: IDENT + identifier { + name: "actor_id" + } + } + param { + type: LITERAL + literal { + type: V_SINT + v_signed_int: 1 + } + } + param { + type: LITERAL + literal { + type: V_SINT + v_signed_int: 2 + } + } + } + } + param { + type: OPERATOR + operator { + name: "like" + param { + type: IDENT + identifier { + name: "first_name" + } + } + param { + type: LITERAL + literal { + type: V_OCTETS + v_octets { + value: "%ham%" + } + } + } + } + } + } + } +} + +actor_id first_name last_name is_active +3 Abraham Vega 1 +4 Jennifer Leon 0 +5 Jhonny Test 1 +command ok +Find specific row with &&, <= and >= Operators +send Mysqlx.Crud.Find { + collection { + name: "actor" + schema: "minisakila" + } + data_model: TABLE + criteria { + type: OPERATOR + operator { + name: "&&" + param { + type: OPERATOR + operator { + name: "<=" + param { + type: IDENT + identifier { + name: "actor_id" + } + } + param { + type: LITERAL + literal { + type: V_SINT + v_signed_int: 4 + } + } + } + } + param { + type: OPERATOR + operator { + name: ">=" + param { + type: IDENT + identifier { + name: "actor_id" + } + } + param { + type: LITERAL + literal { + type: V_SINT + v_signed_int: 2 + } + } + } + } + } + } +} + +actor_id first_name last_name is_active +2 Gonzalo Crhystens 0 +3 Abraham Vega 1 +4 Jennifer Leon 0 +command ok +Find specific row with &&, < and > Operators +send Mysqlx.Crud.Find { + collection { + name: "actor" + schema: "minisakila" + } + data_model: TABLE + criteria { + type: OPERATOR + operator { + name: "&&" + param { + type: OPERATOR + operator { + name: "<" + param { + type: IDENT + identifier { + name: "actor_id" + } + } + param { + type: LITERAL + literal { + type: V_SINT + v_signed_int: 4 + } + } + } + } + param { + type: OPERATOR + operator { + name: ">" + param { + type: IDENT + identifier { + name: "actor_id" + } + } + param { + type: LITERAL + literal { + type: V_SINT + v_signed_int: 2 + } + } + } + } + } + } +} + +actor_id first_name last_name is_active +3 Abraham Vega 1 +command ok +Find specific row with like Operator using string +send Mysqlx.Crud.Find { + collection { + name: "actor" + schema: "minisakila" + } + data_model: TABLE + criteria { + type: OPERATOR + operator { + name: "like" + param { + type: IDENT + identifier { + name: "first_name" + } + } + param { + type: LITERAL + literal { + type: V_STRING + v_string { + value: "%on%" + } + } + } + } + } +} + +actor_id first_name last_name is_active +2 Gonzalo Crhystens 0 +5 Jhonny Test 1 +command ok +Find specific row with != Operator with order desc +send Mysqlx.Crud.Find { + collection { + name: "actor" + schema: "minisakila" + } + data_model: TABLE + criteria { + type: OPERATOR + operator { + name: "!=" + param { + type: IDENT + identifier { + name: "first_name" + } + } + param { + type: LITERAL + literal { + type: V_STRING + v_string { + value: "Omar" + } + } + } + } + } + order { + expr { + type: IDENT + identifier { + name: "last_name" + } + } + direction: DESC + } +} + +actor_id first_name last_name is_active +3 Abraham Vega 1 +5 Jhonny Test 1 +1 Victor Otero 1 +4 Jennifer Leon 0 +2 Gonzalo Crhystens 0 +command ok +Find specific row with != Operator with order asc +send Mysqlx.Crud.Find { + collection { + name: "actor" + schema: "minisakila" + } + data_model: TABLE + criteria { + type: OPERATOR + operator { + name: "!=" + param { + type: IDENT + identifier { + name: "first_name" + } + } + param { + type: LITERAL + literal { + type: V_STRING + v_string { + value: "Omar" + } + } + } + } + } + order { + expr { + type: IDENT + identifier { + name: "last_name" + } + } + direction: ASC + } +} + +actor_id first_name last_name is_active +2 Gonzalo Crhystens 0 +4 Jennifer Leon 0 +1 Victor Otero 1 +5 Jhonny Test 1 +3 Abraham Vega 1 +command ok +Find using not available schema name +send Mysqlx.Crud.Find { + collection { + name: "actor" + schema: "noavailableschema" + } + data_model: TABLE + criteria { + type: OPERATOR + operator { + name: "==" + param { + type: IDENT + identifier { + name: "actor_id" + } + } + param { + type: LITERAL + literal { + type: V_SINT + v_signed_int: 1 + } + } + } + } +} + +Got expected error: Unknown database 'noavailableschema' (code 1049) +Find using not available table name +send Mysqlx.Crud.Find { + collection { + name: "notavailableatable" + schema: "minisakila" + } + data_model: TABLE + criteria { + type: OPERATOR + operator { + name: "==" + param { + type: IDENT + identifier { + name: "actor_id" + } + } + param { + type: LITERAL + literal { + type: V_SINT + v_signed_int: 1 + } + } + } + } +} + +Got expected error: Table 'minisakila.notavailableatable' doesn't exist (code 1146) +Find using not available column name +send Mysqlx.Crud.Find { + collection { + name: "actor" + schema: "minisakila" + } + data_model: TABLE + criteria { + type: OPERATOR + operator { + name: "==" + param { + type: IDENT + identifier { + name: "notavailablecolumn" + } + } + param { + type: LITERAL + literal { + type: V_SINT + v_signed_int: 1 + } + } + } + } +} + +Got expected error: Unknown column 'notavailablecolumn' in 'where clause' (code 1054) +Mysqlx.Ok { + msg: "bye!" +} +ok +RUN CREATE SCHEMA mysqlxcoll + +1 rows affected + +command ok +RUN USE mysqlxcoll + +0 rows affected +RUN INSERT INTO maincoll (doc) values + ('{"_id": "1", "name": "Victor", "last_name": "Otero","amount": 4.99}'), + ('{"_id": "2", "name": "Gonzalo", "last_name": "Crhystens","amount": 120.57}'), + ('{"_id": "3", "name": "Abraham", "last_name": "Vega","amount": 74.56}'), + ('{"_id": "4", "name": "Jennifer", "last_name": "Leon","amount": 387.14}'), + ('{"_id": "5", "name": "Jhonny", "last_name": "Test","amount": 125.45}') + +5 rows affected +Records: 5 Duplicates: 0 Warnings: 0 +Collection based scenarios +Find all the rows including all metadata +send Mysqlx.Crud.Find { + collection { + name: "maincoll" + schema: "mysqlxcoll" + } + data_model: DOCUMENT +} + +Mysqlx.Resultset.ColumnMetaData { + type: BYTES + name: "doc" + original_name: "doc" + table: "maincoll" + original_table: "maincoll" + schema: "mysqlxcoll" + catalog: "def" + collation: 63 + length: 4294967295 + content_type: 2 +} + +Mysqlx.Resultset.Row { + field: "{\"_id\": \"1\", \"name\": \"Victor\", \"amount\": 4.99, \"last_name\": \"Otero\"}\000" +} + +Mysqlx.Resultset.Row { + field: "{\"_id\": \"2\", \"name\": \"Gonzalo\", \"amount\": 120.57, \"last_name\": \"Crhystens\"}\000" +} + +Mysqlx.Resultset.Row { + field: "{\"_id\": \"3\", \"name\": \"Abraham\", \"amount\": 74.56, \"last_name\": \"Vega\"}\000" +} + +Mysqlx.Resultset.Row { + field: "{\"_id\": \"4\", \"name\": \"Jennifer\", \"amount\": 387.14, \"last_name\": \"Leon\"}\000" +} + +Mysqlx.Resultset.Row { + field: "{\"_id\": \"5\", \"name\": \"Jhonny\", \"amount\": 125.45, \"last_name\": \"Test\"}\000" +} + +Mysqlx.Resultset.FetchDone { +} + +Mysqlx.Sql.StmtExecuteOk { +} + +Find all the rows without all metadata +send Mysqlx.Crud.Find { + collection { + name: "maincoll" + schema: "mysqlxcoll" + } + data_model: DOCUMENT +} + +doc +{"_id": "1", "name": "Victor", "amount": 4.99, "last_name": "Otero"} +{"_id": "2", "name": "Gonzalo", "amount": 120.57, "last_name": "Crhystens"} +{"_id": "3", "name": "Abraham", "amount": 74.56, "last_name": "Vega"} +{"_id": "4", "name": "Jennifer", "amount": 387.14, "last_name": "Leon"} +{"_id": "5", "name": "Jhonny", "amount": 125.45, "last_name": "Test"} +command ok + Find with limit row count and offset +send Mysqlx.Crud.Find { + collection { + name: "maincoll" + schema: "mysqlxcoll" + } + data_model: DOCUMENT + limit { + row_count: 2 + offset: 3 + } +} + +doc +{"_id": "4", "name": "Jennifer", "amount": 387.14, "last_name": "Leon"} +{"_id": "5", "name": "Jhonny", "amount": 125.45, "last_name": "Test"} +command ok + Find with limit row count +send Mysqlx.Crud.Find { + collection { + name: "maincoll" + schema: "mysqlxcoll" + } + data_model: DOCUMENT + limit { + row_count: 3 + } +} + +doc +{"_id": "1", "name": "Victor", "amount": 4.99, "last_name": "Otero"} +{"_id": "2", "name": "Gonzalo", "amount": 120.57, "last_name": "Crhystens"} +{"_id": "3", "name": "Abraham", "amount": 74.56, "last_name": "Vega"} +command ok +Find specific row with == Operator +send Mysqlx.Crud.Find { + collection { + name: "maincoll" + schema: "mysqlxcoll" + } + data_model: DOCUMENT + criteria { + type: OPERATOR + operator { + name: "==" + param { + type: IDENT + identifier { + name: "_id" + } + } + param { + type: LITERAL + literal { + type: V_OCTETS + v_octets { + value: "1" + } + } + } + } + } +} + +doc +{"_id": "1", "name": "Victor", "amount": 4.99, "last_name": "Otero"} +command ok +Find specific row with != Operator +send Mysqlx.Crud.Find { + collection { + name: "maincoll" + schema: "mysqlxcoll" + } + data_model: DOCUMENT + criteria { + type: OPERATOR + operator { + name: "!=" + param { + type: IDENT + identifier { + document_path { + type: MEMBER + value: "name" + } + } + } + param { + type: LITERAL + literal { + type: V_OCTETS + v_octets { + value: "Jhonny" + } + } + } + } + } +} + +doc +{"_id": "1", "name": "Victor", "amount": 4.99, "last_name": "Otero"} +{"_id": "2", "name": "Gonzalo", "amount": 120.57, "last_name": "Crhystens"} +{"_id": "3", "name": "Abraham", "amount": 74.56, "last_name": "Vega"} +{"_id": "4", "name": "Jennifer", "amount": 387.14, "last_name": "Leon"} +command ok +Find specific row with like Operator +send Mysqlx.Crud.Find { + collection { + name: "maincoll" + schema: "mysqlxcoll" + } + data_model: DOCUMENT + criteria { + type: OPERATOR + operator { + name: "like" + param { + type: IDENT + identifier { + document_path { + type: MEMBER + value: "name" + } + } + } + param { + type: LITERAL + literal { + type: V_OCTETS + v_octets { + value: "%er%" + } + } + } + } + } +} + +doc +{"_id": "4", "name": "Jennifer", "amount": 387.14, "last_name": "Leon"} +command ok +Find specific row with && and like Operators +send Mysqlx.Crud.Find { + collection { + name: "maincoll" + schema: "mysqlxcoll" + } + data_model: DOCUMENT + criteria { + type: OPERATOR + operator { + name: "&&" + param { + type: OPERATOR + operator { + name: "like" + param { + type: IDENT + identifier { + document_path { + type: MEMBER + value: "name" + } + } + } + param { + type: LITERAL + literal { + type: V_OCTETS + v_octets { + value: "%er%" + } + } + } + } + } + param { + type: OPERATOR + operator { + name: "like" + param { + type: IDENT + identifier { + document_path { + type: MEMBER + value: "last_name" + } + } + } + param { + type: LITERAL + literal { + type: V_OCTETS + v_octets { + value: "%on%" + } + } + } + } + } + } + } +} + +doc +{"_id": "4", "name": "Jennifer", "amount": 387.14, "last_name": "Leon"} +command ok +Find specific row with || and in Operators +send Mysqlx.Crud.Find { + collection { + name: "maincoll" + schema: "mysqlxcoll" + } + data_model: DOCUMENT + criteria { + type: OPERATOR + operator { + name: "||" + param { + type: OPERATOR + operator { + name: "in" + param { + type: IDENT + identifier { + name: "_id" + } + } + param { + type: LITERAL + literal { + type: V_SINT + v_signed_int: 3 + } + } + param { + type: LITERAL + literal { + type: V_SINT + v_signed_int: 4 + } + } + } + } + param { + type: OPERATOR + operator { + name: "like" + param { + type: IDENT + identifier { + document_path { + type: MEMBER + value: "name" + } + } + } + param { + type: LITERAL + literal { + type: V_OCTETS + v_octets { + value: "Gonzalo" + } + } + } + } + } + } + } +} + +doc +{"_id": "2", "name": "Gonzalo", "amount": 120.57, "last_name": "Crhystens"} +{"_id": "3", "name": "Abraham", "amount": 74.56, "last_name": "Vega"} +{"_id": "4", "name": "Jennifer", "amount": 387.14, "last_name": "Leon"} +command ok +Find specific row with not_in Operators +send Mysqlx.Crud.Find { + collection { + name: "maincoll" + schema: "mysqlxcoll" + } + data_model: DOCUMENT + criteria { + type: OPERATOR + operator { + name: "not_in" + param { + type: IDENT + identifier { + name: "_id" + } + } + param { + type: LITERAL + literal { + type: V_OCTETS + v_octets { + value: "1" + } + } + } + param { + type: LITERAL + literal { + type: V_OCTETS + v_octets { + value: "2" + } + } + } + param { + type: LITERAL + literal { + type: V_OCTETS + v_octets { + value: "3" + } + } + } + } + } +} + +doc +{"_id": "4", "name": "Jennifer", "amount": 387.14, "last_name": "Leon"} +{"_id": "5", "name": "Jhonny", "amount": 125.45, "last_name": "Test"} +command ok +Find specific row with &&, <= and >= Operators +send Mysqlx.Crud.Find { + collection { + name: "maincoll" + schema: "mysqlxcoll" + } + data_model: DOCUMENT + criteria { + type: OPERATOR + operator { + name: "&&" + param { + type: OPERATOR + operator { + name: "<=" + param { + type: IDENT + identifier { + document_path { + type: MEMBER + value: "amount" + } + } + } + param { + type: LITERAL + literal { + type: V_DOUBLE + v_double: 120.57 + } + } + } + } + param { + type: OPERATOR + operator { + name: ">=" + param { + type: IDENT + identifier { + document_path { + type: MEMBER + value: "amount" + } + } + } + param { + type: LITERAL + literal { + type: V_DOUBLE + v_double: 4.99 + } + } + } + } + } + } +} + +doc +{"_id": "1", "name": "Victor", "amount": 4.99, "last_name": "Otero"} +{"_id": "2", "name": "Gonzalo", "amount": 120.57, "last_name": "Crhystens"} +{"_id": "3", "name": "Abraham", "amount": 74.56, "last_name": "Vega"} +command ok +Find specific row with &&, < and > Operators +send Mysqlx.Crud.Find { + collection { + name: "maincoll" + schema: "mysqlxcoll" + } + data_model: DOCUMENT + criteria { + type: OPERATOR + operator { + name: "&&" + param { + type: OPERATOR + operator { + name: "<" + param { + type: IDENT + identifier { + document_path { + type: MEMBER + value: "amount" + } + } + } + param { + type: LITERAL + literal { + type: V_DOUBLE + v_double: 120.57 + } + } + } + } + param { + type: OPERATOR + operator { + name: ">" + param { + type: IDENT + identifier { + document_path { + type: MEMBER + value: "amount" + } + } + } + param { + type: LITERAL + literal { + type: V_DOUBLE + v_double: 4.99 + } + } + } + } + } + } +} + +doc +{"_id": "3", "name": "Abraham", "amount": 74.56, "last_name": "Vega"} +command ok +Find with not available schema name +send Mysqlx.Crud.Find { + collection { + name: "maincoll" + schema: "notavailableschema" + } + data_model: DOCUMENT + criteria { + type: OPERATOR + operator { + name: "not_in" + param { + type: IDENT + identifier { + document_path { + type: MEMBER + value: "==" + } + } + } + param { + type: LITERAL + literal { + type: V_OCTETS + v_octets { + value: "1" + } + } + } + } + } +} + +Got expected error: Unknown database 'notavailableschema' (code 1049) +Find with not available table name +send Mysqlx.Crud.Find { + collection { + name: "notavailabletable" + schema: "mysqlxcoll" + } + data_model: DOCUMENT + criteria { + type: OPERATOR + operator { + name: "==" + param { + type: IDENT + identifier { + name: "_id" + } + } + param { + type: LITERAL + literal { + type: V_OCTETS + v_octets { + value: "1" + } + } + } + } + } +} + +Got expected error: Table 'mysqlxcoll.notavailabletable' doesn't exist (code 1146) +Find with not available column name +send Mysqlx.Crud.Find { + collection { + name: "maincoll" + schema: "mysqlxcoll" + } + data_model: DOCUMENT + criteria { + type: OPERATOR + operator { + name: "==" + param { + type: IDENT + identifier { + document_path { + type: MEMBER + value: "notavailablecolumn" + } + } + } + param { + type: LITERAL + literal { + type: V_OCTETS + v_octets { + value: "1" + } + } + } + } + } +} + +doc +command ok +================================================================================ +CLEAN UP +================================================================================ +RUN DROP SCHEMA IF EXISTS minisakila + +1 rows affected +RUN DROP SCHEMA IF EXISTS mysqlxcoll + +1 rows affected +RUN DROP USER crudfinduser@localhost + +0 rows affected +Mysqlx.Ok { + msg: "bye!" +} +ok diff --git a/mysql-test/suite/find_table_find.result-pq b/mysql-test/suite/find_table_find.result-pq new file mode 100644 index 000000000000..4dd3d2b0764f --- /dev/null +++ b/mysql-test/suite/find_table_find.result-pq @@ -0,0 +1,202 @@ +create schema xtest default charset 'utf8mb4'; +RUN use xtest + +0 rows affected +RUN CREATE TABLE `city` ( + `ID` int(11) NOT NULL auto_increment, + `Name` char(35) NOT NULL default '', + `CountryCode` char(3) NOT NULL default '', + `District` char(20) NOT NULL default '', + `Population` int(11) NOT NULL default '0', + PRIMARY KEY (`ID`) +) + +0 rows affected +RUN INSERT INTO `city` VALUES (1,'Kabul','AFG','Kabol',1780000) + +1 rows affected +last insert id: 1 +RUN INSERT INTO `city` VALUES (2,'Qandahar','AFG','Qandahar',237500) + +1 rows affected +last insert id: 2 +RUN INSERT INTO `city` VALUES (3,'Herat','AFG','Herat',186800) + +1 rows affected +last insert id: 3 +RUN INSERT INTO `city` VALUES (4,'Mazar-e-Sharif','AFG','Balkh',127800) + +1 rows affected +last insert id: 4 +RUN INSERT INTO `city` VALUES (5,'Amsterdam','NLD','Noord-Holland',731200) + +1 rows affected +last insert id: 5 +RUN INSERT INTO `city` VALUES (6,'Rotterdam','NLD','Zuid-Holland',593321) + +1 rows affected +last insert id: 6 +RUN INSERT INTO `city` VALUES (7,'Haag','NLD','Zuid-Holland',440900) + +1 rows affected +last insert id: 7 +RUN INSERT INTO `city` VALUES (8,'Utrecht','NLD','Utrecht',234323) + +1 rows affected +last insert id: 8 +RUN INSERT INTO `city` VALUES (9,'Eindhoven','NLD','Noord-Brabant',201843) + +1 rows affected +last insert id: 9 +RUN INSERT INTO `city` VALUES (10,'Tilburg','NLD','Noord-Brabant',193238) + +1 rows affected +last insert id: 10 +RUN INSERT INTO `city` VALUES (11,'Groningen','NLD','Groningen',172701) + +1 rows affected +last insert id: 11 +RUN INSERT INTO `city` VALUES (12,'Breda','NLD','Noord-Brabant',160398) + +1 rows affected +last insert id: 12 +RUN INSERT INTO `city` VALUES (13,'Apeldoorn','NLD','Gelderland',153491) + +1 rows affected +last insert id: 13 +RUN INSERT INTO `city` VALUES (14,'Nijmegen','NLD','Gelderland',152463) + +1 rows affected +last insert id: 14 +RUN INSERT INTO `city` VALUES (15,'Enschede','NLD','Overijssel',149544) + +1 rows affected +last insert id: 15 +RUN INSERT INTO `city` VALUES (16,'Haarlem','NLD','Noord-Holland',148772) + +1 rows affected +last insert id: 16 +send Mysqlx.Crud.Find { + collection { + name: "city" + schema: "xtest" + } + data_model: TABLE + criteria { + type: OPERATOR + operator { + name: "<" + param { + type: IDENT + identifier { + name: "Population" + } + } + param { + type: LITERAL + literal { + type: V_SINT + v_signed_int: 150000 + } + } + } + } +} + +Mysqlx.Resultset.ColumnMetaData { + type: SINT + name: "ID" + original_name: "ID" + table: "city" + original_table: "city" + schema: "xtest" + catalog: "def" + length: 11 + flags: 16 +} + +Mysqlx.Resultset.ColumnMetaData { + type: BYTES + name: "Name" + original_name: "Name" + table: "city" + original_table: "city" + schema: "xtest" + catalog: "def" + collation: 255 + length: 140 + flags: 17 +} + +Mysqlx.Resultset.ColumnMetaData { + type: BYTES + name: "CountryCode" + original_name: "CountryCode" + table: "city" + original_table: "city" + schema: "xtest" + catalog: "def" + collation: 255 + length: 12 + flags: 17 +} + +Mysqlx.Resultset.ColumnMetaData { + type: BYTES + name: "District" + original_name: "District" + table: "city" + original_table: "city" + schema: "xtest" + catalog: "def" + collation: 255 + length: 80 + flags: 17 +} + +Mysqlx.Resultset.ColumnMetaData { + type: SINT + name: "Population" + original_name: "Population" + table: "city" + original_table: "city" + schema: "xtest" + catalog: "def" + length: 11 + flags: 16 +} + +Mysqlx.Resultset.Row { + field: "\010" + field: "Mazar-e-Sharif\000" + field: "AFG\000" + field: "Balkh\000" + field: "\360\314\017" +} + +Mysqlx.Resultset.Row { + field: "\036" + field: "Enschede\000" + field: "NLD\000" + field: "Overijssel\000" + field: "\320\240\022" +} + +Mysqlx.Resultset.Row { + field: " " + field: "Haarlem\000" + field: "NLD\000" + field: "Noord-Holland\000" + field: "\310\224\022" +} + +Mysqlx.Resultset.FetchDone { +} + +Mysqlx.Sql.StmtExecuteOk { +} + +Mysqlx.Ok { + msg: "bye!" +} +ok diff --git a/mysql-test/suite/gcol_keys_innodb.result-pq b/mysql-test/suite/gcol_keys_innodb.result-pq new file mode 100644 index 000000000000..012c77061c11 --- /dev/null +++ b/mysql-test/suite/gcol_keys_innodb.result-pq @@ -0,0 +1,1790 @@ +SET @@session.default_storage_engine = 'InnoDB'; +# - UNIQUE KEY +# - INDEX +# - FULLTEXT INDEX +# - SPATIAL INDEX (not supported) +# - FOREIGN INDEX (partially supported) +# - CHECK (allowed but not used) +# UNIQUE +create table t1 (a int, b int generated always as (a*2) virtual unique); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int DEFAULT NULL, + `b` int GENERATED ALWAYS AS ((`a` * 2)) VIRTUAL, + UNIQUE KEY `b` (`b`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +describe t1; +Field Type Null Key Default Extra +a int YES NULL +b int YES UNI NULL VIRTUAL GENERATED +drop table t1; +create table t1 (a int, b int generated always as (a*2) stored unique); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int DEFAULT NULL, + `b` int GENERATED ALWAYS AS ((`a` * 2)) STORED, + UNIQUE KEY `b` (`b`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +describe t1; +Field Type Null Key Default Extra +a int YES NULL +b int YES UNI NULL STORED GENERATED +drop table t1; +create table t1 (a int, b int generated always as (a*2) virtual, unique key (b)); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int DEFAULT NULL, + `b` int GENERATED ALWAYS AS ((`a` * 2)) VIRTUAL, + UNIQUE KEY `b` (`b`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +describe t1; +Field Type Null Key Default Extra +a int YES NULL +b int YES UNI NULL VIRTUAL GENERATED +drop table t1; +create table t1 (a int, b int generated always as (a*2) stored, unique (b)); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int DEFAULT NULL, + `b` int GENERATED ALWAYS AS ((`a` * 2)) STORED, + UNIQUE KEY `b` (`b`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +describe t1; +Field Type Null Key Default Extra +a int YES NULL +b int YES UNI NULL STORED GENERATED +drop table t1; +create table t1 (a int, b int generated always as (a*2) virtual); +alter table t1 add unique key (b); +drop table t1; +create table t1 (a int, b int generated always as (a*2) stored); +alter table t1 add unique key (b); +drop table t1; +# Testing data manipulation operations involving UNIQUE keys +# on generated columns can be found in: +# - gcol_ins_upd.inc +# - gcol_select.inc +# +# INDEX +create table t1 (a int, b int generated always as (a*2) virtual, index (b)); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int DEFAULT NULL, + `b` int GENERATED ALWAYS AS ((`a` * 2)) VIRTUAL, + KEY `b` (`b`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +describe t1; +Field Type Null Key Default Extra +a int YES NULL +b int YES MUL NULL VIRTUAL GENERATED +drop table t1; +create table t1 (a int, b int generated always as (a*2) virtual, index (a,b)); +drop table t1; +create table t1 (a int, b int generated always as (a*2) stored, index (b)); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int DEFAULT NULL, + `b` int GENERATED ALWAYS AS ((`a` * 2)) STORED, + KEY `b` (`b`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +describe t1; +Field Type Null Key Default Extra +a int YES NULL +b int YES MUL NULL STORED GENERATED +drop table t1; +create table t1 (a int, b int generated always as (a*2) stored, index (a,b)); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int DEFAULT NULL, + `b` int GENERATED ALWAYS AS ((`a` * 2)) STORED, + KEY `a` (`a`,`b`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +describe t1; +Field Type Null Key Default Extra +a int YES MUL NULL +b int YES NULL STORED GENERATED +drop table t1; +create table t1 (a int, b int generated always as (a*2) virtual); +alter table t1 add index (b); +alter table t1 add index (a,b); +drop table t1; +create table t1 (a int, b int generated always as (a*2) stored); +alter table t1 add index (b); +drop table t1; +create table t1 (a int, b int generated always as (a*2) stored); +alter table t1 add index (a,b); +create table t2 like t1; +drop table t2; +drop table t1; +# Testing data manipulation operations involving INDEX +# on generated columns can be found in: +# - gcol_select.inc +# +# TODO: FULLTEXT INDEX +# SPATIAL INDEX +# FOREIGN KEY +# Rejected FK options. +create table t1 (a int, b int generated always as (a+1) stored, +foreign key (b) references t2(a) on update set null); +ERROR HY000: Cannot define foreign key with ON UPDATE SET NULL clause on a generated column. +create table t1 (a int, b int generated always as (a+1) stored, +foreign key (b) references t2(a) on update cascade); +ERROR HY000: Cannot define foreign key with ON UPDATE CASCADE clause on a generated column. +create table t1 (a int, b int generated always as (a+1) stored, +foreign key (b) references t2(a) on delete set null); +ERROR HY000: Cannot define foreign key with ON DELETE SET NULL clause on a generated column. +create table t1 (a int, b int generated always as (a+1) stored); +alter table t1 add foreign key (b) references t2(a) on update set null; +ERROR HY000: Cannot define foreign key with ON UPDATE SET NULL clause on a generated column. +alter table t1 add foreign key (b) references t2(a) on update cascade; +ERROR HY000: Cannot define foreign key with ON UPDATE CASCADE clause on a generated column. +alter table t1 add foreign key (b) references t2(a) on delete set null; +ERROR HY000: Cannot define foreign key with ON DELETE SET NULL clause on a generated column. +drop table t1; +create table t2 (a int primary key); +create table t1 (a int, b int generated always as (a+1) virtual, +foreign key (b) references t2(a)); +ERROR HY000: Foreign key 't1_ibfk_1' uses virtual column 'b' which is not supported. +create table t1 (a int, b int generated always as (a+1) virtual); +alter table t1 add foreign key (b) references t2(a); +ERROR HY000: Foreign key 't1_ibfk_1' uses virtual column 'b' which is not supported. +drop table t1, t2; +# Allowed FK options. +create table t2 (a int primary key, b char(5)); +create table t1 (a int, b int generated always as (a % 10) stored, +foreign key (b) references t2(a) on update restrict); +drop table t1; +create table t1 (a int, b int generated always as (a % 10) stored, +foreign key (b) references t2(a) on update no action); +drop table t1; +create table t1 (a int, b int generated always as (a % 10) stored, +foreign key (b) references t2(a) on delete restrict); +drop table t1; +create table t1 (a int, b int generated always as (a % 10) stored, +foreign key (b) references t2(a) on delete cascade); +drop table t1; +create table t1 (a int, b int generated always as (a % 10) stored, +foreign key (b) references t2(a) on delete no action); +drop table t1,t2; +# +# Bug#20553262: WL8149: ASSERTION `DELSUM+(INT) Y/4-TEMP >= 0' FAILED +# +CREATE TABLE c ( +pk integer AUTO_INCREMENT, +col_datetime_nokey DATETIME /*! NULL */, +col_time_nokey TIME /*! NULL */, +col_datetime_key DATETIME GENERATED ALWAYS AS +(ADDTIME(col_datetime_nokey, col_time_nokey)), +col_time_key TIME GENERATED ALWAYS AS +(ADDTIME(col_datetime_nokey, col_time_nokey)), +col_varchar_nokey VARCHAR(1) /*! NULL */, +PRIMARY KEY (pk), +KEY (col_time_key), +KEY (col_datetime_key)); +INSERT INTO c ( col_time_nokey,col_datetime_nokey,col_varchar_nokey) values +('14:03:03.042673','2001-11-28 00:50:27.051028', 'c'), +('01:46:09.016386','2007-10-09 19:53:04.008332', NULL), +('16:21:18.052408','2001-11-08 21:02:12.009395', 'x'), +('18:56:33.027423','2003-04-01 00:00:00', 'i'); +EXPLAIN SELECT +outr.col_time_key AS x +FROM c as outr +WHERE +outr.col_varchar_nokey in ('c', 'x', 'i') +AND (outr.col_time_key IS NULL OR +outr.col_datetime_key = '2009-09-27'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE outr NULL index_merge col_time_key,col_datetime_key col_time_key,col_datetime_key 4,6 NULL x x Using sort_union(col_time_key,col_datetime_key); Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`outr`.`col_time_key` AS `x` from `test`.`c` `outr` where ((`test`.`outr`.`col_varchar_nokey` in ('c','x','i')) and ((`test`.`outr`.`col_time_key` is null) or (`test`.`outr`.`col_datetime_key` = TIMESTAMP'2009-09-27 00:00:00'))) +SELECT +outr.col_time_key AS x +FROM c AS outr +WHERE +outr.col_varchar_nokey in ('c', 'x', 'i') +AND (outr.col_time_key IS NULL OR +outr.col_datetime_key = '2009-09-27'); +x +DROP TABLE c; +# +# Bug#20913803: WL8149: SIG 11 IN DFIELD_DUP | +# INNOBASE/INCLUDE/DATA0DATA.IC:253 +# +CREATE TABLE A ( +col_varchar_nokey TEXT , +col_varchar_key TEXT GENERATED ALWAYS AS (REPEAT(col_varchar_nokey, 1000)), +KEY (col_varchar_key(50)) +); +INSERT INTO A (col_varchar_nokey) VALUES (''); +CREATE TABLE D ( +pk INTEGER AUTO_INCREMENT, +col_date_nokey BLOB, +col_date_key BLOB GENERATED ALWAYS AS (REPEAT(col_date_nokey,1000)) VIRTUAL, +col_datetime_nokey LONGBLOB, +col_time_nokey LONGTEXT, +col_datetime_key LONGBLOB GENERATED ALWAYS AS (REPEAT(col_datetime_nokey, 1000)), +col_time_key LONGTEXT GENERATED ALWAYS AS (REPEAT(col_datetime_nokey, 1000)), +col_varchar_nokey TEXT, +col_varchar_key TEXT GENERATED ALWAYS AS (REPEAT(col_varchar_nokey, 1000)), +PRIMARY KEY (pk), +KEY (col_varchar_key(50)), +KEY (col_date_key(20)), +KEY (col_time_key(20)), +KEY (col_datetime_key(20)), +KEY (col_varchar_key(10), col_date_key(10), col_time_key(5), col_datetime_key(5)) +); +INSERT INTO D ( +col_date_nokey, +col_time_nokey, +col_datetime_nokey, +col_varchar_nokey +) VALUES ('', '', '', ''),('', '', '', ''); +DELETE FROM OUTR1.* USING D AS OUTR1 RIGHT JOIN A AS OUTR2 ON +( OUTR1 . `col_varchar_nokey` = OUTR2 . `col_varchar_nokey` ); +DROP TABLE IF EXISTS A,D; +# +# Bug#21024896: SIG 11 INNOBASE_ADD_ONE_VIRTUAL | +# INNOBASE/HANDLER/HANDLER0ALTER.CC +# +CREATE TABLE t1 ( +col1 int(11) DEFAULT NULL, +col2 int(11) DEFAULT NULL, +col3 int(11) NOT NULL, +col4 int(11) DEFAULT NULL, +col5 int(11) GENERATED ALWAYS AS (col2 / col2) VIRTUAL, +col7 int(11) GENERATED ALWAYS AS (col5 + col5) VIRTUAL, +col8 int(11) GENERATED ALWAYS AS (col5 * col5) VIRTUAL, +col9 text, +col6 int(11) DEFAULT NULL, +PRIMARY KEY (`col3`), +UNIQUE KEY uidx (`col2`), +KEY idx (`col5`) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1(col1,col2,col3,col4,col9,col6) +VALUES(1,1,0,1,REPEAT(col1,1000),0), (3,2,1,1,REPEAT(col1,1000),NULL); +ALTER TABLE t1 ADD COLUMN extra INT; +DROP TABLE t1; +# +# Bug#21316860: WL8149:INNODB: FAILING ASSERTION: +# TEMPL->CLUST_REC_FIELD_NO != ULINT_UNDEFINED +# +CREATE TABLE t1 ( +pk int(11) NOT NULL, +col_int_nokey int(11), +col_int_key int(11) GENERATED ALWAYS AS (col_int_nokey) VIRTUAL NOT NULL, +col_date_nokey date, +col_date_key date GENERATED ALWAYS AS (col_date_nokey) VIRTUAL NOT NULL, +PRIMARY KEY (pk), +UNIQUE KEY col_int_key (col_int_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +ALTER TABLE t1 DROP COLUMN pk; +DROP TABLE t1; +# Remove the impact on PK choose by index on virtual generated column +CREATE TABLE t1 ( +pk int(11) NOT NULL, +col_int_nokey int(11) DEFAULT NULL, +col_int_key int(11) GENERATED ALWAYS AS (col_int_nokey) VIRTUAL NOT NULL, +UNIQUE KEY col_int_key (col_int_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +ALTER TABLE t1 add unique index idx(pk), algorithm=inplace; +DESC t1; +Field Type Null Key Default Extra +pk int NO PRI NULL +col_int_nokey int YES NULL +col_int_key int NO UNI NULL VIRTUAL GENERATED +DROP TABLE t1; +# +# Bug#21346132: WL8149:INNODB: FAILING ASSERTION: +# PRIMARY_KEY_NO == -1 || PRIMARY_KEY_NO == 0 +# +CREATE TABLE t1 ( +col_int_nokey int(11) NOT NULL, +col_int_key int(11) GENERATED ALWAYS AS (col_int_nokey) NOT NULL, +col_varchar_nokey varchar(1) NOT NULL, +col_varchar_key varchar(2) GENERATED ALWAYS AS (col_varchar_nokey) NOT NULL, +UNIQUE KEY col_int_key (col_int_key), +UNIQUE KEY col_varchar_key (col_varchar_key), +UNIQUE KEY col_int_key_2 (col_int_key,col_varchar_key), +UNIQUE KEY col_varchar_key_2 (col_varchar_key,col_varchar_nokey), +KEY col_int_key_3 (col_int_key,col_int_nokey) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +ALTER TABLE t1 DROP COLUMN col_varchar_key; +Warnings: +Warning 1831 Duplicate index 'col_int_key_2' defined on the table 'test.t1'. This is deprecated and will be disallowed in a future release. +DROP TABLE t1; +# +# Bug#21320151 WL8149: WRONG RESULT WITH INDEX SCAN +# +CREATE TABLE t1 ( +id INTEGER NOT NULL, +b INTEGER GENERATED ALWAYS AS (id+1) VIRTUAL NOT NULL, +UNIQUE KEY (b) +); +INSERT INTO t1 (id) VALUES (2),(3),(4),(5),(6),(7),(8),(9),(10); +EXPLAIN SELECT b FROM t1 FORCE INDEX(b); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index NULL b 4 NULL 9 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`b` AS `b` from `test`.`t1` FORCE INDEX (`b`) +SELECT b FROM t1 FORCE INDEX(b); +b +3 +4 +5 +6 +7 +8 +9 +10 +11 +EXPLAIN SELECT b FROM t1 FORCE INDEX(b) WHERE b BETWEEN 1 AND 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range b b 4 NULL 3 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`b` AS `b` from `test`.`t1` FORCE INDEX (`b`) where (`test`.`t1`.`b` between 1 and 5) +SELECT b FROM t1 FORCE INDEX(b) WHERE b BETWEEN 1 AND 5; +b +3 +4 +5 +DROP TABLE t1; + +# Testing data manipulation operations involving FOREIGN KEY +# on generated columns can be found in: +# - gcol_ins_upd.inc +# - gcol_select.inc +# +# TODO: CHECK +# +# Test how optimizer picks indexes defined on a GC +# +SET optimizer_trace_max_mem_size=1048576; +SET optimizer_trace="enabled=on,one_line=off"; +SET end_markers_in_json="on"; +CREATE TABLE t1 (f1 int, gc int AS (f1 + 1) STORED PRIMARY KEY); +INSERT INTO t1(f1) VALUES (1),(2),(0),(9),(3),(4),(8),(7),(5),(6); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +# Should use index +SELECT * FROM t1 WHERE f1 + 1 > 7; +f1 gc +7 8 +8 9 +9 10 +EXPLAIN SELECT * FROM t1 WHERE f1 + 1 > 7; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range PRIMARY PRIMARY 4 NULL 3 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`f1` AS `f1`,`test`.`t1`.`gc` AS `gc` from `test`.`t1` where (`test`.`t1`.`gc` > 7) +SELECT * FROM information_schema.OPTIMIZER_TRACE; +QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES +EXPLAIN SELECT * FROM t1 WHERE f1 + 1 > 7 { + "steps": [ + { + "join_preparation": { + "select#": 1, + "steps": [ + { + "expanded_query": "/* select#1 */ select `t1`.`f1` AS `f1`,`t1`.`gc` AS `gc` from `t1` where ((`t1`.`f1` + 1) > 7)" + } + ] /* steps */ + } /* join_preparation */ + }, + { + "join_optimization": { + "select#": 1, + "steps": [ + { + "condition_processing": { + "condition": "WHERE", + "original_condition": "((`t1`.`f1` + 1) > 7)", + "steps": [ + { + "transformation": "equality_propagation", + "resulting_condition": "((`t1`.`f1` + 1) > 7)" + }, + { + "transformation": "constant_propagation", + "resulting_condition": "((`t1`.`f1` + 1) > 7)" + }, + { + "transformation": "trivial_condition_removal", + "resulting_condition": "((`t1`.`f1` + 1) > 7)" + } + ] /* steps */ + } /* condition_processing */ + }, + { + "substitute_generated_columns": { + "resulting_condition": "(`t1`.`gc` > 7)" + } /* substitute_generated_columns */ + }, + { + "table_dependencies": [ + { + "table": "`t1`", + "row_may_be_null": false, + "map_bit": 0, + "depends_on_map_bits": [ + ] /* depends_on_map_bits */ + } + ] /* table_dependencies */ + }, + { + "ref_optimizer_key_uses": [ + ] /* ref_optimizer_key_uses */ + }, + { + "rows_estimation": [ + { + "table": "`t1`", + "range_analysis": { + "table_scan": { + "rows": 10, + "cost": 3.35 + } /* table_scan */, + "potential_range_indexes": [ + { + "index": "PRIMARY", + "usable": true, + "key_parts": [ + "gc" + ] /* key_parts */ + } + ] /* potential_range_indexes */, + "setup_range_conditions": [ + ] /* setup_range_conditions */, + "group_index_range": { + "chosen": false, + "cause": "not_group_by_or_distinct" + } /* group_index_range */, + "skip_scan_range": { + "potential_skip_scan_indexes": [ + { + "index": "PRIMARY", + "usable": false, + "cause": "query_references_nonkey_column" + } + ] /* potential_skip_scan_indexes */ + } /* skip_scan_range */, + "analyzing_range_alternatives": { + "range_scan_alternatives": [ + { + "index": "PRIMARY", + "ranges": [ + "7 < gc" + ] /* ranges */, + "index_dives_for_eq_ranges": true, + "rowid_ordered": true, + "using_mrr": false, + "index_only": false, + "rows": 3, + "cost": 0.560618, + "chosen": true + } + ] /* range_scan_alternatives */, + "analyzing_roworder_intersect": { + "usable": false, + "cause": "too_few_roworder_scans" + } /* analyzing_roworder_intersect */ + } /* analyzing_range_alternatives */, + "chosen_range_access_summary": { + "range_access_plan": { + "type": "range_scan", + "index": "PRIMARY", + "rows": 3, + "ranges": [ + "7 < gc" + ] /* ranges */ + } /* range_access_plan */, + "rows_for_plan": 3, + "cost_for_plan": 0.560618, + "chosen": true + } /* chosen_range_access_summary */ + } /* range_analysis */ + } + ] /* rows_estimation */ + }, + { + "considered_execution_plans": [ + { + "plan_prefix": [ + ] /* plan_prefix */, + "table": "`t1`", + "best_access_path": { + "considered_access_paths": [ + { + "rows_to_scan": 3, + "filtering_effect": [ + ] /* filtering_effect */, + "final_filtering_effect": 1, + "access_type": "range", + "range_details": { + "used_index": "PRIMARY" + } /* range_details */, + "resulting_rows": 3, + "cost": 0.860618, + "chosen": true + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 100, + "rows_for_plan": 3, + "cost_for_plan": 0.860618, + "chosen": true + } + ] /* considered_execution_plans */ + }, + { + "attaching_conditions_to_tables": { + "original_condition": "(`t1`.`gc` > 7)", + "attached_conditions_computation": [ + ] /* attached_conditions_computation */, + "attached_conditions_summary": [ + { + "table": "`t1`", + "attached": "(`t1`.`gc` > 7)" + } + ] /* attached_conditions_summary */ + } /* attaching_conditions_to_tables */ + }, + { + "finalizing_table_conditions": [ + { + "table": "`t1`", + "original_table_condition": "(`t1`.`gc` > 7)", + "final_table_condition ": "(`t1`.`gc` > 7)" + } + ] /* finalizing_table_conditions */ + }, + { + "refine_plan": [ + { + "table": "`t1`" + } + ] /* refine_plan */ + } + ] /* steps */ + } /* join_optimization */ + }, + { + "join_explain": { + "select#": 1, + "steps": [ + ] /* steps */ + } /* join_explain */ + } + ] /* steps */ +} 0 0 +SELECT * FROM t1 WHERE f1 + 1 = 7; +f1 gc +6 7 +EXPLAIN SELECT * FROM t1 WHERE f1 + 1 = 7; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select '6' AS `f1`,'7' AS `gc` from `test`.`t1` where true +SELECT * FROM t1 WHERE f1 + 1 IN (7,5); +f1 gc +4 5 +6 7 +EXPLAIN SELECT * FROM t1 WHERE f1 + 1 IN(7,5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range PRIMARY PRIMARY 4 NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`f1` AS `f1`,`test`.`t1`.`gc` AS `gc` from `test`.`t1` where (`test`.`t1`.`gc` in (7,5)) +SELECT * FROM t1 WHERE f1 + 1 BETWEEN 5 AND 7; +f1 gc +4 5 +5 6 +6 7 +EXPLAIN SELECT * FROM t1 WHERE f1 + 1 BETWEEN 5 AND 7; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range PRIMARY PRIMARY 4 NULL 3 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`f1` AS `f1`,`test`.`t1`.`gc` AS `gc` from `test`.`t1` where (`test`.`t1`.`gc` between 5 and 7) +# Check that expression isn't transformed for a disabled key +SELECT * FROM t1 IGNORE KEY FOR JOIN(PRIMARY) WHERE f1 + 1 BETWEEN 5 AND 7; +f1 gc +4 5 +5 6 +6 7 +EXPLAIN SELECT * FROM t1 IGNORE KEY FOR JOIN(PRIMARY) WHERE f1 + 1 BETWEEN 5 AND 7; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`f1` AS `f1`,`test`.`t1`.`gc` AS `gc` from `test`.`t1` IGNORE INDEX FOR JOIN (PRIMARY) where ((`test`.`t1`.`f1` + 1) between 5 and 7) +# Check that ORDER BY could be optimized +SELECT * FROM t1 ORDER BY f1 + 1; +f1 gc +0 1 +1 2 +2 3 +3 4 +4 5 +5 6 +6 7 +7 8 +8 9 +9 10 +EXPLAIN SELECT * FROM t1 ORDER BY f1 + 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index NULL PRIMARY 4 NULL 10 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`f1` AS `f1`,`test`.`t1`.`gc` AS `gc` from `test`.`t1` order by (`test`.`t1`.`f1` + 1) +SELECT * FROM information_schema.OPTIMIZER_TRACE; +QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES +EXPLAIN SELECT * FROM t1 ORDER BY f1 + 1 { + "steps": [ + { + "join_preparation": { + "select#": 1, + "steps": [ + { + "expanded_query": "/* select#1 */ select `t1`.`f1` AS `f1`,`t1`.`gc` AS `gc` from `t1` order by (`t1`.`f1` + 1)" + } + ] /* steps */ + } /* join_preparation */ + }, + { + "join_optimization": { + "select#": 1, + "steps": [ + { + "substitute_generated_columns": { + "resulting_ORDER_BY": "`t1`.`gc`" + } /* substitute_generated_columns */ + }, + { + "table_dependencies": [ + { + "table": "`t1`", + "row_may_be_null": false, + "map_bit": 0, + "depends_on_map_bits": [ + ] /* depends_on_map_bits */ + } + ] /* table_dependencies */ + }, + { + "rows_estimation": [ + { + "table": "`t1`", + "table_scan": { + "rows": 10, + "cost": 0.25 + } /* table_scan */ + } + ] /* rows_estimation */ + }, + { + "considered_execution_plans": [ + { + "plan_prefix": [ + ] /* plan_prefix */, + "table": "`t1`", + "best_access_path": { + "considered_access_paths": [ + { + "rows_to_scan": 10, + "access_type": "scan", + "resulting_rows": 10, + "cost": 1.25, + "chosen": true, + "use_tmp_table": true + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 100, + "rows_for_plan": 10, + "cost_for_plan": 1.25, + "sort_cost": 10, + "new_cost_for_plan": 11.25, + "chosen": true + } + ] /* considered_execution_plans */ + }, + { + "attaching_conditions_to_tables": { + "original_condition": null, + "attached_conditions_computation": [ + ] /* attached_conditions_computation */, + "attached_conditions_summary": [ + { + "table": "`t1`", + "attached": null + } + ] /* attached_conditions_summary */ + } /* attaching_conditions_to_tables */ + }, + { + "optimizing_distinct_group_by_order_by": { + "simplifying_order_by": { + "original_clause": "`t1`.`gc`", + "items": [ + { + "item": "`t1`.`gc`" + } + ] /* items */, + "resulting_clause_is_simple": true, + "resulting_clause": "`t1`.`gc`" + } /* simplifying_order_by */ + } /* optimizing_distinct_group_by_order_by */ + }, + { + "reconsidering_access_paths_for_index_ordering": { + "clause": "ORDER BY", + "steps": [ + ] /* steps */, + "index_order_summary": { + "table": "`t1`", + "index_provides_order": true, + "order_direction": "asc", + "index": "PRIMARY", + "plan_changed": true, + "access_type": "index" + } /* index_order_summary */ + } /* reconsidering_access_paths_for_index_ordering */ + }, + { + "finalizing_table_conditions": [ + ] /* finalizing_table_conditions */ + }, + { + "refine_plan": [ + { + "table": "`t1`" + } + ] /* refine_plan */ + }, + { + "considering_tmp_tables": [ + ] /* considering_tmp_tables */ + } + ] /* steps */ + } /* join_optimization */ + }, + { + "join_explain": { + "select#": 1, + "steps": [ + ] /* steps */ + } /* join_explain */ + } + ] /* steps */ +} 0 0 +EXPLAIN SELECT * FROM t1 IGNORE KEY FOR ORDER BY(PRIMARY) ORDER BY f1 + 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`f1` AS `f1`,`test`.`t1`.`gc` AS `gc` from `test`.`t1` IGNORE INDEX FOR ORDER BY (PRIMARY) order by (`test`.`t1`.`f1` + 1) +# Check that GROUP BY could be optimized +SELECT f1 + 1, MAX(GC) FROM t1 GROUP BY f1 + 1; +f1 + 1 MAX(GC) +1 1 +10 10 +2 2 +3 3 +4 4 +5 5 +6 6 +7 7 +8 8 +9 9 +EXPLAIN SELECT f1 + 1, MAX(GC) FROM t1 GROUP BY f1 + 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index PRIMARY PRIMARY 4 NULL 10 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select (`test`.`t1`.`f1` + 1) AS `f1 + 1`,max(`test`.`t1`.`gc`) AS `MAX(GC)` from `test`.`t1` group by (`test`.`t1`.`f1` + 1) +SELECT * FROM information_schema.OPTIMIZER_TRACE; +QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES +EXPLAIN SELECT f1 + 1, MAX(GC) FROM t1 GROUP BY f1 + 1 { + "steps": [ + { + "join_preparation": { + "select#": 1, + "steps": [ + { + "expanded_query": "/* select#1 */ select (`t1`.`f1` + 1) AS `f1 + 1`,max(`t1`.`gc`) AS `MAX(GC)` from `t1` group by (`t1`.`f1` + 1)" + } + ] /* steps */ + } /* join_preparation */ + }, + { + "join_optimization": { + "select#": 1, + "steps": [ + { + "substitute_generated_columns": { + "resulting_GROUP_BY": "`t1`.`gc`" + } /* substitute_generated_columns */ + }, + { + "table_dependencies": [ + { + "table": "`t1`", + "row_may_be_null": false, + "map_bit": 0, + "depends_on_map_bits": [ + ] /* depends_on_map_bits */ + } + ] /* table_dependencies */ + }, + { + "rows_estimation": [ + { + "table": "`t1`", + "const_keys_added": { + "keys": [ + "PRIMARY" + ] /* keys */, + "cause": "group_by" + } /* const_keys_added */, + "range_analysis": { + "table_scan": { + "rows": 10, + "cost": 3.35 + } /* table_scan */, + "potential_range_indexes": [ + { + "index": "PRIMARY", + "usable": true, + "key_parts": [ + "gc" + ] /* key_parts */ + } + ] /* potential_range_indexes */, + "group_index_range": { + "potential_group_range_indexes": [ + { + "index": "PRIMARY", + "usable": false, + "cause": "not_covering" + } + ] /* potential_group_range_indexes */ + } /* group_index_range */, + "skip_scan_range": { + "chosen": false, + "cause": "has_group_by" + } /* skip_scan_range */ + } /* range_analysis */ + } + ] /* rows_estimation */ + }, + { + "considered_execution_plans": [ + { + "plan_prefix": [ + ] /* plan_prefix */, + "table": "`t1`", + "best_access_path": { + "considered_access_paths": [ + { + "rows_to_scan": 10, + "access_type": "scan", + "resulting_rows": 10, + "cost": 1.25, + "chosen": true, + "use_tmp_table": true + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 100, + "rows_for_plan": 10, + "cost_for_plan": 1.25, + "sort_cost": 10, + "new_cost_for_plan": 11.25, + "chosen": true + } + ] /* considered_execution_plans */ + }, + { + "attaching_conditions_to_tables": { + "original_condition": null, + "attached_conditions_computation": [ + ] /* attached_conditions_computation */, + "attached_conditions_summary": [ + { + "table": "`t1`", + "attached": null + } + ] /* attached_conditions_summary */ + } /* attaching_conditions_to_tables */ + }, + { + "optimizing_distinct_group_by_order_by": { + "simplifying_group_by": { + "original_clause": "`t1`.`gc`", + "items": [ + { + "item": "`t1`.`gc`" + } + ] /* items */, + "resulting_clause_is_simple": true, + "resulting_clause": "`t1`.`gc`" + } /* simplifying_group_by */ + } /* optimizing_distinct_group_by_order_by */ + }, + { + "reconsidering_access_paths_for_index_ordering": { + "clause": "GROUP BY", + "steps": [ + ] /* steps */, + "index_order_summary": { + "table": "`t1`", + "index_provides_order": true, + "order_direction": "asc", + "index": "PRIMARY", + "plan_changed": true, + "access_type": "index" + } /* index_order_summary */ + } /* reconsidering_access_paths_for_index_ordering */ + }, + { + "finalizing_table_conditions": [ + ] /* finalizing_table_conditions */ + }, + { + "refine_plan": [ + { + "table": "`t1`" + } + ] /* refine_plan */ + }, + { + "considering_tmp_tables": [ + ] /* considering_tmp_tables */ + } + ] /* steps */ + } /* join_optimization */ + }, + { + "join_explain": { + "select#": 1, + "steps": [ + ] /* steps */ + } /* join_explain */ + } + ] /* steps */ +} 0 0 +EXPLAIN SELECT f1 + 1, MAX(GC) +FROM t1 IGNORE KEY FOR GROUP BY(PRIMARY) GROUP BY f1 + 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 100.00 Using temporary +Warnings: +Note 1003 /* select#1 */ select (`test`.`t1`.`f1` + 1) AS `f1 + 1`,max(`test`.`t1`.`gc`) AS `MAX(GC)` from `test`.`t1` IGNORE INDEX FOR GROUP BY (PRIMARY) group by (`test`.`t1`.`f1` + 1) +# Shouldn't use index +SELECT * FROM t1 WHERE f1 + 1 > 7.0; +f1 gc +7 8 +8 9 +9 10 +EXPLAIN SELECT * FROM t1 WHERE f1 + 1 > 7.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`f1` AS `f1`,`test`.`t1`.`gc` AS `gc` from `test`.`t1` where ((`test`.`t1`.`f1` + 1) > 7.0) +DROP TABLE t1; +# Pick index with proper type +CREATE TABLE t1 (f1 int, +gc_int int AS (f1 + 1) STORED, +gc_date DATE AS (f1 + 1) STORED, +KEY gc_int_idx(gc_int), +KEY gc_date_idx(gc_date)); +INSERT INTO t1(f1) VALUES +(030303),(040404), +(050505),(060606), +(010101),(020202), +(030303),(040404), +(050505),(060606), +(010101),(020202), +(090909),(101010), +(010101),(020202), +(070707),(080808); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +SELECT * FROM t1 WHERE f1 + 1 > 070707; +f1 gc_int gc_date +101010 101011 2010-10-11 +70707 70708 2007-07-08 +80808 80809 2008-08-09 +90909 90910 2009-09-10 +# INT column & index should be picked +EXPLAIN SELECT * FROM t1 WHERE f1 + 1 > 070707; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range gc_int_idx gc_int_idx 5 NULL 4 100.00 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`f1` AS `f1`,`test`.`t1`.`gc_int` AS `gc_int`,`test`.`t1`.`gc_date` AS `gc_date` from `test`.`t1` where (`test`.`t1`.`gc_int` > 70707) +SELECT * FROM t1 WHERE f1 + 1 > CAST(070707 AS DATE); +f1 gc_int gc_date +101010 101011 2010-10-11 +70707 70708 2007-07-08 +80808 80809 2008-08-09 +90909 90910 2009-09-10 +# DATE column & index should be picked +EXPLAIN SELECT * FROM t1 WHERE f1 + 1 > CAST(070707 AS DATE); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range gc_date_idx gc_date_idx 4 NULL 4 100.00 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`f1` AS `f1`,`test`.`t1`.`gc_int` AS `gc_int`,`test`.`t1`.`gc_date` AS `gc_date` from `test`.`t1` where (`test`.`t1`.`gc_date` > (cast(70707 as date))) +DROP TABLE t1; +# +# BUG#21229846: WL8170: SIGNAL 11 IN JOIN::MAKE_SUM_FUNC_LIST +# +CREATE TABLE t1 ( +pk int primary key auto_increment, +col_int_key INTEGER , +col_int_gc_key INT GENERATED ALWAYS AS (col_int_key + 1) STORED, +KEY col_int_gc_key(col_int_gc_key) +); +INSERT INTO t1 ( col_int_key) VALUES (7); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +SELECT table1.col_int_key + 1 AS field1, table2.col_int_key AS field2 +FROM (t1 AS table1 JOIN t1 AS table2 ON (table2.pk = table1.pk)) +ORDER BY field1, field2; +field1 field2 +8 7 +EXPLAIN SELECT table1.col_int_key + 1 AS field1, table2.col_int_key AS field2 +FROM (t1 AS table1 JOIN t1 AS table2 ON (table2.pk = table1.pk)) +ORDER BY field1, field2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE table1 NULL ALL PRIMARY NULL NULL NULL 1 100.00 Using temporary; Using filesort +1 SIMPLE table2 NULL eq_ref PRIMARY PRIMARY 4 test.table1.pk 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select (`test`.`table1`.`col_int_key` + 1) AS `field1`,`test`.`table2`.`col_int_key` AS `field2` from `test`.`t1` `table1` join `test`.`t1` `table2` where (`test`.`table2`.`pk` = `test`.`table1`.`pk`) order by `field1`,`field2` +SELECT table1.col_int_key + 1 AS field1, table2.col_int_key AS field2 +FROM (t1 AS table1 JOIN t1 AS table2 ON (table2.pk = table1.pk)) +GROUP BY field1, field2; +field1 field2 +8 7 +EXPLAIN SELECT table1.col_int_key + 1 AS field1, table2.col_int_key AS field2 +FROM (t1 AS table1 JOIN t1 AS table2 ON (table2.pk = table1.pk)) +GROUP BY field1, field2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE table1 NULL ALL PRIMARY NULL NULL NULL 1 100.00 Using temporary +1 SIMPLE table2 NULL eq_ref PRIMARY PRIMARY 4 test.table1.pk 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select (`test`.`table1`.`col_int_key` + 1) AS `field1`,`test`.`table2`.`col_int_key` AS `field2` from `test`.`t1` `table1` join `test`.`t1` `table2` where (`test`.`table2`.`pk` = `test`.`table1`.`pk`) group by `field1`,`field2` +DROP TABLE t1; +# +# Bug#21391781 ASSERT WHEN RUNNING ALTER TABLE ON A TABLE WITH INDEX +# ON VIRTUAL COLUMN +# +CREATE TABLE t1 ( +col1 INTEGER NOT NULL, +col2 INTEGER NOT NULL, +gcol1 INTEGER GENERATED ALWAYS AS (col1 + col2) VIRTUAL, +col3 INTEGER NOT NULL, +col4 INTEGER NOT NULL, +col5 INTEGER DEFAULT NULL, +col6 INTEGER DEFAULT NULL, +col7 INTEGER DEFAULT NULL, +col8 INTEGER DEFAULT NULL, +col9 INTEGER DEFAULT NULL, +col10 INTEGER DEFAULT NULL, +col11 INTEGER DEFAULT NULL, +col12 INTEGER DEFAULT NULL, +col13 INTEGER DEFAULT NULL, +col14 INTEGER DEFAULT NULL, +col15 INTEGER DEFAULT NULL, +col16 INTEGER DEFAULT NULL, +col17 INTEGER DEFAULT NULL, +col18 INTEGER DEFAULT NULL, +col19 INTEGER DEFAULT NULL, +col20 INTEGER DEFAULT NULL, +col21 INTEGER DEFAULT NULL, +col22 INTEGER DEFAULT NULL, +col23 INTEGER DEFAULT NULL, +col24 INTEGER DEFAULT NULL, +col25 INTEGER DEFAULT NULL, +col26 INTEGER DEFAULT NULL, +col27 INTEGER DEFAULT NULL, +col28 INTEGER DEFAULT NULL, +col29 INTEGER DEFAULT NULL, +col30 INTEGER DEFAULT NULL, +col31 INTEGER DEFAULT NULL, +col32 INTEGER DEFAULT NULL, +col33 INTEGER DEFAULT NULL, +col34 INTEGER DEFAULT NULL, +col35 INTEGER DEFAULT NULL, +col36 INTEGER DEFAULT NULL, +col37 INTEGER DEFAULT NULL, +col38 INTEGER DEFAULT NULL, +col39 INTEGER DEFAULT NULL, +col40 INTEGER DEFAULT NULL, +col41 INTEGER DEFAULT NULL, +col42 INTEGER DEFAULT NULL, +col43 INTEGER DEFAULT NULL, +col44 INTEGER DEFAULT NULL, +col45 INTEGER DEFAULT NULL, +col46 INTEGER DEFAULT NULL, +col47 INTEGER DEFAULT NULL, +col48 INTEGER DEFAULT NULL, +col49 INTEGER DEFAULT NULL, +col50 INTEGER DEFAULT NULL, +col51 INTEGER DEFAULT NULL, +col52 INTEGER DEFAULT NULL, +col53 INTEGER DEFAULT NULL, +col54 INTEGER DEFAULT NULL, +col55 INTEGER DEFAULT NULL, +col56 INTEGER DEFAULT NULL, +col57 INTEGER DEFAULT NULL, +col58 INTEGER DEFAULT NULL, +col59 INTEGER DEFAULT NULL, +col60 INTEGER DEFAULT NULL, +col61 INTEGER DEFAULT NULL, +col62 INTEGER DEFAULT NULL, +col63 INTEGER DEFAULT NULL, +col64 INTEGER DEFAULT NULL, +col65 INTEGER DEFAULT NULL, +gcol2 INTEGER GENERATED ALWAYS AS (col3 / col4) VIRTUAL, +KEY idx1 (gcol1) +); +INSERT INTO t1 (col1, col2, col3, col4) +VALUES (1,1,1,1), (2,2,2,2), (3,3,3,3), (4,4,4,4), (5,5,5,5); +ALTER TABLE t1 ADD COLUMN extra INTEGER; +SELECT gcol1 FROM t1 FORCE INDEX(idx1); +gcol1 +2 +4 +6 +8 +10 +DROP TABLE t1; +CREATE TABLE t1 ( +col1 INTEGER NOT NULL, +col2 INTEGER NOT NULL, +gcol1 INTEGER GENERATED ALWAYS AS (col1 + col2) VIRTUAL, +col3 INTEGER NOT NULL, +col4 INTEGER NOT NULL, +col5 INTEGER DEFAULT NULL, +col6 INTEGER DEFAULT NULL, +col7 INTEGER DEFAULT NULL, +col8 INTEGER DEFAULT NULL, +col9 INTEGER DEFAULT NULL, +col10 INTEGER DEFAULT NULL, +col11 INTEGER DEFAULT NULL, +col12 INTEGER DEFAULT NULL, +col13 INTEGER DEFAULT NULL, +col14 INTEGER DEFAULT NULL, +col15 INTEGER DEFAULT NULL, +col16 INTEGER DEFAULT NULL, +col17 INTEGER DEFAULT NULL, +col18 INTEGER DEFAULT NULL, +col19 INTEGER DEFAULT NULL, +col20 INTEGER DEFAULT NULL, +col21 INTEGER DEFAULT NULL, +col22 INTEGER DEFAULT NULL, +col23 INTEGER DEFAULT NULL, +col24 INTEGER DEFAULT NULL, +col25 INTEGER DEFAULT NULL, +col26 INTEGER DEFAULT NULL, +col27 INTEGER DEFAULT NULL, +col28 INTEGER DEFAULT NULL, +col29 INTEGER DEFAULT NULL, +col30 INTEGER DEFAULT NULL, +col31 INTEGER DEFAULT NULL, +col32 INTEGER DEFAULT NULL, +col33 INTEGER DEFAULT NULL, +col34 INTEGER DEFAULT NULL, +col35 INTEGER DEFAULT NULL, +col36 INTEGER DEFAULT NULL, +col37 INTEGER DEFAULT NULL, +col38 INTEGER DEFAULT NULL, +col39 INTEGER DEFAULT NULL, +col40 INTEGER DEFAULT NULL, +col41 INTEGER DEFAULT NULL, +col42 INTEGER DEFAULT NULL, +col43 INTEGER DEFAULT NULL, +col44 INTEGER DEFAULT NULL, +col45 INTEGER DEFAULT NULL, +col46 INTEGER DEFAULT NULL, +col47 INTEGER DEFAULT NULL, +col48 INTEGER DEFAULT NULL, +col49 INTEGER DEFAULT NULL, +col50 INTEGER DEFAULT NULL, +col51 INTEGER DEFAULT NULL, +col52 INTEGER DEFAULT NULL, +col53 INTEGER DEFAULT NULL, +col54 INTEGER DEFAULT NULL, +col55 INTEGER DEFAULT NULL, +col56 INTEGER DEFAULT NULL, +col57 INTEGER DEFAULT NULL, +col58 INTEGER DEFAULT NULL, +col59 INTEGER DEFAULT NULL, +col60 INTEGER DEFAULT NULL, +col61 INTEGER DEFAULT NULL, +col62 INTEGER DEFAULT NULL, +col63 INTEGER DEFAULT NULL, +col64 INTEGER DEFAULT NULL, +col65 INTEGER DEFAULT NULL, +gcol2 INTEGER GENERATED ALWAYS AS (col3 / col4) VIRTUAL, +KEY idx1 (gcol2) +); +INSERT INTO t1 (col1, col2, col3, col4) +VALUES (1,1,1,1), (2,2,2,2), (3,3,3,3), (4,4,4,4), (5,5,5,5); +ALTER TABLE t1 ADD COLUMN extra INTEGER; +SELECT gcol2 FROM t1 FORCE INDEX(idx1); +gcol2 +1 +1 +1 +1 +1 +DROP TABLE t1; +# +# Bug#21628161 CRASH/MEMORY CORRUPTION ADDING INDEXES TO VIRTUAL COLUMN +# +Warnings: +Warning 3135 'NO_ZERO_DATE', 'NO_ZERO_IN_DATE' and 'ERROR_FOR_DIVISION_BY_ZERO' sql modes should be used with strict mode. They will be merged with strict mode in a future release. +CREATE TABLE t (a INT, +b BOOLEAN GENERATED ALWAYS AS (a+10000) VIRTUAL, +c BLOB GENERATED ALWAYS AS (b=2) VIRTUAL); +INSERT INTO t(a) VALUES (1); +Warnings: +Warning 1264 Out of range value for column 'b' at row 1 +SELECT * FROM t WHERE c = '0'; +a b c +1 127 0 +ALTER TABLE t ADD UNIQUE INDEX (c(1)); +Warnings: +Warning 1264 Out of range value for column 'b' at row 1 +SELECT * FROM t WHERE c = '0'; +a b c +1 127 0 +DROP TABLE t; +# +# Bug#21688115 VIRTUAL COLUMN COMPUTATION SAVE_IN_FIELD() +# DID NOT RETURN TRUE WITH DIVIDE 0 +# +CREATE TABLE t (a INT, b INT, h VARCHAR(10)); +INSERT INTO t VALUES (12, 3, "ss"); +INSERT INTO t VALUES (13, 4, "ss"); +INSERT INTO t VALUES (14, 0, "ss"); +ALTER TABLE t ADD c INT GENERATED ALWAYS AS (a/b) VIRTUAL; +CREATE INDEX idx ON t(c); +ERROR 22012: Division by 0 +CALL mtr.add_suppression("\\[Warning\\] \\[[^]]*\\] InnoDB: Compute virtual column values failed"); +DROP TABLE t; +# +# Bug#21770798 OPTIMIZER DOES NOT USE INDEX FOR GENERATED EXPRESSIONS +# WITH LOGICAL OPERATORS +# +CREATE TABLE t (a INT, b INT, +gc_and INT GENERATED ALWAYS AS (a AND b) STORED, +gc_or INT GENERATED ALWAYS AS (a OR b) STORED, +gc_xor INT GENERATED ALWAYS AS (a XOR b) STORED, +gc_not INT GENERATED ALWAYS AS (NOT a) STORED, +gc_case INT GENERATED ALWAYS AS +(CASE WHEN (a AND b) THEN a ELSE b END) STORED, +INDEX(gc_and), INDEX(gc_or), INDEX(gc_xor), INDEX(gc_not), +INDEX(gc_case)); +INSERT INTO t (a, b) VALUES (0, 0), (0, 1), (1, 0), (1, 1); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +EXPLAIN SELECT a, b FROM t WHERE (a AND b) = 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL ref gc_and gc_and 5 const 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b` from `test`.`t` where (`test`.`t`.`gc_and` = 1) +SELECT a, b FROM t WHERE (a AND b) = 1; +a b +1 1 +EXPLAIN SELECT a, b FROM t WHERE 1 = (a AND b); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL ref gc_and gc_and 5 const 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b` from `test`.`t` where (1 = `test`.`t`.`gc_and`) +SELECT a, b FROM t WHERE 1 = (a AND b); +a b +1 1 +EXPLAIN SELECT a, b FROM t WHERE (a AND b) IN (1, 2, 3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range gc_and gc_and 5 NULL 3 100.00 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b` from `test`.`t` where (`test`.`t`.`gc_and` in (1,2,3)) +SELECT a, b FROM t WHERE (a AND b) IN (1, 2, 3); +a b +1 1 +EXPLAIN SELECT a, b FROM t WHERE (a OR b) = 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL ref gc_or gc_or 5 const 3 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b` from `test`.`t` where (`test`.`t`.`gc_or` = 1) +SELECT a, b FROM t WHERE (a OR b) = 1; +a b +0 1 +1 0 +1 1 +EXPLAIN SELECT a, b FROM t WHERE (a OR b) BETWEEN 1 AND 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range gc_or gc_or 5 NULL 3 100.00 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b` from `test`.`t` where (`test`.`t`.`gc_or` between 1 and 10) +SELECT a, b FROM t WHERE (a OR b) BETWEEN 1 AND 10; +a b +0 1 +1 0 +1 1 +EXPLAIN SELECT a, b FROM t WHERE (a XOR b) = 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL ref gc_xor gc_xor 5 const 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b` from `test`.`t` where (`test`.`t`.`gc_xor` = 1) +SELECT a, b FROM t WHERE (a XOR b) = 1; +a b +0 1 +1 0 +EXPLAIN SELECT a FROM t WHERE (NOT a) = 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL ref gc_not gc_not 5 const 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a` from `test`.`t` where (`test`.`t`.`gc_not` = 1) +SELECT a FROM t WHERE (NOT a) = 1; +a +0 +0 +EXPLAIN SELECT a FROM t WHERE (CASE WHEN (a AND b) THEN a ELSE b END) = 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL ref gc_case gc_case 5 const 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a` from `test`.`t` where (`test`.`t`.`gc_case` = 1) +SELECT a FROM t WHERE (CASE WHEN (a AND b) THEN a ELSE b END) = 1; +a +0 +1 +EXPLAIN SELECT a, b FROM t WHERE 1 = (b AND a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 4 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b` from `test`.`t` where (1 = ((0 <> `test`.`t`.`b`) and (0 <> `test`.`t`.`a`))) +SELECT a, b FROM t WHERE 1 = (b AND a); +a b +1 1 +EXPLAIN SELECT a, b FROM t WHERE 1 = (b OR a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 4 100.00 Using where +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b` from `test`.`t` where (1 = ((0 <> `test`.`t`.`b`) or (0 <> `test`.`t`.`a`))) +Warnings: +SELECT a, b FROM t WHERE 1 = (b OR a); +a b +0 1 +1 0 +1 1 +DROP TABLE t; +# +# Bug#21854241: QUERY USING JSON_EXTRACT() RETURNS WRONG RESULT +# AFTER ADDING VIRTUAL INDEX +# +CREATE TABLE employees ( +data JSON, +name1 VARCHAR(30) AS (JSON_EXTRACT(data, "$.name")) STORED, +name2 VARCHAR(30) AS (JSON_UNQUOTE(JSON_EXTRACT(data, "$.name"))) STORED +); +INSERT INTO employees (data) VALUES('{"id": 1, "name": "Jane"}'); +INSERT INTO employees (data) VALUES('{"id": 2, "name": "Joe"}'); +ANALYZE TABLE employees; +Table Op Msg_type Msg_text +test.employees analyze status OK +EXPLAIN SELECT * FROM employees WHERE JSON_EXTRACT(data, '$.name') = 'Jane'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE employees NULL ALL NULL NULL NULL NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`employees`.`data` AS `data`,`test`.`employees`.`name1` AS `name1`,`test`.`employees`.`name2` AS `name2` from `test`.`employees` where (json_extract(`test`.`employees`.`data`,'$.name') = 'Jane') +SELECT * FROM employees WHERE JSON_EXTRACT(data, '$.name') = 'Jane'; +data name1 name2 +{"id": 1, "name": "Jane"} "Jane" Jane +ALTER TABLE employees ADD INDEX name_idx1(name1); +ANALYZE TABLE employees; +Table Op Msg_type Msg_text +test.employees analyze status OK +EXPLAIN SELECT * FROM employees WHERE JSON_EXTRACT(data, '$.name') = 'Jane'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE employees NULL ALL NULL NULL NULL NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`employees`.`data` AS `data`,`test`.`employees`.`name1` AS `name1`,`test`.`employees`.`name2` AS `name2` from `test`.`employees` where (json_extract(`test`.`employees`.`data`,'$.name') = 'Jane') +SELECT * FROM employees WHERE JSON_EXTRACT(data, '$.name') = 'Jane'; +data name1 name2 +{"id": 1, "name": "Jane"} "Jane" Jane +ALTER TABLE employees ADD INDEX name_idx2(name2); +ANALYZE TABLE employees; +Table Op Msg_type Msg_text +test.employees analyze status OK +EXPLAIN SELECT * FROM employees WHERE JSON_EXTRACT(data, '$.name') = 'Jane'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE employees NULL ref name_idx2 name_idx2 123 const 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`employees`.`data` AS `data`,`test`.`employees`.`name1` AS `name1`,`test`.`employees`.`name2` AS `name2` from `test`.`employees` where (`test`.`employees`.`name2` = 'Jane') +SELECT * FROM employees WHERE JSON_EXTRACT(data, '$.name') = 'Jane'; +data name1 name2 +{"id": 1, "name": "Jane"} "Jane" Jane +DROP TABLE employees; +# +# Bug#22077611 UPDATE .. WHERE JSON_EXTRACT(..) = '..' NOT USING +# VIRTUAL COL INDEX +# +CREATE TABLE t(a INT, b INT, gc INT GENERATED ALWAYS AS (a+1) STORED, KEY(gc)); +INSERT INTO t(a) VALUES (1), (2), (3), (4), (5), (1), (2), (3), (4), (5); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +EXPLAIN UPDATE t SET b = 10 WHERE (a+1) = 3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t NULL range gc gc 5 const 2 100.00 Using where +Warnings: +Note 1003 update `test`.`t` set `test`.`t`.`b` = 10 where (`test`.`t`.`gc` = 3) +UPDATE t SET b = 10 WHERE (a+1) = 3; +SELECT * FROM t ORDER BY a, b; +a b gc +1 NULL 2 +1 NULL 2 +2 10 3 +2 10 3 +3 NULL 4 +3 NULL 4 +4 NULL 5 +4 NULL 5 +5 NULL 6 +5 NULL 6 +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +EXPLAIN UPDATE t SET b = 9 ORDER BY (a+1) LIMIT 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t NULL index NULL gc 5 NULL 1 100.00 Using temporary +Warnings: +Note 1003 update `test`.`t` set `test`.`t`.`b` = 9 order by `test`.`t`.`gc` limit 1 +UPDATE t SET b = 9 ORDER BY (a+1) LIMIT 1; +SELECT * FROM t ORDER BY a, b; +a b gc +1 NULL 2 +1 9 2 +2 10 3 +2 10 3 +3 NULL 4 +3 NULL 4 +4 NULL 5 +4 NULL 5 +5 NULL 6 +5 NULL 6 +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +EXPLAIN DELETE FROM t WHERE (a+1) = 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t NULL range gc gc 5 const 2 100.00 Using where +Warnings: +Note 1003 delete from `test`.`t` where (`test`.`t`.`gc` = 2) +DELETE FROM t WHERE (a+1) = 2; +SELECT * FROM t ORDER BY a, b; +a b gc +2 10 3 +2 10 3 +3 NULL 4 +3 NULL 4 +4 NULL 5 +4 NULL 5 +5 NULL 6 +5 NULL 6 +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +EXPLAIN DELETE FROM t ORDER BY (a+1) LIMIT 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t NULL index NULL gc 5 NULL 1 100.00 NULL +Warnings: +Note 1003 delete from `test`.`t` order by `test`.`t`.`gc` limit 1 +DELETE FROM t ORDER BY (a+1) LIMIT 1; +SELECT * FROM t ORDER BY a, b; +a b gc +2 10 3 +3 NULL 4 +3 NULL 4 +4 NULL 5 +4 NULL 5 +5 NULL 6 +5 NULL 6 +DROP TABLE t; +# +# Bug#22095783: ALTER TABLE ADD COLUMN FAILS WITH OUT +# OF RANGE VALUE ERROR +CREATE TABLE c1(doc JSON,_id VARCHAR(32) GENERATED ALWAYS +AS (JSON_UNQUOTE(JSON_EXTRACT(doc, '$._id'))) STORED NOT NULL UNIQUE); +INSERT INTO c1(doc) VALUES('{"X":10,"_id":9}'); +ALTER TABLE c1 ADD COLUMN vc1 DOUBLE(4, 3) GENERATED +ALWAYS AS (JSON_EXTRACT(doc, '$.X')) VIRTUAL , ADD INDEX IX1 (vc1); +ERROR 22003: Out of range value for column 'vc1' at row 1 +ALTER TABLE c1 ADD vc2 INT(11); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +ALTER TABLE c1 ADD COLUMN vc3 INT(11) GENERATED ALWAYS AS +(JSON_EXTRACT(doc, '$.X')) VIRTUAL , ADD UNIQUE INDEX IX2 (vc3); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +ALTER TABLE c1 drop vc2; +ALTER TABLE c1 ADD vc4 INT(11); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +DROP TABLE c1; +# +# Bug#22810883: ASSERTION FAILED: +# !(USED_TABS & (~READ_TABLES & ~FILTER_FOR_TABLE)) +# +CREATE TABLE t1 (a1 INTEGER GENERATED ALWAYS AS (1 AND 0) STORED, +a2 INTEGER, KEY (a1)); +INSERT INTO t1 VALUES (); +CREATE TABLE t2 (b INTEGER); +INSERT INTO t2 VALUES (1); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +# Used to choose the index on a1 and get wrong results. +EXPLAIN SELECT * FROM t1 WHERE (a2 AND a2) = 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` where (((0 <> `test`.`t1`.`a2`) and (0 <> `test`.`t1`.`a2`)) = 0) +SELECT * FROM t1 WHERE (a2 AND a2) = 0; +a1 a2 +# Used to get assertion or wrong results. +EXPLAIN SELECT * FROM t1 STRAIGHT_JOIN t2 ON b WHERE (b AND b) = 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,`test`.`t2`.`b` AS `b` from `test`.`t1` straight_join `test`.`t2` where ((((0 <> `test`.`t2`.`b`) and (0 <> `test`.`t2`.`b`)) = 1) and (0 <> `test`.`t2`.`b`)) +SELECT * FROM t1 STRAIGHT_JOIN t2 ON b WHERE (b AND b) = 1; +a1 a2 b +0 NULL 1 +DROP TABLE t1, t2; +# +# Bug#24345509: WRONG RESULTS WHEN GCOL INDEX IS USED +# +CREATE TABLE t1 ( +pk INT PRIMARY KEY AUTO_INCREMENT, +i INT, +vc VARCHAR(7), +gc1 VARCHAR(14) GENERATED ALWAYS AS (concat(vc, vc)) VIRTUAL NOT NULL, +gc2 VARCHAR(14) GENERATED ALWAYS AS (concat(gc1, 'x')) VIRTUAL NOT NULL, +KEY gc2_key (gc2), +KEY gc2_key_prefix (gc2(5)) +); +INSERT INTO t1 (i, vc) VALUES +(7, 'xcek'), (3, 'ceksat'), (3, 'eksate'), (3, 'ksatef'), (6, 's'); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT i FROM t1 WHERE gc2 <= 'ksatefksatefx'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range gc2_key,gc2_key_prefix gc2_key 58 NULL 3 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` where (`test`.`t1`.`gc2` <= 'ksatefksatefx') +SELECT i FROM t1 WHERE gc2 <= 'ksatefksatefx'; +i +3 +3 +3 +EXPLAIN SELECT i FROM t1 FORCE INDEX (gc2_key_prefix) +WHERE gc2 <= 'ksatefksatefx'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range gc2_key_prefix gc2_key_prefix 22 NULL 3 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` FORCE INDEX (`gc2_key_prefix`) where (`test`.`t1`.`gc2` <= 'ksatefksatefx') +SELECT i FROM t1 FORCE INDEX (gc2_key_prefix) +WHERE gc2 <= 'ksatefksatefx'; +i +3 +3 +3 +EXPLAIN SELECT COUNT(*) FROM t1 WHERE gc2 <= 'ksatefksatefx'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range gc2_key,gc2_key_prefix gc2_key 58 NULL 3 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`gc2` <= 'ksatefksatefx') +SELECT COUNT(*) FROM t1 WHERE gc2 <= 'ksatefksatefx'; +COUNT(*) +3 +EXPLAIN SELECT COUNT(*) FROM t1 FORCE INDEX (gc2_key_prefix) +WHERE gc2 <= 'ksatefksatefx'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range gc2_key_prefix gc2_key_prefix 22 NULL 3 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` FORCE INDEX (`gc2_key_prefix`) where (`test`.`t1`.`gc2` <= 'ksatefksatefx') +SELECT COUNT(*) FROM t1 FORCE INDEX (gc2_key_prefix) +WHERE gc2 <= 'ksatefksatefx'; +COUNT(*) +3 +CREATE TABLE t2 ( +i INT NOT NULL, +gc INT GENERATED ALWAYS AS (i) VIRTUAL NOT NULL, +KEY (gc) +); +INSERT INTO t2 (i) VALUES (-1), (0), (1), (2); +BEGIN; +SELECT i FROM t2 FORCE INDEX (gc) WHERE gc <= -1; +i +-1 +SELECT gc FROM t2 FORCE INDEX (gc) WHERE gc <= -1; +gc +-1 +COMMIT; +DROP TABLE t1, t2; +# +# Bug#27010089: ASSERTION FAILURE: +# ROW0SEL.CC:2846:TEMPL->MYSQL_COL_LEN == LEN +# +CREATE TABLE t ( +pk INTEGER AUTO_INCREMENT PRIMARY KEY, +col_int_key INTEGER GENERATED ALWAYS AS (1) VIRTUAL, +col_varchar VARCHAR(7) , +col_varchar_key VARCHAR(14) GENERATED ALWAYS AS ('abc') VIRTUAL, +KEY (col_varchar_key(5), col_int_key), +KEY (col_int_key, col_varchar_key)); +INSERT INTO t VALUES (), (); +SELECT 1 FROM t AS alias1 +WHERE EXISTS +(SELECT SQ2_alias1.col_int_key AS SQ2_field1 +FROM t AS SQ2_alias1 JOIN t AS SQ2_alias2 +ON (SQ2_alias2.col_varchar_key = SQ2_alias1.col_varchar_key) +WHERE SQ2_alias1.col_varchar <> alias1.col_varchar AND +SQ2_alias1.col_int_key >= SQ2_alias2.pk); +1 +DROP TABLE t; +# +# Bug#27403367: GENERATED COLUMN EXPRESSIONS IGNORED WITH PREFIX INDEX +# +CREATE TABLE t (vc VARCHAR(100), +gc VARCHAR(100) GENERATED ALWAYS AS (REVERSE(vc)) STORED, +KEY (gc(3))); +INSERT INTO t(vc) VALUES ('a'), ('abc'), ('abcabc'), ('abcdef'); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +EXPLAIN SELECT * FROM t WHERE REVERSE(vc) = 'cba'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL ref gc gc 15 const 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`vc` AS `vc`,`test`.`t`.`gc` AS `gc` from `test`.`t` where (`test`.`t`.`gc` = 'cba') +SELECT * FROM t WHERE REVERSE(vc) = 'cba'; +vc gc +abc cba +EXPLAIN SELECT * FROM t WHERE REVERSE(vc) = 'cbacba'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL ref gc gc 15 const 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`vc` AS `vc`,`test`.`t`.`gc` AS `gc` from `test`.`t` where (`test`.`t`.`gc` = 'cbacba') +SELECT * FROM t WHERE REVERSE(vc) = 'cbacba'; +vc gc +abcabc cbacba +EXPLAIN SELECT * FROM t WHERE REVERSE(vc) BETWEEN 'c' AND 'e'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range gc gc 15 NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`vc` AS `vc`,`test`.`t`.`gc` AS `gc` from `test`.`t` where (`test`.`t`.`gc` between 'c' and 'e') +SELECT * FROM t WHERE REVERSE(vc) BETWEEN 'c' AND 'e'; +vc gc +abc cba +abcabc cbacba +DROP TABLE t; +# +# +# BUG#21365158 WL8149:ASSERTION `!TABLE || (!TABLE->WRITE_SET +# +CREATE TABLE t1 ( +pk INTEGER AUTO_INCREMENT, +col_int_nokey INTEGER NOT NULL, +col_varchar_nokey VARCHAR(1) NOT NULL, +col_varchar_key VARCHAR(2) GENERATED ALWAYS AS +(CONCAT(col_varchar_nokey, col_varchar_nokey)) VIRTUAL not null, +PRIMARY KEY (pk) +); +INSERT INTO t1 ( col_int_nokey, col_varchar_nokey) +VALUES (4, 'b'),(9, 'o'),(4, 'k'),(5, 'a'),(5, 'f'), +(9, 't'),(3, 'c'),(8, 'c'),(0, 'r'),(98, 'k'); +CREATE TABLE t2 ( +pk INTEGER AUTO_INCREMENT, +col_int_nokey INTEGER NOT NULL, +col_varchar_nokey VARCHAR(1) NOT NULL, +col_varchar_key VARCHAR(2) GENERATED ALWAYS AS +(CONCAT(col_varchar_nokey, col_varchar_nokey)) VIRTUAL not null, +PRIMARY KEY (pk), +UNIQUE KEY (col_varchar_key) +); +INSERT INTO t2 ( col_int_nokey, col_varchar_nokey) +VALUES (1, 'c'),(8, 'm'),(9, 'd'), (6, 'y'),(1, 't'), +(2, 's'),(4, 'r'); +SELECT +CONCAT( t2.col_varchar_nokey , t2.col_varchar_nokey ) AS f2, +t1.col_varchar_key AS f5 +FROM +t2 LEFT JOIN t1 ON t2.col_int_nokey > t1.col_int_nokey +ORDER BY f2, f5; +f2 f5 +cc rr +dd aa +dd bb +dd cc +dd cc +dd ff +dd kk +dd rr +mm aa +mm bb +mm cc +mm ff +mm kk +mm rr +rr cc +rr rr +ss rr +tt rr +yy aa +yy bb +yy cc +yy ff +yy kk +yy rr +DROP TABLE t1,t2; +# +DROP VIEW IF EXISTS v1,v2; +DROP TABLE IF EXISTS t1,t2,t3; +DROP PROCEDURE IF EXISTS p1; +DROP FUNCTION IF EXISTS f1; +DROP TRIGGER IF EXISTS trg1; +DROP TRIGGER IF EXISTS trg2; +set sql_warnings = 0; diff --git a/mysql-test/suite/histograms.result-pq b/mysql-test/suite/histograms.result-pq new file mode 100644 index 000000000000..6eb028ada994 --- /dev/null +++ b/mysql-test/suite/histograms.result-pq @@ -0,0 +1,166 @@ +SET optimizer_trace_max_mem_size = 1000000; +SET optimizer_trace="enabled=on"; +SET @path = "$**.filtering_effect"; +CREATE TABLE t1 (col1 INT, col2 INT); +INSERT INTO t1 VALUES (1, 10), (2, 20), (3, 30), (4, 40), (5, 50), (NULL, NULL); +ANALYZE TABLE t1 UPDATE HISTOGRAM ON col1, col2 WITH 2 BUCKETS; +Table Op Msg_type Msg_text +test.t1 histogram status Histogram statistics created for column 'col1'. +test.t1 histogram status Histogram statistics created for column 'col2'. +UPDATE mysql.innodb_table_stats SET n_rows = 6 +WHERE database_name = "test" AND table_name = "t1"; +EXPLAIN SELECT * FROM t1 WHERE col1 < 4; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 6 50.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 6 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col1` AS `col1`,`test`.`t1`.`col2` AS `col2` from `test`.`t1` where (`test`.`t1`.`col1` < 4) +SELECT JSON_EXTRACT(trace, @path) FROM information_schema.OPTIMIZER_TRACE; +JSON_EXTRACT(trace, @path) +[[{"condition": "(`t1`.`col1` < 4)", "histogram_selectivity": 0.5}]] +EXPLAIN SELECT * FROM t1 WHERE col1 > 4; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 6 16.67 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 6 16.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col1` AS `col1`,`test`.`t1`.`col2` AS `col2` from `test`.`t1` where (`test`.`t1`.`col1` > 4) +SELECT JSON_EXTRACT(trace, @path) FROM information_schema.OPTIMIZER_TRACE; +JSON_EXTRACT(trace, @path) +[[{"condition": "(`t1`.`col1` > 4)", "histogram_selectivity": 0.166667}]] +EXPLAIN SELECT * FROM t1 WHERE col1 >= 4; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 6 33.33 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 6 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col1` AS `col1`,`test`.`t1`.`col2` AS `col2` from `test`.`t1` where (`test`.`t1`.`col1` >= 4) +SELECT JSON_EXTRACT(trace, @path) FROM information_schema.OPTIMIZER_TRACE; +JSON_EXTRACT(trace, @path) +[[{"condition": "(`t1`.`col1` >= 4)", "histogram_selectivity": 0.333333}]] +EXPLAIN SELECT * FROM t1 WHERE col1 <= 4; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 6 66.67 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 6 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col1` AS `col1`,`test`.`t1`.`col2` AS `col2` from `test`.`t1` where (`test`.`t1`.`col1` <= 4) +SELECT JSON_EXTRACT(trace, @path) FROM information_schema.OPTIMIZER_TRACE; +JSON_EXTRACT(trace, @path) +[[{"condition": "(`t1`.`col1` <= 4)", "histogram_selectivity": 0.666667}]] +EXPLAIN SELECT * FROM t1 WHERE col1 = 4; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 6 16.67 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 6 16.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col1` AS `col1`,`test`.`t1`.`col2` AS `col2` from `test`.`t1` where (`test`.`t1`.`col1` = 4) +SELECT JSON_EXTRACT(trace, @path) FROM information_schema.OPTIMIZER_TRACE; +JSON_EXTRACT(trace, @path) +[[{"condition": "(`t1`.`col1` = 4)", "histogram_selectivity": 0.166667}]] +EXPLAIN SELECT * FROM t1 WHERE col1 != 4; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 6 66.67 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 6 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col1` AS `col1`,`test`.`t1`.`col2` AS `col2` from `test`.`t1` where (`test`.`t1`.`col1` <> 4) +SELECT JSON_EXTRACT(trace, @path) FROM information_schema.OPTIMIZER_TRACE; +JSON_EXTRACT(trace, @path) +[[{"condition": "(`t1`.`col1` <> 4)", "histogram_selectivity": 0.666667}]] +EXPLAIN SELECT * FROM t1 WHERE col1 <> 4; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 6 66.67 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 6 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col1` AS `col1`,`test`.`t1`.`col2` AS `col2` from `test`.`t1` where (`test`.`t1`.`col1` <> 4) +SELECT JSON_EXTRACT(trace, @path) FROM information_schema.OPTIMIZER_TRACE; +JSON_EXTRACT(trace, @path) +[[{"condition": "(`t1`.`col1` <> 4)", "histogram_selectivity": 0.666667}]] +EXPLAIN SELECT * FROM t1 WHERE col1 BETWEEN 4 AND 6; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 6 33.33 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 6 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col1` AS `col1`,`test`.`t1`.`col2` AS `col2` from `test`.`t1` where (`test`.`t1`.`col1` between 4 and 6) +SELECT JSON_EXTRACT(trace, @path) FROM information_schema.OPTIMIZER_TRACE; +JSON_EXTRACT(trace, @path) +[[{"condition": "(`t1`.`col1` between 4 and 6)", "histogram_selectivity": 0.333333}]] +EXPLAIN SELECT * FROM t1 WHERE col1 NOT BETWEEN 4 AND 6; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 6 50.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 6 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col1` AS `col1`,`test`.`t1`.`col2` AS `col2` from `test`.`t1` where (`test`.`t1`.`col1` not between 4 and 6) +SELECT JSON_EXTRACT(trace, @path) FROM information_schema.OPTIMIZER_TRACE; +JSON_EXTRACT(trace, @path) +[[{"condition": "(`t1`.`col1` not between 4 and 6)", "histogram_selectivity": 0.5}]] +EXPLAIN SELECT * FROM t1 WHERE col1 IS NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 6 16.67 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 6 16.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col1` AS `col1`,`test`.`t1`.`col2` AS `col2` from `test`.`t1` where (`test`.`t1`.`col1` is null) +SELECT JSON_EXTRACT(trace, @path) FROM information_schema.OPTIMIZER_TRACE; +JSON_EXTRACT(trace, @path) +[[{"condition": "(`t1`.`col1` is null)", "histogram_selectivity": 0.166667}]] +EXPLAIN SELECT * FROM t1 WHERE col1 IS NOT NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 6 83.33 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 6 83.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col1` AS `col1`,`test`.`t1`.`col2` AS `col2` from `test`.`t1` where (`test`.`t1`.`col1` is not null) +SELECT JSON_EXTRACT(trace, @path) FROM information_schema.OPTIMIZER_TRACE; +JSON_EXTRACT(trace, @path) +[[{"condition": "(`t1`.`col1` is not null)", "histogram_selectivity": 0.833333}]] +DROP TABLE t1; +# +# Show that histogram selecitivty estimation is printed for other acecss +# methods as well. +# +# Access method: RANGE +CREATE TABLE t1 (col1 INT, col2 INT); +INSERT INTO t1 VALUES (15, 84), (19, 51), (70, 52), (54, 82), (33, 93), (80, 0), +(51, 82), (50, 14), (22, 27), (96, 82), (96, 3), (86, 61), (4, 58), (95, 20), +(28, 56), (64, 99), (10, 85), (30, 81), (13, 85), (28, 94); +CREATE INDEX idx1 ON t1 (col1, col2); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +ANALYZE TABLE t1 UPDATE HISTOGRAM ON col1, col2 WITH 8 BUCKETS; +Table Op Msg_type Msg_text +test.t1 histogram status Histogram statistics created for column 'col1'. +test.t1 histogram status Histogram statistics created for column 'col2'. +EXPLAIN SELECT * FROM t1 WHERE col1 > 10 AND col2 < 88; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 18 80.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range idx1 idx1 5 NULL 18 80.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col1` AS `col1`,`test`.`t1`.`col2` AS `col2` from `test`.`t1` where ((`test`.`t1`.`col1` > 10) and (`test`.`t1`.`col2` < 88)) +SELECT JSON_EXTRACT(trace, @path) FROM information_schema.OPTIMIZER_TRACE; +JSON_EXTRACT(trace, @path) +[[{"condition": "(`t1`.`col2` < 88)", "histogram_selectivity": 0.8}]] +DROP TABLE t1; +# +# Show the difference between the calculated selectivity estimation for +# each predicate and the total calculated selectivity estimation +# +CREATE TABLE t1 (col1 INT); +INSERT INTO t1 VALUES (1), (2), (3), (4), (5), (6), (7), (8); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +ANALYZE TABLE t1 UPDATE HISTOGRAM ON col1 WITH 2 BUCKETS; +Table Op Msg_type Msg_text +test.t1 histogram status Histogram statistics created for column 'col1'. +EXPLAIN SELECT * FROM t1 WHERE col1 > 2 AND col1 <= 7; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 65.62 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 8 65.62 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col1` AS `col1` from `test`.`t1` where ((`test`.`t1`.`col1` > 2) and (`test`.`t1`.`col1` <= 7)) +# Selectivity estimations for each conditions. +SELECT JSON_EXTRACT(trace, @path) FROM information_schema.OPTIMIZER_TRACE; +JSON_EXTRACT(trace, @path) +[[{"condition": "(`t1`.`col1` > 2)", "histogram_selectivity": 0.75}, {"condition": "(`t1`.`col1` <= 7)", "histogram_selectivity": 0.875}]] +# Total calculated selectivity estimation. +SELECT JSON_EXTRACT(trace, "$**.final_filtering_effect") +FROM information_schema.OPTIMIZER_TRACE; +JSON_EXTRACT(trace, "$**.final_filtering_effect") +[0.65625] +DROP TABLE t1; diff --git a/mysql-test/suite/index_large_prefix.result-pq b/mysql-test/suite/index_large_prefix.result-pq new file mode 100644 index 000000000000..524da565d22d --- /dev/null +++ b/mysql-test/suite/index_large_prefix.result-pq @@ -0,0 +1,467 @@ +SET default_storage_engine=InnoDB; +set global innodb_file_per_table=1; +### Test 1 ### +create table worklog5743(a TEXT not null, primary key (a(1000))) charset latin1 ROW_FORMAT=DYNAMIC; +show warnings; +Level Code Message +insert into worklog5743 values(repeat("a", 20000)); +update worklog5743 set a = (repeat("b", 16000)); +create index idx on worklog5743(a(2000)); +show warnings; +Level Code Message +begin; +update worklog5743 set a = (repeat("x", 17000)); +select @@session.transaction_isolation; +@@session.transaction_isolation +REPEATABLE-READ +select a = repeat("x", 17000) from worklog5743; +a = repeat("x", 17000) +0 +select a = repeat("b", 16000) from worklog5743; +a = repeat("b", 16000) +1 +SET SESSION TRANSACTION ISOLATION LEVEL READ UNCOMMITTED; +select @@session.transaction_isolation; +@@session.transaction_isolation +READ-UNCOMMITTED +select a = repeat("x", 17000) from worklog5743; +a = repeat("x", 17000) +1 +rollback; +drop table worklog5743; +### Test 2 ### +create table worklog5743(a1 int, a2 TEXT not null) charset latin1 ROW_FORMAT=DYNAMIC; +show warnings; +Level Code Message +create index idx on worklog5743(a1, a2(2000)); +show warnings; +Level Code Message +insert into worklog5743 values(9, repeat("a", 10000)); +begin; +update worklog5743 set a1 = 1000; +select @@session.transaction_isolation; +@@session.transaction_isolation +REPEATABLE-READ +explain select a1, a2 = repeat("a", 10000) from worklog5743 where a1 = 9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE worklog5743 NULL ref idx idx 5 const 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`worklog5743`.`a1` AS `a1`,(`test`.`worklog5743`.`a2` = convert(repeat('a',10000) using latin1)) AS `a2 = repeat("a", 10000)` from `test`.`worklog5743` where (`test`.`worklog5743`.`a1` = 9) +select a1, a2 = repeat("a", 10000) from worklog5743 where a1 = 9; +a1 a2 = repeat("a", 10000) +9 1 +SET SESSION TRANSACTION ISOLATION LEVEL READ UNCOMMITTED; +select @@session.transaction_isolation; +@@session.transaction_isolation +READ-UNCOMMITTED +select a1, a2 = repeat("a", 10000) from worklog5743 where a1 = 9; +a1 a2 = repeat("a", 10000) +rollback; +drop table worklog5743; +### Test 3 ### +create table worklog5743(a1 int, a2 TEXT not null) ROW_FORMAT=DYNAMIC; +create index idx on worklog5743(a1, a2(50)); +insert into worklog5743 values(9, repeat("a", 10000)); +begin; +update worklog5743 set a1 = 1000; +select @@session.transaction_isolation; +@@session.transaction_isolation +REPEATABLE-READ +explain select a1, a2 = repeat("a", 10000) from worklog5743 where a1 = 9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE worklog5743 NULL ref idx idx 5 const 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`worklog5743`.`a1` AS `a1`,(`test`.`worklog5743`.`a2` = repeat('a',10000)) AS `a2 = repeat("a", 10000)` from `test`.`worklog5743` where (`test`.`worklog5743`.`a1` = 9) +select a1, a2 = repeat("a", 10000) from worklog5743 where a1 = 9; +a1 a2 = repeat("a", 10000) +9 1 +SET SESSION TRANSACTION ISOLATION LEVEL READ UNCOMMITTED; +select @@session.transaction_isolation; +@@session.transaction_isolation +READ-UNCOMMITTED +select a1, a2 = repeat("a", 10000) from worklog5743 where a1 = 9; +a1 a2 = repeat("a", 10000) +rollback; +drop table worklog5743; +### Test 4 ### +create table worklog5743_1(a1 int, a2 TEXT not null) charset latin1 KEY_BLOCK_SIZE=1; +create table worklog5743_2(a1 int, a2 TEXT not null) charset latin1 KEY_BLOCK_SIZE=2; +create table worklog5743_4(a1 int, a2 TEXT not null) charset latin1 KEY_BLOCK_SIZE=4; +create table worklog5743_8(a1 int, a2 TEXT, a3 TEXT) charset latin1 KEY_BLOCK_SIZE=8; +create table worklog5743_16(a1 int, a2 TEXT, a3 TEXT) charset latin1 KEY_BLOCK_SIZE=16; +create index idx2 on worklog5743_1(a2(4000)); +ERROR 42000: Specified key was too long; max key length is 3072 bytes +show warnings; +Level Code Message +Error 1071 Specified key was too long; max key length is 3072 bytes +create index idx3 on worklog5743_1(a2(436)); +ERROR 42000: Row size too large. The maximum row size for the used table type, not counting BLOBs, is 8126. This includes storage overhead, check the manual. You have to change some columns to TEXT or BLOBs +show warnings; +Level Code Message +Error 1118 Row size too large. The maximum row size for the used table type, not counting BLOBs, is 8126. This includes storage overhead, check the manual. You have to change some columns to TEXT or BLOBs +create index idx4 on worklog5743_1(a2(434)); +show warnings; +Level Code Message +create index idx5 on worklog5743_1(a1, a2(430)); +ERROR 42000: Row size too large. The maximum row size for the used table type, not counting BLOBs, is 8126. This includes storage overhead, check the manual. You have to change some columns to TEXT or BLOBs +show warnings; +Level Code Message +Error 1118 Row size too large. The maximum row size for the used table type, not counting BLOBs, is 8126. This includes storage overhead, check the manual. You have to change some columns to TEXT or BLOBs +create index idx6 on worklog5743_1(a1, a2(428)); +show warnings; +Level Code Message +SET sql_mode= ''; +create index idx2 on worklog5743_2(a2(4000)); +ERROR 42000: Row size too large. The maximum row size for the used table type, not counting BLOBs, is 8126. This includes storage overhead, check the manual. You have to change some columns to TEXT or BLOBs +show warnings; +Level Code Message +Warning 1071 Specified key was too long; max key length is 3072 bytes +Error 1118 Row size too large. The maximum row size for the used table type, not counting BLOBs, is 8126. This includes storage overhead, check the manual. You have to change some columns to TEXT or BLOBs +create index idx3 on worklog5743_2(a2(948)); +ERROR 42000: Row size too large. The maximum row size for the used table type, not counting BLOBs, is 8126. This includes storage overhead, check the manual. You have to change some columns to TEXT or BLOBs +show warnings; +Level Code Message +Error 1118 Row size too large. The maximum row size for the used table type, not counting BLOBs, is 8126. This includes storage overhead, check the manual. You have to change some columns to TEXT or BLOBs +create index idx4 on worklog5743_2(a2(946)); +show warnings; +Level Code Message +create index idx5 on worklog5743_2(a1, a2(942)); +ERROR 42000: Row size too large. The maximum row size for the used table type, not counting BLOBs, is 8126. This includes storage overhead, check the manual. You have to change some columns to TEXT or BLOBs +show warnings; +Level Code Message +Error 1118 Row size too large. The maximum row size for the used table type, not counting BLOBs, is 8126. This includes storage overhead, check the manual. You have to change some columns to TEXT or BLOBs +create index idx6 on worklog5743_2(a1, a2(940)); +show warnings; +Level Code Message +create index idx2 on worklog5743_4(a2(4000)); +ERROR 42000: Row size too large. The maximum row size for the used table type, not counting BLOBs, is 8126. This includes storage overhead, check the manual. You have to change some columns to TEXT or BLOBs +show warnings; +Level Code Message +Warning 1071 Specified key was too long; max key length is 3072 bytes +Error 1118 Row size too large. The maximum row size for the used table type, not counting BLOBs, is 8126. This includes storage overhead, check the manual. You have to change some columns to TEXT or BLOBs +create index idx3 on worklog5743_4(a2(1972)); +ERROR 42000: Row size too large. The maximum row size for the used table type, not counting BLOBs, is 8126. This includes storage overhead, check the manual. You have to change some columns to TEXT or BLOBs +show warnings; +Level Code Message +Error 1118 Row size too large. The maximum row size for the used table type, not counting BLOBs, is 8126. This includes storage overhead, check the manual. You have to change some columns to TEXT or BLOBs +create index idx4 on worklog5743_4(a2(1970)); +show warnings; +Level Code Message +create index idx5 on worklog5743_4(a1, a2(1966)); +ERROR 42000: Row size too large. The maximum row size for the used table type, not counting BLOBs, is 8126. This includes storage overhead, check the manual. You have to change some columns to TEXT or BLOBs +show warnings; +Level Code Message +Error 1118 Row size too large. The maximum row size for the used table type, not counting BLOBs, is 8126. This includes storage overhead, check the manual. You have to change some columns to TEXT or BLOBs +create index idx6 on worklog5743_4(a1, a2(1964)); +show warnings; +Level Code Message +create index idx2 on worklog5743_8(a2(3073)); +Warnings: +Warning 1071 Specified key was too long; max key length is 3072 bytes +show warnings; +Level Code Message +Warning 1071 Specified key was too long; max key length is 3072 bytes +create index idx3 on worklog5743_8(a2(3072)); +Warnings: +Warning 1831 Duplicate index 'idx3' defined on the table 'test.worklog5743_8'. This is deprecated and will be disallowed in a future release. +show warnings; +Level Code Message +Warning 1831 Duplicate index 'idx3' defined on the table 'test.worklog5743_8'. This is deprecated and will be disallowed in a future release. +create index idx4 on worklog5743_8(a1, a2(3069)); +ERROR 42000: Specified key was too long; max key length is 3072 bytes +show warnings; +Level Code Message +Error 1071 Specified key was too long; max key length is 3072 bytes +create index idx5 on worklog5743_8(a1, a2(3068)); +show warnings; +Level Code Message +create index idx6 on worklog5743_8(a1, a2(2000), a3(1069)); +ERROR 42000: Specified key was too long; max key length is 3072 bytes +show warnings; +Level Code Message +Error 1071 Specified key was too long; max key length is 3072 bytes +create index idx7 on worklog5743_8(a1, a2(2000), a3(1068)); +show warnings; +Level Code Message +create index idx2 on worklog5743_16(a2(3073)); +Warnings: +Warning 1071 Specified key was too long; max key length is 3072 bytes +show warnings; +Level Code Message +Warning 1071 Specified key was too long; max key length is 3072 bytes +create index idx3 on worklog5743_16(a2(3072)); +Warnings: +Warning 1831 Duplicate index 'idx3' defined on the table 'test.worklog5743_16'. This is deprecated and will be disallowed in a future release. +show warnings; +Level Code Message +Warning 1831 Duplicate index 'idx3' defined on the table 'test.worklog5743_16'. This is deprecated and will be disallowed in a future release. +create index idx4 on worklog5743_16(a1, a2(3069)); +ERROR 42000: Specified key was too long; max key length is 3072 bytes +show warnings; +Level Code Message +Error 1071 Specified key was too long; max key length is 3072 bytes +create index idx5 on worklog5743_16(a1, a2(3068)); +show warnings; +Level Code Message +create index idx6 on worklog5743_16(a1, a2(2000), a3(1069)); +ERROR 42000: Specified key was too long; max key length is 3072 bytes +show warnings; +Level Code Message +Error 1071 Specified key was too long; max key length is 3072 bytes +create index idx7 on worklog5743_16(a1, a2(2000), a3(1068)); +show warnings; +Level Code Message +set sql_mode= default; +insert into worklog5743_1 values(9, repeat("a", 10000)); +insert into worklog5743_2 values(9, repeat("a", 10000)); +insert into worklog5743_4 values(9, repeat("a", 10000)); +insert into worklog5743_8 values(9, repeat("a", 10000), repeat("a", 10000)); +insert into worklog5743_16 values(9, repeat("a", 10000), repeat("a", 10000)); +insert into worklog5743_1 values(2, repeat("b", 10000)); +insert into worklog5743_2 values(2, repeat("b", 10000)); +insert into worklog5743_4 values(2, repeat("b", 10000)); +insert into worklog5743_8 values(2, repeat("b", 10000), repeat("b", 10000)); +insert into worklog5743_16 values(2, repeat("b", 10000), repeat("b", 10000)); +select a1, left(a2, 20) from worklog5743_1; +a1 left(a2, 20) +9 aaaaaaaaaaaaaaaaaaaa +2 bbbbbbbbbbbbbbbbbbbb +select a1, left(a2, 20) from worklog5743_2; +a1 left(a2, 20) +9 aaaaaaaaaaaaaaaaaaaa +2 bbbbbbbbbbbbbbbbbbbb +select a1, left(a2, 20) from worklog5743_4; +a1 left(a2, 20) +9 aaaaaaaaaaaaaaaaaaaa +2 bbbbbbbbbbbbbbbbbbbb +select a1, left(a2, 20) from worklog5743_8; +a1 left(a2, 20) +9 aaaaaaaaaaaaaaaaaaaa +2 bbbbbbbbbbbbbbbbbbbb +select a1, left(a2, 20) from worklog5743_16; +a1 left(a2, 20) +9 aaaaaaaaaaaaaaaaaaaa +2 bbbbbbbbbbbbbbbbbbbb +begin; +update worklog5743_1 set a1 = 1000; +update worklog5743_2 set a1 = 1000; +update worklog5743_4 set a1 = 1000; +update worklog5743_8 set a1 = 1000; +update worklog5743_16 set a1 = 1000; +select a1, left(a2, 20) from worklog5743_1; +a1 left(a2, 20) +1000 aaaaaaaaaaaaaaaaaaaa +1000 bbbbbbbbbbbbbbbbbbbb +select a1, left(a2, 20) from worklog5743_2; +a1 left(a2, 20) +1000 aaaaaaaaaaaaaaaaaaaa +1000 bbbbbbbbbbbbbbbbbbbb +select a1, left(a2, 20) from worklog5743_4; +a1 left(a2, 20) +1000 aaaaaaaaaaaaaaaaaaaa +1000 bbbbbbbbbbbbbbbbbbbb +select a1, left(a2, 20) from worklog5743_8; +a1 left(a2, 20) +1000 aaaaaaaaaaaaaaaaaaaa +1000 bbbbbbbbbbbbbbbbbbbb +select a1, left(a2, 20) from worklog5743_16; +a1 left(a2, 20) +1000 aaaaaaaaaaaaaaaaaaaa +1000 bbbbbbbbbbbbbbbbbbbb +select @@session.transaction_isolation; +@@session.transaction_isolation +REPEATABLE-READ +explain select a1, left(a2, 20) from worklog5743_1 where a1 = 9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE worklog5743_1 NULL ref idx6 idx6 5 const 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`worklog5743_1`.`a1` AS `a1`,left(`test`.`worklog5743_1`.`a2`,20) AS `left(a2, 20)` from `test`.`worklog5743_1` where (`test`.`worklog5743_1`.`a1` = 9) +explain select a1, left(a2, 20) from worklog5743_2 where a1 = 9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE worklog5743_2 NULL ref idx6 idx6 5 const 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`worklog5743_2`.`a1` AS `a1`,left(`test`.`worklog5743_2`.`a2`,20) AS `left(a2, 20)` from `test`.`worklog5743_2` where (`test`.`worklog5743_2`.`a1` = 9) +explain select a1, left(a2, 20) from worklog5743_4 where a1 = 9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE worklog5743_4 NULL ref idx6 idx6 5 const 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`worklog5743_4`.`a1` AS `a1`,left(`test`.`worklog5743_4`.`a2`,20) AS `left(a2, 20)` from `test`.`worklog5743_4` where (`test`.`worklog5743_4`.`a1` = 9) +explain select a1, left(a2, 20) from worklog5743_8 where a1 = 9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE worklog5743_8 NULL ref idx5,idx7 idx5 5 const 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`worklog5743_8`.`a1` AS `a1`,left(`test`.`worklog5743_8`.`a2`,20) AS `left(a2, 20)` from `test`.`worklog5743_8` where (`test`.`worklog5743_8`.`a1` = 9) +explain select a1, left(a2, 20) from worklog5743_16 where a1 = 9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE worklog5743_16 NULL ref idx5,idx7 idx5 5 const 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`worklog5743_16`.`a1` AS `a1`,left(`test`.`worklog5743_16`.`a2`,20) AS `left(a2, 20)` from `test`.`worklog5743_16` where (`test`.`worklog5743_16`.`a1` = 9) +select a1, left(a2, 20) from worklog5743_1 where a1 = 9; +a1 left(a2, 20) +9 aaaaaaaaaaaaaaaaaaaa +select a1, left(a2, 20) from worklog5743_2 where a1 = 9; +a1 left(a2, 20) +9 aaaaaaaaaaaaaaaaaaaa +select a1, left(a2, 20) from worklog5743_4 where a1 = 9; +a1 left(a2, 20) +9 aaaaaaaaaaaaaaaaaaaa +select a1, left(a2, 20) from worklog5743_8 where a1 = 9; +a1 left(a2, 20) +9 aaaaaaaaaaaaaaaaaaaa +select a1, left(a2, 20) from worklog5743_16 where a1 = 9; +a1 left(a2, 20) +9 aaaaaaaaaaaaaaaaaaaa +SET SESSION TRANSACTION ISOLATION LEVEL READ UNCOMMITTED; +select @@session.transaction_isolation; +@@session.transaction_isolation +READ-UNCOMMITTED +select a1, left(a2, 20) from worklog5743_1 where a1 = 9; +a1 left(a2, 20) +select a1, left(a2, 20) from worklog5743_2 where a1 = 9; +a1 left(a2, 20) +select a1, left(a2, 20) from worklog5743_4 where a1 = 9; +a1 left(a2, 20) +select a1, left(a2, 20) from worklog5743_8 where a1 = 9; +a1 left(a2, 20) +select a1, left(a2, 20) from worklog5743_16 where a1 = 9; +a1 left(a2, 20) +rollback; +drop table worklog5743_1; +drop table worklog5743_2; +drop table worklog5743_4; +drop table worklog5743_8; +drop table worklog5743_16; +### Test 5 ### +create table worklog5743(a1 int, +a2 varchar(20000), +a3 varchar(3073), +a4 varchar(3072), +a5 varchar(3069), +a6 varchar(3068)) +charset latin1 +ROW_FORMAT=DYNAMIC; +SET sql_mode=''; +create index idx1 on worklog5743(a2); +Warnings: +Warning 1071 Specified key was too long; max key length is 3072 bytes +create index idx2 on worklog5743(a3); +Warnings: +Warning 1071 Specified key was too long; max key length is 3072 bytes +create index idx3 on worklog5743(a4); +show warnings; +Level Code Message +SET sql_mode= default; +create index idx4 on worklog5743(a1, a2); +ERROR 42000: Specified key was too long; max key length is 3072 bytes +show warnings; +Level Code Message +Error 1071 Specified key was too long; max key length is 3072 bytes +create index idx5 on worklog5743(a1, a5); +ERROR 42000: Specified key was too long; max key length is 3072 bytes +show warnings; +Level Code Message +Error 1071 Specified key was too long; max key length is 3072 bytes +create index idx6 on worklog5743(a1, a6); +show warnings; +Level Code Message +show create table worklog5743; +Table Create Table +worklog5743 CREATE TABLE `worklog5743` ( + `a1` int DEFAULT NULL, + `a2` varchar(20000) DEFAULT NULL, + `a3` varchar(3073) DEFAULT NULL, + `a4` varchar(3072) DEFAULT NULL, + `a5` varchar(3069) DEFAULT NULL, + `a6` varchar(3068) DEFAULT NULL, + KEY `idx1` (`a2`(3072)), + KEY `idx2` (`a3`(3072)), + KEY `idx3` (`a4`), + KEY `idx6` (`a1`,`a6`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 ROW_FORMAT=DYNAMIC +insert into worklog5743 values(9, +repeat("a", 20000), repeat("a", 3073), +repeat("a", 3072), repeat("a", 3069), +repeat("a", 3068)); +begin; +update worklog5743 set a1 = 1000; +select @@session.transaction_isolation; +@@session.transaction_isolation +REPEATABLE-READ +explain select a1 from worklog5743 where a1 = 9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE worklog5743 NULL ref idx6 idx6 5 const 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`worklog5743`.`a1` AS `a1` from `test`.`worklog5743` where (`test`.`worklog5743`.`a1` = 9) +select a1 from worklog5743 where a1 = 9; +a1 +9 +SET SESSION TRANSACTION ISOLATION LEVEL READ UNCOMMITTED; +select @@session.transaction_isolation; +@@session.transaction_isolation +READ-UNCOMMITTED +select a1 from worklog5743 where a1 = 9; +a1 +rollback; +drop table worklog5743; +### Test 6 ### +create table worklog5743(a TEXT not null, primary key (a(1000))) +charset latin1 +row_format=compact; +ERROR 42000: Specified key was too long; max key length is 767 bytes +create table worklog5743(a TEXT) +charset latin1 +row_format=compact; +create index idx on worklog5743(a(768)); +ERROR 42000: Specified key was too long; max key length is 767 bytes +create index idx on worklog5743(a(767)); +insert into worklog5743 values(repeat("a", 20000)); +begin; +insert into worklog5743 values(repeat("b", 20000)); +update worklog5743 set a = (repeat("x", 25000)); +select @@session.transaction_isolation; +@@session.transaction_isolation +REPEATABLE-READ +select a = repeat("a", 20000) from worklog5743; +a = repeat("a", 20000) +1 +SET SESSION TRANSACTION ISOLATION LEVEL READ UNCOMMITTED; +select @@session.transaction_isolation; +@@session.transaction_isolation +READ-UNCOMMITTED +select a = repeat("x", 25000) from worklog5743; +a = repeat("x", 25000) +1 +1 +rollback; +drop table worklog5743; +### Test 7 ### +create table worklog5743(a TEXT not null) ROW_FORMAT=DYNAMIC; +SET sql_mode=''; +create index idx1 on worklog5743(a(3073)); +Warnings: +Warning 1071 Specified key was too long; max key length is 3072 bytes +create index idx2 on worklog5743(a(3072)); +Warnings: +Warning 1071 Specified key was too long; max key length is 3072 bytes +Warning 1831 Duplicate index 'idx2' defined on the table 'test.worklog5743'. This is deprecated and will be disallowed in a future release. +show create table worklog5743; +Table Create Table +worklog5743 CREATE TABLE `worklog5743` ( + `a` text NOT NULL, + KEY `idx1` (`a`(768)), + KEY `idx2` (`a`(768)) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=DYNAMIC +drop table worklog5743; +SET sql_mode= default; +create table worklog5743(a TEXT not null) charset latin1 ROW_FORMAT=REDUNDANT; +create index idx on worklog5743(a(768)); +ERROR 42000: Specified key was too long; max key length is 767 bytes +create index idx2 on worklog5743(a(767)); +drop table worklog5743; +create table worklog5743(a TEXT not null) charset latin1 ROW_FORMAT=COMPACT; +create index idx on worklog5743(a(768)); +ERROR 42000: Specified key was too long; max key length is 767 bytes +create index idx2 on worklog5743(a(767)); +drop table worklog5743; +SET GLOBAL innodb_file_per_table=1; diff --git a/mysql-test/suite/index_large_prefix_4k.result-pq b/mysql-test/suite/index_large_prefix_4k.result-pq new file mode 100644 index 000000000000..ba07f7c27d59 --- /dev/null +++ b/mysql-test/suite/index_large_prefix_4k.result-pq @@ -0,0 +1,388 @@ +SET default_storage_engine=InnoDB; +set global innodb_file_per_table=1; +### Test 1 ### +create table worklog5743(a TEXT not null, primary key (a(768))) charset latin1 ROW_FORMAT=DYNAMIC; +show warnings; +Level Code Message +insert into worklog5743 values(repeat("a", 20000)); +update worklog5743 set a = (repeat("b", 16000)); +SET sql_mode= ''; +create index idx on worklog5743(a(900)); +Warnings: +Warning 1071 Specified key was too long; max key length is 768 bytes +show warnings; +Level Code Message +Warning 1071 Specified key was too long; max key length is 768 bytes +SET sql_mode= default; +begin; +update worklog5743 set a = (repeat("x", 17000)); +select @@session.transaction_isolation; +@@session.transaction_isolation +REPEATABLE-READ +select a = repeat("x", 17000) from worklog5743; +a = repeat("x", 17000) +0 +select a = repeat("b", 16000) from worklog5743; +a = repeat("b", 16000) +1 +SET SESSION TRANSACTION ISOLATION LEVEL READ UNCOMMITTED; +select @@session.transaction_isolation; +@@session.transaction_isolation +READ-UNCOMMITTED +select a = repeat("x", 17000) from worklog5743; +a = repeat("x", 17000) +1 +rollback; +drop table worklog5743; +### Test 2 ### +create table worklog5743(a1 int, a2 TEXT not null) charset latin1 ROW_FORMAT=DYNAMIC; +show warnings; +Level Code Message +create index idx on worklog5743(a1, a2(750)); +show warnings; +Level Code Message +insert into worklog5743 values(9, repeat("a", 10000)); +begin; +update worklog5743 set a1 = 1111; +select @@session.transaction_isolation; +@@session.transaction_isolation +REPEATABLE-READ +explain select a1, a2 = repeat("a", 10000) from worklog5743 where a1 = 9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE worklog5743 NULL ref idx idx 5 const 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`worklog5743`.`a1` AS `a1`,(`test`.`worklog5743`.`a2` = convert(repeat('a',10000) using latin1)) AS `a2 = repeat("a", 10000)` from `test`.`worklog5743` where (`test`.`worklog5743`.`a1` = 9) +select a1, a2 = repeat("a", 10000) from worklog5743 where a1 = 9; +a1 a2 = repeat("a", 10000) +9 1 +SET SESSION TRANSACTION ISOLATION LEVEL READ UNCOMMITTED; +select @@session.transaction_isolation; +@@session.transaction_isolation +READ-UNCOMMITTED +select a1, a2 = repeat("a", 10000) from worklog5743 where a1 = 9; +a1 a2 = repeat("a", 10000) +rollback; +drop table worklog5743; +### Test 3 ### +create table worklog5743(a1 int, a2 TEXT not null) ROW_FORMAT=DYNAMIC; +create index idx on worklog5743(a1, a2(50)); +insert into worklog5743 values(9, repeat("a", 10000)); +begin; +update worklog5743 set a1 = 2222; +select @@session.transaction_isolation; +@@session.transaction_isolation +REPEATABLE-READ +explain select a1, a2 = repeat("a", 10000) from worklog5743 where a1 = 9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE worklog5743 NULL ref idx idx 5 const 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`worklog5743`.`a1` AS `a1`,(`test`.`worklog5743`.`a2` = repeat('a',10000)) AS `a2 = repeat("a", 10000)` from `test`.`worklog5743` where (`test`.`worklog5743`.`a1` = 9) +select a1, a2 = repeat("a", 10000) from worklog5743 where a1 = 9; +a1 a2 = repeat("a", 10000) +9 1 +SET SESSION TRANSACTION ISOLATION LEVEL READ UNCOMMITTED; +select @@session.transaction_isolation; +@@session.transaction_isolation +READ-UNCOMMITTED +select a1, a2 = repeat("a", 10000) from worklog5743 where a1 = 9; +a1 a2 = repeat("a", 10000) +rollback; +drop table worklog5743; +### Test 4 ### +create table worklog5743_1(a1 int, a2 TEXT not null) charset latin1 KEY_BLOCK_SIZE=1; +create table worklog5743_2(a1 int, a2 TEXT not null) charset latin1 KEY_BLOCK_SIZE=2; +create table worklog5743_4(a1 int, a2 TEXT not null) charset latin1 KEY_BLOCK_SIZE=4; +create index idx1 on worklog5743_1(a2(4000)); +ERROR 42000: Specified key was too long; max key length is 768 bytes +show warnings; +Level Code Message +Error 1071 Specified key was too long; max key length is 768 bytes +create index idx3 on worklog5743_1(a2(436)); +ERROR 42000: Row size too large. The maximum row size for the used table type, not counting BLOBs, is 1982. This includes storage overhead, check the manual. You have to change some columns to TEXT or BLOBs +show warnings; +Level Code Message +Error 1118 Row size too large. The maximum row size for the used table type, not counting BLOBs, is 1982. This includes storage overhead, check the manual. You have to change some columns to TEXT or BLOBs +create index idx4 on worklog5743_1(a2(434)); +show warnings; +Level Code Message +create index idx5 on worklog5743_1(a1, a2(430)); +ERROR 42000: Row size too large. The maximum row size for the used table type, not counting BLOBs, is 1982. This includes storage overhead, check the manual. You have to change some columns to TEXT or BLOBs +show warnings; +Level Code Message +Error 1118 Row size too large. The maximum row size for the used table type, not counting BLOBs, is 1982. This includes storage overhead, check the manual. You have to change some columns to TEXT or BLOBs +create index idx6 on worklog5743_1(a1, a2(428)); +show warnings; +Level Code Message +SET sql_mode= ''; +create index idx1 on worklog5743_2(a2(4000)); +Warnings: +Warning 1071 Specified key was too long; max key length is 768 bytes +show warnings; +Level Code Message +Warning 1071 Specified key was too long; max key length is 768 bytes +show create table worklog5743_2; +Table Create Table +worklog5743_2 CREATE TABLE `worklog5743_2` ( + `a1` int DEFAULT NULL, + `a2` text NOT NULL, + KEY `idx1` (`a2`(768)) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 KEY_BLOCK_SIZE=2 +create index idx3 on worklog5743_2(a2(769)); +Warnings: +Warning 1071 Specified key was too long; max key length is 768 bytes +Warning 1831 Duplicate index 'idx3' defined on the table 'test.worklog5743_2'. This is deprecated and will be disallowed in a future release. +show warnings; +Level Code Message +Warning 1071 Specified key was too long; max key length is 768 bytes +Warning 1831 Duplicate index 'idx3' defined on the table 'test.worklog5743_2'. This is deprecated and will be disallowed in a future release. +create index idx4 on worklog5743_2(a2(768)); +Warnings: +Warning 1831 Duplicate index 'idx4' defined on the table 'test.worklog5743_2'. This is deprecated and will be disallowed in a future release. +show warnings; +Level Code Message +Warning 1831 Duplicate index 'idx4' defined on the table 'test.worklog5743_2'. This is deprecated and will be disallowed in a future release. +create index idx5 on worklog5743_2(a1, a2(765)); +ERROR 42000: Specified key was too long; max key length is 768 bytes +show warnings; +Level Code Message +Error 1071 Specified key was too long; max key length is 768 bytes +create index idx6 on worklog5743_2(a1, a2(764)); +show warnings; +Level Code Message +create index idx1 on worklog5743_4(a2(4000)); +Warnings: +Warning 1071 Specified key was too long; max key length is 768 bytes +show warnings; +Level Code Message +Warning 1071 Specified key was too long; max key length is 768 bytes +show create table worklog5743_4; +Table Create Table +worklog5743_4 CREATE TABLE `worklog5743_4` ( + `a1` int DEFAULT NULL, + `a2` text NOT NULL, + KEY `idx1` (`a2`(768)) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 KEY_BLOCK_SIZE=4 +create index idx3 on worklog5743_4(a2(769)); +Warnings: +Warning 1071 Specified key was too long; max key length is 768 bytes +Warning 1831 Duplicate index 'idx3' defined on the table 'test.worklog5743_4'. This is deprecated and will be disallowed in a future release. +show warnings; +Level Code Message +Warning 1071 Specified key was too long; max key length is 768 bytes +Warning 1831 Duplicate index 'idx3' defined on the table 'test.worklog5743_4'. This is deprecated and will be disallowed in a future release. +create index idx4 on worklog5743_4(a2(768)); +Warnings: +Warning 1831 Duplicate index 'idx4' defined on the table 'test.worklog5743_4'. This is deprecated and will be disallowed in a future release. +show warnings; +Level Code Message +Warning 1831 Duplicate index 'idx4' defined on the table 'test.worklog5743_4'. This is deprecated and will be disallowed in a future release. +create index idx5 on worklog5743_4(a1, a2(765)); +ERROR 42000: Specified key was too long; max key length is 768 bytes +show warnings; +Level Code Message +Error 1071 Specified key was too long; max key length is 768 bytes +create index idx6 on worklog5743_4(a1, a2(764)); +show warnings; +Level Code Message +SET sql_mode= default; +insert into worklog5743_1 values(9, repeat("a", 10000)); +insert into worklog5743_2 values(9, repeat("a", 10000)); +insert into worklog5743_4 values(9, repeat("a", 10000)); +insert into worklog5743_1 values(2, repeat("b", 10000)); +insert into worklog5743_2 values(2, repeat("b", 10000)); +insert into worklog5743_4 values(2, repeat("b", 10000)); +select a1, left(a2, 20) from worklog5743_1; +a1 left(a2, 20) +9 aaaaaaaaaaaaaaaaaaaa +2 bbbbbbbbbbbbbbbbbbbb +select a1, left(a2, 20) from worklog5743_2; +a1 left(a2, 20) +9 aaaaaaaaaaaaaaaaaaaa +2 bbbbbbbbbbbbbbbbbbbb +select a1, left(a2, 20) from worklog5743_4; +a1 left(a2, 20) +9 aaaaaaaaaaaaaaaaaaaa +2 bbbbbbbbbbbbbbbbbbbb +begin; +update worklog5743_1 set a1 = 1000; +update worklog5743_2 set a1 = 1000; +update worklog5743_4 set a1 = 1000; +select a1, left(a2, 20) from worklog5743_1; +a1 left(a2, 20) +1000 aaaaaaaaaaaaaaaaaaaa +1000 bbbbbbbbbbbbbbbbbbbb +select a1, left(a2, 20) from worklog5743_2; +a1 left(a2, 20) +1000 aaaaaaaaaaaaaaaaaaaa +1000 bbbbbbbbbbbbbbbbbbbb +select a1, left(a2, 20) from worklog5743_4; +a1 left(a2, 20) +1000 aaaaaaaaaaaaaaaaaaaa +1000 bbbbbbbbbbbbbbbbbbbb +select @@session.transaction_isolation; +@@session.transaction_isolation +REPEATABLE-READ +explain select a1, left(a2, 20) from worklog5743_1 where a1 = 9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE worklog5743_1 NULL ref idx6 idx6 5 const 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`worklog5743_1`.`a1` AS `a1`,left(`test`.`worklog5743_1`.`a2`,20) AS `left(a2, 20)` from `test`.`worklog5743_1` where (`test`.`worklog5743_1`.`a1` = 9) +explain select a1, left(a2, 20) from worklog5743_2 where a1 = 9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE worklog5743_2 NULL ref idx6 idx6 5 const 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`worklog5743_2`.`a1` AS `a1`,left(`test`.`worklog5743_2`.`a2`,20) AS `left(a2, 20)` from `test`.`worklog5743_2` where (`test`.`worklog5743_2`.`a1` = 9) +explain select a1, left(a2, 20) from worklog5743_4 where a1 = 9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE worklog5743_4 NULL ref idx6 idx6 5 const 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`worklog5743_4`.`a1` AS `a1`,left(`test`.`worklog5743_4`.`a2`,20) AS `left(a2, 20)` from `test`.`worklog5743_4` where (`test`.`worklog5743_4`.`a1` = 9) +select a1, left(a2, 20) from worklog5743_1 where a1 = 9; +a1 left(a2, 20) +9 aaaaaaaaaaaaaaaaaaaa +select a1, left(a2, 20) from worklog5743_2 where a1 = 9; +a1 left(a2, 20) +9 aaaaaaaaaaaaaaaaaaaa +select a1, left(a2, 20) from worklog5743_4 where a1 = 9; +a1 left(a2, 20) +9 aaaaaaaaaaaaaaaaaaaa +SET SESSION TRANSACTION ISOLATION LEVEL READ UNCOMMITTED; +select @@session.transaction_isolation; +@@session.transaction_isolation +READ-UNCOMMITTED +select a1, left(a2, 20) from worklog5743_1 where a1 = 9; +a1 left(a2, 20) +select a1, left(a2, 20) from worklog5743_2 where a1 = 9; +a1 left(a2, 20) +select a1, left(a2, 20) from worklog5743_4 where a1 = 9; +a1 left(a2, 20) +rollback; +drop table worklog5743_1; +drop table worklog5743_2; +drop table worklog5743_4; +### Test 5 ### +create table worklog5743(a1 int, a2 varchar(20000)) charset latin1 ROW_FORMAT=DYNAMIC; +create index idx1 on worklog5743(a2); +ERROR 42000: Specified key was too long; max key length is 3072 bytes +show warnings; +Level Code Message +Error 1071 Specified key was too long; max key length is 3072 bytes +drop table worklog5743; +create table worklog5743(a1 int, a2 varchar(3072)) charset latin1 ROW_FORMAT=DYNAMIC; +create index idx1 on worklog5743(a2); +ERROR 42000: Specified key was too long; max key length is 768 bytes +show warnings; +Level Code Message +Error 1071 Specified key was too long; max key length is 768 bytes +drop table worklog5743; +create table worklog5743(a1 int, a2 varchar(769)) charset latin1 ROW_FORMAT=DYNAMIC; +create index idx1 on worklog5743(a2); +ERROR 42000: Specified key was too long; max key length is 768 bytes +show warnings; +Level Code Message +Error 1071 Specified key was too long; max key length is 768 bytes +drop table worklog5743; +create table worklog5743(a1 int, a2 varchar(768)) charset latin1 ROW_FORMAT=DYNAMIC; +create index idx1 on worklog5743(a2); +show warnings; +Level Code Message +insert into worklog5743 values(9, repeat("a", 768)); +update worklog5743 set a1 = 3333; +drop table worklog5743; +create table worklog5743(a1 int, a2 varchar(765)) charset latin1 ROW_FORMAT=DYNAMIC; +create index idx1 on worklog5743(a1, a2); +ERROR 42000: Specified key was too long; max key length is 768 bytes +show warnings; +Level Code Message +Error 1071 Specified key was too long; max key length is 768 bytes +drop table worklog5743; +create table worklog5743(a1 int, a2 varchar(764)) charset latin1 ROW_FORMAT=DYNAMIC; +create index idx1 on worklog5743(a1, a2); +show warnings; +Level Code Message +insert into worklog5743 values(9, repeat("a", 764)); +begin; +update worklog5743 set a1 = 4444; +select @@session.transaction_isolation; +@@session.transaction_isolation +REPEATABLE-READ +explain select a1 from worklog5743 where a1 = 9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE worklog5743 NULL ref idx1 idx1 5 const 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`worklog5743`.`a1` AS `a1` from `test`.`worklog5743` where (`test`.`worklog5743`.`a1` = 9) +select a1 from worklog5743 where a1 = 9; +a1 +9 +SET SESSION TRANSACTION ISOLATION LEVEL READ UNCOMMITTED; +select @@session.transaction_isolation; +@@session.transaction_isolation +READ-UNCOMMITTED +select a1 from worklog5743 where a1 = 9; +a1 +rollback; +drop table worklog5743; +### Test 6 ### +create table worklog5743(a TEXT not null, primary key (a(1000))); +ERROR 42000: Specified key was too long; max key length is 768 bytes +create table worklog5743(a TEXT) charset latin1 ROW_FORMAT=COMPACT; +create index idx on worklog5743(a(768)); +ERROR 42000: Specified key was too long; max key length is 767 bytes +create index idx on worklog5743(a(767)); +insert into worklog5743 values(repeat("a", 20000)); +begin; +insert into worklog5743 values(repeat("b", 20000)); +update worklog5743 set a = (repeat("x", 25000)); +select @@session.transaction_isolation; +@@session.transaction_isolation +REPEATABLE-READ +select a = repeat("a", 20000) from worklog5743; +a = repeat("a", 20000) +1 +SET SESSION TRANSACTION ISOLATION LEVEL READ UNCOMMITTED; +select @@session.transaction_isolation; +@@session.transaction_isolation +READ-UNCOMMITTED +select a = repeat("x", 25000) from worklog5743; +a = repeat("x", 25000) +1 +1 +rollback; +drop table worklog5743; +### Test 7 ### +create table worklog5743(a TEXT not null) charset latin1 ROW_FORMAT=DYNAMIC; +SET sql_mode= ''; +create index idx1 on worklog5743(a(769)); +Warnings: +Warning 1071 Specified key was too long; max key length is 768 bytes +show warnings; +Level Code Message +Warning 1071 Specified key was too long; max key length is 768 bytes +SET sql_mode= default; +create index idx2 on worklog5743(a(768)); +Warnings: +Warning 1831 Duplicate index 'idx2' defined on the table 'test.worklog5743'. This is deprecated and will be disallowed in a future release. +show warnings; +Level Code Message +Warning 1831 Duplicate index 'idx2' defined on the table 'test.worklog5743'. This is deprecated and will be disallowed in a future release. +show create table worklog5743; +Table Create Table +worklog5743 CREATE TABLE `worklog5743` ( + `a` text NOT NULL, + KEY `idx1` (`a`(768)), + KEY `idx2` (`a`(768)) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 ROW_FORMAT=DYNAMIC +insert into worklog5743 values(repeat("a", 768)); +drop table worklog5743; +create table worklog5743(a TEXT not null) charset latin1 ROW_FORMAT=REDUNDANT; +create index idx on worklog5743(a(768)); +ERROR 42000: Specified key was too long; max key length is 767 bytes +create index idx2 on worklog5743(a(767)); +drop table worklog5743; +create table worklog5743(a TEXT not null) charset latin1 ROW_FORMAT=COMPACT; +create index idx on worklog5743(a(768)); +ERROR 42000: Specified key was too long; max key length is 767 bytes +create index idx2 on worklog5743(a(767)); +drop table worklog5743; +SET GLOBAL innodb_file_per_table=1; diff --git a/mysql-test/suite/index_large_prefix_8k.result-pq b/mysql-test/suite/index_large_prefix_8k.result-pq new file mode 100644 index 000000000000..c7f235fc896a --- /dev/null +++ b/mysql-test/suite/index_large_prefix_8k.result-pq @@ -0,0 +1,396 @@ +SET default_storage_engine=InnoDB; +set global innodb_file_per_table=1; +### Test 1 ### +create table worklog5743(a TEXT not null, primary key (a(1000))) charset latin1 ROW_FORMAT=DYNAMIC; +show warnings; +Level Code Message +insert into worklog5743 values(repeat("a", 20000)); +update worklog5743 set a = (repeat("b", 16000)); +SET sql_mode= ''; +create index idx on worklog5743(a(2000)); +Warnings: +Warning 1071 Specified key was too long; max key length is 1536 bytes +show warnings; +Level Code Message +Warning 1071 Specified key was too long; max key length is 1536 bytes +SET sql_mode= default; +begin; +update worklog5743 set a = (repeat("x", 17000)); +select @@session.transaction_isolation; +@@session.transaction_isolation +REPEATABLE-READ +select a = repeat("x", 17000) from worklog5743; +a = repeat("x", 17000) +0 +select a = repeat("b", 16000) from worklog5743; +a = repeat("b", 16000) +1 +SET SESSION TRANSACTION ISOLATION LEVEL READ UNCOMMITTED; +select @@session.transaction_isolation; +@@session.transaction_isolation +READ-UNCOMMITTED +select a = repeat("x", 17000) from worklog5743; +a = repeat("x", 17000) +1 +rollback; +drop table worklog5743; +### Test 2 ### +create table worklog5743(a1 int, a2 TEXT not null) charset latin1 ROW_FORMAT=DYNAMIC; +show warnings; +Level Code Message +create index idx on worklog5743(a1, a2(1250)); +show warnings; +Level Code Message +insert into worklog5743 values(9, repeat("a", 10000)); +begin; +update worklog5743 set a1 = 1000; +select @@session.transaction_isolation; +@@session.transaction_isolation +REPEATABLE-READ +explain select a1, a2 = repeat("a", 10000) from worklog5743 where a1 = 9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE worklog5743 NULL ref idx idx 5 const 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`worklog5743`.`a1` AS `a1`,(`test`.`worklog5743`.`a2` = convert(repeat('a',10000) using latin1)) AS `a2 = repeat("a", 10000)` from `test`.`worklog5743` where (`test`.`worklog5743`.`a1` = 9) +select a1, a2 = repeat("a", 10000) from worklog5743 where a1 = 9; +a1 a2 = repeat("a", 10000) +9 1 +SET SESSION TRANSACTION ISOLATION LEVEL READ UNCOMMITTED; +select @@session.transaction_isolation; +@@session.transaction_isolation +READ-UNCOMMITTED +select a1, a2 = repeat("a", 10000) from worklog5743 where a1 = 9; +a1 a2 = repeat("a", 10000) +rollback; +drop table worklog5743; +### Test 3 ### +create table worklog5743(a1 int, a2 TEXT not null) ROW_FORMAT=DYNAMIC; +create index idx on worklog5743(a1, a2(50)); +insert into worklog5743 values(9, repeat("a", 10000)); +begin; +update worklog5743 set a1 = 1000; +select @@session.transaction_isolation; +@@session.transaction_isolation +REPEATABLE-READ +explain select a1, a2 = repeat("a", 10000) from worklog5743 where a1 = 9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE worklog5743 NULL ref idx idx 5 const 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`worklog5743`.`a1` AS `a1`,(`test`.`worklog5743`.`a2` = repeat('a',10000)) AS `a2 = repeat("a", 10000)` from `test`.`worklog5743` where (`test`.`worklog5743`.`a1` = 9) +select a1, a2 = repeat("a", 10000) from worklog5743 where a1 = 9; +a1 a2 = repeat("a", 10000) +9 1 +SET SESSION TRANSACTION ISOLATION LEVEL READ UNCOMMITTED; +select @@session.transaction_isolation; +@@session.transaction_isolation +READ-UNCOMMITTED +select a1, a2 = repeat("a", 10000) from worklog5743 where a1 = 9; +a1 a2 = repeat("a", 10000) +rollback; +drop table worklog5743; +### Test 4 ### +create table worklog5743_1(a1 int, a2 TEXT not null) charset latin1 KEY_BLOCK_SIZE=1; +create table worklog5743_2(a1 int, a2 TEXT not null) charset latin1 KEY_BLOCK_SIZE=2; +create table worklog5743_4(a1 int, a2 TEXT not null) charset latin1 KEY_BLOCK_SIZE=4; +create table worklog5743_8(a1 int, a2 TEXT, a3 TEXT) charset latin1 KEY_BLOCK_SIZE=8; +create index idx2 on worklog5743_1(a2(4000)); +ERROR 42000: Specified key was too long; max key length is 1536 bytes +show warnings; +Level Code Message +Error 1071 Specified key was too long; max key length is 1536 bytes +create index idx3 on worklog5743_1(a2(436)); +ERROR 42000: Row size too large. The maximum row size for the used table type, not counting BLOBs, is 4030. This includes storage overhead, check the manual. You have to change some columns to TEXT or BLOBs +show warnings; +Level Code Message +Error 1118 Row size too large. The maximum row size for the used table type, not counting BLOBs, is 4030. This includes storage overhead, check the manual. You have to change some columns to TEXT or BLOBs +create index idx4 on worklog5743_1(a2(434)); +show warnings; +Level Code Message +create index idx5 on worklog5743_1(a1, a2(430)); +ERROR 42000: Row size too large. The maximum row size for the used table type, not counting BLOBs, is 4030. This includes storage overhead, check the manual. You have to change some columns to TEXT or BLOBs +show warnings; +Level Code Message +Error 1118 Row size too large. The maximum row size for the used table type, not counting BLOBs, is 4030. This includes storage overhead, check the manual. You have to change some columns to TEXT or BLOBs +create index idx6 on worklog5743_1(a1, a2(428)); +show warnings; +Level Code Message +SET sql_mode= ''; +create index idx2 on worklog5743_2(a2(4000)); +ERROR 42000: Row size too large. The maximum row size for the used table type, not counting BLOBs, is 4030. This includes storage overhead, check the manual. You have to change some columns to TEXT or BLOBs +show warnings; +Level Code Message +Warning 1071 Specified key was too long; max key length is 1536 bytes +Error 1118 Row size too large. The maximum row size for the used table type, not counting BLOBs, is 4030. This includes storage overhead, check the manual. You have to change some columns to TEXT or BLOBs +create index idx3 on worklog5743_2(a2(948)); +ERROR 42000: Row size too large. The maximum row size for the used table type, not counting BLOBs, is 4030. This includes storage overhead, check the manual. You have to change some columns to TEXT or BLOBs +show warnings; +Level Code Message +Error 1118 Row size too large. The maximum row size for the used table type, not counting BLOBs, is 4030. This includes storage overhead, check the manual. You have to change some columns to TEXT or BLOBs +create index idx4 on worklog5743_2(a2(946)); +show warnings; +Level Code Message +create index idx5 on worklog5743_2(a1, a2(942)); +ERROR 42000: Row size too large. The maximum row size for the used table type, not counting BLOBs, is 4030. This includes storage overhead, check the manual. You have to change some columns to TEXT or BLOBs +show warnings; +Level Code Message +Error 1118 Row size too large. The maximum row size for the used table type, not counting BLOBs, is 4030. This includes storage overhead, check the manual. You have to change some columns to TEXT or BLOBs +create index idx6 on worklog5743_2(a1, a2(940)); +show warnings; +Level Code Message +create index idx1 on worklog5743_4(a2(4000)); +Warnings: +Warning 1071 Specified key was too long; max key length is 1536 bytes +show warnings; +Level Code Message +Warning 1071 Specified key was too long; max key length is 1536 bytes +create index idx3 on worklog5743_4(a2(1537)); +Warnings: +Warning 1071 Specified key was too long; max key length is 1536 bytes +Warning 1831 Duplicate index 'idx3' defined on the table 'test.worklog5743_4'. This is deprecated and will be disallowed in a future release. +show warnings; +Level Code Message +Warning 1071 Specified key was too long; max key length is 1536 bytes +Warning 1831 Duplicate index 'idx3' defined on the table 'test.worklog5743_4'. This is deprecated and will be disallowed in a future release. +create index idx4 on worklog5743_4(a2(1536)); +Warnings: +Warning 1831 Duplicate index 'idx4' defined on the table 'test.worklog5743_4'. This is deprecated and will be disallowed in a future release. +show warnings; +Level Code Message +Warning 1831 Duplicate index 'idx4' defined on the table 'test.worklog5743_4'. This is deprecated and will be disallowed in a future release. +create index idx5 on worklog5743_4(a1, a2(1533)); +ERROR 42000: Specified key was too long; max key length is 1536 bytes +show warnings; +Level Code Message +Error 1071 Specified key was too long; max key length is 1536 bytes +create index idx6 on worklog5743_4(a1, a2(1532)); +show warnings; +Level Code Message +create index idx2 on worklog5743_8(a2(3073)); +Warnings: +Warning 1071 Specified key was too long; max key length is 1536 bytes +show warnings; +Level Code Message +Warning 1071 Specified key was too long; max key length is 1536 bytes +create index idx3 on worklog5743_8(a2(3072)); +Warnings: +Warning 1071 Specified key was too long; max key length is 1536 bytes +Warning 1831 Duplicate index 'idx3' defined on the table 'test.worklog5743_8'. This is deprecated and will be disallowed in a future release. +show warnings; +Level Code Message +Warning 1071 Specified key was too long; max key length is 1536 bytes +Warning 1831 Duplicate index 'idx3' defined on the table 'test.worklog5743_8'. This is deprecated and will be disallowed in a future release. +create index idx4 on worklog5743_8(a1, a2(1533)); +ERROR 42000: Specified key was too long; max key length is 1536 bytes +show warnings; +Level Code Message +Error 1071 Specified key was too long; max key length is 1536 bytes +create index idx5 on worklog5743_8(a1, a2(1532)); +show warnings; +Level Code Message +SET sql_mode= default; +insert into worklog5743_1 values(9, repeat("a", 10000)); +insert into worklog5743_2 values(9, repeat("a", 10000)); +insert into worklog5743_4 values(9, repeat("a", 10000)); +insert into worklog5743_8 values(9, repeat("a", 10000), repeat("a", 10000)); +insert into worklog5743_1 values(2, repeat("b", 10000)); +insert into worklog5743_2 values(2, repeat("b", 10000)); +insert into worklog5743_4 values(2, repeat("b", 10000)); +insert into worklog5743_8 values(2, repeat("b", 10000), repeat("b", 10000)); +select a1, left(a2, 20) from worklog5743_1; +a1 left(a2, 20) +9 aaaaaaaaaaaaaaaaaaaa +2 bbbbbbbbbbbbbbbbbbbb +select a1, left(a2, 20) from worklog5743_2; +a1 left(a2, 20) +9 aaaaaaaaaaaaaaaaaaaa +2 bbbbbbbbbbbbbbbbbbbb +select a1, left(a2, 20) from worklog5743_4; +a1 left(a2, 20) +9 aaaaaaaaaaaaaaaaaaaa +2 bbbbbbbbbbbbbbbbbbbb +select a1, left(a2, 20) from worklog5743_8; +a1 left(a2, 20) +9 aaaaaaaaaaaaaaaaaaaa +2 bbbbbbbbbbbbbbbbbbbb +begin; +update worklog5743_1 set a1 = 1000; +update worklog5743_2 set a1 = 1000; +update worklog5743_4 set a1 = 1000; +update worklog5743_8 set a1 = 1000; +select a1, left(a2, 20) from worklog5743_1; +a1 left(a2, 20) +1000 aaaaaaaaaaaaaaaaaaaa +1000 bbbbbbbbbbbbbbbbbbbb +select a1, left(a2, 20) from worklog5743_2; +a1 left(a2, 20) +1000 aaaaaaaaaaaaaaaaaaaa +1000 bbbbbbbbbbbbbbbbbbbb +select a1, left(a2, 20) from worklog5743_4; +a1 left(a2, 20) +1000 aaaaaaaaaaaaaaaaaaaa +1000 bbbbbbbbbbbbbbbbbbbb +select a1, left(a2, 20) from worklog5743_8; +a1 left(a2, 20) +1000 aaaaaaaaaaaaaaaaaaaa +1000 bbbbbbbbbbbbbbbbbbbb +select @@session.transaction_isolation; +@@session.transaction_isolation +REPEATABLE-READ +explain select a1, left(a2, 20) from worklog5743_1 where a1 = 9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE worklog5743_1 NULL ref idx6 idx6 5 const 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`worklog5743_1`.`a1` AS `a1`,left(`test`.`worklog5743_1`.`a2`,20) AS `left(a2, 20)` from `test`.`worklog5743_1` where (`test`.`worklog5743_1`.`a1` = 9) +explain select a1, left(a2, 20) from worklog5743_2 where a1 = 9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE worklog5743_2 NULL ref idx6 idx6 5 const 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`worklog5743_2`.`a1` AS `a1`,left(`test`.`worklog5743_2`.`a2`,20) AS `left(a2, 20)` from `test`.`worklog5743_2` where (`test`.`worklog5743_2`.`a1` = 9) +explain select a1, left(a2, 20) from worklog5743_4 where a1 = 9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE worklog5743_4 NULL ref idx6 idx6 5 const 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`worklog5743_4`.`a1` AS `a1`,left(`test`.`worklog5743_4`.`a2`,20) AS `left(a2, 20)` from `test`.`worklog5743_4` where (`test`.`worklog5743_4`.`a1` = 9) +explain select a1, left(a2, 20) from worklog5743_8 where a1 = 9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE worklog5743_8 NULL ref idx5 idx5 5 const 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`worklog5743_8`.`a1` AS `a1`,left(`test`.`worklog5743_8`.`a2`,20) AS `left(a2, 20)` from `test`.`worklog5743_8` where (`test`.`worklog5743_8`.`a1` = 9) +select a1, left(a2, 20) from worklog5743_1 where a1 = 9; +a1 left(a2, 20) +9 aaaaaaaaaaaaaaaaaaaa +select a1, left(a2, 20) from worklog5743_2 where a1 = 9; +a1 left(a2, 20) +9 aaaaaaaaaaaaaaaaaaaa +select a1, left(a2, 20) from worklog5743_4 where a1 = 9; +a1 left(a2, 20) +9 aaaaaaaaaaaaaaaaaaaa +select a1, left(a2, 20) from worklog5743_8 where a1 = 9; +a1 left(a2, 20) +9 aaaaaaaaaaaaaaaaaaaa +SET SESSION TRANSACTION ISOLATION LEVEL READ UNCOMMITTED; +select @@session.transaction_isolation; +@@session.transaction_isolation +READ-UNCOMMITTED +select a1, left(a2, 20) from worklog5743_1 where a1 = 9; +a1 left(a2, 20) +select a1, left(a2, 20) from worklog5743_2 where a1 = 9; +a1 left(a2, 20) +select a1, left(a2, 20) from worklog5743_4 where a1 = 9; +a1 left(a2, 20) +select a1, left(a2, 20) from worklog5743_8 where a1 = 9; +a1 left(a2, 20) +rollback; +drop table worklog5743_1; +drop table worklog5743_2; +drop table worklog5743_4; +drop table worklog5743_8; +### Test 5 ### +create table worklog5743(a1 int, a2 varchar(20000)) charset latin1 ROW_FORMAT=DYNAMIC; +create index idx1 on worklog5743(a2); +ERROR 42000: Specified key was too long; max key length is 3072 bytes +drop table worklog5743; +create table worklog5743(a1 int, a2 varchar(1537)) charset latin1 ROW_FORMAT=DYNAMIC; +create index idx1 on worklog5743(a2); +ERROR 42000: Specified key was too long; max key length is 1536 bytes +drop table worklog5743; +create table worklog5743(a1 int, a2 varchar(1536)) charset latin1 ROW_FORMAT=DYNAMIC; +create index idx1 on worklog5743(a2); +show warnings; +Level Code Message +insert into worklog5743 values(9, repeat("a", 1536)); +update worklog5743 set a1 = 1000; +drop table worklog5743; +create table worklog5743(a1 int, a2 varchar(1533)) charset latin1 ROW_FORMAT=DYNAMIC; +create index idx1 on worklog5743(a1, a2); +ERROR 42000: Specified key was too long; max key length is 1536 bytes +show warnings; +Level Code Message +Error 1071 Specified key was too long; max key length is 1536 bytes +drop table worklog5743; +create table worklog5743(a1 int, a2 varchar(1532)) charset latin1 ROW_FORMAT=DYNAMIC; +create index idx1 on worklog5743(a1, a2); +show warnings; +Level Code Message +insert into worklog5743 values(9, repeat("a", 1532)); +update worklog5743 set a1 = 1000; +begin; +update worklog5743 set a1 = 1000; +select @@session.transaction_isolation; +@@session.transaction_isolation +REPEATABLE-READ +explain select a1 from worklog5743 where a1 = 9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE worklog5743 NULL ref idx1 idx1 5 const 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`worklog5743`.`a1` AS `a1` from `test`.`worklog5743` where (`test`.`worklog5743`.`a1` = 9) +select a1 from worklog5743 where a1 = 9; +a1 +SET SESSION TRANSACTION ISOLATION LEVEL READ UNCOMMITTED; +select @@session.transaction_isolation; +@@session.transaction_isolation +READ-UNCOMMITTED +select a1 from worklog5743 where a1 = 9; +a1 +rollback; +drop table worklog5743; +### Test 6 ### +create table worklog5743(a TEXT not null, primary key (a(1000))) +charset latin1 +row_format=compact; +ERROR 42000: Specified key was too long; max key length is 767 bytes +create table worklog5743(a TEXT) charset latin1 row_format=compact; +create index idx on worklog5743(a(768)); +ERROR 42000: Specified key was too long; max key length is 767 bytes +create index idx on worklog5743(a(767)); +insert into worklog5743 values(repeat("a", 20000)); +begin; +insert into worklog5743 values(repeat("b", 20000)); +update worklog5743 set a = (repeat("x", 25000)); +select @@session.transaction_isolation; +@@session.transaction_isolation +REPEATABLE-READ +select a = repeat("a", 20000) from worklog5743; +a = repeat("a", 20000) +1 +SET SESSION TRANSACTION ISOLATION LEVEL READ UNCOMMITTED; +select @@session.transaction_isolation; +@@session.transaction_isolation +READ-UNCOMMITTED +select a = repeat("x", 25000) from worklog5743; +a = repeat("x", 25000) +1 +1 +rollback; +drop table worklog5743; +### Test 7 ### +create table worklog5743(a TEXT not null) ROW_FORMAT=DYNAMIC; +SET sql_mode= ''; +create index idx1 on worklog5743(a(3073)); +Warnings: +Warning 1071 Specified key was too long; max key length is 1536 bytes +create index idx2 on worklog5743(a(3072)); +Warnings: +Warning 1071 Specified key was too long; max key length is 1536 bytes +Warning 1831 Duplicate index 'idx2' defined on the table 'test.worklog5743'. This is deprecated and will be disallowed in a future release. +SET sql_mode= default; +show create table worklog5743; +Table Create Table +worklog5743 CREATE TABLE `worklog5743` ( + `a` text NOT NULL, + KEY `idx1` (`a`(384)), + KEY `idx2` (`a`(384)) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=DYNAMIC +drop table worklog5743; +create table worklog5743(a TEXT not null) charset latin1 ROW_FORMAT=REDUNDANT; +create index idx on worklog5743(a(768)); +ERROR 42000: Specified key was too long; max key length is 767 bytes +create index idx2 on worklog5743(a(767)); +drop table worklog5743; +create table worklog5743(a TEXT not null) charset latin1 ROW_FORMAT=COMPACT; +create index idx on worklog5743(a(768)); +ERROR 42000: Specified key was too long; max key length is 767 bytes +create index idx2 on worklog5743(a(767)); +drop table worklog5743; +SET GLOBAL innodb_file_per_table=1; diff --git a/mysql-test/suite/innodb-index.result-pq b/mysql-test/suite/innodb-index.result-pq new file mode 100644 index 000000000000..a9d78a0b4fdb --- /dev/null +++ b/mysql-test/suite/innodb-index.result-pq @@ -0,0 +1,2007 @@ +SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS; +create table t1(a varchar(2) primary key) engine=innodb; +insert into t1 values(''); +create index t1a1 on t1(a(1)); +affected rows: 0 +info: Records: 0 Duplicates: 0 Warnings: 0 +drop table t1; +create table t1(a int not null, b int, c char(10) not null, d varchar(20)) engine = innodb; +insert into t1 values (5,5,'oo','oo'),(4,4,'tr','tr'),(3,4,'ad','ad'),(2,3,'ak','ak'); +commit; +alter table t1 add index b (b), add index b (b); +ERROR 42000: Duplicate key name 'b' +alter table t1 add index (b,b); +ERROR 42S21: Duplicate column name 'b' +alter table t1 add index d2 (d); +affected rows: 0 +info: Records: 0 Duplicates: 0 Warnings: 0 +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int NOT NULL, + `b` int DEFAULT NULL, + `c` char(10) NOT NULL, + `d` varchar(20) DEFAULT NULL, + KEY `d2` (`d`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +analyze table t1; +explain select * from t1 force index(d2) order by d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL d2 83 NULL 4 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c`,`test`.`t1`.`d` AS `d` from `test`.`t1` FORCE INDEX (`d2`) order by `test`.`t1`.`d` +select * from t1 force index (d2) order by d; +a b c d +3 4 ad ad +2 3 ak ak +5 5 oo oo +4 4 tr tr +alter table t1 add unique index (b); +ERROR 23000: Duplicate entry '4' for key 't1.b' +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int NOT NULL, + `b` int DEFAULT NULL, + `c` char(10) NOT NULL, + `d` varchar(20) DEFAULT NULL, + KEY `d2` (`d`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +alter table t1 add index (b); +affected rows: 0 +info: Records: 0 Duplicates: 0 Warnings: 0 +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int NOT NULL, + `b` int DEFAULT NULL, + `c` char(10) NOT NULL, + `d` varchar(20) DEFAULT NULL, + KEY `d2` (`d`), + KEY `b` (`b`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +alter table t1 add unique index (c), add index (d); +affected rows: 0 +info: Records: 0 Duplicates: 0 Warnings: 1 +Warnings: +Warning 1831 Duplicate index 'd' defined on the table 'test.t1'. This is deprecated and will be disallowed in a future release. +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int NOT NULL, + `b` int DEFAULT NULL, + `c` char(10) NOT NULL, + `d` varchar(20) DEFAULT NULL, + UNIQUE KEY `c` (`c`), + KEY `d2` (`d`), + KEY `b` (`b`), + KEY `d` (`d`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +analyze table t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +explain select * from t1 force index(c) order by c; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL c 40 NULL 4 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c`,`test`.`t1`.`d` AS `d` from `test`.`t1` FORCE INDEX (`c`) order by `test`.`t1`.`c` +alter table t1 add primary key (a), drop index c; +affected rows: 0 +info: Records: 0 Duplicates: 0 Warnings: 0 +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int NOT NULL, + `b` int DEFAULT NULL, + `c` char(10) NOT NULL, + `d` varchar(20) DEFAULT NULL, + PRIMARY KEY (`a`), + KEY `d2` (`d`), + KEY `b` (`b`), + KEY `d` (`d`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +affected rows: 1 +alter table t1 add primary key (c); +ERROR 42000: Multiple primary key defined +alter table t1 drop primary key, add primary key (b); +ERROR 23000: Duplicate entry '4' for key 't1.PRIMARY' +create unique index c on t1 (c); +affected rows: 0 +info: Records: 0 Duplicates: 0 Warnings: 0 +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int NOT NULL, + `b` int DEFAULT NULL, + `c` char(10) NOT NULL, + `d` varchar(20) DEFAULT NULL, + PRIMARY KEY (`a`), + UNIQUE KEY `c` (`c`), + KEY `d2` (`d`), + KEY `b` (`b`), + KEY `d` (`d`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +analyze table t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +explain select * from t1 force index(c) order by c; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL c 40 NULL 4 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c`,`test`.`t1`.`d` AS `d` from `test`.`t1` FORCE INDEX (`c`) order by `test`.`t1`.`c` +select * from t1 force index(c) order by c; +a b c d +3 4 ad ad +2 3 ak ak +5 5 oo oo +4 4 tr tr +alter table t1 drop index b, add index (b); +affected rows: 0 +info: Records: 0 Duplicates: 0 Warnings: 0 +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int NOT NULL, + `b` int DEFAULT NULL, + `c` char(10) NOT NULL, + `d` varchar(20) DEFAULT NULL, + PRIMARY KEY (`a`), + UNIQUE KEY `c` (`c`), + KEY `d2` (`d`), + KEY `b` (`b`), + KEY `d` (`d`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +insert into t1 values(6,1,'ggg','ggg'); +select * from t1; +a b c d +2 3 ak ak +3 4 ad ad +4 4 tr tr +5 5 oo oo +6 1 ggg ggg +select * from t1 force index(b) order by b; +a b c d +6 1 ggg ggg +2 3 ak ak +3 4 ad ad +4 4 tr tr +5 5 oo oo +select * from t1 force index(c) order by c; +a b c d +3 4 ad ad +2 3 ak ak +6 1 ggg ggg +5 5 oo oo +4 4 tr tr +select * from t1 force index(d) order by d; +a b c d +3 4 ad ad +2 3 ak ak +6 1 ggg ggg +5 5 oo oo +4 4 tr tr +analyze table t1; +explain select * from t1 force index(b) order by b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL b 5 NULL 5 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c`,`test`.`t1`.`d` AS `d` from `test`.`t1` FORCE INDEX (`b`) order by `test`.`t1`.`b` +explain select * from t1 force index(c) order by c; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL c 40 NULL 5 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c`,`test`.`t1`.`d` AS `d` from `test`.`t1` FORCE INDEX (`c`) order by `test`.`t1`.`c` +explain select * from t1 force index(d) order by d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL d 83 NULL 5 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c`,`test`.`t1`.`d` AS `d` from `test`.`t1` FORCE INDEX (`d`) order by `test`.`t1`.`d` +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int NOT NULL, + `b` int DEFAULT NULL, + `c` char(10) NOT NULL, + `d` varchar(20) DEFAULT NULL, + PRIMARY KEY (`a`), + UNIQUE KEY `c` (`c`), + KEY `d2` (`d`), + KEY `b` (`b`), + KEY `d` (`d`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +create table t1(a int not null, b int, c char(10), d varchar(20), primary key (a)) engine = innodb; +insert into t1 values (1,1,'ab','ab'),(2,2,'ac','ac'),(3,3,'ad','ad'),(4,4,'afe','afe'); +commit; +alter table t1 add index (c(2)); +affected rows: 0 +info: Records: 0 Duplicates: 0 Warnings: 0 +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int NOT NULL, + `b` int DEFAULT NULL, + `c` char(10) DEFAULT NULL, + `d` varchar(20) DEFAULT NULL, + PRIMARY KEY (`a`), + KEY `c` (`c`(2)) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +affected rows: 1 +alter table t1 add unique index (d(10)); +affected rows: 0 +info: Records: 0 Duplicates: 0 Warnings: 0 +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int NOT NULL, + `b` int DEFAULT NULL, + `c` char(10) DEFAULT NULL, + `d` varchar(20) DEFAULT NULL, + PRIMARY KEY (`a`), + UNIQUE KEY `d` (`d`(10)), + KEY `c` (`c`(2)) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +affected rows: 1 +insert into t1 values(5,1,'ggg','ggg'); +analyze table t1; +select * from t1; +a b c d +1 1 ab ab +2 2 ac ac +3 3 ad ad +4 4 afe afe +5 1 ggg ggg +select * from t1 force index(c) order by c; +a b c d +1 1 ab ab +2 2 ac ac +3 3 ad ad +4 4 afe afe +5 1 ggg ggg +select * from t1 force index(d) order by d; +a b c d +1 1 ab ab +2 2 ac ac +3 3 ad ad +4 4 afe afe +5 1 ggg ggg +explain select * from t1 order by b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c`,`test`.`t1`.`d` AS `d` from `test`.`t1` order by `test`.`t1`.`b` +explain select * from t1 force index(c) order by c; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c`,`test`.`t1`.`d` AS `d` from `test`.`t1` FORCE INDEX (`c`) order by `test`.`t1`.`c` +explain select * from t1 force index(d) order by d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c`,`test`.`t1`.`d` AS `d` from `test`.`t1` FORCE INDEX (`d`) order by `test`.`t1`.`d` +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int NOT NULL, + `b` int DEFAULT NULL, + `c` char(10) DEFAULT NULL, + `d` varchar(20) DEFAULT NULL, + PRIMARY KEY (`a`), + UNIQUE KEY `d` (`d`(10)), + KEY `c` (`c`(2)) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +alter table t1 drop index d; +affected rows: 0 +info: Records: 0 Duplicates: 0 Warnings: 0 +insert into t1 values(8,9,'fff','fff'); +select * from t1; +a b c d +1 1 ab ab +2 2 ac ac +3 3 ad ad +4 4 afe afe +5 1 ggg ggg +8 9 fff fff +select * from t1 force index(c) order by c; +a b c d +1 1 ab ab +2 2 ac ac +3 3 ad ad +4 4 afe afe +8 9 fff fff +5 1 ggg ggg +analyze table t1; +explain select * from t1 order by b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 6 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 6 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c`,`test`.`t1`.`d` AS `d` from `test`.`t1` order by `test`.`t1`.`b` +explain select * from t1 force index(c) order by c; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 6 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 6 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c`,`test`.`t1`.`d` AS `d` from `test`.`t1` FORCE INDEX (`c`) order by `test`.`t1`.`c` +explain select * from t1 order by d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 6 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 6 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c`,`test`.`t1`.`d` AS `d` from `test`.`t1` order by `test`.`t1`.`d` +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int NOT NULL, + `b` int DEFAULT NULL, + `c` char(10) DEFAULT NULL, + `d` varchar(20) DEFAULT NULL, + PRIMARY KEY (`a`), + KEY `c` (`c`(2)) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +create table t1(a int not null, b int, c char(10), d varchar(20), primary key (a)) engine = innodb; +insert into t1 values (1,1,'ab','ab'),(2,2,'ac','ac'),(3,2,'ad','ad'),(4,4,'afe','afe'); +commit; +alter table t1 add unique index (b,c); +affected rows: 0 +info: Records: 0 Duplicates: 0 Warnings: 0 +insert into t1 values(8,9,'fff','fff'); +select * from t1; +a b c d +1 1 ab ab +2 2 ac ac +3 2 ad ad +4 4 afe afe +8 9 fff fff +select * from t1 force index(b) order by b; +a b c d +1 1 ab ab +2 2 ac ac +3 2 ad ad +4 4 afe afe +8 9 fff fff +analyze table t1; +explain select * from t1 force index(b) order by b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL b 46 NULL 5 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c`,`test`.`t1`.`d` AS `d` from `test`.`t1` FORCE INDEX (`b`) order by `test`.`t1`.`b` +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int NOT NULL, + `b` int DEFAULT NULL, + `c` char(10) DEFAULT NULL, + `d` varchar(20) DEFAULT NULL, + PRIMARY KEY (`a`), + UNIQUE KEY `b` (`b`,`c`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +alter table t1 add index (b,c); +affected rows: 0 +info: Records: 0 Duplicates: 0 Warnings: 0 +insert into t1 values(11,11,'kkk','kkk'); +select * from t1; +a b c d +1 1 ab ab +2 2 ac ac +3 2 ad ad +4 4 afe afe +8 9 fff fff +11 11 kkk kkk +select * from t1 force index(b) order by b; +a b c d +1 1 ab ab +2 2 ac ac +3 2 ad ad +4 4 afe afe +8 9 fff fff +11 11 kkk kkk +analyze table t1; +explain select * from t1 force index(b) order by b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 6 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL b 46 NULL 6 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c`,`test`.`t1`.`d` AS `d` from `test`.`t1` FORCE INDEX (`b`) order by `test`.`t1`.`b` +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int NOT NULL, + `b` int DEFAULT NULL, + `c` char(10) DEFAULT NULL, + `d` varchar(20) DEFAULT NULL, + PRIMARY KEY (`a`), + UNIQUE KEY `b` (`b`,`c`), + KEY `b_2` (`b`,`c`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +alter table t1 add unique index (c,d); +affected rows: 0 +info: Records: 0 Duplicates: 0 Warnings: 0 +insert into t1 values(13,13,'yyy','aaa'); +select * from t1; +a b c d +1 1 ab ab +2 2 ac ac +3 2 ad ad +4 4 afe afe +8 9 fff fff +11 11 kkk kkk +13 13 yyy aaa +select * from t1 force index(b) order by b; +a b c d +1 1 ab ab +2 2 ac ac +3 2 ad ad +4 4 afe afe +8 9 fff fff +11 11 kkk kkk +13 13 yyy aaa +select * from t1 force index(c) order by c; +a b c d +1 1 ab ab +2 2 ac ac +3 2 ad ad +4 4 afe afe +8 9 fff fff +11 11 kkk kkk +13 13 yyy aaa +analyze table t1; +explain select * from t1 force index(b) order by b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL b 46 NULL 7 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c`,`test`.`t1`.`d` AS `d` from `test`.`t1` FORCE INDEX (`b`) order by `test`.`t1`.`b` +explain select * from t1 force index(c) order by c; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL c 124 NULL 7 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c`,`test`.`t1`.`d` AS `d` from `test`.`t1` FORCE INDEX (`c`) order by `test`.`t1`.`c` +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int NOT NULL, + `b` int DEFAULT NULL, + `c` char(10) DEFAULT NULL, + `d` varchar(20) DEFAULT NULL, + PRIMARY KEY (`a`), + UNIQUE KEY `b` (`b`,`c`), + UNIQUE KEY `c` (`c`,`d`), + KEY `b_2` (`b`,`c`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +create table t1(a int not null, b int not null, c int, primary key (a), key (b)) engine = innodb; +create table t3(a int not null, c int not null, d int, primary key (a), key (c)) engine = innodb; +create table t4(a int not null, d int not null, e int, primary key (a), key (d)) engine = innodb; +create table t2(a int not null, b int, c int, d int, e int, +foreign key (b) references t1(b) on delete set null, +foreign key (c) references t3(c), foreign key (d) references t4(d) on update set null) +engine = innodb; +alter table t1 drop index b; +ERROR HY000: Cannot drop index 'b': needed in a foreign key constraint +alter table t3 drop index c; +ERROR HY000: Cannot drop index 'c': needed in a foreign key constraint +alter table t4 drop index d; +ERROR HY000: Cannot drop index 'd': needed in a foreign key constraint +alter table t2 drop index b; +ERROR HY000: Cannot drop index 'b': needed in a foreign key constraint +alter table t2 drop index b, drop index c, drop index d; +ERROR HY000: Cannot drop index 'b': needed in a foreign key constraint +alter table t2 MODIFY b INT NOT NULL, ALGORITHM=COPY; +ERROR HY000: Column 'b' cannot be NOT NULL: needed in a foreign key constraint 't2_ibfk_1' SET NULL +alter table t2 MODIFY b INT NOT NULL, ALGORITHM=INPLACE; +ERROR HY000: Column 'b' cannot be NOT NULL: needed in a foreign key constraint 't2_ibfk_1' SET NULL +SET FOREIGN_KEY_CHECKS=0; +alter table t2 DROP COLUMN b, ALGORITHM=COPY; +ERROR HY000: Cannot drop column 'b': needed in a foreign key constraint 't2_ibfk_1' +alter table t2 DROP COLUMN b; +ERROR HY000: Cannot drop column 'b': needed in a foreign key constraint 't2_ibfk_1' +alter table t1 DROP COLUMN b, ALGORITHM=COPY; +ERROR HY000: Cannot drop column 'b': needed in a foreign key constraint 't2_ibfk_1' of table 't2' +alter table t1 DROP COLUMN b; +ERROR HY000: Cannot drop column 'b': needed in a foreign key constraint 't2_ibfk_1' of table 't2' +SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS; +create unique index dc on t2 (d,c); +affected rows: 0 +info: Records: 0 Duplicates: 0 Warnings: 0 +create index dc on t1 (b,c); +affected rows: 0 +info: Records: 0 Duplicates: 0 Warnings: 0 +alter table t2 add primary key (alpha), change a alpha int, +change b beta int not null, change c charlie int not null; +ERROR HY000: Column 'beta' cannot be NOT NULL: needed in a foreign key constraint 't2_ibfk_1' SET NULL +alter table t2 add primary key (alpha), change a alpha int, +change c charlie int not null, change d delta int not null; +ERROR HY000: Column 'delta' cannot be NOT NULL: needed in a foreign key constraint 't2_ibfk_3' SET NULL +alter table t2 add primary key (alpha), change a alpha int, +change b beta int, modify c int not null; +affected rows: 0 +info: Records: 0 Duplicates: 0 Warnings: 0 +insert into t1 values (1,1,1); +insert into t3 values (1,1,1); +insert into t4 values (1,1,1); +insert into t2 values (1,1,1,1,1); +commit; +alter table t4 add constraint dc foreign key (a) references t1(a); +affected rows: 1 +info: Records: 1 Duplicates: 0 Warnings: 0 +show create table t4; +Table Create Table +t4 CREATE TABLE `t4` ( + `a` int NOT NULL, + `d` int NOT NULL, + `e` int DEFAULT NULL, + PRIMARY KEY (`a`), + KEY `d` (`d`), + CONSTRAINT `dc` FOREIGN KEY (`a`) REFERENCES `t1` (`a`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +alter table t3 add constraint dc foreign key (a) references t1(a); +ERROR HY000: Duplicate foreign key constraint name 'dc' +SET FOREIGN_KEY_CHECKS=0; +alter table t3 add constraint dc foreign key (a) references t1(a); +ERROR HY000: Duplicate foreign key constraint name 'dc' +SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS; +show create table t3; +Table Create Table +t3 CREATE TABLE `t3` ( + `a` int NOT NULL, + `c` int NOT NULL, + `d` int DEFAULT NULL, + PRIMARY KEY (`a`), + KEY `c` (`c`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +alter table t2 drop index b, add index (beta); +affected rows: 0 +info: Records: 0 Duplicates: 0 Warnings: 0 +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `alpha` int NOT NULL, + `beta` int DEFAULT NULL, + `c` int NOT NULL, + `d` int DEFAULT NULL, + `e` int DEFAULT NULL, + PRIMARY KEY (`alpha`), + UNIQUE KEY `dc` (`d`,`c`), + KEY `c` (`c`), + KEY `beta` (`beta`), + CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`beta`) REFERENCES `t1` (`b`) ON DELETE SET NULL, + CONSTRAINT `t2_ibfk_2` FOREIGN KEY (`c`) REFERENCES `t3` (`c`), + CONSTRAINT `t2_ibfk_3` FOREIGN KEY (`d`) REFERENCES `t4` (`d`) ON UPDATE SET NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +delete from t1; +ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t4`, CONSTRAINT `dc` FOREIGN KEY (`a`) REFERENCES `t1` (`a`)) +drop index dc on t4; +ERROR 42000: Can't DROP 'dc'; check that column/key exists +alter table t3 drop foreign key dc; +ERROR 42000: Can't DROP 'dc'; check that column/key exists +alter table t4 drop foreign key dc; +affected rows: 0 +info: Records: 0 Duplicates: 0 Warnings: 0 +select * from t2; +alpha beta c d e +1 1 1 1 1 +delete from t1; +select * from t2; +alpha beta c d e +1 NULL 1 1 1 +drop table t2,t4,t3,t1; +create table t1(a int not null, b int, c char(10), d varchar(20), primary key (a)) engine = innodb default charset=utf8; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +insert into t1 values (1,1,'ab','ab'),(2,2,'ac','ac'),(3,2,'ad','ad'),(4,4,'afe','afe'); +commit; +alter table t1 add unique index (b); +ERROR 23000: Duplicate entry '2' for key 't1.b' +insert into t1 values(8,9,'fff','fff'); +select * from t1; +a b c d +1 1 ab ab +2 2 ac ac +3 2 ad ad +4 4 afe afe +8 9 fff fff +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int NOT NULL, + `b` int DEFAULT NULL, + `c` char(10) DEFAULT NULL, + `d` varchar(20) DEFAULT NULL, + PRIMARY KEY (`a`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 +alter table t1 add index (b); +insert into t1 values(10,10,'kkk','iii'); +select * from t1; +a b c d +1 1 ab ab +2 2 ac ac +3 2 ad ad +4 4 afe afe +8 9 fff fff +10 10 kkk iii +select * from t1 force index(b) order by b; +a b c d +1 1 ab ab +2 2 ac ac +3 2 ad ad +4 4 afe afe +8 9 fff fff +10 10 kkk iii +explain select * from t1 force index(b) order by b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 6 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL b 5 NULL 6 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c`,`test`.`t1`.`d` AS `d` from `test`.`t1` FORCE INDEX (`b`) order by `test`.`t1`.`b` +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int NOT NULL, + `b` int DEFAULT NULL, + `c` char(10) DEFAULT NULL, + `d` varchar(20) DEFAULT NULL, + PRIMARY KEY (`a`), + KEY `b` (`b`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 +alter table t1 add unique index (c), add index (d); +insert into t1 values(11,11,'aaa','mmm'); +select * from t1; +a b c d +1 1 ab ab +2 2 ac ac +3 2 ad ad +4 4 afe afe +8 9 fff fff +10 10 kkk iii +11 11 aaa mmm +select * from t1 force index(b) order by b; +a b c d +1 1 ab ab +2 2 ac ac +3 2 ad ad +4 4 afe afe +8 9 fff fff +10 10 kkk iii +11 11 aaa mmm +select * from t1 force index(c) order by c; +a b c d +11 11 aaa mmm +1 1 ab ab +2 2 ac ac +3 2 ad ad +4 4 afe afe +8 9 fff fff +10 10 kkk iii +select * from t1 force index(d) order by d; +a b c d +1 1 ab ab +2 2 ac ac +3 2 ad ad +4 4 afe afe +8 9 fff fff +10 10 kkk iii +11 11 aaa mmm +explain select * from t1 force index(b) order by b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL b 5 NULL 7 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c`,`test`.`t1`.`d` AS `d` from `test`.`t1` FORCE INDEX (`b`) order by `test`.`t1`.`b` +explain select * from t1 force index(c) order by c; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL c 31 NULL 7 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c`,`test`.`t1`.`d` AS `d` from `test`.`t1` FORCE INDEX (`c`) order by `test`.`t1`.`c` +explain select * from t1 force index(d) order by d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL d 63 NULL 7 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c`,`test`.`t1`.`d` AS `d` from `test`.`t1` FORCE INDEX (`d`) order by `test`.`t1`.`d` +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int NOT NULL, + `b` int DEFAULT NULL, + `c` char(10) DEFAULT NULL, + `d` varchar(20) DEFAULT NULL, + PRIMARY KEY (`a`), + UNIQUE KEY `c` (`c`), + KEY `b` (`b`), + KEY `d` (`d`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 +check table t1; +Table Op Msg_type Msg_text +test.t1 check status OK +drop table t1; +create table t1(a int not null, b int) engine = innodb; +insert into t1 values (1,1),(1,1),(1,1),(1,1); +alter table t1 add unique index (a); +ERROR 23000: Duplicate entry '1' for key 't1.a' +alter table t1 add unique index (b); +ERROR 23000: Duplicate entry '1' for key 't1.b' +alter table t1 add unique index (a), add unique index(b); +ERROR 23000: Duplicate entry '1' for key 't1.a' +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int NOT NULL, + `b` int DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +create table t1(a int not null, c int not null,b int, primary key(a), unique key(c), key(b)) engine = innodb; +alter table t1 drop index c, drop index b; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int NOT NULL, + `c` int NOT NULL, + `b` int DEFAULT NULL, + PRIMARY KEY (`a`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +create table t1(a int not null, b int, primary key(a)) engine = innodb; +alter table t1 add index (b); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int NOT NULL, + `b` int DEFAULT NULL, + PRIMARY KEY (`a`), + KEY `b` (`b`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +create table t1(a int not null, b int, c char(10), d varchar(20), primary key (a)) engine = innodb; +insert into t1 values (1,1,'ab','ab'),(2,2,'ac','ac'),(3,3,'ac','ac'),(4,4,'afe','afe'),(5,4,'affe','affe'); +alter table t1 add unique index (b), add unique index (c), add unique index (d); +ERROR 23000: Duplicate entry '4' for key 't1.b' +alter table t1 add unique index (c), add unique index (b), add index (d); +ERROR 23000: Duplicate entry 'ac' for key 't1.c' +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int NOT NULL, + `b` int DEFAULT NULL, + `c` char(10) DEFAULT NULL, + `d` varchar(20) DEFAULT NULL, + PRIMARY KEY (`a`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +create table t1(a int not null, b int not null, c int, primary key (a), key(c)) engine=innodb; +insert into t1 values (5,1,5),(4,2,4),(3,3,3),(2,4,2),(1,5,1); +alter table t1 add unique index (b); +affected rows: 0 +info: Records: 0 Duplicates: 0 Warnings: 0 +insert into t1 values (10,20,20),(11,19,19),(12,18,18),(13,17,17); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int NOT NULL, + `b` int NOT NULL, + `c` int DEFAULT NULL, + PRIMARY KEY (`a`), + UNIQUE KEY `b` (`b`), + KEY `c` (`c`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +check table t1; +Table Op Msg_type Msg_text +test.t1 check status OK +analyze table t1; +explain select * from t1 force index(c) order by c; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 9 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL c 5 NULL 9 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` FORCE INDEX (`c`) order by `test`.`t1`.`c` +explain select * from t1 order by a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 9 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL PRIMARY 4 NULL 9 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` order by `test`.`t1`.`a` +explain select * from t1 force index(b) order by b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 9 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL b 4 NULL 9 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` FORCE INDEX (`b`) order by `test`.`t1`.`b` +select * from t1 order by a; +a b c +1 5 1 +2 4 2 +3 3 3 +4 2 4 +5 1 5 +10 20 20 +11 19 19 +12 18 18 +13 17 17 +select * from t1 force index(b) order by b; +a b c +5 1 5 +4 2 4 +3 3 3 +2 4 2 +1 5 1 +13 17 17 +12 18 18 +11 19 19 +10 20 20 +select * from t1 force index(c) order by c; +a b c +1 5 1 +2 4 2 +3 3 3 +4 2 4 +5 1 5 +13 17 17 +12 18 18 +11 19 19 +10 20 20 +drop table t1; +create table t1(a int not null, b int not null) engine=innodb; +insert into t1 values (1,1); +alter table t1 add primary key(b); +affected rows: 0 +info: Records: 0 Duplicates: 0 Warnings: 0 +insert into t1 values (2,2); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int NOT NULL, + `b` int NOT NULL, + PRIMARY KEY (`b`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +check table t1; +Table Op Msg_type Msg_text +test.t1 check status OK +select * from t1; +a b +1 1 +2 2 +analyze table t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +explain select * from t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` +explain select * from t1 order by a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` order by `test`.`t1`.`a` +explain select * from t1 order by b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL PRIMARY 4 NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` order by `test`.`t1`.`b` +checksum table t1; +Table Checksum +test.t1 582702641 +drop table t1; +create table t1(a int not null) engine=innodb; +insert into t1 values (1); +alter table t1 add primary key(a); +affected rows: 0 +info: Records: 0 Duplicates: 0 Warnings: 0 +insert into t1 values (2); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int NOT NULL, + PRIMARY KEY (`a`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +check table t1; +Table Op Msg_type Msg_text +test.t1 check status OK +commit; +select * from t1; +a +1 +2 +analyze table t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +explain select * from t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL PRIMARY 4 NULL 2 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` +explain select * from t1 order by a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL PRIMARY 4 NULL 2 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` order by `test`.`t1`.`a` +drop table t1; +SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0; +SET FOREIGN_KEY_CHECKS=0; +CREATE TABLE t1( +c1 BIGINT(12) NOT NULL, +PRIMARY KEY (c1) +) ENGINE=InnoDB DEFAULT CHARSET=latin1; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t2( +c1 BIGINT(16) NOT NULL, +c2 BIGINT(12) NOT NULL, +c3 BIGINT(12) NOT NULL, +PRIMARY KEY (c1) +) ENGINE=InnoDB DEFAULT CHARSET=latin1; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +ALTER TABLE t2 ADD CONSTRAINT fk_t2_ca +FOREIGN KEY (c3) REFERENCES t1(c1); +SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS; +SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `c1` bigint NOT NULL, + `c2` bigint NOT NULL, + `c3` bigint NOT NULL, + PRIMARY KEY (`c1`), + KEY `fk_t2_ca` (`c3`), + CONSTRAINT `fk_t2_ca` FOREIGN KEY (`c3`) REFERENCES `t1` (`c1`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +CREATE INDEX i_t2_c3_c2 ON t2(c3, c2); +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `c1` bigint NOT NULL, + `c2` bigint NOT NULL, + `c3` bigint NOT NULL, + PRIMARY KEY (`c1`), + KEY `i_t2_c3_c2` (`c3`,`c2`), + CONSTRAINT `fk_t2_ca` FOREIGN KEY (`c3`) REFERENCES `t1` (`c1`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS; +SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS; +INSERT INTO t2 VALUES(0,0,0); +ERROR 23000: Cannot add or update a child row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `fk_t2_ca` FOREIGN KEY (`c3`) REFERENCES `t1` (`c1`)) +INSERT INTO t1 VALUES(0); +INSERT INTO t2 VALUES(0,0,0); +DROP TABLE t2; +CREATE TABLE t2( +c1 BIGINT(16) NOT NULL, +c2 BIGINT(12) NOT NULL, +c3 BIGINT(12) NOT NULL, +PRIMARY KEY (c1,c2,c3) +) ENGINE=InnoDB DEFAULT CHARSET=latin1; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +SET FOREIGN_KEY_CHECKS=0; +ALTER TABLE t2 ADD CONSTRAINT fk_t2_ca +FOREIGN KEY (c3) REFERENCES t1(c1); +SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `c1` bigint NOT NULL, + `c2` bigint NOT NULL, + `c3` bigint NOT NULL, + PRIMARY KEY (`c1`,`c2`,`c3`), + KEY `fk_t2_ca` (`c3`), + CONSTRAINT `fk_t2_ca` FOREIGN KEY (`c3`) REFERENCES `t1` (`c1`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +CREATE INDEX i_t2_c3_c2 ON t2(c3, c2); +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `c1` bigint NOT NULL, + `c2` bigint NOT NULL, + `c3` bigint NOT NULL, + PRIMARY KEY (`c1`,`c2`,`c3`), + KEY `i_t2_c3_c2` (`c3`,`c2`), + CONSTRAINT `fk_t2_ca` FOREIGN KEY (`c3`) REFERENCES `t1` (`c1`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +INSERT INTO t2 VALUES(0,0,1); +ERROR 23000: Cannot add or update a child row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `fk_t2_ca` FOREIGN KEY (`c3`) REFERENCES `t1` (`c1`)) +INSERT INTO t2 VALUES(0,0,0); +DELETE FROM t1; +ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `fk_t2_ca` FOREIGN KEY (`c3`) REFERENCES `t1` (`c1`)) +DELETE FROM t2; +DROP TABLE t2; +DROP TABLE t1; +CREATE TABLE t1( +c1 BIGINT(12) NOT NULL, +c2 INT(4) NOT NULL, +PRIMARY KEY (c2,c1) +) ENGINE=InnoDB DEFAULT CHARSET=latin1; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t2( +c1 BIGINT(16) NOT NULL, +c2 BIGINT(12) NOT NULL, +c3 BIGINT(12) NOT NULL, +PRIMARY KEY (c1) +) ENGINE=InnoDB DEFAULT CHARSET=latin1; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +SET FOREIGN_KEY_CHECKS=0; +ALTER TABLE t2 ADD CONSTRAINT fk_t2_ca +FOREIGN KEY (c3,c2) REFERENCES t1(c1,c1), ALGORITHM=COPY; +ERROR HY000: Failed to add the foreign key constraint. Missing index for constraint 'fk_t2_ca' in the referenced table 't1' +ALTER TABLE t2 ADD CONSTRAINT fk_t2_ca +FOREIGN KEY (c3,c2) REFERENCES t1(c1,c1); +ERROR HY000: Failed to add the foreign key constraint. Missing index for constraint 'fk_t2_ca' in the referenced table 't1' +ALTER TABLE t2 ADD CONSTRAINT fk_t2_ca +FOREIGN KEY (c3,c2) REFERENCES t1(c1,c2), ALGORITHM=COPY; +ERROR HY000: Referencing column 'c2' and referenced column 'c2' in foreign key constraint 'fk_t2_ca' are incompatible. +ALTER TABLE t2 ADD CONSTRAINT fk_t2_ca +FOREIGN KEY (c3,c2) REFERENCES t1(c1,c2); +ERROR HY000: Referencing column 'c2' and referenced column 'c2' in foreign key constraint 'fk_t2_ca' are incompatible. +ALTER TABLE t2 ADD CONSTRAINT fk_t2_ca +FOREIGN KEY (c3,c2) REFERENCES t1(c2,c1), ALGORITHM=INPLACE; +ERROR HY000: Referencing column 'c3' and referenced column 'c2' in foreign key constraint 'fk_t2_ca' are incompatible. +ALTER TABLE t2 ADD CONSTRAINT fk_t2_ca +FOREIGN KEY (c3,c2) REFERENCES t1(c2,c1), ALGORITHM=COPY; +ERROR HY000: Referencing column 'c3' and referenced column 'c2' in foreign key constraint 'fk_t2_ca' are incompatible. +ALTER TABLE t1 MODIFY COLUMN c2 BIGINT(12) NOT NULL; +affected rows: 0 +info: Records: 0 Duplicates: 0 Warnings: 1 +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +ALTER TABLE t2 ADD CONSTRAINT fk_t2_ca +FOREIGN KEY (c3,c2) REFERENCES t1(c1,c2), ALGORITHM=COPY; +ERROR HY000: Failed to add the foreign key constraint. Missing index for constraint 'fk_t2_ca' in the referenced table 't1' +ALTER TABLE t2 ADD CONSTRAINT fk_t2_ca +FOREIGN KEY (c3,c2) REFERENCES t1(c1,c2); +ERROR HY000: Failed to add the foreign key constraint. Missing index for constraint 'fk_t2_ca' in the referenced table 't1' +ALTER TABLE t2 ADD CONSTRAINT fk_t2_ca +FOREIGN KEY (c3,c2) REFERENCES t1(c2,c1); +affected rows: 0 +info: Records: 0 Duplicates: 0 Warnings: 0 +SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS; +affected rows: 0 +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` bigint NOT NULL, + `c2` bigint NOT NULL, + PRIMARY KEY (`c2`,`c1`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +affected rows: 1 +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `c1` bigint NOT NULL, + `c2` bigint NOT NULL, + `c3` bigint NOT NULL, + PRIMARY KEY (`c1`), + KEY `fk_t2_ca` (`c3`,`c2`), + CONSTRAINT `fk_t2_ca` FOREIGN KEY (`c3`, `c2`) REFERENCES `t1` (`c2`, `c1`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +affected rows: 1 +CREATE INDEX i_t2_c2_c1 ON t2(c2, c1); +affected rows: 0 +info: Records: 0 Duplicates: 0 Warnings: 0 +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `c1` bigint NOT NULL, + `c2` bigint NOT NULL, + `c3` bigint NOT NULL, + PRIMARY KEY (`c1`), + KEY `fk_t2_ca` (`c3`,`c2`), + KEY `i_t2_c2_c1` (`c2`,`c1`), + CONSTRAINT `fk_t2_ca` FOREIGN KEY (`c3`, `c2`) REFERENCES `t1` (`c2`, `c1`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +affected rows: 1 +CREATE INDEX i_t2_c3_c1_c2 ON t2(c3, c1, c2); +affected rows: 0 +info: Records: 0 Duplicates: 0 Warnings: 0 +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `c1` bigint NOT NULL, + `c2` bigint NOT NULL, + `c3` bigint NOT NULL, + PRIMARY KEY (`c1`), + KEY `fk_t2_ca` (`c3`,`c2`), + KEY `i_t2_c2_c1` (`c2`,`c1`), + KEY `i_t2_c3_c1_c2` (`c3`,`c1`,`c2`), + CONSTRAINT `fk_t2_ca` FOREIGN KEY (`c3`, `c2`) REFERENCES `t1` (`c2`, `c1`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +affected rows: 1 +CREATE INDEX i_t2_c3_c2 ON t2(c3, c2); +affected rows: 0 +info: Records: 0 Duplicates: 0 Warnings: 0 +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `c1` bigint NOT NULL, + `c2` bigint NOT NULL, + `c3` bigint NOT NULL, + PRIMARY KEY (`c1`), + KEY `i_t2_c2_c1` (`c2`,`c1`), + KEY `i_t2_c3_c1_c2` (`c3`,`c1`,`c2`), + KEY `i_t2_c3_c2` (`c3`,`c2`), + CONSTRAINT `fk_t2_ca` FOREIGN KEY (`c3`, `c2`) REFERENCES `t1` (`c2`, `c1`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +affected rows: 1 +DROP TABLE t2; +DROP TABLE t1; +CREATE TABLE t1 (a INT, b CHAR(1)) ENGINE=InnoDB; +INSERT INTO t1 VALUES (3,'a'),(3,'b'),(1,'c'),(0,'d'),(1,'e'); +CREATE TABLE t2 (a INT, b CHAR(1)) ENGINE=InnoDB; +CREATE TABLE t2i (a INT, b CHAR(1) NOT NULL) ENGINE=InnoDB; +CREATE TABLE t2c (a INT, b CHAR(1) NOT NULL) ENGINE=InnoDB; +INSERT INTO t2 SELECT * FROM t1; +INSERT INTO t2i SELECT * FROM t1; +INSERT INTO t2c SELECT * FROM t1; +BEGIN; +SELECT * FROM t1; +a b +3 a +3 b +1 c +0 d +1 e +SET lock_wait_timeout=1; +CREATE INDEX t1a ON t1(a); +ERROR HY000: Lock wait timeout exceeded; try restarting transaction +CREATE INDEX t2a ON t2(a); +affected rows: 0 +info: Records: 0 Duplicates: 0 Warnings: 0 +ALTER TABLE t2i ADD PRIMARY KEY(a,b), ADD INDEX t2a(a), ALGORITHM=INPLACE; +affected rows: 0 +info: Records: 0 Duplicates: 0 Warnings: 0 +ALTER TABLE t2c ADD PRIMARY KEY(a,b), ADD INDEX t2a(a), ALGORITHM=COPY; +affected rows: 5 +info: Records: 5 Duplicates: 0 Warnings: 0 +SELECT * FROM t2i; +ERROR HY000: Table definition has changed, please retry transaction +SELECT * FROM t2i FORCE INDEX(t2a) ORDER BY a; +ERROR HY000: Table definition has changed, please retry transaction +SELECT * FROM t2c; +ERROR HY000: Table definition has changed, please retry transaction +SELECT * FROM t2c FORCE INDEX(t2a) ORDER BY a; +ERROR HY000: Table definition has changed, please retry transaction +SELECT * FROM t2; +a b +3 a +3 b +1 c +0 d +1 e +SELECT * FROM t2 FORCE INDEX(t2a) ORDER BY a; +ERROR HY000: Table definition has changed, please retry transaction +SELECT * FROM t2; +a b +3 a +3 b +1 c +0 d +1 e +COMMIT; +SELECT * FROM t2; +a b +3 a +3 b +1 c +0 d +1 e +SELECT * FROM t2 FORCE INDEX(t2a) ORDER BY a; +a b +0 d +1 c +1 e +3 a +3 b +SELECT * FROM t2i; +a b +0 d +1 c +1 e +3 a +3 b +SELECT * FROM t2i FORCE INDEX(t2a) ORDER BY a; +a b +0 d +1 c +1 e +3 a +3 b +SELECT * FROM t2c; +a b +0 d +1 c +1 e +3 a +3 b +SELECT * FROM t2c FORCE INDEX(t2a) ORDER BY a; +a b +0 d +1 c +1 e +3 a +3 b +alter table t2 add index t2a(b); +ERROR 42000: Duplicate key name 't2a' +alter table t2 drop index t2a, add index t2a(b); +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `a` int DEFAULT NULL, + `b` char(1) DEFAULT NULL, + KEY `t2a` (`b`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +show create table t2i; +Table Create Table +t2i CREATE TABLE `t2i` ( + `a` int NOT NULL, + `b` char(1) NOT NULL, + PRIMARY KEY (`a`,`b`), + KEY `t2a` (`a`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +show create table t2c; +Table Create Table +t2c CREATE TABLE `t2c` ( + `a` int NOT NULL, + `b` char(1) NOT NULL, + PRIMARY KEY (`a`,`b`), + KEY `t2a` (`a`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +DROP TABLE t1,t2,t2c,t2i; +# +# Bug #17657223 EXCESSIVE TEMPORARY FILE USAGE IN ALTER TABLE +# +SET GLOBAL innodb_monitor_enable = module_ddl; +create table t1(f1 int not null, f2 blob)engine=innodb; +insert into t1 values(1, repeat('a',20000)); +# Skip sort +# Reusing the same pk +alter table t1 force; +affected rows: 0 +info: Records: 0 Duplicates: 0 Warnings: 0 +SELECT name, count_reset FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE +subsystem = 'ddl' and count_reset > 0; +name count_reset +SET GLOBAL innodb_monitor_reset = module_ddl; +drop table t1; +create table t1(f1 int not null, f2 int not null, +primary key(f1))engine=innodb; +insert into t1 values(1,2), (3,4); +# Add Secondary index. +# Skip temp file usage due to small table size +alter table t1 add key(f2); +affected rows: 0 +info: Records: 0 Duplicates: 0 Warnings: 0 +SELECT name, count_reset FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE +subsystem = 'ddl' and count_reset > 0; +name count_reset +SET GLOBAL innodb_monitor_reset = module_ddl; +drop table t1; +create table t480(a serial)engine=innodb; +insert into t480 +values(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(), +(),(),(),(),(),(),(),(); +insert into t480 select 0 from t480; +insert into t480 select 0 from t480; +insert into t480 select 0 from t480; +insert into t480 select 0 from t480; +create table t1(f1 int auto_increment not null, +f2 char(200) not null, f3 char(200) not null, +f4 char(200) not null,primary key(f1))engine=innodb charset latin1; +insert into t1 select NULL,'aaa','bbb','ccc' from t480; +insert into t1 select NULL,'aaaa','bbbb','cccc' from t480; +insert into t1 select NULL,'aaaaa','bbbbb','ccccc' from t480; +insert into t1 select NULL,'aaaaaa','bbbbbb','cccccc' from t480; +insert into t1 select NULL,'aaaaaaa','bbbbbbb','ccccccc' from t480; +insert into t1 select NULL,'aaaaaaaa','bbbbbbbb','cccccccc' from t480; +select count(*) from t1; +count(*) +2880 +# Skip sort +# Change PK from (f1) to (f1,f2,f3,f4) +alter table t1 drop primary key, add primary key(f1,f2,f3,f4); +affected rows: 0 +info: Records: 0 Duplicates: 0 Warnings: 0 +SELECT name, count_reset FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE +subsystem = 'ddl' and count_reset > 0; +name count_reset +SET GLOBAL innodb_monitor_reset = module_ddl; +# Skip sort +# Change PK from (f1,f2,f3,f4) to (f1,f2,added_columns) +alter table t1 drop primary key,add column f5 int not null, +add column f6 int not null,add primary key(f1,f2,f5,f6); +affected rows: 0 +info: Records: 0 Duplicates: 0 Warnings: 0 +SELECT name, count_reset FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE +subsystem = 'ddl' and count_reset > 0; +name count_reset +SET GLOBAL innodb_monitor_reset = module_ddl; +# Skip sort +# Change PK from (f1,f2,f5,f6) to (f1,f2,f5) +alter table t1 drop column f6; +affected rows: 0 +info: Records: 0 Duplicates: 0 Warnings: 0 +SELECT name, count_reset FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE +subsystem = 'ddl' and count_reset > 0; +name count_reset +SET GLOBAL innodb_monitor_reset = module_ddl; +# Skip sort +# Reusing the same PK +alter table t1 add column f6 int; +affected rows: 0 +info: Records: 0 Duplicates: 0 Warnings: 0 +SELECT name, count_reset FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE +subsystem = 'ddl' and count_reset > 0; +name count_reset +SET GLOBAL innodb_monitor_reset = module_ddl; +# Skip sort +# Reusing the same pk +alter table t1 drop column f6; +affected rows: 0 +info: Records: 0 Duplicates: 0 Warnings: 0 +SELECT name, count_reset FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE +subsystem = 'ddl' and count_reset > 0; +name count_reset +SET GLOBAL innodb_monitor_reset = module_ddl; +# Must sort +# Change PK from (f1,f2,f5) to (f1,f5) +alter table t1 drop column f2; +affected rows: 0 +info: Records: 0 Duplicates: 0 Warnings: 0 +SELECT name, count_reset FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE +subsystem = 'ddl' and count_reset > 0; +name count_reset +ddl_sort_file_alter_table 2 +SET GLOBAL innodb_monitor_reset = module_ddl; +# Skip sort +# Reusing the same pk +alter table t1 add column f2n int after f1, drop primary key, add +primary key (f1,f5,f2n); +affected rows: 0 +info: Records: 0 Duplicates: 0 Warnings: 0 +SELECT name, count_reset FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE +subsystem = 'ddl' and count_reset > 0; +name count_reset +SET GLOBAL innodb_monitor_reset = module_ddl; +# Skip sort +# Reusing the same pk +alter table t1 change f5 f2n int not null,change f2n f5 int not null, +add column f8 int not null; +affected rows: 0 +info: Records: 0 Duplicates: 0 Warnings: 0 +SELECT name, count_reset FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE +subsystem = 'ddl' and count_reset > 0; +name count_reset +SET GLOBAL innodb_monitor_reset = module_ddl; +# Skip sort +# Change PK from (f1,f4,f2n) to (f1,f4,added_column,f2n) +alter table t1 add column f7 int, drop primary key, +add primary key (f1,f5,f7,f2n); +affected rows: 0 +info: Records: 0 Duplicates: 0 Warnings: 0 +SELECT name, count_reset FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE +subsystem = 'ddl' and count_reset > 0; +name count_reset +ddl_sort_file_alter_table 2 +SET GLOBAL innodb_monitor_reset = module_ddl; +# Skip sort +# Reusing the same pk +alter table t1 force; +affected rows: 0 +info: Records: 0 Duplicates: 0 Warnings: 0 +SELECT name, count_reset FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE +subsystem = 'ddl' and count_reset > 0; +name count_reset +SET GLOBAL innodb_monitor_reset = module_ddl; +# Skip sort +# Reusing the same pk +alter table t1 row_format=compact; +affected rows: 0 +info: Records: 0 Duplicates: 0 Warnings: 0 +SELECT name, count_reset FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE +subsystem = 'ddl' and count_reset > 0; +name count_reset +SET GLOBAL innodb_monitor_reset = module_ddl; +# Skip sort +# Reusing the same pk +alter table t1 engine=innodb; +affected rows: 0 +info: Records: 0 Duplicates: 0 Warnings: 0 +SELECT name, count_reset FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE +subsystem = 'ddl' and count_reset > 0; +name count_reset +SET GLOBAL innodb_monitor_reset = module_ddl; +# Skip sort +# Optimize table +optimize table t1; +Table Op Msg_type Msg_text +test.t1 optimize note Table does not support optimize, doing recreate + analyze instead +test.t1 optimize status OK +affected rows: 2 +SELECT name, count_reset FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE +subsystem = 'ddl' and count_reset > 0; +name count_reset +SET GLOBAL innodb_monitor_reset = module_ddl; +# Sort files used for adding secondary index +alter table t1 drop primary key, add primary key(f1,f5,f7), add index +i(f3); +affected rows: 0 +info: Records: 0 Duplicates: 0 Warnings: 0 +SELECT name, count_reset FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE +subsystem = 'ddl' and count_reset > 0; +name count_reset +ddl_sort_file_alter_table 2 +SET GLOBAL innodb_monitor_reset = module_ddl; +# No sort files used for dropping secondary index +alter table t1 drop primary key, add primary key(f1,f5),drop index i; +affected rows: 0 +info: Records: 0 Duplicates: 0 Warnings: 0 +SELECT name, count_reset FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE +subsystem = 'ddl' and count_reset > 0; +name count_reset +SET GLOBAL innodb_monitor_reset = module_ddl; +# Skip sort +# Change PK(f1,f5) to (f1,added_columns) and drop f5 +alter table t1 drop primary key, add primary key(f1,f12), +drop column f5, add column f12 int not null; +affected rows: 0 +info: Records: 0 Duplicates: 0 Warnings: 0 +SELECT name, count_reset FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE +subsystem = 'ddl' and count_reset > 0; +name count_reset +SET GLOBAL innodb_monitor_reset = module_ddl; +# Must sort +# Change PK(f1,f12) to (f1,existing_columns) +alter table t1 drop primary key, add primary key(f1,f3); +affected rows: 0 +info: Records: 0 Duplicates: 0 Warnings: 0 +SELECT name, count_reset FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE +subsystem = 'ddl' and count_reset > 0; +name count_reset +ddl_sort_file_alter_table 2 +SET GLOBAL innodb_monitor_reset = module_ddl; +# Skip sort +# Change PK(f1,f3) to (f1,added_column,f3,added_column) +alter table t1 drop primary key, add column f3n int, +add column f4n int, add primary key(f1,f3n,f3,f4n); +affected rows: 0 +info: Records: 0 Duplicates: 0 Warnings: 0 +SELECT name, count_reset FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE +subsystem = 'ddl' and count_reset > 0; +name count_reset +SET GLOBAL innodb_monitor_reset = module_ddl; +# Adding Secondary index alone. +alter table t1 add key(f1); +affected rows: 0 +info: Records: 0 Duplicates: 0 Warnings: 0 +SELECT name, count_reset FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE +subsystem = 'ddl' and count_reset > 0; +name count_reset +ddl_sort_file_alter_table 2 +SET GLOBAL innodb_monitor_reset = module_ddl; +# Must sort +# Change PK(f1,f3) to (existing_column,f1) +alter table t1 drop primary key, add primary key(f4,f1); +affected rows: 0 +info: Records: 0 Duplicates: 0 Warnings: 0 +SELECT name, count_reset FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE +subsystem = 'ddl' and count_reset > 0; +name count_reset +ddl_sort_file_alter_table 3 +SET GLOBAL innodb_monitor_reset = module_ddl; +# Skip sort for PK. +# Change PK(f4,f1) to (added_columns,f4,f1) +# Secondary index rebuild happens +alter table t1 drop primary key, add column f5n int, +add column f6n int, add primary key(f5n,f6n,f4,f1); +affected rows: 0 +info: Records: 0 Duplicates: 0 Warnings: 0 +SELECT name, count_reset FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE +subsystem = 'ddl' and count_reset > 0; +name count_reset +ddl_sort_file_alter_table 2 +SET GLOBAL innodb_monitor_reset = module_ddl; +# Skip sort for PK. +# Change PK(f5n,f6n,f4,f1) to +# (added_columns,f5n,added_column,f6n,f4,f1) +# Secondary index rebuild happens +alter table t1 drop primary key, add column f7n int, +add column f8n int, add primary key(f7n,f5n,f8n,f6n,f4,f1); +affected rows: 0 +info: Records: 0 Duplicates: 0 Warnings: 0 +SELECT name, count_reset FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE +subsystem = 'ddl' and count_reset > 0; +name count_reset +ddl_sort_file_alter_table 2 +SET GLOBAL innodb_monitor_reset = module_ddl; +SET GLOBAL innodb_monitor_disable = module_ddl; +select count(*) from t1; +count(*) +2880 +drop table t1; +SET GLOBAL innodb_monitor_reset = default; +SET GLOBAL innodb_monitor_enable = default; +SET GLOBAL innodb_monitor_disable = default; +# Bug#19163915 INNODB: DUPLICATE RECORDS COULD EXIST +# WHEN SKIPPING SORT FOR CLUSTER INDEX +SELECT @@innodb_sort_buffer_size; +@@innodb_sort_buffer_size +65536 +create table t1(f1 int auto_increment not null, +f2 char(200) not null, f3 char(200) not null, +f4 char(200) not null,primary key(f1,f2,f3,f4)) charset latin1; +insert into t1 select NULL,'aaa','bbb','ccc' from t480; +insert into t1 values(106, 'aaa','bbb','cccc'); +select count(*) from t1; +count(*) +481 +# Skip sort +# Change PK from (f1,f2,f3,f4) to (f1,f2,f3) +alter table t1 drop primary key, add primary key(f1,f2,f3); +ERROR 23000: Duplicate entry '106-aaa-bbb' for key 't1.PRIMARY' +select count(*) from t1; +count(*) +481 +drop table t1; +create table t1(f1 int auto_increment not null, +f2 char(200) not null, f3 char(200) not null, +f4 char(200) not null,primary key(f1,f2,f3,f4)) charset latin1; +insert into t1 select NULL,'aaa','bbb','ccc' from t480; +insert into t1 values(108,'aaa','bbb','cccc'); +select count(*) from t1; +count(*) +481 +alter table t1 drop primary key, add primary key(f1,f2,f3); +ERROR 23000: Duplicate entry '108-aaa-bbb' for key 't1.PRIMARY' +select count(*) from t1; +count(*) +481 +drop table t1, t480; +# +# Bug #19896922 SORTING SKIPPED WHEN PREFIX LENGTH OF THE PK +# FIELD IS CHANGED +# +create table t1(a int not null, b varchar(30) not null, +primary key (b(10), a)) engine = innodb; +insert into t1 values(0,'khdHps6UxW8Lwaoxa604oK6zkb'),(1,'khdHps6UxW8L'); +select * from t1; +a b +0 khdHps6UxW8Lwaoxa604oK6zkb +1 khdHps6UxW8L +alter table t1 drop primary key, add primary key (b(18),a); +select * from t1; +a b +1 khdHps6UxW8L +0 khdHps6UxW8Lwaoxa604oK6zkb +drop table t1; +create table t1(a int not null, b varchar(30) not null, +primary key (b(10), a)) engine = innodb; +insert into t1 values(0,'khdHps6UxW8Lwaoxa604oK6zkb'),(1,'khdHps6UtW8L'); +select * from t1; +a b +1 khdHps6UtW8L +0 khdHps6UxW8Lwaoxa604oK6zkb +alter table t1 drop primary key, add primary key (b(8),a); +select * from t1; +a b +0 khdHps6UxW8Lwaoxa604oK6zkb +1 khdHps6UtW8L +drop table t1; +# +# Bug #21103101 SORTING SKIPPED WHEN DROPPING THE SINGLE +# COLUMN PRIMARY KEY +# +create table t1(f1 int not null, f2 int not null, +primary key (f1), unique key(f1, f2))engine=innodb; +insert into t1 values(1,3), (2,2); +alter table t1 drop column f1; +drop table t1; +create table t1(f1 int not null, f2 int not null, +primary key (f1), unique key(f1, f2))engine=innodb; +insert into t1 values(1,3), (2,2); +alter table t1 drop primary key, lock=none; +ERROR 0A000: LOCK=NONE is not supported. Reason: Dropping a primary key is not allowed without also adding a new primary key. Try LOCK=SHARED. +drop table t1; +# +# BUG#21612714 ALTER TABLE SORTING SKIPPED WHEN CHANGE PK AND DROP +# LAST COLUMN OF OLD PK +# +create table t1(o1 int, o2 int, o3 int not null, primary key(o1,o2)) engine = innodb; +insert into t1 values(1,1,2),(1,2,1); +alter table t1 drop primary key, add primary key(o1,o3), drop o2, lock=none; +drop table t1; +create table t1(o1 int, o2 int, o3 int not null, primary key(o1,o2)) engine = innodb; +insert into t1 values(1,1,2),(1,2,1); +alter table t1 drop o1, drop o2, add primary key(o3), lock=none; +drop table t1; +create table t1(o1 int, o2 int, o3 int not null, primary key(o1,o2)) engine = innodb; +insert into t1 values(1,1,2),(1,2,1); +alter table t1 drop primary key, add primary key(o1,o3), lock=none; +drop table t1; +create table t1(o1 int, o2 int, o3 int not null, primary key(o1,o2)) engine = innodb; +insert into t1 values(1,1,2),(1,2,1); +alter table t1 drop primary key, add primary key(o3), lock=none; +drop table t1; +create table t1(o1 int, o2 int, o3 int not null, primary key(o1,o2)) engine = innodb; +insert into t1 values(1,1,2),(1,2,1); +alter table t1 add column n1 int not null, drop primary key, add primary key(n1,o3), lock=none; +drop table t1; +create table t1(o1 int, o2 int, o3 int not null, primary key(o1,o2)) engine = innodb; +insert into t1 values(1,1,2),(2,2,1); +alter table t1 add column n1 int not null, drop primary key, add primary key(o3,n1), lock=none; +drop table t1; +create table t1(o1 int, o2 int, o3 int not null, primary key(o1,o2)) engine = innodb; +insert into t1 values(1,2,2),(2,1,1); +alter table t1 drop primary key, add primary key(o2, o1), lock=none; +drop table t1; +create table t1(o1 int, o2 int, o3 int not null, primary key(o1,o2)) engine = innodb; +insert into t1 values(1,2,2),(2,1,1); +alter table t1 drop primary key, add primary key(o2), lock=none; +drop table t1; +create table t1(o1 int, o2 int, o3 int not null, primary key(o1,o2)) engine = innodb; +insert into t1 values(1,2,2),(2,1,1); +alter table t1 drop primary key, add primary key(o2,o3), lock=none; +drop table t1; +create table t1(o1 int, o2 int, o3 int not null, primary key(o2,o1)) engine = innodb; +insert into t1 values(1,1,2),(2,1,1); +alter table t1 drop primary key, add primary key(o2,o3), lock=none; +drop table t1; +create table t1(o1 int, o2 int, o3 int not null, primary key(o1,o2)) engine = innodb; +insert into t1 values(1,1,2),(1,2,1); +alter table t1 drop primary key, add primary key(o1,o3,o2), lock=none; +drop table t1; +create table t1(o1 int, o2 int, o3 int not null, primary key(o1,o2)) engine = innodb; +insert into t1 values(1,2,2),(2,1,1); +alter table t1 drop primary key, add primary key(o3,o1,o2), lock=none; +drop table t1; +create table t1(o1 int, o2 int, o3 int, primary key(o1,o2,o3)) engine = innodb; +insert into t1 values(1,1,2),(1,2,1); +alter table t1 drop primary key, add primary key(o1,o3), lock=none; +drop table t1; +create table t1(o1 int, o2 int, o3 int, primary key(o1,o2,o3)) engine = innodb; +insert into t1 values(1,2,2),(2,1,1); +alter table t1 drop o1, lock=none; +drop table t1; +create table t1(o1 int, o2 int, o3 int, primary key(o1,o2,o3)) engine = innodb; +insert into t1 values(1,1,2),(1,2,1); +alter table t1 drop o2, lock=none; +drop table t1; +create table t1(o1 int, o2 int, o3 int, primary key(o1,o2,o3)) engine = innodb; +insert into t1 values(1,2,2),(2,1,1); +alter table t1 drop o1, drop o2, lock=none; +drop table t1; +create table t1(o1 varchar(10), o2 int, o3 int not null, primary key(o1(2), o2)) engine = innodb; +insert into t1 values('abd', 1, 1), ('abc', 2, 2); +alter table t1 drop primary key, add primary key(o1(3), o2), lock=none; +drop table t1; +create table t1(o1 varchar(10), o2 int, o3 int not null, primary key(o1(2), o2)) engine = innodb; +insert into t1 values('abd', 1, 1), ('abc', 2, 2); +alter table t1 drop primary key, add primary key(o1, o2), lock=none; +drop table t1; +create table t1(o1 varchar(10), o2 int, o3 int not null, primary key(o1(2), o2)) engine = innodb; +insert into t1 values('abd', 1, 1), ('abc', 2, 2); +alter table t1 drop primary key, add primary key(o1(3), o3), lock=none; +drop table t1; +create table t1(o1 varchar(10), o2 int, o3 int not null, primary key(o1(2), o2)) engine = innodb; +insert into t1 values('abd', 1, 1), ('abc', 2, 2); +alter table t1 drop primary key, add primary key(o1, o3), lock=none; +drop table t1; +create table t1(o1 varchar(10), o2 int, o3 int not null, primary key(o1(3), o2)) engine = innodb; +insert into t1 values('abc', 2, 1), ('abd', 1, 2); +alter table t1 drop primary key, add primary key(o1(2), o2), lock=none; +drop table t1; +create table t1(o1 varchar(10), o2 int, o3 int not null, primary key(o1, o2)) engine = innodb; +insert into t1 values('abc', 2, 1), ('abd', 1, 2); +alter table t1 drop primary key, add primary key(o1(2), o2), lock=none; +drop table t1; +create table t1(o1 varchar(10), o2 int, o3 int not null, primary key(o1(3), o2)) engine = innodb; +insert into t1 values('abc', 2, 2), ('abd', 1, 1); +alter table t1 drop primary key, add primary key(o1(2), o3), lock=none; +drop table t1; +create table t1(o1 varchar(10), o2 int, o3 int not null, primary key(o1, o2)) engine = innodb; +insert into t1 values('abc', 2, 2), ('abd', 1, 1); +alter table t1 drop primary key, add primary key(o1(2), o3), lock=none; +drop table t1; +create table t1(o1 int, o2 varchar(10), o3 int, primary key(o1,o2(2),o3)) engine = innodb; +insert into t1 values(1, 'abd', 1), (1, 'abc', 2); +alter table t1 drop primary key, add primary key(o1,o2(3)), lock=none; +drop table t1; +create table t1(o1 int, o2 varchar(10), o3 int, primary key(o1,o2(2),o3)) engine = innodb; +insert into t1 values(1, 'abd', 1), (1, 'abc', 2); +alter table t1 drop primary key, add primary key(o1,o2), lock=none; +drop table t1; +create table t1(o1 varchar(10), o2 varchar(10), primary key(o1(3),o2(3))) engine = innodb; +insert into t1 values('abc', 'acd'), ('abd', 'abd'); +alter table t1 drop primary key, add primary key(o1(2),o2(3)), lock=none; +drop table t1; +create table t1(o1 varchar(10), o2 varchar(10), primary key(o1,o2)) engine = innodb; +insert into t1 values('abc', 'acd'), ('abd', 'abd'); +alter table t1 drop primary key, add primary key(o1(2),o2), lock=none; +drop table t1; +create table t1(o1 varchar(10), o2 varchar(10), primary key(o1(3),o2(3))) engine = innodb; +insert into t1 values('abd', 'acd'), ('acd', 'abd'); +alter table t1 drop primary key, add primary key(o2(3),o1(3)), lock=none; +drop table t1; +create table t1(o1 varchar(10), o2 varchar(10), primary key(o1,o2)) engine = innodb; +insert into t1 values('abd', 'acd'), ('acd', 'abd'); +alter table t1 drop primary key, add primary key(o2,o1), lock=none; +drop table t1; +CREATE TABLE t1(a INT NOT NULL, b INT, PRIMARY KEY (a ASC)) ENGINE=INNODB; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int NOT NULL, + `b` int DEFAULT NULL, + PRIMARY KEY (`a`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +INSERT INTO t1 VALUES(5,5), (4,4), (3,4), (2,3); +ALTER TABLE t1 DROP PRIMARY KEY, ADD PRIMARY KEY (a DESC); +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT * FROM t1; +a b +5 5 +4 4 +3 4 +2 3 +ALTER TABLE t1 DROP PRIMARY KEY, ADD PRIMARY KEY (a ASC); +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT * FROM t1; +a b +2 3 +3 4 +4 4 +5 5 +DROP TABLE t1; +create table t1(o1 varchar(10), primary key(o1(2))) engine = innodb; +insert into t1 values('abd'), ('acd'); +alter table t1 drop primary key, add primary key(o1(3)), lock=none; +drop table t1; +create table t1(o1 varchar(10), primary key(o1(2))) engine = innodb; +insert into t1 values('abd'), ('acd'); +alter table t1 drop primary key, add primary key(o1), lock=none; +drop table t1; +create table t1(o1 varchar(10), primary key(o1(2))) engine = innodb; +insert into t1 values('abd'), ('acd'); +alter table t1 add n1 int not null, drop primary key, add primary key(o1(3), n1), lock=none; +drop table t1; +create table t1(o1 varchar(10), primary key(o1(2))) engine = innodb; +insert into t1 values('abd'), ('acd'); +alter table t1 add n1 int not null, drop primary key, add primary key(o1, n1), lock=none; +drop table t1; +create table t1(o1 varchar(10), o2 int not null, primary key(o1(2))) engine = innodb; +insert into t1 values('abd', 1), ('acd', 2); +alter table t1 add n1 int not null, drop primary key, add primary key(o1(3), o2), lock=none; +drop table t1; +create table t1(o1 varchar(10), o2 int not null, primary key(o1(2))) engine = innodb; +insert into t1 values('abd', 1), ('acd', 2); +alter table t1 add n1 int not null, drop primary key, add primary key(o1, o2), lock=none; +drop table t1; +create table t1(o1 varchar(10), primary key(o1(3))) engine = innodb; +insert into t1 values('abd'), ('acd'); +alter table t1 drop primary key, add primary key(o1(2)), lock=none; +drop table t1; +create table t1(o1 varchar(10), primary key(o1)) engine = innodb; +insert into t1 values('abd'), ('acd'); +alter table t1 drop primary key, add primary key(o1(2)), lock=none; +drop table t1; +create table t1(o1 varchar(10), o2 int, primary key(o1(3), o2)) engine = innodb; +insert into t1 values('abd', 1), ('acd', 2); +alter table t1 drop primary key, add primary key(o1(2)), lock=none; +drop table t1; +create table t1(o1 varchar(10), o2 int, primary key(o1, o2)) engine = innodb; +insert into t1 values('abd', 1), ('acd', 2); +alter table t1 drop primary key, add primary key(o1(2)), lock=none; +drop table t1; +create table t1(o1 varchar(10), o2 int, primary key(o1(3), o2)) engine = innodb; +insert into t1 values('abd', 1), ('acd', 2); +alter table t1 add n1 int not null, drop primary key, add primary key(o1(2),n1), lock=none; +drop table t1; +create table t1(o1 varchar(10), o2 int, primary key(o1, o2)) engine = innodb; +insert into t1 values('abd', 1), ('acd', 2); +alter table t1 add n1 int not null, drop primary key, add primary key(o1(2),n1), lock=none; +drop table t1; +create table t1(o1 varchar(10), o2 int, primary key(o1(3), o2)) engine = innodb; +insert into t1 values('abd', 1), ('acd', 2); +alter table t1 add n1 int not null, drop primary key, add primary key(o1(3),n1), lock=none; +drop table t1; +create table t1(o1 varchar(10), o2 int, primary key(o1, o2)) engine = innodb; +insert into t1 values('abd', 1), ('acd', 2); +alter table t1 add n1 int not null, drop primary key, add primary key(o1,n1), lock=none; +drop table t1; +create table t1(o1 int, o2 varchar(10), primary key(o1,o2(3))) engine = innodb; +insert into t1 values(1,'abd'), (2,'acd'); +alter table t1 drop primary key, add primary key(o1,o2(2)), lock=none; +drop table t1; +create table t1(o1 int, o2 varchar(10), primary key(o1,o2)) engine = innodb; +insert into t1 values(1,'abd'), (2,'acd'); +alter table t1 drop primary key, add primary key(o1,o2(2)), lock=none; +drop table t1; +create table t1(o1 int, o2 varchar(10), primary key(o1,o2(2))) engine = innodb; +insert into t1 values(1, 'abd'), (2, 'acd'); +alter table t1 drop primary key, add primary key(o1,o2(3)), lock=none; +drop table t1; +create table t1(o1 int, o2 varchar(10), primary key(o1,o2(2))) engine = innodb; +insert into t1 values(1, 'abd'), (2, 'acd'); +alter table t1 drop primary key, add primary key(o1,o2), lock=none; +drop table t1; +create table t1(o1 int, o2 varchar(10), o3 int, primary key(o1,o2(3),o3)) engine = innodb; +insert into t1 values(1, 'abd', 1), (2, 'acd', 2); +alter table t1 drop primary key, add primary key(o1,o2(2)), lock=none; +drop table t1; +create table t1(o1 int, o2 varchar(10), o3 int, primary key(o1,o2,o3)) engine = innodb; +insert into t1 values(1, 'abd', 1), (2, 'acd', 2); +alter table t1 drop primary key, add primary key(o1,o2(2)), lock=none; +drop table t1; +create table t1(o1 varchar(10), o2 varchar(10), primary key(o1(3),o2(3))) engine = innodb; +insert into t1 values('abd', 'acd'), ('acd', 'abd'); +alter table t1 drop primary key, add primary key(o1(3),o2(2)), lock=none; +drop table t1; +create table t1(o1 varchar(10), o2 varchar(10), primary key(o1,o2)) engine = innodb; +insert into t1 values('abd', 'acd'), ('acd', 'abd'); +alter table t1 drop primary key, add primary key(o1,o2(2)), lock=none; +drop table t1; +create table t1(o1 varchar(10), o2 varchar(10), primary key(o1(3),o2(2))) engine = innodb; +insert into t1 values('abd', 'acd'), ('acd', 'abd'); +alter table t1 drop primary key, add primary key(o1(3),o2(3)), lock=none; +drop table t1; +create table t1(o1 varchar(10), o2 varchar(10), primary key(o1,o2(2))) engine = innodb; +insert into t1 values('abd', 'acd'), ('acd', 'abd'); +alter table t1 drop primary key, add primary key(o1,o2), lock=none; +drop table t1; +create table t1(o1 varchar(10), o2 int, o3 varchar(10), primary key(o1(3),o2,o3(2))) engine = innodb; +insert into t1 values('abd', 1, 'acd'), ('acd', 2, 'abd'); +alter table t1 drop primary key, add primary key(o1(3),o2,o3(3)), lock=none; +drop table t1; +create table t1(o1 varchar(10), o2 int, o3 varchar(10), primary key(o1,o2,o3(2))) engine = innodb; +insert into t1 values('abd', 1, 'acd'), ('acd', 2, 'abd'); +alter table t1 drop primary key, add primary key(o1,o2,o3), lock=none; +drop table t1; +create table t1(o1 varchar(10), o2 int, o3 varchar(10), primary key(o1(3),o2,o3(3))) engine = innodb; +insert into t1 values('abd', 1, 'acd'), ('acd', 2, 'abd'); +alter table t1 drop primary key, add primary key(o1(3),o2,o3(2)), lock=none; +drop table t1; +create table t1(o1 varchar(10), o2 int, o3 varchar(10), primary key(o1,o2,o3(3))) engine = innodb; +insert into t1 values('abd', 1, 'acd'), ('acd', 2, 'abd'); +alter table t1 drop primary key, add primary key(o1,o2,o3(2)), lock=none; +drop table t1; +create table t1(o1 int, o2 int not null, primary key(o1)) engine = innodb; +insert into t1 values(1,1),(2,2); +alter table t1 drop primary key, add primary key(o1,o2), lock=none; +drop table t1; +create table t1(o1 int, o2 int not null, primary key(o1)) engine = innodb; +insert into t1 values(1,1),(2,2); +alter table t1 add n1 int not null, drop primary key, add primary key(o1,n1), lock=none; +drop table t1; +create table t1(o1 int, o2 int not null, primary key(o1)) engine = innodb; +insert into t1 values(1,1),(2,2); +alter table t1 add n1 int not null, drop primary key, add primary key(n1,o1), lock=none; +drop table t1; +create table t1(o1 int, o2 int not null, primary key(o1)) engine = innodb; +insert into t1 values(1,1),(2,2); +alter table t1 add n1 int not null, add n2 int not null, drop primary key, add primary key(n1,o1,n2), lock=none; +drop table t1; +create table t1(o1 int, o2 int not null, primary key(o1)) engine = innodb; +insert into t1 values(1,1),(2,2); +alter table t1 add n1 int not null, add n2 int not null, drop primary key, add primary key(n1,n2,o1), lock=none; +drop table t1; +create table t1(o1 int, o2 int not null, primary key(o1)) engine = innodb; +insert into t1 values(1,1),(2,2); +alter table t1 add n1 int not null, add n2 int not null, drop primary key, add primary key(o1,n1,n2), lock=none; +drop table t1; +create table t1(o1 int, o2 int not null, primary key(o1)) engine = innodb; +insert into t1 values(1,1),(2,2); +alter table t1 add n1 int not null, drop primary key, add primary key(o1,o2,n1), lock=none; +drop table t1; +create table t1(o1 int, o2 int not null, primary key(o1)) engine = innodb; +insert into t1 values(1,1),(2,2); +alter table t1 add n1 int not null, drop primary key, add primary key(o1,n1,o2), lock=none; +drop table t1; +create table t1(o1 int, o2 int not null, primary key(o1)) engine = innodb; +insert into t1 values(1,1),(2,2); +alter table t1 add n1 int not null, drop primary key, add primary key(n1,o1,o2), lock=none; +drop table t1; +create table t1(o1 int, o2 int not null, o3 int not null, primary key(o1)) engine = innodb; +insert into t1 values(1,1,2),(2,2,1); +alter table t1 drop primary key, add primary key(o1,o2,o3), lock=none; +drop table t1; +create table t1(o1 int, o2 int not null, o3 int not null, primary key(o1)) engine = innodb; +insert into t1 values(1,1,2),(2,2,1); +alter table t1 drop primary key, add primary key(o1,o3,o2), lock=none; +drop table t1; +create table t1(o1 int, o2 int, o3 int, primary key(o1,o2,o3)) engine = innodb; +insert into t1 values(1,1,2),(2,2,1); +alter table t1 drop primary key, add primary key(o1,o2), lock=none; +drop table t1; +create table t1(o1 int, o2 int, o3 int, o4 int not null, primary key(o1,o2,o3)) engine = innodb; +insert into t1 values(1,1,2,2),(2,2,1,1); +alter table t1 add n1 int not null, drop primary key, add primary key(o1,o2,o3,o4), lock=none; +drop table t1; +create table t1(o1 int, o2 int, o3 int, primary key(o1,o2,o3)) engine = innodb; +insert into t1 values(1,1,2),(2,2,1); +alter table t1 add n1 int not null, drop primary key, add primary key(o1,o2,n1), lock=none; +drop table t1; +create table t1(o1 int, o2 int, o3 int, primary key(o1,o2,o3)) engine = innodb; +insert into t1 values(1,1,2),(2,2,1); +alter table t1 add n1 int not null, drop primary key, add primary key(o1,n1,o2), lock=none; +drop table t1; +create table t1(o1 int, o2 int, o3 int, primary key(o1,o2,o3)) engine = innodb; +insert into t1 values(1,1,2),(2,2,1); +alter table t1 drop primary key, add primary key(o1), lock=none; +drop table t1; +CREATE TABLE t1(o1 int, o2 int, o3 int, PRIMARY KEY(o1), KEY(o2)) ENGINE=INNODB; +INSERT INTO t1 VALUES(1,1,2),(2,2,1); +EXPLAIN SELECT * FROM t1 ORDER BY o2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`o1` AS `o1`,`test`.`t1`.`o2` AS `o2`,`test`.`t1`.`o3` AS `o3` from `test`.`t1` order by `test`.`t1`.`o2` +SELECT * FROM t1 ORDER BY o2; +o1 o2 o3 +1 1 2 +2 2 1 +ALTER TABLE t1 DROP INDEX o2, ADD INDEX (o2 DESC); +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT * FROM t1; +o1 o2 o3 +1 1 2 +2 2 1 +EXPLAIN SELECT * FROM t1 ORDER BY o2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`o1` AS `o1`,`test`.`t1`.`o2` AS `o2`,`test`.`t1`.`o3` AS `o3` from `test`.`t1` order by `test`.`t1`.`o2` +SELECT * FROM t1 ORDER BY o2; +o1 o2 o3 +1 1 2 +2 2 1 +ALTER TABLE t1 DROP INDEX o2, ADD INDEX (o2 ASC); +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT * FROM t1; +o1 o2 o3 +1 1 2 +2 2 1 +EXPLAIN SELECT * FROM t1 ORDER BY o2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`o1` AS `o1`,`test`.`t1`.`o2` AS `o2`,`test`.`t1`.`o3` AS `o3` from `test`.`t1` order by `test`.`t1`.`o2` +SELECT * FROM t1 ORDER BY o2; +o1 o2 o3 +1 1 2 +2 2 1 +DROP TABLE t1; diff --git a/mysql-test/suite/innodb-index_ucs2.result-pq b/mysql-test/suite/innodb-index_ucs2.result-pq new file mode 100644 index 000000000000..63cccbc980ed --- /dev/null +++ b/mysql-test/suite/innodb-index_ucs2.result-pq @@ -0,0 +1,128 @@ +create table t1(a int not null, b int, c char(10), d varchar(20), primary key (a)) engine = innodb default charset=ucs2; +insert into t1 values (1,1,'ab','ab'),(2,2,'ac','ac'),(3,2,'ad','ad'),(4,4,'afe','afe'); +commit; +alter table t1 add unique index (b); +ERROR 23000: Duplicate entry '2' for key 't1.b' +insert into t1 values(8,9,'fff','fff'); +select * from t1; +a b c d +1 1 ab ab +2 2 ac ac +3 2 ad ad +4 4 afe afe +8 9 fff fff +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int NOT NULL, + `b` int DEFAULT NULL, + `c` char(10) DEFAULT NULL, + `d` varchar(20) DEFAULT NULL, + PRIMARY KEY (`a`) +) ENGINE=InnoDB DEFAULT CHARSET=ucs2 +alter table t1 add index (b); +insert into t1 values(10,10,'kkk','iii'); +select * from t1; +a b c d +1 1 ab ab +2 2 ac ac +3 2 ad ad +4 4 afe afe +8 9 fff fff +10 10 kkk iii +select * from t1 force index(b) order by b; +a b c d +1 1 ab ab +2 2 ac ac +3 2 ad ad +4 4 afe afe +8 9 fff fff +10 10 kkk iii +explain select * from t1 force index(b) order by b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 6 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL b 5 NULL 6 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c`,`test`.`t1`.`d` AS `d` from `test`.`t1` FORCE INDEX (`b`) order by `test`.`t1`.`b` +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int NOT NULL, + `b` int DEFAULT NULL, + `c` char(10) DEFAULT NULL, + `d` varchar(20) DEFAULT NULL, + PRIMARY KEY (`a`), + KEY `b` (`b`) +) ENGINE=InnoDB DEFAULT CHARSET=ucs2 +alter table t1 add unique index (c), add index (d); +insert into t1 values(11,11,'aaa','mmm'); +select * from t1; +a b c d +1 1 ab ab +2 2 ac ac +3 2 ad ad +4 4 afe afe +8 9 fff fff +10 10 kkk iii +11 11 aaa mmm +select * from t1 force index(b) order by b; +a b c d +1 1 ab ab +2 2 ac ac +3 2 ad ad +4 4 afe afe +8 9 fff fff +10 10 kkk iii +11 11 aaa mmm +select * from t1 force index(c) order by c; +a b c d +11 11 aaa mmm +1 1 ab ab +2 2 ac ac +3 2 ad ad +4 4 afe afe +8 9 fff fff +10 10 kkk iii +select * from t1 force index(d) order by d; +a b c d +1 1 ab ab +2 2 ac ac +3 2 ad ad +4 4 afe afe +8 9 fff fff +10 10 kkk iii +11 11 aaa mmm +explain select * from t1 force index(b) order by b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL b 5 NULL 7 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c`,`test`.`t1`.`d` AS `d` from `test`.`t1` FORCE INDEX (`b`) order by `test`.`t1`.`b` +explain select * from t1 force index(c) order by c; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL c 21 NULL 7 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c`,`test`.`t1`.`d` AS `d` from `test`.`t1` FORCE INDEX (`c`) order by `test`.`t1`.`c` +explain select * from t1 force index(d) order by d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL d 43 NULL 7 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c`,`test`.`t1`.`d` AS `d` from `test`.`t1` FORCE INDEX (`d`) order by `test`.`t1`.`d` +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int NOT NULL, + `b` int DEFAULT NULL, + `c` char(10) DEFAULT NULL, + `d` varchar(20) DEFAULT NULL, + PRIMARY KEY (`a`), + UNIQUE KEY `c` (`c`), + KEY `b` (`b`), + KEY `d` (`d`) +) ENGINE=InnoDB DEFAULT CHARSET=ucs2 +check table t1; +Table Op Msg_type Msg_text +test.t1 check status OK +drop table t1; diff --git a/mysql-test/suite/innodb.result-pq b/mysql-test/suite/innodb.result-pq new file mode 100644 index 000000000000..22f6a9b6b83c --- /dev/null +++ b/mysql-test/suite/innodb.result-pq @@ -0,0 +1,3491 @@ +drop table if exists t1,t2,t3,t4; +drop database if exists mysqltest; +CREATE TABLE bug58912 (a BLOB, b TEXT, PRIMARY KEY(a(1))) ENGINE=InnoDB; +INSERT INTO bug58912 VALUES(REPEAT('a',8000),REPEAT('b',8000)); +UPDATE bug58912 SET a=REPEAT('a',7999); +create table t1 (id int unsigned not null auto_increment, code tinyint unsigned not null, name char(20) not null, primary key (id), key (code), unique (name)) engine=innodb; +insert into t1 (code, name) values (1, 'Tim'), (1, 'Monty'), (2, 'David'), (2, 'Erik'), (3, 'Sasha'), (3, 'Jeremy'), (4, 'Matt'); +select id, code, name from t1 order by id; +id code name +1 1 Tim +2 1 Monty +3 2 David +4 2 Erik +5 3 Sasha +6 3 Jeremy +7 4 Matt +update ignore t1 set id = 8, name = 'Sinisa' where id < 3; +Warnings: +Warning 1062 Duplicate entry '8' for key 't1.PRIMARY' +select id, code, name from t1 order by id; +id code name +2 1 Monty +3 2 David +4 2 Erik +5 3 Sasha +6 3 Jeremy +7 4 Matt +8 1 Sinisa +update ignore t1 set id = id + 10, name = 'Ralph' where id < 4; +Warnings: +Warning 1062 Duplicate entry 'Ralph' for key 't1.name' +select id, code, name from t1 order by id; +id code name +3 2 David +4 2 Erik +5 3 Sasha +6 3 Jeremy +7 4 Matt +8 1 Sinisa +12 1 Ralph +drop table t1; +CREATE TABLE t1 ( +id int(11) NOT NULL auto_increment, +parent_id int(11) DEFAULT '0' NOT NULL, +level tinyint(4) DEFAULT '0' NOT NULL, +PRIMARY KEY (id), +KEY parent_id (parent_id), +KEY level (level) +) engine=innodb; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (1,0,0),(3,1,1),(4,1,1),(8,2,2),(9,2,2),(17,3,2),(22,4,2),(24,4,2),(28,5,2),(29,5,2),(30,5,2),(31,6,2),(32,6,2),(33,6,2),(203,7,2),(202,7,2),(20,3,2),(157,0,0),(193,5,2),(40,7,2),(2,1,1),(15,2,2),(6,1,1),(34,6,2),(35,6,2),(16,3,2),(7,1,1),(36,7,2),(18,3,2),(26,5,2),(27,5,2),(183,4,2),(38,7,2),(25,5,2),(37,7,2),(21,4,2),(19,3,2),(5,1,1),(179,5,2); +update t1 set parent_id=parent_id+100; +select * from t1 where parent_id=102; +id parent_id level +8 102 2 +9 102 2 +15 102 2 +update t1 set id=id+1000; +update t1 set id=1024 where id=1009; +Got one of the listed errors +select * from t1; +id parent_id level +1001 100 0 +1002 101 1 +1003 101 1 +1004 101 1 +1005 101 1 +1006 101 1 +1007 101 1 +1008 102 2 +1009 102 2 +1015 102 2 +1016 103 2 +1017 103 2 +1018 103 2 +1019 103 2 +1020 103 2 +1021 104 2 +1022 104 2 +1024 104 2 +1025 105 2 +1026 105 2 +1027 105 2 +1028 105 2 +1029 105 2 +1030 105 2 +1031 106 2 +1032 106 2 +1033 106 2 +1034 106 2 +1035 106 2 +1036 107 2 +1037 107 2 +1038 107 2 +1040 107 2 +1157 100 0 +1179 105 2 +1183 104 2 +1193 105 2 +1202 107 2 +1203 107 2 +update ignore t1 set id=id+1; +Warnings: +Warning 1062 Duplicate entry '1002' for key 't1.PRIMARY' +Warning 1062 Duplicate entry '1003' for key 't1.PRIMARY' +Warning 1062 Duplicate entry '1004' for key 't1.PRIMARY' +Warning 1062 Duplicate entry '1005' for key 't1.PRIMARY' +Warning 1062 Duplicate entry '1006' for key 't1.PRIMARY' +Warning 1062 Duplicate entry '1007' for key 't1.PRIMARY' +Warning 1062 Duplicate entry '1008' for key 't1.PRIMARY' +Warning 1062 Duplicate entry '1009' for key 't1.PRIMARY' +Warning 1062 Duplicate entry '1016' for key 't1.PRIMARY' +Warning 1062 Duplicate entry '1017' for key 't1.PRIMARY' +Warning 1062 Duplicate entry '1018' for key 't1.PRIMARY' +Warning 1062 Duplicate entry '1019' for key 't1.PRIMARY' +Warning 1062 Duplicate entry '1020' for key 't1.PRIMARY' +Warning 1062 Duplicate entry '1021' for key 't1.PRIMARY' +Warning 1062 Duplicate entry '1022' for key 't1.PRIMARY' +Warning 1062 Duplicate entry '1025' for key 't1.PRIMARY' +Warning 1062 Duplicate entry '1026' for key 't1.PRIMARY' +Warning 1062 Duplicate entry '1027' for key 't1.PRIMARY' +Warning 1062 Duplicate entry '1028' for key 't1.PRIMARY' +Warning 1062 Duplicate entry '1029' for key 't1.PRIMARY' +Warning 1062 Duplicate entry '1030' for key 't1.PRIMARY' +Warning 1062 Duplicate entry '1031' for key 't1.PRIMARY' +Warning 1062 Duplicate entry '1032' for key 't1.PRIMARY' +Warning 1062 Duplicate entry '1033' for key 't1.PRIMARY' +Warning 1062 Duplicate entry '1034' for key 't1.PRIMARY' +Warning 1062 Duplicate entry '1035' for key 't1.PRIMARY' +Warning 1062 Duplicate entry '1036' for key 't1.PRIMARY' +Warning 1062 Duplicate entry '1037' for key 't1.PRIMARY' +Warning 1062 Duplicate entry '1038' for key 't1.PRIMARY' +Warning 1062 Duplicate entry '1203' for key 't1.PRIMARY' +select * from t1; +id parent_id level +1001 100 0 +1002 101 1 +1003 101 1 +1004 101 1 +1005 101 1 +1006 101 1 +1007 101 1 +1008 102 2 +1010 102 2 +1015 102 2 +1016 103 2 +1017 103 2 +1018 103 2 +1019 103 2 +1020 103 2 +1021 104 2 +1023 104 2 +1024 104 2 +1025 105 2 +1026 105 2 +1027 105 2 +1028 105 2 +1029 105 2 +1030 105 2 +1031 106 2 +1032 106 2 +1033 106 2 +1034 106 2 +1035 106 2 +1036 107 2 +1037 107 2 +1039 107 2 +1041 107 2 +1158 100 0 +1180 105 2 +1184 104 2 +1194 105 2 +1202 107 2 +1204 107 2 +update ignore t1 set id=1023 where id=1010; +Warnings: +Warning 1062 Duplicate entry '1023' for key 't1.PRIMARY' +select * from t1 where parent_id=102; +id parent_id level +1008 102 2 +1010 102 2 +1015 102 2 +explain select level from t1 where level=1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref level level 1 const # 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`level` AS `level` from `test`.`t1` where (`test`.`t1`.`level` = 1) +explain select level,id from t1 where level=1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref level level 1 const # 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`level` AS `level`,`test`.`t1`.`id` AS `id` from `test`.`t1` where (`test`.`t1`.`level` = 1) +explain select level,id,parent_id from t1 where level=1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref level level 1 const # 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`level` AS `level`,`test`.`t1`.`id` AS `id`,`test`.`t1`.`parent_id` AS `parent_id` from `test`.`t1` where (`test`.`t1`.`level` = 1) +select level,id from t1 where level=1; +level id +1 1002 +1 1003 +1 1004 +1 1005 +1 1006 +1 1007 +select level,id,parent_id from t1 where level=1; +level id parent_id +1 1002 101 +1 1003 101 +1 1004 101 +1 1005 101 +1 1006 101 +1 1007 101 +optimize table t1; +Table Op Msg_type Msg_text +test.t1 optimize note Table does not support optimize, doing recreate + analyze instead +test.t1 optimize status OK +show keys from t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible Expression +t1 0 PRIMARY 1 id A # NULL NULL BTREE YES NULL +t1 1 parent_id 1 parent_id A # NULL NULL BTREE YES NULL +t1 1 level 1 level A # NULL NULL BTREE YES NULL +drop table t1; +CREATE TABLE t1 ( +gesuchnr int(11) DEFAULT '0' NOT NULL, +benutzer_id int(11) DEFAULT '0' NOT NULL, +PRIMARY KEY (gesuchnr,benutzer_id) +) engine=innodb; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +replace into t1 (gesuchnr,benutzer_id) values (2,1); +replace into t1 (gesuchnr,benutzer_id) values (1,1); +replace into t1 (gesuchnr,benutzer_id) values (1,1); +select * from t1; +gesuchnr benutzer_id +1 1 +2 1 +drop table t1; +create table t1 (a int) engine=innodb; +insert into t1 values (1), (2); +optimize table t1; +Table Op Msg_type Msg_text +test.t1 optimize note Table does not support optimize, doing recreate + analyze instead +test.t1 optimize status OK +delete from t1 where a = 1; +select * from t1; +a +2 +check table t1; +Table Op Msg_type Msg_text +test.t1 check status OK +drop table t1; +create table t1 (a int,b varchar(20)) engine=innodb; +insert into t1 values (1,""), (2,"testing"); +delete from t1 where a = 1; +select * from t1; +a b +2 testing +create index skr on t1 (a); +insert into t1 values (3,""), (4,"testing"); +analyze table t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +show keys from t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible Expression +t1 1 skr 1 a A # NULL NULL YES BTREE YES NULL +drop table t1; +create table t1 (a int,b varchar(20),key(a)) engine=innodb; +insert into t1 values (1,""), (2,"testing"); +select * from t1 where a = 1; +a b +1 +drop table t1; +create table t1 (n int not null primary key) engine=innodb; +set autocommit=0; +insert into t1 values (4); +rollback; +select n, "after rollback" from t1; +n after rollback +insert into t1 values (4); +commit; +select n, "after commit" from t1; +n after commit +4 after commit +commit; +insert into t1 values (5); +insert into t1 values (4); +ERROR 23000: Duplicate entry '4' for key 't1.PRIMARY' +commit; +select n, "after commit" from t1; +n after commit +4 after commit +5 after commit +set autocommit=1; +insert into t1 values (6); +insert into t1 values (4); +ERROR 23000: Duplicate entry '4' for key 't1.PRIMARY' +select n from t1; +n +4 +5 +6 +set autocommit=0; +begin; +savepoint `my_savepoint`; +insert into t1 values (7); +savepoint `savept2`; +insert into t1 values (3); +select n from t1; +n +3 +4 +5 +6 +7 +savepoint savept3; +rollback to savepoint savept2; +rollback to savepoint savept3; +ERROR 42000: SAVEPOINT savept3 does not exist +rollback to savepoint savept2; +release savepoint `my_savepoint`; +select n from t1; +n +4 +5 +6 +7 +rollback to savepoint `my_savepoint`; +ERROR 42000: SAVEPOINT my_savepoint does not exist +rollback to savepoint savept2; +ERROR 42000: SAVEPOINT savept2 does not exist +insert into t1 values (8); +savepoint sv; +commit; +savepoint sv; +set autocommit=1; +rollback; +drop table t1; +create table t1 (n int not null primary key) engine=innodb; +start transaction; +insert into t1 values (4); +flush tables with read lock; +commit; +unlock tables; +commit; +select * from t1; +n +4 +drop table t1; +create table t1 ( id int NOT NULL PRIMARY KEY, nom varchar(64)) engine=innodb; +begin; +insert into t1 values(1,'hamdouni'); +select id as afterbegin_id,nom as afterbegin_nom from t1; +afterbegin_id afterbegin_nom +1 hamdouni +rollback; +select id as afterrollback_id,nom as afterrollback_nom from t1; +afterrollback_id afterrollback_nom +set autocommit=0; +insert into t1 values(2,'mysql'); +select id as afterautocommit0_id,nom as afterautocommit0_nom from t1; +afterautocommit0_id afterautocommit0_nom +2 mysql +rollback; +select id as afterrollback_id,nom as afterrollback_nom from t1; +afterrollback_id afterrollback_nom +set autocommit=1; +drop table t1; +CREATE TABLE t1 (id char(8) not null primary key, val int not null) engine=innodb; +insert into t1 values ('pippo', 12); +insert into t1 values ('pippo', 12); +ERROR 23000: Duplicate entry 'pippo' for key 't1.PRIMARY' +delete from t1; +delete from t1 where id = 'pippo'; +select * from t1; +id val +insert into t1 values ('pippo', 12); +set autocommit=0; +delete from t1; +rollback; +select * from t1; +id val +pippo 12 +delete from t1; +commit; +select * from t1; +id val +drop table t1; +create table t1 (a integer) engine=innodb; +start transaction; +rename table t1 to t2; +create table t1 (b integer) engine=innodb; +insert into t1 values (1); +rollback; +drop table t1; +rename table t2 to t1; +drop table t1; +set autocommit=1; +CREATE TABLE t1 (ID INTEGER NOT NULL PRIMARY KEY, NAME VARCHAR(64)) ENGINE=innodb; +INSERT INTO t1 VALUES (1, 'Jochen'); +select * from t1; +ID NAME +1 Jochen +drop table t1; +CREATE TABLE t1 ( _userid VARCHAR(60) NOT NULL PRIMARY KEY) ENGINE=innodb; +set autocommit=0; +INSERT INTO t1 SET _userid='marc@anyware.co.uk'; +COMMIT; +SELECT * FROM t1; +_userid +marc@anyware.co.uk +SELECT _userid FROM t1 WHERE _userid='marc@anyware.co.uk'; +_userid +marc@anyware.co.uk +drop table t1; +set autocommit=1; +CREATE TABLE t1 ( +user_id int(10) DEFAULT '0' NOT NULL, +name varchar(100), +phone varchar(100), +ref_email varchar(100) DEFAULT '' NOT NULL, +detail varchar(200), +PRIMARY KEY (user_id,ref_email) +)engine=innodb; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (10292,'sanjeev','29153373','sansh777@hotmail.com','xxx'),(10292,'shirish','2333604','shirish@yahoo.com','ddsds'),(10292,'sonali','323232','sonali@bolly.com','filmstar'); +select * from t1 where user_id=10292; +user_id name phone ref_email detail +10292 sanjeev 29153373 sansh777@hotmail.com xxx +10292 shirish 2333604 shirish@yahoo.com ddsds +10292 sonali 323232 sonali@bolly.com filmstar +INSERT INTO t1 VALUES (10291,'sanjeev','29153373','sansh777@hotmail.com','xxx'),(10293,'shirish','2333604','shirish@yahoo.com','ddsds'); +select * from t1 where user_id=10292; +user_id name phone ref_email detail +10292 sanjeev 29153373 sansh777@hotmail.com xxx +10292 shirish 2333604 shirish@yahoo.com ddsds +10292 sonali 323232 sonali@bolly.com filmstar +select * from t1 where user_id>=10292; +user_id name phone ref_email detail +10292 sanjeev 29153373 sansh777@hotmail.com xxx +10292 shirish 2333604 shirish@yahoo.com ddsds +10292 sonali 323232 sonali@bolly.com filmstar +10293 shirish 2333604 shirish@yahoo.com ddsds +select * from t1 where user_id>10292; +user_id name phone ref_email detail +10293 shirish 2333604 shirish@yahoo.com ddsds +select * from t1 where user_id<10292; +user_id name phone ref_email detail +10291 sanjeev 29153373 sansh777@hotmail.com xxx +drop table t1; +CREATE TABLE t1 (a int not null, b int not null,c int not null, +key(a),primary key(a,b), unique(c),key(a),unique(b)); +Warnings: +Warning 1831 Duplicate index 'a_2' defined on the table 'test.t1'. This is deprecated and will be disallowed in a future release. +show index from t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible Expression +t1 0 PRIMARY 1 a A # NULL NULL BTREE YES NULL +t1 0 PRIMARY 2 b A # NULL NULL BTREE YES NULL +t1 0 c 1 c A # NULL NULL BTREE YES NULL +t1 0 b 1 b A # NULL NULL BTREE YES NULL +t1 1 a 1 a A # NULL NULL BTREE YES NULL +t1 1 a_2 1 a A # NULL NULL BTREE YES NULL +drop table t1; +create table t1 (col1 int not null, col2 char(4) not null, primary key(col1)); +alter table t1 engine=innodb; +insert into t1 values ('1','1'),('5','2'),('2','3'),('3','4'),('4','4'); +select * from t1; +col1 col2 +1 1 +2 3 +3 4 +4 4 +5 2 +update t1 set col2='7' where col1='4'; +select * from t1; +col1 col2 +1 1 +2 3 +3 4 +4 7 +5 2 +alter table t1 add co3 int not null; +select * from t1; +col1 col2 co3 +1 1 0 +2 3 0 +3 4 0 +4 7 0 +5 2 0 +update t1 set col2='9' where col1='2'; +select * from t1; +col1 col2 co3 +1 1 0 +2 9 0 +3 4 0 +4 7 0 +5 2 0 +drop table t1; +create table t1 (a int not null , b int, primary key (a)) engine = innodb; +create table t2 (a int not null , b int, primary key (a)) engine = myisam; +insert into t1 VALUES (1,3) , (2,3), (3,3); +select * from t1; +a b +1 3 +2 3 +3 3 +insert into t2 select * from t1; +select * from t2; +a b +1 3 +2 3 +3 3 +delete from t1 where b = 3; +select * from t1; +a b +insert into t1 select * from t2; +select * from t1; +a b +1 3 +2 3 +3 3 +select * from t2; +a b +1 3 +2 3 +3 3 +drop table t1,t2; +CREATE TABLE t1 ( +user_name varchar(12), +password text, +subscribed char(1), +user_id int(11) DEFAULT '0' NOT NULL, +quota bigint(20), +weight double, +access_date date, +access_time time, +approved datetime, +dummy_primary_key int(11) NOT NULL auto_increment, +PRIMARY KEY (dummy_primary_key) +) ENGINE=innodb; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES ('user_0','somepassword','N',0,0,0,'2000-09-07','23:06:59','2000-09-07 23:06:59',1); +INSERT INTO t1 VALUES ('user_1','somepassword','Y',1,1,1,'2000-09-07','23:06:59','2000-09-07 23:06:59',2); +INSERT INTO t1 VALUES ('user_2','somepassword','N',2,2,1.4142135623731,'2000-09-07','23:06:59','2000-09-07 23:06:59',3); +INSERT INTO t1 VALUES ('user_3','somepassword','Y',3,3,1.7320508075689,'2000-09-07','23:06:59','2000-09-07 23:06:59',4); +INSERT INTO t1 VALUES ('user_4','somepassword','N',4,4,2,'2000-09-07','23:06:59','2000-09-07 23:06:59',5); +select user_name, password , subscribed, user_id, quota, weight, access_date, access_time, approved, dummy_primary_key from t1 order by user_name; +user_name password subscribed user_id quota weight access_date access_time approved dummy_primary_key +user_0 somepassword N 0 0 0 2000-09-07 23:06:59 2000-09-07 23:06:59 1 +user_1 somepassword Y 1 1 1 2000-09-07 23:06:59 2000-09-07 23:06:59 2 +user_2 somepassword N 2 2 1.4142135623731 2000-09-07 23:06:59 2000-09-07 23:06:59 3 +user_3 somepassword Y 3 3 1.7320508075689 2000-09-07 23:06:59 2000-09-07 23:06:59 4 +user_4 somepassword N 4 4 2 2000-09-07 23:06:59 2000-09-07 23:06:59 5 +drop table t1; +CREATE TABLE t1 ( +id int(11) NOT NULL auto_increment, +parent_id int(11) DEFAULT '0' NOT NULL, +level tinyint(4) DEFAULT '0' NOT NULL, +KEY (id), +KEY parent_id (parent_id), +KEY level (level) +) engine=innodb; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (1,0,0),(3,1,1),(4,1,1),(8,2,2),(9,2,2),(17,3,2),(22,4,2),(24,4,2),(28,5,2),(29,5,2),(30,5,2),(31,6,2),(32,6,2),(33,6,2),(203,7,2),(202,7,2),(20,3,2),(157,0,0),(193,5,2),(40,7,2),(2,1,1),(15,2,2),(6,1,1),(34,6,2),(35,6,2),(16,3,2),(7,1,1),(36,7,2),(18,3,2),(26,5,2),(27,5,2),(183,4,2),(38,7,2),(25,5,2),(37,7,2),(21,4,2),(19,3,2),(5,1,1); +INSERT INTO t1 values (179,5,2); +update t1 set parent_id=parent_id+100; +select * from t1 where parent_id=102; +id parent_id level +8 102 2 +9 102 2 +15 102 2 +update t1 set id=id+1000; +update t1 set id=1024 where id=1009; +select * from t1; +id parent_id level +1001 100 0 +1002 101 1 +1003 101 1 +1004 101 1 +1005 101 1 +1006 101 1 +1007 101 1 +1008 102 2 +1015 102 2 +1016 103 2 +1017 103 2 +1018 103 2 +1019 103 2 +1020 103 2 +1021 104 2 +1022 104 2 +1024 102 2 +1024 104 2 +1025 105 2 +1026 105 2 +1027 105 2 +1028 105 2 +1029 105 2 +1030 105 2 +1031 106 2 +1032 106 2 +1033 106 2 +1034 106 2 +1035 106 2 +1036 107 2 +1037 107 2 +1038 107 2 +1040 107 2 +1157 100 0 +1179 105 2 +1183 104 2 +1193 105 2 +1202 107 2 +1203 107 2 +update ignore t1 set id=id+1; +select * from t1; +id parent_id level +1002 100 0 +1003 101 1 +1004 101 1 +1005 101 1 +1006 101 1 +1007 101 1 +1008 101 1 +1009 102 2 +1016 102 2 +1017 103 2 +1018 103 2 +1019 103 2 +1020 103 2 +1021 103 2 +1022 104 2 +1023 104 2 +1025 102 2 +1025 104 2 +1026 105 2 +1027 105 2 +1028 105 2 +1029 105 2 +1030 105 2 +1031 105 2 +1032 106 2 +1033 106 2 +1034 106 2 +1035 106 2 +1036 106 2 +1037 107 2 +1038 107 2 +1039 107 2 +1041 107 2 +1158 100 0 +1180 105 2 +1184 104 2 +1194 105 2 +1203 107 2 +1204 107 2 +update ignore t1 set id=1023 where id=1010; +select * from t1 where parent_id=102; +id parent_id level +1009 102 2 +1025 102 2 +1016 102 2 +explain select level from t1 where level=1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref level level 1 const # 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`level` AS `level` from `test`.`t1` where (`test`.`t1`.`level` = 1) +select level,id from t1 where level=1; +level id +1 1003 +1 1004 +1 1005 +1 1006 +1 1007 +1 1008 +select level,id,parent_id from t1 where level=1; +level id parent_id +1 1003 101 +1 1004 101 +1 1005 101 +1 1006 101 +1 1007 101 +1 1008 101 +select level,id from t1 where level=1 order by id; +level id +1 1003 +1 1004 +1 1005 +1 1006 +1 1007 +1 1008 +delete from t1 where level=1; +select * from t1; +id parent_id level +1002 100 0 +1009 102 2 +1016 102 2 +1017 103 2 +1018 103 2 +1019 103 2 +1020 103 2 +1021 103 2 +1022 104 2 +1023 104 2 +1025 102 2 +1025 104 2 +1026 105 2 +1027 105 2 +1028 105 2 +1029 105 2 +1030 105 2 +1031 105 2 +1032 106 2 +1033 106 2 +1034 106 2 +1035 106 2 +1036 106 2 +1037 107 2 +1038 107 2 +1039 107 2 +1041 107 2 +1158 100 0 +1180 105 2 +1184 104 2 +1194 105 2 +1203 107 2 +1204 107 2 +drop table t1; +CREATE TABLE t1 ( +sca_code char(6) NOT NULL, +cat_code char(6) NOT NULL, +sca_desc varchar(50), +lan_code char(2) NOT NULL, +sca_pic varchar(100), +sca_sdesc varchar(50), +sca_sch_desc varchar(16), +PRIMARY KEY (sca_code, cat_code, lan_code), +INDEX sca_pic (sca_pic) +) engine = innodb ; +INSERT INTO t1 ( sca_code, cat_code, sca_desc, lan_code, sca_pic, sca_sdesc, sca_sch_desc) VALUES ( 'PD', 'J', 'PENDANT', 'EN', NULL, NULL, 'PENDANT'),( 'RI', 'J', 'RING', 'EN', NULL, NULL, 'RING'),( 'QQ', 'N', 'RING', 'EN', 'not null', NULL, 'RING'); +select count(*) from t1 where sca_code = 'PD'; +count(*) +1 +select count(*) from t1 where sca_code <= 'PD'; +count(*) +1 +select count(*) from t1 where sca_pic is null; +count(*) +2 +alter table t1 drop index sca_pic, add index sca_pic (cat_code, sca_pic); +select count(*) from t1 where sca_code='PD' and sca_pic is null; +count(*) +1 +select count(*) from t1 where cat_code='E'; +count(*) +0 +alter table t1 drop index sca_pic, add index (sca_pic, cat_code); +select count(*) from t1 where sca_code='PD' and sca_pic is null; +count(*) +1 +select count(*) from t1 where sca_pic >= 'n'; +count(*) +1 +select sca_pic from t1 where sca_pic is null; +sca_pic +NULL +NULL +update t1 set sca_pic="test" where sca_pic is null; +delete from t1 where sca_code='pd'; +drop table t1; +set @a:=now(); +CREATE TABLE t1 (a int not null, b timestamp not null default +current_timestamp on update current_timestamp, primary key (a)) engine=innodb; +insert into t1 (a) values(1),(2),(3); +select t1.a from t1 natural join t1 as t2 where t1.b >= @a order by t1.a; +a +1 +2 +3 +select a from t1 natural join t1 as t2 where b >= @a order by a; +a +1 +2 +3 +update t1 set a=5 where a=1; +select a from t1; +a +2 +3 +5 +drop table t1; +create table t1 (a varchar(100) not null, primary key(a), b int not null) engine=innodb; +insert into t1 values("hello",1),("world",2); +select * from t1 order by b desc; +a b +world 2 +hello 1 +optimize table t1; +Table Op Msg_type Msg_text +test.t1 optimize note Table does not support optimize, doing recreate + analyze instead +test.t1 optimize status OK +show keys from t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible Expression +t1 0 PRIMARY 1 a A # NULL NULL BTREE YES NULL +drop table t1; +create table t1 (i int, j int ) ENGINE=innodb; +insert into t1 values (1,2); +select * from t1 where i=1 and j=2; +i j +1 2 +create index ax1 on t1 (i,j); +select * from t1 where i=1 and j=2; +i j +1 2 +drop table t1; +CREATE TABLE t1 ( +a int3 unsigned NOT NULL, +b int1 unsigned NOT NULL, +UNIQUE (a, b) +) ENGINE = innodb; +INSERT INTO t1 VALUES (1, 1); +SELECT MIN(B),MAX(b) FROM t1 WHERE t1.a = 1; +MIN(B) MAX(b) +1 1 +drop table t1; +create table t1 (a int primary key,b int, c int, d int, e int, f int, g int, h int, i int, j int, k int, l int, m int, n int, o int, p int, q int, r int, s int, t int, u int, v int, w int, x int, y int, z int, a1 int, a2 int, a3 int, a4 int, a5 int, a6 int, a7 int, a8 int, a9 int, b1 int, b2 int, b3 int, b4 int, b5 int, b6 int) engine = innodb; +insert into t1 values (1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1); +explain select * from t1 where a > 0 and a < 50; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range PRIMARY PRIMARY 4 NULL # 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c`,`test`.`t1`.`d` AS `d`,`test`.`t1`.`e` AS `e`,`test`.`t1`.`f` AS `f`,`test`.`t1`.`g` AS `g`,`test`.`t1`.`h` AS `h`,`test`.`t1`.`i` AS `i`,`test`.`t1`.`j` AS `j`,`test`.`t1`.`k` AS `k`,`test`.`t1`.`l` AS `l`,`test`.`t1`.`m` AS `m`,`test`.`t1`.`n` AS `n`,`test`.`t1`.`o` AS `o`,`test`.`t1`.`p` AS `p`,`test`.`t1`.`q` AS `q`,`test`.`t1`.`r` AS `r`,`test`.`t1`.`s` AS `s`,`test`.`t1`.`t` AS `t`,`test`.`t1`.`u` AS `u`,`test`.`t1`.`v` AS `v`,`test`.`t1`.`w` AS `w`,`test`.`t1`.`x` AS `x`,`test`.`t1`.`y` AS `y`,`test`.`t1`.`z` AS `z`,`test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,`test`.`t1`.`a3` AS `a3`,`test`.`t1`.`a4` AS `a4`,`test`.`t1`.`a5` AS `a5`,`test`.`t1`.`a6` AS `a6`,`test`.`t1`.`a7` AS `a7`,`test`.`t1`.`a8` AS `a8`,`test`.`t1`.`a9` AS `a9`,`test`.`t1`.`b1` AS `b1`,`test`.`t1`.`b2` AS `b2`,`test`.`t1`.`b3` AS `b3`,`test`.`t1`.`b4` AS `b4`,`test`.`t1`.`b5` AS `b5`,`test`.`t1`.`b6` AS `b6` from `test`.`t1` where ((`test`.`t1`.`a` > 0) and (`test`.`t1`.`a` < 50)) +drop table t1; +create table t1 (id int NOT NULL,id2 int NOT NULL,id3 int NOT NULL,dummy1 char(30),primary key (id,id2),index index_id3 (id3)) engine=innodb; +insert into t1 values (0,0,0,'ABCDEFGHIJ'),(2,2,2,'BCDEFGHIJK'),(1,1,1,'CDEFGHIJKL'); +LOCK TABLES t1 WRITE; +insert into t1 values (99,1,2,'D'),(1,1,2,'D'); +ERROR 23000: Duplicate entry '1-1' for key 't1.PRIMARY' +select id from t1; +id +0 +1 +2 +select id from t1; +id +0 +1 +2 +UNLOCK TABLES; +DROP TABLE t1; +create table t1 (id int NOT NULL,id2 int NOT NULL,id3 int NOT NULL,dummy1 char(30),primary key (id,id2),index index_id3 (id3)) engine=innodb; +insert into t1 values (0,0,0,'ABCDEFGHIJ'),(2,2,2,'BCDEFGHIJK'),(1,1,1,'CDEFGHIJKL'); +LOCK TABLES t1 WRITE; +begin; +insert into t1 values (99,1,2,'D'),(1,1,2,'D'); +ERROR 23000: Duplicate entry '1-1' for key 't1.PRIMARY' +select id from t1; +id +0 +1 +2 +insert ignore into t1 values (100,1,2,'D'),(1,1,99,'D'); +Warnings: +Warning 1062 Duplicate entry '1-1' for key 't1.PRIMARY' +commit; +select id,id3 from t1; +id id3 +0 0 +1 1 +2 2 +100 2 +UNLOCK TABLES; +DROP TABLE t1; +create table t1 (a char(20), unique (a(5))) engine=innodb; +drop table t1; +create table t1 (a char(20), index (a(5))) engine=innodb; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` char(20) DEFAULT NULL, + KEY `a` (`a`(5)) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +create temporary table t1 (a int not null auto_increment, primary key(a)) engine=innodb; +insert into t1 values (NULL),(NULL),(NULL); +delete from t1 where a=3; +insert into t1 values (NULL); +select * from t1; +a +1 +2 +4 +alter table t1 add b int; +select * from t1; +a b +1 NULL +2 NULL +4 NULL +drop table t1; +create table t1 +( +id int auto_increment primary key, +name varchar(32) not null, +value text not null, +uid int not null, +unique key(name,uid) +) engine=innodb; +insert into t1 values (1,'one','one value',101), +(2,'two','two value',102),(3,'three','three value',103); +set insert_id=5; +replace into t1 (value,name,uid) values ('other value','two',102); +delete from t1 where uid=102; +set insert_id=5; +replace into t1 (value,name,uid) values ('other value','two',102); +set insert_id=6; +replace into t1 (value,name,uid) values ('other value','two',102); +select * from t1; +id name value uid +1 one one value 101 +3 three three value 103 +6 two other value 102 +drop table t1; +create database mysqltest; +create table mysqltest.t1 (a int not null) engine= innodb; +insert into mysqltest.t1 values(1); +create table mysqltest.t2 (a int not null) engine= myisam; +insert into mysqltest.t2 values(1); +create table mysqltest.t3 (a int not null) engine= heap; +insert into mysqltest.t3 values(1); +commit; +drop database mysqltest; +show tables from mysqltest; +ERROR 42000: Unknown database 'mysqltest' +set autocommit=0; +create table t1 (a int not null) engine= innodb; +insert into t1 values(1),(2); +truncate table t1; +commit; +truncate table t1; +truncate table t1; +select * from t1; +a +insert into t1 values(1),(2); +delete from t1; +select * from t1; +a +commit; +drop table t1; +set autocommit=1; +create table t1 (a int not null) engine= innodb; +insert into t1 values(1),(2); +truncate table t1; +insert into t1 values(1),(2); +select * from t1; +a +1 +2 +truncate table t1; +insert into t1 values(1),(2); +delete from t1; +select * from t1; +a +drop table t1; +create table t1 (a int not null, b int not null, c int not null, primary key (a),key(b)) engine=innodb; +insert into t1 values (3,3,3),(1,1,1),(2,2,2),(4,4,4); +explain select * from t1 order by a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL PRIMARY 4 NULL # 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` order by `test`.`t1`.`a` +explain select * from t1 order by b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL # 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` order by `test`.`t1`.`b` +explain select * from t1 order by c; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL # 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` order by `test`.`t1`.`c` +explain select a from t1 order by a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL PRIMARY 4 NULL # 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` order by `test`.`t1`.`a` +explain select b from t1 order by b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL b 4 NULL # 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`b` AS `b` from `test`.`t1` order by `test`.`t1`.`b` +explain select a,b from t1 order by b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL b 4 NULL # 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` order by `test`.`t1`.`b` +explain select a,b from t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL b 4 NULL # 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` +explain select a,b,c from t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL # 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` +drop table t1; +create table t1 (t int not null default 1, key (t)) engine=innodb; +desc t1; +Field Type Null Key Default Extra +t int NO MUL 1 +drop table t1; +SET sql_mode = 'NO_ENGINE_SUBSTITUTION'; +CREATE TABLE t1 ( +number bigint(20) NOT NULL default '0', +cname char(15) NOT NULL default '', +carrier_id smallint(6) NOT NULL default '0', +privacy tinyint(4) NOT NULL default '0', +last_mod_date timestamp NOT NULL, +last_mod_id smallint(6) NOT NULL default '0', +last_app_date timestamp NOT NULL, +last_app_id smallint(6) default '-1', +version smallint(6) NOT NULL default '0', +assigned_scps int(11) default '0', +status tinyint(4) default '0' +) ENGINE=InnoDB; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (4077711111,'SeanWheeler',90,2,20020111112846,500,00000000000000,-1,2,3,1); +INSERT INTO t1 VALUES (9197722223,'berry',90,3,20020111112809,500,20020102114532,501,4,10,0); +INSERT INTO t1 VALUES (650,'San Francisco',0,0,20011227111336,342,00000000000000,-1,1,24,1); +INSERT INTO t1 VALUES (302467,'Sue\'s Subshop',90,3,20020109113241,500,20020102115111,501,7,24,0); +INSERT INTO t1 VALUES (6014911113,'SudzCarwash',520,1,20020102115234,500,20020102115259,501,33,32768,0); +INSERT INTO t1 VALUES (333,'tubs',99,2,20020109113440,501,20020109113440,500,3,10,0); +CREATE TABLE t2 ( +number bigint(20) NOT NULL default '0', +cname char(15) NOT NULL default '', +carrier_id smallint(6) NOT NULL default '0', +privacy tinyint(4) NOT NULL default '0', +last_mod_date timestamp NOT NULL, +last_mod_id smallint(6) NOT NULL default '0', +last_app_date timestamp NOT NULL, +last_app_id smallint(6) default '-1', +version smallint(6) NOT NULL default '0', +assigned_scps int(11) default '0', +status tinyint(4) default '0' +) ENGINE=InnoDB; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (4077711111,'SeanWheeler',0,2,20020111112853,500,00000000000000,-1,2,3,1); +INSERT INTO t2 VALUES (9197722223,'berry',90,3,20020111112818,500,20020102114532,501,4,10,0); +INSERT INTO t2 VALUES (650,'San Francisco',90,0,20020109113158,342,00000000000000,-1,1,24,1); +INSERT INTO t2 VALUES (333,'tubs',99,2,20020109113453,501,20020109113453,500,3,10,0); +select * from t1; +number cname carrier_id privacy last_mod_date last_mod_id last_app_date last_app_id version assigned_scps status +302467 Sue's Subshop 90 3 2002-01-09 11:32:41 500 2002-01-02 11:51:11 501 7 24 0 +333 tubs 99 2 2002-01-09 11:34:40 501 2002-01-09 11:34:40 500 3 10 0 +4077711111 SeanWheeler 90 2 2002-01-11 11:28:46 500 0000-00-00 00:00:00 -1 2 3 1 +6014911113 SudzCarwash 520 1 2002-01-02 11:52:34 500 2002-01-02 11:52:59 501 33 32768 0 +650 San Francisco 0 0 2001-12-27 11:13:36 342 0000-00-00 00:00:00 -1 1 24 1 +9197722223 berry 90 3 2002-01-11 11:28:09 500 2002-01-02 11:45:32 501 4 10 0 +select * from t2; +number cname carrier_id privacy last_mod_date last_mod_id last_app_date last_app_id version assigned_scps status +333 tubs 99 2 2002-01-09 11:34:53 501 2002-01-09 11:34:53 500 3 10 0 +4077711111 SeanWheeler 0 2 2002-01-11 11:28:53 500 0000-00-00 00:00:00 -1 2 3 1 +650 San Francisco 90 0 2002-01-09 11:31:58 342 0000-00-00 00:00:00 -1 1 24 1 +9197722223 berry 90 3 2002-01-11 11:28:18 500 2002-01-02 11:45:32 501 4 10 0 +delete t1, t2 from t1 left join t2 on t1.number=t2.number where (t1.carrier_id=90 and t1.number=t2.number) or (t2.carrier_id=90 and t1.number=t2.number) or (t1.carrier_id=90 and t2.number is null); +select * from t1; +number cname carrier_id privacy last_mod_date last_mod_id last_app_date last_app_id version assigned_scps status +6014911113 SudzCarwash 520 1 2002-01-02 11:52:34 500 2002-01-02 11:52:59 501 33 32768 0 +333 tubs 99 2 2002-01-09 11:34:40 501 2002-01-09 11:34:40 500 3 10 0 +select * from t2; +number cname carrier_id privacy last_mod_date last_mod_id last_app_date last_app_id version assigned_scps status +333 tubs 99 2 2002-01-09 11:34:53 501 2002-01-09 11:34:53 500 3 10 0 +select * from t2; +number cname carrier_id privacy last_mod_date last_mod_id last_app_date last_app_id version assigned_scps status +333 tubs 99 2 2002-01-09 11:34:53 501 2002-01-09 11:34:53 500 3 10 0 +drop table t1,t2; +SET sql_mode = default; +create table t1 (id int unsigned not null auto_increment, code tinyint unsigned not null, name char(20) not null, primary key (id), key (code), unique (name)) engine=innodb; +BEGIN; +SET SESSION TRANSACTION ISOLATION LEVEL SERIALIZABLE; +SELECT @@transaction_isolation,@@global.transaction_isolation; +@@transaction_isolation @@global.transaction_isolation +SERIALIZABLE REPEATABLE-READ +insert into t1 (code, name) values (1, 'Tim'), (1, 'Monty'), (2, 'David'); +select id, code, name from t1 order by id; +id code name +1 1 Tim +2 1 Monty +3 2 David +COMMIT; +BEGIN; +SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ; +insert into t1 (code, name) values (2, 'Erik'), (3, 'Sasha'); +select id, code, name from t1 order by id; +id code name +1 1 Tim +2 1 Monty +3 2 David +4 2 Erik +5 3 Sasha +COMMIT; +SET binlog_format='MIXED'; +BEGIN; +SET SESSION TRANSACTION ISOLATION LEVEL READ UNCOMMITTED; +insert into t1 (code, name) values (3, 'Jeremy'), (4, 'Matt'); +select id, code, name from t1 order by id; +id code name +1 1 Tim +2 1 Monty +3 2 David +4 2 Erik +5 3 Sasha +6 3 Jeremy +7 4 Matt +COMMIT; +DROP TABLE t1; +create table t1 (n int(10), d int(10)) engine=innodb; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +create table t2 (n int(10), d int(10)) engine=innodb; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t1 values(1,1),(1,2); +insert into t2 values(1,10),(2,20); +UPDATE t1,t2 SET t1.d=t2.d,t2.d=30 WHERE t1.n=t2.n; +select * from t1; +n d +1 10 +1 10 +select * from t2; +n d +1 30 +2 20 +drop table t1,t2; +drop table if exists t1, t2; +CREATE TABLE t1 (a int, PRIMARY KEY (a)); +CREATE TABLE t2 (a int, PRIMARY KEY (a)) ENGINE=InnoDB; +create trigger trg_del_t2 after delete on t2 for each row +insert into t1 values (1); +insert into t1 values (1); +insert into t2 values (1),(2); +delete t2 from t2; +ERROR 23000: Duplicate entry '1' for key 't1.PRIMARY' +select count(*) from t2 /* must be 2 as restored after rollback caused by the error */; +count(*) +2 +drop table t1, t2; +drop table if exists t1, t2; +CREATE TABLE t1 (a int, PRIMARY KEY (a)); +CREATE TABLE t2 (a int, PRIMARY KEY (a)) ENGINE=InnoDB; +create trigger trg_del_t2 after delete on t2 for each row +insert into t1 values (1); +insert into t1 values (1); +insert into t2 values (1),(2); +delete t2 from t2; +ERROR 23000: Duplicate entry '1' for key 't1.PRIMARY' +select count(*) from t2 /* must be 2 as restored after rollback caused by the error */; +count(*) +2 +drop table t1, t2; +create table t1 (a int, b int) engine=innodb; +insert into t1 values(20,null); +select t2.b, ifnull(t2.b,"this is null") from t1 as t2 left join t1 as t3 on +t2.b=t3.a; +b ifnull(t2.b,"this is null") +NULL this is null +select t2.b, ifnull(t2.b,"this is null") from t1 as t2 left join t1 as t3 on +t2.b=t3.a order by 1; +b ifnull(t2.b,"this is null") +NULL this is null +insert into t1 values(10,null); +select t2.b, ifnull(t2.b,"this is null") from t1 as t2 left join t1 as t3 on +t2.b=t3.a order by 1; +b ifnull(t2.b,"this is null") +NULL this is null +NULL this is null +drop table t1; +create table t1 (a varchar(10) not null) engine=myisam; +create table t2 (b varchar(10) not null unique) engine=innodb; +select t1.a from t1,t2 where t1.a=t2.b; +a +drop table t1,t2; +create table t1 (a int not null, b int, primary key (a)) engine = innodb; +create table t2 (a int not null, b int, primary key (a)) engine = innodb; +insert into t1 values (10, 20); +insert into t2 values (10, 20); +update t1, t2 set t1.b = 150, t2.b = t1.b where t2.a = t1.a and t1.a = 10; +drop table t1,t2; +CREATE TABLE t1 (id INT NOT NULL, PRIMARY KEY (id)) ENGINE=INNODB; +CREATE TABLE t2 (id INT PRIMARY KEY, t1_id INT, INDEX par_ind (t1_id), FOREIGN KEY (t1_id) REFERENCES t1(id) ON DELETE CASCADE ) ENGINE=INNODB; +insert into t1 set id=1; +insert into t2 set id=1, t1_id=1; +delete t1,t2 from t1,t2 where t1.id=t2.t1_id; +select * from t1; +id +select * from t2; +id t1_id +drop table t2,t1; +CREATE TABLE t1(id INT NOT NULL, PRIMARY KEY (id)) ENGINE=INNODB; +CREATE TABLE t2(id INT PRIMARY KEY, t1_id INT, INDEX par_ind (t1_id) ) ENGINE=INNODB; +INSERT INTO t1 VALUES(1); +INSERT INTO t2 VALUES(1, 1); +SELECT * from t1; +id +1 +UPDATE t1,t2 SET t1.id=t1.id+1, t2.t1_id=t1.id+1; +SELECT * from t1; +id +2 +UPDATE t1,t2 SET t1.id=t1.id+1 where t1.id!=t2.id; +SELECT * from t1; +id +3 +DROP TABLE t1,t2; +set autocommit=0; +CREATE TABLE t1 (id CHAR(15) NOT NULL, value CHAR(40) NOT NULL, PRIMARY KEY(id)) ENGINE=InnoDB; +CREATE TABLE t2 (id CHAR(15) NOT NULL, value CHAR(40) NOT NULL, PRIMARY KEY(id)) ENGINE=InnoDB; +CREATE TABLE t3 (id1 CHAR(15) NOT NULL, id2 CHAR(15) NOT NULL, PRIMARY KEY(id1, id2)) ENGINE=InnoDB; +INSERT INTO t3 VALUES("my-test-1", "my-test-2"); +COMMIT; +INSERT INTO t1 VALUES("this-key", "will disappear"); +INSERT INTO t2 VALUES("this-key", "will also disappear"); +DELETE FROM t3 WHERE id1="my-test-1"; +SELECT * FROM t1; +id value +this-key will disappear +SELECT * FROM t2; +id value +this-key will also disappear +SELECT * FROM t3; +id1 id2 +ROLLBACK; +SELECT * FROM t1; +id value +SELECT * FROM t2; +id value +SELECT * FROM t3; +id1 id2 +my-test-1 my-test-2 +SELECT * FROM t3 WHERE id1="my-test-1" LOCK IN SHARE MODE; +id1 id2 +my-test-1 my-test-2 +COMMIT; +set autocommit=1; +DROP TABLE t1,t2,t3; +CREATE TABLE t1 (a int not null primary key, b int not null, unique (b)) engine=innodb; +INSERT INTO t1 values (1,1),(2,2),(3,3),(4,4),(5,5),(6,6),(7,7),(8,8),(9,9); +UPDATE t1 set a=a+100 where b between 2 and 3 and a < 1000; +SELECT * from t1; +a b +1 1 +102 2 +103 3 +4 4 +5 5 +6 6 +7 7 +8 8 +9 9 +drop table t1; +CREATE TABLE t2 ( NEXT_T BIGINT NOT NULL PRIMARY KEY) ENGINE=MyISAM; +CREATE TABLE t1 ( B_ID INTEGER NOT NULL PRIMARY KEY) ENGINE=InnoDB; +SET AUTOCOMMIT=0; +INSERT INTO t1 ( B_ID ) VALUES ( 1 ); +INSERT INTO t2 ( NEXT_T ) VALUES ( 1 ); +ROLLBACK; +Warnings: +Warning 1196 Some non-transactional changed tables couldn't be rolled back +SELECT * FROM t1; +B_ID +drop table t1,t2; +create table t1 ( pk int primary key, parent int not null, child int not null, index (parent) ) engine = innodb; +insert into t1 values (1,0,4), (2,1,3), (3,2,1), (4,1,2); +select distinct parent,child from t1 order by parent; +parent child +0 4 +1 2 +1 3 +2 1 +drop table t1; +create table t1 (a int not null auto_increment primary key, b int, c int, key(c)) engine=innodb; +create table t2 (a int not null auto_increment primary key, b int); +insert into t1 (b) values (null),(null),(null),(null),(null),(null),(null); +insert into t2 (a) select b from t1; +insert into t1 (b) select b from t2; +insert into t2 (a) select b from t1; +insert into t1 (a) select b from t2; +insert into t2 (a) select b from t1; +insert into t1 (a) select b from t2; +insert into t2 (a) select b from t1; +insert into t1 (a) select b from t2; +insert into t2 (a) select b from t1; +insert into t1 (a) select b from t2; +select count(*) from t1; +count(*) +623 +explain select * from t1 where c between 1 and 2500; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range c c 5 NULL # 100.00 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` where (`test`.`t1`.`c` between 1 and 2500) +update t1 set c=a; +explain select * from t1 where c between 1 and 2500; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # # Parallel execute (2 workers) +2 SIMPLE t1 NULL ALL c NULL NULL NULL # # Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` where (`test`.`t1`.`c` between 1 and 2500) +drop table t1,t2; +create table t1 (id int primary key auto_increment, fk int, index index_fk (fk)) engine=innodb; +insert into t1 (id) values (null),(null),(null),(null),(null); +update t1 set fk=69 where fk is null order by id limit 1; +SELECT * from t1; +id fk +1 69 +2 NULL +3 NULL +4 NULL +5 NULL +drop table t1; +create table t1 (a int not null, b int not null, key (a)); +insert into t1 values (1,1),(1,2),(1,3),(3,1),(3,2),(3,3),(3,1),(3,2),(3,3),(2,1),(2,2),(2,3); +SET @tmp=0; +update t1 set b=(@tmp:=@tmp+1) order by a; +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +update t1 set b=99 where a=1 order by b asc limit 1; +update t1 set b=100 where a=1 order by b desc limit 2; +update t1 set a=a+10+b where a=1 order by b; +select * from t1 order by a,b; +a b +2 4 +2 5 +2 6 +3 7 +3 8 +3 9 +3 10 +3 11 +3 12 +13 2 +111 100 +111 100 +drop table t1; +create table t1 ( c char(8) not null ) engine=innodb; +insert into t1 values ('0'),('1'),('2'),('3'),('4'),('5'),('6'),('7'),('8'),('9'); +insert into t1 values ('A'),('B'),('C'),('D'),('E'),('F'); +alter table t1 add b char(8) not null; +alter table t1 add a char(8) not null; +alter table t1 add primary key (a,b,c); +update t1 set a=c, b=c; +create table t2 (c char(8) not null, b char(8) not null, a char(8) not null, primary key(a,b,c)) engine=innodb; +insert into t2 select * from t1; +delete t1,t2 from t2,t1 where t1.a<'B' and t2.b=t1.b; +drop table t1,t2; +SET AUTOCOMMIT=1; +create table t1 (a integer auto_increment primary key) engine=innodb; +insert into t1 (a) values (NULL),(NULL); +truncate table t1; +insert into t1 (a) values (NULL),(NULL); +SELECT * from t1; +a +1 +2 +drop table t1; +CREATE TABLE t1 (`id 1` INT NOT NULL, PRIMARY KEY (`id 1`)) ENGINE=INNODB; +CREATE TABLE t2 (id INT PRIMARY KEY, t1_id INT, INDEX par_ind (t1_id), FOREIGN KEY (`t1_id`) REFERENCES `t1`(`id 1`) ON DELETE CASCADE ) ENGINE=INNODB; +drop table t2,t1; +create table `t1` (`id` int( 11 ) not null ,primary key ( `id` )) engine = innodb; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into `t1`values ( 1 ) ; +create table `t2` (`id` int( 11 ) not null default '0',unique key `id` ( `id` ) ,constraint `t1_id_fk` foreign key ( `id` ) references `t1` (`id` )) engine = innodb; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into `t2`values ( 1 ) ; +create table `t3` (`id` int( 11 ) not null default '0',key `id` ( `id` ) ,constraint `t2_id_fk` foreign key ( `id` ) references `t2` (`id` )) engine = innodb; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into `t3`values ( 1 ) ; +delete t3,t2,t1 from t1,t2,t3 where t1.id =1 and t2.id = t1.id and t3.id = t2.id; +ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `t1_id_fk` FOREIGN KEY (`id`) REFERENCES `t1` (`id`)) +update t1,t2,t3 set t3.id=5, t2.id=6, t1.id=7 where t1.id =1 and t2.id = t1.id and t3.id = t2.id; +ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `t1_id_fk` FOREIGN KEY (`id`) REFERENCES `t1` (`id`)) +update t3 set t3.id=7 where t1.id =1 and t2.id = t1.id and t3.id = t2.id; +ERROR 42S22: Unknown column 't1.id' in 'where clause' +drop table t3,t2,t1; +CREATE TABLE t1 ( +c1 VARCHAR(8), c2 VARCHAR(8), +PRIMARY KEY (c1, c2) +) ENGINE=InnoDB; +CREATE TABLE t2 ( +c0 INT PRIMARY KEY, +c1 VARCHAR(8) UNIQUE, +FOREIGN KEY (c1) REFERENCES t1 (c1) ON UPDATE CASCADE +) ENGINE=InnoDB; +INSERT INTO t1 VALUES ('old', 'somevalu'), ('other', 'anyvalue'); +INSERT INTO t2 VALUES (10, 'old'), (20, 'other'); +UPDATE t1 SET c1 = 'other' WHERE c1 = 'old'; +ERROR 23000: Foreign key constraint for table 't1', record 'other-somevalu' would lead to a duplicate entry in table 't2', key 'c1' +DROP TABLE t2,t1; +create table t1( +id int primary key, +pid int, +index(pid), +foreign key(pid) references t1(id) on delete cascade) engine=innodb; +insert into t1 values(0,0),(1,0),(2,1),(3,2),(4,3),(5,4),(6,5),(7,6), +(8,7),(9,8),(10,9),(11,10),(12,11),(13,12),(14,13),(15,14); +delete from t1 where id=0; +ERROR HY000: Foreign key cascade delete/update exceeds max depth of 15. +delete from t1 where id=15; +delete from t1 where id=0; +drop table t1; +CREATE TABLE t1 (col1 int(1))ENGINE=InnoDB; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t2 (col1 int(1),stamp TIMESTAMP,INDEX stamp_idx +(stamp))ENGINE=InnoDB; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t1 values (1),(2),(3); +insert ignore into t2 values (1, 20020204130000),(2, 20020204130000),(4,20020204310000 ),(5,20020204230000); +Warnings: +Warning 1265 Data truncated for column 'stamp' at row 3 +SELECT col1 FROM t1 UNION SELECT col1 FROM t2 WHERE stamp < +'20020204120000' GROUP BY col1; +col1 +1 +2 +3 +4 +drop table t1,t2; +CREATE TABLE t1 ( +`id` int(10) unsigned NOT NULL auto_increment, +`id_object` int(10) unsigned default '0', +`id_version` int(10) unsigned NOT NULL default '1', +`label` varchar(100) NOT NULL default '', +`description` text, +PRIMARY KEY (`id`), +KEY `id_object` (`id_object`), +KEY `id_version` (`id_version`) +) ENGINE=InnoDB; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES("6", "3382", "9", "Test", NULL), ("7", "102", "5", "Le Pekin (Test)", NULL),("584", "1794", "4", "Test de resto", NULL),("837", "1822", "6", "Test 3", NULL),("1119", "3524", "1", "Societe Test", NULL),("1122", "3525", "1", "Fournisseur Test", NULL); +CREATE TABLE t2 ( +`id` int(10) unsigned NOT NULL auto_increment, +`id_version` int(10) unsigned NOT NULL default '1', +PRIMARY KEY (`id`), +KEY `id_version` (`id_version`) +) ENGINE=InnoDB; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES("3524", "1"),("3525", "1"),("1794", "4"),("102", "5"),("1822", "6"),("3382", "9"); +SELECT t2.id, t1.`label` FROM t2 INNER JOIN +(SELECT t1.id_object as id_object FROM t1 WHERE t1.`label` LIKE '%test%') AS lbl +ON (t2.id = lbl.id_object) INNER JOIN t1 ON (t2.id = t1.id_object) ORDER BY 1; +id label +102 Le Pekin (Test) +1794 Test de resto +1822 Test 3 +3382 Test +3524 Societe Test +3525 Fournisseur Test +drop table t1,t2; +create table t1 (a int, b varchar(200), c text not null) checksum=1 engine=myisam; +create table t2 (a int, b varchar(200), c text not null) checksum=0 engine=innodb; +create table t3 (a int, b varchar(200), c text not null) checksum=1 engine=innodb; +insert t1 values (1, "aaa", "bbb"), (NULL, "", "ccccc"), (0, NULL, ""); +insert t2 select * from t1; +insert t3 select * from t1; +checksum table t1, t2, t3, t4 quick; +Table Checksum +test.t1 2948697075 +test.t2 NULL +test.t3 NULL +test.t4 NULL +Warnings: +Error 1146 Table 'test.t4' doesn't exist +checksum table t1, t2, t3, t4; +Table Checksum +test.t1 2948697075 +test.t2 2948697075 +test.t3 2948697075 +test.t4 NULL +Warnings: +Error 1146 Table 'test.t4' doesn't exist +checksum table t1, t2, t3, t4 extended; +Table Checksum +test.t1 2948697075 +test.t2 2948697075 +test.t3 2948697075 +test.t4 NULL +Warnings: +Error 1146 Table 'test.t4' doesn't exist +drop table t1,t2,t3; +create table t1 (id int, name char(10) not null, name2 char(10) not null) engine=innodb; +insert into t1 values(1,'first','fff'),(2,'second','sss'),(3,'third','ttt'); +select trim(name2) from t1 union all select trim(name) from t1 union all select trim(id) from t1; +trim(name2) +fff +sss +ttt +first +second +third +1 +2 +3 +drop table t1; +create table t1 (a int) engine=innodb; +create table t2 like t1; +drop table t1,t2; +create table t1 (id int(11) not null, id2 int(11) not null, unique (id,id2)) engine=innodb; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +create table t2 (id int(11) not null, constraint t1_id_fk foreign key ( id ) references t1 (id)) engine = innodb; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `id` int NOT NULL, + `id2` int NOT NULL, + UNIQUE KEY `id` (`id`,`id2`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `id` int NOT NULL, + KEY `t1_id_fk` (`id`), + CONSTRAINT `t1_id_fk` FOREIGN KEY (`id`) REFERENCES `t1` (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +create index id on t2 (id); +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `id` int NOT NULL, + KEY `id` (`id`), + CONSTRAINT `t1_id_fk` FOREIGN KEY (`id`) REFERENCES `t1` (`id`) +) /*!50100 TABLESPACE `innodb_system` */ ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +create index id2 on t2 (id); +Warnings: +Warning 1831 Duplicate index 'id2' defined on the table 'test.t2'. This is deprecated and will be disallowed in a future release. +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `id` int NOT NULL, + KEY `id` (`id`), + KEY `id2` (`id`), + CONSTRAINT `t1_id_fk` FOREIGN KEY (`id`) REFERENCES `t1` (`id`) +) /*!50100 TABLESPACE `innodb_system` */ ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop index id2 on t2; +drop index id on t2; +ERROR HY000: Cannot drop index 'id': needed in a foreign key constraint +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `id` int NOT NULL, + KEY `id` (`id`), + CONSTRAINT `t1_id_fk` FOREIGN KEY (`id`) REFERENCES `t1` (`id`) +) /*!50100 TABLESPACE `innodb_system` */ ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t2; +create table t2 (id int(11) not null, id2 int(11) not null, constraint t1_id_fk foreign key (id,id2) references t1 (id,id2)) engine = innodb; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `id` int NOT NULL, + `id2` int NOT NULL, + KEY `t1_id_fk` (`id`,`id2`), + CONSTRAINT `t1_id_fk` FOREIGN KEY (`id`, `id2`) REFERENCES `t1` (`id`, `id2`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +create unique index id on t2 (id,id2); +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `id` int NOT NULL, + `id2` int NOT NULL, + UNIQUE KEY `id` (`id`,`id2`), + CONSTRAINT `t1_id_fk` FOREIGN KEY (`id`, `id2`) REFERENCES `t1` (`id`, `id2`) +) /*!50100 TABLESPACE `innodb_system` */ ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t2; +create table t2 (id int(11) not null, id2 int(11) not null, unique (id,id2),constraint t1_id_fk foreign key (id2,id) references t1 (id,id2)) engine = innodb; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `id` int NOT NULL, + `id2` int NOT NULL, + UNIQUE KEY `id` (`id`,`id2`), + KEY `t1_id_fk` (`id2`,`id`), + CONSTRAINT `t1_id_fk` FOREIGN KEY (`id2`, `id`) REFERENCES `t1` (`id`, `id2`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t2; +create table t2 (id int(11) not null, id2 int(11) not null, unique (id,id2), constraint t1_id_fk foreign key (id) references t1 (id)) engine = innodb; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `id` int NOT NULL, + `id2` int NOT NULL, + UNIQUE KEY `id` (`id`,`id2`), + CONSTRAINT `t1_id_fk` FOREIGN KEY (`id`) REFERENCES `t1` (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t2; +create table t2 (id int(11) not null, id2 int(11) not null, unique (id,id2),constraint t1_id_fk foreign key (id2,id) references t1 (id,id2)) engine = innodb; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `id` int NOT NULL, + `id2` int NOT NULL, + UNIQUE KEY `id` (`id`,`id2`), + KEY `t1_id_fk` (`id2`,`id`), + CONSTRAINT `t1_id_fk` FOREIGN KEY (`id2`, `id`) REFERENCES `t1` (`id`, `id2`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t2; +create table t2 (id int(11) not null auto_increment, id2 int(11) not null, constraint t1_id_fk foreign key (id) references t1 (id), primary key (id), index (id,id2)) engine = innodb; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `id` int NOT NULL AUTO_INCREMENT, + `id2` int NOT NULL, + PRIMARY KEY (`id`), + KEY `id` (`id`,`id2`), + CONSTRAINT `t1_id_fk` FOREIGN KEY (`id`) REFERENCES `t1` (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t2; +create table t2 (id int(11) not null auto_increment, id2 int(11) not null, constraint t1_id_fk foreign key (id) references t1 (id)) engine= innodb; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `id` int NOT NULL AUTO_INCREMENT, + `id2` int NOT NULL, + KEY `t1_id_fk` (`id`), + CONSTRAINT `t1_id_fk` FOREIGN KEY (`id`) REFERENCES `t1` (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +alter table t2 add index id_test (id), add index id_test2 (id,id2); +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `id` int NOT NULL AUTO_INCREMENT, + `id2` int NOT NULL, + KEY `id_test` (`id`), + KEY `id_test2` (`id`,`id2`), + CONSTRAINT `t1_id_fk` FOREIGN KEY (`id`) REFERENCES `t1` (`id`) +) /*!50100 TABLESPACE `innodb_system` */ ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t2; +create table t2 (id int(11) not null, id2 int(11) not null, constraint t1_id_fk foreign key (id2,id) references t1 (id)) engine = innodb; +ERROR 42000: Incorrect foreign key definition for 't1_id_fk': Key reference and table reference don't match +create table t2 (a int auto_increment primary key, b int, index(b), foreign key (b) references t1(id), unique(b)) engine=innodb; +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `a` int NOT NULL AUTO_INCREMENT, + `b` int DEFAULT NULL, + PRIMARY KEY (`a`), + UNIQUE KEY `b_2` (`b`), + KEY `b` (`b`), + CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`b`) REFERENCES `t1` (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t2; +create table t2 (a int auto_increment primary key, b int, foreign key (b) references t1(id), foreign key (b) references t1(id), unique(b)) engine=innodb; +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `a` int NOT NULL AUTO_INCREMENT, + `b` int DEFAULT NULL, + PRIMARY KEY (`a`), + UNIQUE KEY `b` (`b`), + CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`b`) REFERENCES `t1` (`id`), + CONSTRAINT `t2_ibfk_2` FOREIGN KEY (`b`) REFERENCES `t1` (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t2, t1; +create table t1 (c char(10), index (c,c)) engine=innodb; +ERROR 42S21: Duplicate column name 'c' +create table t1 (c1 char(10), c2 char(10), index (c1,c2,c1)) engine=innodb; +ERROR 42S21: Duplicate column name 'c1' +create table t1 (c1 char(10), c2 char(10), index (c1,c1,c2)) engine=innodb; +ERROR 42S21: Duplicate column name 'c1' +create table t1 (c1 char(10), c2 char(10), index (c2,c1,c1)) engine=innodb; +ERROR 42S21: Duplicate column name 'c1' +create table t1 (c1 char(10), c2 char(10)) engine=innodb; +alter table t1 add key (c1,c1); +ERROR 42S21: Duplicate column name 'c1' +alter table t1 add key (c2,c1,c1); +ERROR 42S21: Duplicate column name 'c1' +alter table t1 add key (c1,c2,c1); +ERROR 42S21: Duplicate column name 'c1' +alter table t1 add key (c1,c1,c2); +ERROR 42S21: Duplicate column name 'c1' +drop table t1; +CREATE TABLE t1 (a_id tinyint(4) NOT NULL default '0', PRIMARY KEY (a_id)) ENGINE=InnoDB DEFAULT CHARSET=latin1; +INSERT INTO t1 VALUES (1),(2),(3); +CREATE TABLE t2 (b_id tinyint(4) NOT NULL default '0',b_a tinyint(4) NOT NULL default '0', PRIMARY KEY (b_id), KEY (b_a), +CONSTRAINT fk_b_a FOREIGN KEY (b_a) REFERENCES t1 (a_id) ON DELETE CASCADE ON UPDATE NO ACTION) ENGINE=InnoDB DEFAULT CHARSET=latin1; +INSERT INTO t2 VALUES (1,1),(2,1),(3,1),(4,2),(5,2); +SELECT * FROM (SELECT t1.*,GROUP_CONCAT(t2.b_id SEPARATOR ',') as b_list FROM (t1 LEFT JOIN (t2) on t1.a_id = t2.b_a) GROUP BY t1.a_id ) AS xyz; +a_id b_list +1 1,2,3 +2 4,5 +3 NULL +DROP TABLE t2; +DROP TABLE t1; +create temporary table t1 (a int) engine=innodb; +insert into t1 values (4711); +truncate t1; +insert into t1 values (42); +select * from t1; +a +42 +drop table t1; +create table t1 (a int) engine=innodb; +insert into t1 values (4711); +truncate t1; +insert into t1 values (42); +select * from t1; +a +42 +drop table t1; +create table t1 (a int not null, b int not null, c blob not null, d int not null, e int, primary key (a,b,c(255),d)) engine=innodb; +insert into t1 values (2,2,"b",2,2),(1,1,"a",1,1),(3,3,"ab",3,3); +analyze table t1; +select * from t1 order by a,b,c,d; +a b c d e +1 1 a 1 1 +2 2 b 2 2 +3 3 ab 3 3 +explain select * from t1 order by a,b,c,d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c`,`test`.`t1`.`d` AS `d`,`test`.`t1`.`e` AS `e` from `test`.`t1` order by `test`.`t1`.`a`,`test`.`t1`.`b`,`test`.`t1`.`c`,`test`.`t1`.`d` +drop table t1; +create table t1 (a char(1), b char(1), key(a, b)) engine=innodb; +insert into t1 values ('8', '6'), ('4', '7'); +select min(a) from t1; +min(a) +4 +select min(b) from t1 where a='8'; +min(b) +6 +drop table t1; +create table t1 (x bigint unsigned not null primary key) engine=innodb; +insert into t1(x) values (0xfffffffffffffff0),(0xfffffffffffffff1); +select * from t1; +x +18446744073709551600 +18446744073709551601 +select count(*) from t1 where x>0; +count(*) +2 +select count(*) from t1 where x=0; +count(*) +0 +select count(*) from t1 where x<0; +count(*) +0 +select count(*) from t1 where x < -16; +count(*) +0 +select count(*) from t1 where x = -16; +count(*) +0 +explain select count(*) from t1 where x > -16; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index NULL PRIMARY 8 NULL 2 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select count(0) AS `count(*)` from `test`.`t1` where true +select count(*) from t1 where x > -16; +count(*) +2 +select * from t1 where x > -16; +x +18446744073709551600 +18446744073709551601 +select count(*) from t1 where x = 18446744073709551601; +count(*) +1 +drop table t1; +SELECT variable_value FROM performance_schema.global_status WHERE LOWER(variable_name) = 'innodb_buffer_pool_pages_total'; +variable_value +{checked_valid} +SELECT variable_value FROM performance_schema.global_status WHERE LOWER(variable_name) = 'innodb_page_size'; +variable_value +{checked_valid} +SELECT sum(variable_value) - @innodb_rows_deleted_orig FROM performance_schema.global_status WHERE LOWER(variable_name) like 'innodb%_rows_deleted'; +sum(variable_value) - @innodb_rows_deleted_orig +1830 +SELECT sum(variable_value) - @innodb_rows_inserted_orig FROM performance_schema.global_status WHERE LOWER(variable_name) like 'innodb%_rows_inserted'; +sum(variable_value) - @innodb_rows_inserted_orig +2733 +SELECT sum(variable_value) - @innodb_rows_updated_orig FROM performance_schema.global_status WHERE LOWER(variable_name) like 'innodb%_rows_updated'; +sum(variable_value) - @innodb_rows_updated_orig +2635 +SELECT variable_value - @innodb_row_lock_waits_orig FROM performance_schema.global_status WHERE LOWER(variable_name) = 'innodb_row_lock_waits'; +variable_value - @innodb_row_lock_waits_orig +0 +SELECT variable_value - @innodb_row_lock_current_waits_orig FROM performance_schema.global_status WHERE LOWER(variable_name) = 'innodb_row_lock_current_waits'; +variable_value - @innodb_row_lock_current_waits_orig +0 +SELECT variable_value - @innodb_row_lock_time_orig FROM performance_schema.global_status WHERE LOWER(variable_name) = 'innodb_row_lock_time'; +variable_value - @innodb_row_lock_time_orig +0 +SELECT variable_value - @innodb_row_lock_time_max_orig FROM performance_schema.global_status WHERE LOWER(variable_name) = 'innodb_row_lock_time_max'; +variable_value - @innodb_row_lock_time_max_orig +0 +SELECT variable_value - @innodb_row_lock_time_avg_orig FROM performance_schema.global_status WHERE LOWER(variable_name) = 'innodb_row_lock_time_avg'; +variable_value - @innodb_row_lock_time_avg_orig +0 +SET @innodb_sync_spin_loops_orig = @@innodb_sync_spin_loops; +show variables like "innodb_sync_spin_loops"; +Variable_name Value +innodb_sync_spin_loops 30 +set global innodb_sync_spin_loops=1000; +show variables like "innodb_sync_spin_loops"; +Variable_name Value +innodb_sync_spin_loops 1000 +set global innodb_sync_spin_loops=0; +show variables like "innodb_sync_spin_loops"; +Variable_name Value +innodb_sync_spin_loops 0 +set global innodb_sync_spin_loops=20; +show variables like "innodb_sync_spin_loops"; +Variable_name Value +innodb_sync_spin_loops 20 +set global innodb_sync_spin_loops=@innodb_sync_spin_loops_orig; +show variables like "innodb_thread_concurrency"; +Variable_name Value +innodb_thread_concurrency 0 +set global innodb_thread_concurrency=1001; +Warnings: +Warning 1292 Truncated incorrect innodb_thread_concurrency value: '1001' +Warning 1210 Current innodb_thread_concurrency is too big for safety of log files. Consider decreasing it or increase number of log files. +show variables like "innodb_thread_concurrency"; +Variable_name Value +innodb_thread_concurrency 1000 +set global innodb_thread_concurrency=0; +show variables like "innodb_thread_concurrency"; +Variable_name Value +innodb_thread_concurrency 0 +set global innodb_thread_concurrency=16; +show variables like "innodb_thread_concurrency"; +Variable_name Value +innodb_thread_concurrency 16 +show variables like "innodb_concurrency_tickets"; +Variable_name Value +innodb_concurrency_tickets 5000 +set global innodb_concurrency_tickets=1000; +show variables like "innodb_concurrency_tickets"; +Variable_name Value +innodb_concurrency_tickets 1000 +set global innodb_concurrency_tickets=0; +Warnings: +Warning 1292 Truncated incorrect innodb_concurrency_tickets value: '0' +show variables like "innodb_concurrency_tickets"; +Variable_name Value +innodb_concurrency_tickets 1 +set global innodb_concurrency_tickets=5000; +show variables like "innodb_concurrency_tickets"; +Variable_name Value +innodb_concurrency_tickets 5000 +show variables like "innodb_thread_sleep_delay"; +Variable_name Value +innodb_thread_sleep_delay 10000 +set global innodb_thread_sleep_delay=100000; +show variables like "innodb_thread_sleep_delay"; +Variable_name Value +innodb_thread_sleep_delay 100000 +set global innodb_thread_sleep_delay=0; +show variables like "innodb_thread_sleep_delay"; +Variable_name Value +innodb_thread_sleep_delay 0 +set global innodb_thread_sleep_delay=10000; +show variables like "innodb_thread_sleep_delay"; +Variable_name Value +innodb_thread_sleep_delay 10000 +set default_storage_engine=INNODB; +set session old_alter_table=1; +drop table if exists t1,t2,t3; +--- Testing varchar --- +--- Testing varchar --- +create table t1 (v varchar(10), c char(10), t text); +insert into t1 values('+ ', '+ ', '+ '); +set @a=repeat(' ',20); +insert into t1 values (concat('+',@a),concat('+',@a),concat('+',@a)); +Warnings: +Note 1265 Data truncated for column 'v' at row 1 +select concat('*',v,'*',c,'*',t,'*') from t1; +concat('*',v,'*',c,'*',t,'*') +*+ *+*+ * +*+ *+*+ * +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `v` varchar(10) DEFAULT NULL, + `c` char(10) DEFAULT NULL, + `t` text +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +create table t2 like t1; +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `v` varchar(10) DEFAULT NULL, + `c` char(10) DEFAULT NULL, + `t` text +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +create table t3 select * from t1; +show create table t3; +Table Create Table +t3 CREATE TABLE `t3` ( + `v` varchar(10) DEFAULT NULL, + `c` char(10) DEFAULT NULL, + `t` text +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +alter table t1 modify c varchar(10); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `v` varchar(10) DEFAULT NULL, + `c` varchar(10) DEFAULT NULL, + `t` text +) /*!50100 TABLESPACE `innodb_system` */ ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +alter table t1 modify v char(10); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `v` char(10) DEFAULT NULL, + `c` varchar(10) DEFAULT NULL, + `t` text +) /*!50100 TABLESPACE `innodb_system` */ ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +alter table t1 modify t varchar(10); +Warnings: +Note 1265 Data truncated for column 't' at row 2 +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `v` char(10) DEFAULT NULL, + `c` varchar(10) DEFAULT NULL, + `t` varchar(10) DEFAULT NULL +) /*!50100 TABLESPACE `innodb_system` */ ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +select concat('*',v,'*',c,'*',t,'*') from t1; +concat('*',v,'*',c,'*',t,'*') +*+*+*+ * +*+*+*+ * +drop table t1,t2,t3; +create table t1 (v varchar(10), c char(10), t text, key(v), key(c), key(t(10))) +stats_persistent=0 charset latin1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `v` varchar(10) DEFAULT NULL, + `c` char(10) DEFAULT NULL, + `t` text, + KEY `v` (`v`), + KEY `c` (`c`), + KEY `t` (`t`(10)) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 STATS_PERSISTENT=0 +select count(*) from t1; +count(*) +270 +insert into t1 values(concat('a',char(1)),concat('a',char(1)),concat('a',char(1))); +select count(*) from t1 where v='a'; +count(*) +10 +select count(*) from t1 where c='a'; +count(*) +10 +select count(*) from t1 where t='a'; +count(*) +10 +select count(*) from t1 where v='a '; +count(*) +10 +select count(*) from t1 where c='a '; +count(*) +10 +select count(*) from t1 where t='a '; +count(*) +10 +select count(*) from t1 where v between 'a' and 'a '; +count(*) +10 +select count(*) from t1 where v between 'a' and 'a ' and v between 'a ' and 'b\n'; +count(*) +10 +select count(*) from t1 where v like 'a%'; +count(*) +11 +select count(*) from t1 where c like 'a%'; +count(*) +11 +select count(*) from t1 where t like 'a%'; +count(*) +11 +select count(*) from t1 where v like 'a %'; +count(*) +9 +explain select count(*) from t1 where v='a '; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref v v 13 const # 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select count(0) AS `count(*)` from `test`.`t1` where (`test`.`t1`.`v` = 'a ') +explain select count(*) from t1 where c='a '; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref c c 11 const # 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select count(0) AS `count(*)` from `test`.`t1` where (`test`.`t1`.`c` = 'a ') +explain select count(*) from t1 where t='a '; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ref t t 13 const # 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select count(0) AS `count(*)` from `test`.`t1` where (`test`.`t1`.`t` = 'a ') +explain select count(*) from t1 where v like 'a%'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range v v 13 NULL # 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select count(0) AS `count(*)` from `test`.`t1` where (`test`.`t1`.`v` like 'a%') +explain select count(*) from t1 where v between 'a' and 'a '; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref v v 13 const # 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select count(0) AS `count(*)` from `test`.`t1` where (`test`.`t1`.`v` between 'a' and 'a ') +explain select count(*) from t1 where v between 'a' and 'a ' and v between 'a ' and 'b\n'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref v v 13 const # 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select count(0) AS `count(*)` from `test`.`t1` where ((`test`.`t1`.`v` between 'a' and 'a ') and (`test`.`t1`.`v` between 'a ' and 'b\n')) +alter table t1 add unique(v); +ERROR 23000: Duplicate entry '{ ' for key 't1.v_2' +alter table t1 add key(v); +Warnings: +Warning 1831 Duplicate index 'v_2' defined on the table 'test.t1'. This is deprecated and will be disallowed in a future release. +select concat('*',v,'*',c,'*',t,'*') as qq from t1 where v='a'; +qq +*a*a*a* +*a *a*a * +*a *a*a * +*a *a*a * +*a *a*a * +*a *a*a * +*a *a*a * +*a *a*a * +*a *a*a * +*a *a*a * +explain select * from t1 where v='a'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ref v,v_2 # 13 const # 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`v` AS `v`,`test`.`t1`.`c` AS `c`,`test`.`t1`.`t` AS `t` from `test`.`t1` where (`test`.`t1`.`v` = 'a') +select TRIM(v),count(*) from t1 group by TRIM(v) order by TRIM(v) limit 10; +TRIM(v) count(*) +a 1 +a 10 +b 10 +c 10 +d 10 +e 10 +f 10 +g 10 +h 10 +i 10 +select TRIM(v),count(t) from t1 group by TRIM(v) order by TRIM(v) limit 10; +TRIM(v) count(t) +a 1 +a 10 +b 10 +c 10 +d 10 +e 10 +f 10 +g 10 +h 10 +i 10 +select TRIM(v),count(c) from t1 group by TRIM(v) order by TRIM(v) limit 10; +TRIM(v) count(c) +a 1 +a 10 +b 10 +c 10 +d 10 +e 10 +f 10 +g 10 +h 10 +i 10 +select sql_big_result TRIM(v),count(t) from t1 group by TRIM(v) order by TRIM(v) limit 10; +TRIM(v) count(t) +a 1 +a 10 +b 10 +c 10 +d 10 +e 10 +f 10 +g 10 +h 10 +i 10 +select sql_big_result TRIM(v),count(c) from t1 group by TRIM(v) order by TRIM(v) limit 10; +TRIM(v) count(c) +a 1 +a 10 +b 10 +c 10 +d 10 +e 10 +f 10 +g 10 +h 10 +i 10 +select c,count(*) from t1 group by c order by c limit 10; +c count(*) +a 1 +a 10 +b 10 +c 10 +d 10 +e 10 +f 10 +g 10 +h 10 +i 10 +select c,count(t) from t1 group by c order by c limit 10; +c count(t) +a 1 +a 10 +b 10 +c 10 +d 10 +e 10 +f 10 +g 10 +h 10 +i 10 +select sql_big_result c,count(t) from t1 group by c limit 10; +c count(t) +a 1 +a 10 +b 10 +c 10 +d 10 +e 10 +f 10 +g 10 +h 10 +i 10 +select TRIM(t),count(*) from t1 group by TRIM(t) order by TRIM(t) limit 10; +TRIM(t) count(*) +a 1 +a 10 +b 10 +c 10 +d 10 +e 10 +f 10 +g 10 +h 10 +i 10 +select TRIM(t),count(t) from t1 group by TRIM(t) order by TRIM(t) limit 10; +TRIM(t) count(t) +a 1 +a 10 +b 10 +c 10 +d 10 +e 10 +f 10 +g 10 +h 10 +i 10 +select sql_big_result TRIM(t),count(t) from t1 group by TRIM(t) order by TRIM(t) limit 10; +TRIM(t) count(t) +a 1 +a 10 +b 10 +c 10 +d 10 +e 10 +f 10 +g 10 +h 10 +i 10 +alter table t1 modify v varchar(300), drop key v, drop key v_2, add key v (v); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `v` varchar(300) DEFAULT NULL, + `c` char(10) DEFAULT NULL, + `t` text, + KEY `c` (`c`), + KEY `t` (`t`(10)), + KEY `v` (`v`) +) /*!50100 TABLESPACE `innodb_system` */ ENGINE=InnoDB DEFAULT CHARSET=latin1 STATS_PERSISTENT=0 +select count(*) from t1 where v='a'; +count(*) +10 +select count(*) from t1 where v='a '; +count(*) +10 +select count(*) from t1 where v between 'a' and 'a '; +count(*) +10 +select count(*) from t1 where v between 'a' and 'a ' and v between 'a ' and 'b\n'; +count(*) +10 +select count(*) from t1 where v like 'a%'; +count(*) +11 +select count(*) from t1 where v like 'a %'; +count(*) +9 +explain select count(*) from t1 where v='a '; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref v v 303 const # 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select count(0) AS `count(*)` from `test`.`t1` where (`test`.`t1`.`v` = 'a ') +explain select count(*) from t1 where v like 'a%'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range v v 303 NULL # 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select count(0) AS `count(*)` from `test`.`t1` where (`test`.`t1`.`v` like 'a%') +explain select count(*) from t1 where v between 'a' and 'a '; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref v v 303 const # 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select count(0) AS `count(*)` from `test`.`t1` where (`test`.`t1`.`v` between 'a' and 'a ') +explain select count(*) from t1 where v between 'a' and 'a ' and v between 'a ' and 'b\n'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref v v 303 const # 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select count(0) AS `count(*)` from `test`.`t1` where ((`test`.`t1`.`v` between 'a' and 'a ') and (`test`.`t1`.`v` between 'a ' and 'b\n')) +explain select * from t1 where v='a'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ref v v 303 const # 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`v` AS `v`,`test`.`t1`.`c` AS `c`,`test`.`t1`.`t` AS `t` from `test`.`t1` where (`test`.`t1`.`v` = 'a') +select v,count(*) from t1 group by v order by v limit 10; +v count(*) +a 1 +a 10 +b 10 +c 10 +d 10 +e 10 +f 10 +g 10 +h 10 +i 10 +select TRIM(v),count(t) from t1 group by v order by v limit 10; +TRIM(v) count(t) +a 1 +a 10 +b 10 +c 10 +d 10 +e 10 +f 10 +g 10 +h 10 +i 10 +select sql_big_result TRIM(v),count(t) from t1 group by v order by v limit 10; +TRIM(v) count(t) +a 1 +a 10 +b 10 +c 10 +d 10 +e 10 +f 10 +g 10 +h 10 +i 10 +alter table t1 drop key v, add key v (v(30)); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `v` varchar(300) DEFAULT NULL, + `c` char(10) DEFAULT NULL, + `t` text, + KEY `c` (`c`), + KEY `t` (`t`(10)), + KEY `v` (`v`(30)) +) /*!50100 TABLESPACE `innodb_system` */ ENGINE=InnoDB DEFAULT CHARSET=latin1 STATS_PERSISTENT=0 +select count(*) from t1 where v='a'; +count(*) +10 +select count(*) from t1 where v='a '; +count(*) +10 +select count(*) from t1 where v between 'a' and 'a '; +count(*) +10 +select count(*) from t1 where v between 'a' and 'a ' and v between 'a ' and 'b\n'; +count(*) +10 +select count(*) from t1 where v like 'a%'; +count(*) +11 +select count(*) from t1 where v like 'a %'; +count(*) +9 +explain select count(*) from t1 where v='a '; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref v v 33 const # 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select count(0) AS `count(*)` from `test`.`t1` where (`test`.`t1`.`v` = 'a ') +explain select count(*) from t1 where v like 'a%'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range v v 33 NULL # 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select count(0) AS `count(*)` from `test`.`t1` where (`test`.`t1`.`v` like 'a%') +explain select count(*) from t1 where v between 'a' and 'a '; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref v v 33 const # 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select count(0) AS `count(*)` from `test`.`t1` where (`test`.`t1`.`v` between 'a' and 'a ') +explain select count(*) from t1 where v between 'a' and 'a ' and v between 'a ' and 'b\n'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref v v 33 const # 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select count(0) AS `count(*)` from `test`.`t1` where ((`test`.`t1`.`v` between 'a' and 'a ') and (`test`.`t1`.`v` between 'a ' and 'b\n')) +explain select * from t1 where v='a'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ref v v 33 const # 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`v` AS `v`,`test`.`t1`.`c` AS `c`,`test`.`t1`.`t` AS `t` from `test`.`t1` where (`test`.`t1`.`v` = 'a') +select TRIM(v),count(*) from t1 group by v order by v limit 10; +TRIM(v) count(*) +a 1 +a 10 +b 10 +c 10 +d 10 +e 10 +f 10 +g 10 +h 10 +i 10 +select TRIM(v),count(t) from t1 group by v order by v limit 10; +TRIM(v) count(t) +a 1 +a 10 +b 10 +c 10 +d 10 +e 10 +f 10 +g 10 +h 10 +i 10 +select sql_big_result TRIM(v),count(t) from t1 group by v order by v limit 10; +TRIM(v) count(t) +a 1 +a 10 +b 10 +c 10 +d 10 +e 10 +f 10 +g 10 +h 10 +i 10 +alter table t1 modify v varchar(600), drop key v, add key v (v); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `v` varchar(600) DEFAULT NULL, + `c` char(10) DEFAULT NULL, + `t` text, + KEY `c` (`c`), + KEY `t` (`t`(10)), + KEY `v` (`v`) +) /*!50100 TABLESPACE `innodb_system` */ ENGINE=InnoDB DEFAULT CHARSET=latin1 STATS_PERSISTENT=0 +select TRIM(v),count(*) from t1 group by v order by v limit 10; +TRIM(v) count(*) +a 1 +a 10 +b 10 +c 10 +d 10 +e 10 +f 10 +g 10 +h 10 +i 10 +select TRIM(v),count(t) from t1 group by v order by v limit 10; +TRIM(v) count(t) +a 1 +a 10 +b 10 +c 10 +d 10 +e 10 +f 10 +g 10 +h 10 +i 10 +select sql_big_result TRIM(v),count(t) from t1 group by v order by v limit 10; +TRIM(v) count(t) +a 1 +a 10 +b 10 +c 10 +d 10 +e 10 +f 10 +g 10 +h 10 +i 10 +drop table t1; +SET NAMES utf8mb4; +create table t1 (a char(10), unique (a)); +insert into t1 values ('a '); +insert into t1 values ('a '); +ERROR 23000: Duplicate entry 'a' for key 't1.a' +alter table t1 modify a varchar(10); +insert into t1 values ('a'),('á'),('à'),('Ã¥'); +ERROR 23000: Duplicate entry 'a' for key 't1.a' +insert into t1 values ('á'); +ERROR 23000: Duplicate entry 'á' for key 't1.a' +insert into t1 values ('A'); +ERROR 23000: Duplicate entry 'A' for key 't1.a' +insert into t1 values ('Ã¥'); +ERROR 23000: Duplicate entry 'Ã¥' for key 't1.a' +update t1 set a='a ' where a like 'a%'; +select concat(a,'.') from t1; +concat(a,'.') +a . +update t1 set a='abc ' where a like 'a '; +select concat(a,'.') from t1; +concat(a,'.') +a . +update t1 set a='a ' where a like 'a %'; +select concat(a,'.') from t1; +concat(a,'.') +a . +update t1 set a='a ' where a like 'a '; +select concat(a,'.') from t1; +concat(a,'.') +a . +drop table t1; +SET NAMES DEFAULT; +create table t1 (v varchar(10), c char(10), t text, key(v(5)), key(c(5)), key(t(5))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `v` varchar(10) DEFAULT NULL, + `c` char(10) DEFAULT NULL, + `t` text, + KEY `v` (`v`(5)), + KEY `c` (`c`(5)), + KEY `t` (`t`(5)) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +create table t1 (v char(10) character set utf8); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `v` char(10) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +create table t1 (v varchar(10), c char(10)) row_format=fixed; +Warnings: +Warning 1478 InnoDB: assuming ROW_FORMAT=DYNAMIC. +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `v` varchar(10) DEFAULT NULL, + `c` char(10) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=DYNAMIC +insert into t1 values('a','a'),('a ','a '); +select concat('*',v,'*',c,'*') from t1; +concat('*',v,'*',c,'*') +*a*a* +*a *a* +drop table t1; +create table t1 (v varchar(65530), key(v(10))) charset latin1; +insert into t1 values(repeat('a',65530)); +select length(v) from t1 where v=repeat('a',65530); +length(v) +65530 +drop table t1; +create table t1(a int, b varchar(12), key ba(b, a)); +insert into t1 values (1, 'A'), (20, NULL); +explain select * from t1 where a=20 and b is null; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref ba ba 56 const,const 1 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`a` = 20) and (`test`.`t1`.`b` is null)) +select * from t1 where a=20 and b is null; +a b +20 NULL +drop table t1; +set session old_alter_table=0; +SET sql_mode = 'NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES'; +Warnings: +Warning 3135 'NO_ZERO_DATE', 'NO_ZERO_IN_DATE' and 'ERROR_FOR_DIVISION_BY_ZERO' sql modes should be used with strict mode. They will be merged with strict mode in a future release. +create table t1 (v varchar(65530), key(v)) charset latin1 ROW_FORMAT=COMPACT; +Got one of the listed errors +SET sql_mode = 'NO_ENGINE_SUBSTITUTION'; +create table t1 (v varchar(65536)); +Warnings: +Note 1246 Converting column 'v' from VARCHAR to TEXT +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `v` mediumtext +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +create table t1 (v varchar(65530) character set utf8); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Note 1246 Converting column 'v' from VARCHAR to TEXT +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `v` mediumtext CHARACTER SET utf8 COLLATE utf8_general_ci +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +SET sql_mode = default; +set default_storage_engine=MyISAM; +create table t1 (v varchar(16384)) charset latin1 engine=innodb; +drop table t1; +create table t1 (a char(1), b char(1), key(a, b)) engine=innodb; +insert into t1 values ('8', '6'), ('4', '7'); +select min(a) from t1; +min(a) +4 +select min(b) from t1 where a='8'; +min(b) +6 +drop table t1; +CREATE TABLE t1 ( `a` int(11) NOT NULL auto_increment, `b` int(11) default NULL,PRIMARY KEY (`a`),UNIQUE KEY `b` (`b`)) ENGINE=innodb; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t1 (b) values (1); +replace into t1 (b) values (2), (1), (3); +select * from t1; +a b +2 2 +3 1 +4 3 +truncate table t1; +insert into t1 (b) values (1); +replace into t1 (b) values (2); +replace into t1 (b) values (1); +replace into t1 (b) values (3); +select * from t1; +a b +2 2 +3 1 +4 3 +drop table t1; +create table t1 (rowid int not null auto_increment, val int not null,primary +key (rowid), unique(val)) engine=innodb; +replace into t1 (val) values ('1'),('2'); +replace into t1 (val) values ('1'),('2'); +insert into t1 (val) values ('1'),('2'); +ERROR 23000: Duplicate entry '1' for key 't1.val' +select * from t1; +rowid val +3 1 +4 2 +drop table t1; +create table t1 (a int not null auto_increment primary key, val int) engine=InnoDB; +insert into t1 (val) values (1); +update t1 set a=2 where a=1; +insert into t1 (val) values (3); +select * from t1; +a val +2 1 +3 3 +insert into t1 values (2, 2); +ERROR 23000: Duplicate entry '2' for key 't1.PRIMARY' +select * from t1; +a val +2 1 +3 3 +drop table t1; +CREATE TABLE t1 (GRADE DECIMAL(4) NOT NULL, PRIMARY KEY (GRADE)) ENGINE=INNODB; +INSERT INTO t1 (GRADE) VALUES (151),(252),(343); +SELECT GRADE FROM t1 WHERE GRADE > 160 AND GRADE < 300; +GRADE +252 +SELECT GRADE FROM t1 WHERE GRADE= 151; +GRADE +151 +DROP TABLE t1; +create table t1 (f1 varchar(10), f2 varchar(10), primary key (f1,f2)) engine=innodb; +create table t2 (f3 varchar(10), f4 varchar(10), key (f4)) engine=innodb; +insert into t2 values ('aa','cc'); +insert into t1 values ('aa','bb'),('aa','cc'); +delete t1 from t1,t2 where f1=f3 and f4='cc'; +select * from t1; +f1 f2 +drop table t1,t2; +CREATE TABLE t1 ( +id INTEGER NOT NULL AUTO_INCREMENT, PRIMARY KEY (id) +) ENGINE=InnoDB; +INSERT INTO t1 (id) VALUES (NULL); +SELECT * FROM t1; +id +1 +TRUNCATE t1; +INSERT INTO t1 (id) VALUES (NULL); +SELECT * FROM t1; +id +1 +DELETE FROM t1; +TRUNCATE t1; +INSERT INTO t1 (id) VALUES (NULL); +SELECT * FROM t1; +id +1 +DROP TABLE t1; +CREATE TABLE t1 +( +id INT PRIMARY KEY +) ENGINE=InnoDB; +CREATE TEMPORARY TABLE t2 +( +id INT NOT NULL PRIMARY KEY, +b INT, +FOREIGN KEY (b) REFERENCES test.t1(id) +) ENGINE=InnoDB; +ERROR HY000: Cannot add foreign key constraint +DROP TABLE t1; +create table t1 (col1 varchar(2000), index (col1(767))) +character set = latin1 engine = innodb; +create table t2 (col1 char(255), index (col1)) +character set = latin1 engine = innodb; +create table t3 (col1 binary(255), index (col1)) +character set = latin1 engine = innodb; +create table t4 (col1 varchar(767), index (col1)) +character set = latin1 engine = innodb; +create table t5 (col1 varchar(767) primary key) +character set = latin1 engine = innodb; +create table t6 (col1 varbinary(767) primary key) +character set = latin1 engine = innodb; +create table t7 (col1 text, index(col1(767))) +character set = latin1 engine = innodb; +create table t8 (col1 blob, index(col1(767))) +character set = latin1 engine = innodb; +drop table t1, t2, t3, t4, t5, t6, t7, t8; +CREATE TABLE t1 +( +id INT PRIMARY KEY +) ENGINE=InnoDB; +CREATE TABLE t2 +( +v INT, +CONSTRAINT c1 FOREIGN KEY (v) REFERENCES t1(id) +) ENGINE=InnoDB; +INSERT INTO t2 VALUES(2); +ERROR 23000: Cannot add or update a child row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `c1` FOREIGN KEY (`v`) REFERENCES `t1` (`id`)) +INSERT INTO t1 VALUES(1); +INSERT INTO t2 VALUES(1); +DELETE FROM t1 WHERE id = 1; +ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `c1` FOREIGN KEY (`v`) REFERENCES `t1` (`id`)) +DROP TABLE t1; +ERROR HY000: Cannot drop table 't1' referenced by a foreign key constraint 'c1' on table 't2'. +SET FOREIGN_KEY_CHECKS=0; +DROP TABLE t1; +SET FOREIGN_KEY_CHECKS=1; +INSERT INTO t2 VALUES(3); +ERROR 23000: Cannot add or update a child row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `c1` FOREIGN KEY (`v`) REFERENCES `t1` (`id`)) +DROP TABLE t2; +create table t1(a int not null) engine=innodb DEFAULT CHARSET=latin1; +insert into t1 values (1),(2); +set autocommit=0; +checksum table t1; +Table Checksum +test.t1 1531596814 +insert into t1 values(3); +checksum table t1; +Table Checksum +test.t1 1531596814 +commit; +checksum table t1; +Table Checksum +test.t1 2050879373 +commit; +drop table t1; +create table t1(a int not null) engine=innodb DEFAULT CHARSET=latin1; +insert into t1 values (1),(2); +set autocommit=1; +checksum table t1; +Table Checksum +test.t1 1531596814 +set autocommit=1; +insert into t1 values(3); +checksum table t1; +Table Checksum +test.t1 2050879373 +drop table t1; +set foreign_key_checks=0; +create table t2 (a int primary key, b int, foreign key (b) references t1(a)) engine = innodb; +create table t1(a char(10) primary key, b varchar(20)) engine = innodb; +ERROR HY000: Referencing column 'b' and referenced column 'a' in foreign key constraint 't2_ibfk_1' are incompatible. +set foreign_key_checks=1; +drop table t2; +set foreign_key_checks=0; +create table t1(a varchar(10) primary key) engine = innodb DEFAULT CHARSET=latin1; +create table t2 (a varchar(10), foreign key (a) references t1(a)) engine = innodb DEFAULT CHARSET=utf8; +ERROR HY000: Referencing column 'a' and referenced column 'a' in foreign key constraint 't2_ibfk_1' are incompatible. +set foreign_key_checks=1; +drop table t1; +set foreign_key_checks=0; +create table t2 (a varchar(10), foreign key (a) references t1(a)) engine = innodb; +create table t1(a varchar(10) primary key) engine = innodb; +alter table t1 modify column a int; +ERROR HY000: Referencing column 'a' and referenced column 'a' in foreign key constraint 't2_ibfk_1' are incompatible. +set foreign_key_checks=1; +drop table t2,t1; +set foreign_key_checks=0; +create table t2 (a varchar(10), foreign key (a) references t1(a)) engine = innodb DEFAULT CHARSET=latin1; +create table t1(a varchar(10) primary key) engine = innodb DEFAULT CHARSET=latin1; +alter table t1 convert to character set utf8; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +set foreign_key_checks=1; +drop table t2,t1; +set foreign_key_checks=0; +create table t2 (a varchar(10), foreign key (a) references t1(a)) engine = innodb DEFAULT CHARSET=latin1; +create table t3(a varchar(10) primary key) engine = innodb DEFAULT CHARSET=utf8; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +rename table t3 to t1; +ERROR HY000: Referencing column 'a' and referenced column 'a' in foreign key constraint 't2_ibfk_1' are incompatible. +set foreign_key_checks=1; +drop table t2,t3; +create table t1(a int primary key) row_format=redundant engine=innodb; +create table t2(a int primary key,constraint foreign key(a)references t1(a)) row_format=compact engine=innodb; +create table t3(a int primary key) row_format=compact engine=innodb; +create table t4(a int primary key,constraint foreign key(a)references t3(a)) row_format=redundant engine=innodb; +insert into t1 values(1); +insert into t3 values(1); +insert into t2 values(2); +ERROR 23000: Cannot add or update a child row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`a`) REFERENCES `t1` (`a`)) +insert into t4 values(2); +ERROR 23000: Cannot add or update a child row: a foreign key constraint fails (`test`.`t4`, CONSTRAINT `t4_ibfk_1` FOREIGN KEY (`a`) REFERENCES `t3` (`a`)) +insert into t2 values(1); +insert into t4 values(1); +update t1 set a=2; +ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`a`) REFERENCES `t1` (`a`)) +update t2 set a=2; +ERROR 23000: Cannot add or update a child row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`a`) REFERENCES `t1` (`a`)) +update t3 set a=2; +ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t4`, CONSTRAINT `t4_ibfk_1` FOREIGN KEY (`a`) REFERENCES `t3` (`a`)) +update t4 set a=2; +ERROR 23000: Cannot add or update a child row: a foreign key constraint fails (`test`.`t4`, CONSTRAINT `t4_ibfk_1` FOREIGN KEY (`a`) REFERENCES `t3` (`a`)) +truncate t1; +ERROR 42000: Cannot truncate a table referenced in a foreign key constraint (`test`.`t2`, CONSTRAINT `t2_ibfk_1`) +truncate t3; +ERROR 42000: Cannot truncate a table referenced in a foreign key constraint (`test`.`t4`, CONSTRAINT `t4_ibfk_1`) +truncate t2; +truncate t4; +truncate t1; +ERROR 42000: Cannot truncate a table referenced in a foreign key constraint (`test`.`t2`, CONSTRAINT `t2_ibfk_1`) +truncate t3; +ERROR 42000: Cannot truncate a table referenced in a foreign key constraint (`test`.`t4`, CONSTRAINT `t4_ibfk_1`) +drop table t4,t3,t2,t1; +SET sql_mode = 'NO_ENGINE_SUBSTITUTION'; +create table t1 (s1 varbinary(2),primary key (s1)) engine=innodb; +create table t2 (s1 binary(2),primary key (s1)) engine=innodb; +create table t3 (s1 varchar(2) binary,primary key (s1)) engine=innodb; +Warnings: +Warning 1287 'BINARY as attribute of a type' is deprecated and will be removed in a future release. Please use a CHARACTER SET clause with _bin collation instead +create table t4 (s1 char(2) binary,primary key (s1)) engine=innodb; +Warnings: +Warning 1287 'BINARY as attribute of a type' is deprecated and will be removed in a future release. Please use a CHARACTER SET clause with _bin collation instead +insert into t1 values (0x41),(0x4120),(0x4100); +insert into t2 values (0x41),(0x4120),(0x4100); +ERROR 23000: Duplicate entry 'A' for key 't2.PRIMARY' +insert into t2 values (0x41),(0x4120); +insert into t3 values (0x41),(0x4120),(0x4100); +ERROR 23000: Duplicate entry 'A ' for key 't3.PRIMARY' +insert into t3 values (0x41),(0x4100); +insert into t4 values (0x41),(0x4120),(0x4100); +ERROR 23000: Duplicate entry 'A' for key 't4.PRIMARY' +insert into t4 values (0x41),(0x4100); +select hex(s1) from t1; +hex(s1) +41 +4100 +4120 +select hex(s1) from t2; +hex(s1) +4100 +4120 +select hex(s1) from t3; +hex(s1) +4100 +41 +select hex(s1) from t4; +hex(s1) +4100 +41 +drop table t1,t2,t3,t4; +create table t1 (a int primary key,s1 varbinary(3) not null unique) engine=innodb; +create table t2 (s1 binary(2) not null, constraint c foreign key(s1) references t1(s1) on update cascade) engine=innodb; +insert into t1 values(1,0x4100),(2,0x41),(3,0x4120),(4,0x42); +insert into t2 values(0x42); +ERROR 23000: Cannot add or update a child row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `c` FOREIGN KEY (`s1`) REFERENCES `t1` (`s1`) ON UPDATE CASCADE) +insert into t2 values(0x41); +select hex(s1) from t2; +hex(s1) +4100 +update t1 set s1=0x123456 where a=2; +select hex(s1) from t2; +hex(s1) +4100 +update t1 set s1=0x12 where a=1; +ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `c` FOREIGN KEY (`s1`) REFERENCES `t1` (`s1`) ON UPDATE CASCADE) +update t1 set s1=0x12345678 where a=1; +ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `c` FOREIGN KEY (`s1`) REFERENCES `t1` (`s1`) ON UPDATE CASCADE) +update t1 set s1=0x123457 where a=1; +ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `c` FOREIGN KEY (`s1`) REFERENCES `t1` (`s1`) ON UPDATE CASCADE) +update t1 set s1=0x1220 where a=1; +select hex(s1) from t2; +hex(s1) +1220 +update t1 set s1=0x1200 where a=1; +select hex(s1) from t2; +hex(s1) +1200 +update t1 set s1=0x4200 where a=1; +select hex(s1) from t2; +hex(s1) +4200 +delete from t1 where a=1; +ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `c` FOREIGN KEY (`s1`) REFERENCES `t1` (`s1`) ON UPDATE CASCADE) +delete from t1 where a=2; +update t2 set s1=0x4120; +delete from t1; +ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `c` FOREIGN KEY (`s1`) REFERENCES `t1` (`s1`) ON UPDATE CASCADE) +delete from t1 where a!=3; +select a,hex(s1) from t1; +a hex(s1) +3 4120 +select hex(s1) from t2; +hex(s1) +4120 +drop table t2,t1; +create table t1 (a int primary key,s1 varchar(2) binary not null unique) engine=innodb; +Warnings: +Warning 1287 'BINARY as attribute of a type' is deprecated and will be removed in a future release. Please use a CHARACTER SET clause with _bin collation instead +create table t2 (s1 char(2) binary not null, constraint c foreign key(s1) references t1(s1) on update cascade) engine=innodb; +Warnings: +Warning 1287 'BINARY as attribute of a type' is deprecated and will be removed in a future release. Please use a CHARACTER SET clause with _bin collation instead +insert into t1 values(1,0x4100),(2,0x41); +insert into t2 values(0x41); +select hex(s1) from t2; +hex(s1) +41 +update t1 set s1=0x1234 where a=1; +select hex(s1) from t2; +hex(s1) +41 +update t1 set s1=0x12 where a=2; +select hex(s1) from t2; +hex(s1) +12 +delete from t1 where a=1; +delete from t1 where a=2; +ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `c` FOREIGN KEY (`s1`) REFERENCES `t1` (`s1`) ON UPDATE CASCADE) +select a,hex(s1) from t1; +a hex(s1) +2 12 +select hex(s1) from t2; +hex(s1) +12 +drop table t2,t1; +CREATE TABLE t1(a INT, PRIMARY KEY(a)) ENGINE=InnoDB; +CREATE TABLE t2(a INT) ENGINE=InnoDB; +ALTER TABLE t2 ADD FOREIGN KEY (a) REFERENCES t1(a); +ALTER TABLE t2 DROP FOREIGN KEY t2_ibfk_1; +ALTER TABLE t2 ADD CONSTRAINT t2_ibfk_0 FOREIGN KEY (a) REFERENCES t1(a); +ALTER TABLE t2 DROP FOREIGN KEY t2_ibfk_0; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `a` int DEFAULT NULL, + KEY `t2_ibfk_0` (`a`) +) /*!50100 TABLESPACE `innodb_system` */ ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +DROP TABLE t2,t1; +SET sql_mode = default; +CREATE TABLE t1 ( +field1 varchar(8) NOT NULL DEFAULT '', +field2 varchar(8) NOT NULL DEFAULT '', +PRIMARY KEY (field1, field2) +) ENGINE=InnoDB; +CREATE TABLE t2 ( +field1 varchar(8) NOT NULL DEFAULT '' PRIMARY KEY, +FOREIGN KEY (field1) REFERENCES t1 (field1) +ON DELETE CASCADE ON UPDATE CASCADE +) ENGINE=InnoDB; +INSERT INTO t1 VALUES ('old', 'somevalu'); +INSERT INTO t1 VALUES ('other', 'anyvalue'); +INSERT INTO t2 VALUES ('old'); +INSERT INTO t2 VALUES ('other'); +UPDATE t1 SET field1 = 'other' WHERE field2 = 'somevalu'; +ERROR 23000: Foreign key constraint for table 't1', record 'other-somevalu' would lead to a duplicate entry in table 't2', key 'PRIMARY' +DROP TABLE t2; +DROP TABLE t1; +create table t1 ( +c1 bigint not null, +c2 bigint not null, +primary key (c1), +unique key (c2) +) engine=innodb; +create table t2 ( +c1 bigint not null, +primary key (c1) +) engine=innodb; +alter table t1 add constraint c2_fk foreign key (c2) +references t2(c1) on delete cascade; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` bigint NOT NULL, + `c2` bigint NOT NULL, + PRIMARY KEY (`c1`), + UNIQUE KEY `c2` (`c2`), + CONSTRAINT `c2_fk` FOREIGN KEY (`c2`) REFERENCES `t2` (`c1`) ON DELETE CASCADE +) /*!50100 TABLESPACE `innodb_system` */ ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +alter table t1 drop foreign key c2_fk; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` bigint NOT NULL, + `c2` bigint NOT NULL, + PRIMARY KEY (`c1`), + UNIQUE KEY `c2` (`c2`) +) /*!50100 TABLESPACE `innodb_system` */ ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1, t2; +create table t1(a date) engine=innodb; +create table t2(a date, key(a)) engine=innodb; +insert into t1 values('2005-10-01'); +insert into t2 values('2005-10-01'); +select * from t1, t2 +where t2.a between t1.a - interval 2 day and t1.a + interval 2 day; +a a +2005-10-01 2005-10-01 +drop table t1, t2; +create table t1 (id int not null, f_id int not null, f int not null, +primary key(f_id, id)) engine=innodb; +create table t2 (id int not null,s_id int not null,s varchar(200), +primary key(id)) engine=innodb; +INSERT INTO t1 VALUES (8, 1, 3); +INSERT INTO t1 VALUES (1, 2, 1); +INSERT INTO t2 VALUES (1, 0, ''); +INSERT INTO t2 VALUES (8, 1, ''); +commit; +DELETE ml.* FROM t1 AS ml LEFT JOIN t2 AS mm ON (mm.id=ml.id) +WHERE mm.id IS NULL; +select ml.* from t1 as ml left join t2 as mm on (mm.id=ml.id) +where mm.id is null lock in share mode; +id f_id f +drop table t1,t2; +create table t1(a int not null, b int, primary key(a)) engine=innodb; +insert into t1 values(1,1),(2,2),(3,1),(4,2),(5,1),(6,2),(7,3); +commit; +SET binlog_format='MIXED'; +set autocommit = 0; +SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED; +update t1 set b = 5 where b = 1; +SET binlog_format='MIXED'; +set autocommit = 0; +SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED; +select * from t1 where a = 7 and b = 3 for update; +a b +7 3 +commit; +commit; +drop table t1; +create table t1(a int not null, b int, primary key(a)) engine=innodb; +insert into t1 values(1,1),(2,2),(3,1),(4,2),(5,1),(6,2); +commit; +set autocommit = 0; +select * from t1 lock in share mode; +a b +1 1 +2 2 +3 1 +4 2 +5 1 +6 2 +update t1 set b = 5 where b = 1; +set autocommit = 0; +select * from t1 where a = 2 and b = 2 for update; +ERROR HY000: Lock wait timeout exceeded; try restarting transaction +commit; +commit; +drop table t1; +create table t1(a int not null, b int, primary key(a)) engine=innodb; +insert into t1 values (1,2),(5,3),(4,2); +create table t2(d int not null, e int, primary key(d)) engine=innodb; +insert into t2 values (8,6),(12,1),(3,1); +commit; +set autocommit = 0; +select * from t2 for update; +d e +3 1 +8 6 +12 1 +SET binlog_format='MIXED'; +set autocommit = 0; +SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED; +insert into t1 select * from t2; +update t1 set b = (select e from t2 where a = d); +create table t3(d int not null, e int, primary key(d)) engine=innodb +select * from t2; +commit; +commit; +drop table t1, t2, t3; +create table t1(a int not null, b int, primary key(a)) engine=innodb; +insert into t1 values (1,2),(5,3),(4,2); +create table t2(a int not null, b int, primary key(a)) engine=innodb; +insert into t2 values (8,6),(12,1),(3,1); +create table t3(d int not null, b int, primary key(d)) engine=innodb; +insert into t3 values (8,6),(12,1),(3,1); +create table t5(a int not null, b int, primary key(a)) engine=innodb; +insert into t5 values (1,2),(5,3),(4,2); +create table t6(d int not null, e int, primary key(d)) engine=innodb; +insert into t6 values (8,6),(12,1),(3,1); +create table t8(a int not null, b int, primary key(a)) engine=innodb; +insert into t8 values (1,2),(5,3),(4,2); +create table t9(d int not null, e int, primary key(d)) engine=innodb; +insert into t9 values (8,6),(12,1),(3,1); +commit; +set autocommit = 0; +select * from t2 for update; +a b +3 1 +8 6 +12 1 +SET binlog_format='MIXED'; +set autocommit = 0; +SET SESSION TRANSACTION ISOLATION LEVEL SERIALIZABLE; +insert into t1 select * from t2; +SET binlog_format='MIXED'; +set autocommit = 0; +SET SESSION TRANSACTION ISOLATION LEVEL SERIALIZABLE; +update t3 set b = (select b from t2 where a = d); +SET binlog_format='MIXED'; +set autocommit = 0; +SET SESSION TRANSACTION ISOLATION LEVEL SERIALIZABLE; +create table t4(a int not null, b int, primary key(a)) engine=innodb select * from t2; +SET binlog_format='MIXED'; +set autocommit = 0; +SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED; +insert into t5 (select * from t2 lock in share mode); +SET binlog_format='MIXED'; +set autocommit = 0; +SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED; +update t6 set e = (select b from t2 where a = d lock in share mode); +SET binlog_format='MIXED'; +set autocommit = 0; +SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED; +create table t7(a int not null, b int, primary key(a)) engine=innodb select * from t2 lock in share mode; +SET binlog_format='MIXED'; +set autocommit = 0; +SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED; +insert into t8 (select * from t2 for update); +SET binlog_format='MIXED'; +set autocommit = 0; +SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED; +update t9 set e = (select b from t2 where a = d for update); +SET binlog_format='MIXED'; +set autocommit = 0; +SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED; +create table t10(a int not null, b int, primary key(a)) engine=innodb select * from t2 for update; +ERROR HY000: Lock wait timeout exceeded; try restarting transaction +ERROR HY000: Lock wait timeout exceeded; try restarting transaction +ERROR HY000: Lock wait timeout exceeded; try restarting transaction +ERROR HY000: Lock wait timeout exceeded; try restarting transaction +ERROR HY000: Lock wait timeout exceeded; try restarting transaction +ERROR HY000: Lock wait timeout exceeded; try restarting transaction +ERROR HY000: Lock wait timeout exceeded; try restarting transaction +ERROR HY000: Lock wait timeout exceeded; try restarting transaction +ERROR HY000: Can't update table 't2' while 't10' is being created. +commit; +drop table t1, t2, t3, t5, t6, t8, t9; +CREATE TABLE t1 (DB_ROW_ID int) engine=innodb; +ERROR 42000: Incorrect column name 'DB_ROW_ID' +CREATE TABLE t1 ( +a BIGINT(20) NOT NULL, +PRIMARY KEY (a) +) ENGINE=INNODB DEFAULT CHARSET=UTF8; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +CREATE TABLE t2 ( +a BIGINT(20) NOT NULL, +b VARCHAR(128) NOT NULL, +c TEXT NOT NULL, +PRIMARY KEY (a,b), +KEY idx_t2_b_c (b,c(100)), +CONSTRAINT t_fk FOREIGN KEY (a) REFERENCES t1 (a) +ON DELETE CASCADE +) ENGINE=INNODB DEFAULT CHARSET=UTF8; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES (1); +INSERT INTO t2 VALUES (1, 'bar', 'vbar'); +INSERT INTO t2 VALUES (1, 'BAR2', 'VBAR'); +INSERT INTO t2 VALUES (1, 'bar_bar', 'bibi'); +INSERT INTO t2 VALUES (1, 'customer_over', '1'); +SELECT * FROM t2 WHERE b = 'customer_over'; +a b c +1 customer_over 1 +SELECT * FROM t2 WHERE BINARY b = 'customer_over'; +a b c +1 customer_over 1 +SELECT DISTINCT p0.a FROM t2 p0 WHERE p0.b = 'customer_over'; +a +1 +/* Bang: Empty result set, above was expected: */ +SELECT DISTINCT p0.a FROM t2 p0 WHERE BINARY p0.b = 'customer_over'; +a +1 +SELECT p0.a FROM t2 p0 WHERE BINARY p0.b = 'customer_over'; +a +1 +drop table t2, t1; +CREATE TABLE t1 ( a int ) ENGINE=innodb; +BEGIN; +INSERT INTO t1 VALUES (1); +OPTIMIZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 optimize note Table does not support optimize, doing recreate + analyze instead +test.t1 optimize status OK +DROP TABLE t1; +CREATE TABLE t1 (id int PRIMARY KEY, f int NOT NULL, INDEX(f)) ENGINE=InnoDB; +CREATE TABLE t2 (id int PRIMARY KEY, f INT NOT NULL, +CONSTRAINT t2_t1 FOREIGN KEY (id) REFERENCES t1 (id) +ON DELETE CASCADE ON UPDATE CASCADE) ENGINE=InnoDB; +ALTER TABLE t2 ADD FOREIGN KEY (f) REFERENCES t1 (f) ON +DELETE CASCADE ON UPDATE CASCADE; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `id` int NOT NULL, + `f` int NOT NULL, + PRIMARY KEY (`id`), + KEY `f` (`f`), + CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`f`) REFERENCES `t1` (`f`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `t2_t1` FOREIGN KEY (`id`) REFERENCES `t1` (`id`) ON DELETE CASCADE ON UPDATE CASCADE +) /*!50100 TABLESPACE `innodb_system` */ ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +DROP TABLE t2, t1; +CREATE TABLE t1 (a INT, INDEX(a)) ENGINE=InnoDB; +CREATE TABLE t2 (a INT, INDEX(a)) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1); +INSERT INTO t2 VALUES (1); +ALTER TABLE t2 ADD FOREIGN KEY (a) REFERENCES t1 (a) ON DELETE SET NULL; +ALTER TABLE t2 MODIFY a INT NOT NULL; +ERROR HY000: Column 'a' cannot be NOT NULL: needed in a foreign key constraint 't2_ibfk_1' SET NULL +DELETE FROM t1; +DROP TABLE t2,t1; +CREATE TABLE t1 (a VARCHAR(5) COLLATE utf8_unicode_ci PRIMARY KEY) +ENGINE=InnoDB; +Warnings: +Warning 3778 'utf8_unicode_ci' is a collation of the deprecated character set UTF8MB3. Please consider using UTF8MB4 with an appropriate collation instead. +INSERT INTO t1 VALUES (0xEFBCA4EFBCA4EFBCA4); +DELETE FROM t1; +INSERT INTO t1 VALUES ('DDD'); +SELECT * FROM t1; +a +DDD +DROP TABLE t1; +CREATE TABLE t1 (id int PRIMARY KEY AUTO_INCREMENT) ENGINE=InnoDB +AUTO_INCREMENT=42; +INSERT INTO t1 VALUES (0),(347),(0); +SELECT * FROM t1; +id +42 +347 +348 +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `id` int NOT NULL AUTO_INCREMENT, + PRIMARY KEY (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=349 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +CREATE TABLE t2 (id int PRIMARY KEY) ENGINE=InnoDB; +INSERT INTO t2 VALUES(42),(347),(348); +ALTER TABLE t1 ADD CONSTRAINT t1_t2 FOREIGN KEY (id) REFERENCES t2(id); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `id` int NOT NULL AUTO_INCREMENT, + PRIMARY KEY (`id`), + CONSTRAINT `t1_t2` FOREIGN KEY (`id`) REFERENCES `t2` (`id`) +) /*!50100 TABLESPACE `innodb_system` */ ENGINE=InnoDB AUTO_INCREMENT=349 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +DROP TABLE t1,t2; +SET innodb_strict_mode=ON; +CREATE TABLE t1 ( +c01 CHAR(255), c02 CHAR(255), c03 CHAR(255), c04 CHAR(255), +c05 CHAR(255), c06 CHAR(255), c07 CHAR(255), c08 CHAR(255), +c09 CHAR(255), c10 CHAR(255), c11 CHAR(255), c12 CHAR(255), +c13 CHAR(255), c14 CHAR(255), c15 CHAR(255), c16 CHAR(255), +c17 CHAR(255), c18 CHAR(255), c19 CHAR(255), c20 CHAR(255), +c21 CHAR(255), c22 CHAR(255), c23 CHAR(255), c24 CHAR(255), +c25 CHAR(255), c26 CHAR(255), c27 CHAR(255), c28 CHAR(255), +c29 CHAR(255), c30 CHAR(255), c31 CHAR(255), c32 CHAR(255) +) charset latin1 ENGINE = InnoDB; +ERROR 42000: Row size too large (> {checked_valid}). Changing some columns to TEXT or BLOB may help. In current row format, BLOB prefix of 0 bytes is stored inline. +SET innodb_strict_mode=OFF; +DROP TABLE IF EXISTS t1; +Warnings: +Note 1051 Unknown table 'test.t1' +CREATE TABLE t1( +id BIGINT(20) NOT NULL AUTO_INCREMENT PRIMARY KEY +) ENGINE=InnoDB; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES(-10); +SELECT * FROM t1; +id +-10 +INSERT INTO t1 VALUES(NULL); +SELECT * FROM t1; +id +-10 +1 +DROP TABLE t1; +create table t1 (i int, j int) engine=innodb; +insert into t1 (i, j) values (1, 1), (2, 2); +update t1 set j = 2; +affected rows: 1 +info: Rows matched: 2 Changed: 1 Warnings: 0 +drop table t1; +create table t1 (id int) comment='this is a comment' engine=innodb; +analyze table t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +select table_comment, data_free > 0 as data_free_is_set +from information_schema.tables +where table_schema='test' and table_name = 't1'; +TABLE_COMMENT data_free_is_set +this is a comment 1 +drop table t1; +CREATE TABLE t1 ( +c1 INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, +c2 VARCHAR(128) NOT NULL, +PRIMARY KEY(c1) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=100; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +CREATE TABLE t2 ( +c1 INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, +c2 INT(10) UNSIGNED DEFAULT NULL, +PRIMARY KEY(c1) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=200; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +ANALYZE TABLE t2; +Table Op Msg_type Msg_text +test.t2 analyze status OK +SELECT AUTO_INCREMENT FROM INFORMATION_SCHEMA.TABLES WHERE table_name = 't2'; +AUTO_INCREMENT +200 +ALTER TABLE t2 ADD CONSTRAINT t1_t2_1 FOREIGN KEY(c1) REFERENCES t1(c1); +ANALYZE TABLE t2; +Table Op Msg_type Msg_text +test.t2 analyze status OK +SELECT AUTO_INCREMENT FROM INFORMATION_SCHEMA.TABLES WHERE table_name = 't2'; +AUTO_INCREMENT +200 +DROP TABLE t2; +DROP TABLE t1; +CREATE TABLE t1 (c1 int default NULL, +c2 int default NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1; +TRUNCATE TABLE t1; +affected rows: 0 +INSERT INTO t1 VALUES (1, 1), (2, 2), (3, 3), (4, 4), (5, 5); +affected rows: 5 +info: Records: 5 Duplicates: 0 Warnings: 0 +TRUNCATE TABLE t1; +affected rows: 0 +DROP TABLE t1; +Variable_name Value +Handler_update 10 +Variable_name Value +Handler_delete 0 +Variable_name Value +Handler_update 11 +Variable_name Value +Handler_delete 1 +DROP TABLE bug58912; +create table t1 (f1 integer primary key) engine=innodb; +flush status; +show status like "handler_read_key"; +Variable_name Value +Handler_read_key 0 +select f1 from t1; +f1 +show status like "handler_read_key"; +Variable_name Value +Handler_read_key 1 +drop table t1; +CREATE TABLE t1 (c1 INT) ENGINE=InnoDB; +CREATE TEMPORARY TABLE t2 (c1 INT) ENGINE=InnoDB; +START TRANSACTION READ ONLY; +INSERT INTO t2 VALUES(0); +INSERT INTO t1 VALUES(0); +ERROR 25006: Cannot execute statement in a READ ONLY transaction. +ROLLBACK; +SELECT * FROM t1; +c1 +SELECT * FROM t2; +c1 +START TRANSACTION READ ONLY; +INSERT INTO t1 VALUES(0); +ERROR 25006: Cannot execute statement in a READ ONLY transaction. +INSERT INTO t2 VALUES(1); +COMMIT; +SET TRANSACTION READ ONLY; +START TRANSACTION; +INSERT INTO t2 VALUES(3); +INSERT INTO t1 VALUES(0); +ERROR 25006: Cannot execute statement in a READ ONLY transaction. +COMMIT; +SELECT * FROM t1; +c1 +SELECT * FROM t2; +c1 +1 +3 +DROP TABLE t2; +CREATE TEMPORARY TABLE t2 ( +c1 INT AUTO_INCREMENT PRIMARY KEY, +c2 INT, INDEX idx(c2)) ENGINE=InnoDB; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TEMPORARY TABLE `t2` ( + `c1` int NOT NULL AUTO_INCREMENT, + `c2` int DEFAULT NULL, + PRIMARY KEY (`c1`), + KEY `idx` (`c2`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +START TRANSACTION READ ONLY; +INSERT INTO t2 VALUES(NULL,1),(NULL,2),(NULL,3); +INSERT INTO t1 VALUES(0); +ERROR 25006: Cannot execute statement in a READ ONLY transaction. +ROLLBACK; +SELECT * FROM t1; +c1 +SELECT * FROM t2; +c1 c2 +START TRANSACTION READ ONLY; +INSERT INTO t1 VALUES(0); +ERROR 25006: Cannot execute statement in a READ ONLY transaction. +INSERT INTO t2 VALUES(NULL,1),(NULL,2),(NULL,3); +COMMIT; +SET TRANSACTION READ ONLY; +START TRANSACTION; +INSERT INTO t2 VALUES(NULL,1),(NULL,2),(NULL,3); +INSERT INTO t1 VALUES(0); +ERROR 25006: Cannot execute statement in a READ ONLY transaction. +COMMIT; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TEMPORARY TABLE `t2` ( + `c1` int NOT NULL AUTO_INCREMENT, + `c2` int DEFAULT NULL, + PRIMARY KEY (`c1`), + KEY `idx` (`c2`) +) ENGINE=InnoDB AUTO_INCREMENT=10 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SELECT * FROM t1; +c1 +SELECT * FROM t2; +c1 c2 +4 1 +5 2 +6 3 +7 1 +8 2 +9 3 +DROP TABLE t1; +DROP TABLE t2; +count_alloc WHERE event_name like 'memory/innodb/other' +count_alloc +0 +SET @old_log_bin_trust_function_creators= @@global.log_bin_trust_function_creators; +SET GLOBAL log_bin_trust_function_creators = 1; +create table t1 (col1 integer primary key, col2 integer) engine=innodb; +insert t1 values (1,100); +create function f1 () returns integer begin +declare var1 int; +select col2 into var1 from t1 where col1=1 for update; +return var1; +end| +start transaction; +select f1(); +f1() +100 +update t1 set col2=0 where col1=1; +select * from t1; +col1 col2 +1 100 +rollback; +rollback; +drop table t1; +drop function f1; +SET @@global.log_bin_trust_function_creators= @old_log_bin_trust_function_creators; diff --git a/mysql-test/suite/innodb_bug30423.result-pq b/mysql-test/suite/innodb_bug30423.result-pq new file mode 100644 index 000000000000..7144f9daa72f --- /dev/null +++ b/mysql-test/suite/innodb_bug30423.result-pq @@ -0,0 +1,103 @@ +set global innodb_stats_method = default; +select @@innodb_stats_method; +@@innodb_stats_method +nulls_equal +select count(*) from bug30243_3 where org_id is not NULL; +count(*) +20 +select count(*) from bug30243_3 where org_id is NULL; +count(*) +16384 +select count(*) from bug30243_2 where org_id is not NULL; +count(*) +224 +select count(*) from bug30243_2 where org_id is NULL; +count(*) +65536 +select @@innodb_stats_method; +@@innodb_stats_method +nulls_equal +analyze table bug30243_1; +Table Op Msg_type Msg_text +test.bug30243_1 analyze status OK +analyze table bug30243_2; +Table Op Msg_type Msg_text +test.bug30243_2 analyze status OK +analyze table bug30243_3; +Table Op Msg_type Msg_text +test.bug30243_3 analyze status OK +set global innodb_stats_method = "NULL"; +ERROR 42000: Variable 'innodb_stats_method' can't be set to the value of 'NULL' +set global innodb_stats_method = "nulls_ignored"; +select @@innodb_stats_method; +@@innodb_stats_method +nulls_ignored +analyze table bug30243_1; +Table Op Msg_type Msg_text +test.bug30243_1 analyze status OK +analyze table bug30243_2; +Table Op Msg_type Msg_text +test.bug30243_2 analyze status OK +analyze table bug30243_3; +Table Op Msg_type Msg_text +test.bug30243_3 analyze status OK +explain SELECT COUNT(*), 0 +FROM bug30243_1 orgs +LEFT JOIN bug30243_3 sa_opportunities +ON orgs.org_id=sa_opportunities.org_id +LEFT JOIN bug30243_2 contacts +ON orgs.org_id=contacts.org_id ; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL ROWS 100.00 Parallel execute (1 workers) +2 SIMPLE orgs NULL index NULL org_id 4 NULL ROWS 100.00 Using index +2 SIMPLE sa_opportunities NULL ref org_id org_id 5 test.orgs.org_id ROWS 100.00 Using index +2 SIMPLE contacts NULL ref contacts$org_id contacts$org_id 5 test.orgs.org_id ROWS 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)`,0 AS `0` from `test`.`bug30243_1` `orgs` left join `test`.`bug30243_3` `sa_opportunities` on((`test`.`sa_opportunities`.`org_id` = `test`.`orgs`.`org_id`)) left join `test`.`bug30243_2` `contacts` on((`test`.`contacts`.`org_id` = `test`.`orgs`.`org_id`)) where true +select @@innodb_stats_method; +@@innodb_stats_method +nulls_ignored +set global innodb_stats_method = "nulls_unequal"; +select @@innodb_stats_method; +@@innodb_stats_method +nulls_unequal +analyze table bug30243_1; +Table Op Msg_type Msg_text +test.bug30243_1 analyze status OK +analyze table bug30243_2; +Table Op Msg_type Msg_text +test.bug30243_2 analyze status OK +analyze table bug30243_3; +Table Op Msg_type Msg_text +test.bug30243_3 analyze status OK +explain SELECT COUNT(*), 0 +FROM bug30243_1 orgs +LEFT JOIN bug30243_3 sa_opportunities +ON orgs.org_id=sa_opportunities.org_id +LEFT JOIN bug30243_2 contacts +ON orgs.org_id=contacts.org_id; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL ROWS 100.00 Parallel execute (1 workers) +2 SIMPLE orgs NULL index NULL org_id 4 NULL ROWS 100.00 Using index +2 SIMPLE sa_opportunities NULL ref org_id org_id 5 test.orgs.org_id ROWS 100.00 Using index +2 SIMPLE contacts NULL ref contacts$org_id contacts$org_id 5 test.orgs.org_id ROWS 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)`,0 AS `0` from `test`.`bug30243_1` `orgs` left join `test`.`bug30243_3` `sa_opportunities` on((`test`.`sa_opportunities`.`org_id` = `test`.`orgs`.`org_id`)) left join `test`.`bug30243_2` `contacts` on((`test`.`contacts`.`org_id` = `test`.`orgs`.`org_id`)) where true +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +SELECT COUNT(*) FROM table_bug30423 WHERE org_id IS NULL; +COUNT(*) +1024 +set global innodb_stats_method = "nulls_unequal"; +analyze table table_bug30423; +Table Op Msg_type Msg_text +test.table_bug30423 analyze status OK +set global innodb_stats_method = "nulls_ignored"; +analyze table table_bug30423; +Table Op Msg_type Msg_text +test.table_bug30423 analyze status OK +set global innodb_stats_method = nulls_equal; +drop table bug30243_2; +drop table bug30243_1; +drop table bug30243_3; +drop table table_bug30423; diff --git a/mysql-test/suite/innodb_bulk_create_index.result-pq b/mysql-test/suite/innodb_bulk_create_index.result-pq new file mode 100644 index 000000000000..b5b318fdb9f3 --- /dev/null +++ b/mysql-test/suite/innodb_bulk_create_index.result-pq @@ -0,0 +1,1073 @@ +CREATE PROCEDURE populate_t1(load_even INT) +BEGIN +DECLARE i int DEFAULT 1; +START TRANSACTION; +WHILE (i <= 10000) DO +IF i%2 = 0 AND load_even = 1 THEN +INSERT INTO t1 VALUES (i, i, CONCAT('a', i)); +END IF; +IF i%2 != 0 AND load_even != 1 THEN +INSERT INTO t1 VALUES (i, i, CONCAT('a', i)); +END IF; +SET i = i + 1; +END WHILE; +COMMIT; +END| +SELECT @@innodb_fill_factor; +@@innodb_fill_factor +100 +CREATE TABLE t1( +class INT, +id INT, +title VARCHAR(100) +) ENGINE=InnoDB ROW_FORMAT=REDUNDANT; +SELECT COUNT(*) FROM t1; +COUNT(*) +5000 +/* Create index. */ +CREATE INDEX idx_id ON t1(id); +CREATE INDEX idx_title ON t1(title); +/* Check table. */ +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +/* Select by index. */ +EXPLAIN SELECT * FROM t1 WHERE id = 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref idx_id idx_id 5 const 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`class` AS `class`,`test`.`t1`.`id` AS `id`,`test`.`t1`.`title` AS `title` from `test`.`t1` where (`test`.`t1`.`id` = 10) +EXPLAIN SELECT * FROM t1 WHERE title = 'a10'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref idx_title idx_title 403 const 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`class` AS `class`,`test`.`t1`.`id` AS `id`,`test`.`t1`.`title` AS `title` from `test`.`t1` where (`test`.`t1`.`title` = 'a10') +SELECT * FROM t1 WHERE id = 10; +class id title +10 10 a10 +SELECT * FROM t1 WHERE title = 'a10'; +class id title +10 10 a10 +SELECT * FROM t1 WHERE id = 5000; +class id title +5000 5000 a5000 +SELECT * FROM t1 WHERE title = 'a5000'; +class id title +5000 5000 a5000 +SELECT * FROM t1 WHERE id = 10000; +class id title +10000 10000 a10000 +SELECT * FROM t1 WHERE title = 'a10000'; +class id title +10000 10000 a10000 +SELECT * FROM t1 WHERE id = 10010; +class id title +SELECT * FROM t1 WHERE title = 'a10010'; +class id title +/*Insert/Update/Delete. */ +DELETE FROM t1 WHERE id < 4010 AND id > 3990; +INSERT INTO t1 VALUES(4000, 4000, 'b4000'); +UPDATE t1 SET title = CONCAT('b', id) WHERE id < 3010 AND id > 2990; +SELECT * FROM t1 WHERE id = 3000; +class id title +3000 3000 b3000 +SELECT * FROM t1 WHERE title = 'a3000'; +class id title +SELECT * FROM t1 WHERE title = 'b3000'; +class id title +3000 3000 b3000 +SELECT * FROM t1 WHERE id = 4000; +class id title +4000 4000 b4000 +SELECT * FROM t1 WHERE title = 'a4000'; +class id title +SELECT * FROM t1 WHERE title = 'b4000'; +class id title +4000 4000 b4000 +SELECT * FROM t1 WHERE id = 4001; +class id title +SELECT * FROM t1 WHERE title = 'a4001'; +class id title +SELECT COUNT(*) FROM t1; +COUNT(*) +9992 +/* Add column. */ +ALTER TABLE t1 ADD COLUMN content TEXT; +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT * FROM t1 WHERE id = 10; +class id title content +10 10 a10 NULL +SELECT * FROM t1 WHERE title = 'a10'; +class id title content +10 10 a10 NULL +SELECT * FROM t1 WHERE id = 5000; +class id title content +5000 5000 a5000 NULL +SELECT * FROM t1 WHERE title = 'a5000'; +class id title content +5000 5000 a5000 NULL +SELECT * FROM t1 WHERE id = 10000; +class id title content +10000 10000 a10000 NULL +SELECT * FROM t1 WHERE title = 'a10000'; +class id title content +10000 10000 a10000 NULL +SELECT * FROM t1 WHERE id = 10010; +class id title content +SELECT * FROM t1 WHERE title = 'a10010'; +class id title content +/* Drop column. */ +ALTER TABLE t1 DROP COLUMN content; +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT * FROM t1 WHERE id = 10; +class id title +10 10 a10 +SELECT * FROM t1 WHERE title = 'a10'; +class id title +10 10 a10 +SELECT * FROM t1 WHERE id = 5000; +class id title +5000 5000 a5000 +SELECT * FROM t1 WHERE title = 'a5000'; +class id title +5000 5000 a5000 +SELECT * FROM t1 WHERE id = 10000; +class id title +10000 10000 a10000 +SELECT * FROM t1 WHERE title = 'a10000'; +class id title +10000 10000 a10000 +SELECT * FROM t1 WHERE id = 10010; +class id title +SELECT * FROM t1 WHERE title = 'a10010'; +class id title +DROP TABLE t1; +CREATE TABLE t1( +a INT PRIMARY KEY, +b TEXT, +c TEXT) ENGINE=InnoDB ROW_FORMAT=REDUNDANT; +ALTER TABLE t1 ADD INDEX `idx` (a,b(5)); +SELECT CHAR_LENGTH(b) FROM t1 WHERE a=4975; +CHAR_LENGTH(b) +10000 +SELECT b=REPEAT(CONCAT('a',4975),2000) FROM t1 WHERE a=4975 AND b like 'a4975%'; +b=REPEAT(CONCAT('a',4975),2000) +1 +UPDATE t1 SET b = REPEAT(CONCAT('b',4975),2000) WHERE a=4975 AND b like 'a4975%'; +SELECT b=REPEAT(CONCAT('a',4975),2000) FROM t1 WHERE a=4975 AND b like 'a4975%'; +b=REPEAT(CONCAT('a',4975),2000) +SELECT b=REPEAT(CONCAT('b',4975),2000) FROM t1 WHERE a=4975 AND b like 'b4975%'; +b=REPEAT(CONCAT('b',4975),2000) +1 +DELETE FROM t1 WHERE a=4975 AND b like 'b4975%'; +SELECT b=REPEAT(CONCAT('b',4975),2000) FROM t1 WHERE a=4975 AND b like 'b4975%'; +b=REPEAT(CONCAT('b',4975),2000) +ALTER TABLE t1 DROP COLUMN c; +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT CHAR_LENGTH(b) FROM t1 WHERE a=4975; +CHAR_LENGTH(b) +DROP TABLE t1; +DROP PROCEDURE populate_t1; +CREATE PROCEDURE populate_t1(load_even INT) +BEGIN +DECLARE i int DEFAULT 1; +START TRANSACTION; +WHILE (i <= 10000) DO +IF i%2 = 0 AND load_even = 1 THEN +INSERT INTO t1 VALUES (i, i, CONCAT('a', i)); +END IF; +IF i%2 != 0 AND load_even != 1 THEN +INSERT INTO t1 VALUES (i, i, CONCAT('a', i)); +END IF; +SET i = i + 1; +END WHILE; +COMMIT; +END| +SELECT @@innodb_fill_factor; +@@innodb_fill_factor +100 +CREATE TABLE t1( +class INT, +id INT, +title VARCHAR(100) +) ENGINE=InnoDB ROW_FORMAT=COMPACT; +SELECT COUNT(*) FROM t1; +COUNT(*) +5000 +/* Create index. */ +CREATE INDEX idx_id ON t1(id); +CREATE INDEX idx_title ON t1(title); +/* Check table. */ +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +/* Select by index. */ +EXPLAIN SELECT * FROM t1 WHERE id = 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref idx_id idx_id 5 const 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`class` AS `class`,`test`.`t1`.`id` AS `id`,`test`.`t1`.`title` AS `title` from `test`.`t1` where (`test`.`t1`.`id` = 10) +EXPLAIN SELECT * FROM t1 WHERE title = 'a10'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref idx_title idx_title 403 const 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`class` AS `class`,`test`.`t1`.`id` AS `id`,`test`.`t1`.`title` AS `title` from `test`.`t1` where (`test`.`t1`.`title` = 'a10') +SELECT * FROM t1 WHERE id = 10; +class id title +10 10 a10 +SELECT * FROM t1 WHERE title = 'a10'; +class id title +10 10 a10 +SELECT * FROM t1 WHERE id = 5000; +class id title +5000 5000 a5000 +SELECT * FROM t1 WHERE title = 'a5000'; +class id title +5000 5000 a5000 +SELECT * FROM t1 WHERE id = 10000; +class id title +10000 10000 a10000 +SELECT * FROM t1 WHERE title = 'a10000'; +class id title +10000 10000 a10000 +SELECT * FROM t1 WHERE id = 10010; +class id title +SELECT * FROM t1 WHERE title = 'a10010'; +class id title +/*Insert/Update/Delete. */ +DELETE FROM t1 WHERE id < 4010 AND id > 3990; +INSERT INTO t1 VALUES(4000, 4000, 'b4000'); +UPDATE t1 SET title = CONCAT('b', id) WHERE id < 3010 AND id > 2990; +SELECT * FROM t1 WHERE id = 3000; +class id title +3000 3000 b3000 +SELECT * FROM t1 WHERE title = 'a3000'; +class id title +SELECT * FROM t1 WHERE title = 'b3000'; +class id title +3000 3000 b3000 +SELECT * FROM t1 WHERE id = 4000; +class id title +4000 4000 b4000 +SELECT * FROM t1 WHERE title = 'a4000'; +class id title +SELECT * FROM t1 WHERE title = 'b4000'; +class id title +4000 4000 b4000 +SELECT * FROM t1 WHERE id = 4001; +class id title +SELECT * FROM t1 WHERE title = 'a4001'; +class id title +SELECT COUNT(*) FROM t1; +COUNT(*) +9992 +/* Add column. */ +ALTER TABLE t1 ADD COLUMN content TEXT; +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT * FROM t1 WHERE id = 10; +class id title content +10 10 a10 NULL +SELECT * FROM t1 WHERE title = 'a10'; +class id title content +10 10 a10 NULL +SELECT * FROM t1 WHERE id = 5000; +class id title content +5000 5000 a5000 NULL +SELECT * FROM t1 WHERE title = 'a5000'; +class id title content +5000 5000 a5000 NULL +SELECT * FROM t1 WHERE id = 10000; +class id title content +10000 10000 a10000 NULL +SELECT * FROM t1 WHERE title = 'a10000'; +class id title content +10000 10000 a10000 NULL +SELECT * FROM t1 WHERE id = 10010; +class id title content +SELECT * FROM t1 WHERE title = 'a10010'; +class id title content +/* Drop column. */ +ALTER TABLE t1 DROP COLUMN content; +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT * FROM t1 WHERE id = 10; +class id title +10 10 a10 +SELECT * FROM t1 WHERE title = 'a10'; +class id title +10 10 a10 +SELECT * FROM t1 WHERE id = 5000; +class id title +5000 5000 a5000 +SELECT * FROM t1 WHERE title = 'a5000'; +class id title +5000 5000 a5000 +SELECT * FROM t1 WHERE id = 10000; +class id title +10000 10000 a10000 +SELECT * FROM t1 WHERE title = 'a10000'; +class id title +10000 10000 a10000 +SELECT * FROM t1 WHERE id = 10010; +class id title +SELECT * FROM t1 WHERE title = 'a10010'; +class id title +DROP TABLE t1; +CREATE TABLE t1( +a INT PRIMARY KEY, +b TEXT, +c TEXT) ENGINE=InnoDB ROW_FORMAT=COMPACT; +ALTER TABLE t1 ADD INDEX `idx` (a,b(5)); +SELECT CHAR_LENGTH(b) FROM t1 WHERE a=4975; +CHAR_LENGTH(b) +10000 +SELECT b=REPEAT(CONCAT('a',4975),2000) FROM t1 WHERE a=4975 AND b like 'a4975%'; +b=REPEAT(CONCAT('a',4975),2000) +1 +UPDATE t1 SET b = REPEAT(CONCAT('b',4975),2000) WHERE a=4975 AND b like 'a4975%'; +SELECT b=REPEAT(CONCAT('a',4975),2000) FROM t1 WHERE a=4975 AND b like 'a4975%'; +b=REPEAT(CONCAT('a',4975),2000) +SELECT b=REPEAT(CONCAT('b',4975),2000) FROM t1 WHERE a=4975 AND b like 'b4975%'; +b=REPEAT(CONCAT('b',4975),2000) +1 +DELETE FROM t1 WHERE a=4975 AND b like 'b4975%'; +SELECT b=REPEAT(CONCAT('b',4975),2000) FROM t1 WHERE a=4975 AND b like 'b4975%'; +b=REPEAT(CONCAT('b',4975),2000) +ALTER TABLE t1 DROP COLUMN c; +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT CHAR_LENGTH(b) FROM t1 WHERE a=4975; +CHAR_LENGTH(b) +DROP TABLE t1; +DROP PROCEDURE populate_t1; +CREATE PROCEDURE populate_t1(load_even INT) +BEGIN +DECLARE i int DEFAULT 1; +START TRANSACTION; +WHILE (i <= 10000) DO +IF i%2 = 0 AND load_even = 1 THEN +INSERT INTO t1 VALUES (i, i, CONCAT('a', i)); +END IF; +IF i%2 != 0 AND load_even != 1 THEN +INSERT INTO t1 VALUES (i, i, CONCAT('a', i)); +END IF; +SET i = i + 1; +END WHILE; +COMMIT; +END| +SELECT @@innodb_fill_factor; +@@innodb_fill_factor +100 +CREATE TABLE t1( +class INT, +id INT, +title VARCHAR(100) +) ENGINE=InnoDB ROW_FORMAT=DYNAMIC; +SELECT COUNT(*) FROM t1; +COUNT(*) +5000 +/* Create index. */ +CREATE INDEX idx_id ON t1(id); +CREATE INDEX idx_title ON t1(title); +/* Check table. */ +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +/* Select by index. */ +EXPLAIN SELECT * FROM t1 WHERE id = 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref idx_id idx_id 5 const 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`class` AS `class`,`test`.`t1`.`id` AS `id`,`test`.`t1`.`title` AS `title` from `test`.`t1` where (`test`.`t1`.`id` = 10) +EXPLAIN SELECT * FROM t1 WHERE title = 'a10'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref idx_title idx_title 403 const 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`class` AS `class`,`test`.`t1`.`id` AS `id`,`test`.`t1`.`title` AS `title` from `test`.`t1` where (`test`.`t1`.`title` = 'a10') +SELECT * FROM t1 WHERE id = 10; +class id title +10 10 a10 +SELECT * FROM t1 WHERE title = 'a10'; +class id title +10 10 a10 +SELECT * FROM t1 WHERE id = 5000; +class id title +5000 5000 a5000 +SELECT * FROM t1 WHERE title = 'a5000'; +class id title +5000 5000 a5000 +SELECT * FROM t1 WHERE id = 10000; +class id title +10000 10000 a10000 +SELECT * FROM t1 WHERE title = 'a10000'; +class id title +10000 10000 a10000 +SELECT * FROM t1 WHERE id = 10010; +class id title +SELECT * FROM t1 WHERE title = 'a10010'; +class id title +/*Insert/Update/Delete. */ +DELETE FROM t1 WHERE id < 4010 AND id > 3990; +INSERT INTO t1 VALUES(4000, 4000, 'b4000'); +UPDATE t1 SET title = CONCAT('b', id) WHERE id < 3010 AND id > 2990; +SELECT * FROM t1 WHERE id = 3000; +class id title +3000 3000 b3000 +SELECT * FROM t1 WHERE title = 'a3000'; +class id title +SELECT * FROM t1 WHERE title = 'b3000'; +class id title +3000 3000 b3000 +SELECT * FROM t1 WHERE id = 4000; +class id title +4000 4000 b4000 +SELECT * FROM t1 WHERE title = 'a4000'; +class id title +SELECT * FROM t1 WHERE title = 'b4000'; +class id title +4000 4000 b4000 +SELECT * FROM t1 WHERE id = 4001; +class id title +SELECT * FROM t1 WHERE title = 'a4001'; +class id title +SELECT COUNT(*) FROM t1; +COUNT(*) +9992 +/* Add column. */ +ALTER TABLE t1 ADD COLUMN content TEXT; +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT * FROM t1 WHERE id = 10; +class id title content +10 10 a10 NULL +SELECT * FROM t1 WHERE title = 'a10'; +class id title content +10 10 a10 NULL +SELECT * FROM t1 WHERE id = 5000; +class id title content +5000 5000 a5000 NULL +SELECT * FROM t1 WHERE title = 'a5000'; +class id title content +5000 5000 a5000 NULL +SELECT * FROM t1 WHERE id = 10000; +class id title content +10000 10000 a10000 NULL +SELECT * FROM t1 WHERE title = 'a10000'; +class id title content +10000 10000 a10000 NULL +SELECT * FROM t1 WHERE id = 10010; +class id title content +SELECT * FROM t1 WHERE title = 'a10010'; +class id title content +/* Drop column. */ +ALTER TABLE t1 DROP COLUMN content; +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT * FROM t1 WHERE id = 10; +class id title +10 10 a10 +SELECT * FROM t1 WHERE title = 'a10'; +class id title +10 10 a10 +SELECT * FROM t1 WHERE id = 5000; +class id title +5000 5000 a5000 +SELECT * FROM t1 WHERE title = 'a5000'; +class id title +5000 5000 a5000 +SELECT * FROM t1 WHERE id = 10000; +class id title +10000 10000 a10000 +SELECT * FROM t1 WHERE title = 'a10000'; +class id title +10000 10000 a10000 +SELECT * FROM t1 WHERE id = 10010; +class id title +SELECT * FROM t1 WHERE title = 'a10010'; +class id title +DROP TABLE t1; +CREATE TABLE t1( +a INT PRIMARY KEY, +b TEXT, +c TEXT) ENGINE=InnoDB ROW_FORMAT=DYNAMIC; +ALTER TABLE t1 ADD INDEX `idx` (a,b(5)); +SELECT CHAR_LENGTH(b) FROM t1 WHERE a=4975; +CHAR_LENGTH(b) +10000 +SELECT b=REPEAT(CONCAT('a',4975),2000) FROM t1 WHERE a=4975 AND b like 'a4975%'; +b=REPEAT(CONCAT('a',4975),2000) +1 +UPDATE t1 SET b = REPEAT(CONCAT('b',4975),2000) WHERE a=4975 AND b like 'a4975%'; +SELECT b=REPEAT(CONCAT('a',4975),2000) FROM t1 WHERE a=4975 AND b like 'a4975%'; +b=REPEAT(CONCAT('a',4975),2000) +SELECT b=REPEAT(CONCAT('b',4975),2000) FROM t1 WHERE a=4975 AND b like 'b4975%'; +b=REPEAT(CONCAT('b',4975),2000) +1 +DELETE FROM t1 WHERE a=4975 AND b like 'b4975%'; +SELECT b=REPEAT(CONCAT('b',4975),2000) FROM t1 WHERE a=4975 AND b like 'b4975%'; +b=REPEAT(CONCAT('b',4975),2000) +ALTER TABLE t1 DROP COLUMN c; +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT CHAR_LENGTH(b) FROM t1 WHERE a=4975; +CHAR_LENGTH(b) +DROP TABLE t1; +DROP PROCEDURE populate_t1; +CREATE PROCEDURE populate_t1(load_even INT) +BEGIN +DECLARE i int DEFAULT 1; +START TRANSACTION; +WHILE (i <= 10000) DO +IF i%2 = 0 AND load_even = 1 THEN +INSERT INTO t1 VALUES (i, i, CONCAT('a', i)); +END IF; +IF i%2 != 0 AND load_even != 1 THEN +INSERT INTO t1 VALUES (i, i, CONCAT('a', i)); +END IF; +SET i = i + 1; +END WHILE; +COMMIT; +END| +SELECT @@innodb_fill_factor; +@@innodb_fill_factor +100 +SET GLOBAL innodb_file_per_table=1; +CREATE TABLE t1( +class INT, +id INT, +title VARCHAR(100) +) ENGINE=InnoDB ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=4; +SELECT COUNT(*) FROM t1; +COUNT(*) +5000 +/* Create index. */ +CREATE INDEX idx_id ON t1(id); +CREATE INDEX idx_title ON t1(title); +/* Check table. */ +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +/* Select by index. */ +EXPLAIN SELECT * FROM t1 WHERE id = 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref idx_id idx_id 5 const 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`class` AS `class`,`test`.`t1`.`id` AS `id`,`test`.`t1`.`title` AS `title` from `test`.`t1` where (`test`.`t1`.`id` = 10) +EXPLAIN SELECT * FROM t1 WHERE title = 'a10'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref idx_title idx_title 403 const 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`class` AS `class`,`test`.`t1`.`id` AS `id`,`test`.`t1`.`title` AS `title` from `test`.`t1` where (`test`.`t1`.`title` = 'a10') +SELECT * FROM t1 WHERE id = 10; +class id title +10 10 a10 +SELECT * FROM t1 WHERE title = 'a10'; +class id title +10 10 a10 +SELECT * FROM t1 WHERE id = 5000; +class id title +5000 5000 a5000 +SELECT * FROM t1 WHERE title = 'a5000'; +class id title +5000 5000 a5000 +SELECT * FROM t1 WHERE id = 10000; +class id title +10000 10000 a10000 +SELECT * FROM t1 WHERE title = 'a10000'; +class id title +10000 10000 a10000 +SELECT * FROM t1 WHERE id = 10010; +class id title +SELECT * FROM t1 WHERE title = 'a10010'; +class id title +/*Insert/Update/Delete. */ +DELETE FROM t1 WHERE id < 4010 AND id > 3990; +INSERT INTO t1 VALUES(4000, 4000, 'b4000'); +UPDATE t1 SET title = CONCAT('b', id) WHERE id < 3010 AND id > 2990; +SELECT * FROM t1 WHERE id = 3000; +class id title +3000 3000 b3000 +SELECT * FROM t1 WHERE title = 'a3000'; +class id title +SELECT * FROM t1 WHERE title = 'b3000'; +class id title +3000 3000 b3000 +SELECT * FROM t1 WHERE id = 4000; +class id title +4000 4000 b4000 +SELECT * FROM t1 WHERE title = 'a4000'; +class id title +SELECT * FROM t1 WHERE title = 'b4000'; +class id title +4000 4000 b4000 +SELECT * FROM t1 WHERE id = 4001; +class id title +SELECT * FROM t1 WHERE title = 'a4001'; +class id title +SELECT COUNT(*) FROM t1; +COUNT(*) +9992 +/* Add column. */ +ALTER TABLE t1 ADD COLUMN content TEXT; +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT * FROM t1 WHERE id = 10; +class id title content +10 10 a10 NULL +SELECT * FROM t1 WHERE title = 'a10'; +class id title content +10 10 a10 NULL +SELECT * FROM t1 WHERE id = 5000; +class id title content +5000 5000 a5000 NULL +SELECT * FROM t1 WHERE title = 'a5000'; +class id title content +5000 5000 a5000 NULL +SELECT * FROM t1 WHERE id = 10000; +class id title content +10000 10000 a10000 NULL +SELECT * FROM t1 WHERE title = 'a10000'; +class id title content +10000 10000 a10000 NULL +SELECT * FROM t1 WHERE id = 10010; +class id title content +SELECT * FROM t1 WHERE title = 'a10010'; +class id title content +/* Drop column. */ +ALTER TABLE t1 DROP COLUMN content; +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT * FROM t1 WHERE id = 10; +class id title +10 10 a10 +SELECT * FROM t1 WHERE title = 'a10'; +class id title +10 10 a10 +SELECT * FROM t1 WHERE id = 5000; +class id title +5000 5000 a5000 +SELECT * FROM t1 WHERE title = 'a5000'; +class id title +5000 5000 a5000 +SELECT * FROM t1 WHERE id = 10000; +class id title +10000 10000 a10000 +SELECT * FROM t1 WHERE title = 'a10000'; +class id title +10000 10000 a10000 +SELECT * FROM t1 WHERE id = 10010; +class id title +SELECT * FROM t1 WHERE title = 'a10010'; +class id title +DROP TABLE t1; +CREATE TABLE t1( +a INT PRIMARY KEY, +b BLOB, +c TEXT) ENGINE=InnoDB ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=4; +ALTER TABLE t1 ADD INDEX `idx` (a,b(5)); +SELECT CHAR_LENGTH(b) FROM t1 WHERE a=4975; +CHAR_LENGTH(b) +10000 +SELECT b=REPEAT(CONCAT('a',4975),2000) FROM t1 WHERE a=4975 AND b like 'a4975%'; +b=REPEAT(CONCAT('a',4975),2000) +1 +UPDATE t1 SET b = REPEAT(CONCAT('b',4975),2000) WHERE a=4975 AND b like 'a4975%'; +SELECT b=REPEAT(CONCAT('a',4975),2000) FROM t1 WHERE a=4975 AND b like 'a4975%'; +b=REPEAT(CONCAT('a',4975),2000) +SELECT b=REPEAT(CONCAT('b',4975),2000) FROM t1 WHERE a=4975 AND b like 'b4975%'; +b=REPEAT(CONCAT('b',4975),2000) +1 +DELETE FROM t1 WHERE a=4975 AND b like 'b4975%'; +SELECT b=REPEAT(CONCAT('b',4975),2000) FROM t1 WHERE a=4975 AND b like 'b4975%'; +b=REPEAT(CONCAT('b',4975),2000) +ALTER TABLE t1 DROP COLUMN c; +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT CHAR_LENGTH(b) FROM t1 WHERE a=4975; +CHAR_LENGTH(b) +DROP TABLE t1; +SET GLOBAL innodb_file_per_table=default; +DROP PROCEDURE populate_t1; +SET GLOBAL innodb_fill_factor=10; +CREATE PROCEDURE populate_t1(load_even INT) +BEGIN +DECLARE i int DEFAULT 1; +START TRANSACTION; +WHILE (i <= 10000) DO +IF i%2 = 0 AND load_even = 1 THEN +INSERT INTO t1 VALUES (i, i, CONCAT('a', i)); +END IF; +IF i%2 != 0 AND load_even != 1 THEN +INSERT INTO t1 VALUES (i, i, CONCAT('a', i)); +END IF; +SET i = i + 1; +END WHILE; +COMMIT; +END| +SELECT @@innodb_fill_factor; +@@innodb_fill_factor +10 +CREATE TABLE t1( +class INT, +id INT, +title VARCHAR(100) +) ENGINE=InnoDB ROW_FORMAT=COMPACT; +SELECT COUNT(*) FROM t1; +COUNT(*) +5000 +/* Create index. */ +CREATE INDEX idx_id ON t1(id); +CREATE INDEX idx_title ON t1(title); +/* Check table. */ +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +/* Select by index. */ +EXPLAIN SELECT * FROM t1 WHERE id = 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref idx_id idx_id 5 const 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`class` AS `class`,`test`.`t1`.`id` AS `id`,`test`.`t1`.`title` AS `title` from `test`.`t1` where (`test`.`t1`.`id` = 10) +EXPLAIN SELECT * FROM t1 WHERE title = 'a10'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref idx_title idx_title 403 const 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`class` AS `class`,`test`.`t1`.`id` AS `id`,`test`.`t1`.`title` AS `title` from `test`.`t1` where (`test`.`t1`.`title` = 'a10') +SELECT * FROM t1 WHERE id = 10; +class id title +10 10 a10 +SELECT * FROM t1 WHERE title = 'a10'; +class id title +10 10 a10 +SELECT * FROM t1 WHERE id = 5000; +class id title +5000 5000 a5000 +SELECT * FROM t1 WHERE title = 'a5000'; +class id title +5000 5000 a5000 +SELECT * FROM t1 WHERE id = 10000; +class id title +10000 10000 a10000 +SELECT * FROM t1 WHERE title = 'a10000'; +class id title +10000 10000 a10000 +SELECT * FROM t1 WHERE id = 10010; +class id title +SELECT * FROM t1 WHERE title = 'a10010'; +class id title +/*Insert/Update/Delete. */ +DELETE FROM t1 WHERE id < 4010 AND id > 3990; +INSERT INTO t1 VALUES(4000, 4000, 'b4000'); +UPDATE t1 SET title = CONCAT('b', id) WHERE id < 3010 AND id > 2990; +SELECT * FROM t1 WHERE id = 3000; +class id title +3000 3000 b3000 +SELECT * FROM t1 WHERE title = 'a3000'; +class id title +SELECT * FROM t1 WHERE title = 'b3000'; +class id title +3000 3000 b3000 +SELECT * FROM t1 WHERE id = 4000; +class id title +4000 4000 b4000 +SELECT * FROM t1 WHERE title = 'a4000'; +class id title +SELECT * FROM t1 WHERE title = 'b4000'; +class id title +4000 4000 b4000 +SELECT * FROM t1 WHERE id = 4001; +class id title +SELECT * FROM t1 WHERE title = 'a4001'; +class id title +SELECT COUNT(*) FROM t1; +COUNT(*) +9992 +/* Add column. */ +ALTER TABLE t1 ADD COLUMN content TEXT; +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT * FROM t1 WHERE id = 10; +class id title content +10 10 a10 NULL +SELECT * FROM t1 WHERE title = 'a10'; +class id title content +10 10 a10 NULL +SELECT * FROM t1 WHERE id = 5000; +class id title content +5000 5000 a5000 NULL +SELECT * FROM t1 WHERE title = 'a5000'; +class id title content +5000 5000 a5000 NULL +SELECT * FROM t1 WHERE id = 10000; +class id title content +10000 10000 a10000 NULL +SELECT * FROM t1 WHERE title = 'a10000'; +class id title content +10000 10000 a10000 NULL +SELECT * FROM t1 WHERE id = 10010; +class id title content +SELECT * FROM t1 WHERE title = 'a10010'; +class id title content +/* Drop column. */ +ALTER TABLE t1 DROP COLUMN content; +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT * FROM t1 WHERE id = 10; +class id title +10 10 a10 +SELECT * FROM t1 WHERE title = 'a10'; +class id title +10 10 a10 +SELECT * FROM t1 WHERE id = 5000; +class id title +5000 5000 a5000 +SELECT * FROM t1 WHERE title = 'a5000'; +class id title +5000 5000 a5000 +SELECT * FROM t1 WHERE id = 10000; +class id title +10000 10000 a10000 +SELECT * FROM t1 WHERE title = 'a10000'; +class id title +10000 10000 a10000 +SELECT * FROM t1 WHERE id = 10010; +class id title +SELECT * FROM t1 WHERE title = 'a10010'; +class id title +DROP TABLE t1; +CREATE TABLE t1( +a INT PRIMARY KEY, +b TEXT, +c TEXT) ENGINE=InnoDB ROW_FORMAT=COMPACT; +ALTER TABLE t1 ADD INDEX `idx` (a,b(5)); +SELECT CHAR_LENGTH(b) FROM t1 WHERE a=4975; +CHAR_LENGTH(b) +10000 +SELECT b=REPEAT(CONCAT('a',4975),2000) FROM t1 WHERE a=4975 AND b like 'a4975%'; +b=REPEAT(CONCAT('a',4975),2000) +1 +UPDATE t1 SET b = REPEAT(CONCAT('b',4975),2000) WHERE a=4975 AND b like 'a4975%'; +SELECT b=REPEAT(CONCAT('a',4975),2000) FROM t1 WHERE a=4975 AND b like 'a4975%'; +b=REPEAT(CONCAT('a',4975),2000) +SELECT b=REPEAT(CONCAT('b',4975),2000) FROM t1 WHERE a=4975 AND b like 'b4975%'; +b=REPEAT(CONCAT('b',4975),2000) +1 +DELETE FROM t1 WHERE a=4975 AND b like 'b4975%'; +SELECT b=REPEAT(CONCAT('b',4975),2000) FROM t1 WHERE a=4975 AND b like 'b4975%'; +b=REPEAT(CONCAT('b',4975),2000) +ALTER TABLE t1 DROP COLUMN c; +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT CHAR_LENGTH(b) FROM t1 WHERE a=4975; +CHAR_LENGTH(b) +DROP TABLE t1; +DROP PROCEDURE populate_t1; +SET GLOBAL innodb_fill_factor=50; +CREATE PROCEDURE populate_t1(load_even INT) +BEGIN +DECLARE i int DEFAULT 1; +START TRANSACTION; +WHILE (i <= 10000) DO +IF i%2 = 0 AND load_even = 1 THEN +INSERT INTO t1 VALUES (i, i, CONCAT('a', i)); +END IF; +IF i%2 != 0 AND load_even != 1 THEN +INSERT INTO t1 VALUES (i, i, CONCAT('a', i)); +END IF; +SET i = i + 1; +END WHILE; +COMMIT; +END| +SELECT @@innodb_fill_factor; +@@innodb_fill_factor +50 +CREATE TABLE t1( +class INT, +id INT, +title VARCHAR(100) +) ENGINE=InnoDB ROW_FORMAT=COMPACT; +SELECT COUNT(*) FROM t1; +COUNT(*) +5000 +/* Create index. */ +CREATE INDEX idx_id ON t1(id); +CREATE INDEX idx_title ON t1(title); +/* Check table. */ +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +/* Select by index. */ +EXPLAIN SELECT * FROM t1 WHERE id = 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref idx_id idx_id 5 const 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`class` AS `class`,`test`.`t1`.`id` AS `id`,`test`.`t1`.`title` AS `title` from `test`.`t1` where (`test`.`t1`.`id` = 10) +EXPLAIN SELECT * FROM t1 WHERE title = 'a10'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref idx_title idx_title 403 const 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`class` AS `class`,`test`.`t1`.`id` AS `id`,`test`.`t1`.`title` AS `title` from `test`.`t1` where (`test`.`t1`.`title` = 'a10') +SELECT * FROM t1 WHERE id = 10; +class id title +10 10 a10 +SELECT * FROM t1 WHERE title = 'a10'; +class id title +10 10 a10 +SELECT * FROM t1 WHERE id = 5000; +class id title +5000 5000 a5000 +SELECT * FROM t1 WHERE title = 'a5000'; +class id title +5000 5000 a5000 +SELECT * FROM t1 WHERE id = 10000; +class id title +10000 10000 a10000 +SELECT * FROM t1 WHERE title = 'a10000'; +class id title +10000 10000 a10000 +SELECT * FROM t1 WHERE id = 10010; +class id title +SELECT * FROM t1 WHERE title = 'a10010'; +class id title +/*Insert/Update/Delete. */ +DELETE FROM t1 WHERE id < 4010 AND id > 3990; +INSERT INTO t1 VALUES(4000, 4000, 'b4000'); +UPDATE t1 SET title = CONCAT('b', id) WHERE id < 3010 AND id > 2990; +SELECT * FROM t1 WHERE id = 3000; +class id title +3000 3000 b3000 +SELECT * FROM t1 WHERE title = 'a3000'; +class id title +SELECT * FROM t1 WHERE title = 'b3000'; +class id title +3000 3000 b3000 +SELECT * FROM t1 WHERE id = 4000; +class id title +4000 4000 b4000 +SELECT * FROM t1 WHERE title = 'a4000'; +class id title +SELECT * FROM t1 WHERE title = 'b4000'; +class id title +4000 4000 b4000 +SELECT * FROM t1 WHERE id = 4001; +class id title +SELECT * FROM t1 WHERE title = 'a4001'; +class id title +SELECT COUNT(*) FROM t1; +COUNT(*) +9992 +/* Add column. */ +ALTER TABLE t1 ADD COLUMN content TEXT; +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT * FROM t1 WHERE id = 10; +class id title content +10 10 a10 NULL +SELECT * FROM t1 WHERE title = 'a10'; +class id title content +10 10 a10 NULL +SELECT * FROM t1 WHERE id = 5000; +class id title content +5000 5000 a5000 NULL +SELECT * FROM t1 WHERE title = 'a5000'; +class id title content +5000 5000 a5000 NULL +SELECT * FROM t1 WHERE id = 10000; +class id title content +10000 10000 a10000 NULL +SELECT * FROM t1 WHERE title = 'a10000'; +class id title content +10000 10000 a10000 NULL +SELECT * FROM t1 WHERE id = 10010; +class id title content +SELECT * FROM t1 WHERE title = 'a10010'; +class id title content +/* Drop column. */ +ALTER TABLE t1 DROP COLUMN content; +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT * FROM t1 WHERE id = 10; +class id title +10 10 a10 +SELECT * FROM t1 WHERE title = 'a10'; +class id title +10 10 a10 +SELECT * FROM t1 WHERE id = 5000; +class id title +5000 5000 a5000 +SELECT * FROM t1 WHERE title = 'a5000'; +class id title +5000 5000 a5000 +SELECT * FROM t1 WHERE id = 10000; +class id title +10000 10000 a10000 +SELECT * FROM t1 WHERE title = 'a10000'; +class id title +10000 10000 a10000 +SELECT * FROM t1 WHERE id = 10010; +class id title +SELECT * FROM t1 WHERE title = 'a10010'; +class id title +DROP TABLE t1; +CREATE TABLE t1( +a INT PRIMARY KEY, +b TEXT, +c TEXT) ENGINE=InnoDB ROW_FORMAT=COMPACT; +ALTER TABLE t1 ADD INDEX `idx` (a,b(5)); +SELECT CHAR_LENGTH(b) FROM t1 WHERE a=4975; +CHAR_LENGTH(b) +10000 +SELECT b=REPEAT(CONCAT('a',4975),2000) FROM t1 WHERE a=4975 AND b like 'a4975%'; +b=REPEAT(CONCAT('a',4975),2000) +1 +UPDATE t1 SET b = REPEAT(CONCAT('b',4975),2000) WHERE a=4975 AND b like 'a4975%'; +SELECT b=REPEAT(CONCAT('a',4975),2000) FROM t1 WHERE a=4975 AND b like 'a4975%'; +b=REPEAT(CONCAT('a',4975),2000) +SELECT b=REPEAT(CONCAT('b',4975),2000) FROM t1 WHERE a=4975 AND b like 'b4975%'; +b=REPEAT(CONCAT('b',4975),2000) +1 +DELETE FROM t1 WHERE a=4975 AND b like 'b4975%'; +SELECT b=REPEAT(CONCAT('b',4975),2000) FROM t1 WHERE a=4975 AND b like 'b4975%'; +b=REPEAT(CONCAT('b',4975),2000) +ALTER TABLE t1 DROP COLUMN c; +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT CHAR_LENGTH(b) FROM t1 WHERE a=4975; +CHAR_LENGTH(b) +DROP TABLE t1; +DROP PROCEDURE populate_t1; +SET GLOBAL innodb_fill_factor=default; diff --git a/mysql-test/suite/innodb_bulk_create_index_replication.result-pq b/mysql-test/suite/innodb_bulk_create_index_replication.result-pq new file mode 100644 index 000000000000..b5c4242f36d0 --- /dev/null +++ b/mysql-test/suite/innodb_bulk_create_index_replication.result-pq @@ -0,0 +1,228 @@ +include/master-slave.inc +Warnings: +Note #### Sending passwords in plain text without SSL/TLS is extremely insecure. +Note #### Storing MySQL user name or password information in the master info repository is not secure and is therefore not recommended. Please consider using the USER and PASSWORD connection options for START SLAVE; see the 'START SLAVE Syntax' in the MySQL Manual for more information. +[connection master] +CREATE PROCEDURE populate_t1(load_even INT) +BEGIN +DECLARE i int DEFAULT 1; +START TRANSACTION; +WHILE (i <= 100) DO +IF i%2 = 0 AND load_even = 1 THEN +INSERT INTO t1 VALUES (i, i, CONCAT('a', i)); +END IF; +IF i%2 != 0 AND load_even != 1 THEN +INSERT INTO t1 VALUES (i, i, CONCAT('a', i)); +END IF; +SET i = i + 1; +END WHILE; +COMMIT; +END| +CREATE TABLE t1( +class INT, +id INT, +title VARCHAR(100) +) charset latin1 ENGINE=InnoDB ; +SELECT COUNT(*) FROM t1; +COUNT(*) +50 +/* Create index. */ +CREATE INDEX idx_id ON t1(id); +CREATE INDEX idx_title ON t1(title); +/* Select by index. */ +EXPLAIN SELECT * FROM t1 WHERE id = 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref idx_id idx_id 5 const 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`class` AS `class`,`test`.`t1`.`id` AS `id`,`test`.`t1`.`title` AS `title` from `test`.`t1` where (`test`.`t1`.`id` = 10) +EXPLAIN SELECT * FROM t1 WHERE title = 'a10'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref idx_title idx_title 103 const 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`class` AS `class`,`test`.`t1`.`id` AS `id`,`test`.`t1`.`title` AS `title` from `test`.`t1` where (`test`.`t1`.`title` = 'a10') +SELECT * FROM t1 WHERE id = 10; +class id title +10 10 a10 +SELECT * FROM t1 WHERE title = 'a10'; +class id title +10 10 a10 +SELECT * FROM t1 WHERE id = 20; +class id title +20 20 a20 +SELECT * FROM t1 WHERE title = 'a20'; +class id title +20 20 a20 +SELECT * FROM t1 WHERE id = 30; +class id title +30 30 a30 +SELECT * FROM t1 WHERE title = 'a30'; +class id title +30 30 a30 +SELECT * FROM t1 WHERE id = 101; +class id title +SELECT * FROM t1 WHERE title = 'a101'; +class id title +/*Insert/Update/Delete. */ +DELETE FROM t1 WHERE id < 40 AND id > 30; +INSERT INTO t1 VALUES(38, 38, 'b38'); +UPDATE t1 SET title = CONCAT('b', id) WHERE id < 30 AND id > 20; +SELECT * FROM t1 WHERE id = 28; +class id title +28 28 b28 +SELECT * FROM t1 WHERE title = 'a28'; +class id title +SELECT * FROM t1 WHERE title = 'b28'; +class id title +28 28 b28 +SELECT * FROM t1 WHERE id = 38; +class id title +38 38 b38 +SELECT * FROM t1 WHERE title = 'a38'; +class id title +SELECT * FROM t1 WHERE title = 'b38'; +class id title +38 38 b38 +SELECT * FROM t1 WHERE id = 101; +class id title +SELECT * FROM t1 WHERE title = 'a101'; +class id title +SELECT COUNT(*) FROM t1; +COUNT(*) +97 +SELECT * FROM t1 WHERE id = 10; +class id title +10 10 a10 +SELECT * FROM t1 WHERE title = 'a10'; +class id title +10 10 a10 +SELECT * FROM t1 WHERE id = 20; +class id title +20 20 a20 +SELECT * FROM t1 WHERE title = 'a20'; +class id title +20 20 a20 +SELECT * FROM t1 WHERE id = 30; +class id title +30 30 a30 +SELECT * FROM t1 WHERE title = 'a30'; +class id title +30 30 a30 +SELECT * FROM t1 WHERE id = 101; +class id title +SELECT * FROM t1 WHERE title = 'a101'; +class id title +CREATE TABLE t_part ( +class INT , +id INT , +title VARCHAR(30) +) charset latin1 ENGINE=InnoDB +PARTITION BY RANGE(id) +SUBPARTITION BY KEY(id) +SUBPARTITIONS 4 +( +PARTITION p0 VALUES LESS THAN (5000), +PARTITION p1 VALUES LESS THAN (MAXVALUE) +); +INSERT INTO t_part SELECT * FROM t1; +ALTER TABLE t_part ADD INDEX `idx` (class,id,title(10)); +SELECT * FROM t_part WHERE id = 10; +class id title +10 10 a10 +SELECT * FROM t_part WHERE title = 'a10'; +class id title +10 10 a10 +SELECT * FROM t_part WHERE id = 20; +class id title +20 20 a20 +SELECT * FROM t_part WHERE title = 'a20'; +class id title +20 20 a20 +SELECT * FROM t_part WHERE id = 30; +class id title +30 30 a30 +SELECT * FROM t_part WHERE title = 'a30'; +class id title +30 30 a30 +SELECT * FROM t_part WHERE id = 101; +class id title +SELECT * FROM t_part WHERE title = 'a101'; +class id title +include/sync_slave_sql_with_master.inc +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `class` int DEFAULT NULL, + `id` int DEFAULT NULL, + `title` varchar(100) DEFAULT NULL, + KEY `idx_id` (`id`), + KEY `idx_title` (`title`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +SHOW CREATE TABLE t_part; +Table Create Table +t_part CREATE TABLE `t_part` ( + `class` int DEFAULT NULL, + `id` int DEFAULT NULL, + `title` varchar(30) DEFAULT NULL, + KEY `idx` (`class`,`id`,`title`(10)) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +/*!50100 PARTITION BY RANGE (`id`) +SUBPARTITION BY KEY (id) +SUBPARTITIONS 4 +(PARTITION p0 VALUES LESS THAN (5000) ENGINE = InnoDB, + PARTITION p1 VALUES LESS THAN MAXVALUE ENGINE = InnoDB) */ +SELECT COUNT(*) FROM t1; +COUNT(*) +97 +SELECT COUNT(*) FROM t_part; +COUNT(*) +97 +SELECT * FROM t1 WHERE id = 10; +class id title +10 10 a10 +SELECT * FROM t1 WHERE title = 'a10'; +class id title +10 10 a10 +SELECT * FROM t1 WHERE id = 20; +class id title +20 20 a20 +SELECT * FROM t1 WHERE title = 'a20'; +class id title +20 20 a20 +SELECT * FROM t1 WHERE id = 30; +class id title +30 30 a30 +SELECT * FROM t1 WHERE title = 'a30'; +class id title +30 30 a30 +SELECT * FROM t1 WHERE id = 101; +class id title +SELECT * FROM t1 WHERE title = 'a101'; +class id title +SELECT * FROM t_part WHERE id = 10; +class id title +10 10 a10 +SELECT * FROM t_part WHERE title = 'a10'; +class id title +10 10 a10 +SELECT * FROM t_part WHERE id = 20; +class id title +20 20 a20 +SELECT * FROM t_part WHERE title = 'a20'; +class id title +20 20 a20 +SELECT * FROM t_part WHERE id = 30; +class id title +30 30 a30 +SELECT * FROM t_part WHERE title = 'a30'; +class id title +30 30 a30 +SELECT * FROM t_part WHERE id = 101; +class id title +SELECT * FROM t_part WHERE title = 'a101'; +class id title +DROP PROCEDURE populate_t1; +DROP TABLE t1; +DROP TABLE t_part; +include/rpl_end.inc diff --git a/mysql-test/suite/innodb_bulk_create_index_small.result-pq b/mysql-test/suite/innodb_bulk_create_index_small.result-pq new file mode 100644 index 000000000000..9f50903dd914 --- /dev/null +++ b/mysql-test/suite/innodb_bulk_create_index_small.result-pq @@ -0,0 +1,151 @@ +CREATE PROCEDURE populate_t1() +BEGIN +DECLARE i int DEFAULT 1; +START TRANSACTION; +WHILE (i <= 1000) DO +INSERT INTO t1 VALUES (i, i, CONCAT('a', i)); +SET i = i + 1; +END WHILE; +COMMIT; +END| +SELECT @@innodb_fill_factor; +@@innodb_fill_factor +100 +CREATE TABLE t1( +class INT, +id INT, +title VARCHAR(100) +) ENGINE=InnoDB ROW_FORMAT=COMPACT; +SELECT COUNT(*) FROM t1; +COUNT(*) +1000 +/* Create index. */ +CREATE INDEX idx_id ON t1(id); +CREATE INDEX idx_title ON t1(title); +/* Check table. */ +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +/* Select by index. */ +EXPLAIN SELECT * FROM t1 WHERE id = 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref idx_id idx_id 5 const 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`class` AS `class`,`test`.`t1`.`id` AS `id`,`test`.`t1`.`title` AS `title` from `test`.`t1` where (`test`.`t1`.`id` = 10) +EXPLAIN SELECT * FROM t1 WHERE title = 'a10'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref idx_title idx_title 403 const 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`class` AS `class`,`test`.`t1`.`id` AS `id`,`test`.`t1`.`title` AS `title` from `test`.`t1` where (`test`.`t1`.`title` = 'a10') +SELECT * FROM t1 WHERE id = 10; +class id title +10 10 a10 +SELECT * FROM t1 WHERE title = 'a10'; +class id title +10 10 a10 +SELECT * FROM t1 WHERE id = 500; +class id title +500 500 a500 +SELECT * FROM t1 WHERE title = 'a500'; +class id title +500 500 a500 +SELECT * FROM t1 WHERE id = 1000; +class id title +1000 1000 a1000 +SELECT * FROM t1 WHERE title = 'a1000'; +class id title +1000 1000 a1000 +SELECT * FROM t1 WHERE id = 1010; +class id title +SELECT * FROM t1 WHERE title = 'a1010'; +class id title +DROP TABLE t1; +CREATE TABLE t1( +a INT PRIMARY KEY, +b TEXT, +c TEXT) ENGINE=InnoDB ROW_FORMAT=COMPACT; +INSERT INTO t1 VALUES +(1, REPEAT('a',10000), 'a'), +(2, REPEAT('b',20000), 'b'), +(3, REPEAT('c',40000), 'c'), +(4, REPEAT('d',60000), 'd'); +ALTER TABLE t1 DROP COLUMN c; +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT CHAR_LENGTH(b) FROM t1 WHERE a=4975; +CHAR_LENGTH(b) +DROP TABLE t1; +SET GLOBAL innodb_file_per_table=default; +SET GLOBAL innodb_file_per_table=1; +CREATE TABLE t1( +class INT, +id INT, +title VARCHAR(100) +) ENGINE=InnoDB ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=4; +SELECT COUNT(*) FROM t1; +COUNT(*) +1000 +/* Create index. */ +CREATE INDEX idx_id ON t1(id); +CREATE INDEX idx_title ON t1(title); +/* Check table. */ +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +/* Select by index. */ +EXPLAIN SELECT * FROM t1 WHERE id = 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref idx_id idx_id 5 const 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`class` AS `class`,`test`.`t1`.`id` AS `id`,`test`.`t1`.`title` AS `title` from `test`.`t1` where (`test`.`t1`.`id` = 10) +EXPLAIN SELECT * FROM t1 WHERE title = 'a10'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref idx_title idx_title 403 const 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`class` AS `class`,`test`.`t1`.`id` AS `id`,`test`.`t1`.`title` AS `title` from `test`.`t1` where (`test`.`t1`.`title` = 'a10') +SELECT * FROM t1 WHERE id = 10; +class id title +10 10 a10 +SELECT * FROM t1 WHERE title = 'a10'; +class id title +10 10 a10 +SELECT * FROM t1 WHERE id = 500; +class id title +500 500 a500 +SELECT * FROM t1 WHERE title = 'a500'; +class id title +500 500 a500 +SELECT * FROM t1 WHERE id = 1000; +class id title +1000 1000 a1000 +SELECT * FROM t1 WHERE title = 'a1000'; +class id title +1000 1000 a1000 +SELECT * FROM t1 WHERE id = 1010; +class id title +SELECT * FROM t1 WHERE title = 'a1010'; +class id title +DROP TABLE t1; +CREATE TABLE t1( +a INT PRIMARY KEY, +b TEXT, +c TEXT) ENGINE=InnoDB ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=4; +INSERT INTO t1 VALUES +(1, REPEAT('a',10000), 'a'), +(2, REPEAT('b',20000), 'b'), +(3, REPEAT('c',40000), 'c'), +(4, REPEAT('d',60000), 'd'); +ALTER TABLE t1 DROP COLUMN c; +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT CHAR_LENGTH(b) FROM t1 WHERE a=4975; +CHAR_LENGTH(b) +DROP TABLE t1; +SET GLOBAL innodb_file_per_table=default; +DROP PROCEDURE populate_t1; diff --git a/mysql-test/suite/innodb_monitor_disable_basic.result-pq b/mysql-test/suite/innodb_monitor_disable_basic.result-pq new file mode 100644 index 000000000000..7aa8e2f12992 --- /dev/null +++ b/mysql-test/suite/innodb_monitor_disable_basic.result-pq @@ -0,0 +1,686 @@ +set global innodb_monitor_disable = All; +select name, status from information_schema.innodb_metrics; +name status +metadata_table_handles_opened disabled +metadata_table_handles_closed disabled +metadata_table_reference_count disabled +lock_deadlocks disabled +lock_deadlock_false_positives disabled +lock_deadlock_rounds disabled +lock_threads_waiting disabled +lock_timeouts disabled +lock_rec_lock_waits disabled +lock_table_lock_waits disabled +lock_rec_lock_requests disabled +lock_rec_release_attempts disabled +lock_rec_grant_attempts disabled +lock_rec_lock_created disabled +lock_rec_lock_removed disabled +lock_rec_locks disabled +lock_table_lock_created disabled +lock_table_lock_removed disabled +lock_table_locks disabled +lock_row_lock_current_waits disabled +lock_row_lock_time disabled +lock_row_lock_time_max disabled +lock_row_lock_waits disabled +lock_row_lock_time_avg disabled +lock_schedule_refreshes disabled +buffer_pool_size disabled +buffer_pool_reads disabled +buffer_pool_read_requests disabled +buffer_pool_write_requests disabled +buffer_pool_wait_free disabled +buffer_pool_read_ahead disabled +buffer_pool_read_ahead_evicted disabled +buffer_pool_pages_total disabled +buffer_pool_pages_misc disabled +buffer_pool_pages_data disabled +buffer_pool_bytes_data disabled +buffer_pool_pages_dirty disabled +buffer_pool_bytes_dirty disabled +buffer_pool_pages_free disabled +buffer_pages_created disabled +buffer_pages_written disabled +buffer_pages_read disabled +buffer_data_reads disabled +buffer_data_written disabled +buffer_flush_batch_scanned disabled +buffer_flush_batch_num_scan disabled +buffer_flush_batch_scanned_per_call disabled +buffer_flush_batch_total_pages disabled +buffer_flush_batches disabled +buffer_flush_batch_pages disabled +buffer_flush_neighbor_total_pages disabled +buffer_flush_neighbor disabled +buffer_flush_neighbor_pages disabled +buffer_flush_n_to_flush_requested disabled +buffer_flush_n_to_flush_by_dirty_page disabled +buffer_flush_n_to_flush_by_age disabled +buffer_flush_adaptive_avg_time_slot disabled +buffer_LRU_batch_flush_avg_time_slot disabled +buffer_flush_adaptive_avg_time_thread disabled +buffer_LRU_batch_flush_avg_time_thread disabled +buffer_flush_adaptive_avg_time_est disabled +buffer_LRU_batch_flush_avg_time_est disabled +buffer_flush_avg_time disabled +buffer_flush_adaptive_avg_pass disabled +buffer_LRU_batch_flush_avg_pass disabled +buffer_flush_avg_pass disabled +buffer_LRU_get_free_loops disabled +buffer_LRU_get_free_waits disabled +buffer_flush_avg_page_rate disabled +buffer_flush_lsn_avg_rate disabled +buffer_flush_pct_for_dirty disabled +buffer_flush_pct_for_lsn disabled +buffer_flush_sync_waits disabled +buffer_flush_adaptive_total_pages disabled +buffer_flush_adaptive disabled +buffer_flush_adaptive_pages disabled +buffer_flush_sync_total_pages disabled +buffer_flush_sync disabled +buffer_flush_sync_pages disabled +buffer_flush_background_total_pages disabled +buffer_flush_background disabled +buffer_flush_background_pages disabled +buffer_LRU_batch_scanned disabled +buffer_LRU_batch_num_scan disabled +buffer_LRU_batch_scanned_per_call disabled +buffer_LRU_batch_flush_total_pages disabled +buffer_LRU_batches_flush disabled +buffer_LRU_batch_flush_pages disabled +buffer_LRU_batch_evict_total_pages disabled +buffer_LRU_batches_evict disabled +buffer_LRU_batch_evict_pages disabled +buffer_LRU_single_flush_scanned disabled +buffer_LRU_single_flush_num_scan disabled +buffer_LRU_single_flush_scanned_per_call disabled +buffer_LRU_single_flush_failure_count disabled +buffer_LRU_get_free_search disabled +buffer_LRU_search_scanned disabled +buffer_LRU_search_num_scan disabled +buffer_LRU_search_scanned_per_call disabled +buffer_LRU_unzip_search_scanned disabled +buffer_LRU_unzip_search_num_scan disabled +buffer_LRU_unzip_search_scanned_per_call disabled +buffer_page_read_index_leaf disabled +buffer_page_read_index_non_leaf disabled +buffer_page_read_index_ibuf_leaf disabled +buffer_page_read_index_ibuf_non_leaf disabled +buffer_page_read_undo_log disabled +buffer_page_read_index_inode disabled +buffer_page_read_ibuf_free_list disabled +buffer_page_read_ibuf_bitmap disabled +buffer_page_read_system_page disabled +buffer_page_read_trx_system disabled +buffer_page_read_fsp_hdr disabled +buffer_page_read_xdes disabled +buffer_page_read_blob disabled +buffer_page_read_zblob disabled +buffer_page_read_zblob2 disabled +buffer_page_read_rseg_array disabled +buffer_page_read_other disabled +buffer_page_written_index_leaf disabled +buffer_page_written_index_non_leaf disabled +buffer_page_written_index_ibuf_leaf disabled +buffer_page_written_index_ibuf_non_leaf disabled +buffer_page_written_undo_log disabled +buffer_page_written_index_inode disabled +buffer_page_written_ibuf_free_list disabled +buffer_page_written_ibuf_bitmap disabled +buffer_page_written_system_page disabled +buffer_page_written_trx_system disabled +buffer_page_written_fsp_hdr disabled +buffer_page_written_xdes disabled +buffer_page_written_blob disabled +buffer_page_written_zblob disabled +buffer_page_written_zblob2 disabled +buffer_page_written_rseg_array disabled +buffer_page_written_other disabled +buffer_page_written_on_log_no_waits disabled +buffer_page_written_on_log_waits disabled +buffer_page_written_on_log_wait_loops disabled +os_data_reads disabled +os_data_writes disabled +os_data_fsyncs disabled +os_pending_reads disabled +os_pending_writes disabled +os_log_bytes_written disabled +os_log_fsyncs disabled +os_log_pending_fsyncs disabled +os_log_pending_writes disabled +trx_rw_commits disabled +trx_ro_commits disabled +trx_nl_ro_commits disabled +trx_commits_insert_update disabled +trx_rollbacks disabled +trx_rollbacks_savepoint disabled +trx_rollback_active disabled +trx_active_transactions disabled +trx_allocations disabled +trx_on_log_no_waits disabled +trx_on_log_waits disabled +trx_on_log_wait_loops disabled +trx_rseg_history_len disabled +trx_undo_slots_used disabled +trx_undo_slots_cached disabled +trx_rseg_current_size disabled +purge_del_mark_records disabled +purge_upd_exist_or_extern_records disabled +purge_invoked disabled +purge_undo_log_pages disabled +purge_dml_delay_usec disabled +purge_stop_count disabled +purge_resume_count disabled +purge_truncate_history_count disabled +purge_truncate_history_usec disabled +undo_truncate_count disabled +undo_truncate_start_logging_count disabled +undo_truncate_done_logging_count disabled +undo_truncate_usec disabled +log_lsn_last_flush disabled +log_lsn_last_checkpoint disabled +log_lsn_current disabled +log_lsn_archived disabled +log_lsn_checkpoint_age disabled +log_lsn_buf_dirty_pages_added disabled +log_lsn_buf_pool_oldest_approx disabled +log_lsn_buf_pool_oldest_lwm disabled +log_max_modified_age_async disabled +log_max_modified_age_sync disabled +log_waits disabled +log_write_requests disabled +log_writes disabled +log_flush_total_time disabled +log_flush_max_time disabled +log_flush_avg_time disabled +log_flush_lsn_avg_rate disabled +log_full_block_writes disabled +log_partial_block_writes disabled +log_padded disabled +log_next_file disabled +log_checkpoints disabled +log_free_space disabled +log_concurrency_margin disabled +log_writer_no_waits disabled +log_writer_waits disabled +log_writer_wait_loops disabled +log_writer_on_file_space_waits disabled +log_writer_on_archiver_waits disabled +log_flusher_no_waits disabled +log_flusher_waits disabled +log_flusher_wait_loops disabled +log_write_notifier_no_waits disabled +log_write_notifier_waits disabled +log_write_notifier_wait_loops disabled +log_flush_notifier_no_waits disabled +log_flush_notifier_waits disabled +log_flush_notifier_wait_loops disabled +log_write_to_file_requests_interval disabled +log_on_write_no_waits disabled +log_on_write_waits disabled +log_on_write_wait_loops disabled +log_on_flush_no_waits disabled +log_on_flush_waits disabled +log_on_flush_wait_loops disabled +log_on_recent_written_wait_loops disabled +log_on_recent_closed_wait_loops disabled +log_on_buffer_space_no_waits disabled +log_on_buffer_space_waits disabled +log_on_buffer_space_wait_loops disabled +log_on_file_space_no_waits disabled +log_on_file_space_waits disabled +log_on_file_space_wait_loops disabled +compress_pages_compressed disabled +compress_pages_decompressed disabled +compression_pad_increments disabled +compression_pad_decrements disabled +index_page_splits disabled +index_page_merge_attempts disabled +index_page_merge_successful disabled +index_page_reorg_attempts disabled +index_page_reorg_successful disabled +index_page_discards disabled +adaptive_hash_searches disabled +adaptive_hash_searches_btree disabled +adaptive_hash_pages_added disabled +adaptive_hash_pages_removed disabled +adaptive_hash_rows_added disabled +adaptive_hash_rows_removed disabled +adaptive_hash_rows_deleted_no_hash_entry disabled +adaptive_hash_rows_updated disabled +file_num_open_files disabled +ibuf_merges_insert disabled +ibuf_merges_delete_mark disabled +ibuf_merges_delete disabled +ibuf_merges_discard_insert disabled +ibuf_merges_discard_delete_mark disabled +ibuf_merges_discard_delete disabled +ibuf_merges disabled +ibuf_size disabled +innodb_master_thread_sleeps disabled +innodb_activity_count disabled +innodb_master_active_loops disabled +innodb_master_idle_loops disabled +innodb_background_drop_table_usec disabled +innodb_ibuf_merge_usec disabled +innodb_mem_validate_usec disabled +innodb_master_purge_usec disabled +innodb_dict_lru_usec disabled +innodb_dict_lru_count disabled +innodb_dblwr_writes disabled +innodb_dblwr_pages_written disabled +innodb_page_size disabled +innodb_rwlock_s_spin_waits disabled +innodb_rwlock_x_spin_waits disabled +innodb_rwlock_sx_spin_waits disabled +innodb_rwlock_s_spin_rounds disabled +innodb_rwlock_x_spin_rounds disabled +innodb_rwlock_sx_spin_rounds disabled +innodb_rwlock_s_os_waits disabled +innodb_rwlock_x_os_waits disabled +innodb_rwlock_sx_os_waits disabled +dml_reads disabled +dml_inserts disabled +dml_deletes disabled +dml_updates disabled +dml_system_reads disabled +dml_system_inserts disabled +dml_system_deletes disabled +dml_system_updates disabled +sampled_pages_read disabled +sampled_pages_skipped disabled +ddl_background_drop_tables disabled +ddl_online_create_index disabled +ddl_pending_alter_table disabled +ddl_sort_file_alter_table disabled +ddl_log_file_alter_table disabled +icp_attempts disabled +icp_no_match disabled +icp_out_of_range disabled +icp_match disabled +module_cpu disabled +cpu_utime_abs disabled +cpu_stime_abs disabled +cpu_utime_pct disabled +cpu_stime_pct disabled +cpu_n disabled +module_page_track disabled +page_track_resets disabled +page_track_partial_block_writes disabled +page_track_full_block_writes disabled +page_track_checkpoint_partial_flush_request disabled +module_dblwr disabled +dblwr_async_requests disabled +dblwr_sync_requests disabled +dblwr_flush_requests disabled +dblwr_flush_wait_events disabled +set global innodb_monitor_enable = all; +create table monitor_test(col int) engine = innodb; +drop table monitor_test; +select name from information_schema.innodb_metrics where status!='enabled'; +name +set global innodb_monitor_enable = aaa; +ERROR 42000: Variable 'innodb_monitor_enable' can't be set to the value of 'aaa' +set global innodb_monitor_disable = All; +select name from information_schema.innodb_metrics where status!='disabled'; +name +set global innodb_monitor_reset_all = all; +select name from information_schema.innodb_metrics where count!=0; +name +set global innodb_monitor_enable = "%lock%"; +select name from information_schema.innodb_metrics +where status != IF(name like "%lock%", 'enabled', 'disabled'); +name +set global innodb_monitor_disable = "%lock%"; +select name, status from information_schema.innodb_metrics +where name like "%lock%"; +name status +lock_deadlocks disabled +lock_deadlock_false_positives disabled +lock_deadlock_rounds disabled +lock_threads_waiting disabled +lock_timeouts disabled +lock_rec_lock_waits disabled +lock_table_lock_waits disabled +lock_rec_lock_requests disabled +lock_rec_release_attempts disabled +lock_rec_grant_attempts disabled +lock_rec_lock_created disabled +lock_rec_lock_removed disabled +lock_rec_locks disabled +lock_table_lock_created disabled +lock_table_lock_removed disabled +lock_table_locks disabled +lock_row_lock_current_waits disabled +lock_row_lock_time disabled +lock_row_lock_time_max disabled +lock_row_lock_waits disabled +lock_row_lock_time_avg disabled +lock_schedule_refreshes disabled +log_full_block_writes disabled +log_partial_block_writes disabled +innodb_rwlock_s_spin_waits disabled +innodb_rwlock_x_spin_waits disabled +innodb_rwlock_sx_spin_waits disabled +innodb_rwlock_s_spin_rounds disabled +innodb_rwlock_x_spin_rounds disabled +innodb_rwlock_sx_spin_rounds disabled +innodb_rwlock_s_os_waits disabled +innodb_rwlock_x_os_waits disabled +innodb_rwlock_sx_os_waits disabled +page_track_partial_block_writes disabled +page_track_full_block_writes disabled +set global innodb_monitor_enable = "%lock*"; +ERROR 42000: Variable 'innodb_monitor_enable' can't be set to the value of '%lock*' +set global innodb_monitor_enable="%%%%%%%%%%%%%%%%%%%%%%%%%%%"; +select name from information_schema.innodb_metrics where status!='enabled'; +name +set global innodb_monitor_disable="%%%%%"; +select name from information_schema.innodb_metrics where status!='disabled'; +name +set global innodb_monitor_enable="%"; +select name from information_schema.innodb_metrics where status!='enabled'; +name +set global innodb_monitor_disable="%_%"; +select name from information_schema.innodb_metrics where status!='disabled'; +name +set global innodb_monitor_enable="log%%%%"; +select name from information_schema.innodb_metrics +where status != IF(name like "log%", 'enabled', 'disabled'); +name +set global innodb_monitor_enable="os_%a_fs_ncs"; +set global innodb_monitor_enable="os%pending%"; +select name, status from information_schema.innodb_metrics +where name like "os%"; +name status +os_data_reads disabled +os_data_writes disabled +os_data_fsyncs enabled +os_pending_reads enabled +os_pending_writes enabled +os_log_bytes_written disabled +os_log_fsyncs disabled +os_log_pending_fsyncs enabled +os_log_pending_writes enabled +set global innodb_monitor_enable=""; +ERROR 42000: Variable 'innodb_monitor_enable' can't be set to the value of '' +set global innodb_monitor_enable="_"; +ERROR 42000: Variable 'innodb_monitor_enable' can't be set to the value of '_' +SET global innodb_monitor_disable = module_metadata; +SET global innodb_monitor_reset_all = module_metadata; +set global innodb_monitor_enable = metadata_table_handles_opened; +create table monitor_test(col int) engine = innodb; +select * from monitor_test; +col +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name = "metadata_table_handles_opened"; +name max_count min_count count max_count_reset min_count_reset count_reset status +metadata_table_handles_opened 3 NULL 3 3 NULL 3 enabled +set global innodb_monitor_reset = metadata_table_handles_opened; +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name = "metadata_table_handles_opened"; +name max_count min_count count max_count_reset min_count_reset count_reset status +metadata_table_handles_opened 3 NULL 3 NULL NULL 0 enabled +drop table monitor_test; +create table monitor_test(col int) engine = innodb; +select * from monitor_test; +col +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name = "metadata_table_handles_opened"; +name max_count min_count count max_count_reset min_count_reset count_reset status +metadata_table_handles_opened 6 NULL 6 3 NULL 3 enabled +set global innodb_monitor_reset_all = metadata_table_handles_opened; +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name = "metadata_table_handles_opened"; +name max_count min_count count max_count_reset min_count_reset count_reset status +metadata_table_handles_opened 6 NULL 6 3 NULL 3 enabled +set global innodb_monitor_disable = metadata_table_handles_opened; +set global innodb_monitor_reset = metadata_table_handles_opened; +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name = "metadata_table_handles_opened"; +name max_count min_count count max_count_reset min_count_reset count_reset status +metadata_table_handles_opened 6 NULL 6 NULL NULL 0 disabled +drop table monitor_test; +create table monitor_test(col int) engine = innodb; +select * from monitor_test; +col +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name = "metadata_table_handles_opened"; +name max_count min_count count max_count_reset min_count_reset count_reset status +metadata_table_handles_opened 6 NULL 6 NULL NULL 0 disabled +set global innodb_monitor_reset_all = metadata_table_handles_opened; +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name = "metadata_table_handles_opened"; +name max_count min_count count max_count_reset min_count_reset count_reset status +metadata_table_handles_opened NULL NULL 0 NULL NULL 0 disabled +set global innodb_monitor_enable = metadata_table_handles_opened; +drop table monitor_test; +create table monitor_test(col int) engine = innodb stats_persistent=0; +select * from monitor_test; +col +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name = "metadata_table_handles_opened"; +name max_count min_count count max_count_reset min_count_reset count_reset status +metadata_table_handles_opened 3 NULL 3 3 NULL 3 enabled +set global innodb_monitor_enable = metadata_table_handles_closed; +create index idx on monitor_test(col); +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name = "metadata_table_handles_closed"; +name max_count min_count count max_count_reset min_count_reset count_reset status +metadata_table_handles_closed 3 NULL 3 3 NULL 3 enabled +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name like "metadata%"; +name max_count min_count count max_count_reset min_count_reset count_reset status +metadata_table_handles_opened 4 NULL 4 4 NULL 4 enabled +metadata_table_handles_closed 3 NULL 3 3 NULL 3 enabled +metadata_table_reference_count NULL NULL 0 NULL NULL 0 disabled +set global innodb_monitor_disable = module_metadata; +set global innodb_monitor_reset = module_metadata; +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name like "metadata%"; +name max_count min_count count max_count_reset min_count_reset count_reset status +metadata_table_handles_opened 4 NULL 4 NULL NULL 0 disabled +metadata_table_handles_closed 3 NULL 3 NULL NULL 0 disabled +metadata_table_reference_count NULL NULL 0 NULL NULL 0 disabled +set global innodb_monitor_reset_all = module_metadata; +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name like "metadata%"; +name max_count min_count count max_count_reset min_count_reset count_reset status +metadata_table_handles_opened NULL NULL 0 NULL NULL 0 disabled +metadata_table_handles_closed NULL NULL 0 NULL NULL 0 disabled +metadata_table_reference_count NULL NULL 0 NULL NULL 0 disabled +set global innodb_monitor_enable = module_trx; +begin; +insert into monitor_test values(9); +commit; +begin; +insert into monitor_test values(9); +rollback; +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name like "trx_rollbacks" or name like "trx_active_transactions"; +name max_count min_count count max_count_reset min_count_reset count_reset status +trx_rollbacks 1 NULL 1 1 NULL 1 enabled +trx_active_transactions 1 0 0 1 0 0 enabled +set global innodb_monitor_disable = module_trx; +set global innodb_monitor_enable = module_dml; +insert into monitor_test values(9); +update monitor_test set col = 10 where col = 9; +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name like "dml%"; +name max_count min_count count max_count_reset min_count_reset count_reset status +dml_reads 4 NULL 4 4 NULL 4 enabled +dml_inserts 1 NULL 1 1 NULL 1 enabled +dml_deletes 0 NULL 0 0 NULL 0 enabled +dml_updates 2 NULL 2 2 NULL 2 enabled +dml_system_reads 0 NULL 0 0 NULL 0 enabled +dml_system_inserts 0 NULL 0 0 NULL 0 enabled +dml_system_deletes 0 NULL 0 0 NULL 0 enabled +dml_system_updates 0 NULL 0 0 NULL 0 enabled +delete from monitor_test; +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name like "dml%"; +name max_count min_count count max_count_reset min_count_reset count_reset status +dml_reads 6 NULL 6 6 NULL 6 enabled +dml_inserts 1 NULL 1 1 NULL 1 enabled +dml_deletes 2 NULL 2 2 NULL 2 enabled +dml_updates 2 NULL 2 2 NULL 2 enabled +dml_system_reads 0 NULL 0 0 NULL 0 enabled +dml_system_inserts 0 NULL 0 0 NULL 0 enabled +dml_system_deletes 0 NULL 0 0 NULL 0 enabled +dml_system_updates 0 NULL 0 0 NULL 0 enabled +set global innodb_monitor_reset = module_dml; +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name like "dml%"; +name max_count min_count count max_count_reset min_count_reset count_reset status +dml_reads 6 NULL 6 0 NULL 0 enabled +dml_inserts 1 NULL 1 0 NULL 0 enabled +dml_deletes 2 NULL 2 0 NULL 0 enabled +dml_updates 2 NULL 2 0 NULL 0 enabled +dml_system_reads 0 NULL 0 0 NULL 0 enabled +dml_system_inserts 0 NULL 0 0 NULL 0 enabled +dml_system_deletes 0 NULL 0 0 NULL 0 enabled +dml_system_updates 0 NULL 0 0 NULL 0 enabled +insert into monitor_test values(9); +insert into monitor_test values(1); +delete from monitor_test; +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name like "dml%"; +name max_count min_count count max_count_reset min_count_reset count_reset status +dml_reads 8 NULL 8 2 NULL 2 enabled +dml_inserts 3 NULL 3 2 NULL 2 enabled +dml_deletes 4 NULL 4 2 NULL 2 enabled +dml_updates 2 NULL 2 0 NULL 0 enabled +dml_system_reads 0 NULL 0 0 NULL 0 enabled +dml_system_inserts 0 NULL 0 0 NULL 0 enabled +dml_system_deletes 0 NULL 0 0 NULL 0 enabled +dml_system_updates 0 NULL 0 0 NULL 0 enabled +set global innodb_monitor_reset_all = module_dml; +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name like "dml%"; +name max_count min_count count max_count_reset min_count_reset count_reset status +dml_reads 8 NULL 8 2 NULL 2 enabled +dml_inserts 3 NULL 3 2 NULL 2 enabled +dml_deletes 4 NULL 4 2 NULL 2 enabled +dml_updates 2 NULL 2 0 NULL 0 enabled +dml_system_reads 0 NULL 0 0 NULL 0 enabled +dml_system_inserts 0 NULL 0 0 NULL 0 enabled +dml_system_deletes 0 NULL 0 0 NULL 0 enabled +dml_system_updates 0 NULL 0 0 NULL 0 enabled +set global innodb_monitor_disable = module_dml; +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name like "dml%"; +name max_count min_count count max_count_reset min_count_reset count_reset status +dml_reads 8 NULL 8 2 NULL 2 disabled +dml_inserts 3 NULL 3 2 NULL 2 disabled +dml_deletes 4 NULL 4 2 NULL 2 disabled +dml_updates 2 NULL 2 0 NULL 0 disabled +dml_system_reads 0 NULL 0 0 NULL 0 disabled +dml_system_inserts 0 NULL 0 0 NULL 0 disabled +dml_system_deletes 0 NULL 0 0 NULL 0 disabled +dml_system_updates 0 NULL 0 0 NULL 0 disabled +set global innodb_monitor_reset_all = module_dml; +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name like "dml%"; +name max_count min_count count max_count_reset min_count_reset count_reset status +dml_reads NULL NULL 0 NULL NULL 0 disabled +dml_inserts NULL NULL 0 NULL NULL 0 disabled +dml_deletes NULL NULL 0 NULL NULL 0 disabled +dml_updates NULL NULL 0 NULL NULL 0 disabled +dml_system_reads NULL NULL 0 NULL NULL 0 disabled +dml_system_inserts NULL NULL 0 NULL NULL 0 disabled +dml_system_deletes NULL NULL 0 NULL NULL 0 disabled +dml_system_updates NULL NULL 0 NULL NULL 0 disabled +set global innodb_monitor_enable = dml_inserts; +insert into monitor_test values(9); +insert into monitor_test values(1); +delete from monitor_test; +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name like "dml%"; +name max_count min_count count max_count_reset min_count_reset count_reset status +dml_reads NULL NULL 0 NULL NULL 0 disabled +dml_inserts 2 NULL 2 2 NULL 2 enabled +dml_deletes NULL NULL 0 NULL NULL 0 disabled +dml_updates NULL NULL 0 NULL NULL 0 disabled +dml_system_reads NULL NULL 0 NULL NULL 0 disabled +dml_system_inserts NULL NULL 0 NULL NULL 0 disabled +dml_system_deletes NULL NULL 0 NULL NULL 0 disabled +dml_system_updates NULL NULL 0 NULL NULL 0 disabled +set global innodb_monitor_disable = module_dml; +drop table monitor_test; +set global innodb_monitor_enable = file_num_open_files; +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name like "file_num_open_files"; +name max_count min_count count max_count_reset min_count_reset count_reset status +file_num_open_files # # # # # # enabled +set global innodb_monitor_disable = file_num_open_files; +set global innodb_monitor_enable = "icp%"; +create table monitor_test(a char(3), b int, c char(2), +primary key (a(1), c(1)), key(b)) engine = innodb; +insert into monitor_test values("13", 2, "aa"); +select a from monitor_test where b < 1 for update; +a +select name, count from information_schema.innodb_metrics +where name like "icp%"; +name count +icp_attempts 1 +icp_no_match 0 +icp_out_of_range 1 +icp_match 0 +select a from monitor_test where b < 3 for update; +a +13 +select name, count from information_schema.innodb_metrics +where name like "icp%"; +name count +icp_attempts 2 +icp_no_match 0 +icp_out_of_range 1 +icp_match 1 +drop table monitor_test; +set global innodb_monitor_disable = All; +set global innodb_monitor_reset_all = all; diff --git a/mysql-test/suite/innodb_monitor_enable_basic.result-pq b/mysql-test/suite/innodb_monitor_enable_basic.result-pq new file mode 100644 index 000000000000..7aa8e2f12992 --- /dev/null +++ b/mysql-test/suite/innodb_monitor_enable_basic.result-pq @@ -0,0 +1,686 @@ +set global innodb_monitor_disable = All; +select name, status from information_schema.innodb_metrics; +name status +metadata_table_handles_opened disabled +metadata_table_handles_closed disabled +metadata_table_reference_count disabled +lock_deadlocks disabled +lock_deadlock_false_positives disabled +lock_deadlock_rounds disabled +lock_threads_waiting disabled +lock_timeouts disabled +lock_rec_lock_waits disabled +lock_table_lock_waits disabled +lock_rec_lock_requests disabled +lock_rec_release_attempts disabled +lock_rec_grant_attempts disabled +lock_rec_lock_created disabled +lock_rec_lock_removed disabled +lock_rec_locks disabled +lock_table_lock_created disabled +lock_table_lock_removed disabled +lock_table_locks disabled +lock_row_lock_current_waits disabled +lock_row_lock_time disabled +lock_row_lock_time_max disabled +lock_row_lock_waits disabled +lock_row_lock_time_avg disabled +lock_schedule_refreshes disabled +buffer_pool_size disabled +buffer_pool_reads disabled +buffer_pool_read_requests disabled +buffer_pool_write_requests disabled +buffer_pool_wait_free disabled +buffer_pool_read_ahead disabled +buffer_pool_read_ahead_evicted disabled +buffer_pool_pages_total disabled +buffer_pool_pages_misc disabled +buffer_pool_pages_data disabled +buffer_pool_bytes_data disabled +buffer_pool_pages_dirty disabled +buffer_pool_bytes_dirty disabled +buffer_pool_pages_free disabled +buffer_pages_created disabled +buffer_pages_written disabled +buffer_pages_read disabled +buffer_data_reads disabled +buffer_data_written disabled +buffer_flush_batch_scanned disabled +buffer_flush_batch_num_scan disabled +buffer_flush_batch_scanned_per_call disabled +buffer_flush_batch_total_pages disabled +buffer_flush_batches disabled +buffer_flush_batch_pages disabled +buffer_flush_neighbor_total_pages disabled +buffer_flush_neighbor disabled +buffer_flush_neighbor_pages disabled +buffer_flush_n_to_flush_requested disabled +buffer_flush_n_to_flush_by_dirty_page disabled +buffer_flush_n_to_flush_by_age disabled +buffer_flush_adaptive_avg_time_slot disabled +buffer_LRU_batch_flush_avg_time_slot disabled +buffer_flush_adaptive_avg_time_thread disabled +buffer_LRU_batch_flush_avg_time_thread disabled +buffer_flush_adaptive_avg_time_est disabled +buffer_LRU_batch_flush_avg_time_est disabled +buffer_flush_avg_time disabled +buffer_flush_adaptive_avg_pass disabled +buffer_LRU_batch_flush_avg_pass disabled +buffer_flush_avg_pass disabled +buffer_LRU_get_free_loops disabled +buffer_LRU_get_free_waits disabled +buffer_flush_avg_page_rate disabled +buffer_flush_lsn_avg_rate disabled +buffer_flush_pct_for_dirty disabled +buffer_flush_pct_for_lsn disabled +buffer_flush_sync_waits disabled +buffer_flush_adaptive_total_pages disabled +buffer_flush_adaptive disabled +buffer_flush_adaptive_pages disabled +buffer_flush_sync_total_pages disabled +buffer_flush_sync disabled +buffer_flush_sync_pages disabled +buffer_flush_background_total_pages disabled +buffer_flush_background disabled +buffer_flush_background_pages disabled +buffer_LRU_batch_scanned disabled +buffer_LRU_batch_num_scan disabled +buffer_LRU_batch_scanned_per_call disabled +buffer_LRU_batch_flush_total_pages disabled +buffer_LRU_batches_flush disabled +buffer_LRU_batch_flush_pages disabled +buffer_LRU_batch_evict_total_pages disabled +buffer_LRU_batches_evict disabled +buffer_LRU_batch_evict_pages disabled +buffer_LRU_single_flush_scanned disabled +buffer_LRU_single_flush_num_scan disabled +buffer_LRU_single_flush_scanned_per_call disabled +buffer_LRU_single_flush_failure_count disabled +buffer_LRU_get_free_search disabled +buffer_LRU_search_scanned disabled +buffer_LRU_search_num_scan disabled +buffer_LRU_search_scanned_per_call disabled +buffer_LRU_unzip_search_scanned disabled +buffer_LRU_unzip_search_num_scan disabled +buffer_LRU_unzip_search_scanned_per_call disabled +buffer_page_read_index_leaf disabled +buffer_page_read_index_non_leaf disabled +buffer_page_read_index_ibuf_leaf disabled +buffer_page_read_index_ibuf_non_leaf disabled +buffer_page_read_undo_log disabled +buffer_page_read_index_inode disabled +buffer_page_read_ibuf_free_list disabled +buffer_page_read_ibuf_bitmap disabled +buffer_page_read_system_page disabled +buffer_page_read_trx_system disabled +buffer_page_read_fsp_hdr disabled +buffer_page_read_xdes disabled +buffer_page_read_blob disabled +buffer_page_read_zblob disabled +buffer_page_read_zblob2 disabled +buffer_page_read_rseg_array disabled +buffer_page_read_other disabled +buffer_page_written_index_leaf disabled +buffer_page_written_index_non_leaf disabled +buffer_page_written_index_ibuf_leaf disabled +buffer_page_written_index_ibuf_non_leaf disabled +buffer_page_written_undo_log disabled +buffer_page_written_index_inode disabled +buffer_page_written_ibuf_free_list disabled +buffer_page_written_ibuf_bitmap disabled +buffer_page_written_system_page disabled +buffer_page_written_trx_system disabled +buffer_page_written_fsp_hdr disabled +buffer_page_written_xdes disabled +buffer_page_written_blob disabled +buffer_page_written_zblob disabled +buffer_page_written_zblob2 disabled +buffer_page_written_rseg_array disabled +buffer_page_written_other disabled +buffer_page_written_on_log_no_waits disabled +buffer_page_written_on_log_waits disabled +buffer_page_written_on_log_wait_loops disabled +os_data_reads disabled +os_data_writes disabled +os_data_fsyncs disabled +os_pending_reads disabled +os_pending_writes disabled +os_log_bytes_written disabled +os_log_fsyncs disabled +os_log_pending_fsyncs disabled +os_log_pending_writes disabled +trx_rw_commits disabled +trx_ro_commits disabled +trx_nl_ro_commits disabled +trx_commits_insert_update disabled +trx_rollbacks disabled +trx_rollbacks_savepoint disabled +trx_rollback_active disabled +trx_active_transactions disabled +trx_allocations disabled +trx_on_log_no_waits disabled +trx_on_log_waits disabled +trx_on_log_wait_loops disabled +trx_rseg_history_len disabled +trx_undo_slots_used disabled +trx_undo_slots_cached disabled +trx_rseg_current_size disabled +purge_del_mark_records disabled +purge_upd_exist_or_extern_records disabled +purge_invoked disabled +purge_undo_log_pages disabled +purge_dml_delay_usec disabled +purge_stop_count disabled +purge_resume_count disabled +purge_truncate_history_count disabled +purge_truncate_history_usec disabled +undo_truncate_count disabled +undo_truncate_start_logging_count disabled +undo_truncate_done_logging_count disabled +undo_truncate_usec disabled +log_lsn_last_flush disabled +log_lsn_last_checkpoint disabled +log_lsn_current disabled +log_lsn_archived disabled +log_lsn_checkpoint_age disabled +log_lsn_buf_dirty_pages_added disabled +log_lsn_buf_pool_oldest_approx disabled +log_lsn_buf_pool_oldest_lwm disabled +log_max_modified_age_async disabled +log_max_modified_age_sync disabled +log_waits disabled +log_write_requests disabled +log_writes disabled +log_flush_total_time disabled +log_flush_max_time disabled +log_flush_avg_time disabled +log_flush_lsn_avg_rate disabled +log_full_block_writes disabled +log_partial_block_writes disabled +log_padded disabled +log_next_file disabled +log_checkpoints disabled +log_free_space disabled +log_concurrency_margin disabled +log_writer_no_waits disabled +log_writer_waits disabled +log_writer_wait_loops disabled +log_writer_on_file_space_waits disabled +log_writer_on_archiver_waits disabled +log_flusher_no_waits disabled +log_flusher_waits disabled +log_flusher_wait_loops disabled +log_write_notifier_no_waits disabled +log_write_notifier_waits disabled +log_write_notifier_wait_loops disabled +log_flush_notifier_no_waits disabled +log_flush_notifier_waits disabled +log_flush_notifier_wait_loops disabled +log_write_to_file_requests_interval disabled +log_on_write_no_waits disabled +log_on_write_waits disabled +log_on_write_wait_loops disabled +log_on_flush_no_waits disabled +log_on_flush_waits disabled +log_on_flush_wait_loops disabled +log_on_recent_written_wait_loops disabled +log_on_recent_closed_wait_loops disabled +log_on_buffer_space_no_waits disabled +log_on_buffer_space_waits disabled +log_on_buffer_space_wait_loops disabled +log_on_file_space_no_waits disabled +log_on_file_space_waits disabled +log_on_file_space_wait_loops disabled +compress_pages_compressed disabled +compress_pages_decompressed disabled +compression_pad_increments disabled +compression_pad_decrements disabled +index_page_splits disabled +index_page_merge_attempts disabled +index_page_merge_successful disabled +index_page_reorg_attempts disabled +index_page_reorg_successful disabled +index_page_discards disabled +adaptive_hash_searches disabled +adaptive_hash_searches_btree disabled +adaptive_hash_pages_added disabled +adaptive_hash_pages_removed disabled +adaptive_hash_rows_added disabled +adaptive_hash_rows_removed disabled +adaptive_hash_rows_deleted_no_hash_entry disabled +adaptive_hash_rows_updated disabled +file_num_open_files disabled +ibuf_merges_insert disabled +ibuf_merges_delete_mark disabled +ibuf_merges_delete disabled +ibuf_merges_discard_insert disabled +ibuf_merges_discard_delete_mark disabled +ibuf_merges_discard_delete disabled +ibuf_merges disabled +ibuf_size disabled +innodb_master_thread_sleeps disabled +innodb_activity_count disabled +innodb_master_active_loops disabled +innodb_master_idle_loops disabled +innodb_background_drop_table_usec disabled +innodb_ibuf_merge_usec disabled +innodb_mem_validate_usec disabled +innodb_master_purge_usec disabled +innodb_dict_lru_usec disabled +innodb_dict_lru_count disabled +innodb_dblwr_writes disabled +innodb_dblwr_pages_written disabled +innodb_page_size disabled +innodb_rwlock_s_spin_waits disabled +innodb_rwlock_x_spin_waits disabled +innodb_rwlock_sx_spin_waits disabled +innodb_rwlock_s_spin_rounds disabled +innodb_rwlock_x_spin_rounds disabled +innodb_rwlock_sx_spin_rounds disabled +innodb_rwlock_s_os_waits disabled +innodb_rwlock_x_os_waits disabled +innodb_rwlock_sx_os_waits disabled +dml_reads disabled +dml_inserts disabled +dml_deletes disabled +dml_updates disabled +dml_system_reads disabled +dml_system_inserts disabled +dml_system_deletes disabled +dml_system_updates disabled +sampled_pages_read disabled +sampled_pages_skipped disabled +ddl_background_drop_tables disabled +ddl_online_create_index disabled +ddl_pending_alter_table disabled +ddl_sort_file_alter_table disabled +ddl_log_file_alter_table disabled +icp_attempts disabled +icp_no_match disabled +icp_out_of_range disabled +icp_match disabled +module_cpu disabled +cpu_utime_abs disabled +cpu_stime_abs disabled +cpu_utime_pct disabled +cpu_stime_pct disabled +cpu_n disabled +module_page_track disabled +page_track_resets disabled +page_track_partial_block_writes disabled +page_track_full_block_writes disabled +page_track_checkpoint_partial_flush_request disabled +module_dblwr disabled +dblwr_async_requests disabled +dblwr_sync_requests disabled +dblwr_flush_requests disabled +dblwr_flush_wait_events disabled +set global innodb_monitor_enable = all; +create table monitor_test(col int) engine = innodb; +drop table monitor_test; +select name from information_schema.innodb_metrics where status!='enabled'; +name +set global innodb_monitor_enable = aaa; +ERROR 42000: Variable 'innodb_monitor_enable' can't be set to the value of 'aaa' +set global innodb_monitor_disable = All; +select name from information_schema.innodb_metrics where status!='disabled'; +name +set global innodb_monitor_reset_all = all; +select name from information_schema.innodb_metrics where count!=0; +name +set global innodb_monitor_enable = "%lock%"; +select name from information_schema.innodb_metrics +where status != IF(name like "%lock%", 'enabled', 'disabled'); +name +set global innodb_monitor_disable = "%lock%"; +select name, status from information_schema.innodb_metrics +where name like "%lock%"; +name status +lock_deadlocks disabled +lock_deadlock_false_positives disabled +lock_deadlock_rounds disabled +lock_threads_waiting disabled +lock_timeouts disabled +lock_rec_lock_waits disabled +lock_table_lock_waits disabled +lock_rec_lock_requests disabled +lock_rec_release_attempts disabled +lock_rec_grant_attempts disabled +lock_rec_lock_created disabled +lock_rec_lock_removed disabled +lock_rec_locks disabled +lock_table_lock_created disabled +lock_table_lock_removed disabled +lock_table_locks disabled +lock_row_lock_current_waits disabled +lock_row_lock_time disabled +lock_row_lock_time_max disabled +lock_row_lock_waits disabled +lock_row_lock_time_avg disabled +lock_schedule_refreshes disabled +log_full_block_writes disabled +log_partial_block_writes disabled +innodb_rwlock_s_spin_waits disabled +innodb_rwlock_x_spin_waits disabled +innodb_rwlock_sx_spin_waits disabled +innodb_rwlock_s_spin_rounds disabled +innodb_rwlock_x_spin_rounds disabled +innodb_rwlock_sx_spin_rounds disabled +innodb_rwlock_s_os_waits disabled +innodb_rwlock_x_os_waits disabled +innodb_rwlock_sx_os_waits disabled +page_track_partial_block_writes disabled +page_track_full_block_writes disabled +set global innodb_monitor_enable = "%lock*"; +ERROR 42000: Variable 'innodb_monitor_enable' can't be set to the value of '%lock*' +set global innodb_monitor_enable="%%%%%%%%%%%%%%%%%%%%%%%%%%%"; +select name from information_schema.innodb_metrics where status!='enabled'; +name +set global innodb_monitor_disable="%%%%%"; +select name from information_schema.innodb_metrics where status!='disabled'; +name +set global innodb_monitor_enable="%"; +select name from information_schema.innodb_metrics where status!='enabled'; +name +set global innodb_monitor_disable="%_%"; +select name from information_schema.innodb_metrics where status!='disabled'; +name +set global innodb_monitor_enable="log%%%%"; +select name from information_schema.innodb_metrics +where status != IF(name like "log%", 'enabled', 'disabled'); +name +set global innodb_monitor_enable="os_%a_fs_ncs"; +set global innodb_monitor_enable="os%pending%"; +select name, status from information_schema.innodb_metrics +where name like "os%"; +name status +os_data_reads disabled +os_data_writes disabled +os_data_fsyncs enabled +os_pending_reads enabled +os_pending_writes enabled +os_log_bytes_written disabled +os_log_fsyncs disabled +os_log_pending_fsyncs enabled +os_log_pending_writes enabled +set global innodb_monitor_enable=""; +ERROR 42000: Variable 'innodb_monitor_enable' can't be set to the value of '' +set global innodb_monitor_enable="_"; +ERROR 42000: Variable 'innodb_monitor_enable' can't be set to the value of '_' +SET global innodb_monitor_disable = module_metadata; +SET global innodb_monitor_reset_all = module_metadata; +set global innodb_monitor_enable = metadata_table_handles_opened; +create table monitor_test(col int) engine = innodb; +select * from monitor_test; +col +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name = "metadata_table_handles_opened"; +name max_count min_count count max_count_reset min_count_reset count_reset status +metadata_table_handles_opened 3 NULL 3 3 NULL 3 enabled +set global innodb_monitor_reset = metadata_table_handles_opened; +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name = "metadata_table_handles_opened"; +name max_count min_count count max_count_reset min_count_reset count_reset status +metadata_table_handles_opened 3 NULL 3 NULL NULL 0 enabled +drop table monitor_test; +create table monitor_test(col int) engine = innodb; +select * from monitor_test; +col +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name = "metadata_table_handles_opened"; +name max_count min_count count max_count_reset min_count_reset count_reset status +metadata_table_handles_opened 6 NULL 6 3 NULL 3 enabled +set global innodb_monitor_reset_all = metadata_table_handles_opened; +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name = "metadata_table_handles_opened"; +name max_count min_count count max_count_reset min_count_reset count_reset status +metadata_table_handles_opened 6 NULL 6 3 NULL 3 enabled +set global innodb_monitor_disable = metadata_table_handles_opened; +set global innodb_monitor_reset = metadata_table_handles_opened; +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name = "metadata_table_handles_opened"; +name max_count min_count count max_count_reset min_count_reset count_reset status +metadata_table_handles_opened 6 NULL 6 NULL NULL 0 disabled +drop table monitor_test; +create table monitor_test(col int) engine = innodb; +select * from monitor_test; +col +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name = "metadata_table_handles_opened"; +name max_count min_count count max_count_reset min_count_reset count_reset status +metadata_table_handles_opened 6 NULL 6 NULL NULL 0 disabled +set global innodb_monitor_reset_all = metadata_table_handles_opened; +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name = "metadata_table_handles_opened"; +name max_count min_count count max_count_reset min_count_reset count_reset status +metadata_table_handles_opened NULL NULL 0 NULL NULL 0 disabled +set global innodb_monitor_enable = metadata_table_handles_opened; +drop table monitor_test; +create table monitor_test(col int) engine = innodb stats_persistent=0; +select * from monitor_test; +col +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name = "metadata_table_handles_opened"; +name max_count min_count count max_count_reset min_count_reset count_reset status +metadata_table_handles_opened 3 NULL 3 3 NULL 3 enabled +set global innodb_monitor_enable = metadata_table_handles_closed; +create index idx on monitor_test(col); +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name = "metadata_table_handles_closed"; +name max_count min_count count max_count_reset min_count_reset count_reset status +metadata_table_handles_closed 3 NULL 3 3 NULL 3 enabled +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name like "metadata%"; +name max_count min_count count max_count_reset min_count_reset count_reset status +metadata_table_handles_opened 4 NULL 4 4 NULL 4 enabled +metadata_table_handles_closed 3 NULL 3 3 NULL 3 enabled +metadata_table_reference_count NULL NULL 0 NULL NULL 0 disabled +set global innodb_monitor_disable = module_metadata; +set global innodb_monitor_reset = module_metadata; +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name like "metadata%"; +name max_count min_count count max_count_reset min_count_reset count_reset status +metadata_table_handles_opened 4 NULL 4 NULL NULL 0 disabled +metadata_table_handles_closed 3 NULL 3 NULL NULL 0 disabled +metadata_table_reference_count NULL NULL 0 NULL NULL 0 disabled +set global innodb_monitor_reset_all = module_metadata; +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name like "metadata%"; +name max_count min_count count max_count_reset min_count_reset count_reset status +metadata_table_handles_opened NULL NULL 0 NULL NULL 0 disabled +metadata_table_handles_closed NULL NULL 0 NULL NULL 0 disabled +metadata_table_reference_count NULL NULL 0 NULL NULL 0 disabled +set global innodb_monitor_enable = module_trx; +begin; +insert into monitor_test values(9); +commit; +begin; +insert into monitor_test values(9); +rollback; +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name like "trx_rollbacks" or name like "trx_active_transactions"; +name max_count min_count count max_count_reset min_count_reset count_reset status +trx_rollbacks 1 NULL 1 1 NULL 1 enabled +trx_active_transactions 1 0 0 1 0 0 enabled +set global innodb_monitor_disable = module_trx; +set global innodb_monitor_enable = module_dml; +insert into monitor_test values(9); +update monitor_test set col = 10 where col = 9; +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name like "dml%"; +name max_count min_count count max_count_reset min_count_reset count_reset status +dml_reads 4 NULL 4 4 NULL 4 enabled +dml_inserts 1 NULL 1 1 NULL 1 enabled +dml_deletes 0 NULL 0 0 NULL 0 enabled +dml_updates 2 NULL 2 2 NULL 2 enabled +dml_system_reads 0 NULL 0 0 NULL 0 enabled +dml_system_inserts 0 NULL 0 0 NULL 0 enabled +dml_system_deletes 0 NULL 0 0 NULL 0 enabled +dml_system_updates 0 NULL 0 0 NULL 0 enabled +delete from monitor_test; +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name like "dml%"; +name max_count min_count count max_count_reset min_count_reset count_reset status +dml_reads 6 NULL 6 6 NULL 6 enabled +dml_inserts 1 NULL 1 1 NULL 1 enabled +dml_deletes 2 NULL 2 2 NULL 2 enabled +dml_updates 2 NULL 2 2 NULL 2 enabled +dml_system_reads 0 NULL 0 0 NULL 0 enabled +dml_system_inserts 0 NULL 0 0 NULL 0 enabled +dml_system_deletes 0 NULL 0 0 NULL 0 enabled +dml_system_updates 0 NULL 0 0 NULL 0 enabled +set global innodb_monitor_reset = module_dml; +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name like "dml%"; +name max_count min_count count max_count_reset min_count_reset count_reset status +dml_reads 6 NULL 6 0 NULL 0 enabled +dml_inserts 1 NULL 1 0 NULL 0 enabled +dml_deletes 2 NULL 2 0 NULL 0 enabled +dml_updates 2 NULL 2 0 NULL 0 enabled +dml_system_reads 0 NULL 0 0 NULL 0 enabled +dml_system_inserts 0 NULL 0 0 NULL 0 enabled +dml_system_deletes 0 NULL 0 0 NULL 0 enabled +dml_system_updates 0 NULL 0 0 NULL 0 enabled +insert into monitor_test values(9); +insert into monitor_test values(1); +delete from monitor_test; +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name like "dml%"; +name max_count min_count count max_count_reset min_count_reset count_reset status +dml_reads 8 NULL 8 2 NULL 2 enabled +dml_inserts 3 NULL 3 2 NULL 2 enabled +dml_deletes 4 NULL 4 2 NULL 2 enabled +dml_updates 2 NULL 2 0 NULL 0 enabled +dml_system_reads 0 NULL 0 0 NULL 0 enabled +dml_system_inserts 0 NULL 0 0 NULL 0 enabled +dml_system_deletes 0 NULL 0 0 NULL 0 enabled +dml_system_updates 0 NULL 0 0 NULL 0 enabled +set global innodb_monitor_reset_all = module_dml; +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name like "dml%"; +name max_count min_count count max_count_reset min_count_reset count_reset status +dml_reads 8 NULL 8 2 NULL 2 enabled +dml_inserts 3 NULL 3 2 NULL 2 enabled +dml_deletes 4 NULL 4 2 NULL 2 enabled +dml_updates 2 NULL 2 0 NULL 0 enabled +dml_system_reads 0 NULL 0 0 NULL 0 enabled +dml_system_inserts 0 NULL 0 0 NULL 0 enabled +dml_system_deletes 0 NULL 0 0 NULL 0 enabled +dml_system_updates 0 NULL 0 0 NULL 0 enabled +set global innodb_monitor_disable = module_dml; +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name like "dml%"; +name max_count min_count count max_count_reset min_count_reset count_reset status +dml_reads 8 NULL 8 2 NULL 2 disabled +dml_inserts 3 NULL 3 2 NULL 2 disabled +dml_deletes 4 NULL 4 2 NULL 2 disabled +dml_updates 2 NULL 2 0 NULL 0 disabled +dml_system_reads 0 NULL 0 0 NULL 0 disabled +dml_system_inserts 0 NULL 0 0 NULL 0 disabled +dml_system_deletes 0 NULL 0 0 NULL 0 disabled +dml_system_updates 0 NULL 0 0 NULL 0 disabled +set global innodb_monitor_reset_all = module_dml; +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name like "dml%"; +name max_count min_count count max_count_reset min_count_reset count_reset status +dml_reads NULL NULL 0 NULL NULL 0 disabled +dml_inserts NULL NULL 0 NULL NULL 0 disabled +dml_deletes NULL NULL 0 NULL NULL 0 disabled +dml_updates NULL NULL 0 NULL NULL 0 disabled +dml_system_reads NULL NULL 0 NULL NULL 0 disabled +dml_system_inserts NULL NULL 0 NULL NULL 0 disabled +dml_system_deletes NULL NULL 0 NULL NULL 0 disabled +dml_system_updates NULL NULL 0 NULL NULL 0 disabled +set global innodb_monitor_enable = dml_inserts; +insert into monitor_test values(9); +insert into monitor_test values(1); +delete from monitor_test; +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name like "dml%"; +name max_count min_count count max_count_reset min_count_reset count_reset status +dml_reads NULL NULL 0 NULL NULL 0 disabled +dml_inserts 2 NULL 2 2 NULL 2 enabled +dml_deletes NULL NULL 0 NULL NULL 0 disabled +dml_updates NULL NULL 0 NULL NULL 0 disabled +dml_system_reads NULL NULL 0 NULL NULL 0 disabled +dml_system_inserts NULL NULL 0 NULL NULL 0 disabled +dml_system_deletes NULL NULL 0 NULL NULL 0 disabled +dml_system_updates NULL NULL 0 NULL NULL 0 disabled +set global innodb_monitor_disable = module_dml; +drop table monitor_test; +set global innodb_monitor_enable = file_num_open_files; +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name like "file_num_open_files"; +name max_count min_count count max_count_reset min_count_reset count_reset status +file_num_open_files # # # # # # enabled +set global innodb_monitor_disable = file_num_open_files; +set global innodb_monitor_enable = "icp%"; +create table monitor_test(a char(3), b int, c char(2), +primary key (a(1), c(1)), key(b)) engine = innodb; +insert into monitor_test values("13", 2, "aa"); +select a from monitor_test where b < 1 for update; +a +select name, count from information_schema.innodb_metrics +where name like "icp%"; +name count +icp_attempts 1 +icp_no_match 0 +icp_out_of_range 1 +icp_match 0 +select a from monitor_test where b < 3 for update; +a +13 +select name, count from information_schema.innodb_metrics +where name like "icp%"; +name count +icp_attempts 2 +icp_no_match 0 +icp_out_of_range 1 +icp_match 1 +drop table monitor_test; +set global innodb_monitor_disable = All; +set global innodb_monitor_reset_all = all; diff --git a/mysql-test/suite/innodb_monitor_reset_all_basic.result-pq b/mysql-test/suite/innodb_monitor_reset_all_basic.result-pq new file mode 100644 index 000000000000..7aa8e2f12992 --- /dev/null +++ b/mysql-test/suite/innodb_monitor_reset_all_basic.result-pq @@ -0,0 +1,686 @@ +set global innodb_monitor_disable = All; +select name, status from information_schema.innodb_metrics; +name status +metadata_table_handles_opened disabled +metadata_table_handles_closed disabled +metadata_table_reference_count disabled +lock_deadlocks disabled +lock_deadlock_false_positives disabled +lock_deadlock_rounds disabled +lock_threads_waiting disabled +lock_timeouts disabled +lock_rec_lock_waits disabled +lock_table_lock_waits disabled +lock_rec_lock_requests disabled +lock_rec_release_attempts disabled +lock_rec_grant_attempts disabled +lock_rec_lock_created disabled +lock_rec_lock_removed disabled +lock_rec_locks disabled +lock_table_lock_created disabled +lock_table_lock_removed disabled +lock_table_locks disabled +lock_row_lock_current_waits disabled +lock_row_lock_time disabled +lock_row_lock_time_max disabled +lock_row_lock_waits disabled +lock_row_lock_time_avg disabled +lock_schedule_refreshes disabled +buffer_pool_size disabled +buffer_pool_reads disabled +buffer_pool_read_requests disabled +buffer_pool_write_requests disabled +buffer_pool_wait_free disabled +buffer_pool_read_ahead disabled +buffer_pool_read_ahead_evicted disabled +buffer_pool_pages_total disabled +buffer_pool_pages_misc disabled +buffer_pool_pages_data disabled +buffer_pool_bytes_data disabled +buffer_pool_pages_dirty disabled +buffer_pool_bytes_dirty disabled +buffer_pool_pages_free disabled +buffer_pages_created disabled +buffer_pages_written disabled +buffer_pages_read disabled +buffer_data_reads disabled +buffer_data_written disabled +buffer_flush_batch_scanned disabled +buffer_flush_batch_num_scan disabled +buffer_flush_batch_scanned_per_call disabled +buffer_flush_batch_total_pages disabled +buffer_flush_batches disabled +buffer_flush_batch_pages disabled +buffer_flush_neighbor_total_pages disabled +buffer_flush_neighbor disabled +buffer_flush_neighbor_pages disabled +buffer_flush_n_to_flush_requested disabled +buffer_flush_n_to_flush_by_dirty_page disabled +buffer_flush_n_to_flush_by_age disabled +buffer_flush_adaptive_avg_time_slot disabled +buffer_LRU_batch_flush_avg_time_slot disabled +buffer_flush_adaptive_avg_time_thread disabled +buffer_LRU_batch_flush_avg_time_thread disabled +buffer_flush_adaptive_avg_time_est disabled +buffer_LRU_batch_flush_avg_time_est disabled +buffer_flush_avg_time disabled +buffer_flush_adaptive_avg_pass disabled +buffer_LRU_batch_flush_avg_pass disabled +buffer_flush_avg_pass disabled +buffer_LRU_get_free_loops disabled +buffer_LRU_get_free_waits disabled +buffer_flush_avg_page_rate disabled +buffer_flush_lsn_avg_rate disabled +buffer_flush_pct_for_dirty disabled +buffer_flush_pct_for_lsn disabled +buffer_flush_sync_waits disabled +buffer_flush_adaptive_total_pages disabled +buffer_flush_adaptive disabled +buffer_flush_adaptive_pages disabled +buffer_flush_sync_total_pages disabled +buffer_flush_sync disabled +buffer_flush_sync_pages disabled +buffer_flush_background_total_pages disabled +buffer_flush_background disabled +buffer_flush_background_pages disabled +buffer_LRU_batch_scanned disabled +buffer_LRU_batch_num_scan disabled +buffer_LRU_batch_scanned_per_call disabled +buffer_LRU_batch_flush_total_pages disabled +buffer_LRU_batches_flush disabled +buffer_LRU_batch_flush_pages disabled +buffer_LRU_batch_evict_total_pages disabled +buffer_LRU_batches_evict disabled +buffer_LRU_batch_evict_pages disabled +buffer_LRU_single_flush_scanned disabled +buffer_LRU_single_flush_num_scan disabled +buffer_LRU_single_flush_scanned_per_call disabled +buffer_LRU_single_flush_failure_count disabled +buffer_LRU_get_free_search disabled +buffer_LRU_search_scanned disabled +buffer_LRU_search_num_scan disabled +buffer_LRU_search_scanned_per_call disabled +buffer_LRU_unzip_search_scanned disabled +buffer_LRU_unzip_search_num_scan disabled +buffer_LRU_unzip_search_scanned_per_call disabled +buffer_page_read_index_leaf disabled +buffer_page_read_index_non_leaf disabled +buffer_page_read_index_ibuf_leaf disabled +buffer_page_read_index_ibuf_non_leaf disabled +buffer_page_read_undo_log disabled +buffer_page_read_index_inode disabled +buffer_page_read_ibuf_free_list disabled +buffer_page_read_ibuf_bitmap disabled +buffer_page_read_system_page disabled +buffer_page_read_trx_system disabled +buffer_page_read_fsp_hdr disabled +buffer_page_read_xdes disabled +buffer_page_read_blob disabled +buffer_page_read_zblob disabled +buffer_page_read_zblob2 disabled +buffer_page_read_rseg_array disabled +buffer_page_read_other disabled +buffer_page_written_index_leaf disabled +buffer_page_written_index_non_leaf disabled +buffer_page_written_index_ibuf_leaf disabled +buffer_page_written_index_ibuf_non_leaf disabled +buffer_page_written_undo_log disabled +buffer_page_written_index_inode disabled +buffer_page_written_ibuf_free_list disabled +buffer_page_written_ibuf_bitmap disabled +buffer_page_written_system_page disabled +buffer_page_written_trx_system disabled +buffer_page_written_fsp_hdr disabled +buffer_page_written_xdes disabled +buffer_page_written_blob disabled +buffer_page_written_zblob disabled +buffer_page_written_zblob2 disabled +buffer_page_written_rseg_array disabled +buffer_page_written_other disabled +buffer_page_written_on_log_no_waits disabled +buffer_page_written_on_log_waits disabled +buffer_page_written_on_log_wait_loops disabled +os_data_reads disabled +os_data_writes disabled +os_data_fsyncs disabled +os_pending_reads disabled +os_pending_writes disabled +os_log_bytes_written disabled +os_log_fsyncs disabled +os_log_pending_fsyncs disabled +os_log_pending_writes disabled +trx_rw_commits disabled +trx_ro_commits disabled +trx_nl_ro_commits disabled +trx_commits_insert_update disabled +trx_rollbacks disabled +trx_rollbacks_savepoint disabled +trx_rollback_active disabled +trx_active_transactions disabled +trx_allocations disabled +trx_on_log_no_waits disabled +trx_on_log_waits disabled +trx_on_log_wait_loops disabled +trx_rseg_history_len disabled +trx_undo_slots_used disabled +trx_undo_slots_cached disabled +trx_rseg_current_size disabled +purge_del_mark_records disabled +purge_upd_exist_or_extern_records disabled +purge_invoked disabled +purge_undo_log_pages disabled +purge_dml_delay_usec disabled +purge_stop_count disabled +purge_resume_count disabled +purge_truncate_history_count disabled +purge_truncate_history_usec disabled +undo_truncate_count disabled +undo_truncate_start_logging_count disabled +undo_truncate_done_logging_count disabled +undo_truncate_usec disabled +log_lsn_last_flush disabled +log_lsn_last_checkpoint disabled +log_lsn_current disabled +log_lsn_archived disabled +log_lsn_checkpoint_age disabled +log_lsn_buf_dirty_pages_added disabled +log_lsn_buf_pool_oldest_approx disabled +log_lsn_buf_pool_oldest_lwm disabled +log_max_modified_age_async disabled +log_max_modified_age_sync disabled +log_waits disabled +log_write_requests disabled +log_writes disabled +log_flush_total_time disabled +log_flush_max_time disabled +log_flush_avg_time disabled +log_flush_lsn_avg_rate disabled +log_full_block_writes disabled +log_partial_block_writes disabled +log_padded disabled +log_next_file disabled +log_checkpoints disabled +log_free_space disabled +log_concurrency_margin disabled +log_writer_no_waits disabled +log_writer_waits disabled +log_writer_wait_loops disabled +log_writer_on_file_space_waits disabled +log_writer_on_archiver_waits disabled +log_flusher_no_waits disabled +log_flusher_waits disabled +log_flusher_wait_loops disabled +log_write_notifier_no_waits disabled +log_write_notifier_waits disabled +log_write_notifier_wait_loops disabled +log_flush_notifier_no_waits disabled +log_flush_notifier_waits disabled +log_flush_notifier_wait_loops disabled +log_write_to_file_requests_interval disabled +log_on_write_no_waits disabled +log_on_write_waits disabled +log_on_write_wait_loops disabled +log_on_flush_no_waits disabled +log_on_flush_waits disabled +log_on_flush_wait_loops disabled +log_on_recent_written_wait_loops disabled +log_on_recent_closed_wait_loops disabled +log_on_buffer_space_no_waits disabled +log_on_buffer_space_waits disabled +log_on_buffer_space_wait_loops disabled +log_on_file_space_no_waits disabled +log_on_file_space_waits disabled +log_on_file_space_wait_loops disabled +compress_pages_compressed disabled +compress_pages_decompressed disabled +compression_pad_increments disabled +compression_pad_decrements disabled +index_page_splits disabled +index_page_merge_attempts disabled +index_page_merge_successful disabled +index_page_reorg_attempts disabled +index_page_reorg_successful disabled +index_page_discards disabled +adaptive_hash_searches disabled +adaptive_hash_searches_btree disabled +adaptive_hash_pages_added disabled +adaptive_hash_pages_removed disabled +adaptive_hash_rows_added disabled +adaptive_hash_rows_removed disabled +adaptive_hash_rows_deleted_no_hash_entry disabled +adaptive_hash_rows_updated disabled +file_num_open_files disabled +ibuf_merges_insert disabled +ibuf_merges_delete_mark disabled +ibuf_merges_delete disabled +ibuf_merges_discard_insert disabled +ibuf_merges_discard_delete_mark disabled +ibuf_merges_discard_delete disabled +ibuf_merges disabled +ibuf_size disabled +innodb_master_thread_sleeps disabled +innodb_activity_count disabled +innodb_master_active_loops disabled +innodb_master_idle_loops disabled +innodb_background_drop_table_usec disabled +innodb_ibuf_merge_usec disabled +innodb_mem_validate_usec disabled +innodb_master_purge_usec disabled +innodb_dict_lru_usec disabled +innodb_dict_lru_count disabled +innodb_dblwr_writes disabled +innodb_dblwr_pages_written disabled +innodb_page_size disabled +innodb_rwlock_s_spin_waits disabled +innodb_rwlock_x_spin_waits disabled +innodb_rwlock_sx_spin_waits disabled +innodb_rwlock_s_spin_rounds disabled +innodb_rwlock_x_spin_rounds disabled +innodb_rwlock_sx_spin_rounds disabled +innodb_rwlock_s_os_waits disabled +innodb_rwlock_x_os_waits disabled +innodb_rwlock_sx_os_waits disabled +dml_reads disabled +dml_inserts disabled +dml_deletes disabled +dml_updates disabled +dml_system_reads disabled +dml_system_inserts disabled +dml_system_deletes disabled +dml_system_updates disabled +sampled_pages_read disabled +sampled_pages_skipped disabled +ddl_background_drop_tables disabled +ddl_online_create_index disabled +ddl_pending_alter_table disabled +ddl_sort_file_alter_table disabled +ddl_log_file_alter_table disabled +icp_attempts disabled +icp_no_match disabled +icp_out_of_range disabled +icp_match disabled +module_cpu disabled +cpu_utime_abs disabled +cpu_stime_abs disabled +cpu_utime_pct disabled +cpu_stime_pct disabled +cpu_n disabled +module_page_track disabled +page_track_resets disabled +page_track_partial_block_writes disabled +page_track_full_block_writes disabled +page_track_checkpoint_partial_flush_request disabled +module_dblwr disabled +dblwr_async_requests disabled +dblwr_sync_requests disabled +dblwr_flush_requests disabled +dblwr_flush_wait_events disabled +set global innodb_monitor_enable = all; +create table monitor_test(col int) engine = innodb; +drop table monitor_test; +select name from information_schema.innodb_metrics where status!='enabled'; +name +set global innodb_monitor_enable = aaa; +ERROR 42000: Variable 'innodb_monitor_enable' can't be set to the value of 'aaa' +set global innodb_monitor_disable = All; +select name from information_schema.innodb_metrics where status!='disabled'; +name +set global innodb_monitor_reset_all = all; +select name from information_schema.innodb_metrics where count!=0; +name +set global innodb_monitor_enable = "%lock%"; +select name from information_schema.innodb_metrics +where status != IF(name like "%lock%", 'enabled', 'disabled'); +name +set global innodb_monitor_disable = "%lock%"; +select name, status from information_schema.innodb_metrics +where name like "%lock%"; +name status +lock_deadlocks disabled +lock_deadlock_false_positives disabled +lock_deadlock_rounds disabled +lock_threads_waiting disabled +lock_timeouts disabled +lock_rec_lock_waits disabled +lock_table_lock_waits disabled +lock_rec_lock_requests disabled +lock_rec_release_attempts disabled +lock_rec_grant_attempts disabled +lock_rec_lock_created disabled +lock_rec_lock_removed disabled +lock_rec_locks disabled +lock_table_lock_created disabled +lock_table_lock_removed disabled +lock_table_locks disabled +lock_row_lock_current_waits disabled +lock_row_lock_time disabled +lock_row_lock_time_max disabled +lock_row_lock_waits disabled +lock_row_lock_time_avg disabled +lock_schedule_refreshes disabled +log_full_block_writes disabled +log_partial_block_writes disabled +innodb_rwlock_s_spin_waits disabled +innodb_rwlock_x_spin_waits disabled +innodb_rwlock_sx_spin_waits disabled +innodb_rwlock_s_spin_rounds disabled +innodb_rwlock_x_spin_rounds disabled +innodb_rwlock_sx_spin_rounds disabled +innodb_rwlock_s_os_waits disabled +innodb_rwlock_x_os_waits disabled +innodb_rwlock_sx_os_waits disabled +page_track_partial_block_writes disabled +page_track_full_block_writes disabled +set global innodb_monitor_enable = "%lock*"; +ERROR 42000: Variable 'innodb_monitor_enable' can't be set to the value of '%lock*' +set global innodb_monitor_enable="%%%%%%%%%%%%%%%%%%%%%%%%%%%"; +select name from information_schema.innodb_metrics where status!='enabled'; +name +set global innodb_monitor_disable="%%%%%"; +select name from information_schema.innodb_metrics where status!='disabled'; +name +set global innodb_monitor_enable="%"; +select name from information_schema.innodb_metrics where status!='enabled'; +name +set global innodb_monitor_disable="%_%"; +select name from information_schema.innodb_metrics where status!='disabled'; +name +set global innodb_monitor_enable="log%%%%"; +select name from information_schema.innodb_metrics +where status != IF(name like "log%", 'enabled', 'disabled'); +name +set global innodb_monitor_enable="os_%a_fs_ncs"; +set global innodb_monitor_enable="os%pending%"; +select name, status from information_schema.innodb_metrics +where name like "os%"; +name status +os_data_reads disabled +os_data_writes disabled +os_data_fsyncs enabled +os_pending_reads enabled +os_pending_writes enabled +os_log_bytes_written disabled +os_log_fsyncs disabled +os_log_pending_fsyncs enabled +os_log_pending_writes enabled +set global innodb_monitor_enable=""; +ERROR 42000: Variable 'innodb_monitor_enable' can't be set to the value of '' +set global innodb_monitor_enable="_"; +ERROR 42000: Variable 'innodb_monitor_enable' can't be set to the value of '_' +SET global innodb_monitor_disable = module_metadata; +SET global innodb_monitor_reset_all = module_metadata; +set global innodb_monitor_enable = metadata_table_handles_opened; +create table monitor_test(col int) engine = innodb; +select * from monitor_test; +col +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name = "metadata_table_handles_opened"; +name max_count min_count count max_count_reset min_count_reset count_reset status +metadata_table_handles_opened 3 NULL 3 3 NULL 3 enabled +set global innodb_monitor_reset = metadata_table_handles_opened; +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name = "metadata_table_handles_opened"; +name max_count min_count count max_count_reset min_count_reset count_reset status +metadata_table_handles_opened 3 NULL 3 NULL NULL 0 enabled +drop table monitor_test; +create table monitor_test(col int) engine = innodb; +select * from monitor_test; +col +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name = "metadata_table_handles_opened"; +name max_count min_count count max_count_reset min_count_reset count_reset status +metadata_table_handles_opened 6 NULL 6 3 NULL 3 enabled +set global innodb_monitor_reset_all = metadata_table_handles_opened; +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name = "metadata_table_handles_opened"; +name max_count min_count count max_count_reset min_count_reset count_reset status +metadata_table_handles_opened 6 NULL 6 3 NULL 3 enabled +set global innodb_monitor_disable = metadata_table_handles_opened; +set global innodb_monitor_reset = metadata_table_handles_opened; +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name = "metadata_table_handles_opened"; +name max_count min_count count max_count_reset min_count_reset count_reset status +metadata_table_handles_opened 6 NULL 6 NULL NULL 0 disabled +drop table monitor_test; +create table monitor_test(col int) engine = innodb; +select * from monitor_test; +col +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name = "metadata_table_handles_opened"; +name max_count min_count count max_count_reset min_count_reset count_reset status +metadata_table_handles_opened 6 NULL 6 NULL NULL 0 disabled +set global innodb_monitor_reset_all = metadata_table_handles_opened; +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name = "metadata_table_handles_opened"; +name max_count min_count count max_count_reset min_count_reset count_reset status +metadata_table_handles_opened NULL NULL 0 NULL NULL 0 disabled +set global innodb_monitor_enable = metadata_table_handles_opened; +drop table monitor_test; +create table monitor_test(col int) engine = innodb stats_persistent=0; +select * from monitor_test; +col +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name = "metadata_table_handles_opened"; +name max_count min_count count max_count_reset min_count_reset count_reset status +metadata_table_handles_opened 3 NULL 3 3 NULL 3 enabled +set global innodb_monitor_enable = metadata_table_handles_closed; +create index idx on monitor_test(col); +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name = "metadata_table_handles_closed"; +name max_count min_count count max_count_reset min_count_reset count_reset status +metadata_table_handles_closed 3 NULL 3 3 NULL 3 enabled +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name like "metadata%"; +name max_count min_count count max_count_reset min_count_reset count_reset status +metadata_table_handles_opened 4 NULL 4 4 NULL 4 enabled +metadata_table_handles_closed 3 NULL 3 3 NULL 3 enabled +metadata_table_reference_count NULL NULL 0 NULL NULL 0 disabled +set global innodb_monitor_disable = module_metadata; +set global innodb_monitor_reset = module_metadata; +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name like "metadata%"; +name max_count min_count count max_count_reset min_count_reset count_reset status +metadata_table_handles_opened 4 NULL 4 NULL NULL 0 disabled +metadata_table_handles_closed 3 NULL 3 NULL NULL 0 disabled +metadata_table_reference_count NULL NULL 0 NULL NULL 0 disabled +set global innodb_monitor_reset_all = module_metadata; +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name like "metadata%"; +name max_count min_count count max_count_reset min_count_reset count_reset status +metadata_table_handles_opened NULL NULL 0 NULL NULL 0 disabled +metadata_table_handles_closed NULL NULL 0 NULL NULL 0 disabled +metadata_table_reference_count NULL NULL 0 NULL NULL 0 disabled +set global innodb_monitor_enable = module_trx; +begin; +insert into monitor_test values(9); +commit; +begin; +insert into monitor_test values(9); +rollback; +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name like "trx_rollbacks" or name like "trx_active_transactions"; +name max_count min_count count max_count_reset min_count_reset count_reset status +trx_rollbacks 1 NULL 1 1 NULL 1 enabled +trx_active_transactions 1 0 0 1 0 0 enabled +set global innodb_monitor_disable = module_trx; +set global innodb_monitor_enable = module_dml; +insert into monitor_test values(9); +update monitor_test set col = 10 where col = 9; +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name like "dml%"; +name max_count min_count count max_count_reset min_count_reset count_reset status +dml_reads 4 NULL 4 4 NULL 4 enabled +dml_inserts 1 NULL 1 1 NULL 1 enabled +dml_deletes 0 NULL 0 0 NULL 0 enabled +dml_updates 2 NULL 2 2 NULL 2 enabled +dml_system_reads 0 NULL 0 0 NULL 0 enabled +dml_system_inserts 0 NULL 0 0 NULL 0 enabled +dml_system_deletes 0 NULL 0 0 NULL 0 enabled +dml_system_updates 0 NULL 0 0 NULL 0 enabled +delete from monitor_test; +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name like "dml%"; +name max_count min_count count max_count_reset min_count_reset count_reset status +dml_reads 6 NULL 6 6 NULL 6 enabled +dml_inserts 1 NULL 1 1 NULL 1 enabled +dml_deletes 2 NULL 2 2 NULL 2 enabled +dml_updates 2 NULL 2 2 NULL 2 enabled +dml_system_reads 0 NULL 0 0 NULL 0 enabled +dml_system_inserts 0 NULL 0 0 NULL 0 enabled +dml_system_deletes 0 NULL 0 0 NULL 0 enabled +dml_system_updates 0 NULL 0 0 NULL 0 enabled +set global innodb_monitor_reset = module_dml; +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name like "dml%"; +name max_count min_count count max_count_reset min_count_reset count_reset status +dml_reads 6 NULL 6 0 NULL 0 enabled +dml_inserts 1 NULL 1 0 NULL 0 enabled +dml_deletes 2 NULL 2 0 NULL 0 enabled +dml_updates 2 NULL 2 0 NULL 0 enabled +dml_system_reads 0 NULL 0 0 NULL 0 enabled +dml_system_inserts 0 NULL 0 0 NULL 0 enabled +dml_system_deletes 0 NULL 0 0 NULL 0 enabled +dml_system_updates 0 NULL 0 0 NULL 0 enabled +insert into monitor_test values(9); +insert into monitor_test values(1); +delete from monitor_test; +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name like "dml%"; +name max_count min_count count max_count_reset min_count_reset count_reset status +dml_reads 8 NULL 8 2 NULL 2 enabled +dml_inserts 3 NULL 3 2 NULL 2 enabled +dml_deletes 4 NULL 4 2 NULL 2 enabled +dml_updates 2 NULL 2 0 NULL 0 enabled +dml_system_reads 0 NULL 0 0 NULL 0 enabled +dml_system_inserts 0 NULL 0 0 NULL 0 enabled +dml_system_deletes 0 NULL 0 0 NULL 0 enabled +dml_system_updates 0 NULL 0 0 NULL 0 enabled +set global innodb_monitor_reset_all = module_dml; +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name like "dml%"; +name max_count min_count count max_count_reset min_count_reset count_reset status +dml_reads 8 NULL 8 2 NULL 2 enabled +dml_inserts 3 NULL 3 2 NULL 2 enabled +dml_deletes 4 NULL 4 2 NULL 2 enabled +dml_updates 2 NULL 2 0 NULL 0 enabled +dml_system_reads 0 NULL 0 0 NULL 0 enabled +dml_system_inserts 0 NULL 0 0 NULL 0 enabled +dml_system_deletes 0 NULL 0 0 NULL 0 enabled +dml_system_updates 0 NULL 0 0 NULL 0 enabled +set global innodb_monitor_disable = module_dml; +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name like "dml%"; +name max_count min_count count max_count_reset min_count_reset count_reset status +dml_reads 8 NULL 8 2 NULL 2 disabled +dml_inserts 3 NULL 3 2 NULL 2 disabled +dml_deletes 4 NULL 4 2 NULL 2 disabled +dml_updates 2 NULL 2 0 NULL 0 disabled +dml_system_reads 0 NULL 0 0 NULL 0 disabled +dml_system_inserts 0 NULL 0 0 NULL 0 disabled +dml_system_deletes 0 NULL 0 0 NULL 0 disabled +dml_system_updates 0 NULL 0 0 NULL 0 disabled +set global innodb_monitor_reset_all = module_dml; +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name like "dml%"; +name max_count min_count count max_count_reset min_count_reset count_reset status +dml_reads NULL NULL 0 NULL NULL 0 disabled +dml_inserts NULL NULL 0 NULL NULL 0 disabled +dml_deletes NULL NULL 0 NULL NULL 0 disabled +dml_updates NULL NULL 0 NULL NULL 0 disabled +dml_system_reads NULL NULL 0 NULL NULL 0 disabled +dml_system_inserts NULL NULL 0 NULL NULL 0 disabled +dml_system_deletes NULL NULL 0 NULL NULL 0 disabled +dml_system_updates NULL NULL 0 NULL NULL 0 disabled +set global innodb_monitor_enable = dml_inserts; +insert into monitor_test values(9); +insert into monitor_test values(1); +delete from monitor_test; +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name like "dml%"; +name max_count min_count count max_count_reset min_count_reset count_reset status +dml_reads NULL NULL 0 NULL NULL 0 disabled +dml_inserts 2 NULL 2 2 NULL 2 enabled +dml_deletes NULL NULL 0 NULL NULL 0 disabled +dml_updates NULL NULL 0 NULL NULL 0 disabled +dml_system_reads NULL NULL 0 NULL NULL 0 disabled +dml_system_inserts NULL NULL 0 NULL NULL 0 disabled +dml_system_deletes NULL NULL 0 NULL NULL 0 disabled +dml_system_updates NULL NULL 0 NULL NULL 0 disabled +set global innodb_monitor_disable = module_dml; +drop table monitor_test; +set global innodb_monitor_enable = file_num_open_files; +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name like "file_num_open_files"; +name max_count min_count count max_count_reset min_count_reset count_reset status +file_num_open_files # # # # # # enabled +set global innodb_monitor_disable = file_num_open_files; +set global innodb_monitor_enable = "icp%"; +create table monitor_test(a char(3), b int, c char(2), +primary key (a(1), c(1)), key(b)) engine = innodb; +insert into monitor_test values("13", 2, "aa"); +select a from monitor_test where b < 1 for update; +a +select name, count from information_schema.innodb_metrics +where name like "icp%"; +name count +icp_attempts 1 +icp_no_match 0 +icp_out_of_range 1 +icp_match 0 +select a from monitor_test where b < 3 for update; +a +13 +select name, count from information_schema.innodb_metrics +where name like "icp%"; +name count +icp_attempts 2 +icp_no_match 0 +icp_out_of_range 1 +icp_match 1 +drop table monitor_test; +set global innodb_monitor_disable = All; +set global innodb_monitor_reset_all = all; diff --git a/mysql-test/suite/innodb_monitor_reset_basic.result-pq b/mysql-test/suite/innodb_monitor_reset_basic.result-pq new file mode 100644 index 000000000000..4a858750f7eb --- /dev/null +++ b/mysql-test/suite/innodb_monitor_reset_basic.result-pq @@ -0,0 +1,694 @@ +set global innodb_monitor_disable = All; +select name, status from information_schema.innodb_metrics; +name status +metadata_table_handles_opened disabled +metadata_table_handles_closed disabled +metadata_table_reference_count disabled +lock_deadlocks disabled +lock_deadlock_false_positives disabled +lock_deadlock_rounds disabled +lock_threads_waiting disabled +lock_timeouts disabled +lock_rec_lock_waits disabled +lock_table_lock_waits disabled +lock_rec_lock_requests disabled +lock_rec_release_attempts disabled +lock_rec_grant_attempts disabled +lock_rec_lock_created disabled +lock_rec_lock_removed disabled +lock_rec_locks disabled +lock_table_lock_created disabled +lock_table_lock_removed disabled +lock_table_locks disabled +lock_row_lock_current_waits disabled +lock_row_lock_time disabled +lock_row_lock_time_max disabled +lock_row_lock_waits disabled +lock_row_lock_time_avg disabled +lock_schedule_refreshes disabled +buffer_pool_size disabled +buffer_pool_reads disabled +buffer_pool_read_requests disabled +buffer_pool_write_requests disabled +buffer_pool_wait_free disabled +buffer_pool_read_ahead disabled +buffer_pool_read_ahead_evicted disabled +buffer_pool_pages_total disabled +buffer_pool_pages_misc disabled +buffer_pool_pages_data disabled +buffer_pool_bytes_data disabled +buffer_pool_pages_dirty disabled +buffer_pool_bytes_dirty disabled +buffer_pool_pages_free disabled +buffer_pages_created disabled +buffer_pages_written disabled +buffer_pages_read disabled +buffer_data_reads disabled +buffer_data_written disabled +buffer_flush_batch_scanned disabled +buffer_flush_batch_num_scan disabled +buffer_flush_batch_scanned_per_call disabled +buffer_flush_batch_total_pages disabled +buffer_flush_batches disabled +buffer_flush_batch_pages disabled +buffer_flush_neighbor_total_pages disabled +buffer_flush_neighbor disabled +buffer_flush_neighbor_pages disabled +buffer_flush_n_to_flush_requested disabled +buffer_flush_n_to_flush_by_dirty_page disabled +buffer_flush_n_to_flush_by_age disabled +buffer_flush_adaptive_avg_time_slot disabled +buffer_LRU_batch_flush_avg_time_slot disabled +buffer_flush_adaptive_avg_time_thread disabled +buffer_LRU_batch_flush_avg_time_thread disabled +buffer_flush_adaptive_avg_time_est disabled +buffer_LRU_batch_flush_avg_time_est disabled +buffer_flush_avg_time disabled +buffer_flush_adaptive_avg_pass disabled +buffer_LRU_batch_flush_avg_pass disabled +buffer_flush_avg_pass disabled +buffer_LRU_get_free_loops disabled +buffer_LRU_get_free_waits disabled +buffer_flush_avg_page_rate disabled +buffer_flush_lsn_avg_rate disabled +buffer_flush_pct_for_dirty disabled +buffer_flush_pct_for_lsn disabled +buffer_flush_sync_waits disabled +buffer_flush_adaptive_total_pages disabled +buffer_flush_adaptive disabled +buffer_flush_adaptive_pages disabled +buffer_flush_sync_total_pages disabled +buffer_flush_sync disabled +buffer_flush_sync_pages disabled +buffer_flush_background_total_pages disabled +buffer_flush_background disabled +buffer_flush_background_pages disabled +buffer_LRU_batch_scanned disabled +buffer_LRU_batch_num_scan disabled +buffer_LRU_batch_scanned_per_call disabled +buffer_LRU_batch_flush_total_pages disabled +buffer_LRU_batches_flush disabled +buffer_LRU_batch_flush_pages disabled +buffer_LRU_batch_evict_total_pages disabled +buffer_LRU_batches_evict disabled +buffer_LRU_batch_evict_pages disabled +buffer_LRU_single_flush_scanned disabled +buffer_LRU_single_flush_num_scan disabled +buffer_LRU_single_flush_scanned_per_call disabled +buffer_LRU_single_flush_failure_count disabled +buffer_LRU_get_free_search disabled +buffer_LRU_search_scanned disabled +buffer_LRU_search_num_scan disabled +buffer_LRU_search_scanned_per_call disabled +buffer_LRU_unzip_search_scanned disabled +buffer_LRU_unzip_search_num_scan disabled +buffer_LRU_unzip_search_scanned_per_call disabled +buffer_page_read_index_leaf disabled +buffer_page_read_index_non_leaf disabled +buffer_page_read_index_ibuf_leaf disabled +buffer_page_read_index_ibuf_non_leaf disabled +buffer_page_read_undo_log disabled +buffer_page_read_index_inode disabled +buffer_page_read_ibuf_free_list disabled +buffer_page_read_ibuf_bitmap disabled +buffer_page_read_system_page disabled +buffer_page_read_trx_system disabled +buffer_page_read_fsp_hdr disabled +buffer_page_read_xdes disabled +buffer_page_read_blob disabled +buffer_page_read_zblob disabled +buffer_page_read_zblob2 disabled +buffer_page_read_rseg_array disabled +buffer_page_read_other disabled +buffer_page_written_index_leaf disabled +buffer_page_written_index_non_leaf disabled +buffer_page_written_index_ibuf_leaf disabled +buffer_page_written_index_ibuf_non_leaf disabled +buffer_page_written_undo_log disabled +buffer_page_written_index_inode disabled +buffer_page_written_ibuf_free_list disabled +buffer_page_written_ibuf_bitmap disabled +buffer_page_written_system_page disabled +buffer_page_written_trx_system disabled +buffer_page_written_fsp_hdr disabled +buffer_page_written_xdes disabled +buffer_page_written_blob disabled +buffer_page_written_zblob disabled +buffer_page_written_zblob2 disabled +buffer_page_written_rseg_array disabled +buffer_page_written_other disabled +buffer_page_written_on_log_no_waits disabled +buffer_page_written_on_log_waits disabled +buffer_page_written_on_log_wait_loops disabled +os_data_reads disabled +os_data_writes disabled +os_data_fsyncs disabled +os_pending_reads disabled +os_pending_writes disabled +os_log_bytes_written disabled +os_log_fsyncs disabled +os_log_pending_fsyncs disabled +os_log_pending_writes disabled +trx_rw_commits disabled +trx_ro_commits disabled +trx_nl_ro_commits disabled +trx_commits_insert_update disabled +trx_rollbacks disabled +trx_rollbacks_savepoint disabled +trx_rollback_active disabled +trx_active_transactions disabled +trx_allocations disabled +trx_on_log_no_waits disabled +trx_on_log_waits disabled +trx_on_log_wait_loops disabled +trx_rseg_history_len disabled +trx_undo_slots_used disabled +trx_undo_slots_cached disabled +trx_rseg_current_size disabled +purge_del_mark_records disabled +purge_upd_exist_or_extern_records disabled +purge_invoked disabled +purge_undo_log_pages disabled +purge_dml_delay_usec disabled +purge_stop_count disabled +purge_resume_count disabled +purge_truncate_history_count disabled +purge_truncate_history_usec disabled +undo_truncate_count disabled +undo_truncate_start_logging_count disabled +undo_truncate_done_logging_count disabled +undo_truncate_usec disabled +log_lsn_last_flush disabled +log_lsn_last_checkpoint disabled +log_lsn_current disabled +log_lsn_archived disabled +log_lsn_checkpoint_age disabled +log_lsn_buf_dirty_pages_added disabled +log_lsn_buf_pool_oldest_approx disabled +log_lsn_buf_pool_oldest_lwm disabled +log_max_modified_age_async disabled +log_max_modified_age_sync disabled +log_waits disabled +log_write_requests disabled +log_writes disabled +log_flush_total_time disabled +log_flush_max_time disabled +log_flush_avg_time disabled +log_flush_lsn_avg_rate disabled +log_full_block_writes disabled +log_partial_block_writes disabled +log_padded disabled +log_next_file disabled +log_checkpoints disabled +log_free_space disabled +log_concurrency_margin disabled +log_writer_no_waits disabled +log_writer_waits disabled +log_writer_wait_loops disabled +log_writer_on_file_space_waits disabled +log_writer_on_archiver_waits disabled +log_flusher_no_waits disabled +log_flusher_waits disabled +log_flusher_wait_loops disabled +log_write_notifier_no_waits disabled +log_write_notifier_waits disabled +log_write_notifier_wait_loops disabled +log_flush_notifier_no_waits disabled +log_flush_notifier_waits disabled +log_flush_notifier_wait_loops disabled +log_write_to_file_requests_interval disabled +log_on_write_no_waits disabled +log_on_write_waits disabled +log_on_write_wait_loops disabled +log_on_flush_no_waits disabled +log_on_flush_waits disabled +log_on_flush_wait_loops disabled +log_on_recent_written_wait_loops disabled +log_on_recent_closed_wait_loops disabled +log_on_buffer_space_no_waits disabled +log_on_buffer_space_waits disabled +log_on_buffer_space_wait_loops disabled +log_on_file_space_no_waits disabled +log_on_file_space_waits disabled +log_on_file_space_wait_loops disabled +compress_pages_compressed disabled +compress_pages_decompressed disabled +compression_pad_increments disabled +compression_pad_decrements disabled +index_page_splits disabled +index_page_merge_attempts disabled +index_page_merge_successful disabled +index_page_reorg_attempts disabled +index_page_reorg_successful disabled +index_page_discards disabled +adaptive_hash_searches disabled +adaptive_hash_searches_btree disabled +adaptive_hash_pages_added disabled +adaptive_hash_pages_removed disabled +adaptive_hash_rows_added disabled +adaptive_hash_rows_removed disabled +adaptive_hash_rows_deleted_no_hash_entry disabled +adaptive_hash_rows_updated disabled +file_num_open_files disabled +ibuf_merges_insert disabled +ibuf_merges_delete_mark disabled +ibuf_merges_delete disabled +ibuf_merges_discard_insert disabled +ibuf_merges_discard_delete_mark disabled +ibuf_merges_discard_delete disabled +ibuf_merges disabled +ibuf_size disabled +innodb_master_thread_sleeps disabled +innodb_activity_count disabled +innodb_master_active_loops disabled +innodb_master_idle_loops disabled +innodb_background_drop_table_usec disabled +innodb_ibuf_merge_usec disabled +innodb_mem_validate_usec disabled +innodb_master_purge_usec disabled +innodb_dict_lru_usec disabled +innodb_dict_lru_count disabled +innodb_dblwr_writes disabled +innodb_dblwr_pages_written disabled +innodb_page_size disabled +innodb_rwlock_s_spin_waits disabled +innodb_rwlock_x_spin_waits disabled +innodb_rwlock_sx_spin_waits disabled +innodb_rwlock_s_spin_rounds disabled +innodb_rwlock_x_spin_rounds disabled +innodb_rwlock_sx_spin_rounds disabled +innodb_rwlock_s_os_waits disabled +innodb_rwlock_x_os_waits disabled +innodb_rwlock_sx_os_waits disabled +dml_reads disabled +dml_inserts disabled +dml_deletes disabled +dml_updates disabled +dml_system_reads disabled +dml_system_inserts disabled +dml_system_deletes disabled +dml_system_updates disabled +sampled_pages_read disabled +sampled_pages_skipped disabled +ddl_background_drop_tables disabled +ddl_online_create_index disabled +ddl_pending_alter_table disabled +ddl_sort_file_alter_table disabled +ddl_log_file_alter_table disabled +icp_attempts disabled +icp_no_match disabled +icp_out_of_range disabled +icp_match disabled +module_cpu disabled +cpu_utime_abs disabled +cpu_stime_abs disabled +cpu_utime_pct disabled +cpu_stime_pct disabled +cpu_n disabled +module_page_track disabled +page_track_resets disabled +page_track_partial_block_writes disabled +page_track_full_block_writes disabled +page_track_checkpoint_partial_flush_request disabled +module_dblwr disabled +dblwr_async_requests disabled +dblwr_sync_requests disabled +dblwr_flush_requests disabled +dblwr_flush_wait_events disabled +set global innodb_monitor_enable = all; +create table monitor_test(col int) engine = innodb; +drop table monitor_test; +select name from information_schema.innodb_metrics where status!='enabled'; +name +set global innodb_monitor_enable = aaa; +ERROR 42000: Variable 'innodb_monitor_enable' can't be set to the value of 'aaa' +set global innodb_monitor_disable = All; +select name from information_schema.innodb_metrics where status!='disabled'; +name +set global innodb_monitor_reset_all = all; +select name from information_schema.innodb_metrics where count!=0; +name +set global innodb_monitor_enable = "%lock%"; +select name from information_schema.innodb_metrics +where status != IF(name like "%lock%", 'enabled', 'disabled'); +name +set global innodb_monitor_disable = "%lock%"; +select name, status from information_schema.innodb_metrics +where name like "%lock%"; +name status +lock_deadlocks disabled +lock_deadlock_false_positives disabled +lock_deadlock_rounds disabled +lock_threads_waiting disabled +lock_timeouts disabled +lock_rec_lock_waits disabled +lock_table_lock_waits disabled +lock_rec_lock_requests disabled +lock_rec_release_attempts disabled +lock_rec_grant_attempts disabled +lock_rec_lock_created disabled +lock_rec_lock_removed disabled +lock_rec_locks disabled +lock_table_lock_created disabled +lock_table_lock_removed disabled +lock_table_locks disabled +lock_row_lock_current_waits disabled +lock_row_lock_time disabled +lock_row_lock_time_max disabled +lock_row_lock_waits disabled +lock_row_lock_time_avg disabled +lock_schedule_refreshes disabled +log_full_block_writes disabled +log_partial_block_writes disabled +innodb_rwlock_s_spin_waits disabled +innodb_rwlock_x_spin_waits disabled +innodb_rwlock_sx_spin_waits disabled +innodb_rwlock_s_spin_rounds disabled +innodb_rwlock_x_spin_rounds disabled +innodb_rwlock_sx_spin_rounds disabled +innodb_rwlock_s_os_waits disabled +innodb_rwlock_x_os_waits disabled +innodb_rwlock_sx_os_waits disabled +page_track_partial_block_writes disabled +page_track_full_block_writes disabled +set global innodb_monitor_enable = "%lock*"; +ERROR 42000: Variable 'innodb_monitor_enable' can't be set to the value of '%lock*' +set global innodb_monitor_enable="%%%%%%%%%%%%%%%%%%%%%%%%%%%"; +select name from information_schema.innodb_metrics where status!='enabled'; +name +set global innodb_monitor_disable="%%%%%"; +select name from information_schema.innodb_metrics where status!='disabled'; +name +set global innodb_monitor_enable="%"; +select name from information_schema.innodb_metrics where status!='enabled'; +name +set global innodb_monitor_disable="%_%"; +select name from information_schema.innodb_metrics where status!='disabled'; +name +set global innodb_monitor_enable="log%%%%"; +select name from information_schema.innodb_metrics +where status != IF(name like "log%", 'enabled', 'disabled'); +name +set global innodb_monitor_enable="os_%a_fs_ncs"; +set global innodb_monitor_enable="os%pending%"; +select name, status from information_schema.innodb_metrics +where name like "os%"; +name status +os_data_reads disabled +os_data_writes disabled +os_data_fsyncs enabled +os_pending_reads enabled +os_pending_writes enabled +os_log_bytes_written disabled +os_log_fsyncs disabled +os_log_pending_fsyncs enabled +os_log_pending_writes enabled +set global innodb_monitor_enable=""; +ERROR 42000: Variable 'innodb_monitor_enable' can't be set to the value of '' +set global innodb_monitor_enable="_"; +ERROR 42000: Variable 'innodb_monitor_enable' can't be set to the value of '_' +SET global innodb_monitor_disable = module_metadata; +SET global innodb_monitor_reset_all = module_metadata; +set global innodb_monitor_enable = metadata_table_handles_opened; +create table monitor_test(col int) engine = innodb; +select * from monitor_test; +col +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name = "metadata_table_handles_opened"; +name max_count min_count count max_count_reset min_count_reset count_reset status +metadata_table_handles_opened 3 NULL 3 3 NULL 3 enabled +set global innodb_monitor_reset = metadata_table_handles_opened; +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name = "metadata_table_handles_opened"; +name max_count min_count count max_count_reset min_count_reset count_reset status +metadata_table_handles_opened 3 NULL 3 NULL NULL 0 enabled +drop table monitor_test; +create table monitor_test(col int) engine = innodb; +select * from monitor_test; +col +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name = "metadata_table_handles_opened"; +name max_count min_count count max_count_reset min_count_reset count_reset status +metadata_table_handles_opened 6 NULL 6 3 NULL 3 enabled +set global innodb_monitor_reset_all = metadata_table_handles_opened; +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name = "metadata_table_handles_opened"; +name max_count min_count count max_count_reset min_count_reset count_reset status +metadata_table_handles_opened 6 NULL 6 3 NULL 3 enabled +set global innodb_monitor_disable = metadata_table_handles_opened; +set global innodb_monitor_reset = metadata_table_handles_opened; +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name = "metadata_table_handles_opened"; +name max_count min_count count max_count_reset min_count_reset count_reset status +metadata_table_handles_opened 6 NULL 6 NULL NULL 0 disabled +drop table monitor_test; +create table monitor_test(col int) engine = innodb; +select * from monitor_test; +col +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name = "metadata_table_handles_opened"; +name max_count min_count count max_count_reset min_count_reset count_reset status +metadata_table_handles_opened 6 NULL 6 NULL NULL 0 disabled +set global innodb_monitor_reset_all = metadata_table_handles_opened; +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name = "metadata_table_handles_opened"; +name max_count min_count count max_count_reset min_count_reset count_reset status +metadata_table_handles_opened NULL NULL 0 NULL NULL 0 disabled +set global innodb_monitor_enable = metadata_table_handles_opened; +drop table monitor_test; +create table monitor_test(col int) engine = innodb stats_persistent=0; +select * from monitor_test; +col +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name = "metadata_table_handles_opened"; +name max_count min_count count max_count_reset min_count_reset count_reset status +metadata_table_handles_opened 3 NULL 3 3 NULL 3 enabled +set global innodb_monitor_enable = metadata_table_handles_closed; +create index idx on monitor_test(col); +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name = "metadata_table_handles_closed"; +name max_count min_count count max_count_reset min_count_reset count_reset status +metadata_table_handles_closed 3 NULL 3 3 NULL 3 enabled +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name like "metadata%"; +name max_count min_count count max_count_reset min_count_reset count_reset status +metadata_table_handles_opened 4 NULL 4 4 NULL 4 enabled +metadata_table_handles_closed 3 NULL 3 3 NULL 3 enabled +metadata_table_reference_count NULL NULL 0 NULL NULL 0 disabled +set global innodb_monitor_disable = module_metadata; +set global innodb_monitor_reset = module_metadata; +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name like "metadata%"; +name max_count min_count count max_count_reset min_count_reset count_reset status +metadata_table_handles_opened 4 NULL 4 NULL NULL 0 disabled +metadata_table_handles_closed 3 NULL 3 NULL NULL 0 disabled +metadata_table_reference_count NULL NULL 0 NULL NULL 0 disabled +set global innodb_monitor_reset_all = module_metadata; +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name like "metadata%"; +name max_count min_count count max_count_reset min_count_reset count_reset status +metadata_table_handles_opened NULL NULL 0 NULL NULL 0 disabled +metadata_table_handles_closed NULL NULL 0 NULL NULL 0 disabled +metadata_table_reference_count NULL NULL 0 NULL NULL 0 disabled +set global innodb_monitor_enable = module_trx; +begin; +insert into monitor_test values(9); +commit; +begin; +insert into monitor_test values(9); +rollback; +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name like "trx_rollbacks" or name like "trx_active_transactions"; +name max_count min_count count max_count_reset min_count_reset count_reset status +trx_rollbacks 1 NULL 1 1 NULL 1 enabled +trx_active_transactions 1 0 0 1 0 0 enabled +set global innodb_monitor_disable = module_trx; +set global innodb_monitor_enable = module_dml; +insert into monitor_test values(9); +update monitor_test set col = 10 where col = 9; +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name like "dml%"; +name max_count min_count count max_count_reset min_count_reset count_reset status +dml_reads 4 NULL 4 4 NULL 4 enabled +dml_inserts 1 NULL 1 1 NULL 1 enabled +dml_deletes 0 NULL 0 0 NULL 0 enabled +dml_updates 2 NULL 2 2 NULL 2 enabled +dml_system_reads 0 NULL 0 0 NULL 0 enabled +dml_system_inserts 0 NULL 0 0 NULL 0 enabled +dml_system_deletes 0 NULL 0 0 NULL 0 enabled +dml_system_updates 0 NULL 0 0 NULL 0 enabled +delete from monitor_test; +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name like "dml%"; +name max_count min_count count max_count_reset min_count_reset count_reset status +dml_reads 6 NULL 6 6 NULL 6 enabled +dml_inserts 1 NULL 1 1 NULL 1 enabled +dml_deletes 2 NULL 2 2 NULL 2 enabled +dml_updates 2 NULL 2 2 NULL 2 enabled +dml_system_reads 0 NULL 0 0 NULL 0 enabled +dml_system_inserts 0 NULL 0 0 NULL 0 enabled +dml_system_deletes 0 NULL 0 0 NULL 0 enabled +dml_system_updates 0 NULL 0 0 NULL 0 enabled +set global innodb_monitor_reset = module_dml; +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name like "dml%"; +name max_count min_count count max_count_reset min_count_reset count_reset status +dml_reads 6 NULL 6 0 NULL 0 enabled +dml_inserts 1 NULL 1 0 NULL 0 enabled +dml_deletes 2 NULL 2 0 NULL 0 enabled +dml_updates 2 NULL 2 0 NULL 0 enabled +dml_system_reads 0 NULL 0 0 NULL 0 enabled +dml_system_inserts 0 NULL 0 0 NULL 0 enabled +dml_system_deletes 0 NULL 0 0 NULL 0 enabled +dml_system_updates 0 NULL 0 0 NULL 0 enabled +insert into monitor_test values(9); +insert into monitor_test values(1); +delete from monitor_test; +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name like "dml%"; +name max_count min_count count max_count_reset min_count_reset count_reset status +dml_reads 8 NULL 8 2 NULL 2 enabled +dml_inserts 3 NULL 3 2 NULL 2 enabled +dml_deletes 4 NULL 4 2 NULL 2 enabled +dml_updates 2 NULL 2 0 NULL 0 enabled +dml_system_reads 0 NULL 0 0 NULL 0 enabled +dml_system_inserts 0 NULL 0 0 NULL 0 enabled +dml_system_deletes 0 NULL 0 0 NULL 0 enabled +dml_system_updates 0 NULL 0 0 NULL 0 enabled +set global innodb_monitor_reset_all = module_dml; +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name like "dml%"; +name max_count min_count count max_count_reset min_count_reset count_reset status +dml_reads 8 NULL 8 2 NULL 2 enabled +dml_inserts 3 NULL 3 2 NULL 2 enabled +dml_deletes 4 NULL 4 2 NULL 2 enabled +dml_updates 2 NULL 2 0 NULL 0 enabled +dml_system_reads 0 NULL 0 0 NULL 0 enabled +dml_system_inserts 0 NULL 0 0 NULL 0 enabled +dml_system_deletes 0 NULL 0 0 NULL 0 enabled +dml_system_updates 0 NULL 0 0 NULL 0 enabled +set global innodb_monitor_disable = module_dml; +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name like "dml%"; +name max_count min_count count max_count_reset min_count_reset count_reset status +dml_reads 8 NULL 8 2 NULL 2 disabled +dml_inserts 3 NULL 3 2 NULL 2 disabled +dml_deletes 4 NULL 4 2 NULL 2 disabled +dml_updates 2 NULL 2 0 NULL 0 disabled +dml_system_reads 0 NULL 0 0 NULL 0 disabled +dml_system_inserts 0 NULL 0 0 NULL 0 disabled +dml_system_deletes 0 NULL 0 0 NULL 0 disabled +dml_system_updates 0 NULL 0 0 NULL 0 disabled +set global innodb_monitor_reset_all = module_dml; +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name like "dml%"; +name max_count min_count count max_count_reset min_count_reset count_reset status +dml_reads NULL NULL 0 NULL NULL 0 disabled +dml_inserts NULL NULL 0 NULL NULL 0 disabled +dml_deletes NULL NULL 0 NULL NULL 0 disabled +dml_updates NULL NULL 0 NULL NULL 0 disabled +dml_system_reads NULL NULL 0 NULL NULL 0 disabled +dml_system_inserts NULL NULL 0 NULL NULL 0 disabled +dml_system_deletes NULL NULL 0 NULL NULL 0 disabled +dml_system_updates NULL NULL 0 NULL NULL 0 disabled +set global innodb_monitor_enable = dml_inserts; +insert into monitor_test values(9); +insert into monitor_test values(1); +delete from monitor_test; +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name like "dml%"; +name max_count min_count count max_count_reset min_count_reset count_reset status +dml_reads NULL NULL 0 NULL NULL 0 disabled +dml_inserts 2 NULL 2 2 NULL 2 enabled +dml_deletes NULL NULL 0 NULL NULL 0 disabled +dml_updates NULL NULL 0 NULL NULL 0 disabled +dml_system_reads NULL NULL 0 NULL NULL 0 disabled +dml_system_inserts NULL NULL 0 NULL NULL 0 disabled +dml_system_deletes NULL NULL 0 NULL NULL 0 disabled +dml_system_updates NULL NULL 0 NULL NULL 0 disabled +set global innodb_monitor_disable = module_dml; +drop table monitor_test; +set global innodb_monitor_enable = file_num_open_files; +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name like "file_num_open_files"; +name max_count min_count count max_count_reset min_count_reset count_reset status +file_num_open_files # # # # # # enabled +set global innodb_monitor_disable = file_num_open_files; +set global innodb_monitor_enable = "icp%"; +create table monitor_test(a char(3), b int, c char(2), +primary key (a(1), c(1)), key(b)) engine = innodb; +insert into monitor_test values("13", 2, "aa"); +select a from monitor_test where b < 1 for update; +a +select name, count from information_schema.innodb_metrics +where name like "icp%"; +name count +icp_attempts 1 +icp_no_match 0 +icp_out_of_range 1 +icp_match 0 +select a from monitor_test where b < 3 for update; +a +13 +select name, count from information_schema.innodb_metrics +where name like "icp%"; +name count +icp_attempts 2 +icp_no_match 0 +icp_out_of_range 1 +icp_match 1 +drop table monitor_test; +set global innodb_monitor_disable = All; +set global innodb_monitor_reset_all = all; +set global innodb_monitor_reset_all=0xe7; +ERROR 42000: Variable 'innodb_monitor_reset_all' can't be set to the value of '\xE7' +set global innodb_monitor_enable =0xee; +ERROR 42000: Variable 'innodb_monitor_enable' can't be set to the value of '\xEE' +set global innodb_monitor_reset =0xe9; +ERROR 42000: Variable 'innodb_monitor_reset' can't be set to the value of '\xE9' +set global innodb_monitor_disable =0xed; +ERROR 42000: Variable 'innodb_monitor_disable' can't be set to the value of '\xED' diff --git a/mysql-test/suite/innodb_mysql.result-pq b/mysql-test/suite/innodb_mysql.result-pq new file mode 100644 index 000000000000..52ec4f692093 --- /dev/null +++ b/mysql-test/suite/innodb_mysql.result-pq @@ -0,0 +1,3491 @@ +SET SESSION DEFAULT_STORAGE_ENGINE = InnoDB; +SET SESSION DEFAULT_TMP_STORAGE_ENGINE = InnoDB; +drop table if exists t1,t2,t3,t1m,t1i,t2m,t2i,t4; +drop procedure if exists p1; +create table t1 ( +c_id int(11) not null default '0', +org_id int(11) default null, +unique key contacts$c_id (c_id), +key contacts$org_id (org_id) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t1 values +(2,null),(120,null),(141,null),(218,7), (128,1), +(151,2),(234,2),(236,2),(243,2),(255,2),(259,2),(232,3),(235,3),(238,3), +(246,3),(253,3),(269,3),(285,3),(291,3),(293,3),(131,4),(230,4),(231,4); +create table t2 ( +slai_id int(11) not null default '0', +owner_tbl int(11) default null, +owner_id int(11) default null, +sla_id int(11) default null, +inc_web int(11) default null, +inc_email int(11) default null, +inc_chat int(11) default null, +inc_csr int(11) default null, +inc_total int(11) default null, +time_billed int(11) default null, +activedate timestamp null default null, +expiredate timestamp null default null, +state int(11) default null, +sla_set int(11) default null, +unique key t2$slai_id (slai_id), +key t2$owner_id (owner_id), +key t2$sla_id (sla_id) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t2(slai_id, owner_tbl, owner_id, sla_id) values +(1,3,1,1), (3,3,10,2), (4,3,3,6), (5,3,2,5), (6,3,8,3), (7,3,9,7), +(8,3,6,8), (9,3,4,9), (10,3,5,10), (11,3,11,11), (12,3,7,12); +flush tables; +select si.slai_id +from t1 c join t2 si on +((si.owner_tbl = 3 and si.owner_id = c.org_id) or +( si.owner_tbl = 2 and si.owner_id = c.c_id)) +where +c.c_id = 218 and expiredate is null; +slai_id +12 +select * from t1 where org_id is null; +c_id org_id +2 NULL +120 NULL +141 NULL +select si.slai_id +from t1 c join t2 si on +((si.owner_tbl = 3 and si.owner_id = c.org_id) or +( si.owner_tbl = 2 and si.owner_id = c.c_id)) +where +c.c_id = 218 and expiredate is null; +slai_id +12 +drop table t1, t2; +CREATE TABLE t1 (a int, b int, KEY b (b)); +CREATE TABLE t2 (a int, b int, PRIMARY KEY (a,b)); +CREATE TABLE t3 (a int, b int, c int, PRIMARY KEY (a), +UNIQUE KEY b (b,c), KEY a (a,b,c)); +INSERT INTO t1 VALUES (1, 1); +INSERT INTO t1 SELECT a + 1, b + 1 FROM t1; +INSERT INTO t1 SELECT a + 2, b + 2 FROM t1; +INSERT INTO t2 VALUES (1,1),(1,2),(1,3),(1,4),(1,5),(1,6),(1,7),(1,8); +INSERT INTO t2 SELECT a + 1, b FROM t2; +DELETE FROM t2 WHERE a = 1 AND b < 2; +INSERT INTO t3 VALUES (1,1,1),(2,1,2); +INSERT INTO t3 SELECT a + 2, a + 2, 3 FROM t3; +INSERT INTO t3 SELECT a + 4, a + 4, 3 FROM t3; +SELECT STRAIGHT_JOIN t1.b, t1.a FROM t1, t3, t2 WHERE +t3.a = t2.a AND t2.b = t1.a AND t3.b = 1 AND t3.c IN (1, 2) +ORDER BY t1.b LIMIT 2; +b a +1 1 +2 2 +SELECT STRAIGHT_JOIN t1.b, t1.a FROM t1, t3, t2 WHERE +t3.a = t2.a AND t2.b = t1.a AND t3.b = 1 AND t3.c IN (1, 2) +ORDER BY t1.b LIMIT 5; +b a +1 1 +2 2 +2 2 +3 3 +3 3 +DROP TABLE t1, t2, t3; +CREATE TABLE `t1` (`id1` INT) ; +INSERT INTO `t1` (`id1`) VALUES (1),(5),(2); +CREATE TABLE `t2` ( +`id1` INT, +`id2` INT NOT NULL, +`id3` INT, +`id4` INT NOT NULL, +UNIQUE (`id2`,`id4`), +KEY (`id1`) +); +INSERT INTO `t2`(`id1`,`id2`,`id3`,`id4`) VALUES +(1,1,1,0), +(1,1,2,1), +(5,1,2,2), +(6,1,2,3), +(1,2,2,2), +(1,2,1,1); +SELECT `id1` FROM `t1` WHERE `id1` NOT IN (SELECT `id1` FROM `t2` WHERE `id2` = 1 AND `id3` = 2); +id1 +2 +DROP TABLE t1, t2; +create table t1 (c1 int) engine=innodb; +handler t1 open; +handler t1 read first; +c1 +Before and after comparison +0 +drop table t1; +CREATE TABLE t1(c1 TEXT, UNIQUE (c1(1)), cnt INT DEFAULT 1) +ENGINE=INNODB CHARACTER SET UTF8; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 (c1) VALUES ('1a'); +SELECT * FROM t1; +c1 cnt +1a 1 +INSERT INTO t1 (c1) VALUES ('1b') ON DUPLICATE KEY UPDATE cnt=cnt+1; +SELECT * FROM t1; +c1 cnt +1a 2 +DROP TABLE t1; +CREATE TABLE t1(c1 VARCHAR(2), UNIQUE (c1(1)), cnt INT DEFAULT 1) +ENGINE=INNODB CHARACTER SET UTF8; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 (c1) VALUES ('1a'); +SELECT * FROM t1; +c1 cnt +1a 1 +INSERT INTO t1 (c1) VALUES ('1b') ON DUPLICATE KEY UPDATE cnt=cnt+1; +SELECT * FROM t1; +c1 cnt +1a 2 +DROP TABLE t1; +CREATE TABLE t1(c1 CHAR(2), UNIQUE (c1(1)), cnt INT DEFAULT 1) +ENGINE=INNODB CHARACTER SET UTF8; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 (c1) VALUES ('1a'); +SELECT * FROM t1; +c1 cnt +1a 1 +INSERT INTO t1 (c1) VALUES ('1b') ON DUPLICATE KEY UPDATE cnt=cnt+1; +SELECT * FROM t1; +c1 cnt +1a 2 +DROP TABLE t1; +CREATE TABLE t1 ( +a1 decimal(10,0) DEFAULT NULL, +a2 blob, +a3 time DEFAULT NULL, +a4 blob, +a5 char(175) DEFAULT NULL, +a6 timestamp NOT NULL DEFAULT '2000-01-01 01:01:01', +a7 tinyblob, +INDEX idx (a6,a7(239),a5) +) charset latin1 ENGINE=InnoDB; +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT a4 FROM t1 WHERE +a6=NULL AND +a4='UNcT5pIde4I6c2SheTo4gt92OV1jgJCVkXmzyf325R1DwLURkbYHwhydANIZMbKTgdcR5xS'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a4` AS `a4` from `test`.`t1` where (multiple equal(NULL, `test`.`t1`.`a6`) and multiple equal('UNcT5pIde4I6c2SheTo4gt92OV1jgJCVkXmzyf325R1DwLURkbYHwhydANIZMbKTgdcR5xS', `test`.`t1`.`a4`)) +EXPLAIN SELECT t1.a4 FROM t1, t1 t WHERE +t.a6=t.a6 AND t1.a6=NULL AND +t1.a4='UNcT5pIde4I6c2SheTo4gt92OV1jgJCVkXmzyf325R1DwLURkbYHwhydANIZMbKTgdcR5xS'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a4` AS `a4` from `test`.`t1` join `test`.`t1` `t` where (multiple equal(NULL, `test`.`t1`.`a6`) and multiple equal('UNcT5pIde4I6c2SheTo4gt92OV1jgJCVkXmzyf325R1DwLURkbYHwhydANIZMbKTgdcR5xS', `test`.`t1`.`a4`)) +DROP TABLE t1; +create table t1m (a int) engine = MEMORY; +create table t1i (a int); +create table t2m (a int) engine = MEMORY; +create table t2i (a int); +insert into t2m values (5); +insert into t2i values (5); +select min(a) from t1i; +min(a) +NULL +select min(7) from t1i; +min(7) +NULL +select min(7) from DUAL; +min(7) +7 +explain select min(7) from t2i join t1i; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t2i NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t1i NULL ALL NULL NULL NULL NULL 1 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select min(7) AS `min(7)` from `test`.`t2i` join `test`.`t1i` +select min(7) from t2i join t1i; +min(7) +NULL +select max(a) from t1i; +max(a) +NULL +select max(7) from t1i; +max(7) +NULL +select max(7) from DUAL; +max(7) +7 +explain select max(7) from t2i join t1i; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t2i NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t1i NULL ALL NULL NULL NULL NULL 1 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select max(7) AS `max(7)` from `test`.`t2i` join `test`.`t1i` +select max(7) from t2i join t1i; +max(7) +NULL +select 1, min(a) from t1i where a=99; +1 min(a) +1 NULL +select 1, min(a) from t1i where 1=99; +1 min(a) +1 NULL +select 1, min(1) from t1i where a=99; +1 min(1) +1 NULL +select 1, min(1) from t1i where 1=99; +1 min(1) +1 NULL +select 1, max(a) from t1i where a=99; +1 max(a) +1 NULL +select 1, max(a) from t1i where 1=99; +1 max(a) +1 NULL +select 1, max(1) from t1i where a=99; +1 max(1) +1 NULL +select 1, max(1) from t1i where 1=99; +1 max(1) +1 NULL +explain select count(*), min(7), max(7) from t1m, t1i; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select count(0) AS `count(*)`,min(7) AS `min(7)`,max(7) AS `max(7)` from `test`.`t1m` join `test`.`t1i` +select count(*), min(7), max(7) from t1m, t1i; +count(*) min(7) max(7) +0 NULL NULL +explain select count(*), min(7), max(7) from t1m, t2i; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select count(0) AS `count(*)`,min(7) AS `min(7)`,max(7) AS `max(7)` from `test`.`t1m` join `test`.`t2i` +select count(*), min(7), max(7) from t1m, t2i; +count(*) min(7) max(7) +0 NULL NULL +explain select count(*), min(7), max(7) from t2m, t1i; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2m NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t1i NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select count(0) AS `count(*)`,min(7) AS `min(7)`,max(7) AS `max(7)` from `test`.`t1i` +select count(*), min(7), max(7) from t2m, t1i; +count(*) min(7) max(7) +0 NULL NULL +drop table t1m, t1i, t2m, t2i; +create table t1 ( +a1 char(64), a2 char(64), b char(16), c char(16) not null, d char(16), dummy char(64) default ' ' +) ENGINE = MEMORY; +insert into t1 (a1, a2, b, c, d) values +('a','a','a','a111','xy1'),('a','a','a','b111','xy2'),('a','a','a','c111','xy3'),('a','a','a','d111','xy4'), +('a','a','b','e112','xy1'),('a','a','b','f112','xy2'),('a','a','b','g112','xy3'),('a','a','b','h112','xy4'), +('a','b','a','i121','xy1'),('a','b','a','j121','xy2'),('a','b','a','k121','xy3'),('a','b','a','l121','xy4'), +('a','b','b','m122','xy1'),('a','b','b','n122','xy2'),('a','b','b','o122','xy3'),('a','b','b','p122','xy4'), +('b','a','a','a211','xy1'),('b','a','a','b211','xy2'),('b','a','a','c211','xy3'),('b','a','a','d211','xy4'), +('b','a','b','e212','xy1'),('b','a','b','f212','xy2'),('b','a','b','g212','xy3'),('b','a','b','h212','xy4'), +('b','b','a','i221','xy1'),('b','b','a','j221','xy2'),('b','b','a','k221','xy3'),('b','b','a','l221','xy4'), +('b','b','b','m222','xy1'),('b','b','b','n222','xy2'),('b','b','b','o222','xy3'),('b','b','b','p222','xy4'), +('c','a','a','a311','xy1'),('c','a','a','b311','xy2'),('c','a','a','c311','xy3'),('c','a','a','d311','xy4'), +('c','a','b','e312','xy1'),('c','a','b','f312','xy2'),('c','a','b','g312','xy3'),('c','a','b','h312','xy4'), +('c','b','a','i321','xy1'),('c','b','a','j321','xy2'),('c','b','a','k321','xy3'),('c','b','a','l321','xy4'), +('c','b','b','m322','xy1'),('c','b','b','n322','xy2'),('c','b','b','o322','xy3'),('c','b','b','p322','xy4'), +('d','a','a','a411','xy1'),('d','a','a','b411','xy2'),('d','a','a','c411','xy3'),('d','a','a','d411','xy4'), +('d','a','b','e412','xy1'),('d','a','b','f412','xy2'),('d','a','b','g412','xy3'),('d','a','b','h412','xy4'), +('d','b','a','i421','xy1'),('d','b','a','j421','xy2'),('d','b','a','k421','xy3'),('d','b','a','l421','xy4'), +('d','b','b','m422','xy1'),('d','b','b','n422','xy2'),('d','b','b','o422','xy3'),('d','b','b','p422','xy4'), +('a','a','a','a111','xy1'),('a','a','a','b111','xy2'),('a','a','a','c111','xy3'),('a','a','a','d111','xy4'), +('a','a','b','e112','xy1'),('a','a','b','f112','xy2'),('a','a','b','g112','xy3'),('a','a','b','h112','xy4'), +('a','b','a','i121','xy1'),('a','b','a','j121','xy2'),('a','b','a','k121','xy3'),('a','b','a','l121','xy4'), +('a','b','b','m122','xy1'),('a','b','b','n122','xy2'),('a','b','b','o122','xy3'),('a','b','b','p122','xy4'), +('b','a','a','a211','xy1'),('b','a','a','b211','xy2'),('b','a','a','c211','xy3'),('b','a','a','d211','xy4'), +('b','a','b','e212','xy1'),('b','a','b','f212','xy2'),('b','a','b','g212','xy3'),('b','a','b','h212','xy4'), +('b','b','a','i221','xy1'),('b','b','a','j221','xy2'),('b','b','a','k221','xy3'),('b','b','a','l221','xy4'), +('b','b','b','m222','xy1'),('b','b','b','n222','xy2'),('b','b','b','o222','xy3'),('b','b','b','p222','xy4'), +('c','a','a','a311','xy1'),('c','a','a','b311','xy2'),('c','a','a','c311','xy3'),('c','a','a','d311','xy4'), +('c','a','b','e312','xy1'),('c','a','b','f312','xy2'),('c','a','b','g312','xy3'),('c','a','b','h312','xy4'), +('c','b','a','i321','xy1'),('c','b','a','j321','xy2'),('c','b','a','k321','xy3'),('c','b','a','l321','xy4'), +('c','b','b','m322','xy1'),('c','b','b','n322','xy2'),('c','b','b','o322','xy3'),('c','b','b','p322','xy4'), +('d','a','a','a411','xy1'),('d','a','a','b411','xy2'),('d','a','a','c411','xy3'),('d','a','a','d411','xy4'), +('d','a','b','e412','xy1'),('d','a','b','f412','xy2'),('d','a','b','g412','xy3'),('d','a','b','h412','xy4'), +('d','b','a','i421','xy1'),('d','b','a','j421','xy2'),('d','b','a','k421','xy3'),('d','b','a','l421','xy4'), +('d','b','b','m422','xy1'),('d','b','b','n422','xy2'),('d','b','b','o422','xy3'),('d','b','b','p422','xy4'); +create table t4 ( +pk_col int auto_increment primary key, a1 char(64), a2 char(64), b char(16), c char(16) not null, d char(16), dummy char(64) default ' ' +); +insert into t4 (a1, a2, b, c, d, dummy) select * from t1; +create index idx12672_0 on t4 (a1); +create index idx12672_1 on t4 (a1,a2,b,c); +create index idx12672_2 on t4 (a1,a2,b); +analyze table t4; +Table Op Msg_type Msg_text +test.t4 analyze status OK +select distinct a1 from t4 where pk_col not in (1,2,3,4); +a1 +a +b +c +d +drop table t1,t4; +DROP TABLE IF EXISTS t2, t1; +CREATE TABLE t1 (i INT NOT NULL PRIMARY KEY) ENGINE= InnoDB; +CREATE TABLE t2 ( +i INT NOT NULL, +FOREIGN KEY (i) REFERENCES t1 (i) ON DELETE NO ACTION +) ENGINE= InnoDB; +INSERT INTO t1 VALUES (1); +INSERT INTO t2 VALUES (1); +DELETE IGNORE FROM t1 WHERE i = 1; +Warnings: +Warning 1451 Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`i`) REFERENCES `t1` (`i`)) +SELECT * FROM t1, t2; +i i +1 1 +DROP TABLE t2, t1; +End of 4.1 tests. +create table t1 ( +a varchar(30), b varchar(30), primary key(a), key(b) +); +select distinct a from t1; +a +drop table t1; +create table t1(a int, key(a)); +insert into t1 values(1); +select a, count(a) from t1 group by a with rollup; +a count(a) +1 1 +NULL 1 +drop table t1; +create table t1 (f1 int, f2 char(1), primary key(f1,f2)) stats_persistent=0; +insert into t1 values ( 1,"e"),(2,"a"),( 3,"c"),(4,"d"); +alter table t1 drop primary key, add primary key (f2, f1); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +explain select distinct f1 a, f1 b from t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index PRIMARY PRIMARY 8 NULL 4 100.00 Using index; Using temporary +Warnings: +Note 1003 /* select#1 */ select distinct `test`.`t1`.`f1` AS `a`,`test`.`t1`.`f1` AS `b` from `test`.`t1` +explain select distinct f1, f2 from t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index PRIMARY PRIMARY 8 NULL 4 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select distinct `test`.`t1`.`f1` AS `f1`,`test`.`t1`.`f2` AS `f2` from `test`.`t1` +drop table t1; +CREATE TABLE t1 (id int(11) NOT NULL PRIMARY KEY, name varchar(20), +INDEX (name)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t2 (id int(11) NOT NULL PRIMARY KEY, fkey int(11)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +ALTER TABLE t2 ADD FOREIGN KEY (fkey) REFERENCES t2(id); +INSERT INTO t1 VALUES (1,'A1'),(2,'A2'),(3,'B'); +INSERT INTO t2 VALUES (1,1),(2,2),(3,2),(4,3),(5,3); +EXPLAIN +SELECT COUNT(*) FROM t2 LEFT JOIN t1 ON t2.fkey = t1.id +WHERE t1.name LIKE 'A%'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range PRIMARY,name name 83 NULL 2 100.00 Using where; Using index +2 SIMPLE t2 NULL ref fkey fkey 5 test.t1.id 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t2` join `test`.`t1` where ((`test`.`t2`.`fkey` = `test`.`t1`.`id`) and (`test`.`t1`.`name` like 'A%')) +EXPLAIN +SELECT COUNT(*) FROM t2 LEFT JOIN t1 ON t2.fkey = t1.id +WHERE t1.name LIKE 'A%' OR FALSE; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range PRIMARY,name name 83 NULL 2 100.00 Using where; Using index +2 SIMPLE t2 NULL ref fkey fkey 5 test.t1.id 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t2` join `test`.`t1` where ((`test`.`t2`.`fkey` = `test`.`t1`.`id`) and (`test`.`t1`.`name` like 'A%')) +DROP TABLE t1,t2; +CREATE TABLE t1 ( +id int NOT NULL, +name varchar(20) NOT NULL, +dept varchar(20) NOT NULL, +age tinyint(3) unsigned NOT NULL, +PRIMARY KEY (id), +INDEX (name,dept) +) ENGINE=InnoDB STATS_PERSISTENT=0; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1(id, dept, age, name) VALUES +(3987, 'cs1', 10, 'rs1'), (3988, 'cs2', 20, 'rs1'), (3995, 'cs3', 10, 'rs2'), +(3996, 'cs4', 20, 'rs2'), (4003, 'cs5', 10, 'rs3'), (4004, 'cs6', 20, 'rs3'), +(4011, 'cs7', 10, 'rs4'), (4012, 'cs8', 20, 'rs4'), (4019, 'cs9', 10, 'rs5'), +(4020, 'cs10', 20, 'rs5'),(4027, 'cs11', 10, 'rs6'),(4028, 'cs12', 20, 'rs6'); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +# Masking (#) number in "rows" column of the following EXPLAIN output, as it may vary (bug#47746). +EXPLAIN SELECT DISTINCT t1.name, t1.dept FROM t1 WHERE t1.name='rs5'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ref name name 82 const # 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select distinct `test`.`t1`.`name` AS `name`,`test`.`t1`.`dept` AS `dept` from `test`.`t1` where (`test`.`t1`.`name` = 'rs5') +SELECT DISTINCT t1.name, t1.dept FROM t1 WHERE t1.name='rs5'; +name dept +rs5 cs10 +rs5 cs9 +DELETE FROM t1; +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +# Masking (#) number in "rows" column of the following EXPLAIN output, as it may vary (bug#47746). +EXPLAIN SELECT DISTINCT t1.name, t1.dept FROM t1 WHERE t1.name='rs5'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ref name name 82 const # 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select distinct `test`.`t1`.`name` AS `name`,`test`.`t1`.`dept` AS `dept` from `test`.`t1` where (`test`.`t1`.`name` = 'rs5') +SELECT DISTINCT t1.name, t1.dept FROM t1 WHERE t1.name='rs5'; +name dept +DROP TABLE t1; +drop table if exists t1; +show variables like 'innodb_rollback_on_timeout'; +Variable_name Value +innodb_rollback_on_timeout OFF +create table t1 (a int unsigned not null primary key) engine = innodb; +insert into t1 values (1); +commit; +begin work; +insert into t1 values (2); +select * from t1; +a +1 +2 +begin work; +insert into t1 values (5); +select * from t1; +a +1 +5 +insert into t1 values (2); +ERROR HY000: Lock wait timeout exceeded; try restarting transaction +select * from t1; +a +1 +5 +commit; +select * from t1; +a +1 +2 +commit; +select * from t1; +a +1 +2 +5 +drop table t1; +End of 5.0 tests +# +# Bug#23753319: !M_THD->TRANSACTION_ROLLBACK_REQUEST' AT +# THD::ATTACHABLE_TRX::INIT IN SQL/SQL_C +# +create table t1 (i int); +insert into t1 values (42); +# Grab locks which will block another con from doing select in RR +BEGIN; +select * from t1 for update; +i +42 +# Create competing connection using RR +BEGIN; +set session transaction isolation level repeatable read; +# Will fail and request rollback due to blocking for update +# (prior to fix this would trigger the assert). +create table t2 as select * from t1; +ERROR HY000: Lock wait timeout exceeded; try restarting transaction +# Additional coverage for WL#7743 "New data dictionary: changes +# to DDL-related parts of SE API". Check how rollback is handled +# by similar CTS for non-transactional table. +BEGIN; +create table t2 engine=myisam as select * from t1; +ERROR HY000: Lock wait timeout exceeded; try restarting transaction +# Cleanup +COMMIT; +drop table t1; +create table t1( +id int auto_increment, +c char(1) not null, +counter int not null default 1, +primary key (id), +unique key (c) +) engine=innodb; +insert into t1 (id, c) values +(NULL, 'a'), +(NULL, 'a') +on duplicate key update id = values(id), counter = counter + 1; +Warnings: +Warning 1287 'VALUES function' is deprecated and will be removed in a future release. Please use an alias (INSERT INTO ... VALUES (...) AS alias) and replace VALUES(col) in the ON DUPLICATE KEY UPDATE clause with alias.col instead +select * from t1; +id c counter +2 a 2 +insert into t1 (id, c) values +(NULL, 'b') +on duplicate key update id = values(id), counter = counter + 1; +Warnings: +Warning 1287 'VALUES function' is deprecated and will be removed in a future release. Please use an alias (INSERT INTO ... VALUES (...) AS alias) and replace VALUES(col) in the ON DUPLICATE KEY UPDATE clause with alias.col instead +select * from t1; +id c counter +2 a 2 +3 b 1 +truncate table t1; +insert into t1 (id, c) values (NULL, 'a'); +select * from t1; +id c counter +1 a 1 +insert into t1 (id, c) values (NULL, 'b'), (NULL, 'b') +on duplicate key update id = values(id), c = values(c), counter = counter + 1; +Warnings: +Warning 1287 'VALUES function' is deprecated and will be removed in a future release. Please use an alias (INSERT INTO ... VALUES (...) AS alias) and replace VALUES(col) in the ON DUPLICATE KEY UPDATE clause with alias.col instead +Warning 1287 'VALUES function' is deprecated and will be removed in a future release. Please use an alias (INSERT INTO ... VALUES (...) AS alias) and replace VALUES(col) in the ON DUPLICATE KEY UPDATE clause with alias.col instead +select * from t1; +id c counter +1 a 1 +3 b 2 +insert into t1 (id, c) values (NULL, 'a') +on duplicate key update id = values(id), c = values(c), counter = counter + 1; +Warnings: +Warning 1287 'VALUES function' is deprecated and will be removed in a future release. Please use an alias (INSERT INTO ... VALUES (...) AS alias) and replace VALUES(col) in the ON DUPLICATE KEY UPDATE clause with alias.col instead +Warning 1287 'VALUES function' is deprecated and will be removed in a future release. Please use an alias (INSERT INTO ... VALUES (...) AS alias) and replace VALUES(col) in the ON DUPLICATE KEY UPDATE clause with alias.col instead +select * from t1; +id c counter +3 b 2 +4 a 2 +drop table t1; +SET sql_mode='NO_ENGINE_SUBSTITUTION'; +CREATE TABLE t1( +id int AUTO_INCREMENT PRIMARY KEY, +stat_id int NOT NULL, +acct_id int DEFAULT NULL, +INDEX idx1 (stat_id, acct_id), +INDEX idx2 (acct_id) +) ENGINE=MyISAM; +CREATE TABLE t2( +id int AUTO_INCREMENT PRIMARY KEY, +stat_id int NOT NULL, +acct_id int DEFAULT NULL, +INDEX idx1 (stat_id, acct_id), +INDEX idx2 (acct_id) +) ENGINE=InnoDB STATS_PERSISTENT=0; +INSERT INTO t1(stat_id,acct_id) VALUES +(1,759), (2,831), (3,785), (4,854), (1,921), +(1,553), (2,589), (3,743), (2,827), (2,545), +(4,779), (4,783), (1,597), (1,785), (4,832), +(1,741), (1,833), (3,788), (2,973), (1,907); +INSERT INTO t1(stat_id,acct_id) SELECT stat_id, mod(id+100000, acct_id) FROM t1; +INSERT INTO t1(stat_id,acct_id) SELECT stat_id, mod(id+100000, acct_id) FROM t1; +INSERT INTO t1(stat_id,acct_id) SELECT stat_id, mod(id+100000, acct_id) FROM t1; +INSERT INTO t1(stat_id,acct_id) SELECT stat_id, mod(id+100000, acct_id) FROM t1; +INSERT INTO t1(stat_id,acct_id) SELECT stat_id, mod(id+100000, acct_id) FROM t1; +INSERT INTO t1(stat_id,acct_id) SELECT stat_id, mod(id+100000, acct_id) FROM t1; +INSERT INTO t1(stat_id,acct_id) SELECT stat_id, mod(id+100000, acct_id) FROM t1; +INSERT INTO t1(stat_id,acct_id) SELECT stat_id, mod(id+100000, acct_id) FROM t1; +INSERT INTO t1(stat_id,acct_id) SELECT stat_id, mod(id+100000, acct_id) FROM t1; +INSERT INTO t1(stat_id,acct_id) SELECT stat_id, mod(id+100000, acct_id) FROM t1; +INSERT INTO t1(stat_id,acct_id) SELECT stat_id, mod(id+100000, acct_id) FROM t1; +UPDATE t1 SET acct_id=785 +WHERE MOD(stat_id,2)=0 AND MOD(id,stat_id)=MOD(acct_id,stat_id); +OPTIMIZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 optimize status OK +SELECT COUNT(*) FROM t1; +COUNT(*) +40960 +SELECT COUNT(*) FROM t1 WHERE acct_id=785; +COUNT(*) +8702 +EXPLAIN SELECT COUNT(*) FROM t1 WHERE stat_id IN (1,3) AND acct_id=785; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range idx1,idx2 idx1 9 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where ((`test`.`t1`.`acct_id` = 785) and (`test`.`t1`.`stat_id` in (1,3))) +INSERT INTO t2 SELECT * FROM t1; +OPTIMIZE TABLE t2; +Table Op Msg_type Msg_text +test.t2 optimize note Table does not support optimize, doing recreate + analyze instead +test.t2 optimize status OK +EXPLAIN SELECT COUNT(*) FROM t2 WHERE stat_id IN (1,3) AND acct_id=785; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (2 workers) +2 SIMPLE t2 NULL range idx1,idx2 idx1 9 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t2` where ((`test`.`t2`.`acct_id` = 785) and (`test`.`t2`.`stat_id` in (1,3))) +SET sql_mode=default; +DROP TABLE t1,t2; +create table t1(a int) engine=innodb; +alter table t1 comment '123'; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='123' +drop table t1; +CREATE TABLE t1 (a CHAR(2), KEY (a)) ENGINE = InnoDB DEFAULT CHARSET=UTF8; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES ('uk'),('bg'); +SELECT * FROM t1 WHERE a = 'uk'; +a +uk +DELETE FROM t1 WHERE a = 'uk'; +SELECT * FROM t1 WHERE a = 'uk'; +a +UPDATE t1 SET a = 'us' WHERE a = 'uk'; +SELECT * FROM t1 WHERE a = 'uk'; +a +CREATE TABLE t2 (a CHAR(2), KEY (a)) ENGINE = InnoDB; +INSERT INTO t2 VALUES ('uk'),('bg'); +SELECT * FROM t2 WHERE a = 'uk'; +a +uk +DELETE FROM t2 WHERE a = 'uk'; +SELECT * FROM t2 WHERE a = 'uk'; +a +INSERT INTO t2 VALUES ('uk'); +UPDATE t2 SET a = 'us' WHERE a = 'uk'; +SELECT * FROM t2 WHERE a = 'uk'; +a +CREATE TABLE t3 (a CHAR(2), KEY (a)) ENGINE = MyISAM; +INSERT INTO t3 VALUES ('uk'),('bg'); +SELECT * FROM t3 WHERE a = 'uk'; +a +uk +DELETE FROM t3 WHERE a = 'uk'; +SELECT * FROM t3 WHERE a = 'uk'; +a +INSERT INTO t3 VALUES ('uk'); +UPDATE t3 SET a = 'us' WHERE a = 'uk'; +SELECT * FROM t3 WHERE a = 'uk'; +a +DROP TABLE t1,t2,t3; +CREATE TABLE t1 (a INT) ENGINE=InnoDB; +CREATE TABLE t2 (a INT) ENGINE=InnoDB; +switch to connection c1 +SET AUTOCOMMIT=0; +INSERT INTO t2 VALUES (1); +switch to connection c2 +SET AUTOCOMMIT=0; +SET @old_lock_wait_timeout= @@lock_wait_timeout; +SET lock_wait_timeout= 1; +LOCK TABLES t1 READ, t2 READ; +ERROR HY000: Lock wait timeout exceeded; try restarting transaction +SET @@lock_wait_timeout= @old_lock_wait_timeout; +switch to connection c1 +COMMIT; +INSERT INTO t1 VALUES (1); +switch to connection default +SET AUTOCOMMIT=default; +DROP TABLE t1,t2; +CREATE TABLE t1 ( +id int NOT NULL auto_increment PRIMARY KEY, +b int NOT NULL, +c datetime NOT NULL, +INDEX idx_b(b), +INDEX idx_c(c) +) ENGINE=InnoDB; +CREATE TABLE t2 ( +b int NOT NULL auto_increment PRIMARY KEY, +c datetime NOT NULL +) ENGINE= MyISAM; +INSERT INTO t2(c) VALUES ('2007-01-01'); +INSERT INTO t2(c) SELECT c FROM t2; +INSERT INTO t2(c) SELECT c FROM t2; +INSERT INTO t2(c) SELECT c FROM t2; +INSERT INTO t2(c) SELECT c FROM t2; +INSERT INTO t2(c) SELECT c FROM t2; +INSERT INTO t2(c) SELECT c FROM t2; +INSERT INTO t2(c) SELECT c FROM t2; +INSERT INTO t2(c) SELECT c FROM t2; +INSERT INTO t2(c) SELECT c FROM t2; +INSERT INTO t2(c) SELECT c FROM t2; +INSERT INTO t1(b,c) SELECT b,c FROM t2; +UPDATE t2 SET c='2007-01-02'; +INSERT INTO t1(b,c) SELECT b,c FROM t2; +UPDATE t2 SET c='2007-01-03'; +INSERT INTO t1(b,c) SELECT b,c FROM t2; +set @@sort_buffer_size=8192; +Warnings: +Warning 1292 Truncated incorrect sort_buffer_size value: '8192' +SELECT COUNT(*) FROM t1; +COUNT(*) +3072 +EXPLAIN +SELECT COUNT(*) FROM t1 +WHERE (c >= '2007-01-02' AND c <= '2007-01-03') OR b >= 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # # Parallel execute (4 workers) +2 SIMPLE t1 NULL ALL idx_b,idx_c NULL NULL NULL # # Using where +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (((`test`.`t1`.`c` >= TIMESTAMP'2007-01-02 00:00:00') and (`test`.`t1`.`c` <= TIMESTAMP'2007-01-03 00:00:00')) or (`test`.`t1`.`b` >= 1)) +SELECT COUNT(*) FROM t1 +WHERE (c >= '2007-01-02' AND c <= '2007-01-03') OR b >= 1; +COUNT(*) +3072 +EXPLAIN +SELECT COUNT(*) FROM t1 FORCE INDEX(idx_b, idx_c) +WHERE (c >= '2007-01-02' AND c <= '2007-01-03') OR b >= 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge idx_b,idx_c idx_c,idx_b 5,4 NULL # # Using sort_union(idx_c,idx_b); Using where +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` FORCE INDEX (`idx_c`) FORCE INDEX (`idx_b`) where (((`test`.`t1`.`c` >= TIMESTAMP'2007-01-02 00:00:00') and (`test`.`t1`.`c` <= TIMESTAMP'2007-01-03 00:00:00')) or (`test`.`t1`.`b` >= 1)) +SELECT COUNT(*) FROM t1 FORCE INDEX(idx_b, idx_c) +WHERE (c >= '2007-01-02' AND c <= '2007-01-03') OR b >= 1; +COUNT(*) +3072 +set @@sort_buffer_size=default; +DROP TABLE t1,t2; +CREATE TABLE t1 (a int, b int); +insert into t1 values (1,1),(1,2); +CREATE TABLE t2 (primary key (a)) select * from t1; +ERROR 23000: Duplicate entry '1' for key 't2.PRIMARY' +drop table if exists t2; +Warnings: +Note 1051 Unknown table 'test.t2' +CREATE TEMPORARY TABLE t2 (primary key (a)) select * from t1; +ERROR 23000: Duplicate entry '1' for key 't2.PRIMARY' +drop table if exists t2; +Warnings: +Note 1051 Unknown table 'test.t2' +CREATE TABLE t2 (a int, b int, primary key (a)); +BEGIN; +INSERT INTO t2 values(100,100); +CREATE TABLE IF NOT EXISTS t2 (primary key (a)) select * from t1; +Warnings: +Note 1050 Table 't2' already exists +SELECT * from t2; +a b +100 100 +ROLLBACK; +SELECT * from t2; +a b +100 100 +TRUNCATE table t2; +INSERT INTO t2 select * from t1; +ERROR 23000: Duplicate entry '1' for key 't2.PRIMARY' +SELECT * from t2; +a b +drop table t2; +CREATE TEMPORARY TABLE t2 (a int, b int, primary key (a)); +BEGIN; +INSERT INTO t2 values(100,100); +CREATE TEMPORARY TABLE IF NOT EXISTS t2 (primary key (a)) select * from t1; +Warnings: +Note 1050 Table 't2' already exists +SELECT * from t2; +a b +100 100 +COMMIT; +BEGIN; +INSERT INTO t2 values(101,101); +CREATE TEMPORARY TABLE IF NOT EXISTS t2 (primary key (a)) select * from t1; +Warnings: +Note 1050 Table 't2' already exists +SELECT * from t2; +a b +100 100 +101 101 +ROLLBACK; +SELECT * from t2; +a b +100 100 +TRUNCATE table t2; +INSERT INTO t2 select * from t1; +ERROR 23000: Duplicate entry '1' for key 't2.PRIMARY' +SELECT * from t2; +a b +drop table t1,t2; +CREATE TABLE t1 (a INT PRIMARY KEY, b INT, c FLOAT, KEY b(b)) ENGINE = INNODB; +INSERT INTO t1 VALUES ( 1 , 1 , 1); +INSERT INTO t1 SELECT a + 1 , MOD(a + 1 , 20), 1 FROM t1; +INSERT INTO t1 SELECT a + 2 , MOD(a + 2 , 20), 1 FROM t1; +INSERT INTO t1 SELECT a + 4 , MOD(a + 4 , 20), 1 FROM t1; +INSERT INTO t1 SELECT a + 8 , MOD(a + 8 , 20), 1 FROM t1; +INSERT INTO t1 SELECT a + 16, MOD(a + 16, 20), 1 FROM t1; +INSERT INTO t1 SELECT a + 32, MOD(a + 32, 20), 1 FROM t1; +INSERT INTO t1 SELECT a + 64, MOD(a + 64, 20), 1 FROM t1; +EXPLAIN SELECT b, SUM(c) FROM t1 GROUP BY b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 128 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index b b 5 NULL 128 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`b` AS `b`,sum(`test`.`t1`.`c`) AS `SUM(c)` from `test`.`t1` group by `test`.`t1`.`b` +EXPLAIN SELECT SQL_BIG_RESULT b, SUM(c) FROM t1 GROUP BY b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 128 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL b NULL NULL NULL 128 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select sql_big_result `test`.`t1`.`b` AS `b`,sum(`test`.`t1`.`c`) AS `SUM(c)` from `test`.`t1` group by `test`.`t1`.`b` +DROP TABLE t1; +drop table if exists t1; +show variables like 'innodb_rollback_on_timeout'; +Variable_name Value +innodb_rollback_on_timeout OFF +create table t1 (a int unsigned not null primary key) engine = innodb; +insert into t1 values (1); +commit; +begin work; +insert into t1 values (2); +select * from t1; +a +1 +2 +begin work; +insert into t1 values (5); +select * from t1; +a +1 +5 +insert into t1 values (2); +ERROR HY000: Lock wait timeout exceeded; try restarting transaction +select * from t1; +a +1 +5 +commit; +select * from t1; +a +1 +2 +commit; +select * from t1; +a +1 +2 +5 +drop table t1; +End of 5.0 tests +# +# Bug#23753319: !M_THD->TRANSACTION_ROLLBACK_REQUEST' AT +# THD::ATTACHABLE_TRX::INIT IN SQL/SQL_C +# +create table t1 (i int); +insert into t1 values (42); +# Grab locks which will block another con from doing select in RR +BEGIN; +select * from t1 for update; +i +42 +# Create competing connection using RR +BEGIN; +set session transaction isolation level repeatable read; +# Will fail and request rollback due to blocking for update +# (prior to fix this would trigger the assert). +create table t2 as select * from t1; +ERROR HY000: Lock wait timeout exceeded; try restarting transaction +# Additional coverage for WL#7743 "New data dictionary: changes +# to DDL-related parts of SE API". Check how rollback is handled +# by similar CTS for non-transactional table. +BEGIN; +create table t2 engine=myisam as select * from t1; +ERROR HY000: Lock wait timeout exceeded; try restarting transaction +# Cleanup +COMMIT; +drop table t1; +drop table if exists t1; +create table t1 (a int) engine=innodb; +alter table t1 alter a set default 1; +drop table t1; + +Bug#24918 drop table and lock / inconsistent between +perm and temp tables + +Check transactional tables under LOCK TABLES + +drop table if exists t24918, t24918_tmp, t24918_trans, t24918_trans_tmp, +t24918_access; +create table t24918_access (id int); +create table t24918 (id int) engine=myisam; +create temporary table t24918_tmp (id int) engine=myisam; +create table t24918_trans (id int) engine=innodb; +create temporary table t24918_trans_tmp (id int) engine=innodb; +lock table t24918 write, t24918_tmp write, t24918_trans write, t24918_trans_tmp write; +drop table t24918; +select * from t24918_access; +ERROR HY000: Table 't24918_access' was not locked with LOCK TABLES +drop table t24918_trans; +select * from t24918_access; +ERROR HY000: Table 't24918_access' was not locked with LOCK TABLES +drop table t24918_trans_tmp; +select * from t24918_access; +ERROR HY000: Table 't24918_access' was not locked with LOCK TABLES +drop table t24918_tmp; +select * from t24918_access; +ERROR HY000: Table 't24918_access' was not locked with LOCK TABLES +unlock tables; +drop table t24918_access; +CREATE TABLE t1 (a int, b int, PRIMARY KEY (a), KEY bkey (b)) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1,2),(3,2),(2,2),(4,2),(5,2),(6,2),(7,2),(8,2); +INSERT INTO t1 SELECT a + 8, 2 FROM t1; +INSERT INTO t1 SELECT a + 16, 1 FROM t1; +EXPLAIN SELECT * FROM t1 WHERE b=2 ORDER BY a; +id 1 +select_type SIMPLE +table +partitions NULL +type ALL +possible_keys NULL +key NULL +key_len NULL +ref NULL +rows 16 +filtered 100.00 +Extra Parallel execute (1 workers) +id 2 +select_type SIMPLE +table t1 +partitions NULL +type ref +possible_keys bkey +key bkey +key_len 5 +ref const +rows 16 +filtered 100.00 +Extra Using index +Warnings: +Level Note +Code 1003 +Message /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (`test`.`t1`.`b` = 2) order by `test`.`t1`.`a` +SELECT * FROM t1 WHERE b=2 ORDER BY a; +a b +1 2 +2 2 +3 2 +4 2 +5 2 +6 2 +7 2 +8 2 +9 2 +10 2 +11 2 +12 2 +13 2 +14 2 +15 2 +16 2 +EXPLAIN SELECT * FROM t1 WHERE b BETWEEN 1 AND 2 ORDER BY a; +id 1 +select_type SIMPLE +table +partitions NULL +type ALL +possible_keys NULL +key NULL +key_len NULL +ref NULL +rows 32 +filtered 100.00 +Extra Parallel execute (1 workers) +id 2 +select_type SIMPLE +table t1 +partitions NULL +type index +possible_keys bkey +key PRIMARY +key_len 4 +ref NULL +rows 32 +filtered 100.00 +Extra Using where +Warnings: +Level Note +Code 1003 +Message /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (`test`.`t1`.`b` between 1 and 2) order by `test`.`t1`.`a` +SELECT * FROM t1 WHERE b BETWEEN 1 AND 2 ORDER BY a; +a b +1 2 +2 2 +3 2 +4 2 +5 2 +6 2 +7 2 +8 2 +9 2 +10 2 +11 2 +12 2 +13 2 +14 2 +15 2 +16 2 +17 1 +18 1 +19 1 +20 1 +21 1 +22 1 +23 1 +24 1 +25 1 +26 1 +27 1 +28 1 +29 1 +30 1 +31 1 +32 1 +EXPLAIN SELECT * FROM t1 WHERE b BETWEEN 1 AND 2 ORDER BY b,a; +id 1 +select_type SIMPLE +table +partitions NULL +type ALL +possible_keys NULL +key NULL +key_len NULL +ref NULL +rows 32 +filtered 100.00 +Extra Parallel execute (1 workers) +id 2 +select_type SIMPLE +table t1 +partitions NULL +type index +possible_keys bkey +key bkey +key_len 5 +ref NULL +rows 32 +filtered 100.00 +Extra Using where; Using index +Warnings: +Level Note +Code 1003 +Message /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (`test`.`t1`.`b` between 1 and 2) order by `test`.`t1`.`b`,`test`.`t1`.`a` +SELECT * FROM t1 WHERE b BETWEEN 1 AND 2 ORDER BY b,a; +a b +17 1 +18 1 +19 1 +20 1 +21 1 +22 1 +23 1 +24 1 +25 1 +26 1 +27 1 +28 1 +29 1 +30 1 +31 1 +32 1 +1 2 +2 2 +3 2 +4 2 +5 2 +6 2 +7 2 +8 2 +9 2 +10 2 +11 2 +12 2 +13 2 +14 2 +15 2 +16 2 +CREATE TABLE t2 (a int, b int, c int, PRIMARY KEY (a), KEY bkey (b,c)) +ENGINE=InnoDB; +INSERT INTO t2 VALUES (1,1,1),(3,1,1),(2,1,1),(4,1,1); +INSERT INTO t2 SELECT a + 4, 1, 1 FROM t2; +INSERT INTO t2 SELECT a + 8, 1, 1 FROM t2; +EXPLAIN SELECT * FROM t2 WHERE b=1 ORDER BY a; +id 1 +select_type SIMPLE +table +partitions NULL +type ALL +possible_keys NULL +key NULL +key_len NULL +ref NULL +rows 16 +filtered 100.00 +Extra Parallel execute (1 workers) +id 2 +select_type SIMPLE +table t2 +partitions NULL +type ref +possible_keys bkey +key bkey +key_len 5 +ref const +rows 16 +filtered 100.00 +Extra Using index; Using filesort +Warnings: +Level Note +Code 1003 +Message /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c` from `test`.`t2` where (`test`.`t2`.`b` = 1) order by `test`.`t2`.`a` +SELECT * FROM t2 WHERE b=1 ORDER BY a; +a b c +1 1 1 +2 1 1 +3 1 1 +4 1 1 +5 1 1 +6 1 1 +7 1 1 +8 1 1 +9 1 1 +10 1 1 +11 1 1 +12 1 1 +13 1 1 +14 1 1 +15 1 1 +16 1 1 +EXPLAIN SELECT * FROM t2 WHERE b=1 AND c=1 ORDER BY a; +id 1 +select_type SIMPLE +table +partitions NULL +type ALL +possible_keys NULL +key NULL +key_len NULL +ref NULL +rows 16 +filtered 100.00 +Extra Parallel execute (1 workers) +id 2 +select_type SIMPLE +table t2 +partitions NULL +type ref +possible_keys bkey +key bkey +key_len 10 +ref const,const +rows 16 +filtered 100.00 +Extra Using index +Warnings: +Level Note +Code 1003 +Message /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c` from `test`.`t2` where ((`test`.`t2`.`c` = 1) and (`test`.`t2`.`b` = 1)) order by `test`.`t2`.`a` +SELECT * FROM t2 WHERE b=1 AND c=1 ORDER BY a; +a b c +1 1 1 +2 1 1 +3 1 1 +4 1 1 +5 1 1 +6 1 1 +7 1 1 +8 1 1 +9 1 1 +10 1 1 +11 1 1 +12 1 1 +13 1 1 +14 1 1 +15 1 1 +16 1 1 +EXPLAIN SELECT * FROM t2 WHERE b=1 AND c=1 ORDER BY b,c,a; +id 1 +select_type SIMPLE +table +partitions NULL +type ALL +possible_keys NULL +key NULL +key_len NULL +ref NULL +rows 16 +filtered 100.00 +Extra Parallel execute (1 workers) +id 2 +select_type SIMPLE +table t2 +partitions NULL +type ref +possible_keys bkey +key bkey +key_len 10 +ref const,const +rows 16 +filtered 100.00 +Extra Using index +Warnings: +Level Note +Code 1003 +Message /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c` from `test`.`t2` where ((`test`.`t2`.`c` = 1) and (`test`.`t2`.`b` = 1)) order by `test`.`t2`.`b`,`test`.`t2`.`c`,`test`.`t2`.`a` +SELECT * FROM t2 WHERE b=1 AND c=1 ORDER BY b,c,a; +a b c +1 1 1 +2 1 1 +3 1 1 +4 1 1 +5 1 1 +6 1 1 +7 1 1 +8 1 1 +9 1 1 +10 1 1 +11 1 1 +12 1 1 +13 1 1 +14 1 1 +15 1 1 +16 1 1 +EXPLAIN SELECT * FROM t2 WHERE b=1 AND c=1 ORDER BY c,a; +id 1 +select_type SIMPLE +table +partitions NULL +type ALL +possible_keys NULL +key NULL +key_len NULL +ref NULL +rows 16 +filtered 100.00 +Extra Parallel execute (1 workers) +id 2 +select_type SIMPLE +table t2 +partitions NULL +type ref +possible_keys bkey +key bkey +key_len 10 +ref const,const +rows 16 +filtered 100.00 +Extra Using index +Warnings: +Level Note +Code 1003 +Message /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c` from `test`.`t2` where ((`test`.`t2`.`c` = 1) and (`test`.`t2`.`b` = 1)) order by `test`.`t2`.`c`,`test`.`t2`.`a` +SELECT * FROM t2 WHERE b=1 AND c=1 ORDER BY c,a; +a b c +1 1 1 +2 1 1 +3 1 1 +4 1 1 +5 1 1 +6 1 1 +7 1 1 +8 1 1 +9 1 1 +10 1 1 +11 1 1 +12 1 1 +13 1 1 +14 1 1 +15 1 1 +16 1 1 +DROP TABLE t1,t2; +CREATE TABLE t1 (a INT, PRIMARY KEY (a)) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1),(2),(3),(4),(5),(6),(7),(8); +INSERT INTO t1 SELECT a + 8 FROM t1; +INSERT INTO t1 SELECT a + 16 FROM t1; +CREATE PROCEDURE p1 () +BEGIN +DECLARE i INT DEFAULT 50; +DECLARE cnt INT; +# Continue even in the presence of ER_LOCK_DEADLOCK. +DECLARE CONTINUE HANDLER FOR 1213 BEGIN END; +START TRANSACTION; +ALTER TABLE t1 ENGINE=InnoDB; +COMMIT; +START TRANSACTION; +WHILE (i > 0) DO +SET i = i - 1; +SELECT COUNT(*) INTO cnt FROM t1 LOCK IN SHARE MODE; +END WHILE; +COMMIT; +END;| +CALL p1(); +CALL p1(); +CALL p1(); +DROP PROCEDURE p1; +DROP TABLE t1; +SET sql_mode='NO_ENGINE_SUBSTITUTION'; +create table t1(a text) engine=innodb row_format=dynamic default charset=utf8; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +insert into t1 values('aaa'); +alter table t1 add index(a(1025)); +Warnings: +Warning 1071 Specified key was too long; max key length is 3072 bytes +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` text, + KEY `a` (`a`(1024)) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 ROW_FORMAT=DYNAMIC +drop table t1; +SET sql_mode=default; +CREATE TABLE t1 ( +a INT, +b INT, +KEY (b) +) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1,10), (2,10), (2,20), (3,30); +START TRANSACTION; +SELECT * FROM t1 WHERE b=20 FOR UPDATE; +a b +2 20 +START TRANSACTION; +SELECT * FROM t1 WHERE b=10 ORDER BY A FOR UPDATE; +a b +1 10 +2 10 +ROLLBACK; +ROLLBACK; +DROP TABLE t1; +CREATE TABLE t1( +a INT, +b INT NOT NULL, +c INT NOT NULL, +d INT, +UNIQUE KEY (c,b) +) engine=innodb; +INSERT INTO t1 VALUES (1,1,1,50), (1,2,3,40), (2,1,3,4); +EXPLAIN SELECT c,b,d FROM t1 GROUP BY c,b,d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c` AS `c`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`d` AS `d` from `test`.`t1` group by `test`.`t1`.`c`,`test`.`t1`.`b`,`test`.`t1`.`d` +SELECT c,b,d FROM t1 GROUP BY c,b,d; +c b d +1 1 50 +3 1 4 +3 2 40 +EXPLAIN SELECT c,b,d FROM t1 GROUP BY c,b,d ORDER BY NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c` AS `c`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`d` AS `d` from `test`.`t1` group by `test`.`t1`.`c`,`test`.`t1`.`b`,`test`.`t1`.`d` order by NULL +SELECT c,b,d FROM t1 GROUP BY c,b,d ORDER BY NULL; +c b d +1 1 50 +3 1 4 +3 2 40 +EXPLAIN SELECT c,b,d FROM t1 ORDER BY c,b,d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c` AS `c`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`d` AS `d` from `test`.`t1` order by `test`.`t1`.`c`,`test`.`t1`.`b`,`test`.`t1`.`d` +SELECT c,b,d FROM t1 ORDER BY c,b,d; +c b d +1 1 50 +3 1 4 +3 2 40 +EXPLAIN SELECT c,b,d FROM t1 GROUP BY c,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL c NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c` AS `c`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`d` AS `d` from `test`.`t1` group by `test`.`t1`.`c`,`test`.`t1`.`b` +SELECT c,b,d FROM t1 GROUP BY c,b; +c b d +1 1 50 +3 1 4 +3 2 40 +EXPLAIN SELECT c,b FROM t1 GROUP BY c,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index c c 8 NULL 3 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c` AS `c`,`test`.`t1`.`b` AS `b` from `test`.`t1` group by `test`.`t1`.`c`,`test`.`t1`.`b` +SELECT c,b FROM t1 GROUP BY c,b; +c b +1 1 +3 1 +3 2 +DROP TABLE t1; +CREATE TABLE t1 (a INT, b INT, PRIMARY KEY (a), INDEX b (b)) ENGINE=InnoDB; +INSERT INTO t1(a,b) VALUES (1,1), (2,2), (3,2); +EXPLAIN SELECT * FROM t1 WHERE b=2 ORDER BY a ASC; +id 1 +select_type SIMPLE +table +partitions NULL +type ALL +possible_keys NULL +key NULL +key_len NULL +ref NULL +rows 2 +filtered 100.00 +Extra Parallel execute (1 workers) +id 2 +select_type SIMPLE +table t1 +partitions NULL +type ref +possible_keys b +key b +key_len 5 +ref const +rows 2 +filtered 100.00 +Extra Using index +Warnings: +Level Note +Code 1003 +Message /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (`test`.`t1`.`b` = 2) order by `test`.`t1`.`a` +SELECT * FROM t1 WHERE b=2 ORDER BY a ASC; +a b +2 2 +3 2 +EXPLAIN SELECT * FROM t1 WHERE b=2 ORDER BY a DESC; +id 1 +select_type SIMPLE +table +partitions NULL +type ALL +possible_keys NULL +key NULL +key_len NULL +ref NULL +rows 2 +filtered 100.00 +Extra Backward index scan; Parallel execute (1 workers) +id 2 +select_type SIMPLE +table t1 +partitions NULL +type ref +possible_keys b +key b +key_len 5 +ref const +rows 2 +filtered 100.00 +Extra Backward index scan; Using index +Warnings: +Level Note +Code 1003 +Message /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (`test`.`t1`.`b` = 2) order by `test`.`t1`.`a` desc +SELECT * FROM t1 WHERE b=2 ORDER BY a DESC; +a b +3 2 +2 2 +EXPLAIN SELECT * FROM t1 ORDER BY b ASC, a ASC; +id 1 +select_type SIMPLE +table +partitions NULL +type ALL +possible_keys NULL +key NULL +key_len NULL +ref NULL +rows 3 +filtered 100.00 +Extra Parallel execute (1 workers) +id 2 +select_type SIMPLE +table t1 +partitions NULL +type index +possible_keys NULL +key b +key_len 5 +ref NULL +rows 3 +filtered 100.00 +Extra Using index +Warnings: +Level Note +Code 1003 +Message /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` order by `test`.`t1`.`b`,`test`.`t1`.`a` +SELECT * FROM t1 ORDER BY b ASC, a ASC; +a b +1 1 +2 2 +3 2 +EXPLAIN SELECT * FROM t1 ORDER BY b DESC, a DESC; +id 1 +select_type SIMPLE +table +partitions NULL +type ALL +possible_keys NULL +key NULL +key_len NULL +ref NULL +rows 3 +filtered 100.00 +Extra Backward index scan; Parallel execute (1 workers) +id 2 +select_type SIMPLE +table t1 +partitions NULL +type index +possible_keys NULL +key b +key_len 5 +ref NULL +rows 3 +filtered 100.00 +Extra Backward index scan; Using index +Warnings: +Level Note +Code 1003 +Message /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` order by `test`.`t1`.`b` desc,`test`.`t1`.`a` desc +SELECT * FROM t1 ORDER BY b DESC, a DESC; +a b +3 2 +2 2 +1 1 +EXPLAIN SELECT * FROM t1 ORDER BY b ASC, a DESC; +id 1 +select_type SIMPLE +table +partitions NULL +type ALL +possible_keys NULL +key NULL +key_len NULL +ref NULL +rows 3 +filtered 100.00 +Extra Parallel execute (1 workers) +id 2 +select_type SIMPLE +table t1 +partitions NULL +type index +possible_keys NULL +key b +key_len 5 +ref NULL +rows 3 +filtered 100.00 +Extra Using index; Using filesort +Warnings: +Level Note +Code 1003 +Message /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` order by `test`.`t1`.`b`,`test`.`t1`.`a` desc +SELECT * FROM t1 ORDER BY b ASC, a DESC; +a b +1 1 +3 2 +2 2 +EXPLAIN SELECT * FROM t1 ORDER BY b DESC, a ASC; +id 1 +select_type SIMPLE +table +partitions NULL +type ALL +possible_keys NULL +key NULL +key_len NULL +ref NULL +rows 3 +filtered 100.00 +Extra Parallel execute (1 workers) +id 2 +select_type SIMPLE +table t1 +partitions NULL +type index +possible_keys NULL +key b +key_len 5 +ref NULL +rows 3 +filtered 100.00 +Extra Using index; Using filesort +Warnings: +Level Note +Code 1003 +Message /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` order by `test`.`t1`.`b` desc,`test`.`t1`.`a` +SELECT * FROM t1 ORDER BY b DESC, a ASC; +a b +2 2 +3 2 +1 1 +DROP TABLE t1; + +# +# Bug#27610: ALTER TABLE ROW_FORMAT=... does not rebuild the table. +# + +# - prepare; + +DROP TABLE IF EXISTS t1; + +CREATE TABLE t1(c INT) +ENGINE = InnoDB +ROW_FORMAT = COMPACT; + +# - initial check; + +SELECT table_schema, table_name, row_format +FROM INFORMATION_SCHEMA.TABLES +WHERE table_schema = DATABASE() AND table_name = 't1'; +TABLE_SCHEMA TABLE_NAME ROW_FORMAT +test t1 Compact + +# - change ROW_FORMAT and check; + +ALTER TABLE t1 ROW_FORMAT = REDUNDANT; + +SELECT table_schema, table_name, row_format +FROM INFORMATION_SCHEMA.TABLES +WHERE table_schema = DATABASE() AND table_name = 't1'; +TABLE_SCHEMA TABLE_NAME ROW_FORMAT +test t1 Redundant + +# - that's it, cleanup. + +DROP TABLE t1; +create table t1(a char(10) not null, unique key aa(a(1)), +b char(4) not null, unique key bb(b(4))) engine=innodb; +desc t1; +Field Type Null Key Default Extra +a char(10) NO UNI NULL +b char(4) NO PRI NULL +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` char(10) NOT NULL, + `b` char(4) NOT NULL, + UNIQUE KEY `bb` (`b`), + UNIQUE KEY `aa` (`a`(1)) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +CREATE TABLE t1 (id int, type char(6), d int, INDEX idx(id,d)) ENGINE=InnoDB; +INSERT INTO t1 VALUES +(191, 'member', 1), (NULL, 'member', 3), (NULL, 'member', 4), +(201, 'member', 2), (NULL, 'member', 5), (191, 'member', 6), +(191, 'member', 7), (191, 'member', 8), (191, 'member', 9), +(191, 'member', 10); +EXPLAIN SELECT * FROM t1 WHERE id=191 OR id IS NULL ORDER BY d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 90.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL idx NULL NULL NULL 10 90.00 Using where; Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,`test`.`t1`.`type` AS `type`,`test`.`t1`.`d` AS `d` from `test`.`t1` where ((`test`.`t1`.`id` = 191) or (`test`.`t1`.`id` is null)) order by `test`.`t1`.`d` +SELECT * FROM t1 WHERE id=191 OR id IS NULL ORDER BY d; +id type d +191 member 1 +NULL member 3 +NULL member 4 +NULL member 5 +191 member 6 +191 member 7 +191 member 8 +191 member 9 +191 member 10 +DROP TABLE t1; +set @my_innodb_autoextend_increment=@@global.innodb_autoextend_increment; +set global innodb_autoextend_increment=8; +set global innodb_autoextend_increment=@my_innodb_autoextend_increment; +set @my_innodb_commit_concurrency=@@global.innodb_commit_concurrency; +set global innodb_commit_concurrency=0; +set global innodb_commit_concurrency=@my_innodb_commit_concurrency; +CREATE TABLE t1 (a int, b int, c int, PRIMARY KEY (a), KEY t1_b (b)) +ENGINE=InnoDB; +INSERT INTO t1 (a,b,c) VALUES (1,1,1), (2,1,1), (3,1,1), (4,1,1); +INSERT INTO t1 (a,b,c) SELECT a+4,b,c FROM t1; +INSERT INTO t1 (a,b,c) SELECT a+8,b,c FROM t1; +EXPLAIN SELECT a, b, c FROM t1 WHERE b = 1 ORDER BY a DESC LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 16 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range t1_b t1_b 5 NULL 16 100.00 Using index condition; Backward index scan +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` where (`test`.`t1`.`b` = 1) order by `test`.`t1`.`a` desc limit 5 +SELECT a, b, c FROM t1 WHERE b = 1 ORDER BY a DESC LIMIT 5; +a b c +16 1 1 +15 1 1 +14 1 1 +13 1 1 +12 1 1 +DROP TABLE t1; +DROP TABLE IF EXISTS t1; +CREATE TABLE t1 (a char(50)) ENGINE=InnoDB; +CREATE INDEX i1 on t1 (a(3)); +SELECT * FROM t1 WHERE a = 'abcde'; +a +DROP TABLE t1; +# +# BUG #26288: savepoint are not deleted on comit, if the transaction +# was otherwise empty +# +BEGIN; +SAVEPOINT s1; +COMMIT; +RELEASE SAVEPOINT s1; +ERROR 42000: SAVEPOINT s1 does not exist +BEGIN; +SAVEPOINT s2; +COMMIT; +ROLLBACK TO SAVEPOINT s2; +ERROR 42000: SAVEPOINT s2 does not exist +BEGIN; +SAVEPOINT s3; +ROLLBACK; +RELEASE SAVEPOINT s3; +ERROR 42000: SAVEPOINT s3 does not exist +BEGIN; +SAVEPOINT s4; +ROLLBACK; +ROLLBACK TO SAVEPOINT s4; +ERROR 42000: SAVEPOINT s4 does not exist +CREATE TABLE t1 (f1 INTEGER PRIMARY KEY COMMENT 'My ID#', f2 INTEGER DEFAULT NULL, f3 CHAR(10) DEFAULT 'My ID#', CONSTRAINT f2_ref FOREIGN KEY (f2) REFERENCES t1 (f1)) ENGINE=INNODB; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `f1` int NOT NULL COMMENT 'My ID#', + `f2` int DEFAULT NULL, + `f3` char(10) DEFAULT 'My ID#', + PRIMARY KEY (`f1`), + KEY `f2_ref` (`f2`), + CONSTRAINT `f2_ref` FOREIGN KEY (`f2`) REFERENCES `t1` (`f1`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +DROP TABLE t1; +# +# Bug #36995: valgrind error in remove_const during subquery executions +# +create table t1 (a bit(1) not null,b int) engine=myisam; +create table t2 (c int) engine=innodb; +SET sql_mode='NO_ENGINE_SUBSTITUTION'; +explain +select b from t1 where a not in (select b from t1,t2 group by a) group by a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL NULL Not optimized, outer query is empty +Warnings: +Note 1003 /* select#1 */ select NULL AS `b` from `test`.`t1` where (NULL,(/* select#2 */ select `test`.`t1`.`b` from `test`.`t1` join `test`.`t2` where (((NULL) = `test`.`t1`.`b`) or (`test`.`t1`.`b` is null)) having (`test`.`t1`.`b`)) is false) group by NULL +DROP TABLE t1,t2; +SET sql_mode=default; +End of 5.0 tests +CREATE TABLE `t2` ( +`k` int(11) NOT NULL auto_increment, +`a` int(11) default NULL, +`c` int(11) default NULL, +PRIMARY KEY (`k`), +UNIQUE KEY `idx_1` (`a`) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t2 ( a ) values ( 6 ) on duplicate key update c = +ifnull( c, +0 ) + 1; +insert into t2 ( a ) values ( 7 ) on duplicate key update c = +ifnull( c, +0 ) + 1; +select last_insert_id(); +last_insert_id() +2 +select * from t2; +k a c +1 6 NULL +2 7 NULL +insert into t2 ( a ) values ( 6 ) on duplicate key update c = +ifnull( c, +0 ) + 1; +select last_insert_id(); +last_insert_id() +2 +select last_insert_id(0); +last_insert_id(0) +0 +insert into t2 ( a ) values ( 6 ) on duplicate key update c = +ifnull( c, +0 ) + 1; +select last_insert_id(); +last_insert_id() +0 +select * from t2; +k a c +1 6 2 +2 7 NULL +insert ignore into t2 values (null,6,1),(10,8,1); +Warnings: +Warning 1062 Duplicate entry '6' for key 't2.idx_1' +select last_insert_id(); +last_insert_id() +0 +insert ignore into t2 values (null,6,1),(null,8,1),(null,15,1),(null,20,1); +Warnings: +Warning 1062 Duplicate entry '6' for key 't2.idx_1' +Warning 1062 Duplicate entry '8' for key 't2.idx_1' +select last_insert_id(); +last_insert_id() +11 +select * from t2; +k a c +1 6 2 +2 7 NULL +10 8 1 +11 15 1 +12 20 1 +insert into t2 ( a ) values ( 6 ) on duplicate key update c = +ifnull( c, +0 ) + 1, k=last_insert_id(k); +select last_insert_id(); +last_insert_id() +1 +select * from t2; +k a c +1 6 3 +2 7 NULL +10 8 1 +11 15 1 +12 20 1 +drop table t2; +drop table if exists t1, t2; +create table t1 (i int); +alter table t1 modify i int default 1; +alter table t1 modify i int default 2, rename t2; +lock table t2 write; +alter table t2 modify i int default 3; +unlock tables; +lock table t2 write; +alter table t2 modify i int default 4, rename t1; +unlock tables; +drop table t1; +drop table if exists t1; +create table t1 (i int); +insert into t1 values (); +lock table t1 write; +alter table t1 modify i int default 1; +insert into t1 values (); +select * from t1; +i +NULL +1 +alter table t1 change i c char(10) default "Two"; +insert into t1 values (); +select * from t1; +c +NULL +1 +Two +unlock tables; +select * from t1; +c +NULL +1 +Two +drop tables t1; +create table t1(f1 varchar(5) unique, f2 timestamp NOT NULL DEFAULT +CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP); +insert into t1(f1) values(1); +select @a:=f2 from t1; +@a:=f2 +# +Warnings: +# 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +update t1 set f1=1; +select @b:=f2 from t1; +@b:=f2 +# +Warnings: +# 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +select if(@a=@b,"ok","wrong"); +if(@a=@b,"ok","wrong") +ok +insert into t1(f1) values (1) on duplicate key update f1="1"; +select @b:=f2 from t1; +@b:=f2 +# +Warnings: +# 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +select if(@a=@b,"ok","wrong"); +if(@a=@b,"ok","wrong") +ok +insert into t1(f1) select f1 from t1 on duplicate key update f1="1"; +select @b:=f2 from t1; +@b:=f2 +# +Warnings: +# 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +select if(@a=@b,"ok","wrong"); +if(@a=@b,"ok","wrong") +ok +drop table t1; +SET SESSION AUTOCOMMIT = 0; +SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED; +set binlog_format=mixed; +# Switch to connection con1 +CREATE TABLE t1 (a INT PRIMARY KEY, b VARCHAR(256)) +ENGINE = InnoDB; +INSERT INTO t1 VALUES (1,2); +# 1. test for locking: +BEGIN; +UPDATE t1 SET b = 12 WHERE a = 1; +affected rows: 1 +info: Rows matched: 1 Changed: 1 Warnings: 0 +SELECT * FROM t1; +a b +1 12 +# Switch to connection con2 +UPDATE t1 SET b = 21 WHERE a = 1; +ERROR HY000: Lock wait timeout exceeded; try restarting transaction +# Switch to connection con1 +SELECT * FROM t1; +a b +1 12 +ROLLBACK; +# Switch to connection con2 +ROLLBACK; +# Switch to connection con1 +# 2. test for serialized update: +CREATE TABLE t2 (a INT); +TRUNCATE t1; +INSERT INTO t1 VALUES (1,'init'); +CREATE PROCEDURE p1() +BEGIN +UPDATE t1 SET b = CONCAT(b, '+con2') WHERE a = 1; +INSERT INTO t2 VALUES (); +END| +BEGIN; +UPDATE t1 SET b = CONCAT(b, '+con1') WHERE a = 1; +affected rows: 1 +info: Rows matched: 1 Changed: 1 Warnings: 0 +SELECT * FROM t1; +a b +1 init+con1 +# Switch to connection con2 +CALL p1;; +# Switch to connection con1 +SELECT * FROM t1; +a b +1 init+con1 +COMMIT; +SELECT * FROM t1; +a b +1 init+con1 +# Switch to connection con2 +SELECT * FROM t1; +a b +1 init+con1+con2 +COMMIT; +# Switch to connection con1 +# 3. test for updated key column: +TRUNCATE t1; +TRUNCATE t2; +INSERT INTO t1 VALUES (1,'init'); +BEGIN; +UPDATE t1 SET a = 2, b = CONCAT(b, '+con1') WHERE a = 1; +affected rows: 1 +info: Rows matched: 1 Changed: 1 Warnings: 0 +SELECT * FROM t1; +a b +2 init+con1 +# Switch to connection con2 +CALL p1;; +# Switch to connection con1 +SELECT * FROM t1; +a b +2 init+con1 +COMMIT; +SELECT * FROM t1; +a b +2 init+con1 +# Switch to connection con2 +SELECT * FROM t1; +a b +2 init+con1 +DROP PROCEDURE p1; +DROP TABLE t1, t2; +CREATE TABLE t1 (a INT NOT NULL, b INT NOT NULL, PRIMARY KEY (a,b)) engine=innodb; +CREATE TABLE t2 (c INT NOT NULL, d INT NOT NULL, PRIMARY KEY (c,d), +CONSTRAINT c2 FOREIGN KEY f2 (c) REFERENCES t1 (a,b) ON UPDATE NO ACTION) engine=innodb; +ERROR 42000: Incorrect foreign key definition for 'c2': Key reference and table reference don't match +CREATE TABLE t2 (c INT NOT NULL, d INT NOT NULL, PRIMARY KEY (c,d), +CONSTRAINT c2 FOREIGN KEY (c) REFERENCES t1 (a,b) ON UPDATE NO ACTION) engine=innodb; +ERROR 42000: Incorrect foreign key definition for 'c2': Key reference and table reference don't match +CREATE TABLE t2 (c INT NOT NULL, d INT NOT NULL, PRIMARY KEY (c,d), +CONSTRAINT c1 FOREIGN KEY c2 (c) REFERENCES t1 (a) ON DELETE NO ACTION, +CONSTRAINT c2 FOREIGN KEY (c) REFERENCES t1 (a) ON UPDATE NO ACTION) engine=innodb; +ALTER TABLE t2 DROP FOREIGN KEY c2; +DROP TABLE t2; +CREATE TABLE t2 (c INT NOT NULL, d INT NOT NULL, PRIMARY KEY (c,d), +FOREIGN KEY (c) REFERENCES t1 (a,k) ON UPDATE NO ACTION) engine=innodb; +ERROR 42000: Incorrect foreign key definition for 'foreign key without name': Key reference and table reference don't match +CREATE TABLE t2 (c INT NOT NULL, d INT NOT NULL, PRIMARY KEY (c,d), +CONSTRAINT f1 FOREIGN KEY (c) REFERENCES t1 (a,k) ON UPDATE NO ACTION) engine=innodb; +ERROR 42000: Incorrect foreign key definition for 'f1': Key reference and table reference don't match +CREATE TABLE t2 (c INT NOT NULL, d INT NOT NULL, PRIMARY KEY (c,d), +CONSTRAINT c1 FOREIGN KEY f1 (c) REFERENCES t1 (a) ON DELETE NO ACTION, +CONSTRAINT c2 FOREIGN KEY (c) REFERENCES t1 (a) ON UPDATE NO ACTION, +FOREIGN KEY f3 (c) REFERENCES t1 (a) ON UPDATE NO ACTION, +FOREIGN KEY (c) REFERENCES t1 (a) ON UPDATE NO ACTION) engine=innodb; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `c` int NOT NULL, + `d` int NOT NULL, + PRIMARY KEY (`c`,`d`), + CONSTRAINT `c1` FOREIGN KEY (`c`) REFERENCES `t1` (`a`), + CONSTRAINT `c2` FOREIGN KEY (`c`) REFERENCES `t1` (`a`), + CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`c`) REFERENCES `t1` (`a`), + CONSTRAINT `t2_ibfk_2` FOREIGN KEY (`c`) REFERENCES `t1` (`a`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +DROP TABLE t2; +DROP TABLE t1; +create table t1 (a int auto_increment primary key) engine=innodb; +alter table t1 order by a; +Warnings: +Warning 1105 ORDER BY ignored as there is a user-defined clustered index in the table 't1' +drop table t1; +CREATE TABLE t1 +(vid integer NOT NULL, +tid integer NOT NULL, +idx integer NOT NULL, +name varchar(128) NOT NULL, +type varchar(128) NULL, +PRIMARY KEY(idx, vid, tid), +UNIQUE(vid, tid, name) +) ENGINE=InnoDB; +INSERT INTO t1 VALUES +(1,1,1,'pk',NULL),(2,1,1,'pk',NULL),(3,1,1,'pk',NULL),(4,1,1,'c1',NULL), +(5,1,1,'pk',NULL),(1,1,2,'c1',NULL),(2,1,2,'c1',NULL),(3,1,2,'c1',NULL), +(4,1,2,'c2',NULL),(5,1,2,'c1',NULL),(2,1,3,'c2',NULL),(3,1,3,'c2',NULL), +(4,1,3,'pk',NULL),(5,1,3,'c2',NULL), +(2,1,4,'c_extra',NULL),(3,1,4,'c_extra',NULL); +EXPLAIN SELECT * FROM t1 FORCE INDEX (PRIMARY) WHERE tid = 1 AND vid = 3 ORDER BY idx DESC; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 16 6.25 Backward index scan; Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL PRIMARY 12 NULL 16 6.25 Using where; Backward index scan +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`vid` AS `vid`,`test`.`t1`.`tid` AS `tid`,`test`.`t1`.`idx` AS `idx`,`test`.`t1`.`name` AS `name`,`test`.`t1`.`type` AS `type` from `test`.`t1` FORCE INDEX (PRIMARY) where ((`test`.`t1`.`vid` = 3) and (`test`.`t1`.`tid` = 1)) order by `test`.`t1`.`idx` desc +SELECT * FROM t1 FORCE INDEX (PRIMARY) WHERE tid = 1 AND vid = 3 ORDER BY idx DESC; +vid tid idx name type +3 1 4 c_extra NULL +3 1 3 c2 NULL +3 1 2 c1 NULL +3 1 1 pk NULL +DROP TABLE t1; +# +# Bug #44290: explain crashes for subquery with distinct in +# SQL_SELECT::test_quick_select +# (reproduced only with InnoDB tables) +# +CREATE TABLE t1 (c1 INT, c2 INT, c3 INT, KEY (c3), KEY (c2, c3)) +ENGINE=InnoDB; +INSERT INTO t1 VALUES (1,1,1), (1,1,1), (1,1,2), (1,1,1), (1,1,2); +SELECT 1 FROM (SELECT COUNT(DISTINCT c1) +FROM t1 WHERE c2 IN (1, 1) AND c3 = 2 GROUP BY c2) x; +1 +1 +EXPLAIN +SELECT 1 FROM (SELECT COUNT(DISTINCT c1) +FROM t1 WHERE c2 IN (1, 1) AND c3 = 2 GROUP BY c2) x; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DERIVED t1 NULL ref c3,c2 c3 5 const 2 40.00 Using where; Using filesort +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from (/* select#2 */ select count(distinct `test`.`t1`.`c1`) AS `COUNT(DISTINCT c1)` from `test`.`t1` where ((`test`.`t1`.`c3` = 2) and (`test`.`t1`.`c2` in (1,1))) group by `test`.`t1`.`c2`) `x` +DROP TABLE t1; +CREATE TABLE t1 (c1 REAL, c2 REAL, c3 REAL, KEY (c3), KEY (c2, c3)) +ENGINE=InnoDB; +INSERT INTO t1 VALUES (1,1,1), (1,1,1), (1,1,2), (1,1,1), (1,1,2); +SELECT 1 FROM (SELECT COUNT(DISTINCT c1) +FROM t1 WHERE c2 IN (1, 1) AND c3 = 2 GROUP BY c2) x; +1 +1 +EXPLAIN +SELECT 1 FROM (SELECT COUNT(DISTINCT c1) +FROM t1 WHERE c2 IN (1, 1) AND c3 = 2 GROUP BY c2) x; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DERIVED t1 NULL ref c3,c2 c3 9 const 2 40.00 Using where; Using filesort +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from (/* select#2 */ select count(distinct `test`.`t1`.`c1`) AS `COUNT(DISTINCT c1)` from `test`.`t1` where ((`test`.`t1`.`c2` in (1,1)) and (`test`.`t1`.`c3` = 2)) group by `test`.`t1`.`c2`) `x` +DROP TABLE t1; +CREATE TABLE t1 (c1 DECIMAL(12,2), c2 DECIMAL(12,2), c3 DECIMAL(12,2), +KEY (c3), KEY (c2, c3)) +ENGINE=InnoDB; +INSERT INTO t1 VALUES (1,1,1), (1,1,1), (1,1,2), (1,1,1), (1,1,2); +SELECT 1 FROM (SELECT COUNT(DISTINCT c1) +FROM t1 WHERE c2 IN (1, 1) AND c3 = 2 GROUP BY c2) x; +1 +1 +EXPLAIN +SELECT 1 FROM (SELECT COUNT(DISTINCT c1) +FROM t1 WHERE c2 IN (1, 1) AND c3 = 2 GROUP BY c2) x; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DERIVED t1 NULL ref c3,c2 c3 7 const 2 40.00 Using where; Using filesort +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from (/* select#2 */ select count(distinct `test`.`t1`.`c1`) AS `COUNT(DISTINCT c1)` from `test`.`t1` where ((`test`.`t1`.`c2` in (1,1)) and (`test`.`t1`.`c3` = 2.00)) group by `test`.`t1`.`c2`) `x` +DROP TABLE t1; +End of 5.1 tests +# +# Bug#43600: Incorrect type conversion caused wrong result. +# +CREATE TABLE t1 ( +a int NOT NULL +) engine= innodb; +CREATE TABLE t2 ( +a int NOT NULL, +b int NOT NULL, +filler char(100) DEFAULT NULL, +KEY a (a,b) +) engine= innodb; +insert into t1 values (0),(1),(2),(3),(4); +insert into t2 select A.a + 10 *B.a, 1, 'filler' from t1 A, t1 B; +explain select * from t1, t2 where t2.a=t1.a and t2.b + 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +2 SIMPLE t2 NULL ref a a 4 test.t1.a 1 100.00 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`filler` AS `filler` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`a` = `test`.`t1`.`a`) and (0 <> (`test`.`t2`.`b` + 1))) +select * from t1, t2 where t2.a=t1.a and t2.b + 1; +a a b filler +0 0 1 filler +1 1 1 filler +2 2 1 filler +3 3 1 filler +4 4 1 filler +drop table t1,t2; +# End of test case for the bug#43600 +# +# Bug#42643: InnoDB does not support replication of TRUNCATE TABLE +# +# Check that a TRUNCATE TABLE statement, needing an exclusive meta +# data lock, waits for a shared metadata lock owned by a concurrent +# transaction. +# +CREATE TABLE t1 (a INT) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1),(2),(3); +BEGIN; +SELECT * FROM t1 ORDER BY a; +a +1 +2 +3 +# Connection con1 +TRUNCATE TABLE t1;; +# Connection default +SELECT * FROM t1 ORDER BY a; +a +1 +2 +3 +ROLLBACK; +# Connection con1 +# Reaping TRUNCATE TABLE +SELECT * FROM t1; +a +# Disconnect con1 +# Connection default +DROP TABLE t1; +# +# BUG#35850: Performance regression in 5.1.23/5.1.24 +# +create table t1(a int); +insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t2 (a int, b int, pk int, key(a,b), primary key(pk)) engine=innodb; +insert into t2 select @a:=A.a+10*(B.a + 10*C.a),@a, @a from t1 A, t1 B, t1 C; +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +ANALYZE TABLE t2; +Table Op Msg_type Msg_text +test.t2 analyze status OK +# this must use key 'a', not PRIMARY: +explain select a from t2 where a=b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (2 workers) +2 SIMPLE t2 NULL index NULL a 10 NULL # 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` where (`test`.`t2`.`b` = `test`.`t2`.`a`) +drop table t1, t2; +# +# Bug #40360: Binlog related errors with binlog off +# +SET @save_log_bin= @@sql_log_bin; +SET @save_binlog_format=@@binlog_format; +SET @@sql_log_bin = 0; +SET SESSION BINLOG_FORMAT=STATEMENT; +SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED; +select @@session.sql_log_bin, @@session.binlog_format, @@session.transaction_isolation; +@@session.sql_log_bin 0 +@@session.binlog_format STATEMENT +@@session.transaction_isolation READ-COMMITTED +CREATE TABLE t1 ( a INT ) ENGINE=InnoDB; +INSERT INTO t1 VALUES(1); +DROP TABLE t1; +SET @@sql_log_bin=@save_log_bin; +SET @@binlog_format=@save_binlog_format; +# +# Bug#37284 Crash in Field_string::type() +# +DROP TABLE IF EXISTS t1; +CREATE TABLE t1 (a char(50)) ENGINE=InnoDB; +CREATE INDEX i1 on t1 (a(3)); +SELECT * FROM t1 WHERE a = 'abcde'; +a +DROP TABLE t1; +# +# Bug #37742: HA_EXTRA_KEYREAD flag is set when key contains only prefix of +# requested column +# +CREATE TABLE foo (a int, b int, c char(10), +PRIMARY KEY (c(3)), +KEY b (b) +) engine=innodb; +CREATE TABLE foo2 (a int, b int, c char(10), +PRIMARY KEY (c), +KEY b (b) +) engine=innodb; +CREATE TABLE bar (a int, b int, c char(10), +PRIMARY KEY (c(3)), +KEY b (b) +) engine=myisam; +INSERT INTO foo VALUES +(1,2,'abcdefghij'), (2,3,''), (3,4,'klmnopqrst'), +(4,5,'uvwxyz'), (5,6,'meotnsyglt'), (4,5,'asfdewe'), (5,6,'trondheim'), +(6,7,'stockholm'), (7,8,'copenhagen'), (8,9,'helsinki'), +(9,10,'reykjavik'); +INSERT INTO bar SELECT * FROM foo; +INSERT INTO foo2 SELECT * FROM foo; +ANALYZE TABLE bar; +ANALYZE TABLE foo; +ANALYZE TABLE foo2; +EXPLAIN SELECT c FROM bar WHERE b>2;; +id 1 +select_type SIMPLE +table bar +partitions NULL +type ALL +possible_keys b +key NULL +key_len NULL +ref NULL +rows 11 +filtered 90.91 +Extra Using where +Warnings: +Level Note +Code 1003 +Message /* select#1 */ select `test`.`bar`.`c` AS `c` from `test`.`bar` where (`test`.`bar`.`b` > 2) +EXPLAIN SELECT c FROM foo WHERE b>2;; +id 1 +select_type SIMPLE +table +partitions NULL +type ALL +possible_keys NULL +key NULL +key_len NULL +ref NULL +rows 11 +filtered 90.91 +Extra Parallel execute (1 workers) +id 2 +select_type SIMPLE +table foo +partitions NULL +type ALL +possible_keys b +key NULL +key_len NULL +ref NULL +rows 11 +filtered 90.91 +Extra Using where +Warnings: +Level Note +Code 1003 +Message /* select#1 */ select `test`.`foo`.`c` AS `c` from `test`.`foo` where (`test`.`foo`.`b` > 2) +EXPLAIN SELECT c FROM foo2 WHERE b>2;; +id 1 +select_type SIMPLE +table +partitions NULL +type ALL +possible_keys NULL +key NULL +key_len NULL +ref NULL +rows 10 +filtered 100.00 +Extra Parallel execute (1 workers) +id 2 +select_type SIMPLE +table foo2 +partitions NULL +type range +possible_keys b +key b +key_len 5 +ref NULL +rows 10 +filtered 100.00 +Extra Using where; Using index +Warnings: +Level Note +Code 1003 +Message /* select#1 */ select `test`.`foo2`.`c` AS `c` from `test`.`foo2` where (`test`.`foo2`.`b` > 2) +EXPLAIN SELECT c FROM bar WHERE c>2;; +id 1 +select_type SIMPLE +table bar +partitions NULL +type ALL +possible_keys PRIMARY +key NULL +key_len NULL +ref NULL +rows 11 +filtered 33.33 +Extra Using where +Warnings: +Level Warning +Code 1739 +Message Cannot use range access on index 'PRIMARY' due to type or collation conversion on field 'c' +Level Note +Code 1003 +Message /* select#1 */ select `test`.`bar`.`c` AS `c` from `test`.`bar` where (`test`.`bar`.`c` > 2) +EXPLAIN SELECT c FROM foo WHERE c>2;; +id 1 +select_type SIMPLE +table +partitions NULL +type ALL +possible_keys NULL +key NULL +key_len NULL +ref NULL +rows 11 +filtered 33.33 +Extra Parallel execute (1 workers) +id 2 +select_type SIMPLE +table foo +partitions NULL +type ALL +possible_keys PRIMARY +key NULL +key_len NULL +ref NULL +rows 11 +filtered 33.33 +Extra Using where +Warnings: +Level Warning +Code 1739 +Message Cannot use range access on index 'PRIMARY' due to type or collation conversion on field 'c' +Level Note +Code 1003 +Message /* select#1 */ select `test`.`foo`.`c` AS `c` from `test`.`foo` where (`test`.`foo`.`c` > 2) +EXPLAIN SELECT c FROM foo2 WHERE c>2;; +id 1 +select_type SIMPLE +table +partitions NULL +type ALL +possible_keys NULL +key NULL +key_len NULL +ref NULL +rows 11 +filtered 33.33 +Extra Parallel execute (1 workers) +id 2 +select_type SIMPLE +table foo2 +partitions NULL +type index +possible_keys PRIMARY +key b +key_len 5 +ref NULL +rows 11 +filtered 33.33 +Extra Using where; Using index +Warnings: +Level Warning +Code 1739 +Message Cannot use range access on index 'PRIMARY' due to type or collation conversion on field 'c' +Level Warning +Code 1739 +Message Cannot use range access on index 'b' due to type or collation conversion on field 'c' +Level Note +Code 1003 +Message /* select#1 */ select `test`.`foo2`.`c` AS `c` from `test`.`foo2` where (`test`.`foo2`.`c` > 2) +DROP TABLE foo, bar, foo2; +# +# Bug#41348: INSERT INTO tbl SELECT * FROM temp_tbl overwrites locking type of temp table +# +DROP TABLE IF EXISTS t1,t3,t2; +DROP FUNCTION IF EXISTS f1; +CREATE FUNCTION f1() RETURNS VARCHAR(250) +BEGIN +return 'hhhhhhh' ; +END| +CREATE TABLE t1 (a VARCHAR(20), b VARCHAR(20), c VARCHAR(20)) ENGINE=INNODB; +BEGIN WORK; +CREATE TEMPORARY TABLE t2 (a VARCHAR(20), b VARCHAR(20), c varchar(20)) ENGINE=INNODB; +CREATE TEMPORARY TABLE t3 LIKE t2; +INSERT INTO t1 VALUES ('a','b',NULL),('c','d',NULL),('e','f',NULL); +SET @stmt := CONCAT('INSERT INTO t2 SELECT tbl.a, tbl.b, f1()',' FROM t1 tbl'); +PREPARE stmt1 FROM @stmt; +SET @stmt := CONCAT('INSERT INTO t3', ' SELECT * FROM t2'); +PREPARE stmt3 FROM @stmt; +EXECUTE stmt1; +COMMIT; +DEALLOCATE PREPARE stmt1; +DEALLOCATE PREPARE stmt3; +DROP TABLE t1,t3,t2; +DROP FUNCTION f1; +# +# Bug#37016: TRUNCATE TABLE removes some rows but not all +# +DROP TABLE IF EXISTS t1,t2; +CREATE TABLE t1 (id INT NOT NULL, PRIMARY KEY (id)) ENGINE=INNODB; +CREATE TABLE t2 (id INT PRIMARY KEY, +t1_id INT, INDEX par_ind (t1_id), +FOREIGN KEY (t1_id) REFERENCES t1(id)) ENGINE=INNODB; +INSERT INTO t1 VALUES (1),(2); +INSERT INTO t2 VALUES (3,2); +SET AUTOCOMMIT = 0; +START TRANSACTION; +TRUNCATE TABLE t1; +ERROR 42000: Cannot truncate a table referenced in a foreign key constraint (`test`.`t2`, CONSTRAINT `t2_ibfk_1`) +SELECT * FROM t1; +id +1 +2 +COMMIT; +SELECT * FROM t1; +id +1 +2 +START TRANSACTION; +TRUNCATE TABLE t1; +ERROR 42000: Cannot truncate a table referenced in a foreign key constraint (`test`.`t2`, CONSTRAINT `t2_ibfk_1`) +SELECT * FROM t1; +id +1 +2 +ROLLBACK; +SELECT * FROM t1; +id +1 +2 +SET AUTOCOMMIT = 1; +START TRANSACTION; +SELECT * FROM t1; +id +1 +2 +COMMIT; +TRUNCATE TABLE t1; +ERROR 42000: Cannot truncate a table referenced in a foreign key constraint (`test`.`t2`, CONSTRAINT `t2_ibfk_1`) +SELECT * FROM t1; +id +1 +2 +DELETE FROM t2 WHERE id = 3; +START TRANSACTION; +SELECT * FROM t1; +id +1 +2 +TRUNCATE TABLE t1; +ERROR 42000: Cannot truncate a table referenced in a foreign key constraint (`test`.`t2`, CONSTRAINT `t2_ibfk_1`) +ROLLBACK; +SELECT * FROM t1; +id +1 +2 +TRUNCATE TABLE t2; +DROP TABLE t2; +DROP TABLE t1; +# +# Bug#40127 Multiple table DELETE IGNORE hangs on foreign key constraint violation on 5.0 +# +CREATE TABLE t1 ( +id INT UNSIGNED NOT NULL AUTO_INCREMENT, +PRIMARY KEY (id) +) ENGINE=InnoDB; +CREATE TABLE t2 ( +id INT UNSIGNED NOT NULL AUTO_INCREMENT, +aid INT UNSIGNED NOT NULL, +PRIMARY KEY (id), +FOREIGN KEY (aid) REFERENCES t1 (id) +) ENGINE=InnoDB; +CREATE TABLE t3 ( +bid INT UNSIGNED NOT NULL, +FOREIGN KEY (bid) REFERENCES t2 (id) +) ENGINE=InnoDB; +CREATE TABLE t4 ( +a INT +) ENGINE=InnoDB; +CREATE TABLE t5 ( +a INT +) ENGINE=InnoDB; +INSERT INTO t1 (id) VALUES (1); +INSERT INTO t2 (id, aid) VALUES (1, 1),(2,1),(3,1),(4,1); +INSERT INTO t3 (bid) VALUES (1); +INSERT INTO t4 VALUES (1),(2),(3),(4),(5); +INSERT INTO t5 VALUES (1); +DELETE t5 FROM t4 LEFT JOIN t5 ON t4.a= t5.a; +DELETE t2, t1 FROM t2 INNER JOIN t1 ON (t2.aid = t1.id) WHERE t2.id = 1; +ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t3`, CONSTRAINT `t3_ibfk_1` FOREIGN KEY (`bid`) REFERENCES `t2` (`id`)) +DELETE t2, t1 FROM t2 INNER JOIN t1 ON (t2.aid = t1.id) WHERE t2.id = 1; +ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t3`, CONSTRAINT `t3_ibfk_1` FOREIGN KEY (`bid`) REFERENCES `t2` (`id`)) +DELETE IGNORE t2, t1 FROM t2 INNER JOIN t1 ON (t2.aid = t1.id) WHERE t2.id = 1; +Warnings: +Warning 1451 Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t3`, CONSTRAINT `t3_ibfk_1` FOREIGN KEY (`bid`) REFERENCES `t2` (`id`)) +Warning 1451 Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`aid`) REFERENCES `t1` (`id`)) +DROP TABLE t3; +DROP TABLE t2; +DROP TABLE t1; +DROP TABLES t4,t5; +# Bug#40127 Multiple table DELETE IGNORE hangs on foreign key constraint violation on 5.0 +# Testing for any side effects of IGNORE on AFTER DELETE triggers used with +# transactional tables. +# +CREATE TABLE t1 (i INT NOT NULL PRIMARY KEY) ENGINE=InnoDB; +CREATE TABLE t2 (a VARCHAR(100)) ENGINE=InnoDB; +CREATE TABLE t3 (i INT NOT NULL PRIMARY KEY) ENGINE=InnoDB; +CREATE TABLE t4 (i INT NOT NULL PRIMARY KEY, t1i INT, +FOREIGN KEY (t1i) REFERENCES t1(i)) +ENGINE=InnoDB; +CREATE TRIGGER trg AFTER DELETE ON t1 FOR EACH ROW +BEGIN +SET @b:='EXECUTED TRIGGER'; +INSERT INTO t2 VALUES (@b); +SET @a:= error_happens_here; +END|| +SET @b:=""; +SET @a:=""; +INSERT INTO t1 VALUES (1),(2),(3),(4); +INSERT INTO t3 SELECT * FROM t1; +** An error in a trigger causes rollback of the statement. +DELETE t1 FROM t3 LEFT JOIN t1 ON t1.i=t3.i; +ERROR 42S22: Unknown column 'error_happens_here' in 'field list' +SELECT @a,@b; +@a @b + EXECUTED TRIGGER +SELECT * FROM t2; +a +SELECT * FROM t1 LEFT JOIN t3 ON t1.i=t3.i; +i i +1 1 +2 2 +3 3 +4 4 +** Same happens with the IGNORE option +DELETE IGNORE t1 FROM t3 LEFT JOIN t1 ON t1.i=t3.i; +ERROR 42S22: Unknown column 'error_happens_here' in 'field list' +SELECT * FROM t2; +a +SELECT * FROM t1 LEFT JOIN t3 ON t1.i=t3.i; +i i +1 1 +2 2 +3 3 +4 4 +** +** The following is an attempt to demonstrate +** error handling inside a row iteration. +** +DROP TRIGGER trg; +DELETE FROM t1; +DELETE FROM t2; +DELETE FROM t3; +INSERT INTO t1 VALUES (1),(2),(3),(4); +INSERT INTO t3 VALUES (1),(2),(3),(4); +INSERT INTO t4 VALUES (3,3),(4,4); +CREATE TRIGGER trg AFTER DELETE ON t1 FOR EACH ROW +BEGIN +SET @b:= CONCAT('EXECUTED TRIGGER FOR ROW ',CAST(OLD.i AS CHAR)); +INSERT INTO t2 VALUES (@b); +END|| +** DELETE is prevented by foreign key constrains but errors are silenced. +** The AFTER trigger isn't fired. +DELETE IGNORE t1 FROM t3 LEFT JOIN t1 ON t1.i=t3.i; +Warnings: +Warning 1451 Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t4`, CONSTRAINT `t4_ibfk_1` FOREIGN KEY (`t1i`) REFERENCES `t1` (`i`)) +Warning 1451 Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t4`, CONSTRAINT `t4_ibfk_1` FOREIGN KEY (`t1i`) REFERENCES `t1` (`i`)) +** Tables are modified by best effort: +SELECT * FROM t1 LEFT JOIN t3 ON t1.i=t3.i; +i i +3 3 +4 4 +** The AFTER trigger was only executed on successful rows: +SELECT * FROM t2; +a +EXECUTED TRIGGER FOR ROW 1 +EXECUTED TRIGGER FOR ROW 2 +DROP TRIGGER trg; +** +** Induce an error midway through an AFTER-trigger +** +DELETE FROM t4; +DELETE FROM t1; +DELETE FROM t3; +INSERT INTO t1 VALUES (1),(2),(3),(4); +INSERT INTO t3 VALUES (1),(2),(3),(4); +CREATE TRIGGER trg AFTER DELETE ON t1 FOR EACH ROW +BEGIN +SET @a:= @a+1; +IF @a > 2 THEN +INSERT INTO t4 VALUES (5,5); +END IF; +END|| +SET @a:=0; +** Errors in the trigger causes the statement to abort. +DELETE IGNORE t1 FROM t3 LEFT JOIN t1 ON t1.i=t3.i; +ERROR 23000: Cannot add or update a child row: a foreign key constraint fails (`test`.`t4`, CONSTRAINT `t4_ibfk_1` FOREIGN KEY (`t1i`) REFERENCES `t1` (`i`)) +SELECT * FROM t1 LEFT JOIN t3 ON t1.i=t3.i; +i i +1 1 +2 2 +3 3 +4 4 +SELECT * FROM t4; +i t1i +DROP TRIGGER trg; +DROP TABLE t4; +DROP TABLE t1; +DROP TABLE t2; +DROP TABLE t3; +# +# Bug#43580: Issue with Innodb on multi-table update +# +CREATE TABLE t1 (a INT, b INT, KEY (a)) ENGINE = INNODB; +CREATE TABLE t2 (a INT KEY, b INT, KEY (b)) ENGINE = INNODB; +CREATE TABLE t3 (a INT, b INT KEY, KEY (a)) ENGINE = INNODB; +CREATE TABLE t4 (a INT KEY, b INT, KEY (b)) ENGINE = INNODB; +INSERT INTO t1 VALUES (1, 1), (2, 2), (3, 3), (4, 4), (5, 5), (6, 6); +INSERT INTO t2 VALUES (1, 1), (2, 2), (3, 3), (4, 4), (5, 5); +INSERT INTO t3 VALUES (1, 101), (2, 102), (3, 103), (4, 104), (5, 105), (6, 106); +INSERT INTO t4 VALUES (1, 1), (2, 2), (3, 3), (4, 4), (5, 5); +UPDATE t2 straight_join t1 SET t1.a = t1.a + 100, t2.b = t1.a + 10 +WHERE t1.a BETWEEN 2 AND 4 AND t2.a = t1.b; +SELECT * FROM t2; +a b +1 1 +2 12 +3 13 +4 14 +5 5 +UPDATE t4 straight_join t3 SET t3.a = t3.a + 100, t4.b = t3.a + 10 +WHERE t3.a BETWEEN 2 AND 4 AND t4.a = t3.b - 100; +SELECT * FROM t4; +a b +1 1 +2 12 +3 13 +4 14 +5 5 +DROP TABLE t1, t2, t3, t4; +# +# Bug#44886: SIGSEGV in test_if_skip_sort_order() - +# uninitialized variable used as subscript +# +CREATE TABLE t1 (a INT, b INT, c INT, d INT, PRIMARY KEY (b), KEY (a,c)) +ENGINE=InnoDB; +INSERT INTO t1 VALUES (1,1,1,0); +CREATE TABLE t2 (a INT, b INT, e INT, KEY (e)) ENGINE=InnoDB; +INSERT INTO t2 VALUES (1,1,2); +CREATE TABLE t3 (a INT, b INT) ENGINE=MyISAM; +INSERT INTO t3 VALUES (1, 1); +SET sql_mode='NO_ENGINE_SUBSTITUTION'; +SELECT * FROM t1, t2, t3 +WHERE t1.a = t3.a AND (t1.b = t3.b OR t1.d) AND t2.b = t1.b AND t2.e = 2 +GROUP BY t1.b; +a b c d a b e a b +1 1 1 0 1 1 2 1 1 +SET sql_mode=default; +DROP TABLE t1, t2, t3; +# +# Bug #45828: Optimizer won't use partial primary key if another +# index can prevent filesort +# +CREATE TABLE `t1` ( +c1 int NOT NULL, +c2 int NOT NULL, +c3 int NOT NULL, +PRIMARY KEY (c1,c2), +KEY (c3) +) ENGINE=InnoDB; +INSERT INTO t1 VALUES (5,2,1246276747); +INSERT INTO t1 VALUES (2,1,1246281721); +INSERT INTO t1 VALUES (7,3,1246281756); +INSERT INTO t1 VALUES (4,2,1246282139); +INSERT INTO t1 VALUES (3,1,1246282230); +INSERT INTO t1 VALUES (1,0,1246282712); +INSERT INTO t1 VALUES (8,3,1246282765); +INSERT INTO t1 SELECT c1+10,c2+10,c3+10 FROM t1; +INSERT INTO t1 SELECT c1+100,c2+100,c3+100 from t1; +INSERT INTO t1 SELECT c1+1000,c2+1000,c3+1000 from t1; +INSERT INTO t1 SELECT c1+10000,c2+10000,c3+10000 from t1; +INSERT INTO t1 SELECT c1+100000,c2+100000,c3+100000 from t1; +INSERT INTO t1 SELECT c1+1000000,c2+1000000,c3+1000000 from t1; +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +SELECT * FROM t1 WHERE c1 = 99999999 AND c3 > 1 ORDER BY c3; +c1 c2 c3 +EXPLAIN SELECT * FROM t1 WHERE c1 = 99999999 AND c3 > 1 ORDER BY c3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref PRIMARY,c3 PRIMARY 4 const 1 100.00 Using where; Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c1` AS `c1`,`test`.`t1`.`c2` AS `c2`,`test`.`t1`.`c3` AS `c3` from `test`.`t1` where ((`test`.`t1`.`c1` = 99999999) and (`test`.`t1`.`c3` > 1)) order by `test`.`t1`.`c3` +EXPLAIN SELECT * FROM t1 FORCE INDEX (PRIMARY) WHERE c1 = 99999999 AND c3 > 1 ORDER BY c3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 33.33 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref PRIMARY PRIMARY 4 const 1 33.33 Using where; Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c1` AS `c1`,`test`.`t1`.`c2` AS `c2`,`test`.`t1`.`c3` AS `c3` from `test`.`t1` FORCE INDEX (PRIMARY) where ((`test`.`t1`.`c1` = 99999999) and (`test`.`t1`.`c3` > 1)) order by `test`.`t1`.`c3` +CREATE TABLE t2 ( +c1 int NOT NULL, +c2 int NOT NULL, +c3 int NOT NULL, +KEY (c1,c2), +KEY (c3) +) ENGINE=InnoDB; +ANALYZE TABLE t2; +Table Op Msg_type Msg_text +test.t2 analyze status OK +explain SELECT * FROM t2 WHERE c1 = 99999999 AND c3 > 1 ORDER BY c3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ref c1,c3 c1 4 const 1 100.00 Using where; Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`c1` AS `c1`,`test`.`t2`.`c2` AS `c2`,`test`.`t2`.`c3` AS `c3` from `test`.`t2` where ((`test`.`t2`.`c1` = 99999999) and (`test`.`t2`.`c3` > 1)) order by `test`.`t2`.`c3` +DROP TABLE t1,t2; +# +# 36259: Optimizing with ORDER BY +# +CREATE TABLE t1 ( +a INT NOT NULL AUTO_INCREMENT, +b INT NOT NULL, +c INT NOT NULL, +d VARCHAR(5), +e INT NOT NULL, +PRIMARY KEY (a), KEY i2 (b,c,d) +) ENGINE=InnoDB; +INSERT INTO t1 (b,c,d,e) VALUES (1,1,'a',1), (2,2,'b',2); +INSERT INTO t1 (b,c,d,e) SELECT RAND()*10000, RAND()*10000, d, e FROM t1; +INSERT INTO t1 (b,c,d,e) SELECT RAND()*10000, RAND()*10000, d, e FROM t1; +INSERT INTO t1 (b,c,d,e) SELECT RAND()*10000, RAND()*10000, d, e FROM t1; +INSERT INTO t1 (b,c,d,e) SELECT RAND()*10000, RAND()*10000, d, e FROM t1; +INSERT INTO t1 (b,c,d,e) SELECT RAND()*10000, RAND()*10000, d, e FROM t1; +INSERT INTO t1 (b,c,d,e) SELECT RAND()*10000, RAND()*10000, d, e FROM t1; +ANALYZE TABLE t1; +EXPLAIN SELECT * FROM t1 WHERE b=1 AND c=1 ORDER BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref i2 i2 8 const,const 1 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c`,`test`.`t1`.`d` AS `d`,`test`.`t1`.`e` AS `e` from `test`.`t1` where ((`test`.`t1`.`c` = 1) and (`test`.`t1`.`b` = 1)) order by `test`.`t1`.`a` +EXPLAIN SELECT * FROM t1 FORCE INDEX(i2) WHERE b=1 and c=1 ORDER BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref i2 i2 8 const,const 1 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c`,`test`.`t1`.`d` AS `d`,`test`.`t1`.`e` AS `e` from `test`.`t1` FORCE INDEX (`i2`) where ((`test`.`t1`.`c` = 1) and (`test`.`t1`.`b` = 1)) order by `test`.`t1`.`a` +EXPLAIN SELECT * FROM t1 FORCE INDEX(PRIMARY) WHERE b=1 AND c=1 ORDER BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # # Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL PRIMARY 4 NULL # # Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c`,`test`.`t1`.`d` AS `d`,`test`.`t1`.`e` AS `e` from `test`.`t1` FORCE INDEX (PRIMARY) where ((`test`.`t1`.`c` = 1) and (`test`.`t1`.`b` = 1)) order by `test`.`t1`.`a` +DROP TABLE t1; +# +# Bug #47963: Wrong results when index is used +# +CREATE TABLE t1( +a VARCHAR(5) NOT NULL, +b VARCHAR(5) NOT NULL, +c DATETIME NOT NULL, +KEY (c) +) ENGINE=InnoDB; +INSERT INTO t1 VALUES('TEST', 'TEST', '2009-10-09 00:00:00'); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +SELECT * FROM t1 WHERE a = 'TEST' AND +c >= '2009-10-09 00:00:00' AND c <= '2009-10-09 00:00:00'; +a b c +TEST TEST 2009-10-09 00:00:00 +SELECT * FROM t1 WHERE a = 'TEST' AND +c >= '2009-10-09 00:00:00.0' AND c <= '2009-10-09 00:00:00.0'; +a b c +TEST TEST 2009-10-09 00:00:00 +SELECT * FROM t1 WHERE a = 'TEST' AND +c >= '2009-10-09 00:00:00.0' AND c <= '2009-10-09 00:00:00'; +a b c +TEST TEST 2009-10-09 00:00:00 +SELECT * FROM t1 WHERE a = 'TEST' AND +c >= '2009-10-09 00:00:00' AND c <= '2009-10-09 00:00:00.0'; +a b c +TEST TEST 2009-10-09 00:00:00 +SELECT * FROM t1 WHERE a = 'TEST' AND +c >= '2009-10-09 00:00:00.000' AND c <= '2009-10-09 00:00:00.000'; +a b c +TEST TEST 2009-10-09 00:00:00 +SELECT * FROM t1 WHERE a = 'TEST' AND +c >= '2009-10-09 00:00:00.00' AND c <= '2009-10-09 00:00:00.001'; +a b c +TEST TEST 2009-10-09 00:00:00 +SELECT * FROM t1 WHERE a = 'TEST' AND +c >= '2009-10-09 00:00:00.001' AND c <= '2009-10-09 00:00:00.00'; +a b c +EXPLAIN SELECT * FROM t1 WHERE a = 'TEST' AND +c >= '2009-10-09 00:00:00.001' AND c <= '2009-10-09 00:00:00.00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` where ((`test`.`t1`.`c` >= TIMESTAMP'2009-10-09 00:00:00.001') and (`test`.`t1`.`c` <= TIMESTAMP'2009-10-09 00:00:00') and multiple equal('TEST', `test`.`t1`.`a`)) +DROP TABLE t1; +# +# Bug #46175: NULL read_view and consistent read assertion +# +CREATE TABLE t1(a CHAR(13),KEY(a)) ENGINE=innodb; +CREATE TABLE t2(b DATETIME,KEY(b)) ENGINE=innodb; +INSERT INTO t1 VALUES (),(); +INSERT INTO t2 VALUES (),(); +CREATE OR REPLACE VIEW v1 AS SELECT 1 FROM t2 +WHERE b =(SELECT a FROM t1 LIMIT 1); +CREATE PROCEDURE p1(num INT) +BEGIN +DECLARE i INT DEFAULT 0; +REPEAT +SHOW CREATE VIEW v1; +SET i:=i+1; +UNTIL i>num END REPEAT; +END| +# Should not crash +# Should not crash +DROP PROCEDURE p1; +DROP VIEW v1; +DROP TABLE t1,t2; +# +# Bug #49324: more valgrind errors in test_if_skip_sort_order +# +CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=innodb ; +# should not cause valgrind warnings +SELECT 1 FROM t1 JOIN t1 a USING(a) GROUP BY t1.a,t1.a; +1 +DROP TABLE t1; +# +# Bug#50843: Filesort used instead of clustered index led to +# performance degradation. +# +create table t1(f1 int not null primary key, f2 int) engine=innodb; +create table t2(f1 int not null, key (f1)) engine=innodb; +insert into t1 values (1,1),(2,2),(3,3); +insert into t2 values (1),(2),(3); +analyze table t1; +analyze table t2; +explain select t1.* from t1 left join t2 using(f1) group by t1.f1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index PRIMARY PRIMARY 4 NULL 3 100.00 NULL +2 SIMPLE t2 NULL ref f1 f1 4 test.t1.f1 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`f1` AS `f1`,`test`.`t1`.`f2` AS `f2` from `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`f1` = `test`.`t1`.`f1`)) where true group by `test`.`t1`.`f1` +drop table t1,t2; +# +# +# Bug #39653: find_shortest_key in sql_select.cc does not consider +# clustered primary keys +# +CREATE TABLE t1 (a INT PRIMARY KEY, b INT, c INT, d INT, e INT, f INT, +KEY (b,c)) ENGINE=INNODB; +INSERT INTO t1 VALUES (1,1,1,1,1,1), (2,2,2,2,2,2), (3,3,3,3,3,3), +(4,4,4,4,4,4), (5,5,5,5,5,5), (6,6,6,6,6,6), +(7,7,7,7,7,7), (8,8,8,8,8,8), (9,9,9,9,9,9), +(11,11,11,11,11,11); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT COUNT(*) FROM t1; +id 1 +select_type SIMPLE +table t1 +partitions NULL +type index +possible_keys NULL +key b +key_len 10 +ref NULL +rows 10 +filtered 100.00 +Extra Using index +Warnings: +Level Note +Code 1003 +Message /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` +DROP TABLE t1; +# +# Bug #49838: DROP INDEX and ADD UNIQUE INDEX for same index may +# corrupt definition at engine +# +CREATE TABLE t1 (a INT NOT NULL, b INT NOT NULL, KEY k (a,b)) +ENGINE=InnoDB; +ALTER TABLE t1 DROP INDEX k, ADD UNIQUE INDEX k (a,b); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +SHOW INDEXES FROM t1;; +Table t1 +Non_unique 0 +Key_name k +Seq_in_index 1 +Column_name a +Collation A +Cardinality 0 +Sub_part NULL +Packed NULL +Null +Index_type BTREE +Comment +Index_comment +Visible YES +Expression NULL +Table t1 +Non_unique 0 +Key_name k +Seq_in_index 2 +Column_name b +Collation A +Cardinality 0 +Sub_part NULL +Packed NULL +Null +Index_type BTREE +Comment +Index_comment +Visible YES +Expression NULL +DROP TABLE t1; +# +# Bug #53334: wrong result for outer join with impossible ON condition +# (see the same test case for MyISAM in join.test) +# +CREATE TABLE t1 (id INT PRIMARY KEY); +CREATE TABLE t2 (id INT); +INSERT INTO t1 VALUES (75); +INSERT INTO t1 VALUES (79); +INSERT INTO t1 VALUES (78); +INSERT INTO t1 VALUES (77); +REPLACE INTO t1 VALUES (76); +REPLACE INTO t1 VALUES (76); +INSERT INTO t1 VALUES (104); +INSERT INTO t1 VALUES (103); +INSERT INTO t1 VALUES (102); +INSERT INTO t1 VALUES (101); +INSERT INTO t1 VALUES (105); +INSERT INTO t1 VALUES (106); +INSERT INTO t1 VALUES (107); +INSERT INTO t2 VALUES (107),(75),(1000); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +ANALYZE TABLE t2; +Table Op Msg_type Msg_text +test.t2 analyze status OK +SELECT t1.id,t2.id FROM t2 LEFT JOIN t1 ON t1.id>=74 AND t1.id<=0 +WHERE t2.id=75 AND t1.id IS NULL; +id id +NULL 75 +EXPLAIN SELECT t1.id,t2.id FROM t2 LEFT JOIN t1 ON t1.id>=74 AND t1.id<=0 +WHERE t2.id=75 AND t1.id IS NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL const PRIMARY NULL NULL NULL 1 100.00 Impossible ON condition +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE t1 NULL const PRIMARY NULL NULL NULL 1 100.00 Impossible ON condition +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,`test`.`t2`.`id` AS `id` from `test`.`t2` left join `test`.`t1` on(((`test`.`t1`.`id` >= 74) and (`test`.`t1`.`id` <= 0))) where ((`test`.`t2`.`id` = 75) and (`test`.`t1`.`id` is null)) +DROP TABLE t1,t2; +# +# Bug#38999 valgrind warnings for update statement in function compare_record() +# +CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=InnoDB; +CREATE TABLE t2 (a INT PRIMARY KEY) ENGINE=InnoDB; +INSERT INTO t1 values (1),(2),(3),(4),(5); +INSERT INTO t2 values (1); +SELECT * FROM t1 WHERE a = 2; +a +2 +UPDATE t1,t2 SET t1.a = t1.a + 100 WHERE t1.a = 1; +DROP TABLE t1,t2; +# +# Bug #53830: !table || (!table->read_set || bitmap_is_set(table->read_set, field_index)) +# +CREATE TABLE t1 (a INT, b INT, c INT, d INT, +PRIMARY KEY(a,b,c), KEY(b,d)) +ENGINE=InnoDB; +INSERT INTO t1 VALUES (0, 77, 1, 3); +UPDATE t1 SET d = 0 WHERE b = 77 AND c = 25; +DROP TABLE t1; +# +# Bug#50389 Using intersect does not return all rows +# +CREATE TABLE t1 ( +f1 INT(10) NOT NULL, +f2 INT(10), +f3 INT(10), +f4 TINYINT(4), +f5 VARCHAR(50), +PRIMARY KEY (f1), +KEY idx1 (f2,f5,f4), +KEY idx2 (f2,f4) +) ENGINE=InnoDB; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +LOAD DATA INFILE '../../std_data/intersect-bug50389.tsv' INTO TABLE t1; +ANALYZE TABLE t1; +SELECT * FROM t1 WHERE f1 IN +(3305028,3353871,3772880,3346860,4228206,3336022, +3470988,3305175,3329875,3817277,3856380,3796193, +3784744,4180925,4559596,3963734,3856391,4494153) +AND f5 = 'abcdefghijklmnopwrst' AND f2 = 1221457 AND f4 = 0 ; +f1 f2 f3 f4 f5 +3305175 1221457 0 0 abcdefghijklmnopwrst +3329875 1221457 1382427 0 abcdefghijklmnopwrst +3336022 1221457 0 0 abcdefghijklmnopwrst +3346860 1221457 0 0 abcdefghijklmnopwrst +3772880 1221457 0 0 abcdefghijklmnopwrst +3784744 1221457 1382427 0 abcdefghijklmnopwrst +3796193 1221457 0 0 abcdefghijklmnopwrst +4228206 1221457 0 0 abcdefghijklmnopwrst +4494153 1221457 0 0 abcdefghijklmnopwrst +4559596 1221457 0 0 abcdefghijklmnopwrst +EXPLAIN SELECT * FROM t1 WHERE f1 IN +(3305028,3353871,3772880,3346860,4228206,3336022, +3470988,3305175,3329875,3817277,3856380,3796193, +3784744,4180925,4559596,3963734,3856391,4494153) +AND f5 = 'abcdefghijklmnopwrst' AND f2 = 1221457 AND f4 = 0 ; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 18 0.28 Parallel execute (4 workers) +2 SIMPLE t1 NULL range PRIMARY,idx1,idx2 PRIMARY 4 NULL 18 0.28 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`f1` AS `f1`,`test`.`t1`.`f2` AS `f2`,`test`.`t1`.`f3` AS `f3`,`test`.`t1`.`f4` AS `f4`,`test`.`t1`.`f5` AS `f5` from `test`.`t1` where ((`test`.`t1`.`f4` = 0) and (`test`.`t1`.`f2` = 1221457) and (`test`.`t1`.`f5` = 'abcdefghijklmnopwrst') and (`test`.`t1`.`f1` in (3305028,3353871,3772880,3346860,4228206,3336022,3470988,3305175,3329875,3817277,3856380,3796193,3784744,4180925,4559596,3963734,3856391,4494153))) +DROP TABLE t1; +# +# Bug#51431 Wrong sort order after import of dump file +# +CREATE TABLE t1 ( +f1 INT(11) NOT NULL, +f2 int(11) NOT NULL, +f3 int(11) NOT NULL, +f4 tinyint(1) NOT NULL, +PRIMARY KEY (f1), +UNIQUE KEY (f2, f3), +KEY (f4) +) ENGINE=InnoDB STATS_PERSISTENT=0; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES +(1,1,991,1), (2,1,992,1), (3,1,993,1), (4,1,994,1), (5,1,995,1), +(6,1,996,1), (7,1,997,1), (8,1,998,1), (10,1,999,1), (11,1,9910,1), +(16,1,9911,1), (17,1,9912,1), (18,1,9913,1), (19,1,9914,1), (20,1,9915,1), +(21,1,9916,1), (22,1,9917,1), (23,1,9918,1), (24,1,9919,1), (25,1,9920,1), +(26,1,9921,1), (27,1,9922,1); +FLUSH TABLES; +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +SELECT * FROM t1 WHERE f2 = 1 AND f4 = TRUE +ORDER BY f1 DESC LIMIT 5; +f1 f2 f3 f4 +27 1 9922 1 +26 1 9921 1 +25 1 9920 1 +24 1 9919 1 +23 1 9918 1 +EXPLAIN SELECT * FROM t1 WHERE f2 = 1 AND f4 = TRUE +ORDER BY f1 DESC LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 22 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range f2,f4 f4 1 NULL 22 100.00 Using index condition; Using where; Backward index scan +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`f1` AS `f1`,`test`.`t1`.`f2` AS `f2`,`test`.`t1`.`f3` AS `f3`,`test`.`t1`.`f4` AS `f4` from `test`.`t1` where ((`test`.`t1`.`f4` = true) and (`test`.`t1`.`f2` = 1)) order by `test`.`t1`.`f1` desc limit 5 +DROP TABLE t1; +# +# Bug#54117 crash in thr_multi_unlock, temporary table +# +CREATE TEMPORARY TABLE t1(a INT) ENGINE = InnoDB; +LOCK TABLES t1 READ; +ALTER TABLE t1 COMMENT 'test'; +UNLOCK TABLES; +DROP TABLE t1; +# +# Bug#55656: mysqldump can be slower after bug #39653 fix +# +CREATE TABLE t1 (a INT , b INT, c INT, d INT, +KEY (b), PRIMARY KEY (a,b)) ENGINE=INNODB STATS_PERSISTENT=0; +INSERT INTO t1 VALUES (1,1,1,1), (2,2,2,2), (3,3,3,3); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT COUNT(*) FROM t1; +id 1 +select_type SIMPLE +table t1 +partitions NULL +type index +possible_keys NULL +key b +key_len 4 +ref NULL +rows 3 +filtered 100.00 +Extra Using index +Warnings: +Level Note +Code 1003 +Message /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` +DROP INDEX b ON t1; +CREATE INDEX b ON t1(a,b); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT COUNT(*) FROM t1; +id 1 +select_type SIMPLE +table t1 +partitions NULL +type index +possible_keys NULL +key b +key_len 8 +ref NULL +rows 3 +filtered 100.00 +Extra Using index +Warnings: +Level Note +Code 1003 +Message /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` +DROP INDEX b ON t1; +CREATE INDEX b ON t1(a,b,c); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT COUNT(*) FROM t1; +id 1 +select_type SIMPLE +table t1 +partitions NULL +type index +possible_keys NULL +key b +key_len 13 +ref NULL +rows 3 +filtered 100.00 +Extra Using index +Warnings: +Level Note +Code 1003 +Message /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` +DROP INDEX b ON t1; +CREATE INDEX b ON t1(a,b,c,d); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT COUNT(*) FROM t1; +id 1 +select_type SIMPLE +table t1 +partitions NULL +type index +possible_keys NULL +key PRIMARY +key_len 8 +ref NULL +rows 3 +filtered 100.00 +Extra Using index +Warnings: +Level Note +Code 1003 +Message /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` +DROP TABLE t1; +# +# Bug#55826: create table .. select crashes with when KILL_BAD_DATA +# is returned +# +CREATE TABLE t1(a INT) ENGINE=innodb; +INSERT INTO t1 VALUES (0); +CREATE TABLE t2 +SELECT LEAST((SELECT '' FROM t1),NOW()) FROM `t1`; +ERROR 22007: Incorrect datetime value: '' for column 'NOW()' at row 2 +DROP TABLE t1; +# +# Bug#56862 Moved to innodb_16k.test +# +# +# Test for bug #39932 "create table fails if column for FK is in different +# case than in corr index". +# +drop tables if exists t1, t2; +create table t1 (pk int primary key) engine=InnoDB; +create table t2 (fk int, key x (fk), +constraint x foreign key (FK) references t1 (PK)) engine=InnoDB; +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `fk` int DEFAULT NULL, + KEY `x` (`fk`), + CONSTRAINT `x` FOREIGN KEY (`fk`) REFERENCES `t1` (`pk`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t2, t1; +# +# Test for bug #11762012 - "54553: INNODB ASSERTS IN HA_INNOBASE:: +# UPDATE_ROW, TEMPORARY TABLE, TABLE LOCK". +# +DROP TABLE IF EXISTS t1; +CREATE TEMPORARY TABLE t1 (c int) ENGINE = InnoDB; +INSERT INTO t1 VALUES (1); +LOCK TABLES t1 READ; +# Even though temporary table was locked for READ we +# still allow writes to it to be compatible with MyISAM. +# This is possible since due to fact that temporary tables +# are specific to connection and therefore locking for them +# is irrelevant. +UPDATE t1 SET c = 5; +UNLOCK TABLES; +DROP TEMPORARY TABLE t1; +# End of 5.1 tests +# +# Bug#49604 "6.0 processing compound WHERE clause incorrectly +# with Innodb - extra rows" +# +CREATE TABLE t1 ( +c1 INT NOT NULL, +c2 INT, +PRIMARY KEY (c1), +KEY k1 (c2) +) ENGINE=InnoDB; +INSERT INTO t1 VALUES (12,1); +INSERT INTO t1 VALUES (15,1); +INSERT INTO t1 VALUES (16,1); +INSERT INTO t1 VALUES (22,1); +INSERT INTO t1 VALUES (20,2); +CREATE TABLE t2 ( +c1 INT NOT NULL, +c2 INT, +PRIMARY KEY (c1) +) ENGINE=InnoDB; +INSERT INTO t2 VALUES (1,2); +INSERT INTO t2 VALUES (2,9); +SELECT STRAIGHT_JOIN t2.c2, t1.c2, t2.c1 +FROM t1 JOIN t2 ON t1.c2 = t2.c1 +WHERE t2.c1 IN (2, 1, 6) OR t2.c1 NOT IN (1); +c2 c2 c1 +2 1 1 +2 1 1 +2 1 1 +2 1 1 +9 2 2 +DROP TABLE t1, t2; +# +# Bug#44613 SELECT statement inside FUNCTION takes a shared lock +# +DROP TABLE IF EXISTS t1; +DROP FUNCTION IF EXISTS f1; +CREATE TABLE t1(x INT PRIMARY KEY, y INT) ENGINE=innodb; +INSERT INTO t1 VALUES (1, 0), (2, 0); +CREATE FUNCTION f1(z INT) RETURNS INT READS SQL DATA +RETURN (SELECT x FROM t1 WHERE x = z); +# Connection default +START TRANSACTION; +SELECT f1(1); +f1(1) +1 +# Connection con2 +START TRANSACTION; +SELECT f1(1); +f1(1) +1 +UPDATE t1 SET y = 1 WHERE x = 1; +COMMIT; +# Connection default +COMMIT; +DROP TABLE t1; +DROP FUNCTION f1; +# +# Bug#42744: Crash when using a join buffer to join a table with a blob +# column and an additional column used for duplicate elimination. +# +CREATE TABLE t1 (a tinyblob) ENGINE=InnoDB; +CREATE TABLE t2 (a int PRIMARY KEY, b tinyblob) ENGINE=InnoDB; +INSERT INTO t1 VALUES ('1'), (NULL); +INSERT INTO t2 VALUES (1, '1'); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +ANALYZE TABLE t2; +Table Op Msg_type Msg_text +test.t2 analyze status OK +EXPLAIN +SELECT t2.b FROM t1,t2 WHERE t1.a IN (SELECT 1 FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t2 NULL index NULL PRIMARY 4 NULL 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`b` AS `b` from `test`.`t1` join `test`.`t2` semi join (`test`.`t2`) where (`test`.`t1`.`a` = ``.`1`) +SELECT t2.b FROM t1,t2 WHERE t1.a IN (SELECT 1 FROM t2); +b +1 +DROP TABLE t1,t2; +# +# Bug#48093: 6.0 Server not processing equivalent IN clauses properly +# with Innodb tables +# +CREATE TABLE t1 ( +i int(11) DEFAULT NULL, +v1 varchar(1) DEFAULT NULL, +v2 varchar(20) DEFAULT NULL, +KEY i (i), +KEY v (v1,i) +) ENGINE=innodb; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (1,'f','no'); +INSERT INTO t1 VALUES (2,'u','yes-u'); +INSERT INTO t1 VALUES (2,'h','yes-h'); +INSERT INTO t1 VALUES (3,'d','no'); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK + +SELECT v2 +FROM t1 +WHERE v1 IN ('f', 'd', 'h', 'u' ) AND i = 2; +v2 +yes-u +yes-h + +# Should not use index_merge +EXPLAIN +SELECT v2 +FROM t1 +WHERE v1 IN ('f', 'd', 'h', 'u' ) AND i = 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 50.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref i,v i 5 const 2 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`v2` AS `v2` from `test`.`t1` where ((`test`.`t1`.`i` = 2) and (`test`.`t1`.`v1` in ('f','d','h','u'))) +DROP TABLE t1; +# +# Bug#54606 innodb fast alter table + pack_keys=0 +# prevents adding new indexes +# +DROP TABLE IF EXISTS t1; +CREATE TABLE t1 (a INT, b CHAR(9), c INT, key(b)) +ENGINE=InnoDB +PACK_KEYS=0; +CREATE INDEX a ON t1 (a); +CREATE INDEX c on t1 (c); +DROP TABLE t1; +# +# Additional coverage for refactoring which is made as part +# of fix for Bug#27480 "Extend CREATE TEMPORARY TABLES privilege +# to allow temp table operations". +# +# Check that OPTIMIZE table works for temporary InnoDB tables. +DROP TABLE IF EXISTS t1; +CREATE TEMPORARY TABLE t1 (a INT) ENGINE=InnoDB; +OPTIMIZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 optimize note Table does not support optimize, doing recreate + analyze instead +test.t1 optimize status OK +DROP TABLE t1; +# +# Bug#11762345 54927: DROPPING AND ADDING AN INDEX IN ONE +# COMMAND CAN FAIL IN INNODB PLUGIN 1.0 +# +DROP TABLE IF EXISTS t1; +CREATE TABLE t1 (id int, a int, b int, PRIMARY KEY (id), +INDEX a (a)) ENGINE=innodb; +ALTER TABLE t1 DROP INDEX a, ADD INDEX a (b, a); +ALTER TABLE t1 DROP INDEX a, ADD INDEX (a, b); +DROP TABLE t1; +# +# Check the prefix index on BLOB could not be promoted to PRIMARY KEY +# +CREATE TABLE t1 (a INT NOT NULL, d INT NOT NULL, b TEXT NOT NULL, c TEXT, +UNIQUE KEY (b(8) desc, a asc, d)) ENGINE = InnoDB; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int NOT NULL, + `d` int NOT NULL, + `b` text NOT NULL, + `c` text, + UNIQUE KEY `b` (`b`(8) DESC,`a`,`d`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +DROP TABLE t1; +# +# Bug#25650516. The problem is the index order for the old and new +# dd::Table are different +# +CREATE TABLE t1 (col1 INT, col2 INT) ENGINE = InnoDB; +ALTER TABLE t1 ADD UNIQUE KEY uidx ( col2 ); +ALTER TABLE t1 ADD UNIQUE KEY uidx ( col1 ), RENAME KEY uidx TO new_uidx; +ALTER TABLE t1 ADD PRIMARY KEY ( col1 ); +ALTER TABLE t1 ALTER COLUMN col1 DROP DEFAULT; +DROP TABLE t1; +# +# BUG 25674492 - INNODB: ASSERTION FAILURE: HA_INNODB.CC:13881 +# :DD_TABLE_MATCH(TABLE, DD_TABLE) +# +CREATE TABLE t1 (col1 INT, col4 TEXT) ENGINE = InnoDB ROW_FORMAT = COMPACT; +ALTER TABLE t1 ADD KEY idx ( col1 ), ADD FULLTEXT KEY ftidx ( col4 ); +Warnings: +Warning 124 InnoDB rebuilding table to add column FTS_DOC_ID +ALTER TABLE t1 DROP KEY ftidx; +TRUNCATE TABLE t1; +DROP TABLE t1; +End of 6.0 tests diff --git a/mysql-test/suite/innodb_table_io.result-pq b/mysql-test/suite/innodb_table_io.result-pq new file mode 100644 index 000000000000..6516d646eb71 --- /dev/null +++ b/mysql-test/suite/innodb_table_io.result-pq @@ -0,0 +1,146 @@ +drop table if exists test.marker; +create table test.marker(a int); +update performance_schema.setup_consumers set enabled='NO'; +update performance_schema.setup_instruments set enabled='NO'; +update performance_schema.setup_instruments set enabled='YES' + where name like "wait/io/table/%"; +truncate table performance_schema.events_waits_history_long; +flush status; +flush tables; +drop table if exists test.no_index_tab; +update performance_schema.setup_consumers set enabled='YES'; +insert into marker set a = 1; +create table test.no_index_tab +( a varchar(255) not null, b int not null) engine = InnoDB; +insert into marker set a = 1; +show create table test.no_index_tab; +Table Create Table +no_index_tab CREATE TABLE `no_index_tab` ( + `a` varchar(255) NOT NULL, + `b` int NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +insert into marker set a = 1; +insert into test.no_index_tab set a = 'foo', b = 1; +insert into marker set a = 1; +insert into test.no_index_tab set a = 'foo', b = 2; +insert into marker set a = 1; +insert into test.no_index_tab set a = 'foo', b = 3; +insert into marker set a = 1; +select * from test.no_index_tab; +a b +foo 1 +foo 2 +foo 3 +insert into marker set a = 1; +update test.no_index_tab set a = 'bar'; +insert into marker set a = 1; +select * from test.no_index_tab limit 2; +a b +bar 1 +bar 2 +insert into marker set a = 1; +delete from test.no_index_tab where b = 3; +insert into marker set a = 1; +select * from test.no_index_tab; +a b +bar 1 +bar 2 +insert into marker set a = 1; +optimize table test.no_index_tab; +Table Op Msg_type Msg_text +test.no_index_tab optimize note Table does not support optimize, doing recreate + analyze instead +test.no_index_tab optimize status OK +insert into marker set a = 1; +select * from test.no_index_tab; +a b +bar 1 +bar 2 +insert into marker set a = 1; +truncate table test.no_index_tab; +insert into marker set a = 1; +drop table test.no_index_tab; +update performance_schema.setup_consumers set enabled='NO'; +select event_name, +left(source, locate(":", source)) as short_source, +object_type, object_schema, +if (locate("#sql-", object_name), "#sql-XXXX", object_name) +as pretty_name, +operation, number_of_bytes +from performance_schema.events_waits_history_long +where event_name like 'wait/io/table/%' + and object_schema in ("test") +order by thread_id, event_id; +event_name short_source object_type object_schema pretty_name operation number_of_bytes +wait/io/table/sql/handler handler.cc: TABLE test marker insert 1 +wait/io/table/sql/handler handler.cc: TABLE test marker insert 1 +wait/io/table/sql/handler handler.cc: TABLE test marker insert 1 +wait/io/table/sql/handler handler.cc: TABLE test no_index_tab insert 1 +wait/io/table/sql/handler handler.cc: TABLE test marker insert 1 +wait/io/table/sql/handler handler.cc: TABLE test no_index_tab insert 1 +wait/io/table/sql/handler handler.cc: TABLE test marker insert 1 +wait/io/table/sql/handler handler.cc: TABLE test no_index_tab insert 1 +wait/io/table/sql/handler handler.cc: TABLE test marker insert 1 +wait/io/table/sql/handler handler.cc: TABLE test marker insert 1 +wait/io/table/sql/handler handler.cc: TABLE test no_index_tab fetch 1 +wait/io/table/sql/handler handler.cc: TABLE test no_index_tab update 1 +wait/io/table/sql/handler handler.cc: TABLE test no_index_tab fetch 1 +wait/io/table/sql/handler handler.cc: TABLE test no_index_tab update 1 +wait/io/table/sql/handler handler.cc: TABLE test no_index_tab fetch 1 +wait/io/table/sql/handler handler.cc: TABLE test no_index_tab update 1 +wait/io/table/sql/handler handler.cc: TABLE test no_index_tab fetch 1 +wait/io/table/sql/handler handler.cc: TABLE test marker insert 1 +wait/io/table/sql/handler handler.cc: TABLE test marker insert 1 +wait/io/table/sql/handler handler.cc: TABLE test no_index_tab fetch 1 +wait/io/table/sql/handler handler.cc: TABLE test no_index_tab fetch 1 +wait/io/table/sql/handler handler.cc: TABLE test no_index_tab fetch 1 +wait/io/table/sql/handler handler.cc: TABLE test no_index_tab delete 1 +wait/io/table/sql/handler handler.cc: TABLE test no_index_tab fetch 1 +wait/io/table/sql/handler handler.cc: TABLE test marker insert 1 +wait/io/table/sql/handler handler.cc: TABLE test marker insert 1 +wait/io/table/sql/handler handler.cc: TABLE test marker insert 1 +wait/io/table/sql/handler handler.cc: TABLE test marker insert 1 +wait/io/table/sql/handler handler.cc: TABLE test marker insert 1 +wait/io/table/sql/handler handler.cc: TABLE test no_index_tab fetch 3 +wait/io/table/sql/handler handler.cc: TABLE test no_index_tab fetch 2 +wait/io/table/sql/handler handler.cc: TABLE test no_index_tab fetch 2 +wait/io/table/sql/handler handler.cc: TABLE test no_index_tab fetch 2 +show global status like 'performance_schema_%_lost'; +Variable_name Value +Performance_schema_accounts_lost 0 +Performance_schema_cond_classes_lost 0 +Performance_schema_cond_instances_lost 0 +Performance_schema_digest_lost 0 +Performance_schema_file_classes_lost 0 +Performance_schema_file_handles_lost 0 +Performance_schema_file_instances_lost 0 +Performance_schema_hosts_lost 0 +Performance_schema_index_stat_lost 0 +Performance_schema_locker_lost 0 +Performance_schema_memory_classes_lost 0 +Performance_schema_metadata_lock_lost 0 +Performance_schema_mutex_classes_lost 0 +Performance_schema_mutex_instances_lost 0 +Performance_schema_nested_statement_lost 0 +Performance_schema_prepared_statements_lost 0 +Performance_schema_program_lost 0 +Performance_schema_rwlock_classes_lost 0 +Performance_schema_rwlock_instances_lost 0 +Performance_schema_session_connect_attrs_lost 0 +Performance_schema_socket_classes_lost 0 +Performance_schema_socket_instances_lost 0 +Performance_schema_stage_classes_lost 0 +Performance_schema_statement_classes_lost 0 +Performance_schema_table_handles_lost 0 +Performance_schema_table_instances_lost 0 +Performance_schema_table_lock_stat_lost 0 +Performance_schema_thread_classes_lost 0 +Performance_schema_thread_instances_lost 0 +Performance_schema_users_lost 0 +truncate performance_schema.events_waits_history_long; +flush status; +update performance_schema.setup_consumers set enabled='NO'; +truncate performance_schema.events_waits_history_long; +drop table test.marker; +flush status; +update performance_schema.setup_instruments set enabled='YES'; +update performance_schema.setup_consumers set enabled='YES'; diff --git a/mysql-test/suite/instant_add_column_basic.result-pq b/mysql-test/suite/instant_add_column_basic.result-pq new file mode 100644 index 000000000000..8e4d9cfa3b21 --- /dev/null +++ b/mysql-test/suite/instant_add_column_basic.result-pq @@ -0,0 +1,6258 @@ +############################################## +# Test instant ADD COLUMN for REDUNDANT format +############################################## +# +# Scenario 1: +# Create a small table, and add all kinds of new columns and verify +# +CREATE TABLE t1 (a INT NOT NULL AUTO_INCREMENT PRIMARY KEY, b INT) ROW_FORMAT=REDUNDANT; +INSERT INTO t1 VALUES(0, 1), (0, 2), (0, 3), (0, 4), (0, 5); +ALTER TABLE t1 ADD COLUMN c1 INT, ALGORITHM=INSTANT; +Table id did not change +count(*) = 1 +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'c1' AND has_default = 1; +name default_value +c1 NULL +INSERT INTO t1(a, c1) VALUES(0, 1); +SELECT count(*) = max(a) FROM t1 WHERE c1 IS NULL; +count(*) = max(a) +1 +SELECT c1 FROM t1 WHERE c1 = 1; +c1 +1 +ALTER TABLE t1 ADD COLUMN c2 INT NOT NULL DEFAULT 10; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'c2' AND has_default = 1; +name default_value +c2 8000000a +INSERT INTO t1(a, c2) VALUES(0, 11); +SELECT count(*) = max(a) FROM t1 WHERE c2 = 10; +count(*) = max(a) +1 +SELECT c2 FROM t1 WHERE c2 = 11; +c2 +11 +ALTER TABLE t1 ADD COLUMN d1 BIGINT, ALGORITHM=INSTANT; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'd1' AND has_default = 1; +name default_value +d1 NULL +INSERT INTO t1(a, d1) VALUES(0, 1); +SELECT count(*) = max(a) FROM t1 WHERE d1 IS NULL; +count(*) = max(a) +1 +SELECT d1 FROM t1 WHERE d1 = 1; +d1 +1 +ALTER TABLE t1 ADD COLUMN d2 BIGINT NOT NULL DEFAULT 1234567890; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'd2' AND has_default = 1; +name default_value +d2 80000000499602d2 +INSERT INTO t1(a, d2) VALUES(0, 1234); +SELECT count(*) = max(a) FROM t1 WHERE d2 = 1234567890; +count(*) = max(a) +1 +SELECT d2 FROM t1 WHERE d2 = 1234; +d2 +1234 +ALTER TABLE t1 ADD COLUMN e1 SMALLINT, ALGORITHM=INSTANT; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'e1' AND has_default = 1; +name default_value +e1 NULL +INSERT INTO t1(a, e1) VALUES(0, 1); +SELECT count(*) = max(a) FROM t1 WHERE e1 IS NULL; +count(*) = max(a) +1 +SELECT e1 FROM t1 WHERE e1 = 1; +e1 +1 +ALTER TABLE t1 ADD COLUMN e2 SMALLINT NOT NULL DEFAULT 10; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'e2' AND has_default = 1; +name default_value +e2 800a +INSERT INTO t1(a, e2) VALUES(0, 11); +SELECT count(*) = max(a) FROM t1 WHERE e2 = 10; +count(*) = max(a) +1 +SELECT e2 FROM t1 WHERE e2 = 11; +e2 +11 +ALTER TABLE t1 ADD COLUMN f1 TINYINT, ALGORITHM=INSTANT; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'f1' AND has_default = 1; +name default_value +f1 NULL +INSERT INTO t1(a, f1) VALUES(0, 1); +SELECT count(*) = max(a) FROM t1 WHERE f1 IS NULL; +count(*) = max(a) +1 +SELECT f1 FROM t1 WHERE f1 = 1; +f1 +1 +ALTER TABLE t1 ADD COLUMN f2 TINYINT NOT NULL DEFAULT 123; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'f2' AND has_default = 1; +name default_value +f2 fb +INSERT INTO t1(a, f2) VALUES(0, 12); +SELECT count(*) = max(a) FROM t1 WHERE f2 = 123; +count(*) = max(a) +1 +SELECT f2 FROM t1 WHERE f2 = 12; +f2 +12 +ALTER TABLE t1 ADD COLUMN g1 MEDIUMINT, ALGORITHM=INSTANT; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'g1' AND has_default = 1; +name default_value +g1 NULL +INSERT INTO t1(a, g1) VALUES(0, 1); +SELECT count(*) = max(a) FROM t1 WHERE g1 IS NULL; +count(*) = max(a) +1 +SELECT g1 FROM t1 WHERE g1 = 1; +g1 +1 +ALTER TABLE t1 ADD COLUMN g2 MEDIUMINT NOT NULL DEFAULT 12345; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'g2' AND has_default = 1; +name default_value +g2 803039 +INSERT INTO t1(a, g2) VALUES(0, 1234); +SELECT count(*) = max(a) FROM t1 WHERE g2 = 12345; +count(*) = max(a) +1 +SELECT g2 FROM t1 WHERE g2 = 1234; +g2 +1234 +ALTER TABLE t1 ADD COLUMN h1 FLOAT, ALGORITHM=INSTANT; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'h1' AND has_default = 1; +name default_value +h1 NULL +INSERT INTO t1(a, h1) VALUES(0, 1.0); +SELECT count(*) = max(a) FROM t1 WHERE h1 IS NULL; +count(*) = max(a) +1 +SELECT h1 FROM t1 WHERE h1 = 1; +h1 +1 +ALTER TABLE t1 ADD COLUMN h2 FLOAT NOT NULL DEFAULT 12.34; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'h2' AND has_default = 1; +name default_value +h2 a4704541 +INSERT INTO t1(a, h2) VALUES(0, 1.234); +SELECT count(*) = max(a) FROM t1 WHERE h2 = 12.34; +count(*) = max(a) +NULL +SELECT h2 FROM t1 WHERE h2 = 1.234; +h2 +ALTER TABLE t1 ADD COLUMN i1 DECIMAL(5, 2), ADD COLUMN i2 double, ALGORITHM=INSTANT; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE (name = 'i1' OR name = 'i2') AND has_default = 1; +name default_value +i1 NULL +i2 NULL +INSERT INTO t1(a, i1, i2) VALUES(0, 10.10, 20.20); +SELECT count(*) = max(a) FROM t1 WHERE i1 IS NULL; +count(*) = max(a) +1 +SELECT count(*) = max(a) FROM t1 WHERE i2 IS NULL; +count(*) = max(a) +1 +SELECT i1 FROM t1 WHERE i1 = 10.10; +i1 +10.10 +SELECT i2 FROM t1 WHERE i2 = 20.20; +i2 +20.2 +ALTER TABLE t1 ADD COLUMN j1 DECIMAL(5, 2) NOT NULL DEFAULT 100.00, ADD COLUMN j2 double NOT NULL DEFAULT 1000.5678; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE (name = 'j1' OR name = 'j2') AND has_default = 1; +name default_value +j1 806400 +j2 5af5b9da8a448f40 +INSERT INTO t1(a, j1, j2) VALUES(0, 90.90, 1000.1234); +SELECT count(*) = max(a) FROM t1 WHERE j1 = 100.00; +count(*) = max(a) +1 +SELECT count(*) = max(a) FROM t1 WHERE j2 = 1000.5678; +count(*) = max(a) +1 +SELECT j1 FROM t1 WHERE j1 = 90.90; +j1 +90.90 +SELECT j2 FROM t1 WHERE j2 = 1000.1234; +j2 +1000.1234 +ALTER TABLE t1 ADD COLUMN k1 BIT(8), ALGORITHM=INSTANT; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'k1' AND has_default = 1; +name default_value +k1 NULL +INSERT INTO t1(a, k1) VALUES(0, b'010101'); +SELECT count(*) = max(a) FROM t1 WHERE k1 IS NULL; +count(*) = max(a) +1 +SELECT hex(k1) FROM t1 WHERE k1 = b'010101'; +hex(k1) +15 +ALTER TABLE t1 ADD COLUMN k2 BIT(8) NOT NULL DEFAULT b'101010'; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'k2' AND has_default = 1; +name default_value +k2 2a +INSERT INTO t1(a, k2) VALUES(0, b'110011'); +SELECT count(*) = max(a) FROM t1 WHERE k2 = b'101010'; +count(*) = max(a) +1 +SELECT hex(k2) FROM t1 WHERE k2 = b'110011'; +hex(k2) +33 +ALTER TABLE t1 ADD COLUMN l1 CHAR(50), ADD COLUMN l2 VARCHAR(100), ALGORITHM=DEFAULT; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE (name = 'l1' OR name = 'l2') AND has_default = 1; +name default_value +l1 NULL +l2 NULL +INSERT INTO t1(a, l1, l2) VALUES(0, 'ABCD EFGH', 'abcdefg hijklmn '); +SELECT count(*) = max(a) FROM t1 WHERE l2 IS NULL; +count(*) = max(a) +1 +SELECT count(*) = max(a) FROM t1 WHERE l1 IS NULL; +count(*) = max(a) +1 +SELECT l1 FROM t1 WHERE l1 = 'ABCD EFGH'; +l1 +ABCD EFGH +SELECT l2 FROM t1 WHERE l2 = 'abcdefg hijklmn '; +l2 +abcdefg hijklmn +ALTER TABLE t1 ADD COLUMN m1 CHAR(50) default 'The fox jumps over', ADD COLUMN m2 VARCHAR(50) DEFAULT 'The fox jumps over the lazy dog.'; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE (name = 'm1' OR name = 'm2') AND has_default = 1; +name default_value +m1 54686520666f78206a756d7073206f7665722020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020 +m2 54686520666f78206a756d7073206f76657220746865206c617a7920646f672e +INSERT INTO t1(a, m1, m2) VALUES(0, 'over the lazy dog', 'The lazy dog jumps over the fox.'); +SELECT count(*) = max(a) FROM t1 WHERE m1 = 'The fox jumps over'; +count(*) = max(a) +1 +SELECT count(*) = max(a) FROM t1 WHERE m2 like 'The fox jumps%'; +count(*) = max(a) +1 +SELECT m1 FROM t1 WHERE m1 = 'over the lazy dog'; +m1 +over the lazy dog +SELECT m2 FROM t1 WHERE m2 like '%the fox.'; +m2 +The lazy dog jumps over the fox. +ALTER TABLE t1 ADD COLUMN n1 BINARY(10), ADD COLUMN n2 VARBINARY(10), ALGORITHM=DEFAULT; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE (name = 'n1' OR name = 'n2') AND has_default = 1; +name default_value +n1 NULL +n2 NULL +INSERT INTO t1(a, n1, n2) VALUES(0, 0x010203040506070809, 0x102030405060708090); +SELECT count(*) = max(a) FROM t1 WHERE n1 IS NULL; +count(*) = max(a) +1 +SELECT count(*) = max(a) FROM t1 WHERE n2 IS NULL; +count(*) = max(a) +1 +SELECT hex(n1) FROM t1 WHERE n1 = 0x01020304050607080900; +hex(n1) +01020304050607080900 +SELECT hex(n2) FROM t1 WHERE n2 = 0x102030405060708090; +hex(n2) +102030405060708090 +ALTER TABLE t1 ADD COLUMN o1 BINARY(10) DEFAULT 0x11223344, ADD COLUMN o2 VARBINARY(10) DEFAULT 0x55667788; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE (name = 'o1' OR name = 'o2') AND has_default = 1; +name default_value +o1 11223344000000000000 +o2 55667788 +INSERT INTO t1(a, o1, o2) VALUES(0, 0x44332211, 0x88776655); +SELECT count(*) = max(a) FROM t1 WHERE o1 = 0x11223344000000000000; +count(*) = max(a) +1 +SELECT count(*) = max(a) FROM t1 WHERE o2 = 0x55667788; +count(*) = max(a) +1 +SELECT hex(o1) FROM t1 WHERE o1 = 0x44332211000000000000; +hex(o1) +44332211000000000000 +SELECT hex(o2) FROM t1 WHERE o2 = 0x88776655; +hex(o2) +88776655 +ALTER TABLE t1 ADD COLUMN p1 DATETIME, ALGORITHM=DEFAULT; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'p1' AND has_default = 1; +name default_value +p1 NULL +INSERT INTO t1(a, p1) VALUES(0, '2017-12-31 00:00:00'); +SELECT count(*) = max(a) FROM t1 WHERE p1 IS NULL; +count(*) = max(a) +1 +SELECT p1 FROM t1 WHERE p1 = '2017-12-31 00:00:00'; +p1 +2017-12-31 00:00:00 +ALTER TABLE t1 ADD COLUMN p2 DATETIME NOT NULL DEFAULT '2017-12-31 01:02:03'; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'p2' AND has_default = 1; +name default_value +p2 999e7e1083 +SELECT count(*) = max(a) FROM t1 GROUP BY p2; +count(*) = max(a) +1 +INSERT INTO t1(a, p2) VALUES(0, now()); +SELECT count(*) FROM t1 GROUP BY p2; +count(*) +26 +1 +ALTER TABLE t1 ADD COLUMN q1 ENUM ('value1','value2','value3'), ALGORITHM=INSTANT; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'q1' AND has_default = 1; +name default_value +q1 NULL +INSERT INTO t1(a, q1) VALUES(0, 1); +SELECT count(*) = max(a) FROM t1 WHERE q1 IS NULL; +count(*) = max(a) +1 +SELECT q1 FROM t1 WHERE q1 = 1; +q1 +value1 +ALTER TABLE t1 ADD COLUMN r1 SET ('a','b','c'), ALGORITHM=INSTANT; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'r1' AND has_default = 1; +name default_value +r1 NULL +INSERT INTO t1(a, r1) VALUES(0, 'a'); +SELECT count(*) = max(a) FROM t1 WHERE r1 IS NULL; +count(*) = max(a) +1 +SELECT r1 FROM t1 WHERE r1 = 'a'; +r1 +a +ALTER TABLE t1 ADD COLUMN s1 BLOB, ADD COLUMN s2 TEXT, ALGORITHM=INSTANT; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE (name = 's1' OR name = 's2') AND has_default = 1; +name default_value +s1 NULL +s2 NULL +INSERT INTO t1(a, s1, s2) VALUES(0, 0x0102030405, 'abcd qwerty'); +SELECT count(*) = max(a) FROM t1 WHERE s1 IS NULL; +count(*) = max(a) +1 +SELECT count(*) = max(a) FROM t1 WHERE s2 IS NULL; +count(*) = max(a) +1 +SELECT hex(s1) FROM t1 WHERE s1 = 0x0102030405; +hex(s1) +0102030405 +SELECT s2 FROM t1 WHERE s2 = 'abcd qwerty'; +s2 +abcd qwerty +ALTER TABLE t1 ADD COLUMN u1 BLOB NOT NULL, ADD COLUMN u2 TEXT NOT NULL; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE (name = 'u1' OR name = 'u2') AND has_default = 1; +name default_value +u1 +u2 +INSERT INTO t1(a, u1, u2) VALUES(0, 0x0102030405, 'abcd qwerty'); +SELECT count(*) = max(a) FROM t1 WHERE u1 = ''; +count(*) = max(a) +1 +SELECT count(*) = max(a) FROM t1 WHERE u2 = ''; +count(*) = max(a) +1 +SELECT hex(u1) FROM t1 WHERE u1 = 0x0102030405; +hex(u1) +0102030405 +SELECT u2 FROM t1 WHERE u2 = 'abcd qwerty'; +u2 +abcd qwerty +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int NOT NULL AUTO_INCREMENT, + `b` int DEFAULT NULL, + `c1` int DEFAULT NULL, + `c2` int NOT NULL DEFAULT '10', + `d1` bigint DEFAULT NULL, + `d2` bigint NOT NULL DEFAULT '1234567890', + `e1` smallint DEFAULT NULL, + `e2` smallint NOT NULL DEFAULT '10', + `f1` tinyint DEFAULT NULL, + `f2` tinyint NOT NULL DEFAULT '123', + `g1` mediumint DEFAULT NULL, + `g2` mediumint NOT NULL DEFAULT '12345', + `h1` float DEFAULT NULL, + `h2` float NOT NULL DEFAULT '12.34', + `i1` decimal(5,2) DEFAULT NULL, + `i2` double DEFAULT NULL, + `j1` decimal(5,2) NOT NULL DEFAULT '100.00', + `j2` double NOT NULL DEFAULT '1000.5678', + `k1` bit(8) DEFAULT NULL, + `k2` bit(8) NOT NULL DEFAULT b'101010', + `l1` char(50) DEFAULT NULL, + `l2` varchar(100) DEFAULT NULL, + `m1` char(50) DEFAULT 'The fox jumps over', + `m2` varchar(50) DEFAULT 'The fox jumps over the lazy dog.', + `n1` binary(10) DEFAULT NULL, + `n2` varbinary(10) DEFAULT NULL, + `o1` binary(10) DEFAULT '"3D\0\0\0\0\0\0', + `o2` varbinary(10) DEFAULT 'Ufw?', + `p1` datetime DEFAULT NULL, + `p2` datetime NOT NULL DEFAULT '2017-12-31 01:02:03', + `q1` enum('value1','value2','value3') DEFAULT NULL, + `r1` set('a','b','c') DEFAULT NULL, + `s1` blob, + `s2` text, + `u1` blob NOT NULL, + `u2` text NOT NULL, + PRIMARY KEY (`a`) +) ENGINE=InnoDB AUTO_INCREMENT=32 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=REDUNDANT +DROP TABLE t1; +# +# Scenario 2: +# Create a small table, add some columns instantly, along with +# virtual columns +# +CREATE TABLE t1 (a INT NOT NULL AUTO_INCREMENT PRIMARY KEY, b INT) ROW_FORMAT=REDUNDANT; +INSERT INTO t1 VALUES(0, 1), (0, 2), (0, 3), (0, 4), (0, 5); +ALTER TABLE t1 ADD COLUMN c INT NOT NULL, ADD COLUMN d INT GENERATED ALWAYS AS ((b * 2)) VIRTUAL; +Table id did not change +count(*) = 1 +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +INSERT INTO t1(a, b, c) VALUES(0, 6, 20); +SELECT * FROM t1; +a b c d +1 1 0 2 +2 2 0 4 +3 3 0 6 +4 4 0 8 +5 5 0 10 +6 6 20 12 +ALTER TABLE t1 ADD COLUMN e VARCHAR(100) DEFAULT 'ABCD EFGH', ADD COLUMN f INT GENERATED ALWAYS AS (LENGTH(e)); +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +INSERT INTO t1(a, c, e) VALUES(0, 20, 'Hello'), (0, 20, 'World'), (0, 20, 'Hello World'); +SELECT * FROM t1; +a b c d e f +1 1 0 2 ABCD EFGH 9 +2 2 0 4 ABCD EFGH 9 +3 3 0 6 ABCD EFGH 9 +4 4 0 8 ABCD EFGH 9 +5 5 0 10 ABCD EFGH 9 +6 6 20 12 ABCD EFGH 9 +7 NULL 20 NULL Hello 5 +8 NULL 20 NULL World 5 +9 NULL 20 NULL Hello World 11 +ALTER TABLE t1 ADD COLUMN g VARCHAR(100) GENERATED ALWAYS AS (e), ADD COLUMN h BIGINT DEFAULT 10000, ADD COLUMN i BIGINT GENERATED ALWAYS AS (h * 2 + b); +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT * FROM t1; +a b c d e f g h i +1 1 0 2 ABCD EFGH 9 ABCD EFGH 10000 20001 +2 2 0 4 ABCD EFGH 9 ABCD EFGH 10000 20002 +3 3 0 6 ABCD EFGH 9 ABCD EFGH 10000 20003 +4 4 0 8 ABCD EFGH 9 ABCD EFGH 10000 20004 +5 5 0 10 ABCD EFGH 9 ABCD EFGH 10000 20005 +6 6 20 12 ABCD EFGH 9 ABCD EFGH 10000 20006 +7 NULL 20 NULL Hello 5 Hello 10000 NULL +8 NULL 20 NULL World 5 World 10000 NULL +9 NULL 20 NULL Hello World 11 Hello World 10000 NULL +INSERT INTO t1(a, b, c, h) VALUES(0, 7, 40, 2000), (0, 7, 40, 20000); +SELECT * FROM t1; +a b c d e f g h i +1 1 0 2 ABCD EFGH 9 ABCD EFGH 10000 20001 +2 2 0 4 ABCD EFGH 9 ABCD EFGH 10000 20002 +3 3 0 6 ABCD EFGH 9 ABCD EFGH 10000 20003 +4 4 0 8 ABCD EFGH 9 ABCD EFGH 10000 20004 +5 5 0 10 ABCD EFGH 9 ABCD EFGH 10000 20005 +6 6 20 12 ABCD EFGH 9 ABCD EFGH 10000 20006 +7 NULL 20 NULL Hello 5 Hello 10000 NULL +8 NULL 20 NULL World 5 World 10000 NULL +9 NULL 20 NULL Hello World 11 Hello World 10000 NULL +10 7 40 14 ABCD EFGH 9 ABCD EFGH 2000 4007 +11 7 40 14 ABCD EFGH 9 ABCD EFGH 20000 40007 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int NOT NULL AUTO_INCREMENT, + `b` int DEFAULT NULL, + `c` int NOT NULL, + `d` int GENERATED ALWAYS AS ((`b` * 2)) VIRTUAL, + `e` varchar(100) DEFAULT 'ABCD EFGH', + `f` int GENERATED ALWAYS AS (length(`e`)) VIRTUAL, + `g` varchar(100) GENERATED ALWAYS AS (`e`) VIRTUAL, + `h` bigint DEFAULT '10000', + `i` bigint GENERATED ALWAYS AS (((`h` * 2) + `b`)) VIRTUAL, + PRIMARY KEY (`a`) +) ENGINE=InnoDB AUTO_INCREMENT=12 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=REDUNDANT +DROP TABLE t1; +# +# Scenario 3: +# Create a small table, add some columns instantly, then change +# their default values, check original default values are correct +# +CREATE TABLE t1 (a INT NOT NULL AUTO_INCREMENT PRIMARY KEY, b INT) ROW_FORMAT=REDUNDANT; +INSERT INTO t1 VALUES(0, 1), (0, 2), (0, 3), (0, 4), (0, 5); +ALTER TABLE t1 ADD COLUMN c INT NOT NULL DEFAULT 100, ADD COLUMN d INT GENERATED ALWAYS AS ((c * 2 + b)) VIRTUAL, ADD COLUMN e VARCHAR(100) DEFAULT 'Hello world'; +Table id did not change +count(*) = 2 +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT * FROM t1; +a b c d e +1 1 100 201 Hello world +2 2 100 202 Hello world +3 3 100 203 Hello world +4 4 100 204 Hello world +5 5 100 205 Hello world +INSERT INTO t1(a, b, c, e) VALUES(0, 6, 200, 'Good day'), (0, 7, 300, 'Good DAY'); +SELECT * FROM t1; +a b c d e +1 1 100 201 Hello world +2 2 100 202 Hello world +3 3 100 203 Hello world +4 4 100 204 Hello world +5 5 100 205 Hello world +6 6 200 406 Good day +7 7 300 607 Good DAY +SELECT default_value FROM information_schema.innodb_columns WHERE name = 'c' AND has_default = 1; +default_value +80000064 +ALTER TABLE t1 ALTER COLUMN c SET DEFAULT 500; +SELECT default_value FROM information_schema.innodb_columns WHERE name = 'c' AND +has_default = 1; +default_value +80000064 +SELECT * FROM t1; +a b c d e +1 1 100 201 Hello world +2 2 100 202 Hello world +3 3 100 203 Hello world +4 4 100 204 Hello world +5 5 100 205 Hello world +6 6 200 406 Good day +7 7 300 607 Good DAY +INSERT INTO t1(a, b) VALUES(0, 8), (0, 9); +SELECT * FROM t1; +a b c d e +1 1 100 201 Hello world +2 2 100 202 Hello world +3 3 100 203 Hello world +4 4 100 204 Hello world +5 5 100 205 Hello world +6 6 200 406 Good day +7 7 300 607 Good DAY +8 8 500 1008 Hello world +9 9 500 1009 Hello world +SELECT default_value FROM information_schema.innodb_columns WHERE name = 'e' AND has_default = 1; +default_value +48656c6c6f20776f726c64 +ALTER TABLE t1 ALTER COLUMN e SET DEFAULT 'HELLO MySQL!'; +SELECT default_value FROM information_schema.innodb_columns WHERE name = 'e' AND has_default = 1; +default_value +48656c6c6f20776f726c64 +SELECT * FROM t1; +a b c d e +1 1 100 201 Hello world +2 2 100 202 Hello world +3 3 100 203 Hello world +4 4 100 204 Hello world +5 5 100 205 Hello world +6 6 200 406 Good day +7 7 300 607 Good DAY +8 8 500 1008 Hello world +9 9 500 1009 Hello world +INSERT INTO t1(a, b) VALUES(0, 10), (0, 20); +SELECT * FROM t1; +a b c d e +1 1 100 201 Hello world +2 2 100 202 Hello world +3 3 100 203 Hello world +4 4 100 204 Hello world +5 5 100 205 Hello world +6 6 200 406 Good day +7 7 300 607 Good DAY +8 8 500 1008 Hello world +9 9 500 1009 Hello world +10 10 500 1010 HELLO MySQL! +11 20 500 1020 HELLO MySQL! +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int NOT NULL AUTO_INCREMENT, + `b` int DEFAULT NULL, + `c` int NOT NULL DEFAULT '500', + `d` int GENERATED ALWAYS AS (((`c` * 2) + `b`)) VIRTUAL, + `e` varchar(100) DEFAULT 'HELLO MySQL!', + PRIMARY KEY (`a`) +) ENGINE=InnoDB AUTO_INCREMENT=12 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=REDUNDANT +DROP TABLE t1; +# +# Scenario 4: +# Create a small table, add some columns instantly, then do DML +# on the table +# +CREATE TABLE t1 (a INT NOT NULL AUTO_INCREMENT PRIMARY KEY, b INT) ROW_FORMAT=REDUNDANT; +INSERT INTO t1 VALUES(0, 1), (0, 2), (0, 3), (0, 4), (0, 5); +ALTER TABLE t1 ADD COLUMN c INT NOT NULL DEFAULT 100, ADD COLUMN d INT GENERATED ALWAYS AS ((c * 2 + b)) VIRTUAL, ADD COLUMN e VARCHAR(100) DEFAULT 'Hello world'; +Table id did not change +count(*) = 2 +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +UPDATE t1 SET c = 200 WHERE a > 3; +SELECT distinct(c) FROM t1; +c +100 +200 +INSERT INTO t1(b, c, e) SELECT b, c, e FROM t1; +INSERT INTO t1(b, c, e) SELECT b, c, e FROM t1; +INSERT INTO t1(b, c, e) SELECT b, c, e FROM t1; +DELETE FROM t1 WHERE c = 100; +UPDATE t1 SET c = 300; +SELECT distinct(c) FROM t1; +c +300 +SELECT count(*) FROM t1; +count(*) +16 +ALTER TABLE t1 ADD COLUMN t DATETIME DEFAULT CURRENT_TIMESTAMP; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +UPDATE t1 SET e = 'Hello MySQL' WHERE a > 10; +UPDATE t1 SET e = 'Hello MySQL!!' WHERE a > 20; +SELECT distinct(e) FROM t1; +e +Hello world +Hello MySQL +Hello MySQL!! +UPDATE t1 SET c = 500 WHERE e LIKE '%world%'; +SELECT c, e FROM t1 GROUP BY c, e; +c e +300 Hello MySQL +300 Hello MySQL!! +500 Hello world +INSERT INTO t1(b, c, e) SELECT b, c, e FROM t1; +UPDATE t1 SET t = CURRENT_TIMESTAMP WHERE a < 50; +SELECT count(t) FROM t1 GROUP BY t; +count(t) +16 +16 +DELETE FROM t1 WHERE a < 50; +SELECT count(t) FROM t1 GROUP BY t; +count(t) +16 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int NOT NULL AUTO_INCREMENT, + `b` int DEFAULT NULL, + `c` int NOT NULL DEFAULT '100', + `d` int GENERATED ALWAYS AS (((`c` * 2) + `b`)) VIRTUAL, + `e` varchar(100) DEFAULT 'Hello world', + `t` datetime DEFAULT CURRENT_TIMESTAMP, + PRIMARY KEY (`a`) +) ENGINE=InnoDB AUTO_INCREMENT=90 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=REDUNDANT +DROP TABLE t1; +# +# Scenario 5: +# Create a small table, add some columns instantly, then do DDL +# to build indexes +# +CREATE TABLE t1 (a INT NOT NULL AUTO_INCREMENT PRIMARY KEY, b INT) ROW_FORMAT=REDUNDANT; +INSERT INTO t1 VALUES(0, 1), (0, 2), (0, 3), (0, 4), (0, 5); +ALTER TABLE t1 ADD COLUMN c INT NOT NULL DEFAULT 100, ADD COLUMN d INT GENERATED ALWAYS AS ((c * 2 + b)) VIRTUAL, ADD COLUMN e VARCHAR(100) DEFAULT 'Hello world'; +Table id did not change +count(*) = 2 +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +ALTER TABLE t1 ADD KEY(c); +EXPLAIN SELECT c FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL # NULL # 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL c # NULL # 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c` AS `c` from `test`.`t1` +SELECT c FROM t1 WHERE c != 100; +c +INSERT INTO t1(b, c, e) SELECT b, c, e FROM t1; +INSERT INTO t1(b, c, e) SELECT b, c, e FROM t1; +INSERT INTO t1(b, c, e) SELECT b, c, e FROM t1; +UPDATE t1 SET e = 'Hello MySQL' WHERE a > 30; +ALTER TABLE t1 ADD KEY(e); +EXPLAIN SELECT e FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL # NULL # 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL e # NULL # 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`e` AS `e` from `test`.`t1` +SELECT count(e) FROM t1 WHERE e LIKE '%MySQL%'; +count(e) +17 +SELECT count(e) FROM t1 WHERE e LIKE '%world%'; +count(e) +23 +ALTER TABLE t1 DROP PRIMARY KEY, ADD PRIMARY KEY(a, c); +SELECT a, c, e FROM t1 WHERE a > 25 AND a < 40; +a c e +28 100 Hello world +29 100 Hello world +30 100 Hello world +31 100 Hello MySQL +32 100 Hello MySQL +33 100 Hello MySQL +34 100 Hello MySQL +35 100 Hello MySQL +36 100 Hello MySQL +37 100 Hello MySQL +38 100 Hello MySQL +39 100 Hello MySQL +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int NOT NULL AUTO_INCREMENT, + `b` int DEFAULT NULL, + `c` int NOT NULL DEFAULT '100', + `d` int GENERATED ALWAYS AS (((`c` * 2) + `b`)) VIRTUAL, + `e` varchar(100) DEFAULT 'Hello world', + PRIMARY KEY (`a`,`c`), + KEY `c` (`c`), + KEY `e` (`e`) +) ENGINE=InnoDB AUTO_INCREMENT=59 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=REDUNDANT +DROP TABLE t1; +# +# Scenario 6: +# Create a small table, add some columns instantly, then do DML +# on the table, and some simple rollback +# +CREATE TABLE t1 (a INT NOT NULL AUTO_INCREMENT PRIMARY KEY, b INT) ROW_FORMAT=REDUNDANT; +INSERT INTO t1 VALUES(0, 1), (0, 2), (0, 3), (0, 4), (0, 5); +ALTER TABLE t1 ADD COLUMN c INT NOT NULL DEFAULT 100, ADD COLUMN d INT GENERATED ALWAYS AS ((c * 2 + b)) VIRTUAL, ADD COLUMN e VARCHAR(100) DEFAULT 'Hello world'; +Table id did not change +count(*) = 2 +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +START TRANSACTION; +INSERT INTO t1(a, b) VALUES(0, 6); +SELECT * FROM t1; +a b c d e +1 1 100 201 Hello world +2 2 100 202 Hello world +3 3 100 203 Hello world +4 4 100 204 Hello world +5 5 100 205 Hello world +6 6 100 206 Hello world +ROLLBACK; +SELECT * FROM t1; +a b c d e +1 1 100 201 Hello world +2 2 100 202 Hello world +3 3 100 203 Hello world +4 4 100 204 Hello world +5 5 100 205 Hello world +START TRANSACTION; +UPDATE t1 SET c = 500 WHERE a = 1; +UPDATE t1 SET b = 1000 WHERE a = 2; +SELECT a, b, c FROM t1 WHERE a = 1 OR a = 2; +a b c +1 1 500 +2 1000 100 +ROLLBACK; +SELECT a, b, c FROM t1; +a b c +1 1 100 +2 2 100 +3 3 100 +4 4 100 +5 5 100 +START TRANSACTION; +DELETE FROM t1 WHERE a < 5; +INSERT INTO t1(a, b) VALUES(0, 6); +SELECT * FROM t1; +a b c d e +5 5 100 205 Hello world +7 6 100 206 Hello world +ROLLBACK; +SELECT * FROM t1; +a b c d e +1 1 100 201 Hello world +2 2 100 202 Hello world +3 3 100 203 Hello world +4 4 100 204 Hello world +5 5 100 205 Hello world +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int NOT NULL AUTO_INCREMENT, + `b` int DEFAULT NULL, + `c` int NOT NULL DEFAULT '100', + `d` int GENERATED ALWAYS AS (((`c` * 2) + `b`)) VIRTUAL, + `e` varchar(100) DEFAULT 'Hello world', + PRIMARY KEY (`a`) +) ENGINE=InnoDB AUTO_INCREMENT=8 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=REDUNDANT +DROP TABLE t1; +CREATE TABLE t1(id INT PRIMARY KEY, c1 VARCHAR(4000), c2 VARCHAR(4000), c3 VARCHAR(1000)) ROW_FORMAT=REDUNDANT; +INSERT INTO t1 VALUES(1, repeat('a', 4000), repeat('b', 4000), repeat('c', 1)); +SELECT id, length(c1), length(c2), length(c3) FROM t1; +id length(c1) length(c2) length(c3) +1 4000 4000 1 +ALTER TABLE t1 ADD COLUMN c4 VARCHAR(500) NOT NULL DEFAULT 'dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd'; +Table id did not change +count(*) = 1 +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT id, length(c1), length(c2), length(c3), length(c4) FROM t1; +id length(c1) length(c2) length(c3) length(c4) +1 4000 4000 1 500 +START TRANSACTION; +UPDATE t1 SET c1 = repeat('x', 200) WHERE id = 1; +ROLLBACK; +SELECT id, length(c1), length(c2), length(c3), length(c4) FROM t1; +id length(c1) length(c2) length(c3) length(c4) +1 4000 4000 1 500 +START TRANSACTION; +UPDATE t1 SET c4 = 'x' WHERE id = 1; +ROLLBACK; +SELECT id, length(c1), length(c2), length(c3), length(c4) FROM t1; +id length(c1) length(c2) length(c3) length(c4) +1 4000 4000 1 500 +DROP TABLE t1; +# +# Scenario 7: +# Confirm some ADD COLUMN are instant, some are not +# +CREATE TABLE t1 (a INT NOT NULL AUTO_INCREMENT PRIMARY KEY, b INT) ROW_FORMAT=REDUNDANT; +INSERT INTO t1 VALUES(0, 1), (0, 2), (0, 3), (0, 4), (0, 5); +ALTER TABLE t1 ADD COLUMN c INT NOT NULL DEFAULT 100 AFTER b; +Table id did not change +count(*) = 1 +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +ALTER TABLE t1 ADD COLUMN d INT NOT NULL DEFAULT 100 AFTER b; +Table ID differed +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +0 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT count(*) AS `Expect 0` FROM information_schema.innodb_columns WHERE has_default = 1; +Expect 0 +0 +ALTER TABLE t1 ADD COLUMN e INT NOT NULL DEFAULT 100, ADD KEY(e); +Table ID differed +count(*) = 1 +0 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT count(*) AS `Expect 0` FROM information_schema.innodb_columns WHERE has_default = 1; +Expect 0 +0 +ALTER TABLE t1 ADD COLUMN f INT NOT NULL DEFAULT 100, FORCE; +Table ID differed +count(*) = 1 +0 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT count(*) AS `Expect 0` FROM information_schema.innodb_columns WHERE has_default = 1; +Expect 0 +0 +ALTER TABLE t1 ADD COLUMN g INT NOT NULL DEFAULT 100, ALGORITHM=INPLACE; +Table ID differed +count(*) = 1 +0 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT count(*) AS `Expect 0` FROM information_schema.innodb_columns WHERE has_default = 1; +Expect 0 +0 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int NOT NULL AUTO_INCREMENT, + `b` int DEFAULT NULL, + `d` int NOT NULL DEFAULT '100', + `c` int NOT NULL DEFAULT '100', + `e` int NOT NULL DEFAULT '100', + `f` int NOT NULL DEFAULT '100', + `g` int NOT NULL DEFAULT '100', + PRIMARY KEY (`a`), + KEY `e` (`e`) +) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=REDUNDANT +DROP TABLE t1; +CREATE TABLE t1 (a INT NOT NULL AUTO_INCREMENT PRIMARY KEY, b INT, c TEXT, FULLTEXT(c)) ROW_FORMAT=REDUNDANT; +INSERT INTO t1 VALUES(0, 1, 'Hello'), (0, 2, 'HELLO'), (0, 3, 'World'), (0, 4, 'Hello world'), (0, 5, 'HELLO WORLD'); +ALTER TABLE t1 ADD COLUMN d INT NOT NULL DEFAULT 100 AFTER b; +Table ID differed +count(*) = 1 +0 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +DROP TABLE t1; +# +# Scenario 8: +# Check FK constraints on instantly added columns +# +CREATE TABLE t1 (a INT NOT NULL AUTO_INCREMENT PRIMARY KEY, b INT) ROW_FORMAT=REDUNDANT; +CREATE TABLE t2(a INT NOT NULL PRIMARY KEY, b INT, c INT, KEY(c)); +INSERT INTO t1 VALUES(0, 1), (0, 2), (0, 3), (0, 4), (0, 5); +INSERT INTO t2 VALUES(1, 2, 3), (2, 3, 4), (3, 4, 5); +ALTER TABLE t1 ADD COLUMN c INT NOT NULL DEFAULT 3; +Table id did not change +count(*) = 1 +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +UPDATE t1 SET c = 4 WHERE a = 2; +UPDATE t1 SET c = 5 WHERE a = 3; +ALTER TABLE t1 ADD KEY(c); +ALTER TABLE t2 ADD FOREIGN KEY (c) REFERENCES t1(c) ON UPDATE CASCADE, ALGORITHM = COPY; +UPDATE t1 SET c = 10 WHERE a = 1; +SELECT c FROM t2; +c +10 +4 +5 +UPDATE t1 SET c = 10; +SELECT c FROM t2; +c +10 +10 +10 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int NOT NULL AUTO_INCREMENT, + `b` int DEFAULT NULL, + `c` int NOT NULL DEFAULT '3', + PRIMARY KEY (`a`), + KEY `c` (`c`) +) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=REDUNDANT +DROP TABLE t2; +DROP TABLE t1; +# +# Scenario 9: +# Instant ADD COLUMN on partitioned table, only simple test here +# +CREATE TABLE t1 (a INT NOT NULL AUTO_INCREMENT PRIMARY KEY, b INT) ROW_FORMAT=REDUNDANT PARTITION BY HASH(a) PARTITIONS 3;; +INSERT INTO t1 VALUES(0, 1), (0, 2), (0, 3), (0, 4), (0, 5), (0, 6), (0, 7), (0, 8); +ALTER TABLE t1 ADD COLUMN c INT NOT NULL DEFAULT 5; +Table id did not change +count(*) = 1 +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT * FROM t1; +a b c +3 3 5 +6 6 5 +1 1 5 +4 4 5 +7 7 5 +2 2 5 +5 5 5 +8 8 5 +INSERT INTO t1 VALUES(0, 9, 10), (0, 10, 20); +SELECT * FROM t1 WHERE b > 8; +a b c +9 9 10 +10 10 20 +UPDATE t1 SET c = 8 WHERE a = 1 OR a = 3 OR a = 5 OR a = 7; +SELECT * FROM t1; +a b c +3 3 8 +6 6 5 +9 9 10 +1 1 8 +4 4 5 +7 7 8 +10 10 20 +2 2 5 +5 5 8 +8 8 5 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int NOT NULL AUTO_INCREMENT, + `b` int DEFAULT NULL, + `c` int NOT NULL DEFAULT '5', + PRIMARY KEY (`a`) +) ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=REDUNDANT +/*!50100 PARTITION BY HASH (`a`) +PARTITIONS 3 */ +DROP TABLE t1; +CREATE TABLE t1 (a INT, b INT) ROW_FORMAT=REDUNDANT PARTITION BY HASH(a) PARTITIONS 2;; +ALTER TABLE t1 ADD COLUMN c INT NOT NULL DEFAULT 5; +Table id did not change +count(*) = 1 +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +ALTER TABLE t1 CHANGE COLUMN c c1 INT; +ALTER TABLE t1 ADD COLUMN c INT NOT NULL DEFAULT 5; +Table id did not change +count(*) = 1 +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +DROP TABLE t1; +# +# Scenario 10: +# EXCHANGE PARTITION is not allowed if either is instant +# +CREATE TABLE t1 (a INT NOT NULL AUTO_INCREMENT PRIMARY KEY, b INT) ROW_FORMAT=REDUNDANT;; +INSERT INTO t1 VALUES(0, 1), (0, 2), (0, 3), (0, 4), (0, 5), (0, 6), (0, 7), (0, 8); +ALTER TABLE t1 ADD COLUMN c INT NOT NULL DEFAULT 5; +Table id did not change +count(*) = 1 +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +CREATE TABLE t2 (a INT NOT NULL AUTO_INCREMENT PRIMARY KEY, b INT, c INT NOT NULL DEFAULT 5) ROW_FORMAT=REDUNDANT PARTITION BY RANGE (a) (PARTITION p1 VALUES LESS THAN (10), PARTITION p2 VALUES LESS THAN (20), PARTITION p3 VALUES LESS THAN (30));; +ALTER TABLE t2 EXCHANGE PARTITION p1 WITH TABLE t1; +ERROR HY000: Non matching attribute 'INSTANT COLUMN(s)' between partition and table +ALTER TABLE t2 ADD COLUMN d INT; +ALTER TABLE t1 ADD COLUMN d INT, ALGORITHM=INPLACE; +ALTER TABLE t2 EXCHANGE PARTITION p1 WITH TABLE t1; +ERROR HY000: Non matching attribute 'INSTANT COLUMN(s)' between partition and table +OPTIMIZE TABLE t2; +Table Op Msg_type Msg_text +test.t2 optimize note Table does not support optimize, doing recreate + analyze instead +test.t2 optimize status OK +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int NOT NULL AUTO_INCREMENT, + `b` int DEFAULT NULL, + `c` int NOT NULL DEFAULT '5', + `d` int DEFAULT NULL, + PRIMARY KEY (`a`) +) ENGINE=InnoDB AUTO_INCREMENT=9 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=REDUNDANT +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `a` int NOT NULL AUTO_INCREMENT, + `b` int DEFAULT NULL, + `c` int NOT NULL DEFAULT '5', + `d` int DEFAULT NULL, + PRIMARY KEY (`a`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=REDUNDANT +/*!50100 PARTITION BY RANGE (`a`) +(PARTITION p1 VALUES LESS THAN (10) ENGINE = InnoDB, + PARTITION p2 VALUES LESS THAN (20) ENGINE = InnoDB, + PARTITION p3 VALUES LESS THAN (30) ENGINE = InnoDB) */ +ALTER TABLE t2 EXCHANGE PARTITION p1 WITH TABLE t1; +DROP TABLE t1, t2; +# +# Scenario 11: +# PRIMARY KEY with more than one column, at least to verify it works with REDUDANT +# +CREATE TABLE t1 (a INT NOT NULL, b INT NOT NULL, PRIMARY KEY(a, b)) ROW_FORMAT=REDUNDANT;; +INSERT INTO t1 VALUES(0, 1), (1, 2), (2, 3), (3, 4); +ALTER TABLE t1 ADD COLUMN c INT NOT NULL DEFAULT 5; +Table id did not change +count(*) = 1 +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT * FROM t1; +a b c +0 1 5 +1 2 5 +2 3 5 +3 4 5 +UPDATE t1 SET c = b WHERE b <= 2; +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT * FROM t1; +a b c +0 1 1 +1 2 2 +2 3 5 +3 4 5 +DROP TABLE t1; +# +# Scenario 12: +# Mix ALTER PARTITION and ALTER TABLE ... INPLACE. This is to check if first partition is not +# instant after ALTER PARTITION, will the metadata be copied correctly +# +CREATE TABLE t1 (col1 INT, col2 INT, col3 INT, col4 TEXT) ENGINE = InnoDB PARTITION BY RANGE(col1 * 2) ( PARTITION p0 VALUES LESS THAN (128), PARTITION p1 VALUES LESS THAN (256) , PARTITION p2 VALUES LESS THAN (384) , PARTITION p3 VALUES LESS THAN MAXVALUE);; +INSERT INTO t1 VALUES(1, 2, 3, 'abcdefg'), (100, 200, 300, 'qwerty'), (200, 300, 400, 'asdfg'); +ALTER TABLE t1 ALGORITHM DEFAULT, ADD COLUMN col5 VARCHAR(500), ADD COLUMN col6 TEXT; +Table id did not change +count(*) = 2 +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT count(*) AS `Expect 4` FROM information_schema.innodb_tables WHERE instant_cols != 0; +Expect 4 +4 +ALTER TABLE t1 ALGORITHM INPLACE, REORGANIZE PARTITION p0 INTO (PARTITION p0_a VALUES LESS THAN (64), PARTITION p0_b VALUES LESS THAN (128)); +SELECT count(*) AS `Expect 3` FROM information_schema.innodb_tables WHERE instant_cols != 0; +Expect 3 +3 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +ALTER TABLE t1 ALGORITHM DEFAULT, ADD KEY idx4(col4(10)); +SELECT count(*) AS `Expect 3` FROM information_schema.innodb_tables WHERE instant_cols != 0; +Expect 3 +3 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +ALTER TABLE t1 ALGORITHM DEFAULT, LOCK EXCLUSIVE, REORGANIZE PARTITION p0_a, p0_b INTO (PARTITION p0 VALUES LESS THAN (128) TABLESPACE innodb_file_per_table); +SELECT count(*) AS `Expect 3` FROM information_schema.innodb_tables WHERE instant_cols != 0; +Expect 3 +3 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +ALTER TABLE t1 ADD KEY idx3(col3); +SELECT count(*) AS `Expect 3` FROM information_schema.innodb_tables WHERE instant_cols != 0; +Expect 3 +3 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT * FROM t1; +col1 col2 col3 col4 col5 col6 +1 2 3 abcdefg NULL NULL +100 200 300 qwerty NULL NULL +200 300 400 asdfg NULL NULL +DROP TABLE t1; +CREATE TABLE t1 (a INT NOT NULL AUTO_INCREMENT PRIMARY KEY, b INT) ROW_FORMAT=REDUNDANT PARTITION BY HASH(a) PARTITIONS 3;; +INSERT INTO t1 VALUES(0, 1), (0, 2), (0, 3), (0, 4), (0, 5), (0, 6), (0, 7), (0, 8); +ALTER TABLE t1 ADD COLUMN c INT NOT NULL DEFAULT 5; +Table id did not change +count(*) = 1 +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT count(*) AS `Expect 3` FROM information_schema.innodb_tables WHERE instant_cols != 0; +Expect 3 +3 +ALTER TABLE t1 ADD PARTITION PARTITIONS 10; +SELECT count(*) AS `Expect 0` FROM information_schema.innodb_tables WHERE instant_cols != 0; +Expect 0 +0 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +ALTER TABLE t1 ADD KEY(b); +SELECT count(*) AS `Expect 0` FROM information_schema.innodb_tables WHERE instant_cols != 0; +Expect 0 +0 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT * FROM t1; +a b c +1 1 5 +2 2 5 +3 3 5 +4 4 5 +5 5 5 +6 6 5 +7 7 5 +8 8 5 +DROP TABLE t1; +# +# Scenario 13: +# Create a table with a two level clustered index, do instant ADD COLUMN, then the non-leaf node +# should be parsed correctly +# +CREATE TABLE t1 (a INT NOT NULL AUTO_INCREMENT, d INT NOT NULL, b BLOB NOT NULL, c VARCHAR(87), INDEX(d), INDEX(a ASC), PRIMARY KEY (a, d DESC, c DESC)) ROW_FORMAT=REDUNDANT PARTITION BY LINEAR KEY(c) PARTITIONS 9;; +INSERT INTO t1(d, b, c) VALUES(1, 2, 'aaaaaaaaaabbbbbbbbbbccccccccccddddddddddeeeeeeeeeeffffffffffgggggggggghhhhhhhhhhjjjjjjj'); +INSERT INTO t1(d, b, c) VALUES(2, 3, 'aaaaaaaaaahhhhhhhhhhbbbbbbbbbbccccccccccddddddddddeeeeeeeeeeffffffffffggggggggggjjjjjjj'); +INSERT INTO t1(d, b, c) VALUES(3, 4, 'bbbbbbbbbbaaaaaaaaaahhhhhhhhhhccccccccccddddddddddeeeeeeeeeeffffffffffggggggggggjjjjjjj'); +INSERT INTO t1(d, b, c) VALUES(4, 5, 'eeeeeeeeeehhhhhhhhhhbbbbbbbbbbccccccccccddddddddddaaaaaaaaaaffffffffffggggggggggjjjjjjj'); +INSERT INTO t1(d, b, c) VALUES(5, 6, 'aaaaaaaaaahhhhhhhhhhbbbbbbbbbbddddddddddcccccccccceeeeeeeeeeffffffffffggggggggggjjjjjjj'); +INSERT INTO t1(d, b, c) VALUES(6, 7, 'cccccccccchhhhhhhhhhbbbbbbbbbbaaaaaaaaaaddddddddddeeeeeeeeeeffffffffffggggggggggjjjjjjj'); +INSERT INTO t1(d, b, c) SELECT d, b, c FROM t1; +INSERT INTO t1(d, b, c) SELECT d, b, c FROM t1; +INSERT INTO t1(d, b, c) SELECT d, b, c FROM t1; +INSERT INTO t1(d, b, c) SELECT d, b, c FROM t1; +INSERT INTO t1(d, b, c) SELECT d, b, c FROM t1; +INSERT INTO t1(d, b, c) SELECT d, b, c FROM t1; +ALTER TABLE t1 ADD COLUMN nc086 BIGINT NOT NULL FIRST, ALGORITHM=INPLACE, LOCK=DEFAULT; +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +ALTER TABLE t1 ADD COLUMN nc082 TINYTEXT; +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT COUNT(*) FROM t1; +COUNT(*) +384 +DROP TABLE t1; +# +# Scenario 14: +# Create a small table, and add GIS kinds of new columns and verify +# +CREATE TABLE t1 (a INT NOT NULL AUTO_INCREMENT PRIMARY KEY, b INT) ROW_FORMAT=REDUNDANT; +INSERT INTO t1 VALUES(0, 1), (0, 2), (0, 3), (0, 4), (0, 5); +ALTER TABLE t1 ADD COLUMN c1 POINT, ALGORITHM = INSTANT; +Table id did not change +count(*) = 1 +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'c1' AND has_default = 1; +name default_value +c1 NULL +INSERT INTO t1(a, c1) VALUES(0, ST_PointFromText('POINT(10 10)')); +SELECT count(*) = max(a) FROM t1 WHERE c1 IS NULL; +count(*) = max(a) +1 +ALTER TABLE t1 ADD COLUMN d1 LINESTRING, ALGORITHM = INSTANT; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'd1' AND has_default = 1; +name default_value +d1 NULL +INSERT INTO t1(a, d1) VALUES(0, ST_LineFromText('LINESTRING(0 0,0 10,10 0)')); +SELECT count(*) = max(a) FROM t1 WHERE d1 IS NULL; +count(*) = max(a) +1 +ALTER TABLE t1 ADD COLUMN e1 POLYGON, ALGORITHM = INSTANT; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'e1' AND has_default = 1; +name default_value +e1 NULL +INSERT INTO t1(a, e1) VALUES(0, ST_PolygonFromText('POLYGON((10 10,20 10,20 20,10 20,10 10))')); +SELECT count(*) = max(a) FROM t1 WHERE e1 IS NULL; +count(*) = max(a) +1 +ALTER TABLE t1 ADD COLUMN f1 MULTIPOINT, ALGORITHM = INSTANT; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'f1' AND has_default = 1; +name default_value +f1 NULL +INSERT INTO t1(a, f1) VALUES(0, ST_MultiPointFromText('MULTIPOINT(0 0,10 10,10 20,20 20)')); +SELECT count(*) = max(a) FROM t1 WHERE f1 IS NULL; +count(*) = max(a) +1 +ALTER TABLE t1 ADD COLUMN g1 MULTILINESTRING, ALGORITHM = INSTANT; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'g1' AND has_default = 1; +name default_value +g1 NULL +INSERT INTO t1(a, g1) VALUES(0, ST_MultiLineStringFromText('MULTILINESTRING((10 48,10 21,10 0),(16 0,16 23,16 48))')); +SELECT count(*) = max(a) FROM t1 WHERE g1 IS NULL; +count(*) = max(a) +1 +ALTER TABLE t1 ADD COLUMN h1 MULTIPOLYGON, ALGORITHM = INSTANT; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'h1' AND has_default = 1; +name default_value +h1 NULL +INSERT INTO t1(a, h1) VALUES(0, ST_MultiPolygonFromText('MULTIPOLYGON(((28 26,28 0,84 0,84 42,28 26),(52 18,66 23,73 9,48 6,52 18)),((59 18,67 18,67 13,59 13,59 18)))')); +SELECT count(*) = max(a) FROM t1 WHERE h1 IS NULL; +count(*) = max(a) +1 +ALTER TABLE t1 ADD COLUMN i1 GEOMETRYCOLLECTION, ALGORITHM = INSTANT; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'i1' AND has_default = 1; +name default_value +i1 NULL +INSERT INTO t1(a, i1) VALUES(0, ST_GeomCollFromText('GEOMETRYCOLLECTION(POINT(0 0), LINESTRING(0 0,10 10))')); +SELECT count(*) = max(a) FROM t1 WHERE i1 IS NULL; +count(*) = max(a) +1 +ALTER TABLE t1 ADD COLUMN j1 GEOMETRY, ALGORITHM = INSTANT; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'j1' AND has_default = 1; +name default_value +j1 NULL +INSERT INTO t1(a, j1) VALUES(0, ST_GeomCollFromText('GEOMETRYCOLLECTION(POINT(0 0), LINESTRING(0 0,10 10))')); +SELECT count(*) = max(a) FROM t1 WHERE j1 IS NULL; +count(*) = max(a) +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int NOT NULL AUTO_INCREMENT, + `b` int DEFAULT NULL, + `c1` point DEFAULT NULL, + `d1` linestring DEFAULT NULL, + `e1` polygon DEFAULT NULL, + `f1` multipoint DEFAULT NULL, + `g1` multilinestring DEFAULT NULL, + `h1` multipolygon DEFAULT NULL, + `i1` geomcollection DEFAULT NULL, + `j1` geometry DEFAULT NULL, + PRIMARY KEY (`a`) +) ENGINE=InnoDB AUTO_INCREMENT=14 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=REDUNDANT +DROP TABLE t1; +# +# Scenario 15: +# Create a small table, and add JSON columns and verify +# +CREATE TABLE t1 (a INT NOT NULL AUTO_INCREMENT PRIMARY KEY, b INT) ROW_FORMAT=REDUNDANT; +INSERT INTO t1 VALUES(0, 1), (0, 2), (0, 3), (0, 4), (0, 5); +ALTER TABLE t1 ADD COLUMN c1 JSON, ALGORITHM = INSTANT; +Table id did not change +count(*) = 1 +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'c1' AND has_default = 1; +name default_value +c1 NULL +INSERT INTO t1(a, c1) VALUES(0, '{"key1": "value1", "key2": "value2"}'); +SELECT count(*) = max(a) FROM t1 WHERE c1 IS NULL; +count(*) = max(a) +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int NOT NULL AUTO_INCREMENT, + `b` int DEFAULT NULL, + `c1` json DEFAULT NULL, + PRIMARY KEY (`a`) +) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=REDUNDANT +DROP TABLE t1; +# +# Scenario 16: +# Create a small table, and add INSTANT columns and verify with trigger +# +CREATE TABLE t1 (a INT NOT NULL AUTO_INCREMENT PRIMARY KEY, b INT) ROW_FORMAT=REDUNDANT; +CREATE TABLE t2 (a INT NOT NULL AUTO_INCREMENT PRIMARY KEY, b INT) ROW_FORMAT=REDUNDANT; +INSERT INTO t1 VALUES(0, 1), (0, 2), (0, 3), (0, 4), (0, 5); +INSERT INTO t2 VALUES(0, 1), (0, 2), (0, 3), (0, 4), (0, 5); +ALTER TABLE t1 ADD COLUMN c1 VARCHAR(10) NOT NULL DEFAULT 'aaaa', ALGORITHM = INSTANT; +Table id did not change +count(*) = 1 +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'c1' AND has_default = 1; +name default_value +c1 61616161 +CREATE TRIGGER t1_ai AFTER INSERT ON t1 FOR EACH ROW +INSERT INTO t2 VALUES(0,6); +INSERT INTO t1(a, c1) VALUES(0, 'bbbb'); +SELECT count(*) = max(a) FROM t1 WHERE c1='aaaa'; +count(*) = max(a) +1 +SELECT c1 FROM t1 WHERE c1 = 'bbbb'; +c1 +bbbb +DROP TRIGGER t1_ai; +ALTER TABLE t2 ADD COLUMN c1 VARCHAR(10) NOT NULL DEFAULT 'cccc', ALGORITHM = INSTANT; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'c1' AND has_default = 1; +name default_value +c1 61616161 +c1 63636363 +CREATE TRIGGER t2_ai AFTER INSERT ON t2 FOR EACH ROW +INSERT INTO t1(a,c1) VALUES(0,'eeee'); +INSERT INTO t2(a, c1) VALUES(0, 'dddd'); +SELECT count(*) = max(a) FROM t2 WHERE c1='cccc'; +count(*) = max(a) +1 +SELECT c1 FROM t2 WHERE c1 = 'dddd'; +c1 +dddd +DROP TRIGGER t2_ai; +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +CHECK TABLE t2; +Table Op Msg_type Msg_text +test.t2 check status OK +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int NOT NULL AUTO_INCREMENT, + `b` int DEFAULT NULL, + `c1` varchar(10) NOT NULL DEFAULT 'aaaa', + PRIMARY KEY (`a`) +) ENGINE=InnoDB AUTO_INCREMENT=8 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=REDUNDANT +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `a` int NOT NULL AUTO_INCREMENT, + `b` int DEFAULT NULL, + `c1` varchar(10) NOT NULL DEFAULT 'cccc', + PRIMARY KEY (`a`) +) ENGINE=InnoDB AUTO_INCREMENT=8 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=REDUNDANT +DROP TABLE t1,t2; +# +# Scenario 17: +# Create a small table, and add INSTANT columns and verify with storedprocedure +# +CREATE TABLE t1 (a INT NOT NULL AUTO_INCREMENT PRIMARY KEY, b INT) ROW_FORMAT=REDUNDANT; +INSERT INTO t1 VALUES(0, 1), (0, 2), (0, 3), (0, 4), (0, 5); +ALTER TABLE t1 ADD COLUMN c1 VARCHAR(10) NOT NULL DEFAULT 'aaaa', ALGORITHM = INSTANT; +Table id did not change +count(*) = 1 +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'c1' AND has_default = 1; +name default_value +c1 61616161 +CREATE PROCEDURE p1() INSERT INTO t1(a,c1) VALUES(0, 'bbbb'); +CALL p1(); +SELECT count(*) = max(a) FROM t1 WHERE c1='aaaa'; +count(*) = max(a) +1 +SELECT c1 FROM t1 WHERE c1 = 'bbbb'; +c1 +bbbb +DROP PROCEDURE p1; +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int NOT NULL AUTO_INCREMENT, + `b` int DEFAULT NULL, + `c1` varchar(10) NOT NULL DEFAULT 'aaaa', + PRIMARY KEY (`a`) +) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=REDUNDANT +DROP TABLE t1; +# +# Scenario 18: +# Create a small table, and add INSTANT columns and verify with view +# +CREATE TABLE t1 (a INT NOT NULL AUTO_INCREMENT PRIMARY KEY, b INT) ROW_FORMAT=REDUNDANT; +INSERT INTO t1 VALUES(0, 1), (0, 2), (0, 3), (0, 4), (0, 5); +ALTER TABLE t1 ADD COLUMN c1 VARCHAR(10) NOT NULL DEFAULT 'aaaa', ALGORITHM = INSTANT; +Table id did not change +count(*) = 1 +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'c1' AND has_default = 1; +name default_value +c1 61616161 +CREATE VIEW v1 AS SELECT * FROM t1; +INSERT INTO t1(a, c1) VALUES(0, 'bbbb'); +SELECT count(*) = max(a) FROM t1 WHERE c1='aaaa'; +count(*) = max(a) +1 +SELECT c1 FROM t1 WHERE c1 = 'bbbb'; +c1 +bbbb +SELECT * FROM v1; +a b c1 +1 1 aaaa +2 2 aaaa +3 3 aaaa +4 4 aaaa +5 5 aaaa +6 NULL bbbb +DROP VIEW v1; +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int NOT NULL AUTO_INCREMENT, + `b` int DEFAULT NULL, + `c1` varchar(10) NOT NULL DEFAULT 'aaaa', + PRIMARY KEY (`a`) +) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=REDUNDANT +DROP TABLE t1; +# +# Scenario 19: +# Create a small table, and add INSTANT columns and drop it and verify +# +CREATE TABLE t1 (a INT NOT NULL AUTO_INCREMENT PRIMARY KEY, b INT) ROW_FORMAT=REDUNDANT; +INSERT INTO t1 VALUES(0, 1), (0, 2), (0, 3), (0, 4), (0, 5); +ALTER TABLE t1 ADD COLUMN c1 VARCHAR(10) NOT NULL DEFAULT 'aaaa', ALGORITHM = INSTANT; +Table id did not change +count(*) = 1 +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'c1' AND has_default = 1; +name default_value +c1 61616161 +INSERT INTO t1(a, c1) VALUES(0, 'bbbb'); +SELECT count(*) = max(a) FROM t1 WHERE c1='aaaa'; +count(*) = max(a) +1 +SELECT c1 FROM t1 WHERE c1 = 'bbbb'; +c1 +bbbb +ALTER TABLE t1 DROP COLUMN c1; +Table ID differed +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +0 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int NOT NULL AUTO_INCREMENT, + `b` int DEFAULT NULL, + PRIMARY KEY (`a`) +) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=REDUNDANT +DROP TABLE t1; +# +# Scenario 20: +# Create a small table, and add INSTANT columns and rename table +# +CREATE TABLE t1 (a INT NOT NULL AUTO_INCREMENT PRIMARY KEY, b INT) ROW_FORMAT=REDUNDANT; +INSERT INTO t1 VALUES(0, 1), (0, 2), (0, 3), (0, 4), (0, 5); +ALTER TABLE t1 ADD COLUMN c1 VARCHAR(10) NOT NULL DEFAULT 'aaaa', ALGORITHM = INSTANT; +Table id did not change +count(*) = 1 +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +ALTER TABLE t1 RENAME t2; +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'c1' AND has_default = 1; +name default_value +c1 61616161 +INSERT INTO t2(a, c1) VALUES(0, 'bbbb'); +SELECT count(*) = max(a) FROM t2 WHERE c1='aaaa'; +count(*) = max(a) +1 +SELECT c1 FROM t2 WHERE c1 = 'bbbb'; +c1 +bbbb +CHECK TABLE t2; +Table Op Msg_type Msg_text +test.t2 check status OK +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `a` int NOT NULL AUTO_INCREMENT, + `b` int DEFAULT NULL, + `c1` varchar(10) NOT NULL DEFAULT 'aaaa', + PRIMARY KEY (`a`) +) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=REDUNDANT +DROP TABLE t2; +# +# Scenario 21: +# Create a small table, and add INSTANT columns and change its data type INSTANTly won't work +# +CREATE TABLE t1 (a INT NOT NULL AUTO_INCREMENT PRIMARY KEY, b INT) ROW_FORMAT=REDUNDANT; +INSERT INTO t1 VALUES(0, 1), (0, 2), (0, 3), (0, 4), (0, 5); +ALTER TABLE t1 ADD COLUMN c1 VARCHAR(10) NOT NULL DEFAULT 'aaaa', ALGORITHM = INSTANT; +Table id did not change +count(*) = 1 +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'c1' AND has_default = 1; +name default_value +c1 61616161 +INSERT INTO t1(a, c1) VALUES(0, 'bbbb'); +SELECT count(*) = max(a) FROM t1 WHERE c1='aaaa'; +count(*) = max(a) +1 +SELECT c1 FROM t1 WHERE c1 = 'bbbb'; +c1 +bbbb +ALTER TABLE t1 CHANGE c1 c2 CHAR(10) NOT NULL DEFAULT 'cccc'; +Table ID differed +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +0 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int NOT NULL AUTO_INCREMENT, + `b` int DEFAULT NULL, + `c2` char(10) NOT NULL DEFAULT 'cccc', + PRIMARY KEY (`a`) +) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=REDUNDANT +DROP TABLE t1; +# +# Scenario 22: +# Create a small table, and add INSTANT columns and create hash,btree multi column index and verify +# +CREATE TABLE t1 (a INT NOT NULL AUTO_INCREMENT PRIMARY KEY, b INT) ROW_FORMAT=REDUNDANT; +INSERT INTO t1 VALUES(0, 1), (0, 2), (0, 3), (0, 4), (0, 5); +ALTER TABLE t1 ADD COLUMN c1 VARCHAR(10) NOT NULL DEFAULT 'aaaa', ALGORITHM = INSTANT; +Table id did not change +count(*) = 1 +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'c1' AND has_default = 1; +name default_value +c1 61616161 +CREATE INDEX id1 ON t1(c1) USING BTREE; +CREATE INDEX id2 ON t1(c1) USING HASH; +Warnings: +Note 3502 This storage engine does not support the HASH index algorithm, storage engine default was used instead. +Warning 1831 Duplicate index 'id2' defined on the table 'test.t1'. This is deprecated and will be disallowed in a future release. +INSERT INTO t1(a, c1) VALUES(0, 'bbbb'); +SELECT count(*) = max(a) FROM t1 WHERE c1='aaaa'; +count(*) = max(a) +1 +SELECT c1 FROM t1 WHERE c1 = 'bbbb'; +c1 +bbbb +DROP INDEX id1 ON t1; +DROP INDEX id2 ON t1; +ALTER TABLE t1 ADD COLUMN c2 VARCHAR(10) NOT NULL DEFAULT 'cccc', ALGORITHM = INSTANT; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'c2' AND has_default = 1; +name default_value +c2 63636363 +CREATE INDEX id1 ON t1(c1 ASC,c2 DESC) USING BTREE; +INSERT INTO t1(a, c2) VALUES(0, 'dddd'); +SELECT count(*) = max(a) FROM t1 WHERE c1='cccc'; +count(*) = max(a) +NULL +SELECT c1 FROM t1 WHERE c1 = 'dddd'; +c1 +ALTER TABLE t1 RENAME INDEX id1 TO id2; +DROP INDEX id2 ON t1; +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int NOT NULL AUTO_INCREMENT, + `b` int DEFAULT NULL, + `c1` varchar(10) NOT NULL DEFAULT 'aaaa', + `c2` varchar(10) NOT NULL DEFAULT 'cccc', + PRIMARY KEY (`a`) +) ENGINE=InnoDB AUTO_INCREMENT=8 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=REDUNDANT +DROP TABLE t1; +# +# Scenario 23: +# Create a small table, and add INSTANT columns and perform table join operation +# +CREATE TABLE t1 (a INT NOT NULL AUTO_INCREMENT PRIMARY KEY, b INT) ROW_FORMAT=REDUNDANT; +CREATE TABLE t2 (a INT NOT NULL AUTO_INCREMENT PRIMARY KEY, b INT) ROW_FORMAT=REDUNDANT; +INSERT INTO t1 VALUES(0, 1), (0, 2), (0, 3), (0, 4), (0, 5); +INSERT INTO t2 VALUES(0, 1), (0, 2), (0, 3), (0, 4), (0, 5); +ALTER TABLE t1 ADD COLUMN c1 VARCHAR(10) NOT NULL DEFAULT 'aaaa', ALGORITHM = INSTANT; +Table id did not change +count(*) = 1 +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'c1' AND has_default = 1; +name default_value +c1 61616161 +INSERT INTO t1(a, c1) VALUES(0, 'cccc'); +SELECT count(*) = max(a) FROM t1 WHERE c1='aaaa'; +count(*) = max(a) +1 +SELECT c1 FROM t1 WHERE c1 = 'cccc'; +c1 +cccc +ALTER TABLE t2 ADD COLUMN c1 VARCHAR(10) NOT NULL DEFAULT 'bbbb', ALGORITHM = INSTANT; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'c1' AND has_default = 1; +name default_value +c1 61616161 +c1 62626262 +INSERT INTO t2(a, c1) VALUES(0, 'cccc'); +SELECT count(*) = max(a) FROM t2 WHERE c1='bbbb'; +count(*) = max(a) +1 +SELECT c1 FROM t2 WHERE c1 = 'cccc'; +c1 +cccc +SELECT * FROM t1 JOIN t2 ON t1.c1=t2.c1; +a b c1 a b c1 +6 NULL cccc 6 NULL cccc +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +CHECK TABLE t2; +Table Op Msg_type Msg_text +test.t2 check status OK +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int NOT NULL AUTO_INCREMENT, + `b` int DEFAULT NULL, + `c1` varchar(10) NOT NULL DEFAULT 'aaaa', + PRIMARY KEY (`a`) +) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=REDUNDANT +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `a` int NOT NULL AUTO_INCREMENT, + `b` int DEFAULT NULL, + `c1` varchar(10) NOT NULL DEFAULT 'bbbb', + PRIMARY KEY (`a`) +) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=REDUNDANT +DROP TABLE t1; +DROP TABLE t2; +# +# Scenario 24: +# Create a small table, and add stored and(or) virtual columns +# after last stored column in the table +# +CREATE TABLE t1 (a INT NOT NULL AUTO_INCREMENT PRIMARY KEY, b INT, c INT, d INT GENERATED ALWAYS AS (b + c) VIRTUAL, e INT GENERATED ALWAYS AS (b * c) VIRTUAL) ROW_FORMAT=REDUNDANT; +INSERT INTO t1(a, b, c) VALUES(0, 1, 2), (0, 2, 3), (0, 3, 4), (0, 4, 5), (0, 5, 6); +ALTER TABLE t1 ADD COLUMN h INT NOT NULL AFTER c; +Table id did not change +count(*) = 1 +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +INSERT INTO t1(a, b, c, h) VALUES(0, 6, 20, 40); +SELECT * FROM t1; +a b c h d e +1 1 2 0 3 2 +2 2 3 0 5 6 +3 3 4 0 7 12 +4 4 5 0 9 20 +5 5 6 0 11 30 +6 6 20 40 26 120 +ALTER TABLE t1 ADD COLUMN i VARCHAR(100) DEFAULT 'ABCD EFGH' AFTER h, ADD COLUMN f INT GENERATED ALWAYS AS (LENGTH(i)) AFTER i; +Table id did not change +SELECT 3 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +INSERT INTO t1(a, b, c, h, i) VALUES(0, 20, 30, 50, 'qwerty'); +SELECT * FROM t1; +a b c h i f d e +1 1 2 0 ABCD EFGH 9 3 2 +2 2 3 0 ABCD EFGH 9 5 6 +3 3 4 0 ABCD EFGH 9 7 12 +4 4 5 0 ABCD EFGH 9 9 20 +5 5 6 0 ABCD EFGH 9 11 30 +6 6 20 40 ABCD EFGH 9 26 120 +7 20 30 50 qwerty 6 50 600 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int NOT NULL AUTO_INCREMENT, + `b` int DEFAULT NULL, + `c` int DEFAULT NULL, + `h` int NOT NULL, + `i` varchar(100) DEFAULT 'ABCD EFGH', + `f` int GENERATED ALWAYS AS (length(`i`)) VIRTUAL, + `d` int GENERATED ALWAYS AS ((`b` + `c`)) VIRTUAL, + `e` int GENERATED ALWAYS AS ((`b` * `c`)) VIRTUAL, + PRIMARY KEY (`a`) +) ENGINE=InnoDB AUTO_INCREMENT=8 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=REDUNDANT +DROP TABLE t1; +############################################ +# Test instant ADD COLUMN for DYNAMIC format +############################################ +# +# Scenario 1: +# Create a small table, and add all kinds of new columns and verify +# +CREATE TABLE t1 (a INT NOT NULL AUTO_INCREMENT PRIMARY KEY, b INT) ROW_FORMAT=DYNAMIC; +INSERT INTO t1 VALUES(0, 1), (0, 2), (0, 3), (0, 4), (0, 5); +ALTER TABLE t1 ADD COLUMN c1 INT, ALGORITHM=INSTANT; +Table id did not change +count(*) = 1 +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'c1' AND has_default = 1; +name default_value +c1 NULL +INSERT INTO t1(a, c1) VALUES(0, 1); +SELECT count(*) = max(a) FROM t1 WHERE c1 IS NULL; +count(*) = max(a) +1 +SELECT c1 FROM t1 WHERE c1 = 1; +c1 +1 +ALTER TABLE t1 ADD COLUMN c2 INT NOT NULL DEFAULT 10; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'c2' AND has_default = 1; +name default_value +c2 8000000a +INSERT INTO t1(a, c2) VALUES(0, 11); +SELECT count(*) = max(a) FROM t1 WHERE c2 = 10; +count(*) = max(a) +1 +SELECT c2 FROM t1 WHERE c2 = 11; +c2 +11 +ALTER TABLE t1 ADD COLUMN d1 BIGINT, ALGORITHM=INSTANT; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'd1' AND has_default = 1; +name default_value +d1 NULL +INSERT INTO t1(a, d1) VALUES(0, 1); +SELECT count(*) = max(a) FROM t1 WHERE d1 IS NULL; +count(*) = max(a) +1 +SELECT d1 FROM t1 WHERE d1 = 1; +d1 +1 +ALTER TABLE t1 ADD COLUMN d2 BIGINT NOT NULL DEFAULT 1234567890; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'd2' AND has_default = 1; +name default_value +d2 80000000499602d2 +INSERT INTO t1(a, d2) VALUES(0, 1234); +SELECT count(*) = max(a) FROM t1 WHERE d2 = 1234567890; +count(*) = max(a) +1 +SELECT d2 FROM t1 WHERE d2 = 1234; +d2 +1234 +ALTER TABLE t1 ADD COLUMN e1 SMALLINT, ALGORITHM=INSTANT; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'e1' AND has_default = 1; +name default_value +e1 NULL +INSERT INTO t1(a, e1) VALUES(0, 1); +SELECT count(*) = max(a) FROM t1 WHERE e1 IS NULL; +count(*) = max(a) +1 +SELECT e1 FROM t1 WHERE e1 = 1; +e1 +1 +ALTER TABLE t1 ADD COLUMN e2 SMALLINT NOT NULL DEFAULT 10; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'e2' AND has_default = 1; +name default_value +e2 800a +INSERT INTO t1(a, e2) VALUES(0, 11); +SELECT count(*) = max(a) FROM t1 WHERE e2 = 10; +count(*) = max(a) +1 +SELECT e2 FROM t1 WHERE e2 = 11; +e2 +11 +ALTER TABLE t1 ADD COLUMN f1 TINYINT, ALGORITHM=INSTANT; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'f1' AND has_default = 1; +name default_value +f1 NULL +INSERT INTO t1(a, f1) VALUES(0, 1); +SELECT count(*) = max(a) FROM t1 WHERE f1 IS NULL; +count(*) = max(a) +1 +SELECT f1 FROM t1 WHERE f1 = 1; +f1 +1 +ALTER TABLE t1 ADD COLUMN f2 TINYINT NOT NULL DEFAULT 123; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'f2' AND has_default = 1; +name default_value +f2 fb +INSERT INTO t1(a, f2) VALUES(0, 12); +SELECT count(*) = max(a) FROM t1 WHERE f2 = 123; +count(*) = max(a) +1 +SELECT f2 FROM t1 WHERE f2 = 12; +f2 +12 +ALTER TABLE t1 ADD COLUMN g1 MEDIUMINT, ALGORITHM=INSTANT; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'g1' AND has_default = 1; +name default_value +g1 NULL +INSERT INTO t1(a, g1) VALUES(0, 1); +SELECT count(*) = max(a) FROM t1 WHERE g1 IS NULL; +count(*) = max(a) +1 +SELECT g1 FROM t1 WHERE g1 = 1; +g1 +1 +ALTER TABLE t1 ADD COLUMN g2 MEDIUMINT NOT NULL DEFAULT 12345; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'g2' AND has_default = 1; +name default_value +g2 803039 +INSERT INTO t1(a, g2) VALUES(0, 1234); +SELECT count(*) = max(a) FROM t1 WHERE g2 = 12345; +count(*) = max(a) +1 +SELECT g2 FROM t1 WHERE g2 = 1234; +g2 +1234 +ALTER TABLE t1 ADD COLUMN h1 FLOAT, ALGORITHM=INSTANT; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'h1' AND has_default = 1; +name default_value +h1 NULL +INSERT INTO t1(a, h1) VALUES(0, 1.0); +SELECT count(*) = max(a) FROM t1 WHERE h1 IS NULL; +count(*) = max(a) +1 +SELECT h1 FROM t1 WHERE h1 = 1; +h1 +1 +ALTER TABLE t1 ADD COLUMN h2 FLOAT NOT NULL DEFAULT 12.34; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'h2' AND has_default = 1; +name default_value +h2 a4704541 +INSERT INTO t1(a, h2) VALUES(0, 1.234); +SELECT count(*) = max(a) FROM t1 WHERE h2 = 12.34; +count(*) = max(a) +NULL +SELECT h2 FROM t1 WHERE h2 = 1.234; +h2 +ALTER TABLE t1 ADD COLUMN i1 DECIMAL(5, 2), ADD COLUMN i2 double, ALGORITHM=INSTANT; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE (name = 'i1' OR name = 'i2') AND has_default = 1; +name default_value +i1 NULL +i2 NULL +INSERT INTO t1(a, i1, i2) VALUES(0, 10.10, 20.20); +SELECT count(*) = max(a) FROM t1 WHERE i1 IS NULL; +count(*) = max(a) +1 +SELECT count(*) = max(a) FROM t1 WHERE i2 IS NULL; +count(*) = max(a) +1 +SELECT i1 FROM t1 WHERE i1 = 10.10; +i1 +10.10 +SELECT i2 FROM t1 WHERE i2 = 20.20; +i2 +20.2 +ALTER TABLE t1 ADD COLUMN j1 DECIMAL(5, 2) NOT NULL DEFAULT 100.00, ADD COLUMN j2 double NOT NULL DEFAULT 1000.5678; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE (name = 'j1' OR name = 'j2') AND has_default = 1; +name default_value +j1 806400 +j2 5af5b9da8a448f40 +INSERT INTO t1(a, j1, j2) VALUES(0, 90.90, 1000.1234); +SELECT count(*) = max(a) FROM t1 WHERE j1 = 100.00; +count(*) = max(a) +1 +SELECT count(*) = max(a) FROM t1 WHERE j2 = 1000.5678; +count(*) = max(a) +1 +SELECT j1 FROM t1 WHERE j1 = 90.90; +j1 +90.90 +SELECT j2 FROM t1 WHERE j2 = 1000.1234; +j2 +1000.1234 +ALTER TABLE t1 ADD COLUMN k1 BIT(8), ALGORITHM=INSTANT; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'k1' AND has_default = 1; +name default_value +k1 NULL +INSERT INTO t1(a, k1) VALUES(0, b'010101'); +SELECT count(*) = max(a) FROM t1 WHERE k1 IS NULL; +count(*) = max(a) +1 +SELECT hex(k1) FROM t1 WHERE k1 = b'010101'; +hex(k1) +15 +ALTER TABLE t1 ADD COLUMN k2 BIT(8) NOT NULL DEFAULT b'101010'; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'k2' AND has_default = 1; +name default_value +k2 2a +INSERT INTO t1(a, k2) VALUES(0, b'110011'); +SELECT count(*) = max(a) FROM t1 WHERE k2 = b'101010'; +count(*) = max(a) +1 +SELECT hex(k2) FROM t1 WHERE k2 = b'110011'; +hex(k2) +33 +ALTER TABLE t1 ADD COLUMN l1 CHAR(50), ADD COLUMN l2 VARCHAR(100), ALGORITHM=DEFAULT; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE (name = 'l1' OR name = 'l2') AND has_default = 1; +name default_value +l1 NULL +l2 NULL +INSERT INTO t1(a, l1, l2) VALUES(0, 'ABCD EFGH', 'abcdefg hijklmn '); +SELECT count(*) = max(a) FROM t1 WHERE l2 IS NULL; +count(*) = max(a) +1 +SELECT count(*) = max(a) FROM t1 WHERE l1 IS NULL; +count(*) = max(a) +1 +SELECT l1 FROM t1 WHERE l1 = 'ABCD EFGH'; +l1 +ABCD EFGH +SELECT l2 FROM t1 WHERE l2 = 'abcdefg hijklmn '; +l2 +abcdefg hijklmn +ALTER TABLE t1 ADD COLUMN m1 CHAR(50) default 'The fox jumps over', ADD COLUMN m2 VARCHAR(50) DEFAULT 'The fox jumps over the lazy dog.'; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE (name = 'm1' OR name = 'm2') AND has_default = 1; +name default_value +m1 54686520666f78206a756d7073206f7665722020202020202020202020202020202020202020202020202020202020202020 +m2 54686520666f78206a756d7073206f76657220746865206c617a7920646f672e +INSERT INTO t1(a, m1, m2) VALUES(0, 'over the lazy dog', 'The lazy dog jumps over the fox.'); +SELECT count(*) = max(a) FROM t1 WHERE m1 = 'The fox jumps over'; +count(*) = max(a) +1 +SELECT count(*) = max(a) FROM t1 WHERE m2 like 'The fox jumps%'; +count(*) = max(a) +1 +SELECT m1 FROM t1 WHERE m1 = 'over the lazy dog'; +m1 +over the lazy dog +SELECT m2 FROM t1 WHERE m2 like '%the fox.'; +m2 +The lazy dog jumps over the fox. +ALTER TABLE t1 ADD COLUMN n1 BINARY(10), ADD COLUMN n2 VARBINARY(10), ALGORITHM=DEFAULT; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE (name = 'n1' OR name = 'n2') AND has_default = 1; +name default_value +n1 NULL +n2 NULL +INSERT INTO t1(a, n1, n2) VALUES(0, 0x010203040506070809, 0x102030405060708090); +SELECT count(*) = max(a) FROM t1 WHERE n1 IS NULL; +count(*) = max(a) +1 +SELECT count(*) = max(a) FROM t1 WHERE n2 IS NULL; +count(*) = max(a) +1 +SELECT hex(n1) FROM t1 WHERE n1 = 0x01020304050607080900; +hex(n1) +01020304050607080900 +SELECT hex(n2) FROM t1 WHERE n2 = 0x102030405060708090; +hex(n2) +102030405060708090 +ALTER TABLE t1 ADD COLUMN o1 BINARY(10) DEFAULT 0x11223344, ADD COLUMN o2 VARBINARY(10) DEFAULT 0x55667788; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE (name = 'o1' OR name = 'o2') AND has_default = 1; +name default_value +o1 11223344000000000000 +o2 55667788 +INSERT INTO t1(a, o1, o2) VALUES(0, 0x44332211, 0x88776655); +SELECT count(*) = max(a) FROM t1 WHERE o1 = 0x11223344000000000000; +count(*) = max(a) +1 +SELECT count(*) = max(a) FROM t1 WHERE o2 = 0x55667788; +count(*) = max(a) +1 +SELECT hex(o1) FROM t1 WHERE o1 = 0x44332211000000000000; +hex(o1) +44332211000000000000 +SELECT hex(o2) FROM t1 WHERE o2 = 0x88776655; +hex(o2) +88776655 +ALTER TABLE t1 ADD COLUMN p1 DATETIME, ALGORITHM=DEFAULT; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'p1' AND has_default = 1; +name default_value +p1 NULL +INSERT INTO t1(a, p1) VALUES(0, '2017-12-31 00:00:00'); +SELECT count(*) = max(a) FROM t1 WHERE p1 IS NULL; +count(*) = max(a) +1 +SELECT p1 FROM t1 WHERE p1 = '2017-12-31 00:00:00'; +p1 +2017-12-31 00:00:00 +ALTER TABLE t1 ADD COLUMN p2 DATETIME NOT NULL DEFAULT '2017-12-31 01:02:03'; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'p2' AND has_default = 1; +name default_value +p2 999e7e1083 +SELECT count(*) = max(a) FROM t1 GROUP BY p2; +count(*) = max(a) +1 +INSERT INTO t1(a, p2) VALUES(0, now()); +SELECT count(*) FROM t1 GROUP BY p2; +count(*) +26 +1 +ALTER TABLE t1 ADD COLUMN q1 ENUM ('value1','value2','value3'), ALGORITHM=INSTANT; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'q1' AND has_default = 1; +name default_value +q1 NULL +INSERT INTO t1(a, q1) VALUES(0, 1); +SELECT count(*) = max(a) FROM t1 WHERE q1 IS NULL; +count(*) = max(a) +1 +SELECT q1 FROM t1 WHERE q1 = 1; +q1 +value1 +ALTER TABLE t1 ADD COLUMN r1 SET ('a','b','c'), ALGORITHM=INSTANT; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'r1' AND has_default = 1; +name default_value +r1 NULL +INSERT INTO t1(a, r1) VALUES(0, 'a'); +SELECT count(*) = max(a) FROM t1 WHERE r1 IS NULL; +count(*) = max(a) +1 +SELECT r1 FROM t1 WHERE r1 = 'a'; +r1 +a +ALTER TABLE t1 ADD COLUMN s1 BLOB, ADD COLUMN s2 TEXT, ALGORITHM=INSTANT; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE (name = 's1' OR name = 's2') AND has_default = 1; +name default_value +s1 NULL +s2 NULL +INSERT INTO t1(a, s1, s2) VALUES(0, 0x0102030405, 'abcd qwerty'); +SELECT count(*) = max(a) FROM t1 WHERE s1 IS NULL; +count(*) = max(a) +1 +SELECT count(*) = max(a) FROM t1 WHERE s2 IS NULL; +count(*) = max(a) +1 +SELECT hex(s1) FROM t1 WHERE s1 = 0x0102030405; +hex(s1) +0102030405 +SELECT s2 FROM t1 WHERE s2 = 'abcd qwerty'; +s2 +abcd qwerty +ALTER TABLE t1 ADD COLUMN u1 BLOB NOT NULL, ADD COLUMN u2 TEXT NOT NULL; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE (name = 'u1' OR name = 'u2') AND has_default = 1; +name default_value +u1 +u2 +INSERT INTO t1(a, u1, u2) VALUES(0, 0x0102030405, 'abcd qwerty'); +SELECT count(*) = max(a) FROM t1 WHERE u1 = ''; +count(*) = max(a) +1 +SELECT count(*) = max(a) FROM t1 WHERE u2 = ''; +count(*) = max(a) +1 +SELECT hex(u1) FROM t1 WHERE u1 = 0x0102030405; +hex(u1) +0102030405 +SELECT u2 FROM t1 WHERE u2 = 'abcd qwerty'; +u2 +abcd qwerty +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int NOT NULL AUTO_INCREMENT, + `b` int DEFAULT NULL, + `c1` int DEFAULT NULL, + `c2` int NOT NULL DEFAULT '10', + `d1` bigint DEFAULT NULL, + `d2` bigint NOT NULL DEFAULT '1234567890', + `e1` smallint DEFAULT NULL, + `e2` smallint NOT NULL DEFAULT '10', + `f1` tinyint DEFAULT NULL, + `f2` tinyint NOT NULL DEFAULT '123', + `g1` mediumint DEFAULT NULL, + `g2` mediumint NOT NULL DEFAULT '12345', + `h1` float DEFAULT NULL, + `h2` float NOT NULL DEFAULT '12.34', + `i1` decimal(5,2) DEFAULT NULL, + `i2` double DEFAULT NULL, + `j1` decimal(5,2) NOT NULL DEFAULT '100.00', + `j2` double NOT NULL DEFAULT '1000.5678', + `k1` bit(8) DEFAULT NULL, + `k2` bit(8) NOT NULL DEFAULT b'101010', + `l1` char(50) DEFAULT NULL, + `l2` varchar(100) DEFAULT NULL, + `m1` char(50) DEFAULT 'The fox jumps over', + `m2` varchar(50) DEFAULT 'The fox jumps over the lazy dog.', + `n1` binary(10) DEFAULT NULL, + `n2` varbinary(10) DEFAULT NULL, + `o1` binary(10) DEFAULT '"3D\0\0\0\0\0\0', + `o2` varbinary(10) DEFAULT 'Ufw?', + `p1` datetime DEFAULT NULL, + `p2` datetime NOT NULL DEFAULT '2017-12-31 01:02:03', + `q1` enum('value1','value2','value3') DEFAULT NULL, + `r1` set('a','b','c') DEFAULT NULL, + `s1` blob, + `s2` text, + `u1` blob NOT NULL, + `u2` text NOT NULL, + PRIMARY KEY (`a`) +) ENGINE=InnoDB AUTO_INCREMENT=32 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=DYNAMIC +DROP TABLE t1; +# +# Scenario 2: +# Create a small table, add some columns instantly, along with +# virtual columns +# +CREATE TABLE t1 (a INT NOT NULL AUTO_INCREMENT PRIMARY KEY, b INT) ROW_FORMAT=DYNAMIC; +INSERT INTO t1 VALUES(0, 1), (0, 2), (0, 3), (0, 4), (0, 5); +ALTER TABLE t1 ADD COLUMN c INT NOT NULL, ADD COLUMN d INT GENERATED ALWAYS AS ((b * 2)) VIRTUAL; +Table id did not change +count(*) = 1 +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +INSERT INTO t1(a, b, c) VALUES(0, 6, 20); +SELECT * FROM t1; +a b c d +1 1 0 2 +2 2 0 4 +3 3 0 6 +4 4 0 8 +5 5 0 10 +6 6 20 12 +ALTER TABLE t1 ADD COLUMN e VARCHAR(100) DEFAULT 'ABCD EFGH', ADD COLUMN f INT GENERATED ALWAYS AS (LENGTH(e)); +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +INSERT INTO t1(a, c, e) VALUES(0, 20, 'Hello'), (0, 20, 'World'), (0, 20, 'Hello World'); +SELECT * FROM t1; +a b c d e f +1 1 0 2 ABCD EFGH 9 +2 2 0 4 ABCD EFGH 9 +3 3 0 6 ABCD EFGH 9 +4 4 0 8 ABCD EFGH 9 +5 5 0 10 ABCD EFGH 9 +6 6 20 12 ABCD EFGH 9 +7 NULL 20 NULL Hello 5 +8 NULL 20 NULL World 5 +9 NULL 20 NULL Hello World 11 +ALTER TABLE t1 ADD COLUMN g VARCHAR(100) GENERATED ALWAYS AS (e), ADD COLUMN h BIGINT DEFAULT 10000, ADD COLUMN i BIGINT GENERATED ALWAYS AS (h * 2 + b); +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT * FROM t1; +a b c d e f g h i +1 1 0 2 ABCD EFGH 9 ABCD EFGH 10000 20001 +2 2 0 4 ABCD EFGH 9 ABCD EFGH 10000 20002 +3 3 0 6 ABCD EFGH 9 ABCD EFGH 10000 20003 +4 4 0 8 ABCD EFGH 9 ABCD EFGH 10000 20004 +5 5 0 10 ABCD EFGH 9 ABCD EFGH 10000 20005 +6 6 20 12 ABCD EFGH 9 ABCD EFGH 10000 20006 +7 NULL 20 NULL Hello 5 Hello 10000 NULL +8 NULL 20 NULL World 5 World 10000 NULL +9 NULL 20 NULL Hello World 11 Hello World 10000 NULL +INSERT INTO t1(a, b, c, h) VALUES(0, 7, 40, 2000), (0, 7, 40, 20000); +SELECT * FROM t1; +a b c d e f g h i +1 1 0 2 ABCD EFGH 9 ABCD EFGH 10000 20001 +2 2 0 4 ABCD EFGH 9 ABCD EFGH 10000 20002 +3 3 0 6 ABCD EFGH 9 ABCD EFGH 10000 20003 +4 4 0 8 ABCD EFGH 9 ABCD EFGH 10000 20004 +5 5 0 10 ABCD EFGH 9 ABCD EFGH 10000 20005 +6 6 20 12 ABCD EFGH 9 ABCD EFGH 10000 20006 +7 NULL 20 NULL Hello 5 Hello 10000 NULL +8 NULL 20 NULL World 5 World 10000 NULL +9 NULL 20 NULL Hello World 11 Hello World 10000 NULL +10 7 40 14 ABCD EFGH 9 ABCD EFGH 2000 4007 +11 7 40 14 ABCD EFGH 9 ABCD EFGH 20000 40007 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int NOT NULL AUTO_INCREMENT, + `b` int DEFAULT NULL, + `c` int NOT NULL, + `d` int GENERATED ALWAYS AS ((`b` * 2)) VIRTUAL, + `e` varchar(100) DEFAULT 'ABCD EFGH', + `f` int GENERATED ALWAYS AS (length(`e`)) VIRTUAL, + `g` varchar(100) GENERATED ALWAYS AS (`e`) VIRTUAL, + `h` bigint DEFAULT '10000', + `i` bigint GENERATED ALWAYS AS (((`h` * 2) + `b`)) VIRTUAL, + PRIMARY KEY (`a`) +) ENGINE=InnoDB AUTO_INCREMENT=12 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=DYNAMIC +DROP TABLE t1; +# +# Scenario 3: +# Create a small table, add some columns instantly, then change +# their default values, check original default values are correct +# +CREATE TABLE t1 (a INT NOT NULL AUTO_INCREMENT PRIMARY KEY, b INT) ROW_FORMAT=DYNAMIC; +INSERT INTO t1 VALUES(0, 1), (0, 2), (0, 3), (0, 4), (0, 5); +ALTER TABLE t1 ADD COLUMN c INT NOT NULL DEFAULT 100, ADD COLUMN d INT GENERATED ALWAYS AS ((c * 2 + b)) VIRTUAL, ADD COLUMN e VARCHAR(100) DEFAULT 'Hello world'; +Table id did not change +count(*) = 2 +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT * FROM t1; +a b c d e +1 1 100 201 Hello world +2 2 100 202 Hello world +3 3 100 203 Hello world +4 4 100 204 Hello world +5 5 100 205 Hello world +INSERT INTO t1(a, b, c, e) VALUES(0, 6, 200, 'Good day'), (0, 7, 300, 'Good DAY'); +SELECT * FROM t1; +a b c d e +1 1 100 201 Hello world +2 2 100 202 Hello world +3 3 100 203 Hello world +4 4 100 204 Hello world +5 5 100 205 Hello world +6 6 200 406 Good day +7 7 300 607 Good DAY +SELECT default_value FROM information_schema.innodb_columns WHERE name = 'c' AND has_default = 1; +default_value +80000064 +ALTER TABLE t1 ALTER COLUMN c SET DEFAULT 500; +SELECT default_value FROM information_schema.innodb_columns WHERE name = 'c' AND +has_default = 1; +default_value +80000064 +SELECT * FROM t1; +a b c d e +1 1 100 201 Hello world +2 2 100 202 Hello world +3 3 100 203 Hello world +4 4 100 204 Hello world +5 5 100 205 Hello world +6 6 200 406 Good day +7 7 300 607 Good DAY +INSERT INTO t1(a, b) VALUES(0, 8), (0, 9); +SELECT * FROM t1; +a b c d e +1 1 100 201 Hello world +2 2 100 202 Hello world +3 3 100 203 Hello world +4 4 100 204 Hello world +5 5 100 205 Hello world +6 6 200 406 Good day +7 7 300 607 Good DAY +8 8 500 1008 Hello world +9 9 500 1009 Hello world +SELECT default_value FROM information_schema.innodb_columns WHERE name = 'e' AND has_default = 1; +default_value +48656c6c6f20776f726c64 +ALTER TABLE t1 ALTER COLUMN e SET DEFAULT 'HELLO MySQL!'; +SELECT default_value FROM information_schema.innodb_columns WHERE name = 'e' AND has_default = 1; +default_value +48656c6c6f20776f726c64 +SELECT * FROM t1; +a b c d e +1 1 100 201 Hello world +2 2 100 202 Hello world +3 3 100 203 Hello world +4 4 100 204 Hello world +5 5 100 205 Hello world +6 6 200 406 Good day +7 7 300 607 Good DAY +8 8 500 1008 Hello world +9 9 500 1009 Hello world +INSERT INTO t1(a, b) VALUES(0, 10), (0, 20); +SELECT * FROM t1; +a b c d e +1 1 100 201 Hello world +2 2 100 202 Hello world +3 3 100 203 Hello world +4 4 100 204 Hello world +5 5 100 205 Hello world +6 6 200 406 Good day +7 7 300 607 Good DAY +8 8 500 1008 Hello world +9 9 500 1009 Hello world +10 10 500 1010 HELLO MySQL! +11 20 500 1020 HELLO MySQL! +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int NOT NULL AUTO_INCREMENT, + `b` int DEFAULT NULL, + `c` int NOT NULL DEFAULT '500', + `d` int GENERATED ALWAYS AS (((`c` * 2) + `b`)) VIRTUAL, + `e` varchar(100) DEFAULT 'HELLO MySQL!', + PRIMARY KEY (`a`) +) ENGINE=InnoDB AUTO_INCREMENT=12 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=DYNAMIC +DROP TABLE t1; +# +# Scenario 4: +# Create a small table, add some columns instantly, then do DML +# on the table +# +CREATE TABLE t1 (a INT NOT NULL AUTO_INCREMENT PRIMARY KEY, b INT) ROW_FORMAT=DYNAMIC; +INSERT INTO t1 VALUES(0, 1), (0, 2), (0, 3), (0, 4), (0, 5); +ALTER TABLE t1 ADD COLUMN c INT NOT NULL DEFAULT 100, ADD COLUMN d INT GENERATED ALWAYS AS ((c * 2 + b)) VIRTUAL, ADD COLUMN e VARCHAR(100) DEFAULT 'Hello world'; +Table id did not change +count(*) = 2 +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +UPDATE t1 SET c = 200 WHERE a > 3; +SELECT distinct(c) FROM t1; +c +100 +200 +INSERT INTO t1(b, c, e) SELECT b, c, e FROM t1; +INSERT INTO t1(b, c, e) SELECT b, c, e FROM t1; +INSERT INTO t1(b, c, e) SELECT b, c, e FROM t1; +DELETE FROM t1 WHERE c = 100; +UPDATE t1 SET c = 300; +SELECT distinct(c) FROM t1; +c +300 +SELECT count(*) FROM t1; +count(*) +16 +ALTER TABLE t1 ADD COLUMN t DATETIME DEFAULT CURRENT_TIMESTAMP; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +UPDATE t1 SET e = 'Hello MySQL' WHERE a > 10; +UPDATE t1 SET e = 'Hello MySQL!!' WHERE a > 20; +SELECT distinct(e) FROM t1; +e +Hello world +Hello MySQL +Hello MySQL!! +UPDATE t1 SET c = 500 WHERE e LIKE '%world%'; +SELECT c, e FROM t1 GROUP BY c, e; +c e +300 Hello MySQL +300 Hello MySQL!! +500 Hello world +INSERT INTO t1(b, c, e) SELECT b, c, e FROM t1; +UPDATE t1 SET t = CURRENT_TIMESTAMP WHERE a < 50; +SELECT count(t) FROM t1 GROUP BY t; +count(t) +16 +16 +DELETE FROM t1 WHERE a < 50; +SELECT count(t) FROM t1 GROUP BY t; +count(t) +16 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int NOT NULL AUTO_INCREMENT, + `b` int DEFAULT NULL, + `c` int NOT NULL DEFAULT '100', + `d` int GENERATED ALWAYS AS (((`c` * 2) + `b`)) VIRTUAL, + `e` varchar(100) DEFAULT 'Hello world', + `t` datetime DEFAULT CURRENT_TIMESTAMP, + PRIMARY KEY (`a`) +) ENGINE=InnoDB AUTO_INCREMENT=90 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=DYNAMIC +DROP TABLE t1; +# +# Scenario 5: +# Create a small table, add some columns instantly, then do DDL +# to build indexes +# +CREATE TABLE t1 (a INT NOT NULL AUTO_INCREMENT PRIMARY KEY, b INT) ROW_FORMAT=DYNAMIC; +INSERT INTO t1 VALUES(0, 1), (0, 2), (0, 3), (0, 4), (0, 5); +ALTER TABLE t1 ADD COLUMN c INT NOT NULL DEFAULT 100, ADD COLUMN d INT GENERATED ALWAYS AS ((c * 2 + b)) VIRTUAL, ADD COLUMN e VARCHAR(100) DEFAULT 'Hello world'; +Table id did not change +count(*) = 2 +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +ALTER TABLE t1 ADD KEY(c); +EXPLAIN SELECT c FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL # NULL # 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL c # NULL # 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c` AS `c` from `test`.`t1` +SELECT c FROM t1 WHERE c != 100; +c +INSERT INTO t1(b, c, e) SELECT b, c, e FROM t1; +INSERT INTO t1(b, c, e) SELECT b, c, e FROM t1; +INSERT INTO t1(b, c, e) SELECT b, c, e FROM t1; +UPDATE t1 SET e = 'Hello MySQL' WHERE a > 30; +ALTER TABLE t1 ADD KEY(e); +EXPLAIN SELECT e FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL # NULL # 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL e # NULL # 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`e` AS `e` from `test`.`t1` +SELECT count(e) FROM t1 WHERE e LIKE '%MySQL%'; +count(e) +17 +SELECT count(e) FROM t1 WHERE e LIKE '%world%'; +count(e) +23 +ALTER TABLE t1 DROP PRIMARY KEY, ADD PRIMARY KEY(a, c); +SELECT a, c, e FROM t1 WHERE a > 25 AND a < 40; +a c e +28 100 Hello world +29 100 Hello world +30 100 Hello world +31 100 Hello MySQL +32 100 Hello MySQL +33 100 Hello MySQL +34 100 Hello MySQL +35 100 Hello MySQL +36 100 Hello MySQL +37 100 Hello MySQL +38 100 Hello MySQL +39 100 Hello MySQL +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int NOT NULL AUTO_INCREMENT, + `b` int DEFAULT NULL, + `c` int NOT NULL DEFAULT '100', + `d` int GENERATED ALWAYS AS (((`c` * 2) + `b`)) VIRTUAL, + `e` varchar(100) DEFAULT 'Hello world', + PRIMARY KEY (`a`,`c`), + KEY `c` (`c`), + KEY `e` (`e`) +) ENGINE=InnoDB AUTO_INCREMENT=59 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=DYNAMIC +DROP TABLE t1; +# +# Scenario 6: +# Create a small table, add some columns instantly, then do DML +# on the table, and some simple rollback +# +CREATE TABLE t1 (a INT NOT NULL AUTO_INCREMENT PRIMARY KEY, b INT) ROW_FORMAT=DYNAMIC; +INSERT INTO t1 VALUES(0, 1), (0, 2), (0, 3), (0, 4), (0, 5); +ALTER TABLE t1 ADD COLUMN c INT NOT NULL DEFAULT 100, ADD COLUMN d INT GENERATED ALWAYS AS ((c * 2 + b)) VIRTUAL, ADD COLUMN e VARCHAR(100) DEFAULT 'Hello world'; +Table id did not change +count(*) = 2 +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +START TRANSACTION; +INSERT INTO t1(a, b) VALUES(0, 6); +SELECT * FROM t1; +a b c d e +1 1 100 201 Hello world +2 2 100 202 Hello world +3 3 100 203 Hello world +4 4 100 204 Hello world +5 5 100 205 Hello world +6 6 100 206 Hello world +ROLLBACK; +SELECT * FROM t1; +a b c d e +1 1 100 201 Hello world +2 2 100 202 Hello world +3 3 100 203 Hello world +4 4 100 204 Hello world +5 5 100 205 Hello world +START TRANSACTION; +UPDATE t1 SET c = 500 WHERE a = 1; +UPDATE t1 SET b = 1000 WHERE a = 2; +SELECT a, b, c FROM t1 WHERE a = 1 OR a = 2; +a b c +1 1 500 +2 1000 100 +ROLLBACK; +SELECT a, b, c FROM t1; +a b c +1 1 100 +2 2 100 +3 3 100 +4 4 100 +5 5 100 +START TRANSACTION; +DELETE FROM t1 WHERE a < 5; +INSERT INTO t1(a, b) VALUES(0, 6); +SELECT * FROM t1; +a b c d e +5 5 100 205 Hello world +7 6 100 206 Hello world +ROLLBACK; +SELECT * FROM t1; +a b c d e +1 1 100 201 Hello world +2 2 100 202 Hello world +3 3 100 203 Hello world +4 4 100 204 Hello world +5 5 100 205 Hello world +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int NOT NULL AUTO_INCREMENT, + `b` int DEFAULT NULL, + `c` int NOT NULL DEFAULT '100', + `d` int GENERATED ALWAYS AS (((`c` * 2) + `b`)) VIRTUAL, + `e` varchar(100) DEFAULT 'Hello world', + PRIMARY KEY (`a`) +) ENGINE=InnoDB AUTO_INCREMENT=8 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=DYNAMIC +DROP TABLE t1; +CREATE TABLE t1(id INT PRIMARY KEY, c1 VARCHAR(4000), c2 VARCHAR(4000), c3 VARCHAR(1000)) ROW_FORMAT=DYNAMIC; +INSERT INTO t1 VALUES(1, repeat('a', 4000), repeat('b', 4000), repeat('c', 1)); +SELECT id, length(c1), length(c2), length(c3) FROM t1; +id length(c1) length(c2) length(c3) +1 4000 4000 1 +ALTER TABLE t1 ADD COLUMN c4 VARCHAR(500) NOT NULL DEFAULT 'dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd'; +Table id did not change +count(*) = 1 +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT id, length(c1), length(c2), length(c3), length(c4) FROM t1; +id length(c1) length(c2) length(c3) length(c4) +1 4000 4000 1 500 +START TRANSACTION; +UPDATE t1 SET c1 = repeat('x', 200) WHERE id = 1; +ROLLBACK; +SELECT id, length(c1), length(c2), length(c3), length(c4) FROM t1; +id length(c1) length(c2) length(c3) length(c4) +1 4000 4000 1 500 +START TRANSACTION; +UPDATE t1 SET c4 = 'x' WHERE id = 1; +ROLLBACK; +SELECT id, length(c1), length(c2), length(c3), length(c4) FROM t1; +id length(c1) length(c2) length(c3) length(c4) +1 4000 4000 1 500 +DROP TABLE t1; +# +# Scenario 7: +# Confirm some ADD COLUMN are instant, some are not +# +CREATE TABLE t1 (a INT NOT NULL AUTO_INCREMENT PRIMARY KEY, b INT) ROW_FORMAT=DYNAMIC; +INSERT INTO t1 VALUES(0, 1), (0, 2), (0, 3), (0, 4), (0, 5); +ALTER TABLE t1 ADD COLUMN c INT NOT NULL DEFAULT 100 AFTER b; +Table id did not change +count(*) = 1 +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +ALTER TABLE t1 ADD COLUMN d INT NOT NULL DEFAULT 100 AFTER b; +Table ID differed +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +0 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT count(*) AS `Expect 0` FROM information_schema.innodb_columns WHERE has_default = 1; +Expect 0 +0 +ALTER TABLE t1 ADD COLUMN e INT NOT NULL DEFAULT 100, ADD KEY(e); +Table ID differed +count(*) = 1 +0 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT count(*) AS `Expect 0` FROM information_schema.innodb_columns WHERE has_default = 1; +Expect 0 +0 +ALTER TABLE t1 ADD COLUMN f INT NOT NULL DEFAULT 100, FORCE; +Table ID differed +count(*) = 1 +0 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT count(*) AS `Expect 0` FROM information_schema.innodb_columns WHERE has_default = 1; +Expect 0 +0 +ALTER TABLE t1 ADD COLUMN g INT NOT NULL DEFAULT 100, ALGORITHM=INPLACE; +Table ID differed +count(*) = 1 +0 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT count(*) AS `Expect 0` FROM information_schema.innodb_columns WHERE has_default = 1; +Expect 0 +0 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int NOT NULL AUTO_INCREMENT, + `b` int DEFAULT NULL, + `d` int NOT NULL DEFAULT '100', + `c` int NOT NULL DEFAULT '100', + `e` int NOT NULL DEFAULT '100', + `f` int NOT NULL DEFAULT '100', + `g` int NOT NULL DEFAULT '100', + PRIMARY KEY (`a`), + KEY `e` (`e`) +) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=DYNAMIC +DROP TABLE t1; +CREATE TABLE t1 (a INT NOT NULL AUTO_INCREMENT PRIMARY KEY, b INT, c TEXT, FULLTEXT(c)) ROW_FORMAT=DYNAMIC; +INSERT INTO t1 VALUES(0, 1, 'Hello'), (0, 2, 'HELLO'), (0, 3, 'World'), (0, 4, 'Hello world'), (0, 5, 'HELLO WORLD'); +ALTER TABLE t1 ADD COLUMN d INT NOT NULL DEFAULT 100 AFTER b; +Table ID differed +count(*) = 1 +0 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +DROP TABLE t1; +# +# Scenario 8: +# Check FK constraints on instantly added columns +# +CREATE TABLE t1 (a INT NOT NULL AUTO_INCREMENT PRIMARY KEY, b INT) ROW_FORMAT=DYNAMIC; +CREATE TABLE t2(a INT NOT NULL PRIMARY KEY, b INT, c INT, KEY(c)); +INSERT INTO t1 VALUES(0, 1), (0, 2), (0, 3), (0, 4), (0, 5); +INSERT INTO t2 VALUES(1, 2, 3), (2, 3, 4), (3, 4, 5); +ALTER TABLE t1 ADD COLUMN c INT NOT NULL DEFAULT 3; +Table id did not change +count(*) = 1 +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +UPDATE t1 SET c = 4 WHERE a = 2; +UPDATE t1 SET c = 5 WHERE a = 3; +ALTER TABLE t1 ADD KEY(c); +ALTER TABLE t2 ADD FOREIGN KEY (c) REFERENCES t1(c) ON UPDATE CASCADE, ALGORITHM = COPY; +UPDATE t1 SET c = 10 WHERE a = 1; +SELECT c FROM t2; +c +10 +4 +5 +UPDATE t1 SET c = 10; +SELECT c FROM t2; +c +10 +10 +10 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int NOT NULL AUTO_INCREMENT, + `b` int DEFAULT NULL, + `c` int NOT NULL DEFAULT '3', + PRIMARY KEY (`a`), + KEY `c` (`c`) +) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=DYNAMIC +DROP TABLE t2; +DROP TABLE t1; +# +# Scenario 9: +# Instant ADD COLUMN on partitioned table, only simple test here +# +CREATE TABLE t1 (a INT NOT NULL AUTO_INCREMENT PRIMARY KEY, b INT) ROW_FORMAT=DYNAMIC PARTITION BY HASH(a) PARTITIONS 3;; +INSERT INTO t1 VALUES(0, 1), (0, 2), (0, 3), (0, 4), (0, 5), (0, 6), (0, 7), (0, 8); +ALTER TABLE t1 ADD COLUMN c INT NOT NULL DEFAULT 5; +Table id did not change +count(*) = 1 +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT * FROM t1; +a b c +3 3 5 +6 6 5 +1 1 5 +4 4 5 +7 7 5 +2 2 5 +5 5 5 +8 8 5 +INSERT INTO t1 VALUES(0, 9, 10), (0, 10, 20); +SELECT * FROM t1 WHERE b > 8; +a b c +9 9 10 +10 10 20 +UPDATE t1 SET c = 8 WHERE a = 1 OR a = 3 OR a = 5 OR a = 7; +SELECT * FROM t1; +a b c +3 3 8 +6 6 5 +9 9 10 +1 1 8 +4 4 5 +7 7 8 +10 10 20 +2 2 5 +5 5 8 +8 8 5 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int NOT NULL AUTO_INCREMENT, + `b` int DEFAULT NULL, + `c` int NOT NULL DEFAULT '5', + PRIMARY KEY (`a`) +) ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=DYNAMIC +/*!50100 PARTITION BY HASH (`a`) +PARTITIONS 3 */ +DROP TABLE t1; +CREATE TABLE t1 (a INT, b INT) ROW_FORMAT=DYNAMIC PARTITION BY HASH(a) PARTITIONS 2;; +ALTER TABLE t1 ADD COLUMN c INT NOT NULL DEFAULT 5; +Table id did not change +count(*) = 1 +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +ALTER TABLE t1 CHANGE COLUMN c c1 INT; +ALTER TABLE t1 ADD COLUMN c INT NOT NULL DEFAULT 5; +Table id did not change +count(*) = 1 +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +DROP TABLE t1; +# +# Scenario 10: +# EXCHANGE PARTITION is not allowed if either is instant +# +CREATE TABLE t1 (a INT NOT NULL AUTO_INCREMENT PRIMARY KEY, b INT) ROW_FORMAT=DYNAMIC;; +INSERT INTO t1 VALUES(0, 1), (0, 2), (0, 3), (0, 4), (0, 5), (0, 6), (0, 7), (0, 8); +ALTER TABLE t1 ADD COLUMN c INT NOT NULL DEFAULT 5; +Table id did not change +count(*) = 1 +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +CREATE TABLE t2 (a INT NOT NULL AUTO_INCREMENT PRIMARY KEY, b INT, c INT NOT NULL DEFAULT 5) ROW_FORMAT=DYNAMIC PARTITION BY RANGE (a) (PARTITION p1 VALUES LESS THAN (10), PARTITION p2 VALUES LESS THAN (20), PARTITION p3 VALUES LESS THAN (30));; +ALTER TABLE t2 EXCHANGE PARTITION p1 WITH TABLE t1; +ERROR HY000: Non matching attribute 'INSTANT COLUMN(s)' between partition and table +ALTER TABLE t2 ADD COLUMN d INT; +ALTER TABLE t1 ADD COLUMN d INT, ALGORITHM=INPLACE; +ALTER TABLE t2 EXCHANGE PARTITION p1 WITH TABLE t1; +ERROR HY000: Non matching attribute 'INSTANT COLUMN(s)' between partition and table +OPTIMIZE TABLE t2; +Table Op Msg_type Msg_text +test.t2 optimize note Table does not support optimize, doing recreate + analyze instead +test.t2 optimize status OK +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int NOT NULL AUTO_INCREMENT, + `b` int DEFAULT NULL, + `c` int NOT NULL DEFAULT '5', + `d` int DEFAULT NULL, + PRIMARY KEY (`a`) +) ENGINE=InnoDB AUTO_INCREMENT=9 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=DYNAMIC +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `a` int NOT NULL AUTO_INCREMENT, + `b` int DEFAULT NULL, + `c` int NOT NULL DEFAULT '5', + `d` int DEFAULT NULL, + PRIMARY KEY (`a`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=DYNAMIC +/*!50100 PARTITION BY RANGE (`a`) +(PARTITION p1 VALUES LESS THAN (10) ENGINE = InnoDB, + PARTITION p2 VALUES LESS THAN (20) ENGINE = InnoDB, + PARTITION p3 VALUES LESS THAN (30) ENGINE = InnoDB) */ +ALTER TABLE t2 EXCHANGE PARTITION p1 WITH TABLE t1; +DROP TABLE t1, t2; +# +# Scenario 11: +# PRIMARY KEY with more than one column, at least to verify it works with REDUDANT +# +CREATE TABLE t1 (a INT NOT NULL, b INT NOT NULL, PRIMARY KEY(a, b)) ROW_FORMAT=DYNAMIC;; +INSERT INTO t1 VALUES(0, 1), (1, 2), (2, 3), (3, 4); +ALTER TABLE t1 ADD COLUMN c INT NOT NULL DEFAULT 5; +Table id did not change +count(*) = 1 +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT * FROM t1; +a b c +0 1 5 +1 2 5 +2 3 5 +3 4 5 +UPDATE t1 SET c = b WHERE b <= 2; +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT * FROM t1; +a b c +0 1 1 +1 2 2 +2 3 5 +3 4 5 +DROP TABLE t1; +# +# Scenario 12: +# Mix ALTER PARTITION and ALTER TABLE ... INPLACE. This is to check if first partition is not +# instant after ALTER PARTITION, will the metadata be copied correctly +# +CREATE TABLE t1 (col1 INT, col2 INT, col3 INT, col4 TEXT) ENGINE = InnoDB PARTITION BY RANGE(col1 * 2) ( PARTITION p0 VALUES LESS THAN (128), PARTITION p1 VALUES LESS THAN (256) , PARTITION p2 VALUES LESS THAN (384) , PARTITION p3 VALUES LESS THAN MAXVALUE);; +INSERT INTO t1 VALUES(1, 2, 3, 'abcdefg'), (100, 200, 300, 'qwerty'), (200, 300, 400, 'asdfg'); +ALTER TABLE t1 ALGORITHM DEFAULT, ADD COLUMN col5 VARCHAR(500), ADD COLUMN col6 TEXT; +Table id did not change +count(*) = 2 +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT count(*) AS `Expect 4` FROM information_schema.innodb_tables WHERE instant_cols != 0; +Expect 4 +4 +ALTER TABLE t1 ALGORITHM INPLACE, REORGANIZE PARTITION p0 INTO (PARTITION p0_a VALUES LESS THAN (64), PARTITION p0_b VALUES LESS THAN (128)); +SELECT count(*) AS `Expect 3` FROM information_schema.innodb_tables WHERE instant_cols != 0; +Expect 3 +3 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +ALTER TABLE t1 ALGORITHM DEFAULT, ADD KEY idx4(col4(10)); +SELECT count(*) AS `Expect 3` FROM information_schema.innodb_tables WHERE instant_cols != 0; +Expect 3 +3 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +ALTER TABLE t1 ALGORITHM DEFAULT, LOCK EXCLUSIVE, REORGANIZE PARTITION p0_a, p0_b INTO (PARTITION p0 VALUES LESS THAN (128) TABLESPACE innodb_file_per_table); +SELECT count(*) AS `Expect 3` FROM information_schema.innodb_tables WHERE instant_cols != 0; +Expect 3 +3 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +ALTER TABLE t1 ADD KEY idx3(col3); +SELECT count(*) AS `Expect 3` FROM information_schema.innodb_tables WHERE instant_cols != 0; +Expect 3 +3 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT * FROM t1; +col1 col2 col3 col4 col5 col6 +1 2 3 abcdefg NULL NULL +100 200 300 qwerty NULL NULL +200 300 400 asdfg NULL NULL +DROP TABLE t1; +CREATE TABLE t1 (a INT NOT NULL AUTO_INCREMENT PRIMARY KEY, b INT) ROW_FORMAT=DYNAMIC PARTITION BY HASH(a) PARTITIONS 3;; +INSERT INTO t1 VALUES(0, 1), (0, 2), (0, 3), (0, 4), (0, 5), (0, 6), (0, 7), (0, 8); +ALTER TABLE t1 ADD COLUMN c INT NOT NULL DEFAULT 5; +Table id did not change +count(*) = 1 +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT count(*) AS `Expect 3` FROM information_schema.innodb_tables WHERE instant_cols != 0; +Expect 3 +3 +ALTER TABLE t1 ADD PARTITION PARTITIONS 10; +SELECT count(*) AS `Expect 0` FROM information_schema.innodb_tables WHERE instant_cols != 0; +Expect 0 +0 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +ALTER TABLE t1 ADD KEY(b); +SELECT count(*) AS `Expect 0` FROM information_schema.innodb_tables WHERE instant_cols != 0; +Expect 0 +0 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT * FROM t1; +a b c +1 1 5 +2 2 5 +3 3 5 +4 4 5 +5 5 5 +6 6 5 +7 7 5 +8 8 5 +DROP TABLE t1; +# +# Scenario 13: +# Create a table with a two level clustered index, do instant ADD COLUMN, then the non-leaf node +# should be parsed correctly +# +CREATE TABLE t1 (a INT NOT NULL AUTO_INCREMENT, d INT NOT NULL, b BLOB NOT NULL, c VARCHAR(87), INDEX(d), INDEX(a ASC), PRIMARY KEY (a, d DESC, c DESC)) ROW_FORMAT=DYNAMIC PARTITION BY LINEAR KEY(c) PARTITIONS 9;; +INSERT INTO t1(d, b, c) VALUES(1, 2, 'aaaaaaaaaabbbbbbbbbbccccccccccddddddddddeeeeeeeeeeffffffffffgggggggggghhhhhhhhhhjjjjjjj'); +INSERT INTO t1(d, b, c) VALUES(2, 3, 'aaaaaaaaaahhhhhhhhhhbbbbbbbbbbccccccccccddddddddddeeeeeeeeeeffffffffffggggggggggjjjjjjj'); +INSERT INTO t1(d, b, c) VALUES(3, 4, 'bbbbbbbbbbaaaaaaaaaahhhhhhhhhhccccccccccddddddddddeeeeeeeeeeffffffffffggggggggggjjjjjjj'); +INSERT INTO t1(d, b, c) VALUES(4, 5, 'eeeeeeeeeehhhhhhhhhhbbbbbbbbbbccccccccccddddddddddaaaaaaaaaaffffffffffggggggggggjjjjjjj'); +INSERT INTO t1(d, b, c) VALUES(5, 6, 'aaaaaaaaaahhhhhhhhhhbbbbbbbbbbddddddddddcccccccccceeeeeeeeeeffffffffffggggggggggjjjjjjj'); +INSERT INTO t1(d, b, c) VALUES(6, 7, 'cccccccccchhhhhhhhhhbbbbbbbbbbaaaaaaaaaaddddddddddeeeeeeeeeeffffffffffggggggggggjjjjjjj'); +INSERT INTO t1(d, b, c) SELECT d, b, c FROM t1; +INSERT INTO t1(d, b, c) SELECT d, b, c FROM t1; +INSERT INTO t1(d, b, c) SELECT d, b, c FROM t1; +INSERT INTO t1(d, b, c) SELECT d, b, c FROM t1; +INSERT INTO t1(d, b, c) SELECT d, b, c FROM t1; +INSERT INTO t1(d, b, c) SELECT d, b, c FROM t1; +ALTER TABLE t1 ADD COLUMN nc086 BIGINT NOT NULL FIRST, ALGORITHM=INPLACE, LOCK=DEFAULT; +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +ALTER TABLE t1 ADD COLUMN nc082 TINYTEXT; +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT COUNT(*) FROM t1; +COUNT(*) +384 +DROP TABLE t1; +# +# Scenario 14: +# Create a small table, and add GIS kinds of new columns and verify +# +CREATE TABLE t1 (a INT NOT NULL AUTO_INCREMENT PRIMARY KEY, b INT) ROW_FORMAT=DYNAMIC; +INSERT INTO t1 VALUES(0, 1), (0, 2), (0, 3), (0, 4), (0, 5); +ALTER TABLE t1 ADD COLUMN c1 POINT, ALGORITHM = INSTANT; +Table id did not change +count(*) = 1 +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'c1' AND has_default = 1; +name default_value +c1 NULL +INSERT INTO t1(a, c1) VALUES(0, ST_PointFromText('POINT(10 10)')); +SELECT count(*) = max(a) FROM t1 WHERE c1 IS NULL; +count(*) = max(a) +1 +ALTER TABLE t1 ADD COLUMN d1 LINESTRING, ALGORITHM = INSTANT; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'd1' AND has_default = 1; +name default_value +d1 NULL +INSERT INTO t1(a, d1) VALUES(0, ST_LineFromText('LINESTRING(0 0,0 10,10 0)')); +SELECT count(*) = max(a) FROM t1 WHERE d1 IS NULL; +count(*) = max(a) +1 +ALTER TABLE t1 ADD COLUMN e1 POLYGON, ALGORITHM = INSTANT; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'e1' AND has_default = 1; +name default_value +e1 NULL +INSERT INTO t1(a, e1) VALUES(0, ST_PolygonFromText('POLYGON((10 10,20 10,20 20,10 20,10 10))')); +SELECT count(*) = max(a) FROM t1 WHERE e1 IS NULL; +count(*) = max(a) +1 +ALTER TABLE t1 ADD COLUMN f1 MULTIPOINT, ALGORITHM = INSTANT; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'f1' AND has_default = 1; +name default_value +f1 NULL +INSERT INTO t1(a, f1) VALUES(0, ST_MultiPointFromText('MULTIPOINT(0 0,10 10,10 20,20 20)')); +SELECT count(*) = max(a) FROM t1 WHERE f1 IS NULL; +count(*) = max(a) +1 +ALTER TABLE t1 ADD COLUMN g1 MULTILINESTRING, ALGORITHM = INSTANT; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'g1' AND has_default = 1; +name default_value +g1 NULL +INSERT INTO t1(a, g1) VALUES(0, ST_MultiLineStringFromText('MULTILINESTRING((10 48,10 21,10 0),(16 0,16 23,16 48))')); +SELECT count(*) = max(a) FROM t1 WHERE g1 IS NULL; +count(*) = max(a) +1 +ALTER TABLE t1 ADD COLUMN h1 MULTIPOLYGON, ALGORITHM = INSTANT; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'h1' AND has_default = 1; +name default_value +h1 NULL +INSERT INTO t1(a, h1) VALUES(0, ST_MultiPolygonFromText('MULTIPOLYGON(((28 26,28 0,84 0,84 42,28 26),(52 18,66 23,73 9,48 6,52 18)),((59 18,67 18,67 13,59 13,59 18)))')); +SELECT count(*) = max(a) FROM t1 WHERE h1 IS NULL; +count(*) = max(a) +1 +ALTER TABLE t1 ADD COLUMN i1 GEOMETRYCOLLECTION, ALGORITHM = INSTANT; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'i1' AND has_default = 1; +name default_value +i1 NULL +INSERT INTO t1(a, i1) VALUES(0, ST_GeomCollFromText('GEOMETRYCOLLECTION(POINT(0 0), LINESTRING(0 0,10 10))')); +SELECT count(*) = max(a) FROM t1 WHERE i1 IS NULL; +count(*) = max(a) +1 +ALTER TABLE t1 ADD COLUMN j1 GEOMETRY, ALGORITHM = INSTANT; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'j1' AND has_default = 1; +name default_value +j1 NULL +INSERT INTO t1(a, j1) VALUES(0, ST_GeomCollFromText('GEOMETRYCOLLECTION(POINT(0 0), LINESTRING(0 0,10 10))')); +SELECT count(*) = max(a) FROM t1 WHERE j1 IS NULL; +count(*) = max(a) +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int NOT NULL AUTO_INCREMENT, + `b` int DEFAULT NULL, + `c1` point DEFAULT NULL, + `d1` linestring DEFAULT NULL, + `e1` polygon DEFAULT NULL, + `f1` multipoint DEFAULT NULL, + `g1` multilinestring DEFAULT NULL, + `h1` multipolygon DEFAULT NULL, + `i1` geomcollection DEFAULT NULL, + `j1` geometry DEFAULT NULL, + PRIMARY KEY (`a`) +) ENGINE=InnoDB AUTO_INCREMENT=14 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=DYNAMIC +DROP TABLE t1; +# +# Scenario 15: +# Create a small table, and add JSON columns and verify +# +CREATE TABLE t1 (a INT NOT NULL AUTO_INCREMENT PRIMARY KEY, b INT) ROW_FORMAT=DYNAMIC; +INSERT INTO t1 VALUES(0, 1), (0, 2), (0, 3), (0, 4), (0, 5); +ALTER TABLE t1 ADD COLUMN c1 JSON, ALGORITHM = INSTANT; +Table id did not change +count(*) = 1 +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'c1' AND has_default = 1; +name default_value +c1 NULL +INSERT INTO t1(a, c1) VALUES(0, '{"key1": "value1", "key2": "value2"}'); +SELECT count(*) = max(a) FROM t1 WHERE c1 IS NULL; +count(*) = max(a) +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int NOT NULL AUTO_INCREMENT, + `b` int DEFAULT NULL, + `c1` json DEFAULT NULL, + PRIMARY KEY (`a`) +) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=DYNAMIC +DROP TABLE t1; +# +# Scenario 16: +# Create a small table, and add INSTANT columns and verify with trigger +# +CREATE TABLE t1 (a INT NOT NULL AUTO_INCREMENT PRIMARY KEY, b INT) ROW_FORMAT=DYNAMIC; +CREATE TABLE t2 (a INT NOT NULL AUTO_INCREMENT PRIMARY KEY, b INT) ROW_FORMAT=DYNAMIC; +INSERT INTO t1 VALUES(0, 1), (0, 2), (0, 3), (0, 4), (0, 5); +INSERT INTO t2 VALUES(0, 1), (0, 2), (0, 3), (0, 4), (0, 5); +ALTER TABLE t1 ADD COLUMN c1 VARCHAR(10) NOT NULL DEFAULT 'aaaa', ALGORITHM = INSTANT; +Table id did not change +count(*) = 1 +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'c1' AND has_default = 1; +name default_value +c1 61616161 +CREATE TRIGGER t1_ai AFTER INSERT ON t1 FOR EACH ROW +INSERT INTO t2 VALUES(0,6); +INSERT INTO t1(a, c1) VALUES(0, 'bbbb'); +SELECT count(*) = max(a) FROM t1 WHERE c1='aaaa'; +count(*) = max(a) +1 +SELECT c1 FROM t1 WHERE c1 = 'bbbb'; +c1 +bbbb +DROP TRIGGER t1_ai; +ALTER TABLE t2 ADD COLUMN c1 VARCHAR(10) NOT NULL DEFAULT 'cccc', ALGORITHM = INSTANT; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'c1' AND has_default = 1; +name default_value +c1 61616161 +c1 63636363 +CREATE TRIGGER t2_ai AFTER INSERT ON t2 FOR EACH ROW +INSERT INTO t1(a,c1) VALUES(0,'eeee'); +INSERT INTO t2(a, c1) VALUES(0, 'dddd'); +SELECT count(*) = max(a) FROM t2 WHERE c1='cccc'; +count(*) = max(a) +1 +SELECT c1 FROM t2 WHERE c1 = 'dddd'; +c1 +dddd +DROP TRIGGER t2_ai; +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +CHECK TABLE t2; +Table Op Msg_type Msg_text +test.t2 check status OK +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int NOT NULL AUTO_INCREMENT, + `b` int DEFAULT NULL, + `c1` varchar(10) NOT NULL DEFAULT 'aaaa', + PRIMARY KEY (`a`) +) ENGINE=InnoDB AUTO_INCREMENT=8 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=DYNAMIC +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `a` int NOT NULL AUTO_INCREMENT, + `b` int DEFAULT NULL, + `c1` varchar(10) NOT NULL DEFAULT 'cccc', + PRIMARY KEY (`a`) +) ENGINE=InnoDB AUTO_INCREMENT=8 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=DYNAMIC +DROP TABLE t1,t2; +# +# Scenario 17: +# Create a small table, and add INSTANT columns and verify with storedprocedure +# +CREATE TABLE t1 (a INT NOT NULL AUTO_INCREMENT PRIMARY KEY, b INT) ROW_FORMAT=DYNAMIC; +INSERT INTO t1 VALUES(0, 1), (0, 2), (0, 3), (0, 4), (0, 5); +ALTER TABLE t1 ADD COLUMN c1 VARCHAR(10) NOT NULL DEFAULT 'aaaa', ALGORITHM = INSTANT; +Table id did not change +count(*) = 1 +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'c1' AND has_default = 1; +name default_value +c1 61616161 +CREATE PROCEDURE p1() INSERT INTO t1(a,c1) VALUES(0, 'bbbb'); +CALL p1(); +SELECT count(*) = max(a) FROM t1 WHERE c1='aaaa'; +count(*) = max(a) +1 +SELECT c1 FROM t1 WHERE c1 = 'bbbb'; +c1 +bbbb +DROP PROCEDURE p1; +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int NOT NULL AUTO_INCREMENT, + `b` int DEFAULT NULL, + `c1` varchar(10) NOT NULL DEFAULT 'aaaa', + PRIMARY KEY (`a`) +) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=DYNAMIC +DROP TABLE t1; +# +# Scenario 18: +# Create a small table, and add INSTANT columns and verify with view +# +CREATE TABLE t1 (a INT NOT NULL AUTO_INCREMENT PRIMARY KEY, b INT) ROW_FORMAT=DYNAMIC; +INSERT INTO t1 VALUES(0, 1), (0, 2), (0, 3), (0, 4), (0, 5); +ALTER TABLE t1 ADD COLUMN c1 VARCHAR(10) NOT NULL DEFAULT 'aaaa', ALGORITHM = INSTANT; +Table id did not change +count(*) = 1 +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'c1' AND has_default = 1; +name default_value +c1 61616161 +CREATE VIEW v1 AS SELECT * FROM t1; +INSERT INTO t1(a, c1) VALUES(0, 'bbbb'); +SELECT count(*) = max(a) FROM t1 WHERE c1='aaaa'; +count(*) = max(a) +1 +SELECT c1 FROM t1 WHERE c1 = 'bbbb'; +c1 +bbbb +SELECT * FROM v1; +a b c1 +1 1 aaaa +2 2 aaaa +3 3 aaaa +4 4 aaaa +5 5 aaaa +6 NULL bbbb +DROP VIEW v1; +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int NOT NULL AUTO_INCREMENT, + `b` int DEFAULT NULL, + `c1` varchar(10) NOT NULL DEFAULT 'aaaa', + PRIMARY KEY (`a`) +) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=DYNAMIC +DROP TABLE t1; +# +# Scenario 19: +# Create a small table, and add INSTANT columns and drop it and verify +# +CREATE TABLE t1 (a INT NOT NULL AUTO_INCREMENT PRIMARY KEY, b INT) ROW_FORMAT=DYNAMIC; +INSERT INTO t1 VALUES(0, 1), (0, 2), (0, 3), (0, 4), (0, 5); +ALTER TABLE t1 ADD COLUMN c1 VARCHAR(10) NOT NULL DEFAULT 'aaaa', ALGORITHM = INSTANT; +Table id did not change +count(*) = 1 +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'c1' AND has_default = 1; +name default_value +c1 61616161 +INSERT INTO t1(a, c1) VALUES(0, 'bbbb'); +SELECT count(*) = max(a) FROM t1 WHERE c1='aaaa'; +count(*) = max(a) +1 +SELECT c1 FROM t1 WHERE c1 = 'bbbb'; +c1 +bbbb +ALTER TABLE t1 DROP COLUMN c1; +Table ID differed +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +0 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int NOT NULL AUTO_INCREMENT, + `b` int DEFAULT NULL, + PRIMARY KEY (`a`) +) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=DYNAMIC +DROP TABLE t1; +# +# Scenario 20: +# Create a small table, and add INSTANT columns and rename table +# +CREATE TABLE t1 (a INT NOT NULL AUTO_INCREMENT PRIMARY KEY, b INT) ROW_FORMAT=DYNAMIC; +INSERT INTO t1 VALUES(0, 1), (0, 2), (0, 3), (0, 4), (0, 5); +ALTER TABLE t1 ADD COLUMN c1 VARCHAR(10) NOT NULL DEFAULT 'aaaa', ALGORITHM = INSTANT; +Table id did not change +count(*) = 1 +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +ALTER TABLE t1 RENAME t2; +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'c1' AND has_default = 1; +name default_value +c1 61616161 +INSERT INTO t2(a, c1) VALUES(0, 'bbbb'); +SELECT count(*) = max(a) FROM t2 WHERE c1='aaaa'; +count(*) = max(a) +1 +SELECT c1 FROM t2 WHERE c1 = 'bbbb'; +c1 +bbbb +CHECK TABLE t2; +Table Op Msg_type Msg_text +test.t2 check status OK +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `a` int NOT NULL AUTO_INCREMENT, + `b` int DEFAULT NULL, + `c1` varchar(10) NOT NULL DEFAULT 'aaaa', + PRIMARY KEY (`a`) +) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=DYNAMIC +DROP TABLE t2; +# +# Scenario 21: +# Create a small table, and add INSTANT columns and change its data type INSTANTly won't work +# +CREATE TABLE t1 (a INT NOT NULL AUTO_INCREMENT PRIMARY KEY, b INT) ROW_FORMAT=DYNAMIC; +INSERT INTO t1 VALUES(0, 1), (0, 2), (0, 3), (0, 4), (0, 5); +ALTER TABLE t1 ADD COLUMN c1 VARCHAR(10) NOT NULL DEFAULT 'aaaa', ALGORITHM = INSTANT; +Table id did not change +count(*) = 1 +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'c1' AND has_default = 1; +name default_value +c1 61616161 +INSERT INTO t1(a, c1) VALUES(0, 'bbbb'); +SELECT count(*) = max(a) FROM t1 WHERE c1='aaaa'; +count(*) = max(a) +1 +SELECT c1 FROM t1 WHERE c1 = 'bbbb'; +c1 +bbbb +ALTER TABLE t1 CHANGE c1 c2 CHAR(10) NOT NULL DEFAULT 'cccc'; +Table ID differed +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +0 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int NOT NULL AUTO_INCREMENT, + `b` int DEFAULT NULL, + `c2` char(10) NOT NULL DEFAULT 'cccc', + PRIMARY KEY (`a`) +) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=DYNAMIC +DROP TABLE t1; +# +# Scenario 22: +# Create a small table, and add INSTANT columns and create hash,btree multi column index and verify +# +CREATE TABLE t1 (a INT NOT NULL AUTO_INCREMENT PRIMARY KEY, b INT) ROW_FORMAT=DYNAMIC; +INSERT INTO t1 VALUES(0, 1), (0, 2), (0, 3), (0, 4), (0, 5); +ALTER TABLE t1 ADD COLUMN c1 VARCHAR(10) NOT NULL DEFAULT 'aaaa', ALGORITHM = INSTANT; +Table id did not change +count(*) = 1 +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'c1' AND has_default = 1; +name default_value +c1 61616161 +CREATE INDEX id1 ON t1(c1) USING BTREE; +CREATE INDEX id2 ON t1(c1) USING HASH; +Warnings: +Note 3502 This storage engine does not support the HASH index algorithm, storage engine default was used instead. +Warning 1831 Duplicate index 'id2' defined on the table 'test.t1'. This is deprecated and will be disallowed in a future release. +INSERT INTO t1(a, c1) VALUES(0, 'bbbb'); +SELECT count(*) = max(a) FROM t1 WHERE c1='aaaa'; +count(*) = max(a) +1 +SELECT c1 FROM t1 WHERE c1 = 'bbbb'; +c1 +bbbb +DROP INDEX id1 ON t1; +DROP INDEX id2 ON t1; +ALTER TABLE t1 ADD COLUMN c2 VARCHAR(10) NOT NULL DEFAULT 'cccc', ALGORITHM = INSTANT; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'c2' AND has_default = 1; +name default_value +c2 63636363 +CREATE INDEX id1 ON t1(c1 ASC,c2 DESC) USING BTREE; +INSERT INTO t1(a, c2) VALUES(0, 'dddd'); +SELECT count(*) = max(a) FROM t1 WHERE c1='cccc'; +count(*) = max(a) +NULL +SELECT c1 FROM t1 WHERE c1 = 'dddd'; +c1 +ALTER TABLE t1 RENAME INDEX id1 TO id2; +DROP INDEX id2 ON t1; +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int NOT NULL AUTO_INCREMENT, + `b` int DEFAULT NULL, + `c1` varchar(10) NOT NULL DEFAULT 'aaaa', + `c2` varchar(10) NOT NULL DEFAULT 'cccc', + PRIMARY KEY (`a`) +) ENGINE=InnoDB AUTO_INCREMENT=8 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=DYNAMIC +DROP TABLE t1; +# +# Scenario 23: +# Create a small table, and add INSTANT columns and perform table join operation +# +CREATE TABLE t1 (a INT NOT NULL AUTO_INCREMENT PRIMARY KEY, b INT) ROW_FORMAT=DYNAMIC; +CREATE TABLE t2 (a INT NOT NULL AUTO_INCREMENT PRIMARY KEY, b INT) ROW_FORMAT=DYNAMIC; +INSERT INTO t1 VALUES(0, 1), (0, 2), (0, 3), (0, 4), (0, 5); +INSERT INTO t2 VALUES(0, 1), (0, 2), (0, 3), (0, 4), (0, 5); +ALTER TABLE t1 ADD COLUMN c1 VARCHAR(10) NOT NULL DEFAULT 'aaaa', ALGORITHM = INSTANT; +Table id did not change +count(*) = 1 +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'c1' AND has_default = 1; +name default_value +c1 61616161 +INSERT INTO t1(a, c1) VALUES(0, 'cccc'); +SELECT count(*) = max(a) FROM t1 WHERE c1='aaaa'; +count(*) = max(a) +1 +SELECT c1 FROM t1 WHERE c1 = 'cccc'; +c1 +cccc +ALTER TABLE t2 ADD COLUMN c1 VARCHAR(10) NOT NULL DEFAULT 'bbbb', ALGORITHM = INSTANT; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'c1' AND has_default = 1; +name default_value +c1 61616161 +c1 62626262 +INSERT INTO t2(a, c1) VALUES(0, 'cccc'); +SELECT count(*) = max(a) FROM t2 WHERE c1='bbbb'; +count(*) = max(a) +1 +SELECT c1 FROM t2 WHERE c1 = 'cccc'; +c1 +cccc +SELECT * FROM t1 JOIN t2 ON t1.c1=t2.c1; +a b c1 a b c1 +6 NULL cccc 6 NULL cccc +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +CHECK TABLE t2; +Table Op Msg_type Msg_text +test.t2 check status OK +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int NOT NULL AUTO_INCREMENT, + `b` int DEFAULT NULL, + `c1` varchar(10) NOT NULL DEFAULT 'aaaa', + PRIMARY KEY (`a`) +) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=DYNAMIC +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `a` int NOT NULL AUTO_INCREMENT, + `b` int DEFAULT NULL, + `c1` varchar(10) NOT NULL DEFAULT 'bbbb', + PRIMARY KEY (`a`) +) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=DYNAMIC +DROP TABLE t1; +DROP TABLE t2; +# +# Scenario 24: +# Create a small table, and add stored and(or) virtual columns +# after last stored column in the table +# +CREATE TABLE t1 (a INT NOT NULL AUTO_INCREMENT PRIMARY KEY, b INT, c INT, d INT GENERATED ALWAYS AS (b + c) VIRTUAL, e INT GENERATED ALWAYS AS (b * c) VIRTUAL) ROW_FORMAT=DYNAMIC; +INSERT INTO t1(a, b, c) VALUES(0, 1, 2), (0, 2, 3), (0, 3, 4), (0, 4, 5), (0, 5, 6); +ALTER TABLE t1 ADD COLUMN h INT NOT NULL AFTER c; +Table id did not change +count(*) = 1 +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +INSERT INTO t1(a, b, c, h) VALUES(0, 6, 20, 40); +SELECT * FROM t1; +a b c h d e +1 1 2 0 3 2 +2 2 3 0 5 6 +3 3 4 0 7 12 +4 4 5 0 9 20 +5 5 6 0 11 30 +6 6 20 40 26 120 +ALTER TABLE t1 ADD COLUMN i VARCHAR(100) DEFAULT 'ABCD EFGH' AFTER h, ADD COLUMN f INT GENERATED ALWAYS AS (LENGTH(i)) AFTER i; +Table id did not change +SELECT 3 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +INSERT INTO t1(a, b, c, h, i) VALUES(0, 20, 30, 50, 'qwerty'); +SELECT * FROM t1; +a b c h i f d e +1 1 2 0 ABCD EFGH 9 3 2 +2 2 3 0 ABCD EFGH 9 5 6 +3 3 4 0 ABCD EFGH 9 7 12 +4 4 5 0 ABCD EFGH 9 9 20 +5 5 6 0 ABCD EFGH 9 11 30 +6 6 20 40 ABCD EFGH 9 26 120 +7 20 30 50 qwerty 6 50 600 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int NOT NULL AUTO_INCREMENT, + `b` int DEFAULT NULL, + `c` int DEFAULT NULL, + `h` int NOT NULL, + `i` varchar(100) DEFAULT 'ABCD EFGH', + `f` int GENERATED ALWAYS AS (length(`i`)) VIRTUAL, + `d` int GENERATED ALWAYS AS ((`b` + `c`)) VIRTUAL, + `e` int GENERATED ALWAYS AS ((`b` * `c`)) VIRTUAL, + PRIMARY KEY (`a`) +) ENGINE=InnoDB AUTO_INCREMENT=8 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=DYNAMIC +DROP TABLE t1; +############################################ +# Test instant ADD COLUMN for COMPACT format +############################################ +# +# Scenario 1: +# Create a small table, and add all kinds of new columns and verify +# +CREATE TABLE t1 (a INT NOT NULL AUTO_INCREMENT PRIMARY KEY, b INT) ROW_FORMAT=COMPACT; +INSERT INTO t1 VALUES(0, 1), (0, 2), (0, 3), (0, 4), (0, 5); +ALTER TABLE t1 ADD COLUMN c1 INT, ALGORITHM=INSTANT; +Table id did not change +count(*) = 1 +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'c1' AND has_default = 1; +name default_value +c1 NULL +INSERT INTO t1(a, c1) VALUES(0, 1); +SELECT count(*) = max(a) FROM t1 WHERE c1 IS NULL; +count(*) = max(a) +1 +SELECT c1 FROM t1 WHERE c1 = 1; +c1 +1 +ALTER TABLE t1 ADD COLUMN c2 INT NOT NULL DEFAULT 10; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'c2' AND has_default = 1; +name default_value +c2 8000000a +INSERT INTO t1(a, c2) VALUES(0, 11); +SELECT count(*) = max(a) FROM t1 WHERE c2 = 10; +count(*) = max(a) +1 +SELECT c2 FROM t1 WHERE c2 = 11; +c2 +11 +ALTER TABLE t1 ADD COLUMN d1 BIGINT, ALGORITHM=INSTANT; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'd1' AND has_default = 1; +name default_value +d1 NULL +INSERT INTO t1(a, d1) VALUES(0, 1); +SELECT count(*) = max(a) FROM t1 WHERE d1 IS NULL; +count(*) = max(a) +1 +SELECT d1 FROM t1 WHERE d1 = 1; +d1 +1 +ALTER TABLE t1 ADD COLUMN d2 BIGINT NOT NULL DEFAULT 1234567890; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'd2' AND has_default = 1; +name default_value +d2 80000000499602d2 +INSERT INTO t1(a, d2) VALUES(0, 1234); +SELECT count(*) = max(a) FROM t1 WHERE d2 = 1234567890; +count(*) = max(a) +1 +SELECT d2 FROM t1 WHERE d2 = 1234; +d2 +1234 +ALTER TABLE t1 ADD COLUMN e1 SMALLINT, ALGORITHM=INSTANT; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'e1' AND has_default = 1; +name default_value +e1 NULL +INSERT INTO t1(a, e1) VALUES(0, 1); +SELECT count(*) = max(a) FROM t1 WHERE e1 IS NULL; +count(*) = max(a) +1 +SELECT e1 FROM t1 WHERE e1 = 1; +e1 +1 +ALTER TABLE t1 ADD COLUMN e2 SMALLINT NOT NULL DEFAULT 10; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'e2' AND has_default = 1; +name default_value +e2 800a +INSERT INTO t1(a, e2) VALUES(0, 11); +SELECT count(*) = max(a) FROM t1 WHERE e2 = 10; +count(*) = max(a) +1 +SELECT e2 FROM t1 WHERE e2 = 11; +e2 +11 +ALTER TABLE t1 ADD COLUMN f1 TINYINT, ALGORITHM=INSTANT; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'f1' AND has_default = 1; +name default_value +f1 NULL +INSERT INTO t1(a, f1) VALUES(0, 1); +SELECT count(*) = max(a) FROM t1 WHERE f1 IS NULL; +count(*) = max(a) +1 +SELECT f1 FROM t1 WHERE f1 = 1; +f1 +1 +ALTER TABLE t1 ADD COLUMN f2 TINYINT NOT NULL DEFAULT 123; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'f2' AND has_default = 1; +name default_value +f2 fb +INSERT INTO t1(a, f2) VALUES(0, 12); +SELECT count(*) = max(a) FROM t1 WHERE f2 = 123; +count(*) = max(a) +1 +SELECT f2 FROM t1 WHERE f2 = 12; +f2 +12 +ALTER TABLE t1 ADD COLUMN g1 MEDIUMINT, ALGORITHM=INSTANT; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'g1' AND has_default = 1; +name default_value +g1 NULL +INSERT INTO t1(a, g1) VALUES(0, 1); +SELECT count(*) = max(a) FROM t1 WHERE g1 IS NULL; +count(*) = max(a) +1 +SELECT g1 FROM t1 WHERE g1 = 1; +g1 +1 +ALTER TABLE t1 ADD COLUMN g2 MEDIUMINT NOT NULL DEFAULT 12345; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'g2' AND has_default = 1; +name default_value +g2 803039 +INSERT INTO t1(a, g2) VALUES(0, 1234); +SELECT count(*) = max(a) FROM t1 WHERE g2 = 12345; +count(*) = max(a) +1 +SELECT g2 FROM t1 WHERE g2 = 1234; +g2 +1234 +ALTER TABLE t1 ADD COLUMN h1 FLOAT, ALGORITHM=INSTANT; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'h1' AND has_default = 1; +name default_value +h1 NULL +INSERT INTO t1(a, h1) VALUES(0, 1.0); +SELECT count(*) = max(a) FROM t1 WHERE h1 IS NULL; +count(*) = max(a) +1 +SELECT h1 FROM t1 WHERE h1 = 1; +h1 +1 +ALTER TABLE t1 ADD COLUMN h2 FLOAT NOT NULL DEFAULT 12.34; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'h2' AND has_default = 1; +name default_value +h2 a4704541 +INSERT INTO t1(a, h2) VALUES(0, 1.234); +SELECT count(*) = max(a) FROM t1 WHERE h2 = 12.34; +count(*) = max(a) +NULL +SELECT h2 FROM t1 WHERE h2 = 1.234; +h2 +ALTER TABLE t1 ADD COLUMN i1 DECIMAL(5, 2), ADD COLUMN i2 double, ALGORITHM=INSTANT; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE (name = 'i1' OR name = 'i2') AND has_default = 1; +name default_value +i1 NULL +i2 NULL +INSERT INTO t1(a, i1, i2) VALUES(0, 10.10, 20.20); +SELECT count(*) = max(a) FROM t1 WHERE i1 IS NULL; +count(*) = max(a) +1 +SELECT count(*) = max(a) FROM t1 WHERE i2 IS NULL; +count(*) = max(a) +1 +SELECT i1 FROM t1 WHERE i1 = 10.10; +i1 +10.10 +SELECT i2 FROM t1 WHERE i2 = 20.20; +i2 +20.2 +ALTER TABLE t1 ADD COLUMN j1 DECIMAL(5, 2) NOT NULL DEFAULT 100.00, ADD COLUMN j2 double NOT NULL DEFAULT 1000.5678; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE (name = 'j1' OR name = 'j2') AND has_default = 1; +name default_value +j1 806400 +j2 5af5b9da8a448f40 +INSERT INTO t1(a, j1, j2) VALUES(0, 90.90, 1000.1234); +SELECT count(*) = max(a) FROM t1 WHERE j1 = 100.00; +count(*) = max(a) +1 +SELECT count(*) = max(a) FROM t1 WHERE j2 = 1000.5678; +count(*) = max(a) +1 +SELECT j1 FROM t1 WHERE j1 = 90.90; +j1 +90.90 +SELECT j2 FROM t1 WHERE j2 = 1000.1234; +j2 +1000.1234 +ALTER TABLE t1 ADD COLUMN k1 BIT(8), ALGORITHM=INSTANT; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'k1' AND has_default = 1; +name default_value +k1 NULL +INSERT INTO t1(a, k1) VALUES(0, b'010101'); +SELECT count(*) = max(a) FROM t1 WHERE k1 IS NULL; +count(*) = max(a) +1 +SELECT hex(k1) FROM t1 WHERE k1 = b'010101'; +hex(k1) +15 +ALTER TABLE t1 ADD COLUMN k2 BIT(8) NOT NULL DEFAULT b'101010'; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'k2' AND has_default = 1; +name default_value +k2 2a +INSERT INTO t1(a, k2) VALUES(0, b'110011'); +SELECT count(*) = max(a) FROM t1 WHERE k2 = b'101010'; +count(*) = max(a) +1 +SELECT hex(k2) FROM t1 WHERE k2 = b'110011'; +hex(k2) +33 +ALTER TABLE t1 ADD COLUMN l1 CHAR(50), ADD COLUMN l2 VARCHAR(100), ALGORITHM=DEFAULT; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE (name = 'l1' OR name = 'l2') AND has_default = 1; +name default_value +l1 NULL +l2 NULL +INSERT INTO t1(a, l1, l2) VALUES(0, 'ABCD EFGH', 'abcdefg hijklmn '); +SELECT count(*) = max(a) FROM t1 WHERE l2 IS NULL; +count(*) = max(a) +1 +SELECT count(*) = max(a) FROM t1 WHERE l1 IS NULL; +count(*) = max(a) +1 +SELECT l1 FROM t1 WHERE l1 = 'ABCD EFGH'; +l1 +ABCD EFGH +SELECT l2 FROM t1 WHERE l2 = 'abcdefg hijklmn '; +l2 +abcdefg hijklmn +ALTER TABLE t1 ADD COLUMN m1 CHAR(50) default 'The fox jumps over', ADD COLUMN m2 VARCHAR(50) DEFAULT 'The fox jumps over the lazy dog.'; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE (name = 'm1' OR name = 'm2') AND has_default = 1; +name default_value +m1 54686520666f78206a756d7073206f7665722020202020202020202020202020202020202020202020202020202020202020 +m2 54686520666f78206a756d7073206f76657220746865206c617a7920646f672e +INSERT INTO t1(a, m1, m2) VALUES(0, 'over the lazy dog', 'The lazy dog jumps over the fox.'); +SELECT count(*) = max(a) FROM t1 WHERE m1 = 'The fox jumps over'; +count(*) = max(a) +1 +SELECT count(*) = max(a) FROM t1 WHERE m2 like 'The fox jumps%'; +count(*) = max(a) +1 +SELECT m1 FROM t1 WHERE m1 = 'over the lazy dog'; +m1 +over the lazy dog +SELECT m2 FROM t1 WHERE m2 like '%the fox.'; +m2 +The lazy dog jumps over the fox. +ALTER TABLE t1 ADD COLUMN n1 BINARY(10), ADD COLUMN n2 VARBINARY(10), ALGORITHM=DEFAULT; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE (name = 'n1' OR name = 'n2') AND has_default = 1; +name default_value +n1 NULL +n2 NULL +INSERT INTO t1(a, n1, n2) VALUES(0, 0x010203040506070809, 0x102030405060708090); +SELECT count(*) = max(a) FROM t1 WHERE n1 IS NULL; +count(*) = max(a) +1 +SELECT count(*) = max(a) FROM t1 WHERE n2 IS NULL; +count(*) = max(a) +1 +SELECT hex(n1) FROM t1 WHERE n1 = 0x01020304050607080900; +hex(n1) +01020304050607080900 +SELECT hex(n2) FROM t1 WHERE n2 = 0x102030405060708090; +hex(n2) +102030405060708090 +ALTER TABLE t1 ADD COLUMN o1 BINARY(10) DEFAULT 0x11223344, ADD COLUMN o2 VARBINARY(10) DEFAULT 0x55667788; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE (name = 'o1' OR name = 'o2') AND has_default = 1; +name default_value +o1 11223344000000000000 +o2 55667788 +INSERT INTO t1(a, o1, o2) VALUES(0, 0x44332211, 0x88776655); +SELECT count(*) = max(a) FROM t1 WHERE o1 = 0x11223344000000000000; +count(*) = max(a) +1 +SELECT count(*) = max(a) FROM t1 WHERE o2 = 0x55667788; +count(*) = max(a) +1 +SELECT hex(o1) FROM t1 WHERE o1 = 0x44332211000000000000; +hex(o1) +44332211000000000000 +SELECT hex(o2) FROM t1 WHERE o2 = 0x88776655; +hex(o2) +88776655 +ALTER TABLE t1 ADD COLUMN p1 DATETIME, ALGORITHM=DEFAULT; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'p1' AND has_default = 1; +name default_value +p1 NULL +INSERT INTO t1(a, p1) VALUES(0, '2017-12-31 00:00:00'); +SELECT count(*) = max(a) FROM t1 WHERE p1 IS NULL; +count(*) = max(a) +1 +SELECT p1 FROM t1 WHERE p1 = '2017-12-31 00:00:00'; +p1 +2017-12-31 00:00:00 +ALTER TABLE t1 ADD COLUMN p2 DATETIME NOT NULL DEFAULT '2017-12-31 01:02:03'; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'p2' AND has_default = 1; +name default_value +p2 999e7e1083 +SELECT count(*) = max(a) FROM t1 GROUP BY p2; +count(*) = max(a) +1 +INSERT INTO t1(a, p2) VALUES(0, now()); +SELECT count(*) FROM t1 GROUP BY p2; +count(*) +26 +1 +ALTER TABLE t1 ADD COLUMN q1 ENUM ('value1','value2','value3'), ALGORITHM=INSTANT; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'q1' AND has_default = 1; +name default_value +q1 NULL +INSERT INTO t1(a, q1) VALUES(0, 1); +SELECT count(*) = max(a) FROM t1 WHERE q1 IS NULL; +count(*) = max(a) +1 +SELECT q1 FROM t1 WHERE q1 = 1; +q1 +value1 +ALTER TABLE t1 ADD COLUMN r1 SET ('a','b','c'), ALGORITHM=INSTANT; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'r1' AND has_default = 1; +name default_value +r1 NULL +INSERT INTO t1(a, r1) VALUES(0, 'a'); +SELECT count(*) = max(a) FROM t1 WHERE r1 IS NULL; +count(*) = max(a) +1 +SELECT r1 FROM t1 WHERE r1 = 'a'; +r1 +a +ALTER TABLE t1 ADD COLUMN s1 BLOB, ADD COLUMN s2 TEXT, ALGORITHM=INSTANT; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE (name = 's1' OR name = 's2') AND has_default = 1; +name default_value +s1 NULL +s2 NULL +INSERT INTO t1(a, s1, s2) VALUES(0, 0x0102030405, 'abcd qwerty'); +SELECT count(*) = max(a) FROM t1 WHERE s1 IS NULL; +count(*) = max(a) +1 +SELECT count(*) = max(a) FROM t1 WHERE s2 IS NULL; +count(*) = max(a) +1 +SELECT hex(s1) FROM t1 WHERE s1 = 0x0102030405; +hex(s1) +0102030405 +SELECT s2 FROM t1 WHERE s2 = 'abcd qwerty'; +s2 +abcd qwerty +ALTER TABLE t1 ADD COLUMN u1 BLOB NOT NULL, ADD COLUMN u2 TEXT NOT NULL; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE (name = 'u1' OR name = 'u2') AND has_default = 1; +name default_value +u1 +u2 +INSERT INTO t1(a, u1, u2) VALUES(0, 0x0102030405, 'abcd qwerty'); +SELECT count(*) = max(a) FROM t1 WHERE u1 = ''; +count(*) = max(a) +1 +SELECT count(*) = max(a) FROM t1 WHERE u2 = ''; +count(*) = max(a) +1 +SELECT hex(u1) FROM t1 WHERE u1 = 0x0102030405; +hex(u1) +0102030405 +SELECT u2 FROM t1 WHERE u2 = 'abcd qwerty'; +u2 +abcd qwerty +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int NOT NULL AUTO_INCREMENT, + `b` int DEFAULT NULL, + `c1` int DEFAULT NULL, + `c2` int NOT NULL DEFAULT '10', + `d1` bigint DEFAULT NULL, + `d2` bigint NOT NULL DEFAULT '1234567890', + `e1` smallint DEFAULT NULL, + `e2` smallint NOT NULL DEFAULT '10', + `f1` tinyint DEFAULT NULL, + `f2` tinyint NOT NULL DEFAULT '123', + `g1` mediumint DEFAULT NULL, + `g2` mediumint NOT NULL DEFAULT '12345', + `h1` float DEFAULT NULL, + `h2` float NOT NULL DEFAULT '12.34', + `i1` decimal(5,2) DEFAULT NULL, + `i2` double DEFAULT NULL, + `j1` decimal(5,2) NOT NULL DEFAULT '100.00', + `j2` double NOT NULL DEFAULT '1000.5678', + `k1` bit(8) DEFAULT NULL, + `k2` bit(8) NOT NULL DEFAULT b'101010', + `l1` char(50) DEFAULT NULL, + `l2` varchar(100) DEFAULT NULL, + `m1` char(50) DEFAULT 'The fox jumps over', + `m2` varchar(50) DEFAULT 'The fox jumps over the lazy dog.', + `n1` binary(10) DEFAULT NULL, + `n2` varbinary(10) DEFAULT NULL, + `o1` binary(10) DEFAULT '"3D\0\0\0\0\0\0', + `o2` varbinary(10) DEFAULT 'Ufw?', + `p1` datetime DEFAULT NULL, + `p2` datetime NOT NULL DEFAULT '2017-12-31 01:02:03', + `q1` enum('value1','value2','value3') DEFAULT NULL, + `r1` set('a','b','c') DEFAULT NULL, + `s1` blob, + `s2` text, + `u1` blob NOT NULL, + `u2` text NOT NULL, + PRIMARY KEY (`a`) +) ENGINE=InnoDB AUTO_INCREMENT=32 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=COMPACT +DROP TABLE t1; +# +# Scenario 2: +# Create a small table, add some columns instantly, along with +# virtual columns +# +CREATE TABLE t1 (a INT NOT NULL AUTO_INCREMENT PRIMARY KEY, b INT) ROW_FORMAT=COMPACT; +INSERT INTO t1 VALUES(0, 1), (0, 2), (0, 3), (0, 4), (0, 5); +ALTER TABLE t1 ADD COLUMN c INT NOT NULL, ADD COLUMN d INT GENERATED ALWAYS AS ((b * 2)) VIRTUAL; +Table id did not change +count(*) = 1 +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +INSERT INTO t1(a, b, c) VALUES(0, 6, 20); +SELECT * FROM t1; +a b c d +1 1 0 2 +2 2 0 4 +3 3 0 6 +4 4 0 8 +5 5 0 10 +6 6 20 12 +ALTER TABLE t1 ADD COLUMN e VARCHAR(100) DEFAULT 'ABCD EFGH', ADD COLUMN f INT GENERATED ALWAYS AS (LENGTH(e)); +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +INSERT INTO t1(a, c, e) VALUES(0, 20, 'Hello'), (0, 20, 'World'), (0, 20, 'Hello World'); +SELECT * FROM t1; +a b c d e f +1 1 0 2 ABCD EFGH 9 +2 2 0 4 ABCD EFGH 9 +3 3 0 6 ABCD EFGH 9 +4 4 0 8 ABCD EFGH 9 +5 5 0 10 ABCD EFGH 9 +6 6 20 12 ABCD EFGH 9 +7 NULL 20 NULL Hello 5 +8 NULL 20 NULL World 5 +9 NULL 20 NULL Hello World 11 +ALTER TABLE t1 ADD COLUMN g VARCHAR(100) GENERATED ALWAYS AS (e), ADD COLUMN h BIGINT DEFAULT 10000, ADD COLUMN i BIGINT GENERATED ALWAYS AS (h * 2 + b); +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT * FROM t1; +a b c d e f g h i +1 1 0 2 ABCD EFGH 9 ABCD EFGH 10000 20001 +2 2 0 4 ABCD EFGH 9 ABCD EFGH 10000 20002 +3 3 0 6 ABCD EFGH 9 ABCD EFGH 10000 20003 +4 4 0 8 ABCD EFGH 9 ABCD EFGH 10000 20004 +5 5 0 10 ABCD EFGH 9 ABCD EFGH 10000 20005 +6 6 20 12 ABCD EFGH 9 ABCD EFGH 10000 20006 +7 NULL 20 NULL Hello 5 Hello 10000 NULL +8 NULL 20 NULL World 5 World 10000 NULL +9 NULL 20 NULL Hello World 11 Hello World 10000 NULL +INSERT INTO t1(a, b, c, h) VALUES(0, 7, 40, 2000), (0, 7, 40, 20000); +SELECT * FROM t1; +a b c d e f g h i +1 1 0 2 ABCD EFGH 9 ABCD EFGH 10000 20001 +2 2 0 4 ABCD EFGH 9 ABCD EFGH 10000 20002 +3 3 0 6 ABCD EFGH 9 ABCD EFGH 10000 20003 +4 4 0 8 ABCD EFGH 9 ABCD EFGH 10000 20004 +5 5 0 10 ABCD EFGH 9 ABCD EFGH 10000 20005 +6 6 20 12 ABCD EFGH 9 ABCD EFGH 10000 20006 +7 NULL 20 NULL Hello 5 Hello 10000 NULL +8 NULL 20 NULL World 5 World 10000 NULL +9 NULL 20 NULL Hello World 11 Hello World 10000 NULL +10 7 40 14 ABCD EFGH 9 ABCD EFGH 2000 4007 +11 7 40 14 ABCD EFGH 9 ABCD EFGH 20000 40007 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int NOT NULL AUTO_INCREMENT, + `b` int DEFAULT NULL, + `c` int NOT NULL, + `d` int GENERATED ALWAYS AS ((`b` * 2)) VIRTUAL, + `e` varchar(100) DEFAULT 'ABCD EFGH', + `f` int GENERATED ALWAYS AS (length(`e`)) VIRTUAL, + `g` varchar(100) GENERATED ALWAYS AS (`e`) VIRTUAL, + `h` bigint DEFAULT '10000', + `i` bigint GENERATED ALWAYS AS (((`h` * 2) + `b`)) VIRTUAL, + PRIMARY KEY (`a`) +) ENGINE=InnoDB AUTO_INCREMENT=12 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=COMPACT +DROP TABLE t1; +# +# Scenario 3: +# Create a small table, add some columns instantly, then change +# their default values, check original default values are correct +# +CREATE TABLE t1 (a INT NOT NULL AUTO_INCREMENT PRIMARY KEY, b INT) ROW_FORMAT=COMPACT; +INSERT INTO t1 VALUES(0, 1), (0, 2), (0, 3), (0, 4), (0, 5); +ALTER TABLE t1 ADD COLUMN c INT NOT NULL DEFAULT 100, ADD COLUMN d INT GENERATED ALWAYS AS ((c * 2 + b)) VIRTUAL, ADD COLUMN e VARCHAR(100) DEFAULT 'Hello world'; +Table id did not change +count(*) = 2 +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT * FROM t1; +a b c d e +1 1 100 201 Hello world +2 2 100 202 Hello world +3 3 100 203 Hello world +4 4 100 204 Hello world +5 5 100 205 Hello world +INSERT INTO t1(a, b, c, e) VALUES(0, 6, 200, 'Good day'), (0, 7, 300, 'Good DAY'); +SELECT * FROM t1; +a b c d e +1 1 100 201 Hello world +2 2 100 202 Hello world +3 3 100 203 Hello world +4 4 100 204 Hello world +5 5 100 205 Hello world +6 6 200 406 Good day +7 7 300 607 Good DAY +SELECT default_value FROM information_schema.innodb_columns WHERE name = 'c' AND has_default = 1; +default_value +80000064 +ALTER TABLE t1 ALTER COLUMN c SET DEFAULT 500; +SELECT default_value FROM information_schema.innodb_columns WHERE name = 'c' AND +has_default = 1; +default_value +80000064 +SELECT * FROM t1; +a b c d e +1 1 100 201 Hello world +2 2 100 202 Hello world +3 3 100 203 Hello world +4 4 100 204 Hello world +5 5 100 205 Hello world +6 6 200 406 Good day +7 7 300 607 Good DAY +INSERT INTO t1(a, b) VALUES(0, 8), (0, 9); +SELECT * FROM t1; +a b c d e +1 1 100 201 Hello world +2 2 100 202 Hello world +3 3 100 203 Hello world +4 4 100 204 Hello world +5 5 100 205 Hello world +6 6 200 406 Good day +7 7 300 607 Good DAY +8 8 500 1008 Hello world +9 9 500 1009 Hello world +SELECT default_value FROM information_schema.innodb_columns WHERE name = 'e' AND has_default = 1; +default_value +48656c6c6f20776f726c64 +ALTER TABLE t1 ALTER COLUMN e SET DEFAULT 'HELLO MySQL!'; +SELECT default_value FROM information_schema.innodb_columns WHERE name = 'e' AND has_default = 1; +default_value +48656c6c6f20776f726c64 +SELECT * FROM t1; +a b c d e +1 1 100 201 Hello world +2 2 100 202 Hello world +3 3 100 203 Hello world +4 4 100 204 Hello world +5 5 100 205 Hello world +6 6 200 406 Good day +7 7 300 607 Good DAY +8 8 500 1008 Hello world +9 9 500 1009 Hello world +INSERT INTO t1(a, b) VALUES(0, 10), (0, 20); +SELECT * FROM t1; +a b c d e +1 1 100 201 Hello world +2 2 100 202 Hello world +3 3 100 203 Hello world +4 4 100 204 Hello world +5 5 100 205 Hello world +6 6 200 406 Good day +7 7 300 607 Good DAY +8 8 500 1008 Hello world +9 9 500 1009 Hello world +10 10 500 1010 HELLO MySQL! +11 20 500 1020 HELLO MySQL! +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int NOT NULL AUTO_INCREMENT, + `b` int DEFAULT NULL, + `c` int NOT NULL DEFAULT '500', + `d` int GENERATED ALWAYS AS (((`c` * 2) + `b`)) VIRTUAL, + `e` varchar(100) DEFAULT 'HELLO MySQL!', + PRIMARY KEY (`a`) +) ENGINE=InnoDB AUTO_INCREMENT=12 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=COMPACT +DROP TABLE t1; +# +# Scenario 4: +# Create a small table, add some columns instantly, then do DML +# on the table +# +CREATE TABLE t1 (a INT NOT NULL AUTO_INCREMENT PRIMARY KEY, b INT) ROW_FORMAT=COMPACT; +INSERT INTO t1 VALUES(0, 1), (0, 2), (0, 3), (0, 4), (0, 5); +ALTER TABLE t1 ADD COLUMN c INT NOT NULL DEFAULT 100, ADD COLUMN d INT GENERATED ALWAYS AS ((c * 2 + b)) VIRTUAL, ADD COLUMN e VARCHAR(100) DEFAULT 'Hello world'; +Table id did not change +count(*) = 2 +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +UPDATE t1 SET c = 200 WHERE a > 3; +SELECT distinct(c) FROM t1; +c +100 +200 +INSERT INTO t1(b, c, e) SELECT b, c, e FROM t1; +INSERT INTO t1(b, c, e) SELECT b, c, e FROM t1; +INSERT INTO t1(b, c, e) SELECT b, c, e FROM t1; +DELETE FROM t1 WHERE c = 100; +UPDATE t1 SET c = 300; +SELECT distinct(c) FROM t1; +c +300 +SELECT count(*) FROM t1; +count(*) +16 +ALTER TABLE t1 ADD COLUMN t DATETIME DEFAULT CURRENT_TIMESTAMP; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +UPDATE t1 SET e = 'Hello MySQL' WHERE a > 10; +UPDATE t1 SET e = 'Hello MySQL!!' WHERE a > 20; +SELECT distinct(e) FROM t1; +e +Hello world +Hello MySQL +Hello MySQL!! +UPDATE t1 SET c = 500 WHERE e LIKE '%world%'; +SELECT c, e FROM t1 GROUP BY c, e; +c e +300 Hello MySQL +300 Hello MySQL!! +500 Hello world +INSERT INTO t1(b, c, e) SELECT b, c, e FROM t1; +UPDATE t1 SET t = CURRENT_TIMESTAMP WHERE a < 50; +SELECT count(t) FROM t1 GROUP BY t; +count(t) +16 +16 +DELETE FROM t1 WHERE a < 50; +SELECT count(t) FROM t1 GROUP BY t; +count(t) +16 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int NOT NULL AUTO_INCREMENT, + `b` int DEFAULT NULL, + `c` int NOT NULL DEFAULT '100', + `d` int GENERATED ALWAYS AS (((`c` * 2) + `b`)) VIRTUAL, + `e` varchar(100) DEFAULT 'Hello world', + `t` datetime DEFAULT CURRENT_TIMESTAMP, + PRIMARY KEY (`a`) +) ENGINE=InnoDB AUTO_INCREMENT=90 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=COMPACT +DROP TABLE t1; +# +# Scenario 5: +# Create a small table, add some columns instantly, then do DDL +# to build indexes +# +CREATE TABLE t1 (a INT NOT NULL AUTO_INCREMENT PRIMARY KEY, b INT) ROW_FORMAT=COMPACT; +INSERT INTO t1 VALUES(0, 1), (0, 2), (0, 3), (0, 4), (0, 5); +ALTER TABLE t1 ADD COLUMN c INT NOT NULL DEFAULT 100, ADD COLUMN d INT GENERATED ALWAYS AS ((c * 2 + b)) VIRTUAL, ADD COLUMN e VARCHAR(100) DEFAULT 'Hello world'; +Table id did not change +count(*) = 2 +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +ALTER TABLE t1 ADD KEY(c); +EXPLAIN SELECT c FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL # NULL # 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL c # NULL # 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c` AS `c` from `test`.`t1` +SELECT c FROM t1 WHERE c != 100; +c +INSERT INTO t1(b, c, e) SELECT b, c, e FROM t1; +INSERT INTO t1(b, c, e) SELECT b, c, e FROM t1; +INSERT INTO t1(b, c, e) SELECT b, c, e FROM t1; +UPDATE t1 SET e = 'Hello MySQL' WHERE a > 30; +ALTER TABLE t1 ADD KEY(e); +EXPLAIN SELECT e FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL # NULL # 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL e # NULL # 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`e` AS `e` from `test`.`t1` +SELECT count(e) FROM t1 WHERE e LIKE '%MySQL%'; +count(e) +17 +SELECT count(e) FROM t1 WHERE e LIKE '%world%'; +count(e) +23 +ALTER TABLE t1 DROP PRIMARY KEY, ADD PRIMARY KEY(a, c); +SELECT a, c, e FROM t1 WHERE a > 25 AND a < 40; +a c e +28 100 Hello world +29 100 Hello world +30 100 Hello world +31 100 Hello MySQL +32 100 Hello MySQL +33 100 Hello MySQL +34 100 Hello MySQL +35 100 Hello MySQL +36 100 Hello MySQL +37 100 Hello MySQL +38 100 Hello MySQL +39 100 Hello MySQL +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int NOT NULL AUTO_INCREMENT, + `b` int DEFAULT NULL, + `c` int NOT NULL DEFAULT '100', + `d` int GENERATED ALWAYS AS (((`c` * 2) + `b`)) VIRTUAL, + `e` varchar(100) DEFAULT 'Hello world', + PRIMARY KEY (`a`,`c`), + KEY `c` (`c`), + KEY `e` (`e`) +) ENGINE=InnoDB AUTO_INCREMENT=59 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=COMPACT +DROP TABLE t1; +# +# Scenario 6: +# Create a small table, add some columns instantly, then do DML +# on the table, and some simple rollback +# +CREATE TABLE t1 (a INT NOT NULL AUTO_INCREMENT PRIMARY KEY, b INT) ROW_FORMAT=COMPACT; +INSERT INTO t1 VALUES(0, 1), (0, 2), (0, 3), (0, 4), (0, 5); +ALTER TABLE t1 ADD COLUMN c INT NOT NULL DEFAULT 100, ADD COLUMN d INT GENERATED ALWAYS AS ((c * 2 + b)) VIRTUAL, ADD COLUMN e VARCHAR(100) DEFAULT 'Hello world'; +Table id did not change +count(*) = 2 +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +START TRANSACTION; +INSERT INTO t1(a, b) VALUES(0, 6); +SELECT * FROM t1; +a b c d e +1 1 100 201 Hello world +2 2 100 202 Hello world +3 3 100 203 Hello world +4 4 100 204 Hello world +5 5 100 205 Hello world +6 6 100 206 Hello world +ROLLBACK; +SELECT * FROM t1; +a b c d e +1 1 100 201 Hello world +2 2 100 202 Hello world +3 3 100 203 Hello world +4 4 100 204 Hello world +5 5 100 205 Hello world +START TRANSACTION; +UPDATE t1 SET c = 500 WHERE a = 1; +UPDATE t1 SET b = 1000 WHERE a = 2; +SELECT a, b, c FROM t1 WHERE a = 1 OR a = 2; +a b c +1 1 500 +2 1000 100 +ROLLBACK; +SELECT a, b, c FROM t1; +a b c +1 1 100 +2 2 100 +3 3 100 +4 4 100 +5 5 100 +START TRANSACTION; +DELETE FROM t1 WHERE a < 5; +INSERT INTO t1(a, b) VALUES(0, 6); +SELECT * FROM t1; +a b c d e +5 5 100 205 Hello world +7 6 100 206 Hello world +ROLLBACK; +SELECT * FROM t1; +a b c d e +1 1 100 201 Hello world +2 2 100 202 Hello world +3 3 100 203 Hello world +4 4 100 204 Hello world +5 5 100 205 Hello world +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int NOT NULL AUTO_INCREMENT, + `b` int DEFAULT NULL, + `c` int NOT NULL DEFAULT '100', + `d` int GENERATED ALWAYS AS (((`c` * 2) + `b`)) VIRTUAL, + `e` varchar(100) DEFAULT 'Hello world', + PRIMARY KEY (`a`) +) ENGINE=InnoDB AUTO_INCREMENT=8 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=COMPACT +DROP TABLE t1; +CREATE TABLE t1(id INT PRIMARY KEY, c1 VARCHAR(4000), c2 VARCHAR(4000), c3 VARCHAR(1000)) ROW_FORMAT=COMPACT; +INSERT INTO t1 VALUES(1, repeat('a', 4000), repeat('b', 4000), repeat('c', 1)); +SELECT id, length(c1), length(c2), length(c3) FROM t1; +id length(c1) length(c2) length(c3) +1 4000 4000 1 +ALTER TABLE t1 ADD COLUMN c4 VARCHAR(500) NOT NULL DEFAULT 'dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd'; +Table id did not change +count(*) = 1 +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT id, length(c1), length(c2), length(c3), length(c4) FROM t1; +id length(c1) length(c2) length(c3) length(c4) +1 4000 4000 1 500 +START TRANSACTION; +UPDATE t1 SET c1 = repeat('x', 200) WHERE id = 1; +ROLLBACK; +SELECT id, length(c1), length(c2), length(c3), length(c4) FROM t1; +id length(c1) length(c2) length(c3) length(c4) +1 4000 4000 1 500 +START TRANSACTION; +UPDATE t1 SET c4 = 'x' WHERE id = 1; +ROLLBACK; +SELECT id, length(c1), length(c2), length(c3), length(c4) FROM t1; +id length(c1) length(c2) length(c3) length(c4) +1 4000 4000 1 500 +DROP TABLE t1; +# +# Scenario 7: +# Confirm some ADD COLUMN are instant, some are not +# +CREATE TABLE t1 (a INT NOT NULL AUTO_INCREMENT PRIMARY KEY, b INT) ROW_FORMAT=COMPACT; +INSERT INTO t1 VALUES(0, 1), (0, 2), (0, 3), (0, 4), (0, 5); +ALTER TABLE t1 ADD COLUMN c INT NOT NULL DEFAULT 100 AFTER b; +Table id did not change +count(*) = 1 +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +ALTER TABLE t1 ADD COLUMN d INT NOT NULL DEFAULT 100 AFTER b; +Table ID differed +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +0 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT count(*) AS `Expect 0` FROM information_schema.innodb_columns WHERE has_default = 1; +Expect 0 +0 +ALTER TABLE t1 ADD COLUMN e INT NOT NULL DEFAULT 100, ADD KEY(e); +Table ID differed +count(*) = 1 +0 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT count(*) AS `Expect 0` FROM information_schema.innodb_columns WHERE has_default = 1; +Expect 0 +0 +ALTER TABLE t1 ADD COLUMN f INT NOT NULL DEFAULT 100, FORCE; +Table ID differed +count(*) = 1 +0 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT count(*) AS `Expect 0` FROM information_schema.innodb_columns WHERE has_default = 1; +Expect 0 +0 +ALTER TABLE t1 ADD COLUMN g INT NOT NULL DEFAULT 100, ALGORITHM=INPLACE; +Table ID differed +count(*) = 1 +0 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT count(*) AS `Expect 0` FROM information_schema.innodb_columns WHERE has_default = 1; +Expect 0 +0 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int NOT NULL AUTO_INCREMENT, + `b` int DEFAULT NULL, + `d` int NOT NULL DEFAULT '100', + `c` int NOT NULL DEFAULT '100', + `e` int NOT NULL DEFAULT '100', + `f` int NOT NULL DEFAULT '100', + `g` int NOT NULL DEFAULT '100', + PRIMARY KEY (`a`), + KEY `e` (`e`) +) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=COMPACT +DROP TABLE t1; +CREATE TABLE t1 (a INT NOT NULL AUTO_INCREMENT PRIMARY KEY, b INT, c TEXT, FULLTEXT(c)) ROW_FORMAT=COMPACT; +INSERT INTO t1 VALUES(0, 1, 'Hello'), (0, 2, 'HELLO'), (0, 3, 'World'), (0, 4, 'Hello world'), (0, 5, 'HELLO WORLD'); +ALTER TABLE t1 ADD COLUMN d INT NOT NULL DEFAULT 100 AFTER b; +Table ID differed +count(*) = 1 +0 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +DROP TABLE t1; +# +# Scenario 8: +# Check FK constraints on instantly added columns +# +CREATE TABLE t1 (a INT NOT NULL AUTO_INCREMENT PRIMARY KEY, b INT) ROW_FORMAT=COMPACT; +CREATE TABLE t2(a INT NOT NULL PRIMARY KEY, b INT, c INT, KEY(c)); +INSERT INTO t1 VALUES(0, 1), (0, 2), (0, 3), (0, 4), (0, 5); +INSERT INTO t2 VALUES(1, 2, 3), (2, 3, 4), (3, 4, 5); +ALTER TABLE t1 ADD COLUMN c INT NOT NULL DEFAULT 3; +Table id did not change +count(*) = 1 +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +UPDATE t1 SET c = 4 WHERE a = 2; +UPDATE t1 SET c = 5 WHERE a = 3; +ALTER TABLE t1 ADD KEY(c); +ALTER TABLE t2 ADD FOREIGN KEY (c) REFERENCES t1(c) ON UPDATE CASCADE, ALGORITHM = COPY; +UPDATE t1 SET c = 10 WHERE a = 1; +SELECT c FROM t2; +c +10 +4 +5 +UPDATE t1 SET c = 10; +SELECT c FROM t2; +c +10 +10 +10 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int NOT NULL AUTO_INCREMENT, + `b` int DEFAULT NULL, + `c` int NOT NULL DEFAULT '3', + PRIMARY KEY (`a`), + KEY `c` (`c`) +) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=COMPACT +DROP TABLE t2; +DROP TABLE t1; +# +# Scenario 9: +# Instant ADD COLUMN on partitioned table, only simple test here +# +CREATE TABLE t1 (a INT NOT NULL AUTO_INCREMENT PRIMARY KEY, b INT) ROW_FORMAT=COMPACT PARTITION BY HASH(a) PARTITIONS 3;; +INSERT INTO t1 VALUES(0, 1), (0, 2), (0, 3), (0, 4), (0, 5), (0, 6), (0, 7), (0, 8); +ALTER TABLE t1 ADD COLUMN c INT NOT NULL DEFAULT 5; +Table id did not change +count(*) = 1 +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT * FROM t1; +a b c +3 3 5 +6 6 5 +1 1 5 +4 4 5 +7 7 5 +2 2 5 +5 5 5 +8 8 5 +INSERT INTO t1 VALUES(0, 9, 10), (0, 10, 20); +SELECT * FROM t1 WHERE b > 8; +a b c +9 9 10 +10 10 20 +UPDATE t1 SET c = 8 WHERE a = 1 OR a = 3 OR a = 5 OR a = 7; +SELECT * FROM t1; +a b c +3 3 8 +6 6 5 +9 9 10 +1 1 8 +4 4 5 +7 7 8 +10 10 20 +2 2 5 +5 5 8 +8 8 5 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int NOT NULL AUTO_INCREMENT, + `b` int DEFAULT NULL, + `c` int NOT NULL DEFAULT '5', + PRIMARY KEY (`a`) +) ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=COMPACT +/*!50100 PARTITION BY HASH (`a`) +PARTITIONS 3 */ +DROP TABLE t1; +CREATE TABLE t1 (a INT, b INT) ROW_FORMAT=COMPACT PARTITION BY HASH(a) PARTITIONS 2;; +ALTER TABLE t1 ADD COLUMN c INT NOT NULL DEFAULT 5; +Table id did not change +count(*) = 1 +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +ALTER TABLE t1 CHANGE COLUMN c c1 INT; +ALTER TABLE t1 ADD COLUMN c INT NOT NULL DEFAULT 5; +Table id did not change +count(*) = 1 +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +DROP TABLE t1; +# +# Scenario 10: +# EXCHANGE PARTITION is not allowed if either is instant +# +CREATE TABLE t1 (a INT NOT NULL AUTO_INCREMENT PRIMARY KEY, b INT) ROW_FORMAT=COMPACT;; +INSERT INTO t1 VALUES(0, 1), (0, 2), (0, 3), (0, 4), (0, 5), (0, 6), (0, 7), (0, 8); +ALTER TABLE t1 ADD COLUMN c INT NOT NULL DEFAULT 5; +Table id did not change +count(*) = 1 +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +CREATE TABLE t2 (a INT NOT NULL AUTO_INCREMENT PRIMARY KEY, b INT, c INT NOT NULL DEFAULT 5) ROW_FORMAT=COMPACT PARTITION BY RANGE (a) (PARTITION p1 VALUES LESS THAN (10), PARTITION p2 VALUES LESS THAN (20), PARTITION p3 VALUES LESS THAN (30));; +ALTER TABLE t2 EXCHANGE PARTITION p1 WITH TABLE t1; +ERROR HY000: Non matching attribute 'INSTANT COLUMN(s)' between partition and table +ALTER TABLE t2 ADD COLUMN d INT; +ALTER TABLE t1 ADD COLUMN d INT, ALGORITHM=INPLACE; +ALTER TABLE t2 EXCHANGE PARTITION p1 WITH TABLE t1; +ERROR HY000: Non matching attribute 'INSTANT COLUMN(s)' between partition and table +OPTIMIZE TABLE t2; +Table Op Msg_type Msg_text +test.t2 optimize note Table does not support optimize, doing recreate + analyze instead +test.t2 optimize status OK +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int NOT NULL AUTO_INCREMENT, + `b` int DEFAULT NULL, + `c` int NOT NULL DEFAULT '5', + `d` int DEFAULT NULL, + PRIMARY KEY (`a`) +) ENGINE=InnoDB AUTO_INCREMENT=9 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=COMPACT +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `a` int NOT NULL AUTO_INCREMENT, + `b` int DEFAULT NULL, + `c` int NOT NULL DEFAULT '5', + `d` int DEFAULT NULL, + PRIMARY KEY (`a`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=COMPACT +/*!50100 PARTITION BY RANGE (`a`) +(PARTITION p1 VALUES LESS THAN (10) ENGINE = InnoDB, + PARTITION p2 VALUES LESS THAN (20) ENGINE = InnoDB, + PARTITION p3 VALUES LESS THAN (30) ENGINE = InnoDB) */ +ALTER TABLE t2 EXCHANGE PARTITION p1 WITH TABLE t1; +DROP TABLE t1, t2; +# +# Scenario 11: +# PRIMARY KEY with more than one column, at least to verify it works with REDUDANT +# +CREATE TABLE t1 (a INT NOT NULL, b INT NOT NULL, PRIMARY KEY(a, b)) ROW_FORMAT=COMPACT;; +INSERT INTO t1 VALUES(0, 1), (1, 2), (2, 3), (3, 4); +ALTER TABLE t1 ADD COLUMN c INT NOT NULL DEFAULT 5; +Table id did not change +count(*) = 1 +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT * FROM t1; +a b c +0 1 5 +1 2 5 +2 3 5 +3 4 5 +UPDATE t1 SET c = b WHERE b <= 2; +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT * FROM t1; +a b c +0 1 1 +1 2 2 +2 3 5 +3 4 5 +DROP TABLE t1; +# +# Scenario 12: +# Mix ALTER PARTITION and ALTER TABLE ... INPLACE. This is to check if first partition is not +# instant after ALTER PARTITION, will the metadata be copied correctly +# +CREATE TABLE t1 (col1 INT, col2 INT, col3 INT, col4 TEXT) ENGINE = InnoDB PARTITION BY RANGE(col1 * 2) ( PARTITION p0 VALUES LESS THAN (128), PARTITION p1 VALUES LESS THAN (256) , PARTITION p2 VALUES LESS THAN (384) , PARTITION p3 VALUES LESS THAN MAXVALUE);; +INSERT INTO t1 VALUES(1, 2, 3, 'abcdefg'), (100, 200, 300, 'qwerty'), (200, 300, 400, 'asdfg'); +ALTER TABLE t1 ALGORITHM DEFAULT, ADD COLUMN col5 VARCHAR(500), ADD COLUMN col6 TEXT; +Table id did not change +count(*) = 2 +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT count(*) AS `Expect 4` FROM information_schema.innodb_tables WHERE instant_cols != 0; +Expect 4 +4 +ALTER TABLE t1 ALGORITHM INPLACE, REORGANIZE PARTITION p0 INTO (PARTITION p0_a VALUES LESS THAN (64), PARTITION p0_b VALUES LESS THAN (128)); +SELECT count(*) AS `Expect 3` FROM information_schema.innodb_tables WHERE instant_cols != 0; +Expect 3 +3 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +ALTER TABLE t1 ALGORITHM DEFAULT, ADD KEY idx4(col4(10)); +SELECT count(*) AS `Expect 3` FROM information_schema.innodb_tables WHERE instant_cols != 0; +Expect 3 +3 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +ALTER TABLE t1 ALGORITHM DEFAULT, LOCK EXCLUSIVE, REORGANIZE PARTITION p0_a, p0_b INTO (PARTITION p0 VALUES LESS THAN (128) TABLESPACE innodb_file_per_table); +SELECT count(*) AS `Expect 3` FROM information_schema.innodb_tables WHERE instant_cols != 0; +Expect 3 +3 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +ALTER TABLE t1 ADD KEY idx3(col3); +SELECT count(*) AS `Expect 3` FROM information_schema.innodb_tables WHERE instant_cols != 0; +Expect 3 +3 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT * FROM t1; +col1 col2 col3 col4 col5 col6 +1 2 3 abcdefg NULL NULL +100 200 300 qwerty NULL NULL +200 300 400 asdfg NULL NULL +DROP TABLE t1; +CREATE TABLE t1 (a INT NOT NULL AUTO_INCREMENT PRIMARY KEY, b INT) ROW_FORMAT=COMPACT PARTITION BY HASH(a) PARTITIONS 3;; +INSERT INTO t1 VALUES(0, 1), (0, 2), (0, 3), (0, 4), (0, 5), (0, 6), (0, 7), (0, 8); +ALTER TABLE t1 ADD COLUMN c INT NOT NULL DEFAULT 5; +Table id did not change +count(*) = 1 +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT count(*) AS `Expect 3` FROM information_schema.innodb_tables WHERE instant_cols != 0; +Expect 3 +3 +ALTER TABLE t1 ADD PARTITION PARTITIONS 10; +SELECT count(*) AS `Expect 0` FROM information_schema.innodb_tables WHERE instant_cols != 0; +Expect 0 +0 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +ALTER TABLE t1 ADD KEY(b); +SELECT count(*) AS `Expect 0` FROM information_schema.innodb_tables WHERE instant_cols != 0; +Expect 0 +0 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT * FROM t1; +a b c +1 1 5 +2 2 5 +3 3 5 +4 4 5 +5 5 5 +6 6 5 +7 7 5 +8 8 5 +DROP TABLE t1; +# +# Scenario 13: +# Create a table with a two level clustered index, do instant ADD COLUMN, then the non-leaf node +# should be parsed correctly +# +CREATE TABLE t1 (a INT NOT NULL AUTO_INCREMENT, d INT NOT NULL, b BLOB NOT NULL, c VARCHAR(87), INDEX(d), INDEX(a ASC), PRIMARY KEY (a, d DESC, c DESC)) ROW_FORMAT=COMPACT PARTITION BY LINEAR KEY(c) PARTITIONS 9;; +INSERT INTO t1(d, b, c) VALUES(1, 2, 'aaaaaaaaaabbbbbbbbbbccccccccccddddddddddeeeeeeeeeeffffffffffgggggggggghhhhhhhhhhjjjjjjj'); +INSERT INTO t1(d, b, c) VALUES(2, 3, 'aaaaaaaaaahhhhhhhhhhbbbbbbbbbbccccccccccddddddddddeeeeeeeeeeffffffffffggggggggggjjjjjjj'); +INSERT INTO t1(d, b, c) VALUES(3, 4, 'bbbbbbbbbbaaaaaaaaaahhhhhhhhhhccccccccccddddddddddeeeeeeeeeeffffffffffggggggggggjjjjjjj'); +INSERT INTO t1(d, b, c) VALUES(4, 5, 'eeeeeeeeeehhhhhhhhhhbbbbbbbbbbccccccccccddddddddddaaaaaaaaaaffffffffffggggggggggjjjjjjj'); +INSERT INTO t1(d, b, c) VALUES(5, 6, 'aaaaaaaaaahhhhhhhhhhbbbbbbbbbbddddddddddcccccccccceeeeeeeeeeffffffffffggggggggggjjjjjjj'); +INSERT INTO t1(d, b, c) VALUES(6, 7, 'cccccccccchhhhhhhhhhbbbbbbbbbbaaaaaaaaaaddddddddddeeeeeeeeeeffffffffffggggggggggjjjjjjj'); +INSERT INTO t1(d, b, c) SELECT d, b, c FROM t1; +INSERT INTO t1(d, b, c) SELECT d, b, c FROM t1; +INSERT INTO t1(d, b, c) SELECT d, b, c FROM t1; +INSERT INTO t1(d, b, c) SELECT d, b, c FROM t1; +INSERT INTO t1(d, b, c) SELECT d, b, c FROM t1; +INSERT INTO t1(d, b, c) SELECT d, b, c FROM t1; +ALTER TABLE t1 ADD COLUMN nc086 BIGINT NOT NULL FIRST, ALGORITHM=INPLACE, LOCK=DEFAULT; +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +ALTER TABLE t1 ADD COLUMN nc082 TINYTEXT; +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT COUNT(*) FROM t1; +COUNT(*) +384 +DROP TABLE t1; +# +# Scenario 14: +# Create a small table, and add GIS kinds of new columns and verify +# +CREATE TABLE t1 (a INT NOT NULL AUTO_INCREMENT PRIMARY KEY, b INT) ROW_FORMAT=COMPACT; +INSERT INTO t1 VALUES(0, 1), (0, 2), (0, 3), (0, 4), (0, 5); +ALTER TABLE t1 ADD COLUMN c1 POINT, ALGORITHM = INSTANT; +Table id did not change +count(*) = 1 +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'c1' AND has_default = 1; +name default_value +c1 NULL +INSERT INTO t1(a, c1) VALUES(0, ST_PointFromText('POINT(10 10)')); +SELECT count(*) = max(a) FROM t1 WHERE c1 IS NULL; +count(*) = max(a) +1 +ALTER TABLE t1 ADD COLUMN d1 LINESTRING, ALGORITHM = INSTANT; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'd1' AND has_default = 1; +name default_value +d1 NULL +INSERT INTO t1(a, d1) VALUES(0, ST_LineFromText('LINESTRING(0 0,0 10,10 0)')); +SELECT count(*) = max(a) FROM t1 WHERE d1 IS NULL; +count(*) = max(a) +1 +ALTER TABLE t1 ADD COLUMN e1 POLYGON, ALGORITHM = INSTANT; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'e1' AND has_default = 1; +name default_value +e1 NULL +INSERT INTO t1(a, e1) VALUES(0, ST_PolygonFromText('POLYGON((10 10,20 10,20 20,10 20,10 10))')); +SELECT count(*) = max(a) FROM t1 WHERE e1 IS NULL; +count(*) = max(a) +1 +ALTER TABLE t1 ADD COLUMN f1 MULTIPOINT, ALGORITHM = INSTANT; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'f1' AND has_default = 1; +name default_value +f1 NULL +INSERT INTO t1(a, f1) VALUES(0, ST_MultiPointFromText('MULTIPOINT(0 0,10 10,10 20,20 20)')); +SELECT count(*) = max(a) FROM t1 WHERE f1 IS NULL; +count(*) = max(a) +1 +ALTER TABLE t1 ADD COLUMN g1 MULTILINESTRING, ALGORITHM = INSTANT; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'g1' AND has_default = 1; +name default_value +g1 NULL +INSERT INTO t1(a, g1) VALUES(0, ST_MultiLineStringFromText('MULTILINESTRING((10 48,10 21,10 0),(16 0,16 23,16 48))')); +SELECT count(*) = max(a) FROM t1 WHERE g1 IS NULL; +count(*) = max(a) +1 +ALTER TABLE t1 ADD COLUMN h1 MULTIPOLYGON, ALGORITHM = INSTANT; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'h1' AND has_default = 1; +name default_value +h1 NULL +INSERT INTO t1(a, h1) VALUES(0, ST_MultiPolygonFromText('MULTIPOLYGON(((28 26,28 0,84 0,84 42,28 26),(52 18,66 23,73 9,48 6,52 18)),((59 18,67 18,67 13,59 13,59 18)))')); +SELECT count(*) = max(a) FROM t1 WHERE h1 IS NULL; +count(*) = max(a) +1 +ALTER TABLE t1 ADD COLUMN i1 GEOMETRYCOLLECTION, ALGORITHM = INSTANT; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'i1' AND has_default = 1; +name default_value +i1 NULL +INSERT INTO t1(a, i1) VALUES(0, ST_GeomCollFromText('GEOMETRYCOLLECTION(POINT(0 0), LINESTRING(0 0,10 10))')); +SELECT count(*) = max(a) FROM t1 WHERE i1 IS NULL; +count(*) = max(a) +1 +ALTER TABLE t1 ADD COLUMN j1 GEOMETRY, ALGORITHM = INSTANT; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'j1' AND has_default = 1; +name default_value +j1 NULL +INSERT INTO t1(a, j1) VALUES(0, ST_GeomCollFromText('GEOMETRYCOLLECTION(POINT(0 0), LINESTRING(0 0,10 10))')); +SELECT count(*) = max(a) FROM t1 WHERE j1 IS NULL; +count(*) = max(a) +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int NOT NULL AUTO_INCREMENT, + `b` int DEFAULT NULL, + `c1` point DEFAULT NULL, + `d1` linestring DEFAULT NULL, + `e1` polygon DEFAULT NULL, + `f1` multipoint DEFAULT NULL, + `g1` multilinestring DEFAULT NULL, + `h1` multipolygon DEFAULT NULL, + `i1` geomcollection DEFAULT NULL, + `j1` geometry DEFAULT NULL, + PRIMARY KEY (`a`) +) ENGINE=InnoDB AUTO_INCREMENT=14 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=COMPACT +DROP TABLE t1; +# +# Scenario 15: +# Create a small table, and add JSON columns and verify +# +CREATE TABLE t1 (a INT NOT NULL AUTO_INCREMENT PRIMARY KEY, b INT) ROW_FORMAT=COMPACT; +INSERT INTO t1 VALUES(0, 1), (0, 2), (0, 3), (0, 4), (0, 5); +ALTER TABLE t1 ADD COLUMN c1 JSON, ALGORITHM = INSTANT; +Table id did not change +count(*) = 1 +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'c1' AND has_default = 1; +name default_value +c1 NULL +INSERT INTO t1(a, c1) VALUES(0, '{"key1": "value1", "key2": "value2"}'); +SELECT count(*) = max(a) FROM t1 WHERE c1 IS NULL; +count(*) = max(a) +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int NOT NULL AUTO_INCREMENT, + `b` int DEFAULT NULL, + `c1` json DEFAULT NULL, + PRIMARY KEY (`a`) +) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=COMPACT +DROP TABLE t1; +# +# Scenario 16: +# Create a small table, and add INSTANT columns and verify with trigger +# +CREATE TABLE t1 (a INT NOT NULL AUTO_INCREMENT PRIMARY KEY, b INT) ROW_FORMAT=COMPACT; +CREATE TABLE t2 (a INT NOT NULL AUTO_INCREMENT PRIMARY KEY, b INT) ROW_FORMAT=COMPACT; +INSERT INTO t1 VALUES(0, 1), (0, 2), (0, 3), (0, 4), (0, 5); +INSERT INTO t2 VALUES(0, 1), (0, 2), (0, 3), (0, 4), (0, 5); +ALTER TABLE t1 ADD COLUMN c1 VARCHAR(10) NOT NULL DEFAULT 'aaaa', ALGORITHM = INSTANT; +Table id did not change +count(*) = 1 +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'c1' AND has_default = 1; +name default_value +c1 61616161 +CREATE TRIGGER t1_ai AFTER INSERT ON t1 FOR EACH ROW +INSERT INTO t2 VALUES(0,6); +INSERT INTO t1(a, c1) VALUES(0, 'bbbb'); +SELECT count(*) = max(a) FROM t1 WHERE c1='aaaa'; +count(*) = max(a) +1 +SELECT c1 FROM t1 WHERE c1 = 'bbbb'; +c1 +bbbb +DROP TRIGGER t1_ai; +ALTER TABLE t2 ADD COLUMN c1 VARCHAR(10) NOT NULL DEFAULT 'cccc', ALGORITHM = INSTANT; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'c1' AND has_default = 1; +name default_value +c1 61616161 +c1 63636363 +CREATE TRIGGER t2_ai AFTER INSERT ON t2 FOR EACH ROW +INSERT INTO t1(a,c1) VALUES(0,'eeee'); +INSERT INTO t2(a, c1) VALUES(0, 'dddd'); +SELECT count(*) = max(a) FROM t2 WHERE c1='cccc'; +count(*) = max(a) +1 +SELECT c1 FROM t2 WHERE c1 = 'dddd'; +c1 +dddd +DROP TRIGGER t2_ai; +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +CHECK TABLE t2; +Table Op Msg_type Msg_text +test.t2 check status OK +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int NOT NULL AUTO_INCREMENT, + `b` int DEFAULT NULL, + `c1` varchar(10) NOT NULL DEFAULT 'aaaa', + PRIMARY KEY (`a`) +) ENGINE=InnoDB AUTO_INCREMENT=8 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=COMPACT +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `a` int NOT NULL AUTO_INCREMENT, + `b` int DEFAULT NULL, + `c1` varchar(10) NOT NULL DEFAULT 'cccc', + PRIMARY KEY (`a`) +) ENGINE=InnoDB AUTO_INCREMENT=8 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=COMPACT +DROP TABLE t1,t2; +# +# Scenario 17: +# Create a small table, and add INSTANT columns and verify with storedprocedure +# +CREATE TABLE t1 (a INT NOT NULL AUTO_INCREMENT PRIMARY KEY, b INT) ROW_FORMAT=COMPACT; +INSERT INTO t1 VALUES(0, 1), (0, 2), (0, 3), (0, 4), (0, 5); +ALTER TABLE t1 ADD COLUMN c1 VARCHAR(10) NOT NULL DEFAULT 'aaaa', ALGORITHM = INSTANT; +Table id did not change +count(*) = 1 +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'c1' AND has_default = 1; +name default_value +c1 61616161 +CREATE PROCEDURE p1() INSERT INTO t1(a,c1) VALUES(0, 'bbbb'); +CALL p1(); +SELECT count(*) = max(a) FROM t1 WHERE c1='aaaa'; +count(*) = max(a) +1 +SELECT c1 FROM t1 WHERE c1 = 'bbbb'; +c1 +bbbb +DROP PROCEDURE p1; +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int NOT NULL AUTO_INCREMENT, + `b` int DEFAULT NULL, + `c1` varchar(10) NOT NULL DEFAULT 'aaaa', + PRIMARY KEY (`a`) +) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=COMPACT +DROP TABLE t1; +# +# Scenario 18: +# Create a small table, and add INSTANT columns and verify with view +# +CREATE TABLE t1 (a INT NOT NULL AUTO_INCREMENT PRIMARY KEY, b INT) ROW_FORMAT=COMPACT; +INSERT INTO t1 VALUES(0, 1), (0, 2), (0, 3), (0, 4), (0, 5); +ALTER TABLE t1 ADD COLUMN c1 VARCHAR(10) NOT NULL DEFAULT 'aaaa', ALGORITHM = INSTANT; +Table id did not change +count(*) = 1 +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'c1' AND has_default = 1; +name default_value +c1 61616161 +CREATE VIEW v1 AS SELECT * FROM t1; +INSERT INTO t1(a, c1) VALUES(0, 'bbbb'); +SELECT count(*) = max(a) FROM t1 WHERE c1='aaaa'; +count(*) = max(a) +1 +SELECT c1 FROM t1 WHERE c1 = 'bbbb'; +c1 +bbbb +SELECT * FROM v1; +a b c1 +1 1 aaaa +2 2 aaaa +3 3 aaaa +4 4 aaaa +5 5 aaaa +6 NULL bbbb +DROP VIEW v1; +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int NOT NULL AUTO_INCREMENT, + `b` int DEFAULT NULL, + `c1` varchar(10) NOT NULL DEFAULT 'aaaa', + PRIMARY KEY (`a`) +) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=COMPACT +DROP TABLE t1; +# +# Scenario 19: +# Create a small table, and add INSTANT columns and drop it and verify +# +CREATE TABLE t1 (a INT NOT NULL AUTO_INCREMENT PRIMARY KEY, b INT) ROW_FORMAT=COMPACT; +INSERT INTO t1 VALUES(0, 1), (0, 2), (0, 3), (0, 4), (0, 5); +ALTER TABLE t1 ADD COLUMN c1 VARCHAR(10) NOT NULL DEFAULT 'aaaa', ALGORITHM = INSTANT; +Table id did not change +count(*) = 1 +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'c1' AND has_default = 1; +name default_value +c1 61616161 +INSERT INTO t1(a, c1) VALUES(0, 'bbbb'); +SELECT count(*) = max(a) FROM t1 WHERE c1='aaaa'; +count(*) = max(a) +1 +SELECT c1 FROM t1 WHERE c1 = 'bbbb'; +c1 +bbbb +ALTER TABLE t1 DROP COLUMN c1; +Table ID differed +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +0 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int NOT NULL AUTO_INCREMENT, + `b` int DEFAULT NULL, + PRIMARY KEY (`a`) +) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=COMPACT +DROP TABLE t1; +# +# Scenario 20: +# Create a small table, and add INSTANT columns and rename table +# +CREATE TABLE t1 (a INT NOT NULL AUTO_INCREMENT PRIMARY KEY, b INT) ROW_FORMAT=COMPACT; +INSERT INTO t1 VALUES(0, 1), (0, 2), (0, 3), (0, 4), (0, 5); +ALTER TABLE t1 ADD COLUMN c1 VARCHAR(10) NOT NULL DEFAULT 'aaaa', ALGORITHM = INSTANT; +Table id did not change +count(*) = 1 +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +ALTER TABLE t1 RENAME t2; +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'c1' AND has_default = 1; +name default_value +c1 61616161 +INSERT INTO t2(a, c1) VALUES(0, 'bbbb'); +SELECT count(*) = max(a) FROM t2 WHERE c1='aaaa'; +count(*) = max(a) +1 +SELECT c1 FROM t2 WHERE c1 = 'bbbb'; +c1 +bbbb +CHECK TABLE t2; +Table Op Msg_type Msg_text +test.t2 check status OK +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `a` int NOT NULL AUTO_INCREMENT, + `b` int DEFAULT NULL, + `c1` varchar(10) NOT NULL DEFAULT 'aaaa', + PRIMARY KEY (`a`) +) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=COMPACT +DROP TABLE t2; +# +# Scenario 21: +# Create a small table, and add INSTANT columns and change its data type INSTANTly won't work +# +CREATE TABLE t1 (a INT NOT NULL AUTO_INCREMENT PRIMARY KEY, b INT) ROW_FORMAT=COMPACT; +INSERT INTO t1 VALUES(0, 1), (0, 2), (0, 3), (0, 4), (0, 5); +ALTER TABLE t1 ADD COLUMN c1 VARCHAR(10) NOT NULL DEFAULT 'aaaa', ALGORITHM = INSTANT; +Table id did not change +count(*) = 1 +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'c1' AND has_default = 1; +name default_value +c1 61616161 +INSERT INTO t1(a, c1) VALUES(0, 'bbbb'); +SELECT count(*) = max(a) FROM t1 WHERE c1='aaaa'; +count(*) = max(a) +1 +SELECT c1 FROM t1 WHERE c1 = 'bbbb'; +c1 +bbbb +ALTER TABLE t1 CHANGE c1 c2 CHAR(10) NOT NULL DEFAULT 'cccc'; +Table ID differed +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +0 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int NOT NULL AUTO_INCREMENT, + `b` int DEFAULT NULL, + `c2` char(10) NOT NULL DEFAULT 'cccc', + PRIMARY KEY (`a`) +) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=COMPACT +DROP TABLE t1; +# +# Scenario 22: +# Create a small table, and add INSTANT columns and create hash,btree multi column index and verify +# +CREATE TABLE t1 (a INT NOT NULL AUTO_INCREMENT PRIMARY KEY, b INT) ROW_FORMAT=COMPACT; +INSERT INTO t1 VALUES(0, 1), (0, 2), (0, 3), (0, 4), (0, 5); +ALTER TABLE t1 ADD COLUMN c1 VARCHAR(10) NOT NULL DEFAULT 'aaaa', ALGORITHM = INSTANT; +Table id did not change +count(*) = 1 +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'c1' AND has_default = 1; +name default_value +c1 61616161 +CREATE INDEX id1 ON t1(c1) USING BTREE; +CREATE INDEX id2 ON t1(c1) USING HASH; +Warnings: +Note 3502 This storage engine does not support the HASH index algorithm, storage engine default was used instead. +Warning 1831 Duplicate index 'id2' defined on the table 'test.t1'. This is deprecated and will be disallowed in a future release. +INSERT INTO t1(a, c1) VALUES(0, 'bbbb'); +SELECT count(*) = max(a) FROM t1 WHERE c1='aaaa'; +count(*) = max(a) +1 +SELECT c1 FROM t1 WHERE c1 = 'bbbb'; +c1 +bbbb +DROP INDEX id1 ON t1; +DROP INDEX id2 ON t1; +ALTER TABLE t1 ADD COLUMN c2 VARCHAR(10) NOT NULL DEFAULT 'cccc', ALGORITHM = INSTANT; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'c2' AND has_default = 1; +name default_value +c2 63636363 +CREATE INDEX id1 ON t1(c1 ASC,c2 DESC) USING BTREE; +INSERT INTO t1(a, c2) VALUES(0, 'dddd'); +SELECT count(*) = max(a) FROM t1 WHERE c1='cccc'; +count(*) = max(a) +NULL +SELECT c1 FROM t1 WHERE c1 = 'dddd'; +c1 +ALTER TABLE t1 RENAME INDEX id1 TO id2; +DROP INDEX id2 ON t1; +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int NOT NULL AUTO_INCREMENT, + `b` int DEFAULT NULL, + `c1` varchar(10) NOT NULL DEFAULT 'aaaa', + `c2` varchar(10) NOT NULL DEFAULT 'cccc', + PRIMARY KEY (`a`) +) ENGINE=InnoDB AUTO_INCREMENT=8 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=COMPACT +DROP TABLE t1; +# +# Scenario 23: +# Create a small table, and add INSTANT columns and perform table join operation +# +CREATE TABLE t1 (a INT NOT NULL AUTO_INCREMENT PRIMARY KEY, b INT) ROW_FORMAT=COMPACT; +CREATE TABLE t2 (a INT NOT NULL AUTO_INCREMENT PRIMARY KEY, b INT) ROW_FORMAT=COMPACT; +INSERT INTO t1 VALUES(0, 1), (0, 2), (0, 3), (0, 4), (0, 5); +INSERT INTO t2 VALUES(0, 1), (0, 2), (0, 3), (0, 4), (0, 5); +ALTER TABLE t1 ADD COLUMN c1 VARCHAR(10) NOT NULL DEFAULT 'aaaa', ALGORITHM = INSTANT; +Table id did not change +count(*) = 1 +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'c1' AND has_default = 1; +name default_value +c1 61616161 +INSERT INTO t1(a, c1) VALUES(0, 'cccc'); +SELECT count(*) = max(a) FROM t1 WHERE c1='aaaa'; +count(*) = max(a) +1 +SELECT c1 FROM t1 WHERE c1 = 'cccc'; +c1 +cccc +ALTER TABLE t2 ADD COLUMN c1 VARCHAR(10) NOT NULL DEFAULT 'bbbb', ALGORITHM = INSTANT; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'c1' AND has_default = 1; +name default_value +c1 61616161 +c1 62626262 +INSERT INTO t2(a, c1) VALUES(0, 'cccc'); +SELECT count(*) = max(a) FROM t2 WHERE c1='bbbb'; +count(*) = max(a) +1 +SELECT c1 FROM t2 WHERE c1 = 'cccc'; +c1 +cccc +SELECT * FROM t1 JOIN t2 ON t1.c1=t2.c1; +a b c1 a b c1 +6 NULL cccc 6 NULL cccc +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +CHECK TABLE t2; +Table Op Msg_type Msg_text +test.t2 check status OK +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int NOT NULL AUTO_INCREMENT, + `b` int DEFAULT NULL, + `c1` varchar(10) NOT NULL DEFAULT 'aaaa', + PRIMARY KEY (`a`) +) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=COMPACT +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `a` int NOT NULL AUTO_INCREMENT, + `b` int DEFAULT NULL, + `c1` varchar(10) NOT NULL DEFAULT 'bbbb', + PRIMARY KEY (`a`) +) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=COMPACT +DROP TABLE t1; +DROP TABLE t2; +# +# Scenario 24: +# Create a small table, and add stored and(or) virtual columns +# after last stored column in the table +# +CREATE TABLE t1 (a INT NOT NULL AUTO_INCREMENT PRIMARY KEY, b INT, c INT, d INT GENERATED ALWAYS AS (b + c) VIRTUAL, e INT GENERATED ALWAYS AS (b * c) VIRTUAL) ROW_FORMAT=COMPACT; +INSERT INTO t1(a, b, c) VALUES(0, 1, 2), (0, 2, 3), (0, 3, 4), (0, 4, 5), (0, 5, 6); +ALTER TABLE t1 ADD COLUMN h INT NOT NULL AFTER c; +Table id did not change +count(*) = 1 +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +INSERT INTO t1(a, b, c, h) VALUES(0, 6, 20, 40); +SELECT * FROM t1; +a b c h d e +1 1 2 0 3 2 +2 2 3 0 5 6 +3 3 4 0 7 12 +4 4 5 0 9 20 +5 5 6 0 11 30 +6 6 20 40 26 120 +ALTER TABLE t1 ADD COLUMN i VARCHAR(100) DEFAULT 'ABCD EFGH' AFTER h, ADD COLUMN f INT GENERATED ALWAYS AS (LENGTH(i)) AFTER i; +Table id did not change +SELECT 3 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +INSERT INTO t1(a, b, c, h, i) VALUES(0, 20, 30, 50, 'qwerty'); +SELECT * FROM t1; +a b c h i f d e +1 1 2 0 ABCD EFGH 9 3 2 +2 2 3 0 ABCD EFGH 9 5 6 +3 3 4 0 ABCD EFGH 9 7 12 +4 4 5 0 ABCD EFGH 9 9 20 +5 5 6 0 ABCD EFGH 9 11 30 +6 6 20 40 ABCD EFGH 9 26 120 +7 20 30 50 qwerty 6 50 600 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int NOT NULL AUTO_INCREMENT, + `b` int DEFAULT NULL, + `c` int DEFAULT NULL, + `h` int NOT NULL, + `i` varchar(100) DEFAULT 'ABCD EFGH', + `f` int GENERATED ALWAYS AS (length(`i`)) VIRTUAL, + `d` int GENERATED ALWAYS AS ((`b` + `c`)) VIRTUAL, + `e` int GENERATED ALWAYS AS ((`b` * `c`)) VIRTUAL, + PRIMARY KEY (`a`) +) ENGINE=InnoDB AUTO_INCREMENT=8 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=COMPACT +DROP TABLE t1; +# +# Test cases which don't care about row format start here +# +# +# Bug #28040201 ADDING A NEW COLUMN TO A TABLE HAVING A GENRATED COLUMN +# CRASHES THE SERVER +# +CREATE TABLE t1 (a TEXT GENERATED ALWAYS AS (lpad(1, 1, 1)) VIRTUAL); +ALTER TABLE t1 ADD COLUMN (b INT); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` text GENERATED ALWAYS AS (lpad(1,1,1)) VIRTUAL, + `b` int DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +DROP TABLE t1; +# +# BUG#27784462 - DD::COLUMN::SE_PRIVATE_DATA[TABLE_ID] IS NOT MAINTAINED PROPERLY +# +CREATE TABLE t1 (a INT NOT NULL AUTO_INCREMENT PRIMARY KEY, b INT, c INT NOT NULL DEFAULT 5, e INT GENERATED ALWAYS AS ((c + 2)) VIRTUAL) PARTITION BY RANGE (a) (PARTITION p1 VALUES LESS THAN (10), PARTITION p2 VALUES LESS THAN (20), PARTITION p3 VALUES LESS THAN (30)); +ALTER TABLE t1 REORGANIZE PARTITION p1 INTO (PARTITION p1_a VALUES LESS THAN (5), PARTITION p1_b VALUES LESS THAN (10)); +ALTER TABLE t1 ADD COLUMN d INT GENERATED ALWAYS AS ((b * 2)) VIRTUAL, ALGORITHM = INSTANT; +DROP TABLE t1; +# +# Check adding a stored columns(along with virtual columns) +# after the last stored column of a table with functional index +# should be fine +# +CREATE TABLE t1 (col1 INT, col2 INT AS (col1 + col1), INDEX (col2)); +INSERT INTO t1(col1) VALUES(10), (20), (30), (40); +ALTER TABLE t1 ADD COLUMN new_col INT AFTER col1, ALGORITHM=INSTANT; +SELECT * FROM t1; +col1 new_col col2 +10 NULL 20 +20 NULL 40 +30 NULL 60 +40 NULL 80 +ALTER TABLE t1 ADD COLUMN new_col_1 INT AFTER new_col, ADD COLUMN new_col_2 INT GENERATED ALWAYS AS (new_col * 3), ALGORITHM=INSTANT; +INSERT INTO t1(col1, new_col, new_col_1) VALUES(100, 200, 300); +SELECT * FROM t1; +col1 new_col new_col_1 col2 new_col_2 +10 NULL NULL 20 NULL +20 NULL NULL 40 NULL +30 NULL NULL 60 NULL +40 NULL NULL 80 NULL +100 200 300 200 600 +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `col1` int DEFAULT NULL, + `new_col` int DEFAULT NULL, + `new_col_1` int DEFAULT NULL, + `col2` int GENERATED ALWAYS AS ((`col1` + `col1`)) VIRTUAL, + `new_col_2` int GENERATED ALWAYS AS ((`new_col` * 3)) VIRTUAL, + KEY `col2` (`col2`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +DROP TABLE t1; diff --git a/mysql-test/suite/max_seeks_for_key_func.result-pq b/mysql-test/suite/max_seeks_for_key_func.result-pq new file mode 100644 index 000000000000..2d93c5080936 --- /dev/null +++ b/mysql-test/suite/max_seeks_for_key_func.result-pq @@ -0,0 +1,95 @@ +DROP TABLE IF EXISTS t1; +CREATE TABLE t1 +(a INT AUTO_INCREMENT PRIMARY KEY, +b CHAR(20) +); +SET @start_value= @@global.max_seeks_for_key; +'#--------------------FN_DYNVARS_084_01-------------------------#' +SELECT @@global.max_seeks_for_key = 10; +@@global.max_seeks_for_key = 10 +0 +SELECT @@session.max_seeks_for_key = 10; +@@session.max_seeks_for_key = 10 +0 +SET @@global.max_seeks_for_key = 20; +SELECT @@global.max_seeks_for_key; +@@global.max_seeks_for_key +20 +INSERT INTO t1(b) VALUES("AREc"); +EXPLAIN SELECT STRAIGHT_JOIN * FROM t1,t1 AS t2 WHERE t1.b = t2.b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # # Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL # # NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL # # Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select straight_join `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` join `test`.`t1` `t2` where (`test`.`t2`.`b` = `test`.`t1`.`b`) +SET @@session.max_seeks_for_key = 2; +SELECT @@session.max_seeks_for_key; +@@session.max_seeks_for_key +2 +INSERT INTO t1(b) VALUES("BREc"); +INSERT INTO t1(b) VALUES("CRec"); +EXPLAIN SELECT STRAIGHT_JOIN * FROM t1,t1 AS t2 WHERE t1.b = t2.b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # # Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL # # NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL # # Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select straight_join `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` join `test`.`t1` `t2` where (`test`.`t2`.`b` = `test`.`t1`.`b`) +'#--------------------FN_DYNVARS_084_02-------------------------#' +SELECT @@global.max_seeks_for_key = 10; +@@global.max_seeks_for_key = 10 +0 +SELECT @@session.max_seeks_for_key = 10; +@@session.max_seeks_for_key = 10 +0 +SET @@global.max_seeks_for_key = 20; +SELECT @@global.max_seeks_for_key; +@@global.max_seeks_for_key +20 +INSERT INTO t1(b) VALUES("AREc"); +EXPLAIN SELECT STRAIGHT_JOIN * FROM t1,t1 AS t2 WHERE t1.b = t2.b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # # Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL # # NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL # # Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select straight_join `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` join `test`.`t1` `t2` where (`test`.`t2`.`b` = `test`.`t1`.`b`) +SET @@session.max_seeks_for_key = 2; +SELECT @@session.max_seeks_for_key; +@@session.max_seeks_for_key +2 +INSERT INTO t1(b) VALUES("BREc"); +INSERT INTO t1(b) VALUES("CRec"); +EXPLAIN SELECT STRAIGHT_JOIN * FROM t1,t1 AS t2 WHERE t1.b = t2.b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # # Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL # # NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL # # Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select straight_join `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` join `test`.`t1` `t2` where (`test`.`t2`.`b` = `test`.`t1`.`b`) +INSERT INTO t1 VALUES(null,"test"); +INSERT INTO t1 VALUES (null,"a"),(null,"a"),(null,"a"), +(null,"a"),(null,"a"),(null,"a"),(null,"a"), +(null,"a"),(null,"a"),(null,"a"); +EXPLAIN SELECT STRAIGHT_JOIN * FROM t1,t1 AS t2 WHERE t1.b = t2.b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # # Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL # # NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL # # Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select straight_join `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` join `test`.`t1` `t2` where (`test`.`t2`.`b` = `test`.`t1`.`b`) +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +SET MAX_SEEKS_FOR_KEY=1; +EXPLAIN SELECT STRAIGHT_JOIN * FROM t1,t1 AS t2 WHERE t1.b = t2.b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # # Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL # # NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL # # Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select straight_join `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` join `test`.`t1` `t2` where (`test`.`t2`.`b` = `test`.`t1`.`b`) +SET MAX_SEEKS_FOR_KEY=DEFAULT; +DROP TABLE t1; +SET @@global.max_seeks_for_key= @start_value; diff --git a/mysql-test/suite/monitor.result-pq b/mysql-test/suite/monitor.result-pq new file mode 100644 index 000000000000..e172c5007484 --- /dev/null +++ b/mysql-test/suite/monitor.result-pq @@ -0,0 +1,739 @@ +set global innodb_monitor_disable = All; +select name, status from information_schema.innodb_metrics; +name status +metadata_table_handles_opened disabled +metadata_table_handles_closed disabled +metadata_table_reference_count disabled +lock_deadlocks disabled +lock_deadlock_false_positives disabled +lock_deadlock_rounds disabled +lock_threads_waiting disabled +lock_timeouts disabled +lock_rec_lock_waits disabled +lock_table_lock_waits disabled +lock_rec_lock_requests disabled +lock_rec_release_attempts disabled +lock_rec_grant_attempts disabled +lock_rec_lock_created disabled +lock_rec_lock_removed disabled +lock_rec_locks disabled +lock_table_lock_created disabled +lock_table_lock_removed disabled +lock_table_locks disabled +lock_row_lock_current_waits disabled +lock_row_lock_time disabled +lock_row_lock_time_max disabled +lock_row_lock_waits disabled +lock_row_lock_time_avg disabled +lock_schedule_refreshes disabled +buffer_pool_size disabled +buffer_pool_reads disabled +buffer_pool_read_requests disabled +buffer_pool_write_requests disabled +buffer_pool_wait_free disabled +buffer_pool_read_ahead disabled +buffer_pool_read_ahead_evicted disabled +buffer_pool_pages_total disabled +buffer_pool_pages_misc disabled +buffer_pool_pages_data disabled +buffer_pool_bytes_data disabled +buffer_pool_pages_dirty disabled +buffer_pool_bytes_dirty disabled +buffer_pool_pages_free disabled +buffer_pages_created disabled +buffer_pages_written disabled +buffer_pages_read disabled +buffer_data_reads disabled +buffer_data_written disabled +buffer_flush_batch_scanned disabled +buffer_flush_batch_num_scan disabled +buffer_flush_batch_scanned_per_call disabled +buffer_flush_batch_total_pages disabled +buffer_flush_batches disabled +buffer_flush_batch_pages disabled +buffer_flush_neighbor_total_pages disabled +buffer_flush_neighbor disabled +buffer_flush_neighbor_pages disabled +buffer_flush_n_to_flush_requested disabled +buffer_flush_n_to_flush_by_dirty_page disabled +buffer_flush_n_to_flush_by_age disabled +buffer_flush_adaptive_avg_time_slot disabled +buffer_LRU_batch_flush_avg_time_slot disabled +buffer_flush_adaptive_avg_time_thread disabled +buffer_LRU_batch_flush_avg_time_thread disabled +buffer_flush_adaptive_avg_time_est disabled +buffer_LRU_batch_flush_avg_time_est disabled +buffer_flush_avg_time disabled +buffer_flush_adaptive_avg_pass disabled +buffer_LRU_batch_flush_avg_pass disabled +buffer_flush_avg_pass disabled +buffer_LRU_get_free_loops disabled +buffer_LRU_get_free_waits disabled +buffer_flush_avg_page_rate disabled +buffer_flush_lsn_avg_rate disabled +buffer_flush_pct_for_dirty disabled +buffer_flush_pct_for_lsn disabled +buffer_flush_sync_waits disabled +buffer_flush_adaptive_total_pages disabled +buffer_flush_adaptive disabled +buffer_flush_adaptive_pages disabled +buffer_flush_sync_total_pages disabled +buffer_flush_sync disabled +buffer_flush_sync_pages disabled +buffer_flush_background_total_pages disabled +buffer_flush_background disabled +buffer_flush_background_pages disabled +buffer_LRU_batch_scanned disabled +buffer_LRU_batch_num_scan disabled +buffer_LRU_batch_scanned_per_call disabled +buffer_LRU_batch_flush_total_pages disabled +buffer_LRU_batches_flush disabled +buffer_LRU_batch_flush_pages disabled +buffer_LRU_batch_evict_total_pages disabled +buffer_LRU_batches_evict disabled +buffer_LRU_batch_evict_pages disabled +buffer_LRU_single_flush_scanned disabled +buffer_LRU_single_flush_num_scan disabled +buffer_LRU_single_flush_scanned_per_call disabled +buffer_LRU_single_flush_failure_count disabled +buffer_LRU_get_free_search disabled +buffer_LRU_search_scanned disabled +buffer_LRU_search_num_scan disabled +buffer_LRU_search_scanned_per_call disabled +buffer_LRU_unzip_search_scanned disabled +buffer_LRU_unzip_search_num_scan disabled +buffer_LRU_unzip_search_scanned_per_call disabled +buffer_page_read_index_leaf disabled +buffer_page_read_index_non_leaf disabled +buffer_page_read_index_ibuf_leaf disabled +buffer_page_read_index_ibuf_non_leaf disabled +buffer_page_read_undo_log disabled +buffer_page_read_index_inode disabled +buffer_page_read_ibuf_free_list disabled +buffer_page_read_ibuf_bitmap disabled +buffer_page_read_system_page disabled +buffer_page_read_trx_system disabled +buffer_page_read_fsp_hdr disabled +buffer_page_read_xdes disabled +buffer_page_read_blob disabled +buffer_page_read_zblob disabled +buffer_page_read_zblob2 disabled +buffer_page_read_rseg_array disabled +buffer_page_read_other disabled +buffer_page_written_index_leaf disabled +buffer_page_written_index_non_leaf disabled +buffer_page_written_index_ibuf_leaf disabled +buffer_page_written_index_ibuf_non_leaf disabled +buffer_page_written_undo_log disabled +buffer_page_written_index_inode disabled +buffer_page_written_ibuf_free_list disabled +buffer_page_written_ibuf_bitmap disabled +buffer_page_written_system_page disabled +buffer_page_written_trx_system disabled +buffer_page_written_fsp_hdr disabled +buffer_page_written_xdes disabled +buffer_page_written_blob disabled +buffer_page_written_zblob disabled +buffer_page_written_zblob2 disabled +buffer_page_written_rseg_array disabled +buffer_page_written_other disabled +buffer_page_written_on_log_no_waits disabled +buffer_page_written_on_log_waits disabled +buffer_page_written_on_log_wait_loops disabled +os_data_reads disabled +os_data_writes disabled +os_data_fsyncs disabled +os_pending_reads disabled +os_pending_writes disabled +os_log_bytes_written disabled +os_log_fsyncs disabled +os_log_pending_fsyncs disabled +os_log_pending_writes disabled +trx_rw_commits disabled +trx_ro_commits disabled +trx_nl_ro_commits disabled +trx_commits_insert_update disabled +trx_rollbacks disabled +trx_rollbacks_savepoint disabled +trx_rollback_active disabled +trx_active_transactions disabled +trx_allocations disabled +trx_on_log_no_waits disabled +trx_on_log_waits disabled +trx_on_log_wait_loops disabled +trx_rseg_history_len disabled +trx_undo_slots_used disabled +trx_undo_slots_cached disabled +trx_rseg_current_size disabled +purge_del_mark_records disabled +purge_upd_exist_or_extern_records disabled +purge_invoked disabled +purge_undo_log_pages disabled +purge_dml_delay_usec disabled +purge_stop_count disabled +purge_resume_count disabled +purge_truncate_history_count disabled +purge_truncate_history_usec disabled +undo_truncate_count disabled +undo_truncate_start_logging_count disabled +undo_truncate_done_logging_count disabled +undo_truncate_usec disabled +log_lsn_last_flush disabled +log_lsn_last_checkpoint disabled +log_lsn_current disabled +log_lsn_archived disabled +log_lsn_checkpoint_age disabled +log_lsn_buf_dirty_pages_added disabled +log_lsn_buf_pool_oldest_approx disabled +log_lsn_buf_pool_oldest_lwm disabled +log_max_modified_age_async disabled +log_max_modified_age_sync disabled +log_waits disabled +log_write_requests disabled +log_writes disabled +log_flush_total_time disabled +log_flush_max_time disabled +log_flush_avg_time disabled +log_flush_lsn_avg_rate disabled +log_full_block_writes disabled +log_partial_block_writes disabled +log_padded disabled +log_next_file disabled +log_checkpoints disabled +log_free_space disabled +log_concurrency_margin disabled +log_writer_no_waits disabled +log_writer_waits disabled +log_writer_wait_loops disabled +log_writer_on_file_space_waits disabled +log_writer_on_archiver_waits disabled +log_flusher_no_waits disabled +log_flusher_waits disabled +log_flusher_wait_loops disabled +log_write_notifier_no_waits disabled +log_write_notifier_waits disabled +log_write_notifier_wait_loops disabled +log_flush_notifier_no_waits disabled +log_flush_notifier_waits disabled +log_flush_notifier_wait_loops disabled +log_write_to_file_requests_interval disabled +log_on_write_no_waits disabled +log_on_write_waits disabled +log_on_write_wait_loops disabled +log_on_flush_no_waits disabled +log_on_flush_waits disabled +log_on_flush_wait_loops disabled +log_on_recent_written_wait_loops disabled +log_on_recent_closed_wait_loops disabled +log_on_buffer_space_no_waits disabled +log_on_buffer_space_waits disabled +log_on_buffer_space_wait_loops disabled +log_on_file_space_no_waits disabled +log_on_file_space_waits disabled +log_on_file_space_wait_loops disabled +compress_pages_compressed disabled +compress_pages_decompressed disabled +compression_pad_increments disabled +compression_pad_decrements disabled +index_page_splits disabled +index_page_merge_attempts disabled +index_page_merge_successful disabled +index_page_reorg_attempts disabled +index_page_reorg_successful disabled +index_page_discards disabled +adaptive_hash_searches disabled +adaptive_hash_searches_btree disabled +adaptive_hash_pages_added disabled +adaptive_hash_pages_removed disabled +adaptive_hash_rows_added disabled +adaptive_hash_rows_removed disabled +adaptive_hash_rows_deleted_no_hash_entry disabled +adaptive_hash_rows_updated disabled +file_num_open_files disabled +ibuf_merges_insert disabled +ibuf_merges_delete_mark disabled +ibuf_merges_delete disabled +ibuf_merges_discard_insert disabled +ibuf_merges_discard_delete_mark disabled +ibuf_merges_discard_delete disabled +ibuf_merges disabled +ibuf_size disabled +innodb_master_thread_sleeps disabled +innodb_activity_count disabled +innodb_master_active_loops disabled +innodb_master_idle_loops disabled +innodb_background_drop_table_usec disabled +innodb_ibuf_merge_usec disabled +innodb_mem_validate_usec disabled +innodb_master_purge_usec disabled +innodb_dict_lru_usec disabled +innodb_dict_lru_count disabled +innodb_dblwr_writes disabled +innodb_dblwr_pages_written disabled +innodb_page_size disabled +innodb_rwlock_s_spin_waits disabled +innodb_rwlock_x_spin_waits disabled +innodb_rwlock_sx_spin_waits disabled +innodb_rwlock_s_spin_rounds disabled +innodb_rwlock_x_spin_rounds disabled +innodb_rwlock_sx_spin_rounds disabled +innodb_rwlock_s_os_waits disabled +innodb_rwlock_x_os_waits disabled +innodb_rwlock_sx_os_waits disabled +dml_reads disabled +dml_inserts disabled +dml_deletes disabled +dml_updates disabled +dml_system_reads disabled +dml_system_inserts disabled +dml_system_deletes disabled +dml_system_updates disabled +sampled_pages_read disabled +sampled_pages_skipped disabled +ddl_background_drop_tables disabled +ddl_online_create_index disabled +ddl_pending_alter_table disabled +ddl_sort_file_alter_table disabled +ddl_log_file_alter_table disabled +icp_attempts disabled +icp_no_match disabled +icp_out_of_range disabled +icp_match disabled +module_cpu disabled +cpu_utime_abs disabled +cpu_stime_abs disabled +cpu_utime_pct disabled +cpu_stime_pct disabled +cpu_n disabled +module_page_track disabled +page_track_resets disabled +page_track_partial_block_writes disabled +page_track_full_block_writes disabled +page_track_checkpoint_partial_flush_request disabled +module_dblwr disabled +dblwr_async_requests disabled +dblwr_sync_requests disabled +dblwr_flush_requests disabled +dblwr_flush_wait_events disabled +set global innodb_monitor_enable = all; +select name from information_schema.innodb_metrics where status!='enabled'; +name +set global innodb_monitor_enable = aaa; +ERROR 42000: Variable 'innodb_monitor_enable' can't be set to the value of 'aaa' +set global innodb_monitor_disable = All; +select name from information_schema.innodb_metrics where status!='disabled'; +name +set global innodb_monitor_reset_all = all; +select name from information_schema.innodb_metrics where count!=0; +name +set global innodb_monitor_enable = "%lock%"; +select name from information_schema.innodb_metrics +where status != IF(name like "%lock%", 'enabled', 'disabled'); +name +set global innodb_monitor_disable = "%lock%"; +select name, status from information_schema.innodb_metrics +where name like "%lock%"; +name status +lock_deadlocks disabled +lock_deadlock_false_positives disabled +lock_deadlock_rounds disabled +lock_threads_waiting disabled +lock_timeouts disabled +lock_rec_lock_waits disabled +lock_table_lock_waits disabled +lock_rec_lock_requests disabled +lock_rec_release_attempts disabled +lock_rec_grant_attempts disabled +lock_rec_lock_created disabled +lock_rec_lock_removed disabled +lock_rec_locks disabled +lock_table_lock_created disabled +lock_table_lock_removed disabled +lock_table_locks disabled +lock_row_lock_current_waits disabled +lock_row_lock_time disabled +lock_row_lock_time_max disabled +lock_row_lock_waits disabled +lock_row_lock_time_avg disabled +lock_schedule_refreshes disabled +log_full_block_writes disabled +log_partial_block_writes disabled +innodb_rwlock_s_spin_waits disabled +innodb_rwlock_x_spin_waits disabled +innodb_rwlock_sx_spin_waits disabled +innodb_rwlock_s_spin_rounds disabled +innodb_rwlock_x_spin_rounds disabled +innodb_rwlock_sx_spin_rounds disabled +innodb_rwlock_s_os_waits disabled +innodb_rwlock_x_os_waits disabled +innodb_rwlock_sx_os_waits disabled +page_track_partial_block_writes disabled +page_track_full_block_writes disabled +set global innodb_monitor_enable = "%lock*"; +ERROR 42000: Variable 'innodb_monitor_enable' can't be set to the value of '%lock*' +set global innodb_monitor_enable="%%%%%%%%%%%%%%%%%%%%%%%%%%%"; +select name from information_schema.innodb_metrics where status!='enabled'; +name +set global innodb_monitor_disable="%%%%%"; +select name from information_schema.innodb_metrics where status!='disabled'; +name +set global innodb_monitor_enable="%"; +select name from information_schema.innodb_metrics where status!='enabled'; +name +set global innodb_monitor_disable="%_%"; +select name from information_schema.innodb_metrics where status!='disabled'; +name +set global innodb_monitor_enable="log%%%%"; +select name from information_schema.innodb_metrics +where status != IF(name like "log%", 'enabled', 'disabled'); +name +set global innodb_monitor_enable="os_%a_fs_ncs"; +set global innodb_monitor_enable="os%pending%"; +select name, status from information_schema.innodb_metrics +where name like "os%"; +name status +os_data_reads disabled +os_data_writes disabled +os_data_fsyncs enabled +os_pending_reads enabled +os_pending_writes enabled +os_log_bytes_written disabled +os_log_fsyncs disabled +os_log_pending_fsyncs enabled +os_log_pending_writes enabled +set global innodb_monitor_enable=""; +ERROR 42000: Variable 'innodb_monitor_enable' can't be set to the value of '' +set global innodb_monitor_enable="_"; +ERROR 42000: Variable 'innodb_monitor_enable' can't be set to the value of '_' +create table monitor_test(col int) engine = innodb; +drop table monitor_test; +set global innodb_monitor_disable = module_metadata; +set global innodb_monitor_reset_all = module_metadata; +set global innodb_monitor_enable = metadata_table_handles_opened; +create table monitor_test(col int) engine = innodb; +select * from monitor_test; +col +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name = "metadata_table_handles_opened"; +name max_count min_count count max_count_reset min_count_reset count_reset status +metadata_table_handles_opened 3 NULL 3 3 NULL 3 enabled +set global innodb_monitor_reset = metadata_table_handles_opened; +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name = "metadata_table_handles_opened"; +name max_count min_count count max_count_reset min_count_reset count_reset status +metadata_table_handles_opened 3 NULL 3 NULL NULL 0 enabled +drop table monitor_test; +create table monitor_test(col int) engine = innodb; +select * from monitor_test; +col +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name = "metadata_table_handles_opened"; +name max_count min_count count max_count_reset min_count_reset count_reset status +metadata_table_handles_opened 6 NULL 6 3 NULL 3 enabled +set global innodb_monitor_reset_all = metadata_table_handles_opened; +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name = "metadata_table_handles_opened"; +name max_count min_count count max_count_reset min_count_reset count_reset status +metadata_table_handles_opened 6 NULL 6 3 NULL 3 enabled +set global innodb_monitor_disable = metadata_table_handles_opened; +set global innodb_monitor_reset = metadata_table_handles_opened; +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name = "metadata_table_handles_opened"; +name max_count min_count count max_count_reset min_count_reset count_reset status +metadata_table_handles_opened 6 NULL 6 NULL NULL 0 disabled +drop table monitor_test; +create table monitor_test(col int) engine = innodb; +select * from monitor_test; +col +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name = "metadata_table_handles_opened"; +name max_count min_count count max_count_reset min_count_reset count_reset status +metadata_table_handles_opened 6 NULL 6 NULL NULL 0 disabled +set global innodb_monitor_reset_all = metadata_table_handles_opened; +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name = "metadata_table_handles_opened"; +name max_count min_count count max_count_reset min_count_reset count_reset status +metadata_table_handles_opened NULL NULL 0 NULL NULL 0 disabled +set global innodb_monitor_enable = metadata_table_handles_opened; +drop table monitor_test; +create table monitor_test(col int) engine = innodb stats_persistent=0; +select * from monitor_test; +col +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name = "metadata_table_handles_opened"; +name max_count min_count count max_count_reset min_count_reset count_reset status +metadata_table_handles_opened 3 NULL 3 3 NULL 3 enabled +set global innodb_monitor_enable = metadata_table_handles_closed; +create index idx on monitor_test(col); +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name = "metadata_table_handles_closed"; +name max_count min_count count max_count_reset min_count_reset count_reset status +metadata_table_handles_closed 3 NULL 3 3 NULL 3 enabled +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name like "metadata%"; +name max_count min_count count max_count_reset min_count_reset count_reset status +metadata_table_handles_opened 4 NULL 4 4 NULL 4 enabled +metadata_table_handles_closed 3 NULL 3 3 NULL 3 enabled +metadata_table_reference_count NULL NULL 0 NULL NULL 0 disabled +set global innodb_monitor_disable = module_metadata; +set global innodb_monitor_reset = module_metadata; +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name like "metadata%"; +name max_count min_count count max_count_reset min_count_reset count_reset status +metadata_table_handles_opened 4 NULL 4 NULL NULL 0 disabled +metadata_table_handles_closed 3 NULL 3 NULL NULL 0 disabled +metadata_table_reference_count NULL NULL 0 NULL NULL 0 disabled +set global innodb_monitor_reset_all = module_metadata; +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name like "metadata%"; +name max_count min_count count max_count_reset min_count_reset count_reset status +metadata_table_handles_opened NULL NULL 0 NULL NULL 0 disabled +metadata_table_handles_closed NULL NULL 0 NULL NULL 0 disabled +metadata_table_reference_count NULL NULL 0 NULL NULL 0 disabled +set global innodb_monitor_enable = module_trx; +begin; +insert into monitor_test values(9); +commit; +begin; +insert into monitor_test values(9); +rollback; +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name like "trx_rollbacks" or name like "trx_active_transactions"; +name max_count min_count count max_count_reset min_count_reset count_reset status +trx_rollbacks 1 NULL 1 1 NULL 1 enabled +trx_active_transactions 1 0 0 1 0 0 enabled +set global innodb_monitor_disable = module_trx; +set global innodb_monitor_enable = module_dml; +insert into monitor_test values(9); +update monitor_test set col = 10 where col = 9; +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name like "dml%"; +name max_count min_count count max_count_reset min_count_reset count_reset status +dml_reads 4 NULL 4 4 NULL 4 enabled +dml_inserts 1 NULL 1 1 NULL 1 enabled +dml_deletes 0 NULL 0 0 NULL 0 enabled +dml_updates 2 NULL 2 2 NULL 2 enabled +dml_system_reads 0 NULL 0 0 NULL 0 enabled +dml_system_inserts 0 NULL 0 0 NULL 0 enabled +dml_system_deletes 0 NULL 0 0 NULL 0 enabled +dml_system_updates 0 NULL 0 0 NULL 0 enabled +delete from monitor_test; +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name like "dml%"; +name max_count min_count count max_count_reset min_count_reset count_reset status +dml_reads 6 NULL 6 6 NULL 6 enabled +dml_inserts 1 NULL 1 1 NULL 1 enabled +dml_deletes 2 NULL 2 2 NULL 2 enabled +dml_updates 2 NULL 2 2 NULL 2 enabled +dml_system_reads 0 NULL 0 0 NULL 0 enabled +dml_system_inserts 0 NULL 0 0 NULL 0 enabled +dml_system_deletes 0 NULL 0 0 NULL 0 enabled +dml_system_updates 0 NULL 0 0 NULL 0 enabled +set global innodb_monitor_reset = module_dml; +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name like "dml%"; +name max_count min_count count max_count_reset min_count_reset count_reset status +dml_reads 6 NULL 6 0 NULL 0 enabled +dml_inserts 1 NULL 1 0 NULL 0 enabled +dml_deletes 2 NULL 2 0 NULL 0 enabled +dml_updates 2 NULL 2 0 NULL 0 enabled +dml_system_reads 0 NULL 0 0 NULL 0 enabled +dml_system_inserts 0 NULL 0 0 NULL 0 enabled +dml_system_deletes 0 NULL 0 0 NULL 0 enabled +dml_system_updates 0 NULL 0 0 NULL 0 enabled +insert into monitor_test values(9); +insert into monitor_test values(1); +delete from monitor_test; +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name like "dml%"; +name max_count min_count count max_count_reset min_count_reset count_reset status +dml_reads 8 NULL 8 2 NULL 2 enabled +dml_inserts 3 NULL 3 2 NULL 2 enabled +dml_deletes 4 NULL 4 2 NULL 2 enabled +dml_updates 2 NULL 2 0 NULL 0 enabled +dml_system_reads 0 NULL 0 0 NULL 0 enabled +dml_system_inserts 0 NULL 0 0 NULL 0 enabled +dml_system_deletes 0 NULL 0 0 NULL 0 enabled +dml_system_updates 0 NULL 0 0 NULL 0 enabled +set global innodb_monitor_reset_all = module_dml; +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name like "dml%"; +name max_count min_count count max_count_reset min_count_reset count_reset status +dml_reads 8 NULL 8 2 NULL 2 enabled +dml_inserts 3 NULL 3 2 NULL 2 enabled +dml_deletes 4 NULL 4 2 NULL 2 enabled +dml_updates 2 NULL 2 0 NULL 0 enabled +dml_system_reads 0 NULL 0 0 NULL 0 enabled +dml_system_inserts 0 NULL 0 0 NULL 0 enabled +dml_system_deletes 0 NULL 0 0 NULL 0 enabled +dml_system_updates 0 NULL 0 0 NULL 0 enabled +set global innodb_monitor_disable = module_dml; +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name like "dml%"; +name max_count min_count count max_count_reset min_count_reset count_reset status +dml_reads 8 NULL 8 2 NULL 2 disabled +dml_inserts 3 NULL 3 2 NULL 2 disabled +dml_deletes 4 NULL 4 2 NULL 2 disabled +dml_updates 2 NULL 2 0 NULL 0 disabled +dml_system_reads 0 NULL 0 0 NULL 0 disabled +dml_system_inserts 0 NULL 0 0 NULL 0 disabled +dml_system_deletes 0 NULL 0 0 NULL 0 disabled +dml_system_updates 0 NULL 0 0 NULL 0 disabled +set global innodb_monitor_reset_all = module_dml; +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name like "dml%"; +name max_count min_count count max_count_reset min_count_reset count_reset status +dml_reads NULL NULL 0 NULL NULL 0 disabled +dml_inserts NULL NULL 0 NULL NULL 0 disabled +dml_deletes NULL NULL 0 NULL NULL 0 disabled +dml_updates NULL NULL 0 NULL NULL 0 disabled +dml_system_reads NULL NULL 0 NULL NULL 0 disabled +dml_system_inserts NULL NULL 0 NULL NULL 0 disabled +dml_system_deletes NULL NULL 0 NULL NULL 0 disabled +dml_system_updates NULL NULL 0 NULL NULL 0 disabled +set global innodb_monitor_enable = dml_inserts; +insert into monitor_test values(9); +insert into monitor_test values(1); +delete from monitor_test; +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name like "dml%"; +name max_count min_count count max_count_reset min_count_reset count_reset status +dml_reads NULL NULL 0 NULL NULL 0 disabled +dml_inserts 2 NULL 2 2 NULL 2 enabled +dml_deletes NULL NULL 0 NULL NULL 0 disabled +dml_updates NULL NULL 0 NULL NULL 0 disabled +dml_system_reads NULL NULL 0 NULL NULL 0 disabled +dml_system_inserts NULL NULL 0 NULL NULL 0 disabled +dml_system_deletes NULL NULL 0 NULL NULL 0 disabled +dml_system_updates NULL NULL 0 NULL NULL 0 disabled +set global innodb_monitor_disable = module_dml; +drop table monitor_test; +set global innodb_monitor_enable = file_num_open_files; +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name like "file_num_open_files"; +name max_count min_count count max_count_reset min_count_reset count_reset status +file_num_open_files # # # # # # enabled +set global innodb_monitor_disable = file_num_open_files; +set global innodb_monitor_enable = "icp%"; +create table monitor_test(a char(3), b int, c char(2), +primary key (a(1), c(1)), key(b)) engine = innodb; +insert into monitor_test values("13", 2, "aa"); +select a from monitor_test where b < 1 for update; +a +select name, count from information_schema.innodb_metrics +where name like "icp%"; +name count +icp_attempts 1 +icp_no_match 0 +icp_out_of_range 1 +icp_match 0 +select a from monitor_test where b < 3 for update; +a +13 +select name, count from information_schema.innodb_metrics +where name like "icp%"; +name count +icp_attempts 2 +icp_no_match 0 +icp_out_of_range 1 +icp_match 1 +drop table monitor_test; +set global innodb_monitor_disable = all; +set global innodb_monitor_reset_all = all; +select 1 from `information_schema`.`INNODB_METRICS` +where case (1) when (1) then (AVG_COUNT_RESET) else (1) end; +1 +set global innodb_monitor_enable = default; +set global innodb_monitor_disable = default; +set global innodb_monitor_reset = default; +set global innodb_monitor_reset_all = default; +# +# Bug#22576241 SETTING INNODB_MONITOR_ENABLE TO ALL DOES NOT ENABLE ALL +# MONITORS +# +CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=InnoDB; +SELECT NAME, COUNT FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE NAME +LIKE 'buffer_page_written_index_leaf'; +NAME COUNT +buffer_page_written_index_leaf 0 +SET GLOBAL innodb_monitor_enable='module_buffer_page'; +INSERT INTO t1 VALUES (1), (2), (3), (4); +FLUSH TABLES t1 FOR EXPORT; +UNLOCK TABLES; +SELECT NAME, COUNT FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE NAME +LIKE 'buffer_page_written_index_leaf'; +NAME COUNT +buffer_page_written_index_leaf NNNN +SET GLOBAL innodb_monitor_disable='module_buffer_page'; +SET GLOBAL innodb_monitor_reset_all='module_buffer_page'; +SELECT NAME, COUNT FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE NAME +LIKE 'buffer_page_written_index_leaf'; +NAME COUNT +buffer_page_written_index_leaf 0 +SET GLOBAL innodb_monitor_enable='%'; +INSERT INTO t1 VALUES (5), (6), (7), (8); +FLUSH TABLES t1 FOR EXPORT; +UNLOCK TABLES; +SELECT NAME, COUNT FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE NAME +LIKE 'buffer_page_written_index_leaf'; +NAME COUNT +buffer_page_written_index_leaf NNNN +SET GLOBAL innodb_monitor_disable='%'; +SET GLOBAL innodb_monitor_reset_all='%'; +SELECT NAME, COUNT FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE NAME +LIKE 'buffer_page_written_index_leaf'; +NAME COUNT +buffer_page_written_index_leaf 0 +SET GLOBAL innodb_monitor_enable='ALL'; +INSERT INTO t1 VALUES (9), (10), (11), (12); +FLUSH TABLES t1 FOR EXPORT; +UNLOCK TABLES; +SELECT NAME, COUNT FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE NAME +LIKE 'buffer_page_written_index_leaf'; +NAME COUNT +buffer_page_written_index_leaf NNNN +DROP TABLE t1; diff --git a/mysql-test/suite/opt_hints_index_merge.result-pq b/mysql-test/suite/opt_hints_index_merge.result-pq new file mode 100644 index 000000000000..74f9de2c1de5 --- /dev/null +++ b/mysql-test/suite/opt_hints_index_merge.result-pq @@ -0,0 +1,1362 @@ +CREATE TABLE t1 (f1 INT, f2 INT, f3 CHAR(1), f4 CHAR(1), f5 CHAR(1), f6 CHAR(1), +PRIMARY KEY (f5, f1), KEY (f2), KEY (f3), KEY (f4)) ENGINE=INNODB; +INSERT INTO t1 VALUES (1, 1, 'a', 'h', 'i', ''), (2, 3, 'a', 'h', 'i', ''), (3, 2, 'b', '', 'j', ''), (4, 2, 'b', '', 'j', ''); +INSERT INTO t1 VALUES (5, 1, 'a', 'h', 'i', ''), (6, 3, 'a', 'h', 'i', ''), (7, 2, 'b', '', 'j', ''), (8, 2, 'b', '', 'j', ''); +INSERT INTO t1 SELECT f1 + 8, f2, f3, f4, f5, f6 FROM t1; +INSERT INTO t1 SELECT f1 + 16, f2, f3, f4, f5, f6 FROM t1; +INSERT INTO t1 VALUES (33, 3, 'c', 'g', '', ''), (34, 4, 'c', 'g', '', ''), (35, 5, 'd', 'f', '', ''), (36, 6, 'd', 'f', '', ''); +INSERT INTO t1 SELECT f1 + 36, f2, f3, f4, f5, f6 FROM t1; +INSERT INTO t1 SELECT f1 + 72, f2, f3, f4, f5, f6 FROM t1; +INSERT INTO t1 SELECT f1 + 144, f2, f3, f4, f5, f6 FROM t1; +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +SET optimizer_trace_max_mem_size=1048576; +SET end_markers_in_json=on; +SET optimizer_trace="enabled=on,one_line=off"; +SET optimizer_switch='index_merge_union=off,index_merge=off'; +EXPLAIN SELECT /*+ INDEX_MERGE(t1 f2, f3) */ f1 FROM t1 WHERE f2 = 5 OR f3 = 'c' OR f4 = 'f'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 288 53.12 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL f2,f3,f4 NULL NULL NULL 288 53.12 Using where +Warnings: +Note 1003 /* select#1 */ select /*+ INDEX_MERGE(`t1`@`select#1` `f2`, `f3`) */ `test`.`t1`.`f1` AS `f1` from `test`.`t1` where ((`test`.`t1`.`f2` = 5) or (`test`.`t1`.`f3` = 'c') or (`test`.`t1`.`f4` = 'f')) +SELECT * FROM information_schema.OPTIMIZER_TRACE; +QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES +EXPLAIN SELECT /*+ INDEX_MERGE(t1 f2, f3) */ f1 FROM t1 WHERE f2 = 5 OR f3 = 'c' OR f4 = 'f' { + "steps": [ + { + "join_preparation": { + "select#": 1, + "steps": [ + { + "expanded_query": "/* select#1 */ select /*+ INDEX_MERGE(`t1`@`select#1` `f2`, `f3`) */ `t1`.`f1` AS `f1` from `t1` where ((`t1`.`f2` = 5) or (`t1`.`f3` = 'c') or (`t1`.`f4` = 'f'))" + } + ] /* steps */ + } /* join_preparation */ + }, + { + "join_optimization": { + "select#": 1, + "steps": [ + { + "condition_processing": { + "condition": "WHERE", + "original_condition": "((`t1`.`f2` = 5) or (`t1`.`f3` = 'c') or (`t1`.`f4` = 'f'))", + "steps": [ + { + "transformation": "equality_propagation", + "resulting_condition": "(multiple equal(5, `t1`.`f2`) or multiple equal('c', `t1`.`f3`) or multiple equal('f', `t1`.`f4`))" + }, + { + "transformation": "constant_propagation", + "resulting_condition": "(multiple equal(5, `t1`.`f2`) or multiple equal('c', `t1`.`f3`) or multiple equal('f', `t1`.`f4`))" + }, + { + "transformation": "trivial_condition_removal", + "resulting_condition": "(multiple equal(5, `t1`.`f2`) or multiple equal('c', `t1`.`f3`) or multiple equal('f', `t1`.`f4`))" + } + ] /* steps */ + } /* condition_processing */ + }, + { + "substitute_generated_columns": { + } /* substitute_generated_columns */ + }, + { + "table_dependencies": [ + { + "table": "`t1`", + "row_may_be_null": false, + "map_bit": 0, + "depends_on_map_bits": [ + ] /* depends_on_map_bits */ + } + ] /* table_dependencies */ + }, + { + "ref_optimizer_key_uses": [ + ] /* ref_optimizer_key_uses */ + }, + { + "rows_estimation": [ + { + "table": "`t1`", + "range_analysis": { + "table_scan": { + "rows": 288, + "cost": 31.15 + } /* table_scan */, + "potential_range_indexes": [ + { + "index": "PRIMARY", + "usable": false, + "cause": "not_applicable" + }, + { + "index": "f2", + "usable": true, + "key_parts": [ + "f2", + "f5", + "f1" + ] /* key_parts */ + }, + { + "index": "f3", + "usable": true, + "key_parts": [ + "f3", + "f5", + "f1" + ] /* key_parts */ + }, + { + "index": "f4", + "usable": true, + "key_parts": [ + "f4", + "f5", + "f1" + ] /* key_parts */ + } + ] /* potential_range_indexes */, + "setup_range_conditions": [ + ] /* setup_range_conditions */, + "group_index_range": { + "chosen": false, + "cause": "not_group_by_or_distinct" + } /* group_index_range */, + "skip_scan_range": { + "potential_skip_scan_indexes": [ + { + "index": "f2", + "usable": false, + "cause": "query_references_nonkey_column" + }, + { + "index": "f3", + "usable": false, + "cause": "query_references_nonkey_column" + }, + { + "index": "f4", + "usable": false, + "cause": "query_references_nonkey_column" + } + ] /* potential_skip_scan_indexes */ + } /* skip_scan_range */, + "analyzing_range_alternatives": { + "range_scan_alternatives": [ + ] /* range_scan_alternatives */, + "analyzing_roworder_intersect": { + "usable": false, + "cause": "too_few_roworder_scans" + } /* analyzing_roworder_intersect */ + } /* analyzing_range_alternatives */, + "analyzing_index_merge_union": [ + { + "indexes_to_merge": [ + { + "range_scan_alternatives": [ + { + "index": "f2", + "ranges": [ + "5 <= f2 <= 5" + ] /* ranges */, + "index_dives_for_eq_ranges": true, + "rowid_ordered": true, + "using_mrr": false, + "index_only": true, + "rows": 8, + "cost": 1.06277, + "chosen": true + } + ] /* range_scan_alternatives */, + "index_to_merge": "f2", + "cumulated_cost": 1.06277 + }, + { + "range_scan_alternatives": [ + { + "index": "f3", + "ranges": [ + "c <= f3 <= c" + ] /* ranges */, + "index_dives_for_eq_ranges": true, + "rowid_ordered": true, + "using_mrr": false, + "index_only": true, + "rows": 16, + "cost": 1.86594, + "chosen": true + } + ] /* range_scan_alternatives */, + "index_to_merge": "f3", + "cumulated_cost": 2.92872 + }, + { + "range_scan_alternatives": [ + { + "index": "f4", + "chosen": false, + "cause": "index_merge_hint" + } + ] /* range_scan_alternatives */, + "chosen": false, + "cause": "cost" + } + ] /* indexes_to_merge */, + "cost_of_reading_ranges": 2.92872, + "chosen": false, + "cause": "cost" + } + ] /* analyzing_index_merge_union */ + } /* range_analysis */ + } + ] /* rows_estimation */ + }, + { + "considered_execution_plans": [ + { + "plan_prefix": [ + ] /* plan_prefix */, + "table": "`t1`", + "best_access_path": { + "considered_access_paths": [ + { + "rows_to_scan": 288, + "filtering_effect": [ + ] /* filtering_effect */, + "final_filtering_effect": 0.53125, + "access_type": "scan", + "resulting_rows": 153, + "cost": 29.05, + "chosen": true + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 100, + "rows_for_plan": 153, + "cost_for_plan": 29.05, + "chosen": true + } + ] /* considered_execution_plans */ + }, + { + "attaching_conditions_to_tables": { + "original_condition": "((`t1`.`f2` = 5) or (`t1`.`f3` = 'c') or (`t1`.`f4` = 'f'))", + "attached_conditions_computation": [ + ] /* attached_conditions_computation */, + "attached_conditions_summary": [ + { + "table": "`t1`", + "attached": "((`t1`.`f2` = 5) or (`t1`.`f3` = 'c') or (`t1`.`f4` = 'f'))" + } + ] /* attached_conditions_summary */ + } /* attaching_conditions_to_tables */ + }, + { + "finalizing_table_conditions": [ + { + "table": "`t1`", + "original_table_condition": "((`t1`.`f2` = 5) or (`t1`.`f3` = 'c') or (`t1`.`f4` = 'f'))", + "final_table_condition ": "((`t1`.`f2` = 5) or (`t1`.`f3` = 'c') or (`t1`.`f4` = 'f'))" + } + ] /* finalizing_table_conditions */ + }, + { + "refine_plan": [ + { + "table": "`t1`" + } + ] /* refine_plan */ + } + ] /* steps */ + } /* join_optimization */ + }, + { + "make_parallel_query_plan": { + "select#": 1, + "detail": [ + { + "table": "`t1`", + "degree of parallel": 4 + } + ] /* detail */ + } /* make_parallel_query_plan */ + }, + { + "join_explain": { + "select#": 1, + "steps": [ + ] /* steps */ + } /* join_explain */ + } + ] /* steps */ +} 0 0 +SET optimizer_switch='index_merge=on,index_merge_intersection=on'; +EXPLAIN SELECT /*+ NO_INDEX_MERGE(t1 f3) */ COUNT(*) FROM t1 WHERE f4 = 'h' AND f2 = 2 AND f3 = 'b'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 128 19.75 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref f2,f3,f4 f2 5 const 128 19.75 Using where +Warnings: +Note 1003 /* select#1 */ select /*+ NO_INDEX_MERGE(`t1`@`select#1` `f3`) */ count(0) AS `COUNT(*)` from `test`.`t1` where ((`test`.`t1`.`f3` = 'b') and (`test`.`t1`.`f2` = 2) and (`test`.`t1`.`f4` = 'h')) +SELECT * FROM information_schema.OPTIMIZER_TRACE; +QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES +EXPLAIN SELECT /*+ NO_INDEX_MERGE(t1 f3) */ COUNT(*) FROM t1 WHERE f4 = 'h' AND f2 = 2 AND f3 = 'b' { + "steps": [ + { + "join_preparation": { + "select#": 1, + "steps": [ + { + "expanded_query": "/* select#1 */ select /*+ NO_INDEX_MERGE(`t1`@`select#1` `f3`) */ count(0) AS `COUNT(*)` from `t1` where ((`t1`.`f4` = 'h') and (`t1`.`f2` = 2) and (`t1`.`f3` = 'b'))" + } + ] /* steps */ + } /* join_preparation */ + }, + { + "join_optimization": { + "select#": 1, + "steps": [ + { + "condition_processing": { + "condition": "WHERE", + "original_condition": "((`t1`.`f4` = 'h') and (`t1`.`f2` = 2) and (`t1`.`f3` = 'b'))", + "steps": [ + { + "transformation": "equality_propagation", + "resulting_condition": "(multiple equal('h', `t1`.`f4`) and multiple equal(2, `t1`.`f2`) and multiple equal('b', `t1`.`f3`))" + }, + { + "transformation": "constant_propagation", + "resulting_condition": "(multiple equal('h', `t1`.`f4`) and multiple equal(2, `t1`.`f2`) and multiple equal('b', `t1`.`f3`))" + }, + { + "transformation": "trivial_condition_removal", + "resulting_condition": "(multiple equal('h', `t1`.`f4`) and multiple equal(2, `t1`.`f2`) and multiple equal('b', `t1`.`f3`))" + } + ] /* steps */ + } /* condition_processing */ + }, + { + "substitute_generated_columns": { + } /* substitute_generated_columns */ + }, + { + "table_dependencies": [ + { + "table": "`t1`", + "row_may_be_null": false, + "map_bit": 0, + "depends_on_map_bits": [ + ] /* depends_on_map_bits */ + } + ] /* table_dependencies */ + }, + { + "ref_optimizer_key_uses": [ + { + "table": "`t1`", + "field": "f2", + "equals": "2", + "null_rejecting": true + }, + { + "table": "`t1`", + "field": "f3", + "equals": "'b'", + "null_rejecting": true + }, + { + "table": "`t1`", + "field": "f4", + "equals": "'h'", + "null_rejecting": true + } + ] /* ref_optimizer_key_uses */ + }, + { + "rows_estimation": [ + { + "table": "`t1`", + "range_analysis": { + "table_scan": { + "rows": 288, + "cost": 31.15 + } /* table_scan */, + "potential_range_indexes": [ + { + "index": "PRIMARY", + "usable": false, + "cause": "not_applicable" + }, + { + "index": "f2", + "usable": true, + "key_parts": [ + "f2", + "f5", + "f1" + ] /* key_parts */ + }, + { + "index": "f3", + "usable": true, + "key_parts": [ + "f3", + "f5", + "f1" + ] /* key_parts */ + }, + { + "index": "f4", + "usable": true, + "key_parts": [ + "f4", + "f5", + "f1" + ] /* key_parts */ + } + ] /* potential_range_indexes */, + "setup_range_conditions": [ + ] /* setup_range_conditions */, + "group_index_range": { + "chosen": false, + "cause": "not_group_by_or_distinct" + } /* group_index_range */, + "skip_scan_range": { + "potential_skip_scan_indexes": [ + { + "index": "f2", + "usable": false, + "cause": "query_references_nonkey_column" + }, + { + "index": "f3", + "usable": false, + "cause": "query_references_nonkey_column" + }, + { + "index": "f4", + "usable": false, + "cause": "query_references_nonkey_column" + } + ] /* potential_skip_scan_indexes */ + } /* skip_scan_range */, + "analyzing_range_alternatives": { + "range_scan_alternatives": [ + { + "index": "f2", + "ranges": [ + "2 <= f2 <= 2" + ] /* ranges */, + "index_dives_for_eq_ranges": true, + "rowid_ordered": true, + "using_mrr": false, + "index_only": false, + "rows": 128, + "cost": 45.06, + "chosen": false, + "cause": "cost" + }, + { + "index": "f3", + "chosen": false, + "cause": "index_merge_hint" + }, + { + "index": "f4", + "ranges": [ + "h <= f4 <= h" + ] /* ranges */, + "index_dives_for_eq_ranges": true, + "rowid_ordered": true, + "using_mrr": false, + "index_only": false, + "rows": 128, + "cost": 45.06, + "chosen": false, + "cause": "cost" + } + ] /* range_scan_alternatives */, + "analyzing_roworder_intersect": { + "intersecting_indexes": [ + { + "index": "f2", + "index_scan_cost": 0.300317, + "cumulated_index_scan_cost": 0.300317, + "disk_sweep_cost": 1, + "cumulated_total_cost": 1.30032, + "usable": true, + "matching_rows_now": 128, + "isect_covering_with_this_index": false, + "chosen": true + }, + { + "index": "f4", + "index_scan_cost": 0.300317, + "cumulated_index_scan_cost": 0.600634, + "disk_sweep_cost": 1, + "cumulated_total_cost": 1.60063, + "usable": true, + "matching_rows_now": 56.8889, + "isect_covering_with_this_index": false, + "chosen": false, + "cause": "does_not_reduce_cost" + } + ] /* intersecting_indexes */, + "clustered_pk": { + "clustered_pk_added_to_intersect": false, + "cause": "no_clustered_pk_index" + } /* clustered_pk */, + "chosen": false, + "cause": "too_few_indexes_to_merge" + } /* analyzing_roworder_intersect */ + } /* analyzing_range_alternatives */ + } /* range_analysis */ + } + ] /* rows_estimation */ + }, + { + "considered_execution_plans": [ + { + "plan_prefix": [ + ] /* plan_prefix */, + "table": "`t1`", + "best_access_path": { + "considered_access_paths": [ + { + "access_type": "ref", + "index": "f2", + "rows": 128, + "cost": 13.55, + "chosen": true + }, + { + "access_type": "ref", + "index": "f3", + "rows": 128, + "cost": 13.55, + "chosen": false + }, + { + "access_type": "ref", + "index": "f4", + "rows": 128, + "cost": 13.55, + "chosen": false + }, + { + "rows_to_scan": 288, + "filtering_effect": [ + ] /* filtering_effect */, + "final_filtering_effect": 0.0877915, + "access_type": "scan", + "resulting_rows": 25.284, + "cost": 29.05, + "chosen": false + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 19.7531, + "rows_for_plan": 25.284, + "cost_for_plan": 13.55, + "chosen": true + } + ] /* considered_execution_plans */ + }, + { + "attaching_conditions_to_tables": { + "original_condition": "((`t1`.`f3` = 'b') and (`t1`.`f2` = 2) and (`t1`.`f4` = 'h'))", + "attached_conditions_computation": [ + ] /* attached_conditions_computation */, + "attached_conditions_summary": [ + { + "table": "`t1`", + "attached": "((`t1`.`f3` = 'b') and (`t1`.`f2` = 2) and (`t1`.`f4` = 'h'))" + } + ] /* attached_conditions_summary */ + } /* attaching_conditions_to_tables */ + }, + { + "optimizing_distinct_group_by_order_by": { + } /* optimizing_distinct_group_by_order_by */ + }, + { + "finalizing_table_conditions": [ + { + "table": "`t1`", + "original_table_condition": "((`t1`.`f3` = 'b') and (`t1`.`f2` = 2) and (`t1`.`f4` = 'h'))", + "final_table_condition ": "((`t1`.`f3` = 'b') and (`t1`.`f4` = 'h'))" + } + ] /* finalizing_table_conditions */ + }, + { + "refine_plan": [ + { + "table": "`t1`" + } + ] /* refine_plan */ + }, + { + "considering_tmp_tables": [ + ] /* considering_tmp_tables */ + } + ] /* steps */ + } /* join_optimization */ + }, + { + "make_parallel_query_plan": { + "select#": 1, + "detail": [ + { + "table": "`t1`", + "degree of parallel": 4, + "unknown_key_1": { + "considering_tmp_tables": [ + { + "adding_tmp_table_in_plan_at_position": 0, + "cause": "output_for_parallel_query" + } + ] /* considering_tmp_tables */ + } + } + ] /* detail */ + } /* make_parallel_query_plan */ + }, + { + "join_explain": { + "select#": 1, + "steps": [ + ] /* steps */ + } /* join_explain */ + } + ] /* steps */ +} 0 0 +SET optimizer_switch='index_merge_union=off,index_merge=off'; +EXPLAIN SELECT /*+ INDEX_MERGE(t1 f2, f3, f4) */ * FROM t1 WHERE (f2 = 5 OR f3 = 'b') AND (f2 BETWEEN 300 AND 310 OR f4 = 'b'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge f2,f3,f4 f2,f4 5,5 NULL 2 100.00 Using sort_union(f2,f4); Using where +Warnings: +Note 1003 /* select#1 */ select /*+ INDEX_MERGE(`t1`@`select#1` `f2`, `f3`, `f4`) */ `test`.`t1`.`f1` AS `f1`,`test`.`t1`.`f2` AS `f2`,`test`.`t1`.`f3` AS `f3`,`test`.`t1`.`f4` AS `f4`,`test`.`t1`.`f5` AS `f5`,`test`.`t1`.`f6` AS `f6` from `test`.`t1` where (((`test`.`t1`.`f2` = 5) or (`test`.`t1`.`f3` = 'b')) and ((`test`.`t1`.`f2` between 300 and 310) or (`test`.`t1`.`f4` = 'b'))) +SELECT * FROM information_schema.OPTIMIZER_TRACE; +QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES +EXPLAIN SELECT /*+ INDEX_MERGE(t1 f2, f3, f4) */ * FROM t1 WHERE (f2 = 5 OR f3 = 'b') AND (f2 BETWEEN 300 AND 310 OR f4 = 'b') { + "steps": [ + { + "join_preparation": { + "select#": 1, + "steps": [ + { + "expanded_query": "/* select#1 */ select /*+ INDEX_MERGE(`t1`@`select#1` `f2`, `f3`, `f4`) */ `t1`.`f1` AS `f1`,`t1`.`f2` AS `f2`,`t1`.`f3` AS `f3`,`t1`.`f4` AS `f4`,`t1`.`f5` AS `f5`,`t1`.`f6` AS `f6` from `t1` where (((`t1`.`f2` = 5) or (`t1`.`f3` = 'b')) and ((`t1`.`f2` between 300 and 310) or (`t1`.`f4` = 'b')))" + } + ] /* steps */ + } /* join_preparation */ + }, + { + "join_optimization": { + "select#": 1, + "steps": [ + { + "condition_processing": { + "condition": "WHERE", + "original_condition": "(((`t1`.`f2` = 5) or (`t1`.`f3` = 'b')) and ((`t1`.`f2` between 300 and 310) or (`t1`.`f4` = 'b')))", + "steps": [ + { + "transformation": "equality_propagation", + "resulting_condition": "((multiple equal(5, `t1`.`f2`) or multiple equal('b', `t1`.`f3`)) and ((`t1`.`f2` between 300 and 310) or multiple equal('b', `t1`.`f4`)))" + }, + { + "transformation": "constant_propagation", + "resulting_condition": "((multiple equal(5, `t1`.`f2`) or multiple equal('b', `t1`.`f3`)) and ((`t1`.`f2` between 300 and 310) or multiple equal('b', `t1`.`f4`)))" + }, + { + "transformation": "trivial_condition_removal", + "resulting_condition": "((multiple equal(5, `t1`.`f2`) or multiple equal('b', `t1`.`f3`)) and ((`t1`.`f2` between 300 and 310) or multiple equal('b', `t1`.`f4`)))" + } + ] /* steps */ + } /* condition_processing */ + }, + { + "substitute_generated_columns": { + } /* substitute_generated_columns */ + }, + { + "table_dependencies": [ + { + "table": "`t1`", + "row_may_be_null": false, + "map_bit": 0, + "depends_on_map_bits": [ + ] /* depends_on_map_bits */ + } + ] /* table_dependencies */ + }, + { + "ref_optimizer_key_uses": [ + ] /* ref_optimizer_key_uses */ + }, + { + "rows_estimation": [ + { + "table": "`t1`", + "range_analysis": { + "table_scan": { + "rows": 288, + "cost": 31.15 + } /* table_scan */, + "potential_range_indexes": [ + { + "index": "PRIMARY", + "usable": false, + "cause": "not_applicable" + }, + { + "index": "f2", + "usable": true, + "key_parts": [ + "f2", + "f5", + "f1" + ] /* key_parts */ + }, + { + "index": "f3", + "usable": true, + "key_parts": [ + "f3", + "f5", + "f1" + ] /* key_parts */ + }, + { + "index": "f4", + "usable": true, + "key_parts": [ + "f4", + "f5", + "f1" + ] /* key_parts */ + } + ] /* potential_range_indexes */, + "setup_range_conditions": [ + ] /* setup_range_conditions */, + "group_index_range": { + "chosen": false, + "cause": "not_group_by_or_distinct" + } /* group_index_range */, + "skip_scan_range": { + "potential_skip_scan_indexes": [ + { + "index": "f2", + "usable": false, + "cause": "query_references_nonkey_column" + }, + { + "index": "f3", + "usable": false, + "cause": "query_references_nonkey_column" + }, + { + "index": "f4", + "usable": false, + "cause": "query_references_nonkey_column" + } + ] /* potential_skip_scan_indexes */ + } /* skip_scan_range */, + "analyzing_range_alternatives": { + "range_scan_alternatives": [ + ] /* range_scan_alternatives */, + "analyzing_roworder_intersect": { + "usable": false, + "cause": "too_few_roworder_scans" + } /* analyzing_roworder_intersect */ + } /* analyzing_range_alternatives */, + "analyzing_index_merge_union": [ + { + "indexes_to_merge": [ + { + "range_scan_alternatives": [ + { + "index": "f2", + "ranges": [ + "5 <= f2 <= 5" + ] /* ranges */, + "index_dives_for_eq_ranges": true, + "rowid_ordered": true, + "using_mrr": false, + "index_only": true, + "rows": 8, + "cost": 1.06277, + "chosen": true + } + ] /* range_scan_alternatives */, + "index_to_merge": "f2", + "cumulated_cost": 1.06277 + }, + { + "range_scan_alternatives": [ + { + "index": "f3", + "ranges": [ + "b <= f3 <= b" + ] /* ranges */, + "index_dives_for_eq_ranges": true, + "rowid_ordered": true, + "using_mrr": false, + "index_only": true, + "rows": 128, + "cost": 13.1103, + "chosen": true + } + ] /* range_scan_alternatives */, + "index_to_merge": "f3", + "cumulated_cost": 14.1731 + } + ] /* indexes_to_merge */, + "cost_of_reading_ranges": 14.1731, + "use_roworder_union": true, + "cause": "always_cheaper_than_not_roworder_retrieval", + "analyzing_roworder_scans": [ + { + "type": "range_scan", + "index": "f2", + "rows": 8, + "ranges": [ + "5 <= f2 <= 5" + ] /* ranges */, + "analyzing_roworder_intersect": { + "usable": false, + "cause": "too_few_roworder_scans" + } /* analyzing_roworder_intersect */ + }, + { + "type": "range_scan", + "index": "f3", + "rows": 128, + "ranges": [ + "b <= f3 <= b" + ] /* ranges */, + "analyzing_roworder_intersect": { + "usable": false, + "cause": "too_few_roworder_scans" + } /* analyzing_roworder_intersect */ + } + ] /* analyzing_roworder_scans */, + "index_roworder_union_cost": 21.9731, + "members": 2, + "chosen": true + }, + { + "indexes_to_merge": [ + { + "range_scan_alternatives": [ + { + "index": "f2", + "ranges": [ + "300 <= f2 <= 310" + ] /* ranges */, + "index_dives_for_eq_ranges": true, + "rowid_ordered": false, + "using_mrr": false, + "index_only": true, + "rows": 1, + "cost": 0.36, + "chosen": true + } + ] /* range_scan_alternatives */, + "index_to_merge": "f2", + "cumulated_cost": 0.36 + }, + { + "range_scan_alternatives": [ + { + "index": "f4", + "ranges": [ + "b <= f4 <= b" + ] /* ranges */, + "index_dives_for_eq_ranges": true, + "rowid_ordered": true, + "using_mrr": false, + "index_only": true, + "rows": 1, + "cost": 0.36, + "chosen": true + } + ] /* range_scan_alternatives */, + "index_to_merge": "f4", + "cumulated_cost": 0.72 + } + ] /* indexes_to_merge */, + "cost_of_reading_ranges": 0.72, + "cost_sort_rowid_and_read_disk": 0.4375, + "cost_duplicate_removal": 0.254503, + "total_cost": 1.412 + } + ] /* analyzing_index_merge_union */, + "chosen_range_access_summary": { + "range_access_plan": { + "type": "index_merge", + "index_merge_of": [ + { + "type": "range_scan", + "index": "f2", + "rows": 1, + "ranges": [ + "300 <= f2 <= 310" + ] /* ranges */ + }, + { + "type": "range_scan", + "index": "f4", + "rows": 1, + "ranges": [ + "b <= f4 <= b" + ] /* ranges */ + } + ] /* index_merge_of */ + } /* range_access_plan */, + "rows_for_plan": 2, + "cost_for_plan": 1.412, + "chosen": true + } /* chosen_range_access_summary */ + } /* range_analysis */ + } + ] /* rows_estimation */ + }, + { + "considered_execution_plans": [ + { + "plan_prefix": [ + ] /* plan_prefix */, + "table": "`t1`", + "best_access_path": { + "considered_access_paths": [ + { + "rows_to_scan": 2, + "filtering_effect": [ + ] /* filtering_effect */, + "final_filtering_effect": 1, + "access_type": "range", + "range_details": { + "used_index": "sort_union(f2,f4)" + } /* range_details */, + "resulting_rows": 2, + "cost": 1.612, + "chosen": true + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 100, + "rows_for_plan": 2, + "cost_for_plan": 1.612, + "chosen": true + } + ] /* considered_execution_plans */ + }, + { + "attaching_conditions_to_tables": { + "original_condition": "(((`t1`.`f2` = 5) or (`t1`.`f3` = 'b')) and ((`t1`.`f2` between 300 and 310) or (`t1`.`f4` = 'b')))", + "attached_conditions_computation": [ + ] /* attached_conditions_computation */, + "attached_conditions_summary": [ + { + "table": "`t1`", + "attached": "(((`t1`.`f2` = 5) or (`t1`.`f3` = 'b')) and ((`t1`.`f2` between 300 and 310) or (`t1`.`f4` = 'b')))" + } + ] /* attached_conditions_summary */ + } /* attaching_conditions_to_tables */ + }, + { + "finalizing_table_conditions": [ + { + "table": "`t1`", + "original_table_condition": "(((`t1`.`f2` = 5) or (`t1`.`f3` = 'b')) and ((`t1`.`f2` between 300 and 310) or (`t1`.`f4` = 'b')))", + "final_table_condition ": "(((`t1`.`f2` = 5) or (`t1`.`f3` = 'b')) and ((`t1`.`f2` between 300 and 310) or (`t1`.`f4` = 'b')))" + } + ] /* finalizing_table_conditions */ + }, + { + "refine_plan": [ + { + "table": "`t1`" + } + ] /* refine_plan */ + } + ] /* steps */ + } /* join_optimization */ + }, + { + "join_explain": { + "select#": 1, + "steps": [ + ] /* steps */ + } /* join_explain */ + } + ] /* steps */ +} 0 0 +EXPLAIN SELECT /*+ INDEX_MERGE(t1 f2, f3, f4) */ * FROM t1 WHERE (f2 = 5 OR f3 = 'b') AND (f2 BETWEEN 1 AND 10 OR f4 = 'b'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge f2,f3,f4 f2,f3 5,5 NULL 136 100.00 Using union(f2,f3); Using where +Warnings: +Note 1003 /* select#1 */ select /*+ INDEX_MERGE(`t1`@`select#1` `f2`, `f3`, `f4`) */ `test`.`t1`.`f1` AS `f1`,`test`.`t1`.`f2` AS `f2`,`test`.`t1`.`f3` AS `f3`,`test`.`t1`.`f4` AS `f4`,`test`.`t1`.`f5` AS `f5`,`test`.`t1`.`f6` AS `f6` from `test`.`t1` where (((`test`.`t1`.`f2` = 5) or (`test`.`t1`.`f3` = 'b')) and ((`test`.`t1`.`f2` between 1 and 10) or (`test`.`t1`.`f4` = 'b'))) +SELECT * FROM information_schema.OPTIMIZER_TRACE; +QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES +EXPLAIN SELECT /*+ INDEX_MERGE(t1 f2, f3, f4) */ * FROM t1 WHERE (f2 = 5 OR f3 = 'b') AND (f2 BETWEEN 1 AND 10 OR f4 = 'b') { + "steps": [ + { + "join_preparation": { + "select#": 1, + "steps": [ + { + "expanded_query": "/* select#1 */ select /*+ INDEX_MERGE(`t1`@`select#1` `f2`, `f3`, `f4`) */ `t1`.`f1` AS `f1`,`t1`.`f2` AS `f2`,`t1`.`f3` AS `f3`,`t1`.`f4` AS `f4`,`t1`.`f5` AS `f5`,`t1`.`f6` AS `f6` from `t1` where (((`t1`.`f2` = 5) or (`t1`.`f3` = 'b')) and ((`t1`.`f2` between 1 and 10) or (`t1`.`f4` = 'b')))" + } + ] /* steps */ + } /* join_preparation */ + }, + { + "join_optimization": { + "select#": 1, + "steps": [ + { + "condition_processing": { + "condition": "WHERE", + "original_condition": "(((`t1`.`f2` = 5) or (`t1`.`f3` = 'b')) and ((`t1`.`f2` between 1 and 10) or (`t1`.`f4` = 'b')))", + "steps": [ + { + "transformation": "equality_propagation", + "resulting_condition": "((multiple equal(5, `t1`.`f2`) or multiple equal('b', `t1`.`f3`)) and ((`t1`.`f2` between 1 and 10) or multiple equal('b', `t1`.`f4`)))" + }, + { + "transformation": "constant_propagation", + "resulting_condition": "((multiple equal(5, `t1`.`f2`) or multiple equal('b', `t1`.`f3`)) and ((`t1`.`f2` between 1 and 10) or multiple equal('b', `t1`.`f4`)))" + }, + { + "transformation": "trivial_condition_removal", + "resulting_condition": "((multiple equal(5, `t1`.`f2`) or multiple equal('b', `t1`.`f3`)) and ((`t1`.`f2` between 1 and 10) or multiple equal('b', `t1`.`f4`)))" + } + ] /* steps */ + } /* condition_processing */ + }, + { + "substitute_generated_columns": { + } /* substitute_generated_columns */ + }, + { + "table_dependencies": [ + { + "table": "`t1`", + "row_may_be_null": false, + "map_bit": 0, + "depends_on_map_bits": [ + ] /* depends_on_map_bits */ + } + ] /* table_dependencies */ + }, + { + "ref_optimizer_key_uses": [ + ] /* ref_optimizer_key_uses */ + }, + { + "rows_estimation": [ + { + "table": "`t1`", + "range_analysis": { + "table_scan": { + "rows": 288, + "cost": 31.15 + } /* table_scan */, + "potential_range_indexes": [ + { + "index": "PRIMARY", + "usable": false, + "cause": "not_applicable" + }, + { + "index": "f2", + "usable": true, + "key_parts": [ + "f2", + "f5", + "f1" + ] /* key_parts */ + }, + { + "index": "f3", + "usable": true, + "key_parts": [ + "f3", + "f5", + "f1" + ] /* key_parts */ + }, + { + "index": "f4", + "usable": true, + "key_parts": [ + "f4", + "f5", + "f1" + ] /* key_parts */ + } + ] /* potential_range_indexes */, + "setup_range_conditions": [ + ] /* setup_range_conditions */, + "group_index_range": { + "chosen": false, + "cause": "not_group_by_or_distinct" + } /* group_index_range */, + "skip_scan_range": { + "potential_skip_scan_indexes": [ + { + "index": "f2", + "usable": false, + "cause": "query_references_nonkey_column" + }, + { + "index": "f3", + "usable": false, + "cause": "query_references_nonkey_column" + }, + { + "index": "f4", + "usable": false, + "cause": "query_references_nonkey_column" + } + ] /* potential_skip_scan_indexes */ + } /* skip_scan_range */, + "analyzing_range_alternatives": { + "range_scan_alternatives": [ + ] /* range_scan_alternatives */, + "analyzing_roworder_intersect": { + "usable": false, + "cause": "too_few_roworder_scans" + } /* analyzing_roworder_intersect */ + } /* analyzing_range_alternatives */, + "analyzing_index_merge_union": [ + { + "indexes_to_merge": [ + { + "range_scan_alternatives": [ + { + "index": "f2", + "ranges": [ + "5 <= f2 <= 5" + ] /* ranges */, + "index_dives_for_eq_ranges": true, + "rowid_ordered": true, + "using_mrr": false, + "index_only": true, + "rows": 8, + "cost": 1.06277, + "chosen": true + } + ] /* range_scan_alternatives */, + "index_to_merge": "f2", + "cumulated_cost": 1.06277 + }, + { + "range_scan_alternatives": [ + { + "index": "f3", + "ranges": [ + "b <= f3 <= b" + ] /* ranges */, + "index_dives_for_eq_ranges": true, + "rowid_ordered": true, + "using_mrr": false, + "index_only": true, + "rows": 128, + "cost": 13.1103, + "chosen": true + } + ] /* range_scan_alternatives */, + "index_to_merge": "f3", + "cumulated_cost": 14.1731 + } + ] /* indexes_to_merge */, + "cost_of_reading_ranges": 14.1731, + "use_roworder_union": true, + "cause": "always_cheaper_than_not_roworder_retrieval", + "analyzing_roworder_scans": [ + { + "type": "range_scan", + "index": "f2", + "rows": 8, + "ranges": [ + "5 <= f2 <= 5" + ] /* ranges */, + "analyzing_roworder_intersect": { + "usable": false, + "cause": "too_few_roworder_scans" + } /* analyzing_roworder_intersect */ + }, + { + "type": "range_scan", + "index": "f3", + "rows": 128, + "ranges": [ + "b <= f3 <= b" + ] /* ranges */, + "analyzing_roworder_intersect": { + "usable": false, + "cause": "too_few_roworder_scans" + } /* analyzing_roworder_intersect */ + } + ] /* analyzing_roworder_scans */, + "index_roworder_union_cost": 21.9731, + "members": 2, + "chosen": true + }, + { + "indexes_to_merge": [ + { + "range_scan_alternatives": [ + { + "index": "f2", + "ranges": [ + "1 <= f2 <= 10" + ] /* ranges */, + "index_dives_for_eq_ranges": true, + "rowid_ordered": false, + "using_mrr": false, + "index_only": true, + "rows": 288, + "cost": 29.1737, + "chosen": true + } + ] /* range_scan_alternatives */, + "index_to_merge": "f2", + "cumulated_cost": 29.1737 + }, + { + "range_scan_alternatives": [ + { + "index": "f4", + "ranges": [ + "b <= f4 <= b" + ] /* ranges */, + "index_dives_for_eq_ranges": true, + "rowid_ordered": true, + "using_mrr": false, + "index_only": true, + "rows": 1, + "cost": 0.36, + "chosen": true + } + ] /* range_scan_alternatives */, + "index_to_merge": "f4", + "cumulated_cost": 29.5337 + } + ] /* indexes_to_merge */, + "cost_of_reading_ranges": 29.5337, + "cost_sort_rowid_and_read_disk": 1, + "cost_duplicate_removal": 195.921, + "total_cost": 226.454 + } + ] /* analyzing_index_merge_union */, + "chosen_range_access_summary": { + "range_access_plan": { + "type": "index_roworder_union", + "union_of": [ + { + "type": "range_scan", + "index": "f2", + "rows": 8, + "ranges": [ + "5 <= f2 <= 5" + ] /* ranges */ + }, + { + "type": "range_scan", + "index": "f3", + "rows": 128, + "ranges": [ + "b <= f3 <= b" + ] /* ranges */ + } + ] /* union_of */ + } /* range_access_plan */, + "rows_for_plan": 136, + "cost_for_plan": 21.9731, + "chosen": true + } /* chosen_range_access_summary */ + } /* range_analysis */ + } + ] /* rows_estimation */ + }, + { + "considered_execution_plans": [ + { + "plan_prefix": [ + ] /* plan_prefix */, + "table": "`t1`", + "best_access_path": { + "considered_access_paths": [ + { + "rows_to_scan": 136, + "filtering_effect": [ + ] /* filtering_effect */, + "final_filtering_effect": 1, + "access_type": "range", + "range_details": { + "used_index": "union(f2,f3)" + } /* range_details */, + "resulting_rows": 136, + "cost": 35.5731, + "chosen": true + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 100, + "rows_for_plan": 136, + "cost_for_plan": 35.5731, + "chosen": true + } + ] /* considered_execution_plans */ + }, + { + "attaching_conditions_to_tables": { + "original_condition": "(((`t1`.`f2` = 5) or (`t1`.`f3` = 'b')) and ((`t1`.`f2` between 1 and 10) or (`t1`.`f4` = 'b')))", + "attached_conditions_computation": [ + ] /* attached_conditions_computation */, + "attached_conditions_summary": [ + { + "table": "`t1`", + "attached": "(((`t1`.`f2` = 5) or (`t1`.`f3` = 'b')) and ((`t1`.`f2` between 1 and 10) or (`t1`.`f4` = 'b')))" + } + ] /* attached_conditions_summary */ + } /* attaching_conditions_to_tables */ + }, + { + "finalizing_table_conditions": [ + { + "table": "`t1`", + "original_table_condition": "(((`t1`.`f2` = 5) or (`t1`.`f3` = 'b')) and ((`t1`.`f2` between 1 and 10) or (`t1`.`f4` = 'b')))", + "final_table_condition ": "(((`t1`.`f2` = 5) or (`t1`.`f3` = 'b')) and ((`t1`.`f2` between 1 and 10) or (`t1`.`f4` = 'b')))" + } + ] /* finalizing_table_conditions */ + }, + { + "refine_plan": [ + { + "table": "`t1`" + } + ] /* refine_plan */ + } + ] /* steps */ + } /* join_optimization */ + }, + { + "join_explain": { + "select#": 1, + "steps": [ + ] /* steps */ + } /* join_explain */ + } + ] /* steps */ +} 0 0 +SET optimizer_switch=default; +DROP TABLE t1; diff --git a/mysql-test/suite/optimizer_temporary_table.result-pq b/mysql-test/suite/optimizer_temporary_table.result-pq new file mode 100644 index 000000000000..48f359d01975 --- /dev/null +++ b/mysql-test/suite/optimizer_temporary_table.result-pq @@ -0,0 +1,4825 @@ +drop table if exists t1, t2; +Warnings: +Note 1051 Unknown table 'test.t1' +Note 1051 Unknown table 'test.t2' +create table t1 (a int, b varchar(20)); +create table t2 (a int, b varchar(20)); +insert into t1 values(1, 'a'), (2, 'b'), (3, 'c'), (3, 'c'), (4, 'c'); +insert into t2 values(2, 'd'), (3, 'e'), (4, 'f'), (4, 'f'), (5, 'e'); +drop function if exists func1; +Warnings: +Note 1305 FUNCTION test.func1 does not exist +create function func1(x int) returns int deterministic +begin +declare z1, z2 int; +set z1 = x; +set z2 = z1 + 2; +return z2; +end| +drop table if exists t3; +Warnings: +Note 1051 Unknown table 'test.t3' +create table t3 like t1; +insert into t3 select 5 + 10000 * rand(), '5' from t3; +insert into t3 select 5 + 10000 * rand(), '5' from t3; +insert into t3 select 5 + 10000 * rand(), '5' from t3; +insert into t3 select 5 + 10000 * rand(), '5' from t3; +insert into t3 select 5 + 10000 * rand(), '5' from t3; +insert into t3 select 5 + 10000 * rand(), '5' from t3; +insert into t3 select 5 + 10000 * rand(), '5' from t3; +insert into t3 select 5 + 10000 * rand(), '5' from t3; +drop table if exists t4; +Warnings: +Note 1051 Unknown table 'test.t4' +create table t4 (a int, b int, c int, d char, e blob); +insert into t4 values (1, 2, 3, '4', '5'); +drop table if exists t5; +Warnings: +Note 1051 Unknown table 'test.t5' +create table t5 (a int, b int primary key); +insert into t5 values (1,7), (1,8); +drop table if exists t6; +Warnings: +Note 1051 Unknown table 'test.t6' +create table t6 (a int, b int, c int, d char); +insert into t6 values(1, 2, 3, '4'); +create index t6_indx1 on t6(a); +drop table if exists t7; +Warnings: +Note 1051 Unknown table 'test.t7' +create table t7 (a int, b varchar(20)); +insert into t7 values(1, 'a'), (2, 'b'), (3, 'c'), (3, 'c'), (4, 'c'); +create index indx7 on t7(b); +drop table if exists t8; +Warnings: +Note 1051 Unknown table 'test.t8' +create table t8 ( +pk integer auto_increment, col_int_key integer, +col_varchar_key varchar(1), primary key (pk), +key (col_int_key), key (col_varchar_key, col_int_key)) engine = innodb; +insert into t8 values (1, 2, 'v'), (2, 150, 'v'); +drop table if exists t9, t10; +Warnings: +Note 1051 Unknown table 'test.t9' +Note 1051 Unknown table 'test.t10' +create table t9 ( +pk int(11) not null auto_increment, +col_int_nokey int(11) default null, +col_int_key int(11) default null, +col_date_key date default null, +col_date_nokey date default null, +primary key (pk), +key col_int_key (col_int_key), +key col_date_key (col_date_key), +key col_varchar_key (col_int_key) +) engine=innodb; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1831 Duplicate index 'col_varchar_key' defined on the table 'test.t9'. This is deprecated and will be disallowed in a future release. +create table t10 ( +pk int(11) not null auto_increment, +col_int_nokey int(11) default null, +col_int_key int(11) default null, +col_date_key date default null, +col_date_nokey date default null, +primary key (pk), +key col_int_key (col_int_key), +key col_date_key (col_date_key), +key col_varchar_key (col_int_key) +) engine=innodb; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1831 Duplicate index 'col_varchar_key' defined on the table 'test.t10'. This is deprecated and will be disallowed in a future release. +insert into t9 values +(1, 2, 4, '2008-12-05', '2008-12-05'), +(2, 150, 62, '2005-03-27', '2005-03-27'), +(3, NULL, 7, '2004-04-09', '2004-04-09'), +(4, 2, 1, '2006-05-13', '2006-05-13'), +(5, 5, 0, '2001-05-06', '2001-05-06'), +(6, 3, 7, '2006-03-03', '2006-03-03'), +(7, 1, 7, '2007-12-28', '2007-12-28'), +(8, 4, 1, '2004-10-20', '2004-10-20'), +(9, NULL, 7, '2008-04-09', '2008-04-09'), +(10, 2, 1, '2005-12-25', '2005-12-25'), +(11, 6, 5, '1900-01-01', '1900-01-01'), +(12, 6, 2, NULL, NULL), +(13, 8, 0, '1900-01-01', '1900-01-01'), +(14, 2, 1, '2001-01-16', '2001-01-16'), +(15, 6, 8, '1900-01-01', '1900-01-01'), +(16, 8, 1, '2001-11-23', '2001-11-23'), +(17, 3, 1, '2004-11-04', '2004-11-04'), +(18, 3, 9, '2003-03-12', '2003-03-12'), +(19, 9, 1, '2002-06-22', '2002-06-22'), +(20, 6, 5, '2004-10-10', '2004-10-10'); +insert into t10 values +(1, 8, 4, '2002-01-03', '2002-01-03'), +(2, 3, 5, '2007-07-08', '2007-07-08'), +(3, 3, 8, '2000-08-02', '2000-08-02'), +(4, NULL, 4, '2000-03-06', '2000-03-06'), +(5, 7, 8, '2002-06-05', '2002-06-05'), +(6, 4, 2, '2009-08-09', '2009-08-09'), +(7, 7, 9, '2001-03-22', '2001-03-22'), +(8, 7, 6, '2002-10-08', '2002-10-08'), +(9, 8, NULL, NULL, NULL), +(10, 6, NULL, '2007-09-13', '2007-09-13'), +(11, 3, 48, '2003-12-08', '2003-12-08'), +(12, 210, 228, '2006-06-01', '2006-06-01'), +(13, 1, 3, '2001-10-04', '2001-10-04'), +(14, 2, 5, '2004-11-16', '2004-11-16'), +(15, 251, 39, NULL, NULL), +(16, 4, 6, '2005-06-22', '2005-06-22'), +(17, 4, 8, '2003-04-19', '2003-04-19'), +(18, 9, 3, '2006-03-23', '2006-03-23'), +(19, 4, NULL, NULL, NULL), +(20, NULL, 2, '2008-10-22', '2008-10-22'), +(21, 4, 6, '2009-04-04', '2009-04-04'), +(22, NULL, 3, NULL, NULL), +(23, 1, 1, '2001-07-15', '2001-07-15'), +(24, 6, 4, '2004-09-25', '2004-09-25'), +(25, 2, 3, '2001-02-20', '2001-02-20'), +(26, NULL, 1, '1900-01-01', '1900-01-01'), +(27, 4, NULL, '2004-08-02', '2004-08-02'), +(28, 248, 97, '2009-02-26', '2009-02-26'), +(29, 4, 0, '2002-11-23', '2002-11-23'), +(30, 8, 0, '2008-12-17', '2008-12-17'), +(31, 4, 9, '2005-08-26', '2005-08-26'), +(32, 5, 5, '2001-03-10', '2001-03-10'), +(33, 9, 9, '1900-01-01', '1900-01-01'), +(34, 2, 0, '2003-08-04', '2003-08-04'), +(35, 4, 2, '2007-11-06', '2007-11-06'), +(36, 211, 172, '2009-04-23', '2009-04-23'), +(37, 2, NULL, '2002-10-06', '2002-10-06'), +(38, 4, 5, '2008-02-12', '2008-02-12'), +(39, 125, 119, '2007-09-18', '2007-09-18'), +(40, 9, 1, '2007-06-26', '2007-06-26'), +(41, 4, 4, NULL, NULL), +(42, 8, 8, '2009-05-05', '2009-05-05'), +(43, 8, NULL, '2003-05-04', '2003-05-04'), +(44, NULL, 6, '2003-11-10', '2003-11-10'), +(45, 8, 5, '2009-02-19', '2009-02-19'), +(46, 4, 5, '2006-11-17', '2006-11-17'), +(47, 8, 1, '2000-02-23', '2000-02-23'), +(48, NULL, 7, '1900-01-01', '1900-01-01'), +(49, 1, 2, '2003-04-08', '2003-04-08'), +(50, 3, 8, '2006-07-08', '2006-07-08'), +(51, 5, 9, '2001-05-21', '2001-05-21'), +(52, 8, NULL, NULL, NULL), +(53, 7, NULL, '2009-01-05', '2009-01-05'), +(54, 2, 3, '2001-08-05', '2001-08-05'), +(55, NULL, 172, '2000-11-01', '2000-11-01'), +(56, 3, NULL, '2004-12-16', '2004-12-16'), +(57, NULL, 6, '2003-02-06', '2003-02-06'), +(58, 9, 6, '2008-04-23', '2008-04-23'), +(59, 1, 5, '2005-12-20', '2005-12-20'), +(60, 0, 4, '2002-03-13', '2002-03-13'), +(61, 0, 3, NULL, NULL), +(62, 8, 2, '2006-07-20', '2006-07-20'), +(63, NULL, 7, '2002-12-19', '2002-12-19'), +(64, 9, 4, '2001-07-09', '2001-07-09'), +(65, 1, 6, '2006-05-27', '2006-05-27'), +(66, 9, 0, '2007-02-26', '2007-02-26'), +(67, 7, 8, NULL, NULL), +(68, 2, 5, '2007-02-07', '2007-02-07'), +(69, 1, 8, '2005-01-22', '2005-01-22'), +(70, 9, 2, '2006-04-25', '2006-04-25'), +(71, 5, 9, '2002-11-13', '2002-11-13'), +(72, 4, 7, '2007-10-26', '2007-10-26'), +(73, 6, 5, '2003-06-16', '2003-06-16'), +(74, 5, 7, '2006-01-18', '2006-01-18'), +(75, 2, 0, '1900-01-01', '1900-01-01'), +(76, 4, 4, '2000-09-13', '2000-09-13'), +(77, 0, 3, '2003-01-26', '2003-01-26'), +(78, 3, 1, '2002-09-09', '2002-09-09'), +(79, 0, 0, '2001-09-06', '2001-09-06'), +(80, 6, 6, '2006-02-23', '2006-02-23'), +(81, 1, 2, '2004-06-21', '2004-06-21'), +(82, 9, NULL, '2006-12-02', '2006-12-02'), +(83, 4, 8, '2005-05-17', '2005-05-17'), +(84, 9, NULL, '2001-12-27', '2001-12-27'), +(85, 4, NULL, '2008-04-11', '2008-04-11'), +(86, 1, NULL, '2000-09-24', '2000-09-24'), +(87, 2, 3, '2004-04-20', '2004-04-20'), +(88, 8, 7, '2008-07-10', '2008-07-10'), +(89, 1, 3, '2007-08-14', '2007-08-14'), +(90, 0, 5, '2008-06-08', '2008-06-08'), +(91, 2, 5, '2001-07-26', '2001-07-26'), +(92, 0, 1, '2008-09-17', '2008-09-17'), +(93, 1, 2, NULL, NULL), +(94, 2, 1, '2004-02-25', '2004-02-25'), +(95, NULL, 7, '2009-11-02', '2009-11-02'), +(96, 3, 1, '2001-12-14', '2001-12-14'), +(97, 8, 9, NULL, NULL), +(98, 4, 9, '1900-01-01', '1900-01-01'), +(99, 4, 8, '2002-04-12', '2002-04-12'), +(100, NULL, 3, '2000-02-09', '2000-02-09'); +create table t11 ( +col_date_key date default null, +col_varchar_10_utf8 varchar(10) CHARACTER SET utf8 default null, +col_varchar_10_latin1 varchar(10) default null, +col_varchar_10_latin1_key varchar(10) default null, +col_datetime datetime default null, +col_varchar_10_utf8_key varchar(10) CHARACTER SET utf8 default null, +col_varchar_1024_latin1_key varchar(1024) default null, +col_varchar_1024_latin1 varchar(1024) default null, +col_varchar_1024_utf8 varchar(1024) CHARACTER SET utf8 default null, +col_int_key int(11) default null, +col_date date default null, +col_varchar_1024_utf8_key varchar(1024) CHARACTER SET utf8 default null, +col_int int(11) default null, +pk int(11) not null auto_increment, +col_datetime_key datetime default null, +primary key (pk), +key col_date_key (col_date_key), +key col_varchar_10_latin1_key (col_varchar_10_latin1_key), +key col_varchar_10_utf8_key (col_varchar_10_utf8_key), +key col_varchar_1024_latin1_key (col_varchar_1024_latin1_key(1000)), +key col_int_key (col_int_key), +key col_varchar_1024_utf8_key (col_varchar_1024_utf8_key(333)), +key col_datetime_key (col_datetime_key) +) engine=myisam auto_increment=76 default charset=latin1; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert ignore into t11 values +('2005-03-10','have','o','gryvuwdllyhymuwyypoiuyeqbnaanbur','2004','going','h','well','f',1140785152,'2003','YTLDF',NULL,NULL,'20050908213850.042201'), +('2003', 'g', 'ELTFL', 'got', '20:07:16.048352', 'ryvuwdllyhymuwyypoiuyeqbnaanbursgddnqhyvxnnpadsjiqdkajofferjfslatroorycttbiuhlubvmoikwwnalqyewgthdmfvsedatazrflwenzeiwdxtheqppbmqfydsawvanehgvfvbsqxzkqzhtjkybvikmpexipoddmoulsnzfchusfgkdazecevrpuakfioamyyqyribcnydfxmmzsxcpkydyczmeajaebsaskneaqwxjbpjptiwgiizoxfygnbjojpifpzldsdhrukdbwpzribxgafunywmmcfpjugozduylotsugqocbadhcnxjqlugncbebwsbobhxgghyyphxfqqnpliazusgjswynfotwdonpbkllfdbuoqceirksegypasuuxnrjumrkaryhkgkbdfgoqbdmrdrmpvwitqzswgossxltimkbtrxitnmigcxgfaqmrnvspyaftisgdbkzlevczyrlossygtnatwcobbtsxqhjrdykmthpyzmdgyirxwlidiknxwsufkyexucekyhivscjdcouswuiyltrpmrngriwvrxgovfyewdsvlwirfzkwexxzoccufvuvhsjfvuwjsrrzguntudxxhblzbescayrbbrijnvucxxmbyltlojlgcweddzrfxsmwnxxewigapgrowtmrlqsknuaegzfvdwfdnnbfyubwckwfdrwmrymagyswwvvyeqhaaskgxogthhrzsdlsyqoeuvhwxquwbnivpowtybzehvbsoppuefqngkqohtdeylosjyvtxuziotnfpbqxkpxvzcjbgxokjzitakfevxduhtudsslluhzgcwgrcrtpnczgxchnmmgnubjzvvuklklfhiupbsjzhcqyadhskxtjzabzesulhgpykga', 'she', 'have', 'PYJKD', 9, '2008-06-10', 'yvuwdllyhymuwyypoiuyeqbnaanbursgddnqhyvxnnpadsjiqdkajofferjfslatroorycttbiuhlubvmoikwwnalqyewgthdmfvsedatazrflwenzeiwdxtheqppbmqfydsawvanehgvfvbsqxzkqzhtjkybvikmpexipoddmoulsnzfchusfgkdazecevrpuakfioamyyqyribcnydfxmmzsxcpkydyczmeajaebsaskneaqwxjbpjptiwgiizoxfygnbjojpifpzldsdhrukdbwpzribxgafunywmmcfpjugozduylotsugqocbadhcnxjqlugncbebwsbobhxgghyyphxfqqnpliazusgjswynfotwdonpbkllfdbuoqceirksegypasuuxnrjumrkaryhkgkbdfgoqbdmrdrmpvwitqzswgossxltimkbtrxitnmigcxgfaqmrnv', NULL, NULL, '2008-01-09'); +create table t12 (t text, c char(10), b blob, d varbinary(10)) engine=innodb; +insert into t12 values (NULL, NULL, NULL,NULL); +insert into t12 values ("", "", "", ""); +insert into t12 values ("hello", "hello", "hello", "hello"); +insert into t12 values ("HELLO", "HELLO","HELLO", "HELLO"); +insert into t12 values ("HELLO MY", "HELLO MY", "HELLO MY", "HELLO MY"); +insert into t12 values ("a", "a", "a", "a"); +insert into t12 values (1,1,1,1); +insert into t12 values (NULL,NULL,NULL,NULL); +create table t13 ( +pk int(11) not null auto_increment, +col_int_nokey int(11) default null, +col_int_key int(11) default null, +col_date_key date default null, +col_time_key time default null, +col_varchar_key varchar(1) default null, +col_varchar_nokey varchar(1) default null, +primary key (pk), +key col_int_key (col_int_key), +key col_date_key (col_date_key), +key col_time_key (col_time_key), +key col_varchar_key (col_varchar_key, col_int_key) +) engine=myisam auto_increment=21; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t13 values +(2, 150, 62, '2005-03-27', '14:26:02', 'v', 'v'), +(3, NULL, 7, '2004-04-09', '14:03:03', 'c', 'c'), +(4, 2, 1, '2006-05-13', '01:46:09', NULL, NULL), +(5, 5, 0, '2001-05-06', '16:21:18', 'x', 'x'), +(6, 3, 7, '2006-03-03', '18:56:33', 'i', 'i'), +(7, 1, 7, '2007-12-28', NULL, 'e', 'e'), +(8, 4, 1, '2004-10-20', '09:29:08', 'p', 'p'), +(9, NULL, 7, '2008-04-09', '19:11:10', 's', 's'), +(10, 2, 1, '2005-12-25', '11:57:26', 'j', 'j'), +(11, 6, 5, '1900-01-01', '00:39:46', 'z', 'z'), +(12, 6, 2, NULL, '03:28:15', 'c', 'c'), +(13, 8, 0, '1900-01-01', '06:44:18', 'a', 'a'), +(14, 2, 1, '2001-01-16', '14:36:39', 'q', 'q'), +(15, 6, 8, '1900-01-01', '18:42:45', 'y', 'y'), +(16, 8, 1, '2001-11-23', '02:57:29', NULL, NULL), +(17, 3, 1, '2004-11-04', '16:46:13', 'r', 'r'), +(18, 3, 9, '2003-03-12', '19:39:02', 'v', 'v'), +(19, 9, 1, '2002-06-22', NULL, NULL, NULL), +(20, 6, 5, '2004-10-10', '20:58:33', 'r', 'r'); +create table t14 ( +pk int(11) not null auto_increment, +col_int_nokey int(11) default null, +col_int_key int(11) default null, +col_date_key date default null, +col_time_key time default null, +col_varchar_key varchar(1) default null, +col_varchar_nokey varchar(1) default null, +primary key (pk), +key col_int_key (col_int_key), +key col_date_key (col_date_key), +key col_time_key (col_time_key), +key col_varchar_key (col_varchar_key,col_int_key) +) ENGINE=myisam auto_increment=30; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t14 values +(10, NULL, 8, '2000-12-03', '22:55:23', 'x', 'x'), +(11, 8, 7, '2008-05-03', '10:19:31', 'd', 'd'), +(12, 1, 1, '2005-12-06', '14:40:36', 'r', 'r'), +(13, 9, 7, '2000-04-10', '04:37:47', 'f', 'f'), +(14, 4, 9, '2002-11-05', '19:34:06', 'y', 'y'), +(15, 3, NULL, '2000-09-06', '20:35:33', 'u', 'u'), +(16, 2, 1, NULL, NULL, 'm', 'm'), +(17, NULL, 9, '2007-06-14', '14:43:37', NULL, NULL), +(18, 2, 2, '2007-11-17', '02:23:09', 'o', 'o'), +(19, NULL, 9, '2009-02-23', '01:22:45', 'w', 'w'), +(20, 6, 2, '2007-01-08', '00:00:00', 'm', 'm'), +(21, 7, 4, '2008-06-10', '00:13:25', 'q', 'q'), +(22, 2, 0, '2002-10-20', '03:47:16', NULL, NULL), +(23, 5, 4, '2008-09-12', '01:41:48', 'd', 'd'), +(24, 7, 8, '2006-06-16', '00:00:00', 'g', 'g'), +(25, 6, NULL, '2004-09-18', '22:32:04', 'x', 'x'), +(26, 6, NULL, '1900-01-01', '16:44:14', 'f', 'f'), +(27, 2, 0, '2005-09-13', '17:38:37', 'p', 'p'), +(28, 9, NULL, '2007-04-09', '08:46:48', 'j', 'j'), +(29, 6, 8, '2000-09-20', '14:11:27', 'c', 'c'); +analyze table t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +test.t4 analyze status OK +test.t5 analyze status OK +test.t6 analyze status OK +test.t7 analyze status OK +test.t8 analyze status OK +test.t9 analyze status OK +test.t10 analyze status OK +test.t11 analyze status OK +test.t12 analyze status OK +test.t13 analyze status OK +test.t14 analyze status OK +# restart: --big-tables=1 +SET @optimizer_switch_saved= @@optimizer_switch; +SET @@optimizer_switch="derived_merge=off"; +explain format = json select sql_buffer_result * from t1; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.75" + }, + "buffer_result": { + "using_temporary_table": true, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "480" + }, + "used_columns": [ + "a", + "b" + ], + "buffer_result": { + "using_temporary_table": true, + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "440" + }, + "used_columns": [ + "a", + "b" + ] + } + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select sql_buffer_result `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` +select sql_buffer_result * from t1; +a b +1 a +2 b +3 c +3 c +4 c +explain format = json select sql_buffer_result * from t2; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.75" + }, + "buffer_result": { + "using_temporary_table": true, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "480" + }, + "used_columns": [ + "a", + "b" + ], + "buffer_result": { + "using_temporary_table": true, + "table": { + "select_id": 2, + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "440" + }, + "used_columns": [ + "a", + "b" + ] + } + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select sql_buffer_result `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t2` +select sql_buffer_result * from t2; +a b +2 d +3 e +4 f +4 f +5 e +explain format = json select * from t1 left join t2 on t1.b = t2.b order by t1.a; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "28.50" + }, + "ordering_operation": { + "using_temporary_table": true, + "using_filesort": true, + "cost_info": { + "sort_cost": "25.00" + }, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "880" + }, + "used_columns": [ + "a", + "b", + "a", + "b" + ], + "ordering_operation": { + "using_temporary_table": true, + "using_filesort": true, + "nested_loop": [ + { + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "440" + }, + "used_columns": [ + "a", + "b" + ] + } + }, + { + "table": { + "select_id": 2, + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 25, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "2.50", + "prefix_cost": "3.50", + "data_read_per_join": "2K" + }, + "used_columns": [ + "a", + "b" + ], + "attached_condition": "(is_not_null_compl(t2), (`test`.`t2`.`b` = `test`.`t1`.`b`), true)" + } + } + ] + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`b` = `test`.`t1`.`b`)) where true order by `test`.`t1`.`a` +select * from t1 left join t2 on t1.b = t2.b order by t1.a; +a b a b +1 a NULL NULL +2 b NULL NULL +3 c NULL NULL +3 c NULL NULL +4 c NULL NULL +explain format = json select * from t1 order by func1(a); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "5.75" + }, + "ordering_operation": { + "using_temporary_table": true, + "using_filesort": true, + "cost_info": { + "sort_cost": "5.00" + }, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "440" + }, + "used_columns": [ + "a", + "b" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` order by `func1`(`test`.`t1`.`a`) +select * from t1 order by func1(a); +a b +1 a +2 b +3 c +3 c +4 c +explain format = json select a from t1 group by b order by sum(a); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.75" + }, + "ordering_operation": { + "using_filesort": true, + "grouping_operation": { + "using_temporary_table": true, + "using_filesort": false, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "560" + }, + "used_columns": [ + "sum(t1.a)", + "b", + "a" + ], + "ordering_operation": { + "using_filesort": true, + "grouping_operation": { + "using_temporary_table": true, + "using_filesort": false, + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "440" + }, + "used_columns": [ + "a", + "b" + ] + } + } + } + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` group by `test`.`t1`.`b` order by sum(`sum(t1.a)`) +select a from t1 group by b order by sum(a); +a +1 +2 +3 +explain format = json select a from t7 group by b order by sum(a); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.75" + }, + "ordering_operation": { + "using_temporary_table": true, + "using_filesort": true, + "grouping_operation": { + "using_filesort": false, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "560" + }, + "used_columns": [ + "sum(t7.a)", + "b", + "a" + ], + "ordering_operation": { + "using_temporary_table": true, + "using_filesort": true, + "grouping_operation": { + "using_filesort": false, + "table": { + "select_id": 2, + "table_name": "t7", + "access_type": "index", + "possible_keys": [ + "indx7" + ], + "key": "indx7", + "used_key_parts": [ + "b" + ], + "key_length": "83", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "440" + }, + "used_columns": [ + "a", + "b" + ] + } + } + } + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t7`.`a` AS `a` from `test`.`t7` group by `test`.`t7`.`b` order by sum(`sum(t7.a)`) +select a from t7 group by b order by sum(a); +a +1 +2 +3 +explain format = json select sql_big_result distinct * from t1, t2; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "3.50" + }, + "duplicates_removal": { + "using_temporary_table": true, + "using_filesort": false, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "440" + }, + "used_columns": [ + "a", + "b" + ] + } + }, + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 25, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "2.50", + "prefix_cost": "3.50", + "data_read_per_join": "2K" + }, + "used_columns": [ + "a", + "b" + ] + } + } + ] + } + } +} +Warnings: +Note 1003 /* select#1 */ select distinct sql_big_result `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` join `test`.`t2` +select sql_big_result distinct * from t1, t2; +a b a b +1 a 2 d +1 a 3 e +1 a 4 f +1 a 5 e +2 b 2 d +2 b 3 e +2 b 4 f +2 b 5 e +3 c 2 d +3 c 3 e +3 c 4 f +3 c 5 e +4 c 2 d +4 c 3 e +4 c 4 f +4 c 5 e +explain format = json select sql_big_result t1.b from t1, t2 group by t1.b; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "3.50" + }, + "grouping_operation": { + "using_temporary_table": true, + "using_filesort": false, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "440" + }, + "used_columns": [ + "b" + ], + "grouping_operation": { + "using_temporary_table": true, + "using_filesort": false, + "nested_loop": [ + { + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "440" + }, + "used_columns": [ + "b" + ] + } + }, + { + "table": { + "select_id": 2, + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 25, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "2.50", + "prefix_cost": "3.50", + "data_read_per_join": "2K" + } + } + } + ] + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select sql_big_result `test`.`t1`.`b` AS `b` from `test`.`t1` join `test`.`t2` group by `test`.`t1`.`b` +select sql_big_result t1.b from t1, t2 group by t1.b; +b +a +b +c +explain format = json select sql_big_result distinct t1.a from t1, t2 group by t1.a, t1.b; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "3.50" + }, + "duplicates_removal": { + "using_filesort": false, + "grouping_operation": { + "using_temporary_table": true, + "using_filesort": false, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "440" + }, + "used_columns": [ + "a", + "b" + ] + } + }, + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 25, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "2.50", + "prefix_cost": "3.50", + "data_read_per_join": "2K" + } + } + } + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select distinct sql_big_result `test`.`t1`.`a` AS `a` from `test`.`t1` join `test`.`t2` group by `test`.`t1`.`a`,`test`.`t1`.`b` +select sql_big_result distinct t1.a from t1, t2 group by t1.a, t1.b; +a +1 +2 +3 +4 +explain format = json select t1.* from t1 inner join t2 on t1.a = t2.a order by t2.a; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "8.50" + }, + "ordering_operation": { + "using_temporary_table": true, + "using_filesort": true, + "cost_info": { + "sort_cost": "5.00" + }, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "480" + }, + "used_columns": [ + "a", + "a", + "b" + ], + "ordering_operation": { + "using_temporary_table": true, + "using_filesort": true, + "nested_loop": [ + { + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "440" + }, + "used_columns": [ + "a", + "b" + ] + } + }, + { + "table": { + "select_id": 2, + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "20.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "3.50", + "data_read_per_join": "440" + }, + "used_columns": [ + "a" + ], + "attached_condition": "(`test`.`t2`.`a` = `test`.`t1`.`a`)" + } + } + ] + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` join `test`.`t2` where (`test`.`t2`.`a` = `test`.`t1`.`a`) order by `test`.`t2`.`a` +select t1.* from t1 inner join t2 on t1.a = t2.a order by t2.a; +a b +2 b +3 c +3 c +4 c +4 c +explain format = json select t1.* from t1, t2 where t1.a = t2.a order by t1.a; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "8.50" + }, + "ordering_operation": { + "using_temporary_table": true, + "using_filesort": true, + "cost_info": { + "sort_cost": "5.00" + }, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "480" + }, + "used_columns": [ + "a", + "b" + ], + "ordering_operation": { + "using_temporary_table": true, + "using_filesort": true, + "nested_loop": [ + { + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "440" + }, + "used_columns": [ + "a", + "b" + ] + } + }, + { + "table": { + "select_id": 2, + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "20.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "3.50", + "data_read_per_join": "440" + }, + "used_columns": [ + "a" + ], + "attached_condition": "(`test`.`t2`.`a` = `test`.`t1`.`a`)" + } + } + ] + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` join `test`.`t2` where (`test`.`t2`.`a` = `test`.`t1`.`a`) order by `test`.`t1`.`a` +select t1.* from t1, t2 where t1.a = t2.a order by t1.a; +a b +2 b +3 c +3 c +4 c +4 c +explain format = json select t1.* from t1 inner join t2 where t1.a = t2.a group by t1.a; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "3.50" + }, + "grouping_operation": { + "using_temporary_table": true, + "using_filesort": false, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "480" + }, + "used_columns": [ + "a", + "b" + ], + "grouping_operation": { + "using_temporary_table": true, + "using_filesort": false, + "nested_loop": [ + { + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "440" + }, + "used_columns": [ + "a", + "b" + ] + } + }, + { + "table": { + "select_id": 2, + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "20.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "3.50", + "data_read_per_join": "440" + }, + "used_columns": [ + "a" + ], + "attached_condition": "(`test`.`t2`.`a` = `test`.`t1`.`a`)" + } + } + ] + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` join `test`.`t2` where (`test`.`t2`.`a` = `test`.`t1`.`a`) group by `test`.`t1`.`a` +select t1.* from t1 inner join t2 where t1.a = t2.a group by t1.a; +a b +2 b +3 c +4 c +explain format = json select t1.* from t1 inner join t2 where t1.a = t2.a group by t2.a; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "3.50" + }, + "grouping_operation": { + "using_temporary_table": true, + "using_filesort": false, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "480" + }, + "used_columns": [ + "a", + "a", + "b" + ], + "grouping_operation": { + "using_temporary_table": true, + "using_filesort": false, + "nested_loop": [ + { + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "440" + }, + "used_columns": [ + "a", + "b" + ] + } + }, + { + "table": { + "select_id": 2, + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "20.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "3.50", + "data_read_per_join": "440" + }, + "used_columns": [ + "a" + ], + "attached_condition": "(`test`.`t2`.`a` = `test`.`t1`.`a`)" + } + } + ] + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` join `test`.`t2` where (`test`.`t2`.`a` = `test`.`t1`.`a`) group by `test`.`t2`.`a` +select t1.* from t1 inner join t2 where t1.a = t2.a group by t2.a; +a b +2 b +3 c +4 c +explain format = json select a from t1 group by a order by a; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "5.75" + }, + "ordering_operation": { + "using_filesort": false, + "grouping_operation": { + "using_temporary_table": true, + "using_filesort": true, + "cost_info": { + "sort_cost": "5.00" + }, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "80" + }, + "used_columns": [ + "a" + ], + "ordering_operation": { + "using_filesort": false, + "grouping_operation": { + "using_temporary_table": true, + "using_filesort": true, + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "440" + }, + "used_columns": [ + "a" + ] + } + } + } + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` group by `test`.`t1`.`a` order by `test`.`t1`.`a` +select a from t1 group by a order by a; +a +1 +2 +3 +4 +explain format = json select b from t1 group by b order by a; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.75" + }, + "ordering_operation": { + "using_filesort": true, + "grouping_operation": { + "using_temporary_table": true, + "using_filesort": false, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "480" + }, + "used_columns": [ + "a", + "b" + ], + "ordering_operation": { + "using_filesort": true, + "grouping_operation": { + "using_temporary_table": true, + "using_filesort": false, + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "440" + }, + "used_columns": [ + "a", + "b" + ] + } + } + } + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`b` AS `b` from `test`.`t1` group by `test`.`t1`.`b` order by `test`.`t1`.`a` +select b from t1 group by b order by a; +b +a +b +c +explain format = json select distinct t1.a from t1, t2 where t1.b = t2.b; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "3.50" + }, + "duplicates_removal": { + "using_temporary_table": true, + "using_filesort": false, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "440" + }, + "used_columns": [ + "a", + "b" + ] + } + }, + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "20.00", + "distinct": true, + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "3.50", + "data_read_per_join": "440" + }, + "used_columns": [ + "b" + ], + "attached_condition": "(`test`.`t2`.`b` = `test`.`t1`.`b`)" + } + } + ] + } + } +} +Warnings: +Note 1003 /* select#1 */ select distinct `test`.`t1`.`a` AS `a` from `test`.`t1` join `test`.`t2` where (`test`.`t2`.`b` = `test`.`t1`.`b`) +select distinct t1.a from t1, t2 where t1.b = t2.b; +a +explain format = json select distinct a from t1 group by b,a; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.75" + }, + "duplicates_removal": { + "using_filesort": false, + "grouping_operation": { + "using_temporary_table": true, + "using_filesort": false, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "440" + }, + "used_columns": [ + "a", + "b" + ] + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select distinct `test`.`t1`.`a` AS `a` from `test`.`t1` group by `test`.`t1`.`b`,`test`.`t1`.`a` +select distinct a from t1 group by b,a; +a +1 +2 +3 +4 +set @old_sort_buffer_size = @@sort_buffer_size; +set @@sort_buffer_size = 32804; +explain format = json select distinct b from t3 group by a having count(*) > 1; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.35" + }, + "duplicates_removal": { + "using_filesort": false, + "grouping_operation": { + "using_temporary_table": true, + "using_filesort": false, + "table": { + "table_name": "t3", + "access_type": "ALL", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.10", + "prefix_cost": "0.35", + "data_read_per_join": "88" + }, + "used_columns": [ + "a", + "b" + ] + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select distinct `test`.`t3`.`b` AS `b` from `test`.`t3` group by `test`.`t3`.`a` having (count(0) > 1) +select distinct b from t3 group by a having count(*) > 1; +b +select distinct b from t3 group by a; +b +set @@sort_buffer_size = @old_sort_buffer_size; +explain format = json select distinct t4.a,e from t4, t1 order by t4.b; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "6.11" + }, + "ordering_operation": { + "using_temporary_table": true, + "using_filesort": true, + "duplicates_removal": { + "using_temporary_table": true, + "using_filesort": false, + "cost_info": { + "sort_cost": "5.00" + }, + "nested_loop": [ + { + "table": { + "table_name": "t4", + "access_type": "ALL", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.10", + "prefix_cost": "0.35", + "data_read_per_join": "32" + }, + "used_columns": [ + "a", + "b", + "e" + ] + } + }, + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "distinct": true, + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.27", + "eval_cost": "0.50", + "prefix_cost": "1.12", + "data_read_per_join": "440" + } + } + } + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select distinct `test`.`t4`.`a` AS `a`,`test`.`t4`.`e` AS `e` from `test`.`t4` join `test`.`t1` order by `test`.`t4`.`b` +select distinct t4.a,e from t4, t1 order by t4.b; +a e +1 5 +explain format = json select * from t1 union all select * from t2; +EXPLAIN +{ + "query_block": { + "union_result": { + "using_temporary_table": false, + "query_specifications": [ + { + "dependent": false, + "cacheable": true, + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.75" + }, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "440" + }, + "used_columns": [ + "a", + "b" + ] + } + } + }, + { + "dependent": false, + "cacheable": true, + "query_block": { + "select_id": 2, + "cost_info": { + "query_cost": "0.75" + }, + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "440" + }, + "used_columns": [ + "a", + "b" + ] + } + } + } + ] + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` union all /* select#2 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t2` +select * from t1 union all select * from t2; +a b +1 a +2 b +3 c +3 c +4 c +2 d +3 e +4 f +4 f +5 e +explain format = json select * from t1 union select * from t2 order by b; +EXPLAIN +{ + "query_block": { + "union_result": { + "using_temporary_table": true, + "table_name": "", + "access_type": "ALL", + "query_specifications": [ + { + "dependent": false, + "cacheable": true, + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.75" + }, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "440" + }, + "used_columns": [ + "a", + "b" + ] + } + } + }, + { + "dependent": false, + "cacheable": true, + "query_block": { + "select_id": 2, + "cost_info": { + "query_cost": "0.75" + }, + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "440" + }, + "used_columns": [ + "a", + "b" + ] + } + } + } + ] + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` union /* select#2 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t2` order by `b` +select * from t1 union select * from t2 order by b; +a b +1 a +2 b +3 c +4 c +2 d +3 e +5 e +4 f +explain format = json select tt.* from (select * from t1) as tt; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.00" + }, + "table": { + "table_name": "tt", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.50", + "prefix_cost": "1.00", + "data_read_per_join": "480" + }, + "used_columns": [ + "a", + "b" + ], + "materialized_from_subquery": { + "using_temporary_table": true, + "dependent": false, + "cacheable": true, + "query_block": { + "select_id": 2, + "cost_info": { + "query_cost": "0.75" + }, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "440" + }, + "used_columns": [ + "a", + "b" + ] + } + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `tt`.`a` AS `a`,`tt`.`b` AS `b` from (/* select#2 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1`) `tt` +select tt.* from (select * from t1) as tt; +a b +1 a +2 b +3 c +3 c +4 c +select * from t5; +a b +1 7 +1 8 +explain format = json select b from (select b from t5 where b > 5) tt; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.70" + }, + "table": { + "table_name": "tt", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 2, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.20", + "prefix_cost": "0.70", + "data_read_per_join": "32" + }, + "used_columns": [ + "b" + ], + "materialized_from_subquery": { + "using_temporary_table": true, + "dependent": false, + "cacheable": true, + "query_block": { + "select_id": 2, + "cost_info": { + "query_cost": "0.45" + }, + "table": { + "table_name": "t5", + "access_type": "index", + "possible_keys": [ + "PRIMARY" + ], + "key": "PRIMARY", + "used_key_parts": [ + "b" + ], + "key_length": "4", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 2, + "filtered": "100.00", + "using_index": true, + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.20", + "prefix_cost": "0.45", + "data_read_per_join": "32" + }, + "used_columns": [ + "b" + ], + "attached_condition": "(`test`.`t5`.`b` > 5)" + } + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `tt`.`b` AS `b` from (/* select#2 */ select `test`.`t5`.`b` AS `b` from `test`.`t5` where (`test`.`t5`.`b` > 5)) `tt` +select b from (select b from t5 where b > 5) tt; +b +7 +8 +explain format = json select * from (select b from t1) as t1, (select b from t2) as t2; +EXPLAIN + "b" + "b" + "data_read_per_join": "440" + "data_read_per_join": "440" + "eval_cost": "0.50", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "prefix_cost": "0.75", + "read_cost": "0.25", + "read_cost": "0.25", + "access_type": "ALL", + "access_type": "ALL", + "cost_info": { + "cost_info": { + "filtered": "100.00", + "filtered": "100.00", + "query_cost": "0.75" + "query_cost": "0.75" + "rows_examined_per_scan": 5, + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "rows_produced_per_join": 5, + "table_name": "t1", + "table_name": "t2", + "used_columns": [ + "used_columns": [ + ] + ] + }, + }, + "cost_info": { + "cost_info": { + "select_id": 2, + "select_id": 3, + "table": { + "table": { + } + } + }, + }, + "b" + "b" + "cacheable": true, + "cacheable": true, + "data_read_per_join": "2K" + "data_read_per_join": "440" + "dependent": false, + "dependent": false, + "eval_cost": "0.50", + "eval_cost": "2.50", + "prefix_cost": "1.00", + "prefix_cost": "4.00", + "query_block": { + "query_block": { + "read_cost": "0.50", + "read_cost": "0.50", + "using_temporary_table": true, + "using_temporary_table": true, + } + } + "access_type": "ALL", + "access_type": "ALL", + "cost_info": { + "cost_info": { + "filtered": "100.00", + "filtered": "100.00", + "materialized_from_subquery": { + "materialized_from_subquery": { + "rows_examined_per_scan": 5, + "rows_examined_per_scan": 5, + "rows_produced_per_join": 25, + "rows_produced_per_join": 5, + "table_name": "t1", + "table_name": "t2", + "used_columns": [ + "used_columns": [ + "using_join_buffer": "hash join", + ], + ], + } + } + }, + }, + "table": { + "table": { + } + } + "query_cost": "4.00" + { + { + } + }, + "cost_info": { + "nested_loop": [ + "select_id": 1, + ] + }, + "query_block": { + } +Note 1003 /* select#1 */ select `t1`.`b` AS `b`,`t2`.`b` AS `b` from (/* select#2 */ select `test`.`t1`.`b` AS `b` from `test`.`t1`) `t1` join (/* select#3 */ select `test`.`t2`.`b` AS `b` from `test`.`t2`) `t2` +Warnings: +{ +} +select * from (select b from t1) as t1, (select b from t2) as t2; +b b +a d +a e +a e +a f +a f +b d +b e +b e +b f +b f +c d +c d +c d +c e +c e +c e +c e +c e +c e +c f +c f +c f +c f +c f +c f +explain format = json select * from t1, (select * from t6) as t where t.a =5; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.95" + }, + "nested_loop": [ + { + "table": { + "table_name": "t", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 2, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.20", + "prefix_cost": "0.70", + "data_read_per_join": "48" + }, + "used_columns": [ + "a", + "b", + "c", + "d" + ], + "materialized_from_subquery": { + "using_temporary_table": true, + "dependent": false, + "cacheable": true, + "query_block": { + "select_id": 2, + "cost_info": { + "query_cost": "0.35" + }, + "table": { + "table_name": "t6", + "access_type": "ref", + "possible_keys": [ + "t6_indx1" + ], + "key": "t6_indx1", + "used_key_parts": [ + "a" + ], + "key_length": "5", + "ref": [ + "const" + ], + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.10", + "prefix_cost": "0.35", + "data_read_per_join": "24" + }, + "used_columns": [ + "a", + "b", + "c", + "d" + ] + } + } + } + } + }, + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 10, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "1.00", + "prefix_cost": "1.95", + "data_read_per_join": "880" + }, + "used_columns": [ + "a", + "b" + ] + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`t`.`a` AS `a`,`t`.`b` AS `b`,`t`.`c` AS `c`,`t`.`d` AS `d` from `test`.`t1` join (/* select#2 */ select `test`.`t6`.`a` AS `a`,`test`.`t6`.`b` AS `b`,`test`.`t6`.`c` AS `c`,`test`.`t6`.`d` AS `d` from `test`.`t6` where (`test`.`t6`.`a` = 5)) `t` +select * from t1, (select * from t6) as t where t.a =5; +a b a b c d +explain format = json select * from t1 where t1.a in (select a from t2) ; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "3.50" + }, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "440" + }, + "used_columns": [ + "a", + "b" + ], + "attached_condition": "(`test`.`t1`.`a` is not null)" + } + }, + { + "table": { + "table_name": "", + "access_type": "eq_ref", + "key": "", + "key_length": "5", + "ref": [ + "test.t1.a" + ], + "rows_examined_per_scan": 1, + "materialized_from_subquery": { + "using_temporary_table": true, + "query_block": { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "440" + }, + "used_columns": [ + "a" + ] + } + } + } + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t2`) where (``.`a` = `test`.`t1`.`a`) +select * from t1 where t1.a in (select a from t2) ; +a b +2 b +3 c +3 c +4 c +set optimizer_switch='materialization=off'; +set optimizer_switch='firstmatch=off'; +set optimizer_switch='loosescan=off'; +explain format = json select * from t1 where t1.a in (select a from t2) ; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "5.50" + }, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "480" + }, + "used_columns": [ + "a", + "b" + ], + "query_block": { + "cost_info": { + "query_cost": "5.50" + }, + "duplicates_removal": { + "using_temporary_table": true, + "nested_loop": [ + { + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "440" + }, + "used_columns": [ + "a", + "b" + ] + } + }, + { + "table": { + "select_id": 2, + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "20.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "5.50", + "data_read_per_join": "440" + }, + "used_columns": [ + "a" + ], + "attached_condition": "(`test`.`t2`.`a` = `test`.`t1`.`a`)" + } + } + ] + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t2`) where (`test`.`t2`.`a` = `test`.`t1`.`a`) +select * from t1 where t1.a in (select a from t2) ; +a b +2 b +3 c +3 c +4 c +set optimizer_switch='default,derived_merge=off'; +explain format = json update t1, t2 set t1.a = 9, t2.a = 10 where t1.b = 'a'; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.50" + }, + "nested_loop": [ + { + "table": { + "update": true, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 1, + "filtered": "20.00", + "cost_info": { + "read_cost": "0.65", + "eval_cost": "0.10", + "prefix_cost": "0.75", + "data_read_per_join": "88" + }, + "used_columns": [ + "a", + "b" + ], + "attached_condition": "(`test`.`t1`.`b` = 'a')" + } + }, + { + "table": { + "update": true, + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "1.50", + "data_read_per_join": "440" + }, + "used_columns": [ + "a", + "b" + ] + } + } + ] + } +} +Warnings: +Note 1003 update `test`.`t1` join `test`.`t2` set `test`.`t1`.`a` = 9,`test`.`t2`.`a` = 10 where (`test`.`t1`.`b` = 'a') +update t1, t2 set t1.a = 9, t2.a = 10 where t1.b = 'a'; +explain format = json select count(distinct a) from t1; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.75" + }, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "440" + }, + "used_columns": [ + "a" + ] + } + } +} +Warnings: +Note 1003 /* select#1 */ select count(distinct `test`.`t1`.`a`) AS `count(distinct a)` from `test`.`t1` +select count(distinct a) from t1; +count(distinct a) +4 +explain format = json select b, group_concat(a) from t1; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.75" + }, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "440" + }, + "used_columns": [ + "a", + "b" + ] + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`b` AS `b`,group_concat(`test`.`t1`.`a` separator ',') AS `group_concat(a)` from `test`.`t1` +select b, group_concat(a) from t1; +b group_concat(a) +a 9,2,3,3,4 +select * from t1; +a b +9 a +2 b +3 c +3 c +4 c +explain format = json select b, count(a), sum(a), avg(a), std(a), +min(a), max(a), bit_and(a), bit_or(a) from t1 group by b; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.75" + }, + "grouping_operation": { + "using_temporary_table": true, + "using_filesort": false, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "440" + }, + "used_columns": [ + "a", + "b" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`b` AS `b`,count(`test`.`t1`.`a`) AS `count(a)`,sum(`test`.`t1`.`a`) AS `sum(a)`,avg(`test`.`t1`.`a`) AS `avg(a)`,std(`test`.`t1`.`a`) AS `std(a)`,min(`test`.`t1`.`a`) AS `min(a)`,max(`test`.`t1`.`a`) AS `max(a)`,bit_and(`test`.`t1`.`a`) AS `bit_and(a)`,bit_or(`test`.`t1`.`a`) AS `bit_or(a)` from `test`.`t1` group by `test`.`t1`.`b` +select b, count(a), sum(a), avg(a), std(a), min(a), +max(a), bit_and(a), bit_or(a) from t1 group by b; +b count(a) sum(a) avg(a) std(a) min(a) max(a) bit_and(a) bit_or(a) +a 1 9 9.0000 0 9 9 9 9 +b 1 2 2.0000 0 2 2 2 2 +c 3 10 3.3333 0.4714045207910316 3 4 0 7 +select sql_big_result * from performance_schema.global_variables where variable_name like 'internal_tmp_mem_storage_engine'; +VARIABLE_NAME VARIABLE_VALUE +internal_tmp_mem_storage_engine TempTable +select 1 union distinct select 1 union all select 1; +1 +1 +1 +select alias1.`col_int_key` AS field1 from (t8 as alias1) where (5) in +(select 7 union select 1) order by alias1.`col_varchar_key` asc; +field1 +select count(table2.col_date_key) as field1 from +(t10 as table1 inner join +((t10 as table2 right join +t9 as table3 on +((table3.pk = table2.pk) or +(table3.pk = table2.col_int_key)))) +on ((table3.pk < table2.col_int_nokey))) +order by field1 ASC; +field1 +2200 +select distinct table1.col_varchar_1024_utf8_key as field1 +from t11 as table1 left join t11 as table2 on +table1.col_varchar_1024_utf8 = table2.col_varchar_1024_latin1_key +order by field1; +field1 +YTLDF +yvuwdllyhymuwyypoiuyeqbnaanbursgddnqhyvxnnpadsjiqdkajofferjfslatroorycttbiuhlubvmoikwwnalqyewgthdmfvsedatazrflwenzeiwdxtheqppbmqfydsawvanehgvfvbsqxzkqzhtjkybvikmpexipoddmoulsnzfchusfgkdazecevrpuakfioamyyqyribcnydfxmmzsxcpkydyczmeajaebsaskneaqwxjbpjptiwgiizoxfygnbjojpifpzldsdhrukdbwpzribxgafunywmmcfpjugozduylotsugqocbadhcnxjqlugncbebwsbobhxgghyyphxfqqnpliazusgjswynfotwdonpbkllfdbuoqceirksegypasuuxnrjumrkaryhkgkbdfgoqbdmrdrmpvwitqzswgossxltimkbtrxitnmigcxgfaqmrnv +select t from t12 group by c; +t +NULL + +1 +a +hello +HELLO MY +select count(outr.col_varchar_nokey) AS x +from t13 as outr2 left join +(select * from t13) as outr +on (outr2.col_time_key > outr.col_date_key) +where outr.pk in +(select innr.col_int_nokey AS y from +(select * from t14) as innr2 left join +(select * from t14) AS innr +ON (innr2.col_int_nokey = innr.col_int_key) +where innr.col_varchar_nokey > innr.col_varchar_key +or not outr.pk > 9) +or outr.col_varchar_key is null; +x +102 +SET @@optimizer_switch=@optimizer_switch_saved; +SET GLOBAL innodb_fast_shutdown = 0; +# restart: --big-tables=1 --innodb-read-only +SET @optimizer_switch_saved= @@optimizer_switch; +SET @@optimizer_switch="derived_merge=off"; +explain format = json select sql_buffer_result * from t1; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.75" + }, + "buffer_result": { + "using_temporary_table": true, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "480" + }, + "used_columns": [ + "a", + "b" + ], + "buffer_result": { + "using_temporary_table": true, + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "440" + }, + "used_columns": [ + "a", + "b" + ] + } + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select sql_buffer_result `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` +select sql_buffer_result * from t1; +a b +9 a +2 b +3 c +3 c +4 c +explain format = json select sql_buffer_result * from t2; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.75" + }, + "buffer_result": { + "using_temporary_table": true, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "480" + }, + "used_columns": [ + "a", + "b" + ], + "buffer_result": { + "using_temporary_table": true, + "table": { + "select_id": 2, + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "440" + }, + "used_columns": [ + "a", + "b" + ] + } + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select sql_buffer_result `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t2` +select sql_buffer_result * from t2; +a b +10 d +10 e +10 f +10 f +10 e +explain format = json select * from t1 left join t2 on t1.b = t2.b order by t1.a; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "28.50" + }, + "ordering_operation": { + "using_temporary_table": true, + "using_filesort": true, + "cost_info": { + "sort_cost": "25.00" + }, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "880" + }, + "used_columns": [ + "a", + "b", + "a", + "b" + ], + "ordering_operation": { + "using_temporary_table": true, + "using_filesort": true, + "nested_loop": [ + { + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "440" + }, + "used_columns": [ + "a", + "b" + ] + } + }, + { + "table": { + "select_id": 2, + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 25, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "2.50", + "prefix_cost": "3.50", + "data_read_per_join": "2K" + }, + "used_columns": [ + "a", + "b" + ], + "attached_condition": "(is_not_null_compl(t2), (`test`.`t2`.`b` = `test`.`t1`.`b`), true)" + } + } + ] + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`b` = `test`.`t1`.`b`)) where true order by `test`.`t1`.`a` +select * from t1 left join t2 on t1.b = t2.b order by t1.a; +a b a b +2 b NULL NULL +3 c NULL NULL +3 c NULL NULL +4 c NULL NULL +9 a NULL NULL +explain format = json select * from t1 order by func1(a); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "5.75" + }, + "ordering_operation": { + "using_temporary_table": true, + "using_filesort": true, + "cost_info": { + "sort_cost": "5.00" + }, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "440" + }, + "used_columns": [ + "a", + "b" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` order by `func1`(`test`.`t1`.`a`) +select * from t1 order by func1(a); +a b +2 b +3 c +3 c +4 c +9 a +explain format = json select a from t1 group by b order by sum(a); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.75" + }, + "ordering_operation": { + "using_filesort": true, + "grouping_operation": { + "using_temporary_table": true, + "using_filesort": false, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "560" + }, + "used_columns": [ + "sum(t1.a)", + "b", + "a" + ], + "ordering_operation": { + "using_filesort": true, + "grouping_operation": { + "using_temporary_table": true, + "using_filesort": false, + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "440" + }, + "used_columns": [ + "a", + "b" + ] + } + } + } + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` group by `test`.`t1`.`b` order by sum(`sum(t1.a)`) +select a from t1 group by b order by sum(a); +a +2 +9 +3 +explain format = json select a from t7 group by b order by sum(a); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.75" + }, + "ordering_operation": { + "using_temporary_table": true, + "using_filesort": true, + "grouping_operation": { + "using_filesort": false, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "560" + }, + "used_columns": [ + "sum(t7.a)", + "b", + "a" + ], + "ordering_operation": { + "using_temporary_table": true, + "using_filesort": true, + "grouping_operation": { + "using_filesort": false, + "table": { + "select_id": 2, + "table_name": "t7", + "access_type": "index", + "possible_keys": [ + "indx7" + ], + "key": "indx7", + "used_key_parts": [ + "b" + ], + "key_length": "83", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "440" + }, + "used_columns": [ + "a", + "b" + ] + } + } + } + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t7`.`a` AS `a` from `test`.`t7` group by `test`.`t7`.`b` order by sum(`sum(t7.a)`) +select a from t7 group by b order by sum(a); +a +1 +2 +3 +explain format = json select sql_big_result distinct * from t1, t2; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "3.50" + }, + "duplicates_removal": { + "using_temporary_table": true, + "using_filesort": false, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "440" + }, + "used_columns": [ + "a", + "b" + ] + } + }, + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 25, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "2.50", + "prefix_cost": "3.50", + "data_read_per_join": "2K" + }, + "used_columns": [ + "a", + "b" + ] + } + } + ] + } + } +} +Warnings: +Note 1003 /* select#1 */ select distinct sql_big_result `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` join `test`.`t2` +select sql_big_result distinct * from t1, t2; +a b a b +2 b 10 d +2 b 10 e +2 b 10 f +3 c 10 d +3 c 10 e +3 c 10 f +4 c 10 d +4 c 10 e +4 c 10 f +9 a 10 d +9 a 10 e +9 a 10 f +explain format = json select sql_big_result t1.b from t1, t2 group by t1.b; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "3.50" + }, + "grouping_operation": { + "using_temporary_table": true, + "using_filesort": false, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "440" + }, + "used_columns": [ + "b" + ], + "grouping_operation": { + "using_temporary_table": true, + "using_filesort": false, + "nested_loop": [ + { + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "440" + }, + "used_columns": [ + "b" + ] + } + }, + { + "table": { + "select_id": 2, + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 25, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "2.50", + "prefix_cost": "3.50", + "data_read_per_join": "2K" + } + } + } + ] + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select sql_big_result `test`.`t1`.`b` AS `b` from `test`.`t1` join `test`.`t2` group by `test`.`t1`.`b` +select sql_big_result t1.b from t1, t2 group by t1.b; +b +a +b +c +explain format = json select sql_big_result distinct t1.a from t1, t2 group by t1.a, t1.b; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "3.50" + }, + "duplicates_removal": { + "using_filesort": false, + "grouping_operation": { + "using_temporary_table": true, + "using_filesort": false, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "440" + }, + "used_columns": [ + "a", + "b" + ] + } + }, + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 25, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "2.50", + "prefix_cost": "3.50", + "data_read_per_join": "2K" + } + } + } + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select distinct sql_big_result `test`.`t1`.`a` AS `a` from `test`.`t1` join `test`.`t2` group by `test`.`t1`.`a`,`test`.`t1`.`b` +select sql_big_result distinct t1.a from t1, t2 group by t1.a, t1.b; +a +2 +3 +4 +9 +explain format = json select t1.* from t1 inner join t2 on t1.a = t2.a order by t2.a; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "8.50" + }, + "ordering_operation": { + "using_temporary_table": true, + "using_filesort": true, + "cost_info": { + "sort_cost": "5.00" + }, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "480" + }, + "used_columns": [ + "a", + "a", + "b" + ], + "ordering_operation": { + "using_temporary_table": true, + "using_filesort": true, + "nested_loop": [ + { + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "440" + }, + "used_columns": [ + "a", + "b" + ] + } + }, + { + "table": { + "select_id": 2, + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "20.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "3.50", + "data_read_per_join": "440" + }, + "used_columns": [ + "a" + ], + "attached_condition": "(`test`.`t2`.`a` = `test`.`t1`.`a`)" + } + } + ] + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` join `test`.`t2` where (`test`.`t2`.`a` = `test`.`t1`.`a`) order by `test`.`t2`.`a` +select t1.* from t1 inner join t2 on t1.a = t2.a order by t2.a; +a b +explain format = json select t1.* from t1, t2 where t1.a = t2.a order by t1.a; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "8.50" + }, + "ordering_operation": { + "using_temporary_table": true, + "using_filesort": true, + "cost_info": { + "sort_cost": "5.00" + }, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "480" + }, + "used_columns": [ + "a", + "b" + ], + "ordering_operation": { + "using_temporary_table": true, + "using_filesort": true, + "nested_loop": [ + { + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "440" + }, + "used_columns": [ + "a", + "b" + ] + } + }, + { + "table": { + "select_id": 2, + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "20.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "3.50", + "data_read_per_join": "440" + }, + "used_columns": [ + "a" + ], + "attached_condition": "(`test`.`t2`.`a` = `test`.`t1`.`a`)" + } + } + ] + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` join `test`.`t2` where (`test`.`t2`.`a` = `test`.`t1`.`a`) order by `test`.`t1`.`a` +select t1.* from t1, t2 where t1.a = t2.a order by t1.a; +a b +explain format = json select t1.* from t1 inner join t2 where t1.a = t2.a group by t1.a; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "3.50" + }, + "grouping_operation": { + "using_temporary_table": true, + "using_filesort": false, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "480" + }, + "used_columns": [ + "a", + "b" + ], + "grouping_operation": { + "using_temporary_table": true, + "using_filesort": false, + "nested_loop": [ + { + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "440" + }, + "used_columns": [ + "a", + "b" + ] + } + }, + { + "table": { + "select_id": 2, + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "20.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "3.50", + "data_read_per_join": "440" + }, + "used_columns": [ + "a" + ], + "attached_condition": "(`test`.`t2`.`a` = `test`.`t1`.`a`)" + } + } + ] + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` join `test`.`t2` where (`test`.`t2`.`a` = `test`.`t1`.`a`) group by `test`.`t1`.`a` +select t1.* from t1 inner join t2 where t1.a = t2.a group by t1.a; +a b +explain format = json select t1.* from t1 inner join t2 where t1.a = t2.a group by t2.a; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "3.50" + }, + "grouping_operation": { + "using_temporary_table": true, + "using_filesort": false, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "480" + }, + "used_columns": [ + "a", + "a", + "b" + ], + "grouping_operation": { + "using_temporary_table": true, + "using_filesort": false, + "nested_loop": [ + { + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "440" + }, + "used_columns": [ + "a", + "b" + ] + } + }, + { + "table": { + "select_id": 2, + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "20.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "3.50", + "data_read_per_join": "440" + }, + "used_columns": [ + "a" + ], + "attached_condition": "(`test`.`t2`.`a` = `test`.`t1`.`a`)" + } + } + ] + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` join `test`.`t2` where (`test`.`t2`.`a` = `test`.`t1`.`a`) group by `test`.`t2`.`a` +select t1.* from t1 inner join t2 where t1.a = t2.a group by t2.a; +a b +explain format = json select a from t1 group by a order by a; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "5.75" + }, + "ordering_operation": { + "using_filesort": false, + "grouping_operation": { + "using_temporary_table": true, + "using_filesort": true, + "cost_info": { + "sort_cost": "5.00" + }, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "80" + }, + "used_columns": [ + "a" + ], + "ordering_operation": { + "using_filesort": false, + "grouping_operation": { + "using_temporary_table": true, + "using_filesort": true, + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "440" + }, + "used_columns": [ + "a" + ] + } + } + } + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` group by `test`.`t1`.`a` order by `test`.`t1`.`a` +select a from t1 group by a order by a; +a +2 +3 +4 +9 +explain format = json select b from t1 group by b order by a; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.75" + }, + "ordering_operation": { + "using_filesort": true, + "grouping_operation": { + "using_temporary_table": true, + "using_filesort": false, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "480" + }, + "used_columns": [ + "a", + "b" + ], + "ordering_operation": { + "using_filesort": true, + "grouping_operation": { + "using_temporary_table": true, + "using_filesort": false, + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "440" + }, + "used_columns": [ + "a", + "b" + ] + } + } + } + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`b` AS `b` from `test`.`t1` group by `test`.`t1`.`b` order by `test`.`t1`.`a` +select b from t1 group by b order by a; +b +b +c +a +explain format = json select distinct t1.a from t1, t2 where t1.b = t2.b; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "3.50" + }, + "duplicates_removal": { + "using_temporary_table": true, + "using_filesort": false, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "440" + }, + "used_columns": [ + "a", + "b" + ] + } + }, + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "20.00", + "distinct": true, + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "3.50", + "data_read_per_join": "440" + }, + "used_columns": [ + "b" + ], + "attached_condition": "(`test`.`t2`.`b` = `test`.`t1`.`b`)" + } + } + ] + } + } +} +Warnings: +Note 1003 /* select#1 */ select distinct `test`.`t1`.`a` AS `a` from `test`.`t1` join `test`.`t2` where (`test`.`t2`.`b` = `test`.`t1`.`b`) +select distinct t1.a from t1, t2 where t1.b = t2.b; +a +explain format = json select distinct a from t1 group by b,a; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.75" + }, + "duplicates_removal": { + "using_filesort": false, + "grouping_operation": { + "using_temporary_table": true, + "using_filesort": false, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "440" + }, + "used_columns": [ + "a", + "b" + ] + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select distinct `test`.`t1`.`a` AS `a` from `test`.`t1` group by `test`.`t1`.`b`,`test`.`t1`.`a` +select distinct a from t1 group by b,a; +a +2 +3 +4 +9 +set @old_sort_buffer_size = @@sort_buffer_size; +set @@sort_buffer_size = 32804; +explain format = json select distinct b from t3 group by a having count(*) > 1; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.35" + }, + "duplicates_removal": { + "using_filesort": false, + "grouping_operation": { + "using_temporary_table": true, + "using_filesort": false, + "table": { + "table_name": "t3", + "access_type": "ALL", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.10", + "prefix_cost": "0.35", + "data_read_per_join": "88" + }, + "used_columns": [ + "a", + "b" + ] + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select distinct `test`.`t3`.`b` AS `b` from `test`.`t3` group by `test`.`t3`.`a` having (count(0) > 1) +select distinct b from t3 group by a having count(*) > 1; +b +select distinct b from t3 group by a; +b +set @@sort_buffer_size = @old_sort_buffer_size; +explain format = json select distinct t4.a,e from t4, t1 order by t4.b; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "6.11" + }, + "ordering_operation": { + "using_temporary_table": true, + "using_filesort": true, + "duplicates_removal": { + "using_temporary_table": true, + "using_filesort": false, + "cost_info": { + "sort_cost": "5.00" + }, + "nested_loop": [ + { + "table": { + "table_name": "t4", + "access_type": "ALL", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.10", + "prefix_cost": "0.35", + "data_read_per_join": "32" + }, + "used_columns": [ + "a", + "b", + "e" + ] + } + }, + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "distinct": true, + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.27", + "eval_cost": "0.50", + "prefix_cost": "1.12", + "data_read_per_join": "440" + } + } + } + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select distinct `test`.`t4`.`a` AS `a`,`test`.`t4`.`e` AS `e` from `test`.`t4` join `test`.`t1` order by `test`.`t4`.`b` +select distinct t4.a,e from t4, t1 order by t4.b; +a e +1 5 +explain format = json select * from t1 union all select * from t2; +EXPLAIN +{ + "query_block": { + "union_result": { + "using_temporary_table": false, + "query_specifications": [ + { + "dependent": false, + "cacheable": true, + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.75" + }, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "440" + }, + "used_columns": [ + "a", + "b" + ] + } + } + }, + { + "dependent": false, + "cacheable": true, + "query_block": { + "select_id": 2, + "cost_info": { + "query_cost": "0.75" + }, + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "440" + }, + "used_columns": [ + "a", + "b" + ] + } + } + } + ] + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` union all /* select#2 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t2` +select * from t1 union all select * from t2; +a b +9 a +2 b +3 c +3 c +4 c +10 d +10 e +10 f +10 f +10 e +explain format = json select * from t1 union select * from t2 order by b; +EXPLAIN +{ + "query_block": { + "union_result": { + "using_temporary_table": true, + "table_name": "", + "access_type": "ALL", + "query_specifications": [ + { + "dependent": false, + "cacheable": true, + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.75" + }, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "440" + }, + "used_columns": [ + "a", + "b" + ] + } + } + }, + { + "dependent": false, + "cacheable": true, + "query_block": { + "select_id": 2, + "cost_info": { + "query_cost": "0.75" + }, + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "440" + }, + "used_columns": [ + "a", + "b" + ] + } + } + } + ] + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` union /* select#2 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t2` order by `b` +select * from t1 union select * from t2 order by b; +a b +9 a +2 b +3 c +4 c +10 d +10 e +10 f +explain format = json select tt.* from (select * from t1) as tt; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.00" + }, + "table": { + "table_name": "tt", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.50", + "prefix_cost": "1.00", + "data_read_per_join": "480" + }, + "used_columns": [ + "a", + "b" + ], + "materialized_from_subquery": { + "using_temporary_table": true, + "dependent": false, + "cacheable": true, + "query_block": { + "select_id": 2, + "cost_info": { + "query_cost": "0.75" + }, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "440" + }, + "used_columns": [ + "a", + "b" + ] + } + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `tt`.`a` AS `a`,`tt`.`b` AS `b` from (/* select#2 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1`) `tt` +select tt.* from (select * from t1) as tt; +a b +9 a +2 b +3 c +3 c +4 c +select * from t5; +a b +1 7 +1 8 +explain format = json select b from (select b from t5 where b > 5) tt; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.70" + }, + "table": { + "table_name": "tt", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 2, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.20", + "prefix_cost": "0.70", + "data_read_per_join": "32" + }, + "used_columns": [ + "b" + ], + "materialized_from_subquery": { + "using_temporary_table": true, + "dependent": false, + "cacheable": true, + "query_block": { + "select_id": 2, + "cost_info": { + "query_cost": "0.45" + }, + "table": { + "table_name": "t5", + "access_type": "index", + "possible_keys": [ + "PRIMARY" + ], + "key": "PRIMARY", + "used_key_parts": [ + "b" + ], + "key_length": "4", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 2, + "filtered": "100.00", + "using_index": true, + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.20", + "prefix_cost": "0.45", + "data_read_per_join": "32" + }, + "used_columns": [ + "b" + ], + "attached_condition": "(`test`.`t5`.`b` > 5)" + } + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `tt`.`b` AS `b` from (/* select#2 */ select `test`.`t5`.`b` AS `b` from `test`.`t5` where (`test`.`t5`.`b` > 5)) `tt` +select b from (select b from t5 where b > 5) tt; +b +7 +8 +explain format = json select * from (select b from t1) as t1, (select b from t2) as t2; +EXPLAIN + "b" + "b" + "data_read_per_join": "440" + "data_read_per_join": "440" + "eval_cost": "0.50", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "prefix_cost": "0.75", + "read_cost": "0.25", + "read_cost": "0.25", + "access_type": "ALL", + "access_type": "ALL", + "cost_info": { + "cost_info": { + "filtered": "100.00", + "filtered": "100.00", + "query_cost": "0.75" + "query_cost": "0.75" + "rows_examined_per_scan": 5, + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "rows_produced_per_join": 5, + "table_name": "t1", + "table_name": "t2", + "used_columns": [ + "used_columns": [ + ] + ] + }, + }, + "cost_info": { + "cost_info": { + "select_id": 2, + "select_id": 3, + "table": { + "table": { + } + } + }, + }, + "b" + "b" + "cacheable": true, + "cacheable": true, + "data_read_per_join": "2K" + "data_read_per_join": "440" + "dependent": false, + "dependent": false, + "eval_cost": "0.50", + "eval_cost": "2.50", + "prefix_cost": "1.00", + "prefix_cost": "4.00", + "query_block": { + "query_block": { + "read_cost": "0.50", + "read_cost": "0.50", + "using_temporary_table": true, + "using_temporary_table": true, + } + } + "access_type": "ALL", + "access_type": "ALL", + "cost_info": { + "cost_info": { + "filtered": "100.00", + "filtered": "100.00", + "materialized_from_subquery": { + "materialized_from_subquery": { + "rows_examined_per_scan": 5, + "rows_examined_per_scan": 5, + "rows_produced_per_join": 25, + "rows_produced_per_join": 5, + "table_name": "t1", + "table_name": "t2", + "used_columns": [ + "used_columns": [ + "using_join_buffer": "hash join", + ], + ], + } + } + }, + }, + "table": { + "table": { + } + } + "query_cost": "4.00" + { + { + } + }, + "cost_info": { + "nested_loop": [ + "select_id": 1, + ] + }, + "query_block": { + } +Note 1003 /* select#1 */ select `t1`.`b` AS `b`,`t2`.`b` AS `b` from (/* select#2 */ select `test`.`t1`.`b` AS `b` from `test`.`t1`) `t1` join (/* select#3 */ select `test`.`t2`.`b` AS `b` from `test`.`t2`) `t2` +Warnings: +{ +} +select * from (select b from t1) as t1, (select b from t2) as t2; +b b +a d +a e +a e +a f +a f +b d +b e +b e +b f +b f +c d +c d +c d +c e +c e +c e +c e +c e +c e +c f +c f +c f +c f +c f +c f +explain format = json select * from t1, (select * from t6) as t where t.a =5; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.95" + }, + "nested_loop": [ + { + "table": { + "table_name": "t", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 2, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.20", + "prefix_cost": "0.70", + "data_read_per_join": "48" + }, + "used_columns": [ + "a", + "b", + "c", + "d" + ], + "materialized_from_subquery": { + "using_temporary_table": true, + "dependent": false, + "cacheable": true, + "query_block": { + "select_id": 2, + "cost_info": { + "query_cost": "0.35" + }, + "table": { + "table_name": "t6", + "access_type": "ref", + "possible_keys": [ + "t6_indx1" + ], + "key": "t6_indx1", + "used_key_parts": [ + "a" + ], + "key_length": "5", + "ref": [ + "const" + ], + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.10", + "prefix_cost": "0.35", + "data_read_per_join": "24" + }, + "used_columns": [ + "a", + "b", + "c", + "d" + ] + } + } + } + } + }, + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 10, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "1.00", + "prefix_cost": "1.95", + "data_read_per_join": "880" + }, + "used_columns": [ + "a", + "b" + ] + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`t`.`a` AS `a`,`t`.`b` AS `b`,`t`.`c` AS `c`,`t`.`d` AS `d` from `test`.`t1` join (/* select#2 */ select `test`.`t6`.`a` AS `a`,`test`.`t6`.`b` AS `b`,`test`.`t6`.`c` AS `c`,`test`.`t6`.`d` AS `d` from `test`.`t6` where (`test`.`t6`.`a` = 5)) `t` +select * from t1, (select * from t6) as t where t.a =5; +a b a b c d +explain format = json select * from t1 where t1.a in (select a from t2) ; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "3.50" + }, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "440" + }, + "used_columns": [ + "a", + "b" + ], + "attached_condition": "(`test`.`t1`.`a` is not null)" + } + }, + { + "table": { + "table_name": "", + "access_type": "eq_ref", + "key": "", + "key_length": "5", + "ref": [ + "test.t1.a" + ], + "rows_examined_per_scan": 1, + "materialized_from_subquery": { + "using_temporary_table": true, + "query_block": { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "440" + }, + "used_columns": [ + "a" + ] + } + } + } + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t2`) where (``.`a` = `test`.`t1`.`a`) +select * from t1 where t1.a in (select a from t2) ; +a b +set optimizer_switch='materialization=off'; +set optimizer_switch='firstmatch=off'; +set optimizer_switch='loosescan=off'; +explain format = json select * from t1 where t1.a in (select a from t2) ; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "5.50" + }, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "480" + }, + "used_columns": [ + "a", + "b" + ], + "query_block": { + "cost_info": { + "query_cost": "5.50" + }, + "duplicates_removal": { + "using_temporary_table": true, + "nested_loop": [ + { + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "440" + }, + "used_columns": [ + "a", + "b" + ] + } + }, + { + "table": { + "select_id": 2, + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "20.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "5.50", + "data_read_per_join": "440" + }, + "used_columns": [ + "a" + ], + "attached_condition": "(`test`.`t2`.`a` = `test`.`t1`.`a`)" + } + } + ] + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t2`) where (`test`.`t2`.`a` = `test`.`t1`.`a`) +select * from t1 where t1.a in (select a from t2) ; +a b +set optimizer_switch='default,derived_merge=off'; +explain format = json select count(distinct a) from t1; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.75" + }, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "440" + }, + "used_columns": [ + "a" + ] + } + } +} +Warnings: +Note 1003 /* select#1 */ select count(distinct `test`.`t1`.`a`) AS `count(distinct a)` from `test`.`t1` +select count(distinct a) from t1; +count(distinct a) +4 +explain format = json select b, group_concat(a) from t1; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.75" + }, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "440" + }, + "used_columns": [ + "a", + "b" + ] + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`b` AS `b`,group_concat(`test`.`t1`.`a` separator ',') AS `group_concat(a)` from `test`.`t1` +select b, group_concat(a) from t1; +b group_concat(a) +a 9,2,3,3,4 +select * from t1; +a b +9 a +2 b +3 c +3 c +4 c +explain format = json select b, count(a), sum(a), avg(a), std(a), +min(a), max(a), bit_and(a), bit_or(a) from t1 group by b; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.75" + }, + "grouping_operation": { + "using_temporary_table": true, + "using_filesort": false, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "440" + }, + "used_columns": [ + "a", + "b" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`b` AS `b`,count(`test`.`t1`.`a`) AS `count(a)`,sum(`test`.`t1`.`a`) AS `sum(a)`,avg(`test`.`t1`.`a`) AS `avg(a)`,std(`test`.`t1`.`a`) AS `std(a)`,min(`test`.`t1`.`a`) AS `min(a)`,max(`test`.`t1`.`a`) AS `max(a)`,bit_and(`test`.`t1`.`a`) AS `bit_and(a)`,bit_or(`test`.`t1`.`a`) AS `bit_or(a)` from `test`.`t1` group by `test`.`t1`.`b` +select b, count(a), sum(a), avg(a), std(a), min(a), +max(a), bit_and(a), bit_or(a) from t1 group by b; +b count(a) sum(a) avg(a) std(a) min(a) max(a) bit_and(a) bit_or(a) +a 1 9 9.0000 0 9 9 9 9 +b 1 2 2.0000 0 2 2 2 2 +c 3 10 3.3333 0.4714045207910316 3 4 0 7 +select sql_big_result * from performance_schema.global_variables where variable_name like 'internal_tmp_mem_storage_engine'; +VARIABLE_NAME VARIABLE_VALUE +internal_tmp_mem_storage_engine TempTable +select 1 union distinct select 1 union all select 1; +1 +1 +1 +select alias1.`col_int_key` AS field1 from (t8 as alias1) where (5) in +(select 7 union select 1) order by alias1.`col_varchar_key` asc; +field1 +select count(table2.col_date_key) as field1 from +(t10 as table1 inner join +((t10 as table2 right join +t9 as table3 on +((table3.pk = table2.pk) or +(table3.pk = table2.col_int_key)))) +on ((table3.pk < table2.col_int_nokey))) +order by field1 ASC; +field1 +2200 +select distinct table1.col_varchar_1024_utf8_key as field1 +from t11 as table1 left join t11 as table2 on +table1.col_varchar_1024_utf8 = table2.col_varchar_1024_latin1_key +order by field1; +field1 +YTLDF +yvuwdllyhymuwyypoiuyeqbnaanbursgddnqhyvxnnpadsjiqdkajofferjfslatroorycttbiuhlubvmoikwwnalqyewgthdmfvsedatazrflwenzeiwdxtheqppbmqfydsawvanehgvfvbsqxzkqzhtjkybvikmpexipoddmoulsnzfchusfgkdazecevrpuakfioamyyqyribcnydfxmmzsxcpkydyczmeajaebsaskneaqwxjbpjptiwgiizoxfygnbjojpifpzldsdhrukdbwpzribxgafunywmmcfpjugozduylotsugqocbadhcnxjqlugncbebwsbobhxgghyyphxfqqnpliazusgjswynfotwdonpbkllfdbuoqceirksegypasuuxnrjumrkaryhkgkbdfgoqbdmrdrmpvwitqzswgossxltimkbtrxitnmigcxgfaqmrnv +select t from t12 group by c; +t +NULL + +1 +a +hello +HELLO MY +select count(outr.col_varchar_nokey) AS x +from t13 as outr2 left join +(select * from t13) as outr +on (outr2.col_time_key > outr.col_date_key) +where outr.pk in +(select innr.col_int_nokey AS y from +(select * from t14) as innr2 left join +(select * from t14) AS innr +ON (innr2.col_int_nokey = innr.col_int_key) +where innr.col_varchar_nokey > innr.col_varchar_key +or not outr.pk > 9) +or outr.col_varchar_key is null; +x +102 +SET @@optimizer_switch=@optimizer_switch_saved; +# restart +select @@big_tables; +@@big_tables +1 +create table t0 (m int, n int, key(m)) engine=innodb; +begin; +select count(*) from t0; +count(*) +0 +set @@session.sql_mode = ANSI; +set @@session.tmp_table_size = 0; +Warnings: +Warning 1292 Truncated incorrect tmp_table_size value: '0' +set @@session.big_tables = 1; +select @@big_tables; +@@big_tables +1 +select event_name, e.min_timer_wait, min(t.min_timer_wait) from +performance_schema.events_waits_summary_global_by_event_name as e JOIN +performance_schema.events_waits_summary_by_thread_by_event_name as t USING +(event_name) group by event_name; +select * from t0; +m n +commit; +drop table t0; +set session big_tables = 1; +select @@big_tables; +@@big_tables +1 +drop function func1; +drop table t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14; +# +# BUG#20762059 - innodb_thread_concurrency=1 and queries using intrinsic +# temp tables, causes hang +# +# Scenario 1: Without timezone tables +# +CREATE TABLE t1(a INT); +INSERT INTO t1 VALUES(1); +# On default connection +SET @@session.max_heap_table_size=0; +Warnings: +Warning 1292 Truncated incorrect max_heap_table_size value: '0' +SET @@global.innodb_thread_concurrency=1; +# Executing I_S query which will create and do index read on +# intrinsic temporary tables +# Switch to connection con1 +SELECT * FROM t1; +a +1 +# Switch to connection default +DROP TABLE t1; +SET @@session.max_heap_table_size = default; +SET @@global.innodb_thread_concurrency = default; +SET @@global.innodb_thread_sleep_delay = default; +# +# Scenario 2: with I_S query and timezone table(uses attachable +# transaction) +# +SET @@session.max_heap_table_size=0; +Warnings: +Warning 1292 Truncated incorrect max_heap_table_size value: '0' +SET @@global.innodb_thread_concurrency=1; +# Executing I_S query which will create and do index read on +# intrinsic temporary tables +select convert_tz(0,'a','a'); +convert_tz(0,'a','a') +NULL +SET @@session.max_heap_table_size = default; +SET @@global.innodb_thread_concurrency = default; +SET @@global.innodb_thread_sleep_delay = default; +# +# Scenario 3: with I_S query and help table(uses attachable +# transaction) +# +SET @@global.innodb_thread_concurrency=1; +# Executing I_S query which will create and do index read on +# intrinsic temporary tables +HELP '%function_2'; +name is_it_category +SET @@global.innodb_thread_concurrency = default; +SET @@global.innodb_thread_sleep_delay = default; +# +# Bug#21871451: INNODB: FAILING ASSERTION: !(&BUF_POOL->MUTEX) +# +SELECT 'SUCCESS_INNODB_CMPMEM' FROM DUAL WHERE EXISTS +(SELECT * FROM INFORMATION_SCHEMA.INNODB_CMPMEM); +SUCCESS_INNODB_CMPMEM +SUCCESS_INNODB_CMPMEM +SELECT 'SUCCESS_INNODB_CMP' FROM DUAL WHERE EXISTS +(SELECT * FROM INFORMATION_SCHEMA.INNODB_CMPMEM_RESET); +SUCCESS_INNODB_CMP +SUCCESS_INNODB_CMP diff --git a/mysql-test/suite/parallel_query/r/pq_having.result-pq b/mysql-test/suite/parallel_query/r/pq_having.result-pq index 353d32d3d10e..bff6773f16c6 100644 --- a/mysql-test/suite/parallel_query/r/pq_having.result-pq +++ b/mysql-test/suite/parallel_query/r/pq_having.result-pq @@ -86,12 +86,15 @@ explain select fd1, fd2, avg(fd2) from t1 group by fd1, fd2 having json_arrayagg id select_type table partitions type possible_keys key key_len ref rows filtered Extra 1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort Warnings: +Warning 3986 Evaluating a JSON value in SQL boolean context does an implicit comparison against JSON integer 0; if this is not what you want, consider converting JSON to a SQL numeric type with JSON_VALUE RETURNING Note 1003 /* select#1 */ select `pq_having_database`.`t1`.`fd1` AS `fd1`,`pq_having_database`.`t1`.`fd2` AS `fd2`,avg(`pq_having_database`.`t1`.`fd2`) AS `avg(fd2)` from `pq_having_database`.`t1` group by `pq_having_database`.`t1`.`fd1`,`pq_having_database`.`t1`.`fd2` having (0 <> json_arrayagg(`pq_having_database`.`t1`.`fd2`)) select fd1, fd2, avg(fd2) from t1 group by fd1, fd2 having json_arrayagg(fd2); fd1 fd2 avg(fd2) 1 1 1.0000 2 2 2.0000 3 3 3.0000 +Warnings: +Warning 3986 Evaluating a JSON value in SQL boolean context does an implicit comparison against JSON integer 0; if this is not what you want, consider converting JSON to a SQL numeric type with JSON_VALUE RETURNING explain select fd1, avg(fd2) from t1 group by fd1, fd2 having json_object(fd1, fd2) is not null; id select_type table partitions type possible_keys key key_len ref rows filtered Extra 1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using temporary diff --git a/mysql-test/suite/pr_statement_performance_analyzer.result-pq b/mysql-test/suite/pr_statement_performance_analyzer.result-pq new file mode 100644 index 000000000000..0e315fc63cec --- /dev/null +++ b/mysql-test/suite/pr_statement_performance_analyzer.result-pq @@ -0,0 +1,199 @@ +use test; +DROP TABLE IF EXISTS t1; +DROP TEMPORARY TABLE IF EXISTS tmp_digests_ini; +DROP VIEW IF EXISTS view_digests; +CREATE TABLE t1 (id INT PRIMARY KEY, val int); +use test; +UPDATE performance_schema.threads SET INSTRUMENTED = IF(THREAD_ID = CON1_THREAD_ID, 'YES', 'NO'); +CALL sys.ps_setup_enable_consumer('events_statements_history_long'); +CALL sys.ps_truncate_all_tables(FALSE); +INSERT INTO t1 VALUES (1, 0); +UPDATE t1 SET val = 1 WHERE id = 1; +SELECT t1a.* FROM t1 AS t1a LEFT OUTER JOIN (SELECT * FROM t1 AS t1b1 INNER JOIN t1 AS t1b2 USING (id, val)) AS t1b ON t1b.id > t1a.id ORDER BY t1a.val, t1a.id; +id val +1 1 +CALL sys.statement_performance_analyzer('create_tmp', 'test.tmp_digests_ini', NULL); +CALL sys.statement_performance_analyzer('snapshot', NULL, NULL); +CALL sys.statement_performance_analyzer('save', 'test.tmp_digests_ini', NULL); +DO SLEEP(1.2); +INSERT INTO t1 VALUES (2, 0); +UPDATE t1 SET val = 1 WHERE id = 2; +SELECT t1a.* FROM t1 AS t1a LEFT OUTER JOIN (SELECT * FROM t1 AS t1b1 INNER JOIN t1 AS t1b2 USING (id, val)) AS t1b ON t1b.id > t1a.id ORDER BY t1a.val, t1a.id; +id val +1 1 +2 1 +CALL sys.statement_performance_analyzer('snapshot', NULL, NULL); +SELECT DIGEST, COUNT_STAR FROM performance_schema.events_statements_summary_by_digest; +DIGEST COUNT_STAR +DIGEST_INSERT 2 +DIGEST_SELECT 2 +DIGEST_UPDATE 2 +CALL sys.statement_performance_analyzer('overall', NULL, 'with_runtimes_in_95th_percentile'); +CALL sys.statement_performance_analyzer('delta', 'test.tmp_digests_ini', 'with_runtimes_in_95th_percentile'); +CALL sys.statement_performance_analyzer('overall', NULL, 'analysis'); +Next Output +QUERY_INSERT test 2 0 0 LATENCY LATENCY LATENCY LATENCY 0 0 0 0 2 1 0 0 0 0 DIGEST_INSERT FIRST_SEEN LAST_SEEN +QUERY_SELECT test * 2 0 0 LATENCY LATENCY LATENCY LATENCY 3 2 15 8 0 0 0 0 3 0 DIGEST_SELECT FIRST_SEEN LAST_SEEN +QUERY_UPDATE test 2 0 0 LATENCY LATENCY LATENCY LATENCY 0 0 2 1 2 1 0 0 0 0 DIGEST_UPDATE FIRST_SEEN LAST_SEEN +Top 100 Queries Ordered by Total Latency +query db full_scan exec_count err_count warn_count total_latency max_latency avg_latency lock_latency rows_sent rows_sent_avg rows_examined rows_examined_avg rows_affected rows_affected_avg tmp_tables tmp_disk_tables rows_sorted sort_merge_passes digest first_seen last_seen +CALL sys.statement_performance_analyzer('delta', 'test.tmp_digests_ini', 'analysis'); +Next Output +QUERY_INSERT test 1 0 0 LATENCY LATENCY LATENCY LATENCY 0 0 0 0 1 1 0 0 0 0 DIGEST_INSERT FIRST_SEEN LAST_SEEN +QUERY_SELECT test * 1 0 0 LATENCY LATENCY LATENCY LATENCY 2 2 11 11 0 0 0 0 2 0 DIGEST_SELECT FIRST_SEEN LAST_SEEN +QUERY_UPDATE test 1 0 0 LATENCY LATENCY LATENCY LATENCY 0 0 1 1 1 1 0 0 0 0 DIGEST_UPDATE FIRST_SEEN LAST_SEEN +Top 100 Queries Ordered by Total Latency +query db full_scan exec_count err_count warn_count total_latency max_latency avg_latency lock_latency rows_sent rows_sent_avg rows_examined rows_examined_avg rows_affected rows_affected_avg tmp_tables tmp_disk_tables rows_sorted sort_merge_passes digest first_seen last_seen +CALL sys.statement_performance_analyzer('overall', NULL, 'with_errors_or_warnings'); +Next Output +Top 100 Queries with Errors +query db exec_count errors error_pct warnings warning_pct first_seen last_seen digest +CALL sys.statement_performance_analyzer('delta', 'test.tmp_digests_ini', 'with_errors_or_warnings'); +Next Output +Top 100 Queries with Errors +query db exec_count errors error_pct warnings warning_pct first_seen last_seen digest +CALL sys.statement_performance_analyzer('overall', NULL, 'with_full_table_scans'); +Next Output +Top 100 Queries with Full Table Scan +query db exec_count total_latency no_index_used_count no_good_index_used_count no_index_used_pct rows_sent rows_examined rows_sent_avg rows_examined_avg first_seen last_seen digest +QUERY_SELECT test 2 LATENCY 2 0 100 3 15 2 8 FIRST_SEEN LAST_SEEN DIGEST_SELECT +CALL sys.statement_performance_analyzer('delta', 'test.tmp_digests_ini', 'with_full_table_scans'); +Next Output +Top 100 Queries with Full Table Scan +query db exec_count total_latency no_index_used_count no_good_index_used_count no_index_used_pct rows_sent rows_examined rows_sent_avg rows_examined_avg first_seen last_seen digest +QUERY_SELECT test 1 LATENCY 1 0 100 2 11 2 11 FIRST_SEEN LAST_SEEN DIGEST_SELECT +CALL sys.statement_performance_analyzer('overall', NULL, 'with_sorting'); +Next Output +Top 100 Queries with Sorting +query db exec_count total_latency sort_merge_passes avg_sort_merges sorts_using_scans sort_using_range rows_sorted avg_rows_sorted first_seen last_seen digest +QUERY_SELECT test 2 LATENCY 0 0 2 0 3 2 FIRST_SEEN LAST_SEEN DIGEST_SELECT +CALL sys.statement_performance_analyzer('delta', 'test.tmp_digests_ini', 'with_sorting'); +Next Output +Top 100 Queries with Sorting +query db exec_count total_latency sort_merge_passes avg_sort_merges sorts_using_scans sort_using_range rows_sorted avg_rows_sorted first_seen last_seen digest +QUERY_SELECT test 1 LATENCY 0 0 1 0 2 2 FIRST_SEEN LAST_SEEN DIGEST_SELECT +CALL sys.statement_performance_analyzer('overall', NULL, 'with_temp_tables'); +Next Output +Top 100 Queries with Internal Temporary Tables +query db exec_count total_latency memory_tmp_tables disk_tmp_tables avg_tmp_tables_per_query tmp_tables_to_disk_pct first_seen last_seen digest +CALL sys.statement_performance_analyzer('delta', 'test.tmp_digests_ini', 'with_temp_tables'); +Next Output +Top 100 Queries with Internal Temporary Tables +query db exec_count total_latency memory_tmp_tables disk_tmp_tables avg_tmp_tables_per_query tmp_tables_to_disk_pct first_seen last_seen digest +CREATE VIEW test.view_digests AS +SELECT sys.format_statement(DIGEST_TEXT) AS query, +SCHEMA_NAME AS db, +COUNT_STAR AS exec_count, +format_pico_time(SUM_TIMER_WAIT) AS total_latency, +format_pico_time(AVG_TIMER_WAIT) AS avg_latency, +ROUND(IFNULL(SUM_ROWS_SENT / NULLIF(COUNT_STAR, 0), 0)) AS rows_sent_avg, +ROUND(IFNULL(SUM_ROWS_EXAMINED / NULLIF(COUNT_STAR, 0), 0)) AS rows_examined_avg, +ROUND(IFNULL(SUM_ROWS_AFFECTED / NULLIF(COUNT_STAR, 0), 0)) AS rows_affected_avg, +DIGEST AS digest +FROM performance_schema.events_statements_summary_by_digest +ORDER BY SUBSTRING(query, 1, 6); +SET @sys.statement_performance_analyzer.view = 'test.view_digests'; +CALL sys.statement_performance_analyzer('overall', NULL, 'custom'); +Next Output +Top 100 Queries Using Custom View +query db exec_count total_latency avg_latency rows_sent_avg rows_examined_avg rows_affected_avg digest +QUERY_INSERT test 2 LATENCY LATENCY 0 0 1 DIGEST_INSERT +QUERY_SELECT test 2 LATENCY LATENCY 2 8 0 DIGEST_SELECT +QUERY_UPDATE test 2 LATENCY LATENCY 0 1 1 DIGEST_UPDATE +CALL sys.statement_performance_analyzer('delta', 'test.tmp_digests_ini', 'custom'); +Next Output +Top 100 Queries Using Custom View +query db exec_count total_latency avg_latency rows_sent_avg rows_examined_avg rows_affected_avg digest +QUERY_INSERT test 1 LATENCY LATENCY 0 0 1 DIGEST_INSERT +QUERY_SELECT test 1 LATENCY LATENCY 2 11 0 DIGEST_SELECT +QUERY_UPDATE test 1 LATENCY LATENCY 0 1 1 DIGEST_UPDATE +SET @sys.statement_performance_analyzer.limit = 2; +CALL sys.statement_performance_analyzer('overall', NULL, 'custom'); +Next Output +Top 2 Queries Using Custom View +query db exec_count total_latency avg_latency rows_sent_avg rows_examined_avg rows_affected_avg digest +QUERY_INSERT test 2 LATENCY LATENCY 0 0 1 DIGEST_INSERT +QUERY_SELECT test 2 LATENCY LATENCY 2 8 0 DIGEST_SELECT +SET SESSION sql_mode = ''; +CALL sys.statement_performance_analyzer('do magic', NULL, NULL); +ERROR 45000: Unknown action. Supported actions are: cleanup, create_table, create_tmp, delta, overall, save, snapshot +SET SESSION sql_mode = 'ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION'; +CALL sys.statement_performance_analyzer('do magic', NULL, NULL); +ERROR 01000: Data truncated for column 'in_action' at row 1 +CALL sys.statement_performance_analyzer('create_tmp', 'sys.tmp_digests', NULL); +ERROR 45000: Invalid value for in_table: `sys`.`tmp_digests` is reserved table name. +CALL sys.statement_performance_analyzer('create_tmp', 'sys.tmp_digests_delta', NULL); +ERROR 45000: Invalid value for in_table: `sys`.`tmp_digests_delta` is reserved table name. +CALL sys.statement_performance_analyzer('create_tmp', 'tmp_digests', NULL); +ERROR 45000: Invalid value for in_table: `sys`.`tmp_digests` is reserved table name. +CALL sys.statement_performance_analyzer('create_tmp', 'test.tmp_digests', NULL); +CREATE TABLE test.tmp_unsupported LIKE test.tmp_digests_ini; +CALL sys.statement_performance_analyzer('create_tmp', 'test.tmp_digests_ini', NULL); +ERROR 45000: Cannot create the table `test`.`tmp_digests_ini` as it already exists. +CALL sys.statement_performance_analyzer('create_table', 'test.tmp_digests_ini', NULL); +ERROR 45000: Cannot create the table `test`.`tmp_digests_ini` as it already exists as a temporary table. +CALL sys.statement_performance_analyzer('create_table', 'test.tmp_unsupported', NULL); +ERROR 45000: Cannot create the table `test`.`tmp_unsupported` as it already exists. +ALTER TABLE test.tmp_unsupported ADD COLUMN myvar int DEFAULT 0; +CALL sys.statement_performance_analyzer('save', 'test.tmp_unsupported', NULL); +ERROR 45000: The table `test`.`tmp_unsupported` has the wrong definition. +CALL sys.statement_performance_analyzer('snapshot', 'test.new_table', NULL); +ERROR 45000: The snapshot action requires in_table to be NULL, NOW() or specify an existing table. The table ...`.`new_table` does not exist. +CALL sys.statement_performance_analyzer('overall', 'test.new_table', 'analysis'); +ERROR 45000: The overall action requires in_table to be NULL, NOW() or specify an existing table. The table ...`.`new_table` does not exist. +CALL sys.statement_performance_analyzer('delta', 'test.new_table', 'analysis'); +ERROR 45000: The delta action requires in_table to be an existing table. The table `test`.`new_table` does not exist. +CALL sys.statement_performance_analyzer('save', 'test.new_table', NULL); +ERROR 45000: The save action requires in_table to be an existing table. The table `test`.`new_table` does not exist. +SET @sys.statement_performance_analyzer.view = NULL; +DELETE FROM sys.sys_config WHERE variable = 'statement_performance_analyzer.view'; +CALL sys.statement_performance_analyzer('overall', NULL, 'custom'); +Next Output +Top 2 Queries Using Custom View +ERROR 45000: The @sys.statement_performance_analyzer.view user variable must be set with the view or query to use. +SET @sys.statement_performance_analyzer.view = 'test.tmp_unsupported'; +CALL sys.statement_performance_analyzer('overall', NULL, 'custom'); +Next Output +Top 2 Queries Using Custom View +ERROR 45000: The @sys.statement_performance_analyzer.view user variable is set but specified neither an existing view nor a query. +CALL sys.table_exists('sys', 'tmp_digests', @exists); +SELECT @exists; +@exists +TEMPORARY +CALL sys.table_exists('sys', 'tmp_digests_delta', @exists); +SELECT @exists; +@exists +TEMPORARY +CALL sys.statement_performance_analyzer('cleanup', NULL, NULL); +DROP TEMPORARY TABLE sys.tmp_digests; +ERROR 42S02: Unknown table 'sys.tmp_digests' +DROP TEMPORARY TABLE sys.tmp_digests_delta; +ERROR 42S02: Unknown table 'sys.tmp_digests_delta' +CALL sys.statement_performance_analyzer('delta', 'test.tmp_digests_ini', 'analysis'); +ERROR 45000: An existing snapshot generated with the statement_performance_analyzer() must exist. +DROP TEMPORARY TABLE sys.tmp_digests_delta; +ERROR 42S02: Unknown table 'sys.tmp_digests_delta' +SET @identifier := REPEAT('a', 65); +CALL sys.statement_performance_analyzer('snapshot', CONCAT(@identifier, '.', @identifier), NULL); +ERROR 22001: Data too long for column 'in_table' at row 1 +DROP TEMPORARY TABLE test.tmp_digests_ini; +DROP TEMPORARY TABLE test.tmp_digests; +DROP TABLE test.tmp_unsupported; +DROP TABLE test.t1; +DROP VIEW view_digests; +SET @identifier := NULL; +SET SESSION sql_mode = @@global.sql_mode; +SET @sys.statement_performance_analyzer.limit = NULL; +SET @sys.statement_performance_analyzer.view = NULL; +UPDATE performance_schema.setup_consumers SET enabled = 'YES'; +UPDATE performance_schema.threads SET instrumented = 'YES'; +SET @sys.ignore_sys_config_triggers := true; +DELETE FROM sys.sys_config; +INSERT IGNORE INTO sys.sys_config (variable, value) VALUES +('statement_truncate_len', 64), +('statement_performance_analyzer.limit', 100), +('statement_performance_analyzer.view', NULL), +('diagnostics.allow_i_s_tables', 'OFF'), +('diagnostics.include_raw', 'OFF'), +('ps_thread_trx_info.max_length', 65535); +SET @sys.ignore_sys_config_triggers := NULL; diff --git a/mysql-test/suite/range_no_prot.result-pq b/mysql-test/suite/range_no_prot.result-pq new file mode 100644 index 000000000000..259102a9cab6 --- /dev/null +++ b/mysql-test/suite/range_no_prot.result-pq @@ -0,0 +1,7444 @@ +SET optimizer_trace_max_mem_size=1048576; +SET end_markers_in_json=on; +SET optimizer_trace="enabled=on,one_line=off"; +CREATE TABLE t1 +( +key1 INT NOT NULL, +INDEX i1(key1) +); +Inserting 1024 records into t1 +ALTER TABLE t1 ADD key2 INT NOT NULL, ADD INDEX i2(key2); +ALTER TABLE t1 ADD key3 INT NOT NULL, ADD INDEX i3(key3); +ALTER TABLE t1 ADD key4 INT NOT NULL, ADD INDEX i4(key4); +ALTER TABLE t1 ADD key5 INT NOT NULL, ADD INDEX i5(key5); +ALTER TABLE t1 ADD key6 INT NOT NULL, ADD INDEX i6(key6); +ALTER TABLE t1 ADD key7 INT NOT NULL, ADD INDEX i7(key7); +ALTER TABLE t1 ADD key8 INT NOT NULL, ADD INDEX i8(key8); +UPDATE t1 SET +key2=key1, +key3=key1, +key4=key1, +key5=key1, +key6=key1, +key7=key1, +key8=1024-key1; +CREATE TABLE t2 ( +key1a INT NOT NULL, +key1b INT NOT NULL, +key2 INT NOT NULL, +key2_1 INT NOT NULL, +key2_2 INT NOT NULL, +key3 INT NOT NULL, +primary key i1a (key1a, key1b), +INDEX i1b (key1b, key1a), +INDEX i2_1(key2, key2_1), +INDEX i2_2(key2, key2_1) +); +Warnings: +Warning 1831 Duplicate index 'i2_2' defined on the table 'test.t2'. This is deprecated and will be disallowed in a future release. +INSERT INTO t2 SELECT key1,key1,key1 div 10, key1 % 10, key1 % 10, key1 FROM t1; + +EXPLAIN SELECT * FROM t1 WHERE key2 < 5 OR key2 > 1020; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range i2 i2 4 NULL 47 100.00 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`key1` AS `key1`,`test`.`t1`.`key2` AS `key2`,`test`.`t1`.`key3` AS `key3`,`test`.`t1`.`key4` AS `key4`,`test`.`t1`.`key5` AS `key5`,`test`.`t1`.`key6` AS `key6`,`test`.`t1`.`key7` AS `key7`,`test`.`t1`.`key8` AS `key8` from `test`.`t1` where ((`test`.`t1`.`key2` < 5) or (`test`.`t1`.`key2` > 1020)) + +SELECT * FROM information_schema.OPTIMIZER_TRACE; +QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES +EXPLAIN SELECT * FROM t1 WHERE key2 < 5 OR key2 > 1020 { + "steps": [ + { + "join_preparation": { + "select#": 1, + "steps": [ + { + "expanded_query": "/* select#1 */ select `t1`.`key1` AS `key1`,`t1`.`key2` AS `key2`,`t1`.`key3` AS `key3`,`t1`.`key4` AS `key4`,`t1`.`key5` AS `key5`,`t1`.`key6` AS `key6`,`t1`.`key7` AS `key7`,`t1`.`key8` AS `key8` from `t1` where ((`t1`.`key2` < 5) or (`t1`.`key2` > 1020))" + } + ] /* steps */ + } /* join_preparation */ + }, + { + "join_optimization": { + "select#": 1, + "steps": [ + { + "condition_processing": { + "condition": "WHERE", + "original_condition": "((`t1`.`key2` < 5) or (`t1`.`key2` > 1020))", + "steps": [ + { + "transformation": "equality_propagation", + "resulting_condition": "((`t1`.`key2` < 5) or (`t1`.`key2` > 1020))" + }, + { + "transformation": "constant_propagation", + "resulting_condition": "((`t1`.`key2` < 5) or (`t1`.`key2` > 1020))" + }, + { + "transformation": "trivial_condition_removal", + "resulting_condition": "((`t1`.`key2` < 5) or (`t1`.`key2` > 1020))" + } + ] /* steps */ + } /* condition_processing */ + }, + { + "substitute_generated_columns": { + } /* substitute_generated_columns */ + }, + { + "table_dependencies": [ + { + "table": "`t1`", + "row_may_be_null": false, + "map_bit": 0, + "depends_on_map_bits": [ + ] /* depends_on_map_bits */ + } + ] /* table_dependencies */ + }, + { + "ref_optimizer_key_uses": [ + ] /* ref_optimizer_key_uses */ + }, + { + "rows_estimation": [ + { + "table": "`t1`", + "range_analysis": { + "table_scan": { + "rows": 1024, + "cost": 107.06 + } /* table_scan */, + "potential_range_indexes": [ + { + "index": "i1", + "usable": false, + "cause": "not_applicable" + }, + { + "index": "i2", + "usable": true, + "key_parts": [ + "key2" + ] /* key_parts */ + }, + { + "index": "i3", + "usable": false, + "cause": "not_applicable" + }, + { + "index": "i4", + "usable": false, + "cause": "not_applicable" + }, + { + "index": "i5", + "usable": false, + "cause": "not_applicable" + }, + { + "index": "i6", + "usable": false, + "cause": "not_applicable" + }, + { + "index": "i7", + "usable": false, + "cause": "not_applicable" + }, + { + "index": "i8", + "usable": false, + "cause": "not_applicable" + } + ] /* potential_range_indexes */, + "setup_range_conditions": [ + ] /* setup_range_conditions */, + "group_index_range": { + "chosen": false, + "cause": "not_group_by_or_distinct" + } /* group_index_range */, + "skip_scan_range": { + "potential_skip_scan_indexes": [ + { + "index": "i2", + "usable": false, + "cause": "query_references_nonkey_column" + } + ] /* potential_skip_scan_indexes */ + } /* skip_scan_range */, + "analyzing_range_alternatives": { + "range_scan_alternatives": [ + { + "index": "i2", + "ranges": [ + "key2 < 5", + "1020 < key2" + ] /* ranges */, + "index_dives_for_eq_ranges": true, + "rowid_ordered": false, + "using_mrr": false, + "index_only": false, + "rows": 47, + "cost": 16.96, + "chosen": true + } + ] /* range_scan_alternatives */, + "analyzing_roworder_intersect": { + "usable": false, + "cause": "too_few_roworder_scans" + } /* analyzing_roworder_intersect */ + } /* analyzing_range_alternatives */, + "chosen_range_access_summary": { + "range_access_plan": { + "type": "range_scan", + "index": "i2", + "rows": 47, + "ranges": [ + "key2 < 5", + "1020 < key2" + ] /* ranges */ + } /* range_access_plan */, + "rows_for_plan": 47, + "cost_for_plan": 16.96, + "chosen": true + } /* chosen_range_access_summary */ + } /* range_analysis */ + } + ] /* rows_estimation */ + }, + { + "considered_execution_plans": [ + { + "plan_prefix": [ + ] /* plan_prefix */, + "table": "`t1`", + "best_access_path": { + "considered_access_paths": [ + { + "rows_to_scan": 47, + "filtering_effect": [ + ] /* filtering_effect */, + "final_filtering_effect": 1, + "access_type": "range", + "range_details": { + "used_index": "i2" + } /* range_details */, + "resulting_rows": 47, + "cost": 21.66, + "chosen": true + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 100, + "rows_for_plan": 47, + "cost_for_plan": 21.66, + "chosen": true + } + ] /* considered_execution_plans */ + }, + { + "attaching_conditions_to_tables": { + "original_condition": "((`t1`.`key2` < 5) or (`t1`.`key2` > 1020))", + "attached_conditions_computation": [ + ] /* attached_conditions_computation */, + "attached_conditions_summary": [ + { + "table": "`t1`", + "attached": "((`t1`.`key2` < 5) or (`t1`.`key2` > 1020))" + } + ] /* attached_conditions_summary */ + } /* attaching_conditions_to_tables */ + }, + { + "finalizing_table_conditions": [ + { + "table": "`t1`", + "original_table_condition": "((`t1`.`key2` < 5) or (`t1`.`key2` > 1020))", + "final_table_condition ": "((`t1`.`key2` < 5) or (`t1`.`key2` > 1020))" + } + ] /* finalizing_table_conditions */ + }, + { + "refine_plan": [ + { + "table": "`t1`", + "pushed_index_condition": "((`t1`.`key2` < 5) or (`t1`.`key2` > 1020))", + "table_condition_attached": null + } + ] /* refine_plan */ + } + ] /* steps */ + } /* join_optimization */ + }, + { + "join_explain": { + "select#": 1, + "steps": [ + ] /* steps */ + } /* join_explain */ + } + ] /* steps */ +} 0 0 +set @@optimizer_trace_features="range_optimizer=off"; + +EXPLAIN SELECT * FROM t1 WHERE key2 < 5 OR key2 > 1020; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range i2 i2 4 NULL 47 100.00 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`key1` AS `key1`,`test`.`t1`.`key2` AS `key2`,`test`.`t1`.`key3` AS `key3`,`test`.`t1`.`key4` AS `key4`,`test`.`t1`.`key5` AS `key5`,`test`.`t1`.`key6` AS `key6`,`test`.`t1`.`key7` AS `key7`,`test`.`t1`.`key8` AS `key8` from `test`.`t1` where ((`test`.`t1`.`key2` < 5) or (`test`.`t1`.`key2` > 1020)) + +SELECT * FROM information_schema.OPTIMIZER_TRACE; +QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES +EXPLAIN SELECT * FROM t1 WHERE key2 < 5 OR key2 > 1020 { + "steps": [ + { + "join_preparation": { + "select#": 1, + "steps": [ + { + "expanded_query": "/* select#1 */ select `t1`.`key1` AS `key1`,`t1`.`key2` AS `key2`,`t1`.`key3` AS `key3`,`t1`.`key4` AS `key4`,`t1`.`key5` AS `key5`,`t1`.`key6` AS `key6`,`t1`.`key7` AS `key7`,`t1`.`key8` AS `key8` from `t1` where ((`t1`.`key2` < 5) or (`t1`.`key2` > 1020))" + } + ] /* steps */ + } /* join_preparation */ + }, + { + "join_optimization": { + "select#": 1, + "steps": [ + { + "condition_processing": { + "condition": "WHERE", + "original_condition": "((`t1`.`key2` < 5) or (`t1`.`key2` > 1020))", + "steps": [ + { + "transformation": "equality_propagation", + "resulting_condition": "((`t1`.`key2` < 5) or (`t1`.`key2` > 1020))" + }, + { + "transformation": "constant_propagation", + "resulting_condition": "((`t1`.`key2` < 5) or (`t1`.`key2` > 1020))" + }, + { + "transformation": "trivial_condition_removal", + "resulting_condition": "((`t1`.`key2` < 5) or (`t1`.`key2` > 1020))" + } + ] /* steps */ + } /* condition_processing */ + }, + { + "substitute_generated_columns": { + } /* substitute_generated_columns */ + }, + { + "table_dependencies": [ + { + "table": "`t1`", + "row_may_be_null": false, + "map_bit": 0, + "depends_on_map_bits": [ + ] /* depends_on_map_bits */ + } + ] /* table_dependencies */ + }, + { + "ref_optimizer_key_uses": [ + ] /* ref_optimizer_key_uses */ + }, + { + "rows_estimation": [ + { + "table": "`t1`", + "range_analysis": { + "table_scan": { + "rows": 1024, + "cost": 107.06 + } /* table_scan */, + "potential_range_indexes": "...", + "setup_range_conditions": [ + ] /* setup_range_conditions */, + "group_index_range": "...", + "skip_scan_range": "...", + "analyzing_range_alternatives": "...", + "chosen_range_access_summary": { + "range_access_plan": { + "type": "range_scan", + "index": "i2", + "rows": 47, + "ranges": [ + "key2 < 5", + "1020 < key2" + ] /* ranges */ + } /* range_access_plan */, + "rows_for_plan": 47, + "cost_for_plan": 16.96, + "chosen": true + } /* chosen_range_access_summary */ + } /* range_analysis */ + } + ] /* rows_estimation */ + }, + { + "considered_execution_plans": [ + { + "plan_prefix": [ + ] /* plan_prefix */, + "table": "`t1`", + "best_access_path": { + "considered_access_paths": [ + { + "rows_to_scan": 47, + "filtering_effect": [ + ] /* filtering_effect */, + "final_filtering_effect": 1, + "access_type": "range", + "range_details": { + "used_index": "i2" + } /* range_details */, + "resulting_rows": 47, + "cost": 21.66, + "chosen": true + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 100, + "rows_for_plan": 47, + "cost_for_plan": 21.66, + "chosen": true + } + ] /* considered_execution_plans */ + }, + { + "attaching_conditions_to_tables": { + "original_condition": "((`t1`.`key2` < 5) or (`t1`.`key2` > 1020))", + "attached_conditions_computation": [ + ] /* attached_conditions_computation */, + "attached_conditions_summary": [ + { + "table": "`t1`", + "attached": "((`t1`.`key2` < 5) or (`t1`.`key2` > 1020))" + } + ] /* attached_conditions_summary */ + } /* attaching_conditions_to_tables */ + }, + { + "finalizing_table_conditions": [ + { + "table": "`t1`", + "original_table_condition": "((`t1`.`key2` < 5) or (`t1`.`key2` > 1020))", + "final_table_condition ": "((`t1`.`key2` < 5) or (`t1`.`key2` > 1020))" + } + ] /* finalizing_table_conditions */ + }, + { + "refine_plan": [ + { + "table": "`t1`", + "pushed_index_condition": "((`t1`.`key2` < 5) or (`t1`.`key2` > 1020))", + "table_condition_attached": null + } + ] /* refine_plan */ + } + ] /* steps */ + } /* join_optimization */ + }, + { + "join_explain": { + "select#": 1, + "steps": [ + ] /* steps */ + } /* join_explain */ + } + ] /* steps */ +} 0 0 +set @@optimizer_trace_features="range_optimizer=on"; + +EXPLAIN SELECT * FROM t1 WHERE key1 < 3 OR key2 > 1020; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge i1,i2 i1,i2 4,4 NULL 45 100.00 Using sort_union(i1,i2); Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`key1` AS `key1`,`test`.`t1`.`key2` AS `key2`,`test`.`t1`.`key3` AS `key3`,`test`.`t1`.`key4` AS `key4`,`test`.`t1`.`key5` AS `key5`,`test`.`t1`.`key6` AS `key6`,`test`.`t1`.`key7` AS `key7`,`test`.`t1`.`key8` AS `key8` from `test`.`t1` where ((`test`.`t1`.`key1` < 3) or (`test`.`t1`.`key2` > 1020)) + +SELECT * FROM information_schema.OPTIMIZER_TRACE; +QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES +EXPLAIN SELECT * FROM t1 WHERE key1 < 3 OR key2 > 1020 { + "steps": [ + { + "join_preparation": { + "select#": 1, + "steps": [ + { + "expanded_query": "/* select#1 */ select `t1`.`key1` AS `key1`,`t1`.`key2` AS `key2`,`t1`.`key3` AS `key3`,`t1`.`key4` AS `key4`,`t1`.`key5` AS `key5`,`t1`.`key6` AS `key6`,`t1`.`key7` AS `key7`,`t1`.`key8` AS `key8` from `t1` where ((`t1`.`key1` < 3) or (`t1`.`key2` > 1020))" + } + ] /* steps */ + } /* join_preparation */ + }, + { + "join_optimization": { + "select#": 1, + "steps": [ + { + "condition_processing": { + "condition": "WHERE", + "original_condition": "((`t1`.`key1` < 3) or (`t1`.`key2` > 1020))", + "steps": [ + { + "transformation": "equality_propagation", + "resulting_condition": "((`t1`.`key1` < 3) or (`t1`.`key2` > 1020))" + }, + { + "transformation": "constant_propagation", + "resulting_condition": "((`t1`.`key1` < 3) or (`t1`.`key2` > 1020))" + }, + { + "transformation": "trivial_condition_removal", + "resulting_condition": "((`t1`.`key1` < 3) or (`t1`.`key2` > 1020))" + } + ] /* steps */ + } /* condition_processing */ + }, + { + "substitute_generated_columns": { + } /* substitute_generated_columns */ + }, + { + "table_dependencies": [ + { + "table": "`t1`", + "row_may_be_null": false, + "map_bit": 0, + "depends_on_map_bits": [ + ] /* depends_on_map_bits */ + } + ] /* table_dependencies */ + }, + { + "ref_optimizer_key_uses": [ + ] /* ref_optimizer_key_uses */ + }, + { + "rows_estimation": [ + { + "table": "`t1`", + "range_analysis": { + "table_scan": { + "rows": 1024, + "cost": 107.06 + } /* table_scan */, + "potential_range_indexes": [ + { + "index": "i1", + "usable": true, + "key_parts": [ + "key1" + ] /* key_parts */ + }, + { + "index": "i2", + "usable": true, + "key_parts": [ + "key2" + ] /* key_parts */ + }, + { + "index": "i3", + "usable": false, + "cause": "not_applicable" + }, + { + "index": "i4", + "usable": false, + "cause": "not_applicable" + }, + { + "index": "i5", + "usable": false, + "cause": "not_applicable" + }, + { + "index": "i6", + "usable": false, + "cause": "not_applicable" + }, + { + "index": "i7", + "usable": false, + "cause": "not_applicable" + }, + { + "index": "i8", + "usable": false, + "cause": "not_applicable" + } + ] /* potential_range_indexes */, + "setup_range_conditions": [ + ] /* setup_range_conditions */, + "group_index_range": { + "chosen": false, + "cause": "not_group_by_or_distinct" + } /* group_index_range */, + "skip_scan_range": { + "potential_skip_scan_indexes": [ + { + "index": "i1", + "usable": false, + "cause": "query_references_nonkey_column" + }, + { + "index": "i2", + "usable": false, + "cause": "query_references_nonkey_column" + } + ] /* potential_skip_scan_indexes */ + } /* skip_scan_range */, + "analyzing_range_alternatives": { + "range_scan_alternatives": [ + ] /* range_scan_alternatives */, + "analyzing_roworder_intersect": { + "usable": false, + "cause": "too_few_roworder_scans" + } /* analyzing_roworder_intersect */ + } /* analyzing_range_alternatives */, + "analyzing_index_merge_union": [ + { + "indexes_to_merge": [ + { + "range_scan_alternatives": [ + { + "index": "i1", + "ranges": [ + "key1 < 3" + ] /* ranges */, + "index_dives_for_eq_ranges": true, + "rowid_ordered": false, + "using_mrr": false, + "index_only": true, + "rows": 3, + "cost": 0.57, + "chosen": true + } + ] /* range_scan_alternatives */, + "index_to_merge": "i1", + "cumulated_cost": 0.57 + }, + { + "range_scan_alternatives": [ + { + "index": "i2", + "ranges": [ + "1020 < key2" + ] /* ranges */, + "index_dives_for_eq_ranges": true, + "rowid_ordered": false, + "using_mrr": false, + "index_only": true, + "rows": 42, + "cost": 4.68, + "chosen": true + } + ] /* range_scan_alternatives */, + "index_to_merge": "i2", + "cumulated_cost": 5.25 + } + ] /* indexes_to_merge */, + "cost_of_reading_ranges": 5.25, + "cost_sort_rowid_and_read_disk": 2.24, + "cost_duplicate_removal": 19.18, + "total_cost": 26.67 + } + ] /* analyzing_index_merge_union */, + "chosen_range_access_summary": { + "range_access_plan": { + "type": "index_merge", + "index_merge_of": [ + { + "type": "range_scan", + "index": "i1", + "rows": 3, + "ranges": [ + "key1 < 3" + ] /* ranges */ + }, + { + "type": "range_scan", + "index": "i2", + "rows": 42, + "ranges": [ + "1020 < key2" + ] /* ranges */ + } + ] /* index_merge_of */ + } /* range_access_plan */, + "rows_for_plan": 45, + "cost_for_plan": 26.67, + "chosen": true + } /* chosen_range_access_summary */ + } /* range_analysis */ + } + ] /* rows_estimation */ + }, + { + "considered_execution_plans": [ + { + "plan_prefix": [ + ] /* plan_prefix */, + "table": "`t1`", + "best_access_path": { + "considered_access_paths": [ + { + "rows_to_scan": 45, + "filtering_effect": [ + ] /* filtering_effect */, + "final_filtering_effect": 1, + "access_type": "range", + "range_details": { + "used_index": "sort_union(i1,i2)" + } /* range_details */, + "resulting_rows": 45, + "cost": 31.17, + "chosen": true + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 100, + "rows_for_plan": 45, + "cost_for_plan": 31.17, + "chosen": true + } + ] /* considered_execution_plans */ + }, + { + "attaching_conditions_to_tables": { + "original_condition": "((`t1`.`key1` < 3) or (`t1`.`key2` > 1020))", + "attached_conditions_computation": [ + ] /* attached_conditions_computation */, + "attached_conditions_summary": [ + { + "table": "`t1`", + "attached": "((`t1`.`key1` < 3) or (`t1`.`key2` > 1020))" + } + ] /* attached_conditions_summary */ + } /* attaching_conditions_to_tables */ + }, + { + "finalizing_table_conditions": [ + { + "table": "`t1`", + "original_table_condition": "((`t1`.`key1` < 3) or (`t1`.`key2` > 1020))", + "final_table_condition ": "((`t1`.`key1` < 3) or (`t1`.`key2` > 1020))" + } + ] /* finalizing_table_conditions */ + }, + { + "refine_plan": [ + { + "table": "`t1`" + } + ] /* refine_plan */ + } + ] /* steps */ + } /* join_optimization */ + }, + { + "join_explain": { + "select#": 1, + "steps": [ + ] /* steps */ + } /* join_explain */ + } + ] /* steps */ +} 0 0 + +EXPLAIN SELECT key2, MIN(key2_1) FROM t2 GROUP BY key2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range i2_1,i2_2 i2_1 4 NULL 103 100.00 Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`key2` AS `key2`,min(`test`.`t2`.`key2_1`) AS `MIN(key2_1)` from `test`.`t2` group by `test`.`t2`.`key2` + +SELECT * FROM information_schema.OPTIMIZER_TRACE; +QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES +EXPLAIN SELECT key2, MIN(key2_1) FROM t2 GROUP BY key2 { + "steps": [ + { + "join_preparation": { + "select#": 1, + "steps": [ + { + "expanded_query": "/* select#1 */ select `t2`.`key2` AS `key2`,min(`t2`.`key2_1`) AS `MIN(key2_1)` from `t2` group by `t2`.`key2`" + } + ] /* steps */ + } /* join_preparation */ + }, + { + "join_optimization": { + "select#": 1, + "steps": [ + { + "substitute_generated_columns": { + } /* substitute_generated_columns */ + }, + { + "table_dependencies": [ + { + "table": "`t2`", + "row_may_be_null": false, + "map_bit": 0, + "depends_on_map_bits": [ + ] /* depends_on_map_bits */ + } + ] /* table_dependencies */ + }, + { + "rows_estimation": [ + { + "table": "`t2`", + "const_keys_added": { + "keys": [ + "i2_1", + "i2_2" + ] /* keys */, + "cause": "group_by" + } /* const_keys_added */, + "range_analysis": { + "table_scan": { + "rows": 1024, + "cost": 106.56 + } /* table_scan */, + "potential_range_indexes": [ + { + "index": "PRIMARY", + "usable": false, + "cause": "not_applicable" + }, + { + "index": "i1b", + "usable": false, + "cause": "not_applicable" + }, + { + "index": "i2_1", + "usable": true, + "key_parts": [ + "key2", + "key2_1" + ] /* key_parts */ + }, + { + "index": "i2_2", + "usable": true, + "key_parts": [ + "key2", + "key2_1" + ] /* key_parts */ + } + ] /* potential_range_indexes */, + "best_covering_index_scan": { + "index": "i2_1", + "cost": 109.96, + "chosen": false, + "cause": "cost" + } /* best_covering_index_scan */, + "group_index_range": { + "potential_group_range_indexes": [ + { + "index": "i2_1", + "covering": true, + "rows": 103, + "cost": 28.1 + }, + { + "index": "i2_2", + "covering": true, + "rows": 103, + "cost": 28.1 + } + ] /* potential_group_range_indexes */ + } /* group_index_range */, + "best_group_range_summary": { + "type": "index_group", + "index": "i2_1", + "group_attribute": "key2_1", + "min_aggregate": true, + "max_aggregate": false, + "distinct_aggregate": false, + "rows": 103, + "cost": 28.1, + "key_parts_used_for_access": [ + "key2" + ] /* key_parts_used_for_access */, + "ranges": [ + ] /* ranges */, + "chosen": true + } /* best_group_range_summary */, + "skip_scan_range": { + "chosen": false, + "cause": "has_group_by" + } /* skip_scan_range */, + "chosen_range_access_summary": { + "range_access_plan": { + "type": "index_group", + "index": "i2_1", + "group_attribute": "key2_1", + "min_aggregate": true, + "max_aggregate": false, + "distinct_aggregate": false, + "rows": 103, + "cost": 28.1, + "key_parts_used_for_access": [ + "key2" + ] /* key_parts_used_for_access */, + "ranges": [ + ] /* ranges */ + } /* range_access_plan */, + "rows_for_plan": 103, + "cost_for_plan": 28.1, + "chosen": true + } /* chosen_range_access_summary */ + } /* range_analysis */ + } + ] /* rows_estimation */ + }, + { + "considered_execution_plans": [ + { + "plan_prefix": [ + ] /* plan_prefix */, + "table": "`t2`", + "best_access_path": { + "considered_access_paths": [ + { + "rows_to_scan": 103, + "access_type": "range", + "range_details": { + "used_index": "index_for_group_by(i2_1)" + } /* range_details */, + "resulting_rows": 103, + "cost": 38.4, + "chosen": true, + "use_tmp_table": true + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 100, + "rows_for_plan": 103, + "cost_for_plan": 38.4, + "sort_cost": 103, + "new_cost_for_plan": 141.4, + "chosen": true + } + ] /* considered_execution_plans */ + }, + { + "attaching_conditions_to_tables": { + "original_condition": null, + "attached_conditions_computation": [ + ] /* attached_conditions_computation */, + "attached_conditions_summary": [ + { + "table": "`t2`", + "attached": null + } + ] /* attached_conditions_summary */ + } /* attaching_conditions_to_tables */ + }, + { + "optimizing_distinct_group_by_order_by": { + "simplifying_group_by": { + "original_clause": "`t2`.`key2`", + "items": [ + { + "item": "`t2`.`key2`" + } + ] /* items */, + "resulting_clause_is_simple": true, + "resulting_clause": "`t2`.`key2`" + } /* simplifying_group_by */ + } /* optimizing_distinct_group_by_order_by */ + }, + { + "reconsidering_access_paths_for_index_ordering": { + "clause": "GROUP BY", + "steps": [ + ] /* steps */, + "index_order_summary": { + "table": "`t2`", + "index_provides_order": true, + "order_direction": "asc", + "index": "i2_1", + "plan_changed": false + } /* index_order_summary */ + } /* reconsidering_access_paths_for_index_ordering */ + }, + { + "finalizing_table_conditions": [ + ] /* finalizing_table_conditions */ + }, + { + "refine_plan": [ + { + "table": "`t2`" + } + ] /* refine_plan */ + }, + { + "considering_tmp_tables": [ + ] /* considering_tmp_tables */ + } + ] /* steps */ + } /* join_optimization */ + }, + { + "join_explain": { + "select#": 1, + "steps": [ + ] /* steps */ + } /* join_explain */ + } + ] /* steps */ +} 0 0 +EXPLAIN SELECT DISTINCT key2 FROM t2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range i2_1,i2_2 i2_1 4 NULL 103 100.00 Using index for group-by +Warnings: +Note 1003 /* select#1 */ select distinct `test`.`t2`.`key2` AS `key2` from `test`.`t2` + +SELECT * FROM information_schema.OPTIMIZER_TRACE; +QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES +EXPLAIN SELECT DISTINCT key2 FROM t2 { + "steps": [ + { + "join_preparation": { + "select#": 1, + "steps": [ + { + "expanded_query": "/* select#1 */ select distinct `t2`.`key2` AS `key2` from `t2`" + } + ] /* steps */ + } /* join_preparation */ + }, + { + "join_optimization": { + "select#": 1, + "steps": [ + { + "table_dependencies": [ + { + "table": "`t2`", + "row_may_be_null": false, + "map_bit": 0, + "depends_on_map_bits": [ + ] /* depends_on_map_bits */ + } + ] /* table_dependencies */ + }, + { + "rows_estimation": [ + { + "table": "`t2`", + "const_keys_added": { + "keys": [ + "i2_1", + "i2_2" + ] /* keys */, + "cause": "distinct" + } /* const_keys_added */, + "range_analysis": { + "table_scan": { + "rows": 1024, + "cost": 106.56 + } /* table_scan */, + "potential_range_indexes": [ + { + "index": "PRIMARY", + "usable": false, + "cause": "not_applicable" + }, + { + "index": "i1b", + "usable": false, + "cause": "not_applicable" + }, + { + "index": "i2_1", + "usable": true, + "key_parts": [ + "key2", + "key2_1" + ] /* key_parts */ + }, + { + "index": "i2_2", + "usable": true, + "key_parts": [ + "key2", + "key2_1" + ] /* key_parts */ + } + ] /* potential_range_indexes */, + "best_covering_index_scan": { + "index": "i2_1", + "cost": 109.96, + "chosen": false, + "cause": "cost" + } /* best_covering_index_scan */, + "group_index_range": { + "distinct_query": true, + "potential_group_range_indexes": [ + { + "index": "i2_1", + "covering": true, + "rows": 103, + "cost": 28.1 + }, + { + "index": "i2_2", + "covering": true, + "rows": 103, + "cost": 28.1 + } + ] /* potential_group_range_indexes */ + } /* group_index_range */, + "best_group_range_summary": { + "type": "index_group", + "index": "i2_1", + "group_attribute": null, + "min_aggregate": false, + "max_aggregate": false, + "distinct_aggregate": false, + "rows": 103, + "cost": 28.1, + "key_parts_used_for_access": [ + "key2" + ] /* key_parts_used_for_access */, + "ranges": [ + ] /* ranges */, + "chosen": true + } /* best_group_range_summary */, + "skip_scan_range": { + "chosen": false, + "cause": "disjuntive_predicate_present" + } /* skip_scan_range */, + "chosen_range_access_summary": { + "range_access_plan": { + "type": "index_group", + "index": "i2_1", + "group_attribute": null, + "min_aggregate": false, + "max_aggregate": false, + "distinct_aggregate": false, + "rows": 103, + "cost": 28.1, + "key_parts_used_for_access": [ + "key2" + ] /* key_parts_used_for_access */, + "ranges": [ + ] /* ranges */ + } /* range_access_plan */, + "rows_for_plan": 103, + "cost_for_plan": 28.1, + "chosen": true + } /* chosen_range_access_summary */ + } /* range_analysis */ + } + ] /* rows_estimation */ + }, + { + "considered_execution_plans": [ + { + "plan_prefix": [ + ] /* plan_prefix */, + "table": "`t2`", + "best_access_path": { + "considered_access_paths": [ + { + "rows_to_scan": 103, + "access_type": "range", + "range_details": { + "used_index": "index_for_group_by(i2_1)" + } /* range_details */, + "resulting_rows": 103, + "cost": 38.4, + "chosen": true + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 100, + "rows_for_plan": 103, + "cost_for_plan": 38.4, + "chosen": true + } + ] /* considered_execution_plans */ + }, + { + "attaching_conditions_to_tables": { + "original_condition": null, + "attached_conditions_computation": [ + ] /* attached_conditions_computation */, + "attached_conditions_summary": [ + { + "table": "`t2`", + "attached": null + } + ] /* attached_conditions_summary */ + } /* attaching_conditions_to_tables */ + }, + { + "optimizing_distinct_group_by_order_by": { + "changed_distinct_to_group_by": true, + "simplifying_group_by": { + "original_clause": "`t2`.`key2`", + "items": [ + { + "item": "`t2`.`key2`" + } + ] /* items */, + "resulting_clause_is_simple": true, + "resulting_clause": "`t2`.`key2`" + } /* simplifying_group_by */ + } /* optimizing_distinct_group_by_order_by */ + }, + { + "reconsidering_access_paths_for_index_ordering": { + "clause": "GROUP BY", + "steps": [ + ] /* steps */, + "index_order_summary": { + "table": "`t2`", + "index_provides_order": true, + "order_direction": "asc", + "index": "i2_1", + "plan_changed": false + } /* index_order_summary */ + } /* reconsidering_access_paths_for_index_ordering */ + }, + { + "finalizing_table_conditions": [ + ] /* finalizing_table_conditions */ + }, + { + "refine_plan": [ + { + "table": "`t2`" + } + ] /* refine_plan */ + }, + { + "considering_tmp_tables": [ + ] /* considering_tmp_tables */ + } + ] /* steps */ + } /* join_optimization */ + }, + { + "join_explain": { + "select#": 1, + "steps": [ + ] /* steps */ + } /* join_explain */ + } + ] /* steps */ +} 0 0 + +EXPLAIN SELECT key2, MIN(key2_1) FROM t2 +WHERE key2 = 5 or key2 = 4 or key2 = 3 or key2 = 2 or key2 = 1 +GROUP BY key2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range i2_1,i2_2 i2_1 4 NULL 47 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`key2` AS `key2`,min(`test`.`t2`.`key2_1`) AS `MIN(key2_1)` from `test`.`t2` where ((`test`.`t2`.`key2` = 5) or (`test`.`t2`.`key2` = 4) or (`test`.`t2`.`key2` = 3) or (`test`.`t2`.`key2` = 2) or (`test`.`t2`.`key2` = 1)) group by `test`.`t2`.`key2` + +SELECT * FROM information_schema.OPTIMIZER_TRACE; +QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES +EXPLAIN SELECT key2, MIN(key2_1) FROM t2 +WHERE key2 = 5 or key2 = 4 or key2 = 3 or key2 = 2 or key2 = 1 +GROUP BY key2 { + "steps": [ + { + "join_preparation": { + "select#": 1, + "steps": [ + { + "expanded_query": "/* select#1 */ select `t2`.`key2` AS `key2`,min(`t2`.`key2_1`) AS `MIN(key2_1)` from `t2` where ((`t2`.`key2` = 5) or (`t2`.`key2` = 4) or (`t2`.`key2` = 3) or (`t2`.`key2` = 2) or (`t2`.`key2` = 1)) group by `t2`.`key2`" + } + ] /* steps */ + } /* join_preparation */ + }, + { + "join_optimization": { + "select#": 1, + "steps": [ + { + "condition_processing": { + "condition": "WHERE", + "original_condition": "((`t2`.`key2` = 5) or (`t2`.`key2` = 4) or (`t2`.`key2` = 3) or (`t2`.`key2` = 2) or (`t2`.`key2` = 1))", + "steps": [ + { + "transformation": "equality_propagation", + "resulting_condition": "(multiple equal(5, `t2`.`key2`) or multiple equal(4, `t2`.`key2`) or multiple equal(3, `t2`.`key2`) or multiple equal(2, `t2`.`key2`) or multiple equal(1, `t2`.`key2`))" + }, + { + "transformation": "constant_propagation", + "resulting_condition": "(multiple equal(5, `t2`.`key2`) or multiple equal(4, `t2`.`key2`) or multiple equal(3, `t2`.`key2`) or multiple equal(2, `t2`.`key2`) or multiple equal(1, `t2`.`key2`))" + }, + { + "transformation": "trivial_condition_removal", + "resulting_condition": "(multiple equal(5, `t2`.`key2`) or multiple equal(4, `t2`.`key2`) or multiple equal(3, `t2`.`key2`) or multiple equal(2, `t2`.`key2`) or multiple equal(1, `t2`.`key2`))" + } + ] /* steps */ + } /* condition_processing */ + }, + { + "substitute_generated_columns": { + } /* substitute_generated_columns */ + }, + { + "table_dependencies": [ + { + "table": "`t2`", + "row_may_be_null": false, + "map_bit": 0, + "depends_on_map_bits": [ + ] /* depends_on_map_bits */ + } + ] /* table_dependencies */ + }, + { + "ref_optimizer_key_uses": [ + ] /* ref_optimizer_key_uses */ + }, + { + "rows_estimation": [ + { + "table": "`t2`", + "range_analysis": { + "table_scan": { + "rows": 1024, + "cost": 106.56 + } /* table_scan */, + "potential_range_indexes": [ + { + "index": "PRIMARY", + "usable": false, + "cause": "not_applicable" + }, + { + "index": "i1b", + "usable": false, + "cause": "not_applicable" + }, + { + "index": "i2_1", + "usable": true, + "key_parts": [ + "key2", + "key2_1" + ] /* key_parts */ + }, + { + "index": "i2_2", + "usable": true, + "key_parts": [ + "key2", + "key2_1" + ] /* key_parts */ + } + ] /* potential_range_indexes */, + "best_covering_index_scan": { + "index": "i2_1", + "cost": 109.96, + "chosen": false, + "cause": "cost" + } /* best_covering_index_scan */, + "setup_range_conditions": [ + ] /* setup_range_conditions */, + "group_index_range": { + "potential_group_range_indexes": [ + { + "index": "i2_1", + "covering": true, + "index_dives_for_eq_ranges": true, + "ranges": [ + "1 <= key2 <= 1", + "2 <= key2 <= 2", + "3 <= key2 <= 3", + "4 <= key2 <= 4", + "5 <= key2 <= 5" + ] /* ranges */, + "rows": 5, + "cost": 8.5 + }, + { + "index": "i2_2", + "covering": true, + "index_dives_for_eq_ranges": true, + "ranges": [ + "1 <= key2 <= 1", + "2 <= key2 <= 2", + "3 <= key2 <= 3", + "4 <= key2 <= 4", + "5 <= key2 <= 5" + ] /* ranges */, + "rows": 5, + "cost": 8.5 + } + ] /* potential_group_range_indexes */ + } /* group_index_range */, + "best_group_range_summary": { + "type": "index_group", + "index": "i2_1", + "group_attribute": "key2_1", + "min_aggregate": true, + "max_aggregate": false, + "distinct_aggregate": false, + "rows": 5, + "cost": 8.5, + "key_parts_used_for_access": [ + "key2" + ] /* key_parts_used_for_access */, + "ranges": [ + "1 <= key2 <= 1", + "2 <= key2 <= 2", + "3 <= key2 <= 3", + "4 <= key2 <= 4", + "5 <= key2 <= 5" + ] /* ranges */, + "chosen": true + } /* best_group_range_summary */, + "skip_scan_range": { + "chosen": false, + "cause": "has_group_by" + } /* skip_scan_range */, + "analyzing_range_alternatives": { + "range_scan_alternatives": [ + { + "index": "i2_1", + "ranges": [ + "1 <= key2 <= 1", + "2 <= key2 <= 2", + "3 <= key2 <= 3", + "4 <= key2 <= 4", + "5 <= key2 <= 5" + ] /* ranges */, + "index_dives_for_eq_ranges": true, + "rowid_ordered": false, + "using_mrr": false, + "index_only": true, + "rows": 47, + "cost": 5.29, + "chosen": true + }, + { + "index": "i2_2", + "ranges": [ + "1 <= key2 <= 1", + "2 <= key2 <= 2", + "3 <= key2 <= 3", + "4 <= key2 <= 4", + "5 <= key2 <= 5" + ] /* ranges */, + "index_dives_for_eq_ranges": true, + "rowid_ordered": false, + "using_mrr": false, + "index_only": true, + "rows": 47, + "cost": 5.29, + "chosen": false, + "cause": "cost" + } + ] /* range_scan_alternatives */, + "analyzing_roworder_intersect": { + "usable": false, + "cause": "too_few_roworder_scans" + } /* analyzing_roworder_intersect */ + } /* analyzing_range_alternatives */, + "chosen_range_access_summary": { + "range_access_plan": { + "type": "range_scan", + "index": "i2_1", + "rows": 47, + "ranges": [ + "1 <= key2 <= 1", + "2 <= key2 <= 2", + "3 <= key2 <= 3", + "4 <= key2 <= 4", + "5 <= key2 <= 5" + ] /* ranges */ + } /* range_access_plan */, + "rows_for_plan": 47, + "cost_for_plan": 5.29, + "chosen": true + } /* chosen_range_access_summary */ + } /* range_analysis */ + } + ] /* rows_estimation */ + }, + { + "considered_execution_plans": [ + { + "plan_prefix": [ + ] /* plan_prefix */, + "table": "`t2`", + "best_access_path": { + "considered_access_paths": [ + { + "rows_to_scan": 47, + "filtering_effect": [ + ] /* filtering_effect */, + "final_filtering_effect": 1, + "access_type": "range", + "range_details": { + "used_index": "i2_1" + } /* range_details */, + "resulting_rows": 47, + "cost": 9.99, + "chosen": true, + "use_tmp_table": true + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 100, + "rows_for_plan": 47, + "cost_for_plan": 9.99, + "sort_cost": 47, + "new_cost_for_plan": 56.99, + "chosen": true + } + ] /* considered_execution_plans */ + }, + { + "attaching_conditions_to_tables": { + "original_condition": "((`t2`.`key2` = 5) or (`t2`.`key2` = 4) or (`t2`.`key2` = 3) or (`t2`.`key2` = 2) or (`t2`.`key2` = 1))", + "attached_conditions_computation": [ + ] /* attached_conditions_computation */, + "attached_conditions_summary": [ + { + "table": "`t2`", + "attached": "((`t2`.`key2` = 5) or (`t2`.`key2` = 4) or (`t2`.`key2` = 3) or (`t2`.`key2` = 2) or (`t2`.`key2` = 1))" + } + ] /* attached_conditions_summary */ + } /* attaching_conditions_to_tables */ + }, + { + "optimizing_distinct_group_by_order_by": { + "simplifying_group_by": { + "original_clause": "`t2`.`key2`", + "items": [ + { + "item": "`t2`.`key2`" + } + ] /* items */, + "resulting_clause_is_simple": true, + "resulting_clause": "`t2`.`key2`" + } /* simplifying_group_by */ + } /* optimizing_distinct_group_by_order_by */ + }, + { + "reconsidering_access_paths_for_index_ordering": { + "clause": "GROUP BY", + "steps": [ + ] /* steps */, + "index_order_summary": { + "table": "`t2`", + "index_provides_order": true, + "order_direction": "asc", + "index": "i2_1", + "plan_changed": false + } /* index_order_summary */ + } /* reconsidering_access_paths_for_index_ordering */ + }, + { + "finalizing_table_conditions": [ + { + "table": "`t2`", + "original_table_condition": "((`t2`.`key2` = 5) or (`t2`.`key2` = 4) or (`t2`.`key2` = 3) or (`t2`.`key2` = 2) or (`t2`.`key2` = 1))", + "final_table_condition ": "((`t2`.`key2` = 5) or (`t2`.`key2` = 4) or (`t2`.`key2` = 3) or (`t2`.`key2` = 2) or (`t2`.`key2` = 1))" + } + ] /* finalizing_table_conditions */ + }, + { + "refine_plan": [ + { + "table": "`t2`" + } + ] /* refine_plan */ + }, + { + "considering_tmp_tables": [ + ] /* considering_tmp_tables */ + } + ] /* steps */ + } /* join_optimization */ + }, + { + "join_explain": { + "select#": 1, + "steps": [ + ] /* steps */ + } /* join_explain */ + } + ] /* steps */ +} 0 0 + +EXPLAIN SELECT * FROM t2 WHERE key2 = 1 AND (key2_1 = 1 OR key3 = 5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ref i2_1,i2_2 i2_1 4 const 10 19.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`key1a` AS `key1a`,`test`.`t2`.`key1b` AS `key1b`,`test`.`t2`.`key2` AS `key2`,`test`.`t2`.`key2_1` AS `key2_1`,`test`.`t2`.`key2_2` AS `key2_2`,`test`.`t2`.`key3` AS `key3` from `test`.`t2` where ((`test`.`t2`.`key2` = 1) and ((`test`.`t2`.`key2_1` = 1) or (`test`.`t2`.`key3` = 5))) + +SELECT * FROM information_schema.OPTIMIZER_TRACE; +QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES +EXPLAIN SELECT * FROM t2 WHERE key2 = 1 AND (key2_1 = 1 OR key3 = 5) { + "steps": [ + { + "join_preparation": { + "select#": 1, + "steps": [ + { + "expanded_query": "/* select#1 */ select `t2`.`key1a` AS `key1a`,`t2`.`key1b` AS `key1b`,`t2`.`key2` AS `key2`,`t2`.`key2_1` AS `key2_1`,`t2`.`key2_2` AS `key2_2`,`t2`.`key3` AS `key3` from `t2` where ((`t2`.`key2` = 1) and ((`t2`.`key2_1` = 1) or (`t2`.`key3` = 5)))" + } + ] /* steps */ + } /* join_preparation */ + }, + { + "join_optimization": { + "select#": 1, + "steps": [ + { + "condition_processing": { + "condition": "WHERE", + "original_condition": "((`t2`.`key2` = 1) and ((`t2`.`key2_1` = 1) or (`t2`.`key3` = 5)))", + "steps": [ + { + "transformation": "equality_propagation", + "resulting_condition": "((multiple equal(1, `t2`.`key2_1`) or multiple equal(5, `t2`.`key3`)) and multiple equal(1, `t2`.`key2`))" + }, + { + "transformation": "constant_propagation", + "resulting_condition": "((multiple equal(1, `t2`.`key2_1`) or multiple equal(5, `t2`.`key3`)) and multiple equal(1, `t2`.`key2`))" + }, + { + "transformation": "trivial_condition_removal", + "resulting_condition": "((multiple equal(1, `t2`.`key2_1`) or multiple equal(5, `t2`.`key3`)) and multiple equal(1, `t2`.`key2`))" + } + ] /* steps */ + } /* condition_processing */ + }, + { + "substitute_generated_columns": { + } /* substitute_generated_columns */ + }, + { + "table_dependencies": [ + { + "table": "`t2`", + "row_may_be_null": false, + "map_bit": 0, + "depends_on_map_bits": [ + ] /* depends_on_map_bits */ + } + ] /* table_dependencies */ + }, + { + "ref_optimizer_key_uses": [ + { + "table": "`t2`", + "field": "key2", + "equals": "1", + "null_rejecting": true + }, + { + "table": "`t2`", + "field": "key2", + "equals": "1", + "null_rejecting": true + } + ] /* ref_optimizer_key_uses */ + }, + { + "rows_estimation": [ + { + "table": "`t2`", + "range_analysis": { + "table_scan": { + "rows": 1024, + "cost": 106.56 + } /* table_scan */, + "potential_range_indexes": [ + { + "index": "PRIMARY", + "usable": false, + "cause": "not_applicable" + }, + { + "index": "i1b", + "usable": false, + "cause": "not_applicable" + }, + { + "index": "i2_1", + "usable": true, + "key_parts": [ + "key2", + "key2_1" + ] /* key_parts */ + }, + { + "index": "i2_2", + "usable": true, + "key_parts": [ + "key2", + "key2_1" + ] /* key_parts */ + } + ] /* potential_range_indexes */, + "setup_range_conditions": [ + ] /* setup_range_conditions */, + "group_index_range": { + "chosen": false, + "cause": "not_group_by_or_distinct" + } /* group_index_range */, + "skip_scan_range": { + "potential_skip_scan_indexes": [ + { + "index": "i2_1", + "usable": false, + "cause": "query_references_nonkey_column" + }, + { + "index": "i2_2", + "usable": false, + "cause": "query_references_nonkey_column" + } + ] /* potential_skip_scan_indexes */ + } /* skip_scan_range */, + "analyzing_range_alternatives": { + "range_scan_alternatives": [ + { + "index": "i2_1", + "ranges": [ + "1 <= key2 <= 1" + ] /* ranges */, + "index_dives_for_eq_ranges": true, + "rowid_ordered": false, + "using_mrr": false, + "index_only": false, + "rows": 10, + "cost": 3.76, + "chosen": true + }, + { + "index": "i2_2", + "ranges": [ + "1 <= key2 <= 1" + ] /* ranges */, + "index_dives_for_eq_ranges": true, + "rowid_ordered": false, + "using_mrr": false, + "index_only": false, + "rows": 10, + "cost": 3.76, + "chosen": false, + "cause": "cost" + } + ] /* range_scan_alternatives */, + "analyzing_roworder_intersect": { + "usable": false, + "cause": "too_few_roworder_scans" + } /* analyzing_roworder_intersect */ + } /* analyzing_range_alternatives */, + "chosen_range_access_summary": { + "range_access_plan": { + "type": "range_scan", + "index": "i2_1", + "rows": 10, + "ranges": [ + "1 <= key2 <= 1" + ] /* ranges */ + } /* range_access_plan */, + "rows_for_plan": 10, + "cost_for_plan": 3.76, + "chosen": true + } /* chosen_range_access_summary */ + } /* range_analysis */ + } + ] /* rows_estimation */ + }, + { + "considered_execution_plans": [ + { + "plan_prefix": [ + ] /* plan_prefix */, + "table": "`t2`", + "best_access_path": { + "considered_access_paths": [ + { + "access_type": "ref", + "index": "i2_1", + "rows": 10, + "cost": 3.5, + "chosen": true + }, + { + "access_type": "ref", + "index": "i2_2", + "rows": 10, + "cost": 3.5, + "chosen": false + }, + { + "access_type": "range", + "range_details": { + "used_index": "i2_1" + } /* range_details */, + "chosen": false, + "cause": "heuristic_index_cheaper" + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 19, + "rows_for_plan": 1.9, + "cost_for_plan": 3.5, + "chosen": true + } + ] /* considered_execution_plans */ + }, + { + "attaching_conditions_to_tables": { + "original_condition": "((`t2`.`key2` = 1) and ((`t2`.`key2_1` = 1) or (`t2`.`key3` = 5)))", + "attached_conditions_computation": [ + ] /* attached_conditions_computation */, + "attached_conditions_summary": [ + { + "table": "`t2`", + "attached": "((`t2`.`key2` = 1) and ((`t2`.`key2_1` = 1) or (`t2`.`key3` = 5)))" + } + ] /* attached_conditions_summary */ + } /* attaching_conditions_to_tables */ + }, + { + "finalizing_table_conditions": [ + { + "table": "`t2`", + "original_table_condition": "((`t2`.`key2` = 1) and ((`t2`.`key2_1` = 1) or (`t2`.`key3` = 5)))", + "final_table_condition ": "((`t2`.`key2_1` = 1) or (`t2`.`key3` = 5))" + } + ] /* finalizing_table_conditions */ + }, + { + "refine_plan": [ + { + "table": "`t2`" + } + ] /* refine_plan */ + } + ] /* steps */ + } /* join_optimization */ + }, + { + "join_explain": { + "select#": 1, + "steps": [ + ] /* steps */ + } /* join_explain */ + } + ] /* steps */ +} 0 0 + +EXPLAIN SELECT * FROM t1 WHERE key2=10 OR key3=3 OR key4 <=> null; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge i2,i3,i4 i2,i3 4,4 NULL 2 100.00 Using union(i2,i3); Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`key1` AS `key1`,`test`.`t1`.`key2` AS `key2`,`test`.`t1`.`key3` AS `key3`,`test`.`t1`.`key4` AS `key4`,`test`.`t1`.`key5` AS `key5`,`test`.`t1`.`key6` AS `key6`,`test`.`t1`.`key7` AS `key7`,`test`.`t1`.`key8` AS `key8` from `test`.`t1` where ((`test`.`t1`.`key2` = 10) or (`test`.`t1`.`key3` = 3) or (`test`.`t1`.`key4` <=> NULL)) + +SELECT * FROM information_schema.OPTIMIZER_TRACE; +QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES +EXPLAIN SELECT * FROM t1 WHERE key2=10 OR key3=3 OR key4 <=> null { + "steps": [ + { + "join_preparation": { + "select#": 1, + "steps": [ + { + "expanded_query": "/* select#1 */ select `t1`.`key1` AS `key1`,`t1`.`key2` AS `key2`,`t1`.`key3` AS `key3`,`t1`.`key4` AS `key4`,`t1`.`key5` AS `key5`,`t1`.`key6` AS `key6`,`t1`.`key7` AS `key7`,`t1`.`key8` AS `key8` from `t1` where ((`t1`.`key2` = 10) or (`t1`.`key3` = 3) or (`t1`.`key4` <=> NULL))" + } + ] /* steps */ + } /* join_preparation */ + }, + { + "join_optimization": { + "select#": 1, + "steps": [ + { + "condition_processing": { + "condition": "WHERE", + "original_condition": "((`t1`.`key2` = 10) or (`t1`.`key3` = 3) or (`t1`.`key4` <=> NULL))", + "steps": [ + { + "transformation": "equality_propagation", + "resulting_condition": "(multiple equal(10, `t1`.`key2`) or multiple equal(3, `t1`.`key3`) or (`t1`.`key4` <=> NULL))" + }, + { + "transformation": "constant_propagation", + "resulting_condition": "(multiple equal(10, `t1`.`key2`) or multiple equal(3, `t1`.`key3`) or (`t1`.`key4` <=> NULL))" + }, + { + "transformation": "trivial_condition_removal", + "resulting_condition": "(multiple equal(10, `t1`.`key2`) or multiple equal(3, `t1`.`key3`) or (`t1`.`key4` <=> NULL))" + } + ] /* steps */ + } /* condition_processing */ + }, + { + "substitute_generated_columns": { + } /* substitute_generated_columns */ + }, + { + "table_dependencies": [ + { + "table": "`t1`", + "row_may_be_null": false, + "map_bit": 0, + "depends_on_map_bits": [ + ] /* depends_on_map_bits */ + } + ] /* table_dependencies */ + }, + { + "ref_optimizer_key_uses": [ + ] /* ref_optimizer_key_uses */ + }, + { + "rows_estimation": [ + { + "table": "`t1`", + "range_analysis": { + "table_scan": { + "rows": 1024, + "cost": 107.06 + } /* table_scan */, + "potential_range_indexes": [ + { + "index": "i1", + "usable": false, + "cause": "not_applicable" + }, + { + "index": "i2", + "usable": true, + "key_parts": [ + "key2" + ] /* key_parts */ + }, + { + "index": "i3", + "usable": true, + "key_parts": [ + "key3" + ] /* key_parts */ + }, + { + "index": "i4", + "usable": true, + "key_parts": [ + "key4" + ] /* key_parts */ + }, + { + "index": "i5", + "usable": false, + "cause": "not_applicable" + }, + { + "index": "i6", + "usable": false, + "cause": "not_applicable" + }, + { + "index": "i7", + "usable": false, + "cause": "not_applicable" + }, + { + "index": "i8", + "usable": false, + "cause": "not_applicable" + } + ] /* potential_range_indexes */, + "setup_range_conditions": [ + { + "impossible_condition": { + "cause": "null_field_in_non_null_column" + } /* impossible_condition */ + } + ] /* setup_range_conditions */, + "group_index_range": { + "chosen": false, + "cause": "not_group_by_or_distinct" + } /* group_index_range */, + "skip_scan_range": { + "potential_skip_scan_indexes": [ + { + "index": "i2", + "usable": false, + "cause": "query_references_nonkey_column" + }, + { + "index": "i3", + "usable": false, + "cause": "query_references_nonkey_column" + }, + { + "index": "i4", + "usable": false, + "cause": "query_references_nonkey_column" + } + ] /* potential_skip_scan_indexes */ + } /* skip_scan_range */, + "analyzing_range_alternatives": { + "range_scan_alternatives": [ + ] /* range_scan_alternatives */, + "analyzing_roworder_intersect": { + "usable": false, + "cause": "too_few_roworder_scans" + } /* analyzing_roworder_intersect */ + } /* analyzing_range_alternatives */, + "analyzing_index_merge_union": [ + { + "indexes_to_merge": [ + { + "range_scan_alternatives": [ + { + "index": "i2", + "ranges": [ + "10 <= key2 <= 10" + ] /* ranges */, + "index_dives_for_eq_ranges": true, + "rowid_ordered": true, + "using_mrr": false, + "index_only": true, + "rows": 1, + "cost": 0.36, + "chosen": true + } + ] /* range_scan_alternatives */, + "index_to_merge": "i2", + "cumulated_cost": 0.36 + }, + { + "range_scan_alternatives": [ + { + "index": "i3", + "ranges": [ + "3 <= key3 <= 3" + ] /* ranges */, + "index_dives_for_eq_ranges": true, + "rowid_ordered": true, + "using_mrr": false, + "index_only": true, + "rows": 1, + "cost": 0.36, + "chosen": true + } + ] /* range_scan_alternatives */, + "index_to_merge": "i3", + "cumulated_cost": 0.72 + } + ] /* indexes_to_merge */, + "cost_of_reading_ranges": 0.72, + "use_roworder_union": true, + "cause": "always_cheaper_than_not_roworder_retrieval", + "analyzing_roworder_scans": [ + { + "type": "range_scan", + "index": "i2", + "rows": 1, + "ranges": [ + "10 <= key2 <= 10" + ] /* ranges */, + "analyzing_roworder_intersect": { + "usable": false, + "cause": "too_few_roworder_scans" + } /* analyzing_roworder_intersect */ + }, + { + "type": "range_scan", + "index": "i3", + "rows": 1, + "ranges": [ + "3 <= key3 <= 3" + ] /* ranges */, + "analyzing_roworder_intersect": { + "usable": false, + "cause": "too_few_roworder_scans" + } /* analyzing_roworder_intersect */ + } + ] /* analyzing_roworder_scans */, + "index_roworder_union_cost": 1.29, + "members": 2, + "chosen": true + } + ] /* analyzing_index_merge_union */, + "chosen_range_access_summary": { + "range_access_plan": { + "type": "index_roworder_union", + "union_of": [ + { + "type": "range_scan", + "index": "i2", + "rows": 1, + "ranges": [ + "10 <= key2 <= 10" + ] /* ranges */ + }, + { + "type": "range_scan", + "index": "i3", + "rows": 1, + "ranges": [ + "3 <= key3 <= 3" + ] /* ranges */ + } + ] /* union_of */ + } /* range_access_plan */, + "rows_for_plan": 2, + "cost_for_plan": 1.29, + "chosen": true + } /* chosen_range_access_summary */ + } /* range_analysis */ + } + ] /* rows_estimation */ + }, + { + "considered_execution_plans": [ + { + "plan_prefix": [ + ] /* plan_prefix */, + "table": "`t1`", + "best_access_path": { + "considered_access_paths": [ + { + "rows_to_scan": 2, + "filtering_effect": [ + ] /* filtering_effect */, + "final_filtering_effect": 1, + "access_type": "range", + "range_details": { + "used_index": "union(i2,i3)" + } /* range_details */, + "resulting_rows": 2, + "cost": 1.49, + "chosen": true + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 100, + "rows_for_plan": 2, + "cost_for_plan": 1.49, + "chosen": true + } + ] /* considered_execution_plans */ + }, + { + "attaching_conditions_to_tables": { + "original_condition": "((`t1`.`key2` = 10) or (`t1`.`key3` = 3) or (`t1`.`key4` <=> NULL))", + "attached_conditions_computation": [ + ] /* attached_conditions_computation */, + "attached_conditions_summary": [ + { + "table": "`t1`", + "attached": "((`t1`.`key2` = 10) or (`t1`.`key3` = 3) or (`t1`.`key4` <=> NULL))" + } + ] /* attached_conditions_summary */ + } /* attaching_conditions_to_tables */ + }, + { + "finalizing_table_conditions": [ + { + "table": "`t1`", + "original_table_condition": "((`t1`.`key2` = 10) or (`t1`.`key3` = 3) or (`t1`.`key4` <=> NULL))", + "final_table_condition ": "((`t1`.`key2` = 10) or (`t1`.`key3` = 3) or (`t1`.`key4` <=> NULL))" + } + ] /* finalizing_table_conditions */ + }, + { + "refine_plan": [ + { + "table": "`t1`" + } + ] /* refine_plan */ + } + ] /* steps */ + } /* join_optimization */ + }, + { + "join_explain": { + "select#": 1, + "steps": [ + ] /* steps */ + } /* join_explain */ + } + ] /* steps */ +} 0 0 + +EXPLAIN SELECT * FROM t2 WHERE key2_1 < 79 OR key2 = 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL i2_1,i2_2 NULL NULL NULL 1024 33.98 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`key1a` AS `key1a`,`test`.`t2`.`key1b` AS `key1b`,`test`.`t2`.`key2` AS `key2`,`test`.`t2`.`key2_1` AS `key2_1`,`test`.`t2`.`key2_2` AS `key2_2`,`test`.`t2`.`key3` AS `key3` from `test`.`t2` where ((`test`.`t2`.`key2_1` < 79) or (`test`.`t2`.`key2` = 2)) + +SELECT * FROM information_schema.OPTIMIZER_TRACE; +QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES +EXPLAIN SELECT * FROM t2 WHERE key2_1 < 79 OR key2 = 2 { + "steps": [ + { + "join_preparation": { + "select#": 1, + "steps": [ + { + "expanded_query": "/* select#1 */ select `t2`.`key1a` AS `key1a`,`t2`.`key1b` AS `key1b`,`t2`.`key2` AS `key2`,`t2`.`key2_1` AS `key2_1`,`t2`.`key2_2` AS `key2_2`,`t2`.`key3` AS `key3` from `t2` where ((`t2`.`key2_1` < 79) or (`t2`.`key2` = 2))" + } + ] /* steps */ + } /* join_preparation */ + }, + { + "join_optimization": { + "select#": 1, + "steps": [ + { + "condition_processing": { + "condition": "WHERE", + "original_condition": "((`t2`.`key2_1` < 79) or (`t2`.`key2` = 2))", + "steps": [ + { + "transformation": "equality_propagation", + "resulting_condition": "((`t2`.`key2_1` < 79) or multiple equal(2, `t2`.`key2`))" + }, + { + "transformation": "constant_propagation", + "resulting_condition": "((`t2`.`key2_1` < 79) or multiple equal(2, `t2`.`key2`))" + }, + { + "transformation": "trivial_condition_removal", + "resulting_condition": "((`t2`.`key2_1` < 79) or multiple equal(2, `t2`.`key2`))" + } + ] /* steps */ + } /* condition_processing */ + }, + { + "substitute_generated_columns": { + } /* substitute_generated_columns */ + }, + { + "table_dependencies": [ + { + "table": "`t2`", + "row_may_be_null": false, + "map_bit": 0, + "depends_on_map_bits": [ + ] /* depends_on_map_bits */ + } + ] /* table_dependencies */ + }, + { + "ref_optimizer_key_uses": [ + ] /* ref_optimizer_key_uses */ + }, + { + "rows_estimation": [ + { + "table": "`t2`", + "range_analysis": { + "table_scan": { + "rows": 1024, + "cost": 106.56 + } /* table_scan */, + "potential_range_indexes": [ + { + "index": "PRIMARY", + "usable": false, + "cause": "not_applicable" + }, + { + "index": "i1b", + "usable": false, + "cause": "not_applicable" + }, + { + "index": "i2_1", + "usable": true, + "key_parts": [ + "key2", + "key2_1" + ] /* key_parts */ + }, + { + "index": "i2_2", + "usable": true, + "key_parts": [ + "key2", + "key2_1" + ] /* key_parts */ + } + ] /* potential_range_indexes */, + "setup_range_conditions": [ + ] /* setup_range_conditions */, + "range_scan_possible": false, + "cause": "condition_always_true", + "group_index_range": { + "chosen": false, + "cause": "not_group_by_or_distinct" + } /* group_index_range */, + "skip_scan_range": { + "chosen": false, + "cause": "disjuntive_predicate_present" + } /* skip_scan_range */ + } /* range_analysis */ + } + ] /* rows_estimation */ + }, + { + "considered_execution_plans": [ + { + "plan_prefix": [ + ] /* plan_prefix */, + "table": "`t2`", + "best_access_path": { + "considered_access_paths": [ + { + "rows_to_scan": 1024, + "filtering_effect": [ + ] /* filtering_effect */, + "final_filtering_effect": 0.34, + "access_type": "scan", + "resulting_rows": 347.97, + "cost": 104.46, + "chosen": true + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 100, + "rows_for_plan": 347.97, + "cost_for_plan": 104.46, + "chosen": true + } + ] /* considered_execution_plans */ + }, + { + "attaching_conditions_to_tables": { + "original_condition": "((`t2`.`key2_1` < 79) or (`t2`.`key2` = 2))", + "attached_conditions_computation": [ + ] /* attached_conditions_computation */, + "attached_conditions_summary": [ + { + "table": "`t2`", + "attached": "((`t2`.`key2_1` < 79) or (`t2`.`key2` = 2))" + } + ] /* attached_conditions_summary */ + } /* attaching_conditions_to_tables */ + }, + { + "finalizing_table_conditions": [ + { + "table": "`t2`", + "original_table_condition": "((`t2`.`key2_1` < 79) or (`t2`.`key2` = 2))", + "final_table_condition ": "((`t2`.`key2_1` < 79) or (`t2`.`key2` = 2))" + } + ] /* finalizing_table_conditions */ + }, + { + "refine_plan": [ + { + "table": "`t2`" + } + ] /* refine_plan */ + } + ] /* steps */ + } /* join_optimization */ + }, + { + "join_explain": { + "select#": 1, + "steps": [ + ] /* steps */ + } /* join_explain */ + } + ] /* steps */ +} 0 0 + +EXPLAIN SELECT * FROM t2 WHERE key1a = 5 and key1b < 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range PRIMARY,i1b PRIMARY 8 NULL 1 100.00 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`key1a` AS `key1a`,`test`.`t2`.`key1b` AS `key1b`,`test`.`t2`.`key2` AS `key2`,`test`.`t2`.`key2_1` AS `key2_1`,`test`.`t2`.`key2_2` AS `key2_2`,`test`.`t2`.`key3` AS `key3` from `test`.`t2` where ((`test`.`t2`.`key1a` = 5) and (`test`.`t2`.`key1b` < 10)) + +SELECT * FROM information_schema.OPTIMIZER_TRACE; +QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES +EXPLAIN SELECT * FROM t2 WHERE key1a = 5 and key1b < 10 { + "steps": [ + { + "join_preparation": { + "select#": 1, + "steps": [ + { + "expanded_query": "/* select#1 */ select `t2`.`key1a` AS `key1a`,`t2`.`key1b` AS `key1b`,`t2`.`key2` AS `key2`,`t2`.`key2_1` AS `key2_1`,`t2`.`key2_2` AS `key2_2`,`t2`.`key3` AS `key3` from `t2` where ((`t2`.`key1a` = 5) and (`t2`.`key1b` < 10))" + } + ] /* steps */ + } /* join_preparation */ + }, + { + "join_optimization": { + "select#": 1, + "steps": [ + { + "condition_processing": { + "condition": "WHERE", + "original_condition": "((`t2`.`key1a` = 5) and (`t2`.`key1b` < 10))", + "steps": [ + { + "transformation": "equality_propagation", + "resulting_condition": "((`t2`.`key1b` < 10) and multiple equal(5, `t2`.`key1a`))" + }, + { + "transformation": "constant_propagation", + "resulting_condition": "((`t2`.`key1b` < 10) and multiple equal(5, `t2`.`key1a`))" + }, + { + "transformation": "trivial_condition_removal", + "resulting_condition": "((`t2`.`key1b` < 10) and multiple equal(5, `t2`.`key1a`))" + } + ] /* steps */ + } /* condition_processing */ + }, + { + "substitute_generated_columns": { + } /* substitute_generated_columns */ + }, + { + "table_dependencies": [ + { + "table": "`t2`", + "row_may_be_null": false, + "map_bit": 0, + "depends_on_map_bits": [ + ] /* depends_on_map_bits */ + } + ] /* table_dependencies */ + }, + { + "ref_optimizer_key_uses": [ + { + "table": "`t2`", + "field": "key1a", + "equals": "5", + "null_rejecting": true + } + ] /* ref_optimizer_key_uses */ + }, + { + "rows_estimation": [ + { + "table": "`t2`", + "range_analysis": { + "table_scan": { + "rows": 1024, + "cost": 106.56 + } /* table_scan */, + "potential_range_indexes": [ + { + "index": "PRIMARY", + "usable": true, + "key_parts": [ + "key1a", + "key1b" + ] /* key_parts */ + }, + { + "index": "i1b", + "usable": true, + "key_parts": [ + "key1b", + "key1a" + ] /* key_parts */ + }, + { + "index": "i2_1", + "usable": false, + "cause": "not_applicable" + }, + { + "index": "i2_2", + "usable": false, + "cause": "not_applicable" + } + ] /* potential_range_indexes */, + "setup_range_conditions": [ + ] /* setup_range_conditions */, + "group_index_range": { + "chosen": false, + "cause": "not_group_by_or_distinct" + } /* group_index_range */, + "skip_scan_range": { + "potential_skip_scan_indexes": [ + { + "index": "PRIMARY", + "usable": false, + "cause": "query_references_nonkey_column" + }, + { + "index": "i1b", + "usable": false, + "cause": "query_references_nonkey_column" + } + ] /* potential_skip_scan_indexes */ + } /* skip_scan_range */, + "analyzing_range_alternatives": { + "range_scan_alternatives": [ + { + "index": "PRIMARY", + "ranges": [ + "5 <= key1a <= 5 AND key1b < 10" + ] /* ranges */, + "index_dives_for_eq_ranges": true, + "rowid_ordered": false, + "using_mrr": false, + "index_only": false, + "rows": 1, + "cost": 0.61, + "chosen": true + }, + { + "index": "i1b", + "ranges": [ + "key1b < 10" + ] /* ranges */, + "index_dives_for_eq_ranges": true, + "rowid_ordered": false, + "using_mrr": false, + "index_only": false, + "rows": 9, + "cost": 3.41, + "chosen": false, + "cause": "cost" + } + ] /* range_scan_alternatives */, + "analyzing_roworder_intersect": { + "usable": false, + "cause": "too_few_roworder_scans" + } /* analyzing_roworder_intersect */ + } /* analyzing_range_alternatives */, + "chosen_range_access_summary": { + "range_access_plan": { + "type": "range_scan", + "index": "PRIMARY", + "rows": 1, + "ranges": [ + "5 <= key1a <= 5 AND key1b < 10" + ] /* ranges */ + } /* range_access_plan */, + "rows_for_plan": 1, + "cost_for_plan": 0.61, + "chosen": true + } /* chosen_range_access_summary */ + } /* range_analysis */ + } + ] /* rows_estimation */ + }, + { + "considered_execution_plans": [ + { + "plan_prefix": [ + ] /* plan_prefix */, + "table": "`t2`", + "best_access_path": { + "considered_access_paths": [ + { + "access_type": "ref", + "index": "PRIMARY", + "rows": 10, + "cost": 3.5, + "chosen": true + }, + { + "rows_to_scan": 1, + "filtering_effect": [ + ] /* filtering_effect */, + "final_filtering_effect": 1, + "access_type": "range", + "range_details": { + "used_index": "PRIMARY" + } /* range_details */, + "resulting_rows": 1, + "cost": 0.71, + "chosen": true + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 100, + "rows_for_plan": 1, + "cost_for_plan": 0.71, + "chosen": true + } + ] /* considered_execution_plans */ + }, + { + "attaching_conditions_to_tables": { + "original_condition": "((`t2`.`key1a` = 5) and (`t2`.`key1b` < 10))", + "attached_conditions_computation": [ + ] /* attached_conditions_computation */, + "attached_conditions_summary": [ + { + "table": "`t2`", + "attached": "((`t2`.`key1a` = 5) and (`t2`.`key1b` < 10))" + } + ] /* attached_conditions_summary */ + } /* attaching_conditions_to_tables */ + }, + { + "finalizing_table_conditions": [ + { + "table": "`t2`", + "original_table_condition": "((`t2`.`key1a` = 5) and (`t2`.`key1b` < 10))", + "final_table_condition ": "((`t2`.`key1a` = 5) and (`t2`.`key1b` < 10))" + } + ] /* finalizing_table_conditions */ + }, + { + "refine_plan": [ + { + "table": "`t2`", + "pushed_index_condition": "((`t2`.`key1a` = 5) and (`t2`.`key1b` < 10))", + "table_condition_attached": null + } + ] /* refine_plan */ + } + ] /* steps */ + } /* join_optimization */ + }, + { + "join_explain": { + "select#": 1, + "steps": [ + ] /* steps */ + } /* join_explain */ + } + ] /* steps */ +} 0 0 + +EXPLAIN SELECT * FROM t2 WHERE (key1a = 5 and key1b < 10 and key1b > 2) or +(key1a = 4 and key1b < 7 and key1b > 3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range PRIMARY,i1b PRIMARY 8 NULL 2 100.00 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`key1a` AS `key1a`,`test`.`t2`.`key1b` AS `key1b`,`test`.`t2`.`key2` AS `key2`,`test`.`t2`.`key2_1` AS `key2_1`,`test`.`t2`.`key2_2` AS `key2_2`,`test`.`t2`.`key3` AS `key3` from `test`.`t2` where (((`test`.`t2`.`key1a` = 5) and (`test`.`t2`.`key1b` < 10) and (`test`.`t2`.`key1b` > 2)) or ((`test`.`t2`.`key1a` = 4) and (`test`.`t2`.`key1b` < 7) and (`test`.`t2`.`key1b` > 3))) + +SELECT * FROM information_schema.OPTIMIZER_TRACE; +QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES +EXPLAIN SELECT * FROM t2 WHERE (key1a = 5 and key1b < 10 and key1b > 2) or +(key1a = 4 and key1b < 7 and key1b > 3) { + "steps": [ + { + "join_preparation": { + "select#": 1, + "steps": [ + { + "expanded_query": "/* select#1 */ select `t2`.`key1a` AS `key1a`,`t2`.`key1b` AS `key1b`,`t2`.`key2` AS `key2`,`t2`.`key2_1` AS `key2_1`,`t2`.`key2_2` AS `key2_2`,`t2`.`key3` AS `key3` from `t2` where (((`t2`.`key1a` = 5) and (`t2`.`key1b` < 10) and (`t2`.`key1b` > 2)) or ((`t2`.`key1a` = 4) and (`t2`.`key1b` < 7) and (`t2`.`key1b` > 3)))" + } + ] /* steps */ + } /* join_preparation */ + }, + { + "join_optimization": { + "select#": 1, + "steps": [ + { + "condition_processing": { + "condition": "WHERE", + "original_condition": "(((`t2`.`key1a` = 5) and (`t2`.`key1b` < 10) and (`t2`.`key1b` > 2)) or ((`t2`.`key1a` = 4) and (`t2`.`key1b` < 7) and (`t2`.`key1b` > 3)))", + "steps": [ + { + "transformation": "equality_propagation", + "resulting_condition": "(((`t2`.`key1b` < 10) and (`t2`.`key1b` > 2) and multiple equal(5, `t2`.`key1a`)) or ((`t2`.`key1b` < 7) and (`t2`.`key1b` > 3) and multiple equal(4, `t2`.`key1a`)))" + }, + { + "transformation": "constant_propagation", + "resulting_condition": "(((`t2`.`key1b` < 10) and (`t2`.`key1b` > 2) and multiple equal(5, `t2`.`key1a`)) or ((`t2`.`key1b` < 7) and (`t2`.`key1b` > 3) and multiple equal(4, `t2`.`key1a`)))" + }, + { + "transformation": "trivial_condition_removal", + "resulting_condition": "(((`t2`.`key1b` < 10) and (`t2`.`key1b` > 2) and multiple equal(5, `t2`.`key1a`)) or ((`t2`.`key1b` < 7) and (`t2`.`key1b` > 3) and multiple equal(4, `t2`.`key1a`)))" + } + ] /* steps */ + } /* condition_processing */ + }, + { + "substitute_generated_columns": { + } /* substitute_generated_columns */ + }, + { + "table_dependencies": [ + { + "table": "`t2`", + "row_may_be_null": false, + "map_bit": 0, + "depends_on_map_bits": [ + ] /* depends_on_map_bits */ + } + ] /* table_dependencies */ + }, + { + "ref_optimizer_key_uses": [ + ] /* ref_optimizer_key_uses */ + }, + { + "rows_estimation": [ + { + "table": "`t2`", + "range_analysis": { + "table_scan": { + "rows": 1024, + "cost": 106.56 + } /* table_scan */, + "potential_range_indexes": [ + { + "index": "PRIMARY", + "usable": true, + "key_parts": [ + "key1a", + "key1b" + ] /* key_parts */ + }, + { + "index": "i1b", + "usable": true, + "key_parts": [ + "key1b", + "key1a" + ] /* key_parts */ + }, + { + "index": "i2_1", + "usable": false, + "cause": "not_applicable" + }, + { + "index": "i2_2", + "usable": false, + "cause": "not_applicable" + } + ] /* potential_range_indexes */, + "setup_range_conditions": [ + ] /* setup_range_conditions */, + "group_index_range": { + "chosen": false, + "cause": "not_group_by_or_distinct" + } /* group_index_range */, + "skip_scan_range": { + "potential_skip_scan_indexes": [ + { + "index": "PRIMARY", + "usable": false, + "cause": "query_references_nonkey_column" + }, + { + "index": "i1b", + "usable": false, + "cause": "query_references_nonkey_column" + } + ] /* potential_skip_scan_indexes */ + } /* skip_scan_range */, + "analyzing_range_alternatives": { + "range_scan_alternatives": [ + { + "index": "PRIMARY", + "ranges": [ + "4 <= key1a <= 4 AND 3 < key1b < 7", + "5 <= key1a <= 5 AND 2 < key1b < 10" + ] /* ranges */, + "index_dives_for_eq_ranges": true, + "rowid_ordered": false, + "using_mrr": false, + "index_only": false, + "rows": 2, + "cost": 1.21, + "chosen": true + }, + { + "index": "i1b", + "ranges": [ + "2 < key1b <= 3", + "3 < key1b < 7", + "7 <= key1b < 10" + ] /* ranges */, + "index_dives_for_eq_ranges": true, + "rowid_ordered": false, + "using_mrr": false, + "index_only": false, + "rows": 6, + "cost": 2.86, + "chosen": false, + "cause": "cost" + } + ] /* range_scan_alternatives */, + "analyzing_roworder_intersect": { + "usable": false, + "cause": "too_few_roworder_scans" + } /* analyzing_roworder_intersect */ + } /* analyzing_range_alternatives */, + "chosen_range_access_summary": { + "range_access_plan": { + "type": "range_scan", + "index": "PRIMARY", + "rows": 2, + "ranges": [ + "4 <= key1a <= 4 AND 3 < key1b < 7", + "5 <= key1a <= 5 AND 2 < key1b < 10" + ] /* ranges */ + } /* range_access_plan */, + "rows_for_plan": 2, + "cost_for_plan": 1.21, + "chosen": true + } /* chosen_range_access_summary */ + } /* range_analysis */ + } + ] /* rows_estimation */ + }, + { + "considered_execution_plans": [ + { + "plan_prefix": [ + ] /* plan_prefix */, + "table": "`t2`", + "best_access_path": { + "considered_access_paths": [ + { + "rows_to_scan": 2, + "filtering_effect": [ + ] /* filtering_effect */, + "final_filtering_effect": 1, + "access_type": "range", + "range_details": { + "used_index": "PRIMARY" + } /* range_details */, + "resulting_rows": 2, + "cost": 1.41, + "chosen": true + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 100, + "rows_for_plan": 2, + "cost_for_plan": 1.41, + "chosen": true + } + ] /* considered_execution_plans */ + }, + { + "attaching_conditions_to_tables": { + "original_condition": "(((`t2`.`key1a` = 5) and (`t2`.`key1b` < 10) and (`t2`.`key1b` > 2)) or ((`t2`.`key1a` = 4) and (`t2`.`key1b` < 7) and (`t2`.`key1b` > 3)))", + "attached_conditions_computation": [ + ] /* attached_conditions_computation */, + "attached_conditions_summary": [ + { + "table": "`t2`", + "attached": "(((`t2`.`key1a` = 5) and (`t2`.`key1b` < 10) and (`t2`.`key1b` > 2)) or ((`t2`.`key1a` = 4) and (`t2`.`key1b` < 7) and (`t2`.`key1b` > 3)))" + } + ] /* attached_conditions_summary */ + } /* attaching_conditions_to_tables */ + }, + { + "finalizing_table_conditions": [ + { + "table": "`t2`", + "original_table_condition": "(((`t2`.`key1a` = 5) and (`t2`.`key1b` < 10) and (`t2`.`key1b` > 2)) or ((`t2`.`key1a` = 4) and (`t2`.`key1b` < 7) and (`t2`.`key1b` > 3)))", + "final_table_condition ": "(((`t2`.`key1a` = 5) and (`t2`.`key1b` < 10) and (`t2`.`key1b` > 2)) or ((`t2`.`key1a` = 4) and (`t2`.`key1b` < 7) and (`t2`.`key1b` > 3)))" + } + ] /* finalizing_table_conditions */ + }, + { + "refine_plan": [ + { + "table": "`t2`", + "pushed_index_condition": "(((`t2`.`key1a` = 5) and (`t2`.`key1b` < 10) and (`t2`.`key1b` > 2)) or ((`t2`.`key1a` = 4) and (`t2`.`key1b` < 7) and (`t2`.`key1b` > 3)))", + "table_condition_attached": null + } + ] /* refine_plan */ + } + ] /* steps */ + } /* join_optimization */ + }, + { + "join_explain": { + "select#": 1, + "steps": [ + ] /* steps */ + } /* join_explain */ + } + ] /* steps */ +} 0 0 + +EXPLAIN SELECT * FROM t2 WHERE (key1b < 10 and key1b > 7) and +(key1a = 4 or key1a = 5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range PRIMARY,i1b i1b 4 NULL 2 19.00 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`key1a` AS `key1a`,`test`.`t2`.`key1b` AS `key1b`,`test`.`t2`.`key2` AS `key2`,`test`.`t2`.`key2_1` AS `key2_1`,`test`.`t2`.`key2_2` AS `key2_2`,`test`.`t2`.`key3` AS `key3` from `test`.`t2` where ((`test`.`t2`.`key1b` < 10) and (`test`.`t2`.`key1b` > 7) and ((`test`.`t2`.`key1a` = 4) or (`test`.`t2`.`key1a` = 5))) + +SELECT * FROM information_schema.OPTIMIZER_TRACE; +QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES +EXPLAIN SELECT * FROM t2 WHERE (key1b < 10 and key1b > 7) and +(key1a = 4 or key1a = 5) { + "steps": [ + { + "join_preparation": { + "select#": 1, + "steps": [ + { + "expanded_query": "/* select#1 */ select `t2`.`key1a` AS `key1a`,`t2`.`key1b` AS `key1b`,`t2`.`key2` AS `key2`,`t2`.`key2_1` AS `key2_1`,`t2`.`key2_2` AS `key2_2`,`t2`.`key3` AS `key3` from `t2` where ((`t2`.`key1b` < 10) and (`t2`.`key1b` > 7) and ((`t2`.`key1a` = 4) or (`t2`.`key1a` = 5)))" + } + ] /* steps */ + } /* join_preparation */ + }, + { + "join_optimization": { + "select#": 1, + "steps": [ + { + "condition_processing": { + "condition": "WHERE", + "original_condition": "((`t2`.`key1b` < 10) and (`t2`.`key1b` > 7) and ((`t2`.`key1a` = 4) or (`t2`.`key1a` = 5)))", + "steps": [ + { + "transformation": "equality_propagation", + "resulting_condition": "((`t2`.`key1b` < 10) and (`t2`.`key1b` > 7) and (multiple equal(4, `t2`.`key1a`) or multiple equal(5, `t2`.`key1a`)))" + }, + { + "transformation": "constant_propagation", + "resulting_condition": "((`t2`.`key1b` < 10) and (`t2`.`key1b` > 7) and (multiple equal(4, `t2`.`key1a`) or multiple equal(5, `t2`.`key1a`)))" + }, + { + "transformation": "trivial_condition_removal", + "resulting_condition": "((`t2`.`key1b` < 10) and (`t2`.`key1b` > 7) and (multiple equal(4, `t2`.`key1a`) or multiple equal(5, `t2`.`key1a`)))" + } + ] /* steps */ + } /* condition_processing */ + }, + { + "substitute_generated_columns": { + } /* substitute_generated_columns */ + }, + { + "table_dependencies": [ + { + "table": "`t2`", + "row_may_be_null": false, + "map_bit": 0, + "depends_on_map_bits": [ + ] /* depends_on_map_bits */ + } + ] /* table_dependencies */ + }, + { + "ref_optimizer_key_uses": [ + ] /* ref_optimizer_key_uses */ + }, + { + "rows_estimation": [ + { + "table": "`t2`", + "range_analysis": { + "table_scan": { + "rows": 1024, + "cost": 106.56 + } /* table_scan */, + "potential_range_indexes": [ + { + "index": "PRIMARY", + "usable": true, + "key_parts": [ + "key1a", + "key1b" + ] /* key_parts */ + }, + { + "index": "i1b", + "usable": true, + "key_parts": [ + "key1b", + "key1a" + ] /* key_parts */ + }, + { + "index": "i2_1", + "usable": false, + "cause": "not_applicable" + }, + { + "index": "i2_2", + "usable": false, + "cause": "not_applicable" + } + ] /* potential_range_indexes */, + "setup_range_conditions": [ + ] /* setup_range_conditions */, + "group_index_range": { + "chosen": false, + "cause": "not_group_by_or_distinct" + } /* group_index_range */, + "skip_scan_range": { + "potential_skip_scan_indexes": [ + { + "index": "PRIMARY", + "usable": false, + "cause": "query_references_nonkey_column" + }, + { + "index": "i1b", + "usable": false, + "cause": "query_references_nonkey_column" + } + ] /* potential_skip_scan_indexes */ + } /* skip_scan_range */, + "analyzing_range_alternatives": { + "range_scan_alternatives": [ + { + "index": "PRIMARY", + "ranges": [ + "4 <= key1a <= 4 AND 7 < key1b < 10", + "5 <= key1a <= 5 AND 7 < key1b < 10" + ] /* ranges */, + "index_dives_for_eq_ranges": true, + "rowid_ordered": false, + "using_mrr": false, + "index_only": false, + "rows": 2, + "cost": 1.21, + "chosen": true + }, + { + "index": "i1b", + "ranges": [ + "7 < key1b < 10" + ] /* ranges */, + "index_dives_for_eq_ranges": true, + "rowid_ordered": false, + "using_mrr": false, + "index_only": false, + "rows": 2, + "cost": 0.96, + "chosen": true + } + ] /* range_scan_alternatives */, + "analyzing_roworder_intersect": { + "usable": false, + "cause": "too_few_roworder_scans" + } /* analyzing_roworder_intersect */ + } /* analyzing_range_alternatives */, + "chosen_range_access_summary": { + "range_access_plan": { + "type": "range_scan", + "index": "i1b", + "rows": 2, + "ranges": [ + "7 < key1b < 10" + ] /* ranges */ + } /* range_access_plan */, + "rows_for_plan": 2, + "cost_for_plan": 0.96, + "chosen": true + } /* chosen_range_access_summary */ + } /* range_analysis */ + } + ] /* rows_estimation */ + }, + { + "considered_execution_plans": [ + { + "plan_prefix": [ + ] /* plan_prefix */, + "table": "`t2`", + "best_access_path": { + "considered_access_paths": [ + { + "rows_to_scan": 2, + "filtering_effect": [ + ] /* filtering_effect */, + "final_filtering_effect": 0.19, + "access_type": "range", + "range_details": { + "used_index": "i1b" + } /* range_details */, + "resulting_rows": 0.38, + "cost": 1.16, + "chosen": true + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 100, + "rows_for_plan": 0.38, + "cost_for_plan": 1.16, + "chosen": true + } + ] /* considered_execution_plans */ + }, + { + "attaching_conditions_to_tables": { + "original_condition": "((`t2`.`key1b` < 10) and (`t2`.`key1b` > 7) and ((`t2`.`key1a` = 4) or (`t2`.`key1a` = 5)))", + "attached_conditions_computation": [ + ] /* attached_conditions_computation */, + "attached_conditions_summary": [ + { + "table": "`t2`", + "attached": "((`t2`.`key1b` < 10) and (`t2`.`key1b` > 7) and ((`t2`.`key1a` = 4) or (`t2`.`key1a` = 5)))" + } + ] /* attached_conditions_summary */ + } /* attaching_conditions_to_tables */ + }, + { + "finalizing_table_conditions": [ + { + "table": "`t2`", + "original_table_condition": "((`t2`.`key1b` < 10) and (`t2`.`key1b` > 7) and ((`t2`.`key1a` = 4) or (`t2`.`key1a` = 5)))", + "final_table_condition ": "((`t2`.`key1b` < 10) and (`t2`.`key1b` > 7) and ((`t2`.`key1a` = 4) or (`t2`.`key1a` = 5)))" + } + ] /* finalizing_table_conditions */ + }, + { + "refine_plan": [ + { + "table": "`t2`", + "pushed_index_condition": "((`t2`.`key1b` < 10) and (`t2`.`key1b` > 7) and ((`t2`.`key1a` = 4) or (`t2`.`key1a` = 5)))", + "table_condition_attached": null + } + ] /* refine_plan */ + } + ] /* steps */ + } /* join_optimization */ + }, + { + "join_explain": { + "select#": 1, + "steps": [ + ] /* steps */ + } /* join_explain */ + } + ] /* steps */ +} 0 0 + +EXPLAIN SELECT * FROM t1 WHERE (key1 > 1 OR key2 > 2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL i1,i2 NULL NULL NULL 1024 55.55 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`key1` AS `key1`,`test`.`t1`.`key2` AS `key2`,`test`.`t1`.`key3` AS `key3`,`test`.`t1`.`key4` AS `key4`,`test`.`t1`.`key5` AS `key5`,`test`.`t1`.`key6` AS `key6`,`test`.`t1`.`key7` AS `key7`,`test`.`t1`.`key8` AS `key8` from `test`.`t1` where ((`test`.`t1`.`key1` > 1) or (`test`.`t1`.`key2` > 2)) + +SELECT * FROM information_schema.OPTIMIZER_TRACE; +QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES +EXPLAIN SELECT * FROM t1 WHERE (key1 > 1 OR key2 > 2) { + "steps": [ + { + "join_preparation": { + "select#": 1, + "steps": [ + { + "expanded_query": "/* select#1 */ select `t1`.`key1` AS `key1`,`t1`.`key2` AS `key2`,`t1`.`key3` AS `key3`,`t1`.`key4` AS `key4`,`t1`.`key5` AS `key5`,`t1`.`key6` AS `key6`,`t1`.`key7` AS `key7`,`t1`.`key8` AS `key8` from `t1` where ((`t1`.`key1` > 1) or (`t1`.`key2` > 2))" + } + ] /* steps */ + } /* join_preparation */ + }, + { + "join_optimization": { + "select#": 1, + "steps": [ + { + "condition_processing": { + "condition": "WHERE", + "original_condition": "((`t1`.`key1` > 1) or (`t1`.`key2` > 2))", + "steps": [ + { + "transformation": "equality_propagation", + "resulting_condition": "((`t1`.`key1` > 1) or (`t1`.`key2` > 2))" + }, + { + "transformation": "constant_propagation", + "resulting_condition": "((`t1`.`key1` > 1) or (`t1`.`key2` > 2))" + }, + { + "transformation": "trivial_condition_removal", + "resulting_condition": "((`t1`.`key1` > 1) or (`t1`.`key2` > 2))" + } + ] /* steps */ + } /* condition_processing */ + }, + { + "substitute_generated_columns": { + } /* substitute_generated_columns */ + }, + { + "table_dependencies": [ + { + "table": "`t1`", + "row_may_be_null": false, + "map_bit": 0, + "depends_on_map_bits": [ + ] /* depends_on_map_bits */ + } + ] /* table_dependencies */ + }, + { + "ref_optimizer_key_uses": [ + ] /* ref_optimizer_key_uses */ + }, + { + "rows_estimation": [ + { + "table": "`t1`", + "range_analysis": { + "table_scan": { + "rows": 1024, + "cost": 107.06 + } /* table_scan */, + "potential_range_indexes": [ + { + "index": "i1", + "usable": true, + "key_parts": [ + "key1" + ] /* key_parts */ + }, + { + "index": "i2", + "usable": true, + "key_parts": [ + "key2" + ] /* key_parts */ + }, + { + "index": "i3", + "usable": false, + "cause": "not_applicable" + }, + { + "index": "i4", + "usable": false, + "cause": "not_applicable" + }, + { + "index": "i5", + "usable": false, + "cause": "not_applicable" + }, + { + "index": "i6", + "usable": false, + "cause": "not_applicable" + }, + { + "index": "i7", + "usable": false, + "cause": "not_applicable" + }, + { + "index": "i8", + "usable": false, + "cause": "not_applicable" + } + ] /* potential_range_indexes */, + "setup_range_conditions": [ + ] /* setup_range_conditions */, + "group_index_range": { + "chosen": false, + "cause": "not_group_by_or_distinct" + } /* group_index_range */, + "skip_scan_range": { + "potential_skip_scan_indexes": [ + { + "index": "i1", + "usable": false, + "cause": "query_references_nonkey_column" + }, + { + "index": "i2", + "usable": false, + "cause": "query_references_nonkey_column" + } + ] /* potential_skip_scan_indexes */ + } /* skip_scan_range */, + "analyzing_range_alternatives": { + "range_scan_alternatives": [ + ] /* range_scan_alternatives */, + "analyzing_roworder_intersect": { + "usable": false, + "cause": "too_few_roworder_scans" + } /* analyzing_roworder_intersect */ + } /* analyzing_range_alternatives */, + "analyzing_index_merge_union": [ + { + "indexes_to_merge": [ + { + "range_scan_alternatives": [ + { + "index": "i1", + "ranges": [ + "1 < key1" + ] /* ranges */, + "index_dives_for_eq_ranges": true, + "rowid_ordered": false, + "using_mrr": false, + "index_only": true, + "rows": 1023, + "cost": 108, + "chosen": false, + "cause": "cost" + } + ] /* range_scan_alternatives */, + "chosen": false, + "cause": "cost" + }, + { + "range_scan_alternatives": [ + { + "index": "i2", + "ranges": [ + "2 < key2" + ] /* ranges */, + "index_dives_for_eq_ranges": true, + "rowid_ordered": false, + "using_mrr": false, + "index_only": true, + "rows": 1022, + "cost": 107.89, + "chosen": false, + "cause": "cost" + } + ] /* range_scan_alternatives */, + "chosen": false, + "cause": "cost" + } + ] /* indexes_to_merge */, + "cost_of_reading_ranges": 0, + "chosen": false, + "cause": "cost" + } + ] /* analyzing_index_merge_union */ + } /* range_analysis */ + } + ] /* rows_estimation */ + }, + { + "considered_execution_plans": [ + { + "plan_prefix": [ + ] /* plan_prefix */, + "table": "`t1`", + "best_access_path": { + "considered_access_paths": [ + { + "rows_to_scan": 1024, + "filtering_effect": [ + ] /* filtering_effect */, + "final_filtering_effect": 0.56, + "access_type": "scan", + "resulting_rows": 568.84, + "cost": 104.96, + "chosen": true + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 100, + "rows_for_plan": 568.84, + "cost_for_plan": 104.96, + "chosen": true + } + ] /* considered_execution_plans */ + }, + { + "attaching_conditions_to_tables": { + "original_condition": "((`t1`.`key1` > 1) or (`t1`.`key2` > 2))", + "attached_conditions_computation": [ + ] /* attached_conditions_computation */, + "attached_conditions_summary": [ + { + "table": "`t1`", + "attached": "((`t1`.`key1` > 1) or (`t1`.`key2` > 2))" + } + ] /* attached_conditions_summary */ + } /* attaching_conditions_to_tables */ + }, + { + "finalizing_table_conditions": [ + { + "table": "`t1`", + "original_table_condition": "((`t1`.`key1` > 1) or (`t1`.`key2` > 2))", + "final_table_condition ": "((`t1`.`key1` > 1) or (`t1`.`key2` > 2))" + } + ] /* finalizing_table_conditions */ + }, + { + "refine_plan": [ + { + "table": "`t1`" + } + ] /* refine_plan */ + } + ] /* steps */ + } /* join_optimization */ + }, + { + "join_explain": { + "select#": 1, + "steps": [ + ] /* steps */ + } /* join_explain */ + } + ] /* steps */ +} 0 0 + +EXPLAIN SELECT STRAIGHT_JOIN * FROM t1, t2 +WHERE t1.key1=t2.key1a AND t1.key2 > 1020; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range i1,i2 i2 4 NULL 42 100.00 Using index condition +1 SIMPLE t2 NULL ref PRIMARY PRIMARY 4 test.t1.key1 10 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select straight_join `test`.`t1`.`key1` AS `key1`,`test`.`t1`.`key2` AS `key2`,`test`.`t1`.`key3` AS `key3`,`test`.`t1`.`key4` AS `key4`,`test`.`t1`.`key5` AS `key5`,`test`.`t1`.`key6` AS `key6`,`test`.`t1`.`key7` AS `key7`,`test`.`t1`.`key8` AS `key8`,`test`.`t2`.`key1a` AS `key1a`,`test`.`t2`.`key1b` AS `key1b`,`test`.`t2`.`key2` AS `key2`,`test`.`t2`.`key2_1` AS `key2_1`,`test`.`t2`.`key2_2` AS `key2_2`,`test`.`t2`.`key3` AS `key3` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`key1a` = `test`.`t1`.`key1`) and (`test`.`t1`.`key2` > 1020)) + +SELECT * FROM information_schema.OPTIMIZER_TRACE; +QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES +EXPLAIN SELECT STRAIGHT_JOIN * FROM t1, t2 +WHERE t1.key1=t2.key1a AND t1.key2 > 1020 { + "steps": [ + { + "join_preparation": { + "select#": 1, + "steps": [ + { + "expanded_query": "/* select#1 */ select straight_join `t1`.`key1` AS `key1`,`t1`.`key2` AS `key2`,`t1`.`key3` AS `key3`,`t1`.`key4` AS `key4`,`t1`.`key5` AS `key5`,`t1`.`key6` AS `key6`,`t1`.`key7` AS `key7`,`t1`.`key8` AS `key8`,`t2`.`key1a` AS `key1a`,`t2`.`key1b` AS `key1b`,`t2`.`key2` AS `key2`,`t2`.`key2_1` AS `key2_1`,`t2`.`key2_2` AS `key2_2`,`t2`.`key3` AS `key3` from `t1` join `t2` where ((`t1`.`key1` = `t2`.`key1a`) and (`t1`.`key2` > 1020))" + } + ] /* steps */ + } /* join_preparation */ + }, + { + "join_optimization": { + "select#": 1, + "steps": [ + { + "condition_processing": { + "condition": "WHERE", + "original_condition": "((`t1`.`key1` = `t2`.`key1a`) and (`t1`.`key2` > 1020))", + "steps": [ + { + "transformation": "equality_propagation", + "resulting_condition": "((`t1`.`key2` > 1020) and multiple equal(`t1`.`key1`, `t2`.`key1a`))" + }, + { + "transformation": "constant_propagation", + "resulting_condition": "((`t1`.`key2` > 1020) and multiple equal(`t1`.`key1`, `t2`.`key1a`))" + }, + { + "transformation": "trivial_condition_removal", + "resulting_condition": "((`t1`.`key2` > 1020) and multiple equal(`t1`.`key1`, `t2`.`key1a`))" + } + ] /* steps */ + } /* condition_processing */ + }, + { + "substitute_generated_columns": { + } /* substitute_generated_columns */ + }, + { + "table_dependencies": [ + { + "table": "`t1`", + "row_may_be_null": false, + "map_bit": 0, + "depends_on_map_bits": [ + ] /* depends_on_map_bits */ + }, + { + "table": "`t2`", + "row_may_be_null": false, + "map_bit": 1, + "depends_on_map_bits": [ + 0 + ] /* depends_on_map_bits */ + } + ] /* table_dependencies */ + }, + { + "ref_optimizer_key_uses": [ + { + "table": "`t1`", + "field": "key1", + "equals": "`t2`.`key1a`", + "null_rejecting": true + }, + { + "table": "`t2`", + "field": "key1a", + "equals": "`t1`.`key1`", + "null_rejecting": true + } + ] /* ref_optimizer_key_uses */ + }, + { + "rows_estimation": [ + { + "table": "`t1`", + "range_analysis": { + "table_scan": { + "rows": 1024, + "cost": 107.06 + } /* table_scan */, + "potential_range_indexes": [ + { + "index": "i1", + "usable": false, + "cause": "not_applicable" + }, + { + "index": "i2", + "usable": true, + "key_parts": [ + "key2" + ] /* key_parts */ + }, + { + "index": "i3", + "usable": false, + "cause": "not_applicable" + }, + { + "index": "i4", + "usable": false, + "cause": "not_applicable" + }, + { + "index": "i5", + "usable": false, + "cause": "not_applicable" + }, + { + "index": "i6", + "usable": false, + "cause": "not_applicable" + }, + { + "index": "i7", + "usable": false, + "cause": "not_applicable" + }, + { + "index": "i8", + "usable": false, + "cause": "not_applicable" + } + ] /* potential_range_indexes */, + "setup_range_conditions": [ + ] /* setup_range_conditions */, + "group_index_range": { + "chosen": false, + "cause": "not_single_table" + } /* group_index_range */, + "skip_scan_range": { + "chosen": false, + "cause": "not_single_table" + } /* skip_scan_range */, + "analyzing_range_alternatives": { + "range_scan_alternatives": [ + { + "index": "i2", + "ranges": [ + "1020 < key2" + ] /* ranges */, + "index_dives_for_eq_ranges": true, + "rowid_ordered": false, + "using_mrr": false, + "index_only": false, + "rows": 42, + "cost": 14.96, + "chosen": true + } + ] /* range_scan_alternatives */, + "analyzing_roworder_intersect": { + "usable": false, + "cause": "too_few_roworder_scans" + } /* analyzing_roworder_intersect */ + } /* analyzing_range_alternatives */, + "chosen_range_access_summary": { + "range_access_plan": { + "type": "range_scan", + "index": "i2", + "rows": 42, + "ranges": [ + "1020 < key2" + ] /* ranges */ + } /* range_access_plan */, + "rows_for_plan": 42, + "cost_for_plan": 14.96, + "chosen": true + } /* chosen_range_access_summary */ + } /* range_analysis */ + }, + { + "table": "`t2`", + "table_scan": { + "rows": 1024, + "cost": 2.06 + } /* table_scan */ + } + ] /* rows_estimation */ + }, + { + "considered_execution_plans": [ + { + "plan_prefix": [ + ] /* plan_prefix */, + "table": "`t1`", + "best_access_path": { + "considered_access_paths": [ + { + "access_type": "ref", + "index": "i1", + "usable": false, + "chosen": false + }, + { + "rows_to_scan": 42, + "filtering_effect": [ + ] /* filtering_effect */, + "final_filtering_effect": 1, + "access_type": "range", + "range_details": { + "used_index": "i2" + } /* range_details */, + "resulting_rows": 42, + "cost": 19.16, + "chosen": true + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 100, + "rows_for_plan": 42, + "cost_for_plan": 19.16 + }, + { + "plan_prefix": [ + "`t1`" + ] /* plan_prefix */, + "table": "`t2`", + "best_access_path": { + "considered_access_paths": [ + { + "access_type": "ref", + "index": "PRIMARY", + "rows": 10, + "cost": 147, + "chosen": true + }, + { + "rows_to_scan": 1024, + "filtering_effect": [ + ] /* filtering_effect */, + "final_filtering_effect": 1, + "access_type": "scan", + "using_join_cache": true, + "buffers_needed": 1, + "resulting_rows": 1024, + "cost": 4302.87, + "chosen": false + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 100, + "rows_for_plan": 420, + "cost_for_plan": 166.16 + } + ] /* considered_execution_plans */ + }, + { + "attaching_conditions_to_tables": { + "original_condition": "((`t2`.`key1a` = `t1`.`key1`) and (`t1`.`key2` > 1020))", + "attached_conditions_computation": [ + ] /* attached_conditions_computation */, + "attached_conditions_summary": [ + { + "table": "`t1`", + "attached": "(`t1`.`key2` > 1020)" + }, + { + "table": "`t2`", + "attached": "(`t2`.`key1a` = `t1`.`key1`)" + } + ] /* attached_conditions_summary */ + } /* attaching_conditions_to_tables */ + }, + { + "finalizing_table_conditions": [ + { + "table": "`t1`", + "original_table_condition": "(`t1`.`key2` > 1020)", + "final_table_condition ": "(`t1`.`key2` > 1020)" + }, + { + "table": "`t2`", + "original_table_condition": "(`t2`.`key1a` = `t1`.`key1`)", + "final_table_condition ": null + } + ] /* finalizing_table_conditions */ + }, + { + "refine_plan": [ + { + "table": "`t1`", + "pushed_index_condition": "(`t1`.`key2` > 1020)", + "table_condition_attached": null + }, + { + "table": "`t2`" + } + ] /* refine_plan */ + } + ] /* steps */ + } /* join_optimization */ + }, + { + "join_explain": { + "select#": 1, + "steps": [ + ] /* steps */ + } /* join_explain */ + } + ] /* steps */ +} 0 0 +DROP TABLE t1,t2; +CREATE TABLE t1 ( +cola char(3) not null, +colb char(3) not null, +filler char(200), +key(cola), +key(colb) +) CHARSET utf8mb4; +INSERT INTO t1 VALUES ('foo','bar', 'ZZ'),('fuz','baz', 'ZZ'); +Inserting records + +EXPLAIN SELECT * FROM t1 WHERE cola = 'foo' AND colb = 'bar'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge cola,colb cola,colb 12,12 NULL 29 100.00 Using intersect(cola,colb); Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`cola` AS `cola`,`test`.`t1`.`colb` AS `colb`,`test`.`t1`.`filler` AS `filler` from `test`.`t1` where ((`test`.`t1`.`colb` = 'bar') and (`test`.`t1`.`cola` = 'foo')) + +SELECT * FROM information_schema.OPTIMIZER_TRACE; +QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES +EXPLAIN SELECT * FROM t1 WHERE cola = 'foo' AND colb = 'bar' { + "steps": [ + { + "join_preparation": { + "select#": 1, + "steps": [ + { + "expanded_query": "/* select#1 */ select `t1`.`cola` AS `cola`,`t1`.`colb` AS `colb`,`t1`.`filler` AS `filler` from `t1` where ((`t1`.`cola` = 'foo') and (`t1`.`colb` = 'bar'))" + } + ] /* steps */ + } /* join_preparation */ + }, + { + "join_optimization": { + "select#": 1, + "steps": [ + { + "condition_processing": { + "condition": "WHERE", + "original_condition": "((`t1`.`cola` = 'foo') and (`t1`.`colb` = 'bar'))", + "steps": [ + { + "transformation": "equality_propagation", + "resulting_condition": "(multiple equal('foo', `t1`.`cola`) and multiple equal('bar', `t1`.`colb`))" + }, + { + "transformation": "constant_propagation", + "resulting_condition": "(multiple equal('foo', `t1`.`cola`) and multiple equal('bar', `t1`.`colb`))" + }, + { + "transformation": "trivial_condition_removal", + "resulting_condition": "(multiple equal('foo', `t1`.`cola`) and multiple equal('bar', `t1`.`colb`))" + } + ] /* steps */ + } /* condition_processing */ + }, + { + "substitute_generated_columns": { + } /* substitute_generated_columns */ + }, + { + "table_dependencies": [ + { + "table": "`t1`", + "row_may_be_null": false, + "map_bit": 0, + "depends_on_map_bits": [ + ] /* depends_on_map_bits */ + } + ] /* table_dependencies */ + }, + { + "ref_optimizer_key_uses": [ + { + "table": "`t1`", + "field": "cola", + "equals": "'foo'", + "null_rejecting": true + }, + { + "table": "`t1`", + "field": "colb", + "equals": "'bar'", + "null_rejecting": true + } + ] /* ref_optimizer_key_uses */ + }, + { + "rows_estimation": [ + { + "table": "`t1`", + "range_analysis": { + "table_scan": { + "rows": 8704, + "cost": 1311.28 + } /* table_scan */, + "potential_range_indexes": [ + { + "index": "cola", + "usable": true, + "key_parts": [ + "cola" + ] /* key_parts */ + }, + { + "index": "colb", + "usable": true, + "key_parts": [ + "colb" + ] /* key_parts */ + } + ] /* potential_range_indexes */, + "setup_range_conditions": [ + ] /* setup_range_conditions */, + "group_index_range": { + "chosen": false, + "cause": "not_group_by_or_distinct" + } /* group_index_range */, + "skip_scan_range": { + "potential_skip_scan_indexes": [ + { + "index": "cola", + "usable": false, + "cause": "query_references_nonkey_column" + }, + { + "index": "colb", + "usable": false, + "cause": "query_references_nonkey_column" + } + ] /* potential_skip_scan_indexes */ + } /* skip_scan_range */, + "analyzing_range_alternatives": { + "range_scan_alternatives": [ + { + "index": "cola", + "ranges": [ + "foo <= cola <= foo" + ] /* ranges */, + "index_dives_for_eq_ranges": true, + "rowid_ordered": true, + "using_mrr": false, + "index_only": false, + "rows": 504, + "cost": 176.66, + "chosen": true + }, + { + "index": "colb", + "ranges": [ + "bar <= colb <= bar" + ] /* ranges */, + "index_dives_for_eq_ranges": true, + "rowid_ordered": true, + "using_mrr": false, + "index_only": false, + "rows": 504, + "cost": 176.66, + "chosen": false, + "cause": "cost" + } + ] /* range_scan_alternatives */, + "analyzing_roworder_intersect": { + "intersecting_indexes": [ + { + "index": "cola", + "index_scan_cost": 4.90741, + "cumulated_index_scan_cost": 4.90741, + "disk_sweep_cost": 109.54, + "cumulated_total_cost": 114.448, + "usable": true, + "matching_rows_now": 504, + "isect_covering_with_this_index": false, + "chosen": true + }, + { + "index": "colb", + "index_scan_cost": 4.90741, + "cumulated_index_scan_cost": 9.81481, + "disk_sweep_cost": 7.19243, + "cumulated_total_cost": 17.0072, + "usable": true, + "matching_rows_now": 29.1838, + "isect_covering_with_this_index": false, + "chosen": true + } + ] /* intersecting_indexes */, + "clustered_pk": { + "clustered_pk_added_to_intersect": false, + "cause": "no_clustered_pk_index" + } /* clustered_pk */, + "rows": 29, + "cost": 17.0072, + "covering": false, + "chosen": true + } /* analyzing_roworder_intersect */ + } /* analyzing_range_alternatives */, + "chosen_range_access_summary": { + "range_access_plan": { + "type": "index_roworder_intersect", + "rows": 29, + "cost": 17.0072, + "covering": false, + "clustered_pk_scan": false, + "intersect_of": [ + { + "type": "range_scan", + "index": "cola", + "rows": 504, + "ranges": [ + "foo <= cola <= foo" + ] /* ranges */ + }, + { + "type": "range_scan", + "index": "colb", + "rows": 504, + "ranges": [ + "bar <= colb <= bar" + ] /* ranges */ + } + ] /* intersect_of */ + } /* range_access_plan */, + "rows_for_plan": 29, + "cost_for_plan": 17.0072, + "chosen": true + } /* chosen_range_access_summary */ + } /* range_analysis */ + } + ] /* rows_estimation */ + }, + { + "considered_execution_plans": [ + { + "plan_prefix": [ + ] /* plan_prefix */, + "table": "`t1`", + "best_access_path": { + "considered_access_paths": [ + { + "access_type": "ref", + "index": "cola", + "rows": 504, + "cost": 176.4, + "chosen": true + }, + { + "access_type": "ref", + "index": "colb", + "rows": 504, + "cost": 176.4, + "chosen": false + }, + { + "rows_to_scan": 29, + "filtering_effect": [ + ] /* filtering_effect */, + "final_filtering_effect": 1, + "access_type": "range", + "range_details": { + "used_index": "intersect(cola,colb)" + } /* range_details */, + "resulting_rows": 29, + "cost": 19.9072, + "chosen": true + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 100, + "rows_for_plan": 29, + "cost_for_plan": 19.9072, + "chosen": true + } + ] /* considered_execution_plans */ + }, + { + "attaching_conditions_to_tables": { + "original_condition": "((`t1`.`colb` = 'bar') and (`t1`.`cola` = 'foo'))", + "attached_conditions_computation": [ + ] /* attached_conditions_computation */, + "attached_conditions_summary": [ + { + "table": "`t1`", + "attached": "((`t1`.`colb` = 'bar') and (`t1`.`cola` = 'foo'))" + } + ] /* attached_conditions_summary */ + } /* attaching_conditions_to_tables */ + }, + { + "finalizing_table_conditions": [ + { + "table": "`t1`", + "original_table_condition": "((`t1`.`colb` = 'bar') and (`t1`.`cola` = 'foo'))", + "final_table_condition ": "((`t1`.`colb` = 'bar') and (`t1`.`cola` = 'foo'))" + } + ] /* finalizing_table_conditions */ + }, + { + "refine_plan": [ + { + "table": "`t1`" + } + ] /* refine_plan */ + } + ] /* steps */ + } /* join_optimization */ + }, + { + "join_explain": { + "select#": 1, + "steps": [ + ] /* steps */ + } /* join_explain */ + } + ] /* steps */ +} 0 0 + +EXPLAIN SELECT * FROM t1 WHERE cola = 'f\no'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ref cola cola 12 const 1 100.00 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`cola` AS `cola`,`test`.`t1`.`colb` AS `colb`,`test`.`t1`.`filler` AS `filler` from `test`.`t1` where (`test`.`t1`.`cola` = 'f\no') + +SELECT * FROM information_schema.OPTIMIZER_TRACE; +QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES +EXPLAIN SELECT * FROM t1 WHERE cola = 'f\no' { + "steps": [ + { + "join_preparation": { + "select#": 1, + "steps": [ + { + "expanded_query": "/* select#1 */ select `t1`.`cola` AS `cola`,`t1`.`colb` AS `colb`,`t1`.`filler` AS `filler` from `t1` where (`t1`.`cola` = 'f\\no')" + } + ] /* steps */ + } /* join_preparation */ + }, + { + "join_optimization": { + "select#": 1, + "steps": [ + { + "condition_processing": { + "condition": "WHERE", + "original_condition": "(`t1`.`cola` = 'f\\no')", + "steps": [ + { + "transformation": "equality_propagation", + "resulting_condition": "multiple equal('f\\no', `t1`.`cola`)" + }, + { + "transformation": "constant_propagation", + "resulting_condition": "multiple equal('f\\no', `t1`.`cola`)" + }, + { + "transformation": "trivial_condition_removal", + "resulting_condition": "multiple equal('f\\no', `t1`.`cola`)" + } + ] /* steps */ + } /* condition_processing */ + }, + { + "substitute_generated_columns": { + } /* substitute_generated_columns */ + }, + { + "table_dependencies": [ + { + "table": "`t1`", + "row_may_be_null": false, + "map_bit": 0, + "depends_on_map_bits": [ + ] /* depends_on_map_bits */ + } + ] /* table_dependencies */ + }, + { + "ref_optimizer_key_uses": [ + { + "table": "`t1`", + "field": "cola", + "equals": "'f\\no'", + "null_rejecting": true + } + ] /* ref_optimizer_key_uses */ + }, + { + "rows_estimation": [ + { + "table": "`t1`", + "range_analysis": { + "table_scan": { + "rows": 8704, + "cost": 1311.28 + } /* table_scan */, + "potential_range_indexes": [ + { + "index": "cola", + "usable": true, + "key_parts": [ + "cola" + ] /* key_parts */ + }, + { + "index": "colb", + "usable": false, + "cause": "not_applicable" + } + ] /* potential_range_indexes */, + "setup_range_conditions": [ + ] /* setup_range_conditions */, + "group_index_range": { + "chosen": false, + "cause": "not_group_by_or_distinct" + } /* group_index_range */, + "skip_scan_range": { + "potential_skip_scan_indexes": [ + { + "index": "cola", + "usable": false, + "cause": "query_references_nonkey_column" + } + ] /* potential_skip_scan_indexes */ + } /* skip_scan_range */, + "analyzing_range_alternatives": { + "range_scan_alternatives": [ + { + "index": "cola", + "ranges": [ + "f\no <= cola <= f\no" + ] /* ranges */, + "index_dives_for_eq_ranges": true, + "rowid_ordered": true, + "using_mrr": false, + "index_only": false, + "rows": 1, + "cost": 0.61, + "chosen": true + } + ] /* range_scan_alternatives */, + "analyzing_roworder_intersect": { + "usable": false, + "cause": "too_few_roworder_scans" + } /* analyzing_roworder_intersect */ + } /* analyzing_range_alternatives */, + "chosen_range_access_summary": { + "range_access_plan": { + "type": "range_scan", + "index": "cola", + "rows": 1, + "ranges": [ + "f\no <= cola <= f\no" + ] /* ranges */ + } /* range_access_plan */, + "rows_for_plan": 1, + "cost_for_plan": 0.61, + "chosen": true + } /* chosen_range_access_summary */ + } /* range_analysis */ + } + ] /* rows_estimation */ + }, + { + "considered_execution_plans": [ + { + "plan_prefix": [ + ] /* plan_prefix */, + "table": "`t1`", + "best_access_path": { + "considered_access_paths": [ + { + "access_type": "ref", + "index": "cola", + "rows": 1, + "cost": 0.35, + "chosen": true + }, + { + "access_type": "range", + "range_details": { + "used_index": "cola" + } /* range_details */, + "chosen": false, + "cause": "heuristic_index_cheaper" + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 100, + "rows_for_plan": 1, + "cost_for_plan": 0.35, + "chosen": true + } + ] /* considered_execution_plans */ + }, + { + "attaching_conditions_to_tables": { + "original_condition": "(`t1`.`cola` = 'f\\no')", + "attached_conditions_computation": [ + ] /* attached_conditions_computation */, + "attached_conditions_summary": [ + { + "table": "`t1`", + "attached": "(`t1`.`cola` = 'f\\no')" + } + ] /* attached_conditions_summary */ + } /* attaching_conditions_to_tables */ + }, + { + "finalizing_table_conditions": [ + { + "table": "`t1`", + "original_table_condition": "(`t1`.`cola` = 'f\\no')", + "final_table_condition ": "(`t1`.`cola` = 'f\\no')" + } + ] /* finalizing_table_conditions */ + }, + { + "refine_plan": [ + { + "table": "`t1`", + "pushed_index_condition": "(`t1`.`cola` = 'f\\no')", + "table_condition_attached": null + } + ] /* refine_plan */ + } + ] /* steps */ + } /* join_optimization */ + }, + { + "join_explain": { + "select#": 1, + "steps": [ + ] /* steps */ + } /* join_explain */ + } + ] /* steps */ +} 0 0 +DROP TABLE t1; +CREATE TABLE t1(c INT); +INSERT INTO t1 VALUES (),(); +CREATE TABLE t2 (b INT, KEY(b)); +INSERT INTO t2 VALUES (),(),(); +SET optimizer_trace_features="greedy_search=off,dynamic_range=on"; +EXPLAIN SELECT 1 FROM +(SELECT 1 FROM t2,t1 WHERE b < c GROUP BY 1 LIMIT 1) AS d2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +2 DERIVED t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DERIVED t2 NULL ALL b NULL NULL NULL 3 33.33 Range checked for each record (index map: 0x1) +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from (/* select#2 */ select 1 AS `1` from `test`.`t2` join `test`.`t1` where (`test`.`t2`.`b` < `test`.`t1`.`c`) group by '' limit 1) `d2` + +SELECT * FROM information_schema.OPTIMIZER_TRACE; +QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES +EXPLAIN SELECT 1 FROM +(SELECT 1 FROM t2,t1 WHERE b < c GROUP BY 1 LIMIT 1) AS d2 { + "steps": [ + { + "join_preparation": { + "select#": 1, + "steps": [ + { + "join_preparation": { + "select#": 2, + "steps": [ + { + "expanded_query": "/* select#2 */ select 1 AS `1` from `t2` join `t1` where (`t2`.`b` < `t1`.`c`) group by '' limit 1" + } + ] /* steps */ + } /* join_preparation */ + }, + { + "derived": { + "table": " `d2`", + "select#": 2, + "materialized": true + } /* derived */ + }, + { + "expanded_query": "/* select#1 */ select 1 AS `1` from (/* select#2 */ select 1 AS `1` from `t2` join `t1` where (`t2`.`b` < `t1`.`c`) group by '' limit 1) `d2`" + } + ] /* steps */ + } /* join_preparation */ + }, + { + "join_optimization": { + "select#": 1, + "steps": [ + { + "join_optimization": { + "select#": 2, + "steps": [ + { + "condition_processing": { + "condition": "WHERE", + "original_condition": "(`t2`.`b` < `t1`.`c`)", + "steps": [ + { + "transformation": "equality_propagation", + "resulting_condition": "(`t2`.`b` < `t1`.`c`)" + }, + { + "transformation": "constant_propagation", + "resulting_condition": "(`t2`.`b` < `t1`.`c`)" + }, + { + "transformation": "trivial_condition_removal", + "resulting_condition": "(`t2`.`b` < `t1`.`c`)" + } + ] /* steps */ + } /* condition_processing */ + }, + { + "substitute_generated_columns": { + } /* substitute_generated_columns */ + }, + { + "table_dependencies": [ + { + "table": "`t2`", + "row_may_be_null": false, + "map_bit": 0, + "depends_on_map_bits": [ + ] /* depends_on_map_bits */ + }, + { + "table": "`t1`", + "row_may_be_null": false, + "map_bit": 1, + "depends_on_map_bits": [ + ] /* depends_on_map_bits */ + } + ] /* table_dependencies */ + }, + { + "ref_optimizer_key_uses": [ + ] /* ref_optimizer_key_uses */ + }, + { + "rows_estimation": [ + { + "table": "`t2`", + "table_scan": { + "rows": 3, + "cost": 0.501282 + } /* table_scan */ + }, + { + "table": "`t1`", + "table_scan": { + "rows": 2, + "cost": 0.500854 + } /* table_scan */ + } + ] /* rows_estimation */ + }, + { + "considered_execution_plans": "..." + }, + { + "attaching_conditions_to_tables": { + "original_condition": "(`t2`.`b` < `t1`.`c`)", + "attached_conditions_computation": [ + { + "table": "`t2`", + "rechecking_index_usage": { + "recheck_reason": "not_first_table", + "range_analysis": { + "table_scan": { + "rows": 3, + "cost": 3.05 + } /* table_scan */, + "potential_range_indexes": [ + { + "index": "b", + "usable": true, + "key_parts": [ + "b" + ] /* key_parts */ + } + ] /* potential_range_indexes */, + "best_covering_index_scan": { + "index": "b", + "cost": 0.561628, + "chosen": true + } /* best_covering_index_scan */, + "setup_range_conditions": [ + ] /* setup_range_conditions */, + "group_index_range": { + "chosen": false, + "cause": "not_single_table" + } /* group_index_range */, + "skip_scan_range": { + "chosen": false, + "cause": "not_single_table" + } /* skip_scan_range */, + "analyzing_range_alternatives": { + "range_scan_alternatives": [ + { + "index": "b", + "chosen": false, + "cause": "depends_on_unread_values" + } + ] /* range_scan_alternatives */, + "analyzing_roworder_intersect": { + "usable": false, + "cause": "too_few_roworder_scans" + } /* analyzing_roworder_intersect */ + } /* analyzing_range_alternatives */ + } /* range_analysis */ + } /* rechecking_index_usage */ + } + ] /* attached_conditions_computation */, + "attached_conditions_summary": [ + { + "table": "`t1`", + "attached": null + }, + { + "table": "`t2`", + "attached": "(`t2`.`b` < `t1`.`c`)" + } + ] /* attached_conditions_summary */ + } /* attaching_conditions_to_tables */ + }, + { + "optimizing_distinct_group_by_order_by": { + "simplifying_group_by": { + "original_clause": "''", + "items": [ + { + "item": "1", + "uses_only_constant_tables": true + } + ] /* items */, + "resulting_clause_is_simple": true, + "resulting_clause": "" + } /* simplifying_group_by */ + } /* optimizing_distinct_group_by_order_by */ + }, + { + "finalizing_table_conditions": [ + { + "table": "`t2`", + "original_table_condition": "(`t2`.`b` < `t1`.`c`)", + "final_table_condition ": "(`t2`.`b` < `t1`.`c`)" + } + ] /* finalizing_table_conditions */ + }, + { + "refine_plan": [ + { + "table": "`t1`" + }, + { + "table": "`t2`" + } + ] /* refine_plan */ + } + ] /* steps */ + } /* join_optimization */ + }, + { + "creating_tmp_table": { + "tmp_table_info": { + "table": " `d2`", + "columns": 1, + "row_length": 5, + "key_length": 0, + "unique_constraint": false, + "makes_grouped_rows": false, + "cannot_insert_duplicates": false, + "location": "TempTable" + } /* tmp_table_info */ + } /* creating_tmp_table */ + }, + { + "join_execution": { + "select#": 2, + "steps": [ + { + "rows_estimation_per_outer_row": { + "table": "`t2`", + "range_analysis": { + "table_scan": { + "rows": 3, + "cost": 2.90128 + } /* table_scan */, + "potential_range_indexes": [ + { + "index": "b", + "usable": true, + "key_parts": [ + "b" + ] /* key_parts */ + } + ] /* potential_range_indexes */, + "best_covering_index_scan": { + "index": "b", + "cost": 0.561628, + "chosen": true + } /* best_covering_index_scan */, + "setup_range_conditions": [ + { + "impossible_condition": { + "cause": "comparison_with_null_always_false" + } /* impossible_condition */ + } + ] /* setup_range_conditions */, + "impossible_range": true + } /* range_analysis */ + } /* rows_estimation_per_outer_row */ + }, + { + "rows_estimation_per_outer_row": { + "table": "`t2`", + "range_analysis": { + "table_scan": { + "rows": 3, + "cost": 2.90128 + } /* table_scan */, + "potential_range_indexes": [ + { + "index": "b", + "usable": true, + "key_parts": [ + "b" + ] /* key_parts */ + } + ] /* potential_range_indexes */, + "best_covering_index_scan": { + "index": "b", + "cost": 0.561628, + "chosen": true + } /* best_covering_index_scan */, + "setup_range_conditions": [ + { + "impossible_condition": { + "cause": "comparison_with_null_always_false" + } /* impossible_condition */ + } + ] /* setup_range_conditions */, + "impossible_range": true + } /* range_analysis */ + } /* rows_estimation_per_outer_row */ + } + ] /* steps */ + } /* join_execution */ + }, + { + "table_dependencies": [ + { + "table": " `d2`", + "row_may_be_null": false, + "map_bit": 0, + "depends_on_map_bits": [ + ] /* depends_on_map_bits */ + } + ] /* table_dependencies */ + }, + { + "rows_estimation": [ + { + "table": " `d2`", + "rows": 1, + "cost": 1, + "table_type": "system", + "empty": true + } + ] /* rows_estimation */ + } + ] /* steps */, + "empty_result": { + "cause": "no matching row in const table" + } /* empty_result */ + } /* join_optimization */ + }, + { + "join_explain": { + "select#": 1, + "steps": [ + { + "join_explain": { + "select#": 2, + "steps": [ + ] /* steps */ + } /* join_explain */ + } + ] /* steps */ + } /* join_explain */ + } + ] /* steps */ +} 0 0 + +SET optimizer_trace_features="greedy_search=off,dynamic_range=off"; +EXPLAIN SELECT 1 FROM +(SELECT 1 FROM t2,t1 WHERE b < c GROUP BY 1 LIMIT 1) AS d2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +2 DERIVED t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DERIVED t2 NULL ALL b NULL NULL NULL 3 33.33 Range checked for each record (index map: 0x1) +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from (/* select#2 */ select 1 AS `1` from `test`.`t2` join `test`.`t1` where (`test`.`t2`.`b` < `test`.`t1`.`c`) group by '' limit 1) `d2` + +SELECT * FROM information_schema.OPTIMIZER_TRACE; +QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES +EXPLAIN SELECT 1 FROM +(SELECT 1 FROM t2,t1 WHERE b < c GROUP BY 1 LIMIT 1) AS d2 { + "steps": [ + { + "join_preparation": { + "select#": 1, + "steps": [ + { + "join_preparation": { + "select#": 2, + "steps": [ + { + "expanded_query": "/* select#2 */ select 1 AS `1` from `t2` join `t1` where (`t2`.`b` < `t1`.`c`) group by '' limit 1" + } + ] /* steps */ + } /* join_preparation */ + }, + { + "derived": { + "table": " `d2`", + "select#": 2, + "materialized": true + } /* derived */ + }, + { + "expanded_query": "/* select#1 */ select 1 AS `1` from (/* select#2 */ select 1 AS `1` from `t2` join `t1` where (`t2`.`b` < `t1`.`c`) group by '' limit 1) `d2`" + } + ] /* steps */ + } /* join_preparation */ + }, + { + "join_optimization": { + "select#": 1, + "steps": [ + { + "join_optimization": { + "select#": 2, + "steps": [ + { + "condition_processing": { + "condition": "WHERE", + "original_condition": "(`t2`.`b` < `t1`.`c`)", + "steps": [ + { + "transformation": "equality_propagation", + "resulting_condition": "(`t2`.`b` < `t1`.`c`)" + }, + { + "transformation": "constant_propagation", + "resulting_condition": "(`t2`.`b` < `t1`.`c`)" + }, + { + "transformation": "trivial_condition_removal", + "resulting_condition": "(`t2`.`b` < `t1`.`c`)" + } + ] /* steps */ + } /* condition_processing */ + }, + { + "substitute_generated_columns": { + } /* substitute_generated_columns */ + }, + { + "table_dependencies": [ + { + "table": "`t2`", + "row_may_be_null": false, + "map_bit": 0, + "depends_on_map_bits": [ + ] /* depends_on_map_bits */ + }, + { + "table": "`t1`", + "row_may_be_null": false, + "map_bit": 1, + "depends_on_map_bits": [ + ] /* depends_on_map_bits */ + } + ] /* table_dependencies */ + }, + { + "ref_optimizer_key_uses": [ + ] /* ref_optimizer_key_uses */ + }, + { + "rows_estimation": [ + { + "table": "`t2`", + "table_scan": { + "rows": 3, + "cost": 0.501282 + } /* table_scan */ + }, + { + "table": "`t1`", + "table_scan": { + "rows": 2, + "cost": 0.500854 + } /* table_scan */ + } + ] /* rows_estimation */ + }, + { + "considered_execution_plans": "..." + }, + { + "attaching_conditions_to_tables": { + "original_condition": "(`t2`.`b` < `t1`.`c`)", + "attached_conditions_computation": [ + { + "table": "`t2`", + "rechecking_index_usage": { + "recheck_reason": "not_first_table", + "range_analysis": { + "table_scan": { + "rows": 3, + "cost": 3.05 + } /* table_scan */, + "potential_range_indexes": [ + { + "index": "b", + "usable": true, + "key_parts": [ + "b" + ] /* key_parts */ + } + ] /* potential_range_indexes */, + "best_covering_index_scan": { + "index": "b", + "cost": 0.561628, + "chosen": true + } /* best_covering_index_scan */, + "setup_range_conditions": [ + ] /* setup_range_conditions */, + "group_index_range": { + "chosen": false, + "cause": "not_single_table" + } /* group_index_range */, + "skip_scan_range": { + "chosen": false, + "cause": "not_single_table" + } /* skip_scan_range */, + "analyzing_range_alternatives": { + "range_scan_alternatives": [ + { + "index": "b", + "chosen": false, + "cause": "depends_on_unread_values" + } + ] /* range_scan_alternatives */, + "analyzing_roworder_intersect": { + "usable": false, + "cause": "too_few_roworder_scans" + } /* analyzing_roworder_intersect */ + } /* analyzing_range_alternatives */ + } /* range_analysis */ + } /* rechecking_index_usage */ + } + ] /* attached_conditions_computation */, + "attached_conditions_summary": [ + { + "table": "`t1`", + "attached": null + }, + { + "table": "`t2`", + "attached": "(`t2`.`b` < `t1`.`c`)" + } + ] /* attached_conditions_summary */ + } /* attaching_conditions_to_tables */ + }, + { + "optimizing_distinct_group_by_order_by": { + "simplifying_group_by": { + "original_clause": "''", + "items": [ + { + "item": "1", + "uses_only_constant_tables": true + } + ] /* items */, + "resulting_clause_is_simple": true, + "resulting_clause": "" + } /* simplifying_group_by */ + } /* optimizing_distinct_group_by_order_by */ + }, + { + "finalizing_table_conditions": [ + { + "table": "`t2`", + "original_table_condition": "(`t2`.`b` < `t1`.`c`)", + "final_table_condition ": "(`t2`.`b` < `t1`.`c`)" + } + ] /* finalizing_table_conditions */ + }, + { + "refine_plan": [ + { + "table": "`t1`" + }, + { + "table": "`t2`" + } + ] /* refine_plan */ + } + ] /* steps */ + } /* join_optimization */ + }, + { + "creating_tmp_table": { + "tmp_table_info": { + "table": " `d2`", + "columns": 1, + "row_length": 5, + "key_length": 0, + "unique_constraint": false, + "makes_grouped_rows": false, + "cannot_insert_duplicates": false, + "location": "TempTable" + } /* tmp_table_info */ + } /* creating_tmp_table */ + }, + { + "join_execution": { + "select#": 2, + "steps": [ + { + "rows_estimation_per_outer_row": { + "table": "`t2`", + "range_analysis": { + "table_scan": { + "rows": 3, + "cost": 2.90128 + } /* table_scan */, + "potential_range_indexes": [ + { + "index": "b", + "usable": true, + "key_parts": [ + "b" + ] /* key_parts */ + } + ] /* potential_range_indexes */, + "best_covering_index_scan": { + "index": "b", + "cost": 0.561628, + "chosen": true + } /* best_covering_index_scan */, + "setup_range_conditions": [ + { + "impossible_condition": { + "cause": "comparison_with_null_always_false" + } /* impossible_condition */ + } + ] /* setup_range_conditions */, + "impossible_range": true + } /* range_analysis */ + } /* rows_estimation_per_outer_row */ + } + ] /* steps */ + } /* join_execution */ + }, + { + "table_dependencies": [ + { + "table": " `d2`", + "row_may_be_null": false, + "map_bit": 0, + "depends_on_map_bits": [ + ] /* depends_on_map_bits */ + } + ] /* table_dependencies */ + }, + { + "rows_estimation": [ + { + "table": " `d2`", + "rows": 1, + "cost": 1, + "table_type": "system", + "empty": true + } + ] /* rows_estimation */ + } + ] /* steps */, + "empty_result": { + "cause": "no matching row in const table" + } /* empty_result */ + } /* join_optimization */ + }, + { + "join_explain": { + "select#": 1, + "steps": [ + { + "join_explain": { + "select#": 2, + "steps": [ + ] /* steps */ + } /* join_explain */ + } + ] /* steps */ + } /* join_explain */ + } + ] /* steps */ +} 0 0 + +DROP TABLE t1,t2; +SET optimizer_trace_features=default; +CREATE TABLE t1 ( +i1 int, +i2 int, +c char(1), +KEY k1 (i1), +KEY k2 (i1, i2) +) CHARSET utf8mb4; +INSERT INTO t1 VALUES (0,1,'2'),(3,2,'1'); +EXPLAIN SELECT * FROM t1 WHERE i1 > '2' ORDER BY i1, i2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range k1,k2 k2 5 NULL 2 100.00 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i1` AS `i1`,`test`.`t1`.`i2` AS `i2`,`test`.`t1`.`c` AS `c` from `test`.`t1` where (`test`.`t1`.`i1` > 2) order by `test`.`t1`.`i1`,`test`.`t1`.`i2` + +SELECT * FROM information_schema.OPTIMIZER_TRACE; +QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES +EXPLAIN SELECT * FROM t1 WHERE i1 > '2' ORDER BY i1, i2 { + "steps": [ + { + "join_preparation": { + "select#": 1, + "steps": [ + { + "expanded_query": "/* select#1 */ select `t1`.`i1` AS `i1`,`t1`.`i2` AS `i2`,`t1`.`c` AS `c` from `t1` where (`t1`.`i1` > '2') order by `t1`.`i1`,`t1`.`i2`" + } + ] /* steps */ + } /* join_preparation */ + }, + { + "join_optimization": { + "select#": 1, + "steps": [ + { + "condition_processing": { + "condition": "WHERE", + "original_condition": "(`t1`.`i1` > '2')", + "steps": [ + { + "transformation": "equality_propagation", + "resulting_condition": "(`t1`.`i1` > '2')" + }, + { + "transformation": "constant_propagation", + "resulting_condition": "(`t1`.`i1` > '2')" + }, + { + "transformation": "trivial_condition_removal", + "resulting_condition": "(`t1`.`i1` > 2)" + } + ] /* steps */ + } /* condition_processing */ + }, + { + "substitute_generated_columns": { + } /* substitute_generated_columns */ + }, + { + "table_dependencies": [ + { + "table": "`t1`", + "row_may_be_null": false, + "map_bit": 0, + "depends_on_map_bits": [ + ] /* depends_on_map_bits */ + } + ] /* table_dependencies */ + }, + { + "ref_optimizer_key_uses": [ + ] /* ref_optimizer_key_uses */ + }, + { + "rows_estimation": [ + { + "table": "`t1`", + "range_analysis": { + "table_scan": { + "rows": 2, + "cost": 2.80159 + } /* table_scan */, + "potential_range_indexes": [ + { + "index": "k1", + "usable": true, + "key_parts": [ + "i1" + ] /* key_parts */ + }, + { + "index": "k2", + "usable": true, + "key_parts": [ + "i1", + "i2" + ] /* key_parts */ + } + ] /* potential_range_indexes */, + "setup_range_conditions": [ + ] /* setup_range_conditions */, + "group_index_range": { + "chosen": false, + "cause": "not_group_by_or_distinct" + } /* group_index_range */, + "skip_scan_range": { + "potential_skip_scan_indexes": [ + { + "index": "k1", + "usable": false, + "cause": "query_references_nonkey_column" + }, + { + "index": "k2", + "usable": false, + "cause": "query_references_nonkey_column" + } + ] /* potential_skip_scan_indexes */ + } /* skip_scan_range */, + "analyzing_range_alternatives": { + "range_scan_alternatives": [ + { + "index": "k1", + "ranges": [ + "2 < i1" + ] /* ranges */, + "index_dives_for_eq_ranges": true, + "rowid_ordered": false, + "using_mrr": false, + "index_only": false, + "rows": 2, + "cost": 0.96, + "chosen": true + }, + { + "index": "k2", + "ranges": [ + "2 < i1" + ] /* ranges */, + "index_dives_for_eq_ranges": true, + "rowid_ordered": false, + "using_mrr": false, + "index_only": false, + "rows": 2, + "cost": 0.96, + "chosen": false, + "cause": "cost" + } + ] /* range_scan_alternatives */, + "analyzing_roworder_intersect": { + "usable": false, + "cause": "too_few_roworder_scans" + } /* analyzing_roworder_intersect */ + } /* analyzing_range_alternatives */, + "chosen_range_access_summary": { + "range_access_plan": { + "type": "range_scan", + "index": "k1", + "rows": 2, + "ranges": [ + "2 < i1" + ] /* ranges */ + } /* range_access_plan */, + "rows_for_plan": 2, + "cost_for_plan": 0.96, + "chosen": true + } /* chosen_range_access_summary */ + } /* range_analysis */ + } + ] /* rows_estimation */ + }, + { + "considered_execution_plans": [ + { + "plan_prefix": [ + ] /* plan_prefix */, + "table": "`t1`", + "best_access_path": { + "considered_access_paths": [ + { + "rows_to_scan": 2, + "filtering_effect": [ + ] /* filtering_effect */, + "final_filtering_effect": 1, + "access_type": "range", + "range_details": { + "used_index": "k1" + } /* range_details */, + "resulting_rows": 2, + "cost": 1.16, + "chosen": true, + "use_tmp_table": true + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 100, + "rows_for_plan": 2, + "cost_for_plan": 1.16, + "sort_cost": 2, + "new_cost_for_plan": 3.16, + "chosen": true + } + ] /* considered_execution_plans */ + }, + { + "attaching_conditions_to_tables": { + "original_condition": "(`t1`.`i1` > 2)", + "attached_conditions_computation": [ + ] /* attached_conditions_computation */, + "attached_conditions_summary": [ + { + "table": "`t1`", + "attached": "(`t1`.`i1` > 2)" + } + ] /* attached_conditions_summary */ + } /* attaching_conditions_to_tables */ + }, + { + "optimizing_distinct_group_by_order_by": { + "simplifying_order_by": { + "original_clause": "`t1`.`i1`,`t1`.`i2`", + "items": [ + { + "item": "`t1`.`i1`" + }, + { + "item": "`t1`.`i2`" + } + ] /* items */, + "resulting_clause_is_simple": true, + "resulting_clause": "`t1`.`i1`,`t1`.`i2`" + } /* simplifying_order_by */ + } /* optimizing_distinct_group_by_order_by */ + }, + { + "reconsidering_access_paths_for_index_ordering": { + "clause": "ORDER BY", + "steps": [ + { + "rows_estimation": { + "table": "`t1`", + "index": "k2", + "range_analysis": { + "table_scan": { + "rows": 2, + "cost": 2.80159 + } /* table_scan */, + "potential_range_indexes": [ + { + "index": "k1", + "usable": false, + "cause": "not_applicable" + }, + { + "index": "k2", + "usable": true, + "key_parts": [ + "i1", + "i2" + ] /* key_parts */ + } + ] /* potential_range_indexes */, + "setup_range_conditions": [ + ] /* setup_range_conditions */, + "group_index_range": { + "chosen": false, + "cause": "not_group_by_or_distinct" + } /* group_index_range */, + "skip_scan_range": { + "potential_skip_scan_indexes": [ + { + "index": "k2", + "usable": false, + "cause": "query_references_nonkey_column" + } + ] /* potential_skip_scan_indexes */ + } /* skip_scan_range */, + "analyzing_range_alternatives": { + "range_scan_alternatives": [ + { + "index": "k2", + "ranges": [ + "2 < i1" + ] /* ranges */, + "index_dives_for_eq_ranges": true, + "rowid_ordered": false, + "using_mrr": false, + "index_only": false, + "rows": 2, + "cost": 0.96, + "chosen": true + } + ] /* range_scan_alternatives */, + "analyzing_roworder_intersect": { + "usable": false, + "cause": "too_few_roworder_scans" + } /* analyzing_roworder_intersect */ + } /* analyzing_range_alternatives */, + "chosen_range_access_summary": { + "range_access_plan": { + "type": "range_scan", + "index": "k2", + "rows": 2, + "ranges": [ + "2 < i1" + ] /* ranges */ + } /* range_access_plan */, + "rows_for_plan": 2, + "cost_for_plan": 0.96, + "chosen": true + } /* chosen_range_access_summary */ + } /* range_analysis */ + } /* rows_estimation */ + } + ] /* steps */, + "index_order_summary": { + "table": "`t1`", + "index_provides_order": true, + "order_direction": "asc", + "index": "k2", + "plan_changed": true, + "access_type": "range" + } /* index_order_summary */ + } /* reconsidering_access_paths_for_index_ordering */ + }, + { + "finalizing_table_conditions": [ + { + "table": "`t1`", + "original_table_condition": "(`t1`.`i1` > 2)", + "final_table_condition ": "(`t1`.`i1` > 2)" + } + ] /* finalizing_table_conditions */ + }, + { + "refine_plan": [ + { + "table": "`t1`", + "pushed_index_condition": "(`t1`.`i1` > 2)", + "table_condition_attached": null + } + ] /* refine_plan */ + }, + { + "considering_tmp_tables": [ + ] /* considering_tmp_tables */ + } + ] /* steps */ + } /* join_optimization */ + }, + { + "join_explain": { + "select#": 1, + "steps": [ + ] /* steps */ + } /* join_explain */ + } + ] /* steps */ +} 0 0 + +EXPLAIN SELECT DISTINCT i1 FROM t1 WHERE i1 >= '1' ORDER BY i1 DESC; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index k1,k2 k1 5 NULL 2 100.00 Using where; Backward index scan; Using index +Warnings: +Note 1003 /* select#1 */ select distinct `test`.`t1`.`i1` AS `i1` from `test`.`t1` where (`test`.`t1`.`i1` >= 1) order by `test`.`t1`.`i1` desc + +SELECT * FROM information_schema.OPTIMIZER_TRACE; +QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES +EXPLAIN SELECT DISTINCT i1 FROM t1 WHERE i1 >= '1' ORDER BY i1 DESC { + "steps": [ + { + "join_preparation": { + "select#": 1, + "steps": [ + { + "expanded_query": "/* select#1 */ select distinct `t1`.`i1` AS `i1` from `t1` where (`t1`.`i1` >= '1') order by `t1`.`i1` desc" + } + ] /* steps */ + } /* join_preparation */ + }, + { + "join_optimization": { + "select#": 1, + "steps": [ + { + "condition_processing": { + "condition": "WHERE", + "original_condition": "(`t1`.`i1` >= '1')", + "steps": [ + { + "transformation": "equality_propagation", + "resulting_condition": "(`t1`.`i1` >= '1')" + }, + { + "transformation": "constant_propagation", + "resulting_condition": "(`t1`.`i1` >= '1')" + }, + { + "transformation": "trivial_condition_removal", + "resulting_condition": "(`t1`.`i1` >= 1)" + } + ] /* steps */ + } /* condition_processing */ + }, + { + "substitute_generated_columns": { + } /* substitute_generated_columns */ + }, + { + "table_dependencies": [ + { + "table": "`t1`", + "row_may_be_null": false, + "map_bit": 0, + "depends_on_map_bits": [ + ] /* depends_on_map_bits */ + } + ] /* table_dependencies */ + }, + { + "ref_optimizer_key_uses": [ + ] /* ref_optimizer_key_uses */ + }, + { + "rows_estimation": [ + { + "table": "`t1`", + "range_analysis": { + "table_scan": { + "rows": 2, + "cost": 2.80159 + } /* table_scan */, + "potential_range_indexes": [ + { + "index": "k1", + "usable": true, + "key_parts": [ + "i1" + ] /* key_parts */ + }, + { + "index": "k2", + "usable": true, + "key_parts": [ + "i1", + "i2" + ] /* key_parts */ + } + ] /* potential_range_indexes */, + "best_covering_index_scan": { + "index": "k1", + "cost": 0.455814, + "chosen": true + } /* best_covering_index_scan */, + "setup_range_conditions": [ + ] /* setup_range_conditions */, + "group_index_range": { + "distinct_query": true, + "potential_group_range_indexes": [ + { + "index": "k1", + "covering": true, + "index_dives_for_eq_ranges": true, + "ranges": [ + "1 <= i1" + ] /* ranges */, + "rows": 3, + "cost": 0.7 + }, + { + "index": "k2", + "covering": true, + "index_dives_for_eq_ranges": true, + "ranges": [ + "1 <= i1" + ] /* ranges */, + "rows": 3, + "cost": 0.7 + } + ] /* potential_group_range_indexes */ + } /* group_index_range */, + "best_group_range_summary": { + "type": "index_group", + "index": "k1", + "group_attribute": null, + "min_aggregate": false, + "max_aggregate": false, + "distinct_aggregate": false, + "rows": 3, + "cost": 0.7, + "key_parts_used_for_access": [ + "i1" + ] /* key_parts_used_for_access */, + "ranges": [ + "1 <= i1" + ] /* ranges */, + "chosen": false, + "cause": "cost" + } /* best_group_range_summary */, + "skip_scan_range": { + "chosen": false, + "cause": "has_select_distinct" + } /* skip_scan_range */, + "analyzing_range_alternatives": { + "range_scan_alternatives": [ + { + "index": "k1", + "ranges": [ + "1 <= i1" + ] /* ranges */, + "index_dives_for_eq_ranges": true, + "rowid_ordered": false, + "using_mrr": false, + "index_only": true, + "rows": 2, + "cost": 0.465814, + "chosen": false, + "cause": "cost" + }, + { + "index": "k2", + "ranges": [ + "1 <= i1" + ] /* ranges */, + "index_dives_for_eq_ranges": true, + "rowid_ordered": false, + "using_mrr": false, + "index_only": true, + "rows": 2, + "cost": 0.468065, + "chosen": false, + "cause": "cost" + } + ] /* range_scan_alternatives */, + "analyzing_roworder_intersect": { + "usable": false, + "cause": "too_few_roworder_scans" + } /* analyzing_roworder_intersect */ + } /* analyzing_range_alternatives */ + } /* range_analysis */ + } + ] /* rows_estimation */ + }, + { + "considered_execution_plans": [ + { + "plan_prefix": [ + ] /* plan_prefix */, + "table": "`t1`", + "best_access_path": { + "considered_access_paths": [ + { + "rows_to_scan": 2, + "filtering_effect": [ + ] /* filtering_effect */, + "final_filtering_effect": 1, + "access_type": "scan", + "resulting_rows": 2, + "cost": 0.701587, + "chosen": true, + "use_tmp_table": true + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 100, + "rows_for_plan": 2, + "cost_for_plan": 0.701587, + "sort_cost": 2, + "new_cost_for_plan": 2.70159, + "chosen": true + } + ] /* considered_execution_plans */ + }, + { + "attaching_conditions_to_tables": { + "original_condition": "(`t1`.`i1` >= 1)", + "attached_conditions_computation": [ + ] /* attached_conditions_computation */, + "attached_conditions_summary": [ + { + "table": "`t1`", + "attached": "(`t1`.`i1` >= 1)" + } + ] /* attached_conditions_summary */ + } /* attaching_conditions_to_tables */ + }, + { + "optimizing_distinct_group_by_order_by": { + "simplifying_order_by": { + "original_clause": "`t1`.`i1` desc", + "items": [ + { + "item": "`t1`.`i1`" + } + ] /* items */, + "resulting_clause_is_simple": true, + "resulting_clause": "`t1`.`i1` desc" + } /* simplifying_order_by */, + "unknown_key_1": { + "reconsidering_access_paths_for_index_ordering": { + "clause": "ORDER BY", + "steps": [ + ] /* steps */, + "index_order_summary": { + "table": "`t1`", + "index_provides_order": true, + "order_direction": "desc", + "index": "k1", + "plan_changed": false + } /* index_order_summary */ + } /* reconsidering_access_paths_for_index_ordering */ + }, + "unknown_key_2": { + "reconsidering_access_paths_for_index_ordering": { + "clause": "GROUP BY", + "steps": [ + ] /* steps */, + "index_order_summary": { + "table": "`t1`", + "index_provides_order": true, + "order_direction": "desc", + "index": "k1", + "plan_changed": false + } /* index_order_summary */ + } /* reconsidering_access_paths_for_index_ordering */ + }, + "changed_distinct_to_group_by": true, + "simplifying_group_by": { + "original_clause": "`t1`.`i1` desc", + "items": [ + { + "item": "`t1`.`i1`" + } + ] /* items */, + "resulting_clause_is_simple": true, + "resulting_clause": "`t1`.`i1` desc" + } /* simplifying_group_by */, + "removed_order_by": true + } /* optimizing_distinct_group_by_order_by */ + }, + { + "reconsidering_access_paths_for_index_ordering": { + "clause": "GROUP BY", + "steps": [ + ] /* steps */, + "index_order_summary": { + "table": "`t1`", + "index_provides_order": true, + "order_direction": "desc", + "index": "k1", + "plan_changed": false + } /* index_order_summary */ + } /* reconsidering_access_paths_for_index_ordering */ + }, + { + "finalizing_table_conditions": [ + { + "table": "`t1`", + "original_table_condition": "(`t1`.`i1` >= 1)", + "final_table_condition ": "(`t1`.`i1` >= 1)" + } + ] /* finalizing_table_conditions */ + }, + { + "refine_plan": [ + { + "table": "`t1`" + } + ] /* refine_plan */ + }, + { + "considering_tmp_tables": [ + ] /* considering_tmp_tables */ + } + ] /* steps */ + } /* join_optimization */ + }, + { + "join_explain": { + "select#": 1, + "steps": [ + ] /* steps */ + } /* join_explain */ + } + ] /* steps */ +} 0 0 + +DROP TABLE t1; +CREATE TABLE t1 ( +pk INT PRIMARY KEY, +i1 INT, +i2 INT, +v varchar(1), +INDEX i1_idx (i1), +INDEX v_idx (v,i1) +) ENGINE=InnoDB, CHARSET utf8mb4; +INSERT INTO t1 VALUES (1, 1, 9,'a'), (2, 2, 8,'b'), (3, 3, 7,'c'), +(4, 4, 6,'d'), (5, 5, 5,'e'); + +# Covering ROR intersect not chosen: Index with more keyparts found. +EXPLAIN SELECT v FROM t1 WHERE i1 = 1 AND v = 'a' AND pk < 3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range PRIMARY,i1_idx,v_idx v_idx 16 NULL 1 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`v` AS `v` from `test`.`t1` where ((`test`.`t1`.`v` = 'a') and (`test`.`t1`.`i1` = 1) and (`test`.`t1`.`pk` < 3)) + +SELECT * FROM information_schema.OPTIMIZER_TRACE; +QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES +EXPLAIN SELECT v FROM t1 WHERE i1 = 1 AND v = 'a' AND pk < 3 { + "steps": [ + { + "join_preparation": { + "select#": 1, + "steps": [ + { + "expanded_query": "/* select#1 */ select `t1`.`v` AS `v` from `t1` where ((`t1`.`i1` = 1) and (`t1`.`v` = 'a') and (`t1`.`pk` < 3))" + } + ] /* steps */ + } /* join_preparation */ + }, + { + "join_optimization": { + "select#": 1, + "steps": [ + { + "condition_processing": { + "condition": "WHERE", + "original_condition": "((`t1`.`i1` = 1) and (`t1`.`v` = 'a') and (`t1`.`pk` < 3))", + "steps": [ + { + "transformation": "equality_propagation", + "resulting_condition": "((`t1`.`pk` < 3) and multiple equal(1, `t1`.`i1`) and multiple equal('a', `t1`.`v`))" + }, + { + "transformation": "constant_propagation", + "resulting_condition": "((`t1`.`pk` < 3) and multiple equal(1, `t1`.`i1`) and multiple equal('a', `t1`.`v`))" + }, + { + "transformation": "trivial_condition_removal", + "resulting_condition": "((`t1`.`pk` < 3) and multiple equal(1, `t1`.`i1`) and multiple equal('a', `t1`.`v`))" + } + ] /* steps */ + } /* condition_processing */ + }, + { + "substitute_generated_columns": { + } /* substitute_generated_columns */ + }, + { + "table_dependencies": [ + { + "table": "`t1`", + "row_may_be_null": false, + "map_bit": 0, + "depends_on_map_bits": [ + ] /* depends_on_map_bits */ + } + ] /* table_dependencies */ + }, + { + "ref_optimizer_key_uses": [ + { + "table": "`t1`", + "field": "i1", + "equals": "1", + "null_rejecting": true + }, + { + "table": "`t1`", + "field": "v", + "equals": "'a'", + "null_rejecting": true + }, + { + "table": "`t1`", + "field": "i1", + "equals": "1", + "null_rejecting": true + } + ] /* ref_optimizer_key_uses */ + }, + { + "rows_estimation": [ + { + "table": "`t1`", + "range_analysis": { + "table_scan": { + "rows": 5, + "cost": 2.85 + } /* table_scan */, + "potential_range_indexes": [ + { + "index": "PRIMARY", + "usable": true, + "key_parts": [ + "pk" + ] /* key_parts */ + }, + { + "index": "i1_idx", + "usable": true, + "key_parts": [ + "i1", + "pk" + ] /* key_parts */ + }, + { + "index": "v_idx", + "usable": true, + "key_parts": [ + "v", + "i1", + "pk" + ] /* key_parts */ + } + ] /* potential_range_indexes */, + "best_covering_index_scan": { + "index": "v_idx", + "cost": 0.751949, + "chosen": true + } /* best_covering_index_scan */, + "setup_range_conditions": [ + ] /* setup_range_conditions */, + "group_index_range": { + "chosen": false, + "cause": "not_group_by_or_distinct" + } /* group_index_range */, + "skip_scan_range": { + "potential_skip_scan_indexes": [ + { + "index": "PRIMARY", + "usable": false, + "cause": "query_references_nonkey_column" + }, + { + "index": "i1_idx", + "usable": false, + "cause": "query_references_nonkey_column" + }, + { + "index": "v_idx", + "usable": false, + "cause": "prefix_not_const_equality" + } + ] /* potential_skip_scan_indexes */ + } /* skip_scan_range */, + "analyzing_range_alternatives": { + "range_scan_alternatives": [ + { + "index": "PRIMARY", + "ranges": [ + "pk < 3" + ] /* ranges */, + "index_dives_for_eq_ranges": true, + "rowid_ordered": true, + "using_mrr": false, + "index_only": false, + "rows": 2, + "cost": 0.71, + "chosen": true + }, + { + "index": "i1_idx", + "ranges": [ + "1 <= i1 <= 1 AND pk < 3" + ] /* ranges */, + "index_dives_for_eq_ranges": true, + "rowid_ordered": true, + "using_mrr": false, + "index_only": false, + "rows": 1, + "cost": 0.61, + "chosen": true + }, + { + "index": "v_idx", + "ranges": [ + "a <= v <= a AND 1 <= i1 <= 1 AND pk < 3" + ] /* ranges */, + "index_dives_for_eq_ranges": true, + "rowid_ordered": true, + "using_mrr": false, + "index_only": true, + "rows": 1, + "cost": 0.36, + "chosen": true + } + ] /* range_scan_alternatives */, + "analyzing_roworder_intersect": { + "intersecting_indexes": [ + { + "index": "v_idx", + "index_scan_cost": 0.25, + "cumulated_index_scan_cost": 0.25, + "disk_sweep_cost": 0, + "cumulated_total_cost": 0.25, + "usable": true, + "matching_rows_now": 1, + "isect_covering_with_this_index": true, + "chosen": true + } + ] /* intersecting_indexes */, + "clustered_pk": { + "clustered_pk_added_to_intersect": false, + "cause": "roworder_is_covering" + } /* clustered_pk */, + "chosen": false, + "cause": "too_few_indexes_to_merge" + } /* analyzing_roworder_intersect */ + } /* analyzing_range_alternatives */, + "chosen_range_access_summary": { + "range_access_plan": { + "type": "range_scan", + "index": "v_idx", + "rows": 1, + "ranges": [ + "a <= v <= a AND 1 <= i1 <= 1 AND pk < 3" + ] /* ranges */ + } /* range_access_plan */, + "rows_for_plan": 1, + "cost_for_plan": 0.36, + "chosen": true + } /* chosen_range_access_summary */ + } /* range_analysis */ + } + ] /* rows_estimation */ + }, + { + "considered_execution_plans": [ + { + "plan_prefix": [ + ] /* plan_prefix */, + "table": "`t1`", + "best_access_path": { + "considered_access_paths": [ + { + "access_type": "ref", + "index": "i1_idx", + "chosen": false, + "cause": "range_uses_more_keyparts" + }, + { + "access_type": "ref", + "index": "v_idx", + "chosen": false, + "cause": "range_uses_more_keyparts" + }, + { + "rows_to_scan": 1, + "filtering_effect": [ + ] /* filtering_effect */, + "final_filtering_effect": 1, + "access_type": "range", + "range_details": { + "used_index": "v_idx" + } /* range_details */, + "resulting_rows": 1, + "cost": 0.46, + "chosen": true + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 100, + "rows_for_plan": 1, + "cost_for_plan": 0.46, + "chosen": true + } + ] /* considered_execution_plans */ + }, + { + "attaching_conditions_to_tables": { + "original_condition": "((`t1`.`v` = 'a') and (`t1`.`i1` = 1) and (`t1`.`pk` < 3))", + "attached_conditions_computation": [ + ] /* attached_conditions_computation */, + "attached_conditions_summary": [ + { + "table": "`t1`", + "attached": "((`t1`.`v` = 'a') and (`t1`.`i1` = 1) and (`t1`.`pk` < 3))" + } + ] /* attached_conditions_summary */ + } /* attaching_conditions_to_tables */ + }, + { + "finalizing_table_conditions": [ + { + "table": "`t1`", + "original_table_condition": "((`t1`.`v` = 'a') and (`t1`.`i1` = 1) and (`t1`.`pk` < 3))", + "final_table_condition ": "((`t1`.`v` = 'a') and (`t1`.`i1` = 1) and (`t1`.`pk` < 3))" + } + ] /* finalizing_table_conditions */ + }, + { + "refine_plan": [ + { + "table": "`t1`" + } + ] /* refine_plan */ + } + ] /* steps */ + } /* join_optimization */ + }, + { + "make_parallel_query_plan": { + "select#": 1, + "detail": [ + { + "table": "`t1`", + "degree of parallel": 4 + } + ] /* detail */ + } /* make_parallel_query_plan */ + }, + { + "join_explain": { + "select#": 1, + "steps": [ + ] /* steps */ + } /* join_explain */ + } + ] /* steps */ +} 0 0 + +# Chooses ROR intersect +EXPLAIN SELECT v FROM t1 WHERE i1 = 1 AND pk < 3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge PRIMARY,i1_idx,v_idx i1_idx,PRIMARY 9,4 NULL 1 100.00 Using intersect(i1_idx,PRIMARY); Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`v` AS `v` from `test`.`t1` where ((`test`.`t1`.`i1` = 1) and (`test`.`t1`.`pk` < 3)) + +SELECT * FROM information_schema.OPTIMIZER_TRACE; +QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES +EXPLAIN SELECT v FROM t1 WHERE i1 = 1 AND pk < 3 { + "steps": [ + { + "join_preparation": { + "select#": 1, + "steps": [ + { + "expanded_query": "/* select#1 */ select `t1`.`v` AS `v` from `t1` where ((`t1`.`i1` = 1) and (`t1`.`pk` < 3))" + } + ] /* steps */ + } /* join_preparation */ + }, + { + "join_optimization": { + "select#": 1, + "steps": [ + { + "condition_processing": { + "condition": "WHERE", + "original_condition": "((`t1`.`i1` = 1) and (`t1`.`pk` < 3))", + "steps": [ + { + "transformation": "equality_propagation", + "resulting_condition": "((`t1`.`pk` < 3) and multiple equal(1, `t1`.`i1`))" + }, + { + "transformation": "constant_propagation", + "resulting_condition": "((`t1`.`pk` < 3) and multiple equal(1, `t1`.`i1`))" + }, + { + "transformation": "trivial_condition_removal", + "resulting_condition": "((`t1`.`pk` < 3) and multiple equal(1, `t1`.`i1`))" + } + ] /* steps */ + } /* condition_processing */ + }, + { + "substitute_generated_columns": { + } /* substitute_generated_columns */ + }, + { + "table_dependencies": [ + { + "table": "`t1`", + "row_may_be_null": false, + "map_bit": 0, + "depends_on_map_bits": [ + ] /* depends_on_map_bits */ + } + ] /* table_dependencies */ + }, + { + "ref_optimizer_key_uses": [ + { + "table": "`t1`", + "field": "i1", + "equals": "1", + "null_rejecting": true + } + ] /* ref_optimizer_key_uses */ + }, + { + "rows_estimation": [ + { + "table": "`t1`", + "range_analysis": { + "table_scan": { + "rows": 5, + "cost": 2.85 + } /* table_scan */, + "potential_range_indexes": [ + { + "index": "PRIMARY", + "usable": true, + "key_parts": [ + "pk" + ] /* key_parts */ + }, + { + "index": "i1_idx", + "usable": true, + "key_parts": [ + "i1", + "pk" + ] /* key_parts */ + }, + { + "index": "v_idx", + "usable": true, + "key_parts": [ + "v", + "i1", + "pk" + ] /* key_parts */ + } + ] /* potential_range_indexes */, + "best_covering_index_scan": { + "index": "v_idx", + "cost": 0.751949, + "chosen": true + } /* best_covering_index_scan */, + "setup_range_conditions": [ + ] /* setup_range_conditions */, + "group_index_range": { + "chosen": false, + "cause": "not_group_by_or_distinct" + } /* group_index_range */, + "skip_scan_range": { + "potential_skip_scan_indexes": [ + { + "index": "PRIMARY", + "usable": false, + "cause": "query_references_nonkey_column" + }, + { + "index": "i1_idx", + "usable": false, + "cause": "query_references_nonkey_column" + }, + { + "index": "v_idx", + "tree_travel_cost": 0.15, + "num_groups": 6, + "rows": 5, + "cost": 2.80195 + } + ] /* potential_skip_scan_indexes */ + } /* skip_scan_range */, + "best_skip_scan_summary": { + "type": "skip_scan", + "index": "v_idx", + "key_parts_used_for_access": [ + "v", + "i1" + ] /* key_parts_used_for_access */, + "range": [ + "1 <= i1 <= 1" + ] /* range */, + "chosen": false, + "cause": "cost" + } /* best_skip_scan_summary */, + "analyzing_range_alternatives": { + "range_scan_alternatives": [ + { + "index": "PRIMARY", + "ranges": [ + "pk < 3" + ] /* ranges */, + "index_dives_for_eq_ranges": true, + "rowid_ordered": true, + "using_mrr": false, + "index_only": false, + "rows": 2, + "cost": 0.71, + "chosen": true + }, + { + "index": "i1_idx", + "ranges": [ + "1 <= i1 <= 1 AND pk < 3" + ] /* ranges */, + "index_dives_for_eq_ranges": true, + "rowid_ordered": true, + "using_mrr": false, + "index_only": false, + "rows": 1, + "cost": 0.61, + "chosen": true + }, + { + "index": "v_idx", + "chosen": false, + "cause": "no_valid_range_for_this_index" + } + ] /* range_scan_alternatives */, + "analyzing_roworder_intersect": { + "intersecting_indexes": [ + { + "index": "i1_idx", + "index_scan_cost": 0.25, + "cumulated_index_scan_cost": 0.25, + "disk_sweep_cost": 0.25, + "cumulated_total_cost": 0.5, + "usable": true, + "matching_rows_now": 1, + "isect_covering_with_this_index": false, + "chosen": true + } + ] /* intersecting_indexes */, + "clustered_pk": { + "index_scan_cost": 0.05, + "cumulated_index_scan_cost": 0.3, + "disk_sweep_cost": 0, + "clustered_pk_scan_added_to_intersect": true, + "cumulated_cost": 0.3 + } /* clustered_pk */, + "rows": 1, + "cost": 0.3, + "covering": false, + "chosen": true + } /* analyzing_roworder_intersect */ + } /* analyzing_range_alternatives */, + "chosen_range_access_summary": { + "range_access_plan": { + "type": "index_roworder_intersect", + "rows": 1, + "cost": 0.3, + "covering": false, + "clustered_pk_scan": true, + "intersect_of": [ + { + "type": "range_scan", + "index": "i1_idx", + "rows": 1, + "ranges": [ + "1 <= i1 <= 1 AND pk < 3" + ] /* ranges */ + } + ] /* intersect_of */ + } /* range_access_plan */, + "rows_for_plan": 1, + "cost_for_plan": 0.3, + "chosen": true + } /* chosen_range_access_summary */ + } /* range_analysis */ + } + ] /* rows_estimation */ + }, + { + "considered_execution_plans": [ + { + "plan_prefix": [ + ] /* plan_prefix */, + "table": "`t1`", + "best_access_path": { + "considered_access_paths": [ + { + "access_type": "ref", + "index": "i1_idx", + "chosen": false, + "cause": "range_uses_more_keyparts" + }, + { + "rows_to_scan": 1, + "filtering_effect": [ + ] /* filtering_effect */, + "final_filtering_effect": 1, + "access_type": "range", + "range_details": { + "used_index": "intersect(i1_idx,PRIMARY)" + } /* range_details */, + "resulting_rows": 1, + "cost": 0.4, + "chosen": true + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 100, + "rows_for_plan": 1, + "cost_for_plan": 0.4, + "chosen": true + } + ] /* considered_execution_plans */ + }, + { + "attaching_conditions_to_tables": { + "original_condition": "((`t1`.`i1` = 1) and (`t1`.`pk` < 3))", + "attached_conditions_computation": [ + ] /* attached_conditions_computation */, + "attached_conditions_summary": [ + { + "table": "`t1`", + "attached": "((`t1`.`i1` = 1) and (`t1`.`pk` < 3))" + } + ] /* attached_conditions_summary */ + } /* attaching_conditions_to_tables */ + }, + { + "finalizing_table_conditions": [ + { + "table": "`t1`", + "original_table_condition": "((`t1`.`i1` = 1) and (`t1`.`pk` < 3))", + "final_table_condition ": "((`t1`.`i1` = 1) and (`t1`.`pk` < 3))" + } + ] /* finalizing_table_conditions */ + }, + { + "refine_plan": [ + { + "table": "`t1`" + } + ] /* refine_plan */ + } + ] /* steps */ + } /* join_optimization */ + }, + { + "join_explain": { + "select#": 1, + "steps": [ + ] /* steps */ + } /* join_explain */ + } + ] /* steps */ +} 0 0 + +DROP TABLE t1; +CREATE TABLE t1 (a int, b int, PRIMARY KEY (a,b), KEY b (b)) ENGINE=InnoDB STATS_PERSISTENT=0; +INSERT INTO t1 VALUES (1,1),(1,2),(1,0),(1,3); + +# Test trace for unreliable_ref_cost_and_range_uses_more_keyparts to +# ignore ref access on index with overly optimistic cost-estimate +EXPLAIN SELECT MAX(b), a FROM t1 WHERE b < 2 AND a = 1 GROUP BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 25.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range PRIMARY,b b 4 NULL 2 25.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select max(`test`.`t1`.`b`) AS `MAX(b)`,`test`.`t1`.`a` AS `a` from `test`.`t1` where ((`test`.`t1`.`a` = 1) and (`test`.`t1`.`b` < 2)) group by `test`.`t1`.`a` + +SELECT * FROM information_schema.OPTIMIZER_TRACE; +QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES +EXPLAIN SELECT MAX(b), a FROM t1 WHERE b < 2 AND a = 1 GROUP BY a { + "steps": [ + { + "join_preparation": { + "select#": 1, + "steps": [ + { + "expanded_query": "/* select#1 */ select max(`t1`.`b`) AS `MAX(b)`,`t1`.`a` AS `a` from `t1` where ((`t1`.`b` < 2) and (`t1`.`a` = 1)) group by `t1`.`a`" + } + ] /* steps */ + } /* join_preparation */ + }, + { + "join_optimization": { + "select#": 1, + "steps": [ + { + "condition_processing": { + "condition": "WHERE", + "original_condition": "((`t1`.`b` < 2) and (`t1`.`a` = 1))", + "steps": [ + { + "transformation": "equality_propagation", + "resulting_condition": "((`t1`.`b` < 2) and multiple equal(1, `t1`.`a`))" + }, + { + "transformation": "constant_propagation", + "resulting_condition": "((`t1`.`b` < 2) and multiple equal(1, `t1`.`a`))" + }, + { + "transformation": "trivial_condition_removal", + "resulting_condition": "((`t1`.`b` < 2) and multiple equal(1, `t1`.`a`))" + } + ] /* steps */ + } /* condition_processing */ + }, + { + "substitute_generated_columns": { + } /* substitute_generated_columns */ + }, + { + "table_dependencies": [ + { + "table": "`t1`", + "row_may_be_null": false, + "map_bit": 0, + "depends_on_map_bits": [ + ] /* depends_on_map_bits */ + } + ] /* table_dependencies */ + }, + { + "ref_optimizer_key_uses": [ + { + "table": "`t1`", + "field": "a", + "equals": "1", + "null_rejecting": true + } + ] /* ref_optimizer_key_uses */ + }, + { + "rows_estimation": [ + { + "table": "`t1`", + "range_analysis": { + "table_scan": { + "rows": 4, + "cost": 2.75 + } /* table_scan */, + "potential_range_indexes": [ + { + "index": "PRIMARY", + "usable": true, + "key_parts": [ + "a", + "b" + ] /* key_parts */ + }, + { + "index": "b", + "usable": true, + "key_parts": [ + "b", + "a" + ] /* key_parts */ + } + ] /* potential_range_indexes */, + "best_covering_index_scan": { + "index": "b", + "cost": 0.651098, + "chosen": true + } /* best_covering_index_scan */, + "setup_range_conditions": [ + ] /* setup_range_conditions */, + "group_index_range": { + "potential_group_range_indexes": [ + { + "index": "PRIMARY", + "covering": true, + "index_dives_for_eq_ranges": true, + "ranges": [ + "1 <= a <= 1 AND b < 2" + ] /* ranges */, + "rows": 2, + "cost": 0.55 + }, + { + "index": "b", + "covering": true, + "usable": false, + "cause": "group_attribute_not_prefix_in_index" + } + ] /* potential_group_range_indexes */ + } /* group_index_range */, + "best_group_range_summary": { + "type": "index_group", + "index": "PRIMARY", + "group_attribute": "b", + "min_aggregate": false, + "max_aggregate": true, + "distinct_aggregate": false, + "rows": 2, + "cost": 0.55, + "key_parts_used_for_access": [ + "a" + ] /* key_parts_used_for_access */, + "ranges": [ + "1 <= a <= 1 AND b < 2" + ] /* ranges */, + "chosen": true + } /* best_group_range_summary */, + "skip_scan_range": { + "chosen": false, + "cause": "has_group_by" + } /* skip_scan_range */, + "analyzing_range_alternatives": { + "range_scan_alternatives": [ + { + "index": "PRIMARY", + "ranges": [ + "1 <= a <= 1 AND b < 2" + ] /* ranges */, + "index_dives_for_eq_ranges": true, + "rowid_ordered": true, + "using_mrr": false, + "index_only": true, + "rows": 2, + "cost": 0.71, + "chosen": false, + "cause": "cost" + }, + { + "index": "b", + "ranges": [ + "b < 2" + ] /* ranges */, + "index_dives_for_eq_ranges": true, + "rowid_ordered": false, + "using_mrr": false, + "index_only": true, + "rows": 2, + "cost": 0.460366, + "chosen": true + } + ] /* range_scan_alternatives */, + "analyzing_roworder_intersect": { + "usable": false, + "cause": "too_few_roworder_scans" + } /* analyzing_roworder_intersect */ + } /* analyzing_range_alternatives */, + "chosen_range_access_summary": { + "range_access_plan": { + "type": "range_scan", + "index": "b", + "rows": 2, + "ranges": [ + "b < 2" + ] /* ranges */ + } /* range_access_plan */, + "rows_for_plan": 2, + "cost_for_plan": 0.460366, + "chosen": true + } /* chosen_range_access_summary */ + } /* range_analysis */ + } + ] /* rows_estimation */ + }, + { + "considered_execution_plans": [ + { + "plan_prefix": [ + ] /* plan_prefix */, + "table": "`t1`", + "best_access_path": { + "considered_access_paths": [ + { + "access_type": "ref", + "index": "PRIMARY", + "chosen": false, + "cause": "range_uses_more_keyparts" + }, + { + "rows_to_scan": 2, + "filtering_effect": [ + ] /* filtering_effect */, + "final_filtering_effect": 0.25, + "access_type": "range", + "range_details": { + "used_index": "b" + } /* range_details */, + "resulting_rows": 0.5, + "cost": 0.660366, + "chosen": true, + "use_tmp_table": true + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 100, + "rows_for_plan": 0.5, + "cost_for_plan": 0.660366, + "sort_cost": 0.5, + "new_cost_for_plan": 1.16037, + "chosen": true + } + ] /* considered_execution_plans */ + }, + { + "attaching_conditions_to_tables": { + "original_condition": "((`t1`.`a` = 1) and (`t1`.`b` < 2))", + "attached_conditions_computation": [ + ] /* attached_conditions_computation */, + "attached_conditions_summary": [ + { + "table": "`t1`", + "attached": "((`t1`.`a` = 1) and (`t1`.`b` < 2))" + } + ] /* attached_conditions_summary */ + } /* attaching_conditions_to_tables */ + }, + { + "optimizing_distinct_group_by_order_by": { + "simplifying_group_by": { + "original_clause": "`t1`.`a`", + "items": [ + { + "item": "`t1`.`a`", + "equals_constant_in_where": true + } + ] /* items */, + "resulting_clause_is_simple": true, + "resulting_clause": "" + } /* simplifying_group_by */ + } /* optimizing_distinct_group_by_order_by */ + }, + { + "finalizing_table_conditions": [ + { + "table": "`t1`", + "original_table_condition": "((`t1`.`a` = 1) and (`t1`.`b` < 2))", + "final_table_condition ": "((`t1`.`a` = 1) and (`t1`.`b` < 2))" + } + ] /* finalizing_table_conditions */ + }, + { + "refine_plan": [ + { + "table": "`t1`" + } + ] /* refine_plan */ + } + ] /* steps */ + } /* join_optimization */ + }, + { + "make_parallel_query_plan": { + "select#": 1, + "detail": [ + { + "table": "`t1`", + "degree of parallel": 4 + } + ] /* detail */ + } /* make_parallel_query_plan */ + }, + { + "join_explain": { + "select#": 1, + "steps": [ + ] /* steps */ + } /* join_explain */ + } + ] /* steps */ +} 0 0 + +drop table t1; +# +# Tracing of when test_if_skip_sort_order() switches to another +# index and we abandon ICP, +# see "disabling_pushed_condition_on_old_index" in trace. +# +CREATE TABLE t1 ( +c1 VARCHAR(2) NOT NULL, +i1 INTEGER NOT NULL, +c2 VARCHAR(2) NOT NULL, +KEY k1 (c1), +KEY k2 (c1, i1) +) CHARSET utf8mb4; +INSERT INTO t1 VALUES ('0',3,'0'),('0',2,'1'); +EXPLAIN SELECT * FROM t1 WHERE c1 = '1' ORDER BY i1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ref k1,k2 k2 10 const 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c1` AS `c1`,`test`.`t1`.`i1` AS `i1`,`test`.`t1`.`c2` AS `c2` from `test`.`t1` where (`test`.`t1`.`c1` = '1') order by `test`.`t1`.`i1` +SELECT * FROM information_schema.OPTIMIZER_TRACE; +QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES +EXPLAIN SELECT * FROM t1 WHERE c1 = '1' ORDER BY i1 { + "steps": [ + { + "join_preparation": { + "select#": 1, + "steps": [ + { + "expanded_query": "/* select#1 */ select `t1`.`c1` AS `c1`,`t1`.`i1` AS `i1`,`t1`.`c2` AS `c2` from `t1` where (`t1`.`c1` = '1') order by `t1`.`i1`" + } + ] /* steps */ + } /* join_preparation */ + }, + { + "join_optimization": { + "select#": 1, + "steps": [ + { + "condition_processing": { + "condition": "WHERE", + "original_condition": "(`t1`.`c1` = '1')", + "steps": [ + { + "transformation": "equality_propagation", + "resulting_condition": "multiple equal('1', `t1`.`c1`)" + }, + { + "transformation": "constant_propagation", + "resulting_condition": "multiple equal('1', `t1`.`c1`)" + }, + { + "transformation": "trivial_condition_removal", + "resulting_condition": "multiple equal('1', `t1`.`c1`)" + } + ] /* steps */ + } /* condition_processing */ + }, + { + "substitute_generated_columns": { + } /* substitute_generated_columns */ + }, + { + "table_dependencies": [ + { + "table": "`t1`", + "row_may_be_null": false, + "map_bit": 0, + "depends_on_map_bits": [ + ] /* depends_on_map_bits */ + } + ] /* table_dependencies */ + }, + { + "ref_optimizer_key_uses": [ + { + "table": "`t1`", + "field": "c1", + "equals": "'1'", + "null_rejecting": true + }, + { + "table": "`t1`", + "field": "c1", + "equals": "'1'", + "null_rejecting": true + } + ] /* ref_optimizer_key_uses */ + }, + { + "rows_estimation": [ + { + "table": "`t1`", + "range_analysis": { + "table_scan": { + "rows": 2, + "cost": 2.80244 + } /* table_scan */, + "potential_range_indexes": [ + { + "index": "k1", + "usable": true, + "key_parts": [ + "c1" + ] /* key_parts */ + }, + { + "index": "k2", + "usable": true, + "key_parts": [ + "c1", + "i1" + ] /* key_parts */ + } + ] /* potential_range_indexes */, + "setup_range_conditions": [ + ] /* setup_range_conditions */, + "group_index_range": { + "chosen": false, + "cause": "not_group_by_or_distinct" + } /* group_index_range */, + "skip_scan_range": { + "potential_skip_scan_indexes": [ + { + "index": "k1", + "usable": false, + "cause": "query_references_nonkey_column" + }, + { + "index": "k2", + "usable": false, + "cause": "query_references_nonkey_column" + } + ] /* potential_skip_scan_indexes */ + } /* skip_scan_range */, + "analyzing_range_alternatives": { + "range_scan_alternatives": [ + { + "index": "k1", + "ranges": [ + "1 <= c1 <= 1" + ] /* ranges */, + "index_dives_for_eq_ranges": true, + "rowid_ordered": true, + "using_mrr": false, + "index_only": false, + "rows": 1, + "cost": 0.61, + "chosen": true + }, + { + "index": "k2", + "ranges": [ + "1 <= c1 <= 1" + ] /* ranges */, + "index_dives_for_eq_ranges": true, + "rowid_ordered": false, + "using_mrr": false, + "index_only": false, + "rows": 1, + "cost": 0.61, + "chosen": false, + "cause": "cost" + } + ] /* range_scan_alternatives */, + "analyzing_roworder_intersect": { + "usable": false, + "cause": "too_few_roworder_scans" + } /* analyzing_roworder_intersect */ + } /* analyzing_range_alternatives */, + "chosen_range_access_summary": { + "range_access_plan": { + "type": "range_scan", + "index": "k1", + "rows": 1, + "ranges": [ + "1 <= c1 <= 1" + ] /* ranges */ + } /* range_access_plan */, + "rows_for_plan": 1, + "cost_for_plan": 0.61, + "chosen": true + } /* chosen_range_access_summary */ + } /* range_analysis */ + } + ] /* rows_estimation */ + }, + { + "considered_execution_plans": [ + { + "plan_prefix": [ + ] /* plan_prefix */, + "table": "`t1`", + "best_access_path": { + "considered_access_paths": [ + { + "access_type": "ref", + "index": "k1", + "rows": 1, + "cost": 0.35, + "chosen": true + }, + { + "access_type": "ref", + "index": "k2", + "rows": 1, + "cost": 0.35, + "chosen": false + }, + { + "access_type": "range", + "range_details": { + "used_index": "k1" + } /* range_details */, + "chosen": false, + "cause": "heuristic_index_cheaper" + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 100, + "rows_for_plan": 1, + "cost_for_plan": 0.35, + "chosen": true + } + ] /* considered_execution_plans */ + }, + { + "attaching_conditions_to_tables": { + "original_condition": "(`t1`.`c1` = '1')", + "attached_conditions_computation": [ + ] /* attached_conditions_computation */, + "attached_conditions_summary": [ + { + "table": "`t1`", + "attached": "(`t1`.`c1` = '1')" + } + ] /* attached_conditions_summary */ + } /* attaching_conditions_to_tables */ + }, + { + "optimizing_distinct_group_by_order_by": { + "simplifying_order_by": { + "original_clause": "`t1`.`i1`", + "items": [ + { + "item": "`t1`.`i1`" + } + ] /* items */, + "resulting_clause_is_simple": true, + "resulting_clause": "`t1`.`i1`" + } /* simplifying_order_by */ + } /* optimizing_distinct_group_by_order_by */ + }, + { + "reconsidering_access_paths_for_index_ordering": { + "clause": "ORDER BY", + "steps": [ + { + "check_if_range_uses_more_keyparts_than_ref": { + "rerunning_range_optimizer_for_single_index": { + "range_analysis": { + "table_scan": { + "rows": 2, + "cost": 1.79769e+308 + } /* table_scan */, + "potential_range_indexes": [ + { + "index": "k1", + "usable": false, + "cause": "not_applicable" + }, + { + "index": "k2", + "usable": true, + "key_parts": [ + "c1", + "i1" + ] /* key_parts */ + } + ] /* potential_range_indexes */, + "setup_range_conditions": [ + ] /* setup_range_conditions */, + "group_index_range": { + "chosen": false, + "cause": "not_group_by_or_distinct" + } /* group_index_range */, + "skip_scan_range": { + "potential_skip_scan_indexes": [ + { + "index": "k2", + "usable": false, + "cause": "query_references_nonkey_column" + } + ] /* potential_skip_scan_indexes */ + } /* skip_scan_range */, + "analyzing_range_alternatives": { + "range_scan_alternatives": [ + { + "index": "k2", + "ranges": [ + "1 <= c1 <= 1" + ] /* ranges */, + "index_dives_for_eq_ranges": true, + "rowid_ordered": false, + "using_mrr": false, + "index_only": false, + "rows": 1, + "cost": 0.61, + "chosen": true + } + ] /* range_scan_alternatives */, + "analyzing_roworder_intersect": { + "usable": false, + "cause": "too_few_roworder_scans" + } /* analyzing_roworder_intersect */ + } /* analyzing_range_alternatives */, + "chosen_range_access_summary": { + "range_access_plan": { + "type": "range_scan", + "index": "k2", + "rows": 1, + "ranges": [ + "1 <= c1 <= 1" + ] /* ranges */ + } /* range_access_plan */, + "rows_for_plan": 1, + "cost_for_plan": 0.61, + "chosen": true + } /* chosen_range_access_summary */ + } /* range_analysis */, + "access_type_unchanged": { + "ref_key_length": 10, + "range_key_length": 10 + } /* access_type_unchanged */ + } /* rerunning_range_optimizer_for_single_index */ + } /* check_if_range_uses_more_keyparts_than_ref */ + } + ] /* steps */, + "index_order_summary": { + "table": "`t1`", + "index_provides_order": true, + "order_direction": "asc", + "index": "k2", + "plan_changed": true, + "access_type": "ref" + } /* index_order_summary */ + } /* reconsidering_access_paths_for_index_ordering */ + }, + { + "finalizing_table_conditions": [ + { + "table": "`t1`", + "original_table_condition": "(`t1`.`c1` = '1')", + "final_table_condition ": null + } + ] /* finalizing_table_conditions */ + }, + { + "refine_plan": [ + { + "table": "`t1`" + } + ] /* refine_plan */ + }, + { + "considering_tmp_tables": [ + ] /* considering_tmp_tables */ + } + ] /* steps */ + } /* join_optimization */ + }, + { + "join_explain": { + "select#": 1, + "steps": [ + ] /* steps */ + } /* join_explain */ + } + ] /* steps */ +} 0 0 +# +# Bug#30266767 OPTIMIZER TRACE CONTAINS INVALID JSON FOR FORCE INDEX QUERIES +# +SELECT JSON_TYPE(REGEXP_SUBSTR(TRACE, "1.*e[+]?308")) AS json_type +FROM information_schema.OPTIMIZER_TRACE; +json_type +DOUBLE +DROP TABLE t1; + +# BUG#18023222 OPTIMIZER TRACE ERROR ON RANGE ANALYSIS OF +# INDEX ON A BINARY COLUMN + +CREATE TABLE t(i INT PRIMARY KEY, b BINARY(16), INDEX i_b(b)); +INSERT INTO t VALUES (1, x'D95B94336A9946A39CF5B58CFE772D8C'); +INSERT INTO t VALUES (2, NULL); +EXPLAIN SELECT * FROM t WHERE b IN (0xD95B94336A9946A39CF5B58CFE772D8C); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL ref i_b i_b 17 const 1 100.00 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`i` AS `i`,`test`.`t`.`b` AS `b` from `test`.`t` where (`test`.`t`.`b` = 0xd95b94336a9946a39cf5b58cfe772d8c) +SELECT trace FROM information_schema.optimizer_trace; +trace +{ + "steps": [ + { + "join_preparation": { + "select#": 1, + "steps": [ + { + "expanded_query": "/* select#1 */ select `t`.`i` AS `i`,`t`.`b` AS `b` from `t` where (`t`.`b` = 0xd95b94336a9946a39cf5b58cfe772d8c)" + } + ] /* steps */ + } /* join_preparation */ + }, + { + "join_optimization": { + "select#": 1, + "steps": [ + { + "condition_processing": { + "condition": "WHERE", + "original_condition": "(`t`.`b` = 0xd95b94336a9946a39cf5b58cfe772d8c)", + "steps": [ + { + "transformation": "equality_propagation", + "resulting_condition": "multiple equal(0xd95b94336a9946a39cf5b58cfe772d8c, `t`.`b`)" + }, + { + "transformation": "constant_propagation", + "resulting_condition": "multiple equal(0xd95b94336a9946a39cf5b58cfe772d8c, `t`.`b`)" + }, + { + "transformation": "trivial_condition_removal", + "resulting_condition": "multiple equal(0xd95b94336a9946a39cf5b58cfe772d8c, `t`.`b`)" + } + ] /* steps */ + } /* condition_processing */ + }, + { + "substitute_generated_columns": { + } /* substitute_generated_columns */ + }, + { + "table_dependencies": [ + { + "table": "`t`", + "row_may_be_null": false, + "map_bit": 0, + "depends_on_map_bits": [ + ] /* depends_on_map_bits */ + } + ] /* table_dependencies */ + }, + { + "ref_optimizer_key_uses": [ + { + "table": "`t`", + "field": "b", + "equals": "0xd95b94336a9946a39cf5b58cfe772d8c", + "null_rejecting": true + } + ] /* ref_optimizer_key_uses */ + }, + { + "rows_estimation": [ + { + "table": "`t`", + "range_analysis": { + "table_scan": { + "rows": 2, + "cost": 2.80256 + } /* table_scan */, + "potential_range_indexes": [ + { + "index": "PRIMARY", + "usable": false, + "cause": "not_applicable" + }, + { + "index": "i_b", + "usable": true, + "key_parts": [ + "b" + ] /* key_parts */ + } + ] /* potential_range_indexes */, + "setup_range_conditions": [ + ] /* setup_range_conditions */, + "group_index_range": { + "chosen": false, + "cause": "not_group_by_or_distinct" + } /* group_index_range */, + "skip_scan_range": { + "potential_skip_scan_indexes": [ + { + "index": "i_b", + "usable": false, + "cause": "query_references_nonkey_column" + } + ] /* potential_skip_scan_indexes */ + } /* skip_scan_range */, + "analyzing_range_alternatives": { + "range_scan_alternatives": [ + { + "index": "i_b", + "ranges": [ + "0xd95b94336a9946a39cf5b58cfe772d8c <= b <= 0xd95b94336a9946a39cf5b58cfe772d8c" + ] /* ranges */, + "index_dives_for_eq_ranges": true, + "rowid_ordered": true, + "using_mrr": false, + "index_only": false, + "rows": 1, + "cost": 0.61, + "chosen": true + } + ] /* range_scan_alternatives */, + "analyzing_roworder_intersect": { + "usable": false, + "cause": "too_few_roworder_scans" + } /* analyzing_roworder_intersect */ + } /* analyzing_range_alternatives */, + "chosen_range_access_summary": { + "range_access_plan": { + "type": "range_scan", + "index": "i_b", + "rows": 1, + "ranges": [ + "0xd95b94336a9946a39cf5b58cfe772d8c <= b <= 0xd95b94336a9946a39cf5b58cfe772d8c" + ] /* ranges */ + } /* range_access_plan */, + "rows_for_plan": 1, + "cost_for_plan": 0.61, + "chosen": true + } /* chosen_range_access_summary */ + } /* range_analysis */ + } + ] /* rows_estimation */ + }, + { + "considered_execution_plans": [ + { + "plan_prefix": [ + ] /* plan_prefix */, + "table": "`t`", + "best_access_path": { + "considered_access_paths": [ + { + "access_type": "ref", + "index": "i_b", + "rows": 1, + "cost": 0.35, + "chosen": true + }, + { + "access_type": "range", + "range_details": { + "used_index": "i_b" + } /* range_details */, + "chosen": false, + "cause": "heuristic_index_cheaper" + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 100, + "rows_for_plan": 1, + "cost_for_plan": 0.35, + "chosen": true + } + ] /* considered_execution_plans */ + }, + { + "attaching_conditions_to_tables": { + "original_condition": "(`t`.`b` = 0xd95b94336a9946a39cf5b58cfe772d8c)", + "attached_conditions_computation": [ + ] /* attached_conditions_computation */, + "attached_conditions_summary": [ + { + "table": "`t`", + "attached": "(`t`.`b` = 0xd95b94336a9946a39cf5b58cfe772d8c)" + } + ] /* attached_conditions_summary */ + } /* attaching_conditions_to_tables */ + }, + { + "finalizing_table_conditions": [ + { + "table": "`t`", + "original_table_condition": "(`t`.`b` = 0xd95b94336a9946a39cf5b58cfe772d8c)", + "final_table_condition ": "(`t`.`b` = 0xd95b94336a9946a39cf5b58cfe772d8c)" + } + ] /* finalizing_table_conditions */ + }, + { + "refine_plan": [ + { + "table": "`t`", + "pushed_index_condition": "(`t`.`b` = 0xd95b94336a9946a39cf5b58cfe772d8c)", + "table_condition_attached": null + } + ] /* refine_plan */ + } + ] /* steps */ + } /* join_optimization */ + }, + { + "join_explain": { + "select#": 1, + "steps": [ + ] /* steps */ + } /* join_explain */ + } + ] /* steps */ +} +EXPLAIN SELECT * FROM t WHERE b IS NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL ref i_b i_b 17 const 1 100.00 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`i` AS `i`,`test`.`t`.`b` AS `b` from `test`.`t` where (`test`.`t`.`b` is null) +SELECT trace FROM information_schema.optimizer_trace; +trace +{ + "steps": [ + { + "join_preparation": { + "select#": 1, + "steps": [ + { + "expanded_query": "/* select#1 */ select `t`.`i` AS `i`,`t`.`b` AS `b` from `t` where (`t`.`b` is null)" + } + ] /* steps */ + } /* join_preparation */ + }, + { + "join_optimization": { + "select#": 1, + "steps": [ + { + "condition_processing": { + "condition": "WHERE", + "original_condition": "(`t`.`b` is null)", + "steps": [ + { + "transformation": "equality_propagation", + "resulting_condition": "(`t`.`b` is null)" + }, + { + "transformation": "constant_propagation", + "resulting_condition": "(`t`.`b` is null)" + }, + { + "transformation": "trivial_condition_removal", + "resulting_condition": "(`t`.`b` is null)" + } + ] /* steps */ + } /* condition_processing */ + }, + { + "substitute_generated_columns": { + } /* substitute_generated_columns */ + }, + { + "table_dependencies": [ + { + "table": "`t`", + "row_may_be_null": false, + "map_bit": 0, + "depends_on_map_bits": [ + ] /* depends_on_map_bits */ + } + ] /* table_dependencies */ + }, + { + "ref_optimizer_key_uses": [ + { + "table": "`t`", + "field": "b", + "equals": "NULL", + "null_rejecting": false + } + ] /* ref_optimizer_key_uses */ + }, + { + "rows_estimation": [ + { + "table": "`t`", + "range_analysis": { + "table_scan": { + "rows": 2, + "cost": 2.80256 + } /* table_scan */, + "potential_range_indexes": [ + { + "index": "PRIMARY", + "usable": false, + "cause": "not_applicable" + }, + { + "index": "i_b", + "usable": true, + "key_parts": [ + "b" + ] /* key_parts */ + } + ] /* potential_range_indexes */, + "setup_range_conditions": [ + ] /* setup_range_conditions */, + "group_index_range": { + "chosen": false, + "cause": "not_group_by_or_distinct" + } /* group_index_range */, + "skip_scan_range": { + "potential_skip_scan_indexes": [ + { + "index": "i_b", + "usable": false, + "cause": "query_references_nonkey_column" + } + ] /* potential_skip_scan_indexes */ + } /* skip_scan_range */, + "analyzing_range_alternatives": { + "range_scan_alternatives": [ + { + "index": "i_b", + "ranges": [ + "NULL <= b <= NULL" + ] /* ranges */, + "index_dives_for_eq_ranges": true, + "rowid_ordered": true, + "using_mrr": false, + "index_only": false, + "rows": 1, + "cost": 0.61, + "chosen": true + } + ] /* range_scan_alternatives */, + "analyzing_roworder_intersect": { + "usable": false, + "cause": "too_few_roworder_scans" + } /* analyzing_roworder_intersect */ + } /* analyzing_range_alternatives */, + "chosen_range_access_summary": { + "range_access_plan": { + "type": "range_scan", + "index": "i_b", + "rows": 1, + "ranges": [ + "NULL <= b <= NULL" + ] /* ranges */ + } /* range_access_plan */, + "rows_for_plan": 1, + "cost_for_plan": 0.61, + "chosen": true + } /* chosen_range_access_summary */ + } /* range_analysis */ + } + ] /* rows_estimation */ + }, + { + "considered_execution_plans": [ + { + "plan_prefix": [ + ] /* plan_prefix */, + "table": "`t`", + "best_access_path": { + "considered_access_paths": [ + { + "access_type": "ref", + "index": "i_b", + "rows": 1, + "cost": 0.35, + "chosen": true + }, + { + "access_type": "range", + "range_details": { + "used_index": "i_b" + } /* range_details */, + "chosen": false, + "cause": "heuristic_index_cheaper" + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 100, + "rows_for_plan": 1, + "cost_for_plan": 0.35, + "chosen": true + } + ] /* considered_execution_plans */ + }, + { + "attaching_conditions_to_tables": { + "original_condition": "(`t`.`b` is null)", + "attached_conditions_computation": [ + ] /* attached_conditions_computation */, + "attached_conditions_summary": [ + { + "table": "`t`", + "attached": "(`t`.`b` is null)" + } + ] /* attached_conditions_summary */ + } /* attaching_conditions_to_tables */ + }, + { + "finalizing_table_conditions": [ + { + "table": "`t`", + "original_table_condition": "(`t`.`b` is null)", + "final_table_condition ": "(`t`.`b` is null)" + } + ] /* finalizing_table_conditions */ + }, + { + "refine_plan": [ + { + "table": "`t`", + "pushed_index_condition": "(`t`.`b` is null)", + "table_condition_attached": null + } + ] /* refine_plan */ + } + ] /* steps */ + } /* join_optimization */ + }, + { + "join_explain": { + "select#": 1, + "steps": [ + ] /* steps */ + } /* join_explain */ + } + ] /* steps */ +} +drop table t; +# +# Test trace of geometry fields +# +CREATE TABLE t1( +pk INT AUTO_INCREMENT PRIMARY KEY, +col_geom GEOMETRY NOT NULL SRID 0 +) ENGINE=MyISAM; +INSERT INTO t1 VALUES (1, ST_GeomFromText('POINT(10 10)')); +INSERT INTO t1 VALUES (2, ST_GeomFromText('POINT(11 11)')); +CREATE SPATIAL INDEX idx3 on t1(col_geom); +# Show that geometry data is traced as "unprintable_geometry_value" +EXPLAIN +SELECT pk, ST_AsText(col_geom) +FROM t1 +WHERE MBREquals(t1.col_geom, ST_GeomFromText('POINT(12 13)')); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range idx3 idx3 34 NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,st_astext(`test`.`t1`.`col_geom`) AS `ST_AsText(col_geom)` from `test`.`t1` where mbrequals(`test`.`t1`.`col_geom`,(st_geomfromtext('POINT(12 13)'))) +SELECT show_json_object('"range_scan_alternatives": [', TRACE) +FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +show_json_object('"range_scan_alternatives": [', TRACE) +"range_scan_alternatives": [ + { + "index": "idx3", + "ranges": [ + "col_geom unprintable_geometry_value" + ] /* ranges */, + "index_dives_for_eq_ranges": true, + "rowid_ordered": false, + "using_mrr": false, + "index_only": false, + "rows": 1, + "cost": 0.61, + "chosen": true + } + ] +DROP TABLE t1; +DROP FUNCTION show_json_object; diff --git a/mysql-test/suite/rpl_invisible_indexes.result-pq b/mysql-test/suite/rpl_invisible_indexes.result-pq new file mode 100644 index 000000000000..fa7a037c2daf --- /dev/null +++ b/mysql-test/suite/rpl_invisible_indexes.result-pq @@ -0,0 +1,91 @@ +include/master-slave.inc +Warnings: +Note #### Sending passwords in plain text without SSL/TLS is extremely insecure. +Note #### Storing MySQL user name or password information in the master info repository is not secure and is therefore not recommended. Please consider using the USER and PASSWORD connection options for START SLAVE; see the 'START SLAVE Syntax' in the MySQL Manual for more information. +[connection master] +# Create a table with an index +CREATE TABLE t1 ( i INT , KEY (i)); +INSERT INTO t1 VALUES (2),(3),(5),(7),(11),(13); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +include/sync_slave_sql_with_master.inc +[Connection Slave] +# Check that the index is on the slave +SHOW INDEXES FROM t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible Expression +t1 1 i 1 i A 6 NULL NULL YES BTREE YES NULL +[Connection Master] +# Make the index invisible +ALTER TABLE t1 ALTER INDEX i INVISIBLE; +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +include/sync_slave_sql_with_master.inc +[Connection Slave] +# Verify that the index is invisible on the slave +SHOW INDEXES FROM t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible Expression +t1 1 i 1 i A 6 NULL NULL YES BTREE NO NULL +EXPLAIN SELECT * FROM t1 WHERE i=3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 6 16.67 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 6 16.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` where (`test`.`t1`.`i` = 3) +[Connection Master] +ALTER TABLE t1 ALTER INDEX i VISIBLE; +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +include/sync_slave_sql_with_master.inc +[Connection Slave] +# Verify that the index is visible on the slave +SHOW INDEXES FROM t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible Expression +t1 1 i 1 i A 6 NULL NULL YES BTREE YES NULL +EXPLAIN SELECT * FROM t1 WHERE i=3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref i i 5 const 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` where (`test`.`t1`.`i` = 3) +[Connection Master] +# Create an invisible index on the table +CREATE UNIQUE INDEX idx ON t1(i) INVISIBLE; +include/sync_slave_sql_with_master.inc +[Connection Slave] +# Verify that the invisible is created on the slave +SHOW INDEXES FROM t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible Expression +t1 0 idx 1 i A 6 NULL NULL YES BTREE NO NULL +t1 1 i 1 i A 6 NULL NULL YES BTREE YES NULL +[Connection Master] +ALTER TABLE t1 DROP INDEX i, ALTER INDEX idx VISIBLE, ALTER INDEX idx INVISIBLE, ALTER INDEX idx VISIBLE; +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +include/sync_slave_sql_with_master.inc +[Connection Slave] +SHOW INDEXES FROM t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible Expression +t1 0 idx 1 i A 6 NULL NULL YES BTREE YES NULL +[Connection Master] +# Alter the engine +ALTER TABLE t1 ALTER INDEX idx INVISIBLE, ALTER INDEX idx VISIBLE; +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +include/sync_slave_sql_with_master.inc +[Connection Slave] +SHOW INDEXES FROM t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible Expression +t1 0 idx 1 i A 6 NULL NULL YES BTREE YES NULL +[Connection Master] +# Clean up +DROP TABLE t1; +include/sync_slave_sql_with_master.inc +[Connection Slave] +SELECT * FROM t1; +ERROR 42S02: Table 'test.t1' doesn't exist +include/rpl_end.inc diff --git a/mysql-test/suite/security_no_prot.result-pq b/mysql-test/suite/security_no_prot.result-pq new file mode 100644 index 000000000000..09f6d3928432 --- /dev/null +++ b/mysql-test/suite/security_no_prot.result-pq @@ -0,0 +1,962 @@ +set @old_size = @@global.optimizer_trace_max_mem_size; +set global optimizer_trace_max_mem_size=1048576; +select user(); +user() +root@localhost +create database somedb; +use somedb; +create table t1(a varchar(100)); +insert into t1 values("first"); +create table t2(a varchar(100)); +insert into t2 values("first"); +create table t3(a varchar(100)); +insert into t3 values("first"); +SET sql_mode = 'ONLY_FULL_GROUP_BY,NO_ENGINE_SUBSTITUTION'; +create procedure p1() sql security definer +begin +declare b int; +if (select count(*) from t1) +then +select 22 into b from dual; +end if; +select a into b from t1 limit 1; +insert into t1 values(current_user()); +end| +create function f1() returns int sql security definer +begin +declare b int; +select 48 into b from dual; +select a into b from t1 limit 1; +insert into t1 values(current_user()); +return 36; +end| +create trigger trg2 before insert on t2 for each row +begin +insert into t3 select * from t3; +end| +SET sql_mode = default; +create sql security definer view v1 as select * from t1; +create user user1@localhost identified by ''; +grant all on *.* to user1@localhost with grant option; + +select user(); +user() +user1@localhost +set optimizer_trace="enabled=on"; +show grants; +Grants for user1@localhost +GRANT APPLICATION_PASSWORD_ADMIN,AUDIT_ADMIN,BACKUP_ADMIN,BINLOG_ADMIN,BINLOG_ENCRYPTION_ADMIN,CLONE_ADMIN,CONNECTION_ADMIN,ENCRYPTION_KEY_ADMIN,FLUSH_OPTIMIZER_COSTS,FLUSH_STATUS,FLUSH_TABLES,FLUSH_USER_RESOURCES,GROUP_REPLICATION_ADMIN,INNODB_REDO_LOG_ARCHIVE,INNODB_REDO_LOG_ENABLE,PERSIST_RO_VARIABLES_ADMIN,REPLICATION_APPLIER,REPLICATION_SLAVE_ADMIN,RESOURCE_GROUP_ADMIN,RESOURCE_GROUP_USER,ROLE_ADMIN,SERVICE_CONNECTION_ADMIN,SESSION_VARIABLES_ADMIN,SET_USER_ID,SHOW_ROUTINE,SYSTEM_USER,SYSTEM_VARIABLES_ADMIN,TABLE_ENCRYPTION_ADMIN,XA_RECOVER_ADMIN ON *.* TO `user1`@`localhost` WITH GRANT OPTION +GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, RELOAD, SHUTDOWN, PROCESS, FILE, REFERENCES, INDEX, ALTER, SHOW DATABASES, SUPER, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, REPLICATION SLAVE, REPLICATION CLIENT, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, CREATE USER, EVENT, TRIGGER, CREATE TABLESPACE, CREATE ROLE, DROP ROLE ON *.* TO `user1`@`localhost` WITH GRANT OPTION + +# ========================================================== +# Part A. +# Test that security context changes are allowed when, and only +# when, invoker has all global privileges. +# ========================================================== + +# Because invoker has all global privileges, all traces are visible: +set optimizer_trace_offset=0,optimizer_trace_limit=100; +call p1(); +select QUERY, length(TRACE), INSUFFICIENT_PRIVILEGES from information_schema.OPTIMIZER_TRACE; +QUERY length(TRACE) INSUFFICIENT_PRIVILEGES +call p1() 20 0 +set b@0 NULL 20 0 +jump_if_not 3(3) (select count(0) from `somedb`.`t1`) 3065 0 +select 22 into b from dual 407 0 +select a into b from t1 limit 1 2253 0 +insert into t1 values(current_user()) 20 0 +# this SET always purges all remembered traces +set optimizer_trace_offset=0,optimizer_trace_limit=100; +select f1(); +f1() +36 +select QUERY, length(TRACE), INSUFFICIENT_PRIVILEGES from information_schema.OPTIMIZER_TRACE; +QUERY length(TRACE) INSUFFICIENT_PRIVILEGES +select f1() 413 0 +set b@0 NULL 20 0 +select 48 into b from dual 407 0 +select a into b from t1 limit 1 2253 0 +insert into t1 values(current_user()) 20 0 +freturn 3 36 20 0 +set optimizer_trace_offset=0,optimizer_trace_limit=100; +select * from v1; +a +first +root@localhost +root@localhost +select QUERY, length(TRACE), INSUFFICIENT_PRIVILEGES from information_schema.OPTIMIZER_TRACE; +QUERY length(TRACE) INSUFFICIENT_PRIVILEGES +select * from v1 2920 0 +set optimizer_trace_offset=0,optimizer_trace_limit=100; +insert into t2 values(current_user()); +select QUERY, length(TRACE), INSUFFICIENT_PRIVILEGES from information_schema.OPTIMIZER_TRACE; +QUERY length(TRACE) INSUFFICIENT_PRIVILEGES +insert into t2 values(current_user()) 20 0 +insert into t3 select * from t3 3080 0 + +# Show that really all global privileges are needed: let root +# revoke just one from user1. Because user1 does not have all global +# privileges anymore, security context changes are forbidden, +# thus there is no trace. + +select user(); +user() +root@localhost +revoke shutdown on *.* from user1@localhost; + +select user(); +user() +user1@localhost +set optimizer_trace="enabled=on"; +show grants; +Grants for user1@localhost +GRANT APPLICATION_PASSWORD_ADMIN,AUDIT_ADMIN,BACKUP_ADMIN,BINLOG_ADMIN,BINLOG_ENCRYPTION_ADMIN,CLONE_ADMIN,CONNECTION_ADMIN,ENCRYPTION_KEY_ADMIN,FLUSH_OPTIMIZER_COSTS,FLUSH_STATUS,FLUSH_TABLES,FLUSH_USER_RESOURCES,GROUP_REPLICATION_ADMIN,INNODB_REDO_LOG_ARCHIVE,INNODB_REDO_LOG_ENABLE,PERSIST_RO_VARIABLES_ADMIN,REPLICATION_APPLIER,REPLICATION_SLAVE_ADMIN,RESOURCE_GROUP_ADMIN,RESOURCE_GROUP_USER,ROLE_ADMIN,SERVICE_CONNECTION_ADMIN,SESSION_VARIABLES_ADMIN,SET_USER_ID,SHOW_ROUTINE,SYSTEM_USER,SYSTEM_VARIABLES_ADMIN,TABLE_ENCRYPTION_ADMIN,XA_RECOVER_ADMIN ON *.* TO `user1`@`localhost` WITH GRANT OPTION +GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, RELOAD, PROCESS, FILE, REFERENCES, INDEX, ALTER, SHOW DATABASES, SUPER, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, REPLICATION SLAVE, REPLICATION CLIENT, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, CREATE USER, EVENT, TRIGGER, CREATE TABLESPACE, CREATE ROLE, DROP ROLE ON *.* TO `user1`@`localhost` WITH GRANT OPTION +set optimizer_trace_offset=0,optimizer_trace_limit=100; +call p1(); +# In CALL we execute stored procedure and notice a security +# context change. The context change is probably only relevant +# for substatements, but we still hide CALL. This is to be +# consistent with what we do when routine body should not be +# exposed. And it also feels safer to disable I_S output as +# soon as possible. +# Ps-protocol-specific note: mysqltest uses normal protocol for CALL +select QUERY, length(TRACE), INSUFFICIENT_PRIVILEGES from information_schema.OPTIMIZER_TRACE; +QUERY length(TRACE) INSUFFICIENT_PRIVILEGES + 0 1 +set optimizer_trace_offset=0,optimizer_trace_limit=100; +select f1(); +f1() +36 +select QUERY, TRACE, INSUFFICIENT_PRIVILEGES from information_schema.OPTIMIZER_TRACE; +QUERY TRACE INSUFFICIENT_PRIVILEGES + 1 +set optimizer_trace_offset=0,optimizer_trace_limit=100; +select * from v1; +a +first +root@localhost +root@localhost +root@localhost +root@localhost +select QUERY, length(TRACE), INSUFFICIENT_PRIVILEGES from information_schema.OPTIMIZER_TRACE; +QUERY length(TRACE) INSUFFICIENT_PRIVILEGES + 0 1 +set optimizer_trace_offset=0,optimizer_trace_limit=100; +insert into t2 values(current_user()); +select QUERY, TRACE, INSUFFICIENT_PRIVILEGES from information_schema.OPTIMIZER_TRACE; +QUERY TRACE INSUFFICIENT_PRIVILEGES + 1 + +# Verify that user1 cannot circumvent security checks by +# setting @@optimizer_trace_offset so that I_S output is disabled +# before the object (routine) is checked, and enabled in the +# middle of object usage, when 'offset' is passed. + +set optimizer_trace_offset=2,optimizer_trace_limit=1; +call p1(); +# Even though the routine's execution started before +# 'offset', it detected the security context changes. So the +# trace of CALL gets the "missing privilege" mark but we don't +# see it as CALL was before 'offset'. +select QUERY, TRACE, INSUFFICIENT_PRIVILEGES from information_schema.OPTIMIZER_TRACE; +QUERY TRACE INSUFFICIENT_PRIVILEGES + +# Finally, verify that if the routine's definer does modify +# @@optimizer_trace from "enabled=off" to "enabled=on", in the +# body of the routine, then tracing works. This is no security +# issue, as it was done by the routine's definer. + +select user(); +user() +root@localhost +create procedure p2() sql security definer +begin +declare b int; +set optimizer_trace="enabled=on"; +select 22 into b from dual; +end| + +select user(); +user() +user1@localhost +set optimizer_trace="enabled=off"; +set optimizer_trace_offset=0,optimizer_trace_limit=100; +call p2(); +select QUERY, TRACE, INSUFFICIENT_PRIVILEGES from information_schema.OPTIMIZER_TRACE; +QUERY TRACE INSUFFICIENT_PRIVILEGES +select 22 into b from dual { + "steps": [ + { + "join_preparation": { + "select#": 1, + "steps": [ + { + "expanded_query": "/* select#1 */ select 22 AS `22`" + } + ] + } + }, + { + "join_optimization": { + "select#": 1, + "steps": [ + ] + } + }, + { + "join_execution": { + "select#": 1, + "steps": [ + ] + } + } + ] +} 0 +# Variable is as set by the routine +select @@optimizer_trace; +@@optimizer_trace +enabled=on,one_line=off + +# ========================================================== +# Part B. +# Do same tests but with SQL SECURITY INVOKER objects, to verify that +# the restriction on security context changes is not present. +# ========================================================== + +select user(); +user() +root@localhost +alter procedure p1 sql security invoker; +alter function f1 sql security invoker; +alter sql security invoker view v1 as select * from t1; +# Triggers cannot be SQL SECURITY INVOKER so we don't test +# them here. +alter procedure p2 sql security invoker; +delete from t1 where a<>"first"; + +select user(); +user() +user1@localhost +set optimizer_trace_offset=0,optimizer_trace_limit=100; +call p1(); +select QUERY, length(TRACE), INSUFFICIENT_PRIVILEGES from information_schema.OPTIMIZER_TRACE; +QUERY length(TRACE) INSUFFICIENT_PRIVILEGES +call p1() 20 0 +set b@0 NULL 20 0 +jump_if_not 3(3) (select count(0) from `somedb`.`t1`) 3065 0 +select 22 into b from dual 407 0 +select a into b from t1 limit 1 2253 0 +insert into t1 values(current_user()) 20 0 +set optimizer_trace_offset=0,optimizer_trace_limit=100; +select f1(); +f1() +36 +select QUERY, length(TRACE), INSUFFICIENT_PRIVILEGES from information_schema.OPTIMIZER_TRACE; +QUERY length(TRACE) INSUFFICIENT_PRIVILEGES +select f1() 413 0 +set b@0 NULL 20 0 +select 48 into b from dual 407 0 +select a into b from t1 limit 1 2253 0 +insert into t1 values(current_user()) 20 0 +freturn 3 36 20 0 +set optimizer_trace_offset=0,optimizer_trace_limit=100; +select * from v1; +a +first +user1@localhost +user1@localhost +select QUERY, length(TRACE), INSUFFICIENT_PRIVILEGES from information_schema.OPTIMIZER_TRACE; +QUERY length(TRACE) INSUFFICIENT_PRIVILEGES +select * from v1 2920 0 +set optimizer_trace_offset=2,optimizer_trace_limit=1; +call p1(); +select QUERY, length(TRACE), INSUFFICIENT_PRIVILEGES from information_schema.OPTIMIZER_TRACE; +QUERY length(TRACE) INSUFFICIENT_PRIVILEGES +jump_if_not 3(3) (select count(0) from `somedb`.`t1`) 2868 0 +set optimizer_trace="enabled=off"; +set optimizer_trace_offset=0,optimizer_trace_limit=100; +call p2(); +# SELECT substatement is traced (no security context change) +select QUERY, TRACE, INSUFFICIENT_PRIVILEGES from information_schema.OPTIMIZER_TRACE; +QUERY TRACE INSUFFICIENT_PRIVILEGES +select 22 into b from dual { + "steps": [ + { + "join_preparation": { + "select#": 1, + "steps": [ + { + "expanded_query": "/* select#1 */ select 22 AS `22`" + } + ] + } + }, + { + "join_optimization": { + "select#": 1, + "steps": [ + ] + } + }, + { + "join_execution": { + "select#": 1, + "steps": [ + ] + } + } + ] +} 0 +select @@optimizer_trace; +@@optimizer_trace +enabled=on,one_line=off + +# ========================================================== +# Part C. +# User1 got traces. Determine the minimum set of privileges he +# needed for that. +# ========================================================== + +drop procedure p2; +select user(); +user() +root@localhost +revoke all privileges, grant option from user1@localhost; +# Grant minimum privileges to use the routines and views, +# without considering optimizer trace: +grant execute on procedure p1 to user1@localhost; +grant execute on function f1 to user1@localhost; +grant select (a) on v1 to user1@localhost; +# Objects above are SQL SECURITY INVOKER, so invoker needs +# privileges on objects used internally: +grant select (a) on t1 to user1@localhost; +grant insert (a) on t1 to user1@localhost; +delete from t1 where a<>"first"; + +select user(); +user() +user1@localhost +set optimizer_trace="enabled=on"; +show grants; +Grants for user1@localhost +GRANT EXECUTE ON FUNCTION `somedb`.`f1` TO `user1`@`localhost` +GRANT EXECUTE ON PROCEDURE `somedb`.`p1` TO `user1`@`localhost` +GRANT SELECT (`a`) ON `somedb`.`v1` TO `user1`@`localhost` +GRANT SELECT (`a`), INSERT (`a`) ON `somedb`.`t1` TO `user1`@`localhost` +GRANT USAGE ON *.* TO `user1`@`localhost` + +# Those privileges are not enough to see traces: +set optimizer_trace_offset=0,optimizer_trace_limit=100; +call p1(); +# In CALL we execute stored procedure and notice that body should +# not be exposed. The trace of this CALL would not expose the +# body. Trace of substatements would. But, due to +# implementation, CALL is hidden. +select QUERY, length(TRACE), INSUFFICIENT_PRIVILEGES from information_schema.OPTIMIZER_TRACE; +QUERY length(TRACE) INSUFFICIENT_PRIVILEGES + 0 1 +set optimizer_trace_offset=0,optimizer_trace_limit=100; +select f1(); +f1() +36 +# SELECT is hidden (same reason as for CALL). +# Ps-protocol-specific note: preparation of SELECT above does not +# execute f1, so does not risk exposing body, so its trace is +# visible. +select QUERY, TRACE, INSUFFICIENT_PRIVILEGES from information_schema.OPTIMIZER_TRACE; +QUERY TRACE INSUFFICIENT_PRIVILEGES + 1 +set optimizer_trace_offset=0,optimizer_trace_limit=100; +select * from v1; +a +first +user1@localhost +user1@localhost +# Cannot see anything as it would expose body of view +select QUERY, length(TRACE), INSUFFICIENT_PRIVILEGES from information_schema.OPTIMIZER_TRACE; +QUERY length(TRACE) INSUFFICIENT_PRIVILEGES + 0 1 + +# C.0) Add more privileges: + +select user(); +user() +root@localhost +# - for use of t1 in routines and view: +grant select on t1 to user1@localhost; +# - for use of view: +grant select, show view on v1 to user1@localhost; +delete from t1 where a<>"first"; + +select user(); +user() +user1@localhost +set optimizer_trace_offset=0,optimizer_trace_limit=100; +call p1(); +select QUERY, length(TRACE), INSUFFICIENT_PRIVILEGES from information_schema.OPTIMIZER_TRACE; +QUERY length(TRACE) INSUFFICIENT_PRIVILEGES + 0 1 +# Trace exposed body of routine, and content of t1, which we +# could see anyway: +show create procedure p1; +Procedure sql_mode Create Procedure character_set_client collation_connection Database Collation +p1 ONLY_FULL_GROUP_BY,NO_ENGINE_SUBSTITUTION NULL utf8mb4 utf8mb4_0900_ai_ci utf8mb4_0900_ai_ci +select * from t1 limit 1; +a +first +set optimizer_trace_offset=0,optimizer_trace_limit=100; +select f1(); +f1() +36 +select QUERY, length(TRACE), INSUFFICIENT_PRIVILEGES from information_schema.OPTIMIZER_TRACE; +QUERY length(TRACE) INSUFFICIENT_PRIVILEGES + 0 1 +# Trace exposed body of routine, and content of t1, which we +# could see anyway: +show create function f1; +Function sql_mode Create Function character_set_client collation_connection Database Collation +f1 ONLY_FULL_GROUP_BY,NO_ENGINE_SUBSTITUTION NULL utf8mb4 utf8mb4_0900_ai_ci utf8mb4_0900_ai_ci +set optimizer_trace_offset=0,optimizer_trace_limit=100; +select * from v1; +a +first +user1@localhost +user1@localhost +select QUERY, length(TRACE), INSUFFICIENT_PRIVILEGES from information_schema.OPTIMIZER_TRACE; +QUERY length(TRACE) INSUFFICIENT_PRIVILEGES +select * from v1 2920 0 +# Trace exposed body of view, and content of t1, which we +# could see anyway: +show create view v1; +View Create View character_set_client collation_connection +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY INVOKER VIEW `v1` AS select `t1`.`a` AS `a` from `t1` utf8mb4 utf8mb4_0900_ai_ci + +# Now remove each privilege to verify that it was needed: +# C.1) remove table-level SELECT privilege on t1 + +select user(); +user() +root@localhost +revoke select on t1 from user1@localhost; +grant select (a) on t1 to user1@localhost; +delete from t1 where a<>"first"; + +select user(); +user() +user1@localhost +set optimizer_trace_offset=0,optimizer_trace_limit=100; +call p1(); +# Cannot see those substatements which use t1 +select QUERY, TRACE, INSUFFICIENT_PRIVILEGES from information_schema.OPTIMIZER_TRACE; +QUERY TRACE INSUFFICIENT_PRIVILEGES + 1 +set optimizer_trace_offset=0,optimizer_trace_limit=100; +select f1(); +f1() +36 +# Cannot see those substatements which use t1 +select QUERY, length(TRACE), INSUFFICIENT_PRIVILEGES from information_schema.OPTIMIZER_TRACE; +QUERY length(TRACE) INSUFFICIENT_PRIVILEGES + 0 1 +# Trace exposed body of routine, which we could see anyway: +set optimizer_trace="enabled=off"; +show create function f1; +Function sql_mode Create Function character_set_client collation_connection Database Collation +f1 ONLY_FULL_GROUP_BY,NO_ENGINE_SUBSTITUTION NULL utf8mb4 utf8mb4_0900_ai_ci utf8mb4_0900_ai_ci +set optimizer_trace="enabled=on"; +set optimizer_trace_offset=0,optimizer_trace_limit=100; +select * from v1; +a +first +user1@localhost +user1@localhost +# Cannot see anything as it might expose some data from columns +# of t1 +select QUERY, length(TRACE), INSUFFICIENT_PRIVILEGES from information_schema.OPTIMIZER_TRACE; +QUERY length(TRACE) INSUFFICIENT_PRIVILEGES + 0 1 + +# C.2) remove table-level SELECT privilege on view + +select user(); +user() +root@localhost +# Put back privilege removed in C.1 +grant select on t1 to user1@localhost; +# And remove a next one: +revoke select on v1 from user1@localhost; +grant select (a) on v1 to user1@localhost; +delete from t1 where a<>"first"; + +select user(); +user() +user1@localhost +set optimizer_trace_offset=0,optimizer_trace_limit=100; +select * from v1; +a +first +# Cannot see anything as it might expose some data from columns +# of v1 +select QUERY, length(TRACE), INSUFFICIENT_PRIVILEGES from information_schema.OPTIMIZER_TRACE; +QUERY length(TRACE) INSUFFICIENT_PRIVILEGES + 0 1 + +# C.3) remove SHOW VIEW privilege on view + +select user(); +user() +root@localhost +# Put back privilege removed in C.3 +grant select on v1 to user1@localhost; +# And remove a next one: +revoke show view on v1 from user1@localhost; +delete from t1 where a<>"first"; + +select user(); +user() +user1@localhost +set optimizer_trace="enabled=off"; +# We have no right to see view's body: +show create view v1; +ERROR 42000: SHOW VIEW command denied to user 'user1'@'localhost' for table 'v1' +set optimizer_trace="enabled=on"; +# Verify that optimizer trace does not influence the privilege +# checking in SHOW CREATE: +show create view v1; +ERROR 42000: SHOW VIEW command denied to user 'user1'@'localhost' for table 'v1' +set optimizer_trace_offset=0,optimizer_trace_limit=100; +select * from v1; +a +first +# Cannot see anything as it would expose body of view +select QUERY, TRACE, INSUFFICIENT_PRIVILEGES from information_schema.OPTIMIZER_TRACE; +QUERY TRACE INSUFFICIENT_PRIVILEGES + 1 + +# ========================================================== +# Part D. +# Like Part C, but instead of SQL SECURITY INVOKER objects +# created by root and used by User1, let's have SQL SECURITY +# DEFINER objects created and used by User1. Determine the +# minimum set of privileges he needs for that. +# ========================================================== + +select user(); +user() +root@localhost +drop procedure p1; +drop function f1; +drop view v1; +drop trigger trg2; +revoke all privileges, grant option from user1@localhost; +# Grant minimum privileges to create and use objects, +# without considering optimizer trace: +grant create routine on somedb.* to user1@localhost; +grant trigger on t2 to user1@localhost; +grant create view on somedb.* to user1@localhost; +grant select (a) on t1 to user1@localhost; +grant insert (a) on t1 to user1@localhost; +grant insert (a) on t2 to user1@localhost; +grant select (a) on t3 to user1@localhost; +grant insert (a) on t3 to user1@localhost; +delete from t1 where a<>"first"; + +select user(); +user() +user1@localhost +set optimizer_trace="enabled=on"; +SET sql_mode = 'ONLY_FULL_GROUP_BY,NO_ENGINE_SUBSTITUTION'; +create procedure p1() sql security definer +begin +declare b int; +if (select count(*) from t1) +then +select 22 into b from dual; +end if; +select a into b from t1 limit 1; +insert into t1 values(current_user()); +end| +create function f1() returns int sql security definer +begin +declare b int; +select 48 into b from dual; +select a into b from t1 limit 1; +insert into t1 values(current_user()); +return 36; +end| +create trigger trg2 before insert on t2 for each row +begin +insert into t3 select * from t3; +end| +create sql security definer view v1 as select * from t1; +SET sql_mode = default; +# Creating a view is not enough to be able to SELECT it... +select user(); +user() +root@localhost +grant select (a) on v1 to user1@localhost; + +select user(); +user() +user1@localhost +# Those privileges are not enough to see traces: +set optimizer_trace_offset=0,optimizer_trace_limit=100; +call p1(); +# Can see body of routine (as definer), but not statements using t1 +select QUERY, length(TRACE), INSUFFICIENT_PRIVILEGES from information_schema.OPTIMIZER_TRACE; +QUERY length(TRACE) INSUFFICIENT_PRIVILEGES +call p1() 20 0 +set b@0 NULL 20 0 + 0 1 +select 22 into b from dual 407 0 + 0 1 + 0 1 +set optimizer_trace_offset=0,optimizer_trace_limit=100; +select f1(); +f1() +36 +# Can see body of routine (as definer), but not statements using t1 +select QUERY, length(TRACE), INSUFFICIENT_PRIVILEGES from information_schema.OPTIMIZER_TRACE; +QUERY length(TRACE) INSUFFICIENT_PRIVILEGES +select f1() 413 0 +set b@0 NULL 20 0 +select 48 into b from dual 407 0 + 0 1 + 0 1 +freturn 3 36 20 0 +show create function f1; +Function sql_mode Create Function character_set_client collation_connection Database Collation +f1 ONLY_FULL_GROUP_BY,NO_ENGINE_SUBSTITUTION CREATE DEFINER=`user1`@`localhost` FUNCTION `f1`() RETURNS int +begin +declare b int; +select 48 into b from dual; +select a into b from t1 limit 1; +insert into t1 values(current_user()); +return 36; +end utf8mb4 utf8mb4_0900_ai_ci utf8mb4_0900_ai_ci +set optimizer_trace_offset=0,optimizer_trace_limit=100; +select * from v1; +a +first +user1@localhost +user1@localhost +# Cannot see anything as it might expose some data from columns +# of t1 +select QUERY, length(TRACE), INSUFFICIENT_PRIVILEGES from information_schema.OPTIMIZER_TRACE; +QUERY length(TRACE) INSUFFICIENT_PRIVILEGES + 0 1 +set optimizer_trace_offset=0,optimizer_trace_limit=100; +insert into t2 values(current_user()); +# Cannot see anything as it might expose some data from +# columns of t2 +select QUERY, length(TRACE), INSUFFICIENT_PRIVILEGES from information_schema.OPTIMIZER_TRACE; +QUERY length(TRACE) INSUFFICIENT_PRIVILEGES + 0 1 +# Also test a query accessing t1 in FROM clause: +set optimizer_trace_offset=0,optimizer_trace_limit=100; +select a from (select a from t1 where a like "f%") as tt where a like "fi%"; +a +first +select QUERY, length(TRACE), INSUFFICIENT_PRIVILEGES from information_schema.OPTIMIZER_TRACE; +QUERY length(TRACE) INSUFFICIENT_PRIVILEGES + 0 1 + +# D.0) Add more privileges: + +select user(); +user() +root@localhost +# - for use of t1 in routines and view: +grant select on t1 to user1@localhost; +# - for use of view: +grant select, show view on v1 to user1@localhost; +# - for use of trigger +grant select on t2 to user1@localhost; +grant select on t3 to user1@localhost; +delete from t1 where a<>"first"; + +select user(); +user() +user1@localhost +set optimizer_trace_offset=0,optimizer_trace_limit=100; +call p1(); +select QUERY, length(TRACE), INSUFFICIENT_PRIVILEGES from information_schema.OPTIMIZER_TRACE; +QUERY length(TRACE) INSUFFICIENT_PRIVILEGES +call p1() 20 0 +set b@0 NULL 20 0 +jump_if_not 3(3) (select count(0) from `somedb`.`t1`) 2868 0 +select 22 into b from dual 218 0 +select a into b from t1 limit 1 2041 0 +insert into t1 values(current_user()) 20 0 +# Trace exposed body of routine, and content of t1, which we +# could see anyway: +show create procedure p1; +Procedure sql_mode Create Procedure character_set_client collation_connection Database Collation +p1 ONLY_FULL_GROUP_BY,NO_ENGINE_SUBSTITUTION CREATE DEFINER=`user1`@`localhost` PROCEDURE `p1`() +begin +declare b int; +if (select count(*) from t1) +then +select 22 into b from dual; +end if; +select a into b from t1 limit 1; +insert into t1 values(current_user()); +end utf8mb4 utf8mb4_0900_ai_ci utf8mb4_0900_ai_ci +select * from t1 limit 1; +a +first +set optimizer_trace_offset=0,optimizer_trace_limit=100; +select f1(); +f1() +36 +select QUERY, length(TRACE), INSUFFICIENT_PRIVILEGES from information_schema.OPTIMIZER_TRACE; +QUERY length(TRACE) INSUFFICIENT_PRIVILEGES +select f1() 413 0 +set b@0 NULL 20 0 +select 48 into b from dual 218 0 +select a into b from t1 limit 1 2041 0 +insert into t1 values(current_user()) 20 0 +freturn 3 36 20 0 +# Trace exposed body of routine, and content of t1, which we +# could see anyway: +show create function f1; +Function sql_mode Create Function character_set_client collation_connection Database Collation +f1 ONLY_FULL_GROUP_BY,NO_ENGINE_SUBSTITUTION CREATE DEFINER=`user1`@`localhost` FUNCTION `f1`() RETURNS int +begin +declare b int; +select 48 into b from dual; +select a into b from t1 limit 1; +insert into t1 values(current_user()); +return 36; +end utf8mb4 utf8mb4_0900_ai_ci utf8mb4_0900_ai_ci +set optimizer_trace_offset=0,optimizer_trace_limit=100; +select * from v1; +a +first +user1@localhost +user1@localhost +select QUERY, length(TRACE), INSUFFICIENT_PRIVILEGES from information_schema.OPTIMIZER_TRACE; +QUERY length(TRACE) INSUFFICIENT_PRIVILEGES +select * from v1 2920 0 +# Trace exposed body of view, and content of t1, which we +# could see anyway: +show create view v1; +View Create View character_set_client collation_connection +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`user1`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`a` AS `a` from `t1` utf8mb4 utf8mb4_0900_ai_ci +set optimizer_trace_offset=0,optimizer_trace_limit=100; +insert into t2 values(current_user()); +select QUERY, length(TRACE), INSUFFICIENT_PRIVILEGES from information_schema.OPTIMIZER_TRACE; +QUERY length(TRACE) INSUFFICIENT_PRIVILEGES +insert into t2 values(current_user()) 20 0 +insert into t3 select * from t3 2841 0 +# Trace exposed body of trigger, and content of t2/t3, which we +# could see anyway: +show create trigger trg2; +Trigger sql_mode SQL Original Statement character_set_client collation_connection Database Collation Created +trg2 ONLY_FULL_GROUP_BY,NO_ENGINE_SUBSTITUTION CREATE DEFINER=`user1`@`localhost` TRIGGER `trg2` BEFORE INSERT ON `t2` FOR EACH ROW begin +insert into t3 select * from t3; +end utf8mb4 utf8mb4_0900_ai_ci utf8mb4_0900_ai_ci # +select * from t2, t3 order by t2.a, t3.a limit 1; +a a +first first +# Trace exposed content of t1 which we could see anyway: +set optimizer_trace_offset=0,optimizer_trace_limit=100; +select a from (select a from t1 where a like "f%") as tt where a like "fi%"; +a +first +select QUERY, length(TRACE), INSUFFICIENT_PRIVILEGES from information_schema.OPTIMIZER_TRACE; +QUERY length(TRACE) INSUFFICIENT_PRIVILEGES +select a from (select a from t1 where a like "f%") as tt where a like "fi%" 4649 0 + +# For routines, as they only use t1 and we added only one +# privilege on t1, we have nothing to remove. + +# Now remove each privilege to verify that it was needed for +# the view. +# D.1) remove table-level SELECT privilege on v1 + +select user(); +user() +root@localhost +revoke select on v1 from user1@localhost; +grant select (a) on v1 to user1@localhost; + +select user(); +user() +user1@localhost +set optimizer_trace_offset=0,optimizer_trace_limit=100; +select * from v1; +a +first +user1@localhost +user1@localhost +# Cannot see anything as it might expose some data from columns +# of v1 +select QUERY, length(TRACE), INSUFFICIENT_PRIVILEGES from information_schema.OPTIMIZER_TRACE; +QUERY length(TRACE) INSUFFICIENT_PRIVILEGES + 0 1 + +# D.2) remove table-level SHOW VIEW privilege on v1 + +select user(); +user() +root@localhost +# Put back privilege removed in D.1 +grant select on v1 to user1@localhost; +# And remove a next one: +revoke show view on v1 from user1@localhost; + +select user(); +user() +user1@localhost +# We have no right to see view's body: +show create view v1; +ERROR 42000: SHOW VIEW command denied to user 'user1'@'localhost' for table 'v1' +set optimizer_trace_offset=0,optimizer_trace_limit=100; +select * from v1; +a +first +user1@localhost +user1@localhost +# Cannot see anything as it would expose body of view +select QUERY, TRACE, INSUFFICIENT_PRIVILEGES from information_schema.OPTIMIZER_TRACE; +QUERY TRACE INSUFFICIENT_PRIVILEGES + 1 + +# D.3) remove table-level SELECT privilege on t1 + +select user(); +user() +root@localhost +# Put back privilege removed in D.2 +grant show view on v1 to user1@localhost; +# And remove a next one: +revoke select on t1 from user1@localhost; +grant select (a) on t1 to user1@localhost; + +select user(); +user() +user1@localhost +set optimizer_trace_offset=0,optimizer_trace_limit=100; +select * from v1; +a +first +user1@localhost +user1@localhost +# Cannot see anything as it might expose some data from columns +# of t1 +select QUERY, length(TRACE), INSUFFICIENT_PRIVILEGES from information_schema.OPTIMIZER_TRACE; +QUERY length(TRACE) INSUFFICIENT_PRIVILEGES + 0 1 + +# Now remove each privilege to verify that it was needed for +# the trigger: +# D.4) remove table-level SELECT privilege on t2 + +select user(); +user() +root@localhost +revoke select on t2 from user1@localhost; +grant select (a) on t2 to user1@localhost; + +select user(); +user() +user1@localhost +set optimizer_trace_offset=0,optimizer_trace_limit=100; +insert into t2 values(current_user()); +# Cannot see anything as it might expose some data from +# columns of t2 +select QUERY, length(TRACE), INSUFFICIENT_PRIVILEGES from information_schema.OPTIMIZER_TRACE; +QUERY length(TRACE) INSUFFICIENT_PRIVILEGES + 0 1 + +# D.5) remove table-level SELECT privilege on t3 + + +select user(); +user() +root@localhost +# Put back privilege removed in D.4 +grant select on t2 to user1@localhost; +# And remove a next one: +revoke select on t3 from user1@localhost; +grant select (a) on t3 to user1@localhost; + +select user(); +user() +user1@localhost +set optimizer_trace_offset=0,optimizer_trace_limit=100; +insert into t2 values(current_user()); +# Cannot see substatement as it might expose some data from +# columns of t3 +select QUERY, length(TRACE), INSUFFICIENT_PRIVILEGES from information_schema.OPTIMIZER_TRACE; +QUERY length(TRACE) INSUFFICIENT_PRIVILEGES +insert into t2 values(current_user()) 20 0 + 0 1 + +# Cleanup +select user(); +user() +root@localhost +drop user user1@localhost; +Warnings: +Warning 4005 User 'user1'@'localhost' is referenced as a definer account in a view. +Warning 4005 User 'user1'@'localhost' is referenced as a definer account in a stored routine. +Warning 4005 User 'user1'@'localhost' is referenced as a definer account in a trigger. + +# ========================================================== +# Part E. +# Misc tests. +# ========================================================== + +select user(); +user() +root@localhost +drop view v1; +create sql security definer view v1 as select * from t1 where 'secret'; +create user user1@localhost identified by ''; +Warnings: +Warning 4005 User 'user1'@'localhost' is referenced as a definer account in a stored routine. +Warning 4005 User 'user1'@'localhost' is referenced as a definer account in a trigger. +grant create, insert, select on somedb.* to user1@localhost; +grant create routine on somedb.* to user1@localhost; + +select user(); +user() +user1@localhost +user1 cannot see view's body: +show create view v1; +ERROR 42000: SHOW VIEW command denied to user 'user1'@'localhost' for table 'v1' +SET sql_mode = 'ONLY_FULL_GROUP_BY,NO_ENGINE_SUBSTITUTION'; +user1 creates a procedure +create procedure proc() sql security definer +begin +set optimizer_trace="enabled=on"; +set optimizer_trace_offset=0,optimizer_trace_limit=100; +select * from v1 limit 0; +create table leak select * from information_schema.optimizer_trace; +set optimizer_trace="enabled=off"; +end| +SET sql_mode = default; +select user(); +user() +root@localhost +root runs procedure, without fear of risk as it is SQL SECURITY DEFINER +call proc(); +a + +select user(); +user() +user1@localhost +user1 cannot see view's body: +select * from leak; +QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES + +# Cleanup +select user(); +user() +root@localhost +drop database somedb; +drop user user1@localhost; +set @@global.optimizer_trace_max_mem_size = @old_size; diff --git a/mysql-test/suite/select_count_perf.result-pq b/mysql-test/suite/select_count_perf.result-pq new file mode 100644 index 000000000000..17c9358dd0b8 --- /dev/null +++ b/mysql-test/suite/select_count_perf.result-pq @@ -0,0 +1,1899 @@ +# +# WL#6742 - Test the interaction of multiple transactions using +# different isolation levels to make sure that the value returned +# by count(*) always reflects the correct view of the table according +# to the transaction's selected isolation level. +# +# +# Traverse various indexes to get the right counts. +# This especially tests count(*) which is pushed down to InnoDB in WL#6742. +# +CREATE TABLE t1 ( +c1 INT AUTO_INCREMENT PRIMARY KEY, +c2 INT, +c3 INT, +c4 INT, +INDEX k2(c2) +) Engine=InnoDB; +INSERT INTO t1(c2,c3,c4) VALUES (1, 1, 1); +INSERT INTO t1(c2,c3,c4) VALUES (1, 1, 1); +INSERT INTO t1(c2,c3,c4) VALUES (1, 1, 1); +INSERT INTO t1(c2,c3,c4) VALUES (1, 1, 1); +INSERT INTO t1(c2,c3,c4) VALUES (1, 1, 1); +INSERT INTO t1(c2,c3,c4) VALUES (1, 1, 1); +INSERT INTO t1(c2,c3,c4) VALUES (1, 1, 1); +INSERT INTO t1(c2,c3,c4) VALUES (1, 1, 1); +INSERT INTO t1(c2,c3,c4) VALUES (1, 1, 1); +INSERT INTO t1(c2,c3,c4) VALUES (1, 1, 1); +CREATE TABLE t2 LIKE t1; +INSERT INTO t2 (SELECT * FROM t1); +affected rows: 10 +info: Records: 10 Duplicates: 0 Warnings: 0 +CREATE TABLE t3 ( +c1 INT AUTO_INCREMENT PRIMARY KEY, +c2 INT, +c3 INT, +c4 INT, +INDEX k2(c2) +) Engine=InnoDB PARTITION BY HASH(c1) PARTITIONS 4; +INSERT INTO t3 (SELECT * FROM t1); +affected rows: 10 +info: Records: 10 Duplicates: 0 Warnings: 0 +########## innodb_wl6742_selects.inc ########## +SELECT * FROM t1; +c1 c2 c3 c4 +1 1 1 1 +2 1 1 1 +3 1 1 1 +4 1 1 1 +5 1 1 1 +6 1 1 1 +7 1 1 1 +8 1 1 1 +9 1 1 1 +10 1 1 1 +SELECT COUNT(*) FROM t1; +COUNT(*) +10 +SELECT COUNT(*) FROM t3; +COUNT(*) +10 +SELECT COUNT(c1) FROM t1; +COUNT(c1) +10 +SELECT COUNT(c2) FROM t1; +COUNT(c2) +10 +SELECT COUNT(c3) FROM t1; +COUNT(c3) +10 +SELECT SUM(c1) FROM t1; +SUM(c1) +55 +SELECT SUM(c2) FROM t1; +SUM(c2) +10 +SELECT AVG(c1), MAX(c1), MIN(c2), AVG(c3), SUM(c4) FROM t1; +AVG(c1) MAX(c1) MIN(c2) AVG(c3) SUM(c4) +5.5000 10 1 1.0000 10 +SELECT AVG(c1), MAX(c1), MIN(c2), AVG(c3), SUM(c4) FROM t3; +AVG(c1) MAX(c1) MIN(c2) AVG(c3) SUM(c4) +5.5000 10 1 1.0000 10 +SELECT c1, c2 FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t1) / 2); +c1 c2 +6 1 +7 1 +8 1 +9 1 +10 1 +SELECT c1, c2 FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t3) / 2); +c1 c2 +6 1 +7 1 +8 1 +9 1 +10 1 +SELECT COUNT(c2) FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t1) / 2); +COUNT(c2) +5 +SELECT COUNT(c2) FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t3) / 2); +COUNT(c2) +5 +SELECT COUNT(*) FROM t1 WHERE c1 > (SELECT AVG(c1) FROM t1); +COUNT(*) +5 +SELECT COUNT(*) FROM t1 WHERE c1 > (SELECT AVG(c1) FROM t3); +COUNT(*) +5 +############################################### +# +# Do some DML in the default connection and leave the transaction pending. +# +SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ; +BEGIN; +UPDATE t1 SET c2 = c2 * 3 WHERE c1 = 1; +affected rows: 1 +info: Rows matched: 1 Changed: 1 Warnings: 0 +UPDATE t3 SET c2 = c2 * 3 WHERE c1 = 1; +affected rows: 1 +info: Rows matched: 1 Changed: 1 Warnings: 0 +DELETE FROM t1 WHERE c1 = 6; +affected rows: 1 +DELETE FROM t3 WHERE c1 = 6; +affected rows: 1 +########## innodb_wl6742_selects.inc ########## +SELECT * FROM t1; +c1 c2 c3 c4 +1 3 1 1 +2 1 1 1 +3 1 1 1 +4 1 1 1 +5 1 1 1 +7 1 1 1 +8 1 1 1 +9 1 1 1 +10 1 1 1 +SELECT COUNT(*) FROM t1; +COUNT(*) +9 +SELECT COUNT(*) FROM t3; +COUNT(*) +9 +SELECT COUNT(c1) FROM t1; +COUNT(c1) +9 +SELECT COUNT(c2) FROM t1; +COUNT(c2) +9 +SELECT COUNT(c3) FROM t1; +COUNT(c3) +9 +SELECT SUM(c1) FROM t1; +SUM(c1) +49 +SELECT SUM(c2) FROM t1; +SUM(c2) +11 +SELECT AVG(c1), MAX(c1), MIN(c2), AVG(c3), SUM(c4) FROM t1; +AVG(c1) MAX(c1) MIN(c2) AVG(c3) SUM(c4) +5.4444 10 1 1.0000 9 +SELECT AVG(c1), MAX(c1), MIN(c2), AVG(c3), SUM(c4) FROM t3; +AVG(c1) MAX(c1) MIN(c2) AVG(c3) SUM(c4) +5.4444 10 1 1.0000 9 +SELECT c1, c2 FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t1) / 2); +c1 c2 +5 1 +7 1 +8 1 +9 1 +10 1 +SELECT c1, c2 FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t3) / 2); +c1 c2 +5 1 +7 1 +8 1 +9 1 +10 1 +SELECT COUNT(c2) FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t1) / 2); +COUNT(c2) +5 +SELECT COUNT(c2) FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t3) / 2); +COUNT(c2) +5 +SELECT COUNT(*) FROM t1 WHERE c1 > (SELECT AVG(c1) FROM t1); +COUNT(*) +4 +SELECT COUNT(*) FROM t1 WHERE c1 > (SELECT AVG(c1) FROM t3); +COUNT(*) +4 +############################################### +# +# Start transactions of Repeatable Read, Read Committed, and Read Uncommitted +# +# Connection 1 REPEATABLE READ +# +SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ; +BEGIN; +########## innodb_wl6742_selects.inc ########## +SELECT * FROM t1; +c1 c2 c3 c4 +1 1 1 1 +2 1 1 1 +3 1 1 1 +4 1 1 1 +5 1 1 1 +6 1 1 1 +7 1 1 1 +8 1 1 1 +9 1 1 1 +10 1 1 1 +SELECT COUNT(*) FROM t1; +COUNT(*) +10 +SELECT COUNT(*) FROM t3; +COUNT(*) +10 +SELECT COUNT(c1) FROM t1; +COUNT(c1) +10 +SELECT COUNT(c2) FROM t1; +COUNT(c2) +10 +SELECT COUNT(c3) FROM t1; +COUNT(c3) +10 +SELECT SUM(c1) FROM t1; +SUM(c1) +55 +SELECT SUM(c2) FROM t1; +SUM(c2) +10 +SELECT AVG(c1), MAX(c1), MIN(c2), AVG(c3), SUM(c4) FROM t1; +AVG(c1) MAX(c1) MIN(c2) AVG(c3) SUM(c4) +5.5000 10 1 1.0000 10 +SELECT AVG(c1), MAX(c1), MIN(c2), AVG(c3), SUM(c4) FROM t3; +AVG(c1) MAX(c1) MIN(c2) AVG(c3) SUM(c4) +5.5000 10 1 1.0000 10 +SELECT c1, c2 FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t1) / 2); +c1 c2 +6 1 +7 1 +8 1 +9 1 +10 1 +SELECT c1, c2 FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t3) / 2); +c1 c2 +6 1 +7 1 +8 1 +9 1 +10 1 +SELECT COUNT(c2) FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t1) / 2); +COUNT(c2) +5 +SELECT COUNT(c2) FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t3) / 2); +COUNT(c2) +5 +SELECT COUNT(*) FROM t1 WHERE c1 > (SELECT AVG(c1) FROM t1); +COUNT(*) +5 +SELECT COUNT(*) FROM t1 WHERE c1 > (SELECT AVG(c1) FROM t3); +COUNT(*) +5 +############################################### +UPDATE t1 SET c2 = c2 * 5 WHERE c1 = 2; +affected rows: 1 +info: Rows matched: 1 Changed: 1 Warnings: 0 +UPDATE t3 SET c2 = c2 * 5 WHERE c1 = 2; +affected rows: 1 +info: Rows matched: 1 Changed: 1 Warnings: 0 +DELETE FROM t1 WHERE c1 = 7; +affected rows: 1 +DELETE FROM t3 WHERE c1 = 7; +affected rows: 1 +INSERT INTO t1(c2,c3,c4) VALUES (100, 1, 1); +affected rows: 1 +INSERT INTO t3(c2,c3,c4) VALUES (100, 1, 1); +affected rows: 1 +########## innodb_wl6742_selects.inc ########## +SELECT * FROM t1; +c1 c2 c3 c4 +1 1 1 1 +2 5 1 1 +3 1 1 1 +4 1 1 1 +5 1 1 1 +6 1 1 1 +8 1 1 1 +9 1 1 1 +10 1 1 1 +11 100 1 1 +SELECT COUNT(*) FROM t1; +COUNT(*) +10 +SELECT COUNT(*) FROM t3; +COUNT(*) +10 +SELECT COUNT(c1) FROM t1; +COUNT(c1) +10 +SELECT COUNT(c2) FROM t1; +COUNT(c2) +10 +SELECT COUNT(c3) FROM t1; +COUNT(c3) +10 +SELECT SUM(c1) FROM t1; +SUM(c1) +59 +SELECT SUM(c2) FROM t1; +SUM(c2) +113 +SELECT AVG(c1), MAX(c1), MIN(c2), AVG(c3), SUM(c4) FROM t1; +AVG(c1) MAX(c1) MIN(c2) AVG(c3) SUM(c4) +5.9000 11 1 1.0000 10 +SELECT AVG(c1), MAX(c1), MIN(c2), AVG(c3), SUM(c4) FROM t3; +AVG(c1) MAX(c1) MIN(c2) AVG(c3) SUM(c4) +5.9000 11 1 1.0000 10 +SELECT c1, c2 FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t1) / 2); +c1 c2 +6 1 +8 1 +9 1 +10 1 +11 100 +SELECT c1, c2 FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t3) / 2); +c1 c2 +6 1 +8 1 +9 1 +10 1 +11 100 +SELECT COUNT(c2) FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t1) / 2); +COUNT(c2) +5 +SELECT COUNT(c2) FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t3) / 2); +COUNT(c2) +5 +SELECT COUNT(*) FROM t1 WHERE c1 > (SELECT AVG(c1) FROM t1); +COUNT(*) +5 +SELECT COUNT(*) FROM t1 WHERE c1 > (SELECT AVG(c1) FROM t3); +COUNT(*) +5 +############################################### +# +# Test a lock wait timeout during COUNT(*) +# +SET innodb_lock_wait_timeout = 1; +SELECT COUNT(*) FROM t1 FOR UPDATE; +ERROR HY000: Lock wait timeout exceeded; try restarting transaction +# +# Connection 2 READ COMMITTED +# +SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED; +BEGIN; +########## innodb_wl6742_selects.inc ########## +SELECT * FROM t1; +c1 c2 c3 c4 +1 1 1 1 +2 1 1 1 +3 1 1 1 +4 1 1 1 +5 1 1 1 +6 1 1 1 +7 1 1 1 +8 1 1 1 +9 1 1 1 +10 1 1 1 +SELECT COUNT(*) FROM t1; +COUNT(*) +10 +SELECT COUNT(*) FROM t3; +COUNT(*) +10 +SELECT COUNT(c1) FROM t1; +COUNT(c1) +10 +SELECT COUNT(c2) FROM t1; +COUNT(c2) +10 +SELECT COUNT(c3) FROM t1; +COUNT(c3) +10 +SELECT SUM(c1) FROM t1; +SUM(c1) +55 +SELECT SUM(c2) FROM t1; +SUM(c2) +10 +SELECT AVG(c1), MAX(c1), MIN(c2), AVG(c3), SUM(c4) FROM t1; +AVG(c1) MAX(c1) MIN(c2) AVG(c3) SUM(c4) +5.5000 10 1 1.0000 10 +SELECT AVG(c1), MAX(c1), MIN(c2), AVG(c3), SUM(c4) FROM t3; +AVG(c1) MAX(c1) MIN(c2) AVG(c3) SUM(c4) +5.5000 10 1 1.0000 10 +SELECT c1, c2 FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t1) / 2); +c1 c2 +6 1 +7 1 +8 1 +9 1 +10 1 +SELECT c1, c2 FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t3) / 2); +c1 c2 +6 1 +7 1 +8 1 +9 1 +10 1 +SELECT COUNT(c2) FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t1) / 2); +COUNT(c2) +5 +SELECT COUNT(c2) FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t3) / 2); +COUNT(c2) +5 +SELECT COUNT(*) FROM t1 WHERE c1 > (SELECT AVG(c1) FROM t1); +COUNT(*) +5 +SELECT COUNT(*) FROM t1 WHERE c1 > (SELECT AVG(c1) FROM t3); +COUNT(*) +5 +############################################### +UPDATE t1 SET c2 = c2 * 7 WHERE c1 = 3; +affected rows: 1 +info: Rows matched: 1 Changed: 1 Warnings: 0 +DELETE FROM t1 WHERE c1 = 8; +affected rows: 1 +DELETE FROM t3 WHERE c1 = 8; +affected rows: 1 +INSERT INTO t1(c2,c3,c4) VALUES (1000, 1, 1); +affected rows: 1 +INSERT INTO t3(c2,c3,c4) VALUES (1000, 1, 1); +affected rows: 1 +########## innodb_wl6742_selects.inc ########## +SELECT * FROM t1; +c1 c2 c3 c4 +1 1 1 1 +2 1 1 1 +3 7 1 1 +4 1 1 1 +5 1 1 1 +6 1 1 1 +7 1 1 1 +9 1 1 1 +10 1 1 1 +12 1000 1 1 +SELECT COUNT(*) FROM t1; +COUNT(*) +10 +SELECT COUNT(*) FROM t3; +COUNT(*) +10 +SELECT COUNT(c1) FROM t1; +COUNT(c1) +10 +SELECT COUNT(c2) FROM t1; +COUNT(c2) +10 +SELECT COUNT(c3) FROM t1; +COUNT(c3) +10 +SELECT SUM(c1) FROM t1; +SUM(c1) +59 +SELECT SUM(c2) FROM t1; +SUM(c2) +1015 +SELECT AVG(c1), MAX(c1), MIN(c2), AVG(c3), SUM(c4) FROM t1; +AVG(c1) MAX(c1) MIN(c2) AVG(c3) SUM(c4) +5.9000 12 1 1.0000 10 +SELECT AVG(c1), MAX(c1), MIN(c2), AVG(c3), SUM(c4) FROM t3; +AVG(c1) MAX(c1) MIN(c2) AVG(c3) SUM(c4) +5.9000 12 1 1.0000 10 +SELECT c1, c2 FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t1) / 2); +c1 c2 +6 1 +7 1 +9 1 +10 1 +12 1000 +SELECT c1, c2 FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t3) / 2); +c1 c2 +6 1 +7 1 +9 1 +10 1 +12 1000 +SELECT COUNT(c2) FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t1) / 2); +COUNT(c2) +5 +SELECT COUNT(c2) FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t3) / 2); +COUNT(c2) +5 +SELECT COUNT(*) FROM t1 WHERE c1 > (SELECT AVG(c1) FROM t1); +COUNT(*) +5 +SELECT COUNT(*) FROM t1 WHERE c1 > (SELECT AVG(c1) FROM t3); +COUNT(*) +5 +############################################### +# +# Connection 3 READ UNCOMMITTED +# +SET SESSION TRANSACTION ISOLATION LEVEL READ UNCOMMITTED; +BEGIN; +########## innodb_wl6742_selects.inc ########## +SELECT * FROM t1; +c1 c2 c3 c4 +1 3 1 1 +2 5 1 1 +3 7 1 1 +4 1 1 1 +5 1 1 1 +9 1 1 1 +10 1 1 1 +11 100 1 1 +12 1000 1 1 +SELECT COUNT(*) FROM t1; +COUNT(*) +9 +SELECT COUNT(*) FROM t3; +COUNT(*) +9 +SELECT COUNT(c1) FROM t1; +COUNT(c1) +9 +SELECT COUNT(c2) FROM t1; +COUNT(c2) +9 +SELECT COUNT(c3) FROM t1; +COUNT(c3) +9 +SELECT SUM(c1) FROM t1; +SUM(c1) +57 +SELECT SUM(c2) FROM t1; +SUM(c2) +1119 +SELECT AVG(c1), MAX(c1), MIN(c2), AVG(c3), SUM(c4) FROM t1; +AVG(c1) MAX(c1) MIN(c2) AVG(c3) SUM(c4) +6.3333 12 1 1.0000 9 +SELECT AVG(c1), MAX(c1), MIN(c2), AVG(c3), SUM(c4) FROM t3; +AVG(c1) MAX(c1) MIN(c2) AVG(c3) SUM(c4) +6.3333 12 1 1.0000 9 +SELECT c1, c2 FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t1) / 2); +c1 c2 +5 1 +9 1 +10 1 +11 100 +12 1000 +SELECT c1, c2 FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t3) / 2); +c1 c2 +5 1 +9 1 +10 1 +11 100 +12 1000 +SELECT COUNT(c2) FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t1) / 2); +COUNT(c2) +5 +SELECT COUNT(c2) FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t3) / 2); +COUNT(c2) +5 +SELECT COUNT(*) FROM t1 WHERE c1 > (SELECT AVG(c1) FROM t1); +COUNT(*) +4 +SELECT COUNT(*) FROM t1 WHERE c1 > (SELECT AVG(c1) FROM t3); +COUNT(*) +4 +############################################### +UPDATE t1 SET c2 = c2 * 11 WHERE c1 = 4; +affected rows: 1 +info: Rows matched: 1 Changed: 1 Warnings: 0 +UPDATE t3 SET c2 = c2 * 11 WHERE c1 = 4; +affected rows: 1 +info: Rows matched: 1 Changed: 1 Warnings: 0 +INSERT INTO t1(c2,c3,c4) VALUES (10000, 1, 1); +affected rows: 1 +INSERT INTO t3(c2,c3,c4) VALUES (10000, 1, 1); +affected rows: 1 +DELETE FROM t1 WHERE c1 in(9); +affected rows: 1 +DELETE FROM t3 WHERE c1 in(9); +affected rows: 1 +########## innodb_wl6742_selects.inc ########## +SELECT * FROM t1; +c1 c2 c3 c4 +1 3 1 1 +2 5 1 1 +3 7 1 1 +4 11 1 1 +5 1 1 1 +10 1 1 1 +11 100 1 1 +12 1000 1 1 +13 10000 1 1 +SELECT COUNT(*) FROM t1; +COUNT(*) +9 +SELECT COUNT(*) FROM t3; +COUNT(*) +9 +SELECT COUNT(c1) FROM t1; +COUNT(c1) +9 +SELECT COUNT(c2) FROM t1; +COUNT(c2) +9 +SELECT COUNT(c3) FROM t1; +COUNT(c3) +9 +SELECT SUM(c1) FROM t1; +SUM(c1) +61 +SELECT SUM(c2) FROM t1; +SUM(c2) +11128 +SELECT AVG(c1), MAX(c1), MIN(c2), AVG(c3), SUM(c4) FROM t1; +AVG(c1) MAX(c1) MIN(c2) AVG(c3) SUM(c4) +6.7778 13 1 1.0000 9 +SELECT AVG(c1), MAX(c1), MIN(c2), AVG(c3), SUM(c4) FROM t3; +AVG(c1) MAX(c1) MIN(c2) AVG(c3) SUM(c4) +6.7778 13 1 1.0000 9 +SELECT c1, c2 FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t1) / 2); +c1 c2 +5 1 +10 1 +11 100 +12 1000 +13 10000 +SELECT c1, c2 FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t3) / 2); +c1 c2 +5 1 +10 1 +11 100 +12 1000 +13 10000 +SELECT COUNT(c2) FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t1) / 2); +COUNT(c2) +5 +SELECT COUNT(c2) FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t3) / 2); +COUNT(c2) +5 +SELECT COUNT(*) FROM t1 WHERE c1 > (SELECT AVG(c1) FROM t1); +COUNT(*) +4 +SELECT COUNT(*) FROM t1 WHERE c1 > (SELECT AVG(c1) FROM t3); +COUNT(*) +4 +############################################### +# +# Connection default REPEATABLE READ +# +########## innodb_wl6742_selects.inc ########## +SELECT * FROM t1; +c1 c2 c3 c4 +1 3 1 1 +2 1 1 1 +3 1 1 1 +4 1 1 1 +5 1 1 1 +7 1 1 1 +8 1 1 1 +9 1 1 1 +10 1 1 1 +SELECT COUNT(*) FROM t1; +COUNT(*) +9 +SELECT COUNT(*) FROM t3; +COUNT(*) +9 +SELECT COUNT(c1) FROM t1; +COUNT(c1) +9 +SELECT COUNT(c2) FROM t1; +COUNT(c2) +9 +SELECT COUNT(c3) FROM t1; +COUNT(c3) +9 +SELECT SUM(c1) FROM t1; +SUM(c1) +49 +SELECT SUM(c2) FROM t1; +SUM(c2) +11 +SELECT AVG(c1), MAX(c1), MIN(c2), AVG(c3), SUM(c4) FROM t1; +AVG(c1) MAX(c1) MIN(c2) AVG(c3) SUM(c4) +5.4444 10 1 1.0000 9 +SELECT AVG(c1), MAX(c1), MIN(c2), AVG(c3), SUM(c4) FROM t3; +AVG(c1) MAX(c1) MIN(c2) AVG(c3) SUM(c4) +5.4444 10 1 1.0000 9 +SELECT c1, c2 FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t1) / 2); +c1 c2 +5 1 +7 1 +8 1 +9 1 +10 1 +SELECT c1, c2 FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t3) / 2); +c1 c2 +5 1 +7 1 +8 1 +9 1 +10 1 +SELECT COUNT(c2) FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t1) / 2); +COUNT(c2) +5 +SELECT COUNT(c2) FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t3) / 2); +COUNT(c2) +5 +SELECT COUNT(*) FROM t1 WHERE c1 > (SELECT AVG(c1) FROM t1); +COUNT(*) +4 +SELECT COUNT(*) FROM t1 WHERE c1 > (SELECT AVG(c1) FROM t3); +COUNT(*) +4 +############################################### +# +# Commit the 3 extra connections +# +# Connection 1 REPEATABLE READ +# +########## innodb_wl6742_selects.inc ########## +SELECT * FROM t1; +c1 c2 c3 c4 +1 1 1 1 +2 5 1 1 +3 1 1 1 +4 1 1 1 +5 1 1 1 +6 1 1 1 +8 1 1 1 +9 1 1 1 +10 1 1 1 +11 100 1 1 +SELECT COUNT(*) FROM t1; +COUNT(*) +10 +SELECT COUNT(*) FROM t3; +COUNT(*) +10 +SELECT COUNT(c1) FROM t1; +COUNT(c1) +10 +SELECT COUNT(c2) FROM t1; +COUNT(c2) +10 +SELECT COUNT(c3) FROM t1; +COUNT(c3) +10 +SELECT SUM(c1) FROM t1; +SUM(c1) +59 +SELECT SUM(c2) FROM t1; +SUM(c2) +113 +SELECT AVG(c1), MAX(c1), MIN(c2), AVG(c3), SUM(c4) FROM t1; +AVG(c1) MAX(c1) MIN(c2) AVG(c3) SUM(c4) +5.9000 11 1 1.0000 10 +SELECT AVG(c1), MAX(c1), MIN(c2), AVG(c3), SUM(c4) FROM t3; +AVG(c1) MAX(c1) MIN(c2) AVG(c3) SUM(c4) +5.9000 11 1 1.0000 10 +SELECT c1, c2 FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t1) / 2); +c1 c2 +6 1 +8 1 +9 1 +10 1 +11 100 +SELECT c1, c2 FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t3) / 2); +c1 c2 +6 1 +8 1 +9 1 +10 1 +11 100 +SELECT COUNT(c2) FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t1) / 2); +COUNT(c2) +5 +SELECT COUNT(c2) FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t3) / 2); +COUNT(c2) +5 +SELECT COUNT(*) FROM t1 WHERE c1 > (SELECT AVG(c1) FROM t1); +COUNT(*) +5 +SELECT COUNT(*) FROM t1 WHERE c1 > (SELECT AVG(c1) FROM t3); +COUNT(*) +5 +############################################### +# +# Connection 2 READ COMMITTED +# +########## innodb_wl6742_selects.inc ########## +SELECT * FROM t1; +c1 c2 c3 c4 +1 1 1 1 +2 1 1 1 +3 7 1 1 +4 1 1 1 +5 1 1 1 +6 1 1 1 +7 1 1 1 +9 1 1 1 +10 1 1 1 +12 1000 1 1 +SELECT COUNT(*) FROM t1; +COUNT(*) +10 +SELECT COUNT(*) FROM t3; +COUNT(*) +10 +SELECT COUNT(c1) FROM t1; +COUNT(c1) +10 +SELECT COUNT(c2) FROM t1; +COUNT(c2) +10 +SELECT COUNT(c3) FROM t1; +COUNT(c3) +10 +SELECT SUM(c1) FROM t1; +SUM(c1) +59 +SELECT SUM(c2) FROM t1; +SUM(c2) +1015 +SELECT AVG(c1), MAX(c1), MIN(c2), AVG(c3), SUM(c4) FROM t1; +AVG(c1) MAX(c1) MIN(c2) AVG(c3) SUM(c4) +5.9000 12 1 1.0000 10 +SELECT AVG(c1), MAX(c1), MIN(c2), AVG(c3), SUM(c4) FROM t3; +AVG(c1) MAX(c1) MIN(c2) AVG(c3) SUM(c4) +5.9000 12 1 1.0000 10 +SELECT c1, c2 FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t1) / 2); +c1 c2 +6 1 +7 1 +9 1 +10 1 +12 1000 +SELECT c1, c2 FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t3) / 2); +c1 c2 +6 1 +7 1 +9 1 +10 1 +12 1000 +SELECT COUNT(c2) FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t1) / 2); +COUNT(c2) +5 +SELECT COUNT(c2) FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t3) / 2); +COUNT(c2) +5 +SELECT COUNT(*) FROM t1 WHERE c1 > (SELECT AVG(c1) FROM t1); +COUNT(*) +5 +SELECT COUNT(*) FROM t1 WHERE c1 > (SELECT AVG(c1) FROM t3); +COUNT(*) +5 +############################################### +# +# Connection 3 READ UNCOMMITTED +# +########## innodb_wl6742_selects.inc ########## +SELECT * FROM t1; +c1 c2 c3 c4 +1 3 1 1 +2 5 1 1 +3 7 1 1 +4 11 1 1 +5 1 1 1 +10 1 1 1 +11 100 1 1 +12 1000 1 1 +13 10000 1 1 +SELECT COUNT(*) FROM t1; +COUNT(*) +9 +SELECT COUNT(*) FROM t3; +COUNT(*) +9 +SELECT COUNT(c1) FROM t1; +COUNT(c1) +9 +SELECT COUNT(c2) FROM t1; +COUNT(c2) +9 +SELECT COUNT(c3) FROM t1; +COUNT(c3) +9 +SELECT SUM(c1) FROM t1; +SUM(c1) +61 +SELECT SUM(c2) FROM t1; +SUM(c2) +11128 +SELECT AVG(c1), MAX(c1), MIN(c2), AVG(c3), SUM(c4) FROM t1; +AVG(c1) MAX(c1) MIN(c2) AVG(c3) SUM(c4) +6.7778 13 1 1.0000 9 +SELECT AVG(c1), MAX(c1), MIN(c2), AVG(c3), SUM(c4) FROM t3; +AVG(c1) MAX(c1) MIN(c2) AVG(c3) SUM(c4) +6.7778 13 1 1.0000 9 +SELECT c1, c2 FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t1) / 2); +c1 c2 +5 1 +10 1 +11 100 +12 1000 +13 10000 +SELECT c1, c2 FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t3) / 2); +c1 c2 +5 1 +10 1 +11 100 +12 1000 +13 10000 +SELECT COUNT(c2) FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t1) / 2); +COUNT(c2) +5 +SELECT COUNT(c2) FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t3) / 2); +COUNT(c2) +5 +SELECT COUNT(*) FROM t1 WHERE c1 > (SELECT AVG(c1) FROM t1); +COUNT(*) +4 +SELECT COUNT(*) FROM t1 WHERE c1 > (SELECT AVG(c1) FROM t3); +COUNT(*) +4 +############################################### +COMMIT; +########## innodb_wl6742_selects.inc ########## +SELECT * FROM t1; +c1 c2 c3 c4 +1 3 1 1 +2 5 1 1 +3 7 1 1 +4 11 1 1 +5 1 1 1 +10 1 1 1 +11 100 1 1 +12 1000 1 1 +13 10000 1 1 +SELECT COUNT(*) FROM t1; +COUNT(*) +9 +SELECT COUNT(*) FROM t3; +COUNT(*) +9 +SELECT COUNT(c1) FROM t1; +COUNT(c1) +9 +SELECT COUNT(c2) FROM t1; +COUNT(c2) +9 +SELECT COUNT(c3) FROM t1; +COUNT(c3) +9 +SELECT SUM(c1) FROM t1; +SUM(c1) +61 +SELECT SUM(c2) FROM t1; +SUM(c2) +11128 +SELECT AVG(c1), MAX(c1), MIN(c2), AVG(c3), SUM(c4) FROM t1; +AVG(c1) MAX(c1) MIN(c2) AVG(c3) SUM(c4) +6.7778 13 1 1.0000 9 +SELECT AVG(c1), MAX(c1), MIN(c2), AVG(c3), SUM(c4) FROM t3; +AVG(c1) MAX(c1) MIN(c2) AVG(c3) SUM(c4) +6.7778 13 1 1.0000 9 +SELECT c1, c2 FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t1) / 2); +c1 c2 +5 1 +10 1 +11 100 +12 1000 +13 10000 +SELECT c1, c2 FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t3) / 2); +c1 c2 +5 1 +10 1 +11 100 +12 1000 +13 10000 +SELECT COUNT(c2) FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t1) / 2); +COUNT(c2) +5 +SELECT COUNT(c2) FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t3) / 2); +COUNT(c2) +5 +SELECT COUNT(*) FROM t1 WHERE c1 > (SELECT AVG(c1) FROM t1); +COUNT(*) +4 +SELECT COUNT(*) FROM t1 WHERE c1 > (SELECT AVG(c1) FROM t3); +COUNT(*) +4 +############################################### +# +# Connection 2 READ COMMITTED +# +########## innodb_wl6742_selects.inc ########## +SELECT * FROM t1; +c1 c2 c3 c4 +1 1 1 1 +2 1 1 1 +3 7 1 1 +4 11 1 1 +5 1 1 1 +6 1 1 1 +7 1 1 1 +10 1 1 1 +12 1000 1 1 +13 10000 1 1 +SELECT COUNT(*) FROM t1; +COUNT(*) +10 +SELECT COUNT(*) FROM t3; +COUNT(*) +10 +SELECT COUNT(c1) FROM t1; +COUNT(c1) +10 +SELECT COUNT(c2) FROM t1; +COUNT(c2) +10 +SELECT COUNT(c3) FROM t1; +COUNT(c3) +10 +SELECT SUM(c1) FROM t1; +SUM(c1) +63 +SELECT SUM(c2) FROM t1; +SUM(c2) +11024 +SELECT AVG(c1), MAX(c1), MIN(c2), AVG(c3), SUM(c4) FROM t1; +AVG(c1) MAX(c1) MIN(c2) AVG(c3) SUM(c4) +6.3000 13 1 1.0000 10 +SELECT AVG(c1), MAX(c1), MIN(c2), AVG(c3), SUM(c4) FROM t3; +AVG(c1) MAX(c1) MIN(c2) AVG(c3) SUM(c4) +6.3000 13 1 1.0000 10 +SELECT c1, c2 FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t1) / 2); +c1 c2 +6 1 +7 1 +10 1 +12 1000 +13 10000 +SELECT c1, c2 FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t3) / 2); +c1 c2 +6 1 +7 1 +10 1 +12 1000 +13 10000 +SELECT COUNT(c2) FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t1) / 2); +COUNT(c2) +5 +SELECT COUNT(c2) FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t3) / 2); +COUNT(c2) +5 +SELECT COUNT(*) FROM t1 WHERE c1 > (SELECT AVG(c1) FROM t1); +COUNT(*) +4 +SELECT COUNT(*) FROM t1 WHERE c1 > (SELECT AVG(c1) FROM t3); +COUNT(*) +4 +############################################### +COMMIT; +########## innodb_wl6742_selects.inc ########## +SELECT * FROM t1; +c1 c2 c3 c4 +1 1 1 1 +2 1 1 1 +3 7 1 1 +4 11 1 1 +5 1 1 1 +6 1 1 1 +7 1 1 1 +10 1 1 1 +12 1000 1 1 +13 10000 1 1 +SELECT COUNT(*) FROM t1; +COUNT(*) +10 +SELECT COUNT(*) FROM t3; +COUNT(*) +10 +SELECT COUNT(c1) FROM t1; +COUNT(c1) +10 +SELECT COUNT(c2) FROM t1; +COUNT(c2) +10 +SELECT COUNT(c3) FROM t1; +COUNT(c3) +10 +SELECT SUM(c1) FROM t1; +SUM(c1) +63 +SELECT SUM(c2) FROM t1; +SUM(c2) +11024 +SELECT AVG(c1), MAX(c1), MIN(c2), AVG(c3), SUM(c4) FROM t1; +AVG(c1) MAX(c1) MIN(c2) AVG(c3) SUM(c4) +6.3000 13 1 1.0000 10 +SELECT AVG(c1), MAX(c1), MIN(c2), AVG(c3), SUM(c4) FROM t3; +AVG(c1) MAX(c1) MIN(c2) AVG(c3) SUM(c4) +6.3000 13 1 1.0000 10 +SELECT c1, c2 FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t1) / 2); +c1 c2 +6 1 +7 1 +10 1 +12 1000 +13 10000 +SELECT c1, c2 FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t3) / 2); +c1 c2 +6 1 +7 1 +10 1 +12 1000 +13 10000 +SELECT COUNT(c2) FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t1) / 2); +COUNT(c2) +5 +SELECT COUNT(c2) FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t3) / 2); +COUNT(c2) +5 +SELECT COUNT(*) FROM t1 WHERE c1 > (SELECT AVG(c1) FROM t1); +COUNT(*) +4 +SELECT COUNT(*) FROM t1 WHERE c1 > (SELECT AVG(c1) FROM t3); +COUNT(*) +4 +############################################### +# +# Connection 1 REPEATABLE READ +# +########## innodb_wl6742_selects.inc ########## +SELECT * FROM t1; +c1 c2 c3 c4 +1 1 1 1 +2 5 1 1 +3 1 1 1 +4 1 1 1 +5 1 1 1 +6 1 1 1 +8 1 1 1 +9 1 1 1 +10 1 1 1 +11 100 1 1 +SELECT COUNT(*) FROM t1; +COUNT(*) +10 +SELECT COUNT(*) FROM t3; +COUNT(*) +10 +SELECT COUNT(c1) FROM t1; +COUNT(c1) +10 +SELECT COUNT(c2) FROM t1; +COUNT(c2) +10 +SELECT COUNT(c3) FROM t1; +COUNT(c3) +10 +SELECT SUM(c1) FROM t1; +SUM(c1) +59 +SELECT SUM(c2) FROM t1; +SUM(c2) +113 +SELECT AVG(c1), MAX(c1), MIN(c2), AVG(c3), SUM(c4) FROM t1; +AVG(c1) MAX(c1) MIN(c2) AVG(c3) SUM(c4) +5.9000 11 1 1.0000 10 +SELECT AVG(c1), MAX(c1), MIN(c2), AVG(c3), SUM(c4) FROM t3; +AVG(c1) MAX(c1) MIN(c2) AVG(c3) SUM(c4) +5.9000 11 1 1.0000 10 +SELECT c1, c2 FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t1) / 2); +c1 c2 +6 1 +8 1 +9 1 +10 1 +11 100 +SELECT c1, c2 FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t3) / 2); +c1 c2 +6 1 +8 1 +9 1 +10 1 +11 100 +SELECT COUNT(c2) FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t1) / 2); +COUNT(c2) +5 +SELECT COUNT(c2) FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t3) / 2); +COUNT(c2) +5 +SELECT COUNT(*) FROM t1 WHERE c1 > (SELECT AVG(c1) FROM t1); +COUNT(*) +5 +SELECT COUNT(*) FROM t1 WHERE c1 > (SELECT AVG(c1) FROM t3); +COUNT(*) +5 +############################################### +# +# Select the first 5 records FOR UPDATE using count(*) in a subquery. +# The second record is still pending so we get a lock timeout. +# +SET innodb_lock_wait_timeout = 1; +SELECT c1, c2 FROM t1 WHERE c1 < ((SELECT COUNT(*) FROM t1) / 2) FOR UPDATE; +ERROR HY000: Lock wait timeout exceeded; try restarting transaction +SELECT COUNT(*) FROM t1 FOR UPDATE; +ERROR HY000: Lock wait timeout exceeded; try restarting transaction +COMMIT; +########## innodb_wl6742_selects.inc ########## +SELECT * FROM t1; +c1 c2 c3 c4 +1 1 1 1 +2 5 1 1 +3 7 1 1 +4 11 1 1 +5 1 1 1 +6 1 1 1 +10 1 1 1 +11 100 1 1 +12 1000 1 1 +13 10000 1 1 +SELECT COUNT(*) FROM t1; +COUNT(*) +10 +SELECT COUNT(*) FROM t3; +COUNT(*) +10 +SELECT COUNT(c1) FROM t1; +COUNT(c1) +10 +SELECT COUNT(c2) FROM t1; +COUNT(c2) +10 +SELECT COUNT(c3) FROM t1; +COUNT(c3) +10 +SELECT SUM(c1) FROM t1; +SUM(c1) +67 +SELECT SUM(c2) FROM t1; +SUM(c2) +11127 +SELECT AVG(c1), MAX(c1), MIN(c2), AVG(c3), SUM(c4) FROM t1; +AVG(c1) MAX(c1) MIN(c2) AVG(c3) SUM(c4) +6.7000 13 1 1.0000 10 +SELECT AVG(c1), MAX(c1), MIN(c2), AVG(c3), SUM(c4) FROM t3; +AVG(c1) MAX(c1) MIN(c2) AVG(c3) SUM(c4) +6.7000 13 1 1.0000 10 +SELECT c1, c2 FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t1) / 2); +c1 c2 +6 1 +10 1 +11 100 +12 1000 +13 10000 +SELECT c1, c2 FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t3) / 2); +c1 c2 +6 1 +10 1 +11 100 +12 1000 +13 10000 +SELECT COUNT(c2) FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t1) / 2); +COUNT(c2) +5 +SELECT COUNT(c2) FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t3) / 2); +COUNT(c2) +5 +SELECT COUNT(*) FROM t1 WHERE c1 > (SELECT AVG(c1) FROM t1); +COUNT(*) +4 +SELECT COUNT(*) FROM t1 WHERE c1 > (SELECT AVG(c1) FROM t3); +COUNT(*) +4 +############################################### +# +# Show The EXPLAIN output for these queries; +# +EXPLAIN SELECT * FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL # 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c1` AS `c1`,`test`.`t1`.`c2` AS `c2`,`test`.`t1`.`c3` AS `c3`,`test`.`t1`.`c4` AS `c4` from `test`.`t1` +EXPLAIN SELECT COUNT(*) FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index NULL k2 5 NULL # 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` +EXPLAIN SELECT COUNT(*) FROM t3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 p0,p1,p2,p3 index NULL k2 5 NULL # 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t3` +EXPLAIN SELECT COUNT(c1) FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index NULL k2 5 NULL # 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select count(`test`.`t1`.`c1`) AS `COUNT(c1)` from `test`.`t1` +EXPLAIN SELECT COUNT(c2) FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL k2 5 NULL # 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select count(`test`.`t1`.`c2`) AS `COUNT(c2)` from `test`.`t1` +EXPLAIN SELECT COUNT(c3) FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL # 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select count(`test`.`t1`.`c3`) AS `COUNT(c3)` from `test`.`t1` +EXPLAIN SELECT SUM(c1) FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL k2 5 NULL # 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select sum(`test`.`t1`.`c1`) AS `SUM(c1)` from `test`.`t1` +EXPLAIN SELECT SUM(c2) FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL k2 5 NULL # 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select sum(`test`.`t1`.`c2`) AS `SUM(c2)` from `test`.`t1` +EXPLAIN SELECT AVG(c1), MAX(c1), MIN(c2), AVG(c3), SUM(c4) FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL # 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select avg(`test`.`t1`.`c1`) AS `AVG(c1)`,max(`test`.`t1`.`c1`) AS `MAX(c1)`,min(`test`.`t1`.`c2`) AS `MIN(c2)`,avg(`test`.`t1`.`c3`) AS `AVG(c3)`,sum(`test`.`t1`.`c4`) AS `SUM(c4)` from `test`.`t1` +EXPLAIN SELECT AVG(c1), MAX(c1), MIN(c2), AVG(c3), SUM(c4) FROM t3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 p0,p1,p2,p3 ALL NULL NULL NULL NULL # 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select avg(`test`.`t3`.`c1`) AS `AVG(c1)`,max(`test`.`t3`.`c1`) AS `MAX(c1)`,min(`test`.`t3`.`c2`) AS `MIN(c2)`,avg(`test`.`t3`.`c3`) AS `AVG(c3)`,sum(`test`.`t3`.`c4`) AS `SUM(c4)` from `test`.`t3` +EXPLAIN SELECT c1, c2 FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t1) / 2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL range PRIMARY,k2 PRIMARY 4 NULL # 100.00 Using where +2 SUBQUERY t1 NULL index NULL k2 5 NULL # 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c1` AS `c1`,`test`.`t1`.`c2` AS `c2` from `test`.`t1` where (`test`.`t1`.`c1` > (((/* select#2 */ select count(0) from `test`.`t1`) / 2))) +EXPLAIN SELECT c1, c2 FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t3) / 2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL range PRIMARY,k2 PRIMARY 4 NULL # 100.00 Using where +2 SUBQUERY t3 p0,p1,p2,p3 index NULL k2 5 NULL # 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c1` AS `c1`,`test`.`t1`.`c2` AS `c2` from `test`.`t1` where (`test`.`t1`.`c1` > (((/* select#2 */ select count(0) from `test`.`t3`) / 2))) +EXPLAIN SELECT COUNT(c2) FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t1) / 2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL range PRIMARY,k2 PRIMARY 4 NULL # 100.00 Using where +2 SUBQUERY t1 NULL index NULL k2 5 NULL # 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select count(`test`.`t1`.`c2`) AS `COUNT(c2)` from `test`.`t1` where (`test`.`t1`.`c1` > (((/* select#2 */ select count(0) from `test`.`t1`) / 2))) +EXPLAIN SELECT COUNT(c2) FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t3) / 2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL range PRIMARY,k2 PRIMARY 4 NULL # 100.00 Using where +2 SUBQUERY t3 p0,p1,p2,p3 index NULL k2 5 NULL # 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select count(`test`.`t1`.`c2`) AS `COUNT(c2)` from `test`.`t1` where (`test`.`t1`.`c1` > (((/* select#2 */ select count(0) from `test`.`t3`) / 2))) +EXPLAIN SELECT COUNT(*) FROM t1 WHERE c1 > (SELECT AVG(c1) FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL range PRIMARY,k2 PRIMARY 4 NULL # 100.00 Using where; Using index +2 SUBQUERY t1 NULL index NULL k2 5 NULL # 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`c1` > (/* select#2 */ select avg(`test`.`t1`.`c1`) from `test`.`t1`)) +EXPLAIN SELECT COUNT(*) FROM t1 WHERE c1 > (SELECT AVG(c1) FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL range PRIMARY,k2 PRIMARY 4 NULL # 100.00 Using where; Using index +2 SUBQUERY t3 p0,p1,p2,p3 index NULL k2 5 NULL # 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`c1` > (/* select#2 */ select avg(`test`.`t3`.`c1`) from `test`.`t3`)) +# +# Make all indexes in t2 obsolete to the active repeatable read transaction +# in the default connection. +# +ALTER TABLE t2 row_format=redundant; +# +# Connection default REPEATABLE READ +# Do more DML in the default REPEATABLE READ transaction in order to use recently committed records. +# +########## innodb_wl6742_selects.inc ########## +SELECT * FROM t1; +c1 c2 c3 c4 +1 3 1 1 +2 1 1 1 +3 1 1 1 +4 1 1 1 +5 1 1 1 +7 1 1 1 +8 1 1 1 +9 1 1 1 +10 1 1 1 +SELECT COUNT(*) FROM t1; +COUNT(*) +9 +SELECT COUNT(*) FROM t3; +COUNT(*) +9 +SELECT COUNT(c1) FROM t1; +COUNT(c1) +9 +SELECT COUNT(c2) FROM t1; +COUNT(c2) +9 +SELECT COUNT(c3) FROM t1; +COUNT(c3) +9 +SELECT SUM(c1) FROM t1; +SUM(c1) +49 +SELECT SUM(c2) FROM t1; +SUM(c2) +11 +SELECT AVG(c1), MAX(c1), MIN(c2), AVG(c3), SUM(c4) FROM t1; +AVG(c1) MAX(c1) MIN(c2) AVG(c3) SUM(c4) +5.4444 10 1 1.0000 9 +SELECT AVG(c1), MAX(c1), MIN(c2), AVG(c3), SUM(c4) FROM t3; +AVG(c1) MAX(c1) MIN(c2) AVG(c3) SUM(c4) +5.4444 10 1 1.0000 9 +SELECT c1, c2 FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t1) / 2); +c1 c2 +5 1 +7 1 +8 1 +9 1 +10 1 +SELECT c1, c2 FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t3) / 2); +c1 c2 +5 1 +7 1 +8 1 +9 1 +10 1 +SELECT COUNT(c2) FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t1) / 2); +COUNT(c2) +5 +SELECT COUNT(c2) FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t3) / 2); +COUNT(c2) +5 +SELECT COUNT(*) FROM t1 WHERE c1 > (SELECT AVG(c1) FROM t1); +COUNT(*) +4 +SELECT COUNT(*) FROM t1 WHERE c1 > (SELECT AVG(c1) FROM t3); +COUNT(*) +4 +############################################### +UPDATE t1 SET c4 = c2 * 10; +affected rows: 9 +info: Rows matched: 9 Changed: 9 Warnings: 0 +UPDATE t3 SET c4 = c2 * 10; +affected rows: 9 +info: Rows matched: 9 Changed: 9 Warnings: 0 +########## innodb_wl6742_selects.inc ########## +SELECT * FROM t1; +c1 c2 c3 c4 +1 3 1 30 +2 5 1 50 +3 7 1 70 +4 11 1 110 +5 1 1 10 +7 1 1 1 +8 1 1 1 +9 1 1 1 +10 1 1 10 +11 100 1 1000 +12 1000 1 10000 +13 10000 1 100000 +SELECT COUNT(*) FROM t1; +COUNT(*) +12 +SELECT COUNT(*) FROM t3; +COUNT(*) +12 +SELECT COUNT(c1) FROM t1; +COUNT(c1) +12 +SELECT COUNT(c2) FROM t1; +COUNT(c2) +12 +SELECT COUNT(c3) FROM t1; +COUNT(c3) +12 +SELECT SUM(c1) FROM t1; +SUM(c1) +85 +SELECT SUM(c2) FROM t1; +SUM(c2) +11131 +SELECT AVG(c1), MAX(c1), MIN(c2), AVG(c3), SUM(c4) FROM t1; +AVG(c1) MAX(c1) MIN(c2) AVG(c3) SUM(c4) +7.0833 13 1 1.0000 111283 +SELECT AVG(c1), MAX(c1), MIN(c2), AVG(c3), SUM(c4) FROM t3; +AVG(c1) MAX(c1) MIN(c2) AVG(c3) SUM(c4) +7.0833 13 1 1.0000 111223 +SELECT c1, c2 FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t1) / 2); +c1 c2 +7 1 +8 1 +9 1 +10 1 +11 100 +12 1000 +13 10000 +SELECT c1, c2 FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t3) / 2); +c1 c2 +7 1 +8 1 +9 1 +10 1 +11 100 +12 1000 +13 10000 +SELECT COUNT(c2) FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t1) / 2); +COUNT(c2) +7 +SELECT COUNT(c2) FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t3) / 2); +COUNT(c2) +7 +SELECT COUNT(*) FROM t1 WHERE c1 > (SELECT AVG(c1) FROM t1); +COUNT(*) +6 +SELECT COUNT(*) FROM t1 WHERE c1 > (SELECT AVG(c1) FROM t3); +COUNT(*) +6 +############################################### +# +# Table t2 has been altered to a new row format. +# The index should not be useable. +# +SELECT COUNT(*) FROM t2; +ERROR HY000: Table definition has changed, please retry transaction +SELECT * FROM t2; +ERROR HY000: Table definition has changed, please retry transaction +COMMIT; +SELECT COUNT(*) FROM t2; +COUNT(*) +10 +########## innodb_wl6742_selects.inc ########## +SELECT * FROM t1; +c1 c2 c3 c4 +1 3 1 30 +2 5 1 50 +3 7 1 70 +4 11 1 110 +5 1 1 10 +10 1 1 10 +11 100 1 1000 +12 1000 1 10000 +13 10000 1 100000 +SELECT COUNT(*) FROM t1; +COUNT(*) +9 +SELECT COUNT(*) FROM t3; +COUNT(*) +9 +SELECT COUNT(c1) FROM t1; +COUNT(c1) +9 +SELECT COUNT(c2) FROM t1; +COUNT(c2) +9 +SELECT COUNT(c3) FROM t1; +COUNT(c3) +9 +SELECT SUM(c1) FROM t1; +SUM(c1) +61 +SELECT SUM(c2) FROM t1; +SUM(c2) +11128 +SELECT AVG(c1), MAX(c1), MIN(c2), AVG(c3), SUM(c4) FROM t1; +AVG(c1) MAX(c1) MIN(c2) AVG(c3) SUM(c4) +6.7778 13 1 1.0000 111280 +SELECT AVG(c1), MAX(c1), MIN(c2), AVG(c3), SUM(c4) FROM t3; +AVG(c1) MAX(c1) MIN(c2) AVG(c3) SUM(c4) +6.7778 13 1 1.0000 111220 +SELECT c1, c2 FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t1) / 2); +c1 c2 +5 1 +10 1 +11 100 +12 1000 +13 10000 +SELECT c1, c2 FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t3) / 2); +c1 c2 +5 1 +10 1 +11 100 +12 1000 +13 10000 +SELECT COUNT(c2) FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t1) / 2); +COUNT(c2) +5 +SELECT COUNT(c2) FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t3) / 2); +COUNT(c2) +5 +SELECT COUNT(*) FROM t1 WHERE c1 > (SELECT AVG(c1) FROM t1); +COUNT(*) +4 +SELECT COUNT(*) FROM t1 WHERE c1 > (SELECT AVG(c1) FROM t3); +COUNT(*) +4 +############################################### +# +# Connection 2 +# +########## innodb_wl6742_selects.inc ########## +SELECT * FROM t1; +c1 c2 c3 c4 +1 3 1 30 +2 5 1 50 +3 7 1 70 +4 11 1 110 +5 1 1 10 +10 1 1 10 +11 100 1 1000 +12 1000 1 10000 +13 10000 1 100000 +SELECT COUNT(*) FROM t1; +COUNT(*) +9 +SELECT COUNT(*) FROM t3; +COUNT(*) +9 +SELECT COUNT(c1) FROM t1; +COUNT(c1) +9 +SELECT COUNT(c2) FROM t1; +COUNT(c2) +9 +SELECT COUNT(c3) FROM t1; +COUNT(c3) +9 +SELECT SUM(c1) FROM t1; +SUM(c1) +61 +SELECT SUM(c2) FROM t1; +SUM(c2) +11128 +SELECT AVG(c1), MAX(c1), MIN(c2), AVG(c3), SUM(c4) FROM t1; +AVG(c1) MAX(c1) MIN(c2) AVG(c3) SUM(c4) +6.7778 13 1 1.0000 111280 +SELECT AVG(c1), MAX(c1), MIN(c2), AVG(c3), SUM(c4) FROM t3; +AVG(c1) MAX(c1) MIN(c2) AVG(c3) SUM(c4) +6.7778 13 1 1.0000 111220 +SELECT c1, c2 FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t1) / 2); +c1 c2 +5 1 +10 1 +11 100 +12 1000 +13 10000 +SELECT c1, c2 FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t3) / 2); +c1 c2 +5 1 +10 1 +11 100 +12 1000 +13 10000 +SELECT COUNT(c2) FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t1) / 2); +COUNT(c2) +5 +SELECT COUNT(c2) FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t3) / 2); +COUNT(c2) +5 +SELECT COUNT(*) FROM t1 WHERE c1 > (SELECT AVG(c1) FROM t1); +COUNT(*) +4 +SELECT COUNT(*) FROM t1 WHERE c1 > (SELECT AVG(c1) FROM t3); +COUNT(*) +4 +############################################### +# +# Try COUNT(*) on a DISCARDED table. +# +CREATE TABLE t4 LIKE t1; +INSERT INTO t4 (SELECT * FROM t1); +SELECT COUNT(*) FROM t4; +COUNT(*) +9 +ALTER TABLE t4 DISCARD TABLESPACE; +SELECT COUNT(*) FROM t4; +ERROR HY000: Tablespace has been discarded for table 't4' +# +# Test the interaction of a repeatable read transaction +# to changes that happen outside its view. +# +CREATE TABLE t5 (a INT AUTO_INCREMENT PRIMARY KEY, b TEXT, aa INT, bb TEXT) Engine=InnoDB; +INSERT INTO t5(b) VALUES ("inserted by client 1"); +INSERT INTO t5(b) VALUES ("inserted by client 1"); +INSERT INTO t5(b) VALUES ("inserted by client 1"); +INSERT INTO t5(b) VALUES ("inserted by client 1"); +UPDATE t5 SET aa=a, bb=b; +CREATE TABLE t6 (a INT AUTO_INCREMENT PRIMARY KEY, b TEXT, aa INT, bb TEXT) Engine=InnoDB; +INSERT INTO t6(b) VALUES ("inserted by client 1"); +INSERT INTO t6(b) VALUES ("inserted by client 1"); +INSERT INTO t6(b) VALUES ("inserted by client 1"); +INSERT INTO t6(b) VALUES ("inserted by client 1"); +UPDATE t6 SET aa=a, bb=b; +CREATE TABLE t7 (a INT AUTO_INCREMENT PRIMARY KEY, b TEXT, aa INT, bb TEXT) Engine=InnoDB; +INSERT INTO t7(b) VALUES ("inserted by client 1"); +INSERT INTO t7(b) VALUES ("inserted by client 1"); +INSERT INTO t7(b) VALUES ("inserted by client 1"); +INSERT INTO t7(b) VALUES ("inserted by client 1"); +UPDATE t7 SET aa=a, bb=b; +BEGIN; +SELECT * FROM t5; +a b aa bb +1 inserted by client 1 1 inserted by client 1 +2 inserted by client 1 2 inserted by client 1 +3 inserted by client 1 3 inserted by client 1 +4 inserted by client 1 4 inserted by client 1 +SELECT COUNT(*) FROM t5; +COUNT(*) +4 +SELECT * FROM t6; +a b aa bb +1 inserted by client 1 1 inserted by client 1 +2 inserted by client 1 2 inserted by client 1 +3 inserted by client 1 3 inserted by client 1 +4 inserted by client 1 4 inserted by client 1 +SELECT COUNT(*) FROM t6; +COUNT(*) +4 +SELECT * FROM t7; +a b aa bb +1 inserted by client 1 1 inserted by client 1 +2 inserted by client 1 2 inserted by client 1 +3 inserted by client 1 3 inserted by client 1 +4 inserted by client 1 4 inserted by client 1 +SELECT COUNT(*) FROM t7; +COUNT(*) +4 +# +# Connection 1 +# +INSERT INTO t5(b) VALUES ("inserted by client 2"); +UPDATE t5 SET a = 10 where a = 1; +UPDATE t5 SET b = "updated by client 2" where a = 2; +DELETE FROM t5 WHERE a = 3; +SELECT * FROM t5; +a b aa bb +2 updated by client 2 2 inserted by client 1 +4 inserted by client 1 4 inserted by client 1 +5 inserted by client 2 NULL NULL +10 inserted by client 1 1 inserted by client 1 +SELECT COUNT(*) FROM t5; +COUNT(*) +4 +INSERT INTO t6(b) VALUES ("inserted by client 2"); +UPDATE t6 SET a = 10 where a = 1; +UPDATE t6 SET b = "updated by client 2" where a = 2; +DELETE FROM t6 WHERE a = 3; +SELECT * FROM t6; +a b aa bb +2 updated by client 2 2 inserted by client 1 +4 inserted by client 1 4 inserted by client 1 +5 inserted by client 2 NULL NULL +10 inserted by client 1 1 inserted by client 1 +SELECT COUNT(*) FROM t6; +COUNT(*) +4 +INSERT INTO t7(b) VALUES ("inserted by client 2"); +UPDATE t7 SET a = 10 where a = 1; +UPDATE t7 SET b = "updated by client 2" where a = 2; +DELETE FROM t7 WHERE a = 3; +SELECT * FROM t7; +a b aa bb +2 updated by client 2 2 inserted by client 1 +4 inserted by client 1 4 inserted by client 1 +5 inserted by client 2 NULL NULL +10 inserted by client 1 1 inserted by client 1 +SELECT COUNT(*) FROM t7; +COUNT(*) +4 +# +# Connection default +# +SELECT * FROM t5; +a b aa bb +1 inserted by client 1 1 inserted by client 1 +2 inserted by client 1 2 inserted by client 1 +3 inserted by client 1 3 inserted by client 1 +4 inserted by client 1 4 inserted by client 1 +INSERT INTO t5(b) VALUES ("inserted by client 1"); +SELECT * FROM t5; +a b aa bb +1 inserted by client 1 1 inserted by client 1 +2 inserted by client 1 2 inserted by client 1 +3 inserted by client 1 3 inserted by client 1 +4 inserted by client 1 4 inserted by client 1 +11 inserted by client 1 NULL NULL +UPDATE t5 SET a = a + 100; +SELECT * FROM t5; +a b aa bb +1 inserted by client 1 1 inserted by client 1 +3 inserted by client 1 3 inserted by client 1 +102 updated by client 2 2 inserted by client 1 +104 inserted by client 1 4 inserted by client 1 +105 inserted by client 2 NULL NULL +110 inserted by client 1 1 inserted by client 1 +111 inserted by client 1 NULL NULL +SELECT COUNT(*) FROM t5; +COUNT(*) +7 +UPDATE t6 SET b = "updated by client 2"; +SELECT * FROM t6; +a b aa bb +1 inserted by client 1 1 inserted by client 1 +2 updated by client 2 2 inserted by client 1 +3 inserted by client 1 3 inserted by client 1 +4 updated by client 2 4 inserted by client 1 +5 updated by client 2 NULL NULL +10 updated by client 2 1 inserted by client 1 +SELECT COUNT(*) FROM t6; +COUNT(*) +6 +DELETE FROM t7; +SELECT * FROM t7; +a b aa bb +1 inserted by client 1 1 inserted by client 1 +3 inserted by client 1 3 inserted by client 1 +SELECT COUNT(*) FROM t7; +COUNT(*) +2 +COMMIT; +SELECT * FROM t5; +a b aa bb +102 updated by client 2 2 inserted by client 1 +104 inserted by client 1 4 inserted by client 1 +105 inserted by client 2 NULL NULL +110 inserted by client 1 1 inserted by client 1 +111 inserted by client 1 NULL NULL +SELECT COUNT(*) FROM t5; +COUNT(*) +5 +SELECT * FROM t6; +a b aa bb +2 updated by client 2 2 inserted by client 1 +4 updated by client 2 4 inserted by client 1 +5 updated by client 2 NULL NULL +10 updated by client 2 1 inserted by client 1 +SELECT COUNT(*) FROM t6; +COUNT(*) +4 +SELECT * FROM t7; +a b aa bb +SELECT COUNT(*) FROM t7; +COUNT(*) +0 +# +# Cleanup +# +DROP TABLE t1,t2,t3,t4,t5,t6,t7; +# +# Bug #23596760: FORCE INDEX IS SKIPPED WHILE EXECUTING SELECT COUNT(*) +# +CREATE TABLE t1(c1 INT NOT NULL PRIMARY KEY, +c2 INT NOT NULL DEFAULT 1, +c3 char(20) DEFAULT '', +KEY c2_idx (c2)); +INSERT INTO t1(c1) VALUES (1), (2), (3); +INSERT INTO t1(c1) SELECT c1 + 10 FROM t1; +INSERT INTO t1(c1) SELECT c1 + 100 FROM t1; +CREATE TABLE t2 SELECT * FROM t1; +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN SELECT COUNT(*) FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index NULL c2_idx 4 NULL # 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` +EXPLAIN SELECT COUNT(*) FROM t1 FORCE INDEX(c2_idx); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index NULL c2_idx 4 NULL # 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` FORCE INDEX (`c2_idx`) +EXPLAIN SELECT COUNT(*) FROM t1, t2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index NULL c2_idx 4 NULL # 100.00 Using index +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL # 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` join `test`.`t2` +EXPLAIN SELECT COUNT(*) FROM t1 FORCE INDEX(c2_idx), t2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index NULL c2_idx 4 NULL # 100.00 Using index +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL # 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` FORCE INDEX (`c2_idx`) join `test`.`t2` +DROP TABLE t1, t2; diff --git a/mysql-test/suite/skip_scan.result-pq b/mysql-test/suite/skip_scan.result-pq new file mode 100644 index 000000000000..6930beb291d4 --- /dev/null +++ b/mysql-test/suite/skip_scan.result-pq @@ -0,0 +1,1225 @@ +CREATE TABLE t (a INT, b INT, c INT, d INT, e INT, PRIMARY KEY(a, b, c, d), KEY(b, d)) ENGINE=innodb; +# Since ANALYZE TABLE only reads a subset of the data, the statistics for +# table t depends on the row order. And since the INSERT INTO ... SELECT +# may be executed using different execution plans, we've added ORDER BY +# to ensure that we rows has the same order every time. If not, the +# estimated number of rows in EXPLAIN may change on different platforms. +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +SET optimizer_switch = 'skip_scan=on'; +SET optimizer_trace="enabled=on,one_line=off"; +EXPLAIN SELECT a, b, c, d FROM t WHERE a = 2 AND d >= 98 AND e = 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 250 3.33 Parallel execute (1 workers) +2 SIMPLE t NULL ref PRIMARY PRIMARY 4 const 250 3.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,`test`.`t`.`c` AS `c`,`test`.`t`.`d` AS `d` from `test`.`t` where ((`test`.`t`.`e` = 2) and (`test`.`t`.`a` = 2) and (`test`.`t`.`d` >= 98)) +SELECT count(*) FROM information_schema.optimizer_trace WHERE trace LIKE '%query_references_nonkey_column%'; +count(*) +1 +EXPLAIN SELECT a, b, c, d FROM t WHERE a = 5 OR b = 2 AND d >= 98; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL index_merge PRIMARY,b b,PRIMARY 8,4 NULL 251 100.00 Using sort_union(b,PRIMARY); Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,`test`.`t`.`c` AS `c`,`test`.`t`.`d` AS `d` from `test`.`t` where ((`test`.`t`.`a` = 5) or ((`test`.`t`.`b` = 2) and (`test`.`t`.`d` >= 98))) +SELECT count(*) FROM information_schema.optimizer_trace WHERE trace LIKE '%disjuntive_predicate_present%'; +count(*) +1 +EXPLAIN SELECT a, b, c, d FROM t WHERE a = 5 OR b = 2 OR d >= 98; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2500 52.00 Parallel execute (4 workers) +2 SIMPLE t NULL index PRIMARY,b b 8 NULL 2500 52.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,`test`.`t`.`c` AS `c`,`test`.`t`.`d` AS `d` from `test`.`t` where ((`test`.`t`.`a` = 5) or (`test`.`t`.`b` = 2) or (`test`.`t`.`d` >= 98)) +SELECT count(*) FROM information_schema.optimizer_trace WHERE trace LIKE '%disjuntive_predicate_present%'; +count(*) +1 +EXPLAIN SELECT a, b, c, d FROM t WHERE a = 5 OR d >= 98; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2500 40.00 Parallel execute (4 workers) +2 SIMPLE t NULL index PRIMARY b 8 NULL 2500 40.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,`test`.`t`.`c` AS `c`,`test`.`t`.`d` AS `d` from `test`.`t` where ((`test`.`t`.`a` = 5) or (`test`.`t`.`d` >= 98)) +SELECT count(*) FROM information_schema.optimizer_trace WHERE trace LIKE '%disjuntive_predicate_present%'; +count(*) +1 +EXPLAIN SELECT a, b, c, d FROM t WHERE ((a = 5 AND b = 2) OR a = 2) and d >= 98; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 300 33.33 Parallel execute (2 workers) +2 SIMPLE t NULL range PRIMARY,b PRIMARY 8 NULL 300 33.33 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,`test`.`t`.`c` AS `c`,`test`.`t`.`d` AS `d` from `test`.`t` where ((((`test`.`t`.`b` = 2) and (`test`.`t`.`a` = 5)) or (`test`.`t`.`a` = 2)) and (`test`.`t`.`d` >= 98)) +SELECT count(*) FROM information_schema.optimizer_trace WHERE trace LIKE '%keypart_in_disjunctive_query%'; +count(*) +1 +EXPLAIN SELECT a, b, c, d FROM t WHERE a > 2 AND d >= 98; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range PRIMARY,b b 8 NULL 833 80.00 Using where; Using index for skip scan +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,`test`.`t`.`c` AS `c`,`test`.`t`.`d` AS `d` from `test`.`t` where ((`test`.`t`.`a` > 2) and (`test`.`t`.`d` >= 98)) +SELECT count(*) FROM information_schema.optimizer_trace WHERE trace LIKE '%prefix_not_const_equality%'; +count(*) +1 +EXPLAIN SELECT a, b, c, d FROM t WHERE a = 2 AND (d >= 98 OR d < 2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 250 55.55 Parallel execute (1 workers) +2 SIMPLE t NULL ref PRIMARY PRIMARY 4 const 250 55.55 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,`test`.`t`.`c` AS `c`,`test`.`t`.`d` AS `d` from `test`.`t` where ((`test`.`t`.`a` = 2) and ((`test`.`t`.`d` >= 98) or (`test`.`t`.`d` < 2))) +SELECT count(*) FROM information_schema.optimizer_trace WHERE trace LIKE '%range_predicate_too_complex%'; +count(*) +1 +EXPLAIN SELECT a, b, c, d FROM t WHERE a = 2 AND b = 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 50 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ref PRIMARY,b PRIMARY 8 const,const 50 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,`test`.`t`.`c` AS `c`,`test`.`t`.`d` AS `d` from `test`.`t` where ((`test`.`t`.`b` = 2) and (`test`.`t`.`a` = 2)) +SELECT count(*) FROM information_schema.optimizer_trace WHERE trace LIKE '%no_range_predicate%'; +count(*) +1 +EXPLAIN SELECT a, b, c, d FROM t WHERE (a < 1 OR a = 4 OR a = 5) AND b IN (1, 2, 3) AND d >= 98; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 46.00 Parallel execute (3 workers) +2 SIMPLE t NULL range PRIMARY,b b 8 NULL 3 46.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,`test`.`t`.`c` AS `c`,`test`.`t`.`d` AS `d` from `test`.`t` where (((`test`.`t`.`a` < 1) or (`test`.`t`.`a` = 4) or (`test`.`t`.`a` = 5)) and (`test`.`t`.`b` in (1,2,3)) and (`test`.`t`.`d` >= 98)) +SELECT count(*) FROM information_schema.optimizer_trace WHERE trace LIKE '%prefix_not_const_equality%'; +count(*) +1 +EXPLAIN SELECT a, b, c, d FROM t WHERE a IN (1, 2, 3, 4, 5) AND b IN (1, 2, 3) AND d >= 98; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 50.00 Parallel execute (3 workers) +2 SIMPLE t NULL range PRIMARY,b b 12 NULL 3 50.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,`test`.`t`.`c` AS `c`,`test`.`t`.`d` AS `d` from `test`.`t` where ((`test`.`t`.`a` in (1,2,3,4,5)) and (`test`.`t`.`b` in (1,2,3)) and (`test`.`t`.`d` >= 98)) +SELECT * FROM information_schema.optimizer_trace; +QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES +EXPLAIN SELECT a, b, c, d FROM t WHERE a IN (1, 2, 3, 4, 5) AND b IN (1, 2, 3) AND d >= 98 { + "steps": [ + { + "join_preparation": { + "select#": 1, + "steps": [ + { + "IN_uses_bisection": true + }, + { + "IN_uses_bisection": true + }, + { + "expanded_query": "/* select#1 */ select `t`.`a` AS `a`,`t`.`b` AS `b`,`t`.`c` AS `c`,`t`.`d` AS `d` from `t` where ((`t`.`a` in (1,2,3,4,5)) and (`t`.`b` in (1,2,3)) and (`t`.`d` >= 98))" + } + ] + } + }, + { + "join_optimization": { + "select#": 1, + "steps": [ + { + "condition_processing": { + "condition": "WHERE", + "original_condition": "((`t`.`a` in (1,2,3,4,5)) and (`t`.`b` in (1,2,3)) and (`t`.`d` >= 98))", + "steps": [ + { + "transformation": "equality_propagation", + "resulting_condition": "((`t`.`a` in (1,2,3,4,5)) and (`t`.`b` in (1,2,3)) and (`t`.`d` >= 98))" + }, + { + "transformation": "constant_propagation", + "resulting_condition": "((`t`.`a` in (1,2,3,4,5)) and (`t`.`b` in (1,2,3)) and (`t`.`d` >= 98))" + }, + { + "transformation": "trivial_condition_removal", + "resulting_condition": "((`t`.`a` in (1,2,3,4,5)) and (`t`.`b` in (1,2,3)) and (`t`.`d` >= 98))" + } + ] + } + }, + { + "substitute_generated_columns": { + } + }, + { + "table_dependencies": [ + { + "table": "`t`", + "row_may_be_null": false, + "map_bit": 0, + "depends_on_map_bits": [ + ] + } + ] + }, + { + "ref_optimizer_key_uses": [ + ] + }, + { + "rows_estimation": [ + { + "table": "`t`", + "range_analysis": { + "table_scan": { + "rows": 2500, + "cost": 254.1 + }, + "potential_range_indexes": [ + { + "index": "PRIMARY", + "usable": true, + "key_parts": [ + "a", + "b", + "c", + "d" + ] + }, + { + "index": "b", + "usable": true, + "key_parts": [ + "b", + "d", + "a", + "c" + ] + } + ], + "best_covering_index_scan": { + "index": "b", + "cost": 252.077, + "chosen": true + }, + "setup_range_conditions": [ + ], + "group_index_range": { + "chosen": false, + "cause": "not_group_by_or_distinct" + }, + "skip_scan_range": { + "potential_skip_scan_indexes": [ + { + "index": "PRIMARY", + "tree_travel_cost": 0.6, + "num_groups": 76, + "rows": 249, + "cost": 129.041 + }, + { + "index": "b", + "usable": false, + "cause": "prefix_not_const_equality" + } + ] + }, + "best_skip_scan_summary": { + "type": "skip_scan", + "index": "PRIMARY", + "key_parts_used_for_access": [ + "a", + "b", + "c", + "d" + ], + "prefix ranges": [ + "1 <= a <= 1 AND 1 <= b <= 1", + "1 <= a <= 1 AND 2 <= b <= 2", + "1 <= a <= 1 AND 3 <= b <= 3", + "2 <= a <= 2 AND 1 <= b <= 1", + "2 <= a <= 2 AND 2 <= b <= 2", + "2 <= a <= 2 AND 3 <= b <= 3", + "3 <= a <= 3 AND 1 <= b <= 1", + "3 <= a <= 3 AND 2 <= b <= 2", + "3 <= a <= 3 AND 3 <= b <= 3", + "4 <= a <= 4 AND 1 <= b <= 1", + "4 <= a <= 4 AND 2 <= b <= 2", + "4 <= a <= 4 AND 3 <= b <= 3", + "5 <= a <= 5 AND 1 <= b <= 1", + "5 <= a <= 5 AND 2 <= b <= 2", + "5 <= a <= 5 AND 3 <= b <= 3" + ], + "range": [ + "98 <= d" + ], + "chosen": true + }, + "analyzing_range_alternatives": { + "range_scan_alternatives": [ + { + "index": "PRIMARY", + "ranges": [ + "1 <= a <= 1 AND 1 <= b <= 1", + "1 <= a <= 1 AND 2 <= b <= 2", + "1 <= a <= 1 AND 3 <= b <= 3", + "2 <= a <= 2 AND 1 <= b <= 1", + "2 <= a <= 2 AND 2 <= b <= 2", + "2 <= a <= 2 AND 3 <= b <= 3", + "3 <= a <= 3 AND 1 <= b <= 1", + "3 <= a <= 3 AND 2 <= b <= 2", + "3 <= a <= 3 AND 3 <= b <= 3", + "4 <= a <= 4 AND 1 <= b <= 1", + "4 <= a <= 4 AND 2 <= b <= 2", + "4 <= a <= 4 AND 3 <= b <= 3", + "5 <= a <= 5 AND 1 <= b <= 1", + "5 <= a <= 5 AND 2 <= b <= 2", + "5 <= a <= 5 AND 3 <= b <= 3" + ], + "index_dives_for_eq_ranges": true, + "rowid_ordered": true, + "using_mrr": false, + "index_only": true, + "rows": 750, + "cost": 79.0151, + "chosen": true + }, + { + "index": "b", + "ranges": [ + "1 <= b <= 1 AND 98 <= d", + "2 <= b <= 2 AND 98 <= d", + "3 <= b <= 3 AND 98 <= d" + ], + "index_dives_for_eq_ranges": true, + "rowid_ordered": false, + "using_mrr": false, + "index_only": true, + "rows": 3, + "cost": 0.561462, + "chosen": true + } + ], + "analyzing_roworder_intersect": { + "usable": false, + "cause": "too_few_roworder_scans" + } + }, + "chosen_range_access_summary": { + "range_access_plan": { + "type": "range_scan", + "index": "b", + "rows": 3, + "ranges": [ + "1 <= b <= 1 AND 98 <= d", + "2 <= b <= 2 AND 98 <= d", + "3 <= b <= 3 AND 98 <= d" + ] + }, + "rows_for_plan": 3, + "cost_for_plan": 0.561462, + "chosen": true + } + } + } + ] + }, + { + "considered_execution_plans": [ + { + "plan_prefix": [ + ], + "table": "`t`", + "best_access_path": { + "considered_access_paths": [ + { + "rows_to_scan": 3, + "filtering_effect": [ + ], + "final_filtering_effect": 0.5, + "access_type": "range", + "range_details": { + "used_index": "b" + }, + "resulting_rows": 1.5, + "cost": 0.861462, + "chosen": true + } + ] + }, + "condition_filtering_pct": 100, + "rows_for_plan": 1.5, + "cost_for_plan": 0.861462, + "chosen": true + } + ] + }, + { + "attaching_conditions_to_tables": { + "original_condition": "((`t`.`a` in (1,2,3,4,5)) and (`t`.`b` in (1,2,3)) and (`t`.`d` >= 98))", + "attached_conditions_computation": [ + ], + "attached_conditions_summary": [ + { + "table": "`t`", + "attached": "((`t`.`a` in (1,2,3,4,5)) and (`t`.`b` in (1,2,3)) and (`t`.`d` >= 98))" + } + ] + } + }, + { + "finalizing_table_conditions": [ + { + "table": "`t`", + "original_table_condition": "((`t`.`a` in (1,2,3,4,5)) and (`t`.`b` in (1,2,3)) and (`t`.`d` >= 98))", + "final_table_condition ": "((`t`.`a` in (1,2,3,4,5)) and (`t`.`b` in (1,2,3)) and (`t`.`d` >= 98))" + } + ] + }, + { + "refine_plan": [ + { + "table": "`t`" + } + ] + } + ] + } + }, + { + "make_parallel_query_plan": { + "select#": 1, + "detail": [ + { + "table": "`t`", + "degree of parallel": 4 + } + ] + } + }, + { + "join_explain": { + "select#": 1, + "steps": [ + ] + } + } + ] +} 0 0 +EXPLAIN SELECT b, c, d FROM t WHERE a = 5 AND c > 4 AND d < 3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range PRIMARY,b PRIMARY 12 NULL 83 33.33 Using where; Using index for skip scan +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`b` AS `b`,`test`.`t`.`c` AS `c`,`test`.`t`.`d` AS `d` from `test`.`t` where ((`test`.`t`.`a` = 5) and (`test`.`t`.`c` > 4) and (`test`.`t`.`d` < 3)) +SELECT * FROM information_schema.optimizer_trace; +QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES +EXPLAIN SELECT b, c, d FROM t WHERE a = 5 AND c > 4 AND d < 3 { + "steps": [ + { + "join_preparation": { + "select#": 1, + "steps": [ + { + "expanded_query": "/* select#1 */ select `t`.`b` AS `b`,`t`.`c` AS `c`,`t`.`d` AS `d` from `t` where ((`t`.`a` = 5) and (`t`.`c` > 4) and (`t`.`d` < 3))" + } + ] + } + }, + { + "join_optimization": { + "select#": 1, + "steps": [ + { + "condition_processing": { + "condition": "WHERE", + "original_condition": "((`t`.`a` = 5) and (`t`.`c` > 4) and (`t`.`d` < 3))", + "steps": [ + { + "transformation": "equality_propagation", + "resulting_condition": "((`t`.`c` > 4) and (`t`.`d` < 3) and multiple equal(5, `t`.`a`))" + }, + { + "transformation": "constant_propagation", + "resulting_condition": "((`t`.`c` > 4) and (`t`.`d` < 3) and multiple equal(5, `t`.`a`))" + }, + { + "transformation": "trivial_condition_removal", + "resulting_condition": "((`t`.`c` > 4) and (`t`.`d` < 3) and multiple equal(5, `t`.`a`))" + } + ] + } + }, + { + "substitute_generated_columns": { + } + }, + { + "table_dependencies": [ + { + "table": "`t`", + "row_may_be_null": false, + "map_bit": 0, + "depends_on_map_bits": [ + ] + } + ] + }, + { + "ref_optimizer_key_uses": [ + { + "table": "`t`", + "field": "a", + "equals": "5", + "null_rejecting": true + } + ] + }, + { + "rows_estimation": [ + { + "table": "`t`", + "range_analysis": { + "table_scan": { + "rows": 2500, + "cost": 254.1 + }, + "potential_range_indexes": [ + { + "index": "PRIMARY", + "usable": true, + "key_parts": [ + "a", + "b", + "c", + "d" + ] + }, + { + "index": "b", + "usable": true, + "key_parts": [ + "b", + "d", + "a", + "c" + ] + } + ], + "best_covering_index_scan": { + "index": "b", + "cost": 252.077, + "chosen": true + }, + "setup_range_conditions": [ + ], + "group_index_range": { + "chosen": false, + "cause": "not_group_by_or_distinct" + }, + "skip_scan_range": { + "potential_skip_scan_indexes": [ + { + "index": "PRIMARY", + "tree_travel_cost": 0.6, + "num_groups": 6, + "rows": 83, + "cost": 19.9798 + }, + { + "index": "b", + "tree_travel_cost": 0.6, + "num_groups": 6, + "rows": 833, + "cost": 133.008 + } + ] + }, + "best_skip_scan_summary": { + "type": "skip_scan", + "index": "PRIMARY", + "key_parts_used_for_access": [ + "a", + "b", + "c" + ], + "prefix ranges": [ + "5 <= a <= 5" + ], + "range": [ + "4 < c" + ], + "chosen": true + }, + "analyzing_range_alternatives": { + "range_scan_alternatives": [ + { + "index": "PRIMARY", + "ranges": [ + "5 <= a <= 5" + ], + "index_dives_for_eq_ranges": true, + "rowid_ordered": true, + "using_mrr": false, + "index_only": true, + "rows": 250, + "cost": 25.345, + "chosen": false, + "cause": "cost" + }, + { + "index": "b", + "chosen": false, + "cause": "no_valid_range_for_this_index" + } + ], + "analyzing_roworder_intersect": { + "usable": false, + "cause": "too_few_roworder_scans" + } + }, + "chosen_range_access_summary": { + "range_access_plan": { + "type": "skip_scan", + "index": "PRIMARY", + "key_parts_used_for_access": [ + "a", + "b", + "c" + ], + "prefix ranges": [ + "5 <= a <= 5" + ], + "range": [ + "4 < c" + ] + }, + "rows_for_plan": 83, + "cost_for_plan": 19.9798, + "chosen": true + } + } + } + ] + }, + { + "considered_execution_plans": [ + { + "plan_prefix": [ + ], + "table": "`t`", + "best_access_path": { + "considered_access_paths": [ + { + "access_type": "ref", + "index": "PRIMARY", + "rows": 250, + "cost": 25.4922, + "chosen": true + }, + { + "rows_to_scan": 83, + "filtering_effect": [ + ], + "final_filtering_effect": 0.3333, + "access_type": "range", + "range_details": { + "used_index": "index_for_skip_scan(PRIMARY)" + }, + "resulting_rows": 27.6639, + "cost": 28.2798, + "chosen": false + } + ] + }, + "condition_filtering_pct": 11.1089, + "rows_for_plan": 27.7722, + "cost_for_plan": 25.4922, + "chosen": true + } + ] + }, + { + "access_type_changed": { + "table": "`t`", + "index": "PRIMARY", + "old_type": "ref", + "new_type": "range", + "cause": "uses_more_keyparts" + } + }, + { + "attaching_conditions_to_tables": { + "original_condition": "((`t`.`a` = 5) and (`t`.`c` > 4) and (`t`.`d` < 3))", + "attached_conditions_computation": [ + ], + "attached_conditions_summary": [ + { + "table": "`t`", + "attached": "((`t`.`a` = 5) and (`t`.`c` > 4) and (`t`.`d` < 3))" + } + ] + } + }, + { + "finalizing_table_conditions": [ + { + "table": "`t`", + "original_table_condition": "((`t`.`a` = 5) and (`t`.`c` > 4) and (`t`.`d` < 3))", + "final_table_condition ": "((`t`.`a` = 5) and (`t`.`c` > 4) and (`t`.`d` < 3))" + } + ] + }, + { + "refine_plan": [ + { + "table": "`t`" + } + ] + } + ] + } + }, + { + "join_explain": { + "select#": 1, + "steps": [ + ] + } + } + ] +} 0 0 +EXPLAIN SELECT b, c, d FROM t WHERE a = 5 AND d < 3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 250 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ref PRIMARY,b PRIMARY 4 const 250 33.33 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`b` AS `b`,`test`.`t`.`c` AS `c`,`test`.`t`.`d` AS `d` from `test`.`t` where ((`test`.`t`.`a` = 5) and (`test`.`t`.`d` < 3)) +SELECT * FROM information_schema.optimizer_trace; +QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES +EXPLAIN SELECT b, c, d FROM t WHERE a = 5 AND d < 3 { + "steps": [ + { + "join_preparation": { + "select#": 1, + "steps": [ + { + "expanded_query": "/* select#1 */ select `t`.`b` AS `b`,`t`.`c` AS `c`,`t`.`d` AS `d` from `t` where ((`t`.`a` = 5) and (`t`.`d` < 3))" + } + ] + } + }, + { + "join_optimization": { + "select#": 1, + "steps": [ + { + "condition_processing": { + "condition": "WHERE", + "original_condition": "((`t`.`a` = 5) and (`t`.`d` < 3))", + "steps": [ + { + "transformation": "equality_propagation", + "resulting_condition": "((`t`.`d` < 3) and multiple equal(5, `t`.`a`))" + }, + { + "transformation": "constant_propagation", + "resulting_condition": "((`t`.`d` < 3) and multiple equal(5, `t`.`a`))" + }, + { + "transformation": "trivial_condition_removal", + "resulting_condition": "((`t`.`d` < 3) and multiple equal(5, `t`.`a`))" + } + ] + } + }, + { + "substitute_generated_columns": { + } + }, + { + "table_dependencies": [ + { + "table": "`t`", + "row_may_be_null": false, + "map_bit": 0, + "depends_on_map_bits": [ + ] + } + ] + }, + { + "ref_optimizer_key_uses": [ + { + "table": "`t`", + "field": "a", + "equals": "5", + "null_rejecting": true + } + ] + }, + { + "rows_estimation": [ + { + "table": "`t`", + "range_analysis": { + "table_scan": { + "rows": 2500, + "cost": 254.1 + }, + "potential_range_indexes": [ + { + "index": "PRIMARY", + "usable": true, + "key_parts": [ + "a", + "b", + "c", + "d" + ] + }, + { + "index": "b", + "usable": true, + "key_parts": [ + "b", + "d", + "a", + "c" + ] + } + ], + "best_covering_index_scan": { + "index": "b", + "cost": 252.077, + "chosen": true + }, + "setup_range_conditions": [ + ], + "group_index_range": { + "chosen": false, + "cause": "not_group_by_or_distinct" + }, + "skip_scan_range": { + "potential_skip_scan_indexes": [ + { + "index": "PRIMARY", + "tree_travel_cost": 0.6, + "num_groups": 26, + "rows": 83, + "cost": 43.9798 + }, + { + "index": "b", + "tree_travel_cost": 0.6, + "num_groups": 6, + "rows": 833, + "cost": 133.008 + } + ] + }, + "best_skip_scan_summary": { + "type": "skip_scan", + "index": "PRIMARY", + "key_parts_used_for_access": [ + "a", + "b", + "c", + "d" + ], + "prefix ranges": [ + "5 <= a <= 5" + ], + "range": [ + "d < 3" + ], + "chosen": true + }, + "analyzing_range_alternatives": { + "range_scan_alternatives": [ + { + "index": "PRIMARY", + "ranges": [ + "5 <= a <= 5" + ], + "index_dives_for_eq_ranges": true, + "rowid_ordered": true, + "using_mrr": false, + "index_only": true, + "rows": 250, + "cost": 25.345, + "chosen": true + }, + { + "index": "b", + "chosen": false, + "cause": "no_valid_range_for_this_index" + } + ], + "analyzing_roworder_intersect": { + "usable": false, + "cause": "too_few_roworder_scans" + } + }, + "chosen_range_access_summary": { + "range_access_plan": { + "type": "range_scan", + "index": "PRIMARY", + "rows": 250, + "ranges": [ + "5 <= a <= 5" + ] + }, + "rows_for_plan": 250, + "cost_for_plan": 25.345, + "chosen": true + } + } + } + ] + }, + { + "considered_execution_plans": [ + { + "plan_prefix": [ + ], + "table": "`t`", + "best_access_path": { + "considered_access_paths": [ + { + "access_type": "ref", + "index": "PRIMARY", + "rows": 250, + "cost": 25.4922, + "chosen": true + }, + { + "access_type": "range", + "range_details": { + "used_index": "PRIMARY" + }, + "chosen": false, + "cause": "heuristic_index_cheaper" + } + ] + }, + "condition_filtering_pct": 33.33, + "rows_for_plan": 83.325, + "cost_for_plan": 25.4922, + "chosen": true + } + ] + }, + { + "attaching_conditions_to_tables": { + "original_condition": "((`t`.`a` = 5) and (`t`.`d` < 3))", + "attached_conditions_computation": [ + ], + "attached_conditions_summary": [ + { + "table": "`t`", + "attached": "((`t`.`a` = 5) and (`t`.`d` < 3))" + } + ] + } + }, + { + "finalizing_table_conditions": [ + { + "table": "`t`", + "original_table_condition": "((`t`.`a` = 5) and (`t`.`d` < 3))", + "final_table_condition ": "(`t`.`d` < 3)" + } + ] + }, + { + "refine_plan": [ + { + "table": "`t`" + } + ] + } + ] + } + }, + { + "make_parallel_query_plan": { + "select#": 1, + "detail": [ + { + "table": "`t`", + "degree of parallel": 4 + } + ] + } + }, + { + "join_explain": { + "select#": 1, + "steps": [ + ] + } + } + ] +} 0 0 +ANALYZE TABLE t UPDATE HISTOGRAM ON d WITH 10 BUCKETS; +Table Op Msg_type Msg_text +test.t histogram status Histogram statistics created for column 'd'. +EXPLAIN SELECT b FROM t WHERE d < 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range PRIMARY,b b 8 NULL 250 100.00 Using where; Using index for skip scan +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`b` AS `b` from `test`.`t` where (`test`.`t`.`d` < 2) +SELECT * FROM information_schema.optimizer_trace; +QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES +EXPLAIN SELECT b FROM t WHERE d < 2 { + "steps": [ + { + "join_preparation": { + "select#": 1, + "steps": [ + { + "expanded_query": "/* select#1 */ select `t`.`b` AS `b` from `t` where (`t`.`d` < 2)" + } + ] + } + }, + { + "join_optimization": { + "select#": 1, + "steps": [ + { + "condition_processing": { + "condition": "WHERE", + "original_condition": "(`t`.`d` < 2)", + "steps": [ + { + "transformation": "equality_propagation", + "resulting_condition": "(`t`.`d` < 2)" + }, + { + "transformation": "constant_propagation", + "resulting_condition": "(`t`.`d` < 2)" + }, + { + "transformation": "trivial_condition_removal", + "resulting_condition": "(`t`.`d` < 2)" + } + ] + } + }, + { + "substitute_generated_columns": { + } + }, + { + "table_dependencies": [ + { + "table": "`t`", + "row_may_be_null": false, + "map_bit": 0, + "depends_on_map_bits": [ + ] + } + ] + }, + { + "ref_optimizer_key_uses": [ + ] + }, + { + "rows_estimation": [ + { + "table": "`t`", + "range_analysis": { + "table_scan": { + "rows": 2500, + "cost": 254.1 + }, + "potential_range_indexes": [ + { + "index": "PRIMARY", + "usable": true, + "key_parts": [ + "a", + "b", + "c", + "d" + ] + }, + { + "index": "b", + "usable": true, + "key_parts": [ + "b", + "d", + "a", + "c" + ] + } + ], + "best_covering_index_scan": { + "index": "b", + "cost": 252.077, + "chosen": true + }, + "setup_range_conditions": [ + ], + "group_index_range": { + "chosen": false, + "cause": "not_group_by_or_distinct" + }, + "skip_scan_range": { + "potential_skip_scan_indexes": [ + { + "index": "PRIMARY", + "histogram_selectivity": { + "condition": "(`t`.`d` < 2)", + "histogram_selectivity": 0.1 + }, + "tree_travel_cost": 0.6, + "num_groups": 251, + "rows": 250, + "cost": 339.192 + }, + { + "index": "b", + "histogram_selectivity": { + "condition": "(`t`.`d` < 2)", + "histogram_selectivity": 0.1 + }, + "tree_travel_cost": 0.6, + "num_groups": 6, + "rows": 250, + "cost": 45.132 + } + ] + }, + "best_skip_scan_summary": { + "type": "skip_scan", + "index": "b", + "key_parts_used_for_access": [ + "b", + "d" + ], + "range": [ + "d < 2" + ], + "chosen": true + }, + "analyzing_range_alternatives": { + "range_scan_alternatives": [ + { + "index": "PRIMARY", + "chosen": false, + "cause": "no_valid_range_for_this_index" + }, + { + "index": "b", + "chosen": false, + "cause": "no_valid_range_for_this_index" + } + ], + "analyzing_roworder_intersect": { + "usable": false, + "cause": "too_few_roworder_scans" + } + }, + "chosen_range_access_summary": { + "range_access_plan": { + "type": "skip_scan", + "index": "b", + "key_parts_used_for_access": [ + "b", + "d" + ], + "range": [ + "d < 2" + ] + }, + "rows_for_plan": 250, + "cost_for_plan": 45.132, + "chosen": true + } + } + } + ] + }, + { + "considered_execution_plans": [ + { + "plan_prefix": [ + ], + "table": "`t`", + "best_access_path": { + "considered_access_paths": [ + { + "rows_to_scan": 250, + "filtering_effect": [ + ], + "final_filtering_effect": 1, + "access_type": "range", + "range_details": { + "used_index": "index_for_skip_scan(b)" + }, + "resulting_rows": 250, + "cost": 70.132, + "chosen": true + } + ] + }, + "condition_filtering_pct": 100, + "rows_for_plan": 250, + "cost_for_plan": 70.132, + "chosen": true + } + ] + }, + { + "attaching_conditions_to_tables": { + "original_condition": "(`t`.`d` < 2)", + "attached_conditions_computation": [ + ], + "attached_conditions_summary": [ + { + "table": "`t`", + "attached": "(`t`.`d` < 2)" + } + ] + } + }, + { + "finalizing_table_conditions": [ + { + "table": "`t`", + "original_table_condition": "(`t`.`d` < 2)", + "final_table_condition ": "(`t`.`d` < 2)" + } + ] + }, + { + "refine_plan": [ + { + "table": "`t`" + } + ] + } + ] + } + }, + { + "join_explain": { + "select#": 1, + "steps": [ + ] + } + } + ] +} 0 0 +SET optimizer_trace="enabled=off"; +DROP TABLE t; +SET optimizer_switch = 'skip_scan=on'; +SET optimizer_trace="enabled=on,one_line=off"; +CREATE TABLE t1 (f1 VARCHAR(10), f2 CHAR(10), f3 INT, KEY(f1, f2, f3)); +INSERT INTO t1 VALUES ('a', 'aaaa', 1); +EXPLAIN SELECT /*+ SKIP_SCAN(t1) */ count(*) FROM t1 WHERE f1 BETWEEN 'a' and 'a ' AND f3 > 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index f1 f1 89 NULL 1 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select /*+ SKIP_SCAN(`t1`@`select#1`) */ count(0) AS `count(*)` from `test`.`t1` where ((`test`.`t1`.`f1` between 'a' and 'a ') and (`test`.`t1`.`f3` > 0)) +SELECT count(*) FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE WHERE trace LIKE '%prefix_not_const_equality%'; +count(*) +1 +DROP TABLE t1; +SET optimizer_trace="enabled=off"; diff --git a/mysql-test/suite/start_server_low_table_lock.result-pq b/mysql-test/suite/start_server_low_table_lock.result-pq new file mode 100644 index 000000000000..8f04ad4033da --- /dev/null +++ b/mysql-test/suite/start_server_low_table_lock.result-pq @@ -0,0 +1,207 @@ +show databases; +Database +information_schema +mtr +mysql +performance_schema +sys +test +select count(*) from performance_schema.performance_timers; +count(*) +4 +select count(*) from performance_schema.setup_consumers; +count(*) +15 +select count(*) > 4 from performance_schema.setup_instruments; +count(*) > 4 +1 +select * from performance_schema.accounts; +select * from performance_schema.cond_instances; +select * from performance_schema.events_stages_current; +select * from performance_schema.events_stages_history; +select * from performance_schema.events_stages_history_long; +select * from performance_schema.events_stages_summary_by_account_by_event_name; +select * from performance_schema.events_stages_summary_by_host_by_event_name; +select * from performance_schema.events_stages_summary_by_thread_by_event_name; +select * from performance_schema.events_stages_summary_by_user_by_event_name; +select * from performance_schema.events_stages_summary_global_by_event_name; +select * from performance_schema.events_statements_current; +select * from performance_schema.events_statements_histogram_by_digest; +select * from performance_schema.events_statements_histogram_global; +select * from performance_schema.events_statements_history; +select * from performance_schema.events_statements_history_long; +select * from performance_schema.events_statements_summary_by_account_by_event_name; +select * from performance_schema.events_statements_summary_by_digest; +select * from performance_schema.events_statements_summary_by_host_by_event_name; +select * from performance_schema.events_statements_summary_by_thread_by_event_name; +select * from performance_schema.events_statements_summary_by_user_by_event_name; +select * from performance_schema.events_statements_summary_global_by_event_name; +select * from performance_schema.events_transactions_current; +select * from performance_schema.events_transactions_history; +select * from performance_schema.events_transactions_history_long; +select * from performance_schema.events_transactions_summary_by_account_by_event_name; +select * from performance_schema.events_transactions_summary_by_host_by_event_name; +select * from performance_schema.events_transactions_summary_by_thread_by_event_name; +select * from performance_schema.events_transactions_summary_by_user_by_event_name; +select * from performance_schema.events_transactions_summary_global_by_event_name; +select * from performance_schema.events_waits_current; +select * from performance_schema.events_waits_history; +select * from performance_schema.events_waits_history_long; +select * from performance_schema.events_waits_summary_by_account_by_event_name; +select * from performance_schema.events_waits_summary_by_host_by_event_name; +select * from performance_schema.events_waits_summary_by_instance; +select * from performance_schema.events_waits_summary_by_thread_by_event_name; +select * from performance_schema.events_waits_summary_by_user_by_event_name; +select * from performance_schema.events_waits_summary_global_by_event_name; +select * from performance_schema.memory_summary_by_account_by_event_name; +select * from performance_schema.memory_summary_by_host_by_event_name; +select * from performance_schema.memory_summary_by_thread_by_event_name; +select * from performance_schema.memory_summary_by_user_by_event_name; +select * from performance_schema.memory_summary_global_by_event_name; +select * from performance_schema.events_errors_summary_by_account_by_error; +select * from performance_schema.events_errors_summary_by_host_by_error; +select * from performance_schema.events_errors_summary_by_thread_by_error; +select * from performance_schema.events_errors_summary_by_user_by_error; +select * from performance_schema.events_errors_summary_global_by_error; +select * from performance_schema.file_instances; +select * from performance_schema.file_summary_by_event_name; +select * from performance_schema.file_summary_by_instance; +select * from performance_schema.host_cache; +select * from performance_schema.hosts; +select * from performance_schema.memory_summary_by_account_by_event_name; +select * from performance_schema.memory_summary_by_host_by_event_name; +select * from performance_schema.memory_summary_by_thread_by_event_name; +select * from performance_schema.memory_summary_by_user_by_event_name; +select * from performance_schema.memory_summary_global_by_event_name; +select * from performance_schema.metadata_locks; +select * from performance_schema.mutex_instances; +select * from performance_schema.objects_summary_global_by_type; +select * from performance_schema.performance_timers; +select * from performance_schema.rwlock_instances; +select * from performance_schema.data_locks; +select * from performance_schema.data_lock_waits; +select * from performance_schema.session_account_connect_attrs; +select * from performance_schema.session_connect_attrs; +select * from performance_schema.setup_actors; +select * from performance_schema.setup_consumers; +select * from performance_schema.setup_instruments; +select * from performance_schema.setup_objects; +select * from performance_schema.setup_threads; +select * from performance_schema.socket_instances; +select * from performance_schema.socket_summary_by_instance; +select * from performance_schema.socket_summary_by_event_name; +select * from performance_schema.table_handles; +select * from performance_schema.table_io_waits_summary_by_index_usage; +select * from performance_schema.table_io_waits_summary_by_table; +select * from performance_schema.table_lock_waits_summary_by_table; +select * from performance_schema.threads; +select * from performance_schema.users; +select * from performance_schema.replication_connection_configuration; +select * from performance_schema.replication_connection_status; +select * from performance_schema.replication_applier_configuration; +select * from performance_schema.replication_applier_status; +select * from performance_schema.replication_applier_status_by_coordinator; +select * from performance_schema.replication_applier_status_by_worker; +select * from performance_schema.global_status; +select * from performance_schema.status_by_thread; +select * from performance_schema.status_by_user; +select * from performance_schema.status_by_host; +select * from performance_schema.status_by_account; +select * from performance_schema.session_status; +select * from performance_schema.global_variables; +select * from performance_schema.variables_by_thread; +select * from performance_schema.session_variables; +show engine PERFORMANCE_SCHEMA status; +show global status like "performance_schema%"; +drop table if exists db1.t1; +drop database if exists db1; +create database db1; +create table db1.t1 (a int, b char(10) default 'default'); +insert into db1.t1 values('1', 'abc'); +insert into db1.t1 values('2', 'abc'); +select * from db1.t1 where a='1'; +a b +1 abc +select COUNT_STAR, OBJECT_TYPE, OBJECT_SCHEMA, OBJECT_NAME +from performance_schema.table_lock_waits_summary_by_table +where OBJECT_SCHEMA='db1' + order by OBJECT_TYPE, OBJECT_SCHEMA, OBJECT_NAME; +COUNT_STAR OBJECT_TYPE OBJECT_SCHEMA OBJECT_NAME +5 TABLE db1 t1 +flush tables; +select COUNT_STAR, OBJECT_TYPE, OBJECT_SCHEMA, OBJECT_NAME +from performance_schema.table_lock_waits_summary_by_table +where OBJECT_SCHEMA='db1' + order by OBJECT_TYPE, OBJECT_SCHEMA, OBJECT_NAME; +COUNT_STAR OBJECT_TYPE OBJECT_SCHEMA OBJECT_NAME +5 TABLE db1 t1 +select variable_value from performance_schema.global_status +where variable_name like 'PERFORMANCE_SCHEMA_TABLE_LOCK_STAT_LOST'; +variable_value +0 +create table db1.t2 (a int, b char(10) default 'default', +unique key uidx(a)); +insert into db1.t1 values('3', 'abc'); +insert into db1.t1 values('4', 'abc'); +select * from db1.t1 where a='1'; +a b +1 abc +insert into db1.t2 values('1', 'abc'); +insert into db1.t2 values('2', 'abc'); +select * from db1.t2 where a='1'; +a b +1 abc +select COUNT_STAR, OBJECT_TYPE, OBJECT_SCHEMA, OBJECT_NAME +from performance_schema.table_lock_waits_summary_by_table +where OBJECT_SCHEMA='db1' + order by OBJECT_TYPE, OBJECT_SCHEMA, OBJECT_NAME; +COUNT_STAR OBJECT_TYPE OBJECT_SCHEMA OBJECT_NAME +10 TABLE db1 t1 +3 TABLE db1 t2 +flush tables; +select COUNT_STAR, OBJECT_TYPE, OBJECT_SCHEMA, OBJECT_NAME +from performance_schema.table_lock_waits_summary_by_table +where OBJECT_SCHEMA='db1' + order by OBJECT_TYPE, OBJECT_SCHEMA, OBJECT_NAME; +COUNT_STAR OBJECT_TYPE OBJECT_SCHEMA OBJECT_NAME +10 TABLE db1 t1 +0 TABLE db1 t2 +select variable_value > 0 from performance_schema.global_status +where variable_name like 'PERFORMANCE_SCHEMA_TABLE_LOCK_STAT_LOST'; +variable_value > 0 +1 +flush status; +update performance_schema.setup_objects set ENABLED='NO' + where OBJECT_TYPE='TABLE' and OBJECT_SCHEMA="%"; +insert into db1.t1 values('5', 'abc'); +insert into db1.t1 values('6', 'abc'); +select * from db1.t1 where a='1'; +a b +1 abc +insert into db1.t2 values('3', 'abc'); +insert into db1.t2 values('4', 'abc'); +select * from db1.t2 where a='1'; +a b +1 abc +select COUNT_STAR, OBJECT_TYPE, OBJECT_SCHEMA, OBJECT_NAME +from performance_schema.table_lock_waits_summary_by_table +where OBJECT_SCHEMA='db1' + order by OBJECT_TYPE, OBJECT_SCHEMA, OBJECT_NAME; +COUNT_STAR OBJECT_TYPE OBJECT_SCHEMA OBJECT_NAME +10 TABLE db1 t1 +0 TABLE db1 t2 +flush tables; +select COUNT_STAR, OBJECT_TYPE, OBJECT_SCHEMA, OBJECT_NAME +from performance_schema.table_lock_waits_summary_by_table +where OBJECT_SCHEMA='db1' + order by OBJECT_TYPE, OBJECT_SCHEMA, OBJECT_NAME; +COUNT_STAR OBJECT_TYPE OBJECT_SCHEMA OBJECT_NAME +10 TABLE db1 t1 +0 TABLE db1 t2 +select variable_value from performance_schema.global_status +where variable_name like 'PERFORMANCE_SCHEMA_TABLE_LOCK_STAT_LOST'; +variable_value +0 +drop database db1; +update performance_schema.setup_objects set ENABLED='YES' + where OBJECT_TYPE='TABLE' and OBJECT_SCHEMA="%"; diff --git a/mysql-test/suite/start_server_no_table_lock.result-pq b/mysql-test/suite/start_server_no_table_lock.result-pq new file mode 100644 index 000000000000..a30c59b426a0 --- /dev/null +++ b/mysql-test/suite/start_server_no_table_lock.result-pq @@ -0,0 +1,143 @@ +show databases; +Database +information_schema +mtr +mysql +performance_schema +sys +test +select count(*) from performance_schema.performance_timers; +count(*) +4 +select count(*) from performance_schema.setup_consumers; +count(*) +15 +select count(*) > 4 from performance_schema.setup_instruments; +count(*) > 4 +1 +select * from performance_schema.accounts; +select * from performance_schema.cond_instances; +select * from performance_schema.events_stages_current; +select * from performance_schema.events_stages_history; +select * from performance_schema.events_stages_history_long; +select * from performance_schema.events_stages_summary_by_account_by_event_name; +select * from performance_schema.events_stages_summary_by_host_by_event_name; +select * from performance_schema.events_stages_summary_by_thread_by_event_name; +select * from performance_schema.events_stages_summary_by_user_by_event_name; +select * from performance_schema.events_stages_summary_global_by_event_name; +select * from performance_schema.events_statements_current; +select * from performance_schema.events_statements_histogram_by_digest; +select * from performance_schema.events_statements_histogram_global; +select * from performance_schema.events_statements_history; +select * from performance_schema.events_statements_history_long; +select * from performance_schema.events_statements_summary_by_account_by_event_name; +select * from performance_schema.events_statements_summary_by_digest; +select * from performance_schema.events_statements_summary_by_host_by_event_name; +select * from performance_schema.events_statements_summary_by_thread_by_event_name; +select * from performance_schema.events_statements_summary_by_user_by_event_name; +select * from performance_schema.events_statements_summary_global_by_event_name; +select * from performance_schema.events_transactions_current; +select * from performance_schema.events_transactions_history; +select * from performance_schema.events_transactions_history_long; +select * from performance_schema.events_transactions_summary_by_account_by_event_name; +select * from performance_schema.events_transactions_summary_by_host_by_event_name; +select * from performance_schema.events_transactions_summary_by_thread_by_event_name; +select * from performance_schema.events_transactions_summary_by_user_by_event_name; +select * from performance_schema.events_transactions_summary_global_by_event_name; +select * from performance_schema.events_waits_current; +select * from performance_schema.events_waits_history; +select * from performance_schema.events_waits_history_long; +select * from performance_schema.events_waits_summary_by_account_by_event_name; +select * from performance_schema.events_waits_summary_by_host_by_event_name; +select * from performance_schema.events_waits_summary_by_instance; +select * from performance_schema.events_waits_summary_by_thread_by_event_name; +select * from performance_schema.events_waits_summary_by_user_by_event_name; +select * from performance_schema.events_waits_summary_global_by_event_name; +select * from performance_schema.memory_summary_by_account_by_event_name; +select * from performance_schema.memory_summary_by_host_by_event_name; +select * from performance_schema.memory_summary_by_thread_by_event_name; +select * from performance_schema.memory_summary_by_user_by_event_name; +select * from performance_schema.memory_summary_global_by_event_name; +select * from performance_schema.events_errors_summary_by_account_by_error; +select * from performance_schema.events_errors_summary_by_host_by_error; +select * from performance_schema.events_errors_summary_by_thread_by_error; +select * from performance_schema.events_errors_summary_by_user_by_error; +select * from performance_schema.events_errors_summary_global_by_error; +select * from performance_schema.file_instances; +select * from performance_schema.file_summary_by_event_name; +select * from performance_schema.file_summary_by_instance; +select * from performance_schema.host_cache; +select * from performance_schema.hosts; +select * from performance_schema.memory_summary_by_account_by_event_name; +select * from performance_schema.memory_summary_by_host_by_event_name; +select * from performance_schema.memory_summary_by_thread_by_event_name; +select * from performance_schema.memory_summary_by_user_by_event_name; +select * from performance_schema.memory_summary_global_by_event_name; +select * from performance_schema.metadata_locks; +select * from performance_schema.mutex_instances; +select * from performance_schema.objects_summary_global_by_type; +select * from performance_schema.performance_timers; +select * from performance_schema.rwlock_instances; +select * from performance_schema.data_locks; +select * from performance_schema.data_lock_waits; +select * from performance_schema.session_account_connect_attrs; +select * from performance_schema.session_connect_attrs; +select * from performance_schema.setup_actors; +select * from performance_schema.setup_consumers; +select * from performance_schema.setup_instruments; +select * from performance_schema.setup_objects; +select * from performance_schema.setup_threads; +select * from performance_schema.socket_instances; +select * from performance_schema.socket_summary_by_instance; +select * from performance_schema.socket_summary_by_event_name; +select * from performance_schema.table_handles; +select * from performance_schema.table_io_waits_summary_by_index_usage; +select * from performance_schema.table_io_waits_summary_by_table; +select * from performance_schema.table_lock_waits_summary_by_table; +select * from performance_schema.threads; +select * from performance_schema.users; +select * from performance_schema.replication_connection_configuration; +select * from performance_schema.replication_connection_status; +select * from performance_schema.replication_applier_configuration; +select * from performance_schema.replication_applier_status; +select * from performance_schema.replication_applier_status_by_coordinator; +select * from performance_schema.replication_applier_status_by_worker; +select * from performance_schema.global_status; +select * from performance_schema.status_by_thread; +select * from performance_schema.status_by_user; +select * from performance_schema.status_by_host; +select * from performance_schema.status_by_account; +select * from performance_schema.session_status; +select * from performance_schema.global_variables; +select * from performance_schema.variables_by_thread; +select * from performance_schema.session_variables; +show engine PERFORMANCE_SCHEMA status; +show global status like "performance_schema%"; +drop table if exists db1.t1; +drop database if exists db1; +create database db1; +create table db1.t1 (a int, b char(10) default 'default'); +insert into db1.t1 values('1', 'abc'); +insert into db1.t1 values('2', 'abc'); +select * from db1.t1 where a='1'; +a b +1 abc +select COUNT_STAR from performance_schema.table_lock_waits_summary_by_table +where OBJECT_SCHEMA='db1' and OBJECT_NAME='t1'; +COUNT_STAR +5 +FLUSH TABLES; +select COUNT_STAR from performance_schema.table_lock_waits_summary_by_table +where OBJECT_SCHEMA='db1' and OBJECT_NAME='t1'; +COUNT_STAR +0 +select variable_value > 0 from performance_schema.global_status +where variable_name like 'PERFORMANCE_SCHEMA_TABLE_LOCK_STAT_LOST'; +variable_value > 0 +1 +FLUSH STATUS; +select variable_value from performance_schema.global_status +where variable_name like 'PERFORMANCE_SCHEMA_TABLE_LOCK_STAT_LOST'; +variable_value +0 +drop database db1; diff --git a/mysql-test/suite/stmtexecute_query_result.result-pq b/mysql-test/suite/stmtexecute_query_result.result-pq new file mode 100644 index 000000000000..9c375ed055a8 --- /dev/null +++ b/mysql-test/suite/stmtexecute_query_result.result-pq @@ -0,0 +1,102 @@ +RUN drop schema if exists xtest + +0 rows affected +RUN create schema xtest + +1 rows affected +RUN use xtest + +0 rows affected +RUN create table mytable (pk int primary key auto_increment, data varchar(100)) + +0 rows affected +RUN create procedure result_and_error () +begin + select 1; + select * from invalid_table; +end + +0 rows affected +send Mysqlx.Sql.StmtExecute { + stmt: "insert into mytable values (DEFAULT, \'one\')" +} + + +1 rows affected +last insert id: 1 +send Mysqlx.Sql.StmtExecute { + stmt: "insert into mytable values (DEFAULT, \'two\')" +} + + +1 rows affected +last insert id: 2 +send Mysqlx.Sql.StmtExecute { + stmt: "insert into mytable values (DEFAULT, \'three\')" +} + + +1 rows affected +last insert id: 3 +send Mysqlx.Sql.StmtExecute { + stmt: "select * from mytable" +} + +Mysqlx.Resultset.ColumnMetaData { + type: SINT + name: "pk" + original_name: "pk" + table: "mytable" + original_table: "mytable" + schema: "xtest" + catalog: "def" + length: 11 + flags: 16 +} + +Mysqlx.Resultset.ColumnMetaData { + type: BYTES + name: "data" + original_name: "data" + table: "mytable" + original_table: "mytable" + schema: "xtest" + catalog: "def" + collation: 255 + length: 400 +} + +Mysqlx.Resultset.Row { + field: "\002" + field: "one\000" +} + +Mysqlx.Resultset.Row { + field: "\004" + field: "two\000" +} + +Mysqlx.Resultset.Row { + field: "\006" + field: "three\000" +} + +Mysqlx.Resultset.FetchDone { +} + +Mysqlx.Notice.Frame { + type: 3 + scope: LOCAL + payload: "Mysqlx.Notice.SessionStateChanged { param: ROWS_AFFECTED\nvalue {\n type: V_UINT\n v_unsigned_int: 0\n}\n }" +} + +Mysqlx.Sql.StmtExecuteOk { +} + +RUN drop schema if exists xtest + +1 rows affected +Mysqlx.Ok { + msg: "bye!" +} +ok diff --git a/mysql-test/suite/subquery_no_prot.result-pq b/mysql-test/suite/subquery_no_prot.result-pq new file mode 100644 index 000000000000..db65a27625cc --- /dev/null +++ b/mysql-test/suite/subquery_no_prot.result-pq @@ -0,0 +1,3400 @@ +SET optimizer_trace_max_mem_size=1048576; +SET end_markers_in_json=on; +SET optimizer_trace="enabled=on,one_line=off"; +CREATE TABLE t1 (a INT); +CREATE TABLE t2 (a INT, b INT); +INSERT INTO t1 VALUES (2); +INSERT INTO t2 VALUES (1,7),(2,7); +# Subselect execute is traced every time it is executed +SET @@optimizer_trace_features="greedy_search=off,repeated_subselect=on"; +SELECT (SELECT a FROM t1 WHERE t1.a=t2.a), a FROM t2; +(SELECT a FROM t1 WHERE t1.a=t2.a) a +NULL 1 +2 2 + +SELECT * FROM information_schema.OPTIMIZER_TRACE; +QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES +SELECT (SELECT a FROM t1 WHERE t1.a=t2.a), a FROM t2 { + "steps": [ + { + "join_preparation": { + "select#": 1, + "steps": [ + { + "join_preparation": { + "select#": 2, + "steps": [ + { + "expanded_query": "/* select#2 */ select `t1`.`a` from `t1` where (`t1`.`a` = `t2`.`a`)" + } + ] /* steps */ + } /* join_preparation */ + }, + { + "expanded_query": "/* select#1 */ select (/* select#2 */ select `t1`.`a` from `t1` where (`t1`.`a` = `t2`.`a`)) AS `(SELECT a FROM t1 WHERE t1.a=t2.a)`,`t2`.`a` AS `a` from `t2`" + } + ] /* steps */ + } /* join_preparation */ + }, + { + "join_optimization": { + "select#": 1, + "steps": [ + { + "table_dependencies": [ + { + "table": "`t2`", + "row_may_be_null": false, + "map_bit": 0, + "depends_on_map_bits": [ + ] /* depends_on_map_bits */ + } + ] /* table_dependencies */ + }, + { + "rows_estimation": [ + { + "table": "`t2`", + "table_scan": { + "rows": 2, + "cost": 0.501099 + } /* table_scan */ + } + ] /* rows_estimation */ + }, + { + "considered_execution_plans": "..." + }, + { + "attaching_conditions_to_tables": { + "original_condition": null, + "attached_conditions_computation": [ + ] /* attached_conditions_computation */, + "attached_conditions_summary": [ + { + "table": "`t2`", + "attached": null + } + ] /* attached_conditions_summary */ + } /* attaching_conditions_to_tables */ + }, + { + "finalizing_table_conditions": [ + ] /* finalizing_table_conditions */ + }, + { + "refine_plan": [ + { + "table": "`t2`" + } + ] /* refine_plan */ + } + ] /* steps */ + } /* join_optimization */ + }, + { + "join_optimization": { + "select#": 2, + "steps": [ + { + "condition_processing": { + "condition": "WHERE", + "original_condition": "(`t1`.`a` = `t2`.`a`)", + "steps": [ + { + "transformation": "equality_propagation", + "resulting_condition": "(`t1`.`a` = `t2`.`a`)" + }, + { + "transformation": "constant_propagation", + "resulting_condition": "(`t1`.`a` = `t2`.`a`)" + }, + { + "transformation": "trivial_condition_removal", + "resulting_condition": "(`t1`.`a` = `t2`.`a`)" + } + ] /* steps */ + } /* condition_processing */ + }, + { + "substitute_generated_columns": { + } /* substitute_generated_columns */ + }, + { + "table_dependencies": [ + { + "table": "`t1`", + "row_may_be_null": false, + "map_bit": 0, + "depends_on_map_bits": [ + ] /* depends_on_map_bits */ + } + ] /* table_dependencies */ + }, + { + "ref_optimizer_key_uses": [ + ] /* ref_optimizer_key_uses */ + }, + { + "rows_estimation": [ + { + "table": "`t1`", + "rows": 1, + "cost": 1, + "table_type": "system", + "empty": false + } + ] /* rows_estimation */ + }, + { + "attaching_conditions_to_tables": { + "original_condition": "('2' = `t2`.`a`)", + "attached_conditions_computation": [ + ] /* attached_conditions_computation */, + "attached_conditions_summary": [ + ] /* attached_conditions_summary */ + } /* attaching_conditions_to_tables */ + }, + { + "refine_plan": [ + ] /* refine_plan */ + } + ] /* steps */ + } /* join_optimization */ + }, + { + "join_execution": { + "select#": 1, + "steps": [ + { + "subselect_execution": { + "select#": 2, + "steps": [ + { + "join_execution": { + "select#": 2, + "steps": [ + ] /* steps */ + } /* join_execution */ + } + ] /* steps */ + } /* subselect_execution */ + }, + { + "subselect_execution": { + "select#": 2, + "steps": [ + { + "join_execution": { + "select#": 2, + "steps": [ + ] /* steps */ + } /* join_execution */ + } + ] /* steps */ + } /* subselect_execution */ + } + ] /* steps */ + } /* join_execution */ + } + ] /* steps */ +} 0 0 + +# Subselect execute is traced only the first time it is executed +SET @@optimizer_trace_features="greedy_search=off,repeated_subselect=off"; +SELECT (SELECT a FROM t1 WHERE t1.a=t2.a), a FROM t2; +(SELECT a FROM t1 WHERE t1.a=t2.a) a +NULL 1 +2 2 + +SELECT * FROM information_schema.OPTIMIZER_TRACE; +QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES +SELECT (SELECT a FROM t1 WHERE t1.a=t2.a), a FROM t2 { + "steps": [ + { + "join_preparation": { + "select#": 1, + "steps": [ + { + "join_preparation": { + "select#": 2, + "steps": [ + { + "expanded_query": "/* select#2 */ select `t1`.`a` from `t1` where (`t1`.`a` = `t2`.`a`)" + } + ] /* steps */ + } /* join_preparation */ + }, + { + "expanded_query": "/* select#1 */ select (/* select#2 */ select `t1`.`a` from `t1` where (`t1`.`a` = `t2`.`a`)) AS `(SELECT a FROM t1 WHERE t1.a=t2.a)`,`t2`.`a` AS `a` from `t2`" + } + ] /* steps */ + } /* join_preparation */ + }, + { + "join_optimization": { + "select#": 1, + "steps": [ + { + "table_dependencies": [ + { + "table": "`t2`", + "row_may_be_null": false, + "map_bit": 0, + "depends_on_map_bits": [ + ] /* depends_on_map_bits */ + } + ] /* table_dependencies */ + }, + { + "rows_estimation": [ + { + "table": "`t2`", + "table_scan": { + "rows": 2, + "cost": 0.501099 + } /* table_scan */ + } + ] /* rows_estimation */ + }, + { + "considered_execution_plans": "..." + }, + { + "attaching_conditions_to_tables": { + "original_condition": null, + "attached_conditions_computation": [ + ] /* attached_conditions_computation */, + "attached_conditions_summary": [ + { + "table": "`t2`", + "attached": null + } + ] /* attached_conditions_summary */ + } /* attaching_conditions_to_tables */ + }, + { + "finalizing_table_conditions": [ + ] /* finalizing_table_conditions */ + }, + { + "refine_plan": [ + { + "table": "`t2`" + } + ] /* refine_plan */ + } + ] /* steps */ + } /* join_optimization */ + }, + { + "join_optimization": { + "select#": 2, + "steps": [ + { + "condition_processing": { + "condition": "WHERE", + "original_condition": "(`t1`.`a` = `t2`.`a`)", + "steps": [ + { + "transformation": "equality_propagation", + "resulting_condition": "(`t1`.`a` = `t2`.`a`)" + }, + { + "transformation": "constant_propagation", + "resulting_condition": "(`t1`.`a` = `t2`.`a`)" + }, + { + "transformation": "trivial_condition_removal", + "resulting_condition": "(`t1`.`a` = `t2`.`a`)" + } + ] /* steps */ + } /* condition_processing */ + }, + { + "substitute_generated_columns": { + } /* substitute_generated_columns */ + }, + { + "table_dependencies": [ + { + "table": "`t1`", + "row_may_be_null": false, + "map_bit": 0, + "depends_on_map_bits": [ + ] /* depends_on_map_bits */ + } + ] /* table_dependencies */ + }, + { + "ref_optimizer_key_uses": [ + ] /* ref_optimizer_key_uses */ + }, + { + "rows_estimation": [ + { + "table": "`t1`", + "rows": 1, + "cost": 1, + "table_type": "system", + "empty": false + } + ] /* rows_estimation */ + }, + { + "attaching_conditions_to_tables": { + "original_condition": "('2' = `t2`.`a`)", + "attached_conditions_computation": [ + ] /* attached_conditions_computation */, + "attached_conditions_summary": [ + ] /* attached_conditions_summary */ + } /* attaching_conditions_to_tables */ + }, + { + "refine_plan": [ + ] /* refine_plan */ + } + ] /* steps */ + } /* join_optimization */ + }, + { + "join_execution": { + "select#": 1, + "steps": [ + { + "subselect_execution": { + "select#": 2, + "steps": [ + { + "join_execution": { + "select#": 2, + "steps": [ + ] /* steps */ + } /* join_execution */ + } + ] /* steps */ + } /* subselect_execution */ + } + ] /* steps */ + } /* join_execution */ + } + ] /* steps */ +} 0 0 + +DROP TABLE t1,t2; +SET @@optimizer_trace_features="default"; +CREATE TABLE t1 (a FLOAT(5,4) zerofill); +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +CREATE TABLE t2 (a FLOAT(5,4),b FLOAT(2,0)); +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +SELECT t1.a +FROM t1 +WHERE t1.a= (SELECT b FROM t2 LIMIT 1) AND NOT +t1.a= (SELECT a FROM t2 LIMIT 1) ; +a + +SELECT * FROM information_schema.OPTIMIZER_TRACE; +QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES +SELECT t1.a +FROM t1 +WHERE t1.a= (SELECT b FROM t2 LIMIT 1) AND NOT +t1.a= (SELECT a FROM t2 LIMIT 1) { + "steps": [ + { + "join_preparation": { + "select#": 1, + "steps": [ + { + "join_preparation": { + "select#": 2, + "steps": [ + { + "expanded_query": "/* select#2 */ select `t2`.`b` from `t2` limit 1" + } + ] /* steps */ + } /* join_preparation */ + }, + { + "join_preparation": { + "select#": 3, + "steps": [ + { + "expanded_query": "/* select#3 */ select `t2`.`a` from `t2` limit 1" + } + ] /* steps */ + } /* join_preparation */ + }, + { + "expanded_query": "/* select#1 */ select `t1`.`a` AS `a` from `t1` where ((`t1`.`a` = (/* select#2 */ select `t2`.`b` from `t2` limit 1)) and (`t1`.`a` <> (/* select#3 */ select `t2`.`a` from `t2` limit 1)))" + } + ] /* steps */ + } /* join_preparation */ + }, + { + "join_optimization": { + "select#": 1, + "steps": [ + { + "condition_processing": { + "condition": "WHERE", + "original_condition": "((`t1`.`a` = (/* select#2 */ select `t2`.`b` from `t2` limit 1)) and (`t1`.`a` <> (/* select#3 */ select `t2`.`a` from `t2` limit 1)))", + "steps": [ + { + "transformation": "equality_propagation", + "subselect_evaluation": [ + { + "subselect_execution": { + "select#": 2, + "steps": [ + { + "join_optimization": { + "select#": 2, + "steps": [ + { + "table_dependencies": [ + { + "table": "`t2`", + "row_may_be_null": false, + "map_bit": 0, + "depends_on_map_bits": [ + ] /* depends_on_map_bits */ + } + ] /* table_dependencies */ + }, + { + "rows_estimation": [ + { + "table": "`t2`", + "rows": 1, + "cost": 1, + "table_type": "system", + "empty": true + } + ] /* rows_estimation */ + } + ] /* steps */, + "empty_result": { + "cause": "no matching row in const table" + } /* empty_result */ + } /* join_optimization */ + }, + { + "join_execution": { + "select#": 2, + "steps": [ + ] /* steps */ + } /* join_execution */ + } + ] /* steps */ + } /* subselect_execution */ + } + ] /* subselect_evaluation */, + "resulting_condition": "((NULL <> (/* select#3 */ select `t2`.`a` from `t2` limit 1)) and multiple equal((/* select#2 */ select NULL from `t2` limit 1), `t1`.`a`))" + }, + { + "transformation": "constant_propagation", + "subselect_evaluation": [ + ] /* subselect_evaluation */, + "resulting_condition": "((NULL <> (/* select#3 */ select `t2`.`a` from `t2` limit 1)) and multiple equal((/* select#2 */ select NULL from `t2` limit 1), `t1`.`a`))" + }, + { + "transformation": "trivial_condition_removal", + "subselect_evaluation": [ + ] /* subselect_evaluation */, + "resulting_condition": null + } + ] /* steps */ + } /* condition_processing */ + } + ] /* steps */, + "empty_result": { + "cause": "Impossible WHERE" + } /* empty_result */ + } /* join_optimization */ + }, + { + "join_execution": { + "select#": 1, + "steps": [ + ] /* steps */ + } /* join_execution */ + } + ] /* steps */ +} 0 0 + +SELECT 1 FROM DUAL +WHERE NOT EXISTS +(SELECT * FROM t2 WHERE a = 50 AND b = 3); +1 +1 + +SELECT * FROM information_schema.OPTIMIZER_TRACE; +QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES +SELECT 1 FROM DUAL +WHERE NOT EXISTS +(SELECT * FROM t2 WHERE a = 50 AND b = 3) { + "steps": [ + { + "join_preparation": { + "select#": 1, + "steps": [ + { + "join_preparation": { + "select#": 2, + "steps": [ + { + "expanded_query": "/* select#2 */ select 1 from `t2` where ((`t2`.`a` = 50) and (`t2`.`b` = 3))" + } + ] /* steps */ + } /* join_preparation */ + }, + { + "expanded_query": "/* select#1 */ select 1 AS `1` from DUAL where exists(/* select#2 */ select 1 from `t2` where ((`t2`.`a` = 50) and (`t2`.`b` = 3))) is false" + } + ] /* steps */ + } /* join_preparation */ + }, + { + "join_optimization": { + "select#": 1, + "steps": [ + { + "condition_processing": { + "condition": "WHERE", + "original_condition": "exists(/* select#2 */ select 1 from `t2` where ((`t2`.`a` = 50) and (`t2`.`b` = 3))) is false", + "steps": [ + { + "transformation": "equality_propagation", + "subselect_evaluation": [ + ] /* subselect_evaluation */, + "resulting_condition": "exists(/* select#2 */ select 1 from `t2` where ((`t2`.`a` = 50) and (`t2`.`b` = 3))) is false" + }, + { + "transformation": "constant_propagation", + "subselect_evaluation": [ + ] /* subselect_evaluation */, + "resulting_condition": "exists(/* select#2 */ select 1 from `t2` where ((`t2`.`a` = 50) and (`t2`.`b` = 3))) is false" + }, + { + "transformation": "trivial_condition_removal", + "subselect_evaluation": [ + { + "subselect_execution": { + "select#": 2, + "steps": [ + { + "join_optimization": { + "select#": 2, + "steps": [ + { + "condition_processing": { + "condition": "WHERE", + "original_condition": "((`t2`.`a` = 50) and (`t2`.`b` = 3))", + "steps": [ + { + "transformation": "equality_propagation", + "resulting_condition": "((`t2`.`a` = 50) and (`t2`.`b` = 3))" + }, + { + "transformation": "constant_propagation", + "resulting_condition": "((`t2`.`a` = 50) and (`t2`.`b` = 3))" + }, + { + "transformation": "trivial_condition_removal", + "resulting_condition": null + } + ] /* steps */ + } /* condition_processing */ + } + ] /* steps */, + "empty_result": { + "cause": "Impossible WHERE" + } /* empty_result */ + } /* join_optimization */ + }, + { + "join_execution": { + "select#": 2, + "steps": [ + ] /* steps */ + } /* join_execution */ + } + ] /* steps */ + } /* subselect_execution */ + } + ] /* subselect_evaluation */, + "resulting_condition": null + } + ] /* steps */ + } /* condition_processing */ + } + ] /* steps */ + } /* join_optimization */ + }, + { + "join_execution": { + "select#": 1, + "steps": [ + ] /* steps */ + } /* join_execution */ + } + ] /* steps */ +} 0 0 + +SELECT 1 FROM DUAL WHERE NOT EXISTS (SELECT DISTINCT(a) FROM t2 GROUP BY a ORDER BY b); +1 +1 + +SELECT * FROM information_schema.OPTIMIZER_TRACE; +QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES +SELECT 1 FROM DUAL WHERE NOT EXISTS (SELECT DISTINCT(a) FROM t2 GROUP BY a ORDER BY b) { + "steps": [ + { + "join_preparation": { + "select#": 1, + "steps": [ + { + "join_preparation": { + "select#": 2, + "steps": [ + { + "transformations_to_subquery": [ + "removed_ordering", + "removed_distinct", + "removed_grouping" + ] /* transformations_to_subquery */ + }, + { + "expanded_query": "/* select#2 */ select `t2`.`a` from `t2`" + } + ] /* steps */ + } /* join_preparation */ + }, + { + "expanded_query": "/* select#1 */ select 1 AS `1` from DUAL where exists(/* select#2 */ select `t2`.`a` from `t2`) is false" + } + ] /* steps */ + } /* join_preparation */ + }, + { + "join_optimization": { + "select#": 1, + "steps": [ + { + "condition_processing": { + "condition": "WHERE", + "original_condition": "exists(/* select#2 */ select `t2`.`a` from `t2`) is false", + "steps": [ + { + "transformation": "equality_propagation", + "subselect_evaluation": [ + ] /* subselect_evaluation */, + "resulting_condition": "exists(/* select#2 */ select `t2`.`a` from `t2`) is false" + }, + { + "transformation": "constant_propagation", + "subselect_evaluation": [ + ] /* subselect_evaluation */, + "resulting_condition": "exists(/* select#2 */ select `t2`.`a` from `t2`) is false" + }, + { + "transformation": "trivial_condition_removal", + "subselect_evaluation": [ + { + "subselect_execution": { + "select#": 2, + "steps": [ + { + "join_optimization": { + "select#": 2, + "steps": [ + { + "table_dependencies": [ + { + "table": "`t2`", + "row_may_be_null": false, + "map_bit": 0, + "depends_on_map_bits": [ + ] /* depends_on_map_bits */ + } + ] /* table_dependencies */ + }, + { + "rows_estimation": [ + { + "table": "`t2`", + "rows": 1, + "cost": 1, + "table_type": "system", + "empty": true + } + ] /* rows_estimation */ + } + ] /* steps */, + "empty_result": { + "cause": "no matching row in const table" + } /* empty_result */ + } /* join_optimization */ + }, + { + "join_execution": { + "select#": 2, + "steps": [ + ] /* steps */ + } /* join_execution */ + } + ] /* steps */ + } /* subselect_execution */ + } + ] /* subselect_evaluation */, + "resulting_condition": null + } + ] /* steps */ + } /* condition_processing */ + } + ] /* steps */ + } /* join_optimization */ + }, + { + "join_execution": { + "select#": 1, + "steps": [ + ] /* steps */ + } /* join_execution */ + } + ] /* steps */ +} 0 0 + +DROP TABLE t1,t2; +# +# BUG#12905521 - ASSERT IN OPT_TRACE_STMT::SYNTAX_ERROR ON SELECT +# DISTINCT/MIN/JOIN/SUBQ QUERY +# +CREATE TABLE t1 ( +pk INTEGER, +col_int_nokey INTEGER, +col_int_key INTEGER, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk), +KEY (col_varchar_key,col_int_key) +) ENGINE=MYISAM; +CREATE TABLE t2 ( +pk INTEGER, +col_int_nokey INTEGER, +col_int_key INTEGER, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk), +KEY (col_varchar_key,col_int_key) +) ENGINE=MYISAM; +CREATE TABLE t3 ( +pk INTEGER, +col_int_nokey INTEGER, +col_int_key INTEGER, +col_time_key TIME, +col_datetime_nokey DATETIME, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk), +KEY (col_time_key), +KEY (col_varchar_key,col_int_key) +) ENGINE=MYISAM; +CREATE TABLE t4 ( +pk INTEGER, +col_int_nokey INTEGER, +col_int_key INTEGER, +col_date_key DATE, +col_date_nokey DATE, +col_time_key TIME, +col_time_nokey TIME, +col_datetime_key DATETIME, +col_datetime_nokey DATETIME, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk), +KEY (col_varchar_key,col_int_key) +) ENGINE=MYISAM; +INSERT IGNORE INTO t4 ( +col_int_key,col_int_nokey, +col_date_key,col_date_nokey, +col_time_key,col_time_nokey, +col_datetime_key,col_datetime_nokey, +col_varchar_key,col_varchar_nokey +) VALUES +(8,7,'2008-10-02','2008-10-02','04:07:22.028954','04:07:22.028954','2001-10-08 00:00:00','2001-10-08 00:00:00','g','g'); +Warnings: +Warning 1364 Field 'pk' doesn't have a default value +CREATE TABLE t5 ( +pk INTEGER AUTO_INCREMENT, +col_int_nokey INTEGER, +col_int_key INTEGER, +col_date_key DATE, +col_date_nokey DATE, +col_time_key TIME, +col_time_nokey TIME, +col_datetime_key DATETIME, +col_datetime_nokey DATETIME, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk), +KEY (col_int_key), +KEY (col_varchar_key,col_int_key) +) ENGINE=MYISAM; +INSERT INTO t5 ( +col_int_key,col_int_nokey, +col_date_key,col_date_nokey, +col_time_key,col_time_nokey, +col_datetime_key,col_datetime_nokey, +col_varchar_key,col_varchar_nokey +) VALUES +(8,NULL,'2000-12-03','2000-12-03','22:55:23.019225','22:55:23.019225','2005-07-20 00:00:00','2005-07-20 00:00:00','x','x'), +(7,8,'2008-05-03','2008-05-03','10:19:31.050677','10:19:31.050677','2007-10-06 17:56:40.056051','2007-10-06 17:56:40.056051','d','d'), +(8,6,'2000-09-20','2000-09-20','14:11:27.044095','14:11:27.044095','2003-06-13 23:19:49.018300','2003-06-13 23:19:49.018300','c','c'); +set @old_opt_switch=@@optimizer_switch; +select distinct +alias1.`col_varchar_key` as field1 ,alias1.`col_date_key` as +field2 ,( select min( sq1_alias1.`col_varchar_nokey` ) as sq1_field1 from ( t1 +as sq1_alias1 inner join ( t5 as sq1_alias2 left join t5 as sq1_alias3 on +(sq1_alias3.`col_varchar_nokey` = sq1_alias2.`col_varchar_key` ) ) on +(sq1_alias3.`col_varchar_nokey` = sq1_alias2.`col_varchar_key` ) ) where +exists ( select distinct c_sq1_alias2.`col_int_nokey` as c_sq1_field1 from ( +t3 as c_sq1_alias1 right join t4 as c_sq1_alias2 on (c_sq1_alias2.`col_int_nokey` = c_sq1_alias1.`pk` ) ) where +c_sq1_alias2.`col_varchar_key` = sq1_alias2.`col_varchar_nokey` ) ) as field3 +,( select max( sq2_alias1.`pk` ) as sq2_field1 from t5 as sq2_alias1 ) as +field4 ,alias2.`col_varchar_nokey` as field5 ,alias2.`col_varchar_nokey` as +field6 from ( t5 as alias1 right outer join ( ( ( select sq3_alias2.* from ( t5 as sq3_alias1 ,t4 as sq3_alias2 ) ) as alias2 right join t4 +as alias3 on (alias3.`col_varchar_key` = alias2.`col_varchar_key` ) ) ) on +(alias3.`col_int_key` = alias2.`pk` ) ) where ( alias1.`col_varchar_nokey` in +( select sq4_alias1.`col_varchar_key` as sq4_field1 from ( t3 as sq4_alias1 +inner join ( t2 as sq4_alias2 right outer join t3 as sq4_alias3 on +(sq4_alias3.`pk` = sq4_alias2.`col_int_key` ) ) on +(sq4_alias3.`col_varchar_nokey` = sq4_alias2.`col_varchar_key` ) ) where +sq4_alias2.`col_int_key` < alias1.`col_int_nokey` and +sq4_alias3.`col_varchar_nokey` <> alias1.`col_varchar_key` ) ) and +alias1.`col_int_key` not in (214) group by field1,field2,field3, +field4,field5,field6; +field1 field2 field3 field4 field5 field6 +select * from information_schema.optimizer_trace; +QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES +select distinct +alias1.`col_varchar_key` as field1 ,alias1.`col_date_key` as +field2 ,( select min( sq1_alias1.`col_varchar_nokey` ) as sq1_field1 from ( t1 +as sq1_alias1 inner join ( t5 as sq1_alias2 left join t5 as sq1_alias3 on +(sq1_alias3.`col_varchar_nokey` = sq1_alias2.`col_varchar_key` ) ) on +(sq1_alias3.`col_varchar_nokey` = sq1_alias2.`col_varchar_key` ) ) where +exists ( select distinct c_sq1_alias2.`col_int_nokey` as c_sq1_field1 from ( +t3 as c_sq1_alias1 right join t4 as c_sq1_alias2 on (c_sq1_alias2.`col_int_nokey` = c_sq1_alias1.`pk` ) ) where +c_sq1_alias2.`col_varchar_key` = sq1_alias2.`col_varchar_nokey` ) ) as field3 +,( select max( sq2_alias1.`pk` ) as sq2_field1 from t5 as sq2_alias1 ) as +field4 ,alias2.`col_varchar_nokey` as field5 ,alias2.`col_varchar_nokey` as +field6 from ( t5 as alias1 right outer join ( ( ( select sq3_alias2.* from ( t5 as sq3_alias1 ,t4 as sq3_alias2 ) ) as alias2 right join t4 +as alias3 on (alias3.`col_varchar_key` = alias2.`col_varchar_key` ) ) ) on +(alias3.`col_int_key` = alias2.`pk` ) ) where ( alias1.`col_varchar_nokey` in +( select sq4_alias1.`col_varchar_key` as sq4_field1 from ( t3 as sq4_alias1 +inner join ( t2 as sq4_alias2 right outer join t3 as sq4_alias3 on +(sq4_alias3.`pk` = sq4_alias2.`col_int_key` ) ) on +(sq4_alias3.`col_varchar_nokey` = sq4_alias2.`col_varchar_key` ) ) where +sq4_alias2.`col_int_key` < alias1.`col_int_nokey` and +sq4_alias3.`col_varchar_nokey` <> alias1.`col_varchar_key` ) ) and +alias1.`col_int_key` not in (214) group by field1,field2,field3, +field4,field5,field6 { + "steps": [ + { + "join_preparation": { + "select#": 1, + "steps": [ + { + "join_preparation": { + "select#": 5, + "steps": [ + { + "expanded_query": "/* select#5 */ select `sq3_alias2`.`pk` AS `pk`,`sq3_alias2`.`col_int_nokey` AS `col_int_nokey`,`sq3_alias2`.`col_int_key` AS `col_int_key`,`sq3_alias2`.`col_date_key` AS `col_date_key`,`sq3_alias2`.`col_date_nokey` AS `col_date_nokey`,`sq3_alias2`.`col_time_key` AS `col_time_key`,`sq3_alias2`.`col_time_nokey` AS `col_time_nokey`,`sq3_alias2`.`col_datetime_key` AS `col_datetime_key`,`sq3_alias2`.`col_datetime_nokey` AS `col_datetime_nokey`,`sq3_alias2`.`col_varchar_key` AS `col_varchar_key`,`sq3_alias2`.`col_varchar_nokey` AS `col_varchar_nokey` from (`t5` `sq3_alias1` join `t4` `sq3_alias2`)" + } + ] /* steps */ + } /* join_preparation */ + }, + { + "derived": { + "table": "`` `alias2`", + "select#": 5, + "merged": true + } /* derived */ + }, + { + "join_preparation": { + "select#": 2, + "steps": [ + { + "join_preparation": { + "select#": 3, + "steps": [ + { + "transformations_to_subquery": [ + "removed_distinct" + ] /* transformations_to_subquery */ + }, + { + "expanded_query": "/* select#3 */ select `c_sq1_alias2`.`col_int_nokey` AS `c_sq1_field1` from (`t4` `c_sq1_alias2` left join `t3` `c_sq1_alias1` on((`c_sq1_alias2`.`col_int_nokey` = `c_sq1_alias1`.`pk`))) where (`c_sq1_alias2`.`col_varchar_key` = `sq1_alias2`.`col_varchar_nokey`)" + } + ] /* steps */ + } /* join_preparation */ + }, + { + "expanded_query": "/* select#2 */ select min(`sq1_alias1`.`col_varchar_nokey`) AS `sq1_field1` from (`t1` `sq1_alias1` join (`t5` `sq1_alias2` left join `t5` `sq1_alias3` on((`sq1_alias3`.`col_varchar_nokey` = `sq1_alias2`.`col_varchar_key`))) on((`sq1_alias3`.`col_varchar_nokey` = `sq1_alias2`.`col_varchar_key`))) where exists(/* select#3 */ select `c_sq1_alias2`.`col_int_nokey` AS `c_sq1_field1` from (`t4` `c_sq1_alias2` left join `t3` `c_sq1_alias1` on((`c_sq1_alias2`.`col_int_nokey` = `c_sq1_alias1`.`pk`))) where (`c_sq1_alias2`.`col_varchar_key` = `sq1_alias2`.`col_varchar_nokey`))" + } + ] /* steps */ + } /* join_preparation */ + }, + { + "join_preparation": { + "select#": 4, + "steps": [ + { + "expanded_query": "/* select#4 */ select max(`sq2_alias1`.`pk`) AS `sq2_field1` from `t5` `sq2_alias1`" + } + ] /* steps */ + } /* join_preparation */ + }, + { + "join_preparation": { + "select#": 6, + "steps": [ + { + "expanded_query": "/* select#6 */ select `sq4_alias1`.`col_varchar_key` AS `sq4_field1` from (`t3` `sq4_alias1` join (`t3` `sq4_alias3` left join `t2` `sq4_alias2` on((`sq4_alias3`.`pk` = `sq4_alias2`.`col_int_key`))) on((`sq4_alias3`.`col_varchar_nokey` = `sq4_alias2`.`col_varchar_key`))) where ((`sq4_alias2`.`col_int_key` < `alias1`.`col_int_nokey`) and (`sq4_alias3`.`col_varchar_nokey` <> `alias1`.`col_varchar_key`))" + }, + { + "transformation": { + "select#": 6, + "from": "IN (SELECT)", + "to": "EXISTS (CORRELATED SELECT)", + "chosen": true, + "evaluating_constant_where_conditions": [ + ] /* evaluating_constant_where_conditions */ + } /* transformation */ + } + ] /* steps */ + } /* join_preparation */ + }, + { + "expanded_query": "/* select#1 */ select `alias1`.`col_varchar_key` AS `field1`,`alias1`.`col_date_key` AS `field2`,(/* select#2 */ select min(`sq1_alias1`.`col_varchar_nokey`) AS `sq1_field1` from (`t1` `sq1_alias1` join (`t5` `sq1_alias2` left join `t5` `sq1_alias3` on((`sq1_alias3`.`col_varchar_nokey` = `sq1_alias2`.`col_varchar_key`))) on((`sq1_alias3`.`col_varchar_nokey` = `sq1_alias2`.`col_varchar_key`))) where exists(/* select#3 */ select `c_sq1_alias2`.`col_int_nokey` AS `c_sq1_field1` from (`t4` `c_sq1_alias2` left join `t3` `c_sq1_alias1` on((`c_sq1_alias2`.`col_int_nokey` = `c_sq1_alias1`.`pk`))) where (`c_sq1_alias2`.`col_varchar_key` = `sq1_alias2`.`col_varchar_nokey`))) AS `field3`,(/* select#4 */ select max(`sq2_alias1`.`pk`) AS `sq2_field1` from `t5` `sq2_alias1`) AS `field4`,`sq3_alias2`.`col_varchar_nokey` AS `field5`,`sq3_alias2`.`col_varchar_nokey` AS `field6` from ((`t4` `alias3` left join ((`t5` `sq3_alias1` join `t4` `sq3_alias2`)) on((`alias3`.`col_varchar_key` = `sq3_alias2`.`col_varchar_key`))) left join `t5` `alias1` on((`alias3`.`col_int_key` = `sq3_alias2`.`pk`))) where ((`alias1`.`col_varchar_nokey`,(/* select#6 */ select `sq4_alias1`.`col_varchar_key` AS `sq4_field1` from (`t3` `sq4_alias1` join (`t3` `sq4_alias3` left join `t2` `sq4_alias2` on((`sq4_alias3`.`pk` = `sq4_alias2`.`col_int_key`))) on((`sq4_alias3`.`col_varchar_nokey` = `sq4_alias2`.`col_varchar_key`))) where ((`sq4_alias2`.`col_int_key` < `alias1`.`col_int_nokey`) and (`sq4_alias3`.`col_varchar_nokey` <> `alias1`.`col_varchar_key`) and ((`alias1`.`col_varchar_nokey`) = `sq4_alias1`.`col_varchar_key`)))) and (`alias1`.`col_int_key` <> 214)) group by `field1`,`field2`,`field3`,`field4`,`field5`,`field6`" + }, + { + "transformations_to_nested_joins": { + "transformations": [ + "outer_join_to_inner_join", + "JOIN_condition_to_WHERE", + "parenthesis_removal" + ] /* transformations */, + "expanded_query": "/* select#6 */ select `sq4_alias1`.`col_varchar_key` AS `sq4_field1` from `t3` `sq4_alias1` join `t3` `sq4_alias3` join `t2` `sq4_alias2` where ((`sq4_alias2`.`col_int_key` < `alias1`.`col_int_nokey`) and (`sq4_alias3`.`col_varchar_nokey` <> `alias1`.`col_varchar_key`) and ((`alias1`.`col_varchar_nokey`) = `sq4_alias1`.`col_varchar_key`) and (`sq4_alias3`.`col_varchar_nokey` = `sq4_alias2`.`col_varchar_key`) and (`sq4_alias3`.`pk` = `sq4_alias2`.`col_int_key`))" + } /* transformations_to_nested_joins */ + }, + { + "transformations_to_nested_joins": { + "transformations": [ + "parenthesis_removal" + ] /* transformations */, + "expanded_query": "/* select#3 */ select `c_sq1_alias2`.`col_int_nokey` AS `c_sq1_field1` from `t4` `c_sq1_alias2` left join `t3` `c_sq1_alias1` on((`c_sq1_alias2`.`col_int_nokey` = `c_sq1_alias1`.`pk`)) where (`c_sq1_alias2`.`col_varchar_key` = `sq1_alias2`.`col_varchar_nokey`)" + } /* transformations_to_nested_joins */ + }, + { + "transformations_to_nested_joins": { + "transformations": [ + "outer_join_to_inner_join", + "JOIN_condition_to_WHERE", + "parenthesis_removal" + ] /* transformations */, + "expanded_query": "/* select#2 */ select min(`sq1_alias1`.`col_varchar_nokey`) AS `sq1_field1` from `t1` `sq1_alias1` join `t5` `sq1_alias2` join `t5` `sq1_alias3` where (exists(/* select#3 */ select `c_sq1_alias2`.`col_int_nokey` AS `c_sq1_field1` from `t4` `c_sq1_alias2` left join `t3` `c_sq1_alias1` on((`c_sq1_alias2`.`col_int_nokey` = `c_sq1_alias1`.`pk`)) where (`c_sq1_alias2`.`col_varchar_key` = `sq1_alias2`.`col_varchar_nokey`)) and (`sq1_alias3`.`col_varchar_nokey` = `sq1_alias2`.`col_varchar_key`) and (`sq1_alias3`.`col_varchar_nokey` = `sq1_alias2`.`col_varchar_key`))" + } /* transformations_to_nested_joins */ + }, + { + "transformations_to_nested_joins": { + "transformations": [ + "outer_join_to_inner_join", + "JOIN_condition_to_WHERE", + "parenthesis_removal" + ] /* transformations */, + "expanded_query": "/* select#1 */ select `alias1`.`col_varchar_key` AS `field1`,`alias1`.`col_date_key` AS `field2`,(/* select#2 */ select min(`sq1_alias1`.`col_varchar_nokey`) AS `sq1_field1` from `t1` `sq1_alias1` join `t5` `sq1_alias2` join `t5` `sq1_alias3` where (exists(/* select#3 */ select `c_sq1_alias2`.`col_int_nokey` AS `c_sq1_field1` from `t4` `c_sq1_alias2` left join `t3` `c_sq1_alias1` on((`c_sq1_alias2`.`col_int_nokey` = `c_sq1_alias1`.`pk`)) where (`c_sq1_alias2`.`col_varchar_key` = `sq1_alias2`.`col_varchar_nokey`)) and (`sq1_alias3`.`col_varchar_nokey` = `sq1_alias2`.`col_varchar_key`) and (`sq1_alias3`.`col_varchar_nokey` = `sq1_alias2`.`col_varchar_key`))) AS `field3`,(/* select#4 */ select max(`sq2_alias1`.`pk`) AS `sq2_field1` from `t5` `sq2_alias1`) AS `field4`,`sq3_alias2`.`col_varchar_nokey` AS `field5`,`sq3_alias2`.`col_varchar_nokey` AS `field6` from `t4` `alias3` join `t5` `sq3_alias1` join `t4` `sq3_alias2` join `t5` `alias1` where ((`alias1`.`col_varchar_nokey`,(/* select#6 */ select `sq4_alias1`.`col_varchar_key` AS `sq4_field1` from `t3` `sq4_alias1` join `t3` `sq4_alias3` join `t2` `sq4_alias2` where ((`sq4_alias2`.`col_int_key` < `alias1`.`col_int_nokey`) and (`sq4_alias3`.`col_varchar_nokey` <> `alias1`.`col_varchar_key`) and ((`alias1`.`col_varchar_nokey`) = `sq4_alias1`.`col_varchar_key`) and (`sq4_alias3`.`col_varchar_nokey` = `sq4_alias2`.`col_varchar_key`) and (`sq4_alias3`.`pk` = `sq4_alias2`.`col_int_key`)))) and (`alias1`.`col_int_key` <> 214) and (`alias3`.`col_int_key` = `sq3_alias2`.`pk`) and (`alias3`.`col_varchar_key` = `sq3_alias2`.`col_varchar_key`)) group by `field1`,`field2`,`field3`,`field4`,`field5`,`field6`" + } /* transformations_to_nested_joins */ + } + ] /* steps */ + } /* join_preparation */ + }, + { + "join_optimization": { + "select#": 1, + "steps": [ + { + "condition_processing": { + "condition": "WHERE", + "original_condition": "((`alias1`.`col_varchar_nokey`,(/* select#6 */ select `sq4_alias1`.`col_varchar_key` AS `sq4_field1` from `t3` `sq4_alias1` join `t3` `sq4_alias3` join `t2` `sq4_alias2` where ((`sq4_alias2`.`col_int_key` < `alias1`.`col_int_nokey`) and (`sq4_alias3`.`col_varchar_nokey` <> `alias1`.`col_varchar_key`) and ((`alias1`.`col_varchar_nokey`) = `sq4_alias1`.`col_varchar_key`) and (`sq4_alias3`.`col_varchar_nokey` = `sq4_alias2`.`col_varchar_key`) and (`sq4_alias3`.`pk` = `sq4_alias2`.`col_int_key`)))) and (`alias1`.`col_int_key` <> 214) and (`alias3`.`col_int_key` = `sq3_alias2`.`pk`) and (`alias3`.`col_varchar_key` = `sq3_alias2`.`col_varchar_key`))", + "steps": [ + { + "transformation": "equality_propagation", + "subselect_evaluation": [ + ] /* subselect_evaluation */, + "resulting_condition": "((`alias1`.`col_varchar_nokey`,(/* select#6 */ select `sq4_alias1`.`col_varchar_key` AS `sq4_field1` from `t3` `sq4_alias1` join `t3` `sq4_alias3` join `t2` `sq4_alias2` where ((`sq4_alias2`.`col_int_key` < `alias1`.`col_int_nokey`) and (`sq4_alias3`.`col_varchar_nokey` <> `alias1`.`col_varchar_key`) and ((`alias1`.`col_varchar_nokey`) = `sq4_alias1`.`col_varchar_key`) and (`sq4_alias3`.`col_varchar_nokey` = `sq4_alias2`.`col_varchar_key`) and (`sq4_alias3`.`pk` = `sq4_alias2`.`col_int_key`)))) and (`alias1`.`col_int_key` <> 214) and multiple equal(`alias3`.`col_int_key`, `sq3_alias2`.`pk`) and multiple equal(`alias3`.`col_varchar_key`, `sq3_alias2`.`col_varchar_key`))" + }, + { + "transformation": "constant_propagation", + "subselect_evaluation": [ + ] /* subselect_evaluation */, + "resulting_condition": "((`alias1`.`col_varchar_nokey`,(/* select#6 */ select `sq4_alias1`.`col_varchar_key` AS `sq4_field1` from `t3` `sq4_alias1` join `t3` `sq4_alias3` join `t2` `sq4_alias2` where ((`sq4_alias2`.`col_int_key` < `alias1`.`col_int_nokey`) and (`sq4_alias3`.`col_varchar_nokey` <> `alias1`.`col_varchar_key`) and ((`alias1`.`col_varchar_nokey`) = `sq4_alias1`.`col_varchar_key`) and (`sq4_alias3`.`col_varchar_nokey` = `sq4_alias2`.`col_varchar_key`) and (`sq4_alias3`.`pk` = `sq4_alias2`.`col_int_key`)))) and (`alias1`.`col_int_key` <> 214) and multiple equal(`alias3`.`col_int_key`, `sq3_alias2`.`pk`) and multiple equal(`alias3`.`col_varchar_key`, `sq3_alias2`.`col_varchar_key`))" + }, + { + "transformation": "trivial_condition_removal", + "subselect_evaluation": [ + ] /* subselect_evaluation */, + "resulting_condition": "((`alias1`.`col_varchar_nokey`,(/* select#6 */ select `sq4_alias1`.`col_varchar_key` AS `sq4_field1` from `t3` `sq4_alias1` join `t3` `sq4_alias3` join `t2` `sq4_alias2` where ((`sq4_alias2`.`col_int_key` < `alias1`.`col_int_nokey`) and (`sq4_alias3`.`col_varchar_nokey` <> `alias1`.`col_varchar_key`) and ((`alias1`.`col_varchar_nokey`) = `sq4_alias1`.`col_varchar_key`) and (`sq4_alias3`.`col_varchar_nokey` = `sq4_alias2`.`col_varchar_key`) and (`sq4_alias3`.`pk` = `sq4_alias2`.`col_int_key`)))) and (`alias1`.`col_int_key` <> 214) and multiple equal(`alias3`.`col_int_key`, `sq3_alias2`.`pk`) and multiple equal(`alias3`.`col_varchar_key`, `sq3_alias2`.`col_varchar_key`))" + } + ] /* steps */ + } /* condition_processing */ + }, + { + "substitute_generated_columns": { + } /* substitute_generated_columns */ + }, + { + "table_dependencies": [ + { + "table": "`t4` `alias3`", + "row_may_be_null": false, + "map_bit": 0, + "depends_on_map_bits": [ + ] /* depends_on_map_bits */ + }, + { + "table": "`t5` `sq3_alias1`", + "row_may_be_null": true, + "map_bit": 1, + "depends_on_map_bits": [ + ] /* depends_on_map_bits */ + }, + { + "table": "`t4` `sq3_alias2`", + "row_may_be_null": true, + "map_bit": 2, + "depends_on_map_bits": [ + ] /* depends_on_map_bits */ + }, + { + "table": "`t5` `alias1`", + "row_may_be_null": true, + "map_bit": 3, + "depends_on_map_bits": [ + ] /* depends_on_map_bits */ + } + ] /* table_dependencies */ + }, + { + "ref_optimizer_key_uses": [ + { + "table": "`t4` `alias3`", + "field": "col_varchar_key", + "equals": "`sq3_alias2`.`col_varchar_key`", + "null_rejecting": true + }, + { + "table": "`t4` `alias3`", + "field": "col_int_key", + "equals": "`sq3_alias2`.`pk`", + "null_rejecting": true + }, + { + "table": "`t4` `sq3_alias2`", + "field": "pk", + "equals": "`alias3`.`col_int_key`", + "null_rejecting": true + }, + { + "table": "`t4` `sq3_alias2`", + "field": "col_varchar_key", + "equals": "`alias3`.`col_varchar_key`", + "null_rejecting": true + } + ] /* ref_optimizer_key_uses */ + }, + { + "rows_estimation": [ + { + "table": "`t4` `alias3`", + "rows": 1, + "cost": 1, + "table_type": "system", + "empty": false + }, + { + "table": "`t5` `sq3_alias1`", + "table_scan": { + "rows": 3, + "cost": 0.508545 + } /* table_scan */ + }, + { + "table": "`t4` `sq3_alias2`", + "rows": 1, + "cost": 1, + "table_type": "system", + "empty": false + }, + { + "table": "`t5` `alias1`", + "range_analysis": { + "table_scan": { + "rows": 3, + "cost": 2.90854 + } /* table_scan */, + "potential_range_indexes": [ + { + "index": "PRIMARY", + "usable": false, + "cause": "not_applicable" + }, + { + "index": "col_int_key", + "usable": true, + "key_parts": [ + "col_int_key" + ] /* key_parts */ + }, + { + "index": "col_varchar_key", + "usable": false, + "cause": "not_applicable" + } + ] /* potential_range_indexes */, + "setup_range_conditions": [ + ] /* setup_range_conditions */, + "impossible_range": true + } /* range_analysis */, + "rows": 0, + "cause": "impossible_where_condition" + } + ] /* rows_estimation */ + }, + { + "considered_execution_plans": [ + { + "plan_prefix": [ + "`t4` `alias3`", + "`t4` `sq3_alias2`", + "`t5` `alias1`" + ] /* plan_prefix */, + "table": "`t5` `sq3_alias1`", + "best_access_path": { + "considered_access_paths": [ + { + "rows_to_scan": 3, + "access_type": "scan", + "resulting_rows": 3, + "cost": 0.808545, + "chosen": true + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 100, + "rows_for_plan": 3, + "cost_for_plan": 0.808545, + "chosen": true + } + ] /* considered_execution_plans */ + } + ] /* steps */, + "empty_result": { + "cause": "no matching row in const table" + } /* empty_result */ + } /* join_optimization */ + }, + { + "join_execution": { + "select#": 1, + "steps": [ + ] /* steps */ + } /* join_execution */ + } + ] /* steps */ +} 0 0 +set optimizer_switch=@old_opt_switch; +drop table t1,t2,t3,t4,t5; +# +# BUG#12905758 - ASSERT IN OPT_TRACE_STMT::SYNTAX_ERROR ON +# SELECT/SUBQ/SUM QUERY +# +CREATE TABLE t1 ( +pk INTEGER AUTO_INCREMENT, +col_int_nokey INTEGER, +col_int_key INTEGER, +col_date_key DATE, +col_date_nokey DATE, +col_time_key TIME, +col_time_nokey TIME, +col_datetime_key DATETIME, +col_datetime_nokey DATETIME, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk), +KEY (col_varchar_key,col_int_key) +) ENGINE=MYISAM, CHARSET utf8mb4; +INSERT INTO t1 ( +col_int_key,col_int_nokey, +col_date_key,col_date_nokey, +col_time_key,col_time_nokey, +col_datetime_key,col_datetime_nokey, +col_varchar_key,col_varchar_nokey +) VALUES +(8,NULL,'2000-12-03','2000-12-03','22:55:23.019225','22:55:23.019225','2005-07-20 00:00:00','2005-07-20 00:00:00','x','x'), +(8,6,'2000-09-20','2000-09-20','14:11:27.044095','14:11:27.044095','2003-06-13 23:19:49.018300','2003-06-13 23:19:49.018300','c','c'); +CREATE TABLE t2 (I INTEGER); +select ( select sum( subquery1_t1.`col_int_nokey` ) as subquery1_field1 from +t1 as subquery1_t1 ) as field1 from ( t1 as table1 straight_join t1 as table2 +on (table2.`col_varchar_key` = table1.`col_varchar_key` ) ) where ( +table2.`col_int_nokey` <> any ( select 5 from t2 ) ) and table1.`pk` in +(192,18) order by field1 desc; +field1 +select * from information_schema.optimizer_trace; +QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES +select ( select sum( subquery1_t1.`col_int_nokey` ) as subquery1_field1 from +t1 as subquery1_t1 ) as field1 from ( t1 as table1 straight_join t1 as table2 +on (table2.`col_varchar_key` = table1.`col_varchar_key` ) ) where ( +table2.`col_int_nokey` <> any ( select 5 from t2 ) ) and table1.`pk` in +(192,18) order by field1 desc { + "steps": [ + { + "join_preparation": { + "select#": 1, + "steps": [ + { + "join_preparation": { + "select#": 2, + "steps": [ + { + "expanded_query": "/* select#2 */ select sum(`subquery1_t1`.`col_int_nokey`) AS `subquery1_field1` from `t1` `subquery1_t1`" + } + ] /* steps */ + } /* join_preparation */ + }, + { + "join_preparation": { + "select#": 3, + "steps": [ + { + "expanded_query": "/* select#3 */ select 5 from `t2`" + }, + { + "transformation": { + "select#": 3, + "from": "IN (SELECT)", + "to": "EXISTS (CORRELATED SELECT)", + "chosen": true, + "evaluating_constant_where_conditions": [ + ] /* evaluating_constant_where_conditions */ + } /* transformation */ + } + ] /* steps */ + } /* join_preparation */ + }, + { + "IN_uses_bisection": true + }, + { + "expanded_query": "/* select#1 */ select (/* select#2 */ select sum(`subquery1_t1`.`col_int_nokey`) AS `subquery1_field1` from `t1` `subquery1_t1`) AS `field1` from (`t1` `table1` straight_join `t1` `table2` on((`table2`.`col_varchar_key` = `table1`.`col_varchar_key`))) where (((`table2`.`col_int_nokey`,(/* select#3 */ select 5 from `t2` where (outer_field_is_not_null, ((`table2`.`col_int_nokey`) <> 5), true)))) and (`table1`.`pk` in (192,18))) order by `field1` desc" + }, + { + "transformations_to_nested_joins": { + "transformations": [ + "JOIN_condition_to_WHERE", + "parenthesis_removal" + ] /* transformations */, + "expanded_query": "/* select#1 */ select (/* select#2 */ select sum(`subquery1_t1`.`col_int_nokey`) AS `subquery1_field1` from `t1` `subquery1_t1`) AS `field1` from `t1` `table1` straight_join `t1` `table2` where (((`table2`.`col_int_nokey`,(/* select#3 */ select 5 from `t2` where (outer_field_is_not_null, ((`table2`.`col_int_nokey`) <> 5), true)))) and (`table1`.`pk` in (192,18)) and (`table2`.`col_varchar_key` = `table1`.`col_varchar_key`)) order by `field1` desc" + } /* transformations_to_nested_joins */ + } + ] /* steps */ + } /* join_preparation */ + }, + { + "join_optimization": { + "select#": 1, + "steps": [ + { + "condition_processing": { + "condition": "WHERE", + "original_condition": "(((`table2`.`col_int_nokey`,(/* select#3 */ select 5 from `t2` where (outer_field_is_not_null, ((`table2`.`col_int_nokey`) <> 5), true)))) and (`table1`.`pk` in (192,18)) and (`table2`.`col_varchar_key` = `table1`.`col_varchar_key`))", + "steps": [ + { + "transformation": "equality_propagation", + "subselect_evaluation": [ + ] /* subselect_evaluation */, + "resulting_condition": "(((`table2`.`col_int_nokey`,(/* select#3 */ select 5 from `t2` where (outer_field_is_not_null, ((`table2`.`col_int_nokey`) <> 5), true)))) and (`table1`.`pk` in (192,18)) and multiple equal(`table2`.`col_varchar_key`, `table1`.`col_varchar_key`))" + }, + { + "transformation": "constant_propagation", + "subselect_evaluation": [ + ] /* subselect_evaluation */, + "resulting_condition": "(((`table2`.`col_int_nokey`,(/* select#3 */ select 5 from `t2` where (outer_field_is_not_null, ((`table2`.`col_int_nokey`) <> 5), true)))) and (`table1`.`pk` in (192,18)) and multiple equal(`table2`.`col_varchar_key`, `table1`.`col_varchar_key`))" + }, + { + "transformation": "trivial_condition_removal", + "subselect_evaluation": [ + ] /* subselect_evaluation */, + "resulting_condition": "(((`table2`.`col_int_nokey`,(/* select#3 */ select 5 from `t2` where (outer_field_is_not_null, ((`table2`.`col_int_nokey`) <> 5), true)))) and (`table1`.`pk` in (192,18)) and multiple equal(`table2`.`col_varchar_key`, `table1`.`col_varchar_key`))" + } + ] /* steps */ + } /* condition_processing */ + }, + { + "substitute_generated_columns": { + } /* substitute_generated_columns */ + }, + { + "table_dependencies": [ + { + "table": "`t1` `table1`", + "row_may_be_null": false, + "map_bit": 0, + "depends_on_map_bits": [ + ] /* depends_on_map_bits */ + }, + { + "table": "`t1` `table2`", + "row_may_be_null": false, + "map_bit": 1, + "depends_on_map_bits": [ + 0 + ] /* depends_on_map_bits */ + } + ] /* table_dependencies */ + }, + { + "ref_optimizer_key_uses": [ + { + "table": "`t1` `table1`", + "field": "col_varchar_key", + "equals": "`table2`.`col_varchar_key`", + "null_rejecting": true + }, + { + "table": "`t1` `table2`", + "field": "col_varchar_key", + "equals": "`table1`.`col_varchar_key`", + "null_rejecting": true + } + ] /* ref_optimizer_key_uses */ + }, + { + "rows_estimation": [ + { + "table": "`t1` `table1`", + "range_analysis": { + "table_scan": { + "rows": 2, + "cost": 2.80562 + } /* table_scan */, + "potential_range_indexes": [ + { + "index": "PRIMARY", + "usable": true, + "key_parts": [ + "pk" + ] /* key_parts */ + }, + { + "index": "col_varchar_key", + "usable": false, + "cause": "not_applicable" + } + ] /* potential_range_indexes */, + "setup_range_conditions": [ + ] /* setup_range_conditions */, + "group_index_range": { + "chosen": false, + "cause": "not_single_table" + } /* group_index_range */, + "skip_scan_range": { + "chosen": false, + "cause": "not_single_table" + } /* skip_scan_range */, + "analyzing_range_alternatives": { + "range_scan_alternatives": [ + { + "index": "PRIMARY", + "ranges": [ + "18 <= pk <= 18", + "192 <= pk <= 192" + ] /* ranges */, + "index_dives_for_eq_ranges": true, + "rowid_ordered": false, + "using_mrr": false, + "index_only": false, + "rows": 2, + "cost": 1.21, + "chosen": true + } + ] /* range_scan_alternatives */, + "analyzing_roworder_intersect": { + "usable": false, + "cause": "too_few_roworder_scans" + } /* analyzing_roworder_intersect */ + } /* analyzing_range_alternatives */, + "chosen_range_access_summary": { + "range_access_plan": { + "type": "range_scan", + "index": "PRIMARY", + "rows": 2, + "ranges": [ + "18 <= pk <= 18", + "192 <= pk <= 192" + ] /* ranges */ + } /* range_access_plan */, + "rows_for_plan": 2, + "cost_for_plan": 1.21, + "chosen": true + } /* chosen_range_access_summary */ + } /* range_analysis */ + }, + { + "table": "`t1` `table2`", + "table_scan": { + "rows": 2, + "cost": 0.505615 + } /* table_scan */ + } + ] /* rows_estimation */ + }, + { + "considered_execution_plans": [ + { + "plan_prefix": [ + ] /* plan_prefix */, + "table": "`t1` `table1`", + "best_access_path": { + "considered_access_paths": [ + { + "access_type": "ref", + "index": "col_varchar_key", + "usable": false, + "chosen": false + }, + { + "rows_to_scan": 2, + "filtering_effect": [ + ] /* filtering_effect */, + "final_filtering_effect": 1, + "access_type": "range", + "range_details": { + "used_index": "PRIMARY" + } /* range_details */, + "resulting_rows": 2, + "cost": 1.41, + "chosen": true + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 100, + "rows_for_plan": 2, + "cost_for_plan": 1.41, + "rest_of_plan": [ + { + "plan_prefix": [ + "`t1` `table1`" + ] /* plan_prefix */, + "table": "`t1` `table2`", + "best_access_path": { + "considered_access_paths": [ + { + "access_type": "ref", + "index": "col_varchar_key", + "rows": 2, + "cost": 1.4, + "chosen": true + }, + { + "rows_to_scan": 2, + "filtering_effect": [ + ] /* filtering_effect */, + "final_filtering_effect": 1, + "access_type": "scan", + "using_join_cache": true, + "buffers_needed": 1, + "resulting_rows": 2, + "cost": 0.905658, + "chosen": true + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 100, + "rows_for_plan": 4, + "cost_for_plan": 2.31566, + "chosen": true + } + ] /* rest_of_plan */ + } + ] /* considered_execution_plans */ + }, + { + "attaching_conditions_to_tables": { + "original_condition": "((`table2`.`col_varchar_key` = `table1`.`col_varchar_key`) and ((`table2`.`col_int_nokey`,(/* select#3 */ select 5 from `t2` where (outer_field_is_not_null, ((`table2`.`col_int_nokey`) <> 5), true)))) and (`table1`.`pk` in (192,18)))", + "attached_conditions_computation": [ + { + "table": "`t1` `table2`", + "rechecking_index_usage": { + "recheck_reason": "not_first_table", + "range_analysis": { + "table_scan": { + "rows": 2, + "cost": 2.80562 + } /* table_scan */, + "potential_range_indexes": [ + { + "index": "PRIMARY", + "usable": false, + "cause": "not_applicable" + }, + { + "index": "col_varchar_key", + "usable": true, + "key_parts": [ + "col_varchar_key", + "col_int_key" + ] /* key_parts */ + } + ] /* potential_range_indexes */, + "setup_range_conditions": [ + ] /* setup_range_conditions */, + "group_index_range": { + "chosen": false, + "cause": "not_single_table" + } /* group_index_range */, + "skip_scan_range": { + "chosen": false, + "cause": "not_single_table" + } /* skip_scan_range */, + "analyzing_range_alternatives": { + "range_scan_alternatives": [ + { + "index": "col_varchar_key", + "chosen": false, + "cause": "depends_on_unread_values" + } + ] /* range_scan_alternatives */, + "analyzing_roworder_intersect": { + "usable": false, + "cause": "too_few_roworder_scans" + } /* analyzing_roworder_intersect */ + } /* analyzing_range_alternatives */ + } /* range_analysis */ + } /* rechecking_index_usage */ + } + ] /* attached_conditions_computation */, + "attached_conditions_summary": [ + { + "table": "`t1` `table1`", + "attached": "(`table1`.`pk` in (192,18))" + }, + { + "table": "`t1` `table2`", + "attached": "((`table2`.`col_varchar_key` = `table1`.`col_varchar_key`) and ((`table2`.`col_int_nokey`,(/* select#3 */ select 5 from `t2` where (outer_field_is_not_null, ((`table2`.`col_int_nokey`) <> 5), true)))))" + } + ] /* attached_conditions_summary */ + } /* attaching_conditions_to_tables */ + }, + { + "optimizing_distinct_group_by_order_by": { + "simplifying_order_by": { + "original_clause": "`field1` desc", + "items": [ + { + "item": "(/* select#2 */ select sum(`subquery1_t1`.`col_int_nokey`) AS `subquery1_field1` from `t1` `subquery1_t1`)", + "subselect_evaluation": [ + { + "subselect_execution": { + "select#": 2, + "steps": [ + { + "join_optimization": { + "select#": 2, + "steps": [ + { + "table_dependencies": [ + { + "table": "`t1` `subquery1_t1`", + "row_may_be_null": false, + "map_bit": 0, + "depends_on_map_bits": [ + ] /* depends_on_map_bits */ + } + ] /* table_dependencies */ + }, + { + "rows_estimation": [ + { + "table": "`t1` `subquery1_t1`", + "table_scan": { + "rows": 2, + "cost": 0.505615 + } /* table_scan */ + } + ] /* rows_estimation */ + }, + { + "considered_execution_plans": [ + { + "plan_prefix": [ + ] /* plan_prefix */, + "table": "`t1` `subquery1_t1`", + "best_access_path": { + "considered_access_paths": [ + { + "rows_to_scan": 2, + "access_type": "scan", + "resulting_rows": 2, + "cost": 0.705615, + "chosen": true + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 100, + "rows_for_plan": 2, + "cost_for_plan": 0.705615, + "chosen": true + } + ] /* considered_execution_plans */ + }, + { + "attaching_conditions_to_tables": { + "original_condition": null, + "attached_conditions_computation": [ + ] /* attached_conditions_computation */, + "attached_conditions_summary": [ + { + "table": "`t1` `subquery1_t1`", + "attached": null + } + ] /* attached_conditions_summary */ + } /* attaching_conditions_to_tables */ + }, + { + "optimizing_distinct_group_by_order_by": { + } /* optimizing_distinct_group_by_order_by */ + }, + { + "finalizing_table_conditions": [ + ] /* finalizing_table_conditions */ + }, + { + "refine_plan": [ + { + "table": "`t1` `subquery1_t1`" + } + ] /* refine_plan */ + }, + { + "considering_tmp_tables": [ + ] /* considering_tmp_tables */ + } + ] /* steps */ + } /* join_optimization */ + }, + { + "join_execution": { + "select#": 2, + "steps": [ + ] /* steps */ + } /* join_execution */ + } + ] /* steps */ + } /* subselect_execution */ + } + ] /* subselect_evaluation */, + "uses_only_constant_tables": true + } + ] /* items */, + "resulting_clause_is_simple": true, + "resulting_clause": "" + } /* simplifying_order_by */ + } /* optimizing_distinct_group_by_order_by */ + }, + { + "finalizing_table_conditions": [ + { + "table": "`t1` `table1`", + "original_table_condition": "(`table1`.`pk` in (192,18))", + "final_table_condition ": "(`table1`.`pk` in (192,18))" + }, + { + "table": "`t1` `table2`", + "original_table_condition": "((`table2`.`col_varchar_key` = `table1`.`col_varchar_key`) and ((`table2`.`col_int_nokey`,(/* select#3 */ select 5 from `t2` where (outer_field_is_not_null, ((`table2`.`col_int_nokey`) <> 5), true)))))", + "final_table_condition ": "((`table2`.`col_varchar_key` = `table1`.`col_varchar_key`) and ((`table2`.`col_int_nokey`,(/* select#3 */ select 5 from `t2` where (outer_field_is_not_null, ((`table2`.`col_int_nokey`) <> 5), true)))))" + } + ] /* finalizing_table_conditions */ + }, + { + "refine_plan": [ + { + "table": "`t1` `table1`", + "pushed_index_condition": "(`table1`.`pk` in (192,18))", + "table_condition_attached": null + }, + { + "table": "`t1` `table2`" + } + ] /* refine_plan */ + } + ] /* steps */ + } /* join_optimization */ + }, + { + "join_optimization": { + "select#": 3, + "steps": [ + { + "condition_processing": { + "condition": "WHERE", + "original_condition": "(outer_field_is_not_null, ((`table2`.`col_int_nokey`) <> 5), true)", + "steps": [ + { + "transformation": "equality_propagation", + "resulting_condition": "(outer_field_is_not_null, ((`table2`.`col_int_nokey`) <> 5), true)" + }, + { + "transformation": "constant_propagation", + "resulting_condition": "(outer_field_is_not_null, ((`table2`.`col_int_nokey`) <> 5), true)" + }, + { + "transformation": "trivial_condition_removal", + "resulting_condition": "(outer_field_is_not_null, ((`table2`.`col_int_nokey`) <> 5), true)" + } + ] /* steps */ + } /* condition_processing */ + }, + { + "substitute_generated_columns": { + } /* substitute_generated_columns */ + }, + { + "table_dependencies": [ + { + "table": "`t2`", + "row_may_be_null": false, + "map_bit": 0, + "depends_on_map_bits": [ + ] /* depends_on_map_bits */ + } + ] /* table_dependencies */ + }, + { + "ref_optimizer_key_uses": [ + ] /* ref_optimizer_key_uses */ + }, + { + "rows_estimation": [ + { + "table": "`t2`", + "rows": 1, + "cost": 1, + "table_type": "system", + "empty": true + } + ] /* rows_estimation */ + }, + { + "transformation": { + "select#": 3, + "from": "IN (SELECT)", + "to": "materialization", + "possible": false, + "cause": "not an IN predicate" + } /* transformation */ + } + ] /* steps */, + "empty_result": { + "cause": "no matching row in const table" + } /* empty_result */ + } /* join_optimization */ + }, + { + "join_execution": { + "select#": 1, + "steps": [ + ] /* steps */ + } /* join_execution */ + } + ] /* steps */ +} 0 0 +drop table t1,t2; + +# +# Tracing of semijoin loosescan +# +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (a int, b int, filler char(100), key(a,b)) charset utf8mb4; +insert into t1 select A.a, B.a, 'filler' from t0 A, t0 B; +create table t2 as select * from t1; +set @old_opt_switch=@@optimizer_switch; +set optimizer_switch="firstmatch=off,materialization=off,duplicateweedout=off"; +set @old_opt_prune_level=@@optimizer_prune_level; +set optimizer_prune_level=0; +explain select * from t2 where a in (select b from t1 where a=3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ref a a 5 const 8 100.00 Using index; LooseScan +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 100 10.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`filler` AS `filler` from `test`.`t2` semi join (`test`.`t1`) where ((`test`.`t2`.`a` = `test`.`t1`.`b`) and (`test`.`t1`.`a` = 3)) +# Equality-propagation involving inner field => 1st sj equality is bound +explain select * from t2 where (b+0,a+0) in (select a,b from t1 where a=3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ref a a 5 const 8 100.00 Using index; LooseScan +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 100 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`filler` AS `filler` from `test`.`t2` semi join (`test`.`t1`) where ((`test`.`t1`.`a` = 3) and ((`test`.`t2`.`b` + 0) = 3) and ((`test`.`t2`.`a` + 0) = `test`.`t1`.`b`)) +# Equality-propagation involving outer field => 3rd sj equality is bound. +explain select * from t2 where (b,a,filler) in (select a,b,a*3 from t1) and filler='abc'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index a a 10 NULL 100 100.00 Using index; LooseScan +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 100 1.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`filler` AS `filler` from `test`.`t2` semi join (`test`.`t1`) where ((`test`.`t2`.`a` = `test`.`t1`.`b`) and (`test`.`t2`.`b` = `test`.`t1`.`a`) and (`test`.`t2`.`filler` = 'abc') and (cast(`test`.`t2`.`filler` as double) = cast((`test`.`t1`.`a` * 3) as double))) +SELECT show_json_object('"recalculate_access_paths_and_cost": {', TRACE) +FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +show_json_object('"recalculate_access_paths_and_cost": {', TRACE) +"recalculate_access_paths_and_cost": { + "tables": [ + { + "table": "`t1`", + "best_access_path": { + "considered_access_paths": [ + { + "access_type": "ref", + "index": "a", + "usable": false, + "chosen": false + }, + { + "rows_to_scan": 100, + "filtering_effect": [ + ] /* filtering_effect */, + "final_filtering_effect": 1, + "access_type": "scan", + "resulting_rows": 100, + "cost": 12.9963, + "chosen": true + } + ] /* considered_access_paths */ + } /* best_access_path */, + "unknown_key_1": { + "searching_loose_scan_index": { + "indexes": [ + { + "index": "a", + "covering_scan": { + "cost": 1.04839, + "chosen": true + } /* covering_scan */ + } + ] /* indexes */ + } /* searching_loose_scan_index */ + } + }, + { + "table": "`t2`", + "best_access_path": { + "considered_access_paths": [ + { + "rows_to_scan": 100, + "filtering_effect": [ + ] /* filtering_effect */, + "final_filtering_effect": 0.1, + "access_type": "scan", + "using_join_cache": true, + "buffers_needed": 1, + "resulting_rows": 10, + "cost": 112.038, + "chosen": true + } + ] /* considered_access_paths */ + } /* best_access_path */ + } + ] /* tables */ + } +# Remove the condition on 'filler' => 3rd sj equality is not bound. +explain select * from t2 where (b,a,filler) in (select a,b,a*3 from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 100 100.00 Using where +1 SIMPLE t1 NULL ref a a 10 test.t2.b,test.t2.a 1 100.00 Using index; Start temporary; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`filler` AS `filler` from `test`.`t2` semi join (`test`.`t1`) where ((`test`.`t1`.`b` = `test`.`t2`.`a`) and (`test`.`t1`.`a` = `test`.`t2`.`b`) and (cast(`test`.`t2`.`filler` as double) = cast((`test`.`t2`.`b` * 3) as double))) +SELECT show_json_object('"searching_loose_scan_index": {', TRACE) +FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +show_json_object('"searching_loose_scan_index": {', TRACE) +"searching_loose_scan_index": { + "indexes": [ + { + "index": "a", + "index_handles_needed_semijoin_equalities": false + } + ] /* indexes */ + } +# Equality-propagation involving outer field => 3rd sj equality is bound. +explain select * from t2 as t3, t2 +where t2.filler=t3.filler and +(t2.b,t2.a,t2.filler) in (select a,b,a*3 from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 100 100.00 NULL +1 SIMPLE t1 NULL index a a 10 NULL 100 100.00 Using where; Using index; LooseScan +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 100 1.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t3`.`filler` AS `filler`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`filler` AS `filler` from `test`.`t2` `t3` join `test`.`t2` semi join (`test`.`t1`) where ((`test`.`t2`.`a` = `test`.`t1`.`b`) and (`test`.`t2`.`b` = `test`.`t1`.`a`) and (`test`.`t2`.`filler` = `test`.`t3`.`filler`) and (cast(`test`.`t3`.`filler` as double) = cast((`test`.`t1`.`a` * 3) as double))) +SELECT show_json_object('"recalculate_access_paths_and_cost": {', TRACE) +FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +show_json_object('"recalculate_access_paths_and_cost": {', TRACE) +"recalculate_access_paths_and_cost": { + "tables": [ + { + "table": "`t1`", + "best_access_path": { + "considered_access_paths": [ + { + "access_type": "ref", + "index": "a", + "usable": false, + "chosen": false + }, + { + "rows_to_scan": 100, + "filtering_effect": [ + ] /* filtering_effect */, + "final_filtering_effect": 1, + "access_type": "scan", + "resulting_rows": 100, + "cost": 1299.63, + "chosen": true + } + ] /* considered_access_paths */ + } /* best_access_path */, + "unknown_key_1": { + "searching_loose_scan_index": { + "indexes": [ + { + "index": "a", + "covering_scan": { + "cost": 1.04839, + "chosen": true + } /* covering_scan */ + } + ] /* indexes */ + } /* searching_loose_scan_index */ + } + }, + { + "table": "`t2`", + "best_access_path": { + "considered_access_paths": [ + { + "rows_to_scan": 100, + "filtering_effect": [ + ] /* filtering_effect */, + "final_filtering_effect": 1, + "access_type": "scan", + "using_join_cache": true, + "buffers_needed": 16, + "resulting_rows": 100, + "cost": 100051, + "chosen": true + } + ] /* considered_access_paths */ + } /* best_access_path */ + } + ] /* tables */ + } +# In plan t3-t1-t2, 3rd outer expression is dependent only on +# previous tables => 3rd sj equality is bound. +# If t1 is before t3, 3rd sj equality is not bound. +explain select * from t2 as t3 left join t2 on t2.filler+10=t3.filler+20 +where (t2.b,t2.a,t3.filler+2) in (select a,b,a*3 from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 100 100.00 NULL +1 SIMPLE t1 NULL index a a 10 NULL 100 100.00 Using where; Using index; LooseScan +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 100 1.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t3`.`filler` AS `filler`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`filler` AS `filler` from `test`.`t2` `t3` join `test`.`t2` semi join (`test`.`t1`) where ((`test`.`t2`.`a` = `test`.`t1`.`b`) and (`test`.`t2`.`b` = `test`.`t1`.`a`) and ((`test`.`t3`.`filler` + 2) = (`test`.`t1`.`a` * 3)) and ((`test`.`t2`.`filler` + 10) = (`test`.`t3`.`filler` + 20))) +SELECT show_json_object('"considered_execution_plans": [', TRACE) +FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +show_json_object('"considered_execution_plans": [', TRACE) +"considered_execution_plans": [ + { + "plan_prefix": [ + ] /* plan_prefix */, + "table": "`t2` `t3`", + "best_access_path": { + "considered_access_paths": [ + { + "rows_to_scan": 100, + "filtering_effect": [ + ] /* filtering_effect */, + "final_filtering_effect": 1, + "access_type": "scan", + "resulting_rows": 100, + "cost": 12.9963, + "chosen": true + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 100, + "rows_for_plan": 100, + "cost_for_plan": 12.9963, + "semijoin_strategy_choice": [ + ] /* semijoin_strategy_choice */, + "rest_of_plan": [ + { + "plan_prefix": [ + "`t2` `t3`" + ] /* plan_prefix */, + "table": "`t2`", + "best_access_path": { + "considered_access_paths": [ + { + "rows_to_scan": 100, + "filtering_effect": [ + ] /* filtering_effect */, + "final_filtering_effect": 1, + "access_type": "scan", + "using_join_cache": true, + "buffers_needed": 1, + "resulting_rows": 100, + "cost": 1003.46, + "chosen": true + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 100, + "rows_for_plan": 10000, + "cost_for_plan": 1016.46, + "semijoin_strategy_choice": [ + ] /* semijoin_strategy_choice */, + "rest_of_plan": [ + { + "plan_prefix": [ + "`t2` `t3`", + "`t2`" + ] /* plan_prefix */, + "table": "`t1`", + "best_access_path": { + "considered_access_paths": [ + { + "access_type": "ref", + "index": "a", + "rows": 1, + "cost": 3500, + "chosen": true + }, + { + "rows_to_scan": 100, + "filtering_effect": [ + ] /* filtering_effect */, + "final_filtering_effect": 1, + "access_type": "scan", + "using_join_cache": true, + "buffers_needed": 32, + "resulting_rows": 100, + "cost": 100097, + "chosen": false + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 100, + "rows_for_plan": 10000, + "cost_for_plan": 4516.46, + "semijoin_strategy_choice": [ + { + "strategy": "DuplicatesWeedout", + "cost": 6517.46, + "rows": 10000, + "duplicate_tables_left": true, + "chosen": true + } + ] /* semijoin_strategy_choice */, + "chosen": true + } + ] /* rest_of_plan */ + }, + { + "plan_prefix": [ + "`t2` `t3`" + ] /* plan_prefix */, + "table": "`t1`", + "best_access_path": { + "considered_access_paths": [ + { + "access_type": "ref", + "index": "a", + "usable": false, + "chosen": false + }, + { + "rows_to_scan": 100, + "filtering_effect": [ + ] /* filtering_effect */, + "final_filtering_effect": 1, + "access_type": "scan", + "using_join_cache": true, + "buffers_needed": 1, + "resulting_rows": 100, + "cost": 1003.46, + "chosen": true + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 100, + "rows_for_plan": 10000, + "cost_for_plan": 1016.46, + "semijoin_strategy_choice": [ + ] /* semijoin_strategy_choice */, + "rest_of_plan": [ + { + "plan_prefix": [ + "`t2` `t3`", + "`t1`" + ] /* plan_prefix */, + "table": "`t2`", + "best_access_path": { + "considered_access_paths": [ + { + "rows_to_scan": 100, + "filtering_effect": [ + ] /* filtering_effect */, + "final_filtering_effect": 1, + "access_type": "scan", + "using_join_cache": true, + "buffers_needed": 16, + "resulting_rows": 100, + "cost": 100051, + "chosen": true + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 1, + "rows_for_plan": 10000, + "cost_for_plan": 101067, + "semijoin_strategy_choice": [ + { + "strategy": "LooseScan", + "recalculate_access_paths_and_cost": { + "tables": [ + { + "table": "`t1`", + "best_access_path": { + "considered_access_paths": [ + { + "access_type": "ref", + "index": "a", + "usable": false, + "chosen": false + }, + { + "rows_to_scan": 100, + "filtering_effect": [ + ] /* filtering_effect */, + "final_filtering_effect": 1, + "access_type": "scan", + "resulting_rows": 100, + "cost": 1299.63, + "chosen": true + } + ] /* considered_access_paths */ + } /* best_access_path */, + "unknown_key_1": { + "searching_loose_scan_index": { + "indexes": [ + { + "index": "a", + "covering_scan": { + "cost": 1.04839, + "chosen": true + } /* covering_scan */ + } + ] /* indexes */ + } /* searching_loose_scan_index */ + } + }, + { + "table": "`t2`", + "best_access_path": { + "considered_access_paths": [ + { + "rows_to_scan": 100, + "filtering_effect": [ + ] /* filtering_effect */, + "final_filtering_effect": 1, + "access_type": "scan", + "using_join_cache": true, + "buffers_needed": 16, + "resulting_rows": 100, + "cost": 100051, + "chosen": true + } + ] /* considered_access_paths */ + } /* best_access_path */ + } + ] /* tables */ + } /* recalculate_access_paths_and_cost */, + "cost": 101065, + "rows": 100, + "chosen": true + }, + { + "strategy": "DuplicatesWeedout", + "cost": 102078, + "rows": 100, + "duplicate_tables_left": false, + "chosen": false + } + ] /* semijoin_strategy_choice */, + "chosen": true, + "cause": "previous_plan_used_disabled_strategy" + } + ] /* rest_of_plan */ + } + ] /* rest_of_plan */ + }, + { + "plan_prefix": [ + ] /* plan_prefix */, + "table": "`t2`", + "best_access_path": { + "considered_access_paths": [ + { + "rows_to_scan": 100, + "filtering_effect": [ + ] /* filtering_effect */, + "final_filtering_effect": 1, + "access_type": "scan", + "resulting_rows": 100, + "cost": 12.9963, + "chosen": true + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 100, + "rows_for_plan": 100, + "cost_for_plan": 12.9963, + "semijoin_strategy_choice": [ + ] /* semijoin_strategy_choice */, + "rest_of_plan": [ + { + "plan_prefix": [ + "`t2`" + ] /* plan_prefix */, + "table": "`t2` `t3`", + "best_access_path": { + "considered_access_paths": [ + { + "rows_to_scan": 100, + "filtering_effect": [ + ] /* filtering_effect */, + "final_filtering_effect": 1, + "access_type": "scan", + "using_join_cache": true, + "buffers_needed": 1, + "resulting_rows": 100, + "cost": 1003.46, + "chosen": true + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 100, + "rows_for_plan": 10000, + "cost_for_plan": 1016.46, + "semijoin_strategy_choice": [ + ] /* semijoin_strategy_choice */, + "rest_of_plan": [ + { + "plan_prefix": [ + "`t2`", + "`t2` `t3`" + ] /* plan_prefix */, + "table": "`t1`", + "best_access_path": { + "considered_access_paths": [ + { + "access_type": "ref", + "index": "a", + "rows": 1, + "cost": 3500, + "chosen": true + }, + { + "rows_to_scan": 100, + "filtering_effect": [ + ] /* filtering_effect */, + "final_filtering_effect": 1, + "access_type": "scan", + "using_join_cache": true, + "buffers_needed": 32, + "resulting_rows": 100, + "cost": 100097, + "chosen": false + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 100, + "rows_for_plan": 10000, + "cost_for_plan": 4516.46, + "semijoin_strategy_choice": [ + { + "strategy": "DuplicatesWeedout", + "cost": 6517.46, + "rows": 10000, + "duplicate_tables_left": true, + "chosen": true + } + ] /* semijoin_strategy_choice */, + "chosen": false, + "cause": "plan_uses_disabled_strategy" + } + ] /* rest_of_plan */ + }, + { + "plan_prefix": [ + "`t2`" + ] /* plan_prefix */, + "table": "`t1`", + "best_access_path": { + "considered_access_paths": [ + { + "access_type": "ref", + "index": "a", + "rows": 1, + "cost": 35, + "chosen": true + }, + { + "rows_to_scan": 100, + "filtering_effect": [ + ] /* filtering_effect */, + "final_filtering_effect": 1, + "access_type": "scan", + "using_join_cache": true, + "buffers_needed": 1, + "resulting_rows": 100, + "cost": 1003.46, + "chosen": false + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 100, + "rows_for_plan": 100, + "cost_for_plan": 47.9963, + "semijoin_strategy_choice": [ + ] /* semijoin_strategy_choice */, + "rest_of_plan": [ + { + "plan_prefix": [ + "`t2`", + "`t1`" + ] /* plan_prefix */, + "table": "`t2` `t3`", + "best_access_path": { + "considered_access_paths": [ + { + "rows_to_scan": 100, + "filtering_effect": [ + ] /* filtering_effect */, + "final_filtering_effect": 1, + "access_type": "scan", + "using_join_cache": true, + "buffers_needed": 1, + "resulting_rows": 100, + "cost": 1003.48, + "chosen": true + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 100, + "rows_for_plan": 10000, + "cost_for_plan": 1051.47, + "semijoin_strategy_choice": [ + { + "strategy": "LooseScan", + "recalculate_access_paths_and_cost": { + "tables": [ + { + "table": "`t1`", + "best_access_path": { + "considered_access_paths": [ + { + "access_type": "ref", + "index": "a", + "rows": 1, + "cost": 35, + "chosen": true + }, + { + "rows_to_scan": 100, + "filtering_effect": [ + ] /* filtering_effect */, + "final_filtering_effect": 1, + "access_type": "scan", + "resulting_rows": 100, + "cost": 1299.63, + "chosen": false + } + ] /* considered_access_paths */ + } /* best_access_path */, + "unknown_key_2": { + "searching_loose_scan_index": { + "indexes": [ + { + "index": "a", + "index_handles_needed_semijoin_equalities": false + } + ] /* indexes */ + } /* searching_loose_scan_index */ + } + } + ] /* tables */ + } /* recalculate_access_paths_and_cost */, + "chosen": false + }, + { + "strategy": "DuplicatesWeedout", + "cost": 3052.47, + "rows": 10000, + "duplicate_tables_left": true, + "chosen": true + } + ] /* semijoin_strategy_choice */, + "chosen": false, + "cause": "plan_uses_disabled_strategy" + } + ] /* rest_of_plan */ + } + ] /* rest_of_plan */ + }, + { + "plan_prefix": [ + ] /* plan_prefix */, + "table": "`t1`", + "best_access_path": { + "considered_access_paths": [ + { + "access_type": "ref", + "index": "a", + "usable": false, + "chosen": false + }, + { + "rows_to_scan": 100, + "filtering_effect": [ + ] /* filtering_effect */, + "final_filtering_effect": 1, + "access_type": "scan", + "resulting_rows": 100, + "cost": 12.9963, + "chosen": true + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 100, + "rows_for_plan": 100, + "cost_for_plan": 12.9963, + "semijoin_strategy_choice": [ + ] /* semijoin_strategy_choice */, + "rest_of_plan": [ + { + "plan_prefix": [ + "`t1`" + ] /* plan_prefix */, + "table": "`t2` `t3`", + "best_access_path": { + "considered_access_paths": [ + { + "rows_to_scan": 100, + "filtering_effect": [ + ] /* filtering_effect */, + "final_filtering_effect": 1, + "access_type": "scan", + "using_join_cache": true, + "buffers_needed": 1, + "resulting_rows": 100, + "cost": 1003.01, + "chosen": true + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 100, + "rows_for_plan": 10000, + "cost_for_plan": 1016, + "semijoin_strategy_choice": [ + ] /* semijoin_strategy_choice */, + "rest_of_plan": [ + { + "plan_prefix": [ + "`t1`", + "`t2` `t3`" + ] /* plan_prefix */, + "table": "`t2`", + "best_access_path": { + "considered_access_paths": [ + { + "rows_to_scan": 100, + "filtering_effect": [ + ] /* filtering_effect */, + "final_filtering_effect": 1, + "access_type": "scan", + "using_join_cache": true, + "buffers_needed": 16, + "resulting_rows": 100, + "cost": 100051, + "chosen": true + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 1, + "rows_for_plan": 10000, + "cost_for_plan": 101067, + "semijoin_strategy_choice": [ + { + "strategy": "LooseScan", + "recalculate_access_paths_and_cost": { + "tables": [ + { + "table": "`t1`", + "best_access_path": { + "considered_access_paths": [ + { + "access_type": "ref", + "index": "a", + "usable": false, + "chosen": false + }, + { + "rows_to_scan": 100, + "filtering_effect": [ + ] /* filtering_effect */, + "final_filtering_effect": 1, + "access_type": "scan", + "resulting_rows": 100, + "cost": 12.9963, + "chosen": true + } + ] /* considered_access_paths */ + } /* best_access_path */, + "unknown_key_3": { + "searching_loose_scan_index": { + "indexes": [ + { + "index": "a", + "index_handles_needed_semijoin_equalities": false + } + ] /* indexes */ + } /* searching_loose_scan_index */ + } + } + ] /* tables */ + } /* recalculate_access_paths_and_cost */, + "chosen": false + }, + { + "strategy": "DuplicatesWeedout", + "cost": 102078, + "rows": 100, + "duplicate_tables_left": true, + "chosen": true + } + ] /* semijoin_strategy_choice */, + "pruned_by_cost": true + } + ] /* rest_of_plan */ + }, + { + "plan_prefix": [ + "`t1`" + ] /* plan_prefix */, + "table": "`t2`", + "best_access_path": { + "considered_access_paths": [ + { + "rows_to_scan": 100, + "filtering_effect": [ + ] /* filtering_effect */, + "final_filtering_effect": 1, + "access_type": "scan", + "using_join_cache": true, + "buffers_needed": 1, + "resulting_rows": 100, + "cost": 1003.01, + "chosen": true + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 1, + "rows_for_plan": 100, + "cost_for_plan": 1016, + "semijoin_strategy_choice": [ + ] /* semijoin_strategy_choice */, + "rest_of_plan": [ + { + "plan_prefix": [ + "`t1`", + "`t2`" + ] /* plan_prefix */, + "table": "`t2` `t3`", + "best_access_path": { + "considered_access_paths": [ + { + "rows_to_scan": 100, + "filtering_effect": [ + ] /* filtering_effect */, + "final_filtering_effect": 1, + "access_type": "scan", + "using_join_cache": true, + "buffers_needed": 1, + "resulting_rows": 100, + "cost": 1003.48, + "chosen": true + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 100, + "rows_for_plan": 10000, + "cost_for_plan": 2019.48, + "semijoin_strategy_choice": [ + { + "strategy": "LooseScan", + "recalculate_access_paths_and_cost": { + "tables": [ + { + "table": "`t1`", + "best_access_path": { + "considered_access_paths": [ + { + "access_type": "ref", + "index": "a", + "usable": false, + "chosen": false + }, + { + "rows_to_scan": 100, + "filtering_effect": [ + ] /* filtering_effect */, + "final_filtering_effect": 1, + "access_type": "scan", + "resulting_rows": 100, + "cost": 12.9963, + "chosen": true + } + ] /* considered_access_paths */ + } /* best_access_path */, + "unknown_key_4": { + "searching_loose_scan_index": { + "indexes": [ + { + "index": "a", + "index_handles_needed_semijoin_equalities": false + } + ] /* indexes */ + } /* searching_loose_scan_index */ + } + } + ] /* tables */ + } /* recalculate_access_paths_and_cost */, + "chosen": false + }, + { + "strategy": "DuplicatesWeedout", + "cost": 3030.48, + "rows": 100, + "duplicate_tables_left": true, + "chosen": true + } + ] /* semijoin_strategy_choice */, + "chosen": false, + "cause": "plan_uses_disabled_strategy" + } + ] /* rest_of_plan */ + } + ] /* rest_of_plan */ + }, + { + "final_semijoin_strategy": "LooseScan", + "recalculate_access_paths_and_cost": { + "tables": [ + { + "table": "`t1`", + "best_access_path": { + "considered_access_paths": [ + { + "access_type": "ref", + "index": "a", + "usable": false, + "chosen": false + }, + { + "rows_to_scan": 100, + "filtering_effect": [ + ] /* filtering_effect */, + "final_filtering_effect": 1, + "access_type": "scan", + "resulting_rows": 100, + "cost": 1299.63, + "chosen": true + } + ] /* considered_access_paths */ + } /* best_access_path */, + "unknown_key_5": { + "searching_loose_scan_index": { + "indexes": [ + { + "index": "a", + "covering_scan": { + "cost": 1.04839, + "chosen": true + } /* covering_scan */ + } + ] /* indexes */ + } /* searching_loose_scan_index */ + } + }, + { + "table": "`t2`", + "best_access_path": { + "considered_access_paths": [ + { + "rows_to_scan": 100, + "filtering_effect": [ + ] /* filtering_effect */, + "final_filtering_effect": 1, + "access_type": "scan", + "using_join_cache": true, + "buffers_needed": 32, + "resulting_rows": 100, + "cost": 100097, + "chosen": true + } + ] /* considered_access_paths */ + } /* best_access_path */ + } + ] /* tables */ + } /* recalculate_access_paths_and_cost */ + } + ] +drop table t0,t1,t2; +# +# Discover bound equality thanks to equality propagation +# specific of ON clause. +# +CREATE TABLE t1 ( +a int(11) DEFAULT NULL, +b varchar(100) DEFAULT NULL, +c int(11) DEFAULT NULL, +KEY b_c_a (b,c,a) +) ENGINE=InnoDB, CHARSET utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +explain select * +from t1 left join t1 as t2 +on (t2.a= t1.a and (t2.a,t2.b) in (select a,b from t1 as t3)) +where t1.a < 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL b_c_a 413 NULL 1 100.00 Using where; Using index +2 SIMPLE t3 NULL index b_c_a b_c_a 413 NULL 1 100.00 Using where; Using index; LooseScan +2 SIMPLE t2 NULL ref b_c_a b_c_a 403 test.t3.b 1 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c` from `test`.`t1` left join (`test`.`t1` `t2` semi join (`test`.`t1` `t3`)) on(((`test`.`t2`.`b` = `test`.`t3`.`b`) and (`test`.`t3`.`a` = `test`.`t1`.`a`) and (`test`.`t2`.`a` = `test`.`t1`.`a`))) where (`test`.`t1`.`a` < 5) +drop table t1; +# +# Show that loosescan planning is not dependent on order of +# creation of indexes anymore. +# +create table it(a int, b int, index a_b (a,b), index a (a)) +engine=InnoDB; +insert into it values(1,1),(2,3),(4,3); +select * from it as ot +where (ot.a,ot.b) in (select it.a,it.b from it where it.b=3); +a b +2 3 +4 3 +select TRACE LIKE '%"index_handles_needed_semijoin_equalities": false%' +from information_schema.optimizer_trace; +TRACE LIKE '%"index_handles_needed_semijoin_equalities": false%' +0 +drop table it; +create table it(a int, b int, index a (a),index a_b (a,b)) +engine=InnoDB; +insert into it values(1,1),(2,3),(4,3); +select * from it as ot +where (ot.a,ot.b) in (select it.a,it.b from it where it.b=3); +a b +2 3 +4 3 +select TRACE LIKE '%"index_handles_needed_semijoin_equalities": false%' +from information_schema.optimizer_trace; +TRACE LIKE '%"index_handles_needed_semijoin_equalities": false%' +0 +drop table it; +# +# Show that we reject LooseScan if no handled key parts +# +CREATE TABLE t1 (a INT, b INT, KEY (a)) ENGINE=INNODB; +CREATE TABLE t2 (a INT, b INT) ENGINE=INNODB; +EXPLAIN SELECT * FROM t2 AS t3, t2 +WHERE t2.b=t3.b AND +(t2.b) IN (SELECT b*3 FROM t1 WHERE a=10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t1 NULL ref a a 5 const 1 100.00 Using where; Start temporary; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t2` `t3` join `test`.`t2` semi join (`test`.`t1`) where ((`test`.`t1`.`a` = 10) and (`test`.`t2`.`b` = `test`.`t3`.`b`) and (`test`.`t3`.`b` = (`test`.`t1`.`b` * 3))) +SELECT TRACE LIKE '%"some_index_part_used": false%' +FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +TRACE LIKE '%"some_index_part_used": false%' +1 +DROP TABLE t1,t2; +# +# Show that we detect a hole in sequence of key parts +# +CREATE TABLE ot1 (a INTEGER); +INSERT INTO ot1 VALUES (0),(1),(3),(7); +CREATE TABLE it1 (a VARCHAR(1), b INTEGER, KEY (a,b)) CHARSET utf8mb4; +INSERT INTO it1 VALUES ('a',7), ('b',7); +CREATE TABLE it2 (a VARCHAR(1), b INTEGER, KEY (a,b)) CHARSET utf8mb4; +INSERT INTO it2 VALUES ('a',7), ('b',7); +explain SELECT * FROM ot1 +WHERE a IN ( +SELECT it1.b +FROM it1 JOIN it2 +ON it1.a = it2.a +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE it1 NULL index a a 12 NULL 2 100.00 Using index; Start temporary +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; Using join buffer (hash join) +1 SIMPLE it2 NULL index a a 12 NULL 2 50.00 Using where; Using index; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a` from `test`.`ot1` semi join (`test`.`it1` join `test`.`it2`) where ((`test`.`it2`.`a` = `test`.`it1`.`a`) and (`test`.`ot1`.`a` = `test`.`it1`.`b`)) +SELECT TRACE LIKE '%"index_can_remove_duplicates": false%' +FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +TRACE LIKE '%"index_can_remove_duplicates": false%' +1 +DROP TABLE ot1, it1, it2; +# +# Show that handled keyparts cannot be on prefix +# +create table t1 (a int, b varchar(100), key a_b (a,b)) charset utf8mb4; +insert into t1 values(25,'111111'),(25,'1111112'); +explain select * from t1 as t2 where t2.b in (select b from t1 where a=25); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ref a_b a_b 5 const 1 100.00 Using index; LooseScan +1 SIMPLE t2 NULL index NULL a_b 408 NULL 2 50.00 Using where; Using index; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` `t2` semi join (`test`.`t1`) where ((`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t1`.`a` = 25)) +select * from t1 as t2 where t2.b in (select b from t1 where a=25); +a b +25 111111 +25 1111112 +alter table t1 drop key a_b, add key a_b_prefix (a,b(2)); +explain select * from t1 as t2 where t2.b in (select b from t1 where a=25); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ref a_b_prefix a_b_prefix 5 const 1 100.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` `t2` semi join (`test`.`t1`) where ((`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t1`.`a` = 25)) +select * from t1 as t2 where t2.b in (select b from t1 where a=25); +a b +25 111111 +25 1111112 +select TRACE LIKE '%"index_handles_needed_semijoin_equalities": false%' +from information_schema.optimizer_trace; +TRACE LIKE '%"index_handles_needed_semijoin_equalities": false%' +1 +drop table t1; +set optimizer_switch=@old_opt_switch; +set optimizer_prune_level=@old_opt_prune_level; +# Tracing of CTEs using the same tmp table: observe +# "reusing_tmp_table" and only one "creating_tmp_table". +with q(a) as (select 1 union all select 2) +select * from q, q q1 where q.a=1 and q1.a=2; +a a +1 2 +select TRACE from information_schema.optimizer_trace; +TRACE +{ + "steps": [ + { + "join_preparation": { + "select#": 1, + "steps": [ + { + "join_preparation": { + "select#": 2, + "steps": [ + { + "expanded_query": "/* select#2 */ select 1 AS `1`" + } + ] /* steps */ + } /* join_preparation */ + }, + { + "join_preparation": { + "select#": 3, + "steps": [ + { + "expanded_query": "/* select#3 */ select 2 AS `2`" + } + ] /* steps */ + } /* join_preparation */ + }, + { + "derived": { + "table": "`q`", + "select#": 2, + "materialized": true + } /* derived */ + }, + { + "join_preparation": { + "select#": 4, + "steps": [ + { + "expanded_query": "/* select#4 */ select 1 AS `1`" + } + ] /* steps */ + } /* join_preparation */ + }, + { + "join_preparation": { + "select#": 5, + "steps": [ + { + "expanded_query": "/* select#5 */ select 2 AS `2`" + } + ] /* steps */ + } /* join_preparation */ + }, + { + "derived": { + "table": "`q` `q1`", + "select#": 4, + "materialized": true, + "reusing_tmp_table": true + } /* derived */ + }, + { + "expanded_query": "/* select#1 */ select `q`.`a` AS `a`,`q1`.`a` AS `a` from `q` join `q` `q1` where ((`q`.`a` = 1) and (`q1`.`a` = 2))" + } + ] /* steps */ + } /* join_preparation */ + }, + { + "join_optimization": { + "select#": 1, + "steps": [ + { + "join_optimization": { + "select#": 2, + "steps": [ + ] /* steps */ + } /* join_optimization */ + }, + { + "join_optimization": { + "select#": 3, + "steps": [ + ] /* steps */ + } /* join_optimization */ + }, + { + "join_optimization": { + "select#": 4, + "steps": [ + ] /* steps */ + } /* join_optimization */ + }, + { + "join_optimization": { + "select#": 5, + "steps": [ + ] /* steps */ + } /* join_optimization */ + }, + { + "condition_processing": { + "condition": "WHERE", + "original_condition": "((`q`.`a` = 1) and (`q1`.`a` = 2))", + "steps": [ + { + "transformation": "equality_propagation", + "resulting_condition": "(multiple equal(1, `q`.`a`) and multiple equal(2, `q1`.`a`))" + }, + { + "transformation": "constant_propagation", + "resulting_condition": "(multiple equal(1, `q`.`a`) and multiple equal(2, `q1`.`a`))" + }, + { + "transformation": "trivial_condition_removal", + "resulting_condition": "(multiple equal(1, `q`.`a`) and multiple equal(2, `q1`.`a`))" + } + ] /* steps */ + } /* condition_processing */ + }, + { + "substitute_generated_columns": { + } /* substitute_generated_columns */ + }, + { + "table_dependencies": [ + { + "table": "`q`", + "row_may_be_null": false, + "map_bit": 0, + "depends_on_map_bits": [ + ] /* depends_on_map_bits */ + }, + { + "table": "`q` `q1`", + "row_may_be_null": false, + "map_bit": 1, + "depends_on_map_bits": [ + ] /* depends_on_map_bits */ + } + ] /* table_dependencies */ + }, + { + "ref_optimizer_key_uses": [ + { + "table": "`q`", + "field": "a", + "equals": "1", + "null_rejecting": true + }, + { + "table": "`q`", + "field": "a", + "equals": "1", + "null_rejecting": true + }, + { + "table": "`q` `q1`", + "field": "a", + "equals": "2", + "null_rejecting": true + }, + { + "table": "`q` `q1`", + "field": "a", + "equals": "2", + "null_rejecting": true + } + ] /* ref_optimizer_key_uses */ + }, + { + "rows_estimation": [ + { + "table": "`q`", + "table_scan": { + "rows": 2, + "cost": 2.525 + } /* table_scan */ + }, + { + "table": "`q` `q1`", + "table_scan": { + "rows": 2, + "cost": 2.525 + } /* table_scan */ + } + ] /* rows_estimation */ + }, + { + "considered_execution_plans": [ + { + "plan_prefix": [ + ] /* plan_prefix */, + "table": "`q`", + "best_access_path": { + "considered_access_paths": [ + { + "access_type": "ref", + "index": "", + "rows": 1, + "cost": 0.35, + "chosen": true + }, + { + "access_type": "ref", + "index": "", + "rows": 1, + "cost": 0.35, + "chosen": false + }, + { + "access_type": "scan", + "cost": 2.725, + "rows": 2, + "chosen": false, + "cause": "cost" + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 100, + "rows_for_plan": 1, + "cost_for_plan": 0.35, + "rest_of_plan": [ + { + "plan_prefix": [ + "`q`" + ] /* plan_prefix */, + "table": "`q` `q1`", + "best_access_path": { + "considered_access_paths": [ + { + "access_type": "ref", + "index": "", + "rows": 1, + "cost": 0.35, + "chosen": true + }, + { + "access_type": "ref", + "index": "", + "rows": 1, + "cost": 0.35, + "chosen": false + }, + { + "access_type": "scan", + "cost": 2.725, + "rows": 2, + "chosen": false, + "cause": "cost" + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 100, + "rows_for_plan": 1, + "cost_for_plan": 0.7, + "chosen": true + } + ] /* rest_of_plan */ + }, + { + "plan_prefix": [ + ] /* plan_prefix */, + "table": "`q` `q1`", + "best_access_path": { + "considered_access_paths": [ + { + "access_type": "ref", + "index": "", + "rows": 1, + "cost": 0.35, + "chosen": true + }, + { + "access_type": "ref", + "index": "", + "rows": 1, + "cost": 0.35, + "chosen": false + }, + { + "access_type": "scan", + "cost": 2.725, + "rows": 2, + "chosen": false, + "cause": "cost" + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 100, + "rows_for_plan": 1, + "cost_for_plan": 0.35, + "pruned_by_heuristic": true + } + ] /* considered_execution_plans */ + }, + { + "attaching_conditions_to_tables": { + "original_condition": "((`q1`.`a` = 2) and (`q`.`a` = 1))", + "attached_conditions_computation": [ + ] /* attached_conditions_computation */, + "attached_conditions_summary": [ + { + "table": "`q`", + "attached": "(`q`.`a` = 1)" + }, + { + "table": "`q` `q1`", + "attached": "(`q1`.`a` = 2)" + } + ] /* attached_conditions_summary */ + } /* attaching_conditions_to_tables */ + }, + { + "finalizing_table_conditions": [ + { + "table": "`q`", + "original_table_condition": "(`q`.`a` = 1)", + "final_table_condition ": null + }, + { + "table": "`q` `q1`", + "original_table_condition": "(`q1`.`a` = 2)", + "final_table_condition ": null + } + ] /* finalizing_table_conditions */ + }, + { + "refine_plan": [ + { + "table": "`q`" + }, + { + "table": "`q` `q1`" + } + ] /* refine_plan */ + } + ] /* steps */ + } /* join_optimization */ + }, + { + "join_execution": { + "select#": 1, + "steps": [ + { + "creating_tmp_table": { + "tmp_table_info": { + "table": "`q`", + "in_plan_at_position": 0, + "columns": 1, + "row_length": 9, + "key_length": 8, + "unique_constraint": false, + "makes_grouped_rows": false, + "cannot_insert_duplicates": false, + "location": "TempTable" + } /* tmp_table_info */ + } /* creating_tmp_table */ + }, + { + "materialize": { + "select#": 2, + "steps": [ + ] /* steps */ + } /* materialize */ + }, + { + "materialize": { + "select#": 3, + "steps": [ + ] /* steps */ + } /* materialize */ + } + ] /* steps */ + } /* join_execution */ + } + ] /* steps */ +} +# Tracing of repetitions of the recursive member +# can be silenced with repeated_subselect=off +with recursive qn(n) as +(select 1 union all select n+1 from qn where n<4) +select count(*) from qn; +count(*) +4 +SELECT show_json_object('"join_execution": {', TRACE) +FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +show_json_object('"join_execution": {', TRACE) +"join_execution": { + "select#": 1, + "steps": [ + { + "creating_tmp_table": { + "tmp_table_info": { + "table": "`qn`", + "in_plan_at_position": 0, + "columns": 1, + "row_length": 9, + "key_length": 0, + "unique_constraint": false, + "makes_grouped_rows": false, + "cannot_insert_duplicates": false, + "location": "TempTable" + } /* tmp_table_info */ + } /* creating_tmp_table */ + }, + { + "materialize": { + "select#": 2, + "steps": [ + ] /* steps */ + } /* materialize */ + }, + { + "materialize": { + "select#": 3, + "steps": [ + ] /* steps */ + } /* materialize */ + }, + { + "materialize": { + "select#": 3, + "steps": [ + ] /* steps */ + } /* materialize */ + } + ] /* steps */ + } +SET @@optimizer_trace_features="repeated_subselect=off"; +with recursive qn(n) as +(select 1 union all select n+1 from qn where n<4) +select count(*) from qn; +count(*) +4 +SELECT show_json_object('"join_execution": {', TRACE) +FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +show_json_object('"join_execution": {', TRACE) +"join_execution": { + "select#": 1, + "steps": [ + { + "creating_tmp_table": { + "tmp_table_info": { + "table": "`qn`", + "in_plan_at_position": 0, + "columns": 1, + "row_length": 9, + "key_length": 0, + "unique_constraint": false, + "makes_grouped_rows": false, + "cannot_insert_duplicates": false, + "location": "TempTable" + } /* tmp_table_info */ + } /* creating_tmp_table */ + }, + { + "materialize": { + "select#": 2, + "steps": [ + ] /* steps */ + } /* materialize */ + }, + { + "materialize": { + "select#": 3, + "steps": [ + ] /* steps */ + } /* materialize */ + } + ] /* steps */ + } +SET @@optimizer_trace_features=default; +drop function show_json_object; diff --git a/mysql-test/suite/table_aggregate_global_2u_3t.result-pq b/mysql-test/suite/table_aggregate_global_2u_3t.result-pq new file mode 100644 index 000000000000..85bef9e95c2c --- /dev/null +++ b/mysql-test/suite/table_aggregate_global_2u_3t.result-pq @@ -0,0 +1,1741 @@ +update performance_schema.setup_consumers +set enabled='NO' where name='thread_instrumentation'; +delete from performance_schema.setup_actors +where user in ('user2', 'user4'); +select * from performance_schema.setup_actors +order by USER, HOST, `ROLE`; +HOST USER ROLE ENABLED HISTORY +localhost user1 % YES YES +localhost user3 % YES YES +select * from performance_schema.setup_objects +order by object_type, object_schema, object_name; +OBJECT_TYPE OBJECT_SCHEMA OBJECT_NAME ENABLED TIMED +TABLE test t1 YES YES +TABLE test t2 YES NO +TABLE test t3 YES NO +select * from performance_schema.setup_consumers; +NAME ENABLED +events_stages_current YES +events_stages_history YES +events_stages_history_long YES +events_statements_current YES +events_statements_history YES +events_statements_history_long YES +events_transactions_current YES +events_transactions_history YES +events_transactions_history_long YES +events_waits_current YES +events_waits_history YES +events_waits_history_long YES +global_instrumentation YES +thread_instrumentation NO +statements_digest YES +flush tables; +truncate performance_schema.objects_summary_global_by_type; +truncate performance_schema.table_io_waits_summary_by_index_usage; +truncate performance_schema.table_io_waits_summary_by_table; +truncate performance_schema.table_lock_waits_summary_by_table; +truncate performance_schema.events_waits_summary_by_thread_by_event_name; +truncate performance_schema.events_waits_summary_by_account_by_event_name; +truncate performance_schema.events_waits_summary_by_user_by_event_name; +truncate performance_schema.events_waits_summary_by_host_by_event_name; +truncate performance_schema.events_waits_summary_global_by_event_name; +truncate performance_schema.events_waits_history_long; +show global variables like "performance_schema%table%"; +Variable_name Value +performance_schema_max_table_handles -1 +performance_schema_max_table_instances -1 +performance_schema_max_table_lock_stat -1 +show global status like "performance_schema%table%_lost"; +Variable_name Value +Performance_schema_table_handles_lost 0 +Performance_schema_table_instances_lost 0 +Performance_schema_table_lock_stat_lost 0 +"================== Step 1 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +execute dump_waits_user; +user event_name count_star +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 0 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 0 0 0 0 0 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 index_b 0 0 0 0 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 0 0 0 0 0 0 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 0 +TABLE test t2 0 +TABLE test t3 0 +select concat(current_user(), " is connected") as status; +status +user1@localhost is connected +"================== Step 2 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 0 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 0 0 0 0 0 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 index_b 0 0 0 0 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 0 0 0 0 0 0 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 0 +TABLE test t2 0 +TABLE test t3 0 +insert into test.t1 set a=101, b=1, c=1; +insert into test.t2 set a=102, b=2, c=2; +insert into test.t2 set a=103, b=3, c=3; +insert into test.t3 set a=104, b=4, c=4; +insert into test.t3 set a=105, b=5, c=5; +insert into test.t3 set a=106, b=6, c=6; +select * from test.t1; +a b c d +101 1 1 0 +select * from test.t2; +a b c d +102 2 2 0 +103 3 3 0 +select * from test.t3; +a b c d +104 4 4 0 +105 5 5 0 +106 6 6 0 +update test.t1 set d=d+1; +update test.t2 set d=d+1; +update test.t3 set d=d+1; +update test.t1 set d=d+1 where a=101; +update test.t2 set d=d+1 where a=101; +update test.t3 set d=d+1 where a=101; +select * from test.t1 force index(index_b) where b=5; +a b c d +select * from test.t2 force index(index_b) where b=5; +a b c d +select * from test.t3 force index(index_b) where b=5; +a b c d +105 5 5 1 +"================== con1 marker ==================" +"================== Step 3-A ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 32 +wait/lock/table/sql/handler 30 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 4 3 1 3 1 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 3 1 2 1 0 2 0 +TABLE test t2 NULL 7 5 2 5 2 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 3 1 2 1 0 2 0 +TABLE test t3 NULL 10 7 3 7 3 0 0 +TABLE test t3 index_b 1 1 0 1 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 4 1 3 1 0 3 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 7 4 3 4 1 2 0 +TABLE test t2 10 6 4 6 2 2 0 +TABLE test t3 15 9 6 9 3 3 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 9 6 3 0 0 0 0 6 0 3 +TABLE test t2 10 6 4 0 0 0 0 6 0 4 +TABLE test t3 11 6 5 0 0 0 0 6 0 5 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 16 +TABLE test t2 20 +TABLE test t3 26 +flush tables; +"================== con1 FLUSH ==================" +"================== Step 3-B ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 32 +wait/lock/table/sql/handler 30 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 4 3 1 3 1 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 3 1 2 1 0 2 0 +TABLE test t2 NULL 7 5 2 5 2 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 3 1 2 1 0 2 0 +TABLE test t3 NULL 10 7 3 7 3 0 0 +TABLE test t3 index_b 1 1 0 1 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 4 1 3 1 0 3 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 7 4 3 4 1 2 0 +TABLE test t2 10 6 4 6 2 2 0 +TABLE test t3 15 9 6 9 3 3 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 9 6 3 0 0 0 0 6 0 3 +TABLE test t2 10 6 4 0 0 0 0 6 0 4 +TABLE test t3 11 6 5 0 0 0 0 6 0 5 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 16 +TABLE test t2 20 +TABLE test t3 26 +select concat(current_user(), " is connected") as status; +status +user2@localhost is connected +"================== Step 4 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +username event_name count_star +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 32 +wait/lock/table/sql/handler 30 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 4 3 1 3 1 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 3 1 2 1 0 2 0 +TABLE test t2 NULL 7 5 2 5 2 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 3 1 2 1 0 2 0 +TABLE test t3 NULL 10 7 3 7 3 0 0 +TABLE test t3 index_b 1 1 0 1 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 4 1 3 1 0 3 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 7 4 3 4 1 2 0 +TABLE test t2 10 6 4 6 2 2 0 +TABLE test t3 15 9 6 9 3 3 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 9 6 3 0 0 0 0 6 0 3 +TABLE test t2 10 6 4 0 0 0 0 6 0 4 +TABLE test t3 11 6 5 0 0 0 0 6 0 5 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 16 +TABLE test t2 20 +TABLE test t3 26 +insert into test.t1 set a=201, b=1, c=1; +insert into test.t2 set a=202, b=2, c=2; +insert into test.t2 set a=203, b=3, c=3; +insert into test.t3 set a=204, b=4, c=4; +insert into test.t3 set a=205, b=5, c=5; +insert into test.t3 set a=206, b=6, c=6; +select * from test.t1; +a b c d +101 1 1 2 +201 1 1 0 +select * from test.t2; +a b c d +102 2 2 1 +103 3 3 1 +202 2 2 0 +203 3 3 0 +select * from test.t3; +a b c d +104 4 4 1 +105 5 5 1 +106 6 6 1 +204 4 4 0 +205 5 5 0 +206 6 6 0 +update test.t1 set d=d+1; +update test.t2 set d=d+1; +update test.t3 set d=d+1; +update test.t1 set d=d+1 where a=201; +update test.t2 set d=d+1 where a=201; +update test.t3 set d=d+1 where a=201; +select * from test.t1 force index(index_b) where b=5; +a b c d +select * from test.t2 force index(index_b) where b=5; +a b c d +select * from test.t3 force index(index_b) where b=5; +a b c d +105 5 5 2 +205 5 5 1 +"================== con2 marker ==================" +"================== Step 5 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +username event_name count_star +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 83 +wait/lock/table/sql/handler 60 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 10 8 2 8 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 7 2 5 2 0 5 0 +TABLE test t2 NULL 18 14 4 14 4 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 8 2 6 2 0 6 0 +TABLE test t3 NULL 26 20 6 20 6 0 0 +TABLE test t3 index_b 3 3 0 3 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 11 2 9 2 0 9 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 17 10 7 10 2 5 0 +TABLE test t2 26 16 10 16 4 6 0 +TABLE test t3 40 25 15 25 6 9 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 18 12 6 0 0 0 0 12 0 6 +TABLE test t2 20 12 8 0 0 0 0 12 0 8 +TABLE test t3 22 12 10 0 0 0 0 12 0 10 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 35 +TABLE test t2 46 +TABLE test t3 62 +select concat(current_user(), " is connected") as status; +status +user3@localhost is connected +"================== Step 6 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +username event_name count_star +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 83 +wait/lock/table/sql/handler 60 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 10 8 2 8 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 7 2 5 2 0 5 0 +TABLE test t2 NULL 18 14 4 14 4 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 8 2 6 2 0 6 0 +TABLE test t3 NULL 26 20 6 20 6 0 0 +TABLE test t3 index_b 3 3 0 3 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 11 2 9 2 0 9 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 17 10 7 10 2 5 0 +TABLE test t2 26 16 10 16 4 6 0 +TABLE test t3 40 25 15 25 6 9 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 18 12 6 0 0 0 0 12 0 6 +TABLE test t2 20 12 8 0 0 0 0 12 0 8 +TABLE test t3 22 12 10 0 0 0 0 12 0 10 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 35 +TABLE test t2 46 +TABLE test t3 62 +insert into test.t1 set a=301, b=1, c=1; +insert into test.t2 set a=302, b=2, c=2; +insert into test.t2 set a=303, b=3, c=3; +insert into test.t3 set a=304, b=4, c=4; +insert into test.t3 set a=305, b=5, c=5; +insert into test.t3 set a=306, b=6, c=6; +select * from test.t1; +a b c d +101 1 1 3 +201 1 1 2 +301 1 1 0 +select * from test.t2; +a b c d +102 2 2 2 +103 3 3 2 +202 2 2 1 +203 3 3 1 +302 2 2 0 +303 3 3 0 +select * from test.t3; +a b c d +104 4 4 2 +105 5 5 2 +106 6 6 2 +204 4 4 1 +205 5 5 1 +206 6 6 1 +304 4 4 0 +305 5 5 0 +306 6 6 0 +update test.t1 set d=d+1; +update test.t2 set d=d+1; +update test.t3 set d=d+1; +update test.t1 set d=d+1 where a=301; +update test.t2 set d=d+1 where a=301; +update test.t3 set d=d+1 where a=301; +select * from test.t1 force index(index_b) where b=5; +a b c d +select * from test.t2 force index(index_b) where b=5; +a b c d +select * from test.t3 force index(index_b) where b=5; +a b c d +105 5 5 3 +205 5 5 2 +305 5 5 1 +"================== con3 marker ==================" +"================== Step 7 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +username event_name count_star +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 153 +wait/lock/table/sql/handler 90 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 15 3 15 3 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 12 3 9 3 0 9 0 +TABLE test t2 NULL 33 27 6 27 6 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 15 3 12 3 0 12 0 +TABLE test t3 NULL 48 39 9 39 9 0 0 +TABLE test t3 index_b 6 6 0 6 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 21 3 18 3 0 18 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 30 18 12 18 3 9 0 +TABLE test t2 48 30 18 30 6 12 0 +TABLE test t3 75 48 27 48 9 18 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 27 18 9 0 0 0 0 18 0 9 +TABLE test t2 30 18 12 0 0 0 0 18 0 12 +TABLE test t3 33 18 15 0 0 0 0 18 0 15 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 57 +TABLE test t2 78 +TABLE test t3 108 +select concat(current_user(), " is connected") as status; +status +user4@localhost is connected +"================== Step 8 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +username event_name count_star +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +username event_name count_star +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 0 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 153 +wait/lock/table/sql/handler 90 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 15 3 15 3 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 12 3 9 3 0 9 0 +TABLE test t2 NULL 33 27 6 27 6 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 15 3 12 3 0 12 0 +TABLE test t3 NULL 48 39 9 39 9 0 0 +TABLE test t3 index_b 6 6 0 6 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 21 3 18 3 0 18 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 30 18 12 18 3 9 0 +TABLE test t2 48 30 18 30 6 12 0 +TABLE test t3 75 48 27 48 9 18 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 27 18 9 0 0 0 0 18 0 9 +TABLE test t2 30 18 12 0 0 0 0 18 0 12 +TABLE test t3 33 18 15 0 0 0 0 18 0 15 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 57 +TABLE test t2 78 +TABLE test t3 108 +insert into test.t1 set a=401, b=1, c=1; +insert into test.t2 set a=402, b=2, c=2; +insert into test.t2 set a=403, b=3, c=3; +insert into test.t3 set a=404, b=4, c=4; +insert into test.t3 set a=405, b=5, c=5; +insert into test.t3 set a=406, b=6, c=6; +select * from test.t1; +a b c d +101 1 1 4 +201 1 1 3 +301 1 1 2 +401 1 1 0 +select * from test.t2; +a b c d +102 2 2 3 +103 3 3 3 +202 2 2 2 +203 3 3 2 +302 2 2 1 +303 3 3 1 +402 2 2 0 +403 3 3 0 +select * from test.t3; +a b c d +104 4 4 3 +105 5 5 3 +106 6 6 3 +204 4 4 2 +205 5 5 2 +206 6 6 2 +304 4 4 1 +305 5 5 1 +306 6 6 1 +404 4 4 0 +405 5 5 0 +406 6 6 0 +update test.t1 set d=d+1; +update test.t2 set d=d+1; +update test.t3 set d=d+1; +update test.t1 set d=d+1 where a=401; +update test.t2 set d=d+1 where a=401; +update test.t3 set d=d+1 where a=401; +select * from test.t1 force index(index_b) where b=5; +a b c d +select * from test.t2 force index(index_b) where b=5; +a b c d +select * from test.t3 force index(index_b) where b=5; +a b c d +105 5 5 4 +205 5 5 3 +305 5 5 2 +405 5 5 1 +"================== con4 marker ==================" +"================== Step 9 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +username event_name count_star +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +username event_name count_star +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 0 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 242 +wait/lock/table/sql/handler 120 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 NULL 52 44 8 44 8 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 24 4 20 4 0 20 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 76 48 28 48 8 20 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 36 24 12 0 0 0 0 24 0 12 +TABLE test t2 40 24 16 0 0 0 0 24 0 16 +TABLE test t3 44 24 20 0 0 0 0 24 0 20 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 82 +TABLE test t2 116 +TABLE test t3 164 +lock tables test.t1 read, test.t2 read, test.t3 read; +unlock tables; +lock tables test.t1 write, test.t2 write, test.t3 write; +unlock tables; +"================== con1 marker ==================" +"================== Step 10 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +username event_name count_star +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +username event_name count_star +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 0 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 242 +wait/lock/table/sql/handler 126 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 NULL 52 44 8 44 8 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 24 4 20 4 0 20 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 76 48 28 48 8 20 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 38 25 13 0 0 0 0 25 0 13 +TABLE test t2 42 25 17 0 0 0 0 25 0 17 +TABLE test t3 46 25 21 0 0 0 0 25 0 21 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 84 +TABLE test t2 118 +TABLE test t3 166 +flush tables; +"================== flush marker ==================" +"================== Step 11 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +username event_name count_star +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +username event_name count_star +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 0 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 242 +wait/lock/table/sql/handler 126 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 NULL 52 44 8 44 8 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 24 4 20 4 0 20 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 76 48 28 48 8 20 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 38 25 13 0 0 0 0 25 0 13 +TABLE test t2 42 25 17 0 0 0 0 25 0 17 +TABLE test t3 46 25 21 0 0 0 0 25 0 21 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 84 +TABLE test t2 118 +TABLE test t3 166 +set global read_only=1; +set global read_only=0; +"================== global read_only marker ==================" +"================== Step 12 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +username event_name count_star +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +username event_name count_star +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 0 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 242 +wait/lock/table/sql/handler 126 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 NULL 52 44 8 44 8 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 24 4 20 4 0 20 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 76 48 28 48 8 20 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 38 25 13 0 0 0 0 25 0 13 +TABLE test t2 42 25 17 0 0 0 0 25 0 17 +TABLE test t3 46 25 21 0 0 0 0 25 0 21 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 84 +TABLE test t2 118 +TABLE test t3 166 +"================== con1 disconnected ==================" +"================== Step 13 ==================" +call dump_thread(); +username status +user1 not found +username event_name count_star +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +username event_name count_star +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 0 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 242 +wait/lock/table/sql/handler 126 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 NULL 52 44 8 44 8 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 24 4 20 4 0 20 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 76 48 28 48 8 20 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 38 25 13 0 0 0 0 25 0 13 +TABLE test t2 42 25 17 0 0 0 0 25 0 17 +TABLE test t3 46 25 21 0 0 0 0 25 0 21 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 84 +TABLE test t2 118 +TABLE test t3 166 +"================== con2 disconnected ==================" +"================== Step 14 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username event_name count_star +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +username event_name count_star +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 0 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 242 +wait/lock/table/sql/handler 126 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 NULL 52 44 8 44 8 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 24 4 20 4 0 20 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 76 48 28 48 8 20 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 38 25 13 0 0 0 0 25 0 13 +TABLE test t2 42 25 17 0 0 0 0 25 0 17 +TABLE test t3 46 25 21 0 0 0 0 25 0 21 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 84 +TABLE test t2 118 +TABLE test t3 166 +"================== con3 disconnected ==================" +"================== Step 15 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username event_name count_star +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 0 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 242 +wait/lock/table/sql/handler 126 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 NULL 52 44 8 44 8 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 24 4 20 4 0 20 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 76 48 28 48 8 20 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 38 25 13 0 0 0 0 25 0 13 +TABLE test t2 42 25 17 0 0 0 0 25 0 17 +TABLE test t3 46 25 21 0 0 0 0 25 0 21 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 84 +TABLE test t2 118 +TABLE test t3 166 +"================== con4 disconnected ==================" +"================== Step 16 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 0 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 242 +wait/lock/table/sql/handler 126 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 NULL 52 44 8 44 8 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 24 4 20 4 0 20 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 76 48 28 48 8 20 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 38 25 13 0 0 0 0 25 0 13 +TABLE test t2 42 25 17 0 0 0 0 25 0 17 +TABLE test t3 46 25 21 0 0 0 0 25 0 21 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 84 +TABLE test t2 118 +TABLE test t3 166 +truncate performance_schema.events_waits_summary_by_thread_by_event_name; +"================== BY_THREAD truncated ==================" +"================== Step 17 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 0 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 242 +wait/lock/table/sql/handler 126 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 NULL 52 44 8 44 8 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 24 4 20 4 0 20 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 76 48 28 48 8 20 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 38 25 13 0 0 0 0 25 0 13 +TABLE test t2 42 25 17 0 0 0 0 25 0 17 +TABLE test t3 46 25 21 0 0 0 0 25 0 21 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 84 +TABLE test t2 118 +TABLE test t3 166 +truncate performance_schema.events_waits_summary_by_account_by_event_name; +"================== BY_ACCOUNT truncated ==================" +"================== Step 18 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 0 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 242 +wait/lock/table/sql/handler 126 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 NULL 52 44 8 44 8 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 24 4 20 4 0 20 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 76 48 28 48 8 20 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 38 25 13 0 0 0 0 25 0 13 +TABLE test t2 42 25 17 0 0 0 0 25 0 17 +TABLE test t3 46 25 21 0 0 0 0 25 0 21 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 84 +TABLE test t2 118 +TABLE test t3 166 +truncate performance_schema.events_waits_summary_by_user_by_event_name; +"================== BY_USER truncated ==================" +"================== Step 19 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 0 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 242 +wait/lock/table/sql/handler 126 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 NULL 52 44 8 44 8 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 24 4 20 4 0 20 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 76 48 28 48 8 20 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 38 25 13 0 0 0 0 25 0 13 +TABLE test t2 42 25 17 0 0 0 0 25 0 17 +TABLE test t3 46 25 21 0 0 0 0 25 0 21 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 84 +TABLE test t2 118 +TABLE test t3 166 +truncate performance_schema.events_waits_summary_by_host_by_event_name; +"================== BY_HOST truncated ==================" +"================== Step 21 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 0 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 242 +wait/lock/table/sql/handler 126 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 NULL 52 44 8 44 8 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 24 4 20 4 0 20 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 76 48 28 48 8 20 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 38 25 13 0 0 0 0 25 0 13 +TABLE test t2 42 25 17 0 0 0 0 25 0 17 +TABLE test t3 46 25 21 0 0 0 0 25 0 21 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 84 +TABLE test t2 118 +TABLE test t3 166 +truncate performance_schema.events_waits_summary_global_by_event_name; +"================== GLOBAL truncated ==================" +"================== Step 21 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 0 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 0 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 0 0 0 0 0 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 0 0 0 0 0 0 0 +TABLE test t2 NULL 0 0 0 0 0 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 0 0 0 0 0 0 0 +TABLE test t3 index_b 0 0 0 0 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 0 0 0 0 0 0 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 0 +TABLE test t2 0 +TABLE test t3 0 +show global status like "performance_schema%table%_lost"; +Variable_name Value +Performance_schema_table_handles_lost 0 +Performance_schema_table_instances_lost 0 +Performance_schema_table_lock_stat_lost 0 diff --git a/mysql-test/suite/table_aggregate_global_4u_2t.result-pq b/mysql-test/suite/table_aggregate_global_4u_2t.result-pq new file mode 100644 index 000000000000..f609a41313e3 --- /dev/null +++ b/mysql-test/suite/table_aggregate_global_4u_2t.result-pq @@ -0,0 +1,1722 @@ +update performance_schema.setup_consumers +set enabled='NO' where name='thread_instrumentation'; +delete from performance_schema.setup_objects +where object_name='t2'; +select * from performance_schema.setup_actors +order by USER, HOST, `ROLE`; +HOST USER ROLE ENABLED HISTORY +localhost user1 % YES YES +localhost user2 % YES YES +localhost user3 % YES YES +localhost user4 % YES YES +select * from performance_schema.setup_objects +order by object_type, object_schema, object_name; +OBJECT_TYPE OBJECT_SCHEMA OBJECT_NAME ENABLED TIMED +TABLE test t1 YES YES +TABLE test t3 YES NO +select * from performance_schema.setup_consumers; +NAME ENABLED +events_stages_current YES +events_stages_history YES +events_stages_history_long YES +events_statements_current YES +events_statements_history YES +events_statements_history_long YES +events_transactions_current YES +events_transactions_history YES +events_transactions_history_long YES +events_waits_current YES +events_waits_history YES +events_waits_history_long YES +global_instrumentation YES +thread_instrumentation NO +statements_digest YES +flush tables; +truncate performance_schema.objects_summary_global_by_type; +truncate performance_schema.table_io_waits_summary_by_index_usage; +truncate performance_schema.table_io_waits_summary_by_table; +truncate performance_schema.table_lock_waits_summary_by_table; +truncate performance_schema.events_waits_summary_by_thread_by_event_name; +truncate performance_schema.events_waits_summary_by_account_by_event_name; +truncate performance_schema.events_waits_summary_by_user_by_event_name; +truncate performance_schema.events_waits_summary_by_host_by_event_name; +truncate performance_schema.events_waits_summary_global_by_event_name; +truncate performance_schema.events_waits_history_long; +show global variables like "performance_schema%table%"; +Variable_name Value +performance_schema_max_table_handles -1 +performance_schema_max_table_instances -1 +performance_schema_max_table_lock_stat -1 +show global status like "performance_schema%table%_lost"; +Variable_name Value +Performance_schema_table_handles_lost 0 +Performance_schema_table_instances_lost 0 +Performance_schema_table_lock_stat_lost 0 +"================== Step 1 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +execute dump_waits_user; +user event_name count_star +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 0 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 0 0 0 0 0 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 index_b 0 0 0 0 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 0 0 0 0 0 0 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 0 +TABLE test t2 0 +TABLE test t3 0 +select concat(current_user(), " is connected") as status; +status +user1@localhost is connected +"================== Step 2 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 0 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 0 0 0 0 0 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 index_b 0 0 0 0 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 0 0 0 0 0 0 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 0 +TABLE test t2 0 +TABLE test t3 0 +insert into test.t1 set a=101, b=1, c=1; +insert into test.t2 set a=102, b=2, c=2; +insert into test.t2 set a=103, b=3, c=3; +insert into test.t3 set a=104, b=4, c=4; +insert into test.t3 set a=105, b=5, c=5; +insert into test.t3 set a=106, b=6, c=6; +select * from test.t1; +a b c d +101 1 1 0 +select * from test.t2; +a b c d +102 2 2 0 +103 3 3 0 +select * from test.t3; +a b c d +104 4 4 0 +105 5 5 0 +106 6 6 0 +update test.t1 set d=d+1; +update test.t2 set d=d+1; +update test.t3 set d=d+1; +update test.t1 set d=d+1 where a=101; +update test.t2 set d=d+1 where a=101; +update test.t3 set d=d+1 where a=101; +select * from test.t1 force index(index_b) where b=5; +a b c d +select * from test.t2 force index(index_b) where b=5; +a b c d +select * from test.t3 force index(index_b) where b=5; +a b c d +105 5 5 1 +"================== con1 marker ==================" +"================== Step 3-A ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 22 +wait/lock/table/sql/handler 20 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 4 3 1 3 1 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 3 1 2 1 0 2 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 10 7 3 7 3 0 0 +TABLE test t3 index_b 1 1 0 1 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 4 1 3 1 0 3 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 7 4 3 4 1 2 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 15 9 6 9 3 3 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 9 6 3 0 0 0 0 6 0 3 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 11 6 5 0 0 0 0 6 0 5 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 16 +TABLE test t2 0 +TABLE test t3 26 +flush tables; +"================== con1 FLUSH ==================" +"================== Step 3-B ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 22 +wait/lock/table/sql/handler 20 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 4 3 1 3 1 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 3 1 2 1 0 2 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 10 7 3 7 3 0 0 +TABLE test t3 index_b 1 1 0 1 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 4 1 3 1 0 3 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 7 4 3 4 1 2 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 15 9 6 9 3 3 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 9 6 3 0 0 0 0 6 0 3 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 11 6 5 0 0 0 0 6 0 5 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 16 +TABLE test t2 0 +TABLE test t3 26 +select concat(current_user(), " is connected") as status; +status +user2@localhost is connected +"================== Step 4 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +username event_name count_star +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 22 +wait/lock/table/sql/handler 20 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 4 3 1 3 1 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 3 1 2 1 0 2 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 10 7 3 7 3 0 0 +TABLE test t3 index_b 1 1 0 1 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 4 1 3 1 0 3 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 7 4 3 4 1 2 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 15 9 6 9 3 3 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 9 6 3 0 0 0 0 6 0 3 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 11 6 5 0 0 0 0 6 0 5 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 16 +TABLE test t2 0 +TABLE test t3 26 +insert into test.t1 set a=201, b=1, c=1; +insert into test.t2 set a=202, b=2, c=2; +insert into test.t2 set a=203, b=3, c=3; +insert into test.t3 set a=204, b=4, c=4; +insert into test.t3 set a=205, b=5, c=5; +insert into test.t3 set a=206, b=6, c=6; +select * from test.t1; +a b c d +101 1 1 2 +201 1 1 0 +select * from test.t2; +a b c d +102 2 2 1 +103 3 3 1 +202 2 2 0 +203 3 3 0 +select * from test.t3; +a b c d +104 4 4 1 +105 5 5 1 +106 6 6 1 +204 4 4 0 +205 5 5 0 +206 6 6 0 +update test.t1 set d=d+1; +update test.t2 set d=d+1; +update test.t3 set d=d+1; +update test.t1 set d=d+1 where a=201; +update test.t2 set d=d+1 where a=201; +update test.t3 set d=d+1 where a=201; +select * from test.t1 force index(index_b) where b=5; +a b c d +select * from test.t2 force index(index_b) where b=5; +a b c d +select * from test.t3 force index(index_b) where b=5; +a b c d +105 5 5 2 +205 5 5 1 +"================== con2 marker ==================" +"================== Step 5 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +username event_name count_star +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 57 +wait/lock/table/sql/handler 40 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 10 8 2 8 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 7 2 5 2 0 5 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 26 20 6 20 6 0 0 +TABLE test t3 index_b 3 3 0 3 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 11 2 9 2 0 9 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 17 10 7 10 2 5 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 40 25 15 25 6 9 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 18 12 6 0 0 0 0 12 0 6 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 22 12 10 0 0 0 0 12 0 10 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 35 +TABLE test t2 0 +TABLE test t3 62 +select concat(current_user(), " is connected") as status; +status +user3@localhost is connected +"================== Step 6 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +username event_name count_star +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 57 +wait/lock/table/sql/handler 40 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 10 8 2 8 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 7 2 5 2 0 5 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 26 20 6 20 6 0 0 +TABLE test t3 index_b 3 3 0 3 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 11 2 9 2 0 9 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 17 10 7 10 2 5 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 40 25 15 25 6 9 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 18 12 6 0 0 0 0 12 0 6 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 22 12 10 0 0 0 0 12 0 10 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 35 +TABLE test t2 0 +TABLE test t3 62 +insert into test.t1 set a=301, b=1, c=1; +insert into test.t2 set a=302, b=2, c=2; +insert into test.t2 set a=303, b=3, c=3; +insert into test.t3 set a=304, b=4, c=4; +insert into test.t3 set a=305, b=5, c=5; +insert into test.t3 set a=306, b=6, c=6; +select * from test.t1; +a b c d +101 1 1 3 +201 1 1 2 +301 1 1 0 +select * from test.t2; +a b c d +102 2 2 2 +103 3 3 2 +202 2 2 1 +203 3 3 1 +302 2 2 0 +303 3 3 0 +select * from test.t3; +a b c d +104 4 4 2 +105 5 5 2 +106 6 6 2 +204 4 4 1 +205 5 5 1 +206 6 6 1 +304 4 4 0 +305 5 5 0 +306 6 6 0 +update test.t1 set d=d+1; +update test.t2 set d=d+1; +update test.t3 set d=d+1; +update test.t1 set d=d+1 where a=301; +update test.t2 set d=d+1 where a=301; +update test.t3 set d=d+1 where a=301; +select * from test.t1 force index(index_b) where b=5; +a b c d +select * from test.t2 force index(index_b) where b=5; +a b c d +select * from test.t3 force index(index_b) where b=5; +a b c d +105 5 5 3 +205 5 5 2 +305 5 5 1 +"================== con3 marker ==================" +"================== Step 7 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +username event_name count_star +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 105 +wait/lock/table/sql/handler 60 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 15 3 15 3 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 12 3 9 3 0 9 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 48 39 9 39 9 0 0 +TABLE test t3 index_b 6 6 0 6 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 21 3 18 3 0 18 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 30 18 12 18 3 9 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 75 48 27 48 9 18 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 27 18 9 0 0 0 0 18 0 9 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 33 18 15 0 0 0 0 18 0 15 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 57 +TABLE test t2 0 +TABLE test t3 108 +select concat(current_user(), " is connected") as status; +status +user4@localhost is connected +"================== Step 8 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +username event_name count_star +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +username event_name count_star +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 0 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 105 +wait/lock/table/sql/handler 60 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 15 3 15 3 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 12 3 9 3 0 9 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 48 39 9 39 9 0 0 +TABLE test t3 index_b 6 6 0 6 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 21 3 18 3 0 18 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 30 18 12 18 3 9 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 75 48 27 48 9 18 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 27 18 9 0 0 0 0 18 0 9 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 33 18 15 0 0 0 0 18 0 15 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 57 +TABLE test t2 0 +TABLE test t3 108 +insert into test.t1 set a=401, b=1, c=1; +insert into test.t2 set a=402, b=2, c=2; +insert into test.t2 set a=403, b=3, c=3; +insert into test.t3 set a=404, b=4, c=4; +insert into test.t3 set a=405, b=5, c=5; +insert into test.t3 set a=406, b=6, c=6; +select * from test.t1; +a b c d +101 1 1 4 +201 1 1 3 +301 1 1 2 +401 1 1 0 +select * from test.t2; +a b c d +102 2 2 3 +103 3 3 3 +202 2 2 2 +203 3 3 2 +302 2 2 1 +303 3 3 1 +402 2 2 0 +403 3 3 0 +select * from test.t3; +a b c d +104 4 4 3 +105 5 5 3 +106 6 6 3 +204 4 4 2 +205 5 5 2 +206 6 6 2 +304 4 4 1 +305 5 5 1 +306 6 6 1 +404 4 4 0 +405 5 5 0 +406 6 6 0 +update test.t1 set d=d+1; +update test.t2 set d=d+1; +update test.t3 set d=d+1; +update test.t1 set d=d+1 where a=401; +update test.t2 set d=d+1 where a=401; +update test.t3 set d=d+1 where a=401; +select * from test.t1 force index(index_b) where b=5; +a b c d +select * from test.t2 force index(index_b) where b=5; +a b c d +select * from test.t3 force index(index_b) where b=5; +a b c d +105 5 5 4 +205 5 5 3 +305 5 5 2 +405 5 5 1 +"================== con4 marker ==================" +"================== Step 9 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +username event_name count_star +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +username event_name count_star +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 0 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 166 +wait/lock/table/sql/handler 80 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 36 24 12 0 0 0 0 24 0 12 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 44 24 20 0 0 0 0 24 0 20 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 82 +TABLE test t2 0 +TABLE test t3 164 +lock tables test.t1 read, test.t2 read, test.t3 read; +unlock tables; +lock tables test.t1 write, test.t2 write, test.t3 write; +unlock tables; +"================== con1 marker ==================" +"================== Step 10 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +username event_name count_star +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +username event_name count_star +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 0 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 166 +wait/lock/table/sql/handler 84 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 38 25 13 0 0 0 0 25 0 13 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 46 25 21 0 0 0 0 25 0 21 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 84 +TABLE test t2 0 +TABLE test t3 166 +flush tables; +"================== flush marker ==================" +"================== Step 11 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +username event_name count_star +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +username event_name count_star +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 0 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 166 +wait/lock/table/sql/handler 84 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 38 25 13 0 0 0 0 25 0 13 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 46 25 21 0 0 0 0 25 0 21 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 84 +TABLE test t2 0 +TABLE test t3 166 +set global read_only=1; +set global read_only=0; +"================== global read_only marker ==================" +"================== Step 12 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +username event_name count_star +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +username event_name count_star +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 0 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 166 +wait/lock/table/sql/handler 84 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 38 25 13 0 0 0 0 25 0 13 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 46 25 21 0 0 0 0 25 0 21 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 84 +TABLE test t2 0 +TABLE test t3 166 +"================== con1 disconnected ==================" +"================== Step 13 ==================" +call dump_thread(); +username status +user1 not found +username event_name count_star +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +username event_name count_star +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 0 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 166 +wait/lock/table/sql/handler 84 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 38 25 13 0 0 0 0 25 0 13 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 46 25 21 0 0 0 0 25 0 21 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 84 +TABLE test t2 0 +TABLE test t3 166 +"================== con2 disconnected ==================" +"================== Step 14 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username event_name count_star +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +username event_name count_star +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 0 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 166 +wait/lock/table/sql/handler 84 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 38 25 13 0 0 0 0 25 0 13 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 46 25 21 0 0 0 0 25 0 21 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 84 +TABLE test t2 0 +TABLE test t3 166 +"================== con3 disconnected ==================" +"================== Step 15 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username event_name count_star +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 0 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 166 +wait/lock/table/sql/handler 84 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 38 25 13 0 0 0 0 25 0 13 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 46 25 21 0 0 0 0 25 0 21 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 84 +TABLE test t2 0 +TABLE test t3 166 +"================== con4 disconnected ==================" +"================== Step 16 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 0 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 166 +wait/lock/table/sql/handler 84 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 38 25 13 0 0 0 0 25 0 13 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 46 25 21 0 0 0 0 25 0 21 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 84 +TABLE test t2 0 +TABLE test t3 166 +truncate performance_schema.events_waits_summary_by_thread_by_event_name; +"================== BY_THREAD truncated ==================" +"================== Step 17 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 0 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 166 +wait/lock/table/sql/handler 84 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 38 25 13 0 0 0 0 25 0 13 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 46 25 21 0 0 0 0 25 0 21 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 84 +TABLE test t2 0 +TABLE test t3 166 +truncate performance_schema.events_waits_summary_by_account_by_event_name; +"================== BY_ACCOUNT truncated ==================" +"================== Step 18 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 0 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 166 +wait/lock/table/sql/handler 84 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 38 25 13 0 0 0 0 25 0 13 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 46 25 21 0 0 0 0 25 0 21 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 84 +TABLE test t2 0 +TABLE test t3 166 +truncate performance_schema.events_waits_summary_by_user_by_event_name; +"================== BY_USER truncated ==================" +"================== Step 19 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 0 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 166 +wait/lock/table/sql/handler 84 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 38 25 13 0 0 0 0 25 0 13 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 46 25 21 0 0 0 0 25 0 21 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 84 +TABLE test t2 0 +TABLE test t3 166 +truncate performance_schema.events_waits_summary_by_host_by_event_name; +"================== BY_HOST truncated ==================" +"================== Step 21 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 0 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 166 +wait/lock/table/sql/handler 84 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 38 25 13 0 0 0 0 25 0 13 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 46 25 21 0 0 0 0 25 0 21 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 84 +TABLE test t2 0 +TABLE test t3 166 +truncate performance_schema.events_waits_summary_global_by_event_name; +"================== GLOBAL truncated ==================" +"================== Step 21 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 0 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 0 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 0 0 0 0 0 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 0 0 0 0 0 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 0 0 0 0 0 0 0 +TABLE test t3 index_b 0 0 0 0 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 0 0 0 0 0 0 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 0 +TABLE test t2 0 +TABLE test t3 0 +show global status like "performance_schema%table%_lost"; +Variable_name Value +Performance_schema_table_handles_lost 0 +Performance_schema_table_instances_lost 0 +Performance_schema_table_lock_stat_lost 0 diff --git a/mysql-test/suite/table_aggregate_hist_2u_3t.result-pq b/mysql-test/suite/table_aggregate_hist_2u_3t.result-pq new file mode 100644 index 000000000000..9ab1cff9fc56 --- /dev/null +++ b/mysql-test/suite/table_aggregate_hist_2u_3t.result-pq @@ -0,0 +1,1859 @@ +delete from performance_schema.setup_actors +where user in ('user2', 'user4'); +select * from performance_schema.setup_actors +order by USER, HOST, `ROLE`; +HOST USER ROLE ENABLED HISTORY +localhost user1 % YES YES +localhost user3 % YES YES +select * from performance_schema.setup_objects +order by object_type, object_schema, object_name; +OBJECT_TYPE OBJECT_SCHEMA OBJECT_NAME ENABLED TIMED +TABLE test t1 YES YES +TABLE test t2 YES NO +TABLE test t3 YES NO +select * from performance_schema.setup_consumers; +NAME ENABLED +events_stages_current YES +events_stages_history YES +events_stages_history_long YES +events_statements_current YES +events_statements_history YES +events_statements_history_long YES +events_transactions_current YES +events_transactions_history YES +events_transactions_history_long YES +events_waits_current YES +events_waits_history YES +events_waits_history_long YES +global_instrumentation YES +thread_instrumentation YES +statements_digest YES +flush tables; +truncate performance_schema.objects_summary_global_by_type; +truncate performance_schema.table_io_waits_summary_by_index_usage; +truncate performance_schema.table_io_waits_summary_by_table; +truncate performance_schema.table_lock_waits_summary_by_table; +truncate performance_schema.events_waits_summary_by_thread_by_event_name; +truncate performance_schema.events_waits_summary_by_account_by_event_name; +truncate performance_schema.events_waits_summary_by_user_by_event_name; +truncate performance_schema.events_waits_summary_by_host_by_event_name; +truncate performance_schema.events_waits_summary_global_by_event_name; +truncate performance_schema.events_waits_history_long; +show global variables like "performance_schema%table%"; +Variable_name Value +performance_schema_max_table_handles -1 +performance_schema_max_table_instances -1 +performance_schema_max_table_lock_stat -1 +show global status like "performance_schema%table%_lost"; +Variable_name Value +Performance_schema_table_handles_lost 0 +Performance_schema_table_instances_lost 0 +Performance_schema_table_lock_stat_lost 0 +"================== Step 1 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +execute dump_waits_user; +user event_name count_star +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 0 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 0 0 0 0 0 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 index_b 0 0 0 0 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 0 0 0 0 0 0 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 0 +TABLE test t2 0 +TABLE test t3 0 +select concat(current_user(), " is connected") as status; +status +user1@localhost is connected +"================== Step 2 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 0 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 0 0 0 0 0 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 index_b 0 0 0 0 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 0 0 0 0 0 0 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 0 +TABLE test t2 0 +TABLE test t3 0 +insert into test.t1 set a=101, b=1, c=1; +insert into test.t2 set a=102, b=2, c=2; +insert into test.t2 set a=103, b=3, c=3; +insert into test.t3 set a=104, b=4, c=4; +insert into test.t3 set a=105, b=5, c=5; +insert into test.t3 set a=106, b=6, c=6; +select * from test.t1; +a b c d +101 1 1 0 +select * from test.t2; +a b c d +102 2 2 0 +103 3 3 0 +select * from test.t3; +a b c d +104 4 4 0 +105 5 5 0 +106 6 6 0 +update test.t1 set d=d+1; +update test.t2 set d=d+1; +update test.t3 set d=d+1; +update test.t1 set d=d+1 where a=101; +update test.t2 set d=d+1 where a=101; +update test.t3 set d=d+1 where a=101; +select * from test.t1 force index(index_b) where b=5; +a b c d +select * from test.t2 force index(index_b) where b=5; +a b c d +select * from test.t3 force index(index_b) where b=5; +a b c d +105 5 5 1 +"================== con1 marker ==================" +"================== Step 3-A ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 25 +user1 wait/lock/table/sql/handler 24 +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 30 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 30 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 32 +localhost wait/lock/table/sql/handler 30 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 32 +wait/lock/table/sql/handler 30 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 7 TABLE test t1 +wait/lock/table/sql/handler 9 TABLE test t1 +wait/io/table/sql/handler 10 TABLE test t2 +wait/lock/table/sql/handler 10 TABLE test t2 +wait/io/table/sql/handler 15 TABLE test t3 +wait/lock/table/sql/handler 11 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 4 3 1 3 1 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 3 1 2 1 0 2 0 +TABLE test t2 NULL 7 5 2 5 2 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 3 1 2 1 0 2 0 +TABLE test t3 NULL 10 7 3 7 3 0 0 +TABLE test t3 index_b 1 1 0 1 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 4 1 3 1 0 3 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 7 4 3 4 1 2 0 +TABLE test t2 10 6 4 6 2 2 0 +TABLE test t3 15 9 6 9 3 3 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 9 6 3 0 0 0 0 6 0 3 +TABLE test t2 10 6 4 0 0 0 0 6 0 4 +TABLE test t3 11 6 5 0 0 0 0 6 0 5 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 16 +TABLE test t2 20 +TABLE test t3 26 +flush tables; +"================== con1 FLUSH ==================" +"================== Step 3-B ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 25 +user1 wait/lock/table/sql/handler 24 +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 30 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 30 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 32 +localhost wait/lock/table/sql/handler 30 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 32 +wait/lock/table/sql/handler 30 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 7 TABLE test t1 +wait/lock/table/sql/handler 9 TABLE test t1 +wait/io/table/sql/handler 10 TABLE test t2 +wait/lock/table/sql/handler 10 TABLE test t2 +wait/io/table/sql/handler 15 TABLE test t3 +wait/lock/table/sql/handler 11 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 4 3 1 3 1 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 3 1 2 1 0 2 0 +TABLE test t2 NULL 7 5 2 5 2 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 3 1 2 1 0 2 0 +TABLE test t3 NULL 10 7 3 7 3 0 0 +TABLE test t3 index_b 1 1 0 1 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 4 1 3 1 0 3 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 7 4 3 4 1 2 0 +TABLE test t2 10 6 4 6 2 2 0 +TABLE test t3 15 9 6 9 3 3 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 9 6 3 0 0 0 0 6 0 3 +TABLE test t2 10 6 4 0 0 0 0 6 0 4 +TABLE test t3 11 6 5 0 0 0 0 6 0 5 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 16 +TABLE test t2 20 +TABLE test t3 26 +select concat(current_user(), " is connected") as status; +status +user2@localhost is connected +"================== Step 4 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 25 +user1 wait/lock/table/sql/handler 24 +username event_name count_star +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 30 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 30 +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 32 +localhost wait/lock/table/sql/handler 30 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 32 +wait/lock/table/sql/handler 30 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 7 TABLE test t1 +wait/lock/table/sql/handler 9 TABLE test t1 +wait/io/table/sql/handler 10 TABLE test t2 +wait/lock/table/sql/handler 10 TABLE test t2 +wait/io/table/sql/handler 15 TABLE test t3 +wait/lock/table/sql/handler 11 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 4 3 1 3 1 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 3 1 2 1 0 2 0 +TABLE test t2 NULL 7 5 2 5 2 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 3 1 2 1 0 2 0 +TABLE test t3 NULL 10 7 3 7 3 0 0 +TABLE test t3 index_b 1 1 0 1 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 4 1 3 1 0 3 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 7 4 3 4 1 2 0 +TABLE test t2 10 6 4 6 2 2 0 +TABLE test t3 15 9 6 9 3 3 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 9 6 3 0 0 0 0 6 0 3 +TABLE test t2 10 6 4 0 0 0 0 6 0 4 +TABLE test t3 11 6 5 0 0 0 0 6 0 5 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 16 +TABLE test t2 20 +TABLE test t3 26 +insert into test.t1 set a=201, b=1, c=1; +insert into test.t2 set a=202, b=2, c=2; +insert into test.t2 set a=203, b=3, c=3; +insert into test.t3 set a=204, b=4, c=4; +insert into test.t3 set a=205, b=5, c=5; +insert into test.t3 set a=206, b=6, c=6; +select * from test.t1; +a b c d +101 1 1 2 +201 1 1 0 +select * from test.t2; +a b c d +102 2 2 1 +103 3 3 1 +202 2 2 0 +203 3 3 0 +select * from test.t3; +a b c d +104 4 4 1 +105 5 5 1 +106 6 6 1 +204 4 4 0 +205 5 5 0 +206 6 6 0 +update test.t1 set d=d+1; +update test.t2 set d=d+1; +update test.t3 set d=d+1; +update test.t1 set d=d+1 where a=201; +update test.t2 set d=d+1 where a=201; +update test.t3 set d=d+1 where a=201; +select * from test.t1 force index(index_b) where b=5; +a b c d +select * from test.t2 force index(index_b) where b=5; +a b c d +select * from test.t3 force index(index_b) where b=5; +a b c d +105 5 5 2 +205 5 5 1 +"================== con2 marker ==================" +"================== Step 5 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 25 +user1 wait/lock/table/sql/handler 24 +username event_name count_star +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 30 +user2 localhost wait/io/table/sql/handler 14 +user2 localhost wait/lock/table/sql/handler 6 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 30 +user2 wait/io/table/sql/handler 14 +user2 wait/lock/table/sql/handler 6 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 46 +localhost wait/lock/table/sql/handler 36 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 46 +wait/lock/table/sql/handler 36 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 9 TABLE test t1 +wait/lock/table/sql/handler 11 TABLE test t1 +wait/io/table/sql/handler 14 TABLE test t2 +wait/lock/table/sql/handler 12 TABLE test t2 +wait/io/table/sql/handler 23 TABLE test t3 +wait/lock/table/sql/handler 13 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 6 5 1 5 1 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 3 1 2 1 0 2 0 +TABLE test t2 NULL 11 9 2 9 2 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 3 1 2 1 0 2 0 +TABLE test t3 NULL 16 13 3 13 3 0 0 +TABLE test t3 index_b 3 3 0 3 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 4 1 3 1 0 3 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 9 6 3 6 1 2 0 +TABLE test t2 14 10 4 10 2 2 0 +TABLE test t3 23 17 6 17 3 3 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 11 8 3 0 0 0 0 8 0 3 +TABLE test t2 12 8 4 0 0 0 0 8 0 4 +TABLE test t3 13 8 5 0 0 0 0 8 0 5 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 20 +TABLE test t2 26 +TABLE test t3 36 +select concat(current_user(), " is connected") as status; +status +user3@localhost is connected +"================== Step 6 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 25 +user1 wait/lock/table/sql/handler 24 +username event_name count_star +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 30 +user2 localhost wait/io/table/sql/handler 14 +user2 localhost wait/lock/table/sql/handler 6 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 30 +user2 wait/io/table/sql/handler 14 +user2 wait/lock/table/sql/handler 6 +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 46 +localhost wait/lock/table/sql/handler 36 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 46 +wait/lock/table/sql/handler 36 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 9 TABLE test t1 +wait/lock/table/sql/handler 11 TABLE test t1 +wait/io/table/sql/handler 14 TABLE test t2 +wait/lock/table/sql/handler 12 TABLE test t2 +wait/io/table/sql/handler 23 TABLE test t3 +wait/lock/table/sql/handler 13 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 6 5 1 5 1 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 3 1 2 1 0 2 0 +TABLE test t2 NULL 11 9 2 9 2 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 3 1 2 1 0 2 0 +TABLE test t3 NULL 16 13 3 13 3 0 0 +TABLE test t3 index_b 3 3 0 3 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 4 1 3 1 0 3 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 9 6 3 6 1 2 0 +TABLE test t2 14 10 4 10 2 2 0 +TABLE test t3 23 17 6 17 3 3 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 11 8 3 0 0 0 0 8 0 3 +TABLE test t2 12 8 4 0 0 0 0 8 0 4 +TABLE test t3 13 8 5 0 0 0 0 8 0 5 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 20 +TABLE test t2 26 +TABLE test t3 36 +insert into test.t1 set a=301, b=1, c=1; +insert into test.t2 set a=302, b=2, c=2; +insert into test.t2 set a=303, b=3, c=3; +insert into test.t3 set a=304, b=4, c=4; +insert into test.t3 set a=305, b=5, c=5; +insert into test.t3 set a=306, b=6, c=6; +select * from test.t1; +a b c d +101 1 1 3 +201 1 1 2 +301 1 1 0 +select * from test.t2; +a b c d +102 2 2 2 +103 3 3 2 +202 2 2 1 +203 3 3 1 +302 2 2 0 +303 3 3 0 +select * from test.t3; +a b c d +104 4 4 2 +105 5 5 2 +106 6 6 2 +204 4 4 1 +205 5 5 1 +206 6 6 1 +304 4 4 0 +305 5 5 0 +306 6 6 0 +update test.t1 set d=d+1; +update test.t2 set d=d+1; +update test.t3 set d=d+1; +update test.t1 set d=d+1 where a=301; +update test.t2 set d=d+1 where a=301; +update test.t3 set d=d+1 where a=301; +select * from test.t1 force index(index_b) where b=5; +a b c d +select * from test.t2 force index(index_b) where b=5; +a b c d +select * from test.t3 force index(index_b) where b=5; +a b c d +105 5 5 3 +205 5 5 2 +305 5 5 1 +"================== con3 marker ==================" +"================== Step 7 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 25 +user1 wait/lock/table/sql/handler 24 +username event_name count_star +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 49 +user3 wait/lock/table/sql/handler 24 +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 30 +user2 localhost wait/io/table/sql/handler 14 +user2 localhost wait/lock/table/sql/handler 6 +user3 localhost wait/io/table/sql/handler 70 +user3 localhost wait/lock/table/sql/handler 30 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 30 +user2 wait/io/table/sql/handler 14 +user2 wait/lock/table/sql/handler 6 +user3 wait/io/table/sql/handler 70 +user3 wait/lock/table/sql/handler 30 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 116 +localhost wait/lock/table/sql/handler 66 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 116 +wait/lock/table/sql/handler 66 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 22 TABLE test t1 +wait/lock/table/sql/handler 20 TABLE test t1 +wait/io/table/sql/handler 36 TABLE test t2 +wait/lock/table/sql/handler 22 TABLE test t2 +wait/io/table/sql/handler 58 TABLE test t3 +wait/lock/table/sql/handler 24 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 14 12 2 12 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 8 2 6 2 0 6 0 +TABLE test t2 NULL 26 22 4 22 4 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 10 2 8 2 0 8 0 +TABLE test t3 NULL 38 32 6 32 6 0 0 +TABLE test t3 index_b 6 6 0 6 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 14 2 12 2 0 12 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 22 14 8 14 2 6 0 +TABLE test t2 36 24 12 24 4 8 0 +TABLE test t3 58 40 18 40 6 12 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 20 14 6 0 0 0 0 14 0 6 +TABLE test t2 22 14 8 0 0 0 0 14 0 8 +TABLE test t3 24 14 10 0 0 0 0 14 0 10 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 42 +TABLE test t2 58 +TABLE test t3 82 +select concat(current_user(), " is connected") as status; +status +user4@localhost is connected +"================== Step 8 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 25 +user1 wait/lock/table/sql/handler 24 +username event_name count_star +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 49 +user3 wait/lock/table/sql/handler 24 +username event_name count_star +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 30 +user2 localhost wait/io/table/sql/handler 14 +user2 localhost wait/lock/table/sql/handler 6 +user3 localhost wait/io/table/sql/handler 70 +user3 localhost wait/lock/table/sql/handler 30 +user4 localhost wait/io/table/sql/handler 0 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 30 +user2 wait/io/table/sql/handler 14 +user2 wait/lock/table/sql/handler 6 +user3 wait/io/table/sql/handler 70 +user3 wait/lock/table/sql/handler 30 +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 116 +localhost wait/lock/table/sql/handler 66 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 116 +wait/lock/table/sql/handler 66 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 22 TABLE test t1 +wait/lock/table/sql/handler 20 TABLE test t1 +wait/io/table/sql/handler 36 TABLE test t2 +wait/lock/table/sql/handler 22 TABLE test t2 +wait/io/table/sql/handler 58 TABLE test t3 +wait/lock/table/sql/handler 24 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 14 12 2 12 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 8 2 6 2 0 6 0 +TABLE test t2 NULL 26 22 4 22 4 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 10 2 8 2 0 8 0 +TABLE test t3 NULL 38 32 6 32 6 0 0 +TABLE test t3 index_b 6 6 0 6 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 14 2 12 2 0 12 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 22 14 8 14 2 6 0 +TABLE test t2 36 24 12 24 4 8 0 +TABLE test t3 58 40 18 40 6 12 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 20 14 6 0 0 0 0 14 0 6 +TABLE test t2 22 14 8 0 0 0 0 14 0 8 +TABLE test t3 24 14 10 0 0 0 0 14 0 10 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 42 +TABLE test t2 58 +TABLE test t3 82 +insert into test.t1 set a=401, b=1, c=1; +insert into test.t2 set a=402, b=2, c=2; +insert into test.t2 set a=403, b=3, c=3; +insert into test.t3 set a=404, b=4, c=4; +insert into test.t3 set a=405, b=5, c=5; +insert into test.t3 set a=406, b=6, c=6; +select * from test.t1; +a b c d +101 1 1 4 +201 1 1 3 +301 1 1 2 +401 1 1 0 +select * from test.t2; +a b c d +102 2 2 3 +103 3 3 3 +202 2 2 2 +203 3 3 2 +302 2 2 1 +303 3 3 1 +402 2 2 0 +403 3 3 0 +select * from test.t3; +a b c d +104 4 4 3 +105 5 5 3 +106 6 6 3 +204 4 4 2 +205 5 5 2 +206 6 6 2 +304 4 4 1 +305 5 5 1 +306 6 6 1 +404 4 4 0 +405 5 5 0 +406 6 6 0 +update test.t1 set d=d+1; +update test.t2 set d=d+1; +update test.t3 set d=d+1; +update test.t1 set d=d+1 where a=401; +update test.t2 set d=d+1 where a=401; +update test.t3 set d=d+1 where a=401; +select * from test.t1 force index(index_b) where b=5; +a b c d +select * from test.t2 force index(index_b) where b=5; +a b c d +select * from test.t3 force index(index_b) where b=5; +a b c d +105 5 5 4 +205 5 5 3 +305 5 5 2 +405 5 5 1 +"================== con4 marker ==================" +"================== Step 9 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 25 +user1 wait/lock/table/sql/handler 24 +username event_name count_star +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 49 +user3 wait/lock/table/sql/handler 24 +username event_name count_star +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 30 +user2 localhost wait/io/table/sql/handler 14 +user2 localhost wait/lock/table/sql/handler 6 +user3 localhost wait/io/table/sql/handler 70 +user3 localhost wait/lock/table/sql/handler 30 +user4 localhost wait/io/table/sql/handler 28 +user4 localhost wait/lock/table/sql/handler 6 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 30 +user2 wait/io/table/sql/handler 14 +user2 wait/lock/table/sql/handler 6 +user3 wait/io/table/sql/handler 70 +user3 wait/lock/table/sql/handler 30 +user4 wait/io/table/sql/handler 28 +user4 wait/lock/table/sql/handler 6 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 144 +localhost wait/lock/table/sql/handler 72 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 144 +wait/lock/table/sql/handler 72 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 26 TABLE test t1 +wait/lock/table/sql/handler 22 TABLE test t1 +wait/io/table/sql/handler 44 TABLE test t2 +wait/lock/table/sql/handler 24 TABLE test t2 +wait/io/table/sql/handler 74 TABLE test t3 +wait/lock/table/sql/handler 26 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 16 2 16 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 8 2 6 2 0 6 0 +TABLE test t2 NULL 34 30 4 30 4 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 10 2 8 2 0 8 0 +TABLE test t3 NULL 50 44 6 44 6 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 14 2 12 2 0 12 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 26 18 8 18 2 6 0 +TABLE test t2 44 32 12 32 4 8 0 +TABLE test t3 74 56 18 56 6 12 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 22 16 6 0 0 0 0 16 0 6 +TABLE test t2 24 16 8 0 0 0 0 16 0 8 +TABLE test t3 26 16 10 0 0 0 0 16 0 10 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 48 +TABLE test t2 68 +TABLE test t3 100 +lock tables test.t1 read, test.t2 read, test.t3 read; +unlock tables; +lock tables test.t1 write, test.t2 write, test.t3 write; +unlock tables; +"================== con1 marker ==================" +"================== Step 10 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 25 +user1 wait/lock/table/sql/handler 30 +username event_name count_star +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 49 +user3 wait/lock/table/sql/handler 24 +username event_name count_star +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 36 +user2 localhost wait/io/table/sql/handler 14 +user2 localhost wait/lock/table/sql/handler 6 +user3 localhost wait/io/table/sql/handler 70 +user3 localhost wait/lock/table/sql/handler 30 +user4 localhost wait/io/table/sql/handler 28 +user4 localhost wait/lock/table/sql/handler 6 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 36 +user2 wait/io/table/sql/handler 14 +user2 wait/lock/table/sql/handler 6 +user3 wait/io/table/sql/handler 70 +user3 wait/lock/table/sql/handler 30 +user4 wait/io/table/sql/handler 28 +user4 wait/lock/table/sql/handler 6 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 144 +localhost wait/lock/table/sql/handler 78 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 144 +wait/lock/table/sql/handler 78 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 26 TABLE test t1 +wait/lock/table/sql/handler 24 TABLE test t1 +wait/io/table/sql/handler 44 TABLE test t2 +wait/lock/table/sql/handler 26 TABLE test t2 +wait/io/table/sql/handler 74 TABLE test t3 +wait/lock/table/sql/handler 28 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 16 2 16 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 8 2 6 2 0 6 0 +TABLE test t2 NULL 34 30 4 30 4 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 10 2 8 2 0 8 0 +TABLE test t3 NULL 50 44 6 44 6 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 14 2 12 2 0 12 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 26 18 8 18 2 6 0 +TABLE test t2 44 32 12 32 4 8 0 +TABLE test t3 74 56 18 56 6 12 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 24 17 7 0 0 0 0 17 0 7 +TABLE test t2 26 17 9 0 0 0 0 17 0 9 +TABLE test t3 28 17 11 0 0 0 0 17 0 11 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 50 +TABLE test t2 70 +TABLE test t3 102 +flush tables; +"================== flush marker ==================" +"================== Step 11 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 25 +user1 wait/lock/table/sql/handler 30 +username event_name count_star +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 49 +user3 wait/lock/table/sql/handler 24 +username event_name count_star +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 36 +user2 localhost wait/io/table/sql/handler 14 +user2 localhost wait/lock/table/sql/handler 6 +user3 localhost wait/io/table/sql/handler 70 +user3 localhost wait/lock/table/sql/handler 30 +user4 localhost wait/io/table/sql/handler 28 +user4 localhost wait/lock/table/sql/handler 6 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 36 +user2 wait/io/table/sql/handler 14 +user2 wait/lock/table/sql/handler 6 +user3 wait/io/table/sql/handler 70 +user3 wait/lock/table/sql/handler 30 +user4 wait/io/table/sql/handler 28 +user4 wait/lock/table/sql/handler 6 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 144 +localhost wait/lock/table/sql/handler 78 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 144 +wait/lock/table/sql/handler 78 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 26 TABLE test t1 +wait/lock/table/sql/handler 24 TABLE test t1 +wait/io/table/sql/handler 44 TABLE test t2 +wait/lock/table/sql/handler 26 TABLE test t2 +wait/io/table/sql/handler 74 TABLE test t3 +wait/lock/table/sql/handler 28 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 16 2 16 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 8 2 6 2 0 6 0 +TABLE test t2 NULL 34 30 4 30 4 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 10 2 8 2 0 8 0 +TABLE test t3 NULL 50 44 6 44 6 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 14 2 12 2 0 12 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 26 18 8 18 2 6 0 +TABLE test t2 44 32 12 32 4 8 0 +TABLE test t3 74 56 18 56 6 12 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 24 17 7 0 0 0 0 17 0 7 +TABLE test t2 26 17 9 0 0 0 0 17 0 9 +TABLE test t3 28 17 11 0 0 0 0 17 0 11 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 50 +TABLE test t2 70 +TABLE test t3 102 +set global read_only=1; +set global read_only=0; +"================== global read_only marker ==================" +"================== Step 12 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 25 +user1 wait/lock/table/sql/handler 30 +username event_name count_star +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 49 +user3 wait/lock/table/sql/handler 24 +username event_name count_star +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 36 +user2 localhost wait/io/table/sql/handler 14 +user2 localhost wait/lock/table/sql/handler 6 +user3 localhost wait/io/table/sql/handler 70 +user3 localhost wait/lock/table/sql/handler 30 +user4 localhost wait/io/table/sql/handler 28 +user4 localhost wait/lock/table/sql/handler 6 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 36 +user2 wait/io/table/sql/handler 14 +user2 wait/lock/table/sql/handler 6 +user3 wait/io/table/sql/handler 70 +user3 wait/lock/table/sql/handler 30 +user4 wait/io/table/sql/handler 28 +user4 wait/lock/table/sql/handler 6 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 144 +localhost wait/lock/table/sql/handler 78 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 144 +wait/lock/table/sql/handler 78 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 26 TABLE test t1 +wait/lock/table/sql/handler 24 TABLE test t1 +wait/io/table/sql/handler 44 TABLE test t2 +wait/lock/table/sql/handler 26 TABLE test t2 +wait/io/table/sql/handler 74 TABLE test t3 +wait/lock/table/sql/handler 28 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 16 2 16 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 8 2 6 2 0 6 0 +TABLE test t2 NULL 34 30 4 30 4 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 10 2 8 2 0 8 0 +TABLE test t3 NULL 50 44 6 44 6 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 14 2 12 2 0 12 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 26 18 8 18 2 6 0 +TABLE test t2 44 32 12 32 4 8 0 +TABLE test t3 74 56 18 56 6 12 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 24 17 7 0 0 0 0 17 0 7 +TABLE test t2 26 17 9 0 0 0 0 17 0 9 +TABLE test t3 28 17 11 0 0 0 0 17 0 11 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 50 +TABLE test t2 70 +TABLE test t3 102 +"================== con1 disconnected ==================" +"================== Step 13 ==================" +call dump_thread(); +username status +user1 not found +username event_name count_star +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 49 +user3 wait/lock/table/sql/handler 24 +username event_name count_star +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 36 +user2 localhost wait/io/table/sql/handler 14 +user2 localhost wait/lock/table/sql/handler 6 +user3 localhost wait/io/table/sql/handler 70 +user3 localhost wait/lock/table/sql/handler 30 +user4 localhost wait/io/table/sql/handler 28 +user4 localhost wait/lock/table/sql/handler 6 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 36 +user2 wait/io/table/sql/handler 14 +user2 wait/lock/table/sql/handler 6 +user3 wait/io/table/sql/handler 70 +user3 wait/lock/table/sql/handler 30 +user4 wait/io/table/sql/handler 28 +user4 wait/lock/table/sql/handler 6 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 144 +localhost wait/lock/table/sql/handler 78 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 144 +wait/lock/table/sql/handler 78 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 26 TABLE test t1 +wait/lock/table/sql/handler 24 TABLE test t1 +wait/io/table/sql/handler 44 TABLE test t2 +wait/lock/table/sql/handler 26 TABLE test t2 +wait/io/table/sql/handler 74 TABLE test t3 +wait/lock/table/sql/handler 28 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 16 2 16 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 8 2 6 2 0 6 0 +TABLE test t2 NULL 34 30 4 30 4 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 10 2 8 2 0 8 0 +TABLE test t3 NULL 50 44 6 44 6 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 14 2 12 2 0 12 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 26 18 8 18 2 6 0 +TABLE test t2 44 32 12 32 4 8 0 +TABLE test t3 74 56 18 56 6 12 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 24 17 7 0 0 0 0 17 0 7 +TABLE test t2 26 17 9 0 0 0 0 17 0 9 +TABLE test t3 28 17 11 0 0 0 0 17 0 11 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 50 +TABLE test t2 70 +TABLE test t3 102 +"================== con2 disconnected ==================" +"================== Step 14 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username event_name count_star +user3 wait/io/table/sql/handler 49 +user3 wait/lock/table/sql/handler 24 +username event_name count_star +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 36 +user2 localhost wait/io/table/sql/handler 14 +user2 localhost wait/lock/table/sql/handler 6 +user3 localhost wait/io/table/sql/handler 70 +user3 localhost wait/lock/table/sql/handler 30 +user4 localhost wait/io/table/sql/handler 28 +user4 localhost wait/lock/table/sql/handler 6 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 36 +user2 wait/io/table/sql/handler 14 +user2 wait/lock/table/sql/handler 6 +user3 wait/io/table/sql/handler 70 +user3 wait/lock/table/sql/handler 30 +user4 wait/io/table/sql/handler 28 +user4 wait/lock/table/sql/handler 6 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 144 +localhost wait/lock/table/sql/handler 78 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 144 +wait/lock/table/sql/handler 78 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 26 TABLE test t1 +wait/lock/table/sql/handler 24 TABLE test t1 +wait/io/table/sql/handler 44 TABLE test t2 +wait/lock/table/sql/handler 26 TABLE test t2 +wait/io/table/sql/handler 74 TABLE test t3 +wait/lock/table/sql/handler 28 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 16 2 16 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 8 2 6 2 0 6 0 +TABLE test t2 NULL 34 30 4 30 4 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 10 2 8 2 0 8 0 +TABLE test t3 NULL 50 44 6 44 6 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 14 2 12 2 0 12 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 26 18 8 18 2 6 0 +TABLE test t2 44 32 12 32 4 8 0 +TABLE test t3 74 56 18 56 6 12 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 24 17 7 0 0 0 0 17 0 7 +TABLE test t2 26 17 9 0 0 0 0 17 0 9 +TABLE test t3 28 17 11 0 0 0 0 17 0 11 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 50 +TABLE test t2 70 +TABLE test t3 102 +"================== con3 disconnected ==================" +"================== Step 15 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username event_name count_star +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 36 +user2 localhost wait/io/table/sql/handler 14 +user2 localhost wait/lock/table/sql/handler 6 +user3 localhost wait/io/table/sql/handler 70 +user3 localhost wait/lock/table/sql/handler 30 +user4 localhost wait/io/table/sql/handler 28 +user4 localhost wait/lock/table/sql/handler 6 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 36 +user2 wait/io/table/sql/handler 14 +user2 wait/lock/table/sql/handler 6 +user3 wait/io/table/sql/handler 70 +user3 wait/lock/table/sql/handler 30 +user4 wait/io/table/sql/handler 28 +user4 wait/lock/table/sql/handler 6 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 144 +localhost wait/lock/table/sql/handler 78 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 144 +wait/lock/table/sql/handler 78 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 26 TABLE test t1 +wait/lock/table/sql/handler 24 TABLE test t1 +wait/io/table/sql/handler 44 TABLE test t2 +wait/lock/table/sql/handler 26 TABLE test t2 +wait/io/table/sql/handler 74 TABLE test t3 +wait/lock/table/sql/handler 28 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 16 2 16 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 8 2 6 2 0 6 0 +TABLE test t2 NULL 34 30 4 30 4 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 10 2 8 2 0 8 0 +TABLE test t3 NULL 50 44 6 44 6 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 14 2 12 2 0 12 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 26 18 8 18 2 6 0 +TABLE test t2 44 32 12 32 4 8 0 +TABLE test t3 74 56 18 56 6 12 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 24 17 7 0 0 0 0 17 0 7 +TABLE test t2 26 17 9 0 0 0 0 17 0 9 +TABLE test t3 28 17 11 0 0 0 0 17 0 11 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 50 +TABLE test t2 70 +TABLE test t3 102 +"================== con4 disconnected ==================" +"================== Step 16 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 36 +user2 localhost wait/io/table/sql/handler 14 +user2 localhost wait/lock/table/sql/handler 6 +user3 localhost wait/io/table/sql/handler 70 +user3 localhost wait/lock/table/sql/handler 30 +user4 localhost wait/io/table/sql/handler 28 +user4 localhost wait/lock/table/sql/handler 6 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 36 +user2 wait/io/table/sql/handler 14 +user2 wait/lock/table/sql/handler 6 +user3 wait/io/table/sql/handler 70 +user3 wait/lock/table/sql/handler 30 +user4 wait/io/table/sql/handler 28 +user4 wait/lock/table/sql/handler 6 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 144 +localhost wait/lock/table/sql/handler 78 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 144 +wait/lock/table/sql/handler 78 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 26 TABLE test t1 +wait/lock/table/sql/handler 24 TABLE test t1 +wait/io/table/sql/handler 44 TABLE test t2 +wait/lock/table/sql/handler 26 TABLE test t2 +wait/io/table/sql/handler 74 TABLE test t3 +wait/lock/table/sql/handler 28 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 16 2 16 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 8 2 6 2 0 6 0 +TABLE test t2 NULL 34 30 4 30 4 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 10 2 8 2 0 8 0 +TABLE test t3 NULL 50 44 6 44 6 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 14 2 12 2 0 12 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 26 18 8 18 2 6 0 +TABLE test t2 44 32 12 32 4 8 0 +TABLE test t3 74 56 18 56 6 12 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 24 17 7 0 0 0 0 17 0 7 +TABLE test t2 26 17 9 0 0 0 0 17 0 9 +TABLE test t3 28 17 11 0 0 0 0 17 0 11 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 50 +TABLE test t2 70 +TABLE test t3 102 +truncate performance_schema.events_waits_summary_by_thread_by_event_name; +"================== BY_THREAD truncated ==================" +"================== Step 17 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 36 +user2 localhost wait/io/table/sql/handler 14 +user2 localhost wait/lock/table/sql/handler 6 +user3 localhost wait/io/table/sql/handler 70 +user3 localhost wait/lock/table/sql/handler 30 +user4 localhost wait/io/table/sql/handler 28 +user4 localhost wait/lock/table/sql/handler 6 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 36 +user2 wait/io/table/sql/handler 14 +user2 wait/lock/table/sql/handler 6 +user3 wait/io/table/sql/handler 70 +user3 wait/lock/table/sql/handler 30 +user4 wait/io/table/sql/handler 28 +user4 wait/lock/table/sql/handler 6 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 144 +localhost wait/lock/table/sql/handler 78 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 144 +wait/lock/table/sql/handler 78 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 26 TABLE test t1 +wait/lock/table/sql/handler 24 TABLE test t1 +wait/io/table/sql/handler 44 TABLE test t2 +wait/lock/table/sql/handler 26 TABLE test t2 +wait/io/table/sql/handler 74 TABLE test t3 +wait/lock/table/sql/handler 28 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 16 2 16 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 8 2 6 2 0 6 0 +TABLE test t2 NULL 34 30 4 30 4 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 10 2 8 2 0 8 0 +TABLE test t3 NULL 50 44 6 44 6 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 14 2 12 2 0 12 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 26 18 8 18 2 6 0 +TABLE test t2 44 32 12 32 4 8 0 +TABLE test t3 74 56 18 56 6 12 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 24 17 7 0 0 0 0 17 0 7 +TABLE test t2 26 17 9 0 0 0 0 17 0 9 +TABLE test t3 28 17 11 0 0 0 0 17 0 11 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 50 +TABLE test t2 70 +TABLE test t3 102 +truncate performance_schema.events_waits_summary_by_account_by_event_name; +"================== BY_ACCOUNT truncated ==================" +"================== Step 18 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 0 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 36 +user2 wait/io/table/sql/handler 14 +user2 wait/lock/table/sql/handler 6 +user3 wait/io/table/sql/handler 70 +user3 wait/lock/table/sql/handler 30 +user4 wait/io/table/sql/handler 28 +user4 wait/lock/table/sql/handler 6 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 144 +localhost wait/lock/table/sql/handler 78 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 144 +wait/lock/table/sql/handler 78 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 26 TABLE test t1 +wait/lock/table/sql/handler 24 TABLE test t1 +wait/io/table/sql/handler 44 TABLE test t2 +wait/lock/table/sql/handler 26 TABLE test t2 +wait/io/table/sql/handler 74 TABLE test t3 +wait/lock/table/sql/handler 28 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 16 2 16 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 8 2 6 2 0 6 0 +TABLE test t2 NULL 34 30 4 30 4 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 10 2 8 2 0 8 0 +TABLE test t3 NULL 50 44 6 44 6 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 14 2 12 2 0 12 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 26 18 8 18 2 6 0 +TABLE test t2 44 32 12 32 4 8 0 +TABLE test t3 74 56 18 56 6 12 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 24 17 7 0 0 0 0 17 0 7 +TABLE test t2 26 17 9 0 0 0 0 17 0 9 +TABLE test t3 28 17 11 0 0 0 0 17 0 11 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 50 +TABLE test t2 70 +TABLE test t3 102 +truncate performance_schema.events_waits_summary_by_user_by_event_name; +"================== BY_USER truncated ==================" +"================== Step 19 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 0 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 144 +localhost wait/lock/table/sql/handler 78 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 144 +wait/lock/table/sql/handler 78 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 26 TABLE test t1 +wait/lock/table/sql/handler 24 TABLE test t1 +wait/io/table/sql/handler 44 TABLE test t2 +wait/lock/table/sql/handler 26 TABLE test t2 +wait/io/table/sql/handler 74 TABLE test t3 +wait/lock/table/sql/handler 28 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 16 2 16 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 8 2 6 2 0 6 0 +TABLE test t2 NULL 34 30 4 30 4 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 10 2 8 2 0 8 0 +TABLE test t3 NULL 50 44 6 44 6 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 14 2 12 2 0 12 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 26 18 8 18 2 6 0 +TABLE test t2 44 32 12 32 4 8 0 +TABLE test t3 74 56 18 56 6 12 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 24 17 7 0 0 0 0 17 0 7 +TABLE test t2 26 17 9 0 0 0 0 17 0 9 +TABLE test t3 28 17 11 0 0 0 0 17 0 11 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 50 +TABLE test t2 70 +TABLE test t3 102 +truncate performance_schema.events_waits_summary_by_host_by_event_name; +"================== BY_HOST truncated ==================" +"================== Step 21 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 0 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 144 +wait/lock/table/sql/handler 78 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 26 TABLE test t1 +wait/lock/table/sql/handler 24 TABLE test t1 +wait/io/table/sql/handler 44 TABLE test t2 +wait/lock/table/sql/handler 26 TABLE test t2 +wait/io/table/sql/handler 74 TABLE test t3 +wait/lock/table/sql/handler 28 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 16 2 16 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 8 2 6 2 0 6 0 +TABLE test t2 NULL 34 30 4 30 4 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 10 2 8 2 0 8 0 +TABLE test t3 NULL 50 44 6 44 6 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 14 2 12 2 0 12 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 26 18 8 18 2 6 0 +TABLE test t2 44 32 12 32 4 8 0 +TABLE test t3 74 56 18 56 6 12 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 24 17 7 0 0 0 0 17 0 7 +TABLE test t2 26 17 9 0 0 0 0 17 0 9 +TABLE test t3 28 17 11 0 0 0 0 17 0 11 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 50 +TABLE test t2 70 +TABLE test t3 102 +truncate performance_schema.events_waits_summary_global_by_event_name; +"================== GLOBAL truncated ==================" +"================== Step 21 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 0 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 0 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 26 TABLE test t1 +wait/lock/table/sql/handler 24 TABLE test t1 +wait/io/table/sql/handler 44 TABLE test t2 +wait/lock/table/sql/handler 26 TABLE test t2 +wait/io/table/sql/handler 74 TABLE test t3 +wait/lock/table/sql/handler 28 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 0 0 0 0 0 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 0 0 0 0 0 0 0 +TABLE test t2 NULL 0 0 0 0 0 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 0 0 0 0 0 0 0 +TABLE test t3 index_b 0 0 0 0 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 0 0 0 0 0 0 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 0 +TABLE test t2 0 +TABLE test t3 0 +show global status like "performance_schema%table%_lost"; +Variable_name Value +Performance_schema_table_handles_lost 0 +Performance_schema_table_instances_lost 0 +Performance_schema_table_lock_stat_lost 0 diff --git a/mysql-test/suite/table_aggregate_hist_4u_2t.result-pq b/mysql-test/suite/table_aggregate_hist_4u_2t.result-pq new file mode 100644 index 000000000000..9f5a25e3fda6 --- /dev/null +++ b/mysql-test/suite/table_aggregate_hist_4u_2t.result-pq @@ -0,0 +1,1800 @@ +delete from performance_schema.setup_objects +where object_name='t2'; +select * from performance_schema.setup_actors +order by USER, HOST, `ROLE`; +HOST USER ROLE ENABLED HISTORY +localhost user1 % YES YES +localhost user2 % YES YES +localhost user3 % YES YES +localhost user4 % YES YES +select * from performance_schema.setup_objects +order by object_type, object_schema, object_name; +OBJECT_TYPE OBJECT_SCHEMA OBJECT_NAME ENABLED TIMED +TABLE test t1 YES YES +TABLE test t3 YES NO +select * from performance_schema.setup_consumers; +NAME ENABLED +events_stages_current YES +events_stages_history YES +events_stages_history_long YES +events_statements_current YES +events_statements_history YES +events_statements_history_long YES +events_transactions_current YES +events_transactions_history YES +events_transactions_history_long YES +events_waits_current YES +events_waits_history YES +events_waits_history_long YES +global_instrumentation YES +thread_instrumentation YES +statements_digest YES +flush tables; +truncate performance_schema.objects_summary_global_by_type; +truncate performance_schema.table_io_waits_summary_by_index_usage; +truncate performance_schema.table_io_waits_summary_by_table; +truncate performance_schema.table_lock_waits_summary_by_table; +truncate performance_schema.events_waits_summary_by_thread_by_event_name; +truncate performance_schema.events_waits_summary_by_account_by_event_name; +truncate performance_schema.events_waits_summary_by_user_by_event_name; +truncate performance_schema.events_waits_summary_by_host_by_event_name; +truncate performance_schema.events_waits_summary_global_by_event_name; +truncate performance_schema.events_waits_history_long; +show global variables like "performance_schema%table%"; +Variable_name Value +performance_schema_max_table_handles -1 +performance_schema_max_table_instances -1 +performance_schema_max_table_lock_stat -1 +show global status like "performance_schema%table%_lost"; +Variable_name Value +Performance_schema_table_handles_lost 0 +Performance_schema_table_instances_lost 0 +Performance_schema_table_lock_stat_lost 0 +"================== Step 1 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +execute dump_waits_user; +user event_name count_star +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 0 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 0 0 0 0 0 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 index_b 0 0 0 0 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 0 0 0 0 0 0 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 0 +TABLE test t2 0 +TABLE test t3 0 +select concat(current_user(), " is connected") as status; +status +user1@localhost is connected +"================== Step 2 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 0 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 0 0 0 0 0 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 index_b 0 0 0 0 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 0 0 0 0 0 0 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 0 +TABLE test t2 0 +TABLE test t3 0 +insert into test.t1 set a=101, b=1, c=1; +insert into test.t2 set a=102, b=2, c=2; +insert into test.t2 set a=103, b=3, c=3; +insert into test.t3 set a=104, b=4, c=4; +insert into test.t3 set a=105, b=5, c=5; +insert into test.t3 set a=106, b=6, c=6; +select * from test.t1; +a b c d +101 1 1 0 +select * from test.t2; +a b c d +102 2 2 0 +103 3 3 0 +select * from test.t3; +a b c d +104 4 4 0 +105 5 5 0 +106 6 6 0 +update test.t1 set d=d+1; +update test.t2 set d=d+1; +update test.t3 set d=d+1; +update test.t1 set d=d+1 where a=101; +update test.t2 set d=d+1 where a=101; +update test.t3 set d=d+1 where a=101; +select * from test.t1 force index(index_b) where b=5; +a b c d +select * from test.t2 force index(index_b) where b=5; +a b c d +select * from test.t3 force index(index_b) where b=5; +a b c d +105 5 5 1 +"================== con1 marker ==================" +"================== Step 3-A ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 17 +user1 wait/lock/table/sql/handler 16 +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 20 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 20 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 22 +localhost wait/lock/table/sql/handler 20 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 22 +wait/lock/table/sql/handler 20 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 7 TABLE test t1 +wait/lock/table/sql/handler 9 TABLE test t1 +wait/io/table/sql/handler 15 TABLE test t3 +wait/lock/table/sql/handler 11 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 4 3 1 3 1 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 3 1 2 1 0 2 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 10 7 3 7 3 0 0 +TABLE test t3 index_b 1 1 0 1 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 4 1 3 1 0 3 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 7 4 3 4 1 2 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 15 9 6 9 3 3 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 9 6 3 0 0 0 0 6 0 3 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 11 6 5 0 0 0 0 6 0 5 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 16 +TABLE test t2 0 +TABLE test t3 26 +flush tables; +"================== con1 FLUSH ==================" +"================== Step 3-B ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 17 +user1 wait/lock/table/sql/handler 16 +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 20 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 20 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 22 +localhost wait/lock/table/sql/handler 20 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 22 +wait/lock/table/sql/handler 20 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 7 TABLE test t1 +wait/lock/table/sql/handler 9 TABLE test t1 +wait/io/table/sql/handler 15 TABLE test t3 +wait/lock/table/sql/handler 11 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 4 3 1 3 1 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 3 1 2 1 0 2 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 10 7 3 7 3 0 0 +TABLE test t3 index_b 1 1 0 1 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 4 1 3 1 0 3 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 7 4 3 4 1 2 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 15 9 6 9 3 3 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 9 6 3 0 0 0 0 6 0 3 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 11 6 5 0 0 0 0 6 0 5 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 16 +TABLE test t2 0 +TABLE test t3 26 +select concat(current_user(), " is connected") as status; +status +user2@localhost is connected +"================== Step 4 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 17 +user1 wait/lock/table/sql/handler 16 +username event_name count_star +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 20 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 20 +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 22 +localhost wait/lock/table/sql/handler 20 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 22 +wait/lock/table/sql/handler 20 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 7 TABLE test t1 +wait/lock/table/sql/handler 9 TABLE test t1 +wait/io/table/sql/handler 15 TABLE test t3 +wait/lock/table/sql/handler 11 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 4 3 1 3 1 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 3 1 2 1 0 2 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 10 7 3 7 3 0 0 +TABLE test t3 index_b 1 1 0 1 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 4 1 3 1 0 3 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 7 4 3 4 1 2 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 15 9 6 9 3 3 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 9 6 3 0 0 0 0 6 0 3 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 11 6 5 0 0 0 0 6 0 5 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 16 +TABLE test t2 0 +TABLE test t3 26 +insert into test.t1 set a=201, b=1, c=1; +insert into test.t2 set a=202, b=2, c=2; +insert into test.t2 set a=203, b=3, c=3; +insert into test.t3 set a=204, b=4, c=4; +insert into test.t3 set a=205, b=5, c=5; +insert into test.t3 set a=206, b=6, c=6; +select * from test.t1; +a b c d +101 1 1 2 +201 1 1 0 +select * from test.t2; +a b c d +102 2 2 1 +103 3 3 1 +202 2 2 0 +203 3 3 0 +select * from test.t3; +a b c d +104 4 4 1 +105 5 5 1 +106 6 6 1 +204 4 4 0 +205 5 5 0 +206 6 6 0 +update test.t1 set d=d+1; +update test.t2 set d=d+1; +update test.t3 set d=d+1; +update test.t1 set d=d+1 where a=201; +update test.t2 set d=d+1 where a=201; +update test.t3 set d=d+1 where a=201; +select * from test.t1 force index(index_b) where b=5; +a b c d +select * from test.t2 force index(index_b) where b=5; +a b c d +select * from test.t3 force index(index_b) where b=5; +a b c d +105 5 5 2 +205 5 5 1 +"================== con2 marker ==================" +"================== Step 5 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 17 +user1 wait/lock/table/sql/handler 16 +username event_name count_star +user2 wait/io/table/sql/handler 25 +user2 wait/lock/table/sql/handler 16 +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 20 +user2 localhost wait/io/table/sql/handler 35 +user2 localhost wait/lock/table/sql/handler 20 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 20 +user2 wait/io/table/sql/handler 35 +user2 wait/lock/table/sql/handler 20 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 57 +localhost wait/lock/table/sql/handler 40 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 57 +wait/lock/table/sql/handler 40 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 17 TABLE test t1 +wait/lock/table/sql/handler 18 TABLE test t1 +wait/io/table/sql/handler 40 TABLE test t3 +wait/lock/table/sql/handler 22 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 10 8 2 8 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 7 2 5 2 0 5 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 26 20 6 20 6 0 0 +TABLE test t3 index_b 3 3 0 3 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 11 2 9 2 0 9 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 17 10 7 10 2 5 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 40 25 15 25 6 9 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 18 12 6 0 0 0 0 12 0 6 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 22 12 10 0 0 0 0 12 0 10 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 35 +TABLE test t2 0 +TABLE test t3 62 +select concat(current_user(), " is connected") as status; +status +user3@localhost is connected +"================== Step 6 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 17 +user1 wait/lock/table/sql/handler 16 +username event_name count_star +user2 wait/io/table/sql/handler 25 +user2 wait/lock/table/sql/handler 16 +username event_name count_star +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 20 +user2 localhost wait/io/table/sql/handler 35 +user2 localhost wait/lock/table/sql/handler 20 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 20 +user2 wait/io/table/sql/handler 35 +user2 wait/lock/table/sql/handler 20 +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 57 +localhost wait/lock/table/sql/handler 40 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 57 +wait/lock/table/sql/handler 40 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 17 TABLE test t1 +wait/lock/table/sql/handler 18 TABLE test t1 +wait/io/table/sql/handler 40 TABLE test t3 +wait/lock/table/sql/handler 22 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 10 8 2 8 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 7 2 5 2 0 5 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 26 20 6 20 6 0 0 +TABLE test t3 index_b 3 3 0 3 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 11 2 9 2 0 9 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 17 10 7 10 2 5 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 40 25 15 25 6 9 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 18 12 6 0 0 0 0 12 0 6 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 22 12 10 0 0 0 0 12 0 10 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 35 +TABLE test t2 0 +TABLE test t3 62 +insert into test.t1 set a=301, b=1, c=1; +insert into test.t2 set a=302, b=2, c=2; +insert into test.t2 set a=303, b=3, c=3; +insert into test.t3 set a=304, b=4, c=4; +insert into test.t3 set a=305, b=5, c=5; +insert into test.t3 set a=306, b=6, c=6; +select * from test.t1; +a b c d +101 1 1 3 +201 1 1 2 +301 1 1 0 +select * from test.t2; +a b c d +102 2 2 2 +103 3 3 2 +202 2 2 1 +203 3 3 1 +302 2 2 0 +303 3 3 0 +select * from test.t3; +a b c d +104 4 4 2 +105 5 5 2 +106 6 6 2 +204 4 4 1 +205 5 5 1 +206 6 6 1 +304 4 4 0 +305 5 5 0 +306 6 6 0 +update test.t1 set d=d+1; +update test.t2 set d=d+1; +update test.t3 set d=d+1; +update test.t1 set d=d+1 where a=301; +update test.t2 set d=d+1 where a=301; +update test.t3 set d=d+1 where a=301; +select * from test.t1 force index(index_b) where b=5; +a b c d +select * from test.t2 force index(index_b) where b=5; +a b c d +select * from test.t3 force index(index_b) where b=5; +a b c d +105 5 5 3 +205 5 5 2 +305 5 5 1 +"================== con3 marker ==================" +"================== Step 7 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 17 +user1 wait/lock/table/sql/handler 16 +username event_name count_star +user2 wait/io/table/sql/handler 25 +user2 wait/lock/table/sql/handler 16 +username event_name count_star +user3 wait/io/table/sql/handler 33 +user3 wait/lock/table/sql/handler 16 +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 20 +user2 localhost wait/io/table/sql/handler 35 +user2 localhost wait/lock/table/sql/handler 20 +user3 localhost wait/io/table/sql/handler 48 +user3 localhost wait/lock/table/sql/handler 20 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 20 +user2 wait/io/table/sql/handler 35 +user2 wait/lock/table/sql/handler 20 +user3 wait/io/table/sql/handler 48 +user3 wait/lock/table/sql/handler 20 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 105 +localhost wait/lock/table/sql/handler 60 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 105 +wait/lock/table/sql/handler 60 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 30 TABLE test t1 +wait/lock/table/sql/handler 27 TABLE test t1 +wait/io/table/sql/handler 75 TABLE test t3 +wait/lock/table/sql/handler 33 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 15 3 15 3 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 12 3 9 3 0 9 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 48 39 9 39 9 0 0 +TABLE test t3 index_b 6 6 0 6 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 21 3 18 3 0 18 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 30 18 12 18 3 9 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 75 48 27 48 9 18 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 27 18 9 0 0 0 0 18 0 9 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 33 18 15 0 0 0 0 18 0 15 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 57 +TABLE test t2 0 +TABLE test t3 108 +select concat(current_user(), " is connected") as status; +status +user4@localhost is connected +"================== Step 8 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 17 +user1 wait/lock/table/sql/handler 16 +username event_name count_star +user2 wait/io/table/sql/handler 25 +user2 wait/lock/table/sql/handler 16 +username event_name count_star +user3 wait/io/table/sql/handler 33 +user3 wait/lock/table/sql/handler 16 +username event_name count_star +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 20 +user2 localhost wait/io/table/sql/handler 35 +user2 localhost wait/lock/table/sql/handler 20 +user3 localhost wait/io/table/sql/handler 48 +user3 localhost wait/lock/table/sql/handler 20 +user4 localhost wait/io/table/sql/handler 0 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 20 +user2 wait/io/table/sql/handler 35 +user2 wait/lock/table/sql/handler 20 +user3 wait/io/table/sql/handler 48 +user3 wait/lock/table/sql/handler 20 +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 105 +localhost wait/lock/table/sql/handler 60 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 105 +wait/lock/table/sql/handler 60 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 30 TABLE test t1 +wait/lock/table/sql/handler 27 TABLE test t1 +wait/io/table/sql/handler 75 TABLE test t3 +wait/lock/table/sql/handler 33 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 15 3 15 3 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 12 3 9 3 0 9 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 48 39 9 39 9 0 0 +TABLE test t3 index_b 6 6 0 6 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 21 3 18 3 0 18 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 30 18 12 18 3 9 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 75 48 27 48 9 18 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 27 18 9 0 0 0 0 18 0 9 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 33 18 15 0 0 0 0 18 0 15 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 57 +TABLE test t2 0 +TABLE test t3 108 +insert into test.t1 set a=401, b=1, c=1; +insert into test.t2 set a=402, b=2, c=2; +insert into test.t2 set a=403, b=3, c=3; +insert into test.t3 set a=404, b=4, c=4; +insert into test.t3 set a=405, b=5, c=5; +insert into test.t3 set a=406, b=6, c=6; +select * from test.t1; +a b c d +101 1 1 4 +201 1 1 3 +301 1 1 2 +401 1 1 0 +select * from test.t2; +a b c d +102 2 2 3 +103 3 3 3 +202 2 2 2 +203 3 3 2 +302 2 2 1 +303 3 3 1 +402 2 2 0 +403 3 3 0 +select * from test.t3; +a b c d +104 4 4 3 +105 5 5 3 +106 6 6 3 +204 4 4 2 +205 5 5 2 +206 6 6 2 +304 4 4 1 +305 5 5 1 +306 6 6 1 +404 4 4 0 +405 5 5 0 +406 6 6 0 +update test.t1 set d=d+1; +update test.t2 set d=d+1; +update test.t3 set d=d+1; +update test.t1 set d=d+1 where a=401; +update test.t2 set d=d+1 where a=401; +update test.t3 set d=d+1 where a=401; +select * from test.t1 force index(index_b) where b=5; +a b c d +select * from test.t2 force index(index_b) where b=5; +a b c d +select * from test.t3 force index(index_b) where b=5; +a b c d +105 5 5 4 +205 5 5 3 +305 5 5 2 +405 5 5 1 +"================== con4 marker ==================" +"================== Step 9 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 17 +user1 wait/lock/table/sql/handler 16 +username event_name count_star +user2 wait/io/table/sql/handler 25 +user2 wait/lock/table/sql/handler 16 +username event_name count_star +user3 wait/io/table/sql/handler 33 +user3 wait/lock/table/sql/handler 16 +username event_name count_star +user4 wait/io/table/sql/handler 41 +user4 wait/lock/table/sql/handler 16 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 20 +user2 localhost wait/io/table/sql/handler 35 +user2 localhost wait/lock/table/sql/handler 20 +user3 localhost wait/io/table/sql/handler 48 +user3 localhost wait/lock/table/sql/handler 20 +user4 localhost wait/io/table/sql/handler 61 +user4 localhost wait/lock/table/sql/handler 20 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 20 +user2 wait/io/table/sql/handler 35 +user2 wait/lock/table/sql/handler 20 +user3 wait/io/table/sql/handler 48 +user3 wait/lock/table/sql/handler 20 +user4 wait/io/table/sql/handler 61 +user4 wait/lock/table/sql/handler 20 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 166 +localhost wait/lock/table/sql/handler 80 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 166 +wait/lock/table/sql/handler 80 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 46 TABLE test t1 +wait/lock/table/sql/handler 36 TABLE test t1 +wait/io/table/sql/handler 120 TABLE test t3 +wait/lock/table/sql/handler 44 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 36 24 12 0 0 0 0 24 0 12 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 44 24 20 0 0 0 0 24 0 20 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 82 +TABLE test t2 0 +TABLE test t3 164 +lock tables test.t1 read, test.t2 read, test.t3 read; +unlock tables; +lock tables test.t1 write, test.t2 write, test.t3 write; +unlock tables; +"================== con1 marker ==================" +"================== Step 10 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 17 +user1 wait/lock/table/sql/handler 20 +username event_name count_star +user2 wait/io/table/sql/handler 25 +user2 wait/lock/table/sql/handler 16 +username event_name count_star +user3 wait/io/table/sql/handler 33 +user3 wait/lock/table/sql/handler 16 +username event_name count_star +user4 wait/io/table/sql/handler 41 +user4 wait/lock/table/sql/handler 16 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 24 +user2 localhost wait/io/table/sql/handler 35 +user2 localhost wait/lock/table/sql/handler 20 +user3 localhost wait/io/table/sql/handler 48 +user3 localhost wait/lock/table/sql/handler 20 +user4 localhost wait/io/table/sql/handler 61 +user4 localhost wait/lock/table/sql/handler 20 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 24 +user2 wait/io/table/sql/handler 35 +user2 wait/lock/table/sql/handler 20 +user3 wait/io/table/sql/handler 48 +user3 wait/lock/table/sql/handler 20 +user4 wait/io/table/sql/handler 61 +user4 wait/lock/table/sql/handler 20 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 166 +localhost wait/lock/table/sql/handler 84 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 166 +wait/lock/table/sql/handler 84 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 46 TABLE test t1 +wait/lock/table/sql/handler 38 TABLE test t1 +wait/io/table/sql/handler 120 TABLE test t3 +wait/lock/table/sql/handler 46 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 38 25 13 0 0 0 0 25 0 13 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 46 25 21 0 0 0 0 25 0 21 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 84 +TABLE test t2 0 +TABLE test t3 166 +flush tables; +"================== flush marker ==================" +"================== Step 11 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 17 +user1 wait/lock/table/sql/handler 20 +username event_name count_star +user2 wait/io/table/sql/handler 25 +user2 wait/lock/table/sql/handler 16 +username event_name count_star +user3 wait/io/table/sql/handler 33 +user3 wait/lock/table/sql/handler 16 +username event_name count_star +user4 wait/io/table/sql/handler 41 +user4 wait/lock/table/sql/handler 16 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 24 +user2 localhost wait/io/table/sql/handler 35 +user2 localhost wait/lock/table/sql/handler 20 +user3 localhost wait/io/table/sql/handler 48 +user3 localhost wait/lock/table/sql/handler 20 +user4 localhost wait/io/table/sql/handler 61 +user4 localhost wait/lock/table/sql/handler 20 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 24 +user2 wait/io/table/sql/handler 35 +user2 wait/lock/table/sql/handler 20 +user3 wait/io/table/sql/handler 48 +user3 wait/lock/table/sql/handler 20 +user4 wait/io/table/sql/handler 61 +user4 wait/lock/table/sql/handler 20 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 166 +localhost wait/lock/table/sql/handler 84 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 166 +wait/lock/table/sql/handler 84 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 46 TABLE test t1 +wait/lock/table/sql/handler 38 TABLE test t1 +wait/io/table/sql/handler 120 TABLE test t3 +wait/lock/table/sql/handler 46 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 38 25 13 0 0 0 0 25 0 13 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 46 25 21 0 0 0 0 25 0 21 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 84 +TABLE test t2 0 +TABLE test t3 166 +set global read_only=1; +set global read_only=0; +"================== global read_only marker ==================" +"================== Step 12 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 17 +user1 wait/lock/table/sql/handler 20 +username event_name count_star +user2 wait/io/table/sql/handler 25 +user2 wait/lock/table/sql/handler 16 +username event_name count_star +user3 wait/io/table/sql/handler 33 +user3 wait/lock/table/sql/handler 16 +username event_name count_star +user4 wait/io/table/sql/handler 41 +user4 wait/lock/table/sql/handler 16 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 24 +user2 localhost wait/io/table/sql/handler 35 +user2 localhost wait/lock/table/sql/handler 20 +user3 localhost wait/io/table/sql/handler 48 +user3 localhost wait/lock/table/sql/handler 20 +user4 localhost wait/io/table/sql/handler 61 +user4 localhost wait/lock/table/sql/handler 20 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 24 +user2 wait/io/table/sql/handler 35 +user2 wait/lock/table/sql/handler 20 +user3 wait/io/table/sql/handler 48 +user3 wait/lock/table/sql/handler 20 +user4 wait/io/table/sql/handler 61 +user4 wait/lock/table/sql/handler 20 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 166 +localhost wait/lock/table/sql/handler 84 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 166 +wait/lock/table/sql/handler 84 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 46 TABLE test t1 +wait/lock/table/sql/handler 38 TABLE test t1 +wait/io/table/sql/handler 120 TABLE test t3 +wait/lock/table/sql/handler 46 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 38 25 13 0 0 0 0 25 0 13 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 46 25 21 0 0 0 0 25 0 21 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 84 +TABLE test t2 0 +TABLE test t3 166 +"================== con1 disconnected ==================" +"================== Step 13 ==================" +call dump_thread(); +username status +user1 not found +username event_name count_star +user2 wait/io/table/sql/handler 25 +user2 wait/lock/table/sql/handler 16 +username event_name count_star +user3 wait/io/table/sql/handler 33 +user3 wait/lock/table/sql/handler 16 +username event_name count_star +user4 wait/io/table/sql/handler 41 +user4 wait/lock/table/sql/handler 16 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 24 +user2 localhost wait/io/table/sql/handler 35 +user2 localhost wait/lock/table/sql/handler 20 +user3 localhost wait/io/table/sql/handler 48 +user3 localhost wait/lock/table/sql/handler 20 +user4 localhost wait/io/table/sql/handler 61 +user4 localhost wait/lock/table/sql/handler 20 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 24 +user2 wait/io/table/sql/handler 35 +user2 wait/lock/table/sql/handler 20 +user3 wait/io/table/sql/handler 48 +user3 wait/lock/table/sql/handler 20 +user4 wait/io/table/sql/handler 61 +user4 wait/lock/table/sql/handler 20 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 166 +localhost wait/lock/table/sql/handler 84 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 166 +wait/lock/table/sql/handler 84 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 46 TABLE test t1 +wait/lock/table/sql/handler 38 TABLE test t1 +wait/io/table/sql/handler 120 TABLE test t3 +wait/lock/table/sql/handler 46 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 38 25 13 0 0 0 0 25 0 13 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 46 25 21 0 0 0 0 25 0 21 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 84 +TABLE test t2 0 +TABLE test t3 166 +"================== con2 disconnected ==================" +"================== Step 14 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username event_name count_star +user3 wait/io/table/sql/handler 33 +user3 wait/lock/table/sql/handler 16 +username event_name count_star +user4 wait/io/table/sql/handler 41 +user4 wait/lock/table/sql/handler 16 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 24 +user2 localhost wait/io/table/sql/handler 35 +user2 localhost wait/lock/table/sql/handler 20 +user3 localhost wait/io/table/sql/handler 48 +user3 localhost wait/lock/table/sql/handler 20 +user4 localhost wait/io/table/sql/handler 61 +user4 localhost wait/lock/table/sql/handler 20 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 24 +user2 wait/io/table/sql/handler 35 +user2 wait/lock/table/sql/handler 20 +user3 wait/io/table/sql/handler 48 +user3 wait/lock/table/sql/handler 20 +user4 wait/io/table/sql/handler 61 +user4 wait/lock/table/sql/handler 20 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 166 +localhost wait/lock/table/sql/handler 84 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 166 +wait/lock/table/sql/handler 84 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 46 TABLE test t1 +wait/lock/table/sql/handler 38 TABLE test t1 +wait/io/table/sql/handler 120 TABLE test t3 +wait/lock/table/sql/handler 46 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 38 25 13 0 0 0 0 25 0 13 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 46 25 21 0 0 0 0 25 0 21 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 84 +TABLE test t2 0 +TABLE test t3 166 +"================== con3 disconnected ==================" +"================== Step 15 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username event_name count_star +user4 wait/io/table/sql/handler 41 +user4 wait/lock/table/sql/handler 16 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 24 +user2 localhost wait/io/table/sql/handler 35 +user2 localhost wait/lock/table/sql/handler 20 +user3 localhost wait/io/table/sql/handler 48 +user3 localhost wait/lock/table/sql/handler 20 +user4 localhost wait/io/table/sql/handler 61 +user4 localhost wait/lock/table/sql/handler 20 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 24 +user2 wait/io/table/sql/handler 35 +user2 wait/lock/table/sql/handler 20 +user3 wait/io/table/sql/handler 48 +user3 wait/lock/table/sql/handler 20 +user4 wait/io/table/sql/handler 61 +user4 wait/lock/table/sql/handler 20 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 166 +localhost wait/lock/table/sql/handler 84 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 166 +wait/lock/table/sql/handler 84 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 46 TABLE test t1 +wait/lock/table/sql/handler 38 TABLE test t1 +wait/io/table/sql/handler 120 TABLE test t3 +wait/lock/table/sql/handler 46 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 38 25 13 0 0 0 0 25 0 13 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 46 25 21 0 0 0 0 25 0 21 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 84 +TABLE test t2 0 +TABLE test t3 166 +"================== con4 disconnected ==================" +"================== Step 16 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 24 +user2 localhost wait/io/table/sql/handler 35 +user2 localhost wait/lock/table/sql/handler 20 +user3 localhost wait/io/table/sql/handler 48 +user3 localhost wait/lock/table/sql/handler 20 +user4 localhost wait/io/table/sql/handler 61 +user4 localhost wait/lock/table/sql/handler 20 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 24 +user2 wait/io/table/sql/handler 35 +user2 wait/lock/table/sql/handler 20 +user3 wait/io/table/sql/handler 48 +user3 wait/lock/table/sql/handler 20 +user4 wait/io/table/sql/handler 61 +user4 wait/lock/table/sql/handler 20 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 166 +localhost wait/lock/table/sql/handler 84 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 166 +wait/lock/table/sql/handler 84 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 46 TABLE test t1 +wait/lock/table/sql/handler 38 TABLE test t1 +wait/io/table/sql/handler 120 TABLE test t3 +wait/lock/table/sql/handler 46 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 38 25 13 0 0 0 0 25 0 13 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 46 25 21 0 0 0 0 25 0 21 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 84 +TABLE test t2 0 +TABLE test t3 166 +truncate performance_schema.events_waits_summary_by_thread_by_event_name; +"================== BY_THREAD truncated ==================" +"================== Step 17 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 24 +user2 localhost wait/io/table/sql/handler 35 +user2 localhost wait/lock/table/sql/handler 20 +user3 localhost wait/io/table/sql/handler 48 +user3 localhost wait/lock/table/sql/handler 20 +user4 localhost wait/io/table/sql/handler 61 +user4 localhost wait/lock/table/sql/handler 20 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 24 +user2 wait/io/table/sql/handler 35 +user2 wait/lock/table/sql/handler 20 +user3 wait/io/table/sql/handler 48 +user3 wait/lock/table/sql/handler 20 +user4 wait/io/table/sql/handler 61 +user4 wait/lock/table/sql/handler 20 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 166 +localhost wait/lock/table/sql/handler 84 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 166 +wait/lock/table/sql/handler 84 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 46 TABLE test t1 +wait/lock/table/sql/handler 38 TABLE test t1 +wait/io/table/sql/handler 120 TABLE test t3 +wait/lock/table/sql/handler 46 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 38 25 13 0 0 0 0 25 0 13 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 46 25 21 0 0 0 0 25 0 21 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 84 +TABLE test t2 0 +TABLE test t3 166 +truncate performance_schema.events_waits_summary_by_account_by_event_name; +"================== BY_ACCOUNT truncated ==================" +"================== Step 18 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 0 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 24 +user2 wait/io/table/sql/handler 35 +user2 wait/lock/table/sql/handler 20 +user3 wait/io/table/sql/handler 48 +user3 wait/lock/table/sql/handler 20 +user4 wait/io/table/sql/handler 61 +user4 wait/lock/table/sql/handler 20 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 166 +localhost wait/lock/table/sql/handler 84 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 166 +wait/lock/table/sql/handler 84 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 46 TABLE test t1 +wait/lock/table/sql/handler 38 TABLE test t1 +wait/io/table/sql/handler 120 TABLE test t3 +wait/lock/table/sql/handler 46 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 38 25 13 0 0 0 0 25 0 13 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 46 25 21 0 0 0 0 25 0 21 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 84 +TABLE test t2 0 +TABLE test t3 166 +truncate performance_schema.events_waits_summary_by_user_by_event_name; +"================== BY_USER truncated ==================" +"================== Step 19 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 0 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 166 +localhost wait/lock/table/sql/handler 84 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 166 +wait/lock/table/sql/handler 84 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 46 TABLE test t1 +wait/lock/table/sql/handler 38 TABLE test t1 +wait/io/table/sql/handler 120 TABLE test t3 +wait/lock/table/sql/handler 46 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 38 25 13 0 0 0 0 25 0 13 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 46 25 21 0 0 0 0 25 0 21 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 84 +TABLE test t2 0 +TABLE test t3 166 +truncate performance_schema.events_waits_summary_by_host_by_event_name; +"================== BY_HOST truncated ==================" +"================== Step 21 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 0 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 166 +wait/lock/table/sql/handler 84 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 46 TABLE test t1 +wait/lock/table/sql/handler 38 TABLE test t1 +wait/io/table/sql/handler 120 TABLE test t3 +wait/lock/table/sql/handler 46 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 38 25 13 0 0 0 0 25 0 13 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 46 25 21 0 0 0 0 25 0 21 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 84 +TABLE test t2 0 +TABLE test t3 166 +truncate performance_schema.events_waits_summary_global_by_event_name; +"================== GLOBAL truncated ==================" +"================== Step 21 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 0 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 0 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 46 TABLE test t1 +wait/lock/table/sql/handler 38 TABLE test t1 +wait/io/table/sql/handler 120 TABLE test t3 +wait/lock/table/sql/handler 46 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 0 0 0 0 0 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 0 0 0 0 0 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 0 0 0 0 0 0 0 +TABLE test t3 index_b 0 0 0 0 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 0 0 0 0 0 0 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 0 +TABLE test t2 0 +TABLE test t3 0 +show global status like "performance_schema%table%_lost"; +Variable_name Value +Performance_schema_table_handles_lost 0 +Performance_schema_table_instances_lost 0 +Performance_schema_table_lock_stat_lost 0 diff --git a/mysql-test/suite/table_aggregate_hist_4u_3t.result-pq b/mysql-test/suite/table_aggregate_hist_4u_3t.result-pq new file mode 100644 index 000000000000..845d1d0f7ece --- /dev/null +++ b/mysql-test/suite/table_aggregate_hist_4u_3t.result-pq @@ -0,0 +1,1859 @@ +select * from performance_schema.setup_actors +order by USER, HOST, `ROLE`; +HOST USER ROLE ENABLED HISTORY +localhost user1 % YES YES +localhost user2 % YES YES +localhost user3 % YES YES +localhost user4 % YES YES +select * from performance_schema.setup_objects +order by object_type, object_schema, object_name; +OBJECT_TYPE OBJECT_SCHEMA OBJECT_NAME ENABLED TIMED +TABLE test t1 YES YES +TABLE test t2 YES NO +TABLE test t3 YES NO +select * from performance_schema.setup_consumers; +NAME ENABLED +events_stages_current YES +events_stages_history YES +events_stages_history_long YES +events_statements_current YES +events_statements_history YES +events_statements_history_long YES +events_transactions_current YES +events_transactions_history YES +events_transactions_history_long YES +events_waits_current YES +events_waits_history YES +events_waits_history_long YES +global_instrumentation YES +thread_instrumentation YES +statements_digest YES +flush tables; +truncate performance_schema.objects_summary_global_by_type; +truncate performance_schema.table_io_waits_summary_by_index_usage; +truncate performance_schema.table_io_waits_summary_by_table; +truncate performance_schema.table_lock_waits_summary_by_table; +truncate performance_schema.events_waits_summary_by_thread_by_event_name; +truncate performance_schema.events_waits_summary_by_account_by_event_name; +truncate performance_schema.events_waits_summary_by_user_by_event_name; +truncate performance_schema.events_waits_summary_by_host_by_event_name; +truncate performance_schema.events_waits_summary_global_by_event_name; +truncate performance_schema.events_waits_history_long; +show global variables like "performance_schema%table%"; +Variable_name Value +performance_schema_max_table_handles -1 +performance_schema_max_table_instances -1 +performance_schema_max_table_lock_stat -1 +show global status like "performance_schema%table%_lost"; +Variable_name Value +Performance_schema_table_handles_lost 0 +Performance_schema_table_instances_lost 0 +Performance_schema_table_lock_stat_lost 0 +"================== Step 1 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +execute dump_waits_user; +user event_name count_star +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 0 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 0 0 0 0 0 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 index_b 0 0 0 0 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 0 0 0 0 0 0 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 0 +TABLE test t2 0 +TABLE test t3 0 +select concat(current_user(), " is connected") as status; +status +user1@localhost is connected +"================== Step 2 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 0 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 0 0 0 0 0 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 index_b 0 0 0 0 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 0 0 0 0 0 0 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 0 +TABLE test t2 0 +TABLE test t3 0 +insert into test.t1 set a=101, b=1, c=1; +insert into test.t2 set a=102, b=2, c=2; +insert into test.t2 set a=103, b=3, c=3; +insert into test.t3 set a=104, b=4, c=4; +insert into test.t3 set a=105, b=5, c=5; +insert into test.t3 set a=106, b=6, c=6; +select * from test.t1; +a b c d +101 1 1 0 +select * from test.t2; +a b c d +102 2 2 0 +103 3 3 0 +select * from test.t3; +a b c d +104 4 4 0 +105 5 5 0 +106 6 6 0 +update test.t1 set d=d+1; +update test.t2 set d=d+1; +update test.t3 set d=d+1; +update test.t1 set d=d+1 where a=101; +update test.t2 set d=d+1 where a=101; +update test.t3 set d=d+1 where a=101; +select * from test.t1 force index(index_b) where b=5; +a b c d +select * from test.t2 force index(index_b) where b=5; +a b c d +select * from test.t3 force index(index_b) where b=5; +a b c d +105 5 5 1 +"================== con1 marker ==================" +"================== Step 3-A ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 25 +user1 wait/lock/table/sql/handler 24 +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 30 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 30 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 32 +localhost wait/lock/table/sql/handler 30 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 32 +wait/lock/table/sql/handler 30 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 7 TABLE test t1 +wait/lock/table/sql/handler 9 TABLE test t1 +wait/io/table/sql/handler 10 TABLE test t2 +wait/lock/table/sql/handler 10 TABLE test t2 +wait/io/table/sql/handler 15 TABLE test t3 +wait/lock/table/sql/handler 11 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 4 3 1 3 1 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 3 1 2 1 0 2 0 +TABLE test t2 NULL 7 5 2 5 2 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 3 1 2 1 0 2 0 +TABLE test t3 NULL 10 7 3 7 3 0 0 +TABLE test t3 index_b 1 1 0 1 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 4 1 3 1 0 3 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 7 4 3 4 1 2 0 +TABLE test t2 10 6 4 6 2 2 0 +TABLE test t3 15 9 6 9 3 3 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 9 6 3 0 0 0 0 6 0 3 +TABLE test t2 10 6 4 0 0 0 0 6 0 4 +TABLE test t3 11 6 5 0 0 0 0 6 0 5 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 16 +TABLE test t2 20 +TABLE test t3 26 +flush tables; +"================== con1 FLUSH ==================" +"================== Step 3-B ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 25 +user1 wait/lock/table/sql/handler 24 +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 30 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 30 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 32 +localhost wait/lock/table/sql/handler 30 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 32 +wait/lock/table/sql/handler 30 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 7 TABLE test t1 +wait/lock/table/sql/handler 9 TABLE test t1 +wait/io/table/sql/handler 10 TABLE test t2 +wait/lock/table/sql/handler 10 TABLE test t2 +wait/io/table/sql/handler 15 TABLE test t3 +wait/lock/table/sql/handler 11 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 4 3 1 3 1 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 3 1 2 1 0 2 0 +TABLE test t2 NULL 7 5 2 5 2 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 3 1 2 1 0 2 0 +TABLE test t3 NULL 10 7 3 7 3 0 0 +TABLE test t3 index_b 1 1 0 1 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 4 1 3 1 0 3 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 7 4 3 4 1 2 0 +TABLE test t2 10 6 4 6 2 2 0 +TABLE test t3 15 9 6 9 3 3 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 9 6 3 0 0 0 0 6 0 3 +TABLE test t2 10 6 4 0 0 0 0 6 0 4 +TABLE test t3 11 6 5 0 0 0 0 6 0 5 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 16 +TABLE test t2 20 +TABLE test t3 26 +select concat(current_user(), " is connected") as status; +status +user2@localhost is connected +"================== Step 4 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 25 +user1 wait/lock/table/sql/handler 24 +username event_name count_star +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 30 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 30 +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 32 +localhost wait/lock/table/sql/handler 30 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 32 +wait/lock/table/sql/handler 30 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 7 TABLE test t1 +wait/lock/table/sql/handler 9 TABLE test t1 +wait/io/table/sql/handler 10 TABLE test t2 +wait/lock/table/sql/handler 10 TABLE test t2 +wait/io/table/sql/handler 15 TABLE test t3 +wait/lock/table/sql/handler 11 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 4 3 1 3 1 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 3 1 2 1 0 2 0 +TABLE test t2 NULL 7 5 2 5 2 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 3 1 2 1 0 2 0 +TABLE test t3 NULL 10 7 3 7 3 0 0 +TABLE test t3 index_b 1 1 0 1 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 4 1 3 1 0 3 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 7 4 3 4 1 2 0 +TABLE test t2 10 6 4 6 2 2 0 +TABLE test t3 15 9 6 9 3 3 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 9 6 3 0 0 0 0 6 0 3 +TABLE test t2 10 6 4 0 0 0 0 6 0 4 +TABLE test t3 11 6 5 0 0 0 0 6 0 5 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 16 +TABLE test t2 20 +TABLE test t3 26 +insert into test.t1 set a=201, b=1, c=1; +insert into test.t2 set a=202, b=2, c=2; +insert into test.t2 set a=203, b=3, c=3; +insert into test.t3 set a=204, b=4, c=4; +insert into test.t3 set a=205, b=5, c=5; +insert into test.t3 set a=206, b=6, c=6; +select * from test.t1; +a b c d +101 1 1 2 +201 1 1 0 +select * from test.t2; +a b c d +102 2 2 1 +103 3 3 1 +202 2 2 0 +203 3 3 0 +select * from test.t3; +a b c d +104 4 4 1 +105 5 5 1 +106 6 6 1 +204 4 4 0 +205 5 5 0 +206 6 6 0 +update test.t1 set d=d+1; +update test.t2 set d=d+1; +update test.t3 set d=d+1; +update test.t1 set d=d+1 where a=201; +update test.t2 set d=d+1 where a=201; +update test.t3 set d=d+1 where a=201; +select * from test.t1 force index(index_b) where b=5; +a b c d +select * from test.t2 force index(index_b) where b=5; +a b c d +select * from test.t3 force index(index_b) where b=5; +a b c d +105 5 5 2 +205 5 5 1 +"================== con2 marker ==================" +"================== Step 5 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 25 +user1 wait/lock/table/sql/handler 24 +username event_name count_star +user2 wait/io/table/sql/handler 37 +user2 wait/lock/table/sql/handler 24 +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 30 +user2 localhost wait/io/table/sql/handler 51 +user2 localhost wait/lock/table/sql/handler 30 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 30 +user2 wait/io/table/sql/handler 51 +user2 wait/lock/table/sql/handler 30 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 83 +localhost wait/lock/table/sql/handler 60 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 83 +wait/lock/table/sql/handler 60 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 17 TABLE test t1 +wait/lock/table/sql/handler 18 TABLE test t1 +wait/io/table/sql/handler 26 TABLE test t2 +wait/lock/table/sql/handler 20 TABLE test t2 +wait/io/table/sql/handler 40 TABLE test t3 +wait/lock/table/sql/handler 22 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 10 8 2 8 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 7 2 5 2 0 5 0 +TABLE test t2 NULL 18 14 4 14 4 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 8 2 6 2 0 6 0 +TABLE test t3 NULL 26 20 6 20 6 0 0 +TABLE test t3 index_b 3 3 0 3 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 11 2 9 2 0 9 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 17 10 7 10 2 5 0 +TABLE test t2 26 16 10 16 4 6 0 +TABLE test t3 40 25 15 25 6 9 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 18 12 6 0 0 0 0 12 0 6 +TABLE test t2 20 12 8 0 0 0 0 12 0 8 +TABLE test t3 22 12 10 0 0 0 0 12 0 10 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 35 +TABLE test t2 46 +TABLE test t3 62 +select concat(current_user(), " is connected") as status; +status +user3@localhost is connected +"================== Step 6 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 25 +user1 wait/lock/table/sql/handler 24 +username event_name count_star +user2 wait/io/table/sql/handler 37 +user2 wait/lock/table/sql/handler 24 +username event_name count_star +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 30 +user2 localhost wait/io/table/sql/handler 51 +user2 localhost wait/lock/table/sql/handler 30 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 30 +user2 wait/io/table/sql/handler 51 +user2 wait/lock/table/sql/handler 30 +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 83 +localhost wait/lock/table/sql/handler 60 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 83 +wait/lock/table/sql/handler 60 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 17 TABLE test t1 +wait/lock/table/sql/handler 18 TABLE test t1 +wait/io/table/sql/handler 26 TABLE test t2 +wait/lock/table/sql/handler 20 TABLE test t2 +wait/io/table/sql/handler 40 TABLE test t3 +wait/lock/table/sql/handler 22 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 10 8 2 8 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 7 2 5 2 0 5 0 +TABLE test t2 NULL 18 14 4 14 4 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 8 2 6 2 0 6 0 +TABLE test t3 NULL 26 20 6 20 6 0 0 +TABLE test t3 index_b 3 3 0 3 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 11 2 9 2 0 9 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 17 10 7 10 2 5 0 +TABLE test t2 26 16 10 16 4 6 0 +TABLE test t3 40 25 15 25 6 9 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 18 12 6 0 0 0 0 12 0 6 +TABLE test t2 20 12 8 0 0 0 0 12 0 8 +TABLE test t3 22 12 10 0 0 0 0 12 0 10 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 35 +TABLE test t2 46 +TABLE test t3 62 +insert into test.t1 set a=301, b=1, c=1; +insert into test.t2 set a=302, b=2, c=2; +insert into test.t2 set a=303, b=3, c=3; +insert into test.t3 set a=304, b=4, c=4; +insert into test.t3 set a=305, b=5, c=5; +insert into test.t3 set a=306, b=6, c=6; +select * from test.t1; +a b c d +101 1 1 3 +201 1 1 2 +301 1 1 0 +select * from test.t2; +a b c d +102 2 2 2 +103 3 3 2 +202 2 2 1 +203 3 3 1 +302 2 2 0 +303 3 3 0 +select * from test.t3; +a b c d +104 4 4 2 +105 5 5 2 +106 6 6 2 +204 4 4 1 +205 5 5 1 +206 6 6 1 +304 4 4 0 +305 5 5 0 +306 6 6 0 +update test.t1 set d=d+1; +update test.t2 set d=d+1; +update test.t3 set d=d+1; +update test.t1 set d=d+1 where a=301; +update test.t2 set d=d+1 where a=301; +update test.t3 set d=d+1 where a=301; +select * from test.t1 force index(index_b) where b=5; +a b c d +select * from test.t2 force index(index_b) where b=5; +a b c d +select * from test.t3 force index(index_b) where b=5; +a b c d +105 5 5 3 +205 5 5 2 +305 5 5 1 +"================== con3 marker ==================" +"================== Step 7 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 25 +user1 wait/lock/table/sql/handler 24 +username event_name count_star +user2 wait/io/table/sql/handler 37 +user2 wait/lock/table/sql/handler 24 +username event_name count_star +user3 wait/io/table/sql/handler 49 +user3 wait/lock/table/sql/handler 24 +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 30 +user2 localhost wait/io/table/sql/handler 51 +user2 localhost wait/lock/table/sql/handler 30 +user3 localhost wait/io/table/sql/handler 70 +user3 localhost wait/lock/table/sql/handler 30 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 30 +user2 wait/io/table/sql/handler 51 +user2 wait/lock/table/sql/handler 30 +user3 wait/io/table/sql/handler 70 +user3 wait/lock/table/sql/handler 30 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 153 +localhost wait/lock/table/sql/handler 90 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 153 +wait/lock/table/sql/handler 90 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 30 TABLE test t1 +wait/lock/table/sql/handler 27 TABLE test t1 +wait/io/table/sql/handler 48 TABLE test t2 +wait/lock/table/sql/handler 30 TABLE test t2 +wait/io/table/sql/handler 75 TABLE test t3 +wait/lock/table/sql/handler 33 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 15 3 15 3 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 12 3 9 3 0 9 0 +TABLE test t2 NULL 33 27 6 27 6 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 15 3 12 3 0 12 0 +TABLE test t3 NULL 48 39 9 39 9 0 0 +TABLE test t3 index_b 6 6 0 6 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 21 3 18 3 0 18 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 30 18 12 18 3 9 0 +TABLE test t2 48 30 18 30 6 12 0 +TABLE test t3 75 48 27 48 9 18 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 27 18 9 0 0 0 0 18 0 9 +TABLE test t2 30 18 12 0 0 0 0 18 0 12 +TABLE test t3 33 18 15 0 0 0 0 18 0 15 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 57 +TABLE test t2 78 +TABLE test t3 108 +select concat(current_user(), " is connected") as status; +status +user4@localhost is connected +"================== Step 8 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 25 +user1 wait/lock/table/sql/handler 24 +username event_name count_star +user2 wait/io/table/sql/handler 37 +user2 wait/lock/table/sql/handler 24 +username event_name count_star +user3 wait/io/table/sql/handler 49 +user3 wait/lock/table/sql/handler 24 +username event_name count_star +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 30 +user2 localhost wait/io/table/sql/handler 51 +user2 localhost wait/lock/table/sql/handler 30 +user3 localhost wait/io/table/sql/handler 70 +user3 localhost wait/lock/table/sql/handler 30 +user4 localhost wait/io/table/sql/handler 0 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 30 +user2 wait/io/table/sql/handler 51 +user2 wait/lock/table/sql/handler 30 +user3 wait/io/table/sql/handler 70 +user3 wait/lock/table/sql/handler 30 +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 153 +localhost wait/lock/table/sql/handler 90 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 153 +wait/lock/table/sql/handler 90 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 30 TABLE test t1 +wait/lock/table/sql/handler 27 TABLE test t1 +wait/io/table/sql/handler 48 TABLE test t2 +wait/lock/table/sql/handler 30 TABLE test t2 +wait/io/table/sql/handler 75 TABLE test t3 +wait/lock/table/sql/handler 33 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 15 3 15 3 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 12 3 9 3 0 9 0 +TABLE test t2 NULL 33 27 6 27 6 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 15 3 12 3 0 12 0 +TABLE test t3 NULL 48 39 9 39 9 0 0 +TABLE test t3 index_b 6 6 0 6 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 21 3 18 3 0 18 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 30 18 12 18 3 9 0 +TABLE test t2 48 30 18 30 6 12 0 +TABLE test t3 75 48 27 48 9 18 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 27 18 9 0 0 0 0 18 0 9 +TABLE test t2 30 18 12 0 0 0 0 18 0 12 +TABLE test t3 33 18 15 0 0 0 0 18 0 15 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 57 +TABLE test t2 78 +TABLE test t3 108 +insert into test.t1 set a=401, b=1, c=1; +insert into test.t2 set a=402, b=2, c=2; +insert into test.t2 set a=403, b=3, c=3; +insert into test.t3 set a=404, b=4, c=4; +insert into test.t3 set a=405, b=5, c=5; +insert into test.t3 set a=406, b=6, c=6; +select * from test.t1; +a b c d +101 1 1 4 +201 1 1 3 +301 1 1 2 +401 1 1 0 +select * from test.t2; +a b c d +102 2 2 3 +103 3 3 3 +202 2 2 2 +203 3 3 2 +302 2 2 1 +303 3 3 1 +402 2 2 0 +403 3 3 0 +select * from test.t3; +a b c d +104 4 4 3 +105 5 5 3 +106 6 6 3 +204 4 4 2 +205 5 5 2 +206 6 6 2 +304 4 4 1 +305 5 5 1 +306 6 6 1 +404 4 4 0 +405 5 5 0 +406 6 6 0 +update test.t1 set d=d+1; +update test.t2 set d=d+1; +update test.t3 set d=d+1; +update test.t1 set d=d+1 where a=401; +update test.t2 set d=d+1 where a=401; +update test.t3 set d=d+1 where a=401; +select * from test.t1 force index(index_b) where b=5; +a b c d +select * from test.t2 force index(index_b) where b=5; +a b c d +select * from test.t3 force index(index_b) where b=5; +a b c d +105 5 5 4 +205 5 5 3 +305 5 5 2 +405 5 5 1 +"================== con4 marker ==================" +"================== Step 9 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 25 +user1 wait/lock/table/sql/handler 24 +username event_name count_star +user2 wait/io/table/sql/handler 37 +user2 wait/lock/table/sql/handler 24 +username event_name count_star +user3 wait/io/table/sql/handler 49 +user3 wait/lock/table/sql/handler 24 +username event_name count_star +user4 wait/io/table/sql/handler 61 +user4 wait/lock/table/sql/handler 24 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 30 +user2 localhost wait/io/table/sql/handler 51 +user2 localhost wait/lock/table/sql/handler 30 +user3 localhost wait/io/table/sql/handler 70 +user3 localhost wait/lock/table/sql/handler 30 +user4 localhost wait/io/table/sql/handler 89 +user4 localhost wait/lock/table/sql/handler 30 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 30 +user2 wait/io/table/sql/handler 51 +user2 wait/lock/table/sql/handler 30 +user3 wait/io/table/sql/handler 70 +user3 wait/lock/table/sql/handler 30 +user4 wait/io/table/sql/handler 89 +user4 wait/lock/table/sql/handler 30 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 242 +localhost wait/lock/table/sql/handler 120 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 242 +wait/lock/table/sql/handler 120 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 46 TABLE test t1 +wait/lock/table/sql/handler 36 TABLE test t1 +wait/io/table/sql/handler 76 TABLE test t2 +wait/lock/table/sql/handler 40 TABLE test t2 +wait/io/table/sql/handler 120 TABLE test t3 +wait/lock/table/sql/handler 44 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 NULL 52 44 8 44 8 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 24 4 20 4 0 20 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 76 48 28 48 8 20 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 36 24 12 0 0 0 0 24 0 12 +TABLE test t2 40 24 16 0 0 0 0 24 0 16 +TABLE test t3 44 24 20 0 0 0 0 24 0 20 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 82 +TABLE test t2 116 +TABLE test t3 164 +lock tables test.t1 read, test.t2 read, test.t3 read; +unlock tables; +lock tables test.t1 write, test.t2 write, test.t3 write; +unlock tables; +"================== con1 marker ==================" +"================== Step 10 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 25 +user1 wait/lock/table/sql/handler 30 +username event_name count_star +user2 wait/io/table/sql/handler 37 +user2 wait/lock/table/sql/handler 24 +username event_name count_star +user3 wait/io/table/sql/handler 49 +user3 wait/lock/table/sql/handler 24 +username event_name count_star +user4 wait/io/table/sql/handler 61 +user4 wait/lock/table/sql/handler 24 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 36 +user2 localhost wait/io/table/sql/handler 51 +user2 localhost wait/lock/table/sql/handler 30 +user3 localhost wait/io/table/sql/handler 70 +user3 localhost wait/lock/table/sql/handler 30 +user4 localhost wait/io/table/sql/handler 89 +user4 localhost wait/lock/table/sql/handler 30 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 36 +user2 wait/io/table/sql/handler 51 +user2 wait/lock/table/sql/handler 30 +user3 wait/io/table/sql/handler 70 +user3 wait/lock/table/sql/handler 30 +user4 wait/io/table/sql/handler 89 +user4 wait/lock/table/sql/handler 30 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 242 +localhost wait/lock/table/sql/handler 126 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 242 +wait/lock/table/sql/handler 126 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 46 TABLE test t1 +wait/lock/table/sql/handler 38 TABLE test t1 +wait/io/table/sql/handler 76 TABLE test t2 +wait/lock/table/sql/handler 42 TABLE test t2 +wait/io/table/sql/handler 120 TABLE test t3 +wait/lock/table/sql/handler 46 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 NULL 52 44 8 44 8 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 24 4 20 4 0 20 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 76 48 28 48 8 20 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 38 25 13 0 0 0 0 25 0 13 +TABLE test t2 42 25 17 0 0 0 0 25 0 17 +TABLE test t3 46 25 21 0 0 0 0 25 0 21 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 84 +TABLE test t2 118 +TABLE test t3 166 +flush tables; +"================== flush marker ==================" +"================== Step 11 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 25 +user1 wait/lock/table/sql/handler 30 +username event_name count_star +user2 wait/io/table/sql/handler 37 +user2 wait/lock/table/sql/handler 24 +username event_name count_star +user3 wait/io/table/sql/handler 49 +user3 wait/lock/table/sql/handler 24 +username event_name count_star +user4 wait/io/table/sql/handler 61 +user4 wait/lock/table/sql/handler 24 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 36 +user2 localhost wait/io/table/sql/handler 51 +user2 localhost wait/lock/table/sql/handler 30 +user3 localhost wait/io/table/sql/handler 70 +user3 localhost wait/lock/table/sql/handler 30 +user4 localhost wait/io/table/sql/handler 89 +user4 localhost wait/lock/table/sql/handler 30 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 36 +user2 wait/io/table/sql/handler 51 +user2 wait/lock/table/sql/handler 30 +user3 wait/io/table/sql/handler 70 +user3 wait/lock/table/sql/handler 30 +user4 wait/io/table/sql/handler 89 +user4 wait/lock/table/sql/handler 30 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 242 +localhost wait/lock/table/sql/handler 126 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 242 +wait/lock/table/sql/handler 126 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 46 TABLE test t1 +wait/lock/table/sql/handler 38 TABLE test t1 +wait/io/table/sql/handler 76 TABLE test t2 +wait/lock/table/sql/handler 42 TABLE test t2 +wait/io/table/sql/handler 120 TABLE test t3 +wait/lock/table/sql/handler 46 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 NULL 52 44 8 44 8 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 24 4 20 4 0 20 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 76 48 28 48 8 20 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 38 25 13 0 0 0 0 25 0 13 +TABLE test t2 42 25 17 0 0 0 0 25 0 17 +TABLE test t3 46 25 21 0 0 0 0 25 0 21 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 84 +TABLE test t2 118 +TABLE test t3 166 +set global read_only=1; +set global read_only=0; +"================== global read_only marker ==================" +"================== Step 12 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 25 +user1 wait/lock/table/sql/handler 30 +username event_name count_star +user2 wait/io/table/sql/handler 37 +user2 wait/lock/table/sql/handler 24 +username event_name count_star +user3 wait/io/table/sql/handler 49 +user3 wait/lock/table/sql/handler 24 +username event_name count_star +user4 wait/io/table/sql/handler 61 +user4 wait/lock/table/sql/handler 24 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 36 +user2 localhost wait/io/table/sql/handler 51 +user2 localhost wait/lock/table/sql/handler 30 +user3 localhost wait/io/table/sql/handler 70 +user3 localhost wait/lock/table/sql/handler 30 +user4 localhost wait/io/table/sql/handler 89 +user4 localhost wait/lock/table/sql/handler 30 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 36 +user2 wait/io/table/sql/handler 51 +user2 wait/lock/table/sql/handler 30 +user3 wait/io/table/sql/handler 70 +user3 wait/lock/table/sql/handler 30 +user4 wait/io/table/sql/handler 89 +user4 wait/lock/table/sql/handler 30 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 242 +localhost wait/lock/table/sql/handler 126 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 242 +wait/lock/table/sql/handler 126 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 46 TABLE test t1 +wait/lock/table/sql/handler 38 TABLE test t1 +wait/io/table/sql/handler 76 TABLE test t2 +wait/lock/table/sql/handler 42 TABLE test t2 +wait/io/table/sql/handler 120 TABLE test t3 +wait/lock/table/sql/handler 46 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 NULL 52 44 8 44 8 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 24 4 20 4 0 20 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 76 48 28 48 8 20 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 38 25 13 0 0 0 0 25 0 13 +TABLE test t2 42 25 17 0 0 0 0 25 0 17 +TABLE test t3 46 25 21 0 0 0 0 25 0 21 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 84 +TABLE test t2 118 +TABLE test t3 166 +"================== con1 disconnected ==================" +"================== Step 13 ==================" +call dump_thread(); +username status +user1 not found +username event_name count_star +user2 wait/io/table/sql/handler 37 +user2 wait/lock/table/sql/handler 24 +username event_name count_star +user3 wait/io/table/sql/handler 49 +user3 wait/lock/table/sql/handler 24 +username event_name count_star +user4 wait/io/table/sql/handler 61 +user4 wait/lock/table/sql/handler 24 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 36 +user2 localhost wait/io/table/sql/handler 51 +user2 localhost wait/lock/table/sql/handler 30 +user3 localhost wait/io/table/sql/handler 70 +user3 localhost wait/lock/table/sql/handler 30 +user4 localhost wait/io/table/sql/handler 89 +user4 localhost wait/lock/table/sql/handler 30 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 36 +user2 wait/io/table/sql/handler 51 +user2 wait/lock/table/sql/handler 30 +user3 wait/io/table/sql/handler 70 +user3 wait/lock/table/sql/handler 30 +user4 wait/io/table/sql/handler 89 +user4 wait/lock/table/sql/handler 30 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 242 +localhost wait/lock/table/sql/handler 126 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 242 +wait/lock/table/sql/handler 126 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 46 TABLE test t1 +wait/lock/table/sql/handler 38 TABLE test t1 +wait/io/table/sql/handler 76 TABLE test t2 +wait/lock/table/sql/handler 42 TABLE test t2 +wait/io/table/sql/handler 120 TABLE test t3 +wait/lock/table/sql/handler 46 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 NULL 52 44 8 44 8 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 24 4 20 4 0 20 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 76 48 28 48 8 20 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 38 25 13 0 0 0 0 25 0 13 +TABLE test t2 42 25 17 0 0 0 0 25 0 17 +TABLE test t3 46 25 21 0 0 0 0 25 0 21 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 84 +TABLE test t2 118 +TABLE test t3 166 +"================== con2 disconnected ==================" +"================== Step 14 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username event_name count_star +user3 wait/io/table/sql/handler 49 +user3 wait/lock/table/sql/handler 24 +username event_name count_star +user4 wait/io/table/sql/handler 61 +user4 wait/lock/table/sql/handler 24 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 36 +user2 localhost wait/io/table/sql/handler 51 +user2 localhost wait/lock/table/sql/handler 30 +user3 localhost wait/io/table/sql/handler 70 +user3 localhost wait/lock/table/sql/handler 30 +user4 localhost wait/io/table/sql/handler 89 +user4 localhost wait/lock/table/sql/handler 30 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 36 +user2 wait/io/table/sql/handler 51 +user2 wait/lock/table/sql/handler 30 +user3 wait/io/table/sql/handler 70 +user3 wait/lock/table/sql/handler 30 +user4 wait/io/table/sql/handler 89 +user4 wait/lock/table/sql/handler 30 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 242 +localhost wait/lock/table/sql/handler 126 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 242 +wait/lock/table/sql/handler 126 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 46 TABLE test t1 +wait/lock/table/sql/handler 38 TABLE test t1 +wait/io/table/sql/handler 76 TABLE test t2 +wait/lock/table/sql/handler 42 TABLE test t2 +wait/io/table/sql/handler 120 TABLE test t3 +wait/lock/table/sql/handler 46 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 NULL 52 44 8 44 8 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 24 4 20 4 0 20 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 76 48 28 48 8 20 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 38 25 13 0 0 0 0 25 0 13 +TABLE test t2 42 25 17 0 0 0 0 25 0 17 +TABLE test t3 46 25 21 0 0 0 0 25 0 21 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 84 +TABLE test t2 118 +TABLE test t3 166 +"================== con3 disconnected ==================" +"================== Step 15 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username event_name count_star +user4 wait/io/table/sql/handler 61 +user4 wait/lock/table/sql/handler 24 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 36 +user2 localhost wait/io/table/sql/handler 51 +user2 localhost wait/lock/table/sql/handler 30 +user3 localhost wait/io/table/sql/handler 70 +user3 localhost wait/lock/table/sql/handler 30 +user4 localhost wait/io/table/sql/handler 89 +user4 localhost wait/lock/table/sql/handler 30 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 36 +user2 wait/io/table/sql/handler 51 +user2 wait/lock/table/sql/handler 30 +user3 wait/io/table/sql/handler 70 +user3 wait/lock/table/sql/handler 30 +user4 wait/io/table/sql/handler 89 +user4 wait/lock/table/sql/handler 30 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 242 +localhost wait/lock/table/sql/handler 126 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 242 +wait/lock/table/sql/handler 126 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 46 TABLE test t1 +wait/lock/table/sql/handler 38 TABLE test t1 +wait/io/table/sql/handler 76 TABLE test t2 +wait/lock/table/sql/handler 42 TABLE test t2 +wait/io/table/sql/handler 120 TABLE test t3 +wait/lock/table/sql/handler 46 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 NULL 52 44 8 44 8 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 24 4 20 4 0 20 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 76 48 28 48 8 20 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 38 25 13 0 0 0 0 25 0 13 +TABLE test t2 42 25 17 0 0 0 0 25 0 17 +TABLE test t3 46 25 21 0 0 0 0 25 0 21 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 84 +TABLE test t2 118 +TABLE test t3 166 +"================== con4 disconnected ==================" +"================== Step 16 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 36 +user2 localhost wait/io/table/sql/handler 51 +user2 localhost wait/lock/table/sql/handler 30 +user3 localhost wait/io/table/sql/handler 70 +user3 localhost wait/lock/table/sql/handler 30 +user4 localhost wait/io/table/sql/handler 89 +user4 localhost wait/lock/table/sql/handler 30 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 36 +user2 wait/io/table/sql/handler 51 +user2 wait/lock/table/sql/handler 30 +user3 wait/io/table/sql/handler 70 +user3 wait/lock/table/sql/handler 30 +user4 wait/io/table/sql/handler 89 +user4 wait/lock/table/sql/handler 30 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 242 +localhost wait/lock/table/sql/handler 126 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 242 +wait/lock/table/sql/handler 126 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 46 TABLE test t1 +wait/lock/table/sql/handler 38 TABLE test t1 +wait/io/table/sql/handler 76 TABLE test t2 +wait/lock/table/sql/handler 42 TABLE test t2 +wait/io/table/sql/handler 120 TABLE test t3 +wait/lock/table/sql/handler 46 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 NULL 52 44 8 44 8 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 24 4 20 4 0 20 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 76 48 28 48 8 20 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 38 25 13 0 0 0 0 25 0 13 +TABLE test t2 42 25 17 0 0 0 0 25 0 17 +TABLE test t3 46 25 21 0 0 0 0 25 0 21 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 84 +TABLE test t2 118 +TABLE test t3 166 +truncate performance_schema.events_waits_summary_by_thread_by_event_name; +"================== BY_THREAD truncated ==================" +"================== Step 17 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 36 +user2 localhost wait/io/table/sql/handler 51 +user2 localhost wait/lock/table/sql/handler 30 +user3 localhost wait/io/table/sql/handler 70 +user3 localhost wait/lock/table/sql/handler 30 +user4 localhost wait/io/table/sql/handler 89 +user4 localhost wait/lock/table/sql/handler 30 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 36 +user2 wait/io/table/sql/handler 51 +user2 wait/lock/table/sql/handler 30 +user3 wait/io/table/sql/handler 70 +user3 wait/lock/table/sql/handler 30 +user4 wait/io/table/sql/handler 89 +user4 wait/lock/table/sql/handler 30 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 242 +localhost wait/lock/table/sql/handler 126 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 242 +wait/lock/table/sql/handler 126 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 46 TABLE test t1 +wait/lock/table/sql/handler 38 TABLE test t1 +wait/io/table/sql/handler 76 TABLE test t2 +wait/lock/table/sql/handler 42 TABLE test t2 +wait/io/table/sql/handler 120 TABLE test t3 +wait/lock/table/sql/handler 46 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 NULL 52 44 8 44 8 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 24 4 20 4 0 20 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 76 48 28 48 8 20 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 38 25 13 0 0 0 0 25 0 13 +TABLE test t2 42 25 17 0 0 0 0 25 0 17 +TABLE test t3 46 25 21 0 0 0 0 25 0 21 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 84 +TABLE test t2 118 +TABLE test t3 166 +truncate performance_schema.events_waits_summary_by_account_by_event_name; +"================== BY_ACCOUNT truncated ==================" +"================== Step 18 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 0 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 36 +user2 wait/io/table/sql/handler 51 +user2 wait/lock/table/sql/handler 30 +user3 wait/io/table/sql/handler 70 +user3 wait/lock/table/sql/handler 30 +user4 wait/io/table/sql/handler 89 +user4 wait/lock/table/sql/handler 30 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 242 +localhost wait/lock/table/sql/handler 126 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 242 +wait/lock/table/sql/handler 126 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 46 TABLE test t1 +wait/lock/table/sql/handler 38 TABLE test t1 +wait/io/table/sql/handler 76 TABLE test t2 +wait/lock/table/sql/handler 42 TABLE test t2 +wait/io/table/sql/handler 120 TABLE test t3 +wait/lock/table/sql/handler 46 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 NULL 52 44 8 44 8 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 24 4 20 4 0 20 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 76 48 28 48 8 20 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 38 25 13 0 0 0 0 25 0 13 +TABLE test t2 42 25 17 0 0 0 0 25 0 17 +TABLE test t3 46 25 21 0 0 0 0 25 0 21 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 84 +TABLE test t2 118 +TABLE test t3 166 +truncate performance_schema.events_waits_summary_by_user_by_event_name; +"================== BY_USER truncated ==================" +"================== Step 19 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 0 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 242 +localhost wait/lock/table/sql/handler 126 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 242 +wait/lock/table/sql/handler 126 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 46 TABLE test t1 +wait/lock/table/sql/handler 38 TABLE test t1 +wait/io/table/sql/handler 76 TABLE test t2 +wait/lock/table/sql/handler 42 TABLE test t2 +wait/io/table/sql/handler 120 TABLE test t3 +wait/lock/table/sql/handler 46 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 NULL 52 44 8 44 8 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 24 4 20 4 0 20 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 76 48 28 48 8 20 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 38 25 13 0 0 0 0 25 0 13 +TABLE test t2 42 25 17 0 0 0 0 25 0 17 +TABLE test t3 46 25 21 0 0 0 0 25 0 21 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 84 +TABLE test t2 118 +TABLE test t3 166 +truncate performance_schema.events_waits_summary_by_host_by_event_name; +"================== BY_HOST truncated ==================" +"================== Step 21 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 0 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 242 +wait/lock/table/sql/handler 126 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 46 TABLE test t1 +wait/lock/table/sql/handler 38 TABLE test t1 +wait/io/table/sql/handler 76 TABLE test t2 +wait/lock/table/sql/handler 42 TABLE test t2 +wait/io/table/sql/handler 120 TABLE test t3 +wait/lock/table/sql/handler 46 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 NULL 52 44 8 44 8 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 24 4 20 4 0 20 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 76 48 28 48 8 20 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 38 25 13 0 0 0 0 25 0 13 +TABLE test t2 42 25 17 0 0 0 0 25 0 17 +TABLE test t3 46 25 21 0 0 0 0 25 0 21 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 84 +TABLE test t2 118 +TABLE test t3 166 +truncate performance_schema.events_waits_summary_global_by_event_name; +"================== GLOBAL truncated ==================" +"================== Step 21 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 0 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 0 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 46 TABLE test t1 +wait/lock/table/sql/handler 38 TABLE test t1 +wait/io/table/sql/handler 76 TABLE test t2 +wait/lock/table/sql/handler 42 TABLE test t2 +wait/io/table/sql/handler 120 TABLE test t3 +wait/lock/table/sql/handler 46 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 0 0 0 0 0 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 0 0 0 0 0 0 0 +TABLE test t2 NULL 0 0 0 0 0 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 0 0 0 0 0 0 0 +TABLE test t3 index_b 0 0 0 0 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 0 0 0 0 0 0 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 0 +TABLE test t2 0 +TABLE test t3 0 +show global status like "performance_schema%table%_lost"; +Variable_name Value +Performance_schema_table_handles_lost 0 +Performance_schema_table_instances_lost 0 +Performance_schema_table_lock_stat_lost 0 diff --git a/mysql-test/suite/table_aggregate_thread_2u_2t.result-pq b/mysql-test/suite/table_aggregate_thread_2u_2t.result-pq new file mode 100644 index 000000000000..1b5d2cf59fa3 --- /dev/null +++ b/mysql-test/suite/table_aggregate_thread_2u_2t.result-pq @@ -0,0 +1,1722 @@ +update performance_schema.setup_consumers +set enabled='NO' where name like 'event%'; +delete from performance_schema.setup_actors +where user in ('user2', 'user4'); +delete from performance_schema.setup_objects +where object_name='t2'; +select * from performance_schema.setup_actors +order by USER, HOST, `ROLE`; +HOST USER ROLE ENABLED HISTORY +localhost user1 % YES YES +localhost user3 % YES YES +select * from performance_schema.setup_objects +order by object_type, object_schema, object_name; +OBJECT_TYPE OBJECT_SCHEMA OBJECT_NAME ENABLED TIMED +TABLE test t1 YES YES +TABLE test t3 YES NO +select * from performance_schema.setup_consumers; +NAME ENABLED +events_stages_current NO +events_stages_history NO +events_stages_history_long NO +events_statements_current NO +events_statements_history NO +events_statements_history_long NO +events_transactions_current NO +events_transactions_history NO +events_transactions_history_long NO +events_waits_current NO +events_waits_history NO +events_waits_history_long NO +global_instrumentation YES +thread_instrumentation YES +statements_digest YES +flush tables; +truncate performance_schema.objects_summary_global_by_type; +truncate performance_schema.table_io_waits_summary_by_index_usage; +truncate performance_schema.table_io_waits_summary_by_table; +truncate performance_schema.table_lock_waits_summary_by_table; +truncate performance_schema.events_waits_summary_by_thread_by_event_name; +truncate performance_schema.events_waits_summary_by_account_by_event_name; +truncate performance_schema.events_waits_summary_by_user_by_event_name; +truncate performance_schema.events_waits_summary_by_host_by_event_name; +truncate performance_schema.events_waits_summary_global_by_event_name; +truncate performance_schema.events_waits_history_long; +show global variables like "performance_schema%table%"; +Variable_name Value +performance_schema_max_table_handles -1 +performance_schema_max_table_instances -1 +performance_schema_max_table_lock_stat -1 +show global status like "performance_schema%table%_lost"; +Variable_name Value +Performance_schema_table_handles_lost 0 +Performance_schema_table_instances_lost 0 +Performance_schema_table_lock_stat_lost 0 +"================== Step 1 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +execute dump_waits_user; +user event_name count_star +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 0 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 0 0 0 0 0 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 index_b 0 0 0 0 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 0 0 0 0 0 0 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 0 +TABLE test t2 0 +TABLE test t3 0 +select concat(current_user(), " is connected") as status; +status +user1@localhost is connected +"================== Step 2 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 0 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 0 0 0 0 0 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 index_b 0 0 0 0 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 0 0 0 0 0 0 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 0 +TABLE test t2 0 +TABLE test t3 0 +insert into test.t1 set a=101, b=1, c=1; +insert into test.t2 set a=102, b=2, c=2; +insert into test.t2 set a=103, b=3, c=3; +insert into test.t3 set a=104, b=4, c=4; +insert into test.t3 set a=105, b=5, c=5; +insert into test.t3 set a=106, b=6, c=6; +select * from test.t1; +a b c d +101 1 1 0 +select * from test.t2; +a b c d +102 2 2 0 +103 3 3 0 +select * from test.t3; +a b c d +104 4 4 0 +105 5 5 0 +106 6 6 0 +update test.t1 set d=d+1; +update test.t2 set d=d+1; +update test.t3 set d=d+1; +update test.t1 set d=d+1 where a=101; +update test.t2 set d=d+1 where a=101; +update test.t3 set d=d+1 where a=101; +select * from test.t1 force index(index_b) where b=5; +a b c d +select * from test.t2 force index(index_b) where b=5; +a b c d +select * from test.t3 force index(index_b) where b=5; +a b c d +105 5 5 1 +"================== con1 marker ==================" +"================== Step 3-A ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 17 +user1 wait/lock/table/sql/handler 16 +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 20 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 20 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 22 +localhost wait/lock/table/sql/handler 20 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 22 +wait/lock/table/sql/handler 20 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 4 3 1 3 1 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 3 1 2 1 0 2 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 10 7 3 7 3 0 0 +TABLE test t3 index_b 1 1 0 1 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 4 1 3 1 0 3 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 7 4 3 4 1 2 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 15 9 6 9 3 3 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 9 6 3 0 0 0 0 6 0 3 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 11 6 5 0 0 0 0 6 0 5 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 16 +TABLE test t2 0 +TABLE test t3 26 +flush tables; +"================== con1 FLUSH ==================" +"================== Step 3-B ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 17 +user1 wait/lock/table/sql/handler 16 +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 20 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 20 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 22 +localhost wait/lock/table/sql/handler 20 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 22 +wait/lock/table/sql/handler 20 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 4 3 1 3 1 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 3 1 2 1 0 2 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 10 7 3 7 3 0 0 +TABLE test t3 index_b 1 1 0 1 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 4 1 3 1 0 3 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 7 4 3 4 1 2 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 15 9 6 9 3 3 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 9 6 3 0 0 0 0 6 0 3 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 11 6 5 0 0 0 0 6 0 5 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 16 +TABLE test t2 0 +TABLE test t3 26 +select concat(current_user(), " is connected") as status; +status +user2@localhost is connected +"================== Step 4 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 17 +user1 wait/lock/table/sql/handler 16 +username event_name count_star +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 20 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 20 +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 22 +localhost wait/lock/table/sql/handler 20 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 22 +wait/lock/table/sql/handler 20 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 4 3 1 3 1 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 3 1 2 1 0 2 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 10 7 3 7 3 0 0 +TABLE test t3 index_b 1 1 0 1 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 4 1 3 1 0 3 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 7 4 3 4 1 2 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 15 9 6 9 3 3 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 9 6 3 0 0 0 0 6 0 3 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 11 6 5 0 0 0 0 6 0 5 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 16 +TABLE test t2 0 +TABLE test t3 26 +insert into test.t1 set a=201, b=1, c=1; +insert into test.t2 set a=202, b=2, c=2; +insert into test.t2 set a=203, b=3, c=3; +insert into test.t3 set a=204, b=4, c=4; +insert into test.t3 set a=205, b=5, c=5; +insert into test.t3 set a=206, b=6, c=6; +select * from test.t1; +a b c d +101 1 1 2 +201 1 1 0 +select * from test.t2; +a b c d +102 2 2 1 +103 3 3 1 +202 2 2 0 +203 3 3 0 +select * from test.t3; +a b c d +104 4 4 1 +105 5 5 1 +106 6 6 1 +204 4 4 0 +205 5 5 0 +206 6 6 0 +update test.t1 set d=d+1; +update test.t2 set d=d+1; +update test.t3 set d=d+1; +update test.t1 set d=d+1 where a=201; +update test.t2 set d=d+1 where a=201; +update test.t3 set d=d+1 where a=201; +select * from test.t1 force index(index_b) where b=5; +a b c d +select * from test.t2 force index(index_b) where b=5; +a b c d +select * from test.t3 force index(index_b) where b=5; +a b c d +105 5 5 2 +205 5 5 1 +"================== con2 marker ==================" +"================== Step 5 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 17 +user1 wait/lock/table/sql/handler 16 +username event_name count_star +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 20 +user2 localhost wait/io/table/sql/handler 10 +user2 localhost wait/lock/table/sql/handler 4 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 20 +user2 wait/io/table/sql/handler 10 +user2 wait/lock/table/sql/handler 4 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 32 +localhost wait/lock/table/sql/handler 24 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 32 +wait/lock/table/sql/handler 24 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 6 5 1 5 1 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 3 1 2 1 0 2 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 16 13 3 13 3 0 0 +TABLE test t3 index_b 3 3 0 3 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 4 1 3 1 0 3 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 9 6 3 6 1 2 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 23 17 6 17 3 3 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 11 8 3 0 0 0 0 8 0 3 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 13 8 5 0 0 0 0 8 0 5 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 20 +TABLE test t2 0 +TABLE test t3 36 +select concat(current_user(), " is connected") as status; +status +user3@localhost is connected +"================== Step 6 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 17 +user1 wait/lock/table/sql/handler 16 +username event_name count_star +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 20 +user2 localhost wait/io/table/sql/handler 10 +user2 localhost wait/lock/table/sql/handler 4 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 20 +user2 wait/io/table/sql/handler 10 +user2 wait/lock/table/sql/handler 4 +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 32 +localhost wait/lock/table/sql/handler 24 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 32 +wait/lock/table/sql/handler 24 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 6 5 1 5 1 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 3 1 2 1 0 2 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 16 13 3 13 3 0 0 +TABLE test t3 index_b 3 3 0 3 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 4 1 3 1 0 3 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 9 6 3 6 1 2 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 23 17 6 17 3 3 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 11 8 3 0 0 0 0 8 0 3 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 13 8 5 0 0 0 0 8 0 5 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 20 +TABLE test t2 0 +TABLE test t3 36 +insert into test.t1 set a=301, b=1, c=1; +insert into test.t2 set a=302, b=2, c=2; +insert into test.t2 set a=303, b=3, c=3; +insert into test.t3 set a=304, b=4, c=4; +insert into test.t3 set a=305, b=5, c=5; +insert into test.t3 set a=306, b=6, c=6; +select * from test.t1; +a b c d +101 1 1 3 +201 1 1 2 +301 1 1 0 +select * from test.t2; +a b c d +102 2 2 2 +103 3 3 2 +202 2 2 1 +203 3 3 1 +302 2 2 0 +303 3 3 0 +select * from test.t3; +a b c d +104 4 4 2 +105 5 5 2 +106 6 6 2 +204 4 4 1 +205 5 5 1 +206 6 6 1 +304 4 4 0 +305 5 5 0 +306 6 6 0 +update test.t1 set d=d+1; +update test.t2 set d=d+1; +update test.t3 set d=d+1; +update test.t1 set d=d+1 where a=301; +update test.t2 set d=d+1 where a=301; +update test.t3 set d=d+1 where a=301; +select * from test.t1 force index(index_b) where b=5; +a b c d +select * from test.t2 force index(index_b) where b=5; +a b c d +select * from test.t3 force index(index_b) where b=5; +a b c d +105 5 5 3 +205 5 5 2 +305 5 5 1 +"================== con3 marker ==================" +"================== Step 7 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 17 +user1 wait/lock/table/sql/handler 16 +username event_name count_star +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 33 +user3 wait/lock/table/sql/handler 16 +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 20 +user2 localhost wait/io/table/sql/handler 10 +user2 localhost wait/lock/table/sql/handler 4 +user3 localhost wait/io/table/sql/handler 48 +user3 localhost wait/lock/table/sql/handler 20 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 20 +user2 wait/io/table/sql/handler 10 +user2 wait/lock/table/sql/handler 4 +user3 wait/io/table/sql/handler 48 +user3 wait/lock/table/sql/handler 20 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 80 +localhost wait/lock/table/sql/handler 44 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 80 +wait/lock/table/sql/handler 44 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 14 12 2 12 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 8 2 6 2 0 6 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 38 32 6 32 6 0 0 +TABLE test t3 index_b 6 6 0 6 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 14 2 12 2 0 12 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 22 14 8 14 2 6 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 58 40 18 40 6 12 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 20 14 6 0 0 0 0 14 0 6 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 24 14 10 0 0 0 0 14 0 10 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 42 +TABLE test t2 0 +TABLE test t3 82 +select concat(current_user(), " is connected") as status; +status +user4@localhost is connected +"================== Step 8 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 17 +user1 wait/lock/table/sql/handler 16 +username event_name count_star +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 33 +user3 wait/lock/table/sql/handler 16 +username event_name count_star +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 20 +user2 localhost wait/io/table/sql/handler 10 +user2 localhost wait/lock/table/sql/handler 4 +user3 localhost wait/io/table/sql/handler 48 +user3 localhost wait/lock/table/sql/handler 20 +user4 localhost wait/io/table/sql/handler 0 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 20 +user2 wait/io/table/sql/handler 10 +user2 wait/lock/table/sql/handler 4 +user3 wait/io/table/sql/handler 48 +user3 wait/lock/table/sql/handler 20 +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 80 +localhost wait/lock/table/sql/handler 44 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 80 +wait/lock/table/sql/handler 44 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 14 12 2 12 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 8 2 6 2 0 6 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 38 32 6 32 6 0 0 +TABLE test t3 index_b 6 6 0 6 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 14 2 12 2 0 12 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 22 14 8 14 2 6 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 58 40 18 40 6 12 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 20 14 6 0 0 0 0 14 0 6 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 24 14 10 0 0 0 0 14 0 10 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 42 +TABLE test t2 0 +TABLE test t3 82 +insert into test.t1 set a=401, b=1, c=1; +insert into test.t2 set a=402, b=2, c=2; +insert into test.t2 set a=403, b=3, c=3; +insert into test.t3 set a=404, b=4, c=4; +insert into test.t3 set a=405, b=5, c=5; +insert into test.t3 set a=406, b=6, c=6; +select * from test.t1; +a b c d +101 1 1 4 +201 1 1 3 +301 1 1 2 +401 1 1 0 +select * from test.t2; +a b c d +102 2 2 3 +103 3 3 3 +202 2 2 2 +203 3 3 2 +302 2 2 1 +303 3 3 1 +402 2 2 0 +403 3 3 0 +select * from test.t3; +a b c d +104 4 4 3 +105 5 5 3 +106 6 6 3 +204 4 4 2 +205 5 5 2 +206 6 6 2 +304 4 4 1 +305 5 5 1 +306 6 6 1 +404 4 4 0 +405 5 5 0 +406 6 6 0 +update test.t1 set d=d+1; +update test.t2 set d=d+1; +update test.t3 set d=d+1; +update test.t1 set d=d+1 where a=401; +update test.t2 set d=d+1 where a=401; +update test.t3 set d=d+1 where a=401; +select * from test.t1 force index(index_b) where b=5; +a b c d +select * from test.t2 force index(index_b) where b=5; +a b c d +select * from test.t3 force index(index_b) where b=5; +a b c d +105 5 5 4 +205 5 5 3 +305 5 5 2 +405 5 5 1 +"================== con4 marker ==================" +"================== Step 9 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 17 +user1 wait/lock/table/sql/handler 16 +username event_name count_star +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 33 +user3 wait/lock/table/sql/handler 16 +username event_name count_star +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 20 +user2 localhost wait/io/table/sql/handler 10 +user2 localhost wait/lock/table/sql/handler 4 +user3 localhost wait/io/table/sql/handler 48 +user3 localhost wait/lock/table/sql/handler 20 +user4 localhost wait/io/table/sql/handler 20 +user4 localhost wait/lock/table/sql/handler 4 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 20 +user2 wait/io/table/sql/handler 10 +user2 wait/lock/table/sql/handler 4 +user3 wait/io/table/sql/handler 48 +user3 wait/lock/table/sql/handler 20 +user4 wait/io/table/sql/handler 20 +user4 wait/lock/table/sql/handler 4 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 100 +localhost wait/lock/table/sql/handler 48 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 100 +wait/lock/table/sql/handler 48 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 16 2 16 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 8 2 6 2 0 6 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 50 44 6 44 6 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 14 2 12 2 0 12 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 26 18 8 18 2 6 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 74 56 18 56 6 12 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 22 16 6 0 0 0 0 16 0 6 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 26 16 10 0 0 0 0 16 0 10 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 48 +TABLE test t2 0 +TABLE test t3 100 +lock tables test.t1 read, test.t2 read, test.t3 read; +unlock tables; +lock tables test.t1 write, test.t2 write, test.t3 write; +unlock tables; +"================== con1 marker ==================" +"================== Step 10 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 17 +user1 wait/lock/table/sql/handler 20 +username event_name count_star +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 33 +user3 wait/lock/table/sql/handler 16 +username event_name count_star +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 24 +user2 localhost wait/io/table/sql/handler 10 +user2 localhost wait/lock/table/sql/handler 4 +user3 localhost wait/io/table/sql/handler 48 +user3 localhost wait/lock/table/sql/handler 20 +user4 localhost wait/io/table/sql/handler 20 +user4 localhost wait/lock/table/sql/handler 4 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 24 +user2 wait/io/table/sql/handler 10 +user2 wait/lock/table/sql/handler 4 +user3 wait/io/table/sql/handler 48 +user3 wait/lock/table/sql/handler 20 +user4 wait/io/table/sql/handler 20 +user4 wait/lock/table/sql/handler 4 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 100 +localhost wait/lock/table/sql/handler 52 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 100 +wait/lock/table/sql/handler 52 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 16 2 16 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 8 2 6 2 0 6 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 50 44 6 44 6 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 14 2 12 2 0 12 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 26 18 8 18 2 6 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 74 56 18 56 6 12 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 24 17 7 0 0 0 0 17 0 7 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 28 17 11 0 0 0 0 17 0 11 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 50 +TABLE test t2 0 +TABLE test t3 102 +flush tables; +"================== flush marker ==================" +"================== Step 11 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 17 +user1 wait/lock/table/sql/handler 20 +username event_name count_star +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 33 +user3 wait/lock/table/sql/handler 16 +username event_name count_star +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 24 +user2 localhost wait/io/table/sql/handler 10 +user2 localhost wait/lock/table/sql/handler 4 +user3 localhost wait/io/table/sql/handler 48 +user3 localhost wait/lock/table/sql/handler 20 +user4 localhost wait/io/table/sql/handler 20 +user4 localhost wait/lock/table/sql/handler 4 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 24 +user2 wait/io/table/sql/handler 10 +user2 wait/lock/table/sql/handler 4 +user3 wait/io/table/sql/handler 48 +user3 wait/lock/table/sql/handler 20 +user4 wait/io/table/sql/handler 20 +user4 wait/lock/table/sql/handler 4 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 100 +localhost wait/lock/table/sql/handler 52 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 100 +wait/lock/table/sql/handler 52 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 16 2 16 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 8 2 6 2 0 6 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 50 44 6 44 6 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 14 2 12 2 0 12 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 26 18 8 18 2 6 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 74 56 18 56 6 12 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 24 17 7 0 0 0 0 17 0 7 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 28 17 11 0 0 0 0 17 0 11 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 50 +TABLE test t2 0 +TABLE test t3 102 +set global read_only=1; +set global read_only=0; +"================== global read_only marker ==================" +"================== Step 12 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 17 +user1 wait/lock/table/sql/handler 20 +username event_name count_star +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 33 +user3 wait/lock/table/sql/handler 16 +username event_name count_star +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 24 +user2 localhost wait/io/table/sql/handler 10 +user2 localhost wait/lock/table/sql/handler 4 +user3 localhost wait/io/table/sql/handler 48 +user3 localhost wait/lock/table/sql/handler 20 +user4 localhost wait/io/table/sql/handler 20 +user4 localhost wait/lock/table/sql/handler 4 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 24 +user2 wait/io/table/sql/handler 10 +user2 wait/lock/table/sql/handler 4 +user3 wait/io/table/sql/handler 48 +user3 wait/lock/table/sql/handler 20 +user4 wait/io/table/sql/handler 20 +user4 wait/lock/table/sql/handler 4 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 100 +localhost wait/lock/table/sql/handler 52 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 100 +wait/lock/table/sql/handler 52 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 16 2 16 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 8 2 6 2 0 6 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 50 44 6 44 6 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 14 2 12 2 0 12 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 26 18 8 18 2 6 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 74 56 18 56 6 12 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 24 17 7 0 0 0 0 17 0 7 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 28 17 11 0 0 0 0 17 0 11 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 50 +TABLE test t2 0 +TABLE test t3 102 +"================== con1 disconnected ==================" +"================== Step 13 ==================" +call dump_thread(); +username status +user1 not found +username event_name count_star +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 33 +user3 wait/lock/table/sql/handler 16 +username event_name count_star +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 24 +user2 localhost wait/io/table/sql/handler 10 +user2 localhost wait/lock/table/sql/handler 4 +user3 localhost wait/io/table/sql/handler 48 +user3 localhost wait/lock/table/sql/handler 20 +user4 localhost wait/io/table/sql/handler 20 +user4 localhost wait/lock/table/sql/handler 4 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 24 +user2 wait/io/table/sql/handler 10 +user2 wait/lock/table/sql/handler 4 +user3 wait/io/table/sql/handler 48 +user3 wait/lock/table/sql/handler 20 +user4 wait/io/table/sql/handler 20 +user4 wait/lock/table/sql/handler 4 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 100 +localhost wait/lock/table/sql/handler 52 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 100 +wait/lock/table/sql/handler 52 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 16 2 16 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 8 2 6 2 0 6 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 50 44 6 44 6 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 14 2 12 2 0 12 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 26 18 8 18 2 6 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 74 56 18 56 6 12 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 24 17 7 0 0 0 0 17 0 7 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 28 17 11 0 0 0 0 17 0 11 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 50 +TABLE test t2 0 +TABLE test t3 102 +"================== con2 disconnected ==================" +"================== Step 14 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username event_name count_star +user3 wait/io/table/sql/handler 33 +user3 wait/lock/table/sql/handler 16 +username event_name count_star +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 24 +user2 localhost wait/io/table/sql/handler 10 +user2 localhost wait/lock/table/sql/handler 4 +user3 localhost wait/io/table/sql/handler 48 +user3 localhost wait/lock/table/sql/handler 20 +user4 localhost wait/io/table/sql/handler 20 +user4 localhost wait/lock/table/sql/handler 4 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 24 +user2 wait/io/table/sql/handler 10 +user2 wait/lock/table/sql/handler 4 +user3 wait/io/table/sql/handler 48 +user3 wait/lock/table/sql/handler 20 +user4 wait/io/table/sql/handler 20 +user4 wait/lock/table/sql/handler 4 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 100 +localhost wait/lock/table/sql/handler 52 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 100 +wait/lock/table/sql/handler 52 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 16 2 16 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 8 2 6 2 0 6 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 50 44 6 44 6 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 14 2 12 2 0 12 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 26 18 8 18 2 6 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 74 56 18 56 6 12 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 24 17 7 0 0 0 0 17 0 7 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 28 17 11 0 0 0 0 17 0 11 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 50 +TABLE test t2 0 +TABLE test t3 102 +"================== con3 disconnected ==================" +"================== Step 15 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username event_name count_star +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 24 +user2 localhost wait/io/table/sql/handler 10 +user2 localhost wait/lock/table/sql/handler 4 +user3 localhost wait/io/table/sql/handler 48 +user3 localhost wait/lock/table/sql/handler 20 +user4 localhost wait/io/table/sql/handler 20 +user4 localhost wait/lock/table/sql/handler 4 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 24 +user2 wait/io/table/sql/handler 10 +user2 wait/lock/table/sql/handler 4 +user3 wait/io/table/sql/handler 48 +user3 wait/lock/table/sql/handler 20 +user4 wait/io/table/sql/handler 20 +user4 wait/lock/table/sql/handler 4 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 100 +localhost wait/lock/table/sql/handler 52 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 100 +wait/lock/table/sql/handler 52 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 16 2 16 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 8 2 6 2 0 6 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 50 44 6 44 6 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 14 2 12 2 0 12 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 26 18 8 18 2 6 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 74 56 18 56 6 12 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 24 17 7 0 0 0 0 17 0 7 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 28 17 11 0 0 0 0 17 0 11 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 50 +TABLE test t2 0 +TABLE test t3 102 +"================== con4 disconnected ==================" +"================== Step 16 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 24 +user2 localhost wait/io/table/sql/handler 10 +user2 localhost wait/lock/table/sql/handler 4 +user3 localhost wait/io/table/sql/handler 48 +user3 localhost wait/lock/table/sql/handler 20 +user4 localhost wait/io/table/sql/handler 20 +user4 localhost wait/lock/table/sql/handler 4 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 24 +user2 wait/io/table/sql/handler 10 +user2 wait/lock/table/sql/handler 4 +user3 wait/io/table/sql/handler 48 +user3 wait/lock/table/sql/handler 20 +user4 wait/io/table/sql/handler 20 +user4 wait/lock/table/sql/handler 4 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 100 +localhost wait/lock/table/sql/handler 52 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 100 +wait/lock/table/sql/handler 52 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 16 2 16 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 8 2 6 2 0 6 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 50 44 6 44 6 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 14 2 12 2 0 12 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 26 18 8 18 2 6 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 74 56 18 56 6 12 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 24 17 7 0 0 0 0 17 0 7 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 28 17 11 0 0 0 0 17 0 11 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 50 +TABLE test t2 0 +TABLE test t3 102 +truncate performance_schema.events_waits_summary_by_thread_by_event_name; +"================== BY_THREAD truncated ==================" +"================== Step 17 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 24 +user2 localhost wait/io/table/sql/handler 10 +user2 localhost wait/lock/table/sql/handler 4 +user3 localhost wait/io/table/sql/handler 48 +user3 localhost wait/lock/table/sql/handler 20 +user4 localhost wait/io/table/sql/handler 20 +user4 localhost wait/lock/table/sql/handler 4 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 24 +user2 wait/io/table/sql/handler 10 +user2 wait/lock/table/sql/handler 4 +user3 wait/io/table/sql/handler 48 +user3 wait/lock/table/sql/handler 20 +user4 wait/io/table/sql/handler 20 +user4 wait/lock/table/sql/handler 4 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 100 +localhost wait/lock/table/sql/handler 52 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 100 +wait/lock/table/sql/handler 52 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 16 2 16 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 8 2 6 2 0 6 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 50 44 6 44 6 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 14 2 12 2 0 12 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 26 18 8 18 2 6 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 74 56 18 56 6 12 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 24 17 7 0 0 0 0 17 0 7 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 28 17 11 0 0 0 0 17 0 11 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 50 +TABLE test t2 0 +TABLE test t3 102 +truncate performance_schema.events_waits_summary_by_account_by_event_name; +"================== BY_ACCOUNT truncated ==================" +"================== Step 18 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 0 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 24 +user2 wait/io/table/sql/handler 10 +user2 wait/lock/table/sql/handler 4 +user3 wait/io/table/sql/handler 48 +user3 wait/lock/table/sql/handler 20 +user4 wait/io/table/sql/handler 20 +user4 wait/lock/table/sql/handler 4 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 100 +localhost wait/lock/table/sql/handler 52 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 100 +wait/lock/table/sql/handler 52 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 16 2 16 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 8 2 6 2 0 6 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 50 44 6 44 6 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 14 2 12 2 0 12 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 26 18 8 18 2 6 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 74 56 18 56 6 12 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 24 17 7 0 0 0 0 17 0 7 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 28 17 11 0 0 0 0 17 0 11 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 50 +TABLE test t2 0 +TABLE test t3 102 +truncate performance_schema.events_waits_summary_by_user_by_event_name; +"================== BY_USER truncated ==================" +"================== Step 19 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 0 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 100 +localhost wait/lock/table/sql/handler 52 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 100 +wait/lock/table/sql/handler 52 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 16 2 16 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 8 2 6 2 0 6 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 50 44 6 44 6 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 14 2 12 2 0 12 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 26 18 8 18 2 6 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 74 56 18 56 6 12 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 24 17 7 0 0 0 0 17 0 7 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 28 17 11 0 0 0 0 17 0 11 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 50 +TABLE test t2 0 +TABLE test t3 102 +truncate performance_schema.events_waits_summary_by_host_by_event_name; +"================== BY_HOST truncated ==================" +"================== Step 21 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 0 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 100 +wait/lock/table/sql/handler 52 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 16 2 16 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 8 2 6 2 0 6 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 50 44 6 44 6 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 14 2 12 2 0 12 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 26 18 8 18 2 6 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 74 56 18 56 6 12 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 24 17 7 0 0 0 0 17 0 7 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 28 17 11 0 0 0 0 17 0 11 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 50 +TABLE test t2 0 +TABLE test t3 102 +truncate performance_schema.events_waits_summary_global_by_event_name; +"================== GLOBAL truncated ==================" +"================== Step 21 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 0 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 0 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 0 0 0 0 0 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 0 0 0 0 0 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 0 0 0 0 0 0 0 +TABLE test t3 index_b 0 0 0 0 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 0 0 0 0 0 0 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 0 +TABLE test t2 0 +TABLE test t3 0 +show global status like "performance_schema%table%_lost"; +Variable_name Value +Performance_schema_table_handles_lost 0 +Performance_schema_table_instances_lost 0 +Performance_schema_table_lock_stat_lost 0 diff --git a/mysql-test/suite/table_aggregate_thread_2u_3t.result-pq b/mysql-test/suite/table_aggregate_thread_2u_3t.result-pq new file mode 100644 index 000000000000..34f30e6805b3 --- /dev/null +++ b/mysql-test/suite/table_aggregate_thread_2u_3t.result-pq @@ -0,0 +1,1741 @@ +update performance_schema.setup_consumers +set enabled='NO' where name like 'event%'; +delete from performance_schema.setup_actors +where user in ('user2', 'user4'); +select * from performance_schema.setup_actors +order by USER, HOST, `ROLE`; +HOST USER ROLE ENABLED HISTORY +localhost user1 % YES YES +localhost user3 % YES YES +select * from performance_schema.setup_objects +order by object_type, object_schema, object_name; +OBJECT_TYPE OBJECT_SCHEMA OBJECT_NAME ENABLED TIMED +TABLE test t1 YES YES +TABLE test t2 YES NO +TABLE test t3 YES NO +select * from performance_schema.setup_consumers; +NAME ENABLED +events_stages_current NO +events_stages_history NO +events_stages_history_long NO +events_statements_current NO +events_statements_history NO +events_statements_history_long NO +events_transactions_current NO +events_transactions_history NO +events_transactions_history_long NO +events_waits_current NO +events_waits_history NO +events_waits_history_long NO +global_instrumentation YES +thread_instrumentation YES +statements_digest YES +flush tables; +truncate performance_schema.objects_summary_global_by_type; +truncate performance_schema.table_io_waits_summary_by_index_usage; +truncate performance_schema.table_io_waits_summary_by_table; +truncate performance_schema.table_lock_waits_summary_by_table; +truncate performance_schema.events_waits_summary_by_thread_by_event_name; +truncate performance_schema.events_waits_summary_by_account_by_event_name; +truncate performance_schema.events_waits_summary_by_user_by_event_name; +truncate performance_schema.events_waits_summary_by_host_by_event_name; +truncate performance_schema.events_waits_summary_global_by_event_name; +truncate performance_schema.events_waits_history_long; +show global variables like "performance_schema%table%"; +Variable_name Value +performance_schema_max_table_handles -1 +performance_schema_max_table_instances -1 +performance_schema_max_table_lock_stat -1 +show global status like "performance_schema%table%_lost"; +Variable_name Value +Performance_schema_table_handles_lost 0 +Performance_schema_table_instances_lost 0 +Performance_schema_table_lock_stat_lost 0 +"================== Step 1 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +execute dump_waits_user; +user event_name count_star +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 0 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 0 0 0 0 0 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 index_b 0 0 0 0 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 0 0 0 0 0 0 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 0 +TABLE test t2 0 +TABLE test t3 0 +select concat(current_user(), " is connected") as status; +status +user1@localhost is connected +"================== Step 2 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 0 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 0 0 0 0 0 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 index_b 0 0 0 0 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 0 0 0 0 0 0 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 0 +TABLE test t2 0 +TABLE test t3 0 +insert into test.t1 set a=101, b=1, c=1; +insert into test.t2 set a=102, b=2, c=2; +insert into test.t2 set a=103, b=3, c=3; +insert into test.t3 set a=104, b=4, c=4; +insert into test.t3 set a=105, b=5, c=5; +insert into test.t3 set a=106, b=6, c=6; +select * from test.t1; +a b c d +101 1 1 0 +select * from test.t2; +a b c d +102 2 2 0 +103 3 3 0 +select * from test.t3; +a b c d +104 4 4 0 +105 5 5 0 +106 6 6 0 +update test.t1 set d=d+1; +update test.t2 set d=d+1; +update test.t3 set d=d+1; +update test.t1 set d=d+1 where a=101; +update test.t2 set d=d+1 where a=101; +update test.t3 set d=d+1 where a=101; +select * from test.t1 force index(index_b) where b=5; +a b c d +select * from test.t2 force index(index_b) where b=5; +a b c d +select * from test.t3 force index(index_b) where b=5; +a b c d +105 5 5 1 +"================== con1 marker ==================" +"================== Step 3-A ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 25 +user1 wait/lock/table/sql/handler 24 +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 30 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 30 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 32 +localhost wait/lock/table/sql/handler 30 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 32 +wait/lock/table/sql/handler 30 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 4 3 1 3 1 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 3 1 2 1 0 2 0 +TABLE test t2 NULL 7 5 2 5 2 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 3 1 2 1 0 2 0 +TABLE test t3 NULL 10 7 3 7 3 0 0 +TABLE test t3 index_b 1 1 0 1 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 4 1 3 1 0 3 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 7 4 3 4 1 2 0 +TABLE test t2 10 6 4 6 2 2 0 +TABLE test t3 15 9 6 9 3 3 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 9 6 3 0 0 0 0 6 0 3 +TABLE test t2 10 6 4 0 0 0 0 6 0 4 +TABLE test t3 11 6 5 0 0 0 0 6 0 5 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 16 +TABLE test t2 20 +TABLE test t3 26 +flush tables; +"================== con1 FLUSH ==================" +"================== Step 3-B ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 25 +user1 wait/lock/table/sql/handler 24 +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 30 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 30 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 32 +localhost wait/lock/table/sql/handler 30 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 32 +wait/lock/table/sql/handler 30 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 4 3 1 3 1 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 3 1 2 1 0 2 0 +TABLE test t2 NULL 7 5 2 5 2 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 3 1 2 1 0 2 0 +TABLE test t3 NULL 10 7 3 7 3 0 0 +TABLE test t3 index_b 1 1 0 1 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 4 1 3 1 0 3 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 7 4 3 4 1 2 0 +TABLE test t2 10 6 4 6 2 2 0 +TABLE test t3 15 9 6 9 3 3 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 9 6 3 0 0 0 0 6 0 3 +TABLE test t2 10 6 4 0 0 0 0 6 0 4 +TABLE test t3 11 6 5 0 0 0 0 6 0 5 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 16 +TABLE test t2 20 +TABLE test t3 26 +select concat(current_user(), " is connected") as status; +status +user2@localhost is connected +"================== Step 4 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 25 +user1 wait/lock/table/sql/handler 24 +username event_name count_star +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 30 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 30 +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 32 +localhost wait/lock/table/sql/handler 30 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 32 +wait/lock/table/sql/handler 30 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 4 3 1 3 1 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 3 1 2 1 0 2 0 +TABLE test t2 NULL 7 5 2 5 2 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 3 1 2 1 0 2 0 +TABLE test t3 NULL 10 7 3 7 3 0 0 +TABLE test t3 index_b 1 1 0 1 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 4 1 3 1 0 3 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 7 4 3 4 1 2 0 +TABLE test t2 10 6 4 6 2 2 0 +TABLE test t3 15 9 6 9 3 3 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 9 6 3 0 0 0 0 6 0 3 +TABLE test t2 10 6 4 0 0 0 0 6 0 4 +TABLE test t3 11 6 5 0 0 0 0 6 0 5 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 16 +TABLE test t2 20 +TABLE test t3 26 +insert into test.t1 set a=201, b=1, c=1; +insert into test.t2 set a=202, b=2, c=2; +insert into test.t2 set a=203, b=3, c=3; +insert into test.t3 set a=204, b=4, c=4; +insert into test.t3 set a=205, b=5, c=5; +insert into test.t3 set a=206, b=6, c=6; +select * from test.t1; +a b c d +101 1 1 2 +201 1 1 0 +select * from test.t2; +a b c d +102 2 2 1 +103 3 3 1 +202 2 2 0 +203 3 3 0 +select * from test.t3; +a b c d +104 4 4 1 +105 5 5 1 +106 6 6 1 +204 4 4 0 +205 5 5 0 +206 6 6 0 +update test.t1 set d=d+1; +update test.t2 set d=d+1; +update test.t3 set d=d+1; +update test.t1 set d=d+1 where a=201; +update test.t2 set d=d+1 where a=201; +update test.t3 set d=d+1 where a=201; +select * from test.t1 force index(index_b) where b=5; +a b c d +select * from test.t2 force index(index_b) where b=5; +a b c d +select * from test.t3 force index(index_b) where b=5; +a b c d +105 5 5 2 +205 5 5 1 +"================== con2 marker ==================" +"================== Step 5 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 25 +user1 wait/lock/table/sql/handler 24 +username event_name count_star +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 30 +user2 localhost wait/io/table/sql/handler 14 +user2 localhost wait/lock/table/sql/handler 6 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 30 +user2 wait/io/table/sql/handler 14 +user2 wait/lock/table/sql/handler 6 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 46 +localhost wait/lock/table/sql/handler 36 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 46 +wait/lock/table/sql/handler 36 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 6 5 1 5 1 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 3 1 2 1 0 2 0 +TABLE test t2 NULL 11 9 2 9 2 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 3 1 2 1 0 2 0 +TABLE test t3 NULL 16 13 3 13 3 0 0 +TABLE test t3 index_b 3 3 0 3 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 4 1 3 1 0 3 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 9 6 3 6 1 2 0 +TABLE test t2 14 10 4 10 2 2 0 +TABLE test t3 23 17 6 17 3 3 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 11 8 3 0 0 0 0 8 0 3 +TABLE test t2 12 8 4 0 0 0 0 8 0 4 +TABLE test t3 13 8 5 0 0 0 0 8 0 5 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 20 +TABLE test t2 26 +TABLE test t3 36 +select concat(current_user(), " is connected") as status; +status +user3@localhost is connected +"================== Step 6 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 25 +user1 wait/lock/table/sql/handler 24 +username event_name count_star +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 30 +user2 localhost wait/io/table/sql/handler 14 +user2 localhost wait/lock/table/sql/handler 6 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 30 +user2 wait/io/table/sql/handler 14 +user2 wait/lock/table/sql/handler 6 +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 46 +localhost wait/lock/table/sql/handler 36 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 46 +wait/lock/table/sql/handler 36 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 6 5 1 5 1 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 3 1 2 1 0 2 0 +TABLE test t2 NULL 11 9 2 9 2 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 3 1 2 1 0 2 0 +TABLE test t3 NULL 16 13 3 13 3 0 0 +TABLE test t3 index_b 3 3 0 3 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 4 1 3 1 0 3 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 9 6 3 6 1 2 0 +TABLE test t2 14 10 4 10 2 2 0 +TABLE test t3 23 17 6 17 3 3 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 11 8 3 0 0 0 0 8 0 3 +TABLE test t2 12 8 4 0 0 0 0 8 0 4 +TABLE test t3 13 8 5 0 0 0 0 8 0 5 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 20 +TABLE test t2 26 +TABLE test t3 36 +insert into test.t1 set a=301, b=1, c=1; +insert into test.t2 set a=302, b=2, c=2; +insert into test.t2 set a=303, b=3, c=3; +insert into test.t3 set a=304, b=4, c=4; +insert into test.t3 set a=305, b=5, c=5; +insert into test.t3 set a=306, b=6, c=6; +select * from test.t1; +a b c d +101 1 1 3 +201 1 1 2 +301 1 1 0 +select * from test.t2; +a b c d +102 2 2 2 +103 3 3 2 +202 2 2 1 +203 3 3 1 +302 2 2 0 +303 3 3 0 +select * from test.t3; +a b c d +104 4 4 2 +105 5 5 2 +106 6 6 2 +204 4 4 1 +205 5 5 1 +206 6 6 1 +304 4 4 0 +305 5 5 0 +306 6 6 0 +update test.t1 set d=d+1; +update test.t2 set d=d+1; +update test.t3 set d=d+1; +update test.t1 set d=d+1 where a=301; +update test.t2 set d=d+1 where a=301; +update test.t3 set d=d+1 where a=301; +select * from test.t1 force index(index_b) where b=5; +a b c d +select * from test.t2 force index(index_b) where b=5; +a b c d +select * from test.t3 force index(index_b) where b=5; +a b c d +105 5 5 3 +205 5 5 2 +305 5 5 1 +"================== con3 marker ==================" +"================== Step 7 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 25 +user1 wait/lock/table/sql/handler 24 +username event_name count_star +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 49 +user3 wait/lock/table/sql/handler 24 +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 30 +user2 localhost wait/io/table/sql/handler 14 +user2 localhost wait/lock/table/sql/handler 6 +user3 localhost wait/io/table/sql/handler 70 +user3 localhost wait/lock/table/sql/handler 30 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 30 +user2 wait/io/table/sql/handler 14 +user2 wait/lock/table/sql/handler 6 +user3 wait/io/table/sql/handler 70 +user3 wait/lock/table/sql/handler 30 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 116 +localhost wait/lock/table/sql/handler 66 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 116 +wait/lock/table/sql/handler 66 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 14 12 2 12 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 8 2 6 2 0 6 0 +TABLE test t2 NULL 26 22 4 22 4 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 10 2 8 2 0 8 0 +TABLE test t3 NULL 38 32 6 32 6 0 0 +TABLE test t3 index_b 6 6 0 6 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 14 2 12 2 0 12 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 22 14 8 14 2 6 0 +TABLE test t2 36 24 12 24 4 8 0 +TABLE test t3 58 40 18 40 6 12 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 20 14 6 0 0 0 0 14 0 6 +TABLE test t2 22 14 8 0 0 0 0 14 0 8 +TABLE test t3 24 14 10 0 0 0 0 14 0 10 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 42 +TABLE test t2 58 +TABLE test t3 82 +select concat(current_user(), " is connected") as status; +status +user4@localhost is connected +"================== Step 8 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 25 +user1 wait/lock/table/sql/handler 24 +username event_name count_star +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 49 +user3 wait/lock/table/sql/handler 24 +username event_name count_star +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 30 +user2 localhost wait/io/table/sql/handler 14 +user2 localhost wait/lock/table/sql/handler 6 +user3 localhost wait/io/table/sql/handler 70 +user3 localhost wait/lock/table/sql/handler 30 +user4 localhost wait/io/table/sql/handler 0 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 30 +user2 wait/io/table/sql/handler 14 +user2 wait/lock/table/sql/handler 6 +user3 wait/io/table/sql/handler 70 +user3 wait/lock/table/sql/handler 30 +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 116 +localhost wait/lock/table/sql/handler 66 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 116 +wait/lock/table/sql/handler 66 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 14 12 2 12 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 8 2 6 2 0 6 0 +TABLE test t2 NULL 26 22 4 22 4 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 10 2 8 2 0 8 0 +TABLE test t3 NULL 38 32 6 32 6 0 0 +TABLE test t3 index_b 6 6 0 6 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 14 2 12 2 0 12 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 22 14 8 14 2 6 0 +TABLE test t2 36 24 12 24 4 8 0 +TABLE test t3 58 40 18 40 6 12 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 20 14 6 0 0 0 0 14 0 6 +TABLE test t2 22 14 8 0 0 0 0 14 0 8 +TABLE test t3 24 14 10 0 0 0 0 14 0 10 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 42 +TABLE test t2 58 +TABLE test t3 82 +insert into test.t1 set a=401, b=1, c=1; +insert into test.t2 set a=402, b=2, c=2; +insert into test.t2 set a=403, b=3, c=3; +insert into test.t3 set a=404, b=4, c=4; +insert into test.t3 set a=405, b=5, c=5; +insert into test.t3 set a=406, b=6, c=6; +select * from test.t1; +a b c d +101 1 1 4 +201 1 1 3 +301 1 1 2 +401 1 1 0 +select * from test.t2; +a b c d +102 2 2 3 +103 3 3 3 +202 2 2 2 +203 3 3 2 +302 2 2 1 +303 3 3 1 +402 2 2 0 +403 3 3 0 +select * from test.t3; +a b c d +104 4 4 3 +105 5 5 3 +106 6 6 3 +204 4 4 2 +205 5 5 2 +206 6 6 2 +304 4 4 1 +305 5 5 1 +306 6 6 1 +404 4 4 0 +405 5 5 0 +406 6 6 0 +update test.t1 set d=d+1; +update test.t2 set d=d+1; +update test.t3 set d=d+1; +update test.t1 set d=d+1 where a=401; +update test.t2 set d=d+1 where a=401; +update test.t3 set d=d+1 where a=401; +select * from test.t1 force index(index_b) where b=5; +a b c d +select * from test.t2 force index(index_b) where b=5; +a b c d +select * from test.t3 force index(index_b) where b=5; +a b c d +105 5 5 4 +205 5 5 3 +305 5 5 2 +405 5 5 1 +"================== con4 marker ==================" +"================== Step 9 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 25 +user1 wait/lock/table/sql/handler 24 +username event_name count_star +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 49 +user3 wait/lock/table/sql/handler 24 +username event_name count_star +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 30 +user2 localhost wait/io/table/sql/handler 14 +user2 localhost wait/lock/table/sql/handler 6 +user3 localhost wait/io/table/sql/handler 70 +user3 localhost wait/lock/table/sql/handler 30 +user4 localhost wait/io/table/sql/handler 28 +user4 localhost wait/lock/table/sql/handler 6 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 30 +user2 wait/io/table/sql/handler 14 +user2 wait/lock/table/sql/handler 6 +user3 wait/io/table/sql/handler 70 +user3 wait/lock/table/sql/handler 30 +user4 wait/io/table/sql/handler 28 +user4 wait/lock/table/sql/handler 6 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 144 +localhost wait/lock/table/sql/handler 72 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 144 +wait/lock/table/sql/handler 72 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 16 2 16 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 8 2 6 2 0 6 0 +TABLE test t2 NULL 34 30 4 30 4 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 10 2 8 2 0 8 0 +TABLE test t3 NULL 50 44 6 44 6 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 14 2 12 2 0 12 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 26 18 8 18 2 6 0 +TABLE test t2 44 32 12 32 4 8 0 +TABLE test t3 74 56 18 56 6 12 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 22 16 6 0 0 0 0 16 0 6 +TABLE test t2 24 16 8 0 0 0 0 16 0 8 +TABLE test t3 26 16 10 0 0 0 0 16 0 10 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 48 +TABLE test t2 68 +TABLE test t3 100 +lock tables test.t1 read, test.t2 read, test.t3 read; +unlock tables; +lock tables test.t1 write, test.t2 write, test.t3 write; +unlock tables; +"================== con1 marker ==================" +"================== Step 10 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 25 +user1 wait/lock/table/sql/handler 30 +username event_name count_star +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 49 +user3 wait/lock/table/sql/handler 24 +username event_name count_star +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 36 +user2 localhost wait/io/table/sql/handler 14 +user2 localhost wait/lock/table/sql/handler 6 +user3 localhost wait/io/table/sql/handler 70 +user3 localhost wait/lock/table/sql/handler 30 +user4 localhost wait/io/table/sql/handler 28 +user4 localhost wait/lock/table/sql/handler 6 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 36 +user2 wait/io/table/sql/handler 14 +user2 wait/lock/table/sql/handler 6 +user3 wait/io/table/sql/handler 70 +user3 wait/lock/table/sql/handler 30 +user4 wait/io/table/sql/handler 28 +user4 wait/lock/table/sql/handler 6 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 144 +localhost wait/lock/table/sql/handler 78 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 144 +wait/lock/table/sql/handler 78 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 16 2 16 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 8 2 6 2 0 6 0 +TABLE test t2 NULL 34 30 4 30 4 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 10 2 8 2 0 8 0 +TABLE test t3 NULL 50 44 6 44 6 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 14 2 12 2 0 12 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 26 18 8 18 2 6 0 +TABLE test t2 44 32 12 32 4 8 0 +TABLE test t3 74 56 18 56 6 12 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 24 17 7 0 0 0 0 17 0 7 +TABLE test t2 26 17 9 0 0 0 0 17 0 9 +TABLE test t3 28 17 11 0 0 0 0 17 0 11 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 50 +TABLE test t2 70 +TABLE test t3 102 +flush tables; +"================== flush marker ==================" +"================== Step 11 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 25 +user1 wait/lock/table/sql/handler 30 +username event_name count_star +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 49 +user3 wait/lock/table/sql/handler 24 +username event_name count_star +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 36 +user2 localhost wait/io/table/sql/handler 14 +user2 localhost wait/lock/table/sql/handler 6 +user3 localhost wait/io/table/sql/handler 70 +user3 localhost wait/lock/table/sql/handler 30 +user4 localhost wait/io/table/sql/handler 28 +user4 localhost wait/lock/table/sql/handler 6 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 36 +user2 wait/io/table/sql/handler 14 +user2 wait/lock/table/sql/handler 6 +user3 wait/io/table/sql/handler 70 +user3 wait/lock/table/sql/handler 30 +user4 wait/io/table/sql/handler 28 +user4 wait/lock/table/sql/handler 6 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 144 +localhost wait/lock/table/sql/handler 78 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 144 +wait/lock/table/sql/handler 78 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 16 2 16 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 8 2 6 2 0 6 0 +TABLE test t2 NULL 34 30 4 30 4 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 10 2 8 2 0 8 0 +TABLE test t3 NULL 50 44 6 44 6 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 14 2 12 2 0 12 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 26 18 8 18 2 6 0 +TABLE test t2 44 32 12 32 4 8 0 +TABLE test t3 74 56 18 56 6 12 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 24 17 7 0 0 0 0 17 0 7 +TABLE test t2 26 17 9 0 0 0 0 17 0 9 +TABLE test t3 28 17 11 0 0 0 0 17 0 11 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 50 +TABLE test t2 70 +TABLE test t3 102 +set global read_only=1; +set global read_only=0; +"================== global read_only marker ==================" +"================== Step 12 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 25 +user1 wait/lock/table/sql/handler 30 +username event_name count_star +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 49 +user3 wait/lock/table/sql/handler 24 +username event_name count_star +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 36 +user2 localhost wait/io/table/sql/handler 14 +user2 localhost wait/lock/table/sql/handler 6 +user3 localhost wait/io/table/sql/handler 70 +user3 localhost wait/lock/table/sql/handler 30 +user4 localhost wait/io/table/sql/handler 28 +user4 localhost wait/lock/table/sql/handler 6 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 36 +user2 wait/io/table/sql/handler 14 +user2 wait/lock/table/sql/handler 6 +user3 wait/io/table/sql/handler 70 +user3 wait/lock/table/sql/handler 30 +user4 wait/io/table/sql/handler 28 +user4 wait/lock/table/sql/handler 6 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 144 +localhost wait/lock/table/sql/handler 78 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 144 +wait/lock/table/sql/handler 78 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 16 2 16 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 8 2 6 2 0 6 0 +TABLE test t2 NULL 34 30 4 30 4 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 10 2 8 2 0 8 0 +TABLE test t3 NULL 50 44 6 44 6 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 14 2 12 2 0 12 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 26 18 8 18 2 6 0 +TABLE test t2 44 32 12 32 4 8 0 +TABLE test t3 74 56 18 56 6 12 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 24 17 7 0 0 0 0 17 0 7 +TABLE test t2 26 17 9 0 0 0 0 17 0 9 +TABLE test t3 28 17 11 0 0 0 0 17 0 11 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 50 +TABLE test t2 70 +TABLE test t3 102 +"================== con1 disconnected ==================" +"================== Step 13 ==================" +call dump_thread(); +username status +user1 not found +username event_name count_star +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 49 +user3 wait/lock/table/sql/handler 24 +username event_name count_star +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 36 +user2 localhost wait/io/table/sql/handler 14 +user2 localhost wait/lock/table/sql/handler 6 +user3 localhost wait/io/table/sql/handler 70 +user3 localhost wait/lock/table/sql/handler 30 +user4 localhost wait/io/table/sql/handler 28 +user4 localhost wait/lock/table/sql/handler 6 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 36 +user2 wait/io/table/sql/handler 14 +user2 wait/lock/table/sql/handler 6 +user3 wait/io/table/sql/handler 70 +user3 wait/lock/table/sql/handler 30 +user4 wait/io/table/sql/handler 28 +user4 wait/lock/table/sql/handler 6 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 144 +localhost wait/lock/table/sql/handler 78 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 144 +wait/lock/table/sql/handler 78 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 16 2 16 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 8 2 6 2 0 6 0 +TABLE test t2 NULL 34 30 4 30 4 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 10 2 8 2 0 8 0 +TABLE test t3 NULL 50 44 6 44 6 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 14 2 12 2 0 12 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 26 18 8 18 2 6 0 +TABLE test t2 44 32 12 32 4 8 0 +TABLE test t3 74 56 18 56 6 12 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 24 17 7 0 0 0 0 17 0 7 +TABLE test t2 26 17 9 0 0 0 0 17 0 9 +TABLE test t3 28 17 11 0 0 0 0 17 0 11 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 50 +TABLE test t2 70 +TABLE test t3 102 +"================== con2 disconnected ==================" +"================== Step 14 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username event_name count_star +user3 wait/io/table/sql/handler 49 +user3 wait/lock/table/sql/handler 24 +username event_name count_star +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 36 +user2 localhost wait/io/table/sql/handler 14 +user2 localhost wait/lock/table/sql/handler 6 +user3 localhost wait/io/table/sql/handler 70 +user3 localhost wait/lock/table/sql/handler 30 +user4 localhost wait/io/table/sql/handler 28 +user4 localhost wait/lock/table/sql/handler 6 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 36 +user2 wait/io/table/sql/handler 14 +user2 wait/lock/table/sql/handler 6 +user3 wait/io/table/sql/handler 70 +user3 wait/lock/table/sql/handler 30 +user4 wait/io/table/sql/handler 28 +user4 wait/lock/table/sql/handler 6 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 144 +localhost wait/lock/table/sql/handler 78 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 144 +wait/lock/table/sql/handler 78 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 16 2 16 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 8 2 6 2 0 6 0 +TABLE test t2 NULL 34 30 4 30 4 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 10 2 8 2 0 8 0 +TABLE test t3 NULL 50 44 6 44 6 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 14 2 12 2 0 12 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 26 18 8 18 2 6 0 +TABLE test t2 44 32 12 32 4 8 0 +TABLE test t3 74 56 18 56 6 12 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 24 17 7 0 0 0 0 17 0 7 +TABLE test t2 26 17 9 0 0 0 0 17 0 9 +TABLE test t3 28 17 11 0 0 0 0 17 0 11 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 50 +TABLE test t2 70 +TABLE test t3 102 +"================== con3 disconnected ==================" +"================== Step 15 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username event_name count_star +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 36 +user2 localhost wait/io/table/sql/handler 14 +user2 localhost wait/lock/table/sql/handler 6 +user3 localhost wait/io/table/sql/handler 70 +user3 localhost wait/lock/table/sql/handler 30 +user4 localhost wait/io/table/sql/handler 28 +user4 localhost wait/lock/table/sql/handler 6 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 36 +user2 wait/io/table/sql/handler 14 +user2 wait/lock/table/sql/handler 6 +user3 wait/io/table/sql/handler 70 +user3 wait/lock/table/sql/handler 30 +user4 wait/io/table/sql/handler 28 +user4 wait/lock/table/sql/handler 6 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 144 +localhost wait/lock/table/sql/handler 78 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 144 +wait/lock/table/sql/handler 78 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 16 2 16 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 8 2 6 2 0 6 0 +TABLE test t2 NULL 34 30 4 30 4 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 10 2 8 2 0 8 0 +TABLE test t3 NULL 50 44 6 44 6 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 14 2 12 2 0 12 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 26 18 8 18 2 6 0 +TABLE test t2 44 32 12 32 4 8 0 +TABLE test t3 74 56 18 56 6 12 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 24 17 7 0 0 0 0 17 0 7 +TABLE test t2 26 17 9 0 0 0 0 17 0 9 +TABLE test t3 28 17 11 0 0 0 0 17 0 11 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 50 +TABLE test t2 70 +TABLE test t3 102 +"================== con4 disconnected ==================" +"================== Step 16 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 36 +user2 localhost wait/io/table/sql/handler 14 +user2 localhost wait/lock/table/sql/handler 6 +user3 localhost wait/io/table/sql/handler 70 +user3 localhost wait/lock/table/sql/handler 30 +user4 localhost wait/io/table/sql/handler 28 +user4 localhost wait/lock/table/sql/handler 6 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 36 +user2 wait/io/table/sql/handler 14 +user2 wait/lock/table/sql/handler 6 +user3 wait/io/table/sql/handler 70 +user3 wait/lock/table/sql/handler 30 +user4 wait/io/table/sql/handler 28 +user4 wait/lock/table/sql/handler 6 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 144 +localhost wait/lock/table/sql/handler 78 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 144 +wait/lock/table/sql/handler 78 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 16 2 16 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 8 2 6 2 0 6 0 +TABLE test t2 NULL 34 30 4 30 4 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 10 2 8 2 0 8 0 +TABLE test t3 NULL 50 44 6 44 6 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 14 2 12 2 0 12 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 26 18 8 18 2 6 0 +TABLE test t2 44 32 12 32 4 8 0 +TABLE test t3 74 56 18 56 6 12 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 24 17 7 0 0 0 0 17 0 7 +TABLE test t2 26 17 9 0 0 0 0 17 0 9 +TABLE test t3 28 17 11 0 0 0 0 17 0 11 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 50 +TABLE test t2 70 +TABLE test t3 102 +truncate performance_schema.events_waits_summary_by_thread_by_event_name; +"================== BY_THREAD truncated ==================" +"================== Step 17 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 36 +user2 localhost wait/io/table/sql/handler 14 +user2 localhost wait/lock/table/sql/handler 6 +user3 localhost wait/io/table/sql/handler 70 +user3 localhost wait/lock/table/sql/handler 30 +user4 localhost wait/io/table/sql/handler 28 +user4 localhost wait/lock/table/sql/handler 6 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 36 +user2 wait/io/table/sql/handler 14 +user2 wait/lock/table/sql/handler 6 +user3 wait/io/table/sql/handler 70 +user3 wait/lock/table/sql/handler 30 +user4 wait/io/table/sql/handler 28 +user4 wait/lock/table/sql/handler 6 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 144 +localhost wait/lock/table/sql/handler 78 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 144 +wait/lock/table/sql/handler 78 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 16 2 16 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 8 2 6 2 0 6 0 +TABLE test t2 NULL 34 30 4 30 4 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 10 2 8 2 0 8 0 +TABLE test t3 NULL 50 44 6 44 6 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 14 2 12 2 0 12 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 26 18 8 18 2 6 0 +TABLE test t2 44 32 12 32 4 8 0 +TABLE test t3 74 56 18 56 6 12 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 24 17 7 0 0 0 0 17 0 7 +TABLE test t2 26 17 9 0 0 0 0 17 0 9 +TABLE test t3 28 17 11 0 0 0 0 17 0 11 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 50 +TABLE test t2 70 +TABLE test t3 102 +truncate performance_schema.events_waits_summary_by_account_by_event_name; +"================== BY_ACCOUNT truncated ==================" +"================== Step 18 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 0 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 36 +user2 wait/io/table/sql/handler 14 +user2 wait/lock/table/sql/handler 6 +user3 wait/io/table/sql/handler 70 +user3 wait/lock/table/sql/handler 30 +user4 wait/io/table/sql/handler 28 +user4 wait/lock/table/sql/handler 6 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 144 +localhost wait/lock/table/sql/handler 78 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 144 +wait/lock/table/sql/handler 78 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 16 2 16 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 8 2 6 2 0 6 0 +TABLE test t2 NULL 34 30 4 30 4 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 10 2 8 2 0 8 0 +TABLE test t3 NULL 50 44 6 44 6 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 14 2 12 2 0 12 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 26 18 8 18 2 6 0 +TABLE test t2 44 32 12 32 4 8 0 +TABLE test t3 74 56 18 56 6 12 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 24 17 7 0 0 0 0 17 0 7 +TABLE test t2 26 17 9 0 0 0 0 17 0 9 +TABLE test t3 28 17 11 0 0 0 0 17 0 11 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 50 +TABLE test t2 70 +TABLE test t3 102 +truncate performance_schema.events_waits_summary_by_user_by_event_name; +"================== BY_USER truncated ==================" +"================== Step 19 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 0 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 144 +localhost wait/lock/table/sql/handler 78 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 144 +wait/lock/table/sql/handler 78 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 16 2 16 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 8 2 6 2 0 6 0 +TABLE test t2 NULL 34 30 4 30 4 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 10 2 8 2 0 8 0 +TABLE test t3 NULL 50 44 6 44 6 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 14 2 12 2 0 12 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 26 18 8 18 2 6 0 +TABLE test t2 44 32 12 32 4 8 0 +TABLE test t3 74 56 18 56 6 12 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 24 17 7 0 0 0 0 17 0 7 +TABLE test t2 26 17 9 0 0 0 0 17 0 9 +TABLE test t3 28 17 11 0 0 0 0 17 0 11 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 50 +TABLE test t2 70 +TABLE test t3 102 +truncate performance_schema.events_waits_summary_by_host_by_event_name; +"================== BY_HOST truncated ==================" +"================== Step 21 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 0 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 144 +wait/lock/table/sql/handler 78 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 16 2 16 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 8 2 6 2 0 6 0 +TABLE test t2 NULL 34 30 4 30 4 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 10 2 8 2 0 8 0 +TABLE test t3 NULL 50 44 6 44 6 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 14 2 12 2 0 12 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 26 18 8 18 2 6 0 +TABLE test t2 44 32 12 32 4 8 0 +TABLE test t3 74 56 18 56 6 12 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 24 17 7 0 0 0 0 17 0 7 +TABLE test t2 26 17 9 0 0 0 0 17 0 9 +TABLE test t3 28 17 11 0 0 0 0 17 0 11 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 50 +TABLE test t2 70 +TABLE test t3 102 +truncate performance_schema.events_waits_summary_global_by_event_name; +"================== GLOBAL truncated ==================" +"================== Step 21 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 0 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 0 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 0 0 0 0 0 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 0 0 0 0 0 0 0 +TABLE test t2 NULL 0 0 0 0 0 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 0 0 0 0 0 0 0 +TABLE test t3 index_b 0 0 0 0 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 0 0 0 0 0 0 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 0 +TABLE test t2 0 +TABLE test t3 0 +show global status like "performance_schema%table%_lost"; +Variable_name Value +Performance_schema_table_handles_lost 0 +Performance_schema_table_instances_lost 0 +Performance_schema_table_lock_stat_lost 0 diff --git a/mysql-test/suite/table_aggregate_thread_4u_2t.result-pq b/mysql-test/suite/table_aggregate_thread_4u_2t.result-pq new file mode 100644 index 000000000000..4b88cd545b40 --- /dev/null +++ b/mysql-test/suite/table_aggregate_thread_4u_2t.result-pq @@ -0,0 +1,1722 @@ +update performance_schema.setup_consumers +set enabled='NO' where name like 'event%'; +delete from performance_schema.setup_objects +where object_name='t2'; +select * from performance_schema.setup_actors +order by USER, HOST, `ROLE`; +HOST USER ROLE ENABLED HISTORY +localhost user1 % YES YES +localhost user2 % YES YES +localhost user3 % YES YES +localhost user4 % YES YES +select * from performance_schema.setup_objects +order by object_type, object_schema, object_name; +OBJECT_TYPE OBJECT_SCHEMA OBJECT_NAME ENABLED TIMED +TABLE test t1 YES YES +TABLE test t3 YES NO +select * from performance_schema.setup_consumers; +NAME ENABLED +events_stages_current NO +events_stages_history NO +events_stages_history_long NO +events_statements_current NO +events_statements_history NO +events_statements_history_long NO +events_transactions_current NO +events_transactions_history NO +events_transactions_history_long NO +events_waits_current NO +events_waits_history NO +events_waits_history_long NO +global_instrumentation YES +thread_instrumentation YES +statements_digest YES +flush tables; +truncate performance_schema.objects_summary_global_by_type; +truncate performance_schema.table_io_waits_summary_by_index_usage; +truncate performance_schema.table_io_waits_summary_by_table; +truncate performance_schema.table_lock_waits_summary_by_table; +truncate performance_schema.events_waits_summary_by_thread_by_event_name; +truncate performance_schema.events_waits_summary_by_account_by_event_name; +truncate performance_schema.events_waits_summary_by_user_by_event_name; +truncate performance_schema.events_waits_summary_by_host_by_event_name; +truncate performance_schema.events_waits_summary_global_by_event_name; +truncate performance_schema.events_waits_history_long; +show global variables like "performance_schema%table%"; +Variable_name Value +performance_schema_max_table_handles -1 +performance_schema_max_table_instances -1 +performance_schema_max_table_lock_stat -1 +show global status like "performance_schema%table%_lost"; +Variable_name Value +Performance_schema_table_handles_lost 0 +Performance_schema_table_instances_lost 0 +Performance_schema_table_lock_stat_lost 0 +"================== Step 1 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +execute dump_waits_user; +user event_name count_star +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 0 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 0 0 0 0 0 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 index_b 0 0 0 0 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 0 0 0 0 0 0 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 0 +TABLE test t2 0 +TABLE test t3 0 +select concat(current_user(), " is connected") as status; +status +user1@localhost is connected +"================== Step 2 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 0 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 0 0 0 0 0 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 index_b 0 0 0 0 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 0 0 0 0 0 0 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 0 +TABLE test t2 0 +TABLE test t3 0 +insert into test.t1 set a=101, b=1, c=1; +insert into test.t2 set a=102, b=2, c=2; +insert into test.t2 set a=103, b=3, c=3; +insert into test.t3 set a=104, b=4, c=4; +insert into test.t3 set a=105, b=5, c=5; +insert into test.t3 set a=106, b=6, c=6; +select * from test.t1; +a b c d +101 1 1 0 +select * from test.t2; +a b c d +102 2 2 0 +103 3 3 0 +select * from test.t3; +a b c d +104 4 4 0 +105 5 5 0 +106 6 6 0 +update test.t1 set d=d+1; +update test.t2 set d=d+1; +update test.t3 set d=d+1; +update test.t1 set d=d+1 where a=101; +update test.t2 set d=d+1 where a=101; +update test.t3 set d=d+1 where a=101; +select * from test.t1 force index(index_b) where b=5; +a b c d +select * from test.t2 force index(index_b) where b=5; +a b c d +select * from test.t3 force index(index_b) where b=5; +a b c d +105 5 5 1 +"================== con1 marker ==================" +"================== Step 3-A ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 17 +user1 wait/lock/table/sql/handler 16 +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 20 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 20 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 22 +localhost wait/lock/table/sql/handler 20 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 22 +wait/lock/table/sql/handler 20 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 4 3 1 3 1 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 3 1 2 1 0 2 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 10 7 3 7 3 0 0 +TABLE test t3 index_b 1 1 0 1 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 4 1 3 1 0 3 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 7 4 3 4 1 2 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 15 9 6 9 3 3 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 9 6 3 0 0 0 0 6 0 3 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 11 6 5 0 0 0 0 6 0 5 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 16 +TABLE test t2 0 +TABLE test t3 26 +flush tables; +"================== con1 FLUSH ==================" +"================== Step 3-B ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 17 +user1 wait/lock/table/sql/handler 16 +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 20 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 20 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 22 +localhost wait/lock/table/sql/handler 20 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 22 +wait/lock/table/sql/handler 20 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 4 3 1 3 1 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 3 1 2 1 0 2 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 10 7 3 7 3 0 0 +TABLE test t3 index_b 1 1 0 1 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 4 1 3 1 0 3 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 7 4 3 4 1 2 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 15 9 6 9 3 3 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 9 6 3 0 0 0 0 6 0 3 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 11 6 5 0 0 0 0 6 0 5 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 16 +TABLE test t2 0 +TABLE test t3 26 +select concat(current_user(), " is connected") as status; +status +user2@localhost is connected +"================== Step 4 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 17 +user1 wait/lock/table/sql/handler 16 +username event_name count_star +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 20 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 20 +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 22 +localhost wait/lock/table/sql/handler 20 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 22 +wait/lock/table/sql/handler 20 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 4 3 1 3 1 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 3 1 2 1 0 2 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 10 7 3 7 3 0 0 +TABLE test t3 index_b 1 1 0 1 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 4 1 3 1 0 3 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 7 4 3 4 1 2 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 15 9 6 9 3 3 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 9 6 3 0 0 0 0 6 0 3 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 11 6 5 0 0 0 0 6 0 5 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 16 +TABLE test t2 0 +TABLE test t3 26 +insert into test.t1 set a=201, b=1, c=1; +insert into test.t2 set a=202, b=2, c=2; +insert into test.t2 set a=203, b=3, c=3; +insert into test.t3 set a=204, b=4, c=4; +insert into test.t3 set a=205, b=5, c=5; +insert into test.t3 set a=206, b=6, c=6; +select * from test.t1; +a b c d +101 1 1 2 +201 1 1 0 +select * from test.t2; +a b c d +102 2 2 1 +103 3 3 1 +202 2 2 0 +203 3 3 0 +select * from test.t3; +a b c d +104 4 4 1 +105 5 5 1 +106 6 6 1 +204 4 4 0 +205 5 5 0 +206 6 6 0 +update test.t1 set d=d+1; +update test.t2 set d=d+1; +update test.t3 set d=d+1; +update test.t1 set d=d+1 where a=201; +update test.t2 set d=d+1 where a=201; +update test.t3 set d=d+1 where a=201; +select * from test.t1 force index(index_b) where b=5; +a b c d +select * from test.t2 force index(index_b) where b=5; +a b c d +select * from test.t3 force index(index_b) where b=5; +a b c d +105 5 5 2 +205 5 5 1 +"================== con2 marker ==================" +"================== Step 5 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 17 +user1 wait/lock/table/sql/handler 16 +username event_name count_star +user2 wait/io/table/sql/handler 25 +user2 wait/lock/table/sql/handler 16 +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 20 +user2 localhost wait/io/table/sql/handler 35 +user2 localhost wait/lock/table/sql/handler 20 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 20 +user2 wait/io/table/sql/handler 35 +user2 wait/lock/table/sql/handler 20 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 57 +localhost wait/lock/table/sql/handler 40 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 57 +wait/lock/table/sql/handler 40 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 10 8 2 8 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 7 2 5 2 0 5 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 26 20 6 20 6 0 0 +TABLE test t3 index_b 3 3 0 3 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 11 2 9 2 0 9 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 17 10 7 10 2 5 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 40 25 15 25 6 9 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 18 12 6 0 0 0 0 12 0 6 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 22 12 10 0 0 0 0 12 0 10 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 35 +TABLE test t2 0 +TABLE test t3 62 +select concat(current_user(), " is connected") as status; +status +user3@localhost is connected +"================== Step 6 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 17 +user1 wait/lock/table/sql/handler 16 +username event_name count_star +user2 wait/io/table/sql/handler 25 +user2 wait/lock/table/sql/handler 16 +username event_name count_star +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 20 +user2 localhost wait/io/table/sql/handler 35 +user2 localhost wait/lock/table/sql/handler 20 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 20 +user2 wait/io/table/sql/handler 35 +user2 wait/lock/table/sql/handler 20 +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 57 +localhost wait/lock/table/sql/handler 40 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 57 +wait/lock/table/sql/handler 40 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 10 8 2 8 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 7 2 5 2 0 5 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 26 20 6 20 6 0 0 +TABLE test t3 index_b 3 3 0 3 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 11 2 9 2 0 9 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 17 10 7 10 2 5 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 40 25 15 25 6 9 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 18 12 6 0 0 0 0 12 0 6 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 22 12 10 0 0 0 0 12 0 10 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 35 +TABLE test t2 0 +TABLE test t3 62 +insert into test.t1 set a=301, b=1, c=1; +insert into test.t2 set a=302, b=2, c=2; +insert into test.t2 set a=303, b=3, c=3; +insert into test.t3 set a=304, b=4, c=4; +insert into test.t3 set a=305, b=5, c=5; +insert into test.t3 set a=306, b=6, c=6; +select * from test.t1; +a b c d +101 1 1 3 +201 1 1 2 +301 1 1 0 +select * from test.t2; +a b c d +102 2 2 2 +103 3 3 2 +202 2 2 1 +203 3 3 1 +302 2 2 0 +303 3 3 0 +select * from test.t3; +a b c d +104 4 4 2 +105 5 5 2 +106 6 6 2 +204 4 4 1 +205 5 5 1 +206 6 6 1 +304 4 4 0 +305 5 5 0 +306 6 6 0 +update test.t1 set d=d+1; +update test.t2 set d=d+1; +update test.t3 set d=d+1; +update test.t1 set d=d+1 where a=301; +update test.t2 set d=d+1 where a=301; +update test.t3 set d=d+1 where a=301; +select * from test.t1 force index(index_b) where b=5; +a b c d +select * from test.t2 force index(index_b) where b=5; +a b c d +select * from test.t3 force index(index_b) where b=5; +a b c d +105 5 5 3 +205 5 5 2 +305 5 5 1 +"================== con3 marker ==================" +"================== Step 7 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 17 +user1 wait/lock/table/sql/handler 16 +username event_name count_star +user2 wait/io/table/sql/handler 25 +user2 wait/lock/table/sql/handler 16 +username event_name count_star +user3 wait/io/table/sql/handler 33 +user3 wait/lock/table/sql/handler 16 +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 20 +user2 localhost wait/io/table/sql/handler 35 +user2 localhost wait/lock/table/sql/handler 20 +user3 localhost wait/io/table/sql/handler 48 +user3 localhost wait/lock/table/sql/handler 20 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 20 +user2 wait/io/table/sql/handler 35 +user2 wait/lock/table/sql/handler 20 +user3 wait/io/table/sql/handler 48 +user3 wait/lock/table/sql/handler 20 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 105 +localhost wait/lock/table/sql/handler 60 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 105 +wait/lock/table/sql/handler 60 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 15 3 15 3 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 12 3 9 3 0 9 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 48 39 9 39 9 0 0 +TABLE test t3 index_b 6 6 0 6 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 21 3 18 3 0 18 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 30 18 12 18 3 9 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 75 48 27 48 9 18 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 27 18 9 0 0 0 0 18 0 9 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 33 18 15 0 0 0 0 18 0 15 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 57 +TABLE test t2 0 +TABLE test t3 108 +select concat(current_user(), " is connected") as status; +status +user4@localhost is connected +"================== Step 8 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 17 +user1 wait/lock/table/sql/handler 16 +username event_name count_star +user2 wait/io/table/sql/handler 25 +user2 wait/lock/table/sql/handler 16 +username event_name count_star +user3 wait/io/table/sql/handler 33 +user3 wait/lock/table/sql/handler 16 +username event_name count_star +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 20 +user2 localhost wait/io/table/sql/handler 35 +user2 localhost wait/lock/table/sql/handler 20 +user3 localhost wait/io/table/sql/handler 48 +user3 localhost wait/lock/table/sql/handler 20 +user4 localhost wait/io/table/sql/handler 0 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 20 +user2 wait/io/table/sql/handler 35 +user2 wait/lock/table/sql/handler 20 +user3 wait/io/table/sql/handler 48 +user3 wait/lock/table/sql/handler 20 +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 105 +localhost wait/lock/table/sql/handler 60 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 105 +wait/lock/table/sql/handler 60 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 15 3 15 3 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 12 3 9 3 0 9 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 48 39 9 39 9 0 0 +TABLE test t3 index_b 6 6 0 6 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 21 3 18 3 0 18 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 30 18 12 18 3 9 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 75 48 27 48 9 18 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 27 18 9 0 0 0 0 18 0 9 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 33 18 15 0 0 0 0 18 0 15 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 57 +TABLE test t2 0 +TABLE test t3 108 +insert into test.t1 set a=401, b=1, c=1; +insert into test.t2 set a=402, b=2, c=2; +insert into test.t2 set a=403, b=3, c=3; +insert into test.t3 set a=404, b=4, c=4; +insert into test.t3 set a=405, b=5, c=5; +insert into test.t3 set a=406, b=6, c=6; +select * from test.t1; +a b c d +101 1 1 4 +201 1 1 3 +301 1 1 2 +401 1 1 0 +select * from test.t2; +a b c d +102 2 2 3 +103 3 3 3 +202 2 2 2 +203 3 3 2 +302 2 2 1 +303 3 3 1 +402 2 2 0 +403 3 3 0 +select * from test.t3; +a b c d +104 4 4 3 +105 5 5 3 +106 6 6 3 +204 4 4 2 +205 5 5 2 +206 6 6 2 +304 4 4 1 +305 5 5 1 +306 6 6 1 +404 4 4 0 +405 5 5 0 +406 6 6 0 +update test.t1 set d=d+1; +update test.t2 set d=d+1; +update test.t3 set d=d+1; +update test.t1 set d=d+1 where a=401; +update test.t2 set d=d+1 where a=401; +update test.t3 set d=d+1 where a=401; +select * from test.t1 force index(index_b) where b=5; +a b c d +select * from test.t2 force index(index_b) where b=5; +a b c d +select * from test.t3 force index(index_b) where b=5; +a b c d +105 5 5 4 +205 5 5 3 +305 5 5 2 +405 5 5 1 +"================== con4 marker ==================" +"================== Step 9 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 17 +user1 wait/lock/table/sql/handler 16 +username event_name count_star +user2 wait/io/table/sql/handler 25 +user2 wait/lock/table/sql/handler 16 +username event_name count_star +user3 wait/io/table/sql/handler 33 +user3 wait/lock/table/sql/handler 16 +username event_name count_star +user4 wait/io/table/sql/handler 41 +user4 wait/lock/table/sql/handler 16 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 20 +user2 localhost wait/io/table/sql/handler 35 +user2 localhost wait/lock/table/sql/handler 20 +user3 localhost wait/io/table/sql/handler 48 +user3 localhost wait/lock/table/sql/handler 20 +user4 localhost wait/io/table/sql/handler 61 +user4 localhost wait/lock/table/sql/handler 20 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 20 +user2 wait/io/table/sql/handler 35 +user2 wait/lock/table/sql/handler 20 +user3 wait/io/table/sql/handler 48 +user3 wait/lock/table/sql/handler 20 +user4 wait/io/table/sql/handler 61 +user4 wait/lock/table/sql/handler 20 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 166 +localhost wait/lock/table/sql/handler 80 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 166 +wait/lock/table/sql/handler 80 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 36 24 12 0 0 0 0 24 0 12 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 44 24 20 0 0 0 0 24 0 20 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 82 +TABLE test t2 0 +TABLE test t3 164 +lock tables test.t1 read, test.t2 read, test.t3 read; +unlock tables; +lock tables test.t1 write, test.t2 write, test.t3 write; +unlock tables; +"================== con1 marker ==================" +"================== Step 10 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 17 +user1 wait/lock/table/sql/handler 20 +username event_name count_star +user2 wait/io/table/sql/handler 25 +user2 wait/lock/table/sql/handler 16 +username event_name count_star +user3 wait/io/table/sql/handler 33 +user3 wait/lock/table/sql/handler 16 +username event_name count_star +user4 wait/io/table/sql/handler 41 +user4 wait/lock/table/sql/handler 16 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 24 +user2 localhost wait/io/table/sql/handler 35 +user2 localhost wait/lock/table/sql/handler 20 +user3 localhost wait/io/table/sql/handler 48 +user3 localhost wait/lock/table/sql/handler 20 +user4 localhost wait/io/table/sql/handler 61 +user4 localhost wait/lock/table/sql/handler 20 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 24 +user2 wait/io/table/sql/handler 35 +user2 wait/lock/table/sql/handler 20 +user3 wait/io/table/sql/handler 48 +user3 wait/lock/table/sql/handler 20 +user4 wait/io/table/sql/handler 61 +user4 wait/lock/table/sql/handler 20 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 166 +localhost wait/lock/table/sql/handler 84 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 166 +wait/lock/table/sql/handler 84 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 38 25 13 0 0 0 0 25 0 13 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 46 25 21 0 0 0 0 25 0 21 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 84 +TABLE test t2 0 +TABLE test t3 166 +flush tables; +"================== flush marker ==================" +"================== Step 11 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 17 +user1 wait/lock/table/sql/handler 20 +username event_name count_star +user2 wait/io/table/sql/handler 25 +user2 wait/lock/table/sql/handler 16 +username event_name count_star +user3 wait/io/table/sql/handler 33 +user3 wait/lock/table/sql/handler 16 +username event_name count_star +user4 wait/io/table/sql/handler 41 +user4 wait/lock/table/sql/handler 16 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 24 +user2 localhost wait/io/table/sql/handler 35 +user2 localhost wait/lock/table/sql/handler 20 +user3 localhost wait/io/table/sql/handler 48 +user3 localhost wait/lock/table/sql/handler 20 +user4 localhost wait/io/table/sql/handler 61 +user4 localhost wait/lock/table/sql/handler 20 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 24 +user2 wait/io/table/sql/handler 35 +user2 wait/lock/table/sql/handler 20 +user3 wait/io/table/sql/handler 48 +user3 wait/lock/table/sql/handler 20 +user4 wait/io/table/sql/handler 61 +user4 wait/lock/table/sql/handler 20 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 166 +localhost wait/lock/table/sql/handler 84 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 166 +wait/lock/table/sql/handler 84 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 38 25 13 0 0 0 0 25 0 13 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 46 25 21 0 0 0 0 25 0 21 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 84 +TABLE test t2 0 +TABLE test t3 166 +set global read_only=1; +set global read_only=0; +"================== global read_only marker ==================" +"================== Step 12 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 17 +user1 wait/lock/table/sql/handler 20 +username event_name count_star +user2 wait/io/table/sql/handler 25 +user2 wait/lock/table/sql/handler 16 +username event_name count_star +user3 wait/io/table/sql/handler 33 +user3 wait/lock/table/sql/handler 16 +username event_name count_star +user4 wait/io/table/sql/handler 41 +user4 wait/lock/table/sql/handler 16 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 24 +user2 localhost wait/io/table/sql/handler 35 +user2 localhost wait/lock/table/sql/handler 20 +user3 localhost wait/io/table/sql/handler 48 +user3 localhost wait/lock/table/sql/handler 20 +user4 localhost wait/io/table/sql/handler 61 +user4 localhost wait/lock/table/sql/handler 20 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 24 +user2 wait/io/table/sql/handler 35 +user2 wait/lock/table/sql/handler 20 +user3 wait/io/table/sql/handler 48 +user3 wait/lock/table/sql/handler 20 +user4 wait/io/table/sql/handler 61 +user4 wait/lock/table/sql/handler 20 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 166 +localhost wait/lock/table/sql/handler 84 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 166 +wait/lock/table/sql/handler 84 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 38 25 13 0 0 0 0 25 0 13 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 46 25 21 0 0 0 0 25 0 21 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 84 +TABLE test t2 0 +TABLE test t3 166 +"================== con1 disconnected ==================" +"================== Step 13 ==================" +call dump_thread(); +username status +user1 not found +username event_name count_star +user2 wait/io/table/sql/handler 25 +user2 wait/lock/table/sql/handler 16 +username event_name count_star +user3 wait/io/table/sql/handler 33 +user3 wait/lock/table/sql/handler 16 +username event_name count_star +user4 wait/io/table/sql/handler 41 +user4 wait/lock/table/sql/handler 16 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 24 +user2 localhost wait/io/table/sql/handler 35 +user2 localhost wait/lock/table/sql/handler 20 +user3 localhost wait/io/table/sql/handler 48 +user3 localhost wait/lock/table/sql/handler 20 +user4 localhost wait/io/table/sql/handler 61 +user4 localhost wait/lock/table/sql/handler 20 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 24 +user2 wait/io/table/sql/handler 35 +user2 wait/lock/table/sql/handler 20 +user3 wait/io/table/sql/handler 48 +user3 wait/lock/table/sql/handler 20 +user4 wait/io/table/sql/handler 61 +user4 wait/lock/table/sql/handler 20 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 166 +localhost wait/lock/table/sql/handler 84 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 166 +wait/lock/table/sql/handler 84 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 38 25 13 0 0 0 0 25 0 13 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 46 25 21 0 0 0 0 25 0 21 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 84 +TABLE test t2 0 +TABLE test t3 166 +"================== con2 disconnected ==================" +"================== Step 14 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username event_name count_star +user3 wait/io/table/sql/handler 33 +user3 wait/lock/table/sql/handler 16 +username event_name count_star +user4 wait/io/table/sql/handler 41 +user4 wait/lock/table/sql/handler 16 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 24 +user2 localhost wait/io/table/sql/handler 35 +user2 localhost wait/lock/table/sql/handler 20 +user3 localhost wait/io/table/sql/handler 48 +user3 localhost wait/lock/table/sql/handler 20 +user4 localhost wait/io/table/sql/handler 61 +user4 localhost wait/lock/table/sql/handler 20 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 24 +user2 wait/io/table/sql/handler 35 +user2 wait/lock/table/sql/handler 20 +user3 wait/io/table/sql/handler 48 +user3 wait/lock/table/sql/handler 20 +user4 wait/io/table/sql/handler 61 +user4 wait/lock/table/sql/handler 20 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 166 +localhost wait/lock/table/sql/handler 84 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 166 +wait/lock/table/sql/handler 84 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 38 25 13 0 0 0 0 25 0 13 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 46 25 21 0 0 0 0 25 0 21 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 84 +TABLE test t2 0 +TABLE test t3 166 +"================== con3 disconnected ==================" +"================== Step 15 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username event_name count_star +user4 wait/io/table/sql/handler 41 +user4 wait/lock/table/sql/handler 16 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 24 +user2 localhost wait/io/table/sql/handler 35 +user2 localhost wait/lock/table/sql/handler 20 +user3 localhost wait/io/table/sql/handler 48 +user3 localhost wait/lock/table/sql/handler 20 +user4 localhost wait/io/table/sql/handler 61 +user4 localhost wait/lock/table/sql/handler 20 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 24 +user2 wait/io/table/sql/handler 35 +user2 wait/lock/table/sql/handler 20 +user3 wait/io/table/sql/handler 48 +user3 wait/lock/table/sql/handler 20 +user4 wait/io/table/sql/handler 61 +user4 wait/lock/table/sql/handler 20 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 166 +localhost wait/lock/table/sql/handler 84 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 166 +wait/lock/table/sql/handler 84 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 38 25 13 0 0 0 0 25 0 13 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 46 25 21 0 0 0 0 25 0 21 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 84 +TABLE test t2 0 +TABLE test t3 166 +"================== con4 disconnected ==================" +"================== Step 16 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 24 +user2 localhost wait/io/table/sql/handler 35 +user2 localhost wait/lock/table/sql/handler 20 +user3 localhost wait/io/table/sql/handler 48 +user3 localhost wait/lock/table/sql/handler 20 +user4 localhost wait/io/table/sql/handler 61 +user4 localhost wait/lock/table/sql/handler 20 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 24 +user2 wait/io/table/sql/handler 35 +user2 wait/lock/table/sql/handler 20 +user3 wait/io/table/sql/handler 48 +user3 wait/lock/table/sql/handler 20 +user4 wait/io/table/sql/handler 61 +user4 wait/lock/table/sql/handler 20 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 166 +localhost wait/lock/table/sql/handler 84 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 166 +wait/lock/table/sql/handler 84 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 38 25 13 0 0 0 0 25 0 13 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 46 25 21 0 0 0 0 25 0 21 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 84 +TABLE test t2 0 +TABLE test t3 166 +truncate performance_schema.events_waits_summary_by_thread_by_event_name; +"================== BY_THREAD truncated ==================" +"================== Step 17 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 24 +user2 localhost wait/io/table/sql/handler 35 +user2 localhost wait/lock/table/sql/handler 20 +user3 localhost wait/io/table/sql/handler 48 +user3 localhost wait/lock/table/sql/handler 20 +user4 localhost wait/io/table/sql/handler 61 +user4 localhost wait/lock/table/sql/handler 20 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 24 +user2 wait/io/table/sql/handler 35 +user2 wait/lock/table/sql/handler 20 +user3 wait/io/table/sql/handler 48 +user3 wait/lock/table/sql/handler 20 +user4 wait/io/table/sql/handler 61 +user4 wait/lock/table/sql/handler 20 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 166 +localhost wait/lock/table/sql/handler 84 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 166 +wait/lock/table/sql/handler 84 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 38 25 13 0 0 0 0 25 0 13 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 46 25 21 0 0 0 0 25 0 21 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 84 +TABLE test t2 0 +TABLE test t3 166 +truncate performance_schema.events_waits_summary_by_account_by_event_name; +"================== BY_ACCOUNT truncated ==================" +"================== Step 18 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 0 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 24 +user2 wait/io/table/sql/handler 35 +user2 wait/lock/table/sql/handler 20 +user3 wait/io/table/sql/handler 48 +user3 wait/lock/table/sql/handler 20 +user4 wait/io/table/sql/handler 61 +user4 wait/lock/table/sql/handler 20 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 166 +localhost wait/lock/table/sql/handler 84 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 166 +wait/lock/table/sql/handler 84 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 38 25 13 0 0 0 0 25 0 13 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 46 25 21 0 0 0 0 25 0 21 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 84 +TABLE test t2 0 +TABLE test t3 166 +truncate performance_schema.events_waits_summary_by_user_by_event_name; +"================== BY_USER truncated ==================" +"================== Step 19 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 0 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 166 +localhost wait/lock/table/sql/handler 84 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 166 +wait/lock/table/sql/handler 84 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 38 25 13 0 0 0 0 25 0 13 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 46 25 21 0 0 0 0 25 0 21 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 84 +TABLE test t2 0 +TABLE test t3 166 +truncate performance_schema.events_waits_summary_by_host_by_event_name; +"================== BY_HOST truncated ==================" +"================== Step 21 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 0 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 166 +wait/lock/table/sql/handler 84 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 38 25 13 0 0 0 0 25 0 13 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 46 25 21 0 0 0 0 25 0 21 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 84 +TABLE test t2 0 +TABLE test t3 166 +truncate performance_schema.events_waits_summary_global_by_event_name; +"================== GLOBAL truncated ==================" +"================== Step 21 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 0 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 0 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 0 0 0 0 0 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 0 0 0 0 0 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 0 0 0 0 0 0 0 +TABLE test t3 index_b 0 0 0 0 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 0 0 0 0 0 0 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 0 +TABLE test t2 0 +TABLE test t3 0 +show global status like "performance_schema%table%_lost"; +Variable_name Value +Performance_schema_table_handles_lost 0 +Performance_schema_table_instances_lost 0 +Performance_schema_table_lock_stat_lost 0 diff --git a/mysql-test/suite/table_aggregate_thread_4u_3t.result-pq b/mysql-test/suite/table_aggregate_thread_4u_3t.result-pq new file mode 100644 index 000000000000..557bb6cb1543 --- /dev/null +++ b/mysql-test/suite/table_aggregate_thread_4u_3t.result-pq @@ -0,0 +1,1741 @@ +update performance_schema.setup_consumers +set enabled='NO' where name like 'event%'; +select * from performance_schema.setup_actors +order by USER, HOST, `ROLE`; +HOST USER ROLE ENABLED HISTORY +localhost user1 % YES YES +localhost user2 % YES YES +localhost user3 % YES YES +localhost user4 % YES YES +select * from performance_schema.setup_objects +order by object_type, object_schema, object_name; +OBJECT_TYPE OBJECT_SCHEMA OBJECT_NAME ENABLED TIMED +TABLE test t1 YES YES +TABLE test t2 YES NO +TABLE test t3 YES NO +select * from performance_schema.setup_consumers; +NAME ENABLED +events_stages_current NO +events_stages_history NO +events_stages_history_long NO +events_statements_current NO +events_statements_history NO +events_statements_history_long NO +events_transactions_current NO +events_transactions_history NO +events_transactions_history_long NO +events_waits_current NO +events_waits_history NO +events_waits_history_long NO +global_instrumentation YES +thread_instrumentation YES +statements_digest YES +flush tables; +truncate performance_schema.objects_summary_global_by_type; +truncate performance_schema.table_io_waits_summary_by_index_usage; +truncate performance_schema.table_io_waits_summary_by_table; +truncate performance_schema.table_lock_waits_summary_by_table; +truncate performance_schema.events_waits_summary_by_thread_by_event_name; +truncate performance_schema.events_waits_summary_by_account_by_event_name; +truncate performance_schema.events_waits_summary_by_user_by_event_name; +truncate performance_schema.events_waits_summary_by_host_by_event_name; +truncate performance_schema.events_waits_summary_global_by_event_name; +truncate performance_schema.events_waits_history_long; +show global variables like "performance_schema%table%"; +Variable_name Value +performance_schema_max_table_handles -1 +performance_schema_max_table_instances -1 +performance_schema_max_table_lock_stat -1 +show global status like "performance_schema%table%_lost"; +Variable_name Value +Performance_schema_table_handles_lost 0 +Performance_schema_table_instances_lost 0 +Performance_schema_table_lock_stat_lost 0 +"================== Step 1 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +execute dump_waits_user; +user event_name count_star +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 0 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 0 0 0 0 0 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 index_b 0 0 0 0 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 0 0 0 0 0 0 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 0 +TABLE test t2 0 +TABLE test t3 0 +select concat(current_user(), " is connected") as status; +status +user1@localhost is connected +"================== Step 2 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 0 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 0 0 0 0 0 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 index_b 0 0 0 0 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 0 0 0 0 0 0 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 0 +TABLE test t2 0 +TABLE test t3 0 +insert into test.t1 set a=101, b=1, c=1; +insert into test.t2 set a=102, b=2, c=2; +insert into test.t2 set a=103, b=3, c=3; +insert into test.t3 set a=104, b=4, c=4; +insert into test.t3 set a=105, b=5, c=5; +insert into test.t3 set a=106, b=6, c=6; +select * from test.t1; +a b c d +101 1 1 0 +select * from test.t2; +a b c d +102 2 2 0 +103 3 3 0 +select * from test.t3; +a b c d +104 4 4 0 +105 5 5 0 +106 6 6 0 +update test.t1 set d=d+1; +update test.t2 set d=d+1; +update test.t3 set d=d+1; +update test.t1 set d=d+1 where a=101; +update test.t2 set d=d+1 where a=101; +update test.t3 set d=d+1 where a=101; +select * from test.t1 force index(index_b) where b=5; +a b c d +select * from test.t2 force index(index_b) where b=5; +a b c d +select * from test.t3 force index(index_b) where b=5; +a b c d +105 5 5 1 +"================== con1 marker ==================" +"================== Step 3-A ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 25 +user1 wait/lock/table/sql/handler 24 +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 30 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 30 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 32 +localhost wait/lock/table/sql/handler 30 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 32 +wait/lock/table/sql/handler 30 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 4 3 1 3 1 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 3 1 2 1 0 2 0 +TABLE test t2 NULL 7 5 2 5 2 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 3 1 2 1 0 2 0 +TABLE test t3 NULL 10 7 3 7 3 0 0 +TABLE test t3 index_b 1 1 0 1 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 4 1 3 1 0 3 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 7 4 3 4 1 2 0 +TABLE test t2 10 6 4 6 2 2 0 +TABLE test t3 15 9 6 9 3 3 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 9 6 3 0 0 0 0 6 0 3 +TABLE test t2 10 6 4 0 0 0 0 6 0 4 +TABLE test t3 11 6 5 0 0 0 0 6 0 5 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 16 +TABLE test t2 20 +TABLE test t3 26 +flush tables; +"================== con1 FLUSH ==================" +"================== Step 3-B ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 25 +user1 wait/lock/table/sql/handler 24 +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 30 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 30 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 32 +localhost wait/lock/table/sql/handler 30 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 32 +wait/lock/table/sql/handler 30 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 4 3 1 3 1 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 3 1 2 1 0 2 0 +TABLE test t2 NULL 7 5 2 5 2 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 3 1 2 1 0 2 0 +TABLE test t3 NULL 10 7 3 7 3 0 0 +TABLE test t3 index_b 1 1 0 1 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 4 1 3 1 0 3 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 7 4 3 4 1 2 0 +TABLE test t2 10 6 4 6 2 2 0 +TABLE test t3 15 9 6 9 3 3 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 9 6 3 0 0 0 0 6 0 3 +TABLE test t2 10 6 4 0 0 0 0 6 0 4 +TABLE test t3 11 6 5 0 0 0 0 6 0 5 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 16 +TABLE test t2 20 +TABLE test t3 26 +select concat(current_user(), " is connected") as status; +status +user2@localhost is connected +"================== Step 4 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 25 +user1 wait/lock/table/sql/handler 24 +username event_name count_star +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 30 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 30 +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 32 +localhost wait/lock/table/sql/handler 30 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 32 +wait/lock/table/sql/handler 30 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 4 3 1 3 1 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 3 1 2 1 0 2 0 +TABLE test t2 NULL 7 5 2 5 2 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 3 1 2 1 0 2 0 +TABLE test t3 NULL 10 7 3 7 3 0 0 +TABLE test t3 index_b 1 1 0 1 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 4 1 3 1 0 3 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 7 4 3 4 1 2 0 +TABLE test t2 10 6 4 6 2 2 0 +TABLE test t3 15 9 6 9 3 3 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 9 6 3 0 0 0 0 6 0 3 +TABLE test t2 10 6 4 0 0 0 0 6 0 4 +TABLE test t3 11 6 5 0 0 0 0 6 0 5 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 16 +TABLE test t2 20 +TABLE test t3 26 +insert into test.t1 set a=201, b=1, c=1; +insert into test.t2 set a=202, b=2, c=2; +insert into test.t2 set a=203, b=3, c=3; +insert into test.t3 set a=204, b=4, c=4; +insert into test.t3 set a=205, b=5, c=5; +insert into test.t3 set a=206, b=6, c=6; +select * from test.t1; +a b c d +101 1 1 2 +201 1 1 0 +select * from test.t2; +a b c d +102 2 2 1 +103 3 3 1 +202 2 2 0 +203 3 3 0 +select * from test.t3; +a b c d +104 4 4 1 +105 5 5 1 +106 6 6 1 +204 4 4 0 +205 5 5 0 +206 6 6 0 +update test.t1 set d=d+1; +update test.t2 set d=d+1; +update test.t3 set d=d+1; +update test.t1 set d=d+1 where a=201; +update test.t2 set d=d+1 where a=201; +update test.t3 set d=d+1 where a=201; +select * from test.t1 force index(index_b) where b=5; +a b c d +select * from test.t2 force index(index_b) where b=5; +a b c d +select * from test.t3 force index(index_b) where b=5; +a b c d +105 5 5 2 +205 5 5 1 +"================== con2 marker ==================" +"================== Step 5 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 25 +user1 wait/lock/table/sql/handler 24 +username event_name count_star +user2 wait/io/table/sql/handler 37 +user2 wait/lock/table/sql/handler 24 +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 30 +user2 localhost wait/io/table/sql/handler 51 +user2 localhost wait/lock/table/sql/handler 30 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 30 +user2 wait/io/table/sql/handler 51 +user2 wait/lock/table/sql/handler 30 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 83 +localhost wait/lock/table/sql/handler 60 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 83 +wait/lock/table/sql/handler 60 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 10 8 2 8 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 7 2 5 2 0 5 0 +TABLE test t2 NULL 18 14 4 14 4 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 8 2 6 2 0 6 0 +TABLE test t3 NULL 26 20 6 20 6 0 0 +TABLE test t3 index_b 3 3 0 3 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 11 2 9 2 0 9 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 17 10 7 10 2 5 0 +TABLE test t2 26 16 10 16 4 6 0 +TABLE test t3 40 25 15 25 6 9 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 18 12 6 0 0 0 0 12 0 6 +TABLE test t2 20 12 8 0 0 0 0 12 0 8 +TABLE test t3 22 12 10 0 0 0 0 12 0 10 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 35 +TABLE test t2 46 +TABLE test t3 62 +select concat(current_user(), " is connected") as status; +status +user3@localhost is connected +"================== Step 6 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 25 +user1 wait/lock/table/sql/handler 24 +username event_name count_star +user2 wait/io/table/sql/handler 37 +user2 wait/lock/table/sql/handler 24 +username event_name count_star +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 30 +user2 localhost wait/io/table/sql/handler 51 +user2 localhost wait/lock/table/sql/handler 30 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 30 +user2 wait/io/table/sql/handler 51 +user2 wait/lock/table/sql/handler 30 +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 83 +localhost wait/lock/table/sql/handler 60 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 83 +wait/lock/table/sql/handler 60 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 10 8 2 8 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 7 2 5 2 0 5 0 +TABLE test t2 NULL 18 14 4 14 4 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 8 2 6 2 0 6 0 +TABLE test t3 NULL 26 20 6 20 6 0 0 +TABLE test t3 index_b 3 3 0 3 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 11 2 9 2 0 9 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 17 10 7 10 2 5 0 +TABLE test t2 26 16 10 16 4 6 0 +TABLE test t3 40 25 15 25 6 9 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 18 12 6 0 0 0 0 12 0 6 +TABLE test t2 20 12 8 0 0 0 0 12 0 8 +TABLE test t3 22 12 10 0 0 0 0 12 0 10 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 35 +TABLE test t2 46 +TABLE test t3 62 +insert into test.t1 set a=301, b=1, c=1; +insert into test.t2 set a=302, b=2, c=2; +insert into test.t2 set a=303, b=3, c=3; +insert into test.t3 set a=304, b=4, c=4; +insert into test.t3 set a=305, b=5, c=5; +insert into test.t3 set a=306, b=6, c=6; +select * from test.t1; +a b c d +101 1 1 3 +201 1 1 2 +301 1 1 0 +select * from test.t2; +a b c d +102 2 2 2 +103 3 3 2 +202 2 2 1 +203 3 3 1 +302 2 2 0 +303 3 3 0 +select * from test.t3; +a b c d +104 4 4 2 +105 5 5 2 +106 6 6 2 +204 4 4 1 +205 5 5 1 +206 6 6 1 +304 4 4 0 +305 5 5 0 +306 6 6 0 +update test.t1 set d=d+1; +update test.t2 set d=d+1; +update test.t3 set d=d+1; +update test.t1 set d=d+1 where a=301; +update test.t2 set d=d+1 where a=301; +update test.t3 set d=d+1 where a=301; +select * from test.t1 force index(index_b) where b=5; +a b c d +select * from test.t2 force index(index_b) where b=5; +a b c d +select * from test.t3 force index(index_b) where b=5; +a b c d +105 5 5 3 +205 5 5 2 +305 5 5 1 +"================== con3 marker ==================" +"================== Step 7 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 25 +user1 wait/lock/table/sql/handler 24 +username event_name count_star +user2 wait/io/table/sql/handler 37 +user2 wait/lock/table/sql/handler 24 +username event_name count_star +user3 wait/io/table/sql/handler 49 +user3 wait/lock/table/sql/handler 24 +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 30 +user2 localhost wait/io/table/sql/handler 51 +user2 localhost wait/lock/table/sql/handler 30 +user3 localhost wait/io/table/sql/handler 70 +user3 localhost wait/lock/table/sql/handler 30 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 30 +user2 wait/io/table/sql/handler 51 +user2 wait/lock/table/sql/handler 30 +user3 wait/io/table/sql/handler 70 +user3 wait/lock/table/sql/handler 30 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 153 +localhost wait/lock/table/sql/handler 90 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 153 +wait/lock/table/sql/handler 90 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 15 3 15 3 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 12 3 9 3 0 9 0 +TABLE test t2 NULL 33 27 6 27 6 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 15 3 12 3 0 12 0 +TABLE test t3 NULL 48 39 9 39 9 0 0 +TABLE test t3 index_b 6 6 0 6 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 21 3 18 3 0 18 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 30 18 12 18 3 9 0 +TABLE test t2 48 30 18 30 6 12 0 +TABLE test t3 75 48 27 48 9 18 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 27 18 9 0 0 0 0 18 0 9 +TABLE test t2 30 18 12 0 0 0 0 18 0 12 +TABLE test t3 33 18 15 0 0 0 0 18 0 15 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 57 +TABLE test t2 78 +TABLE test t3 108 +select concat(current_user(), " is connected") as status; +status +user4@localhost is connected +"================== Step 8 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 25 +user1 wait/lock/table/sql/handler 24 +username event_name count_star +user2 wait/io/table/sql/handler 37 +user2 wait/lock/table/sql/handler 24 +username event_name count_star +user3 wait/io/table/sql/handler 49 +user3 wait/lock/table/sql/handler 24 +username event_name count_star +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 30 +user2 localhost wait/io/table/sql/handler 51 +user2 localhost wait/lock/table/sql/handler 30 +user3 localhost wait/io/table/sql/handler 70 +user3 localhost wait/lock/table/sql/handler 30 +user4 localhost wait/io/table/sql/handler 0 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 30 +user2 wait/io/table/sql/handler 51 +user2 wait/lock/table/sql/handler 30 +user3 wait/io/table/sql/handler 70 +user3 wait/lock/table/sql/handler 30 +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 153 +localhost wait/lock/table/sql/handler 90 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 153 +wait/lock/table/sql/handler 90 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 15 3 15 3 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 12 3 9 3 0 9 0 +TABLE test t2 NULL 33 27 6 27 6 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 15 3 12 3 0 12 0 +TABLE test t3 NULL 48 39 9 39 9 0 0 +TABLE test t3 index_b 6 6 0 6 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 21 3 18 3 0 18 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 30 18 12 18 3 9 0 +TABLE test t2 48 30 18 30 6 12 0 +TABLE test t3 75 48 27 48 9 18 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 27 18 9 0 0 0 0 18 0 9 +TABLE test t2 30 18 12 0 0 0 0 18 0 12 +TABLE test t3 33 18 15 0 0 0 0 18 0 15 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 57 +TABLE test t2 78 +TABLE test t3 108 +insert into test.t1 set a=401, b=1, c=1; +insert into test.t2 set a=402, b=2, c=2; +insert into test.t2 set a=403, b=3, c=3; +insert into test.t3 set a=404, b=4, c=4; +insert into test.t3 set a=405, b=5, c=5; +insert into test.t3 set a=406, b=6, c=6; +select * from test.t1; +a b c d +101 1 1 4 +201 1 1 3 +301 1 1 2 +401 1 1 0 +select * from test.t2; +a b c d +102 2 2 3 +103 3 3 3 +202 2 2 2 +203 3 3 2 +302 2 2 1 +303 3 3 1 +402 2 2 0 +403 3 3 0 +select * from test.t3; +a b c d +104 4 4 3 +105 5 5 3 +106 6 6 3 +204 4 4 2 +205 5 5 2 +206 6 6 2 +304 4 4 1 +305 5 5 1 +306 6 6 1 +404 4 4 0 +405 5 5 0 +406 6 6 0 +update test.t1 set d=d+1; +update test.t2 set d=d+1; +update test.t3 set d=d+1; +update test.t1 set d=d+1 where a=401; +update test.t2 set d=d+1 where a=401; +update test.t3 set d=d+1 where a=401; +select * from test.t1 force index(index_b) where b=5; +a b c d +select * from test.t2 force index(index_b) where b=5; +a b c d +select * from test.t3 force index(index_b) where b=5; +a b c d +105 5 5 4 +205 5 5 3 +305 5 5 2 +405 5 5 1 +"================== con4 marker ==================" +"================== Step 9 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 25 +user1 wait/lock/table/sql/handler 24 +username event_name count_star +user2 wait/io/table/sql/handler 37 +user2 wait/lock/table/sql/handler 24 +username event_name count_star +user3 wait/io/table/sql/handler 49 +user3 wait/lock/table/sql/handler 24 +username event_name count_star +user4 wait/io/table/sql/handler 61 +user4 wait/lock/table/sql/handler 24 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 30 +user2 localhost wait/io/table/sql/handler 51 +user2 localhost wait/lock/table/sql/handler 30 +user3 localhost wait/io/table/sql/handler 70 +user3 localhost wait/lock/table/sql/handler 30 +user4 localhost wait/io/table/sql/handler 89 +user4 localhost wait/lock/table/sql/handler 30 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 30 +user2 wait/io/table/sql/handler 51 +user2 wait/lock/table/sql/handler 30 +user3 wait/io/table/sql/handler 70 +user3 wait/lock/table/sql/handler 30 +user4 wait/io/table/sql/handler 89 +user4 wait/lock/table/sql/handler 30 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 242 +localhost wait/lock/table/sql/handler 120 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 242 +wait/lock/table/sql/handler 120 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 NULL 52 44 8 44 8 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 24 4 20 4 0 20 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 76 48 28 48 8 20 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 36 24 12 0 0 0 0 24 0 12 +TABLE test t2 40 24 16 0 0 0 0 24 0 16 +TABLE test t3 44 24 20 0 0 0 0 24 0 20 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 82 +TABLE test t2 116 +TABLE test t3 164 +lock tables test.t1 read, test.t2 read, test.t3 read; +unlock tables; +lock tables test.t1 write, test.t2 write, test.t3 write; +unlock tables; +"================== con1 marker ==================" +"================== Step 10 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 25 +user1 wait/lock/table/sql/handler 30 +username event_name count_star +user2 wait/io/table/sql/handler 37 +user2 wait/lock/table/sql/handler 24 +username event_name count_star +user3 wait/io/table/sql/handler 49 +user3 wait/lock/table/sql/handler 24 +username event_name count_star +user4 wait/io/table/sql/handler 61 +user4 wait/lock/table/sql/handler 24 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 36 +user2 localhost wait/io/table/sql/handler 51 +user2 localhost wait/lock/table/sql/handler 30 +user3 localhost wait/io/table/sql/handler 70 +user3 localhost wait/lock/table/sql/handler 30 +user4 localhost wait/io/table/sql/handler 89 +user4 localhost wait/lock/table/sql/handler 30 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 36 +user2 wait/io/table/sql/handler 51 +user2 wait/lock/table/sql/handler 30 +user3 wait/io/table/sql/handler 70 +user3 wait/lock/table/sql/handler 30 +user4 wait/io/table/sql/handler 89 +user4 wait/lock/table/sql/handler 30 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 242 +localhost wait/lock/table/sql/handler 126 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 242 +wait/lock/table/sql/handler 126 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 NULL 52 44 8 44 8 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 24 4 20 4 0 20 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 76 48 28 48 8 20 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 38 25 13 0 0 0 0 25 0 13 +TABLE test t2 42 25 17 0 0 0 0 25 0 17 +TABLE test t3 46 25 21 0 0 0 0 25 0 21 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 84 +TABLE test t2 118 +TABLE test t3 166 +flush tables; +"================== flush marker ==================" +"================== Step 11 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 25 +user1 wait/lock/table/sql/handler 30 +username event_name count_star +user2 wait/io/table/sql/handler 37 +user2 wait/lock/table/sql/handler 24 +username event_name count_star +user3 wait/io/table/sql/handler 49 +user3 wait/lock/table/sql/handler 24 +username event_name count_star +user4 wait/io/table/sql/handler 61 +user4 wait/lock/table/sql/handler 24 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 36 +user2 localhost wait/io/table/sql/handler 51 +user2 localhost wait/lock/table/sql/handler 30 +user3 localhost wait/io/table/sql/handler 70 +user3 localhost wait/lock/table/sql/handler 30 +user4 localhost wait/io/table/sql/handler 89 +user4 localhost wait/lock/table/sql/handler 30 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 36 +user2 wait/io/table/sql/handler 51 +user2 wait/lock/table/sql/handler 30 +user3 wait/io/table/sql/handler 70 +user3 wait/lock/table/sql/handler 30 +user4 wait/io/table/sql/handler 89 +user4 wait/lock/table/sql/handler 30 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 242 +localhost wait/lock/table/sql/handler 126 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 242 +wait/lock/table/sql/handler 126 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 NULL 52 44 8 44 8 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 24 4 20 4 0 20 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 76 48 28 48 8 20 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 38 25 13 0 0 0 0 25 0 13 +TABLE test t2 42 25 17 0 0 0 0 25 0 17 +TABLE test t3 46 25 21 0 0 0 0 25 0 21 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 84 +TABLE test t2 118 +TABLE test t3 166 +set global read_only=1; +set global read_only=0; +"================== global read_only marker ==================" +"================== Step 12 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 25 +user1 wait/lock/table/sql/handler 30 +username event_name count_star +user2 wait/io/table/sql/handler 37 +user2 wait/lock/table/sql/handler 24 +username event_name count_star +user3 wait/io/table/sql/handler 49 +user3 wait/lock/table/sql/handler 24 +username event_name count_star +user4 wait/io/table/sql/handler 61 +user4 wait/lock/table/sql/handler 24 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 36 +user2 localhost wait/io/table/sql/handler 51 +user2 localhost wait/lock/table/sql/handler 30 +user3 localhost wait/io/table/sql/handler 70 +user3 localhost wait/lock/table/sql/handler 30 +user4 localhost wait/io/table/sql/handler 89 +user4 localhost wait/lock/table/sql/handler 30 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 36 +user2 wait/io/table/sql/handler 51 +user2 wait/lock/table/sql/handler 30 +user3 wait/io/table/sql/handler 70 +user3 wait/lock/table/sql/handler 30 +user4 wait/io/table/sql/handler 89 +user4 wait/lock/table/sql/handler 30 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 242 +localhost wait/lock/table/sql/handler 126 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 242 +wait/lock/table/sql/handler 126 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 NULL 52 44 8 44 8 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 24 4 20 4 0 20 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 76 48 28 48 8 20 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 38 25 13 0 0 0 0 25 0 13 +TABLE test t2 42 25 17 0 0 0 0 25 0 17 +TABLE test t3 46 25 21 0 0 0 0 25 0 21 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 84 +TABLE test t2 118 +TABLE test t3 166 +"================== con1 disconnected ==================" +"================== Step 13 ==================" +call dump_thread(); +username status +user1 not found +username event_name count_star +user2 wait/io/table/sql/handler 37 +user2 wait/lock/table/sql/handler 24 +username event_name count_star +user3 wait/io/table/sql/handler 49 +user3 wait/lock/table/sql/handler 24 +username event_name count_star +user4 wait/io/table/sql/handler 61 +user4 wait/lock/table/sql/handler 24 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 36 +user2 localhost wait/io/table/sql/handler 51 +user2 localhost wait/lock/table/sql/handler 30 +user3 localhost wait/io/table/sql/handler 70 +user3 localhost wait/lock/table/sql/handler 30 +user4 localhost wait/io/table/sql/handler 89 +user4 localhost wait/lock/table/sql/handler 30 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 36 +user2 wait/io/table/sql/handler 51 +user2 wait/lock/table/sql/handler 30 +user3 wait/io/table/sql/handler 70 +user3 wait/lock/table/sql/handler 30 +user4 wait/io/table/sql/handler 89 +user4 wait/lock/table/sql/handler 30 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 242 +localhost wait/lock/table/sql/handler 126 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 242 +wait/lock/table/sql/handler 126 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 NULL 52 44 8 44 8 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 24 4 20 4 0 20 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 76 48 28 48 8 20 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 38 25 13 0 0 0 0 25 0 13 +TABLE test t2 42 25 17 0 0 0 0 25 0 17 +TABLE test t3 46 25 21 0 0 0 0 25 0 21 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 84 +TABLE test t2 118 +TABLE test t3 166 +"================== con2 disconnected ==================" +"================== Step 14 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username event_name count_star +user3 wait/io/table/sql/handler 49 +user3 wait/lock/table/sql/handler 24 +username event_name count_star +user4 wait/io/table/sql/handler 61 +user4 wait/lock/table/sql/handler 24 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 36 +user2 localhost wait/io/table/sql/handler 51 +user2 localhost wait/lock/table/sql/handler 30 +user3 localhost wait/io/table/sql/handler 70 +user3 localhost wait/lock/table/sql/handler 30 +user4 localhost wait/io/table/sql/handler 89 +user4 localhost wait/lock/table/sql/handler 30 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 36 +user2 wait/io/table/sql/handler 51 +user2 wait/lock/table/sql/handler 30 +user3 wait/io/table/sql/handler 70 +user3 wait/lock/table/sql/handler 30 +user4 wait/io/table/sql/handler 89 +user4 wait/lock/table/sql/handler 30 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 242 +localhost wait/lock/table/sql/handler 126 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 242 +wait/lock/table/sql/handler 126 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 NULL 52 44 8 44 8 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 24 4 20 4 0 20 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 76 48 28 48 8 20 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 38 25 13 0 0 0 0 25 0 13 +TABLE test t2 42 25 17 0 0 0 0 25 0 17 +TABLE test t3 46 25 21 0 0 0 0 25 0 21 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 84 +TABLE test t2 118 +TABLE test t3 166 +"================== con3 disconnected ==================" +"================== Step 15 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username event_name count_star +user4 wait/io/table/sql/handler 61 +user4 wait/lock/table/sql/handler 24 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 36 +user2 localhost wait/io/table/sql/handler 51 +user2 localhost wait/lock/table/sql/handler 30 +user3 localhost wait/io/table/sql/handler 70 +user3 localhost wait/lock/table/sql/handler 30 +user4 localhost wait/io/table/sql/handler 89 +user4 localhost wait/lock/table/sql/handler 30 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 36 +user2 wait/io/table/sql/handler 51 +user2 wait/lock/table/sql/handler 30 +user3 wait/io/table/sql/handler 70 +user3 wait/lock/table/sql/handler 30 +user4 wait/io/table/sql/handler 89 +user4 wait/lock/table/sql/handler 30 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 242 +localhost wait/lock/table/sql/handler 126 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 242 +wait/lock/table/sql/handler 126 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 NULL 52 44 8 44 8 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 24 4 20 4 0 20 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 76 48 28 48 8 20 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 38 25 13 0 0 0 0 25 0 13 +TABLE test t2 42 25 17 0 0 0 0 25 0 17 +TABLE test t3 46 25 21 0 0 0 0 25 0 21 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 84 +TABLE test t2 118 +TABLE test t3 166 +"================== con4 disconnected ==================" +"================== Step 16 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 36 +user2 localhost wait/io/table/sql/handler 51 +user2 localhost wait/lock/table/sql/handler 30 +user3 localhost wait/io/table/sql/handler 70 +user3 localhost wait/lock/table/sql/handler 30 +user4 localhost wait/io/table/sql/handler 89 +user4 localhost wait/lock/table/sql/handler 30 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 36 +user2 wait/io/table/sql/handler 51 +user2 wait/lock/table/sql/handler 30 +user3 wait/io/table/sql/handler 70 +user3 wait/lock/table/sql/handler 30 +user4 wait/io/table/sql/handler 89 +user4 wait/lock/table/sql/handler 30 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 242 +localhost wait/lock/table/sql/handler 126 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 242 +wait/lock/table/sql/handler 126 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 NULL 52 44 8 44 8 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 24 4 20 4 0 20 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 76 48 28 48 8 20 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 38 25 13 0 0 0 0 25 0 13 +TABLE test t2 42 25 17 0 0 0 0 25 0 17 +TABLE test t3 46 25 21 0 0 0 0 25 0 21 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 84 +TABLE test t2 118 +TABLE test t3 166 +truncate performance_schema.events_waits_summary_by_thread_by_event_name; +"================== BY_THREAD truncated ==================" +"================== Step 17 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 36 +user2 localhost wait/io/table/sql/handler 51 +user2 localhost wait/lock/table/sql/handler 30 +user3 localhost wait/io/table/sql/handler 70 +user3 localhost wait/lock/table/sql/handler 30 +user4 localhost wait/io/table/sql/handler 89 +user4 localhost wait/lock/table/sql/handler 30 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 36 +user2 wait/io/table/sql/handler 51 +user2 wait/lock/table/sql/handler 30 +user3 wait/io/table/sql/handler 70 +user3 wait/lock/table/sql/handler 30 +user4 wait/io/table/sql/handler 89 +user4 wait/lock/table/sql/handler 30 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 242 +localhost wait/lock/table/sql/handler 126 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 242 +wait/lock/table/sql/handler 126 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 NULL 52 44 8 44 8 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 24 4 20 4 0 20 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 76 48 28 48 8 20 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 38 25 13 0 0 0 0 25 0 13 +TABLE test t2 42 25 17 0 0 0 0 25 0 17 +TABLE test t3 46 25 21 0 0 0 0 25 0 21 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 84 +TABLE test t2 118 +TABLE test t3 166 +truncate performance_schema.events_waits_summary_by_account_by_event_name; +"================== BY_ACCOUNT truncated ==================" +"================== Step 18 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 0 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 36 +user2 wait/io/table/sql/handler 51 +user2 wait/lock/table/sql/handler 30 +user3 wait/io/table/sql/handler 70 +user3 wait/lock/table/sql/handler 30 +user4 wait/io/table/sql/handler 89 +user4 wait/lock/table/sql/handler 30 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 242 +localhost wait/lock/table/sql/handler 126 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 242 +wait/lock/table/sql/handler 126 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 NULL 52 44 8 44 8 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 24 4 20 4 0 20 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 76 48 28 48 8 20 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 38 25 13 0 0 0 0 25 0 13 +TABLE test t2 42 25 17 0 0 0 0 25 0 17 +TABLE test t3 46 25 21 0 0 0 0 25 0 21 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 84 +TABLE test t2 118 +TABLE test t3 166 +truncate performance_schema.events_waits_summary_by_user_by_event_name; +"================== BY_USER truncated ==================" +"================== Step 19 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 0 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 242 +localhost wait/lock/table/sql/handler 126 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 242 +wait/lock/table/sql/handler 126 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 NULL 52 44 8 44 8 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 24 4 20 4 0 20 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 76 48 28 48 8 20 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 38 25 13 0 0 0 0 25 0 13 +TABLE test t2 42 25 17 0 0 0 0 25 0 17 +TABLE test t3 46 25 21 0 0 0 0 25 0 21 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 84 +TABLE test t2 118 +TABLE test t3 166 +truncate performance_schema.events_waits_summary_by_host_by_event_name; +"================== BY_HOST truncated ==================" +"================== Step 21 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 0 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 242 +wait/lock/table/sql/handler 126 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 NULL 52 44 8 44 8 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 24 4 20 4 0 20 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 76 48 28 48 8 20 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 38 25 13 0 0 0 0 25 0 13 +TABLE test t2 42 25 17 0 0 0 0 25 0 17 +TABLE test t3 46 25 21 0 0 0 0 25 0 21 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 84 +TABLE test t2 118 +TABLE test t3 166 +truncate performance_schema.events_waits_summary_global_by_event_name; +"================== GLOBAL truncated ==================" +"================== Step 21 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 0 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 0 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 0 0 0 0 0 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 0 0 0 0 0 0 0 +TABLE test t2 NULL 0 0 0 0 0 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 0 0 0 0 0 0 0 +TABLE test t3 index_b 0 0 0 0 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 0 0 0 0 0 0 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 0 +TABLE test t2 0 +TABLE test t3 0 +show global status like "performance_schema%table%_lost"; +Variable_name Value +Performance_schema_table_handles_lost 0 +Performance_schema_table_instances_lost 0 +Performance_schema_table_lock_stat_lost 0 diff --git a/mysql-test/suite/table_io_aggregate_hist_2u_2t.result-pq b/mysql-test/suite/table_io_aggregate_hist_2u_2t.result-pq new file mode 100644 index 000000000000..954e14d35985 --- /dev/null +++ b/mysql-test/suite/table_io_aggregate_hist_2u_2t.result-pq @@ -0,0 +1,1762 @@ +update performance_schema.setup_instruments +set enabled='NO' where name='wait/lock/table/sql/handler'; +delete from performance_schema.setup_actors +where user in ('user2', 'user4'); +delete from performance_schema.setup_objects +where object_name='t2'; +select * from performance_schema.setup_actors +order by USER, HOST, `ROLE`; +HOST USER ROLE ENABLED HISTORY +localhost user1 % YES YES +localhost user3 % YES YES +select * from performance_schema.setup_objects +order by object_type, object_schema, object_name; +OBJECT_TYPE OBJECT_SCHEMA OBJECT_NAME ENABLED TIMED +TABLE test t1 YES YES +TABLE test t3 YES NO +select * from performance_schema.setup_consumers; +NAME ENABLED +events_stages_current YES +events_stages_history YES +events_stages_history_long YES +events_statements_current YES +events_statements_history YES +events_statements_history_long YES +events_transactions_current YES +events_transactions_history YES +events_transactions_history_long YES +events_waits_current YES +events_waits_history YES +events_waits_history_long YES +global_instrumentation YES +thread_instrumentation YES +statements_digest YES +flush tables; +truncate performance_schema.objects_summary_global_by_type; +truncate performance_schema.table_io_waits_summary_by_index_usage; +truncate performance_schema.table_io_waits_summary_by_table; +truncate performance_schema.table_lock_waits_summary_by_table; +truncate performance_schema.events_waits_summary_by_thread_by_event_name; +truncate performance_schema.events_waits_summary_by_account_by_event_name; +truncate performance_schema.events_waits_summary_by_user_by_event_name; +truncate performance_schema.events_waits_summary_by_host_by_event_name; +truncate performance_schema.events_waits_summary_global_by_event_name; +truncate performance_schema.events_waits_history_long; +show global variables like "performance_schema%table%"; +Variable_name Value +performance_schema_max_table_handles -1 +performance_schema_max_table_instances -1 +performance_schema_max_table_lock_stat -1 +show global status like "performance_schema%table%_lost"; +Variable_name Value +Performance_schema_table_handles_lost 0 +Performance_schema_table_instances_lost 0 +Performance_schema_table_lock_stat_lost 0 +"================== Step 1 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +execute dump_waits_user; +user event_name count_star +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 0 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 0 0 0 0 0 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 index_b 0 0 0 0 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 0 0 0 0 0 0 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 0 +TABLE test t2 0 +TABLE test t3 0 +select concat(current_user(), " is connected") as status; +status +user1@localhost is connected +"================== Step 2 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 0 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 0 0 0 0 0 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 index_b 0 0 0 0 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 0 0 0 0 0 0 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 0 +TABLE test t2 0 +TABLE test t3 0 +insert into test.t1 set a=101, b=1, c=1; +insert into test.t2 set a=102, b=2, c=2; +insert into test.t2 set a=103, b=3, c=3; +insert into test.t3 set a=104, b=4, c=4; +insert into test.t3 set a=105, b=5, c=5; +insert into test.t3 set a=106, b=6, c=6; +select * from test.t1; +a b c d +101 1 1 0 +select * from test.t2; +a b c d +102 2 2 0 +103 3 3 0 +select * from test.t3; +a b c d +104 4 4 0 +105 5 5 0 +106 6 6 0 +update test.t1 set d=d+1; +update test.t2 set d=d+1; +update test.t3 set d=d+1; +update test.t1 set d=d+1 where a=101; +update test.t2 set d=d+1 where a=101; +update test.t3 set d=d+1 where a=101; +select * from test.t1 force index(index_b) where b=5; +a b c d +select * from test.t2 force index(index_b) where b=5; +a b c d +select * from test.t3 force index(index_b) where b=5; +a b c d +105 5 5 1 +"================== con1 marker ==================" +"================== Step 3-A ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 17 +user1 wait/lock/table/sql/handler 0 +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 22 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 22 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 7 TABLE test t1 +wait/io/table/sql/handler 15 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 4 3 1 3 1 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 3 1 2 1 0 2 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 10 7 3 7 3 0 0 +TABLE test t3 index_b 1 1 0 1 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 4 1 3 1 0 3 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 7 4 3 4 1 2 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 15 9 6 9 3 3 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 7 +TABLE test t2 0 +TABLE test t3 15 +flush tables; +"================== con1 FLUSH ==================" +"================== Step 3-B ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 17 +user1 wait/lock/table/sql/handler 0 +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 22 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 22 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 7 TABLE test t1 +wait/io/table/sql/handler 15 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 4 3 1 3 1 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 3 1 2 1 0 2 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 10 7 3 7 3 0 0 +TABLE test t3 index_b 1 1 0 1 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 4 1 3 1 0 3 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 7 4 3 4 1 2 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 15 9 6 9 3 3 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 7 +TABLE test t2 0 +TABLE test t3 15 +select concat(current_user(), " is connected") as status; +status +user2@localhost is connected +"================== Step 4 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 17 +user1 wait/lock/table/sql/handler 0 +username event_name count_star +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 22 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 22 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 7 TABLE test t1 +wait/io/table/sql/handler 15 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 4 3 1 3 1 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 3 1 2 1 0 2 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 10 7 3 7 3 0 0 +TABLE test t3 index_b 1 1 0 1 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 4 1 3 1 0 3 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 7 4 3 4 1 2 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 15 9 6 9 3 3 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 7 +TABLE test t2 0 +TABLE test t3 15 +insert into test.t1 set a=201, b=1, c=1; +insert into test.t2 set a=202, b=2, c=2; +insert into test.t2 set a=203, b=3, c=3; +insert into test.t3 set a=204, b=4, c=4; +insert into test.t3 set a=205, b=5, c=5; +insert into test.t3 set a=206, b=6, c=6; +select * from test.t1; +a b c d +101 1 1 2 +201 1 1 0 +select * from test.t2; +a b c d +102 2 2 1 +103 3 3 1 +202 2 2 0 +203 3 3 0 +select * from test.t3; +a b c d +104 4 4 1 +105 5 5 1 +106 6 6 1 +204 4 4 0 +205 5 5 0 +206 6 6 0 +update test.t1 set d=d+1; +update test.t2 set d=d+1; +update test.t3 set d=d+1; +update test.t1 set d=d+1 where a=201; +update test.t2 set d=d+1 where a=201; +update test.t3 set d=d+1 where a=201; +select * from test.t1 force index(index_b) where b=5; +a b c d +select * from test.t2 force index(index_b) where b=5; +a b c d +select * from test.t3 force index(index_b) where b=5; +a b c d +105 5 5 2 +205 5 5 1 +"================== con2 marker ==================" +"================== Step 5 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 17 +user1 wait/lock/table/sql/handler 0 +username event_name count_star +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 10 +user2 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 10 +user2 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 32 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 32 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 9 TABLE test t1 +wait/io/table/sql/handler 23 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 6 5 1 5 1 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 3 1 2 1 0 2 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 16 13 3 13 3 0 0 +TABLE test t3 index_b 3 3 0 3 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 4 1 3 1 0 3 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 9 6 3 6 1 2 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 23 17 6 17 3 3 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 9 +TABLE test t2 0 +TABLE test t3 23 +select concat(current_user(), " is connected") as status; +status +user3@localhost is connected +"================== Step 6 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 17 +user1 wait/lock/table/sql/handler 0 +username event_name count_star +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 10 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 10 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 32 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 32 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 9 TABLE test t1 +wait/io/table/sql/handler 23 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 6 5 1 5 1 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 3 1 2 1 0 2 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 16 13 3 13 3 0 0 +TABLE test t3 index_b 3 3 0 3 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 4 1 3 1 0 3 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 9 6 3 6 1 2 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 23 17 6 17 3 3 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 9 +TABLE test t2 0 +TABLE test t3 23 +insert into test.t1 set a=301, b=1, c=1; +insert into test.t2 set a=302, b=2, c=2; +insert into test.t2 set a=303, b=3, c=3; +insert into test.t3 set a=304, b=4, c=4; +insert into test.t3 set a=305, b=5, c=5; +insert into test.t3 set a=306, b=6, c=6; +select * from test.t1; +a b c d +101 1 1 3 +201 1 1 2 +301 1 1 0 +select * from test.t2; +a b c d +102 2 2 2 +103 3 3 2 +202 2 2 1 +203 3 3 1 +302 2 2 0 +303 3 3 0 +select * from test.t3; +a b c d +104 4 4 2 +105 5 5 2 +106 6 6 2 +204 4 4 1 +205 5 5 1 +206 6 6 1 +304 4 4 0 +305 5 5 0 +306 6 6 0 +update test.t1 set d=d+1; +update test.t2 set d=d+1; +update test.t3 set d=d+1; +update test.t1 set d=d+1 where a=301; +update test.t2 set d=d+1 where a=301; +update test.t3 set d=d+1 where a=301; +select * from test.t1 force index(index_b) where b=5; +a b c d +select * from test.t2 force index(index_b) where b=5; +a b c d +select * from test.t3 force index(index_b) where b=5; +a b c d +105 5 5 3 +205 5 5 2 +305 5 5 1 +"================== con3 marker ==================" +"================== Step 7 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 17 +user1 wait/lock/table/sql/handler 0 +username event_name count_star +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 33 +user3 wait/lock/table/sql/handler 0 +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 10 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 48 +user3 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 10 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 48 +user3 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 80 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 80 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 22 TABLE test t1 +wait/io/table/sql/handler 58 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 14 12 2 12 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 8 2 6 2 0 6 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 38 32 6 32 6 0 0 +TABLE test t3 index_b 6 6 0 6 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 14 2 12 2 0 12 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 22 14 8 14 2 6 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 58 40 18 40 6 12 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 22 +TABLE test t2 0 +TABLE test t3 58 +select concat(current_user(), " is connected") as status; +status +user4@localhost is connected +"================== Step 8 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 17 +user1 wait/lock/table/sql/handler 0 +username event_name count_star +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 33 +user3 wait/lock/table/sql/handler 0 +username event_name count_star +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 10 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 48 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 0 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 10 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 48 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 80 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 80 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 22 TABLE test t1 +wait/io/table/sql/handler 58 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 14 12 2 12 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 8 2 6 2 0 6 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 38 32 6 32 6 0 0 +TABLE test t3 index_b 6 6 0 6 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 14 2 12 2 0 12 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 22 14 8 14 2 6 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 58 40 18 40 6 12 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 22 +TABLE test t2 0 +TABLE test t3 58 +insert into test.t1 set a=401, b=1, c=1; +insert into test.t2 set a=402, b=2, c=2; +insert into test.t2 set a=403, b=3, c=3; +insert into test.t3 set a=404, b=4, c=4; +insert into test.t3 set a=405, b=5, c=5; +insert into test.t3 set a=406, b=6, c=6; +select * from test.t1; +a b c d +101 1 1 4 +201 1 1 3 +301 1 1 2 +401 1 1 0 +select * from test.t2; +a b c d +102 2 2 3 +103 3 3 3 +202 2 2 2 +203 3 3 2 +302 2 2 1 +303 3 3 1 +402 2 2 0 +403 3 3 0 +select * from test.t3; +a b c d +104 4 4 3 +105 5 5 3 +106 6 6 3 +204 4 4 2 +205 5 5 2 +206 6 6 2 +304 4 4 1 +305 5 5 1 +306 6 6 1 +404 4 4 0 +405 5 5 0 +406 6 6 0 +update test.t1 set d=d+1; +update test.t2 set d=d+1; +update test.t3 set d=d+1; +update test.t1 set d=d+1 where a=401; +update test.t2 set d=d+1 where a=401; +update test.t3 set d=d+1 where a=401; +select * from test.t1 force index(index_b) where b=5; +a b c d +select * from test.t2 force index(index_b) where b=5; +a b c d +select * from test.t3 force index(index_b) where b=5; +a b c d +105 5 5 4 +205 5 5 3 +305 5 5 2 +405 5 5 1 +"================== con4 marker ==================" +"================== Step 9 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 17 +user1 wait/lock/table/sql/handler 0 +username event_name count_star +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 33 +user3 wait/lock/table/sql/handler 0 +username event_name count_star +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 10 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 48 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 20 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 10 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 48 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 20 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 100 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 100 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 26 TABLE test t1 +wait/io/table/sql/handler 74 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 16 2 16 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 8 2 6 2 0 6 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 50 44 6 44 6 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 14 2 12 2 0 12 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 26 18 8 18 2 6 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 74 56 18 56 6 12 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 26 +TABLE test t2 0 +TABLE test t3 74 +lock tables test.t1 read, test.t2 read, test.t3 read; +unlock tables; +lock tables test.t1 write, test.t2 write, test.t3 write; +unlock tables; +"================== con1 marker ==================" +"================== Step 10 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 17 +user1 wait/lock/table/sql/handler 0 +username event_name count_star +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 33 +user3 wait/lock/table/sql/handler 0 +username event_name count_star +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 10 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 48 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 20 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 10 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 48 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 20 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 100 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 100 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 26 TABLE test t1 +wait/io/table/sql/handler 74 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 16 2 16 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 8 2 6 2 0 6 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 50 44 6 44 6 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 14 2 12 2 0 12 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 26 18 8 18 2 6 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 74 56 18 56 6 12 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 26 +TABLE test t2 0 +TABLE test t3 74 +flush tables; +"================== flush marker ==================" +"================== Step 11 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 17 +user1 wait/lock/table/sql/handler 0 +username event_name count_star +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 33 +user3 wait/lock/table/sql/handler 0 +username event_name count_star +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 10 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 48 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 20 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 10 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 48 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 20 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 100 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 100 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 26 TABLE test t1 +wait/io/table/sql/handler 74 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 16 2 16 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 8 2 6 2 0 6 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 50 44 6 44 6 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 14 2 12 2 0 12 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 26 18 8 18 2 6 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 74 56 18 56 6 12 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 26 +TABLE test t2 0 +TABLE test t3 74 +set global read_only=1; +set global read_only=0; +"================== global read_only marker ==================" +"================== Step 12 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 17 +user1 wait/lock/table/sql/handler 0 +username event_name count_star +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 33 +user3 wait/lock/table/sql/handler 0 +username event_name count_star +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 10 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 48 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 20 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 10 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 48 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 20 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 100 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 100 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 26 TABLE test t1 +wait/io/table/sql/handler 74 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 16 2 16 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 8 2 6 2 0 6 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 50 44 6 44 6 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 14 2 12 2 0 12 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 26 18 8 18 2 6 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 74 56 18 56 6 12 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 26 +TABLE test t2 0 +TABLE test t3 74 +"================== con1 disconnected ==================" +"================== Step 13 ==================" +call dump_thread(); +username status +user1 not found +username event_name count_star +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 33 +user3 wait/lock/table/sql/handler 0 +username event_name count_star +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 10 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 48 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 20 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 10 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 48 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 20 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 100 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 100 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 26 TABLE test t1 +wait/io/table/sql/handler 74 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 16 2 16 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 8 2 6 2 0 6 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 50 44 6 44 6 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 14 2 12 2 0 12 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 26 18 8 18 2 6 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 74 56 18 56 6 12 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 26 +TABLE test t2 0 +TABLE test t3 74 +"================== con2 disconnected ==================" +"================== Step 14 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username event_name count_star +user3 wait/io/table/sql/handler 33 +user3 wait/lock/table/sql/handler 0 +username event_name count_star +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 10 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 48 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 20 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 10 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 48 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 20 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 100 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 100 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 26 TABLE test t1 +wait/io/table/sql/handler 74 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 16 2 16 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 8 2 6 2 0 6 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 50 44 6 44 6 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 14 2 12 2 0 12 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 26 18 8 18 2 6 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 74 56 18 56 6 12 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 26 +TABLE test t2 0 +TABLE test t3 74 +"================== con3 disconnected ==================" +"================== Step 15 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username event_name count_star +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 10 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 48 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 20 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 10 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 48 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 20 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 100 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 100 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 26 TABLE test t1 +wait/io/table/sql/handler 74 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 16 2 16 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 8 2 6 2 0 6 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 50 44 6 44 6 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 14 2 12 2 0 12 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 26 18 8 18 2 6 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 74 56 18 56 6 12 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 26 +TABLE test t2 0 +TABLE test t3 74 +"================== con4 disconnected ==================" +"================== Step 16 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 10 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 48 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 20 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 10 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 48 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 20 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 100 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 100 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 26 TABLE test t1 +wait/io/table/sql/handler 74 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 16 2 16 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 8 2 6 2 0 6 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 50 44 6 44 6 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 14 2 12 2 0 12 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 26 18 8 18 2 6 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 74 56 18 56 6 12 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 26 +TABLE test t2 0 +TABLE test t3 74 +truncate performance_schema.events_waits_summary_by_thread_by_event_name; +"================== BY_THREAD truncated ==================" +"================== Step 17 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 10 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 48 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 20 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 10 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 48 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 20 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 100 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 100 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 26 TABLE test t1 +wait/io/table/sql/handler 74 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 16 2 16 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 8 2 6 2 0 6 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 50 44 6 44 6 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 14 2 12 2 0 12 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 26 18 8 18 2 6 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 74 56 18 56 6 12 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 26 +TABLE test t2 0 +TABLE test t3 74 +truncate performance_schema.events_waits_summary_by_account_by_event_name; +"================== BY_ACCOUNT truncated ==================" +"================== Step 18 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 0 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 10 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 48 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 20 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 100 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 100 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 26 TABLE test t1 +wait/io/table/sql/handler 74 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 16 2 16 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 8 2 6 2 0 6 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 50 44 6 44 6 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 14 2 12 2 0 12 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 26 18 8 18 2 6 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 74 56 18 56 6 12 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 26 +TABLE test t2 0 +TABLE test t3 74 +truncate performance_schema.events_waits_summary_by_user_by_event_name; +"================== BY_USER truncated ==================" +"================== Step 19 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 0 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 100 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 100 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 26 TABLE test t1 +wait/io/table/sql/handler 74 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 16 2 16 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 8 2 6 2 0 6 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 50 44 6 44 6 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 14 2 12 2 0 12 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 26 18 8 18 2 6 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 74 56 18 56 6 12 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 26 +TABLE test t2 0 +TABLE test t3 74 +truncate performance_schema.events_waits_summary_by_host_by_event_name; +"================== BY_HOST truncated ==================" +"================== Step 21 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 0 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 100 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 26 TABLE test t1 +wait/io/table/sql/handler 74 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 16 2 16 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 8 2 6 2 0 6 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 50 44 6 44 6 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 14 2 12 2 0 12 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 26 18 8 18 2 6 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 74 56 18 56 6 12 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 26 +TABLE test t2 0 +TABLE test t3 74 +truncate performance_schema.events_waits_summary_global_by_event_name; +"================== GLOBAL truncated ==================" +"================== Step 21 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 0 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 0 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 26 TABLE test t1 +wait/io/table/sql/handler 74 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 0 0 0 0 0 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 0 0 0 0 0 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 0 0 0 0 0 0 0 +TABLE test t3 index_b 0 0 0 0 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 0 0 0 0 0 0 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 0 +TABLE test t2 0 +TABLE test t3 0 +show global status like "performance_schema%table%_lost"; +Variable_name Value +Performance_schema_table_handles_lost 0 +Performance_schema_table_instances_lost 0 +Performance_schema_table_lock_stat_lost 0 diff --git a/mysql-test/suite/table_io_aggregate_hist_2u_3t.result-pq b/mysql-test/suite/table_io_aggregate_hist_2u_3t.result-pq new file mode 100644 index 000000000000..c72bee60cf3b --- /dev/null +++ b/mysql-test/suite/table_io_aggregate_hist_2u_3t.result-pq @@ -0,0 +1,1801 @@ +update performance_schema.setup_instruments +set enabled='NO' where name='wait/lock/table/sql/handler'; +delete from performance_schema.setup_actors +where user in ('user2', 'user4'); +select * from performance_schema.setup_actors +order by USER, HOST, `ROLE`; +HOST USER ROLE ENABLED HISTORY +localhost user1 % YES YES +localhost user3 % YES YES +select * from performance_schema.setup_objects +order by object_type, object_schema, object_name; +OBJECT_TYPE OBJECT_SCHEMA OBJECT_NAME ENABLED TIMED +TABLE test t1 YES YES +TABLE test t2 YES NO +TABLE test t3 YES NO +select * from performance_schema.setup_consumers; +NAME ENABLED +events_stages_current YES +events_stages_history YES +events_stages_history_long YES +events_statements_current YES +events_statements_history YES +events_statements_history_long YES +events_transactions_current YES +events_transactions_history YES +events_transactions_history_long YES +events_waits_current YES +events_waits_history YES +events_waits_history_long YES +global_instrumentation YES +thread_instrumentation YES +statements_digest YES +flush tables; +truncate performance_schema.objects_summary_global_by_type; +truncate performance_schema.table_io_waits_summary_by_index_usage; +truncate performance_schema.table_io_waits_summary_by_table; +truncate performance_schema.table_lock_waits_summary_by_table; +truncate performance_schema.events_waits_summary_by_thread_by_event_name; +truncate performance_schema.events_waits_summary_by_account_by_event_name; +truncate performance_schema.events_waits_summary_by_user_by_event_name; +truncate performance_schema.events_waits_summary_by_host_by_event_name; +truncate performance_schema.events_waits_summary_global_by_event_name; +truncate performance_schema.events_waits_history_long; +show global variables like "performance_schema%table%"; +Variable_name Value +performance_schema_max_table_handles -1 +performance_schema_max_table_instances -1 +performance_schema_max_table_lock_stat -1 +show global status like "performance_schema%table%_lost"; +Variable_name Value +Performance_schema_table_handles_lost 0 +Performance_schema_table_instances_lost 0 +Performance_schema_table_lock_stat_lost 0 +"================== Step 1 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +execute dump_waits_user; +user event_name count_star +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 0 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 0 0 0 0 0 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 index_b 0 0 0 0 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 0 0 0 0 0 0 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 0 +TABLE test t2 0 +TABLE test t3 0 +select concat(current_user(), " is connected") as status; +status +user1@localhost is connected +"================== Step 2 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 0 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 0 0 0 0 0 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 index_b 0 0 0 0 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 0 0 0 0 0 0 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 0 +TABLE test t2 0 +TABLE test t3 0 +insert into test.t1 set a=101, b=1, c=1; +insert into test.t2 set a=102, b=2, c=2; +insert into test.t2 set a=103, b=3, c=3; +insert into test.t3 set a=104, b=4, c=4; +insert into test.t3 set a=105, b=5, c=5; +insert into test.t3 set a=106, b=6, c=6; +select * from test.t1; +a b c d +101 1 1 0 +select * from test.t2; +a b c d +102 2 2 0 +103 3 3 0 +select * from test.t3; +a b c d +104 4 4 0 +105 5 5 0 +106 6 6 0 +update test.t1 set d=d+1; +update test.t2 set d=d+1; +update test.t3 set d=d+1; +update test.t1 set d=d+1 where a=101; +update test.t2 set d=d+1 where a=101; +update test.t3 set d=d+1 where a=101; +select * from test.t1 force index(index_b) where b=5; +a b c d +select * from test.t2 force index(index_b) where b=5; +a b c d +select * from test.t3 force index(index_b) where b=5; +a b c d +105 5 5 1 +"================== con1 marker ==================" +"================== Step 3-A ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 25 +user1 wait/lock/table/sql/handler 0 +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 32 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 32 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 7 TABLE test t1 +wait/io/table/sql/handler 10 TABLE test t2 +wait/io/table/sql/handler 15 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 4 3 1 3 1 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 3 1 2 1 0 2 0 +TABLE test t2 NULL 7 5 2 5 2 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 3 1 2 1 0 2 0 +TABLE test t3 NULL 10 7 3 7 3 0 0 +TABLE test t3 index_b 1 1 0 1 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 4 1 3 1 0 3 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 7 4 3 4 1 2 0 +TABLE test t2 10 6 4 6 2 2 0 +TABLE test t3 15 9 6 9 3 3 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 7 +TABLE test t2 10 +TABLE test t3 15 +flush tables; +"================== con1 FLUSH ==================" +"================== Step 3-B ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 25 +user1 wait/lock/table/sql/handler 0 +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 32 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 32 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 7 TABLE test t1 +wait/io/table/sql/handler 10 TABLE test t2 +wait/io/table/sql/handler 15 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 4 3 1 3 1 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 3 1 2 1 0 2 0 +TABLE test t2 NULL 7 5 2 5 2 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 3 1 2 1 0 2 0 +TABLE test t3 NULL 10 7 3 7 3 0 0 +TABLE test t3 index_b 1 1 0 1 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 4 1 3 1 0 3 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 7 4 3 4 1 2 0 +TABLE test t2 10 6 4 6 2 2 0 +TABLE test t3 15 9 6 9 3 3 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 7 +TABLE test t2 10 +TABLE test t3 15 +select concat(current_user(), " is connected") as status; +status +user2@localhost is connected +"================== Step 4 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 25 +user1 wait/lock/table/sql/handler 0 +username event_name count_star +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 32 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 32 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 7 TABLE test t1 +wait/io/table/sql/handler 10 TABLE test t2 +wait/io/table/sql/handler 15 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 4 3 1 3 1 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 3 1 2 1 0 2 0 +TABLE test t2 NULL 7 5 2 5 2 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 3 1 2 1 0 2 0 +TABLE test t3 NULL 10 7 3 7 3 0 0 +TABLE test t3 index_b 1 1 0 1 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 4 1 3 1 0 3 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 7 4 3 4 1 2 0 +TABLE test t2 10 6 4 6 2 2 0 +TABLE test t3 15 9 6 9 3 3 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 7 +TABLE test t2 10 +TABLE test t3 15 +insert into test.t1 set a=201, b=1, c=1; +insert into test.t2 set a=202, b=2, c=2; +insert into test.t2 set a=203, b=3, c=3; +insert into test.t3 set a=204, b=4, c=4; +insert into test.t3 set a=205, b=5, c=5; +insert into test.t3 set a=206, b=6, c=6; +select * from test.t1; +a b c d +101 1 1 2 +201 1 1 0 +select * from test.t2; +a b c d +102 2 2 1 +103 3 3 1 +202 2 2 0 +203 3 3 0 +select * from test.t3; +a b c d +104 4 4 1 +105 5 5 1 +106 6 6 1 +204 4 4 0 +205 5 5 0 +206 6 6 0 +update test.t1 set d=d+1; +update test.t2 set d=d+1; +update test.t3 set d=d+1; +update test.t1 set d=d+1 where a=201; +update test.t2 set d=d+1 where a=201; +update test.t3 set d=d+1 where a=201; +select * from test.t1 force index(index_b) where b=5; +a b c d +select * from test.t2 force index(index_b) where b=5; +a b c d +select * from test.t3 force index(index_b) where b=5; +a b c d +105 5 5 2 +205 5 5 1 +"================== con2 marker ==================" +"================== Step 5 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 25 +user1 wait/lock/table/sql/handler 0 +username event_name count_star +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 14 +user2 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 14 +user2 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 46 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 46 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 9 TABLE test t1 +wait/io/table/sql/handler 14 TABLE test t2 +wait/io/table/sql/handler 23 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 6 5 1 5 1 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 3 1 2 1 0 2 0 +TABLE test t2 NULL 11 9 2 9 2 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 3 1 2 1 0 2 0 +TABLE test t3 NULL 16 13 3 13 3 0 0 +TABLE test t3 index_b 3 3 0 3 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 4 1 3 1 0 3 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 9 6 3 6 1 2 0 +TABLE test t2 14 10 4 10 2 2 0 +TABLE test t3 23 17 6 17 3 3 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 9 +TABLE test t2 14 +TABLE test t3 23 +select concat(current_user(), " is connected") as status; +status +user3@localhost is connected +"================== Step 6 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 25 +user1 wait/lock/table/sql/handler 0 +username event_name count_star +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 14 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 14 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 46 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 46 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 9 TABLE test t1 +wait/io/table/sql/handler 14 TABLE test t2 +wait/io/table/sql/handler 23 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 6 5 1 5 1 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 3 1 2 1 0 2 0 +TABLE test t2 NULL 11 9 2 9 2 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 3 1 2 1 0 2 0 +TABLE test t3 NULL 16 13 3 13 3 0 0 +TABLE test t3 index_b 3 3 0 3 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 4 1 3 1 0 3 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 9 6 3 6 1 2 0 +TABLE test t2 14 10 4 10 2 2 0 +TABLE test t3 23 17 6 17 3 3 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 9 +TABLE test t2 14 +TABLE test t3 23 +insert into test.t1 set a=301, b=1, c=1; +insert into test.t2 set a=302, b=2, c=2; +insert into test.t2 set a=303, b=3, c=3; +insert into test.t3 set a=304, b=4, c=4; +insert into test.t3 set a=305, b=5, c=5; +insert into test.t3 set a=306, b=6, c=6; +select * from test.t1; +a b c d +101 1 1 3 +201 1 1 2 +301 1 1 0 +select * from test.t2; +a b c d +102 2 2 2 +103 3 3 2 +202 2 2 1 +203 3 3 1 +302 2 2 0 +303 3 3 0 +select * from test.t3; +a b c d +104 4 4 2 +105 5 5 2 +106 6 6 2 +204 4 4 1 +205 5 5 1 +206 6 6 1 +304 4 4 0 +305 5 5 0 +306 6 6 0 +update test.t1 set d=d+1; +update test.t2 set d=d+1; +update test.t3 set d=d+1; +update test.t1 set d=d+1 where a=301; +update test.t2 set d=d+1 where a=301; +update test.t3 set d=d+1 where a=301; +select * from test.t1 force index(index_b) where b=5; +a b c d +select * from test.t2 force index(index_b) where b=5; +a b c d +select * from test.t3 force index(index_b) where b=5; +a b c d +105 5 5 3 +205 5 5 2 +305 5 5 1 +"================== con3 marker ==================" +"================== Step 7 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 25 +user1 wait/lock/table/sql/handler 0 +username event_name count_star +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 49 +user3 wait/lock/table/sql/handler 0 +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 14 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 70 +user3 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 14 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 70 +user3 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 116 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 116 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 22 TABLE test t1 +wait/io/table/sql/handler 36 TABLE test t2 +wait/io/table/sql/handler 58 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 14 12 2 12 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 8 2 6 2 0 6 0 +TABLE test t2 NULL 26 22 4 22 4 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 10 2 8 2 0 8 0 +TABLE test t3 NULL 38 32 6 32 6 0 0 +TABLE test t3 index_b 6 6 0 6 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 14 2 12 2 0 12 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 22 14 8 14 2 6 0 +TABLE test t2 36 24 12 24 4 8 0 +TABLE test t3 58 40 18 40 6 12 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 22 +TABLE test t2 36 +TABLE test t3 58 +select concat(current_user(), " is connected") as status; +status +user4@localhost is connected +"================== Step 8 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 25 +user1 wait/lock/table/sql/handler 0 +username event_name count_star +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 49 +user3 wait/lock/table/sql/handler 0 +username event_name count_star +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 14 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 70 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 0 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 14 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 70 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 116 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 116 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 22 TABLE test t1 +wait/io/table/sql/handler 36 TABLE test t2 +wait/io/table/sql/handler 58 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 14 12 2 12 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 8 2 6 2 0 6 0 +TABLE test t2 NULL 26 22 4 22 4 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 10 2 8 2 0 8 0 +TABLE test t3 NULL 38 32 6 32 6 0 0 +TABLE test t3 index_b 6 6 0 6 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 14 2 12 2 0 12 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 22 14 8 14 2 6 0 +TABLE test t2 36 24 12 24 4 8 0 +TABLE test t3 58 40 18 40 6 12 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 22 +TABLE test t2 36 +TABLE test t3 58 +insert into test.t1 set a=401, b=1, c=1; +insert into test.t2 set a=402, b=2, c=2; +insert into test.t2 set a=403, b=3, c=3; +insert into test.t3 set a=404, b=4, c=4; +insert into test.t3 set a=405, b=5, c=5; +insert into test.t3 set a=406, b=6, c=6; +select * from test.t1; +a b c d +101 1 1 4 +201 1 1 3 +301 1 1 2 +401 1 1 0 +select * from test.t2; +a b c d +102 2 2 3 +103 3 3 3 +202 2 2 2 +203 3 3 2 +302 2 2 1 +303 3 3 1 +402 2 2 0 +403 3 3 0 +select * from test.t3; +a b c d +104 4 4 3 +105 5 5 3 +106 6 6 3 +204 4 4 2 +205 5 5 2 +206 6 6 2 +304 4 4 1 +305 5 5 1 +306 6 6 1 +404 4 4 0 +405 5 5 0 +406 6 6 0 +update test.t1 set d=d+1; +update test.t2 set d=d+1; +update test.t3 set d=d+1; +update test.t1 set d=d+1 where a=401; +update test.t2 set d=d+1 where a=401; +update test.t3 set d=d+1 where a=401; +select * from test.t1 force index(index_b) where b=5; +a b c d +select * from test.t2 force index(index_b) where b=5; +a b c d +select * from test.t3 force index(index_b) where b=5; +a b c d +105 5 5 4 +205 5 5 3 +305 5 5 2 +405 5 5 1 +"================== con4 marker ==================" +"================== Step 9 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 25 +user1 wait/lock/table/sql/handler 0 +username event_name count_star +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 49 +user3 wait/lock/table/sql/handler 0 +username event_name count_star +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 14 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 70 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 28 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 14 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 70 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 28 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 144 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 144 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 26 TABLE test t1 +wait/io/table/sql/handler 44 TABLE test t2 +wait/io/table/sql/handler 74 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 16 2 16 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 8 2 6 2 0 6 0 +TABLE test t2 NULL 34 30 4 30 4 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 10 2 8 2 0 8 0 +TABLE test t3 NULL 50 44 6 44 6 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 14 2 12 2 0 12 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 26 18 8 18 2 6 0 +TABLE test t2 44 32 12 32 4 8 0 +TABLE test t3 74 56 18 56 6 12 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 26 +TABLE test t2 44 +TABLE test t3 74 +lock tables test.t1 read, test.t2 read, test.t3 read; +unlock tables; +lock tables test.t1 write, test.t2 write, test.t3 write; +unlock tables; +"================== con1 marker ==================" +"================== Step 10 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 25 +user1 wait/lock/table/sql/handler 0 +username event_name count_star +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 49 +user3 wait/lock/table/sql/handler 0 +username event_name count_star +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 14 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 70 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 28 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 14 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 70 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 28 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 144 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 144 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 26 TABLE test t1 +wait/io/table/sql/handler 44 TABLE test t2 +wait/io/table/sql/handler 74 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 16 2 16 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 8 2 6 2 0 6 0 +TABLE test t2 NULL 34 30 4 30 4 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 10 2 8 2 0 8 0 +TABLE test t3 NULL 50 44 6 44 6 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 14 2 12 2 0 12 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 26 18 8 18 2 6 0 +TABLE test t2 44 32 12 32 4 8 0 +TABLE test t3 74 56 18 56 6 12 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 26 +TABLE test t2 44 +TABLE test t3 74 +flush tables; +"================== flush marker ==================" +"================== Step 11 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 25 +user1 wait/lock/table/sql/handler 0 +username event_name count_star +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 49 +user3 wait/lock/table/sql/handler 0 +username event_name count_star +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 14 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 70 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 28 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 14 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 70 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 28 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 144 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 144 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 26 TABLE test t1 +wait/io/table/sql/handler 44 TABLE test t2 +wait/io/table/sql/handler 74 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 16 2 16 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 8 2 6 2 0 6 0 +TABLE test t2 NULL 34 30 4 30 4 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 10 2 8 2 0 8 0 +TABLE test t3 NULL 50 44 6 44 6 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 14 2 12 2 0 12 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 26 18 8 18 2 6 0 +TABLE test t2 44 32 12 32 4 8 0 +TABLE test t3 74 56 18 56 6 12 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 26 +TABLE test t2 44 +TABLE test t3 74 +set global read_only=1; +set global read_only=0; +"================== global read_only marker ==================" +"================== Step 12 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 25 +user1 wait/lock/table/sql/handler 0 +username event_name count_star +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 49 +user3 wait/lock/table/sql/handler 0 +username event_name count_star +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 14 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 70 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 28 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 14 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 70 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 28 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 144 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 144 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 26 TABLE test t1 +wait/io/table/sql/handler 44 TABLE test t2 +wait/io/table/sql/handler 74 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 16 2 16 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 8 2 6 2 0 6 0 +TABLE test t2 NULL 34 30 4 30 4 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 10 2 8 2 0 8 0 +TABLE test t3 NULL 50 44 6 44 6 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 14 2 12 2 0 12 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 26 18 8 18 2 6 0 +TABLE test t2 44 32 12 32 4 8 0 +TABLE test t3 74 56 18 56 6 12 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 26 +TABLE test t2 44 +TABLE test t3 74 +"================== con1 disconnected ==================" +"================== Step 13 ==================" +call dump_thread(); +username status +user1 not found +username event_name count_star +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 49 +user3 wait/lock/table/sql/handler 0 +username event_name count_star +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 14 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 70 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 28 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 14 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 70 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 28 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 144 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 144 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 26 TABLE test t1 +wait/io/table/sql/handler 44 TABLE test t2 +wait/io/table/sql/handler 74 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 16 2 16 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 8 2 6 2 0 6 0 +TABLE test t2 NULL 34 30 4 30 4 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 10 2 8 2 0 8 0 +TABLE test t3 NULL 50 44 6 44 6 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 14 2 12 2 0 12 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 26 18 8 18 2 6 0 +TABLE test t2 44 32 12 32 4 8 0 +TABLE test t3 74 56 18 56 6 12 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 26 +TABLE test t2 44 +TABLE test t3 74 +"================== con2 disconnected ==================" +"================== Step 14 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username event_name count_star +user3 wait/io/table/sql/handler 49 +user3 wait/lock/table/sql/handler 0 +username event_name count_star +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 14 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 70 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 28 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 14 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 70 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 28 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 144 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 144 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 26 TABLE test t1 +wait/io/table/sql/handler 44 TABLE test t2 +wait/io/table/sql/handler 74 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 16 2 16 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 8 2 6 2 0 6 0 +TABLE test t2 NULL 34 30 4 30 4 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 10 2 8 2 0 8 0 +TABLE test t3 NULL 50 44 6 44 6 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 14 2 12 2 0 12 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 26 18 8 18 2 6 0 +TABLE test t2 44 32 12 32 4 8 0 +TABLE test t3 74 56 18 56 6 12 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 26 +TABLE test t2 44 +TABLE test t3 74 +"================== con3 disconnected ==================" +"================== Step 15 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username event_name count_star +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 14 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 70 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 28 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 14 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 70 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 28 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 144 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 144 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 26 TABLE test t1 +wait/io/table/sql/handler 44 TABLE test t2 +wait/io/table/sql/handler 74 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 16 2 16 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 8 2 6 2 0 6 0 +TABLE test t2 NULL 34 30 4 30 4 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 10 2 8 2 0 8 0 +TABLE test t3 NULL 50 44 6 44 6 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 14 2 12 2 0 12 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 26 18 8 18 2 6 0 +TABLE test t2 44 32 12 32 4 8 0 +TABLE test t3 74 56 18 56 6 12 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 26 +TABLE test t2 44 +TABLE test t3 74 +"================== con4 disconnected ==================" +"================== Step 16 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 14 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 70 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 28 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 14 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 70 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 28 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 144 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 144 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 26 TABLE test t1 +wait/io/table/sql/handler 44 TABLE test t2 +wait/io/table/sql/handler 74 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 16 2 16 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 8 2 6 2 0 6 0 +TABLE test t2 NULL 34 30 4 30 4 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 10 2 8 2 0 8 0 +TABLE test t3 NULL 50 44 6 44 6 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 14 2 12 2 0 12 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 26 18 8 18 2 6 0 +TABLE test t2 44 32 12 32 4 8 0 +TABLE test t3 74 56 18 56 6 12 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 26 +TABLE test t2 44 +TABLE test t3 74 +truncate performance_schema.events_waits_summary_by_thread_by_event_name; +"================== BY_THREAD truncated ==================" +"================== Step 17 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 14 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 70 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 28 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 14 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 70 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 28 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 144 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 144 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 26 TABLE test t1 +wait/io/table/sql/handler 44 TABLE test t2 +wait/io/table/sql/handler 74 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 16 2 16 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 8 2 6 2 0 6 0 +TABLE test t2 NULL 34 30 4 30 4 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 10 2 8 2 0 8 0 +TABLE test t3 NULL 50 44 6 44 6 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 14 2 12 2 0 12 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 26 18 8 18 2 6 0 +TABLE test t2 44 32 12 32 4 8 0 +TABLE test t3 74 56 18 56 6 12 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 26 +TABLE test t2 44 +TABLE test t3 74 +truncate performance_schema.events_waits_summary_by_account_by_event_name; +"================== BY_ACCOUNT truncated ==================" +"================== Step 18 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 0 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 14 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 70 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 28 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 144 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 144 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 26 TABLE test t1 +wait/io/table/sql/handler 44 TABLE test t2 +wait/io/table/sql/handler 74 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 16 2 16 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 8 2 6 2 0 6 0 +TABLE test t2 NULL 34 30 4 30 4 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 10 2 8 2 0 8 0 +TABLE test t3 NULL 50 44 6 44 6 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 14 2 12 2 0 12 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 26 18 8 18 2 6 0 +TABLE test t2 44 32 12 32 4 8 0 +TABLE test t3 74 56 18 56 6 12 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 26 +TABLE test t2 44 +TABLE test t3 74 +truncate performance_schema.events_waits_summary_by_user_by_event_name; +"================== BY_USER truncated ==================" +"================== Step 19 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 0 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 144 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 144 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 26 TABLE test t1 +wait/io/table/sql/handler 44 TABLE test t2 +wait/io/table/sql/handler 74 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 16 2 16 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 8 2 6 2 0 6 0 +TABLE test t2 NULL 34 30 4 30 4 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 10 2 8 2 0 8 0 +TABLE test t3 NULL 50 44 6 44 6 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 14 2 12 2 0 12 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 26 18 8 18 2 6 0 +TABLE test t2 44 32 12 32 4 8 0 +TABLE test t3 74 56 18 56 6 12 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 26 +TABLE test t2 44 +TABLE test t3 74 +truncate performance_schema.events_waits_summary_by_host_by_event_name; +"================== BY_HOST truncated ==================" +"================== Step 21 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 0 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 144 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 26 TABLE test t1 +wait/io/table/sql/handler 44 TABLE test t2 +wait/io/table/sql/handler 74 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 16 2 16 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 8 2 6 2 0 6 0 +TABLE test t2 NULL 34 30 4 30 4 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 10 2 8 2 0 8 0 +TABLE test t3 NULL 50 44 6 44 6 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 14 2 12 2 0 12 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 26 18 8 18 2 6 0 +TABLE test t2 44 32 12 32 4 8 0 +TABLE test t3 74 56 18 56 6 12 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 26 +TABLE test t2 44 +TABLE test t3 74 +truncate performance_schema.events_waits_summary_global_by_event_name; +"================== GLOBAL truncated ==================" +"================== Step 21 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 0 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 0 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 26 TABLE test t1 +wait/io/table/sql/handler 44 TABLE test t2 +wait/io/table/sql/handler 74 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 0 0 0 0 0 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 0 0 0 0 0 0 0 +TABLE test t2 NULL 0 0 0 0 0 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 0 0 0 0 0 0 0 +TABLE test t3 index_b 0 0 0 0 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 0 0 0 0 0 0 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 0 +TABLE test t2 0 +TABLE test t3 0 +show global status like "performance_schema%table%_lost"; +Variable_name Value +Performance_schema_table_handles_lost 0 +Performance_schema_table_instances_lost 0 +Performance_schema_table_lock_stat_lost 0 diff --git a/mysql-test/suite/table_io_aggregate_hist_4u_2t.result-pq b/mysql-test/suite/table_io_aggregate_hist_4u_2t.result-pq new file mode 100644 index 000000000000..53b272be8e30 --- /dev/null +++ b/mysql-test/suite/table_io_aggregate_hist_4u_2t.result-pq @@ -0,0 +1,1762 @@ +update performance_schema.setup_instruments +set enabled='NO' where name='wait/lock/table/sql/handler'; +delete from performance_schema.setup_objects +where object_name='t2'; +select * from performance_schema.setup_actors +order by USER, HOST, `ROLE`; +HOST USER ROLE ENABLED HISTORY +localhost user1 % YES YES +localhost user2 % YES YES +localhost user3 % YES YES +localhost user4 % YES YES +select * from performance_schema.setup_objects +order by object_type, object_schema, object_name; +OBJECT_TYPE OBJECT_SCHEMA OBJECT_NAME ENABLED TIMED +TABLE test t1 YES YES +TABLE test t3 YES NO +select * from performance_schema.setup_consumers; +NAME ENABLED +events_stages_current YES +events_stages_history YES +events_stages_history_long YES +events_statements_current YES +events_statements_history YES +events_statements_history_long YES +events_transactions_current YES +events_transactions_history YES +events_transactions_history_long YES +events_waits_current YES +events_waits_history YES +events_waits_history_long YES +global_instrumentation YES +thread_instrumentation YES +statements_digest YES +flush tables; +truncate performance_schema.objects_summary_global_by_type; +truncate performance_schema.table_io_waits_summary_by_index_usage; +truncate performance_schema.table_io_waits_summary_by_table; +truncate performance_schema.table_lock_waits_summary_by_table; +truncate performance_schema.events_waits_summary_by_thread_by_event_name; +truncate performance_schema.events_waits_summary_by_account_by_event_name; +truncate performance_schema.events_waits_summary_by_user_by_event_name; +truncate performance_schema.events_waits_summary_by_host_by_event_name; +truncate performance_schema.events_waits_summary_global_by_event_name; +truncate performance_schema.events_waits_history_long; +show global variables like "performance_schema%table%"; +Variable_name Value +performance_schema_max_table_handles -1 +performance_schema_max_table_instances -1 +performance_schema_max_table_lock_stat -1 +show global status like "performance_schema%table%_lost"; +Variable_name Value +Performance_schema_table_handles_lost 0 +Performance_schema_table_instances_lost 0 +Performance_schema_table_lock_stat_lost 0 +"================== Step 1 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +execute dump_waits_user; +user event_name count_star +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 0 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 0 0 0 0 0 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 index_b 0 0 0 0 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 0 0 0 0 0 0 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 0 +TABLE test t2 0 +TABLE test t3 0 +select concat(current_user(), " is connected") as status; +status +user1@localhost is connected +"================== Step 2 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 0 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 0 0 0 0 0 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 index_b 0 0 0 0 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 0 0 0 0 0 0 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 0 +TABLE test t2 0 +TABLE test t3 0 +insert into test.t1 set a=101, b=1, c=1; +insert into test.t2 set a=102, b=2, c=2; +insert into test.t2 set a=103, b=3, c=3; +insert into test.t3 set a=104, b=4, c=4; +insert into test.t3 set a=105, b=5, c=5; +insert into test.t3 set a=106, b=6, c=6; +select * from test.t1; +a b c d +101 1 1 0 +select * from test.t2; +a b c d +102 2 2 0 +103 3 3 0 +select * from test.t3; +a b c d +104 4 4 0 +105 5 5 0 +106 6 6 0 +update test.t1 set d=d+1; +update test.t2 set d=d+1; +update test.t3 set d=d+1; +update test.t1 set d=d+1 where a=101; +update test.t2 set d=d+1 where a=101; +update test.t3 set d=d+1 where a=101; +select * from test.t1 force index(index_b) where b=5; +a b c d +select * from test.t2 force index(index_b) where b=5; +a b c d +select * from test.t3 force index(index_b) where b=5; +a b c d +105 5 5 1 +"================== con1 marker ==================" +"================== Step 3-A ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 17 +user1 wait/lock/table/sql/handler 0 +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 22 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 22 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 7 TABLE test t1 +wait/io/table/sql/handler 15 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 4 3 1 3 1 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 3 1 2 1 0 2 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 10 7 3 7 3 0 0 +TABLE test t3 index_b 1 1 0 1 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 4 1 3 1 0 3 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 7 4 3 4 1 2 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 15 9 6 9 3 3 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 7 +TABLE test t2 0 +TABLE test t3 15 +flush tables; +"================== con1 FLUSH ==================" +"================== Step 3-B ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 17 +user1 wait/lock/table/sql/handler 0 +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 22 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 22 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 7 TABLE test t1 +wait/io/table/sql/handler 15 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 4 3 1 3 1 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 3 1 2 1 0 2 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 10 7 3 7 3 0 0 +TABLE test t3 index_b 1 1 0 1 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 4 1 3 1 0 3 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 7 4 3 4 1 2 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 15 9 6 9 3 3 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 7 +TABLE test t2 0 +TABLE test t3 15 +select concat(current_user(), " is connected") as status; +status +user2@localhost is connected +"================== Step 4 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 17 +user1 wait/lock/table/sql/handler 0 +username event_name count_star +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 22 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 22 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 7 TABLE test t1 +wait/io/table/sql/handler 15 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 4 3 1 3 1 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 3 1 2 1 0 2 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 10 7 3 7 3 0 0 +TABLE test t3 index_b 1 1 0 1 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 4 1 3 1 0 3 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 7 4 3 4 1 2 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 15 9 6 9 3 3 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 7 +TABLE test t2 0 +TABLE test t3 15 +insert into test.t1 set a=201, b=1, c=1; +insert into test.t2 set a=202, b=2, c=2; +insert into test.t2 set a=203, b=3, c=3; +insert into test.t3 set a=204, b=4, c=4; +insert into test.t3 set a=205, b=5, c=5; +insert into test.t3 set a=206, b=6, c=6; +select * from test.t1; +a b c d +101 1 1 2 +201 1 1 0 +select * from test.t2; +a b c d +102 2 2 1 +103 3 3 1 +202 2 2 0 +203 3 3 0 +select * from test.t3; +a b c d +104 4 4 1 +105 5 5 1 +106 6 6 1 +204 4 4 0 +205 5 5 0 +206 6 6 0 +update test.t1 set d=d+1; +update test.t2 set d=d+1; +update test.t3 set d=d+1; +update test.t1 set d=d+1 where a=201; +update test.t2 set d=d+1 where a=201; +update test.t3 set d=d+1 where a=201; +select * from test.t1 force index(index_b) where b=5; +a b c d +select * from test.t2 force index(index_b) where b=5; +a b c d +select * from test.t3 force index(index_b) where b=5; +a b c d +105 5 5 2 +205 5 5 1 +"================== con2 marker ==================" +"================== Step 5 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 17 +user1 wait/lock/table/sql/handler 0 +username event_name count_star +user2 wait/io/table/sql/handler 25 +user2 wait/lock/table/sql/handler 0 +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 35 +user2 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 35 +user2 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 57 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 57 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 17 TABLE test t1 +wait/io/table/sql/handler 40 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 10 8 2 8 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 7 2 5 2 0 5 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 26 20 6 20 6 0 0 +TABLE test t3 index_b 3 3 0 3 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 11 2 9 2 0 9 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 17 10 7 10 2 5 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 40 25 15 25 6 9 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 17 +TABLE test t2 0 +TABLE test t3 40 +select concat(current_user(), " is connected") as status; +status +user3@localhost is connected +"================== Step 6 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 17 +user1 wait/lock/table/sql/handler 0 +username event_name count_star +user2 wait/io/table/sql/handler 25 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 35 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 35 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 57 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 57 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 17 TABLE test t1 +wait/io/table/sql/handler 40 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 10 8 2 8 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 7 2 5 2 0 5 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 26 20 6 20 6 0 0 +TABLE test t3 index_b 3 3 0 3 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 11 2 9 2 0 9 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 17 10 7 10 2 5 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 40 25 15 25 6 9 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 17 +TABLE test t2 0 +TABLE test t3 40 +insert into test.t1 set a=301, b=1, c=1; +insert into test.t2 set a=302, b=2, c=2; +insert into test.t2 set a=303, b=3, c=3; +insert into test.t3 set a=304, b=4, c=4; +insert into test.t3 set a=305, b=5, c=5; +insert into test.t3 set a=306, b=6, c=6; +select * from test.t1; +a b c d +101 1 1 3 +201 1 1 2 +301 1 1 0 +select * from test.t2; +a b c d +102 2 2 2 +103 3 3 2 +202 2 2 1 +203 3 3 1 +302 2 2 0 +303 3 3 0 +select * from test.t3; +a b c d +104 4 4 2 +105 5 5 2 +106 6 6 2 +204 4 4 1 +205 5 5 1 +206 6 6 1 +304 4 4 0 +305 5 5 0 +306 6 6 0 +update test.t1 set d=d+1; +update test.t2 set d=d+1; +update test.t3 set d=d+1; +update test.t1 set d=d+1 where a=301; +update test.t2 set d=d+1 where a=301; +update test.t3 set d=d+1 where a=301; +select * from test.t1 force index(index_b) where b=5; +a b c d +select * from test.t2 force index(index_b) where b=5; +a b c d +select * from test.t3 force index(index_b) where b=5; +a b c d +105 5 5 3 +205 5 5 2 +305 5 5 1 +"================== con3 marker ==================" +"================== Step 7 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 17 +user1 wait/lock/table/sql/handler 0 +username event_name count_star +user2 wait/io/table/sql/handler 25 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 33 +user3 wait/lock/table/sql/handler 0 +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 35 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 48 +user3 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 35 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 48 +user3 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 105 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 105 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 30 TABLE test t1 +wait/io/table/sql/handler 75 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 15 3 15 3 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 12 3 9 3 0 9 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 48 39 9 39 9 0 0 +TABLE test t3 index_b 6 6 0 6 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 21 3 18 3 0 18 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 30 18 12 18 3 9 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 75 48 27 48 9 18 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 30 +TABLE test t2 0 +TABLE test t3 75 +select concat(current_user(), " is connected") as status; +status +user4@localhost is connected +"================== Step 8 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 17 +user1 wait/lock/table/sql/handler 0 +username event_name count_star +user2 wait/io/table/sql/handler 25 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 33 +user3 wait/lock/table/sql/handler 0 +username event_name count_star +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 35 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 48 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 0 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 35 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 48 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 105 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 105 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 30 TABLE test t1 +wait/io/table/sql/handler 75 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 15 3 15 3 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 12 3 9 3 0 9 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 48 39 9 39 9 0 0 +TABLE test t3 index_b 6 6 0 6 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 21 3 18 3 0 18 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 30 18 12 18 3 9 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 75 48 27 48 9 18 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 30 +TABLE test t2 0 +TABLE test t3 75 +insert into test.t1 set a=401, b=1, c=1; +insert into test.t2 set a=402, b=2, c=2; +insert into test.t2 set a=403, b=3, c=3; +insert into test.t3 set a=404, b=4, c=4; +insert into test.t3 set a=405, b=5, c=5; +insert into test.t3 set a=406, b=6, c=6; +select * from test.t1; +a b c d +101 1 1 4 +201 1 1 3 +301 1 1 2 +401 1 1 0 +select * from test.t2; +a b c d +102 2 2 3 +103 3 3 3 +202 2 2 2 +203 3 3 2 +302 2 2 1 +303 3 3 1 +402 2 2 0 +403 3 3 0 +select * from test.t3; +a b c d +104 4 4 3 +105 5 5 3 +106 6 6 3 +204 4 4 2 +205 5 5 2 +206 6 6 2 +304 4 4 1 +305 5 5 1 +306 6 6 1 +404 4 4 0 +405 5 5 0 +406 6 6 0 +update test.t1 set d=d+1; +update test.t2 set d=d+1; +update test.t3 set d=d+1; +update test.t1 set d=d+1 where a=401; +update test.t2 set d=d+1 where a=401; +update test.t3 set d=d+1 where a=401; +select * from test.t1 force index(index_b) where b=5; +a b c d +select * from test.t2 force index(index_b) where b=5; +a b c d +select * from test.t3 force index(index_b) where b=5; +a b c d +105 5 5 4 +205 5 5 3 +305 5 5 2 +405 5 5 1 +"================== con4 marker ==================" +"================== Step 9 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 17 +user1 wait/lock/table/sql/handler 0 +username event_name count_star +user2 wait/io/table/sql/handler 25 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 33 +user3 wait/lock/table/sql/handler 0 +username event_name count_star +user4 wait/io/table/sql/handler 41 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 35 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 48 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 61 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 35 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 48 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 61 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 166 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 166 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 46 TABLE test t1 +wait/io/table/sql/handler 120 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 46 +TABLE test t2 0 +TABLE test t3 120 +lock tables test.t1 read, test.t2 read, test.t3 read; +unlock tables; +lock tables test.t1 write, test.t2 write, test.t3 write; +unlock tables; +"================== con1 marker ==================" +"================== Step 10 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 17 +user1 wait/lock/table/sql/handler 0 +username event_name count_star +user2 wait/io/table/sql/handler 25 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 33 +user3 wait/lock/table/sql/handler 0 +username event_name count_star +user4 wait/io/table/sql/handler 41 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 35 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 48 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 61 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 35 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 48 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 61 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 166 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 166 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 46 TABLE test t1 +wait/io/table/sql/handler 120 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 46 +TABLE test t2 0 +TABLE test t3 120 +flush tables; +"================== flush marker ==================" +"================== Step 11 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 17 +user1 wait/lock/table/sql/handler 0 +username event_name count_star +user2 wait/io/table/sql/handler 25 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 33 +user3 wait/lock/table/sql/handler 0 +username event_name count_star +user4 wait/io/table/sql/handler 41 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 35 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 48 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 61 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 35 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 48 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 61 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 166 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 166 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 46 TABLE test t1 +wait/io/table/sql/handler 120 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 46 +TABLE test t2 0 +TABLE test t3 120 +set global read_only=1; +set global read_only=0; +"================== global read_only marker ==================" +"================== Step 12 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 17 +user1 wait/lock/table/sql/handler 0 +username event_name count_star +user2 wait/io/table/sql/handler 25 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 33 +user3 wait/lock/table/sql/handler 0 +username event_name count_star +user4 wait/io/table/sql/handler 41 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 35 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 48 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 61 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 35 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 48 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 61 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 166 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 166 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 46 TABLE test t1 +wait/io/table/sql/handler 120 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 46 +TABLE test t2 0 +TABLE test t3 120 +"================== con1 disconnected ==================" +"================== Step 13 ==================" +call dump_thread(); +username status +user1 not found +username event_name count_star +user2 wait/io/table/sql/handler 25 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 33 +user3 wait/lock/table/sql/handler 0 +username event_name count_star +user4 wait/io/table/sql/handler 41 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 35 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 48 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 61 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 35 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 48 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 61 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 166 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 166 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 46 TABLE test t1 +wait/io/table/sql/handler 120 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 46 +TABLE test t2 0 +TABLE test t3 120 +"================== con2 disconnected ==================" +"================== Step 14 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username event_name count_star +user3 wait/io/table/sql/handler 33 +user3 wait/lock/table/sql/handler 0 +username event_name count_star +user4 wait/io/table/sql/handler 41 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 35 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 48 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 61 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 35 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 48 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 61 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 166 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 166 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 46 TABLE test t1 +wait/io/table/sql/handler 120 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 46 +TABLE test t2 0 +TABLE test t3 120 +"================== con3 disconnected ==================" +"================== Step 15 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username event_name count_star +user4 wait/io/table/sql/handler 41 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 35 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 48 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 61 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 35 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 48 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 61 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 166 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 166 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 46 TABLE test t1 +wait/io/table/sql/handler 120 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 46 +TABLE test t2 0 +TABLE test t3 120 +"================== con4 disconnected ==================" +"================== Step 16 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 35 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 48 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 61 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 35 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 48 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 61 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 166 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 166 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 46 TABLE test t1 +wait/io/table/sql/handler 120 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 46 +TABLE test t2 0 +TABLE test t3 120 +truncate performance_schema.events_waits_summary_by_thread_by_event_name; +"================== BY_THREAD truncated ==================" +"================== Step 17 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 35 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 48 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 61 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 35 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 48 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 61 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 166 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 166 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 46 TABLE test t1 +wait/io/table/sql/handler 120 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 46 +TABLE test t2 0 +TABLE test t3 120 +truncate performance_schema.events_waits_summary_by_account_by_event_name; +"================== BY_ACCOUNT truncated ==================" +"================== Step 18 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 0 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 35 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 48 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 61 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 166 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 166 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 46 TABLE test t1 +wait/io/table/sql/handler 120 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 46 +TABLE test t2 0 +TABLE test t3 120 +truncate performance_schema.events_waits_summary_by_user_by_event_name; +"================== BY_USER truncated ==================" +"================== Step 19 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 0 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 166 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 166 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 46 TABLE test t1 +wait/io/table/sql/handler 120 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 46 +TABLE test t2 0 +TABLE test t3 120 +truncate performance_schema.events_waits_summary_by_host_by_event_name; +"================== BY_HOST truncated ==================" +"================== Step 21 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 0 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 166 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 46 TABLE test t1 +wait/io/table/sql/handler 120 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 46 +TABLE test t2 0 +TABLE test t3 120 +truncate performance_schema.events_waits_summary_global_by_event_name; +"================== GLOBAL truncated ==================" +"================== Step 21 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 0 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 0 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 46 TABLE test t1 +wait/io/table/sql/handler 120 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 0 0 0 0 0 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 0 0 0 0 0 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 0 0 0 0 0 0 0 +TABLE test t3 index_b 0 0 0 0 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 0 0 0 0 0 0 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 0 +TABLE test t2 0 +TABLE test t3 0 +show global status like "performance_schema%table%_lost"; +Variable_name Value +Performance_schema_table_handles_lost 0 +Performance_schema_table_instances_lost 0 +Performance_schema_table_lock_stat_lost 0 diff --git a/mysql-test/suite/table_io_aggregate_hist_4u_3t.result-pq b/mysql-test/suite/table_io_aggregate_hist_4u_3t.result-pq new file mode 100644 index 000000000000..bc3667dd6b11 --- /dev/null +++ b/mysql-test/suite/table_io_aggregate_hist_4u_3t.result-pq @@ -0,0 +1,1801 @@ +update performance_schema.setup_instruments +set enabled='NO' where name='wait/lock/table/sql/handler'; +select * from performance_schema.setup_actors +order by USER, HOST, `ROLE`; +HOST USER ROLE ENABLED HISTORY +localhost user1 % YES YES +localhost user2 % YES YES +localhost user3 % YES YES +localhost user4 % YES YES +select * from performance_schema.setup_objects +order by object_type, object_schema, object_name; +OBJECT_TYPE OBJECT_SCHEMA OBJECT_NAME ENABLED TIMED +TABLE test t1 YES YES +TABLE test t2 YES NO +TABLE test t3 YES NO +select * from performance_schema.setup_consumers; +NAME ENABLED +events_stages_current YES +events_stages_history YES +events_stages_history_long YES +events_statements_current YES +events_statements_history YES +events_statements_history_long YES +events_transactions_current YES +events_transactions_history YES +events_transactions_history_long YES +events_waits_current YES +events_waits_history YES +events_waits_history_long YES +global_instrumentation YES +thread_instrumentation YES +statements_digest YES +flush tables; +truncate performance_schema.objects_summary_global_by_type; +truncate performance_schema.table_io_waits_summary_by_index_usage; +truncate performance_schema.table_io_waits_summary_by_table; +truncate performance_schema.table_lock_waits_summary_by_table; +truncate performance_schema.events_waits_summary_by_thread_by_event_name; +truncate performance_schema.events_waits_summary_by_account_by_event_name; +truncate performance_schema.events_waits_summary_by_user_by_event_name; +truncate performance_schema.events_waits_summary_by_host_by_event_name; +truncate performance_schema.events_waits_summary_global_by_event_name; +truncate performance_schema.events_waits_history_long; +show global variables like "performance_schema%table%"; +Variable_name Value +performance_schema_max_table_handles -1 +performance_schema_max_table_instances -1 +performance_schema_max_table_lock_stat -1 +show global status like "performance_schema%table%_lost"; +Variable_name Value +Performance_schema_table_handles_lost 0 +Performance_schema_table_instances_lost 0 +Performance_schema_table_lock_stat_lost 0 +"================== Step 1 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +execute dump_waits_user; +user event_name count_star +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 0 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 0 0 0 0 0 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 index_b 0 0 0 0 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 0 0 0 0 0 0 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 0 +TABLE test t2 0 +TABLE test t3 0 +select concat(current_user(), " is connected") as status; +status +user1@localhost is connected +"================== Step 2 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 0 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 0 0 0 0 0 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 index_b 0 0 0 0 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 0 0 0 0 0 0 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 0 +TABLE test t2 0 +TABLE test t3 0 +insert into test.t1 set a=101, b=1, c=1; +insert into test.t2 set a=102, b=2, c=2; +insert into test.t2 set a=103, b=3, c=3; +insert into test.t3 set a=104, b=4, c=4; +insert into test.t3 set a=105, b=5, c=5; +insert into test.t3 set a=106, b=6, c=6; +select * from test.t1; +a b c d +101 1 1 0 +select * from test.t2; +a b c d +102 2 2 0 +103 3 3 0 +select * from test.t3; +a b c d +104 4 4 0 +105 5 5 0 +106 6 6 0 +update test.t1 set d=d+1; +update test.t2 set d=d+1; +update test.t3 set d=d+1; +update test.t1 set d=d+1 where a=101; +update test.t2 set d=d+1 where a=101; +update test.t3 set d=d+1 where a=101; +select * from test.t1 force index(index_b) where b=5; +a b c d +select * from test.t2 force index(index_b) where b=5; +a b c d +select * from test.t3 force index(index_b) where b=5; +a b c d +105 5 5 1 +"================== con1 marker ==================" +"================== Step 3-A ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 25 +user1 wait/lock/table/sql/handler 0 +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 32 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 32 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 7 TABLE test t1 +wait/io/table/sql/handler 10 TABLE test t2 +wait/io/table/sql/handler 15 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 4 3 1 3 1 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 3 1 2 1 0 2 0 +TABLE test t2 NULL 7 5 2 5 2 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 3 1 2 1 0 2 0 +TABLE test t3 NULL 10 7 3 7 3 0 0 +TABLE test t3 index_b 1 1 0 1 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 4 1 3 1 0 3 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 7 4 3 4 1 2 0 +TABLE test t2 10 6 4 6 2 2 0 +TABLE test t3 15 9 6 9 3 3 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 7 +TABLE test t2 10 +TABLE test t3 15 +flush tables; +"================== con1 FLUSH ==================" +"================== Step 3-B ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 25 +user1 wait/lock/table/sql/handler 0 +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 32 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 32 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 7 TABLE test t1 +wait/io/table/sql/handler 10 TABLE test t2 +wait/io/table/sql/handler 15 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 4 3 1 3 1 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 3 1 2 1 0 2 0 +TABLE test t2 NULL 7 5 2 5 2 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 3 1 2 1 0 2 0 +TABLE test t3 NULL 10 7 3 7 3 0 0 +TABLE test t3 index_b 1 1 0 1 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 4 1 3 1 0 3 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 7 4 3 4 1 2 0 +TABLE test t2 10 6 4 6 2 2 0 +TABLE test t3 15 9 6 9 3 3 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 7 +TABLE test t2 10 +TABLE test t3 15 +select concat(current_user(), " is connected") as status; +status +user2@localhost is connected +"================== Step 4 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 25 +user1 wait/lock/table/sql/handler 0 +username event_name count_star +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 32 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 32 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 7 TABLE test t1 +wait/io/table/sql/handler 10 TABLE test t2 +wait/io/table/sql/handler 15 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 4 3 1 3 1 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 3 1 2 1 0 2 0 +TABLE test t2 NULL 7 5 2 5 2 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 3 1 2 1 0 2 0 +TABLE test t3 NULL 10 7 3 7 3 0 0 +TABLE test t3 index_b 1 1 0 1 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 4 1 3 1 0 3 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 7 4 3 4 1 2 0 +TABLE test t2 10 6 4 6 2 2 0 +TABLE test t3 15 9 6 9 3 3 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 7 +TABLE test t2 10 +TABLE test t3 15 +insert into test.t1 set a=201, b=1, c=1; +insert into test.t2 set a=202, b=2, c=2; +insert into test.t2 set a=203, b=3, c=3; +insert into test.t3 set a=204, b=4, c=4; +insert into test.t3 set a=205, b=5, c=5; +insert into test.t3 set a=206, b=6, c=6; +select * from test.t1; +a b c d +101 1 1 2 +201 1 1 0 +select * from test.t2; +a b c d +102 2 2 1 +103 3 3 1 +202 2 2 0 +203 3 3 0 +select * from test.t3; +a b c d +104 4 4 1 +105 5 5 1 +106 6 6 1 +204 4 4 0 +205 5 5 0 +206 6 6 0 +update test.t1 set d=d+1; +update test.t2 set d=d+1; +update test.t3 set d=d+1; +update test.t1 set d=d+1 where a=201; +update test.t2 set d=d+1 where a=201; +update test.t3 set d=d+1 where a=201; +select * from test.t1 force index(index_b) where b=5; +a b c d +select * from test.t2 force index(index_b) where b=5; +a b c d +select * from test.t3 force index(index_b) where b=5; +a b c d +105 5 5 2 +205 5 5 1 +"================== con2 marker ==================" +"================== Step 5 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 25 +user1 wait/lock/table/sql/handler 0 +username event_name count_star +user2 wait/io/table/sql/handler 37 +user2 wait/lock/table/sql/handler 0 +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 51 +user2 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 51 +user2 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 83 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 83 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 17 TABLE test t1 +wait/io/table/sql/handler 26 TABLE test t2 +wait/io/table/sql/handler 40 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 10 8 2 8 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 7 2 5 2 0 5 0 +TABLE test t2 NULL 18 14 4 14 4 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 8 2 6 2 0 6 0 +TABLE test t3 NULL 26 20 6 20 6 0 0 +TABLE test t3 index_b 3 3 0 3 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 11 2 9 2 0 9 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 17 10 7 10 2 5 0 +TABLE test t2 26 16 10 16 4 6 0 +TABLE test t3 40 25 15 25 6 9 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 17 +TABLE test t2 26 +TABLE test t3 40 +select concat(current_user(), " is connected") as status; +status +user3@localhost is connected +"================== Step 6 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 25 +user1 wait/lock/table/sql/handler 0 +username event_name count_star +user2 wait/io/table/sql/handler 37 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 51 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 51 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 83 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 83 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 17 TABLE test t1 +wait/io/table/sql/handler 26 TABLE test t2 +wait/io/table/sql/handler 40 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 10 8 2 8 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 7 2 5 2 0 5 0 +TABLE test t2 NULL 18 14 4 14 4 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 8 2 6 2 0 6 0 +TABLE test t3 NULL 26 20 6 20 6 0 0 +TABLE test t3 index_b 3 3 0 3 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 11 2 9 2 0 9 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 17 10 7 10 2 5 0 +TABLE test t2 26 16 10 16 4 6 0 +TABLE test t3 40 25 15 25 6 9 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 17 +TABLE test t2 26 +TABLE test t3 40 +insert into test.t1 set a=301, b=1, c=1; +insert into test.t2 set a=302, b=2, c=2; +insert into test.t2 set a=303, b=3, c=3; +insert into test.t3 set a=304, b=4, c=4; +insert into test.t3 set a=305, b=5, c=5; +insert into test.t3 set a=306, b=6, c=6; +select * from test.t1; +a b c d +101 1 1 3 +201 1 1 2 +301 1 1 0 +select * from test.t2; +a b c d +102 2 2 2 +103 3 3 2 +202 2 2 1 +203 3 3 1 +302 2 2 0 +303 3 3 0 +select * from test.t3; +a b c d +104 4 4 2 +105 5 5 2 +106 6 6 2 +204 4 4 1 +205 5 5 1 +206 6 6 1 +304 4 4 0 +305 5 5 0 +306 6 6 0 +update test.t1 set d=d+1; +update test.t2 set d=d+1; +update test.t3 set d=d+1; +update test.t1 set d=d+1 where a=301; +update test.t2 set d=d+1 where a=301; +update test.t3 set d=d+1 where a=301; +select * from test.t1 force index(index_b) where b=5; +a b c d +select * from test.t2 force index(index_b) where b=5; +a b c d +select * from test.t3 force index(index_b) where b=5; +a b c d +105 5 5 3 +205 5 5 2 +305 5 5 1 +"================== con3 marker ==================" +"================== Step 7 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 25 +user1 wait/lock/table/sql/handler 0 +username event_name count_star +user2 wait/io/table/sql/handler 37 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 49 +user3 wait/lock/table/sql/handler 0 +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 51 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 70 +user3 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 51 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 70 +user3 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 153 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 153 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 30 TABLE test t1 +wait/io/table/sql/handler 48 TABLE test t2 +wait/io/table/sql/handler 75 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 15 3 15 3 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 12 3 9 3 0 9 0 +TABLE test t2 NULL 33 27 6 27 6 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 15 3 12 3 0 12 0 +TABLE test t3 NULL 48 39 9 39 9 0 0 +TABLE test t3 index_b 6 6 0 6 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 21 3 18 3 0 18 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 30 18 12 18 3 9 0 +TABLE test t2 48 30 18 30 6 12 0 +TABLE test t3 75 48 27 48 9 18 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 30 +TABLE test t2 48 +TABLE test t3 75 +select concat(current_user(), " is connected") as status; +status +user4@localhost is connected +"================== Step 8 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 25 +user1 wait/lock/table/sql/handler 0 +username event_name count_star +user2 wait/io/table/sql/handler 37 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 49 +user3 wait/lock/table/sql/handler 0 +username event_name count_star +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 51 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 70 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 0 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 51 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 70 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 153 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 153 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 30 TABLE test t1 +wait/io/table/sql/handler 48 TABLE test t2 +wait/io/table/sql/handler 75 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 15 3 15 3 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 12 3 9 3 0 9 0 +TABLE test t2 NULL 33 27 6 27 6 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 15 3 12 3 0 12 0 +TABLE test t3 NULL 48 39 9 39 9 0 0 +TABLE test t3 index_b 6 6 0 6 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 21 3 18 3 0 18 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 30 18 12 18 3 9 0 +TABLE test t2 48 30 18 30 6 12 0 +TABLE test t3 75 48 27 48 9 18 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 30 +TABLE test t2 48 +TABLE test t3 75 +insert into test.t1 set a=401, b=1, c=1; +insert into test.t2 set a=402, b=2, c=2; +insert into test.t2 set a=403, b=3, c=3; +insert into test.t3 set a=404, b=4, c=4; +insert into test.t3 set a=405, b=5, c=5; +insert into test.t3 set a=406, b=6, c=6; +select * from test.t1; +a b c d +101 1 1 4 +201 1 1 3 +301 1 1 2 +401 1 1 0 +select * from test.t2; +a b c d +102 2 2 3 +103 3 3 3 +202 2 2 2 +203 3 3 2 +302 2 2 1 +303 3 3 1 +402 2 2 0 +403 3 3 0 +select * from test.t3; +a b c d +104 4 4 3 +105 5 5 3 +106 6 6 3 +204 4 4 2 +205 5 5 2 +206 6 6 2 +304 4 4 1 +305 5 5 1 +306 6 6 1 +404 4 4 0 +405 5 5 0 +406 6 6 0 +update test.t1 set d=d+1; +update test.t2 set d=d+1; +update test.t3 set d=d+1; +update test.t1 set d=d+1 where a=401; +update test.t2 set d=d+1 where a=401; +update test.t3 set d=d+1 where a=401; +select * from test.t1 force index(index_b) where b=5; +a b c d +select * from test.t2 force index(index_b) where b=5; +a b c d +select * from test.t3 force index(index_b) where b=5; +a b c d +105 5 5 4 +205 5 5 3 +305 5 5 2 +405 5 5 1 +"================== con4 marker ==================" +"================== Step 9 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 25 +user1 wait/lock/table/sql/handler 0 +username event_name count_star +user2 wait/io/table/sql/handler 37 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 49 +user3 wait/lock/table/sql/handler 0 +username event_name count_star +user4 wait/io/table/sql/handler 61 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 51 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 70 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 89 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 51 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 70 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 89 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 242 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 242 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 46 TABLE test t1 +wait/io/table/sql/handler 76 TABLE test t2 +wait/io/table/sql/handler 120 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 NULL 52 44 8 44 8 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 24 4 20 4 0 20 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 76 48 28 48 8 20 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 46 +TABLE test t2 76 +TABLE test t3 120 +lock tables test.t1 read, test.t2 read, test.t3 read; +unlock tables; +lock tables test.t1 write, test.t2 write, test.t3 write; +unlock tables; +"================== con1 marker ==================" +"================== Step 10 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 25 +user1 wait/lock/table/sql/handler 0 +username event_name count_star +user2 wait/io/table/sql/handler 37 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 49 +user3 wait/lock/table/sql/handler 0 +username event_name count_star +user4 wait/io/table/sql/handler 61 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 51 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 70 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 89 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 51 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 70 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 89 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 242 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 242 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 46 TABLE test t1 +wait/io/table/sql/handler 76 TABLE test t2 +wait/io/table/sql/handler 120 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 NULL 52 44 8 44 8 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 24 4 20 4 0 20 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 76 48 28 48 8 20 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 46 +TABLE test t2 76 +TABLE test t3 120 +flush tables; +"================== flush marker ==================" +"================== Step 11 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 25 +user1 wait/lock/table/sql/handler 0 +username event_name count_star +user2 wait/io/table/sql/handler 37 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 49 +user3 wait/lock/table/sql/handler 0 +username event_name count_star +user4 wait/io/table/sql/handler 61 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 51 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 70 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 89 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 51 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 70 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 89 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 242 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 242 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 46 TABLE test t1 +wait/io/table/sql/handler 76 TABLE test t2 +wait/io/table/sql/handler 120 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 NULL 52 44 8 44 8 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 24 4 20 4 0 20 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 76 48 28 48 8 20 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 46 +TABLE test t2 76 +TABLE test t3 120 +set global read_only=1; +set global read_only=0; +"================== global read_only marker ==================" +"================== Step 12 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 25 +user1 wait/lock/table/sql/handler 0 +username event_name count_star +user2 wait/io/table/sql/handler 37 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 49 +user3 wait/lock/table/sql/handler 0 +username event_name count_star +user4 wait/io/table/sql/handler 61 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 51 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 70 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 89 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 51 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 70 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 89 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 242 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 242 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 46 TABLE test t1 +wait/io/table/sql/handler 76 TABLE test t2 +wait/io/table/sql/handler 120 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 NULL 52 44 8 44 8 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 24 4 20 4 0 20 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 76 48 28 48 8 20 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 46 +TABLE test t2 76 +TABLE test t3 120 +"================== con1 disconnected ==================" +"================== Step 13 ==================" +call dump_thread(); +username status +user1 not found +username event_name count_star +user2 wait/io/table/sql/handler 37 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 49 +user3 wait/lock/table/sql/handler 0 +username event_name count_star +user4 wait/io/table/sql/handler 61 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 51 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 70 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 89 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 51 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 70 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 89 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 242 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 242 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 46 TABLE test t1 +wait/io/table/sql/handler 76 TABLE test t2 +wait/io/table/sql/handler 120 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 NULL 52 44 8 44 8 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 24 4 20 4 0 20 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 76 48 28 48 8 20 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 46 +TABLE test t2 76 +TABLE test t3 120 +"================== con2 disconnected ==================" +"================== Step 14 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username event_name count_star +user3 wait/io/table/sql/handler 49 +user3 wait/lock/table/sql/handler 0 +username event_name count_star +user4 wait/io/table/sql/handler 61 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 51 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 70 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 89 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 51 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 70 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 89 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 242 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 242 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 46 TABLE test t1 +wait/io/table/sql/handler 76 TABLE test t2 +wait/io/table/sql/handler 120 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 NULL 52 44 8 44 8 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 24 4 20 4 0 20 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 76 48 28 48 8 20 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 46 +TABLE test t2 76 +TABLE test t3 120 +"================== con3 disconnected ==================" +"================== Step 15 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username event_name count_star +user4 wait/io/table/sql/handler 61 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 51 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 70 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 89 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 51 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 70 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 89 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 242 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 242 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 46 TABLE test t1 +wait/io/table/sql/handler 76 TABLE test t2 +wait/io/table/sql/handler 120 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 NULL 52 44 8 44 8 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 24 4 20 4 0 20 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 76 48 28 48 8 20 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 46 +TABLE test t2 76 +TABLE test t3 120 +"================== con4 disconnected ==================" +"================== Step 16 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 51 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 70 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 89 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 51 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 70 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 89 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 242 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 242 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 46 TABLE test t1 +wait/io/table/sql/handler 76 TABLE test t2 +wait/io/table/sql/handler 120 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 NULL 52 44 8 44 8 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 24 4 20 4 0 20 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 76 48 28 48 8 20 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 46 +TABLE test t2 76 +TABLE test t3 120 +truncate performance_schema.events_waits_summary_by_thread_by_event_name; +"================== BY_THREAD truncated ==================" +"================== Step 17 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 51 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 70 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 89 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 51 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 70 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 89 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 242 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 242 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 46 TABLE test t1 +wait/io/table/sql/handler 76 TABLE test t2 +wait/io/table/sql/handler 120 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 NULL 52 44 8 44 8 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 24 4 20 4 0 20 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 76 48 28 48 8 20 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 46 +TABLE test t2 76 +TABLE test t3 120 +truncate performance_schema.events_waits_summary_by_account_by_event_name; +"================== BY_ACCOUNT truncated ==================" +"================== Step 18 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 0 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 51 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 70 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 89 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 242 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 242 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 46 TABLE test t1 +wait/io/table/sql/handler 76 TABLE test t2 +wait/io/table/sql/handler 120 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 NULL 52 44 8 44 8 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 24 4 20 4 0 20 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 76 48 28 48 8 20 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 46 +TABLE test t2 76 +TABLE test t3 120 +truncate performance_schema.events_waits_summary_by_user_by_event_name; +"================== BY_USER truncated ==================" +"================== Step 19 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 0 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 242 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 242 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 46 TABLE test t1 +wait/io/table/sql/handler 76 TABLE test t2 +wait/io/table/sql/handler 120 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 NULL 52 44 8 44 8 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 24 4 20 4 0 20 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 76 48 28 48 8 20 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 46 +TABLE test t2 76 +TABLE test t3 120 +truncate performance_schema.events_waits_summary_by_host_by_event_name; +"================== BY_HOST truncated ==================" +"================== Step 21 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 0 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 242 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 46 TABLE test t1 +wait/io/table/sql/handler 76 TABLE test t2 +wait/io/table/sql/handler 120 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 NULL 52 44 8 44 8 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 24 4 20 4 0 20 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 76 48 28 48 8 20 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 46 +TABLE test t2 76 +TABLE test t3 120 +truncate performance_schema.events_waits_summary_global_by_event_name; +"================== GLOBAL truncated ==================" +"================== Step 21 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 0 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 0 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 46 TABLE test t1 +wait/io/table/sql/handler 76 TABLE test t2 +wait/io/table/sql/handler 120 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 0 0 0 0 0 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 0 0 0 0 0 0 0 +TABLE test t2 NULL 0 0 0 0 0 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 0 0 0 0 0 0 0 +TABLE test t3 index_b 0 0 0 0 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 0 0 0 0 0 0 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 0 +TABLE test t2 0 +TABLE test t3 0 +show global status like "performance_schema%table%_lost"; +Variable_name Value +Performance_schema_table_handles_lost 0 +Performance_schema_table_instances_lost 0 +Performance_schema_table_lock_stat_lost 0 diff --git a/mysql-test/suite/table_io_aggregate_thread_2u_2t.result-pq b/mysql-test/suite/table_io_aggregate_thread_2u_2t.result-pq new file mode 100644 index 000000000000..e3d164b57bf4 --- /dev/null +++ b/mysql-test/suite/table_io_aggregate_thread_2u_2t.result-pq @@ -0,0 +1,1724 @@ +update performance_schema.setup_instruments +set enabled='NO' where name='wait/lock/table/sql/handler'; +update performance_schema.setup_consumers +set enabled='NO' where name like 'event%'; +delete from performance_schema.setup_actors +where user in ('user2', 'user4'); +delete from performance_schema.setup_objects +where object_name='t2'; +select * from performance_schema.setup_actors +order by USER, HOST, `ROLE`; +HOST USER ROLE ENABLED HISTORY +localhost user1 % YES YES +localhost user3 % YES YES +select * from performance_schema.setup_objects +order by object_type, object_schema, object_name; +OBJECT_TYPE OBJECT_SCHEMA OBJECT_NAME ENABLED TIMED +TABLE test t1 YES YES +TABLE test t3 YES NO +select * from performance_schema.setup_consumers; +NAME ENABLED +events_stages_current NO +events_stages_history NO +events_stages_history_long NO +events_statements_current NO +events_statements_history NO +events_statements_history_long NO +events_transactions_current NO +events_transactions_history NO +events_transactions_history_long NO +events_waits_current NO +events_waits_history NO +events_waits_history_long NO +global_instrumentation YES +thread_instrumentation YES +statements_digest YES +flush tables; +truncate performance_schema.objects_summary_global_by_type; +truncate performance_schema.table_io_waits_summary_by_index_usage; +truncate performance_schema.table_io_waits_summary_by_table; +truncate performance_schema.table_lock_waits_summary_by_table; +truncate performance_schema.events_waits_summary_by_thread_by_event_name; +truncate performance_schema.events_waits_summary_by_account_by_event_name; +truncate performance_schema.events_waits_summary_by_user_by_event_name; +truncate performance_schema.events_waits_summary_by_host_by_event_name; +truncate performance_schema.events_waits_summary_global_by_event_name; +truncate performance_schema.events_waits_history_long; +show global variables like "performance_schema%table%"; +Variable_name Value +performance_schema_max_table_handles -1 +performance_schema_max_table_instances -1 +performance_schema_max_table_lock_stat -1 +show global status like "performance_schema%table%_lost"; +Variable_name Value +Performance_schema_table_handles_lost 0 +Performance_schema_table_instances_lost 0 +Performance_schema_table_lock_stat_lost 0 +"================== Step 1 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +execute dump_waits_user; +user event_name count_star +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 0 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 0 0 0 0 0 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 index_b 0 0 0 0 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 0 0 0 0 0 0 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 0 +TABLE test t2 0 +TABLE test t3 0 +select concat(current_user(), " is connected") as status; +status +user1@localhost is connected +"================== Step 2 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 0 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 0 0 0 0 0 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 index_b 0 0 0 0 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 0 0 0 0 0 0 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 0 +TABLE test t2 0 +TABLE test t3 0 +insert into test.t1 set a=101, b=1, c=1; +insert into test.t2 set a=102, b=2, c=2; +insert into test.t2 set a=103, b=3, c=3; +insert into test.t3 set a=104, b=4, c=4; +insert into test.t3 set a=105, b=5, c=5; +insert into test.t3 set a=106, b=6, c=6; +select * from test.t1; +a b c d +101 1 1 0 +select * from test.t2; +a b c d +102 2 2 0 +103 3 3 0 +select * from test.t3; +a b c d +104 4 4 0 +105 5 5 0 +106 6 6 0 +update test.t1 set d=d+1; +update test.t2 set d=d+1; +update test.t3 set d=d+1; +update test.t1 set d=d+1 where a=101; +update test.t2 set d=d+1 where a=101; +update test.t3 set d=d+1 where a=101; +select * from test.t1 force index(index_b) where b=5; +a b c d +select * from test.t2 force index(index_b) where b=5; +a b c d +select * from test.t3 force index(index_b) where b=5; +a b c d +105 5 5 1 +"================== con1 marker ==================" +"================== Step 3-A ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 17 +user1 wait/lock/table/sql/handler 0 +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 22 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 22 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 4 3 1 3 1 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 3 1 2 1 0 2 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 10 7 3 7 3 0 0 +TABLE test t3 index_b 1 1 0 1 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 4 1 3 1 0 3 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 7 4 3 4 1 2 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 15 9 6 9 3 3 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 7 +TABLE test t2 0 +TABLE test t3 15 +flush tables; +"================== con1 FLUSH ==================" +"================== Step 3-B ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 17 +user1 wait/lock/table/sql/handler 0 +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 22 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 22 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 4 3 1 3 1 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 3 1 2 1 0 2 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 10 7 3 7 3 0 0 +TABLE test t3 index_b 1 1 0 1 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 4 1 3 1 0 3 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 7 4 3 4 1 2 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 15 9 6 9 3 3 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 7 +TABLE test t2 0 +TABLE test t3 15 +select concat(current_user(), " is connected") as status; +status +user2@localhost is connected +"================== Step 4 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 17 +user1 wait/lock/table/sql/handler 0 +username event_name count_star +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 22 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 22 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 4 3 1 3 1 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 3 1 2 1 0 2 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 10 7 3 7 3 0 0 +TABLE test t3 index_b 1 1 0 1 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 4 1 3 1 0 3 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 7 4 3 4 1 2 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 15 9 6 9 3 3 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 7 +TABLE test t2 0 +TABLE test t3 15 +insert into test.t1 set a=201, b=1, c=1; +insert into test.t2 set a=202, b=2, c=2; +insert into test.t2 set a=203, b=3, c=3; +insert into test.t3 set a=204, b=4, c=4; +insert into test.t3 set a=205, b=5, c=5; +insert into test.t3 set a=206, b=6, c=6; +select * from test.t1; +a b c d +101 1 1 2 +201 1 1 0 +select * from test.t2; +a b c d +102 2 2 1 +103 3 3 1 +202 2 2 0 +203 3 3 0 +select * from test.t3; +a b c d +104 4 4 1 +105 5 5 1 +106 6 6 1 +204 4 4 0 +205 5 5 0 +206 6 6 0 +update test.t1 set d=d+1; +update test.t2 set d=d+1; +update test.t3 set d=d+1; +update test.t1 set d=d+1 where a=201; +update test.t2 set d=d+1 where a=201; +update test.t3 set d=d+1 where a=201; +select * from test.t1 force index(index_b) where b=5; +a b c d +select * from test.t2 force index(index_b) where b=5; +a b c d +select * from test.t3 force index(index_b) where b=5; +a b c d +105 5 5 2 +205 5 5 1 +"================== con2 marker ==================" +"================== Step 5 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 17 +user1 wait/lock/table/sql/handler 0 +username event_name count_star +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 10 +user2 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 10 +user2 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 32 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 32 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 6 5 1 5 1 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 3 1 2 1 0 2 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 16 13 3 13 3 0 0 +TABLE test t3 index_b 3 3 0 3 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 4 1 3 1 0 3 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 9 6 3 6 1 2 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 23 17 6 17 3 3 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 9 +TABLE test t2 0 +TABLE test t3 23 +select concat(current_user(), " is connected") as status; +status +user3@localhost is connected +"================== Step 6 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 17 +user1 wait/lock/table/sql/handler 0 +username event_name count_star +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 10 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 10 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 32 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 32 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 6 5 1 5 1 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 3 1 2 1 0 2 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 16 13 3 13 3 0 0 +TABLE test t3 index_b 3 3 0 3 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 4 1 3 1 0 3 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 9 6 3 6 1 2 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 23 17 6 17 3 3 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 9 +TABLE test t2 0 +TABLE test t3 23 +insert into test.t1 set a=301, b=1, c=1; +insert into test.t2 set a=302, b=2, c=2; +insert into test.t2 set a=303, b=3, c=3; +insert into test.t3 set a=304, b=4, c=4; +insert into test.t3 set a=305, b=5, c=5; +insert into test.t3 set a=306, b=6, c=6; +select * from test.t1; +a b c d +101 1 1 3 +201 1 1 2 +301 1 1 0 +select * from test.t2; +a b c d +102 2 2 2 +103 3 3 2 +202 2 2 1 +203 3 3 1 +302 2 2 0 +303 3 3 0 +select * from test.t3; +a b c d +104 4 4 2 +105 5 5 2 +106 6 6 2 +204 4 4 1 +205 5 5 1 +206 6 6 1 +304 4 4 0 +305 5 5 0 +306 6 6 0 +update test.t1 set d=d+1; +update test.t2 set d=d+1; +update test.t3 set d=d+1; +update test.t1 set d=d+1 where a=301; +update test.t2 set d=d+1 where a=301; +update test.t3 set d=d+1 where a=301; +select * from test.t1 force index(index_b) where b=5; +a b c d +select * from test.t2 force index(index_b) where b=5; +a b c d +select * from test.t3 force index(index_b) where b=5; +a b c d +105 5 5 3 +205 5 5 2 +305 5 5 1 +"================== con3 marker ==================" +"================== Step 7 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 17 +user1 wait/lock/table/sql/handler 0 +username event_name count_star +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 33 +user3 wait/lock/table/sql/handler 0 +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 10 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 48 +user3 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 10 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 48 +user3 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 80 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 80 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 14 12 2 12 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 8 2 6 2 0 6 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 38 32 6 32 6 0 0 +TABLE test t3 index_b 6 6 0 6 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 14 2 12 2 0 12 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 22 14 8 14 2 6 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 58 40 18 40 6 12 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 22 +TABLE test t2 0 +TABLE test t3 58 +select concat(current_user(), " is connected") as status; +status +user4@localhost is connected +"================== Step 8 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 17 +user1 wait/lock/table/sql/handler 0 +username event_name count_star +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 33 +user3 wait/lock/table/sql/handler 0 +username event_name count_star +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 10 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 48 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 0 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 10 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 48 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 80 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 80 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 14 12 2 12 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 8 2 6 2 0 6 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 38 32 6 32 6 0 0 +TABLE test t3 index_b 6 6 0 6 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 14 2 12 2 0 12 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 22 14 8 14 2 6 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 58 40 18 40 6 12 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 22 +TABLE test t2 0 +TABLE test t3 58 +insert into test.t1 set a=401, b=1, c=1; +insert into test.t2 set a=402, b=2, c=2; +insert into test.t2 set a=403, b=3, c=3; +insert into test.t3 set a=404, b=4, c=4; +insert into test.t3 set a=405, b=5, c=5; +insert into test.t3 set a=406, b=6, c=6; +select * from test.t1; +a b c d +101 1 1 4 +201 1 1 3 +301 1 1 2 +401 1 1 0 +select * from test.t2; +a b c d +102 2 2 3 +103 3 3 3 +202 2 2 2 +203 3 3 2 +302 2 2 1 +303 3 3 1 +402 2 2 0 +403 3 3 0 +select * from test.t3; +a b c d +104 4 4 3 +105 5 5 3 +106 6 6 3 +204 4 4 2 +205 5 5 2 +206 6 6 2 +304 4 4 1 +305 5 5 1 +306 6 6 1 +404 4 4 0 +405 5 5 0 +406 6 6 0 +update test.t1 set d=d+1; +update test.t2 set d=d+1; +update test.t3 set d=d+1; +update test.t1 set d=d+1 where a=401; +update test.t2 set d=d+1 where a=401; +update test.t3 set d=d+1 where a=401; +select * from test.t1 force index(index_b) where b=5; +a b c d +select * from test.t2 force index(index_b) where b=5; +a b c d +select * from test.t3 force index(index_b) where b=5; +a b c d +105 5 5 4 +205 5 5 3 +305 5 5 2 +405 5 5 1 +"================== con4 marker ==================" +"================== Step 9 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 17 +user1 wait/lock/table/sql/handler 0 +username event_name count_star +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 33 +user3 wait/lock/table/sql/handler 0 +username event_name count_star +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 10 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 48 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 20 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 10 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 48 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 20 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 100 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 100 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 16 2 16 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 8 2 6 2 0 6 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 50 44 6 44 6 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 14 2 12 2 0 12 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 26 18 8 18 2 6 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 74 56 18 56 6 12 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 26 +TABLE test t2 0 +TABLE test t3 74 +lock tables test.t1 read, test.t2 read, test.t3 read; +unlock tables; +lock tables test.t1 write, test.t2 write, test.t3 write; +unlock tables; +"================== con1 marker ==================" +"================== Step 10 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 17 +user1 wait/lock/table/sql/handler 0 +username event_name count_star +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 33 +user3 wait/lock/table/sql/handler 0 +username event_name count_star +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 10 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 48 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 20 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 10 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 48 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 20 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 100 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 100 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 16 2 16 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 8 2 6 2 0 6 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 50 44 6 44 6 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 14 2 12 2 0 12 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 26 18 8 18 2 6 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 74 56 18 56 6 12 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 26 +TABLE test t2 0 +TABLE test t3 74 +flush tables; +"================== flush marker ==================" +"================== Step 11 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 17 +user1 wait/lock/table/sql/handler 0 +username event_name count_star +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 33 +user3 wait/lock/table/sql/handler 0 +username event_name count_star +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 10 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 48 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 20 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 10 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 48 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 20 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 100 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 100 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 16 2 16 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 8 2 6 2 0 6 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 50 44 6 44 6 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 14 2 12 2 0 12 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 26 18 8 18 2 6 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 74 56 18 56 6 12 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 26 +TABLE test t2 0 +TABLE test t3 74 +set global read_only=1; +set global read_only=0; +"================== global read_only marker ==================" +"================== Step 12 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 17 +user1 wait/lock/table/sql/handler 0 +username event_name count_star +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 33 +user3 wait/lock/table/sql/handler 0 +username event_name count_star +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 10 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 48 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 20 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 10 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 48 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 20 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 100 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 100 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 16 2 16 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 8 2 6 2 0 6 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 50 44 6 44 6 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 14 2 12 2 0 12 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 26 18 8 18 2 6 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 74 56 18 56 6 12 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 26 +TABLE test t2 0 +TABLE test t3 74 +"================== con1 disconnected ==================" +"================== Step 13 ==================" +call dump_thread(); +username status +user1 not found +username event_name count_star +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 33 +user3 wait/lock/table/sql/handler 0 +username event_name count_star +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 10 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 48 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 20 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 10 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 48 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 20 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 100 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 100 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 16 2 16 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 8 2 6 2 0 6 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 50 44 6 44 6 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 14 2 12 2 0 12 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 26 18 8 18 2 6 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 74 56 18 56 6 12 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 26 +TABLE test t2 0 +TABLE test t3 74 +"================== con2 disconnected ==================" +"================== Step 14 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username event_name count_star +user3 wait/io/table/sql/handler 33 +user3 wait/lock/table/sql/handler 0 +username event_name count_star +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 10 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 48 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 20 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 10 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 48 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 20 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 100 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 100 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 16 2 16 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 8 2 6 2 0 6 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 50 44 6 44 6 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 14 2 12 2 0 12 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 26 18 8 18 2 6 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 74 56 18 56 6 12 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 26 +TABLE test t2 0 +TABLE test t3 74 +"================== con3 disconnected ==================" +"================== Step 15 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username event_name count_star +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 10 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 48 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 20 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 10 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 48 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 20 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 100 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 100 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 16 2 16 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 8 2 6 2 0 6 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 50 44 6 44 6 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 14 2 12 2 0 12 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 26 18 8 18 2 6 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 74 56 18 56 6 12 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 26 +TABLE test t2 0 +TABLE test t3 74 +"================== con4 disconnected ==================" +"================== Step 16 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 10 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 48 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 20 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 10 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 48 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 20 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 100 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 100 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 16 2 16 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 8 2 6 2 0 6 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 50 44 6 44 6 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 14 2 12 2 0 12 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 26 18 8 18 2 6 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 74 56 18 56 6 12 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 26 +TABLE test t2 0 +TABLE test t3 74 +truncate performance_schema.events_waits_summary_by_thread_by_event_name; +"================== BY_THREAD truncated ==================" +"================== Step 17 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 10 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 48 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 20 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 10 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 48 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 20 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 100 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 100 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 16 2 16 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 8 2 6 2 0 6 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 50 44 6 44 6 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 14 2 12 2 0 12 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 26 18 8 18 2 6 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 74 56 18 56 6 12 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 26 +TABLE test t2 0 +TABLE test t3 74 +truncate performance_schema.events_waits_summary_by_account_by_event_name; +"================== BY_ACCOUNT truncated ==================" +"================== Step 18 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 0 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 10 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 48 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 20 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 100 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 100 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 16 2 16 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 8 2 6 2 0 6 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 50 44 6 44 6 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 14 2 12 2 0 12 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 26 18 8 18 2 6 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 74 56 18 56 6 12 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 26 +TABLE test t2 0 +TABLE test t3 74 +truncate performance_schema.events_waits_summary_by_user_by_event_name; +"================== BY_USER truncated ==================" +"================== Step 19 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 0 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 100 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 100 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 16 2 16 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 8 2 6 2 0 6 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 50 44 6 44 6 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 14 2 12 2 0 12 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 26 18 8 18 2 6 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 74 56 18 56 6 12 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 26 +TABLE test t2 0 +TABLE test t3 74 +truncate performance_schema.events_waits_summary_by_host_by_event_name; +"================== BY_HOST truncated ==================" +"================== Step 21 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 0 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 100 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 16 2 16 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 8 2 6 2 0 6 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 50 44 6 44 6 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 14 2 12 2 0 12 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 26 18 8 18 2 6 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 74 56 18 56 6 12 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 26 +TABLE test t2 0 +TABLE test t3 74 +truncate performance_schema.events_waits_summary_global_by_event_name; +"================== GLOBAL truncated ==================" +"================== Step 21 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 0 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 0 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 0 0 0 0 0 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 0 0 0 0 0 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 0 0 0 0 0 0 0 +TABLE test t3 index_b 0 0 0 0 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 0 0 0 0 0 0 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 0 +TABLE test t2 0 +TABLE test t3 0 +show global status like "performance_schema%table%_lost"; +Variable_name Value +Performance_schema_table_handles_lost 0 +Performance_schema_table_instances_lost 0 +Performance_schema_table_lock_stat_lost 0 diff --git a/mysql-test/suite/table_io_aggregate_thread_2u_3t.result-pq b/mysql-test/suite/table_io_aggregate_thread_2u_3t.result-pq new file mode 100644 index 000000000000..d2418b8611ac --- /dev/null +++ b/mysql-test/suite/table_io_aggregate_thread_2u_3t.result-pq @@ -0,0 +1,1743 @@ +update performance_schema.setup_instruments +set enabled='NO' where name='wait/lock/table/sql/handler'; +update performance_schema.setup_consumers +set enabled='NO' where name like 'event%'; +delete from performance_schema.setup_actors +where user in ('user2', 'user4'); +select * from performance_schema.setup_actors +order by USER, HOST, `ROLE`; +HOST USER ROLE ENABLED HISTORY +localhost user1 % YES YES +localhost user3 % YES YES +select * from performance_schema.setup_objects +order by object_type, object_schema, object_name; +OBJECT_TYPE OBJECT_SCHEMA OBJECT_NAME ENABLED TIMED +TABLE test t1 YES YES +TABLE test t2 YES NO +TABLE test t3 YES NO +select * from performance_schema.setup_consumers; +NAME ENABLED +events_stages_current NO +events_stages_history NO +events_stages_history_long NO +events_statements_current NO +events_statements_history NO +events_statements_history_long NO +events_transactions_current NO +events_transactions_history NO +events_transactions_history_long NO +events_waits_current NO +events_waits_history NO +events_waits_history_long NO +global_instrumentation YES +thread_instrumentation YES +statements_digest YES +flush tables; +truncate performance_schema.objects_summary_global_by_type; +truncate performance_schema.table_io_waits_summary_by_index_usage; +truncate performance_schema.table_io_waits_summary_by_table; +truncate performance_schema.table_lock_waits_summary_by_table; +truncate performance_schema.events_waits_summary_by_thread_by_event_name; +truncate performance_schema.events_waits_summary_by_account_by_event_name; +truncate performance_schema.events_waits_summary_by_user_by_event_name; +truncate performance_schema.events_waits_summary_by_host_by_event_name; +truncate performance_schema.events_waits_summary_global_by_event_name; +truncate performance_schema.events_waits_history_long; +show global variables like "performance_schema%table%"; +Variable_name Value +performance_schema_max_table_handles -1 +performance_schema_max_table_instances -1 +performance_schema_max_table_lock_stat -1 +show global status like "performance_schema%table%_lost"; +Variable_name Value +Performance_schema_table_handles_lost 0 +Performance_schema_table_instances_lost 0 +Performance_schema_table_lock_stat_lost 0 +"================== Step 1 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +execute dump_waits_user; +user event_name count_star +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 0 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 0 0 0 0 0 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 index_b 0 0 0 0 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 0 0 0 0 0 0 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 0 +TABLE test t2 0 +TABLE test t3 0 +select concat(current_user(), " is connected") as status; +status +user1@localhost is connected +"================== Step 2 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 0 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 0 0 0 0 0 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 index_b 0 0 0 0 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 0 0 0 0 0 0 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 0 +TABLE test t2 0 +TABLE test t3 0 +insert into test.t1 set a=101, b=1, c=1; +insert into test.t2 set a=102, b=2, c=2; +insert into test.t2 set a=103, b=3, c=3; +insert into test.t3 set a=104, b=4, c=4; +insert into test.t3 set a=105, b=5, c=5; +insert into test.t3 set a=106, b=6, c=6; +select * from test.t1; +a b c d +101 1 1 0 +select * from test.t2; +a b c d +102 2 2 0 +103 3 3 0 +select * from test.t3; +a b c d +104 4 4 0 +105 5 5 0 +106 6 6 0 +update test.t1 set d=d+1; +update test.t2 set d=d+1; +update test.t3 set d=d+1; +update test.t1 set d=d+1 where a=101; +update test.t2 set d=d+1 where a=101; +update test.t3 set d=d+1 where a=101; +select * from test.t1 force index(index_b) where b=5; +a b c d +select * from test.t2 force index(index_b) where b=5; +a b c d +select * from test.t3 force index(index_b) where b=5; +a b c d +105 5 5 1 +"================== con1 marker ==================" +"================== Step 3-A ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 25 +user1 wait/lock/table/sql/handler 0 +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 32 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 32 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 4 3 1 3 1 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 3 1 2 1 0 2 0 +TABLE test t2 NULL 7 5 2 5 2 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 3 1 2 1 0 2 0 +TABLE test t3 NULL 10 7 3 7 3 0 0 +TABLE test t3 index_b 1 1 0 1 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 4 1 3 1 0 3 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 7 4 3 4 1 2 0 +TABLE test t2 10 6 4 6 2 2 0 +TABLE test t3 15 9 6 9 3 3 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 7 +TABLE test t2 10 +TABLE test t3 15 +flush tables; +"================== con1 FLUSH ==================" +"================== Step 3-B ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 25 +user1 wait/lock/table/sql/handler 0 +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 32 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 32 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 4 3 1 3 1 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 3 1 2 1 0 2 0 +TABLE test t2 NULL 7 5 2 5 2 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 3 1 2 1 0 2 0 +TABLE test t3 NULL 10 7 3 7 3 0 0 +TABLE test t3 index_b 1 1 0 1 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 4 1 3 1 0 3 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 7 4 3 4 1 2 0 +TABLE test t2 10 6 4 6 2 2 0 +TABLE test t3 15 9 6 9 3 3 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 7 +TABLE test t2 10 +TABLE test t3 15 +select concat(current_user(), " is connected") as status; +status +user2@localhost is connected +"================== Step 4 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 25 +user1 wait/lock/table/sql/handler 0 +username event_name count_star +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 32 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 32 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 4 3 1 3 1 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 3 1 2 1 0 2 0 +TABLE test t2 NULL 7 5 2 5 2 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 3 1 2 1 0 2 0 +TABLE test t3 NULL 10 7 3 7 3 0 0 +TABLE test t3 index_b 1 1 0 1 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 4 1 3 1 0 3 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 7 4 3 4 1 2 0 +TABLE test t2 10 6 4 6 2 2 0 +TABLE test t3 15 9 6 9 3 3 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 7 +TABLE test t2 10 +TABLE test t3 15 +insert into test.t1 set a=201, b=1, c=1; +insert into test.t2 set a=202, b=2, c=2; +insert into test.t2 set a=203, b=3, c=3; +insert into test.t3 set a=204, b=4, c=4; +insert into test.t3 set a=205, b=5, c=5; +insert into test.t3 set a=206, b=6, c=6; +select * from test.t1; +a b c d +101 1 1 2 +201 1 1 0 +select * from test.t2; +a b c d +102 2 2 1 +103 3 3 1 +202 2 2 0 +203 3 3 0 +select * from test.t3; +a b c d +104 4 4 1 +105 5 5 1 +106 6 6 1 +204 4 4 0 +205 5 5 0 +206 6 6 0 +update test.t1 set d=d+1; +update test.t2 set d=d+1; +update test.t3 set d=d+1; +update test.t1 set d=d+1 where a=201; +update test.t2 set d=d+1 where a=201; +update test.t3 set d=d+1 where a=201; +select * from test.t1 force index(index_b) where b=5; +a b c d +select * from test.t2 force index(index_b) where b=5; +a b c d +select * from test.t3 force index(index_b) where b=5; +a b c d +105 5 5 2 +205 5 5 1 +"================== con2 marker ==================" +"================== Step 5 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 25 +user1 wait/lock/table/sql/handler 0 +username event_name count_star +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 14 +user2 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 14 +user2 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 46 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 46 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 6 5 1 5 1 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 3 1 2 1 0 2 0 +TABLE test t2 NULL 11 9 2 9 2 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 3 1 2 1 0 2 0 +TABLE test t3 NULL 16 13 3 13 3 0 0 +TABLE test t3 index_b 3 3 0 3 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 4 1 3 1 0 3 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 9 6 3 6 1 2 0 +TABLE test t2 14 10 4 10 2 2 0 +TABLE test t3 23 17 6 17 3 3 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 9 +TABLE test t2 14 +TABLE test t3 23 +select concat(current_user(), " is connected") as status; +status +user3@localhost is connected +"================== Step 6 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 25 +user1 wait/lock/table/sql/handler 0 +username event_name count_star +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 14 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 14 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 46 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 46 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 6 5 1 5 1 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 3 1 2 1 0 2 0 +TABLE test t2 NULL 11 9 2 9 2 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 3 1 2 1 0 2 0 +TABLE test t3 NULL 16 13 3 13 3 0 0 +TABLE test t3 index_b 3 3 0 3 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 4 1 3 1 0 3 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 9 6 3 6 1 2 0 +TABLE test t2 14 10 4 10 2 2 0 +TABLE test t3 23 17 6 17 3 3 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 9 +TABLE test t2 14 +TABLE test t3 23 +insert into test.t1 set a=301, b=1, c=1; +insert into test.t2 set a=302, b=2, c=2; +insert into test.t2 set a=303, b=3, c=3; +insert into test.t3 set a=304, b=4, c=4; +insert into test.t3 set a=305, b=5, c=5; +insert into test.t3 set a=306, b=6, c=6; +select * from test.t1; +a b c d +101 1 1 3 +201 1 1 2 +301 1 1 0 +select * from test.t2; +a b c d +102 2 2 2 +103 3 3 2 +202 2 2 1 +203 3 3 1 +302 2 2 0 +303 3 3 0 +select * from test.t3; +a b c d +104 4 4 2 +105 5 5 2 +106 6 6 2 +204 4 4 1 +205 5 5 1 +206 6 6 1 +304 4 4 0 +305 5 5 0 +306 6 6 0 +update test.t1 set d=d+1; +update test.t2 set d=d+1; +update test.t3 set d=d+1; +update test.t1 set d=d+1 where a=301; +update test.t2 set d=d+1 where a=301; +update test.t3 set d=d+1 where a=301; +select * from test.t1 force index(index_b) where b=5; +a b c d +select * from test.t2 force index(index_b) where b=5; +a b c d +select * from test.t3 force index(index_b) where b=5; +a b c d +105 5 5 3 +205 5 5 2 +305 5 5 1 +"================== con3 marker ==================" +"================== Step 7 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 25 +user1 wait/lock/table/sql/handler 0 +username event_name count_star +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 49 +user3 wait/lock/table/sql/handler 0 +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 14 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 70 +user3 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 14 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 70 +user3 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 116 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 116 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 14 12 2 12 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 8 2 6 2 0 6 0 +TABLE test t2 NULL 26 22 4 22 4 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 10 2 8 2 0 8 0 +TABLE test t3 NULL 38 32 6 32 6 0 0 +TABLE test t3 index_b 6 6 0 6 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 14 2 12 2 0 12 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 22 14 8 14 2 6 0 +TABLE test t2 36 24 12 24 4 8 0 +TABLE test t3 58 40 18 40 6 12 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 22 +TABLE test t2 36 +TABLE test t3 58 +select concat(current_user(), " is connected") as status; +status +user4@localhost is connected +"================== Step 8 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 25 +user1 wait/lock/table/sql/handler 0 +username event_name count_star +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 49 +user3 wait/lock/table/sql/handler 0 +username event_name count_star +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 14 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 70 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 0 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 14 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 70 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 116 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 116 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 14 12 2 12 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 8 2 6 2 0 6 0 +TABLE test t2 NULL 26 22 4 22 4 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 10 2 8 2 0 8 0 +TABLE test t3 NULL 38 32 6 32 6 0 0 +TABLE test t3 index_b 6 6 0 6 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 14 2 12 2 0 12 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 22 14 8 14 2 6 0 +TABLE test t2 36 24 12 24 4 8 0 +TABLE test t3 58 40 18 40 6 12 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 22 +TABLE test t2 36 +TABLE test t3 58 +insert into test.t1 set a=401, b=1, c=1; +insert into test.t2 set a=402, b=2, c=2; +insert into test.t2 set a=403, b=3, c=3; +insert into test.t3 set a=404, b=4, c=4; +insert into test.t3 set a=405, b=5, c=5; +insert into test.t3 set a=406, b=6, c=6; +select * from test.t1; +a b c d +101 1 1 4 +201 1 1 3 +301 1 1 2 +401 1 1 0 +select * from test.t2; +a b c d +102 2 2 3 +103 3 3 3 +202 2 2 2 +203 3 3 2 +302 2 2 1 +303 3 3 1 +402 2 2 0 +403 3 3 0 +select * from test.t3; +a b c d +104 4 4 3 +105 5 5 3 +106 6 6 3 +204 4 4 2 +205 5 5 2 +206 6 6 2 +304 4 4 1 +305 5 5 1 +306 6 6 1 +404 4 4 0 +405 5 5 0 +406 6 6 0 +update test.t1 set d=d+1; +update test.t2 set d=d+1; +update test.t3 set d=d+1; +update test.t1 set d=d+1 where a=401; +update test.t2 set d=d+1 where a=401; +update test.t3 set d=d+1 where a=401; +select * from test.t1 force index(index_b) where b=5; +a b c d +select * from test.t2 force index(index_b) where b=5; +a b c d +select * from test.t3 force index(index_b) where b=5; +a b c d +105 5 5 4 +205 5 5 3 +305 5 5 2 +405 5 5 1 +"================== con4 marker ==================" +"================== Step 9 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 25 +user1 wait/lock/table/sql/handler 0 +username event_name count_star +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 49 +user3 wait/lock/table/sql/handler 0 +username event_name count_star +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 14 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 70 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 28 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 14 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 70 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 28 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 144 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 144 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 16 2 16 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 8 2 6 2 0 6 0 +TABLE test t2 NULL 34 30 4 30 4 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 10 2 8 2 0 8 0 +TABLE test t3 NULL 50 44 6 44 6 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 14 2 12 2 0 12 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 26 18 8 18 2 6 0 +TABLE test t2 44 32 12 32 4 8 0 +TABLE test t3 74 56 18 56 6 12 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 26 +TABLE test t2 44 +TABLE test t3 74 +lock tables test.t1 read, test.t2 read, test.t3 read; +unlock tables; +lock tables test.t1 write, test.t2 write, test.t3 write; +unlock tables; +"================== con1 marker ==================" +"================== Step 10 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 25 +user1 wait/lock/table/sql/handler 0 +username event_name count_star +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 49 +user3 wait/lock/table/sql/handler 0 +username event_name count_star +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 14 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 70 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 28 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 14 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 70 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 28 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 144 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 144 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 16 2 16 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 8 2 6 2 0 6 0 +TABLE test t2 NULL 34 30 4 30 4 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 10 2 8 2 0 8 0 +TABLE test t3 NULL 50 44 6 44 6 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 14 2 12 2 0 12 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 26 18 8 18 2 6 0 +TABLE test t2 44 32 12 32 4 8 0 +TABLE test t3 74 56 18 56 6 12 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 26 +TABLE test t2 44 +TABLE test t3 74 +flush tables; +"================== flush marker ==================" +"================== Step 11 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 25 +user1 wait/lock/table/sql/handler 0 +username event_name count_star +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 49 +user3 wait/lock/table/sql/handler 0 +username event_name count_star +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 14 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 70 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 28 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 14 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 70 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 28 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 144 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 144 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 16 2 16 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 8 2 6 2 0 6 0 +TABLE test t2 NULL 34 30 4 30 4 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 10 2 8 2 0 8 0 +TABLE test t3 NULL 50 44 6 44 6 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 14 2 12 2 0 12 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 26 18 8 18 2 6 0 +TABLE test t2 44 32 12 32 4 8 0 +TABLE test t3 74 56 18 56 6 12 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 26 +TABLE test t2 44 +TABLE test t3 74 +set global read_only=1; +set global read_only=0; +"================== global read_only marker ==================" +"================== Step 12 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 25 +user1 wait/lock/table/sql/handler 0 +username event_name count_star +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 49 +user3 wait/lock/table/sql/handler 0 +username event_name count_star +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 14 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 70 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 28 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 14 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 70 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 28 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 144 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 144 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 16 2 16 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 8 2 6 2 0 6 0 +TABLE test t2 NULL 34 30 4 30 4 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 10 2 8 2 0 8 0 +TABLE test t3 NULL 50 44 6 44 6 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 14 2 12 2 0 12 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 26 18 8 18 2 6 0 +TABLE test t2 44 32 12 32 4 8 0 +TABLE test t3 74 56 18 56 6 12 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 26 +TABLE test t2 44 +TABLE test t3 74 +"================== con1 disconnected ==================" +"================== Step 13 ==================" +call dump_thread(); +username status +user1 not found +username event_name count_star +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 49 +user3 wait/lock/table/sql/handler 0 +username event_name count_star +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 14 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 70 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 28 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 14 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 70 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 28 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 144 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 144 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 16 2 16 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 8 2 6 2 0 6 0 +TABLE test t2 NULL 34 30 4 30 4 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 10 2 8 2 0 8 0 +TABLE test t3 NULL 50 44 6 44 6 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 14 2 12 2 0 12 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 26 18 8 18 2 6 0 +TABLE test t2 44 32 12 32 4 8 0 +TABLE test t3 74 56 18 56 6 12 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 26 +TABLE test t2 44 +TABLE test t3 74 +"================== con2 disconnected ==================" +"================== Step 14 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username event_name count_star +user3 wait/io/table/sql/handler 49 +user3 wait/lock/table/sql/handler 0 +username event_name count_star +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 14 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 70 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 28 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 14 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 70 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 28 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 144 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 144 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 16 2 16 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 8 2 6 2 0 6 0 +TABLE test t2 NULL 34 30 4 30 4 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 10 2 8 2 0 8 0 +TABLE test t3 NULL 50 44 6 44 6 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 14 2 12 2 0 12 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 26 18 8 18 2 6 0 +TABLE test t2 44 32 12 32 4 8 0 +TABLE test t3 74 56 18 56 6 12 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 26 +TABLE test t2 44 +TABLE test t3 74 +"================== con3 disconnected ==================" +"================== Step 15 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username event_name count_star +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 14 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 70 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 28 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 14 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 70 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 28 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 144 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 144 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 16 2 16 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 8 2 6 2 0 6 0 +TABLE test t2 NULL 34 30 4 30 4 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 10 2 8 2 0 8 0 +TABLE test t3 NULL 50 44 6 44 6 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 14 2 12 2 0 12 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 26 18 8 18 2 6 0 +TABLE test t2 44 32 12 32 4 8 0 +TABLE test t3 74 56 18 56 6 12 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 26 +TABLE test t2 44 +TABLE test t3 74 +"================== con4 disconnected ==================" +"================== Step 16 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 14 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 70 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 28 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 14 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 70 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 28 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 144 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 144 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 16 2 16 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 8 2 6 2 0 6 0 +TABLE test t2 NULL 34 30 4 30 4 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 10 2 8 2 0 8 0 +TABLE test t3 NULL 50 44 6 44 6 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 14 2 12 2 0 12 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 26 18 8 18 2 6 0 +TABLE test t2 44 32 12 32 4 8 0 +TABLE test t3 74 56 18 56 6 12 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 26 +TABLE test t2 44 +TABLE test t3 74 +truncate performance_schema.events_waits_summary_by_thread_by_event_name; +"================== BY_THREAD truncated ==================" +"================== Step 17 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 14 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 70 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 28 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 14 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 70 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 28 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 144 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 144 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 16 2 16 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 8 2 6 2 0 6 0 +TABLE test t2 NULL 34 30 4 30 4 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 10 2 8 2 0 8 0 +TABLE test t3 NULL 50 44 6 44 6 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 14 2 12 2 0 12 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 26 18 8 18 2 6 0 +TABLE test t2 44 32 12 32 4 8 0 +TABLE test t3 74 56 18 56 6 12 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 26 +TABLE test t2 44 +TABLE test t3 74 +truncate performance_schema.events_waits_summary_by_account_by_event_name; +"================== BY_ACCOUNT truncated ==================" +"================== Step 18 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 0 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 14 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 70 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 28 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 144 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 144 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 16 2 16 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 8 2 6 2 0 6 0 +TABLE test t2 NULL 34 30 4 30 4 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 10 2 8 2 0 8 0 +TABLE test t3 NULL 50 44 6 44 6 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 14 2 12 2 0 12 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 26 18 8 18 2 6 0 +TABLE test t2 44 32 12 32 4 8 0 +TABLE test t3 74 56 18 56 6 12 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 26 +TABLE test t2 44 +TABLE test t3 74 +truncate performance_schema.events_waits_summary_by_user_by_event_name; +"================== BY_USER truncated ==================" +"================== Step 19 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 0 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 144 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 144 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 16 2 16 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 8 2 6 2 0 6 0 +TABLE test t2 NULL 34 30 4 30 4 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 10 2 8 2 0 8 0 +TABLE test t3 NULL 50 44 6 44 6 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 14 2 12 2 0 12 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 26 18 8 18 2 6 0 +TABLE test t2 44 32 12 32 4 8 0 +TABLE test t3 74 56 18 56 6 12 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 26 +TABLE test t2 44 +TABLE test t3 74 +truncate performance_schema.events_waits_summary_by_host_by_event_name; +"================== BY_HOST truncated ==================" +"================== Step 21 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 0 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 144 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 16 2 16 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 8 2 6 2 0 6 0 +TABLE test t2 NULL 34 30 4 30 4 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 10 2 8 2 0 8 0 +TABLE test t3 NULL 50 44 6 44 6 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 14 2 12 2 0 12 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 26 18 8 18 2 6 0 +TABLE test t2 44 32 12 32 4 8 0 +TABLE test t3 74 56 18 56 6 12 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 26 +TABLE test t2 44 +TABLE test t3 74 +truncate performance_schema.events_waits_summary_global_by_event_name; +"================== GLOBAL truncated ==================" +"================== Step 21 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 0 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 0 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 0 0 0 0 0 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 0 0 0 0 0 0 0 +TABLE test t2 NULL 0 0 0 0 0 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 0 0 0 0 0 0 0 +TABLE test t3 index_b 0 0 0 0 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 0 0 0 0 0 0 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 0 +TABLE test t2 0 +TABLE test t3 0 +show global status like "performance_schema%table%_lost"; +Variable_name Value +Performance_schema_table_handles_lost 0 +Performance_schema_table_instances_lost 0 +Performance_schema_table_lock_stat_lost 0 diff --git a/mysql-test/suite/table_io_aggregate_thread_4u_2t.result-pq b/mysql-test/suite/table_io_aggregate_thread_4u_2t.result-pq new file mode 100644 index 000000000000..c44f9a9093d1 --- /dev/null +++ b/mysql-test/suite/table_io_aggregate_thread_4u_2t.result-pq @@ -0,0 +1,1724 @@ +update performance_schema.setup_instruments +set enabled='NO' where name='wait/lock/table/sql/handler'; +update performance_schema.setup_consumers +set enabled='NO' where name like 'event%'; +delete from performance_schema.setup_objects +where object_name='t2'; +select * from performance_schema.setup_actors +order by USER, HOST, `ROLE`; +HOST USER ROLE ENABLED HISTORY +localhost user1 % YES YES +localhost user2 % YES YES +localhost user3 % YES YES +localhost user4 % YES YES +select * from performance_schema.setup_objects +order by object_type, object_schema, object_name; +OBJECT_TYPE OBJECT_SCHEMA OBJECT_NAME ENABLED TIMED +TABLE test t1 YES YES +TABLE test t3 YES NO +select * from performance_schema.setup_consumers; +NAME ENABLED +events_stages_current NO +events_stages_history NO +events_stages_history_long NO +events_statements_current NO +events_statements_history NO +events_statements_history_long NO +events_transactions_current NO +events_transactions_history NO +events_transactions_history_long NO +events_waits_current NO +events_waits_history NO +events_waits_history_long NO +global_instrumentation YES +thread_instrumentation YES +statements_digest YES +flush tables; +truncate performance_schema.objects_summary_global_by_type; +truncate performance_schema.table_io_waits_summary_by_index_usage; +truncate performance_schema.table_io_waits_summary_by_table; +truncate performance_schema.table_lock_waits_summary_by_table; +truncate performance_schema.events_waits_summary_by_thread_by_event_name; +truncate performance_schema.events_waits_summary_by_account_by_event_name; +truncate performance_schema.events_waits_summary_by_user_by_event_name; +truncate performance_schema.events_waits_summary_by_host_by_event_name; +truncate performance_schema.events_waits_summary_global_by_event_name; +truncate performance_schema.events_waits_history_long; +show global variables like "performance_schema%table%"; +Variable_name Value +performance_schema_max_table_handles -1 +performance_schema_max_table_instances -1 +performance_schema_max_table_lock_stat -1 +show global status like "performance_schema%table%_lost"; +Variable_name Value +Performance_schema_table_handles_lost 0 +Performance_schema_table_instances_lost 0 +Performance_schema_table_lock_stat_lost 0 +"================== Step 1 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +execute dump_waits_user; +user event_name count_star +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 0 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 0 0 0 0 0 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 index_b 0 0 0 0 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 0 0 0 0 0 0 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 0 +TABLE test t2 0 +TABLE test t3 0 +select concat(current_user(), " is connected") as status; +status +user1@localhost is connected +"================== Step 2 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 0 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 0 0 0 0 0 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 index_b 0 0 0 0 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 0 0 0 0 0 0 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 0 +TABLE test t2 0 +TABLE test t3 0 +insert into test.t1 set a=101, b=1, c=1; +insert into test.t2 set a=102, b=2, c=2; +insert into test.t2 set a=103, b=3, c=3; +insert into test.t3 set a=104, b=4, c=4; +insert into test.t3 set a=105, b=5, c=5; +insert into test.t3 set a=106, b=6, c=6; +select * from test.t1; +a b c d +101 1 1 0 +select * from test.t2; +a b c d +102 2 2 0 +103 3 3 0 +select * from test.t3; +a b c d +104 4 4 0 +105 5 5 0 +106 6 6 0 +update test.t1 set d=d+1; +update test.t2 set d=d+1; +update test.t3 set d=d+1; +update test.t1 set d=d+1 where a=101; +update test.t2 set d=d+1 where a=101; +update test.t3 set d=d+1 where a=101; +select * from test.t1 force index(index_b) where b=5; +a b c d +select * from test.t2 force index(index_b) where b=5; +a b c d +select * from test.t3 force index(index_b) where b=5; +a b c d +105 5 5 1 +"================== con1 marker ==================" +"================== Step 3-A ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 17 +user1 wait/lock/table/sql/handler 0 +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 22 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 22 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 4 3 1 3 1 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 3 1 2 1 0 2 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 10 7 3 7 3 0 0 +TABLE test t3 index_b 1 1 0 1 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 4 1 3 1 0 3 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 7 4 3 4 1 2 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 15 9 6 9 3 3 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 7 +TABLE test t2 0 +TABLE test t3 15 +flush tables; +"================== con1 FLUSH ==================" +"================== Step 3-B ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 17 +user1 wait/lock/table/sql/handler 0 +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 22 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 22 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 4 3 1 3 1 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 3 1 2 1 0 2 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 10 7 3 7 3 0 0 +TABLE test t3 index_b 1 1 0 1 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 4 1 3 1 0 3 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 7 4 3 4 1 2 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 15 9 6 9 3 3 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 7 +TABLE test t2 0 +TABLE test t3 15 +select concat(current_user(), " is connected") as status; +status +user2@localhost is connected +"================== Step 4 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 17 +user1 wait/lock/table/sql/handler 0 +username event_name count_star +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 22 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 22 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 4 3 1 3 1 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 3 1 2 1 0 2 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 10 7 3 7 3 0 0 +TABLE test t3 index_b 1 1 0 1 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 4 1 3 1 0 3 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 7 4 3 4 1 2 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 15 9 6 9 3 3 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 7 +TABLE test t2 0 +TABLE test t3 15 +insert into test.t1 set a=201, b=1, c=1; +insert into test.t2 set a=202, b=2, c=2; +insert into test.t2 set a=203, b=3, c=3; +insert into test.t3 set a=204, b=4, c=4; +insert into test.t3 set a=205, b=5, c=5; +insert into test.t3 set a=206, b=6, c=6; +select * from test.t1; +a b c d +101 1 1 2 +201 1 1 0 +select * from test.t2; +a b c d +102 2 2 1 +103 3 3 1 +202 2 2 0 +203 3 3 0 +select * from test.t3; +a b c d +104 4 4 1 +105 5 5 1 +106 6 6 1 +204 4 4 0 +205 5 5 0 +206 6 6 0 +update test.t1 set d=d+1; +update test.t2 set d=d+1; +update test.t3 set d=d+1; +update test.t1 set d=d+1 where a=201; +update test.t2 set d=d+1 where a=201; +update test.t3 set d=d+1 where a=201; +select * from test.t1 force index(index_b) where b=5; +a b c d +select * from test.t2 force index(index_b) where b=5; +a b c d +select * from test.t3 force index(index_b) where b=5; +a b c d +105 5 5 2 +205 5 5 1 +"================== con2 marker ==================" +"================== Step 5 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 17 +user1 wait/lock/table/sql/handler 0 +username event_name count_star +user2 wait/io/table/sql/handler 25 +user2 wait/lock/table/sql/handler 0 +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 35 +user2 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 35 +user2 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 57 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 57 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 10 8 2 8 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 7 2 5 2 0 5 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 26 20 6 20 6 0 0 +TABLE test t3 index_b 3 3 0 3 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 11 2 9 2 0 9 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 17 10 7 10 2 5 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 40 25 15 25 6 9 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 17 +TABLE test t2 0 +TABLE test t3 40 +select concat(current_user(), " is connected") as status; +status +user3@localhost is connected +"================== Step 6 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 17 +user1 wait/lock/table/sql/handler 0 +username event_name count_star +user2 wait/io/table/sql/handler 25 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 35 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 35 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 57 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 57 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 10 8 2 8 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 7 2 5 2 0 5 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 26 20 6 20 6 0 0 +TABLE test t3 index_b 3 3 0 3 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 11 2 9 2 0 9 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 17 10 7 10 2 5 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 40 25 15 25 6 9 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 17 +TABLE test t2 0 +TABLE test t3 40 +insert into test.t1 set a=301, b=1, c=1; +insert into test.t2 set a=302, b=2, c=2; +insert into test.t2 set a=303, b=3, c=3; +insert into test.t3 set a=304, b=4, c=4; +insert into test.t3 set a=305, b=5, c=5; +insert into test.t3 set a=306, b=6, c=6; +select * from test.t1; +a b c d +101 1 1 3 +201 1 1 2 +301 1 1 0 +select * from test.t2; +a b c d +102 2 2 2 +103 3 3 2 +202 2 2 1 +203 3 3 1 +302 2 2 0 +303 3 3 0 +select * from test.t3; +a b c d +104 4 4 2 +105 5 5 2 +106 6 6 2 +204 4 4 1 +205 5 5 1 +206 6 6 1 +304 4 4 0 +305 5 5 0 +306 6 6 0 +update test.t1 set d=d+1; +update test.t2 set d=d+1; +update test.t3 set d=d+1; +update test.t1 set d=d+1 where a=301; +update test.t2 set d=d+1 where a=301; +update test.t3 set d=d+1 where a=301; +select * from test.t1 force index(index_b) where b=5; +a b c d +select * from test.t2 force index(index_b) where b=5; +a b c d +select * from test.t3 force index(index_b) where b=5; +a b c d +105 5 5 3 +205 5 5 2 +305 5 5 1 +"================== con3 marker ==================" +"================== Step 7 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 17 +user1 wait/lock/table/sql/handler 0 +username event_name count_star +user2 wait/io/table/sql/handler 25 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 33 +user3 wait/lock/table/sql/handler 0 +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 35 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 48 +user3 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 35 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 48 +user3 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 105 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 105 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 15 3 15 3 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 12 3 9 3 0 9 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 48 39 9 39 9 0 0 +TABLE test t3 index_b 6 6 0 6 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 21 3 18 3 0 18 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 30 18 12 18 3 9 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 75 48 27 48 9 18 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 30 +TABLE test t2 0 +TABLE test t3 75 +select concat(current_user(), " is connected") as status; +status +user4@localhost is connected +"================== Step 8 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 17 +user1 wait/lock/table/sql/handler 0 +username event_name count_star +user2 wait/io/table/sql/handler 25 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 33 +user3 wait/lock/table/sql/handler 0 +username event_name count_star +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 35 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 48 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 0 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 35 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 48 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 105 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 105 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 15 3 15 3 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 12 3 9 3 0 9 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 48 39 9 39 9 0 0 +TABLE test t3 index_b 6 6 0 6 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 21 3 18 3 0 18 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 30 18 12 18 3 9 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 75 48 27 48 9 18 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 30 +TABLE test t2 0 +TABLE test t3 75 +insert into test.t1 set a=401, b=1, c=1; +insert into test.t2 set a=402, b=2, c=2; +insert into test.t2 set a=403, b=3, c=3; +insert into test.t3 set a=404, b=4, c=4; +insert into test.t3 set a=405, b=5, c=5; +insert into test.t3 set a=406, b=6, c=6; +select * from test.t1; +a b c d +101 1 1 4 +201 1 1 3 +301 1 1 2 +401 1 1 0 +select * from test.t2; +a b c d +102 2 2 3 +103 3 3 3 +202 2 2 2 +203 3 3 2 +302 2 2 1 +303 3 3 1 +402 2 2 0 +403 3 3 0 +select * from test.t3; +a b c d +104 4 4 3 +105 5 5 3 +106 6 6 3 +204 4 4 2 +205 5 5 2 +206 6 6 2 +304 4 4 1 +305 5 5 1 +306 6 6 1 +404 4 4 0 +405 5 5 0 +406 6 6 0 +update test.t1 set d=d+1; +update test.t2 set d=d+1; +update test.t3 set d=d+1; +update test.t1 set d=d+1 where a=401; +update test.t2 set d=d+1 where a=401; +update test.t3 set d=d+1 where a=401; +select * from test.t1 force index(index_b) where b=5; +a b c d +select * from test.t2 force index(index_b) where b=5; +a b c d +select * from test.t3 force index(index_b) where b=5; +a b c d +105 5 5 4 +205 5 5 3 +305 5 5 2 +405 5 5 1 +"================== con4 marker ==================" +"================== Step 9 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 17 +user1 wait/lock/table/sql/handler 0 +username event_name count_star +user2 wait/io/table/sql/handler 25 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 33 +user3 wait/lock/table/sql/handler 0 +username event_name count_star +user4 wait/io/table/sql/handler 41 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 35 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 48 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 61 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 35 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 48 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 61 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 166 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 166 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 46 +TABLE test t2 0 +TABLE test t3 120 +lock tables test.t1 read, test.t2 read, test.t3 read; +unlock tables; +lock tables test.t1 write, test.t2 write, test.t3 write; +unlock tables; +"================== con1 marker ==================" +"================== Step 10 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 17 +user1 wait/lock/table/sql/handler 0 +username event_name count_star +user2 wait/io/table/sql/handler 25 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 33 +user3 wait/lock/table/sql/handler 0 +username event_name count_star +user4 wait/io/table/sql/handler 41 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 35 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 48 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 61 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 35 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 48 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 61 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 166 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 166 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 46 +TABLE test t2 0 +TABLE test t3 120 +flush tables; +"================== flush marker ==================" +"================== Step 11 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 17 +user1 wait/lock/table/sql/handler 0 +username event_name count_star +user2 wait/io/table/sql/handler 25 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 33 +user3 wait/lock/table/sql/handler 0 +username event_name count_star +user4 wait/io/table/sql/handler 41 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 35 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 48 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 61 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 35 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 48 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 61 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 166 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 166 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 46 +TABLE test t2 0 +TABLE test t3 120 +set global read_only=1; +set global read_only=0; +"================== global read_only marker ==================" +"================== Step 12 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 17 +user1 wait/lock/table/sql/handler 0 +username event_name count_star +user2 wait/io/table/sql/handler 25 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 33 +user3 wait/lock/table/sql/handler 0 +username event_name count_star +user4 wait/io/table/sql/handler 41 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 35 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 48 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 61 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 35 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 48 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 61 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 166 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 166 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 46 +TABLE test t2 0 +TABLE test t3 120 +"================== con1 disconnected ==================" +"================== Step 13 ==================" +call dump_thread(); +username status +user1 not found +username event_name count_star +user2 wait/io/table/sql/handler 25 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 33 +user3 wait/lock/table/sql/handler 0 +username event_name count_star +user4 wait/io/table/sql/handler 41 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 35 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 48 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 61 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 35 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 48 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 61 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 166 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 166 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 46 +TABLE test t2 0 +TABLE test t3 120 +"================== con2 disconnected ==================" +"================== Step 14 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username event_name count_star +user3 wait/io/table/sql/handler 33 +user3 wait/lock/table/sql/handler 0 +username event_name count_star +user4 wait/io/table/sql/handler 41 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 35 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 48 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 61 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 35 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 48 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 61 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 166 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 166 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 46 +TABLE test t2 0 +TABLE test t3 120 +"================== con3 disconnected ==================" +"================== Step 15 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username event_name count_star +user4 wait/io/table/sql/handler 41 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 35 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 48 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 61 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 35 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 48 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 61 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 166 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 166 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 46 +TABLE test t2 0 +TABLE test t3 120 +"================== con4 disconnected ==================" +"================== Step 16 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 35 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 48 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 61 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 35 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 48 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 61 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 166 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 166 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 46 +TABLE test t2 0 +TABLE test t3 120 +truncate performance_schema.events_waits_summary_by_thread_by_event_name; +"================== BY_THREAD truncated ==================" +"================== Step 17 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 35 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 48 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 61 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 35 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 48 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 61 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 166 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 166 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 46 +TABLE test t2 0 +TABLE test t3 120 +truncate performance_schema.events_waits_summary_by_account_by_event_name; +"================== BY_ACCOUNT truncated ==================" +"================== Step 18 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 0 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 35 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 48 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 61 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 166 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 166 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 46 +TABLE test t2 0 +TABLE test t3 120 +truncate performance_schema.events_waits_summary_by_user_by_event_name; +"================== BY_USER truncated ==================" +"================== Step 19 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 0 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 166 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 166 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 46 +TABLE test t2 0 +TABLE test t3 120 +truncate performance_schema.events_waits_summary_by_host_by_event_name; +"================== BY_HOST truncated ==================" +"================== Step 21 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 0 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 166 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 46 +TABLE test t2 0 +TABLE test t3 120 +truncate performance_schema.events_waits_summary_global_by_event_name; +"================== GLOBAL truncated ==================" +"================== Step 21 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 0 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 0 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 0 0 0 0 0 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 0 0 0 0 0 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 0 0 0 0 0 0 0 +TABLE test t3 index_b 0 0 0 0 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 0 0 0 0 0 0 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 0 +TABLE test t2 0 +TABLE test t3 0 +show global status like "performance_schema%table%_lost"; +Variable_name Value +Performance_schema_table_handles_lost 0 +Performance_schema_table_instances_lost 0 +Performance_schema_table_lock_stat_lost 0 diff --git a/mysql-test/suite/table_io_aggregate_thread_4u_3t.result-pq b/mysql-test/suite/table_io_aggregate_thread_4u_3t.result-pq new file mode 100644 index 000000000000..5204f15a857f --- /dev/null +++ b/mysql-test/suite/table_io_aggregate_thread_4u_3t.result-pq @@ -0,0 +1,1743 @@ +update performance_schema.setup_instruments +set enabled='NO' where name='wait/lock/table/sql/handler'; +update performance_schema.setup_consumers +set enabled='NO' where name like 'event%'; +select * from performance_schema.setup_actors +order by USER, HOST, `ROLE`; +HOST USER ROLE ENABLED HISTORY +localhost user1 % YES YES +localhost user2 % YES YES +localhost user3 % YES YES +localhost user4 % YES YES +select * from performance_schema.setup_objects +order by object_type, object_schema, object_name; +OBJECT_TYPE OBJECT_SCHEMA OBJECT_NAME ENABLED TIMED +TABLE test t1 YES YES +TABLE test t2 YES NO +TABLE test t3 YES NO +select * from performance_schema.setup_consumers; +NAME ENABLED +events_stages_current NO +events_stages_history NO +events_stages_history_long NO +events_statements_current NO +events_statements_history NO +events_statements_history_long NO +events_transactions_current NO +events_transactions_history NO +events_transactions_history_long NO +events_waits_current NO +events_waits_history NO +events_waits_history_long NO +global_instrumentation YES +thread_instrumentation YES +statements_digest YES +flush tables; +truncate performance_schema.objects_summary_global_by_type; +truncate performance_schema.table_io_waits_summary_by_index_usage; +truncate performance_schema.table_io_waits_summary_by_table; +truncate performance_schema.table_lock_waits_summary_by_table; +truncate performance_schema.events_waits_summary_by_thread_by_event_name; +truncate performance_schema.events_waits_summary_by_account_by_event_name; +truncate performance_schema.events_waits_summary_by_user_by_event_name; +truncate performance_schema.events_waits_summary_by_host_by_event_name; +truncate performance_schema.events_waits_summary_global_by_event_name; +truncate performance_schema.events_waits_history_long; +show global variables like "performance_schema%table%"; +Variable_name Value +performance_schema_max_table_handles -1 +performance_schema_max_table_instances -1 +performance_schema_max_table_lock_stat -1 +show global status like "performance_schema%table%_lost"; +Variable_name Value +Performance_schema_table_handles_lost 0 +Performance_schema_table_instances_lost 0 +Performance_schema_table_lock_stat_lost 0 +"================== Step 1 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +execute dump_waits_user; +user event_name count_star +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 0 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 0 0 0 0 0 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 index_b 0 0 0 0 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 0 0 0 0 0 0 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 0 +TABLE test t2 0 +TABLE test t3 0 +select concat(current_user(), " is connected") as status; +status +user1@localhost is connected +"================== Step 2 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 0 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 0 0 0 0 0 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 index_b 0 0 0 0 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 0 0 0 0 0 0 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 0 +TABLE test t2 0 +TABLE test t3 0 +insert into test.t1 set a=101, b=1, c=1; +insert into test.t2 set a=102, b=2, c=2; +insert into test.t2 set a=103, b=3, c=3; +insert into test.t3 set a=104, b=4, c=4; +insert into test.t3 set a=105, b=5, c=5; +insert into test.t3 set a=106, b=6, c=6; +select * from test.t1; +a b c d +101 1 1 0 +select * from test.t2; +a b c d +102 2 2 0 +103 3 3 0 +select * from test.t3; +a b c d +104 4 4 0 +105 5 5 0 +106 6 6 0 +update test.t1 set d=d+1; +update test.t2 set d=d+1; +update test.t3 set d=d+1; +update test.t1 set d=d+1 where a=101; +update test.t2 set d=d+1 where a=101; +update test.t3 set d=d+1 where a=101; +select * from test.t1 force index(index_b) where b=5; +a b c d +select * from test.t2 force index(index_b) where b=5; +a b c d +select * from test.t3 force index(index_b) where b=5; +a b c d +105 5 5 1 +"================== con1 marker ==================" +"================== Step 3-A ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 25 +user1 wait/lock/table/sql/handler 0 +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 32 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 32 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 4 3 1 3 1 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 3 1 2 1 0 2 0 +TABLE test t2 NULL 7 5 2 5 2 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 3 1 2 1 0 2 0 +TABLE test t3 NULL 10 7 3 7 3 0 0 +TABLE test t3 index_b 1 1 0 1 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 4 1 3 1 0 3 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 7 4 3 4 1 2 0 +TABLE test t2 10 6 4 6 2 2 0 +TABLE test t3 15 9 6 9 3 3 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 7 +TABLE test t2 10 +TABLE test t3 15 +flush tables; +"================== con1 FLUSH ==================" +"================== Step 3-B ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 25 +user1 wait/lock/table/sql/handler 0 +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 32 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 32 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 4 3 1 3 1 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 3 1 2 1 0 2 0 +TABLE test t2 NULL 7 5 2 5 2 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 3 1 2 1 0 2 0 +TABLE test t3 NULL 10 7 3 7 3 0 0 +TABLE test t3 index_b 1 1 0 1 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 4 1 3 1 0 3 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 7 4 3 4 1 2 0 +TABLE test t2 10 6 4 6 2 2 0 +TABLE test t3 15 9 6 9 3 3 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 7 +TABLE test t2 10 +TABLE test t3 15 +select concat(current_user(), " is connected") as status; +status +user2@localhost is connected +"================== Step 4 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 25 +user1 wait/lock/table/sql/handler 0 +username event_name count_star +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 32 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 32 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 4 3 1 3 1 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 3 1 2 1 0 2 0 +TABLE test t2 NULL 7 5 2 5 2 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 3 1 2 1 0 2 0 +TABLE test t3 NULL 10 7 3 7 3 0 0 +TABLE test t3 index_b 1 1 0 1 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 4 1 3 1 0 3 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 7 4 3 4 1 2 0 +TABLE test t2 10 6 4 6 2 2 0 +TABLE test t3 15 9 6 9 3 3 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 7 +TABLE test t2 10 +TABLE test t3 15 +insert into test.t1 set a=201, b=1, c=1; +insert into test.t2 set a=202, b=2, c=2; +insert into test.t2 set a=203, b=3, c=3; +insert into test.t3 set a=204, b=4, c=4; +insert into test.t3 set a=205, b=5, c=5; +insert into test.t3 set a=206, b=6, c=6; +select * from test.t1; +a b c d +101 1 1 2 +201 1 1 0 +select * from test.t2; +a b c d +102 2 2 1 +103 3 3 1 +202 2 2 0 +203 3 3 0 +select * from test.t3; +a b c d +104 4 4 1 +105 5 5 1 +106 6 6 1 +204 4 4 0 +205 5 5 0 +206 6 6 0 +update test.t1 set d=d+1; +update test.t2 set d=d+1; +update test.t3 set d=d+1; +update test.t1 set d=d+1 where a=201; +update test.t2 set d=d+1 where a=201; +update test.t3 set d=d+1 where a=201; +select * from test.t1 force index(index_b) where b=5; +a b c d +select * from test.t2 force index(index_b) where b=5; +a b c d +select * from test.t3 force index(index_b) where b=5; +a b c d +105 5 5 2 +205 5 5 1 +"================== con2 marker ==================" +"================== Step 5 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 25 +user1 wait/lock/table/sql/handler 0 +username event_name count_star +user2 wait/io/table/sql/handler 37 +user2 wait/lock/table/sql/handler 0 +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 51 +user2 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 51 +user2 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 83 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 83 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 10 8 2 8 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 7 2 5 2 0 5 0 +TABLE test t2 NULL 18 14 4 14 4 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 8 2 6 2 0 6 0 +TABLE test t3 NULL 26 20 6 20 6 0 0 +TABLE test t3 index_b 3 3 0 3 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 11 2 9 2 0 9 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 17 10 7 10 2 5 0 +TABLE test t2 26 16 10 16 4 6 0 +TABLE test t3 40 25 15 25 6 9 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 17 +TABLE test t2 26 +TABLE test t3 40 +select concat(current_user(), " is connected") as status; +status +user3@localhost is connected +"================== Step 6 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 25 +user1 wait/lock/table/sql/handler 0 +username event_name count_star +user2 wait/io/table/sql/handler 37 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 51 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 51 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 83 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 83 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 10 8 2 8 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 7 2 5 2 0 5 0 +TABLE test t2 NULL 18 14 4 14 4 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 8 2 6 2 0 6 0 +TABLE test t3 NULL 26 20 6 20 6 0 0 +TABLE test t3 index_b 3 3 0 3 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 11 2 9 2 0 9 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 17 10 7 10 2 5 0 +TABLE test t2 26 16 10 16 4 6 0 +TABLE test t3 40 25 15 25 6 9 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 17 +TABLE test t2 26 +TABLE test t3 40 +insert into test.t1 set a=301, b=1, c=1; +insert into test.t2 set a=302, b=2, c=2; +insert into test.t2 set a=303, b=3, c=3; +insert into test.t3 set a=304, b=4, c=4; +insert into test.t3 set a=305, b=5, c=5; +insert into test.t3 set a=306, b=6, c=6; +select * from test.t1; +a b c d +101 1 1 3 +201 1 1 2 +301 1 1 0 +select * from test.t2; +a b c d +102 2 2 2 +103 3 3 2 +202 2 2 1 +203 3 3 1 +302 2 2 0 +303 3 3 0 +select * from test.t3; +a b c d +104 4 4 2 +105 5 5 2 +106 6 6 2 +204 4 4 1 +205 5 5 1 +206 6 6 1 +304 4 4 0 +305 5 5 0 +306 6 6 0 +update test.t1 set d=d+1; +update test.t2 set d=d+1; +update test.t3 set d=d+1; +update test.t1 set d=d+1 where a=301; +update test.t2 set d=d+1 where a=301; +update test.t3 set d=d+1 where a=301; +select * from test.t1 force index(index_b) where b=5; +a b c d +select * from test.t2 force index(index_b) where b=5; +a b c d +select * from test.t3 force index(index_b) where b=5; +a b c d +105 5 5 3 +205 5 5 2 +305 5 5 1 +"================== con3 marker ==================" +"================== Step 7 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 25 +user1 wait/lock/table/sql/handler 0 +username event_name count_star +user2 wait/io/table/sql/handler 37 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 49 +user3 wait/lock/table/sql/handler 0 +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 51 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 70 +user3 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 51 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 70 +user3 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 153 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 153 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 15 3 15 3 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 12 3 9 3 0 9 0 +TABLE test t2 NULL 33 27 6 27 6 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 15 3 12 3 0 12 0 +TABLE test t3 NULL 48 39 9 39 9 0 0 +TABLE test t3 index_b 6 6 0 6 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 21 3 18 3 0 18 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 30 18 12 18 3 9 0 +TABLE test t2 48 30 18 30 6 12 0 +TABLE test t3 75 48 27 48 9 18 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 30 +TABLE test t2 48 +TABLE test t3 75 +select concat(current_user(), " is connected") as status; +status +user4@localhost is connected +"================== Step 8 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 25 +user1 wait/lock/table/sql/handler 0 +username event_name count_star +user2 wait/io/table/sql/handler 37 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 49 +user3 wait/lock/table/sql/handler 0 +username event_name count_star +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 51 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 70 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 0 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 51 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 70 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 153 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 153 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 15 3 15 3 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 12 3 9 3 0 9 0 +TABLE test t2 NULL 33 27 6 27 6 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 15 3 12 3 0 12 0 +TABLE test t3 NULL 48 39 9 39 9 0 0 +TABLE test t3 index_b 6 6 0 6 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 21 3 18 3 0 18 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 30 18 12 18 3 9 0 +TABLE test t2 48 30 18 30 6 12 0 +TABLE test t3 75 48 27 48 9 18 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 30 +TABLE test t2 48 +TABLE test t3 75 +insert into test.t1 set a=401, b=1, c=1; +insert into test.t2 set a=402, b=2, c=2; +insert into test.t2 set a=403, b=3, c=3; +insert into test.t3 set a=404, b=4, c=4; +insert into test.t3 set a=405, b=5, c=5; +insert into test.t3 set a=406, b=6, c=6; +select * from test.t1; +a b c d +101 1 1 4 +201 1 1 3 +301 1 1 2 +401 1 1 0 +select * from test.t2; +a b c d +102 2 2 3 +103 3 3 3 +202 2 2 2 +203 3 3 2 +302 2 2 1 +303 3 3 1 +402 2 2 0 +403 3 3 0 +select * from test.t3; +a b c d +104 4 4 3 +105 5 5 3 +106 6 6 3 +204 4 4 2 +205 5 5 2 +206 6 6 2 +304 4 4 1 +305 5 5 1 +306 6 6 1 +404 4 4 0 +405 5 5 0 +406 6 6 0 +update test.t1 set d=d+1; +update test.t2 set d=d+1; +update test.t3 set d=d+1; +update test.t1 set d=d+1 where a=401; +update test.t2 set d=d+1 where a=401; +update test.t3 set d=d+1 where a=401; +select * from test.t1 force index(index_b) where b=5; +a b c d +select * from test.t2 force index(index_b) where b=5; +a b c d +select * from test.t3 force index(index_b) where b=5; +a b c d +105 5 5 4 +205 5 5 3 +305 5 5 2 +405 5 5 1 +"================== con4 marker ==================" +"================== Step 9 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 25 +user1 wait/lock/table/sql/handler 0 +username event_name count_star +user2 wait/io/table/sql/handler 37 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 49 +user3 wait/lock/table/sql/handler 0 +username event_name count_star +user4 wait/io/table/sql/handler 61 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 51 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 70 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 89 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 51 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 70 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 89 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 242 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 242 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 NULL 52 44 8 44 8 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 24 4 20 4 0 20 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 76 48 28 48 8 20 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 46 +TABLE test t2 76 +TABLE test t3 120 +lock tables test.t1 read, test.t2 read, test.t3 read; +unlock tables; +lock tables test.t1 write, test.t2 write, test.t3 write; +unlock tables; +"================== con1 marker ==================" +"================== Step 10 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 25 +user1 wait/lock/table/sql/handler 0 +username event_name count_star +user2 wait/io/table/sql/handler 37 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 49 +user3 wait/lock/table/sql/handler 0 +username event_name count_star +user4 wait/io/table/sql/handler 61 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 51 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 70 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 89 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 51 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 70 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 89 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 242 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 242 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 NULL 52 44 8 44 8 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 24 4 20 4 0 20 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 76 48 28 48 8 20 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 46 +TABLE test t2 76 +TABLE test t3 120 +flush tables; +"================== flush marker ==================" +"================== Step 11 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 25 +user1 wait/lock/table/sql/handler 0 +username event_name count_star +user2 wait/io/table/sql/handler 37 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 49 +user3 wait/lock/table/sql/handler 0 +username event_name count_star +user4 wait/io/table/sql/handler 61 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 51 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 70 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 89 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 51 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 70 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 89 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 242 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 242 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 NULL 52 44 8 44 8 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 24 4 20 4 0 20 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 76 48 28 48 8 20 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 46 +TABLE test t2 76 +TABLE test t3 120 +set global read_only=1; +set global read_only=0; +"================== global read_only marker ==================" +"================== Step 12 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 25 +user1 wait/lock/table/sql/handler 0 +username event_name count_star +user2 wait/io/table/sql/handler 37 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 49 +user3 wait/lock/table/sql/handler 0 +username event_name count_star +user4 wait/io/table/sql/handler 61 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 51 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 70 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 89 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 51 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 70 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 89 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 242 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 242 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 NULL 52 44 8 44 8 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 24 4 20 4 0 20 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 76 48 28 48 8 20 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 46 +TABLE test t2 76 +TABLE test t3 120 +"================== con1 disconnected ==================" +"================== Step 13 ==================" +call dump_thread(); +username status +user1 not found +username event_name count_star +user2 wait/io/table/sql/handler 37 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 49 +user3 wait/lock/table/sql/handler 0 +username event_name count_star +user4 wait/io/table/sql/handler 61 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 51 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 70 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 89 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 51 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 70 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 89 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 242 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 242 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 NULL 52 44 8 44 8 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 24 4 20 4 0 20 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 76 48 28 48 8 20 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 46 +TABLE test t2 76 +TABLE test t3 120 +"================== con2 disconnected ==================" +"================== Step 14 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username event_name count_star +user3 wait/io/table/sql/handler 49 +user3 wait/lock/table/sql/handler 0 +username event_name count_star +user4 wait/io/table/sql/handler 61 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 51 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 70 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 89 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 51 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 70 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 89 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 242 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 242 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 NULL 52 44 8 44 8 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 24 4 20 4 0 20 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 76 48 28 48 8 20 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 46 +TABLE test t2 76 +TABLE test t3 120 +"================== con3 disconnected ==================" +"================== Step 15 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username event_name count_star +user4 wait/io/table/sql/handler 61 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 51 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 70 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 89 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 51 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 70 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 89 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 242 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 242 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 NULL 52 44 8 44 8 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 24 4 20 4 0 20 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 76 48 28 48 8 20 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 46 +TABLE test t2 76 +TABLE test t3 120 +"================== con4 disconnected ==================" +"================== Step 16 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 51 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 70 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 89 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 51 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 70 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 89 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 242 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 242 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 NULL 52 44 8 44 8 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 24 4 20 4 0 20 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 76 48 28 48 8 20 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 46 +TABLE test t2 76 +TABLE test t3 120 +truncate performance_schema.events_waits_summary_by_thread_by_event_name; +"================== BY_THREAD truncated ==================" +"================== Step 17 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 51 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 70 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 89 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 51 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 70 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 89 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 242 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 242 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 NULL 52 44 8 44 8 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 24 4 20 4 0 20 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 76 48 28 48 8 20 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 46 +TABLE test t2 76 +TABLE test t3 120 +truncate performance_schema.events_waits_summary_by_account_by_event_name; +"================== BY_ACCOUNT truncated ==================" +"================== Step 18 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 0 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 51 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 70 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 89 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 242 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 242 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 NULL 52 44 8 44 8 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 24 4 20 4 0 20 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 76 48 28 48 8 20 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 46 +TABLE test t2 76 +TABLE test t3 120 +truncate performance_schema.events_waits_summary_by_user_by_event_name; +"================== BY_USER truncated ==================" +"================== Step 19 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 0 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 242 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 242 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 NULL 52 44 8 44 8 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 24 4 20 4 0 20 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 76 48 28 48 8 20 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 46 +TABLE test t2 76 +TABLE test t3 120 +truncate performance_schema.events_waits_summary_by_host_by_event_name; +"================== BY_HOST truncated ==================" +"================== Step 21 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 0 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 242 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 NULL 52 44 8 44 8 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 24 4 20 4 0 20 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 76 48 28 48 8 20 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 46 +TABLE test t2 76 +TABLE test t3 120 +truncate performance_schema.events_waits_summary_global_by_event_name; +"================== GLOBAL truncated ==================" +"================== Step 21 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 0 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 0 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 0 0 0 0 0 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 0 0 0 0 0 0 0 +TABLE test t2 NULL 0 0 0 0 0 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 0 0 0 0 0 0 0 +TABLE test t3 index_b 0 0 0 0 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 0 0 0 0 0 0 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 0 +TABLE test t2 0 +TABLE test t3 0 +show global status like "performance_schema%table%_lost"; +Variable_name Value +Performance_schema_table_handles_lost 0 +Performance_schema_table_instances_lost 0 +Performance_schema_table_lock_stat_lost 0 diff --git a/mysql-test/suite/temp_table.result-pq b/mysql-test/suite/temp_table.result-pq new file mode 100644 index 000000000000..5d1bc41a2fa6 --- /dev/null +++ b/mysql-test/suite/temp_table.result-pq @@ -0,0 +1,1399 @@ +SET optimizer_trace_max_mem_size=1048576; +SET optimizer_trace="enabled=on,one_line=off"; +SET end_markers_in_json="on"; +CREATE TABLE tmp ( +pk INT PRIMARY KEY AUTO_INCREMENT, +col1 CHAR (1) +); +INSERT INTO tmp(col1) VALUES ('a'),('b'),('c'),('d'),('e'),('f'),('g'),('h'); +CREATE TABLE t1 ( +uniq VARCHAR(10), +col1 VARCHAR(10), +col2 VARCHAR(1024) +) CHARSET utf8mb4; +INSERT INTO t1 SELECT pk, col1, col1 FROM tmp; +SELECT uniq, col1 FROM t1 GROUP BY col2,uniq LIMIT 3; +uniq col1 +1 a +2 b +3 c +SELECT * FROM information_schema.OPTIMIZER_TRACE; +QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES +SELECT uniq, col1 FROM t1 GROUP BY col2,uniq LIMIT 3 { + "steps": [ + { + "join_preparation": { + "select#": 1, + "steps": [ + { + "expanded_query": "/* select#1 */ select `t1`.`uniq` AS `uniq`,`t1`.`col1` AS `col1` from `t1` group by `t1`.`col2`,`t1`.`uniq` limit 3" + } + ] /* steps */ + } /* join_preparation */ + }, + { + "join_optimization": { + "select#": 1, + "steps": [ + { + "substitute_generated_columns": { + } /* substitute_generated_columns */ + }, + { + "table_dependencies": [ + { + "table": "`t1`", + "row_may_be_null": false, + "map_bit": 0, + "depends_on_map_bits": [ + ] /* depends_on_map_bits */ + } + ] /* table_dependencies */ + }, + { + "rows_estimation": [ + { + "table": "`t1`", + "table_scan": { + "rows": 8, + "cost": 0.25 + } /* table_scan */ + } + ] /* rows_estimation */ + }, + { + "considered_execution_plans": [ + { + "plan_prefix": [ + ] /* plan_prefix */, + "table": "`t1`", + "best_access_path": { + "considered_access_paths": [ + { + "rows_to_scan": 8, + "access_type": "scan", + "resulting_rows": 8, + "cost": 1.05, + "chosen": true + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 100, + "rows_for_plan": 8, + "cost_for_plan": 1.05, + "chosen": true + } + ] /* considered_execution_plans */ + }, + { + "attaching_conditions_to_tables": { + "original_condition": null, + "attached_conditions_computation": [ + ] /* attached_conditions_computation */, + "attached_conditions_summary": [ + { + "table": "`t1`", + "attached": null + } + ] /* attached_conditions_summary */ + } /* attaching_conditions_to_tables */ + }, + { + "optimizing_distinct_group_by_order_by": { + "simplifying_group_by": { + "original_clause": "`t1`.`col2`,`t1`.`uniq`", + "items": [ + { + "item": "`t1`.`col2`" + }, + { + "item": "`t1`.`uniq`" + } + ] /* items */, + "resulting_clause_is_simple": true, + "resulting_clause": "`t1`.`col2`,`t1`.`uniq`" + } /* simplifying_group_by */ + } /* optimizing_distinct_group_by_order_by */ + }, + { + "finalizing_table_conditions": [ + ] /* finalizing_table_conditions */ + }, + { + "refine_plan": [ + { + "table": "`t1`" + } + ] /* refine_plan */ + }, + { + "considering_tmp_tables": [ + { + "adding_tmp_table_in_plan_at_position": 1, + "write_method": "write_all_rows" + } + ] /* considering_tmp_tables */ + } + ] /* steps */ + } /* join_optimization */ + }, + { + "make_parallel_query_plan": { + "select#": 1, + "detail": [ + { + "table": "`t1`", + "degree of parallel": 4, + "unknown_key_1": { + "considering_tmp_tables": [ + { + "adding_tmp_table_in_plan_at_position": 0, + "cause": "output_for_parallel_query", + "write_method": "write_all_rows" + } + ] /* considering_tmp_tables */ + } + } + ] /* detail */ + } /* make_parallel_query_plan */ + }, + { + "join_execution": { + "select#": 1, + "steps": [ + { + "creating_tmp_table": { + "tmp_table_info": { + "in_plan_at_position": 1, + "columns": 4, + "row_length": 4190, + "key_length": 8, + "unique_constraint": true, + "makes_grouped_rows": true, + "cannot_insert_duplicates": false, + "location": "TempTable" + } /* tmp_table_info */ + } /* creating_tmp_table */ + }, + { + "materialize": { + "select#": 1, + "steps": [ + ] /* steps */ + } /* materialize */ + } + ] /* steps */ + } /* join_execution */ + } + ] /* steps */ +} 0 0 +SELECT uniq, col1, col2 FROM t1 GROUP BY uniq ; +uniq col1 col2 +1 a a +2 b b +3 c c +4 d d +5 e e +6 f f +7 g g +8 h h +SELECT * FROM information_schema.OPTIMIZER_TRACE; +QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES +SELECT uniq, col1, col2 FROM t1 GROUP BY uniq { + "steps": [ + { + "join_preparation": { + "select#": 1, + "steps": [ + { + "expanded_query": "/* select#1 */ select `t1`.`uniq` AS `uniq`,`t1`.`col1` AS `col1`,`t1`.`col2` AS `col2` from `t1` group by `t1`.`uniq`" + } + ] /* steps */ + } /* join_preparation */ + }, + { + "join_optimization": { + "select#": 1, + "steps": [ + { + "substitute_generated_columns": { + } /* substitute_generated_columns */ + }, + { + "table_dependencies": [ + { + "table": "`t1`", + "row_may_be_null": false, + "map_bit": 0, + "depends_on_map_bits": [ + ] /* depends_on_map_bits */ + } + ] /* table_dependencies */ + }, + { + "rows_estimation": [ + { + "table": "`t1`", + "table_scan": { + "rows": 8, + "cost": 0.25 + } /* table_scan */ + } + ] /* rows_estimation */ + }, + { + "considered_execution_plans": [ + { + "plan_prefix": [ + ] /* plan_prefix */, + "table": "`t1`", + "best_access_path": { + "considered_access_paths": [ + { + "rows_to_scan": 8, + "access_type": "scan", + "resulting_rows": 8, + "cost": 1.05, + "chosen": true, + "use_tmp_table": true + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 100, + "rows_for_plan": 8, + "cost_for_plan": 1.05, + "sort_cost": 8, + "new_cost_for_plan": 9.05, + "chosen": true + } + ] /* considered_execution_plans */ + }, + { + "attaching_conditions_to_tables": { + "original_condition": null, + "attached_conditions_computation": [ + ] /* attached_conditions_computation */, + "attached_conditions_summary": [ + { + "table": "`t1`", + "attached": null + } + ] /* attached_conditions_summary */ + } /* attaching_conditions_to_tables */ + }, + { + "optimizing_distinct_group_by_order_by": { + "simplifying_group_by": { + "original_clause": "`t1`.`uniq`", + "items": [ + { + "item": "`t1`.`uniq`" + } + ] /* items */, + "resulting_clause_is_simple": true, + "resulting_clause": "`t1`.`uniq`" + } /* simplifying_group_by */ + } /* optimizing_distinct_group_by_order_by */ + }, + { + "finalizing_table_conditions": [ + ] /* finalizing_table_conditions */ + }, + { + "refine_plan": [ + { + "table": "`t1`" + } + ] /* refine_plan */ + }, + { + "considering_tmp_tables": [ + { + "adding_tmp_table_in_plan_at_position": 1, + "write_method": "write_all_rows" + } + ] /* considering_tmp_tables */ + } + ] /* steps */ + } /* join_optimization */ + }, + { + "make_parallel_query_plan": { + "select#": 1, + "detail": [ + { + "table": "`t1`", + "degree of parallel": 4, + "unknown_key_1": { + "considering_tmp_tables": [ + { + "adding_tmp_table_in_plan_at_position": 0, + "cause": "output_for_parallel_query", + "write_method": "write_all_rows" + } + ] /* considering_tmp_tables */ + } + } + ] /* detail */ + } /* make_parallel_query_plan */ + }, + { + "join_execution": { + "select#": 1, + "steps": [ + { + "creating_tmp_table": { + "tmp_table_info": { + "in_plan_at_position": 1, + "columns": 3, + "row_length": 4182, + "key_length": 43, + "unique_constraint": false, + "makes_grouped_rows": true, + "cannot_insert_duplicates": false, + "location": "TempTable" + } /* tmp_table_info */ + } /* creating_tmp_table */ + }, + { + "materialize": { + "select#": 1, + "steps": [ + ] /* steps */ + } /* materialize */ + } + ] /* steps */ + } /* join_execution */ + } + ] /* steps */ +} 0 0 +select @@tmp_table_size; +@@tmp_table_size +16777216 +SET @old_size= @@tmp_table_size; +SET SESSION tmp_table_size= 1024; +SET SESSION internal_tmp_mem_storage_engine='memory'; +INSERT INTO t1 SELECT pk+8, col1, col1 FROM tmp; +SELECT uniq, col1, col2 FROM t1 GROUP BY uniq; +uniq col1 col2 +1 a a +10 b b +11 c c +12 d d +13 e e +14 f f +15 g g +16 h h +2 b b +3 c c +4 d d +5 e e +6 f f +7 g g +8 h h +9 a a +SELECT * FROM information_schema.OPTIMIZER_TRACE; +QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES +SELECT uniq, col1, col2 FROM t1 GROUP BY uniq { + "steps": [ + { + "join_preparation": { + "select#": 1, + "steps": [ + { + "expanded_query": "/* select#1 */ select `t1`.`uniq` AS `uniq`,`t1`.`col1` AS `col1`,`t1`.`col2` AS `col2` from `t1` group by `t1`.`uniq`" + } + ] /* steps */ + } /* join_preparation */ + }, + { + "join_optimization": { + "select#": 1, + "steps": [ + { + "substitute_generated_columns": { + } /* substitute_generated_columns */ + }, + { + "table_dependencies": [ + { + "table": "`t1`", + "row_may_be_null": false, + "map_bit": 0, + "depends_on_map_bits": [ + ] /* depends_on_map_bits */ + } + ] /* table_dependencies */ + }, + { + "rows_estimation": [ + { + "table": "`t1`", + "table_scan": { + "rows": 16, + "cost": 0.25 + } /* table_scan */ + } + ] /* rows_estimation */ + }, + { + "considered_execution_plans": [ + { + "plan_prefix": [ + ] /* plan_prefix */, + "table": "`t1`", + "best_access_path": { + "considered_access_paths": [ + { + "rows_to_scan": 16, + "access_type": "scan", + "resulting_rows": 16, + "cost": 1.85, + "chosen": true, + "use_tmp_table": true + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 100, + "rows_for_plan": 16, + "cost_for_plan": 1.85, + "sort_cost": 16, + "new_cost_for_plan": 17.85, + "chosen": true + } + ] /* considered_execution_plans */ + }, + { + "attaching_conditions_to_tables": { + "original_condition": null, + "attached_conditions_computation": [ + ] /* attached_conditions_computation */, + "attached_conditions_summary": [ + { + "table": "`t1`", + "attached": null + } + ] /* attached_conditions_summary */ + } /* attaching_conditions_to_tables */ + }, + { + "optimizing_distinct_group_by_order_by": { + "simplifying_group_by": { + "original_clause": "`t1`.`uniq`", + "items": [ + { + "item": "`t1`.`uniq`" + } + ] /* items */, + "resulting_clause_is_simple": true, + "resulting_clause": "`t1`.`uniq`" + } /* simplifying_group_by */ + } /* optimizing_distinct_group_by_order_by */ + }, + { + "finalizing_table_conditions": [ + ] /* finalizing_table_conditions */ + }, + { + "refine_plan": [ + { + "table": "`t1`" + } + ] /* refine_plan */ + }, + { + "considering_tmp_tables": [ + { + "adding_tmp_table_in_plan_at_position": 1, + "write_method": "write_all_rows" + } + ] /* considering_tmp_tables */ + } + ] /* steps */ + } /* join_optimization */ + }, + { + "make_parallel_query_plan": { + "select#": 1, + "detail": [ + { + "table": "`t1`", + "degree of parallel": 4, + "unknown_key_1": { + "considering_tmp_tables": [ + { + "adding_tmp_table_in_plan_at_position": 0, + "cause": "output_for_parallel_query", + "write_method": "write_all_rows" + } + ] /* considering_tmp_tables */ + } + } + ] /* detail */ + } /* make_parallel_query_plan */ + }, + { + "join_execution": { + "select#": 1, + "steps": [ + { + "creating_tmp_table": { + "tmp_table_info": { + "in_plan_at_position": 1, + "columns": 3, + "row_length": 4182, + "key_length": 43, + "unique_constraint": false, + "makes_grouped_rows": true, + "cannot_insert_duplicates": false, + "location": "memory (heap)", + "row_limit_estimate": 1 + } /* tmp_table_info */ + } /* creating_tmp_table */ + }, + { + "materialize": { + "select#": 1, + "steps": [ + { + "converting_tmp_table_to_ondisk": { + "cause": "memory_table_size_exceeded", + "tmp_table_info": { + "in_plan_at_position": 1, + "columns": 3, + "row_length": 4182, + "key_length": 43, + "unique_constraint": false, + "makes_grouped_rows": true, + "cannot_insert_duplicates": false, + "location": "disk (TMP_TABLE_ENGINE)", + "record_format": "packed" + } /* tmp_table_info */ + } /* converting_tmp_table_to_ondisk */ + } + ] /* steps */ + } /* materialize */ + } + ] /* steps */ + } /* join_execution */ + } + ] /* steps */ +} 0 0 +SET SESSION internal_tmp_mem_storage_engine=default; +SET GLOBAL tmp_table_size= @old_size; +SELECT pool_id FROM information_schema.INNODB_BUFFER_PAGE LIMIT 1; +pool_id +0 +SELECT * FROM information_schema.OPTIMIZER_TRACE; +QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES +SELECT pool_id FROM information_schema.INNODB_BUFFER_PAGE LIMIT 1 { + "steps": [ + { + "creating_tmp_table": { + "tmp_table_info": { + "columns": 21, + "row_length": 6863, + "key_length": 0, + "unique_constraint": false, + "makes_grouped_rows": false, + "cannot_insert_duplicates": false, + "location": "memory (heap)", + "row_limit_estimate": 1 + } /* tmp_table_info */ + } /* creating_tmp_table */ + }, + { + "join_preparation": { + "select#": 1, + "steps": [ + { + "expanded_query": "/* select#1 */ select `information_schema`.`INNODB_BUFFER_PAGE`.`POOL_ID` AS `pool_id` from `information_schema`.`INNODB_BUFFER_PAGE` limit 1" + } + ] /* steps */ + } /* join_preparation */ + }, + { + "join_optimization": { + "select#": 1, + "steps": [ + { + "table_dependencies": [ + { + "table": "`information_schema`.`INNODB_BUFFER_PAGE`", + "row_may_be_null": false, + "map_bit": 0, + "depends_on_map_bits": [ + ] /* depends_on_map_bits */ + } + ] /* table_dependencies */ + }, + { + "rows_estimation": [ + { + "table": "`information_schema`.`INNODB_BUFFER_PAGE`", + "table_scan": { + "rows": 2, + "cost": 2.525 + } /* table_scan */ + } + ] /* rows_estimation */ + }, + { + "considered_execution_plans": [ + { + "plan_prefix": [ + ] /* plan_prefix */, + "table": "`information_schema`.`INNODB_BUFFER_PAGE`", + "best_access_path": { + "considered_access_paths": [ + { + "rows_to_scan": 2, + "access_type": "scan", + "resulting_rows": 2, + "cost": 2.725, + "chosen": true + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 100, + "rows_for_plan": 2, + "cost_for_plan": 2.725, + "chosen": true + } + ] /* considered_execution_plans */ + }, + { + "attaching_conditions_to_tables": { + "original_condition": null, + "attached_conditions_computation": [ + ] /* attached_conditions_computation */, + "attached_conditions_summary": [ + { + "table": "`information_schema`.`INNODB_BUFFER_PAGE`", + "attached": null + } + ] /* attached_conditions_summary */ + } /* attaching_conditions_to_tables */ + }, + { + "finalizing_table_conditions": [ + ] /* finalizing_table_conditions */ + }, + { + "refine_plan": [ + { + "table": "`information_schema`.`INNODB_BUFFER_PAGE`" + } + ] /* refine_plan */ + } + ] /* steps */ + } /* join_optimization */ + }, + { + "join_execution": { + "select#": 1, + "steps": [ + { + "converting_tmp_table_to_ondisk": { + "cause": "memory_table_size_exceeded", + "tmp_table_info": { + "table": "`information_schema`.`INNODB_BUFFER_PAGE`", + "in_plan_at_position": 0, + "columns": 21, + "row_length": 6863, + "key_length": 0, + "unique_constraint": false, + "makes_grouped_rows": false, + "cannot_insert_duplicates": false, + "location": "disk (TMP_TABLE_ENGINE)", + "record_format": "packed" + } /* tmp_table_info */ + } /* converting_tmp_table_to_ondisk */ + } + ] /* steps */ + } /* join_execution */ + } + ] /* steps */ +} 0 0 +DROP TABLE t1, tmp; +# +# Bug#17231940: THE OPTIMIZER STILL USES FIXED LENGTH TEMPORARY TABLES +# ON DISK +# +CREATE TABLE t1 ( +c1 INT AUTO_INCREMENT PRIMARY KEY, +c2 VARCHAR(250) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1(c2) VALUES ('b'),('b'); +INSERT INTO t1(c2) SELECT t1.c2 FROM t1, t1 t2, t1 t3, t1 t4, t1 t5, t1 t6; +SET @@max_heap_table_size=1; +Warnings: +Warning 1292 Truncated incorrect max_heap_table_size value: '1' +SET @@group_concat_max_len= 500; +SET SESSION internal_tmp_mem_storage_engine='memory'; +SELECT c1,GROUP_CONCAT(c2) cc FROM +(SELECT * FROM t1 UNION SELECT c1, 'a' FROM t1) tt +GROUP BY c1 +ORDER BY cc; +c1 cc +1 a,b +10 a,b +11 a,b +12 a,b +13 a,b +14 a,b +15 a,b +16 a,b +17 a,b +18 a,b +19 a,b +2 a,b +20 a,b +21 a,b +22 a,b +23 a,b +24 a,b +25 a,b +26 a,b +27 a,b +28 a,b +29 a,b +3 a,b +30 a,b +31 a,b +32 a,b +33 a,b +34 a,b +35 a,b +36 a,b +37 a,b +38 a,b +39 a,b +4 a,b +40 a,b +41 a,b +42 a,b +43 a,b +44 a,b +45 a,b +46 a,b +47 a,b +48 a,b +49 a,b +5 a,b +50 a,b +51 a,b +52 a,b +53 a,b +54 a,b +55 a,b +56 a,b +57 a,b +58 a,b +59 a,b +6 a,b +60 a,b +61 a,b +62 a,b +63 a,b +64 a,b +65 a,b +66 a,b +7 a,b +8 a,b +9 a,b +SELECT * FROM information_schema.OPTIMIZER_TRACE; +QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES +SELECT c1,GROUP_CONCAT(c2) cc FROM +(SELECT * FROM t1 UNION SELECT c1, 'a' FROM t1) tt +GROUP BY c1 +ORDER BY cc { + "steps": [ + { + "join_preparation": { + "select#": 1, + "steps": [ + { + "join_preparation": { + "select#": 2, + "steps": [ + { + "expanded_query": "/* select#2 */ select `t1`.`c1` AS `c1`,`t1`.`c2` AS `c2` from `t1`" + } + ] /* steps */ + } /* join_preparation */ + }, + { + "join_preparation": { + "select#": 3, + "steps": [ + { + "expanded_query": "/* select#3 */ select `t1`.`c1` AS `c1`,'a' AS `a` from `t1`" + } + ] /* steps */ + } /* join_preparation */ + }, + { + "creating_tmp_table": { + "tmp_table_info": { + "table": "intermediate_tmp_table", + "columns": 2, + "row_length": 757, + "key_length": 757, + "unique_constraint": false, + "makes_grouped_rows": false, + "cannot_insert_duplicates": true, + "location": "memory (heap)", + "row_limit_estimate": 1 + } /* tmp_table_info */ + } /* creating_tmp_table */ + }, + { + "join_preparation": { + "select#": "fake", + "steps": [ + { + "expanded_query": "/* select#fake */ select `c1` AS `c1`,`c2` AS `c2` from dual" + } + ] /* steps */ + } /* join_preparation */ + }, + { + "derived": { + "table": " `tt`", + "select#": 2, + "materialized": true + } /* derived */ + }, + { + "expanded_query": "/* select#1 */ select `tt`.`c1` AS `c1`,group_concat(`tt`.`c2` separator ',') AS `cc` from (/* select#2 */ select `t1`.`c1` AS `c1`,`t1`.`c2` AS `c2` from `t1` union /* select#3 */ select `t1`.`c1` AS `c1`,'a' AS `a` from `t1`) `tt` group by `tt`.`c1` order by `cc`" + } + ] /* steps */ + } /* join_preparation */ + }, + { + "join_optimization": { + "select#": 1, + "steps": [ + { + "join_optimization": { + "select#": 2, + "steps": [ + { + "table_dependencies": [ + { + "table": "`t1`", + "row_may_be_null": false, + "map_bit": 0, + "depends_on_map_bits": [ + ] /* depends_on_map_bits */ + } + ] /* table_dependencies */ + }, + { + "rows_estimation": [ + { + "table": "`t1`", + "table_scan": { + "rows": 66, + "cost": 0.25 + } /* table_scan */ + } + ] /* rows_estimation */ + }, + { + "considered_execution_plans": [ + { + "plan_prefix": [ + ] /* plan_prefix */, + "table": "`t1`", + "best_access_path": { + "considered_access_paths": [ + { + "rows_to_scan": 66, + "access_type": "scan", + "resulting_rows": 66, + "cost": 6.85, + "chosen": true + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 100, + "rows_for_plan": 66, + "cost_for_plan": 6.85, + "chosen": true + } + ] /* considered_execution_plans */ + }, + { + "attaching_conditions_to_tables": { + "original_condition": null, + "attached_conditions_computation": [ + ] /* attached_conditions_computation */, + "attached_conditions_summary": [ + { + "table": "`t1`", + "attached": null + } + ] /* attached_conditions_summary */ + } /* attaching_conditions_to_tables */ + }, + { + "finalizing_table_conditions": [ + ] /* finalizing_table_conditions */ + }, + { + "refine_plan": [ + { + "table": "`t1`" + } + ] /* refine_plan */ + } + ] /* steps */ + } /* join_optimization */ + }, + { + "join_optimization": { + "select#": 3, + "steps": [ + { + "table_dependencies": [ + { + "table": "`t1`", + "row_may_be_null": false, + "map_bit": 0, + "depends_on_map_bits": [ + ] /* depends_on_map_bits */ + } + ] /* table_dependencies */ + }, + { + "rows_estimation": [ + { + "table": "`t1`", + "table_scan": { + "rows": 66, + "cost": 0.25 + } /* table_scan */ + } + ] /* rows_estimation */ + }, + { + "considered_execution_plans": [ + { + "plan_prefix": [ + ] /* plan_prefix */, + "table": "`t1`", + "best_access_path": { + "considered_access_paths": [ + { + "rows_to_scan": 66, + "access_type": "scan", + "resulting_rows": 66, + "cost": 6.85, + "chosen": true + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 100, + "rows_for_plan": 66, + "cost_for_plan": 6.85, + "chosen": true + } + ] /* considered_execution_plans */ + }, + { + "attaching_conditions_to_tables": { + "original_condition": null, + "attached_conditions_computation": [ + ] /* attached_conditions_computation */, + "attached_conditions_summary": [ + { + "table": "`t1`", + "attached": null + } + ] /* attached_conditions_summary */ + } /* attaching_conditions_to_tables */ + }, + { + "finalizing_table_conditions": [ + ] /* finalizing_table_conditions */ + }, + { + "refine_plan": [ + { + "table": "`t1`" + } + ] /* refine_plan */ + } + ] /* steps */ + } /* join_optimization */ + }, + { + "join_optimization": { + "select#": "fake", + "steps": [ + { + "table_dependencies": [ + { + "table": "``", + "row_may_be_null": false, + "map_bit": 0, + "depends_on_map_bits": [ + ] /* depends_on_map_bits */ + } + ] /* table_dependencies */ + }, + { + "rows_estimation": [ + { + "table": "``", + "table_scan": { + "rows": 0, + "cost": 2.5 + } /* table_scan */ + } + ] /* rows_estimation */ + }, + { + "considered_execution_plans": [ + { + "plan_prefix": [ + ] /* plan_prefix */, + "table": "``", + "best_access_path": { + "considered_access_paths": [ + { + "rows_to_scan": 0, + "access_type": "scan", + "resulting_rows": 0, + "cost": 2.5, + "chosen": true + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 100, + "rows_for_plan": 0, + "cost_for_plan": 2.5, + "chosen": true + } + ] /* considered_execution_plans */ + }, + { + "attaching_conditions_to_tables": { + "original_condition": null, + "attached_conditions_computation": [ + ] /* attached_conditions_computation */, + "attached_conditions_summary": [ + { + "table": "``", + "attached": null + } + ] /* attached_conditions_summary */ + } /* attaching_conditions_to_tables */ + }, + { + "finalizing_table_conditions": [ + ] /* finalizing_table_conditions */ + }, + { + "refine_plan": [ + { + "table": "``" + } + ] /* refine_plan */ + } + ] /* steps */ + } /* join_optimization */ + }, + { + "substitute_generated_columns": { + } /* substitute_generated_columns */ + }, + { + "table_dependencies": [ + { + "table": " `tt`", + "row_may_be_null": false, + "map_bit": 0, + "depends_on_map_bits": [ + ] /* depends_on_map_bits */ + } + ] /* table_dependencies */ + }, + { + "rows_estimation": [ + { + "table": " `tt`", + "table_scan": { + "rows": 132, + "cost": 4.15 + } /* table_scan */ + } + ] /* rows_estimation */ + }, + { + "considered_execution_plans": [ + { + "plan_prefix": [ + ] /* plan_prefix */, + "table": " `tt`", + "best_access_path": { + "considered_access_paths": [ + { + "rows_to_scan": 132, + "access_type": "scan", + "resulting_rows": 132, + "cost": 17.35, + "chosen": true + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 100, + "rows_for_plan": 132, + "cost_for_plan": 17.35, + "chosen": true + } + ] /* considered_execution_plans */ + }, + { + "attaching_conditions_to_tables": { + "original_condition": null, + "attached_conditions_computation": [ + ] /* attached_conditions_computation */, + "attached_conditions_summary": [ + { + "table": " `tt`", + "attached": null + } + ] /* attached_conditions_summary */ + } /* attaching_conditions_to_tables */ + }, + { + "optimizing_distinct_group_by_order_by": { + "simplifying_order_by": { + "original_clause": "`cc`", + "items": [ + { + "item": "group_concat(`tt`.`c2` separator ',')" + } + ] /* items */, + "resulting_clause_is_simple": false, + "resulting_clause": "`cc`" + } /* simplifying_order_by */, + "simplifying_group_by": { + "original_clause": "`tt`.`c1`", + "items": [ + { + "item": "`tt`.`c1`" + } + ] /* items */, + "resulting_clause_is_simple": true, + "resulting_clause": "`tt`.`c1`" + } /* simplifying_group_by */ + } /* optimizing_distinct_group_by_order_by */ + }, + { + "finalizing_table_conditions": [ + ] /* finalizing_table_conditions */ + }, + { + "refine_plan": [ + { + "table": " `tt`" + } + ] /* refine_plan */ + }, + { + "considering_tmp_tables": [ + { + "adding_tmp_table_in_plan_at_position": 1, + "filesort": { + "adding_sort_to_table": "tt" + } /* filesort */, + "unknown_key_1": { + "creating_tmp_table": { + "tmp_table_info": { + "table": "intermediate_tmp_table", + "columns": 1, + "row_length": 753, + "key_length": 0, + "unique_constraint": false, + "makes_grouped_rows": false, + "cannot_insert_duplicates": false, + "location": "memory (heap)", + "row_limit_estimate": 1 + } /* tmp_table_info */ + } /* creating_tmp_table */ + }, + "write_method": "write_group_row_when_complete" + }, + { + "adding_sort_to_table": "" + } /* filesort */ + ] /* considering_tmp_tables */ + } + ] /* steps */ + } /* join_optimization */ + }, + { + "join_execution": { + "select#": 1, + "steps": [ + { + "creating_tmp_table": { + "tmp_table_info": { + "table": " `tt`", + "in_plan_at_position": 0, + "columns": 2, + "row_length": 757, + "key_length": 757, + "unique_constraint": false, + "makes_grouped_rows": false, + "cannot_insert_duplicates": true, + "location": "memory (heap)", + "row_limit_estimate": 1 + } /* tmp_table_info */ + } /* creating_tmp_table */ + }, + { + "materialize": { + "select#": 2, + "steps": [ + { + "converting_tmp_table_to_ondisk": { + "cause": "memory_table_size_exceeded", + "tmp_table_info": { + "table": " `tt`", + "in_plan_at_position": 0, + "columns": 2, + "row_length": 757, + "key_length": 757, + "unique_constraint": false, + "makes_grouped_rows": false, + "cannot_insert_duplicates": true, + "location": "disk (TMP_TABLE_ENGINE)", + "record_format": "packed" + } /* tmp_table_info */ + } /* converting_tmp_table_to_ondisk */ + } + ] /* steps */ + } /* materialize */ + }, + { + "materialize": { + "select#": 3, + "steps": [ + ] /* steps */ + } /* materialize */ + }, + { + "sorting_table": "tt", + "filesort_information": [ + { + "direction": "asc", + "expression": "`tt`.`c1`" + } + ] /* filesort_information */, + "filesort_priority_queue_optimization": { + "usable": false, + "cause": "not applicable (no LIMIT)" + } /* filesort_priority_queue_optimization */, + "filesort_execution": [ + ] /* filesort_execution */, + "filesort_summary": { + "memory_available": 262144, + "key_size": 8, + "row_size": 769, + "max_rows_per_buffer": 132, + "num_rows_estimate": 132, + "num_rows_found": 132, + "num_initial_chunks_spilled_to_disk": 0, + "peak_memory_used": "NNN", + "sort_algorithm": "std::stable_sort", + "sort_mode": "" + } /* filesort_summary */ + }, + { + "sorting_table": "", + "filesort_information": [ + { + "direction": "asc", + "expression": "`cc`" + } + ] /* filesort_information */, + "filesort_priority_queue_optimization": { + "usable": false, + "cause": "not applicable (no LIMIT)" + } /* filesort_priority_queue_optimization */, + "filesort_execution": [ + ] /* filesort_execution */, + "filesort_summary": { + "memory_available": 262144, + "key_size": 1001, + "row_size": 2512, + "max_rows_per_buffer": 104, + "num_rows_estimate": 18446744073709551615, + "num_rows_found": 66, + "num_initial_chunks_spilled_to_disk": 0, + "peak_memory_used": "NNN", + "sort_algorithm": "std::sort", + "sort_mode": "" + } /* filesort_summary */ + } + ] /* steps */ + } /* join_execution */ + } + ] /* steps */ +} 0 0 +DROP TABLE t1; +# +SET SESSION internal_tmp_mem_storage_engine=default; +# +# Bug #30773218 ASSERTION IN SQL_TMP_TABLE.CC::TRACE_TMP_TABLE +# +CREATE TABLE t1(name VARCHAR(64), type TEXT); +INSERT INTO t1(name, type) VALUES +('t1', 'table'), +('t2', 'table'), +('t3', 'table'), +('t4', 'table'), +('t5', 'table'), +('t6', 'table'), +('t7', 'table'), +('t8', 'table'), +('t9', 'table'), +('t10', 'table'), +('t11', 'table'); +CREATE TABLE t2(name VARCHAR(64), data TEXT); +INSERT INTO t2(name, data) VALUES +('t1', 'data'), +('t2', 'data'), +('t3', 'data'), +('t4', 'data'), +('t5', 'data'), +('t6', 'data'), +('t7', 'data'), +('t8', 'data'); +SET SESSION internal_tmp_mem_storage_engine=MEMORY; +SET @@session.optimizer_trace='enabled=on'; +SET @@session.tmp_table_size = 1024; +SET @@optimizer_switch='semijoin=off'; +SELECT name, data FROM t2 WHERE name IN +( SELECT name FROM t1 WHERE type='table'); +name data +t1 data +t2 data +t3 data +t4 data +t5 data +t6 data +t7 data +t8 data +DROP TABLE t1, t2; +SET SESSION internal_tmp_mem_storage_engine=default; +SET @@session.optimizer_trace='enabled=default'; +SET @@session.tmp_table_size = default; +SET @@optimizer_switch='semijoin=default'; diff --git a/mysql-test/suite/test_sql_complex.result-pq b/mysql-test/suite/test_sql_complex.result-pq new file mode 100644 index 000000000000..d4b2b12ec19d --- /dev/null +++ b/mysql-test/suite/test_sql_complex.result-pq @@ -0,0 +1,6424 @@ +------ Run plugin ------------------------------------------------ +INSTALL PLUGIN test_sql_complex SONAME 'TEST_SQL_COMPLEX'; +------ Stop plugin ----------------------------------------------- +UNINSTALL PLUGIN test_sql_complex; +------ plugin log ------------------------------------------------ +======================================================================== +Test in a server thread +[srv_session_open] +------------------------------------------------------------------ +EXECUTING:[35][SELECT 'first complex command' as a] +[CS_TEXT_REPRESENTATION] + [meta] rows: 1 + [meta] cols: 1 + [meta] server status: 2 + [meta] server status: AUTOCOMMIT + [meta] warning count: 0 + + [meta][field] db name: + [meta][field] table name: + [meta][field] org table name: + [meta][field] col name: a + [meta][field] org col name: + [meta][field] length: 63 + [meta][field] charsetnr: 33 + [meta][field] flags: 1 (NOT_NULL ) + [meta][field] decimals: 31 + [meta][field] type: VARCHAR (15) + + + [meta][charset result] number: 33 + [meta][charset result] name: utf8mb3 + [meta][charset result] collation: utf8_general_ci + [meta][charset result] sort order: + + [data][.a][ 21][first complex command] + + [end] server status: 2 + [end] server status: AUTOCOMMIT + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +[CS_BINARY_REPRESENTATION] + [meta] rows: 1 + [meta] cols: 1 + [meta] server status: 2 + [meta] server status: AUTOCOMMIT + [meta] warning count: 0 + + [meta][field] db name: + [meta][field] table name: + [meta][field] org table name: + [meta][field] col name: a + [meta][field] org col name: + [meta][field] length: 63 + [meta][field] charsetnr: 33 + [meta][field] flags: 1 (NOT_NULL ) + [meta][field] decimals: 31 + [meta][field] type: VARCHAR (15) + + + [meta][charset result] number: 33 + [meta][charset result] name: utf8mb3 + [meta][charset result] collation: utf8_general_ci + [meta][charset result] sort order: + + [data][.a][ 21][first complex command] + + [end] server status: 2 + [end] server status: AUTOCOMMIT + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +------------------------------------------------------------------ +EXECUTING:[21][CREATE DATABASE test1] +[CS_TEXT_REPRESENTATION] + [meta] rows: 0 + [meta] cols: 0 + [meta] server status: 0 + [meta] server status: + [meta] warning count: 0 + + [meta] no columns + + [meta] no charset + + [data] no rows + + [end] server status: 2 + [end] server status: AUTOCOMMIT + [end] warning count: 0 + [end] affected rows: 1 + [end] last insert id: 0 + [end] message: +------------------------------------------------------------------ +EXECUTING:[8][USE test] +[CS_TEXT_REPRESENTATION] + [meta] rows: 0 + [meta] cols: 0 + [meta] server status: 0 + [meta] server status: + [meta] warning count: 0 + + [meta] no columns + + [meta] no charset + + [data] no rows + + [end] server status: 2 + [end] server status: AUTOCOMMIT + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +------------------------------------------------------------------ +EXECUTING:[343][CREATE TABLE test_inserts( a INT UNSIGNED, b VARCHAR(100), c DOUBLE, d INT, e FLOAT,f DATETIME, g DATE, h TIME, i TINYINT, k TINYINT UNSIGNED,l SMALLINT, m SMALLINT UNSIGNED, n MEDIUMINT, o MEDIUMINT UNSIGNED,p INTEGER, q INTEGER UNSIGNED, r BIGINT, s BIGINT UNSIGNED,t YEAR, u DECIMAL(5,2) UNSIGNED, v DECIMAL(5,2), PRIMARY KEY(a), INDEX(d));] +[CS_TEXT_REPRESENTATION] + [meta] rows: 0 + [meta] cols: 0 + [meta] server status: 0 + [meta] server status: + [meta] warning count: 0 + + [meta] no columns + + [meta] no charset + + [data] no rows + + [end] server status: 2 + [end] server status: AUTOCOMMIT + [end] warning count: 1 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +------------------------------------------------------------------ +EXECUTING:[244][INSERT INTO test_inserts VALUES (1, 'one', 1.23, -1, 11.2323, '2014-07-06 07:06:05', '1980-02-19', '-830:12:23', 127, 255, 32767, 65535, 8388607, 16777215, 2147483647, 4294967295, 9223372036854775807, 18446744073709551615,1901, 999.99, -999.99)] +[CS_TEXT_REPRESENTATION] + [meta] rows: 0 + [meta] cols: 0 + [meta] server status: 0 + [meta] server status: + [meta] warning count: 0 + + [meta] no columns + + [meta] no charset + + [data] no rows + + [end] server status: 2 + [end] server status: AUTOCOMMIT + [end] warning count: 0 + [end] affected rows: 1 + [end] last insert id: 0 + [end] message: +------------------------------------------------------------------ +EXECUTING:[236][INSERT INTO test_inserts VALUES (2, 'two', 2.34, -2, 22.3434, '2015-07-06 21:22:23', '2014-06-05', '356:22:33', -128, 0, -32768, 32768, -8388608, 8388607, -2147483648, 0, -9223372036854775808, 18446744073709551615,2039, 123.45, -543.21)] +[CS_TEXT_REPRESENTATION] + [meta] rows: 0 + [meta] cols: 0 + [meta] server status: 0 + [meta] server status: + [meta] warning count: 0 + + [meta] no columns + + [meta] no charset + + [data] no rows + + [end] server status: 2 + [end] server status: AUTOCOMMIT + [end] warning count: 0 + [end] affected rows: 1 + [end] last insert id: 0 + [end] message: +------------------------------------------------------------------ +EXECUTING:[179][INSERT INTO test_inserts VALUES (3, 'three',3.45,-3, 33.4545, '2016-09-12 11:12:13', '2013-05-04', '821:33:44', -1, 128, -1, 65534, -1, 16777214, 1, 2, 3, 4,2155, 222.22, -567.89)] +[CS_TEXT_REPRESENTATION] + [meta] rows: 0 + [meta] cols: 0 + [meta] server status: 0 + [meta] server status: + [meta] warning count: 0 + + [meta] no columns + + [meta] no charset + + [data] no rows + + [end] server status: 2 + [end] server status: AUTOCOMMIT + [end] warning count: 0 + [end] affected rows: 1 + [end] last insert id: 0 + [end] message: +------------------------------------------------------------------ +EXECUTING:[43][SELECT * FROM test1.test_inserts ORDER BY a] +[CS_TEXT_REPRESENTATION] + [meta] rows: 3 + [meta] cols: 21 + [meta] server status: 2 + [meta] server status: AUTOCOMMIT + [meta] warning count: 0 + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: a + [meta][field] org col name: a + [meta][field] length: 10 + [meta][field] charsetnr: 8 + [meta][field] flags: 4129 (NOT_NULL UNSIGNED NO_DEFAULT_VALUE ) + [meta][field] decimals: 0 + [meta][field] type: LONG (3) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: b + [meta][field] org col name: b + [meta][field] length: 400 + [meta][field] charsetnr: 255 + [meta][field] flags: 0 + [meta][field] decimals: 0 + [meta][field] type: VARCHAR (15) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: c + [meta][field] org col name: c + [meta][field] length: 22 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 31 + [meta][field] type: DOUBLE (5) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: d + [meta][field] org col name: d + [meta][field] length: 11 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 0 + [meta][field] type: LONG (3) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: e + [meta][field] org col name: e + [meta][field] length: 12 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 31 + [meta][field] type: FLOAT (4) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: f + [meta][field] org col name: f + [meta][field] length: 19 + [meta][field] charsetnr: 8 + [meta][field] flags: 128 (BINARY ) + [meta][field] decimals: 0 + [meta][field] type: DATETIME (12) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: g + [meta][field] org col name: g + [meta][field] length: 10 + [meta][field] charsetnr: 8 + [meta][field] flags: 128 (BINARY ) + [meta][field] decimals: 0 + [meta][field] type: DATE (10) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: h + [meta][field] org col name: h + [meta][field] length: 10 + [meta][field] charsetnr: 8 + [meta][field] flags: 128 (BINARY ) + [meta][field] decimals: 0 + [meta][field] type: TIME (11) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: i + [meta][field] org col name: i + [meta][field] length: 4 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 0 + [meta][field] type: TINY (1) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: k + [meta][field] org col name: k + [meta][field] length: 3 + [meta][field] charsetnr: 8 + [meta][field] flags: 32 (UNSIGNED ) + [meta][field] decimals: 0 + [meta][field] type: TINY (1) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: l + [meta][field] org col name: l + [meta][field] length: 6 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 0 + [meta][field] type: SHORT (2) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: m + [meta][field] org col name: m + [meta][field] length: 5 + [meta][field] charsetnr: 8 + [meta][field] flags: 32 (UNSIGNED ) + [meta][field] decimals: 0 + [meta][field] type: SHORT (2) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: n + [meta][field] org col name: n + [meta][field] length: 9 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 0 + [meta][field] type: INT24 (9) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: o + [meta][field] org col name: o + [meta][field] length: 8 + [meta][field] charsetnr: 8 + [meta][field] flags: 32 (UNSIGNED ) + [meta][field] decimals: 0 + [meta][field] type: INT24 (9) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: p + [meta][field] org col name: p + [meta][field] length: 11 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 0 + [meta][field] type: LONG (3) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: q + [meta][field] org col name: q + [meta][field] length: 10 + [meta][field] charsetnr: 8 + [meta][field] flags: 32 (UNSIGNED ) + [meta][field] decimals: 0 + [meta][field] type: LONG (3) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: r + [meta][field] org col name: r + [meta][field] length: 20 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 0 + [meta][field] type: LONGLONG (8) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: s + [meta][field] org col name: s + [meta][field] length: 20 + [meta][field] charsetnr: 8 + [meta][field] flags: 32 (UNSIGNED ) + [meta][field] decimals: 0 + [meta][field] type: LONGLONG (8) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: t + [meta][field] org col name: t + [meta][field] length: 4 + [meta][field] charsetnr: 8 + [meta][field] flags: 96 (UNSIGNED ZEROFILL ) + [meta][field] decimals: 0 + [meta][field] type: YEAR (13) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: u + [meta][field] org col name: u + [meta][field] length: 6 + [meta][field] charsetnr: 8 + [meta][field] flags: 32 (UNSIGNED ) + [meta][field] decimals: 2 + [meta][field] type: NEWDECIMAL (246) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: v + [meta][field] org col name: v + [meta][field] length: 7 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 2 + [meta][field] type: NEWDECIMAL (246) + + + [meta][charset result] number: 33 + [meta][charset result] name: utf8mb3 + [meta][charset result] collation: utf8_general_ci + [meta][charset result] sort order: + + [data][test_inserts.a][ 1][1] + [data][test_inserts.b][ 3][one] + [data][test_inserts.c][ 4][1.23] + [data][test_inserts.d][ 2][-1] + [data][test_inserts.e][ 7][11.2323] + [data][test_inserts.f][ 19][2014-07-06 07:06:05] + [data][test_inserts.g][ 10][1980-02-19] + [data][test_inserts.h][ 10][-830:12:23] + [data][test_inserts.i][ 3][127] + [data][test_inserts.k][ 3][255] + [data][test_inserts.l][ 5][32767] + [data][test_inserts.m][ 5][65535] + [data][test_inserts.n][ 7][8388607] + [data][test_inserts.o][ 8][16777215] + [data][test_inserts.p][ 10][2147483647] + [data][test_inserts.q][ 10][4294967295] + [data][test_inserts.r][ 19][9223372036854775807] + [data][test_inserts.s][ 20][18446744073709551615] + [data][test_inserts.t][ 4][1901] + [data][test_inserts.u][ 6][999.99] + [data][test_inserts.v][ 7][-999.99] + + [data][test_inserts.a][ 1][2] + [data][test_inserts.b][ 3][two] + [data][test_inserts.c][ 4][2.34] + [data][test_inserts.d][ 2][-2] + [data][test_inserts.e][ 7][22.3434] + [data][test_inserts.f][ 19][2015-07-06 21:22:23] + [data][test_inserts.g][ 10][2014-06-05] + [data][test_inserts.h][ 9][356:22:33] + [data][test_inserts.i][ 4][-128] + [data][test_inserts.k][ 1][0] + [data][test_inserts.l][ 6][-32768] + [data][test_inserts.m][ 5][32768] + [data][test_inserts.n][ 8][-8388608] + [data][test_inserts.o][ 7][8388607] + [data][test_inserts.p][ 11][-2147483648] + [data][test_inserts.q][ 1][0] + [data][test_inserts.r][ 20][-9223372036854775808] + [data][test_inserts.s][ 20][18446744073709551615] + [data][test_inserts.t][ 4][2039] + [data][test_inserts.u][ 6][123.45] + [data][test_inserts.v][ 7][-543.21] + + [data][test_inserts.a][ 1][3] + [data][test_inserts.b][ 5][three] + [data][test_inserts.c][ 4][3.45] + [data][test_inserts.d][ 2][-3] + [data][test_inserts.e][ 7][33.4545] + [data][test_inserts.f][ 19][2016-09-12 11:12:13] + [data][test_inserts.g][ 10][2013-05-04] + [data][test_inserts.h][ 9][821:33:44] + [data][test_inserts.i][ 2][-1] + [data][test_inserts.k][ 3][128] + [data][test_inserts.l][ 2][-1] + [data][test_inserts.m][ 5][65534] + [data][test_inserts.n][ 2][-1] + [data][test_inserts.o][ 8][16777214] + [data][test_inserts.p][ 1][1] + [data][test_inserts.q][ 1][2] + [data][test_inserts.r][ 1][3] + [data][test_inserts.s][ 1][4] + [data][test_inserts.t][ 4][2155] + [data][test_inserts.u][ 6][222.22] + [data][test_inserts.v][ 7][-567.89] + + [end] server status: 2 + [end] server status: AUTOCOMMIT + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +[CS_BINARY_REPRESENTATION] + [meta] rows: 3 + [meta] cols: 21 + [meta] server status: 2 + [meta] server status: AUTOCOMMIT + [meta] warning count: 0 + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: a + [meta][field] org col name: a + [meta][field] length: 10 + [meta][field] charsetnr: 8 + [meta][field] flags: 4129 (NOT_NULL UNSIGNED NO_DEFAULT_VALUE ) + [meta][field] decimals: 0 + [meta][field] type: LONG (3) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: b + [meta][field] org col name: b + [meta][field] length: 400 + [meta][field] charsetnr: 255 + [meta][field] flags: 0 + [meta][field] decimals: 0 + [meta][field] type: VARCHAR (15) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: c + [meta][field] org col name: c + [meta][field] length: 22 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 31 + [meta][field] type: DOUBLE (5) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: d + [meta][field] org col name: d + [meta][field] length: 11 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 0 + [meta][field] type: LONG (3) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: e + [meta][field] org col name: e + [meta][field] length: 12 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 31 + [meta][field] type: FLOAT (4) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: f + [meta][field] org col name: f + [meta][field] length: 19 + [meta][field] charsetnr: 8 + [meta][field] flags: 128 (BINARY ) + [meta][field] decimals: 0 + [meta][field] type: DATETIME (12) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: g + [meta][field] org col name: g + [meta][field] length: 10 + [meta][field] charsetnr: 8 + [meta][field] flags: 128 (BINARY ) + [meta][field] decimals: 0 + [meta][field] type: DATE (10) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: h + [meta][field] org col name: h + [meta][field] length: 10 + [meta][field] charsetnr: 8 + [meta][field] flags: 128 (BINARY ) + [meta][field] decimals: 0 + [meta][field] type: TIME (11) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: i + [meta][field] org col name: i + [meta][field] length: 4 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 0 + [meta][field] type: TINY (1) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: k + [meta][field] org col name: k + [meta][field] length: 3 + [meta][field] charsetnr: 8 + [meta][field] flags: 32 (UNSIGNED ) + [meta][field] decimals: 0 + [meta][field] type: TINY (1) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: l + [meta][field] org col name: l + [meta][field] length: 6 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 0 + [meta][field] type: SHORT (2) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: m + [meta][field] org col name: m + [meta][field] length: 5 + [meta][field] charsetnr: 8 + [meta][field] flags: 32 (UNSIGNED ) + [meta][field] decimals: 0 + [meta][field] type: SHORT (2) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: n + [meta][field] org col name: n + [meta][field] length: 9 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 0 + [meta][field] type: INT24 (9) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: o + [meta][field] org col name: o + [meta][field] length: 8 + [meta][field] charsetnr: 8 + [meta][field] flags: 32 (UNSIGNED ) + [meta][field] decimals: 0 + [meta][field] type: INT24 (9) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: p + [meta][field] org col name: p + [meta][field] length: 11 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 0 + [meta][field] type: LONG (3) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: q + [meta][field] org col name: q + [meta][field] length: 10 + [meta][field] charsetnr: 8 + [meta][field] flags: 32 (UNSIGNED ) + [meta][field] decimals: 0 + [meta][field] type: LONG (3) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: r + [meta][field] org col name: r + [meta][field] length: 20 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 0 + [meta][field] type: LONGLONG (8) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: s + [meta][field] org col name: s + [meta][field] length: 20 + [meta][field] charsetnr: 8 + [meta][field] flags: 32 (UNSIGNED ) + [meta][field] decimals: 0 + [meta][field] type: LONGLONG (8) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: t + [meta][field] org col name: t + [meta][field] length: 4 + [meta][field] charsetnr: 8 + [meta][field] flags: 96 (UNSIGNED ZEROFILL ) + [meta][field] decimals: 0 + [meta][field] type: YEAR (13) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: u + [meta][field] org col name: u + [meta][field] length: 6 + [meta][field] charsetnr: 8 + [meta][field] flags: 32 (UNSIGNED ) + [meta][field] decimals: 2 + [meta][field] type: NEWDECIMAL (246) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: v + [meta][field] org col name: v + [meta][field] length: 7 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 2 + [meta][field] type: NEWDECIMAL (246) + + + [meta][charset result] number: 33 + [meta][charset result] name: utf8mb3 + [meta][charset result] collation: utf8_general_ci + [meta][charset result] sort order: + + [data][test_inserts.a][ 1][1] + [data][test_inserts.b][ 3][one] + [data][test_inserts.c][ 4][1.23] + [data][test_inserts.d][ 2][-1] + [data][test_inserts.e][ 7][11.2323] + [data][test_inserts.f][ 19][2014-07-06 07:06:05] + [data][test_inserts.g][ 10][1980-02-19] + [data][test_inserts.h][ 10][-830:12:23] + [data][test_inserts.i][ 3][127] + [data][test_inserts.k][ 3][255] + [data][test_inserts.l][ 5][32767] + [data][test_inserts.m][ 5][65535] + [data][test_inserts.n][ 7][8388607] + [data][test_inserts.o][ 8][16777215] + [data][test_inserts.p][ 10][2147483647] + [data][test_inserts.q][ 10][4294967295] + [data][test_inserts.r][ 19][9223372036854775807] + [data][test_inserts.s][ 20][18446744073709551615] + [data][test_inserts.t][ 4][1901] + [data][test_inserts.u][ 6][999.99] + [data][test_inserts.v][ 7][-999.99] + + [data][test_inserts.a][ 1][2] + [data][test_inserts.b][ 3][two] + [data][test_inserts.c][ 4][2.34] + [data][test_inserts.d][ 2][-2] + [data][test_inserts.e][ 7][22.3434] + [data][test_inserts.f][ 19][2015-07-06 21:22:23] + [data][test_inserts.g][ 10][2014-06-05] + [data][test_inserts.h][ 9][356:22:33] + [data][test_inserts.i][ 4][-128] + [data][test_inserts.k][ 1][0] + [data][test_inserts.l][ 6][-32768] + [data][test_inserts.m][ 5][32768] + [data][test_inserts.n][ 8][-8388608] + [data][test_inserts.o][ 7][8388607] + [data][test_inserts.p][ 11][-2147483648] + [data][test_inserts.q][ 1][0] + [data][test_inserts.r][ 20][-9223372036854775808] + [data][test_inserts.s][ 20][18446744073709551615] + [data][test_inserts.t][ 4][2039] + [data][test_inserts.u][ 6][123.45] + [data][test_inserts.v][ 7][-543.21] + + [data][test_inserts.a][ 1][3] + [data][test_inserts.b][ 5][three] + [data][test_inserts.c][ 4][3.45] + [data][test_inserts.d][ 2][-3] + [data][test_inserts.e][ 7][33.4545] + [data][test_inserts.f][ 19][2016-09-12 11:12:13] + [data][test_inserts.g][ 10][2013-05-04] + [data][test_inserts.h][ 9][821:33:44] + [data][test_inserts.i][ 2][-1] + [data][test_inserts.k][ 3][128] + [data][test_inserts.l][ 2][-1] + [data][test_inserts.m][ 5][65534] + [data][test_inserts.n][ 2][-1] + [data][test_inserts.o][ 8][16777214] + [data][test_inserts.p][ 1][1] + [data][test_inserts.q][ 1][2] + [data][test_inserts.r][ 1][3] + [data][test_inserts.s][ 1][4] + [data][test_inserts.t][ 4][2155] + [data][test_inserts.u][ 6][222.22] + [data][test_inserts.v][ 7][-567.89] + + [end] server status: 2 + [end] server status: AUTOCOMMIT + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +------------------------------------------------------------------ +EXECUTING:[34][DELETE FROM test_inserts WHERE a=2] +[CS_TEXT_REPRESENTATION] + [meta] rows: 0 + [meta] cols: 0 + [meta] server status: 0 + [meta] server status: + [meta] warning count: 0 + + [meta] no columns + + [meta] no charset + + [data] no rows + + [end] server status: 2 + [end] server status: AUTOCOMMIT + [end] warning count: 0 + [end] affected rows: 1 + [end] last insert id: 0 + [end] message: +------------------------------------------------------------------ +EXECUTING:[37][SELECT * FROM test_inserts ORDER BY a] +[CS_TEXT_REPRESENTATION] + [meta] rows: 2 + [meta] cols: 21 + [meta] server status: 2 + [meta] server status: AUTOCOMMIT + [meta] warning count: 0 + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: a + [meta][field] org col name: a + [meta][field] length: 10 + [meta][field] charsetnr: 8 + [meta][field] flags: 4129 (NOT_NULL UNSIGNED NO_DEFAULT_VALUE ) + [meta][field] decimals: 0 + [meta][field] type: LONG (3) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: b + [meta][field] org col name: b + [meta][field] length: 400 + [meta][field] charsetnr: 255 + [meta][field] flags: 0 + [meta][field] decimals: 0 + [meta][field] type: VARCHAR (15) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: c + [meta][field] org col name: c + [meta][field] length: 22 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 31 + [meta][field] type: DOUBLE (5) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: d + [meta][field] org col name: d + [meta][field] length: 11 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 0 + [meta][field] type: LONG (3) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: e + [meta][field] org col name: e + [meta][field] length: 12 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 31 + [meta][field] type: FLOAT (4) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: f + [meta][field] org col name: f + [meta][field] length: 19 + [meta][field] charsetnr: 8 + [meta][field] flags: 128 (BINARY ) + [meta][field] decimals: 0 + [meta][field] type: DATETIME (12) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: g + [meta][field] org col name: g + [meta][field] length: 10 + [meta][field] charsetnr: 8 + [meta][field] flags: 128 (BINARY ) + [meta][field] decimals: 0 + [meta][field] type: DATE (10) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: h + [meta][field] org col name: h + [meta][field] length: 10 + [meta][field] charsetnr: 8 + [meta][field] flags: 128 (BINARY ) + [meta][field] decimals: 0 + [meta][field] type: TIME (11) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: i + [meta][field] org col name: i + [meta][field] length: 4 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 0 + [meta][field] type: TINY (1) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: k + [meta][field] org col name: k + [meta][field] length: 3 + [meta][field] charsetnr: 8 + [meta][field] flags: 32 (UNSIGNED ) + [meta][field] decimals: 0 + [meta][field] type: TINY (1) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: l + [meta][field] org col name: l + [meta][field] length: 6 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 0 + [meta][field] type: SHORT (2) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: m + [meta][field] org col name: m + [meta][field] length: 5 + [meta][field] charsetnr: 8 + [meta][field] flags: 32 (UNSIGNED ) + [meta][field] decimals: 0 + [meta][field] type: SHORT (2) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: n + [meta][field] org col name: n + [meta][field] length: 9 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 0 + [meta][field] type: INT24 (9) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: o + [meta][field] org col name: o + [meta][field] length: 8 + [meta][field] charsetnr: 8 + [meta][field] flags: 32 (UNSIGNED ) + [meta][field] decimals: 0 + [meta][field] type: INT24 (9) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: p + [meta][field] org col name: p + [meta][field] length: 11 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 0 + [meta][field] type: LONG (3) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: q + [meta][field] org col name: q + [meta][field] length: 10 + [meta][field] charsetnr: 8 + [meta][field] flags: 32 (UNSIGNED ) + [meta][field] decimals: 0 + [meta][field] type: LONG (3) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: r + [meta][field] org col name: r + [meta][field] length: 20 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 0 + [meta][field] type: LONGLONG (8) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: s + [meta][field] org col name: s + [meta][field] length: 20 + [meta][field] charsetnr: 8 + [meta][field] flags: 32 (UNSIGNED ) + [meta][field] decimals: 0 + [meta][field] type: LONGLONG (8) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: t + [meta][field] org col name: t + [meta][field] length: 4 + [meta][field] charsetnr: 8 + [meta][field] flags: 96 (UNSIGNED ZEROFILL ) + [meta][field] decimals: 0 + [meta][field] type: YEAR (13) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: u + [meta][field] org col name: u + [meta][field] length: 6 + [meta][field] charsetnr: 8 + [meta][field] flags: 32 (UNSIGNED ) + [meta][field] decimals: 2 + [meta][field] type: NEWDECIMAL (246) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: v + [meta][field] org col name: v + [meta][field] length: 7 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 2 + [meta][field] type: NEWDECIMAL (246) + + + [meta][charset result] number: 33 + [meta][charset result] name: utf8mb3 + [meta][charset result] collation: utf8_general_ci + [meta][charset result] sort order: + + [data][test_inserts.a][ 1][1] + [data][test_inserts.b][ 3][one] + [data][test_inserts.c][ 4][1.23] + [data][test_inserts.d][ 2][-1] + [data][test_inserts.e][ 7][11.2323] + [data][test_inserts.f][ 19][2014-07-06 07:06:05] + [data][test_inserts.g][ 10][1980-02-19] + [data][test_inserts.h][ 10][-830:12:23] + [data][test_inserts.i][ 3][127] + [data][test_inserts.k][ 3][255] + [data][test_inserts.l][ 5][32767] + [data][test_inserts.m][ 5][65535] + [data][test_inserts.n][ 7][8388607] + [data][test_inserts.o][ 8][16777215] + [data][test_inserts.p][ 10][2147483647] + [data][test_inserts.q][ 10][4294967295] + [data][test_inserts.r][ 19][9223372036854775807] + [data][test_inserts.s][ 20][18446744073709551615] + [data][test_inserts.t][ 4][1901] + [data][test_inserts.u][ 6][999.99] + [data][test_inserts.v][ 7][-999.99] + + [data][test_inserts.a][ 1][3] + [data][test_inserts.b][ 5][three] + [data][test_inserts.c][ 4][3.45] + [data][test_inserts.d][ 2][-3] + [data][test_inserts.e][ 7][33.4545] + [data][test_inserts.f][ 19][2016-09-12 11:12:13] + [data][test_inserts.g][ 10][2013-05-04] + [data][test_inserts.h][ 9][821:33:44] + [data][test_inserts.i][ 2][-1] + [data][test_inserts.k][ 3][128] + [data][test_inserts.l][ 2][-1] + [data][test_inserts.m][ 5][65534] + [data][test_inserts.n][ 2][-1] + [data][test_inserts.o][ 8][16777214] + [data][test_inserts.p][ 1][1] + [data][test_inserts.q][ 1][2] + [data][test_inserts.r][ 1][3] + [data][test_inserts.s][ 1][4] + [data][test_inserts.t][ 4][2155] + [data][test_inserts.u][ 6][222.22] + [data][test_inserts.v][ 7][-567.89] + + [end] server status: 2 + [end] server status: AUTOCOMMIT + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +[CS_BINARY_REPRESENTATION] + [meta] rows: 2 + [meta] cols: 21 + [meta] server status: 2 + [meta] server status: AUTOCOMMIT + [meta] warning count: 0 + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: a + [meta][field] org col name: a + [meta][field] length: 10 + [meta][field] charsetnr: 8 + [meta][field] flags: 4129 (NOT_NULL UNSIGNED NO_DEFAULT_VALUE ) + [meta][field] decimals: 0 + [meta][field] type: LONG (3) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: b + [meta][field] org col name: b + [meta][field] length: 400 + [meta][field] charsetnr: 255 + [meta][field] flags: 0 + [meta][field] decimals: 0 + [meta][field] type: VARCHAR (15) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: c + [meta][field] org col name: c + [meta][field] length: 22 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 31 + [meta][field] type: DOUBLE (5) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: d + [meta][field] org col name: d + [meta][field] length: 11 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 0 + [meta][field] type: LONG (3) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: e + [meta][field] org col name: e + [meta][field] length: 12 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 31 + [meta][field] type: FLOAT (4) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: f + [meta][field] org col name: f + [meta][field] length: 19 + [meta][field] charsetnr: 8 + [meta][field] flags: 128 (BINARY ) + [meta][field] decimals: 0 + [meta][field] type: DATETIME (12) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: g + [meta][field] org col name: g + [meta][field] length: 10 + [meta][field] charsetnr: 8 + [meta][field] flags: 128 (BINARY ) + [meta][field] decimals: 0 + [meta][field] type: DATE (10) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: h + [meta][field] org col name: h + [meta][field] length: 10 + [meta][field] charsetnr: 8 + [meta][field] flags: 128 (BINARY ) + [meta][field] decimals: 0 + [meta][field] type: TIME (11) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: i + [meta][field] org col name: i + [meta][field] length: 4 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 0 + [meta][field] type: TINY (1) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: k + [meta][field] org col name: k + [meta][field] length: 3 + [meta][field] charsetnr: 8 + [meta][field] flags: 32 (UNSIGNED ) + [meta][field] decimals: 0 + [meta][field] type: TINY (1) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: l + [meta][field] org col name: l + [meta][field] length: 6 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 0 + [meta][field] type: SHORT (2) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: m + [meta][field] org col name: m + [meta][field] length: 5 + [meta][field] charsetnr: 8 + [meta][field] flags: 32 (UNSIGNED ) + [meta][field] decimals: 0 + [meta][field] type: SHORT (2) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: n + [meta][field] org col name: n + [meta][field] length: 9 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 0 + [meta][field] type: INT24 (9) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: o + [meta][field] org col name: o + [meta][field] length: 8 + [meta][field] charsetnr: 8 + [meta][field] flags: 32 (UNSIGNED ) + [meta][field] decimals: 0 + [meta][field] type: INT24 (9) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: p + [meta][field] org col name: p + [meta][field] length: 11 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 0 + [meta][field] type: LONG (3) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: q + [meta][field] org col name: q + [meta][field] length: 10 + [meta][field] charsetnr: 8 + [meta][field] flags: 32 (UNSIGNED ) + [meta][field] decimals: 0 + [meta][field] type: LONG (3) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: r + [meta][field] org col name: r + [meta][field] length: 20 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 0 + [meta][field] type: LONGLONG (8) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: s + [meta][field] org col name: s + [meta][field] length: 20 + [meta][field] charsetnr: 8 + [meta][field] flags: 32 (UNSIGNED ) + [meta][field] decimals: 0 + [meta][field] type: LONGLONG (8) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: t + [meta][field] org col name: t + [meta][field] length: 4 + [meta][field] charsetnr: 8 + [meta][field] flags: 96 (UNSIGNED ZEROFILL ) + [meta][field] decimals: 0 + [meta][field] type: YEAR (13) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: u + [meta][field] org col name: u + [meta][field] length: 6 + [meta][field] charsetnr: 8 + [meta][field] flags: 32 (UNSIGNED ) + [meta][field] decimals: 2 + [meta][field] type: NEWDECIMAL (246) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: v + [meta][field] org col name: v + [meta][field] length: 7 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 2 + [meta][field] type: NEWDECIMAL (246) + + + [meta][charset result] number: 33 + [meta][charset result] name: utf8mb3 + [meta][charset result] collation: utf8_general_ci + [meta][charset result] sort order: + + [data][test_inserts.a][ 1][1] + [data][test_inserts.b][ 3][one] + [data][test_inserts.c][ 4][1.23] + [data][test_inserts.d][ 2][-1] + [data][test_inserts.e][ 7][11.2323] + [data][test_inserts.f][ 19][2014-07-06 07:06:05] + [data][test_inserts.g][ 10][1980-02-19] + [data][test_inserts.h][ 10][-830:12:23] + [data][test_inserts.i][ 3][127] + [data][test_inserts.k][ 3][255] + [data][test_inserts.l][ 5][32767] + [data][test_inserts.m][ 5][65535] + [data][test_inserts.n][ 7][8388607] + [data][test_inserts.o][ 8][16777215] + [data][test_inserts.p][ 10][2147483647] + [data][test_inserts.q][ 10][4294967295] + [data][test_inserts.r][ 19][9223372036854775807] + [data][test_inserts.s][ 20][18446744073709551615] + [data][test_inserts.t][ 4][1901] + [data][test_inserts.u][ 6][999.99] + [data][test_inserts.v][ 7][-999.99] + + [data][test_inserts.a][ 1][3] + [data][test_inserts.b][ 5][three] + [data][test_inserts.c][ 4][3.45] + [data][test_inserts.d][ 2][-3] + [data][test_inserts.e][ 7][33.4545] + [data][test_inserts.f][ 19][2016-09-12 11:12:13] + [data][test_inserts.g][ 10][2013-05-04] + [data][test_inserts.h][ 9][821:33:44] + [data][test_inserts.i][ 2][-1] + [data][test_inserts.k][ 3][128] + [data][test_inserts.l][ 2][-1] + [data][test_inserts.m][ 5][65534] + [data][test_inserts.n][ 2][-1] + [data][test_inserts.o][ 8][16777214] + [data][test_inserts.p][ 1][1] + [data][test_inserts.q][ 1][2] + [data][test_inserts.r][ 1][3] + [data][test_inserts.s][ 1][4] + [data][test_inserts.t][ 4][2155] + [data][test_inserts.u][ 6][222.22] + [data][test_inserts.v][ 7][-567.89] + + [end] server status: 2 + [end] server status: AUTOCOMMIT + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +------------------------------------------------------------------ +EXECUTING:[21][TRUNCATE test_inserts] +[CS_TEXT_REPRESENTATION] + [meta] rows: 0 + [meta] cols: 0 + [meta] server status: 0 + [meta] server status: + [meta] warning count: 0 + + [meta] no columns + + [meta] no charset + + [data] no rows + + [end] server status: 2 + [end] server status: AUTOCOMMIT + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +------------------------------------------------------------------ +EXECUTING:[37][SELECT * FROM test_inserts ORDER BY a] +[CS_TEXT_REPRESENTATION] + [meta] rows: 0 + [meta] cols: 21 + [meta] server status: 2 + [meta] server status: AUTOCOMMIT + [meta] warning count: 0 + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: a + [meta][field] org col name: a + [meta][field] length: 10 + [meta][field] charsetnr: 8 + [meta][field] flags: 4129 (NOT_NULL UNSIGNED NO_DEFAULT_VALUE ) + [meta][field] decimals: 0 + [meta][field] type: LONG (3) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: b + [meta][field] org col name: b + [meta][field] length: 400 + [meta][field] charsetnr: 255 + [meta][field] flags: 0 + [meta][field] decimals: 0 + [meta][field] type: VARCHAR (15) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: c + [meta][field] org col name: c + [meta][field] length: 22 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 31 + [meta][field] type: DOUBLE (5) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: d + [meta][field] org col name: d + [meta][field] length: 11 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 0 + [meta][field] type: LONG (3) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: e + [meta][field] org col name: e + [meta][field] length: 12 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 31 + [meta][field] type: FLOAT (4) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: f + [meta][field] org col name: f + [meta][field] length: 19 + [meta][field] charsetnr: 8 + [meta][field] flags: 128 (BINARY ) + [meta][field] decimals: 0 + [meta][field] type: DATETIME (12) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: g + [meta][field] org col name: g + [meta][field] length: 10 + [meta][field] charsetnr: 8 + [meta][field] flags: 128 (BINARY ) + [meta][field] decimals: 0 + [meta][field] type: DATE (10) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: h + [meta][field] org col name: h + [meta][field] length: 10 + [meta][field] charsetnr: 8 + [meta][field] flags: 128 (BINARY ) + [meta][field] decimals: 0 + [meta][field] type: TIME (11) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: i + [meta][field] org col name: i + [meta][field] length: 4 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 0 + [meta][field] type: TINY (1) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: k + [meta][field] org col name: k + [meta][field] length: 3 + [meta][field] charsetnr: 8 + [meta][field] flags: 32 (UNSIGNED ) + [meta][field] decimals: 0 + [meta][field] type: TINY (1) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: l + [meta][field] org col name: l + [meta][field] length: 6 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 0 + [meta][field] type: SHORT (2) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: m + [meta][field] org col name: m + [meta][field] length: 5 + [meta][field] charsetnr: 8 + [meta][field] flags: 32 (UNSIGNED ) + [meta][field] decimals: 0 + [meta][field] type: SHORT (2) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: n + [meta][field] org col name: n + [meta][field] length: 9 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 0 + [meta][field] type: INT24 (9) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: o + [meta][field] org col name: o + [meta][field] length: 8 + [meta][field] charsetnr: 8 + [meta][field] flags: 32 (UNSIGNED ) + [meta][field] decimals: 0 + [meta][field] type: INT24 (9) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: p + [meta][field] org col name: p + [meta][field] length: 11 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 0 + [meta][field] type: LONG (3) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: q + [meta][field] org col name: q + [meta][field] length: 10 + [meta][field] charsetnr: 8 + [meta][field] flags: 32 (UNSIGNED ) + [meta][field] decimals: 0 + [meta][field] type: LONG (3) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: r + [meta][field] org col name: r + [meta][field] length: 20 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 0 + [meta][field] type: LONGLONG (8) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: s + [meta][field] org col name: s + [meta][field] length: 20 + [meta][field] charsetnr: 8 + [meta][field] flags: 32 (UNSIGNED ) + [meta][field] decimals: 0 + [meta][field] type: LONGLONG (8) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: t + [meta][field] org col name: t + [meta][field] length: 4 + [meta][field] charsetnr: 8 + [meta][field] flags: 96 (UNSIGNED ZEROFILL ) + [meta][field] decimals: 0 + [meta][field] type: YEAR (13) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: u + [meta][field] org col name: u + [meta][field] length: 6 + [meta][field] charsetnr: 8 + [meta][field] flags: 32 (UNSIGNED ) + [meta][field] decimals: 2 + [meta][field] type: NEWDECIMAL (246) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: v + [meta][field] org col name: v + [meta][field] length: 7 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 2 + [meta][field] type: NEWDECIMAL (246) + + + [meta][charset result] number: 33 + [meta][charset result] name: utf8mb3 + [meta][charset result] collation: utf8_general_ci + [meta][charset result] sort order: + + [data] no rows + + [end] server status: 2 + [end] server status: AUTOCOMMIT + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +[CS_BINARY_REPRESENTATION] + [meta] rows: 0 + [meta] cols: 21 + [meta] server status: 2 + [meta] server status: AUTOCOMMIT + [meta] warning count: 0 + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: a + [meta][field] org col name: a + [meta][field] length: 10 + [meta][field] charsetnr: 8 + [meta][field] flags: 4129 (NOT_NULL UNSIGNED NO_DEFAULT_VALUE ) + [meta][field] decimals: 0 + [meta][field] type: LONG (3) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: b + [meta][field] org col name: b + [meta][field] length: 400 + [meta][field] charsetnr: 255 + [meta][field] flags: 0 + [meta][field] decimals: 0 + [meta][field] type: VARCHAR (15) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: c + [meta][field] org col name: c + [meta][field] length: 22 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 31 + [meta][field] type: DOUBLE (5) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: d + [meta][field] org col name: d + [meta][field] length: 11 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 0 + [meta][field] type: LONG (3) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: e + [meta][field] org col name: e + [meta][field] length: 12 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 31 + [meta][field] type: FLOAT (4) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: f + [meta][field] org col name: f + [meta][field] length: 19 + [meta][field] charsetnr: 8 + [meta][field] flags: 128 (BINARY ) + [meta][field] decimals: 0 + [meta][field] type: DATETIME (12) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: g + [meta][field] org col name: g + [meta][field] length: 10 + [meta][field] charsetnr: 8 + [meta][field] flags: 128 (BINARY ) + [meta][field] decimals: 0 + [meta][field] type: DATE (10) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: h + [meta][field] org col name: h + [meta][field] length: 10 + [meta][field] charsetnr: 8 + [meta][field] flags: 128 (BINARY ) + [meta][field] decimals: 0 + [meta][field] type: TIME (11) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: i + [meta][field] org col name: i + [meta][field] length: 4 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 0 + [meta][field] type: TINY (1) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: k + [meta][field] org col name: k + [meta][field] length: 3 + [meta][field] charsetnr: 8 + [meta][field] flags: 32 (UNSIGNED ) + [meta][field] decimals: 0 + [meta][field] type: TINY (1) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: l + [meta][field] org col name: l + [meta][field] length: 6 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 0 + [meta][field] type: SHORT (2) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: m + [meta][field] org col name: m + [meta][field] length: 5 + [meta][field] charsetnr: 8 + [meta][field] flags: 32 (UNSIGNED ) + [meta][field] decimals: 0 + [meta][field] type: SHORT (2) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: n + [meta][field] org col name: n + [meta][field] length: 9 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 0 + [meta][field] type: INT24 (9) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: o + [meta][field] org col name: o + [meta][field] length: 8 + [meta][field] charsetnr: 8 + [meta][field] flags: 32 (UNSIGNED ) + [meta][field] decimals: 0 + [meta][field] type: INT24 (9) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: p + [meta][field] org col name: p + [meta][field] length: 11 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 0 + [meta][field] type: LONG (3) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: q + [meta][field] org col name: q + [meta][field] length: 10 + [meta][field] charsetnr: 8 + [meta][field] flags: 32 (UNSIGNED ) + [meta][field] decimals: 0 + [meta][field] type: LONG (3) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: r + [meta][field] org col name: r + [meta][field] length: 20 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 0 + [meta][field] type: LONGLONG (8) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: s + [meta][field] org col name: s + [meta][field] length: 20 + [meta][field] charsetnr: 8 + [meta][field] flags: 32 (UNSIGNED ) + [meta][field] decimals: 0 + [meta][field] type: LONGLONG (8) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: t + [meta][field] org col name: t + [meta][field] length: 4 + [meta][field] charsetnr: 8 + [meta][field] flags: 96 (UNSIGNED ZEROFILL ) + [meta][field] decimals: 0 + [meta][field] type: YEAR (13) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: u + [meta][field] org col name: u + [meta][field] length: 6 + [meta][field] charsetnr: 8 + [meta][field] flags: 32 (UNSIGNED ) + [meta][field] decimals: 2 + [meta][field] type: NEWDECIMAL (246) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: v + [meta][field] org col name: v + [meta][field] length: 7 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 2 + [meta][field] type: NEWDECIMAL (246) + + + [meta][charset result] number: 33 + [meta][charset result] name: utf8mb3 + [meta][charset result] collation: utf8_general_ci + [meta][charset result] sort order: + + [data] no rows + + [end] server status: 2 + [end] server status: AUTOCOMMIT + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +------------------------------------------------------------------ +EXECUTING:[27][PREPARE ps1 FROM 'select 1'] +[CS_TEXT_REPRESENTATION] + [meta] rows: 0 + [meta] cols: 0 + [meta] server status: 0 + [meta] server status: + [meta] warning count: 0 + + [meta] no columns + + [meta] no charset + + [data] no rows + + [end] server status: 2 + [end] server status: AUTOCOMMIT + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: Statement prepared +------------------------------------------------------------------ +EXECUTING:[11][EXECUTE ps1] +[CS_TEXT_REPRESENTATION] + [meta] rows: 1 + [meta] cols: 1 + [meta] server status: 2 + [meta] server status: AUTOCOMMIT + [meta] warning count: 0 + + [meta][field] db name: + [meta][field] table name: + [meta][field] org table name: + [meta][field] col name: 1 + [meta][field] org col name: + [meta][field] length: 1 + [meta][field] charsetnr: 8 + [meta][field] flags: 129 (NOT_NULL BINARY ) + [meta][field] decimals: 0 + [meta][field] type: LONGLONG (8) + + + [meta][charset result] number: 33 + [meta][charset result] name: utf8mb3 + [meta][charset result] collation: utf8_general_ci + [meta][charset result] sort order: + + [data][.1][ 1][1] + + [end] server status: 2 + [end] server status: AUTOCOMMIT + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +------------------------------------------------------------------ +EXECUTING:[22][DEALLOCATE PREPARE ps1] +[CS_TEXT_REPRESENTATION] + [meta] rows: 0 + [meta] cols: 0 + [meta] server status: 0 + [meta] server status: + [meta] warning count: 0 + + [meta] no columns + + [meta] no charset + + [data] no rows + + [end] server status: 2 + [end] server status: AUTOCOMMIT + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +------------------------------------------------------------------ +EXECUTING:[24][CREATE TABLE tbl (a INT)] +[CS_TEXT_REPRESENTATION] + [meta] rows: 0 + [meta] cols: 0 + [meta] server status: 0 + [meta] server status: + [meta] warning count: 0 + + [meta] no columns + + [meta] no charset + + [data] no rows + + [end] server status: 2 + [end] server status: AUTOCOMMIT + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +------------------------------------------------------------------ +EXECUTING:[55][PREPARE ps1 FROM 'INSERT INTO tbl VALUES (1), (2), (3)'] +[CS_TEXT_REPRESENTATION] + [meta] rows: 0 + [meta] cols: 0 + [meta] server status: 0 + [meta] server status: + [meta] warning count: 0 + + [meta] no columns + + [meta] no charset + + [data] no rows + + [end] server status: 2 + [end] server status: AUTOCOMMIT + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: Statement prepared +------------------------------------------------------------------ +EXECUTING:[11][EXECUTE ps1] +[CS_TEXT_REPRESENTATION] + [meta] rows: 0 + [meta] cols: 0 + [meta] server status: 0 + [meta] server status: + [meta] warning count: 0 + + [meta] no columns + + [meta] no charset + + [data] no rows + + [end] server status: 2 + [end] server status: AUTOCOMMIT + [end] warning count: 0 + [end] affected rows: 3 + [end] last insert id: 0 + [end] message: Records: 3 Duplicates: 0 Warnings: 0 +------------------------------------------------------------------ +EXECUTING:[22][DEALLOCATE PREPARE ps1] +[CS_TEXT_REPRESENTATION] + [meta] rows: 0 + [meta] cols: 0 + [meta] server status: 0 + [meta] server status: + [meta] warning count: 0 + + [meta] no columns + + [meta] no charset + + [data] no rows + + [end] server status: 2 + [end] server status: AUTOCOMMIT + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +------------------------------------------------------------------ +EXECUTING:[46][SELECT IF(SUM(a)=6, 'OK:)', 'FAIL:(') FROM tbl] +[CS_TEXT_REPRESENTATION] + [meta] rows: 1 + [meta] cols: 1 + [meta] server status: 34 + [meta] server status: AUTOCOMMIT QUERY_NO_INDEX_USED + [meta] warning count: 0 + + [meta][field] db name: + [meta][field] table name: + [meta][field] org table name: + [meta][field] col name: IF(SUM(a)=6, 'OK:)', 'FAIL:(') + [meta][field] org col name: + [meta][field] length: 18 + [meta][field] charsetnr: 33 + [meta][field] flags: 1 (NOT_NULL ) + [meta][field] decimals: 31 + [meta][field] type: VARCHAR (15) + + + [meta][charset result] number: 33 + [meta][charset result] name: utf8mb3 + [meta][charset result] collation: utf8_general_ci + [meta][charset result] sort order: + + [data][.IF(SUM(a)=6, 'OK:)', 'FAIL:(')][ 4][OK:)] + + [end] server status: 34 + [end] server status: AUTOCOMMIT QUERY_NO_INDEX_USED + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +------------------------------------------------------------------ +EXECUTING:[22][DEALLOCATE PREPARE ps1] +[CS_TEXT_REPRESENTATION] +[1243][HY000][Unknown prepared statement handler (ps1) given to DEALLOCATE PREPARE] [meta] rows: 0 + [meta] cols: 0 + [meta] server status: 0 + [meta] server status: + [meta] warning count: 0 + + [meta] no columns + + [meta] no charset + + [data] no rows + + [end] server status: 0 + [end] server status: + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +[CS_BINARY_REPRESENTATION] +[1243][HY000][Unknown prepared statement handler (ps1) given to DEALLOCATE PREPARE] [meta] rows: 0 + [meta] cols: 0 + [meta] server status: 0 + [meta] server status: + [meta] warning count: 0 + + [meta] no columns + + [meta] no charset + + [data] no rows + + [end] server status: 0 + [end] server status: + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +------------------------------------------------------------------ +EXECUTING:[7][garbage] +[CS_TEXT_REPRESENTATION] +[1064][42000][You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'garbage' at line 1] [meta] rows: 0 + [meta] cols: 0 + [meta] server status: 0 + [meta] server status: + [meta] warning count: 0 + + [meta] no columns + + [meta] no charset + + [data] no rows + + [end] server status: 0 + [end] server status: + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +[CS_BINARY_REPRESENTATION] +[1064][42000][You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'garbage' at line 1] [meta] rows: 0 + [meta] cols: 0 + [meta] server status: 0 + [meta] server status: + [meta] warning count: 0 + + [meta] no columns + + [meta] no charset + + [data] no rows + + [end] server status: 0 + [end] server status: + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +------------------------------------------------------------------ +EXECUTING:[17][SELECT b FROM tbl] +[CS_TEXT_REPRESENTATION] +[1054][42S22][Unknown column 'b' in 'field list'] [meta] rows: 0 + [meta] cols: 0 + [meta] server status: 0 + [meta] server status: + [meta] warning count: 0 + + [meta] no columns + + [meta] no charset + + [data] no rows + + [end] server status: 0 + [end] server status: + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +[CS_BINARY_REPRESENTATION] +[1054][42S22][Unknown column 'b' in 'field list'] [meta] rows: 0 + [meta] cols: 0 + [meta] server status: 0 + [meta] server status: + [meta] warning count: 0 + + [meta] no columns + + [meta] no charset + + [data] no rows + + [end] server status: 0 + [end] server status: + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +------------------------------------------------------------------ +EXECUTING:[43][ALTER USER bogus@remotehost PASSWORD EXPIRE] +[CS_TEXT_REPRESENTATION] +[1396][HY000][Operation ALTER USER failed for 'bogus'@'remotehost'] [meta] rows: 0 + [meta] cols: 0 + [meta] server status: 0 + [meta] server status: + [meta] warning count: 0 + + [meta] no columns + + [meta] no charset + + [data] no rows + + [end] server status: 0 + [end] server status: + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +[CS_BINARY_REPRESENTATION] +[1396][HY000][Operation ALTER USER failed for 'bogus'@'remotehost'] [meta] rows: 0 + [meta] cols: 0 + [meta] server status: 0 + [meta] server status: + [meta] warning count: 0 + + [meta] no columns + + [meta] no charset + + [data] no rows + + [end] server status: 0 + [end] server status: + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +------------------------------------------------------------------ +EXECUTING:[26][CREATE TABLE tbld (d TIME)] +[CS_TEXT_REPRESENTATION] + [meta] rows: 0 + [meta] cols: 0 + [meta] server status: 0 + [meta] server status: + [meta] warning count: 0 + + [meta] no columns + + [meta] no charset + + [data] no rows + + [end] server status: 2 + [end] server status: AUTOCOMMIT + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +------------------------------------------------------------------ +EXECUTING:[36][INSERT INTO tbld VALUES ('43141231')] +[CS_TEXT_REPRESENTATION] +[1292][22007][Incorrect time value: '43141231' for column 'd' at row 1] [meta] rows: 0 + [meta] cols: 0 + [meta] server status: 0 + [meta] server status: + [meta] warning count: 0 + + [meta] no columns + + [meta] no charset + + [data] no rows + + [end] server status: 0 + [end] server status: + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +[CS_BINARY_REPRESENTATION] +[1292][22007][Incorrect time value: '43141231' for column 'd' at row 1] [meta] rows: 0 + [meta] cols: 0 + [meta] server status: 0 + [meta] server status: + [meta] warning count: 0 + + [meta] no columns + + [meta] no charset + + [data] no rows + + [end] server status: 0 + [end] server status: + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +------------------------------------------------------------------ +EXECUTING:[10][SELECT 1/0] +[CS_TEXT_REPRESENTATION] + [meta] rows: 1 + [meta] cols: 1 + [meta] server status: 2 + [meta] server status: AUTOCOMMIT + [meta] warning count: 0 + + [meta][field] db name: + [meta][field] table name: + [meta][field] org table name: + [meta][field] col name: 1/0 + [meta][field] org col name: + [meta][field] length: 7 + [meta][field] charsetnr: 8 + [meta][field] flags: 128 (BINARY ) + [meta][field] decimals: 4 + [meta][field] type: NEWDECIMAL (246) + + + [meta][charset result] number: 33 + [meta][charset result] name: utf8mb3 + [meta][charset result] collation: utf8_general_ci + [meta][charset result] sort order: + + [data][.1/0][ 6][[NULL]] + + [end] server status: 2 + [end] server status: AUTOCOMMIT + [end] warning count: 1 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +------------------------------------------------------------------ +EXECUTING:[18][UPDATE tbl SET a=5] +[CS_TEXT_REPRESENTATION] + [meta] rows: 0 + [meta] cols: 0 + [meta] server status: 0 + [meta] server status: + [meta] warning count: 0 + + [meta] no columns + + [meta] no charset + + [data] no rows + + [end] server status: 34 + [end] server status: AUTOCOMMIT QUERY_NO_INDEX_USED + [end] warning count: 0 + [end] affected rows: 3 + [end] last insert id: 0 + [end] message: Rows matched: 3 Changed: 3 Warnings: 0 +------------------------------------------------------------------ +EXECUTING:[17][START TRANSACTION] +[CS_TEXT_REPRESENTATION] + [meta] rows: 0 + [meta] cols: 0 + [meta] server status: 0 + [meta] server status: + [meta] warning count: 0 + + [meta] no columns + + [meta] no charset + + [data] no rows + + [end] server status: 3 + [end] server status: IN_TRANS AUTOCOMMIT + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +------------------------------------------------------------------ +EXECUTING:[18][UPDATE tbl SET a=4] +[CS_TEXT_REPRESENTATION] + [meta] rows: 0 + [meta] cols: 0 + [meta] server status: 0 + [meta] server status: + [meta] warning count: 0 + + [meta] no columns + + [meta] no charset + + [data] no rows + + [end] server status: 35 + [end] server status: IN_TRANS AUTOCOMMIT QUERY_NO_INDEX_USED + [end] warning count: 0 + [end] affected rows: 3 + [end] last insert id: 0 + [end] message: Rows matched: 3 Changed: 3 Warnings: 0 +------------------------------------------------------------------ +EXECUTING:[8][ROLLBACK] +[CS_TEXT_REPRESENTATION] + [meta] rows: 0 + [meta] cols: 0 + [meta] server status: 0 + [meta] server status: + [meta] warning count: 0 + + [meta] no columns + + [meta] no charset + + [data] no rows + + [end] server status: 2 + [end] server status: AUTOCOMMIT + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +------------------------------------------------------------------ +EXECUTING:[45][SELECT IF(SUM(a) = 15, 'OK', 'FAIL') FROM tbl] +[CS_TEXT_REPRESENTATION] + [meta] rows: 1 + [meta] cols: 1 + [meta] server status: 34 + [meta] server status: AUTOCOMMIT QUERY_NO_INDEX_USED + [meta] warning count: 0 + + [meta][field] db name: + [meta][field] table name: + [meta][field] org table name: + [meta][field] col name: IF(SUM(a) = 15, 'OK', 'FAIL') + [meta][field] org col name: + [meta][field] length: 12 + [meta][field] charsetnr: 33 + [meta][field] flags: 1 (NOT_NULL ) + [meta][field] decimals: 31 + [meta][field] type: VARCHAR (15) + + + [meta][charset result] number: 33 + [meta][charset result] name: utf8mb3 + [meta][charset result] collation: utf8_general_ci + [meta][charset result] sort order: + + [data][.IF(SUM(a) = 15, 'OK', 'FAIL')][ 2][OK] + + [end] server status: 34 + [end] server status: AUTOCOMMIT QUERY_NO_INDEX_USED + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +------------------------------------------------------------------ +EXECUTING:[17][START TRANSACTION] +[CS_TEXT_REPRESENTATION] + [meta] rows: 0 + [meta] cols: 0 + [meta] server status: 0 + [meta] server status: + [meta] warning count: 0 + + [meta] no columns + + [meta] no charset + + [data] no rows + + [end] server status: 3 + [end] server status: IN_TRANS AUTOCOMMIT + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +------------------------------------------------------------------ +EXECUTING:[18][UPDATE tbl SET a=4] +[CS_TEXT_REPRESENTATION] + [meta] rows: 0 + [meta] cols: 0 + [meta] server status: 0 + [meta] server status: + [meta] warning count: 0 + + [meta] no columns + + [meta] no charset + + [data] no rows + + [end] server status: 35 + [end] server status: IN_TRANS AUTOCOMMIT QUERY_NO_INDEX_USED + [end] warning count: 0 + [end] affected rows: 3 + [end] last insert id: 0 + [end] message: Rows matched: 3 Changed: 3 Warnings: 0 +------------------------------------------------------------------ +EXECUTING:[6][COMMIT] +[CS_TEXT_REPRESENTATION] + [meta] rows: 0 + [meta] cols: 0 + [meta] server status: 0 + [meta] server status: + [meta] warning count: 0 + + [meta] no columns + + [meta] no charset + + [data] no rows + + [end] server status: 2 + [end] server status: AUTOCOMMIT + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +------------------------------------------------------------------ +EXECUTING:[45][SELECT IF(SUM(a) = 12, 'OK', 'FAIL') FROM tbl] +[CS_TEXT_REPRESENTATION] + [meta] rows: 1 + [meta] cols: 1 + [meta] server status: 34 + [meta] server status: AUTOCOMMIT QUERY_NO_INDEX_USED + [meta] warning count: 0 + + [meta][field] db name: + [meta][field] table name: + [meta][field] org table name: + [meta][field] col name: IF(SUM(a) = 12, 'OK', 'FAIL') + [meta][field] org col name: + [meta][field] length: 12 + [meta][field] charsetnr: 33 + [meta][field] flags: 1 (NOT_NULL ) + [meta][field] decimals: 31 + [meta][field] type: VARCHAR (15) + + + [meta][charset result] number: 33 + [meta][charset result] name: utf8mb3 + [meta][charset result] collation: utf8_general_ci + [meta][charset result] sort order: + + [data][.IF(SUM(a) = 12, 'OK', 'FAIL')][ 2][OK] + + [end] server status: 34 + [end] server status: AUTOCOMMIT QUERY_NO_INDEX_USED + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +------------------------------------------------------------------ +EXECUTING:[27][START TRANSACTION READ ONLY] +[CS_TEXT_REPRESENTATION] + [meta] rows: 0 + [meta] cols: 0 + [meta] server status: 0 + [meta] server status: + [meta] warning count: 0 + + [meta] no columns + + [meta] no charset + + [data] no rows + + [end] server status: 8195 + [end] server status: IN_TRANS AUTOCOMMIT IN_TRANS_READONLY + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +------------------------------------------------------------------ +EXECUTING:[18][UPDATE tbl SET a=2] +[CS_TEXT_REPRESENTATION] +[1792][25006][Cannot execute statement in a READ ONLY transaction.] [meta] rows: 0 + [meta] cols: 0 + [meta] server status: 0 + [meta] server status: + [meta] warning count: 0 + + [meta] no columns + + [meta] no charset + + [data] no rows + + [end] server status: 0 + [end] server status: + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +------------------------------------------------------------------ +EXECUTING:[6][COMMIT] +[CS_TEXT_REPRESENTATION] + [meta] rows: 0 + [meta] cols: 0 + [meta] server status: 0 + [meta] server status: + [meta] warning count: 0 + + [meta] no columns + + [meta] no charset + + [data] no rows + + [end] server status: 2 + [end] server status: AUTOCOMMIT + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +------------------------------------------------------------------ +EXECUTING:[45][SELECT IF(SUM(4) = 12, 'OK', 'FAIL') FROM tbl] +[CS_TEXT_REPRESENTATION] + [meta] rows: 1 + [meta] cols: 1 + [meta] server status: 34 + [meta] server status: AUTOCOMMIT QUERY_NO_INDEX_USED + [meta] warning count: 0 + + [meta][field] db name: + [meta][field] table name: + [meta][field] org table name: + [meta][field] col name: IF(SUM(4) = 12, 'OK', 'FAIL') + [meta][field] org col name: + [meta][field] length: 12 + [meta][field] charsetnr: 33 + [meta][field] flags: 1 (NOT_NULL ) + [meta][field] decimals: 31 + [meta][field] type: VARCHAR (15) + + + [meta][charset result] number: 33 + [meta][charset result] name: utf8mb3 + [meta][charset result] collation: utf8_general_ci + [meta][charset result] sort order: + + [data][.IF(SUM(4) = 12, 'OK', 'FAIL')][ 2][OK] + + [end] server status: 34 + [end] server status: AUTOCOMMIT QUERY_NO_INDEX_USED + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +------------------------------------------------------------------ +EXECUTING:[16][SET autocommit=0] +[CS_TEXT_REPRESENTATION] + [meta] rows: 0 + [meta] cols: 0 + [meta] server status: 0 + [meta] server status: + [meta] warning count: 0 + + [meta] no columns + + [meta] no charset + + [data] no rows + + [end] server status: 0 + [end] server status: + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +------------------------------------------------------------------ +EXECUTING:[18][UPDATE tbl SET a=2] +[CS_TEXT_REPRESENTATION] + [meta] rows: 0 + [meta] cols: 0 + [meta] server status: 0 + [meta] server status: + [meta] warning count: 0 + + [meta] no columns + + [meta] no charset + + [data] no rows + + [end] server status: 33 + [end] server status: IN_TRANS QUERY_NO_INDEX_USED + [end] warning count: 0 + [end] affected rows: 3 + [end] last insert id: 0 + [end] message: Rows matched: 3 Changed: 3 Warnings: 0 +------------------------------------------------------------------ +EXECUTING:[8][ROLLBACK] +[CS_TEXT_REPRESENTATION] + [meta] rows: 0 + [meta] cols: 0 + [meta] server status: 0 + [meta] server status: + [meta] warning count: 0 + + [meta] no columns + + [meta] no charset + + [data] no rows + + [end] server status: 0 + [end] server status: + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +------------------------------------------------------------------ +EXECUTING:[45][SELECT IF(SUM(4) = 12, 'OK', 'FAIL') FROM tbl] +[CS_TEXT_REPRESENTATION] + [meta] rows: 1 + [meta] cols: 1 + [meta] server status: 33 + [meta] server status: IN_TRANS QUERY_NO_INDEX_USED + [meta] warning count: 0 + + [meta][field] db name: + [meta][field] table name: + [meta][field] org table name: + [meta][field] col name: IF(SUM(4) = 12, 'OK', 'FAIL') + [meta][field] org col name: + [meta][field] length: 12 + [meta][field] charsetnr: 33 + [meta][field] flags: 1 (NOT_NULL ) + [meta][field] decimals: 31 + [meta][field] type: VARCHAR (15) + + + [meta][charset result] number: 33 + [meta][charset result] name: utf8mb3 + [meta][charset result] collation: utf8_general_ci + [meta][charset result] sort order: + + [data][.IF(SUM(4) = 12, 'OK', 'FAIL')][ 2][OK] + + [end] server status: 33 + [end] server status: IN_TRANS QUERY_NO_INDEX_USED + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +------------------------------------------------------------------ +EXECUTING:[35][set @a=((2) in (select a from tbl))] +[CS_TEXT_REPRESENTATION] + [meta] rows: 0 + [meta] cols: 0 + [meta] server status: 0 + [meta] server status: + [meta] warning count: 0 + + [meta] no columns + + [meta] no charset + + [data] no rows + + [end] server status: 33 + [end] server status: IN_TRANS QUERY_NO_INDEX_USED + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +[CS_BINARY_REPRESENTATION] + [meta] rows: 0 + [meta] cols: 0 + [meta] server status: 0 + [meta] server status: + [meta] warning count: 0 + + [meta] no columns + + [meta] no charset + + [data] no rows + + [end] server status: 33 + [end] server status: IN_TRANS QUERY_NO_INDEX_USED + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +------------------------------------------------------------------ +EXECUTING:[9][SELECT @a] +[CS_TEXT_REPRESENTATION] + [meta] rows: 1 + [meta] cols: 1 + [meta] server status: 1 + [meta] server status: IN_TRANS + [meta] warning count: 0 + + [meta][field] db name: + [meta][field] table name: + [meta][field] org table name: + [meta][field] col name: @a + [meta][field] org col name: + [meta][field] length: 21 + [meta][field] charsetnr: 33 + [meta][field] flags: 128 (BINARY ) + [meta][field] decimals: 0 + [meta][field] type: LONGLONG (8) + + + [meta][charset result] number: 33 + [meta][charset result] name: utf8mb3 + [meta][charset result] collation: utf8_general_ci + [meta][charset result] sort order: + + [data][.@a][ 1][0] + + [end] server status: 1 + [end] server status: IN_TRANS + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +[CS_BINARY_REPRESENTATION] + [meta] rows: 1 + [meta] cols: 1 + [meta] server status: 1 + [meta] server status: IN_TRANS + [meta] warning count: 0 + + [meta][field] db name: + [meta][field] table name: + [meta][field] org table name: + [meta][field] col name: @a + [meta][field] org col name: + [meta][field] length: 21 + [meta][field] charsetnr: 33 + [meta][field] flags: 128 (BINARY ) + [meta][field] decimals: 0 + [meta][field] type: LONGLONG (8) + + + [meta][charset result] number: 33 + [meta][charset result] name: utf8mb3 + [meta][charset result] collation: utf8_general_ci + [meta][charset result] sort order: + + [data][.@a][ 1][0] + + [end] server status: 1 + [end] server status: IN_TRANS + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +------------------------------------------------------------------ +EXECUTING:[9][set @b=42] +[CS_TEXT_REPRESENTATION] + [meta] rows: 0 + [meta] cols: 0 + [meta] server status: 0 + [meta] server status: + [meta] warning count: 0 + + [meta] no columns + + [meta] no charset + + [data] no rows + + [end] server status: 1 + [end] server status: IN_TRANS + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +[CS_BINARY_REPRESENTATION] + [meta] rows: 0 + [meta] cols: 0 + [meta] server status: 0 + [meta] server status: + [meta] warning count: 0 + + [meta] no columns + + [meta] no charset + + [data] no rows + + [end] server status: 1 + [end] server status: IN_TRANS + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +------------------------------------------------------------------ +EXECUTING:[9][SELECT @b] +[CS_TEXT_REPRESENTATION] + [meta] rows: 1 + [meta] cols: 1 + [meta] server status: 1 + [meta] server status: IN_TRANS + [meta] warning count: 0 + + [meta][field] db name: + [meta][field] table name: + [meta][field] org table name: + [meta][field] col name: @b + [meta][field] org col name: + [meta][field] length: 21 + [meta][field] charsetnr: 33 + [meta][field] flags: 128 (BINARY ) + [meta][field] decimals: 0 + [meta][field] type: LONGLONG (8) + + + [meta][charset result] number: 33 + [meta][charset result] name: utf8mb3 + [meta][charset result] collation: utf8_general_ci + [meta][charset result] sort order: + + [data][.@b][ 2][42] + + [end] server status: 1 + [end] server status: IN_TRANS + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +[CS_BINARY_REPRESENTATION] + [meta] rows: 1 + [meta] cols: 1 + [meta] server status: 1 + [meta] server status: IN_TRANS + [meta] warning count: 0 + + [meta][field] db name: + [meta][field] table name: + [meta][field] org table name: + [meta][field] col name: @b + [meta][field] org col name: + [meta][field] length: 21 + [meta][field] charsetnr: 33 + [meta][field] flags: 128 (BINARY ) + [meta][field] decimals: 0 + [meta][field] type: LONGLONG (8) + + + [meta][charset result] number: 33 + [meta][charset result] name: utf8mb3 + [meta][charset result] collation: utf8_general_ci + [meta][charset result] sort order: + + [data][.@b][ 2][42] + + [end] server status: 1 + [end] server status: IN_TRANS + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +------------------------------------------------------------------ +EXECUTING:[20][SELECT @non_existing] +[CS_TEXT_REPRESENTATION] + [meta] rows: 1 + [meta] cols: 1 + [meta] server status: 1 + [meta] server status: IN_TRANS + [meta] warning count: 0 + + [meta][field] db name: + [meta][field] table name: + [meta][field] org table name: + [meta][field] col name: @non_existing + [meta][field] org col name: + [meta][field] length: 65535 + [meta][field] charsetnr: 33 + [meta][field] flags: 128 (BINARY ) + [meta][field] decimals: 31 + [meta][field] type: VARCHAR (15) + + + [meta][charset result] number: 33 + [meta][charset result] name: utf8mb3 + [meta][charset result] collation: utf8_general_ci + [meta][charset result] sort order: + + [data][.@non_existing][ 6][[NULL]] + + [end] server status: 1 + [end] server status: IN_TRANS + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +[CS_BINARY_REPRESENTATION] + [meta] rows: 1 + [meta] cols: 1 + [meta] server status: 1 + [meta] server status: IN_TRANS + [meta] warning count: 0 + + [meta][field] db name: + [meta][field] table name: + [meta][field] org table name: + [meta][field] col name: @non_existing + [meta][field] org col name: + [meta][field] length: 65535 + [meta][field] charsetnr: 33 + [meta][field] flags: 128 (BINARY ) + [meta][field] decimals: 31 + [meta][field] type: VARCHAR (15) + + + [meta][charset result] number: 33 + [meta][charset result] name: utf8mb3 + [meta][charset result] collation: utf8_general_ci + [meta][charset result] sort order: + + [data][.@non_existing][ 6][[NULL]] + + [end] server status: 1 + [end] server status: IN_TRANS + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +------------------------------------------------------------------ +EXECUTING:[0][] +[CS_TEXT_REPRESENTATION] +[1065][42000][Query was empty] [meta] rows: 0 + [meta] cols: 0 + [meta] server status: 0 + [meta] server status: + [meta] warning count: 0 + + [meta] no columns + + [meta] no charset + + [data] no rows + + [end] server status: 0 + [end] server status: + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +[CS_BINARY_REPRESENTATION] +[1065][42000][Query was empty] [meta] rows: 0 + [meta] cols: 0 + [meta] server status: 0 + [meta] server status: + [meta] warning count: 0 + + [meta] no columns + + [meta] no charset + + [data] no rows + + [end] server status: 0 + [end] server status: + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +------------------------------------------------------------------ +EXECUTING:[14][DROP TABLE tbl] +[CS_TEXT_REPRESENTATION] + [meta] rows: 0 + [meta] cols: 0 + [meta] server status: 0 + [meta] server status: + [meta] warning count: 0 + + [meta] no columns + + [meta] no charset + + [data] no rows + + [end] server status: 0 + [end] server status: + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +------------------------------------------------------------------ +EXECUTING:[15][DROP TABLE tbld] +[CS_TEXT_REPRESENTATION] + [meta] rows: 0 + [meta] cols: 0 + [meta] server status: 0 + [meta] server status: + [meta] warning count: 0 + + [meta] no columns + + [meta] no charset + + [data] no rows + + [end] server status: 0 + [end] server status: + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +------------------------------------------------------------------ +EXECUTING:[19][DROP DATABASE test1] +[CS_TEXT_REPRESENTATION] + [meta] rows: 0 + [meta] cols: 0 + [meta] server status: 0 + [meta] server status: + [meta] warning count: 0 + + [meta] no columns + + [meta] no charset + + [data] no rows + + [end] server status: 256 + [end] server status: DB_DROPPED + [end] warning count: 0 + [end] affected rows: 1 + [end] last insert id: 0 + [end] message: +------------------------------------------------------------------ +[srv_session_close] +Follows threaded run +======================================================================== +init thread +[srv_session_open] +------------------------------------------------------------------ +EXECUTING:[35][SELECT 'first complex command' as a] +[CS_TEXT_REPRESENTATION] + [meta] rows: 1 + [meta] cols: 1 + [meta] server status: 2 + [meta] server status: AUTOCOMMIT + [meta] warning count: 0 + + [meta][field] db name: + [meta][field] table name: + [meta][field] org table name: + [meta][field] col name: a + [meta][field] org col name: + [meta][field] length: 63 + [meta][field] charsetnr: 33 + [meta][field] flags: 1 (NOT_NULL ) + [meta][field] decimals: 31 + [meta][field] type: VARCHAR (15) + + + [meta][charset result] number: 33 + [meta][charset result] name: utf8mb3 + [meta][charset result] collation: utf8_general_ci + [meta][charset result] sort order: + + [data][.a][ 21][first complex command] + + [end] server status: 2 + [end] server status: AUTOCOMMIT + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +[CS_BINARY_REPRESENTATION] + [meta] rows: 1 + [meta] cols: 1 + [meta] server status: 2 + [meta] server status: AUTOCOMMIT + [meta] warning count: 0 + + [meta][field] db name: + [meta][field] table name: + [meta][field] org table name: + [meta][field] col name: a + [meta][field] org col name: + [meta][field] length: 63 + [meta][field] charsetnr: 33 + [meta][field] flags: 1 (NOT_NULL ) + [meta][field] decimals: 31 + [meta][field] type: VARCHAR (15) + + + [meta][charset result] number: 33 + [meta][charset result] name: utf8mb3 + [meta][charset result] collation: utf8_general_ci + [meta][charset result] sort order: + + [data][.a][ 21][first complex command] + + [end] server status: 2 + [end] server status: AUTOCOMMIT + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +------------------------------------------------------------------ +EXECUTING:[21][CREATE DATABASE test1] +[CS_TEXT_REPRESENTATION] + [meta] rows: 0 + [meta] cols: 0 + [meta] server status: 0 + [meta] server status: + [meta] warning count: 0 + + [meta] no columns + + [meta] no charset + + [data] no rows + + [end] server status: 2 + [end] server status: AUTOCOMMIT + [end] warning count: 0 + [end] affected rows: 1 + [end] last insert id: 0 + [end] message: +------------------------------------------------------------------ +EXECUTING:[8][USE test] +[CS_TEXT_REPRESENTATION] + [meta] rows: 0 + [meta] cols: 0 + [meta] server status: 0 + [meta] server status: + [meta] warning count: 0 + + [meta] no columns + + [meta] no charset + + [data] no rows + + [end] server status: 2 + [end] server status: AUTOCOMMIT + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +------------------------------------------------------------------ +EXECUTING:[343][CREATE TABLE test_inserts( a INT UNSIGNED, b VARCHAR(100), c DOUBLE, d INT, e FLOAT,f DATETIME, g DATE, h TIME, i TINYINT, k TINYINT UNSIGNED,l SMALLINT, m SMALLINT UNSIGNED, n MEDIUMINT, o MEDIUMINT UNSIGNED,p INTEGER, q INTEGER UNSIGNED, r BIGINT, s BIGINT UNSIGNED,t YEAR, u DECIMAL(5,2) UNSIGNED, v DECIMAL(5,2), PRIMARY KEY(a), INDEX(d));] +[CS_TEXT_REPRESENTATION] + [meta] rows: 0 + [meta] cols: 0 + [meta] server status: 0 + [meta] server status: + [meta] warning count: 0 + + [meta] no columns + + [meta] no charset + + [data] no rows + + [end] server status: 2 + [end] server status: AUTOCOMMIT + [end] warning count: 1 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +------------------------------------------------------------------ +EXECUTING:[244][INSERT INTO test_inserts VALUES (1, 'one', 1.23, -1, 11.2323, '2014-07-06 07:06:05', '1980-02-19', '-830:12:23', 127, 255, 32767, 65535, 8388607, 16777215, 2147483647, 4294967295, 9223372036854775807, 18446744073709551615,1901, 999.99, -999.99)] +[CS_TEXT_REPRESENTATION] + [meta] rows: 0 + [meta] cols: 0 + [meta] server status: 0 + [meta] server status: + [meta] warning count: 0 + + [meta] no columns + + [meta] no charset + + [data] no rows + + [end] server status: 2 + [end] server status: AUTOCOMMIT + [end] warning count: 0 + [end] affected rows: 1 + [end] last insert id: 0 + [end] message: +------------------------------------------------------------------ +EXECUTING:[236][INSERT INTO test_inserts VALUES (2, 'two', 2.34, -2, 22.3434, '2015-07-06 21:22:23', '2014-06-05', '356:22:33', -128, 0, -32768, 32768, -8388608, 8388607, -2147483648, 0, -9223372036854775808, 18446744073709551615,2039, 123.45, -543.21)] +[CS_TEXT_REPRESENTATION] + [meta] rows: 0 + [meta] cols: 0 + [meta] server status: 0 + [meta] server status: + [meta] warning count: 0 + + [meta] no columns + + [meta] no charset + + [data] no rows + + [end] server status: 2 + [end] server status: AUTOCOMMIT + [end] warning count: 0 + [end] affected rows: 1 + [end] last insert id: 0 + [end] message: +------------------------------------------------------------------ +EXECUTING:[179][INSERT INTO test_inserts VALUES (3, 'three',3.45,-3, 33.4545, '2016-09-12 11:12:13', '2013-05-04', '821:33:44', -1, 128, -1, 65534, -1, 16777214, 1, 2, 3, 4,2155, 222.22, -567.89)] +[CS_TEXT_REPRESENTATION] + [meta] rows: 0 + [meta] cols: 0 + [meta] server status: 0 + [meta] server status: + [meta] warning count: 0 + + [meta] no columns + + [meta] no charset + + [data] no rows + + [end] server status: 2 + [end] server status: AUTOCOMMIT + [end] warning count: 0 + [end] affected rows: 1 + [end] last insert id: 0 + [end] message: +------------------------------------------------------------------ +EXECUTING:[43][SELECT * FROM test1.test_inserts ORDER BY a] +[CS_TEXT_REPRESENTATION] + [meta] rows: 3 + [meta] cols: 21 + [meta] server status: 2 + [meta] server status: AUTOCOMMIT + [meta] warning count: 0 + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: a + [meta][field] org col name: a + [meta][field] length: 10 + [meta][field] charsetnr: 8 + [meta][field] flags: 4129 (NOT_NULL UNSIGNED NO_DEFAULT_VALUE ) + [meta][field] decimals: 0 + [meta][field] type: LONG (3) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: b + [meta][field] org col name: b + [meta][field] length: 400 + [meta][field] charsetnr: 255 + [meta][field] flags: 0 + [meta][field] decimals: 0 + [meta][field] type: VARCHAR (15) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: c + [meta][field] org col name: c + [meta][field] length: 22 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 31 + [meta][field] type: DOUBLE (5) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: d + [meta][field] org col name: d + [meta][field] length: 11 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 0 + [meta][field] type: LONG (3) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: e + [meta][field] org col name: e + [meta][field] length: 12 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 31 + [meta][field] type: FLOAT (4) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: f + [meta][field] org col name: f + [meta][field] length: 19 + [meta][field] charsetnr: 8 + [meta][field] flags: 128 (BINARY ) + [meta][field] decimals: 0 + [meta][field] type: DATETIME (12) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: g + [meta][field] org col name: g + [meta][field] length: 10 + [meta][field] charsetnr: 8 + [meta][field] flags: 128 (BINARY ) + [meta][field] decimals: 0 + [meta][field] type: DATE (10) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: h + [meta][field] org col name: h + [meta][field] length: 10 + [meta][field] charsetnr: 8 + [meta][field] flags: 128 (BINARY ) + [meta][field] decimals: 0 + [meta][field] type: TIME (11) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: i + [meta][field] org col name: i + [meta][field] length: 4 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 0 + [meta][field] type: TINY (1) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: k + [meta][field] org col name: k + [meta][field] length: 3 + [meta][field] charsetnr: 8 + [meta][field] flags: 32 (UNSIGNED ) + [meta][field] decimals: 0 + [meta][field] type: TINY (1) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: l + [meta][field] org col name: l + [meta][field] length: 6 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 0 + [meta][field] type: SHORT (2) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: m + [meta][field] org col name: m + [meta][field] length: 5 + [meta][field] charsetnr: 8 + [meta][field] flags: 32 (UNSIGNED ) + [meta][field] decimals: 0 + [meta][field] type: SHORT (2) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: n + [meta][field] org col name: n + [meta][field] length: 9 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 0 + [meta][field] type: INT24 (9) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: o + [meta][field] org col name: o + [meta][field] length: 8 + [meta][field] charsetnr: 8 + [meta][field] flags: 32 (UNSIGNED ) + [meta][field] decimals: 0 + [meta][field] type: INT24 (9) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: p + [meta][field] org col name: p + [meta][field] length: 11 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 0 + [meta][field] type: LONG (3) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: q + [meta][field] org col name: q + [meta][field] length: 10 + [meta][field] charsetnr: 8 + [meta][field] flags: 32 (UNSIGNED ) + [meta][field] decimals: 0 + [meta][field] type: LONG (3) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: r + [meta][field] org col name: r + [meta][field] length: 20 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 0 + [meta][field] type: LONGLONG (8) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: s + [meta][field] org col name: s + [meta][field] length: 20 + [meta][field] charsetnr: 8 + [meta][field] flags: 32 (UNSIGNED ) + [meta][field] decimals: 0 + [meta][field] type: LONGLONG (8) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: t + [meta][field] org col name: t + [meta][field] length: 4 + [meta][field] charsetnr: 8 + [meta][field] flags: 96 (UNSIGNED ZEROFILL ) + [meta][field] decimals: 0 + [meta][field] type: YEAR (13) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: u + [meta][field] org col name: u + [meta][field] length: 6 + [meta][field] charsetnr: 8 + [meta][field] flags: 32 (UNSIGNED ) + [meta][field] decimals: 2 + [meta][field] type: NEWDECIMAL (246) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: v + [meta][field] org col name: v + [meta][field] length: 7 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 2 + [meta][field] type: NEWDECIMAL (246) + + + [meta][charset result] number: 33 + [meta][charset result] name: utf8mb3 + [meta][charset result] collation: utf8_general_ci + [meta][charset result] sort order: + + [data][test_inserts.a][ 1][1] + [data][test_inserts.b][ 3][one] + [data][test_inserts.c][ 4][1.23] + [data][test_inserts.d][ 2][-1] + [data][test_inserts.e][ 7][11.2323] + [data][test_inserts.f][ 19][2014-07-06 07:06:05] + [data][test_inserts.g][ 10][1980-02-19] + [data][test_inserts.h][ 10][-830:12:23] + [data][test_inserts.i][ 3][127] + [data][test_inserts.k][ 3][255] + [data][test_inserts.l][ 5][32767] + [data][test_inserts.m][ 5][65535] + [data][test_inserts.n][ 7][8388607] + [data][test_inserts.o][ 8][16777215] + [data][test_inserts.p][ 10][2147483647] + [data][test_inserts.q][ 10][4294967295] + [data][test_inserts.r][ 19][9223372036854775807] + [data][test_inserts.s][ 20][18446744073709551615] + [data][test_inserts.t][ 4][1901] + [data][test_inserts.u][ 6][999.99] + [data][test_inserts.v][ 7][-999.99] + + [data][test_inserts.a][ 1][2] + [data][test_inserts.b][ 3][two] + [data][test_inserts.c][ 4][2.34] + [data][test_inserts.d][ 2][-2] + [data][test_inserts.e][ 7][22.3434] + [data][test_inserts.f][ 19][2015-07-06 21:22:23] + [data][test_inserts.g][ 10][2014-06-05] + [data][test_inserts.h][ 9][356:22:33] + [data][test_inserts.i][ 4][-128] + [data][test_inserts.k][ 1][0] + [data][test_inserts.l][ 6][-32768] + [data][test_inserts.m][ 5][32768] + [data][test_inserts.n][ 8][-8388608] + [data][test_inserts.o][ 7][8388607] + [data][test_inserts.p][ 11][-2147483648] + [data][test_inserts.q][ 1][0] + [data][test_inserts.r][ 20][-9223372036854775808] + [data][test_inserts.s][ 20][18446744073709551615] + [data][test_inserts.t][ 4][2039] + [data][test_inserts.u][ 6][123.45] + [data][test_inserts.v][ 7][-543.21] + + [data][test_inserts.a][ 1][3] + [data][test_inserts.b][ 5][three] + [data][test_inserts.c][ 4][3.45] + [data][test_inserts.d][ 2][-3] + [data][test_inserts.e][ 7][33.4545] + [data][test_inserts.f][ 19][2016-09-12 11:12:13] + [data][test_inserts.g][ 10][2013-05-04] + [data][test_inserts.h][ 9][821:33:44] + [data][test_inserts.i][ 2][-1] + [data][test_inserts.k][ 3][128] + [data][test_inserts.l][ 2][-1] + [data][test_inserts.m][ 5][65534] + [data][test_inserts.n][ 2][-1] + [data][test_inserts.o][ 8][16777214] + [data][test_inserts.p][ 1][1] + [data][test_inserts.q][ 1][2] + [data][test_inserts.r][ 1][3] + [data][test_inserts.s][ 1][4] + [data][test_inserts.t][ 4][2155] + [data][test_inserts.u][ 6][222.22] + [data][test_inserts.v][ 7][-567.89] + + [end] server status: 2 + [end] server status: AUTOCOMMIT + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +[CS_BINARY_REPRESENTATION] + [meta] rows: 3 + [meta] cols: 21 + [meta] server status: 2 + [meta] server status: AUTOCOMMIT + [meta] warning count: 0 + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: a + [meta][field] org col name: a + [meta][field] length: 10 + [meta][field] charsetnr: 8 + [meta][field] flags: 4129 (NOT_NULL UNSIGNED NO_DEFAULT_VALUE ) + [meta][field] decimals: 0 + [meta][field] type: LONG (3) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: b + [meta][field] org col name: b + [meta][field] length: 400 + [meta][field] charsetnr: 255 + [meta][field] flags: 0 + [meta][field] decimals: 0 + [meta][field] type: VARCHAR (15) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: c + [meta][field] org col name: c + [meta][field] length: 22 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 31 + [meta][field] type: DOUBLE (5) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: d + [meta][field] org col name: d + [meta][field] length: 11 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 0 + [meta][field] type: LONG (3) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: e + [meta][field] org col name: e + [meta][field] length: 12 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 31 + [meta][field] type: FLOAT (4) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: f + [meta][field] org col name: f + [meta][field] length: 19 + [meta][field] charsetnr: 8 + [meta][field] flags: 128 (BINARY ) + [meta][field] decimals: 0 + [meta][field] type: DATETIME (12) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: g + [meta][field] org col name: g + [meta][field] length: 10 + [meta][field] charsetnr: 8 + [meta][field] flags: 128 (BINARY ) + [meta][field] decimals: 0 + [meta][field] type: DATE (10) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: h + [meta][field] org col name: h + [meta][field] length: 10 + [meta][field] charsetnr: 8 + [meta][field] flags: 128 (BINARY ) + [meta][field] decimals: 0 + [meta][field] type: TIME (11) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: i + [meta][field] org col name: i + [meta][field] length: 4 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 0 + [meta][field] type: TINY (1) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: k + [meta][field] org col name: k + [meta][field] length: 3 + [meta][field] charsetnr: 8 + [meta][field] flags: 32 (UNSIGNED ) + [meta][field] decimals: 0 + [meta][field] type: TINY (1) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: l + [meta][field] org col name: l + [meta][field] length: 6 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 0 + [meta][field] type: SHORT (2) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: m + [meta][field] org col name: m + [meta][field] length: 5 + [meta][field] charsetnr: 8 + [meta][field] flags: 32 (UNSIGNED ) + [meta][field] decimals: 0 + [meta][field] type: SHORT (2) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: n + [meta][field] org col name: n + [meta][field] length: 9 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 0 + [meta][field] type: INT24 (9) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: o + [meta][field] org col name: o + [meta][field] length: 8 + [meta][field] charsetnr: 8 + [meta][field] flags: 32 (UNSIGNED ) + [meta][field] decimals: 0 + [meta][field] type: INT24 (9) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: p + [meta][field] org col name: p + [meta][field] length: 11 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 0 + [meta][field] type: LONG (3) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: q + [meta][field] org col name: q + [meta][field] length: 10 + [meta][field] charsetnr: 8 + [meta][field] flags: 32 (UNSIGNED ) + [meta][field] decimals: 0 + [meta][field] type: LONG (3) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: r + [meta][field] org col name: r + [meta][field] length: 20 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 0 + [meta][field] type: LONGLONG (8) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: s + [meta][field] org col name: s + [meta][field] length: 20 + [meta][field] charsetnr: 8 + [meta][field] flags: 32 (UNSIGNED ) + [meta][field] decimals: 0 + [meta][field] type: LONGLONG (8) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: t + [meta][field] org col name: t + [meta][field] length: 4 + [meta][field] charsetnr: 8 + [meta][field] flags: 96 (UNSIGNED ZEROFILL ) + [meta][field] decimals: 0 + [meta][field] type: YEAR (13) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: u + [meta][field] org col name: u + [meta][field] length: 6 + [meta][field] charsetnr: 8 + [meta][field] flags: 32 (UNSIGNED ) + [meta][field] decimals: 2 + [meta][field] type: NEWDECIMAL (246) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: v + [meta][field] org col name: v + [meta][field] length: 7 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 2 + [meta][field] type: NEWDECIMAL (246) + + + [meta][charset result] number: 33 + [meta][charset result] name: utf8mb3 + [meta][charset result] collation: utf8_general_ci + [meta][charset result] sort order: + + [data][test_inserts.a][ 1][1] + [data][test_inserts.b][ 3][one] + [data][test_inserts.c][ 4][1.23] + [data][test_inserts.d][ 2][-1] + [data][test_inserts.e][ 7][11.2323] + [data][test_inserts.f][ 19][2014-07-06 07:06:05] + [data][test_inserts.g][ 10][1980-02-19] + [data][test_inserts.h][ 10][-830:12:23] + [data][test_inserts.i][ 3][127] + [data][test_inserts.k][ 3][255] + [data][test_inserts.l][ 5][32767] + [data][test_inserts.m][ 5][65535] + [data][test_inserts.n][ 7][8388607] + [data][test_inserts.o][ 8][16777215] + [data][test_inserts.p][ 10][2147483647] + [data][test_inserts.q][ 10][4294967295] + [data][test_inserts.r][ 19][9223372036854775807] + [data][test_inserts.s][ 20][18446744073709551615] + [data][test_inserts.t][ 4][1901] + [data][test_inserts.u][ 6][999.99] + [data][test_inserts.v][ 7][-999.99] + + [data][test_inserts.a][ 1][2] + [data][test_inserts.b][ 3][two] + [data][test_inserts.c][ 4][2.34] + [data][test_inserts.d][ 2][-2] + [data][test_inserts.e][ 7][22.3434] + [data][test_inserts.f][ 19][2015-07-06 21:22:23] + [data][test_inserts.g][ 10][2014-06-05] + [data][test_inserts.h][ 9][356:22:33] + [data][test_inserts.i][ 4][-128] + [data][test_inserts.k][ 1][0] + [data][test_inserts.l][ 6][-32768] + [data][test_inserts.m][ 5][32768] + [data][test_inserts.n][ 8][-8388608] + [data][test_inserts.o][ 7][8388607] + [data][test_inserts.p][ 11][-2147483648] + [data][test_inserts.q][ 1][0] + [data][test_inserts.r][ 20][-9223372036854775808] + [data][test_inserts.s][ 20][18446744073709551615] + [data][test_inserts.t][ 4][2039] + [data][test_inserts.u][ 6][123.45] + [data][test_inserts.v][ 7][-543.21] + + [data][test_inserts.a][ 1][3] + [data][test_inserts.b][ 5][three] + [data][test_inserts.c][ 4][3.45] + [data][test_inserts.d][ 2][-3] + [data][test_inserts.e][ 7][33.4545] + [data][test_inserts.f][ 19][2016-09-12 11:12:13] + [data][test_inserts.g][ 10][2013-05-04] + [data][test_inserts.h][ 9][821:33:44] + [data][test_inserts.i][ 2][-1] + [data][test_inserts.k][ 3][128] + [data][test_inserts.l][ 2][-1] + [data][test_inserts.m][ 5][65534] + [data][test_inserts.n][ 2][-1] + [data][test_inserts.o][ 8][16777214] + [data][test_inserts.p][ 1][1] + [data][test_inserts.q][ 1][2] + [data][test_inserts.r][ 1][3] + [data][test_inserts.s][ 1][4] + [data][test_inserts.t][ 4][2155] + [data][test_inserts.u][ 6][222.22] + [data][test_inserts.v][ 7][-567.89] + + [end] server status: 2 + [end] server status: AUTOCOMMIT + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +------------------------------------------------------------------ +EXECUTING:[34][DELETE FROM test_inserts WHERE a=2] +[CS_TEXT_REPRESENTATION] + [meta] rows: 0 + [meta] cols: 0 + [meta] server status: 0 + [meta] server status: + [meta] warning count: 0 + + [meta] no columns + + [meta] no charset + + [data] no rows + + [end] server status: 2 + [end] server status: AUTOCOMMIT + [end] warning count: 0 + [end] affected rows: 1 + [end] last insert id: 0 + [end] message: +------------------------------------------------------------------ +EXECUTING:[37][SELECT * FROM test_inserts ORDER BY a] +[CS_TEXT_REPRESENTATION] + [meta] rows: 2 + [meta] cols: 21 + [meta] server status: 2 + [meta] server status: AUTOCOMMIT + [meta] warning count: 0 + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: a + [meta][field] org col name: a + [meta][field] length: 10 + [meta][field] charsetnr: 8 + [meta][field] flags: 4129 (NOT_NULL UNSIGNED NO_DEFAULT_VALUE ) + [meta][field] decimals: 0 + [meta][field] type: LONG (3) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: b + [meta][field] org col name: b + [meta][field] length: 400 + [meta][field] charsetnr: 255 + [meta][field] flags: 0 + [meta][field] decimals: 0 + [meta][field] type: VARCHAR (15) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: c + [meta][field] org col name: c + [meta][field] length: 22 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 31 + [meta][field] type: DOUBLE (5) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: d + [meta][field] org col name: d + [meta][field] length: 11 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 0 + [meta][field] type: LONG (3) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: e + [meta][field] org col name: e + [meta][field] length: 12 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 31 + [meta][field] type: FLOAT (4) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: f + [meta][field] org col name: f + [meta][field] length: 19 + [meta][field] charsetnr: 8 + [meta][field] flags: 128 (BINARY ) + [meta][field] decimals: 0 + [meta][field] type: DATETIME (12) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: g + [meta][field] org col name: g + [meta][field] length: 10 + [meta][field] charsetnr: 8 + [meta][field] flags: 128 (BINARY ) + [meta][field] decimals: 0 + [meta][field] type: DATE (10) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: h + [meta][field] org col name: h + [meta][field] length: 10 + [meta][field] charsetnr: 8 + [meta][field] flags: 128 (BINARY ) + [meta][field] decimals: 0 + [meta][field] type: TIME (11) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: i + [meta][field] org col name: i + [meta][field] length: 4 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 0 + [meta][field] type: TINY (1) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: k + [meta][field] org col name: k + [meta][field] length: 3 + [meta][field] charsetnr: 8 + [meta][field] flags: 32 (UNSIGNED ) + [meta][field] decimals: 0 + [meta][field] type: TINY (1) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: l + [meta][field] org col name: l + [meta][field] length: 6 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 0 + [meta][field] type: SHORT (2) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: m + [meta][field] org col name: m + [meta][field] length: 5 + [meta][field] charsetnr: 8 + [meta][field] flags: 32 (UNSIGNED ) + [meta][field] decimals: 0 + [meta][field] type: SHORT (2) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: n + [meta][field] org col name: n + [meta][field] length: 9 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 0 + [meta][field] type: INT24 (9) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: o + [meta][field] org col name: o + [meta][field] length: 8 + [meta][field] charsetnr: 8 + [meta][field] flags: 32 (UNSIGNED ) + [meta][field] decimals: 0 + [meta][field] type: INT24 (9) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: p + [meta][field] org col name: p + [meta][field] length: 11 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 0 + [meta][field] type: LONG (3) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: q + [meta][field] org col name: q + [meta][field] length: 10 + [meta][field] charsetnr: 8 + [meta][field] flags: 32 (UNSIGNED ) + [meta][field] decimals: 0 + [meta][field] type: LONG (3) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: r + [meta][field] org col name: r + [meta][field] length: 20 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 0 + [meta][field] type: LONGLONG (8) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: s + [meta][field] org col name: s + [meta][field] length: 20 + [meta][field] charsetnr: 8 + [meta][field] flags: 32 (UNSIGNED ) + [meta][field] decimals: 0 + [meta][field] type: LONGLONG (8) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: t + [meta][field] org col name: t + [meta][field] length: 4 + [meta][field] charsetnr: 8 + [meta][field] flags: 96 (UNSIGNED ZEROFILL ) + [meta][field] decimals: 0 + [meta][field] type: YEAR (13) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: u + [meta][field] org col name: u + [meta][field] length: 6 + [meta][field] charsetnr: 8 + [meta][field] flags: 32 (UNSIGNED ) + [meta][field] decimals: 2 + [meta][field] type: NEWDECIMAL (246) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: v + [meta][field] org col name: v + [meta][field] length: 7 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 2 + [meta][field] type: NEWDECIMAL (246) + + + [meta][charset result] number: 33 + [meta][charset result] name: utf8mb3 + [meta][charset result] collation: utf8_general_ci + [meta][charset result] sort order: + + [data][test_inserts.a][ 1][1] + [data][test_inserts.b][ 3][one] + [data][test_inserts.c][ 4][1.23] + [data][test_inserts.d][ 2][-1] + [data][test_inserts.e][ 7][11.2323] + [data][test_inserts.f][ 19][2014-07-06 07:06:05] + [data][test_inserts.g][ 10][1980-02-19] + [data][test_inserts.h][ 10][-830:12:23] + [data][test_inserts.i][ 3][127] + [data][test_inserts.k][ 3][255] + [data][test_inserts.l][ 5][32767] + [data][test_inserts.m][ 5][65535] + [data][test_inserts.n][ 7][8388607] + [data][test_inserts.o][ 8][16777215] + [data][test_inserts.p][ 10][2147483647] + [data][test_inserts.q][ 10][4294967295] + [data][test_inserts.r][ 19][9223372036854775807] + [data][test_inserts.s][ 20][18446744073709551615] + [data][test_inserts.t][ 4][1901] + [data][test_inserts.u][ 6][999.99] + [data][test_inserts.v][ 7][-999.99] + + [data][test_inserts.a][ 1][3] + [data][test_inserts.b][ 5][three] + [data][test_inserts.c][ 4][3.45] + [data][test_inserts.d][ 2][-3] + [data][test_inserts.e][ 7][33.4545] + [data][test_inserts.f][ 19][2016-09-12 11:12:13] + [data][test_inserts.g][ 10][2013-05-04] + [data][test_inserts.h][ 9][821:33:44] + [data][test_inserts.i][ 2][-1] + [data][test_inserts.k][ 3][128] + [data][test_inserts.l][ 2][-1] + [data][test_inserts.m][ 5][65534] + [data][test_inserts.n][ 2][-1] + [data][test_inserts.o][ 8][16777214] + [data][test_inserts.p][ 1][1] + [data][test_inserts.q][ 1][2] + [data][test_inserts.r][ 1][3] + [data][test_inserts.s][ 1][4] + [data][test_inserts.t][ 4][2155] + [data][test_inserts.u][ 6][222.22] + [data][test_inserts.v][ 7][-567.89] + + [end] server status: 2 + [end] server status: AUTOCOMMIT + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +[CS_BINARY_REPRESENTATION] + [meta] rows: 2 + [meta] cols: 21 + [meta] server status: 2 + [meta] server status: AUTOCOMMIT + [meta] warning count: 0 + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: a + [meta][field] org col name: a + [meta][field] length: 10 + [meta][field] charsetnr: 8 + [meta][field] flags: 4129 (NOT_NULL UNSIGNED NO_DEFAULT_VALUE ) + [meta][field] decimals: 0 + [meta][field] type: LONG (3) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: b + [meta][field] org col name: b + [meta][field] length: 400 + [meta][field] charsetnr: 255 + [meta][field] flags: 0 + [meta][field] decimals: 0 + [meta][field] type: VARCHAR (15) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: c + [meta][field] org col name: c + [meta][field] length: 22 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 31 + [meta][field] type: DOUBLE (5) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: d + [meta][field] org col name: d + [meta][field] length: 11 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 0 + [meta][field] type: LONG (3) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: e + [meta][field] org col name: e + [meta][field] length: 12 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 31 + [meta][field] type: FLOAT (4) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: f + [meta][field] org col name: f + [meta][field] length: 19 + [meta][field] charsetnr: 8 + [meta][field] flags: 128 (BINARY ) + [meta][field] decimals: 0 + [meta][field] type: DATETIME (12) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: g + [meta][field] org col name: g + [meta][field] length: 10 + [meta][field] charsetnr: 8 + [meta][field] flags: 128 (BINARY ) + [meta][field] decimals: 0 + [meta][field] type: DATE (10) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: h + [meta][field] org col name: h + [meta][field] length: 10 + [meta][field] charsetnr: 8 + [meta][field] flags: 128 (BINARY ) + [meta][field] decimals: 0 + [meta][field] type: TIME (11) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: i + [meta][field] org col name: i + [meta][field] length: 4 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 0 + [meta][field] type: TINY (1) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: k + [meta][field] org col name: k + [meta][field] length: 3 + [meta][field] charsetnr: 8 + [meta][field] flags: 32 (UNSIGNED ) + [meta][field] decimals: 0 + [meta][field] type: TINY (1) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: l + [meta][field] org col name: l + [meta][field] length: 6 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 0 + [meta][field] type: SHORT (2) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: m + [meta][field] org col name: m + [meta][field] length: 5 + [meta][field] charsetnr: 8 + [meta][field] flags: 32 (UNSIGNED ) + [meta][field] decimals: 0 + [meta][field] type: SHORT (2) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: n + [meta][field] org col name: n + [meta][field] length: 9 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 0 + [meta][field] type: INT24 (9) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: o + [meta][field] org col name: o + [meta][field] length: 8 + [meta][field] charsetnr: 8 + [meta][field] flags: 32 (UNSIGNED ) + [meta][field] decimals: 0 + [meta][field] type: INT24 (9) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: p + [meta][field] org col name: p + [meta][field] length: 11 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 0 + [meta][field] type: LONG (3) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: q + [meta][field] org col name: q + [meta][field] length: 10 + [meta][field] charsetnr: 8 + [meta][field] flags: 32 (UNSIGNED ) + [meta][field] decimals: 0 + [meta][field] type: LONG (3) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: r + [meta][field] org col name: r + [meta][field] length: 20 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 0 + [meta][field] type: LONGLONG (8) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: s + [meta][field] org col name: s + [meta][field] length: 20 + [meta][field] charsetnr: 8 + [meta][field] flags: 32 (UNSIGNED ) + [meta][field] decimals: 0 + [meta][field] type: LONGLONG (8) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: t + [meta][field] org col name: t + [meta][field] length: 4 + [meta][field] charsetnr: 8 + [meta][field] flags: 96 (UNSIGNED ZEROFILL ) + [meta][field] decimals: 0 + [meta][field] type: YEAR (13) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: u + [meta][field] org col name: u + [meta][field] length: 6 + [meta][field] charsetnr: 8 + [meta][field] flags: 32 (UNSIGNED ) + [meta][field] decimals: 2 + [meta][field] type: NEWDECIMAL (246) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: v + [meta][field] org col name: v + [meta][field] length: 7 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 2 + [meta][field] type: NEWDECIMAL (246) + + + [meta][charset result] number: 33 + [meta][charset result] name: utf8mb3 + [meta][charset result] collation: utf8_general_ci + [meta][charset result] sort order: + + [data][test_inserts.a][ 1][1] + [data][test_inserts.b][ 3][one] + [data][test_inserts.c][ 4][1.23] + [data][test_inserts.d][ 2][-1] + [data][test_inserts.e][ 7][11.2323] + [data][test_inserts.f][ 19][2014-07-06 07:06:05] + [data][test_inserts.g][ 10][1980-02-19] + [data][test_inserts.h][ 10][-830:12:23] + [data][test_inserts.i][ 3][127] + [data][test_inserts.k][ 3][255] + [data][test_inserts.l][ 5][32767] + [data][test_inserts.m][ 5][65535] + [data][test_inserts.n][ 7][8388607] + [data][test_inserts.o][ 8][16777215] + [data][test_inserts.p][ 10][2147483647] + [data][test_inserts.q][ 10][4294967295] + [data][test_inserts.r][ 19][9223372036854775807] + [data][test_inserts.s][ 20][18446744073709551615] + [data][test_inserts.t][ 4][1901] + [data][test_inserts.u][ 6][999.99] + [data][test_inserts.v][ 7][-999.99] + + [data][test_inserts.a][ 1][3] + [data][test_inserts.b][ 5][three] + [data][test_inserts.c][ 4][3.45] + [data][test_inserts.d][ 2][-3] + [data][test_inserts.e][ 7][33.4545] + [data][test_inserts.f][ 19][2016-09-12 11:12:13] + [data][test_inserts.g][ 10][2013-05-04] + [data][test_inserts.h][ 9][821:33:44] + [data][test_inserts.i][ 2][-1] + [data][test_inserts.k][ 3][128] + [data][test_inserts.l][ 2][-1] + [data][test_inserts.m][ 5][65534] + [data][test_inserts.n][ 2][-1] + [data][test_inserts.o][ 8][16777214] + [data][test_inserts.p][ 1][1] + [data][test_inserts.q][ 1][2] + [data][test_inserts.r][ 1][3] + [data][test_inserts.s][ 1][4] + [data][test_inserts.t][ 4][2155] + [data][test_inserts.u][ 6][222.22] + [data][test_inserts.v][ 7][-567.89] + + [end] server status: 2 + [end] server status: AUTOCOMMIT + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +------------------------------------------------------------------ +EXECUTING:[21][TRUNCATE test_inserts] +[CS_TEXT_REPRESENTATION] + [meta] rows: 0 + [meta] cols: 0 + [meta] server status: 0 + [meta] server status: + [meta] warning count: 0 + + [meta] no columns + + [meta] no charset + + [data] no rows + + [end] server status: 2 + [end] server status: AUTOCOMMIT + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +------------------------------------------------------------------ +EXECUTING:[37][SELECT * FROM test_inserts ORDER BY a] +[CS_TEXT_REPRESENTATION] + [meta] rows: 0 + [meta] cols: 21 + [meta] server status: 2 + [meta] server status: AUTOCOMMIT + [meta] warning count: 0 + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: a + [meta][field] org col name: a + [meta][field] length: 10 + [meta][field] charsetnr: 8 + [meta][field] flags: 4129 (NOT_NULL UNSIGNED NO_DEFAULT_VALUE ) + [meta][field] decimals: 0 + [meta][field] type: LONG (3) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: b + [meta][field] org col name: b + [meta][field] length: 400 + [meta][field] charsetnr: 255 + [meta][field] flags: 0 + [meta][field] decimals: 0 + [meta][field] type: VARCHAR (15) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: c + [meta][field] org col name: c + [meta][field] length: 22 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 31 + [meta][field] type: DOUBLE (5) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: d + [meta][field] org col name: d + [meta][field] length: 11 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 0 + [meta][field] type: LONG (3) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: e + [meta][field] org col name: e + [meta][field] length: 12 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 31 + [meta][field] type: FLOAT (4) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: f + [meta][field] org col name: f + [meta][field] length: 19 + [meta][field] charsetnr: 8 + [meta][field] flags: 128 (BINARY ) + [meta][field] decimals: 0 + [meta][field] type: DATETIME (12) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: g + [meta][field] org col name: g + [meta][field] length: 10 + [meta][field] charsetnr: 8 + [meta][field] flags: 128 (BINARY ) + [meta][field] decimals: 0 + [meta][field] type: DATE (10) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: h + [meta][field] org col name: h + [meta][field] length: 10 + [meta][field] charsetnr: 8 + [meta][field] flags: 128 (BINARY ) + [meta][field] decimals: 0 + [meta][field] type: TIME (11) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: i + [meta][field] org col name: i + [meta][field] length: 4 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 0 + [meta][field] type: TINY (1) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: k + [meta][field] org col name: k + [meta][field] length: 3 + [meta][field] charsetnr: 8 + [meta][field] flags: 32 (UNSIGNED ) + [meta][field] decimals: 0 + [meta][field] type: TINY (1) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: l + [meta][field] org col name: l + [meta][field] length: 6 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 0 + [meta][field] type: SHORT (2) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: m + [meta][field] org col name: m + [meta][field] length: 5 + [meta][field] charsetnr: 8 + [meta][field] flags: 32 (UNSIGNED ) + [meta][field] decimals: 0 + [meta][field] type: SHORT (2) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: n + [meta][field] org col name: n + [meta][field] length: 9 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 0 + [meta][field] type: INT24 (9) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: o + [meta][field] org col name: o + [meta][field] length: 8 + [meta][field] charsetnr: 8 + [meta][field] flags: 32 (UNSIGNED ) + [meta][field] decimals: 0 + [meta][field] type: INT24 (9) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: p + [meta][field] org col name: p + [meta][field] length: 11 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 0 + [meta][field] type: LONG (3) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: q + [meta][field] org col name: q + [meta][field] length: 10 + [meta][field] charsetnr: 8 + [meta][field] flags: 32 (UNSIGNED ) + [meta][field] decimals: 0 + [meta][field] type: LONG (3) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: r + [meta][field] org col name: r + [meta][field] length: 20 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 0 + [meta][field] type: LONGLONG (8) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: s + [meta][field] org col name: s + [meta][field] length: 20 + [meta][field] charsetnr: 8 + [meta][field] flags: 32 (UNSIGNED ) + [meta][field] decimals: 0 + [meta][field] type: LONGLONG (8) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: t + [meta][field] org col name: t + [meta][field] length: 4 + [meta][field] charsetnr: 8 + [meta][field] flags: 96 (UNSIGNED ZEROFILL ) + [meta][field] decimals: 0 + [meta][field] type: YEAR (13) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: u + [meta][field] org col name: u + [meta][field] length: 6 + [meta][field] charsetnr: 8 + [meta][field] flags: 32 (UNSIGNED ) + [meta][field] decimals: 2 + [meta][field] type: NEWDECIMAL (246) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: v + [meta][field] org col name: v + [meta][field] length: 7 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 2 + [meta][field] type: NEWDECIMAL (246) + + + [meta][charset result] number: 33 + [meta][charset result] name: utf8mb3 + [meta][charset result] collation: utf8_general_ci + [meta][charset result] sort order: + + [data] no rows + + [end] server status: 2 + [end] server status: AUTOCOMMIT + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +[CS_BINARY_REPRESENTATION] + [meta] rows: 0 + [meta] cols: 21 + [meta] server status: 2 + [meta] server status: AUTOCOMMIT + [meta] warning count: 0 + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: a + [meta][field] org col name: a + [meta][field] length: 10 + [meta][field] charsetnr: 8 + [meta][field] flags: 4129 (NOT_NULL UNSIGNED NO_DEFAULT_VALUE ) + [meta][field] decimals: 0 + [meta][field] type: LONG (3) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: b + [meta][field] org col name: b + [meta][field] length: 400 + [meta][field] charsetnr: 255 + [meta][field] flags: 0 + [meta][field] decimals: 0 + [meta][field] type: VARCHAR (15) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: c + [meta][field] org col name: c + [meta][field] length: 22 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 31 + [meta][field] type: DOUBLE (5) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: d + [meta][field] org col name: d + [meta][field] length: 11 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 0 + [meta][field] type: LONG (3) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: e + [meta][field] org col name: e + [meta][field] length: 12 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 31 + [meta][field] type: FLOAT (4) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: f + [meta][field] org col name: f + [meta][field] length: 19 + [meta][field] charsetnr: 8 + [meta][field] flags: 128 (BINARY ) + [meta][field] decimals: 0 + [meta][field] type: DATETIME (12) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: g + [meta][field] org col name: g + [meta][field] length: 10 + [meta][field] charsetnr: 8 + [meta][field] flags: 128 (BINARY ) + [meta][field] decimals: 0 + [meta][field] type: DATE (10) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: h + [meta][field] org col name: h + [meta][field] length: 10 + [meta][field] charsetnr: 8 + [meta][field] flags: 128 (BINARY ) + [meta][field] decimals: 0 + [meta][field] type: TIME (11) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: i + [meta][field] org col name: i + [meta][field] length: 4 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 0 + [meta][field] type: TINY (1) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: k + [meta][field] org col name: k + [meta][field] length: 3 + [meta][field] charsetnr: 8 + [meta][field] flags: 32 (UNSIGNED ) + [meta][field] decimals: 0 + [meta][field] type: TINY (1) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: l + [meta][field] org col name: l + [meta][field] length: 6 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 0 + [meta][field] type: SHORT (2) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: m + [meta][field] org col name: m + [meta][field] length: 5 + [meta][field] charsetnr: 8 + [meta][field] flags: 32 (UNSIGNED ) + [meta][field] decimals: 0 + [meta][field] type: SHORT (2) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: n + [meta][field] org col name: n + [meta][field] length: 9 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 0 + [meta][field] type: INT24 (9) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: o + [meta][field] org col name: o + [meta][field] length: 8 + [meta][field] charsetnr: 8 + [meta][field] flags: 32 (UNSIGNED ) + [meta][field] decimals: 0 + [meta][field] type: INT24 (9) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: p + [meta][field] org col name: p + [meta][field] length: 11 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 0 + [meta][field] type: LONG (3) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: q + [meta][field] org col name: q + [meta][field] length: 10 + [meta][field] charsetnr: 8 + [meta][field] flags: 32 (UNSIGNED ) + [meta][field] decimals: 0 + [meta][field] type: LONG (3) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: r + [meta][field] org col name: r + [meta][field] length: 20 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 0 + [meta][field] type: LONGLONG (8) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: s + [meta][field] org col name: s + [meta][field] length: 20 + [meta][field] charsetnr: 8 + [meta][field] flags: 32 (UNSIGNED ) + [meta][field] decimals: 0 + [meta][field] type: LONGLONG (8) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: t + [meta][field] org col name: t + [meta][field] length: 4 + [meta][field] charsetnr: 8 + [meta][field] flags: 96 (UNSIGNED ZEROFILL ) + [meta][field] decimals: 0 + [meta][field] type: YEAR (13) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: u + [meta][field] org col name: u + [meta][field] length: 6 + [meta][field] charsetnr: 8 + [meta][field] flags: 32 (UNSIGNED ) + [meta][field] decimals: 2 + [meta][field] type: NEWDECIMAL (246) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: v + [meta][field] org col name: v + [meta][field] length: 7 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 2 + [meta][field] type: NEWDECIMAL (246) + + + [meta][charset result] number: 33 + [meta][charset result] name: utf8mb3 + [meta][charset result] collation: utf8_general_ci + [meta][charset result] sort order: + + [data] no rows + + [end] server status: 2 + [end] server status: AUTOCOMMIT + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +------------------------------------------------------------------ +EXECUTING:[27][PREPARE ps1 FROM 'select 1'] +[CS_TEXT_REPRESENTATION] + [meta] rows: 0 + [meta] cols: 0 + [meta] server status: 0 + [meta] server status: + [meta] warning count: 0 + + [meta] no columns + + [meta] no charset + + [data] no rows + + [end] server status: 2 + [end] server status: AUTOCOMMIT + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: Statement prepared +------------------------------------------------------------------ +EXECUTING:[11][EXECUTE ps1] +[CS_TEXT_REPRESENTATION] + [meta] rows: 1 + [meta] cols: 1 + [meta] server status: 2 + [meta] server status: AUTOCOMMIT + [meta] warning count: 0 + + [meta][field] db name: + [meta][field] table name: + [meta][field] org table name: + [meta][field] col name: 1 + [meta][field] org col name: + [meta][field] length: 1 + [meta][field] charsetnr: 8 + [meta][field] flags: 129 (NOT_NULL BINARY ) + [meta][field] decimals: 0 + [meta][field] type: LONGLONG (8) + + + [meta][charset result] number: 33 + [meta][charset result] name: utf8mb3 + [meta][charset result] collation: utf8_general_ci + [meta][charset result] sort order: + + [data][.1][ 1][1] + + [end] server status: 2 + [end] server status: AUTOCOMMIT + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +------------------------------------------------------------------ +EXECUTING:[22][DEALLOCATE PREPARE ps1] +[CS_TEXT_REPRESENTATION] + [meta] rows: 0 + [meta] cols: 0 + [meta] server status: 0 + [meta] server status: + [meta] warning count: 0 + + [meta] no columns + + [meta] no charset + + [data] no rows + + [end] server status: 2 + [end] server status: AUTOCOMMIT + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +------------------------------------------------------------------ +EXECUTING:[24][CREATE TABLE tbl (a INT)] +[CS_TEXT_REPRESENTATION] + [meta] rows: 0 + [meta] cols: 0 + [meta] server status: 0 + [meta] server status: + [meta] warning count: 0 + + [meta] no columns + + [meta] no charset + + [data] no rows + + [end] server status: 2 + [end] server status: AUTOCOMMIT + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +------------------------------------------------------------------ +EXECUTING:[55][PREPARE ps1 FROM 'INSERT INTO tbl VALUES (1), (2), (3)'] +[CS_TEXT_REPRESENTATION] + [meta] rows: 0 + [meta] cols: 0 + [meta] server status: 0 + [meta] server status: + [meta] warning count: 0 + + [meta] no columns + + [meta] no charset + + [data] no rows + + [end] server status: 2 + [end] server status: AUTOCOMMIT + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: Statement prepared +------------------------------------------------------------------ +EXECUTING:[11][EXECUTE ps1] +[CS_TEXT_REPRESENTATION] + [meta] rows: 0 + [meta] cols: 0 + [meta] server status: 0 + [meta] server status: + [meta] warning count: 0 + + [meta] no columns + + [meta] no charset + + [data] no rows + + [end] server status: 2 + [end] server status: AUTOCOMMIT + [end] warning count: 0 + [end] affected rows: 3 + [end] last insert id: 0 + [end] message: Records: 3 Duplicates: 0 Warnings: 0 +------------------------------------------------------------------ +EXECUTING:[22][DEALLOCATE PREPARE ps1] +[CS_TEXT_REPRESENTATION] + [meta] rows: 0 + [meta] cols: 0 + [meta] server status: 0 + [meta] server status: + [meta] warning count: 0 + + [meta] no columns + + [meta] no charset + + [data] no rows + + [end] server status: 2 + [end] server status: AUTOCOMMIT + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +------------------------------------------------------------------ +EXECUTING:[46][SELECT IF(SUM(a)=6, 'OK:)', 'FAIL:(') FROM tbl] +[CS_TEXT_REPRESENTATION] + [meta] rows: 1 + [meta] cols: 1 + [meta] server status: 34 + [meta] server status: AUTOCOMMIT QUERY_NO_INDEX_USED + [meta] warning count: 0 + + [meta][field] db name: + [meta][field] table name: + [meta][field] org table name: + [meta][field] col name: IF(SUM(a)=6, 'OK:)', 'FAIL:(') + [meta][field] org col name: + [meta][field] length: 18 + [meta][field] charsetnr: 33 + [meta][field] flags: 1 (NOT_NULL ) + [meta][field] decimals: 31 + [meta][field] type: VARCHAR (15) + + + [meta][charset result] number: 33 + [meta][charset result] name: utf8mb3 + [meta][charset result] collation: utf8_general_ci + [meta][charset result] sort order: + + [data][.IF(SUM(a)=6, 'OK:)', 'FAIL:(')][ 4][OK:)] + + [end] server status: 34 + [end] server status: AUTOCOMMIT QUERY_NO_INDEX_USED + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +------------------------------------------------------------------ +EXECUTING:[22][DEALLOCATE PREPARE ps1] +[CS_TEXT_REPRESENTATION] +[1243][HY000][Unknown prepared statement handler (ps1) given to DEALLOCATE PREPARE] [meta] rows: 0 + [meta] cols: 0 + [meta] server status: 0 + [meta] server status: + [meta] warning count: 0 + + [meta] no columns + + [meta] no charset + + [data] no rows + + [end] server status: 0 + [end] server status: + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +[CS_BINARY_REPRESENTATION] +[1243][HY000][Unknown prepared statement handler (ps1) given to DEALLOCATE PREPARE] [meta] rows: 0 + [meta] cols: 0 + [meta] server status: 0 + [meta] server status: + [meta] warning count: 0 + + [meta] no columns + + [meta] no charset + + [data] no rows + + [end] server status: 0 + [end] server status: + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +------------------------------------------------------------------ +EXECUTING:[7][garbage] +[CS_TEXT_REPRESENTATION] +[1064][42000][You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'garbage' at line 1] [meta] rows: 0 + [meta] cols: 0 + [meta] server status: 0 + [meta] server status: + [meta] warning count: 0 + + [meta] no columns + + [meta] no charset + + [data] no rows + + [end] server status: 0 + [end] server status: + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +[CS_BINARY_REPRESENTATION] +[1064][42000][You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'garbage' at line 1] [meta] rows: 0 + [meta] cols: 0 + [meta] server status: 0 + [meta] server status: + [meta] warning count: 0 + + [meta] no columns + + [meta] no charset + + [data] no rows + + [end] server status: 0 + [end] server status: + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +------------------------------------------------------------------ +EXECUTING:[17][SELECT b FROM tbl] +[CS_TEXT_REPRESENTATION] +[1054][42S22][Unknown column 'b' in 'field list'] [meta] rows: 0 + [meta] cols: 0 + [meta] server status: 0 + [meta] server status: + [meta] warning count: 0 + + [meta] no columns + + [meta] no charset + + [data] no rows + + [end] server status: 0 + [end] server status: + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +[CS_BINARY_REPRESENTATION] +[1054][42S22][Unknown column 'b' in 'field list'] [meta] rows: 0 + [meta] cols: 0 + [meta] server status: 0 + [meta] server status: + [meta] warning count: 0 + + [meta] no columns + + [meta] no charset + + [data] no rows + + [end] server status: 0 + [end] server status: + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +------------------------------------------------------------------ +EXECUTING:[43][ALTER USER bogus@remotehost PASSWORD EXPIRE] +[CS_TEXT_REPRESENTATION] +[1396][HY000][Operation ALTER USER failed for 'bogus'@'remotehost'] [meta] rows: 0 + [meta] cols: 0 + [meta] server status: 0 + [meta] server status: + [meta] warning count: 0 + + [meta] no columns + + [meta] no charset + + [data] no rows + + [end] server status: 0 + [end] server status: + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +[CS_BINARY_REPRESENTATION] +[1396][HY000][Operation ALTER USER failed for 'bogus'@'remotehost'] [meta] rows: 0 + [meta] cols: 0 + [meta] server status: 0 + [meta] server status: + [meta] warning count: 0 + + [meta] no columns + + [meta] no charset + + [data] no rows + + [end] server status: 0 + [end] server status: + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +------------------------------------------------------------------ +EXECUTING:[26][CREATE TABLE tbld (d TIME)] +[CS_TEXT_REPRESENTATION] + [meta] rows: 0 + [meta] cols: 0 + [meta] server status: 0 + [meta] server status: + [meta] warning count: 0 + + [meta] no columns + + [meta] no charset + + [data] no rows + + [end] server status: 2 + [end] server status: AUTOCOMMIT + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +------------------------------------------------------------------ +EXECUTING:[36][INSERT INTO tbld VALUES ('43141231')] +[CS_TEXT_REPRESENTATION] +[1292][22007][Incorrect time value: '43141231' for column 'd' at row 1] [meta] rows: 0 + [meta] cols: 0 + [meta] server status: 0 + [meta] server status: + [meta] warning count: 0 + + [meta] no columns + + [meta] no charset + + [data] no rows + + [end] server status: 0 + [end] server status: + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +[CS_BINARY_REPRESENTATION] +[1292][22007][Incorrect time value: '43141231' for column 'd' at row 1] [meta] rows: 0 + [meta] cols: 0 + [meta] server status: 0 + [meta] server status: + [meta] warning count: 0 + + [meta] no columns + + [meta] no charset + + [data] no rows + + [end] server status: 0 + [end] server status: + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +------------------------------------------------------------------ +EXECUTING:[10][SELECT 1/0] +[CS_TEXT_REPRESENTATION] + [meta] rows: 1 + [meta] cols: 1 + [meta] server status: 2 + [meta] server status: AUTOCOMMIT + [meta] warning count: 0 + + [meta][field] db name: + [meta][field] table name: + [meta][field] org table name: + [meta][field] col name: 1/0 + [meta][field] org col name: + [meta][field] length: 7 + [meta][field] charsetnr: 8 + [meta][field] flags: 128 (BINARY ) + [meta][field] decimals: 4 + [meta][field] type: NEWDECIMAL (246) + + + [meta][charset result] number: 33 + [meta][charset result] name: utf8mb3 + [meta][charset result] collation: utf8_general_ci + [meta][charset result] sort order: + + [data][.1/0][ 6][[NULL]] + + [end] server status: 2 + [end] server status: AUTOCOMMIT + [end] warning count: 1 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +------------------------------------------------------------------ +EXECUTING:[18][UPDATE tbl SET a=5] +[CS_TEXT_REPRESENTATION] + [meta] rows: 0 + [meta] cols: 0 + [meta] server status: 0 + [meta] server status: + [meta] warning count: 0 + + [meta] no columns + + [meta] no charset + + [data] no rows + + [end] server status: 34 + [end] server status: AUTOCOMMIT QUERY_NO_INDEX_USED + [end] warning count: 0 + [end] affected rows: 3 + [end] last insert id: 0 + [end] message: Rows matched: 3 Changed: 3 Warnings: 0 +------------------------------------------------------------------ +EXECUTING:[17][START TRANSACTION] +[CS_TEXT_REPRESENTATION] + [meta] rows: 0 + [meta] cols: 0 + [meta] server status: 0 + [meta] server status: + [meta] warning count: 0 + + [meta] no columns + + [meta] no charset + + [data] no rows + + [end] server status: 3 + [end] server status: IN_TRANS AUTOCOMMIT + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +------------------------------------------------------------------ +EXECUTING:[18][UPDATE tbl SET a=4] +[CS_TEXT_REPRESENTATION] + [meta] rows: 0 + [meta] cols: 0 + [meta] server status: 0 + [meta] server status: + [meta] warning count: 0 + + [meta] no columns + + [meta] no charset + + [data] no rows + + [end] server status: 35 + [end] server status: IN_TRANS AUTOCOMMIT QUERY_NO_INDEX_USED + [end] warning count: 0 + [end] affected rows: 3 + [end] last insert id: 0 + [end] message: Rows matched: 3 Changed: 3 Warnings: 0 +------------------------------------------------------------------ +EXECUTING:[8][ROLLBACK] +[CS_TEXT_REPRESENTATION] + [meta] rows: 0 + [meta] cols: 0 + [meta] server status: 0 + [meta] server status: + [meta] warning count: 0 + + [meta] no columns + + [meta] no charset + + [data] no rows + + [end] server status: 2 + [end] server status: AUTOCOMMIT + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +------------------------------------------------------------------ +EXECUTING:[45][SELECT IF(SUM(a) = 15, 'OK', 'FAIL') FROM tbl] +[CS_TEXT_REPRESENTATION] + [meta] rows: 1 + [meta] cols: 1 + [meta] server status: 34 + [meta] server status: AUTOCOMMIT QUERY_NO_INDEX_USED + [meta] warning count: 0 + + [meta][field] db name: + [meta][field] table name: + [meta][field] org table name: + [meta][field] col name: IF(SUM(a) = 15, 'OK', 'FAIL') + [meta][field] org col name: + [meta][field] length: 12 + [meta][field] charsetnr: 33 + [meta][field] flags: 1 (NOT_NULL ) + [meta][field] decimals: 31 + [meta][field] type: VARCHAR (15) + + + [meta][charset result] number: 33 + [meta][charset result] name: utf8mb3 + [meta][charset result] collation: utf8_general_ci + [meta][charset result] sort order: + + [data][.IF(SUM(a) = 15, 'OK', 'FAIL')][ 2][OK] + + [end] server status: 34 + [end] server status: AUTOCOMMIT QUERY_NO_INDEX_USED + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +------------------------------------------------------------------ +EXECUTING:[17][START TRANSACTION] +[CS_TEXT_REPRESENTATION] + [meta] rows: 0 + [meta] cols: 0 + [meta] server status: 0 + [meta] server status: + [meta] warning count: 0 + + [meta] no columns + + [meta] no charset + + [data] no rows + + [end] server status: 3 + [end] server status: IN_TRANS AUTOCOMMIT + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +------------------------------------------------------------------ +EXECUTING:[18][UPDATE tbl SET a=4] +[CS_TEXT_REPRESENTATION] + [meta] rows: 0 + [meta] cols: 0 + [meta] server status: 0 + [meta] server status: + [meta] warning count: 0 + + [meta] no columns + + [meta] no charset + + [data] no rows + + [end] server status: 35 + [end] server status: IN_TRANS AUTOCOMMIT QUERY_NO_INDEX_USED + [end] warning count: 0 + [end] affected rows: 3 + [end] last insert id: 0 + [end] message: Rows matched: 3 Changed: 3 Warnings: 0 +------------------------------------------------------------------ +EXECUTING:[6][COMMIT] +[CS_TEXT_REPRESENTATION] + [meta] rows: 0 + [meta] cols: 0 + [meta] server status: 0 + [meta] server status: + [meta] warning count: 0 + + [meta] no columns + + [meta] no charset + + [data] no rows + + [end] server status: 2 + [end] server status: AUTOCOMMIT + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +------------------------------------------------------------------ +EXECUTING:[45][SELECT IF(SUM(a) = 12, 'OK', 'FAIL') FROM tbl] +[CS_TEXT_REPRESENTATION] + [meta] rows: 1 + [meta] cols: 1 + [meta] server status: 34 + [meta] server status: AUTOCOMMIT QUERY_NO_INDEX_USED + [meta] warning count: 0 + + [meta][field] db name: + [meta][field] table name: + [meta][field] org table name: + [meta][field] col name: IF(SUM(a) = 12, 'OK', 'FAIL') + [meta][field] org col name: + [meta][field] length: 12 + [meta][field] charsetnr: 33 + [meta][field] flags: 1 (NOT_NULL ) + [meta][field] decimals: 31 + [meta][field] type: VARCHAR (15) + + + [meta][charset result] number: 33 + [meta][charset result] name: utf8mb3 + [meta][charset result] collation: utf8_general_ci + [meta][charset result] sort order: + + [data][.IF(SUM(a) = 12, 'OK', 'FAIL')][ 2][OK] + + [end] server status: 34 + [end] server status: AUTOCOMMIT QUERY_NO_INDEX_USED + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +------------------------------------------------------------------ +EXECUTING:[27][START TRANSACTION READ ONLY] +[CS_TEXT_REPRESENTATION] + [meta] rows: 0 + [meta] cols: 0 + [meta] server status: 0 + [meta] server status: + [meta] warning count: 0 + + [meta] no columns + + [meta] no charset + + [data] no rows + + [end] server status: 8195 + [end] server status: IN_TRANS AUTOCOMMIT IN_TRANS_READONLY + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +------------------------------------------------------------------ +EXECUTING:[18][UPDATE tbl SET a=2] +[CS_TEXT_REPRESENTATION] +[1792][25006][Cannot execute statement in a READ ONLY transaction.] [meta] rows: 0 + [meta] cols: 0 + [meta] server status: 0 + [meta] server status: + [meta] warning count: 0 + + [meta] no columns + + [meta] no charset + + [data] no rows + + [end] server status: 0 + [end] server status: + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +------------------------------------------------------------------ +EXECUTING:[6][COMMIT] +[CS_TEXT_REPRESENTATION] + [meta] rows: 0 + [meta] cols: 0 + [meta] server status: 0 + [meta] server status: + [meta] warning count: 0 + + [meta] no columns + + [meta] no charset + + [data] no rows + + [end] server status: 2 + [end] server status: AUTOCOMMIT + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +------------------------------------------------------------------ +EXECUTING:[45][SELECT IF(SUM(4) = 12, 'OK', 'FAIL') FROM tbl] +[CS_TEXT_REPRESENTATION] + [meta] rows: 1 + [meta] cols: 1 + [meta] server status: 34 + [meta] server status: AUTOCOMMIT QUERY_NO_INDEX_USED + [meta] warning count: 0 + + [meta][field] db name: + [meta][field] table name: + [meta][field] org table name: + [meta][field] col name: IF(SUM(4) = 12, 'OK', 'FAIL') + [meta][field] org col name: + [meta][field] length: 12 + [meta][field] charsetnr: 33 + [meta][field] flags: 1 (NOT_NULL ) + [meta][field] decimals: 31 + [meta][field] type: VARCHAR (15) + + + [meta][charset result] number: 33 + [meta][charset result] name: utf8mb3 + [meta][charset result] collation: utf8_general_ci + [meta][charset result] sort order: + + [data][.IF(SUM(4) = 12, 'OK', 'FAIL')][ 2][OK] + + [end] server status: 34 + [end] server status: AUTOCOMMIT QUERY_NO_INDEX_USED + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +------------------------------------------------------------------ +EXECUTING:[16][SET autocommit=0] +[CS_TEXT_REPRESENTATION] + [meta] rows: 0 + [meta] cols: 0 + [meta] server status: 0 + [meta] server status: + [meta] warning count: 0 + + [meta] no columns + + [meta] no charset + + [data] no rows + + [end] server status: 0 + [end] server status: + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +------------------------------------------------------------------ +EXECUTING:[18][UPDATE tbl SET a=2] +[CS_TEXT_REPRESENTATION] + [meta] rows: 0 + [meta] cols: 0 + [meta] server status: 0 + [meta] server status: + [meta] warning count: 0 + + [meta] no columns + + [meta] no charset + + [data] no rows + + [end] server status: 33 + [end] server status: IN_TRANS QUERY_NO_INDEX_USED + [end] warning count: 0 + [end] affected rows: 3 + [end] last insert id: 0 + [end] message: Rows matched: 3 Changed: 3 Warnings: 0 +------------------------------------------------------------------ +EXECUTING:[8][ROLLBACK] +[CS_TEXT_REPRESENTATION] + [meta] rows: 0 + [meta] cols: 0 + [meta] server status: 0 + [meta] server status: + [meta] warning count: 0 + + [meta] no columns + + [meta] no charset + + [data] no rows + + [end] server status: 0 + [end] server status: + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +------------------------------------------------------------------ +EXECUTING:[45][SELECT IF(SUM(4) = 12, 'OK', 'FAIL') FROM tbl] +[CS_TEXT_REPRESENTATION] + [meta] rows: 1 + [meta] cols: 1 + [meta] server status: 33 + [meta] server status: IN_TRANS QUERY_NO_INDEX_USED + [meta] warning count: 0 + + [meta][field] db name: + [meta][field] table name: + [meta][field] org table name: + [meta][field] col name: IF(SUM(4) = 12, 'OK', 'FAIL') + [meta][field] org col name: + [meta][field] length: 12 + [meta][field] charsetnr: 33 + [meta][field] flags: 1 (NOT_NULL ) + [meta][field] decimals: 31 + [meta][field] type: VARCHAR (15) + + + [meta][charset result] number: 33 + [meta][charset result] name: utf8mb3 + [meta][charset result] collation: utf8_general_ci + [meta][charset result] sort order: + + [data][.IF(SUM(4) = 12, 'OK', 'FAIL')][ 2][OK] + + [end] server status: 33 + [end] server status: IN_TRANS QUERY_NO_INDEX_USED + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +------------------------------------------------------------------ +EXECUTING:[35][set @a=((2) in (select a from tbl))] +[CS_TEXT_REPRESENTATION] + [meta] rows: 0 + [meta] cols: 0 + [meta] server status: 0 + [meta] server status: + [meta] warning count: 0 + + [meta] no columns + + [meta] no charset + + [data] no rows + + [end] server status: 33 + [end] server status: IN_TRANS QUERY_NO_INDEX_USED + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +[CS_BINARY_REPRESENTATION] + [meta] rows: 0 + [meta] cols: 0 + [meta] server status: 0 + [meta] server status: + [meta] warning count: 0 + + [meta] no columns + + [meta] no charset + + [data] no rows + + [end] server status: 33 + [end] server status: IN_TRANS QUERY_NO_INDEX_USED + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +------------------------------------------------------------------ +EXECUTING:[9][SELECT @a] +[CS_TEXT_REPRESENTATION] + [meta] rows: 1 + [meta] cols: 1 + [meta] server status: 1 + [meta] server status: IN_TRANS + [meta] warning count: 0 + + [meta][field] db name: + [meta][field] table name: + [meta][field] org table name: + [meta][field] col name: @a + [meta][field] org col name: + [meta][field] length: 21 + [meta][field] charsetnr: 33 + [meta][field] flags: 128 (BINARY ) + [meta][field] decimals: 0 + [meta][field] type: LONGLONG (8) + + + [meta][charset result] number: 33 + [meta][charset result] name: utf8mb3 + [meta][charset result] collation: utf8_general_ci + [meta][charset result] sort order: + + [data][.@a][ 1][0] + + [end] server status: 1 + [end] server status: IN_TRANS + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +[CS_BINARY_REPRESENTATION] + [meta] rows: 1 + [meta] cols: 1 + [meta] server status: 1 + [meta] server status: IN_TRANS + [meta] warning count: 0 + + [meta][field] db name: + [meta][field] table name: + [meta][field] org table name: + [meta][field] col name: @a + [meta][field] org col name: + [meta][field] length: 21 + [meta][field] charsetnr: 33 + [meta][field] flags: 128 (BINARY ) + [meta][field] decimals: 0 + [meta][field] type: LONGLONG (8) + + + [meta][charset result] number: 33 + [meta][charset result] name: utf8mb3 + [meta][charset result] collation: utf8_general_ci + [meta][charset result] sort order: + + [data][.@a][ 1][0] + + [end] server status: 1 + [end] server status: IN_TRANS + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +------------------------------------------------------------------ +EXECUTING:[9][set @b=42] +[CS_TEXT_REPRESENTATION] + [meta] rows: 0 + [meta] cols: 0 + [meta] server status: 0 + [meta] server status: + [meta] warning count: 0 + + [meta] no columns + + [meta] no charset + + [data] no rows + + [end] server status: 1 + [end] server status: IN_TRANS + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +[CS_BINARY_REPRESENTATION] + [meta] rows: 0 + [meta] cols: 0 + [meta] server status: 0 + [meta] server status: + [meta] warning count: 0 + + [meta] no columns + + [meta] no charset + + [data] no rows + + [end] server status: 1 + [end] server status: IN_TRANS + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +------------------------------------------------------------------ +EXECUTING:[9][SELECT @b] +[CS_TEXT_REPRESENTATION] + [meta] rows: 1 + [meta] cols: 1 + [meta] server status: 1 + [meta] server status: IN_TRANS + [meta] warning count: 0 + + [meta][field] db name: + [meta][field] table name: + [meta][field] org table name: + [meta][field] col name: @b + [meta][field] org col name: + [meta][field] length: 21 + [meta][field] charsetnr: 33 + [meta][field] flags: 128 (BINARY ) + [meta][field] decimals: 0 + [meta][field] type: LONGLONG (8) + + + [meta][charset result] number: 33 + [meta][charset result] name: utf8mb3 + [meta][charset result] collation: utf8_general_ci + [meta][charset result] sort order: + + [data][.@b][ 2][42] + + [end] server status: 1 + [end] server status: IN_TRANS + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +[CS_BINARY_REPRESENTATION] + [meta] rows: 1 + [meta] cols: 1 + [meta] server status: 1 + [meta] server status: IN_TRANS + [meta] warning count: 0 + + [meta][field] db name: + [meta][field] table name: + [meta][field] org table name: + [meta][field] col name: @b + [meta][field] org col name: + [meta][field] length: 21 + [meta][field] charsetnr: 33 + [meta][field] flags: 128 (BINARY ) + [meta][field] decimals: 0 + [meta][field] type: LONGLONG (8) + + + [meta][charset result] number: 33 + [meta][charset result] name: utf8mb3 + [meta][charset result] collation: utf8_general_ci + [meta][charset result] sort order: + + [data][.@b][ 2][42] + + [end] server status: 1 + [end] server status: IN_TRANS + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +------------------------------------------------------------------ +EXECUTING:[20][SELECT @non_existing] +[CS_TEXT_REPRESENTATION] + [meta] rows: 1 + [meta] cols: 1 + [meta] server status: 1 + [meta] server status: IN_TRANS + [meta] warning count: 0 + + [meta][field] db name: + [meta][field] table name: + [meta][field] org table name: + [meta][field] col name: @non_existing + [meta][field] org col name: + [meta][field] length: 65535 + [meta][field] charsetnr: 33 + [meta][field] flags: 128 (BINARY ) + [meta][field] decimals: 31 + [meta][field] type: VARCHAR (15) + + + [meta][charset result] number: 33 + [meta][charset result] name: utf8mb3 + [meta][charset result] collation: utf8_general_ci + [meta][charset result] sort order: + + [data][.@non_existing][ 6][[NULL]] + + [end] server status: 1 + [end] server status: IN_TRANS + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +[CS_BINARY_REPRESENTATION] + [meta] rows: 1 + [meta] cols: 1 + [meta] server status: 1 + [meta] server status: IN_TRANS + [meta] warning count: 0 + + [meta][field] db name: + [meta][field] table name: + [meta][field] org table name: + [meta][field] col name: @non_existing + [meta][field] org col name: + [meta][field] length: 65535 + [meta][field] charsetnr: 33 + [meta][field] flags: 128 (BINARY ) + [meta][field] decimals: 31 + [meta][field] type: VARCHAR (15) + + + [meta][charset result] number: 33 + [meta][charset result] name: utf8mb3 + [meta][charset result] collation: utf8_general_ci + [meta][charset result] sort order: + + [data][.@non_existing][ 6][[NULL]] + + [end] server status: 1 + [end] server status: IN_TRANS + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +------------------------------------------------------------------ +EXECUTING:[0][] +[CS_TEXT_REPRESENTATION] +[1065][42000][Query was empty] [meta] rows: 0 + [meta] cols: 0 + [meta] server status: 0 + [meta] server status: + [meta] warning count: 0 + + [meta] no columns + + [meta] no charset + + [data] no rows + + [end] server status: 0 + [end] server status: + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +[CS_BINARY_REPRESENTATION] +[1065][42000][Query was empty] [meta] rows: 0 + [meta] cols: 0 + [meta] server status: 0 + [meta] server status: + [meta] warning count: 0 + + [meta] no columns + + [meta] no charset + + [data] no rows + + [end] server status: 0 + [end] server status: + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +------------------------------------------------------------------ +EXECUTING:[14][DROP TABLE tbl] +[CS_TEXT_REPRESENTATION] + [meta] rows: 0 + [meta] cols: 0 + [meta] server status: 0 + [meta] server status: + [meta] warning count: 0 + + [meta] no columns + + [meta] no charset + + [data] no rows + + [end] server status: 0 + [end] server status: + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +------------------------------------------------------------------ +EXECUTING:[15][DROP TABLE tbld] +[CS_TEXT_REPRESENTATION] + [meta] rows: 0 + [meta] cols: 0 + [meta] server status: 0 + [meta] server status: + [meta] warning count: 0 + + [meta] no columns + + [meta] no charset + + [data] no rows + + [end] server status: 0 + [end] server status: + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +------------------------------------------------------------------ +EXECUTING:[19][DROP DATABASE test1] +[CS_TEXT_REPRESENTATION] + [meta] rows: 0 + [meta] cols: 0 + [meta] server status: 0 + [meta] server status: + [meta] warning count: 0 + + [meta] no columns + + [meta] no charset + + [data] no rows + + [end] server status: 256 + [end] server status: DB_DROPPED + [end] warning count: 0 + [end] affected rows: 1 + [end] last insert id: 0 + [end] message: +------------------------------------------------------------------ +[srv_session_close] +deinit thread +------ cleanup --------------------------------------------------- diff --git a/mysql-test/suite/transaction_nested_events.result-pq b/mysql-test/suite/transaction_nested_events.result-pq new file mode 100644 index 000000000000..46e53c604a0e --- /dev/null +++ b/mysql-test/suite/transaction_nested_events.result-pq @@ -0,0 +1,674 @@ + +#======================================================================== +# STEP 1 - SETUP +#======================================================================== + +## Setup control thread + +SET SESSION AUTOCOMMIT= 1; +USE test; +DROP DATABASE IF EXISTS db; + +## Create test database, test tables, one transactional and one non-transactional +CREATE DATABASE db; +CREATE TABLE db.t1 (s1 int, s2 varchar(64)) ENGINE=INNODB; +CREATE TABLE db.nt1 (s1 int, s2 varchar(64)) ENGINE=MYISAM; +CREATE PROCEDURE db.tp_update() UPDATE t1 SET s1 = s1 + 1; +CREATE PROCEDURE db.tp_start() START TRANSACTION; +CREATE PROCEDURE db.tp_rollback() ROLLBACK; +CREATE PROCEDURE db.tp_commit() COMMIT; +CREATE FUNCTION db.fn_add(x INT, y INT) RETURNS INT +BEGIN +INSERT INTO t1 VALUES (x, "INSERT x"),(y, "INSERT y"); +RETURN x+y; +END | + +## Warm-up data-dictionary cache. + +## Setup connection 1 +USE db; +SET SESSION AUTOCOMMIT = 1; +SELECT thread_id INTO @my_thread_id +FROM performance_schema.threads +WHERE processlist_id = connection_id(); + +## Disable events from the control (default) connection +UPDATE performance_schema.threads SET instrumented = 'NO' WHERE processlist_id = CONNECTION_ID(); +SET @all_threads= 0; + +## Enable only transaction and statement instruments +UPDATE performance_schema.setup_instruments SET enabled='NO', timed='NO'; +UPDATE performance_schema.setup_instruments SET enabled='YES' + WHERE name LIKE ('statement/%') OR name = 'transaction'; + +## Clear statement and transaction history +CALL test.clear_history(); + +#======================================================================== +# STEP 2 - BASIC TRANSACTION +#======================================================================== +# +# STEP 2.1 - IMPLICIT +# +INSERT INTO t1 VALUES (210, "INSERT 210"); +INSERT INTO t1 VALUES (211, "INSERT 211"); +INSERT INTO t1 VALUES (212, "INSERT 212"); +UPDATE t1 SET s1 = s1 + 1 WHERE s1 = 212; +#======================================================================== +# Verify +#======================================================================== +EVENTS_TRANSACTIONS_CURRENT + +THREAD_ID R_EVENT_ID R_END_EVENT_ID EVENT_NAME STATE ACCESS_MODE ISOLATION_LEVEL AUTO R_NESTING_EVENT_ID NESTING_EVENT_TYPE +thread_id 8 8 transaction COMMITTED READ WRITE REPEATABLE READ YES 7 STATEMENT + +EVENTS_TRANSACTIONS_HISTORY_LONG + +THREAD_ID R_EVENT_ID R_END_EVENT_ID EVENT_NAME STATE ACCESS_MODE ISOLATION_LEVEL AUTO R_NESTING_EVENT_ID NESTING_EVENT_TYPE +thread_id 2 2 transaction COMMITTED READ WRITE REPEATABLE READ YES 1 STATEMENT +thread_id 4 4 transaction COMMITTED READ WRITE REPEATABLE READ YES 3 STATEMENT +thread_id 6 6 transaction COMMITTED READ WRITE REPEATABLE READ YES 5 STATEMENT +thread_id 8 8 transaction COMMITTED READ WRITE REPEATABLE READ YES 7 STATEMENT + +EVENTS_STATEMENTS_HISTORY_LONG + +THREAD_ID R_EVENT_ID R_END_EVENT_ID EVENT_NAME OBJECT_NAME R_NESTING_EVENT_ID NESTING_EVENT_TYPE LEVEL SQL_TEXT +thread_id 1 2 statement/sql/insert NULL NULL NULL 0 INSERT INTO t1 VALUES (210, "INSERT 210") +thread_id 3 4 statement/sql/insert NULL NULL NULL 0 INSERT INTO t1 VALUES (211, "INSERT 211") +thread_id 5 6 statement/sql/insert NULL NULL NULL 0 INSERT INTO t1 VALUES (212, "INSERT 212") +thread_id 7 8 statement/sql/update NULL NULL NULL 0 UPDATE t1 SET s1 = s1 + 1 WHERE s1 = 212 + +## Combined statement and transaction event history ordered by event id + +EVENTS_STATEMENTS_HISTORY_LONG + EVENTS_TRANSACTIONS_HISTORY_LONG + +THREAD_ID R_EVENT_ID R_END_EVENT_ID EVENT_NAME R_NESTING_EVENT_ID NESTING_EVENT_TYPE SQL_TXT +thread_id 1 2 statement/sql/insert NULL NULL INSERT INTO t1 VALUES (210, "INSERT 210") +thread_id 2 2 transaction 1 STATEMENT +thread_id 3 4 statement/sql/insert NULL NULL INSERT INTO t1 VALUES (211, "INSERT 211") +thread_id 4 4 transaction 3 STATEMENT +thread_id 5 6 statement/sql/insert NULL NULL INSERT INTO t1 VALUES (212, "INSERT 212") +thread_id 6 6 transaction 5 STATEMENT +thread_id 7 8 statement/sql/update NULL NULL UPDATE t1 SET s1 = s1 + 1 WHERE s1 = 212 +thread_id 8 8 transaction 7 STATEMENT + +## Clear statement and transaction history +CALL test.clear_history(); +## Reset db.t1 +DELETE FROM db.t1; + +# +# STEP 2.2 - EXPLICIT +# +START TRANSACTION; +INSERT INTO t1 VALUES (220, "INSERT 220"), (221, "INSERT 221"); +UPDATE t1 SET s2 = "UPDATE 221" WHERE s1 = 221; +COMMIT; +#======================================================================== +# Verify +#======================================================================== +EVENTS_TRANSACTIONS_CURRENT + +THREAD_ID R_EVENT_ID R_END_EVENT_ID EVENT_NAME STATE ACCESS_MODE ISOLATION_LEVEL AUTO R_NESTING_EVENT_ID NESTING_EVENT_TYPE +thread_id 2 5 transaction COMMITTED READ WRITE REPEATABLE READ NO 1 STATEMENT + +EVENTS_TRANSACTIONS_HISTORY_LONG + +THREAD_ID R_EVENT_ID R_END_EVENT_ID EVENT_NAME STATE ACCESS_MODE ISOLATION_LEVEL AUTO R_NESTING_EVENT_ID NESTING_EVENT_TYPE +thread_id 2 5 transaction COMMITTED READ WRITE REPEATABLE READ NO 1 STATEMENT + +EVENTS_STATEMENTS_HISTORY_LONG + +THREAD_ID R_EVENT_ID R_END_EVENT_ID EVENT_NAME OBJECT_NAME R_NESTING_EVENT_ID NESTING_EVENT_TYPE LEVEL SQL_TEXT +thread_id 1 2 statement/sql/begin NULL NULL NULL 0 START TRANSACTION +thread_id 3 3 statement/sql/insert NULL 2 TRANSACTION 0 INSERT INTO t1 VALUES (220, "INSERT 220"), (221, "INSERT 221") +thread_id 4 4 statement/sql/update NULL 2 TRANSACTION 0 UPDATE t1 SET s2 = "UPDATE 221" WHERE s1 = 221 +thread_id 5 5 statement/sql/commit NULL 2 TRANSACTION 0 COMMIT + +## Combined statement and transaction event history ordered by event id + +EVENTS_STATEMENTS_HISTORY_LONG + EVENTS_TRANSACTIONS_HISTORY_LONG + +THREAD_ID R_EVENT_ID R_END_EVENT_ID EVENT_NAME R_NESTING_EVENT_ID NESTING_EVENT_TYPE SQL_TXT +thread_id 1 2 statement/sql/begin NULL NULL START TRANSACTION +thread_id 2 5 transaction 1 STATEMENT +thread_id 3 3 statement/sql/insert 2 TRANSACTION INSERT INTO t1 VALUES (220, "INSERT 220"), (221, "INSERT 221") +thread_id 4 4 statement/sql/update 2 TRANSACTION UPDATE t1 SET s2 = "UPDATE 221" WHERE s1 = 221 +thread_id 5 5 statement/sql/commit 2 TRANSACTION COMMIT + +## Clear statement and transaction history +CALL test.clear_history(); +## Reset db.t1 +DELETE FROM db.t1; + +#======================================================================== +# STEP 3 - TRANSACTIONS AND STORED PROCEDURES +#======================================================================== +# +# STEP 3.1 - STORED PROCEDURE STARTED WITHIN TRANSACTION +# + +START TRANSACTION; +INSERT INTO t1 VALUES (310, "INSERT 310"); +INSERT INTO t1 VALUES (311, "INSERT 311"); +INSERT INTO t1 VALUES (312, "INSERT 312"); +INSERT INTO t1 VALUES (313, "INSERT 313"); +CALL tp_update(); +COMMIT; +#======================================================================== +# Verify +#======================================================================== +EVENTS_TRANSACTIONS_CURRENT + +THREAD_ID R_EVENT_ID R_END_EVENT_ID EVENT_NAME STATE ACCESS_MODE ISOLATION_LEVEL AUTO R_NESTING_EVENT_ID NESTING_EVENT_TYPE +thread_id 2 9 transaction COMMITTED READ WRITE REPEATABLE READ NO 1 STATEMENT + +EVENTS_TRANSACTIONS_HISTORY_LONG + +THREAD_ID R_EVENT_ID R_END_EVENT_ID EVENT_NAME STATE ACCESS_MODE ISOLATION_LEVEL AUTO R_NESTING_EVENT_ID NESTING_EVENT_TYPE +thread_id 2 9 transaction COMMITTED READ WRITE REPEATABLE READ NO 1 STATEMENT + +EVENTS_STATEMENTS_HISTORY_LONG + +THREAD_ID R_EVENT_ID R_END_EVENT_ID EVENT_NAME OBJECT_NAME R_NESTING_EVENT_ID NESTING_EVENT_TYPE LEVEL SQL_TEXT +thread_id 1 2 statement/sql/begin NULL NULL NULL 0 START TRANSACTION +thread_id 3 3 statement/sql/insert NULL 2 TRANSACTION 0 INSERT INTO t1 VALUES (310, "INSERT 310") +thread_id 4 4 statement/sql/insert NULL 2 TRANSACTION 0 INSERT INTO t1 VALUES (311, "INSERT 311") +thread_id 5 5 statement/sql/insert NULL 2 TRANSACTION 0 INSERT INTO t1 VALUES (312, "INSERT 312") +thread_id 6 6 statement/sql/insert NULL 2 TRANSACTION 0 INSERT INTO t1 VALUES (313, "INSERT 313") +thread_id 7 8 statement/sql/call_procedure NULL 2 TRANSACTION 0 CALL tp_update() +thread_id 8 8 statement/sp/stmt tp_update 7 STATEMENT 1 UPDATE t1 SET s1 = s1 + 1 +thread_id 9 9 statement/sql/commit NULL 2 TRANSACTION 0 COMMIT + +## Combined statement and transaction event history ordered by event id + +EVENTS_STATEMENTS_HISTORY_LONG + EVENTS_TRANSACTIONS_HISTORY_LONG + +THREAD_ID R_EVENT_ID R_END_EVENT_ID EVENT_NAME R_NESTING_EVENT_ID NESTING_EVENT_TYPE SQL_TXT +thread_id 1 2 statement/sql/begin NULL NULL START TRANSACTION +thread_id 2 9 transaction 1 STATEMENT +thread_id 3 3 statement/sql/insert 2 TRANSACTION INSERT INTO t1 VALUES (310, "INSERT 310") +thread_id 4 4 statement/sql/insert 2 TRANSACTION INSERT INTO t1 VALUES (311, "INSERT 311") +thread_id 5 5 statement/sql/insert 2 TRANSACTION INSERT INTO t1 VALUES (312, "INSERT 312") +thread_id 6 6 statement/sql/insert 2 TRANSACTION INSERT INTO t1 VALUES (313, "INSERT 313") +thread_id 7 8 statement/sql/call_proced 2 TRANSACTION CALL tp_update() +thread_id 8 8 statement/sp/stmt 7 STATEMENT UPDATE t1 SET s1 = s1 + 1 +thread_id 9 9 statement/sql/commit 2 TRANSACTION COMMIT + +## Clear statement and transaction history +CALL test.clear_history(); +## Reset db.t1 +DELETE FROM db.t1; + +# +# STEP 3.2 - TRANSACTION STARTED WITHIN STORED PROCEDURE +# + +CALL tp_start(); +INSERT INTO t1 VALUES (320, "INSERT 320"),(321, "INSERT 321"); +INSERT INTO t1 VALUES (322, "INSERT 322"),(323, "INSERT 323"); +UPDATE t1 SET s1 = s1 + 1 WHERE s1 > 320; + +SELECT * FROM t1 ORDER BY s1; +s1 s2 +320 INSERT 320 +322 INSERT 321 +323 INSERT 322 +324 INSERT 323 +COMMIT; +#======================================================================== +# Verify +#======================================================================== +EVENTS_TRANSACTIONS_CURRENT + +THREAD_ID R_EVENT_ID R_END_EVENT_ID EVENT_NAME STATE ACCESS_MODE ISOLATION_LEVEL AUTO R_NESTING_EVENT_ID NESTING_EVENT_TYPE +thread_id 8 9 transaction COMMITTED READ WRITE REPEATABLE READ NO 7 STATEMENT + +EVENTS_TRANSACTIONS_HISTORY_LONG + +THREAD_ID R_EVENT_ID R_END_EVENT_ID EVENT_NAME STATE ACCESS_MODE ISOLATION_LEVEL AUTO R_NESTING_EVENT_ID NESTING_EVENT_TYPE +thread_id 8 8 transaction ROLLED BACK READ WRITE REPEATABLE READ NO 7 STATEMENT +thread_id 8 9 transaction COMMITTED READ WRITE REPEATABLE READ NO 7 STATEMENT + +EVENTS_STATEMENTS_HISTORY_LONG + +THREAD_ID R_EVENT_ID R_END_EVENT_ID EVENT_NAME OBJECT_NAME R_NESTING_EVENT_ID NESTING_EVENT_TYPE LEVEL SQL_TEXT +thread_id 1 3 statement/sql/call_procedure NULL NULL NULL 0 CALL tp_start() +thread_id 2 3 statement/sp/stmt tp_start 1 STATEMENT 1 START TRANSACTION +thread_id 4 4 statement/sql/insert NULL 3 TRANSACTION 0 INSERT INTO t1 VALUES (320, "INSERT 320"),(321, "INSERT 321") +thread_id 5 5 statement/sql/insert NULL 3 TRANSACTION 0 INSERT INTO t1 VALUES (322, "INSERT 322"),(323, "INSERT 323") +thread_id 6 6 statement/sql/update NULL 3 TRANSACTION 0 UPDATE t1 SET s1 = s1 + 1 WHERE s1 > 320 +thread_id 7 8 statement/sql/select NULL 3 TRANSACTION 0 SELECT * FROM t1 ORDER BY s1 +thread_id 9 9 statement/sql/commit NULL NULL NULL 0 COMMIT + +## Combined statement and transaction event history ordered by event id + +EVENTS_STATEMENTS_HISTORY_LONG + EVENTS_TRANSACTIONS_HISTORY_LONG + +THREAD_ID R_EVENT_ID R_END_EVENT_ID EVENT_NAME R_NESTING_EVENT_ID NESTING_EVENT_TYPE SQL_TXT +thread_id 1 3 statement/sql/call_proced NULL NULL CALL tp_start() +thread_id 2 3 statement/sp/stmt 1 STATEMENT START TRANSACTION +thread_id 4 4 statement/sql/insert 3 TRANSACTION INSERT INTO t1 VALUES (320, "INSERT 320"),(321, "INSERT 321") +thread_id 5 5 statement/sql/insert 3 TRANSACTION INSERT INTO t1 VALUES (322, "INSERT 322"),(323, "INSERT 323") +thread_id 6 6 statement/sql/update 3 TRANSACTION UPDATE t1 SET s1 = s1 + 1 WHERE s1 > 320 +thread_id 7 8 statement/sql/select 3 TRANSACTION SELECT * FROM t1 ORDER BY s1 +thread_id 8 8 transaction 7 STATEMENT +thread_id 8 9 transaction 7 STATEMENT +thread_id 9 9 statement/sql/commit NULL NULL COMMIT + +## Clear statement and transaction history +CALL test.clear_history(); +## Reset db.t1 +DELETE FROM db.t1; + +# +# STEP 3.3 - TRANSACTION ENDED WITHIN STORED PROCEDURE +# + +## COMMIT within stored procedure +START TRANSACTION; +INSERT INTO t1 VALUES (330, "INSERT 330"),(331, "INSERT 331"); +INSERT INTO t1 VALUES (332, "INSERT 332"),(333, "INSERT 333"); +DELETE FROM t1 WHERE s1 > 331; +CALL tp_commit(); + +SELECT * FROM t1 ORDER BY s1; +s1 s2 +330 INSERT 330 +331 INSERT 331 + +## ROLLBACK within stored procedure +START TRANSACTION; +UPDATE t1 SET s1 = s1*2 WHERE s1 > 331; +CALL tp_rollback(); + +SELECT * FROM t1 ORDER BY s1; +s1 s2 +330 INSERT 330 +331 INSERT 331 +#======================================================================== +# Verify +#======================================================================== +EVENTS_TRANSACTIONS_CURRENT + +THREAD_ID R_EVENT_ID R_END_EVENT_ID EVENT_NAME STATE ACCESS_MODE ISOLATION_LEVEL AUTO R_NESTING_EVENT_ID NESTING_EVENT_TYPE +thread_id 18 18 transaction COMMITTED READ WRITE REPEATABLE READ YES 16 STATEMENT + +EVENTS_TRANSACTIONS_HISTORY_LONG + +THREAD_ID R_EVENT_ID R_END_EVENT_ID EVENT_NAME STATE ACCESS_MODE ISOLATION_LEVEL AUTO R_NESTING_EVENT_ID NESTING_EVENT_TYPE +thread_id 2 7 transaction COMMITTED READ WRITE REPEATABLE READ NO 1 STATEMENT +thread_id 10 10 transaction COMMITTED READ WRITE REPEATABLE READ YES 8 STATEMENT +thread_id 10 10 transaction COMMITTED READ WRITE REPEATABLE READ YES 8 STATEMENT +thread_id 12 15 transaction ROLLED BACK READ WRITE REPEATABLE READ NO 11 STATEMENT +thread_id 18 18 transaction COMMITTED READ WRITE REPEATABLE READ YES 16 STATEMENT +thread_id 18 18 transaction COMMITTED READ WRITE REPEATABLE READ YES 16 STATEMENT + +EVENTS_STATEMENTS_HISTORY_LONG + +THREAD_ID R_EVENT_ID R_END_EVENT_ID EVENT_NAME OBJECT_NAME R_NESTING_EVENT_ID NESTING_EVENT_TYPE LEVEL SQL_TEXT +thread_id 1 2 statement/sql/begin NULL NULL NULL 0 START TRANSACTION +thread_id 3 3 statement/sql/insert NULL 2 TRANSACTION 0 INSERT INTO t1 VALUES (330, "INSERT 330"),(331, "INSERT 331") +thread_id 4 4 statement/sql/insert NULL 2 TRANSACTION 0 INSERT INTO t1 VALUES (332, "INSERT 332"),(333, "INSERT 333") +thread_id 5 5 statement/sql/delete NULL 2 TRANSACTION 0 DELETE FROM t1 WHERE s1 > 331 +thread_id 6 7 statement/sql/call_procedure NULL 2 TRANSACTION 0 CALL tp_commit() +thread_id 7 7 statement/sp/stmt tp_commit 6 STATEMENT 1 COMMIT +thread_id 8 10 statement/sql/select NULL NULL NULL 0 SELECT * FROM t1 ORDER BY s1 +thread_id 11 12 statement/sql/begin NULL NULL NULL 0 START TRANSACTION +thread_id 13 13 statement/sql/update NULL 12 TRANSACTION 0 UPDATE t1 SET s1 = s1*2 WHERE s1 > 331 +thread_id 14 15 statement/sql/call_procedure NULL 12 TRANSACTION 0 CALL tp_rollback() +thread_id 15 15 statement/sp/stmt tp_rollback 14 STATEMENT 1 ROLLBACK +thread_id 16 18 statement/sql/select NULL NULL NULL 0 SELECT * FROM t1 ORDER BY s1 + +## Combined statement and transaction event history ordered by event id + +EVENTS_STATEMENTS_HISTORY_LONG + EVENTS_TRANSACTIONS_HISTORY_LONG + +THREAD_ID R_EVENT_ID R_END_EVENT_ID EVENT_NAME R_NESTING_EVENT_ID NESTING_EVENT_TYPE SQL_TXT +thread_id 1 2 statement/sql/begin NULL NULL START TRANSACTION +thread_id 2 7 transaction 1 STATEMENT +thread_id 3 3 statement/sql/insert 2 TRANSACTION INSERT INTO t1 VALUES (330, "INSERT 330"),(331, "INSERT 331") +thread_id 4 4 statement/sql/insert 2 TRANSACTION INSERT INTO t1 VALUES (332, "INSERT 332"),(333, "INSERT 333") +thread_id 5 5 statement/sql/delete 2 TRANSACTION DELETE FROM t1 WHERE s1 > 331 +thread_id 6 7 statement/sql/call_proced 2 TRANSACTION CALL tp_commit() +thread_id 7 7 statement/sp/stmt 6 STATEMENT COMMIT +thread_id 8 10 statement/sql/select NULL NULL SELECT * FROM t1 ORDER BY s1 +thread_id 10 10 transaction 8 STATEMENT +thread_id 11 12 statement/sql/begin NULL NULL START TRANSACTION +thread_id 12 15 transaction 11 STATEMENT +thread_id 13 13 statement/sql/update 12 TRANSACTION UPDATE t1 SET s1 = s1*2 WHERE s1 > 331 +thread_id 14 15 statement/sql/call_proced 12 TRANSACTION CALL tp_rollback() +thread_id 15 15 statement/sp/stmt 14 STATEMENT ROLLBACK +thread_id 16 18 statement/sql/select NULL NULL SELECT * FROM t1 ORDER BY s1 +thread_id 18 18 transaction 16 STATEMENT + +## Clear statement and transaction history +CALL test.clear_history(); +## Reset db.t1 +DELETE FROM db.t1; + +#======================================================================== +# STEP 4 - TRANSACTIONS AND STORED FUNCTIONS +#======================================================================== + +# +# STEP 4.1 - FUNCTION WITHIN A TRANSACTION +# + +## Clear history +CALL test.clear_history(); + +START TRANSACTION; +INSERT INTO t1 VALUES (410, "INSERT 410"); +INSERT INTO t1 VALUES (411, "INSERT 411"); +INSERT INTO t1 VALUES (412, "INSERT 412"); +DELETE FROM t1 WHERE s1 > 410; + +SELECT * FROM t1 ORDER BY s1; +s1 s2 +410 INSERT 410 + +SELECT fn_add(413, 414); +fn_add(413, 414) +827 +COMMIT; + +SELECT * FROM t1 ORDER BY s1; +s1 s2 +410 INSERT 410 +413 INSERT x +414 INSERT y +#======================================================================== +# Verify +#======================================================================== +EVENTS_TRANSACTIONS_CURRENT + +THREAD_ID R_EVENT_ID R_END_EVENT_ID EVENT_NAME STATE ACCESS_MODE ISOLATION_LEVEL AUTO R_NESTING_EVENT_ID NESTING_EVENT_TYPE +thread_id 15 15 transaction COMMITTED READ WRITE REPEATABLE READ YES 13 STATEMENT + +EVENTS_TRANSACTIONS_HISTORY_LONG + +THREAD_ID R_EVENT_ID R_END_EVENT_ID EVENT_NAME STATE ACCESS_MODE ISOLATION_LEVEL AUTO R_NESTING_EVENT_ID NESTING_EVENT_TYPE +thread_id 8 8 transaction ROLLED BACK READ WRITE REPEATABLE READ NO 7 STATEMENT +thread_id 8 12 transaction COMMITTED READ WRITE REPEATABLE READ NO 7 STATEMENT +thread_id 15 15 transaction COMMITTED READ WRITE REPEATABLE READ YES 13 STATEMENT +thread_id 15 15 transaction COMMITTED READ WRITE REPEATABLE READ YES 13 STATEMENT + +EVENTS_STATEMENTS_HISTORY_LONG + +THREAD_ID R_EVENT_ID R_END_EVENT_ID EVENT_NAME OBJECT_NAME R_NESTING_EVENT_ID NESTING_EVENT_TYPE LEVEL SQL_TEXT +thread_id 1 2 statement/sql/begin NULL NULL NULL 0 START TRANSACTION +thread_id 3 3 statement/sql/insert NULL 2 TRANSACTION 0 INSERT INTO t1 VALUES (410, "INSERT 410") +thread_id 4 4 statement/sql/insert NULL 2 TRANSACTION 0 INSERT INTO t1 VALUES (411, "INSERT 411") +thread_id 5 5 statement/sql/insert NULL 2 TRANSACTION 0 INSERT INTO t1 VALUES (412, "INSERT 412") +thread_id 6 6 statement/sql/delete NULL 2 TRANSACTION 0 DELETE FROM t1 WHERE s1 > 410 +thread_id 7 8 statement/sql/select NULL 2 TRANSACTION 0 SELECT * FROM t1 ORDER BY s1 +thread_id 9 11 statement/sql/select NULL NULL NULL 0 SELECT fn_add(413, 414) +thread_id 10 10 statement/sp/stmt fn_add 9 STATEMENT 1 INSERT INTO t1 VALUES (x, "INSERT x"),(y, "INSERT y") +thread_id 11 11 statement/sp/freturn fn_add 9 STATEMENT 1 NULL +thread_id 12 12 statement/sql/commit NULL NULL NULL 0 COMMIT +thread_id 13 15 statement/sql/select NULL NULL NULL 0 SELECT * FROM t1 ORDER BY s1 + +## Combined statement and transaction event history ordered by event id + +EVENTS_STATEMENTS_HISTORY_LONG + EVENTS_TRANSACTIONS_HISTORY_LONG + +THREAD_ID R_EVENT_ID R_END_EVENT_ID EVENT_NAME R_NESTING_EVENT_ID NESTING_EVENT_TYPE SQL_TXT +thread_id 1 2 statement/sql/begin NULL NULL START TRANSACTION +thread_id 3 3 statement/sql/insert 2 TRANSACTION INSERT INTO t1 VALUES (410, "INSERT 410") +thread_id 4 4 statement/sql/insert 2 TRANSACTION INSERT INTO t1 VALUES (411, "INSERT 411") +thread_id 5 5 statement/sql/insert 2 TRANSACTION INSERT INTO t1 VALUES (412, "INSERT 412") +thread_id 6 6 statement/sql/delete 2 TRANSACTION DELETE FROM t1 WHERE s1 > 410 +thread_id 7 8 statement/sql/select 2 TRANSACTION SELECT * FROM t1 ORDER BY s1 +thread_id 8 8 transaction 7 STATEMENT +thread_id 8 12 transaction 7 STATEMENT +thread_id 9 11 statement/sql/select NULL NULL SELECT fn_add(413, 414) +thread_id 10 10 statement/sp/stmt 9 STATEMENT INSERT INTO t1 VALUES (x, "INSERT x"),(y, "INSERT y") +thread_id 11 11 statement/sp/freturn 9 STATEMENT NULL +thread_id 12 12 statement/sql/commit NULL NULL COMMIT +thread_id 13 15 statement/sql/select NULL NULL SELECT * FROM t1 ORDER BY s1 +thread_id 15 15 transaction 13 STATEMENT + +## Clear statement and transaction history +CALL test.clear_history(); +## Reset db.t1 +DELETE FROM db.t1; + + +## Again, but this time with a rollback + +START TRANSACTION; +SELECT fn_add(415, 416); +fn_add(415, 416) +831 + +ROLLBACK; + +SELECT * FROM t1 ORDER BY s1; +s1 s2 +#======================================================================== +# Verify +#======================================================================== +EVENTS_TRANSACTIONS_CURRENT + +THREAD_ID R_EVENT_ID R_END_EVENT_ID EVENT_NAME STATE ACCESS_MODE ISOLATION_LEVEL AUTO R_NESTING_EVENT_ID NESTING_EVENT_TYPE +thread_id 9 9 transaction COMMITTED READ WRITE REPEATABLE READ YES 7 STATEMENT + +EVENTS_TRANSACTIONS_HISTORY_LONG + +THREAD_ID R_EVENT_ID R_END_EVENT_ID EVENT_NAME STATE ACCESS_MODE ISOLATION_LEVEL AUTO R_NESTING_EVENT_ID NESTING_EVENT_TYPE +thread_id 2 6 transaction ROLLED BACK READ WRITE REPEATABLE READ NO 1 STATEMENT +thread_id 9 9 transaction COMMITTED READ WRITE REPEATABLE READ YES 7 STATEMENT +thread_id 9 9 transaction COMMITTED READ WRITE REPEATABLE READ YES 7 STATEMENT + +EVENTS_STATEMENTS_HISTORY_LONG + +THREAD_ID R_EVENT_ID R_END_EVENT_ID EVENT_NAME OBJECT_NAME R_NESTING_EVENT_ID NESTING_EVENT_TYPE LEVEL SQL_TEXT +thread_id 1 2 statement/sql/begin NULL NULL NULL 0 START TRANSACTION +thread_id 3 5 statement/sql/select NULL 2 TRANSACTION 0 SELECT fn_add(415, 416) +thread_id 4 4 statement/sp/stmt fn_add 3 STATEMENT 1 INSERT INTO t1 VALUES (x, "INSERT x"),(y, "INSERT y") +thread_id 5 5 statement/sp/freturn fn_add 3 STATEMENT 1 NULL +thread_id 6 6 statement/sql/rollback NULL 2 TRANSACTION 0 ROLLBACK +thread_id 7 9 statement/sql/select NULL NULL NULL 0 SELECT * FROM t1 ORDER BY s1 + +## Combined statement and transaction event history ordered by event id + +EVENTS_STATEMENTS_HISTORY_LONG + EVENTS_TRANSACTIONS_HISTORY_LONG + +THREAD_ID R_EVENT_ID R_END_EVENT_ID EVENT_NAME R_NESTING_EVENT_ID NESTING_EVENT_TYPE SQL_TXT +thread_id 1 2 statement/sql/begin NULL NULL START TRANSACTION +thread_id 2 6 transaction 1 STATEMENT +thread_id 3 5 statement/sql/select 2 TRANSACTION SELECT fn_add(415, 416) +thread_id 4 4 statement/sp/stmt 3 STATEMENT INSERT INTO t1 VALUES (x, "INSERT x"),(y, "INSERT y") +thread_id 5 5 statement/sp/freturn 3 STATEMENT NULL +thread_id 6 6 statement/sql/rollback 2 TRANSACTION ROLLBACK +thread_id 7 9 statement/sql/select NULL NULL SELECT * FROM t1 ORDER BY s1 +thread_id 9 9 transaction 7 STATEMENT + +## Clear statement and transaction history +CALL test.clear_history(); +## Reset db.t1 +DELETE FROM db.t1; + +# +# STEP 4.2 - TRANSACTION CANNOT BE STARTED OR ENDED WITHIN FUNCTION +# +CREATE FUNCTION fn_err1() RETURNS VARCHAR(10) BEGIN START TRANSACTION ; RETURN invalid ; END| +ERROR HY000: Explicit or implicit commit is not allowed in stored function or trigger. + +## Expect 0 transactions +SELECT COUNT(*) FROM performance_schema.events_transactions_history; +COUNT(*) +0 + +## Expect stored function does not exist + +SELECT fn_err1(); +ERROR 42000: FUNCTION db.fn_err1 does not exist + +## Expect 0 transactions +SELECT COUNT(*) FROM performance_schema.events_transactions_history; +COUNT(*) +0 + +CREATE FUNCTION fn_err2() RETURNS VARCHAR(10) BEGIN COMMIT; RETURN invalid ; END| +ERROR HY000: Explicit or implicit commit is not allowed in stored function or trigger. + +## Expect stored function does not exist + +START TRANSACTION; +DELETE FROM t1 WHERE s1 > 320; +SELECT fn_err2(); +ERROR 42000: FUNCTION db.fn_err2 does not exist + +## Expect 0 transactions +SELECT COUNT(*) FROM performance_schema.events_transactions_history; +COUNT(*) +0 + +## Clear transaction and statement tables +CALL test.clear_history(); +#======================================================================== +# STEP 5 - TRANSACTIONS AND TRIGGERS +#======================================================================== + +# +# STEP 5.1 - FORCE STATEMENT ROLLBACK FROM TRIGGER +# +## Create a trigger to force statement rollback + +CREATE TRIGGER trigger_before_update BEFORE UPDATE ON t1 +FOR EACH ROW +BEGIN +IF OLD.s1 >= 505 THEN +SIGNAL sqlstate '45001' SET message_text = "FORCE ERROR"; +END IF; +END;| + +## Warm-up data-dictionary cache. + +## Clear history +CALL test.clear_history(); + +## Insert multiple rows, then update. Trigger will force rollback the +## UPDATE statement, but the transaction should not roll back. + +START TRANSACTION; +INSERT INTO t1 VALUES (500, "INSERT 500"); +INSERT INTO t1 VALUES (501, "INSERT 501"); +INSERT INTO t1 VALUES (502, "INSERT 502"); +INSERT INTO t1 VALUES (503, "INSERT 503"); +INSERT INTO t1 VALUES (504, "INSERT 504"); +INSERT INTO t1 VALUES (505, "INSERT 505"); + +SELECT * FROM t1 ORDER BY s1; +s1 s2 +500 INSERT 500 +501 INSERT 501 +502 INSERT 502 +503 INSERT 503 +504 INSERT 504 +505 INSERT 505 + +## Expect error when UPDATE hits record 505 + +UPDATE t1 SET s1 = s1 * 2 WHERE s1 >= 500; +ERROR 45001: FORCE ERROR + +## Verify that INSERT succeeded, UPDATE failed and transaction did not rollback + +SELECT * FROM t1 ORDER BY s1; +s1 s2 +500 INSERT 500 +501 INSERT 501 +502 INSERT 502 +503 INSERT 503 +504 INSERT 504 +505 INSERT 505 +COMMIT; + +DROP TRIGGER trigger_before_update; +#======================================================================== +# Verify +#======================================================================== +EVENTS_TRANSACTIONS_CURRENT + +THREAD_ID R_EVENT_ID R_END_EVENT_ID EVENT_NAME STATE ACCESS_MODE ISOLATION_LEVEL AUTO R_NESTING_EVENT_ID NESTING_EVENT_TYPE +thread_id 23 23 transaction COMMITTED READ WRITE REPEATABLE READ NO 22 STATEMENT + +EVENTS_TRANSACTIONS_HISTORY_LONG + +THREAD_ID R_EVENT_ID R_END_EVENT_ID EVENT_NAME STATE ACCESS_MODE ISOLATION_LEVEL AUTO R_NESTING_EVENT_ID NESTING_EVENT_TYPE +thread_id 10 10 transaction ROLLED BACK READ WRITE REPEATABLE READ NO 9 STATEMENT +thread_id 20 20 transaction ROLLED BACK READ WRITE REPEATABLE READ NO 19 STATEMENT +thread_id 20 21 transaction COMMITTED READ WRITE REPEATABLE READ NO 19 STATEMENT +thread_id 23 23 transaction COMMITTED READ WRITE REPEATABLE READ NO 22 STATEMENT + +EVENTS_STATEMENTS_HISTORY_LONG + +THREAD_ID R_EVENT_ID R_END_EVENT_ID EVENT_NAME OBJECT_NAME R_NESTING_EVENT_ID NESTING_EVENT_TYPE LEVEL SQL_TEXT +thread_id 1 2 statement/sql/begin NULL NULL NULL 0 START TRANSACTION +thread_id 3 3 statement/sql/insert NULL 2 TRANSACTION 0 INSERT INTO t1 VALUES (500, "INSERT 500") +thread_id 4 4 statement/sql/insert NULL 2 TRANSACTION 0 INSERT INTO t1 VALUES (501, "INSERT 501") +thread_id 5 5 statement/sql/insert NULL 2 TRANSACTION 0 INSERT INTO t1 VALUES (502, "INSERT 502") +thread_id 6 6 statement/sql/insert NULL 2 TRANSACTION 0 INSERT INTO t1 VALUES (503, "INSERT 503") +thread_id 7 7 statement/sql/insert NULL 2 TRANSACTION 0 INSERT INTO t1 VALUES (504, "INSERT 504") +thread_id 8 8 statement/sql/insert NULL 2 TRANSACTION 0 INSERT INTO t1 VALUES (505, "INSERT 505") +thread_id 9 10 statement/sql/select NULL 2 TRANSACTION 0 SELECT * FROM t1 ORDER BY s1 +thread_id 11 18 statement/sql/update NULL NULL NULL 0 UPDATE t1 SET s1 = s1 * 2 WHERE s1 >= 500 +thread_id 12 12 statement/sp/jump_if_not trigger_befo 11 STATEMENT 1 NULL +thread_id 13 13 statement/sp/jump_if_not trigger_befo 11 STATEMENT 1 NULL +thread_id 14 14 statement/sp/jump_if_not trigger_befo 11 STATEMENT 1 NULL +thread_id 15 15 statement/sp/jump_if_not trigger_befo 11 STATEMENT 1 NULL +thread_id 16 16 statement/sp/jump_if_not trigger_befo 11 STATEMENT 1 NULL +thread_id 17 17 statement/sp/jump_if_not trigger_befo 11 STATEMENT 1 NULL +thread_id 18 18 statement/sp/stmt trigger_befo 11 STATEMENT 1 SIGNAL sqlstate '45001' SET message_text = "FORCE ERROR" +thread_id 19 20 statement/sql/select NULL NULL NULL 0 SELECT * FROM t1 ORDER BY s1 +thread_id 21 21 statement/sql/commit NULL NULL NULL 0 COMMIT +thread_id 22 23 statement/sql/drop_trigger NULL NULL NULL 0 DROP TRIGGER trigger_before_update + +## Combined statement and transaction event history ordered by event id + +EVENTS_STATEMENTS_HISTORY_LONG + EVENTS_TRANSACTIONS_HISTORY_LONG + +THREAD_ID R_EVENT_ID R_END_EVENT_ID EVENT_NAME R_NESTING_EVENT_ID NESTING_EVENT_TYPE SQL_TXT +thread_id 1 2 statement/sql/begin NULL NULL START TRANSACTION +thread_id 3 3 statement/sql/insert 2 TRANSACTION INSERT INTO t1 VALUES (500, "INSERT 500") +thread_id 4 4 statement/sql/insert 2 TRANSACTION INSERT INTO t1 VALUES (501, "INSERT 501") +thread_id 5 5 statement/sql/insert 2 TRANSACTION INSERT INTO t1 VALUES (502, "INSERT 502") +thread_id 6 6 statement/sql/insert 2 TRANSACTION INSERT INTO t1 VALUES (503, "INSERT 503") +thread_id 7 7 statement/sql/insert 2 TRANSACTION INSERT INTO t1 VALUES (504, "INSERT 504") +thread_id 8 8 statement/sql/insert 2 TRANSACTION INSERT INTO t1 VALUES (505, "INSERT 505") +thread_id 9 10 statement/sql/select 2 TRANSACTION SELECT * FROM t1 ORDER BY s1 +thread_id 10 10 transaction 9 STATEMENT +thread_id 11 18 statement/sql/update NULL NULL UPDATE t1 SET s1 = s1 * 2 WHERE s1 >= 500 +thread_id 12 12 statement/sp/jump_if_not 11 STATEMENT NULL +thread_id 13 13 statement/sp/jump_if_not 11 STATEMENT NULL +thread_id 14 14 statement/sp/jump_if_not 11 STATEMENT NULL +thread_id 15 15 statement/sp/jump_if_not 11 STATEMENT NULL +thread_id 16 16 statement/sp/jump_if_not 11 STATEMENT NULL +thread_id 17 17 statement/sp/jump_if_not 11 STATEMENT NULL +thread_id 18 18 statement/sp/stmt 11 STATEMENT SIGNAL sqlstate '45001' SET message_text = "FORCE ERROR" +thread_id 19 20 statement/sql/select NULL NULL SELECT * FROM t1 ORDER BY s1 +thread_id 20 20 transaction 19 STATEMENT +thread_id 20 21 transaction 19 STATEMENT +thread_id 21 21 statement/sql/commit NULL NULL COMMIT +thread_id 22 23 statement/sql/drop_trigge NULL NULL DROP TRIGGER trigger_before_update +thread_id 23 23 transaction 22 STATEMENT + +## Clear statement and transaction history +CALL test.clear_history(); +## Reset db.t1 +DELETE FROM db.t1; + +# TODO: Detect statement events from scheduled event +#======================================================================= +# Cleanup +#======================================================================= +DROP DATABASE db; +UPDATE performance_schema.setup_instruments SET enabled='YES', timed='YES'; +DROP PROCEDURE clear_transaction_tables; +DROP PROCEDURE clear_transaction_history; +DROP PROCEDURE clear_statement_history; +DROP PROCEDURE clear_history; +DROP PROCEDURE transaction_verifier; diff --git a/sql/handler.cc b/sql/handler.cc index 6d4a8873e8a8..f7f215c86a1c 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -6519,7 +6519,7 @@ int DsMrr_impl::dsmrr_init(RANGE_SEQ_IF *seq_funcs, void *seq_init_param, return retval; } - if (!thd->in_sp_trigger && thd->parallel_exec && + if (thd->in_sp_trigger == 0 && thd->parallel_exec && table->file->pq_range_type != PQ_QUICK_SELECT_NONE) { use_default_impl = true; retval = h->handler::multi_range_read_init(seq_funcs, seq_init_param, diff --git a/sql/join_optimizer/explain_access_path.cc b/sql/join_optimizer/explain_access_path.cc index 2ebf6e073551..468360c5b0aa 100644 --- a/sql/join_optimizer/explain_access_path.cc +++ b/sql/join_optimizer/explain_access_path.cc @@ -807,10 +807,7 @@ ExplainData ExplainAccessPath(const AccessPath *path, JOIN *join) { path->parallel_scan().table->alias + path->parallel_scan().table->file->explain_extra()); Gather_operator *gather = path->parallel_scan().gather; - AccessPath *root_path = gather->m_template_join->m_root_access_path; - root_path = root_path ? root_path - : (gather->m_workers[0] - ->thd_worker->lex->unit->m_root_access_path); + AccessPath *root_path = gather->m_workers[0]->thd_worker->lex->unit->m_root_access_path; children.push_back({root_path, "", gather->m_template_join}); break; } diff --git a/sql/opt_explain.cc b/sql/opt_explain.cc index e755db33eb56..7eb6d78676fa 100644 --- a/sql/opt_explain.cc +++ b/sql/opt_explain.cc @@ -2134,9 +2134,13 @@ static bool ExplainIterator(THD *ethd, const THD *query_thd, default: break; } - explain += PrintQueryPlan(base_level, unit->root_access_path(), + if (ethd->parallel_exec && ethd->lex->is_explain_analyze) { + explain += ethd->pq_explain; + } else { + explain += PrintQueryPlan(base_level, unit->root_access_path(), unit->is_union() ? nullptr : join, /*is_root_of_join=*/!unit->is_union()); + } } else { explain += PrintQueryPlan(0, /*path=*/nullptr, /*join=*/nullptr, /*is_root_of_join=*/false); diff --git a/sql/pq_clone_item.cc b/sql/pq_clone_item.cc index 3dad94c35a62..0aef4f5a043a 100644 --- a/sql/pq_clone_item.cc +++ b/sql/pq_clone_item.cc @@ -420,6 +420,14 @@ Item *Item_view_ref::pq_clone(class THD *thd, class Query_block *select) { } item_ref = &found_table->field_translation[field_index].item; + + const char *db_name; + if (found_table->is_view()) { + db_name = found_table->db; + } else { + db_name = nullptr; + } + item = new (thd->pq_mem_root) Item_view_ref(&select->context, item_ref, db_name, table_name, orig_table_name(), field_name, found_table); @@ -1596,8 +1604,16 @@ PQ_CLONE_RETURN COPY_FUNC_ITEM(Item_typecast_real, ARG0) PQ_CLONE_DEF(Item_func_get_system_var) { - new_item = new (thd->pq_mem_root) Item_func_get_system_var( - var, var_type, &component, item_name.ptr(), item_name.length()); + sys_var *var_arg = var; + + if (var_arg == nullptr) { + var_arg = var_tracker.bind_system_variable(thd); + } + + if (var_arg != nullptr) { + new_item = new (thd->pq_mem_root) Item_func_get_system_var( + var_arg, var_type, &component, item_name.ptr(), item_name.length()); + } } PQ_CLONE_RETURN diff --git a/sql/pq_condition.cc b/sql/pq_condition.cc index 39a680dfca14..a814d4426def 100644 --- a/sql/pq_condition.cc +++ b/sql/pq_condition.cc @@ -695,7 +695,7 @@ void set_pq_condition_status(THD *thd) { } bool suite_for_parallel_query(THD *thd) { - if (thd->in_sp_trigger || // store procedure or trigger + if (thd->in_sp_trigger != 0 || // store procedure or trigger thd->m_attachable_trx || // attachable transaction thd->tx_isolation == ISO_SERIALIZABLE) { // serializable without snapshot read @@ -760,6 +760,13 @@ bool suite_for_parallel_query(Query_block *select) { } } + for (TABLE_LIST *tbl_list = select->table_list.first; tbl_list != nullptr; + tbl_list = tbl_list->next_global) { + if (!suite_for_parallel_query(tbl_list)) { + return false; + } + } + for (TABLE_LIST *tbl_list = select->leaf_tables; tbl_list != nullptr; tbl_list = tbl_list->next_leaf) { if (!suite_for_parallel_query(tbl_list)) { diff --git a/sql/sp_head.cc b/sql/sp_head.cc index 29ed8ec52a7b..f4f4d71a38a6 100644 --- a/sql/sp_head.cc +++ b/sql/sp_head.cc @@ -2490,9 +2490,9 @@ bool sp_head::execute_trigger(THD *thd, const LEX_CSTRING &db_name, locker = MYSQL_START_SP(&psi_state, m_sp_share); #endif // disable paralle query for trigger - thd->in_sp_trigger = true; + thd->in_sp_trigger++; err_status = execute(thd, false); - thd->in_sp_trigger = false; + thd->in_sp_trigger--; #ifdef HAVE_PSI_SP_INTERFACE MYSQL_END_SP(locker); #endif @@ -2671,9 +2671,9 @@ bool sp_head::execute_function(THD *thd, Item **argp, uint argcount, locker = MYSQL_START_SP(&psi_state, m_sp_share); #endif // disable paralle query for store function - thd->in_sp_trigger = true; + thd->in_sp_trigger++; err_status = execute(thd, true); - thd->in_sp_trigger = false; + thd->in_sp_trigger--; #ifdef HAVE_PSI_SP_INTERFACE MYSQL_END_SP(locker); #endif @@ -2876,9 +2876,9 @@ bool sp_head::execute_procedure(THD *thd, mem_root_deque *args) { locker = MYSQL_START_SP(&psi_state, m_sp_share); #endif // disable parallel query for store procedure - thd->in_sp_trigger = true; + thd->in_sp_trigger++; if (!err_status) err_status = execute(thd, true); - thd->in_sp_trigger = false; + thd->in_sp_trigger--; #ifdef HAVE_PSI_SP_INTERFACE MYSQL_END_SP(locker); #endif diff --git a/sql/sql_class.cc b/sql/sql_class.cc index b152ca544935..d4092d955afe 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -412,7 +412,7 @@ THD::THD(bool enable_plugins) pq_threads_running(0), pq_dop(0), no_pq(false), - in_sp_trigger(false), + in_sp_trigger(0), locking_clause(0), pq_error(false), pq_check_fields(0), @@ -1559,7 +1559,7 @@ void THD::cleanup_after_query() { // Set the default "cute" mode for the execution environment: check_for_truncated_fields = CHECK_FIELD_IGNORE; - if (!in_sp_trigger) { + if (in_sp_trigger == 0) { // cleanup for parallel query if (pq_threads_running > 0) { release_pq_running_threads(pq_threads_running); @@ -1572,6 +1572,7 @@ void THD::cleanup_after_query() { locking_clause = 0; pq_error = false; pq_workers.clear(); + pq_explain.clear(); if (killed == THD::KILL_PQ_QUERY) killed.store(THD::NOT_KILLED); // restore killed for next query diff --git a/sql/sql_class.h b/sql/sql_class.h index 5639c51cc703..3815220d1867 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -951,7 +951,7 @@ class THD : public MDL_context_owner, /* disable parallel execute */ bool no_pq; /* disable parallel query for store procedure and trigger */ - bool in_sp_trigger; + uint in_sp_trigger; /* select .. fro share/update */ bool locking_clause; /* indicates whether parallel query is supported */ @@ -972,6 +972,9 @@ class THD : public MDL_context_owner, /* protects THD::pq_workers. */ mysql_mutex_t pq_lock_worker; + /* for explain analyze. */ + std::string pq_explain; + /* Used to execute base64 coded binlog events in MySQL server */ Relay_log_info *rli_fake; /* Slave applier execution context */ diff --git a/sql/sql_parallel.cc b/sql/sql_parallel.cc index dbd991aa12d7..8b03c28c87e8 100644 --- a/sql/sql_parallel.cc +++ b/sql/sql_parallel.cc @@ -47,6 +47,7 @@ #include "sql/sql_tmp_table.h" #include "sql/timing_iterator.h" #include "sql/transaction.h" +#include "sql/join_optimizer/explain_access_path.h" ulonglong parallel_memory_limit = 0; ulong parallel_max_threads = 0; @@ -785,6 +786,14 @@ void *pq_worker_exec(void *arg) { mngr->signal_status(thd, PQ_worker_state::READY); join->query_expression()->ExecuteIteratorQuery(thd); + if (thd->lex->is_explain_analyze && mngr->m_id == 0) { + Query_expression *unit = leader_thd->lex->unit; + leader_thd->pq_explain += PrintQueryPlan( + 0, unit->root_access_path(), + unit->is_union() ? nullptr : unit->first_query_block()->join, + !unit->is_union()); + } + if (join->thd->is_error() || join->thd->pq_error || DBUG_EVALUATE_IF("pq_worker_error3", true, false)) { goto err; @@ -1136,18 +1145,18 @@ bool set_key_order(QEP_TAB *tab, std::vector &key_fields, return false; } - std::map fields_map; // map[field] = item - std::map::iterator iter; - std::vector order_items; + std::map fields_map; // map[field] = item + std::map::iterator iter; + std::vector order_items; - Ref_item_array ref_items = *ref_ptrs; + Ref_item_array &ref_items = *ref_ptrs; /** (1) build the map: {name} -> {item} */ for (uint i = 0; i < join->query_block_fields->size(); i++) { Item *item = ref_items[i]; if (item && item->type() == Item::FIELD_ITEM) { std::string field_name = static_cast(item)->field->field_name; - fields_map[field_name] = item; + fields_map[field_name] = &ref_items[i]; } } @@ -1163,15 +1172,15 @@ bool set_key_order(QEP_TAB *tab, std::vector &key_fields, THD *thd = join->thd; SQL_I_List order_list; - for (Item *item : order_items) { + for (Item **item : order_items) { ORDER *order = new (thd->pq_mem_root) ORDER(); if (!order) { *order_ptr = NULL; return true; } - order->item_initial = item; - order->item = &item; + order->item_initial = *item; + order->item = item; order->in_field_list = 1; order->is_explicit = 0; add_to_list(order_list, order); diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 87afc8cd4821..c4110b07cc96 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -3741,7 +3741,7 @@ bool JOIN::make_pq_tables_info() { in tmplist, which we call it sum_field that use for recieving PQ workers's sum data. */ table = create_tmp_table(thd, tmp_param, *curr_fields, nullptr, false, true, - query_block->active_options(), HA_POS_ERROR, "", true); + query_block->active_options(), HA_POS_ERROR, "", true, true); query_result->m_table = table; // the leader/worker's table is not same @@ -4409,7 +4409,7 @@ bool JOIN::make_leader_tables_info() { */ TABLE *table = create_tmp_table(thd, tmp_param, tmplist, nullptr, false, true, - query_block->active_options(), HA_POS_ERROR, "", true); + query_block->active_options(), HA_POS_ERROR, "", true, true); if (table == nullptr) { DBUG_RETURN(true); } table->materialized= false; tmp_tables = 1; diff --git a/sql/sql_tmp_table.cc b/sql/sql_tmp_table.cc index 761be4ef2352..a166910b8e9c 100644 --- a/sql/sql_tmp_table.cc +++ b/sql/sql_tmp_table.cc @@ -904,7 +904,8 @@ TABLE *create_tmp_table(THD *thd, Temp_table_param *param, const mem_root_deque &fields, ORDER *group, bool distinct, bool save_sum_fields, ulonglong select_options, ha_rows rows_limit, - const char *table_alias, bool force_disk_table) { + const char *table_alias, bool force_disk_table, + bool parallel_query) { DBUG_TRACE; if (!param->allow_group_via_temp_table) group = nullptr; // Can't use group key @@ -1065,10 +1066,13 @@ TABLE *create_tmp_table(THD *thd, Temp_table_param *param, if (param->m_window == nullptr || !param->m_window->is_last()) store_column = false; } - if (item->const_item() && (int)hidden_field_count <= 0) { - // mark this item and then we can identify it without sending a message to MQ. - item->skip_create_tmp_table = true; - continue; // We don't have to store this + + if (item->const_item()) { + if (parallel_query || (int)hidden_field_count <= 0) { + // mark this item and then we can identify it without sending a message to MQ. + item->skip_create_tmp_table = true; + continue; // We don't have to store this + } } } diff --git a/sql/sql_tmp_table.h b/sql/sql_tmp_table.h index 82138650286f..16338aa00b69 100644 --- a/sql/sql_tmp_table.h +++ b/sql/sql_tmp_table.h @@ -56,7 +56,8 @@ TABLE *create_tmp_table(THD *thd, Temp_table_param *param, const mem_root_deque &fields, ORDER *group, bool distinct, bool save_sum_fields, ulonglong select_options, ha_rows rows_limit, - const char *table_alias, bool force_disk_table = false); + const char *table_alias, bool force_disk_table = false, + bool parallel_query = false); bool open_tmp_table(TABLE *table); TABLE *create_tmp_table_from_fields(THD *thd, List &field_list, bool is_virtual = true,